From 875dfd5d4b32a05d200e3f6e0b8a738cb1381d7e Mon Sep 17 00:00:00 2001 From: lh <3191213465@qq.com> Date: Fri, 22 May 2026 15:05:04 +0800 Subject: [PATCH] =?UTF-8?q?[9.1]=209.1=E9=A6=96=E7=89=88=E4=B8=80=E5=9B=9E?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=9F=BA=E7=BA=BF=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 1 + TSCP/Makefile | 161 + TSCP/src/APP/APP_API.c | 797 + TSCP/src/APP/APP_API.h | 114 + .../ci_integrate_config.h | 35 + TSCP/src/APP/ProtclParam.h | 17 + .../APP/ciapp/2oo2/2oo2DataTransferManage.c | 1799 ++ .../APP/ciapp/2oo2/2oo2DataTransferManage.h | 195 + .../APP/ciapp/2oo2/2oo2InterfaceDataManage.c | 1176 + .../APP/ciapp/2oo2/2oo2InterfaceDataManage.h | 416 + .../AllAutoReturnConfigDataManage.c | 385 + .../AllAutoReturnConfigDataManage.h | 195 + .../AllAutoReturn/AllAutoReturnDataManage.c | 114 + .../AllAutoReturn/AllAutoReturnDataManage.h | 61 + .../ciapp/AllAutoReturn/AllAutoReturnDefine.h | 45 + .../AutoReturn/AutoReturnConfigDataManage.c | 328 + .../AutoReturn/AutoReturnConfigDataManage.h | 165 + .../ciapp/AutoReturn/AutoReturnDataManage.c | 115 + .../ciapp/AutoReturn/AutoReturnDataManage.h | 60 + .../APP/ciapp/AutoReturn/AutoReturnDefine.h | 45 + .../AutoRoute/AutoRouteConfigDataManage.c | 364 + .../AutoRoute/AutoRouteConfigDataManage.h | 193 + .../APP/ciapp/AutoRoute/AutoRouteDataManage.c | 113 + .../APP/ciapp/AutoRoute/AutoRouteDataManage.h | 65 + .../src/APP/ciapp/AutoRoute/AutoRouteDefine.h | 42 + .../ciapp/AxisAssert/AxisAssertDataPrepare.c | 601 + .../ciapp/AxisAssert/AxisAssertDataPrepare.h | 268 + .../APP/ciapp/AxisAssert/AxisAssertDefine.h | 66 + .../APP/ciapp/AxisAssert/AxisAssertManage.c | 593 + .../APP/ciapp/AxisAssert/AxisAssertManage.h | 248 + .../ciapp/AxisAssert/AxisAssertManageAPI.c | 2057 ++ .../ciapp/AxisAssert/AxisAssertManageAPI.h | 216 + TSCP/src/APP/ciapp/AxisSort/AxisSort.c | 2457 ++ TSCP/src/APP/ciapp/AxisSort/AxisSort.h | 52 + TSCP/src/APP/ciapp/AxisSort/AxisSort_api.h | 223 + TSCP/src/APP/ciapp/AxisSort/AxisSort_define.h | 52 + .../CutoffPoint/CutoffPointConfigDataManage.c | 503 + .../CutoffPoint/CutoffPointConfigDataManage.h | 147 + .../ciapp/CutoffPoint/CutoffPointDataManage.c | 1634 + .../ciapp/CutoffPoint/CutoffPointDataManage.h | 358 + .../APP/ciapp/CutoffPoint/CutoffPointDefine.h | 20 + .../ciapp/DataManage/DeviceConfigDataManage.c | 317 + .../ciapp/DataManage/DeviceConfigDataManage.h | 128 + .../APP/ciapp/DataManage/DeviceDataManage.c | 11117 +++++++ .../APP/ciapp/DataManage/DeviceDataManage.h | 1827 ++ .../src/APP/ciapp/DataManage/PlatDataManage.c | 674 + .../src/APP/ciapp/DataManage/PlatDataManage.h | 280 + TSCP/src/APP/ciapp/DebugPrint/DebugPrint.c | 81 + TSCP/src/APP/ciapp/DebugPrint/DebugPrint.h | 55 + .../ciapp/DebugPrint/DebugPrintInterface.h | 13 + TSCP/src/APP/ciapp/DebugPrint/ErrorCode.h | 45 + .../APP/ciapp/DebugPrint/ErrorDeviceType.h | 17 + TSCP/src/APP/ciapp/Deployment/Deployment.c | 959 + TSCP/src/APP/ciapp/Deployment/Deployment.h | 100 + .../APP/ciapp/Deployment/DeploymentExtern.h | 101 + .../DiffLineDev/DiffLineDevConfigDataManage.c | 81 + .../DiffLineDev/DiffLineDevConfigDataManage.h | 72 + .../APP/ciapp/DiffLineDev/DiffLineDevDefine.h | 43 + TSCP/src/APP/ciapp/ERROR/ErrorDataManage.c | 254 + TSCP/src/APP/ciapp/ERROR/ErrorDataManage.h | 120 + TSCP/src/APP/ciapp/ERROR/ErrorDefine.h | 407 + TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.c | 665 + TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.h | 300 + TSCP/src/APP/ciapp/ESB/ESBDataManage.c | 800 + TSCP/src/APP/ciapp/ESB/ESBDataManage.h | 317 + TSCP/src/APP/ciapp/ESB/ESBDefine.h | 62 + .../ciapp/EnvelopeManage/CTEnvelopeTrack.c | 1574 + .../APP/ciapp/EnvelopeManage/ELMDataPrepare.c | 2575 ++ .../APP/ciapp/EnvelopeManage/ELMDataPrepare.h | 801 + .../APP/ciapp/EnvelopeManage/EnvelopeDefine.h | 155 + .../EnvelopeManage/EnvelopeLogicProcess.c | 3233 ++ .../EnvelopeManage/EnvelopeLogicProcess.h | 489 + .../APP/ciapp/EnvelopeManage/EnvelopeManage.c | 1493 + .../APP/ciapp/EnvelopeManage/EnvelopeManage.h | 447 + .../ciapp/EnvelopeManage/EnvelopeManageAPI.c | 1203 + .../ciapp/EnvelopeManage/EnvelopeManageAPI.h | 234 + .../APP/ciapp/EnvelopeManage/EnvelopeScreen.c | 688 + .../ciapp/EnvelopeManage/UCTEnvelopeTrack.c | 3921 +++ .../ciapp/EnvelopeManage/UKTEnvelopeTrack.c | 186 + .../FloodGate/FloodGateConfigDataManage.c | 492 + .../FloodGate/FloodGateConfigDataManage.h | 225 + .../APP/ciapp/FloodGate/FloodGateDataManage.c | 755 + .../APP/ciapp/FloodGate/FloodGateDataManage.h | 294 + .../src/APP/ciapp/FloodGate/FloodGateDefine.h | 68 + .../Garagedoor/GaragedoorConfigDataManage.c | 679 + .../Garagedoor/GaragedoorConfigDataManage.h | 296 + .../ciapp/Garagedoor/GaragedoorDataManage.c | 1261 + .../ciapp/Garagedoor/GaragedoorDataManage.h | 387 + .../APP/ciapp/Garagedoor/GaragedoorDefine.h | 59 + .../HLHTMsgHead/HLHTCommonDataPacketHead.c | 369 + .../HLHTMsgHead/HLHTCommonDataPacketHead.h | 113 + .../ciapp/HLHTMsgHead/HLHTHeadContexManage.c | 1185 + .../ciapp/HLHTMsgHead/HLHTHeadContexManage.h | 293 + .../src/APP/ciapp/IO/DeviceRelayDataProcess.c | 15130 +++++++++ .../src/APP/ciapp/IO/DeviceRelayDataProcess.h | 860 + TSCP/src/APP/ciapp/IO/InputDataProcess.c | 12202 ++++++++ TSCP/src/APP/ciapp/IO/InputDataProcess.h | 458 + TSCP/src/APP/ciapp/IO/OutputDataProcess.c | 8540 +++++ TSCP/src/APP/ciapp/IO/OutputDataProcess.h | 463 + .../Indicator/IndicatorConfigDataManage.c | 459 + .../Indicator/IndicatorConfigDataManage.h | 192 + .../APP/ciapp/Indicator/IndicatorDataManage.c | 127 + .../APP/ciapp/Indicator/IndicatorDataManage.h | 99 + .../src/APP/ciapp/Indicator/IndicatorDefine.h | 201 + .../APP/ciapp/Initial/ConfigDataReadManage.c | 3429 ++ .../APP/ciapp/Initial/ConfigDataReadManage.h | 167 + TSCP/src/APP/ciapp/Initial/InitialProcess.c | 3195 ++ TSCP/src/APP/ciapp/Initial/InitialProcess.h | 337 + .../InvadeSectionConfigDataManage.c | 214 + .../InvadeSectionConfigDataManage.h | 118 + .../InvadeSection/InvadeSectionDataManage.c | 14 + .../InvadeSection/InvadeSectionDataManage.h | 34 + .../ciapp/InvadeSection/InvadeSectionDefine.h | 24 + TSCP/src/APP/ciapp/LogRecord/LogRecord.c | 2915 ++ TSCP/src/APP/ciapp/LogRecord/LogRecord.h | 193 + .../ciapp/LogicManage/InterlockCommonManage.c | 5662 ++++ .../ciapp/LogicManage/InterlockCommonManage.h | 535 + .../ciapp/LogicManage/InterlockLogicManage.c | 15934 ++++++++++ .../ciapp/LogicManage/InterlockLogicManage.h | 1138 + .../ciapp/LogicManage/RouteRecoverManage.c | 4881 +++ .../ciapp/LogicManage/RouteRecoverManage.h | 179 + .../LogicManage/TradInterlockLogicManage.c | 7345 +++++ .../LogicManage/TradInterlockLogicManage.h | 861 + .../ciapp/LogicProcess/InterlockLogicCheck.c | 25890 ++++++++++++++++ .../ciapp/LogicProcess/InterlockLogicCheck.h | 2723 ++ .../LogicProcess/InterlockLogicProcess.c | 12646 ++++++++ .../LogicProcess/InterlockLogicProcess.h | 830 + .../LogicProcess/LogicalRouteLogicCheck.c | 3968 +++ .../LogicProcess/LogicalRouteLogicCheck.h | 526 + .../LogicProcess/TradInterlockLogicProcess.c | 4401 +++ .../LogicProcess/TradInterlockLogicProcess.h | 385 + TSCP/src/APP/ciapp/Main/MainApp.c | 162 + TSCP/src/APP/ciapp/Main/MainApp.h | 60 + .../src/APP/ciapp/Mask/MaskConfigDataManage.c | 415 + .../src/APP/ciapp/Mask/MaskConfigDataManage.h | 158 + TSCP/src/APP/ciapp/Mask/MaskDefine.h | 225 + .../NonAutoReturnConfigDataManage.c | 268 + .../NonAutoReturnConfigDataManage.h | 135 + .../NonAutoReturn/NonAutoReturnDataManage.c | 363 + .../NonAutoReturn/NonAutoReturnDataManage.h | 169 + .../ciapp/NonAutoReturn/NonAutoReturnDefine.h | 24 + .../ciapp/NonRoute/NonRouteConfigDataManage.c | 546 + .../ciapp/NonRoute/NonRouteConfigDataManage.h | 275 + .../APP/ciapp/NonRoute/NonRouteDataManage.c | 388 + .../APP/ciapp/NonRoute/NonRouteDataManage.h | 172 + TSCP/src/APP/ciapp/NonRoute/NonRouteDefine.h | 56 + .../ciapp/Overlap/OverlapConfigDataManage.c | 875 + .../ciapp/Overlap/OverlapConfigDataManage.h | 380 + .../src/APP/ciapp/Overlap/OverlapDataManage.c | 978 + .../src/APP/ciapp/Overlap/OverlapDataManage.h | 367 + TSCP/src/APP/ciapp/Overlap/OverlapDefine.h | 78 + TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.c | 57 + TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.h | 60 + TSCP/src/APP/ciapp/PSC/PSCDefine.h | 23 + TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.c | 1044 + TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.h | 418 + TSCP/src/APP/ciapp/PSD/PSDDataManage.c | 2512 ++ TSCP/src/APP/ciapp/PSD/PSDDataManage.h | 879 + TSCP/src/APP/ciapp/PSD/PSDDefine.h | 175 + .../APP/ciapp/ParsePack/CiInterfaceDefine.h | 451 + .../APP/ciapp/ParsePack/ParsePackAtsData.c | 2673 ++ .../APP/ciapp/ParsePack/ParsePackAtsData.h | 373 + .../APP/ciapp/ParsePack/ParsePackAxleData.c | 956 + .../APP/ciapp/ParsePack/ParsePackAxleData.h | 134 + .../src/APP/ciapp/ParsePack/ParsePackCiData.c | 16084 ++++++++++ .../src/APP/ciapp/ParsePack/ParsePackCiData.h | 916 + .../src/APP/ciapp/ParsePack/ParsePackCommon.c | 4776 +++ .../src/APP/ciapp/ParsePack/ParsePackCommon.h | 387 + .../src/APP/ciapp/ParsePack/ParsePackDefine.h | 124 + .../ciapp/ParsePack/ParsePackGateWayData.c | 2084 ++ .../ciapp/ParsePack/ParsePackGateWayData.h | 411 + .../APP/ciapp/ParsePack/ParsePackITEData.c | 489 + .../APP/ciapp/ParsePack/ParsePackITEData.h | 129 + .../src/APP/ciapp/ParsePack/ParsePackIoData.c | 328 + .../src/APP/ciapp/ParsePack/ParsePackIoData.h | 122 + .../APP/ciapp/ParsePack/ParsePackLeuData.c | 318 + .../APP/ciapp/ParsePack/ParsePackLeuData.h | 127 + .../src/APP/ciapp/ParsePack/ParsePackManage.c | 1164 + .../src/APP/ciapp/ParsePack/ParsePackManage.h | 105 + .../src/APP/ciapp/ParsePack/ParsePackOcData.c | 2356 ++ .../src/APP/ciapp/ParsePack/ParsePackOcData.h | 407 + .../APP/ciapp/ParsePack/ParsePackPSCData.c | 453 + .../APP/ciapp/ParsePack/ParsePackPSCData.h | 137 + .../ciapp/ParsePack/ParsePackPlatformData.c | 425 + .../ciapp/ParsePack/ParsePackPlatformData.h | 124 + .../APP/ciapp/ParsePack/ParsePackTmcData.c | 1616 + .../APP/ciapp/ParsePack/ParsePackTmcData.h | 106 + .../APP/ciapp/ParsePack/ParsePackVobcData.c | 12252 ++++++++ .../APP/ciapp/ParsePack/ParsePackVobcData.h | 690 + .../src/APP/ciapp/ParsePack/ParsePackZcData.c | 1370 + .../src/APP/ciapp/ParsePack/ParsePackZcData.h | 212 + TSCP/src/APP/ciapp/QueryFiles/CiConfigData.h | 50 + .../APP/ciapp/QueryFiles/commonQueryStruDef.c | 104 + .../APP/ciapp/QueryFiles/commonQueryStruDef.h | 110 + TSCP/src/APP/ciapp/QueryFiles/dquCIInit.c | 12387 ++++++++ TSCP/src/APP/ciapp/QueryFiles/dquCIInit.h | 935 + .../src/APP/ciapp/QueryFiles/dquCIInterFace.c | 4562 +++ .../src/APP/ciapp/QueryFiles/dquCIInterFace.h | 503 + .../ciapp/QueryFiles/dquCIJDQStruFrmChar.c | 1133 + .../ciapp/QueryFiles/dquCIJDQStruFrmChar.h | 152 + .../APP/ciapp/QueryFiles/dquCIJDQStruInit.c | 1625 + .../APP/ciapp/QueryFiles/dquCIJDQStruInit.h | 177 + TSCP/src/APP/ciapp/QueryFiles/dquCILSStru.h | 415 + .../APP/ciapp/QueryFiles/dquCILSStruFrmChar.c | 1060 + .../APP/ciapp/QueryFiles/dquCILSStruFrmChar.h | 205 + .../APP/ciapp/QueryFiles/dquCILSStruInit.c | 2354 ++ .../APP/ciapp/QueryFiles/dquCILSStruInit.h | 266 + TSCP/src/APP/ciapp/QueryFiles/dquCIPZStru.h | 63 + .../APP/ciapp/QueryFiles/dquCIPZStruFrmChar.c | 441 + .../APP/ciapp/QueryFiles/dquCIPZStruFrmChar.h | 192 + .../ciapp/QueryFiles/dquCIReadCommonChar.c | 99 + .../ciapp/QueryFiles/dquCIReadCommonChar.h | 54 + TSCP/src/APP/ciapp/QueryFiles/dquCIStru.h | 26 + TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.c | 4488 +++ TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.h | 410 + TSCP/src/APP/ciapp/QueryFiles/dqucijdqstru.h | 459 + .../APP/ciapp/Relay/RelayConfigDataManage.c | 1660 + .../APP/ciapp/Relay/RelayConfigDataManage.h | 486 + TSCP/src/APP/ciapp/Relay/RelayDataManage.c | 919 + TSCP/src/APP/ciapp/Relay/RelayDataManage.h | 295 + TSCP/src/APP/ciapp/Relay/RelayDefine.h | 110 + TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.c | 1583 + TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.h | 444 + TSCP/src/APP/ciapp/RemoteRM/RRMDefine.h | 71 + TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.c | 2032 ++ TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.h | 103 + .../ReverseCut/ReverseCutConfigDataManage.c | 168 + .../ReverseCut/ReverseCutConfigDataManage.h | 89 + .../ciapp/ReverseCut/ReverseCutDataManage.c | 240 + .../ciapp/ReverseCut/ReverseCutDataManage.h | 115 + .../APP/ciapp/ReverseCut/ReverseCutDefine.h | 34 + .../ReverseRouteConfigDataManage.c | 224 + .../ReverseRouteConfigDataManage.h | 110 + .../ciapp/ReverseRoute/ReverseRouteDefine.h | 28 + .../APP/ciapp/Route/DynamicRouteDataManage.c | 4066 +++ .../APP/ciapp/Route/DynamicRouteDataManage.h | 172 + .../APP/ciapp/Route/LogicalRouteDataManage.c | 4393 +++ .../APP/ciapp/Route/LogicalRouteDataManage.h | 799 + .../ciapp/Route/LongRouteConfigDataManage.c | 221 + .../ciapp/Route/LongRouteConfigDataManage.h | 108 + .../src/APP/ciapp/Route/LongRouteDataManage.c | 120 + .../src/APP/ciapp/Route/LongRouteDataManage.h | 73 + .../APP/ciapp/Route/RouteConfigDataManage.c | 3577 +++ .../APP/ciapp/Route/RouteConfigDataManage.h | 1369 + TSCP/src/APP/ciapp/Route/RouteDataManage.c | 5749 ++++ TSCP/src/APP/ciapp/Route/RouteDataManage.h | 1642 + TSCP/src/APP/ciapp/Route/RouteDefine.h | 383 + .../src/APP/ciapp/SGBJ/SGBJConfigDataManage.c | 255 + .../src/APP/ciapp/SGBJ/SGBJConfigDataManage.h | 118 + TSCP/src/APP/ciapp/SGBJ/SGBJDefine.h | 25 + .../src/APP/ciapp/SPKS/SpksConfigDataManage.c | 906 + .../src/APP/ciapp/SPKS/SpksConfigDataManage.h | 350 + TSCP/src/APP/ciapp/SPKS/SpksDataManage.c | 270 + TSCP/src/APP/ciapp/SPKS/SpksDataManage.h | 120 + TSCP/src/APP/ciapp/SPKS/SpksDefine.h | 45 + .../APP/ciapp/Section/AxisConfigDataManage.c | 120 + .../APP/ciapp/Section/AxisConfigDataManage.h | 84 + .../Section/AxisSectionConfigDataManage.c | 1127 + .../Section/AxisSectionConfigDataManage.h | 318 + .../APP/ciapp/Section/AxisSectionDataManage.c | 789 + .../APP/ciapp/Section/AxisSectionDataManage.h | 263 + .../APP/ciapp/Section/LinkConfigDataManage.c | 4296 +++ .../APP/ciapp/Section/LinkConfigDataManage.h | 735 + .../ciapp/Section/LinkLineConfigDataManage.h | 25 + .../Section/LogicSectionConfigDataManage.c | 1465 + .../Section/LogicSectionConfigDataManage.h | 548 + .../ciapp/Section/LogicSectionDataManage.c | 5733 ++++ .../ciapp/Section/LogicSectionDataManage.h | 1301 + .../Section/PhysicalSectionConfigDataManage.c | 1568 + .../Section/PhysicalSectionConfigDataManage.h | 507 + .../ciapp/Section/PhysicalSectionDataManage.c | 4010 +++ .../ciapp/Section/PhysicalSectionDataManage.h | 1020 + TSCP/src/APP/ciapp/Section/SectionDefine.h | 355 + .../SectionStateProcess/SectionStateProcess.c | 1001 + .../SectionStateProcess_api.h | 30 + .../SectionStateProcess_define.h | 29 + .../APP/ciapp/Signal/SignalConfigDataManage.c | 1864 ++ .../APP/ciapp/Signal/SignalConfigDataManage.h | 745 + TSCP/src/APP/ciapp/Signal/SignalDataManage.c | 5091 +++ TSCP/src/APP/ciapp/Signal/SignalDataManage.h | 1035 + TSCP/src/APP/ciapp/Signal/SignalDefine.h | 301 + .../APP/ciapp/Switch/SwitchConfigDataManage.c | 1424 + .../APP/ciapp/Switch/SwitchConfigDataManage.h | 569 + TSCP/src/APP/ciapp/Switch/SwitchDataManage.c | 2778 ++ TSCP/src/APP/ciapp/Switch/SwitchDataManage.h | 686 + TSCP/src/APP/ciapp/Switch/SwitchDefine.h | 145 + TSCP/src/APP/ciapp/System/CiSystemDefine.h | 304 + .../src/APP/ciapp/System/SystemConfigDefine.h | 116 + .../APP/ciapp/System/SystemParameterManage.c | 2889 ++ .../APP/ciapp/System/SystemParameterManage.h | 1385 + .../APP/ciapp/Train/EvacuationAreaManage.c | 3815 +++ .../APP/ciapp/Train/EvacuationAreaManage.h | 338 + TSCP/src/APP/ciapp/Train/TrainDataManage.c | 10849 +++++++ TSCP/src/APP/ciapp/Train/TrainDataManage.h | 2454 ++ TSCP/src/APP/ciapp/Train/TrainDefine.h | 245 + TSCP/src/APP/ciapp/Train/TrainOnAcManage.c | 2922 ++ TSCP/src/APP/ciapp/Train/TrainOnAcManage.h | 202 + TSCP/src/APP/ciapp/Transmit/TransmitDefine.h | 52 + .../ciapp/Transmit/TransmitStateDataManage.c | 1027 + .../ciapp/Transmit/TransmitStateDataManage.h | 177 + .../VirtualDevice/VirtualDevDataManage.c | 1375 + .../VirtualDevice/VirtualDevDataManage.h | 509 + .../ciapp/VirtualDevice/VirtualDevDefine.h | 27 + .../src/APP/ciapp/WLBrake/WLBrakeDataManage.c | 456 + .../src/APP/ciapp/WLBrake/WLBrakeDataManage.h | 51 + TSCP/src/APP/ciapp/WLBrake/WLBrakeDefine.h | 9 + .../APP/ciapp/WLScreen/WLScreenDataManage.c | 634 + .../APP/ciapp/WLScreen/WLScreenDataManage.h | 257 + .../APP/ciapp/WLScreen/WLScreenDataPrepare.c | 595 + .../APP/ciapp/WLScreen/WLScreenDataPrepare.h | 136 + .../APP/ciapp/WLScreen/WLScreenLogicProcess.c | 324 + .../APP/ciapp/WLScreen/WLScreenLogicProcess.h | 35 + .../APP/ciapp/WLScreen/WholeLineScreenAPI.c | 525 + .../APP/ciapp/WLScreen/WholeLineScreenAPI.h | 123 + .../ciapp/WLScreen/WholeLineScreenDefine.h | 88 + .../WashMachine/WashMachineConfigDataManage.c | 718 + .../WashMachine/WashMachineConfigDataManage.h | 310 + .../ciapp/WashMachine/WashMachineDataManage.c | 1334 + .../ciapp/WashMachine/WashMachineDataManage.h | 459 + .../APP/ciapp/WashMachine/WashMachineDefine.h | 112 + TSCP/src/DRV/imx8_drv_gpio.c | 862 + TSCP/src/DRV/imx8_drv_gpio.h | 85 + TSCP/src/DRV/imx8_drv_i2c.c | 772 + TSCP/src/DRV/imx8_drv_i2c.h | 355 + TSCP/src/MSCP/CFM/CFM_Net.c | 4142 +++ TSCP/src/MSCP/CFM/CFM_Net.h | 663 + TSCP/src/MSCP/CFM/CFM_Raw.c | 947 + TSCP/src/MSCP/CFM/CFM_Raw.h | 58 + TSCP/src/MSCP/CM/CM_Atomic.h | 58 + TSCP/src/MSCP/CM/CM_CRC32.c | 88 + TSCP/src/MSCP/CM/CM_CRC32.h | 36 + TSCP/src/MSCP/CM/CM_Com.c | 536 + TSCP/src/MSCP/CM/CM_Com.h | 98 + TSCP/src/MSCP/CM/CM_Convert.c | 226 + TSCP/src/MSCP/CM/CM_Convert.h | 61 + TSCP/src/MSCP/CM/CM_FFFE.c | 169 + TSCP/src/MSCP/CM/CM_FFFE.h | 84 + TSCP/src/MSCP/CM/CM_IniFile.c | 450 + TSCP/src/MSCP/CM/CM_IniFile.h | 48 + TSCP/src/MSCP/CM/CM_MD5.c | 520 + TSCP/src/MSCP/CM/CM_MD5.h | 77 + TSCP/src/MSCP/CM/CM_MQ.c | 680 + TSCP/src/MSCP/CM/CM_MQ.h | 156 + TSCP/src/MSCP/CM/CM_MQ_Light.c | 365 + TSCP/src/MSCP/CM/CM_MQ_Light.h | 122 + TSCP/src/MSCP/CM/CM_Memory.c | 173 + TSCP/src/MSCP/CM/CM_Memory.h | 50 + TSCP/src/MSCP/CM/CM_MultiThread.h | 85 + TSCP/src/MSCP/CM/CM_MultiThread_Priority.h | 341 + TSCP/src/MSCP/CM/CM_MultiThread_qnx.c | 123 + TSCP/src/MSCP/CM/CM_MultiThread_vxworks.c | 90 + TSCP/src/MSCP/CM/CM_MultiThread_windows.c | 73 + TSCP/src/MSCP/CM/CM_Mutex.h | 95 + TSCP/src/MSCP/CM/CM_Mutex_qnx.c | 182 + TSCP/src/MSCP/CM/CM_Mutex_vxworks.c | 130 + TSCP/src/MSCP/CM/CM_Mutex_windows.c | 138 + TSCP/src/MSCP/CM/CM_Queue.c | 481 + TSCP/src/MSCP/CM/CM_Queue.h | 140 + TSCP/src/MSCP/CM/CM_RingBuf.c | 139 + TSCP/src/MSCP/CM/CM_RingBuf.h | 80 + TSCP/src/MSCP/CM/CM_Sem.h | 94 + TSCP/src/MSCP/CM/CM_Sem_qnx.c | 212 + TSCP/src/MSCP/CM/CM_Sem_vxworks.c | 122 + TSCP/src/MSCP/CM/CM_Sem_windows.c | 143 + TSCP/src/MSCP/CM/CM_Socket.c | 182 + TSCP/src/MSCP/CM/CM_Socket.h | 98 + TSCP/src/MSCP/CM/CM_TCP.c | 1183 + TSCP/src/MSCP/CM/CM_TCP.h | 183 + TSCP/src/MSCP/CM/CM_Time.c | 128 + TSCP/src/MSCP/CM/CM_Time.h | 52 + TSCP/src/MSCP/CM/CM_Types.h | 178 + TSCP/src/MSCP/CM/CM_UDP.c | 445 + TSCP/src/MSCP/CM/CM_UDP.h | 104 + TSCP/src/MSCP/DFM/DFM_DRV.h | 88 + TSCP/src/MSCP/DFM/DFM_DRV_QNX.c | 636 + TSCP/src/MSCP/DFM/DFM_DRV_WIN.c | 147 + TSCP/src/MSCP/DFM/DFM_Time.c | 123 + TSCP/src/MSCP/DFM/DFM_Time.h | 67 + TSCP/src/MSCP/MSCP_APP_API.c | 893 + TSCP/src/MSCP/MSCP_APP_API.h | 475 + TSCP/src/MSCP/MSCP_APP_Interface.h | 168 + TSCP/src/MSCP/MSCP_Define.h | 61 + TSCP/src/MSCP/MSCP_main.c | 917 + TSCP/src/MSCP/MSCP_main.h | 16 + TSCP/src/MSCP/PFM/PFM_CPUCheck.c | 971 + TSCP/src/MSCP/PFM/PFM_CPUCheck.h | 15 + TSCP/src/MSCP/PFM/PFM_CPUUsage.c | 362 + TSCP/src/MSCP/PFM/PFM_CPUUsage.h | 81 + TSCP/src/MSCP/PFM/PFM_Cfg.c | 812 + TSCP/src/MSCP/PFM/PFM_Cfg.h | 352 + TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.c | 372 + TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.h | 63 + TSCP/src/MSCP/PFM/PFM_FS.c | 158 + TSCP/src/MSCP/PFM/PFM_FS.h | 32 + TSCP/src/MSCP/PFM/PFM_InputOutput.c | 1816 ++ TSCP/src/MSCP/PFM/PFM_InputOutput.h | 70 + TSCP/src/MSCP/PFM/PFM_Log.c | 957 + TSCP/src/MSCP/PFM/PFM_Log.h | 326 + TSCP/src/MSCP/PFM/PFM_MemCheck.c | 29 + TSCP/src/MSCP/PFM/PFM_MemCheck.h | 16 + TSCP/src/MSCP/PFM/PFM_MemoryCheck.c | 637 + TSCP/src/MSCP/PFM/PFM_MemoryCheck.h | 27 + TSCP/src/MSCP/PFM/PFM_RemoteUpdate.c | 3007 ++ TSCP/src/MSCP/PFM/PFM_RemoteUpdate.h | 165 + TSCP/src/MSCP/PFM/PFM_SelfCheck.c | 412 + TSCP/src/MSCP/PFM/PFM_SelfCheck.h | 54 + TSCP/src/MSCP/SFM/SFM_2oo2.c | 1017 + TSCP/src/MSCP/SFM/SFM_2oo2.h | 85 + TSCP/src/MSCP/SFM/SFM_2x2.c | 3321 ++ TSCP/src/MSCP/SFM/SFM_2x2.h | 466 + TSCP/src/MSCP/SFM/SFM_Prtcl.c | 2387 ++ TSCP/src/MSCP/SFM/SFM_Prtcl.h | 221 + TSCP/src/MSCP/SFM/SFM_package.c | 264 + TSCP/src/MSCP/SFM/SFM_package.h | 47 + TSCP/src/MSCP_CFG/MSCP_Cfg.h | 16 + TSCP/src/commoncode/common/CRC16.c | 136 + TSCP/src/commoncode/common/CRC16.h | 41 + TSCP/src/commoncode/common/CRC32.c | 394 + TSCP/src/commoncode/common/CRC32.h | 88 + TSCP/src/commoncode/common/CbtcVersion.c | 187 + TSCP/src/commoncode/common/CbtcVersion.h | 115 + TSCP/src/commoncode/common/CommonBit.c | 88 + TSCP/src/commoncode/common/CommonBit.h | 50 + TSCP/src/commoncode/common/CommonCRC.c | 232 + TSCP/src/commoncode/common/CommonCRC.h | 49 + TSCP/src/commoncode/common/CommonMemory.c | 130 + TSCP/src/commoncode/common/CommonMemory.h | 54 + TSCP/src/commoncode/common/CommonQueue.c | 487 + TSCP/src/commoncode/common/CommonQueue.h | 138 + TSCP/src/commoncode/common/CommonRecord.c | 603 + TSCP/src/commoncode/common/CommonRecord.h | 201 + TSCP/src/commoncode/common/CommonStack.c | 250 + TSCP/src/commoncode/common/CommonStack.h | 104 + TSCP/src/commoncode/common/CommonTypes.h | 137 + TSCP/src/commoncode/common/Convert.c | 187 + TSCP/src/commoncode/common/Convert.h | 94 + TSCP/src/commoncode/common/DataPackage.c | 210 + TSCP/src/commoncode/common/DataPackage.h | 71 + TSCP/src/commoncode/common/FFFE.c | 519 + TSCP/src/commoncode/common/FFFE.h | 91 + TSCP/src/commoncode/common/Translate0203.c | 153 + TSCP/src/commoncode/common/Translate0203.h | 55 + TSCP/src/commoncode/common/VobcNetPack.c | 143 + TSCP/src/commoncode/common/VobcNetPack.h | 53 + .../commoncode_config_vxworks/CommonConfig.h | 37 + .../dqu_cbtc_common/dquCbtcConfigData.c | 1343 + .../dqu_cbtc_common/dquCbtcConfigData.h | 214 + .../dqu_common/dqu_dfs_common/dfsDataRead.c | 1596 + .../dqu_common/dqu_dfs_common/dfsDataRead.h | 350 + .../dqu_common/dqu_dfs_common/dquCbtcType.c | 93 + .../dqu_common/dqu_dfs_common/dquCbtcType.h | 105 + .../dqu_dfs_common/dquDataTypeDefine.h | 214 + .../dqu_common/dqu_emap_common/dquEmapInit.c | 16862 ++++++++++ .../dqu_common/dqu_emap_common/dquEmapInit.h | 702 + .../src/dqu_common/dqu_emap_common/dquQuery.c | 1007 + .../src/dqu_common/dqu_emap_common/dquQuery.h | 403 + .../dqu_common/dqu_emap_common/dquQueryExp.c | 7647 +++++ .../dqu_common/dqu_emap_common/dquQueryExp.h | 364 + .../dqu_emap_common/dquStructInit.c | 4567 +++ .../dqu_emap_common/dquStructInit.h | 476 + .../dqu_emap_common/dquVobcCommonStru.h | 93 + .../dqu_emap_common/dsuEmapDefine.h | 328 + .../dqu_common/dqu_emap_common/dsuStruct.h | 1308 + TSCP/src/dqu_common/dqu_emap_common/dsuVar.c | 144 + TSCP/src/dqu_common/dqu_emap_common/dsuVar.h | 60 + .../dqu_idmap_common/dquIdmapInit.c | 4532 +++ .../dqu_idmap_common/dquIdmapInit.h | 379 + .../dqu_idmap_common/dquIdmapQuery.c | 1804 ++ .../dqu_idmap_common/dquIdmapQuery.h | 310 + .../dqu_idmap_common/dsuIdmapStruct.h | 316 + .../dqu_common/dqu_idmap_common/dsuIdmapVar.c | 107 + .../dqu_common/dqu_idmap_common/dsuIdmapVar.h | 54 + TSCP/src/main/2oo2/processor.h | 844 + TSCP/src/main/2oo2/simulation2oo2.c | 59 + TSCP/src/main/2oo2/vxWorks.h | 16 + TSCP/src/main/CiSimulation.cpp | 5319 ++++ TSCP/src/main/CiSimulation.h | 211 + .../main/DeviceInfoManager/readxmltodata.cpp | 1723 + .../main/DeviceInfoManager/readxmltodata.h | 213 + .../DeviceInfoManager/tinyxml/tinystr.cpp | 111 + .../main/DeviceInfoManager/tinyxml/tinystr.h | 305 + .../DeviceInfoManager/tinyxml/tinyxml.cpp | 1886 ++ .../main/DeviceInfoManager/tinyxml/tinyxml.h | 1805 ++ .../tinyxml/tinyxmlerror.cpp | 52 + .../tinyxml/tinyxmlparser.cpp | 1638 + TSCP/src/main/RecordClass/RecordClass.cpp | 580 + TSCP/src/main/RecordClass/RecordClass.h | 68 + TSCP/src/main/SimDef/SimDef.h | 21 + TSCP/src/main/ccov/Ccov_RSSPII_Parser.cpp | 148 + TSCP/src/main/ccov/Ccov_RSSPII_Parser.h | 28 + TSCP/src/main/ccov/Ccov_RsspII.cpp | 313 + TSCP/src/main/ccov/Ccov_RsspII.h | 31 + TSCP/src/main/ccov/Ccov_TcpCallBackDef.h | 6 + TSCP/src/main/ccov/Ccov_TcpSer.cpp | 197 + TSCP/src/main/ccov/Ccov_TcpSer.h | 39 + TSCP/src/main/ccov/EndPointConStatus.h | 14 + TSCP/src/main/ccov/TcpConnection_Ser.cpp | 119 + TSCP/src/main/ccov/TcpConnection_Ser.h | 34 + TSCP/src/main/ccov/ccov.cpp | 420 + TSCP/src/main/ccov/ccov.h | 58 + TSCP/src/main/commLib/CRC32long.c | 71 + TSCP/src/main/commLib/CRC32long.h | 18 + TSCP/src/main/ini/ReadCcovConfigInfo.cpp | 71 + TSCP/src/main/ini/ReadCcovConfigInfo.h | 31 + .../fsfb/common_dqu_fsfb/dsuFsfbDataStru.h | 124 + .../fsfb/common_dqu_fsfb/dsuFsfbFunc.c | 865 + .../fsfb/common_dqu_fsfb/dsuFsfbFunc.h | 153 + .../protocol/fsfb/common_fsfb/FsfbConfig.h | 23 + .../fsfb/common_fsfb/FsfbLnkNodeMgr.c | 1423 + .../fsfb/common_fsfb/FsfbLnkNodeMgr.h | 189 + .../fsfb/common_fsfb/FsfbMessageInfo.c | 1431 + .../fsfb/common_fsfb/FsfbMessageInfo.h | 160 + .../protocol/fsfb/common_fsfb/FsfbProtcl.c | 1180 + .../protocol/fsfb/common_fsfb/FsfbProtcl.h | 68 + .../fsfb/common_fsfb/FsfbProtclCommon.c | 965 + .../fsfb/common_fsfb/FsfbProtclCommon.h | 319 + .../common_fsfb/FsfbProtclConfigMessage.h | 140 + .../fsfb/common_fsfb/FsfbRecordDelare.h | 77 + .../fsfb/common_fsfb/RpHandleInterface.c | 651 + .../fsfb/common_fsfb/RpHandleInterface.h | 30 + .../fsfb/common_fsfb/RpHandlePlatform.h | 131 + .../fsfb/common_fsfb/fsfbProtclStruct.h | 198 + .../common_dqu_protocol/dsuProtclFun.c | 605 + .../common_dqu_protocol/dsuProtclFun.h | 120 + .../common_protocol/ProtclManage.c | 4648 +++ .../common_protocol/ProtclManage.h | 247 + .../common_protocol/protclInterFun.c | 1549 + .../common_protocol/protclInterFun.h | 230 + .../common_protocol/protclMgeCfg.h | 58 + .../common_protocol/protclStruct.h | 156 + .../common_protocol_config/protocolConfig.h | 28 + .../common_dqu_rp/dsuRpFunc.c | 151 + .../common_dqu_rp/dsuRpFunc.h | 84 + .../common_redun/RpDeclare.h | 76 + .../common_redun/RpInterface.c | 1801 ++ .../common_redun/RpInterface.h | 42 + .../common_redun/RpPlatform.h | 130 + .../redun_record_cbtc/common_redun/RpStruct.h | 43 + .../common_redun_record_config/RpConfig.h | 26 + .../common_dqu_rsr/dsuRsrDataStru.h | 114 + .../common_dqu_rsr/dsuRsrFunc.c | 1377 + .../common_dqu_rsr/dsuRsrFunc.h | 193 + .../protocol/rsr_record_cbtc/common_rsr/Rsr.c | 758 + .../protocol/rsr_record_cbtc/common_rsr/Rsr.h | 143 + .../rsr_record_cbtc/common_rsr/RsrCommon.c | 164 + .../rsr_record_cbtc/common_rsr/RsrCommon.h | 124 + .../rsr_record_cbtc/common_rsr/RsrPlatform.h | 47 + .../common_rsr/RsrRecordDelare.h | 113 + .../common_rsr/rssp/RsspCommon.c | 855 + .../common_rsr/rssp/RsspCommon.h | 289 + .../rsr_record_cbtc/common_rsr/rssp/RsspIF.h | 138 + .../common_rsr/rssp/RsspInit.c | 156 + .../common_rsr/rssp/RsspLnkNodeMgr.c | 1236 + .../common_rsr/rssp/RsspLnkNodeMgr.h | 187 + .../common_rsr/rssp/RsspOutput.c | 929 + .../common_rsr/rssp/RsspRecive.c | 1217 + .../common_rsr/rssp/RsspStruct.h | 166 + .../common_rsr/rssp/RsspTmpMsgLnkCommon.c | 463 + .../common_rsr/rssp/RsspTmpMsgLnkCommon.h | 110 + .../common_rsr/sig/sigDeclare.h | 64 + .../common_rsr/sig/sigInterface.c | 458 + .../common_rsr/sig/sigInterface.h | 103 + .../common_rsr_record_config/RsrConfig.h | 23 + .../dqu_rsspii_cbtc/dsuRssp2DataStru.h | 123 + .../dqu_rsspii_cbtc/dsuRssp2Func.c | 918 + .../dqu_rsspii_cbtc/dsuRssp2Func.h | 90 + .../rssp2_record_cbtc/rsspii_cbtc/CM_Base.c | 53 + .../rssp2_record_cbtc/rsspii_cbtc/CM_Base.h | 51 + .../rssp2_record_cbtc/rsspii_cbtc/CM_Define.h | 33 + .../rsspii_cbtc/CM_RingQueue.c | 1058 + .../rsspii_cbtc/CM_RingQueue.h | 223 + .../rssp2_record_cbtc/rsspii_cbtc/CM_Type.h | 68 + .../rsspii_cbtc/PrtclBaseParse.c | 308 + .../rsspii_cbtc/PrtclBaseParse.h | 88 + .../rsspii_cbtc/PrtclParseManage.c | 93 + .../rsspii_cbtc/PrtclParseManage.h | 57 + .../rssp2_record_cbtc/rsspii_cbtc/Rssp2.c | 4850 +++ .../rssp2_record_cbtc/rsspii_cbtc/Rssp2.h | 176 + .../rsspii_cbtc/Rssp2Common.c | 107 + .../rsspii_cbtc/Rssp2Common.h | 96 + .../rsspii_cbtc/Rssp2LnkNodeMgr.c | 500 + .../rsspii_cbtc/Rssp2LnkNodeMgr.h | 103 + .../rsspii_cbtc/Rssp2Struct.h | 510 + .../rssp2_record_cbtc/rsspii_cbtc/crc.c | 70 + .../rssp2_record_cbtc/rsspii_cbtc/crc.h | 25 + .../rssp2_record_cbtc/rsspii_cbtc/des.c | 428 + .../rssp2_record_cbtc/rsspii_cbtc/des.h | 64 + .../rsspii_cbtc/typedefine.h | 131 + .../rsspii_record_config_cbtc/Rssp2Configl.h | 54 + .../common_dqu_rssp/dsuRsspDataStru.h | 112 + .../common_dqu_rssp/dsuRsspFunc.c | 1917 ++ .../common_dqu_rssp/dsuRsspFunc.h | 213 + .../common_rssp/RsspCommonWl.c | 1045 + .../common_rssp/RsspCommonWl.h | 429 + .../rssp_record_cbtc1/common_rssp/RsspIFWl.h | 127 + .../common_rssp/RsspInitWl.c | 174 + .../common_rssp/RsspLnkNodeMgrWl.c | 1139 + .../common_rssp/RsspLnkNodeMgrWl.h | 189 + .../common_rssp/RsspOutputWl.c | 982 + .../common_rssp/RsspReciveWl.c | 1203 + .../common_rssp/RsspRecordDelareWl.h | 90 + .../common_rssp/RsspStructWl.h | 161 + .../common_rssp/RsspTmpMsgLnkCommonWl.c | 524 + .../common_rssp/RsspTmpMsgLnkCommonWl.h | 135 + .../rssp_record_cbtc1/common_rssp/RsspWl.c | 694 + .../rssp_record_cbtc1/common_rssp/RsspWl.h | 202 + .../common_rssp_record_config/RsspConfigWl.h | 26 + .../common_dqu_sfp/dsuRelatedDeal.c | 1158 + .../common_dqu_sfp/dsuRelatedDeal.h | 156 + .../sfp_record_cbtc1/common_sfp/sfpDeclare.h | 148 + .../common_sfp/sfpLinkManage.c | 811 + .../common_sfp/sfpLinkManage.h | 135 + .../common_sfp/sfpPrtclCommon.c | 433 + .../common_sfp/sfpPrtclCommon.h | 152 + .../common_sfp/sfpPrtclInit.c | 460 + .../common_sfp/sfpPrtclReceive.c | 2383 ++ .../common_sfp/sfpPrtclReceive.h | 207 + .../common_sfp/sfpPrtclStruct.h | 181 + .../common_sfp/sfpPrtcl_Output.c | 1886 ++ .../common_sfp/sfpPrtcl_Output.h | 159 + .../common_sfp/sfpWindowsTimeCounter.c | 35 + .../common_sfp/sfpWindowsTimeCounter.h | 42 + .../sfp_record_cbtc1/common_sfp/sfpplatform.h | 261 + .../common_sfp/协议c和cpp转换.bat | 18 + .../common_sfp_nr_config/sfpConfig.h | 28 + 625 files changed, 562213 insertions(+) create mode 100644 .gitattributes create mode 100644 TSCP/Makefile create mode 100644 TSCP/src/APP/APP_API.c create mode 100644 TSCP/src/APP/APP_API.h create mode 100644 TSCP/src/APP/PU13_integration_config/ci_integrate_config.h create mode 100644 TSCP/src/APP/ProtclParam.h create mode 100644 TSCP/src/APP/ciapp/2oo2/2oo2DataTransferManage.c create mode 100644 TSCP/src/APP/ciapp/2oo2/2oo2DataTransferManage.h create mode 100644 TSCP/src/APP/ciapp/2oo2/2oo2InterfaceDataManage.c create mode 100644 TSCP/src/APP/ciapp/2oo2/2oo2InterfaceDataManage.h create mode 100644 TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDataManage.c create mode 100644 TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDataManage.h create mode 100644 TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDefine.h create mode 100644 TSCP/src/APP/ciapp/AutoReturn/AutoReturnConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/AutoReturn/AutoReturnConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/AutoReturn/AutoReturnDataManage.c create mode 100644 TSCP/src/APP/ciapp/AutoReturn/AutoReturnDataManage.h create mode 100644 TSCP/src/APP/ciapp/AutoReturn/AutoReturnDefine.h create mode 100644 TSCP/src/APP/ciapp/AutoRoute/AutoRouteConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/AutoRoute/AutoRouteConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/AutoRoute/AutoRouteDataManage.c create mode 100644 TSCP/src/APP/ciapp/AutoRoute/AutoRouteDataManage.h create mode 100644 TSCP/src/APP/ciapp/AutoRoute/AutoRouteDefine.h create mode 100644 TSCP/src/APP/ciapp/AxisAssert/AxisAssertDataPrepare.c create mode 100644 TSCP/src/APP/ciapp/AxisAssert/AxisAssertDataPrepare.h create mode 100644 TSCP/src/APP/ciapp/AxisAssert/AxisAssertDefine.h create mode 100644 TSCP/src/APP/ciapp/AxisAssert/AxisAssertManage.c create mode 100644 TSCP/src/APP/ciapp/AxisAssert/AxisAssertManage.h create mode 100644 TSCP/src/APP/ciapp/AxisAssert/AxisAssertManageAPI.c create mode 100644 TSCP/src/APP/ciapp/AxisAssert/AxisAssertManageAPI.h create mode 100644 TSCP/src/APP/ciapp/AxisSort/AxisSort.c create mode 100644 TSCP/src/APP/ciapp/AxisSort/AxisSort.h create mode 100644 TSCP/src/APP/ciapp/AxisSort/AxisSort_api.h create mode 100644 TSCP/src/APP/ciapp/AxisSort/AxisSort_define.h create mode 100644 TSCP/src/APP/ciapp/CutoffPoint/CutoffPointConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/CutoffPoint/CutoffPointConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDataManage.c create mode 100644 TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDataManage.h create mode 100644 TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDefine.h create mode 100644 TSCP/src/APP/ciapp/DataManage/DeviceConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/DataManage/DeviceConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/DataManage/DeviceDataManage.c create mode 100644 TSCP/src/APP/ciapp/DataManage/DeviceDataManage.h create mode 100644 TSCP/src/APP/ciapp/DataManage/PlatDataManage.c create mode 100644 TSCP/src/APP/ciapp/DataManage/PlatDataManage.h create mode 100644 TSCP/src/APP/ciapp/DebugPrint/DebugPrint.c create mode 100644 TSCP/src/APP/ciapp/DebugPrint/DebugPrint.h create mode 100644 TSCP/src/APP/ciapp/DebugPrint/DebugPrintInterface.h create mode 100644 TSCP/src/APP/ciapp/DebugPrint/ErrorCode.h create mode 100644 TSCP/src/APP/ciapp/DebugPrint/ErrorDeviceType.h create mode 100644 TSCP/src/APP/ciapp/Deployment/Deployment.c create mode 100644 TSCP/src/APP/ciapp/Deployment/Deployment.h create mode 100644 TSCP/src/APP/ciapp/Deployment/DeploymentExtern.h create mode 100644 TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevDefine.h create mode 100644 TSCP/src/APP/ciapp/ERROR/ErrorDataManage.c create mode 100644 TSCP/src/APP/ciapp/ERROR/ErrorDataManage.h create mode 100644 TSCP/src/APP/ciapp/ERROR/ErrorDefine.h create mode 100644 TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/ESB/ESBDataManage.c create mode 100644 TSCP/src/APP/ciapp/ESB/ESBDataManage.h create mode 100644 TSCP/src/APP/ciapp/ESB/ESBDefine.h create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/CTEnvelopeTrack.c create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/ELMDataPrepare.c create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/ELMDataPrepare.h create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeDefine.h create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeLogicProcess.c create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeLogicProcess.h create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManage.c create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManage.h create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManageAPI.c create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManageAPI.h create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeScreen.c create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/UCTEnvelopeTrack.c create mode 100644 TSCP/src/APP/ciapp/EnvelopeManage/UKTEnvelopeTrack.c create mode 100644 TSCP/src/APP/ciapp/FloodGate/FloodGateConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/FloodGate/FloodGateConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/FloodGate/FloodGateDataManage.c create mode 100644 TSCP/src/APP/ciapp/FloodGate/FloodGateDataManage.h create mode 100644 TSCP/src/APP/ciapp/FloodGate/FloodGateDefine.h create mode 100644 TSCP/src/APP/ciapp/Garagedoor/GaragedoorConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Garagedoor/GaragedoorConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Garagedoor/GaragedoorDataManage.c create mode 100644 TSCP/src/APP/ciapp/Garagedoor/GaragedoorDataManage.h create mode 100644 TSCP/src/APP/ciapp/Garagedoor/GaragedoorDefine.h create mode 100644 TSCP/src/APP/ciapp/HLHTMsgHead/HLHTCommonDataPacketHead.c create mode 100644 TSCP/src/APP/ciapp/HLHTMsgHead/HLHTCommonDataPacketHead.h create mode 100644 TSCP/src/APP/ciapp/HLHTMsgHead/HLHTHeadContexManage.c create mode 100644 TSCP/src/APP/ciapp/HLHTMsgHead/HLHTHeadContexManage.h create mode 100644 TSCP/src/APP/ciapp/IO/DeviceRelayDataProcess.c create mode 100644 TSCP/src/APP/ciapp/IO/DeviceRelayDataProcess.h create mode 100644 TSCP/src/APP/ciapp/IO/InputDataProcess.c create mode 100644 TSCP/src/APP/ciapp/IO/InputDataProcess.h create mode 100644 TSCP/src/APP/ciapp/IO/OutputDataProcess.c create mode 100644 TSCP/src/APP/ciapp/IO/OutputDataProcess.h create mode 100644 TSCP/src/APP/ciapp/Indicator/IndicatorConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Indicator/IndicatorConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Indicator/IndicatorDataManage.c create mode 100644 TSCP/src/APP/ciapp/Indicator/IndicatorDataManage.h create mode 100644 TSCP/src/APP/ciapp/Indicator/IndicatorDefine.h create mode 100644 TSCP/src/APP/ciapp/Initial/ConfigDataReadManage.c create mode 100644 TSCP/src/APP/ciapp/Initial/ConfigDataReadManage.h create mode 100644 TSCP/src/APP/ciapp/Initial/InitialProcess.c create mode 100644 TSCP/src/APP/ciapp/Initial/InitialProcess.h create mode 100644 TSCP/src/APP/ciapp/InvadeSection/InvadeSectionConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/InvadeSection/InvadeSectionConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDataManage.c create mode 100644 TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDataManage.h create mode 100644 TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDefine.h create mode 100644 TSCP/src/APP/ciapp/LogRecord/LogRecord.c create mode 100644 TSCP/src/APP/ciapp/LogRecord/LogRecord.h create mode 100644 TSCP/src/APP/ciapp/LogicManage/InterlockCommonManage.c create mode 100644 TSCP/src/APP/ciapp/LogicManage/InterlockCommonManage.h create mode 100644 TSCP/src/APP/ciapp/LogicManage/InterlockLogicManage.c create mode 100644 TSCP/src/APP/ciapp/LogicManage/InterlockLogicManage.h create mode 100644 TSCP/src/APP/ciapp/LogicManage/RouteRecoverManage.c create mode 100644 TSCP/src/APP/ciapp/LogicManage/RouteRecoverManage.h create mode 100644 TSCP/src/APP/ciapp/LogicManage/TradInterlockLogicManage.c create mode 100644 TSCP/src/APP/ciapp/LogicManage/TradInterlockLogicManage.h create mode 100644 TSCP/src/APP/ciapp/LogicProcess/InterlockLogicCheck.c create mode 100644 TSCP/src/APP/ciapp/LogicProcess/InterlockLogicCheck.h create mode 100644 TSCP/src/APP/ciapp/LogicProcess/InterlockLogicProcess.c create mode 100644 TSCP/src/APP/ciapp/LogicProcess/InterlockLogicProcess.h create mode 100644 TSCP/src/APP/ciapp/LogicProcess/LogicalRouteLogicCheck.c create mode 100644 TSCP/src/APP/ciapp/LogicProcess/LogicalRouteLogicCheck.h create mode 100644 TSCP/src/APP/ciapp/LogicProcess/TradInterlockLogicProcess.c create mode 100644 TSCP/src/APP/ciapp/LogicProcess/TradInterlockLogicProcess.h create mode 100644 TSCP/src/APP/ciapp/Main/MainApp.c create mode 100644 TSCP/src/APP/ciapp/Main/MainApp.h create mode 100644 TSCP/src/APP/ciapp/Mask/MaskConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Mask/MaskConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Mask/MaskDefine.h create mode 100644 TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDataManage.c create mode 100644 TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDataManage.h create mode 100644 TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDefine.h create mode 100644 TSCP/src/APP/ciapp/NonRoute/NonRouteConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/NonRoute/NonRouteConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/NonRoute/NonRouteDataManage.c create mode 100644 TSCP/src/APP/ciapp/NonRoute/NonRouteDataManage.h create mode 100644 TSCP/src/APP/ciapp/NonRoute/NonRouteDefine.h create mode 100644 TSCP/src/APP/ciapp/Overlap/OverlapConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Overlap/OverlapConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Overlap/OverlapDataManage.c create mode 100644 TSCP/src/APP/ciapp/Overlap/OverlapDataManage.h create mode 100644 TSCP/src/APP/ciapp/Overlap/OverlapDefine.h create mode 100644 TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/PSC/PSCDefine.h create mode 100644 TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/PSD/PSDDataManage.c create mode 100644 TSCP/src/APP/ciapp/PSD/PSDDataManage.h create mode 100644 TSCP/src/APP/ciapp/PSD/PSDDefine.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/CiInterfaceDefine.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackAtsData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackAtsData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackAxleData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackAxleData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackCiData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackCiData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackCommon.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackCommon.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackDefine.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackGateWayData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackGateWayData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackITEData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackITEData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackIoData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackIoData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackLeuData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackLeuData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackManage.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackManage.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackOcData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackOcData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackPSCData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackPSCData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackPlatformData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackPlatformData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackTmcData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackTmcData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackVobcData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackVobcData.h create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackZcData.c create mode 100644 TSCP/src/APP/ciapp/ParsePack/ParsePackZcData.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/CiConfigData.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/commonQueryStruDef.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/commonQueryStruDef.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIInit.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIInit.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIInterFace.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIInterFace.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruFrmChar.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruFrmChar.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruInit.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruInit.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCILSStru.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCILSStruFrmChar.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCILSStruFrmChar.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCILSStruInit.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCILSStruInit.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIPZStru.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIPZStruFrmChar.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIPZStruFrmChar.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIReadCommonChar.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIReadCommonChar.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquCIStru.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.c create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.h create mode 100644 TSCP/src/APP/ciapp/QueryFiles/dqucijdqstru.h create mode 100644 TSCP/src/APP/ciapp/Relay/RelayConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Relay/RelayConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Relay/RelayDataManage.c create mode 100644 TSCP/src/APP/ciapp/Relay/RelayDataManage.h create mode 100644 TSCP/src/APP/ciapp/Relay/RelayDefine.h create mode 100644 TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.c create mode 100644 TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.h create mode 100644 TSCP/src/APP/ciapp/RemoteRM/RRMDefine.h create mode 100644 TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.c create mode 100644 TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.h create mode 100644 TSCP/src/APP/ciapp/ReverseCut/ReverseCutConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/ReverseCut/ReverseCutConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/ReverseCut/ReverseCutDataManage.c create mode 100644 TSCP/src/APP/ciapp/ReverseCut/ReverseCutDataManage.h create mode 100644 TSCP/src/APP/ciapp/ReverseCut/ReverseCutDefine.h create mode 100644 TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteDefine.h create mode 100644 TSCP/src/APP/ciapp/Route/DynamicRouteDataManage.c create mode 100644 TSCP/src/APP/ciapp/Route/DynamicRouteDataManage.h create mode 100644 TSCP/src/APP/ciapp/Route/LogicalRouteDataManage.c create mode 100644 TSCP/src/APP/ciapp/Route/LogicalRouteDataManage.h create mode 100644 TSCP/src/APP/ciapp/Route/LongRouteConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Route/LongRouteConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Route/LongRouteDataManage.c create mode 100644 TSCP/src/APP/ciapp/Route/LongRouteDataManage.h create mode 100644 TSCP/src/APP/ciapp/Route/RouteConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Route/RouteConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Route/RouteDataManage.c create mode 100644 TSCP/src/APP/ciapp/Route/RouteDataManage.h create mode 100644 TSCP/src/APP/ciapp/Route/RouteDefine.h create mode 100644 TSCP/src/APP/ciapp/SGBJ/SGBJConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/SGBJ/SGBJConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/SGBJ/SGBJDefine.h create mode 100644 TSCP/src/APP/ciapp/SPKS/SpksConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/SPKS/SpksConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/SPKS/SpksDataManage.c create mode 100644 TSCP/src/APP/ciapp/SPKS/SpksDataManage.h create mode 100644 TSCP/src/APP/ciapp/SPKS/SpksDefine.h create mode 100644 TSCP/src/APP/ciapp/Section/AxisConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Section/AxisConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/AxisSectionConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Section/AxisSectionConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/AxisSectionDataManage.c create mode 100644 TSCP/src/APP/ciapp/Section/AxisSectionDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/LinkConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Section/LinkConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/LinkLineConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/LogicSectionConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Section/LogicSectionConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/LogicSectionDataManage.c create mode 100644 TSCP/src/APP/ciapp/Section/LogicSectionDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/PhysicalSectionConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Section/PhysicalSectionConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/PhysicalSectionDataManage.c create mode 100644 TSCP/src/APP/ciapp/Section/PhysicalSectionDataManage.h create mode 100644 TSCP/src/APP/ciapp/Section/SectionDefine.h create mode 100644 TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess.c create mode 100644 TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess_api.h create mode 100644 TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess_define.h create mode 100644 TSCP/src/APP/ciapp/Signal/SignalConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Signal/SignalConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Signal/SignalDataManage.c create mode 100644 TSCP/src/APP/ciapp/Signal/SignalDataManage.h create mode 100644 TSCP/src/APP/ciapp/Signal/SignalDefine.h create mode 100644 TSCP/src/APP/ciapp/Switch/SwitchConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/Switch/SwitchConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/Switch/SwitchDataManage.c create mode 100644 TSCP/src/APP/ciapp/Switch/SwitchDataManage.h create mode 100644 TSCP/src/APP/ciapp/Switch/SwitchDefine.h create mode 100644 TSCP/src/APP/ciapp/System/CiSystemDefine.h create mode 100644 TSCP/src/APP/ciapp/System/SystemConfigDefine.h create mode 100644 TSCP/src/APP/ciapp/System/SystemParameterManage.c create mode 100644 TSCP/src/APP/ciapp/System/SystemParameterManage.h create mode 100644 TSCP/src/APP/ciapp/Train/EvacuationAreaManage.c create mode 100644 TSCP/src/APP/ciapp/Train/EvacuationAreaManage.h create mode 100644 TSCP/src/APP/ciapp/Train/TrainDataManage.c create mode 100644 TSCP/src/APP/ciapp/Train/TrainDataManage.h create mode 100644 TSCP/src/APP/ciapp/Train/TrainDefine.h create mode 100644 TSCP/src/APP/ciapp/Train/TrainOnAcManage.c create mode 100644 TSCP/src/APP/ciapp/Train/TrainOnAcManage.h create mode 100644 TSCP/src/APP/ciapp/Transmit/TransmitDefine.h create mode 100644 TSCP/src/APP/ciapp/Transmit/TransmitStateDataManage.c create mode 100644 TSCP/src/APP/ciapp/Transmit/TransmitStateDataManage.h create mode 100644 TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDataManage.c create mode 100644 TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDataManage.h create mode 100644 TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDefine.h create mode 100644 TSCP/src/APP/ciapp/WLBrake/WLBrakeDataManage.c create mode 100644 TSCP/src/APP/ciapp/WLBrake/WLBrakeDataManage.h create mode 100644 TSCP/src/APP/ciapp/WLBrake/WLBrakeDefine.h create mode 100644 TSCP/src/APP/ciapp/WLScreen/WLScreenDataManage.c create mode 100644 TSCP/src/APP/ciapp/WLScreen/WLScreenDataManage.h create mode 100644 TSCP/src/APP/ciapp/WLScreen/WLScreenDataPrepare.c create mode 100644 TSCP/src/APP/ciapp/WLScreen/WLScreenDataPrepare.h create mode 100644 TSCP/src/APP/ciapp/WLScreen/WLScreenLogicProcess.c create mode 100644 TSCP/src/APP/ciapp/WLScreen/WLScreenLogicProcess.h create mode 100644 TSCP/src/APP/ciapp/WLScreen/WholeLineScreenAPI.c create mode 100644 TSCP/src/APP/ciapp/WLScreen/WholeLineScreenAPI.h create mode 100644 TSCP/src/APP/ciapp/WLScreen/WholeLineScreenDefine.h create mode 100644 TSCP/src/APP/ciapp/WashMachine/WashMachineConfigDataManage.c create mode 100644 TSCP/src/APP/ciapp/WashMachine/WashMachineConfigDataManage.h create mode 100644 TSCP/src/APP/ciapp/WashMachine/WashMachineDataManage.c create mode 100644 TSCP/src/APP/ciapp/WashMachine/WashMachineDataManage.h create mode 100644 TSCP/src/APP/ciapp/WashMachine/WashMachineDefine.h create mode 100644 TSCP/src/DRV/imx8_drv_gpio.c create mode 100644 TSCP/src/DRV/imx8_drv_gpio.h create mode 100644 TSCP/src/DRV/imx8_drv_i2c.c create mode 100644 TSCP/src/DRV/imx8_drv_i2c.h create mode 100644 TSCP/src/MSCP/CFM/CFM_Net.c create mode 100644 TSCP/src/MSCP/CFM/CFM_Net.h create mode 100644 TSCP/src/MSCP/CFM/CFM_Raw.c create mode 100644 TSCP/src/MSCP/CFM/CFM_Raw.h create mode 100644 TSCP/src/MSCP/CM/CM_Atomic.h create mode 100644 TSCP/src/MSCP/CM/CM_CRC32.c create mode 100644 TSCP/src/MSCP/CM/CM_CRC32.h create mode 100644 TSCP/src/MSCP/CM/CM_Com.c create mode 100644 TSCP/src/MSCP/CM/CM_Com.h create mode 100644 TSCP/src/MSCP/CM/CM_Convert.c create mode 100644 TSCP/src/MSCP/CM/CM_Convert.h create mode 100644 TSCP/src/MSCP/CM/CM_FFFE.c create mode 100644 TSCP/src/MSCP/CM/CM_FFFE.h create mode 100644 TSCP/src/MSCP/CM/CM_IniFile.c create mode 100644 TSCP/src/MSCP/CM/CM_IniFile.h create mode 100644 TSCP/src/MSCP/CM/CM_MD5.c create mode 100644 TSCP/src/MSCP/CM/CM_MD5.h create mode 100644 TSCP/src/MSCP/CM/CM_MQ.c create mode 100644 TSCP/src/MSCP/CM/CM_MQ.h create mode 100644 TSCP/src/MSCP/CM/CM_MQ_Light.c create mode 100644 TSCP/src/MSCP/CM/CM_MQ_Light.h create mode 100644 TSCP/src/MSCP/CM/CM_Memory.c create mode 100644 TSCP/src/MSCP/CM/CM_Memory.h create mode 100644 TSCP/src/MSCP/CM/CM_MultiThread.h create mode 100644 TSCP/src/MSCP/CM/CM_MultiThread_Priority.h create mode 100644 TSCP/src/MSCP/CM/CM_MultiThread_qnx.c create mode 100644 TSCP/src/MSCP/CM/CM_MultiThread_vxworks.c create mode 100644 TSCP/src/MSCP/CM/CM_MultiThread_windows.c create mode 100644 TSCP/src/MSCP/CM/CM_Mutex.h create mode 100644 TSCP/src/MSCP/CM/CM_Mutex_qnx.c create mode 100644 TSCP/src/MSCP/CM/CM_Mutex_vxworks.c create mode 100644 TSCP/src/MSCP/CM/CM_Mutex_windows.c create mode 100644 TSCP/src/MSCP/CM/CM_Queue.c create mode 100644 TSCP/src/MSCP/CM/CM_Queue.h create mode 100644 TSCP/src/MSCP/CM/CM_RingBuf.c create mode 100644 TSCP/src/MSCP/CM/CM_RingBuf.h create mode 100644 TSCP/src/MSCP/CM/CM_Sem.h create mode 100644 TSCP/src/MSCP/CM/CM_Sem_qnx.c create mode 100644 TSCP/src/MSCP/CM/CM_Sem_vxworks.c create mode 100644 TSCP/src/MSCP/CM/CM_Sem_windows.c create mode 100644 TSCP/src/MSCP/CM/CM_Socket.c create mode 100644 TSCP/src/MSCP/CM/CM_Socket.h create mode 100644 TSCP/src/MSCP/CM/CM_TCP.c create mode 100644 TSCP/src/MSCP/CM/CM_TCP.h create mode 100644 TSCP/src/MSCP/CM/CM_Time.c create mode 100644 TSCP/src/MSCP/CM/CM_Time.h create mode 100644 TSCP/src/MSCP/CM/CM_Types.h create mode 100644 TSCP/src/MSCP/CM/CM_UDP.c create mode 100644 TSCP/src/MSCP/CM/CM_UDP.h create mode 100644 TSCP/src/MSCP/DFM/DFM_DRV.h create mode 100644 TSCP/src/MSCP/DFM/DFM_DRV_QNX.c create mode 100644 TSCP/src/MSCP/DFM/DFM_DRV_WIN.c create mode 100644 TSCP/src/MSCP/DFM/DFM_Time.c create mode 100644 TSCP/src/MSCP/DFM/DFM_Time.h create mode 100644 TSCP/src/MSCP/MSCP_APP_API.c create mode 100644 TSCP/src/MSCP/MSCP_APP_API.h create mode 100644 TSCP/src/MSCP/MSCP_APP_Interface.h create mode 100644 TSCP/src/MSCP/MSCP_Define.h create mode 100644 TSCP/src/MSCP/MSCP_main.c create mode 100644 TSCP/src/MSCP/MSCP_main.h create mode 100644 TSCP/src/MSCP/PFM/PFM_CPUCheck.c create mode 100644 TSCP/src/MSCP/PFM/PFM_CPUCheck.h create mode 100644 TSCP/src/MSCP/PFM/PFM_CPUUsage.c create mode 100644 TSCP/src/MSCP/PFM/PFM_CPUUsage.h create mode 100644 TSCP/src/MSCP/PFM/PFM_Cfg.c create mode 100644 TSCP/src/MSCP/PFM/PFM_Cfg.h create mode 100644 TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.c create mode 100644 TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.h create mode 100644 TSCP/src/MSCP/PFM/PFM_FS.c create mode 100644 TSCP/src/MSCP/PFM/PFM_FS.h create mode 100644 TSCP/src/MSCP/PFM/PFM_InputOutput.c create mode 100644 TSCP/src/MSCP/PFM/PFM_InputOutput.h create mode 100644 TSCP/src/MSCP/PFM/PFM_Log.c create mode 100644 TSCP/src/MSCP/PFM/PFM_Log.h create mode 100644 TSCP/src/MSCP/PFM/PFM_MemCheck.c create mode 100644 TSCP/src/MSCP/PFM/PFM_MemCheck.h create mode 100644 TSCP/src/MSCP/PFM/PFM_MemoryCheck.c create mode 100644 TSCP/src/MSCP/PFM/PFM_MemoryCheck.h create mode 100644 TSCP/src/MSCP/PFM/PFM_RemoteUpdate.c create mode 100644 TSCP/src/MSCP/PFM/PFM_RemoteUpdate.h create mode 100644 TSCP/src/MSCP/PFM/PFM_SelfCheck.c create mode 100644 TSCP/src/MSCP/PFM/PFM_SelfCheck.h create mode 100644 TSCP/src/MSCP/SFM/SFM_2oo2.c create mode 100644 TSCP/src/MSCP/SFM/SFM_2oo2.h create mode 100644 TSCP/src/MSCP/SFM/SFM_2x2.c create mode 100644 TSCP/src/MSCP/SFM/SFM_2x2.h create mode 100644 TSCP/src/MSCP/SFM/SFM_Prtcl.c create mode 100644 TSCP/src/MSCP/SFM/SFM_Prtcl.h create mode 100644 TSCP/src/MSCP/SFM/SFM_package.c create mode 100644 TSCP/src/MSCP/SFM/SFM_package.h create mode 100644 TSCP/src/MSCP_CFG/MSCP_Cfg.h create mode 100644 TSCP/src/commoncode/common/CRC16.c create mode 100644 TSCP/src/commoncode/common/CRC16.h create mode 100644 TSCP/src/commoncode/common/CRC32.c create mode 100644 TSCP/src/commoncode/common/CRC32.h create mode 100644 TSCP/src/commoncode/common/CbtcVersion.c create mode 100644 TSCP/src/commoncode/common/CbtcVersion.h create mode 100644 TSCP/src/commoncode/common/CommonBit.c create mode 100644 TSCP/src/commoncode/common/CommonBit.h create mode 100644 TSCP/src/commoncode/common/CommonCRC.c create mode 100644 TSCP/src/commoncode/common/CommonCRC.h create mode 100644 TSCP/src/commoncode/common/CommonMemory.c create mode 100644 TSCP/src/commoncode/common/CommonMemory.h create mode 100644 TSCP/src/commoncode/common/CommonQueue.c create mode 100644 TSCP/src/commoncode/common/CommonQueue.h create mode 100644 TSCP/src/commoncode/common/CommonRecord.c create mode 100644 TSCP/src/commoncode/common/CommonRecord.h create mode 100644 TSCP/src/commoncode/common/CommonStack.c create mode 100644 TSCP/src/commoncode/common/CommonStack.h create mode 100644 TSCP/src/commoncode/common/CommonTypes.h create mode 100644 TSCP/src/commoncode/common/Convert.c create mode 100644 TSCP/src/commoncode/common/Convert.h create mode 100644 TSCP/src/commoncode/common/DataPackage.c create mode 100644 TSCP/src/commoncode/common/DataPackage.h create mode 100644 TSCP/src/commoncode/common/FFFE.c create mode 100644 TSCP/src/commoncode/common/FFFE.h create mode 100644 TSCP/src/commoncode/common/Translate0203.c create mode 100644 TSCP/src/commoncode/common/Translate0203.h create mode 100644 TSCP/src/commoncode/common/VobcNetPack.c create mode 100644 TSCP/src/commoncode/common/VobcNetPack.h create mode 100644 TSCP/src/commoncode/commoncode_config_vxworks/CommonConfig.h create mode 100644 TSCP/src/dqu_common/dqu_cbtc_common/dquCbtcConfigData.c create mode 100644 TSCP/src/dqu_common/dqu_cbtc_common/dquCbtcConfigData.h create mode 100644 TSCP/src/dqu_common/dqu_dfs_common/dfsDataRead.c create mode 100644 TSCP/src/dqu_common/dqu_dfs_common/dfsDataRead.h create mode 100644 TSCP/src/dqu_common/dqu_dfs_common/dquCbtcType.c create mode 100644 TSCP/src/dqu_common/dqu_dfs_common/dquCbtcType.h create mode 100644 TSCP/src/dqu_common/dqu_dfs_common/dquDataTypeDefine.h create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquEmapInit.c create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquEmapInit.h create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquQuery.c create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquQuery.h create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquQueryExp.c create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquQueryExp.h create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquStructInit.c create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquStructInit.h create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dquVobcCommonStru.h create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dsuEmapDefine.h create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dsuStruct.h create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dsuVar.c create mode 100644 TSCP/src/dqu_common/dqu_emap_common/dsuVar.h create mode 100644 TSCP/src/dqu_common/dqu_idmap_common/dquIdmapInit.c create mode 100644 TSCP/src/dqu_common/dqu_idmap_common/dquIdmapInit.h create mode 100644 TSCP/src/dqu_common/dqu_idmap_common/dquIdmapQuery.c create mode 100644 TSCP/src/dqu_common/dqu_idmap_common/dquIdmapQuery.h create mode 100644 TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapStruct.h create mode 100644 TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapVar.c create mode 100644 TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapVar.h create mode 100644 TSCP/src/main/2oo2/processor.h create mode 100644 TSCP/src/main/2oo2/simulation2oo2.c create mode 100644 TSCP/src/main/2oo2/vxWorks.h create mode 100644 TSCP/src/main/CiSimulation.cpp create mode 100644 TSCP/src/main/CiSimulation.h create mode 100644 TSCP/src/main/DeviceInfoManager/readxmltodata.cpp create mode 100644 TSCP/src/main/DeviceInfoManager/readxmltodata.h create mode 100644 TSCP/src/main/DeviceInfoManager/tinyxml/tinystr.cpp create mode 100644 TSCP/src/main/DeviceInfoManager/tinyxml/tinystr.h create mode 100644 TSCP/src/main/DeviceInfoManager/tinyxml/tinyxml.cpp create mode 100644 TSCP/src/main/DeviceInfoManager/tinyxml/tinyxml.h create mode 100644 TSCP/src/main/DeviceInfoManager/tinyxml/tinyxmlerror.cpp create mode 100644 TSCP/src/main/DeviceInfoManager/tinyxml/tinyxmlparser.cpp create mode 100644 TSCP/src/main/RecordClass/RecordClass.cpp create mode 100644 TSCP/src/main/RecordClass/RecordClass.h create mode 100644 TSCP/src/main/SimDef/SimDef.h create mode 100644 TSCP/src/main/ccov/Ccov_RSSPII_Parser.cpp create mode 100644 TSCP/src/main/ccov/Ccov_RSSPII_Parser.h create mode 100644 TSCP/src/main/ccov/Ccov_RsspII.cpp create mode 100644 TSCP/src/main/ccov/Ccov_RsspII.h create mode 100644 TSCP/src/main/ccov/Ccov_TcpCallBackDef.h create mode 100644 TSCP/src/main/ccov/Ccov_TcpSer.cpp create mode 100644 TSCP/src/main/ccov/Ccov_TcpSer.h create mode 100644 TSCP/src/main/ccov/EndPointConStatus.h create mode 100644 TSCP/src/main/ccov/TcpConnection_Ser.cpp create mode 100644 TSCP/src/main/ccov/TcpConnection_Ser.h create mode 100644 TSCP/src/main/ccov/ccov.cpp create mode 100644 TSCP/src/main/ccov/ccov.h create mode 100644 TSCP/src/main/commLib/CRC32long.c create mode 100644 TSCP/src/main/commLib/CRC32long.h create mode 100644 TSCP/src/main/ini/ReadCcovConfigInfo.cpp create mode 100644 TSCP/src/main/ini/ReadCcovConfigInfo.h create mode 100644 TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbDataStru.h create mode 100644 TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbFunc.c create mode 100644 TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbFunc.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbConfig.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbLnkNodeMgr.c create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbLnkNodeMgr.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbMessageInfo.c create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbMessageInfo.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbProtcl.c create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbProtcl.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclCommon.c create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclCommon.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclConfigMessage.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/FsfbRecordDelare.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/RpHandleInterface.c create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/RpHandleInterface.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/RpHandlePlatform.h create mode 100644 TSCP/src/protocol/fsfb/common_fsfb/fsfbProtclStruct.h create mode 100644 TSCP/src/protocol/protocol_cbtc/common_dqu_protocol/dsuProtclFun.c create mode 100644 TSCP/src/protocol/protocol_cbtc/common_dqu_protocol/dsuProtclFun.h create mode 100644 TSCP/src/protocol/protocol_cbtc/common_protocol/ProtclManage.c create mode 100644 TSCP/src/protocol/protocol_cbtc/common_protocol/ProtclManage.h create mode 100644 TSCP/src/protocol/protocol_cbtc/common_protocol/protclInterFun.c create mode 100644 TSCP/src/protocol/protocol_cbtc/common_protocol/protclInterFun.h create mode 100644 TSCP/src/protocol/protocol_cbtc/common_protocol/protclMgeCfg.h create mode 100644 TSCP/src/protocol/protocol_cbtc/common_protocol/protclStruct.h create mode 100644 TSCP/src/protocol/protocol_cbtc/common_protocol_config/protocolConfig.h create mode 100644 TSCP/src/protocol/redun_record_cbtc/common_dqu_rp/dsuRpFunc.c create mode 100644 TSCP/src/protocol/redun_record_cbtc/common_dqu_rp/dsuRpFunc.h create mode 100644 TSCP/src/protocol/redun_record_cbtc/common_redun/RpDeclare.h create mode 100644 TSCP/src/protocol/redun_record_cbtc/common_redun/RpInterface.c create mode 100644 TSCP/src/protocol/redun_record_cbtc/common_redun/RpInterface.h create mode 100644 TSCP/src/protocol/redun_record_cbtc/common_redun/RpPlatform.h create mode 100644 TSCP/src/protocol/redun_record_cbtc/common_redun/RpStruct.h create mode 100644 TSCP/src/protocol/redun_record_cbtc/common_redun_record_config/RpConfig.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrDataStru.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrFunc.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrFunc.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/Rsr.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/Rsr.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrCommon.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrCommon.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrPlatform.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrRecordDelare.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspCommon.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspCommon.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspIF.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspInit.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspLnkNodeMgr.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspLnkNodeMgr.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspOutput.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspRecive.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspStruct.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspTmpMsgLnkCommon.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspTmpMsgLnkCommon.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigDeclare.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigInterface.c create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigInterface.h create mode 100644 TSCP/src/protocol/rsr_record_cbtc/common_rsr_record_config/RsrConfig.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2DataStru.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2Func.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2Func.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Base.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Base.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Define.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_RingQueue.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_RingQueue.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Type.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclBaseParse.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclBaseParse.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclParseManage.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclParseManage.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Common.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Common.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2LnkNodeMgr.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2LnkNodeMgr.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Struct.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/crc.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/crc.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/des.c create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/des.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/typedefine.h create mode 100644 TSCP/src/protocol/rssp2_record_cbtc/rsspii_record_config_cbtc/Rssp2Configl.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspDataStru.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspFunc.c create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspFunc.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspCommonWl.c create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspCommonWl.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspIFWl.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspInitWl.c create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspLnkNodeMgrWl.c create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspLnkNodeMgrWl.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspOutputWl.c create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspReciveWl.c create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspRecordDelareWl.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspStructWl.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspTmpMsgLnkCommonWl.c create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspTmpMsgLnkCommonWl.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspWl.c create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspWl.h create mode 100644 TSCP/src/protocol/rssp_record_cbtc1/common_rssp_record_config/RsspConfigWl.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_dqu_sfp/dsuRelatedDeal.c create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_dqu_sfp/dsuRelatedDeal.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpDeclare.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpLinkManage.c create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpLinkManage.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclCommon.c create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclCommon.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclInit.c create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclReceive.c create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclReceive.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclStruct.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtcl_Output.c create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtcl_Output.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpWindowsTimeCounter.c create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpWindowsTimeCounter.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpplatform.h create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp/协议c和cpp转换.bat create mode 100644 TSCP/src/protocol/sfp_record_cbtc1/common_sfp_nr_config/sfpConfig.h diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..486a232 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.zip filter=lfs diff=lfs merge=lfs -text diff --git a/TSCP/Makefile b/TSCP/Makefile new file mode 100644 index 0000000..7580ed5 --- /dev/null +++ b/TSCP/Makefile @@ -0,0 +1,161 @@ +ARTIFACT = RCOCI + +#Build architecture/variant string, possible values: x86, armv7le, etc... +PLATFORM ?= aarch64le + +#Build profile, possible values: release, debug, profile, coverage +BUILD_PROFILE ?= debug + +CONFIG_NAME ?= $(PLATFORM)-$(BUILD_PROFILE) +OUTPUT_DIR = build/$(CONFIG_NAME) +TARGET = $(OUTPUT_DIR)/$(ARTIFACT) + +#Compiler definitions + +CC = qcc -Vgcc_nto$(PLATFORM) -D _TSCP_ +CXX = qcc -lang-c++ -Vgcc_nto$(PLATFORM) -D _TSCP_ +LD = $(CC) + +#User defined include/preprocessor flags and libraries + +#INCLUDES += -I/path/to/my/lib/include +#INCLUDES += -I../mylib/public +INCLUDES += -I ./src/APP \ + -I ./src/APP/ciapp/2oo2 \ + -I ./src/APP/ciapp/AllAutoReturn \ + -I ./src/APP/ciapp/AutoReturn \ + -I ./src/APP/ciapp/AutoRoute \ + -I ./src/APP/ciapp/AxisAssert \ + -I ./src/APP/ciapp/AxisSort \ + -I ./src/APP/ciapp/CutoffPoint \ + -I ./src/APP/ciapp/DataManage \ + -I ./src/APP/ciapp/DebugPrint \ + -I ./src/APP/ciapp/Deployment \ + -I ./src/APP/ciapp/DiffLineDev \ + -I ./src/APP/ciapp/EnvelopeManage \ + -I ./src/APP/ciapp/ERROR \ + -I ./src/APP/ciapp/ESB \ + -I ./src/APP/ciapp/FloodGate \ + -I ./src/APP/ciapp/Garagedoor \ + -I ./src/APP/ciapp/HLHTMsgHead \ + -I ./src/APP/ciapp/Indicator \ + -I ./src/APP/ciapp/Initial \ + -I ./src/APP/ciapp/InvadeSection \ + -I ./src/APP/ciapp/IO \ + -I ./src/APP/ciapp/LogicManage \ + -I ./src/APP/ciapp/LogicProcess \ + -I ./src/APP/ciapp/LogRecord \ + -I ./src/APP/ciapp/Main \ + -I ./src/APP/ciapp/Mask \ + -I ./src/APP/ciapp/NonAutoReturn \ + -I ./src/APP/ciapp/NonRoute \ + -I ./src/APP/ciapp/Overlap \ + -I ./src/APP/ciapp/ParsePack \ + -I ./src/APP/ciapp/PSC \ + -I ./src/APP/ciapp/PSD \ + -I ./src/APP/ciapp/QueryFiles \ + -I ./src/APP/ciapp/Relay \ + -I ./src/APP/ciapp/RemoteRM \ + -I ./src/APP/ciapp/ReverseCut \ + -I ./src/APP/ciapp/ReverseRoute \ + -I ./src/APP/ciapp/Route \ + -I ./src/APP/ciapp/Section \ + -I ./src/APP/ciapp/SectionStateProcess \ + -I ./src/APP/ciapp/SGBJ \ + -I ./src/APP/ciapp/Signal \ + -I ./src/APP/ciapp/SPKS \ + -I ./src/APP/ciapp/Switch \ + -I ./src/APP/ciapp/System \ + -I ./src/APP/ciapp/Train \ + -I ./src/APP/ciapp/Transmit \ + -I ./src/APP/ciapp/VirtualDevice \ + -I ./src/APP/ciapp/WashMachine \ + -I ./src/APP/ciapp/WLScreen \ + -I ./src/APP/ciapp/WLBrake \ + -I ./src/APP/PU13_integration_config \ + -I ./src/commoncode/common \ + -I ./src/commoncode/commoncode_config_vxworks \ + -I ./src/dqu_common/dqu_idmap_common \ + -I ./src/dqu_common/dqu_emap_common \ + -I ./src/dqu_common/dqu_dfs_common \ + -I ./src/dqu_common/dqu_cbtc_common \ + -I .\src\protocol\fsfb\common_dqu_fsfb \ + -I .\src\protocol\fsfb\common_fsfb \ + -I .\src\protocol\protocol_cbtc\common_protocol_config \ + -I .\src\protocol\protocol_cbtc\common_dqu_protocol \ + -I .\src\protocol\protocol_cbtc\common_protocol \ + -I .\src\protocol\redun_record_cbtc\common_dqu_rp \ + -I .\src\protocol\redun_record_cbtc\common_redun \ + -I .\src\protocol\redun_record_cbtc\common_redun_record_config \ + -I .\src\protocol\rsr_record_cbtc\common_dqu_rsr \ + -I .\src\protocol\rsr_record_cbtc\common_rsr \ + -I .\src\protocol\rsr_record_cbtc\common_rsr\rssp \ + -I .\src\protocol\rsr_record_cbtc\common_rsr\sig \ + -I .\src\protocol\rsr_record_cbtc\common_rsr_record_config \ + -I .\src\protocol\rssp_record_cbtc1\common_dqu_rssp \ + -I .\src\protocol\rssp_record_cbtc1\common_rssp \ + -I .\src\protocol\rssp_record_cbtc1\common_rssp_record_config \ + -I .\src\protocol\rssp2_record_cbtc\dqu_rsspii_cbtc \ + -I .\src\protocol\rssp2_record_cbtc\rsspii_cbtc \ + -I .\src\protocol\rssp2_record_cbtc\rsspii_record_config_cbtc \ + -I .\src\protocol\sfp_record_cbtc1\common_dqu_sfp \ + -I .\src\protocol\sfp_record_cbtc1\common_sfp \ + -I .\src\protocol\sfp_record_cbtc1\common_sfp_nr_config \ + -I ./src/DRV \ + -I ./src/MSCP \ + -I ./src/MSCP/CM \ + -I ./src/MSCP/DFM \ + -I ./src/MSCP/CFM \ + -I ./src/MSCP/SFM \ + -I ./src/MSCP/PFM \ + -I ./src/MSCP_CFG \ + +#LIBS += -L/path/to/my/lib/$(PLATFORM)/usr/lib -lmylib +#LIBS += -L../mylib/$(OUTPUT_DIR) -lmylib + +#Compiler flags for build profiles +CCFLAGS_release += -O0 +CCFLAGS_debug += -g -O0 -fno-builtin +CCFLAGS_coverage += -g -O0 -ftest-coverage -fprofile-arcs -nopipe -Wc,-auxbase-strip,$@ +LDFLAGS_coverage += -ftest-coverage -fprofile-arcs +CCFLAGS_profile += -g -O0 -finstrument-functions +LIBS_profile += -lprofilingS + +#Generic compiler flags (which include build type flags) +CCFLAGS_all += -w -fmessage-length=0 +CCFLAGS_all += $(CCFLAGS_$(BUILD_PROFILE)) +#Shared library has to be compiled with -fPIC +#CCFLAGS_all += -fPIC +LDFLAGS_all += -l socket -l m +LDFLAGS_all += $(LDFLAGS_$(BUILD_PROFILE)) +LIBS_all += $(LIBS_$(BUILD_PROFILE)) +DEPS = -Wp,-MMD,$(@:%.o=%.d),-MT,$@ + +#Macro to expand files recursively: parameters $1 - directory, $2 - extension, i.e. cpp +rwildcard = $(wildcard $(addprefix $1/*.,$2)) $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2)) + +#Source list +SRCS = $(call rwildcard, src, c) + +#Object files list +OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(basename $(SRCS)))) + +#Compiling rule +$(OUTPUT_DIR)/%.o: %.c + @mkdir -p $(dir $@) + $(CC) -c $(DEPS) -o $@ $(INCLUDES) $(CCFLAGS_all) $(CCFLAGS) $< + +#Linking rule +$(TARGET):$(OBJS) + $(LD) -o $(TARGET) $(LDFLAGS_all) $(LDFLAGS) $(OBJS) $(LIBS_all) $(LIBS) + +#Rules section for default compilation and linking +all: $(TARGET) + +clean: + rm -fr $(OUTPUT_DIR) + +rebuild: clean all + +#Inclusion of dependencies (object files to source and includes) +-include $(OBJS:%.o=%.d) \ No newline at end of file diff --git a/TSCP/src/APP/APP_API.c b/TSCP/src/APP/APP_API.c new file mode 100644 index 0000000..6e0cd90 --- /dev/null +++ b/TSCP/src/APP/APP_API.c @@ -0,0 +1,797 @@ +/* +这是一个示例文件,各产品应当参考本文件,开发自己的APP_API.c +也可以根据自身项目情况将这些函数分散到不同的.c文件中,只保持APP_API.h不变即可 +*/ +#include "APP_API.h" +#include "MSCP_APP_API.h" +#include "MSCP_APP_Interface.h" +#include "2oo2InterfaceDataManage.h" +#include "2oo2DataTransferManage.h" +#include "commonQueryStruDef.h" +#include "SystemParameterManage.h" +#include "ConfigDataReadManage.h" +#include "ProtclParam.h" +#include "../Deployment/DeploymentExtern.h" + + +static CM_UINT32 gFollowDataLen = 0u; /*应用跟随数据长度*/ +static CM_UINT8 gFollowData[MSCP_FOLLOW_BUFF_SIZE] = { 0 }; /*应用跟随数据*/ + +/* 内网安全通信配置参数,示例: */ +/* 内网安全通信配置参数,示例: */ +/*ATP、ATO、MMI间通信时,SFP协议使用的数据库数组: +*两端ATP分别当作ZC1和ZC2,ZC1为发起方; +*ATO为CI3,MMI为CI4,CCOV为CI5(CCOV仅为预留,暂无通信的需求).ZC与CI通信时ZC为发起方 +*总结各子系统ID为:两端ATP分别为0x5501,0x5502;ATO为0x7103;MMI为0x7104;CCOV为0x7105*/ +const CM_UINT8 g_SfpInnetParam[] = +{ + + 0,4,/*不同设备通信关系表记录个数*/ + /*记录的格式如下:*/ + /* 发起方 发起方发送数据 发起方报文 发起方报文 发起方接收Ack 跟随方 跟随方发送数据 跟随方运行 跟随方报文 此通信关系中成功发送 */ + /* 设备类型 通信类型 发送周期长度 最大延时 报文最大延时差 设备类型 通信类型 周期长度 最大延时 一包数据所需最小周期数 */ + /*ZC->CI*/ 0x22, 0x55, 0x01,0x1D, 0x01,0x1D, 0x01,0x1D, 0xff, 0x55, 0x00,0xC8, 0x00,0xC8, 0x02, + /*AOM->TIAS*/ 0x15, 0x55, 0x00,0xC8, 0x00,0xC8, 0x00,0xC8, 0x03, 0x55, 0x00,0xC8, 0x00,0xC8, 0x02, + /*AOM->ATP*/ 0x14, 0x55, 0x00,0xC8, 0x00,0xC8, 0x00,0xC8, 0x15, 0x55, 0x00,0xC8, 0x00,0xC8, 0x02, + /*主机->维护机*/ 0xD9, 0x55, 0x01,0x2c, 0x01,0x2C, 0x01,0x2C, 0xf8, 0x55, 0x00,0xc8, 0x00,0xc8, 0x02, + 0,2,/*相同设备通信关系表记录个数*/ + /*记录的格式如下:*/ + /* 发起方 发起方 发起方发送数据 发起方报文 发起方报文 发起方接收Ack 跟随方 跟随方 跟随方发送数据 跟随方运行 跟随方报文 此通信关系中成功发送 */ + /* 设备类型 设备ID 通信类型 发送周期长度 最大延时 报文最大延时差 设备类型 设备ID 通信类型 周期长度 最大延时 一包数据所需最小周期数 */ + /*AOM1->AOM2*/ 0x22, 1, 0x55, 0x00,0xC8, 0x00,0xC8, 0x00,0xC8, 0x22, 2, 0x55, 0x00,0xC8, 0x00,0xC8, 0x02, + /*ZC1->ZC2*/ 0x55, 1, 0x55, 0x00,0xC8, 0x00,0xC8, 0x00,0xC8, 0x55, 2, 0x55, 0x00,0xC8, 0x00,0xC8, 0x02 +}; + +/* 应用周期主逻辑2 */ +ENUM_CM_RETURN APP_API_MainFunc2(void); +/* 应用周期主逻辑3 */ +ENUM_CM_RETURN APP_API_MainFunc3(void); +/* 应用周期主逻辑4 */ +ENUM_CM_RETURN APP_API_MainFunc4(void); +/* 应用周期主逻辑4 */ +ENUM_CM_RETURN APP_API_MainFunc5(void); +/* 应用周期主逻辑4 */ +ENUM_CM_RETURN APP_API_MainFunc6(void); + +#if (kPLATFORM==kVXWORKS) +static ENUM_CM_RETURN AddOneAppCheckData(IN const UINT32 dwDataAddr, IN const UINT16 wDataLen); +static ENUM_CM_RETURN AddAppCheckData(UINT32* pConfigDataAdderBuf, UINT16* pConfigDataLenBuf, UINT16 wDataLen); +#endif + + +/** +* @brief 应用初始化 +* @param VitalBuf 关键数据数组 +* @param pVitalLen 关键数据长度 +* @return ENUM_CM_RETURN 初始化结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败(平台立即宕机) +* @details +* 2oo2双机的关键数据内容不一致时,2oo2初始化将失败——平台宕机; +* 2x2双系的关键数据内容不一致时,非主系运行的设备将宕机; +* 关键数据应尽可能短(如几个版本号或MD5码)总长不得超过200字节。 +*/ +ENUM_CM_RETURN APP_API_Init(OUT CM_UINT8 VitalBuf[200], OUT CM_UINT16* pVitalLen) +{ + ENUM_CM_RETURN retVal = ENUM_CM_FALSE; /*返回值*/ + UINT8 initRtn = 0U; /*应用初始化结果*/ + UINT16* pTiocFsVersion = NULL;/* 数据版本号 */ + +#if (kPLATFORM==kVXWORKS) + UINT16 wAppConfigDataLen = 0u; + UINT32 szConfigDataAddr[200u] = { 0u }; + UINT16 szConfigDataLen[200u] = { 0u }; + SERIAL_ID_FUNC pIsSendExtendBoard = NULL;/* 扩展板相关 */ + SERIAL_OUT_ATS_VOBC pReserveOutVobc = NULL; + SERIAL_IN_VOBC_ATS pReserveInAts = NULL; +#if 1 + UINT8 cSwtichFalg = FUNC_SWITCH_OFF; /* 预留 下版本支持 */ +#endif +#endif + + if ((NULL != VitalBuf) && (NULL != pVitalLen) && (192u >= *pVitalLen)) + { + initRtn = CiAppInitial(); + if (1u == initRtn) + { + retVal = ENUM_CM_TRUE; + } + else + { + ; /*返回失败*/ + } + } + else + { + ;/* 返回失败 */ + } + printf("CiAppInitial ret:%x\n", retVal); + if (ENUM_CM_TRUE == retVal) + { + /* 应用初始化成功 */ + + /* 获取数据版本号 */ + pTiocFsVersion = GetTiocFsVersion(); + + if (NULL != pTiocFsVersion) + { + /* 输出数据版本号 */ + ShortToChar(pTiocFsVersion[0], &VitalBuf[*pVitalLen]); + *pVitalLen += 2u; + ShortToChar(pTiocFsVersion[1], &VitalBuf[*pVitalLen]); + *pVitalLen += 2u; + ShortToChar(pTiocFsVersion[2], &VitalBuf[*pVitalLen]); + *pVitalLen += 2u; + ShortToChar(pTiocFsVersion[3], &VitalBuf[*pVitalLen]); + *pVitalLen += 2u; + } + else + { + retVal = ENUM_CM_FALSE; + } + } + else + { + ;/* 无处理 */ + } + printf("GetTiocFsVersion ret:%x\n", retVal); +#if (kPLATFORM==kVXWORKS) + if (ENUM_CM_TRUE == retVal) + { + /* 获取自检内存 */ + wAppConfigDataLen = GetTiocDeviceConfigData(szConfigDataAddr, szConfigDataLen, 200u); + + /* 添加自检内存 */ + if ((0u != wAppConfigDataLen) && (200u >= wAppConfigDataLen)) + { + retVal = AddAppCheckData(szConfigDataAddr, szConfigDataLen, wAppConfigDataLen); + printf("AddAppCheckData1 ret:%x\n", retVal); + } + else + { + retVal = ENUM_CM_FALSE; + } + } + else + { + ;/* 无处理 */ + } + printf("GetTiocDeviceConfigData ret:%x\n", retVal); + if (ENUM_CM_TRUE == retVal) + { + /* 获取自检内存 */ + wAppConfigDataLen = GetTiocSystemParameterData(szConfigDataAddr, szConfigDataLen, 200u); + + /* 添加自检内存 */ + if ((0u != wAppConfigDataLen) && (200u >= wAppConfigDataLen)) + { + retVal = AddAppCheckData(szConfigDataAddr, szConfigDataLen, wAppConfigDataLen); + printf("AddAppCheckData2 ret:%x\n", retVal); + } + else + { + retVal = ENUM_CM_FALSE; + } + } + else + { + ;/* 无处理 */ + } + printf("GetTiocSystemParameterData ret:%x\n", retVal); + if (ENUM_CM_TRUE == retVal) + { + pIsSendExtendBoard = Is_Send_ExtendBoard; + MSCP_SetSerial(pIsSendExtendBoard); + pReserveOutVobc = SerialOutAtsVobcFunc; + MSCP_SetOutAtsVobcFunc(pReserveOutVobc); + pReserveInAts = SerialInVobcAtsFunc; + MSCP_SetInVobcAtsFunc(pReserveInAts); +#if 1 + cSwtichFalg = GetCiFunctionSwitchConfig(FUNC_OC_200_INOUTNET); + + if (FUNC_SWITCH_ON == cSwtichFalg) + { + /*设置协议参数*/ + MSCP_ParamData(innetProtclParam, innetProtclParamLen); + } + else + { + /* 无处理 */ + } +#endif + + + /*设置主应用任务*/ + MSCP_SetAppFunc(APP_API_MainFunc, APP_API_MainFunc2, APP_API_MainFunc3, APP_API_MainFunc4, APP_API_MainFunc5); + } +#endif + + return retVal; +} + +/* +* @brief 提供给平台的初始化函数 +* @return无 +* @details +* 给平台提供FS版本号,维护ID、内网参数,系统版本号 +**/ +void APP_API_Data_Init() +{ + UINT8 fsVersBuffer[4] = { 0u }; + UINT8 appVersBuffer[4] = { 0u }; + UINT8 ciToCimDataBuffer[4] = { 0u }; + UINT8 deviceSum = 0u; /*通信设备数*/ + UINT16* pTiocFsVersion = NULL; /*FS版本号buff*/ + UINT16 ii = 0U; + UINT8 szFSFILEVersionFS[DFS_VERSION_LENGTH] = { 0 }; + UINT8 funcRetVal = 0U; + funcRetVal = dquGetFSVersion(DataPath, szFSFILEVersionFS); + +#if (kPLATFORM==kVXWORKS) + /*文件配置*/ + STRU_APP_CFG_T AppCfgInterface = { + .FS_NAME = "RCI.FS", /**< FS文件名称 */ + .APP_NAME = "RCOCI", /**< 应用文件名称 */ + .CYC_TIME = 300, /**< 系统周期 */ + .app_num = 1, /**< app任务数 */ + .M_2oo2_Enable = 0x55, /**< 2oo2功能开关 */ + .M_2x2_Enable = 0x55, /**< 2x2功能开关*/ + .M_InnetSafe_Enable = 0x55, /**< 内网安全通信功能开关 */ + .M_InnetRaw_Enable = 0xAA, /**< 内网透传通信功能开关 */ + .M_OutnetSafe_Enable = 0x55,/**< 外网安全通信功能开关 */ + .M_OutnetRaw_Enable = 0xAA, /**< 外网透传通信功能开关 */ + .M_CpuUsageGet_Enable = 0xAA,/**< 获取cpu使用率功能开关 */ + .M_RemoteUpdate_Enable = 0x55,/**< 远程部署内网安全通信功能开关 */ + .ID_Maintenance = DEVICE_TYPE_AIM, + .Start_Path = "/emmc1", /**< 程序启动路径 */ + .reboot_replycount = 10, /**< 重启确认报文回复次数 */ + .M_AutoReboot_Count = 3, /**< 自动重启次数 */ + .M_AutoClear_Days = 1, /**< 连续运行多久清空宕机次数的天数 */ + .CPU[0].IP_2oo2 = "192.168.0.11", /**< 2oo2通信IP */ + .CPU[0].IP_2x2 = "192.168.1.62", /**< 2x2通信IP */ + .CPU[0].IP_Out = "192.168.1.62", /**< 外网通信IP */ + .CPU[0].IP_Maintain = "192.168.146.101", /**< 维护通信IP */ + /*适用透传通道-选配*/ + .CPU[0].IP_Com = "192.168.1.62", /**< 通用通信IP */ + .CPU[0].IP_Com_Extend = "192.168.1.62",/**< 通用通信扩展IP */ + .CPU[0].Logger_PortBase = 55011, /**< 明文日志记录发送端口 */ + .CPU[0].Logger_PortCiphertext = 55002, /**< 暗文日志记录发送端口 */ + + .CPU[1].IP_2oo2 = "192.168.0.12", /**< 2oo2通信IP */ + .CPU[1].IP_2x2 = "192.168.2.62", /**< 2x2通信IP */ + .CPU[1].IP_Out = "192.168.2.62", /**< 外网通信IP */ + .CPU[1].IP_Maintain = "192.168.18.102", /**< 维护通信IP */ + /*适用透传通道-选配*/ + .CPU[1].IP_Com = "192.168.2.62", /**< 通用通信IP */ + .CPU[1].IP_Com_Extend = "192.168.2.62",/**< 通用通信扩展IP */ + .CPU[1].Logger_PortBase = 55012, /**< 明文日志记录发送端口 */ + .CPU[1].Logger_PortCiphertext = 55002, /**< 暗文日志记录发送端口 */ + + .CPU[2].IP_2oo2 = "192.168.0.21", /**< 2oo2通信IP */ + .CPU[2].IP_2x2 = "192.168.1.64", /**< 2x2通信IP */ + .CPU[2].IP_Out = "192.168.1.64", /**< 外网通信IP */ + .CPU[2].IP_Maintain = "192.168.146.103", /**< 维护通信IP */ + /*适用透传通道-选配*/ + .CPU[2].IP_Com = "192.168.1.64", /**< 通用通信IP */ + .CPU[2].IP_Com_Extend = "192.168.1.64",/**< 通用通信扩展IP */ + .CPU[2].Logger_PortBase = 55021, /**< 明文日志记录发送端口 */ + .CPU[2].Logger_PortCiphertext = 55002, /**< 暗文日志记录发送端口 */ + + .CPU[3].IP_2oo2 = "192.168.0.22", /**< 2oo2通信IP */ + .CPU[3].IP_2x2 = "192.168.2.64", /**< 2x2通信IP */ + .CPU[3].IP_Out = "192.168.2.64", /**< 外网通信IP */ + .CPU[3].IP_Maintain = "192.168.18.104", /**< 维护通信IP */ + /*适用透传通道-选配*/ + .CPU[3].IP_Com = "192.168.2.64", /**< 通用通信IP */ + .CPU[3].IP_Com_Extend = "192.168.2.64",/**< 通用通信扩展IP */ + .CPU[3].Logger_PortBase = 55022, /**< 明文日志记录发送端口 */ + .CPU[3].Logger_PortCiphertext = 55002, /**< 暗文日志记录发送端口 */ + /*通用端口配置*/ + .Port_Outnet_Safe = 54001, /**< 外网安全通信端口 */ + .Port_Innet_Safe = 53001, /**< 内网安全通信端口 */ + .Port_Outnet_Raw = 54002, /**< 外网透明传输端口 */ + .Port_Remote_Update = 50000, /**< 远程部署通信端口 */ + /*透传配置-选配*/ + .Port_Innet_Raw_Num = 0, /**< 内网透传端口数量 */ + .Port_Innet_Raw_Extend_Num = 0, /**< 内网透传扩展端口数量 */ + .Innet_Raw_Parameter[0].Port_Innet_Raw = 3956, /**< 内网透明传输端口 */ + .Innet_Raw_Parameter[0].Port_Type_Enable = RAW_COM_UDP, /**< 内网透明tcp传输模式 */ + .Innet_Raw_Parameter[0].Server_DevId = 0, /**< 服务端设备类型和id */ + .Innet_Raw_Parameter[0].TIME_STAMP_ENABLE = 0XAA, /**< 2取2乘时间戳使能开关 */ + .Innet_Raw_Parameter[0].INNET_2oo2_RAW = 0X55, /**< 透传通道2取开关 */ + .Innet_Raw_Parameter[0].INNET_2x2_RAW = 0XAA, /**< 透传通道2乘开关 */ + .Innet_Raw_Parameter[0].IP_InnetRaw_maddr = "224.0.0.31",/**< 内网透传的组播IP */ + + .Innet_Raw_Parameter[1].Port_Innet_Raw = 3956, /**< 内网透明传输端口 */ + .Innet_Raw_Parameter[1].Port_Type_Enable = RAW_COM_UDP, /**< 内网透明tcp传输模式 */ + .Innet_Raw_Parameter[1].Server_DevId = 0, /**< 服务端设备类型和id */ + .Innet_Raw_Parameter[1].TIME_STAMP_ENABLE = 0XAA, /**< 2取2乘时间戳使能开关 */ + .Innet_Raw_Parameter[1].INNET_2oo2_RAW = 0X55, /**< 透传通道2取开关 */ + .Innet_Raw_Parameter[1].INNET_2x2_RAW = 0XAA, /**< 透传通道2乘开关 */ + .Innet_Raw_Parameter[1].IP_InnetRaw_maddr = "224.0.0.32",/**< 内网透传的组播IP */ + /*外网通信配置*/ + .OutNetRed.CC_G_IP = "192.168.1.60", /**< 通控的内网IP */ + .OutNetRed.CC_P_IP = "192.168.2.60", /**< 通控的内网IP */ + .OutNetRed.EXTEND_G_IP = "192.168.1.70", /**< 扩展板卡的内网IP */ + .OutNetRed.EXTEND_P_IP = "192.168.2.70", /**< 扩展板卡的内网IP */ + .OutNetRed.OutnetSafe_Port = 54001, /**< 外网安全通信端口 */ + .OutNetRed.OutnetRaw_Port = 54002, /**< 外网透传通信端口 */ + .OutNetRed.InnetRaw_Port = 53003, /**< 内网透传通信端口 */ + + .OutNetBlue.CC_G_IP = "192.168.1.61", /**< 通控的内网IP */ + .OutNetBlue.CC_P_IP = "192.168.2.61", /**< 通控的内网IP */ + .OutNetBlue.EXTEND_G_IP = "192.168.1.71", /**< 扩展板卡的内网IP */ + .OutNetBlue.EXTEND_P_IP = "192.168.2.71", /**< 扩展板卡的内网IP */ + .OutNetBlue.OutnetSafe_Port = 54001, /**< 外网安全通信端口 */ + .OutNetBlue.OutnetRaw_Port = 54002, /**< 外网透传通信端口 */ + .OutNetBlue.InnetRaw_Port = 53003, /**< 内网透传通信端口 */ + /*日志记录目标设备IP配置*/ + .Logger_G_IP = "192.168.146.100", /**< 绿网日志记录IP */ + .Logger_P_IP = "192.168.18.100", /**< 紫网日志记录IP */ + /*内网通信设备注册最大支持0-255*/ + .INNET_COM_NUM = 1, /**< 内网通信设备数量 */ + .INNET_COM_CFG[0].InnetID = DEVICE_TYPE_AIM, /**< 内网通信ID */ + .INNET_COM_CFG[0].IP_G = (CM_UINT32)inet_addr("192.168.146.100"),/**< 绿网IP */ + .INNET_COM_CFG[0].Port_Raw_G = 55004, /**< 绿网透传端口 */ + .INNET_COM_CFG[0].Port_Safe_G = 55003, /**< 绿网安全端口 */ + .INNET_COM_CFG[0].IP_P = (CM_UINT32)inet_addr("192.168.18.100"),/**< 紫网IP */ + .INNET_COM_CFG[0].Port_Raw_P = 55004, /**< 紫网透传端口 */ + .INNET_COM_CFG[0].Port_Safe_P = 55003, /**< 紫网安全端口 */ + }; + MSCP_Set_APP_ConfigData(&AppCfgInterface); +#endif + + /*组FS版本号*/ + ii = 0U; + fsVersBuffer[ii++] = szFSFILEVersionFS[0]; + fsVersBuffer[ii++] = szFSFILEVersionFS[1]; + fsVersBuffer[ii++] = szFSFILEVersionFS[2]; + fsVersBuffer[ii++] = szFSFILEVersionFS[3]; + + /*组软件版本号*/ + ii = 0U; + appVersBuffer[ii++] = VER_INTE_PROJECT; + appVersBuffer[ii++] = VER_INTE_PRODUCT >> 2U; + appVersBuffer[ii++] = (VER_INTE_PRODUCT << 6U) + (VER_INTE_EXE & (UINT8)0x3F); + appVersBuffer[ii++] = VER_INTE_TIME; + /*设置平台调用获取外网信息函数*/ + MSCP_SetSrcId(SetOutNetPara); + /*设置内网参数*/ + MSCP_SetSfpInnetPara(g_SfpInnetParam); + MSCP_SetAppVersion(appVersBuffer); + MSCP_SetFsVersion(fsVersBuffer); +} +/** +* @brief 应用周期主逻辑 +* @return ENUM_CM_RETURN 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败(平台立即宕机) +* @details +* 当本系热备状态为:ENUM_2x2_SHUTDOWN,时 +* 本函数不执行; +* 当本系热备状态为:ENUM_2x2_OFFLINE,ENUM_2x2_PRE_MASTER,ENUM_2x2_SLAVE,时 +* 本函数被周期执行,但 ENUM_MSG_OUTNET_SAFE 报文不会真实输出; +* 当本系热备状态为:ENUM_2x2_MASTER,时 +* 本函数被周期执行,并且所有输出信息被真实输出。 +*/ +ENUM_CM_RETURN APP_API_MainFunc(void) +{ + ENUM_CM_RETURN retVal = ENUM_CM_NULL; + CM_UINT64 startCycTick = 0u; + CM_UINT64 endCycTick = 0u; + + startCycTick = MSCP_GetTick(); + debug_infor_printf("app proc start at %llu us\n", startCycTick); + if (1 == MainProcess()) + { + retVal = ENUM_CM_TRUE; + } + else + { + debug_infor_printf("app proc err\n"); + } + + endCycTick = MSCP_GetTick(); + debug_infor_printf("app proc end at %llu us,used %d us\n", endCycTick, (CM_INT32)((endCycTick - startCycTick) / 1000)); + + gFollowDataLen = GetCiAppData(gFollowData); + MSCP_SetFollowData(gFollowData, gFollowDataLen); + + return retVal; +} + +/** +* @brief 应用周期主逻辑2 +* @return ENUM_CM_RETURN 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败(平台立即宕机) +* @details +* 当本系热备状态为:ENUM_2x2_SHUTDOWN,时 +* 本函数不执行; +* 当本系热备状态为:ENUM_2x2_OFFLINE,ENUM_2x2_PRE_MASTER,ENUM_2x2_SLAVE,时 +* 本函数被周期执行,但 ENUM_MSG_OUTNET_SAFE 报文不会真实输出; +* 当本系热备状态为:ENUM_2x2_MASTER,时 +* 本函数被周期执行,并且所有输出信息被真实输出。 +*/ +ENUM_CM_RETURN APP_API_MainFunc2(void) +{ + /*MSCP_LogMsg("app2\n");*/ + /*CM_Sleep(50u);*/ + return ENUM_CM_TRUE; +} + +/** +* @brief 应用周期主逻辑3 +* @return ENUM_CM_RETURN 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败(平台立即宕机) +* @details +* 当本系热备状态为:ENUM_2x2_SHUTDOWN,时 +* 本函数不执行; +* 当本系热备状态为:ENUM_2x2_OFFLINE,ENUM_2x2_PRE_MASTER,ENUM_2x2_SLAVE,时 +* 本函数被周期执行,但 ENUM_MSG_OUTNET_SAFE 报文不会真实输出; +* 当本系热备状态为:ENUM_2x2_MASTER,时 +* 本函数被周期执行,并且所有输出信息被真实输出。 +*/ +ENUM_CM_RETURN APP_API_MainFunc3(void) +{ + /*MSCP_LogMsg("app3\n");*/ + /*CM_Sleep(50u);*/ + return ENUM_CM_TRUE; +} + +ENUM_CM_RETURN APP_API_MainFunc4(void) +{ + /*MSCP_LogMsg("app3\n");*/ + /*CM_Sleep(50u);*/ + return ENUM_CM_TRUE; +} + +/** +* @brief 应用周期主逻辑5 +* @return ENUM_CM_RETURN 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败(平台立即宕机) +* @details +* 当本系热备状态为:ENUM_2x2_SHUTDOWN,时 +* 本函数不执行; +* 当本系热备状态为:ENUM_2x2_OFFLINE,ENUM_2x2_PRE_MASTER,ENUM_2x2_SLAVE,时 +* 本函数被周期执行,但 ENUM_MSG_OUTNET_SAFE 报文不会真实输出; +* 当本系热备状态为:ENUM_2x2_MASTER,时 +* 本函数被周期执行,并且所有输出信息被真实输出。 +*/ +ENUM_CM_RETURN APP_API_MainFunc5(void) +{ + /*MSCP_LogMsg("app3\n");*/ + /*CM_Sleep(50u);*/ + return ENUM_CM_TRUE; +} + +ENUM_CM_RETURN APP_API_MainFunc6(void) +{ + /*MSCP_LogMsg("app3\n");*/ + /*CM_Sleep(50u);*/ + return ENUM_CM_TRUE; +} +/** +* @brief 应用输入处理逻辑 +* @return ENUM_CM_RETURN 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败(平台立即宕机) +* @note +* 本函数在平台线程的输入阶段被调用 +* 注意平台线程在第N周期接收的输入数据,应用线程在第N+1周期才能读取到 +*/ +ENUM_CM_RETURN APP_API_InputFunc(void) +{ + return ENUM_CM_TRUE; +} + +/** +* @brief 备系跟随接口 +* @param Data 跟随数据数组 +* @param Len 跟随数据长度 +* @return ENUM_CM_RETURN 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败(平台立即宕机) +* @details +* 当本系热备状态为:ENUM_2x2_OFFLINE,ENUM_2x2_SLAVE,且收到了邻系正确的跟随数据时 +* 本函数将在APP_API_MainFunc()之前执行; +* 否则,本函数不执行。 +* 应用跟随数据的最大长度不得超过1024*1000字节 +* @see :: MSCP_SetFollowData +*/ +ENUM_CM_RETURN APP_API_FollowUp(IN const CM_UINT8 Data[MSCP_FOLLOW_BUFF_SIZE], IN CM_UINT32 Len) +{ + ENUM_CM_RETURN retVal = ENUM_CM_FALSE; + UINT8 setRtn = 0u; + + setRtn = SetCiAppData(Data, Len); + if (1u == setRtn) + { + retVal = ENUM_CM_TRUE; + } + + return retVal; +} + +ENUM_CM_RECCUSEB Is_Send_ExtendBoard(IN const CM_UINT16 dstDevTypeId) +{ + ENUM_CM_RECCUSEB retVal = ENUM_CM_CC; /*返回值*/ + CM_UINT8 devType = 0U; /*设备类型*/ + CM_UINT8 devId = 0U; /*设备ID*/ + CM_UINT16 wAtsGtWayDevTypeId = 0U; + UINT8 chLocalCiType = 0U; /*本联锁属性*/ + UINT8 chDstCiType = 0U; /*本联锁属性*/ + UINT8 chCldScxCommMode = 0U; + UINT8 chResult = CI_ERROR; /*联锁属性检查结果*/ + + wAtsGtWayDevTypeId = GetTiocTrnsmtGtwyDevTypeId(); + /**使用通控板与ATS网关通信*/ + if (dstDevTypeId != wAtsGtWayDevTypeId) + { + devType = (CM_UINT8)((dstDevTypeId >> 8) & 0xFF); + devId = (CM_UINT8)(dstDevTypeId & 0xFF); + + chLocalCiType = GetLocalCiType(); + chDstCiType = GetCiType(devId); + chCldScxCommMode = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE); + + if ((SCX_CLD_SERIAL_PORT_COMM == chCldScxCommMode) && (CI_SYSTEM_TYPE_CI == devType)) + { + if (((CI_TYPE_CLD == chLocalCiType) && (CI_TYPE_SCX == chDstCiType)) || ((CI_TYPE_SCX == chLocalCiType) && (CI_TYPE_CLD == chDstCiType))) + { + /*串口通信要求双方一个为车辆段一个为试车线*/ + chResult = CI_SUCCESS; + } + else + { + ; /*CI类型错误,返回失败*/ + } + } + else + { + ; /*不为串口通信,此时不对本地CI类型及对方CI类型进行判断*/ + } + + if ((CI_SYSTEM_TYPE_XIANDI == devType) || (CI_SYSTEM_TYPE_ATS == devType) || (CI_SYSTEM_TYPE_LEU == devType) + || (CI_SUCCESS == chResult) + || (CI_SYSTEM_TYPE_VOBC_BACKUP == devType)) /*现地,ATS,LEU,使用串口的相邻CI*/ + { + retVal = ENUM_CM_SEB; + } + else if (CI_SYSTEM_TYPE_ITE == devType) + { + retVal = ENUM_CM_CCSEB; + } + else + { + retVal = ENUM_CM_CC; + } + } + else + { + retVal = ENUM_CM_CC; + } + + return retVal; +} +/* +* @func: 外网输入ID 红蓝网类型及ID缓存 +* @param: void +* @return :VOID +*/ +void SetOutNetPara(UINT8* pRxBuf, UINT32 dwLen, ENUM_OUTNET_CHN_T chOutNetType, UINT16* pOutBuf, INOUT UINT16* pCurLen) +{ + UINT16 wSrcId = 0U; + UINT32 dwTmpLen = 0U; + UINT16 tmpAppLen = 0U; + UINT16 objLen = 0U; + UINT16 tempLen = 0U; + UINT16 ii = 0U; + UINT16 gTransmitObjTypeId[TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX] = { 0U }; + if ((NULL != pRxBuf) && (NULL != pOutBuf) && (NULL != pCurLen)) + { + if ((ENUM_OUTNET_RED == chOutNetType) || (ENUM_OUTNET_EXTEND_RED == chOutNetType) + || (ENUM_OUTNET_BLUE == chOutNetType) || (ENUM_OUTNET_EXTEND_BLUE == chOutNetType)) + { + while (dwTmpLen < dwLen) + { + tmpAppLen = ShortFromChar(&pRxBuf[dwTmpLen]); + if ((tmpAppLen + 2) <= (dwLen - dwTmpLen)) + { + wSrcId = ShortFromChar(&pRxBuf[dwTmpLen + 2]); + dwTmpLen += (tmpAppLen + 2); + + /*去重*/ + for (ii = 0U; ii < objLen; ii++) + { + if (gTransmitObjTypeId[ii] == wSrcId) + { + break; + } + } + if ((ii == objLen) && (TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX > objLen)) + { + gTransmitObjTypeId[objLen++] = wSrcId; + } + + } + else + { + break; + } + } + tempLen = *pCurLen; + if ((TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX) > (tempLen + objLen)) + { + CommonMemCpy((void*)&pOutBuf[tempLen], objLen * sizeof(UINT16), \ + (const void*)gTransmitObjTypeId, objLen * sizeof(UINT16)); + *pCurLen = tempLen + objLen; + debug_infor_printf("outnet in type len :%d", chOutNetType, objLen); + debug_out_array(0xAA, gTransmitObjTypeId, objLen * sizeof(UINT16)); + } + } + else + { + ; + } + } + else + { + printf("buf Null\n"); + } +} + + + + + + +#if (kPLATFORM==kVXWORKS) +/* +* 功能描述: 处理平台网络数据类型信息 +* 参数说明: void +* 返回值 : void +*/ +void ProcessPlatformNetData(void) +{ + UINT16 ii = 0U; + UINT16 wSrcId = 0U; + UINT16 gRedTransmitObjTypeId[TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX] = { 0U }; + UINT16 gBlueTransmitObjTypeId[TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX] = { 0U }; + MSCP_GetRciTempBuf(gRedTransmitObjTypeId, gBlueTransmitObjTypeId); + debug_infor_printf("\nRED type in cycle:%d", Get2oo2CurCycleNum()); + debug_out_array(0xAA, gRedTransmitObjTypeId, TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX * sizeof(UINT16)); + debug_infor_printf("\nBlue type in cycle:%d", Get2oo2CurCycleNum()); + debug_out_array(0xAA, gBlueTransmitObjTypeId, TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX * sizeof(UINT16)); + for (ii = 0; ii < TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX; ii++) + { + wSrcId = gRedTransmitObjTypeId[ii]; + SetCiTrnsmitCycNumByNetType((UINT8)(wSrcId >> 8U), (UINT8)(wSrcId & 0x00ffU), TRANSMIT_NET_ATC_RED); + + wSrcId = gBlueTransmitObjTypeId[ii]; + SetCiTrnsmitCycNumByNetType((UINT8)(wSrcId >> 8U), (UINT8)(wSrcId & 0x00ffU), TRANSMIT_NET_ATC_BLUE); + } + +} +ENUM_CM_RETURN AddOneAppCheckData(IN const UINT32 dwDataAddr, IN const UINT16 wDataLen) +{ + ENUM_CM_RETURN retVal = ENUM_CM_FALSE; /*返回值*/ + CM_UINT32* pTmpDataAdder = NULL; + CM_UINT32 wTmpDataLen = 0u; + + pTmpDataAdder = (CM_UINT32*)dwDataAddr; + wTmpDataLen = (CM_UINT32)wDataLen; + + if ((NULL != pTmpDataAdder) && (0u != wTmpDataLen)) + { + MSCP_MemCheck_Register(pTmpDataAdder, wTmpDataLen); + retVal = ENUM_CM_TRUE; + } + return retVal; +} + +ENUM_CM_RETURN AddAppCheckData(UINT32* pConfigDataAdderBuf, UINT16* pConfigDataLenBuf, UINT16 wDataLen) +{ + ENUM_CM_RETURN retVal = ENUM_CM_FALSE; /*返回值*/ + UINT16 i = 0u; + + if ((NULL != pConfigDataAdderBuf) && (NULL != pConfigDataLenBuf) && (0u != wDataLen) && (UINT16_MAX != wDataLen)) + { + for (i = 0u; i < wDataLen; i++) + { + retVal = AddOneAppCheckData(pConfigDataAdderBuf[i], pConfigDataLenBuf[i]); + + if (ENUM_CM_TRUE != retVal) + { + break; + } + else + { + ;/* 无处理 */ + } + } + } + else + { + ;/* 返回失败 */ + } + return retVal; +} +#endif +/* +* 功能描述: 退出运营处理,设置板卡退出 +* 参数说明: void +* 返回值 : void +*/ +void APP_API_ExitOperation(void) +{ + + UINT8 chExitOpStatus = 0U; + /*退出运营处理*/ + Deploy_ExitOperationHandle(); + chExitOpStatus = Deploy_GetExitOperateStatus(); + if (EXIT_OP_STATUS == chExitOpStatus) + { + MSCP_SetBoardState(ENUM_BOARDSTATE_EXIT); /*设置板卡退出*/ + debug_infor_printf("Tell TSCP I AM INTO EXTOPRATION!\n"); + } + else + { + /*- 不处理*/ + debug_infor_printf("Tell TSCP I AM STAYOPRATION!\n"); + } +} + + +/** +* @brief 输出ats转车数据备用通道判断函数(串口扩展版)。 +* @param UINT16 inSrcId ,UINT16 outSrcId ,UINT16 outDstId +* @details 此函数指针为一个返回值,三个参数。 +* 返回值ENUM_CM_RETURN 0x55或0xaa +* 参数1入参CM_UINT16 输入目标Id +* 参数2出参CM_UINT16* 输出源Id +* 参数3出参CM_UINT16* 输出目的Id +*/ +ENUM_CM_RETURN SerialOutAtsVobcFunc(UINT16 inDstId IN, UINT16* outSrcId OUT, UINT16* outDstId OUT) +{ + ENUM_CM_RETURN retVal = ENUM_CM_FALSE; + UINT8 inDstType = 0U; + + inDstType = (UINT8)((inDstId & 0xff00U) >> 8); + if ((CI_SYSTEM_TYPE_VOBC_BACKUP == inDstType) || (CI_SYSTEM_TYPE_ITE == inDstType)) + { + *outSrcId = (CI_SYSTEM_TYPE_CI << 8) + GetSystemParaLocalCiId(); + *outDstId = GetATSInterfaceTypeId(); + + retVal = ENUM_CM_TRUE; + } + + return retVal; +} + +/** +* @brief 输入ats转车数据备用通道判断函数(串口扩展版)。 +* @param UINT16 inSrcId +* @details 此函数指针为一个返回值,三个参数。 +* 返回值ENUM_CM_RETURN 0x55 true或0xaa false +* 参数1入参CM_UINT16 输入源Id +*/ +ENUM_CM_RETURN SerialInVobcAtsFunc(UINT16 inSrcId IN) +{ + + ENUM_CM_RETURN retVal = ENUM_CM_FALSE; + UINT16 atsBackUpTypeId = 0U; + atsBackUpTypeId = GetATSInterfaceTypeId(); + /*判断与列车后备通道0x1300一致*/ + if (atsBackUpTypeId == inSrcId) + { + + retVal = ENUM_CM_TRUE; + } + + return retVal; +} + + diff --git a/TSCP/src/APP/APP_API.h b/TSCP/src/APP/APP_API.h new file mode 100644 index 0000000..eb33843 --- /dev/null +++ b/TSCP/src/APP/APP_API.h @@ -0,0 +1,114 @@ +/** +* @file APP_API.h +* @brief 应用为平台提供的接口 +* @details 一些由应用实现,由平台调用的函数,主要是应用初始化、应用周期逻辑等 +* @author GT-BU 平台软件组 +* @date 2021.3.1 +* @version V1.0 +* @copyright TCT +* @note 本文件采用doxygen格式编写,用于生成平台对外接口说明书 +*/ +#pragma once +#include "CM_Types.h" +#include "CommonTypes.h" +#include "MSCP_APP_API.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + + /** 应用周期调用函数集 */ + typedef struct + { + ENUM_CM_RETURN(*pApp1)(void); /**< 线程1入口函数 */ + ENUM_CM_RETURN(*pApp2)(void); /**< 线程2入口函数 */ + ENUM_CM_RETURN(*pApp3)(void); /**< 线程3入口函数 */ + ENUM_CM_RETURN(*pApp4)(void); /**< 线程4入口函数 */ + ENUM_CM_RETURN(*pApp5)(void); /**< 线程5入口函数 */ + }STRU_APP_FUNC_T; + + +/* 以上使用内网安全通信时需要定义 */ + + + + /** + * @brief 应用周期主逻辑 + * @return ENUM_CM_RETURN 函数执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败(平台立即宕机) + * @note + * 当本系热备状态为:ENUM_2x2_SHUTDOWN,时 + * 本函数不执行; + * 当本系热备状态为:ENUM_2x2_OFFLINE,ENUM_2x2_PRE_MASTER,ENUM_2x2_SLAVE,时 + * 本函数被周期执行,但 ENUM_MSG_OUTNET_SAFE 报文不会真实输出; + * 当本系热备状态为:ENUM_2x2_MASTER,时 + * 本函数被周期执行,并且所有输出信息被真实输出。 + */ + ENUM_CM_RETURN APP_API_MainFunc(void); + + /** + * @brief 应用输入处理逻辑 + * @return ENUM_CM_RETURN 函数执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败(平台立即宕机) + * @note + * 本函数在平台线程的输入阶段被调用 + * 注意平台线程在第N周期接收的输入数据,应用线程在第N+1周期才能读取到 + */ + ENUM_CM_RETURN APP_API_InputFunc(void); + + + + ENUM_CM_RECCUSEB Is_Send_ExtendBoard(IN const CM_UINT16 dstDevTypeId); + /** + * @brief 输出ats转车数据备用通道判断函数(串口扩展版)。 + * @param UINT16 inSrcId ,UINT16 outSrcId ,UINT16 outDstId + * @details 此函数指针为一个返回值,三个参数。 + * 返回值ENUM_CM_RETURN 0x55或0xaa + * 参数1入参CM_UINT16 输入目标Id + * 参数2出参CM_UINT16* 输出源Id + * 参数3出参CM_UINT16* 输出目的Id + */ + ENUM_CM_RETURN SerialOutAtsVobcFunc(UINT16 inSrcId IN, UINT16 * outSrcId OUT, UINT16* outDstId OUT); + + /** + * @brief 输入ats转车数据备用通道判断函数(串口扩展版)。 + * @param UINT16 inSrcId + * @details 此函数指针为一个返回值,三个参数。 + * 返回值ENUM_CM_RETURN 0x55 true或0xaa false + * 参数1入参CM_UINT16 输入源Id + */ + ENUM_CM_RETURN SerialInVobcAtsFunc(UINT16 inSrcId IN); + /* + * @func: 外网输入ID 红蓝网类型及ID缓存 + * @param: void + * @return :VOID + */ + void SetOutNetPara(UINT8* pRxBuf, UINT32 dwLen, ENUM_OUTNET_CHN_T chOutNetType,UINT16* pOutBuf,INOUT UINT16 *pCurLen); + /* + * 功能描述: 处理平台网络数据类型信息 + * 参数说明: void + * 返回值 : void + */ + void ProcessPlatformNetData(void); + + /* + * 功能描述: 退出运营处理 + * 参数说明: void + * 返回值 : void + */ + void APP_API_ExitOperation(void); + + /* + * @brief 提供给平台的初始化函数 + * @return无 + * @details + * 给平台提供FS版本号,维护ID、内网参数,系统版本号 + **/ + void APP_API_Data_Init(); +#ifdef __cplusplus +} +#endif diff --git a/TSCP/src/APP/PU13_integration_config/ci_integrate_config.h b/TSCP/src/APP/PU13_integration_config/ci_integrate_config.h new file mode 100644 index 0000000..935cad1 --- /dev/null +++ b/TSCP/src/APP/PU13_integration_config/ci_integrate_config.h @@ -0,0 +1,35 @@ +/***************************************************************************/ +/* */ +/* */ +/* CI Software Package (V1.00) */ +/* */ +/* Program Name: ci_integrate_cofig.h Version: 1.00 */ +/* */ +/* Designer: qiaorui.liu */ +/* */ +/* Creat Date: 2015-05-04 */ +/* */ +/* Release Date: */ +/* */ +/* Function: This module define all system Macro definition. */ +/* */ +/* Project Name: NULL */ +/* */ +/* Change Record: */ +/* Date Name Functions */ +/* */ +/***************************************************************************/ + + + +/*Ԥָļ*/ +#ifndef _CI_INTEGRATE_CONFIG_H +#define _CI_INTEGRATE_CONFIG_H + +/*д漯ں˰汾*/ +#define VER_INTE_PROJECT 220 /*Ŀ*/ +#define VER_INTE_PRODUCT 40 /*Ʒ*/ +#define VER_INTE_EXE 1 /*ִб*/ +#define VER_INTE_TIME 77 /*ɴ*/ + +#endif/*endif of #define _CI_INTEGRATE_CONFIG_H*/ \ No newline at end of file diff --git a/TSCP/src/APP/ProtclParam.h b/TSCP/src/APP/ProtclParam.h new file mode 100644 index 0000000..8ce185a --- /dev/null +++ b/TSCP/src/APP/ProtclParam.h @@ -0,0 +1,17 @@ +#ifndef _PROTCL_PARAM_H_ +#define _PROTCL_PARAM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "CommonTypes.h" + +UINT32 innetProtclParamLen = 17444; +UINT8 innetProtclParam[17444] = {0xe4,0xe1,0x02,0x13,0x81,0xfe,0x40,0x40,0x00,0x00,0x44,0x24,0x00,0x00,0x00,0x02,0x05,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x30,0x00,0x00,0x2f,0x1a,0x00,0x00,0x00,0x58,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x40,0x00,0x00,0x14,0xb2,0x00,0x00,0x2f,0x72,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x92,0x17,0x35,0x54,0x81,0x30,0x41,0x20,0x00,0x00,0x2f,0x1a,0x00,0x00,0x00,0x04,0x05,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x01,0x00,0x00,0x2e,0x7c,0x00,0x00,0x00,0x88,0x00,0x64,0x00,0x23,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x00,0x00,0x2f,0x04,0x00,0x02,0x00,0x09,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x1a,0x00,0x00,0x00,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x1a,0x00,0x00,0x00,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x01,0x00,0x00,0x64,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x16,0xa4,0xf0,0x1c,0x7d,0x54,0xf0,0x18,0x01,0x72,0xc4,0xf0,0x14,0x4f,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x64,0x01,0x00,0x00,0x00,0x01,0x00,0x02,0x6a,0x64,0xf0,0x1e,0x01,0x94,0xf0,0x1a,0x01,0x0e,0x04,0xf0,0x16,0x4f,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x64,0x02,0x00,0x00,0x00,0x01,0x00,0x01,0x11,0x24,0xf0,0x2c,0x7a,0xd4,0xf0,0x28,0x01,0x75,0x44,0xf0,0x24,0x4f,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x64,0x02,0x00,0x00,0x00,0x01,0x00,0x02,0x6d,0xe4,0xf0,0x2e,0x06,0x14,0xf0,0x2a,0x01,0x09,0x84,0xf0,0x26,0x4f,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x64,0x03,0x00,0x00,0x00,0x01,0x00,0x01,0x10,0xd4,0xf0,0x3c,0x7b,0x24,0xf0,0x38,0x01,0x74,0xb4,0xf0,0x34,0x4f,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x64,0x03,0x00,0x00,0x00,0x01,0x00,0x02,0x6c,0x14,0xf0,0x3e,0x07,0xe4,0xf0,0x3a,0x01,0x08,0x74,0xf0,0x36,0x4f,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x64,0x04,0x00,0x00,0x00,0x01,0x00,0x01,0x1d,0xe4,0xf0,0x4c,0x76,0x14,0xf0,0x48,0x01,0x79,0x84,0xf0,0x44,0x4f,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x64,0x04,0x00,0x00,0x00,0x01,0x00,0x02,0x61,0x24,0xf0,0x4e,0x0a,0xd4,0xf0,0x4a,0x01,0x05,0x44,0xf0,0x46,0x4f,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x64,0x05,0x00,0x00,0x00,0x01,0x00,0x01,0x1c,0x14,0xf0,0x5c,0x77,0xe4,0xf0,0x58,0x01,0x78,0x74,0xf0,0x54,0x4f,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x64,0x05,0x00,0x00,0x00,0x01,0x00,0x02,0x60,0xd4,0xf0,0x5e,0x0b,0x24,0xf0,0x5a,0x01,0x04,0xb4,0xf0,0x56,0x4f,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x64,0x06,0x00,0x00,0x00,0x01,0x00,0x01,0x1b,0x94,0xf0,0x6c,0x70,0x64,0xf0,0x68,0x01,0x7f,0xf4,0xf0,0x64,0x4f,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x64,0x06,0x00,0x00,0x00,0x01,0x00,0x02,0x67,0x54,0xf0,0x6e,0x0c,0xa4,0xf0,0x6a,0x01,0x03,0x34,0xf0,0x66,0x4f,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,0x00,0x64,0x07,0x00,0x00,0x00,0x01,0x00,0x01,0x1a,0x64,0xf0,0x7c,0x71,0x94,0xf0,0x78,0x01,0x7e,0x04,0xf0,0x74,0x4f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x64,0x07,0x00,0x00,0x00,0x01,0x00,0x02,0x66,0xa4,0xf0,0x7e,0x0d,0x54,0xf0,0x7a,0x01,0x02,0xc4,0xf0,0x76,0x4f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x64,0x08,0x00,0x00,0x00,0x01,0x00,0x01,0x1a,0x04,0xf0,0x8c,0x71,0xf4,0xf0,0x88,0x01,0x7e,0x64,0xf0,0x84,0x4f,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x64,0x08,0x00,0x00,0x00,0x01,0x00,0x02,0x66,0xc4,0xf0,0x8e,0x0d,0x34,0xf0,0x8a,0x01,0x02,0xa4,0xf0,0x86,0x4f,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x64,0x09,0x00,0x00,0x00,0x01,0x00,0x01,0x1b,0xf4,0xf0,0x9c,0x70,0x04,0xf0,0x98,0x01,0x7f,0x94,0xf0,0x94,0x4f,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x64,0x09,0x00,0x00,0x00,0x01,0x00,0x02,0x67,0x34,0xf0,0x9e,0x0c,0xc4,0xf0,0x9a,0x01,0x03,0x54,0xf0,0x96,0x4f,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x64,0x0a,0x00,0x00,0x00,0x01,0x00,0x01,0x1c,0x74,0xf0,0xac,0x77,0x84,0xf0,0xa8,0x01,0x78,0x14,0xf0,0xa4,0x4f,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x64,0x0a,0x00,0x00,0x00,0x01,0x00,0x02,0x60,0xb4,0xf0,0xae,0x0b,0x44,0xf0,0xaa,0x01,0x04,0xd4,0xf0,0xa6,0x4f,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x64,0x0b,0x00,0x00,0x00,0x01,0x00,0x01,0x1d,0x84,0xf0,0xbc,0x76,0x74,0xf0,0xb8,0x01,0x79,0xe4,0xf0,0xb4,0x4f,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x64,0x0b,0x00,0x00,0x00,0x01,0x00,0x02,0x61,0x44,0xf0,0xbe,0x0a,0xb4,0xf0,0xba,0x01,0x05,0x24,0xf0,0xb6,0x4f,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x17,0x00,0x00,0x64,0x0c,0x00,0x00,0x00,0x01,0x00,0x01,0x10,0xb4,0xf0,0xcc,0x7b,0x44,0xf0,0xc8,0x01,0x74,0xd4,0xf0,0xc4,0x4f,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x64,0x0c,0x00,0x00,0x00,0x01,0x00,0x02,0x6c,0x74,0xf0,0xce,0x07,0x84,0xf0,0xca,0x01,0x08,0x14,0xf0,0xc6,0x4f,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x64,0x0d,0x00,0x00,0x00,0x01,0x00,0x01,0x11,0x44,0xf0,0xdc,0x7a,0xb4,0xf0,0xd8,0x01,0x75,0x24,0xf0,0xd4,0x4f,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1a,0x00,0x00,0x64,0x0d,0x00,0x00,0x00,0x01,0x00,0x02,0x6d,0x84,0xf0,0xde,0x06,0x74,0xf0,0xda,0x01,0x09,0xe4,0xf0,0xd6,0x4f,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x64,0x0e,0x00,0x00,0x00,0x01,0x00,0x01,0x16,0xc4,0xf0,0xec,0x7d,0x34,0xf0,0xe8,0x01,0x72,0xa4,0xf0,0xe4,0x4f,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,0x64,0x0e,0x00,0x00,0x00,0x01,0x00,0x02,0x6a,0x04,0xf0,0xee,0x01,0xf4,0xf0,0xea,0x01,0x0e,0x64,0xf0,0xe6,0x4f,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1d,0x00,0x00,0x64,0x0f,0x00,0x00,0x00,0x01,0x00,0x01,0x17,0x34,0xf0,0xfc,0x7c,0xc4,0xf0,0xf8,0x01,0x73,0x54,0xf0,0xf4,0x4f,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x00,0x64,0x0f,0x00,0x00,0x00,0x01,0x00,0x02,0x6b,0xf4,0xf0,0xfe,0x00,0x04,0xf0,0xfa,0x01,0x0f,0x94,0xf0,0xf6,0x4f,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x00,0x64,0x10,0x00,0x00,0x00,0x01,0x00,0x01,0x05,0x84,0xf1,0x0c,0x6e,0x74,0xf1,0x08,0x01,0x61,0xe4,0xf1,0x04,0x4f,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x64,0x10,0x00,0x00,0x00,0x01,0x00,0x02,0x79,0x44,0xf1,0x0e,0x12,0xb4,0xf1,0x0a,0x01,0x1d,0x24,0xf1,0x06,0x4f,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x00,0x00,0x64,0x11,0x00,0x00,0x00,0x01,0x00,0x01,0x04,0x74,0xf1,0x1c,0x6f,0x84,0xf1,0x18,0x01,0x60,0x14,0xf1,0x14,0x4f,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x22,0x00,0x00,0x64,0x11,0x00,0x00,0x00,0x01,0x00,0x02,0x78,0xb4,0xf1,0x1e,0x13,0x44,0xf1,0x1a,0x01,0x1c,0xd4,0xf1,0x16,0x4f,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x64,0x12,0x00,0x00,0x00,0x01,0x00,0x01,0x03,0xf4,0xf1,0x2c,0x68,0x04,0xf1,0x28,0x01,0x67,0x94,0xf1,0x24,0x4f,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x64,0x12,0x00,0x00,0x00,0x01,0x00,0x02,0x7f,0x34,0xf1,0x2e,0x14,0xc4,0xf1,0x2a,0x01,0x1b,0x54,0xf1,0x26,0x4f,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x00,0x00,0x64,0x13,0x00,0x00,0x00,0x01,0x00,0x01,0x02,0x04,0xf1,0x3c,0x69,0xf4,0xf1,0x38,0x01,0x66,0x64,0xf1,0x34,0x4f,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0x00,0x00,0x64,0x13,0x00,0x00,0x00,0x01,0x00,0x02,0x7e,0xc4,0xf1,0x3e,0x15,0x34,0xf1,0x3a,0x01,0x1a,0xa4,0xf1,0x36,0x4f,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27,0x00,0x00,0x64,0x14,0x00,0x00,0x00,0x01,0x00,0x01,0x0f,0x34,0xf1,0x4c,0x64,0xc4,0xf1,0x48,0x01,0x6b,0x54,0xf1,0x44,0x4f,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x00,0x00,0x64,0x14,0x00,0x00,0x00,0x01,0x00,0x02,0x73,0xf4,0xf1,0x4e,0x18,0x04,0xf1,0x4a,0x01,0x17,0x94,0xf1,0x46,0x4f,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0x00,0x00,0x64,0x15,0x00,0x00,0x00,0x01,0x00,0x01,0x0e,0xc4,0xf1,0x5c,0x65,0x34,0xf1,0x58,0x01,0x6a,0xa4,0xf1,0x54,0x4f,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2a,0x00,0x00,0x64,0x15,0x00,0x00,0x00,0x01,0x00,0x02,0x72,0x04,0xf1,0x5e,0x19,0xf4,0xf1,0x5a,0x01,0x16,0x64,0xf1,0x56,0x4f,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2b,0x00,0x00,0x64,0x16,0x00,0x00,0x00,0x01,0x00,0x01,0x09,0x44,0xf1,0x6c,0x62,0xb4,0xf1,0x68,0x01,0x6d,0x24,0xf1,0x64,0x4f,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x64,0x16,0x00,0x00,0x00,0x01,0x00,0x02,0x75,0x84,0xf1,0x6e,0x1e,0x74,0xf1,0x6a,0x01,0x11,0xe4,0xf1,0x66,0x4f,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x64,0x17,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0xb4,0xf1,0x7c,0x63,0x44,0xf1,0x78,0x01,0x6c,0xd4,0xf1,0x74,0x4f,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2e,0x00,0x00,0x64,0x17,0x00,0x00,0x00,0x01,0x00,0x02,0x74,0x74,0xf1,0x7e,0x1f,0x84,0xf1,0x7a,0x01,0x10,0x14,0xf1,0x76,0x4f,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x00,0x00,0x64,0x18,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0xd4,0xf1,0x8c,0x63,0x24,0xf1,0x88,0x01,0x6c,0xb4,0xf1,0x84,0x4f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x64,0x18,0x00,0x00,0x00,0x01,0x00,0x02,0x74,0x14,0xf1,0x8e,0x1f,0xe4,0xf1,0x8a,0x01,0x10,0x74,0xf1,0x86,0x4f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x00,0x00,0x64,0x19,0x00,0x00,0x00,0x01,0x00,0x01,0x09,0x24,0xf1,0x9c,0x62,0xd4,0xf1,0x98,0x01,0x6d,0x44,0xf1,0x94,0x4f,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x64,0x19,0x00,0x00,0x00,0x01,0x00,0x02,0x75,0xe4,0xf1,0x9e,0x1e,0x14,0xf1,0x9a,0x01,0x11,0x84,0xf1,0x96,0x4f,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x64,0x1a,0x00,0x00,0x00,0x01,0x00,0x01,0x0e,0xa4,0xf1,0xac,0x65,0x54,0xf1,0xa8,0x01,0x6a,0xc4,0xf1,0xa4,0x4f,0x1a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x00,0x00,0x64,0x1a,0x00,0x00,0x00,0x01,0x00,0x02,0x72,0x64,0xf1,0xae,0x19,0x94,0xf1,0xaa,0x01,0x16,0x04,0xf1,0xa6,0x4f,0x1a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x00,0x00,0x64,0x1b,0x00,0x00,0x00,0x01,0x00,0x01,0x0f,0x54,0xf1,0xbc,0x64,0xa4,0xf1,0xb8,0x01,0x6b,0x34,0xf1,0xb4,0x4f,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x64,0x1b,0x00,0x00,0x00,0x01,0x00,0x02,0x73,0x94,0xf1,0xbe,0x18,0x64,0xf1,0xba,0x01,0x17,0xf4,0xf1,0xb6,0x4f,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x00,0x00,0x64,0x1c,0x00,0x00,0x00,0x01,0x00,0x01,0x02,0x64,0xf1,0xcc,0x69,0x94,0xf1,0xc8,0x01,0x66,0x04,0xf1,0xc4,0x4f,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x64,0x1c,0x00,0x00,0x00,0x01,0x00,0x02,0x7e,0xa4,0xf1,0xce,0x15,0x54,0xf1,0xca,0x01,0x1a,0xc4,0xf1,0xc6,0x4f,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x39,0x00,0x00,0x64,0x1d,0x00,0x00,0x00,0x01,0x00,0x01,0x03,0x94,0xf1,0xdc,0x68,0x64,0xf1,0xd8,0x01,0x67,0xf4,0xf1,0xd4,0x4f,0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3a,0x00,0x00,0x64,0x1d,0x00,0x00,0x00,0x01,0x00,0x02,0x7f,0x54,0xf1,0xde,0x14,0xa4,0xf1,0xda,0x01,0x1b,0x34,0xf1,0xd6,0x4f,0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3b,0x00,0x00,0x64,0x1e,0x00,0x00,0x00,0x01,0x00,0x01,0x04,0x14,0xf1,0xec,0x6f,0xe4,0xf1,0xe8,0x01,0x60,0x74,0xf1,0xe4,0x4f,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x64,0x1e,0x00,0x00,0x00,0x01,0x00,0x02,0x78,0xd4,0xf1,0xee,0x13,0x24,0xf1,0xea,0x01,0x1c,0xb4,0xf1,0xe6,0x4f,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x00,0x64,0x1f,0x00,0x00,0x00,0x01,0x00,0x01,0x05,0xe4,0xf1,0xfc,0x6e,0x14,0xf1,0xf8,0x01,0x61,0x84,0xf1,0xf4,0x4f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x64,0x1f,0x00,0x00,0x00,0x01,0x00,0x02,0x79,0x24,0xf1,0xfe,0x12,0xd4,0xf1,0xfa,0x01,0x1d,0x44,0xf1,0xf6,0x4f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x00,0x64,0x20,0x00,0x00,0x00,0x01,0x00,0x01,0x02,0x34,0xf2,0x0c,0x69,0xc4,0xf2,0x08,0x01,0x66,0x54,0xf2,0x04,0x4f,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x64,0x20,0x00,0x00,0x00,0x01,0x00,0x02,0x7e,0xf4,0xf2,0x0e,0x15,0x04,0xf2,0x0a,0x01,0x1a,0x94,0xf2,0x06,0x4f,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x00,0x64,0x21,0x00,0x00,0x00,0x01,0x00,0x01,0x03,0xc4,0xf2,0x1c,0x68,0x34,0xf2,0x18,0x01,0x67,0xa4,0xf2,0x14,0x4f,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x00,0x00,0x64,0x21,0x00,0x00,0x00,0x01,0x00,0x02,0x7f,0x04,0xf2,0x1e,0x14,0xf4,0xf2,0x1a,0x01,0x1b,0x64,0xf2,0x16,0x4f,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x00,0x00,0x64,0x22,0x00,0x00,0x00,0x01,0x00,0x01,0x04,0x44,0xf2,0x2c,0x6f,0xb4,0xf2,0x28,0x01,0x60,0x24,0xf2,0x24,0x4f,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x64,0x22,0x00,0x00,0x00,0x01,0x00,0x02,0x78,0x84,0xf2,0x2e,0x13,0x74,0xf2,0x2a,0x01,0x1c,0xe4,0xf2,0x26,0x4f,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x64,0x23,0x00,0x00,0x00,0x01,0x00,0x01,0x05,0xb4,0xf2,0x3c,0x6e,0x44,0xf2,0x38,0x01,0x61,0xd4,0xf2,0x34,0x4f,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x00,0x00,0x64,0x23,0x00,0x00,0x00,0x01,0x00,0x02,0x79,0x74,0xf2,0x3e,0x12,0x84,0xf2,0x3a,0x01,0x1d,0x14,0xf2,0x36,0x4f,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x00,0x64,0x24,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x84,0xf2,0x4c,0x63,0x74,0xf2,0x48,0x01,0x6c,0xe4,0xf2,0x44,0x4f,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x64,0x24,0x00,0x00,0x00,0x01,0x00,0x02,0x74,0x44,0xf2,0x4e,0x1f,0xb4,0xf2,0x4a,0x01,0x10,0x24,0xf2,0x46,0x4f,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x49,0x00,0x00,0x64,0x25,0x00,0x00,0x00,0x01,0x00,0x01,0x09,0x74,0xf2,0x5c,0x62,0x84,0xf2,0x58,0x01,0x6d,0x14,0xf2,0x54,0x4f,0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x00,0x00,0x64,0x25,0x00,0x00,0x00,0x01,0x00,0x02,0x75,0xb4,0xf2,0x5e,0x1e,0x44,0xf2,0x5a,0x01,0x11,0xd4,0xf2,0x56,0x4f,0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4b,0x00,0x00,0x64,0x26,0x00,0x00,0x00,0x01,0x00,0x01,0x0e,0xf4,0xf2,0x6c,0x65,0x04,0xf2,0x68,0x01,0x6a,0x94,0xf2,0x64,0x4f,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4c,0x00,0x00,0x64,0x26,0x00,0x00,0x00,0x01,0x00,0x02,0x72,0x34,0xf2,0x6e,0x19,0xc4,0xf2,0x6a,0x01,0x16,0x54,0xf2,0x66,0x4f,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4d,0x00,0x00,0x64,0x27,0x00,0x00,0x00,0x01,0x00,0x01,0x0f,0x04,0xf2,0x7c,0x64,0xf4,0xf2,0x78,0x01,0x6b,0x64,0xf2,0x74,0x4f,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4e,0x00,0x00,0x64,0x27,0x00,0x00,0x00,0x01,0x00,0x02,0x73,0xc4,0xf2,0x7e,0x18,0x34,0xf2,0x7a,0x01,0x17,0xa4,0xf2,0x76,0x4f,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4f,0x00,0x00,0x64,0x28,0x00,0x00,0x00,0x01,0x00,0x01,0x0f,0x64,0xf2,0x8c,0x64,0x94,0xf2,0x88,0x01,0x6b,0x04,0xf2,0x84,0x4f,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x64,0x28,0x00,0x00,0x00,0x01,0x00,0x02,0x73,0xa4,0xf2,0x8e,0x18,0x54,0xf2,0x8a,0x01,0x17,0xc4,0xf2,0x86,0x4f,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0x00,0x00,0x64,0x29,0x00,0x00,0x00,0x01,0x00,0x01,0x0e,0x94,0xf2,0x9c,0x65,0x64,0xf2,0x98,0x01,0x6a,0xf4,0xf2,0x94,0x4f,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x00,0x00,0x64,0x29,0x00,0x00,0x00,0x01,0x00,0x02,0x72,0x54,0xf2,0x9e,0x19,0xa4,0xf2,0x9a,0x01,0x16,0x34,0xf2,0x96,0x4f,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x00,0x00,0x64,0x2a,0x00,0x00,0x00,0x01,0x00,0x01,0x09,0x14,0xf2,0xac,0x62,0xe4,0xf2,0xa8,0x01,0x6d,0x74,0xf2,0xa4,0x4f,0x2a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x64,0x2a,0x00,0x00,0x00,0x01,0x00,0x02,0x75,0xd4,0xf2,0xae,0x1e,0x24,0xf2,0xaa,0x01,0x11,0xb4,0xf2,0xa6,0x4f,0x2a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x00,0x00,0x64,0x2b,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0xe4,0xf2,0xbc,0x63,0x14,0xf2,0xb8,0x01,0x6c,0x84,0xf2,0xb4,0x4f,0x2b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x00,0x00,0x64,0x2b,0x00,0x00,0x00,0x01,0x00,0x02,0x74,0x24,0xf2,0xbe,0x1f,0xd4,0xf2,0xba,0x01,0x10,0x44,0xf2,0xb6,0x4f,0x2b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x00,0x00,0x64,0x2c,0x00,0x00,0x00,0x01,0x00,0x01,0x05,0xd4,0xf2,0xcc,0x6e,0x24,0xf2,0xc8,0x01,0x61,0xb4,0xf2,0xc4,0x4f,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x64,0x2c,0x00,0x00,0x00,0x01,0x00,0x02,0x79,0x14,0xf2,0xce,0x12,0xe4,0xf2,0xca,0x01,0x1d,0x74,0xf2,0xc6,0x4f,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x00,0x00,0x64,0x2d,0x00,0x00,0x00,0x01,0x00,0x01,0x04,0x24,0xf2,0xdc,0x6f,0xd4,0xf2,0xd8,0x01,0x60,0x44,0xf2,0xd4,0x4f,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5a,0x00,0x00,0x64,0x2d,0x00,0x00,0x00,0x01,0x00,0x02,0x78,0xe4,0xf2,0xde,0x13,0x14,0xf2,0xda,0x01,0x1c,0x84,0xf2,0xd6,0x4f,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5b,0x00,0x00,0x64,0x2e,0x00,0x00,0x00,0x01,0x00,0x01,0x03,0xa4,0xf2,0xec,0x68,0x54,0xf2,0xe8,0x01,0x67,0xc4,0xf2,0xe4,0x4f,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x00,0x00,0x64,0x2e,0x00,0x00,0x00,0x01,0x00,0x02,0x7f,0x64,0xf2,0xee,0x14,0x94,0xf2,0xea,0x01,0x1b,0x04,0xf2,0xe6,0x4f,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5d,0x00,0x00,0x64,0x2f,0x00,0x00,0x00,0x01,0x00,0x01,0x02,0x54,0xf2,0xfc,0x69,0xa4,0xf2,0xf8,0x01,0x66,0x34,0xf2,0xf4,0x4f,0x2f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5e,0x00,0x00,0x64,0x2f,0x00,0x00,0x00,0x01,0x00,0x02,0x7e,0x94,0xf2,0xfe,0x15,0x64,0xf2,0xfa,0x01,0x1a,0xf4,0xf2,0xf6,0x4f,0x2f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x64,0x30,0x00,0x00,0x00,0x01,0x00,0x01,0x10,0xe4,0xf3,0x0c,0x7b,0x14,0xf3,0x08,0x01,0x74,0x84,0xf3,0x04,0x4f,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x64,0x30,0x00,0x00,0x00,0x01,0x00,0x02,0x6c,0x24,0xf3,0x0e,0x07,0xd4,0xf3,0x0a,0x01,0x08,0x44,0xf3,0x06,0x4f,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x00,0x00,0x64,0x31,0x00,0x00,0x00,0x01,0x00,0x01,0x11,0x14,0xf3,0x1c,0x7a,0xe4,0xf3,0x18,0x01,0x75,0x74,0xf3,0x14,0x4f,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x00,0x00,0x64,0x31,0x00,0x00,0x00,0x01,0x00,0x02,0x6d,0xd4,0xf3,0x1e,0x06,0x24,0xf3,0x1a,0x01,0x09,0xb4,0xf3,0x16,0x4f,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x00,0x64,0x32,0x00,0x00,0x00,0x01,0x00,0x01,0x16,0x94,0xf3,0x2c,0x7d,0x64,0xf3,0x28,0x01,0x72,0xf4,0xf3,0x24,0x4f,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x00,0x00,0x64,0x32,0x00,0x00,0x00,0x01,0x00,0x02,0x6a,0x54,0xf3,0x2e,0x01,0xa4,0xf3,0x2a,0x01,0x0e,0x34,0xf3,0x26,0x4f,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x64,0x03,0x04,0x04,0x64,0x04,0x01,0x03,0x00,0x64,0x00,0x3c,0x03,0x03,0x03,0x50,0x03,0x65,0x03,0x00,0x4c,0xcd,0x41,0x81,0x40,0x44,0x60,0x00,0x00,0x14,0xb2,0x00,0x00,0x00,0x03,0x05,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x01,0x00,0x00,0x0f,0x3c,0x00,0x00,0x00,0x70,0x00,0x82,0x00,0x0d,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x0f,0xac,0x00,0x02,0x00,0x04,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x05,0x00,0x00,0x05,0x00,0x00,0x00,0x0f,0xb2,0x00,0x50,0x00,0x05,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x64,0x01,0x00,0x00,0x64,0x01,0xc0,0xa8,0x02,0x65,0xc0,0xa8,0x01,0x65,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x01,0x00,0x00,0x64,0x01,0xc0,0xa8,0x02,0x66,0xc0,0xa8,0x01,0x66,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x02,0x00,0x00,0x64,0x02,0xc0,0xa8,0x02,0x67,0xc0,0xa8,0x01,0x67,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x02,0x00,0x00,0x64,0x02,0xc0,0xa8,0x02,0x68,0xc0,0xa8,0x01,0x68,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x03,0x00,0x00,0x64,0x03,0xc0,0xa8,0x02,0x69,0xc0,0xa8,0x01,0x69,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x03,0x00,0x00,0x64,0x03,0xc0,0xa8,0x02,0x6a,0xc0,0xa8,0x01,0x6a,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x04,0x00,0x00,0x64,0x04,0xc0,0xa8,0x02,0x6b,0xc0,0xa8,0x01,0x6b,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x04,0x00,0x00,0x64,0x04,0xc0,0xa8,0x02,0x6c,0xc0,0xa8,0x01,0x6c,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x05,0x00,0x00,0x64,0x05,0xc0,0xa8,0x02,0x6d,0xc0,0xa8,0x01,0x6d,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x05,0x00,0x00,0x64,0x05,0xc0,0xa8,0x02,0x6e,0xc0,0xa8,0x01,0x6e,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x06,0x00,0x00,0x64,0x06,0xc0,0xa8,0x02,0x6f,0xc0,0xa8,0x01,0x6f,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x06,0x00,0x00,0x64,0x06,0xc0,0xa8,0x02,0x70,0xc0,0xa8,0x01,0x70,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x07,0x00,0x00,0x64,0x07,0xc0,0xa8,0x02,0x71,0xc0,0xa8,0x01,0x71,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x07,0x00,0x00,0x64,0x07,0xc0,0xa8,0x02,0x72,0xc0,0xa8,0x01,0x72,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x08,0x00,0x00,0x64,0x08,0xc0,0xa8,0x02,0x73,0xc0,0xa8,0x01,0x73,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x08,0x00,0x00,0x64,0x08,0xc0,0xa8,0x02,0x74,0xc0,0xa8,0x01,0x74,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x09,0x00,0x00,0x64,0x09,0xc0,0xa8,0x02,0x75,0xc0,0xa8,0x01,0x75,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x09,0x00,0x00,0x64,0x09,0xc0,0xa8,0x02,0x76,0xc0,0xa8,0x01,0x76,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0a,0x00,0x00,0x64,0x0a,0xc0,0xa8,0x02,0x77,0xc0,0xa8,0x01,0x77,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0a,0x00,0x00,0x64,0x0a,0xc0,0xa8,0x02,0x78,0xc0,0xa8,0x01,0x78,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0b,0x00,0x00,0x64,0x0b,0xc0,0xa8,0x02,0x79,0xc0,0xa8,0x01,0x79,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0b,0x00,0x00,0x64,0x0b,0xc0,0xa8,0x02,0x7a,0xc0,0xa8,0x01,0x7a,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0c,0x00,0x00,0x64,0x0c,0xc0,0xa8,0x02,0x7b,0xc0,0xa8,0x01,0x7b,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0c,0x00,0x00,0x64,0x0c,0xc0,0xa8,0x02,0x7c,0xc0,0xa8,0x01,0x7c,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0d,0x00,0x00,0x64,0x0d,0xc0,0xa8,0x02,0x7d,0xc0,0xa8,0x01,0x7d,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0d,0x00,0x00,0x64,0x0d,0xc0,0xa8,0x02,0x7e,0xc0,0xa8,0x01,0x7e,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0e,0x00,0x00,0x64,0x0e,0xc0,0xa8,0x02,0x7f,0xc0,0xa8,0x01,0x7f,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0e,0x00,0x00,0x64,0x0e,0xc0,0xa8,0x02,0x80,0xc0,0xa8,0x01,0x80,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0f,0x00,0x00,0x64,0x0f,0xc0,0xa8,0x02,0x81,0xc0,0xa8,0x01,0x81,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0f,0x00,0x00,0x64,0x0f,0xc0,0xa8,0x02,0x82,0xc0,0xa8,0x01,0x82,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x10,0x00,0x00,0x64,0x10,0xc0,0xa8,0x02,0x83,0xc0,0xa8,0x01,0x83,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x10,0x00,0x00,0x64,0x10,0xc0,0xa8,0x02,0x84,0xc0,0xa8,0x01,0x84,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x11,0x00,0x00,0x64,0x11,0xc0,0xa8,0x02,0x85,0xc0,0xa8,0x01,0x85,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x11,0x00,0x00,0x64,0x11,0xc0,0xa8,0x02,0x86,0xc0,0xa8,0x01,0x86,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x12,0x00,0x00,0x64,0x12,0xc0,0xa8,0x02,0x87,0xc0,0xa8,0x01,0x87,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x12,0x00,0x00,0x64,0x12,0xc0,0xa8,0x02,0x88,0xc0,0xa8,0x01,0x88,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x13,0x00,0x00,0x64,0x13,0xc0,0xa8,0x02,0x89,0xc0,0xa8,0x01,0x89,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x13,0x00,0x00,0x64,0x13,0xc0,0xa8,0x02,0x8a,0xc0,0xa8,0x01,0x8a,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x14,0x00,0x00,0x64,0x14,0xc0,0xa8,0x02,0x8b,0xc0,0xa8,0x01,0x8b,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x14,0x00,0x00,0x64,0x14,0xc0,0xa8,0x02,0x8c,0xc0,0xa8,0x01,0x8c,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x15,0x00,0x00,0x64,0x15,0xc0,0xa8,0x02,0x8d,0xc0,0xa8,0x01,0x8d,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x15,0x00,0x00,0x64,0x15,0xc0,0xa8,0x02,0x8e,0xc0,0xa8,0x01,0x8e,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x16,0x00,0x00,0x64,0x16,0xc0,0xa8,0x02,0x8f,0xc0,0xa8,0x01,0x8f,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x16,0x00,0x00,0x64,0x16,0xc0,0xa8,0x02,0x90,0xc0,0xa8,0x01,0x90,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x17,0x00,0x00,0x64,0x17,0xc0,0xa8,0x02,0x91,0xc0,0xa8,0x01,0x91,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x17,0x00,0x00,0x64,0x17,0xc0,0xa8,0x02,0x92,0xc0,0xa8,0x01,0x92,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x18,0x00,0x00,0x64,0x18,0xc0,0xa8,0x02,0x93,0xc0,0xa8,0x01,0x93,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x18,0x00,0x00,0x64,0x18,0xc0,0xa8,0x02,0x94,0xc0,0xa8,0x01,0x94,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x19,0x00,0x00,0x64,0x19,0xc0,0xa8,0x02,0x95,0xc0,0xa8,0x01,0x95,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x19,0x00,0x00,0x64,0x19,0xc0,0xa8,0x02,0x96,0xc0,0xa8,0x01,0x96,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1a,0x00,0x00,0x64,0x1a,0xc0,0xa8,0x02,0x97,0xc0,0xa8,0x01,0x97,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1a,0x00,0x00,0x64,0x1a,0xc0,0xa8,0x02,0x98,0xc0,0xa8,0x01,0x98,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1b,0x00,0x00,0x64,0x1b,0xc0,0xa8,0x02,0x99,0xc0,0xa8,0x01,0x99,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1b,0x00,0x00,0x64,0x1b,0xc0,0xa8,0x02,0x9a,0xc0,0xa8,0x01,0x9a,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1c,0x00,0x00,0x64,0x1c,0xc0,0xa8,0x02,0x9b,0xc0,0xa8,0x01,0x9b,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1c,0x00,0x00,0x64,0x1c,0xc0,0xa8,0x02,0x9c,0xc0,0xa8,0x01,0x9c,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1d,0x00,0x00,0x64,0x1d,0xc0,0xa8,0x02,0x9d,0xc0,0xa8,0x01,0x9d,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1d,0x00,0x00,0x64,0x1d,0xc0,0xa8,0x02,0x9e,0xc0,0xa8,0x01,0x9e,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1e,0x00,0x00,0x64,0x1e,0xc0,0xa8,0x02,0x9f,0xc0,0xa8,0x01,0x9f,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1e,0x00,0x00,0x64,0x1e,0xc0,0xa8,0x02,0xa0,0xc0,0xa8,0x01,0xa0,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1f,0x00,0x00,0x64,0x1f,0xc0,0xa8,0x02,0xa1,0xc0,0xa8,0x01,0xa1,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1f,0x00,0x00,0x64,0x1f,0xc0,0xa8,0x02,0xa2,0xc0,0xa8,0x01,0xa2,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x20,0x00,0x00,0x64,0x20,0xc0,0xa8,0x02,0xa3,0xc0,0xa8,0x01,0xa3,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x20,0x00,0x00,0x64,0x20,0xc0,0xa8,0x02,0xa4,0xc0,0xa8,0x01,0xa4,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x21,0x00,0x00,0x64,0x21,0xc0,0xa8,0x02,0xa5,0xc0,0xa8,0x01,0xa5,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x21,0x00,0x00,0x64,0x21,0xc0,0xa8,0x02,0xa6,0xc0,0xa8,0x01,0xa6,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x22,0x00,0x00,0x64,0x22,0xc0,0xa8,0x02,0xa7,0xc0,0xa8,0x01,0xa7,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x22,0x00,0x00,0x64,0x22,0xc0,0xa8,0x02,0xa8,0xc0,0xa8,0x01,0xa8,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x23,0x00,0x00,0x64,0x23,0xc0,0xa8,0x02,0xa9,0xc0,0xa8,0x01,0xa9,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x23,0x00,0x00,0x64,0x23,0xc0,0xa8,0x02,0xaa,0xc0,0xa8,0x01,0xaa,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x24,0x00,0x00,0x64,0x24,0xc0,0xa8,0x02,0xab,0xc0,0xa8,0x01,0xab,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x24,0x00,0x00,0x64,0x24,0xc0,0xa8,0x02,0xac,0xc0,0xa8,0x01,0xac,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x25,0x00,0x00,0x64,0x25,0xc0,0xa8,0x02,0xad,0xc0,0xa8,0x01,0xad,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x25,0x00,0x00,0x64,0x25,0xc0,0xa8,0x02,0xae,0xc0,0xa8,0x01,0xae,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x26,0x00,0x00,0x64,0x26,0xc0,0xa8,0x02,0xaf,0xc0,0xa8,0x01,0xaf,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x26,0x00,0x00,0x64,0x26,0xc0,0xa8,0x02,0xb0,0xc0,0xa8,0x01,0xb0,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x27,0x00,0x00,0x64,0x27,0xc0,0xa8,0x02,0xb1,0xc0,0xa8,0x01,0xb1,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x27,0x00,0x00,0x64,0x27,0xc0,0xa8,0x02,0xb2,0xc0,0xa8,0x01,0xb2,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x28,0x00,0x00,0x64,0x28,0xc0,0xa8,0x02,0xb3,0xc0,0xa8,0x01,0xb3,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x28,0x00,0x00,0x64,0x28,0xc0,0xa8,0x02,0xb4,0xc0,0xa8,0x01,0xb4,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x29,0x00,0x00,0x64,0x29,0xc0,0xa8,0x02,0xb5,0xc0,0xa8,0x01,0xb5,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x29,0x00,0x00,0x64,0x29,0xc0,0xa8,0x02,0xb6,0xc0,0xa8,0x01,0xb6,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2a,0x00,0x00,0x64,0x2a,0xc0,0xa8,0x02,0xb7,0xc0,0xa8,0x01,0xb7,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2a,0x00,0x00,0x64,0x2a,0xc0,0xa8,0x02,0xb8,0xc0,0xa8,0x01,0xb8,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2b,0x00,0x00,0x64,0x2b,0xc0,0xa8,0x02,0xb9,0xc0,0xa8,0x01,0xb9,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2b,0x00,0x00,0x64,0x2b,0xc0,0xa8,0x02,0xba,0xc0,0xa8,0x01,0xba,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2c,0x00,0x00,0x64,0x2c,0xc0,0xa8,0x02,0xbb,0xc0,0xa8,0x01,0xbb,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2c,0x00,0x00,0x64,0x2c,0xc0,0xa8,0x02,0xbc,0xc0,0xa8,0x01,0xbc,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2d,0x00,0x00,0x64,0x2d,0xc0,0xa8,0x02,0xbd,0xc0,0xa8,0x01,0xbd,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2d,0x00,0x00,0x64,0x2d,0xc0,0xa8,0x02,0xbe,0xc0,0xa8,0x01,0xbe,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2e,0x00,0x00,0x64,0x2e,0xc0,0xa8,0x02,0xbf,0xc0,0xa8,0x01,0xbf,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2e,0x00,0x00,0x64,0x2e,0xc0,0xa8,0x02,0xc0,0xc0,0xa8,0x01,0xc0,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2f,0x00,0x00,0x64,0x2f,0xc0,0xa8,0x02,0xc1,0xc0,0xa8,0x01,0xc1,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2f,0x00,0x00,0x64,0x2f,0xc0,0xa8,0x02,0xc2,0xc0,0xa8,0x01,0xc2,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x30,0x00,0x00,0x64,0x30,0xc0,0xa8,0x02,0xc3,0xc0,0xa8,0x01,0xc3,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x30,0x00,0x00,0x64,0x30,0xc0,0xa8,0x02,0xc4,0xc0,0xa8,0x01,0xc4,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x31,0x00,0x00,0x64,0x31,0xc0,0xa8,0x02,0xc5,0xc0,0xa8,0x01,0xc5,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x31,0x00,0x00,0x64,0x31,0xc0,0xa8,0x02,0xc6,0xc0,0xa8,0x01,0xc6,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x32,0x00,0x00,0x64,0x32,0xc0,0xa8,0x02,0xc7,0xc0,0xa8,0x01,0xc7,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x32,0x00,0x00,0x64,0x32,0xc0,0xa8,0x02,0xc8,0xc0,0xa8,0x01,0xc8,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x01,0x00,0x00,0x3c,0x01,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x02,0x00,0x00,0x3c,0x02,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x03,0x00,0x00,0x3c,0x03,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x04,0x00,0x00,0x3c,0x04,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x05,0x00,0x00,0x3c,0x05,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x06,0x00,0x00,0x3c,0x06,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x07,0x00,0x00,0x3c,0x07,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x08,0x00,0x00,0x3c,0x08,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x09,0x00,0x00,0x3c,0x09,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0a,0x00,0x00,0x3c,0x0a,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0b,0x00,0x00,0x3c,0x0b,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0c,0x00,0x00,0x3c,0x0c,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0d,0x00,0x00,0x3c,0x0d,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0e,0x00,0x00,0x3c,0x0e,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0f,0x00,0x00,0x3c,0x0f,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x10,0x00,0x00,0x3c,0x10,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x11,0x00,0x00,0x3c,0x11,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x12,0x00,0x00,0x3c,0x12,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x13,0x00,0x00,0x3c,0x13,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x14,0x00,0x00,0x3c,0x14,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x15,0x00,0x00,0x3c,0x15,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x16,0x00,0x00,0x3c,0x16,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x17,0x00,0x00,0x3c,0x17,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x18,0x00,0x00,0x3c,0x18,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x19,0x00,0x00,0x3c,0x19,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1a,0x00,0x00,0x3c,0x1a,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1b,0x00,0x00,0x3c,0x1b,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1c,0x00,0x00,0x3c,0x1c,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1d,0x00,0x00,0x3c,0x1d,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1e,0x00,0x00,0x3c,0x1e,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x64,0x04,0x64,0x3c,0x04,0x00,0x01,0x64,0x01,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x02,0x64,0x02,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x03,0x64,0x03,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x04,0x64,0x04,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x05,0x64,0x05,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x06,0x64,0x06,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x07,0x64,0x07,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x08,0x64,0x08,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x09,0x64,0x09,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0a,0x64,0x0a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0b,0x64,0x0b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0c,0x64,0x0c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0d,0x64,0x0d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0e,0x64,0x0e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0f,0x64,0x0f,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x10,0x64,0x10,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x11,0x64,0x11,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x12,0x64,0x12,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x13,0x64,0x13,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x14,0x64,0x14,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x15,0x64,0x15,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x16,0x64,0x16,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x17,0x64,0x17,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x18,0x64,0x18,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x19,0x64,0x19,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1a,0x64,0x1a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1b,0x64,0x1b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1c,0x64,0x1c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1d,0x64,0x1d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1e,0x64,0x1e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1f,0x64,0x1f,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x20,0x64,0x20,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x21,0x64,0x21,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x22,0x64,0x22,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x23,0x64,0x23,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x24,0x64,0x24,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x25,0x64,0x25,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x26,0x64,0x26,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x27,0x64,0x27,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x28,0x64,0x28,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x29,0x64,0x29,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2a,0x64,0x2a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2b,0x64,0x2b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2c,0x64,0x2c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2d,0x64,0x2d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2e,0x64,0x2e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2f,0x64,0x2f,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x30,0x64,0x30,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x31,0x64,0x31,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x32,0x64,0x32,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x33,0x3c,0x01,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x34,0x3c,0x02,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x35,0x3c,0x03,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x36,0x3c,0x04,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x37,0x3c,0x05,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x38,0x3c,0x06,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x39,0x3c,0x07,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3a,0x3c,0x08,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3b,0x3c,0x09,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3c,0x3c,0x0a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3d,0x3c,0x0b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3e,0x3c,0x0c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3f,0x3c,0x0d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x40,0x3c,0x0e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x41,0x3c,0x0f,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x42,0x3c,0x10,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x43,0x3c,0x11,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x44,0x3c,0x12,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x45,0x3c,0x13,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x46,0x3c,0x14,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x47,0x3c,0x15,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x48,0x3c,0x16,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x49,0x3c,0x17,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4a,0x3c,0x18,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4b,0x3c,0x19,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4c,0x3c,0x1a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4d,0x3c,0x1b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4e,0x3c,0x1c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4f,0x3c,0x1d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x50,0x3c,0x1e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/2oo2/2oo2DataTransferManage.c b/TSCP/src/APP/ciapp/2oo2/2oo2DataTransferManage.c new file mode 100644 index 0000000..1d4e480 --- /dev/null +++ b/TSCP/src/APP/ciapp/2oo2/2oo2DataTransferManage.c @@ -0,0 +1,1799 @@ +/******************************************************** +* +* 2oo2DataTransferManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2011-06-24 +* ߣ +* Ӧת +* ޸ļ¼ +* +********************************************************/ + +#include "2oo2DataTransferManage.h" +#include "HLHTHeadContexManage.h" +#include "ParsePackGateWayData.h" +#include "WLBrakeDataManage.h" +#include "NonAutoReturnDataManage.h" +#include "DynamicRouteDataManage.h" +#include "../Deployment/DeploymentExtern.h" +/**/ +extern UINT16 TransmitStateDataCurSum; /*ͨŹϵ״̬ݵǰ*/ +extern UINT8 ComCycNumForCiToAts; /*ATSͨڼ¼*/ +extern UINT8 ComCycNumForCiToXianDi; /*ֵͨڼ¼*/ + + +extern TransmitStateDataStruct TransmitStateDataStru[TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX]; /*ͨ״̬ṹ*/ + + + + +/* +* ṹЧid + + const void *pDataStru ṹָ + UINT16 struNum:鳤, + UINT16 struLength:ṹ峤 + + UINT8 *pCurCiAppDataPointer:ǰָ, +* ֵ ݵij +* ע ֻڽṹһԪΪֽڵID +*/ +UINT32 CopyValidGetDataStru(UINT8 *pCurCiAppDataPointer, const void *pDataStru, UINT16 struNum, UINT16 struLength) +{ + UINT32 curIndex = 0u; + + UINT16 ValidIdNum = 0u; + + UINT16 i = 0u; + + void * pSrcAddr = NULL; + + /*У*/ + if((NULL != pCurCiAppDataPointer) && (NULL != pDataStru) && (0u != struNum) && (0u != struLength)) + { + curIndex += (UINT32)sizeof(UINT16); + + for(i = 0u; i < struNum; i++) + { + pSrcAddr = (const UINT8 *)pDataStru + struLength * i; + + /*ṹԪǰֽIDΪ0ʱЧ,˴˵Ч*/ + if(0u != ShortFromCharLE(pSrcAddr)) + { + (void)memcpy(pCurCiAppDataPointer + curIndex, pSrcAddr, struLength); + + curIndex += (UINT32)struLength; + + ValidIdNum++; + } + else + { + /*ִκβ*/ + } + } + + /*Ч*/ + ShortToChar(ValidIdNum, pCurCiAppDataPointer); + } + else + { + curIndex = 0u; + + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} +/* +* ṹЧͨųid + + VobcToCiDataStruct *pDataStru ṹָ + UINT16 struNum:鳤, + + UINT8 *pCurCiAppDataPointer:ǰָ, +* ֵ ݵij +* ע ֻڽṹһԪΪֽڵID +*/ +UINT32 CopyValidGetVobcDataStru(UINT8* pCurCiAppDataPointer, VobcToCiDataStruct* pDataStru, UINT16 struNum) +{ + UINT32 curIndex = 0U; + UINT16 ValidIdNum = 0U; + UINT16 i = 0U; + + /*У*/ + if ((NULL != pCurCiAppDataPointer) && (NULL != pDataStru) && (0U != struNum)) + { + curIndex += (UINT32)sizeof(UINT16); /*VOBC*/ + + for (i = 0U; i < struNum; i++) + { + /*ṹԪǰֽVOBC IDΪ0ʱЧ,˴˵Ч*/ + if (0U != pDataStru[i].VobcId) + { + ShortToChar(pDataStru[i].VobcId, &pCurCiAppDataPointer[curIndex]); /*VOBC ID*/ + curIndex += 2U; + + pCurCiAppDataPointer[curIndex] = pDataStru[i].trainDirection; /*гз*/ + curIndex++; + + pCurCiAppDataPointer[curIndex] = pDataStru[i].chTrainLevel; /*гм*/ + curIndex++; + + ShortToChar(pDataStru[i].wTrainMaxSafeHeadLink, &pCurCiAppDataPointer[curIndex]); /*ǰlink ID*/ + curIndex += 2U; + + LongToChar(pDataStru[i].dwTrainMaxSafeHeadOffset, &pCurCiAppDataPointer[curIndex]); /*ǰlinkƫ*/ + curIndex += 4U; + + ShortToChar(pDataStru[i].wTrainMinSafeHeadLink, &pCurCiAppDataPointer[curIndex]); /*Сǰlink ID*/ + curIndex += 2U; + + LongToChar(pDataStru[i].dwTrainMinSafeHeadOffset, &pCurCiAppDataPointer[curIndex]); /*Сǰlinkƫ*/ + curIndex += 4U; + + ShortToChar(pDataStru[i].wTrainMaxSafeTailLink, &pCurCiAppDataPointer[curIndex]); /*link ID*/ + curIndex += 2U; + + LongToChar(pDataStru[i].dwTrainMaxSafeTailOffset, &pCurCiAppDataPointer[curIndex]); /*linkƫ*/ + curIndex += 4U; + + ShortToChar(pDataStru[i].wTrainMinSafeTailLink, &pCurCiAppDataPointer[curIndex]); /*Сlink ID*/ + curIndex += 2U; + + LongToChar(pDataStru[i].dwTrainMinSafeTailOffset, &pCurCiAppDataPointer[curIndex]); /*Сlinkƫ*/ + curIndex += 4U; + + ShortToChar(pDataStru[i].wTrainSpeed, &pCurCiAppDataPointer[curIndex]); /*гٶ*/ + curIndex += 2U; + + pCurCiAppDataPointer[curIndex] = pDataStru[i].chSpeedDir; /*гٶȷ*/ + curIndex++; + + LongToChar(pDataStru[i].ComStartCycle, &pCurCiAppDataPointer[curIndex]); /*гͨʼʱ*/ + curIndex += 4U; + + ShortToChar(pDataStru[i].appInfoType, &pCurCiAppDataPointer[curIndex]); /*ӦϢ*/ + curIndex += 2U; + + ShortToChar(pDataStru[i].vobcLogId, &pCurCiAppDataPointer[curIndex]); /*VOBCͨID*/ + curIndex += 2U; + + LongToChar(pDataStru[i].signalID, &pCurCiAppDataPointer[curIndex]); /*VOBC->CIźŻID*/ + curIndex += 4U; + + pCurCiAppDataPointer[curIndex] = pDataStru[i].chLogOutState; /*ע״̬*/ + curIndex++; + + ValidIdNum++; + } + else + { + /*ִκβ*/ + } + } + + ShortToChar(ValidIdNum, pCurCiAppDataPointer); /*Ч*/ + } + else + { + curIndex = 0U; + + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* ṹͨITE +* ˵IteToCiDataStruct pDataStru[ITE_TO_CI_SUM_MAX] ITEṹ +* UINT16 struNum 鳤 +* UINT8* pCurCiAppDataPointer ǰָ루Σ +* ֵݳ +* Created By LQ 2024.06.15 +*/ +UINT32 CopyValidGetIteDataStru(UINT8* pCurCiAppDataPointer, IteToCiDataStruct pDataStru[ITE_TO_CI_SUM_MAX], UINT16 struNum) +{ + UINT32 curIndex = 0U; + UINT16 ValidIdNum = 0U; + UINT16 i = 0U; + + /*У*/ + if ((NULL != pCurCiAppDataPointer) && (NULL != pDataStru) && (0U != struNum)) + { + curIndex += (UINT32)sizeof(UINT16); /*ITE*/ + + for (i = 0U; i < struNum; i++) + { + /*ṹԪǰֽITE IDΪ0ʱЧ,˴˵Ч*/ + if (0U != pDataStru[i].wIteId) + { + ShortToChar(pDataStru[i].wIteId, &pCurCiAppDataPointer[curIndex]); /*ITE ID*/ + curIndex += 2U; + + ShortToChar(pDataStru[i].wIteLogId, &pCurCiAppDataPointer[curIndex]); /*ITE߼ID*/ + curIndex += 2U; + + LongToChar(pDataStru[i].dwComStartCycCount, &pCurCiAppDataPointer[curIndex]); /*ͨʼ*/ + curIndex += 4U; + + ValidIdNum++; + } + else + { + /*ִκβ*/ + } + } + + ShortToChar(ValidIdNum, pCurCiAppDataPointer); /*Ч*/ + } + else + { + curIndex = 0U; + + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* Чͨͷ + +const void *pDataStru ṹָ +UINT16 struNum:鳤, +UINT16 struLength:ṹ峤 + +UINT8 *pCurCiAppDataPointer:ǰָ, +* ֵ ݵij +* ע ջͨͷidжЧ +*/ +UINT32 CopyValidGetVobcBackHlht(UINT8 *pCurCiAppDataPointer, UINT16 struNum, UINT16 struLength) +{ + UINT32 curIndex = 0U; + + UINT16 ValidIdNum = 0U; + + UINT16 i = 0U; + + /*У*/ + if ((NULL != pCurCiAppDataPointer) && (0U != struNum) && (0U != struLength)&&(NULL != vobcBackupHLHTHeadCtxs)) + { + curIndex += (UINT32)sizeof(UINT16); + + for (i = 0U; i < struNum; i++) + { + /*ͨͷidΪ0ʱЧ*/ + if (0U != vobcBackupHLHTHeadCtxs[i].sourceId) + { + (void)CommonMemCpy((void *)(pCurCiAppDataPointer + curIndex), struLength, (void *)(&vobcBackupHLHTHeadCtxs[i]), struLength); + curIndex += (UINT32)struLength; + + ValidIdNum++; + } + else + { + /*ִκβ*/ + } + } + + /*Ч*/ + ShortToChar(ValidIdNum, pCurCiAppDataPointer); + } + else + { + curIndex = 0u; + + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* ṹ߼· + + UINT8 *pCurCiAppDataPointer:ǰָ, +* ֵ ݵij +* ע ֻڽṹһԪΪֽڵID +*/ +UINT32 CopyValidGetLogicRouteDataStru(UINT8* pCurCiAppDataPointer) +{ + UINT32 curIndex = 0U; + + UINT16 ValidIdNum = 0U; + + UINT16 i = 0U; + UINT16 wLogRouteId = 0U; + UINT8 cRouteState = ROUTE_LOGICAL_STATE_IDLE; + + void* pSrcAddr = NULL; + + /*У*/ + if (NULL != pCurCiAppDataPointer) + { + curIndex += (UINT32)sizeof(UINT16); + + for (i = 1U; i < ROUTE_LOGICAL_SUM_MAX; i++) + { + pSrcAddr = (UINT8*)(void*)&LogicalRouteDataStru[i]; + + wLogRouteId = GetLogicalRouteId(i - 1U); + cRouteState = GetLogicalRouteState(wLogRouteId); + + if ((ROUTE_LOGICAL_STATE_IDLE != cRouteState) && (0U != cRouteState)) + { + /*ṹԪǰֽIDΪ0ʱЧ,˴˵Ч*/ + if (0U != ShortFromCharLE(pSrcAddr)) + { + (void)memcpy(pCurCiAppDataPointer + curIndex, pSrcAddr, sizeof(LogicalRouteDataStruct)); + + curIndex += (UINT32)sizeof(LogicalRouteDataStruct); + + ValidIdNum++; + } + else + { + /*ִκβ*/ + } + } + } + + /*Ч*/ + ShortToChar(ValidIdNum, pCurCiAppDataPointer); + } + else + { + curIndex = 0U; + + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* ЧݵӦȫ +* ˵ + + const UINT8 *pCurCiAppDataPointer:ǰָ + UINT16 struNum:鳤, + UINT16 struLength:ṹ峤 + + void *pDataStru:ṹָ, +* ֵ ݵij +* ע ֻڽṹһԪΪֽڵID +*/ +UINT32 CopyValidSetDataStru(const UINT8 *pCurCiAppDataPointer, void *pDataStru, UINT16 struNum, UINT16 struLength) +{ + UINT32 curIndex = 0u; + + UINT16 i = 0u; + + UINT16 ValidIdNum = 0u; + + UINT16 dataStruIndex = 0u; + + void * pDstAddr = NULL; + + /*У*/ + if((NULL != pCurCiAppDataPointer) && (NULL != pDataStru) && (0u != struNum) && (0u != struLength)) + { + /*ȡܵЧID*/ + ValidIdNum = ShortFromChar(pCurCiAppDataPointer); + + curIndex += (UINT32)sizeof(UINT16); + + for(i = 0u; i < ValidIdNum; i++) + { + dataStruIndex = ShortFromCharLE(pCurCiAppDataPointer + curIndex); + + if(dataStruIndex < struNum) + { + pDstAddr = (UINT8 *)pDataStru + struLength * dataStruIndex; + + (void)memcpy(pDstAddr, pCurCiAppDataPointer + curIndex, struLength); + + curIndex += (UINT32)struLength; + } + else + { + curIndex += (UINT32)struLength; + + debug_infor_printf((const)"ERROR: SetValidIdNum = %d\n", (const) dataStruIndex); + } + } + } + else + { + curIndex = 0u; + + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* ͨųЧݵӦȫ +* ˵ + + const UINT8 *pCurCiAppDataPointer:ǰָ + UINT16 struNum:鳤, + + VobcToCiDataStruct *pDataStru:ṹָ, +* ֵ ݵij +* ע ֻڽṹһԪΪֽڵID +*/ +UINT32 CopyValidSetVobcDataStru(const UINT8* pCurCiAppDataPointer, VobcToCiDataStruct* pDataStru, UINT16 struNum) +{ + UINT32 curIndex = 0U; + UINT16 i = 0U; + UINT16 ValidIdNum = 0U; + + /*У*/ + if ((NULL != pCurCiAppDataPointer) && (NULL != pDataStru) && (0U != struNum)) + { + /*ȡܵЧID*/ + ValidIdNum = ShortFromChar(pCurCiAppDataPointer); + + curIndex += (UINT32)sizeof(UINT16); + + for (i = 0U; i < ValidIdNum; i++) + { + if (i < struNum) + { + pDataStru[i].VobcId = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬVOBC ID*/ + curIndex += 2U; + + pDataStru[i].trainDirection = pCurCiAppDataPointer[curIndex]; /*ͬгз*/ + curIndex++; + + pDataStru[i].chTrainLevel = pCurCiAppDataPointer[curIndex]; /*ͬгм*/ + curIndex++; + + pDataStru[i].wTrainMaxSafeHeadLink = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгǰlink ID*/ + curIndex += 2U; + + pDataStru[i].dwTrainMaxSafeHeadOffset = LongFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгǰlinkƫ*/ + curIndex += 4U; + + pDataStru[i].wTrainMinSafeHeadLink = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгСǰlink ID*/ + curIndex += 2U; + + pDataStru[i].dwTrainMinSafeHeadOffset = LongFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгСǰlinkƫ*/ + curIndex += 4U; + + pDataStru[i].wTrainMaxSafeTailLink = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгlink ID*/ + curIndex += 2U; + + pDataStru[i].dwTrainMaxSafeTailOffset = LongFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгlinkƫ*/ + curIndex += 4U; + + pDataStru[i].wTrainMinSafeTailLink = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгСlink ID*/ + curIndex += 2U; + + pDataStru[i].dwTrainMinSafeTailOffset = LongFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгСlinkƫ*/ + curIndex += 4U; + + pDataStru[i].wTrainSpeed = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгٶ*/ + curIndex += 2U; + + pDataStru[i].chSpeedDir = pCurCiAppDataPointer[curIndex]; /*ͬгٶȷ*/ + curIndex++; + + pDataStru[i].ComStartCycle = LongFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬгͨʼʱ*/ + curIndex += 4U; + + pDataStru[i].appInfoType = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬӦϢ*/ + curIndex += 2U; + + pDataStru[i].vobcLogId = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬVOBCͨID*/ + curIndex += 2U; + + pDataStru[i].signalID = LongFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬVOBC->CIźŻID*/ + curIndex += 4U; + + pDataStru[i].chLogOutState = pCurCiAppDataPointer[curIndex]; /*ͬע״̬*/ + curIndex++; + } + else + { + curIndex += VOBC_2X_DATA_LEN; + debug_infor_printf((const)"ERROR: SetValidIdNum = %d\n", i); + } + } + } + else + { + curIndex = 0U; + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* ITEЧݵӦȫ +* ˵const UINT8 *pCurCiAppDataPointer:ǰָ +* UINT16 struNum 鳤 +* IteToCiDataStruct pDataStru[ITE_TO_CI_SUM_MAX] ITEṹ Σ +* ֵݵij +* Created By LQ 2024.06.15 +*/ +UINT32 CopyValidSetIteDataStru(const UINT8* pCurCiAppDataPointer, IteToCiDataStruct pDataStru[ITE_TO_CI_SUM_MAX], UINT16 struNum) +{ + UINT32 curIndex = 0U; + UINT16 i = 0U; + UINT16 ValidIdNum = 0U; + + /*У*/ + if ((NULL != pCurCiAppDataPointer) && (NULL != pDataStru) && (0U != struNum)) + { + /*ȡܵЧID*/ + ValidIdNum = ShortFromChar(pCurCiAppDataPointer); + + curIndex += (UINT32)sizeof(UINT16); + + for (i = 0U; i < ValidIdNum; i++) + { + if (i < struNum) + { + pDataStru[i].wIteId = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬITE ID*/ + curIndex += 2U; + + pDataStru[i].wIteLogId = ShortFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬITE߼ID*/ + curIndex += 2U; + + pDataStru[i].dwComStartCycCount = LongFromChar(&pCurCiAppDataPointer[curIndex]); /*ͬITEͨʼ*/ + curIndex += 4U; + } + else + { + curIndex += ITE_2X_DATA_LEN; + debug_infor_printf((const)"ERROR:ITE SetValidIdNum = %d\n", i); + } + } + } + else + { + curIndex = 0U; + debug_infor_printf((const)"ERROR: ITE Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* ЧͨͷӦȫ +* ˵ + +const UINT8 *pCurCiAppDataPointer:ǰָ +UINT16 struNum:鳤, +UINT16 struLength:ṹ峤 + +* ֵ ݵij +*/ +UINT32 CopyValidSetVobcBackHlht(const UINT8 *pCurCiAppDataPointer,UINT16 struNum, UINT16 struLength) +{ + UINT32 curIndex = 0U; + + UINT16 i = 0U; + + UINT16 ValidIdNum = 0U; + + UINT8 devId = 0U; + + HLHTHeadContextStru temp = { 0 }; + + /*У*/ + if ((NULL != pCurCiAppDataPointer) && (NULL != vobcBackupHLHTHeadCtxs) && (0U != struNum) && (0U != struLength)) + { + /*ȡܵЧID*/ + ValidIdNum = ShortFromChar(pCurCiAppDataPointer); + + curIndex += (UINT32)sizeof(UINT16); + + for (i = 0u; i < ValidIdNum; i++) + { + /*浽ʱṹ岢ȡ豸id*/ + (void)CommonMemCpy((void *)(&temp), struLength, (const void *)(pCurCiAppDataPointer + curIndex), struLength); + devId = temp.sourceId; + if (devId < struNum) + { + /*浽ȫ*/ + (void)CommonMemCpy((void *)(&vobcBackupHLHTHeadCtxs[devId]), struLength, (const void *)(&temp), struLength); + curIndex += (UINT32)struLength; + } + else + { + curIndex += (UINT32)struLength; + + debug_infor_printf((const)"ERROR: SetValidIdNum = %d\n", devId); + } + } + } + else + { + curIndex = 0u; + + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* ߼·ЧݵӦȫ +* ˵ + + const UINT8 *pCurCiAppDataPointer:ǰָ +* ֵ ݵij +* ע ֻڽṹһԪΪֽڵID +*/ +UINT32 CopyValidSetLogicRouteDataStru(const UINT8* pCurCiAppDataPointer) +{ + UINT32 curIndex = 0U; + + UINT32 i = 0U; + + UINT16 ValidIdNum = 0U; + UINT16 dataStruIndex = 0u; + void* pDstAddr = NULL; + + /*У*/ + if (NULL != pCurCiAppDataPointer) + { + /*ȡܵЧID*/ + ValidIdNum = ShortFromChar(pCurCiAppDataPointer); + + curIndex += (UINT32)sizeof(UINT16); + + for (i = 0U; i < ValidIdNum; i++) + { + dataStruIndex = ShortFromCharLE(pCurCiAppDataPointer + curIndex); + if (ROUTE_LOGICAL_SUM_MAX > i) + { + pDstAddr = (UINT8*)(void*)&LogicalRouteDataStru[dataStruIndex]; + + (void)memcpy(pDstAddr, pCurCiAppDataPointer + curIndex, sizeof(LogicalRouteDataStruct)); + + curIndex += (UINT32)sizeof(LogicalRouteDataStruct); + } + else + { + curIndex += (UINT32)sizeof(LogicalRouteDataStruct); + + debug_infor_printf((const)"ERROR: SetValidIdNum = %d\n", i); + } + } + } + else + { + curIndex = 0U; + + debug_infor_printf((const)"ERROR: Parameter is invailid\n"); + } + + return curIndex; +} + +/* +* ȡCIӦ +* ˵ UINT8 *pCiAppDataPointer, CIӦָ +* ֵ void +*/ +UINT32 GetCiAppData(UINT8 *pCiAppDataPointer) +{ + UINT32 curIndex = 0u; /*¼ƶ±*/ + UINT32 curResult = 0u; /*ṹЧid*/ + UINT8 ii= 0u; + + if (NULL != pCiAppDataPointer) + { + + /*ȫվƱ־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &AllSignalBrightFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ȫվ־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &AllSwitchYLockFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ȫվ־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &StartFLockFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ϵձ־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &StartLockFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ֹͣδ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &StopCheckState, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*Ӧ̵̼ID*/ + (void)memcpy(pCiAppDataPointer + curIndex, &JkjRelayId, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + + /*ƽ̨崻־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &PlatOverFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*JKJӦ̵̼Ч*/ + (void)memcpy(pCiAppDataPointer + curIndex, &JkjRelayValid, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ȫѩģʽ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &g_AllSnowModel, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*Ӧ̵̼Ч*/ + (void)memcpy(pCiAppDataPointer + curIndex, &JkjRelayValidCycNum, sizeof(UINT32)); + curIndex = curIndex + (UINT32)sizeof(UINT32); + + /*ܸλ״̬Ч*/ + (void)memcpy(pCiAppDataPointer + curIndex, &ZFWValidCycNum, sizeof(UINT32)); + curIndex = curIndex + (UINT32)sizeof(UINT32); + + /*ܸλʼ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &ZFWCmdStartCycNum, sizeof(UINT32)); + curIndex = curIndex + (UINT32)sizeof(UINT32); + + /*ݵǰ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &ErrorDataCurSum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + + /*ͨŹϵ״̬ݵǰ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &TransmitStateDataCurSum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + + /*ATSͨڼ¼*/ + (void)memcpy(pCiAppDataPointer + curIndex, &ComCycNumForCiToAts, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ֵͨڼ¼*/ + (void)memcpy(pCiAppDataPointer + curIndex, &ComCycNumForCiToXianDi, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*һβԴϵͳ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &LastCmdSourceSysType, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*״βȷϵID*/ + (void)memcpy(pCiAppDataPointer + curIndex, &FirstCmdId, sizeof(UINT32)); + curIndex = curIndex + (UINT32)sizeof(UINT32); + + /*CIṹ鳤*/ + (void)memcpy(pCiAppDataPointer + curIndex, &CiSendCmdStruCurSum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + + /*CI͵ṹ鳤*/ + (void)memcpy(pCiAppDataPointer + curIndex, &SendCiCmdDataStruCurSum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + + /*ͨŵVobcĿ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &VobcToCiSum, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ͨŵITEĿ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &IteToCiSum, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + +#if 0 + /*г*/ + (void)memcpy(pCiAppDataPointer + curIndex, &ComTrainSum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); +#endif + /*ܸλ־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &generalResetFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ȷϱ־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &g_cTsrSureFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ȫʱ״̬*/ + (void)memcpy(pCiAppDataPointer + curIndex, &g_AllLineTsrState, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ȫʱٶ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &g_AllLineTsrSpeed, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*·ݽṹ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)RouteDataStru, ROUTE_SUM_MAX, (UINT16)sizeof(RouteDataStruct)); + curIndex = curIndex + curResult; + + /*߼·ݽṹ*/ + curResult = CopyValidGetLogicRouteDataStru(pCiAppDataPointer + curIndex); + curIndex = curIndex + curResult; + + /*źŻݽṹ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)SignalDataStru, SIGNAL_SUM_MAX, (UINT16)sizeof(SignalDataStruct)); + curIndex = curIndex + curResult; + + /*ݽṹ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)SwitchDataStru, SWITCH_SUM_MAX, (UINT16)sizeof(SwitchDataStruct)); + curIndex = curIndex + curResult; + + /*ݽṹ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)AxisSectionDataStru, AXIS_SECTION_SUM_MAX, (UINT16)sizeof(AxisSectionDataStruct)); + curIndex = curIndex + curResult; + + /*߼ݽṹ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)LogicSectionDataStru, LOGIC_SECTION_SUM_MAX, (UINT16)sizeof(LogicSectionDataStruct)); + curIndex = curIndex + curResult; + + /*ݽṹ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)PhysicalSectionDataStru, PHYSICAL_SECTION_SUM_MAX, (UINT16)sizeof(PhysicalSectionDataStruct)); + curIndex = curIndex + curResult; + + /*̵ݽṹ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)RelayDataStru, RELAY_SUM_MAX, (UINT16)sizeof(RelayDataStruct)); + curIndex = curIndex + curResult; + + /*ESBݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, EsbDataStru, (ESB_SUM_MAX)*sizeof(EsbDataStruct)); + curIndex = curIndex + (UINT32)((ESB_SUM_MAX)*sizeof(EsbDataStruct)); + + /*ݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, PsdDataStru, (PSD_SUM_MAX)*sizeof(PsdDataStruct)); + curIndex = curIndex + (UINT32)((PSD_SUM_MAX)*sizeof(PsdDataStruct)); + + /*OVERLAPݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, OverlapDataStru, (OVERLAP_SUM_MAX)*sizeof(OverlapDataStruct)); + curIndex = curIndex + (UINT32)((OVERLAP_SUM_MAX)*sizeof(OverlapDataStruct)); + + /*Զ۷ݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, AutoReturnDataStru, (AUTO_RETURN_SUM_MAX)*sizeof(AutoReturnDataStruct)); + curIndex = curIndex + (UINT32)((AUTO_RETURN_SUM_MAX)*sizeof(AutoReturnDataStruct)); + + /*Զ·ݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, AutoRouteDataStru, (AUTO_ROUTE_SUM_MAX)*sizeof(AutoRouteDataStruct)); + curIndex = curIndex + (UINT32)((AUTO_ROUTE_SUM_MAX)*sizeof(AutoRouteDataStruct)); + + /*ǽ·ݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, NonRouteDataStruArr, NONROUTE_ID_NUM_MAX*sizeof(NonRouteDataStruct)); + curIndex = curIndex + (UINT32)(NONROUTE_ID_NUM_MAX*sizeof(NonRouteDataStruct)); + + /*ָʾݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, IndicatorDataStru, (INDICATOR_SUM_MAX)*sizeof(IndicatorDataStruct)); + curIndex = curIndex + (UINT32)((INDICATOR_SUM_MAX)*sizeof(IndicatorDataStruct)); + + /*OCվվͷǼվָʾṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, g_OCStationIndicDataStru, (INDICATOR_SUM_MAX) * sizeof(OCStationIndicDataStru)); + curIndex = curIndex + (UINT32)((INDICATOR_SUM_MAX) * sizeof(OCStationIndicDataStru)); + + /*ݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, ErrorDataStru, (ERROR_DATA_SUM_MAX)*sizeof(ErrorDataStruct)); + curIndex = curIndex + (UINT32)((ERROR_DATA_SUM_MAX)*sizeof(ErrorDataStruct)); + + /*·ݽṹ*/ +#if 0 + (void)memcpy(pCiAppDataPointer + curIndex, LongRouteDataStru, (ROUTE_LONG_SUM_MAX)*sizeof(LongRouteDataStruct)); + curIndex = curIndex + (ROUTE_LONG_SUM_MAX)*sizeof(LongRouteDataStruct); +#endif + curIndex += CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)LongRouteDataStru, ROUTE_LONG_SUM_MAX, (UINT16)sizeof(LongRouteDataStruct)); + + /*ͨ״̬ṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, TransmitStateDataStru, (TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX)*sizeof(TransmitStateDataStruct)); + curIndex = curIndex + (UINT32)((TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX)*sizeof(TransmitStateDataStruct)); + + /*CIṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, CiSendCmdDataStru, (CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX)*sizeof(CommandDataStruct)); + curIndex = curIndex + (UINT32)((CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX)*sizeof(CommandDataStruct)); + + /*CI͵ṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, SendCiCmdDataStru, (SENDCI_CMD_DATA_STRU_SUM_MAX)*sizeof(ToCiCommandDataStruct)); + curIndex = curIndex + (UINT32)((SENDCI_CMD_DATA_STRU_SUM_MAX)*sizeof(ToCiCommandDataStruct)); + + /*ͨŵVobcϢ*/ + curResult = CopyValidGetVobcDataStru(pCiAppDataPointer + curIndex, VobcToCiDataStru, VOBC_TO_CI_SUM_MAX); + curIndex = curIndex + curResult; + + /*ʹúģʽͨŵVobcϢ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)VobcBackUpToCiDataStru, VOBC_BACKUP_TO_CI_SUM_MAX, (UINT16)sizeof(VobcBackUpToCiDataStruct)); + curIndex = curIndex + curResult; + + /*ͨŵITEϢ*/ + curResult = CopyValidGetIteDataStru(pCiAppDataPointer + curIndex, IteToCiDataStru, ITE_TO_CI_SUM_MAX); + curIndex = curIndex + curResult; +#if 0 + /*гλϢ*/ + (void)memcpy(pCiAppDataPointer + curIndex, ComTrainPosDataStru, (ZC_TO_CI_TRAIN_MAX)*sizeof(ComTrainPosDataStruct)); + curIndex = curIndex + (ZC_TO_CI_TRAIN_MAX)*sizeof(ComTrainPosDataStruct); +#endif + /*ȫԶ۷ݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, AllAutoReturnDataStru, (ALL_AUTO_RETURN_SUM_MAX)*sizeof(AllAutoReturnDataStruct)); + curIndex = curIndex + (UINT32)((ALL_AUTO_RETURN_SUM_MAX)*sizeof(AllAutoReturnDataStruct)); + + /*ݽṹ*/ + (void)memcpy(pCiAppDataPointer + curIndex, GaragedoorDataStru, (GARAGE_DOOR_SUM_MAX)*sizeof(GaragedoorDataStruct)); + curIndex = curIndex + (UINT32)((GARAGE_DOOR_SUM_MAX)*sizeof(GaragedoorDataStruct)); + + /* SPKS (void *pDest, UINT32 destBuffSize, const void *pSrc, UINT32 count);*/ + (void)memcpy(pCiAppDataPointer + curIndex,spksDataBuff,(SPKS_SUM_MAX)*sizeof(SpksDataStruct)); + curIndex += (UINT32)((SPKS_SUM_MAX)*sizeof(SpksDataStruct)); + + /* վģʽ */ + pCiAppDataPointer[curIndex] = GetCiModeFlag(); + curIndex += 1U; + + /*˹ȡʱ״̬ת*/ + pCiAppDataPointer[curIndex] = LabourCancelLinShiXianState; + curIndex += 1U; + + /*뱾CIͨŵCIͨͷ*/ + (void)memcpy(pCiAppDataPointer + curIndex,ciHLHTHeadCtxs,(CI_SUM_MAX)*sizeof(HLHTHeadContextStru)); + curIndex = curIndex + (UINT32)((CI_SUM_MAX)*sizeof(HLHTHeadContextStru)); + + /*뱾CIͨŵVOBCͨͷ*/ + (void)memcpy(pCiAppDataPointer + curIndex,vobcHLHTHeadCtxs,(VOBC_SUM_MAX)*sizeof(HLHTHeadContextStru)); + curIndex = curIndex + (UINT32)((VOBC_SUM_MAX)*sizeof(HLHTHeadContextStru)); + + /*뱾CIͨŵVOBC󱸻ͨͷ*/ + curResult = CopyValidGetVobcBackHlht(pCiAppDataPointer + curIndex, VOBC_BACKUP_SUM_MAX, (UINT16)sizeof(HLHTHeadContextStru)); + curIndex = curIndex + curResult; + + /*뱾CIͨŵZCͨͷ*/ + (void)memcpy(pCiAppDataPointer + curIndex,zcHLHTHeadCtxs,(ZC_SUM_MAX)*sizeof(HLHTHeadContextStru)); + curIndex = curIndex + (UINT32)((ZC_SUM_MAX)*sizeof(HLHTHeadContextStru)); + + /*뱾CIͨŵļϵͳͨͷ*/ + (void)memcpy(pCiAppDataPointer + curIndex, axleHLHTHeadCtxs, (AXLE_SUM_MAX) * sizeof(HLHTHeadContextStru)); + curIndex = curIndex + (UINT32)((AXLE_SUM_MAX) * sizeof(HLHTHeadContextStru)); + + /*뱾CIͨŵOCϵͳͨͷ*/ + (void)memcpy(pCiAppDataPointer + curIndex, ocHLHTHeadCtxs, (OC_SUM_MAX) * sizeof(HLHTHeadContextStru)); + curIndex = curIndex + (UINT32)((OC_SUM_MAX) * sizeof(HLHTHeadContextStru)); + + /*뱾CIͨŵTMCϵͳͨͷ*/ + (void)memcpy(pCiAppDataPointer + curIndex, tmcHLHTHeadCtxs, (TMC_SUM_MAX) * sizeof(HLHTHeadContextStru)); + curIndex = curIndex + (UINT32)((TMC_SUM_MAX) * sizeof(HLHTHeadContextStru)); + + /*뱾CIͨŵITEͨͷ*/ + (void)memcpy(pCiAppDataPointer + curIndex, IteHLHTHeadCtxs, (ITE_SUM_MAX * VOBC_INC_ITE_SUM_MAX) * sizeof(HLHTHeadContextStru)); + curIndex = curIndex + (UINT32)((ITE_SUM_MAX * VOBC_INC_ITE_SUM_MAX) * sizeof(HLHTHeadContextStru)); + + /*ǰԳ״̬*/ + (void)memcpy(pCiAppDataPointer + curIndex, &ciTrainTestStatus, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ǰϴ״̬*/ + (void)memcpy(pCiAppDataPointer + curIndex, WashMachineDataStru, (WASHMACHINE_SUM_MAX)*sizeof(WashMachineDataStruct)); + curIndex = curIndex + (UINT32)((WASHMACHINE_SUM_MAX)*sizeof(WashMachineDataStruct)); + + /*Զ־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &AutoTriggerFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*Ŷ̬*/ + curIndex += CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void *)FloodGateDataStru, FLOOD_GATE_SUM_MAX, (UINT16)sizeof(FloodGateDataStruct)); + + /*̵ӿȷϱ־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &CiCiRelayInterfaceConfirmFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*OCźŻ豸*/ + (void)memcpy(pCiAppDataPointer + curIndex, &m_SignalNum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + /*뱾CIͨŵOCźŻ*/ + (void)memcpy(pCiAppDataPointer + curIndex, m_Signals, m_SignalNum * sizeof(OcDeviceStruct)); + curIndex = curIndex + (UINT32)(m_SignalNum * sizeof(OcDeviceStruct)); + + /*OCе豸*/ + (void)memcpy(pCiAppDataPointer + curIndex, &m_SwitchNum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + /*뱾CIͨŵOC*/ + (void)memcpy(pCiAppDataPointer + curIndex, m_Switches, m_SwitchNum * sizeof(OcDeviceStruct)); + curIndex = curIndex + (UINT32)(m_SwitchNum * sizeof(OcDeviceStruct)); + + /*뱾CIͨŵOC DI*/ + curIndex += CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void*)m_OcConvertedPtDataArr, (OC_SUM_MAX), (UINT16)sizeof(OcCollBoardDataStruct)); + + /*OCй*/ + (void)memcpy(pCiAppDataPointer + curIndex, &m_GdNum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + /*뱾CIͨŵOC */ + (void)memcpy(pCiAppDataPointer + curIndex, m_Gds, m_GdNum * sizeof(OcGdDevice)); + curIndex = curIndex + (UINT32)(m_GdNum * sizeof(OcGdDevice)); + + /*뱾CIͨŵOC ID*/ + (void)memcpy(pCiAppDataPointer + curIndex, LocalOcIds, (OC_SUM_MAX) * sizeof(UINT16)); + curIndex = curIndex + (UINT32)((OC_SUM_MAX) * sizeof(UINT16)); + + /*OcCiݵǰ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &m_OcToCiOrginDataNum, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + /*뱾CIͨŵOC ԭʼ*/ + (void)memcpy(pCiAppDataPointer + curIndex, m_OcToCiOrginDataArr, m_OcToCiOrginDataNum * sizeof(OcToCiOriginDataStruct)); + curIndex = curIndex + (UINT32)(m_OcToCiOrginDataNum * sizeof(OcToCiOriginDataStruct)); + + /*뱾CIͨŵļ*/ + curResult = CopyValidGetDataStru(pCiAppDataPointer + curIndex, (void*)axisToCiDataStru, AXIS_TO_CI_SUM_MAX, (UINT16)sizeof(AxisToCiDataStruct)); + curIndex = curIndex + curResult; + + /*ܸλ߱־*/ + (void)memcpy(pCiAppDataPointer + curIndex, &ZFWJRelayHunXianFlag, sizeof(UINT8)); + curIndex = curIndex + (UINT32)sizeof(UINT8); + + /*ݴһ*/ + (void)memcpy(pCiAppDataPointer + curIndex, CiSendBackDataTempStru, (CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX)*sizeof(CommandDataStruct)); + curIndex = curIndex + (UINT32)((CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX)*sizeof(CommandDataStruct)); + + /*ݴһ*/ + (void)memcpy(pCiAppDataPointer + curIndex, &CiSendBackDataTempStruSum, sizeof(UINT16)); + curIndex = curIndex + (UINT32)sizeof(UINT16); + + /**/ + for(ii = 0u;ii> 8u) & 0xFFu); + + OcToCiDataQueue = NULL; /*ʼOcCiݶ*/ + CiToOcDataQueue = CiToProtocolDataQueue; /*ʼCiOcݶ*/ + + if (1U != QueueInitial(&logPrintfQue, 500000U)) /*ʼ־*/ + { + debug_infor_printf((const)"canQueueRecv init error \n"); + } + +#if 0 + /*LEUZCCIȵͨ״̬*/ + if (TransmitRelaDataCurSum < TRANSMIT_OBJECT_SUM_MAX) + { + for (ii = 0u; ii < TRANSMIT_OBJECT_SUM_MAX; ii++) + { + PlatComStatusStru[ii].SystemType = &(ComDevStatusInfo[ii].DeviceTypeOther); + PlatComStatusStru[ii].SystemNum = &(ComDevStatusInfo[ii].ComDevSum); + for (jj = 0u; jj < TRANSMIT_OBJECT_DEVICE_SUM_MAX; jj++) + { + PlatComStatusStru[ii].SystemIdBuf[jj] = &(ComDevStatusInfo[ii].ComDevIdBuf[jj]); + PlatComStatusStru[ii].CommunicationStatusBuf[jj] = &(ComDevStatusInfo[ii].ComDevIdComStatusBuf[jj]); + } + } + + } + else + { + + } +#endif + +#endif + result = HLHTCiIdMapInitial(); + if (CI_SUCCESS == result) + { + rtn = 1; + } + + return rtn; + +} + +/* +* ȡAxisCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: AxisCIӿڶ +*/ +QueueStruct* Get2oo2AxisToCiDataQueue(void) +{ + return AxisToCiDataQueue; +} + +/* +* ȡƽ̨ͨЭ鵽CIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨ͨЭ鵽CIӿڶ +*/ +QueueStruct* Get2oo2ProtocolToCiDataQueue(void) +{ + + return ProtocolToCiDataQueue; +} + +/* +* ȡƽ̨CIͨЭӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIͨЭӿڶ +*/ +QueueStruct* Get2oo2CiToProtocolDataQueue(void) +{ + + return CiToProtocolDataQueue; +} + +/* +* ȡƽ̨FsfbCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIFsfbӿڶ +*/ +QueueStruct* Get2oo2FsfbToCiDataQueue(void) +{ + + return FsfbToCiDataQueue; +} + +/* +* ȡƽ̨CIFsfbPӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIFsfbӿڶ +*/ +QueueStruct* Get2oo2CiToFsfbDataQueue(void) +{ + + return CiToFsfbDataQueue; +} + + + +/* +* ȡƽ̨ATSCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨ATSCIӿڶ +*/ +QueueStruct* Get2oo2AtsToCiDataQueue(void) +{ + + return AtsToCiDataQueue; +} + + +/* +* ȡƽ̨CIֵؽӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIֵؽӿڶ +*/ +QueueStruct* Get2oo2CiToXianDiDataQueue(void) +{ + return CiToXianDiDataQueue; +} + +/* +* ȡƽֵ̨صCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽֵ̨صCIӿڶ +*/ +QueueStruct* Get2oo2XianDiToCiDataQueue(void) +{ + + return XianDiToCiDataQueue; +} + + +/* +* ȡƽ̨CIATSӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIATSӿڶ +*/ +QueueStruct* Get2oo2CiToAtsDataQueue(void) +{ + return CiToAtsDataQueue; +} + + +/* +* ȡZCCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ZCCIӿڶ +*/ +QueueStruct* Get2oo2ZcToCiDataQueue(void) +{ + return ZcToCiDataQueue; +} + + +/* +* ȡCIZCӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIZCӿڶ +*/ +QueueStruct* Get2oo2CiToZcDataQueue(void) +{ + return CiToZcDataQueue; +} + + + +/* +* ȡƽ̨CICIսӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CICIӿڶ +*/ +QueueStruct* Get2oo2CiRecvCiDataQueue(void) +{ + return CiRecvFromCiDataQueue; +} + + +/* +* ȡCI͵CIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CICIӿڶ +*/ +QueueStruct* Get2oo2CiSendCiDataQueue(void) +{ + return CiSendToCiDataQueue; +} + +/* +* ȡƽ̨IOCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨IOCIӿڶ +*/ +QueueStruct* Get2oo2IoToCiDataQueue(void) +{ + return IoToCiDataQueue; +} + + +/* +* ȡƽ̨CIIOӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIIOӿڶ +*/ +QueueStruct* Get2oo2CiToIoDataQueue(void) +{ + return CiToIoDataQueue; +} + +/* +* ȡLeuCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: LeuCIӿڶ +*/ +QueueStruct* Get2oo2LEUToCiDataQueue(void) +{ + return LEUToCiDataQueue; +} + +/* +* ȡCILeuӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CILeuӿڶ +*/ +QueueStruct* Get2oo2CiToLEUDataQueue(void) +{ + return CiToLEUDataQueue; +} + +/* +* ȡCIVobcӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIVobcӿڶ +*/ +QueueStruct* Get2oo2VobcToCiDataQueue(void) +{ + return VobcToCiDataQueue; +} + +/* +* ȡCIVobcӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIVobcӿڶ +*/ +QueueStruct* Get2oo2CiToVobcDataQueue(void) +{ + return CiToVobcDataQueue; +} + + +/* +* ȡCIAxisӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIAxisӿڶ +*/ +QueueStruct* Get2oo2CiToAxisDataQueue(void) +{ + return CiToAxisDataQueue; +} + +/* +* ȡCIOcӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIOcӿڶ +*/ +QueueStruct* Get2oo2CiToOcDataQueue(void) +{ + return CiToOcDataQueue; +} + + +/* +* ȡPSDCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: PSDCIӿڶ +*/ +QueueStruct* Get2oo2PlatformToCiDataQueue(void) +{ + return PlatformToCiDataQueue; +} + +/* +* ȡCIPsdӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIPsdӿڶ +*/ +QueueStruct* Get2oo2CiToPlatformDataQueue(void) +{ + return CiToPlatformDataQueue; +} + +/* +* ȡPscCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: PscCIӿڶ +*/ +QueueStruct* Get2oo2PscToCiDataQueue(void) +{ + return PscToCiDataQueue; +} + +/* +* ȡCIPscӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIPscӿڶ +*/ +QueueStruct* Get2oo2CiToPscDataQueue(void) +{ + return CiToPscDataQueue; +} + +/* +* ȡƽ̨ں +* ˵ void +* ֵ 0: ȡʧ +* >0: ƽ̨ں +*/ +UINT32 Get2oo2CurCycleNum(void) +{ +#if (kPLATFORM==kVXWORKS) + return MSCP_GetSysCount(); +#else + return *CurCycleNum; +#endif + +} + + +/* +* ȡƽ̨ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ƽ̨ID +*/ +UINT8 Get2oo2ComputerId(void) +{ +#if (kPLATFORM==kVXWORKS) + return MSCP_GetBoardID(); +#else + return *PlatComputerId; +#endif + + +} + + +/* +* ȡƽ̨ģʽ +* ˵ void +* ֵ 0: ȡʧ +* >0: ƽ̨ģʽ +*/ +UINT8 Get2oo2ProcessMode(void) +{ +#if (kPLATFORM==kVXWORKS) + UINT8 rtn = 0u; + UINT8 cutSysState = 0U; + ENUM_2x2_STATE_T state = ENUM_2x2_SHUTDOWN; + state = MSCP_GetLastLocal2x2State(); + cutSysState = MSCP_2x2_GetSwitchFlag(); + if (ENUM_2x2_MASTER == state) + { + rtn = 0xA0; + } + else if ((ENUM_2x2_SLAVE == state)||(1==cutSysState)) + { + rtn = 0x50; + } + else + { + rtn = 0U; + } + + debug_infor_printf((const)"MSCP_GetLastLocal2x2State %x", state); + return rtn; +#else + + return *PlatRunMode; +#endif +} + +/* +* ȡƽ̨ģʽ +* ˵ void +* ֵ 0: ȡʧ +* >0: ƽ̨ģʽ +*/ +UINT8 Get2oo2OhterProcessMode(void) +{ + UINT8 rtn = 0u; +#if (kPLATFORM==kVXWORKS) + + UINT8 cutSysState = 0U; + ENUM_2x2_STATE_T state = ENUM_2x2_SHUTDOWN; + state = MSCP_GetLastPartner2x2State(); + cutSysState = MSCP_2x2_GetSwitchFlag(); + if (ENUM_2x2_MASTER == state) + { + rtn = 0x0A; + } + else if ((ENUM_2x2_SLAVE == state) || (1 == cutSysState)) + { + rtn = 0x05; + } + else + { + rtn = 0U; + } + debug_infor_printf((const)"MSCP_GetLastPartner2x2State %x", state); + return rtn; +#else + + return rtn; +#endif +} +/* +* ȡCI豸ͨŵĸ豸 +* ˵ const UINT8 systemType, ϵͳ +* ֵ ͨ豸Ŀ +*/ +UINT8 Get2oo2CiAndOtherSysCommNum(const UINT8 systemType) +{ + UINT8 ii = 0u; + UINT8 returnValue = 0u; + + for (ii = 0u; ii < TRANSMIT_OBJECT_SUM_MAX; ii++) + { + if (TransmitRelaDataStru[ii].SystemType == systemType) + { + returnValue = TransmitRelaDataStru[ii].DeviceSum; + + break; + } + } + + return returnValue; +} + + + +/* +* ȡCIIOͨ״̬ +* ˵ void +* ֵ +*/ +UINT8 Get2oo2CiAndIoCommState(void) +{ + return *CiAndIoComState; +} + +/* +* ȡʼں +* ˵ void +* ֵ +*/ +UINT32 Get2oo2StartCycleNum(void) +{ + return StartCycleNum; +} + +/* +* ȡƽ̨豸 +* ˵ void +* ֵ +*/ +UINT8 Get2oo2SheBeiType(void) +{ +#ifdef PLATFORM_2OO2 + + return gSheBeiType; + +#endif + + +} + + +#if (kPLATFORM==kVXWORKS) +/*ά־ӡ-ַ*/ +void debug_infor_printf(char* debug_string, ...) +{ + UINT32 wdataLength = 0U; + va_list argList; + CM_CHAR msgBuf[1024 + 256]; + va_start(argList, debug_string); + (void)vsnprintf(msgBuf, sizeof(msgBuf), debug_string, argList); + va_end(argList); + + wdataLength = (UINT32)strlen(msgBuf); + msgBuf[wdataLength] = '\n'; + /*־䵽*/ + (void)QueueWrite((wdataLength+ (UINT32)1u), (UINT8*)msgBuf, &logPrintfQue); +} + +/*ά־ӡ-ֽ*/ +void debug_out_array(UINT8 mode, UINT8* debug_array, UINT16 len) +{ + UINT16 i = 0U; + UINT16 indexChar = 0U; + CM_CHAR msgBuf[UDPSEND_BUF_MAX * 3U] = { '\0' }; + CM_CHAR byteTochar[6] = { '\0' }; + UINT16 wdataLength = 0U; + /*һ8ֽתΪ2ַֽ鲻ֵܳ*/ + if ((NULL != debug_array) && (UDPSEND_BUF_MAX > len)) + { + if (0xAA == mode) + { +#if 0 + for (i = 0U; i < len; i++) + { + /*ֽ(16)תΪַ飬ٴ*/ + /*ֽڲλ'0'*/ + if (i == len - 1) + { + indexChar += sprintf(msgBuf + indexChar, "%02x", debug_array[i]); + } + else + { + indexChar += sprintf(msgBuf + indexChar, "%02x-", debug_array[i]); + } + } + wdataLength = (UINT16)strlen(msgBuf); + +#endif + /*####+2ֽڳȣʶ####Ȼ*/ + byteTochar[0] = '#'; + byteTochar[1] = '#'; + byteTochar[2] = '#'; + byteTochar[3] = '#'; + ShortToChar(len, &byteTochar[4]); + (void)QueueWrite(6, (UINT8*)byteTochar, &logPrintfQue); + (void)QueueWrite(len, (UINT8*)debug_array, &logPrintfQue); + } + else + { + ; /**/ + } + + } + else + { + ; /**/ + } +} + +void DarkInfoPack(UINT16 mode, UINT8* debug_array, UINT16 len) +{ + if (NULL != debug_array) + { + MSCP_PFM_LOG_DARK(0x55, mode, len, debug_array); + } + else + { + ; /**/ + } +} +#endif + +/**/ +UINT8 OutnetSafeRecv(UINT16* srcTypeId, UINT16* srcLogicId, UINT8* data, UINT32* dataLen, UINT32 dataMaxLen) +{ + UINT8 rtn = 0u; /*ֵ*/ + + UINT8 lifeTime = 0u; /*ʱ*/ + + rtn = MSCP_AppRecvMsg(ENUM_MSG_OUTNET_SAFE, srcTypeId, srcLogicId, &lifeTime, data, dataLen, dataMaxLen); + + return rtn; +} + +/*ȫ*/ +UINT8 InnetSafeRecv(UINT16* srcTypeId, UINT16* srcLogicId, UINT8* data, UINT32* dataLen, UINT32 dataMaxLen) +{ + UINT8 rtn = 0u; /*ֵ*/ + + UINT8 lifeTime = 0u; /*ʱ*/ + + rtn = MSCP_AppRecvMsg(ENUM_MSG_INNET_MAINTENANCE, srcTypeId, srcLogicId, &lifeTime, data, dataLen, dataMaxLen); + + return rtn; +} + + +/**/ +UINT8 OutnetSafeSend(UINT16 dstTypeId, UINT16 dstLogicId, UINT8* data, UINT32 dataLen) +{ + UINT8 rtn = 0u; /*ֵ*/ + + /*ʵ*/ + rtn = MSCP_AppSendMsg(ENUM_MSG_OUTNET_SAFE, dstTypeId, dstLogicId, data, dataLen); + + return rtn; +} + +/*ά*/ +UINT8 InnetSafeSend(UINT16 dstTypeId, UINT16 dstLogicId, UINT8* data, UINT32 dataLen) +{ + UINT8 rtn = 0u; /*ֵ*/ + + /*ʵ*/ + rtn = MSCP_AppSendMsg(ENUM_MSG_INNET_MAINTENANCE, dstTypeId, dstLogicId, data, dataLen); + + return rtn; +} + +UINT32 InnetRawIoRecv(UINT8* data, UINT32 dataMaxLen) +{ + UINT32 dataLen = 0u; /*ֵ*/ + +#if (kPLATFORM==kVXWORKS) + + UINT16 srcTypeId = 0u; /*ԴID*/ + + dataLen = MSCP_InnetRaw_AppRecv(1, &srcTypeId, data, dataMaxLen); +#else + QueueStruct* rawDataQueue = Get2oo2IoToCiDataQueue(); + + UINT32 dataQueueTotalLen = 0; /*ܳ*/ + + if (rawDataQueue != NULL) + { + /*ȡܳ*/ + dataQueueTotalLen = QueueStatus(rawDataQueue); + + if (dataQueueTotalLen >= dataMaxLen) + {/*IO >= IOЧʱ:ȡIOЧ*/ + + /*Ӷж*/ + dataQueueTotalLen = dataMaxLen; + (void)QueueRead(dataQueueTotalLen, data, rawDataQueue); + + } + else if(0U < dataQueueTotalLen) + {/*0 < dataQueueTotalLen < maxIoDataLen*/ + + /*Ӷж*/ + (void)QueueRead((UINT16)dataQueueTotalLen, data, rawDataQueue); + } + else + {/*dataQueueTotalLen == 0*/ + } +#if 0 + /*IOCI֡*/ + ParseIoToCiDataFrame(tempDataBuf, (UINT16)dataQueueTotalLen); +#endif + /*ȡܳ*/ + dataQueueTotalLen = QueueStatus(rawDataQueue); + + if (0U < dataQueueTotalLen) + { + (void)QueueClear(rawDataQueue); /**/ + + dataLen = CI_ERROR; + } + else + { + dataLen = CI_SUCCESS; + } + } +#endif + return dataLen; +} + +UINT8 InnetRawIoSend(UINT8* data, UINT32 dataLen) +{ + UINT8 rtn = 0u; /*ֵ*/ +#if (kPLATFORM==kVXWORKS) + rtn = MSCP_InnetRaw_AppSend(1, 0x0901, data, dataLen); +#else + QueueStruct* rawDataQueueToSend = Get2oo2CiToIoDataQueue();/*ݵĶ*/ + if (rawDataQueueToSend != NULL) + { + (void)QueueClear(rawDataQueueToSend); /**/ + + if (0U == QueueWrite(dataLen, data, rawDataQueueToSend)) + { /*дʧ*/ + + (void)QueueClear(rawDataQueueToSend); /**/ + + debug_infor_printf((const)"Error: write rawDataQueueToSend fail, QueueWrite = 0"); + + rtn = CI_ERROR; + } + else + { + ; + } + } + else + { + ; /**/ + } +#endif + return rtn; +} + +UINT32 InnetRawLeuRecv(UINT16* srcTypeId, UINT8* data, UINT32 dataMaxLen) +{ + UINT32 dataLen = 0u; /*ֵ*/ +#if (kPLATFORM==kVXWORKS) + dataLen = MSCP_InnetRaw_AppRecv(2, srcTypeId, data, dataMaxLen); +#else + +#endif + return dataLen; +} + +UINT8 InnetRawLeuSend(UINT16 dstTypeId, UINT8* data, UINT32 dataLen) +{ + UINT8 rtn = 0u; /*ֵ*/ +#if (kPLATFORM==kVXWORKS) + rtn = MSCP_InnetRaw_AppSend(2, dstTypeId, data, dataLen); +#else + +#endif + return rtn; +} + + +/* +* ƽ̨֡ +* ˵ OUT UINT8* CC1_data CC1 +* OUT UINT8* CC2_data CC2 +* OUT UINT8* SEB1_data SEB1 +* OUT UINT8* SEB2_data SEB2 +* OUT UINT8* CC1_commFFlag CC1ݱ־ +* OUT UINT8* CC2_commFFlag CC2ݱ־ +* OUT UINT8* SEB1_commFFlag SEB1ݱ־ +* OUT UINT8* SEB2_commFFlag SEB2ݱ־ +* ֵ +* BY LC +*/ +void InnetHeartFrameRecv(OUT UINT8* CC1_data, OUT UINT8* CC2_data, OUT UINT8* SEB1_data, OUT UINT8* SEB2_data, OUT UINT8* CC1_commFFlag, OUT UINT8* CC2_commFFlag, OUT UINT8* SEB1_commFFlag, OUT UINT8* SEB2_commFFlag) +{ + UINT32 remainCount = UINT32_MAX; + UINT8 count = 0U; + UINT8 tmpDataBuff[HEART_FRAME_MAX_LENGTH] = { 0U }; + UINT8 rtnDataBuff_CCA[HEART_FRAME_MAX_LENGTH] = { 0U }; + UINT8 rtnDataBuff_CCB[HEART_FRAME_MAX_LENGTH] = { 0U }; + UINT8 rtnDataBuff_SEBA[HEART_FRAME_MAX_LENGTH] = { 0U }; + UINT8 rtnDataBuff_SEBB[HEART_FRAME_MAX_LENGTH] = { 0U }; + UINT32 cycNew_CCA = 0U; + UINT32 cycNew_CCB = 0U; + UINT32 cycNew_SEBA = 0U; + UINT32 cycNew_SEBB = 0U; + UINT32 tmpCyc = 0U; + + while (0U != remainCount) + { + /**/ + (void)CommonMemSet(&tmpDataBuff, HEART_FRAME_MAX_LENGTH, 0U, HEART_FRAME_MAX_LENGTH); + +#if (kPLATFORM == kVXWORKS) + + remainCount = MSCP_OutNetHeart_AppRecv(OUT &tmpDataBuff, HEART_FRAME_MAX_LENGTH); + debug_infor_printf((const)"\nBoard ID: %d, Printf Heart DataBuff from [MSCP_OutNetHeart_AppRecv], remainCount = %d", tmpDataBuff[2], remainCount); + debug_out_array(0xAA, tmpDataBuff, HEART_FRAME_REAL_LENGTH); +#endif + + + if (0U != tmpDataBuff[2]) + { + count++; + + /*CC1*/ + if (BOARD_TYPE_CCUA == tmpDataBuff[2]) + { + tmpCyc = LongFromChar(&tmpDataBuff[3]); /*ȡ֡ں*/ + if (tmpCyc > cycNew_CCA) + { + cycNew_CCA = tmpCyc; + (void)CommonMemCpy((void*)&rtnDataBuff_CCA, HEART_FRAME_MAX_LENGTH, (const void*)&tmpDataBuff, HEART_FRAME_MAX_LENGTH); + + } + *CC1_commFFlag = CI_SUCCESS; + } + /*CC2*/ + else if (BOARD_TYPE_CCUB == tmpDataBuff[2]) + { + tmpCyc = LongFromChar(&tmpDataBuff[3]); /*ȡ֡ں*/ + if (tmpCyc > cycNew_CCB) + { + cycNew_CCB = tmpCyc; + (void)CommonMemCpy((void*)&rtnDataBuff_CCB, HEART_FRAME_MAX_LENGTH, (const void*)&tmpDataBuff, HEART_FRAME_MAX_LENGTH); + } + *CC2_commFFlag = CI_SUCCESS; + } + /*SEB1*/ + else if (BOARD_TYPE_SEBA == tmpDataBuff[2]) + { + tmpCyc = LongFromChar(&tmpDataBuff[3]); /*ȡ֡ں*/ + if (tmpCyc > cycNew_SEBA) + { + cycNew_SEBA = tmpCyc; + (void)CommonMemCpy((void*)&rtnDataBuff_SEBA, HEART_FRAME_MAX_LENGTH, (const void*)&tmpDataBuff, HEART_FRAME_MAX_LENGTH); + } + *SEB1_commFFlag = CI_SUCCESS; + } + /*SEB2*/ + else if (BOARD_TYPE_SEBB == tmpDataBuff[2]) + { + tmpCyc = LongFromChar(&tmpDataBuff[3]); /*ȡ֡ں*/ + if (tmpCyc > cycNew_SEBB) + { + cycNew_SEBB = tmpCyc; + (void)CommonMemCpy((void*)&rtnDataBuff_SEBB, HEART_FRAME_MAX_LENGTH, (const void*)&tmpDataBuff, HEART_FRAME_MAX_LENGTH); + } + *SEB2_commFFlag = CI_SUCCESS; + } + else + { + /*Դ忨Ƿ*/ + } + + /*ѽֵܵ ˳ѭ*/ + if (HEART_FRAME_MAX_SUM == count) + { + remainCount = 0U; + } + } + else + { + remainCount = 0U; + } + } + + (void)CommonMemCpy((void*)CC1_data, HEART_FRAME_MAX_LENGTH, (const void*)&rtnDataBuff_CCA, HEART_FRAME_MAX_LENGTH); + (void)CommonMemCpy((void*)CC2_data, HEART_FRAME_MAX_LENGTH, (const void*)&rtnDataBuff_CCB, HEART_FRAME_MAX_LENGTH); + (void)CommonMemCpy((void*)SEB1_data, HEART_FRAME_MAX_LENGTH, (const void*)&rtnDataBuff_SEBA, HEART_FRAME_MAX_LENGTH); + (void)CommonMemCpy((void*)SEB2_data, HEART_FRAME_MAX_LENGTH, (const void*)&rtnDataBuff_SEBB, HEART_FRAME_MAX_LENGTH); + +} + + +/* +* ȡϵյϵIO״̬ +* ˵UINT8* ioData ȡIO +* ֵ CI_SUCCESS ȡɹ +* CI_ERROR ȡʧ +* BY LC +*/ +UINT8 InnetChannelIODataRecv(UINT8* ioData) +{ + UINT8 retVal = CI_ERROR; + UINT8 ioRecvFlag = 0U; + UINT8 recvIOData[IO_DATA_LENGTH] = { 0U };/*յ40ֽGPIOݣ50ֽڴ*/ + UINT8 paraseIOData[IO_DATA_DATA_LENGTH] = { 0U };/*ʵΪ4PU4״̬ 16ֽ*/ + +#if (kPLATFORM == kVXWORKS) + if (NULL != ioData) + { + /*ȡϵPUյIO*/ + ioRecvFlag = MSCP_2x2_GetLastIoInput(recvIOData, (UINT16)IO_DATA_LENGTH); + if (0x55U == ioRecvFlag) + { + debug_infor_printf((const)"\nRECV IOData:"); + debug_out_array(0xAA, recvIOData, (UINT16)IO_DATA_LENGTH); + (void)CommonMemCpy(¶seIOData[0], 4U, &recvIOData[0], 4U);/*PU1*/ + (void)CommonMemCpy(¶seIOData[4], 4U, &recvIOData[10], 4U);/*PU2*/ + (void)CommonMemCpy(¶seIOData[8], 4U, &recvIOData[20], 4U);/*PU3*/ + (void)CommonMemCpy(¶seIOData[12], 4U, &recvIOData[30], 4U);/*PU4*/ + debug_infor_printf((const)"\nPUA IOData:%d-%d-%d-%d %d-%d-%d-%d", paraseIOData[0], paraseIOData[1], paraseIOData[2], paraseIOData[3], paraseIOData[4], paraseIOData[5], paraseIOData[6], paraseIOData[7]); + debug_infor_printf((const)"\nPUB IOData:%d-%d-%d-%d %d-%d-%d-%d", paraseIOData[8], paraseIOData[9], paraseIOData[10], paraseIOData[11], paraseIOData[12], paraseIOData[13], paraseIOData[14], paraseIOData[15]); + retVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + } + + if (CI_SUCCESS == retVal) + { + (void)CommonMemCpy(ioData, IO_DATA_DATA_LENGTH, paraseIOData, IO_DATA_DATA_LENGTH); + } + else + { + /*ʧ*/ + } +#endif + + return retVal; +} + + + + + +/* +* еݴȥ +* ˵ UINT8* thisString, +* ֵ 0: ӡʧ +* 1: ӡɹ +*/ +void SendOut_LogBuff() +{ +#if (kPLATFORM==kVXWORKS) + + UINT16 ii = 0U; + UINT16 subPackLength = 0U; /*ÿְݳ*/ + UINT8 pData[UDPSEND_BUF_MAX + 1] = { 0U }; + UINT16 wCount = 0U; /**/ + UINT16 wTotalNum = 0U; /*ܰ*/ + UINT16 wLastLength = 0U; + UINT16 wNowNum = 1U; /*ǰ*/ + UINT32 dataLength = 0U; /*־ܳ*/ + UINT8 retval = CI_ERROR; + UINT32 wCycleNum = 0U; + UINT32 wCRCCheck = 0U; + UINT32 curCycNum = 0U; + + curCycNum = Get2oo2CurCycleNum(); + subPackLength = GetLogSubPackDataLength(); + + /****贫־С******/ + wCycleNum = Get2oo2CurCycleNum(); + dataLength = QueueStatus(&logPrintfQue) + PACK_LOG_ALARM_LENGTH; /*־г+ӡķְ¼*/ + wCount = (UINT16)(dataLength / (subPackLength - 13U)); /* ÿ13ֽ ͷCRC 9+4*/ + wLastLength = (UINT16)(dataLength % (subPackLength - 13U)); /* */ + if (0U == wLastLength) + { + wTotalNum = wCount; + } + else + { + wTotalNum = wCount + 1U; + } + + debug_infor_printf((const)"\nSystemCycleNum:%10d,Pack %2d Frame Log,Full Pack Length Is %4d,Last Pack Length Is %4d", wCycleNum, wTotalNum, subPackLength, wLastLength); + + /*־ֳɹ涨һ*/ + for (ii = 0U; ii < wCount; ii++) + { + (void)CommonMemSet(pData, (UINT32)sizeof(pData), 0u, (UINT32)sizeof(pData)); /*pData*/ + + LongToChar(wCycleNum, &pData[0]); /*ں 4ֽ*/ + + pData[4] = 0x10; /**/ + + pData[5] = (UINT8)wTotalNum; /*ܰ*/ + + pData[6] = (UINT8)wNowNum++; /**/ + + ShortToChar(subPackLength - 13U, &pData[7]); /*ݳ 2ֽ*/ + + retval = QueueRead(subPackLength - 13U, &pData[9], &logPrintfQue); /**/ + + wCRCCheck = Tioc_CommonCrc32(&pData[0], (UINT32)((UINT32)subPackLength - 4U)); + + LongToChar(wCRCCheck, &pData[subPackLength - 4U]); /*CRC 4ֽ*/ + + if (CI_SUCCESS == retval) + { + /*ͷְ*/ + MSCP_LogBin(pData, subPackLength); + } + } + /**/ + wLastLength = (UINT16)QueueStatus(&logPrintfQue); + (void)CommonMemSet(pData, (UINT32)sizeof(pData), 0u, (UINT32)sizeof(pData)); /*pData*/ + + LongToChar(wCycleNum, &pData[0]); /*ں 4ֽ*/ + + pData[4] = 0x10; /**/ + + pData[5] = (UINT8)wTotalNum; /*ܰ*/ + + pData[6] = (UINT8)wNowNum++; /**/ + + ShortToChar((UINT16)dataLength, &pData[7]); /*ݳ 2ֽ*/ + + retval = QueueRead(wLastLength, &pData[9], &logPrintfQue); /**/ + + wCRCCheck = Tioc_CommonCrc32(&pData[0], (UINT32)((UINT32)wLastLength + 9U));/*CRCУ*/ + + LongToChar(wCRCCheck, &pData[wLastLength +9U]); /*CRC 4ֽ*/ + + if (CI_SUCCESS == retval) + { + /*ͷְ*/ + MSCP_LogBin(pData, wLastLength+13U); + + } + +#endif + /*ɺն*/ + (void)QueueClear(&logPrintfQue); +} + + diff --git a/TSCP/src/APP/ciapp/2oo2/2oo2InterfaceDataManage.h b/TSCP/src/APP/ciapp/2oo2/2oo2InterfaceDataManage.h new file mode 100644 index 0000000..0542b2b --- /dev/null +++ b/TSCP/src/APP/ciapp/2oo2/2oo2InterfaceDataManage.h @@ -0,0 +1,416 @@ +/******************************************************** +* +* 2oo2InterfaceDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-26 +* ߣ +* ȫӿݹ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _2OO2_INTERFACE_DATA_MANAGE_H_ +#define _2OO2_INTERFACE_DATA_MANAGE_H_ + + +#include "../System/SystemConfigDefine.h" +#include "../System/CiSystemDefine.h" +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "../Transmit/TransmitStateDataManage.h" + +#ifdef PLATFORM_2OO2 +#include "sfpplatform.h" +#include "RsspWl.h" +#include "FsfbProtcl.h" +#endif + + + + + +/*ϵȡFSIO*/ +#define START_GET_FSIO_CYCLE_NUM ((UINT16)20) /*ϵȡFSIO*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/*ƽ̨ͨ״̬ṹ*/ +typedef struct S_PlatComStatusStruct +{ + UINT8* SystemType; /*ͨŵϵͳ豸*/ + UINT8* SystemNum; /*ͨŵϵͳ豸*/ + UINT8* SystemIdBuf[TRANSMIT_OBJECT_DEVICE_SUM_MAX]; /*ͨŵϵͳ豸ID*/ + UINT8* CommunicationStatusBuf[TRANSMIT_OBJECT_DEVICE_SUM_MAX]; /*ͨ״̬ IDӦ*/ +} PlatComStatusStruct; + +/*ȫֱ*/ +extern PlatComStatusStruct PlatComStatusStru[TRANSMIT_OBJECT_SUM_MAX]; /*ƽ̨ͨŹϵݽṹ*/ +extern QueueStruct* FsfbToCiDataQueue; /*FsfbCIݶ*/ +extern QueueStruct* CiToFsfbDataQueue; /*CIFsfbݶ*/ +extern QueueStruct* ProtocolToCiDataQueue; /*Э鵽Ӧõݶ*/ +extern QueueStruct* CiToProtocolDataQueue; /*CIЭݶ*/ +extern QueueStruct* AtsToCiDataQueue; /*ATSCIݶ*/ +extern QueueStruct* CiToAtsDataQueue; /*CIATSݶ*/ +extern QueueStruct* XianDiToCiDataQueue; /*ֵصCIݶ*/ +extern QueueStruct* CiToXianDiDataQueue; /*CIֵݶ*/ +extern QueueStruct* IoToCiDataQueue; /*IOCIݶ*/ +extern QueueStruct* CiToIoDataQueue; /*CIIOݶ*/ +extern QueueStruct* ZcToCiDataQueue; /*ZCCIݶ*/ +extern QueueStruct* CiToZcDataQueue; /*CIZcݶ*/ +extern QueueStruct* LEUToCiDataQueue; /*LEUCIݶ*/ +extern QueueStruct* CiToLEUDataQueue; /*CILEUݶ*/ +extern QueueStruct* VobcToCiDataQueue; /*VobcCIݶ*/ +extern QueueStruct* CiToVobcDataQueue; /*CIVobcݶ*/ +extern QueueStruct* PlatformToCiDataQueue; /*PlatformCIݶ*/ +extern QueueStruct* CiToPlatformDataQueue; /*CIplatformݶ*/ +extern QueueStruct* PscToCiDataQueue; /*PscCIݶ*/ +extern QueueStruct* CiToPscDataQueue; /*CIPscݶ*/ +extern QueueStruct* CiRecvFromCiDataQueue; /*CICIݶ*/ +extern QueueStruct* CiSendToCiDataQueue; /*CI͵CIݶ*/ + +extern QueueStruct* AxisToCiDataQueue; /*AxisCIݶ*/ +extern QueueStruct* CiToAxisDataQueue; /*CIAxisݶ*/ +extern QueueStruct* OcToCiDataQueue; /*OcCiݶ*/ +extern QueueStruct* CiToOcDataQueue; /*CiOcݶ*/ + +extern UINT32* CurCycleNum; /*ǰں*/ +extern UINT32 StartCycleNum; /*ϵں*/ +extern UINT8* PlatComputerId; /*ƽ̨ID*/ +extern UINT8* PlatRunMode; /*ƽ̨ģʽ*/ +extern UINT8* CiAndIoComState; /*IOͨ״̬*/ +extern UINT8* CiAndLeuComState; /*LEUͨ״̬*/ +extern UINT8* CiAndZcComState; /*ZCͨ״̬*/ +extern UINT8* CiAndCiComDeviceNum; /**/ +extern UINT8* CiAndCiComIdBuf; /*ͨ豸ID*/ +extern UINT8* CiAndCiComState; /*ͨ״̬*/ +extern UINT8* PlatSheBeiType; /*ƽ̨豸*/ + +/* +* ƽ̨ʼ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨ATSCIӿڶ +*/ +UINT8 Initial2oo2Interface(void); + + +/* +* ȡƽ̨ͨЭ鵽CIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨ͨЭ鵽CIӿڶ +*/ +QueueStruct* Get2oo2ProtocolToCiDataQueue(void); + +/* +* ȡƽ̨CIͨЭӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIͨЭӿڶ +*/ +QueueStruct* Get2oo2CiToProtocolDataQueue(void); + + + +/* +* ȡƽ̨FsfbCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIFsfbӿڶ +*/ +QueueStruct* Get2oo2FsfbToCiDataQueue(void); + +/* +* ȡƽ̨CIFsfbPӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIFsfbӿڶ +*/ +QueueStruct* Get2oo2CiToFsfbDataQueue(void); + + + +/* +* ȡƽ̨ATSCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨ATSCIӿڶ +*/ +QueueStruct* Get2oo2AtsToCiDataQueue(void); + +/* +* ȡƽ̨CIATSӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIATSӿڶ +*/ +QueueStruct* Get2oo2CiToAtsDataQueue(void); + +/* +* ȡƽ̨CIֵؽӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIֵؽӿڶ +*/ +QueueStruct* Get2oo2CiToXianDiDataQueue(void); + +/* +* ȡƽֵ̨صCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽֵ̨صCIӿڶ +*/ +QueueStruct* Get2oo2XianDiToCiDataQueue(void); + +/* +* ȡZCCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ZCCIӿڶ +*/ +QueueStruct* Get2oo2ZcToCiDataQueue(void); + +/* +* ȡCIZCӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIZCӿڶ +*/ +QueueStruct* Get2oo2CiToZcDataQueue(void); + +/* +* ȡƽ̨CICIսӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CICIӿڶ +*/ +QueueStruct* Get2oo2CiRecvCiDataQueue(void); + +/* +* ȡCI͵CIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CICIӿڶ +*/ +QueueStruct* Get2oo2CiSendCiDataQueue(void); + +/* +* ȡƽ̨IOCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨IOCIӿڶ +*/ +QueueStruct* Get2oo2IoToCiDataQueue(void); + +/* +* ȡƽ̨CIIOӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ƽ̨CIIOӿڶ +*/ +QueueStruct* Get2oo2CiToIoDataQueue(void); + +/* +* ȡLeuCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: LeuCIӿڶ +*/ +QueueStruct* Get2oo2LEUToCiDataQueue(void); + +/* +* ȡCILeuӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CILeuӿڶ +*/ +QueueStruct* Get2oo2CiToLEUDataQueue(void); + +/* +* ȡCIVobcӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIVobcӿڶ +*/ +QueueStruct* Get2oo2VobcToCiDataQueue(void); + +/* +* ȡCIVobcӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIVobcӿڶ +*/ +QueueStruct* Get2oo2CiToVobcDataQueue(void); + +/* +* ȡCIOcӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIOcӿڶ +*/ +QueueStruct* Get2oo2CiToOcDataQueue(void); + +/* +* ȡPSDCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: PSDCIӿڶ +*/ +QueueStruct* Get2oo2PlatformToCiDataQueue(void); + +/* +* ȡCIPsdӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIPsdӿڶ +*/ +QueueStruct* Get2oo2CiToPlatformDataQueue(void); + + +/* +* ȡPscCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: PscCIӿڶ +*/ +QueueStruct* Get2oo2PscToCiDataQueue(void); + +/* +* ȡCIPscӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIPscӿڶ +*/ +QueueStruct* Get2oo2CiToPscDataQueue(void); + +/* +* ȡƽ̨ں +* ˵ void +* ֵ 0: ȡʧ +* >0: ƽ̨ں +*/ +UINT32 Get2oo2CurCycleNum(void); + +/* +* ȡƽ̨ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ƽ̨ID +*/ + + +UINT8 Get2oo2ComputerId(void); + +/* +* ȡƽ̨ģʽ +* ˵ void +* ֵ 0: ȡʧ +* >0: ƽ̨ģʽ +*/ +UINT8 Get2oo2ProcessMode(void); + +/* +* ȡƽ̨ģʽ +* ˵ void +* ֵ 0: ȡʧ +* >0: ƽ̨ģʽ +*/ +UINT8 Get2oo2OhterProcessMode(void); + +/* +* ȡCI豸ͨŵĸ豸 +* ˵ const UINT8 systemType, ϵͳ +* ֵ ͨ豸Ŀ +*/ +UINT8 Get2oo2CiAndOtherSysCommNum(const UINT8 systemType); + + + +/* +* ȡCIIOͨ״̬ +* ˵ void +* ֵ +*/ +UINT8 Get2oo2CiAndIoCommState(void); + +/* +* ȡʼں +* ˵ void +* ֵ +*/ +UINT32 Get2oo2StartCycleNum(void); + +/* +* ȡƽ̨豸 +* ˵ void +* ֵ +*/ +UINT8 Get2oo2SheBeiType(void); + + +/* +* ȡAxisCIӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: AxisCIӿڶ +*/ +QueueStruct* Get2oo2AxisToCiDataQueue(void); + + +/* +* ȡCIAxisӿڶ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIAxisӿڶ +*/ +QueueStruct* Get2oo2CiToAxisDataQueue(void); + + + +/* +* еݴȥ +* ˵ UINT8* thisString, +* ֵ 0: ӡʧ +* 1: ӡɹ +*/ +void SendOut_LogBuff(); + + + + + +void debug_infor_printf(char* debug_string, ...); +void debug_out_array(UINT8 mode, UINT8* debug_array, UINT16 len); + + +UINT8 OutnetSafeRecv(UINT16* srcTypeId, UINT16* srcLogicId, UINT8* data, UINT32* dataLen, UINT32 dataMaxLen); +UINT8 InnetSafeRecv(UINT16* srcTypeId, UINT16* srcLogicId, UINT8* data, UINT32* dataLen, UINT32 dataMaxLen); +UINT8 OutnetSafeSend(UINT16 dstTypeId, UINT16 dstLogicId, UINT8* data, UINT32 dataLen); +UINT8 InnetSafeSend(UINT16 dstTypeId, UINT16 dstLogicId, UINT8* data, UINT32 dataLen); + +UINT32 InnetRawIoRecv(UINT8* data, UINT32 dataMaxLen); +UINT8 InnetRawIoSend(UINT8* data, UINT32 dataLen); +UINT32 InnetRawLeuRecv(UINT16* srcTypeId, UINT8* data, UINT32 dataMaxLen); + +UINT8 InnetRawLeuSend(UINT16 dstTypeId, UINT8* data, UINT32 dataLen); + + +void InnetHeartFrameRecv(OUT UINT8* CC1_data, OUT UINT8* CC2_data, OUT UINT8* SEB1_data, OUT UINT8* SEB2_data, OUT UINT8* CC1_commFFlag, OUT UINT8* CC2_commFFlag, OUT UINT8* SEB1_commFFlag, OUT UINT8* SEB2_commFFlag); + + +UINT8 InnetChannelIODataRecv(UINT8* ioData); +#if (kPLATFORM == kWINDOWS) +#define TMP_BUF_LEN 10000 +static UINT8 gTempDataBuf[TMP_BUF_LEN] = {0}; /*ʱ*/ +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnConfigDataManage.c b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnConfigDataManage.c new file mode 100644 index 0000000..5b55c93 --- /dev/null +++ b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnConfigDataManage.c @@ -0,0 +1,385 @@ +/******************************************************** +* +* AllAutoReturnConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-10-11 +* ߣ +* ȫԶ۷ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "../AllAutoReturn/AllAutoReturnConfigDataManage.h" + + + + +AllAutoReturnConfigDataStruct AllAutoReturnConfigDataStru[ALL_AUTO_RETURN_SUM_MAX]; /*ȫԶ۷ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiAllAutoReturnIdBuf[ALL_AUTO_RETURN_SUM_MAX] = {0u}; /*屾ȫԶ۷·IDӳ*/ +INT16 AllAutoReturnCurSum = 0; /*ȫԶ۷ǰ*/ + +/* +* ȡȫԶ۷·ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ȫԶ۷·ǰ +*/ +UINT16 GetAllAutoReturnRouteCurSum(void) +{ + UINT16 allAutoReturnCurSum = 0u; + + if ((INT16)ALL_AUTO_RETURN_SUM_MAX <= AllAutoReturnCurSum) + { + allAutoReturnCurSum = ALL_AUTO_RETURN_SUM_MAX; + } + else if (0 > AllAutoReturnCurSum) + { + allAutoReturnCurSum = 0u; + } + else + { + allAutoReturnCurSum = (UINT16)AllAutoReturnCurSum; + } + + return allAutoReturnCurSum; +} + +/* +* ȡָ±ӦȫԶ۷·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ȫԶ۷·ID +*/ +UINT16 GetAllAutoReturnRouteId(const UINT16 bufIndex) +{ + UINT16 localCiAllAutoReturnId = CI_ERROR; + UINT16 routeCurSum = 0u; + routeCurSum = GetAllAutoReturnRouteCurSum(); + + if (bufIndex < routeCurSum) + { + localCiAllAutoReturnId = LocalCiAllAutoReturnIdBuf[bufIndex]; + } + + return localCiAllAutoReturnId; +} + +/* +* ȡָIDȫԶ۷·± +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ȫԶ۷·ID +*/ +UINT16 GetAllAutoReturnBufIndex(const UINT16 allAutoReturnId) +{ + UINT16 index = 0u; + if ((allAutoReturnId >= 1u) && (allAutoReturnId < ALL_AUTO_RETURN_SUM_MAX)) + { + index = allAutoReturnId; + } + else + { + index = ALL_AUTO_RETURN_SUM_MAX; + } + return index; +} + +/* +* ȡָIDȫԶ۷·Ŀ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT8 GetAllAutoReturnIncludeRouteSum(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 routeSum = CI_ERROR; + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡȫԶ۷±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + routeSum = AllAutoReturnConfigDataStru[bufIndex].RouteSum; + } + + return routeSum; +} + +/* +* ȡָIDȫԶ۷ID +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAllAutoReturnRouteBelongCiId(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 belongCiId = CI_ERROR; + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡȫԶ۷±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + belongCiId = AllAutoReturnConfigDataStru[bufIndex].BelongCiId; + } + + return belongCiId; +} + +/* +* ȡָIDȫԶ۷·ID +* ˵ const UINT8 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetAllAutoReturnIncludeRouteBuf(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* routeIdBuf = NULL; + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡȫԶ۷±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + routeIdBuf = AllAutoReturnConfigDataStru[bufIndex].RouteIdBuf; + } + return routeIdBuf; +} + +/* +* ȡָIDȫԶ۷ṹ۳·Id +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetAllAutoReturnRebackRouteBuf(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* rebackRouteIdBuf = NULL; + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡȫԶ۷±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + rebackRouteIdBuf = AllAutoReturnConfigDataStru[bufIndex].RebackRouteIdBuf; + } + + return rebackRouteIdBuf; +} +/* +* ȡָIDȫԶ۷ṹ۳·IdĿ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT8 GetAllAutoReturnRebackRouteSum(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 rebackRouteSum = CI_ERROR; + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡȫԶ۷±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + rebackRouteSum = AllAutoReturnConfigDataStru[bufIndex].RebackRouteSum; + } + + return rebackRouteSum; +} +/* +* ȫԶ۷· +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AllAutoReturnConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 allAutoReturnConfigDataSum = 0u; /*ȫԶ۷·豸*/ + UINT8 returnValue = CI_SUCCESS; + + /*ȫԶ۷·Id*/ + allAutoReturnConfigDataSum = GetAllAutoReturnRouteCurSum(); + if (allAutoReturnConfigDataSum >= ALL_AUTO_RETURN_SUM_MAX) + {/**/ + + returnValue = CI_ERROR; + } + else + { + for (ii = 0u; ii < ALL_AUTO_RETURN_SUM_MAX; ii++) + { + if (jj == allAutoReturnConfigDataSum) + {/*allAutoReturnConfigDataSumΪ0ʾûȫԶ۷·allAutoReturnConfigDataSum0ʾЧ*/ + + break; + } + + if (AllAutoReturnConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + + LocalCiAllAutoReturnIdBuf[jj] = AllAutoReturnConfigDataStru[ii].AllAutoReturnId; + jj++; + } + + } + + } + + return returnValue; +} + +/* +* ȡȫԶ۷·ִԶͨ·Ŀ +* ˵ const UINT16 allAutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAllAutoRtnOppRouteIdSum(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡ±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + returnValue = AllAutoReturnConfigDataStru[bufIndex].AllAutoReturnOpposedRouteIdSum; + } + return returnValue; +} + +/* +* ȡȫԶ۷·ִԶͨ· +* ˵ const UINT16 allAutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAllAutoRtnOppRouteIdBuf(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡ±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + returnValue = AllAutoReturnConfigDataStru[bufIndex].AllAutoReturnOpposedRouteIdBuf; + } + return returnValue; +} + +/* +* ȡȫԶ۷·ִԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAllAutoRtnOppReturnIdSum(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡ±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + returnValue = AllAutoReturnConfigDataStru[bufIndex].AllAutoReturnOpposedReturnIdSum; + } + return returnValue; +} + +/* +* ȡȫԶ۷·ִԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAllAutoRtnOppReturnIdBuf(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡ±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + returnValue = AllAutoReturnConfigDataStru[bufIndex].AllAutoReturnOpposedReturnIdBuf; + } + return returnValue; +} + + +/* +* ȡȫԶ۷·ִȫԶ۷·Ŀ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAllAutoRtnOppAllReturnIdSum(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡ±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + returnValue = AllAutoReturnConfigDataStru[bufIndex].AllAutoReturnOpposedAllRtnIdSum; + } + return returnValue; +} + +/* +* ȡȫԶ۷·ִȫԶ۷· +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAllAutoRtnOppAllRtnIdBuf(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡ±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + returnValue = AllAutoReturnConfigDataStru[bufIndex].AllAutoReturnOpposedAllRtnIdBuf; + } + return returnValue; +} +/* +* ȡȫԶ۷·ִ۳·Ŀ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAllAutoRtnInOppOutIdSum(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡ±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + returnValue = AllAutoReturnConfigDataStru[bufIndex].AllAutoReturnInOpposedOutSum; + } + return returnValue; +} + +/* +* ȡȫԶ۷·ִ۳· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ִ· +*/ +UINT16* GetAllAutoRtnInOppOutIdBuf(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡ±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + returnValue = AllAutoReturnConfigDataStru[bufIndex].AllAutoReturnInOpposedOutBuf; + } + return returnValue; +} diff --git a/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnConfigDataManage.h b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnConfigDataManage.h new file mode 100644 index 0000000..146cffe --- /dev/null +++ b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnConfigDataManage.h @@ -0,0 +1,195 @@ +/******************************************************** +* +* AllAutoReturnConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-10-11 +* ߣ +* ȫԶ۷ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ALLAUTORETURN_CONFIG_DATA_MANAGE_H_ +#define _ALLAUTORETURN_CONFIG_DATA_MANAGE_H_ + + +#include "AllAutoReturnDefine.h" +#include "../Route/RouteDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*ȫԶ۷ݽṹ*/ +typedef struct S_AllAutoReturnConfigDataStruct +{ + UINT16 AllAutoReturnId; /*ȫԶ۷ID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 RouteSum; /*ȫԶ۷·Ŀ (ֶ)*/ + UINT16 RouteIdBuf[ALL_AUTO_RETURN_INCLROUTE_SUM_MAX]; /*ȫԶ۷·ID (ֶ)*/ + UINT16 RebackRouteIdBuf[ALL_AUTO_RETURN_REBACKROUTE_SUM_MAX]; /*ȫԶ۷۳·(ֶ)*/ + UINT8 RebackRouteSum; /*ȫԶ۷۳·(ֶ)*/ + UINT8 AllAutoReturnOpposedReturnIdSum; /*ȫԶ۷ִԶ۷·Ŀ (ֶ)*/ + UINT16 AllAutoReturnOpposedReturnIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*ȫԶ۷ִԶ۷·ID (ֶ)*/ + UINT8 AllAutoReturnOpposedRouteIdSum; /*ȫԶ۷·ִԶ·Ŀ (ֶ)*/ + UINT16 AllAutoReturnOpposedRouteIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*ȫԶ۷·ִԶ·ID (ֶ)*/ + UINT8 AllAutoReturnOpposedAllRtnIdSum; /*ȫԶ۷·ִȫԶ۷·Ŀ (ֶ)*/ + UINT16 AllAutoReturnOpposedAllRtnIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*ȫԶ۷·ִȫԶ۷·ID (ֶ)*/ + UINT16 AllAutoReturnInOpposedOutBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*ȫԶ۷··ִ۳·ID (ֶ)*/ + UINT8 AllAutoReturnInOpposedOutSum; /*ȫԶ۷··ִ۳·IDĿ (ֶ)*/ +} AllAutoReturnConfigDataStruct; + +/*ȫֱ*/ +extern AllAutoReturnConfigDataStruct AllAutoReturnConfigDataStru[ALL_AUTO_RETURN_SUM_MAX]; /*ȫԶ۷ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiAllAutoReturnIdBuf[ALL_AUTO_RETURN_SUM_MAX]; /*屾ȫԶ۷·IDӳ*/ +extern INT16 AllAutoReturnCurSum; /*ȫԶ۷ǰ*/ + +/* +* ȡȫԶ۷·ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ȫԶ۷·ǰ +*/ +UINT16 GetAllAutoReturnRouteCurSum(void); + +/* +* ȡָ±ӦȫԶ۷·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ȫԶ۷·ID +*/ +UINT16 GetAllAutoReturnRouteId(const UINT16 bufIndex); + +/* +* ȡָIDȫԶ۷·± +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ȫԶ۷·ID +*/ +UINT16 GetAllAutoReturnBufIndex(const UINT16 allAutoReturnId); + +/* +* ȡָIDȫԶ۷·Ŀ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT8 GetAllAutoReturnIncludeRouteSum(const UINT16 allAutoReturnId); + +/* +* ȡָIDȫԶ۷ID +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAllAutoReturnRouteBelongCiId(const UINT16 allAutoReturnId); + +/* +* ȡָIDȫԶ۷·ID +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetAllAutoReturnIncludeRouteBuf(const UINT16 allAutoReturnId); + +/* +* ȡָIDȫԶ۷ṹ۳·Id +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetAllAutoReturnRebackRouteBuf(const UINT16 allAutoReturnId); +/* +* ȡָIDȫԶ۷ṹ۳·IdĿ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT8 GetAllAutoReturnRebackRouteSum(const UINT16 allAutoReturnId); + +/* +* ȫԶ۷· +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AllAutoReturnConfigDataManage(void); + +/* +* ȡȫԶ۷·ִԶͨ·Ŀ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAllAutoRtnOppRouteIdSum(const UINT16 allAutoReturnId); + +/* +* ȡȫԶ۷·ִԶͨ· +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAllAutoRtnOppRouteIdBuf(const UINT16 allAutoReturnId); + +/* +* ȡȫԶ۷·ִԶ۷·Ŀ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAllAutoRtnOppReturnIdSum(const UINT16 allAutoReturnId); + +/* +* ȡȫԶ۷·ִԶ۷· +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAllAutoRtnOppReturnIdBuf(const UINT16 allAutoReturnId); + +/* +* ȡȫԶ۷·ִȫԶ۷·Ŀ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAllAutoRtnOppAllReturnIdSum(const UINT16 allAutoReturnId); + +/* +* ȡȫԶ۷·ִȫԶ۷· +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAllAutoRtnOppAllRtnIdBuf(const UINT16 allAutoReturnId); +/* +* ȡȫԶ۷·ִ۳·Ŀ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAllAutoRtnInOppOutIdSum(const UINT16 allAutoReturnId); + +/* +* ȡȫԶ۷·ִ۳· +* ˵ const UINT16 allAutoReturnId, ·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAllAutoRtnInOppOutIdBuf(const UINT16 allAutoReturnId); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDataManage.c b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDataManage.c new file mode 100644 index 0000000..3b78383 --- /dev/null +++ b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDataManage.c @@ -0,0 +1,114 @@ +/******************************************************** +* +* AllAutoReturnDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-10-11 +* ߣ +* ȫԶ۷ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "../AllAutoReturn/AllAutoReturnDataManage.h" + + + + +AllAutoReturnDataStruct AllAutoReturnDataStru[ALL_AUTO_RETURN_SUM_MAX]; /*Զ۷ݽṹ*/ + + +/* +* ȡָIDԶ۷־ +* ˵ const UINT8 allAutoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ־ +*/ +UINT8 GetAllAutoReturnSetFlag(const UINT16 allAutoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 allAutoReturnSetFlag = CI_ERROR; + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡԶ۷±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + allAutoReturnSetFlag = AllAutoReturnDataStru[bufIndex].AllAutoReturnSetFlag; + } + + return allAutoReturnSetFlag; +} + + +/* +* ָIDȫԶ۷־ +* ˵ const UINT8 allAutoReturnId, ȫԶ۷ID +* const UINT8 setState, ־ +* ֵ +* +*/ +void SetAllAutoReturnSetFlag(const UINT16 allAutoReturnId, const UINT8 setState) +{ + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 autoIncludeRouteSum = 0u; + UINT16 *pAutoIncludeRouteIdbuf = NULL; + UINT8 autoSetFlag = CI_ERROR; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetAllAutoReturnBufIndex(allAutoReturnId); /*ȡԶ۷±*/ + + if (bufIndex < ALL_AUTO_RETURN_SUM_MAX) + { + autoIncludeRouteSum = GetAllAutoReturnIncludeRouteSum(allAutoReturnId); + pAutoIncludeRouteIdbuf = GetAllAutoReturnIncludeRouteBuf(allAutoReturnId); + + if (ALL_AUTO_RETURN_SET_YES == setState) + { + autoSetFlag = CI_ERROR; + + /*Զ*/ + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + autoSetFlag = SetRouteAllAutoReturnId(pAutoIncludeRouteIdbuf[ii],allAutoReturnId); + if (autoSetFlag == CI_ERROR) + { + /*ʧ*/ + break; + } + } + + if (autoSetFlag == CI_ERROR) + { + for (jj = 0u; jj < ii; jj++) + { + /*Id*/ + (void)SetRouteAllAutoReturnId(pAutoIncludeRouteIdbuf[jj],0u); + } + + } + else + { + AllAutoReturnDataStru[bufIndex].AllAutoReturnSetFlag = ALL_AUTO_RETURN_SET_YES; + + } + } + else if (ALL_AUTO_RETURN_SET_NO == setState) + { + for (ii = 0; ii < autoIncludeRouteSum; ii++) + { + /*Id*/ + (void)SetRouteAllAutoReturnId(pAutoIncludeRouteIdbuf[ii],0u); + } + + AllAutoReturnDataStru[bufIndex].AllAutoReturnSetFlag = ALL_AUTO_RETURN_SET_NO; + + } + else + { + /**/ + } + } +} + + + diff --git a/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDataManage.h b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDataManage.h new file mode 100644 index 0000000..d5fbbaf --- /dev/null +++ b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDataManage.h @@ -0,0 +1,61 @@ +/******************************************************** +* +* AllAutoReturnDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-10-11 +* ߣ +* ȫԶ۷ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ALLAUTORETURN_DATA_MANAGE_H_ +#define _ALLAUTORETURN_DATA_MANAGE_H_ + +#include "AllAutoReturnDefine.h" +#include "AllAutoReturnConfigDataManage.h" +#include "CommonTypes.h" +#include "../DataManage/DeviceDataManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ȫԶ۷ݽṹ*/ +typedef struct S_AllAutoReturnDataStruct +{ + UINT16 AllAutoReturnId; /*ȫԶ۷ID (ʼֶ)*/ + UINT8 AllAutoReturnSetFlag; /*ȫԶñ־(δ/) (ֶ̬)*/ +} AllAutoReturnDataStruct; + +/*ȫֱ*/ +extern AllAutoReturnDataStruct AllAutoReturnDataStru[ALL_AUTO_RETURN_SUM_MAX]; /*Զ۷ݽṹ*/ + + +/* +* ȡָIDȫԶ۷־ +* ˵ const UINT8 allAutoReturnId, ȫԶ۷ID +* ֵ 0: ȡʧ +* >0: ־ +*/ +UINT8 GetAllAutoReturnSetFlag(const UINT16 allAutoReturnId); + +/* +* ָIDȫԶ۷־ +* ˵ const UINT8 allAutoReturnId, ȫԶ۷ID +* const UINT8 setState, ־ +* ֵ +* +*/ +void SetAllAutoReturnSetFlag(const UINT16 allAutoReturnId, const UINT8 setState); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDefine.h b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDefine.h new file mode 100644 index 0000000..df1a7f4 --- /dev/null +++ b/TSCP/src/APP/ciapp/AllAutoReturn/AllAutoReturnDefine.h @@ -0,0 +1,45 @@ +/******************************************************** +* +* AllAutoReturnDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-10-11 +* ߣ +* ȫԶ۷ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ALLAUTORETURN_CONFIG_H_ +#define _ALLAUTORETURN_CONFIG_H_ + + + + +/*ȫԶ۷ֵ*/ +#define ALL_AUTO_RETURN_SUM_MAX ((UINT16)30) /*ȫԶ۷ֵ*/ + +/*ֵ*/ +#define ALL_AUTO_RETURN_INCLROUTE_SUM_MAX ((UINT16)10) /*ȫԶ۷·ֵ*/ +#define ALL_AUTO_RETURN_REBACKROUTE_SUM_MAX ((UINT16)2) /*ȫԶ۷۳·ֵ*/ + +/*Զ۷·*/ +#define ALL_AUTO_RETURN_ROUTE_TYPE_IN ((UINT8)0x55) /**/ +#define ALL_AUTO_RETURN_ROUTE_TYPE_OUT ((UINT8)0xAA) /*۳*/ + +#define ALL_AUTO_RETURN_ROUTE_TYPE_VAIN ((UINT8)0xFF) /*Ч*/ + + +/*Զ۷־*/ +#define ALL_AUTO_RETURN_SET_NO ((UINT8)0x55) /*δ*/ +#define ALL_AUTO_RETURN_SET_YES ((UINT8)0xaa) /**/ + +#define ALL_AUTO_RETURN_DICHU_AUTOR ((UINT8)0x01) /*ִԶͨ·Ѱ*/ +#define ALL_AUTO_RETURN_DICHU_AUTORETR ((UINT8)0x04) /*ִԶ۷·Ѱ*/ +#define ALL_AUTO_RETURN_DICHU_ALLAUTOR ((UINT8)0x05) /*ִȫԶ۷·Ѱ*/ +#define ALL_AUTO_RETURN_DICHU_COMMR ((UINT8)0x06) /*ִͨ·Ѱ*/ +#define ALL_AUTO_RETURN_HAVE_BLOCK ((UINT8)0x02) /*ȫԶ۷·ڷ*/ +#define ALL_AUTO_RETURN_FLOOD_STATE_ERR ((UINT8)0x03) /*ȫԶ۷·ڷŲ*/ + +#endif diff --git a/TSCP/src/APP/ciapp/AutoReturn/AutoReturnConfigDataManage.c b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnConfigDataManage.c new file mode 100644 index 0000000..488536e --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnConfigDataManage.c @@ -0,0 +1,328 @@ +/******************************************************** +* +* AutoReturnConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* Զ۷ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "../AutoReturn/AutoReturnConfigDataManage.h" + + + + +AutoReturnConfigDataStruct AutoReturnConfigDataStru[AUTO_RETURN_SUM_MAX]; /*Զ۷ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiAutoReturnIdBuf[AUTO_RETURN_SUM_MAX] = {0u}; /*屾Զ۷·IDӳ*/ +INT16 AutoReturnCurSum = 0; /*Զ۷ǰ*/ + + +/* +* ȡԶ۷·ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Զ۷·ǰ +*/ +UINT16 GetAutoReturnRouteCurSum(void) +{ + UINT16 autoReturnCurSum = 0u; + if ((INT16)AUTO_RETURN_SUM_MAX <= AutoReturnCurSum) + { + autoReturnCurSum = AUTO_RETURN_SUM_MAX; + } + else if (0 > AutoReturnCurSum) + { + autoReturnCurSum = 0u; + } + else + { + autoReturnCurSum = (UINT16)AutoReturnCurSum; + } + + return autoReturnCurSum; +} + +/* +* ȡָ±ӦԶ۷·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: Զ۷·ID +*/ +UINT16 GetAutoReturnRouteId(const UINT16 bufIndex) +{ + UINT16 returnValue = CI_ERROR; + if (bufIndex < GetAutoReturnRouteCurSum()) + { + returnValue = LocalCiAutoReturnIdBuf[bufIndex]; + } + + return returnValue; +} + +/* +* ȡָIDԶ۷·± +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: Զ۷·ID +*/ +UINT16 GetAutoReturnBufIndex(const UINT16 autoReturnId) +{ + UINT16 returnValue = AUTO_RETURN_SUM_MAX; + if ((autoReturnId >= 1u) && (autoReturnId < AUTO_RETURN_SUM_MAX)) + { + returnValue = autoReturnId; + } + + return returnValue; +} + +/* +* ȡָIDԶ۷·Ŀ +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT8 GetAutoReturnIncludeRouteSum(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡԶ۷±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].RouteSum; + } + + return returnValue; +} + +/* +* ȡָIDԶ۷ID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAutoReturnRouteBelongCiId(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡԶ۷±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].BelongCiId; + } + + return returnValue; +} + +/* +* ȡָIDԶ۷·ID +* ˵ const UINT8 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetAutoReturnIncludeRouteBuf(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡԶ۷±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].RouteIdBuf; + } + + return returnValue; +} + +/* +* ȡָIDԶ۷ṹ۳·Id +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetAutoReturnRebackRouteId(const UINT16 autoReturnId) +{ + UINT8 includeRouteSum = 0u; + UINT16 bufIndex = 0u; /*±*/ + UINT16 returnValue = CI_ERROR; + + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡԶ۷±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + includeRouteSum = AutoReturnConfigDataStru[bufIndex].RouteSum; + + if ((includeRouteSum >= 1u) && (includeRouteSum < AUTO_RETURN_INCLROUTE_SUM_MAX)) + { + returnValue = AutoReturnConfigDataStru[bufIndex].RouteIdBuf[includeRouteSum - 1U]; + } + } + return returnValue; +} + +/* +* Զ۷· +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AutoReturnConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 autoReturnConfigDataSum = 0u; /*Զ۷·豸*/ + UINT8 returnValue = CI_SUCCESS; + UINT8 localCiId = 0u; + localCiId = GetSystemParaLocalCiId(); + + /*Զ۷·Id*/ + autoReturnConfigDataSum = GetAutoReturnRouteCurSum(); + if (autoReturnConfigDataSum >= AUTO_RETURN_SUM_MAX) + {/**/ + + returnValue = CI_ERROR; + } + else + { + for (ii = 0u; ii < AUTO_RETURN_SUM_MAX; ii++) + { + if (jj == autoReturnConfigDataSum) + {/*Ч*/ + + break; + } + + if (AutoReturnConfigDataStru[ii].BelongCiId == localCiId) + {/*òΪЧ*/ + + LocalCiAutoReturnIdBuf[jj] = AutoReturnConfigDataStru[ii].AutoReturnId; + jj++; + } + } + } + return returnValue; +} + +/* +* ȡԶ۷·ִԶͨ·Ŀ +* ˵ const UINT16 autoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoReturnOpposedRouteIdSum(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡ±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].AutoReturnOpposedRouteIdSum; + } + return returnValue; +} + +/* +* ȡԶ۷·ִԶͨ· +* ˵ const UINT16 autoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoReturnOpposedRouteIdBuf(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡ±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].AutoReturnOpposedRouteIdBuf; + } + return returnValue; +} + +/* +* ȡԶ۷·ִԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoReturnOpposedReturnIdSum(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡ±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].AutoReturnOpposedReturnIdSum; + } + return returnValue; +} + +/* +* ȡԶ۷·ִԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoReturnOpposedReturnIdBuf(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡ±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].AutoReturnOpposedReturnIdBuf; + } + return returnValue; +} + + +/* +* ȡԶ۷·ִȫԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoRtnOppAllReturnIdSum(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡ±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].AutoReturnOpposedAllReturnIdSum; + } + return returnValue; +} +/* +* ȡԶ۷·ִȫԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoRtnOppAllReturnIdBuf(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡ±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + returnValue = AutoReturnConfigDataStru[bufIndex].AutoReturnOpposedAllReturnIdBuf; + } + return returnValue; +} + + diff --git a/TSCP/src/APP/ciapp/AutoReturn/AutoReturnConfigDataManage.h b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnConfigDataManage.h new file mode 100644 index 0000000..f2a50af --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnConfigDataManage.h @@ -0,0 +1,165 @@ +/******************************************************** +* +* AutoReturnConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* Զ۷ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _AUTORETURN_CONFIG_DATA_MANAGE_H_ +#define _AUTORETURN_CONFIG_DATA_MANAGE_H_ + + +#include "AutoReturnDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../Route/RouteDefine.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*Զ۷ݽṹ*/ +typedef struct S_AutoReturnConfigDataStruct +{ + UINT16 AutoReturnId; /*Զ۷ID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 RouteSum; /*Զ۷·Ŀ (ֶ)*/ + UINT16 RouteIdBuf[AUTO_RETURN_INCLROUTE_SUM_MAX]; /*Զ۷··ID (ֶ)*/ + UINT8 AutoReturnOpposedReturnIdSum; /*Զ۷ִԶ۷·Ŀ (ֶ)*/ + UINT16 AutoReturnOpposedReturnIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*Զ۷ִԶ۷·ID (ֶ)*/ + UINT8 AutoReturnOpposedRouteIdSum; /*Զ۷·ִԶ·Ŀ (ֶ)*/ + UINT16 AutoReturnOpposedRouteIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*Զ۷·ִԶ·ID (ֶ)*/ + UINT8 AutoReturnOpposedAllReturnIdSum; /*Զ۷ִȫԶ۷·Ŀ (ֶ)*/ + UINT16 AutoReturnOpposedAllReturnIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*Զ۷ִȫԶ۷·ID (ֶ)*/ +} AutoReturnConfigDataStruct; + +/*ȫֱ*/ +extern AutoReturnConfigDataStruct AutoReturnConfigDataStru[AUTO_RETURN_SUM_MAX]; /*Զ۷ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiAutoReturnIdBuf[AUTO_RETURN_SUM_MAX]; /*屾Զ۷·IDӳ*/ +extern INT16 AutoReturnCurSum; /*Զ۷ǰ*/ + +/* +* ȡԶ۷·ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Զ۷·ǰ +*/ +UINT16 GetAutoReturnRouteCurSum(void); + +/* +* ȡָ±ӦԶ۷·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: Զ۷·ID +*/ +UINT16 GetAutoReturnRouteId(const UINT16 bufIndex); + +/* +* ȡָIDԶ۷·± +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: Զ۷·ID +*/ +UINT16 GetAutoReturnBufIndex(const UINT16 autoReturnId); + +/* +* ȡָIDԶ۷·Ŀ +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT8 GetAutoReturnIncludeRouteSum(const UINT16 autoReturnId); + +/* +* ȡָIDԶ۷ID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAutoReturnRouteBelongCiId(const UINT16 autoReturnId); + +/* +* ȡָIDԶ۷·ID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetAutoReturnIncludeRouteBuf(const UINT16 autoReturnId); + +/* +* ȡָIDԶ۷ṹ۳·Id +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetAutoReturnRebackRouteId(const UINT16 autoReturnId); + +/* +* Զ۷· +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AutoReturnConfigDataManage(void); +/* +* ȡԶ۷·ִԶͨ·Ŀ +* ˵ const UINT16 autoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoReturnOpposedRouteIdSum(const UINT16 autoReturnId); + +/* +* ȡԶ۷·ִԶͨ· +* ˵ const UINT16 autoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoReturnOpposedRouteIdBuf(const UINT16 autoReturnId); + +/* +* ȡԶ۷·ִԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoReturnOpposedReturnIdSum(const UINT16 autoReturnId); + +/* +* ȡԶ۷·ִԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoReturnOpposedReturnIdBuf(const UINT16 autoReturnId); +/* +* ȡԶ۷·ִȫԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoRtnOppAllReturnIdBuf(const UINT16 autoReturnId); +/* +* ȡԶ۷·ִȫԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoRtnOppAllReturnIdSum(const UINT16 autoReturnId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDataManage.c b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDataManage.c new file mode 100644 index 0000000..b9a24c2 --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDataManage.c @@ -0,0 +1,115 @@ +/******************************************************** +* +* AutoReturnDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* Զ۷ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "AutoReturnDataManage.h" + + + + + +AutoReturnDataStruct AutoReturnDataStru[AUTO_RETURN_SUM_MAX]; /*Զ۷ݽṹ*/ + + +/* +* ȡָIDԶ۷־ +* ˵ const UINT8 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ־ +*/ +UINT8 GetAutoReturnSetFlag(const UINT16 autoReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 autoReturnSetFlag = CI_ERROR; + + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡԶ۷±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + autoReturnSetFlag = AutoReturnDataStru[bufIndex].AutoReturnSetFlag; + } + return autoReturnSetFlag; +} + + +/* +* ָIDԶ۷־ +* ˵ const UINT8 autoReturnId, Զ۷ID +* const UINT8 setState, ־ +* ֵ +* +*/ +void SetAutoReturnSetFlag(const UINT16 autoReturnId, const UINT8 setState) +{ + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 autoIncludeRouteSum = 0u; + UINT16 *pAutoIncludeRouteIdbuf = NULL; + UINT8 autoSetFlag = CI_ERROR; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetAutoReturnBufIndex(autoReturnId); /*ȡԶ۷±*/ + + if (bufIndex < AUTO_RETURN_SUM_MAX) + { + autoIncludeRouteSum = GetAutoReturnIncludeRouteSum(autoReturnId); + pAutoIncludeRouteIdbuf = GetAutoReturnIncludeRouteBuf(autoReturnId); + + if (AUTO_RETURN_SET_YES == setState) + { + autoSetFlag = CI_ERROR; + + /*Զ*/ + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + autoSetFlag = SetRouteAutoReturnId(pAutoIncludeRouteIdbuf[ii],autoReturnId); + if (autoSetFlag == CI_ERROR) + { + /*ʧ*/ + break; + } + } + + if (autoSetFlag == CI_ERROR) + { + for (jj = 0u; jj < ii; jj++) + { + /*Id*/ + (void)SetRouteAutoReturnId(pAutoIncludeRouteIdbuf[jj],0u); + } + + } + else + { + AutoReturnDataStru[bufIndex].AutoReturnSetFlag = AUTO_RETURN_SET_YES; + + } + } + else if (AUTO_RETURN_SET_NO == setState) + { + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + /*Id*/ + (void)SetRouteAutoReturnId(pAutoIncludeRouteIdbuf[ii],0u); + } + + AutoReturnDataStru[bufIndex].AutoReturnSetFlag = AUTO_RETURN_SET_NO; + + } + else + { + /**/ + } + } +} + + + + diff --git a/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDataManage.h b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDataManage.h new file mode 100644 index 0000000..bd6ab4d --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDataManage.h @@ -0,0 +1,60 @@ +/******************************************************** +* +* AutoReturnDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* Զ۷ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _AUTORETURN_DATA_MANAGE_H_ +#define _AUTORETURN_DATA_MANAGE_H_ + +#include "AutoReturnDefine.h" +#include "AutoReturnConfigDataManage.h" +#include "CommonTypes.h" +#include "../DataManage/DeviceDataManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*Զ۷ݽṹ*/ +typedef struct S_AutoReturnDataStruct +{ + UINT16 AutoReturnId; /*Զ۷ID (ֶ)*/ + UINT8 AutoReturnSetFlag; /*Զñ־(δ/) (ֶ)*/ +} AutoReturnDataStruct; + +/*ȫֱ*/ +extern AutoReturnDataStruct AutoReturnDataStru[AUTO_RETURN_SUM_MAX]; /*Զ۷ݽṹ*/ + +/* +* ȡָIDԶ۷־ +* ˵ const UINT8 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ־ +*/ +UINT8 GetAutoReturnSetFlag(const UINT16 autoReturnId); + +/* +* ָIDԶ۷־ +* ˵ const UINT8 autoReturnId, Զ۷ID +* const UINT8 setState, ־ +* ֵ +* +*/ +void SetAutoReturnSetFlag(const UINT16 autoReturnId, const UINT8 setState); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDefine.h b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDefine.h new file mode 100644 index 0000000..a5c9562 --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoReturn/AutoReturnDefine.h @@ -0,0 +1,45 @@ +/******************************************************** +* +* AutoReturnConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* Զ۷ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _AUTORETURN_CONFIG_H_ +#define _AUTORETURN_CONFIG_H_ + + + + +/*Զ۷ֵ*/ +#define AUTO_RETURN_SUM_MAX ((UINT16)100) /*Զ۷ֵ*/ + + +/*ֵ*/ +#define AUTO_RETURN_INCLROUTE_SUM_MAX ((UINT16)8) /*Զ۷·ֵ*/ + + +/*Զ۷·*/ +#define AUTO_RETURN_ROUTE_TYPE_IN ((UINT8)0x55) /*۷*/ +#define AUTO_RETURN_ROUTE_TYPE_OUT ((UINT8)0xAA) /*۳*/ +#define AUTO_RETURN_ROUTE_TYPE_VAIN ((UINT8)0xFF) /*Ч*/ + + +/*Զ۷־*/ +#define AUTO_RETURN_SET_NO ((UINT8)0x55) /*δ*/ +#define AUTO_RETURN_SET_YES ((UINT8)0xaa) /**/ + +#define AUTO_RETURN_DICHU_AUTOROUTE ((UINT8)0x01) /*ִԶͨ·Ѱ*/ +#define AUTO_RETURN_DICHU_AUTOREROUTE ((UINT8)0x04) /*ִԶ۷·Ѱ*/ +#define AUTO_RETURN_DICHU_ALLAUTOROUTE ((UINT8)0x05) /*ִȫԶ۷·Ѱ*/ +#define AUTO_RETURN_DICHU_COMMROUTE ((UINT8)0x06) /*ִͨ·Ѱ*/ +#define AUTO_RETURN_HAVE_BLOCK ((UINT8)0x02) /*Զ۷·ڷ*/ +#define AUTO_RETURN_FLOOD_STATE_ERR ((UINT8)0x03) /*Զ۷·ڷŲ*/ + +#endif diff --git a/TSCP/src/APP/ciapp/AutoRoute/AutoRouteConfigDataManage.c b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteConfigDataManage.c new file mode 100644 index 0000000..6c87926 --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteConfigDataManage.c @@ -0,0 +1,364 @@ +/******************************************************** +* +* AutoRouteConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* Զ·ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "AutoRouteConfigDataManage.h" + + +AutoRouteConfigDataStruct AutoRouteConfigDataStru[AUTO_ROUTE_SUM_MAX]; /*Զ·ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiAutoRouteIdBuf[AUTO_ROUTE_SUM_MAX] = {0u}; /*屾Զ·IDӳ*/ +INT16 AutoRouteCurSum = 0; /*Զ·ǰ*/ +GroupAutoRouteConfigDataStruct GroupAutoRouteConfigDataStru[GROUP_AUTO_ROUTE_SUM_MAX] = {0u}; /*Զ·ýṹ*/ + + +/* +* ȡԶ··ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Զ··ǰ +*/ +UINT16 GetAutoRouteRouteCurSum(void) +{ + UINT16 autoRouteCurSum = 0u; + if ((INT16)AUTO_ROUTE_SUM_MAX <= AutoRouteCurSum) + { + autoRouteCurSum = AUTO_ROUTE_SUM_MAX; + } + else if (0 > AutoRouteCurSum) + { + autoRouteCurSum = 0u; + } + else + { + autoRouteCurSum = (UINT16)AutoRouteCurSum; + } + return autoRouteCurSum; +} + +/* +* ȡָ±ӦԶ··ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: Զ··ID +*/ +UINT16 GetAutoRouteRouteId(const UINT16 bufIndex) +{ + UINT16 returnValue = CI_ERROR; + UINT16 routeCurSum = 0u; + routeCurSum = GetAutoRouteRouteCurSum(); + if (bufIndex < routeCurSum) + { + returnValue = LocalCiAutoRouteIdBuf[bufIndex]; + } + return returnValue; +} + +/* +* ȡָIDԶ·± +* ˵ const UINT16 AutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: Զ·ID +*/ +UINT16 GetAutoRouteBufIndex(const UINT16 AutoRouteId) +{ + UINT16 returnValue = AUTO_ROUTE_SUM_MAX; + + if ((AutoRouteId >= 1u) && (AutoRouteId < AUTO_ROUTE_SUM_MAX)) + { + returnValue = AutoRouteId; + } + + return returnValue; +} + +/* +* ȡָIDԶ·ID +* ˵ const UINT16 autoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAutoRouteBelongCiId(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 belongCiId = CI_ERROR; + + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡԶ·±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + belongCiId = AutoRouteConfigDataStru[bufIndex].BelongCiId; + } + return belongCiId; +} + + +/* +* ȡָIDԶ··Ŀ +* ˵ const UINT16 AutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT8 GetAutoRouteIncludeRouteSum(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 routeSum = CI_ERROR; + + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡԶ·±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + routeSum = AutoRouteConfigDataStru[bufIndex].RouteSum; + } + return routeSum; +} + + +/* +* ȡָIDԶ·· +* ˵ const UINT8 autoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT16* GetAutoRouteIncludeRouteBuf(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* routeIdBuf = NULL; + + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡԶ·±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + routeIdBuf = AutoRouteConfigDataStru[bufIndex].RouteIdBuf; + } + return routeIdBuf; +} + +/* +* Զ· +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 AutoRouteConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 autoRouteConfigDataSum = 0u; /*Զ·豸*/ + UINT8 returnValue = CI_SUCCESS; + UINT8 localCiId = 0u; + localCiId = GetSystemParaLocalCiId(); + /*Զ·Id*/ + autoRouteConfigDataSum = GetAutoRouteRouteCurSum(); + if (autoRouteConfigDataSum >= AUTO_ROUTE_SUM_MAX) + {/**/ + + returnValue = CI_ERROR; + } + else + { + for (ii = 0u; ii < AUTO_ROUTE_SUM_MAX; ii++) + { + if (jj == autoRouteConfigDataSum) + {/*autoRouteConfigDataSumΪ0ʾûԶ·autoRouteConfigDataSum0ʾЧ*/ + + break; + } + + if (AutoRouteConfigDataStru[ii].BelongCiId == localCiId) + {/*òΪЧ*/ + + LocalCiAutoRouteIdBuf[jj] = AutoRouteConfigDataStru[ii].AutoRouteId; + jj++; + } + } + } + return returnValue; +} + + + + +/* +* ȡԶͨ·ִԶͨ·Ŀ +* ˵ const UINT16 autoRouteId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoRouteOpposedRouteIdSum(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡ±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + returnValue = AutoRouteConfigDataStru[bufIndex].AutoRouteOpposedRouteIdSum; + } + return returnValue; +} + +/* +* ȡԶͨ·ִԶͨ· +* ˵ const UINT16 autoRouteId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoRouteOpposedRouteIdBuf(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡ±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + returnValue = AutoRouteConfigDataStru[bufIndex].AutoRouteOpposedRouteIdBuf; + } + return returnValue; +} + +/* +* ȡԶͨ·ִԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoRouteOpposedReturnIdSum(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡ±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + returnValue = AutoRouteConfigDataStru[bufIndex].AutoRouteOpposedReturnIdSum; + } + return returnValue; +} + +/* +* ȡԶͨ·ִԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoRouteOpposedReturnIdBuf(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡ±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + returnValue = AutoRouteConfigDataStru[bufIndex].AutoRouteOpposedReturnIdBuf; + } + return returnValue; +} +/* +* ȡԶͨ·ִȫԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoRouteOpposedAllRtnIdSum(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡ±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + returnValue = AutoRouteConfigDataStru[bufIndex].AutoRouteOpposedAllReturnIdSum; + } + return returnValue; +} + +/* +* ȡԶͨ·ִȫԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoRouteOpposedAllRtnIdBuf(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡ±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + returnValue = AutoRouteConfigDataStru[bufIndex].AutoRouteOpposedAllReturnIdBuf; + } + return returnValue; +} + + +/* +* ȡָIDԶ·± +* ˵ const UINT16 groupAutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: Զ·ID +*/ +UINT16 GetGroupAutoRouteBufIndex(const UINT16 groupAutoRouteId) +{ + UINT16 returnValue = GROUP_AUTO_ROUTE_SUM_MAX; + + if ((groupAutoRouteId >= 1u) && (GROUP_AUTO_ROUTE_SUM_MAX > groupAutoRouteId)) + { + returnValue = groupAutoRouteId; + } + + return returnValue; +} + +/* +* ȡԶ·Զ· +* ˵ const UINT16 groupAutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: Զ· +*/ +UINT16 GetGroupAutoRouteHasRouteSum(const UINT16 groupAutoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 returnValue = CI_ERROR; + bufIndex = GetGroupAutoRouteBufIndex(groupAutoRouteId); /*ȡ±*/ + + if (GROUP_AUTO_ROUTE_SUM_MAX > bufIndex) + { + returnValue = GroupAutoRouteConfigDataStru[bufIndex].InAutoRouteSum; + } + else + { + /*޲*/ + } + return returnValue; +} + +/* +* ȡԶ·Զ·ID +* ˵ const UINT16 groupAutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: Զ·Զ·ID +*/ +UINT16* GetGroupAutoRouteHasRouteIdBuff(const UINT16 groupAutoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetGroupAutoRouteBufIndex(groupAutoRouteId); /*ȡ±*/ + + if (GROUP_AUTO_ROUTE_SUM_MAX > bufIndex) + { + returnValue = GroupAutoRouteConfigDataStru[bufIndex].InAutoRouteIdBuff; + } + else + { + /*޲*/ + } + return returnValue; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/AutoRoute/AutoRouteConfigDataManage.h b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteConfigDataManage.h new file mode 100644 index 0000000..4c87722 --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteConfigDataManage.h @@ -0,0 +1,193 @@ +/******************************************************** +* +* AutoRouteConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* Զ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _AUTOROUTE_CONFIG_DATA_MANAGE_H_ +#define _AUTOROUTE_CONFIG_DATA_MANAGE_H_ + + +#include "AutoRouteDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../Route/RouteDefine.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*Զ·ݽṹ*/ +typedef struct S_AutoRouteConfigDataStruct +{ + UINT16 AutoRouteId; /*Զ·ID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 RouteSum; /*Զ··Ŀ (ֶ)*/ + UINT16 RouteIdBuf[AUTO_ROUTE_INCLROUTE_SUM_MAX]; /*Զ··ID (ֶ)*/ + UINT8 AutoRouteOpposedRouteIdSum; /*Զͨ·ִԶͨ·Ŀ (ֶ)*/ + UINT16 AutoRouteOpposedRouteIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*Զͨ·ִԶͨ·ID (ֶ)*/ + UINT8 AutoRouteOpposedReturnIdSum; /*ԶִͨԶ۷·Ŀ (ֶ)*/ + UINT16 AutoRouteOpposedReturnIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*ԶִͨԶ۷·ID (ֶ)*/ + UINT8 AutoRouteOpposedAllReturnIdSum; /*ԶִͨȫԶ۷·Ŀ (ֶ)*/ + UINT16 AutoRouteOpposedAllReturnIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*ԶִͨȫԶ۷·ID (ֶ)*/ + +} AutoRouteConfigDataStruct; + +/*Զ·ݽṹ*/ +typedef struct Group_AutoRouteConfigDataStruct +{ + UINT16 GroupAutoRouteId; /*Զ·ID*/ + UINT16 InAutoRouteSum; /*Զ·*/ + UINT16 InAutoRouteIdBuff[IN_AUTO_ROUTE_SUM_MAX]; /*Զ·ID*/ + +}GroupAutoRouteConfigDataStruct; + +/*ȫֱ*/ +extern AutoRouteConfigDataStruct AutoRouteConfigDataStru[AUTO_ROUTE_SUM_MAX]; /*Զ·ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiAutoRouteIdBuf[AUTO_ROUTE_SUM_MAX] ; /*屾Զ·IDӳ*/ +extern INT16 AutoRouteCurSum; /*Զ·ǰ*/ +extern GroupAutoRouteConfigDataStruct GroupAutoRouteConfigDataStru[GROUP_AUTO_ROUTE_SUM_MAX]; /*Զ·ýṹ*/ + +/* +* ȡԶ··ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Զ··ǰ +*/ +UINT16 GetAutoRouteRouteCurSum(void); + +/* +* ȡָ±ӦԶ··ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: Զ··ID +*/ +UINT16 GetAutoRouteRouteId(const UINT16 bufIndex); + +/* +* ȡָIDԶ۷·± +* ˵ const UINT16 AutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: Զ۷·ID +*/ +UINT16 GetAutoRouteBufIndex(const UINT16 AutoRouteId); + +/* +* ȡָIDԶ·ID +* ˵ const UINT16 autoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAutoRouteBelongCiId(const UINT16 autoRouteId); + +/* +* ȡָIDԶ··Ŀ +* ˵ const UINT16 AutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT8 GetAutoRouteIncludeRouteSum(const UINT16 autoRouteId); + +/* +* ȡָIDԶ··Ŀ +* ˵ const UINT8 AutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT16* GetAutoRouteIncludeRouteBuf(const UINT16 autoRouteId); + +/* +* Զ· +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 AutoRouteConfigDataManage(void); + +/* +* ȡԶͨ·ִԶͨ·Ŀ +* ˵ const UINT16 autoRouteId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoRouteOpposedRouteIdSum(const UINT16 autoRouteId); + +/* +* ȡԶͨ·ִԶͨ· +* ˵ const UINT16 autoRouteId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoRouteOpposedRouteIdBuf(const UINT16 autoRouteId); + + +/* +* ȡԶͨ·ִԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoRouteOpposedReturnIdSum(const UINT16 autoRouteId); + +/* +* ȡԶͨ·ִԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoRouteOpposedReturnIdBuf(const UINT16 autoRouteId); +/* +* ȡԶͨ·ִȫԶ۷·Ŀ +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetAutoRouteOpposedAllRtnIdSum(const UINT16 autoRouteId); + +/* +* ȡԶͨ·ִȫԶ۷· +* ˵ const UINT16 AutoReturnId, Զ۷·ID +* ֵ 0: ȡʧ +* >0: ִ·ָ +*/ +UINT16* GetAutoRouteOpposedAllRtnIdBuf(const UINT16 autoRouteId); + +/* +* ȡָIDԶ·± +* ˵ const UINT16 groupAutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: Զ·ID +*/ +UINT16 GetGroupAutoRouteBufIndex(const UINT16 groupAutoRouteId); + +/* +* ȡԶ·Զ· +* ˵ const UINT16 groupAutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: Զ· +*/ +UINT16 GetGroupAutoRouteHasRouteSum(const UINT16 groupAutoRouteId); + +/* +* ȡԶ·Զ·ID +* ˵ const UINT16 groupAutoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: Զ·Զ·ID +*/ +UINT16* GetGroupAutoRouteHasRouteIdBuff(const UINT16 groupAutoRouteId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDataManage.c b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDataManage.c new file mode 100644 index 0000000..c0f3c2e --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDataManage.c @@ -0,0 +1,113 @@ +/******************************************************** +* +* AutoRouteDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* Զ·ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "AutoRouteDataManage.h" + + +AutoRouteDataStruct AutoRouteDataStru[AUTO_ROUTE_SUM_MAX] = {0u}; /*Զ·ݽṹ*/ + + +/* +* ȡָIDԶ·־ +* ˵ const UINT8 autoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: ־ +*/ +UINT8 GetAutoRouteSetFlag(const UINT16 autoRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 autoRouteSetFlag = CI_ERROR; + + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡԶ·±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + autoRouteSetFlag = AutoRouteDataStru[bufIndex].AutoRouteSetFlag; + } + return autoRouteSetFlag; +} + + +/* +* ָIDԶ·־ +* ˵ const UINT8 autoRouteId, Զ·ID +* const UINT8 setState, ־ +* ֵ +* +*/ +void SetAutoRouteSetFlag(const UINT16 autoRouteId, const UINT8 setState) +{ + + UINT8 autoIncludeRouteSum = 0u; + UINT16 *pAutoIncludeRouteIdbuf = NULL; + UINT8 autoSetFlag = CI_ERROR; + UINT16 bufIndex = 0u; /*±*/ + UINT8 ii = 0u; + UINT8 jj = 0u; + + bufIndex = GetAutoRouteBufIndex(autoRouteId); /*ȡԶ·±*/ + + if (bufIndex < AUTO_ROUTE_SUM_MAX) + { + autoIncludeRouteSum = GetAutoRouteIncludeRouteSum(autoRouteId); + pAutoIncludeRouteIdbuf = GetAutoRouteIncludeRouteBuf(autoRouteId); + + if (AUTO_ROUTE_SET_YES == setState) + { + autoSetFlag = CI_ERROR; + + /*Զ*/ + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + autoSetFlag = SetRouteAutoRouteId(pAutoIncludeRouteIdbuf[ii],autoRouteId); + if (autoSetFlag == CI_ERROR) + { + /*ʧ*/ + break; + } + } + + if (autoSetFlag == CI_ERROR) + { + for (jj = 0u; jj < ii; jj++) + { + /*Id*/ + (void)SetRouteAutoRouteId(pAutoIncludeRouteIdbuf[jj],0u); + } + } + else + { + AutoRouteDataStru[bufIndex].AutoRouteSetFlag = AUTO_ROUTE_SET_YES; + + } + } + else if (AUTO_ROUTE_SET_NO == setState) + { + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + /*Id*/ + (void)SetRouteAutoRouteId(pAutoIncludeRouteIdbuf[ii],0u); + } + + AutoRouteDataStru[bufIndex].AutoRouteSetFlag = AUTO_ROUTE_SET_NO; + + } + else + { + /**/ + } + } +} + + + + + diff --git a/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDataManage.h b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDataManage.h new file mode 100644 index 0000000..e096ca1 --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDataManage.h @@ -0,0 +1,65 @@ +/******************************************************** +* +* AutoRouteDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* Զ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _AUTOROUTE_DATA_MANAGE_H_ +#define _AUTOROUTE_DATA_MANAGE_H_ + + +#include "AutoRouteDefine.h" +#include "AutoRouteConfigDataManage.h" +#include "CommonTypes.h" +#include "../DataManage/DeviceDataManage.h" + + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*Զ·ݽṹ*/ +typedef struct S_AutoRouteDataStruct +{ + UINT16 AutoRouteId; /*Զ·ID (ֶ)*/ + UINT8 AutoRouteSetFlag; /*Զ·ñ־(δ/) (ֶ)*/ +} AutoRouteDataStruct; + +/*ȫֱ*/ +extern AutoRouteDataStruct AutoRouteDataStru[AUTO_ROUTE_SUM_MAX]; /*Զ·ݽṹ*/ + + +/* +* ȡָIDԶ·־ +* ˵ const UINT8 autoRouteId, Զ·ID +* ֵ 0: ȡʧ +* >0: ־ +*/ +UINT8 GetAutoRouteSetFlag(const UINT16 autoRouteId); + +/* +* ָIDԶ·־ +* ˵ const UINT8 autoRouteId, Զ·ID +* const UINT8 setState, ־ +* ֵ +* +*/ +void SetAutoRouteSetFlag(const UINT16 autoRouteId, const UINT8 setState); + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDefine.h b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDefine.h new file mode 100644 index 0000000..ee88cf1 --- /dev/null +++ b/TSCP/src/APP/ciapp/AutoRoute/AutoRouteDefine.h @@ -0,0 +1,42 @@ +/******************************************************** +* +* AutoRouteConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* Զ·ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _AUTOROUTE_CONFIG_H_ +#define _AUTOROUTE_CONFIG_H_ + + + +/*Զ·ֵ*/ +#define AUTO_ROUTE_SUM_MAX ((UINT16)200) /*Զ·ֵ*/ + +/*Զ·*/ +#define GROUP_AUTO_ROUTE_SUM_MAX ((UINT16)120) /*Զ·ֵ*/ +#define IN_AUTO_ROUTE_SUM_MAX ((UINT16)20) /*Ͻ·Զ·ֵ*/ + +/*ֵ*/ +#define AUTO_ROUTE_INCLROUTE_SUM_MAX ((UINT16)20) /*Զ··ֵ*/ + +/*Զ·־*/ +#define AUTO_ROUTE_SET_NO ((UINT8)0x55) /*δ*/ +#define AUTO_ROUTE_SET_YES ((UINT8)0xaa) /**/ + +#define AUTO_ROUTE_DICHU_AUTOROUTE ((UINT8)0x01) /*ִԶͨ·Ѱ*/ +#define AUTO_ROUTE_DICHU_AUTOREROUTE ((UINT8)0x04) /*ִԶ۷·Ѱ*/ +#define AUTO_ROUTE_DICHU_ALLAUTOREROUTE ((UINT8)0x05) /*ִȫԶ۷·Ѱ*/ +#define AUTO_ROUTE_DICHU_COMMROUTE ((UINT8)0x06) /*ִͨ·Ѱ*/ +#define AUTO_ROUTE_HAVE_BLOCK ((UINT8)0x02) /*Զ·ڷ*/ +#define AUTO_ROUTE_FLOOD_STATE_ERR ((UINT8)0x03) /*Զ·ڷŲ*/ + + + +#endif diff --git a/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDataPrepare.c b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDataPrepare.c new file mode 100644 index 0000000..7111c3e --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDataPrepare.c @@ -0,0 +1,601 @@ +#include "AxisAssertDataPrepare.h" +#include "AxisSectionConfigDataManage.h" +#include "PhysicalSectionDataManage.h" +#include "SystemParameterManage.h" + +#include + + +/** + * @brief ӡDebugϢ + * @param[in] UINT8 level ־ + * @param[in] const char *fmt ӡϢ + * @return + * @note ͨⲿӿڣʵֱģĴӡ + */ +void aam_PrintDebugInfo(UINT8 level,const char *fmt, ...) +{ + va_list para; + CHAR tmpPrintBuf[AMM_PRINT_LEN] = {'\0'}; + + if (AAM_LOG_LEVEL >= level) + { + va_start(para,fmt); + (void)vsnprintf(tmpPrintBuf,AMM_PRINT_LEN,fmt,para); + va_end(para); + + debug_infor_printf((const)"%s",(const)tmpPrintBuf); + } + else + { + /** ־𲻹*/ + } +} + + +/** + * @brief ȡOCΧйڼε + * @param[out] OUT UINT16** pACIdBuff ID + * @return 0 ѯ + 1~AXIS_SECTION_SUM_MAX ѯȷ + * @note OCּ֧IDӳϵֱӻȡ + */ +UINT16 aam_PrepareACBuffIndexs(OUT const UINT16** pACIdBuff) +{ + return elm_PrepareACBuffIndexs(pACIdBuff); +} + +/** + * @brief ͨIDȡε + * @param[in] UINT16 ACId ID + * @return λ + * @note + */ +UINT16 aam_PrepareACIndex(UINT16 ACId) +{ + return elm_PrepareACIndex(ACId); +} + +/** + * @brief ͨIDȡ״̬ + * @param[in] UINT16 ACID ID + * @return ELM_AC_OCC ռ + ELM_AC_FREE + * @note + */ +UINT8 aam_PrepareACStatus(UINT16 ACID) +{ + return elm_PrepareACStatus(ACID); +} + +/** + * @brief ȡǷڱOC + * @param[in] UINT16 acID ID + * @param[out] UINT8 *pOCId OCid + * @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ + * @note + */ + UINT8 aam_PrepareACIsSelf(UINT16 acID,UINT8 *pOCId) + { + return elm_PrepareACIsSelf(acID,pOCId); + } + + /** + * @brief ѯǰ/󷽼 + * @param[in] UINT16 ACID ׼ID + * @param[in] UINT8 dir ѯ + * @param[out] UINT16 arACID[AC_MAXCNT_IN_SWITCH] ڼID + * @return UINT8_MAX ѯʧ + 0~AC_MAXCNT_IN_SWITCH ѯɹ + * @note + */ +UINT8 aam_PrepareAdjacentAC(UINT16 ACID, UINT8 dir, INOUT UINT16 arACID[AC_MAXCNT_IN_SWITCH]) +{ + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + return elm_PrepareAdjacentAC(ACID, dir, arACID, &cDirectionPointFlag); +} + +/** + * @brief ͨIDҼλ + * @param[in] UINT16 ACID ID + * @param[in] UINT8 dir ѯ + * @param[out] ELM_AxisLocStruct* pACLoc λ + * @return CI_SUCCESS ѯȷسɹ + * CI_ERROR ѯ󣬷ʧ + * @note + */ +UINT8 aam_PrepareACLoc(UINT16 ACID, UINT8 dir, INOUT ELM_AxisLocStruct* pACLoc) +{ + return elm_PrepareACLoc(ACID,dir,pACLoc); +} + + +/** + * @brief ͨβҼڵ + * @param[in] UINT16 ACID + * @param[out] UINT16 *PrePhyid ǰID + * @param[out] UINT16 *BackPhyid ID + * @return CI_ERROR ش + CI_SUCCESS ȷ + * @note + * 1½2022422գǰ󷽰߼ȷ + */ +UINT8 aam_PreparePreAndBackPhySecOFAC(UINT16 ACID,UINT16 *PrePhyid, UINT16 *BackPhyid) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 tmpACCnt = 0u; + UINT16 tmpACId[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 tmpPrePhyId = 0u; + UINT16 tmpBackPhyid = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + /*- ڲж */ + ASSERT_RET_VALUE(NULL == PrePhyid,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == BackPhyid,ret,0x40000000u); + + /** ѯڼ */ + tmpACCnt = elm_PrepareAdjacentAC(ACID, EMAP_SAME_DIR, tmpACId, &cDirectionPointFlag); + + if (UINT8_MAX == tmpACCnt) + { + /** ѯ*/ + } + else + { + if (0u == tmpACCnt) + { + /** ǰΪͷ */ + tmpPrePhyId = UINT16_MAX; + } + else + { + tmpPrePhyId = GetAxisSecRelativePhySecId(tmpACId[0u]); + } + (*PrePhyid) = tmpPrePhyId; + } + + /** ѯڼ */ + tmpACCnt = elm_PrepareAdjacentAC(ACID, EMAP_CONVER_DIR, tmpACId, &cDirectionPointFlag); + + if (UINT8_MAX == tmpACCnt) + { + /** ѯ*/ + } + else + { + if (0u == tmpACCnt) + { + /** ǰΪͷ */ + tmpBackPhyid = UINT16_MAX; + } + else + { + tmpBackPhyid = GetAxisSecRelativePhySecId(tmpACId[0u]); + } + (*BackPhyid) = tmpBackPhyid; + } + + /** úֵ */ + ASSERT_SETRET((0u == tmpPrePhyId) || (0u == tmpBackPhyid) || ((UINT16_MAX == tmpPrePhyId) && (tmpPrePhyId == tmpBackPhyid)),ret,CI_ERROR,CI_SUCCESS); + return ret; +} + + +/** + * @brief ȡ״̬ + * @param[in] UINT16 PhyId id + * @param[out] + * @return SECTION_OCCUPY_YES ռ + SECTION_OCCUPY_NO ο + * @note + */ +UINT8 aam_PreparePhyOccStatus(UINT16 PhyId) +{ + /*- ֲ */ + UINT8 ret = SECTION_OCCUPY_YES; + + /** ѯ״̬ */ + ret = GetPhySecCurOccupyState(PhyId); + + if (SECTION_OCCUPY_NO == ret) + { + /** οУ*/ + } + else + { + /** Ϊռ */ + ret = SECTION_OCCUPY_YES; + } + + /** */ + return ret; +} + + +/** + * @brief ȡӦ + * @param[in] UINT16 ACID ID + * @param[out] + * @return + * @note + */ +UINT16 aam_PrepareACBelongPhyid(UINT16 ACID) +{ + return GetAxisSecRelativePhySecId(ACID); +} + + +/** + * @brief жϼǷΪ + * @param[in] UINT16 ACID ID + * @param[out] + * @return CI_SUCCESS Ϊ + CI_ERROR Ϊ + * @note + */ +UINT8 aam_PrepareACIsLinkingAxle(UINT16 ACID) +{ + UINT8 chFunRet = AXIS_SEC_LINK_LINE_NO; + UINT8 ret = CI_ERROR; + chFunRet = GetAxisSecLinkLineFlag(ACID); + if (AXIS_SEC_LINK_LINE_YES == chFunRet) + { + ret = CI_SUCCESS; + } + else + { + ; + } + return ret; +} + +/** + * @brief ȡͷ߹ܿ + * @param[in] + * @param[out] + * @return CI_SUCCESS ܴ + CI_ERROR ܹر + * @note + */ +UINT8 aam_PrepareInitCTPassFlagSwitch(void) +{ + UINT8 chFunRet = 0u; + UINT8 ret = CI_ERROR; + + chFunRet = GetCiFunctionSwitchConfig(FUNC_RESET_ARB_SWITCH); + + if (FUNC_SWITCH_ON == chFunRet) + {/* ܿش */ + ret = CI_SUCCESS; + } + else + { + ; /* ܿعر */ + } + return ret; +} + + +/** + * @brief ȡ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_PrepareRedunTimes(void) +{ + /** ǷҪǶԺķֵУ飬ȽϾᣬֻǿת*/ + return (UINT8)GetSystemParaOccuToIdleCyc(); +} + + +/** + * @brief ȡΰļ + * @param[in] UINT16 PhyId + * @param[out] UINT8* pACCnt + * @return const UINT16* δ洢ַ + * @note NULL ѯȷ + NULL ѯ + */ +const UINT16* aam_PreparePhyRelACIds(UINT16 PhyId,UINT8* pACCnt) +{ + const UINT16* ret = NULL; + UINT8 tempCnt = 0u; + + /** ڲ */ + ASSERT_RET_VALUE(NULL == pACCnt,ret,0x80000000u); + + /** ȡΰļ */ + tempCnt = GetPAxisSectionSum(PhyId); + ret = GetPAxisSectionIdBuf(PhyId); + + if (0u == tempCnt) + { + /** ѯ */ + *pACCnt = 0u; + ret = NULL; + } + else + { + /** ѯȷ */ + *pACCnt = tempCnt; + } + + return ret; +} + +/** +* @brief ȡǷڱTIOC +* @param[in] UINT16 phyID ID +* @param[out] UINT8 *pOCId TIOCid +* @return ELM_BELONG_OTHER TIOC +ELM_BELONG_OWNER ڱTIOC +Ƿ +* @note +*/ +UINT8 aam_PreparePhyIsSelf(UINT16 phyID, UINT8 *pOCId) +{ + /*- ֲ */ + UINT8 ret = ELM_BELONG_OWNER; + UINT8 localOCid = 0u; + UINT8 phyBelongOcid = 0u; + + /** ڲУ */ + if (NULL == pOCId) + { + /** ڲ */ + } + else + { + /** ȡOCid */ + localOCid = GetSystemParaLocalCiId(); + + /** ȡOC id 255*/ + phyBelongOcid = (UINT8)GetPhySecBelongCiId(phyID); + + if ((0u == localOCid) || (0u == phyBelongOcid)) + { + /** ݳʼ */ + } + else if (localOCid == phyBelongOcid) + { + /** һOC*/ + *pOCId = phyBelongOcid; + ret = ELM_BELONG_OWNER; + } + else + { + /** ͬһOC*/ + *pOCId = phyBelongOcid; + ret = ELM_BELONG_OTHER; + } + } + + return ret; +} + +/** + * @brief жֵǷUINT16ֵ + * @param[in] UINT16 targetValue ѯֵ + * @param[in] const UINT16 arValue[] ͻΧ + * @param[in] UINT16 buffsize ͻΧС + * @return CI_SUCCESS ֵָڳͻΧ + * CI_ERROR ֵָڳͻΧ + * @note + */ +UINT8 aam_PrepareInUINT16Array(UINT16 targetValue,const UINT16 arValue[],UINT16 buffsize) +{ + /*- ֲ */ + UINT8 cRetVal = CI_ERROR; + UINT16 cycle = 0u; + + /** ڲУ */ + if (NULL == arValue) + { + /** ڲ */ + } + else + { + /*- ĿֵǷָΧ */ + for (cycle = 0u; cycle < buffsize; cycle++) + { + if (targetValue == arValue[cycle]) + { + cRetVal = CI_SUCCESS; + break; + } + } + } + + /** */ + return cRetVal; +} + +/** +* @brief ȡARBܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ +CI_ERROR ܹر +* @note +*/ +UINT8 aam_PrepareArbSwitch(void) +{ + UINT8 chFunRet = 0u; + UINT8 ret = CI_ERROR; + + chFunRet = GetCiFunctionSwitchConfig(FUNC_ARB_SWITCH); + + if (FUNC_SWITCH_ON == chFunRet) + {/* ܿش */ + ret = CI_SUCCESS; + } + else + { + ; /* ܿعر */ + } + return ret; +} + +/** +* @brief ȡRCͨŵOCid +* @param[out] UINT8 *pOCIDbuff OCid +* @return OCͨ +*/ +UINT8 aam_PrepareComOcId(IN const UINT8 **pOcIdBuff) +{ + /*- ֲ */ + UINT8 ret = 0u; + + /** ڲУ */ + if (NULL == pOcIdBuff) + { + /** ڲ󣬷0,ⲿ*/ + } + else + { + /** ȡRCͨŵOC */ + ret = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC); + + /** жǷڣֱӷ*/ + if (0u == ret) + { + /** OC */ + } + else + { + /** ȡͨOD ID */ + (*pOcIdBuff) = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); + } + } + + return ret; +} + + +/** +* @brief ȡOCͨ״̬ +* @param[in] UINT8 OCID +* @return AAM_COM_STATUS_ERROR ͨ״̬ +AAM_COM_STATUS_OK ͨ״̬ȷ +* @note +*/ +UINT8 aam_PrepareOcCommStatus(UINT8 OcId) +{ + /*- ֲ */ + UINT8 ret = AAM_COM_STATUS_ERROR; + UINT8 funRtn = TRANSMIT_STATE_BAD; + UINT8 localId = GetSystemParaLocalCiId(); + UINT32 recvCyc = 0u; + + /** ȡOCͨ״̬ */ + funRtn = GetCiTransmitState(CI_SYSTEM_TYPE_OC, OcId); + + /** ȡյϢں */ + recvCyc = GetCiTransmitRecvDataCycNum(localId, CI_SYSTEM_TYPE_OC, OcId); + + /** úֵ */ + ASSERT_SETRET(((TRANSMIT_STATE_GOOD == funRtn) && (0u != recvCyc)), ret, AAM_COM_STATUS_OK, AAM_COM_STATUS_ERROR); + + /** */ + return ret; +} + +/** +* @brief ȡϵͳܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ +CI_ERROR ܹر +* @note +*/ +UINT8 aam_PrepareAsSwitch(void) +{ + UINT8 ret = CI_ERROR; + UINT8 acFty = 0u; + acFty = GetCiFunctionSwitchConfig(FUNC_SWITCH_AC_FACTORY); + /** úֵ */ + ASSERT_SETRET(FUNC_SWITCH_OFF == acFty, ret, CI_ERROR, CI_SUCCESS); + return ret; +} + +/** +* @brief ȡRCͨŵļϵͳid +* @param[out] UINT8 *pAsIdBuff ϵͳid +* @return RCͨżϵͳ +*/ +UINT8 aam_PrepareComAsId(IN const UINT8 **pAsIdBuff) +{ + /*- ֲ */ + UINT8 ret = 0u; + + /** ڲУ */ + if (NULL == pAsIdBuff) + { + /** ڲ󣬷0,ⲿ*/ + } + else + { + /** ȡRCͨŵļϵͳ */ + ret = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); + + /** жǷڣֱӷ*/ + if (0u == ret) + { + /** ޼ϵͳ */ + } + else + { + /** ȡͨżϵͳ ID */ + (*pAsIdBuff) = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); + } + } + + return ret; +} + + +/** +* @brief ȡϵͳͨ״̬ +* @param[in] UINT8 AsId +* @return AAM_COM_STATUS_ERROR ͨ״̬ +AAM_COM_STATUS_OK ͨ״̬ȷ +* @note +*/ +UINT8 aam_PrepareAsCommStatus(UINT8 AsId) +{ + /*- ֲ */ + UINT8 ret = AAM_COM_STATUS_ERROR; + UINT8 funRtn = TRANSMIT_STATE_BAD; + UINT8 localId = GetSystemParaLocalCiId(); + UINT32 recvCyc = 0u; + + /** ȡϵͳͨ״̬ */ + funRtn = GetCiTransmitState(CI_SYSTEM_TYPE_AXIS, AsId); + + /** ȡϵͳ */ + recvCyc = GetCiTransmitRecvDataCycNum(localId, CI_SYSTEM_TYPE_AXIS, AsId); + + /** úֵ */ + ASSERT_SETRET(((TRANSMIT_STATE_GOOD == funRtn) && (0u != recvCyc)), ret, AAM_COM_STATUS_OK, AAM_COM_STATUS_ERROR); + + /** */ + return ret; +} + +/** +* @brief жǷͬ +* @param[in] LOD_STRU strPointA +* @param[in] LOD_STRU strPointB +* @return CI_ERROR:ȽʧܣFLAG_SET:ͬFLAG_UNSET:ͬ +* @note +*/ +UINT8 aam_PrepareTwoPointsSameDir(const LOD_STRU strPointA, const LOD_STRU strPointB) +{ + return IsPointABSameDir(strPointA, strPointB); +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDataPrepare.h b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDataPrepare.h new file mode 100644 index 0000000..0f9ac86 --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDataPrepare.h @@ -0,0 +1,268 @@ +/****************************************************************************** +** ļ: AxisAssertDataPrepare.h +** : ģ飬ģaam׼ +*******************************************************************************/ +#ifndef AXIS_ASSERT_DATA_PREPARE_H_ +#define AXIS_ASSERT_DATA_PREPARE_H_ + +#include "AxisAssertDefine.h" +#include "EnvelopeDefine.h" +#include "ELMDataPrepare.h" +#include "dsuEmapDefine.h" + +#define AAM_LOG_FATAL 0u /** ά־--ά */ +#define AAM_LOG_ERROR 1u /*ά־--󼶱*/ +#define AAM_LOG_WARING 2u /*ά־--漶*/ +#define AAM_LOG_DEBUG 3u /*ά־--Լ*/ +#define AAM_LOG_LEVEL AAM_LOG_DEBUG /*ά־--ǰ־*/ +#define AMM_PRINT_LEN 1280u /* ά־ӡӡ 1024+256 */ + + +/** ־ӡ */ +#define AAM_LOG_LOC(level,fmt,...) aam_PrintDebugInfo(level,fmt" line:%d fun:%s.\n",##__VA_ARGS__,__LINE__,__FUNCTION__); + +#define AAM_LOG(level,fmt,...) aam_PrintDebugInfo(level,fmt,##__VA_ARGS__); + +#if (kPLATFORM==kWINDOWS) +#define AAM_LOG_TIME(level,fmt,...) { \ + SYSTEMTIME sys; \ + GetLocalTime(&sys); \ + aam_PrintDebugInfo(level,fmt" time:%02d:%02d:%02d.%03d.\n",##__VA_ARGS__,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds); \ +} +#else +#define AAM_LOG_TIME(level,fmt,...) aam_PrintDebugInfo(level,fmt" time:%08d.\n",##__VA_ARGS__,TimeStamp); +#endif + + + + +/** + * @brief ӡDebugϢ + * @param[in] UINT8 level ־ + * @param[in] const char *fmt ӡϢ + * @return + * @note ͨⲿӿڣʵֱģĴӡ + */ +void aam_PrintDebugInfo(UINT8 level, const char *fmt, ...); + +/** + * @brief ȡOCΧйڼε + * @param[out] OUT UINT16** pACIdBuff ID + * @return 0 ѯ + 1~AXIS_SECTION_SUM_MAX ѯȷ + * @note OCּ֧IDӳϵֱӻȡ + */ +UINT16 aam_PrepareACBuffIndexs(OUT const UINT16** pACIdBuff); + + +/** + * @brief ͨIDȡε + * @param[in] UINT16 ACId ID + * @return λ + * @note + */ +UINT16 aam_PrepareACIndex(UINT16 ACId); + +/** + * @brief ͨIDȡ״̬ + * @param[in] UINT16 ACID ID + * @return ELM_AC_OCC ռ + ELM_AC_FREE + * @note + */ +UINT8 aam_PrepareACStatus(UINT16 ACID); + +/** + * @brief ȡǷڱOC + * @param[in] UINT16 acID ID + * @param[out] UINT8 *pOCId OCid + * @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ + * @note + */ + UINT8 aam_PrepareACIsSelf(UINT16 acID,UINT8 *pOCId); + + + /** + * @brief ѯǰ/󷽼 + * @param[in] UINT16 ACID ׼ID + * @param[in] UINT8 dir ѯ + * @param[out] UINT16 arACID[AC_MAXCNT_IN_SWITCH] ڼID + * @return UINT8_MAX ѯʧ + 0~AC_MAXCNT_IN_SWITCH ѯɹ + * @note + */ +UINT8 aam_PrepareAdjacentAC(UINT16 ACID, UINT8 dir, INOUT UINT16 arACID[AC_MAXCNT_IN_SWITCH]); + +/** + * @brief ͨIDҼλ + * @param[in] UINT16 ACID ID + * @param[in] UINT8 dir ѯ + * @param[out] ELM_AxisLocStruct* pACLoc λ + * @return CI_SUCCESS ѯȷسɹ + * CI_ERROR ѯ󣬷ʧ + * @note + */ +UINT8 aam_PrepareACLoc(UINT16 ACID, UINT8 dir,INOUT ELM_AxisLocStruct* pACLoc); + + +/** + * @brief ͨβҼڵ + * @param[in] UINT16 ACID + * @param[out] UINT16 *PrePhyid ǰID + * @param[out] UINT16 *BackPhyid ID + * @return CI_ERROR ش + CI_SUCCESS ȷ + * @note + * 1½2022422գǰ󷽰߼ȷ + */ +UINT8 aam_PreparePreAndBackPhySecOFAC(UINT16 ACID,UINT16 *PrePhyid, UINT16 *BackPhyid); + + +/** + * @brief ȡ״̬ + * @param[in] UINT16 PhyId id + * @param[out] + * @return SECTION_OCCUPY_YES ռ + SECTION_OCCUPY_NO ο + * @note + */ +UINT8 aam_PreparePhyOccStatus(UINT16 PhyId); + + +/** + * @brief ȡӦ + * @param[in] UINT16 ACID ID + * @param[out] + * @return + * @note + */ +UINT16 aam_PrepareACBelongPhyid(UINT16 ACID); + + +/** + * @brief жϼǷΪ + * @param[in] UINT16 ACID ID + * @param[out] + * @return CI_SUCCESS Ϊ + CI_ERROR Ϊ + * @note + */ +UINT8 aam_PrepareACIsLinkingAxle(UINT16 ACID); + + +/** + * @brief ȡͷ߹ܿ + * @param[in] + * @param[out] + * @return CI_SUCCESS ܴ + CI_ERROR ܹر + * @note + */ +UINT8 aam_PrepareInitCTPassFlagSwitch(void); + + +/** + * @brief ȡ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_PrepareRedunTimes(void); + + +/** + * @brief ȡΰļ + * @param[in] UINT16 PhyId + * @param[out] UINT8* pACCnt + * @return const UINT16* δ洢ַ + * @note NULL ѯȷ + NULL ѯ + */ +const UINT16* aam_PreparePhyRelACIds(UINT16 PhyId,UINT8* pACCnt); + +/** +* @brief ȡǷڱTIOC +* @param[in] UINT16 phyID ID +* @param[out] UINT8 *pOCId TIOCid +* @return ELM_BELONG_OTHER TIOC +ELM_BELONG_OWNER ڱTIOC +Ƿ +* @note +*/ +UINT8 aam_PreparePhyIsSelf(UINT16 phyID, UINT8 *pOCId); + +/** + * @brief жֵǷUINT16ֵ + * @param[in] UINT16 targetValue ѯֵ + * @param[in] const UINT16 arValue[] ͻΧ + * @param[in] UINT16 buffsize ͻΧС + * @return CI_SUCCESS ֵָڳͻΧ + * CI_ERROR ֵָڳͻΧ + * @note + */ +UINT8 aam_PrepareInUINT16Array(UINT16 targetValue,const UINT16 arValue[],UINT16 buffsize); + +/** +* @brief ȡARBܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ +CI_ERROR ܹر +* @note +*/ +UINT8 aam_PrepareArbSwitch(void); + +/** +* @brief ȡRCͨŵOCid +* @param[out] UINT8 *pOCIDbuff OCid +* @return OCͨ +*/ +UINT8 aam_PrepareComOcId(IN const UINT8 **pOcIdBuff); + +/** +* @brief ȡOCͨ״̬ +* @param[in] UINT8 OCID +* @return ELM_COM_STATUS_ERROR ͨ״̬ +ELM_COM_STATUS_OK ͨ״̬ȷ +* @note +*/ +UINT8 aam_PrepareOcCommStatus(UINT8 OcId); + +/** +* @brief ȡϵͳܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ +CI_ERROR ܹر +* @note +*/ +UINT8 aam_PrepareAsSwitch(void); + +/** +* @brief ȡRCͨŵļϵͳid +* @param[out] UINT8 *pAsIdBuff ϵͳid +* @return RCͨżϵͳ +*/ +UINT8 aam_PrepareComAsId(IN const UINT8 **pAsIdBuff); + +/** +* @brief ȡϵͳͨ״̬ +* @param[in] UINT8 AsId +* @return AAM_COM_STATUS_ERROR ͨ״̬ +AAM_COM_STATUS_OK ͨ״̬ȷ +* @note +*/ +UINT8 aam_PrepareAsCommStatus(UINT8 AsId); + +/** +* @brief жǷͬ +* @param[in] LOD_STRU strPointA +* @param[in] LOD_STRU strPointB +* @return CI_ERROR:ȽʧܣFLAG_SET:ͬFLAG_UNSET:ͬ +* @note +*/ +UINT8 aam_PrepareTwoPointsSameDir(const LOD_STRU strPointA, const LOD_STRU strPointB); +#endif /*AXIS_ASSERT_DATA_PREPARE_H_*/ diff --git a/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDefine.h b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDefine.h new file mode 100644 index 0000000..5e2c566 --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertDefine.h @@ -0,0 +1,66 @@ +/****************************************************************************** +** ļ: AxisAssertDefine.h +** : ģ飬ģaam Ϊĸģ +*******************************************************************************/ +#ifndef AXIS_ASSERT_DEFINE_H_ +#define AXIS_ASSERT_DEFINE_H_ +#include "EnvelopeDefine.h" + + +#define AAM_STATUS_OCC 0x00u /* ռ״̬CT/UTռã */ +#define AAM_STATUS_ARB 0x55u /* ARB״̬ */ +#define AAM_STATUS_FREE_OR_REDUN 0xaau /* л״̬ */ + +#define AAM_CT_PASS 0xffu /* κóͨ */ +#define AAM_UT_PASS 0x00u /* λͨ*/ + +#define AAM_ENVELOPE_ENTER_ERROR 0x00u /* óͨ*/ +#define AAM_ENVELOPE_HEAD_ENTER 0x01u /* óͨһͷ*/ +#define AAM_ENVELOPE_TAIL_ENTER 0x02u /* óͨڶβ*/ +#define AAM_ENVELOPE_TAIL_EXIT 0x03u /* óͨβ*/ +#define AAM_ENVELOPE_HEAD_EXIT 0x04u /* ͷ */ + +#define AAM_GOOD_NEAR 0x01u /* óӽ */ +#define AAM_GOOD_FAR_AWAY 0x02u /* óԶ */ +#define AAM_BAD_NEAR 0x03u /* ӽ */ +#define AAM_NO_TRAIN_NEAR 0x04u /* ޳ӽ */ +#define AAM_GOOD_OCC 0x05u /* óռ */ + + +#define AAM_API_AC_ARB 0x01u /* ARB*/ +#define AAM_API_AC_REDUNARB 0x02u /* ARB */ +#define AAM_API_AC_UT 0x03u /* UT */ +#define AAM_API_AC_REDUNUT 0x04u /* UT */ + +/*ɷΪARB־*/ +#define REDUN_OVER_ARB_YES ((UINT8)0x55) /*ARB*/ +#define REDUN_OVER_ARB_NO ((UINT8)0xaa) /*ΪUTռ*/ + + +#define AAM_END_LINE_INIT 0x55u /* ͷARBʼ */ +#define AAM_END_LINE_UNINIT 0xaau /* ͷARBδʼ */ + +#define AAM_COM_STATUS_OK (0x55u) /* ͨ״̬ȷ */ +#define AAM_COM_STATUS_ERROR (0xaau) /* ͨ״̬ */ + +/*ϵͳͨжARBЧ־*/ +#define AAM_COMM_BAD_ARB_YES (0x55U) /*ϵͳͨжARBЧ*/ +#define AAM_COMM_BAD_ARB_NO (0xAAU) /*ϵͳͨжARBЧ*/ + +/** Ϣṹ */ +typedef struct +{ + UINT8 acAssertStatus; /* ARB״̬ */ + UINT8 passTrainFlag; /* óͨ־λ */ + UINT16 passTrainID; /* óͨгID */ + UINT8 redunTime; /* ռʱ*/ + UINT8 headEnterTrainCnt; /* гͷ */ + UINT16 headEnterTrainId[SECTION_REL_ENVELOPE_SUM_MAX]; /* гͷļ */ + UINT8 tailEnterTrainCnt; /* гβ */ + UINT16 tailEnterTrainId[SECTION_REL_ENVELOPE_SUM_MAX]; /* гβļ */ + UINT8 redunOverCanArb; /*ܷΪARB־ ʱΪ0x55*/ + UINT8 AxisCommBadArbFlag; /*ͨжϿARBЧ־0x55-Ч,0xAA-Ч*/ +}AxisAsserStruct; + + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManage.c b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManage.c new file mode 100644 index 0000000..7537494 --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManage.c @@ -0,0 +1,593 @@ +#include "AxisAssertManage.h" + +static AxisAsserStruct gs_AxisAssert[AXIS_SECTION_SUM_MAX] = {0u}; /** ݻ */ +static UINT8 gs_InitEndlineFlag = AAM_END_LINE_UNINIT; /* ͷARB⴦־ */ + + +/** + * @brief ʼϢ + * @param[in] + * @param[out] + * @return CI_ERROR, + * CI_SUCCESS, ɹ + * @note + */ +UINT8 aam_InitAxisAssert(void) +{ + return CommonMemSet(&gs_AxisAssert[0u],(UINT32)sizeof(AxisAsserStruct) * AXIS_SECTION_SUM_MAX,0u, (UINT32)sizeof(AxisAsserStruct)*AXIS_SECTION_SUM_MAX); +} + +/** + * @brief ͨȡϢ + * @param[in] + * @param[out] + * @return + * @note + */ +const AxisAsserStruct* aam_GetAxisAssertInfo(UINT16 acIndex) +{ + AxisAsserStruct* pRtn = NULL; + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + pRtn = &gs_AxisAssert[acIndex]; + } + return pRtn; +} + +/** + * @brief ðļ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_SetEnvelopeEnterType(UINT16 acIndex,UINT8 type,UINT16 trainID) +{ + UINT8 cycle = 0u; + + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + if (AAM_ENVELOPE_HEAD_ENTER == type) + { + for (cycle = 0u;cycle < gs_AxisAssert[acIndex].headEnterTrainCnt; cycle++) + { + if (trainID == gs_AxisAssert[acIndex].headEnterTrainId[cycle]) + { + break; + } + } + + if ((cycle == gs_AxisAssert[acIndex].headEnterTrainCnt) && + (gs_AxisAssert[acIndex].headEnterTrainCnt < SECTION_REL_ENVELOPE_SUM_MAX)) + { + gs_AxisAssert[acIndex].headEnterTrainId[cycle] = trainID; + gs_AxisAssert[acIndex].headEnterTrainCnt++; + } + else + { + /** */ + } + } + else if(AAM_ENVELOPE_TAIL_ENTER == type) + { + for (cycle = 0u;cycle < gs_AxisAssert[acIndex].tailEnterTrainCnt; cycle++) + { + if (trainID == gs_AxisAssert[acIndex].tailEnterTrainId[cycle]) + { + break; + } + } + + if ((cycle == gs_AxisAssert[acIndex].tailEnterTrainCnt) && + (gs_AxisAssert[acIndex].tailEnterTrainCnt < SECTION_REL_ENVELOPE_SUM_MAX)) + { + gs_AxisAssert[acIndex].tailEnterTrainId[cycle] = trainID; + gs_AxisAssert[acIndex].tailEnterTrainCnt++; + } + else + { + /** */ + } + } + else + { + /** */ + } + } +} + + +/** + * @brief úóͨ־λ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_SetPassTrainFlag(UINT16 acIndex,UINT16 trainID) +{ + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + gs_AxisAssert[acIndex].passTrainFlag = AAM_CT_PASS; + gs_AxisAssert[acIndex].passTrainID = trainID; + } +} + +/** + * @brief ʱλ + * @param[in] UINT16 acIndex + * @param[in] UINT8 maxTimes ռõеʱ + * @param[out] + * @return + * @note + */ +void aam_AddRedunTime(UINT16 acIndex,UINT8 maxTimes) +{ + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + if (gs_AxisAssert[acIndex].redunTime >= maxTimes) + { + /** ʱۼ */ + } + else + { + gs_AxisAssert[acIndex].redunTime++; + } + } +} + +/** + * @brief ü״̬ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_SetAxisStatus(UINT16 acIndex,UINT8 status) +{ + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX) && + ((AAM_STATUS_FREE_OR_REDUN == status) ||(AAM_STATUS_ARB == status) || (AAM_STATUS_OCC == status))) + { + gs_AxisAssert[acIndex].acAssertStatus = status; + } +} + +/** + * @brief ָϢ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_SetAxisAssert(UINT16 acIndex,const AxisAsserStruct* pBuff) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = 0u; + + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX) && (NULL != pBuff)) + { + funRtn = CommonMemCpy((void*)&gs_AxisAssert[acIndex], (UINT32)sizeof(AxisAsserStruct), (const void*)pBuff, (UINT32)sizeof(AxisAsserStruct)); + ASSERT_SETRET(1u == funRtn,ret,CI_SUCCESS,CI_ERROR); + } + return ret; +} + + +/** + * @brief ָϢ洢ռ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ResetAxisAssertByACIndex(UINT16 acIndex) +{ + if ((0U != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + (void)CommonMemSet(&gs_AxisAssert[acIndex], (UINT32)sizeof(AxisAsserStruct),0, (UINT32)sizeof(AxisAsserStruct)); + } +} + +/** + * @brief óͨ־λ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_ClearPassTrainFlag(UINT16 acIndex) +{ + UINT8 ret = CI_ERROR; + + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + gs_AxisAssert[acIndex].passTrainFlag = AAM_UT_PASS; + gs_AxisAssert[acIndex].passTrainID = 0u; + ret = CI_SUCCESS; + } + + return ret; +} + +/** + * @brief ʱλ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_ClearRedunTime(UINT16 acIndex) +{ + UINT8 ret = CI_ERROR; + + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + gs_AxisAssert[acIndex].redunTime = 0u; + ret = CI_SUCCESS; + } + + return ret; +} + +/** + * @brief ϳͷϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ClearHeadEnterTrainId(UINT16 acIndex) +{ + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + (void)CommonMemSet(&gs_AxisAssert[acIndex].headEnterTrainId[0], (UINT32)sizeof(UINT16)*SECTION_REL_ENVELOPE_SUM_MAX,0, (UINT32)sizeof(UINT16)*SECTION_REL_ENVELOPE_SUM_MAX); + gs_AxisAssert[acIndex].headEnterTrainCnt = 0u; + } +} + +/** + * @brief ϳͷϢָгϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ClearHeadEnterIdForTrain(UINT16 acIndex,UINT16 trainId) +{ + UINT8 cycle = 0u; + UINT8 moveCycle = 0u; + + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX) && (0u != gs_AxisAssert[acIndex].headEnterTrainCnt)) + { + for (cycle = 0u;cycle < gs_AxisAssert[acIndex].headEnterTrainCnt; cycle++) + { + if (trainId == gs_AxisAssert[acIndex].headEnterTrainId[cycle]) + { + break; + } + } + if (cycle == gs_AxisAssert[acIndex].headEnterTrainCnt) + { + /** ûУ */ + } + else + { + /** ҵֱ*/ + for (moveCycle = cycle; moveCycle < (gs_AxisAssert[acIndex].headEnterTrainCnt - 1u);moveCycle++) + { + gs_AxisAssert[acIndex].headEnterTrainId[cycle] = gs_AxisAssert[acIndex].headEnterTrainId[cycle+1u]; + } + gs_AxisAssert[acIndex].headEnterTrainId[moveCycle] = 0u; + gs_AxisAssert[acIndex].headEnterTrainCnt--; + } + } +} + +/** + * @brief ϳβϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ClearTailEnterTrainId(UINT16 acIndex) +{ + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + (void)CommonMemSet(&gs_AxisAssert[acIndex].tailEnterTrainId[0u], (UINT32)sizeof(UINT16)*SECTION_REL_ENVELOPE_SUM_MAX,0, (UINT32)sizeof(UINT16)*SECTION_REL_ENVELOPE_SUM_MAX); + gs_AxisAssert[acIndex].tailEnterTrainCnt = 0u; + } +} + + +/** + * @brief ϳβϢָгϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ClearTailEnterIdForTrain(UINT16 acIndex,UINT16 trainId) +{ + UINT8 cycle = 0u; + UINT8 moveCycle = 0u; + + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX) && (0u != gs_AxisAssert[acIndex].tailEnterTrainCnt)) + { + for (cycle = 0u;cycle < gs_AxisAssert[acIndex].tailEnterTrainCnt; cycle++) + { + if (trainId == gs_AxisAssert[acIndex].tailEnterTrainId[cycle]) + { + break; + } + } + if (cycle == gs_AxisAssert[acIndex].tailEnterTrainCnt) + { + /** ûУ */ + } + else + { + /** ҵֱ*/ + for (moveCycle = cycle; moveCycle < (gs_AxisAssert[acIndex].tailEnterTrainCnt - 1u);moveCycle++) + { + gs_AxisAssert[acIndex].tailEnterTrainId[cycle] = gs_AxisAssert[acIndex].tailEnterTrainId[cycle+1u]; + } + gs_AxisAssert[acIndex].tailEnterTrainId[moveCycle] = 0u; + gs_AxisAssert[acIndex].tailEnterTrainCnt--; + } + } +} + + +/** + * @brief þͷARB⴦־ + * @param[in] UINT8 flag ־ + * @param[out] + * @return + * @note + */ +void aam_SetInitEndlineFlag(UINT8 flag) +{ + if ((AAM_END_LINE_UNINIT == flag) || (AAM_END_LINE_INIT == flag)) + { + gs_InitEndlineFlag = flag; + } + else + { + gs_InitEndlineFlag = AAM_END_LINE_INIT; + } +} + + +/** + * @brief ȡͷARB⴦־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetInitEndlineFlag(void) +{ + return gs_InitEndlineFlag; +} + + + + +/** + * @brief ȡóͨ־λ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetPassTrainFlag(UINT16 acIndex) +{ + UINT8 ret = AAM_UT_PASS; + + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + ret = gs_AxisAssert[acIndex].passTrainFlag; + } + + return ret; +} + +/** + * @brief ȡ״̬ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetAxisStatus(UINT16 acIndex) +{ + UINT8 ret = AAM_STATUS_OCC; + if ((0U != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + ret = gs_AxisAssert[acIndex].acAssertStatus; + } + return ret; +} + + +/** + * @brief ȡʱ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetRedunTime(UINT16 acIndex) +{ + UINT8 ret = 0u; + if ((0u != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + ret = gs_AxisAssert[acIndex].redunTime; + } + return ret; +} + + +/** + * @brief ȡгͷ־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetHeadEnterFlag(UINT16 acIndex,UINT16 trainID) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + + if ((0u != acIndex) && (AXIS_SECTION_SUM_MAX > acIndex) && (0u != gs_AxisAssert[acIndex].headEnterTrainCnt)) + { + for (cycle = 0u;cycle < gs_AxisAssert[acIndex].headEnterTrainCnt; cycle++) + { + if (trainID == gs_AxisAssert[acIndex].headEnterTrainId[cycle]) + { + ret = CI_SUCCESS; + break; + } + else + { + ; + } + } + } + return ret; +} + + +/** + * @brief ȡгβ־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetTailEnterFlag(UINT16 acIndex,UINT16 trainID) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + + if ((0u != acIndex) && (AXIS_SECTION_SUM_MAX > acIndex) && (0u != gs_AxisAssert[acIndex].tailEnterTrainCnt)) + { + for (cycle = 0u;cycle < gs_AxisAssert[acIndex].tailEnterTrainCnt; cycle++) + { + if (trainID == gs_AxisAssert[acIndex].tailEnterTrainId[cycle]) + { + ret = CI_SUCCESS; + break; + } + else + { + ; + } + } + } + else + { + ; /*ȡֵǷ*/ + } + return ret; +} + +/* +* ȡָIDɷARB־ +* ˵ const UINT16 acIndex, +* ֵ 0x55 ARB 0xaa ARB +* Create: fan 2024/10/14 +*/ +UINT8 aam_GetAxisRedunCanArbFlag(const UINT16 acIndex) +{ + UINT8 ret = REDUN_OVER_ARB_NO; + if ((0U != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + ret = gs_AxisAssert[acIndex].redunOverCanArb; + } + else + { + ; /*REDUN_OVER_ARB_NO*/ + } + return ret; +} + + +/* +* ָIDɷARB־ +* ˵ const UINT16 acIndex, +* const UINT8 redunOverArbFlag, ɷARB־ +* ֵ +* Create: fan 2024/10/14 +*/ +void aam_SetAxisRedunCanArbFlag(const UINT16 acIndex, const UINT8 redunOverArbFlag) +{ + + if ((0u != acIndex) && (AXIS_SECTION_SUM_MAX > acIndex)) + { + if ((REDUN_OVER_ARB_YES == redunOverArbFlag) || (REDUN_OVER_ARB_NO == redunOverArbFlag)) + { + gs_AxisAssert[acIndex].redunOverCanArb = redunOverArbFlag; /*ɷARB־*/ + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ָIDμͨжϿARB־ +* ˵const UINT16 acIndex +* const UINT8 cCommBadArbFlag ͨжϿARB־ +* ֵ +* Created By LQ 2025.02.24 +*/ +void aam_SetAxisCommBadArbFlag(const UINT16 acIndex, const UINT8 cCommBadArbFlag) +{ + + if ((0U != acIndex) && (AXIS_SECTION_SUM_MAX > acIndex)) + { + if ((AAM_COMM_BAD_ARB_YES == cCommBadArbFlag) || (AAM_COMM_BAD_ARB_NO == cCommBadArbFlag)) + { + gs_AxisAssert[acIndex].AxisCommBadArbFlag = cCommBadArbFlag; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ȡָIDμͨжϿARB־ +* ˵const UINT16 acIndex +* ֵ0x55 Ч +* 0xAA Ч +* Created By LQ 2025.02.24 +*/ +UINT8 aam_GetAxisCommBadArbFlag(const UINT16 acIndex) +{ + UINT8 ret = AAM_COMM_BAD_ARB_NO; + + if ((0U != acIndex) && (acIndex < AXIS_SECTION_SUM_MAX)) + { + ret = gs_AxisAssert[acIndex].AxisCommBadArbFlag; + } + else + { + ; + } + + return ret; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManage.h b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManage.h new file mode 100644 index 0000000..653c2cb --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManage.h @@ -0,0 +1,248 @@ +/****************************************************************************** +** ļ: AxisAssertManage.h +** : ģ飬ģaam +*******************************************************************************/ +#ifndef AXIS_ASSERT_MANAGE_H_ +#define AXIS_ASSERT_MANAGE_H_ +#include "AxisAssertDefine.h" +#include "ELMDataPrepare.h" + +/** + * @brief ʼϢ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_InitAxisAssert(void); + + +/** + * @brief ͨȡϢ + * @param[in] + * @param[out] + * @return + * @note + */ +const AxisAsserStruct* aam_GetAxisAssertInfo(UINT16 acIndex); + + +/** + * @brief гļ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_SetEnvelopeEnterType(UINT16 acIndex,UINT8 type,UINT16 trainID); + + +/** + * @brief úóͨ־λ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_SetPassTrainFlag(UINT16 acIndex,UINT16 trainID); + + +/** + * @brief ʱλ + * @param[in] UINT16 acIndex + * @param[in] UINT8 maxTimes ռõеʱ + * @param[out] + * @return + * @note + */ +void aam_AddRedunTime(UINT16 acIndex,UINT8 maxTimes); + +/** + * @brief ü״̬ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_SetAxisStatus(UINT16 acIndex,UINT8 status); + + +/** + * @brief ָϢ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_SetAxisAssert(UINT16 acIndex,const AxisAsserStruct* pBuff); + + +/** + * @brief ָϢ洢ռ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ResetAxisAssertByACIndex(UINT16 acIndex); + + +/** + * @brief óͨ־λ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_ClearPassTrainFlag(UINT16 acIndex); + + +/** + * @brief ʱλ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_ClearRedunTime(UINT16 acIndex); + +/** + * @brief ϳͷϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ClearHeadEnterTrainId(UINT16 acIndex); + +/** + * @brief ϳͷϢָгϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ClearHeadEnterIdForTrain(UINT16 acIndex,UINT16 trainId); + +/** + * @brief ϳβϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ClearTailEnterTrainId(UINT16 acIndex); + + +/** + * @brief ϳβϢָгϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_ClearTailEnterIdForTrain(UINT16 acIndex,UINT16 trainId); + +/** + * @brief þͷARB⴦־ + * @param[in] UINT8 flag ־ + * @param[out] + * @return + * @note + */ +void aam_SetInitEndlineFlag(UINT8 flag); + + +/** + * @brief ȡͷARB⴦־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetInitEndlineFlag(void); + + +/** + * @brief ȡóͨ־λ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetPassTrainFlag(UINT16 acIndex); + + +/** + * @brief ȡ״̬ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetAxisStatus(UINT16 acIndex); + + +/** + * @brief ȡʱ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetRedunTime(UINT16 acIndex); + + +/** + * @brief ȡгͷ־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetHeadEnterFlag(UINT16 acIndex,UINT16 trainID); + +/** + * @brief ȡгβ־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetTailEnterFlag(UINT16 acIndex,UINT16 trainID); + +/* +* ȡָIDɷARB־ +* ˵ const UINT16 acIndex, +* ֵ 0x55 ARB 0xaa ARB +* Create: fan 2024/10/14 +*/ +UINT8 aam_GetAxisRedunCanArbFlag(const UINT16 acIndex); +/* +* ָIDɷARB־ +* ˵ const UINT16 acIndex, +* const UINT8 redunOverArbFlag, ɷARB־ +* ֵ +* Create: fan 2024/10/14 +*/ +void aam_SetAxisRedunCanArbFlag(const UINT16 acIndex, const UINT8 redunOverArbFlag); + +/* +* ָIDμͨжϿARB־ +* ˵const UINT16 acIndex +* const UINT8 cCommBadArbFlag ͨжϿARB־ +* ֵ +* Created By LQ 2025.02.24 +*/ +void aam_SetAxisCommBadArbFlag(const UINT16 acIndex, const UINT8 cCommBadArbFlag); + +/* +* ȡָIDμͨжϿARB־ +* ˵const UINT16 acIndex +* ֵ0x55 Ч +* 0xAA Ч +* Created By LQ 2025.02.24 +*/ +UINT8 aam_GetAxisCommBadArbFlag(const UINT16 acIndex); + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManageAPI.c b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManageAPI.c new file mode 100644 index 0000000..48315bd --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManageAPI.c @@ -0,0 +1,2057 @@ +#include "AxisAssertManageAPI.h" +#include "AxisAssertManage.h" +#include "AxisAssertDataPrepare.h" +#include "EnvelopeManageAPI.h" +#include "dsuEmapDefine.h" +#include "DeviceDataManage.h" + +/*================================̬==============================*/ +static UINT8 aam_CreatTempUKTEnvelope(UINT16 acID, UINT8 Dir ,EnvelopeStruct *pEnvelope); /* һʱUKT */ +static UINT8 aam_SearchNearestTrainInNextAC(UINT16 baseACID, UINT8 Dir, UINT8 envelpeCnt, const UINT16* envelopeIds); /* ȡڼϵгӽ */ +static UINT8 aam_AxisErrorJudge(UINT16 acID,UINT16 acIndex); /* ж */ +static void aam_ProessPassTrainFlag(UINT16 acid, UINT16 acIndex,UINT16 trainID,UINT16 supicTrainid); /* óͨ־λ*/ +static void aam_InitEndLinePassFlag(void); /* ͷARB⴦*/ + +/** + * @brief һʱUKT + * @param[in] UINT16 acID ID + * UINT8 Dir 緽 + * @param[out] EnvelopeStruct* pEnvelope İ + * @return 1 ɹ + * 0 ʧ + */ +static UINT8 aam_CreatTempUKTEnvelope(UINT16 acID, UINT8 Dir, EnvelopeStruct *pEnvelope) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelope, ret, 0x80000000u); + ASSERT_RET_VALUE((EMAP_SAME_DIR != Dir) && (EMAP_CONVER_DIR != Dir), ret, 0x40000000u); + + ret = elm_CreatTempUKTEnvelope(acID, Dir, pEnvelope); + + return ret; +} + + +/** + * @brief ̬ȡڼϵгӽ + * @param[in] + * @param[out] + * @return + * @note ע˺֧baseACIDϴڰ磬ڿ޷ѯɹ + */ +static UINT8 aam_SearchNearestTrainInNextAC(UINT16 baseACID, UINT8 Dir, UINT8 envelpeCnt, const UINT16* envelopeIds) +{ + /*- ֲ */ + UINT8 ret = AAM_BAD_NEAR; + UINT8 funRtn = CI_ERROR; + EnvelopeStruct tempEnvelope = {0u}; + UINT16 preEnvelope = 0u; + UINT16 backEnvelope = 0u; + UINT32 errorCode = 0u; + const EnvelopeStruct* pTempEnvelope = NULL; + ELM_AxisLocStruct tmpAcLoc = { 0u }; + + /*- ڲУ */ + ASSERT_RET_VALUE(NULL == envelopeIds,ret,0x80000000u); + ASSERT_RET_VALUE(SECTION_REL_ENVELOPE_SUM_MAX == envelpeCnt,ret,0x40000000u); + ASSERT_RET_VALUE((EMAP_SAME_DIR != Dir) && ((UINT8)EMAP_CONVER_DIR != Dir),ret,0x20000000u); + + /** ڻ׼ϴ*/ + funRtn = aam_CreatTempUKTEnvelope(baseACID,Dir,&tempEnvelope); + + /** жǷ񴴽ɹ */ + if (CI_SUCCESS == funRtn) + { + /** ѯǰ */ + funRtn = elm_GetNearestBaseOnEnvelope(&tempEnvelope,envelopeIds,envelpeCnt,&preEnvelope,&backEnvelope); + + if (CI_ERROR == funRtn) + { + ret = AAM_BAD_NEAR; + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x0800000u); + AAM_LOG_LOC(AAM_LOG_ERROR,"errno:0x%08x info:Search NearestTrain InNextAC error.",errorCode); + } + else + { + /** Ϊʱ޸˷򣬹ֻҪϵǰ*/ + if (0u == preEnvelope) + { + /** ˵޳*/ + ret = AAM_NO_TRAIN_NEAR; + } + else + { + /** ͨIDѯϢ */ + pTempEnvelope = elm_GetEnvelopeInfoByID(preEnvelope); + funRtn = aam_PrepareACLoc(baseACID, Dir, &tmpAcLoc); + if ((NULL != pTempEnvelope) && (CI_SUCCESS == funRtn)) + { + funRtn = aam_PrepareTwoPointsSameDir(tmpAcLoc.endPos, pTempEnvelope->startPos); + } + else + { + ; /* do nothing */ + } + + if ((NULL == pTempEnvelope) || (CI_ERROR == funRtn)) + { + /** ѯݴ󣬵ȫ */ + ret = AAM_BAD_NEAR; + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x10000000u); + AAM_LOG_LOC(AAM_LOG_ERROR,"errno:0x%08x info:Search NearestTrain ELM%d,ELM info error.",errorCode,preEnvelope) + } + else if (((TYPE_CT_ENVELOPE == pTempEnvelope->envelopeType) || (TYPE_UCT_ENVELOPE == pTempEnvelope->envelopeType)) && + (FLAG_SET == funRtn) && (0u == pTempEnvelope->tailTrainID)) + { + /** óԶ */ + ret = AAM_GOOD_FAR_AWAY; + + } + else if (((TYPE_CT_ENVELOPE == pTempEnvelope->envelopeType) || (TYPE_UCT_ENVELOPE == pTempEnvelope->envelopeType)) && + (FLAG_UNSET == funRtn) && (0u == pTempEnvelope->headTrainID)) + { + /** óӽ */ + ret = AAM_GOOD_NEAR; + } + else + { + /** ӽ */ + ret = AAM_BAD_NEAR; + } + } + } + } + else + { + /** ѯݴ󣬵ȫ */ + ret = AAM_BAD_NEAR; + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x10000000u) + AAM_LOG_LOC(AAM_LOG_ERROR,"errno:0x%08x info:Create AC%d of Temp UKT Envelope error.",errorCode,baseACID) + } + + /** */ + return ret; +} + + +/** + * @brief ѯӽ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_SearchNearbyTrainType(UINT16 baseACID, UINT8 Dir, UINT8 acCnt, UINT16 acID[AC_MAXCNT_IN_SWITCH]) +{ + /*- ֲ */ + UINT8 ret = AAM_BAD_NEAR; + UINT8 funRtn = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 cycle = 0u; + UINT8 cycleELM = 0u; + UINT8 cycleELMAC = 0u; + UINT8 acStatus = ELM_AC_OCC; + UINT16 tmpPhyid = 0u; + UINT8 phyRelACCnt = 0u; + UINT8 i = 0U; + UINT16 wTrainId = 0U; + const UINT16* phyRelACIDs = NULL; + const EnvelopeStruct* pTempEnvelope = NULL; + UINT8 acRelEnvelopeCnt = 0u; + UINT16 envelopeIds[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + + /** ѯ׼ */ + tmpPhyid = aam_PrepareACBelongPhyid(baseACID); + phyRelACIDs = aam_PreparePhyRelACIds(tmpPhyid,&phyRelACCnt); + + /** ڲУ */ + ASSERT_RET_VALUE(acCnt > AC_MAXCNT_IN_SWITCH,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == acID,ret,0x40000000u); + ASSERT_RET_VALUE((EMAP_SAME_DIR != Dir) && ((UINT8)EMAP_CONVER_DIR != Dir),ret,0x20000000u); + ASSERT_RET_VALUE((NULL == phyRelACIDs) || (0u == phyRelACCnt),ret,0x10000000u); + + + + if(0u == acCnt) + { + /** ˵ΪͷߣΪ޳ӽ */ + ret = AAM_NO_TRAIN_NEAR; + } + else + { + for (cycle = 0u;cycle < acCnt;cycle++) + { + /** ȡ״̬ */ + acStatus = aam_PrepareACStatus(acID[cycle]); + + if (ELM_AC_FREE == acStatus) + { + /** ޳ӽ*/ + ret = AAM_NO_TRAIN_NEAR; + } + else + { + /** ȡİ */ + acRelEnvelopeCnt = elm_GetEnvelopeIDsInAC(acID[cycle],envelopeIds); + + /** гд */ + if (0u == acRelEnvelopeCnt) + { + /** ˵޳ӽڼҲҪUT */ + ret = AAM_NO_TRAIN_NEAR; + } + else if (acRelEnvelopeCnt < SECTION_REL_ENVELOPE_SUM_MAX) + { + /** жеİ磬а˻׼Σӳٴȳκٴǰϵѯʧܵ´ */ + for(cycleELM = 0u;cycleELM < acRelEnvelopeCnt;cycleELM++) + { + pTempEnvelope = elm_GetEnvelopeInfoByID(envelopeIds[cycleELM]); + + if ((NULL == pTempEnvelope) || + ((TYPE_CT_ENVELOPE != pTempEnvelope->envelopeType) && (TYPE_UCT_ENVELOPE != pTempEnvelope->envelopeType))) + { + /** ѯ*/ + ret = AAM_BAD_NEAR; + break; + } + else + { + for (cycleELMAC = 0u; cycleELMAC < pTempEnvelope->ACCnt;cycleELMAC++) + { + funRtn = aam_PrepareInUINT16Array(pTempEnvelope->ACID[cycleELMAC],phyRelACIDs,phyRelACCnt); + + /** ڻ׼Σغóռãȳٴ*/ + ASSERT_BREAK(CI_SUCCESS == funRtn,errorCode,0x00000000u); + } + + if (cycleELMAC == pTempEnvelope->ACCnt) + { + /** 粻ڻ׼Σ*/ + } + else + { + /** ڻ׼Σغóռ */ + ret = AAM_GOOD_OCC; + break; + } + } + } + + if (cycleELM == acRelEnvelopeCnt) + { + /** ްٻ׼ڣѯһ */ + ret = aam_SearchNearestTrainInNextAC(baseACID,Dir,acRelEnvelopeCnt,envelopeIds); + } + else + { + /* ڻ׼ */ + } + } + else + { + /** ѯûͨ */ + ret = AAM_BAD_NEAR; + } + } + + /**˵лΪӽѭ */ + ASSERT_BREAK(AAM_BAD_NEAR == ret,errorCode,0x10000000u); + } + } + + return ret; +} + + +/** + * @brief ̬ж + * @param[in] UINT16 acID, ID + * @param[in] UINT16 acIndex IDڲ + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + */ +static UINT8 aam_AxisErrorJudge(UINT16 acID,UINT16 acIndex) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT8 chNearbyCheck = CI_ERROR; + UINT8 acSameCnt = 0u; + UINT16 acSameID[AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT8 acConvertCnt = 0u; + UINT16 acConvertID[AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT32 errorCode = 0u; + UINT8 sameTrainType = AAM_BAD_NEAR; + UINT8 convertTrainType = AAM_BAD_NEAR; + UINT8 tmpRedunTime = 0u; + UINT8 tmppassTrainType = 0u; + UINT8 tmpACStatus = AAM_STATUS_OCC; + UINT8 maxRedunTimes = 0u; + UINT8 chSwitch = 0u; + UINT32 dwArbCheckDistance = 0U; /*RC16.0 ϵͳARB*/ + UINT8 chRedunArbFlag = REDUN_OVER_ARB_NO; /*жʱɷARB־*/ + UINT8 dwCiAndAxleTransBadEnsureCnt = 0U; /*жͨж*/ + UINT32 dwCurAxleOccStartCycNum = 0U; /*ռʼ*/ + UINT8 ii = 0U; + UINT32 dwNearAxleOccStartCycNum = 0U; /*ڼռʼ*/ + UINT8 cAcRelEnvelopeCnt = 0U; + EnvelopeStruct strEnvelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX] = { 0U }; + UINT8 cOccCheckFlag = CI_ERROR; + UINT16 wCurRelPhySecId = 0U; + UINT16 wNearRelPhySecId = 0U; + UINT8 cAxisCommBadArbFlag = AAM_COMM_BAD_ARB_NO; + + chSwitch = aam_PrepareArbSwitch(); + if (CI_SUCCESS == chSwitch) + { + ; + } + else + { + funRtn=aam_ClearPassTrainFlag(acIndex); + } + dwArbCheckDistance = (UINT32)(GetArbCheckAxisLen()*100U); + if (0U == dwArbCheckDistance) + { + debug_infor_printf((const)"aam_AxisErrorJudge acID: %d Fail: ArbCheckDistance =%d .\n", acID, dwArbCheckDistance); + } + else + { + /** ѯǰ*/ + acSameCnt = aam_PrepareAdjacentAC(acID, EMAP_SAME_DIR, acSameID); + + /** ѯ󷽼 */ + acConvertCnt = aam_PrepareAdjacentAC(acID, EMAP_CONVER_DIR, acConvertID); + + /** ȡռñгʱ */ + maxRedunTimes = aam_PrepareRedunTimes(); + if ((UINT8_MAX == acSameCnt) || (UINT8_MAX == acConvertCnt)) + { + /** ܲʧܣݴ */ + /** ֮ǰĺóͨ־λ*/ + funRtn &= aam_ClearPassTrainFlag(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x80000000u); + + /** ʱλ */ + funRtn = aam_ClearRedunTime(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x40000000u); + ASSER_DEBUG(0u != errorCode, AAM_LOG(AAM_LOG_FATAL, "info:Clear AC%d RedunTime becasue pre/back error.\n", acID)); + } + else + { + /** 鸽״̬*/ + chNearbyCheck = aam_CheckNearbyTrainType(acID); + + /** ǰᳵӽ*/ + sameTrainType = aam_SearchNearbyTrainType(acID, EMAP_SAME_DIR, acSameCnt, acSameID); + + /** 󷽼ᳵӽ */ + convertTrainType = aam_SearchNearbyTrainType(acID, EMAP_CONVER_DIR, acConvertCnt, acConvertID); + + /** жڷΧڼỵռʱͨ */ + if ((CI_ERROR == chNearbyCheck)) + { + /* ӽ ڼ޳ӽ ʱ*/ + if ((AAM_BAD_NEAR == sameTrainType) || (AAM_BAD_NEAR == convertTrainType)) + { + /** ֮ǰʱλ */ + funRtn = aam_ClearPassTrainFlag(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + funRtn = aam_ClearRedunTime(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + aam_SetAxisStatus(acIndex, AAM_STATUS_OCC); + AAM_LOG(AAM_LOG_FATAL, "info:AC%d not match ARB condition, NearByTrainCheck:%d.\n", acID, chNearbyCheck); + } + else + { + /** ʱλ1*/ + aam_AddRedunTime(acIndex, maxRedunTimes); + + /*ñ־λ*/ + aam_SetAxisRedunCanArbFlag(acIndex, REDUN_OVER_ARB_NO); + } + } + else + { + /** ʱλ1*/ + aam_AddRedunTime(acIndex, maxRedunTimes); + } + + /** ϵж */ + tmpRedunTime = aam_GetRedunTime(acIndex); + tmppassTrainType = aam_GetPassTrainFlag(acIndex); + tmpACStatus = aam_GetAxisStatus(acIndex); + cAxisCommBadArbFlag = aam_GetAxisCommBadArbFlag(acIndex); /*ȡμϵͳͨжARB־*/ + + /** ARBж */ + if ((AAM_CT_PASS == tmppassTrainType) || (AAM_COMM_BAD_ARB_YES == cAxisCommBadArbFlag)) + { + if (AAM_STATUS_ARB == tmpACStatus) + { + /** ѾARB Χ ʧܲӦάARB*/ + if (CI_ERROR == chNearbyCheck) + { + /** ֮ǰʱλ */ + funRtn = aam_ClearPassTrainFlag(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + funRtn = aam_ClearRedunTime(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + aam_SetAxisStatus(acIndex, AAM_STATUS_OCC); + AAM_LOG(AAM_LOG_FATAL, "info:AC%d keep ARB Fail, NearByTrainCheck:%d.\n", acID, chNearbyCheck); + } + else + { + cOccCheckFlag = CI_SUCCESS; + dwCiAndAxleTransBadEnsureCnt = GetCiAndAxleTransBadEnsureCnt(); /*ȡжͨжϳʱ*/ + wCurRelPhySecId = GetAxisSecRelativePhySecId(acID); + if (0U != wCurRelPhySecId) + { + dwCurAxleOccStartCycNum = GetSecColOccupyStartCycNum(wCurRelPhySecId); + for (ii = 0U; ii < acSameCnt; ii++) + { + wNearRelPhySecId = GetAxisSecRelativePhySecId(acSameID[ii]); + if (0U != wNearRelPhySecId) + { + cAcRelEnvelopeCnt = elm_GetEnvelopeInAC(acSameID[ii], strEnvelopeInfo); + dwNearAxleOccStartCycNum = GetSecColOccupyStartCycNum(wNearRelPhySecId); + if (((0U == cAcRelEnvelopeCnt) || (SECTION_REL_ENVELOPE_SUM_MAX == cAcRelEnvelopeCnt)) + && ((dwCurAxleOccStartCycNum + dwCiAndAxleTransBadEnsureCnt) < dwNearAxleOccStartCycNum)) + { + cOccCheckFlag = CI_ERROR; /*ڼްռʼʱ䳬ˡͨжϳʱжʱ䡱*/ + } + else + { + /*ڼռʼδͨжϳʱжʱ䡱*/ + } + } + else + { + cOccCheckFlag = CI_ERROR; + } + + if (CI_ERROR == cOccCheckFlag) + { + break; + } + else + { + ; + } + } + + if (CI_SUCCESS == cOccCheckFlag) + { + for (ii = 0U; ii < acConvertCnt; ii++) + { + wNearRelPhySecId = GetAxisSecRelativePhySecId(acConvertID[ii]); + if (0U != wNearRelPhySecId) + { + cAcRelEnvelopeCnt = elm_GetEnvelopeInAC(acConvertID[ii], strEnvelopeInfo); + dwNearAxleOccStartCycNum = GetSecColOccupyStartCycNum(wNearRelPhySecId); + if (((0U == cAcRelEnvelopeCnt) || (SECTION_REL_ENVELOPE_SUM_MAX == cAcRelEnvelopeCnt)) + && ((dwCurAxleOccStartCycNum + dwCiAndAxleTransBadEnsureCnt) < dwNearAxleOccStartCycNum)) + { + cOccCheckFlag = CI_ERROR; /*ڼްռʼʱ䳬ˡͨжϳʱжʱ䡱*/ + } + else + { + /*ڼռʼδͨжϳʱжʱ䡱*/ + } + } + else + { + cOccCheckFlag = CI_ERROR; + } + + if (CI_ERROR == cOccCheckFlag) + { + break; + } + else + { + ; + } + } + } + else + { + /*ʧܣ*/ + } + } + else + { + cOccCheckFlag = CI_ERROR; + } + + if (CI_SUCCESS != cOccCheckFlag) + { + /** ֮ǰʱλ */ + funRtn = aam_ClearPassTrainFlag(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00800000U); + + funRtn = aam_ClearRedunTime(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00400000U); + + aam_SetAxisStatus(acIndex, AAM_STATUS_OCC); + AAM_LOG(AAM_LOG_FATAL, "info:AC%d Keep ARB Fail Because Of Near Sec Occ\n", acID); + } + else + { + /*ռüͨάARB״̬*/ + } + } + } + else if (tmpRedunTime >= maxRedunTimes) + { + /** ʱ䵽޺ó ü״̬ΪARB*/ + if ((AAM_GOOD_OCC == sameTrainType) || (AAM_GOOD_OCC == convertTrainType)) + { + /** ҪʱARB˸*/ + funRtn = aam_ClearPassTrainFlag(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000u); + + aam_AddRedunTime(acIndex, maxRedunTimes); + /** λа糵βռã ĿõλΪARBȳж*/ + AAM_LOG(AAM_LOG_FATAL, "info:AC%d not ARB because of CT oCC,preTrainType:%d.tailTrainType:%d.\n", acID, sameTrainType, convertTrainType); + } + else + { + /*ڹARBʧ ΪUT*/ + chRedunArbFlag = aam_GetAxisRedunCanArbFlag(acIndex); + + if (REDUN_OVER_ARB_YES== chRedunArbFlag) + { + aam_SetAxisStatus(acIndex, AAM_STATUS_ARB); + AAM_LOG(AAM_LOG_FATAL, "info:ac%d ARB Redun:ARB.\n", acID); + } + else + { + /*ΪUT ʱ*/ + funRtn = aam_ClearPassTrainFlag(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + funRtn = aam_ClearRedunTime(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + aam_SetAxisStatus(acIndex, AAM_STATUS_OCC); + AAM_LOG(AAM_LOG_FATAL, "info:ac%d UT Redun:UT.\n", acID); + } + } + } + else + { + /** ARB */ + AAM_LOG(AAM_LOG_FATAL, "info:ac%d ARB Redun:%d.\n", acID, tmpRedunTime); + } + } + else + { + if (AAM_STATUS_OCC == tmpACStatus) + { + /** ΪUTռã*/ + } + else if (tmpRedunTime >= maxRedunTimes) + { + /** ʱ䵽ü״̬ΪARB*/ + if ((AAM_GOOD_OCC == sameTrainType) ||(AAM_GOOD_OCC == convertTrainType) ) + { + /** ҪʱUT˸*/ + funRtn = aam_ClearPassTrainFlag(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x04000000u); + + aam_AddRedunTime(acIndex, maxRedunTimes); + /** λа糵βռã ĿõλΪUTȳж*/ + AAM_LOG(AAM_LOG_FATAL, "info:AC%d not UT because of CT oCC,preTrainType:%d.tailTrainType:%d.\n", acID, sameTrainType, convertTrainType); + } + else + { + aam_SetAxisStatus(acIndex, AAM_STATUS_OCC); + AAM_LOG(AAM_LOG_FATAL, "info:ac%d UT Redun:UT.\n", acID); + } + } + else + { + /** UT */ + AAM_LOG(AAM_LOG_FATAL, "info:ac%d UT Redun:%d.\n", acID, tmpRedunTime); + } + } + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + ASSER_DEBUG(0u != errorCode, AAM_LOG_LOC(AAM_LOG_ERROR, "errno:0x%08x info:Assert AC%d index%d error.", errorCode, acID, acIndex)); + } + return ret; +} + + +/** + * @brief ̬óͨ־λ + * @param[in] + * @param[out] + * @return + * @note + */ +static void aam_ProessPassTrainFlag(UINT16 acid, UINT16 acIndex,UINT16 trainID,UINT16 supicTrainid) +{ + /*-ֲ */ + UINT8 headEnterFlag = CI_ERROR; + UINT8 tailEnterFLag = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 isLinkingAxle = CI_ERROR; + UINT8 isUseNvram = CI_ERROR; + + /** һǷͷ */ + headEnterFlag = aam_GetHeadEnterFlag(acIndex,trainID); + + /** ڶǷβ */ + tailEnterFLag = aam_GetTailEnterFlag(acIndex,trainID); + + /** жϼǷΪ */ + isLinkingAxle = aam_PrepareACIsLinkingAxle(acid); + + /*жгδʹNvramλ*/ + isUseNvram = GetTrainNvramPosFlag(trainID); + + /** úóͨ */ + if ((CI_SUCCESS == headEnterFlag) && (CI_SUCCESS == tailEnterFLag) + && (0u == supicTrainid) && (CI_ERROR == isLinkingAxle)&&(TRAIN_NVRAM_POS_FLAG_NO == isUseNvram)) + { + aam_SetPassTrainFlag(acIndex,trainID); + AAM_LOG(AAM_LOG_FATAL,"info:Add acIndex:%d CT train%d pass flag.\n",acIndex,trainID); + } + else + { + /** ޷úóͨ */ + errorCode = errorCode + 0x80000000u; + AAM_LOG_LOC(AAM_LOG_ERROR,"errno:0x%08x info:Add acIndex:%d CT train%d pass flag error,%d-%d-%d-%d.\n", \ + errorCode,acIndex,trainID,headEnterFlag,tailEnterFLag,supicTrainid,isLinkingAxle); + } + + /** IJϸóϢ */ + aam_ClearHeadEnterIdForTrain(acIndex,trainID); + aam_ClearTailEnterIdForTrain(acIndex,trainID); +} + + +/** + * @brief ̬ͷARB⴦ + * @param[in] + * @param[out] + * @return + * @note + */ +static void aam_InitEndLinePassFlag(void) +{ + /*- ֲ */ + UINT8 switchFlag = CI_ERROR; + UINT8 arbSwitch = CI_ERROR; + UINT8 InitEndlineFlag = AAM_END_LINE_INIT; + UINT16 acCnt = 0u; + UINT16 cycle = 0u; + const UINT16* pACIdBuff = NULL; + UINT8 acStatus = ELM_AC_OCC; + UINT8 OCId = 0u; + UINT8 funRtn = ELM_BELONG_OWNER; + UINT16 PrePhyid = 0u; + UINT16 BackPhyid = 0u; + UINT8 isLinkingAxle = CI_SUCCESS; + UINT16 curPhyid = 0u; + UINT8 NextPhyStatus = SECTION_OCCUPY_YES; + UINT8 curPhyStatus = SECTION_OCCUPY_YES; + UINT16 acIndex = 0u; + UINT8 chObjNum = 0u; + const UINT8 * pObjIdBuff = NULL; + UINT8 chComStatus = AAM_COM_STATUS_ERROR; + UINT8 chObjIndex = 0u; + UINT32 errorCode = 0u; + UINT8 chAsSwitch = 0u; + + /** ȡͷARB־ */ + switchFlag = aam_PrepareInitCTPassFlagSwitch(); + arbSwitch = aam_PrepareArbSwitch(); + + if ((CI_ERROR == switchFlag) || (CI_ERROR == arbSwitch)) + { + /** ܿδ账 */ + } + else + { + /** ȡͷARB⴦־ */ + InitEndlineFlag = aam_GetInitEndlineFlag(); + chAsSwitch = aam_PrepareAsSwitch(); + if (CI_ERROR == chAsSwitch) + { + /* ϵͳܹرգжOCȫͨţʼͷ */ + chObjNum = aam_PrepareComOcId(&pObjIdBuff); + } + else + { + /* ϵͳܴ򿪣жмϵͳͨţʼͷ */ + chObjNum = aam_PrepareComAsId(&pObjIdBuff); + } + if ((0u == chObjNum) || (NULL == pObjIdBuff)) + { + /** ܷ֧*/ + errorCode = errorCode + 0x10000000u; + } + else + { + for (chObjIndex = 0u; chObjIndex < chObjNum; chObjIndex++) + { + if (CI_ERROR == chAsSwitch) + { + chComStatus = aam_PrepareOcCommStatus(pObjIdBuff[chObjIndex]); + } + else + { + chComStatus = aam_PrepareAsCommStatus(pObjIdBuff[chObjIndex]); + } + ASSERT_BREAK(AAM_COM_STATUS_ERROR == chComStatus, errorCode, 0x20000000u); + } + } + + if ((AAM_END_LINE_UNINIT == InitEndlineFlag) && (0u == errorCode)) + { + /** ȡϢ */ + acCnt = aam_PrepareACBuffIndexs(&pACIdBuff); + + if (NULL == pACIdBuff) + { + /** ܷ֧*/ + } + else + { + /** жǷ뾡ͷARBúóͨʱΧڼηȫռʱ*/ + for (cycle = 0u; cycle < acCnt;cycle++) + { + /** жϼǷڱOC */ + funRtn = aam_PrepareACIsSelf(pACIdBuff[cycle],&OCId); + + /** ȡ״̬ */ + acStatus = aam_PrepareACStatus(pACIdBuff[cycle]); + + if ((ELM_BELONG_OWNER == funRtn) && (ELM_AC_FREE == acStatus)) + { + /** ҵмᣬ˵϶ɼռ*/ + break; + } + else + { + /** */ + } + } + + if (cycle == acCnt) + { + /** ˵ȫռãδʱ*/ + } + else + { + + /** þͷARB⴦־ */ + aam_SetInitEndlineFlag(AAM_END_LINE_INIT); + + for (cycle = 0u; cycle < acCnt;cycle++) + { + /** жϼǷڱOC */ + funRtn = aam_PrepareACIsSelf(pACIdBuff[cycle],&OCId); + + if (ELM_BELONG_OWNER == funRtn) + { + /** ѯε*/ + funRtn = aam_PreparePreAndBackPhySecOFAC(pACIdBuff[cycle],&PrePhyid,&BackPhyid); + + /** жǷΪͷ */ + if ((CI_SUCCESS == funRtn) && ((UINT16_MAX == PrePhyid) || (UINT16_MAX == BackPhyid))) + { + /** жϼǷΪ */ + isLinkingAxle = aam_PrepareACIsLinkingAxle(pACIdBuff[cycle]); + + if (CI_SUCCESS == isLinkingAxle) + { + /** Ϊߣ*/ + } + else + { + /** ȡἰε״̬*/ + curPhyid = aam_PrepareACBelongPhyid(pACIdBuff[cycle]); + curPhyStatus = aam_PreparePhyOccStatus(curPhyid); + NextPhyStatus = (UINT16_MAX == PrePhyid) ? aam_PreparePhyOccStatus(BackPhyid) : aam_PreparePhyOccStatus(PrePhyid); + + if ((SECTION_OCCUPY_NO == curPhyStatus) && (SECTION_OCCUPY_NO == NextPhyStatus)) + { + /** ȡ */ + acIndex = aam_PrepareACIndex(pACIdBuff[cycle]); + aam_SetPassTrainFlag(acIndex,0u); + AAM_LOG(AAM_LOG_FATAL,"info:Set AC%d CI pass Flag.\n",pACIdBuff[cycle]); + } + else + { + /** */ + AAM_LOG(AAM_LOG_FATAL,"info:Can't Set AC%d CI pass Flag becasue %d-%d,%d-%d-%d.\n",pACIdBuff[cycle],curPhyid,curPhyStatus,PrePhyid,BackPhyid,NextPhyStatus); + } + } + } + else + { + /** Ǿͷߣ*/ + } + } + else + { + /** DZOCᣬ */ + } + } + } + } + } + else + { + /** ͷARB⴦־λOCδȫͨ */ + } + } +} + + + +/** + * @brief ģʼ + * @return CI_ERROR ʼɹ + CI_SUCCESS ʼʧ + * @note + */ +UINT8 aam_Init(void) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT32 errorCode = 0u; + + /** ʼϢ*/ + funRtn = aam_InitAxisAssert(); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x80000000u); + + /** þͷARB⴦־ */ + aam_SetInitEndlineFlag(AAM_END_LINE_UNINIT); + + /** ÷ֵ */ + ASSER_DEBUG(0u != errorCode,AAM_LOG_LOC(AAM_LOG_ERROR,"errno:0x%08x info:Axis Assert Init error.",errorCode)); + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + + +/** + * @brief ģ鴦 + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_MainProcess(void) +{ + /*- ֲ*/ + UINT8 funRtn = ELM_BELONG_OWNER; + UINT8 acStatus = ELM_AC_OCC; + UINT16 acCnt = 0u; + UINT16 cycle = 0u; + UINT8 OCId = 0u; + UINT16 acIndex = 0u; + const UINT16* pACIdBuff = NULL; + UINT32 errorCode = 0u; + UINT8 acRelEnvelopeCnt = 0u; + EnvelopeStruct envelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + UINT8 chPreAcStatus = ELM_AC_OCC; + UINT8 ii = 0U; + UINT8 chCTcheck = CI_ERROR; + + /** ȡϢ */ + acCnt = aam_PrepareACBuffIndexs(&pACIdBuff); + + if (NULL == pACIdBuff) + { + ASSER_ERROR(NULL == pACIdBuff,errorCode,0x80000000u); + } + else + { + /** ͷARB⴦*/ + aam_InitEndLinePassFlag(); + + /*ϵͳͨжARB⴦*/ + aam_AxisCommBadArbPro(); + + for (cycle = 0u; cycle < acCnt; cycle++) + { + /** жϼǷڱOC */ + funRtn = aam_PrepareACIsSelf(pACIdBuff[cycle], &OCId); + + if (ELM_BELONG_OWNER == funRtn) + { + /** ȡ״̬ */ + acStatus = aam_PrepareACStatus(pACIdBuff[cycle]); + + /** ȡİ */ + acRelEnvelopeCnt = elm_GetEnvelopeInAC(pACIdBuff[cycle], envelopeInfo); + + /** ȡ */ + acIndex = aam_PrepareACIndex(pACIdBuff[cycle]); + ASSERT_BREAK(UINT16_MAX == acIndex, errorCode, 0x40000000u); + + if ((ELM_AC_OCC == acStatus) && (0u != acRelEnvelopeCnt)) + { + chPreAcStatus = aam_GetAxisStatus(acIndex); + chCTcheck = CI_SUCCESS; + for (ii = 0U; ii < acRelEnvelopeCnt; ii++) + { + if (((TYPE_UCT_ENVELOPE == envelopeInfo[ii].envelopeType) || (TYPE_UKT_ENVELOPE == envelopeInfo[ii].envelopeType)) + ||(0U != envelopeInfo[ii].tailTrainID) || (0U != envelopeInfo[ii].headTrainID)) + { + /*سUCT ǰ˴ڿ*/ + chCTcheck = CI_ERROR; + break; + } + } + if ((AAM_STATUS_ARB != chPreAcStatus) || (CI_ERROR == chCTcheck)) + { + /* ˵ARBгռãռðCT CT ֮ǰʱλ */ + funRtn = aam_ClearRedunTime(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + aam_SetAxisStatus(acIndex, AAM_STATUS_OCC); + } + else + { + /*ARB ǰ˿ɵCTгʻüΣάARB״̬*/ + funRtn = aam_AxisErrorJudge(pACIdBuff[cycle], acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + } + else if ((ELM_AC_OCC == acStatus) && (0u == acRelEnvelopeCnt)) + { + /** ˵ռ޳ARBж*/ + funRtn = aam_AxisErrorJudge(pACIdBuff[cycle], acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + else + { + /** ֮ǰʱλü */ + funRtn = aam_ClearRedunTime(acIndex); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000u); + aam_SetAxisStatus(acIndex, AAM_STATUS_FREE_OR_REDUN); + aam_SetAxisCommBadArbFlag(acIndex, AAM_COMM_BAD_ARB_NO); /*УüͨжARB־Ч*/ + } + } + else + { + /** ڱOC */ + } + + /** жǷ */ + ASSERT_BREAK(0u != errorCode, errorCode, 0x00000000u); + } + } + + /** */ + if (0u != errorCode) + { + /** ֱ³ʼ*/ + funRtn = aam_Init(); + + if (CI_ERROR == funRtn) + { + /** 崻 */ + SetPlatOverFlag(); + ASSER_ERROR(NULL == pACIdBuff,errorCode,0x80000000u); + AAM_LOG_LOC(AAM_LOG_ERROR,"errno:0x%08x info:Axis Assert Process error.",errorCode); + } + else + { + /** ȷ³ʼִ */ + } + + AAM_LOG_LOC(AAM_LOG_ERROR,"errno:0x%08x info:Axis Assert Process error.",errorCode); + } + else + { + /** */ + } +} + +/** + * @brief ӿڣüΰ + * @param[in] UINT8 flag + * @param[in] UINT16 envelopeId ID + * @return + * @note + */ +void aam_SetEnvelopeEnterFlag(UINT8 flag,UINT16 supicTrainid, UINT16 acID,UINT16 trainId) +{ + /*- ȡͨidȡ */ + UINT16 acIndex = 0u; + UINT8 ocid = 0u; + UINT8 isSelfFlag = 0u; + UINT32 errorCode = 0u; + + UINT8 acStatus = ELM_AC_OCC; + UINT8 passFlag = AAM_UT_PASS; + + /** ȡ */ + acIndex = aam_PrepareACIndex(acID); + isSelfFlag = aam_PrepareACIsSelf(acID,&ocid); + acStatus = aam_PrepareACStatus(acID); + passFlag = aam_GetPassTrainFlag(acIndex); + + if (ELM_BELONG_OWNER == isSelfFlag) + { + if (AAM_ENVELOPE_ENTER_ERROR == flag) + { + /** ˵γUKT,óͨ־λ */ + aam_ResetAxisAssertByACIndex(acIndex); + + /** ӡά־*/ + AAM_LOG(AAM_LOG_FATAL,"info:Init assertInfo for ac%d.\n",acID); + } + else if ((AAM_ENVELOPE_HEAD_ENTER == flag) || (AAM_ENVELOPE_TAIL_ENTER == flag)) + { + if ((AAM_CT_PASS == passFlag) && (ELM_AC_OCC == acStatus) && (0u != supicTrainid)) + { + /** ǰ˻ߺ˿ɵİռã֮ǰĺóͨ־λ */ + (void)aam_ClearPassTrainFlag(acIndex); + AAM_LOG(AAM_LOG_FATAL,"info:clear acIndex:%d CT pass flag by suspic.\n",acIndex); + } + else + { + /** 账 */ + } + /** ӳͷ/β־*/ + aam_SetEnvelopeEnterType(acIndex,flag,trainId); + } + else if (AAM_ENVELOPE_TAIL_EXIT == flag) + { + /** β崦*/ + aam_ProessPassTrainFlag(acID,acIndex,trainId,supicTrainid); + } + else if (AAM_ENVELOPE_HEAD_EXIT == flag) + { + /** ͷ崦*/ + aam_ClearHeadEnterIdForTrain(acIndex,trainId); + } + else + { + /** */ + } + } + else + { + /** ӡά־*/ + ASSER_ERROR(0u == isSelfFlag,errorCode,0x80000000u); + ASSER_DEBUG(0u == isSelfFlag,AAM_LOG_LOC(AAM_LOG_FATAL,"errorCode:0x%08x info:Clear PassTrainFlag for ac%d.\n",errorCode,acID)); + /** ڱOC߲ѯ */ + aam_ResetAxisAssertByACIndex(acIndex); + } +} + +/** + * @brief ӿڣȡ״̬ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetACAssertStatus(UINT16 ACID) +{ + /*- ֲ */ + UINT8 ret = AAM_API_AC_UT; + UINT8 tmpRedunTime = 0u; + UINT8 tmppassTrainType = AAM_UT_PASS; + UINT8 tmpACStatus = AAM_STATUS_OCC; + UINT16 acIndex = 0u; + UINT8 acRelEnvelopeCnt = 0u; + EnvelopeStruct envelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX] = { 0u }; + UINT8 chRedunArbFlag = REDUN_OVER_ARB_NO; + + /** ȡ */ + acIndex = aam_PrepareACIndex(ACID); + + /** ϵж */ + tmpRedunTime = aam_GetRedunTime(acIndex); + tmppassTrainType = aam_GetPassTrainFlag(acIndex); + tmpACStatus = aam_GetAxisStatus(acIndex); + + /** ȡιİ */ + acRelEnvelopeCnt = elm_GetEnvelopeInAC(ACID, envelopeInfo); + + if (0u != acRelEnvelopeCnt) + { + ret = AAM_API_AC_UT; + } + else if (AAM_STATUS_FREE_OR_REDUN == tmpACStatus) + { + if (0u != tmpRedunTime) + { + /** ˴⴦Ŀǣڼ䣬ռãǼϳɿУֻмǰ״̬ǿУռ޳ʱŻif֧ */ + chRedunArbFlag = aam_GetAxisRedunCanArbFlag(acIndex); + if ((AAM_CT_PASS == tmppassTrainType)&&(REDUN_OVER_ARB_YES == chRedunArbFlag)) + { + ret = AAM_API_AC_REDUNARB; + } + else + { + ret = AAM_API_AC_REDUNUT; + } + } + else + { + ret = AAM_API_AC_UT; + } + } + else if(AAM_STATUS_ARB == tmpACStatus) + { + ret = AAM_API_AC_ARB; + } + else if ((AAM_STATUS_OCC == tmpACStatus) && (0u != tmpRedunTime) && (AAM_CT_PASS == tmppassTrainType) ) + { + /** ˴⴦ĿǣUTɨCTʻUT󣬼״̬ΪARB,ARB࣬˴Ϊ˷ֹUKT磬Ӷʵɨ*/ + ret = AAM_API_AC_REDUNARB; + } + else + { + ret = AAM_API_AC_UT; + } + + return ret; +} + +/** + * @brief ӿڣȡεĹ״̬ + * @param[in] UINT16 phyID + * @param[out] + * @return AAM_API_AC_ARB ARB + UINT8_MAX ηARB + * @note ιļռҶΪARBʱ򷵻ARB򷵻UT + */ +UINT8 aam_GetPhyIsARB(UINT16 phyID) +{ + UINT8 ret = UINT8_MAX; + UINT8 cycle = 0u; + UINT8 acCnt = 0u; /* ΰļ */ + const UINT16* acIDBuff = NULL; /* ΰļID */ + UINT8 ocid = 0u; + UINT8 isSelfFlag = 0u; + UINT8 ACOCCStatus = ELM_AC_OCC; + UINT8 ACAssertStatus = AAM_API_AC_UT; + UINT8 PhyOCCStatus = SECTION_OCCUPY_YES; + UINT32 errorCode = 0u; + + + isSelfFlag = aam_PreparePhyIsSelf(phyID,&ocid); + + if (ELM_BELONG_OWNER == isSelfFlag) + { + /** ȡռ״̬ */ + PhyOCCStatus = aam_PreparePhyOccStatus(phyID); + + if (SECTION_OCCUPY_YES == PhyOCCStatus) + { + /** ȡΰļ*/ + acIDBuff = aam_PreparePhyRelACIds(phyID,&acCnt); + ASSER_ERROR((NULL == acIDBuff) || (0u == acCnt),errorCode,0x80000000u); + + if (0u == errorCode) + { + /** ѯȷеļΣռҶΪARBʱ򷵻ARB򷵻UT */ + for (cycle = 0u; cycle < acCnt;cycle++) + { + ACOCCStatus = aam_PrepareACStatus(acIDBuff[cycle]); + ACAssertStatus = aam_GetACAssertStatus(acIDBuff[cycle]); + + if (ELM_AC_FREE == ACOCCStatus) + { + /** ,ü״̬ϴֵ*/ + } + else if ((ELM_AC_OCC == ACOCCStatus) && (AAM_API_AC_ARB == ACAssertStatus)) + { + /** ռΪARBʱ,ü״̬ΪARB*/ + ret = AAM_API_AC_ARB; + } + else if ((ELM_AC_OCC == ACOCCStatus) && (AAM_API_AC_REDUNARB == ACAssertStatus)) + { + /** ռΪARB */ + } + else + { + /** ռΪARBʱ,ֹͣ*/ + ret = UINT8_MAX; + break; + } + } + } + } + else + { + /** ηARB */ + } + } + else + { + /** DZOCᣬӦñãηARB */ + } + + return ret; +} + +/** + * @brief ӿڣȡóͨ־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetACPassTrainFlag(UINT16 ACID) +{ + UINT16 acIndex = 0u; + + /** ȡ */ + acIndex = aam_PrepareACIndex(ACID); + + return aam_GetPassTrainFlag(acIndex); +} + +/** + * @brief ӿڣȡӦϢַ + * @param[in] + * @param[out] + * @return + * @note + */ +const AxisAsserStruct* aam_GetAxisAssertInfoPtr(UINT16 ACID) +{ + /*- ֲ */ + UINT16 acIndex = 0u; + /** ȡ */ + acIndex = aam_PrepareACIndex(ACID); + return aam_GetAxisAssertInfo(acIndex); +} + + +/** + * @brief ӿڣģ + * @param[out] UINT8 *pDataBuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ݵij + * @note + */ +UINT32 aam_GetTransferData(OUT UINT8 *pDataBuff,UINT32 curIndex) +{ + /*- ֲ */ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex; + UINT16 cycle = 0u; + UINT16 acCnt = 0u; + UINT8 endLineInitFlag = 0u; + const UINT16* pACIdBuff = NULL; + const AxisAsserStruct* pACAssertInfo = NULL; + UINT32 errorCode = 0u; + + + /** ڲУ*/ + ASSERT_RET_VALUE(NULL == pDataBuff,ret,0x80000000u); + + /** ȡϢ */ + acCnt = aam_PrepareACBuffIndexs(&pACIdBuff); + + /** жϼϢǷȡɹ */ + ASSERT_RET_VALUE(NULL == pACIdBuff,ret,0x40000000u); + + /** ģʶ */ + pDataBuff[copyIndex++] = (UINT8)'A'; + pDataBuff[copyIndex++] = (UINT8)'A'; + pDataBuff[copyIndex++] = (UINT8)'M'; + + /** üϢ */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(UINT16),&acCnt, (UINT32)sizeof(UINT16)); + copyIndex += (UINT32)sizeof(UINT16); + + /** м */ + for (cycle = 0u; cycle < acCnt;cycle++) + { + /** ȡϢ */ + pACAssertInfo = aam_GetAxisAssertInfoPtr(pACIdBuff[cycle]); + + /** жǷȷ*/ + ASSERT_BREAK(NULL == pACAssertInfo,errorCode,0x40000000u); + + /** ID*/ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(UINT16),&(pACIdBuff[cycle]), (UINT32)sizeof(UINT16)); + copyIndex += (UINT32)sizeof(UINT16); + + /** Ϣ*/ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(AxisAsserStruct),pACAssertInfo, (UINT32)sizeof(AxisAsserStruct)); + copyIndex += (UINT32)sizeof(AxisAsserStruct); + } + + /*- жǷɹ*/ + if (cycle == acCnt) + { + /** ȡͷARB⴦־*/ + endLineInitFlag = aam_GetInitEndlineFlag(); + pDataBuff[copyIndex++] = endLineInitFlag; + + /** ȷ*/ + ret = copyIndex; + } + else + { + /** */ + } + + /** */ + return ret; +} + + +/** + * @brief ӿڣģ + * @param[in] const UINT8 *pDatabuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @param[in] UINT32 len ݵij + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + */ +UINT32 aam_SetTransferData(IN const UINT8 *pDatabuff,UINT32 curIndex,UINT32 len) +{ + UINT32 ret = curIndex; + UINT8 funRtn = CI_ERROR; + UINT8 endLineInitFlag = 0u; + UINT32 setIndex = curIndex; + UINT16 cycle = 0u; + UINT16 acCnt = 0u; + UINT16 tempID = 0u; + UINT16 acIndex = 0u; + AxisAsserStruct tmpAssertInfo = {0u}; + UINT32 errorCode = 0u; + + /** ڲж */ + ASSERT_RET_VALUE(NULL == pDatabuff,ret,0x80000000u); + ASSERT_RET_VALUE(curIndex >= len,ret,0x40000000u); + + + /** ʼ */ + if ((UINT8)'A' == pDatabuff[setIndex]) + { + setIndex++; + if ((UINT8)'A' == pDatabuff[setIndex]) + { + setIndex++; + if ((UINT8)'M' == pDatabuff[setIndex]) + { + setIndex++; + /** ȡϢ */ + (void)CommonMemCpy(&acCnt, (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += (UINT32) sizeof(UINT16); + + for (cycle = 0u; cycle < acCnt; cycle++) + { + /** ȡID */ + (void)CommonMemCpy(&tempID, (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += (UINT32)sizeof(UINT16); + + /** ͨIDȡ*/ + acIndex = aam_PrepareACIndex(tempID); + /** жǷȷ*/ + ASSERT_BREAK(UINT16_MAX == acIndex, errorCode, 0x20000000u); + + /** ȡϢ */ + (void)CommonMemSet(&tmpAssertInfo, (UINT32) sizeof(AxisAsserStruct), 0, (UINT32)sizeof(AxisAsserStruct)); + (void)CommonMemCpy(&tmpAssertInfo, (UINT32)sizeof(AxisAsserStruct), &pDatabuff[setIndex], (UINT32)sizeof(AxisAsserStruct)); + setIndex += (UINT32)sizeof(AxisAsserStruct); + + funRtn = aam_SetAxisAssert(acIndex, &tmpAssertInfo); + /** жǷȷ*/ + ASSERT_BREAK(UINT16_MAX == acIndex, errorCode, 0x10000000u); + } + + /** ȡͷARB⴦־ */ + endLineInitFlag = pDatabuff[setIndex++]; + aam_SetInitEndlineFlag(endLineInitFlag); + + /** ÷ֵ */ + ASSERT_SETRET((0u == errorCode) && (setIndex <= len), ret, setIndex, ret); + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:ELM Set dataIndex%d.dataLen:%d.\n", errorCode, setIndex, len)); + } + else + { + /** ʹ */ + ASSER_ERROR(CI_ERROR == ret,errorCode,0x20000000u); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:TransferData type:%c%c%c error.",errorCode,pDatabuff[curIndex],pDatabuff[curIndex+1U],pDatabuff[curIndex+2U]) + } + } + else + { + /** ʹ */ + ASSER_ERROR(CI_ERROR == ret,errorCode,0x20000000u); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:TransferData type:%c%c%c error.",errorCode,pDatabuff[curIndex],pDatabuff[curIndex+1U],pDatabuff[curIndex+2U]) + } + } + else + { + /** ʹ */ + ASSER_ERROR(CI_ERROR == ret,errorCode,0x20000000u); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:TransferData type:%c%c%c error.",errorCode,pDatabuff[curIndex],pDatabuff[curIndex+1U],pDatabuff[curIndex+2U]) + + } + return ret; +} + + +/** + * @brief ӿڣóͨ־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_ClearACPassTrainFlag(UINT16 ACID) +{ + /*- ֲ */ + UINT16 acIndex = 0u; + /** ȡ */ + acIndex = aam_PrepareACIndex(ACID); + return aam_ClearPassTrainFlag(acIndex); +} + +/** + * @brief ӿڣóͨϢ + * @param[in] UINT16 ACID ID + * @param[in] UINT16 trainID гID + * @param[out] + * @return + * @note + */ +void aam_ClearACEnvelopeEnterInfo(UINT16 ACID,UINT16 trainID) +{ + /*- ֲ */ + UINT16 acIndex = 0u; + /** ȡ */ + acIndex = aam_PrepareACIndex(ACID); + + aam_ClearHeadEnterIdForTrain(acIndex,trainID); + aam_ClearTailEnterIdForTrain(acIndex,trainID); + +} + +/** +* @brief ӿڣȡǷںóͨ +* @param[in] UINT16 acID +* @param[out] +* @return AAM_CT_PASS κóͨ +AAM_UT_PASS λͨ +* @note ιļкóͨ־Ϊκóͨ +*ξ޺óͨ־λͨ +*/ +UINT8 aam_GetACRelPhyPassTrainFlag(UINT16 acID) +{ + UINT8 ret = AAM_UT_PASS; + UINT8 cycle = 0u; + UINT8 acCnt = 0u; /* ΰļ */ + const UINT16* acIDBuff = NULL; /* ΰļID */ + UINT8 ocid = 0u; + UINT8 isSelfFlag = 0u; + UINT32 errorCode = 0u; + UINT16 phyID = 0u; + UINT8 passTrainFlag = AAM_UT_PASS; + + phyID = aam_PrepareACBelongPhyid(acID); + + isSelfFlag = aam_PreparePhyIsSelf(phyID, &ocid); + + if (ELM_BELONG_OWNER == isSelfFlag) + { + /** ȡΰļ*/ + acIDBuff = aam_PreparePhyRelACIds(phyID, &acCnt); + ASSER_ERROR((NULL == acIDBuff) || (0u == acCnt), errorCode, 0x80000000u); + + if (0u == errorCode) + { + /** ѯȷеļΣмζ޺óͨ־λͨ */ + for (cycle = 0u; cycle < acCnt; cycle++) + { + passTrainFlag = aam_GetACPassTrainFlag(acIDBuff[cycle]); + if (AAM_CT_PASS == passTrainFlag) + { + ret = AAM_CT_PASS; + break; + } + else + { + ; /* */ + } + } + } + } + else + { + /** DZOCᣬӦñãλͨ */ + } + + return ret; +} + + +/** + * @brief ӿڣü״̬ + * @param[in] UINT16 ACID ID + * @param[out] + * @return + * @note ˺Ҫ֤ôͨʽãʱλۼֻڼģнУ˺չʹá + õǼǣ + 1elm_UCTEnvelopeSplit UCTָ󣬺óͨļΪδ״̬´UT + */ +void aam_SetACEnterRedun(UINT16 ACID) +{ + UINT16 acIndex = 0u; + UINT8 maxRedunTimes = 0u; + UINT8 redunTime = 0u; + + /** ȡ */ + acIndex = aam_PrepareACIndex(ACID); + /** ȡռñгʱ */ + maxRedunTimes = aam_PrepareRedunTimes(); + + if (UINT16_MAX == acIndex) + { + /** */ + } + else + { + /** ȡǰʱ */ + redunTime = aam_GetRedunTime(acIndex); + + if (0u == redunTime) + { + /** */ + aam_AddRedunTime(acIndex,maxRedunTimes); + } + else + { + /** ʱ */ + } + } +} + + +/** +* @brief ӿڣǷΪڼ״̬ +* @param[in] UINT16 ACID ID +* @param[out] +* @return CI_ERROR δ + CI_SUCCESS ѽ +* @note +*/ +UINT8 aam_CheckACEnterRedun(UINT16 ACID) +{ + UINT8 ret = CI_ERROR; + UINT16 acIndex = 0u; + UINT8 redunTime = 0u; + + /** ȡ */ + acIndex = aam_PrepareACIndex(ACID); + + if (UINT16_MAX != acIndex) + { + /** ȡǰʱ */ + redunTime = aam_GetRedunTime(acIndex); + + /** úֵ */ + ASSERT_SETRET(0u != redunTime,ret,CI_SUCCESS,CI_ERROR); + } + else + { + /** ѯüѽ״̬ */ + ret = CI_ERROR; + } + return ret; +} +/** +* ܣѯڽΧ޻ռ +* UINT16 ACID +* ֵCI_ERROR жʱ;뷶Χл CI_SUCCESS ͨ +* Create: fan 2024/08/22 +*/ +UINT8 aam_CheckNearbyTrainType(UINT16 ACID) +{ + UINT8 retVal = CI_ERROR; + UINT8 phyAcNum = 0u; + UINT16* pACBuff = NULL; + UINT16 wBasePhyid = 0U; + UINT8 jj = 0U; + UINT8 ii = 0U; + UINT8 chKeepcheck = CI_SUCCESS; /*־*/ + UINT8 chTimeFlag = 0U; /*ỵϴͨʱ־*/ + UINT32 cyCheckUtCyc = 0U; /**/ + UINT32 dwRecentUtCyc = 0U; /*ռں*/ + UINT16 wCheckPhySec = 0U; /**/ + UINT16* wAdjacentPhyBuf = NULL; /*ֱ*/ + UINT8 chAdjacentPhyNum = 0U; /*ֱ*/ + UINT8 chNearSecNum = 0U; /**/ + UINT16* dwNearSecBuf = NULL; /**/ + + cyCheckUtCyc = GetArbProtectCheckTime(); + wBasePhyid = aam_PrepareACBelongPhyid(ACID); + + chKeepcheck = GetPhyPossibleArbTag(wBasePhyid); + if (CI_SUCCESS == chKeepcheck) + { + /*Step1 :ǰм޻*/ + phyAcNum = GetPAxisSectionSum(wBasePhyid); + pACBuff = GetPAxisSectionIdBuf(wBasePhyid); + /*ռ*/ + if ((0U != phyAcNum) && (NULL != pACBuff)) + { + for (jj = 0; jj < phyAcNum; jj++) + { + dwRecentUtCyc = GetAxisRecentUtOccupyCyc(pACBuff[jj]); + chTimeFlag = SystemOverTimeCheck(dwRecentUtCyc, cyCheckUtCyc); + if (CI_TIME_IN == chTimeFlag) + { + /*ʱ䷶Χ Ϊӽ*/ + chKeepcheck = CI_ERROR; + retVal = CI_ERROR; + debug_infor_printf((const)"ACid: %d , ArbNearSecCheck fail step1, PhySec = %d\n", ACID, wBasePhyid); + break; + } + } + } + else + { + chKeepcheck = CI_ERROR; + } + } + + if(CI_SUCCESS == chKeepcheck) + { + /*Step2 :ǰֱм޻*/ + chAdjacentPhyNum = GetAdjacentPhySecNum(wBasePhyid); + wAdjacentPhyBuf = GetAdjacentPhySecBuf(wBasePhyid); + if ((0U != chAdjacentPhyNum) && (NULL != wAdjacentPhyBuf)) + { + for (ii = 0; ii < chAdjacentPhyNum; ii++) + { + wCheckPhySec = wAdjacentPhyBuf[ii]; + phyAcNum = GetPAxisSectionSum(wCheckPhySec); + pACBuff = GetPAxisSectionIdBuf(wCheckPhySec); + /*ռ*/ + if ((0U != phyAcNum) && (NULL != pACBuff)) + { + for (jj = 0; jj < phyAcNum; jj++) + { + dwRecentUtCyc = GetAxisRecentUtOccupyCyc(pACBuff[jj]); + chTimeFlag = SystemOverTimeCheck(dwRecentUtCyc, cyCheckUtCyc); + if (CI_TIME_IN == chTimeFlag) + { + /*ʱ䷶Χ Ϊӽ*/ + chKeepcheck = CI_ERROR; + retVal = CI_ERROR; + debug_infor_printf((const)"ACid: %d , ArbNearSecCheck fail step2, PhySec = %d\n", ACID, wCheckPhySec); + break; + } + } + } + else + { + chKeepcheck = CI_ERROR; + } + } + } + else + { + chKeepcheck = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepcheck) + { + /*Step3 :ǰμм޻*/ + chNearSecNum = GetNearPhySecNum(wBasePhyid); + dwNearSecBuf = GetIndirectNearPhySecBuf(wBasePhyid); + for (ii = 0; ii < chNearSecNum; ii++) + { + wCheckPhySec = dwNearSecBuf[ii]; + phyAcNum = GetPAxisSectionSum(wCheckPhySec); + pACBuff = GetPAxisSectionIdBuf(wCheckPhySec); + /*ռ*/ + if ((0U != phyAcNum) && (NULL != pACBuff)) + { + for (jj = 0; jj < phyAcNum; jj++) + { + dwRecentUtCyc = GetAxisRecentUtOccupyCyc(pACBuff[jj]); + chTimeFlag = SystemOverTimeCheck(dwRecentUtCyc, cyCheckUtCyc); + if (CI_TIME_IN == chTimeFlag) + { + /*ʱ䷶Χ Ϊӽ*/ + chKeepcheck = CI_ERROR; + retVal = CI_ERROR; + debug_infor_printf((const)"ACid: %d , ArbNearSecCheck fail step3, PhySec = %d\n", ACID, wCheckPhySec); + break; + } + } + } + else + { + chKeepcheck = CI_ERROR; + } + } + } + if (CI_SUCCESS == chKeepcheck) + { + retVal = CI_SUCCESS;/*ȫͨ*/ + } + return retVal; +} + +/** +* ܣϵͳͨжARB +* +* ֵ +* Create By LQ 2025.02.23 +*/ +void aam_AxisCommBadArbPro(void) +{ + UINT8 cFuncRetVal = CI_ERROR; + UINT8 cLocalWorkMode = RC_WORK_MODE_CI; + UINT8 cFuncSwitch = FUNC_SWITCH_OFF; + UINT8 cLocalCiType = 0U; + UINT8 cLocalRcLinkLineAttr = 0U; /**/ + UINT8 cCommAxisNum = 0U; /*ͨŹϵļϵͳ*/ + UINT8* pAxisSysIdBuf = NULL; + UINT8 cCommState = TRANSMIT_2OO2_STATE_BAD; /*ͨ״̬*/ + + cLocalWorkMode = GetLocalRcWorkMode(); + cFuncSwitch = GetCiFunctionSwitchConfig(FUNC_AXIS_COMM_BAD_KEEP_CBTC); + if ((RC_WORK_MODE_TIOC == cLocalWorkMode) && (FUNC_SWITCH_ON == cFuncSwitch)) + { + cLocalCiType = GetLocalCiType(); + cLocalRcLinkLineAttr = GetLocalRcLinkLineAttr(); + if (((CI_TYPE_ZX == cLocalCiType) || (CI_TYPE_SCX == cLocalCiType)) && (RC_LINK_LINE_NO == cLocalRcLinkLineAttr)) + { + cCommAxisNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); + pAxisSysIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); + + if ((1U == cCommAxisNum) && (NULL != pAxisSysIdBuf)) + { + cCommState = GetCiTransmitState(CI_SYSTEM_TYPE_AXIS, pAxisSysIdBuf[0U]); + if (TRANSMIT_STATE_BAD == cCommState) + { + /*1.г飺UT/UCT/CT߳гNVRAM־Ч*/ + cFuncRetVal = aam_AxisCommBadArbTrainCheck(); + + /*2.飺߽ARBΧڡARBʱûֹϳڿ߽δARB*/ + cFuncRetVal &= aam_AxisCommBadArbSecCheck(); + + if (CI_SUCCESS == cFuncRetVal) + { + SetRcAxleArb(); /*üARB*/ + debug_infor_printf((const)"aam_AxisCommBadArbPro Success\n"); + } + else + { + ; + } + } + else + { + /*ͨ*/ + } + } + else + { + /*ڶͨŵļϵͳ*/ + } + } + else + { + /*λRC*/ + } + } + else + { + /*RCģʽ򡰼ϵͳͨжϺǷܹάCBTCСعرգ*/ + } +} + +/** +* ܣϵͳͨжARBг +* +* ֵCI_SUCCESS 1 ɹ +* CI_ERROR 0 ʧ +* Create By LQ 2025.02.23 +*/ +UINT8 aam_AxisCommBadArbTrainCheck(void) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wAcNum = 0u; /*OCΧеļ*/ + const UINT16* pACIdbuff = NULL; /** IDֵ */ + UINT8 cLocalCiId = 0U; + UINT16 ii = 0U; + UINT8 cAcBelongCiId = 0U; + UINT8 cEnvelopeNum = SECTION_REL_ENVELOPE_SUM_MAX; /**/ + UINT16 szEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = { 0U }; /*ID*/ + UINT8 jj = 0U; + const EnvelopeStruct* pELMInfo = NULL; /**/ + UINT8 cSleepState = TRAIN_SLEEP_YES; /*г״̬*/ + UINT8 cNvramFlag = TRAIN_NVRAM_POS_FLAG_YES; /*гNVRAM־*/ + + wAcNum = elm_PrepareACBuffIndexs(&pACIdbuff); /*ȡID*/ + cLocalCiId = GetSystemParaLocalCiId(); + if ((0U < wAcNum) && (AXIS_SECTION_SUM_MAX > wAcNum ) && (NULL != pACIdbuff) && (0U != cLocalCiId)) + { + cRetVal = CI_SUCCESS; + for (ii = 0U; ii < wAcNum; ii++) + { + cAcBelongCiId = (UINT8)GetAxisBelongTioc(pACIdbuff[ii]); + if (cLocalCiId == cAcBelongCiId) + { + cEnvelopeNum = elm_GetEnvelopeIDsInAC(pACIdbuff[ii], szEnvelopeID); + if (0U == cEnvelopeNum) + { + /*ް磬ͨ*/ + } + else if(SECTION_REL_ENVELOPE_SUM_MAX > cEnvelopeNum) + { + for (jj = 0U; jj < cEnvelopeNum; jj++) + { + pELMInfo = elm_GetEnvelopeInfoByID(szEnvelopeID[jj]); + + if ((NULL != pELMInfo) && (TYPE_CT_ENVELOPE == pELMInfo->envelopeType) && + (0U == pELMInfo->headTrainID) && (0U == pELMInfo->tailTrainID)) + { + /*δس*/ + if (1U == pELMInfo->trianCnt) + { + cSleepState = GetTrainSleepState(pELMInfo->trainID[0]); + cNvramFlag = GetTrainNvramPosFlag(pELMInfo->trainID[0]); + if ((TRAIN_SLEEP_NO == cSleepState) && (TRAIN_NVRAM_POS_FLAG_NO == cNvramFlag)) + { + /*߳гʹNVRAM*/ + } + else + { + debug_infor_printf((const)"aam_AxisCommBadArbTrainCheck Error: Sleep Train Or Nvram Valid\n"); + cRetVal = CI_ERROR; /*߳ʹNVRAMͨųʧܣʧ*/ + } + } + else + { + debug_infor_printf((const)"aam_AxisCommBadArbTrainCheck Error: Envelope Train Num Invalid\n"); + cRetVal = CI_ERROR; /*쳣ʧܣʧ*/ + } + } + else + { + debug_infor_printf((const)"aam_AxisCommBadArbTrainCheck Error: Exist UT\n"); + cRetVal = CI_ERROR; /*سֹͣ飬ʧ*/ + } + + if (CI_SUCCESS != cRetVal) + { + cRetVal = CI_ERROR; + break; /*ʧܣֹͣʧ*/ + } + else + { + /**/ + } + } + } + else + { + cRetVal = CI_ERROR; + } + + if (CI_SUCCESS != cRetVal) + { + cRetVal = CI_ERROR; + break; /*ʧܣֹͣʧ*/ + } + else + { + /**/ + } + } + else + { + /*DZΣ*/ + } + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/** +* ܣϵͳͨжARB +* +* ֵCI_SUCCESS 1 ɹ +* CI_ERROR 0 ʧ +* Create By LQ 2025.02.23 +*/ +UINT8 aam_AxisCommBadArbSecCheck(void) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wAcNum = 0u; /*OCΧеļ*/ + const UINT16* pACIdbuff = NULL; /** IDֵ */ + UINT8 cLocalCiId = 0U; + UINT16 ii = 0U; + UINT8 cAxleBorderAttr = AXIS_BORDER_AXLE_YES; + UINT8 cAcBelongCiId = 0U; + UINT16 wRelPhySecId = 0U; /*ιID*/ + UINT8 cPhySecArbState = 0U; + + wAcNum = elm_PrepareACBuffIndexs(&pACIdbuff); /*ȡID*/ + cLocalCiId = GetSystemParaLocalCiId(); + if ((0U < wAcNum) && (AXIS_SECTION_SUM_MAX > wAcNum) && (NULL != pACIdbuff) && (0U != cLocalCiId)) + { + cRetVal = CI_SUCCESS; + for (ii = 0U; ii < wAcNum; ii++) + { + cAxleBorderAttr = GetAxisSecBorderProperty(pACIdbuff[ii]); + if (AXIS_BORDER_AXLE_NO == cAxleBorderAttr) + { + /*DZ߽Σ*/ + } + else if (AXIS_BORDER_AXLE_YES == cAxleBorderAttr) + { + cAcBelongCiId = (UINT8)GetAxisBelongTioc(pACIdbuff[ii]); + if (cLocalCiId == cAcBelongCiId) + { + /*߽ΣARBΧڡARBʱûֹϳ*/ + cRetVal = aam_CheckNearbyTrainType(pACIdbuff[ii]); + if (CI_SUCCESS != cRetVal) + { + debug_infor_printf((const)"aam_AxisCommBadArbSecCheck Error: Near Sec Exist UT\n"); + cRetVal = CI_ERROR; /*ʧܣֹͣʧ*/ + } + else + { + /**/ + } + } + else + { + /*DZ߽ΣδARB*/ + wRelPhySecId = GetAxisSecRelativePhySecId(pACIdbuff[ii]); + cPhySecArbState = GetPhySecArbState(wRelPhySecId); + if (AXIS_SECTION_ARB_NO == cPhySecArbState) + { + /*δARB*/ + } + else + { + debug_infor_printf((const)"aam_AxisCommBadArbSecCheck Error: Other Rc Cfp ARB\n"); + cRetVal = CI_ERROR; /*ڿ߽ARBʧ*/ + } + } + } + else + { + cRetVal = CI_ERROR; + } + + if (CI_SUCCESS != cRetVal) + { + cRetVal = CI_ERROR; + break; + } + else + { + /**/ + } + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* üڼARB +* ˵ +* ֵ +*/ +void SetRcAxleArb(void) +{ + UINT16 wAcNum = 0U; + UINT16* pACBuff = NULL; + UINT8 cLocalCiId = 0U; + UINT16 ii = 0U; + UINT8 cAcBelongCiId = 0U; + UINT16 wACindex = 0U; + UINT8 cAcOccStatus = ELM_AC_FREE; /*ռ״̬*/ + + wAcNum = GetLocalCiAxisSectionIdBuf(&pACBuff); /*ȡϢ*/ + cLocalCiId = GetSystemParaLocalCiId(); + if ((0U < wAcNum) && (NULL != pACBuff) && (0U != cLocalCiId)) + { + for (ii = 0U; ii < wAcNum; ii++) + { + cAcBelongCiId = (UINT8)GetAxisBelongTioc(pACBuff[ii]); + wACindex = aam_PrepareACIndex(pACBuff[ii]); + if ((cLocalCiId == cAcBelongCiId) && (UINT16_MAX != wACindex)) + { + cAcOccStatus = aam_PrepareACStatus(pACBuff[ii]); + if (ELM_AC_OCC == cAcOccStatus) + { + aam_SetAxisStatus(wACindex, AAM_STATUS_ARB); + aam_SetAxisCommBadArbFlag(wACindex, AAM_COMM_BAD_ARB_YES); + } + else + { + /*δռã*/ + } + } + else + { + /*DZΣ*/ + } + } + } + else + { + ; + } +} + +/** +* @brief ӿڣȡ״̬ӿ +* @param[in] UINT16 ID +* @param[out] +* @return UINT8 ״̬ 0ռ 0x55ARB 0xaa +* Creat fan 20250310 +*/ +UINT8 aam_GetAxisStatusAPI(UINT16 ACID) +{ + UINT8 reVal = AAM_STATUS_OCC; + UINT16 acIndex = 0U; + + /** ȡ */ + acIndex = aam_PrepareACIndex(ACID); + reVal = aam_GetAxisStatus(acIndex); + return reVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManageAPI.h b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManageAPI.h new file mode 100644 index 0000000..7e4836e --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisAssert/AxisAssertManageAPI.h @@ -0,0 +1,216 @@ +/****************************************************************************** +** ļ: AxisAssertManageAPI.h +** : ģ飬ģaam +*******************************************************************************/ + +#ifndef AXIS_ASSERT_MANAGE_API_H_ +#define AXIS_ASSERT_MANAGE_API_H_ + +#include "AxisAssertDefine.h" +#include "EnvelopeDefine.h" + + +/** + * @brief ģʼ + * @return CI_ERROR ʼɹ + CI_SUCCESS ʼʧ + * @note + */ +UINT8 aam_Init(void); + + +/** + * @brief ģ鴦 + * @param[in] + * @param[out] + * @return + * @note + */ +void aam_MainProcess(void); + + +/** + * @brief ӿڣüг + * @param[in] UINT8 flag г + * @param[in] UINT16 supicTrainid ɳid + * @param[in] UINT16 acID id + * @param[in] UINT16 trainid гID + * @return + * @note + */ +void aam_SetEnvelopeEnterFlag(UINT8 flag,UINT16 supicTrainid, UINT16 acID,UINT16 trainId); + +/** + * @brief ӿڣȡ״̬ + * @param[in] UINT16 ACID + * @param[out] + * @return + * @note + */ +UINT8 aam_GetACAssertStatus(UINT16 ACID); + +/** + * @brief ӿڣȡεĹ״̬ + * @param[in] UINT16 phyID ID + * @param[out] + * @return AAM_API_AC_ARB ARB + UINT8_MAX ηARB + * @note ιļռҶΪARBʱ򷵻ARB򷵻UT + */ +UINT8 aam_GetPhyIsARB(UINT16 phyID); + +/** + * @brief ӿڣȡóͨ־ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT8 aam_GetACPassTrainFlag(UINT16 ACID); + +/** + * @brief ӿڣȡӦϢַ + * @param[in] + * @param[out] + * @return + * @note + */ +const AxisAsserStruct* aam_GetAxisAssertInfoPtr(UINT16 ACID); + + +/** + * @brief ӿڣģ + * @param[out] UINT8 *pDataBuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ݵij + * @note + */ +UINT32 aam_GetTransferData(OUT UINT8 *pDataBuff,UINT32 curIndex); + +/** + * @brief ӿڣģ + * @param[in] const UINT8 *pDatabuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @param[in] UINT32 len ݵij + * @return ȡ + * @note + */ +UINT32 aam_SetTransferData(IN const UINT8 *pDatabuff,UINT32 curIndex,UINT32 len); + + +/** + * @brief ӿڣóͨ־ + * @param[in] UINT16 ACID ID + * @param[out] + * @return + * @note + */ +UINT8 aam_ClearACPassTrainFlag(UINT16 ACID); + + +/** + * @brief ӿڣóͨϢ + * @param[in] UINT16 ACID ID + * @param[in] UINT16 trainID гID + * @param[out] + * @return + * @note + */ +void aam_ClearACEnvelopeEnterInfo(UINT16 ACID,UINT16 trainID); + +/** +* @brief ӿڣȡǷںóͨ +* @param[in] UINT16 acID +* @param[out] +* @return AAM_CT_PASS κóͨ +AAM_UT_PASS λͨ +* @note ιļкóͨ־Ϊκóͨ +*ξ޺óͨ־λͨ +*/ +UINT8 aam_GetACRelPhyPassTrainFlag(UINT16 acID); + + + +/** + * @brief ӿڣѯӽ + * @param[in] UINT16 baseACID ׼ + * @param[in] UINT8 Dir ѯ + * @param[in] UINT8 acCnt ڼ + * @param[in] UINT16 acID[AC_MAXCNT_IN_SWITCH] ڼID + * @param[out] + * @return + * @note + */ +UINT8 aam_SearchNearbyTrainType(UINT16 baseACID, UINT8 Dir, UINT8 acCnt, UINT16 acID[AC_MAXCNT_IN_SWITCH]); + + +/** + * @brief ӿڣü״̬ + * @param[in] UINT16 ACID ID + * @param[out] + * @return + * @note + */ +void aam_SetACEnterRedun(UINT16 ACID); + + +/** +* @brief ӿڣǷ״̬ +* @param[in] UINT16 ACID ID +* @param[out] +* @return +* @note +*/ +UINT8 aam_CheckACEnterRedun(UINT16 ACID); + +/** +* ܣѯڽΧ޻ռ +* UINT16 ACID +* ֵCI_ERROR жʱ;뷶Χл CI_SUCCESS ͨ +* Create: fan 2024/08/22 +*/ +UINT8 aam_CheckNearbyTrainType(UINT16 ACID); + +/** +* ܣϵͳͨжARB +* +* ֵ +* Create By LQ 2025.02.23 +*/ +void aam_AxisCommBadArbPro(void); + +/** +* ܣϵͳͨжARBг +* +* ֵCI_SUCCESS 1 ɹ +* CI_ERROR 0 ʧ +* Create By LQ 2025.02.23 +*/ +UINT8 aam_AxisCommBadArbTrainCheck(void); + +/** +* ܣϵͳͨжARB +* +* ֵCI_SUCCESS 1 ɹ +* CI_ERROR 0 ʧ +* Create By LQ 2025.02.23 +*/ +UINT8 aam_AxisCommBadArbSecCheck(void); + +/* +* üڼARB +* ˵ +* ֵ +*/ +void SetRcAxleArb(void); + +/** +* @brief ӿڣȡ״̬ӿ +* @param[in] UINT16 ID +* @param[out] +* @return UINT8 ״̬ +* Creat fan 20250310 +*/ +UINT8 aam_GetAxisStatusAPI(UINT16 ACID); + +#endif /*AXIS_ASSERT_MANAGE_API_H_*/ diff --git a/TSCP/src/APP/ciapp/AxisSort/AxisSort.c b/TSCP/src/APP/ciapp/AxisSort/AxisSort.c new file mode 100644 index 0000000..80e5898 --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisSort/AxisSort.c @@ -0,0 +1,2457 @@ +/****************************************************************************** +** ļ: as.c ( ) +** : ģ +*******************************************************************************/ + +#include "AxisSort.h" +#include "AxisSort_api.h" +#include "../EnvelopeManage/EnvelopeManageAPI.h" +#include "../EnvelopeManage/ELMDataPrepare.h" +#include "TrainOnAcManage.h" +#include "SystemConfigDefine.h" +#include "Convert.h" +#include "AxisSectionConfigDataManage.h" + +/* LINK */ +static UINT16 g_pSortLinkNum; /* Link */ +static UINT16 g_pSortLinkIndex[AS_LINK_MAX + 1U]; /* Link */ + +static AS_SORT_INFO_s g_pSortLinkInfo[AS_LINK_MAX + 1U]; /*link*/ + +/* ͨųУSortCT׶CT */ +static UINT16 s_pCTSortIndex[SIZE_MAX_LINE_TRAIN_NUM]; /*Ϣ*/ +static CT_SORT_INFO_s s_pCTSortInfo[SIZE_MAX_COM_VOBC_NUM + 1U]; /*Ϣ*/ + +static UINT16 g_pSortACNum; /* ZCZCϽļ */ +static UINT16 g_pSortACIndex[AS_AC_MAX + 1U]; /* ZCϽļ */ +static AS_SORT_INFO_s g_pSortACInfo[AS_AC_MAX + 1U]; /* AC */ + +static s_TRAIN_ENVELOPE_ID s_TrainELSeq; /*г*/ + +/*ͨųгʼ*/ +static void CTSortInit(void); +/*Link*/ +static void LinksClear(void); +/*AC*/ +static void ACClear(void); +/*Linkгʼ*/ +static void LinkSortInit(void); +/*ACгʼ*/ +static void ACSortInit(void); +/*ȡеͨųнڵ*/ +static UINT16 GetFreeCTNode(void); +/*ͨųɾ*/ +static void CTDelTrain(UINT16 u16TrainID); +/*ͨųмӳ*/ +static void CTAddTrain(UINT16 u16TrainID); +/*Ӷͨų*/ +static void UCTAddTrain(UINT16 u16TrainID, IN UINT8 u8Dir, IN LOD_STRU sHead, IN LOD_STRU sTail); +/*Linkλг*/ +static void LinkAddTrain(UINT16 u16LinkID, UINT16 u16TrainID, UINT8 u8Type); +/*Linkг*/ +static void LinksAddTrain(UINT16 u16TrainID, UINT8 u8TrainType); +/*гӹϳ*/ +static void TrainAddSuspectLeft(UINT16 u16TrainID, UINT16 u16LinkID); +/*гҶӹϳ*/ +static void TrainAddSuspectRight(UINT16 u16TrainID, UINT16 u16LinkID); +/**/ +static void SeqInsert(IN UINT16 u16TrainID, IN UINT8 u8TrainType, IN UINT16 u16ELID, INOUT UINT8 *pu8TrainNum, INOUT TRAIN_SEQUANCE_s TrainList[SIZE_MAX_TRAINOFAC], IN UINT8 u8InsertIndex); + +/*гλã䵽link*/ +static UINT8 CalcTrainOrder(IN UINT16 u16Train1, IN UINT16 u16Train2,UINT16 u16LinkID); + +/*λ,䵽*/ +static UINT8 CalcEnveLopeOrderInAC(IN const EnvelopeStruct* p1, IN const EnvelopeStruct* p2, UINT16 u16ACID); +/*гģȡеİ磬elmİ䵽AC*/ +static void SortAllEnveLopeInAC(void); +/*θݰӳ*/ +static void ACAddEnvelope(IN UINT16 u16ACID, IN const EnvelopeStruct *pEnvelope, IN UINT16 u16ELID); +/*س*/ +static void SortSuspectCT(void); +/*ʧͨų*/ +static void SortUCT(void); +/*UT*/ +static void SortUKT(void); + +/******Ǵӿģȡ׼*******************************/ +/*ѯLink*/ +static UINT8 LinkManage_GetLinkInfoExp(LOD_STRU pStart, LOD_STRU pEnd, UINT8 u8Direction, UINT16 pu16LinkID[]); +/*жǰ˳*/ +static UINT8 LinkManage_CheckSortTrainExp(UINT16 u16Link1, UINT32 u32Offset1, UINT16 u16Link2, UINT32 u32Offset2, UINT8 u8Direction); +/*ɸѡģȡгİϢ*/ +static void elm_GetAllTrainELSeq(void); +/*ǷCTҳͷسUKT*/ +static UINT8 elm_IsCTHeadUKT(UINT16 u16TrainID); +/*ǷCTҳβسUKT*/ +static UINT8 elm_IsCTTailUKT(UINT16 u16TrainID); + +/*гλ*/ +static UINT8 CalcAreaOrder(IN const TrainLocStruct* p1, IN const TrainLocStruct* p2); + +/** +* @brief ӡlinkϢ +* @param +* @return +* @note +*/ +static void as_DebugPrint(void); +/***************************************************************************** +* @name as_Init +* @brief ASģʼ +* @param[in] +* @return +* @note +*****************************************************************************/ +void as_Init(void) +{ + /*- ͨųгʼ */ + CTSortInit(); + + /*- Linkгʼ */ + LinkSortInit(); + + /*- ACгʼ */ + ACSortInit(); + + +} + +/***************************************************************************** +* @name as_MainProcess +* @brief ASģ +* @param[in] +* @return +* @note +*****************************************************************************/ +void as_MainProcess(void) +{ + as_CycleInit(); + + /*ͨų*/ + as_SortCT(); + + /*׼гϢfromгģ飩*/ + elm_GetAllTrainELSeq(); + + /*UT*/ + as_SortUT(); + + /*г*/ + as_SortBaseEnveLope(); + + /*linkϢӡ*/ + as_DebugPrint(); + +} +/************************************************************* +* @name as_CycleInit +* @brief ڳʼ +* @param[in] void +* @return void +* @note +*************************************************************/ +void as_CycleInit(void) +{ + /*- link */ + LinksClear(); + /*- AC */ + ACClear(); +} + +/***************************************************************************** +* @name CTSortInit +* @brief ͨųгʼ +* @param[in] +* @return +* @note +*****************************************************************************/ +static void CTSortInit(void) +{ + /*- ʼͨų*/ + (void)CommonMemSet(s_pCTSortIndex, (UINT32)sizeof(s_pCTSortIndex), 0u, (UINT32)sizeof(s_pCTSortIndex)); + (void)CommonMemSet(s_pCTSortInfo, (UINT32)sizeof(s_pCTSortInfo), 0u, (UINT32)sizeof(s_pCTSortInfo)); +} + + +/***************************************************************************** +* @name LinksClear +* @brief Link +* @param[in] +* @return +* @note +*****************************************************************************/ +static void LinksClear(void) +{ + UINT16 u16LinkID = DEFAULT_ZERO; + UINT16 u16Index = DEFAULT_ZERO; + /*- 1 ; Ƿβ? ; */ + for (u16Index = 1U; u16Index <= g_pSortLinkNum; u16Index++) + { + /*- link */ + u16LinkID = g_pSortLinkInfo[u16Index].u16ID; + (void)memset(&g_pSortLinkInfo[u16Index], 0, sizeof(AS_SORT_INFO_s)); + g_pSortLinkInfo[u16Index].u16ID = u16LinkID; + g_pSortLinkInfo[u16Index].u8SortFail = FLAG_UNSET; + + } +} + +/***************************************************************************** +* @name ACClear +* @brief AC +* @param[in] +* @return +* @note +*****************************************************************************/ +static void ACClear(void) +{ + UINT16 u16ACID = DEFAULT_ZERO; + UINT16 u16Index = DEFAULT_ZERO; + /*- 1 ; Ƿβ? ; */ + for (u16Index = 1U; u16Index <= g_pSortACNum; u16Index++) + { + /*- AC */ + u16ACID = g_pSortACInfo[u16Index].u16ID; + (void)memset(&g_pSortACInfo[u16Index], 0, sizeof(AS_SORT_INFO_s)); + g_pSortACInfo[u16Index].u16ID = u16ACID; + g_pSortACInfo[u16Index].u8SortFail = FLAG_UNSET; + + } +} + + +/***************************************************************************** +* @name LinkSortInit +* @brief Linkгʼ +* @param[in] +* @return +* @note +*****************************************************************************/ +static void LinkSortInit(void) +{ + UINT16 u16LinkID = DEFAULT_ZERO; /* LinkID */ + + /*- ʼLink */ + (void)CommonMemSet(g_pSortLinkIndex, (UINT32)sizeof(g_pSortLinkIndex), 0u, (UINT32)sizeof(g_pSortLinkIndex)); + (void)CommonMemSet(g_pSortLinkInfo, (UINT32)sizeof(g_pSortLinkInfo), 0u, (UINT32)sizeof(g_pSortLinkInfo)); + + g_pSortLinkNum = DEFAULT_ZERO; + for (u16LinkID = 1U; u16LinkID <= AS_LINK_MAX; u16LinkID++) + { + if (g_pSortLinkNum < AS_LINK_MAX) + { + g_pSortLinkNum++; + g_pSortLinkIndex[u16LinkID] = g_pSortLinkNum; + g_pSortLinkInfo[g_pSortLinkNum].u16ID = u16LinkID; + g_pSortLinkInfo[g_pSortLinkNum].u8SortFail = FLAG_UNSET; + } + else + { + debug_infor_printf((const)"FATAL:[AS]Link\n"); + } + } +} + + +/***************************************************************************** +* @name ACSortInit +* @brief гʼ +* @param[in] +* @return +* @note +*****************************************************************************/ +static void ACSortInit(void) +{ + UINT16 u16ACID = DEFAULT_ZERO; /* ID */ + + /*- ʼ */ + (void)CommonMemSet(g_pSortACIndex, (UINT32)sizeof(g_pSortACIndex), 0u, (UINT32)sizeof(g_pSortACIndex)); + (void)CommonMemSet(g_pSortACInfo, (UINT32)sizeof(g_pSortACInfo), 0u, (UINT32)sizeof(g_pSortACInfo)); + g_pSortACNum = DEFAULT_ZERO; + + /*- @alias гʼΪZCļ */ + for (u16ACID = 1U; u16ACID <= AS_AC_MAX; u16ACID++) + { + if (g_pSortACNum < AS_AC_MAX) + { + g_pSortACNum++; + g_pSortACIndex[u16ACID] = g_pSortACNum; + g_pSortACInfo[g_pSortACNum].u16ID = u16ACID; + g_pSortACInfo[g_pSortACNum].u8SortFail = FLAG_UNSET; + } + else + { + debug_infor_printf((const)"FATAL:[AS]ڼ\n"); + } + } +} + +/***************************************************************************** +* @name as_SortCT +* @brief ͨų +* @param[in] +* @return +* @note ͨг: гˢͨų; +* ڶʧλõͨг: תΪϳͨųƳ +* ³ֵλñг: ӵͨųкlinkС +*****************************************************************************/ +void as_SortCT(void) +{ + UINT8 u8LocValid = DEFAULT_ZERO; /* λЧ */ + UINT16 u16TrainID = DEFAULT_ZERO; /* гID */ + /* ҪͨжϵгתΪϳУﲻֻǰͨг */ + + /*- г1 ; Ƿβ? ; */ + for (u16TrainID = 1U; u16TrainID < SIZE_MAX_LINETRAIN; u16TrainID++) + { + /*гģлȡгλǷЧǷCT*/ + u8LocValid = TrainManage_GetTrainLocValid(u16TrainID); + + /*- ͨųǷѾ */ + if (DEFAULT_ZERO != s_pCTSortIndex[u16TrainID]) + { + /*- гλǷЧ */ + if (FLAG_SET == u8LocValid) + { + /*- ͨųиг */ + CTAddTrain(u16TrainID); + /*- LinkCT */ + LinksAddTrain(u16TrainID, TYPE_CT); + } + else + { + debug_infor_printf((const)"AS0001:[%d Train] Location is Invalid, UTC Train\n", (const)u16TrainID); +#if 0 + /*- LinkUT */ + LinksAddTrain(u16TrainID, TYPE_UCT); + /****ע⣬ʧͨųSortUCT()ʵ֣Ϊ漰ĸ*****/ +#endif + } + } + else + { + /*- гλǷЧ */ + if (FLAG_SET == u8LocValid) + { + debug_infor_printf((const)"AS0002:Added Location Reporting Train:[%d]\n", (const)u16TrainID); + /*- ͨųг */ + CTAddTrain(u16TrainID); + /*- LinkCT */ + LinksAddTrain(u16TrainID, TYPE_CT); + } + else + { + /*г޶λӵͨų*/ + } + } + } + + /*- г1 ; Ƿβ? ; */ + for (u16TrainID = 1U; u16TrainID < SIZE_MAX_LINETRAIN; u16TrainID++) + { + u8LocValid = TrainManage_GetTrainLocValid(u16TrainID); + /*- ǷͨųеλЧг */ + if ((DEFAULT_ZERO != s_pCTSortIndex[u16TrainID]) && (FLAG_SET != u8LocValid)) + { + debug_infor_printf((const)"AS0003:[%d Train] location is invalid, delete the train\n", (const)u16TrainID); + /*- ͨųɾг */ + CTDelTrain(u16TrainID); + } + else + { + /*账*/ + } + } +} + +/***************************************************************************** +* @name as_SortUT +* @brief ͨų +* @param[in] +* @return +* @note 1гģijϢͨŹϳ +* IDUCTͨŹϳ +* 2гģģijϢӿɳ + гIDҿɱ־Ч +* 3гģijϢӴUT + IDΪ255س + +*****************************************************************************/ +void as_SortUT(void) +{ + /*CTسUKT*/ + SortSuspectCT(); + /*سUKT*/ + SortUKT(); + /*ͨŹϳ*/ + SortUCT(); +} +/***************************************************************************** +* @name SortSuspectCT +* @brief س +* @param[in] +* @return +* @note ɳ򣬸гijɱ־ڿƷӹϳ +* ֻCT255س֣UCT账ѾSortUCT׶δ +* +*****************************************************************************/ +static void SortSuspectCT(void) +{ + UINT8 u8Flag = DEFAULT_ZERO; /* ɱ־ */ + UINT16 u16TrainID = DEFAULT_ZERO; /* гID */ + UINT8 u8Dir_head = DEFAULT_ZERO; /*гȫͷз*/ + UINT8 u8Dir_tail = DEFAULT_ZERO; /*гȫβз*/ + /*- г1 ; Ƿβ? ; */ + for (u16TrainID = 1U; u16TrainID < SIZE_MAX_LINETRAIN; u16TrainID++) + { + /*- ͨųǷ */ + if (DEFAULT_ZERO != s_pCTSortIndex[u16TrainID]) + { + u8Dir_head = GetTrainSafeHeadDir(u16TrainID); + u8Dir_tail = GetTrainSafeTailDir(u16TrainID); + u8Flag = elm_IsCTHeadUKT(u16TrainID); + /*- ǷCTǰпUT*/ + if (FLAG_SET == u8Flag) + { + /*- зӵͼͬ */ + if (EMAP_SAME_DIR == u8Dir_head) + { + /*- ˿ɵгUT */ + TrainAddSuspectRight(u16TrainID, s_pCTSortInfo[s_pCTSortIndex[u16TrainID]].SafeHead.Lnk); + } + else + { + /*- ǰ˿ɵгǰUT */ + TrainAddSuspectLeft(u16TrainID, s_pCTSortInfo[s_pCTSortIndex[u16TrainID]].SafeHead.Lnk); + } + } + else + { + ; + } + u8Flag = elm_IsCTTailUKT(u16TrainID); + /*- ǷCTпUT */ + if (FLAG_SET == u8Flag) + { + /*- зӵͼͬ */ + if (EMAP_SAME_DIR == u8Dir_tail) + { + /*- ǰ˿ɵгǰUT */ + TrainAddSuspectLeft(u16TrainID, s_pCTSortInfo[s_pCTSortIndex[u16TrainID]].SafeTail.Lnk); + } + else + { + /*- ˿ɵгUT */ + TrainAddSuspectRight(u16TrainID, s_pCTSortInfo[s_pCTSortIndex[u16TrainID]].SafeTail.Lnk); + } + } + else + { + ; + } + } + else + { + ; + } + } +} +/***************************************************************************** +* @name SortUCT +* @brief ʧͨų +* @param[in] +* @return +* @note гģijϢͨŹϳ +* IDUCTͨŹϳ +* +* +*****************************************************************************/ +static void SortUCT(void) +{ + UINT16 cycIndex = DEFAULT_ZERO; /* */ + UINT16 TrainID = DEFAULT_ZERO; + UINT8 u8LinkNum = DEFAULT_ZERO; /*ijlink*/ + UINT8 u8Index = DEFAULT_ZERO; /*гlink */ + UINT16 u16LinkIndex = DEFAULT_ZERO; /* Link */ + UINT32 u32LinkLenth = DEFAULT_ZERO; /* Link lenth */ + UINT16 LinkList[MAX_LINK_LIST_NUM] = { 0U }; /* Linkб */ + const EnvelopeStruct* pEnvelope = NULL; + + UINT8 TempNum = DEFAULT_ZERO; + UINT16 LinkListTemp[MAX_LINK_LIST_NUM] = { DEFAULT_ZERO }; + UINT16 AcID = DEFAULT_ZERO; + UINT8 u8OccState = DEFAULT_ZERO; + + for (cycIndex = 0U; cycIndex < s_TrainELSeq.ELNum; cycIndex++) + { + /*аҵʧͨų*/ + pEnvelope = elm_GetEnvelopeInfoByID(s_TrainELSeq.TrainEnveLopeID[cycIndex]); + + if (NULL != pEnvelope) + { + if (TYPE_UCT == pEnvelope->envelopeType) + { + /**ѯгڵlink*/ + u8LinkNum = LinkManage_GetLinkInfoExp(pEnvelope->startPos, pEnvelope->endPos, pEnvelope->startPos.Dir, LinkList); + TempNum = DEFAULT_ZERO; + + /*UCTֻҪȫʼ˵ն˵linkʼ˵ն˵linkctѾǿɡ*/ + /*LinkListת*/ + for (u8Index = 0U; u8Index < u8LinkNum; u8Index++) + { + u32LinkLenth = GetLinkLengthById(LinkList[u8Index]); + if (1u == u8LinkNum) + { + if (((0u < pEnvelope->startPos.Off) && (u32LinkLenth > pEnvelope->startPos.Off)) + || ((0u < pEnvelope->endPos.Off) && (u32LinkLenth > pEnvelope->endPos.Off))) + { + ; /*ʼ˻ն˲Ƕ˵㣬账*/ + } + else + { + /*˶Ƕ˵*/ + LinkListTemp[0] = LinkList[0]; + TempNum = 1u; + } + } + else if (MAX_LINK_LIST_NUM > u8LinkNum) + { + if ((0u == u8Index) + && (0u != pEnvelope->startPos.Off) && (u32LinkLenth != pEnvelope->startPos.Off)) + { + ; /* 㲻Ƕ˵㣬˵ͬlinkCT޳ */ + } + else if (((u8LinkNum - 1u) == u8Index) + && (0u != pEnvelope->endPos.Off) && (u32LinkLenth != pEnvelope->endPos.Off)) + { + ; /* յ㲻Ƕ˵㣬˵ͬlinkCT޳ */ + } + else + { + LinkListTemp[TempNum] = LinkList[u8Index]; + TempNum++; + } + } + else + { + ; /**/ + } + } + /************/ + + /*гڵLinkгʼֵ0; Ƿβ? ; */ + for (u8Index = 0U; u8Index < TempNum; u8Index++) + { + /*linkIDҵ*/ + u16LinkIndex = g_pSortLinkIndex[LinkListTemp[u8Index]]; + + AcID = GetLinkBelongAcId(LinkListTemp[u8Index]); + u8OccState = elm_PrepareACStatus(AcID); /*Ŀǰuctܰסֱ죬ѱ书ܲסĻҪ*/ + + /*- LinkǷ */ + if ((DEFAULT_ZERO != u16LinkIndex) && (ELM_AC_OCC == u8OccState)) + { + /*- UT */ + debug_infor_printf((const)"AS0067:[%d Train] In Link[%d] Insert UCT Train\n", NAME_FAILUREAREA, (const)LinkListTemp[u8Index]); + SeqInsert(NAME_FAILUREAREA, TYPE_FAILURE, cycIndex, &g_pSortLinkInfo[u16LinkIndex].u8TrainNum, g_pSortLinkInfo[u16LinkIndex].TrainList, 0U); + } + else + { + ; /**/ + } + + } + + } + else + { + /*UCT账*/ + } + } + else + { + ; + } + } +} + + +/***************************************************************************** +* @name SortUKT +* @brief UT +* @param[in] +* @return +* @note UT򣬸ɸѡģijϢӴUT +* +*****************************************************************************/ +static void SortUKT(void) +{ + UINT16 u16LinkIndex = DEFAULT_ZERO;/* Link */ + UINT16 cycIndex = DEFAULT_ZERO; /* */ + + UINT8 u8LinkNum = DEFAULT_ZERO; /*ijlink*/ + UINT8 u8Index = DEFAULT_ZERO; /*link */ + UINT16 LinkList[MAX_LINK_LIST_NUM] = { 0U }; /* Linkб */ + const EnvelopeStruct* pEnvelope = NULL; + + for (cycIndex = 0U; cycIndex < s_TrainELSeq.ELNum; cycIndex++) + { + /*аҵUKTID255ΪUKT*/ + pEnvelope = elm_GetEnvelopeInfoByID(s_TrainELSeq.TrainEnveLopeID[cycIndex]); + if (NULL != pEnvelope) + { + if ((NAME_FAILUREAREA == pEnvelope->trainID[0]) && (TYPE_FAILURE == pEnvelope->envelopeType)) + { + /**ѯгڵlink*/ + u8LinkNum = LinkManage_GetLinkInfoExp(pEnvelope->startPos, pEnvelope->endPos, pEnvelope->startPos.Dir, LinkList); + /*гڵLinkгʼֵ0; Ƿβ? ; */ + for (u8Index = 0U; u8Index < u8LinkNum; u8Index++) + { + if (MAX_LINK_LIST_NUM > u8Index) + { + /*linkIDҵ*/ + u16LinkIndex = g_pSortLinkIndex[LinkList[u8Index]]; + /*- LinkǷ */ + if (DEFAULT_ZERO != u16LinkIndex) + { + /*- UT */ + debug_infor_printf((const)"AS0066:[Train %d ]in Link[%d] Set UT Train\n", NAME_FAILUREAREA, (const) LinkList[u8Index]); + SeqInsert(NAME_FAILUREAREA, TYPE_FAILURE, cycIndex, &g_pSortLinkInfo[u16LinkIndex].u8TrainNum, g_pSortLinkInfo[u16LinkIndex].TrainList, 0U); + } + else + { + ; + } + } + else + { + ; + } + } + } + else + { + /*UKT账*/ + } + } + else + { + ;/*޴*/ + } + + } + +} + +/***************************************************************************** +* @name CTAddTrain +* @brief ͨųмӳ +* @param[in] u16TrainID гID +* @return +* @note +*****************************************************************************/ +static void CTAddTrain(UINT16 u16TrainID) +{ + UINT16 u16Index = DEFAULT_ZERO; /* ͨų */ + + /*- CTDz */ + if (DEFAULT_ZERO == s_pCTSortIndex[u16TrainID]) + { + /*- µCT */ + debug_infor_printf((const) "AS0005:CT Train Sequences Add Train[%d]\n", (const)u16TrainID); + s_pCTSortIndex[u16TrainID] = GetFreeCTNode(); + } + else + { + ; + } + + u16Index = s_pCTSortIndex[u16TrainID]; + + /*- CTǷЧ,ͨųϢ*/ + if (DEFAULT_ZERO != u16Index) + { + s_pCTSortInfo[u16Index].u16SortTrainID = u16TrainID; + s_pCTSortInfo[u16Index].u8NodeValidTag = FLAG_SET; + + /*****IDȡгз,ȫ********/ + s_pCTSortInfo[u16Index].u8SortTrainDir = GetTrainSafeTailDir(u16TrainID);/* ȫβķ*/ + (void)TrainManage_GetTrainSafeLoc(FINDHEADSAFEFLAG, u16TrainID, &s_pCTSortInfo[u16Index].SafeHead.Lnk, &s_pCTSortInfo[u16Index].SafeHead.Off, &s_pCTSortInfo[u16Index].SafeHead.Dir); + (void)TrainManage_GetTrainSafeLoc(FINDTAILSAFEFLAG, u16TrainID, &s_pCTSortInfo[u16Index].SafeTail.Lnk, &s_pCTSortInfo[u16Index].SafeTail.Off, &s_pCTSortInfo[u16Index].SafeTail.Dir); + } + else + { + debug_infor_printf((const)"FATAL:[AS]ͨų\n"); + } +} + +/***************************************************************************** +* @name UCTAddTrain +* @brief Ӷͨų +* @param[in] u16TrainID гID +* @return +* @note +*****************************************************************************/ +static void UCTAddTrain(UINT16 u16TrainID, IN UINT8 u8Dir,IN LOD_STRU sHead, IN LOD_STRU sTail) +{ + UINT16 u16Index = DEFAULT_ZERO; /* ͨų */ + + /*- CTDz */ + if (DEFAULT_ZERO == s_pCTSortIndex[u16TrainID]) + { + /*- µCT */ + debug_infor_printf((const)"AS0055:UCT Train Sequences Add Train[%d]\n", (const)u16TrainID); + s_pCTSortIndex[u16TrainID] = GetFreeCTNode(); + } + else + { + ; + } + + u16Index = s_pCTSortIndex[u16TrainID]; + + /*- CTǷЧ,ͨųϢ*/ + if (DEFAULT_ZERO != u16Index) + { + s_pCTSortInfo[u16Index].u16SortTrainID = u16TrainID; + s_pCTSortInfo[u16Index].u8NodeValidTag = FLAG_SET; + + s_pCTSortInfo[u16Index].u8SortTrainDir = u8Dir; + s_pCTSortInfo[u16Index].SafeHead = sHead; + s_pCTSortInfo[u16Index].SafeHead = sTail; + } + else + { + debug_infor_printf((const)"FATAL:[AS]ͨųorʧͨų\n"); + } +} + +/***************************************************************************** +* @name CTDelTrain +* @brief ͨųɾ +* @param[in] u16TrainID гID +* @return +* @note +*****************************************************************************/ +static void CTDelTrain(UINT16 u16TrainID) +{ + UINT16 u16Index = DEFAULT_ZERO; + + u16Index = s_pCTSortIndex[u16TrainID]; + /*- ͨųǷ */ + if (DEFAULT_ZERO != u16Index) + { + /*- ɾó */ + debug_infor_printf((const)"AS0006:CT Train Sequences Delete Train[%d], Envelope[%d,%d]~[%d,%d], Direction[%x]\n", u16TrainID, + s_pCTSortInfo[u16Index].SafeHead.Lnk, s_pCTSortInfo[u16Index].SafeHead.Off, + s_pCTSortInfo[u16Index].SafeTail.Lnk, s_pCTSortInfo[u16Index].SafeTail.Off, + s_pCTSortInfo[u16Index].u8SortTrainDir); + (void)memset(&s_pCTSortInfo[u16Index], 0, sizeof(CT_SORT_INFO_s)); + s_pCTSortIndex[u16TrainID] = DEFAULT_ZERO; + } + else + { + /*- ɴ֧ */ + debug_infor_printf((const) "AS0007:Try to Delete Train in CT Train Sequences, But The Train Did Not Exist\n"); + } +} + +/***************************************************************************** +* @name GetFreeCTNode +* @brief ȡеͨųнڵ +* @param[in] +* @return ͨų +* @note +*****************************************************************************/ +static UINT16 GetFreeCTNode(void) +{ + UINT16 u16Index = DEFAULT_ZERO; + UINT16 u16Ret = DEFAULT_ZERO; + + /*- ͨг1 ; Ƿβ? ; */ + for (u16Index = 1U; u16Index <= SIZE_MAX_COM_VOBC_NUM; u16Index++) + { + /*- Ƿǿнڵ */ + if (FLAG_SET != s_pCTSortInfo[u16Index].u8NodeValidTag) + { + /*- ¼ڵ˳ѭ */ + u16Ret = u16Index; + break; + } + else + { + ; + } + } + return u16Ret; +} + + +/***************************************************************************** +* @name LinksAddTrain +* @brief Linkг +* @param[in] u16TrainID гID +* @param[in] u8TrainType г +* @return +* @note +*****************************************************************************/ +static void LinksAddTrain(UINT16 u16TrainID, UINT8 u8TrainType) +{ + UINT8 u8LinkNum = DEFAULT_ZERO; /* */ + UINT8 u8Index = DEFAULT_ZERO; /* ѭ */ + UINT16 u16TrainIndex = DEFAULT_ZERO; /* ͨų */ + UINT16 u16LinkList[MAX_LINK_LIST_NUM] = {0u}; /* Linkб */ + + u16TrainIndex = s_pCTSortIndex[u16TrainID]; + + /**ѯгڵlink*/ + u8LinkNum = LinkManage_GetLinkInfoExp(s_pCTSortInfo[u16TrainIndex].SafeTail,s_pCTSortInfo[u16TrainIndex].SafeHead, s_pCTSortInfo[u16TrainIndex].u8SortTrainDir, u16LinkList); + + /*гڵLinkгʼֵ0; Ƿβ? ; */ + for (u8Index = 0U; u8Index < u8LinkNum; u8Index++) + { + if (MAX_LINK_LIST_NUM > u8Index) + { + /*- Linkг */ + LinkAddTrain(u16LinkList[u8Index], u16TrainID, u8TrainType); + } + else + { + ; + } + } +} + + +/***************************************************************************** +* @name LinkAddTrain +* @brief Linkλг +* @param[in] u16LinkID Link ID +* @param[in] u16TrainID гID +* @param[in] u8Type г +* @return +* @note +*****************************************************************************/ +static void LinkAddTrain(UINT16 u16LinkID, UINT16 u16TrainID, UINT8 u8Type) +{ + UINT8 u8Order = DEFAULT_ZERO; /* λ */ + UINT8 u8Index = DEFAULT_ZERO; /* ѭ */ + UINT16 u16LinkIndex = DEFAULT_ZERO; /* */ + + u16LinkIndex = g_pSortLinkIndex[u16LinkID]; + + /*- ǷDZLink */ + if (DEFAULT_ZERO != u16LinkIndex) + { + /*- LinkǷ쳣 */ + if (FLAG_SET == g_pSortLinkInfo[u16LinkIndex].u8SortFail) + { + debug_infor_printf((const)"AS0011: Try To Add Train[%d] in Abnormal Link[%d]\n", u16TrainID, u16LinkID ); + } + /*- LinkгǷΪ */ + else if (DEFAULT_ZERO == g_pSortLinkInfo[u16LinkIndex].u8TrainNum) + { + debug_infor_printf((const)"AS0028:Link[%d] add the first train[%d]\n", u16LinkID, u16TrainID); + g_pSortLinkInfo[u16LinkIndex].TrainList[0].u16TrainID = u16TrainID; + g_pSortLinkInfo[u16LinkIndex].TrainList[0].u8TrainType = u8Type; + g_pSortLinkInfo[u16LinkIndex].u8TrainNum = 1U; + } + /*- LinkǷ */ + else if (SIZE_MAX_TRAINOFAC <= g_pSortLinkInfo[u16LinkIndex].u8TrainNum) + { + /* linkг࣬ΪLINK IDг */ + g_pSortLinkInfo[u16LinkIndex].u8SortFail = FLAG_SET; + debug_infor_printf((const)"AS0029:Link[%d] have too many trains, Train:[%d]\n", u16LinkID, g_pSortLinkInfo[u16LinkIndex].u8TrainNum); + /*- @alias Linkг࣬쳣 */ + for (u8Index = 0U; u8Index < g_pSortLinkInfo[u16LinkIndex].u8TrainNum; u8Index++) + { + debug_infor_printf((const)"[%d,%d]", + g_pSortLinkInfo[u16LinkIndex].TrainList[u8Index].u16TrainID, + g_pSortLinkInfo[u16LinkIndex].TrainList[u8Index].u8TrainType); + } + debug_infor_printf((const)"\n"); + } + else + { + /*- Linkгʼֵ0; Ƿβ? ; */ + for (u8Index = 0U; u8Index < g_pSortLinkInfo[u16LinkIndex].u8TrainNum; u8Index++) + { + u8Order = CalcTrainOrder(u16TrainID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8Index].u16TrainID,u16LinkID); + /*- ³Ƿڸó */ + if (AS_ORDER_DOWNSTREAM == u8Order) + { + /*- ³ڸóΣ */ + } + else + { + /*- ³Ƿڸó */ + if (AS_ORDER_UPSTREAM == u8Order) + { + /*- ³ڸóΣҵλãѭ˳ */ + } + else + { + /*- 쳣ѭ쳣˳ */ + g_pSortLinkInfo[u16LinkIndex].u8SortFail = FLAG_SET; + debug_infor_printf((const)"AS0030:Link[%d] sort faild : Failed to calculate relative position[%d Train][%d Train]\n", + u16LinkID, u16TrainID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8Index].u16TrainID); + + } + /* ֻҪ³ڸóΣͶѭٸǷ쳣Ƿ */ + /*- ѭ˳ */ + break; + } + } + + /* + * ҵ˲λʱڲλò룬 + * ûҵλʱ˵³ĩβ + */ + /*- Ƿ */ + if (FLAG_UNSET == g_pSortLinkInfo[u16LinkIndex].u8SortFail) + { + /*- Linkвг */ + debug_infor_printf((const) "AS0031:Link[%d] in [%d/%d] insert train[%d,%d]\n", + u16LinkID, u8Index, g_pSortLinkInfo[u16LinkIndex].u8TrainNum, u16TrainID, u8Type); + SeqInsert(u16TrainID, u8Type, 0 ,&g_pSortLinkInfo[u16LinkIndex].u8TrainNum, g_pSortLinkInfo[u16LinkIndex].TrainList, u8Index); + } + else + { + ; + } + } + } + else + { + ; + } +} + + +/***************************************************************************** +* @name SeqInsert +* @brief +* @param[in] u16TrainID гID +* @param[in] u8TrainType г +* @param[in] u16ELID гID +* @param[in] pu8TrainNum ǰг +* @param[out] pu8TrainNum г +* @param[in] TrainList ǰгб +* @param[out] TrainList гб +* @param[out] u8InsertIndex λ +* @return +* @note +*****************************************************************************/ +static void SeqInsert(IN UINT16 u16TrainID, IN UINT8 u8TrainType, IN UINT16 u16ELID, INOUT UINT8 *pu8TrainNum, INOUT TRAIN_SEQUANCE_s TrainList[SIZE_MAX_TRAINOFAC], IN UINT8 u8InsertIndex) +{ + UINT8 u8Cycle = DEFAULT_ZERO; /* ѭ */ + /*- ǷԽ */ + if ((*pu8TrainNum < SIZE_MAX_TRAINOFAC) && (u8InsertIndex <= *pu8TrainNum)) + { + /*- @alias λü֮г */ + for (u8Cycle = *pu8TrainNum; u8Cycle > u8InsertIndex; u8Cycle--) + { + TrainList[u8Cycle] = TrainList[u8Cycle - 1U]; + } + /*- г */ + TrainList[u8InsertIndex].u16TrainID = u16TrainID; + TrainList[u8InsertIndex].u8TrainType = u8TrainType; + TrainList[u8InsertIndex].u16ELID = u16ELID; + (*pu8TrainNum)++; + } + else + { + debug_infor_printf((const)"AS0027:When Index [%d/%d] insert Train[%d,%d], The number of trains overflowed \n", u8InsertIndex, *pu8TrainNum, u16TrainID, u8TrainType); + /*- ɴ֧ */ + for (u8Cycle = DEFAULT_ZERO; u8Cycle < *pu8TrainNum; u8Cycle++) + { + debug_infor_printf((const) "[%d,%d]", TrainList[u8Cycle].u16TrainID, TrainList[u8Cycle].u8TrainType); + } + debug_infor_printf((const) "\n"); + } +} + +/***************************************************************************** +* @name CalcTrainOrder +* @brief гλ +* @param[in] u16Train1 г1ID +* @param[in] u16Train2 г2ID +* @param[in] u16LinkID Ҫӳlink +* @return +* AS_ORDER_DOWNSTREAM (0x55) [T1][T2]=0x55T1<-T2 +* AS_ORDER_UPSTREAM (0xAA) [T1][T2]=0xAAT1->T2 +* AS_ORDER_FAIL (0xFF) ʧ +* @note +*****************************************************************************/ +static UINT8 CalcTrainOrder(IN UINT16 u16Train1, IN UINT16 u16Train2, UINT16 u16LinkID) +{ + UINT8 u8Ret = AS_ORDER_FAIL; /* ֵ */ + UINT8 u8HeadSort = DEFAULT_ZERO; /* ͷ */ + UINT8 u8TailSort = DEFAULT_ZERO; /* β */ + UINT16 u16T1Index = DEFAULT_ZERO; /* г1ͨųе */ + UINT16 u16T2Index = DEFAULT_ZERO; /* г2ͨųе */ + LOD_STRU T1StartPos = {0u}; /* г1 */ + LOD_STRU T1EndPos = { 0u }; /* г1յ */ + LOD_STRU T2StartPos = { 0u } ; /* г2 */ + LOD_STRU T2EndPos = { 0u }; /* г2յ */ + + LOD_STRU tempPos = { 0u }; /* ʱ */ + + u16T1Index = s_pCTSortIndex[u16Train1]; + u16T2Index = s_pCTSortIndex[u16Train2]; + + /*- гͨųǷ */ + if ((DEFAULT_ZERO != u16T1Index) && (DEFAULT_ZERO != u16T2Index) && (DEFAULT_ZERO != u16LinkID)) + { + T1StartPos = s_pCTSortInfo[u16T1Index].SafeTail; + T1EndPos = s_pCTSortInfo[u16T1Index].SafeHead; + /*ݱзѡʼ˺նˣжгзǷͬ*/ + u8Ret = IsPointABSameDir(s_pCTSortInfo[u16T1Index].SafeHead, s_pCTSortInfo[u16T2Index].SafeTail); + if (FLAG_SET == u8Ret) + { + /*ͬ*/ + T2StartPos = s_pCTSortInfo[u16T2Index].SafeTail; + T2EndPos = s_pCTSortInfo[u16T2Index].SafeHead; + } + else if (FLAG_UNSET == u8Ret) + { + /**/ + T2StartPos = s_pCTSortInfo[u16T2Index].SafeHead; + T2EndPos = s_pCTSortInfo[u16T2Index].SafeTail; + } + else + { + u8Ret = AS_ORDER_FAIL; + } + + if (AS_ORDER_FAIL != u8Ret) + { + /**ȡǰλùϵ****************/ + /*0x00Uѯʧܣ0x01U11ں󷽣0x02U1ķ1ǰ0x03Uغ*/ + u8HeadSort = LinkManage_CheckSortTrainExp(T1StartPos.Lnk, T1StartPos.Off, T2StartPos.Lnk, T2StartPos.Off, T1StartPos.Dir); + u8TailSort = LinkManage_CheckSortTrainExp(T1EndPos.Lnk, T1EndPos.Off,T2EndPos.Lnk, T2EndPos.Off, T1EndPos.Dir); + + tempPos.Lnk = u16LinkID; + tempPos.Off = 1; /*ֵΪ1cm*/ + tempPos.Dir = EMAP_SAME_DIR; + + /*ѯ֮Ƿͬ򣬿1ķʹӳlinkǷͬ*/ + u8Ret = IsPointABSameDir(T1EndPos, tempPos); + + /*- 1Ƿ2 */ + if ((0x01U == u8HeadSort) && (0x01U == u8TailSort) && (CI_ERROR != u8Ret)) + { + /*- 1 (0-max,0)*/ + if (FLAG_SET == u8Ret) + { + u8Ret = AS_ORDER_UPSTREAM; + } + else + { + u8Ret = AS_ORDER_DOWNSTREAM; + } + + } + /*- 1Ƿ2(0-max,max) */ + else if ((0x02U == u8HeadSort) && (0x02U == u8TailSort) && (CI_ERROR != u8Ret)) + { + /*- 1 */ + + if (FLAG_SET == u8Ret) + { + u8Ret = AS_ORDER_DOWNSTREAM; + } + else + { + u8Ret = AS_ORDER_UPSTREAM; + } + } + else + { + /*- ѯʧ(г಻ɴ?) */ + debug_infor_printf((const)"AS0024: Get relative position error, Result:[%d,%d],[%d Train][%d,%d]~[%d,%d],[%d Train][%d,%d]~[%d,%d]\n", u8HeadSort, u8TailSort, + u16Train1, s_pCTSortInfo[u16T1Index].SafeHead.Lnk, s_pCTSortInfo[u16T1Index].SafeHead.Off, + s_pCTSortInfo[u16T1Index].SafeTail.Lnk, s_pCTSortInfo[u16T1Index].SafeTail.Off, + u16Train2, s_pCTSortInfo[u16T2Index].SafeHead.Lnk, s_pCTSortInfo[u16T2Index].SafeHead.Off, + s_pCTSortInfo[u16T2Index].SafeTail.Lnk, s_pCTSortInfo[u16T2Index].SafeTail.Off); + u8Ret = AS_ORDER_FAIL; + } + + } + + } + else + { + /*- ɴ֧ */ + debug_infor_printf((const) "AS0025: Get relative position error, Train don't exist[%d,%d],[%d,%d]\n", u16Train1, u16T1Index, u16Train2, u16T2Index); + u8Ret = AS_ORDER_FAIL; + } + + return u8Ret; +} + +/***************************************************************************** +* @name TrainAddSuspectLeft +* @brief гӹϳ +* @param[in] u16TrainID гID +* @param[in] u16LinkID LINK ID +* @return +* @note +*****************************************************************************/ +static void TrainAddSuspectLeft(UINT16 u16TrainID, UINT16 u16LinkID) +{ + UINT8 u8SeqIndex = DEFAULT_ZERO; /* */ + UINT16 u16LinkIndex = DEFAULT_ZERO; /* Link */ + + /*- ʼ */ + u16LinkIndex = g_pSortLinkIndex[u16LinkID]; + + /*- LinkǷڱZC */ + if (DEFAULT_ZERO != u16LinkIndex) + { + /*- ұгLinkеλ */ + u8SeqIndex = as_SeqSearch(u16TrainID, g_pSortLinkInfo[u16LinkIndex].u8TrainNum, g_pSortLinkInfo[u16LinkIndex].TrainList); + /*- LinkǷ쳣 */ + if (FLAG_SET == g_pSortLinkInfo[u16LinkIndex].u8SortFail) + { + debug_infor_printf((const) "AS0014:At abnormal Link[%d], train[%d] Try to add Leftsuspicious Train\n", u16LinkID, u16TrainID); + } + /*- Ƿʧ*/ + else if (INVALID_8 == u8SeqIndex) + { + /* гʧܣΪLINK IDгID */ + debug_infor_printf((const)"AS0015:[%d Train] At Link[%d]Add Leftsuspicious Train failed,(Axle sequence Error[%d])\n", + u16TrainID, u16LinkID, g_pSortLinkInfo[u16LinkIndex].u8TrainNum); + /*- @alias ɴ֧ */ + for (u8SeqIndex = DEFAULT_ZERO; u8SeqIndex < g_pSortLinkInfo[u16LinkIndex].u8TrainNum; u8SeqIndex++) + { + debug_infor_printf((const) "[%d,%d]", + g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex].u16TrainID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex].u8TrainType); + } + debug_infor_printf((const) "\n"); + } + /*- ͷǷѾйϳ */ + else if ((DEFAULT_ZERO < u8SeqIndex) && (TYPE_FAILURE == g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex - 1U].u8TrainType)) + { + /*- ظ */ + debug_infor_printf((const)"AS0016:[%d Train] At Link[%d] left have UT Train[%d,%d], No more additions\n", + u16TrainID, u16LinkID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex - 1U].u16TrainID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex - 1U].u8TrainType); + } + /*- Ƿ */ + else if (SIZE_MAX_TRAINOFAC <= g_pSortLinkInfo[u16LinkIndex].u8TrainNum) + { + /* гʧܣΪLINK IDгID */ + g_pSortLinkInfo[u16LinkIndex].u8SortFail = FLAG_SET; + debug_infor_printf((const) "AS0017:[%d Train] At Link[%d] Add Leftsuspicious Train Failed, too many trains [%d] in Link\n", u16TrainID, u16LinkID, g_pSortLinkInfo[u16LinkIndex].u8TrainNum); + /*- @alias ü쳣 */ + for (u8SeqIndex = DEFAULT_ZERO; u8SeqIndex < g_pSortLinkInfo[u16LinkIndex].u8TrainNum; u8SeqIndex++) + { + debug_infor_printf((const)"[%d,%d]", + g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex].u16TrainID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex].u8TrainType); + } + } + else + { + /*- ӹϳ */ + debug_infor_printf((const) "AS0018:[%d Train] At Link[%d][%d/%d] Add Leftsuspicious Train\n", u16TrainID, u16LinkID, u8SeqIndex, g_pSortLinkInfo[u16LinkIndex].u8TrainNum); + SeqInsert(NAME_FAILUREAREA, TYPE_FAILURE,0, &g_pSortLinkInfo[u16LinkIndex].u8TrainNum, g_pSortLinkInfo[u16LinkIndex].TrainList, u8SeqIndex); + } + } + else + { + ; + } + +} + +/***************************************************************************** +* @name TrainAddSuspectRight +* @brief гҶӹϳ +* @param[in] u16TrainID гID +* @param[in] u16LinkID LINK ID +* @return +* @note +*****************************************************************************/ +static void TrainAddSuspectRight(UINT16 u16TrainID, UINT16 u16LinkID) +{ + UINT8 u8SeqIndex = DEFAULT_ZERO; /* */ + UINT16 u16LinkIndex = DEFAULT_ZERO; /* */ + + /*- ʼ */ + u16LinkIndex = g_pSortLinkIndex[u16LinkID]; + + /*- LinkǷڱZC */ + if (DEFAULT_ZERO != u16LinkIndex) + { + /*- ұгLinkеλ */ + u8SeqIndex = as_SeqSearch(u16TrainID, g_pSortLinkInfo[u16LinkIndex].u8TrainNum, g_pSortLinkInfo[u16LinkIndex].TrainList); + /*- LinkǷ쳣 */ + if (FLAG_SET == g_pSortLinkInfo[u16LinkIndex].u8SortFail) + { + debug_infor_printf((const) "AS0019:At Abnormal Link[%d], Train[%d] Try to Add Rightsuspicious Train\n", u16LinkID, u16TrainID); + } + /*- Ƿʧ*/ + else if (INVALID_8 == u8SeqIndex) + { + debug_infor_printf((const) "AS0020:[%d Train] At Link[%d] Add Leftsuspicious Train Failed (Axle sequence Error[%d])\n", + u16TrainID, u16LinkID, g_pSortLinkInfo[u16LinkIndex].u8TrainNum); + /*- ɴ֧ */ + for (u8SeqIndex = DEFAULT_ZERO; u8SeqIndex < g_pSortLinkInfo[u16LinkIndex].u8TrainNum; u8SeqIndex++) + { + debug_infor_printf((const)"[%d,%d]", + g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex].u16TrainID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex].u8TrainType); + } + } + /*- βǷѾйϳ */ + else if (((u8SeqIndex + 1U) < g_pSortLinkInfo[u16LinkIndex].u8TrainNum) && (TYPE_FAILURE == g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex + 1U].u8TrainType)) + { + /*- ظ */ + debug_infor_printf((const) "AS0021:[%d Train]At Link[%d] Right have UT Train[%d,%d], No more additions\n", + u16TrainID, u16LinkID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex + 1U].u16TrainID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex + 1U].u8TrainType); + } + /*- LinkǷ */ + else if (SIZE_MAX_TRAINOFAC <= g_pSortLinkInfo[u16LinkIndex].u8TrainNum) + { + g_pSortLinkInfo[u16LinkIndex].u8SortFail = FLAG_SET; + debug_infor_printf((const)"AS0022:[%d Train] At Link[%d] Add Rightsuspicious Train Failed, too much trains[%d] in Link\n", u16TrainID, u16LinkID, g_pSortLinkInfo[u16LinkIndex].u8TrainNum); + /*- @alias Link쳣 */ + for (u8SeqIndex = DEFAULT_ZERO; u8SeqIndex < g_pSortLinkInfo[u16LinkIndex].u8TrainNum; u8SeqIndex++) + { + debug_infor_printf((const) "[%d,%d]", + g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex].u16TrainID, g_pSortLinkInfo[u16LinkIndex].TrainList[u8SeqIndex].u8TrainType); + } + } + else + { + /*- ӹϳ */ + debug_infor_printf((const)"AS0023:[%d Train] At Link[%d][%d/%d] Add Rightsuspicious Train\n", u16TrainID, u16LinkID, u8SeqIndex + 1U, g_pSortLinkInfo[u16LinkIndex].u8TrainNum); + SeqInsert(NAME_FAILUREAREA, TYPE_FAILURE, 0,&g_pSortLinkInfo[u16LinkIndex].u8TrainNum, g_pSortLinkInfo[u16LinkIndex].TrainList, u8SeqIndex + 1U); + } + } + else + { + /*none*/ + } +} + + +/***************************************************************************** +* @name CalcEnveLopeOrderInAC +* @brief λ,ͬʱ䵽 +* @param[in] p1 1 +* @param[in] p2 2 +* @param[in] u16ACID +* @return +* AS_ORDER_DOWNSTREAM (0x55) 0x55p1->p2 +* AS_ORDER_UPSTREAM (0xAA) 0xAAp1<-p2 +* AS_ORDER_FAIL (0xFF) ʧ +* @note +*****************************************************************************/ +static UINT8 CalcEnveLopeOrderInAC(IN const EnvelopeStruct* p1, IN const EnvelopeStruct* p2, UINT16 u16ACID) +{ + UINT8 u8Ret = AS_ORDER_FAIL; /* ֵ */ + UINT8 u8HeadSort = DEFAULT_ZERO; /* ͷ */ + UINT8 u8TailSort = DEFAULT_ZERO; /* β */ + UINT16 * pAcLinkId = NULL; /* ΰlink */ + LOD_STRU E1StartPos = { 0u }; /* 1 */ + LOD_STRU E1EndPos = { 0u }; /* 1յ */ + LOD_STRU E2StartPos = { 0u }; /* 2 */ + LOD_STRU E2EndPos = { 0u }; /* 2յ */ + LOD_STRU tempPos = { 0u }; + + pAcLinkId = GetAxisLinkIdBuf(u16ACID); + + if ((NULL == p1) || (NULL == p2) || (NULL == pAcLinkId)) + { + ;/**/ + } + else + { + tempPos.Lnk = pAcLinkId[0]; + tempPos.Off = 1u; /*ֵΪ1cm*/ + tempPos.Dir = EMAP_SAME_DIR; + + E1StartPos = p1->endPos; + E1EndPos = p1->startPos; + + /*жǷͬҪȷ¹ϳҲҪȷһ׼ǸķڵҪ*/ + u8Ret = IsPointABSameDir(p1->startPos, p2->endPos); + if (CI_ERROR != u8Ret) + { + if (FLAG_SET == u8Ret) + { + /*ͬ*/ + E2StartPos = p2->endPos; + E2EndPos = p2->startPos; + } + else + { + /**/ + E2StartPos = p2->startPos; + E2EndPos = p2->endPos; + } + + /**ȡǰλùϵ****************/ + /*0x00Uѯʧܣ0x01Uһλں󷽣0x02Uڶλں󷽣0x03Uʶĵλغ*/ + u8HeadSort = LinkManage_CheckSortTrainExp(E1StartPos.Lnk, E1StartPos.Off, E2StartPos.Lnk, E2StartPos.Off, E1StartPos.Dir); + u8TailSort = LinkManage_CheckSortTrainExp(E1EndPos.Lnk, E1EndPos.Off, E2EndPos.Lnk, E2EndPos.Off, E1EndPos.Dir); + + /*ѯ֮Ƿͬ򣬿1ķʹӳļǷͬ*/ + u8Ret = IsPointABSameDir(E1StartPos, tempPos); + + /*- 1Ƿ2 */ + if ((0x01U == u8HeadSort) && (0x01U == u8TailSort) && (CI_ERROR != u8Ret)) + { + /*- 1 (0-max,0)*/ + if (FLAG_SET == u8Ret) + { + u8Ret = AS_ORDER_UPSTREAM; + } + else + { + u8Ret = AS_ORDER_DOWNSTREAM; + } + } + /*- 1Ƿ2 */ + else if ((0x02U == u8HeadSort) && (0x02U == u8TailSort) && (CI_ERROR != u8Ret)) + { + /*- 1 */ + + if (FLAG_SET == u8Ret) + { + u8Ret = AS_ORDER_DOWNSTREAM; + } + else + { + u8Ret = AS_ORDER_UPSTREAM; + } + } + else + { + + u8Ret = AS_ORDER_FAIL; + + /*- ѯʧ(г಻ɴ?) */ + debug_infor_printf((const)"AS0040: Get relative position error, Result[%d,%d],[%d Train, ELid:%d][%d,%d]~[%d,%d],[%d Train,ELid:%d][%d,%d]~[%d,%d]\n", u8HeadSort, u8TailSort, + p1->trainID[0], p1->id, E1StartPos.Lnk, E1StartPos.Off, E1EndPos.Lnk, E1EndPos.Off, + p2->trainID[0], p2->id, E2StartPos.Lnk, E2StartPos.Off, E2EndPos.Lnk, E2EndPos.Off); + } + } + else + { + u8Ret = AS_ORDER_FAIL; + } + } + return u8Ret; +} + +/***************************************************************************** +* @name CalcEnveLopeOrder +* @brief λ +* @param[in] p1 1 +* @param[in] p2 2 +* @return +* AS_ORDER_DOWNSTREAM (0x55) 0x55p1->p2 +* AS_ORDER_UPSTREAM (0xAA) 0xAAp1<-p2 +* AS_ORDER_1INCLUDE2 p1p2(() ),( ())( () ) +* AS_ORDER_2INCLUDE1 p2p1(() ),( ())( () ) +* AS_ORDER_FAIL (0xFF) ʧ +* @note +*****************************************************************************/ +static UINT8 CalcEnveLopeOrder(IN const EnvelopeStruct* p1, IN const EnvelopeStruct* p2) +{ + UINT8 u8Ret = AS_ORDER_FAIL; /* ֵ */ + UINT8 u8HeadSort = DEFAULT_ZERO; /* ͷ */ + UINT8 u8TailSort = DEFAULT_ZERO; /* β */ + UINT16 * pAcLinkId = NULL; /* ΰlink */ + LOD_STRU E1StartPos = { 0u }; /* 1 */ + LOD_STRU E1EndPos = { 0u }; /* 1յ */ + LOD_STRU E2StartPos = { 0u }; /* 2 */ + LOD_STRU E2EndPos = { 0u }; /* 2յ */ + LOD_STRU tempPos = { 0u }; + + if ((NULL == p1) || (NULL == p2)) + { + ;/**/ + } + else + { + E1StartPos = p1->endPos; + E1EndPos = p1->startPos; + + /*жǷͬҪȷ¹ϳҲҪȷһ׼ǸķڵҪ*/ + u8Ret = IsPointABSameDir(p1->startPos, p2->endPos); + if (CI_ERROR != u8Ret) + { + if (FLAG_SET == u8Ret) + { + /*ͬ*/ + E2StartPos = p2->endPos; + E2EndPos = p2->startPos; + } + else + { + /**/ + E2StartPos = p2->startPos; + E2EndPos = p2->endPos; + } + + /**ȡǰλùϵ****************/ + /*0x00Uѯʧܣ0x01Uһλں󷽣0x02Uڶλں󷽣0x03Uʶĵλغ*/ + u8HeadSort = LinkManage_CheckSortTrainExp(E1StartPos.Lnk, E1StartPos.Off, E2StartPos.Lnk, E2StartPos.Off, E1StartPos.Dir); + u8TailSort = LinkManage_CheckSortTrainExp(E1EndPos.Lnk, E1EndPos.Off, E2EndPos.Lnk, E2EndPos.Off, E1EndPos.Dir); + + if ((0x01U == u8HeadSort) && (0x01U == u8TailSort)) + { + u8Ret = AS_ORDER_DOWNSTREAM; /*p1->p2*/ + } + else if ((0x02U == u8HeadSort) && (0x02U == u8TailSort) ) + { + u8Ret = AS_ORDER_UPSTREAM; /*p1<-p2*/ + } + else + { + if (((0x01U == u8HeadSort) && (0x03U == u8TailSort)) + || (((0x03U == u8HeadSort) && (0x01U == u8TailSort))) + || (((0x01U == u8HeadSort) && (0x02U == u8TailSort)))) + { + u8Ret = AS_ORDER_1INCLUDE2; /*1*/ + } + else if (((0x02U == u8HeadSort) && (0x03U == u8TailSort)) + || (((0x03U == u8HeadSort) && (0x02U == u8TailSort))) + || (((0x02U == u8HeadSort) && (0x01U == u8TailSort)))) + { + u8Ret = AS_ORDER_2INCLUDE1; /*p1*/ + } + else + { + u8Ret = AS_ORDER_FAIL; + } + /*- ѯʧ(г಻ɴ?) */ + debug_infor_printf((const)"AS0040: Get relative position error, Result[%d,%d],[%d Train,ELid:%d][%d,%d]~[%d,%d],[%d Train,ELid:%d][%d,%d]~[%d,%d]\n", u8HeadSort, u8TailSort, + p1->trainID[0], p1->id, E1StartPos.Lnk, E1StartPos.Off, E1EndPos.Lnk, E1EndPos.Off, + p2->trainID[0], p2->id, E2StartPos.Lnk, E2StartPos.Off, E2EndPos.Lnk, E2EndPos.Off); + } + } + else + { + u8Ret = AS_ORDER_FAIL; + } + } + return u8Ret; +} + + +void as_SortBaseEnveLope(void) +{ + /*еCTгϢ򣬲䵽*/ + SortAllEnveLopeInAC(); +} + +/***************************************************************************** +* @name SortAllEnveLopeInAC +* @brief гģȡеİ磬elmCT䵽AC +* @param[in] +* @return +* @note ݰģṩCT磬ÿϵİ +* עֻCT򣬶ǰɸѡЧδ +* Ҫṩ״̬ģ +* +*****************************************************************************/ +static void SortAllEnveLopeInAC(void) +{ + UINT16 ELIndex = DEFAULT_ZERO; /* */ + UINT8 ACNum = DEFAULT_ZERO; /*ijAC*/ + UINT8 u8Index = DEFAULT_ZERO; /*AC */ + + UINT16 ACList[AS_AC_MAX] = { 0U }; /* Linkб */ + const EnvelopeStruct* pEnvelope = NULL; + + /*ȡег*/ + for (ELIndex = 0U; ELIndex < s_TrainELSeq.ELNum; ELIndex++) + { + /*ȡ*/ + pEnvelope = elm_GetEnvelopeInfoByID(s_TrainELSeq.TrainEnveLopeID[ELIndex]); + if (NULL != pEnvelope) + { + if (TYPE_CT == pEnvelope->envelopeType) + { + /*гڵLinkгʼֵ0; Ƿβ? ; */ + for (u8Index = 0U; u8Index < pEnvelope->ACCnt; u8Index++) + { + /*- ACг */ + ACAddEnvelope(pEnvelope->ACID[u8Index], pEnvelope, s_TrainELSeq.TrainEnveLopeID[ELIndex]); + } + } + else + { + ; /*ֻCT*/ + } + + } + } +} + +/***************************************************************************** +* @name ACAddEnvelope +* @brief θݰӳ +* @param[in] u16ACID AC ID +* @param[in] pEnvelope г +* @param[in] u16ELID ID +* @return +* @note +*****************************************************************************/ +static void ACAddEnvelope(IN UINT16 u16ACID, IN const EnvelopeStruct *pEnvelope,IN UINT16 u16ELID) +{ + UINT8 u8Order = DEFAULT_ZERO; /* λ */ + UINT8 u8Index = DEFAULT_ZERO; /* ѭ */ + UINT8 u8Ret = DEFAULT_ZERO; /* ֵ */ + UINT16 ACIndex = DEFAULT_ZERO; /* link */ + const EnvelopeStruct* pEL = NULL; + + /*- ʼ */ + ACIndex = g_pSortACIndex[u16ACID]; + /*- ǷDZAC */ + if (DEFAULT_ZERO != ACIndex) + { + /*- ACǷ쳣 */ + if (FLAG_SET == g_pSortACInfo[ACIndex].u8SortFail) + { + debug_infor_printf((const) "AS0041:try to at abnormal AC[%d] add Train[%d]\n", u16ACID, pEnvelope->trainID[0]); + } + /*- ACгǷΪ */ + else if (DEFAULT_ZERO == g_pSortACInfo[ACIndex].u8TrainNum) + { + debug_infor_printf((const)"AS0042:AC[%d] add first Train[%d]\n", u16ACID, pEnvelope->trainID[0], pEnvelope->envelopeType); + g_pSortACInfo[ACIndex].TrainList[0].u16TrainID = pEnvelope->trainID[0]; + g_pSortACInfo[ACIndex].TrainList[0].u8TrainType = pEnvelope->envelopeType; + g_pSortACInfo[ACIndex].TrainList[0].u16ELID = u16ELID; /*u16ELID ==pEnvelope->id*/ + g_pSortACInfo[ACIndex].u8TrainNum = 1U; + } + /*- ACǷ */ + else if (SIZE_MAX_TRAINOFAC <= g_pSortACInfo[ACIndex].u8TrainNum) + { + g_pSortACInfo[ACIndex].u8SortFail = FLAG_SET; + debug_infor_printf((const) "AS0043:AC[%d]have too many trains [%d]\n", u16ACID, g_pSortACInfo[ACIndex].u8TrainNum); + /*- @alias ACг࣬쳣 */ + for (u8Index = 0U; u8Index < g_pSortACInfo[ACIndex].u8TrainNum; u8Index++) + { + debug_infor_printf((const)"[%d,%d]", + g_pSortACInfo[ACIndex].TrainList[u8Index].u16TrainID, + g_pSortACInfo[ACIndex].TrainList[u8Index].u8TrainType); + } + debug_infor_printf((const) "\n"); + } + else + { + for (u8Index = 0U; u8Index < g_pSortACInfo[ACIndex].u8TrainNum; u8Index++) + { + pEL = elm_GetEnvelopeInfoByID(g_pSortACInfo[ACIndex].TrainList[u8Index].u16ELID); + if (NULL != pEL) + { + u8Order = CalcEnveLopeOrderInAC(pEnvelope, pEL, u16ACID); + + /*- ³Ƿڸó */ + if (AS_ORDER_DOWNSTREAM == u8Order) + { + /*- ³ڸóΣ */ + } + else + { + /*- ³Ƿڸó */ + if (AS_ORDER_UPSTREAM == u8Order) + { + /*- ³ڸóΣҵλãѭ˳ */ + } + else + { + /*- 쳣ѭ쳣˳ */ + g_pSortACInfo[ACIndex].u8SortFail = FLAG_SET; + debug_infor_printf((const) "AS1044:AC[%d]쳣:λʧ[%d][%d]\n", + u16ACID, pEnvelope->trainID[0], g_pSortACInfo[ACIndex].TrainList[u8Index].u16TrainID); + + } + /* ֻҪ³ڸóΣͶѭٸǷ쳣Ƿ */ + /*- ѭ˳ */ + break; + } + } + else + { + ; + } + } + /* + * ҵ˲λʱڲλò룬 + * ûҵλʱ˵³ĩβ + */ + /*- Ƿ */ + if (FLAG_UNSET == g_pSortACInfo[ACIndex].u8SortFail) + { + /*- ACвг */ + debug_infor_printf((const) "AS1045:AC[%d][%d/%d]г[%d,%d]\n", + u16ACID, u8Index, g_pSortACInfo[ACIndex].u8TrainNum, pEnvelope->trainID[0], pEnvelope->envelopeType); + SeqInsert(pEnvelope->trainID[0], pEnvelope->envelopeType, pEnvelope->id, &g_pSortACInfo[ACIndex].u8TrainNum, g_pSortACInfo[ACIndex].TrainList, u8Index); + } + else + { + ; + } + } + } + else + { + ; + } +} + +/***************************************************************************** +* @name as_GetLinkFirstTrain +* @brief ȡLinkϵһгϢ +* @param[in] u16LinkID LinkID +* @return һггϢ +* @note һгָӵͼг +* LinkڱZC/Link쳣/Link޳ʱñһϳ +* as_GetLinkTrainNum()ʹ +*****************************************************************************/ +TRAIN_SEQUANCE_s as_GetLinkFirstTrain(IN UINT16 u16LinkID) +{ + TRAIN_SEQUANCE_s TrainSeq = { NAME_FAILUREAREA, TYPE_FAILURE, DEFAULT_ZERO }; /* г */ + + /*- ǷDZZCгLink */ + if ((DEFAULT_ZERO < g_pSortLinkIndex[u16LinkID]) + && (FLAG_UNSET == g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8SortFail) + && (DEFAULT_ZERO < g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8TrainNum)) + { + /*- Linkг*/ + TrainSeq = g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].TrainList[0]; + } + else + { + /*- һϳ */ + TrainSeq.u16TrainID = NAME_FAILUREAREA; + TrainSeq.u8TrainType = TYPE_FAILURE; + TrainSeq.u16ELID = DEFAULT_ZERO; + } + return TrainSeq; +} + +/***************************************************************************** +* @name as_GetLinkLastTrain +* @brief ȡLinkһгϢ +* @param[in] u16LinkID LinkID +* @return һггϢ +* @note һгָӵͼյ˵г +* LinkڱZC/Link쳣/Link޳ʱñһϳ +* as_GetLinkTrainNum()ʹ +*****************************************************************************/ +TRAIN_SEQUANCE_s as_GetLinkLastTrain(IN UINT16 u16LinkID) +{ + TRAIN_SEQUANCE_s TrainSeq = { NAME_FAILUREAREA, TYPE_FAILURE ,DEFAULT_ZERO }; /* г */ + + /*- ǷDZZCгļ */ + if ((DEFAULT_ZERO < g_pSortLinkIndex[u16LinkID]) + && (FLAG_UNSET == g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8SortFail) + && (DEFAULT_ZERO < g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8TrainNum)) + { + /*- ĩг*/ + TrainSeq = g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].TrainList[g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8TrainNum - 1U]; + } + else + { + /*- һϳ */ + TrainSeq.u16TrainID = NAME_FAILUREAREA; + TrainSeq.u8TrainType = TYPE_FAILURE; + TrainSeq.u16ELID = DEFAULT_ZERO; + } + return TrainSeq; +} + +/***************************************************************************** +* @name as_GetLinkTrainNum +* @brief ȡLinkϵг +* @param[in] u16LinkID LinkID +* @return г +* @note LinkڱZC/Link쳣ʱ1(һϳ) +*****************************************************************************/ +UINT8 as_GetLinkTrainNum(IN UINT16 u16LinkID) +{ + UINT8 u8TrainNum = DEFAULT_ZERO; /* г */ + + /*- ǷDZZCļ */ + if ((DEFAULT_ZERO < g_pSortLinkIndex[u16LinkID]) + && (FLAG_UNSET == g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8SortFail)) + { + /*- г */ + u8TrainNum = g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8TrainNum; + } + else + { + /*- һ()*/ + u8TrainNum = 1U; + } + return u8TrainNum; +} + +/***************************************************************************** +* @name as_GetLinkTrainList +* @brief ȡLinkϵг +* @param[in] u16LinkID LinkID +* @param[out] TrainList г +* @param[in] u32MaxTrainNum ге +* @return г +* @note TrainList[]صӵͼյУTrainList[0]ǵӵͼг +* LinkڱZC/Link쳣/гпռСʱһϳ +*****************************************************************************/ +UINT8 as_GetLinkTrainList(IN UINT16 u16LinkID, OUT TRAIN_SEQUANCE_s TrainList[SIZE_MAX_TRAINOFAC], IN UINT32 u32MaxTrainNum) +{ + UINT8 u8TrainNum = DEFAULT_ZERO; /* г */ + + /*- ǷDZZCLinkпռ乻 */ + if ((DEFAULT_ZERO < g_pSortLinkIndex[u16LinkID]) + && (FLAG_UNSET == g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8SortFail) + && (u32MaxTrainNum >= g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8TrainNum)) + { + /*- г */ + u8TrainNum = g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].u8TrainNum; + (void)memmove(TrainList, g_pSortLinkInfo[g_pSortLinkIndex[u16LinkID]].TrainList, u8TrainNum * sizeof(TRAIN_SEQUANCE_s)); + } + else + { + /*- һϳ */ + u8TrainNum = 1U; + TrainList[0].u16TrainID = NAME_FAILUREAREA; + TrainList[0].u8TrainType = TYPE_FAILURE; + TrainList[0].u16ELID = DEFAULT_ZERO; + } + return u8TrainNum; +} + +/***************************************************************************** +* @name as_SeqSearch +* @brief г +* @param[in] u16TrainID гID +* @param[in] u8TrainNum г +* @param[in] TrainList гб +* @return геĽDZ꣬쳣INVALID_8 +* @note +*****************************************************************************/ +UINT8 as_SeqSearch(IN UINT16 u16TrainID, IN UINT8 u8TrainNum, IN const TRAIN_SEQUANCE_s TrainList[SIZE_MAX_TRAINOFAC]) +{ + UINT8 u8Index = DEFAULT_ZERO; /* ѭ */ + /*- @alias гУҵĿгʱֹͣ*/ + for (u8Index = DEFAULT_ZERO; u8Index < u8TrainNum; u8Index++) + { + if (TrainList[u8Index].u16TrainID == u16TrainID) + { + break; + } + else + { + ; + } + } + + /*- @alias δҵĿгʱINVALID_8 */ + if (u8Index >= u8TrainNum) + { + u8Index = INVALID_8; + } + else + { + ; + } + return u8Index; +} + + +/***************************************************************************** +* @name as_GetACTrainEnevelopList +* @brief ȡϵİ +* @param[in] u16ACID ID +* @param[out] TrainList г +* @param[in] u32MaxTrainNum ге +* @return г +* @note TrainList[]صӵͼյУTrainList[0]ǵӵͼг +* ᲻ڱZC/쳣(жг)/гпռСʱ1ϳ +* ע⣺ACϵֻ԰򣬲ctͷβɸѡЧس +*****************************************************************************************/ +UINT8 as_GetACTrainEnevelopList(UINT16 u16ACID, TRAIN_SEQUANCE_s TrainList[], UINT32 u32MaxTrainNum) +{ + UINT8 u8TrainNum = DEFAULT_ZERO; /* г */ + + /*ǷDZZCļпռ乻 */ + if ((DEFAULT_ZERO < g_pSortACIndex[u16ACID]) + && (FLAG_UNSET == g_pSortACInfo[g_pSortACIndex[u16ACID]].u8SortFail) + && (u32MaxTrainNum >= g_pSortACInfo[g_pSortACIndex[u16ACID]].u8TrainNum)) + { + /*- г */ + u8TrainNum = g_pSortACInfo[g_pSortACIndex[u16ACID]].u8TrainNum; + (void)memmove(TrainList, g_pSortACInfo[g_pSortACIndex[u16ACID]].TrainList, u8TrainNum * sizeof(TRAIN_SEQUANCE_s)); + } + else + { + /*- 1г*/ + u8TrainNum = 1U; + TrainList[0].u16TrainID = NAME_FAILUREAREA; + TrainList[0].u8TrainType = TYPE_FAILURE; + TrainList[0].u16ELID = DEFAULT_ZERO; + } + return u8TrainNum; +} + + +/**********************Ǵⲿӿڻȡ******************************************/ + +/***************************************************************************** +* @name TrainManage_GetTrainLocValid +* @brief ȡгλǷЧ +* @param[in] UINT16 TrainID +* @return гλǷЧ,ͨų򷵻FLAG_SET +* @note гģȡ +*****************************************************************************/ +UINT8 TrainManage_GetTrainLocValid(IN UINT16 TrainID) +{ + UINT8 u8Ret = FLAG_UNSET; + UINT8 u8LocValid = DEFAULT_ZERO; + UINT8 u8TrainSlpStt = 0U; + UINT16 u16IDIndex = DEFAULT_ZERO; + + /*гģȡгλǷЧ*/ + if (TrainID > DEFAULT_ZERO) + { + u16IDIndex = GetTrainId(TrainID - 1U); + u8LocValid = GetTrainTransitmitStat(u16IDIndex); + u8TrainSlpStt = GetTrainSleepState(u16IDIndex); + if (TRAIN_COMM_STATE_GOOD == u8LocValid) + { + u8Ret = FLAG_SET; + } + else if((TRAIN_COMM_STATE_BAD == u8LocValid) + &&(TRAIN_SLEEP_YES==u8TrainSlpStt)) + { + u8Ret = FLAG_SET; + } + else + { + u8Ret = FLAG_UNSET; + } + + } + else + { + ;/*޴*/ + } + return u8Ret; +} + +/***************************************************************************** +* @name TrainManage_GetTrainDir +* @brief ȡгзСȫָͷ +* @param[in] UINT16 TrainID +* @return 0: ȡʧ +* 0x55:߼ͬ +* 0xAA: ߼ +* 0xFF: Ч +* @note гģȡ +*****************************************************************************/ +UINT8 TrainManage_GetTrainDir(IN UINT16 TrainID) +{ + UINT8 dir = DEFAULT_ZERO; + UINT16 u16IDIndex = DEFAULT_ZERO; + if (TrainID > DEFAULT_ZERO) + { + u16IDIndex = GetTrainId(TrainID - 1U); + dir = GetTrainDir(u16IDIndex); + } + else + { + ; + } + return dir; +} + +/****************************************** +* @name TrainManage_GetTrainSafeLoc +* @brief ȡгȫλãȫǰˣ +* @param[in] Ҫȡİȫλ FINDHEADSAFEFLAG ȫͷ FINDTAILSAFEFLAG ȫβ +* @param[in] гID +* @param[out] ȫͷ/βlink +* @param[out] ȫͷ/βƫ +* @return ѯɹ0 ѯʧ +* @note гģȡ +******************************************/ +UINT8 TrainManage_GetTrainSafeLoc(IN UINT8 u8SafelocType, IN UINT16 u16TrainID,OUT UINT16 *pu16Link, OUT UINT32 *pu32Offset, OUT UINT8 *pu8Dir) +{ + /*- */ + UINT8 u8RetVal = DEFAULT_ZERO; + UINT16 u16IDIndex = DEFAULT_ZERO; + + if (u16TrainID > DEFAULT_ZERO) + { + u16IDIndex = GetTrainId(u16TrainID - 1U); + /*- жҪȡİȫλ*/ + switch (u8SafelocType) + { + case FINDHEADSAFEFLAG: + /*- ֵȫͷ*/ + *pu16Link = GetTrainSafeHeadLink(u16IDIndex); + *pu32Offset = GetTrainSafeHeadOffset(u16IDIndex); + *pu8Dir = GetTrainSafeHeadDir(u16IDIndex); + u8RetVal = DEFAULT_ONE; + break; + case FINDTAILSAFEFLAG: + /*- ֵȫβ*/ + *pu16Link = GetTrainSafeTailLink(u16IDIndex); + *pu32Offset = GetTrainSafeTailOffset(u16IDIndex); + *pu8Dir = GetTrainSafeTailDir(u16IDIndex); + u8RetVal = DEFAULT_ONE; + break; + default: + /*- ѯʧ*/ + u8RetVal = DEFAULT_ZERO; + break; + } + } + else + { + ; + } + return u8RetVal; +} + + + +/*********************************************** +* @name LinkManage_GetLinkInfoExp +* @brief ѯLink +* @param[in] pStart λ +* @param[in] pEnd յλ +* @param[in] u8Direction ѯ +* @param[out] pu16LinkID[MAX_LINK_LIST_NUM] LinkУMAX_LINK_LIST_NUM +* @return 0ѯʧܣزҵlinkĿѯɹ +* @note linkģлȡ +************************************************/ +static UINT8 LinkManage_GetLinkInfoExp(LOD_STRU pStart, LOD_STRU pEnd, UINT8 u8Direction, UINT16 pu16LinkID[]) +{ + UINT8 u8Ret = 0U; + struct_PathPoint p1 = { 0U }; + struct_PathPoint p2 = { 0U }; + UINT8 Val = 0U; + UINT8 dir = 0U; + UINT16 linkNum = 0U; + + p1.dwOffset = pStart.Off; + p1.wLinkId = pStart.Lnk; + + p2.dwOffset = pEnd.Off; + p2.wLinkId = pEnd.Lnk; + Val = DsuLinkSeqBtwPoints(&p1,&p2, &dir,&linkNum, pu16LinkID); + if (CI_SUCCESS == Val) + { + u8Ret = (UINT8)linkNum; + } + else + { + ; + } + return u8Ret; +} + + +/*********************************************** +* @name LinkManage_CheckSortTrainExp +* @brief жǰ˳ +* @param[in] u16Link1 һlink +* @param[in] u32Offset1 һlinkƫ +* @param[in] u16Link2 ڶlink +* @param[in] u32Offset2 ڶβlinkƫ +* @param[in] u8Direction гз +* @return 0x00Uѯʧܣ0x01U11->2,1󷽣0x02U1ķ2->1, 1ǰ0x03Uʶĵλغ +* @note linkģȡ +************************************************/ +static UINT8 LinkManage_CheckSortTrainExp(UINT16 u16Link1, UINT32 u32Offset1, UINT16 u16Link2, UINT32 u32Offset2, UINT8 u8Direction) +{ + UINT8 Order = 0U; + UINT8 RetVal = 0U; + struct_PathPoint p1 = { 0U }; + struct_PathPoint p2 = { 0U }; + + p1.dwOffset = u32Offset1; + p1.wLinkId = u16Link1; + + p2.dwOffset = u32Offset2; + p2.wLinkId = u16Link2; + + Order = dsuJudgePointAandPointBPosition(&p1, &p2, u8Direction); + switch (Order) + { + case FLAG_SET: /*AķAں*/ + RetVal = 0x01U; + break; + case FLAG_UNSET: /*AķAǰ*/ + RetVal = 0x02U; + break; + case CI_SUCCESS: + RetVal = 0x03U;/*غ*/ + break; + default: + RetVal = 0x00U; + break; + } + return RetVal; +} + + +/** +* @brief Ƚǰϵ +* @param[in] const EnvelopeStruct* pEnvelopeA A +* @param[in] const EnvelopeStruct* pEnvelopeB B +* @return 0x01 AB + 0x02 ABǰ + 0x03 AB + 0x04 BA + 0x00 ޷Ƚλùϵ +* @note +*/ +UINT8 as_CalcEnvelopeOrder(IN const EnvelopeStruct* pEnvelopeA, IN const EnvelopeStruct* pEnvelopeB) +{ + UINT8 RetVal = DEFAULT_ZERO; + + if ((NULL != pEnvelopeA) && (NULL != pEnvelopeB)) + { + + RetVal = CalcEnveLopeOrder(pEnvelopeA, pEnvelopeB); + switch (RetVal) + { + case AS_ORDER_UPSTREAM: /*B->A*/ + RetVal = 0x02U; + break; + case AS_ORDER_DOWNSTREAM: + RetVal = 0x01U; /*A->B*/ + break; + case AS_ORDER_1INCLUDE2: + RetVal = 0x03U; /*AB*/ + break; + case AS_ORDER_2INCLUDE1: + RetVal = 0x04U; /*BA*/ + break; + default: + RetVal = DEFAULT_ZERO; + break; + } + } + else + { + ; + } + return RetVal; +} + +/***************************************************************************** +* @name elm_GetAllTrainELSeq +* @brief ɸѡģȡгİϢs_TrainELSeqģֱӲѯʹ +* @param[in] none +* @return none +* @note гɸѡģлȡ +*****************************************************************************/ +static void elm_GetAllTrainELSeq(void) +{ + UINT16 u16ELNum = DEFAULT_ZERO; + + /*ÿ*/ + (void)memset(&s_TrainELSeq, 0, sizeof(s_TrainELSeq)); + + /*ȡег*/ + u16ELNum = elm_GetAllEnvelope(s_TrainELSeq.TrainEnveLopeID); + if (ENVELOPE_SUM_MAX >= u16ELNum) + { + s_TrainELSeq.ELNum = u16ELNum; + } + else + { + (void)memset(&s_TrainELSeq, 0, sizeof(s_TrainELSeq)); + } + +} + + +/***************************************************************************** +* @name elm_IsCTHeadUKT +* @brief ǷCTҳͷسUT +* @param[in] u16TrainID гID +* @return CTͷǷпUKT FLAG_SET:,FLAG_UNSET: +* @note гɸѡģлȡ +*****************************************************************************/ +static UINT8 elm_IsCTHeadUKT(UINT16 u16TrainID) +{ + UINT8 u8Ret = FLAG_UNSET; + UINT16 cycIndex = 0U; + UINT16 Val = 0U; + UINT8 u8HeadVirScreen = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; + const EnvelopeStruct* pEnvelope = NULL; + + for (cycIndex = 0U; cycIndex < s_TrainELSeq.ELNum; cycIndex++) + { + /*ȡ*/ + pEnvelope = elm_GetEnvelopeInfoByID(s_TrainELSeq.TrainEnveLopeID[cycIndex]); + if (NULL != pEnvelope) + { + /**аиIDCT**/ + if ((TYPE_CT == pEnvelope->envelopeType) && (u16TrainID == pEnvelope->trainID[0])) + { + Val = pEnvelope->headTrainID; + u8HeadVirScreen = GetTrainVirHeadScreenPassFlag(u16TrainID); + break; + } + else + { + ; + } + } + } + if ((DEFAULT_ZERO != Val) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != u8HeadVirScreen)) + { + u8Ret = FLAG_SET; + } + else + { + u8Ret = FLAG_UNSET; + } + + /*- ͷɸ״̬*/ + return u8Ret; +} + + +/***************************************************************************** +* @name elm_IsCTTailUKT +* @brief ǷCTҳβسUT +* @param[in] u16TrainID гID +* @return CTβǷпUKT,FLAG_SET:,FLAG_UNSET: +* @note +*****************************************************************************/ +static UINT8 elm_IsCTTailUKT(UINT16 u16TrainID) +{ + UINT8 u8Ret = FLAG_UNSET; + UINT16 cycIndex = 0U; + UINT16 Val = 0U; + UINT8 u8TailVirScreen = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; + const EnvelopeStruct* pEnvelope = NULL; + + for (cycIndex = 0U; cycIndex < s_TrainELSeq.ELNum; cycIndex++) + { + /*ȡ*/ + pEnvelope = elm_GetEnvelopeInfoByID(s_TrainELSeq.TrainEnveLopeID[cycIndex]); + if (NULL != pEnvelope) + { + /**аиIDijCT**/ + if ((TYPE_CT == pEnvelope->envelopeType) && (u16TrainID == pEnvelope->trainID[0])) + { + Val = pEnvelope->tailTrainID; + u8TailVirScreen = GetTrainVirTailScreenPassFlag(u16TrainID); + break; + } + else + { + ; + } + } + else + { + ; + } + + } + if ((DEFAULT_ZERO != Val) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != u8TailVirScreen)) + { + u8Ret = FLAG_SET; + } + else + { + u8Ret = FLAG_UNSET; + } + + /*- βɸ״̬*/ + return u8Ret; +} + +/***************************************************************************** +* @name as_GetTrainsferData +* @brief ȡ +* @param[in] UINT32 curIndex ǰ +* @param[OUT] UINT8 * pDataBuff ݴ洢 +* @return ret>curIndex ȡɹ +* @note +*****************************************************************************/ +UINT32 as_GetTransferData(OUT UINT8 * pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex; + if (NULL != pDataBuff) + { + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)(sizeof(UINT16) * SIZE_MAX_LINE_TRAIN_NUM), s_pCTSortIndex, (UINT32)(sizeof(UINT16) * SIZE_MAX_LINE_TRAIN_NUM)); + copyIndex += (UINT32)(sizeof(UINT16) * SIZE_MAX_LINE_TRAIN_NUM); + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)(sizeof(CT_SORT_INFO_s) * SIZE_MAX_COM_VOBC_NUM + 1u), s_pCTSortInfo, (UINT32)(sizeof(CT_SORT_INFO_s) * SIZE_MAX_COM_VOBC_NUM + 1u)); + copyIndex += (UINT32)(sizeof(CT_SORT_INFO_s) * SIZE_MAX_COM_VOBC_NUM + 1u); + ret = copyIndex; + } + else + { + ; + } + return ret; +} + +/***************************************************************************** +* @name as_SetTrainsferData +* @brief ø +* @param[in] UINT32 curIndex ǰ +* @param[IN] UINT8 * pDataBuff ݴ洢 +* @return ret>curIndex ȡɹ +* @note +*****************************************************************************/ +UINT32 as_SetTransferData(IN UINT8 * pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex; + if (NULL != pDataBuff) + { + (void)CommonMemCpy(s_pCTSortIndex, (UINT32)(sizeof(UINT16) * SIZE_MAX_LINE_TRAIN_NUM), &pDataBuff[copyIndex], (UINT32)(sizeof(UINT16) * SIZE_MAX_LINE_TRAIN_NUM)); + copyIndex += (UINT32)(sizeof(UINT16) * SIZE_MAX_LINE_TRAIN_NUM); + (void)CommonMemCpy(s_pCTSortInfo, (UINT32)(sizeof(CT_SORT_INFO_s) * SIZE_MAX_COM_VOBC_NUM + 1u), &pDataBuff[copyIndex], (UINT32)(sizeof(CT_SORT_INFO_s) * SIZE_MAX_COM_VOBC_NUM + 1u)); + copyIndex += (UINT32)(sizeof(CT_SORT_INFO_s) * SIZE_MAX_COM_VOBC_NUM + 1u); + ret = copyIndex; + } + else + { + ; + } + return ret; +} + +/***************************************************************************** +* @name CalcTrainOrder +* @brief гλ +* @param[in] p1 г1 +* @param[in] p2 г2 +* @return +* AS_ORDER_DOWNSTREAM (0x55) 0x55p1p2з(p2ǰ) +* AS_ORDER_UPSTREAM (0xAA) 0xAAp1p2з(p1ǰ) +* AS_ORDER_FAIL (0xFF) ʧ +* @note +*****************************************************************************/ +static UINT8 CalcAreaOrder(IN const TrainLocStruct* p1, IN const TrainLocStruct* p2) +{ + UINT8 u8Ret = AS_ORDER_FAIL; /* ֵ */ + UINT8 u8HeadSort = DEFAULT_ZERO; /* ͷ */ + UINT8 u8TailSort = DEFAULT_ZERO; /* β */ + LOD_STRU E1StartPos = { 0u }; /* 1 */ + LOD_STRU E1EndPos = { 0u }; /* 1յ */ + LOD_STRU E2StartPos = { 0u }; /* 2 */ + LOD_STRU E2EndPos = { 0u }; /* 2յ */ + + if ((NULL == p1) || (NULL == p2)) + { + ;/**/ + } + else + { + /*- 1յȡֵ */ + if (EMAP_SAME_DIR == p1->startPos.Dir) + { + E1StartPos = p1->endPos; + E1EndPos = p1->startPos; + } + else + { + E1StartPos = p1->startPos; + E1EndPos = p1->endPos; + } + + /*- 2յȡֵ */ + if (EMAP_SAME_DIR == p2->startPos.Dir) + { + E2StartPos = p2->endPos; + E2EndPos = p2->startPos; + } + else + { + E2StartPos = p2->startPos; + E2EndPos = p2->endPos; + } + + /**ȡǰλùϵ****************/ + /*0x00Uѯʧܣ0x01Uһλǰ0x02Uڶλǰ0x03Uʶĵλغ*/ + u8HeadSort = LinkManage_CheckSortTrainExp(E1StartPos.Lnk, E1StartPos.Off, E2StartPos.Lnk, E2StartPos.Off, EMAP_SAME_DIR); + u8TailSort = LinkManage_CheckSortTrainExp(E2EndPos.Lnk, E2EndPos.Off, E1EndPos.Lnk, E1EndPos.Off, EMAP_SAME_DIR); + + /*- 1Ƿ2 */ + if ((0x01U == u8HeadSort) && (0x02U == u8TailSort)) + { + /*- 1 */ + u8Ret = AS_ORDER_UPSTREAM; + } + /*- 1Ƿ2 */ + else if ((0x02U == u8HeadSort) && (0x01U == u8TailSort)) + { + /*- 1 */ + u8Ret = AS_ORDER_DOWNSTREAM; + } + else + { + /*- ѯʧ(г಻ɴ?) */ + debug_infor_printf((const)"AS0044: Get relative position error, Result[%d,%d],[%d,%d]~[%d,%d],[%d,%d]~[%d,%d]\n", u8HeadSort, u8TailSort, + E1StartPos.Lnk, E1StartPos.Off, E1EndPos.Lnk, E1EndPos.Off, + E2StartPos.Lnk, E2StartPos.Off, E2EndPos.Lnk, E2EndPos.Off); + u8Ret = AS_ORDER_FAIL; + } + + } + + return u8Ret; +} + +/** +* @brief Ƚгǰϵ +* @param[in] const EnvelopeStruct* pEnvelopeA A +* @param[in] const EnvelopeStruct* pEnvelopeB B +* @return 0x01 Aӵͼ +0x02 Bڵӵͼ +0x00 ޷Ƚλùϵ +* @note +*/ +UINT8 as_CalcAreaOrder(IN const TrainLocStruct* pTrainA, IN const TrainLocStruct* pTrainB) +{ + UINT8 RetVal = DEFAULT_ZERO; + + if ((NULL != pTrainA) && (NULL != pTrainB)) + { + RetVal = CalcAreaOrder(pTrainA, pTrainB); + switch (RetVal) + { + case AS_ORDER_UPSTREAM: /*A*/ + RetVal = 0x01U; + break; + case AS_ORDER_DOWNSTREAM: + RetVal = 0x02U; /*B*/ + break; + default: + RetVal = DEFAULT_ZERO; + break; + } + } + else + { + ; + } + return RetVal; +} + +/** +* @brief ӡlinkϢ +* @param +* @return +* @note +*/ +static void as_DebugPrint(void) +{ + UINT16 wLinkIndex = 0u; + UINT8 chTrainNum = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chLocalId = 0u; + UINT16 wLinkTioc = 0u; + TRAIN_SEQUANCE_s TrainList[SIZE_MAX_TRAINOFAC] = { 0u }; + LinkDataConfigStru * strTemp = NULL; + UINT8 outString[AXIS_SORT_LOG_BUF_SIZE] = { 0U }; + UINT16 outStringLength = 0U; + + chLocalId = GetSystemParaLocalCiId(); + + for (wLinkIndex = 0u; wLinkIndex < AS_LINK_MAX; wLinkIndex++) + { + strTemp = GetLinkDataByIndex(wLinkIndex); + if ((0u < strTemp->wId) && (AS_LINK_MAX > strTemp->wId)) + { + wLinkTioc = GetLinkManageTiocById(strTemp->wId); + if (wLinkTioc == chLocalId) + { + chTrainNum = as_GetLinkTrainList(strTemp->wId, TrainList, SIZE_MAX_LINETRAIN); + + ShortToChar(strTemp->wId, &outString[outStringLength]); /*Link ID*/ + outStringLength += 2U; + outString[outStringLength] = chTrainNum; /*г*/ + outStringLength++; + + for (chTrainIndex = 0u; chTrainIndex < chTrainNum; chTrainIndex++) + { + ShortToChar(TrainList[chTrainIndex].u16TrainID, &outString[outStringLength]); /*гID*/ + outStringLength += 2U; + outString[outStringLength] = TrainList[chTrainIndex].u8TrainType; /*г*/ + outStringLength++; + ShortToChar(TrainList[chTrainIndex].u16ELID, &outString[outStringLength]); /*гID*/ + outStringLength += 2U; + } + } + else + { + ; /* DZӡ */ + } + } + else + { + ; + } + } + + if (0u == outStringLength) + { + ; + } + else + { +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nSortLinkData:%d\nLinkId(2)-TrainNum-TrainID(2)-TrainType-TrainEnvelopId(2)", outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + + +#endif + +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0, "\nSortLinkData:%d", outStringLength); + Out_Array_Buffer(0, "\nLinkId(2)-TrainNum-TrainID(2)-TrainType-TrainEnvelopId(2):%d", outStringLength); + Out_Array_Buffer(16, outString, outStringLength); + +#endif + } +} + +/***************************************************************************** +* @name TrainManage_GetTrainSleepState +* @brief ȡг״̬ +* @param[in] UINT16 TrainID +* @return 0: ȡʧ +* 0x55:г״̬ +* 0xAA:гδ״̬ +* @note гģȡ +* by cgh 20240726 +*****************************************************************************/ +UINT8 TrainManage_GetTrainSleepState(IN UINT16 TrainID) +{ + UINT8 dir = DEFAULT_ZERO; + UINT16 u16IDIndex = DEFAULT_ZERO; + + if (TrainID > DEFAULT_ZERO) + { + u16IDIndex = GetTrainId(TrainID - 1U); + dir = GetTrainSleepState(u16IDIndex); + } + else + { + ; + } + return dir; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/AxisSort/AxisSort.h b/TSCP/src/APP/ciapp/AxisSort/AxisSort.h new file mode 100644 index 0000000..9c8a49b --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisSort/AxisSort.h @@ -0,0 +1,52 @@ +/****************************************************************************** +** ļ: as.h ( ) +** : ģ +*******************************************************************************/ +#ifndef INC_AXIS_SORT_INC +#define INC_AXIS_SORT_INC + +#include "AxisSort_define.h" +#include "dquVobcCommonStru.h" +#include "TrainDefine.h" +#include "TrainDataManage.h" +#include "dsuemapdefine.h" + +#define AXIS_SORT_LOG_BUF_SIZE ((UINT16)6000) /*ӡݵֽ*/ + +typedef struct TrainSequance +{ + UINT16 u16TrainID; /*гID(14)*/ + UINT8 u8TrainType; /*г*/ + UINT16 u16ELID; /*ID*/ /*ģڲ*/ +}TRAIN_SEQUANCE_s; + +/*Ϣ */ +typedef struct +{ + UINT8 u8NodeValidTag; /* ڵЧ־ FLAG_SET-ڵڱʹ DEFAULT_ZERO-ڵδʹ */ + UINT16 u16SortTrainID; /* гID */ + UINT8 u8SortTrainDir; /* г */ + LOD_STRU SafeHead; /* ȫǰ */ + LOD_STRU SafeTail; /* ȫ */ +}CT_SORT_INFO_s; + + +/*********Ϣ**************/ +typedef struct +{ + UINT16 u16ID; /* ID */ + UINT8 u8SortFail; /* 쳣־ */ + UINT8 u8TrainNum; /* г */ + TRAIN_SEQUANCE_s TrainList[SIZE_MAX_TRAINOFAC];/* г TrainList[0]ǵӵͼг */ +}AS_SORT_INFO_s; /*ζ̬ݽṹ*/ + +/*гϢ****/ + +typedef struct +{ + UINT16 ELNum; /**/ + UINT16 TrainEnveLopeID[ENVELOPE_SUM_MAX]; /*аIDϢ*/ +}s_TRAIN_ENVELOPE_ID; + + +#endif /* INC_AXIS_SORT_INC */ \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/AxisSort/AxisSort_api.h b/TSCP/src/APP/ciapp/AxisSort/AxisSort_api.h new file mode 100644 index 0000000..852f4f4 --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisSort/AxisSort_api.h @@ -0,0 +1,223 @@ +/****************************************************************************** +** ļ: as_api.h ( link,ⲿú ) +** : linkģ +*******************************************************************************/ +#ifndef INC_AS_API_INC +#define INC_AS_API_INC + +#include "AxisSort_define.h" +#include "AxisSort.h" +#include "TrainOnAcManage.h" + + +/* ģ߼ */ +/* + * @brief ASģʼ + */ +void as_Init(void); + +/************************************************************* +* @name as_CycleInit +* @brief ڳʼ +* @param[in] void +* @return void +* @note +*************************************************************/ +void as_CycleInit(void); + +/***************************************************************************** +* @name as_MainProcess +* @brief ASģ +* @param[in] +* @return +* @note +*****************************************************************************/ +void as_MainProcess(void); + + + +/* + * @brief ͨų + * ͨг: гˢͨųУ + * ڶʧλõͨг: תΪϳͨųƳ + * ³ֵλñг: ӵͨųкlinkС + */ +void as_SortCT(void); + +/* + * @brief ͨų + * ϳӹϳ + * ޳UTᣬӹϳУ + */ +void as_SortUT(void); + +/***************************************************************************** +* @name as_SortBaseEnveLope +* @brief еİ䵽AClinkϣδɸѡЧ +* @param[in] +* @return +* @note +*****************************************************************************/ +void as_SortBaseEnveLope(void); + +/*- + * @brief ȡLinkϵһгϢ + * @param[in] u16LinkID LinkID + * @return һггϢ + * @note "һг"ָӵͼг + * LinkڱZC/Link쳣/Link޳ʱñһϳ + * as_GetLinkTrainNum()ʹ + */ +TRAIN_SEQUANCE_s as_GetLinkFirstTrain(IN UINT16 u16LinkID); + +/*- + * @brief ȡLinkһгϢ + * @param[in] u16LinkID LinkID + * @return һггϢ + * @note "һг"ָӵͼյ˵г + * LinkڱZC/Link쳣/Link޳ʱñһϳ + * as_GetLinkTrainNum()ʹ + */ +TRAIN_SEQUANCE_s as_GetLinkLastTrain(IN UINT16 u16LinkID); + +/*- + * @brief ȡLinkϵг + * @param[in] u16LinkID LinkID + * @return г + * @note LinkڱZC/Link쳣ʱ1һϳ + */ +UINT8 as_GetLinkTrainNum(IN UINT16 u16LinkID); + +/*- + * @brief ȡLinkϵг + * @param[in] u16LinkID LinkID + * @param[out] TrainList г + * @param[in] u32MaxTrainNum ге(SIZE_MAX_TRAINOFAC(20U)) + * @return г + * @note TrainList[]صӵͼյУTrainList[0]ǵӵͼг + * LinkڱZC/Link쳣/гпռСʱһϳ + */ +UINT8 as_GetLinkTrainList(IN UINT16 u16LinkID, OUT TRAIN_SEQUANCE_s TrainList[SIZE_MAX_TRAINOFAC], IN UINT32 u32MaxTrainNum); + +/* ѯAPI */ +/*- +* @brief г +* @param[in] u16TrainID гID +* @param[in] u8TrainNum г +* @param[in] TrainList гб +* @return геĽDZ +* 쳣 INVALID_80xFFU +*/ +UINT8 as_SeqSearch(IN UINT16 u16TrainID, IN UINT8 u8TrainNum, IN const TRAIN_SEQUANCE_s TrainList[SIZE_MAX_TRAINOFAC]); + + +/***************************************************************************** +* @name as_GetACTrainEnevelopList +* @brief ȡϵİ +* @param[in] u16ACID ID +* @param[out] TrainList г +* @param[in] u32MaxTrainNum ге +* @return г +* @note TrainList[]صӵͼյУTrainList[0]ǵӵͼг +* ᲻ڱZC/쳣(жг)/гпռСʱ1ϳ +* ע⣺ACϵֻ԰򣬲ctͷβɸѡЧس +*****************************************************************************/ +UINT8 as_GetACTrainEnevelopList(UINT16 u16ACID, TRAIN_SEQUANCE_s TrainList[], UINT32 u32MaxTrainNum); + +/** +* @brief Ƚǰϵ +* @param[in] const EnvelopeStruct* pEnvelopeA A +* @param[in] const EnvelopeStruct* pEnvelopeB B +* @return 0x01 AڰBǰ +0x02 BڰAǰ +0x00 ޷Ƚλùϵ +* @note +*/ +UINT8 as_CalcEnvelopeOrder(IN const EnvelopeStruct* pEnvelopeA, IN const EnvelopeStruct* pEnvelopeB); + + + +/******Ǵӿģȡ,assspģҪ***************************/ + +/* +* @name TrainManage_GetTrainLocValid +* @brief ȡгλǷЧ +* @param[in] UINT16 TrainID +* @return гλǷЧ,ͨų򷵻FLAG_SET +* @note гģȡ +***/ +UINT8 TrainManage_GetTrainLocValid(IN UINT16 TrainID); + + +/** +* @name TrainManage_GetTrainDir +* @brief ȡгзСȫָͷ +* @param[in] UINT16 TrainID +* @return 0: ȡʧ +* 0x55:߼ͬ +* 0xAA: ߼ +* 0xFF: Ч +* @note гģȡ +***/ +UINT8 TrainManage_GetTrainDir(IN UINT16 TrainID); + + +/*** +* @name TrainManage_GetTrainSafeLoc +* @brief ȡгȫλãȫǰˣ +* @param[in] Ҫȡİȫλ FINDHEADSAFEFLAG ȫͷ FINDTAILSAFEFLAG ȫβ +* @param[in] гID +* @param[out] ȫͷ/βlink +* @param[out] ȫͷ/βƫ +* @return ѯɹ0 ѯʧ +* @note гģȡ +**/ +UINT8 TrainManage_GetTrainSafeLoc(IN UINT8 u8SafelocType, IN UINT16 u16TrainID, OUT UINT16 *pu16Link, OUT UINT32 *pu32Offset, OUT UINT8 *pu8Dir); + +/***************************************************************************** +* @name as_GetTrainsferData +* @brief ȡ +* @param[in] UINT32 curIndex ǰ +* @param[OUT] UINT8 * pDataBuff ݴ洢 +* @return ret>curIndex ȡɹ +* @note +*****************************************************************************/ +UINT32 as_GetTransferData(OUT UINT8 * pDataBuff, IN UINT32 curIndex); + +/***************************************************************************** +* @name as_SetTrainsferData +* @brief ø +* @param[in] UINT32 curIndex ǰ +* @param[IN] UINT8 * pDataBuff ݴ洢 +* @return ret>curIndex ȡɹ +* @note +*****************************************************************************/ +UINT32 as_SetTransferData(IN UINT8 * pDataBuff, IN UINT32 curIndex); + +/** +* @brief Ƚгǰϵ +* @param[in] const EnvelopeStruct* pEnvelopeA A +* @param[in] const EnvelopeStruct* pEnvelopeB B +* @return 0x01 Aӵͼ +0x02 Bڵӵͼ +0x00 ޷Ƚλùϵ +* @note +*/ +UINT8 as_CalcAreaOrder(IN const TrainLocStruct* pTrainA, IN const TrainLocStruct* pTrainB); + +/***************************************************************************** +* @name TrainManage_GetTrainSleepState +* @brief ȡг״̬ +* @param[in] UINT16 TrainID +* @return 0: ȡʧ +* 0x55:г״̬ +* 0xAA:гδ״̬ +* @note гģȡ +* by cgh 20240726 +*****************************************************************************/ +UINT8 TrainManage_GetTrainSleepState(IN UINT16 TrainID); + +#endif /* INC_AS_API_INC */ + + + diff --git a/TSCP/src/APP/ciapp/AxisSort/AxisSort_define.h b/TSCP/src/APP/ciapp/AxisSort/AxisSort_define.h new file mode 100644 index 0000000..e9376fe --- /dev/null +++ b/TSCP/src/APP/ciapp/AxisSort/AxisSort_define.h @@ -0,0 +1,52 @@ +/****************************************************************************** +** ļ: as_define.h ( ) +** : ģ +*******************************************************************************/ +#ifndef INC_AXIS_SORT_DEFINE_INC +#define INC_AXIS_SORT_DEFINE_INC + +#include "CommonTypes.h" +#include +#include "CiSystemDefine.h" +#include "../EnvelopeManage/EnvelopeDefine.h" + + +/*гжӦг*/ +#define TYPE_CT TYPE_CT_ENVELOPE /*г״̬Ϊͨų */ +#define TYPE_UCT TYPE_UCT_ENVELOPE /*г״̬Ϊʧͨų */ +#define TYPE_FAILURE TYPE_UKT_ENVELOPE /*г״̬Ϊг*/ + +#define DEFAULT_ZERO (0U) /*ʼֵΪ0*/ +#define DEFAULT_ONE (1U) /*ʼֵΪ1*/ + +#ifndef INVALID_8 +#define INVALID_8 ((UINT8)0xFFU) /*- 8λ Чֵ*/ +#endif + + +#define NAME_FAILUREAREA (SIZE_MAX_LINETRAIN) /*ʹõID*/ +#define SIZE_MAX_LINETRAIN (255U) /*·*/ + +#define SIZE_MAX_LINE_TRAIN_NUM (SIZE_MAX_LINETRAIN+1U) /*·*/ +#define SIZE_MAX_COM_VOBC_NUM (40U) /*ZCͨŵVOBC*/ + +#define AS_LINK_MAX (LINK_SUM_MAX) /* ASģLink */ +#define SIZE_MAX_TRAINOFAC (20U) /*ег*/ +#define SIZE_MAX_TRAINOFTRACK (20U) /*ег*/ + +#define AS_AC_MAX (AXIS_SECTION_SUM_MAX) /* ASģļ */ + + +#define MAX_LINK_LIST_NUM (100U) /*LinkĿ*/ + + +#define AS_ORDER_DOWNSTREAM (0x55U) /* g_pTrainOrder[T1][T2]=0x55T1T2ӵͼ(ҷ) */ +#define AS_ORDER_UPSTREAM (0xAAU) /* g_pTrainOrder[T1][T2]=0x55T1T2ӵͼ() */ +#define AS_ORDER_1INCLUDE2 (0xCCU) /*12*/ +#define AS_ORDER_2INCLUDE1 (0xDDU) /*21*/ +#define AS_ORDER_FAIL (0xFFU) /* ʧ */ + + + + +#endif /* INC_AXIS_SORT_DEFINE_INC */ \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointConfigDataManage.c b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointConfigDataManage.c new file mode 100644 index 0000000..c007c9b --- /dev/null +++ b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointConfigDataManage.c @@ -0,0 +1,503 @@ +#include "CutoffPointConfigDataManage.h" + +CfpConfigStru g_szCfpConfig[CUTOFF_POINT_SUM_MAX] = { 0u }; /* ֽݴ */ +UINT16 gszCfpId[CUTOFF_POINT_SUM_MAX] = {0U}; +UINT16 gCfpConfigSum = 0u; /* ֽø */ + +/** +* @brief ȡTIOCֽ +* @param +* @return TIOCֽ +*/ +UINT16 GetCfpSum(void) +{ + UINT16 wRetVal = 0u; + if (CUTOFF_POINT_SUM_MAX <= gCfpConfigSum) + { + wRetVal = CUTOFF_POINT_SUM_MAX; + } + else + { + wRetVal = gCfpConfigSum; + } + return wRetVal; +} + +/** +* @brief ȡֽID +* @param bufIndex ID± +* @return ֽID +*/ +UINT16 GetCfpId(const UINT16 bufIndex) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wCfpSum = GetCfpSum(); + if (bufIndex < wCfpSum) + { + wRetVal = gszCfpId[bufIndex]; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/** +* @brief ȡֽ洢ָ +* @param +* @return ֽ洢ָ +*/ +CfpConfigStru * GetCfpConfigData(void) +{ + return (CfpConfigStru *)g_szCfpConfig; +} + +/** +* @brief ȡֽ洢 +* @param wCfpId ֽID +* @return ֽ洢 +* @note ڲŻ 20220418 wqm δ0ļ +*/ +UINT16 GetCfpBufIndex(const UINT16 wCfpId) +{ + UINT16 wRetVal = CUTOFF_POINT_SUM_MAX; + if ((CUTOFF_POINT_SUM_MAX > wCfpId) && ( 0u < wCfpId)) + { + wRetVal = wCfpId; + } + else + { + ; + } + return wRetVal; +} + +/** +* @brief ȡֽlink +* @param wCfpId ֽID +* @return ֽlink +*/ +UINT16 GetCfpLink(const UINT16 wCfpId) +{ + UINT16 wRetVal = 0u; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + wRetVal = g_szCfpConfig[wIndex].wLinkId; + } + else + { + ; + } + return wRetVal; +} + +/** +* @brief ȡֽlinkƫ +* @param wCfpId ֽID +* @return ֽ洢linkƫ +* @note 20220418 wqm ޸ĬֵΪUINT32_MAX +*/ +UINT32 GetCfpOffset(const UINT16 wCfpId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + dwRetVal = g_szCfpConfig[wIndex].dwOffset; + } + else + { + ; + } + return dwRetVal; +} + +/** +* @brief ȡֽTIOC +* @param wCfpId ֽID +* @return ֽTIOC +*/ +UINT16 GetCfpOtherTioc(const UINT16 wCfpId) +{ + UINT16 wRetVal = 0u; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + wRetVal = g_szCfpConfig[wIndex].wOtherTiocId; + } + else + { + ; + } + return wRetVal; +} + +/** +* @brief ȡTIOCڷֽ㷽 +* @param wCfpId ֽID +* @return TIOCڷֽ㷽 +*/ +UINT8 GetCfpLocDir(const UINT16 wCfpId) +{ + UINT8 chRetVal = 0u; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + chRetVal = g_szCfpConfig[wIndex].chLocDir; + } + else + { + ; + } + return chRetVal; +} + +/** +* @brief ȡֽڷһlink +* @param wCfpId ֽID +* @return ֽڷһlink +*/ +UINT16 GetCfpInFirstLink(const UINT16 wCfpId) +{ + UINT16 wRetVal = 0u; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + wRetVal = g_szCfpConfig[wIndex].wInFirstLink; + } + else + { + ; + } + return wRetVal; +} + +/** +* @brief linkƫȡֽID +* @param wLink +* @param dwOffset +* @return 0ѯʧ ֽID +*/ +UINT16 GetCfpIdByPoint(UINT16 wLink, UINT32 dwOffset) +{ + UINT16 wIndex = 0u; + UINT16 wCfpSum = GetCfpSum(); + UINT16 wCfpId = 0u; + UINT16 wCfpLink = 0u; + UINT32 dwCfpOffset = UINT32_MAX; + UINT16 wRetVal = 0u; + UINT8 chFunRet = CI_ERROR; + UINT16 wSameLink = 0u; + UINT32 dwSameOffset = UINT32_MAX; + chFunRet = CheckLinkValid(wLink, dwOffset); + if (CI_SUCCESS == chFunRet) + { + for (wIndex = 0u; wIndex < wCfpSum; wIndex++) + {/* ֽ */ + wCfpId = GetCfpId(wIndex); + wCfpLink = GetCfpLink(wCfpId); + dwCfpOffset = GetCfpOffset(wCfpId); + (void)dsuCheckSameLoc(wCfpLink, dwCfpOffset, &wSameLink, &dwSameOffset); + if ((wCfpLink == wLink) && (dwCfpOffset == dwOffset)) + { + wRetVal = wCfpId;/* ߽λһ£ҵ˱߽ */ + } + else if(((wSameLink == wLink) && (dwSameOffset == dwOffset))) + { + wRetVal = wCfpId;/* ߽ͬλõһ£ҵ˱߽ */ + } + else + { + ; /*޲*/ + } + + if (0u != wRetVal) + { + break;/* ҵӦ߽㣬ѭ */ + } + else + { + ; + } + } + } + else + { + ; + } + return wRetVal; +} + +/* +* ķֽ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 CutoffPointConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 wCutoffDataSum = 0u; /*źŻ豸*/ + UINT8 ret = CI_ERROR; + UINT8 localCiId = GetSystemParaLocalCiId(); + + /*źŻID*/ + wCutoffDataSum =GetCfpSum (); + if (wCutoffDataSum < CUTOFF_POINT_SUM_MAX) + {/**/ + + for (ii = 0u; ii < CUTOFF_POINT_SUM_MAX; ii++) + { + if (jj == wCutoffDataSum) + {/*Ч*/ + + break; + } + else + { + ; + } + if (localCiId == g_szCfpConfig[ii].wLocalTiocId) + {/*òΪЧ*/ + + gszCfpId[jj] = g_szCfpConfig[ii].wPointId; + jj++; + } + else + { + ; + } + } + ret = CI_SUCCESS; + } + else + { + ; + } + + return ret; + +} + +/** +* @brief ȡ֮ڱķֽ +* @param struct_PathPoint strPointA +* @param struct_PathPoint strPointB +* @param struct_PathPoint *pPoint +* @return CI_SUCCESS:ȡɹ CI_ERROR:ȡʧ +*/ +UINT8 GetCfpLocByTwoPoints(struct_PathPoint strPointA, struct_PathPoint strPointB, struct_PathPoint* pPoint) +{ + UINT16 wIndex = 0u; + UINT16 wCfpSum = GetCfpSum(); + UINT16 wCfpId = 0u; + UINT16 wCfpLink = 0u; + UINT32 dwCfpOffset = UINT32_MAX; + UINT8 chFunRet = CI_ERROR; + UINT16 wSameLink = 0u; + UINT32 dwSameOffset = UINT32_MAX; + UINT8 chDirA = 0u; + UINT8 chDirB = 0u; + struct_PathPoint strPointCfp = { 0u }; + UINT8 chRtn = CI_ERROR; + UINT16 wLinkTioc = 0u; + UINT8 chLocTioc = 0u; + LOD_STRU lodStrPointA = { 0U }; + LOD_STRU lodStrPointB = { 0U }; + str_Zone strZone = { 0u }; + UINT32 dwLen = UINT32_MAX; + UINT16 wLinkNum = 0U; + UINT8 chFunRtn = CI_ERROR; + + /* μ⣬жǷΪϷλ */ + chFunRet = CheckLinkValid(strPointA.wLinkId, strPointA.dwOffset); + chFunRet &= CheckLinkValid(strPointB.wLinkId, strPointB.dwOffset); + if (CI_SUCCESS == chFunRet) + { + chLocTioc = GetSystemParaLocalCiId(); + for (wIndex = 0u; wIndex < wCfpSum; wIndex++) + { + wCfpId = GetCfpId(wIndex); + wCfpLink = GetCfpLink(wCfpId); + dwCfpOffset = GetCfpOffset(wCfpId); + strPointCfp.wLinkId = wCfpLink; + strPointCfp.dwOffset = dwCfpOffset; + + /* ߽㣬ȡ߽㴦λ */ + lodStrPointA.Lnk = strPointA.wLinkId; + lodStrPointA.Off = strPointA.dwOffset; + lodStrPointB.Lnk = strPointB.wLinkId; + lodStrPointB.Off = strPointB.dwOffset; + + dwLen = dsuLenByPoint(&lodStrPointA, &lodStrPointB, &wLinkNum, strZone.pLinkSeq.szLinkId, &strZone.Dir); + + if (UINT32_MAX != dwLen) + { + strZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + strZone.pStart.wLinkId = lodStrPointA.Lnk; + strZone.pStart.dwOffset = lodStrPointA.Off; + strZone.pEnd.wLinkId = lodStrPointB.Lnk; + strZone.pEnd.dwOffset = lodStrPointB.Off; + + chFunRtn = IsPointInPath(strPointCfp, strZone); /*жϷֽǷ*/ + + if (CI_ERROR == chFunRtn) + { + chRtn = CI_SUCCESS; /*γɵ֮*/ + } + else + { + + } + } + else + { + chRtn = CI_ERROR; /*ʧ*/ + } + + if (CI_SUCCESS == chRtn) + { + wLinkTioc = GetLinkManageTiocById(wCfpLink); + if (wLinkTioc == chLocTioc) + { + pPoint->wLinkId = wCfpLink; + pPoint->dwOffset = dwCfpOffset; + } + else + { + /* Ҫر߽ڱλãԱ߽linkΪTIOCȡͬλõ */ + chFunRet = dsuCheckSameLoc(wCfpLink, dwCfpOffset, &wSameLink, &dwSameOffset); + if (CI_SUCCESS == chFunRet) + { + pPoint->wLinkId = wSameLink; + pPoint->dwOffset = dwSameOffset; + } + else + { + chRtn = CI_ERROR; + } + } + break; + } + } + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡ֮ڱķֽ +* @param struct_PathPoint strPointA +* @param struct_PathPoint strPointB +* @param struct_PathPoint *pPoint +* @return CI_SUCCESS:ȡɹ CI_ERROR:ȡʧ +*/ +UINT8 GetCfpLocByTwoPointsEx(LOD_STRU strPointA, LOD_STRU strPointB, LOD_STRU *pPoint) +{ + UINT8 chRtn = CI_ERROR; + struct_PathPoint strTmpA = { 0u }; + struct_PathPoint strTmpB = { 0u }; + struct_PathPoint strTmpC = { 0u }; + LOD_STRU strTmpD = { 0u }; + UINT8 chDirChangeNum = 0u; + if (NULL == pPoint) + { + ; + } + else + { + chRtn = CheckLinkValid(strPointA.Lnk, strPointA.Off); + chRtn &= CheckLinkValid(strPointB.Lnk, strPointB.Off); + } + + /* μͨ */ + if (CI_SUCCESS == chRtn) + { + strTmpA.wLinkId = strPointA.Lnk; + strTmpA.dwOffset = strPointA.Off; + strTmpB.wLinkId = strPointB.Lnk; + strTmpB.dwOffset = strPointB.Off; + chRtn = GetCfpLocByTwoPoints(strTmpA, strTmpB, &strTmpC); + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + strTmpD.Lnk = strTmpC.wLinkId; + strTmpD.Off = strTmpC.dwOffset; + strTmpD.Dir = EMAP_SAME_DIR;/*ʹãֵ*/ + + chDirChangeNum = GetDirChangeNumBtwPoints(&(strPointA), &(strTmpD)); + pPoint->Lnk = strTmpC.wLinkId; + pPoint->Off = strTmpC.dwOffset; + pPoint->Dir = TransDirByChangeNum(strPointA.Dir, chDirChangeNum); + } + else + { + ; + } + + return chRtn; +} + +/** +* @brief ȡֽ㱾TIOC +* @param wCfpId ֽID +* @return ֽTIOC +* by cgh 20240221 +*/ +UINT16 GetCfpwLocalTiocId(const UINT16 wCfpId) +{ + UINT16 wRetVal = 0U; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + wRetVal = g_szCfpConfig[wIndex].wLocalTiocId; + } + else + { + ; + } + return wRetVal; +} + +/* +* @brief ȡֽRCźŻID +* @param const UINT16 wCfpId ֽID +* @return ֽRCźŻID +* Created By LQ 2024.09.03 +*/ +UINT16 GetCfpRelAdjacentRcSignalId(const UINT16 wCfpId) +{ + UINT16 wRetVal = 0U; + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + wRetVal = g_szCfpConfig[wIndex].wRelAdjacentRcSignalId; + } + else + { + /*μʧܣ0*/ + } + + return wRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointConfigDataManage.h b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointConfigDataManage.h new file mode 100644 index 0000000..674ad30 --- /dev/null +++ b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointConfigDataManage.h @@ -0,0 +1,147 @@ +#ifndef _CUTOFPOINT_CONFIG_DATA_MANAGE_H_ +#define _CUTOFPOINT_CONFIG_DATA_MANAGE_H_ + +#include "CutoffPointDefine.h" +#include "LinkConfigDataManage.h" +#include "../System/SystemParameterManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct S_CutoffPointConfigDataStruct + { + UINT16 wPointId; /* ֽID */ + UINT16 wLinkId; /* ֽlink */ + UINT32 dwOffset; /* ֽlinkƫ */ + UINT16 wLocalTiocId; /* TiocID*/ + UINT16 wOtherTiocId; /* TIOC */ + UINT8 chLocDir; /* TIOCڷֽ߼ */ + UINT16 wInFirstLink; /* ֽڷһlink */ + UINT16 wRelAdjacentRcSignalId; /* ֽRCźŻID */ + }CfpConfigStru; + + /*ȫֱ*/ + extern CfpConfigStru g_szCfpConfig[CUTOFF_POINT_SUM_MAX]; /* ֽݴ */ + extern UINT16 gszCfpId[CUTOFF_POINT_SUM_MAX]; + extern UINT16 gCfpConfigSum; /* ֽø */ + + /** + * @brief ȡTIOCֽ + * @param + * @return TIOCֽ + */ + extern UINT16 GetCfpSum(void); + + /** + * @brief ȡֽID + * @param bufIndex ID± + * @return ֽID + */ + extern UINT16 GetCfpId(const UINT16 bufIndex); + + /** + * @brief ȡֽ洢ָ + * @param + * @return ֽ洢ָ + */ + extern CfpConfigStru * GetCfpConfigData(void); + + /** + * @brief ȡֽ洢 + * @param wCfpId ֽID + * @return ֽ洢 + */ + extern UINT16 GetCfpBufIndex(const UINT16 wCfpId); + + /** + * @brief ȡֽlink + * @param wCfpId ֽID + * @return ֽlink + */ + extern UINT16 GetCfpLink(const UINT16 wCfpId); + + /** + * @brief ȡֽlinkƫ + * @param wCfpId ֽID + * @return ֽ洢linkƫ + */ + extern UINT32 GetCfpOffset(const UINT16 wCfpId); + + /** + * @brief ȡֽTIOC + * @param wCfpId ֽID + * @return ֽTIOC + */ + extern UINT16 GetCfpOtherTioc(const UINT16 wCfpId); + + /** + * @brief ȡTIOCڷֽ㷽 + * @param wCfpId ֽID + * @return TIOCڷֽ㷽 + */ + extern UINT8 GetCfpLocDir(const UINT16 wCfpId); + + /** + * @brief ȡֽڷһlink + * @param wCfpId ֽID + * @return ֽڷһlink + */ + extern UINT16 GetCfpInFirstLink(const UINT16 wCfpId); + + /** + * @brief linkƫȡֽID + * @param wLink + * @param dwOffset + * @return 0ѯʧ ֽID + */ + extern UINT16 GetCfpIdByPoint(UINT16 wLink, UINT32 dwOffset); + + /* + * ķֽ + * ˵ + * ֵ CI_SUCCESS,ɹ + * CI_ERROR,ʧ + */ + extern UINT8 CutoffPointConfigDataManage(void); + + /** +* @brief ȡ֮ڱķֽ +* @param struct_PathPoint strPointA +* @param struct_PathPoint strPointB +* @param struct_PathPoint *pPoint +* @return CI_SUCCESS:ȡɹ CI_ERROR:ȡʧ +*/ + UINT8 GetCfpLocByTwoPoints(struct_PathPoint strPointA, struct_PathPoint strPointB, struct_PathPoint* pPoint); + + /** + * @brief ȡ֮ڱķֽ + * @param struct_PathPoint strPointA + * @param struct_PathPoint strPointB + * @param struct_PathPoint *pPoint + * @return CI_SUCCESS:ȡɹ CI_ERROR:ȡʧ + */ + extern UINT8 GetCfpLocByTwoPointsEx(LOD_STRU strPointA, LOD_STRU strPointB, LOD_STRU *pPoint); + + /** +* @brief ȡֽ㱾TIOC +* @param wCfpId ֽID +* @return ֽTIOC +* by cgh 20240221 +*/ + UINT16 GetCfpwLocalTiocId(const UINT16 wCfpId); + + /* + * @brief ȡֽRCźŻID + * @param const UINT16 wCfpId ֽID + * @return ֽRCźŻID + * Created By LQ 2024.09.03 + */ + UINT16 GetCfpRelAdjacentRcSignalId(const UINT16 wCfpId); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDataManage.c b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDataManage.c new file mode 100644 index 0000000..fdadd97 --- /dev/null +++ b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDataManage.c @@ -0,0 +1,1634 @@ +#include "CiSystemDefine.h" +#include "SystemParameterManage.h" +#include "CutoffPointDataManage.h" +#include "CutoffPointConfigDataManage.h" +#include "LinkConfigDataManage.h" +#include "AxisSort_api.h" +#include "EnvelopeManageAPI.h" +#include "ELMDataPrepare.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "RRMManageAPI.h" + + +CfpDataStru g_CutoffPointDataBuf[CUTOFF_POINT_SUM_MAX] = { 0u }; + +/** +* @brief ڱ߽ռм +* @param wCutoffPointId ߽ +* @param pLinkNum link +* @param szLinkIdBuf link +* @return CI_SUCCESSɹCI_ERRORʧ +*/ +static UINT8 CalCutoffPointOccupyLinkSeq(IN const UINT16 wCutoffPointId, OUT UINT16 * pLinkNum, OUT UINT16 szLinkIdBuf[]); + +/* +* ֽݳʼ +* ˵ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 CutoffPointDataManageInit(void) +{ + UINT8 ret = CI_ERROR; + UINT16 dwCutoffPointSum = 0u; + UINT16 dwCutoffPointId = 0u; + UINT16 i = 0u; + UINT16 dwIndex = 0u; + + /* ȡ߽ */ + dwCutoffPointSum = GetCfpSum(); + if (dwCutoffPointSum < CUTOFF_POINT_SUM_MAX) + { + for (i = 0u; i < dwCutoffPointSum; i++) + { + /* ȡ߽ID */ + dwCutoffPointId = GetCfpId(i); + dwIndex = GetCfpBufIndex(dwCutoffPointId); + g_CutoffPointDataBuf[dwIndex].wId = dwCutoffPointId; + g_CutoffPointDataBuf[dwIndex].localTiocTrainInfo.wTrainId = 0u; + g_CutoffPointDataBuf[dwIndex].localTiocTrainInfo.chTrainLevel = 0u; + g_CutoffPointDataBuf[dwIndex].localTiocTrainInfo.dwDis = 0u; + + g_CutoffPointDataBuf[dwIndex].otherTiocTrainInfo.wTrainId = 0u; + g_CutoffPointDataBuf[dwIndex].otherTiocTrainInfo.chTrainLevel = 0u; + g_CutoffPointDataBuf[dwIndex].otherTiocTrainInfo.dwDis = 0u; + + g_CutoffPointDataBuf[dwIndex].szCfpRRMData.cRrmSrcRcId = 0U; + g_CutoffPointDataBuf[dwIndex].szCfpRRMData.wRrmTrainId = 0U; + g_CutoffPointDataBuf[dwIndex].szCfpRRMData.wRrmTrainNextStaId = 0U; + g_CutoffPointDataBuf[dwIndex].szCfpRRMData.chRrmSrcApplyState = TRAIN_RRM_LOCALCI_NOT_APPLY; + g_CutoffPointDataBuf[dwIndex].szCfpRRMData.chRrmDstAllowState = TRAIN_RRM_OTHERCI_NOT_ALLOW; + g_CutoffPointDataBuf[dwIndex].cSignalLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_NO; + } + ret = CI_SUCCESS; + } + else + { + ;/* ʼʧ */ + } + + + return ret; +} + +/* +* ȡ߽ݴ洢ַ +* ˵ +* ֵ ߽ݴ洢ַ +*/ +CfpDataStru * GetCfpData(void) +{ + return (CfpDataStru *)(&g_CutoffPointDataBuf[0]); +} + +/** +* @brief ȡֽOCгϢ +* @param wCfpId ֽID +* @return гϢ +*/ +CfpTrainInfoStru GetCfpOtherOcTrainInfo(const UINT16 wCfpId) +{ + CfpTrainInfoStru dwRetVal = {0u}; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + dwRetVal = g_CutoffPointDataBuf[wIndex].otherTiocTrainInfo; + } + else + { + dwRetVal.wTrainId = UINT16_MAX; + } + return dwRetVal; +} + +/** +* @brief ȡֽ㱾OC͵гϢ +* @param wCfpId ֽID +* @return гϢ +*/ +CfpTrainInfoStru GetCfpLocalOcTrainInfo(const UINT16 wCfpId) +{ + CfpTrainInfoStru dwRetVal = { 0u }; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + dwRetVal = g_CutoffPointDataBuf[wIndex].localTiocTrainInfo; + } + else + { + dwRetVal.wTrainId = UINT16_MAX; + } + return dwRetVal; +} + + +/** +* @brief ÷ֽOCгϢ +* @param wCfpId ֽID trainInfo гϢ +* @return гϢ +*/ +void SetCfpOtherOcTrainInfo(const UINT16 wCfpId, CfpTrainInfoStru trainInfo) +{ + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + g_CutoffPointDataBuf[wIndex].otherTiocTrainInfo = trainInfo; + } + else + { + ; + } +} + +/** +* @brief ÷ֽ㱾OC͵гϢ +* @param wCfpId ֽID trainInfo гϢ +* @return гϢ +*/ +void SetCfpLocalOcTrainInfo(const UINT16 wCfpId, CfpTrainInfoStru trainInfo) +{ + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + g_CutoffPointDataBuf[wIndex].localTiocTrainInfo = trainInfo; + } + else + { + ; + } +} + + +/** +* @brief ڱ߽ռм +* @param wCutoffPointId ߽ +* @param pLinkNum link +* @param szLinkIdBuf link +* @return CI_SUCCESSɹCI_ERRORʧ +*/ +static UINT8 CalCutoffPointOccupyLinkSeq(IN const UINT16 wCutoffPointId, OUT UINT16 * pLinkNum, OUT UINT16 szLinkIdBuf[]) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cKeepWork = CI_ERROR; + UINT16 wLinkSum = 0u; + UINT16 wszLinkIdBuf[MAX_CFG_LIGHTUPLINK_NUM] = { 0u }; + UINT16 wCutoffPointInFirstLinkId = 0u; + UINT32 dwCutoffPointInFirstLinkLen = 0u; + UINT32 dwFindLen = 0u; /*źŻƾ*/ + UINT8 cCutoffPointDir = UINT8_MAX; + UINT32 dwSearchLen = UINT32_MAX; + UINT16 wCurrentLink = UINT16_MAX; + UINT16 wNextLink = UINT16_MAX; + UINT16 wPointId = UINT16_MAX; + UINT8 cRetMem = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 cDirectionPointCnt = 0U; /*仯*/ + + dwFindLen = GetSystemParaValue(SIGNAL_LIGHTUP_SEC_LEN_ID); + dwFindLen *= 100u; + + /*μ*/ + if ((0u < wCutoffPointId) && (CUTOFF_POINT_SUM_MAX > wCutoffPointId)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == cKeepWork) + { + /*μ*/ + if ((NULL != pLinkNum) && (NULL != szLinkIdBuf)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWork) + { + /* 鵽 */ + if ((0u != dwFindLen) && (UINT32_MAX != dwFindLen)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWork) + { + /* ȡڷlinkID */ + wCutoffPointInFirstLinkId = GetCfpInFirstLink(wCutoffPointId); + dwCutoffPointInFirstLinkLen = GetLinkLengthById(wCutoffPointInFirstLinkId); + wCurrentLink = wCutoffPointInFirstLinkId; + /*ֵ*/ + if ((UINT16_MAX != wCutoffPointInFirstLinkId) && (UINT32_MAX != dwCutoffPointInFirstLinkLen)) + { + /* ȡѯ */ + cCutoffPointDir = GetCfpLocDir(wCutoffPointId); + + dwSearchLen = dwCutoffPointInFirstLinkLen; + /*źŻ*/ + if ((DIR_SAME == cCutoffPointDir) || (DIR_CONVERT == cCutoffPointDir)) + { + ;/* Ч */ + } + else + { + cCutoffPointDir = DIR_INVALID; + cKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == cKeepWork) + { + do + { + /*ȡһlinkID*/ + wNextLink = FindAdjacentLinkIDSafe(wCurrentLink, cCutoffPointDir, &wPointId, &cDirectionPointFlag); + + if (MAX_CFG_LIGHTUPLINK_NUM > wLinkSum) + { + wszLinkIdBuf[wLinkSum] = wCurrentLink; + wLinkSum++; + } + else + { + ; + } + + if ((UINT16_MAX != wNextLink) && (0u != wNextLink) && (dwSearchLen < dwFindLen)) + { + cKeepWork = dsuCheckLinkFitPointSafe(wCurrentLink, cCutoffPointDir, &wPointId); + if (CI_SUCCESS == cKeepWork) + { + /*ȡɹ*/ + wCurrentLink = wNextLink; + /*ݷ仯Ϣתѯһlink*/ + cCutoffPointDir = TransDirectionPointDir(cDirectionPointFlag, cCutoffPointDir, &cDirectionPointCnt); + + dwSearchLen += GetLinkLengthById(wCurrentLink); + if ((dwSearchLen >= dwFindLen) && (MAX_CFG_LIGHTUPLINK_NUM > wLinkSum)) + { + wszLinkIdBuf[wLinkSum] = wCurrentLink; + wLinkSum++; + } + else + { + ; + } + } + else + { + /*λãֹͣ*/ + dwSearchLen = UINT32_MAX; + cKeepWork = CI_SUCCESS; + } + } + else + { + dwSearchLen = UINT32_MAX; + } + } while (dwSearchLen < dwFindLen); + + } + else + { + ; + } + } + else + { + /*ŵһЧ*/ + cKeepWork = CI_SUCCESS; + } + } + else + { + ; + } + + + + if (CI_SUCCESS == cKeepWork) + { + /*ͨ*/ + cRetMem = CommonMemCpy(szLinkIdBuf, (UINT32)(MAX_CFG_LIGHTUPLINK_NUM * sizeof(UINT16)), wszLinkIdBuf, (UINT32)(wLinkSum * sizeof(UINT16))); + if (CI_SUCCESS == cRetMem) + { + /**/ + *pLinkNum = wLinkSum; + cRetVal = CI_SUCCESS; + } + else + { + ; + } + + } + else + { + cRetVal = CI_ERROR; + } + + return cRetVal; +} + +/* +* ֽ +* ˵ +* ֵ +*/ +void CutoffPointOutput(void) +{ + UINT16 wCutoffPointSum = 0u; + UINT16 wCutoffPointId = 0u; + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 wLinkSum = 0u; + UINT16 wszLinkIdBuf[MAX_CFG_LIGHTUPLINK_NUM] = { 0u }; + UINT16 wLinkId = 0u; + UINT16 wPhySecId = 0u; + UINT8 chOccState = 0u; + UINT8 cDir = 0u; + UINT8 cTrainDir = 0u; + UINT8 cFunRetVal = CI_ERROR; + TRAIN_SEQUANCE_s strTmp = { 0u }; + CfpTrainInfoStru tmpTrainInfo = { 0u }; + UINT16 wTrainId = 0u; + UINT32 dwDis = UINT32_MAX; + UINT32 dwDisTail = UINT32_MAX; + UINT32 dwDisHead = UINT32_MAX; + struct_PathPoint TrainPoint = { 0u }; + struct_PathPoint TrainHeadPoint = { 0u }; + struct_PathPoint TrainTailPoint = { 0u }; + struct_PathPoint CutoffPoint = { 0u }; + UINT8 cTrainTailDir = 0U; /*гȫβ*/ + UINT8 cTrainHeadDir = 0U; /*гȫͷ*/ + UINT32 dwFindLen = 0u; + UINT8 chTrainNum = 0u; + UINT8 cDirectionPointfirst = 0U; /*仯1*/ + UINT8 cDirectionPointsecond = 0U; /*仯2*/ + + dwFindLen = GetSystemParaValue(SIGNAL_LIGHTUP_SEC_LEN_ID); + dwFindLen *= 100u; + + /* ȡ߽ */ + wCutoffPointSum = GetCfpSum(); + if (wCutoffPointSum < CUTOFF_POINT_SUM_MAX) + { + for (i = 0u; i < wCutoffPointSum; i++) + { + /* ȡ߽ID */ + wCutoffPointId = GetCfpId(i); + + /* ȡѯ */ + cDir = GetCfpLocDir(wCutoffPointId); + + /* ߽ĵlink */ + cFunRetVal = CalCutoffPointOccupyLinkSeq(wCutoffPointId, &wLinkSum, wszLinkIdBuf); + + /* ȡ߽Ϣ */ + CutoffPoint.wLinkId = GetCfpLink(wCutoffPointId); + CutoffPoint.dwOffset = GetCfpOffset(wCutoffPointId); + + wTrainId = 0u; + TrainPoint.wLinkId = 0u; + TrainPoint.dwOffset = 0u; + + TrainTailPoint.wLinkId = 0U; + TrainTailPoint.dwOffset = 0U; + TrainHeadPoint.wLinkId = 0U; + TrainHeadPoint.dwOffset = 0U; + + if (CI_SUCCESS == cFunRetVal) + { + /* βҳɹ,鵽ϵг */ + for (j = 0u;j < wLinkSum;j++) + { + wLinkId = wszLinkIdBuf[j]; + wPhySecId = GetLinkRelatedPhySec(wLinkId); + chOccState = GetPhySecCurOccupyState(wPhySecId); + chTrainNum = as_GetLinkTrainNum(wLinkId); + + if ((SECTION_OCCUPY_NO != chOccState) && (0u != chTrainNum)) + { + /* ҵгռõ */ + break; + } + else + { + ; + } + + /*Ƿз仯㣬˴飬ǰlinkѰȶ꣬һlinkʱмз仯㣬仯㣬һlinkı䷽*/ + if (j < (wLinkSum - 1U)) + { + cDirectionPointfirst = GetLinkLogicDirChangedById(wszLinkIdBuf[j]); + cDirectionPointsecond = GetLinkLogicDirChangedById(wszLinkIdBuf[(j + 1U)]); /*todoԽ*/ + if (((LINK_DIRCHANGE_BEGIN == cDirectionPointfirst) || (LINK_DIRCHANGE_END == cDirectionPointfirst)) + && (cDirectionPointsecond == cDirectionPointfirst)) + { + cDir = ConvertTrainDir(cDir); /*з仯㣬ת*/ + } + else + { + ; /*ûз任㣬DZ䷽*/ + } + } + else + { + ; /*һlinkҪǷ仯⣬ֹԽ*/ + } + } + + /* ȡгID ȡֽг*/ + if (j < wLinkSum) + { + if (DIR_SAME == cDir) + { + strTmp = as_GetLinkFirstTrain(wLinkId); + } + else + { + strTmp = as_GetLinkLastTrain(wLinkId); + } + wTrainId = strTmp.u16TrainID; + } + else + { + ; + } + + if (j == wLinkSum) + { + /* δҵгռ÷޳ */ + tmpTrainInfo.wTrainId = 0u; + tmpTrainInfo.chTrainLevel = 0u; + tmpTrainInfo.dwDis = 0u; + } + else + { + /* ռãжг */ + if (NAME_FAILUREAREA == strTmp.u16TrainID) + { + /* */ + tmpTrainInfo.wTrainId = SIZE_MAX_LINETRAIN; + tmpTrainInfo.chTrainLevel = 0u; + + /* ȡλ */ + TrainPoint.wLinkId = wLinkId; + + /*ѡȡlinkϾֽĵ*/ + if (DIR_SAME == cDir) + { + TrainPoint.dwOffset = 0u; + } + else + { + TrainPoint.dwOffset = GetLinkLengthById(wLinkId); + } + + /* ѯ */ + dwDis = DsuAPointToBPoint(&TrainPoint, &CutoffPoint, &cTrainDir); + } + else + { + /* */ + tmpTrainInfo.wTrainId = strTmp.u16TrainID; + tmpTrainInfo.chTrainLevel = GetTrainLevel(tmpTrainInfo.wTrainId); + + /*ȡȫβ*/ + TrainTailPoint.wLinkId = GetTrainSafeTailLink(wTrainId); + TrainTailPoint.dwOffset = GetTrainSafeTailOffset(wTrainId); + /*ȡȫͷ*/ + TrainHeadPoint.wLinkId = GetTrainSafeHeadLink(wTrainId); + TrainHeadPoint.dwOffset = GetTrainSafeHeadOffset(wTrainId); + + /*ȡβֽ*/ + dwDisTail = DsuAPointToBPoint(&TrainTailPoint, &CutoffPoint, &cTrainTailDir); + + /*ȡͷֽ*/ + dwDisHead = DsuAPointToBPoint(&TrainHeadPoint, &CutoffPoint, &cTrainHeadDir); + + if (dwDisTail < dwDisHead) + { + dwDis = dwDisTail; + } + else + { + dwDis = dwDisHead; + } + } + + if (UINT32_MAX == dwDis) + { + tmpTrainInfo.dwDis = 0u; + } + else if(dwFindLen >= dwDis) + { + tmpTrainInfo.dwDis = dwDis; + } + else + { + /* Χ޳ */ + tmpTrainInfo.wTrainId = 0u; + tmpTrainInfo.chTrainLevel = 0u; + tmpTrainInfo.dwDis = 0u; + } + } + } + else + { + /* βʧܷ͹ϳ */ + tmpTrainInfo.wTrainId = SIZE_MAX_LINETRAIN; + tmpTrainInfo.chTrainLevel = 0u; + tmpTrainInfo.dwDis = 0u; + } + + SetCfpLocalOcTrainInfo(wCutoffPointId, tmpTrainInfo); + SetCfpLocalOcEData(wCutoffPointId); + SetCfpLocalOcCtData(wCutoffPointId); + CutoffPointRRMDataClearPro(wCutoffPointId); /*ڼ飬ӦֽеRRM*/ + } + } + else + { + ;/* ޴ */ + } +} + +/** +* @brief ȡֽOCİ +* @param wCfpId ֽID +* @return +*/ +UINT16 GetCfpOtherOcENum(const UINT16 wCfpId) +{ + UINT16 wRetVal = 0u; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + wRetVal = g_CutoffPointDataBuf[wIndex].chOtherTiocEnvelopeNum; + } + else + { + wRetVal = UINT16_MAX; + } + return wRetVal; +} + +/** +* @brief ȡֽOCİ洢ַ +* @param wCfpId ֽID +* @return 洢ַ +*/ +CfpEnvelopeStruct * GetCfpOtherOcEData(const UINT16 wCfpId) +{ + CfpEnvelopeStruct * pRetVal = NULL; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + pRetVal = g_CutoffPointDataBuf[wIndex].szOtherEnvelope; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/** +* @brief ȡֽ㷢͸OCİ +* @param wCfpId ֽID +* @return +*/ +UINT8 GetCfpLocalOcENum(const UINT16 wCfpId) +{ + UINT8 chRetVal = 0u; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + chRetVal = g_CutoffPointDataBuf[wIndex].chLocalTiocEnvelopeNum; + } + else + { + chRetVal = UINT8_MAX; + } + return chRetVal; +} + +/** +* @brief ȡֽ㷢͸OCİ洢ַ +* @param wCfpId ֽID +* @return 洢ַ +*/ +CfpEnvelopeStruct * GetCfpLocalOcEData(const UINT16 wCfpId) +{ + CfpEnvelopeStruct * pRetVal = NULL; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + pRetVal = g_CutoffPointDataBuf[wIndex].szLocalEnvelope; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/** +* @brief ÷ֽOCİ +* @param wCfpId ֽID +* @param UINT16 wNum +* @return +*/ +void SetCfpOtherOcENum(const UINT16 wCfpId, const UINT16 wNum) +{ + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + g_CutoffPointDataBuf[wIndex].chOtherTiocEnvelopeNum = (UINT8)wNum; + } + else + { + ; + } +} + +/** +* @brief ÷ֽOCİ +* @param wCfpId ֽID +* @param UINT8 chEnvelopeIndex +* @param CfpEnvelopeStruct strEnvelope +* @return +*/ +void SetCfpOtherOcEData(const UINT16 wCfpId, const UINT8 chEnvelopeIndex, const CfpEnvelopeStruct strEnvelope) +{ + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if ((CUTOFF_POINT_SUM_MAX > wIndex) && (SECTION_REL_ENVELOPE_SUM_MAX > chEnvelopeIndex)) + { + g_CutoffPointDataBuf[wIndex].szOtherEnvelope[chEnvelopeIndex] = strEnvelope; + } + else + { + ; + } +} + +/** +* @brief ÷ֽ㷢͸OCİ +* @param wCfpId ֽID +* @return +* @note ڲŻ 20220419 wqm 淶dsuCheckSameLocֵҪн +*/ +void SetCfpLocalOcEData(const UINT16 wCfpId) +{ + UINT16 wIndex = 0u; + UINT8 chEnvelopeNum = 0u; + UINT16 wLinkId = 0u; + UINT16 wAcId = 0u; + UINT8 chEnvelopeIndex = 0u; + EnvelopeStruct szTmpEnvelope[SECTION_REL_ENVELOPE_SUM_MAX] = { 0u }; + UINT8 chLocalId = 0u; + UINT16 wLinkTioc = 0u; + + wIndex = GetCfpBufIndex(wCfpId); + chLocalId = GetSystemParaLocalCiId(); + /* Ϸ */ + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + wLinkId = GetCfpInFirstLink(wCfpId); + wAcId = GetLinkBelongAcId(wLinkId); + chEnvelopeNum = elm_GetEnvelopeInAC(wAcId, szTmpEnvelope); + if (SECTION_REL_ENVELOPE_SUM_MAX == chEnvelopeNum) + { + ; + } + else + {/* Ϣӵֽ㶯̬ */ + g_CutoffPointDataBuf[wIndex].chLocalTiocEnvelopeNum = chEnvelopeNum; + for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++) + { + g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].envelopeType = szTmpEnvelope[chEnvelopeIndex].envelopeType; + g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].headTrainID = szTmpEnvelope[chEnvelopeIndex].headTrainID; + g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].tailTrainID = szTmpEnvelope[chEnvelopeIndex].tailTrainID; + g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].startPos = szTmpEnvelope[chEnvelopeIndex].startPos; + wLinkTioc = GetLinkManageTiocById(g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].startPos.Lnk); + /* ڲŻ 20220419 wqm 淶dsuCheckSameLocֵҪн*/ + if (wLinkTioc != chLocalId) + { + (void)dsuCheckSameLoc(g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].startPos.Lnk, \ + g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].startPos.Off, \ + &g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].startPos.Lnk, \ + &g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].startPos.Off); + } + g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].endPos = szTmpEnvelope[chEnvelopeIndex].endPos; + wLinkTioc = GetLinkManageTiocById(g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].endPos.Lnk); + if (wLinkTioc != chLocalId) + { + (void)dsuCheckSameLoc(g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].endPos.Lnk, \ + g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].endPos.Off, \ + &g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].endPos.Lnk, \ + &g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].endPos.Off); + } + g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].trianCnt = szTmpEnvelope[chEnvelopeIndex].trianCnt; + (void)CommonMemCpy(g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].trainID, (UINT32)sizeof(g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].trainID), \ + szTmpEnvelope[chEnvelopeIndex].trainID, (UINT32)sizeof(szTmpEnvelope[chEnvelopeIndex].trainID)); + + (void)CommonMemCpy(g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].ACTPort, (UINT32)sizeof(g_CutoffPointDataBuf[wIndex].szLocalEnvelope[chEnvelopeIndex].ACTPort), \ + szTmpEnvelope[chEnvelopeIndex].ACTPort, (UINT32)sizeof(szTmpEnvelope[chEnvelopeIndex].ACTPort)); + } + } + } + else + { + ; + } +} + +/** +* @brief ȡOCİ +* @param UINT16 wOtherOc OC +* @param CfpEnvelopeStruct szEnvelope +* @return +*/ +UINT8 GetOtherOcEnvelope(const UINT16 wOtherOc, CfpEnvelopeStruct szEnvelope[SECTION_REL_ENVELOPE_SUM_MAX * ONE_OTHER_CFP_SUM_MAX]) +{ + UINT16 wCfpIndex = 0u; + UINT16 wCfpId = 0u; + UINT16 wOcId = 0u; + UINT8 chEnvelopeNum = 0u; + UINT16 chCfpENum = 0u; + CfpEnvelopeStruct * pCfpEData = NULL; + UINT16 wCfgSum = GetCfpSum(); + for (wCfpIndex = 0u; wCfpIndex < wCfgSum; wCfpIndex++) + { + wCfpId = GetCfpId(wCfpIndex); + wOcId = GetCfpOtherTioc(wCfpId); + if (wOcId == wOtherOc) + {/* ȡָֽTIOCİϢ */ + chCfpENum = GetCfpOtherOcENum(wCfpId); + pCfpEData = GetCfpOtherOcEData(wCfpId); + if ((NULL != pCfpEData) && (0u != chCfpENum) && (UINT16_MAX != chCfpENum)) + {/* ͬTIOCֽͨİһ */ + (void)CommonMemCpy(&szEnvelope[chEnvelopeNum], (UINT32)(chCfpENum * sizeof(CfpEnvelopeStruct)), \ + pCfpEData, (UINT32)(chCfpENum * sizeof(CfpEnvelopeStruct))); + chEnvelopeNum += (UINT8)chCfpENum; + } + else + { + ; + } + } + else + { + ; + } + } + return chEnvelopeNum; +} + +/** +* @brief ÷ֽ㷢͸OCͨг +* @param wCfpId ֽID +* @return +* @note +*/ +void SetCfpLocalOcCtData(const UINT16 wCfpId) +{ + UINT16 wIndex = 0u; + UINT8 chCtNum = 0u; + UINT16 wLinkId = 0u; + UINT16 wAcId = 0u; + UINT8 chCtIndex = 0u; + UINT16 szCtTrainId[TRAIN_SUM_MAX] = { 0u }; + UINT8 chSendNum = 0u; + UINT8 chFunRtn = CI_ERROR; + struct_PathPoint strPoint = { 0u }; + + wIndex = GetCfpBufIndex(wCfpId); + /* Ϸ */ + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + strPoint.wLinkId = GetCfpLink(wCfpId); + strPoint.dwOffset = GetCfpOffset(wCfpId); + wLinkId = GetCfpInFirstLink(wCfpId); + wAcId = GetLinkBelongAcId(wLinkId); + chCtNum = GetTrainInAc(wAcId, szCtTrainId); + for (chCtIndex = 0u; chCtIndex < chCtNum; chCtIndex++) + { + chFunRtn = IsTrainMoveToPoint(szCtTrainId[chCtIndex], strPoint); + if (CI_SUCCESS == chFunRtn) + { + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].wTrainId = szCtTrainId[chCtIndex]; + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].chLevel = GetTrainLevel(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].dwDelay = GetTrainMsgDelayTime(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].wSpeed = GetTrainSpeed(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].chSpeedDir = GetTrainSpeedDir(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].chTrainDir = GetTrainDir(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].wMaxHeadLink = GetTrainMaxHeadLink(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].dwMaxHeadOff = GetTrainMaxHeadOffset(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].wMinHeadLink = GetTrainMinHeadLink(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].dwMinHeadOff = GetTrainMinHeadOffset(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].wMaxTailLink = GetTrainMaxTailLink(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].dwMaxTailOff = GetTrainMaxTailOffset(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].wMinTailLink = GetTrainMinTailLink(szCtTrainId[chCtIndex]); + g_CutoffPointDataBuf[wIndex].szLocalCtTrain[chSendNum].dwMinTailOff = GetTrainMinTailOffset(szCtTrainId[chCtIndex]); + chSendNum++; + } + else + { + ; + } + } + g_CutoffPointDataBuf[wIndex].chCtNum = chSendNum; + } + else + { + ; + } +} + +/** +* @brief ȡֽ㷢͸OCͨųַ +* @param wCfpId ֽID +* @return ͨų洢ַ +*/ +CfpCtTrainStruct * GetCfpLocalOcCtData(const UINT16 wCfpId) +{ + CfpCtTrainStruct * pRetVal = NULL; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + pRetVal = g_CutoffPointDataBuf[wIndex].szLocalCtTrain; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/** +* @brief ȡֽ㷢͸OCͨų +* @param wCfpId ֽID +* @return ͨų +*/ +UINT8 GetCfpLocalOcCtNum(const UINT16 wCfpId) +{ + UINT8 chRtn = 0u; + UINT16 wIndex = 0u; + wIndex = GetCfpBufIndex(wCfpId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + chRtn = g_CutoffPointDataBuf[wIndex].chCtNum; + } + else + { + chRtn = UINT8_MAX; + } + return chRtn; +} + +/** +* @brief ȡֽOCİ +* @param wCfpId ֽID +* @param CfpEnvelopeStruct* strEnvelope +* @return CI_ ERROR ȡʧ +* CI_ SUCCESS ȡɹ +* by cgh 20240111 +*/ +UINT8 CutCfpOtherOcEData(const UINT16 wCfpId, CfpEnvelopeStruct* strEnvelope) +{ + UINT8 chReval = CI_ERROR; + UINT8 chLocalCiId = 0U;/*ID*/ + UINT16 wLinkTioc = 0U;/*LINKID*/ + UINT16 wCfpLinkId = 0U;/*ֽLINK ID*/ + UINT32 dwCfpLinkOffset = 0U;/*ֽLINKƫ*/ + UINT16 wCfpSameLocLinkId = 0U;/*ֽͬλLINK ID*/ + UINT32 dwCfpSameLocLinkOffset = 0U;/*ֽͬλLINKƫ*/ + UINT16 wLinkBelongAxieId = 0U;/*LINKID*/ + UINT8 chAxieIncLinkSum = 0U;/*ΰLINKĿ*/ + UINT16* szAxieIncLink = NULL;/*ΰLINK*/ + UINT8 ii = 0U; + UINT8 chKeepFlag = 0U;/*ִб־*/ + UINT8 chEnvelopeStartFlag = 0U;/*ʼǷڼα־*/ + UINT8 chEnvelopeEndFlag = 0U;/*նǷڼα־*/ + ELM_AxisLocStruct tmpAxieSecLoc = { 0U };/*λ*/ + + if (CUTOFF_POINT_SUM_MAX > wCfpId) + { + /*ֻȡUCT*/ + if ((TYPE_UCT_ENVELOPE == strEnvelope->envelopeType) || (TYPE_CT_ENVELOPE == strEnvelope->envelopeType)) + { + chLocalCiId = GetSystemParaLocalCiId(); + wCfpLinkId = GetCfpLink(wCfpId); + dwCfpLinkOffset = GetCfpOffset(wCfpId); + wLinkTioc = GetLinkManageTiocById(wCfpLinkId); + + if (chLocalCiId == wLinkTioc) + { + /*ֽõλΪҪתΪͬλ*/ + chKeepFlag = dsuCheckSameLoc(wCfpLinkId, dwCfpLinkOffset, &wCfpSameLocLinkId, &dwCfpSameLocLinkOffset); + } + else + { + /*ֽLINKʱʹ÷ֽӦLINK*/ + chKeepFlag = CI_SUCCESS; + wCfpSameLocLinkId = wCfpLinkId; + dwCfpSameLocLinkOffset = dwCfpLinkOffset; + } + + if (CI_SUCCESS == chKeepFlag) + { + wLinkBelongAxieId = GetLinkBelongAcId(wCfpSameLocLinkId); + chAxieIncLinkSum = GetAxisLinkSum(wLinkBelongAxieId); + szAxieIncLink = GetAxisLinkIdBuf(wLinkBelongAxieId); + chKeepFlag = elm_PrepareACLoc(wLinkBelongAxieId, ELM_DIR_SAME, &tmpAxieSecLoc); + + if (CI_SUCCESS == chKeepFlag) + { + for (ii = 0U; ii < chAxieIncLinkSum; ii++) + { + if (szAxieIncLink[ii] == strEnvelope->startPos.Lnk) + { + chEnvelopeStartFlag = CI_SUCCESS; + break; + } + else + { + ; /**/ + } + } + + for (ii = 0U; ii < chAxieIncLinkSum; ii++) + { + if (szAxieIncLink[ii] == strEnvelope->endPos.Lnk) + { + chEnvelopeEndFlag = CI_SUCCESS; + break; + } + else + { + ; /**/ + } + } + + chReval = CI_SUCCESS; + if ((CI_SUCCESS == chEnvelopeStartFlag) && (CI_SUCCESS == chEnvelopeEndFlag)) + { + ; /*ʼ˶˾ڼڣȡ*/ + } + else if (CI_SUCCESS == chEnvelopeStartFlag) + { + /*ʼڼ*/ + strEnvelope->endPos.Dir = strEnvelope->startPos.Dir; + if (EMAP_SAME_DIR == strEnvelope->startPos.Dir) + { + /*ʼ˷Ϊ߼򣬽ȡİնΪյ*/ + strEnvelope->endPos.Lnk = tmpAxieSecLoc.endPos.Lnk; + strEnvelope->endPos.Off = tmpAxieSecLoc.endPos.Off; + } + else + { + /*ʼ˷Ϊ߼򣬽ȡİնΪ*/ + strEnvelope->endPos.Lnk = tmpAxieSecLoc.startPos.Lnk; + strEnvelope->endPos.Off = tmpAxieSecLoc.startPos.Off; + } + } + else if (CI_SUCCESS == chEnvelopeEndFlag) + { + /*նڼ*/ + strEnvelope->startPos.Dir = strEnvelope->endPos.Dir; + if (EMAP_SAME_DIR == strEnvelope->endPos.Dir) + { + /*βΪ߼򣬽ȡİնΪ*/ + strEnvelope->startPos.Lnk = tmpAxieSecLoc.startPos.Lnk; + strEnvelope->startPos.Off = tmpAxieSecLoc.startPos.Off; + } + else + { + /*βΪ߼򣬽ȡİնΪյ*/ + strEnvelope->startPos.Lnk = tmpAxieSecLoc.endPos.Lnk; + strEnvelope->startPos.Off = tmpAxieSecLoc.endPos.Off; + } + } + else + { + chReval = CI_ERROR; + } + } + else + { + ; /*ʧ*/ + } + } + else + { + ; /*ʧ*/ + } + } + else + { + /*Ͳȡԭ*/ + chReval = CI_SUCCESS; + } + } + else + { + ; /*ֽIDޣʧ*/ + } + + return chReval; +} + +/** +* @brief ȡֽRRMԴRC ID +* @param const UINT16 wCfpId ֽID +* @return 0 ȡʧܣ ԴRC ID +* Created By LQ 20240229 +*/ +UINT8 GetCfpRrmSrcRcId(const UINT16 wCfpId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + chRetVal = g_CutoffPointDataBuf[wIndex].szCfpRRMData.cRrmSrcRcId; + } + else + { + ; + } + + return chRetVal; +} + +/** +* @brief ÷ֽRRMԴRC ID +* @param wCfpId ֽID +* @param const UINT8 chSrcRcId ԴRC ID +* @return +* Created By LQ 20240229 +*/ +void SetCfpRrmSrcRcId(const UINT16 wCfpId, const UINT8 chSrcRcId) +{ + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if ((CUTOFF_POINT_SUM_MAX > wIndex) && ((0U < chSrcRcId) || (CI_SUM_MAX > chSrcRcId))) + { + g_CutoffPointDataBuf[wIndex].szCfpRRMData.cRrmSrcRcId = chSrcRcId; + } + else + { + ; + } +} + +/** +* @brief ȡֽRRMԴTIOC״̬ +* @param wCfpId ֽID +* @return RRMԴTIOC״̬ +* by cgh 20240220 +*/ +UINT8 GetCfpRrmSrcApplyState(const UINT16 wCfpId) +{ + UINT8 chRetVal = TRAIN_RRM_LOCALCI_NOT_APPLY; + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + chRetVal = g_CutoffPointDataBuf[wIndex].szCfpRRMData.chRrmSrcApplyState; + } + else + { + ; + } + return chRetVal; +} + +/** +* @brief ÷ֽRRMԴTIOC״̬ +* @param wCfpId ֽID +* @param const UINT8 chRrmSrcApplyState RRMԴTIOC״̬ +* @return +* by cgh 20240221 +*/ +void SetCfpRrmSrcApplyState(const UINT16 wCfpId,const UINT8 chRrmSrcApplyState) +{ + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if ((CUTOFF_POINT_SUM_MAX > wIndex) && ((TRAIN_RRM_LOCALCI_NOT_APPLY == chRrmSrcApplyState) || (TRAIN_RRM_LOCALCI_APPLY == chRrmSrcApplyState))) + { + g_CutoffPointDataBuf[wIndex].szCfpRRMData.chRrmSrcApplyState = chRrmSrcApplyState; + } + else + { + ; + } +} + +/** +* @brief ȡֽRRMĿTIOC״̬ +* @param wCfpId ֽID +* @return RRMĿTIOC״̬ +* by cgh 20240220 +*/ +UINT8 GetCfpRrmDstAllowState(const UINT16 wCfpId) +{ + UINT8 chRetVal = TRAIN_RRM_OTHERCI_NOT_ALLOW; + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + chRetVal = g_CutoffPointDataBuf[wIndex].szCfpRRMData.chRrmDstAllowState; + } + else + { + ; + } + return chRetVal; +} + +/** +* @brief ÷ֽRRMĿTIOC״̬ +* @param wCfpId ֽID +* @param const UINT8 chRrmSrcApplyState RRMĿTIOC״̬ +* @return +* by cgh 20240221 +*/ +void SetCfpRrmDstAllowState(const UINT16 wCfpId, const UINT8 chRrmDstAllowState) +{ + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if ((CUTOFF_POINT_SUM_MAX > wIndex) && ((TRAIN_RRM_OTHERCI_ALLOW == chRrmDstAllowState) || (TRAIN_RRM_OTHERCI_NOT_ALLOW == chRrmDstAllowState))) + { + g_CutoffPointDataBuf[wIndex].szCfpRRMData.chRrmDstAllowState = chRrmDstAllowState; + } + else + { + ; + } +} + +/** +* @brief ȡֽRRMгID +* @param wCfpId ֽID +* @return RRMгID +* by cgh 20240221 +*/ +UINT16 GetCfpRrmTrainId(const UINT16 wCfpId) +{ + UINT16 chRetVal = 0U; + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + chRetVal = g_CutoffPointDataBuf[wIndex].szCfpRRMData.wRrmTrainId; + } + else + { + ; + } + return chRetVal; +} + +/** +* @brief ÷ֽRRMгID +* @param wCfpId ֽID +* @param const UINT16 wRrmTrainId RRMгID +* @return +* by cgh 20240221 +*/ +void SetCfpRrmTrainId(const UINT16 wCfpId, const UINT16 wRrmTrainId) +{ + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if ((CUTOFF_POINT_SUM_MAX > wIndex) && (LINE_MAX_TRAIN > wRrmTrainId)) + { + g_CutoffPointDataBuf[wIndex].szCfpRRMData.wRrmTrainId = wRrmTrainId; + } + else + { + ; + } +} + +/** +* @brief ȡֽRRMгһվ̨ID +* @param wCfpId ֽID +* @return RRMгһվ̨ID +* by cgh 20240221 +*/ +UINT16 GetCfpRrmTrainNextStaId(const UINT16 wCfpId) +{ + UINT16 chRetVal = 0U; + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + chRetVal = g_CutoffPointDataBuf[wIndex].szCfpRRMData.wRrmTrainNextStaId; + } + else + { + ; + } + return chRetVal; +} + +/** +* @brief ÷ֽRRMгһվ̨ID +* @param wCfpId ֽID +* @param const UINT16 wRrmTrainNextStaId RRMгһվ̨ID +* @return +* by cgh 20240221 +*/ +void SetCfpRrmTrainNextStaId(const UINT16 wCfpId, const UINT16 wRrmTrainNextStaId) +{ + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if ((CUTOFF_POINT_SUM_MAX > wIndex) && (UINT16_MAX > wRrmTrainNextStaId)) + { + g_CutoffPointDataBuf[wIndex].szCfpRRMData.wRrmTrainNextStaId = wRrmTrainNextStaId; + } + else + { + ; + } +} + +/* +* TIOCͨãRRM +* ˵ UINT8 chTiocId TIOC +* ֵ +* by cgh 20240221 +*/ +void NeighborGoodRrmProc(UINT8 chTiocId) +{ + UINT8 ii = 0U; + UINT16 wCutoffPointSum = 0U;/*TIOCֽĿ*/ + UINT16 wCutoffPointId = 0U;/*ֽID*/ + UINT16 wOtherTiocId = 0U;/*ֽԷTIOC ID*/ + UINT8 cLocalCiId = 0U; + UINT8 cRrmSrcRcId = 0U; /*RRMԴRCID*/ + UINT16 wRrmTrainId = 0U; /*RRMгID*/ + UINT16 wRrmStationId = 0U; /*RRMվ̨ID*/ + UINT8 cRrmSrcRcApplyState = TRAIN_RRM_LOCALCI_NOT_APPLY; + UINT8 chCheckResult = CI_ERROR;/**/ + UINT16 wCfpAxisSecIdBuf[CUTOFF_POINT_SUM_MAX] = { 0U };/*ֽ*/ + UINT8 chAxisSecSum = 0U;/*Ŀ*/ + UINT8 chLocDir = 0U; + UINT16 wCfpAxisSecId = 0U; /*ֽ㴦ļID*/ + + if ((0U < chTiocId) && (CI_SUM_MAX > chTiocId)) + { + wCutoffPointSum = GetCfpSum(); + cLocalCiId = GetSystemParaLocalCiId(); + for (ii = 0U; ii < wCutoffPointSum; ii++) + { + wCutoffPointId = GetCfpId(ii); + wOtherTiocId = GetCfpOtherTioc(wCutoffPointId); + cRrmSrcRcId = GetCfpRrmSrcRcId(wCutoffPointId); + cRrmSrcRcApplyState = GetCfpRrmSrcApplyState(wCutoffPointId); + if ((chTiocId == wOtherTiocId) && (cLocalCiId != cRrmSrcRcId) && (TRAIN_RRM_LOCALCI_APPLY == cRrmSrcRcApplyState)) + { + /*RCԴRCԴRCRMMŽд*/ + chAxisSecSum = elm_PrepareCfpAc(wCfpAxisSecIdBuf); + chLocDir = GetCfpLocDir(wCutoffPointId); + + if ((0U < chAxisSecSum) && (CUTOFF_POINT_SUM_MAX > chAxisSecSum) && ((EMAP_CONVER_DIR == chLocDir) || (EMAP_SAME_DIR == chLocDir))) + { + wCfpAxisSecId = GetAxisSecIdAccordCfpId(wCutoffPointId, chAxisSecSum, wCfpAxisSecIdBuf); /*ȡֽ㴦ļID*/ + + if (CI_ERROR != wCfpAxisSecId) + { + wRrmTrainId = GetCfpRrmTrainId(wCutoffPointId); + wRrmStationId = GetCfpRrmTrainNextStaId(wCutoffPointId); + chCheckResult = rrm_OtherCiConditionsCheck(wRrmTrainId, wRrmStationId, wCfpAxisSecId, chLocDir); + } + else + { + /*ȡʧܣ*/ + } + } + else + { + ; /*飬Ĭʧ*/ + } + + if (CI_SUCCESS == chCheckResult) + { + SetCfpRrmDstAllowState(wCutoffPointId, TRAIN_RRM_OTHERCI_ALLOW); + } + else + { + /*ֽCI 鲻ͨĿTIOC*/ + SetCfpRrmDstAllowState(wCutoffPointId, TRAIN_RRM_OTHERCI_NOT_ALLOW); + } + } + else + { + /*ֽԷCI IDָCIRRM룬*/ + } + } + } + else + { + ; /*IDϷ*/ + } +} + + +/* +* ݷֽIDȡֽ㴦ļID +* ˵UINT16 wCfpId ֽID +* UINT8 cAxisSecNum +* UINT16 pAxisSecIdBuf[CUTOFF_POINT_SUM_MAX] ID +* ֵ CI_ERROR 0 ȡʧ +* ID +* Created by LQ 20240227 +*/ +UINT16 GetAxisSecIdAccordCfpId(UINT16 wCfpId, UINT8 cAxisSecNum, UINT16 pAxisSecIdBuf[CUTOFF_POINT_SUM_MAX]) +{ + UINT16 retVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT16 wCutoffPointFstLinkId = 0U; /*ֽڷһlink ID*/ + UINT16* pAxleSecIncLinkId = NULL; /*ΰlink ID*/ + UINT8 cAxleSecIncLinkNum = 0U; /*ΰlink*/ + + if ((0U < wCfpId) && (CUTOFF_POINT_SUM_MAX > wCfpId) && (0U < cAxisSecNum) && (CUTOFF_POINT_SUM_MAX >= cAxisSecNum) && (NULL != pAxisSecIdBuf)) + { + wCutoffPointFstLinkId = GetCfpInFirstLink(wCfpId); + + for (ii = 0U; ii < cAxisSecNum; ii++) + { + pAxleSecIncLinkId = GetAxisLinkIdBuf(pAxisSecIdBuf[ii]); + cAxleSecIncLinkNum = GetAxisLinkSum(pAxisSecIdBuf[ii]); + + if ((0U < cAxleSecIncLinkNum) && (AXIS_INCLUDE_LINK_SUM_MAX >= cAxleSecIncLinkNum) && (NULL != pAxleSecIncLinkId)) + { + for (jj = 0U; jj < cAxleSecIncLinkNum; jj++) + { + if ((wCutoffPointFstLinkId == pAxleSecIncLinkId[jj]) && (0U != wCutoffPointFstLinkId)) + { + retVal = pAxisSecIdBuf[ii]; /*ΰlinkΪֽڷһlinkΪֽ㴦ļ*/ + break; + } + else + { + /**/ + } + } + + if (CI_ERROR != retVal) + { + break; /*ҵֽ㴦Σֹͣ*/ + } + else + { + /**/ + } + } + else + { + /**/ + } + } + } + else + { + /*ηǷ0ʧ*/ + } + + return retVal; +} + +/* +* ֽRRM +* ˵const UINT16 wCutoffPointId ֽID +* ֵ +* Created By CGH 2024.07.29 +*/ +void CutoffPointRRMDataClearPro(const UINT16 wCutoffPointId) +{ + UINT16 ii = 0U; + UINT16 wIndex = 0u; + UINT16 wTrainId = 0U; + UINT8 cLocalCiId = 0U; + UINT8 cRrmSrcRcId = 0U; + UINT8 cElmNum = 0u; + EnvelopeStruct* pEnvelop = NULL; + UINT16 szEnvelopeId[TRAIN_REL_ENVELOPE_SUM_MAX] = { 0u }; + UINT8 cRRMRequstState = TRAIN_RRM_RQST_NO; + UINT8 cClearFlag = FLAG_UNSET; + UINT16 wCutoffPointSum = 0U; /*ֽ*/ + UINT16 wOtherCfpId = 0U; /*ֽID*/ + UINT16 wOtherCfpTrainId = 0U; /*ֽRRMгID*/ + UINT8 cOtherCfpSrcRcId = 0U; /*ֽRRMԴRCID*/ + UINT8 cRrmReason = TRAIN_RRM_RESON_FF; + UINT8 cOtherRcRrmReason = TRAIN_RRM_RESON_FF; + + wIndex = GetCfpBufIndex(wCutoffPointId); + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + wTrainId = GetCfpRrmTrainId(wCutoffPointId); + + /*жϷֽǷڿRRMг*/ + if ((0U < (wTrainId & 0x00FFU)) && (TRAIN_SUM_MAX > (wTrainId & 0x00FFU))) + { + cLocalCiId = GetSystemParaLocalCiId(); + cRrmSrcRcId = GetCfpRrmSrcRcId(wCutoffPointId); + + /*жϷֽRRMڵԴRCǷΪ*/ + if ((cLocalCiId == cRrmSrcRcId) && (0U != cRrmSrcRcId)) + { + cElmNum = elm_GetTrainRelELM(wTrainId, szEnvelopeId); + pEnvelop = elm_GetEnvelopeInfoByID(szEnvelopeId[0u]); + + /*жгǷΪUCTCT*/ + if ((1U == cElmNum) && (NULL != pEnvelop) && ((TYPE_UCT_ENVELOPE == pEnvelop->envelopeType) || (TYPE_CT_ENVELOPE == pEnvelop->envelopeType))) + { + cRRMRequstState = GetTrainRrmRqst(wTrainId); + + /*жгǷRRM*/ + if (TRAIN_RRM_RQST_YES == cRRMRequstState) + { + /**/ + } + else + { + cClearFlag = FLAG_SET; /*гδRRMӦֽڵRRM*/ + } + } + else + { + wCutoffPointSum = GetCfpSum(); /*ȡǰеķֽ*/ + for (ii = 0u; ii < wCutoffPointSum; ii++) + { + wOtherCfpId = GetCfpId(ii); + if (wOtherCfpId != wCutoffPointId) + { + wOtherCfpTrainId = GetCfpRrmTrainId(wOtherCfpId); + cOtherCfpSrcRcId = GetCfpRrmSrcRcId(wOtherCfpId); + if ((wOtherCfpTrainId == wTrainId) && (cOtherCfpSrcRcId != cLocalCiId)) + { + break; /*ֽҵ˳ʾRMMRCֽܶڵRRM*/ + } + } + else + { + /*ֽ㲻*/ + } + } + + if (ii == wCutoffPointSum) + { + cClearFlag = FLAG_SET; /*гҷUCTCT磬ֽ޳ӦֽڵRRM*/ + } + else + { + /*ֽд˳ʾRMMӦֽڵRRM*/ + } + } + + cRrmReason = GetTrainRrmReson(wTrainId); + cOtherRcRrmReason = GetTrainOtherRcRrmReson(wTrainId); + if (((TRAIN_RRM_RESON_15 != cRrmReason) && (TRAIN_RRM_RESON_FF != cRrmReason)) || ((TRAIN_RRM_RESON_15 != cOtherRcRrmReason) && (TRAIN_RRM_RESON_FF != cOtherRcRrmReason))) + { + cClearFlag = FLAG_SET; /*鲻ͨڿͼ飬ֽRRM*/ + } + else + { + /**/ + } + + } + else + { + /*ԴRCDZ*/ + } + } + else + { + /*г*/ + } + + if (FLAG_SET == cClearFlag) + { + /*ֽڵRRM*/ + g_CutoffPointDataBuf[wIndex].szCfpRRMData.cRrmSrcRcId = 0U; + g_CutoffPointDataBuf[wIndex].szCfpRRMData.wRrmTrainId = 0U; + g_CutoffPointDataBuf[wIndex].szCfpRRMData.wRrmTrainNextStaId = 0U; + g_CutoffPointDataBuf[wIndex].szCfpRRMData.chRrmSrcApplyState = TRAIN_RRM_LOCALCI_NOT_APPLY; + g_CutoffPointDataBuf[wIndex].szCfpRRMData.chRrmDstAllowState = TRAIN_RRM_OTHERCI_NOT_ALLOW; + SetTrainOtherRcRrmReson(wTrainId, TRAIN_RRM_RESON_FF); + } + else + { + /**/ + } + } + else + { + /*ηǷ*/ + } +} + +/** +* @brief ȡֽźŻ־ +* @param const UINT16 wCfpId ֽID +* @return 0x55 ־Ч +* 0xAA ־Ч +* Created By LQ 2024.09.03 +*/ +UINT8 GetCfpSignalLightUpFlag(const UINT16 wCfpId) +{ + UINT8 cRetVal = SIGNAL_SLEEP_TRAIN_LIGHTUP_YES; + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if (CUTOFF_POINT_SUM_MAX > wIndex) + { + cRetVal = g_CutoffPointDataBuf[wIndex].cSignalLightUpFlag; + } + else + { + ; + } + + return cRetVal; +} + +/** +* @brief ÷ֽźŻƱ־ +* @param const UINT16 wCfpId ֽID +* @param const UINT8 cLightUpFlag Ʊ־ +* @return +* Created By LQ 2024.09.03 +*/ +void SetCfpSignalLightUpFlag(const UINT16 wCfpId, const UINT8 cLightUpFlag) +{ + UINT16 wIndex = 0U; + + wIndex = GetCfpBufIndex(wCfpId); + + if ((CUTOFF_POINT_SUM_MAX > wIndex) && ((SIGNAL_SLEEP_TRAIN_LIGHTUP_YES == cLightUpFlag) || (SIGNAL_SLEEP_TRAIN_LIGHTUP_NO == cLightUpFlag))) + { + g_CutoffPointDataBuf[wIndex].cSignalLightUpFlag = cLightUpFlag; + } + else + { + ; + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDataManage.h b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDataManage.h new file mode 100644 index 0000000..3a46323 --- /dev/null +++ b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDataManage.h @@ -0,0 +1,358 @@ +#ifndef _CUTOFPOINT_DATA_MANAGE_H_ +#define _CUTOFPOINT_DATA_MANAGE_H_ + +#include "CutoffPointDefine.h" +#include "EnvelopeDefine.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + UINT16 wTrainId; /* ֽгID */ + UINT8 chTrainLevel; /* ֽгм */ + UINT32 dwDis; /* ֽгֽ֮루cm */ +}CfpTrainInfoStru; + +/** TIOCӿʹõİ */ +typedef struct +{ + UINT8 envelopeType; /* */ + UINT16 headTrainID; /*ǰгID*/ + UINT16 tailTrainID; /*гID*/ + LOD_STRU startPos; /*ʼλ*/ + LOD_STRU endPos; /*նλ*/ + UINT8 trianCnt; /*аг*/ + UINT16 trainID[TRAIN_IN_ENVELOPE_SUM_MAX]; /*агID*/ + UINT8 ACTPort[TRAIN_IN_ENVELOPE_SUM_MAX]; /*гˡUCTֽ޷RMM */ + UINT8 ACCnt; /*AC*/ + UINT16 ACID[SECTION_IN_ENVELOPE_SUM_MAX]; /*AC ID*/ +}CfpEnvelopeStruct; + +/* ֽͨг */ +typedef struct +{ + UINT16 wTrainId; /* гID */ + UINT8 chLevel; /* гм */ + UINT32 dwDelay; /* TIOCгͨʱ */ + UINT16 wSpeed; /* гٶ */ + UINT8 chSpeedDir; /* ٶȷ */ + UINT8 chTrainDir; /* гз */ + UINT16 wMaxHeadLink; /* гȫǰlink */ + UINT32 dwMaxHeadOff; /* гȫǰƫ */ + UINT16 wMinHeadLink; /* гСȫǰlink */ + UINT32 dwMinHeadOff; /* гСȫǰƫ */ + UINT16 wMaxTailLink; /* гȫlink */ + UINT32 dwMaxTailOff; /* гȫƫ */ + UINT16 wMinTailLink; /* гСȫlink */ + UINT32 dwMinTailOff; /* гСȫƫ */ +}CfpCtTrainStruct; + +/* ԶRM */ +typedef struct +{ + UINT8 cRrmSrcRcId; /* ԴRC ID */ + UINT16 wRrmTrainId; /* RRMгID */ + UINT16 wRrmTrainNextStaId; /* RRMгһվ̨ID */ + UINT8 chRrmSrcApplyState; /* ԶRMʱԴTIOC״̬ */ + UINT8 chRrmDstAllowState; /* ԶRMʱĿTIOC״̬ */ +}CfpRRMDataStruct; + +typedef struct +{ + UINT16 wId; /* ֽID */ + CfpTrainInfoStru otherTiocTrainInfo; /* յгϢ */ + CfpTrainInfoStru localTiocTrainInfo; /* ͵гϢ */ + UINT8 chLocalTiocEnvelopeNum; /* ͵İ */ + CfpEnvelopeStruct szLocalEnvelope[SECTION_REL_ENVELOPE_SUM_MAX]; /* ͵İ */ + UINT8 chOtherTiocEnvelopeNum; /* յİ */ + CfpEnvelopeStruct szOtherEnvelope[SECTION_REL_ENVELOPE_SUM_MAX]; /* յİϢ */ + UINT8 chCtNum; /* ֽͨų */ + CfpCtTrainStruct szLocalCtTrain[TRAIN_SUM_MAX]; /* ֽͨųϢ */ + CfpRRMDataStruct szCfpRRMData; /* ֽԶRM*/ + UINT8 cSignalLightUpFlag; /*ֽźŻƱ־0x55 Ʊ־Ч0xAA Ʊ־Ч*/ +}CfpDataStru; + +/*ȫֱ*/ +extern CfpDataStru g_CutoffPointDataBuf[CUTOFF_POINT_SUM_MAX]; + +/* +* ֽݳʼ +* ˵ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 CutoffPointDataManageInit(void); + +/** +* @brief ȡֽOCгϢ +* @param wCfpId ֽID +* @return гϢ +*/ +CfpTrainInfoStru GetCfpOtherOcTrainInfo(const UINT16 wCfpId); + + +/** +* @brief ȡֽ㱾OC͵гϢ +* @param wCfpId ֽID +* @return гϢ +*/ +CfpTrainInfoStru GetCfpLocalOcTrainInfo(const UINT16 wCfpId); + +/** +* @brief ÷ֽOCгϢ +* @param wCfpId ֽID trainInfo гϢ +* @return гϢ +*/ +void SetCfpOtherOcTrainInfo(const UINT16 wCfpId, CfpTrainInfoStru trainInfo); + +/** +* @brief ÷ֽ㱾OC͵гϢ +* @param wCfpId ֽID trainInfo гϢ +* @return гϢ +*/ +void SetCfpLocalOcTrainInfo(const UINT16 wCfpId, CfpTrainInfoStru trainInfo); + +/* +* ֽ +* ˵ +* ֵ +*/ +void CutoffPointOutput(void); + +/** +* @brief ȡֽOCİ +* @param wCfpId ֽID +* @return +*/ +UINT16 GetCfpOtherOcENum(const UINT16 wCfpId); + +/** +* @brief ȡֽOCİ洢ַ +* @param wCfpId ֽID +* @return 洢ַ +*/ +CfpEnvelopeStruct * GetCfpOtherOcEData(const UINT16 wCfpId); + +/** +* @brief ȡֽ㷢͸OCİ +* @param wCfpId ֽID +* @return +*/ +UINT8 GetCfpLocalOcENum(const UINT16 wCfpId); + +/** +* @brief ȡֽ㷢͸OCİ洢ַ +* @param wCfpId ֽID +* @return 洢ַ +*/ +CfpEnvelopeStruct * GetCfpLocalOcEData(const UINT16 wCfpId); + +/** +* @brief ÷ֽOCİ +* @param wCfpId ֽID +* @param UINT16 wNum +* @return +*/ +void SetCfpOtherOcENum(const UINT16 wCfpId, const UINT16 wNum); + +/** +* @brief ÷ֽOCİ +* @param wCfpId ֽID +* @param UINT8 chEnvelopeIndex +* @param CfpEnvelopeStruct strEnvelope +* @return +*/ +void SetCfpOtherOcEData(const UINT16 wCfpId, const UINT8 chEnvelopeIndex, const CfpEnvelopeStruct strEnvelope); + +/** +* @brief ÷ֽ㷢͸OCİ +* @param wCfpId ֽID +* @return +*/ +void SetCfpLocalOcEData(const UINT16 wCfpId); + +/** +* @brief ȡOCİ +* @param UINT16 wOtherOc OC +* @param CfpEnvelopeStruct szEnvelope +* @return +*/ +UINT8 GetOtherOcEnvelope(const UINT16 wOtherOc, CfpEnvelopeStruct szEnvelope[SECTION_REL_ENVELOPE_SUM_MAX * ONE_OTHER_CFP_SUM_MAX]); + +/* +* ȡ߽ݴ洢ַ +* ˵ +* ֵ ߽ݴ洢ַ +*/ +CfpDataStru * GetCfpData(void); + +/** +* @brief ÷ֽ㷢͸OCͨг +* @param wCfpId ֽID +* @return +* @note +*/ +void SetCfpLocalOcCtData(const UINT16 wCfpId); + +/** +* @brief ȡֽ㷢͸OCͨųַ +* @param wCfpId ֽID +* @return ͨų洢ַ +*/ +CfpCtTrainStruct * GetCfpLocalOcCtData(const UINT16 wCfpId); + +/** +* @brief ȡֽ㷢͸OCͨų +* @param wCfpId ֽID +* @return ͨų +*/ +UINT8 GetCfpLocalOcCtNum(const UINT16 wCfpId); + +/** +* @brief ȡֽOCİ +* @param wCfpId ֽID +* @param CfpEnvelopeStruct* strEnvelope +* @return CI_ ERROR ȡʧ +* CI_ SUCCESS ȡɹ +* by cgh 20240111 +*/ +UINT8 CutCfpOtherOcEData(const UINT16 wCfpId,CfpEnvelopeStruct* strEnvelope); + +/** +* @brief ȡֽRRMԴRC ID +* @param const UINT16 wCfpId ֽID +* @return 0 ȡʧܣ ԴRC ID +* Created By LQ 20240229 +*/ +UINT8 GetCfpRrmSrcRcId(const UINT16 wCfpId); + +/** +* @brief ÷ֽRRMԴRC ID +* @param wCfpId ֽID +* @param const UINT8 chSrcRcId ԴRC ID +* @return +* Created By LQ 20240229 +*/ +void SetCfpRrmSrcRcId(const UINT16 wCfpId, const UINT8 chSrcRcId); + +/** +* @brief ȡֽRRMԴTIOC״̬ +* @param wCfpId ֽID +* @return RRMԴTIOC״̬ +* by cgh 20240220 +*/ +UINT8 GetCfpRrmSrcApplyState(const UINT16 wCfpId); + +/** +* @brief ÷ֽRRMԴTIOC״̬ +* @param wCfpId ֽID +* @param const UINT8 chRrmSrcApplyState RRMԴTIOC״̬ +* @return +* by cgh 20240221 +*/ +void SetCfpRrmSrcApplyState(const UINT16 wCfpId, const UINT8 chRrmSrcApplyState); + +/** +* @brief ȡֽRRMĿTIOC״̬ +* @param wCfpId ֽID +* @return RRMĿTIOC״̬ +* by cgh 20240220 +*/ +UINT8 GetCfpRrmDstAllowState(const UINT16 wCfpId); + +/** +* @brief ÷ֽRRMĿTIOC״̬ +* @param wCfpId ֽID +* @param const UINT8 chRrmSrcApplyState RRMĿTIOC״̬ +* @return +* by cgh 20240221 +*/ +void SetCfpRrmDstAllowState(const UINT16 wCfpId, const UINT8 chRrmDstAllowState); + +/** +* @brief ȡֽRRMгID +* @param wCfpId ֽID +* @return RRMгID +* by cgh 20240221 +*/ +UINT16 GetCfpRrmTrainId(const UINT16 wCfpId); + +/** +* @brief ÷ֽRRMгID +* @param wCfpId ֽID +* @param const UINT16 wRrmTrainId RRMгID +* @return +* by cgh 20240221 +*/ +void SetCfpRrmTrainId(const UINT16 wCfpId, const UINT16 wRrmTrainId); + +/** +* @brief ȡֽRRMгһվ̨ID +* @param wCfpId ֽID +* @return RRMгһվ̨ID +* by cgh 20240221 +*/ +UINT16 GetCfpRrmTrainNextStaId(const UINT16 wCfpId); + +/** +* @brief ÷ֽRRMгһվ̨ID +* @param wCfpId ֽID +* @param const UINT16 wRrmTrainNextStaId RRMгһվ̨ID +* @return +* by cgh 20240221 +*/ +void SetCfpRrmTrainNextStaId(const UINT16 wCfpId, const UINT16 wRrmTrainNextStaId); + +/* +* TIOCͨãRRM +* ˵ UINT8 chTiocId TIOC +* ֵ +* by cgh 20240221 +*/ +void NeighborGoodRrmProc(UINT8 chTiocId); + +/* +* ݷֽIDȡֽ㴦ļID +* ˵UINT16 wCfpId ֽID +* UINT8 cAxisSecNum +* UINT16 pAxisSecIdBuf[CUTOFF_POINT_SUM_MAX] ID +* ֵ CI_ERROR 0 ȡʧ +* ID +* Created by LQ 20240227 +*/ +UINT16 GetAxisSecIdAccordCfpId(UINT16 wCfpId, UINT8 cAxisSecNum, UINT16 pAxisSecIdBuf[CUTOFF_POINT_SUM_MAX]); + +/* +* ֽRRM +* ˵const UINT16 wCutoffPointId ֽID +* ֵ +* Created By LQ 2024.02.28 +*/ +void CutoffPointRRMDataClearPro(const UINT16 wCutoffPointId); + +/** +* @brief ȡֽźŻƱ־ +* @param const UINT16 wCfpId ֽID +* @return 0x55 ־Ч +* 0xAA ־Ч +* Created By LQ 2024.09.03 +*/ +UINT8 GetCfpSignalLightUpFlag(const UINT16 wCfpId); + +/** +* @brief ÷ֽźŻƱ־ +* @param const UINT16 wCfpId ֽID +* @param const UINT8 cLightUpFlag Ʊ־ +* @return +* Created By LQ 2024.09.03 +*/ +void SetCfpSignalLightUpFlag(const UINT16 wCfpId, const UINT8 cLightUpFlag); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDefine.h b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDefine.h new file mode 100644 index 0000000..db66f9a --- /dev/null +++ b/TSCP/src/APP/ciapp/CutoffPoint/CutoffPointDefine.h @@ -0,0 +1,20 @@ +#ifndef _CUTOFPOINT_DEFINE_H_ +#define _CUTOFPOINT_DEFINE_H_ + +#include "Commontypes.h" +#include "CiSystemDefine.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define CUTOFF_POINT_SUM_MAX ((UINT8)50) /*ֽ*/ +#define MAX_CFG_LIGHTUPLINK_NUM ((UINT8)50u) /* ֽռòlink */ + +#define ONE_OTHER_CFP_SUM_MAX ((UINT8)6u) /* ͬһOC뱾OCֽ */ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/DataManage/DeviceConfigDataManage.c b/TSCP/src/APP/ciapp/DataManage/DeviceConfigDataManage.c new file mode 100644 index 0000000..f34cb34 --- /dev/null +++ b/TSCP/src/APP/ciapp/DataManage/DeviceConfigDataManage.c @@ -0,0 +1,317 @@ +/******************************************************** +* +* DeviceConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-12-18 +* ߣ +* +豸ݹCIⲿ߼ӣҪԽԽࡣ +֮ǰļеĽṹǰ豸໮ֵģ磺źź͵ԼļУļо̬ݺͶ̬ݵĶѾļ +񣬺ܶõ豸岢ôԣΪ˱Ŀ¼ṹͣǶһЩýͳһ +* +* ʹע⣺ +* ޸ļ¼ +* 2016-12-18 ½ +* +********************************************************/ + +#include "DeviceConfigDataManage.h" +#include "dquCbtcType.h" +#include "dquCIInterFace.h" + +EmapCiConfigStru gEmapCiConfigStrus[CI_SUM_MAX] = {0u};/*洢CIʹõĵӵͼ汾*/ + + +/* +* ȡָCIĵӵͼУ汾 +* ˵ + const UINT8 ciId: + UINT32 *emapVer:洢ָCIĵӵͼУ汾ŵUINT32ָ + const UINT8 commDevType:CIͨŵ豸 +* ֵ: + CI_SUCCESS:ȡɹ + CI_ERROR:ȡʧ +*/ +UINT8 GetCiEmapCheckVer(const UINT8 ciId, UINT32 *emapVer,const UINT8 commDevType) +{ + UINT8 retVal = CI_ERROR; + + if ((ciId > 0u) && (ciId < CI_SUM_MAX) &&(commDevType > 0u)) + { + if (gEmapCiConfigStrus[ciId].devId == ciId) + { + switch (commDevType) + {/*ͨ豸ͻȡCIͨ豸ĹУϢ*/ + case CI_SYSTEM_TYPE_VOBC: + case CI_SYSTEM_TYPE_ITE: + *emapVer = gEmapCiConfigStrus[ciId].dataVerCheckCIAndVOBC; /*ITEʹVOBCͬУϢ*/ + break; + case CI_SYSTEM_TYPE_ZC: + *emapVer = gEmapCiConfigStrus[ciId].dataVerCheckCIAndZC; + break; + case CI_SYSTEM_TYPE_XIANDI: + case CI_SYSTEM_TYPE_ATS: + *emapVer = gEmapCiConfigStrus[ciId].dataVerCheckCIAndATS; + break; + case CI_SYSTEM_TYPE_TMC: + *emapVer = gEmapCiConfigStrus[ciId].dataVerCheckCIAndTMC; + break; + default: + /*CI_SYSTEM_TYPE_CI*/ + break; + } + + retVal = CI_SUCCESS; + } + } + + return retVal; +} + +/********************************************* +*ܣȡ +*˵const UINT8 ciIdID +*ֵUINT8 +* 0x01 +* 0x04 +* 0x02 Գ +* 0 Ч +*********************************************/ +UINT8 GetCiType(const UINT8 ciId) +{ + UINT8 retVal = 0u; + + if ((ciId > 0u) && (ciId < CI_SUM_MAX)) + { + if (gEmapCiConfigStrus[ciId].devId == ciId) + { + retVal = gEmapCiConfigStrus[ciId].ciType; + } + } + + return retVal; +} + +/* +* жCIǷͬһ· +* ˵ +const UINT8 ciA, һCI +const UINT8 ciB, ڶCI +* ֵ: +SAME_LINE_YES,CIͬһ· +SAME_LINE_NO,CIڲͬ· +SAME_LINE_ERR,޷ȷCIǷͬһ· +*/ +UINT8 IsSameLineCI(const UINT8 ciA, const UINT8 ciB) +{ + UINT32 etcsIdA, etcsIdB; + UINT16 u16CiA, u16CiB; + UINT8 retVal = SAME_LINE_ERR; + UINT8 cbtcSysType = DQU_CBTC_FAO; + UINT8 dquDevNameA = CI_ERROR; + UINT8 dquDevNameB = CI_ERROR; + + u16CiA = (UINT16)((CI_SYSTEM_TYPE_CI * 256u) + ciA); + u16CiB = (UINT16)((CI_SYSTEM_TYPE_CI * 256u) + ciB); + + cbtcSysType = GetCbtcSysType(); + + dquDevNameA = dquDevName2HlhtId(u16CiA,0u,&etcsIdA); + + dquDevNameB = dquDevName2HlhtId(u16CiB,0u,&etcsIdB); + + if(DQU_CBTC_CPK == cbtcSysType) + { + retVal = SAME_LINE_YES; + } + else if(DQU_CBTC_FAO == cbtcSysType) + { + retVal = SAME_LINE_YES; + } + else if(DQU_CBTC_HLT == cbtcSysType) + { + /*Ҫӻͨж*/ + if ((CI_SUCCESS == dquDevNameA) && (CI_SUCCESS == dquDevNameB)) + { + /*ݻͨETCSŵĶ壬ӵ͵ߵֽΪ·*/ + if ((etcsIdA&((UINT32)0x00ff0000)) == (etcsIdB & ((UINT32)0x00ff0000))) + { + retVal = SAME_LINE_YES; + } + else + { + retVal = SAME_LINE_NO; + } + } + else + { + retVal = SAME_LINE_ERR; + } + }/* zt ɾش 2022-02-15 */ + else if (DQU_CBTC_CC == cbtcSysType) + { + retVal = SAME_LINE_YES; + } + else + { + retVal = SAME_LINE_ERR; + } + return retVal; +} +/* +* ȡָCIͨŵĸüݰ汾 +* ˵ +* const UINT8 ciId: +* const UINT16 deviceName:CIͨŵļϵͳ(+ID) +* ֵ: +* ϵͳУ汾 +* cgh-ϲECI11.0: +*/ +UINT32 GetCiTranAxisDataCheckVer(const UINT8 ciId, const UINT16 deviceName) +{ + UINT32 retDataVer = CI_ERROR; + UINT8 ii = 0u; + + if ((ciId > 0u) && (ciId < CI_SUM_MAX) && (deviceName > 0u)) + { + if (gEmapCiConfigStrus[ciId].devId == ciId) + { + for (ii = 0u; ii < CI_TRAINSMIT_AXIS_MAX_NUM; ii++) + { + if ((deviceName == gEmapCiConfigStrus[ciId].ciTransmitAxisId[ii]) && (gEmapCiConfigStrus[ciId].ciTransmitAxisId[ii] > 0u) && (gEmapCiConfigStrus[ciId].ciTransmitAxisId[ii] < 0xFFFFU)) + { + retDataVer = gEmapCiConfigStrus[ciId].ciTransmitAxisCheckData[ii]; + break; + } + } + } + } + return retDataVer; +} + +/* +* ȡָCIͨŵݰ汾 +* ˵ +* const UINT8 ciId: +* const UINT16 deviceName:CIͨŵCIϵͳ(+ID) +* ֵ: +* CIϵͳУ汾 +*/ +UINT32 GetCiTranCiDataCheckVer(const UINT8 ciId, const UINT16 deviceName) +{ + UINT32 retDataVer = CI_ERROR; + UINT8 ii = 0U; + UINT8 chBreakFlag = 0U; + + if ((ciId > 0U) && (ciId < CI_SUM_MAX) && (deviceName > 0U)) + { + if (gEmapCiConfigStrus[ciId].devId == ciId) + { + for (ii = 0U; ii < gEmapCiConfigStrus[ciId].chAdjoinCICount; ii++) + { + if (ii < CI_TRAINSMIT_CI_MAX_NUM) + { + if ((deviceName == gEmapCiConfigStrus[ciId].wAdjoinCIId[ii]) && (gEmapCiConfigStrus[ciId].wAdjoinCIId[ii] > 0U) && (gEmapCiConfigStrus[ciId].wAdjoinCIId[ii] < 0xFFFFU)) + { + retDataVer = gEmapCiConfigStrus[ciId].dwAdjoinCIShareCheckData[ii]; + chBreakFlag = 1U; + } + } + else + { + chBreakFlag = 1U; + } + if (1U == chBreakFlag) + { + break; + } + } + } + } + return retDataVer; +} + +/* +* ȡָOCͨŵݰ汾 +* ˵ +* const UINT8 ciId: +* const UINT16 deviceName:CIͨŵOCϵͳ(+ID) +* ֵ: +* OCϵͳУ汾 +*/ +UINT32 GetCiTranOcDataCheckVer(const UINT8 ciId, const UINT16 deviceName) +{ + UINT32 retDataVer = CI_ERROR; + UINT8 ii = 0U; + UINT8 chBreakFlag = 0U; + + if ((ciId > 0U) && (ciId < CI_SUM_MAX) && (deviceName > 0U)) + { + if (gEmapCiConfigStrus[ciId].devId == ciId) + { + for (ii = 0U; ii < gEmapCiConfigStrus[ciId].chAdjoinOcCount; ii++) + { + if (ii < CI_TRAINSMIT_OC_MAX_NUM) + { + if ((deviceName == gEmapCiConfigStrus[ciId].wAdjoinOcId[ii]) && (gEmapCiConfigStrus[ciId].wAdjoinOcId[ii] > 0U) && (gEmapCiConfigStrus[ciId].wAdjoinOcId[ii] < 0xFFFFU)) + { + retDataVer = gEmapCiConfigStrus[ciId].dwAdjoinOcShareCheckData[ii]; + chBreakFlag = 1U; + } + + } + else + { + chBreakFlag = 1U; + } + if (1U == chBreakFlag) + { + break; + } + } + } + } + return retDataVer; +} + +/** + * @brief ȡָĿ + * @param[in] const UINT8 chCiId ָCI ID + * @return ָĿ + * @note by cgh 20240220 + */ +UINT8 GetCiTranCiSum(const UINT8 chCiId) +{ + UINT8 chReval = 0U; + + if ((0U < chCiId) && (CI_SUM_MAX > chCiId)) + { + chReval = gEmapCiConfigStrus[chCiId].chAdjoinCICount; + } + else + { + ; /*У鲻ͨ0*/ + } + return chReval; +} + +/** + * @brief ȡָ + * @param[in] const UINT8 chCiId ָCI ID + * @return ָ + * @note by cgh 20240220 + */ +UINT16* GetCiTranCiData(const UINT8 chCiId) +{ + UINT16* chReval = NULL; + + if ((0U < chCiId) && (CI_SUM_MAX > chCiId)) + { + chReval = gEmapCiConfigStrus[chCiId].wAdjoinCIId; + } + else + { + ; /*У鲻ͨؿ*/ + } + return chReval; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/DataManage/DeviceConfigDataManage.h b/TSCP/src/APP/ciapp/DataManage/DeviceConfigDataManage.h new file mode 100644 index 0000000..a70aed8 --- /dev/null +++ b/TSCP/src/APP/ciapp/DataManage/DeviceConfigDataManage.h @@ -0,0 +1,128 @@ +/******************************************************** +* +* DeviceConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-12-18 +* ߣ +* + 豸ݹCIⲿ߼ӣҪԽԽࡣ + ֮ǰļеĽṹǰ豸໮ֵģ磺źź͵ԼļУļо̬ݺͶ̬ݵĶѾļ + 񣬺ܶõ豸岢ôԣΪ˱Ŀ¼ṹͣǶһЩýͳһ +* +* ʹע⣺ +* ޸ļ¼ +* 2016-12-18 ½ +* +********************************************************/ +#ifndef _DEVICE_CONFIG_DATA_MANAGE_H_ +#define _DEVICE_CONFIG_DATA_MANAGE_H_ + +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" + +#define SAME_LINE_YES ((UINT8)0x55) /*CIͬһ·*/ +#define SAME_LINE_NO ((UINT8)0xAA) /*CIڲͬ·*/ +#define SAME_LINE_ERR ((UINT8)0xff) /*޷ȷCIǷͬһ·*/ + +/*ӵͼУ汾ýṹ*/ +typedef struct S_EmapCheckVerConfigStruct +{ + UINT8 devId;/*tct豸IDֻռһֽ*/ + UINT8 ciType;/*ԣ1ߣ2Գߣ4*/ + UINT32 dataVerCheckCIAndVOBC;/*CI-VOBCУϢ*/ + UINT32 dataVerCheckCIAndZC;/*CI-ZCУϢ*/ + UINT32 dataVerCheckCIAndATS;/*CI-ATSУϢ*/ + UINT32 dataVerCheckCIAndTMC;/*CI-TMCУϢ*/ + UINT8 chAdjoinCICount; /*CI*/ + UINT16 wAdjoinCIId[CI_TRAINSMIT_CI_MAX_NUM]; /*CI[1-6]ID*/ + UINT32 dwAdjoinCIShareCheckData[CI_TRAINSMIT_CI_MAX_NUM]; /*CI[1-6]ĹУϢ*/ + UINT16 ciTransmitAxisId[CI_TRAINSMIT_AXIS_MAX_NUM];/*ͨŵļϵͳID*/ + UINT32 ciTransmitAxisCheckData[CI_TRAINSMIT_AXIS_MAX_NUM];/*ͨŵļϵͳУϢ*/ + UINT8 chAdjoinOcCount; /*CIͨŵoc*/ + UINT16 wAdjoinOcId[CI_TRAINSMIT_OC_MAX_NUM]; /*Oc[1-10]ID*/ + UINT32 dwAdjoinOcShareCheckData[CI_TRAINSMIT_OC_MAX_NUM]; /*OC[1-10]ĹУϢ*/ +} EmapCiConfigStru; + +extern EmapCiConfigStru gEmapCiConfigStrus[CI_SUM_MAX];/*洢CIʹõĵӵͼ汾*/ + +/* +* ȡָCIĵӵͼУ汾 +* ˵ + const UINT8 ciId: + UINT32 *emapVer:洢ָCIĵӵͼУ汾ŵUINT32ָ +* ֵ: + CI_SUCCESS:ȡɹ + CI_ERROR:ȡʧ +*/ +UINT8 GetCiEmapCheckVer(const UINT8 ciId, UINT32 *emapVer,const UINT8 commDevType); + +/* +* жCIǷͬһ· +* ˵ +const UINT8 ciA, һCI +const UINT8 ciB, ڶCI +* ֵ: + SAME_LINE_YES,CIͬһ· + SAME_LINE_NO,CIڲͬ· + SAME_LINE_ERR,޷ȷCIǷͬһ· +*/ +UINT8 IsSameLineCI(const UINT8 ciA, const UINT8 ciB); + +/********************************************* +*ܣȡ +*˵const UINT8 ciIdID +*ֵUINT8 +* 0x01 +* 0x04 +* 0x02 Գ +* 0 Ч +*********************************************/ +UINT8 GetCiType(const UINT8 ciId); +/* +* ȡָCIͨŵĸüݰ汾 +* ˵ +* const UINT8 ciId: +* const UINT16 deviceName:CIͨŵļϵͳ(+ID) +* ֵ: +* ϵͳУ汾 +* cgh-ϲECI11.0: +*/ +UINT32 GetCiTranAxisDataCheckVer(const UINT8 ciId, const UINT16 deviceName); + +/* +* ȡָCIͨŵݰ汾 +* ˵ +* const UINT8 ciId: +* const UINT16 deviceName:CIͨŵCIϵͳ(+ID) +* ֵ: +* CIϵͳУ汾 +*/ +UINT32 GetCiTranCiDataCheckVer(const UINT8 ciId, const UINT16 deviceName); + +/* +* ȡָOCͨŵݰ汾 +* ˵ +* const UINT8 ciId: +* const UINT16 deviceName:CIͨŵOCϵͳ(+ID) +* ֵ: +* OCϵͳУ汾 +*/ +UINT32 GetCiTranOcDataCheckVer(const UINT8 ciId, const UINT16 deviceName); + +/** + * @brief ȡָĿ + * @param[in] const UINT8 chCiId ָCI ID + * @return ָĿ + * @note by cgh 20240220 + */ +UINT8 GetCiTranCiSum(const UINT8 chCiId); + +/** + * @brief ȡָ + * @param[in] const UINT8 chCiId ָCI ID + * @return ָ + * @note by cgh 20240220 + */ +UINT16* GetCiTranCiData(const UINT8 chCiId); + +#endif diff --git a/TSCP/src/APP/ciapp/DataManage/DeviceDataManage.c b/TSCP/src/APP/ciapp/DataManage/DeviceDataManage.c new file mode 100644 index 0000000..be10a07 --- /dev/null +++ b/TSCP/src/APP/ciapp/DataManage/DeviceDataManage.c @@ -0,0 +1,11117 @@ +/******************************************************** +* +* DeviceDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-09-21 +* ߣ +* 豸ݹ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + +#include "DeviceDataManage.h" +#include "../AutoRoute/AutoRouteDefine.h" +#include "../ParsePack/CiInterfaceDefine.h" +#include "LogicSectionDataManage.h" +#include "../LogicManage/InterlockLogicManage.h" +#include "LogicSectionConfigDataManage.h" +#include "dquCIInterFace.h" +#include "LogicalRouteDataManage.h" +#include "../LogicProcess/LogicalRouteLogicCheck.h" + +UINT8 AllSignalBrightFlag = CI_ALL_SIGNAL_BRIGHT_NO; /*ȫվƱ־*/ + +UINT8 AllSwitchYLockFlag = CI_ALL_SWITCH_YLOCK_NO; /*ȫվ־*/ + +UINT8 StartFLockFlag = CI_START_FLOCK_YES; /*ȫվ־*/ + +UINT8 StartLockFlag = CI_START_LOCK_YES; /*ϵձ־*/ + +UINT8 LSXianSuCancelBtnIsValidFlag = CI_LINSHIXIANSU_CANCEL_BUTTON_VALID; /*ʱ˹־*/ + +UINT8 LabourCancelLinShiXianState = LINSHIXIANSU_COMM_BAD_STATE; /*˹ȡʱǨ״̬*/ + +UINT8 StopCheckState = ROUTE_STOPCHECK_SET_NO; /*ֹͣδ*/ + +UINT16 JkjRelayId = 0u; /*Ӧ̵̼ID*/ + +UINT8 PlatOverFlag = CI_OVER_NO; /*ƽ̨崻־*/ + +UINT8 ciMode = CI_MODE_CI_LOCAL; /* ģʽ */ + +UINT8 g_AllTsrFlag = CI_ALL_TSR_UNVALID; /* ʱٱ־ */ + +UINT8 g_AllSnowModel = CI_ALL_SNOW_UNVALID; /*ȫѩģʽ*/ + +UINT8 g_IteLineCutState = CI_ITE_LINE_CUT_DEFAULT; /*ITEȫг״̬0x55гITE0xAAʹITE0xFFĬֵ*/ + +UINT8 g_AllLineTsrState = CI_ALL_LINE_TSR_UNVALID; /*ȫʱ״̬*/ + +UINT8 g_AllLineTsrSpeed = 0u; /*ȫʱٶ*/ + +UINT8 JkjRelayValid = JKJ_REYLAY_INVALID; /*JKJӦ̵̼Ч*/ + +UINT32 JkjRelayValidCycNum = 0u; /*JKJӦ̵̼Ч*/ + +UINT8 ciTrainTestStatus = CI_TRAIN_TEST_OFF; /*Գ״̬Գ*/ + +UINT8 psdPangluFlag = PSD_BUTTON_PANGLU_STATE_INVALID; /*վ̨ȫŰť·״̬*/ + +UINT8 generalResetFlag = CI_PHYSEC_GENERAL_RESET_NO; /*ܸλ־Ч*/ + +UINT32 ZFWValidCycNum = 0u; /*ZFWܸλ̵Ч*/ + +UINT32 ZFWCmdStartCycNum = 0u; /*ZFWյ*/ + +UINT8 g_cTsrSureFlag = CI_TSR_SURE_NO; /* ʱȷϱ־ */ + +UINT8 comm_Train_Test_SQAJ_SCX_State = COMM_TRAIN_TEST_DEV_STATE_INVALID; /*Գ복βͨŽӿʱԳSQAJ״̬*/ +UINT8 comm_Train_Test_YSKJ_SCX_State = COMM_TRAIN_TEST_DEV_STATE_INVALID; /*Գ복βͨŽӿʱԳYSKJ״̬*/ +UINT8 comm_Train_Test_SQJ_CLD_State = COMM_TRAIN_TEST_DEV_STATE_INVALID; /*Գ복βͨŽӿʱSQJ״̬*/ +UINT8 comm_Train_Test_TYSJ_CLD_State = COMM_TRAIN_TEST_DEV_STATE_INVALID; /*Գ복βͨŽӿʱTYSJ״̬*/ + +UINT8 AutoTriggerFlag = AUTO_TRIGGER_SET_NO; /*Զ־ʼΪδ*/ + +UINT8 CiCiRelayInterfaceConfirmFlag = CICI_RELAY_INTERFACE_CONFIRM_NO;/*̵ӿȷϱ־*/ +UINT8 ZFWJRelayHunXianFlag = ZFWJ_HUN_XIAN_NO; /*ܸλ߱־*/ +UINT8 SwitchBlockLinkState = RECOVER_SWITCH_BLOCK_LINK; /*ʼֵΪָ״̬ʱЧ*/ + +CtrlPowerStruct ctrlpowerFlag[VIRTUAL_CI_MAX] = { 0u }; + +UINT8 LocalAreaSnowNum = 0U; /*ѩվ̨*/ +UINT32 szLocalAreaSnowId[LOCAL_AREA_SNOW_SUM_MAX] = { 0U }; /*ѩվ̨ID*/ + +LineCommTrainStruct gStrLineCommTrain = { 0U }; /*ȫͨųṹ*/ + +UINT32 gFlyProtectOverCyc = 0U; /*ɳ崻ʼ*/ + +UINT8 g_LocalSnowModel = CI_LOCAL_SNOW_UNVALID; /*ѩģʽ*/ + +/******************************־ݹ****************************/ + + +/******************************ʽʱݼ****************************/ +/* +* ·߼Ƿʱ +* ˵ const UINT16 routeId, ·Id +* ֵ + LOGSEC_LSXS_SET_STATE_NO 0x55 δʱ٣ڵ1ã + LOGSEC_LSXS_SET_STATE_YES 0xAA ʱ٣ȫδã +*/ +static UINT8 RouteIncludeLogSecLSXSSetCheck(const UINT16 routeId); + + +/* +* ·Ƿʱ +* ˵ const UINT16 routeId, ·Id +* ֵ + LOGSEC_LSXS_SET_STATE_NO 0x55 δʱ٣ڵ1ã + LOGSEC_LSXS_SET_STATE_YES 0xAA ʱ٣ȫδã +*/ +static UINT8 RouteOvlpLogSecLSXianSuSetCheck(const UINT16 routeId); + +/* +* ȡϵ־ +* ˵ void +* ֵ CI_START_FLOCK_YES + CI_START_FLOCK_NO + CI_START_FLOCK_ERROR +*/ +UINT8 GetStartFLockFlag(void) +{ + return StartFLockFlag; +} + +/* +* ϵ־ +* ˵ void +* ֵ CI_START_FLOCK_YES + CI_START_FLOCK_NO + CI_START_FLOCK_ERROR +*/ +void SetStartFLockFlag(UINT8 setFlag) +{ + if (CI_START_FLOCK_YES == setFlag) + { + StartFLockFlag = setFlag; + } + else if (CI_START_FLOCK_NO == setFlag) + { + StartFLockFlag = setFlag; + } + else if (CI_START_FLOCK_ERROR == setFlag) + { + StartFLockFlag = setFlag; + } + else + { + /**/ + } +} + +/* +* ȡϵ־ +* ˵ void +* ֵ CI_START_LOCK_NO + CI_START_LOCK_YES + CI_START_LOCK_ERROR +*/ +UINT8 GetStartLockFlag(void) +{ + return StartLockFlag; +} + +/* +* ϵ־ +* ˵ void +* ֵ CI_START_LOCK_NO + CI_START_LOCK_YES + CI_START_LOCK_ERROR +*/ +void SetStartLockFlag(UINT8 setFlag) +{ + if (CI_START_LOCK_YES == setFlag) + { + StartLockFlag = setFlag; + } + else if (CI_START_LOCK_NO == setFlag) + { + StartLockFlag = setFlag; + } + else if (CI_START_LOCK_ERROR == setFlag) + { + StartLockFlag = setFlag; + } + else + { + /**/ + } +} + + + +/* +* ȡ˹ȡʱٵ״̬ +* ˵ void +* ֵ LINSHIXIANSU_COMM_GOOD_STATE + LINSHIXIANSU_COMM_BAD_NO_LABOURCANCLE_STATE + LINSHIXIANSU_COMM_BAD_YES_LABOURCANCLE_STATE +*/ +UINT8 GetLabourCancelLinShiXianState(void) +{ + return LabourCancelLinShiXianState; +} + + +/* + ˹ȡʱ״̬Ǩƴ + ˵setFlag ״̬ + ֵ +*/ +void LabourCancelLSXianStaMoveProc(UINT8 setFlag) +{ + UINT8 linShiXianState = 0u; + UINT8 wholelinShiXianState = 0u; + linShiXianState = GetLabourCancelLinShiXianState(); + wholelinShiXianState = GetWholeLineLinShiXianSuFlag(); + switch(setFlag) + { + case LINSHIXIANSU_COMM_GOOD_STATE:/*ZCͨ״̬*/ + if((LINSHIXIANSU_COMM_BAD_STATE == linShiXianState) || + (LINSHIXIANSU_LABOURCANCLE_YES_STATE == linShiXianState)) + {/*ǰһ״̬Ϊ ͨŹδ˹ȡ || ͨŹҽ˹ȡ ״̬Ǩ*/ + LabourCancelLinShiXianState = setFlag; + } + break; + case LINSHIXIANSU_COMM_BAD_STATE:/*ZCͨŹ״̬*/ + if((LINSHIXIANSU_COMM_GOOD_STATE == linShiXianState) && (WHOLE_LINE_LINSHIXIANSUSET_YES == wholelinShiXianState)) + {/*ǰһ״̬Ϊͨ״̬ʱٱ־Ϊ ״̬Ǩ*/ + LabourCancelLinShiXianState = setFlag; + } + break; + case LINSHIXIANSU_LABOURCANCLE_YES_STATE:/*Ѿ˹ȡʱ*/ + if(LINSHIXIANSU_COMM_BAD_STATE == linShiXianState) + {/*ǰһ״̬ΪͨŹ״̬ ״̬Ǩ*/ + LabourCancelLinShiXianState = setFlag; + } + break; + default: + /*ɴ֧*/ + break; + + + } +} +/* + ˹ȡʱ״̬Ǩƴ + ˵setFlag ״̬,UINT8 virCIid ID + ֵ +*/ +void LaborCancelLSXSXStaMoveProc_Vir(UINT8 setFlag,UINT8 virCIid) +{ + UINT8 linShiXianState = 0u; + UINT8 wholelinShiXianState = 0u; + linShiXianState = GetVirCILabourCancelLSXianSta(virCIid); + wholelinShiXianState = GetWholeLineLinShiXianSuFlag(); + switch(setFlag) + { + case LINSHIXIANSU_COMM_GOOD_STATE:/*ZCͨ״̬*/ + if((LINSHIXIANSU_COMM_BAD_STATE == linShiXianState) || + (LINSHIXIANSU_LABOURCANCLE_YES_STATE == linShiXianState)) + {/*ǰһ״̬Ϊ ͨŹδ˹ȡ || ͨŹҽ˹ȡ ״̬Ǩ*/ + SetVirCILabourCancelLSXianSta(virCIid,setFlag); + } + break; + case LINSHIXIANSU_COMM_BAD_STATE:/*ZCͨŹ״̬*/ + if((LINSHIXIANSU_COMM_GOOD_STATE == linShiXianState) && (WHOLE_LINE_LINSHIXIANSUSET_YES == wholelinShiXianState)) + {/*ǰһ״̬Ϊͨ״̬ʱٱ־Ϊ ״̬Ǩ*/ + SetVirCILabourCancelLSXianSta(virCIid,setFlag); + } + break; + case LINSHIXIANSU_LABOURCANCLE_YES_STATE:/*Ѿ˹ȡʱ*/ + if(LINSHIXIANSU_COMM_BAD_STATE == linShiXianState) + {/*ǰһ״̬ΪͨŹ״̬ ״̬Ǩ*/ + SetVirCILabourCancelLSXianSta(virCIid,setFlag); + } + break; + default: + /*ɴ֧*/ + break; + + + } +} + + + +/* +* ȡȫվ־ +* ˵ void +* ֵ CI_ALL_SWITCH_YLOCK_NO + CI_ALL_SWITCH_YLOCK_YES +*/ +UINT8 GetAllSwitchYLockFlag(void) +{ + return AllSwitchYLockFlag; +} + + +/* +* ȫվ־ +* ˵ void +* ֵ CI_ALL_SWITCH_YLOCK_NO + CI_ALL_SWITCH_YLOCK_YES +*/ +void SetAllSwitchYLockFlag(UINT8 setFlag) +{ + UINT16 switchCurSum = 0u; /*Ŀ*/ + UINT16 signalCurSum = 0u; /*źŻĿ*/ + UINT8 localCiId = 0u; /*ID*/ + + UINT16 switchId = 0u; + UINT16 signalId = 0u; + UINT8 belongCiId = 0u; + + UINT16 ii = 0u; /*ѭ*/ + + UINT8 checkRetVal = CI_FALSE; /*豸Ƿ·豸ֵ*/ + + switchCurSum = GetSwitchCurSum(); /*ȡ*/ + signalCurSum = GetSignalCurSum(); /*ȡźŻ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if (setFlag == CI_ALL_SWITCH_YLOCK_NO) + { + /**/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = 0u; /*ID*/ + belongCiId = 0u; /*·ID*/ + + switchId = GetSwitchId(ii); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡ·ID*/ + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + continue; + } + + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId); + + if(CI_TRUE == checkRetVal) + { + /*õδ*/ + SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_NO); + } + } + + /*źŻ*/ + for (ii = 0u; ii < signalCurSum; ii++) + { + signalId = 0u; /*ID*/ + belongCiId = 0u; /*·ID*/ + + signalId = GetSignalId(ii); /*ȡźŻID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡ·ID*/ + + if ((0u == signalId) || (signalId > SIGNAL_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + continue; + } + + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, signalId); + + if(CI_TRUE == checkRetVal) + { + /*źŻ״̬Ϊر*/ + SetSignalYLockOpenState(signalId, SIGNAL_CLOSE); + } + } + + /*ȡ־*/ + AllSwitchYLockFlag = setFlag; + } + else if (setFlag == CI_ALL_SWITCH_YLOCK_YES) + { + /**/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = 0u; /*ID*/ + belongCiId = 0u; /*·ID*/ + + switchId = GetSwitchId(ii); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡ·ID*/ + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + continue; + } + + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId); + + if(CI_TRUE == checkRetVal) + { + /*õ*/ + SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_YES); + } + } + + /*־*/ + AllSwitchYLockFlag = setFlag; + } + else + { + /**/ + } +} + +/* +* ָȫվ־ +* ˵ void +* ֵ CI_ALL_SWITCH_YLOCK_NO + CI_ALL_SWITCH_YLOCK_YES +*/ +void AllSwitchYLock_UseVirCI(UINT8 virCIid,UINT8 setFlag) +{ + UINT16 switchCurSum = 0u; /*Ŀ*/ + UINT16 signalCurSum = 0u; /*źŻĿ*/ + UINT8 localCiId = 0u; /*ID*/ + + UINT16 switchId = 0u; + UINT16 signalId = 0u; + UINT8 belongCiId = 0u; + UINT8 flag = 0u; + UINT8 belongVirCI = 0u; + + UINT16 ii = 0u; /*ѭ*/ + + UINT8 checkRetVal = CI_FALSE; /*豸Ƿ·豸ֵ*/ + + switchCurSum = GetSwitchCurSum(); /*ȡ*/ + signalCurSum = GetSignalCurSum(); /*ȡźŻ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if (CI_ALL_SWITCH_YLOCK_NO == setFlag) + { + /**/ + for (ii = 0u; ii < switchCurSum; ii++) + { + flag = 0u; + switchId = 0u; /*ID*/ + belongCiId = 0u; /*·ID*/ + + switchId = GetSwitchId(ii); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡ·ID*/ + belongVirCI = GetSwitchBelongVirCiId(switchId); + if ((0u == switchId) || (SWITCH_SUM_MAX <= switchId)) + { + flag = 1u; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + flag = 1u; + } + + if ((belongVirCI != virCIid) || (0u == virCIid)) + { + flag = 1u; + } + + if(0u == flag) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId); + + if(CI_TRUE == checkRetVal) + { + /*õδ*/ + SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_NO); + } + } + + } + + /*źŻ*/ + for (ii = 0u; ii < signalCurSum; ii++) + { + flag = 0u; + signalId = 0u; /*ID*/ + belongCiId = 0u; /*·ID*/ + + signalId = GetSignalId(ii); /*ȡźŻID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡ·ID*/ + belongVirCI = GetSignalBelongVirCiId(signalId); + if ((0u == signalId) || (signalId > SIGNAL_SUM_MAX)) + { + flag = 1u; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + flag = 1u; + } + + if ((belongVirCI != virCIid) || (0u == virCIid)) + { + flag = 1u; + } + + if(0u == flag) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, signalId); + + if(CI_TRUE == checkRetVal) + { + /*źŻ״̬Ϊر*/ + SetSignalYLockOpenState(signalId, SIGNAL_CLOSE); + } + } + + } + + /*ȡ־*/ + SetVirCIAllSwitchYLockState(virCIid,setFlag); + } + else if (setFlag == CI_ALL_SWITCH_YLOCK_YES) + { + /**/ + for (ii = 0u; ii < switchCurSum; ii++) + { + flag = 0u; + switchId = 0u; /*ID*/ + belongCiId = 0u; /*·ID*/ + + switchId = GetSwitchId(ii); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡ·ID*/ + belongVirCI = GetSwitchBelongVirCiId(switchId); + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + flag =1u; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + flag =1u; + } + + if ((belongVirCI != virCIid) || (0u == virCIid)) + { + flag = 1u; + } + + if(0u == flag) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, switchId); + + if(CI_TRUE == checkRetVal) + { + /*õ*/ + SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_YES); + } + } + } + + /*־*/ + SetVirCIAllSwitchYLockState(virCIid,setFlag); + } + else + { + /**/ + } +} +/* +* ȡȫվƱ־ +* ˵ void +* ֵ CI_ALL_SIGNAL_BRIGHT_NO + CI_ALL_SIGNAL_BRIGHT_YES +*/ +UINT8 GetAllSignalBrightFlag(void) +{ + return AllSignalBrightFlag; +} + + +/* +* ȫվƱ־ +* ˵ void +* ֵ CI_ALL_SIGNAL_BRIGHT_NO + CI_ALL_SIGNAL_BRIGHT_YES +*/ +void SetAllSignalBrightFlag(UINT8 setFlag) +{ + UINT16 j = 0u; + UINT16 signalNum = GetTotalSignalCurNum(); /*źŻĿ*/ + UINT16 signalId = 0u; + UINT8 belongCIid = 0u; + UINT8 localCIid = GetSystemParaLocalCiId(); + + if (setFlag == CI_ALL_SIGNAL_BRIGHT_YES) + { + AllSignalBrightFlag = setFlag; + } + else if (setFlag == CI_ALL_SIGNAL_BRIGHT_NO) + { + AllSignalBrightFlag = setFlag; + } + else + { + /**/ + } + /*ȫվά޵ʱźŻά޵״̬ͬʱ*/ + for(j =0u;j 0 ID +*/ +UINT16 GetRouteFirstNormalLockSection(UINT16 RouteId) +{ +/* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 sectionId = 0u; + UINT16 belongRouteId = 0u; + UINT8 sectionLockState = 0u; + UINT16 reVal = 0u; /*⴦continue*/ + UINT16 flag = 0u;/*ҳɹ־*/ +/*·*/ + UINT8 const routeSecNum = GetRoutePhysicalSectionSum(RouteId); + RoutePhysicalSectionStruct* const pRouteSecBuf = GetRouteSectionData(RouteId); + +/*ڵǰ·*/ + if (0u == routeSecNum) + { + /*޼*/ + reVal = 0u; + } + else + { + /*ʼ*/ + for (i = 0u; i < routeSecNum; i++) + { + sectionId = pRouteSecBuf[i].PhysicalSectionId; + belongRouteId = GetPhySecRLockBelongRouteId(sectionId); + if (belongRouteId == RouteId) + { + /*Ϊǰ·*/ + sectionLockState = GetPhySecLockState(sectionId); + if (PHYSICAL_SECTION_LOCK_NORMAL == sectionLockState) + { + /*Ϊա*/ + reVal = sectionId; + flag = 1u; + } + else if (PHYSICAL_SECTION_LOCK_DELAY == sectionLockState) + { + /* ʱա */ + + } + else + { + /* աʧ */ + reVal = 0u; + flag = 1u; + } + if (1u == flag) + { + break; + } + else + { + /*޲*/ + } + } + } + } + + /*δҵ*/ + return reVal; +} + + +/* ҵ·ڵһʱ */ +/* +* ҵ·ڵһʱ +* ˵ UINT16 routeId, + +* ֵ UINT16 ID +* = 0 Ч +* > 0 ID +*/ +UINT16 GetRouteFirstDelayLockSection(UINT16 RouteId) +{ + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 sectionId = 0u; + UINT16 belongRouteId = 0u; + UINT8 sectionLockState = 0u; + UINT16 reVal = 0u; + /*·*/ + UINT8 const routeSecNum = GetRoutePhysicalSectionSum(RouteId); + RoutePhysicalSectionStruct* const pRouteSecBuf = GetRouteSectionData(RouteId); + + /*ڵǰ·*/ + if (0u == routeSecNum) + { + /*޼*/ + reVal = 0u; + } + else + { + /*ʼ*/ + for (i = 0u; i < routeSecNum; i++) + { + sectionId = pRouteSecBuf[i].PhysicalSectionId; + belongRouteId = GetPhySecRLockBelongRouteId(sectionId); + if (belongRouteId == RouteId) + { + /*Ϊǰ·*/ + sectionLockState = GetPhySecLockState(sectionId); + if (PHYSICAL_SECTION_LOCK_DELAY == sectionLockState) + { + /*Ϊʱա*/ + reVal = sectionId; + break; + } + else + { + /* ״̬ */ + } + } + else + { + /*ڵǰ·*/ + } + } + } + + /*δҵ*/ + return reVal; +} + + +/* +* ·ѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckRoutePhySecHaveUnLock(const UINT16 routeId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *RouteSecStru = NULL; /**/ + UINT16 phySecId = 0u; /*ID*/ + UINT8 ii= 0u; + UINT8 reVal = CI_SUCCESS; + UINT16 rLockId = 0u; + UINT8 lockState = 0u; + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + RouteSecStru = GetRouteSectionData(routeId); /*·*/ + + if (0u == sectionSum) + { + reVal = CI_ERROR; + } + else + { + for(ii = 0u; ii < sectionSum; ii++) + { + phySecId = RouteSecStru[ii].PhysicalSectionId; + rLockId = GetPhySecRLockBelongRouteId(phySecId); + lockState = GetPhySecLockState(phySecId); + if ((PHYSICAL_SECTION_LOCK_NO == lockState) || + ((PHYSICAL_SECTION_LOCK_NO != lockState) && (routeId != rLockId))) + { /*δջDZ·*/ + } + else + { + reVal = CI_ERROR; + break; + } + } + } + + return reVal; +} + + +/* +* ·ηЧ +* ˵ +* UINT16 routeId, · +* ֵ CI_ERROR ηЧ +* CI_SUCCESS ηЧ +*/ +UINT8 RouteSecFlockVainCheck(const UINT16 routeId) +{ + /*·*/ + UINT8 const routeSecSum = GetRoutePhysicalSectionSum(routeId); + RoutePhysicalSectionStruct* const pRouteSecDataBuf = GetRouteSectionData(routeId); + UINT8 reVal = CI_SUCCESS; + UINT16 ii = 0u; + UINT8 fLockState= 0u; + + for (ii = 0u; ii < routeSecSum; ii++) + { + fLockState = GetPhySecFLockState(pRouteSecDataBuf[ii].PhysicalSectionId); + if (PHYSICAL_SECTION_FLOCK_YES == fLockState) + { + /*η*/ + + /* ¼ */ + SetErrorData(EFUNC_CHECK_ROUTE_SEC_FLOCK,CI_DEVICE_TYPE_PHYSEC, + pRouteSecDataBuf[ii].PhysicalSectionId, + ETYPE_PS_FLOCK_STATE, + PHYSICAL_SECTION_FLOCK_YES, + ESEND_LEVEL_ATS); + + reVal = CI_ERROR; + break; + } + } + + return reVal; +} + +/* +* ·ηЧ +* ˵ +* UINT16 routeId, · +* ֵ CI_ERROR ηЧ +* CI_SUCCESS ηЧ +*/ +UINT8 RouteOverlapSecFlockVainCheck(const UINT16 routeId) +{ + /**/ + UINT16 const overlapLockId = GetRouteOverlapLockedId(routeId); + UINT8 const overlapSecSum = GetOverlapPhySecSum(overlapLockId); + UINT16* const pOverlapSecBuf = GetOverlapPhySecIdBuf(overlapLockId); + UINT8 reVal = CI_SUCCESS; + UINT16 ii = 0u; + UINT8 fLockState= 0u; + UINT8 routeLevel = 0u; + routeLevel = GetRouteLevel(routeId); + + if ((overlapLockId > 0u) && (ROUTE_LEVEL_BLOC == routeLevel)) + { + /*бյĵʽ·*/ + for (ii = 0u; ii < overlapSecSum; ii++) + { + fLockState = GetPhySecFLockState(pOverlapSecBuf[ii]); + if (PHYSICAL_SECTION_FLOCK_YES == fLockState) + { + /*η*/ + + /* ¼ */ + SetErrorData(EFUNC_CHECK_OLAP_SEC_FLOCK,CI_DEVICE_TYPE_PHYSEC, + pOverlapSecBuf[ii], + ETYPE_PS_FLOCK_STATE, + PHYSICAL_SECTION_FLOCK_YES, + ESEND_LEVEL_ATS); + + reVal = CI_ERROR; + break; + } + } + } + return reVal; +} + +/* +* ·гӽ +* ˵ const UINT16 routeId, ·ID +* ֵ SUCCESSӽ +* ERROR ӽ +* by cgh 20231014 ޸ĽӽжԪΪ߼ +*/ +UINT8 RouteHaveTrainNear(const UINT16 routeId) +{ + UINT8 routeLevel = 0U; /*·ල*/ + UINT8 secOccupyState = 0U; /*ռ״̬*/ + UINT16 switchId = 0U; /*ID*/ + UINT8 switchPos = 0U; /*λ*/ + UINT8 ii = 0U; /*±*/ + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 isSwitchPosRight = 1U; /*λǷȷ Ĭ1Ϊȷ0Ϊ*/ + UINT8 isSecOccupied = 1U; /*Ƿռñ־ Ĭ1Ϊδռã0Ϊռ*/ + UINT8 switchCurPosition = 0U; + UINT8 nearCbtcSecConditionSum = 0U; /*CBTCӽ*/ + RouteNearLogicSectionStruct* nearLogicSecStru = NULL; /*ӽ߼νṹ*/ + UINT8 nearBlocSecConditionSum = 0u; /*ʽӽ*/ + RouteNearPhySectionStruct* nearPhySecStru=NULL; /*ӽνṹ*/ + UINT8 chReval = CI_SUCCESS; + UINT8 chLogicSecSwitchSum = 0U;/*߼εĿ*/ + LogsecSwitchStruct* pLogicSecSwitchIdData = NULL;/*߼εID*/ + + if ((0U == routeId) || (ROUTE_SUM_MAX <=routeId)) + { + chReval = CI_SUCCESS; + } + else + { + chReval = CI_ERROR; + routeLevel = GetRouteLevel(routeId); /*ȡ·ල*/ + + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + nearCbtcSecConditionSum = GetRouteCbtcNearSecConditionSum(routeId); /*ȡCBTC·ӽ߼Ŀ*/ + nearLogicSecStru = GetRouteCbtcNearLogSectionStru(routeId); /*ȡCBTC·ӽ߼νṹ*/ + + if ((0U < nearCbtcSecConditionSum) && (ROUTE_NEARSEC_CONDITION_SUM_MAX >= nearCbtcSecConditionSum)) + {/*жӽ*/ + + for (ii = 0U; ii < nearCbtcSecConditionSum; ii++) + {/**/ + + isSecOccupied = 1U;/*ռñ־Ϊδռ*/ + isSwitchPosRight = 1U;/*õλñ־Ϊȷ*/ + + for (jj = 0U; jj < nearLogicSecStru[ii].NearLogicSecSum; jj++) + { + secOccupyState = GetLogSecCurOccupyState(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]);/*ȡ߼εǰռ״̬*/ + + if (SECTION_OCCUPY_NO != secOccupyState) + {/*ηǿУռúͽӽ*/ + isSecOccupied = 0U;/*øӽռ*/ + } + else + { + ; /*ü*/ + } + + chLogicSecSwitchSum = GetLogicSecSwitchSum(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]); + pLogicSecSwitchIdData = GetLogicSecSwitchIdStru(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]); + + for (kk = 0U; kk < chLogicSecSwitchSum; kk++) + { + switchId = pLogicSecSwitchIdData[kk].SwitchId; + switchPos = pLogicSecSwitchIdData[kk].SwitchPosition; + switchCurPosition = GetSwitchCurPosition(switchId); + + if (SWITCH_POSITION_DINGWEI == switchPos) + { + /*涨λ*/ + if (SWITCH_POSITION_FANWEI == switchCurPosition) + {/*λڷλ*/ + + isSwitchPosRight = 0U;/*õλô*/ + } + else + {/*λòڷλ*/ + + ; /*λȷ ñ־*/ + } + + } + else + { + if (SWITCH_POSITION_DINGWEI == switchCurPosition) + {/*λڶλ*/ + isSwitchPosRight = 0U;/*õλô*/ + } + else + {/*λòڶλ*/ + + ; /*λȷ ñ־*/ + } + } + + } + if ((0U == isSecOccupied) || (0U == isSwitchPosRight)) + {/*ռλô󣬾жϸѭ*/ + break; + } + }/*ӽ*/ + + /*жϸӽǷӽ*/ + if ((0U == isSecOccupied) && (0U != isSwitchPosRight)) + {/*ռ ռ֮ǰĵλþȷ*/ + + chReval = CI_SUCCESS;/*ؽӽ*/ + break; + } + }/*нӽ*/ + } + else + { + /*Ŀ*/ + chReval = CI_SUCCESS;/*ؽӽ*/ + } + }/*CBTCģʽ֧*/ + else + {/*Blocģʽ*/ + + nearBlocSecConditionSum = GetRouteBlocNearSecConditionSum(routeId); /*ȡBloc·ӽĿ*/ + nearPhySecStru = GetRouteBlocNearPhySectionStru(routeId); /*ȡBloc·ӽνṹ*/ + + if ((0U < nearBlocSecConditionSum) && (ROUTE_NEARSEC_CONDITION_SUM_MAX >= nearBlocSecConditionSum)) + {/*жӽ*/ + + for (ii = 0U; ii < nearBlocSecConditionSum; ii++) + {/**/ + + isSecOccupied = 1U;/*ռñ־Ϊδռ*/ + isSwitchPosRight = 1U;/*õλñ־Ϊȷ*/ + + for (jj = 0U; jj < nearPhySecStru[ii].BlocNearLogSecSum; jj++) + { + secOccupyState = GetLogSecCurOccupyState(nearPhySecStru[ii].BlocNearLogSecIdBuf[jj]);/*ȡ߼εǰռ״̬*/ + + if (SECTION_OCCUPY_NO != secOccupyState) + {/*ηǿУռúͽӽ*/ + + isSecOccupied = 0U;/*øӽռ*/ + } + else + { + ; /*ü*/ + } + + chLogicSecSwitchSum = GetLogicSecSwitchSum(nearPhySecStru[ii].BlocNearLogSecIdBuf[jj]); + pLogicSecSwitchIdData = GetLogicSecSwitchIdStru(nearPhySecStru[ii].BlocNearLogSecIdBuf[jj]); + + for (kk = 0U; kk < chLogicSecSwitchSum; kk++) + { + switchId = pLogicSecSwitchIdData[kk].SwitchId; + switchPos = pLogicSecSwitchIdData[kk].SwitchPosition; + switchCurPosition = GetSwitchCurPosition(switchId); + + if (SWITCH_POSITION_DINGWEI == switchPos) + { + /*涨λ*/ + if (SWITCH_POSITION_FANWEI == switchCurPosition) + {/*λڷλ*/ + + isSwitchPosRight = 0U;/*õλô*/ + } + else + {/*λòڷλ*/ + + ; /*λȷ ñ־*/ + } + + } + else + { + if (SWITCH_POSITION_DINGWEI == switchCurPosition) + {/*λڶλ*/ + isSwitchPosRight = 0U;/*õλô*/ + } + else + {/*λòڶλ*/ + + ; /*λȷ ñ־*/ + } + } + + } + + if ((0U == isSecOccupied) || (0U == isSwitchPosRight)) + {/*ռλô󣬾жϸѭ*/ + break; + } + + }/*ӽ*/ + + /*жϸӽǷӽ*/ + if ((0U == isSecOccupied) && (0U != isSwitchPosRight)) + {/*ռ ռ֮ǰĵλþȷ*/ + + chReval = CI_SUCCESS;/*ؽӽ*/ + break; + } + + }/*нӽ*/ + } + else + { + /*Ŀ*/ + chReval = CI_SUCCESS;/*ؽӽ*/ + } + }/*Blocģʽ֧*/ + } + return chReval; +} + + +/* ҵ·Ч۷źŻ */ +/* +* ҵ·Ч۷źŻ +* ˵ UINT16 const routeId ·ID +* ֵ UINT16 const setionId ID +* = 0 Ч +* > 0 źŻID +*/ +UINT16 GetValidReturnSinalId(UINT16 const routeId,UINT16 const setionId) +{ +/* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 signalId = 0u; + UINT16 signalOutSectionId = 0u; + +/*·*/ + UINT8 const returnSignalSum = GetRouteReturnSignalSum(routeId); + UINT16* const pReturnSignalIdBuf = GetRouteReturnSignalIdBuf(routeId); + UINT16 reVal = 0u; + + if (0u == returnSignalSum) + { + /*޼*/ + reVal = 0u; + } + else + { + /*ʼ*/ + for (i = 0u; i < returnSignalSum; i++) + { + signalId = pReturnSignalIdBuf[i]; + signalOutSectionId = GetSignalOutFirstPhySecId(signalId); + if ((0u < signalOutSectionId) && (signalOutSectionId == setionId)) + { + /*۷źŻ۷ƥ*/ + reVal = signalId; + break; + } + else + { + /*޲*/ + } + } + } + + return reVal; +} + +/* +: ·ڱص +: const UINT16 routeId ·ID +: const UINT8 DrivFlag ־ +ֵ: +edit cgh 20241203 +*/ +void RouteDrvInnerSwitch(const UINT16 routeId, const UINT8 DrivFlag) +{ + UINT8 switchSum = 0u; /*Ŀ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 switchExpPos = 0u; /*λ*/ + RouteSwitchStruct* routeSwitchStru = NULL; /**/ + UINT8 ii = 0u; /*ѭ*/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + UINT8 funRtn = CI_ERROR; + RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL; /**/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chSwitchBelCiId = 0U;/**/ + + switchSum = GetRouteSwitchSum(routeId); /*ȡ·Ŀ*/ + routeSwitchStru = GetRouteSwitchData(routeId); /*ȡ·ڵ*/ + routeProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId);/*ȡĿ*/ + pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId);/*ȡ*/ + + if(SWITCH_NEED_DRIV_TRUE == DrivFlag) + {/*Ҫ·ڵ*/ + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + for(ii = 0u; ii < switchSum; ii++) + { + switchId = routeSwitchStru[ii].SwitchId; + chSwitchBelCiId = GetSwitchBelongCiId(switchId); + if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId)) + { + switchExpPos = routeSwitchStru[ii].SwitchPosition; + (void)SwitchDriveProcess(switchId, switchExpPos); /*ý·ڵ״̬Ϊ*/ + } + else + { + ; + } + + } + + for(ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = pRouteProtectSwitchStru[ii].ProtectSwitchId; + chSwitchBelCiId = GetSwitchBelongCiId(switchId); + if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId)) + { + switchExpPos = pRouteProtectSwitchStru[ii].ProtectPosition; + (void)SwitchDriveProcess(switchId, switchExpPos); /*ý·״̬Ϊ*/ + } + else + { + ; + } + } + } +} + +/* +: · +: const UINT16 routeId ·ID + UINT8 DrivFlag ־ +: +ֵ: +*/ +void RouteDrvAssocSwitch(const UINT16 routeId, const UINT8 DrivFlag) +{ + UINT16 switchId = 0u; /*ID*/ + UINT8 switchExpPos = 0u; /*λ*/ + UINT8 switchSum = 0u; /*Ŀ*/ + UINT8 ii = 0u; /*ѭ*/ + UINT8 funRtn = CI_ERROR; + RouteAssocSwitchStruct routeAssocSwitchStru = {0,0}; /**/ + + switchSum = GetRouteAssocSwitchSum(routeId); /*ȡ·Ŀ*/ + + if(SWITCH_NEED_DRIV_TRUE == DrivFlag) + {/*Ҫ*/ + for(ii = 0u; ii < switchSum; ii++) + { + GetRouteAssocSwitchData(routeId, ii, &routeAssocSwitchStru);/*ȡ*/ + + switchId = routeAssocSwitchStru.SwitchId; + switchExpPos = routeAssocSwitchStru.SwitchPosition; + + funRtn = SwitchDriveProcess(switchId, switchExpPos); /*õλ*/ + } + } +} + +/* +: · +: const UINT16 routeId ·ID + const UINT8 NeedForDrvRoutAssoSwit ǷҪ +: +ֵ: CI_SUCCESS,մɹ + CI_ERROR,մʧ +edit cgh 20241203 +*/ +UINT8 RouteLockDriveSwitch(const UINT16 routeId, const UINT8 NeedForDrvRoutAssoSwit) +{ + UINT8 ii = 0u; + UINT8 switchSum = 0u; + UINT16 switchId = 0u; + UINT8 switchExpPosition = SWITCH_POSITION_INVALID; /*λ*/ + UINT8 switchDancaoPosition = SWITCH_POSITION_INVALID; /*Чλ*/ + RouteSwitchStruct* pRouteSwitchStru = NULL; /*ݽṹָ*/ + UINT8 innerSwitchRetVal = CI_ERROR; /*·ڵǷɱĽ*/ + UINT8 assocSwitchRetVal = CI_ERROR; /*ǷɱĽ*/ + UINT8 assocSwitchSum = 0u; /*Ŀ*/ + RouteAssocSwitchStruct routeAssocSwitchStru = {0,0}; /**/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL; /**/ + + if((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + innerSwitchRetVal = CI_ERROR; + } + else + { + innerSwitchRetVal = RouteLockSwitchDanCaoCheck(routeId); + + if(SWITCH_NEED_DRIV_TRUE == NeedForDrvRoutAssoSwit) + {/*·Ҫ*/ + assocSwitchRetVal = CI_SUCCESS; + + assocSwitchSum = GetRouteAssocSwitchSum(routeId); /*ȡ·Ŀ*/ + + for (ii = 0u; ii < assocSwitchSum; ii++) + { + /*ȡ*/ + GetRouteAssocSwitchData(routeId, ii, &routeAssocSwitchStru); + + switchId = routeAssocSwitchStru.SwitchId; + switchExpPosition = routeAssocSwitchStru.SwitchPosition; + + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + + if( (SWITCH_POSITION_INVALID == switchDancaoPosition) + || + (switchDancaoPosition == switchExpPosition)) + { + /*Ч λ붯λһ*/ + assocSwitchRetVal = CI_SUCCESS; + } + else + { + /*ٵ෴λ*/ + assocSwitchRetVal = CI_ERROR; + /*ñ·ѱٹ*/ + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_TRUE); + /*һ,ٱ*/ + break; + } + + } + } + + if(CI_SUCCESS == innerSwitchRetVal) + { + /*·*/ + RouteDrvInnerSwitch(routeId, SWITCH_NEED_DRIV_TRUE); + } + else + { + RouteDrvInnerSwitch(routeId, SWITCH_NEED_DRIV_FALSE); + } + + if((CI_SUCCESS == assocSwitchRetVal) && (CI_SUCCESS == innerSwitchRetVal)) + { + /**/ + RouteDrvAssocSwitch(routeId, SWITCH_NEED_DRIV_TRUE); + } + else + { + RouteDrvAssocSwitch(routeId, SWITCH_NEED_DRIV_FALSE); + } + + } + + return innerSwitchRetVal; +} + + +/* +* гʻ·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERROR; CI_SUCCESS +* edit cgh 20250113 +*/ +UINT8 GetTrainEnteringRouteState(const UINT16 routeId) +{ + RoutePhysicalSectionStruct* routePhySecData = NULL; + UINT8 reVal = CI_ERROR; + UINT8 chInPhySecCurMergeState = 0U; + UINT8 chRouteState = 0U; + + if ((0U < routeId) && (ROUTE_SUM_MAX > routeId)) + { + chRouteState = GetRouteState(routeId); + + if (ROUTE_STATE_NEAR_OPEN != chRouteState) + { + ; + } + else + { + routePhySecData = GetRouteSectionData(routeId); + + if (NULL != routePhySecData) + { + chInPhySecCurMergeState = GetPhySecCurMergeState(routePhySecData[0].PhysicalSectionId); + if (SECTION_OCCUPY_YES == chInPhySecCurMergeState) + { + /*ֻڷһΣⷽΣٿѹڷռѹλ*/ + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + else + { + ; + } + } + } + else + { + ; + } + + return reVal; +} + +/* +* ·߼ȫ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckRouteLogSecHaveUnLock(const UINT16 routeId) +{ + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 belongRouteId = 0u; + UINT8 logLockState = 0u; + UINT8 reVal = CI_ERROR; + UINT16 routeLogNum = 0u; + UINT16* routeLogIdBuf = NULL; + + /*ȡ·߼*/ + routeLogNum = GetRouteLogSectionSum(routeId); + routeLogIdBuf = GetRouteLogSectionIdBuf(routeId); + + /*·߼ݺϷ*/ + if(0u < routeLogNum) + { + for(i = 0u; i < routeLogNum; i++) + { + belongRouteId = GetLogSecLockBelongRoute(routeLogIdBuf[i]); + /*ȡ״̬*/ + logLockState = GetLogSecLockState(routeLogIdBuf[i]); + /*δա·Ϊ·*/ + if((LOG_SECTION_LOCK_NO == logLockState) || ((LOG_SECTION_LOCK_NO != logLockState) && + (belongRouteId != routeId))) + { + /*سɹ*/ + reVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + reVal = CI_ERROR; + break; + } + } + } + else + { + reVal = CI_ERROR; + } + return(reVal); +} + + +/* +* ΰ߼״̬ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +void SetPhyIncludeLogLockState(const UINT16 phyId, const UINT8 lockState,const UINT16 routeId) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 alexSum = 0u; + UINT16* axisIdBuf = NULL; + UINT8 logSectionSum = 0u; + UINT16* logIdBuf = NULL; + UINT16 logBelongRoute = 0u; + UINT8 routeDir = 0u; + + /*ȡϢ*/ + alexSum = GetPAxisSectionSum(phyId); + axisIdBuf = GetPAxisSectionIdBuf(phyId); + + /*Ϣȷ*/ + if(0u < alexSum) + { + for(i = 0u; i < alexSum; i++) + { + /*ȡ߼Ϣ*/ + logSectionSum = GetAxisSecLogSectionSum(axisIdBuf[i]); + logIdBuf = GetAxisSecLogSectionIdBuf(axisIdBuf[i]); + /*߼Ϣȷ*/ + if((0u < logSectionSum) && (NULL != logIdBuf)) + { + for(j = 0u; j < logSectionSum; j++) + { + /*ȡ߼·*/ + logBelongRoute = GetLogSecLockBelongRoute(logIdBuf[j]); + routeDir = GetRouteDirection(logBelongRoute); + /*·*/ + if(logBelongRoute == routeId) + { + /*öӦ߼״̬*/ + SetLogSecLockState(logIdBuf[j],lockState,routeId,routeDir); + } + else + { + /**/ + } + } + } + else + { + /*޲*/ + } + } + } + else + { + } +} + +/* +* ڵ߼ȫ +* ˵ UINT16 routeId · +* ֵCI_SUCCESSȫ +* CI_ERROR: ڱ·߼ +*/ +UINT8 CheckPhyInLogUlock(const UINT16 phyId, const UINT16 routeId, UINT16* belongRoute) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 alexSum = 0u; + UINT16* axisIdBuf = NULL; + UINT8 logSectionSum = 0u; + UINT16* logIdBuf = NULL; + UINT16 logBelongRoute = 0u; + UINT8 logLockState = 0u; + UINT8 reVal = CI_ERROR; + + /*ȡ*/ + alexSum = GetPAxisSectionSum(phyId); + axisIdBuf = GetPAxisSectionIdBuf(phyId); + + /*Ϣȷ*/ + if(0u < alexSum) + { + for(i = 0u; i < alexSum; i++) + { + /*ȡ߼Ϣ*/ + logSectionSum = GetAxisSecLogSectionSum(axisIdBuf[i]); + logIdBuf = GetAxisSecLogSectionIdBuf(axisIdBuf[i]); + /*߼Ϣȷ*/ + if((0u < logSectionSum) && (NULL != logIdBuf)) + { + for(j = 0u; j < logSectionSum; j++) + { + /*ȡ߼· ״̬*/ + logBelongRoute = GetLogSecLockBelongRoute(logIdBuf[j]); + logLockState = GetLogSecLockState(logIdBuf[j]); + + /*δգղڽ·*/ + if(LOG_SECTION_LOCK_NO == logLockState) + { + /*سɹ*/ + reVal = CI_SUCCESS; + } + /*״̬*/ + else + { + /*ղDZ·*/ + if(logBelongRoute != routeId) + { + *belongRoute = logBelongRoute; + reVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + reVal = CI_ERROR; + break; + } + } + } + } + else + { + /*޲*/ + } + if(CI_ERROR == reVal) + { + /*ѭ*/ + break; + } + else + { + /*޲*/ + } + } + } + return(reVal); +} +/******************************źŻݽ****************************/ + +/* +* źŻ +* ˵ const UINT16 signalId , źŻID +* const UINT16 routeId , ·ID +* ֵ 0:ʧ +* 1:ɹ +*/ +void DriveSignalOpen(const UINT16 signalId, const UINT16 routeId) +{ + UINT8 lightExtinctState = 0u;/*źŻϢ*/ + UINT8 driveColor = 0u; /*źſɫ*/ + UINT8 oriDriveColor = 0u; /*·Ӧźſɫ*/ + UINT8 routeLeadProperty = 0u; /*·*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 allSignalBrightFlag = 0u; /*ȫվƱ־*/ + UINT16 routeEndSignalId = 0u; /*·նźŻID*/ + UINT8 routeEndSignalShowColour = 0u; /*·նźŻʾɫ*/ + UINT8 routeLevel = 0u; + + /*by hanxiao 20170308*/ + /*·迪źŻ*/ + UINT8 needOpenSigSum = 0u; + UINT16* pNeedOpenBuf = NULL; + + UINT16 devId = 0u;/*迪źŻ豸ID*/ + UINT8 sigColor = 0u;/*źŻǰɫ*/ + UINT16 ii = 0u; + UINT16 statrSigRtSum = 0u; + UINT16 *startSigRouteBuf = NULL; + UINT16 tmpRtId = 0u; + UINT8 tmpRtState = 0u; + UINT8 sigOpen = 0u; + + UINT8 bCiSwitchShowGreenYellow = FUNC_SWITCH_OFF;/*ciʾ̻ƿ,Ĭǹرյ*/ + UINT8 belongVirCI= 0u; + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 sigalMaintainState = 0u; + UINT8 signalIsfushiFlag = 0u; + UINT8 signalCurDriveColor = 0u; + + routeLevel = GetRouteLevel(routeId); /*ȡ·*/ + if(ROUTE_LEVEL_BLOC == routeLevel) + { + needOpenSigSum = GetRouteOpenNeedOpenSigSum(routeId); + pNeedOpenBuf = GetRouteOpenNeedOpenSigIdBuf(routeId); + } + else if(ROUTE_LEVEL_CBTC == routeLevel) + { + needOpenSigSum = GetRouteCbtcNeedOpenSigSum(routeId); + pNeedOpenBuf = GetRouteCbtcNeedOpenSigIdBuf(routeId); + } + else + { + /*쳣ֵ*/ + } + + if(1u == needOpenSigSum) + { + devId = pNeedOpenBuf[0]; + } + else + { + /*迪źŻֻ1*/ + } + + if ((0u < devId) && ( SIGNAL_SUM_MAX > devId)) + {/*迪źŻIDЧȡǰɫ*/ + sigColor = GetSignalCurColor(devId); + } + else + { + /*޲*/ + } + oriDriveColor = GetRouteSignalOpenColor(routeId); + if ((0u == signalId) || (SIGNAL_SUM_MAX <= signalId)) + { + /**/ + } + else + { + routeLeadProperty = GetRouteLeadProperty(routeId);/*ȡ·*/ + routeState = GetRouteState(routeId);/*ȡ·״̬*/ + + if (((ROUTE_LEAD_PROPERTY_YES == routeLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == routeLeadProperty)) + && ((ROUTE_STATE_LEAD_LOCK == routeState) + || (ROUTE_STATE_LEAD_LOCKERR == routeState) + || (ROUTE_STATE_LEAD_OPEN == routeState))) + {/*·Ϊҽ·״̬Ϊ<><쳣><>*/ + + driveColor = GetRouteLeadSignalOpenColor(routeId);/*·ɫ*/ + } + else + { + if ((0u != devId)&&(SIGNAL_VIRTUAL_YES == GetSignalVirtualAttr(devId)) && (SIGNAL_OPEN == GetSignalOpenCloseState(sigColor))) + {/*źŻźŻ 迪źŻɫΪźſɫ*/ + /*ԸźŻΪʼ˵Ľ·ȡ·ɫ*/ + statrSigRtSum = GetStartSignalRouteSum(devId);/*ȡԸźŻΪʼźŻĽ·Ŀ*/ + startSigRouteBuf = GetStartSignalRouteBuf(devId);/*ȡԸźŻΪʼźŻĽ·*/ + if ((0u != statrSigRtSum) && (NULL != startSigRouteBuf)) + { + for (ii = 0u;ii < statrSigRtSum;ii++) + {/*źŻΪʼźŻĿŵĽ·ID*/ + tmpRtId = startSigRouteBuf[ii]; + tmpRtState = GetRouteState(tmpRtId);/*ȡ·״̬*/ + if ((ROUTE_STATE_YUXIAN_OPEN == tmpRtState) || (ROUTE_STATE_NEAR_OPEN == tmpRtState)) + {/*ҵŵĽ·˳*/ + driveColor = GetRouteSignalOpenColor(tmpRtId); + break; + } + else + { + /*޲*/ + } + } + } + else + { + /*޲*/ + } + + } + else + { + driveColor = GetRouteSignalOpenColor(routeId);/*·ɫ*/ + } + } + + /**/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCI = GetSignalBelongVirCiId(signalId); + allSignalBrightFlag = GetVirCIAllSignalBrightState(belongVirCI);/*ȫվƱ־*/ + } + else + { + allSignalBrightFlag = GetAllSignalBrightFlag(); /*ȫվƱ־*/ + } + + lightExtinctState = GetSignalLightExtinctState(signalId);/*źŻ״̬*/ + sigalMaintainState = GetSignalMaintainState(signalId);/*źŻά޵״̬*/ + + signalIsfushiFlag = GetSignalIsfushiFlag(signalId); + signalCurDriveColor = GetSignalCurDriveColor(signalId); + if ((SIGNAL_DRIVECOLOUR_NULL == signalCurDriveColor)&&(SIGNALTYPE_FUSHI_YES != signalIsfushiFlag))/*Ƿʾ߼µ쳣*/ + { + /*δźŻɿ*/ + + switch (driveColor) + { + case SIGNAL_SHOWCOLOUR_GREEN:/*̵*/ + { + /*̵*/ + if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) || + (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)|| + (MAINTAIN_STATE_YES == sigalMaintainState) + ) + {/*Ϣ*/ + if (SIGNAL_SHOWCOLOUR_GREEN == oriDriveColor) + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_GREEN); + } + else if (SIGNAL_SHOWCOLOUR_YELLOW == oriDriveColor) + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_YELLOW); + } + else + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + } + else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) + {/*Ϣ*/ + if (SIGNAL_SHOWCOLOUR_GREEN == oriDriveColor) + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_GREENCLOSE); + } + else if (SIGNAL_SHOWCOLOUR_YELLOW == oriDriveColor) + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_YELLOWCLOSE); + } + else + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + } + + else + {/*δյյϢ*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + } + break; + + case SIGNAL_SHOWCOLOUR_YELLOW:/*Ƶ*/ + { + /*Ƶ*/ + if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) || + (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)|| + (MAINTAIN_STATE_YES == sigalMaintainState) + ) + {/*Ϣ*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_YELLOW); + } + else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) + {/*Ϣ*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_YELLOWCLOSE); + } + else + {/*δյյϢ*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + } + break; + + case SIGNAL_SHOWCOLOUR_REDYELLOW:/*Ƶ*/ + /*Ƶ*/ + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDYELLOW); + break; + + case SIGNAL_SHOWCOLOUR_WHITE:/*׵*/ + /*׵*/ + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_WHITE); + break; + case SIGNAL_SHOWCOLOUR_RED_WHITE:/*׵*/ + /*׵*/ + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED_WHITE); + break; + + case SIGNAL_SHOWCOLOUR_GREEN_OR_GREENYELLOW:/*̻̻ for人*/ + { + /*ڴ⴦ҪնźŻɫȷ·ɫ(̻̻)*/ + routeEndSignalId = GetRouteEndSignalId(routeId);/*ȡ·նźŻID*/ + routeEndSignalShowColour = GetSignalCurColor(routeEndSignalId);/*ȡ·նźŻʾɫ*/ + bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*ʾ̻ƹܿǷ*/ + if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) || + (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)|| + (MAINTAIN_STATE_YES == sigalMaintainState) + ) + {/*Ϣ ģʽ*/ + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow) + {/*ܴ*/ + if ( (SIGNAL_SHOWCOLOUR_GREEN == routeEndSignalShowColour) || + (SIGNAL_SHOWCOLOUR_GREENYELLOW == routeEndSignalShowColour)|| + (SIGNAL_SHOWCOLOUR_YELLOW == routeEndSignalShowColour) + )/*·նźŻɫΪ̵ƻ̻ƻƵƣʼΪ̵*/ + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREEN);/*̵*/ + } + else if (SIGNAL_SHOWCOLOUR_RED == routeEndSignalShowColour)/*·նźŻɫΪƣʼΪ̻*/ + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENYELLOW);/*̻*/ + } + else + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENYELLOW);/*Ƿֵպƴ̻*/ + } + } + else + { + /*δʲô*/ + } + } + else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) + {/*Ϣ CBTCģʽ*/ + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow) + {/*ܴ*/ + sigOpen = GetSignalOpenCloseState(routeEndSignalShowColour); + if (SIGNAL_OPEN == sigOpen) + {/*նźŻʾɫΪ*/ + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENCLOSE);/**/ + } + else + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE);/*̻*/ + } + } + else + { + /*δʲô*/ + } + } + else + {/*δյյϢ*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + break; + } + + case SIGNAL_SHOWCOLOUR_GREEN_OR_YELLOW:/*̻߻ for人*/ + { + /*ڴ⴦ҪնźŻɫȷ·ɫ(̻ǻ)*/ + routeEndSignalId = GetRouteEndSignalId(routeId);/*ȡ·նźŻID*/ + routeEndSignalShowColour = GetSignalCurColor(routeEndSignalId);/*ȡ·նźŻʾɫ*/ + + sigOpen = GetSignalOpenCloseState(routeEndSignalShowColour);/*ȡ·նźŻŹر״̬*/ + + bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*ʾ̻ƹܿǷ*/ + + if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) || + (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState)|| + (MAINTAIN_STATE_YES == sigalMaintainState) + ) + {/*Ϣ ģʽ*/ + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow) + {/*ܴ*/ + if (SIGNAL_OPEN != sigOpen)/*·նźŻΪ*/ + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_YELLOW);/*Ƶ*/ + } + else + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREEN);/*̵*/ + } + } + else + { + /*δʲô*/ + } + } + else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) + {/*Ϣ CBTCģʽ*/ + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow) + {/*ܴ*/ + sigOpen = GetSignalOpenCloseState(routeEndSignalShowColour); + if (SIGNAL_OPEN != sigOpen) + {/*նźŻʾɫΪ*/ + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_YELLOWCLOSE);/**/ + } + else + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_GREENCLOSE);/**/ + } + } + else + { + /*δʲô*/ + } + } + else + {/*δյյϢ*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + } + break; + case SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW:/*˫ for人*/ + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW);/*˫*/ + break; + } + + case SIGNAL_SHOWCOLOUR_DOUBLE_GREEN:/*˫ for人*/ + { + SetSignalCurDriveColor(signalId,SIGNAL_DRIVECOLOUR_DOUBLE_GREEN);/*˫*/ + break; + } + + default: + /*Ƕɫ*/ + if ((CI_ALL_SIGNAL_BRIGHT_NO == allSignalBrightFlag) && + (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState)&& + (MAINTAIN_STATE_NO == sigalMaintainState) + ) + {/*źŻȫվҴ״̬Ҳڵά޵״̬*/ + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + else + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + break; + } + + } + else + { + /**/ + } + } +} + +/* +* źŻر +* ˵ const UINT16 signalId, źŻID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 DriveSignalClose(const UINT16 signalId) +{ + UINT8 lightExtinctState = 0u; + UINT8 allSignalBrightFlag = 0u; /*ȫվƱ־*/ + UINT8 reVal = CI_SUCCESS; + UINT8 belongVirCIid = 0u; + UINT8 detainOpenRedBright = 0u; + UINT8 signalDetainFlag = 0u; + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 sigalMaintainState = 0u; + UINT8 signalIsfushiFlag = 0u; + UINT16 wSigInFirstPhyId = 0U; + UINT16 routeId = 0U; + UINT8 routeLeadProperty = 0U; + UINT8 routeState = 0U; + UINT16 wStartSignalId = 0u; + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + reVal = CI_ERROR; + } + else + { + /**/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCIid = GetSignalBelongVirCiId(signalId); + allSignalBrightFlag = GetVirCIAllSignalBrightState(belongVirCIid); /*ȫվƱ־*/ + } + else + { + allSignalBrightFlag = GetAllSignalBrightFlag(); /*ȫվƱ־*/ + } + /*ʲôʱ򣬸ʾźŻرն*/ + signalIsfushiFlag = GetSignalIsfushiFlag(signalId); + if (SIGNALTYPE_FUSHI_YES == signalIsfushiFlag) + { + /*ǸźŻ*/ + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + else + { + /*ƺͿ۳ܿжźŻرɫ*/ + lightExtinctState = GetSignalLightExtinctState(signalId); + sigalMaintainState = GetSignalMaintainState(signalId);/*źŻά޵״̬*/ + wSigInFirstPhyId = GetSignalInFirstPhySecId(signalId, routeId); + routeId = GetPhySecRLockBelongRouteId(wSigInFirstPhyId); + routeLeadProperty = GetRouteLeadProperty(routeId);/*ȡ·*/ + routeState = GetRouteState(routeId);/*ȡ·״̬*/ + wStartSignalId = GetRouteStartSignalId(routeId); + + if (((ROUTE_LEAD_PROPERTY_YES == routeLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == routeLeadProperty)) + && ((ROUTE_STATE_LEAD_LOCK == routeState) + || (ROUTE_STATE_LEAD_LOCKERR == routeState) + || (ROUTE_STATE_LEAD_OPEN == routeState)) + && (wStartSignalId == signalId)) + {/*·Ϊҽ·״̬Ϊ<><쳣><>*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED);/*·رɫ*/ + } + else if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) || + (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) || + (MAINTAIN_STATE_YES == sigalMaintainState) + ) + {/*Ϣ*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) + {/*Ϣ*/ + detainOpenRedBright = GetCiFunctionSwitchConfig(FUNC_DETAIN_OPEN_RED); + if (FUNC_SWITCH_ON == detainOpenRedBright) + { /*˿۳󿪷ź*/ + signalDetainFlag = GetSignalDetainFlag(signalId); + if (SIGNAL_DETAIN_NO == signalDetainFlag) + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + else + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + + } + else + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + } + else + {/*δյܵźŻϢ*/ + + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + } + } + + + return reVal; +} + +/******************************ݽ****************************/ + + +/* +* ǰЧԼ +* ˵ UINT16 switchIdId +* UINT8 oper_src,Դ +* UINT8 sendLevelͼ +* ֵ CI_SUCCESS: ʧ +* CI_ERROR: ³ɹ +* add 20221009 ·ǰ⶯ +*/ +UINT8 GetSwitchMoveEarlyValidState(UINT16 switchId, UINT8 oper_src, UINT8 sendLevel) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_SWITCH_MOVE; + + /*ֲ*/ + /**/ + UINT8 ciType = 0u; + /**/ + UINT8 switchType = 0u; + /*1*/ + UINT16 switch1stSecId = 0u; + UINT8 switch1stLockStatus = 0u; + UINT8 switch1stYLockState = 0u; + UINT8 switch1stSecOccuState = 0u; + UINT8 switch1stSecLockState = 0u; + UINT8 switch1stSecMerOccuState = 0u; + UINT8 arbState = 0u; + UINT8 switch1stSecJumpLockState = 0u; + UINT8 switch1stSecFLockState = 0u;/*1η״̬*/ + /*2*/ + UINT16 switch2ndId = 0u; + UINT16 switch2ndSecId = 0u; + UINT8 switch2ndLockStatus = 0u; + UINT8 switch2ndYLockState = 0u; + UINT8 switch2ndSecOccuState = 0u; + UINT8 switch2ndSecLockState = 0u; + UINT8 switch2ndSecMerOccuState = 0u; + UINT8 reVal = CI_ERROR; + UINT8 ARBMoveSwitchFlag = 0u; + UINT8 switch2ndSecJumpLockState = 0u; + UINT8 switch2ndSecFLockState = 0u;/*2η״̬*/ + UINT8 vobcInterface = 0u;/*vobcӿڱʶ*/ + UINT8 localCiType = 0u; /*ci*/ + UINT8 vobcInerface = 0u;/*vobcӿ*/ + UINT8 gdDLline = 0u; /*·ʶ*/ + UINT8 logLockState = 0u; /*߼*/ + UINT8 logOccState = 0u; /*߼ռü*/ + UINT16 logOccOrLockId = 0u; + UINT8 logState = 0u; + + /* */ + switch1stSecId = GetSwitchPhySectionId(switchId); + switch1stLockStatus = GetSwitchLockStatus(switchId); + switch1stYLockState = GetSwitchYLockState(switchId); + switch1stSecMerOccuState = GetPhySecCurMergeState(switch1stSecId); + switch1stSecFLockState = GetPhySecFLockState(switch1stSecId);/*ȡ1η״̬*/ + ciType = GetLocalCiType(); + /*жǷù·*/ + gdDLline = GetCiFunctionSwitchConfig(FUNC_CLD_GD_DIANLU_LINE); + + if ((JkjRelayId > 0u) && (JKJ_REYLAY_VALID == JkjRelayValid) && (CI_TYPE_CLD == ciType)) + {/*Ӧ̵̼Ч״̬*/ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, JkjRelayId, ETYPE_JKJ_WORK, RELAY_STATE_DOWN, ESEND_LEVEL_ATS); + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + vobcInerface = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY); + + if (((LINE_FAO == vobcInerface) || (LINE_HLHT == vobcInerface) || (LINE_FAOHLHT == vobcInerface) || (LINE_FAOHLHT_ONESELF == vobcInerface)|| (LINE_FAOHLHT_ONESELFSECOND == vobcInerface)) + && (CI_TYPE_CLD == ciType) && (FUNC_SWITCH_ON == gdDLline)) + {/*FAO·FALHLHT· ʹù·ֱʹռԭںϺ״̬*/ + switch1stSecOccuState = GetPhySecCurAndMergeState(switch1stSecId); + } + else + {/*ߡʹü豸ʹGJ*/ + switch1stSecOccuState = GetPhySecCurOccupyState(switch1stSecId); + } + /*ȡARB״̬*/ + arbState = GetArbState(switch1stSecId); + switch1stSecLockState = GetPhySecLockState(switch1stSecId); + switch1stSecJumpLockState = GetPhySecJumpLockState(switch1stSecId); /*ȡԾ״̬*/ + if (CI_SUCCESS == reVal) + { + if (SWITCH_LOCK_STATUS_NO != switch1stLockStatus) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, + ETYPE_SWT_LOCK_STATUS, switch1stLockStatus, sendLevel); + reVal = CI_ERROR; + } + } + if (CI_SUCCESS == reVal) + { + if (SWITCH_LOCK_YINZONG_NO != switch1stYLockState) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, + ETYPE_SWT_YLOCK_STATE, switch1stYLockState, sendLevel); + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + { + /*ȡ߼״̬*/ + logLockState = GetSwitchLogSecLockState(switchId, &logOccOrLockId, &logState); + /*ηաϵ*/ + if ((PHYSICAL_SECTION_LOCK_START == switch1stSecLockState) || (PHYSICAL_SECTION_LOCK_PROTECT == switch1stSecLockState)) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_LOCK_STATE, switch1stSecLockState, sendLevel); + reVal = CI_ERROR; + } + else + { /*߼*/ + if (CI_ERROR == logLockState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, + ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + } + } + if (CI_SUCCESS == reVal) + { + if (PHYSICAL_SECTION_JUMP_LOCK_NO != switch1stSecJumpLockState) + { /*Ծ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_JUMP_LOCK, switch1stSecJumpLockState, sendLevel); + reVal = CI_ERROR; + } + } + if (CI_SUCCESS == reVal) + { + /*ȡι߼εռ״̬*/ + logOccState = GetSwitchSecOccState(switchId, &logOccOrLockId, &logState); + if (CI_ERROR == logOccState) + { + /*߼ռ*/ + /*¼*/ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, + ETYPE_LOGSEC_OCC_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + { + ARBMoveSwitchFlag = GetCiFunctionSwitchConfig(ARB_MOVE_SWITCH_CONF); + if (FUNC_SWITCH_ON == ARBMoveSwitchFlag) + {/*ARBɶܿش*/ + /*ɼΪռҼARB״̬ΪARBںϺΪҲԶ*/ + if (SECTION_OCCUPY_NO != switch1stSecOccuState) + { + if ((AXIS_SECTION_ARB_YES == arbState) && (SECTION_OCCUPY_NO == switch1stSecMerOccuState)) + { /*ARBںϺ״̬ΪУ*/ + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel); + reVal = CI_ERROR; + } + } + + } + else if (FUNC_SWITCH_OFF == ARBMoveSwitchFlag) + { + + if (AXIS_SECTION_ARB_NO != arbState) + { /*ռ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel); + reVal = CI_ERROR; + } + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel); + reVal = CI_ERROR; + } + + } + + if (CI_SUCCESS == reVal) + {/*ηηǰЧɶ򣬲ɶ*/ + if (PHYSICAL_SECTION_FLOCK_NO != switch1stSecFLockState) + { + if (SWITCH_OPER_DANCAO == oper_src) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_FLOCK_STATE, switch1stSecFLockState, sendLevel); + } + } + } + if (CI_SUCCESS == reVal) + { + /*˫*/ + switchType = GetSwitchType(switchId); + if (SWITCH_TYPE_DOUBLE == switchType) + { + switch2ndId = GetDSwitchOtherId(switchId); + switch2ndSecId = GetSwitchPhySectionId(switch2ndId); + switch2ndLockStatus = GetSwitchLockStatus(switch2ndId); + switch2ndYLockState = GetSwitchYLockState(switch2ndId); + switch2ndSecLockState = GetPhySecLockState(switch2ndSecId); + switch2ndSecMerOccuState = GetPhySecCurMergeState(switch2ndSecId); + switch2ndSecJumpLockState = GetPhySecJumpLockState(switch2ndSecId); /*ȡԾ״̬*/ + switch2ndSecFLockState = GetPhySecFLockState(switch2ndSecId);/*ȡ˫2η״̬*/ + /*ȡARB״̬*/ + arbState = GetArbState(switch2ndSecId); + vobcInterface = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY); + localCiType = GetLocalCiType(); + if (((LINE_FAO == vobcInterface) || (LINE_HLHT == vobcInerface) || (LINE_FAOHLHT == vobcInerface) || (LINE_FAOHLHT_ONESELF == vobcInerface) || (LINE_FAOHLHT_ONESELFSECOND == vobcInerface)) + && (CI_TYPE_CLD == localCiType) && (FUNC_SWITCH_ON == gdDLline)) + {/*FAO·FAOHLHT· ΣֱʹռԭںϺ״̬*/ + switch2ndSecOccuState = GetPhySecCurAndMergeState(switch2ndSecId); + } + else + {/*ߡʹü豸ʹGJ*/ + switch2ndSecOccuState = GetPhySecCurOccupyState(switch2ndSecId); + } + + if (SWITCH_LOCK_STATUS_NO != switch2ndLockStatus) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switch2ndId, + ETYPE_SWT_LOCK_STATUS, switch2ndLockStatus, sendLevel); + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + if (SWITCH_LOCK_YINZONG_NO != switch2ndYLockState) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switch2ndId, + ETYPE_SWT_YLOCK_STATE, switch2ndYLockState, sendLevel); + reVal = CI_ERROR; + } + } + if (CI_SUCCESS == reVal) + { + /*ȡ߼״̬*/ + logLockState = GetSwitchLogSecLockState(switch2ndId, &logOccOrLockId, &logState); + /*ηաϵ*/ + if ((PHYSICAL_SECTION_LOCK_START == switch2ndSecLockState) || (PHYSICAL_SECTION_LOCK_PROTECT == switch2ndSecLockState)) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_LOCK_STATE, switch2ndSecLockState, sendLevel); + reVal = CI_ERROR; + } + else + { /*߼*/ + if (CI_ERROR == logLockState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, + ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + } + } + if (CI_SUCCESS == reVal) + { + if (switch2ndSecJumpLockState != PHYSICAL_SECTION_JUMP_LOCK_NO) + { /*Ծ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_JUMP_LOCK, switch2ndSecJumpLockState, sendLevel); + reVal = CI_ERROR; + } + } + if (CI_SUCCESS == reVal) + { + /*ȡι߼εռ״̬*/ + logOccState = GetSwitchSecOccState(switch2ndId, &logOccOrLockId, &logState); + if (CI_ERROR == logOccState) + { + /*߼ռ*/ + /*¼*/ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, + ETYPE_LOGSEC_OCC_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + { + ARBMoveSwitchFlag = GetCiFunctionSwitchConfig(ARB_MOVE_SWITCH_CONF); + if (FUNC_SWITCH_ON == ARBMoveSwitchFlag) + {/*ARBɶܿش*/ + /*ɼΪռҼARB״̬ΪARBںϺΪҲԶ*/ + if (SECTION_OCCUPY_NO != switch2ndSecOccuState) + { + if ((AXIS_SECTION_ARB_YES == arbState) && (SECTION_OCCUPY_NO == switch2ndSecMerOccuState)) + { /*ARBںϺ״̬ΪУ*/ + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel); + reVal = CI_ERROR; + } + } + + } + else if (FUNC_SWITCH_OFF == ARBMoveSwitchFlag) + { + if (AXIS_SECTION_ARB_NO != arbState) + { + /*߼ռ*/ + /*¼*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel); + reVal = CI_ERROR; + } + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel); + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + {/*ηηǰЧɶ򣬲ɶ*/ + + if (PHYSICAL_SECTION_FLOCK_NO != switch2ndSecFLockState) + { + if (SWITCH_OPER_DANCAO == oper_src) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_FLOCK_STATE, switch2ndSecFLockState, sendLevel); + } + } + + } + } + } + + /*ɶ*/ + return reVal; +} + +/* +* ɶЧԼ +* ˵ UINT16 switchIdId +* UINT8 oper_src,Դ +* UINT8 sendLevelͼ +* ֵ CI_SUCCESS: ³ɹ +* CI_ERROR: ʧ +* modify 20221009 ߼λֹ +*/ +UINT8 GetSwitchMoveValidState(UINT16 switchId,UINT8 oper_src,UINT8 sendLevel) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_SWITCH_MOVE; + + /*ֲ*/ + /**/ + UINT8 ciType = 0u; + /**/ + UINT8 switchType = 0u; + /*1*/ + UINT16 switch1stSecId = 0u; + UINT8 switch1stLockStatus = 0u; + UINT8 switch1stYLockState = 0u; + UINT8 switch1stSecOccuState = 0u; + UINT8 switch1stSecLockState = 0u; + UINT8 switch1stSecMerOccuState = 0u; + UINT8 arbState = 0u; + UINT8 switch1stSecJumpLockState = 0u; + UINT8 switch1stSecFLockState = 0u;/*1η״̬*/ + /*2*/ + UINT16 switch2ndId = 0u; + UINT16 switch2ndSecId = 0u; + UINT8 switch2ndLockStatus = 0u; + UINT8 switch2ndYLockState = 0u; + UINT8 switch2ndSecOccuState = 0u; + UINT8 switch2ndSecLockState = 0u; + UINT8 switch2ndSecMerOccuState = 0u; + UINT8 reVal = CI_ERROR; + UINT8 ARBMoveSwitchFlag = 0u; + UINT8 switch2ndSecJumpLockState = 0u; + UINT8 switch2ndSecFLockState = 0u;/*2η״̬*/ + UINT8 vobcInterface = 0u;/*vobcӿڱʶ*/ + UINT8 localCiType = 0u; /*ci*/ + UINT8 vobcInerface = 0u;/*vobcӿ*/ + UINT8 gdDLline = 0u; /*·ʶ*/ + UINT8 cLogSecLockFlag = 0u; /*߼ձ־*/ + UINT16 logOccOrLockId = 0u; + UINT8 logState = 0U; + + /* */ + switch1stSecId = GetSwitchPhySectionId(switchId); + switch1stLockStatus = GetSwitchLockStatus(switchId); + switch1stYLockState = GetSwitchYLockState(switchId); + switch1stSecMerOccuState = GetPhySecCurMergeState(switch1stSecId); + switch1stSecFLockState = GetPhySecFLockState(switch1stSecId);/*ȡ1η״̬*/ + ciType = GetLocalCiType(); + /*жǷù·*/ + gdDLline = GetCiFunctionSwitchConfig(FUNC_CLD_GD_DIANLU_LINE); + + if ((JkjRelayId > 0u) && (JKJ_REYLAY_VALID == JkjRelayValid) && (CI_TYPE_CLD == ciType)) + {/*Ӧ̵̼Ч״̬*/ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, JkjRelayId, ETYPE_JKJ_WORK, RELAY_STATE_DOWN, ESEND_LEVEL_ATS); + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + vobcInerface = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY); + + if (((LINE_FAO == vobcInerface) || (LINE_HLHT == vobcInerface) || (LINE_FAOHLHT == vobcInerface)) + && (CI_TYPE_CLD == ciType) && (FUNC_SWITCH_ON == gdDLline)) + {/*FAO·FALHLHT· ʹù·ֱʹռԭںϺ״̬*/ + switch1stSecOccuState = GetPhySecCurAndMergeState(switch1stSecId); + } + else + {/*ߡʹü豸ʹGJ*/ + switch1stSecOccuState = GetPhySecCurOccupyState(switch1stSecId); + } + /*ȡARB״̬*/ + arbState = GetArbState(switch1stSecId); + switch1stSecLockState = GetPhySecLockState(switch1stSecId); + switch1stSecJumpLockState = GetPhySecJumpLockState(switch1stSecId); /*ȡԾ״̬*/ + if (CI_SUCCESS == reVal) + { + if (SWITCH_LOCK_STATUS_NO != switch1stLockStatus) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, + ETYPE_SWT_LOCK_STATUS, switch1stLockStatus, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /*޲*/ + } + } + else + { + ; /*ִ*/ + } + + if (CI_SUCCESS == reVal) + { + if (SWITCH_LOCK_YINZONG_NO != switch1stYLockState) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, + ETYPE_SWT_YLOCK_STATE, switch1stYLockState, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /*޲*/ + } + } + else + { + ; /*ִ*/ + } + + if (CI_SUCCESS == reVal) + { + if (PHYSICAL_SECTION_LOCK_NO != switch1stSecLockState) + {/**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_LOCK_STATE, switch1stSecLockState, sendLevel); + reVal = CI_ERROR; + } + else + { + /*δգΰ߼ν·״̬*/ + cLogSecLockFlag = CheckPSecIncLSecLockState(switch1stSecId, &logOccOrLockId, &logState); + if (CI_ERROR == cLogSecLockFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + else + { + /*δգ߼δ·գΰ߼߼״̬*/ + cLogSecLockFlag = CheckPSecIncLSecLogicLockState(switch1stSecId, &logOccOrLockId, &logState); + if (CI_ERROR == cLogSecLockFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /**/ + } + } + } + } + else + { + ; /*ִ*/ + } + + if (CI_SUCCESS == reVal) + { + if (PHYSICAL_SECTION_JUMP_LOCK_NO != switch1stSecJumpLockState) + { /*Ծ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_JUMP_LOCK, switch1stSecJumpLockState, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /*޲*/ + } + } + else + { + ; /*ִ*/ + } + + if (CI_SUCCESS == reVal) + { + + ARBMoveSwitchFlag = GetCiFunctionSwitchConfig(ARB_MOVE_SWITCH_CONF); + if (FUNC_SWITCH_ON == ARBMoveSwitchFlag) + {/*ARBɶܿش*/ + /*ɼΪռҼARB״̬ΪARBںϺΪҲԶ*/ + if (SECTION_OCCUPY_NO != switch1stSecOccuState) + { + if ((AXIS_SECTION_ARB_YES == arbState) && (SECTION_OCCUPY_NO == switch1stSecMerOccuState)) + { /*ARBںϺ״̬ΪУ*/ + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel); + reVal = CI_ERROR; + } + } + else + { + ; /**/ + } + } + else if (FUNC_SWITCH_OFF == ARBMoveSwitchFlag) + { + if (AXIS_SECTION_ARB_NO != arbState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_MERGY_OCU_STATE, SECTION_OCCUPY_YES, sendLevel); + reVal = CI_ERROR; + } + else + { + if (SECTION_OCCUPY_NO != switch1stSecOccuState) + { /*ռ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /**/ + } + } + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_MERGY_OCU_STATE, switch1stSecOccuState, sendLevel); + reVal = CI_ERROR; + } + } + else + { + ; /*ִ*/ + } + + if (CI_SUCCESS == reVal) + {/*ηηǰЧɶ򣬲ɶ*/ + if (PHYSICAL_SECTION_FLOCK_NO != switch1stSecFLockState) + { + if (SWITCH_OPER_DANCAO == oper_src) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, + ETYPE_PS_FLOCK_STATE, switch1stSecFLockState, sendLevel); + } + } + else + { + ; /**/ + } + } + else + { + ; /*ִ*/ + } + + if (CI_SUCCESS == reVal) + { + /*˫*/ + switchType = GetSwitchType(switchId); + if (SWITCH_TYPE_DOUBLE == switchType) + { + switch2ndId = GetDSwitchOtherId(switchId); + switch2ndSecId = GetSwitchPhySectionId(switch2ndId); + switch2ndLockStatus = GetSwitchLockStatus(switch2ndId); + switch2ndYLockState = GetSwitchYLockState(switch2ndId); + switch2ndSecLockState = GetPhySecLockState(switch2ndSecId); + switch2ndSecMerOccuState = GetPhySecCurMergeState(switch2ndSecId); + switch2ndSecJumpLockState = GetPhySecJumpLockState(switch2ndSecId); /*ȡԾ״̬*/ + switch2ndSecFLockState = GetPhySecFLockState(switch2ndSecId);/*ȡ˫2η״̬*/ + /*ȡARB״̬*/ + arbState = GetArbState(switch2ndSecId); + vobcInterface = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY); + localCiType = GetLocalCiType(); + if (((LINE_FAO == vobcInterface) || (LINE_HLHT == vobcInerface) || (LINE_FAOHLHT == vobcInerface)) + && (CI_TYPE_CLD == localCiType) && (FUNC_SWITCH_ON == gdDLline)) + {/*FAO·FAOHLHT· ΣֱʹռԭںϺ״̬*/ + switch2ndSecOccuState = GetPhySecCurAndMergeState(switch2ndSecId); + } + else + {/*ߡʹü豸ʹGJ*/ + switch2ndSecOccuState = GetPhySecCurOccupyState(switch2ndSecId); + } + + if (SWITCH_LOCK_STATUS_NO != switch2ndLockStatus) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switch2ndId, + ETYPE_SWT_LOCK_STATUS, switch2ndLockStatus, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /**/ + } + + if (CI_SUCCESS == reVal) + { + if (SWITCH_LOCK_YINZONG_NO != switch2ndYLockState) + { /**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switch2ndId, + ETYPE_SWT_YLOCK_STATE, switch2ndYLockState, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /**/ + } + } + if (CI_SUCCESS == reVal) + { + if (PHYSICAL_SECTION_LOCK_NO != switch2ndSecLockState) + {/**/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_LOCK_STATE, switch2ndSecLockState, sendLevel); + reVal = CI_ERROR; + } + else + { + /*δգΰ߼ν·״̬*/ + cLogSecLockFlag = CheckPSecIncLSecLockState(switch2ndSecId, &logOccOrLockId, &logState); + if (CI_ERROR == cLogSecLockFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + else + { + /*δգΰ߼δ·գ߼״̬*/ + cLogSecLockFlag = CheckPSecIncLSecLogicLockState(switch2ndSecId, &logOccOrLockId, &logState); + if (CI_ERROR == cLogSecLockFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /**/ + } + } + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == reVal) + { + if (switch2ndSecJumpLockState != PHYSICAL_SECTION_JUMP_LOCK_NO) + { /*Ծ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_JUMP_LOCK, switch2ndSecJumpLockState, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == reVal) + { + + ARBMoveSwitchFlag = GetCiFunctionSwitchConfig(ARB_MOVE_SWITCH_CONF); + if (FUNC_SWITCH_ON == ARBMoveSwitchFlag) + {/*ARBɶܿش*/ + /*ɼΪռҼARB״̬ΪARBںϺΪҲԶ*/ + if (SECTION_OCCUPY_NO != switch2ndSecOccuState) + { + if ((AXIS_SECTION_ARB_YES == arbState) && (SECTION_OCCUPY_NO == switch2ndSecMerOccuState)) + { + ; /*ARBںϺ״̬ΪУ*/ + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel); + reVal = CI_ERROR; + } + } + else + { + ; /**/ + } + } + else if (FUNC_SWITCH_OFF == ARBMoveSwitchFlag) + { + if (AXIS_SECTION_ARB_NO != arbState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_MERGY_OCU_STATE, SECTION_OCCUPY_YES, sendLevel); + reVal = CI_ERROR; + } + else + { + if (SECTION_OCCUPY_NO != switch2ndSecOccuState) + { /*ռ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel); + reVal = CI_ERROR; + } + else + { + ; /**/ + } + } + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_MERGY_OCU_STATE, switch2ndSecOccuState, sendLevel); + reVal = CI_ERROR; + } + + } + else + { + ; /**/ + } + + if (CI_SUCCESS == reVal) + {/*ηηǰЧɶ򣬲ɶ*/ + + if (PHYSICAL_SECTION_FLOCK_NO != switch2ndSecFLockState) + { + if (SWITCH_OPER_DANCAO == oper_src) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, + ETYPE_PS_FLOCK_STATE, switch2ndSecFLockState, sendLevel); + } + } + else + { + ; /**/ + } + + } + else + { + ; /**/ + } + } + else + { + ; /*޲*/ + } + } + else + { + ; /*ִ*/ + } + + /*ɶ*/ + return reVal; +} + +/* zt ɾش 2022-02-15 */ +/* +* ǿɶЧԼ +* ˵ UINT16 switchId ID +* UINT8 sendLevel ATSֵطͼ +* ֵ CI_SUCCESS: ʧ +* CI_ERROR: ³ɹ +*/ +UINT8 GetSwitchForceMoveValidState(UINT16 switchId,UINT8 sendLevel) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_FORCE_SWITCH_MOVE; + +/*ֲ*/ + /**/ + UINT8 switchType = 0u; + /*1*/ + UINT16 switch1stSecId = 0u; + UINT8 switch1stLockStatus = 0u; + UINT8 switch1stYLockState = 0u; + UINT8 switch1stSecOccuState = 0u; + UINT8 switch1stSecLockState = 0u; + UINT8 switch1stSecJumpLockState = 0u; + + /*2*/ + UINT16 switch2ndId = 0u; + UINT16 switch2ndSecId = 0u; + UINT8 switch2ndLockStatus = 0u; + UINT8 switch2ndYLockState = 0u; + UINT8 switch2ndSecLockState = 0u; + UINT8 switch2ndSecJumpLockState = 0u; + UINT8 reVal = CI_SUCCESS; + UINT8 cLogSecLockFlag = 0U; /*߼ձ־*/ + UINT16 logOccOrLockId = 0U; + UINT8 logState = 0U; + + /* */ + switch1stSecId = GetSwitchPhySectionId(switchId); + switch1stLockStatus = GetSwitchLockStatus(switchId); + switch1stYLockState = GetSwitchYLockState(switchId); + switch1stSecOccuState = GetPhySecCurOccupyState(switch1stSecId); + switch1stSecLockState = GetPhySecLockState(switch1stSecId); + switch1stSecJumpLockState = GetPhySecJumpLockState(switch1stSecId); /*ȡԾ״̬*/ + + if ((SWITCH_LOCK_STATUS_DANSUO == switch1stLockStatus) || (SWITCH_LOCK_STATUS_PROTECT == switch1stLockStatus) + || (SWITCH_LOCK_STATUS_DAP == switch1stLockStatus)) + { /**/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId, + ETYPE_SWT_LOCK_STATUS,switch1stLockStatus,sendLevel); + reVal = CI_ERROR; + } + + if (reVal == CI_SUCCESS) + { + if (SWITCH_LOCK_YINZONG_YES == switch1stYLockState) + { /**/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId, + ETYPE_SWT_YLOCK_STATE,switch1stYLockState,sendLevel); + reVal = CI_ERROR; + } + } + if (reVal == CI_SUCCESS) + { + if (PHYSICAL_SECTION_LOCK_NO != switch1stSecLockState) + { /**/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch1stSecId, + ETYPE_PS_LOCK_STATE,switch1stSecLockState,sendLevel); + reVal = CI_ERROR; + } + else + { + /*δգΰ߼ν·״̬*/ + cLogSecLockFlag = CheckPSecIncLSecLockState(switch1stSecId, &logOccOrLockId, &logState); + if (CI_ERROR == cLogSecLockFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + + /*δգΰ߼߼״̬*/ + cLogSecLockFlag = CheckPSecIncLSecLogicLockState(switch1stSecId, &logOccOrLockId, &logState); + if (CI_ERROR == cLogSecLockFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + } + } + if (reVal == CI_SUCCESS) + { + if (PHYSICAL_SECTION_JUMP_LOCK_NO != switch1stSecJumpLockState ) + { /*Ծ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch1stSecId, + ETYPE_PS_JUMP_LOCK,switch1stSecJumpLockState,sendLevel); + reVal = CI_ERROR; + } + } + if (reVal == CI_SUCCESS) + { + if (SECTION_OCCUPY_YES != switch1stSecOccuState) + { /*δռ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch1stSecId, + ETYPE_PS_MERGY_OCU_STATE,switch1stSecOccuState,sendLevel); + reVal = CI_ERROR; + } + } + if (CI_SUCCESS == reVal) + { + /*˫*/ + switchType = GetSwitchType(switchId); + if (SWITCH_TYPE_DOUBLE == switchType ) + { + switch2ndId = GetDSwitchOtherId(switchId); + switch2ndSecId = GetSwitchPhySectionId(switch2ndId); + switch2ndLockStatus = GetSwitchLockStatus(switch2ndId); + switch2ndYLockState = GetSwitchYLockState(switch2ndId); + switch2ndSecLockState = GetPhySecLockState(switch2ndSecId); + switch2ndSecJumpLockState = GetPhySecJumpLockState(switch2ndSecId); /*ȡԾ״̬*/ + + if ((SWITCH_LOCK_STATUS_DANSUO == switch2ndLockStatus) || (SWITCH_LOCK_STATUS_PROTECT == switch2ndLockStatus) + || (SWITCH_LOCK_STATUS_DAP == switch2ndLockStatus)) + { /**/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switch2ndId, + ETYPE_SWT_LOCK_STATUS,switch2ndLockStatus,sendLevel); + reVal = CI_ERROR; + } + + if (reVal == CI_SUCCESS) + { + if (SWITCH_LOCK_YINZONG_YES == switch2ndYLockState) + { /**/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switch2ndId, + ETYPE_SWT_YLOCK_STATE,switch2ndYLockState,sendLevel); + reVal = CI_ERROR; + } + } + if (reVal == CI_SUCCESS) + { + if (PHYSICAL_SECTION_LOCK_NO != switch2ndSecLockState ) + { /**/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch2ndSecId, + ETYPE_PS_LOCK_STATE,switch2ndSecLockState,sendLevel); + reVal = CI_ERROR; + } + else + { + /*δգΰ߼ν·״̬*/ + cLogSecLockFlag = CheckPSecIncLSecLockState(switch2ndSecId, &logOccOrLockId, &logState); + if (CI_ERROR == cLogSecLockFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + + /*δգΰ߼߼״̬*/ + cLogSecLockFlag = CheckPSecIncLSecLogicLockState(switch2ndSecId, &logOccOrLockId, &logState); + if (CI_ERROR == cLogSecLockFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logOccOrLockId, ETYPE_LOGSEC_LOCK_STATE, logState, sendLevel); + reVal = CI_ERROR; + } + } + } + if (reVal == CI_SUCCESS) + { + if (PHYSICAL_SECTION_JUMP_LOCK_NO != switch2ndSecJumpLockState ) + { /*Ծ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch2ndSecId, + ETYPE_PS_JUMP_LOCK,switch2ndSecJumpLockState,sendLevel); + reVal = CI_ERROR; + } + } + + } + } + + /*ɶ*/ + return reVal; +} +/* zt ɾش 2022-02-15 */ + + +/* +* ȡ״̬ +* ˵ void +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchRouteLockState(UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 belongSecId = 0u; /*ID*/ + UINT16 doubleSwitchId = 0u; /*˫ID*/ + UINT8 belongPhySecState = 0u; /*εĽ·״̬*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + belongSecId = GetSwitchPhySectionId(switchId); + belongPhySecState = GetPhySecLockState(belongSecId); + + if ((PHYSICAL_SECTION_LOCK_NORMAL == belongPhySecState) || + (PHYSICAL_SECTION_LOCK_PROTECT == belongPhySecState)|| + (PHYSICAL_SECTION_LOCK_DELAY == belongPhySecState) || + (PHYSICAL_SECTION_LOCK_FAULTDELAY == belongPhySecState)) + { + /* աաʱʽʱΪ״̬ + ֹʱΪZC*/ + reVal = CI_SUCCESS; + } + else + { + doubleSwitchId = GetDSwitchOtherId(switchId);/*ȡ˫ID*/ + if (doubleSwitchId != 0u) + {/*˫ǿ*/ + + belongSecId = GetSwitchPhySectionId(doubleSwitchId); + belongPhySecState = GetPhySecLockState(belongSecId); + + if ((PHYSICAL_SECTION_LOCK_NORMAL == belongPhySecState) || + (PHYSICAL_SECTION_LOCK_PROTECT == belongPhySecState) || + (PHYSICAL_SECTION_LOCK_DELAY == belongPhySecState) || + (PHYSICAL_SECTION_LOCK_FAULTDELAY == belongPhySecState)) + { + reVal = CI_SUCCESS; + } + } + } + } + return reVal; +} + +/* +* +* ˵ const UINT16 switchId, ID +* const UINT8 switchPos, λ +* ֵ void +*/ +UINT8 SwitchDriveProcess(const UINT16 switchId, const UINT8 switchPos) +{ + UINT8 reValue = CI_ERROR; + UINT8 switchPreExpDrvPos = SWITCH_DRIVE_POS_INVALID; + UINT8 switchCurExpDrvPos = SWITCH_DRIVE_POS_INVALID; + UINT8 switchExpDrvPos = SWITCH_DRIVE_POS_INVALID; + + /*ȡǰλ*/ + switchCurExpDrvPos = GetSwitchExpDrvPosition(switchId); + + if(SWITCH_DRIVE_POS_INVALID != switchCurExpDrvPos) + {/*ǰλЧ*/ + /*ζűѴҵҪ,ʱʲôҲ*/ + /*ע⣬Ϊ˫Ƚ⣬ȻѾڣп˫һʱһϵģʱҪ + 뵱ǰһ£÷ֵΪCI_SUCCESS*/ + if ( + ((SWITCH_DRIVE_POS_FANWEI == switchCurExpDrvPos)&&(SWITCH_POSITION_FANWEI == switchPos)) || + ((SWITCH_DRIVE_POS_DINGWEI == switchCurExpDrvPos)&&(SWITCH_POSITION_DINGWEI == switchPos)) + ) + {/* zt ɾش 2022-02-15 */ + reValue = CI_SUCCESS; + } + } + else + { + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + if (SWITCH_POSITION_DINGWEI == switchPos) + {/*Ҫλ*/ + /*λDINGWEIתΪλ*/ + switchExpDrvPos = SWITCH_DRIVE_POS_DINGWEI; + } + else if (SWITCH_POSITION_FANWEI == switchPos) + {/*Ҫλ*/ + /*λFANWEIתΪλ*/ + switchExpDrvPos = SWITCH_DRIVE_POS_FANWEI; + }/* zt ɾش 2022-02-15 */ + else + {/*ҪЧλ*/ + /*λINVALIDתΪλ*/ + switchExpDrvPos = SWITCH_DRIVE_POS_INVALID; + } + } + + if(SWITCH_DRIVE_POS_INVALID != switchExpDrvPos) + {/*λЧ*/ + /*ȡλ*/ + switchPreExpDrvPos = GetSwitchPreExpDrvPosition(switchId); + + if(SWITCH_DRIVE_POS_INVALID != switchPreExpDrvPos) + {/*λЧ*/ + if(switchPreExpDrvPos == switchExpDrvPos) + {/*λͬ*/ + /*ñλ*/ + reValue = SetSwitchExpDrvPosition(switchId, switchExpDrvPos); + } + else + {/*λڲͬ*/ + /*ζ֮ǰɸڰںпѴҵҪ,ʱʲôҲ*/ + } + } + else + {/*λЧ*/ + /*ñλ*/ + reValue = SetSwitchExpDrvPosition(switchId, switchExpDrvPos); + } + } + else + {/*λЧ*/ + /*ʲôҲ*/ + } + } + + return reValue; +} + + +/* +: + ·λ +: + const UINT16 routeId ·ID +: + . +ֵ: + +*/ +void ClearRouteSwitchDrivePos(const UINT16 routeId) +{ + UINT8 retValOfSetSwiExpDrvPos = CI_ERROR; /*õλõķֵ*/ + UINT8 switchSum = 0u; /*Ŀ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 ii = 0u; /*ѭ*/ + RouteSwitchStruct* pRouteSwitchStru = NULL; /**/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL; /**/ + + switchSum = GetRouteSwitchSum(routeId); /*ȡ·Ŀ*/ + pRouteSwitchStru = GetRouteSwitchData(routeId); /*ȡ·ڵ*/ + routeProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId); /*ȡ·Ŀ*/ + pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId); /*ȡ·*/ + + if(NULL != pRouteSwitchStru) + { + for(ii = 0u; ii < switchSum; ii++) + { + switchId = pRouteSwitchStru[ii].SwitchId; + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if(CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + + if(NULL != pRouteProtectSwitchStru) + { + for(ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = pRouteProtectSwitchStru[ii].ProtectSwitchId; + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if(CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + +} + +/* +: + ιλ +: + const UINT16 routeId ·ID +: + . +ֵ: + +*/ +void ClearOverlapSwitchDrivePos(const UINT16 overlapId) +{ + UINT8 retValOfSetSwiExpDrvPos = CI_ERROR; /*õλõķֵ*/ + UINT8 ii; + UINT8 switchSum = 0u; + UINT16 switchId = 0u; + OverlapConditionSwitchStruct* conditionSwitchStru = NULL; + UINT8 protectSwitchSum = 0u; + OverlapProtectSwitchStruct* protectSwitchStru = NULL; + + if ((0u < overlapId) && (OVERLAP_SUM_MAX > overlapId)) + { + switchSum = GetOverlapSwitchSum(overlapId); + protectSwitchSum = GetOverlapRelatedProtSwitSum(overlapId); + conditionSwitchStru = GetOverlapCondSwitchStruct(overlapId); + protectSwitchStru = GetOverlapRelatedProtSwitStru(overlapId); + + if (NULL != conditionSwitchStru) + { + for (ii = 0u; ii < switchSum; ii++) + { + switchId = conditionSwitchStru[ii].SwitchId; + + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if(CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + + if (NULL != protectSwitchStru) + { + for (ii = 0u; ii < protectSwitchSum; ii++) + { + switchId = protectSwitchStru[ii].ProtectSwitchId; + + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if(CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + } + else + { + /**/ + } + +} + +/* +: + ·λ +: + const UINT16 routeId ·ID +: + . +ֵ: + +*/ +void ClearRouteSwitchDanCaoPos(const UINT16 routeId) +{ + UINT8 retValOfSetSwiDanCaoPos = CI_ERROR; /*õλõķֵ*/ + UINT8 switchSum = 0u; /*Ŀ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 ii = 0u; /*ѭ*/ + RouteSwitchStruct* routeSwitchStru = NULL; /**/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct* routeProtectSwitchStru = NULL; /**/ + + switchSum = GetRouteSwitchSum(routeId); /*ȡ·Ŀ*/ + routeSwitchStru = GetRouteSwitchData(routeId); /*ȡ·ڵ*/ + routeProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId); /*ȡ·Ŀ*/ + routeProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId); /*ȡ·*/ + + if(NULL != routeSwitchStru) + { + for(ii = 0u; ii < switchSum; ii++) + { + switchId = routeSwitchStru[ii].SwitchId; + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + if(CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + + if (NULL != routeProtectSwitchStru) + { + for(ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = routeProtectSwitchStru[ii].ProtectSwitchId; + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + if(CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } +} + +/* +: + ιλ +: + const UINT16 routeId ·ID +: + . +ֵ: + +*/ +void ClearOverlapSwitchDanCaoPos(const UINT16 overlapId) +{ + UINT8 retValOfSetSwiDanCaoPos = CI_ERROR; /*õλõķֵ*/ + UINT8 switchSum = 0u; /*Ŀ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 ii = 0u; /*ѭ*/ + OverlapConditionSwitchStruct* conditionSwitchStru = NULL; + UINT8 protectSwitchSum = 0u; + OverlapProtectSwitchStruct* protectSwitchStru = NULL; + + if ((0u < overlapId) && (OVERLAP_SUM_MAX > overlapId)) + { + switchSum = GetOverlapSwitchSum(overlapId); + protectSwitchSum = GetOverlapRelatedProtSwitSum(overlapId); + conditionSwitchStru = GetOverlapCondSwitchStruct(overlapId); + protectSwitchStru = GetOverlapRelatedProtSwitStru(overlapId); + + if (NULL != conditionSwitchStru) + { + for(ii = 0u; ii < switchSum; ii++) + { + switchId = conditionSwitchStru[ii].SwitchId; + + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + + if(CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + /**/ + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + + if (NULL != protectSwitchStru) + { + for(ii = 0u; ii < protectSwitchSum; ii++) + { + switchId = protectSwitchStru[ii].ProtectSwitchId; + + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + + if(CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + /**/ + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + } + else + { + /**/ + } +} + + +/* +: + ǽ·λ +: + +: + . +ֵ: + CI_SUCCESS ɹ + CI_ERROR ʧ +*/ +UINT8 ClearNonRouteSwitchDrivePos(UINT8 nonRouteId) +{ /*ķֵ*/ + UINT8 retValOfSetSwiExpDrvPos = CI_ERROR; /*õλõķֵ*/ + UINT8 switchSum = 0u; /*Ŀ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 ii = 0u; /*ѭ*/ + NonRouteSwitchStruct* pNonRouteSwitchStru = NULL; + UINT8 retVal = CI_SUCCESS; + UINT8 protectSwitchSum = 0u; /**/ + NonRouteProtectSwitchStruct* pNonRouteProtectSwitchStru = NULL; /**/ + /*ȡǽ·Ŀ*/ + switchSum = GetNonRouteSwitchSumById(nonRouteId); + /*ȡǽ·ݽṹָ*/ + pNonRouteSwitchStru = GetNonRouteSwitchStructBufById(nonRouteId); + protectSwitchSum = GetNonRouteRelatedProtSwitSum(nonRouteId); /*ǽ·*/ + pNonRouteProtectSwitchStru = GetNonRouteRelatedProtSwitStru(nonRouteId); /*ǽ·*/ + + if (pNonRouteSwitchStru !=NULL) + { + for(ii = 0u; ii < switchSum; ii++) + { + switchId = pNonRouteSwitchStru[ii].SwitchId; + + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if(CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + retVal = CI_ERROR; + } + } + } + else + { + retVal = CI_ERROR; + } + + if (pNonRouteProtectSwitchStru !=NULL) + { + for(ii = 0u; ii < protectSwitchSum; ii++) + { + switchId = pNonRouteProtectSwitchStru[ii].ProtectSwitchId; + + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if(CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + retVal = CI_ERROR; + } + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + + +/* +: + ǽ·λ +: + const UINT16 routeId ·ID +: + . +ֵ: + CI_SUCCESS ɹ + CI_ERROR ʧ +*/ +UINT8 ClearNonRouteSwitchDanCaoPos(UINT8 nonRouteId) +{ + UINT8 retVal = CI_SUCCESS; /*ķֵ*/ + UINT8 retValOfSetSwiDanCaoPos = CI_ERROR; /*õλõķֵ*/ + UINT8 switchSum = 0u; /*Ŀ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 ii = 0u; /*ѭ*/ + NonRouteSwitchStruct* pNonRouteSwitchStru = NULL; + UINT8 protectSwitchSum = 0u; /**/ + NonRouteProtectSwitchStruct* pNonRouteProtectSwitchStru = NULL; /**/ + + /*ȡǽ·Ŀ*/ + switchSum = GetNonRouteSwitchSumById(nonRouteId); + /*ȡǽ·ݽṹָ*/ + pNonRouteSwitchStru = GetNonRouteSwitchStructBufById(nonRouteId); + protectSwitchSum = GetNonRouteRelatedProtSwitSum(nonRouteId); /*ǽ·*/ + pNonRouteProtectSwitchStru = GetNonRouteRelatedProtSwitStru(nonRouteId); /*ǽ·*/ + + if(NULL != pNonRouteSwitchStru) + { + for(ii = 0u; ii < switchSum; ii++) + { + switchId = pNonRouteSwitchStru[ii].SwitchId; + + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + + if(CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + retVal = CI_ERROR; + } + } + } + else + { + retVal = CI_ERROR; + } + + if(NULL != pNonRouteProtectSwitchStru) + { + for(ii = 0u; ii < protectSwitchSum; ii++) + { + switchId = pNonRouteProtectSwitchStru[ii].ProtectSwitchId; + + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + + if(CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + retVal = CI_ERROR; + } + } + } + else + { + retVal = CI_ERROR; + } + + + return retVal; +} + + +/******************************ݽ****************************/ + +/* +* ȡARBϢ +* ˵ void +* ֵ AXIS_SECTION_ARB_NO δARB +* AXIS_SECTION_ARB_YES ARB +*/ +UINT8 GetArbState(UINT16 phySectionId) +{ + UINT16* axisSectionIds = NULL; /*ID*/ + UINT8 axisSectionSum = 0u; /*ļ*/ + UINT8 ii = 0u; /*α*/ + UINT8 reValue = AXIS_SECTION_ARB_NO; + UINT8 chArbState = 0U; + + axisSectionSum = GetPAxisSectionSum(phySectionId); + axisSectionIds = GetPAxisSectionIdBuf(phySectionId); + + if ((NULL == axisSectionIds)) + { + reValue = AXIS_SECTION_ARB_NO; + } + else + { + for (ii = 0u; ii < axisSectionSum; ii++) + { + chArbState = GetAxisSecArbState(axisSectionIds[ii]); + if (AXIS_SECTION_ARB_YES == chArbState) + { + reValue = AXIS_SECTION_ARB_YES; + break; + } + else + { + /*޲*/ + } + } + } + return reValue; +} + +/* +* ȡ߼ռںϢ +* ˵ void +* ֵ +* SECTION_OCCUPY_NO +* SECTION_OCCUPY_YES +*/ + +/*ʱãԤ*/ +#if 0 +UINT8 GetLogicSecMergyOccuState(UINT16 phySectionId) +{ + UINT8 const axisSecSum = GetPAxisSectionSum(phySectionId); + UINT16* const pAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId); + + UINT16 axisSecId = 0u; + UINT8 logicSecSum = 0u; + UINT16* pLogicSecIdBuf = NULL; + + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 logicOccupyState = 0u; + UINT8 reValue = SECTION_OCCUPY_NO; + + if ((0u == axisSecSum) || (NULL == pAxisSecIdBuf)) + { + reValue = SECTION_OCCUPY_YES; + } + else + { + for (ii = 0u; ii < axisSecSum; ii++) + { + axisSecId = pAxisSecIdBuf[ii]; + logicSecSum = GetAxisSecLogSectionSum(axisSecId); + pLogicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId); + for (jj = 0u; jj < logicSecSum; jj++) + { + logicOccupyState = GetLogSecCurOccupyState(pLogicSecIdBuf[jj]); + if (logicOccupyState == SECTION_OCCUPY_YES) + { + /*һ߼ռ*/ + reValue = SECTION_OCCUPY_YES; + break; + } + } + if (reValue == SECTION_OCCUPY_YES) + { + break; + } + } + } + return reValue; +} +#endif + +/* +* ȡ߼ռϢ +* ˵ void +* ֵ +* SECTION_OCCUPY_NO +* SECTION_OCCUPY_YES +*/ +UINT8 GetLogicSecOccuState(UINT16 phySectionId) +{ + UINT8 const axisSecSum = GetPAxisSectionSum(phySectionId); + UINT16* const pAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId); + + UINT16 axisSecId = 0u; + UINT8 logicSecSum = 0u; + UINT16* pLogicSecIdBuf = NULL; + + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 logicOccupyState = 0u; + UINT8 reValue = SECTION_OCCUPY_NO; + + if (0u == axisSecSum) + { + reValue = SECTION_OCCUPY_YES; + } + else + { + for (ii = 0u; ii < axisSecSum; ii++) + { + axisSecId = pAxisSecIdBuf[ii]; + logicSecSum = GetAxisSecLogSectionSum(axisSecId); + pLogicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId); + for (jj = 0u; jj < logicSecSum; jj++) + { + logicOccupyState = GetLogSecOccupyState(pLogicSecIdBuf[jj]); + if ((LOGICSECTION_OCCUPY_UT == logicOccupyState) || (LOGICSECTION_OCCUPY_CT == logicOccupyState)) + { + /*һ߼ռ*/ + reValue = SECTION_OCCUPY_YES; + break; + } + else + { + /*޲*/ + } + } + if (reValue == SECTION_OCCUPY_YES) + { + break; + } + else + { + /*޲*/ + } + } + } + return reValue; +} + +/******************************ݽ****************************/ + +#if 0 + +/* +* ָſŵվ·źŹرյijվ· +* ˵ const UINT16 doorId ID +* const UINT8 PsdOpenedBeforeFlag ſ֮ǰ־ 1:ſ֮ǰͳ 0:ſ֮ͳ +* ֵ +*/ +void CalculatePsdOpenedLeadToSignalCloseRoute(const UINT16 doorId,const UINT8 PsdOpenedBeforeFlag) +{ + UINT8 outStationRouteSum = 0u; /*Źijվ·Ŀ*/ + UINT16 * outStationRouteIdBuf = NULL; /*Źijվ·Id*/ + UINT8 signedCloseRouteSum = 0u; /*ſźŹرյijվ·Ŀ*/ + UINT16 * signedCloseRouteIdBuf = NULL; /*ſźŹرյijվ·Id*/ + UINT8 *psdOpenBeforeRouteIsBuildedFlagBuf =NULL; + UINT8 routeState = 0u; /*·״̬*/ + UINT8 ii; + UINT8 jj; + + outStationRouteSum = GetPsdRalatedOutStationRouteSum(doorId); /*ȡŹվ·Ŀ*/ + outStationRouteIdBuf = GetPsdRalatedOutStationRouteIdBuf(doorId); /*ȡŹվ·ID*/ + + + for(ii = 0u;ii < outStationRouteSum;ii++) + {/*йվ·*/ + + if(CI_ERROR == AutoSignalOrRouteValid(outStationRouteIdBuf[ii])) + {/*Զ*/ + routeState = GetRouteState(outStationRouteIdBuf[ii]); /*ȡվ·״̬*/ + if((ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) + ) + {/*·״̬Ϊ(·쳣 ) || (·Ԥ) || (·ӽ쳣)˵Ŵ򿪵´˽·źŹر*/ + + signedCloseRouteSum = GetBuildedOutStationRouteSum(doorId); /*ȡſŵ³վ·źŹرյijվ·Ŀ*/ + signedCloseRouteIdBuf = GetBuildedOutStationRouteIdBuf(doorId);/*ȡſŵ³վ·źŹرյijվ·ID*/ + psdOpenBeforeRouteIsBuildedFlagBuf = GetPsdOpenBeforeOutStationRouteIsBuildedFlagBuf(doorId); + for(jj = 0u;jj < signedCloseRouteSum;jj++) + {/*ſźŹرյijվ·飬ظԼ*/ + if(outStationRouteIdBuf[ii] == signedCloseRouteIdBuf[jj]) + {/*֮ǰѾ*/ + break; + } + } + if(jj == signedCloseRouteSum) + {/*δ,б*/ + + signedCloseRouteIdBuf[signedCloseRouteSum] = outStationRouteIdBuf[ii]; + if(0u == PsdOpenedBeforeFlag) + {/*֮ͳ*/ + psdOpenBeforeRouteIsBuildedFlagBuf[signedCloseRouteSum] = PSD_OPEN_BEFORE_SIG_CLOSE_NO; + } + else + {/*֮ǰͳ*/ + psdOpenBeforeRouteIsBuildedFlagBuf[signedCloseRouteSum] = PSD_OPEN_BEFORE_SIG_CLOSE_YES; + } + + signedCloseRouteSum++; + SetBuildedOutStationRouteSum(doorId, signedCloseRouteSum); + + } + } + } + + } + +} + +#endif + +/******************************Զ۷·ݽ****************************/ +/* +* Զ۷·۳·Ƿ԰ЧԼ +* ˵ const UINT16 routeId, ·Id +* ֵ CI_ERROR: Ч +* CI_SUCCESS: Ч +*/ +UINT8 GetAutoReturnRebackRouteValid(const UINT16 routeId) +{ + UINT8 autoRouteType = 0u; /*Զ·*/ + UINT16 rebackRouteId = 0u; /*Զ۳·Id*/ + UINT16 rebackRouteStartSignalId = 0u; /*Զ۳·ʼźŻId*/ + UINT16 returnSectionId = 0u; /*Զ۷·۷Id*/ + UINT8 returnSectionOccuState = 0u; /*Զ۷·۷ռ״̬*/ + UINT8 returnSectionLockState = 0u; /*Զ۷·۷״̬*/ + UINT16 returnRouteId = 0u; /*Զ۷·Id*/ + UINT8 returnRouteState = 0u; /*Զ۷·״̬*/ + UINT8 reValue = CI_ERROR; + + autoRouteType = GetRouteAutoRouteSetState(routeId); + + if (ROUTE_AUTOROUTE_RETURN == autoRouteType) + { + rebackRouteId = GetAutoReturnRebackRouteId(GetRouteAutoReturnId(routeId)); + if (rebackRouteId == routeId) + { + /*Զ·۳·*/ + rebackRouteStartSignalId = GetRouteStartSignalId(routeId); + returnSectionId = GetSignalOutFirstPhySecId(rebackRouteStartSignalId); + returnSectionOccuState = GetPhySecCurMergeState(returnSectionId); + returnSectionLockState = GetPhySecLockState(returnSectionId); + returnRouteId = GetPhySecRLockBelongRouteId(returnSectionId); + returnRouteState = GetRouteState(returnRouteId); + + if ((returnSectionOccuState == SECTION_OCCUPY_YES) && + (returnSectionLockState == PHYSICAL_SECTION_LOCK_NORMAL) && + (GetRouteAutoReturnId(returnRouteId) == GetRouteAutoReturnId(rebackRouteId)) && + ((returnRouteState == ROUTE_STATE_AUTO_UNLOCK) || (returnRouteState == ROUTE_STATE_NEAR_LOCK)) + ) + { + /*۷졾ռáҡա ۷·Զ۷Id۳·Զ۷Id + ۷·״̬ΪԶ򡾽ӽ*/ + /*Զ۷·۳·*/ + reValue = CI_SUCCESS; + } + } + else + { + /*Զ۷·۳·*/ + reValue = CI_ERROR; + } + } + else + { + /*Զ۷·*/ + reValue = CI_ERROR; + } + return reValue; +} + + +/* +* Զ۷·۳·Ƿ԰ЧԼ +* ˵ const UINT16 routeId, ·Id +* ֵ + AUTO_RETURN_ROUTE_TYPE_IN 0x55 ۷ + AUTO_RETURN_ROUTE_TYPE_OUT 0xAA ۳ + AUTO_RETURN_ROUTE_TYPE_VAIN 0xFF Ч +*/ +UINT8 GetAutoReturnRouteType(const UINT16 autoReturnId, const UINT16 routeId) +{ + UINT8 ii = 0u; + UINT8 autoIncludeRouteSum = 0u; + UINT16 *pAutoIncludeRouteIdbuf = NULL; + + UINT8 autoSetFlag = AUTO_RETURN_ROUTE_TYPE_VAIN; + + if ((autoReturnId >= 1u) && (autoReturnId < AUTO_RETURN_SUM_MAX)) + { + autoIncludeRouteSum = GetAutoReturnIncludeRouteSum(autoReturnId); + pAutoIncludeRouteIdbuf = GetAutoReturnIncludeRouteBuf(autoReturnId); + + for (ii = 0u; ii < (autoIncludeRouteSum - 1u); ii++) + { + if (pAutoIncludeRouteIdbuf[ii] == routeId) + { + /*۷·*/ + autoSetFlag = AUTO_RETURN_ROUTE_TYPE_IN; + break; + } + } + + if (pAutoIncludeRouteIdbuf[autoIncludeRouteSum - 1u] == routeId) + { + /*۳·*/ + autoSetFlag = AUTO_RETURN_ROUTE_TYPE_OUT; + } + } + else + { + /*ЧԶ۷·*/ + autoSetFlag = AUTO_RETURN_ROUTE_TYPE_VAIN; + } + + return autoSetFlag; +} + + +/******************************overlapݽ****************************/ +/* +* ȡָID״̬ +* ˵ const UINT16 overlapId, ID +* ֵ 0: δ +* >0: ״̬ +*/ +UINT8 GetOverlapLockState(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ContainSecSum = 0u; /*Ŀ*/ + UINT16* ContainSecStru = NULL; /*ID*/ + UINT16 PhySecId = 0u; /*ǰID*/ + UINT8 ii = 0u; + UINT8 tmpPhyState = 0u; /*ʱ״̬*/ + UINT16 tmpRouteId = 0u;/*ʱ·id*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (OVERLAP_SUM_MAX > bufIndex) + { + ContainSecSum = GetOverlapPhySecSum(overlapId); + ContainSecStru = GetOverlapPhySecIdBuf(overlapId); + + if (0u == ContainSecSum) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + if(CI_SUCCESS == reVal) + { + for (ii = 0u; ii < ContainSecSum; ii++) + { + PhySecId = ContainSecStru[ii]; + tmpPhyState = GetPhySecLockState(PhySecId); + tmpRouteId = GetOverlapBelongRouteId(overlapId); + if ((PHYSICAL_SECTION_LOCK_PROTECT == tmpPhyState) + || (0u != tmpRouteId)) + { + + } + else + { + reVal = CI_ERROR; + break; + } + } + } + else + { + /*޲*/ + } + } + else + { + reVal = CI_ERROR; + } + return reVal; +} + + +/******************************Զ·ݽ****************************/ +/* +* ·ԶЧԼ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 AutoSignalOrRouteValid(const UINT16 routeId) +{ + UINT8 autoRouteProperty = 0u; /*Զ·*/ + UINT8 autoSigRouteState = 0u; /*ԶźŽ·״̬*/ + UINT8 autoRouteState = 0u; /*Զ·״̬*/ + UINT8 retVal = CI_SUCCESS; /*ֵ*/ + + + /*ȡ·ֶ̬*/ + autoRouteProperty = GetRouteAutoRouteProperty(routeId); /*ȡ·Զ·*/ + autoSigRouteState = GetRouteAutoSigSetState(routeId); /*ȡԶźŽ·״̬*/ + autoRouteState = GetRouteAutoRouteSetState(routeId); /*ȡ·Զ·״̬*/ + + + + /*Զ·ԶźŴ*/ + if ((ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) || + ((ROUTE_AUTOROUTE_PROPERTY_YES == autoRouteProperty) && + ((ROUTE_AUTOROUTE_NORMAL == autoRouteState) || (ROUTE_AUTOROUTE_RETURN == autoRouteState)|| + (ROUTE_ALLAUTOROUTE_RETURN == autoRouteState)) + ) + ) + { /*ԶźŻԶ·*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + + +/******************************ݽ****************************/ +/* +* ȡֹͣ־ +* ˵ void +* ֵ UINT8 ֹͣ־ +*/ +UINT8 GetStopCheckFlag(void) +{ + return StopCheckState; +} + +/* +* ֹͣ־ +* ˵ void +* ֵ +*/ +void SetStopCheckFlag(void) +{ + StopCheckState = ROUTE_STOPCHECK_SET_YES; /*ֹͣ*/ +} + + +/* +* ȡֹͣ־ +* ˵ void +* ֵ +*/ +void CancelStopCheckFlag(void) +{ + StopCheckState = ROUTE_STOPCHECK_SET_NO; /*ȡֹͣ*/ +} + + +/* +* ȡӦ̵̼ID +* ˵ void +* ֵ +*/ +UINT16 GetJkjRelayId(void) +{ + return JkjRelayId; +} + + +/* +* ȡ崻־ +* ˵ void +* ֵ +*/ +UINT8 GetPlatOverFlag(void) +{ + return PlatOverFlag; +} + + +/* +* ȡ崻־ +* ˵ void +* ֵ +*/ +void SetPlatOverFlag(void) +{ + PlatOverFlag = CI_OVER_YES; +} + + +/* +* źŻ߼ +* ˵ void +* ֵ void +*/ +void YLockSignalOpenManage(void) +{ + UINT16 signalCurSum = GetSignalCurSum(); /*źŻĿ*/ + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT16 signalId = 0u; + UINT8 belongCiId = 0u; + + UINT16 ii = 0u; /*ѭ*/ + UINT8 belongVirCI = 0u; + UINT8 flag = 0u; + UINT8 yLockState = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + + /*źŻ*/ + for (ii = 0u; ii < signalCurSum; ii++) + { + flag = 0u; + signalId = 0u; /*ID*/ + belongCiId = 0u; /*·ID*/ + + signalId = GetSignalId(ii); /*ȡźŻID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡ·ID*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCI = GetSignalBelongVirCiId(signalId); /*ȡźŻID*/ + yLockState = GetVirCIAllSwitchYLockState(belongVirCI); + } + else + { + yLockState = GetAllSwitchYLockFlag(); + } + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + flag =1u; + } + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + flag =1u; + } + + if (0u == flag) + { + /*ؿź߼*/ + LeadzLockNewOpenManage(signalId, yLockState); + } + else + { + ; /**/ + } + + } +} + +/******************************ȫԶ۷·ݽ****************************/ + +/* +* ȫԶ۷·۳·Ƿ԰ЧԼ +* ˵ const UINT16 routeId, ·Id +* ֵ CI_ERROR: Ч +* CI_SUCCESS: Ч +*/ +UINT8 GetAllAutoReturnOutRouteValid(const UINT16 routeId) +{ + UINT8 autoRouteType = 0u; /*Զ·*/ + + UINT16 rebackRouteStartSignalId = 0u; /*ȫԶ۳·ʼźŻId*/ + UINT16 returnSectionId = 0u; /*ȫԶ۷·۷Id*/ + UINT8 returnSectionOccuState = 0u; /*ȫԶ۷·۷ռ״̬*/ + UINT8 returnSectionLockState = 0u; /*ȫԶ۷·۷״̬*/ + UINT8 returnRouteState = 0u; /*ȫԶ۷·״̬*/ + UINT16 returnRouteId = 0u; + UINT8 ii = 0u; + + UINT16 allAutoReturnId = 0u; + UINT8 allReturnRouteSum = 0u; + UINT16 *pAllReturnRouteBuf = NULL; /*ȫԶ۷·*/ + UINT16 otherRebackRouteStartSignalId = 0u; + UINT16 otherReturnSectionId = 0u; + UINT8 returnValue = CI_ERROR; + autoRouteType = GetRouteAutoRouteSetState(routeId); + allAutoReturnId = GetRouteAllAutoReturnId(routeId); + /*ǷҪжȫԶ۷·Чԣ*/ + if (autoRouteType == ROUTE_ALLAUTOROUTE_RETURN) + { + pAllReturnRouteBuf = GetAllAutoReturnRebackRouteBuf(allAutoReturnId); + allReturnRouteSum = GetAllAutoReturnRebackRouteSum(allAutoReturnId); + if ((ALL_AUTO_RETURN_REBACKROUTE_SUM_MAX < allReturnRouteSum)||(0u ==routeId)) + { + returnValue = CI_ERROR; + } + else + { + /*ȫԶ۷·۳·*/ + rebackRouteStartSignalId = GetRouteStartSignalId(routeId); + returnSectionId = GetSignalOutFirstPhySecId(rebackRouteStartSignalId); /*۷ID*/ + returnSectionOccuState = GetPhySecCurMergeState(returnSectionId); + returnSectionLockState = GetPhySecLockState(returnSectionId); + returnRouteId = GetPhySecRLockBelongRouteId(returnSectionId); + returnRouteState = GetRouteState(returnRouteId); + if ((returnSectionOccuState == SECTION_OCCUPY_YES) && + (returnSectionLockState == PHYSICAL_SECTION_LOCK_NORMAL) && + (GetRouteAllAutoReturnId(returnRouteId) == GetRouteAllAutoReturnId(routeId)) && + ((returnRouteState == ROUTE_STATE_AUTO_UNLOCK) || (returnRouteState == ROUTE_STATE_NEAR_LOCK))) + { + /*۷졾ռáҡա ۷·Զ۷Id۳·Զ۷Id + ۷·״̬ΪԶ򡾽ӽ*/ + /*Զ۷·۳·*/ + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + for (ii = 0u; ii < allReturnRouteSum; ii++) + { + if (pAllReturnRouteBuf[ii] != routeId) + { + + otherRebackRouteStartSignalId = GetRouteStartSignalId(pAllReturnRouteBuf[ii]); + otherReturnSectionId = GetSignalOutFirstPhySecId(otherRebackRouteStartSignalId); /*۷ID*/ + + } + } + if (CI_SUCCESS == returnValue) + { + + if(CompareOccuTime(returnSectionId , otherReturnSectionId) > 0u) + { + /*۳·Ĵʱһ۳·Ĵʱ䳤·*/ + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + } + } + } + else + { + /*ȫԶ۷·*/ + returnValue = CI_ERROR; + } + return returnValue; +} + +/* +* ȫԶ۷·· +* ˵ const UINT16 routeId, ·Id +* ֵ + ALL_AUTO_RETURN_ROUTE_TYPE_IN 0x55 ۷ + ALL_AUTO_RETURN_ROUTE_TYPE_OUT 0xAA ۳ + ALL_AUTO_RETURN_ROUTE_TYPE_VAIN 0xFF Ч +*/ +UINT8 GetAllAutoReturnRouteType(const UINT16 allAutoReturnId, const UINT16 routeId) +{ + UINT8 ii = 0u; + UINT8 autoIncludeRouteSum = 0u; + UINT16 *pAutoIncludeRouteIdbuf = NULL; + + UINT8 autoSetFlag = CI_ERROR; + + if ((1u <= allAutoReturnId) && (ALL_AUTO_RETURN_SUM_MAX > allAutoReturnId)) + { + autoIncludeRouteSum = GetAllAutoReturnIncludeRouteSum(allAutoReturnId); + pAutoIncludeRouteIdbuf = GetAllAutoReturnIncludeRouteBuf(allAutoReturnId); + if(2u < autoIncludeRouteSum) + { + for (ii = 0u; ii < (autoIncludeRouteSum - 2u); ii++) + { + if (pAutoIncludeRouteIdbuf[ii] == routeId) + { + /*۷·*/ + autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_IN; + break; + } + else + { + /*޲*/ + } + } + + if(ALL_AUTO_RETURN_ROUTE_TYPE_IN != autoSetFlag) + { + if((pAutoIncludeRouteIdbuf[autoIncludeRouteSum - 1u] == routeId)|| + (pAutoIncludeRouteIdbuf[autoIncludeRouteSum - 2u] == routeId)) + { + /*۳·*/ + autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_OUT; + } + else + { + /*δҵӦ·*/ + autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_VAIN; + } + + } + else + { + /*޲*/ + } + } + else + { + /*δҵӦ·*/ + autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_VAIN; + } + } + + else + { + /*ЧȫԶ۷·*/ + autoSetFlag = ALL_AUTO_RETURN_ROUTE_TYPE_VAIN; + } + return autoSetFlag; +} + + +/******************************ʽʱݼ****************************/ + +/* +* ·߼Ƿʱ +* ˵ const UINT16 routeId, ·Id +* ֵ + LOGSEC_LSXS_SET_STATE_NO 0x55 δʱ٣ڵ1ã + LOGSEC_LSXS_SET_STATE_YES 0xAA ʱ٣ȫδã +*/ +static UINT8 RouteIncludeLogSecLSXSSetCheck(const UINT16 routeId) +{ + UINT8 retVal = LOGSEC_LSXS_SET_STATE_NO; + + UINT16 jj = 0u; + UINT16 kk = 0u; + UINT16 mm = 0u; + UINT16 phySecId = 0u; /*ID*/ + UINT16 axisSecId = 0u; /*ID*/ + UINT16 logicSecId = 0u; /*߼ID*/ + + + UINT16 physicalSectionSum = 0u; /*·Ŀ*/ + UINT16 axisSectionSum = 0u; /*ΰĿ*/ + UINT16 secLogSectionSum = 0u; /*ΰ߼Ŀ*/ + + RoutePhysicalSectionStruct * routePhysicalSectionStru = NULL; /*·νṹָ*/ + UINT16 * axisSecIdBuf = NULL; /*ΰIDָ*/ + UINT16 * logicSecIdBuf = NULL; /*ΰ߼IDָ*/ + + routePhysicalSectionStru = GetRouteSectionData(routeId); /*ȡ·νṹָ*/ + physicalSectionSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·Ŀ*/ + for(jj = 0u;jj < physicalSectionSum;jj++) + { + phySecId = routePhysicalSectionStru[jj].PhysicalSectionId; + + if(GetPhySecRLockBelongRouteId(phySecId) == routeId ) + {/*ʾ:Ϊ·գ߼εʱٶԱ·Ч*/ + axisSecIdBuf = GetPAxisSectionIdBuf(phySecId); /*ȡΰIDָ*/ + axisSectionSum = GetPAxisSectionSum(phySecId); /*ȡΰĿ*/ + for(kk = 0u; kk < axisSectionSum;kk++) + { + axisSecId = axisSecIdBuf[kk]; + logicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId); /*ȡΰ߼IDָ*/ + secLogSectionSum = GetAxisSecLogSectionSum(axisSecId); /*ȡΰ߼Ŀ*/ + for(mm = 0u;mm < secLogSectionSum;mm++ ) + { + logicSecId = logicSecIdBuf[mm]; + if(LOGSEC_LSXS_SET_STATE_YES == GetLogSecLinShiXianSuSetState(logicSecId)) + {/*(߼ʱ) (߼α·) <==> ʱεĽ·ɹ*/ + break; + } + } + if(mm < secLogSectionSum) + {/*ڴ˼Ѿҵһ߼ʱ٣ٱ*/ + break; + } + } + + if(kk < axisSectionSum) + {/*ڴѾҵһΰʱٵ߼Σٱ*/ + retVal = LOGSEC_LSXS_SET_STATE_YES; + break; + } + }/*if(GetPhySecRLockBelongRouteId(phySecId) == routeId )*/ + }/*for(jj = 0;jj < physicalSectionSum;jj++)*/ + return retVal; + +} + + +/* +* ·Ƿʱ +* ˵ const UINT16 routeId, ·Id +* ֵ + LOGSEC_LSXS_SET_STATE_NO 0x55 δʱ٣ڵ1ã + LOGSEC_LSXS_SET_STATE_YES 0xAA ʱ٣ȫδã +*/ +static UINT8 RouteOvlpLogSecLSXianSuSetCheck(const UINT16 routeId) +{ + UINT8 retVal = LOGSEC_LSXS_SET_STATE_NO; + + UINT16 jj = 0u; + UINT16 kk = 0u; + UINT16 mm = 0u; + UINT16 phySecId = 0u; /*ID*/ + UINT16 axisSecId = 0u; /*ID*/ + UINT16 logicSecId = 0u; /*߼ID*/ + + + UINT16 physicalSectionSum = 0u; /*·Ŀ*/ + UINT16 axisSectionSum = 0u; /*ΰĿ*/ + UINT16 secLogSectionSum = 0u; /*ΰ߼Ŀ*/ + + + UINT16 * routePhysicalSectionIdBuf = NULL; /*OVERLAPνṹָ*/ + UINT16 * axisSecIdBuf = NULL; /*ΰIDָ*/ + UINT16 * logicSecIdBuf = NULL; /*ΰ߼IDָ*/ + + UINT16 overlapLockedId = GetRouteOverlapLockedId(routeId); + + if(0u == overlapLockedId) + { + /*·ޱʱʱټĬͨΪδʱ*/ + retVal = LOGSEC_LSXS_SET_STATE_NO; + } + else + { + physicalSectionSum = GetOverlapPhySecSum(overlapLockedId); + routePhysicalSectionIdBuf = GetOverlapPhySecIdBuf(overlapLockedId); + + for(jj = 0u;jj < physicalSectionSum;jj++) + { + phySecId = routePhysicalSectionIdBuf[jj]; + + if(GetPhySecPLockBelongRouteId(phySecId) == routeId ) + {/*ʾ:Ϊ·գ߼εʱٶԱ·Ч*/ + axisSecIdBuf = GetPAxisSectionIdBuf(phySecId); /*ȡΰIDָ*/ + axisSectionSum = GetPAxisSectionSum(phySecId); /*ȡΰĿ*/ + for(kk = 0u; kk < axisSectionSum;kk++) + { + axisSecId = axisSecIdBuf[kk]; + logicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId); /*ȡΰ߼IDָ*/ + secLogSectionSum = GetAxisSecLogSectionSum(axisSecId); /*ȡΰ߼Ŀ*/ + for(mm = 0u;mm < secLogSectionSum;mm++ ) + { + logicSecId = logicSecIdBuf[mm]; + if(LOGSEC_LSXS_SET_STATE_YES == GetLogSecLinShiXianSuSetState(logicSecId)) + {/*(߼ʱ) (߼α·) <==> ʱεĽ·ɹ*/ + break; + } + } + if(mm < secLogSectionSum) + {/*ڴ˼Ѿҵһ߼ʱ٣ٱ*/ + break; + } + } + + if(kk < axisSectionSum) + {/*ڴѾҵһΰʱٵ߼Σٱ*/ + + break; + } + }/*if(GetPhySecPLockBelongRouteId(phySecId) == routeId )*/ + }/*for(jj = 0;jj < physicalSectionSum;jj++)*/ + + if(jj < physicalSectionSum) + { + retVal = LOGSEC_LSXS_SET_STATE_YES; + } + } + + return retVal; +} + +/* +* źŻʱټ(չ·) +* ˵ void +* ֵ void +*/ +void RouteSignalLSXianSuCalculate(void) +{ + UINT16 ii = 0u; + UINT16 routeId = 0u; /*·ID*/ + + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT16 signalId = 0u; /*źŻID*/ + + UINT16 routeSum = 0u; /*·Ŀ*/ + UINT16 signalSum = 0u; /*źŻĿ*/ + + UINT8 routeState = 0u; /*·״̬*/ + UINT8 chOvlpLSCheck = 0U; + UINT8 chLogSecLSCheck = 0U; + routeSum = GetRouteCurSum(); /*ȡ·ǰ*/ + signalSum = GetSignalCurSum(); /*ȡźŻǰ*/ + + /*ʱЧźŻʱٳʼΪδʱ*/ + for (ii = 0u; ii < signalSum; ii++) + { + signalId = GetSignalId(ii); + + SetSignalLinShiXianSuSetFlag(signalId, SIGNAL_LINSHIXIANSUSET_STATE_NO); + + } + + /*Խ·ΪʼźŻʱٱ־λ*/ + for (ii = 0u; ii < routeSum; ii++) + { + routeId = GetRouteId(ii); + startSignalId = GetRouteStartSignalId(routeId); + /*·״̬Żжʱ*/ + /*·ʼźŻʱЧԱʱ٣*/ + routeState = GetRouteState(routeId); /*ȡ·ǰ״̬*/ + if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState) || + (ROUTE_STATE_DELAY_UNLOCK == routeState) || + (ROUTE_STATE_NEAR_LOCK == routeState)) + { /*ʾ:·,ʱٶЧ*/ + chOvlpLSCheck = RouteOvlpLogSecLSXianSuSetCheck(routeId); + if (LOGSEC_LSXS_SET_STATE_NO == chOvlpLSCheck) + {/*δʱ*/ + chLogSecLSCheck = RouteIncludeLogSecLSXSSetCheck(routeId); + if (LOGSEC_LSXS_SET_STATE_YES == chLogSecLSCheck) + {/*·ʱ*/ + SetSignalLinShiXianSuSetFlag(startSignalId, SIGNAL_LINSHIXIANSUSET_STATE_YES); + } + } + else + {/*ʱ*/ + SetSignalLinShiXianSuSetFlag(startSignalId, SIGNAL_LINSHIXIANSUSET_STATE_YES); + } + + } + + + } +} + + +/* +* źŻʱټ(źŻμ) +* ˵ void +* ֵ void +*/ +void OutStationSignalLSXSCalculate(void) +{ + UINT16 ii = 0u; + UINT16 jj = 0u; + SignalDataStruct * pSignalDataStr = NULL; + UINT16 * pLogSecBuf = NULL; + UINT16 logSecSum = 0u; + UINT16 signalId = 0u; + + pSignalDataStr = GetSignalData(); /*ȡźŻ̬׵ַ*/ + + for(ii = 0u;ii < GetSignalCurSum();ii++) + {/*еźŻ*/ + + signalId = GetSignalId(ii); /*ȡźŻID*/ + + + logSecSum = GetSignalRelatedLogSecSum(signalId); /*ȡźŻʱٹ߼*/ + pLogSecBuf = GetSignalRelatedLogSecIdBuf(signalId);/*ȡźŻʱٹ߼ID*/ + + if(0u == logSecSum ) + { + + SetSignalLinShiXianSuSetFlag(signalId,SIGNAL_LINSHIXIANSUSET_STATE_YES); + + } + else + { + SetSignalLinShiXianSuSetFlag(signalId,SIGNAL_LINSHIXIANSUSET_STATE_NO); + for(jj = 0u;jj < logSecSum;jj++) + {/*еĹ߼*/ + + if(LOGSEC_LSXS_SET_STATE_YES == GetLogSecLinShiXianSuSetState(pLogSecBuf[jj])) + {/*һ߼ʱ٣˳վźŻʱ*/ + SetSignalLinShiXianSuSetFlag(signalId,SIGNAL_LINSHIXIANSUSET_STATE_YES); + break; + } + } + + } + + + } +} + + +/* +* źŻʱټ +* ˵ void +* ֵ void +*/ +void SignalLinShiXianSuFlagCalculate(void) +{ + UINT8 functionSwitchFlag = 0U; /*ʱټ㷽ʽ*/ + functionSwitchFlag = GetCiFunctionSwitchConfig(FUNC_SIGNAL_LSXS_TYPE); + + if (FUNC_SWITCH_ON == functionSwitchFlag) + { + /*ԸźŻΪʼ˵Ľ·Ƿʱ*/ + RouteSignalLSXianSuCalculate(); + } + else + { + /*źŻʱ*/ + OutStationSignalLSXSCalculate(); + } +} + + +/******************************·ؼ****************************/ +/* +* ָID·ԶźŽ·ԶʧЧ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 autoSigPropertyLoseEfficacyFlag, ·ԶźʧЧñ־ +* ֵ +* +*/ +void SetRevrRouteAutoSigInvalidFlag(const UINT16 routeId, const UINT8 autoSigPropertyLoseEfficacyFlag) +{ + UINT8 i = 0u; + UINT8 retVal = CI_SUCCESS; + UINT8 localCiId = 0u; + UINT8 autoSigRouteBelongCi = 0u; + UINT8 reverseRouteAutoSigRouteSum = 0u; /*·ԶźŽ·Ŀ*/ + UINT16 * reverseRouteAutoSigRouteBuf = NULL; /*·ԶźŽ·Id*/ + reverseRouteAutoSigRouteSum = GetReverseRouteIncludeRouteSum(routeId);/*ȡ·ԶźŽ·Ŀ*/ + reverseRouteAutoSigRouteBuf = GetReverseRouteIncludeRouteBuf(routeId);/*ȡ·ԶźŽ·ID*/ + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + for(i = 0u;i < reverseRouteAutoSigRouteSum;i++) + { + /*ȡԶź*/ + autoSigRouteBelongCi = GetRouteBelongCiId(reverseRouteAutoSigRouteBuf[i]); + if(localCiId == autoSigRouteBelongCi) + { + retVal = SetRouteAutoSigLoseEfficacyFlag(reverseRouteAutoSigRouteBuf[i], autoSigPropertyLoseEfficacyFlag); + if(CI_ERROR == retVal) + { + break; + } + } + /*ԶźŲDZ*/ + else + { + if(ROUTE_AUTOSIG_LOSE_SET_NO == autoSigPropertyLoseEfficacyFlag) + { + /**/ + AddCiSendToCiCmdInfo(CI_CMD_SET_AUTO_SIG_ROUTE_VALID, reverseRouteAutoSigRouteBuf[i],0u,autoSigRouteBelongCi); + } + } + } +} + + + +/* +* SPKS״̬Լη +* ˵ spksId SPKS ID + spksStatus SPKS״̬ +* ֵ +* cgh-ϲCID-2539-2\CID-2588-5 +*/ +void SetPhySecSpksFLockBySpksId(UINT16 spksId,UINT8 spksStatus) +{ + UINT16 phySecSumOfSpks = 0u; + UINT16 tmpPhySecId = 0u; + UINT16 spksIndex = 0u; + UINT16 phySecIndex = 0u; + UINT8 phySecFlockState = PHYSICAL_SECTION_FLOCK_YES; + UINT8 tmpRet = CI_ERROR; + UINT8 typeFlockType = 0u; + UINT8 CheckPhySecFlock = CI_ERROR; + UINT32 curCycNum = 0U; + UINT8 curSpksState = 0U; + + curSpksState = GetSpksState(spksId); + curCycNum = Get2oo2CurCycleNum(); + spksIndex = GetSpksConfigBufIndex(spksId); + + + if (SPKS_SUM_MAX > spksIndex) + { + /*SPKSť״̬*/ + if ((SPKS_STATUS_YES == spksStatus) && (SPKS_STATUS_YES != curSpksState)) + { + tmpRet = SetSpksState(spksId, spksStatus); + phySecFlockState = PHYSICAL_SECTION_FLOCK_YES; + SetSpksflockStartNum(spksId, curCycNum); + } + else if ((SPKS_STATUS_NO == spksStatus) && (SPKS_STATUS_NO != curSpksState)) + { + tmpRet = SetSpksState(spksId, spksStatus); + phySecFlockState = PHYSICAL_SECTION_FLOCK_NO; + SetSpksflockStartNum(spksId, 0U); + } + else + { + spksIndex = SPKS_SUM_MAX; + } + + + } + else + { + spksIndex = SPKS_SUM_MAX; + } + + + /* SPKSлȡӦΣӦóɶӦ״̬ */ + if ((spksIndex > 0u) && (spksIndex < SPKS_SUM_MAX) && (CI_SUCCESS == tmpRet)) + { + phySecSumOfSpks = GetSpksPhySecSumByIndex(spksId); + for (phySecIndex = 0u; phySecIndex < phySecSumOfSpks; phySecIndex++) + { + tmpPhySecId = GetSpksPhySecId(spksId,phySecIndex); + CheckPhySecFlock = CheckPhySecFlockBlongSpks(tmpPhySecId,spksId); + if ((tmpPhySecId > 0u) && (tmpPhySecId < PHYSICAL_SECTION_SUM_MAX)) + { + if(SPKS_STATUS_NO == spksStatus) + { + typeFlockType = GetPhySecFLockType(tmpPhySecId); + + if((PHY_SEC_FLOCK_TYPE_SPKS == typeFlockType)&&(CI_SUCCESS == CheckPhySecFlock)) + { + tmpRet = SetPhySecFLockState(tmpPhySecId,phySecFlockState); + } + } + else + { + tmpRet = SetPhySecFLockState(tmpPhySecId,phySecFlockState); + } + if(CI_ERROR == tmpRet) + { + break; + } + /*cgh-ϲCID-2539-2\CID-2588-5,SPKSη*/ + typeFlockType = GetPhySecFLockType(tmpPhySecId); + if ( SPKS_STATUS_YES == spksStatus ) + { + if(PHY_SEC_FLOCK_TYPE_CMD == typeFlockType) + { + SetPhySecFLockType(tmpPhySecId, PHY_SEC_FLOCK_TYPE_SPKSCMD);/*SPKS η */ + } + else if(PHY_SEC_FLOCK_TYPE_NONE == typeFlockType) + { + SetPhySecFLockType(tmpPhySecId, PHY_SEC_FLOCK_TYPE_SPKS);/*¼ηSPKSµ*/ + } + else + { + /*ѾSPKS*/ + } + } + else if (SPKS_STATUS_NO == spksStatus) + { + if((PHY_SEC_FLOCK_TYPE_SPKS == typeFlockType)&&(CI_SUCCESS == CheckPhySecFlock)) + { + SetPhySecFLockType(tmpPhySecId, PHY_SEC_FLOCK_TYPE_NONE);/*֮ǰֻSPKSȡ޷*/ + } + else if((PHY_SEC_FLOCK_TYPE_SPKSCMD == typeFlockType)&&(CI_SUCCESS == CheckPhySecFlock)) + { + SetPhySecFLockType(tmpPhySecId, PHY_SEC_FLOCK_TYPE_CMD);/*֮ǰSPKSȡSPKSֻʣ*/ + } + else + { + /*ѾȡSPKS,жSPKS*/ + } + } + else + { + /**/ + } + } + else + { + /*޲*/ + } + } + + } +} + +/* +* ȡ豸״̬,״̬תΪӦ +* ˵ UINT16 devType 豸 +* UINT16 devId 豸ID +* UINT16 const chkDevStatus 豸״̬ +* ֵ 0 ʧ +* >0 豸״̬ +*/ +UINT8 GetOtherCiDevStatus(UINT16 const devType,UINT16 const devId,UINT16 const chkDevStatus) +{ + UINT8 devState = 0u; + UINT8 tmpDevState = 0u; + UINT8 tmpPsdVobcCmd = 0u; + UINT8 tmpColor = 0u; + UINT8 ttmpDevState = 0u; + UINT8 psdMutualLockState = 0u; + UINT16 tempdevId = 0u; /*ʱ豸ID*/ + UINT8 tempdevState = 0u; /*ʱ豸״̬*/ + + switch(devType) + { + case CI_DEVICE_TYPE_SWITCH: /**/ + tmpDevState = GetSwitchCurPosition(devId); + if(SWITCH_POSITION_DINGWEI == tmpDevState) + { + devState = OTHER_CI_SWTICH_STATUS_DINGWEI; + } + else if (SWITCH_POSITION_FANWEI == tmpDevState) + { + devState = OTHER_CI_SWTICH_STATUS_FANWEI; + } + else + { + devState = 0u; + } + break; + case CI_DEVICE_TYPE_SIGNAL: /*źŻ*/ + tmpColor = GetSignalCurColor(devId); + if (tmpColor > 0u) + { + tmpDevState = GetSignalOpenCloseState(tmpColor); + if (SIGNAL_OPEN == tmpDevState) + { + devState = OTHER_CI_SIGNAL_STATUS_OPEN; + } + else + { + devState = OTHER_CI_SIGNAL_STATUS_CLOSE; + } + } + else + { + devState = 0u; + } + break; + case CI_DEVICE_TYPE_ROUTE: /*·*/ + tmpDevState = GetDiaoCheRouteOpenState(devId); + if (CI_SUCCESS == tmpDevState) + { + devState = OTHER_CI_ROUTE_STATUS_OPEN_YES; + } + else + { + devState = OTHER_CI_ROUTE_STATUS_OPEN_NO; + } + break; + case CI_DEVICE_TYPE_ESB: /*վ̨رհť*/ + tmpDevState = GetEsbState(devId); + ttmpDevState = GetEsbCutState(devId); + if (ESB_STATE_VALID_NO == tmpDevState) + { + devState = OTHER_CI_ESB_STATUS_UNVALID; + } + else if (ESB_STATE_VALID_YES == tmpDevState) + { + if (ESB_CUT_YES == ttmpDevState) + { + devState = OTHER_CI_ESB_STATUS_UNVALID; + } + else + { + devState = OTHER_CI_ESB_STATUS_VALID; + } + } + else + { + devState = 0u; + } + break; + case CI_DEVICE_TYPE_PSD: /*վ̨*/ + tmpDevState = GetPsdState(devId); + tmpPsdVobcCmd = GetPsdVobcCmd(devId); + psdMutualLockState = GetPsdMutualLockRemoveState(devId); + if ((PSD_MUTUALLOCK_REMOVE_YES == psdMutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == psdMutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == psdMutualLockState)) + { + /* ɼֱΪŹر */ + devState = OTHER_CI_PSD_STATUS_CLOSE; + } + else if (PSD_STATE_OPEN == tmpDevState) + { + if (tmpPsdVobcCmd == VOBCTOCI_COMMAND_TYPE_PSDOPEN) + { + /* յVOBCToCIֱΪռô */ + devState = OTHER_CI_PSD_STATUS_OCCUPY_OPEN; + } + else + { + /* δյVOBCToCIֱΪŴ */ + devState = OTHER_CI_PSD_STATUS_OPEN; + } + } + else if (PSD_STATE_CLOSE == tmpDevState) + { + /* δɼֱΪŹر */ + devState = OTHER_CI_PSD_STATUS_CLOSE; + } + else + { + devState = 0u; + } + break; + case CI_DEVICE_TYPE_GARAGEDOOR: /**/ + tmpDevState = GetGaragedoorState(devId); + if (GARAGE_DOOR_STATE_OPEN == tmpDevState) + { + devState = OTHER_CI_GARAGEDOOR_OPEN; + } + else if (GARAGE_DOOR_STATE_CLOSE == tmpDevState) + { + devState = OTHER_CI_GARAGEDOOR_CLOSE; + } + else + { + devState = 0u; + } + break; + case CI_DEVICE_TYPE_WASHMACHINE: /* ϴ */ + tmpDevState = GetTrainEmergencyStopState(devId); + if (WASHMACHINE_COL_FALUT_NO_2 == tmpDevState) + { + devState = OTHER_CI_WASH_READ_NO; + } + else + { + devState = OTHER_CI_WASH_READ_YES; + } + break; + case CI_DEVICE_TYPE_SPKS: /* SPKS */ + tmpDevState = GetSpksState(devId); + ttmpDevState = GetSpksCutState(devId); + if (SPKS_STATUS_NO == tmpDevState) + { + devState = OTHER_CI_SPKS_NO; + } + else + { + if (ttmpDevState == SPKS_CUT_NO) + { + devState = OTHER_CI_SPKS_YES; + } + else + { + devState = OTHER_CI_SPKS_NO; + } + } + break; + case CI_DEVICE_TYPE_AXISSEC: /**/ + tmpDevState = CheckLogContactOccState(devId, &tempdevId, &tempdevState); + if (CI_SUCCESS == tmpDevState) + { + devState = OTHER_CI_PHYSICAL_OCCU_NO; + } + else + { + devState = OTHER_CI_PHYSICAL_OCCU_YES; + } + break; + case CI_DEVICE_TYPE_WASH_LINE: /* ϴ */ + tmpDevState = GetDownWashAllowState(devId);/*ȡϴģʽϴͬ״̬*/ + if (WASH_COL_STATE_ALLOW_YES == tmpDevState) + { + devState = OTHER_CI_WASH_LINE_ALLOW_YES; + } + else + { + devState = OTHER_CI_WASH_LINE_ALLOW_NO; + } + break; + case CI_DEVICE_TYPE_FLOODGATE:/**/ + devState = GetFloodGateCurLogicCloseState(devId); + break; + /*ߵ*/ + case CI_DEVICE_TYPE_CONNECT_SWITCH: + tmpDevState = CheckLogContactSwitchState(devId, (UINT8)chkDevStatus, &tempdevId, &tempdevState); + if (CI_SUCCESS == tmpDevState) + { + devState = (UINT8)chkDevStatus; + } + else + { + devState = OTHER_CI_CONNECT_SWITCH_NO; + } + break; + case CI_DEVICE_TYPE_PHYSEC:/* η״̬ η 20220530-lyj */ + tmpDevState = GetPhySecFLockType(devId); + if (PHY_SEC_FLOCK_TYPE_NONE == tmpDevState) + { + devState = OTHER_CI_PHYSICAL_FENGSUO_NO; + } + else + { + devState = OTHER_CI_PHYSICAL_FENGSUO_YES; + } + + break; + case CI_DEVICE_TYPE_WASH_ALLOW_PASS: /*ϴͬͨ*/ + tmpDevState = GetDownWashAllowPassState(devId); + if (WASH_COL_STATE_ALLOW_PASS_YES == tmpDevState) + { + devState = OTHER_CI_DOWNWASH_ALLOW_PASS_YES; + } + else + { + devState = OTHER_CI_DOWNWASH_ALLOW_PASS_NO; + } + break; + default: + /*ɴ֧ devState=0U */ + break; + } + + return devState; +} + +/* +* 豸ͻȡʧʱ +* ˵ UINT16 devType 豸 +* ֵ 0 豸״̬ +*/ +UINT8 GetOtherCiCheckDevStateType(UINT16 const devType) +{ + UINT8 retType = 0u; + switch(devType) + { + case CI_DEVICE_TYPE_SWITCH: /**/ + retType = ETYPE_OTHER_SWITCH_POSITION_ERROR; + break; + case CI_DEVICE_TYPE_SIGNAL: /*źŻ*/ + retType = ETYPE_OTHER_SIGNAL_CHECK; + break; + case CI_DEVICE_TYPE_ROUTE: /*·*/ + retType = ETYPE_OTHER_ROUTE_CHECK; + break; + case CI_DEVICE_TYPE_ESB: /*վ̨رհť*/ + retType = ETYPE_ESB_VALID; + break; + case CI_DEVICE_TYPE_PSD: /*վ̨*/ + retType = ETYPE_PSD_CLOSE_NO; + break; + case CI_DEVICE_TYPE_GARAGEDOOR: /**/ + retType = ETYPE_OTHER_GARAGEDOOR_OPEN_NO; + break; + case CI_DEVICE_TYPE_WASHMACHINE: /* ϴ */ + retType = ETYPE_WASH_MACHINE_UNVALID; + break; + case CI_DEVICE_TYPE_SPKS: /* SPKS */ + retType = ETYPE_SPKS_STATE_UP; + break; + case CI_DEVICE_TYPE_AXISSEC: /**/ + retType = ETYPE_PS_MERGY_OCU_STATE; + break; + case CI_DEVICE_TYPE_WASH_LINE: /*ϴ*/ + retType = ETYPE_OTHER_WASH_LINE_NOT_ALLOW; + break; + case CI_DEVICE_TYPE_FLOODGATE:/**/ + retType = ETYPE_FLOODGATE_CLOSESTATE; + break; + case CI_DEVICE_TYPE_PHYSEC:/**/ + retType = ETYPE_PS_FLOCK_STATE; + break; + case CI_DEVICE_TYPE_WASH_ALLOW_PASS: /*ϴͬͨ*/ + retType = ETYPE_OTHER_DOWNWASH_NOT_ALLOW_PASS; + break; + default: + /*ɴ*/ + break; + } + + return retType; +} + + +/* +* ȡģʽ־ +* ˵ void +* ֵ ģʽ 0x55: վ 0xAA:п 0x71:̨ 0xFF:վ +*/ +UINT8 GetCiModeFlag(void) +{ + return ciMode; +} + +/* +* ģʽ־ +* ˵ ģʽ 0x55: ǿվ 0xAA:п 0x71:̨ 0xFF: 0xBB:վ +* ֵ void +*/ +void SetCiModeFlag(UINT8 setFlag) +{ + UINT8 localCi = 0U; + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + if ((CI_MODE_ATS == setFlag) || (CI_MODE_CONSOLE == setFlag) + ||(CI_MODE_CI_LOCAL == setFlag) ||(CI_MODE_CONSTRA_LOCAL == setFlag) || ((CI_MODE_APPLAY_LOCAL == setFlag))) + { + if ((CI_MODE_ATS == ciMode) && (CI_MODE_ATS != setFlag)) + { + ReleaseCtrlPower(localCi, CONTRAL_POWER_NO, 0U, 0U); + } + else + { + ; + } + ciMode = setFlag; + } + else + { + /**/ + } + + if (CI_MODE_ATS == setFlag) + { + DefaultCtrlPowerDeal(localCi); + } + else + { + ; + } +} + + + + +/* +* ȡȫվʱٱ־ +* ˵ void +* ֵ 0x55: Ч 0xAA:Ч +*/ +UINT8 GetAllTsrFlag(void) +{ + return g_AllTsrFlag; +} + +/* +* ȫվʱٱ־ +* ˵ 0x55: Ч 0xAA:Ч +* ֵ void +*/ +void SetAllTsrFlag(UINT8 setFlag) +{ + if ((CI_ALL_TSR_VALID == setFlag) || (CI_ALL_TSR_UNVALID == setFlag)) + { + g_AllTsrFlag = setFlag; + } + else + { + /**/ + } +} + +/* +* ȡȫѩģʽ +* ˵ void +* ֵ 0x55: Ч 0xAA:Ч +*/ + +UINT8 GetAllSnowModel(void) +{ + return g_AllSnowModel; +} + +/* +* ȡȫѩģʽ +* ˵ 0x55: Ч 0xAA:Ч +* ֵ void +*/ +void SetAllSnowModel(UINT8 setmodle) +{ + if ((CI_ALL_SNOW_VALID == setmodle) || (CI_ALL_SNOW_UNVALID == setmodle)) + { + g_AllSnowModel = setmodle; + } + else + { + /**/ + } +} + +/* +* ȡITEȫг״̬ +* ˵void +* ֵ0x55 гITE +* 0xAA ʹITE +* 0xFF Ĭֵ +* Created By LQ 2024.07.12 +*/ +UINT8 GetIteLineCutState(void) +{ + return g_IteLineCutState; +} + +/* +* ITEȫг״̬ +* ˵UINT8 cSetState õITEȫг״̬ +* ֵ +* Created By LQ 2024.07.12 +*/ +void SetIteLineCutState(UINT8 cSetState) +{ + if ((CI_ITE_LINE_CUT_VALID == cSetState) || (CI_ITE_LINE_CUT_INVALID == cSetState) || (CI_ITE_LINE_CUT_DEFAULT == cSetState)) + { + g_IteLineCutState = cSetState; + } + else + { + /**/ + } +} + +/* +* ȡȫʱ״̬ +* ˵ void +* ֵ 0x55: Ч 0xAA:Ч +*/ + +UINT8 GetAllLineTsrState(void) +{ + return g_AllLineTsrState; +} + +/* +* ȫʱ״̬ +* ˵ 0x55: Ч 0xAA:Ч +* ֵ void +*/ +void SetAllLineTsrState(UINT8 cSetState) +{ + if ((CI_ALL_LINE_TSR_VALID == cSetState) || (CI_ALL_LINE_TSR_UNVALID == cSetState)) + { + g_AllLineTsrState = cSetState; + } + else + { + ; /**/ + } +} + +/* +* ȡȫʱٶ +* ˵ void +* ֵ ȫʱֵ +*/ + +UINT8 GetAllLineTsrSpeed(void) +{ + return g_AllLineTsrSpeed; +} + +/* +* ȫʱٶ +* ˵ UINT8 cSpeed ٶֵ +* ֵ void +*/ +void SetAllLineTsrSpeed(UINT8 cSpeed) +{ + g_AllLineTsrSpeed = cSpeed; +} + +/* +* ȡԳ״̬ +* ˵ void +* ֵ Գ״̬ + CI_TRAIN_TEST_OFF 0xFF Գ + CI_TRAIN_TEST_START 0x01 Գť + CI_TRAIN_TEST_ON 0x02 Գ + CI_TRAIN_TEST_STOP 0x03 Գ + +*/ +UINT8 GetCiTrainTestStatus(void) +{ + return ciTrainTestStatus; +} + +/* +* Գ״̬ +* ˵ Գ״̬ + CI_TRAIN_TEST_OFF 0xFF Գ + CI_TRAIN_TEST_START 0x01 Գť + CI_TRAIN_TEST_ON 0x02 Գ + CI_TRAIN_TEST_STOP 0x03 Գ +* ֵ void +*/ +void SetCiTrainTestStatus(UINT8 flag) +{ + if ((CI_TRAIN_TEST_OFF == flag) || (CI_TRAIN_TEST_START == flag) + || (CI_TRAIN_TEST_ON == flag) || (CI_TRAIN_TEST_STOP == flag)) + { + ciTrainTestStatus = flag; + } + else + { + /**/ + } +} + +/* +* ȡSQJ״̬ +* ˵ void +* ֵ SQJ״̬ +* 0x55 豸״̬Ч +* 0xAA 豸״̬Ч +*/ +UINT8 GetCommTrainTestCLDSQJStatus(void) +{ + return comm_Train_Test_SQJ_CLD_State; +} + +/* +* ԳȡYSKJ״̬ +* ˵ void +* ֵ YSKJ״̬ +* 0x55 豸״̬Ч +* 0xAA 豸״̬Ч +*/ +UINT8 GetCommTrainTestSCXYSKJStatus(void) +{ + return comm_Train_Test_YSKJ_SCX_State; +} + +/* +* ȡTYSJ״̬ +* ˵ void +* ֵ TYSJ״̬ +* 0x55 豸״̬Ч +* 0xAA 豸״̬Ч +*/ +UINT8 GetCommTrainTestCLDTYSJStatus(void) +{ + return comm_Train_Test_TYSJ_CLD_State; +} + +/* +* ԳȡSQAJ״̬ +* ˵ void +* ֵ SQAJ״̬ +* 0x55 豸״̬Ч +* 0xAA 豸״̬Ч +*/ +UINT8 GetCommTrainTestSCXSQAJStatus(void) +{ + return comm_Train_Test_SQAJ_SCX_State; +} + +/* +* ͨŽӿڵԳSQAJ״̬ +* ˵ ԳSQAJ״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0xAA Ч״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0x55 Ч״̬ +* ֵ void +*/ +void SetCommTrainTestSCXSQAJStatus(UINT8 flag) +{ + if ((COMM_TRAIN_TEST_DEV_STATE_VALID == flag) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == flag)) + { + comm_Train_Test_SQAJ_SCX_State = flag; + } +} + +/* +* ͨŽӿڵԳYSKJ״̬ +* ˵ ԳYSKJ״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0xAA Ч״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0x55 Ч״̬ +* ֵ void +*/ +void SetCommTrainTestSCXYSKJStatus(UINT8 flag) +{ + if ((COMM_TRAIN_TEST_DEV_STATE_VALID == flag) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == flag)) + { + comm_Train_Test_YSKJ_SCX_State = flag; + } +} + +/* +* ͨŽӿڵijTYSJ״̬ +* ˵ TYSJ״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0xAA Ч״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0x55 Ч״̬ +* ֵ void +*/ +void SetCommTrainTestCLDTYSJStatus(UINT8 flag) +{ + if ((COMM_TRAIN_TEST_DEV_STATE_VALID == flag) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == flag)) + { + comm_Train_Test_TYSJ_CLD_State = flag; + } +} + +/* +* ͨŽӿڵijSQJ״̬ +* ˵ SQJ״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0xAA Ч״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0x55 Ч״̬ +* ֵ void +*/ +void SetCommTrainTestCLDSQJStatus(UINT8 flag) +{ + if ((COMM_TRAIN_TEST_DEV_STATE_VALID == flag) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == flag)) + { + comm_Train_Test_SQJ_CLD_State = flag; + } +} + +/* +* Զ־ +* ˵UINT8 virCIid ID +* UINT8 setFlag õԶ־ +* ֵ +*cgh-ϲECI11.0: +*/ +void SetAutoTriggerLogicManage(UINT8 virCIid, UINT8 setFlag) +{ + UINT16 ii = 0u; + UINT16 routeCurSum = 0; /*·Ŀ*/ + UINT16 routeId = 0; /*·ID*/ + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + /*·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = GetRouteId(ii); /*ȡ·ID*/ + SetSigleRouteAutoTriggerManage(virCIid, routeId, setFlag); /*ԶÿһԶ·Զ־*/ + } +} + +/* +* Զ־ +* ˵ UINT8 setFlag õԶ־ +* ֵ +*/ +void SetAutoTriggerFlag(UINT8 setFlag) +{ + + if ((AUTO_TRIGGER_SET_YES == setFlag) || (AUTO_TRIGGER_SET_NO == setFlag)) + { + AutoTriggerFlag = setFlag; /*Զ־*/ + } + +} + +/* +* ȡԶ־ +* ˵ +* ֵ Զ־ +*/ +UINT8 GetAutoTriggerFlag(void) +{ + return AutoTriggerFlag; /*ȡԶ־*/ +} + +/* +* гǷռѹ +* ˵ const UINT16 routeId ·ID +* ֵ CI_SUCCESS: δռѹ +* CI_ERROR: ռѹ +*/ +UINT8 RouteTriggerOccu(const UINT16 routeId) +{ + /*Ŀǰѯ֧CBTCΰĵϢʴ˰汾CBTC·ҲʽдڻŻ*/ + /*·Զдӽ˳෴*/ + UINT8 secOccupyState = 0u; /*ռ״̬*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 switchPos = 0u; /*λ*/ + UINT8 ii = 0u; /*±*/ + UINT8 kk = 0u; + UINT8 isSwitchPosRight = 1u; /*λǷȷ Ĭ1Ϊȷ0Ϊ*/ + UINT8 isSecOccupied = 1u; /*Ƿռñ־ Ĭ1Ϊδռã0Ϊռ*/ + RouteTriggerPhySectionStruct* pTriggerPhySecStru = NULL; + UINT8 retVal = CI_ERROR; + UINT8 SwitchCurPosition = SWITCH_POSITION_INVALID; + UINT8 PhySecType = 0u; /*ָID*/ + UINT16 SwitchPhySectionId = 0u; /*ָIDID*/ + UINT8 jj = 0U; + + if ((0u == routeId) || (ROUTE_SUM_MAX <= routeId)) + { + retVal = CI_ERROR; + } + else + { + pTriggerPhySecStru = GetRouteBlocTrigLogSecStru(routeId); + if (NULL != pTriggerPhySecStru) + { + /*ռãǰλȷελþȷ򴥷 + ǰλòȷΪǰռõı־ЧǷռãռ򲻴 + ռãѭ*/ + for (jj = 0U; jj < ROUTE_BLOC_TRIGGERPHY_NUM; jj++) + { + isSecOccupied = 1U; + for (ii = 0u; ii < pTriggerPhySecStru[jj].TriggerPhySecSum; ii++) + { + secOccupyState = GetPhySecCurMergeState(pTriggerPhySecStru[jj].TriggerPhySecIdBuf[ii]); + + if (SECTION_OCCUPY_NO != secOccupyState) + {/*ηǿУռúͽӽ*/ + + isSecOccupied = 0u;/*øӽռ*/ + } + else + { + /*޲*/ + } + if (0u == isSecOccupied) + { /*ռռλãһλò򲻴*/ + /*漰ĵλǷȷ*/ + isSwitchPosRight = 1u;/*õλñ־Ϊȷ*/ + PhySecType = GetPhySecType(pTriggerPhySecStru[jj].TriggerPhySecIdBuf[ii]); + if (PHYSICAL_SEC_TYPE_NOSWITCH == PhySecType) + {/*޲*/ + + /*ñ־*/ + } + else + {/*в*/ + + /*жϵλǷ෴λ*/ + for (kk = 0u; kk < pTriggerPhySecStru[jj].SwitchSum; kk++) + { + switchId = pTriggerPhySecStru[jj].ConditionSwitchStru[kk].SwitchId; + switchPos = pTriggerPhySecStru[jj].ConditionSwitchStru[kk].SwitchPosition; + SwitchPhySectionId = GetSwitchPhySectionId(switchId); + if (SwitchPhySectionId == pTriggerPhySecStru[jj].TriggerPhySecIdBuf[ii]) + {/*Ϊ*/ + + SwitchCurPosition = GetSwitchCurPosition(switchId); + if (SWITCH_POSITION_DINGWEI == switchPos) + {/*涨λ*/ + + if (SWITCH_POSITION_FANWEI == SwitchCurPosition) + {/*λڷλ*/ + + isSwitchPosRight = 0u;/*õλô󣬲㴥*/ + } + else + { + /*޲*/ + } + + } + else + {/*涨λ*/ + + if (SWITCH_POSITION_DINGWEI == SwitchCurPosition) + {/*λڶλ*/ + + isSwitchPosRight = 0u;/*õλô*/ + } + else + { + /*޲*/ + } + + } + if (0u == isSwitchPosRight) + { + isSecOccupied = 1u;/*ռñ־Ϊδռ*/ + break; /*һλôΪ㴥*/ + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } + + }/**/ + + }/*в*/ + } + else + { + /*޲*/ + } + + + }/*ӽ*/ + + /*жϸӽǷӽ*/ + if ((0u == isSecOccupied) && (0u != isSwitchPosRight)) + {/*ռ ռ֮ǰĵλþȷ*/ + + retVal = CI_SUCCESS;/*ؽӽ*/ + } + else + { + /*޲*/ + } + } + } + else + { + retVal = CI_ERROR; + } + + + + } + return retVal; +} +/* +* жǷȡ +* ȡ־ȡ򲻱 +* ˵ UINT16 routeId ·ID +* ֵ CI_SUCCESS: δȡ +* CI_ERROR: ȡ +*/ +UINT8 CancleAutoFlag(UINT16 routeId) +{ + UINT8 allAutoReturnSetFlag = ALL_AUTO_RETURN_SET_NO; + UINT8 autoReturnSetFlag = AUTO_RETURN_SET_NO; + UINT8 autoRouteSetFlag = AUTO_ROUTE_SET_NO; + UINT8 autoTriggerSetFlag = AUTO_TRIGGER_SET_NO; + UINT8 reVal = CI_SUCCESS; + + allAutoReturnSetFlag = GetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(routeId)); + autoReturnSetFlag = GetAutoReturnSetFlag(GetRouteAutoReturnId(routeId)); + autoRouteSetFlag = GetAutoRouteSetFlag(GetRouteAutoRouteId(routeId)); + autoTriggerSetFlag = GetRouteAutoTriggerFlag(routeId); + if ((ALL_AUTO_RETURN_SET_YES == allAutoReturnSetFlag) ||(AUTO_RETURN_SET_YES == autoReturnSetFlag) + || (AUTO_ROUTE_SET_YES == autoRouteSetFlag)) + {/*·Զ·Զ־ȡԶ־ 2018.10.24*/ + SetAutoRouteSetFlag(GetRouteAutoRouteId(routeId),AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(GetRouteAutoReturnId(routeId),AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(routeId),ALL_AUTO_RETURN_SET_NO); + + reVal = CI_ERROR; + } + if (AUTO_TRIGGER_SET_YES == autoTriggerSetFlag) + { /*·ΪԶԶ־ãȡԶ־*/ + SetRouteAutoTriggerFlag(routeId, AUTO_TRIGGER_SET_NO); + reVal = CI_ERROR; + } + return reVal; +} +/* +* жǷԾ +* ԾգԾ +* ˵ UINT16 axisSectionId ID +* ֵ CI_SUCCESS: +* CI_ERROR: +*/ +UINT8 CheckJumpLockApply(UINT16 axisSectionId) +{ + UINT16 routeRlockId = 0u; /*·ID*/ + UINT16 routePlockId = 0u; /*η·ID*/ + UINT8 routeType = 0u;/*·*/ + UINT8 phySecFLockState = 0u; /*η״̬,ӦSPKS*/ + UINT8 reVal = CI_ERROR; + AxisSwitchStruct* axisSwitchStru = NULL; + UINT8 axisSwitchSum = 0u; + UINT8 ii = 0u; + UINT8 switchCurPosition = 0u; /*ǰλ*/ + UINT8 routeState = 0u; /*ԾյĽ·״̬*/ + UINT16 physicalSecId = 0u; + UINT8 retFlag = 0u; /*ʱ*/ + UINT16 curSwitchId = 0u; /*ʱ*/ + UINT8 switchFLockState = 0u; /*ʱ*/ + UINT16 jj = 0U; + UINT16 floodGateSum = 0U; /**/ + UINT16* floodGateIdBuf = NULL;/*ʱ*/ + UINT8 floodState = 0u;/*״̬*/ + UINT8 routeLevel = 0u; + UINT8 routeTrainNear = 0u; + UINT8 physicalCheck = 0u; + UINT8 phyPLockRouteState = 0u; + + physicalSecId = GetAxisSecRelativePhySecId(axisSectionId); + routeRlockId = GetPhySecRLockBelongRouteId(physicalSecId);/*ν··ID*/ + routePlockId = GetPhySecPLockBelongRouteId(physicalSecId);/*η·ID*/ + routeType = GetRouteType(routeRlockId);/*·*/ + phySecFLockState = GetPhySecFLockState(physicalSecId);/*ȡη״̬SPKSǷʵʩ*/ + axisSwitchSum = GetAxisSwitchSum(axisSectionId); + axisSwitchStru = GetAxisSwitchIdStru(axisSectionId); + routeState = GetRouteState(routeRlockId); /*ȡ·״̬*/ + physicalCheck = PhysicalIntruSecVainCheck(physicalSecId); /*μ*/ + + if (NULL == axisSwitchStru) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + /*·գ鲻ͨ*/ + if (CI_SUCCESS == reVal) + { + if ((0u < routeRlockId) && ( ROUTE_TYPE_DIAOCHE == routeType)) + { + reVal = CI_ERROR; + } + } + + if ((0u < routePlockId) && (CI_SUCCESS == reVal)) + { + routeLevel = GetRouteLevel(routePlockId); /*ȡ·ල*/ + phyPLockRouteState = GetRouteState(routePlockId); /*ȡ·״̬*/ + /*CBTC*/ + if(ROUTE_LEVEL_CBTC == routeLevel) + { + reVal = CI_SUCCESS; /*سɹ*/ + } + else + { + routeTrainNear = RouteHaveTrainNear(routePlockId); + /*·гӽҽ·״̬ΪӽŻԤȿ*/ + if ((CI_SUCCESS == routeTrainNear) && + ((ROUTE_STATE_YUXIAN_OPEN == phyPLockRouteState)||(ROUTE_STATE_NEAR_OPEN == phyPLockRouteState))) + { + /*ʧ*/ + reVal = CI_ERROR; + } + } + } + if ((CI_SUCCESS == reVal) &&(PHYSICAL_SECTION_FLOCK_YES == phySecFLockState)) + { + /*δڷ״̬(SPKSʵʩ)*/ + + reVal = CI_ERROR; + } + if ((CI_SUCCESS == reVal)&&( CI_ERROR == physicalCheck)) + { + /*αռ*/ + + reVal = CI_ERROR; + } + if ((CI_SUCCESS == reVal)&&(0u < routeRlockId)) + { + routeLevel = GetRouteLevel(routeRlockId); /*ȡ·ල*/ + /*ʽ*/ + if(ROUTE_LEVEL_BLOC == routeLevel) + { + routeTrainNear = RouteHaveTrainNear(routeRlockId); + /*·гӽҽ·״̬ΪӽŻԤȿ*/ + if ((CI_SUCCESS == routeTrainNear) && + ((ROUTE_STATE_YUXIAN_OPEN == routeState)||(ROUTE_STATE_NEAR_OPEN == routeState))) + { + + reVal = CI_ERROR; + } + } + else + { + reVal = CI_SUCCESS; + } + + } + if (CI_SUCCESS == reVal) + { + /*(λȷңûڶңδ*/ + + if ((0u !=axisSwitchSum) && (NULL != axisSwitchStru)) + { + for (ii = 0u;ii< axisSwitchSum;ii++) + { + curSwitchId = axisSwitchStru[ii].SwitchId; + if ((0u != curSwitchId) && (UINT16_MAX != curSwitchId)) + {/*IDЧ*/ + switchCurPosition = GetSwitchCurPosition(curSwitchId); /*ȡǰλ*/ + retFlag = checkSwtLastValDrvPosStayorNot(curSwitchId,switchCurPosition); /*һǷЧ*/ + switchFLockState = GetSwitchFLockState(curSwitchId); /*ȡ״̬*/ + if ((axisSwitchStru[ii].SwitchPosition != switchCurPosition) || (CI_ERROR == retFlag) || (SWITCH_LOCK_FENGSUO_YES == switchFLockState)) + {/*жϵǰĵλǰλһͬijһȻЧ򣨵*/ + reVal = CI_ERROR; + break; + } + else + { + reVal = CI_SUCCESS; + } + } + + } + } + + } + + if (CI_SUCCESS == reVal) + { + if (0u < physicalSecId) + { + floodGateSum = GetPhySecLocatedFloodSum(physicalSecId); + if (0U < floodGateSum) + { + floodGateIdBuf = GetPhySecLocatedFloodId(physicalSecId); + if (NULL != floodGateIdBuf) + { + for (jj = 0U; jj < floodGateSum; jj++) + { + /*зţ״̬*/ + floodState = GetFloodGateCurLogicCloseState(floodGateIdBuf[jj]); + if (FLOOD_GATE_OPEN != floodState) + { + reVal = CI_ERROR; + break; + } + else + { + reVal = CI_SUCCESS; + } + } + } + else + { + reVal = CI_ERROR; /*ȡʧܣʧ*/ + } + } + } + } + return reVal; +} + +/* +* ָ·ڵָ߼IDǰָ߼IDUTռ +* ˵ UINT16 routeId, ·ID +* UINT16 physicalId, ߼ID +* ֵ CI_ERROR UTռ +* CI_SUCCESS UTռ +*/ +UINT8 CheckBeforLogSecinRouteHaveNoUT(UINT16 routeId, UINT16 logSectionId) +{ + UINT8 retVal = CI_ERROR; + UINT16 logSecNum = 0u; + UINT16* logSecIdBuf = NULL; + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 logSecOccState = LOGICSECTION_OCCUPY_UT; + UINT16 checkLogSecNum = 0u; + UINT8 checkSulicTrain = CI_ERROR; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + /** κϷ*/ + if ((routeId >= 1u) && (routeId < ROUTE_SUM_MAX) + && (LOGIC_SECTION_SUM_MAX > bufIndex)) + { + /**ȡ·߼ID*/ + logSecNum = GetRouteLogSectionSum(routeId); + logSecIdBuf = GetRouteLogSectionIdBuf(routeId); + if (NULL != logSecIdBuf) + { + for (ii = 0u; ii < logSecNum; ii++) + { + if (logSecIdBuf[ii] == logSectionId) + { + break; + } + } + + if (ii == logSecNum) + { + /** ·в߼*/ + retVal = CI_ERROR; + } + else + { + checkLogSecNum = ii + 1U; + for (jj = 0u; jj < checkLogSecNum; jj++) + { + logSecOccState = GetLogSecOccupyState(logSecIdBuf[jj]); + checkSulicTrain = IsLogicHaveNoSupicTrain(logSecIdBuf[jj]); + /** ߼ûCTռûпУUTռûȡռ״̬ʧܣ߼CTռس*/ + if (((LOGICSECTION_OCCUPY_CT != logSecOccState) && (LOGICSECTION_OCCUPY_NO != logSecOccState)) + || ((LOGICSECTION_OCCUPY_CT == logSecOccState) && (CI_ERROR == checkSulicTrain))) + { + break; + } + } + + if (jj == checkLogSecNum) + { + /** ·ڵһ߼ξUTռ */ + retVal = CI_SUCCESS; + } + else + { + /** ·ڵһ߼UTռ */ + retVal = CI_ERROR; + } + } + } + else + { + /** ʧ*/ + retVal = CI_ERROR; + } + } + else + { + /**ʧ*/ + retVal = CI_ERROR; + } + return retVal; +} + +/* +* жǷ߼Ծ +* ߼ԾգԾ +* ˵ UINT16 logSectionId ߼ID +* ֵ CI_SUCCESS: +* CI_ERROR: +*/ +UINT8 CheckLogJumpLockApply(UINT16 logSectionId) +{ + UINT16 routeRlockId = 0u; /*߼·ID*/ + UINT16 routePlockId = 0u; /*߼η·ID*/ + UINT8 routeType = 0u;/*·*/ + UINT8 phySecFLockState = 0u; /*η״̬,ӦSPKS*/ + UINT8 reVal = CI_ERROR; + LogsecSwitchStruct* pLgcSecSwitchStru = NULL; + UINT8 chLgcSecSwitchSum = 0u; + UINT8 ii = 0u; + UINT8 switchCurPosition = 0u; /*ǰλ*/ + UINT8 routeState = 0u; /*ԾյĽ·״̬*/ + UINT16 physicalSecId = 0u; + UINT8 retFlag = 0u; /*ʱ*/ + UINT16 curSwitchId = 0u; /*ʱ*/ + UINT8 switchFLockState = 0u; /*ʱ*/ + UINT16 jj = 0U; + UINT16 floodGateSum = 0U; /**/ + UINT16* floodGateIdBuf = NULL;/*ʱ*/ + UINT8 floodState = 0u;/*״̬*/ + UINT8 routeLevel = 0u; + UINT8 routeTrainNear = 0u; + UINT8 phyPLockRouteState = 0u; + UINT8 checkResult = CI_ERROR; + UINT16 logSecNum = 0u; + UINT16* plogSecIdPBuf = NULL; + UINT8 curLogSecOccState = LOGICSECTION_OCCUPY_UT; + UINT8 checkSulicTrain = CI_ERROR; + UINT8 logicCheck = CI_ERROR; + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 bufIndex = 0u; /*±*/ + UINT8 logSecLockState = 0U; + UINT8 logSecLockRouteNum = 0U; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + /**±Ϸ*/ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + physicalSecId = GetLgcSecRelativePhySecId(logSectionId); + routeRlockId = GetLogSecLockBelongRoute(logSectionId);/*߼ν··ID*/ + routePlockId = GetLogSecPLockRouteId(logSectionId);/*߼η·ID*/ + routeType = GetRouteType(routeRlockId);/*·*/ + phySecFLockState = GetPhySecFLockState(physicalSecId);/*ȡη״̬SPKSǷʵʩ*/ + chLgcSecSwitchSum = GetLogicSecSwitchSum(logSectionId); + pLgcSecSwitchStru = GetLogicSecSwitchIdStru(logSectionId); + routeState = GetRouteState(routeRlockId); /*ȡ·״̬*/ + logicCheck = LogicIntruSecVainCheck(logSectionId, &devId, &devState); /*߼޼*/ + logSecLockState = GetLogSecLogLockState(logSectionId); + logSecLockRouteNum = GetLogSecLockBelLogRouteSum(logSectionId); + + if (NULL == pLgcSecSwitchStru) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + if (CI_SUCCESS == reVal) + { + if ((0u < routeRlockId) && (ROUTE_TYPE_DIAOCHE == routeType)) + { + /*·*/ + reVal = CI_ERROR; + } + } + if (CI_SUCCESS == reVal) + { + if ((0u < logSecLockRouteNum) ||(LOG_SECTION_LOGLOCK_NO != logSecLockState)) + { + /*߼δ߼·*/ + reVal = CI_ERROR; + } + } + + if ((0u < routePlockId) && (CI_SUCCESS == reVal)) + { + /** ·UTռѹԾ */ + logSecNum = GetRouteLogSectionSum(routePlockId); + plogSecIdPBuf = GetRouteLogSectionIdBuf(routePlockId); + if (NULL != plogSecIdPBuf) + { + for (ii = 0u; ii < logSecNum; ii++) + { + curLogSecOccState = GetLogSecOccupyState(plogSecIdPBuf[ii]); + checkSulicTrain = IsLogicHaveNoSupicTrain(plogSecIdPBuf[ii]); + /** ߼ûCTռûпУUTռûȡռ״̬ʧܣ߼CTռس*/ + if (((LOGICSECTION_OCCUPY_CT != curLogSecOccState) && (LOGICSECTION_OCCUPY_NO != curLogSecOccState)) + || ((LOGICSECTION_OCCUPY_CT == curLogSecOccState) && (CI_ERROR == checkSulicTrain))) + { + reVal = CI_ERROR; + break; + } + else + { + /** ִ */ + } + } + } + else + { + /** */ + } + + if (CI_SUCCESS == reVal) + { + routeLevel = GetRouteLevel(routePlockId); /*ȡ·ල*/ + phyPLockRouteState = GetRouteState(routePlockId); /*ȡ·״̬*/ + + /** VBTC· */ + if (ROUTE_LEVEL_CBTC == routeLevel) + { + reVal = CI_SUCCESS; /*سɹ*/ + } + /** ʽ· */ + else + { + routeTrainNear = RouteHaveTrainNear(routePlockId); + /** ·гӽҽ·״̬ΪӽŻԤȿ */ + if ((CI_SUCCESS == routeTrainNear) && + ((ROUTE_STATE_YUXIAN_OPEN == phyPLockRouteState) || (ROUTE_STATE_NEAR_OPEN == phyPLockRouteState))) + { + /*ʧ*/ + reVal = CI_ERROR; + } + else + { + + } + } + } + else + { + /** */ + } + + } + if ((CI_SUCCESS == reVal) && (PHYSICAL_SECTION_FLOCK_YES == phySecFLockState)) + { + /*δڷ״̬(SPKSʵʩ)*/ + + reVal = CI_ERROR; + } + if ((CI_SUCCESS == reVal) && (CI_ERROR == logicCheck)) + { + /*߼޼鲻ͨ*/ + + reVal = CI_ERROR; + } + + if ((CI_SUCCESS == reVal) && (0u < routeRlockId)) + { + routeLevel = GetRouteLevel(routeRlockId); /*ȡ·ල*/ + /*ʽ*/ + if (ROUTE_LEVEL_BLOC == routeLevel) + { + routeTrainNear = RouteHaveTrainNear(routeRlockId); + /*·гӽҽ·״̬ΪӽŻԤȿ*/ + if ((CI_SUCCESS == routeTrainNear) && + ((ROUTE_STATE_YUXIAN_OPEN == routeState) || (ROUTE_STATE_NEAR_OPEN == routeState))) + { + + reVal = CI_ERROR; + } + } + else + { + reVal = CI_SUCCESS; + } + + } + if (CI_SUCCESS == reVal) + { + /*(λȷңûڶңδ*/ + + if ((0u != chLgcSecSwitchSum) && (NULL != pLgcSecSwitchStru)) + { + for (ii = 0u; ii< chLgcSecSwitchSum; ii++) + { + curSwitchId = pLgcSecSwitchStru[ii].SwitchId; + if ((0u != curSwitchId) && (UINT16_MAX != curSwitchId)) + {/*IDЧ*/ + switchCurPosition = GetSwitchCurPosition(curSwitchId); /*ȡǰλ*/ + retFlag = checkSwtLastValDrvPosStayorNot(curSwitchId, switchCurPosition); /*һǷЧ*/ + switchFLockState = GetSwitchFLockState(curSwitchId); /*ȡ״̬*/ + if ((pLgcSecSwitchStru[ii].SwitchPosition != switchCurPosition) || (CI_ERROR == retFlag) || (SWITCH_LOCK_FENGSUO_YES == switchFLockState)) + {/*жϵǰĵλǰλһͬijһȻЧ򣨵*/ + reVal = CI_ERROR; + break; + } + else + { + reVal = CI_SUCCESS; + } + } + + } + } + + } + + if (CI_SUCCESS == reVal) + { + if (0u < physicalSecId) + { + floodGateSum = GetPhySecLocatedFloodSum(physicalSecId); /*Ϊ0˵ûзţ飬ɷسɹ*/ + if (0U < floodGateSum) + { + floodGateIdBuf = GetPhySecLocatedFloodId(physicalSecId); + if (NULL != floodGateIdBuf) + { + for (jj = 0U; jj < floodGateSum; jj++) + { + /*зţ״̬*/ + floodState = GetFloodGateCurLogicCloseState(floodGateIdBuf[jj]); + if (FLOOD_GATE_OPEN != floodState) + { + reVal = CI_ERROR; + break; + } + else + { + reVal = CI_SUCCESS; + } + } + } + else + { + reVal = CI_ERROR; /*ȡʧܣʧ*/ + } + } + } + } + + if (CI_SUCCESS == reVal) + { + /** ߼ûCTռûпУUTռûȡռ״̬ʧܣ߼CTռس*/ + curLogSecOccState = GetLogSecOccupyState(logSectionId); + checkSulicTrain = IsLogicHaveNoSupicTrain(logSectionId); + if (((LOGICSECTION_OCCUPY_CT != curLogSecOccState) && (LOGICSECTION_OCCUPY_NO != curLogSecOccState)) + || ((LOGICSECTION_OCCUPY_CT == curLogSecOccState) && (CI_ERROR == checkSulicTrain))) + { + reVal = CI_ERROR; + } + else + { + /** ִ */ + reVal = CI_SUCCESS; + } + } + + if (CI_SUCCESS == reVal) + { + /** α·*/ + if (0u < routeRlockId) + { + /** ָ·ڵָ߼IDǰָ߼IDUTռ*/ + checkResult = CheckBeforLogSecinRouteHaveNoUT(routeRlockId, logSectionId); + /** UTռ*/ + if (CI_ERROR == checkResult) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + } + else + { + /** */ + } + } + } + else + { + reVal = CI_ERROR; + } + return reVal; +} + +/* +* Ч +* ˵ +* UINT16 const physicalId, ID +* ֵ CI_ERROR +* CI_SUCCESS ޲ +*/ +UINT8 PhysicalIntruSecVainCheck(UINT16 const physicalId) +{ + /* */ + UINT8 const checkSum = GetSecIntrudePhySectionSum(physicalId); + UINT16* const dataIdBuf = GetSecIntrudePhySectionData(physicalId); + + /* ֲʼ */ + UINT16 i = 0U; /* ѭ */ + UINT16 j = 0U; /* ѭ */ + UINT16 intruSwitchSum = 0U; + UINT16 intruSwitchId = 0U; + UINT16 intruSwitchPos = 0U; + UINT16 devId = 0U; + UINT8 devState = 0U; + UINT8 devFengSuoState = 0U; + UINT8 intruSwitchPosValid = CI_ERROR; + UINT8 reVal = CI_ERROR; + UINT8 flag = 0U; + UINT8 devLockState = 0U; + UINT8 devJumpLockState = 0U; + UINT8 curSwitchPos = SWITCH_POSITION_SIKAI; + UINT8 checkFlockFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_CHECKFLOCK_FLAG); + UINT8 chPhySecLogLockState = 0U;/*߼״̬*/ + + /* ״̬ */ + if (NULL == dataIdBuf) + { + /*޼*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = GetInvaSectId(dataIdBuf[i]); + devState = GetPhySecCurMergeState(devId); + devFengSuoState = GetPhySecFLockState(devId); + devLockState = GetPhySecLockState(devId); + devJumpLockState = GetPhySecJumpLockState(devId); + chPhySecLogLockState = PhySecLogLockStateCheck(devId); + + /* Ƿռû򣨷δգԾ*/ + if ((SECTION_OCCUPY_YES == devState) + || ((PHYSICAL_SECTION_FLOCK_YES == devFengSuoState) && (FUNC_SWITCH_ON != checkFlockFlag)) + || (PHYSICAL_SECTION_LOCK_NO != devLockState) + || (PHYSICAL_SECTION_JUMP_LOCK_YES == devJumpLockState) + || (LOG_SECTION_LOGLOCK_NO != chPhySecLogLockState)) + { + /*ռû*/ + intruSwitchSum = GetInvaSectsCondSwitSum(dataIdBuf[i]); + if (intruSwitchSum > 0u) + { + /*޵λü*/ + intruSwitchPosValid = CI_ERROR; + for (j = 0u; j < intruSwitchSum; j++) + { + intruSwitchId = GetInvaSectsCondSwitId(dataIdBuf[i], (INT16)j); + intruSwitchPos = GetInvaSectsCondSwitStat(dataIdBuf[i], (INT16)j); + curSwitchPos = GetSwitchCurPosition(intruSwitchId); + + if ((intruSwitchPos == curSwitchPos) + || (SWITCH_POSITION_SIKAI == curSwitchPos) + || (SWITCH_POSITION_MOVE == curSwitchPos) + || (SWITCH_POSITION_JICHA == curSwitchPos) + || (SWITCH_POSITION_INVALID == curSwitchPos)) + { + intruSwitchPosValid = CI_ERROR; + } + else + { + /*δ*/ + intruSwitchPosValid = CI_SUCCESS; + break; + } + } + + if (intruSwitchPosValid == CI_ERROR) + { + /*в*/ + reVal = CI_ERROR; + } + } + else + { + /*޲*/ + reVal = CI_ERROR; + } + if (CI_ERROR == reVal) + { + flag = 1U; + } + } + /* δռ(δ򲻼)δδԾ*/ + else if ((SECTION_OCCUPY_NO == devState) + && ((PHYSICAL_SECTION_FLOCK_NO == devFengSuoState) || (FUNC_SWITCH_ON == checkFlockFlag)) + && (PHYSICAL_SECTION_LOCK_NO == devLockState) + && (PHYSICAL_SECTION_JUMP_LOCK_NO == devJumpLockState) + && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState)) + { + /* δ⵽ */ + } + else + { + /*ռ״̬쳣ȫ*/ + flag = 1U; + reVal = CI_ERROR; + } + + if (1U == flag) + { + break; + } + } + } + + /* δ⵽ */ + return reVal; +} + +/* жϱIDǷڽ·ı +* ˵ const UINT16 routeId, ·ID +* const UINT16 expLkOverlapId, ID +* ֵ 0: ָβڽ·ı +* 1: ָڽ·ı +*/ +UINT8 checkExpOverlapBelongToRtOrNot(const UINT16 routeId, const UINT16 expLkOverlapId) +{ + UINT8 ii = 0u; + UINT8 checkResult = 0u; + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + + overlapSum = GetRouteOverlapSum(routeId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(routeId); /*ȡOverlap ID BUF*/ + + + if ((0u == overlapSum)||(0u == expLkOverlapId)) + { + /*ûбλձIDЧ*/ + } + else + { + for (ii = 0u; ii < overlapSum; ii++) + {/*·ı*/ + if (expLkOverlapId == overlapIdBuf[ii]) + {/*ҵ*/ + checkResult = 1u; + break; + } + else + { + /*޲*/ + } + if (ii == (overlapSum-1u)) + {/*ϣδҵ*/ + checkResult = 0u; + } + else + { + /*޲*/ + } + } + } + + return checkResult; +} + +/* +* JKJӦ״̬Ч־ +* ˵ void +* ֵ JKJ_REYLAY_INVALID 0x55 JKJӦЧ +* JKJ_REYLAY_VALID 0xaa JKJӦЧ +*/ +UINT8 GetCiJkjFlag(void) +{ + return JkjRelayValid; +} + +/* +* JKJӦ״̬Ч־ +* ˵ JKJ_REYLAY_INVALID 0x55 JKJӦЧ +* JKJ_REYLAY_VALID 0xaa JKJӦЧ +* ֵ void +*/ +void SetCiJkjFlag(UINT8 setFlag) +{ + if ((JKJ_REYLAY_INVALID == setFlag) || (JKJ_REYLAY_VALID == setFlag)) + { + JkjRelayValid = setFlag; + } + else + { + /**/ + } +} + +/* +* ȡJKJЧ״̬Чں +* ˵ +* ֵ JkjRelayValidCycNum +*/ +UINT32 GetJkjRelayValidCycNum(void) +{ + return JkjRelayValidCycNum; +} + + +/* +* JKJӦ״̬Чں +* ˵ const UINT32 updateCycNum, ӦЧں +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetJkjRelayValidCycNum(const UINT32 updateCycNum) +{ + JkjRelayValidCycNum = updateCycNum; /*ָIDӦЧ״̬ں*/ +} + +/* +* ȡZFWЧ״̬Чں +* ˵ +* ֵ ZFWValidCycNum +*/ +UINT32 GetZFWValidCycNum(void) +{ + return ZFWValidCycNum; +} + + +/* +* ZFWܸλ״̬Чں +* ˵ const UINT32 updateCycNum, ܸλЧں +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetZFWValidCycNum(const UINT32 updateCycNum) +{ + ZFWValidCycNum = updateCycNum; /*ָIDܸλЧ״̬ں*/ +} + +/* +* ȡZFWյں +* ˵ +* ֵ ZFWCmdStartCycNum +*/ +UINT32 GetZFWcmdStartCycNum(void) +{ + return ZFWCmdStartCycNum; +} + + +/* +* ZFWܸλʼں +* ˵ const UINT32 updateCycNum, ܸλں +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetZFWcmdStartCycNum(const UINT32 updateCycNum) +{ + ZFWCmdStartCycNum = updateCycNum; /*ָIDܸλʼں*/ +} + + +/* +: Ծ +: const UINT16 axisSecId ID +: +ֵ: CI_SUCCESS,մɹ + CI_ERROR,մʧ +*/ +UINT8 JumpLockDriveSwitch(const UINT16 axisSecId) +{ + UINT8 ii = 0u; + UINT8 switchSum = 0u; + UINT16 switchId = 0u; + UINT8 switchExpPosition = SWITCH_POSITION_INVALID; /*λ*/ + UINT8 switchDancaoPosition = SWITCH_POSITION_INVALID; /*Чλ*/ + AxisSwitchStruct* pRouteSwitchStru = NULL; /*ݽṹָ*/ + UINT8 innerSwitchRetVal = CI_ERROR; /*ڵǷɱĽ*/ + + switchSum = GetAxisSwitchSum(axisSecId); + pRouteSwitchStru = GetAxisSwitchIdStru(axisSecId); + + if((0u == axisSecId) || (axisSecId >= AXIS_SECTION_SUM_MAX)) + { + innerSwitchRetVal = CI_ERROR; + } + else + { + innerSwitchRetVal = CI_SUCCESS; + + /* ෴λȡ */ + for(ii = 0u; ii < switchSum; ii++) + { + switchId = pRouteSwitchStru[ii].SwitchId; + switchExpPosition = pRouteSwitchStru[ii].SwitchPosition; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + + if( (SWITCH_POSITION_INVALID == switchDancaoPosition) + || + (switchDancaoPosition == switchExpPosition)) + {/*Ч λ붯λһ*/ + innerSwitchRetVal = CI_SUCCESS; + } + else + { + /*ٵ෴λȡ*/ + innerSwitchRetVal = CI_ERROR; + break; + } + } + + if(innerSwitchRetVal == CI_SUCCESS) + { + /*ε*/ + AxisSecDrvInnerSwitch(axisSecId, SWITCH_NEED_DRIV_TRUE); + } + else + { + AxisSecDrvInnerSwitch(axisSecId, SWITCH_NEED_DRIV_FALSE); + } + + } + + return innerSwitchRetVal; + +} + + +/* +: ڵ +: const UINT16 axisSecId ID +: const UINT8 DrivFlag ־ +ֵ: +*/ +void AxisSecDrvInnerSwitch(const UINT16 axisSecId, const UINT8 DrivFlag) +{ + UINT8 switchSum = 0u; /*Ŀ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 switchExpPos = 0u; /*λ*/ + AxisSwitchStruct* pAxisSecSwitchStru = NULL; /**/ + UINT8 ii = 0u; /*ѭ*/ + UINT8 funRtn = CI_ERROR; + + switchSum = GetAxisSwitchSum(axisSecId); /*ȡεĿ*/ + pAxisSecSwitchStru = GetAxisSwitchIdStru(axisSecId); /*ȡڵ*/ + + + if(SWITCH_NEED_DRIV_TRUE == DrivFlag) + {/*Ҫڵ*/ + + for(ii = 0u; ii < switchSum; ii++) + { + switchId = pAxisSecSwitchStru[ii].SwitchId; + switchExpPos = pAxisSecSwitchStru[ii].SwitchPosition; + funRtn = SwitchDriveProcess(switchId, switchExpPos); /*üڵ״̬Ϊ*/ + } + + } +} + + + + + + +/* +* ̵ӿ¼DZĽ·ڣڱǷѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckNoLocalCiRoutePhySecUnLock(const UINT16 routeId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *RouteSecStru = NULL; /**/ + UINT16 phySecId = 0u; /*ID*/ + UINT8 ii= 0u; + UINT8 reVal = CI_ERROR; + + UINT8 routeBelongCi = 0u; + UINT8 localCi = 0u; + UINT8 phyBelongCi = 0u;/**/ + UINT8 phyLockState = 0u;/*״̬*/ + + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + UINT32 curCycle = 0u; + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + RouteSecStru = GetRouteSectionData(routeId); /*·*/ + + routeBelongCi = GetRouteBelongCiId(routeId);/*·ID*/ + localCi = GetSystemParaLocalCiId();/*ID*/ + + + if (NULL == RouteSecStru) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + commState = GetLocalCiAndOtherCiTransSta(routeBelongCi);/*ͨͨ״̬*/ + /*·ڱ·ڱζѽ*/ + if ((routeBelongCi != localCi) && (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + for(ii = 0u; ii < sectionSum; ii++) + { + phySecId = RouteSecStru[ii].PhysicalSectionId; + phyBelongCi = GetPhySecBelongCiId(phySecId); + + phyLockState = GetPhySecLockState(phySecId); + curCycle = Get2oo2CurCycleNum(); + if ( phyBelongCi==localCi) + { /*ڱδ*/ + if (PHYSICAL_SECTION_LOCK_NO == phyLockState) + { + } + else + { + debug_infor_printf((const)"CheckNo, phySecId:%d phyLockState:%d curCycle:%d\n", + phySecId,phyLockState,curCycle); + reVal = CI_ERROR; + break; + } + } + } + } + + } + + return reVal; +} + + +/* +* ·Ƿ +* ˵ UINT16 routeId · +* , UINT8 *pOtherCiId ID +* ֵ1ִгɹ +* 0: ִʧ +*/ +UINT8 RouteHavePhySecBelongOtherCi(const UINT16 routeId, UINT8 *pOtherCiId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT16 phySecId = 0u; /*ID*/ + UINT8 ii= 0u; + UINT8 routeBelongCi = 0u; + UINT8 phyBelongCi = 0u; + UINT8 reVal = CI_ERROR; + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId);/*ȡ·*/ + + routeBelongCi = GetRouteBelongCiId(routeId); + + if ((NULL==pRouteSecStru ) || (NULL == pOtherCiId)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + + for(ii = 0u; ii < sectionSum; ii++) + { + phySecId = pRouteSecStru[ii].PhysicalSectionId; + phyBelongCi = GetPhySecBelongCiId(phySecId); + if (routeBelongCi != phyBelongCi) + { + *pOtherCiId = phyBelongCi; + break; + } + } + } + + return reVal; +} + +/* +* ·ڱѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckLocalCiRoutePhySecUnLock(const UINT16 routeId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT16 phySecId = 0u; /*ID*/ + UINT8 ii= 0u; + UINT8 localCi = 0u; + UINT8 reVal = CI_ERROR; + + UINT8 phySecLockState = 0u;/*״̬*/ + UINT8 phyBelongCi = 0u;/**/ + UINT8 routeBelongCi = 0u;/*·*/ + UINT16 phyLockBelongRoute = 0u; + + localCi = GetSystemParaLocalCiId(); + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + + if (NULL ==pRouteSecStru) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + for(ii = 0u; ii < sectionSum; ii++) + { + phySecId = pRouteSecStru[ii].PhysicalSectionId; + phySecLockState = GetPhySecLockState(phySecId); + phyLockBelongRoute = GetPhySecRLockBelongRouteId(phySecId); + + phyBelongCi = GetPhySecBelongCiId(phySecId); + routeBelongCi = GetRouteBelongCiId(routeId); + if ((routeBelongCi == phyBelongCi) && (phyBelongCi == localCi)) + {/*ڱIJ,δջյIJDZ·*/ + if (((PHYSICAL_SECTION_LOCK_NO == phySecLockState) || + ((PHYSICAL_SECTION_LOCK_NO !=phySecLockState ) && (routeId != phyLockBelongRoute))) ) + { /*δջDZ·*/ + } + else + { + reVal = CI_ERROR; + break; + } + } + } + } + + return reVal; +} + + +/* +* üܸλǷ״̬ +* ˵ void +* ֵ +* +*/ +void SetZfwjHunXianFLag(UINT8 setFlag) +{ + ZFWJRelayHunXianFlag = setFlag; +} + +/* +* ȡܸλǷ״̬ +* ˵ void +* ֵ +* +*/ +UINT8 GetZfwjHunXianFLag(void) +{ + return ZFWJRelayHunXianFlag; +} + + +/* +* ת޻ȡͻָ״̬ +* ˵ UINT8 blockLinkState ״̬ +* ֵ +* +*/ +void SetCancelOrRcvrBlockLinkSta(UINT8 blockLinkState) +{ + /*״̬Ч*/ + if((CANCEL_SWITCH_BLOCK_LINK == blockLinkState) || (RECOVER_SWITCH_BLOCK_LINK == blockLinkState)) + { + SwitchBlockLinkState = blockLinkState; + } + else + { + /**/ + } +} + +/* +* ȡת޻״̬ +* ˵ void +* ֵ SwitchBlockLinkState ת޻״̬ +* +*/ +UINT8 GetCancelOrRcvrBlockLinkSta(void) +{ + return(SwitchBlockLinkState); +} + +/* +* ҵ·ڵһʱ߼ +* ˵ UINT16 routeId, + +* ֵ UINT16 ID +* = 0 Ч +* > 0 ID +*/ +UINT16 GetRouteFirstDelayLockLogId(UINT16 routeId) +{ + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 belongRouteId = 0u; + UINT8 logLockState = 0u; + UINT16 reVal = 0u; + UINT16 routeLogNum = 0u; + UINT16* routeLogIdBuf = NULL; + + /*ȡ·߼*/ + routeLogNum = GetRouteLogSectionSum(routeId); + routeLogIdBuf = GetRouteLogSectionIdBuf(routeId); + if(0u < routeLogNum) + { + for(i = 0u; i < routeLogNum; i++) + { + belongRouteId = GetLogSecLockBelongRoute(routeLogIdBuf[i]); + /*·ڱ·*/ + if(belongRouteId == routeId) + { + /*ȡ״̬*/ + logLockState = GetLogSecLockState(routeLogIdBuf[i]); + /*ʱ״̬*/ + if(LOG_SECTION_LOCK_DELAY == logLockState) + { + /*߼*/ + reVal = routeLogIdBuf[i]; + break; + } + else + { + /**/ + } + } + else + { + /*޲*/ + } + } + } + else + { + /*޲*/ + } + return(reVal); + + +} + + +/* +* ߼εռ״̬ +* ˵ UINT16 switchIdId +* UINT16* logOccOrLockId ߼ID +* UINT8* pState ߼״̬ +* ֵ CI_SUCCESS: ߼ζ +* CI_ERROR: ߼δռ +* modify 20221009 pState +*/ +UINT8 GetSwitchLogSecOccState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 logSecSum = 0u; + UINT8 logOccState = 0u; + UINT16* logSecBuf = NULL; + UINT8 retValue = CI_ERROR; + + /*ȡ߼Ϣ*/ + logSecSum = GetSwitchLogSecSum(switchId); + logSecBuf = GetSwitchLogSecBuf(switchId); + + /*߼*/ + if(0u != logSecSum) + { + /*߼ռ״̬*/ + for(i = 0u; i < logSecSum; i++) + { + logOccState = GetLogSecCurOccupyState(logSecBuf[i]); + /*ҵռ*/ + if(SECTION_OCCUPY_NO != logOccState) + { + *logOccOrLockId = logSecBuf[i]; + *pState = logOccState; + retValue = CI_ERROR; + break; + } + else + { + retValue = CI_SUCCESS; + } + } + } + else + { + /*޲*/ + } + return(retValue); +} + +/* +* ι߼εռ״̬ +* ˵ UINT16 switchIdId +* UINT16* logOccOrLockId ߼ID +* UINT8* pState ߼״̬ +* ֵ CI_SUCCESS: ͨ +* CI_ERROR: 鲻ͨ +* add 20221009 ·ǰ +*/ +UINT8 GetSwitchSecOccState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState) +{ + /*ʼ*/ + UINT8 i = 0u; + UINT8 logOccState = 0u; + UINT8 retValue = CI_ERROR; + UINT16 logId = 0u; + UINT16 switch1stSecId = 0u; + UINT8 checkLogSecSum = 0u; + UINT16* logSecIdBuf = NULL; + UINT8 logSecOccState = 0u; + UINT8 logSecLockState = 0u; + + + /*ȡ߼ռ״̬*/ + switch1stSecId = GetSwitchPhySectionId(switchId); + logOccState = GetSwitchLogSecOccState(switchId, &logId, &logSecOccState); + if (CI_ERROR == logOccState) + { + /*߼ռ*/ + *logOccOrLockId = logId; + *pState = logSecOccState; + retValue = CI_ERROR; + } + else + { /*߼ο,ε߼ֻCTռû*/ + checkLogSecSum = GetPhySecIncLogSecSum(switch1stSecId); + logSecIdBuf = GetPhySecIncLogSecIdBuf(switch1stSecId); + if (NULL != logSecIdBuf) + { + retValue = CI_SUCCESS; + for (i = 0u; i < checkLogSecSum; i++) + { + logSecOccState = GetLogSecCurCtOrUtOccupyState(logSecIdBuf[i]); + if (LOGICSECTION_OCCUPY_NO == logSecOccState) + { + + } + else if (LOGICSECTION_OCCUPY_CT == logSecOccState) + { + logSecLockState = GetLogSecLockState(logSecIdBuf[i]); + if (LOG_SECTION_LOCK_NORMAL != logSecLockState) + { + retValue = CI_ERROR; + } + else + { + /*߼CTռұ*/ + } + } + else + { + /*߼μȲCTռҲǿ*/ + retValue = CI_ERROR; + } + + if (CI_ERROR == retValue) + { + *logOccOrLockId = logSecIdBuf[i]; + *pState = logSecOccState; + break; + } + else + { + + } + } + } + else + { + /*ݴ*/ + retValue = CI_ERROR; + } + + } + return retValue; +} + +/* +* ߼ε״̬ +* ˵ UINT16 switchIdId +* UINT16* logOccOrLockId ߼ID +* UINT8* pState ߼״̬ +* ֵ CI_SUCCESS: ߼ζδ +* CI_ERROR: ߼ռ +* modify 20221009 pState +*/ +UINT8 GetSwitchLogSecLockState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 logSecSum = 0u; + UINT8 logLockState = 0u; + UINT16* logSecBuf = NULL; + UINT8 retValue = CI_ERROR; + UINT8 chLogSecLogLockState = 0U; /*߼߼״̬*/ + UINT8 cLockBelongLogicRouteNum = 0U; /*߼߼߼·*/ + + /*ȡ߼Ϣ*/ + logSecSum = GetSwitchLogSecSum(switchId); + logSecBuf = GetSwitchLogSecBuf(switchId); + + /*߼*/ + if(0u != logSecSum) + { + /*߼״̬*/ + for(i = 0u; i < logSecSum; i++) + { + logLockState = GetLogSecLockState(logSecBuf[i]); + /*ҵ*/ + if(LOG_SECTION_LOCK_NO != logLockState) + { + *logOccOrLockId = logSecBuf[i]; + *pState = logLockState; + retValue = CI_ERROR; + } + else + { + /*߼߼״̬*/ + chLogSecLogLockState = GetLogSecLogLockState(logSecBuf[i]); + cLockBelongLogicRouteNum = GetLogSecLockBelLogRouteSum(logSecBuf[i]); + + if ((LOG_SECTION_LOGLOCK_NO == chLogSecLogLockState) && (0U == cLockBelongLogicRouteNum)) + { + retValue = CI_SUCCESS; + } + else + { + *logOccOrLockId = logSecBuf[i]; + *pState = chLogSecLogLockState; + retValue = CI_ERROR; + } + } + + if (CI_ERROR == retValue) + { + break; /*鲻ͨ*/ + } + } + } + else + { + /*޲*/ + } + return(retValue); +} + +/* +* ҵ·ڵһ߼ +* ˵ UINT16 routeId, + +* ֵ UINT16 ID +* = 0 Ч +* > 0 ߼ID +*/ +UINT16 GetRouteFirstNormalLockLogId(UINT16 RouteId) +{ + /*ʼ*/ + UINT16 i = 0u; /* ѭ */ + UINT16 belongRouteId = 0u; + UINT8 logLockState = 0u; + UINT8 flag = 0u;/*ҳɹ־*/ + UINT16 routeLogNum = 0u; + UINT16 reVal = CI_ERROR; + UINT16* routeLogIdBuf = NULL; + + /*ȡ·߼*/ + routeLogNum = GetRouteLogSectionSum(RouteId); + routeLogIdBuf = GetRouteLogSectionIdBuf(RouteId); + + if(0u < routeLogNum) + { + for(i = 0u; i < routeLogNum; i++) + { + belongRouteId = GetLogSecLockBelongRoute(routeLogIdBuf[i]); + /*·ڱ·*/ + if(belongRouteId == RouteId) + { + /*ȡ״̬*/ + logLockState = GetLogSecLockState(routeLogIdBuf[i]); + /**/ + if(LOG_SECTION_LOCK_NORMAL == logLockState) + { + /*߼*/ + reVal = routeLogIdBuf[i]; + flag = 1u; + } + /*ʱ*/ + else if(LOG_SECTION_LOCK_DELAY == logLockState) + { + /**/ + } + else + { + /*ش*/ + reVal = CI_ERROR; + flag = 1u; + } + if(1u == flag) + { + break; + } + else + { + /*޲*/ + } + } + else + { + } + + } + } + else + { + } + return(reVal); + +} + +/* +* ý·߼ԴгID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +* qw.liu 2022-03-03 +* @note bug 20220420 淶ɾע +*/ +void SetRouteLogicSecResTrainId(const UINT16 routeId, const UINT16 wTrainId) +{ + UINT8 chRouteType = 0U; + UINT8 chLogicSecResTrainSum = 0U; + UINT16 wLogicSum = 0U; + UINT16 wLogicSecId = 0U; + UINT16 ii = 0U; + UINT16 wRouteLastPhySecId = 0U; + UINT16 wLogicSecRelativePhySecId = 0U; + UINT16 wGroupOtherTrainId = 0U; + LogicTrainResStruct *pstLgcTrnResInfo = NULL; + UINT8 cLocalCiId = 0u; + UINT8 cRouteCiId = 0u; + UINT8 chReturnLogAddFlag = CI_ERROR; + UINT16 wLogicPLockRouteId = 0U; + const UINT16 *wszLogicSecId = GetRouteLogSectionIdBuf(routeId); + UINT8 chLocalCiType = 0U;/**/ + UINT8 chHitSoftWallSwitch = 0U;/*ײǽ*/ + UINT16 wRLockStartSignalId = 0U; /*ʼźŻID*/ + UINT16 wRLockLightUpTrainId = 0U; /*νӽг*/ + cLocalCiId = GetSystemParaLocalCiId(); + wLogicSum = GetRouteLogSectionSum(routeId); + chLocalCiType = GetLocalCiType(); + chHitSoftWallSwitch = GetHitSoftWallSwitch(); + + if ((CI_TYPE_TCC == chLocalCiType) || (CI_TYPE_CLD == chLocalCiType)) + { + /* ȡ·*/ + chRouteType = GetConfigRouteType(routeId); + } + else + { + /* ȡ·*/ + chRouteType = GetRouteType(routeId); + } + + + /* ȡ·ID */ + cRouteCiId = GetRouteBelongCiId(routeId); + if ((MAX_ROUTE_IN_LT_NUM > wLogicSum)&&(NULL!=wszLogicSecId)&&(0u != cLocalCiId)) + { + if (cRouteCiId == cLocalCiId) + { + if (ROUTE_TYPE_RETURN == chRouteType) + { + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + wLogicPLockRouteId = GetLogSecPLockRouteId(wLogicSecId); + chLogicSecResTrainSum = GetLogSecTrainInfoSum(wLogicSecId); + if (0U < chLogicSecResTrainSum) + { + if (0U == wLogicPLockRouteId) + { + break; + } + else + { + + } + } + } + + if (ii == wLogicSum) + { + chReturnLogAddFlag = CI_SUCCESS; + } + else + { + /*жǰ뱾Ϊͬһг--Դ*/ + wGroupOtherTrainId = GetGroupTrainOtherId(wTrainId); + pstLgcTrnResInfo = GetLogSecTrainInfoById(wLogicSecId, wGroupOtherTrainId); + if (NULL != pstLgcTrnResInfo) + { + chReturnLogAddFlag = CI_SUCCESS; + } + else + { + chReturnLogAddFlag = CI_ERROR; + } + } + + if (CI_SUCCESS == chReturnLogAddFlag) + { + /*·Դ*/ + wRouteLastPhySecId = GetRouteLastPhySectionId(routeId); + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + + /*߼гԴϢ*/ + AddLogSecTrainRes(wLogicSecId, wTrainId); + wLogicSecRelativePhySecId = GetLgcSecRelativePhySecId(wLogicSecId); + if ((wRouteLastPhySecId == wLogicSecRelativePhySecId) + && (0U != wLogicSecRelativePhySecId)) + { + SetLogSecTrainReturnState(wLogicSecId, wTrainId, LOGIC_SECTION_TRAIN_RETURN_YES); + } + else + { + /*ִ*/ + } + } + } + else + { + + } + } + else if (ROUTE_TYPE_LIECHE == chRouteType) + { + /*жײǽأش򿪣Դɷг*/ + if (FUNC_HITSOFTWALL_ON == chHitSoftWallSwitch) + { + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + + /*߼гԴϢ*/ + AddLogSecTrainRes(wLogicSecId, wTrainId); + } + } + /*عرգԴֻӽ·г*/ + else + { + /*ӽ·г*/ + wRLockStartSignalId = GetRouteStartSignalId(routeId); + wRLockLightUpTrainId = GetSignalLightUpTrainId(wRLockStartSignalId); + + /*ָгΪ·ӽг*/ + if ((wTrainId & 0x00ffU) == wRLockLightUpTrainId) + { + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + + /*߼гԴϢ*/ + AddLogSecTrainRes(wLogicSecId, wTrainId); + } + } + else + { + /*г*/ + } + } + } + else + { + /* */ + } + } + else + { + ;/* DZ· */ + } + } + else + { + /* */ + } +} + +/* +* ȡ·гӽʱռѹ߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ α +*/ +UINT16 GetRouteHaveTrainNearLogSecId(const UINT16 routeId) +{ + UINT8 secOccupyState = 0U; /*ռ״̬*/ + UINT16 switchId = 0U; /*ID*/ + UINT8 switchPos = 0U; /*λ*/ + UINT8 ii = 0U; /*±*/ + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 isSwitchPosRight = 1U; /*λǷȷ Ĭ1Ϊȷ0Ϊ*/ + UINT8 isSecOccupied = 1U; /*Ƿռñ־ Ĭ1Ϊδռã0Ϊռ*/ + UINT8 switchCurPosition = 0U; + UINT8 ckeepWorkFlag = CI_ERROR; + UINT16 wRetVal = 0U; + UINT8 nearSecConditionSum = 0U; /*ӽ*/ + RouteNearLogicSectionStruct* nearLogicSecStru = NULL; /*ӽ߼νṹ*/ + UINT8 chLogicSecSwitchSum = 0U;/*߼εĿ*/ + LogsecSwitchStruct* pLogicSecSwitchIdData = NULL;/*߼εID*/ + + + if ((0u == routeId) || (ROUTE_SUM_MAX <= routeId)) + { + ckeepWorkFlag = CI_ERROR; + } + else + { + ckeepWorkFlag = CI_SUCCESS; + } + + + if (CI_SUCCESS == ckeepWorkFlag) + { + nearSecConditionSum = GetRouteCbtcNearSecConditionSum(routeId); /*ȡCBTC·ӽ߼Ŀ*/ + nearLogicSecStru = GetRouteCbtcNearLogSectionStru(routeId); /*ȡCBTC·ӽ߼νṹ*/ + + if ((0U < nearSecConditionSum) + && (ROUTE_NEARSEC_CONDITION_SUM_MAX >= nearSecConditionSum) + && (NULL != nearLogicSecStru)) + {/*жӽ*/ + + for (ii = 0U; ii < nearSecConditionSum; ii++) + {/**/ + + isSecOccupied = 1U;/*ռñ־Ϊδռ*/ + isSwitchPosRight = 1U;/*õλñ־Ϊȷ*/ + + for (jj = 0U; jj < nearLogicSecStru[ii].NearLogicSecSum; jj++) + { + secOccupyState = GetLogSecCurOccupyState(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]);/*ȡ߼εǰռ״̬*/ + + if (SECTION_OCCUPY_NO != secOccupyState) + {/*ηǿУռúͽӽ*/ + + isSecOccupied = 0U;/*øӽռ*/ + } + else + { + ; /*ü*/ + } + + chLogicSecSwitchSum = GetLogicSecSwitchSum(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]); + pLogicSecSwitchIdData = GetLogicSecSwitchIdStru(nearLogicSecStru[ii].NearLogicSecIdBuf[jj]); + + for (kk = 0U; kk < chLogicSecSwitchSum; kk++) + { + switchId = pLogicSecSwitchIdData[kk].SwitchId; + switchPos = pLogicSecSwitchIdData[kk].SwitchPosition; + switchCurPosition = GetSwitchCurPosition(switchId); + + if (SWITCH_POSITION_DINGWEI == switchPos) + { + /*涨λ*/ + if (SWITCH_POSITION_FANWEI == switchCurPosition) + {/*λڷλ*/ + + isSwitchPosRight = 0U;/*õλô*/ + } + else + {/*λòڷλ*/ + + ; /*λȷ ñ־*/ + } + + } + else + { + if (SWITCH_POSITION_DINGWEI == switchCurPosition) + {/*λڶλ*/ + isSwitchPosRight = 0U;/*õλô*/ + } + else + {/*λòڶλ*/ + + ; /*λȷ ñ־*/ + } + } + } + + if ((0U == isSecOccupied) || (0U == isSwitchPosRight)) + {/*ռλô󣬾жϸѭ*/ + break; + } + + }/*ӽ*/ + + /*жϸӽǷӽ*/ + if ((0U == isSecOccupied) && (0U != isSwitchPosRight)) + {/*ռ ռ֮ǰĵλþȷ*/ + + wRetVal = nearLogicSecStru[ii].NearLogicSecIdBuf[jj]; + break; + } + + }/*нӽ*/ + } + else + { + /*Ŀ*/ + ; + } + } + else + { + ; + } + return wRetVal; +} +/* +* ·δ״̬ +* ˵ UINT16 routeId, ·ID +* +* ֵ CI_ERROR IDδջ +* CI_SUCCESS +*/ +UINT8 CheckRouteStateNotYinDaoLock(UINT16 routeId) +{ + UINT8 chRetVal = 0U; + UINT8 chRouteState = 0U; + chRouteState = GetRouteState(routeId); + if (CI_ERROR == chRouteState) + { + chRetVal = CI_ERROR; + } + else if ((ROUTE_STATE_FIRST_LOCK == chRouteState) + || (ROUTE_STATE_FIRST_LOCKERR == chRouteState) + || (ROUTE_STATE_YUXIAN_LOCK == chRouteState) + || (ROUTE_STATE_YUXIAN_OPEN == chRouteState) + || (ROUTE_STATE_NEAR_LOCK == chRouteState) + || (ROUTE_STATE_NEAR_LOCKERR == chRouteState) + || (ROUTE_STATE_NEAR_OPEN == chRouteState) + || (ROUTE_STATE_DELAY_UNLOCK == chRouteState) + || (ROUTE_STATE_AUTO_UNLOCK == chRouteState) + || (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState) + || (ROUTE_STATE_HALF_LOCK == chRouteState) + || (ROUTE_STATE_HALF_UNLOCKDELAY == chRouteState) + || (ROUTE_STATE_HALF_UNLOCK == chRouteState)) + { + chRetVal = CI_SUCCESS; + } + else + { + + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡ·׼·гϢ +* ˵ const UINT16 routeId, ·ID pTrainNumԤ wszTrainId ԤID +* ֵ CI_ERROR :ȡʧ +* CI_SUCCESS:ȡɹ +*/ +UINT8 GetRouteReadyEnterTrainInfo(const UINT16 wRouteId,UINT8 * pTrainNum,UINT16 wszTrainId[]) +{ + + UINT8 ii = 0u; /*±*/ + UINT8 jj = 0u; + UINT16 wRouteFirstLgcId = 0u; + UINT16 wRouteLastLgcId = 0u; + UINT8 chSameIdTrainSum = 0U; + UINT16 wszSameIdTrainSum[LOGIC_SECTION_RES_SUM_MAX] = {0U}; + UINT16 wRouteFirstLgcTrainId = 0U; + UINT16 wRouteLastLgcTrainId = 0U; + UINT8 chRouteFirstLgcTrainSum = 0U; + UINT8 chRouteLastLgcTrainSum = 0U; + UINT8 ckeepWorkFlag = CI_ERROR; + UINT8 wRetVal = CI_ERROR; + + if ((NULL == pTrainNum) || (NULL == wszTrainId)) + { + ckeepWorkFlag = CI_ERROR; + } + else + { + ckeepWorkFlag = CI_SUCCESS; + } + + if (CI_SUCCESS == ckeepWorkFlag) + { + wRouteFirstLgcId = GetRouteInFirstLogSecId(wRouteId); + wRouteLastLgcId = GetRouteInLastLogSecId(wRouteId); + if ((CI_ERROR == wRouteFirstLgcId) + || (CI_ERROR == wRouteLastLgcId)) + { + ckeepWorkFlag = CI_ERROR; + } + else + { + chRouteFirstLgcTrainSum = GetLogSecTrainInfoSum(wRouteFirstLgcId); + chRouteLastLgcTrainSum = GetLogSecTrainInfoSum(wRouteLastLgcId); + } + } + + if (CI_SUCCESS == ckeepWorkFlag) + { + for (ii = 0; ii < chRouteFirstLgcTrainSum; ii++) + { + wRouteFirstLgcTrainId = GetLogSecTrainIdByIndex(wRouteFirstLgcId, ii); + for (jj = 0U; jj < chRouteLastLgcTrainSum; jj++) + { + wRouteLastLgcTrainId = GetLogSecTrainIdByIndex(wRouteLastLgcId, jj); + if ((wRouteFirstLgcTrainId == wRouteLastLgcTrainId) + &&(0U!=wRouteFirstLgcTrainId)) + { + wszSameIdTrainSum[chSameIdTrainSum] = wRouteFirstLgcTrainId; + chSameIdTrainSum += 1U; + break; + } + } + } + } + if (CI_SUCCESS == ckeepWorkFlag) + { + *pTrainNum = chSameIdTrainSum; + for (ii = 0U; ii < chSameIdTrainSum; ii++) + { + wszTrainId[ii] = wszSameIdTrainSum[ii]; + } + wRetVal = CI_SUCCESS; + } + else + { + wRetVal = CI_ERROR; + } + + + return wRetVal; +} + +/* +* ȡ·ⷽһ߼ξԴгϢ +* ˵const UINT16 routeId ·ID +* UINT8* pTrainNum Ԥ +* UINT16 szTrainId[LOGIC_SECTION_RES_SUM_MAX] ԤID +* ֵ0 ȡʧ +* 1 ȡɹ +* Created By LQ 2024.12.02 +*/ +UINT8 GetRouteInOutFstLgcTrainInfo(const UINT16 wRouteId, UINT8* pTrainNum, UINT16 szTrainId[LOGIC_SECTION_RES_SUM_MAX]) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT16 wRouteInFstLgcId = 0U; /*·ڷһ߼ID*/ + UINT16 wRouteOutFstLgcId = 0U; /*·ⷽһ߼ID*/ + UINT16 wRouteStartSignalId = 0U; /*·ʼźŻID*/ + UINT8 cRouteInFstLgcTrainSum = 0U; /*·ڷһ߼ԴгϢ*/ + UINT16 wRouteInFstLgcTrainId = 0U; + UINT8 cRouteOutFstLgcTrainSum = 0U; /*·ⷽһ߼ԴгϢ*/ + UINT16 wRouteOutFstLgcTrainId = 0U; + UINT8 cSameIdTrainSum = 0U; + UINT16 szSameIdTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId) && (NULL != pTrainNum) && (NULL != szTrainId)) + { + wRouteInFstLgcId = GetRouteInFirstLogSecId(wRouteId); /*ȡ·ڷһ߼ID*/ + wRouteStartSignalId = GetRouteStartSignalId(wRouteId); /*ȡ·ʼźŻID*/ + wRouteOutFstLgcId = GetSignalOutFirstLogSec(wRouteStartSignalId); /*ȡ·ⷽһ߼ID*/ + + if ((CI_ERROR != wRouteInFstLgcId) && (CI_ERROR != wRouteOutFstLgcId)) + { + cRetVal = CI_SUCCESS; + cRouteInFstLgcTrainSum = GetLogSecTrainInfoSum(wRouteInFstLgcId); /*ȡ·ڷһ߼Դг*/ + cRouteOutFstLgcTrainSum = GetLogSecTrainInfoSum(wRouteOutFstLgcId); /*ȡ·ⷽһ߼Դг*/ + if ((0U != cRouteInFstLgcTrainSum) && (0U != cRouteOutFstLgcTrainSum)) + { + for (ii = 0U; ii < cRouteInFstLgcTrainSum; ii++) + { + wRouteInFstLgcTrainId = GetLogSecTrainIdByIndex(wRouteInFstLgcId, ii); /*ȡ·ڷһ߼ԴгID*/ + if (0U != wRouteInFstLgcTrainId) + { + for (jj = 0U; jj < cRouteOutFstLgcTrainSum; jj++) + { + wRouteOutFstLgcTrainId = GetLogSecTrainIdByIndex(wRouteOutFstLgcId, jj); /*ȡ·ⷽһ߼ԴгID*/ + if (wRouteInFstLgcTrainId == wRouteOutFstLgcTrainId) + { + if (LOGIC_SECTION_RES_SUM_MAX > cSameIdTrainSum) + { + szSameIdTrainId[cSameIdTrainSum] = wRouteInFstLgcTrainId; /*·ⷽһ߼ԴгIDͬ洢гIDͬг1*/ + cSameIdTrainSum++; + } + else + { + cRetVal = CI_ERROR; /*Դгޣӣʧ*/ + } + break; + } + else + { + /**/ + } + } + } + else + { + /*һ*/ + } + + if (CI_SUCCESS != cRetVal) + { + + break; /*ʧܣֹͣ*/ + } + else + { + /*Ƚ*/ + } + } + } + else + { + /*·/ⷽһ߼Դг*/ + } + + if (CI_SUCCESS == cRetVal) + { + *pTrainNum = cSameIdTrainSum; + for (ii = 0U; ii < cSameIdTrainSum; ii++) + { + szTrainId[ii] = szSameIdTrainId[ii]; + } + } + else + { + /*ʧ*/ + } + } + else + { + /*ȡ·ʧܣʧ*/ + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* ·߼ԴID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +* qw.liu 2022-03-03 +*/ +void SetLgcSecResTrnIdOtherTiocRt(const UINT16 routeId, const UINT16 wTrainId) +{ + UINT8 chRouteType = 0U; + UINT8 chLogicSecResTrainSum = 0U; + UINT16 wLogicSum = 0U; + UINT16 wLogicSecId = 0U; + UINT16 ii = 0U; + UINT8 cLocalCiId = 0u; + UINT8 cRouteCiId = 0u; + UINT8 cLogicSecCiId = 0u; + UINT16 wOverlapId = 0u; + UINT8 cOverlapCiId = 0u; + UINT8 cRouteState = 0u; + UINT16 wLastLgcTrainId = 0U; + UINT8 cOverLapAddFlag = 0U; + const UINT16 *wszLogicSecId = GetRouteLogSectionIdBuf(routeId); + + cLocalCiId = GetSystemParaLocalCiId(); + chRouteType = GetRouteType(routeId); + wLogicSum = GetRouteLogSectionSum(routeId); + cRouteState = GetRouteState(routeId); + + /* ȡ·ID */ + cRouteCiId = GetRouteBelongCiId(routeId); + cOverLapAddFlag = CI_ERROR; + if ((MAX_ROUTE_IN_LT_NUM > wLogicSum) && (NULL != wszLogicSecId) && (0u != cLocalCiId)) + { + + /* ȡ·ձID */ + wOverlapId = GetRouteOverlapLockedId(routeId); + /* ȡID */ + cOverlapCiId = GetOverlapBelongCiId(wOverlapId); + + if (cRouteCiId != cLocalCiId) + { + if (ROUTE_TYPE_RETURN == chRouteType) + { + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + chLogicSecResTrainSum = GetLogSecTrainInfoSum(wLogicSecId); + if (1U != chLogicSecResTrainSum) + { + break; + } + } + + if (ii == wLogicSum) + { + wLastLgcTrainId = GetLogSecTrainIdByIndex(wszLogicSecId[ii-1U],0U); + if (wLastLgcTrainId == wTrainId) + { + cOverLapAddFlag = CI_SUCCESS; + } + } + else + { + + } + } + else if (ROUTE_TYPE_LIECHE == chRouteType) + { + cOverLapAddFlag = CI_SUCCESS; + } + else + { + /*޲*/ + } + } + else + { + ;/* DZ·ֻ */ + } + + /* δ */ + if ((0u != wOverlapId)&&(CI_SUCCESS==cOverLapAddFlag)) + { + /* ڽ·յıΣӱԴ */ + wLogicSum = GetOverlapLogicSectionSum(wOverlapId); + wszLogicSecId = GetOverlapLogicSectionBuf(wOverlapId); + + if ((NULL != wszLogicSecId) + && (OVLP_LOGICSECTION_SUM_MAX>wLogicSum)) + { + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + cLogicSecCiId = GetLogSecBelongCiId(wLogicSecId); + + if (cLogicSecCiId == cLocalCiId) + { + /*߼гԴϢ*/ + AddLogSecTrainRes(wLogicSecId, wTrainId); + } + } + } + } + + } + else + { + + } +} + +/* +* ͷűԴ +* ˵ const UINT16 wOverlapId, ID +* ֵ +* qw.liu 2022-06-10 +*/ +void ReleaseOverlapRes(const UINT16 wOverlapId) +{ + /* */ + UINT8 chRetVal = CI_ERROR; + UINT8 chFunRet = CI_ERROR; + UINT8 chOverlapLgcSecSum = 0U; + UINT16 *wpOverlapLgcSecIdBuf = NULL; + UINT16 wRouteId = 0U; + UINT8 ii = 0U; + UINT8 jj = 0U; + /* ·豸 */ + /*źŻ*/ + UINT8 chNotEnterRouteTrainSum = 0U; + UINT16 wszNotEtRouteTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + + chOverlapLgcSecSum = GetOverlapLogicSectionSum(wOverlapId); + wpOverlapLgcSecIdBuf = GetOverlapLogicSectionBuf(wOverlapId); + if (CI_ERROR != chOverlapLgcSecSum) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + /* ߼ */ + + + /* ·ʼźŻδѹ ǣ·ⷽΡСڷһ߼Ρռá*/ + if (CI_SUCCESS == chRetVal) + { + wRouteId = GetLogSecLockBelongRoute(wpOverlapLgcSecIdBuf[0]); + /* ͨ CBTC·ڵһ߼жгԴʱź*/ + if (0U < wRouteId) + { + chFunRet = GetRouteNotEnterTrainInfo(wRouteId, &chNotEnterRouteTrainSum, wszNotEtRouteTrainId); + if (CI_SUCCESS == chFunRet) + { + if ((0U < chNotEnterRouteTrainSum) + &&(LOGIC_SECTION_RES_SUM_MAX>chNotEnterRouteTrainSum)) + { + chRetVal = CI_SUCCESS; + for (jj = 0U; jj < chOverlapLgcSecSum; jj++) + { + for (ii = 0U; ii < chNotEnterRouteTrainSum; ii++) + { + RemoveLgcSecResTrain(wpOverlapLgcSecIdBuf[jj],wszNotEtRouteTrainId[ii]); + } + } + } + else + { + + } + } + else { + chRetVal = CI_ERROR; + } + + } + else + { + + } + + } + else + { + + } + +} + +/* +* ȡ·Ϊ·ԴгϢ +* ˵ const UINT16 routeId, ·ID pTrainNum г wszTrainId гIDBuf +* ֵ CI_ERROR :ȡʧ +* CI_SUCCESS:ȡɹ +*/ +UINT8 GetRouteNotEnterTrainInfo(const UINT16 wRouteId, UINT8 * pTrainNum, UINT16 wszTrainId[]) +{ + + UINT8 ii = 0u; /*±*/ + UINT8 jj = 0u; + UINT16 wRouteFirstLgcId = 0u; + UINT16 wRouteLastLgcId = 0u; + UINT8 chNotSameIdTrainSum = 0U; + UINT16 wszNotSameIdTrainSum[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + UINT16 wRouteFirstLgcTrainId = 0U; + UINT16 wRouteLastLgcTrainId = 0U; + UINT8 chRouteFirstLgcTrainSum = 0U; + UINT8 chRouteLastLgcTrainSum = 0U; + UINT8 ckeepWorkFlag = CI_ERROR; + UINT8 wRetVal = CI_ERROR; + + if ((NULL == pTrainNum) || (NULL == wszTrainId)) + { + ckeepWorkFlag = CI_ERROR; + } + else + { + ckeepWorkFlag = CI_SUCCESS; + } + + if (CI_SUCCESS == ckeepWorkFlag) + { + wRouteFirstLgcId = GetRouteInFirstLogSecId(wRouteId); + wRouteLastLgcId = GetRouteInLastLogSecId(wRouteId); + if ((CI_ERROR == wRouteFirstLgcId) + || (CI_ERROR == wRouteLastLgcId)) + { + ckeepWorkFlag = CI_ERROR; + } + else + { + chRouteFirstLgcTrainSum = GetLogSecTrainInfoSum(wRouteFirstLgcId); + chRouteLastLgcTrainSum = GetLogSecTrainInfoSum(wRouteLastLgcId); + } + } + + if (CI_SUCCESS == ckeepWorkFlag) + { + for (ii = 0; ii < chRouteFirstLgcTrainSum; ii++) + { + wRouteFirstLgcTrainId = GetLogSecTrainIdByIndex(wRouteFirstLgcId, ii); + for (jj = 0U; jj < chRouteLastLgcTrainSum; jj++) + { + wRouteLastLgcTrainId = GetLogSecTrainIdByIndex(wRouteLastLgcId, jj); + if ((wRouteFirstLgcTrainId == wRouteLastLgcTrainId) + && (0U != wRouteFirstLgcTrainId)) + { + + break; + } + } + + if (jj == chRouteLastLgcTrainSum) + { + wszNotSameIdTrainSum[chNotSameIdTrainSum] = wRouteFirstLgcTrainId; + chNotSameIdTrainSum += 1U; + } + } + } + if (CI_SUCCESS == ckeepWorkFlag) + { + *pTrainNum = chNotSameIdTrainSum; + for (ii = 0U; ii < chNotSameIdTrainSum; ii++) + { + wszTrainId[ii] = wszNotSameIdTrainSum[ii]; + } + wRetVal = CI_SUCCESS; + } + else + { + wRetVal = CI_ERROR; + } + + + return wRetVal; +} + +/* +* ȡʱȷϱ־ +* ˵ +* ֵ ȷϱ־ +*/ +UINT8 GetTsrSureFlag(void) +{ + return g_cTsrSureFlag; +} + +/* +* ʱȷϱ־ +* ˵cTsrSureFlag ȷϱ־ +* ֵ +*/ +void SetTsrSureFlag(UINT8 cTsrSureFlag) +{ + if ((CI_TSR_SURE_YES == cTsrSureFlag) || (CI_TSR_SURE_NO == cTsrSureFlag)) + { + g_cTsrSureFlag = cTsrSureFlag; + } +} + +/* +* ˹ռѹʱ· +* ˵ UINT16 wPhySecId, ID + +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CancelOutFirstFaultOccUnlock(UINT16 wPhySecId) +{ + /*ʼ*/ + UINT16 belongRouteId = 0u; + UINT8 chRetVal = CI_ERROR; + UINT8 chRouteState = 0U; + UINT8 chFuncRet = 0U; + UINT8 chAutoRouteSetState = 0U; + UINT8 chAutoSigRouteType = 0U; + UINT16 wRouteInFirstPhySecId = 0U; + belongRouteId = GetPhySecRLockBelongRouteId(wPhySecId); + chRouteState = GetRouteState(belongRouteId); + chFuncRet = AutoSignalOrRouteValid(belongRouteId); + wRouteInFirstPhySecId = GetSignalInFirstPhySecId(GetRouteStartSignalId(belongRouteId), belongRouteId); + if ((wRouteInFirstPhySecId == wPhySecId) && (0U != wPhySecId)) + { + if (ROUTE_STATE_NEAR_OPEN == chRouteState) + { + chRetVal = CI_SUCCESS; + if (CI_SUCCESS == chFuncRet) + { /*Զ·źЧ*/ + chAutoRouteSetState = GetRouteAutoRouteSetState(belongRouteId); + chAutoSigRouteType = GetRouteAutoSigSetState(belongRouteId);/*ȡ·ǰǷΪԶźŽ·*/ + + if ((chAutoRouteSetState == ROUTE_AUTOROUTE_RETURN) + || (chAutoRouteSetState == ROUTE_ALLAUTOROUTE_RETURN) + || (chAutoSigRouteType == ROUTE_AUTOSIGROUTE_YES)) + { + /*Զ۷·ɽ*//*ԶźŰת״̬ߣڽӽ߼д*/ + + SetRouteStateManage(belongRouteId, ROUTE_STATE_NEAR_LOCK); /*-->ýӽ*/ + } + else + { + SetRouteStateManage(belongRouteId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + } + else + { + SetRouteStateManage(belongRouteId, ROUTE_STATE_NEAR_LOCK); /*-->ýӽ*/ + } + } + } + + return (chRetVal); +} + +/** +* @brief гǰ߼ +* @param wTrainId гID +* @param pLogicSecSum ߼ +* @param szLogicSecIdBuf ߼ +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.8.23 +*/ +UINT8 CalTrainFrontLogicSecSeq(IN const UINT16 wTrainId, OUT UINT16 * pLogicSecSum, OUT UINT16 szLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM]) +{ + /*ʼ*/ + UINT8 cRetVal = CI_ERROR; + UINT8 cKeepWork = CI_ERROR; + UINT16 wLogicSecSum = 0U; + UINT16 wszTrainIncLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM] = {0U}; + UINT16 tmpACCnt = 0U; + UINT16 tmpAcIdBuf[AC_MAXCNT_IN_SWITCH] = {0U}; + struct_PathPoint stTrainTailPoint = { 0U }; + UINT16 wTrainMinTailLink = 0U; + UINT32 dwTrainMinTailOff = 0U; + UINT16 wAxisSecIncLogicSum = 0U; + UINT16 *pAxisSecIncLogicSecIdBuf = NULL; + UINT16 wCurrentAxisSecId = UINT16_MAX; + UINT16 wNextAxisSecId = UINT16_MAX; + UINT8 cSearchDir = UINT8_MAX; + UINT8 chCycFlag = CI_ERROR; + UINT16 wFuncRetVal = 0u; + UINT8 cRetMem = 0U; + UINT8 chStartAddFlag = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT8 chLocalCiId = 0U; + UINT8 chAxisSecBelongCiId = 0U; + UINT16 wTmpLogicId = 0U; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT8 changeFlag = 0u; + UINT8 cDirectionPointCnt = 0U; /*仯*/ + UINT8 cResUsableLogSecNum = 0U; /*Դõ߼*/ + UINT16 wMinTailBelongAxle = 0U; /*СڼID*/ + UINT16 wMinTailBelongLogSec = 0U; /*С߼ID*/ + UINT16 szPossibleLgcIdBuf[POINT_BELONG_LGC_MAX] = { 0U }; /*ĿʱгСܴڵ߼*/ + UINT8 cPossibleLgcNum = 0U; + + /*ѯ*/ + cSearchDir = GetTrainDir(wTrainId);/*Сȫ˷*/ + chLocalCiId = GetSystemParaLocalCiId(); + if ((DIR_SAME == cSearchDir)|| (DIR_CONVERT == cSearchDir)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cSearchDir = DIR_INVALID; + cKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == cKeepWork) + { + /*μ*/ + if ((NULL != pLogicSecSum) && (NULL != szLogicSecIdBuf)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + /*0ʧ*/ + } + + if (CI_SUCCESS == cKeepWork) + { + wTrainMinTailLink = GetTrainMinTailLink(wTrainId); + dwTrainMinTailOff = GetTrainMinTailOffset(wTrainId); + stTrainTailPoint.wLinkId = wTrainMinTailLink; + stTrainTailPoint.dwOffset = dwTrainMinTailOff; + wMinTailBelongLogSec = GetPointBelongLogSec(stTrainTailPoint); + /*ȡСȫ˵ID*/ + funRtn =GetAxisSeqFromLinkSeq(&wTrainMinTailLink, 1u, tmpAcIdBuf, &tmpACCnt, AC_MAXCNT_IN_SWITCH); + if ((CI_SUCCESS == funRtn) && (0u != tmpACCnt)) + { + wCurrentAxisSecId = GetAxisIdFromAxisSeqSafeSw(tmpAcIdBuf, tmpACCnt); + if (0U == wCurrentAxisSecId) + { + /*гβʼ*/ + wCurrentAxisSecId = tmpAcIdBuf[0]; + wMinTailBelongAxle = wCurrentAxisSecId; + } + else + { + wMinTailBelongAxle = wCurrentAxisSecId; + /*ֵǰID*/ + chCycFlag = CI_SUCCESS; + do + { + /*ӳβʼѯԴõ*/ + tmpACCnt = FindAdjacentAC(wCurrentAxisSecId, (~cSearchDir), tmpAcIdBuf, &changeFlag); + + if ((UINT8_MAX != tmpACCnt) && (0U != tmpACCnt)) + { + if (1U != tmpACCnt) + { + wNextAxisSecId = GetAxisIdFromAxisSeqSafeSw(tmpAcIdBuf, tmpACCnt); + } + else + { + wNextAxisSecId = tmpAcIdBuf[0]; + } + + if (0U != wNextAxisSecId) + { + wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wNextAxisSecId); + pAxisSecIncLogicSecIdBuf = GetAxisSecLogSectionIdBuf(wNextAxisSecId); + chAxisSecBelongCiId = GetAxisSectionBelongCiId(wNextAxisSecId); + if ((wAxisSecIncLogicSum != 0U) && (pAxisSecIncLogicSecIdBuf != NULL)) + { + if ((chAxisSecBelongCiId == chLocalCiId) && (0U != chAxisSecBelongCiId)) + { + if ((TRAIN_INCLUDE_RES_MAX_SUM > wLogicSecSum) && ((TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) > wAxisSecIncLogicSum)) + { + cSearchDir = TransDirectionPointDir(changeFlag, cSearchDir, &cDirectionPointCnt); /*ݷ仯ת*/ + cResUsableLogSecNum = GetResUsableLogSecNumInAxis(wNextAxisSecId, wTrainId, cSearchDir, &wszTrainIncLogicSecIdBuf[wLogicSecSum]); /*ȡԴõ߼*/ + + if ((UINT8_MAX != cResUsableLogSecNum) && (0U != cResUsableLogSecNum)) + { + wCurrentAxisSecId = wNextAxisSecId; /*ҳβ*/ + ii += wAxisSecIncLogicSum; /*ʹüֹѭۼ*/ + + if (cResUsableLogSecNum != wAxisSecIncLogicSum) + { + chCycFlag = CI_ERROR; /*üδ߼Դãֹͣҳβ*/ + } + } + else + { + cSearchDir = TransDirectionPointDir(changeFlag, cSearchDir, &cDirectionPointCnt); /*ԴãΣѯسһεķ*/ + chCycFlag = CI_ERROR; /*Դãֹͣҳβ*/ + } + } + else + { + chCycFlag = CI_ERROR; /*ޣֹͣҳβ*/ + } + } + else + { + chCycFlag = CI_ERROR; /*ѯDZΣֹͣҳβ*/ + } + } + else + { + chCycFlag = CI_ERROR; /*ȡΰ߼ʧܣֹͣҳβ*/ + } + } + else + { + chCycFlag = CI_ERROR; /*һIDΪ0ֹͣҳβ*/ + } + } + else + { + chCycFlag = CI_ERROR; /*ѯʧܣֹͣҳβ*/ + } + + } while ((ii < TRAIN_INCLUDE_RES_MAX_SUM) && (CI_SUCCESS == chCycFlag)); + } + + (void)CommonMemSet(wszTrainIncLogicSecIdBuf, (UINT32)(TRAIN_INCLUDE_RES_MAX_SUM * sizeof(UINT16)), 0U, (UINT32)(TRAIN_INCLUDE_RES_MAX_SUM * sizeof(UINT16))); /*ʼǰѯ洢߼*/ + + wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wCurrentAxisSecId); + pAxisSecIncLogicSecIdBuf = GetAxisSecLogSectionIdBuf(wCurrentAxisSecId); + chAxisSecBelongCiId = GetAxisSectionBelongCiId(wCurrentAxisSecId); + + if ((wAxisSecIncLogicSum != 0U) && (pAxisSecIncLogicSecIdBuf != NULL)) + { + /*ѯڼΪTIOC*/ + if ((chAxisSecBelongCiId == chLocalCiId) && (0U != chAxisSecBelongCiId)) + { + /*жϲԽ*/ + if ((TRAIN_INCLUDE_RES_MAX_SUM > wLogicSecSum) && ((TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) > wAxisSecIncLogicSum)) + { + cResUsableLogSecNum = GetResUsableLogSecNumInAxis(wCurrentAxisSecId, wTrainId, cSearchDir, &wszTrainIncLogicSecIdBuf[wLogicSecSum]); /*ȡԴõ߼*/ + + if ((UINT8_MAX != cResUsableLogSecNum) && (0U != cResUsableLogSecNum)) + { + wLogicSecSum += cResUsableLogSecNum; + chStartAddFlag = CI_SUCCESS; + } + else if (wMinTailBelongAxle == wCurrentAxisSecId) + { + /*ΪСڼΣҼ޿ԴҲӦӴΣӰ쳵ǰԴس*/ + if (0U == wMinTailBelongLogSec) + { + /*гСĿʱȡС߼IDΪ0ٻȡСڵ߼ΣϼȷС߼*/ + cPossibleLgcNum = GetPointBelongLogSecEx(stTrainTailPoint, szPossibleLgcIdBuf); + for (ii = 0U; ii < wAxisSecIncLogicSum; ii++) + { + for (jj = 0U; jj < cPossibleLgcNum; jj++) + { + if (pAxisSecIncLogicSecIdBuf[ii] == szPossibleLgcIdBuf[jj]) + { + wMinTailBelongLogSec = szPossibleLgcIdBuf[jj]; + break; + } + else + { + /**/ + } + } + + if (0U != wMinTailBelongLogSec) + { + break; + } + else + { + /**/ + } + } + } + else + { + /*ʹõǰ߼ΪгС*/ + } + + cResUsableLogSecNum = (UINT8)GetLgcSecSeqBelongAc(wMinTailBelongLogSec, wCurrentAxisSecId, cSearchDir, &wszTrainIncLogicSecIdBuf[wLogicSecSum]); + wLogicSecSum += cResUsableLogSecNum; + chStartAddFlag = CI_SUCCESS; + } + else + { + /**/ + } + } + } + else + { + ; /*DZΣ*/ + } + } + else + { + cKeepWork = CI_ERROR; /*Ч0ʧ*/ + } + } + else + { + /*ڵڹ涨λʱѯʧ ,޸߼λֺϸ*/ + cKeepWork = CI_ERROR; + } +#if 0 + wTmpLogicId = GetPointBelongLogSec(stTrainTailPoint); + /** жϲѯǷɹ */ + if (0U != wTmpLogicId) + { + /*ȡгڼ*/ + wCurrentAxisSecId = GetLgcSecRelativeAxleSecId(wTmpLogicId); + wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wCurrentAxisSecId); + chAxisSecBelongCiId = GetAxisSectionBelongCiId(wCurrentAxisSecId); + /*Ч*/ + if (0 != wAxisSecIncLogicSum) + { + /*ѯڼΪTIOC*/ + if ((chAxisSecBelongCiId == chLocalCiId) + &&(0U!=chAxisSecBelongCiId)) + { + /*жϲԽ*/ + if ((TRAIN_INCLUDE_RES_MAX_SUM > wLogicSecSum) + && ((TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) > wAxisSecIncLogicSum)) + { + wFuncRetVal = GetLgcSecSeqBelongAc(wTmpLogicId,cSearchDir,wszTrainIncLogicSecIdBuf); + if (0U < wFuncRetVal) + { + wLogicSecSum += wFuncRetVal; + chStartAddFlag = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + chStartAddFlag = CI_ERROR; /*Set CI_ERROR*/ + } + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + /**˴βĿȳ ѯʧ*/ + } +#endif + } + + if (CI_SUCCESS == cKeepWork) + { + chCycFlag = CI_SUCCESS; + do + { + /*ȡһlinkID*/ + tmpACCnt = FindAdjacentAC(wCurrentAxisSecId, cSearchDir, tmpAcIdBuf, &changeFlag); + + /*ǰlinkһlink֮ڷ仯㣬ҷ*/ + cSearchDir = TransDirectionPointDir(changeFlag, cSearchDir, &cDirectionPointCnt); + + if ((UINT8_MAX != tmpACCnt)&&(0U!=tmpACCnt)) + { + if (1U != tmpACCnt) + { + wNextAxisSecId = GetAxisIdFromAxisSeqSafeSw(tmpAcIdBuf, tmpACCnt); + } + else + { + wNextAxisSecId = tmpAcIdBuf[0]; + } + if (0U != wNextAxisSecId) + { + wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wNextAxisSecId); + pAxisSecIncLogicSecIdBuf = GetAxisSecLogSectionIdBuf(wNextAxisSecId); + chAxisSecBelongCiId = GetAxisSectionBelongCiId(wNextAxisSecId); + /*Ч*/ + if ((wAxisSecIncLogicSum != 0U) && (pAxisSecIncLogicSecIdBuf != NULL)) + { + /*ѯڼΪTIOC*/ + if ((chAxisSecBelongCiId == chLocalCiId) && (0U != chAxisSecBelongCiId)) + { + /*жϲԽ*/ + if ((TRAIN_INCLUDE_RES_MAX_SUM > wLogicSecSum) && ((TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) > wAxisSecIncLogicSum)) + { + if (DIR_SAME == cSearchDir) + { + wTmpLogicId = pAxisSecIncLogicSecIdBuf[0]; + } + else + { + wTmpLogicId = pAxisSecIncLogicSecIdBuf[wAxisSecIncLogicSum - 1U]; + } + wFuncRetVal = GetLgcSecSeqBelongAc(wTmpLogicId, wNextAxisSecId, cSearchDir, (UINT16*)&wszTrainIncLogicSecIdBuf[wLogicSecSum]); + if (wAxisSecIncLogicSum == wFuncRetVal) + { + wLogicSecSum += wAxisSecIncLogicSum; + chStartAddFlag = CI_SUCCESS; + } +#if 0 + cRetMem = CommonMemCpy(((void *)&wszTrainIncLogicSecIdBuf[wLogicSecSum]), (TRAIN_INCLUDE_RES_MAX_SUM - wLogicSecSum) * sizeof(UINT16), \ + (void *)pAxisSecIncLogicSecIdBuf, wAxisSecIncLogicSum * sizeof(UINT16)); + if (CI_SUCCESS == cRetMem) + { + /**/ + wLogicSecSum += wAxisSecIncLogicSum; + cRetVal = CI_SUCCESS; + chStartAddFlag = CI_SUCCESS; + } + else + { + ; /*DO NOTHING*/ + } +#endif + } + else + { + chCycFlag = CI_ERROR; + } + } + else + { + if (CI_SUCCESS == chStartAddFlag) + { + /*Ѿӹѯڱʱ˳*/ + chCycFlag = CI_ERROR; + } + } + } + else + { + cKeepWork = CI_ERROR; + chCycFlag = CI_ERROR; + } + } + else + { + /*ڹ涨λã˳ѯ*/ + chCycFlag = CI_ERROR; + } + + } + else + { + chCycFlag = CI_ERROR; /**ѯʧ*/ + } + + wCurrentAxisSecId = wNextAxisSecId; + + if (CI_ERROR == chCycFlag) + { + break; + } + else + { + ; /*ѭ*/ + } + } while (wLogicSecSum < TRAIN_INCLUDE_RES_MAX_SUM); + + } + else + { + ; /***/ + } + + if (CI_SUCCESS == cKeepWork) + { + debug_infor_printf((const)"ResRetreat TrainIncLogicSecId:["); + for (ii = 0U; ii < wLogicSecSum; ii++) + { + debug_infor_printf((const)"%d,", wszTrainIncLogicSecIdBuf[ii]); + } + debug_infor_printf((const)"]\n"); + + /*ͨ*/ + cRetMem = CommonMemCpy(szLogicSecIdBuf, (UINT32)(TRAIN_INCLUDE_RES_MAX_SUM * sizeof(UINT16)), wszTrainIncLogicSecIdBuf, (UINT32)(wLogicSecSum * sizeof(UINT16))); + if (CI_SUCCESS == cRetMem) + { + /**/ + *pLogicSecSum = wLogicSecSum; + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; + } + + } + else + { + cRetVal = CI_ERROR; + } + + return cRetVal; +} + +/** +* @brief ȡг߼ +* @param wTrainId гID +* @param pLogicSecSum ߼ +* @param szLogicSecIdBuf ߼ +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.8.23 +*/ +UINT8 GetTrainUsableLogicSec(IN const UINT16 wTrainId, OUT UINT16 * pLogicSecSum, OUT UINT16 szLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM]) +{ + /*ʼ*/ + UINT8 cRetVal = CI_ERROR; + UINT8 cKeepWork = CI_ERROR; + UINT16 wLogicCurSum = 0U; + UINT16 wLogicSecId = 0U; + UINT16 wTrainUsableLogicSum = 0U; + UINT16 wszTrainIncLogicIdBuf[TRAIN_INCLUDE_RES_MAX_SUM] = { 0U }; + UINT16 ii = 0U; + UINT8 chTrainUsableStt = 0U; + UINT8 chFlagExec = CI_ERROR; + UINT8 cRetMem = 0u; + UINT8 chLocalCiId = 0U; + UINT8 chLogicSecBelongCiId = 0U; + + /*ȡCI ID*/ + + chLocalCiId = GetSystemParaLocalCiId(); + wLogicCurSum = GetLogicSecCurSum(); + + + + /*μ*/ + if ((NULL != pLogicSecSum) && (NULL != szLogicSecIdBuf)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == cKeepWork) + { + for (ii = 0u; ii < wLogicCurSum; ii++) + { + + chFlagExec = CI_ERROR; + chTrainUsableStt = LOGIC_SECTION_RES_UNUSABLE; + wLogicSecId = GetLogicSecId(ii); + chLogicSecBelongCiId = GetLogSecBelongCiId(wLogicSecId); /*ȡ߼ID*/ + chTrainUsableStt = GetLogSecTrainResUsableState(wLogicSecId, wTrainId); + if ((0u == wLogicSecId) || (LOGIC_SECTION_SUM_MAX < wLogicSecId)) + { + chFlagExec = CI_ERROR; + } + else + { + chFlagExec = CI_SUCCESS; + } + + if (CI_SUCCESS == chFlagExec) + { + if (chLogicSecBelongCiId != chLocalCiId) + { + chFlagExec = CI_ERROR; + } + else + { + ; /*ִ*/ + } + } + if (CI_SUCCESS == chFlagExec) + { + if (LOGIC_SECTION_RES_USABLE == chTrainUsableStt) + { + if (TRAIN_INCLUDE_RES_MAX_SUM > wTrainUsableLogicSum) + { + wszTrainIncLogicIdBuf[wTrainUsableLogicSum++] = wLogicSecId; + } + } + } + } + } + else + { + ; /* */ + } + + + if (CI_SUCCESS == cKeepWork) + { + /*ͨ*/ + cRetMem = CommonMemCpy(szLogicSecIdBuf, (UINT32)(TRAIN_INCLUDE_RES_MAX_SUM * sizeof(UINT16)), wszTrainIncLogicIdBuf, (UINT32)(wTrainUsableLogicSum * sizeof(UINT16))); + if (CI_SUCCESS == cRetMem) + { + /**/ + *pLogicSecSum = wTrainUsableLogicSum; + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; + } + + } + else + { + cRetVal = CI_ERROR; + } + + return cRetVal; +} + + +/* +* ȡ߼ռϢ +* ˵ void +* ֵ +* LOGICSECTION_OCCUPY_UT +* LOGICSECTION_OCCUPY_CT +* LOGICSECTION_OCCUPY_NO +*/ +UINT8 GetPhySecUtOrCtOccuState(UINT16 phySectionId) +{ + UINT8 const logicSecSum = GetPhySecIncLogSecSum(phySectionId); + UINT16* const pLogicSecIdBuf = GetPhySecIncLogSecIdBuf(phySectionId); + + UINT8 jj = 0u; + UINT8 logicOccupyState = 0u; + UINT8 reValue = LOGICSECTION_OCCUPY_UT; + + if (0u == logicSecSum) + { + reValue = LOGICSECTION_OCCUPY_UT; + } + else + { + + for (jj = 0u; jj < logicSecSum; jj++) + { + logicOccupyState = GetLogSecCurCtOrUtOccupyState(pLogicSecIdBuf[jj]); + if(LOGICSECTION_OCCUPY_CT == logicOccupyState) + { + /*CTռ ִ*/ + reValue = LOGICSECTION_OCCUPY_CT; + }else if(LOGICSECTION_OCCUPY_NO == logicOccupyState) + { + ; /*ռѹִ*/ + } + else + { + /*һ߼UTռ*/ + reValue = LOGICSECTION_OCCUPY_UT; + break; + } + } + + } + return reValue; +} + + +/* +* ָIDȨ־ +* ˵ const UINT8 virtualCiId ID + const UINT8 ctrlPowerFlag ״̬ + const UINT16 ctrlPowerId 豸 + const UINT8 ctrlDeviceType 豸 + + +* ֵ viod +* +*/ +void SetCtrlPower(const UINT8 virtualCiId, const UINT8 ctrlPowerFlag, const UINT16 ctrlPowerId, const UINT8 ctrlDeviceType) +{ + UINT8 i = 0u; + UINT8 cimode = 0u; + UINT8 virtualCiNum = 0u; + cimode = GetCiModeFlag(); + virtualCiNum = GetVirtualCINum(); + if (CI_MODE_ATS != cimode) + { + if (virtualCiNum <= VIRTUAL_CI_MAX) + { + for (i = 0u; i < virtualCiNum; i++) + { + if ((CONTRAL_POWER_YES == ctrlpowerFlag[i].ctrlPowerState) && (virtualCiId == ctrlpowerFlag[i].virCiId)) + {/*ȨȨʱԭȨϢ*/ + ctrlpowerFlag[i].ctrlPowerState = CONTRAL_POWER_NO; + ctrlpowerFlag[i].ctrlDeviceId = 0u; + ctrlpowerFlag[i].ctrlDeviceType = 0u; + } + } + for (i = 0u; i < virtualCiNum; i++) + { + if (virtualCiId == ctrlpowerFlag[i].virCiId) + { /*Ȩ¸豸ȨϢ*/ + ctrlpowerFlag[i].ctrlPowerState = ctrlPowerFlag; + ctrlpowerFlag[i].ctrlDeviceId = ctrlPowerId; + ctrlpowerFlag[i].ctrlDeviceType = ctrlDeviceType; + } + } + } + } + else + { + /*ִ*/ + } + +} +/* +* ͷָIDȨ־ +* ˵ const UINT8 virtualCiId ID + const UINT8 ctrlPowerFlag ״̬ + const UINT16 ctrlPowerId 豸 + const UINT8 ctrlDeviceType 豸 + + +* ֵ viod +* +*/ +void ReleaseCtrlPower(const UINT8 virtualCiId, const UINT8 ctrlPowerFlag, const UINT16 ctrlPowerId, const UINT8 ctrlDeviceType) +{ + + UINT8 ii = 0U; + UINT8 virtualCiNum = 0U; + UINT8 chXiandiHavePower = 0U;/*ϵʼֵǷ߱Ȩ*/ + + chXiandiHavePower = GetCiFunctionSwitchConfig(FUNC_INIT_XIANDI_HAVE_POWER); + virtualCiNum = GetVirtualCINum(); + + if (virtualCiNum <= VIRTUAL_CI_MAX) + { + for (ii = 0U; ii < virtualCiNum; ii++) + { + if (virtualCiId == ctrlpowerFlag[ii].virCiId) + { + ctrlpowerFlag[ii].ctrlDeviceId = 0U; + if (FUNC_SWITCH_ON == chXiandiHavePower) + { + ctrlpowerFlag[ii].ctrlDeviceType = CI_SYSTEM_TYPE_XIANDI; + ctrlpowerFlag[ii].ctrlPowerState = CONTRAL_POWER_YES; + } + else + { + ctrlpowerFlag[ii].ctrlDeviceType = 0U; + ctrlpowerFlag[ii].ctrlPowerState = CONTRAL_POWER_NO; + } + + } + } + } +} +/* +* ȡԶ־ +* ˵ UINT8 virCIid ID +* UINT8 setFlag õԶ־ +* ֵ +* cgh-ϲCID-3037-4 +*/ +void CancelAutoTriggerLogicManage(UINT8 virCIid, UINT8 setFlag) +{ + UINT16 ii = 0u; + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT16 routeId = 0u; /*·ID*/ + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + /*·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = GetRouteId(ii); /*ȡ·ID*/ + CancelSigleRouteAutoTrigger(virCIid, routeId, setFlag); /*ȡԶ־Ľ·Զ־*/ + } +} +/* +* ָ·Զ־ +* ˵UINT8 virCIid ID + UINT16 routeId ·ID +* UINT8 setFlag õԶ־ +* ֵ +*/ +void SetSigleRouteAutoTriggerManage(UINT8 virCIid, UINT16 routeId, UINT8 setFlag) +{ + UINT8 chkFState = CI_ERROR; + UINT8 chkFloodState = CI_ERROR; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongVirCI = 0u; + UINT8 flag = 0u; + UINT8 autoTriggerType = 0u; /*Զ·*/ + + autoTriggerType = GetAutoTriggerType(routeId); /*ȡ·Զ·*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + if (ROUTE_TYPE_AUTO_TRIGGER == autoTriggerType) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCI = GetRouteBelongVirCiId(routeId); + if (belongVirCI != virCIid) + { + flag = 1u; + } + } + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX) || (belongCiId != localCiId) || (1u == flag)) + { + /*IDЧDZ*/ + } + else + { + /*Զ·״̬*/ + chkFState = ChekAutoTriggerRouteFlockState(routeId); + + if (CI_SUCCESS == chkFState) + { + /*Զ·״̬*/ + chkFloodState = ChekAutoTrigRouteFloodGateState(routeId); + + if (CI_SUCCESS == chkFloodState) + { + if (AUTO_TRIGGER_SET_YES == setFlag) + { + SetRouteAutoTriggerFlag(routeId, setFlag); /*ñָԶ·Զ*/ + } + } + else + { + /*·Զʧ*/ + SetCiSendCmdBackInfoData(CI_BACK_AUTO_TRIGGER_SET_ERR, CI_DEVICE_TYPE_ROUTE, routeId, 0u, 0u);/*·Զ־ʧ*/ + } + } + else + { + /*·Զʧ*/ + SetCiSendCmdBackInfoData(CI_BACK_AUTO_TRIGGER_SET_ERR, CI_DEVICE_TYPE_ROUTE, routeId, 0u, 0u);/*·Զ־ʧ*/ + } + } + } +} + +/* +* ȡָ·Զ־ +* ˵ UINT8 virCIid ID +* UINT16 routeId ·ID +* UINT8 setFlag õԶ־ +* ֵ +* cgh-ϲCID-3037-4 +*/ +void CancelSigleRouteAutoTrigger(UINT8 virCIid, UINT16 routeId, UINT8 setFlag) +{ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongVirCI = 0u; + UINT8 flag = 0u; + UINT8 routeAutoTriggerFlag = 0u; /*Զ־*/ + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + flag = 0u; + if (FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCI = GetRouteBelongVirCiId(routeId); + if (belongVirCI != virCIid) + { + flag = 1u; + } + } + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX) || (belongCiId != localCiId) || (1u == flag)) + { + /*IDЧDZ*/ + } + else + { + routeAutoTriggerFlag = GetRouteAutoTriggerFlag(routeId); /*ȡ·Զ־*/ + if (AUTO_TRIGGER_SET_YES == routeAutoTriggerFlag) + { + SetRouteAutoTriggerFlag(routeId, setFlag); /*ñָԶ·Զ*/ + } + } +} +/* +* վ̨ͱ־ +* ˵UINT16 phySecId ID +* UINT8 setFlag õͱ־ +* ֵ +* cgh-ϲCID-3037-7 +*/ +void SetClearPassenagerManage(UINT16 phySecId, UINT8 setFlag) +{ + UINT16 psdSum = 0u; /**/ + UINT16 psdRelatPhySecId = 0u; /*ŹID*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 devBelongCiId = 0u; /*豸*/ + UINT16 ii = 0u; /*α*/ + UINT16 psdId = 0u; + + localCiId = GetSystemParaLocalCiId(); + devBelongCiId = GetPhySecBelongCiId(phySecId); + if (localCiId != devBelongCiId) + { + /**/ + } + else + { + psdSum = GetPsdSum(); /*ȡ*/ + for (ii = 0u; ii < psdSum; ii++) + { + psdId = GetPsdId(ii); + psdRelatPhySecId = GetPsdRelatedPhySecId(psdId); /*ȡŹID*/ + if (phySecId == psdRelatPhySecId) + { + if (ATS_TO_CI_PLATFORM_QK_YES == setFlag) + { + SetClearPassenagerFlag(psdId, setFlag); /*ͱ־*/ + } + break; + } + } + } +} + + +/* +* ý·߼ԴгID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +* qw.liu 2022-03-03 +* @note bug 20220420 淶ɾע +*/ +void SetRouteHalfLogSecResTrainId(const UINT16 routeId, const UINT16 wTrainId) +{ + UINT8 chRouteType = 0U; + UINT8 chLogicSecResTrainSum = 0U; + UINT16 wLogicSum = 0U; + UINT16 wLogicSecId = 0U; + UINT16 ii = 0U; + UINT16 wRouteLastPhySecId = 0U; + UINT16 wLogicSecRelativePhySecId = 0U; + UINT16 wGroupOtherTrainId = 0U; + LogicTrainResStruct *pstLgcTrnResInfo = NULL; + UINT8 cLocalCiId = 0u; + UINT8 cRouteCiId = 0u; + UINT8 chReturnLogAddFlag = CI_ERROR; + UINT16 wLogicPLockRouteId = 0U; + UINT8 funcRet = CI_ERROR; + const UINT16 *wszLogicSecId = GetHalfRouteLockLgcSecIdBuf(routeId); + UINT8 chLocalCiType = 0U;/**/ + + cLocalCiId = GetSystemParaLocalCiId(); + wLogicSum = GetHalfRouteLockLgcSecSum(routeId); + chLocalCiType = GetLocalCiType(); + + if ((CI_TYPE_TCC == chLocalCiType) || (CI_TYPE_CLD == chLocalCiType)) + { + /* ȡ·*/ + chRouteType = GetConfigRouteType(routeId); + } + else + { + /* ȡ·*/ + chRouteType = GetRouteType(routeId); + } + + /* ȡ·ID */ + cRouteCiId = GetRouteBelongCiId(routeId); + if ((MAX_ROUTE_IN_LT_NUM > wLogicSum) + && (NULL != wszLogicSecId) + && (0u != cLocalCiId) + &&(0U!=wTrainId)) + { + if (cRouteCiId == cLocalCiId) + { + if (ROUTE_TYPE_RETURN == chRouteType) + { + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + funcRet = CheckLgcSecNotInTrainLoc(routeId, wLogicSecId); + if (CI_SUCCESS == funcRet) + { + wLogicPLockRouteId = GetLogSecPLockRouteId(wLogicSecId); + chLogicSecResTrainSum = GetLogSecTrainInfoSum(wLogicSecId); + if (0U < chLogicSecResTrainSum) + { + if (0U == wLogicPLockRouteId) + { + break; + } + else + { + + } + } + } + } + + if (ii == wLogicSum) + { + chReturnLogAddFlag = CI_SUCCESS; + } + else + { + /*жǰ뱾Ϊͬһг--Դ*/ + wGroupOtherTrainId = GetGroupTrainOtherId(wTrainId); + pstLgcTrnResInfo = GetLogSecTrainInfoById(wLogicSecId, wGroupOtherTrainId); + if (NULL != pstLgcTrnResInfo) + { + chReturnLogAddFlag = CI_SUCCESS; + } + else + { + chReturnLogAddFlag = CI_ERROR; + } + } + + if (CI_SUCCESS == chReturnLogAddFlag) + { + /*·Դ*/ + wRouteLastPhySecId = GetRouteLastPhySectionId(routeId); + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + + funcRet = CheckLgcSecNotInTrainLoc(routeId, wLogicSecId); + if (CI_SUCCESS == funcRet) + { + /*߼гԴϢ*/ + AddLogSecTrainRes(wLogicSecId, wTrainId); + wLogicSecRelativePhySecId = GetLgcSecRelativePhySecId(wLogicSecId); + if ((wRouteLastPhySecId == wLogicSecRelativePhySecId) + && (0U != wLogicSecRelativePhySecId)) + { + SetLogSecTrainReturnState(wLogicSecId, wTrainId, LOGIC_SECTION_TRAIN_RETURN_YES); + } + else + { + /*ִ*/ + } + } + } + } + else + { + + } + } + else if (ROUTE_TYPE_LIECHE == chRouteType) + { + for (ii = 0U; ii < wLogicSum; ii++) + { + wLogicSecId = wszLogicSecId[ii]; + funcRet = CheckLgcSecNotInTrainLoc(routeId, wLogicSecId); + if (CI_SUCCESS == funcRet) + { + /*߼гԴϢ*/ + AddLogSecTrainRes(wLogicSecId, wTrainId); + } + else + { + SetLogSecTrainReturnState(wLogicSecId, wTrainId, LOGIC_SECTION_TRAIN_RETURN_NO); /*۷־*/ + } + } + } + else + { + /* */ + } + } + else + { + ;/* DZ·*/ + } + } + else + { + /* */ + } +} + +/* +*:·ֹλ +* +*: const UINT16 routeId ·ID +* +*:. +* +*ֵ: +* +*/ +void ClearRouteHalfSwitchDrivePos(const UINT16 routeId) +{ + UINT8 retValOfSetSwiExpDrvPos = CI_ERROR; /*õλõķֵ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct *pLgcSecSwitchData = NULL; + UINT8 ii = 0u; /*ѭ*/ + UINT8 jj = 0U; + + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + /*ȡ·߼Ϣ*/ + logSectionSum = GetHalfRouteLockLgcSecSum(routeId); + pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId); + routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru); /*ȡ*/ + + if (NULL != pLogIdBuff) + { + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX) + { + for (jj = 0u; jj < lgcSecSwitchSum; jj++) + { + switchId = pLgcSecSwitchData[jj].SwitchId; + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if (CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + } + } + + if (NULL != routeProtectSwitchStru) + { + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = routeProtectSwitchStru[ii].ProtectSwitchId; + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if (CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + +} + +/* +*:·ֹλ +* +*: const UINT16 routeId ·ID +* +*:. +* +*ֵ: +* +*/ +void ClearRouteHalfSwitchDanCaoPos(const UINT16 routeId) +{ + UINT8 retValOfSetSwiDanCaoPos = CI_ERROR; /*õλõķֵ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct *pLgcSecSwitchData = NULL; + UINT8 ii = 0u; /*ѭ*/ + UINT8 jj = 0U; + + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + /*ȡ·߼Ϣ*/ + logSectionSum = GetHalfRouteLockLgcSecSum(routeId); + pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId); + routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru); /*ȡ*/ + + if (NULL != pLogIdBuff) + { + /*·ڵ*/ + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if ((NULL!= pLgcSecSwitchData) + &&(lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)) + { + for (jj = 0u; jj < lgcSecSwitchSum; jj++) + { + switchId = pLgcSecSwitchData[jj].SwitchId; + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if (CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + } + } + + if (NULL != routeProtectSwitchStru) + { + /*·*/ + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = routeProtectSwitchStru[ii].ProtectSwitchId; + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if (CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + +} + +/* +*:߼·λ +*: const UINT16 routeId ·ID +*:. +*ֵ: +*/ +void ClearLogRouteSwitchDrivePos(const UINT16 logRouteId) +{ + UINT8 retValOfSetSwiExpDrvPos = CI_ERROR; /*õλõķֵ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct* pLgcSecSwitchData = NULL; + UINT8 ii = 0u; /*ѭ*/ + UINT8 jj = 0U; + + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + /*ȡ·߼Ϣ*/ + logSectionSum = GetLogicalRouteInLogSecSum(logRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId); + routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, routeProtectSwitchStru); /*ȡ*/ + + if (NULL != pLogIdBuff) + { + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX) + { + for (jj = 0u; jj < lgcSecSwitchSum; jj++) + { + switchId = pLgcSecSwitchData[jj].SwitchId; + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if (CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + } + } + + if (NULL != routeProtectSwitchStru) + { + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = routeProtectSwitchStru[ii].ProtectSwitchId; + /*øõλΪЧ*/ + retValOfSetSwiExpDrvPos = SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if (CI_SUCCESS == retValOfSetSwiExpDrvPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + +} + +/* +*:߼·λ +*: const UINT16 routeId ·ID +*:. +*ֵ: +*/ +void ClearLogRouteSwitchDanCaoPos(const UINT16 logRouteId) +{ + UINT8 retValOfSetSwiDanCaoPos = CI_ERROR; /*õλõķֵ*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct* pLgcSecSwitchData = NULL; + UINT8 ii = 0u; /*ѭ*/ + UINT8 jj = 0U; + + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + /*ȡ·߼Ϣ*/ + logSectionSum = GetLogicalRouteInLogSecSum(logRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId); + routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, routeProtectSwitchStru); /*ȡ*/ + + if (NULL != pLogIdBuff) + { + /*·ڵ*/ + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if ((NULL != pLgcSecSwitchData) + && (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)) + { + for (jj = 0u; jj < lgcSecSwitchSum; jj++) + { + switchId = pLgcSecSwitchData[jj].SwitchId; + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if (CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + } + } + + if (NULL != routeProtectSwitchStru) + { + /*·*/ + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = routeProtectSwitchStru[ii].ProtectSwitchId; + /*øõλΪЧ*/ + retValOfSetSwiDanCaoPos = SetSwitchDanCaoPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + if (CI_SUCCESS == retValOfSetSwiDanCaoPos) + { + + } + else + {/*ʧ*/ + /*ijһλʧܵȻλ*/ + } + } + } + +} +/* +* ΰȫ߼״̬ +* ˵ const UINT16 phyId ID, const UINT8 lockState ״̬ +* ֵ1 +* 0: +*/ +void SetPhyIncAllLogLockState(const UINT16 phyId, const UINT8 lockState) +{ + /*ʼ*/ + UINT16 i = 0U; + UINT16 j = 0U; + UINT8 chAlexSum = 0U; + UINT16* pAxisIdBuf = NULL; + UINT8 chLogSectionSum = 0U; + UINT16* pLogIdBuf = NULL; + UINT16 wLogBelongRoute = 0U; + UINT8 chRouteDir = 0U; + UINT16 logBelongRoute = 0U; + + /*ȡϢ*/ + chAlexSum = GetPAxisSectionSum(phyId); + pAxisIdBuf = GetPAxisSectionIdBuf(phyId); + + /*Ϣȷ*/ + if (0u < chAlexSum) + { + for (i = 0u; i < chAlexSum; i++) + { + /*ȡ߼Ϣ*/ + chLogSectionSum = GetAxisSecLogSectionSum(pAxisIdBuf[i]); + pLogIdBuf = GetAxisSecLogSectionIdBuf(pAxisIdBuf[i]); + /*߼Ϣȷ*/ + if ((0u < chLogSectionSum) && (NULL != pLogIdBuf)) + { + for (j = 0u; j < chLogSectionSum; j++) + { + /*ȡ߼·*/ + logBelongRoute = GetLogSecLockBelongRoute(pLogIdBuf[j]); + chRouteDir = GetRouteDirection(wLogBelongRoute); + /*öӦ߼״̬*/ + SetLogSecLockState(pLogIdBuf[j], lockState, logBelongRoute, chRouteDir); + } + } + else + { + /*޲*/ + } + } + } + else + { + } +} + +/* +: · +: const UINT16 routeId ·ID +: +ֵ: CI_SUCCESS,մɹ +CI_ERROR,մʧ +*/ +UINT8 RouteLockHalfDriveSwitch(const UINT16 routeId) +{ + UINT8 ii = 0u; + UINT8 jj = 0U; + UINT16 switchId = 0u; + UINT8 switchExpPosition = SWITCH_POSITION_INVALID; /*λ*/ + UINT8 switchDancaoPosition = SWITCH_POSITION_INVALID; /*Чλ*/ + UINT8 innerSwitchRetVal = CI_ERROR; /*·ڵǷɱĽ*/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct *pLgcSecSwitchData = NULL; + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + /*ȡ·߼Ϣ*/ + logSectionSum = GetHalfRouteLockLgcSecSum(routeId); + pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId); + routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru); /*ȡ*/ + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)||(0U==logSectionSum)) + { + innerSwitchRetVal = CI_ERROR; + } + else + { + innerSwitchRetVal = CI_SUCCESS; + + if (NULL != pLogIdBuff) + { + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if ((NULL != pLgcSecSwitchData) + && (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)) + { + for (jj = 0u; jj < lgcSecSwitchSum; jj++) + { + switchId = pLgcSecSwitchData[jj].SwitchId; + switchExpPosition = pLgcSecSwitchData[jj].SwitchPosition; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + + if ((SWITCH_POSITION_INVALID == switchDancaoPosition) + || + (switchDancaoPosition == switchExpPosition)) + {/*Ч λ붯λһ*/ + innerSwitchRetVal = CI_SUCCESS; + } + else + { + /*ٵ෴λȡ·*/ + innerSwitchRetVal = CI_ERROR; + break; + } + } + } + else + { + innerSwitchRetVal = CI_ERROR; + } + if (CI_SUCCESS != innerSwitchRetVal) + { + break; + } + } + } + else + { + innerSwitchRetVal = CI_ERROR; + } + if (CI_SUCCESS == innerSwitchRetVal) + { + + /* ෴λȡ· */ + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = routeProtectSwitchStru[ii].ProtectSwitchId; + switchExpPosition = routeProtectSwitchStru[ii].ProtectPosition; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + + if ((SWITCH_POSITION_INVALID == switchDancaoPosition) + || + (switchDancaoPosition == switchExpPosition)) + {/*Ч λ붯λһ*/ + innerSwitchRetVal = CI_SUCCESS; + } + else + { + /*ٵ෴λȡ·*/ + innerSwitchRetVal = CI_ERROR; + break; + } + } + } + else + { + innerSwitchRetVal = CI_ERROR; + } + + + if (CI_SUCCESS == innerSwitchRetVal) + { + /*·*/ + RouteHalfDrvInnerSwitch(routeId, SWITCH_NEED_DRIV_TRUE); + } + else + { + RouteHalfDrvInnerSwitch(routeId, SWITCH_NEED_DRIV_FALSE); + } + + } + + return innerSwitchRetVal; +} + +/* +: ·յ + : const UINT16 routeId ·ID + : const UINT8 DrivFlag ־ +ֵ : +*/ +void RouteHalfDrvInnerSwitch(const UINT16 routeId, const UINT8 DrivFlag) +{ + UINT8 ii = 0u; + UINT8 jj = 0U; + UINT8 funRtn = 0U; + UINT16 switchId = 0u; + UINT8 switchExpPos = SWITCH_POSITION_INVALID; /*λ*/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct *pLgcSecSwitchData = NULL; + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + /*ȡ·߼Ϣ*/ + logSectionSum = GetHalfRouteLockLgcSecSum(routeId); + pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId); + routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru); /*ȡ*/ + + if (SWITCH_NEED_DRIV_TRUE == DrivFlag) + {/*Ҫ·ڵ*/ + if (NULL != pLogIdBuff) + { + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if ((NULL != pLgcSecSwitchData) + && (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)) + { + for (jj = 0u; jj < lgcSecSwitchSum; jj++) + { + switchId = pLgcSecSwitchData[jj].SwitchId; + switchExpPos = pLgcSecSwitchData[jj].SwitchPosition; + funRtn = SwitchDriveProcess(switchId, switchExpPos); /*ý·ڵ״̬Ϊ*/ + } + } + } + + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = routeProtectSwitchStru[ii].ProtectSwitchId; + switchExpPos = routeProtectSwitchStru[ii].ProtectPosition; + funRtn = SwitchDriveProcess(switchId, switchExpPos); /*ý·״̬Ϊ*/ + } + } + + } +} + +/* +: ؿźŴ + : const UINT16 signalId źŻID + : const UINT8 yLockState ״̬ +ֵ : +*/ +void LeadzLockOpenSignal(const UINT16 signalId, const UINT8 yLockState) +{ + UINT16 starSigRouteSum = 0u; /*ͬźŻΪʼ˵Ľ·Ŀ*/ + UINT16* starSigRouteBuf = NULL; /*ͬźŻΪʼ˵Ľ·ID*/ + UINT8 signalYLockOpenState = 0u; + UINT16 jj = 0u; /*ѭ*/ + UINT16 routeId = 0u;/*·IDʱ*/ + UINT8 routeCiId = 0u;/*·CIʱ*/ + UINT8 driveColor = 0u; /*źſɫ*/ + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT16 autoRouteState = 0U; /*·Զ·״̬*/ + UINT16 autoReturnState = 0U;/*Զ۷״̬*/ + UINT16 allAutoRoute =0U;/*ȫԶ۷ID*/ + + signalYLockOpenState = GetSignalYLockOpenState(signalId); + if ((SIGNAL_OPEN == signalYLockOpenState) && (CI_ALL_SWITCH_YLOCK_YES == yLockState)) + {/*޸ڣ20171227ա޸ԭԽ߳źſź׵*/ + if ((SIGNAL_SHOWCOLOUR_RED == GetSignalCurColor(signalId)) + || (SIGNAL_SHOWCOLOUR_REDYELLOW == GetSignalCurColor(signalId)) + || (SIGNAL_SHOWCOLOUR_RED_WHITE == GetSignalCurColor(signalId))) + { + starSigRouteSum = GetStartSignalRouteSum(signalId); + starSigRouteBuf = GetStartSignalRouteBuf(signalId); + + if ((NULL != starSigRouteBuf) && (starSigRouteSum != 0u)) + {/*ȡĽ·ID*/ + for (jj = 0u; jj < starSigRouteSum; jj++) + { + routeId = 0u; /*·ID*/ + routeCiId = 0u; /*·ID*/ + driveColor = 0u; /*źſɫ*/ + routeId = starSigRouteBuf[jj]; + + if ((0u < routeId) && (ROUTE_SUM_MAX > routeId)) + { + routeCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((routeCiId == localCiId) && (0u != localCiId)) + { + /*ÿŵź*/ + driveColor = GetRouteLeadSignalOpenColor(routeId);/*·ɫ*/ + if (SIGNAL_SHOWCOLOUR_RED_WHITE == driveColor) + {/*źŻΪδźŻ򿪷ź׵*/ + SetSignalCurDriveColor(signalId, SIGNAL_SHOWCOLOUR_RED_WHITE); + } + else if (SIGNAL_SHOWCOLOUR_REDYELLOW == driveColor) + {/*ƵƴܵźŻźƵ*/ + SetSignalCurDriveColor(signalId, SIGNAL_SHOWCOLOUR_REDYELLOW); + } + else + { + /*ܵźŻɫIJ*/ + } + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*ý·źؿ־Ч*/ + /*ý·Զ·Ч*/ + autoRouteState =GetRouteAutoRouteId(routeId); /*ȡ·Զ·״̬*/ + autoReturnState = GetRouteAutoReturnId(routeId);/*ȡԶ۷״̬*/ + allAutoRoute = GetRouteAllAutoReturnId(routeId);/*ȡȫԶ۷ID*/ + SetAutoRouteSetFlag(autoRouteState , AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(autoReturnState, AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(allAutoRoute , ALL_AUTO_RETURN_SET_NO); + if (ROUTE_TYPE_AUTO_TRIGGER == GetAutoTriggerType(routeId)) + {/**/ + SetRouteAutoTriggerFlag(routeId, AUTO_TRIGGER_SET_NO); + } + } + } + } + } + } + else + { + SetSignalYLockOpenState(signalId, SIGNAL_CLOSE); + } + } + else + { + /**/ + } +} + +/* +: ؿź¹ܴ + : const UINT16 signalId źŻID + : const UINT8 yLockState ״̬ +ֵ : +*/ +void LeadzLockNewOpenManage(const UINT16 signalId, const UINT8 yLockState) +{ + UINT8 wSignalLeadRouteCbtcFlag = 0U; /*źŻĽ·ǷԣCBTCͷCBTC*/ + UINT8 wLeadCheckFlag = 0U; /*־*/ + UINT8 signalYLockOpenState = 0u; + /**/ + UINT8 const functionId = EFUNC_SIGNAL_LEAD_OPEN_LOCK; + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS; + + + /*ҪCBTCĽ·ͷCBTCĽ·dzɶԶΪ0xaaɶߣߺCBTCζΪ0xbbҪCBTCβ0xaa*/ + wSignalLeadRouteCbtcFlag = GetSignalLeadRouteCbtcFlag(signalId); + switch (wSignalLeadRouteCbtcFlag) + { + case SIGNAL_LEADROUTE_ALLCBTC: + /*dzμؿźţؿ߼*/ + wLeadCheckFlag = 1U; + break; + case SIGNAL_LEADROUTE_ALL_NO_CBTC: + LeadzLockOpenSignal(signalId, yLockState); /*ȫźŻĽ·ڷCBTCֱԭ߼ؿź*/ + break; + case SIGNAL_LEADROUTE_CBTC_ANDNO: + LeadzLockSignalOpenRouteCheck(signalId, yLockState); + break; + default: + /*·账*/ + break; + } + + if (1U == wLeadCheckFlag) + { + /*ؿźű־*/ + signalYLockOpenState = GetSignalYLockOpenState(signalId); + if ((SIGNAL_OPEN == signalYLockOpenState) && (CI_ALL_SWITCH_YLOCK_YES == yLockState)) + { + SetSignalYLockOpenState(signalId, SIGNAL_CLOSE); + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, signalId, ETYPE_SIG_LEAD_ALL_LOCK, CI_ERROR, sendLevel); + } + } + else + { + ; /**/ + } +} + + +/* +: ΣCBTCзCBTC򣬼·Уźؿ + : const UINT16 signalId źŻID + : const UINT8 yLockState ״̬ +ֵ : +*/ +void LeadzLockSignalOpenRouteCheck(const UINT16 signalId, const UINT8 yLockState) +{ + /**/ + UINT8 const functionId = EFUNC_LeadzLockSignalOpenRouteCheck; + UINT16 starSigRouteSum = 0u; /*ͬźŻΪʼ˵Ľ·Ŀ*/ + UINT16* starSigRouteBuf = NULL; /*ͬźŻΪʼ˵Ľ·ID*/ + UINT16 jj = 0u; /*ѭ*/ + UINT16 routeId = 0u;/*·IDʱ*/ + UINT8 routeState = 0U; + UINT8 signalYLockOpenState = 0u; + + + signalYLockOpenState = GetSignalYLockOpenState(signalId); + if ((SIGNAL_OPEN == signalYLockOpenState) && (CI_ALL_SWITCH_YLOCK_YES == yLockState)) + { + starSigRouteSum = GetStartSignalRouteSum(signalId); + starSigRouteBuf = GetStartSignalRouteBuf(signalId); + if ((NULL != starSigRouteBuf) && (starSigRouteSum != 0u)) + {/*н·ǷΪУвܸؿźŻĽ·յģ򲻸ؿͬʱATS*/ + for (jj = 0u; jj < starSigRouteSum; jj++) + { + routeId = 0u; /*·ID*/ + routeId = starSigRouteBuf[jj]; + routeState = GetRouteState(routeId); + + if (ROUTE_STATE_IDLE != routeState) + { + break; + } + else + { + ; /*ѯһ·״̬*/ + } + } + + if (jj == starSigRouteSum) + { + LeadzLockOpenSignal(signalId, yLockState); /*ȫźŻĽ·Уִؿź߼*/ + } + else + { + SetSignalYLockOpenState(signalId, SIGNAL_CLOSE); + /* ¼,ATSϱн·ǿ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, routeState, ESEND_LEVEL_ATS); + } + } + } + else + { + ; /**/ + } +} + +/* +* ·Ƿ߼ +* ˵ UINT16 routeId · +* , UINT8 *pOtherCiId ID +* ֵ1ִгɹ +* 0: ִʧ +* by cgh 20231007 +*/ +UINT8 RouteHaveLogSecBelongOtherCi(const UINT16 routeId, UINT8* pOtherCiId) +{ + UINT16 chRouteLogSecSum = 0U; /*·߼*/ + UINT16* pRouteLogSecId = NULL; /*·߼*/ + UINT16 ii = 0U; + UINT8 chRouteBelongCi = 0U;/*·*/ + UINT8 chLogSecBelongCi = 0U;/*߼*/ + UINT8 reVal = CI_ERROR; + + chRouteLogSecSum = GetRouteLogSectionSum(routeId); /*ý·Ŀ*/ + pRouteLogSecId = GetRouteLogSectionIdBuf(routeId);/*ȡ·߼*/ + chRouteBelongCi = GetRouteBelongCiId(routeId); + + if ((NULL == pRouteLogSecId) || (NULL == pOtherCiId)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + + for (ii = 0u; ii < chRouteLogSecSum; ii++) + { + chLogSecBelongCi = GetLogSecBelongCiId(pRouteLogSecId[ii]); + if (chRouteBelongCi != chLogSecBelongCi) + { + *pOtherCiId = chLogSecBelongCi; + break; + } + } + } + return reVal; +} + +/* +* ·ڱ߼ѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +* by cgh 20231007 +*/ +UINT8 CheckLocalCiRouteLogSecUnLock(const UINT16 routeId) +{ + UINT16 chRouteLogSecSum = 0U; /*·߼*/ + UINT16* pRouteLogSecId = NULL; /*·߼*/ + UINT16 ii = 0U; + UINT8 chRouteBelongCi = 0U;/*·*/ + UINT8 chLogSecBelongCi = 0U;/*߼*/ + UINT8 reVal = CI_ERROR; + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chLogSecLockState = 0U;/*߼״̬*/ + UINT16 wLogSecLockBelongRoute = 0U;/*߼·*/ + + chLocalCiId = GetSystemParaLocalCiId(); + chRouteLogSecSum = GetRouteLogSectionSum(routeId); /*ý·Ŀ*/ + pRouteLogSecId = GetRouteLogSectionIdBuf(routeId);/*ȡ·߼*/ + + if (NULL == pRouteLogSecId) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + for (ii = 0u; ii < chRouteLogSecSum; ii++) + { + chLogSecLockState = GetLogSecLockState(pRouteLogSecId[ii]); + wLogSecLockBelongRoute = GetLogSecLockBelongRoute(pRouteLogSecId[ii]); + chLogSecBelongCi = GetLogSecBelongCiId(pRouteLogSecId[ii]); + chRouteBelongCi = GetRouteBelongCiId(routeId); + + if ((chLogSecBelongCi == chRouteBelongCi) && (chLocalCiId == chLogSecBelongCi)) + {/*ڱIJ,δջյIJDZ·*/ + if (((LOG_SECTION_LOCK_NO == chLogSecLockState) || + ((LOG_SECTION_LOCK_NO != chLogSecLockState) && (routeId != wLogSecLockBelongRoute)))) + { /*δջDZ·*/ + } + else + { + reVal = CI_ERROR; + break; + } + } + } + } + return reVal; +} + +/* +* ̵ӿ¼DZĽ·ڣڱ߼Ƿѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +* by cgh 20231007 +*/ +UINT8 CheckRouteLogSecUnLock(const UINT16 routeId) +{ + UINT16 chRouteLogSecSum = 0U; /*߼*/ + UINT16* pRouteLogSecId = NULL; /*߼*/ + UINT16 ii = 0U; + UINT8 reVal = CI_ERROR; + UINT8 chRouteBelongCi = 0U;/*·*/ + UINT8 chLocalCi = 0U;/*ID*/ + UINT8 chLogSecBelongCi = 0U;/*߼*/ + UINT8 chLogLockState = 0u;/*߼״̬*/ + UINT8 chCommState = 0u;/*ͨ״̬*/ + UINT32 dwCurCycle = 0u;/*ǰں*/ + UINT8 chFuncSwitch = 0U;/*Ƿ̵ּ֧ӿ*/ + UINT8 chConfirmRelayInterfaceFlag = 0U;/*̵ӿȷ״̬*/ + + chFuncSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + chConfirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + chRouteLogSecSum = GetRouteLogSectionSum(routeId); /*ý·Ŀ*/ + pRouteLogSecId = GetRouteLogSectionIdBuf(routeId);/*ȡ·߼*/ + chRouteBelongCi = GetRouteBelongCiId(routeId);/*·ID*/ + chLocalCi = GetSystemParaLocalCiId();/*ID*/ + + if (NULL == pRouteLogSecId) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + chCommState = GetLocalCiAndOtherCiTransSta(chRouteBelongCi);/*ͨͨ״̬*/ + /*·ڱ·ڱζѽ*/ + if ((chLocalCi != chRouteBelongCi) && (TRANSMIT_STATE_BAD == chCommState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == chConfirmRelayInterfaceFlag) && + (FUNC_SWITCH_ON == chFuncSwitch)) + { + for (ii = 0u; ii < chRouteLogSecSum; ii++) + { + chLogSecBelongCi = GetLogSecBelongCiId(pRouteLogSecId[ii]); + chLogLockState = GetLogSecLockState(pRouteLogSecId[ii]); + dwCurCycle = Get2oo2CurCycleNum(); + if (chLocalCi == chLogSecBelongCi) + { /*ڱδ*/ + if (LOG_SECTION_LOCK_NO == chLogLockState) + { + } + else + { + debug_infor_printf((const)"CheckNo, pRouteLogSecId:%d chLogLockState:%d curCycle:%d\n", + pRouteLogSecId[ii], chLogLockState, dwCurCycle); + reVal = CI_ERROR; + break; + } + } + } + } + } + return reVal; +} + +/* +* ҵ߼·ڵһ߼յ߼ +* ˵ const UINT16 wLogRouteId ߼·ID +* ֵ = 0 Ч +* > 0 ߼ID +* by cgh 20231012 +*/ +UINT16 GetLogRouteFirNormalLockLogId(const UINT16 wLogRouteId) +{ + UINT16 wLogRouteLogSecNum = 0U;/*߼·߼*/ + UINT16* pLogRouteLogSecIdBuf = NULL;/*߼·߼ID*/ + UINT16 ii = 0U; + UINT16 wReVal = CI_ERROR; + UINT8 chCheckFlag = 0U;/*־*/ + UINT8 chLogSecLogLockSta = 0U;/*߼߼״̬*/ + + if (ROUTE_LOGICAL_SUM_MAX > wLogRouteId) + { + /*ȡ߼·߼*/ + wLogRouteLogSecNum = GetLogicalRouteInLogSecSum(wLogRouteId); + pLogRouteLogSecIdBuf = GetLogicalRouteInLogSecId(wLogRouteId); + + if (NULL != pLogRouteLogSecIdBuf) + { + for (ii = 0U; ii < wLogRouteLogSecNum; ii++) + { + chCheckFlag = CheckLogSecLockBelLogRoute(pLogRouteLogSecIdBuf[ii], wLogRouteId); + if (CI_SUCCESS == chCheckFlag) + { + chLogSecLogLockSta = GetLogSecLogLockState(pLogRouteLogSecIdBuf[ii]); + + if (LOG_SECTION_LOGLOCK_NORMAL == chLogSecLogLockSta) + { + wReVal = pLogRouteLogSecIdBuf[ii]; + break; + } + else + { + ; /**/ + } + } + else + { + ;/*һ*/ + } + } + } + else + { + ; /*ִ*/ + } + } + else + { + ; /*ִ*/ + } + + + return wReVal; + +} + +/* +* ߼Ƿָ߼· +* ˵ const UINT16 wLogSection ߼ID + const UINT16 wLogRouteId ߼·ID +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20231012 +*/ +UINT8 CheckLogSecLockBelLogRoute(const UINT16 wLogSection,const UINT16 wLogRouteId) +{ + UINT8 chLogSecLockBelLogRouteSum = 0U;/*߼߼·*/ + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT16 wLogSecLockBelLogRouteId = 0U;/*߼߼·ID*/ + UINT8 ii = 0U; + UINT8 wReVal = CI_ERROR; + + if ((ROUTE_LOGICAL_SUM_MAX > wLogRouteId) && (LOGIC_SECTION_SUM_MAX > wLogSection)) + { + /*ȡ߼߼·*/ + chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSection); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSection); + + if (NULL != szLogSecLockBelLogRouteData) + { + for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++) + { + wLogSecLockBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId; + if (wLogRouteId == wLogSecLockBelLogRouteId) + { + wReVal = CI_SUCCESS; + break; + } + } + } + else + { + ; /*ִ*/ + } + } + else + { + ; /*ִ*/ + } + return wReVal; +} + +/* +* ΰ߼߼״̬ +* ˵ const UINT16 wPhySecId, ID + const UINT8 chLockState, ߼״̬ + const UINT16 wLogRouteId ߼·ID +* ֵ +* by cgh 20231013 +*/ +void SetPhyIncLogSecLogLockState(const UINT16 wPhySecId, const UINT8 chLockState, const UINT16 wLogRouteId) +{ + /*ʼ*/ + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT8 chAxisSum = 0U;/*Ŀ*/ + UINT16* pAxisIdBuf = NULL;/*ID*/ + UINT8 chLogSectionSum = 0U;/*߼Ŀ*/ + UINT16* pLogSecIdBuf = NULL;/*߼ID*/ + UINT8 chCheckFlag = 0U;/*־*/ + UINT8 chLogLockDir = 0U;/*߼շ*/ + + /*ȡϢ*/ + chAxisSum = GetPAxisSectionSum(wPhySecId); + pAxisIdBuf = GetPAxisSectionIdBuf(wPhySecId); + + /*Ϣȷ*/ + if (0U < chAxisSum) + { + for (ii = 0U; ii < chAxisSum; ii++) + { + /*ȡ߼Ϣ*/ + chLogSectionSum = GetAxisSecLogSectionSum(pAxisIdBuf[ii]); + pLogSecIdBuf = GetAxisSecLogSectionIdBuf(pAxisIdBuf[ii]); + /*߼Ϣȷ*/ + if ((0U < chLogSectionSum) && (NULL != pLogSecIdBuf)) + { + for (jj = 0U; jj < chLogSectionSum; jj++) + { + chCheckFlag = CheckLogSecLockBelLogRoute(pLogSecIdBuf[jj], wLogRouteId); + + if (CI_SUCCESS == chCheckFlag) + { + chLogLockDir = GetLogSecLogLockDir(pLogSecIdBuf[jj]); + SetLogSecLogLockState(pLogSecIdBuf[jj], chLockState, chLogLockDir); + } + } + } + else + { + /*޲*/ + } + } + } + else + { + ; /**/ + } +} + +/* +* ȡ߼α߼·յ߼· +* ˵ const UINT16 wLogSection ߼ID + const UINT16 wLogRouteId ߼·ID +* ֵ ߼· +* by cgh 20231013 +*/ +UINT8 GetLogSecLogLockBelRouteDir(const UINT16 wLogSection, const UINT16 wLogRouteId) +{ + UINT8 chLogSecLockBelLogRouteSum = 0U;/*߼߼·*/ + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT16 wLogSecLockBelLogRouteId = 0U;/*߼߼·ID*/ + UINT8 ii = 0U; + UINT8 wReVal = CI_ERROR; + + if ((ROUTE_LOGICAL_SUM_MAX > wLogRouteId) && (LOGIC_SECTION_SUM_MAX > wLogSection)) + { + /*ȡ߼߼·*/ + chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogRouteId); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogRouteId); + + if (NULL != szLogSecLockBelLogRouteData) + { + for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++) + { + wLogSecLockBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId; + if (wLogRouteId == wLogSecLockBelLogRouteId) + { + wReVal = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteDir; + break; + } + } + } + else + { + ; /*ִ*/ + } + } + else + { + ; /*ִ*/ + } + return wReVal; +} + +/* +* ߼·߼ȫ +* ˵ UINT16 wLogRouteId ߼· +* ֵCI_SUCCESS +* CI_ERROR: +* by cgh 20231013 +*/ +UINT8 CheckLogRouteLogSecHaveUnLock(const UINT16 wLogRouteId) +{ + UINT8 chReVal = CI_ERROR; + UINT16 wLogRouteInLogSecSum = 0U;/*߼·߼Ŀ*/ + UINT16* szLogRouteInLogSecIdBuf = NULL;/*߼·߼ID*/ + UINT16 ii = 0U; + UINT8 chLogSecLogLockState = 0U;/*߼߼״̬*/ + + if ((0U < wLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wLogRouteId)) + { + wLogRouteInLogSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + szLogRouteInLogSecIdBuf = GetLogicalRouteInLogSecId(wLogRouteId); + + if (NULL != szLogRouteInLogSecIdBuf) + { + for (ii = 0U; ii < wLogRouteInLogSecSum; ii++) + { + chReVal = CheckLogSecLockBelLogRoute(szLogRouteInLogSecIdBuf[ii], wLogRouteId); + + if (CI_SUCCESS == chReVal) + { + chLogSecLogLockState = GetLogSecLogLockState(szLogRouteInLogSecIdBuf[ii]); + + if (LOG_SECTION_LOGLOCK_NO != chLogSecLogLockState) + { + /*ڱ߼·߼εδ״̬ʧ*/ + break; + } + else + { + ; /*ͨж*/ + } + } + else + { + ; /**/ + } + } + if (wLogRouteInLogSecSum == ii) + { + chReVal = CI_SUCCESS; + } + else + { + chReVal = CI_ERROR; + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + return chReVal; +} + +/* +* ΰ߼εĽ·״̬ +* ˵ const UINT16 wPhySecId ID +* UINT16* pLogSecLockId յ߼ID +* UINT8* pState ߼״̬ +* ֵ CI_SUCCESS ߼ζδ +* CI_ERROR ߼δ +* Created By LQ 2023/10/17 +*/ +UINT8 CheckPSecIncLSecLockState(const UINT16 wPhySecId, UINT16* pLogSecLockId, UINT8* pState) +{ + UINT8 retVal = CI_ERROR; + UINT8 i = 0U; + UINT8 cPhySecIncLogSecSum = 0U; /*ΰ߼*/ + UINT16* pPhySecIncLogSecId = NULL; /*ΰ߼ID*/ + UINT8 cLogSecLockState = 0U; /*߼״̬*/ + + if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId) && (NULL != pLogSecLockId) && (NULL != pState)) + { + /*ȡι߼Ϣ*/ + cPhySecIncLogSecSum = GetPhySecIncLogSecSum(wPhySecId); + pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(wPhySecId); + + if ((0U != cPhySecIncLogSecSum) && (NULL != pPhySecIncLogSecId)) + { + /*߼״̬*/ + for (i = 0U; i < cPhySecIncLogSecSum; i++) + { + cLogSecLockState = GetLogSecLockState(pPhySecIncLogSecId[i]); + if (LOG_SECTION_LOCK_NO == cLogSecLockState) + { + retVal = CI_SUCCESS; /*߼δգسɹ*/ + } + else + { + *pLogSecLockId = pPhySecIncLogSecId[i]; + *pState = cLogSecLockState; + retVal = CI_ERROR; /*߼α·գʧ*/ + break; + } + } + } + else + { + /*ȡΰ߼ʧܣʧ*/ + } + } + else + { + /*ηǷʧ*/ + } + return(retVal); +} + +/* +* ΰ߼ε߼·״̬ +* ˵ const UINT16 wPhySecId ID +* UINT16* pLogSecLockId յ߼ID +* UINT8* pState ߼߼״̬ +* ֵ CI_SUCCESS ߼ζδ +* CI_ERROR ߼δ +* Created By LQ 2023/10/17 +*/ +UINT8 CheckPSecIncLSecLogicLockState(const UINT16 wPhySecId, UINT16* pLogSecLockId, UINT8* pState) +{ + UINT8 retVal = CI_ERROR; + UINT8 i = 0U; + UINT8 cPhySecIncLogSecSum = 0U; /*ΰ߼*/ + UINT16* pPhySecIncLogSecId = NULL; /*ΰ߼ID*/ + UINT8 cLogSecLockState = 0U; /*߼߼״̬*/ + UINT8 cLockBelongLogicRouteNum = 0U; /*߼߼߼·*/ + + if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId) && (NULL != pLogSecLockId) && (NULL != pState)) + { + /*ȡι߼Ϣ*/ + cPhySecIncLogSecSum = GetPhySecIncLogSecSum(wPhySecId); + pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(wPhySecId); + + if ((0U != cPhySecIncLogSecSum) && (NULL != pPhySecIncLogSecId)) + { + /*߼״̬*/ + for (i = 0U; i < cPhySecIncLogSecSum; i++) + { + cLogSecLockState = GetLogSecLogLockState(pPhySecIncLogSecId[i]); + cLockBelongLogicRouteNum = GetLogSecLockBelLogRouteSum(pPhySecIncLogSecId[i]); + + if ((LOG_SECTION_LOGLOCK_NO == cLogSecLockState) && (0U == cLockBelongLogicRouteNum)) + { + retVal = CI_SUCCESS; /*߼δ߼գسɹ*/ + } + else + { + *pLogSecLockId = pPhySecIncLogSecId[i]; + *pState = cLogSecLockState; + retVal = CI_ERROR; /*߼α߼·գʧ*/ + break; + } + } + } + else + { + /*ȡΰ߼ʧܣʧ*/ + } + } + else + { + /*ηǷʧ*/ + } + + return retVal; +} + +/* +* ȡָ·״̬ +* ˵ const UINT16 wRouteId, ·ID +* ֵ 0: ȡʧ +* 1: · +* by cgh 20231113 +*/ +UINT8 GetDiaoCheRouteOpenState(const UINT16 wRouteId) +{ + UINT8 retVal = CI_ERROR; + UINT8 chRouteType = 0U;/*·*/ + UINT8 chRouteState = 0U;/*·״̬*/ + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + chRouteType = GetRouteType(wRouteId); + if (ROUTE_TYPE_DIAOCHE == chRouteType) + { + chRouteState = GetRouteState(wRouteId); + if ((ROUTE_STATE_YUXIAN_OPEN == chRouteState) + || (ROUTE_STATE_NEAR_OPEN == chRouteState)) + { + retVal = CI_SUCCESS; + } + else + { + ; /*·ţʧ*/ + } + } + else + { + ; /*ǵ·ʧ*/ + } + } + else + { + ; /*ʧ*/ + } + return retVal; +} + +/* +* ñѩվ̨Ϣ +* ˵const UINT8 cAreaSnowNum ѩ +* const UINT32 pAreaSnowIdBuf[] ѩID +* ֵ +*/ +void SetLocalAreaSnowInfo(const UINT8 cAreaSnowNum, const UINT32 pAreaSnowIdBuf[]) +{ + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT16 kk = 0U; + UINT8 cPlatFormRelSpksNum = 0U; /*վ̨SPKS*/ + UINT16 szPlatFormRelSpksId[PLATFORM_REL_SPKS_NUM_MAX] = { 0U }; /*վ̨SPKS ID*/ + UINT16 wSpksIndex = 0U; + UINT16 wSpksRelPhySecNum = 0U; /*SPKS*/ + UINT16 wSpksRelPhySecId = 0U; /*SPKSID*/ + UINT8 cPhySecBelongCiId = 0U; /*SPKSε*/ + UINT8 cLocalCiId = 0U; /*CI ID*/ + + if ((LOCAL_AREA_SNOW_SUM_MAX >= cAreaSnowNum) && (NULL != pAreaSnowIdBuf)) + { + /*ѩվ̨Ϣͷ͸ѩϢ*/ + ClearCiSendAreaSnowInfo(); + (void)CommonMemSet(szLocalAreaSnowId, (UINT32)(sizeof(UINT32) * LOCAL_AREA_SNOW_SUM_MAX), 0U, (UINT32)(sizeof(UINT32) * LOCAL_AREA_SNOW_SUM_MAX)); + + LocalAreaSnowNum = cAreaSnowNum; + for (ii = 0U; ii < cAreaSnowNum; ii++) + { + szLocalAreaSnowId[ii] = pAreaSnowIdBuf[ii]; /*洢ѩ״̬Ϣ*/ + + /*жǷҪͱѩվ̨*/ + cLocalCiId = GetSystemParaLocalCiId(); + cPlatFormRelSpksNum = GetPlatFormRelSpksNum((UINT16)pAreaSnowIdBuf[ii], szPlatFormRelSpksId); /*ȡվ̨SPKS*/ + + if (CI_ERROR != cPlatFormRelSpksNum) + { + /*վ̨SPKSжSPKSǷзDZ*/ + for (jj = 0U; jj < cPlatFormRelSpksNum; jj++) + { + wSpksIndex = GetSpksConfigBufIndex(szPlatFormRelSpksId[jj]); + if (SPKS_SUM_MAX > wSpksIndex) + { + wSpksRelPhySecNum = GetSpksPhySecSumByIndex(wSpksIndex); + + for (kk = 0U; kk < wSpksRelPhySecNum; kk++) + { + wSpksRelPhySecId = GetSpksPhySecId(szPlatFormRelSpksId[jj], kk); + cPhySecBelongCiId = GetPhySecBelongCiId(wSpksRelPhySecId); + + if ((cLocalCiId != cPhySecBelongCiId) && (0U != cLocalCiId) && (0U != cPhySecBelongCiId)) + { + AddCiSendAreaSnowInfo(cLocalCiId, cPhySecBelongCiId, pAreaSnowIdBuf[ii]); /*վ̨зDZΣCIվ̨ID*/ + } + else + { + /**/ + } + } + } + else + { + /*¸ѩ*/ + } + } + } + else + { + /*ȡվ̨SPKSʧܣ*/ + } + } + } + else + { + /*ηǷ*/ + } +} + +/* +* ȡѩվ̨ +* ˵ +* ֵ ѩվ̨ +*/ +UINT8 GetLocalAreaSnowNum(void) +{ + return LocalAreaSnowNum; +} + +/* +* ȡѩվ̨ID +* ˵ +* ֵ ѩվ̨ID +*/ +UINT32* GetLocalAreaSnowId(void) +{ + return szLocalAreaSnowId; +} + + +/* +* ·ڵһյDzǹ +* ˵ UINT16 routeId, ·ID +* UINT16 ID һյIDΣ +* ֵ 0 һյβǹ +* 1 һյǹ +*/ +UINT8 RouteFirstLockErrCheck(UINT16 routeId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct* pRouteSecStru = NULL; /**/ + UINT8 ii = 0U; + UINT8 wPhySecState = 0U; + UINT16 phyRlockrouteId = 0U; /*·*/ + UINT8 retVal = CI_ERROR; + + if ((0U != routeId) && (ROUTE_SUM_MAX > routeId)) + { + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + + if (NULL != pRouteSecStru) + { + for (ii = 0u; ii < sectionSum; ii++) + { + wPhySecState = GetPhySecLockState(pRouteSecStru[ii].PhysicalSectionId); + phyRlockrouteId = GetPhySecRLockBelongRouteId(pRouteSecStru[ii].PhysicalSectionId);/*ν··ID*/ + + /*ҵһ·յ*/ + if ((PHYSICAL_SECTION_LOCK_NO != wPhySecState) && (phyRlockrouteId == routeId)) + { + /*쳣*/ + if (PHYSICAL_SECTION_LOCK_EXCEPT == wPhySecState) + { + retVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + retVal = CI_ERROR; + } + break; + } + else + { + /**/ + } + + } + } + else + { + /*ʧ*/ + } + } + return retVal; +} + +/* +* ȡȫͨų +* ˵ +* ֵȫͨųṹ +* Created By LQ 2024.07.14 +*/ +LineCommTrainStruct GetLineCommTrainData(void) +{ + return gStrLineCommTrain; +} + +/* +* ȫͨų +* ˵UINT8 cLineCtNum ȫͨų +* UINT16 szLineCtId[TRAIN_SUM_MAX] ȫͨID +* ֵ +* Created By LQ 2024.07.14 +*/ +void ProcessLineCommTrainData(UINT8 cLineCtNum, UINT16 szLineCtId[TRAIN_SUM_MAX]) +{ + if ((TRAIN_SUM_MAX > cLineCtNum) && (NULL != szLineCtId)) + { + gStrLineCommTrain.cCommTrainNum = cLineCtNum; + + (void)CommonMemSet(gStrLineCommTrain.szCommTrainNumID, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX), 0U, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX)); /**/ + (void)CommonMemCpy(gStrLineCommTrain.szCommTrainNumID, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX), szLineCtId, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX)); + } + else + { + /*ηǷ*/ + } +} + +/* +* ȫͨų +* ˵ +* ֵ +* Created By LQ 2024.07.14 +*/ +void ClearLineCommTrainData(void) +{ + /*ȫͨų*/ + gStrLineCommTrain.cCommTrainNum = 0U; + (void)CommonMemSet(gStrLineCommTrain.szCommTrainNumID, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX), 0U, (UINT32)(sizeof(UINT16) * TRAIN_SUM_MAX)); +} + +/* +* ÷ɳ崻ʼ +* ˵ UINT32 dwFlyProtectOverCyc 崻ں +* ֵ +*/ +void SetFlyProtectOverCyc(UINT32 dwFlyProtectOverCyc) +{ + if ((0U == gFlyProtectOverCyc) && (0U != dwFlyProtectOverCyc)) + { + gFlyProtectOverCyc = dwFlyProtectOverCyc; + } + else + { + ; /*ò޸ */ + } +} + +/* +* ȡɳ崻ʼ,δ÷0 +* ˵ void +* ֵ +*/ +UINT32 GetFlyProtectOverCyc(void) +{ + return gFlyProtectOverCyc; +} + +/* +* ȡѩģʽ +* ˵ void +* ֵ 0x55: Ч 0xAA:Ч +* by cgh 20241030 +*/ + +UINT8 GetLocalSnowModel(void) +{ + return g_LocalSnowModel; +} + +/* +* ñѩģʽ +* ˵UINT8 setmodle ѩģʽ +* ֵ void +* by cgh 20241030 +*/ +void SetLocalSnowModel(UINT8 setmodle) +{ + if ((CI_LOCAL_SNOW_UNVALID == setmodle) || (CI_LOCAL_SNOW_VALID == setmodle)) + { + g_LocalSnowModel = setmodle; + } + else + { + ; /**/ + } +} + +/* +* :·յټ +* : const UINT16 routeId ·ID +* : +* ֵ: CI_SUCCESS :ɹ +* CI_ERROR: ʧ +* by cgh 20241203 +*/ +UINT8 RouteLockSwitchDanCaoCheck(const UINT16 routeId) +{ + UINT8 ii = 0U; + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chSwitchBelCiId = 0U;/**/ + UINT8 chRouteSwitchSum = 0U; /*·Ŀ*/ + UINT16 wSwitchId = 0U; /*·ID*/ + UINT8 chSwitchExpPosition = SWITCH_POSITION_INVALID; /*λ*/ + UINT8 chSwitchDancaoPosition = SWITCH_POSITION_INVALID; /*Чλ*/ + RouteSwitchStruct* pRouteSwitchStru = NULL; /*·ݽṹָ*/ + UINT8 chReval = CI_ERROR; + UINT8 chRouteProtectSwitchSum = 0U; /*Ŀ*/ + RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL; /**/ + + if ((0U < routeId) && (ROUTE_SUM_MAX > routeId)) + { + chLocalCiId = GetSystemParaLocalCiId(); + chRouteSwitchSum = GetRouteSwitchSum(routeId); + pRouteSwitchStru = GetRouteSwitchData(routeId); + chReval = CI_SUCCESS; + + /* ෴λȡ· */ + for (ii = 0u; ii < chRouteSwitchSum; ii++) + { + wSwitchId = pRouteSwitchStru[ii].SwitchId; + chSwitchBelCiId = GetSwitchBelongCiId(wSwitchId); + if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId)) + { + chSwitchExpPosition = pRouteSwitchStru[ii].SwitchPosition; + chSwitchDancaoPosition = GetSwitchDanCaoPostition(wSwitchId); + + if ((SWITCH_POSITION_INVALID == chSwitchDancaoPosition) + || + (chSwitchDancaoPosition == chSwitchExpPosition)) + {/*Ч λ붯λһ*/ + chReval = CI_SUCCESS; + } + else + { + /*ٵ෴λȡ·*/ + chReval = CI_ERROR; + break; + } + } + else + { + ; /*DZ*/ + } + } + + if (CI_SUCCESS == chReval) + { + chRouteProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId); + pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId); + + /* ෴λȡ· */ + for (ii = 0u; ii < chRouteProtectSwitchSum; ii++) + { + wSwitchId = pRouteProtectSwitchStru[ii].ProtectSwitchId; + chSwitchBelCiId = GetSwitchBelongCiId(wSwitchId); + if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId)) + { + chSwitchExpPosition = pRouteProtectSwitchStru[ii].ProtectPosition; + chSwitchDancaoPosition = GetSwitchDanCaoPostition(wSwitchId); + + if ((SWITCH_POSITION_INVALID == chSwitchDancaoPosition) + || + (chSwitchDancaoPosition == chSwitchExpPosition)) + {/*Ч λ붯λһ*/ + chReval = CI_SUCCESS; + } + else + { + /*ٵ෴λȡ·*/ + chReval = CI_ERROR; + break; + } + } + else + { + ; /*DZ*/ + } + } + } + else + { + chReval = CI_ERROR; + } + } + else + { + ; + } + return chReval; +} + +/* +* ЧԼ +* ˵ const UINT16 wSwitchIdId +* const UINT8 functionId, ID +* const UINT8 chSendLevel͵ȼ +* ֵ CI_SUCCESS: ɹ +* CI_ERROR: ʧ +* by cgh 20241205 +*/ +UINT8 GetSwitchUsingValidState(const UINT16 wSwitchId,const UINT8 chFunctionId,const UINT8 chSendLevel) +{ + UINT8 chReval = CI_ERROR; + UINT8 chSwitchUsingState = 0U;/*״̬*/ + UINT16 wSwitchSecId = 0U;/*ID*/ + UINT8 chSwitchSecUsingState = 0U;/*״̬*/ + UINT8 chSwitchType = 0U;/**/ + UINT16 wDSwitchOtherId = 0U;/*˫һID*/ + + if ((0U < wSwitchId) && (SWITCH_SUM_MAX > wSwitchId)) + { + chSwitchUsingState = GetSwitchUsingState(wSwitchId); + if (SWITCH_USING_NO == chSwitchUsingState) + { + chReval = CI_SUCCESS; + } + else + { + chReval = CI_ERROR; + SetErrorData(chFunctionId, CI_DEVICE_TYPE_SWITCH, wSwitchId, ETYPE_SWT_USE_STATE, chSwitchUsingState, chSendLevel); + } + + if (CI_SUCCESS == chReval) + { + wSwitchSecId = GetSwitchPhySectionId(wSwitchId); + chSwitchSecUsingState = GetPhySecUseState(wSwitchSecId); + if (PHYSICAL_SECTION_USING_NO == chSwitchSecUsingState) + { + chReval = CI_SUCCESS; + } + else + { + chReval = CI_ERROR; + SetErrorData(chFunctionId, CI_DEVICE_TYPE_PHYSEC, wSwitchSecId, ETYPE_PS_USE_STATE, chSwitchSecUsingState, chSendLevel); + } + } + else + { + ; + } + + if (CI_SUCCESS == chReval) + { + chSwitchType = GetSwitchType(wSwitchId); + if (SWITCH_TYPE_DOUBLE == chSwitchType) + { + wDSwitchOtherId = GetDSwitchOtherId(wSwitchId); + chSwitchUsingState = GetSwitchUsingState(wDSwitchOtherId); + if (SWITCH_USING_NO == chSwitchUsingState) + { + chReval = CI_SUCCESS; + } + else + { + chReval = CI_ERROR; + SetErrorData(chFunctionId, CI_DEVICE_TYPE_SWITCH, wDSwitchOtherId, ETYPE_SWT_USE_STATE, chSwitchUsingState, chSendLevel); + } + + if (CI_SUCCESS == chReval) + { + wSwitchSecId = GetSwitchPhySectionId(wDSwitchOtherId); + chSwitchSecUsingState = GetPhySecUseState(wSwitchSecId); + if (PHYSICAL_SECTION_USING_NO == chSwitchSecUsingState) + { + chReval = CI_SUCCESS; + } + else + { + chReval = CI_ERROR; + SetErrorData(chFunctionId, CI_DEVICE_TYPE_PHYSEC, wSwitchSecId, ETYPE_PS_USE_STATE, chSwitchSecUsingState, chSendLevel); + } + } + else + { + ; + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + else + { + ; + } + + return chReval; +} + +/* +* ָIDȨĬ״̬ +* ˵ const UINT8 virtualCiId ID +* ֵ viod +* by cgh 20250305 +*/ +void DefaultCtrlPowerDeal(const UINT8 virtualCiId) +{ + + UINT8 ii = 0U; + UINT8 chVirtualCiNum = 0U; + + chVirtualCiNum = GetVirtualCINum(); + + if (chVirtualCiNum <= VIRTUAL_CI_MAX) + { + for (ii = 0U; ii < chVirtualCiNum; ii++) + { + if (virtualCiId == ctrlpowerFlag[ii].virCiId) + { + ctrlpowerFlag[ii].ctrlPowerState = CONTRAL_POWER_NO; + ctrlpowerFlag[ii].ctrlDeviceId = 0U; + ctrlpowerFlag[ii].ctrlDeviceType = 0U; + } + else + { + ; /**/ + } + } + } + else + { + ; + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/DataManage/DeviceDataManage.h b/TSCP/src/APP/ciapp/DataManage/DeviceDataManage.h new file mode 100644 index 0000000..2781843 --- /dev/null +++ b/TSCP/src/APP/ciapp/DataManage/DeviceDataManage.h @@ -0,0 +1,1827 @@ +/******************************************************** +* +* DeviceDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-09-21 +* ߣ +* 豸ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* 20141205 ෿׷SPKSӦ +* +********************************************************/ +#ifndef _DEVICE_DATA_MANAGE_H_ +#define _DEVICE_DATA_MANAGE_H_ + +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../error/ErrorDataManage.h" +#include "../Transmit/TransmitStateDataManage.h" + +#include "../Route/RouteConfigDataManage.h" +#include "../Route/RouteDataManage.h" + +#include "../Section/AxisSectionConfigDataManage.h" +#include "../Section/AxisSectionDataManage.h" +#include "../Section/LogicSectionConfigDataManage.h" +#include "../Section/LogicSectionDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" + +#include "../Signal/SignalDataManage.h" + +#include "../Switch/SwitchConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" + +#include "../Overlap/OverlapConfigDataManage.h" +#include "../Overlap/OverlapDataManage.h" + +#include "../AutoReturn/AutoReturnDefine.h" +#include "../AutoReturn/AutoReturnConfigDataManage.h" + +#include "../AllAutoReturn/AllAutoReturnDefine.h" +#include "../AllAutoReturn/AllAutoReturnConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../spks/SpksConfigDataManage.h" +#include "../spks/SpksDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" +#include "../WashMachine/WashMachineDataManage.h" + +#include "../PSD/PSDConfigDataManage.h" +#include "../PSD/PSDDataManage.h" +#include "../DiffLineDev/DiffLineDevConfigDataManage.h" +#include "../AutoRoute/AutoRouteDataManage.h" +#include "../AutoReturn/AutoReturnDataManage.h" +#include "../AllAutoReturn/AllAutoReturnDataManage.h" +#include "../LogicProcess/InterlockLogicCheck.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../VirtualDevice/VirtualDevDefine.h" + +/*-------------------------------------------------------------------------- + * ״̬ + *--------------------------------------------------------------------------*/ +/* ״̬ض */ +#define LOCAL_AREA_SNOW_SUM_MAX ((UINT8)20) /*ڿ͵ѩվ̨*/ +#define ALL_AREA_SNOW_SUM_MAX ((UINT8)254) /*TMC͵ȫѩվ̨*/ + +/* 1 źŻ +0x55 +ر0xaa +ͬ0xbbźŻɫʼźŻͬ +*/ +#define OTHER_CI_SIGNAL_STATUS_OPEN ((UINT8)0x55) +#define OTHER_CI_SIGNAL_STATUS_CLOSE ((UINT8)0xAA) +#define OTHER_CI_SIGNAL_STATUS_SAME ((UINT8)0xbb) + +/* 2 λ0x55 λ0xaa */ +#define OTHER_CI_SWTICH_STATUS_DINGWEI ((UINT8)0x55) +#define OTHER_CI_SWTICH_STATUS_FANWEI ((UINT8)0xAA) + +/* 3 0x55 ر0xaa VOBC 0xff*/ +#define OTHER_CI_PSD_STATUS_OPEN ((UINT8)0x55) +#define OTHER_CI_PSD_STATUS_CLOSE ((UINT8)0xAA) +#define OTHER_CI_PSD_STATUS_OCCUPY_OPEN ((UINT8)0xFF) + +/* 4 رհť ʵʩ0xaa δʵʩ0x55 */ +#define OTHER_CI_ESB_STATUS_VALID ((UINT8)0xAA) +#define OTHER_CI_ESB_STATUS_UNVALID ((UINT8)0x55) + + +/* 5 ҵ ʵʩ0x55 δʵʩ0xaa */ +#define OTHER_CI_SPKS_YES ((UINT8)0x55) +#define OTHER_CI_SPKS_NO ((UINT8)0xAA) + +/* 6 0x55 ر0xAA */ +#define OTHER_CI_GARAGEDOOR_OPEN ((UINT8)0x55) +#define OTHER_CI_GARAGEDOOR_CLOSE ((UINT8)0xAA) + + +/* 7 ϴ״̬ 0x55 δ0xaa */ +#define OTHER_CI_WASH_READ_YES ((UINT8)0x55) +#define OTHER_CI_WASH_READ_NO ((UINT8)0xAA) + +/* 8 ռ״̬ 0x55 ռ0xaa */ +#define OTHER_CI_PHYSICAL_OCCU_YES ((UINT8)0xAA) +#define OTHER_CI_PHYSICAL_OCCU_NO ((UINT8)0x55) + +/* 9 ϴͬϴ ͬ0xAA δͬ0x55 */ +#define OTHER_CI_WASH_LINE_ALLOW_YES ((UINT8)0xAA) +#define OTHER_CI_WASH_LINE_ALLOW_NO ((UINT8)0x55) + +/* 10 ϴͬͨ ͬ0x55 ͬ0xaa */ +#define OTHER_CI_DOWNWASH_ALLOW_PASS_NO ((UINT8)0x55) +#define OTHER_CI_DOWNWASH_ALLOW_PASS_YES ((UINT8)0xAA) + +/* 11 · ·źŹر0x55 źſ0xaa */ +#define OTHER_CI_ROUTE_STATUS_OPEN_NO ((UINT8)0x55) +#define OTHER_CI_ROUTE_STATUS_OPEN_YES ((UINT8)0xAA) + +#define VOBCTOCIAUTORTN_INDICT_MASK_VALID ((UINT8)0x55) /*VOBCCI۷λЧ*/ +#define VOBCTOCIAUTORTN_INDICT_MASK_INVALID ((UINT8)0xAA) /*VOBCCI۷λЧ*/ + +#define OTHER_CI_FLOOD_GATE_OPEN ((UINT8)0x55) /*ſ*/ +#define OTHER_CI_FLOOD_GATE_CLOSE ((UINT8)0xaa) /*Ź*/ + +#define OTHER_CI_CONNECT_SWITCH_YES ((UINT8)0xaa) /*ߵ״̬㣺·++λ*/ +#define OTHER_CI_CONNECT_SWITCH_NODSUO_YES ((UINT8)0x5a) /*ߵ״̬㣺·+λ*/ +#define OTHER_CI_CONNECT_SWITCH_NO ((UINT8)0x55) /*ߵ״̬*/ + +#define CICI_RELAY_INTERFACE_CONFIRM_NO ((UINT8)0x55) /*̵ӿδȷ*/ +#define CICI_RELAY_INTERFACE_CONFIRM_YES ((UINT8)0xaa) /*̵ӿȷ*/ + +#define ZFWJ_HUN_XIAN_NO ((UINT8)0x00) /*ܸλǻ״̬*/ +#define ZFWJ_HUN_XIAN_YES ((UINT8)0x01) /*ܸλ״̬*/ +#define CANCEL_SWITCH_BLOCK_LINK ((UINT8)0x55) /*ȡת޻*/ +#define RECOVER_SWITCH_BLOCK_LINK ((UINT8)0xaa) /*ָת޻*/ + +/* η״̬ η */ +#define OTHER_CI_PHYSICAL_FENGSUO_YES ((UINT8)0xAA) /*0xaa ֮Ӱźſ*/ +#define OTHER_CI_PHYSICAL_FENGSUO_NO ((UINT8)0x55) /*δ0x55֮źŲ*/ +/*ƽṹ*/ +typedef struct S_CtrlPowerStruct +{ + UINT8 virCiId; /*ID*/ + UINT16 ctrlDeviceId; /*豸ID*/ + UINT8 ctrlDeviceType; /*豸*/ + UINT8 ctrlPowerState; /*Ȩ״̬*/ +}CtrlPowerStruct; + +/*ȫͨųϢṹ*/ +typedef struct S_LineCommTrainStruct +{ + UINT8 cCommTrainNum; /*ȫͨų*/ + UINT16 szCommTrainNumID[TRAIN_SUM_MAX]; /*ȫͨųID*/ +}LineCommTrainStruct; + +/*******************************ȫֱ*******************************/ +extern UINT8 AllSignalBrightFlag; /*ȫվƱ־*/ + +extern UINT8 AllSwitchYLockFlag; /*ȫվ־*/ + +extern UINT8 StartFLockFlag; /*ȫվ־*/ + +extern UINT8 StartLockFlag; /*ϵձ־*/ + +extern UINT8 LSXianSuCancelBtnIsValidFlag; /*ʱ˹־*/ + +extern UINT8 LabourCancelLinShiXianState; /*˹ȡʱǨ״̬*/ + +extern UINT8 StopCheckState; /*ֹͣδ*/ + +extern UINT16 JkjRelayId; /*Ӧ̵̼ID*/ + +extern UINT8 PlatOverFlag; /*ƽ̨崻־*/ + +extern UINT8 ciMode; /* ģʽ */ + +extern UINT8 g_AllTsrFlag; /* ʱٱ־ */ + +extern UINT8 g_AllSnowModel; /*ȫѩģʽ*/ + +extern UINT8 g_IteLineCutState; /*ITEȫг״̬0x55гITE0xAAʹITE0xFFĬֵ*/ + +extern UINT8 g_AllLineTsrState; /*ȫʱ״̬*/ + +extern UINT8 g_AllLineTsrSpeed; /*ȫʱٶ*/ + +extern UINT8 JkjRelayValid; /*JKJӦ̵̼Ч*/ + +extern UINT32 JkjRelayValidCycNum; /*JKJӦ̵̼Ч*/ + +extern UINT8 ciTrainTestStatus; /*Գ״̬Գ*/ + +extern UINT8 psdPangluFlag; /*վ̨ȫŰť·״̬*/ + +extern UINT8 generalResetFlag; /*ܸλ־Ч*/ + +extern UINT32 ZFWValidCycNum; /*ZFWܸλ̵Ч*/ + +extern UINT32 ZFWCmdStartCycNum; /*ZFWյ*/ + +extern UINT8 g_cTsrSureFlag; /* ʱȷϱ־ */ + +extern UINT8 comm_Train_Test_SQAJ_SCX_State; /*Գ복βͨŽӿʱԳSQAJ״̬*/ +extern UINT8 comm_Train_Test_YSKJ_SCX_State; /*Գ복βͨŽӿʱԳYSKJ״̬*/ +extern UINT8 comm_Train_Test_SQJ_CLD_State; /*Գ복βͨŽӿʱSQJ״̬*/ +extern UINT8 comm_Train_Test_TYSJ_CLD_State; /*Գ복βͨŽӿʱTYSJ״̬*/ + +extern UINT8 ZCToCIAutoRtnIndict_Flash_Sta; /*ZCCI۷״̬*/ +extern UINT8 ZCToCIAutoRtnIndict_Steady_Sta; /*ZCCI۷ȵ״̬*/ +extern UINT8 AutoTriggerFlag; /*Զ־ʼΪδ*/ + +extern UINT8 CiCiRelayInterfaceConfirmFlag;/*̵ӿȷϱ־*/ +extern UINT8 ZFWJRelayHunXianFlag; /*ܸλ߱־*/ +extern UINT8 SwitchBlockLinkState; /*ʼֵΪָ״̬ʱЧ*/ + +extern CtrlPowerStruct ctrlpowerFlag[VIRTUAL_CI_MAX]; + +extern UINT8 LocalAreaSnowNum; /*ѩվ̨*/ +extern UINT32 szLocalAreaSnowId[LOCAL_AREA_SNOW_SUM_MAX]; /*ѩվ̨ID*/ + +extern LineCommTrainStruct gStrLineCommTrain; /*ȫͨųṹ*/ + +extern UINT32 gFlyProtectOverCyc; /*ɳ崻ʼ*/ +extern UINT8 g_LocalSnowModel; /*ѩģʽ*/ + +/******************************־ݹ****************************/ + +/* +* ȡ־ +* ˵ void +* ֵ CI_START_FLOCK_YES + CI_START_FLOCK_NO +*/ +UINT8 GetStartFLockFlag(void); + +/* +* ϵ־ +* ˵ void +* ֵ CI_START_FLOCK_YES + CI_START_FLOCK_NO + CI_START_FLOCK_ERROR +*/ +void SetStartFLockFlag(UINT8 setFlag); + +/* +* ȡϵ־ +* ˵ void +* ֵ CI_START_LOCK_NO + CI_START_LOCK_YES +*/ +UINT8 GetStartLockFlag(void); + +/* +* ϵ־ +* ˵ void +* ֵ CI_START_LOCK_NO + CI_START_LOCK_YES + CI_START_LOCK_ERROR +*/ +void SetStartLockFlag(UINT8 setFlag); + + + + + +/* +* ȡ˹ȡʱٵ״̬ +* ˵ void +* ֵ LINSHIXIANSU_COMM_GOOD_STATE + LINSHIXIANSU_COMM_BAD_NO_LABOURCANCLE_STATE + LINSHIXIANSU_COMM_BAD_YES_LABOURCANCLE_STATE +*/ +UINT8 GetLabourCancelLinShiXianState(void); + +/* + ˹ȡʱ״̬Ǩƴ + ˵setFlag ״̬ + ֵ +*/ +void LabourCancelLSXianStaMoveProc(UINT8 setFlag); +/* + ˹ȡʱ״̬Ǩƴ + ˵setFlag ״̬,UINT8 virCIid ID + ֵ +*/ +void LaborCancelLSXSXStaMoveProc_Vir(UINT8 setFlag,UINT8 virCIid); + + +/* +* ȡȫվ־ +* ˵ void +* ֵ CI_ALL_SWITCH_YLOCK_NO + CI_ALL_SWITCH_YLOCK_YES +*/ +UINT8 GetAllSwitchYLockFlag(void); + + + +/* +* ȫվ־ +* ˵ void +* ֵ CI_ALL_SWITCH_YLOCK_NO + CI_ALL_SWITCH_YLOCK_YES +*/ +void SetAllSwitchYLockFlag(UINT8 setFlag); + +/* +* ȡȫվƱ־ +* ˵ void +* ֵ CI_ALL_SIGNAL_BRIGHT_NO + CI_ALL_SIGNAL_BRIGHT_YES +*/ +UINT8 GetAllSignalBrightFlag(void); + + +/* +* ȫվƱ־ +* ˵ void +* ֵ CI_ALL_SIGNAL_BRIGHT_NO + CI_ALL_SIGNAL_BRIGHT_YES +*/ +void SetAllSignalBrightFlag(UINT8 setFlag); + +/* +* ȡܸλ־ +* ˵ void +* ֵ CI_PHYSEC_GENERAL_RESET_NO + CI_PHYSEC_GENERAL_RESET_YES +*/ +UINT8 GetPhySecGeneralResetFlag(void); + +/* +* üܸλ־ +* ˵ void +* ֵ CI_ALL_SIGNAL_BRIGHT_NO + CI_ALL_SIGNAL_BRIGHT_YES +*/ +void SetPhySecGeneralResetFlag(UINT8 setFlag); + +/******************************·ݽ****************************/ + +/* +* ҵ·ڵһ +* ˵ UINT16 routeId +* ֵ UINT16 ID +* = 0 Ч +* > 0 ID +*/ +UINT16 GetRouteFirstNormalLockSection(UINT16 RouteId); + +/* +* ҵ·ڵһʱ +* ˵ UINT16 routeId, · + +* ֵ UINT16 ID +* = 0 Ч +* > 0 ID +*/ +UINT16 GetRouteFirstDelayLockSection(UINT16 RouteId); + +/* +* ·ѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckRoutePhySecHaveUnLock(const UINT16 routeId); + +/* +* ·ηЧ +* ˵ +* UINT16 routeId, · +* ֵ CI_ERROR ηЧ +* CI_SUCCESS ηЧ +*/ +UINT8 RouteSecFlockVainCheck(const UINT16 routeId); +/* +* ·ηЧ +* ˵ +* UINT16 routeId, · +* ֵ CI_ERROR ηЧ +* CI_SUCCESS ηЧ +*/ +UINT8 RouteOverlapSecFlockVainCheck(const UINT16 routeId); + + + +/* +* ·гӽ +* ˵ const UINT16 routeId, ·ID +* ֵ FUNCTION_SUCCESSɹ +* FUNCTION_ERROR ʧ +*/ +UINT8 RouteHaveTrainNear(const UINT16 routeId); + + + +/* ҵ·Ч۷źŻ */ +/* +* ҵ·Ч۷źŻ +* ˵ UINT16 routeId +* ֵ UINT16 źŻID +* = 0 Ч +* > 0 źŻID +*/ +UINT16 GetValidReturnSinalId(UINT16 const routeId,UINT16 const setionId); + +/* +: ·ڱص +: const UINT16 routeId ·ID +: const UINT8 DrivFlag ־ +ֵ: +edit cgh 20241203 +*/ +void RouteDrvInnerSwitch(const UINT16 routeId, const UINT8 DrivFlag); + +/* +: +: const UINT16 routeId ·ID + UINT8 DrivFlag ־ +: +ֵ: +*/ +void RouteDrvAssocSwitch(const UINT16 routeId, const UINT8 DrivFlag); + +/* +: · +: const UINT16 routeId ·ID + UINT8 NeedForDrvRoutAssoSwit ǷҪ +: +ֵ: CI_SUCCESS,մɹ + CI_ERROR,մʧ +*/ +UINT8 RouteLockDriveSwitch(const UINT16 routeId, const UINT8 NeedForDrvRoutAssoSwit); + +/* +* гʻ·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERROR; CI_SUCCESS +* edit cgh 20250113 +*/ +UINT8 GetTrainEnteringRouteState(const UINT16 routeId); + + +/******************************źŻݽ****************************/ + +/* +* źŻ +* ˵ const UINT16 signalId , źŻID +* const UINT16 routeId , ·ID +* ֵ 0:ʧ +* 1:ɹ +*/ +void DriveSignalOpen(const UINT16 signalId, const UINT16 routeId); + +/* +* źŻر +* ˵ const UINT16 signalId, źŻID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 DriveSignalClose(const UINT16 signalId); + +/******************************ݽ****************************/ + +/* +* ǰЧԼ +* ˵ UINT16 switchIdId +* UINT8 oper_src,Դ +* UINT8 sendLevelͼ +* ֵ CI_SUCCESS: ʧ +* CI_ERROR: ³ɹ +* add 20221009 ·ǰ⶯ +*/ +UINT8 GetSwitchMoveEarlyValidState(UINT16 switchId, UINT8 oper_src, UINT8 sendLevel); + +/* +* ɶЧԼ +* ˵ UINT16 switchIdId +* UINT8 oper_src,Դ +* UINT8 sendLevelͼ +* ֵ CI_SUCCESS: ʧ +* CI_ERROR: ³ɹ +* modify 20221009 ·ǰ⶯ +*/ +UINT8 GetSwitchMoveValidState(UINT16 switchId,UINT8 oper_src,UINT8 sendLevel); + +/* zt ɾش 2022-02-15 */ + +/* +* ǿɶЧԼ +* ˵ UINT16 switchId ID +* UINT8 sendLevel ATSֵطͼ +* ֵ CI_SUCCESS: ʧ +* CI_ERROR: ³ɹ +*/ +UINT8 GetSwitchForceMoveValidState(UINT16 switchId,UINT8 sendLevel); + +/* zt ɾش 2022-02-15 */ + +/* +* ȡ״̬ +* ˵ void +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchRouteLockState(UINT16 switchId); + +/* +* +* ˵ const UINT16 switchId, ID +* const UINT8 switchPos, λ +* const UINT32 curCycleNum, ǰں +* ֵ void +*/ +UINT8 SwitchDriveProcess(const UINT16 switchId, const UINT8 switchPos); + + +/* +: + ·λ +: + const UINT16 routeId ·ID +: + . +ֵ: + +*/ +void ClearRouteSwitchDrivePos(const UINT16 routeId); + + +/* +: + ιλ +: + const UINT16 routeId ·ID +: + . +ֵ: + +*/ +void ClearOverlapSwitchDrivePos(const UINT16 overlapId); + +/* +: + ιλ +: + const UINT16 routeId ·ID +: + . +ֵ: + +*/ +void ClearOverlapSwitchDanCaoPos(const UINT16 overlapId); + +/* +: + ·λ +: + const UINT16 routeId ·ID +: + . +ֵ: + +*/ +void ClearRouteSwitchDanCaoPos(const UINT16 routeId); + +/* +: + ǽ·λ +: + +: + . +ֵ: + CI_SUCCESS ɹ + CI_ERROR ʧ +*/ +UINT8 ClearNonRouteSwitchDrivePos(UINT8 nonRouteId); + +/* +: + ǽ·λ +: + const UINT16 routeId ·ID +: + . +ֵ: + CI_SUCCESS ɹ + CI_ERROR ʧ +*/ +UINT8 ClearNonRouteSwitchDanCaoPos(UINT8 nonRouteId); + + +/******************************ݽ****************************/ + + +/* +* ȡARBϢ +* ˵ void +* ֵ AXIS_SECTION_ARB_NO δARB +* AXIS_SECTION_ARB_YES ARB +*/ +UINT8 GetArbState(UINT16 phySectionId); + +#if 0 +/* +* ȡ߼ռںϢ +* ˵ void +* ֵ +* SECTION_OCCUPY_NO +* SECTION_OCCUPY_YES +*/ +/*ʱԤ*/ +UINT8 GetLogicSecMergyOccuState(UINT16 phySectionId); +#endif + +/* +* ȡ߼ռϢ +* ˵ void +* ֵ +* SECTION_OCCUPY_NO +* SECTION_OCCUPY_YES +*/ +UINT8 GetLogicSecOccuState(UINT16 phySectionId); + + +/******************************ݽ****************************/ + +#if 0 +/* +* ָſŵվ·źŹرյijվ· +* ˵ const UINT16 doorId ID +* const UINT8 PsdOpenedBeforeFlag ſ֮ǰ־ 1:ſ֮ǰ 0:ſ֮ +* ֵ +*/ +void CalculatePsdOpenedLeadToSignalCloseRoute(const UINT16 doorId,const UINT8 PsdOpenedBeforeFlag); +#endif + + + +/******************************Զ۷·ݽ****************************/ + +/* +* Զ۷·۳·Ƿ԰ЧԼ +* ˵ const UINT16 routeId, ·Id +* ֵ CI_ERROR: Ч +* CI_SUCCESS: Ч +*/ +UINT8 GetAutoReturnRebackRouteValid(const UINT16 routeId); + +/* +* Զ۷·۳·Ƿ԰ЧԼ +* ˵ const UINT16 routeId, ·Id +* ֵ +AUTO_RETURN_ROUTE_TYPE_IN 0x55 ۷ +AUTO_RETURN_ROUTE_TYPE_OUT 0xAA ۳ +AUTO_RETURN_ROUTE_TYPE_VAIN 0xFF Ч +*/ +UINT8 GetAutoReturnRouteType(const UINT16 autoReturnId, const UINT16 routeId); + + +/******************************overlapݽ****************************/ +/* +* ȡָID״̬ +* ˵ const UINT16 overlapId, ID +* ֵ 0: δ +* 1: +*/ +UINT8 GetOverlapLockState(const UINT16 overlapId); + +/******************************Զ·ݽ****************************/ +/* +* ·ԶЧԼ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 AutoSignalOrRouteValid(const UINT16 routeId); + +/* +* źŻʱټ(չ·) +* ˵ void +* ֵ void +*/ +void RouteSignalLSXianSuCalculate(void); + + +/* +* źŻʱټ(źŻμ) +* ˵ void +* ֵ void +*/ +void OutStationSignalLSXSCalculate(void); + +/* +* źŻʱټ +* ˵ void +* ֵ void +*/ +void SignalLinShiXianSuFlagCalculate(void); + +/******************************ݽ****************************/ +/* +* ȡֹͣ־ +* ˵ void +* ֵ UINT8 ֹͣ־ +*/ +UINT8 GetStopCheckFlag(void); + +/* +* ֹͣ߼ +* ˵ void +* ֵ +*/ +void SetStopCheckFlag(void); + +/* +* ȡֹͣ߼ +* ˵ void +* ֵ +*/ +void CancelStopCheckFlag(void); + +/* +* ȡӦ̵̼ID +* ˵ void +* ֵ +*/ +UINT16 GetJkjRelayId(void); + +/* +* ȡ崻־ +* ˵ void +* ֵ +*/ +UINT8 GetPlatOverFlag(void); + +/* +* 崻־ +* ˵ void +* ֵ +*/ +void SetPlatOverFlag(void); + +/* +* źŻ߼ +* ˵ void +* ֵ void +*/ +void YLockSignalOpenManage(void); + +/* +* ȫԶ۷·۳·Ƿ԰ЧԼ +* ˵ const UINT16 routeId, ·Id +* ֵ CI_ERROR: Ч +* CI_SUCCESS: Ч +*/ +UINT8 GetAllAutoReturnOutRouteValid(const UINT16 routeId); + +/* +* ȫԶ۷·۳·Ƿ԰ЧԼ +* ˵ const UINT16 routeId, ·Id +* ֵ + AUTO_RETURN_ROUTE_TYPE_IN 0x55 ۷ + AUTO_RETURN_ROUTE_TYPE_OUT 0xAA ۳ + AUTO_RETURN_ROUTE_TYPE_VAIN 0xFF Ч +*/ +UINT8 GetAllAutoReturnRouteType(const UINT16 allAutoReturnId, const UINT16 routeId); + + + + +/******************************·ؼ****************************/ +/* +* ָID·ԶźŽ·ԶʧЧ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 autoSigPropertyLoseEfficacyFlag, ·ԶźʧЧñ־ +* ֵ +* +*/ +void SetRevrRouteAutoSigInvalidFlag(const UINT16 routeId, const UINT8 autoSigPropertyLoseEfficacyFlag); + + + +/*****************************ؼ****************************/ +/* +* SPKS״̬Լη +* ˵ spksId spksStatus ״̬ +* ֵ +*/ +void SetPhySecSpksFLockBySpksId(UINT16 spksId,UINT8 spksStatus); + + +/******************************ؼ****************************/ +/* +* ȡ豸״̬,״̬תΪӦ +* ˵ UINT16 devType 豸 +* UINT16 devId 豸ID +* UINT16 const chkDevStatus 豸״̬ +* ֵ 0 ʧ +* >0 豸״̬ +*/ +UINT8 GetOtherCiDevStatus(UINT16 const devType,UINT16 const devId,UINT16 const chkDevStatus); + +/* +* 豸ͻȡʧʱ +* ˵ UINT16 devType 豸 +* ֵ 0 豸״̬ +*/ +UINT8 GetOtherCiCheckDevStateType(UINT16 const devType); + + +/******************************ģʽؼ****************************/ +/* +* ȡģʽ־ +* ˵ void +* ֵ ģʽ 0x55: վ 0xAA:п 0x71:̨ 0xFF:վ +*/ +UINT8 GetCiModeFlag(void); + +/* +* ģʽ־ +* ˵ ģʽ 0x55: վ 0xAA:п 0x71:̨ 0xFF:վ +* ֵ void +*/ +void SetCiModeFlag(UINT8 setFlag); + +/* +* ȡȫվʱٱ־ +* ˵ void +* ֵ 0x55: Ч 0xAA:Ч +*/ +UINT8 GetAllTsrFlag(void); + +/* +* ȫվʱٱ־ +* ˵ 0x55: Ч 0xAA:Ч +* ֵ void +*/ +void SetAllTsrFlag(UINT8 setFlag); + +/******************************Գ״̬****************************/ + +/* +* ȡԳ״̬ +* ˵ void +* ֵ Գ״̬ + CI_TRAIN_TEST_OFF 0xFF Գ + CI_TRAIN_TEST_START 0x01 Գť + CI_TRAIN_TEST_ON 0x02 Գ + CI_TRAIN_TEST_STOP 0x03 Գ +*/ +UINT8 GetCiTrainTestStatus(void); + +/* +* Գ״̬ +* ˵ Գ״̬ + CI_TRAIN_TEST_OFF 0xFF Գ + CI_TRAIN_TEST_START 0x01 Գť + CI_TRAIN_TEST_ON 0x02 Գ + CI_TRAIN_TEST_STOP 0x03 Գ +* ֵ void +*/ +void SetCiTrainTestStatus(UINT8 flag); + +/* +* ȡSQJ״̬ +* ˵ void +* ֵ SQJ״̬ +* 0x55 豸״̬Ч +* 0xAA 豸״̬Ч +*/ +UINT8 GetCommTrainTestCLDSQJStatus(void); + +/* +* ԳȡYSKJ״̬ +* ˵ void +* ֵ YSKJ״̬ +* 0x55 豸״̬Ч +* 0xAA 豸״̬Ч +*/ +UINT8 GetCommTrainTestSCXYSKJStatus(void); + +/* +* ȡTYSJ״̬ +* ˵ void +* ֵ TYSJ״̬ +* 0x55 豸״̬Ч +* 0xAA 豸״̬Ч +*/ +UINT8 GetCommTrainTestCLDTYSJStatus(void); + +/* +* ԳȡSQAJ״̬ +* ˵ void +* ֵ SQAJ״̬ +* 0x55 豸״̬Ч +* 0xAA 豸״̬Ч +*/ +UINT8 GetCommTrainTestSCXSQAJStatus(void); + +/* +* ͨŽӿڵԳSQAJ״̬ +* ˵ ԳSQAJ״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0xAA Ч״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0x55 Ч״̬ +* ֵ void +*/ +void SetCommTrainTestSCXSQAJStatus(UINT8 flag); + +/* +* ͨŽӿڵijTYSJ״̬ +* ˵ TYSJ״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0xAA Ч״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0x55 Ч״̬ +* ֵ void +*/ +void SetCommTrainTestCLDTYSJStatus(UINT8 flag); + +/* +* ͨŽӿڵԳYSKJ״̬ +* ˵ ԳYSKJ״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0xAA Ч״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0x55 Ч״̬ +* ֵ void +*/ +void SetCommTrainTestSCXYSKJStatus(UINT8 flag); + +/* +* ͨŽӿڵijSQJ״̬ +* ˵ SQJ״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0xAA Ч״̬ +* COMM_TRAIN_TEST_DEV_STATE_INVALID 0x55 Ч״̬ +* ֵ void +*/ +void SetCommTrainTestCLDSQJStatus(UINT8 flag); + +/* +* Զ־ +* ˵ UINT8 setFlag õԶ־ +* ֵ +*/ +void SetAutoTriggerFlag(UINT8 setFlag); + +/* +* Զ־ +* ˵UINT8 virCIid ID +* UINT8 setFlag õԶ־ +* ֵ +*cgh-ϲECI11.0: +*/ +void SetAutoTriggerLogicManage(UINT8 virCIid, UINT8 setFlag); +/* +* ȡԶ־ +* ˵ +* ֵ Զ־ +*/ +UINT8 GetAutoTriggerFlag(void); +/* +* гǷռѹ +* ˵ const UINT16 routeId ·ID +* ֵ CI_SUCCESS: δռѹ +* CI_ERROR: ռѹ +*/ +UINT8 RouteTriggerOccu(const UINT16 routeId); +/* +* жǷȡ +* ȡ־ȡ򲻱 +* ˵ UINT16 routeId ·ID +* ֵ CI_SUCCESS: δȡ +* CI_ERROR: ȡ +*/ +UINT8 CancleAutoFlag(UINT16 routeId); +/* +* жǷԾ +* ԾգԾ +* ˵ UINT16 axisSectionId ID +* ֵ CI_SUCCESS: +* CI_ERROR: +*/ +UINT8 CheckJumpLockApply(UINT16 axisSectionId); + +/* +* ָ·ڵָ߼IDǰָ߼IDUTռ +* ˵ UINT16 routeId, ·ID +* UINT16 physicalId, ߼ID +* ֵ CI_ERROR UTռ +* CI_SUCCESS UTռ +*/ +UINT8 CheckBeforLogSecinRouteHaveNoUT(UINT16 routeId, UINT16 logSectionId); + +/* +* жǷ߼Ծ +* ߼ԾգԾ +* ˵ UINT16 logSectionId ߼ID +* ֵ CI_SUCCESS: +* CI_ERROR: +*/ +UINT8 CheckLogJumpLockApply(UINT16 logSectionId); + +/* +* Ч +* ˵ +* UINT16 const physicalId, ID + +* ֵ CI_ERROR +* CI_SUCCESS ޲ +*/ +UINT8 PhysicalIntruSecVainCheck(UINT16 const physicalId); + +/* жϱIDǷڽ·ı +* ˵ const UINT16 routeId, ·ID +* const UINT16 expLkOverlapId, ID +* ֵ 0: ָβڽ·ı +* 1: ָڽ·ı +*/ +UINT8 checkExpOverlapBelongToRtOrNot(const UINT16 routeId, const UINT16 expLkOverlapId); + +/* +* JKJӦ̵̼Ч־ +* ˵ void +* ֵ JKJ_REYLAY_INVALID 0x55 JKJ̵Ч +* JKJ_REYLAY_VALID 0xaa JKJ̵Ч +*/ +UINT8 GetCiJkjFlag(void); + +/* +* JKJӦ̵̼Ч־ +* ˵ JKJ_REYLAY_INVALID 0x55 JKJ̵Ч +* JKJ_REYLAY_VALID 0xaa JKJ̵Ч +* ֵ void +*/ +void SetCiJkjFlag(UINT8 setFlag); + +/* +* ȡJKJЧ״̬Чں +* ˵ +* ֵ JkjRelayValidCycNum +*/ +UINT32 GetJkjRelayValidCycNum(void); + +/* +* JKJ̵״̬Чں +* ˵ const UINT32 updateCycNum, ̵ں +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetJkjRelayValidCycNum(const UINT32 updateCycNum); + +/* +* ȡZFWЧ״̬Чں +* ˵ +* ֵ ZFWValidCycNum +*/ +UINT32 GetZFWValidCycNum(void); + +/* +* ZFWܸλ״̬Чں +* ˵ const UINT32 updateCycNum, ܸλЧں +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetZFWValidCycNum(const UINT32 updateCycNum); + +/* +* ȡZFWյں +* ˵ +* ֵ ZFWCmdStartCycNum +*/ +UINT32 GetZFWcmdStartCycNum(void); + +/* +* ZFWܸλʼں +* ˵ const UINT32 updateCycNum, ܸλں +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetZFWcmdStartCycNum(const UINT32 updateCycNum); + +/* +: Ծ +: const UINT16 axisSecId ID +: +ֵ: CI_SUCCESS,մɹ + CI_ERROR,մʧ +*/ +UINT8 JumpLockDriveSwitch(const UINT16 axisSecId); + +/* +: ڵ +: const UINT16 axisSecId ID +: const UINT8 DrivFlag ־ +ֵ: +*/ +void AxisSecDrvInnerSwitch(const UINT16 axisSecId, const UINT8 DrivFlag); + + + +/* +* ̵ӿ¼DZĽ·ڣڱǷѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckNoLocalCiRoutePhySecUnLock(const UINT16 routeId); + +/* +* ·Ƿ +* ˵ UINT16 routeId · +* , UINT8 *pOtherCiId ID +* ֵ1 +* 0: +*/ +UINT8 RouteHavePhySecBelongOtherCi(const UINT16 routeId, UINT8 *pOtherCiId); + +/* +* ·ڱѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckLocalCiRoutePhySecUnLock(const UINT16 routeId); + +/* +* üܸλǷ״̬ +* ˵ void +* ֵ +* +*/ +void SetZfwjHunXianFLag(UINT8 setFlag); + +/* +* ȡܸλǷ״̬ +* ˵ void +* ֵ +* +*/ +UINT8 GetZfwjHunXianFLag(void); + +/* +* ָȫվ־ +* ˵ void +* ֵ CI_ALL_SWITCH_YLOCK_NO + CI_ALL_SWITCH_YLOCK_YES +*/ +void AllSwitchYLock_UseVirCI(UINT8 virCIid,UINT8 setFlag); + +/* +* ȡת޻״̬ +* ˵ void +* ֵ SwitchBlockLinkState ת޻״̬ +* +*/ +UINT8 GetCancelOrRcvrBlockLinkSta(void); + +/* +* ת޻ȡͻָ״̬ +* ˵ UINT8 blockLinkState ״̬ +* ֵ +* +*/ +void SetCancelOrRcvrBlockLinkSta(UINT8 blockLinkState); + +/* +* ҵ·ڵһʱ߼ +* ˵ UINT16 routeId, + +* ֵ UINT16 ID +* = 0 Ч +* > 0 ID +*/ +UINT16 GetRouteFirstDelayLockLogId(UINT16 routeId); + +/* +* ·߼ȫ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckRouteLogSecHaveUnLock(const UINT16 routeId); + +/* +* ùյΰ߼ι +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +void SetPhyIncludeLogLockState(const UINT16 phyId, const UINT8 lockState, const UINT16 routeId); + +/* +* ڵ߼ȫ +* ˵ UINT16 routeId · +* ֵCI_SUCCESSȫ +* CI_ERROR: ڱ·߼ +*/ +UINT8 CheckPhyInLogUlock(const UINT16 phyId, const UINT16 routeId, UINT16* belongRoute); + + + +/* +* ߼εռ״̬ +* ˵ UINT16 switchIdId +* UINT16* logOccOrLockId ߼ID +* UINT8* pState ߼״̬ +* ֵ CI_SUCCESS: ߼ζ +* CI_ERROR: ߼δռ +* modify 20221009 pState +*/ +UINT8 GetSwitchLogSecOccState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState); + +/* +* ι߼εռ״̬ +* ˵ UINT16 switchIdId +* UINT16* logOccOrLockId ߼ID +* UINT8* pState ߼״̬ +* ֵ CI_SUCCESS: ͨ +* CI_ERROR: 鲻ͨ +* add 20221009 ·ǰ +*/ +UINT8 GetSwitchSecOccState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState); + +/* +* ߼ε״̬ +* ˵ UINT16 switchIdId +* UINT16* logOccOrLockId ߼ID +* UINT8* pState ߼״̬ +* ֵ CI_SUCCESS: ߼ζδ +* CI_ERROR: ߼ռ +* modify 20221009 pState +*/ +UINT8 GetSwitchLogSecLockState(UINT16 switchId, UINT16* logOccOrLockId, UINT8* pState); +/* +* ҵ·ڵһ߼ +* ˵ UINT16 routeId, +* ֵ UINT16 ID +* = 0 Ч +* > 0 ߼ID +*/ +UINT16 GetRouteFirstNormalLockLogId(UINT16 RouteId); + +/* +* ý·߼ԴгID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +* qw.liu 2022-03-03 +*/ +void SetRouteLogicSecResTrainId(const UINT16 routeId, const UINT16 wTrainId); + +/* +* ȡ·гӽʱռѹ߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ α +*/ +UINT16 GetRouteHaveTrainNearLogSecId(const UINT16 routeId); + +/* +* ·δ״̬ +* ˵ const UINT16 routeId, ·ID +* +* ֵ CI_ERROR IDδջ +* CI_SUCCESS +*/ +UINT8 CheckRouteStateNotYinDaoLock(UINT16 routeId); + +/* +* ȡ·׼·гϢ +* ˵ const UINT16 routeId, ·ID pTrainNumԤ wszTrainId ԤID +* ֵ CI_ERROR :ȡʧ +* CI_SUCCESS:ȡɹ +*/ +UINT8 GetRouteReadyEnterTrainInfo(const UINT16 wRouteId, UINT8 * pTrainNum, UINT16 wszTrainId[]); + +/* +* ȡ·ⷽһ߼ξԴгϢ +* ˵const UINT16 routeId ·ID +* UINT8* pTrainNum Ԥ +* UINT16 szTrainId[LOGIC_SECTION_RES_SUM_MAX] ԤID +* ֵ0 ȡʧ +* 1 ȡɹ +* Created By LQ 2024.12.02 +*/ +UINT8 GetRouteInOutFstLgcTrainInfo(const UINT16 wRouteId, UINT8* pTrainNum, UINT16 szTrainId[LOGIC_SECTION_RES_SUM_MAX]); + +/* +* ·߼ԴID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +* qw.liu 2022-03-03 +*/ +void SetLgcSecResTrnIdOtherTiocRt(const UINT16 routeId, const UINT16 wTrainId); + +/* +* ȡ·Ϊ·ԴгϢ +* ˵ const UINT16 routeId, ·ID pTrainNum г wszTrainId гIDBuf +* ֵ CI_ERROR :ȡʧ +* CI_SUCCESS:ȡɹ +*/ +UINT8 GetRouteNotEnterTrainInfo(const UINT16 wRouteId, UINT8 * pTrainNum, UINT16 wszTrainId[]); + +/* +* ͷűԴ +* ˵ const UINT16 wOverlapId, ID +* ֵ +* qw.liu 2022-06-10 +*/ +void ReleaseOverlapRes(const UINT16 wOverlapId); + +/* +* ȡʱȷϱ־ +* ˵ +* ֵ ȷϱ־ +*/ +extern UINT8 GetTsrSureFlag(void); +/* +* ʱȷϱ־ +* ˵cTsrSureFlag ȷϱ־ +* ֵ +*/ +extern void SetTsrSureFlag(UINT8 cTsrSureFlag); + +/* +* ˹ռѹʱ· +* ˵ UINT16 wPhySecId, ID + +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CancelOutFirstFaultOccUnlock(UINT16 wPhySecId); + +/** +* @brief гǰ߼ +* @param wTrainId гID +* @param pLogicSecSum ߼ +* @param szLogicSecIdBuf ߼ +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.8.23 +*/ +UINT8 CalTrainFrontLogicSecSeq(IN const UINT16 wTrainId, OUT UINT16 * pLogicSecSum, OUT UINT16 szLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM]); + +/** +* @brief ȡг߼ +* @param wTrainId гID +* @param pLogicSecSum ߼ +* @param szLogicSecIdBuf ߼ +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.8.23 +*/ +UINT8 GetTrainUsableLogicSec(IN const UINT16 wTrainId, OUT UINT16 * pLogicSecSum, OUT UINT16 szLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM]); + + +/* +* ȡȫѩģʽ +* ˵ void +* ֵ 0x55: Ч 0xAA:Ч +*/ + +extern UINT8 GetAllSnowModel(void); +/* +* ȫѩģʽ +* ˵ 0x55: Ч 0xAA:Ч +* ֵ void +*/ +extern void SetAllSnowModel(UINT8 setmodle); + +/* +* ȡITEȫг״̬ +* ˵void +* ֵ0x55 гITE +* 0xAA ʹITE +* 0xFF Ĭֵ +* Created By LQ 2024.07.12 +*/ +UINT8 GetIteLineCutState(void); + +/* +* ITEȫг״̬ +* ˵UINT8 cSetState õITEȫг״̬ +* ֵ +* Created By LQ 2024.07.12 +*/ +void SetIteLineCutState(UINT8 cSetState); + +/* +* ȡȫʱ״̬ +* ˵ void +* ֵ 0x55: Ч 0xAA:Ч +*/ + +extern UINT8 GetAllLineTsrState(void); + +/* +* ȫʱ״̬ +* ˵ 0x55: Ч 0xAA:Ч +* ֵ void +*/ +extern void SetAllLineTsrState(UINT8 cSetState); + +/* +* ȡȫʱٶ +* ˵ void +* ֵ ȫʱֵ +*/ + +extern UINT8 GetAllLineTsrSpeed(void); + +/* +* ȫʱٶ +* ˵ UINT8 cSpeed ٶֵ +* ֵ void +*/ +extern void SetAllLineTsrSpeed(UINT8 cSpeed); + +/* +* ȡ߼ռϢ +* ˵ void +* ֵ +* LOGICSECTION_OCCUPY_UT +* LOGICSECTION_OCCUPY_CT +* LOGICSECTION_OCCUPY_NO +*/ +UINT8 GetPhySecUtOrCtOccuState(UINT16 phySectionId); + + +/* +* ָIDȨ־ +* ˵ const UINT8 virCiId ID + const UINT8 ctrlPowerFlag ״̬ + const UINT16 ctrlPowerId 豸 + const UINT8 ctrlDeviceType 豸 + + +* ֵ viod +* +*/ +void SetCtrlPower(const UINT8 virtualCiId, const UINT8 ctrlPowerFlag, const UINT16 ctrlPowerId, const UINT8 ctrlDeviceType); +/* +* ͷָIDȨ־ +* ˵ const UINT8 virCiId ID + const UINT8 ctrlPowerFlag ״̬ + const UINT16 ctrlPowerId 豸 + const UINT8 ctrlDeviceType 豸 + + +* ֵ viod +* +*/ +void ReleaseCtrlPower(const UINT8 virtualCiId, const UINT8 ctrlPowerFlag, const UINT16 ctrlPowerId, const UINT8 ctrlDeviceType); + +/* +* ȡԶ־ +* ˵ UINT8 virCIid ID +* UINT8 setFlag õԶ־ +* ֵ +* cgh-ϲCID-3037-4 +*/ +void CancelAutoTriggerLogicManage(UINT8 virCIid, UINT8 setFlag); +/* +* ָ·Զ־ +* ˵UINT8 virCIid ID + UINT16 routeId ·ID +* UINT8 setFlag õԶ־ +* ֵ +*/ +void SetSigleRouteAutoTriggerManage(UINT8 virCIid, UINT16 routeId, UINT8 setFlag); +/* +* ȡָ·Զ־ +* ˵ UINT8 virCIid ID +* UINT16 routeId ·ID +* UINT8 setFlag õԶ־ +* ֵ +* cgh-ϲCID-3037-4 +*/ +void CancelSigleRouteAutoTrigger(UINT8 virCIid, UINT16 routeId, UINT8 setFlag); +/* +* վ̨ͱ־ +* ˵UINT16 phySecId ID +* UINT8 setFlag õͱ־ +* ֵ +* cgh-ϲCID-3037-7 +*/ +void SetClearPassenagerManage(UINT16 phySecId, UINT8 setFlag); + +/* +* ý·߼ԴгID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +* qw.liu 2022-03-03 +* @note bug 20220420 淶ɾע +*/ +void SetRouteHalfLogSecResTrainId(const UINT16 routeId, const UINT16 wTrainId); + +/* +*:·ֹλ +* +*: const UINT16 routeId ·ID +* +*:. +* +*ֵ: +* +*/ +void ClearRouteHalfSwitchDrivePos(const UINT16 routeId); + +/* +*:·ֹλ +* +*: const UINT16 routeId ·ID +* +*:. +* +*ֵ: +* +*/ +void ClearRouteHalfSwitchDanCaoPos(const UINT16 routeId); + +/* +*:߼·λ +*: const UINT16 routeId ·ID +*:. +*ֵ: +*/ +void ClearLogRouteSwitchDrivePos(const UINT16 logRouteId); + +/* +*:߼·λ +*: const UINT16 routeId ·ID +*:. +*ֵ: +*/ +void ClearLogRouteSwitchDanCaoPos(const UINT16 logRouteId); + +/* +* ··յλȷ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +* CI_SUCCESS:·λȷ +* CI_ERROR:·λ +*/ +UINT8 ChekRouteHalfSwPosRight(const UINT16 routeId); + +/* +* ··Ƿеʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +CI_SUCCESS:·޵ʱ +CI_ERROR:·еʱ +*/ +UINT8 ChekRouteHalfSwDrvOvTime(const UINT16 routeId); +/* +* ΰȫ߼״̬ +* ˵ const UINT16 phyId ID, const UINT8 lockState ״̬ +* ֵ1 +* 0: +*/ +void SetPhyIncAllLogLockState(const UINT16 phyId, const UINT8 lockState); + +/* +: · +: const UINT16 routeId ·ID +: +ֵ: CI_SUCCESS,մɹ +CI_ERROR,մʧ +*/ +UINT8 RouteLockHalfDriveSwitch(const UINT16 routeId); + +/* +: ·յ + : const UINT16 routeId ·ID + : const UINT8 DrivFlag ־ +ֵ : +*/ +void RouteHalfDrvInnerSwitch(const UINT16 routeId, const UINT8 DrivFlag); + +/* +: ؿźŴ + : const UINT16 signalId źŻID + : const UINT8 yLockState ״̬ +ֵ : +*/ +void LeadzLockOpenSignal(const UINT16 signalId, const UINT8 yLockState); + +/* +: ؿź¹ܴ + : const UINT16 signalId źŻID + : const UINT8 yLockState ״̬ +ֵ : +*/ +void LeadzLockNewOpenManage(const UINT16 signalId, const UINT8 yLockState); + +/* +: ΣCBTCзCBTC򣬼·Уźؿ + : const UINT16 signalId źŻID + : const UINT8 yLockState ״̬ +ֵ : +*/ +void LeadzLockSignalOpenRouteCheck(const UINT16 signalId, const UINT8 yLockState); + +/* +* ·Ƿ߼ +* ˵ UINT16 routeId · +* , UINT8 *pOtherCiId ID +* ֵ1ִгɹ +* 0: ִʧ +* by cgh 20231007 +*/ +UINT8 RouteHaveLogSecBelongOtherCi(const UINT16 routeId, UINT8* pOtherCiId); + +/* +* ·ڱ߼ѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +* by cgh 20231007 +*/ +UINT8 CheckLocalCiRouteLogSecUnLock(const UINT16 routeId); + +/* +* ̵ӿ¼DZĽ·ڣڱ߼Ƿѽ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +* by cgh 20231007 +*/ +UINT8 CheckRouteLogSecUnLock(const UINT16 routeId); + +/* +* ҵ߼·ڵһ߼յ߼ +* ˵ const UINT16 wLogRouteId ߼·ID +* ֵ = 0 Ч +* > 0 ߼ID +* by cgh 20231012 +*/ +UINT16 GetLogRouteFirNormalLockLogId(const UINT16 wLogRouteId); + +/* +* ߼Ƿָ߼· +* ˵ const UINT16 wLogSection ߼ID + const UINT16 wLogRouteId ߼·ID +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20231012 +*/ +UINT8 CheckLogSecLockBelLogRoute(const UINT16 wLogSection, const UINT16 wLogRouteId); + +/* +* ΰ߼߼״̬ +* ˵ const UINT16 wPhySecId, ID + const UINT8 chLockState, ߼״̬ + const UINT16 wLogRouteId ߼·ID +* ֵ +* by cgh 20231013 +*/ +void SetPhyIncLogSecLogLockState(const UINT16 wPhySecId, const UINT8 chLockState, const UINT16 wLogRouteId); + +/* +* ȡ߼α߼·յ߼· +* ˵ const UINT16 wLogSection ߼ID + const UINT16 wLogRouteId ߼·ID +* ֵ ߼· +* by cgh 20231013 +*/ +UINT8 GetLogSecLogLockBelRouteDir(const UINT16 wLogSection, const UINT16 wLogRouteId); + +/* +* ߼·߼ȫ +* ˵ UINT16 wLogRouteId ߼· +* ֵCI_SUCCESS +* CI_ERROR: +* by cgh 20231013 +*/ +UINT8 CheckLogRouteLogSecHaveUnLock(const UINT16 wLogRouteId); + +/* +* ΰ߼εĽ·״̬ +* ˵ const UINT16 wPhySecId ID +* UINT16* pLogSecLockId յ߼ID +* UINT8* pState ߼״̬ +* ֵ CI_SUCCESS ߼ζδ +* CI_ERROR ߼δ +* Created By LQ 2023/10/17 +*/ +UINT8 CheckPSecIncLSecLockState(const UINT16 wPhySecId, UINT16* pLogSecLockId, UINT8* pState); + +/* +* ΰ߼ε߼·״̬ +* ˵ const UINT16 wPhySecId ID +* UINT16* pLogSecLockId յ߼ID +* UINT8* pState ߼߼״̬ +* ֵ CI_SUCCESS ߼ζδ +* CI_ERROR ߼δ +* Created By LQ 2023/10/17 +*/ +UINT8 CheckPSecIncLSecLogicLockState(const UINT16 wPhySecId, UINT16* pLogSecLockId, UINT8* pState); + +/* +* ȡָ·״̬ +* ˵ const UINT16 wRouteId, ·ID +* ֵ 0: ȡʧ +* >0: · +* by cgh 20231113 +*/ +UINT8 GetDiaoCheRouteOpenState(const UINT16 wRouteId); + +/* +* ñѩվ̨Ϣ +* ˵const UINT8 cAreaSnowNum ѩ +* const UINT32 pAreaSnowIdBuf[] ѩID +* ֵ +*/ +void SetLocalAreaSnowInfo(const UINT8 cAreaSnowNum, const UINT32 pAreaSnowIdBuf[]); + +/* +* ȡѩվ̨ +* ˵ +* ֵ ѩվ̨ +*/ +UINT8 GetLocalAreaSnowNum(void); + +/* +* ȡѩվ̨ID +* ˵ +* ֵ ѩվ̨ID +*/ +UINT32* GetLocalAreaSnowId(void); + + +/* +* ·ڵһյDzǹ +* ˵ UINT16 routeId, ·ID +* UINT16 ID һյIDΣ +* ֵ 0 һյβǹ +* 1 һյǹ +*/ +UINT8 RouteFirstLockErrCheck(UINT16 routeId); + +/* +* ȡȫͨų +* ˵ +* ֵȫͨųṹ +* Created By LQ 2024.07.14 +*/ +LineCommTrainStruct GetLineCommTrainData(void); + +/* +* ȫͨų +* ˵UINT8 cLineCtNum ȫͨų +* UINT16 szLineCtId[TRAIN_SUM_MAX] ȫͨID +* ֵ +* Created By LQ 2024.07.14 +*/ +void ProcessLineCommTrainData(UINT8 cLineCtNum, UINT16 szLineCtId[TRAIN_SUM_MAX]); + +/* +* ȫͨų +* ˵ +* ֵ +* Created By LQ 2024.07.14 +*/ +void ClearLineCommTrainData(void); + +/* +* ÷ɳ崻ʼ +* ˵ UINT32 dwFlyProtectOverCyc 崻ں +* ֵ +*/ +void SetFlyProtectOverCyc(UINT32 dwFlyProtectOverCyc); + +/* +* ȡɳ崻ʼ,δ÷0 +* ˵ void +* ֵ +*/ +UINT32 GetFlyProtectOverCyc(void); + +/* +* ȡѩģʽ +* ˵ void +* ֵ 0x55: Ч 0xAA:Ч +* by cgh 20241030 +*/ + +UINT8 GetLocalSnowModel(void); + +/* +* ñѩģʽ +* ˵UINT8 setmodle ѩģʽ +* ֵ void +* by cgh 20241030 +*/ +void SetLocalSnowModel(UINT8 setmodle); + +/* +* :·յټ +* : const UINT16 routeId ·ID +* : +* ֵ: CI_SUCCESS :ɹ +* CI_ERROR: ʧ +* by cgh 20241203 +*/ +UINT8 RouteLockSwitchDanCaoCheck(const UINT16 routeId); + +/* +* ЧԼ +* ˵ const UINT16 wSwitchIdId +* const UINT8 functionId, ID +* const UINT8 chSendLevel͵ȼ +* ֵ CI_SUCCESS: ɹ +* CI_ERROR: ʧ +* by cgh 20241205 +*/ +UINT8 GetSwitchUsingValidState(const UINT16 wSwitchId, const UINT8 chFunctionId, const UINT8 chSendLevel); + +/* +* ָIDȨĬ״̬ +* ˵ const UINT8 virtualCiId ID +* ֵ viod +* by cgh 20250305 +*/ +void DefaultCtrlPowerDeal(const UINT8 virtualCiId); + +#endif diff --git a/TSCP/src/APP/ciapp/DataManage/PlatDataManage.c b/TSCP/src/APP/ciapp/DataManage/PlatDataManage.c new file mode 100644 index 0000000..239b672 --- /dev/null +++ b/TSCP/src/APP/ciapp/DataManage/PlatDataManage.c @@ -0,0 +1,674 @@ +/******************************************************** +* +* PlatDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2023-12-12 +* ߣ +* ƽ̨յƽ̨豸ݴ +* +* ʹע⣺ +* ޸ļ¼ +* by lc 20231212 +* +********************************************************/ + + +#include "PlatDataManage.h" + +extern PlatHeartDataStruct RecvHeartDataStru ; /*ƽ̨֡ݽṹ*/ +extern PlatGPIODataStruct RecvPlatDataStruGPIO;/*ƽ̨0x2D֡ݽṹ GPIOɼ״̬*/ + + + + +/* +* ָͨذ忨͵ +* ˵ 忨ID +* ֵ +*/ +void ClearnCCUHeartData(UINT8 boardId) +{ + /*Aϵͨ*/ + if (BOARD_TYPE_CCUA == boardId) + { + RecvHeartDataStru.voltageA_CCA = 0U; /*24VAԴ_ѹ*1000*/ + RecvHeartDataStru.voltageB_CCA = 0U; /*24VBԴ_ѹ*1000*/ + RecvHeartDataStru.currentA_CCA = 0U; /*24VAԴ_*1000*/ + RecvHeartDataStru.currentB_CCA = 0U; /*24VVԴ_*1000*/ + RecvHeartDataStru.voltageCoup_CCA = 0U; /*24VԴ_ѹ*1000*/ + RecvHeartDataStru.currentCoup_CCA = 0U; /*24VԴ_*1000*/ + RecvHeartDataStru.temperature_CCA = 0U; /*¶ֵ*1000*/ + RecvHeartDataStru.check_EEPROM_CCA = 0U; /*EEPROM洢*/ + RecvHeartDataStru.commStartCycle_CCA = 0U; /*ͨ*/ + } + else if (BOARD_TYPE_CCUB == boardId) + { + RecvHeartDataStru.voltageA_CCB = 0U; /*24VAԴ_ѹ*1000*/ + RecvHeartDataStru.voltageB_CCB = 0U; /*24VBԴ_ѹ*1000*/ + RecvHeartDataStru.currentA_CCB = 0U; /*24VAԴ_*1000*/ + RecvHeartDataStru.currentB_CCB = 0U; /*24VVԴ_*1000*/ + RecvHeartDataStru.voltageCoup_CCB = 0U; /*24VԴ_ѹ*1000*/ + RecvHeartDataStru.currentCoup_CCB = 0U; /*24VԴ_*1000*/ + RecvHeartDataStru.temperature_CCB = 0U; /*¶ֵ*1000*/ + RecvHeartDataStru.check_EEPROM_CCB = 0U; /*EEPROM洢*/ + RecvHeartDataStru.commStartCycle_CCB = 0U; /*ͨ*/ + } + else if (BOARD_TYPE_SEBA == boardId) + { + RecvHeartDataStru.commStartCycle_SEBA = 0U; /*ͨ*/ + } + else if (BOARD_TYPE_SEBB == boardId) + { + RecvHeartDataStru.commStartCycle_SEBB = 0U; /*ͨ*/ + } + else + { + /**/ + } +} + +/* +* ģʽ£ƽ̨֡Ϊֵ +* ˵ +* ֵ +*/ +void SetCCUHeartDataNormal(void) +{ + RecvHeartDataStru.voltageA_CCA = 24000U; /*24VAԴ_ѹ*1000*/ + RecvHeartDataStru.voltageB_CCA = 24000U; /*24VBԴ_ѹ*1000*/ + RecvHeartDataStru.currentA_CCA = 5000U; /*24VAԴ_*1000*/ + RecvHeartDataStru.currentB_CCA = 5000U; /*24VVԴ_*1000*/ + RecvHeartDataStru.voltageCoup_CCA = 24000U; /*24VԴ_ѹ*1000*/ + RecvHeartDataStru.currentCoup_CCA = 5000U; /*24VԴ_*1000*/ + RecvHeartDataStru.temperature_CCA = 0U; /*¶ֵ*1000*/ + RecvHeartDataStru.check_EEPROM_CCA = 0U; /*EEPROM洢*/ + RecvHeartDataStru.voltageA_CCB = 24000U; /*24VAԴ_ѹ*1000*/ + RecvHeartDataStru.voltageB_CCB = 24000U; /*24VBԴ_ѹ*1000*/ + RecvHeartDataStru.currentA_CCB = 5000U; /*24VAԴ_*1000*/ + RecvHeartDataStru.currentB_CCB = 5000U; /*24VVԴ_*1000*/ + RecvHeartDataStru.voltageCoup_CCB = 24000U; /*24VԴ_ѹ*1000*/ + RecvHeartDataStru.currentCoup_CCB = 5000U; /*24VԴ_*1000*/ + RecvHeartDataStru.temperature_CCB = 0U; /*¶ֵ*1000*/ + RecvHeartDataStru.check_EEPROM_CCB = 0U; /*EEPROM洢*/ + RecvHeartDataStru.commState_CCA = CCU_COMMSTATUS_GOOD; + RecvHeartDataStru.commState_CCB = CCU_COMMSTATUS_GOOD; + RecvHeartDataStru.commState_SEBA = CCU_COMMSTATUS_GOOD; + RecvHeartDataStru.commState_SEBB = CCU_COMMSTATUS_GOOD; +} + +/* +* ģʽ£ƽ̨GPIOPɼΪֵ +* ˵ +* ֵ +*/ +void SetCCUPlatGPIODataNormal(void) +{ + RecvPlatDataStruGPIO.powerANodeState = NODE_STATUS_CLOSE; + RecvPlatDataStruGPIO.powerBNodeState = NODE_STATUS_CLOSE; + RecvPlatDataStruGPIO.ModepowerAState_PUA = POWER_STATUS_NORMAL; + RecvPlatDataStruGPIO.ModepowerBState_PUA = POWER_STATUS_NORMAL; + RecvPlatDataStruGPIO.ModepowerAState_PUB = POWER_STATUS_NORMAL; + RecvPlatDataStruGPIO.ModepowerBState_PUB = POWER_STATUS_NORMAL; +} + +/* +* ȡָɼ㴦ѹ +* ˵ UINT8 pointType ɼ +* ֵ ɼѹ +*/ +UINT16 GetCollectPointVoltage(UINT8 pointType) +{ + UINT16 retVal = 0U; + switch (pointType) + { + case COLLECT_MODEA_CCUA: + { + retVal = RecvHeartDataStru.voltageA_CCA; + break; + } + case COLLECT_MODEA_CCUB: + { + retVal = RecvHeartDataStru.voltageA_CCB; + break; + } + case COLLECT_MODEB_CCUA: + { + retVal = RecvHeartDataStru.voltageB_CCA; + break; + } + case COLLECT_MODEB_CCUB: + { + retVal = RecvHeartDataStru.voltageB_CCB; + break; + } + case COLLECT_COUPLING_CCUA: + { + retVal = RecvHeartDataStru.voltageCoup_CCA; + break; + } + case COLLECT_COUPLING_CCUB: + { + retVal = RecvHeartDataStru.voltageCoup_CCB; + break; + } + default: + /*ɴ֧*/ + break; + } + + return retVal; +} + + +/* +* ȡָɼ㴦 +* ˵ UINT8 pointType ɼ +* ֵ ɼ +*/ +UINT16 GetCollectPointCurrent(UINT8 pointType) +{ + UINT16 retVal = 0U; + switch (pointType) + { + case COLLECT_MODEA_CCUA: + { + retVal = RecvHeartDataStru.currentA_CCA; + break; + } + case COLLECT_MODEA_CCUB: + { + retVal = RecvHeartDataStru.currentA_CCB; + break; + } + case COLLECT_MODEB_CCUA: + { + retVal = RecvHeartDataStru.currentB_CCA; + break; + } + case COLLECT_MODEB_CCUB: + { + retVal = RecvHeartDataStru.currentB_CCB; + break; + } + case COLLECT_COUPLING_CCUA: + { + retVal = RecvHeartDataStru.currentCoup_CCA; + break; + } + case COLLECT_COUPLING_CCUB: + { + retVal = RecvHeartDataStru.currentCoup_CCB; + break; + } + default: + /*ɴ֧*/ + break; + } + + return retVal; +} + + +/* +* ȡԴAĿտ״̬ +* ˵ +* ֵ 0x55 պ +* 0xaa Ͽ +*/ +UINT8 GetPowerANodeStatue(void) +{ + UINT8 retVal = 0U; + if (NODE_STATUS_CLOSE == RecvPlatDataStruGPIO.powerANodeState) + { + retVal = NODE_STATUS_CLOSE; + } + else + { + retVal = NODE_STATUS_BREAK; + } + + return retVal; +} + +/* +* ȡԴBĿտ״̬ +* ˵ +* ֵ 0x55 պ +* 0xaa Ͽ +*/ +UINT8 GetPowerBNodeStatue(void) +{ + UINT8 retVal = 0U; + if (NODE_STATUS_CLOSE == RecvPlatDataStruGPIO.powerBNodeState) + { + retVal = NODE_STATUS_CLOSE; + } + else + { + retVal = NODE_STATUS_BREAK; + } + + return retVal; +} + +/* +* ȡͨAͨ״̬ +* ˵ +* ֵ 0x55 ͨ +* 0xaa ͨж +*/ +UINT8 GetCCUACommStatus(void) +{ + UINT8 retVal = 0U; + + if (CCU_COMMSTATUS_GOOD == RecvHeartDataStru.commState_CCA) + { + retVal = CCU_COMMSTATUS_GOOD; + } + else + { + retVal = CCU_COMMSTATUS_BAD; + } + return retVal; +} + +/* +* ȡͨBͨ״̬ +* ˵ +* ֵ 0x55 ͨ +* 0xaa ͨж +*/ +UINT8 GetCCUBCommStatus(void) +{ + UINT8 retVal = 0U; + + if (CCU_COMMSTATUS_GOOD == RecvHeartDataStru.commState_CCB) + { + retVal = CCU_COMMSTATUS_GOOD; + } + else + { + retVal = CCU_COMMSTATUS_BAD; + } + return retVal; +} + +/* +* ȡչAͨ״̬ +* ˵ +* ֵ 0x55 ͨ +* 0xaa ͨж +*/ +UINT8 GetSEBACommStatus(void) +{ + UINT8 retVal = 0U; + + if (CCU_COMMSTATUS_GOOD == RecvHeartDataStru.commState_SEBA) + { + retVal = CCU_COMMSTATUS_GOOD; + } + else + { + retVal = CCU_COMMSTATUS_BAD; + } + return retVal; +} + +/* +* ȡչBͨ״̬ +* ˵ +* ֵ 0x55 ͨ +* 0xaa ͨж +*/ +UINT8 GetSEBBCommStatus(void) +{ + UINT8 retVal = 0U; + + if (CCU_COMMSTATUS_GOOD == RecvHeartDataStru.commState_SEBB) + { + retVal = CCU_COMMSTATUS_GOOD; + } + else + { + retVal = CCU_COMMSTATUS_BAD; + } + return retVal; +} + +/* +* ȡָɼ㴦GPIOɼĵԴ״̬ 1\2\3\4ɼ +* ˵ UINT8 pointType ɼ +* ֵ 0x55 Դ״̬ +* 0xaa Դ״̬쳣 +*/ +UINT8 GetGPIOCollectPointStatus(UINT8 pointType) +{ + UINT8 powerState = 0U; + switch (pointType) + { + case COLLECT_MODEA_CCUA: + { + powerState = RecvPlatDataStruGPIO.ModepowerAState_PUA; + break; + } + case COLLECT_MODEA_CCUB: + { + powerState = RecvPlatDataStruGPIO.ModepowerAState_PUB; + break; + } + case COLLECT_MODEB_CCUA: + { + powerState = RecvPlatDataStruGPIO.ModepowerBState_PUA; + break; + } + case COLLECT_MODEB_CCUB: + { + powerState = RecvPlatDataStruGPIO.ModepowerBState_PUB; + break; + } + default: + /*ɴ֧*/ + break; + } + + + return powerState; +} + + +/* +* ijɼѹǷڶΧ +* ˵ UINT8 pointType ɼ +* ֵ 0 ѹΪ0 +* 0x55 ڶΧ +* 0xaa +* 0xbb Ƿѹ +*/ +UINT8 CheckPointVoltageState(UINT8 pointType) +{ + UINT8 retVal = CHECK_VOLTAGE_ZERO; + UINT16 voltage = 0U; /*ɼ5ѹ*/ + + /*ȡòɼѹ*/ + voltage = GetCollectPointVoltage(pointType); + + if (VOLTAGE_MAX_TO_0 > voltage) + { + retVal = CHECK_VOLTAGE_ZERO; + } + else if ((RATED_VOLTAGE_MIN <= voltage) && (RATED_VOLTAGE_MAX >= voltage)) + { + retVal = CHECK_VOLTAGE_NOMAL; + } + else if (RATED_VOLTAGE_MAX < voltage) + { + retVal = CHECK_VOLTAGE_OVERRUN; + } + else if (RATED_VOLTAGE_MIN > voltage) + { + retVal = CHECK_VOLTAGE_FEWER; + } + else + { + /*ɴ֧0ѹ*/ + } + return retVal; +} + + + +/* +* AϵԴ״̬ +* ˵ +* ֵ CI_SUCCESS δ +* CI_ERROR +*/ +UINT8 CheckRCIAPowerFaultState(void) +{ + UINT8 retVal = CI_ERROR; + UINT8 cxABreakFlag = 0U; /*AϵԴտϿ*/ + + cxABreakFlag = GetPowerANodeStatue(); + + /* 1AϵԴտϿ */ + if (NODE_STATUS_BREAK == cxABreakFlag) + { + /*AϵԴ״̬*/ + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + return retVal; +} + +/* +* BϵԴ״̬ +* ˵ +* ֵ CI_SUCCESS δ +* CI_ERROR +*/ +UINT8 CheckRCIBPowerFaultState(void) +{ + UINT8 retVal = CI_ERROR; + UINT8 cxBBreakFlag = 0U; /*BϵԴտϿ*/ + + cxBBreakFlag = GetPowerBNodeStatue(); + + /* 1BϵԴտϿ */ + if (NODE_STATUS_BREAK == cxBBreakFlag) + { + /*BϵԴ״̬*/ + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + return retVal; +} + + +/* +* AϵԴģ״̬ +* ˵ +* ֵ CI_SUCCESS δ +* CI_ERROR +*/ +UINT8 CheckRCIAPowerModeFaultState(void) +{ + UINT8 retVal = CI_ERROR; + + UINT8 powerAPUBAState = 0U; /*PUB Aɼ24VAԴ״̬ 1*/ + UINT8 powerBPUBAState = 0U; /*PUB Aɼ24VBԴ״̬ 3*/ + UINT8 vol1Flag = 0U; /*CPI Aɼ24VAԴ 1*/ + UINT8 vol3Flag = 0U; /*CPI Aɼ24VBԴ 3*/ + + powerAPUBAState = GetGPIOCollectPointStatus(COLLECT_MODEA_CCUA); + powerBPUBAState = GetGPIOCollectPointStatus(COLLECT_MODEB_CCUA); + vol1Flag = CheckPointVoltageState(COLLECT_MODEA_CCUA); + vol3Flag = CheckPointVoltageState(COLLECT_MODEB_CCUA); + + /* 1PUB Aɼ24VAԴ쳣24VBԴ쳣 + 2CPI Aɼ24VAԴ24VBԴѹΪ0V */ + + if (((CHECK_VOLTAGE_ZERO == vol1Flag) || (CHECK_VOLTAGE_ZERO == vol3Flag)) + && ((POWER_STATUS_ABNORMAL == powerAPUBAState) || (POWER_STATUS_ABNORMAL == powerBPUBAState))) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + + return retVal; +} + +/* +* BϵԴģ״̬ +* ˵ +* ֵ CI_SUCCESS δ +* CI_ERROR +*/ +UINT8 CheckRCIBPowerModeFaultState(void) +{ + UINT8 retVal = CI_ERROR; + + UINT8 powerAPUBBState = 0U; /*PUB Aɼ24VAԴ״̬ 2*/ + UINT8 powerBPUBBState = 0U; /*PUB Aɼ24VBԴ״̬ 4*/ + UINT8 vol2Flag = 0U; /*CPI Bɼ24VAԴ 2*/ + UINT8 vol4Flag = 0U; /*CPI Bɼ24VBԴ 4*/ + + powerAPUBBState = GetGPIOCollectPointStatus(COLLECT_MODEA_CCUB); + powerBPUBBState = GetGPIOCollectPointStatus(COLLECT_MODEB_CCUB); + vol2Flag = CheckPointVoltageState(COLLECT_MODEA_CCUB); + vol4Flag = CheckPointVoltageState(COLLECT_MODEB_CCUB); + + /* 1PUB Bɼ24VAԴ쳣24VBԴ쳣 + 2CPI Bɼ24VAԴ24VBԴѹΪ0V */ + + + /*δʵPUBɼֻжϵԴѹ*/ + if (((CHECK_VOLTAGE_ZERO == vol2Flag) || (CHECK_VOLTAGE_ZERO == vol4Flag)) + && ((POWER_STATUS_ABNORMAL == powerAPUBBState) || (POWER_STATUS_ABNORMAL == powerBPUBBState))) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + + return retVal; +} + + + + + +/* +* ͨ豸(ͨ)״̬ +* ˵ +* ֵ CI_SUCCESS ͨ +* CI_ERROR ͨж +*/ +UINT8 CheckRCICommCCUDeviceStatue(void) +{ + UINT8 retVal = CI_ERROR; + + UINT8 commCCA = 0U; /*ͨذAͨ״̬*/ + UINT8 commCCB = 0U; /*ͨذBͨ״̬*/ + UINT8 commSEBA = 0U; /*չAͨ״̬*/ + UINT8 commSEBB = 0U; /*չBͨ״̬*/ + commCCA = GetCCUACommStatus(); + commCCB = GetCCUBCommStatus(); + commSEBA = GetSEBACommStatus(); + commSEBB = GetSEBBCommStatus(); + + if ((CCU_COMMSTATUS_GOOD == commCCA) && (CCU_COMMSTATUS_GOOD == commCCB) && (CCU_COMMSTATUS_GOOD == commSEBA) && (CCU_COMMSTATUS_GOOD == commSEBB)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָͨŰͨ״̬ +* ˵UINT8 boardId ͨŰ忨ID +* UINT8 commState ͨ״̬ +* ֵ +* BY LC +*/ +void SetRCIandCCBoardCommStatus(UINT8 boardId, UINT8 commState) +{ + if ((CCU_COMMSTATUS_BAD == commState) || (CCU_COMMSTATUS_GOOD == commState)) + { + if (BOARD_TYPE_CCUA == boardId) + { + RecvHeartDataStru.commState_CCA = commState; + } + else if (BOARD_TYPE_CCUB == boardId) + { + RecvHeartDataStru.commState_CCB = commState; + } + else if (BOARD_TYPE_SEBA == boardId) + { + RecvHeartDataStru.commState_SEBA = commState; + } + else if (BOARD_TYPE_SEBB == boardId) + { + RecvHeartDataStru.commState_SEBB = commState; + } + else + { + /*ִ*/ + } + } +} + + +/* +* ȡָͨŰͨ״̬ +* ˵UINT8 boardId ͨŰ忨ID +* ֵ UINT8 commState ͨ״̬ +* BY LC +*/ +UINT8 GetRCIandCCBoardCommStatus(UINT8 boardId) +{ + UINT8 retVal = CCU_COMMSTATUS_BAD; + + if (BOARD_TYPE_CCUA == boardId) + { + retVal = RecvHeartDataStru.commState_CCA; + } + else if (BOARD_TYPE_CCUB == boardId) + { + retVal = RecvHeartDataStru.commState_CCB; + } + else + { + /*ִ*/ + } + return retVal; +} + + +/* +* ȡָͨŰͨſʼ +* ˵UINT8 boardId ͨŰ忨ID +* ֵ UINT8 commState ͨ״̬ +* BY LC +*/ +UINT32 GetRCIandCCBoardCommCyCNum(UINT8 boardId) +{ + UINT32 retVal = 0U; + + if (BOARD_TYPE_CCUA == boardId) + { + retVal = RecvHeartDataStru.commStartCycle_CCA; + } + else if (BOARD_TYPE_CCUB == boardId) + { + retVal = RecvHeartDataStru.commStartCycle_CCB; + } + else if (BOARD_TYPE_SEBA == boardId) + { + retVal = RecvHeartDataStru.commStartCycle_SEBA; + } + else if (BOARD_TYPE_SEBB == boardId) + { + retVal = RecvHeartDataStru.commStartCycle_SEBB; + } + else + { + /*ִ*/ + } + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/DataManage/PlatDataManage.h b/TSCP/src/APP/ciapp/DataManage/PlatDataManage.h new file mode 100644 index 0000000..7395560 --- /dev/null +++ b/TSCP/src/APP/ciapp/DataManage/PlatDataManage.h @@ -0,0 +1,280 @@ +/******************************************************** +* +* PlatDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2023-12-12 +* ߣ +* ƽ̨յƽ̨豸ݴ +* +* ʹע⣺ +* ޸ļ¼ +* 23231212 BY LC +* +********************************************************/ +#ifndef _DEVICE_PLAT_DATA_MANAGE_H_ +#define _DEVICE_PLAT_DATA_MANAGE_H_ + +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" + + + +#define BOARD_TYPE_CCUA ((UINT8)0x09) /*ͨذA*/ +#define BOARD_TYPE_CCUB ((UINT8)0x0C) /*ͨذB*/ +#define BOARD_TYPE_SEBA ((UINT8)0x01) /*չA*/ +#define BOARD_TYPE_SEBB ((UINT8)0x02) /*չB*/ + +#define CHECK_VOLTAGE_ZERO ((UINT8)0x00) /*ɼѹΪ0*/ +#define CHECK_VOLTAGE_OVERRUN ((UINT8)0xaa) /*ɼѹ*/ +#define CHECK_VOLTAGE_FEWER ((UINT8)0xbb) /*ɼѹǷѹ*/ +#define CHECK_VOLTAGE_NOMAL ((UINT8)0x55) /*ɼѹڶΧ*/ + +#define CHECK_CURRENT_OVERRUN ((UINT8)0xaa) /*ɼ*/ +#define CHECK_CURRENT_NOMAL ((UINT8)0x55) /*ɼڶΧ*/ + +#define RATED_VOLTAGE_MIN ((UINT16)21600U) /*ѹСֵ mV*/ +#define RATED_VOLTAGE_MAX ((UINT16)26400U) /*ѹֵ mV*/ +#define RATED_CURRENT_MIN ((UINT16)0U) /*Сֵ mA*/ +#define RATED_CURRENT_MAX ((UINT16)10000U) /*ֵ mA*/ + +#define COLLECT_MODEA_CCUA ((UINT8)0x11) /*ͨAģAɼ ɼ1*/ +#define COLLECT_MODEA_CCUB ((UINT8)0x22) /*ͨBģAɼ ɼ2*/ +#define COLLECT_MODEB_CCUA ((UINT8)0x33) /*ͨAģBɼ ɼ3*/ +#define COLLECT_MODEB_CCUB ((UINT8)0x44) /*ͨBģBɼ ɼ4*/ +#define COLLECT_COUPLING_CCUA ((UINT8)0x55) /*ͨAϵͳԴϲɼ ɼ5*/ +#define COLLECT_COUPLING_CCUB ((UINT8)0x66) /*ͨBϵͳԴϲɼ ɼ6*/ +#define COLLECT_POWER_NODE_A ((UINT8)0x77) /*AϵԴĿտ״̬*/ +#define COLLECT_POWER_NODE_B ((UINT8)0x88) /*BϵԴĿտ״̬*/ + +#define NODE_STATUS_CLOSE ((UINT8)0x55) /*տպѹ*/ +#define NODE_STATUS_BREAK ((UINT8)0xaa) /*տϿδ*/ + + +#define POWER_STATUS_NORMAL ((UINT8)0x55) /*Դ״̬*/ +#define POWER_STATUS_ABNORMAL ((UINT8)0xaa) /*Դ״̬쳣*/ + +#define CCU_COMMSTATUS_GOOD ((UINT8)0x55) /*ͨذͨ*/ +#define CCU_COMMSTATUS_BAD ((UINT8)0xaa) /*ͨذͨŹ*/ + +#define CCU_CommBadEnsureTime_CycleCount ((UINT16)5u) /*Ӧͨͨжж*/ + +#define VOLTAGE_MAX_TO_0 ((UINT16)500U) /*ѹжΪ0ֵ*/ + +/*ƽ̨֡Ϣṹ*/ +typedef struct S_PlatHeartDataStruct +{ + UINT16 voltageA_CCA; /*24VAԴ_ѹ*1000 ͨغ*/ + UINT16 voltageB_CCA; /*24VBԴ_ѹ*1000 ͨغ*/ + UINT16 currentA_CCA; /*24VAԴ_*1000 ͨغ*/ + UINT16 currentB_CCA; /*24VBԴ_*1000 ͨغ*/ + UINT16 voltageCoup_CCA; /*24VAԴ_ѹ*1000 ͨغ*/ + UINT16 currentCoup_CCA; /*24VAԴ_*1000 ͨغ*/ + UINT32 temperature_CCA; /*¶ֵ*1000 ͨغ*/ + UINT8 check_EEPROM_CCA; /*EEPROM洢 ͨغ ɹ0x55ʧ0xaa*/ + UINT16 voltageA_CCB; /*24VAԴ_ѹ*1000 ͨ*/ + UINT16 voltageB_CCB; /*24VBԴ_ѹ*1000 ͨ*/ + UINT16 currentA_CCB; /*24VAԴ_*1000 ͨ*/ + UINT16 currentB_CCB; /*24VBԴ_*1000 ͨ*/ + UINT16 voltageCoup_CCB; /*24VAԴ_ѹ*1000 ͨ*/ + UINT16 currentCoup_CCB; /*24VAԴ_*1000 ͨ*/ + UINT32 temperature_CCB; /*¶ֵ*1000 ͨ*/ + UINT8 check_EEPROM_CCB; /*EEPROM洢 ͨ ɹ0x55ʧ0xaa */ + UINT32 commStartCycle_CCA; /*ͨAͨſʼڣʹøͨͨжж*/ + UINT32 commStartCycle_CCB; /*ͨBͨſʼڣʹøͨͨжж*/ + UINT32 commStartCycle_SEBA; /*չ1ͨſʼڣʹøͨͨжж*/ + UINT32 commStartCycle_SEBB; /*չ2ͨſʼڣʹøͨͨжж*/ + UINT8 commState_CCA; /*CCAͨ״̬ 55 ͨ aa ͨŹ*/ + UINT8 commState_CCB; /*CCBͨ״̬ 55 ͨ aa ͨŹ*/ + UINT8 commState_SEBA; /*չ1ͨ״̬ 55 ͨ aa ͨŹ*/ + UINT8 commState_SEBB; /*չ2ͨ״̬ 55 ͨ aa ͨŹ*/ +}PlatHeartDataStruct; + +/*ƽ̨AIM0x2D֡ GPIOɼԴ״̬ṹ*/ +typedef struct S_PlatGPIODataStruct +{ + UINT8 powerANodeState; /*AϵԴĿտ״̬*/ + UINT8 powerBNodeState; /*BϵԴĿտ״̬*/ + UINT8 ModepowerAState_PUA; /*AϵԴΪCPUA24VDCԴģ״̬*/ + UINT8 ModepowerBState_PUA; /*BϵԴΪCPUA24VDCԴģ״̬*/ + UINT8 ModepowerAState_PUB; /*AϵԴΪCPUB24VDCԴģ״̬*/ + UINT8 ModepowerBState_PUB; /*BϵԴΪCPUB24VDCԴģ״̬*/ +}PlatGPIODataStruct; + + + + + + +/* +* ָͨذ忨͵ +* ˵ 忨ID +* ֵ +*/ +void ClearnCCUHeartData(UINT8 boardId); + +/* +* ģʽ£ƽ̨֡Ϊֵ +* ˵ +* ֵ +*/ +void SetCCUHeartDataNormal(void); + +/* +* ģʽ£ƽ̨GPIOPɼΪֵ +* ˵ +* ֵ +*/ +void SetCCUPlatGPIODataNormal(void); + +/* +* ȡָɼ㴦ѹ +* ˵ UINT8 boardType ͨذ +* ֵ ɼѹ +*/ +UINT16 GetCollectPointVoltage(UINT8 pointType); + + +/* +* ȡָɼ㴦 +* ˵ UINT8 boardType ͨذ +* ֵ ɼ +*/ +UINT16 GetCollectPointCurrent(UINT8 pointType); + + +/* +* ȡԴAĿտ״̬ +* ˵ +* ֵ 0x55 պ +* 0xaa Ͽ +*/ +UINT8 GetPowerANodeStatue(void); + +/* +* ȡԴBĿտ״̬ +* ˵ +* ֵ 0x55 պ +* 0xaa Ͽ +*/ +UINT8 GetPowerBNodeStatue(void); + +/* +* ȡͨAͨ״̬ +* ˵ +* ֵ 0x55 ͨ +* 0xaa ͨж +*/ +UINT8 GetCCUACommStatus(void); + +/* +* ȡͨBͨ״̬ +* ˵ +* ֵ 0x55 ͨ +* 0xaa ͨж +*/ +UINT8 GetCCUBCommStatus(void); + +/* +* ȡչAͨ״̬ +* ˵ +* ֵ 0x55 ͨ +* 0xaa ͨж +*/ +UINT8 GetSEBACommStatus(void); + +/* +* ȡչBͨ״̬ +* ˵ +* ֵ 0x55 ͨ +* 0xaa ͨж +*/ +UINT8 GetSEBBCommStatus(void); + +/* +* ȡָɼ㴦GPIOɼĵԴ״̬ +* ˵ UINT8 pointType ɼ +* ֵ 0x55 Դ״̬ +* 0xaa Դ״̬쳣 +*/ +UINT8 GetGPIOCollectPointStatus(UINT8 pointType); + + +/* +* ijɼѹǷڶΧ +* ˵ UINT8 pointType ɼ +* ֵ 0 ѹΪ0 +* 0x55 ڶΧ +* 0xaa +* 0xbb Ƿѹ +*/ +UINT8 CheckPointVoltageState(UINT8 pointType); + + + +/* +* AϵԴ״̬ +* ˵ +* ֵ CI_SUCCESS δ +* CI_ERROR +*/ +UINT8 CheckRCIAPowerFaultState(void); + +/* +* BϵԴ״̬ +* ˵ +* ֵ CI_SUCCESS δ +* CI_ERROR +*/ +UINT8 CheckRCIBPowerFaultState(void); + + +/* +* AϵԴģ״̬ +* ˵ +* ֵ CI_SUCCESS δ +* CI_ERROR +*/ +UINT8 CheckRCIAPowerModeFaultState(void); + +/* +* BϵԴģ״̬ +* ˵ +* ֵ CI_SUCCESS δ +* CI_ERROR +*/ +UINT8 CheckRCIBPowerModeFaultState(void); + +/* +* ͨ豸(ͨ)״̬ +* ˵ +* ֵ CI_SUCCESS ͨ +* CI_ERROR ͨж +*/ +UINT8 CheckRCICommCCUDeviceStatue(void); + +/* +* ָͨŰͨ״̬ +* ˵UINT8 boardId ͨŰ忨ID +* UINT8 commState ͨ״̬ +* ֵ +* BY LC +*/ +void SetRCIandCCBoardCommStatus(UINT8 boardId, UINT8 commState); + +/* +* ȡָͨŰͨ״̬ +* ˵UINT8 boardId ͨŰ忨ID +* ֵ UINT8 commState ͨ״̬ +* BY LC +*/ +UINT8 GetRCIandCCBoardCommStatus(UINT8 boardId); + +/* +* ȡָͨŰͨſʼ +* ˵UINT8 boardId ͨŰ忨ID +* ֵ UINT8 commState ͨ״̬ +* BY LC +*/ +UINT32 GetRCIandCCBoardCommCyCNum(UINT8 boardId); + +#endif diff --git a/TSCP/src/APP/ciapp/DebugPrint/DebugPrint.c b/TSCP/src/APP/ciapp/DebugPrint/DebugPrint.c new file mode 100644 index 0000000..6598676 --- /dev/null +++ b/TSCP/src/APP/ciapp/DebugPrint/DebugPrint.c @@ -0,0 +1,81 @@ +/************************************************************************ +* +* ļ DebugPrint.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2020.02.05 +* з +* Դӡӿ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#include "DebugPrint.h" +#include "Convert.h" +static UINT8 printImmediatelyFlag = 1u; + +/********************************************* +*ܣӡӦõĵԴ֡Ϣ +*˵ +* UINT32 errorCode +* UINT8 devType豸 +* UINT16 devId豸id +* UINT8 isCycleǷڵ +*ֵ +*********************************************/ +void DebugPrintAppError(UINT32 errorCode,UINT32 devType,UINT32 devId,UINT8 isCycleCall) +{ + DebugPrintError(CI_APP,errorCode,devType,devId,isCycleCall); +} + + +/********************************************* +*ܣӡϢ +*˵ +* UINT8 errorSrcԴ +* UINT32 errorCode +* UINT8 devType豸 +* UINT16 devId豸id +*ֵ +*********************************************/ +void DebugPrintError(UINT8 errorSrc,UINT32 errorCode,UINT32 devType,UINT32 devId,UINT8 isCycleCall) +{ + char tmpInfoError[15]={0}; + UINT16 ii = 0u; + UINT32 curCount = Get2oo2CurCycleNum(); + tmpInfoError[0] = (char)0xabU; + tmpInfoError[1] = (char)0xcdU; /*֡ʼ0xabcd*/ + tmpInfoError[2] = (char)errorSrc; /*Դ*/ + LongToChar(errorCode,&tmpInfoError[3]);/**/ + LongToChar(devType,&tmpInfoError[7]); /*豸*/ + LongToChar(devId,&tmpInfoError[11]); /*豸Id*/ + if (PRINT_CYCLE == isCycleCall) + { + if (curCount % 20U == 0u)/*ڵã6Ӵӡһ*/ + { + (void)debug_out_array(0xAA, tmpInfoError, 15); + + } + else + { + if (1u == printImmediatelyFlag) + { + (void)debug_out_array(0xAA, tmpInfoError, 15);/*ȷһδӡʱΪǴӡڣҲҪӡһ*/ + } + + if (1u ==printImmediatelyFlag) + { + printImmediatelyFlag = 0u; + } + + } + } + else + { + (void)debug_out_array(0xAA, tmpInfoError, 15); + } + +} + + diff --git a/TSCP/src/APP/ciapp/DebugPrint/DebugPrint.h b/TSCP/src/APP/ciapp/DebugPrint/DebugPrint.h new file mode 100644 index 0000000..2edbfdf --- /dev/null +++ b/TSCP/src/APP/ciapp/DebugPrint/DebugPrint.h @@ -0,0 +1,55 @@ +#ifndef DUBUG_PRINT +#define DUBUG_PRINT + + +#include "commontypes.h" +#include "../2oo2/2oo2InterfaceDataManage.h" + + + +#define CI_APP ((UINT8)1) /*Ӧ*/ +#define CI_PU ((UINT8)2) /*ƽ̨*/ +#define CI_CC ((UINT8)3) /*ͨ*/ + + +#define PRINT_CYCLE ((UINT8)1) +#define PRINT_ONCE ((UINT8)0) + + + + +/********************************************* +*ܣӡӦõĵԴ֡Ϣ +*˵ +* UINT32 errorCode +* UINT8 devType豸 +* UINT16 devId豸id +* UINT8 isCycleCallǷڴӡ +*ֵ0ʧܣ1ɹ +*********************************************/ +void DebugPrintAppError(UINT32 errorCode,UINT32 devType,UINT32 devId,UINT8 isCycleCall); + + +/********************************************* +*ܣӡϢ +*˵ +* UINT8 errorSrcԴ +* UINT32 errorCode +* UINT8 devType豸 +* UINT16 devId豸id +* UINT8 isCycleǷڴӡ +*ֵ0ʧܣ1ɹ +*********************************************/ +void DebugPrintError(UINT8 errorSrc,UINT32 errorCode,UINT32 devType,UINT32 devId,UINT8 isCycleCall); + + + + + + + + + + + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/DebugPrint/DebugPrintInterface.h b/TSCP/src/APP/ciapp/DebugPrint/DebugPrintInterface.h new file mode 100644 index 0000000..6785ab4 --- /dev/null +++ b/TSCP/src/APP/ciapp/DebugPrint/DebugPrintInterface.h @@ -0,0 +1,13 @@ +#ifndef DEBUG_PRINT_INTERFACE_H +#define DEBUG_PRINT_INTERFACE_H + + +#include "DebugPrint.h" +#include "ErrorCode.h" +#include "ErrorDeviceType.h" + + + + + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/DebugPrint/ErrorCode.h b/TSCP/src/APP/ciapp/DebugPrint/ErrorCode.h new file mode 100644 index 0000000..5eb2993 --- /dev/null +++ b/TSCP/src/APP/ciapp/DebugPrint/ErrorCode.h @@ -0,0 +1,45 @@ +#ifndef DUBUG_ERROR_CODE +#define DUBUG_ERROR_CODE + + +#define ERROR_fs_columns_len_not_equal_to_ci_software ((UINT32)0x00000001) /*FSгCIжIJһ*/ +#define ERROR_INDEX_EXCEED ((UINT32)0x00000002) /**/ +#define ERROR_RTNROUTE_RTNSIG_NOCONFIG ((UINT32)0x00000003) /*۷·۷źŻû*/ +#define ERROR_RTNROUTE_RTNSIG_INVALID ((UINT32)0x00000004) /*۷·۷źŻIDЧ*/ + +#define ERROR_SIGNAL_LXJ_NOT_CONFIG ((UINT32)0x00000005) /*źŻгźż̵û*/ +#define ERROR_SIGNAL_YDJ_NOT_CONFIG ((UINT32)0x00000006) /*źŻźż̵û*/ +#define ERROR_SIGNAL_1DJ_NOT_CONFIG ((UINT32)0x00000007) /*źŻ1˿̵û*/ +#define ERROR_SIGNAL_2DJ_NOT_CONFIG ((UINT32)0x00000008) /*źŻ2˿̵û*/ +#define ERROR_SIGNAL_ZXJ_NOT_CONFIG ((UINT32)0x00000009) /*źŻźż̵û*/ +#define ERROR_SIGNAL_DXJ_NOT_CONFIG ((UINT32)0x0000000a) /*źŻźż̵û*/ +#define ERROR_SIGNAL_DDJ_NOT_CONFIG ((UINT32)0x0000000b) /*źŻƼ̵û*/ + +#define ERROR_SIGNAL_GREENJ_NOT_CONFIG ((UINT32)0x0000000C) /*źŻ̵Ƽ̵û*/ +#define ERROR_SIGNAL_YELLOWJ_NOT_CONFIG ((UINT32)0x0000000D) /*źŻƵƼ̵û*/ +#define ERROR_SIGNAL_BLUEJ_NOT_CONFIG ((UINT32)0x0000000E) /*źŻƼ̵û*/ + +#define ERROR_SIGNAL_YXJ_NOT_DOUBLE_COLL ((UINT32)0x0000000f) /*źŻźż̵Ϊ˫ڵɼ*/ +#define ERROR_SIGNAL_DXJ_NOT_DOUBLE_COLL ((UINT32)0x00000010) /*źŻźż̵Ϊ˫ڵɼ*/ +#define ERROR_SIGNAL_YELLOWJ_NOT_DOUBLE_COLL ((UINT32)0x00000011) /*źŻƵƵ˿̵Ϊ˫ڵɼ*/ +#define ERROR_SIGNAL_GREENJ_NOT_DOUBLE_COLL ((UINT32)0x00000012) /*źŻ̵Ƶ˿̵Ϊ˫ڵɼ*/ + +#define ERROR_SWITCH_DBJ_NOT_CONFIG ((UINT32)0x00000013) /*̵û*/ +#define ERROR_SWITCH_FBJ_NOT_CONFIG ((UINT32)0x00000014) /*̵û*/ +#define ERROR_SWITCH_YCJ_NOT_CONFIG ((UINT32)0x00000015) /*ʲټ̵û*/ +#define ERROR_SWITCH_DCJ_NOT_CONFIG ((UINT32)0x00000016) /*ټ̵û*/ +#define ERROR_SWITCH_FCJ_NOT_CONFIG ((UINT32)0x00000017) /*ټ̵û*/ + +#define ERROR_SPKS_COLLJ_NOT_CONFIG ((UINT32)0x00000018) /*SPKSɼ̵û*/ +#define ERROR_SPKS_COLLJ_NOT_DOUBLE_COLL ((UINT32)0x00000019) /*SPKSɼ̵Ϊ˫ڵɼ*/ + +#define ERROR_PHYSEC_GJ_NOT_CONFIG ((UINT32)0x0000001A) /*ι̵û*/ +#define ERROR_PHYSEC_GJ_NOT_DOUBLE_COLL ((UINT32)0x0000001B) /*ι̵Ϊ˫ڵɼ*/ + + +#define ERROR_ROUTE_OVERLAP_CIZCMASK_NOT_CONFIG ((UINT32)0x0000001C) /*·ıCI-ZCλû*/ +#define ERROR_ONEROUTE_OVERLAP_CIZCMASK_NOT_SAME ((UINT32)0x0000001D) /*ͬһ·εCI-ZCλһ*/ + + + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/DebugPrint/ErrorDeviceType.h b/TSCP/src/APP/ciapp/DebugPrint/ErrorDeviceType.h new file mode 100644 index 0000000..9682e86 --- /dev/null +++ b/TSCP/src/APP/ciapp/DebugPrint/ErrorDeviceType.h @@ -0,0 +1,17 @@ +#ifndef ERROR_DEVICE_TYPE +#define ERROR_DEVICE_TYPE + +/* +* +* ע⣺ɸCiSystemDefine.hе豸 +* 0x0100ʼ +* +*/ + +#define CI_DEVICE_TYPE_FS_TABLE ((UINT32)0x00000100)/*fs*/ + + + + + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Deployment/Deployment.c b/TSCP/src/APP/ciapp/Deployment/Deployment.c new file mode 100644 index 0000000..af96292 --- /dev/null +++ b/TSCP/src/APP/ciapp/Deployment/Deployment.c @@ -0,0 +1,959 @@ + +#include "Deployment.h" +#include + +const static UINT32 gCrcTable[256] = +{ + 0x00000000U,0x04c11db7U,0x09823b6eU,0x0d4326d9U,0x130476dcU,0x17c56b6bU, + 0x1a864db2U,0x1e475005U,0x2608edb8U,0x22c9f00fU,0x2f8ad6d6U,0x2b4bcb61U, + 0x350c9b64U,0x31cd86d3U,0x3c8ea00aU,0x384fbdbdU,0x4c11db70U,0x48d0c6c7U, + 0x4593e01eU,0x4152fda9U,0x5f15adacU,0x5bd4b01bU,0x569796c2U,0x52568b75U, + 0x6a1936c8U,0x6ed82b7fU,0x639b0da6U,0x675a1011U,0x791d4014U,0x7ddc5da3U, + 0x709f7b7aU,0x745e66cdU,0x9823b6e0U,0x9ce2ab57U,0x91a18d8eU,0x95609039U, + 0x8b27c03cU,0x8fe6dd8bU,0x82a5fb52U,0x8664e6e5U,0xbe2b5b58U,0xbaea46efU, + 0xb7a96036U,0xb3687d81U,0xad2f2d84U,0xa9ee3033U,0xa4ad16eaU,0xa06c0b5dU, + 0xd4326d90U,0xd0f37027U,0xddb056feU,0xd9714b49U,0xc7361b4cU,0xc3f706fbU, + 0xceb42022U,0xca753d95U,0xf23a8028U,0xf6fb9d9fU,0xfbb8bb46U,0xff79a6f1U, + 0xe13ef6f4U,0xe5ffeb43U,0xe8bccd9aU,0xec7dd02dU,0x34867077U,0x30476dc0U, + 0x3d044b19U,0x39c556aeU,0x278206abU,0x23431b1cU,0x2e003dc5U,0x2ac12072U, + 0x128e9dcfU,0x164f8078U,0x1b0ca6a1U,0x1fcdbb16U,0x018aeb13U,0x054bf6a4U, + 0x0808d07dU,0x0cc9cdcaU,0x7897ab07U,0x7c56b6b0U,0x71159069U,0x75d48ddeU, + 0x6b93dddbU,0x6f52c06cU,0x6211e6b5U,0x66d0fb02U,0x5e9f46bfU,0x5a5e5b08U, + 0x571d7dd1U,0x53dc6066U,0x4d9b3063U,0x495a2dd4U,0x44190b0dU,0x40d816baU, + 0xaca5c697U,0xa864db20U,0xa527fdf9U,0xa1e6e04eU,0xbfa1b04bU,0xbb60adfcU, + 0xb6238b25U,0xb2e29692U,0x8aad2b2fU,0x8e6c3698U,0x832f1041U,0x87ee0df6U, + 0x99a95df3U,0x9d684044U,0x902b669dU,0x94ea7b2aU,0xe0b41de7U,0xe4750050U, + 0xe9362689U,0xedf73b3eU,0xf3b06b3bU,0xf771768cU,0xfa325055U,0xfef34de2U, + 0xc6bcf05fU,0xc27dede8U,0xcf3ecb31U,0xcbffd686U,0xd5b88683U,0xd1799b34U, + 0xdc3abdedU,0xd8fba05aU,0x690ce0eeU,0x6dcdfd59U,0x608edb80U,0x644fc637U, + 0x7a089632U,0x7ec98b85U,0x738aad5cU,0x774bb0ebU,0x4f040d56U,0x4bc510e1U, + 0x46863638U,0x42472b8fU,0x5c007b8aU,0x58c1663dU,0x558240e4U,0x51435d53U, + 0x251d3b9eU,0x21dc2629U,0x2c9f00f0U,0x285e1d47U,0x36194d42U,0x32d850f5U, + 0x3f9b762cU,0x3b5a6b9bU,0x0315d626U,0x07d4cb91U,0x0a97ed48U,0x0e56f0ffU, + 0x1011a0faU,0x14d0bd4dU,0x19939b94U,0x1d528623U,0xf12f560eU,0xf5ee4bb9U, + 0xf8ad6d60U,0xfc6c70d7U,0xe22b20d2U,0xe6ea3d65U,0xeba91bbcU,0xef68060bU, + 0xd727bbb6U,0xd3e6a601U,0xdea580d8U,0xda649d6fU,0xc423cd6aU,0xc0e2d0ddU, + 0xcda1f604U,0xc960ebb3U,0xbd3e8d7eU,0xb9ff90c9U,0xb4bcb610U,0xb07daba7U, + 0xae3afba2U,0xaafbe615U,0xa7b8c0ccU,0xa379dd7bU,0x9b3660c6U,0x9ff77d71U, + 0x92b45ba8U,0x9675461fU,0x8832161aU,0x8cf30badU,0x81b02d74U,0x857130c3U, + 0x5d8a9099U,0x594b8d2eU,0x5408abf7U,0x50c9b640U,0x4e8ee645U,0x4a4ffbf2U, + 0x470cdd2bU,0x43cdc09cU,0x7b827d21U,0x7f436096U,0x7200464fU,0x76c15bf8U, + 0x68860bfdU,0x6c47164aU,0x61043093U,0x65c52d24U,0x119b4be9U,0x155a565eU, + 0x18197087U,0x1cd86d30U,0x029f3d35U,0x065e2082U,0x0b1d065bU,0x0fdc1becU, + 0x3793a651U,0x3352bbe6U,0x3e119d3fU,0x3ad08088U,0x2497d08dU,0x2056cd3aU, + 0x2d15ebe3U,0x29d4f654U,0xc5a92679U,0xc1683bceU,0xcc2b1d17U,0xc8ea00a0U, + 0xd6ad50a5U,0xd26c4d12U,0xdf2f6bcbU,0xdbee767cU,0xe3a1cbc1U,0xe760d676U, + 0xea23f0afU,0xeee2ed18U,0xf0a5bd1dU,0xf464a0aaU,0xf9278673U,0xfde69bc4U, + 0x89b8fd09U,0x8d79e0beU,0x803ac667U,0x84fbdbd0U,0x9abc8bd5U,0x9e7d9662U, + 0x933eb0bbU,0x97ffad0cU,0xafb010b1U,0xab710d06U,0xa6322bdfU,0xa2f33668U, + 0xbcb4666dU,0xb8757bdaU,0xb5365d03U,0xb1f740b4U +}; +/** ̬ȫֱ-- */ +static EXIT_OP_STRUCT gExitOpInfo = {0u}; + +/** ̬ȫֱ-- */ +static EXIT_OP_FIRST_REQ_STRUCT gFirstFReqInfo = {0u}; +static EXIT_OP_SEC_REQ_STRUCT gSecondReqInfo = {0u}; + + +static void ParseExitOpFirstRequst(const UINT8* dataBuf, UINT32 startIndex); /* ״˳Ӫ */ +static void ParseExitOpSecondRequst(const UINT8* dataBuf, UINT32 startIndex); /* ٴ˳Ӫ */ +static UINT16 PackExitOpFirstReply(UINT8* dataBuf,UINT16 maxLen); /** ״˳Ӫȷ */ +static UINT16 PackExitOpSecondReply(UINT8* dataBuf,UINT16 maxLen); /** ٴ˳Ӫȷ */ +static void ResetInitParam(void); /** ò*/ +static UINT32 CRC32_AIM(UINT8 *pData, UINT16 wDataLen); /** AIM ʹõCRC32㺯 */ +static void AIMPrinf(UINT8 Level,const char* lpszFormat, ...); /* Դӡ */ +static UINT8 Deploy_FirstReqHandle(void); /*״˳Ӫ*/ +static UINT8 Deploy_SecondReqHandle(void); /*ٴ˳Ӫ*/ +static UINT8 Deploy_CheckBoardID(UINT8 boardID_in);/*忨ID뱾ذ忨IDһxԼ*/ + /** + * @brief AIM ʹõCRC32㺯 + * @param[in] const UINT8* dataBuf,뱨ʼַ + * @param[in] UINT16 wDataLen, + * @param[out] + * @return UINT32 CRCֵ + * @note + */ +static UINT32 CRC32_AIM(UINT8 *pData, UINT16 wDataLen) +{ + UINT32 dwCrc = 0; + UINT16 wCycle = 0; + + /*ѭCRC32*/ + for(wCycle = (UINT8)0; wCycle < wDataLen; wCycle++) + { + dwCrc = (dwCrc << 8) ^ gCrcTable[ (dwCrc >> 24) ^ pData[wCycle] ] ; + } + + /*ؼ*/ + return dwCrc; +} + + +/** + * @brief Դӡ + * @param[in] const UINT8* dataBuf,뱨ʼַ + * @param[in] UINT16 wDataLen, + * @param[out] + * @return UINT32 CRCֵ + * @note + */ +static void AIMPrinf(UINT8 Level, const char* lpszFormat, ...) +{ + va_list para; + static CHAR tmpPrintBuf[65535u] = { '\0' }; + + (void)CommonMemSet(tmpPrintBuf, 65535u, 0u, 65535u); + if ((Level < AIM_LOG_LEVEL) && (NULL != gExitOpInfo.pfun)) + { + va_start(para, lpszFormat); + (void)vsnprintf(tmpPrintBuf, 65535u, lpszFormat, para); + va_end(para); + + gExitOpInfo.pfun("%s", tmpPrintBuf); + } +} + + /** + * @brief ״˳Ӫ + * @param[in] const UINT8* dataBuf,뱨ʼַ + * @param[in] UINT32 startIndex,ʼַ + * @param[out] + * @return + * @note + */ + static void ParseExitOpFirstRequst(const UINT8* dataBuf, UINT32 startIndex) + { + UINT32 errorcode = 0u; + UINT32 msgstartIndex = startIndex; + UINT32 exitOpCmdIndex = 0u; + UINT32 index = startIndex; + UINT32 tempCrc32 = 0u; + UINT8 checkBoardid = 0u; + + if (NULL == dataBuf) + { + errorcode += 0x80000000u; + } + else + { + /** ֡ */ + index += 1u; + exitOpCmdIndex = index; /* Ϣʼַ */ + + /** 忨 */ + gFirstFReqInfo.boardType = dataBuf[index]; + index += 1u; + + /** 忨ID */ + gFirstFReqInfo.chanelID = dataBuf[index]; + index += 1u; + + /** ʱ */ + gFirstFReqInfo.firstRequstTime = LongFromChar(&dataBuf[index]); + index += 4u; + + /** ˳Ӫ */ + gFirstFReqInfo.exitOpCmd = dataBuf[index]; + index += 1u; + + checkBoardid = Deploy_CheckBoardID(gFirstFReqInfo.chanelID); + if ((0x01u != gFirstFReqInfo.boardType) || (0x55U != checkBoardid)) + { + errorcode += 0x01000000u; + } + else + { + if (0xaau == gFirstFReqInfo.exitOpCmd) + { + /** ˳ӪCRC */ + gFirstFReqInfo.exitOpCmdCrc = LongFromChar(&dataBuf[index]); + index += 4u; + + /** ˳ӪCRC */ + tempCrc32 = CRC32_AIM(&dataBuf[exitOpCmdIndex], (UINT16)(index - 4u - exitOpCmdIndex)); + + if (tempCrc32 == gFirstFReqInfo.exitOpCmdCrc) + { + /** */ + } + else + { + gExitOpInfo.opReason = FORBID_EXIT_OP_REASON_1; + AIMPrinf(AIM_LOG_FATAL, "opFirstCRC error: recv:%x, calc:%x,\n", gFirstFReqInfo.exitOpCmdCrc, tempCrc32); + } + + /** Ϣ֡CRC */ + gFirstFReqInfo.msgCrc = LongFromChar(&dataBuf[index]); + index += 4u; + + /** Ϣ֡CRC */ + tempCrc32 = CRC32_AIM(&dataBuf[msgstartIndex], (UINT16)(index - 4u - msgstartIndex)); + + if (tempCrc32 == gFirstFReqInfo.msgCrc) + { + /** */ + } + else + { + gExitOpInfo.opReason = FORBID_EXIT_OP_REASON_1; + AIMPrinf(AIM_LOG_FATAL, "msgFirstCRC error: recv:%x, calc:%x.\n", gFirstFReqInfo.msgCrc, tempCrc32); + } + + gFirstFReqInfo.refreshFlag = MSG_REFRESH; + } + else + { + errorcode += 0x40000000u; + } + } + } + + if (0u == errorcode) + { + /** ȷ账,˴Ҫôӡӡ*/ + } + else + { + (void)CommonMemSet(&gFirstFReqInfo, (UINT32)sizeof(EXIT_OP_FIRST_REQ_STRUCT),0u, (UINT32)sizeof(EXIT_OP_FIRST_REQ_STRUCT)); + } + } + + + /** + * @brief ٴ˳Ӫ + * @param[in] const UINT8* dataBuf,뱨ʼַ + * @param[in] UINT32 startIndex,ʼַ + * @param[out] + * @return + * @note + */ + static void ParseExitOpSecondRequst(const UINT8* dataBuf, UINT32 startIndex) + { + UINT32 errorcode = 0u; + UINT32 msgstartIndex = startIndex; + UINT32 exitOpCmdIndex = 0u; + UINT32 index = startIndex; + UINT32 tempCrc32 = 0u; + UINT8 checkBoardid = 0u; + + if (NULL == dataBuf) + { + errorcode += 0x80000000u; + } + else + { + /** ֡ */ + index += 1u; + exitOpCmdIndex = index; /* Ϣʼַ */ + + /** 忨 */ + gSecondReqInfo.boardType = dataBuf[index]; + index += 1u; + + /** 忨ID */ + gSecondReqInfo.chanelID = dataBuf[index]; + index += 1u; + + /** ʱ */ + gSecondReqInfo.secondRequstTime = LongFromChar(&dataBuf[index]); + index += 4u; + + /** ״ȷϢеʱ */ + gSecondReqInfo.firstReplyTime = LongFromChar(&dataBuf[index]); + index += 4u; + + /** ˳Ӫ */ + gSecondReqInfo.exitOpCmd = dataBuf[index]; + index += 1u; + + checkBoardid = Deploy_CheckBoardID(gSecondReqInfo.chanelID); + if ((0x01u != gSecondReqInfo.boardType) || (0x55U != checkBoardid)) + { + errorcode += 0x01000000u; + } + else + { + if (0xaau == gSecondReqInfo.exitOpCmd) + { + /** ˳ӪCRC */ + gSecondReqInfo.exitOpCmdCrc = LongFromChar(&dataBuf[index]); + index += 4u; + + /** ˳ӪCRC */ + tempCrc32 = CRC32_AIM(&dataBuf[exitOpCmdIndex], (UINT16)(index - 4u - exitOpCmdIndex)); + + if (tempCrc32 == gSecondReqInfo.exitOpCmdCrc) + { + /** */ + } + else + { + gExitOpInfo.opReason = FORBID_EXIT_OP_REASON_1; + AIMPrinf(AIM_LOG_FATAL, "opSecCRC error: recv:%x, calc:%x,\n", gSecondReqInfo.exitOpCmdCrc, tempCrc32); + } + + /** Ϣ֡CRC */ + gSecondReqInfo.msgCrc = LongFromChar(&dataBuf[index]); + index += 4u; + + /** Ϣ֡CRC */ + tempCrc32 = CRC32_AIM(&dataBuf[msgstartIndex], (UINT16)(index - 4u - msgstartIndex)); + + if (tempCrc32 == gSecondReqInfo.msgCrc) + { + /** */ + } + else + { + gExitOpInfo.opReason = FORBID_EXIT_OP_REASON_1; + AIMPrinf(AIM_LOG_FATAL, "msgSecCRC error: recv:%x, calc:%x.\n", gSecondReqInfo.msgCrc, tempCrc32); + } + + gSecondReqInfo.refreshFlag = MSG_REFRESH; + } + else + { + errorcode += 0x40000000u; + } + } + } + + if (0u == errorcode) + { + /** ȷ账,˴Ҫôӡӡ*/ + } + else + { + (void)CommonMemSet(&gFirstFReqInfo, (UINT32)sizeof(EXIT_OP_FIRST_REQ_STRUCT),0u, (UINT32)sizeof(EXIT_OP_FIRST_REQ_STRUCT)); + (void)CommonMemSet(&gSecondReqInfo, (UINT32)sizeof(EXIT_OP_SEC_REQ_STRUCT), 0u, (UINT32)sizeof(EXIT_OP_SEC_REQ_STRUCT)); + } + } + + /** + * @brief ״˳Ӫȷ + * @param[in] UINT8* dataBuf, ͱʼַ + * @param[in] UINT16 maxLen, ͱ󳤶 + * @param[out] + * @return 0 ʧܣ0 ɹ + * @note + */ + static UINT16 PackExitOpFirstReply(UINT8* dataBuf,UINT16 maxLen) + { + UINT16 ret = 0u; + UINT8 tmpBuff[500u] = {0u}; /** ȱ֤˻ռ㹻*/ + UINT16 index = 0u; + UINT32 tempCrc32 = 0u; + + if (NULL == dataBuf) + { + /** ڲ */ + } + else + { + /** Ԥֽڳ */ + index += 2u; + + /** ֡ */ + tmpBuff[index] = EXIT_OP_FIRST_REPLY; + index += 1u; + + /** 忨 */ + tmpBuff[index] = gExitOpInfo.boardType; + index += 1u; + + /** 忨id */ + tmpBuff[index] = gExitOpInfo.chanelID; + index += 1u; + + /** ʱ */ + (void)LongToChar(gExitOpInfo.ReplytTime,&tmpBuff[index]); + index += 4u; + + /** ״Ϣеʱ */ + (void)LongToChar(gExitOpInfo.recvLastRequestTimestamp,&tmpBuff[index]); + index += 4u; + + /** Ȩ״̬ */ + tmpBuff[index] = gExitOpInfo.opStatus; + index += 1u; + + /** Ȩʧԭ */ + tmpBuff[index] = gExitOpInfo.opReason; + index += 1u; + + /** ˳ӪȷCRC */ + tempCrc32 = CRC32_AIM(&tmpBuff[3u], index - 3u); + (void)LongToChar(tempCrc32,&tmpBuff[index]); + index += 4u; + + /** Ϣ֡CRC */ + tempCrc32 = CRC32_AIM(&tmpBuff[2u], index - 2u); + (void)LongToChar(tempCrc32,&tmpBuff[index]); + index += 4u; + + /** дϢ */ + (void)ShortToChar(index - 2u,&tmpBuff[0u]); + + if (index <= maxLen) + { + ret = index; + (void)CommonMemCpy(dataBuf,maxLen,tmpBuff,index); + } + else + { + /** */ + } + } + return ret; + } + + /** + * @brief ٴ˳Ӫȷ + * @param[in] UINT8* dataBuf, ͱʼַ + * @param[in] UINT16 maxLen, ͱ󳤶 + * @param[out] + * @return 0 ʧܣ0 ɹ + * @note + */ + static UINT16 PackExitOpSecondReply(UINT8* dataBuf,UINT16 maxLen) + { + UINT16 ret = 0u; + UINT8 tmpBuff[500u] = {0u}; /** ȱ֤˻ռ㹻*/ + UINT16 index = 0u; + UINT32 tempCrc32 = 0u; + + if (NULL == dataBuf) + { + /** ڲ */ + } + else + { + /** Ԥֽڳ */ + index += 2u; + + /** ֡ */ + tmpBuff[index] = EXIT_OP_SECOND_REPLY; + index += 1u; + + /** 忨 */ + tmpBuff[index] = gExitOpInfo.boardType; + index += 1u; + + /** 忨id */ + tmpBuff[index] = gExitOpInfo.chanelID; + index += 1u; + + /** ʱ */ + (void)LongToChar(gExitOpInfo.ReplytTime,&tmpBuff[index]); + index += 4u; + + /** ٴϢеʱ */ + (void)LongToChar(gExitOpInfo.recvLastRequestTimestamp,&tmpBuff[index]); + index += 4u; + + /** Ȩ״̬ */ + tmpBuff[index] = gExitOpInfo.opStatus; + index += 1u; + + /** Ȩʧԭ */ + tmpBuff[index] = gExitOpInfo.opReason; + index += 1u; + + /** ˳ӪȷCRC */ + tempCrc32 = CRC32_AIM(&tmpBuff[3u], index - 3u); + (void)LongToChar(tempCrc32,&tmpBuff[index]); + index += 4u; + + /** Ϣ֡CRC */ + tempCrc32 = CRC32_AIM(&tmpBuff[2u], index - 2u); + (void)LongToChar(tempCrc32,&tmpBuff[index]); + index += 4u; + + /** дϢ */ + (void)ShortToChar(index - 2u,&tmpBuff[0u]); + + if (index <= maxLen) + { + ret = index; + (void)CommonMemCpy(dataBuf,maxLen,tmpBuff,index); + } + else + { + /** */ + } + } + return ret; + } + + /** + * @brief ò + * @param[in] + * @param[out] + * @return + * @note + */ + static void ResetInitParam(void) + { + gExitOpInfo.inputMsgType = EXIT_OP_DEFAULT; + gExitOpInfo.outputMsgType = EXIT_OP_DEFAULT; + + gExitOpInfo.boardType = 0u; + gExitOpInfo.chanelID = 0u; + + gExitOpInfo.recvLastRequestTimestamp = 0u; + gExitOpInfo.ReplytTime = 0u; + + gExitOpInfo.curTimeout = 0u; + + gExitOpInfo.opStatus = FORBID_EXIT_OP_STATUS; + gExitOpInfo.opReason = FORBID_EXIT_OP_REASON_0; + } + +/** =============================================ӿش=============================== */ + +/** + * @brief ˳Ӫģʼ + * @param[in] UINT16 cycleTime ǰϵͳ + * @param[in] const p_DPrintf pfun ӡӿ + * @param[out] + * @return + * @note + */ + extern void Deploy_Init(UINT16 cycleTime,const p_DPrintf pfun) + { +/*˳Ӫ*/ + + gExitOpInfo.inputMsgType = EXIT_OP_DEFAULT; + gExitOpInfo.outputMsgType = EXIT_OP_DEFAULT; + + gExitOpInfo.boardType = 0u; + gExitOpInfo.chanelID = 0u; + + gExitOpInfo.recvLastRequestTimestamp = 0u; + gExitOpInfo.ReplytTime = 0u; + + if (0u != cycleTime) + { + gExitOpInfo.maxTimeout = (UINT16)(EXIT_OP_TIMEOUT / cycleTime); + } + else + { + gExitOpInfo.maxTimeout = 0u; + } + + gExitOpInfo.curTimeout = 0u; + gExitOpInfo.innerTime = 0u; + gExitOpInfo.exitOperateStatus = STAY_OP_STATUS; + + gExitOpInfo.opStatus = FORBID_EXIT_OP_STATUS; + gExitOpInfo.opReason = FORBID_EXIT_OP_REASON_0; + + /*ӡɾ*/ + if (NULL == pfun) + { + gExitOpInfo.pfun = NULL; + } + else + { + gExitOpInfo.pfun = pfun; + } + } + + /** + * @brief + * @param[in] const UINT8* dataBuf,뱨ʼַ + * @param[in] UINT16 dataLength,뱨ij + * @param[in] UINT8 srcType, + * @param[in] UINT8 srcId,ID + * @param[out] + * @return 0,ʧ + 1ɹ + * @note ϢΪȥЭЭͷ + */ +extern UINT8 Deploy_ParseAIMInputInfo(const UINT8* dataBuf, UINT16 dataLength, UINT8 srcType,UINT8 srcId) +{ + UINT8 ret = 0u; + UINT32 msgLen = 0; + UINT16 msgIndex = 0u; + UINT16 srcDev = 0u; + UINT32 checkCrc = 0u; + UINT8 msgType = EXIT_OP_DEFAULT; + + srcDev += srcType; + srcDev = (UINT16)(srcDev << 8u) + srcId; + + if ((NULL == dataBuf) || (DEVICE_TYPE_AIM != srcDev)) + { + /** ڲ*/ + } + else + { + /** ȡϢ*/ + msgLen = (UINT32)ShortFromChar(dataBuf); + msgIndex += 2u; + + if ((2u < dataLength) && ((msgLen + 2U) == dataLength)) + { + msgType = dataBuf[msgIndex]; + AIMPrinf(AIM_LOG_FATAL, "msgType:%x,\n", msgType); + + switch (msgType) + { + case EXIT_OP_FIRST_REQUEST: + AIMPrinf(AIM_LOG_FATAL, "ParseExitOpFirstRequst,\n"); + ParseExitOpFirstRequst(&dataBuf[msgIndex],0u); + ret = 1u; + break; + case EXIT_OP_SECOND_REQUEST: + AIMPrinf(AIM_LOG_FATAL, "ParseExitOpSecondRequst,\n"); + ParseExitOpSecondRequst(&dataBuf[msgIndex],0u); + ret = 1u; + break; + default: + ; /*ʹ󲻴*/ + break; + } + } + else + { + /** Ȳ */ + } + } + return ret; +} + + +/** +* @brief ״˳Ӫ +* @param[in] +* @param[out] +* @return +* @note +*/ +static UINT8 Deploy_FirstReqHandle(void) +{ + UINT8 rtn = 0u; + + if (((EXIT_OP_DEFAULT == gExitOpInfo.inputMsgType) || (EXIT_OP_FIRST_REQUEST == gExitOpInfo.inputMsgType)) + && (gExitOpInfo.recvLastRequestTimestamp != gFirstFReqInfo.firstRequstTime)) + { + gExitOpInfo.inputMsgType = EXIT_OP_FIRST_REQUEST; + gExitOpInfo.outputMsgType = EXIT_OP_FIRST_REPLY; + gExitOpInfo.boardType = gFirstFReqInfo.boardType; + gExitOpInfo.chanelID = gFirstFReqInfo.chanelID; + gExitOpInfo.ReplytTime = gExitOpInfo.innerTime; + gExitOpInfo.recvLastRequestTimestamp = gFirstFReqInfo.firstRequstTime; + AIMPrinf(AIM_LOG_FATAL, "fisrt_opReason: %d,\n", gExitOpInfo.opReason); + if (FORBID_EXIT_OP_REASON_0 == gExitOpInfo.opReason) + { + gExitOpInfo.opStatus = PERMIT_EXIT_OP_STATUS; + } + else + { + gExitOpInfo.opStatus = FORBID_EXIT_OP_STATUS; + } + + if (PERMIT_EXIT_OP_STATUS == gExitOpInfo.opStatus) + { + /** ʱ */ + gExitOpInfo.curTimeout = 0u; + } + else + { + /** ֹʱ,ڲò */ + gExitOpInfo.curTimeout = gExitOpInfo.maxTimeout; + } + } + else + { + /** ٴյ״߳ʱò*/ + rtn = 0xffu; + } + + return rtn; +} + +/** +* @brief ٴ˳Ӫ +* @param[in] +* @param[out] +* @return +* @note +*/ +static UINT8 Deploy_SecondReqHandle(void) +{ + UINT8 rtn = 0u; + + if ((EXIT_OP_FIRST_REQUEST == gExitOpInfo.inputMsgType) && + (MSG_REFRESH == gSecondReqInfo.refreshFlag) && + (PERMIT_EXIT_OP_STATUS == gExitOpInfo.opStatus)) + { + gExitOpInfo.inputMsgType = EXIT_OP_SECOND_REQUEST; + + if (FORBID_EXIT_OP_REASON_0 != gExitOpInfo.opReason) + { + gExitOpInfo.opStatus = FORBID_EXIT_OP_STATUS; + } + else + { + if ((gExitOpInfo.boardType == gSecondReqInfo.boardType) && + (gExitOpInfo.chanelID == gSecondReqInfo.chanelID)) + { + if (gExitOpInfo.ReplytTime == gSecondReqInfo.firstReplyTime) + { + gExitOpInfo.opStatus = PERMIT_EXIT_OP_STATUS; + gExitOpInfo.exitOperateStatus = EXIT_OP_STATUS; + } + else + { + gExitOpInfo.opStatus = FORBID_EXIT_OP_STATUS; + gExitOpInfo.opReason = FORBID_EXIT_OP_REASON_3; + } + } + else + { + gExitOpInfo.opStatus = FORBID_EXIT_OP_STATUS; + gExitOpInfo.opReason = FORBID_EXIT_OP_REASON_2; + } + } + + /** ʱ */ + gExitOpInfo.ReplytTime = gExitOpInfo.innerTime; + gExitOpInfo.recvLastRequestTimestamp = gSecondReqInfo.secondRequstTime; + + gExitOpInfo.outputMsgType = EXIT_OP_SECOND_REPLY; + + AIMPrinf(AIM_LOG_FATAL, "Sec_opReason: %d.\n", gExitOpInfo.opReason); + + /** ֹʱ,ڲò */ + gExitOpInfo.curTimeout = gExitOpInfo.maxTimeout; + } + else + { + /** յٴ߳ʱò**/ + gExitOpInfo.curTimeout = gExitOpInfo.maxTimeout; + rtn = 0xffu; + } + + return rtn; +} + + + +/** + * @brief ˳Ӫ + * @param[in] + * @param[out] + * @return + * @note + */ +extern void Deploy_ExitOperationHandle(void) + { + UINT8 needTimeOutProcess = 0u; + gExitOpInfo.innerTime++; + gExitOpInfo.outputMsgType = EXIT_OP_DEFAULT; + + + AIMPrinf(AIM_LOG_FATAL, "refreshFlag:%x-%x ,\n", gFirstFReqInfo.refreshFlag, gSecondReqInfo.refreshFlag); + + if (((MSG_REFRESH == gFirstFReqInfo.refreshFlag) && (MSG_REFRESH == gSecondReqInfo.refreshFlag)) || + ((MSG_NO_REFRESH == gFirstFReqInfo.refreshFlag) && (MSG_NO_REFRESH == gSecondReqInfo.refreshFlag))) + { + needTimeOutProcess = 0xffu; + } + else if (MSG_REFRESH == gFirstFReqInfo.refreshFlag) + { + needTimeOutProcess = Deploy_FirstReqHandle(); + } + else if (MSG_REFRESH == gSecondReqInfo.refreshFlag) + { + needTimeOutProcess = Deploy_SecondReqHandle(); + } + else + { + needTimeOutProcess = 0xffu; + } + + if (0xffU == needTimeOutProcess) + { + if (gExitOpInfo.curTimeout < gExitOpInfo.maxTimeout) + { + gExitOpInfo.curTimeout++; + } + else + { + /** δʱ߳ʱ */ + ResetInitParam(); + } + } + else + { + /** 账 */ + } + + /* ӡڴ洢 */ + AIMPrinf(AIM_LOG_FATAL, "AIM:Osta:%x,iType:%x,oType:%x,board:%d-%d,recvLastTime:%08x,rTime:%08x,timeout:%d-%d,innerTime:%d,Opsta:%x,opReason:%x,pfun:%x.\n", + gExitOpInfo.exitOperateStatus, gExitOpInfo.inputMsgType, gExitOpInfo.outputMsgType, gExitOpInfo.boardType, gExitOpInfo.chanelID, + gExitOpInfo.recvLastRequestTimestamp, gExitOpInfo.ReplytTime, gExitOpInfo.curTimeout, gExitOpInfo.maxTimeout, gExitOpInfo.innerTime, + gExitOpInfo.opStatus, gExitOpInfo.opReason, gExitOpInfo.pfun); + + /** Ϣ */ + (void)CommonMemSet(&gFirstFReqInfo, (UINT32)sizeof(EXIT_OP_FIRST_REQ_STRUCT),0u, (UINT32)sizeof(EXIT_OP_FIRST_REQ_STRUCT)); + (void)CommonMemSet(&gSecondReqInfo, (UINT32)sizeof(EXIT_OP_SEC_REQ_STRUCT),0u, (UINT32)sizeof(EXIT_OP_SEC_REQ_STRUCT)); + + } + + + +/** + * @brief + * @param[in] UINT16 maxLen,Ĵ洢ռ + * @param[out] UINT8* dataBuf,ʼַ + * @return 0 ʧܣ0 ɹ + * @note + */ +extern UINT16 Deploy_PackToAIMInfo(UINT8* dataBuf,UINT16 maxLen) + { + UINT16 ret = 0u; + + switch(gExitOpInfo.outputMsgType) + { + case EXIT_OP_FIRST_REPLY: + ret = PackExitOpFirstReply(dataBuf,maxLen); + break; + case EXIT_OP_SECOND_REPLY: + ret = PackExitOpSecondReply(dataBuf,maxLen); + break; + default: + /**/ + break; + } + + return ret; + } + + + /** + * @brief + * @param[out] UINT8 *pDataBuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ݵij + * @note + */ +extern UINT32 Deploy_GetTransferData(OUT UINT8 *pDataBuff,UINT32 curIndex) +{ + /*- ֲ */ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex; + + if (NULL == pDataBuff) + { + /** ڲ */ + } + else + { + /** ģʶ*/ + pDataBuff[copyIndex++] = (UINT8)'D'; + pDataBuff[copyIndex++] = (UINT8)'e'; + pDataBuff[copyIndex++] = (UINT8)'p'; + pDataBuff[copyIndex++] = (UINT8)'l'; + pDataBuff[copyIndex++] = (UINT8)'o'; + pDataBuff[copyIndex++] = (UINT8)'y'; + + pDataBuff[copyIndex++] = gExitOpInfo.exitOperateStatus; + + ret = copyIndex; + } + + return ret; +} + +/** + * @brief ø + * @param[in] const UINT8 *pDatabuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @param[in] UINT32 len ݵij + * @return ȡ + * @note + */ +extern UINT32 Deploy_SetTransferData(IN const UINT8 *pDatabuff,UINT32 curIndex) +{ + UINT32 ret = curIndex; + UINT32 setIndex = curIndex; + UINT8 modelFlag[6] = {0u}; + + if (NULL == pDatabuff) + { + /** ڲ */ + } + else + { + /** ģʶ */ + modelFlag[0] = pDatabuff[setIndex++]; + modelFlag[1] = pDatabuff[setIndex++]; + modelFlag[2] = pDatabuff[setIndex++]; + modelFlag[3] = pDatabuff[setIndex++]; + modelFlag[4] = pDatabuff[setIndex++]; + modelFlag[5] = pDatabuff[setIndex++]; + + if (((UINT8)'D' == modelFlag[0]) && ((UINT8)'e' == modelFlag[1]) && ((UINT8)'p' == modelFlag[2]) && + ((UINT8)'l' == modelFlag[3]) && ((UINT8)'o' == modelFlag[4]) && ((UINT8)'y' == modelFlag[5])) + { + gExitOpInfo.exitOperateStatus = pDatabuff[setIndex++]; + + ret = setIndex; + } + else + { + /** ݴ */ + } + } + + return ret; +} + + + /** + * @brief ȡ˳Ӫ״̬ + * @param[in] + * @param[out] + * @return EXIT_OP_STATUS ˳ӪSTAY_OP_STATUS Ӫ + * @note + */ +extern UINT8 Deploy_GetExitOperateStatus(void) +{ + return gExitOpInfo.exitOperateStatus; +} + + +/** +* @brief 忨ID뱾ذ忨IDһԼ +* @param[in] localboardID 忨ID +* @param[out] +* @return 0x55һЧ 0xaaЧȽϲһ +*/ +static UINT8 Deploy_CheckBoardID(UINT8 boardID_in) +{ + UINT8 retval = 0xaaU; + + UINT8 localBoardId = 0U; +#if (kPLATFORM==kVXWORKS) + localBoardId=MSCP_GetBoardID(); + if ((1U == localBoardId) && (0xA0U == boardID_in)) + { + /*忨Aϵ*/ + retval = 0x55; + } + else if ((2U == localBoardId) && (0x0BU == boardID_in)) + { + /*忨Bϵ*/ + retval = 0x55; + } + else + { + retval = 0xaa; + } +#endif + return retval; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Deployment/Deployment.h b/TSCP/src/APP/ciapp/Deployment/Deployment.h new file mode 100644 index 0000000..8e44ef3 --- /dev/null +++ b/TSCP/src/APP/ciapp/Deployment/Deployment.h @@ -0,0 +1,100 @@ + + +/****************************************************************************** +** ļ: Deployment.h +** : ģʵ +*******************************************************************************/ + +#ifndef DEPLOYMENT_H_ +#define DEPLOYMENT_H_ + +#include "DeploymentExtern.h" +#include "CommonCRC.h" +#include "Convert.h" +#include "CommonMemory.h" + +#define AIM_LOG_FATAL 0u /** ά־--ά */ +#define AIM_LOG_ERROR 1u /*ά־--󼶱*/ +#define AIM_LOG_WARING 2u /*ά־--漶*/ +#define AIM_LOG_DEBUG 3u /*ά־--Լ*/ +#define AIM_LOG_LEVEL AIM_LOG_DEBUG /*ά־--ǰ־*/ + + +#define EXIT_OP_DEFAULT 0X00u /* ϢĬֵ */ +#define EXIT_OP_FIRST_REQUEST 0XA1u /* ˳Ӫ״ */ +#define EXIT_OP_SECOND_REQUEST 0XA2u /* ˳Ӫٴ*/ +#define EXIT_OP_FIRST_REPLY 0X51u /* ˳Ӫ״ȷ */ +#define EXIT_OP_SECOND_REPLY 0X52u /* ˳Ӫٴȷ*/ + +#define EXIT_OP_TIMEOUT 120000u /* ˳Ӫʱʱ䣬λ */ + +#define MSG_NO_REFRESH 0x00u /* Ϣδ */ +#define MSG_REFRESH 0xffu /* ϢѸ */ + +#define PERMIT_EXIT_OP_STATUS 0x00u /** ˳Ӫ */ +#define FORBID_EXIT_OP_STATUS 0x01u /** ֹ˳Ӫ */ + +#define FORBID_EXIT_OP_REASON_0 0x00u /** Ĭֵ */ +#define FORBID_EXIT_OP_REASON_1 0x01u /** CRCУʧ */ +#define FORBID_EXIT_OP_REASON_2 0x02u /** ϢǷ忨ͨ͡ID״Ϣһ£ */ +#define FORBID_EXIT_OP_REASON_3 0x03u /** ٴظ״ȷʱһ */ + + +#ifdef WIN32 +#define DP_LOG_PRINT(fmt,...) printf(fmt,##__VA_ARGS__) +#else +#define DP_LOG_PRINT(fmt,...) printf(fmt,##__VA_ARGS__) +#endif + + +/** ˳Ӫؽṹ */ +typedef struct +{ + UINT8 inputMsgType; /* Ϣ */ + UINT8 outputMsgType; /* Ϣ */ + + UINT8 boardType; /* 忨 */ + UINT8 chanelID; /* ͨid */ + UINT32 recvLastRequestTimestamp; /* յʱ */ + UINT32 ReplytTime; /* ״ʱ */ + + UINT16 maxTimeout; /* ʱʱ */ + UINT16 curTimeout; /* ǰʱʱ */ + + UINT32 innerTime; /** ڲʱ */ + UINT8 exitOperateStatus; /* ˳Ӫ״̬ */ + + UINT8 opStatus; /** ȷϽ */ + UINT8 opReason; /** ԭ */ + + p_DPrintf pfun; /* ӡע */ +}EXIT_OP_STRUCT; + + +/* ˳Ӫ״ */ +typedef struct +{ + UINT8 refreshFlag; /* ڸ±־ */ + UINT8 boardType; /* 忨 */ + UINT8 chanelID; /* ͨid */ + UINT32 firstRequstTime; /* ״ʱ */ + UINT8 exitOpCmd; /* ˳Ӫ */ + UINT32 exitOpCmdCrc; /* ˳ӪCRC */ + UINT32 msgCrc; /* Ϣ֡CRC */ +}EXIT_OP_FIRST_REQ_STRUCT; + +/* ˳Ӫٴ */ +typedef struct +{ + UINT8 refreshFlag; /* ڸ±־ */ + UINT8 boardType; /* 忨 */ + UINT8 chanelID; /* ͨid */ + UINT32 secondRequstTime; /* ٴʱ */ + UINT32 firstReplyTime; /** յһ״ȷϢеʱ */ + UINT8 exitOpCmd; /* ˳Ӫ */ + UINT32 exitOpCmdCrc; /* ˳ӪCRC */ + UINT32 msgCrc; /* Ϣ֡CRC */ +}EXIT_OP_SEC_REQ_STRUCT; + + +#endif diff --git a/TSCP/src/APP/ciapp/Deployment/DeploymentExtern.h b/TSCP/src/APP/ciapp/Deployment/DeploymentExtern.h new file mode 100644 index 0000000..7f94ec9 --- /dev/null +++ b/TSCP/src/APP/ciapp/Deployment/DeploymentExtern.h @@ -0,0 +1,101 @@ + + +/****************************************************************************** +** ļ: DeploymentExtern.h +** : ܴ + 1˳Ӫ +*******************************************************************************/ +#ifndef DEPLOYMENT_EXTERN_H_ +#define DEPLOYMENT_EXTERN_H_ + +#include "CommonTypes.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define EXIT_OP_STATUS 0x55u /* ˳Ӫ״̬ */ +#define STAY_OP_STATUS 0xaau /* Ӫ״̬ */ + +#define DEVICE_TYPE_AIM 0xF800U +#define DEVTYPE_AIM (0xF8u) /*AIMݺ ȷ*/ + +typedef void (*p_DPrintf)(const char* lpszFormat, ...); + +/** + * @brief ˳Ӫģʼ + * @param[in] UINT16 cycleTime ǰϵͳ + * @param[in] const p_DPrintf pfun ӡӿ + * @param[out] + * @return + * @note + */ +extern void Deploy_Init(UINT16 cycleTime, const p_DPrintf pfun); + +/** + * @brief + * @param[in] const UINT8* dataBuf,뱨ʼַ + * @param[in] UINT16 dataLength,뱨ij + * @param[in] UINT8 srcType, + * @param[in] UINT8 srcId,ID + * @param[out] + * @return 0,ʧ + 1ɹ + * @note ϢΪȥЭЭͷ + */ +extern UINT8 Deploy_ParseAIMInputInfo(const UINT8* dataBuf, UINT16 dataLength, UINT8 srcType,UINT8 srcId); + + +/** + * @brief ˳Ӫ + * @param[in] + * @param[out] + * @return + * @note + */ +extern void Deploy_ExitOperationHandle(void); + +/** + * @brief + * @param[in] UINT16 maxLen,Ĵ洢ռ + * @param[out] UINT8* dataBuf,ʼַ + * @return 0 ʧܣ0 ɹ + * @note + */ +extern UINT16 Deploy_PackToAIMInfo(UINT8* dataBuf,UINT16 maxLen); + + +/** + * @brief + * @param[out] UINT8 *pDataBuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ݵij + * @note + */ +extern UINT32 Deploy_GetTransferData(OUT UINT8 *pDataBuff,UINT32 curIndex); + +/** + * @brief ø + * @param[in] const UINT8 *pDatabuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ȡ + * @note + */ +extern UINT32 Deploy_SetTransferData(IN const UINT8 *pDatabuff,UINT32 curIndex); + + + /** + * @brief ȡ˳Ӫ״̬ + * @param[in] + * @param[out] + * @return EXIT_OP_STATUS ˳ӪSTAY_OP_STATUS Ӫ + * @note + */ +extern UINT8 Deploy_GetExitOperateStatus(void); + + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevConfigDataManage.c b/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevConfigDataManage.c new file mode 100644 index 0000000..aae9bf8 --- /dev/null +++ b/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevConfigDataManage.c @@ -0,0 +1,81 @@ +/******************************************************** +* +* DiffLineDevDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-11-05 +* ߣ +* ·豸Cļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#include "DiffLineDevConfigDataManage.h" + +DiffLineDevStruct DiffLineDevData;/*·豸*/ +UINT16 DiffLineDevSum = 0u; /*·豸*/ + +/* +: 豸Ƿ· +: UINT8 devType 豸 + UINT16 devId 豸ID +: +ֵ: CI_TRUE · + CI_FALSE · +*/ +UINT8 CheckTheDevIsNotOfDiffLine(UINT8 devType, UINT16 devId) +{ + UINT16 *pDevId = NULL; /*ͬ豸IDָ*/ + UINT16 devSum = 0u; /*ͬ豸*/ + UINT16 i = 0u; /*ѭ*/ + UINT8 retVal = CI_FALSE; /*ֵ*/ + + switch (devType) + { + case CI_DEVICE_TYPE_SWITCH: /* */ + pDevId = DiffLineDevData.switchIdBuf; + devSum = DiffLineDevData.switchNum; + break; + case CI_DEVICE_TYPE_SIGNAL: /* źŻ */ + pDevId = DiffLineDevData.signalIdBuf; + devSum = DiffLineDevData.signalNum; + break; + case CI_DEVICE_TYPE_ESB: /* ESB */ + pDevId = DiffLineDevData.esbIdBuf; + devSum = DiffLineDevData.esbNum; + break; + case CI_DEVICE_TYPE_PSD: /* PSD */ + pDevId = DiffLineDevData.psdIdBuf; + devSum = DiffLineDevData.psdNum; + break; + case CI_DEVICE_TYPE_SPKS: /* SPKS */ + pDevId = DiffLineDevData.spksIdBuff; + devSum = DiffLineDevData.spksNum; + break; + case CI_DEVICE_TYPE_AXISSEC: /**/ + pDevId = DiffLineDevData.axisSectIdBuff; + devSum = DiffLineDevData.axisSectNum; + break; + case CI_DEVICE_TYPE_PHYSEC: /**/ + pDevId = DiffLineDevData.physSectIdBuff; + devSum = DiffLineDevData.physSectNum; + break; + default: + pDevId = NULL; + devSum = 0u; + break; + } + retVal = CI_TRUE; /*ֵ*/ + for(i = 0u; i < devSum; i++) + { + if(pDevId[i] == devId) + {/*ָ豸ID·豸IDͬ*/ + retVal = CI_FALSE; + break; + } + } + + return retVal; +} + diff --git a/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevConfigDataManage.h b/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevConfigDataManage.h new file mode 100644 index 0000000..162a060 --- /dev/null +++ b/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevConfigDataManage.h @@ -0,0 +1,72 @@ +/******************************************************** +* +* DiffLineDevConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-10-05 +* ߣ +* ·豸ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _DIFF_LINE_DEV_DATA_MANAGE_H_ +#define _DIFF_LINE_DEV_DATA_MANAGE_H_ + + +#include "DiffLineDevDefine.h" +#include "../System/CiSystemDefine.h" +#include "CommonTypes.h" +#include "Convert.h" +#include "../System/SystemParameterManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*·豸ݽṹ*/ +typedef struct S_DiffLineDevStruct +{ + UINT16 diffLineDevSum; + + UINT16 signalNum; /*źŻ*/ + UINT16 signalIdBuf[DIFF_LINE_SIGNAL_MAX]; /*źŻID*/ + + UINT16 switchNum; /**/ + UINT16 switchIdBuf[DIFF_LINE_SWITCH_SUM_MAX]; /*ID*/ + + UINT16 psdNum; /**/ + UINT16 psdIdBuf[DIFF_LINE_PSD_SUM_MAX]; /*ID*/ + + UINT16 esbNum; /*ͣť*/ + UINT16 esbIdBuf[DIFF_LINE_ESB_SUM_MAX]; /*ͣťID*/ + + UINT16 spksNum; /*SPKS */ + UINT16 spksIdBuff[DIFF_LINE_SPKS_SUM_MAX]; /*SPKS ID*/ + + UINT16 axisSectNum; /* */ + UINT16 axisSectIdBuff[DIFF_LINE_AXIS_SECT_SUM_MAX]; /* ID*/ + + UINT16 physSectNum; /**/ + UINT16 physSectIdBuff[DIFF_LINE_PHYS_SECT_SUM_MAX]; /* ID*/ +} DiffLineDevStruct; + +/*******************************ȫֱ*******************************/ +extern DiffLineDevStruct DiffLineDevData;/*·豸*/ +extern UINT16 DiffLineDevSum; /*·豸*/ +/* +: 豸Ƿ· +: UINT8 devType 豸 + UINT16 devId 豸ID +: +ֵ: CI_TRUE · + CI_FALSE · +*/ +UINT8 CheckTheDevIsNotOfDiffLine(UINT8 devType, UINT16 devId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevDefine.h b/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevDefine.h new file mode 100644 index 0000000..aed6fba --- /dev/null +++ b/TSCP/src/APP/ciapp/DiffLineDev/DiffLineDevDefine.h @@ -0,0 +1,43 @@ +/******************************************************** +* +* DiffLineDevDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-11-05 +* ߣ +* ·豸ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _DIFF_LINE_DEV_DEFINE_H_ +#define _DIFF_LINE_DEV_DEFINE_H_ + +/*ϵͳͷļ*/ +#include "../System/SystemConfigDefine.h" + +/*·źŻ*/ +#define DIFF_LINE_SIGNAL_MAX ((UINT16)16) + +/*·*/ +#define DIFF_LINE_SWITCH_SUM_MAX ((UINT16)16) + +/*·PSD*/ +#define DIFF_LINE_PSD_SUM_MAX ((UINT16)16) + +/*·ESB*/ +#define DIFF_LINE_ESB_SUM_MAX ((UINT16)16) + +/*·SPKS*/ +#define DIFF_LINE_SPKS_SUM_MAX ((UINT16)16) + +/*·*/ +#define DIFF_LINE_AXIS_SECT_SUM_MAX ((UINT16)16) + +/*·*/ +#define DIFF_LINE_PHYS_SECT_SUM_MAX ((UINT16)16) + +#endif + + diff --git a/TSCP/src/APP/ciapp/ERROR/ErrorDataManage.c b/TSCP/src/APP/ciapp/ERROR/ErrorDataManage.c new file mode 100644 index 0000000..538b0d7 --- /dev/null +++ b/TSCP/src/APP/ciapp/ERROR/ErrorDataManage.c @@ -0,0 +1,254 @@ +/******************************************************** +* +* ErrorDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-11 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "ErrorDataManage.h" +#include "../LogicManage/InterlockLogicManage.h" + + +/* ÿЧ ڽʱ */ +ErrorDataStruct ErrorDataStru[ERROR_DATA_SUM_MAX]; /*ݽṹ*/ + +UINT16 ErrorDataCurSum = 0u; /*ݵǰ*/ + + +/* +* ȡݵǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ݵǰ +*/ +UINT16 GetErrorDataCurSum(void) +{ + UINT16 reVal = 0u; + if (ErrorDataCurSum >= ERROR_DATA_SUM_MAX) + { + reVal = 0u; + } + else + { + reVal = ErrorDataCurSum; + } + return reVal; +} + + +/* +* ȡ +* ˵ const UINT16 bufIndex, ± +* ֵ NULL: ȡʧ +* !NULL: +*/ +ErrorDataStruct* GetErrorData(const UINT16 bufIndex) +{ + ErrorDataStruct* reVal = NULL; + ErrorDataStruct *pErrorData = NULL; /* ֵ */ + + if (bufIndex >= ERROR_DATA_SUM_MAX) + { + reVal = NULL; + } + else + { + if (ErrorDataStru[bufIndex].FunctionId != 0u) + { + /* Ч */ + pErrorData = &ErrorDataStru[bufIndex]; + reVal = pErrorData; + } + else + { + /* Ч */ + pErrorData = NULL; + reVal = pErrorData; + } + } + return reVal; +} + + +/* +* ô +* ˵ const UINT8 functionId, ID +* const UINT8 DeviceType, 豸 +* const UINT16 DeviceId, 豸ID +* const UINT8 DeviceStateType, 豸״̬ +* const UINT8 DeviceState, 豸״̬ +* const UINT8 SendLevel, ͼ +* ֵ +* +*/ +void SetErrorData(const UINT8 FunctionId, const UINT8 DeviceType, const UINT16 DeviceId, + const UINT8 DeviceStateType, const UINT8 DeviceState, + const UINT8 SendLevel) +{ + UINT16 tempErrorDataIndex = 0u; /*¼Ѱַ*/ + + tempErrorDataIndex = ErrorDataCurSum; + if (tempErrorDataIndex < ERROR_DATA_SUM_MAX) + { + if (ETYPE_PS_FLOCK_SPKSCMD_STATE == DeviceStateType) + { + SetPhySecSpksCmdFlockErrorData(FunctionId, DeviceType, DeviceId, DeviceStateType, DeviceState, SendLevel); + } + else + { + /* ¼ */ + ErrorDataStru[tempErrorDataIndex].FunctionId = FunctionId; + ErrorDataStru[tempErrorDataIndex].DeviceType = DeviceType; + ErrorDataStru[tempErrorDataIndex].DeviceId = DeviceId; + ErrorDataStru[tempErrorDataIndex].DeviceStateType = DeviceStateType; + ErrorDataStru[tempErrorDataIndex].DeviceState = DeviceState; + ErrorDataStru[tempErrorDataIndex].SendLevel = SendLevel; + + /* ¼δѰַָ */ + ErrorDataCurSum = (UINT16)(tempErrorDataIndex + 1u); + } + + } + else + { + /* ¼ʧ */ + } +} + + +/* +* ݣÿڽ +* ˵ void +* ֵ void +*/ +void ClearErrorData(void) +{ + UINT16 i = 0u; + + /* */ + ErrorDataCurSum = 0u; + for (i = 0u; i< ERROR_DATA_SUM_MAX; i++) + { + ErrorDataStru[i].FunctionId = 0u; + ErrorDataStru[i].DeviceStateType = 0u; + ErrorDataStru[i].DeviceId = 0u; + ErrorDataStru[i].DeviceState = 0u; + ErrorDataStru[i].SendLevel = 0u; + ErrorDataStru[i].DeviceType = 0u; + ErrorDataStru[i].VirCIid = 0u; + } +} + + +/* +* ɾϢ +* ˵ const UINT16 Index +* ֵ void +*/ +void DeleteErrorData(const UINT16 Index) +{ + ErrorDataStru[Index].FunctionId = 0u; + ErrorDataStru[Index].DeviceStateType = 0u; + ErrorDataStru[Index].DeviceId = 0u; + ErrorDataStru[Index].DeviceState = 0u; + ErrorDataStru[Index].SendLevel = 0u; + ErrorDataStru[Index].DeviceType = 0u; + ErrorDataStru[Index].VirCIid = 0u; + ErrorDataCurSum--; +} + +/* +* ôݵID +* ˵ +* const UINT16 preErrorNum, ֮ǰErrorĿ +* const UINT8 virCIid, ID +* ֵ void +* cgh-ϲCID-2349-5 +*/ +void SetErrorDataBelongVirCiId(const UINT16 preErrorNum, const UINT8 virCIid) +{ + UINT16 tempErrorDataNum = 0u; /*¼Ѱַ*/ + UINT16 ii = 0u; + + tempErrorDataNum = GetErrorDataCurSum(); /*ֵСERROR_DATA_SUM_MAX*/ + if ((0u < tempErrorDataNum) && (ERROR_DATA_SUM_MAX > preErrorNum)) + { + + for (ii = preErrorNum; ii < tempErrorDataNum; ii++)/**/ + { + ErrorDataStru[ii].VirCIid = virCIid;/*¼ErrorDataID*/ + } + + } + else + { + /**/ + } + +} + +/* +* ηΪSPKSʱĴ +* ˵ const UINT8 functionId, ID +* const UINT8 DeviceType, 豸 +* const UINT16 DeviceId, 豸ID +* const UINT8 DeviceStateType, 豸״̬ +* const UINT8 DeviceState, 豸״̬ +* const UINT8 SendLevel, ͼ +* ֵ +*cgh-ϲCID-2539-1 +*/ +void SetPhySecSpksCmdFlockErrorData(const UINT8 FunctionId, const UINT8 DeviceType, const UINT16 DeviceId, + const UINT8 DeviceStateType, const UINT8 DeviceState, + const UINT8 SendLevel) +{ + UINT16 tempErrorDataIndex = 0u; /*¼Ѱַ*/ + UINT16 spksId = 0u; /*SPKS ID*/ + UINT8 spksState = 0u; /*SPKS ״̬*/ + UINT8 checkResult = 0u; /**/ + tempErrorDataIndex = ErrorDataCurSum; + if (tempErrorDataIndex < ERROR_DATA_SUM_MAX) + { + + /* ¼Ĵ */ + ErrorDataStru[tempErrorDataIndex].FunctionId = FunctionId; + ErrorDataStru[tempErrorDataIndex].DeviceType = DeviceType; + ErrorDataStru[tempErrorDataIndex].DeviceId = DeviceId; + ErrorDataStru[tempErrorDataIndex].DeviceStateType = ETYPE_PS_FLOCK_STATE; + ErrorDataStru[tempErrorDataIndex].DeviceState = DeviceState; + ErrorDataStru[tempErrorDataIndex].SendLevel = SendLevel; + + tempErrorDataIndex++; + + checkResult = CheckPhysecFlockReasonSpksId(DeviceId, &spksId, &spksState);/*ȡηǸspksµµ*/ + if (CI_SUCCESS == checkResult) + { + /* ¼SPKSĴ */ + ErrorDataStru[tempErrorDataIndex].FunctionId = FunctionId; + ErrorDataStru[tempErrorDataIndex].DeviceType = CI_DEVICE_TYPE_SPKS; + ErrorDataStru[tempErrorDataIndex].DeviceId = spksId; + ErrorDataStru[tempErrorDataIndex].DeviceStateType = ETYPE_SPKS_STATE_UP; + ErrorDataStru[tempErrorDataIndex].DeviceState = spksState; + ErrorDataStru[tempErrorDataIndex].SendLevel = SendLevel; + + tempErrorDataIndex++; + } + /* ¼δѰַָ */ + ErrorDataCurSum = (UINT16)(tempErrorDataIndex); + } + else + { + /**/ + } + +} + + + + + + diff --git a/TSCP/src/APP/ciapp/ERROR/ErrorDataManage.h b/TSCP/src/APP/ciapp/ERROR/ErrorDataManage.h new file mode 100644 index 0000000..aeb0954 --- /dev/null +++ b/TSCP/src/APP/ciapp/ERROR/ErrorDataManage.h @@ -0,0 +1,120 @@ +/******************************************************** +* +* ErrorDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-11 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ERROR_DATA_MANAGE_H_ +#define _ERROR_DATA_MANAGE_H_ + + +#include "ErrorDefine.h" +#include "../System/CiSystemDefine.h" +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ݽṹ*/ +typedef struct S_ErrorDataStruct +{ + UINT8 FunctionId; /*ID (ֶ̬)*/ + UINT8 DeviceType; /*豸 (ֶ̬)*/ + UINT16 DeviceId; /*豸ID (ֶ̬)*/ + UINT8 DeviceStateType; /*豸״̬ (ֶ̬)*/ + UINT8 DeviceState; /*豸״̬ (ֶ̬)*/ + UINT8 SendLevel; /*ⷢͼ (ֶ̬)*/ + UINT8 VirCIid; /*ñID*/ +} ErrorDataStruct; + +/*******************************ȫֱ*******************************/ +extern ErrorDataStruct ErrorDataStru[ERROR_DATA_SUM_MAX]; /*ݽṹ*/ + +extern UINT16 ErrorDataCurSum; /*ݵǰ*/ + +/* +* ȡݵǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ݵǰ +*/ +UINT16 GetErrorDataCurSum(void); + + +/* +* ȡ +* ˵ const UINT16 bufIndex, ± +* ֵ NULL: ȡʧ +* !NULL: +*/ +ErrorDataStruct* GetErrorData(const UINT16 bufIndex); + + +/* +* ô +* ˵ const UINT8 functionId, ID +* const UINT8 DeviceType, 豸 +* const UINT16 DeviceId, 豸ID +* const UINT8 DeviceStateType, 豸״̬ +* const UINT8 DeviceState, 豸״̬ +* const UINT8 SendLevel, ͼ +* ֵ +* +*/ +void SetErrorData(const UINT8 FunctionId, const UINT8 DeviceType, const UINT16 DeviceId, + const UINT8 DeviceStateType, const UINT8 DeviceState, + const UINT8 SendLevel); + + + +/* +* +* ˵ void +* ֵ void +*/ +void ClearErrorData(void); +/* +* ɾϢ +* ˵ const UINT16 Index +* ֵ void +*/ +void DeleteErrorData(const UINT16 Index); + +/* +* ôݵID +* ˵ +* const UINT16 preErrorNum, ֮ǰErrorĿ +* const UINT8 virCIid, ID +* ֵ void +* cgh-ϲCID-2349-5 +*/ +void SetErrorDataBelongVirCiId(const UINT16 preErrorNum, const UINT8 virCIid); +/* +* ηΪSPKSʱĴ +* ˵ const UINT8 functionId, ID +* const UINT8 DeviceType, 豸 +* const UINT16 DeviceId, 豸ID +* const UINT8 DeviceStateType, 豸״̬ +* const UINT8 DeviceState, 豸״̬ +* const UINT8 SendLevel, ͼ +* ֵ +*cgh-ϲCID-2539-1 +*/ +void SetPhySecSpksCmdFlockErrorData(const UINT8 FunctionId, const UINT8 DeviceType, const UINT16 DeviceId, + const UINT8 DeviceStateType, const UINT8 DeviceState, + const UINT8 SendLevel); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ERROR/ErrorDefine.h b/TSCP/src/APP/ciapp/ERROR/ErrorDefine.h new file mode 100644 index 0000000..48a21ec --- /dev/null +++ b/TSCP/src/APP/ciapp/ERROR/ErrorDefine.h @@ -0,0 +1,407 @@ +/******************************************************** +* +* ErrorDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-11 +* ߣ +* ݶͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ +#ifndef _ERROR_DEFINE_H_ +#define _ERROR_DEFINE_H_ + +#include "../System/CiSystemDefine.h" + + +/*һڴֵ*/ +#define ERROR_DATA_SUM_MAX ((UINT16)100) /*ֵ*/ + +/* ˫汾ӿںͬĹ */ +#define EFUNC_NO_ERROR ((UINT8)0x00) /* سɹ */ + +/*߼*/ +#define EFUNC_ROUTE_LEVEL ((UINT8)0x01) /* RouteLevelConfirmLogicProcess */ +#define EFUNC_SET_BLOC_T_ROUTE ((UINT8)0x02) /* SetBlocLTrainRouteLogicProcess */ +#define EFUNC_SET_CBTC_T_ROUTE ((UINT8)0x03) /* SetCbtcLTrainRouteLogicProcess */ +#define EFUNC_SET_BLOC_R_ROUTE ((UINT8)0x04) /* SetBlocReturnRouteLogicProcess */ +#define EFUNC_SET_CBTC_R_ROUTE ((UINT8)0x05) /* SetCbtcReturnRouteLogicProcess */ +#define EFUNC_LOCK_LEAD_ROUTE ((UINT8)0x06) /* LockLeadRouteLogicProcess */ +#define EFUNC_LOCK_BLOC_T_ROUTE ((UINT8)0x07) /* LockBlocLTrainRouteLogicProcess */ +#define EFUNC_LOCK_CBTC_T_ROUTE ((UINT8)0x08) /* LockCbtcLTrainRouteLogicProcess */ +#define EFUNC_LOCK_BLOC_R_ROUTE ((UINT8)0x09) /* LockBlocReturnRouteLogicProcess */ +#define EFUNC_LOCK_CBTC_R_ROUTE ((UINT8)0x0a) /* LockCbtcReturnRouteLogicProcess */ +#define EFUNC_LOCK_OVER_LAP ((UINT8)0x0b) /* LockRouteOverlapLogicProcess */ +#define EFUNC_OPEN_BLOC_T_SIGNAL ((UINT8)0x0c) /* OpenBlocLTrainRouteLogicProcess */ +#define EFUNC_KEEP_BLOC_T_SIGNAL ((UINT8)0x0d) /* KeepBlocLTrainRouteLogicProcess */ +#define EFUNC_OPEN_CBTC_T_SIGNAL ((UINT8)0x0e) /* OpenCbtcLTrainRouteLogicProcess */ +#define EFUNC_KEEP_CBTC_T_SIGNAL ((UINT8)0x0f) /* KeepCbtcLTrainRouteLogicProcess */ +#define EFUNC_OPEN_BLOC_R_SIGNAL ((UINT8)0x10) /* OpenBlocReturnRouteLogicProcess */ +#define EFUNC_KEEP_BLOC_R_SIGNAL ((UINT8)0x11) /* KeepBlocReturnRouteLogicProcess */ +#define EFUNC_OPEN_CBTC_R_SIGNAL ((UINT8)0x12) /* OpenCbtcReturnRouteLogicProcess */ +#define EFUNC_KEEP_CBTC_R_SIGNAL ((UINT8)0x13) /* KeepCbtcReturnRouteLogicProcess */ +#define EFUNC_OPEN_LEAD_SIGNAL ((UINT8)0x14) /* OpenLeadRouteLogicProcess */ +#define EFUNC_KEEP_LEAD_SIGNAL ((UINT8)0x15) /* KeepLeadRouteLogicProcess */ +#define EFUNC_UNLOCK_1ST_SECTION ((UINT8)0x16) /* RouteFirstSecAutoUnlockProcess */ +#define EFUNC_UNLOCK_OTHERS_SECTION ((UINT8)0x17) /* RouteOtherSectionAutoLockLogicProcess */ +#define EFUNC_DLOCK_SECTION ((UINT8)0x18) /* PhySectionDelayUnlockProcess */ +#define EFUNC_UNLOCK_OVER_LAP ((UINT8)0x19) /* UnlockRouteOverlapLogicProcess */ +#define EFUNC_CANCLE_ROUTE ((UINT8)0x1a) /* RouteCancelLogicProcess */ +#define EFUNC_CHECK_SECTION_USE ((UINT8)0x1b) /* RoutePhySectionUseLogicProcess */ +#define EFUNC_UNLOCK_FAULT_SECTION ((UINT8)0x1c) /* PhySecFaultUnlockLogicProcess */ +#define EFUNC_SET_SWITCH_POS ((UINT8)0x1d) /* SetSwitchPositionProcess */ +#define EFUNC_SET_SWITCH_DLOCK ((UINT8)0x1e) /* SetSwitchDLockLogicProcess */ +#define EFUNC_CANCEL_SWITCH_DLOCK ((UINT8)0x1f) /* CancelSwitchDLockProcess */ +#define EFUNC_SET_SWITCH_FLOCK ((UINT8)0x20) /* SetSwitchFLockProcess */ +#define EFUNC_CANCEL_SWITCH_FLOCK ((UINT8)0x21) /* CancelSwitchFLockProcess */ +#define EFUNC_SET_SIGNAL_FLOCK ((UINT8)0x22) /* SetSignalFLockLogicProcess */ +#define EFUNC_CANCEL_SIGNAL_FLOCK ((UINT8)0x23) /* CancelSignalFLockLogicProcess */ +#define EFUNC_FORCE_SET_SWITCH_POS ((UINT8)0x24) /* ForceSetSwitchPosLogicProcess */ +#define EFUNC_SET_REVERSE_T_ROUTE ((UINT8)0x25) /* SetRevrLTrainRouteLogicProcess */ +#define EFUNC_SET_REVERSE_R_ROUTE ((UINT8)0x26) /* SetReverseRtnRouteLogicProcess*/ +#define EFUNC_CHECK_ROUTE_ZRJ ((UINT8)0x27) /* CheckRouteZongRenJieFeasibility ·˽Ŀ*/ +#define EFUNC_CHECK_OPEN_CT_ROUTE_ERR_ZX ((UINT8)0x28) +#define EFUNC_CHECK_OPEN_UT_ROUTE_ERR_ZX ((UINT8)0x29) +#define EFUNC_CHECK_OPEN_CT_RETURN_ERR_ZX ((UINT8)0x2a) +#define EFUNC_CHECK_OPEN_UT_RETURN_ERR_ZX ((UINT8)0x2b) +#define EFUNC_KEEP_CT_SIGNAL_ERR_ZX ((UINT8)0x2c) +#define EFUNC_KEEP_UT_SIGNAL_ERR_ZX ((UINT8)0x2d) +#define EFUNC_KEEP_CT_RETURN_SIG_ERR_ZX ((UINT8)0x2e) +#define EFUNC_KEEP_UT_RETURN_SIG_ERR_ZX ((UINT8)0x2f) +#define EFUNC_LOCK_HLHT_LOC_OVLP ((UINT8)0x30) /*LockLocalOvlpCheckHlht */ +#define EFUNC_LOCK_HLHT_REM_OVLP ((UINT8)0x31) /*LockOthCiOvlpCheckHlht */ +#define EFUNC_CHECK_LEAD_ROUTE_ZRJ ((UINT8)0x32) +#define EFUNC_SET_SECTION_FLOCK ((UINT8)0x33) /*ηηȡԶԣ2018.10.23*/ + + +#define EFUNC_SIGNAL_RELAY_TO_DEVICE ((UINT8)0x34) /*SignalRelayToDeviceStateProc*/ + +#define EFUNC_ZC_CI_MaskDataProcess ((UINT8)0x35) /*ZCCIλ*/ + +#define EFUNC_LockAxisSecProc ((UINT8)0x36) /*Ծռ*/ +#define EFUNC_RouteFirstXuanPaiManage ((UINT8)0x37U) /*-·ѡ*/ +#define EFUNC_CommonRouteXuanPaiDeal ((UINT8)0x38U) /*-·ѡ*/ +#define EFUNC_PartialRouteFirstXuanPaiManage ((UINT8)0x91U) /*··ѡ*/ +#define EFUNC_DynamicRouteProc ((UINT8)0x92U) /*SetDynamicRouteProc*/ +#define EFUNC_LEAD_ROUTE_FIRST_XUANPAI ((UINT8)0x3eU) /*LeadRouteFirstXuanPaiManage*/ + +#define EFUNC_KEEPROUTESECTIONERRCHECK ((UINT8)0x39U) /*KeepCbtcRouteSectionErrCheck*/ +#define EFUNC_OPENROUTESECTIONERRCHECK ((UINT8)0x3aU) /*KeepCbtcRouteSectionErrCheck*/ + +#define EFUNC_SET_AUTOROUTE ((UINT8)0x3bU) /*SetAutoRouteLogicManage*/ +#define EFUNC_SET_AUTORETURN ((UINT8)0x3cU) /*SetAutoReturnLogicManage*/ +#define EFUNC_SET_ALLAUTORETURN ((UINT8)0x3dU) /*SetAllAutoReturnLogicManage*/ + +#define EFUNC_PARSE_TMC2CI_DATA ((UINT8)0x3f) /*ParseTmcToTiocDataFrame*/ +#define EFUNC_PACK_CI2VOBC_DATA ((UINT8)0x40) /*PackCiToVobcData*/ +#define EFUNC_PARSE_ATS2CI_DATA ((UINT8)0x41) /*ProcessAtsOrXianDiToCiData*/ +#define EFUNC_PARSE_VOBC2CI_DATA ((UINT8)0x42) /*ParseVobcToCiDataFrameHLHT */ +#define EFUNC_PARSE_ZC2CI_DATA ((UINT8)0x43) /*ParseZcToCiDataFrame */ +#define EFUNC_PARSE_CI2CI_DATA ((UINT8)0x44) /*ParseCiToCiDataFrameHLHT */ + +#define EFUNC_CHECK_SWITCH_USING ((UINT8)0x45) /*CheckRouteContainSwitchUsingState*/ +#define EFUNC_CROSS_CI_AUTOROUTE_FLOCK_DEV ((UINT8)0x46) /*CrossCiAutoRouteFLockDevProc 缯Զ·豸*/ +#define EFUNC_CHECK_GROUP_AUTO_ROUTE ((UINT8)0x47) /*:SetGroupAutoRouteLogicManage ԶϽ·Զ·Ƿ*/ +#define EFUNC_UPDATE_ZHAOCHA_CHECK ((UINT8)0x48) /*UpdateZhaoChaCheckZhaoChaDrive ղղ̵*/ +#define EFUNC_CHECKORDERWHETHERDO ((UINT8)0x49) /*CheckOrderWhetherDoing Ƿִ*/ +#define EFUNC_ROUTE_FIRST_LOG_UNLOCK ((UINT8)0x50) /*RouteFirstLogSecAutoUnlockProcess·һ߼Զ*/ +#define EFUNC_SWITCHTESTLOGIC ((UINT8)0x80U) /*SetSwitchTestLogicManageλ*/ +#define EFUNC_OVERLAP_VALIDMASK_CHECK ((UINT8)0x4A) /*OverlapValidMaskCheck 㱣Чλ*/ + +/*߼*/ +#define EFUNC_SET_LEAD_ROUTE_CHECK ((UINT8)0x4B) /*·*/ +#define EFUNC_CLD_SET_L_TRAIN_ROUTE ((UINT8)0x51) /*г·*/ +#define EFUNC_CLD_SET_D_TRAIN_ROUTE ((UINT8)0x52) /*·*/ +#define EFUNC_CLD_SET_LEAD_ROUTE ((UINT8)0x53) /*·*/ +#define EFUNC_CLD_SET_D_LONG_ROUTE ((UINT8)0x54) /*·*/ +#define EFUNC_CLD_LOCK_L_TRAIN_ROUTE ((UINT8)0x55) /*г·*/ +#define EFUNC_CLD_LOCK_D_TRAIN_ROUTE ((UINT8)0x56) /*յ·*/ +#define EFUNC_CLD_LOCK_LEAD_ROUTE ((UINT8)0x57) /*·*/ +#define EFUNC_CLD_LOCK_D_LONG_ROUTE ((UINT8)0x58) /*ճ·*/ +#define EFUNC_CLD_OPEN_L_TRAIN_ROUTE ((UINT8)0x59) /*г·ź*/ +#define EFUNC_CLD_OPEN_D_TRAIN_ROUTE ((UINT8)0x5a) /*ŵ·ź*/ +#define EFUNC_CLD_OPEN_LEAD_ROUTE ((UINT8)0x5b) /*·ź*/ +#define EFUNC_CLD_KEEP_L_TRAIN_ROUTE ((UINT8)0x5c) /*г·ź*/ +#define EFUNC_CLD_KEEP_D_TRAIN_ROUTE ((UINT8)0x5d) /*ֵ·ź*/ +#define EFUNC_CLD_KEEP_LEAD_ROUTE ((UINT8)0x5e) /*·ź*/ +#define EFUNC_CLD_SET_NONROUTE ((UINT8)0x5f) /*ǽ·*/ +#define EFUNC_CLD_LOCK_NONROUTE ((UINT8)0x60) /*շǽ·*/ +#define EFUNC_CLD_OPEN_NONROUTE ((UINT8)0x61) /*ŷǽ·*/ +#define EFUNC_CLD_KEEP_NONROUTE ((UINT8)0x62) /*ַǽ·*/ +#define EFUNC_CLD_CANCEL_NONROUTE ((UINT8)0x64) /*ȡǽ·*/ +#define EFUNC_CLD_FAULT_CANCEL_NONROUTE ((UINT8)0x65) /*ȡǽ·*/ +#define EFUNC_CLD_CANCEL_D_TRAIN_ROUTE ((UINT8)0x66) /*ȡ·*/ +#define EFUNC_CLD_CLOSE_GARAGEDOOR ((UINT8)0x67) /*رճ*/ +#define EFUNC_CLD_CHECK_GARAGEDOOR_CLOSE ((UINT8)0xc9) /*Źر飨RCģʽ£*/ +#define EFUNC_CHECK_DIAOCHE_ROUTE_ZRJ ((UINT8)0x68) /* CheckDiaoCheRouteZRJFeasibility ·˽Ŀ*/ +#define EFUNC_CHECK_OPEN_L_ERR_CLD ((UINT8)0x69) /*OpenLTrainRouteErrP*/ +#define EFUNC_CHECK_OPEN_D_ERR_CLD ((UINT8)0x6a) +#define EFUNC_KEEP_L_ERR_CLD ((UINT8)0x6b) +#define EFUNC_KEEP_D_ERR_CLD ((UINT8)0x6c) +#define EFUNC_KEEP_D_SEC_ERR_CHECK_CLD ((UINT8)0x6d) +#define EFUNC_OPEN_D_SEC_ERR_CHECK_CLD ((UINT8)0x6e) + +#define EFUNC_CLD_OpenCommRouteSigProc ((UINT8)0x6f) /*OpenCommRouteSigProc*/ +#define EFUNC_ZX_ProcessAtsOrXianDiToCiData ((UINT8)0x70) /*ProcessAtsOrXianDiToCiData*/ + +#define EFUNC_FloodGateDeviceToRelayStateProc ((UINT8)0x71) /*FloodGateDeviceToRelayStateProc*/ + +#define EFUNC_LeadzLockSignalOpenRouteCheck ((UINT8)0x93) /*LeadzLockSignalOpenRouteCheck*/ + +#define EFUNC_SetCiCiRelayInterfaceConfirmFlag ((UINT8)0x72) /*CICI̵ӿȷ״̬*/ +#define EFUNC_SET_SEC_RESET_LOGIC_MANAGE ((UINT8)0x73) /*SetSectionResetLogicManage Ḵλ߼*/ +#define EFUNC_PHYSEC_RESET_TO_RELAY_STATE_PROC ((UINT8)0x74) /*PhySecResetToRelayStateProc μḴλ̵״̬*/ +#define EFUNC_SETCIPSCPLCONFIRMFLAG ((UINT8)0x75) /*SetCiPscPlConfirmFlagPSC·*/ +#define EFUNC_SETNEARCIPSCPLFLAG ((UINT8)0x76) /*SetNearCiPscPlFlagվPSC·*/ + +#define EFUNC_RouteYuXianOpenManage ((UINT8)0x77) /*EFUNC_RouteYuXianOpenManageźŻԤȿ*/ +#define EFUNC_RouteNearOpenManage ((UINT8)0x78) /*EFUNC_RouteNearOpenManageźŻӽ*/ +#define EFUNC_RouteYuXianOpenDeal ((UINT8)0x79) /*EFUNC_RouteYuXianOpenDealźŻԤȿ*/ +#define EFUNC_RouteNearOpenDeal ((UINT8)0x7a) /*EFUNC_RouteNearOpenDealźŻӽ*/ +#define EFUNC_RouteLockVainCheak ((UINT8)0x7bU) /*·߼飬ѡŵλ֮ߣκͬһID*/ +#define EFUNC_LOGIC_RES_APP_CHECK ((UINT8)0x80) /*߼ԴԼ*/ +#define EFUNC_SET_HALF_ROUTE_LOGIC ((UINT8)0x81) /*EFUNC_SetHalfTrainRouteLogicProcess·*/ +#define EFUNC_LOCK_HALF_ROUTE_LOGIC ((UINT8)0x82) /*EFUNC_LockRouteHalfLogicProcessղ·*/ +#define EFUNC_LOCK_DYNAMIC_ROUTE_LOGIC ((UINT8)0x83) /*EFUNC_LockDynamicRouteProcն̬·ж*/ +#define EFUNC_UNLOCK_FAULT_LOGSEC ((UINT8)0x84) /* LogSecFaultUnlockLogicProcess */ +#define EFUNC_CHECK_HALFROUTE_USEING ((UINT8)0xc8) /* HalfRoutePhySecUseLogicProcess ·δü*/ +#define EFUNC_OVERLAP_RES_APP_CHECK ((UINT8)0xca) /*ԴԼ*/ + +#define EFUNC_SetAtsLockOverlapHaveRouteId (UINT8)0x7cU /*ձδ·ID*/ +#define EFUNC_SetAtsExpectLockOverlapIdProc (UINT8)0x7dU /*ձδ·ID*/ + +/*߼·ʽر*/ +#define EFUNC_PHYSEC_FAULT_BELONG_ROUTE ((UINT8)0x90) /* PhySecFaultUnlockRouteCheck */ +#define EFUNC_LOGSEC_FAULT_FIRST_SECLOCK ((UINT8)0x91) /* LogicSecFaultUnlockLogicManage */ +#define EFUNC_LOGSEC_LAST_SECLOCK ((UINT8)0x92) /* CheckLogRouteLogSecLastSecLock */ + +#define EFUNC_ROUTE_ZHONGTUZHEFAN_UNLOCK ((UINT8)0x94) /* CheckRouteZhefanJiesuo */ + +/*߼·ر*/ +#define EFUNC_LogRouteOpenManage ((UINT8)0xC1) /*EFUNC_LogRouteOpenManage߼·źſŴ*/ +#define EFUNC_SetLogRouteCheckProcess ((UINT8)0xC2) /*SetLogRouteCheckProcess߼·*/ +#define EFUNC_LockLogRouteCheckProcess ((UINT8)0xC3) /*LockLogRouteCheckProcess߼·*/ +#define EFUNC_KeepLogRouteSignalProcess ((UINT8)0xC4) /*KeepLogRouteSignalProcessֿ߼·ź*/ +#define EFUNC_OpenLogRouteSignalProcess ((UINT8)0xC5) /*LogRouteSignalProcess߼·ź*/ +#define EFUNC_LOGROUTE_LOGIC_RES_APP_CHECK ((UINT8)0xC6) /*߼·߼ԴԼ*/ +#define EFUNC_LogRoureUsingStateCheck ((UINT8)0xC7) /*LogRoutePhySecUseLogicProcess*/ +/**/ +#define EFUNC_LOGIC_MANAGE_SYETEM ((UINT8)0xF0) /* Logicmanage.cе崻쳣 */ +#define EFUNC_CHECK_ROUTE_SEC_FLOCK ((UINT8)0xF1) /* RouteSecFlockVainCheck */ +#define EFUNC_CHECK_OLAP_SEC_FLOCK ((UINT8)0xF2) /* RouteOverlapSecFlockVainCheck */ +#define EFUNC_CHECK_FORCE_SWITCH_MOVE ((UINT8)0xF3) /* GetSwitchForceMoveValidState */ +#define EFUNC_CHECK_SWITCH_MOVE ((UINT8)0xF4) /* GetSwitchMoveValidState */ +#define EFUNC_CHECK_SWITCHPOS_MOVEVALID ((UINT8)0xF5) /* RouteSwitchPosAndMoveValidCheck */ +#define EFUNC_CHECK_NON_SWITCH_MOVE ((UINT8)0xF6) /* NonRouteSwitchPosMovValCheck */ +#define EFUNC_CHECK_LABOUR_CANCEL_VALID ((UINT8)0xF7) /*CancleLinShiXianSuManage*/ +#define EFUNC_LEAD_ROUTE_MANAGE_ERROR ((UINT8)0xF8) /* SetLeadRouteLogicManage */ + +#define EFUNC_SET_AIRSHAFT_ERROR ((UINT8)0xFC) /* SetCommonRouteLogicManage羮·ʧ */ + +#define EFUNC_LEU_CI_COMM_FAULT ((UINT8)0xF9) /*LEU-CIͨŹ*/ +#define EFUNC_PLAT_OVER ((UINT8)0xFA) /*崻*/ +#define EFUNC_ROUTE_ZRJ_DEAL ((UINT8)0xFD) /*RouteZongRenJieProc˽·*/ +#define EFUNC_SWITCH_DRIVE_OUTTIME ((UINT8)0xFB) /*ձʱʱ*/ +#define EFUNC_PHYSEC_RESET_PROC ((UINT8)0xFE) /*μḴλ̵״̬ʱܸλ̵*/ + +#define EFUNC_SIGNAL_LEAD_OPEN_LOCK ((UINT8)0xD0) /*ؿźLeadzLockNewOpenManage*/ + +#define EFUNC_FIRSTLEAVE_LOGSEC_CHECK ((UINT8)0xD1) /*ȥ߼μRouteLeaveLogSecCheck*/ + + +/*************************************************ֽ******************************************************************************/ +/*************************************************ֽ******************************************************************************/ + +/* */ +/* ·ͱ (UINT8)0x01-(UINT8)0x2f */ +/* 豸 CI_DEVICE_TYPE_ROUTE */ +#define ETYPE_ROUTE_LEVEL ((UINT8)0x01) /*·ල*/ +#define ETYPE_ROUTE_TYPE ((UINT8)0x02) /*·*/ +#define ETYPE_ROUTE_STATE ((UINT8)0x03) /*·״̬*/ +#define ETYPE_ROUTE_LEAD_PROPERTY ((UINT8)0x04) /*·*/ +#define ETYPE_ROUTE_CANCEL ((UINT8)0x05) /*·ȡ*/ +#define ETYPE_ROUTE_OVERLAP_UNLOCK ((UINT8)0x06) /*Overlapδ*/ +#define ETYPE_ROUTE_OVERLAP_OCCUPY ((UINT8)0x07) /*Overlapռ*/ +#define ETYPE_ROUTE_FLYING_TRAIN ((UINT8)0x08) /*·ɳ*/ +#define ETYPE_RETURN_ROUTE_STATE ((UINT8)0x09) /*۷·״̬*/ +#define ETYPE_ROUTE_FIRST_XUANPAI_OVERTIME ((UINT8)0x0a) /*·ѡųʱ*/ +#define ETYPE_ROUTE_APPLY_SWITCH_CHECK ((UINT8)0x0b) /*·״̬*/ +#define ETYPE_ROUTE_XUANPAI_OVERTIME ((UINT8)0x10) /*·ѡųʱ*/ +#define ETYPE_GROUP_AUTO_ROUTE_STATE ((UINT8)0x16) /*Զ·*/ + + +#define ETYPE_COMM_WITH_VOBC ((UINT8)0x11) /*VOBCͨ*/ +#define ETYPE_COMM_WITH_ZC ((UINT8)0x12) /*ZCͨ*/ +#define ETYPE_COMM_WITH_CI ((UINT8)0x13) /*CIͨ*/ + +#define ETYPE_COMM_WITH_NEIGHBOUR_CI ((UINT8)0x14) /*CIͨ*/ +#define ETYPE_COMM_WITH_PSC ((UINT8)0x15) /*CIPSCͨ*/ + +#define ETYPE_COMM_WITH_TMC ((UINT8)0x17) /*TMCͨ*/ + +/* źŻͱ (UINT8)0x21-(UINT8)0x3f */ +/* 豸 CI_DEVICE_TYPE_SIGNAL */ +#define ETYPE_SIG_START_OPEN_STATE ((UINT8)0x21) /*ʼźŻ״̬/رգ*/ +#define ETYPE_SIG_FLOCK_STATE ((UINT8)0x22) /*źŻ״̬(δ/)*/ +#define ETYPE_SIG_ENEMY_STATE ((UINT8)0x23) /*жźŻ״̬/رգ*/ +#define ETYPE_SIG_NEED_CLOSE_STATE ((UINT8)0x24) /*·رźŻ״̬/رգ*/ +#define ETYPE_SIG_NEED_OPEN_STATE ((UINT8)0x25) /*·迪źŻ״̬/رգ*/ +#define ETYPE_SIG_ONE_OPEN_STATE ((UINT8)0x26) /*·ͬʱźŻ״̬/رգ*/ +#define ETYPE_SIG_CLOSE_OVER_TIME ((UINT8)0x27) /*źŻرճʱ*/ +#define ETYPE_SIG_OPEN_OVERTIME ((UINT8)0x28) /*źųʱ*/ +#define ETYPE_SIG_RETURN_DS_STATE ((UINT8)0x29) /*۷źŻ˿*/ +#define ETYPE_SIG_RETURN_OPENED_STATE ((UINT8)0x30) /*۷źŻǷ񿪷Ź*/ +#define ETYPE_SIG_PRO_SEC_VALID ((UINT8)0x31) /*źŻЧ*/ +#define ETYPE_SIG_LIGHT_EXTINCT ((UINT8)0x32) /*źŻǿƵ״̬*/ +#define ETYPE_SIG_YDROUTE_SEARCH_ERR ((UINT8)0x7f) /*ԱźŻ·*/ +#define ETYPE_SIG_LEAD_ALL_LOCK ((UINT8)0x3F) /*·źſ㣬ȫվѰ*/ + +/*Զ*/ +#define ETYPE_AUTO_ROUTE_FLAG ((UINT8)0x33) /* Զͨ· */ +#define ETYPE_AUTO_RETURN_FLAG ((UINT8)0x34) /* Զ۷ */ +#define ETYPE_ALL_AUTO_RETURN_FLAG ((UINT8)0x35) /* ȫԶ۷ */ +#define ETYPE_AUTO_TRAGGER_FLAG ((UINT8)0x36) /* Զ */ + +#define ETYPE_SIG_ENDSIGNAL_DS ((UINT8)0x37) /*նźŻ˿*/ + +#define ETYPE_SIG_CROSS ((UINT8)0x38) /*źŻѹ*/ + +#define ETYPE_PHY_MUTY_AXISSEC_JUMPLOCK_APPLY ((UINT8)0x39) /*ͬһζԾ*/ + +#define ETYPE_JUMP_LOCK_DIAOCE_ROUTE_LOCK ((UINT8)0x3a) /*Ծα·*/ + +/* ιͱ (UINT8)0x41-(UINT8)0x5f */ +/* 豸 CI_DEVICE_TYPE_PHYSEC */ +#define ETYPE_PS_MERGY_OCU_STATE ((UINT8)0x41) /*ںϺ״̬(/ռ)*/ +#define ETYPE_PS_LOCK_STATE ((UINT8)0x42) /*״̬*/ +#define ETYPE_PS_INTRU_OCU_STATE ((UINT8)0x43) /*ںϺ״̬ռûջ*/ +#define ETYPE_PS_RUNLOCK_ERROR ((UINT8)0x44) /*۷쳣*/ +#define ETYPE_PS_AUNLOCK_ERROR ((UINT8)0x45) /*Զ쳣*/ +#define ETYPE_PS_USE_STATE ((UINT8)0x46) /*״̬*/ +#define ETYPE_PS_FLOCK_STATE ((UINT8)0x47) /*η*/ +#define ETYPE_PS_UNFLOCK_STATE ((UINT8)0x50) /*δ*/ +#define ETYPE_PS_ZHAOCHA_CHECK ((UINT8)0x48) /*ղ*/ +#define ETYPE_PS_JUMP_LOCK ((UINT8)0x49) /*Ծ*/ +#define ETYPE_PS_INSTRU ((UINT8)0x4a) /**/ +#define ETYPE_PS_NO_UT_CT_OCU_STATE ((UINT8)0x4b) /*γռ״̬(޳/UT/CT)*/ +#define ETYPE_PS_STOPSTEADY_STATE ((UINT8)0x4cU) /*ͣ״̬*/ +#define ETYPE_PS_LJJL_NAMAL_BUT_LOGEXCEPT ((UINT8)0x4d) /*߼·յ߼߼쳣*/ +#define ETYPE_PS_LJJL_PHYJL_ALL_NAMAL ((UINT8)0x4E) /*߼··ͬʱ*/ +#define ETYPE_PS_NONROUTE_SET ((UINT8)0x4F) /*ǽ·Ѱ*/ +/**/ +#define ETYPE_OVERLAP_LABORUNLOCK_FAIL ((UINT8)0x51U) /*˹*/ +#define ETYPE_OVERLAP_RES_CHECK_FAIL ((UINT8)0x52U) /*Դ*/ + +/* ͱ (UINT8)0x61-(UINT8)0x7f */ +/* 豸 CI_DEVICE_TYPE_SWITCH */ +#define ETYPE_SWT_YLOCK_STATE ((UINT8)0x61) /*״̬*/ +#define ETYPE_SWT_FLOCK_STATE ((UINT8)0x62) /*״̬*/ +#define ETYPE_SWT_LOCK_STATUS ((UINT8)0x63) /*״̬*/ +#define ETYPE_SWT_POSTION_STATE ((UINT8)0x64) /*λ*/ +#define ETYPE_SWT_MOVE_INVALID ((UINT8)0x65) /*ɶ*/ +#define ETYPE_SWT_MOVE_OVERTIME ((UINT8)0x66) /*ճʱ*/ +#define ETYPE_SWT_USE_STATE ((UINT8)0x6aU) /**/ +#define ETYPE_SWT_MOVE_STATE ((UINT8)0x6bU) /*ᶯ״̬*/ +#define ETYPE_SWT_MOVE_CHECK_RESULT ((UINT8)0x6cU) /*ɶԼ*/ + +/* ̵ͱ (UINT8)0x81-(UINT8)0x8f */ +/* 豸 CI_DEVICE_TYPE_RELAY */ +#define ETYPE_THAT_ZHAOCHA ((UINT8)0x81) /*Զղ̵*/ +#define ETYPE_THIS_ZHAOCHA ((UINT8)0x85) /*ղ̵*/ +#define ETYPE_CANCLE_ZHAOCHA ((UINT8)0x82) /*ȡղ̵*/ +#define ETYPE_ZHAOCHA_ROUTE_OVERTIME ((UINT8)0x83) /*·ղ鳬ʱ*/ +#define ETYPE_JKJ_WORK ((UINT8)0x84) /*ӦЧ*/ + +/* عͱ (UINT8)0x91-(UINT8)0x9f */ +/* 豸 + CI_DEVICE_TYPE_PLATFORM + CI_DEVICE_TYPE_ESB + CI_DEVICE_TYPE_PSD +*/ +#define ETYPE_ESB_VALID ((UINT8)0x91) /*ťЧ*/ +#define ETYPE_PSD_CLOSE_NO ((UINT8)0x92) /*δر*/ +#define ETYPE_PSD_MUTUALLOCK ((UINT8)0x93) /*Ż*/ +#define ETYPE_PLAT_DETAIN ((UINT8)0x94) /*վ̨۳*/ +#define ETYPE_WASH_MACHINE_UNVALID ((UINT8)0x95) /* ϴδ */ +#define ETYPE_OTHER_GARAGEDOOR_OPEN_NO ((UINT8)0x96) /* δ */ +#define ETYPE_OTHER_SIGNAL_OPEN_CHECK ((UINT8)0x97) /* źſʧ */ +#define ETYPE_OTHER_SIGNAL_CHECK ((UINT8)0x98) /* źŻʧ */ +#define ETYPE_OTHER_SWITCH_POSITION_ERROR ((UINT8)0x99) /* ָλ */ +#define ETYPE_SPKS_STATE_UP ((UINT8)0x9A) /* SPKSť */ +#define ETYPE_GARAGEDOOR_STATE_MODE_LOCAL ((UINT8)0x9B) /* ſģʽΪ */ +#define ETYPE_GARAGEDOOR_FAULT ((UINT8)0x9C) /* Ź*/ + +#define ETYPE_GARDOOR_NOT_RECV_ZC_GMXK ((UINT8)0x9D) /* ŹرδյZCظر*/ +#define ETYPE_GARAGEDOOR_PANGLU ((UINT8)0x80) /*Ϊ·״̬*/ +#define ETYPE_GARAGEDOOR_DRIVE_INVALID ((UINT8)0x81) /*ŵǰλãЧ*/ + + +#define ETYPE_PHYSEC_OCCUPY ((UINT8)0x9E) /*ռźţ2018.9.19»*/ +#define ETYPE_OTHER_WASH_LINE_NOT_ALLOW ((UINT8)0x9F) /*ϴϴ̵ͬXTJδ𣬾ϴߵĽ·ź*/ +#define ETYPE_OTHER_DOWNWASH_NOT_ALLOW_PASS ((UINT8)0x90) /*ϴͬͨťδ£ϴߵĽ·ź*/ +#define ETYPE_OTHER_ROUTE_CHECK ((UINT8)0x70) /*·迪Ž·ʧ*/ + + +/*г*/ +#define ETYPE_GARDOOR_NOT_RECV_IVOC_GMXK ((UINT8)0x71) /* ŹرδյIVOCظر*/ +#define ETYPE_GDOOR_TRAIN_HEADSCREEN ((UINT8)0x73) /* гǰɸѡ*/ +#define ETYPE_GDOOR_TRAIN_TAILSCREEN ((UINT8)0x74) /* гɸѡ*/ +#define ETYPE_GDOOR_TRAIN_KUAYAGD ((UINT8)0x75) /* гѹ*/ + + + +/* ʱ */ +/* 豸 EFUNC_LOGIC_MANAGE_TIMEER */ +#define ETYPE_TIMEER_COUNT_LEAD ((UINT8)0xA1) /*źŹϵʱ*/ +#define ETYPE_TIMEER_COUNT_ZONGRENJIE ((UINT8)0xA2) /*˽⵹ʱ*/ +#define ETYPE_TIMEER_COUNT_SECFAULT ((UINT8)0xA3) /*ʽ⵹ʱ*/ + +/*Źͱ (UINT8)0xB0-(UINT8)0xBF*/ +#define ETYPE_FLOODGATE_OPENLOCKSTATE ((UINT8)0xB0)/*ſ״̬*/ +#define ETYPE_FLOODGATE_CLOSEREQSTATE ((UINT8)0xB1)/*Ź״̬*/ +#define ETYPE_FLOODGATE_AGREECLOSESTATE ((UINT8)0xB2)/*Żزͬ״̬*/ +#define ETYPE_FLOODGATE_CLOSESTATE ((UINT8)0xB3)/*Ź״̬*/ + +#define ETYPE_DCTY_NOT_SATIFY ((UINT8)0xB4) /*ͬⲻ*/ +#define ETYPE_DCTY_REOPEN_TIMING_BREAK ((UINT8)0xB5) /*㣬ͬؿʱж*/ +#define ETYPE_TRAIN_TEST_OFF ((UINT8)0xB6) /*δԳģʽЧ*/ +#define ETYPE_DCTY_REOPEN_TIMEOUT ((UINT8)0xB7) /*·XXȴͬⳬʱ*/ +#define ETYPE_FLOOD_GATE_YGJ_CROSS_LINE ((UINT8)0xB8) /*YGJ*/ + +/* ߼ιͱ (UINT8)0xC1-(UINT8)0xCF */ +/*豸 CI_DEVICE_TYPE_LOGICSEC*/ +#define ETYPE_LOGSEC_LINSHIXIANSU_CANCLE_STATE ((UINT8)0xC1) /*߼ʱ˹ȡ*/ +#define ETYPE_PSC_CONFIRM_PL_STATE ((UINT8)0xC2) /*ATSȡPSC·ȷ״̬*/ +#define ETYPE_LOGSEC_OCC_STATE ((UINT8)0xC3) /*߼ռ״̬ᶯʹã*/ +#define ETYPE_LOGSEC_LOCK_STATE ((UINT8)0xC4) /*߼״̬ᶯʹã*/ +#define ETYPE_LOGSEC_XIANSU_STATE ((UINT8)0xC5) /*߼*/ +#define ETYPE_LOGSEC_FIRSTLOCK_STATE ((UINT8)0xC6) /*߼Ϊһμ*/ +#define ETYPE_LOGSEC_CBTC_PROPERTY ((UINT8)0xC7) /*߼CBTCԼ*/ + +/* ϵͳ */ +/* 豸 EFUNC_LOGIC_MANAGE_SYETEM */ +#define ETYPE_SYSTEM_SIGNAL_OPEN ((UINT8)0xF1) /* δźŻ */ +#define ETYPE_SYSTEM_EXCEPT ((UINT8)0xF2) /* ϵͳ״̬쳣 */ +#define ETYPE_SYSTEM_STARTLOCKE_ERROR ((UINT8)0xF3) /* ϵ쳣 */ +#define ETYPE_SYSTEM_REL_UPDATA_ERROR ((UINT8)0xF4) /* ̵ʧ */ +#define ETYPE_SYSTEM_SIG_UPDATA_ERROR ((UINT8)0xF5) /* źŻʧ */ +#define ETYPE_SYSTEM_SEC_UPDATA_ERROR ((UINT8)0xF6) /* θʧ */ +#define ETYPE_SYSTEM_SWT_UPDATA_ERROR ((UINT8)0xF7) /* ʧ */ + +#define ETYPE_LEU_CI_COMM_ALL_STATE_FAULT ((UINT8)0xF8) /*CI-LEUijLEUͨŹ*/ +#define ETYPE_LEU_CI_COMM_CHANNEL_SWITCH_FAULT ((UINT8)0xF9) /*CI-LEUijLEUͨл*/ + +/*Ϸͼ*/ +#define ESEND_LEVEL_ZERO ((UINT8)0x00) /* ֻ¼ */ +#define ESEND_LEVEL_ATS ((UINT8)0x01) /* ֵֻغATS */ + +#define ETYPE_DATA_CFG_ERR ((UINT8)0xFA) /*ô */ + + /*ΪSCADE޸ģͣηΪSPKSʱǴͣerrorcodeʱٷֱerrorcode */ +#define ETYPE_PS_FLOCK_SPKSCMD_STATE ((UINT8)0xAFU) + + + +#endif diff --git a/TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.c b/TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.c new file mode 100644 index 0000000..50767dc --- /dev/null +++ b/TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.c @@ -0,0 +1,665 @@ +/******************************************************** +* +* ESBConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ͣťݹ +* ޸ļ¼ +* +********************************************************/ + +#include "ESBConfigDataManage.h" + + + + +EsbConfigDataStruct EsbConfigDataStru[ESB_SUM_MAX]; /*ESBýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiEsbIdBuf[ESB_SUM_MAX] = {0u}; /*屾ͣťIDӳ*/ +INT16 EsbCurSum = 0; /*ESBǰ*/ +UINT16 totalEsbNum = 0u;/*͸ESB*/ + + + + +/* +* ȡͣǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ͣǰ +*/ +UINT16 GetEsbSum(void) +{ + UINT16 reVal = 0u; + + if (EsbCurSum >= (INT16)ESB_SUM_MAX) + { + reVal = ESB_SUM_MAX; + } + else if (EsbCurSum < 0) + { + reVal = 0u; + } + else + { + reVal = (UINT16)EsbCurSum; + } + return reVal; +} + +/* +* ȡָ±ӦĽͣID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ͣID +*/ +UINT16 GetEsbId(const UINT16 bufIndex) +{ + UINT16 reVal = CI_ERROR; + + if (bufIndex < GetTotalEsbCurNum()) + { + reVal = LocalCiEsbIdBuf[bufIndex]; + } + return reVal; +} + +/* +* ȡָIDͣť +* ˵ const UINT16 esbId, ͣťID +* ֵ ESB_SUM_MAX: ȡʧ +* = 1u) && (esbId < ESB_SUM_MAX)) + { + reVal = esbId; + } + + return reVal; +} + + + + +/* +* ȡָIDվ̨ͣťID +* ˵ const UINT16 esbId, վ̨ͣťID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetEsbBelongCiId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].BelongCiId; + } + return reVal; +} + +/* +* ȡָIDվ̨ͣťվ̨ID +* ˵ const UINT16 esbId, վ̨ͣťID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetEsbBelongPlatFormId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].BelongPlatFormId; + } + return reVal; +} +/* +* ȡָIDͣť̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť̵ID +*/ +UINT16 GetEsbRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].EsbRelayId; + } + return reVal; +} + + + + +/* +* ȡָIDͣť·̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť̵ID +*/ +UINT16 GetEsbCutRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].EsbCutRelayId; + } + return reVal; +} + + +/* +* ESB +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 EsbConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 esbConfigDataSum = 0u; /*ESB豸*/ + UINT8 reVal = CI_SUCCESS; + + /*ESBID*/ + esbConfigDataSum = GetEsbSum(); + totalEsbNum = esbConfigDataSum; + if (esbConfigDataSum >= ESB_SUM_MAX) + {/**/ + + reVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < ESB_SUM_MAX; ii++) + { + if (jj == esbConfigDataSum) + {/*Ч*/ + + break; + } + + if (EsbConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + + LocalCiEsbIdBuf[jj] = EsbConfigDataStru[ii].EsbId; + jj++; + } + } + } + + + return reVal; +} + +/* +* ESB +* ˵ esbSum · +* esbIdBuff ͸ESBID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendEsbIdDataManage(UINT16 esbSum,const UINT16 *esbIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if ((totalEsbNum + esbSum) >= ESB_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = totalEsbNum; + totalEsbNum += esbSum; + for(ii = 0u;ii< esbSum;ii++) + { + LocalCiEsbIdBuf[index+ii] = esbIdBuff[ii];/*׷ӵLocalCiEsbIdBuf*/ + } + } + + return retVal; +} + +/* +* ȡ͸ԼESBǰ +* ˵ void +* ֵ 0: ȡʧ +* >0С ESB_SUM_MAX : ESBǰ +*/ +UINT16 GetTotalEsbCurNum(void) +{ + UINT16 retVal = 0u; + if (totalEsbNum >= ESB_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = totalEsbNum; + } + return retVal; +} + +/* +* ȡָID ESB +* ˵ const UINT16 esbId, ESB ID +* ֵ 0: ȡʧ +* >0: ESB +*/ +UINT8 GetEsbVirtualAttribute(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡESB±*/ + + if (bufIndex < ESB_SUM_MAX) + { + retVal = EsbConfigDataStru[bufIndex].VirtualAttribute; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/***********ֽ esbʾ̵********************************************/ +/* +* ȡָID ESBʾ̵ID +* ˵ const UINT16 esbId +* ֵ 0: ȡʧ +* >0: esbӼ̵ID +*/ +UINT16 GetEsbRepRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡESB±*/ + + if (bufIndex < ESB_SUM_MAX) + { + retVal = EsbConfigDataStru[bufIndex].EsbRepRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + + +/* +* ȡָIDͣťָʾƼ̵ID +* ˵ const UINT16 esbId, ͣťָʾID +* ֵ 0: ȡʧ +* >0: ͣťָʾƼ̵ID +*/ +UINT16 GetEsbDisRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].EsbDisRelayId; + } + return reVal; +} + +/* +* ȡָIDͣť·ָʾƼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť̵ID +*/ +UINT16 GetEsbCutDisRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].EsbCutDisRelayId; + } + return reVal; +} +/* +* ȡָIDվ̨ͣťID +* ˵ const UINT16 esbId, վ̨ͣťID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetEsbBelongVirCiId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].BelongVirCiId; + } + return reVal; +} + +/* +* ȡָIDվ̨ͣťӦķ̵ID +* ˵ const UINT16 esbId, վ̨ͣťID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetEsbBuzzRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + /*ط̵ID*/ + reVal = EsbConfigDataStru[bufIndex].EsbBuzzRelayId; + } + else + { + /**/ + } + return reVal; +} + +/* +* ȡָIDͣť̵ID 2 +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť̵ID +*/ +UINT16 GetEsbRelayId2(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].wEsbRelayId2; + } + return reVal; +} +/* +* ȡָIDͣؼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣؼ̵ID +* cgh-ϲCID-2349-3 +*/ +UINT16 GetESSRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].ESSRelayId; + } + return reVal; +} + + +/* +* ȡָIDͣȵƼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣȵƼ̵ID +* cgh-ϲCID-2349-3 +*/ +UINT16 GetESSSteadyIndicatRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].ESSSteadyIndicatRelayId; + } + return reVal; +} + +/* +* ȡָIDָͣʾƼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣƼ̵ID +* cgh-ϲCID-2349-3 +*/ +UINT16 GetESSFlashIndicatRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].ESSFlashIndicatRelayId; + } + return reVal; +} +/* +* ȡָͣӦESSȵƼ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ̵ID +* cgh-ϲCID-2349-3\cgh-ϲCID-3037-1 +*/ +UINT16 GetEssSteadyIndicatId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].ESSSteadyIndicatRelayId; + } + return reVal; +} + +/* +* ȡָͣӦESSƼ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ̵ID +* cgh-ϲCID-2349-3\cgh-ϲCID-3037-1 +*/ +UINT16 GetEssFlashIndicatId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].ESSFlashIndicatRelayId; + } + return reVal; +} + +/* +* ȡָESBӦATS-CIESSȵ״̬λǷñ־ +* ˵ UINT16 esbId ESBID +* ֵ ESS_MASK_NO δ +* ESS_MASK_YES +* cgh-ϲCID-2349-3 +*/ +UINT8 GetEssSteadyCiToAtsMaskFlag(UINT16 esbId) +{ + UINT8 reVal = ESS_MASK_NO; + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + reVal = EsbConfigDataStru[bufIndex].ConfigAtsCiEssSteadyMask; + } + return reVal; +} + +/* +* ȡָESBӦATS-CIESS״̬λǷñ־ +* ˵ UINT16 esbId ESBID +* ֵ ESS_MASK_NO δ +* ESS_MASK_YES +* cgh-ϲCID-2349-3 +*/ +UINT8 GetEssFlashCiToAtsMaskFlag(UINT16 esbId) +{ + UINT8 reVal = ESS_MASK_NO; + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + reVal = EsbConfigDataStru[bufIndex].ConfigAtsCiEssFlashMask; + } + return reVal; +} + +/* +* ȡָIDͣťȡͣť̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ȡͣť̵ID +*/ +UINT16 GetCancelEsbRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].CancelEsbRelayId; + } + return reVal; +} + +/* +* ȡָIDͣťվָ̨ʾƼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣťվָ̨ʾƼ̵ID +*/ +UINT16 GetEsbPlatformDisRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].EsbPlatformDisRelayId; + } + return reVal; +} + +/* +* ȡָIDͣťг̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣťг̵ID +*/ +UINT16 GetEsbCutoffBuzzRelayId(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbConfigDataStru[bufIndex].EsbCutoffBuzzRelayId; + } + return reVal; +} + +/* +* EsbǷڴ䷶Χ +* ˵ const UINT16 wCheckEsbId, EsbID +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20240621 +*/ +UINT8 CheckEsbBelSendRange(const UINT16 wCheckEsbId) +{ + UINT8 retVal = CI_ERROR; + UINT16 wEsbSum = 0U;/*EsbĿ*/ + UINT16 ii = 0U; + UINT16 wEsbId = 0U;/*Esb ID*/ + + if ((0U < wCheckEsbId) && (ESB_SUM_MAX > wCheckEsbId)) + { + /*ʼ*/ + retVal = CI_SUCCESS; + wEsbSum = GetTotalEsbCurNum(); + for (ii = 0U; ii < wEsbSum; ii++) + { + wEsbId = GetEsbId(ii);/*ȡļиµPSD ID*/ + if (wCheckEsbId == wEsbId) + { + retVal = CI_ERROR; + break; + } + else + { + ; /*do nothing*/ + } + } + } + else + { + ; /**/ + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.h b/TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.h new file mode 100644 index 0000000..1015dc0 --- /dev/null +++ b/TSCP/src/APP/ciapp/ESB/ESBConfigDataManage.h @@ -0,0 +1,300 @@ +/******************************************************** +* +* ESBConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ͣťݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ESB_CONFIG_DATA_MANAGE_H_ +#define _ESB_CONFIG_DATA_MANAGE_H_ + + +#include "ESBDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*ͣťӿݽṹ*/ +typedef struct S_EsbConfigDataStruct +{ + UINT16 EsbId; /*ͣťID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 BelongVirCiId; /*ID*/ + UINT16 BelongPlatFormId; /*ͣťվ̨ID*/ + UINT16 EsbRelayId; /*ͣťؼ̵ID (ֶ)*/ + UINT16 wEsbRelayId2; /*˹ͣťؼ̵ID 2(ֶ)*/ + UINT16 EsbDisRelayId; /*ͣťʾؼ̵ID (ֶ)*/ + UINT16 EsbCutRelayId; /*ͣť·̵ID (ֶ)*/ + UINT16 EsbCutDisRelayId; /*ͣť·ʾƼ̵ID (ֶ)*/ + UINT16 EsbRepRelayId; /*ʾڽͣťؼ̵ID (ֶ)*/ + UINT16 EsbBuzzRelayId; /*̵ͣID*/ + UINT8 VirtualAttribute; /*ֶ*/ + UINT16 ESSRelayId; /*ͣؼ̵ID*/ + UINT16 ESSSteadyIndicatRelayId; /*ͣȵƼ̵ID*/ + UINT16 ESSFlashIndicatRelayId; /*ͣƼ̵ID*/ + UINT16 CancelEsbRelayId; /*ȡͣťɼ̵ID*/ + UINT16 EsbPlatformDisRelayId; /*ͣťվָ̨ʾƼ̵ID*/ + UINT16 EsbCutoffBuzzRelayId; /*г̵ID*/ + UINT8 ConfigAtsCiEssSteadyMask; /*ǷATS-CIȵ״̬λ0x55 ã0xaaδ*/ + UINT8 ConfigAtsCiEssFlashMask; /*ǷATS-CI״̬λ0x55 ã0xaaδ*/ +} EsbConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern EsbConfigDataStruct EsbConfigDataStru[ESB_SUM_MAX]; /*ESBýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiEsbIdBuf[ESB_SUM_MAX]; /*屾ͣťIDӳ*/ +extern INT16 EsbCurSum; /*ESBǰ*/ +extern UINT16 totalEsbNum;/*͸ESB*/ + +/* +* ȡͣǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ͣǰ +*/ +UINT16 GetEsbSum(void); + +/* +* ȡָ±ӦĽͣID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ͣID +*/ +UINT16 GetEsbId(const UINT16 bufIndex); + +/* +* ȡָIDͣť +* ˵ const UINT16 esbId, ͣťID +* ֵ ESB_SUM_MAX: ȡʧ +* 0: ID +*/ +UINT8 GetEsbBelongCiId(const UINT16 esbId); + +/* +* ȡָIDվ̨ͣťվ̨ID +* ˵ const UINT16 esbId, վ̨ͣťID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetEsbBelongPlatFormId(const UINT16 esbId); + +/* +* ȡָIDͣť̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť̵ID +*/ +UINT16 GetEsbRelayId(const UINT16 esbId); + +/* +* ȡָIDͣť̵ID 2 +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť̵ID +*/ +UINT16 GetEsbRelayId2(const UINT16 esbId); + +/* +* ȡָIDͣť·̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť̵ID +*/ +UINT16 GetEsbCutRelayId(const UINT16 esbId); + +/* +* ESB +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 EsbConfigDataManage(void); + +/* +* ESB +* ˵ esbSum ESB +* esbIdBuff ͸ESBID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendEsbIdDataManage(UINT16 esbSum,const UINT16 *esbIdBuff); + +/* +* ȡ͸ԼESBǰ +* ˵ void +* ֵ 0: ȡʧ +* >0С ESB_SUM_MAX: ESBǰ +*/ +UINT16 GetTotalEsbCurNum(void); + +/* +* ȡָID ESB +* ˵ const UINT16 esbId, ESB ID +* ֵ 0: ȡʧ +* >0: ESB +*/ +UINT8 GetEsbVirtualAttribute(const UINT16 esbId); + +/* +* ȡָID ESBʾ̵ID +* ˵ const UINT16 esbId +* ֵ 0: ȡʧ +* >0: esbӼ̵ID +*/ +UINT16 GetEsbRepRelayId(const UINT16 esbId); + + + +/* +* ȡָIDͣťָʾƼ̵ID +* ˵ const UINT16 esbId, ͣťָʾID +* ֵ 0: ȡʧ +* >0: ͣťָʾƼ̵ID +*/ +UINT16 GetEsbDisRelayId(const UINT16 esbId); + + +/* +* ȡָIDͣť·ָʾƼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť̵ID +*/ +UINT16 GetEsbCutDisRelayId(const UINT16 esbId); + +/* +* ȡָIDվ̨ͣťID +* ˵ const UINT16 esbId, վ̨ͣťID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetEsbBelongVirCiId(const UINT16 esbId); + +/* +* ȡָIDվ̨ͣťӦķ̵ID +* ˵ const UINT16 esbId, վ̨ͣťID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetEsbBuzzRelayId(const UINT16 esbId); +/* +* ȡָIDͣؼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣؼ̵ID +* cgh-ϲCID-2349-3 +*/ +UINT16 GetESSRelayId(const UINT16 esbId); + + +/* +* ȡָIDͣȵƼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣȵƼ̵ID +* cgh-ϲCID-2349-3 +*/ +UINT16 GetESSSteadyIndicatRelayId(const UINT16 esbId); + +/* +* ȡָIDָͣʾƼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣƼ̵ID +* cgh-ϲCID-2349-3 +*/ +UINT16 GetESSFlashIndicatRelayId(const UINT16 esbId); +/* +* ȡָͣӦESSȵƼ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ̵ID +* cgh-ϲCID-2349-3 +*/ +UINT16 GetEssSteadyIndicatId(const UINT16 esbId); + +/* +* ȡָͣӦESSƼ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ̵ID +* cgh-ϲCID-2349-3 +*/ +UINT16 GetEssFlashIndicatId(const UINT16 esbId); + +/* +* ȡָESBӦATS-CIESSȵ״̬λǷñ־ +* ˵ UINT16 esbId ESBID +* ֵ ESS_MASK_NO δ +* ESS_MASK_YES +* cgh-ϲCID-2349-3 +*/ +UINT8 GetEssSteadyCiToAtsMaskFlag(UINT16 esbId); + +/* +* ȡָESBӦATS-CIESS״̬λǷñ־ +* ˵ UINT16 esbId ESBID +* ֵ ESS_MASK_NO δ +* ESS_MASK_YES +* cgh-ϲCID-2349-3 +*/ +UINT8 GetEssFlashCiToAtsMaskFlag(UINT16 esbId); + +/* +* ȡָIDͣťȡͣť̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ȡͣť̵ID +*/ +UINT16 GetCancelEsbRelayId(const UINT16 esbId); + +/* +* ȡָIDͣťվָ̨ʾƼ̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣťվָ̨ʾƼ̵ID +*/ +UINT16 GetEsbPlatformDisRelayId(const UINT16 esbId); + +/* +* ȡָIDͣťг̵ID +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣťг̵ID +*/ +UINT16 GetEsbCutoffBuzzRelayId(const UINT16 esbId); + +/* +* EsbǷڴ䷶Χ +* ˵ const UINT16 wCheckEsbId, EsbID +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20240621 +*/ +UINT8 CheckEsbBelSendRange(const UINT16 wCheckEsbId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ESB/ESBDataManage.c b/TSCP/src/APP/ciapp/ESB/ESBDataManage.c new file mode 100644 index 0000000..9e3a815 --- /dev/null +++ b/TSCP/src/APP/ciapp/ESB/ESBDataManage.c @@ -0,0 +1,800 @@ +/******************************************************** +* +* ESBDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ͣťݹ +* ޸ļ¼ +* +********************************************************/ + +#include "ESBDataManage.h" +#include "ESBConfigDataManage.h" + +EsbDataStruct EsbDataStru[ESB_SUM_MAX]; /*ESBݽṹ*/ + + +/* +* ȡָESB +* ˵ +* ֵ + EsbDataStruct * +*/ +EsbDataStruct *GetEsbData(void) +{ + return EsbDataStru; +} + +/* +* ȡָIDͣť״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť״̬ +*/ +UINT8 GetEsbState(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbDataStru[bufIndex].EsbState; + } + return reVal; +} + + +/* +* ָIDͣť״̬ +* ˵ const UINT16 esbId, ťID +* const UINT8 esbState, ť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetEsbState(const UINT16 esbId, const UINT8 esbState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + if ((ESB_STATE_VALID_NO == esbState) || (ESB_STATE_VALID_YES == esbState)) + { + EsbDataStru[bufIndex].EsbState = esbState; /*ͣť״̬*/ + + reVal = CI_SUCCESS; + } + } + return reVal; +} + +/* +* ȡָID ͣť·״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: spksť״̬ +*/ +UINT8 GetEsbCutState(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 status = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + status = EsbDataStru[bufIndex].CutStatus; + } + + return status; +} + +/* +* ָID ·״̬ +* ˵ const UINT16 esbId, ͣť +* const UINT8 esbCutState, ·״̬ +* ֵ +* +*/ +void SetEsbCutState(const UINT16 esbId, const UINT8 esbCutState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + if ((ESB_CUT_NO == esbCutState) || (ESB_CUT_YES == esbCutState)) + { + EsbDataStru[bufIndex].CutStatus = esbCutState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ESB״̬ʼ +* ˵ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 EsbDataManageInit(void) +{ + UINT8 rtn = CI_ERROR; /*ֵ*/ + UINT16 esbNum = 0u; /*ESB*/ + UINT16 i = 0u; /*ѭ*/ + UINT16 esbId = 0u; /*ESB ID*/ + UINT8 chEsbVirAttribute = 0u; + esbNum = GetTotalEsbCurNum(); + + for (i = 0u; i < esbNum; i++) + { + esbId = GetEsbId(i); + chEsbVirAttribute = GetEsbVirtualAttribute(esbId); + if (ESB_VIRTUAL_ATTR_YES == chEsbVirAttribute) + {/*ESBʼΪδ*/ + EsbDataStru[esbId].EsbState = ESB_STATE_VALID_NO; + EsbDataStru[esbId].EssState = ESB_STATE_GO_FLAG; + EsbDataStru[esbId].EsbActualState = ESB_STATE_VALID_NO; + } + else + {/*ESBʼΪ*/ + EsbDataStru[esbId].EsbState = ESB_STATE_VALID_YES; + EsbDataStru[esbId].EssState = ESB_STATE_STOP_FLAG; + EsbDataStru[esbId].EsbActualState = ESB_STATE_VALID_YES; + } + EsbDataStru[esbId].EssSteadyState = ESB_STATE_LIGHT_STATE_N;/*ESSȵ״̬δ*/ + EsbDataStru[esbId].EssFlashState = ESB_STATE_LIGHT_STATE_N;/*ESS״̬δ*/ + EsbDataStru[esbId].CutStatus = ESB_CUT_NO; /*ESB·δ*/ + EsbDataStru[esbId].EsbRelateRelayDriveState = ESB_PEPUP_ESSUP_INITION_STA; /*PEPESSЧ*/ + EsbDataStru[esbId].EsbErrorFlag = ESB_ERROR_FLAG_NO; /*ԸʽESBδ*/ + EsbDataStru[esbId].CancelEsbErrorFlag = ESB_ERROR_FLAG_NO; /*ԸʽȡESBδ*/ + EsbDataStru[esbId].EsbPressCycNum = 0U; /*رհť*/ + EsbDataStru[esbId].CancelEsbPressCycNum = 0U; /*ȡرհť*/ + EsbDataStru[esbId].CancelEsbErrTriggerPressCycNum = 0U; /*ȡرհť󴥷*/ + EsbDataStru[esbId].CancelEsbValidFlag = ESB_CANCEL_VALID_NO; /*ȡرհťЧ־*/ + EsbDataStru[esbId].CancelEsbRelayDownState = ESB_RELAY_ERROR_DOWN_YES; /*ȡرհťɼ̵״̬ʼΪͨ쳣*/ + } + rtn = CI_SUCCESS; + return rtn; +} + +/* +* ָESB IDؼ̵״̬ +* ˵ const UINT16 esbId, ͣť +* const UINT8 state, ״̬ +* ֵ +* cgh-ϲCID-2349-1 +*/ +void SetEsbRelateRelayDriveProState(const UINT16 esbId, const UINT8 state) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + /*״̬6״̬еһ*/ + if ((ESB_PEPUP_ESSUP_INITION_STA == state) || (ESB_PEPDOWN_ESSUP_TWO_STATE == state) || (ESB_PEPDOWN_ESSDOWN_THREE_STATE == state) + || (ESB_ONEPEPUP_ESSDOWN_FOUR_STATE == state) || (ESB_TWOPEPUP_ESSDOWN_FIVE_STATE == state) || (ESB_FAULT_SIX_STATE == state)) + { + EsbDataStru[bufIndex].EsbRelateRelayDriveState = state; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָESB IDؼ̵״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: esbؼ̵״̬ +* cgh-ϲCID-2349-1 +*/ +UINT8 GetEsbRelateRelayDriveProState(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 status = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + status = EsbDataStru[bufIndex].EsbRelateRelayDriveState; + } + + return status; +} + +/* +* ָESB IDӦESSȵ״̬ +* ˵ const UINT16 esbId, ͣť +* const UINT8 state, ״̬ +* ֵ +* cgh-ϲCID-2349-1\cgh-ϲCID-3037-1 +*/ +void SetEsbRelateEssSteadyState(const UINT16 esbId, const UINT8 state) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + if ((ESB_STATE_LIGHT_STATE_Y == state) || (ESB_STATE_LIGHT_STATE_N == state)) + { + EsbDataStru[bufIndex].EssSteadyState = state; + } + else + { + /**/ + } + } + else + { + /**/ + } +} +/* +* ȡָESB IDӦESSȵ״̬ +* ˵ const UINT16 esbId, ͣť +* ֵ +* עcgh-ϲCID-2349-1\cgh-ϲCID-3037-1 +*/ +UINT8 GetEsbRelateEssSteadyState(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 chEssSteadyState = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + if (bufIndex < ESB_SUM_MAX) + { + + chEssSteadyState = EsbDataStru[bufIndex].EssSteadyState; + } + else + { + /**/ + } + return chEssSteadyState; +} + + +/* +* ָESB IDӦESS״̬ +* ˵ const UINT16 esbId, ͣť +* const UINT8 state, ״̬ +* ֵ +* עcgh-ϲCID-2349-1 +*/ +void SetEsbRelateEssFlashState(const UINT16 esbId, const UINT8 state) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + if ((ESB_STATE_LIGHT_STATE_Y == state) || (ESB_STATE_LIGHT_STATE_N == state)) + { + EsbDataStru[bufIndex].EssFlashState = state; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָESB IDӦESS״̬ +* ˵ const UINT16 esbId, ͣť +* ֵ +* עcgh-ϲCID-2349-1 +*/ +UINT8 GetEsbRelateEssFlashState(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 chEssFlashState = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + if (bufIndex < ESB_SUM_MAX) + { + + chEssFlashState = EsbDataStru[bufIndex].EssFlashState; + } + else + { + /**/ + } + return chEssFlashState; +} +/* +* ָIDͣťʵ״̬ATSť״̬-Ծ߱ +* ˵ const UINT16 esbId, ťID +* const UINT8 esbState, ť״̬ +* ֵ 0: ʧ +* 1: óɹ +* cgh-ϲCID-2349-1\cgh-ϲCID-3037-1 +* +*/ +void SetEsbAutualState(const UINT16 esbId, const UINT8 EsbState) +{ + UINT16 bufIndex = 0U; /*±꣬m by yt޸MISRA2004-10_1_h-32022214*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + if ((ESB_STATE_VALID_NO == EsbState) || (ESB_STATE_VALID_YES == EsbState)) + { + EsbDataStru[bufIndex].EsbActualState = EsbState; /*ͣť״̬*/ + + } + else + { + ; /*״̬Ϸִ״̬*/ + } + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ȡָIDͣESBť״̬ATSť״̬-Ծ߱ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ESSť״̬ +*עcgh-ϲCID-2349-1\GetEsbAutualState +*/ +UINT8 GetEsbAutualState(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbDataStru[bufIndex].EsbActualState; + } + return reVal; +} + + +/* +* ȡָIDͣESSť״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ESSť״̬ +*עcgh-ϲCID-2349-1\cgh-ϲCID-3037-1 +*/ +UINT8 GetEssState(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbDataStru[bufIndex].EssState; + } + return reVal; +} + +/* +* ָIDESSť״̬ +* ˵ const UINT16 esbId, ťID +* const UINT8 EssState, ESSť״̬ +* ֵ 0: ʧ +* 1: óɹ +*עcgh-ϲCID-2349-1\cgh-ϲCID-3037-1 +*/ +void SetEssState(const UINT16 esbId, const UINT8 EssState) +{ + UINT16 bufIndex = 0U; /*±꣬m by yt޸MISRA2004-10_1_h-32022214*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + if ((ESB_STATE_GO_FLAG == EssState) || (ESB_STATE_STOP_FLAG == EssState)) + { + EsbDataStru[bufIndex].EssState = EssState; /*ͣť״̬*/ + } + else + { + ; /*״̬Ϸ״̬*/ + } + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ȡָIDԸʽȡͣťϱ־ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ȡͣťϱ־ +*/ +UINT8 GetCancelEsbErrFlag(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbDataStru[bufIndex].CancelEsbErrorFlag; + } + else + { + ; /*±겻Ϸִ״̬*/ + } + return reVal; +} + +/* +* ָIDԸʽȡͣťϱ־ +* ˵const UINT16 esbId, ͣťID +* const UINT8 cancelEsbErrFlag, ȡͣťϱ־ +* ֵ +*/ +void SetCancelEsbErrFlag(const UINT16 esbId, const UINT8 cancelEsbErrFlag) +{ + UINT16 bufIndex = 0U; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + if ((ESB_ERROR_FLAG_NO == cancelEsbErrFlag) || (ESB_ERROR_FLAG_YES == cancelEsbErrFlag)) + { + EsbDataStru[bufIndex].CancelEsbErrorFlag = cancelEsbErrFlag; /*ͣť״̬*/ + } + else + { + ; /*״̬Ϸ״̬*/ + } + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ýرհť +* const UINT16 esbId Esb ID +* const UINT32 startCycNum ں +* +* ֵ +*/ +void SetEsbPressCycNum(const UINT16 esbId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0U; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + EsbDataStru[bufIndex].EsbPressCycNum = startCycNum; /*ͣť״̬*/ + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ȡرհť +* const UINT16 esbId Esb ID +* +* ֵ ESB +*/ +UINT32 GetEsbPressCycNum(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + reVal = EsbDataStru[bufIndex].EsbPressCycNum; + } + else + { + /*±Ƿ0*/ + } + return reVal; +} + +/* +* ȡرհť +* const UINT16 esbId Esb ID +* const UINT32 startCycNum ں +* +* ֵ +*/ +void SetCancelEsbPressCycNum(const UINT16 esbId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0U; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + EsbDataStru[bufIndex].CancelEsbPressCycNum = startCycNum; /*ͣť״̬*/ + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ȡȡرհť +* const UINT16 esbId Esb ID +* +* ֵ ȡرհť +*/ +UINT32 GetCancelEsbPressCycNum(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + reVal = EsbDataStru[bufIndex].CancelEsbPressCycNum; + } + else + { + /*±Ƿ0*/ + } + return reVal; +} + +/* +* ȡָIDԸʽȡͣťЧ־ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ȡͣťЧ־ +*/ +UINT8 GetCancelEsbValidFlag(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbDataStru[bufIndex].CancelEsbValidFlag; + } + else + { + ; /*±겻Ϸִ״̬*/ + } + return reVal; +} + +/* +* ָIDԸʽȡͣťЧ־ +* ˵const UINT16 esbId, ͣťID +* const UINT8 cancelEsbValidFlag, ȡͣťЧ־ +* ֵ +*/ +void SetCancelEsbValidFlag(const UINT16 esbId, const UINT8 cancelEsbValidFlag) +{ + UINT16 bufIndex = 0U; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + if ((ESB_CANCEL_VALID_NO == cancelEsbValidFlag) || (ESB_CANCEL_VALID_YES == cancelEsbValidFlag)) + { + EsbDataStru[bufIndex].CancelEsbValidFlag = cancelEsbValidFlag; /*ͣťЧ־*/ + } + else + { + ; /*״̬Ϸ״̬*/ + } + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ȡָIDԸʽͣťϱ־ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣťϱ־ +*/ +UINT8 GetEsbErrFlag(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + reVal = EsbDataStru[bufIndex].EsbErrorFlag; + } + else + { + ; /*±겻Ϸִ״̬*/ + } + return reVal; +} + +/* +* ָIDԸʽͣťϱ־ +* ˵const UINT16 esbId, ͣťID +* const UINT8 cancelEsbErrFlag, ͣťϱ־ +* ֵ +*/ +void SetEsbErrFlag(const UINT16 esbId, const UINT8 esbErrFlag) +{ + UINT16 bufIndex = 0U; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + if ((ESB_ERROR_FLAG_NO == esbErrFlag) || (ESB_ERROR_FLAG_YES == esbErrFlag)) + { + EsbDataStru[bufIndex].EsbErrorFlag = esbErrFlag; /*ͣť״̬*/ + } + else + { + ; /*״̬Ϸ״̬*/ + } + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ȡرհť󴥷 +* const UINT16 esbId Esb ID +* const UINT32 startCycNum ں +* +* ֵ +* Created By LQ 2024.04.10 +*/ +void SetCancelEsbErrTrigPressCycNum(const UINT16 esbId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0U; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + EsbDataStru[bufIndex].CancelEsbErrTriggerPressCycNum = startCycNum; + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ȡȡرհť󴥷 +* const UINT16 esbId Esb ID +* +* ֵ ȡرհť󴥷 +* Created By LQ 2024.04.10 +*/ +UINT32 GetCancelEsbErrTrigPressCycNum(const UINT16 esbId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + reVal = EsbDataStru[bufIndex].CancelEsbErrTriggerPressCycNum; + } + else + { + /*±Ƿ0*/ + } + + return reVal; +} + +/* +* ȡͣťɼ̵״̬ +* ˵const UINT16 esbId ͣťID +* const UINT8 cRelayDownState ̵״̬ +* ֵ +* Created By LQ 2024.04.10 +*/ +void SetCancelEsbRelayDownState(const UINT16 esbId, const UINT8 cRelayDownState) +{ + UINT16 bufIndex = 0U; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + if ((ESB_RELAY_ERROR_DOWN_NO == cRelayDownState) || (ESB_RELAY_ERROR_DOWN_YES == cRelayDownState)) + { + EsbDataStru[bufIndex].CancelEsbRelayDownState = cRelayDownState; + } + else + { + ; /*״̬Ϸ״̬*/ + } + } + else + { + ; /*±겻Ϸִ״̬*/ + } +} + +/* +* ȡȡͣťɼ̵״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* 0x55: +* 0xaa: ͨ쳣 +* Created By LQ 2024.04.10 +*/ +UINT8 GetCancelEsbRelayDownState(const UINT16 esbId) +{ + UINT16 bufIndex = 0U; + UINT8 reVal = CI_ERROR; + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (ESB_SUM_MAX > bufIndex) + { + reVal = EsbDataStru[bufIndex].CancelEsbRelayDownState; + } + else + { + ; /*±겻Ϸִ״̬*/ + } + + return reVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ESB/ESBDataManage.h b/TSCP/src/APP/ciapp/ESB/ESBDataManage.h new file mode 100644 index 0000000..7495d3a --- /dev/null +++ b/TSCP/src/APP/ciapp/ESB/ESBDataManage.h @@ -0,0 +1,317 @@ +/******************************************************** +* +* ESBDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ͣťݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ESB_DATA_MANAGE_H_ +#define _ESB_DATA_MANAGE_H_ + + +#include "ESBDefine.h" +#include "ESBConfigDataManage.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ͣťݽṹ*/ +typedef struct S_EsbDataStruct +{ + UINT16 EsbId; /*ͣťID (ʼֶ)*/ + UINT8 EsbState; /*ͣť״̬ (ֶ̬)-ESSPEPں״̬*/ + UINT8 EssState; /*Essť״̬ (ֶ̬)--Բž߱*/ + UINT8 EsbActualState; /*ESBͣť״̬--ATŞ/״̬Բž߱*/ + UINT8 CutStatus; /*ͣť·״̬*/ + UINT8 EsbRelateRelayDriveState; /*ͣơȵƺͷ̵״̬*/ + UINT8 EssSteadyState; /*ESSȵ״̬ATS--0x55 Ҫȵƣ0xaaҪȵ*/ + UINT8 EssFlashState; /*ESS״̬ATS--0x55 Ҫƣ0xaaҪ*/ + UINT8 EsbErrorFlag; /*Ըʽͣťϱ־0x55δϣ0xaa*/ + UINT8 CancelEsbErrorFlag; /*Ըʽȡͣťϱ־0x55δϣ0xaa*/ + UINT32 EsbPressCycNum; /*رհť*/ + UINT32 CancelEsbPressCycNum; /*ȡرհť*/ + UINT32 CancelEsbErrTriggerPressCycNum; /*ȡرհť󴥷*/ + UINT8 CancelEsbValidFlag; /*ȡرհťЧ־0x55Ч0xaaЧ*/ + UINT8 CancelEsbRelayDownState; /*ȡرհťɼ̵״̬0x55ɼ£0xaaͨ쳣*/ +} EsbDataStruct; + +/*******************************ȫֱ*******************************/ +extern EsbDataStruct EsbDataStru[ESB_SUM_MAX]; /*ESBݽṹ*/ + + +/* +* ȡָESB +* ˵ +* ֵ + EsbDataStruct * +*/ +EsbDataStruct *GetEsbData(void); + +/* +* ȡָIDͣť״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣť״̬ +*/ +UINT8 GetEsbState(const UINT16 esbId); + +/* +* ָIDͣť״̬ +* ˵ const UINT16 esbId, ťID +* const UINT8 esbState, ť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetEsbState(const UINT16 esbId, const UINT8 esbState); + +/* +* ȡָID ͣť·״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: spksť״̬ +*/ +UINT8 GetEsbCutState(const UINT16 esbId); + +/* +* ָID ·״̬ +* ˵ const UINT16 esbId, ͣť +* const UINT8 esbCutState, ·״̬ +* ֵ +* +*/ +void SetEsbCutState(const UINT16 esbId, const UINT8 esbCutState); + +/* +* ESB״̬ʼ +* ˵ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 EsbDataManageInit(void); + +/* +* ָESB IDؼ̵״̬ +* ˵ const UINT16 esbId, ͣť +* const UINT8 state, ״̬ +* ֵ +* cgh-ϲCID-2349-1 +*/ +void SetEsbRelateRelayDriveProState(const UINT16 esbId, const UINT8 state); + +/* +* ȡָESB IDؼ̵״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: esbؼ̵״̬ +* cgh-ϲCID-2349-1 +*/ +UINT8 GetEsbRelateRelayDriveProState(const UINT16 esbId); + +/* +* ָESB IDӦESSȵ״̬ +* ˵ const UINT16 esbId, ͣť +* const UINT8 state, ״̬ +* ֵ +* cgh-ϲCID-2349-1 +*/ +void SetEsbRelateEssSteadyState(const UINT16 esbId, const UINT8 state); +/* +* ȡָESB IDӦESSȵ״̬ +* ˵ const UINT16 esbId, ͣť +* ֵ +* עcgh-ϲCID-2349-1 +*/ +UINT8 GetEsbRelateEssSteadyState(const UINT16 esbId); + +/* +* ָESB IDӦESS״̬ +* ˵ const UINT16 esbId, ͣť +* const UINT8 state, ״̬ +* ֵ +* עcgh-ϲCID-2349-1 +*/ +void SetEsbRelateEssFlashState(const UINT16 esbId, const UINT8 state); + +/* +* ȡָESB IDӦESS״̬ +* ˵ const UINT16 esbId, ͣť +* ֵ +* עcgh-ϲCID-2349-1 +*/ +UINT8 GetEsbRelateEssFlashState(const UINT16 esbId); +/* +* ָIDͣťʵ״̬ATSť״̬-Ծ߱ +* ˵ const UINT16 esbId, ťID +* const UINT8 esbState, ť״̬ +* ֵ 0: ʧ +* 1: óɹ +* cgh-ϲCID-2349-1 +* +*/ +void SetEsbAutualState(const UINT16 esbId, const UINT8 EsbState); + +/* +* ȡָIDͣESBť״̬ATSť״̬-Ծ߱ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ESSť״̬ +*עcgh-ϲCID-2349-1 +*/ +UINT8 GetEsbAutualState(const UINT16 esbId); + + +/* +* ȡָIDͣESSť״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ESSť״̬ +*עcgh-ϲCID-2349-1 +*/ +UINT8 GetEssState(const UINT16 esbId); + +/* +* ָIDESSť״̬ +* ˵ const UINT16 esbId, ťID +* const UINT8 EssState, ESSť״̬ +* ֵ 0: ʧ +* 1: óɹ +*עcgh-ϲCID-2349-1 +*/ +void SetEssState(const UINT16 esbId, const UINT8 EssState); + +/* +* ȡָIDԸʽȡͣťϱ־ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ȡͣťϱ־ +*/ +UINT8 GetCancelEsbErrFlag(const UINT16 esbId); + +/* +* ָIDԸʽȡͣťϱ־ +* ˵const UINT16 esbId, ͣťID +* const UINT8 cancelEsbErrFlag, ȡͣťϱ־ +* ֵ +*/ +void SetCancelEsbErrFlag(const UINT16 esbId, const UINT8 cancelEsbErrFlag); + +/* +* ýرհť +* const UINT16 esbId Esb ID +* const UINT32 startCycNum ں +* +* ֵ +*/ +void SetEsbPressCycNum(const UINT16 esbId, const UINT32 startCycNum); + +/* +* ȡرհť +* const UINT16 esbId Esb ID +* +* ֵ ESB +*/ +UINT32 GetEsbPressCycNum(const UINT16 esbId); + +/* +* ȡرհť +* const UINT16 esbId Esb ID +* const UINT32 startCycNum ں +* +* ֵ +*/ +void SetCancelEsbPressCycNum(const UINT16 esbId, const UINT32 startCycNum); + +/* +* ȡȡرհť +* const UINT16 esbId Esb ID +* +* ֵ ȡرհť +*/ +UINT32 GetCancelEsbPressCycNum(const UINT16 esbId); + +/* +* ȡָIDԸʽȡͣťЧ־ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ȡͣťЧ־ +*/ +UINT8 GetCancelEsbValidFlag(const UINT16 esbId); + +/* +* ָIDԸʽȡͣťЧ־ +* ˵const UINT16 esbId, ͣťID +* const UINT8 cancelEsbValidFlag, ȡͣťЧ־ +* ֵ +*/ +void SetCancelEsbValidFlag(const UINT16 esbId, const UINT8 cancelEsbValidFlag); + +/* +* ȡָIDԸʽͣťϱ־ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* >0: ͣťϱ־ +*/ +UINT8 GetEsbErrFlag(const UINT16 esbId); + +/* +* ָIDԸʽͣťϱ־ +* ˵const UINT16 esbId, ͣťID +* const UINT8 cancelEsbErrFlag, ͣťϱ־ +* ֵ +*/ +void SetEsbErrFlag(const UINT16 esbId, const UINT8 esbErrFlag); + +/* +* ȡرհť󴥷 +* const UINT16 esbId Esb ID +* const UINT32 startCycNum ں +* +* ֵ +* Created By LQ 2024.04.10 +*/ +void SetCancelEsbErrTrigPressCycNum(const UINT16 esbId, const UINT32 startCycNum); + +/* +* ȡȡرհť󴥷 +* const UINT16 esbId Esb ID +* +* ֵ ȡرհť󴥷 +* Created By LQ 2024.04.10 +*/ +UINT32 GetCancelEsbErrTrigPressCycNum(const UINT16 esbId); + +/* +* ȡͣťɼ̵״̬ +* ˵const UINT16 esbId ͣťID +* const UINT8 cRelayDownState ̵״̬ +* ֵ +* Created By LQ 2024.04.10 +*/ +void SetCancelEsbRelayDownState(const UINT16 esbId, const UINT8 cRelayDownState); + +/* +* ȡȡͣťɼ̵״̬ +* ˵ const UINT16 esbId, ͣťID +* ֵ 0: ȡʧ +* 0x55: +* 0xaa: ͨ쳣 +* Created By LQ 2024.04.10 +*/ +UINT8 GetCancelEsbRelayDownState(const UINT16 esbId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ESB/ESBDefine.h b/TSCP/src/APP/ciapp/ESB/ESBDefine.h new file mode 100644 index 0000000..25821e6 --- /dev/null +++ b/TSCP/src/APP/ciapp/ESB/ESBDefine.h @@ -0,0 +1,62 @@ +/******************************************************** +* +* ESBConfigDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ͣťͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ESB_CONFIG_DEFINE_H_ +#define _ESB_CONFIG_DEFINE_H_ + + + +/*ͣťֵ*/ +#define ESB_SUM_MAX ((UINT16)200) /*ESBֵ*/ + +/*ť״̬*/ +#define ESB_STATE_VALID_NO ((UINT8)0x55) /*Ч*/ +#define ESB_STATE_VALID_YES ((UINT8)0xaa) /*Ч*/ + +/*ť·״̬*/ +#define ESB_CUT_NO ((UINT8)0x55) /* δ· */ +#define ESB_CUT_YES ((UINT8)0xaa) /* · */ +#define ESB_VIRTUAL_ATTR_YES ((UINT8)0x55) /*ESB*/ +#define ESB_VIRTUAL_ATTR_NO ((UINT8)0xaa) /*ESB*/ + +/*Ըʽťϱ־*/ +#define ESB_ERROR_FLAG_NO ((UINT8)0x55) /*Ըʽťϱ־Ч*/ +#define ESB_ERROR_FLAG_YES ((UINT8)0xaa) /*Ըʽťϱ־Ч*/ + +#define ESB_CANCEL_VALID_NO ((UINT8)0x55) /*Ըʽȡť־Ч*/ +#define ESB_CANCEL_VALID_YES ((UINT8)0xaa) /*Ըʽȡť־Ч*/ + +/*Ըʽȡť̵״̬*/ +#define ESB_RELAY_ERROR_DOWN_NO ((UINT8)0x55) /**/ +#define ESB_RELAY_ERROR_DOWN_YES ((UINT8)0xaa) /*ͨ쳣*/ + +/*ESSATS-CIλ״̬*/ +#define ESS_MASK_YES ((UINT8)0x55U) /*λ*/ +#define ESS_MASK_NO ((UINT8)0xaaU) /*δλ*/ + +/*ESSȥλ/ͣλ־*/ +#define ESB_STATE_GO_FLAG ((UINT8)0x55U) /*ESSȥλ*/ +#define ESB_STATE_STOP_FLAG ((UINT8)0xaaU) /*ESSͣλ*/ + +/*ESS/ȵ״̬*/ +#define ESB_STATE_LIGHT_STATE_Y ((UINT8)0x55U) /**/ +#define ESB_STATE_LIGHT_STATE_N ((UINT8)0xaaU) /*δ*/ + +/*ESBơȵƺͷؼ̵״̬*/ +#define ESB_PEPUP_ESSUP_INITION_STA ((UINT8)0x01U) /*ESB̵ʼλ״̬1*/ +#define ESB_PEPDOWN_ESSUP_TWO_STATE ((UINT8)0x02U) /*ESB̵PEPESSȥλ״̬2*/ +#define ESB_PEPDOWN_ESSDOWN_THREE_STATE ((UINT8)0x03U) /*ESB̵PEPESSͣλ״̬3*/ +#define ESB_ONEPEPUP_ESSDOWN_FOUR_STATE ((UINT8)0x04U) /*ESB̵PEPȰµPEPESSͣλ״̬4*/ +#define ESB_TWOPEPUP_ESSDOWN_FIVE_STATE ((UINT8)0x05U) /*ESB̵ESSȰµPEPESSͣλ״̬5*/ +#define ESB_FAULT_SIX_STATE ((UINT8)0x06U) /*ESB̵Ĺ״̬״̬6*/ +#endif diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/CTEnvelopeTrack.c b/TSCP/src/APP/ciapp/EnvelopeManage/CTEnvelopeTrack.c new file mode 100644 index 0000000..651c825 --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/CTEnvelopeTrack.c @@ -0,0 +1,1574 @@ + /****************************************************************************** +** ļ: CTEnvelopeTrack.c +** : ʵCT׷ٴ +*******************************************************************************/ +#include "EnvelopeLogicProcess.h" +#include "AxisAssertManageAPI.h" +#include "../DataManage/DeviceDataManage.h" +#include "WholeLineScreenAPI.h" + +#if LINE_MAX_TRAIN > 255 +#error LINE_MAX_TRAINֵܳ255Ŀǰ豸ID壨ͣ1ֽڣ+ID1ֽڣ +#endif + +/*================================̬==============================*/ + + +static UINT8 elm_ProcessHeadLeave(UINT16 trainid, IN const EnvelopeStruct* pEnvelop, IN const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX], \ + UINT8 preACCnt, IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX], UINT8 newACCnt); /* ͷ뿪 */ +static UINT8 elm_ProcessTailLeave(UINT16 trainid, IN const EnvelopeStruct* pEnvelop, IN const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX], \ + UINT8 preACCnt, IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX], UINT8 newACCnt); /* β뿪 */ + +static UINT8 elm_RefreshACMapInfo(IN const EnvelopeStruct* pEnvelop, IN const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX], \ + UINT8 preACCnt, IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX], UINT8 newACCnt); /* ˢ°ڼӳϵϢ */ + +static void elm_SearchCTELMSuspHeadandTail(UINT16 trainID, UINT8 cutFlag, IN const ELM_TrainSafeLocStruct *pSafeLoc, \ + OUT UINT16 *preTrainID, OUT UINT16 *pBackTrainID); /* гλãȡгǰɸϢ */ +static UINT8 elm_AddCTEnvelope(UINT16 trainID, OUT UINT8 *handOverFlag); /* CT */ +static UINT8 elm_ReFreshACInCTEnvelope(IN const EnvelopeStruct* pEnvelop, UINT16 trainid, OUT UINT8 *handOverFlag); /* CT߹· */ +static UINT8 elm_MonitorCTEnvelopePreAndBack(IN const EnvelopeStruct* pEnvelop); /* CTǰ */ +static UINT8 elm_ReFreshCTEnvelope(UINT16 envelopeID, UINT16 trainid, OUT UINT8 *handOverFlag); /* ˢг*/ + +/** +* @brief ̬ͷ뿪 +* @param[in] UINT16 trainid гID +* @param[in] IN const EnvelopeStruct* pEnvelop Ϣ +* @param[in] const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ +* @param[in] UINT8 preACCnt ռõİ +* @param[in] const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ +* @param[in] UINT8 newACCnt ռõİ +* @param[out] +* @return CI_SUCCESS ȷسɹ +* CI_ERROR 󣬷ʧ +* @note +* 1½2022421 +*/ +static UINT8 elm_ProcessHeadLeave(UINT16 trainid, IN const EnvelopeStruct* pEnvelop, IN const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX], \ + UINT8 preACCnt, IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX], UINT8 newACCnt) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + UINT32 errorCode = 0u; + UINT8 posFlag = (UINT8)UINT8_MAX; + + /*- ڲУ */ + ASSERT_RET_VALUE(NULL == preACID, ret, 0x80000000u); + ASSERT_RET_VALUE((UINT8)SECTION_IN_ENVELOPE_SUM_MAX < preACCnt, ret, 0x40000000u); + ASSERT_RET_VALUE(NULL == newACID, ret, 0x20000000u); + ASSERT_RET_VALUE((UINT8)SECTION_IN_ENVELOPE_SUM_MAX < newACCnt, ret, 0x10000000u); + ASSERT_RET_VALUE(NULL == pEnvelop, ret, 0x08000000u); + + /*- аͷӰسҪļUKT*/ + for (cycle = 0u; cycle < preACCnt; cycle++) + { + /** жϼǷµİ*/ + funRet = elm_PrepareInUINT16Array(preACID[preACCnt - cycle - 1u], newACID, newACCnt); + + /** ȡڰеλ */ + posFlag = elm_GetACOfEnvelopePos(preACID[preACCnt - cycle - 1u], preACID, preACCnt); + + /** жǷѯȷ */ + ASSERT_BREAK(UINT8_MAX == posFlag, errorCode, 0x04000000u); + + if ((CI_SUCCESS == funRet) && (ELM_HEAD == posFlag)) + { + /** °Ϊͷ֮ǰĿ*/ + } + else if (CI_SUCCESS == funRet) + { + /** ҵδʻļᣬ */ + break; + } + else if (ELM_HEAD == posFlag) + { + if (LINE_MAX_TRAIN == pEnvelop->headTrainID) + { + /** ά־Լ*/ + ELM_LOG(ELM_LOG_FATAL, "info:Refresh CT_ELM%d for Train%d,Front AC%d need to add UKT_ELM.\n", pEnvelop->id, trainid, preACID[preACCnt - cycle - 1u]); + + /** ڼӹϰ*/ + funRet = elm_AddUKTEnvelopeInAC(preACID[preACCnt - cycle - 1u]); + + /** жǷӳɹ*/ + if (CI_ERROR == funRet) + { + /** ʧܣܷ֧߽뵽˷֧ðģ޷ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ASSER_ERROR(CI_SUCCESS == funRet, errorCode, 0x02000000u); + ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Refresh CT_ELM%d for Train%d,Front AC%d need to add UKT_ELM error.", errorCode, pEnvelop->id, trainid, preACID[preACCnt - cycle - 1u]); + break; + } + else + { + /** */ + } + } + else + { + /** 账 */ + } + + /** óͷ*/ + aam_SetEnvelopeEnterFlag(AAM_ENVELOPE_HEAD_EXIT, pEnvelop->headTrainID, preACID[preACCnt - cycle - 1u], trainid); + } + else + { + /** dzβͳβ*/ + break; + } + } + + /*_ úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + return ret; +} + + +/** +* @brief ̬β뿪 +* @param[in] UINT16 trainid гID +* @param[in] IN const EnvelopeStruct* pEnvelop Ϣ +* @param[in] const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ +* @param[in] UINT8 preACCnt ռõİ +* @param[in] const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ +* @param[in] UINT8 newACCnt ռõİ +* @param[out] +* @return CI_SUCCESS ȷسɹ +* CI_ERROR 󣬷ʧ +* @note +* 1½2022421 +*/ +static UINT8 elm_ProcessTailLeave(UINT16 trainid, IN const EnvelopeStruct* pEnvelop, IN const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX], \ + UINT8 preACCnt, IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX], UINT8 newACCnt) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + UINT32 errorCode = 0u; + UINT8 posFlag = (UINT8)UINT8_MAX; + + /*- ڲУ */ + ASSERT_RET_VALUE(NULL == preACID, ret, 0x80000000u); + ASSERT_RET_VALUE((UINT8)SECTION_IN_ENVELOPE_SUM_MAX < preACCnt, ret, 0x40000000u); + ASSERT_RET_VALUE(NULL == newACID, ret, 0x20000000u); + ASSERT_RET_VALUE((UINT8)SECTION_IN_ENVELOPE_SUM_MAX < newACCnt, ret, 0x10000000u); + ASSERT_RET_VALUE(NULL == pEnvelop, ret, 0x08000000u); + + /*- аβӰسҪʻļUKT*/ + for (cycle = 0u; cycle < preACCnt; cycle++) + { + /** жϼǷµİ*/ + funRet = elm_PrepareInUINT16Array(preACID[cycle], newACID, newACCnt); + + /** ȡڰеλ */ + posFlag = elm_GetACOfEnvelopePos(preACID[cycle], preACID, preACCnt); + + /** жǷѯȷ */ + ASSERT_BREAK(UINT8_MAX == posFlag, errorCode, 0x04000000u); + + if ((CI_SUCCESS == funRet) && (ELM_TAIL == posFlag)) + { + /** °Ϊβ֮ǰĿ*/ + } + else if (CI_SUCCESS == funRet) + { + /** ҵδʻļᣬ */ + break; + } + else if (((UINT8)ELM_TAIL == posFlag) || ((UINT8)ELM_BODY == posFlag)) + { + if ((UINT16)LINE_MAX_TRAIN == pEnvelop->tailTrainID) + { + /** ά־ά*/ + ELM_LOG(ELM_LOG_FATAL, "info:Refresh CT_ELM%d Train%d,Back AC%d need to add UKT_ELM.\n", pEnvelop->id, trainid, preACID[cycle]); + + /** ڼӹϰ*/ + funRet = elm_AddUKTEnvelopeInAC(preACID[cycle]); + + /** жǷӳɹ*/ + if (CI_ERROR == funRet) + { + /** ʧܣܷ֧߽뵽˷֧ðģ޷ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ASSER_ERROR(CI_SUCCESS == funRet, errorCode, 0x04000000u); + ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Refresh CT_ELM%d for Train%d,Back AC%d need to add UKT_ELM error.", errorCode, pEnvelop->id, trainid, preACID[cycle]); + break; + } + else + { + /** */ + } + + } + else + { + /** 账 */ + } + + /** óβ*/ + aam_SetEnvelopeEnterFlag(AAM_ENVELOPE_TAIL_EXIT, pEnvelop->tailTrainID, preACID[cycle], trainid); + } + else + { + /** dzβͳͷ*/ + break; + } + } + + /*_ úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + return ret; +} + + +/** +* @brief ̬ˢ°ڼӳϵϢ +* @param[in] IN const EnvelopeStruct* pEnvelop Ϣ +* @param[in] const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ +* @param[in] UINT8 preACCnt ռõİ +* @param[in] const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ +* @param[in] UINT8 newACCnt ռõİ +* @param[out] +* @return CI_SUCCESS ȷسɹ +* CI_ERROR 󣬷ʧ +* @note +* 1½2022421 +*/ +static UINT8 elm_RefreshACMapInfo(IN const EnvelopeStruct* pEnvelop, IN const UINT16 preACID[SECTION_IN_ENVELOPE_SUM_MAX], \ + UINT8 preACCnt, IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX], UINT8 newACCnt) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + UINT8 cycleY = 0u; + UINT16 tmpACIndex = 0u; + UINT32 errorCode = 0u; + + /*- ڲУ */ + ASSERT_RET_VALUE(NULL == preACID, ret, 0x80000000u); + ASSERT_RET_VALUE((UINT8)SECTION_IN_ENVELOPE_SUM_MAX < preACCnt, ret, 0x40000000u); + ASSERT_RET_VALUE(NULL == newACID, ret, 0x20000000u); + ASSERT_RET_VALUE((UINT8)SECTION_IN_ENVELOPE_SUM_MAX < newACCnt, ret, 0x10000000u); + ASSERT_RET_VALUE(NULL == pEnvelop, ret, 0x08000000u); + + /** ռü */ + for (cycle = 0u; cycle < preACCnt; cycle++) + { + for (cycleY = 0u; cycleY < newACCnt; cycleY++) + { + /** жǷΪռѭ */ + ASSERT_BREAK(preACID[cycle] == newACID[cycleY], errorCode, 0x00000000u); + } + + /** жǷΪռѭ */ + ASSERT_BREAK(cycleY != newACCnt, errorCode, 0x00000000u); + } + + if (cycle == preACCnt) + { + /** ˵гռüᣬɾ˳磬гռõΪUKT */ + ASSER_ERROR(cycle == preACCnt, errorCode, 0x04000000u); + ELM_LOG_LOC(ELM_LOG_FATAL, "errorCode:0x%08x info:elm ac not continue occ error.", errorCode); + } + else + { + /** ˵ɰ°нռüᣬȷɾϵİӳ*/ + for (cycle = 0u; cycle < preACCnt; cycle++) + { + tmpACIndex = elm_PrepareACIndex(preACID[cycle]); + funRet = elm_SetACRelEnvelopeMap(OP_DEL, tmpACIndex, pEnvelop->id); + ASSERT_BREAK(CI_ERROR == funRet, errorCode, 0x02000000u); /*ô*/ + } + + /** ¼ϵİӳ*/ + for (cycle = 0u; cycle < newACCnt; cycle++) + { + tmpACIndex = elm_PrepareACIndex(newACID[cycle]); + funRet = elm_SetACRelEnvelopeMap(OP_ADD, tmpACIndex, pEnvelop->id); + ASSERT_BREAK(CI_ERROR == funRet, errorCode, 0x01000000u); /*ô*/ + } + + + /*_ úֵ */ + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Refresh acMap error.", errorCode)); + } + + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + return ret; +} + +/** +* @brief ̬гλãȡгǰɸϢ +* @param[in] UINT16 trainID гID +* @param[in] const ELM_TrainSafeLocStruct *pSafeLoc ȫ +* @param[out] UINT16 *preTrainID ǰ +* @param[out] UINT16 *pBackTrainID +* @return +* @note +* 1EnvelopeManageAPI.cֵļУδ޸ +*/ +static void elm_SearchCTELMSuspHeadandTail(UINT16 trainID, UINT8 cutFlag, IN const ELM_TrainSafeLocStruct *pSafeLoc, OUT UINT16 *preTrainID, OUT UINT16 *pBackTrainID) +{ + /*- ֲ */ + UINT8 OCid = 0u; + UINT8 cycle = 0u; + UINT8 envelopeCnt = 0u; + UINT8 acCnt = 0u; + UINT8 funRtn = 0u; + UINT8 acUTOccFlag = CI_ERROR; + UINT16 ACID[SECTION_IN_ENVELOPE_SUM_MAX] = { 0u }; + UINT32 errorCode = 0u; + CfpEnvelopeStruct InfEnvelope[SECTION_REL_ENVELOPE_SUM_MAX * ONE_OTHER_CFP_SUM_MAX] = { 0u };/** ȡOC͵İϢ */ + ELM_TrainSafeLocStruct tmpSafeLoc = { 0u }; /* ȫλʱ洢 */ + + + /** ȡгİȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(trainID, &tmpSafeLoc); + + /** ڲж*/ + ASSERT_RET_NO_VALUE(NULL == pSafeLoc, 0x80000000u); + ASSERT_RET_NO_VALUE(NULL == preTrainID, 0x40000000u); + ASSERT_RET_NO_VALUE(NULL == pBackTrainID, 0x20000000u); + ASSERT_RET_NO_VALUE(CI_ERROR == funRtn, 0x10000000u); + + /** жϳβǷڱOC*/ + if ((ELM_HEAD_CUT == cutFlag) || (ELM_TAIL_CUT == cutFlag)) + { + /** ѯ緶ΧڵļᣬUKTOCɸѡϢ */ + acCnt = elm_PrepareACBtwPoints(pSafeLoc->startPos, pSafeLoc->endPos, ACID); + + /** жǷѯɹ */ + if (0u == acCnt) + { + /** ѯ */ + ASSER_ERROR(CI_ERROR == acUTOccFlag, errorCode, 0x08000000u); + } + else + { + /** еļᣬϴUKT˳ */ + for (cycle = 0u; cycle < acCnt; cycle++) + { + /** ͨIDȡǷUTռ */ + acUTOccFlag = elm_CheckACIsUTOcc(ACID[cycle]); + + /** жϼǷΪUTռ*/ + ASSERT_BREAK(CI_ERROR == acUTOccFlag, errorCode, 0x00000000u); + } + + if (cycle == acCnt) + { + + /** ȡOC ID*/ + if (ELM_HEAD_CUT == cutFlag) + { + /** ȡͷOC */ + funRtn = elm_PreparePointIsSelf(&(tmpSafeLoc.endPos), &OCid); + } + else + { + /** ȡβOC */ + funRtn = elm_PreparePointIsSelf(&(tmpSafeLoc.startPos), &OCid); + + } + + /** UTռãOCɸѡϢ */ + if (0u == funRtn) + { + ELM_LOG(ELM_LOG_FATAL, "info:Get next OC id error.\n"); + } + else + { + /** ȡOC͵İϢ */ + envelopeCnt = elm_PrepareNextOcInfEnvelope(OCid, InfEnvelope); + + /** еİ */ + for (cycle = 0u; cycle < envelopeCnt; cycle++) + { + if ((TYPE_CT_ENVELOPE == InfEnvelope[cycle].envelopeType) && (trainID == InfEnvelope[cycle].trainID[0])) + { + (*preTrainID) = InfEnvelope[cycle].headTrainID; + (*pBackTrainID) = InfEnvelope[cycle].tailTrainID; + ELM_LOG(ELM_LOG_FATAL, "info:Believe SuspicHeadandTail for Train%d from next OC%d cycle%d.\n", trainID, OCid, cycle); + break; + } + else + { + /** */ + } + } + } + } + else + { + /** OCɸѡϢ*/ + } + } + } + else + { + /** ڱOCǰ*/ + } + + /** ӡ*/ + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:train supec get error.", errorCode)); +} + + +/** +* @brief ̬CT +* @param[in] UINT16 trainID гID +* @param[out] UINT8* handOverFlag лʶ +* @return CI_SUCCESS CTȷسɹ +* CI_ERROR CT󣬷ʧ +* @note +* 1EnvelopeManageAPI.cֵļУδ޸ +*/ +static UINT8 elm_AddCTEnvelope(UINT16 trainID, OUT UINT8* handOverFlag) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; /* ֵ */ + UINT8 cycle = 0u; /*ѭ*/ + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; /**/ + UINT16 buffIndex = ENVELOPE_UNVAILD_INDEX; /** 绺ַ */ + UINT16 tmpACIndex = 0u; /**/ + EnvelopeStruct tmpEnvelope = { 0u }; /*ʱ*/ + ELM_TrainSafeLocStruct tmpSafeLoc = { 0u }; /* ȫλʱ洢 */ + UINT8 tempEnvelopeCnt = 0u; /**/ + UINT16 tempEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = { 0u }; /*ID*/ + const EnvelopeStruct* pEnvelopeTemp = NULL; /*ָ*/ + UINT16 preTrainID = LINE_MAX_TRAIN; + UINT16 BackTrainID = LINE_MAX_TRAIN; + UINT8 cutFlag = ELM_NO_CUT; + + /** ڲϷУ */ + ASSERT_RET_VALUE(NULL == handOverFlag, ret, 0x80000000u); + *(handOverFlag) = CI_ERROR; + + /** һȡгİȫλ*/ + funRet = elm_PrepareTrainSafeLoc(trainID, &tmpSafeLoc); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x80000000u) + + /** ά־Լ*/ + ELM_LOG(ELM_LOG_FATAL, "info:ADD CT_ELM Train%d,safeT:%d-%d-%02x,safeH:%d-%d-%02x.\n", trainID, tmpSafeLoc.startPos.Lnk, tmpSafeLoc.startPos.Off, tmpSafeLoc.startPos.Dir, \ + tmpSafeLoc.endPos.Lnk, tmpSafeLoc.endPos.Off, tmpSafeLoc.endPos.Dir) + + /** ԰нȡ */ + funRet = elm_PrepareCutZoneInSelf(&(tmpSafeLoc.startPos), &(tmpSafeLoc.endPos), &cutFlag); + + /** жǷл״δʱгVBTCгOC͵ǰɸϢ*/ + elm_SearchCTELMSuspHeadandTail(trainID, cutFlag, &tmpSafeLoc, &preTrainID, &BackTrainID); + + /** ά־Լ*/ + ELM_LOG(ELM_LOG_FATAL, "info:CUT CT_ELM Train%d,safeT:%d-%d-%02x,safeH:%d-%d-%02x.\n", trainID, tmpSafeLoc.startPos.Lnk, tmpSafeLoc.startPos.Off, tmpSafeLoc.startPos.Dir, \ + tmpSafeLoc.endPos.Lnk, tmpSafeLoc.endPos.Off, tmpSafeLoc.endPos.Dir) + + if (ELM_BELONG_OWNER == funRet) + { + /** ڶ */ + funRet = elm_CreateEnveLope(TYPE_CT_ENVELOPE, trainID, tmpSafeLoc.startPos, tmpSafeLoc.endPos, preTrainID, BackTrainID, &tmpEnvelope); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x40000000u) + + /** жϰǷ񴴽ɹ */ + if (0u == errorCode) + { + /** ӳβʼ*/ + for (cycle = 0u; cycle < tmpEnvelope.ACCnt; cycle++) + { + /** ͨIDȡ */ + tmpACIndex = elm_PrepareACIndex(tmpEnvelope.ACID[cycle]); + + /** ͨȡİͰID */ + tempEnvelopeCnt = elm_GetACRelEnvelopeCnt(tmpACIndex, tempEnvelopeID); + + /** ѯİǷ˳ѭ */ + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX == tempEnvelopeCnt, errorCode, 0x20000000u); + + /** жǷڰ*/ + if ((0u == tempEnvelopeCnt) || (1u != tempEnvelopeCnt)) + { + /** ڻߴ磬ֱӰ*/ + } + else + { + /** ͨIDȡ*/ + pEnvelopeTemp = elm_GetEnvelopeInfoPtr(tempEnvelopeID[0]); + + /** жϰǷUKT */ + if (TYPE_UKT_ENVELOPE == pEnvelopeTemp->envelopeType) + { + /** ΪUKT磬ɾUKT*/ + funRet = elm_DeleteUKTEnvelope(pEnvelopeTemp); + } + else + { + /** UKT磬账 */ + } + } + ASSERT_BREAK(CI_ERROR == funRet, errorCode, 0x10000000u); + } + + /** жϴΧڵİϢ */ + if (0u == errorCode) + { + /** ڶȡõİ洢λ */ + buffIndex = elm_GetEnvelopeValidIndex(); + ASSER_ERROR(ENVELOPE_UNVAILD_INDEX == buffIndex, errorCode, 0x08000000u); + + /** жϰλǷȷ*/ + if (ENVELOPE_UNVAILD_INDEX != buffIndex) + { + /** ðΨһʶ*/ + tmpEnvelope.id = buffIndex; + + /** ӵ洢*/ + funRet = elm_SetEnvelopeByIndex(&tmpEnvelope, buffIndex); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x04000000u); + + /** ӳβʼ*/ + for (cycle = 0u; cycle < tmpEnvelope.ACCnt; cycle++) + { + /** ͨIDȡ */ + tmpACIndex = elm_PrepareACIndex(tmpEnvelope.ACID[cycle]); + + /** ᵽӳϵ */ + funRet = elm_SetACRelEnvelopeMap(OP_ADD, tmpACIndex, buffIndex); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x02000000u); + } + + /** г */ + funRet = elm_SetTrainRelEnvelopeMap(OP_ADD, trainID, buffIndex); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x01000000u); + + /** жCTǷȷ */ + if (0u != errorCode) + { + /** Ӱ󣬲ܷ֧ð紦ģ쳣 */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Create CT_ELM for Train%d error because add error.", errorCode, trainID); + } + else + { + /** ȷ*/ + } + } + else + { + /** ޿õİ洢ռ䣬ܷ֧ð紦ģ쳣 */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Create CT_ELM for Train%d error because no valid buff.", errorCode, trainID); + } + } + else + { + /** 󣬲ɴ֧ð紦ģ쳣 */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Create CT_ELM for Train%d error,errorInfo:%d-%d-%d-%d-%d.", \ + errorCode, trainID, tmpEnvelope.ACID[cycle], tmpACIndex, tempEnvelopeCnt, tempEnvelopeID[0], funRet); + } + } + else + { + /** CT紴ʧ */ + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Create CT_ELM for Train%d error.", errorCode, trainID); + } + } + else + { + /** ɱʶ */ + *(handOverFlag) = (ELM_BELONG_OTHER == funRet) ? CI_SUCCESS : CI_ERROR; + + ASSER_ERROR(0u == funRet, errorCode, 0x00800000u); + ASSER_DEBUG(ELM_BELONG_OTHER == funRet, ELM_LOG(ELM_LOG_FATAL, "info:CUT CT_ELM for Train%d not need to control,flag%d.\n", trainID, funRet)); + ASSER_DEBUG(0u == funRet, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:CUT CT_ELM for Train%d error.", trainID, funRet)); + } + + /*- ÷ֵ */ + ASSERT_SETRET((0u == errorCode), ret, CI_SUCCESS, CI_ERROR); + + /** */ + return ret; +} + + +/** +* @brief ̬CT߹· +* @param[in] const EnvelopeStruct* pEnvelop Ҫİ +* @param[in] UINT16 trainid ӦCTID +* @param[out] UINT8* handOverFlag лɱʶ +* @return CI_SUCCESS ȷ +* CI_ERROR +* @note +* 1EnvelopeManageAPI.cֵļУδ޸ +*/ +static UINT8 elm_ReFreshACInCTEnvelope(IN const EnvelopeStruct* pEnvelop, UINT16 trainid, OUT UINT8 *handOverFlag) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; /**/ + UINT8 tmpACCnt = 0u; /**/ + UINT16 tmpACID[SECTION_IN_ENVELOPE_SUM_MAX] = { 0u }; /*ID*/ + ELM_TrainSafeLocStruct safeLoc = { 0u }; /*гȫλ*/ + UINT8 tmpSearchACCnt; /**/ + UINT16 tmpSearchACID[SECTION_IN_ENVELOPE_SUM_MAX] = { 0u }; /*ID*/ + UINT16 temTrainID = 0u; + UINT8 cutFlag = ELM_NO_CUT; + UINT8 headNeedScreen = NEED_SCREEN; + UINT8 tailNeedScreen = NEED_SCREEN; + UINT8 trainPort = 0u; + + /** ڲУ */ + if ((NULL == pEnvelop) || (0u == trainid) || (LINE_MAX_TRAIN == trainid) || (NULL == handOverFlag)) + { + /** ڲ*/ + ASSER_ERROR(CI_ERROR == ret, errorCode, 0x80000000u) + ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:input error!", errorCode) + } + else + { + /*- ֮ǰļϢ */ + tmpACCnt = pEnvelop->ACCnt; + if (SECTION_IN_ENVELOPE_SUM_MAX > tmpACCnt) + { + (void)CommonMemCpy(tmpACID, (UINT32)(sizeof(UINT16)*SECTION_IN_ENVELOPE_SUM_MAX), pEnvelop->ACID, (UINT32)(sizeof(UINT16)*pEnvelop->ACCnt)); + } + else + { + ; /*Ҫݴڿռ䣬*/ + } + /*- ȡгȫλ*/ + funRet = elm_PrepareTrainSafeLoc(trainid, &safeLoc); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x40000000u); /*ô*/ + + /** ά־Լ*/ + ELM_LOG(ELM_LOG_FATAL, "info:Refresh CT_ELM Train%d,safeT:%d-%d-%02x,safeH:%d-%d-%02x.\n", trainid, safeLoc.startPos.Lnk, safeLoc.startPos.Off, safeLoc.startPos.Dir, \ + safeLoc.endPos.Lnk, safeLoc.endPos.Off, safeLoc.endPos.Dir); + + /** ԰нȡ */ + funRet = elm_PrepareCutZoneInSelf(&(safeLoc.startPos), &(safeLoc.endPos), &cutFlag); + + /** ά־Լ*/ + ELM_LOG(ELM_LOG_FATAL, "info:CUT CT_ELM Train%d,safeT:%d-%d-%02x,safeH:%d-%d-%02x.\n", trainid, safeLoc.startPos.Lnk, safeLoc.startPos.Off, safeLoc.startPos.Dir, \ + safeLoc.endPos.Lnk, safeLoc.endPos.Off, safeLoc.endPos.Dir) + + if (ELM_BELONG_OWNER == funRet) + { + /*- ȡȫ緶Χļ*/ + tmpSearchACCnt = elm_PrepareACBtwPoints(safeLoc.startPos, safeLoc.endPos, tmpSearchACID); + ASSER_ERROR((0u == tmpSearchACCnt) || (SECTION_IN_ENVELOPE_SUM_MAX == tmpSearchACCnt), errorCode, 0x20000000u); /*ô*/ + + /*- ¼ϵİӳ*/ + funRet = elm_RefreshACMapInfo(pEnvelop, tmpACID, tmpACCnt, tmpSearchACID, tmpSearchACCnt); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x10000000u); /*ô*/ + + if (0u == errorCode) + { + funRet = elm_SetEnvelopeACInfo(pEnvelop->id, tmpSearchACCnt, tmpSearchACID); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x08000000u); /*ô*/ + + /*- °λ */ + funRet = elm_SetEnvelopeLoc(pEnvelop->id, safeLoc.startPos, safeLoc.endPos); /*λ*/ + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x04000000u); /*ô*/ + + /** г */ + trainPort = elm_PrepareTrainACT(trainid); + elm_SetTrainACTPortInELM(pEnvelop->id, trainid, trainPort); + + /*- ¼г */ + funRet = elm_RefreshACseqInfoForCT(pEnvelop, tmpSearchACID, tmpSearchACCnt, cutFlag); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x02000000u); /*ô*/ + + if (0u == errorCode) + { + /** βʻļ */ + funRet = elm_ProcessTailLeave(trainid, pEnvelop, tmpACID, tmpACCnt, tmpSearchACID, tmpSearchACCnt); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x01000000u); /*ô*/ + + /** ͷʻļ*/ + funRet = elm_ProcessHeadLeave(trainid, pEnvelop, tmpACID, tmpACCnt, tmpSearchACID, tmpSearchACCnt); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x00800000u); /*ô*/ + } + else + { + /** */ + } + } + else + { + /** Ѿóɴ账*/ + } + } + else if (ELM_BELONG_OTHER == funRet) + { + /** ڱOCˣֱɾ */ + ELM_LOG(ELM_LOG_FATAL, "errno:0x%08x info:CUT CT_ELM for Train%d not need to control,flag%d.", errorCode, trainid, funRet); + + funRet = elm_ClearHanderOverEnvelope(pEnvelop, trainid); + + + /** ߳ */ + headNeedScreen = (LINE_MAX_TRAIN == pEnvelop->headTrainID) ? NEED_SCREEN : UNNEED_SCREEN; + tailNeedScreen = (LINE_MAX_TRAIN == pEnvelop->tailTrainID) ? NEED_SCREEN : UNNEED_SCREEN; + elm_JudgeTrainOffline(trainid, headNeedScreen, tailNeedScreen); + + (*handOverFlag) = CI_SUCCESS; /* лг */ + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x00400000u); /*ô*/ + } + else + { + ASSER_ERROR(0u == funRet, errorCode, 0x00200000u) + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:CUT CT_ELM for Train%d error.", errorCode, trainid) + } + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR) + + /** */ + return ret; +} + + +/** +* @brief ̬CTǰ +* @param[in] +* @param[out] +* @return +* 1EnvelopeManageAPI.cֵļУδ޸ +*/ +static UINT8 elm_MonitorCTEnvelopePreAndBack(IN const EnvelopeStruct* pEnvelop) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; /**/ + const EnvelopeStruct* pTemp = NULL; + UINT16 preEnvelopeid = 0u; + UINT16 backEnvelopeid = 0u; + UINT8 dirCheck = 0u; + UINT8 chRet = CI_ERROR; /*ǰ˿ɺֵ*/ + + /** ڲУ */ + if (NULL == pEnvelop) + { + /** ڲ*/ + ASSER_ERROR(CI_ERROR == ret, errorCode, 0x80000000u) + ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:input error!", errorCode) + } + else + { + /** ѯǰͺ󷽰磬ڲѯĿΪ˳ԵǰUKT*/ + funRet = elm_GetNearestEnvelope(pEnvelop->id, &preEnvelopeid, &backEnvelopeid); + + if (CI_ERROR == funRet) + { + /** гǰӰس*/ + (void)elm_SetEnvelopeHeadTrainID(pEnvelop->id, LINE_MAX_TRAIN); + (void)elm_SetEnvelopeTailTrainID(pEnvelop->id, LINE_MAX_TRAIN); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Monitor CT_ELM%d , Pre/Back ELM search error need to Add Head and Tail suspicious.", pEnvelop->id) + } + else + { + /*- ذǰ*/ + pTemp = elm_GetEnvelopeInfoPtr(preEnvelopeid); + if (NULL != pTemp) + { + /** Ƚ緽Ƿͬ */ + dirCheck = elm_DirIsSameELMWithELM(pEnvelop, pTemp); + + if (TYPE_UKT_ENVELOPE == pTemp->envelopeType) + { + /** ǰ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, LINE_MAX_TRAIN); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Monitor CT_ELM%d,Add Head suspicious becasue UKT_ELM id:%d.", pEnvelop->id, pTemp->id) + + /** жUKTǷڰȫλڲ*/ + funRet = elm_PrepareInUINT16Array(pTemp->ACID[0], pEnvelop->ACID, pEnvelop->ACCnt); + + + if (CI_SUCCESS == funRet) + { + /** UKT类CTԵ */ + chRet &= elm_DeleteUKTEnvelope(pTemp); + } + else + { + /** 账ֻҪǰ˿*/ + } + } + else if (LINE_MAX_TRAIN == pEnvelop->headTrainID) + { + /** ǰسáڴ˴ĿģΪCTǰʱܳԵUKT */ + chRet = CI_SUCCESS; + } + else if ((ELM_DIR_SAME == dirCheck) && (0u == pEnvelop->headTrainID) && (0u != pTemp->tailTrainID)) + { + /** ǰ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, pTemp->tailTrainID); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Head suspicious becasue ELM id:%d-T%d.", pEnvelop->id, pTemp->id, pTemp->tailTrainID); + } + else if ((ELM_DIR_SAME == dirCheck) && (0u != pEnvelop->headTrainID) && (0u != pTemp->tailTrainID) && (pEnvelop->headTrainID != pTemp->tailTrainID)) + { + /** ǰ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, LINE_MAX_TRAIN); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Head suspicious becasue ELM id:%d-T%d.", pEnvelop->id, pTemp->id, pTemp->tailTrainID); + } + else if ((ELM_DIR_CONVERT == dirCheck) && (0u == pEnvelop->headTrainID) && (0u != pTemp->headTrainID)) + { + /** ǰ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, pTemp->headTrainID); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Head suspicious becasue ELM id:%d-H%d.", pEnvelop->id, pTemp->id, pTemp->headTrainID); + } + else if ((ELM_DIR_CONVERT == dirCheck) && (0u != pEnvelop->headTrainID) && (0u != pTemp->headTrainID) && (pEnvelop->headTrainID != pTemp->headTrainID)) + { + /** ǰ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, LINE_MAX_TRAIN); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Head suspicious becasue ELM id:%d-H%d.", pEnvelop->id, pTemp->id, pTemp->headTrainID); + } + else if (TYPE_UCT_ENVELOPE == pTemp->envelopeType) + { + if (ELM_DIR_SAME == dirCheck) + { + if ((0u != pEnvelop->headTrainID) && (pEnvelop->headTrainID != pTemp->trainID[0u])) + { + /** ǰгIDUCTβͬ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, LINE_MAX_TRAIN); + } + else if (pEnvelop->trainID[0u] == pTemp->trainID[0u]) + { + /** Ŀǰûо۱䣬ֱȾUCTĺгID */ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, pTemp->tailTrainID); + } + else + { + /** ǰгΪUCTгеβ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, pTemp->trainID[0u]); + } + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Head suspicious becasue UCT_ELM id:%d-%d.", pEnvelop->id, pTemp->id, pTemp->trainID[0u]); + } + else + { + + if ((0u != pEnvelop->headTrainID) && (pEnvelop->headTrainID != pTemp->trainID[pTemp->trianCnt - 1u])) + { + /** ǰгIDUCTͷͬ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, LINE_MAX_TRAIN); + } + else if (pEnvelop->trainID[0u] == pTemp->trainID[0u]) + { + /** Ŀǰûо۱䣬ֱȾUCTǰг */ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, pTemp->headTrainID); + } + else + { + /** ǰгΪUCTгеβ*/ + chRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, pTemp->trainID[pTemp->trianCnt - 1u]); + } + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Head suspicious becasue UCT_ELM id:%d-%d.", pEnvelop->id, pTemp->id, pTemp->trainID[pTemp->trianCnt - 1u]); + } + } + else + { + /** 账*/ + chRet = CI_SUCCESS; + } + if (CI_ERROR == chRet) + { + ; /*ÿʧܣݲ*/ + } + } + else + { + /** 账*/ + } + + + /*- ذ*/ + pTemp = elm_GetEnvelopeInfoPtr(backEnvelopeid); + if (NULL != pTemp) + { + chRet = CI_SUCCESS; + /** Ƚ緽Ƿͬ */ + dirCheck = elm_DirIsSameELMWithELM(pEnvelop, pTemp); + + if (TYPE_UKT_ENVELOPE == pTemp->envelopeType) + { + /** Ӻ󷽿*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, LINE_MAX_TRAIN); + + /** ά־Լ*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Monitor CT_ELM%d,Add Tail suspicious becasue UKT_ELM id:%d.", pEnvelop->id, pTemp->id) + + /** жUKTǷڰȫλڲ*/ + funRet = elm_PrepareInUINT16Array(pTemp->ACID[0], pEnvelop->ACID, pEnvelop->ACCnt); + + if (CI_SUCCESS == funRet) + { + /** UKT类CTԵ */ + chRet &= elm_DeleteUKTEnvelope(pTemp); + } + else + { + /** 账ֻҪǰ˿*/ + } + } + else if (LINE_MAX_TRAIN == pEnvelop->tailTrainID) + { + /** 󷽴سáڴ˴ĿģΪCTǰʱܳԵUKT */ + } + else if ((ELM_DIR_SAME == dirCheck) && (0u == pEnvelop->tailTrainID) && (0u != pTemp->headTrainID)) + { + /** Ӻ󷽿*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, pTemp->headTrainID); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Tail suspicious becasue ELM id:%d-H%d.", pEnvelop->id, pTemp->id, pTemp->headTrainID); + } + else if ((ELM_DIR_SAME == dirCheck) && (0u != pEnvelop->tailTrainID) && (0u != pTemp->headTrainID) && (pEnvelop->tailTrainID != pTemp->headTrainID)) + { + /** Ӻ󷽿*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, LINE_MAX_TRAIN); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Tail suspicious becasue ELM id:%d-H%d.", pEnvelop->id, pTemp->id, pTemp->headTrainID); + } + else if ((ELM_DIR_CONVERT == dirCheck) && (0u == pEnvelop->tailTrainID) && (0u != pTemp->tailTrainID)) + { + /** Ӻ󷽿*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, pTemp->tailTrainID); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Tail suspicious becasue ELM id:%d-T%d.", pEnvelop->id, pTemp->id, pTemp->tailTrainID); + } + else if ((ELM_DIR_CONVERT == dirCheck) && (0u != pEnvelop->tailTrainID) && (0u != pTemp->tailTrainID) && (pEnvelop->tailTrainID != pTemp->tailTrainID)) + { + /** Ӻ󷽿*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, LINE_MAX_TRAIN); + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Tail suspicious becasue ELM id:%d-T%d.", pEnvelop->id, pTemp->id, pTemp->tailTrainID); + } + else if (TYPE_UCT_ENVELOPE == pTemp->envelopeType) + { + if (ELM_DIR_SAME == dirCheck) + { + if ((0u != pEnvelop->tailTrainID) && (pEnvelop->tailTrainID != pTemp->trainID[pTemp->trianCnt - 1u])) + { + /** ӺгΪ255*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, LINE_MAX_TRAIN); + } + else if (pEnvelop->trainID[0u] == pTemp->trainID[0u]) + { + /** Ŀǰûо۱䣬ֱȾUCTĺг */ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, pTemp->headTrainID); + } + else + { + /** ӺгΪUCTгеͷ*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, pTemp->trainID[pTemp->trianCnt - 1u]); + } + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Tail suspicious becasue UCT_ELM id:%d-%d.", pEnvelop->id, pTemp->id, pTemp->trainID[pTemp->trianCnt - 1u]); + } + else + { + if ((0u != pEnvelop->tailTrainID) && (pEnvelop->tailTrainID != pTemp->trainID[0u])) + { + /** ӺгΪ255*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, LINE_MAX_TRAIN); + } + else if (pEnvelop->trainID[0u] == pTemp->trainID[0u]) + { + /** Ŀǰûо۱䣬ֱȾUCTĺг */ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, pTemp->tailTrainID); + } + else + { + /** ǰгΪUCTгеβ*/ + chRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, pTemp->trainID[0u]); + } + + /** ά־--ά*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Refresh CT_ELM%d,Add Tail suspicious becasue UCT_ELM id:%d-%d.", pEnvelop->id, pTemp->id, pTemp->trainID[0u]); + } + } + else + { + /** 账*/ + } + if (CI_ERROR == chRet) + { + ; /*ÿʧܣݲ*/ + } + } + else + { + /** 账*/ + } + } + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR) + + /** */ + return ret; +} + +/** +* @brief ̬ˢг +* @param[in] UINT16 envelopeID г +* @param[out] UINT8 *handOverFlag лʶ +* @return CI_SUCCESS CTȷسɹ +* CI_ERROR CT󣬷ʧ +* @note +* 1EnvelopeManageAPI.cֵļУδ޸ +*/ +static UINT8 elm_ReFreshCTEnvelope(UINT16 envelopeID, UINT16 trainid, OUT UINT8 *handOverFlag) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; /**/ + const EnvelopeStruct* pEnvelop = NULL; + + /** ȡг */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeID); + + /** ڲУ */ + if ((NULL == pEnvelop) || (NULL == handOverFlag)) + { + /** ID */ + ASSER_ERROR(CI_ERROR == ret, errorCode, 0x80000000u) + ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:input error!", errorCode) + } + else + { + /** ʼλδл */ + (*handOverFlag) = CI_ERROR; + + /** ˢ°Ϣ */ + funRet = elm_ReFreshACInCTEnvelope(pEnvelop, trainid, handOverFlag); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x40000000u); + + if ((CI_SUCCESS == funRet) && (CI_ERROR == (*handOverFlag))) + { + /** лгҪǰ */ + funRet = elm_MonitorCTEnvelopePreAndBack(pEnvelop); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x20000000u); + } + else if ((CI_SUCCESS == funRet) && (CI_SUCCESS == (*handOverFlag))) + { + /** лгҪǰ */ + } + else + { + /** ˢ°Ϣ󣬷ʧ */ + } + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + + /** */ + return ret; +} + + +/** +* @brief CTٴ +* @note ȫǰ᣺һCT粻һCT磻һCT粻ԽһUCT磻UKTļ᲻ܴCTUCT +* 1EnvelopeManageAPI.cֵļУδ޸ +*/ +void elm_CTEnvelopeTrack(void) +{ + /*- ֲ */ + UINT8 funRet = CI_ERROR; /* ֵ */ + UINT8 cycle = 0u; /*ѭ*/ + UINT8 trainCnt = 0u; /*ͨų*/ + UINT8 handOverFlag = CI_ERROR; + UINT16 trainID[TRAIN_SUM_MAX_IN_OC] = { 0u }; /*ͨųID*/ + UINT16 needCheckFlag[TRAIN_SUM_MAX_IN_OC] = { 0u }; /*ͨųҪ鶪־*/ + UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] = { 0u }; /*гİ*/ + UINT16 relEnvelopeCnt = TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + UINT32 errorCode = 0u; /**/ + + /** ȡͨųelm_PrepareCommTrainIDҪʵֶгIDĺϷУ*/ + trainCnt = elm_PrepareCommTrainID(trainID); + + /** еͨų */ + for (cycle = 0u; cycle < trainCnt; cycle++) + { + /** ȡͨųĹID */ + relEnvelopeCnt = elm_GetRelELIdByTrainIDAndType(TYPE_CT_ENVELOPE, trainID[cycle], relEnvelopeID); + + /** ȡȫλõĵλǷ񲻷˹ϵռñ־ */ + funRet = elm_PrepareTrainSafeHeadFlag(trainID[cycle]); + + /** жгǷΪʼг */ + if ((CI_SUCCESS == funRet) && (0u == relEnvelopeCnt)) + { + /** ά־--ά*/ + ELM_LOG(ELM_LOG_FATAL, "info: Create new CT_ELM for train%d.\n", trainID[cycle]) + + /** гΪʼ㱨Ҫһͨų*/ + funRet = elm_AddCTEnvelope(trainID[cycle], &handOverFlag); + + /** жϴǷɹ*/ + if (CI_ERROR == funRet) + { + /** г鶪 */ + needCheckFlag[cycle] = UINT8_MAX; + + /** ͨųʧܣ账άUKT */ + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x80000000u) + ASSER_DEBUG(CI_ERROR == funRet, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Create new CT_ELM for train%d error!", errorCode, trainID[cycle])) + } + else + { + if (CI_SUCCESS == handOverFlag) + { + /** глɾˣ鶪*/ + needCheckFlag[cycle] = UINT8_MAX; + } + else + { + /** ȷҪǷ񶪳 */ + } + } + } + else if ((CI_SUCCESS == funRet) && (1u == relEnvelopeCnt)) + { + /* ֻCTBUT׷ٹ*/ + elm_DealNoCGFollowUt(relEnvelopeID[0u], trainID[cycle]); + + /** ά־--Լ*/ + ELM_LOG(ELM_LOG_FATAL, "info: Refresh CT_ELM id%d for train%d .\n", relEnvelopeID[0u], trainID[cycle]) + + /** г磬ֻҪигİ磬ǰгļ*/ + funRet = elm_ReFreshCTEnvelope(relEnvelopeID[0u], trainID[cycle], &handOverFlag); + + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x40000000u); + ASSER_DEBUG(CI_ERROR == funRet, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Refresh CT_ELM id%d for train%d error,convert to UKT!", errorCode, relEnvelopeID[0u], trainID[cycle])); + + /** жϴǷɹ*/ + if (CI_ERROR == funRet) + { + /** г鶪 */ + needCheckFlag[cycle] = UINT8_MAX; + + /** ɾCT磬UKT */ + funRet = elm_DeleteCTOrUCTEnvelope(relEnvelopeID[0u]); + + /** жǷɹ */ + if (CI_ERROR == funRet) + { + /** ðģ鴦 */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x20000000u) + ASSER_DEBUG(CI_ERROR == funRet, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Refresh CT_ELM id%d for train%d convert to UKT error!", errorCode, relEnvelopeID, trainID[cycle])) + } + else + { + /** */ + } + } + else + { + if (CI_SUCCESS == handOverFlag) + { + /** глɾˣ鶪*/ + needCheckFlag[cycle] = UINT8_MAX; + } + else + { + /** ȷҪǷ񶪳 */ + } + } + } + else if ((CI_ERROR == funRet) && (0u == relEnvelopeCnt)) + { + /** г鶪 */ + needCheckFlag[cycle] = UINT8_MAX; + + /** гĿϣάUKT */ + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x10000000u); + ASSER_DEBUG(CI_ERROR == funRet, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Don't Create new CT_ELM for train%d because switch error!", errorCode, trainID[cycle])); + + } + else if ((CI_ERROR == funRet) && (1u == relEnvelopeCnt)) + { + /** г鶪 */ + needCheckFlag[cycle] = UINT8_MAX; + + /** CTгͷռѹĿϣɾΪUKT */ + (void) elm_DeleteCTOrUCTEnvelope(relEnvelopeID[0u]); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x08000000u); + ASSER_DEBUG(CI_ERROR == funRet, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Delete CT_ELM for train%d because switch error!", errorCode, trainID[cycle])); + } + else + { + /** г鶪 */ + needCheckFlag[cycle] = UINT8_MAX; + /* һCT磬ҪжǷΪUCTĻָ*/ + elm_UCTEnvelopeRecover(trainID[cycle]); + } + + + /** жǷҪ*/ + if (UINT8_MAX == needCheckFlag[cycle]) + { + /** ˵Ѿȫˣж */ + } + else + { + /** ȡͨųĹID */ + relEnvelopeCnt = elm_GetRelELIdByTrainIDAndType(TYPE_CT_ENVELOPE, trainID[cycle], relEnvelopeID); + ASSER_ERROR((0u == relEnvelopeCnt) || (TRAIN_REL_ENVELOPE_SUM_MAX == relEnvelopeCnt), errorCode, 0x08000000u); + + if ((0u == relEnvelopeCnt) || (TRAIN_REL_ENVELOPE_SUM_MAX == relEnvelopeCnt)) + { + /** ڶջ߰紦,ðģ鴦*/ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Train%d losed error!", errorCode, trainID[cycle]); + break; + } + else + { + /** ڶ*/ + } + } + } +} + +/** +* @brief C׷BUT +* @param[in] UINT16 envelopeID г +* @param[in] UINT16 wTrainId гID +* @return +* @note by cgh 20240815 +*/ +void elm_DealNoCGFollowUt(UINT16 wEnvelopeID,UINT16 wTrainId) +{ + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0U;/**/ + const EnvelopeStruct* pEnvelop = NULL; + UINT8 chNoCGFollowUtSwitch = 0U; + ELM_TrainSafeLocStruct safeLoc = { 0U }; /*гȫλ*/ + UINT8 chLinkRelPhySecAGorBGAttr = 0U;/*LINKABD*/ + UINT8 chEnvelopLinkABGAttr = 0U;/*LINKABG*/ + UINT16 wLinkRelatedPhySec = 0U;/*LINK*/ + UINT8 chPhyLjkFlag = 0U;/*м*/ + UINT16 wTrainEnterLjkLinkId = 0U;/*гмLINK ID*/ + UINT32 dwCycNum = 0U;/*ǰں*/ + UINT16 wTempTrainID = 0U;/*ʱ¼гID*/ + UINT8 chTempVirHeadScreenFlag = 0U;/*ʱǰɸ־*/ + UINT8 chTempVirTailScreenFlag = 0U;/*ʱɸ־*/ + UINT8 chAgLinkExistRelCgFlag = 0U;/*AGǷCG־*/ + + /** ȡг */ + pEnvelop = elm_GetEnvelopeInfoPtr(wEnvelopeID); + + /** ڲУ */ + if ((NULL != pEnvelop) && (0U < wTrainId) && (LINE_MAX_TRAIN > wTrainId)) + { + funRet = elm_PrepareTrainSafeLoc(wTrainId, &safeLoc); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x40000000U); + funRet = elm_PrepareTwoPointsSameDir(safeLoc.startPos, pEnvelop->startPos); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x20000000u); /*ô*/ + if (FLAG_UNSET == funRet) + { + /*۷°ɻŵĿDZ֤ڰȫλúͰӦͷβһµ*/ + wTempTrainID = pEnvelop->headTrainID; + funRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, pEnvelop->tailTrainID); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x10000000u); /*ô*/ + funRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, wTempTrainID); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x08000000u); /*ô*/ + + /*ɸѡ־ҲҪ*/ + chTempVirHeadScreenFlag = GetTrainVirHeadScreenPassFlag(wTrainId); + chTempVirTailScreenFlag = GetTrainVirTailScreenPassFlag(wTrainId); + SetTrainVirHeadScreenPassFlag(wTrainId, chTempVirTailScreenFlag); + SetTrainVirTailScreenPassFlag(wTrainId, chTempVirHeadScreenFlag); + } + else + { + /** δ۷ */ + } + + chNoCGFollowUtSwitch = GetNoCGFollowUtSwitch(); + if (FUNC_SWITCH_ON == chNoCGFollowUtSwitch) + { + if (0U == errorCode) + { + chLinkRelPhySecAGorBGAttr = GetLinkRelPhySecAGorBGAttr(safeLoc.endPos.Lnk); + chEnvelopLinkABGAttr = GetLinkRelPhySecAGorBGAttr(pEnvelop->endPos.Lnk); + wLinkRelatedPhySec = GetLinkRelatedPhySec(pEnvelop->endPos.Lnk); + chPhyLjkFlag = GetPhySecLjkFlag(wLinkRelatedPhySec); + chAgLinkExistRelCgFlag = GetAgLinkExistRelCgFlag(safeLoc.endPos.Lnk); + + /*ˢںԴʱȻȫλýAGܻû*/ + if ((LINK_REL_PHYSEC_AG == chLinkRelPhySecAGorBGAttr) && (0U == pEnvelop->headTrainID) + && (LINK_REL_PHYSEC_DEFAULT == chEnvelopLinkABGAttr) && (PHYSICAL_SECTION_LJK_NO == chPhyLjkFlag) + && (AGLINK_EXIST_REL_CG_NO == chAgLinkExistRelCgFlag)) + { + /*гȫͷʻAGҵǰʻǰûǰ˿ҲǴBGijҲCGǰɸͨ־Ч*/ + SetTrainVirHeadScreenPassFlag(wTrainId,TRAIN_VIR_SCREEN_PASS_FLAG_VALID); + SetTrainEnterLjkLinkId(wTrainId, safeLoc.endPos.Lnk); + } + else + { + ; /*öӦ־ȫλúͰAGάԭı־*/ + } + + chLinkRelPhySecAGorBGAttr = GetLinkRelPhySecAGorBGAttr(safeLoc.startPos.Lnk); + chEnvelopLinkABGAttr = GetLinkRelPhySecAGorBGAttr(pEnvelop->startPos.Lnk); + wLinkRelatedPhySec = GetLinkRelatedPhySec(pEnvelop->startPos.Lnk); + chPhyLjkFlag = GetPhySecLjkFlag(wLinkRelatedPhySec); + chAgLinkExistRelCgFlag = GetAgLinkExistRelCgFlag(safeLoc.startPos.Lnk); + + /*ˢںԴʱȻȫλýAGܻû*/ + if ((LINK_REL_PHYSEC_AG == chLinkRelPhySecAGorBGAttr) && (0U == pEnvelop->tailTrainID) + && (LINK_REL_PHYSEC_DEFAULT == chEnvelopLinkABGAttr) && (PHYSICAL_SECTION_LJK_NO == chPhyLjkFlag) + && (AGLINK_EXIST_REL_CG_NO == chAgLinkExistRelCgFlag)) + { + /*гȫβʻAGҵǰʻǰûк˿ҲǴBGijҲCGúɸͨ־Ч*/ + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_VALID); + SetTrainEnterLjkLinkId(wTrainId, safeLoc.startPos.Lnk); + } + else + { + ; /*öӦ־ȫλúͰAGάԭı־*/ + } + + wTrainEnterLjkLinkId = GetTrainEnterLjkLinkId(wTrainId); + /*гȫAռõʱ䣬DּΣλͨD죩ɼռãǰɸͨʶɸͨʶЧ*/ + if ((LINK_REL_PHYSEC_AG == chLinkRelPhySecAGorBGAttr) && (safeLoc.startPos.Lnk == safeLoc.endPos.Lnk) + && (safeLoc.startPos.Lnk == wTrainEnterLjkLinkId) && (AGLINK_EXIST_REL_CG_NO == chAgLinkExistRelCgFlag)) + { + dwCycNum = Get2oo2CurCycleNum(); + SetTrainFullEnterLjkCycNum(wTrainId, dwCycNum); + } + else + { + ; + } + } + else + { + SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainFullEnterLjkCycNum(wTrainId, 0U); + SetTrainEnterLjkLinkId(wTrainId, 0U); + } + } + else + { + ; /*ܿδ򿪲*/ + } + } + else + { + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x80000000U); + } + + ASSER_DEBUG(0U != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:Train%d elm_DealNoCGFollowUt!", errorCode, wTrainId)); +} + +/** +* @brief ɸѡͨ־ +* @param[in] UINT16 wTrainId гID +* @return +* @note by cgh 20240815 +*/ +void elm_ClearVirScreenPassFlag(UINT16 wTrainId) +{ + ELM_TrainSafeLocStruct safeLoc = { 0U }; /*гȫλ*/ + UINT8 chCheckFlag = CI_ERROR; + UINT16 wTrainEnterLjkLinkId = 0U;/*гʻмLINK ID*/ + UINT16 wOrgnJointMainLkId = 0U;/*LINK*/ + UINT16 wTmnlJointMainLkId = 0U;/*յLINK*/ + UINT16 wNeedCheckLinkId = 0U;/*ҪLINK*/ + UINT16 wLinkRelatedPhySec = 0U;/*LINK*/ + UINT8 chCheckOccFlag = 0U;/*ռñ־*/ + UINT8 chAxisOccState = 0U;/*ռ״̬*/ + UINT32 dwOccupyToIdleCount = 0U;/*ռõгʱ*/ + UINT8 chPhyLjkFlag = 0U;/*м*/ + UINT16 wLinkBelongAcId = 0U;/*LINKID*/ + UINT32 dwTrainFullEnterLjkCycNum = 0U;/*гȫʻLJKں*/ + UINT8 chLinkRelPhySecAGorBGAttr = 0U;/*LINKABD*/ + UINT8 chTransmitState = 0U;/*гͨ״̬*/ + UINT16 wTrainIndex = 0U;/*г*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + if ((0U < wTrainIndex) && (LINE_MAX_TRAIN > wTrainIndex)) + { + dwTrainFullEnterLjkCycNum = GetTrainFullEnterLjkCycNum(wTrainId); + wTrainEnterLjkLinkId = GetTrainEnterLjkLinkId(wTrainId); + chLinkRelPhySecAGorBGAttr = GetLinkRelPhySecAGorBGAttr(wTrainEnterLjkLinkId); + + if ((0U != dwTrainFullEnterLjkCycNum) && (LINK_REL_PHYSEC_AG == chLinkRelPhySecAGorBGAttr)) + { + /*ǰгȫʻLJKAGżලDG*/ + /*гȫAռõʱ䣬DּΣλͨD죩ɼռãǰɸͨʶɸͨʶЧ*/ + wOrgnJointMainLkId = GetLinkOrgnJointMainLkIdById(wTrainEnterLjkLinkId); + wTmnlJointMainLkId = GetLinkTmnlJointMainLkById(wTrainEnterLjkLinkId); + wLinkRelatedPhySec = GetLinkRelatedPhySec(wOrgnJointMainLkId); + chPhyLjkFlag = GetPhySecLjkFlag(wLinkRelatedPhySec); + + /*AG߱һLINKβм*/ + if (PHYSICAL_SECTION_LJK_NO == chPhyLjkFlag) + { + wNeedCheckLinkId = wOrgnJointMainLkId; + } + else + { + wNeedCheckLinkId = wTmnlJointMainLkId; + } + + wLinkBelongAcId = GetLinkBelongAcId(wNeedCheckLinkId); + + if ((0U < wLinkBelongAcId) && (wLinkBelongAcId < AXIS_SECTION_SUM_MAX)) + { + chAxisOccState = GetAxisOccupyState(wLinkBelongAcId); + if (AXIS_SECTION_OCCUPY_NO != chAxisOccState) + { + dwOccupyToIdleCount = GetSystemParaOccuToIdleCyc(); + chCheckOccFlag = SystemOverTimeCheck(dwTrainFullEnterLjkCycNum, dwOccupyToIdleCount); + } + else + { + ; /*δռñ*/ + } + } + else + { + /*ȡļδΪ쳣*/ + chCheckOccFlag = CI_TIME_OUT; + } + + if (CI_TIME_OUT == chCheckOccFlag) + { + /*ʱǰɸͨ־Ч*/ + SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainFullEnterLjkCycNum(wTrainId, 0U); + SetTrainEnterLjkLinkId(wTrainId, 0U); + } + else + { + ; + } + } + else + { + ; /*ලDG*/ + } + + + /*гͨҪгλ־*/ + chTransmitState = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_GOOD == chTransmitState) + { + chCheckFlag = elm_PrepareTrainSafeLoc(wTrainId, &safeLoc); + if (CI_SUCCESS == chCheckFlag) + { + /*ͷʻ߻ѹ죬ǰɸͨʶЧβʻ߻ѹ죬úɸͨʶЧ*/ + if (safeLoc.endPos.Lnk != wTrainEnterLjkLinkId) + { + SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + } + else + { + ; /**/ + } + + if (safeLoc.startPos.Lnk != wTrainEnterLjkLinkId) + { + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + } + else + { + ; /**/ + } + + if ((safeLoc.startPos.Lnk != wTrainEnterLjkLinkId) && (safeLoc.endPos.Lnk != wTrainEnterLjkLinkId)) + { + /*гȫڶӦгʻмLINK*/ + SetTrainEnterLjkLinkId(wTrainId, 0U); + SetTrainFullEnterLjkCycNum(wTrainId, 0U); + } + else + { + ; + } + } + else + { + SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainFullEnterLjkCycNum(wTrainId, 0U); + SetTrainEnterLjkLinkId(wTrainId, 0U); + } + } + else + { + ; /*Ҳⷢ*/ + } + } + else + { + ; /**/ + } +} + +/** +* @brief ɸѡͨ־ල +* @param[in] UINT16 wTrainId гID +* @return +* @note by cgh 20240822 +*/ +void elm_VirScreenPassMonitor(void) +{ + UINT16 trainCycle = 0U; + UINT16 wTrainId = 0U; + UINT16 wTrainEnterLjkLinkId = 0U;/*гʻмLINK ID*/ + + /*г*/ + for (trainCycle = 0U; trainCycle < TRAIN_SUM_MAX; trainCycle++) + { + wTrainId = GetTrainId(trainCycle); + wTrainEnterLjkLinkId = GetTrainEnterLjkLinkId(wTrainId); + if (0U != wTrainEnterLjkLinkId) + { + /*˵Ҫȥִмල*/ + elm_ClearVirScreenPassFlag(wTrainId); + } + else + { + ; /*Ҫල*/ + } + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/ELMDataPrepare.c b/TSCP/src/APP/ciapp/EnvelopeManage/ELMDataPrepare.c new file mode 100644 index 0000000..d46c6dd --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/ELMDataPrepare.c @@ -0,0 +1,2575 @@ +#include "ELMDataPrepare.h" +#include "TrainDataManage.h" +#include "AxisSectionConfigDataManage.h" +#include "LinkConfigDataManage.h" +#include "AxisConfigDataManage.h" +#include "dquCbtcConfigData.h" +#include "dquEmapInit.h" +#include "AxisSort_api.h" +#include "SystemParameterManage.h" +#include "LinkConfigDataManage.h" +#include "TrainOnAcManage.h" +#include "dquCIInterFace.h" +#include "CiSystemDefine.h" +#include + +UINT16 OutEnvelopeStrLen = 0U; /*Ҫӡİݳ*/ +UINT8 OutEnvelopeStr[MAX_ENVELOPE_LOG_NUM] = { 0U }; /*Ҫӡİ*/ + +/** +* @brief ӡϢ +* @param[in] const EnvelopeStruct* PEnvelpe ָ +* @return +* @note ־ӡ⺯־ӡ +*/ +void elm_PrintfEnvelope(const EnvelopeStruct* PEnvelpe) +{ +UINT8 cycle = 0U; +UINT8 rrmRequst = 0U; +UINT8 curAct = 0U; +UINT16 nextSta = 0U; +UINT8 runDir = 0U; +UINT8 lastAct = 0U; +UINT8 rrmReply = 0U; +UINT8 rrmReason = 0U; + +if (NULL != PEnvelpe) +{ + ShortToChar(PEnvelpe->id, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + OutEnvelopeStr[OutEnvelopeStrLen++] = PEnvelpe->envelopeType; + ShortToChar(PEnvelpe->headTrainID, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + ShortToChar(PEnvelpe->tailTrainID, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + + OutEnvelopeStr[OutEnvelopeStrLen++] = PEnvelpe->trianCnt; + + for (cycle = 0u; cycle < PEnvelpe->trianCnt; cycle++) + { + ShortToChar(PEnvelpe->trainID[cycle], &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + } + + for (cycle = 0u; cycle < PEnvelpe->trianCnt; cycle++) + { + rrmRequst = GetTrainRrmRqst(PEnvelpe->trainID[cycle]); + curAct = GetTrainActive(PEnvelpe->trainID[cycle]); + nextSta = GetTrainAtsLgcStation(PEnvelpe->trainID[cycle]); + runDir = GetTrainDir(PEnvelpe->trainID[cycle]); + lastAct = PEnvelpe->ACTPort[cycle]; + rrmReply = GetTrainRrmState(PEnvelpe->trainID[cycle]); + rrmReason = GetTrainRrmReson(PEnvelpe->trainID[cycle]); + + ShortToChar(PEnvelpe->trainID[cycle], &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + + OutEnvelopeStr[OutEnvelopeStrLen++] = rrmRequst; + OutEnvelopeStr[OutEnvelopeStrLen++] = curAct; + ShortToChar(nextSta, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + OutEnvelopeStr[OutEnvelopeStrLen++] = runDir; + OutEnvelopeStr[OutEnvelopeStrLen++] = lastAct; + OutEnvelopeStr[OutEnvelopeStrLen++] = rrmReply; + OutEnvelopeStr[OutEnvelopeStrLen++] = rrmReason; + } + ShortToChar(PEnvelpe->startPos.Lnk, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + LongToChar(PEnvelpe->startPos.Off, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 4U; + OutEnvelopeStr[OutEnvelopeStrLen++] = PEnvelpe->startPos.Dir; + + ShortToChar(PEnvelpe->endPos.Lnk, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + LongToChar(PEnvelpe->endPos.Off, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 4U; + OutEnvelopeStr[OutEnvelopeStrLen++] = PEnvelpe->endPos.Dir; + + OutEnvelopeStr[OutEnvelopeStrLen++] = PEnvelpe->ACCnt; + for (cycle = 0u; cycle < PEnvelpe->ACCnt; cycle++) + { + ShortToChar(PEnvelpe->ACID[cycle], &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 2U; + } + + LongToChar(PEnvelpe->dwUCTToUKTStartCycNum, &OutEnvelopeStr[OutEnvelopeStrLen]); + OutEnvelopeStrLen += 4U; +} +else +{ + /**/ +} + +#if (kPLATFORM!=kVXWORKS) +if (NULL != PEnvelpe) +{ + debug_infor_printf((const)"Envelop id:%d,type:%d,H:%d,T:%d,", PEnvelpe->id, PEnvelpe->envelopeType, PEnvelpe->headTrainID, PEnvelpe->tailTrainID); + debug_infor_printf((const)"Tcnt:%d,TId[", PEnvelpe->trianCnt); + + for (cycle = 0u; cycle < PEnvelpe->trianCnt; cycle++) + { + debug_infor_printf((const)"%d,", PEnvelpe->trainID[cycle]); + } + + debug_infor_printf((const)"],rrm["); + for (cycle = 0u; cycle < PEnvelpe->trianCnt; cycle++) + { + rrmRequst = GetTrainRrmRqst(PEnvelpe->trainID[cycle]); + curAct = GetTrainActive(PEnvelpe->trainID[cycle]); + nextSta = GetTrainAtsLgcStation(PEnvelpe->trainID[cycle]); + runDir = GetTrainDir(PEnvelpe->trainID[cycle]); + lastAct = PEnvelpe->ACTPort[cycle]; + rrmReply = GetTrainRrmState(PEnvelpe->trainID[cycle]); + rrmReason = GetTrainRrmReson(PEnvelpe->trainID[cycle]); + + debug_infor_printf((const)"%d-%02x-%d-%d-%02x-%d-%02x-%d,", PEnvelpe->trainID[cycle], rrmRequst, curAct, nextSta, runDir, lastAct, rrmReply, rrmReason); + } + + debug_infor_printf((const)"],S:%d-%d-%d,E:%d-%d-%d,ACCnt:%d,ACID[", PEnvelpe->startPos.Lnk, PEnvelpe->startPos.Off, PEnvelpe->startPos.Dir, \ + PEnvelpe->endPos.Lnk, PEnvelpe->endPos.Off, PEnvelpe->endPos.Dir, PEnvelpe->ACCnt); + + for (cycle = 0u; cycle < PEnvelpe->ACCnt; cycle++) + { + debug_infor_printf((const)"%d,", PEnvelpe->ACID[cycle]); + } + debug_infor_printf((const)"]\n"); +} +#endif +} + + +/** +* @brief ӡDebugϢ +* @param[in] UINT8 level ־ +* @param[in] const char *fmt ӡϢ +* @return +* @note ͨⲿӿڣʵֱģĴӡ +*/ +void elm_PrintDebugInfo(UINT8 level,const char *fmt, ...) +{ +va_list para; +CHAR tmpPrintBuf[ELM_PRINT_LEN] = {'\0'}; + +if (ELM_LOG_LEVEL >= level) +{ + va_start(para,fmt); + (void)vsnprintf(tmpPrintBuf, ELM_PRINT_LEN, fmt, para); + va_end(para); + + debug_infor_printf((const)"%s",tmpPrintBuf); +} +else +{ + /** ־𲻹*/ +} +} + + +/** +* @brief ͨгID׼гİȫϢ +* @param[in] UINT16 trainID гID +* @param[out] INOUT TrainSafeLocStruct* pTrainSafeLoc гȫ +* @return CI_SUCCESS Ҫڴȷسɹ +* CI_ERROR Ҫڴ󣬷ʧ +* @note +*/ +UINT8 elm_PrepareTrainSafeLoc(UINT16 trainID,INOUT ELM_TrainSafeLocStruct* pTrainSafeLoc) +{ +UINT8 chRtnVal = CI_ERROR; +UINT16 wTrainID = (UINT16)(0x1400u + (trainID & 0x00ffu)); + +if (NULL != pTrainSafeLoc) +{ + pTrainSafeLoc->startPos.Lnk = GetTrainSafeTailLink(wTrainID); + pTrainSafeLoc->startPos.Off = GetTrainSafeTailOffset(wTrainID); + pTrainSafeLoc->startPos.Dir = GetTrainSafeTailDir(wTrainID); + pTrainSafeLoc->endPos.Lnk = GetTrainSafeHeadLink(wTrainID); + pTrainSafeLoc->endPos.Off = GetTrainSafeHeadOffset(wTrainID); + pTrainSafeLoc->endPos.Dir = GetTrainSafeHeadDir(wTrainID); + chRtnVal = CI_SUCCESS; +} +return chRtnVal; +} + + + +/** +* @brief ȡOCΧйڼε +* @param[out] OUT UINT16** pACIdBuff ID +* @return 0 ѯ + 1~AXIS_SECTION_SUM_MAX ѯȷ +* @note OCּ֧IDӳϵֱӻȡ +*/ +UINT16 elm_PrepareACBuffIndexs(OUT const UINT16** pACIdBuff) +{ +/*- ֲ */ +UINT16 ret = 0u; /*ֵ*/ +UINT16 tempACCnt = 0u; +UINT32 errorCode = 0u; + +/** ڲУ */ +ASSERT_RET_VALUE(NULL == pACIdBuff,ret,0x80000000u); + +/** ȡ */ +tempACCnt = GetLocalCiAxisSectionIdBuf(pACIdBuff); + +/** жǷѯɹ */ +if ((0u == tempACCnt) || (AXIS_SECTION_SUM_MAX <= tempACCnt)) +{ + /** ô */ + (*pACIdBuff) = NULL; + errorCode = 0x40000000u; +} +else +{ + /** */ + ret = tempACCnt; +} + +/** ÷ֵ */ +ASSERT_SETRET(0u == errorCode,ret,tempACCnt,0u); + +/** */ +return ret; +} + + +/** +* @brief ͨεȡID +* @param[in] UINT16 ACBuffIndex λ +* @return ID +* @note +*/ +UINT16 elm_PrepareACID(UINT16 ACBuffIndex) +{ +UINT16 wRtnVal = UINT16_MAX; +wRtnVal = GetAxisSecId(ACBuffIndex); +return wRtnVal; +} + +/** +* @brief ͨIDȡε +* @param[in] UINT16 ACId ID +* @return λ +* @note +*/ +UINT16 elm_PrepareACIndex(UINT16 ACId) +{ +return GetLocalCiAxisSectionIndex(ACId); +} + + +/** +* @brief ͨIDȡ״̬ +* @param[in] UINT16 ACID ID +* @return ELM_AC_OCC ռ + ELM_AC_FREE +* @note bug 20220420 wqm ռãϵϷռ +*/ +UINT8 elm_PrepareACStatus(UINT16 ACID) +{ + UINT8 ret = ELM_AC_OCC; + UINT8 chRtnVal = AXIS_SECTION_OCCUPY_YES; + + chRtnVal = GetAxisOccupyState(ACID); + ASSERT_SETRET(AXIS_SECTION_OCCUPY_NO == chRtnVal, ret, ELM_AC_FREE, ELM_AC_OCC); + return ret; +} + +/** +* @brief ͨIDѯڲͨʱռ +* @param[in] UINT16 ACID ID +* @return SECTION_OCCUPY_YES ռ + SECTION_OCCUPY_NO ο +*/ +UINT8 elm_PrepareACofSwichPhyStatus(UINT16 ACID) +{ + UINT8 ret = SECTION_OCCUPY_YES; + UINT8 retValIsSwitch = CI_ERROR; /*Ƿڲ־*/ + UINT8 retSwitchCheckSuccess = CI_ERROR; /*εǷλ*/ + + retValIsSwitch = elm_PrepareACIsSwitchZone(ACID); + + if (CI_SUCCESS == retValIsSwitch) + { + retSwitchCheckSuccess = elm_PrepareCheckACofSwichPos(ACID); + if (CI_SUCCESS == retSwitchCheckSuccess) + { + ret = SECTION_OCCUPY_NO; /*λãֱͨӷؿУ迼*/ + } + else + { + ret = elm_PrepareACRelPhyStatus(ACID);/*λã᲻ͨҪضӦεռ״̬*/ + } + } + else + { + ret = SECTION_OCCUPY_NO; /*βڵʱռѹ*/ + } + return ret; +} + +/** +* @brief ͨIDҼλ +* @param[in] UINT16 ACID ID +* @param[in] UINT8 chDir ָյķ +* @param[out] ELM_AxisLocStruct* pACLoc λ +* @return CI_SUCCESS ѯȷسɹ +* CI_ERROR ѯ󣬷ʧ +* @note +*/ +UINT8 elm_PrepareACLoc(UINT16 ACID, UINT8 chDir, ELM_AxisLocStruct* pACLoc) +{ +/*- ֲ */ +UINT8 ret = CI_ERROR; +struct_PathPoint strStart = { 0u }; +struct_PathPoint strEnd = { 0u }; + +UINT32 errorCode = 0u; +UINT16* pLinkIDBuf = NULL; +UINT16 pLinkSum = 0U; + + +/*- ȡΰLinkϢ*/ +pLinkSum = GetAxisLinkSum(ACID); +pLinkIDBuf = GetAxisLinkIdBuf(ACID); +/** ڲУ */ +ASSERT_RET_VALUE(NULL == pACLoc,ret,0x80000000u); +ASSERT_RET_VALUE((ELM_DIR_SAME != chDir) && (ELM_DIR_CONVERT != chDir),ret,0x40000000u); +ASSERT_RET_VALUE(0U == pLinkSum, ret, 0x08000000u); +ASSERT_RET_VALUE(NULL == pLinkIDBuf, ret, 0x04000000u); + +/*- ȡյλ*/ +strStart.wLinkId = pLinkIDBuf[0]; +strStart.dwOffset = 0u; +strEnd.wLinkId = pLinkIDBuf[pLinkSum-1U]; +strEnd.dwOffset = GetLinkLengthById(strEnd.wLinkId); + + +/** жλǷȷ */ +if (((0u != strStart.wLinkId) && (UINT16_MAX != strStart.wLinkId)) || + ((0u != strEnd.wLinkId) && (UINT16_MAX != strEnd.wLinkId))) +{ + /*- λòѯɹλϢ--ٶ޷仯*/ + if (ELM_DIR_SAME == chDir) + { + pACLoc->dir = chDir; + pACLoc->startPos.Lnk = strStart.wLinkId; + pACLoc->startPos.Off = strStart.dwOffset; + pACLoc->startPos.Dir = chDir; + pACLoc->endPos.Lnk = strEnd.wLinkId; + pACLoc->endPos.Off = strEnd.dwOffset; + pACLoc->endPos.Dir = chDir; + } + else + { + pACLoc->dir = chDir; + pACLoc->endPos.Lnk = strStart.wLinkId; + pACLoc->endPos.Off = strStart.dwOffset; + pACLoc->endPos.Dir = chDir; + pACLoc->startPos.Lnk = strEnd.wLinkId; + pACLoc->startPos.Off = strEnd.dwOffset; + pACLoc->startPos.Dir = chDir; + } + + ret = CI_SUCCESS; +} +else +{ + /** ݴ */ + ASSER_ERROR(CI_ERROR == ret,errorCode,0x40000000u); +} + +/** úֵ */ +ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + +/** */ +return ret; +} + +/** +* @brief ͨIDгǰӦ +* @param[in] UINT16 ACID ID +* @param[in] UINT8 chDir ָյķ +* @param[out] UINT16* AxisId ǰѯId +* @return CI_SUCCESS ѯȷسɹ +* CI_ERROR ѯ󣬷ʧ +* Create: fan 2024 3.2 +*/ +UINT8 elm_PrepareACHeadAxisId(UINT16 ACID, UINT8 chDir, UINT16* AxisId) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT16 tmpAxis = 0U; + UINT32 errorCode = 0u; + + /*ڲУ*/ + if (((ELM_DIR_SAME == chDir) || (ELM_DIR_CONVERT == chDir)) + &&(NULL != AxisId)) + { + if (ELM_DIR_SAME == chDir) + { + tmpAxis = GetAxisTmnlAxisId(ACID); + } + else + { + tmpAxis = GetAxisOrgnAxisId(ACID); + } + if (0U != tmpAxis) + { + *AxisId = tmpAxis; + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + else + { + /** ݴ */ + ASSER_ERROR(CI_ERROR == ret, errorCode, 0x40000000u); + } + return ret; +} + +/** +* @brief ͨIDг󷽶Ӧ +* @param[in] UINT16 ACID ID +* @param[in] UINT8 chDir ָյķ +* @param[out] UINT16* AxisId 󷽲ѯId +* @return CI_SUCCESS ѯȷسɹ +* CI_ERROR ѯ󣬷ʧ +* Create: fan 2024 3.2 +*/ +UINT8 elm_PrepareACTailAxisId(UINT16 ACID, UINT8 chDir, UINT16* AxisId) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT16 tmpAxis = 0U; + UINT32 errorCode = 0u; + + /*ڲУ*/ + if (((ELM_DIR_SAME == chDir) || (ELM_DIR_CONVERT == chDir)) + && (NULL != AxisId)) + { + if (ELM_DIR_SAME == chDir) + { + tmpAxis = GetAxisOrgnAxisId(ACID); + } + else + { + tmpAxis = GetAxisTmnlAxisId(ACID); + } + if (0U != tmpAxis) + { + *AxisId = tmpAxis; + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + else + { + /** ݴ */ + ASSER_ERROR(CI_ERROR == ret, errorCode, 0x40000000u); + } + return ret; +} + + +/** +* @brief ͨIDͲѯѯlink +* @param[in] UINT16 ACID ID +* @param[out] UINT16 linkID[] link +* @return 0 Ƿ + 0 link +* @note linkʱղѯ˳򷵻 +*/ +UINT8 elm_PrepareACrelLink(UINT16 ACID,UINT8 dir, INOUT UINT16 linkID[]) +{ +UINT8 chRtnVal = CI_ERROR; +UINT8 chLinkNum = 0u; +UINT16 * pLinkIdBuf = NULL; +UINT8 chIndex = 0u; + +chLinkNum = GetAxisLinkSum(ACID); +pLinkIdBuf = GetAxisLinkIdBuf(ACID); +if(((EMAP_CONVER_DIR != dir) && (EMAP_SAME_DIR != dir)) || (0u == chLinkNum) + || (NULL == linkID)) +{ + ; +} +else +{ + for (chIndex = 0u; chIndex < chLinkNum; chIndex++) + { + if (EMAP_SAME_DIR == dir) + { + linkID[chIndex] = pLinkIdBuf[chIndex]; + } + else + { + linkID[chLinkNum - 1u - chIndex] = pLinkIdBuf[chIndex]; + } + } + chRtnVal = CI_SUCCESS; +} + +return chRtnVal; +} + +/** +* @brief ѯ֮link +* @param[in] LOD_STRU pointA λõA +* @param[in] LOD_STRU pointB λõB +* @param[out] UINT16 linkID[] ֮link +* @return ֮link +* @note pointAλõķΪָpointBķ +*/ +UINT16 elm_PrepareLinkBtwPoints(LOD_STRU pointA,LOD_STRU pointB,INOUT UINT16 linkID[]) +{ +UINT16 chLinkNum = 0u; +UINT8 chDir = 0u; +UINT32 dwLen = UINT32_MAX; +if(NULL == linkID) +{ + ; +} +else +{ + dwLen = dsuLenByPoint(&pointA, &pointB, &chLinkNum, linkID, &chDir); + if (UINT32_MAX != dwLen) + { + ; + } + else + { + chLinkNum = 0u; + } +} +return chLinkNum; +} + + + +/** +* @brief ѯ֮ļ +* @param[in] LOD_STRU pointA λõA +* @param[in] LOD_STRU pointB λõB +* @param[out] UINT16 ACID[] ֮ļ +* @return ֮ļ +* @note pointAλõķΪָpointBķ +*/ +UINT8 elm_PrepareACBtwPoints(LOD_STRU pointA,LOD_STRU pointB,INOUT UINT16 ACID[SECTION_IN_ENVELOPE_SUM_MAX]) +{ +UINT16 wLinkNum = 0u; +UINT8 chDir = 0u; +UINT32 dwLen = UINT32_MAX; +UINT16 wAcNum = 0u; +UINT8 chFunRtn = CI_ERROR; +UINT16 szLink[LINK_SUM_MAX] = {0u}; + + +if (NULL == ACID) +{ + ;/* λݴ */ +} +else +{ + /* ȡlink */ + dwLen = dsuLenByPoint(&pointA, &pointB, &wLinkNum, szLink, &chDir); + if (UINT32_MAX != dwLen) + { + ; + } + else + { + wLinkNum = 0u; + } + + if (0u != wLinkNum) + {/* linkлȡ */ + chFunRtn = GetAxisSeqFromLinkSeq(szLink, wLinkNum, ACID, &wAcNum,SECTION_IN_ENVELOPE_SUM_MAX); + if ((CI_ERROR == chFunRtn )|| (SECTION_IN_ENVELOPE_SUM_MAX < wAcNum)) + { + wAcNum = 0u; + } + else + { + ; /*޲*/ + } + } + else + { + } +} + +/** ֮ļ᲻SECTION_IN_ENVELOPE_SUM_MAXʽǿת */ +return (UINT8)wAcNum; +} + + +/** +* @brief ȡǰOCеͨųгID +* @param[out] UINT16 trainID[TRAIN_SUM_MAX_IN_OC] гID +* @return OCΧͨг +* @note bug 20220420 wqm ע +*/ +UINT8 elm_PrepareCommTrainID(INOUT UINT16 trainID[TRAIN_SUM_MAX_IN_OC]) +{ +/*- ֲ */ +UINT8 chTrainNum = 0u; +UINT8 chIndex = 0u; +UINT16 wTrainId = 0u; +UINT8 chTransmitState = 0u; +UINT32 errorCode = 0u; + +/** ڲУ*/ +if (NULL == trainID) +{ + /** ڲ */ + ASSER_ERROR(NULL == trainID,errorCode,0x80000000u); +} +else +{ + /** ȡͨг */ + for (chIndex = 0u; chIndex < TRAIN_SUM_MAX; chIndex++) + + { + /** ȡг + ID*/ + wTrainId = GetTrainId(chIndex); + + /** ȡгͨ״̬*/ + chTransmitState = elm_PrepareTrainCommStatus(wTrainId); + + /** жͨ״̬Ƿ*/ + if ((ELM_COM_STATUS_OK == chTransmitState) && (chTrainNum < TRAIN_SUM_MAX_IN_OC)) + { + trainID[chTrainNum++] = (UINT16)(wTrainId & 0x00ffu); + } + else + { + /** ͨų */ + } + } +} + +/** */ +return chTrainNum; + +} + + +/** +* @brief ȡгͨ״̬ +* @param[in] UINT16 trainid +* @param[out] +* @return ELM_COM_STATUS_OK ͨ +* ELM_COM_STATUS_ERROR ͨ쳣 +* @note +*/ +UINT8 elm_PrepareTrainCommStatus(IN UINT16 trainID) +{ +UINT8 ret = ELM_COM_STATUS_ERROR; +UINT8 comStatus = TRAIN_COMM_STATE_BAD; +UINT8 chSleepState = TRAIN_SLEEP_NO; +UINT8 trainPosValid = CI_ERROR; + +/** ȡгͨ״̬*/ +comStatus = GetTrainTransitmitStat(trainID); + +/** ȡг״̬*/ +chSleepState = elm_PrepareTrainSleepStatus(trainID); + +/** ȡгλǷЧ */ +trainPosValid = IsTrainPosValid(trainID); + +if (((TRAIN_COMM_STATE_GOOD == comStatus) && (CI_SUCCESS == trainPosValid)) || + ((TRAIN_SLEEP_YES == chSleepState) && (TRAIN_COMM_STATE_BAD == comStatus))) +{ + ret = ELM_COM_STATUS_OK; +} +else +{ + /** ͨ쳣 */ +} + +return ret; +} + +/** +* @brief ȡͨгλǷЧ +* @param[in] UINT16 trainid +* @param[out] +* @return CI_SUCCESS λЧ +* CI_ERROR λЧ +* @note +*/ +UINT8 elm_PrepareTrainPosValid(IN UINT16 trainID) +{ +return IsTrainPosValid(trainID); +} + +/** +* @brief ȡλùϵ +* @param[in] LOD_STRU pointA λA +* @param[in] UINT8 dirAtoB λAָλB +* @param[in] LOD_STRU pointB λB +* @return LOC_BEFORE λBλAǰ + LOC_SAME λAλBغ + LOC_AFTER λAλB + Ƿ +* @note +*/ +UINT8 elm_PrepareRelationBtwPoint(LOD_STRU pointA,UINT8 dirAtoB, LOD_STRU pointB) +{ +UINT16 wLinkNum = 0u; +UINT8 chDir = 0u; +UINT32 dwLen = UINT32_MAX; +UINT16 szLink[LINK_SUM_MAX] = { 0u }; +UINT8 chRtnVal = 0u; + +dwLen = dsuLenByPoint(&pointA, &pointB, &wLinkNum, szLink, &chDir); +if (UINT32_MAX != dwLen) +{ + if (0u == dwLen) + { + chRtnVal = LOC_SAME; + } + else if (chDir == dirAtoB) + { + chRtnVal = LOC_BEFORE; + } + else + { + chRtnVal = LOC_AFTER; + } +} +else +{ + ; +} + +return chRtnVal; +} + + +/** +* @brief ѯǰ/󷽼 +* @param[in] UINT16 ACID ׼ID +* @param[in] UINT8 dir ѯ +* @param[out] UINT16 arACID[AC_MAXCNT_IN_SWITCH] ڼID +* param[out] UINT8* DirectionPointFlag Ƿз仯 DIRECTIONPOINT_FLAG_VALID +* @return UINT8_MAX ѯʧ + 0~AC_MAXCNT_IN_SWITCH ѯɹ +* @note +*/ +UINT8 elm_PrepareAdjacentAC(UINT16 ACID, UINT8 dir, INOUT UINT16 arACID[AC_MAXCNT_IN_SWITCH], UINT8* DirectionPointFlag) +{ +/*- ֲ */ +UINT8 ret = (UINT8)UINT8_MAX; +UINT8 funRtn = CI_ERROR; +UINT8 tmpLinkcnt = 0u; +const UINT16 *pLinkIdBuf = NULL; +UINT16 wBaseLink = 0u; +UINT16 tmpACCnt = 0u; +UINT16 wNextLink = 0u; +UINT16 wSwitchId = 0u; +UINT16 tmpACid[AC_MAXCNT_IN_SWITCH] = {0u}; +UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + +/*- ȡlinkϢ */ +tmpLinkcnt = GetAxisLinkSum(ACID); +pLinkIdBuf = GetAxisLinkIdBuf(ACID); + +/** ڲж */ +if ((0u == tmpLinkcnt) || (NULL == arACID) + || ((EMAP_CONVER_DIR != dir) && (EMAP_SAME_DIR != dir))||(NULL == DirectionPointFlag)) +{ + /** ڲ */ +} +else +{ + /** */ + (void)CommonMemSet(arACID, (UINT32)(sizeof(UINT16)*AC_MAXCNT_IN_SWITCH),0u, (UINT32)(sizeof(UINT16)*AC_MAXCNT_IN_SWITCH)); + + /* ȡ뷽һlink */ + if (EMAP_SAME_DIR == dir) + { + wBaseLink = pLinkIdBuf[tmpLinkcnt - 1u]; + } + else + { + wBaseLink = pLinkIdBuf[0]; + } + + /* ȡһlink */ + wNextLink = FindAdjacentLinkIDSafe(wBaseLink, dir, &wSwitchId, &cDirectionPointFlag); + + *DirectionPointFlag = cDirectionPointFlag; + + if (0u == wNextLink) + { + /** ·ͷѯɹ */ + ret = 0u; + } + else if (UINT16_MAX == wNextLink) + { + /** ݴ󣬷ʧ */ + } + else + { + /** ѯlinkаļ */ + funRtn = GetAxisSeqFromLinkSeq(&wNextLink,1u,tmpACid,&tmpACCnt,AC_MAXCNT_IN_SWITCH); + + /** жϲѯǷɹ */ + if ((CI_SUCCESS == funRtn) && (0u != tmpACCnt) && (tmpACCnt <= AC_MAXCNT_IN_SWITCH)) + { + (void)CommonMemCpy(arACID, (UINT32)(sizeof(UINT16) * AC_MAXCNT_IN_SWITCH),tmpACid, (UINT32)(sizeof(UINT16) * tmpACCnt)); + ret = (UINT8)tmpACCnt; + } + else + { + /** ѯʧ*/ + } + } +} + +return ret; +} + + +/** +* @brief ϲUINT16 +* @param[in] UINT16 dstBuffSize ĿĻС +* @param[in] UINT16 startIndex ĿĻʼַ +* @param[in] const UINT16 srcArray[] Դַ +* @param[in] UINT16 srcBuffSize ԴС +* @param[in] UINT16 mergeSize ϲС +* @param[out] UINT16 dstArray[] ĿĻ +* @return Ŀĺϲַ +* @note ϲʧܣĿĻС +*/ +UINT16 elm_PrepareMergeUINT16Array(INOUT UINT16 dstArray[], UINT16 dstBuffSize, UINT16 startIndex, IN const UINT16 srcArray[], UINT16 srcBuffSize,UINT16 mergeSize) +{ +/*- ֲ*/ +UINT16 wRtnVal = (UINT16)UINT16_MAX; +UINT16 wMergeIndex = startIndex; +UINT16 wIndex = 0u; + +/** ڲУ*/ +if ((NULL == dstArray) || (NULL == srcArray) || ((UINT16_MAX - startIndex) < mergeSize) || + (srcBuffSize < mergeSize) || (dstBuffSize < startIndex + mergeSize)) +{ + /** ڲ */ +} +else +{ + /*- ϲ */ + for (wIndex = 0u; wIndex < mergeSize; wIndex++) + { + dstArray[wMergeIndex++] = srcArray[wIndex]; + } + wRtnVal = wMergeIndex; +} + +/** */ +return wRtnVal; +} + + +/** +* @brief Ƚǰϵ +* @param[in] const EnvelopeStruct pEnvelopeA A +* @param[in] const LOD_STRU* strPointA ׼ +* @param[in] const EnvelopeStruct* pEnvelopeB B +* @return 0x01 AڰBǰ + 0x02 BڰAǰ + 0x03 AB¹ϵ(() )( ()) ͣ () + 0x04 BA¹ϵ(() )( ()) ͣ () + 0x00 ޷Ƚλùϵ +* @note +*/ +UINT8 elm_PrepareRelationBtwEnvelope(IN const EnvelopeStruct* pEnvelopeA, const LOD_STRU strPointBase,IN const EnvelopeStruct* pEnvelopeB) +{ +UINT8 ret = 0u; +UINT8 funRtn = 0u; +UINT8 cABSameDirFlag = 0U; + +funRtn = CheckLinkValid(strPointBase.Lnk, strPointBase.Off); +if ((NULL == pEnvelopeA) || (NULL == pEnvelopeB) || (CI_SUCCESS != funRtn)) +{ + /** ڲ*/ +} +else +{ + funRtn = as_CalcEnvelopeOrder(pEnvelopeA,pEnvelopeB); + + if ((0x01u == funRtn) || (0x02u == funRtn)) + { + cABSameDirFlag = IsPointABSameDir(pEnvelopeA->startPos, strPointBase); /*ж㷽Ƿͬ*/ + if(FLAG_SET == cABSameDirFlag) + { + ret = (0x01u == funRtn) ? 0x02u : 0x01u; + } + else if(FLAG_UNSET == cABSameDirFlag) + { + ret = funRtn; + } + else + { + ret = 0u; + } + } + else + { + ret = funRtn; + } +} +return ret; +} + + +/** +* @brief жֵǷUINT16ֵ +* @param[in] UINT16 targetValue ѯֵ +* @param[in] const UINT16 arValue[] ͻΧ +* @param[in] UINT16 buffsize ͻΧС +* @return CI_SUCCESS ֵָڳͻΧ +* CI_ERROR ֵָڳͻΧ +* @note +*/ +UINT8 elm_PrepareInUINT16Array(UINT16 targetValue,const UINT16 arValue[],UINT16 buffsize) +{ +/*- ֲ */ +UINT8 cRetVal = CI_ERROR; +UINT16 cycle = 0u; + +/** ڲУ */ +if (NULL == arValue) +{ + /** ڲ */ +} +else +{ + /*- ĿֵǷָΧ */ + for (cycle = 0u; cycle < buffsize; cycle++) + { + if (targetValue == arValue[cycle]) + { + cRetVal = CI_SUCCESS; + break; + } + } +} + +/** */ +return cRetVal; +} + +/** +* @brief ͨȡ֮ľ +* @param[in] LOD_STRU pointA λA +* @param[in] LOD_STRU pointB λB +* @return ֮ľ루cm +* @note pointAΪ pointBΪյ +*/ +UINT32 elm_PrepareDistanceBtwPoints(LOD_STRU pointA, LOD_STRU pointB) +{ + UINT32 dwLen = UINT32_MAX; + struct_PathPoint strPointA = { 0u }; + struct_PathPoint strPointB = { 0u }; + UINT8 chDir = 0u; + strPointA.wLinkId = pointA.Lnk; + strPointA.dwOffset = pointA.Off; + strPointB.wLinkId = pointB.Lnk; + strPointB.dwOffset = pointB.Off; + dwLen = DsuAPointToBPoint(&strPointA, &strPointB, &chDir); + if ((EMAP_CONVER_DIR != chDir) && (EMAP_SAME_DIR != chDir)) + { + dwLen = UINT32_MAX; + } + else + { + ; + } + return dwLen; +} + +/** +* @brief ͨгIDȡг +* @param[in] +* @param[out] +* @return гcm +* @note 1ѯɹг򷵻·̳ +*/ +UINT32 elm_PrepareTrainLength(UINT16 trainid) +{ + CBTC_TRAIN_INFO_STRU strTrainInfo = { 0u }; + UINT8 chTrainType = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT32 dwRtnVal = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + /*ȡг*/ + chFunRtn = dquGetTrainType(wTrainID, &chTrainType); + if (CI_SUCCESS == chFunRtn) + { + /*ȡгܲ*/ + (void)dquGetCbtcTrainInfo(chTrainType, &strTrainInfo); + dwRtnVal = (UINT32)strTrainInfo.TrainLength; + } + else + { + dwRtnVal = GetShortestTrainLen(); + } + return dwRtnVal; +} + +/** +* @brief ȡгз +* @param[in] UINT16 trainid гID +* @param[out] +* @return ELM_DIR_SAME ɹ +* ELM_DIR_CONVERT ʧ + Ƿ +* @note +*/ +UINT8 elm_PrepareTrainDir(UINT16 trainid) +{ + UINT8 ret = 0u; + UINT8 chDir = 0u; + chDir = GetTrainDir(trainid); + + if ((ELM_DIR_SAME == chDir) || (ELM_DIR_CONVERT == chDir)) + { + ret = chDir; + } + else + { + /** Ƿ */ + } + + return ret; +} + +/** +* @brief ѯгСȫǰǰ +* @param[in] UINT16 trainid гID +* @param[out] UINT16 acID[AC_MAXCNT_IN_SWITCH] +* @return AC_MAXCNT_IN_SWITCH ʧ + 0~AC_MAXCNT_IN_SWITCH ҳɹ +* @note +*/ +UINT8 elm_PrepareNextAcMinSafeHeadLoc(UINT16 trainid, OUT UINT16 acID[AC_MAXCNT_IN_SWITCH]) +{ + UINT16 wAcId = 0u; + UINT16 wBaseLink = 0u; + UINT16 wNextLink = 0u; + UINT8 chDir = 0u; + UINT8 chNum = 0u; + UINT8 chFunRtn = CI_ERROR; + LinkPointDataStru strPoint = { 0u }; + UINT16 wSwitchId = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + + chDir = GetTrainDir_MinHead(wTrainID); + wBaseLink = GetTrainMinHeadLink(wTrainID); + chFunRtn = IsLinkIdValid(wBaseLink); + if (((DIR_SAME != chDir) && (DIR_CONVERT != chDir)) || (CI_ERROR == chFunRtn)) + {/* βϷ */ + chFunRtn = CI_ERROR; + } + else + { + chFunRtn = GetLinkPointInfo(chDir, wBaseLink, &strPoint); + } + + if (CI_SUCCESS == chFunRtn) + {/* ҵгзlink */ + while ((EMAP_POINT_DOT == strPoint.wPointType) && (CI_SUCCESS == chFunRtn)) + { + /*Ǽ㣬Ƿ*/ + wBaseLink = FindAdjacentLinkIDSafe(wBaseLink, chDir, &wSwitchId, &cDirectionPointFlag); + chFunRtn = GetLinkPointInfo(chDir, wBaseLink, &strPoint); + } + + } + else + { + ; + } + + if (CI_SUCCESS == chFunRtn) + {/* ȡһlink */ + wNextLink = FindAdjacentLinkIDSafe(wBaseLink, chDir, &wSwitchId, &cDirectionPointFlag); + + wAcId = GetLinkBelongAcId(wNextLink); + + acID[chNum++] = wAcId; + } + else + { + ; + } + + return chNum; +} + +/** +* @brief ȡгȫǰλ +* @param[in] UINT16 trainid гID +* @param[out] LOD_STRU *pLoc гλ +* @return CI_SUCCESS ѯɹ +* CI_ERROR ѯʧ +* @note +*/ +UINT8 elm_PrepareMaxSafeHeadLoc(UINT16 trainid, OUT LOD_STRU *pLoc) +{ + UINT8 chRtn = CI_ERROR; + UINT16 wLink = 0u; + UINT32 dwOff = UINT32_MAX; + UINT8 chDir = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + + wLink = GetTrainMaxHeadLink(wTrainID); + dwOff = GetTrainMaxHeadOffset(wTrainID); + chDir = GetTrainDir_MaxHead(wTrainID); + chRtn = CheckLinkValid(wLink, dwOff); + if (CI_SUCCESS == chRtn) + { + pLoc->Dir = chDir; + pLoc->Lnk = wLink; + pLoc->Off = dwOff; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡгСȫǰλ +* @param[in] UINT16 trainid гID +* @param[out] LOD_STRU *pLoc гλ +* @return CI_SUCCESS ѯɹ +* CI_ERROR ѯʧ +* @note +*/ +UINT8 elm_PrepareMinSafeHeadLoc(UINT16 trainid, OUT LOD_STRU *pLoc) +{ + UINT8 chRtn = CI_ERROR; + UINT16 wLink = 0u; + UINT32 dwOff = UINT32_MAX; + UINT8 chDir = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + + wLink = GetTrainMinHeadLink(wTrainID); + dwOff = GetTrainMinHeadOffset(wTrainID); + chDir = GetTrainDir_MinHead(wTrainID); + chRtn = CheckLinkValid(wLink, dwOff); + if (CI_SUCCESS == chRtn) + { + pLoc->Dir = chDir; + pLoc->Lnk = wLink; + pLoc->Off = dwOff; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡгȫǰ +* @param[in] UINT16 trainid гID +* @return ID +* @note +*/ +UINT16 elm_PrepareACOfMaxSafeHeadLoc(UINT16 trainid) +{ + UINT16 wMinHeadLink = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT16 wRtn = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + wMinHeadLink = GetTrainMaxHeadLink(wTrainID); + chFunRtn = IsLinkIdValid(wMinHeadLink); + if (CI_SUCCESS == chFunRtn) + { + wRtn = GetLinkBelongAcId(wMinHeadLink); + } + else + { + ; + } + + return wRtn; +} + +/** +* @brief ȡгСȫǰ +* @param[in] UINT16 trainid гID +* @return ID +* @note +*/ +UINT16 elm_PrepareACOfMinSafeHeadLoc(UINT16 trainid) +{ + UINT16 wMinHeadLink = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT16 wRtn = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + wMinHeadLink = GetTrainMinHeadLink(wTrainID); + chFunRtn = IsLinkIdValid(wMinHeadLink); + if (CI_SUCCESS == chFunRtn) + { + wRtn = GetLinkBelongAcId(wMinHeadLink); + } + else + { + ; + } + + return wRtn; +} + + +/** +* @brief ѯгȫ󷽼 +* @param[in] UINT16 trainid гID +* @param[out] UINT16 acID[AC_MAXCNT_IN_SWITCH] +* @return ҳɹļ +* @note bug 20220420 wqm Ӧȡȫlink ID +*/ +UINT8 elm_PrepareNextAcMaxSafeTailLoc(UINT16 trainid, OUT UINT16 acID[AC_MAXCNT_IN_SWITCH]) +{ + UINT16 wAcId = 0u; + UINT16 wBaseLink = 0u; + UINT16 wNextLink = 0u; + UINT8 chDir = 0u; + UINT8 chNum = 0u; + UINT8 chFunRtn = CI_ERROR; + LinkPointDataStru strPoint = { 0u }; + UINT16 wSwitchId = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + + chDir = GetTrainDir_MaxTail(wTrainID); + wBaseLink = GetTrainMaxTailLink(wTrainID); /* bug 20220420 wqm Ӧȡȫlink ID*/ + chFunRtn = IsLinkIdValid(wBaseLink); + if (((DIR_SAME != chDir) && (DIR_CONVERT != chDir)) || (CI_ERROR == chFunRtn)) + {/* ηǷ */ + chFunRtn = CI_ERROR; /*chFunRtnΪCI_SUCCESSʱǷֹȻִ*/ + } + else + { + chDir = (UINT8)(~chDir); + chFunRtn = GetLinkPointInfo(chDir, wBaseLink, &strPoint); + } + + if (CI_SUCCESS == chFunRtn) + {/* ҵгзlink */ + while ((EMAP_POINT_DOT == strPoint.wPointType) && (CI_SUCCESS == chFunRtn)) + { + /*Ǽ㣬Ƿ仯*/ + wBaseLink = FindAdjacentLinkIDSafe(wBaseLink, chDir, &wSwitchId, &cDirectionPointFlag); + chFunRtn = GetLinkPointInfo(chDir, wBaseLink, &strPoint); + } + + } + else + { + ; + } + + if (CI_SUCCESS == chFunRtn) + {/* ȡһlinkڼ */ + wNextLink = FindAdjacentLinkIDSafe(wBaseLink, chDir, &wSwitchId, &cDirectionPointFlag); + + wAcId = GetLinkBelongAcId(wNextLink); + + acID[chNum++] = wAcId; + } + else + { + ; + } + + return chNum; +} + + +/** +* @brief ȡгȫλ +* @param[in] UINT16 trainid гID +* @param[out] LOD_STRU *pLoc гλ +* @return CI_SUCCESS ѯɹ +* CI_ERROR ѯʧ +* @note +*/ +UINT8 elm_PrepareMaxSafeTailLoc(UINT16 trainid, OUT LOD_STRU *pLoc) +{ + UINT8 chRtn = CI_ERROR; + UINT16 wLink = 0u; + UINT32 dwOff = UINT32_MAX; + UINT8 chDir = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + wLink = GetTrainMaxTailLink(wTrainID); + dwOff = GetTrainMaxTailOffset(wTrainID); + chDir = GetTrainDir_MaxTail(wTrainID); + chRtn = CheckLinkValid(wLink, dwOff); + if (CI_SUCCESS == chRtn) + { + pLoc->Dir = chDir; + pLoc->Lnk = wLink; + pLoc->Off = dwOff; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡгСȫλ +* @param[in] UINT16 trainid гID +* @param[out] LOD_STRU *pLoc гλ +* @return CI_SUCCESS ѯɹ +* CI_ERROR ѯʧ +* @note +*/ +UINT8 elm_PrepareMinSafeTailLoc(UINT16 trainid, OUT LOD_STRU *pLoc) +{ + UINT8 chRtn = CI_ERROR; + UINT16 wLink = 0u; + UINT32 dwOff = UINT32_MAX; + UINT8 chDir = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + wLink = GetTrainMinTailLink(wTrainID); + dwOff = GetTrainMinTailOffset(wTrainID); + chDir = GetTrainDir(wTrainID); + chRtn = CheckLinkValid(wLink, dwOff); + if (CI_SUCCESS == chRtn) + { + pLoc->Dir = chDir; + pLoc->Lnk = wLink; + pLoc->Off = dwOff; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡгȫ +* @param[in] UINT16 trainid гID +* @return ID +* @note +*/ +UINT16 elm_PrepareACOfMaxSafeTailLoc(UINT16 trainid) +{ + UINT16 wMaxTailLink = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT16 wRtn = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + wMaxTailLink = GetTrainMaxTailLink(wTrainID); + chFunRtn = IsLinkIdValid(wMaxTailLink); + if (CI_SUCCESS == chFunRtn) + { + wRtn = GetLinkBelongAcId(wMaxTailLink); + } + else + { + ; + } + + return wRtn; +} + +/** +* @brief ȡгСȫ +* @param[in] UINT16 trainid гID +* @return ID +* @note +*/ +UINT16 elm_PrepareACOfMinSafeTailLoc(UINT16 trainid) +{ + UINT16 wMaxTailLink = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT16 wRtn = 0u; + UINT16 wTrainID = (UINT16)(0x1400u + (trainid & 0x00ffu)); + + wMaxTailLink = GetTrainMinTailLink(wTrainID); + chFunRtn = IsLinkIdValid(wMaxTailLink); + if (CI_SUCCESS == chFunRtn) + { + wRtn = GetLinkBelongAcId(wMaxTailLink); + } + else + { + ; + } + + return wRtn; +} + +/** +* @brief ȡг״̬ +* @param[in] UINT16 trainid гID +* @param[out] +* @return TRAIN_SLEEP_YES ״̬ + TRAIN_SLEEP_NO δ״̬ + Ƿ +* @note +*/ +UINT8 elm_PrepareTrainSleepStatus(UINT16 trainid) +{ + UINT8 ret = TRAIN_SLEEP_NO; + ret = GetTrainSleepState(trainid); + return ret; +} + +/** +* @brief ȡǷڱOC +* @param[in] UINT16 acID ID +* @param[out] UINT8 *pOCId OCid +* @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ +* @note +*/ +UINT8 elm_PrepareACIsSelf(UINT16 acID,UINT8 *pOCId) +{ + /*- ֲ */ + UINT8 ret = 0u; + UINT8 localOCid = 0u; + UINT8 acBelongOcid = 0u; + + /** ڲУ */ + if (NULL == pOCId) + { + /** ڲ */ + } + else + { + /** ȡOCid */ + localOCid = GetSystemParaLocalCiId(); + + /** ȡOC id 255*/ + acBelongOcid = (UINT8)GetAxisBelongTioc(acID); + + if ((0u == localOCid) || (0u == acBelongOcid)) + { + /** ݳʼ */ + } + else if (localOCid == acBelongOcid) + { + /** һOC*/ + (*pOCId) = acBelongOcid; + ret = ELM_BELONG_OWNER; + } + else + { + /** ͬһOC*/ + (*pOCId) = acBelongOcid; + ret = ELM_BELONG_OTHER; + } + } + + return ret; +} + +/** +* @brief ȡǷȫڱOC +* @param[in] const EnvelopeStruct* Ptemp +* @param[out] +* @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + CI_ERRORǷ +* @note +*/ +UINT8 elm_PrepareEnvelopeIsSelf(IN const EnvelopeStruct* ptemp) +{ + UINT8 ret = CI_ERROR; + UINT16 localOCid = 0u; + UINT16 pointABelongOcid = 0u; + UINT16 pointBBelongOcid = 0u; + + /** ڲϷУ */ + ASSERT_RET_VALUE(NULL == ptemp,ret,0x80000000u); + + /** ȡOCid */ + localOCid = GetSystemParaLocalCiId(); + + /** ȡAOC */ + pointABelongOcid = GetLinkManageTiocById(ptemp->startPos.Lnk); + + /** ȡBOC */ + pointBBelongOcid = GetLinkManageTiocById(ptemp->endPos.Lnk); + + if ((localOCid == pointABelongOcid) && (localOCid == pointBBelongOcid)) + { + /** һOC*/ + ret = ELM_BELONG_OWNER; + } + else if((localOCid != pointABelongOcid) && (localOCid != pointBBelongOcid)) + { + /** ͬһOC*/ + ret = ELM_BELONG_OTHER; + } + else + { + /** ķ֧ */ + } + + return ret; +} + +/** +* @brief ȡ[A,B]ΧȫڱOCķΧ[A',B'] +* @param[in] +* @param[out] LOD_STRU *pointA ȡֽ +* @param[out] LOD_STRU *pointB ȡֽ +* @param[out] UINT8* cutFlag ȡ־ +* @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ +* @note +*/ +UINT8 elm_PrepareCutZoneInSelf(INOUT LOD_STRU *pointA,INOUT LOD_STRU *pointB, INOUT UINT8* cutFlag) +{ + /*- ֲ */ + UINT8 ret = 0u; + UINT8 funRtn = CI_ERROR; + UINT16 localOCid = 0u; + UINT16 pointABelongOcid = 0u; + UINT16 pointBBelongOcid = 0u; + LOD_STRU temp = {0u}; + + /** ڲУ */ + if ((NULL == pointA) || (NULL == pointB) || (NULL == cutFlag)) + { + /** ڲ */ + } + else + { + + /** ȡOCid */ + localOCid = GetSystemParaLocalCiId(); + + /** ȡAOC */ + pointABelongOcid = GetLinkManageTiocById(pointA->Lnk); + + /** ȡBOC */ + pointBBelongOcid = GetLinkManageTiocById(pointB->Lnk); + + + if ((0u == localOCid) || (0u == pointABelongOcid) || (0u == pointBBelongOcid)) + { + /** ݳʼ */ + } + else if ((localOCid == pointABelongOcid) && (localOCid == pointBBelongOcid)) + { + /** һOC*/ + ret = ELM_BELONG_OWNER; + (*cutFlag) = ELM_NO_CUT; + } + else if((localOCid != pointABelongOcid) && (localOCid != pointBBelongOcid)) + { + /** ͬһOC*/ + ret = ELM_BELONG_OTHER; + (*cutFlag) = ELM_NO_CUT; + } + else if ((localOCid != pointABelongOcid) && (localOCid == pointBBelongOcid)) + { + + /** ˵ŷֽ βڱOC*/ + funRtn = GetCfpLocByTwoPointsEx((*pointA),(*pointB),&temp); + (*cutFlag) = ELM_TAIL_CUT; + + /** ݲѯóڲ */ + ASSERT_SETRET(CI_SUCCESS == funRtn,(*pointA),temp,(*pointA)); + + /** ݲѯ÷ֵ*/ + ASSERT_SETRET(CI_SUCCESS == funRtn,ret,ELM_BELONG_OWNER,0u); + } + else if ((localOCid == pointABelongOcid) && (localOCid != pointBBelongOcid)) + { + /** ˵ŷֽ ͷڱOC*/ + funRtn = GetCfpLocByTwoPointsEx((*pointA),(*pointB),&temp); + (*cutFlag) = ELM_HEAD_CUT; + + /** ݲѯóڲ */ + ASSERT_SETRET(CI_SUCCESS == funRtn,(*pointB),temp,(*pointB)); + + /** ݲѯ÷ֵ*/ + ASSERT_SETRET(CI_SUCCESS == funRtn,ret,ELM_BELONG_OWNER,0u); + } + else + { + /** ɷֵ֧*/ + } + } + + /** */ + return ret; +} + + +/** +* @brief ȡOCͨŵOCid +* @param[out] UINT8 *pOCIDbuff OCid +* @return OCͨ +* @note bug 20220420 wqm ע +*/ +UINT8 elm_PrepareComOCID(IN const UINT8 **pOCIDbuff) +{ + /*- ֲ */ + UINT8 ret = 0u; + + /** ڲУ */ + if (NULL == pOCIDbuff) + { + /** ڲ󣬷0,ⲿ*/ + } + else + { + /** ȡOCͨŵOC */ + ret = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI); + + /** жǷڣֱӷ*/ + if (0u == ret) + { + /** OC */ + } + else + { + /** ȡͨŵTIOC ID */ + (*pOCIDbuff) = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI); + } + } + + return ret; +} + + +/** +* @brief ȡOCͨ״̬ +* @param[in] UINT8 OCID +* @return ELM_COM_STATUS_ERROR ͨ״̬ + ELM_COM_STATUS_OK ͨ״̬ȷ +* @note +*/ +UINT8 elm_PrepareOCCommStatus(UINT8 OCID) +{ + /*- ֲ */ + UINT8 ret = ELM_COM_STATUS_ERROR; + UINT8 funRtn = TRANSMIT_STATE_BAD; + + /** ȡOCͨ״̬ */ + funRtn = GetCiTransmitState(CI_SYSTEM_TYPE_CI,OCID); + + /** úֵ */ + ASSERT_SETRET(TRANSMIT_STATE_GOOD == funRtn,ret,ELM_COM_STATUS_OK,ELM_COM_STATUS_ERROR) + +/** */ +return ret; +} + +/** +* @brief ȡλõOC +* @param[in] +* @param[out] +* @return +* @note +*/ +UINT8 elm_PreparePointIsSelf(IN const LOD_STRU *pointA,UINT8 *pOCId) +{ + /*- ֲ */ + UINT8 ret = 0u; + UINT8 pointBelongOcid = 0u; + UINT8 localOCid = 0u; + + /** ڲж */ + if ((NULL == pointA) || (NULL == pOCId)) + { + /**ڲ */ + } + else + { + /** ȡOCid */ + localOCid = GetSystemParaLocalCiId(); + + /** ȡAOCid,OCIdᳬ255 */ + pointBelongOcid = (UINT8)GetLinkManageTiocById(pointA->Lnk); + + if ((0u != localOCid) && (0u != pointBelongOcid)) + { + (*pOCId) = pointBelongOcid; + ret = (localOCid == pointBelongOcid) ? ELM_BELONG_OWNER : ELM_BELONG_OTHER; + } + else + { + /** ѯ*/ + } + } + return ret; +} + + +/** +* @brief ȡOC͵İϢ +* @param[in] UINT8 OCid +* @param[out] CfpEnvelopeStruct *pInfEnvelope ӿڰϢ +* @return +* @note +*/ +UINT8 elm_PrepareNextOcInfEnvelope(UINT8 OCid,CfpEnvelopeStruct *pInfEnvelope) +{ + return GetOtherOcEnvelope(OCid,pInfEnvelope); +} + + +/** +* @brief ȡӦϢַ +* @param[in] +* @param[out] +* @return +* @note +*/ +const AxisAsserStruct* elm_PrepareAxisAssertInfoPtr(UINT16 ACID) +{ + return aam_GetAxisAssertInfoPtr(ACID); +} + +/** +* @brief ȡȫλõĵλǷ񲻷˹ϵռñ־ +* @param[in] гID +* @param[out] +* @return CI_SUCCESS ˹ϵռ +* CI_ERROR ˹ϵռ +* @note +*/ +UINT8 elm_PrepareTrainSafeHeadFlag(UINT16 trainId) +{ + UINT8 ret = CI_ERROR; + UINT16 funRtn = TRAIN_HEAD_FLAG_YES; + UINT16 wTrainID = (UINT16)(0x1400u + (trainId & 0x00ffu)); + + funRtn = GetTrainSafeHeadFlag(wTrainID); + + ret = (TRAIN_HEAD_FLAG_NO == funRtn) ? CI_SUCCESS : CI_ERROR; + return ret; +} + + +/** +* @brief ȡID +* @param[in] UINT16 ACID Id +* @param[out] +* @return 0 ѯʧ + >0 ѯɹ +* @note +*/ +UINT16 elm_PrepareACRelPhyId(UINT16 ACID) +{ + return GetAxisSecRelativePhySecId(ACID); +} + +/** +* @brief ȡ״̬ +* @param[in] ID +* @param[out] +* @return AAM_API_AC_ARB ARB + AAM_API_AC_REDUNARB ARB + AAM_API_AC_UT UT + AAM_API_AC_REDUNUT UT +* @note +*/ +UINT8 elm_PrepareACAssertStatus(UINT16 ACID) +{ + return aam_GetACAssertStatus(ACID); +} + +/** +* @brief ȡ״̬ +* @param[in] ID +* @param[out] +* @return AAM_UT_PASS ͨ + AAM_CT_PASS óͨ +* @note +*/ +UINT8 elm_PrepareACPassTrainFlag(UINT16 ACID) +{ + return aam_GetACPassTrainFlag(ACID); +} + + +/** +* @brief жϼǷΪ +* @param[in] UINT16 ACID ID +* @param[out] +* @return +* @note CI_SUCCESS Ϊ +* CI_ERROR Ϊ +*/ +UINT8 elm_PrepareACIsSwitchZone(UINT16 ACID) +{ + UINT8 ret = CI_ERROR; + UINT8 switchCnt = 0u; + + /** ȡΰĵ */ + switchCnt = GetAxisSwitchSum(ACID); + + /** úֵ */ + ASSERT_SETRET(0u != switchCnt,ret,CI_SUCCESS,CI_ERROR); + + /** */ + return ret; +} + +/** +* @brief жϼǷ˹ϵ +* @param[in] UINT16 ACID ID +* @param[out] +* @return CI_SUCCESS ˹ϵ +* CI_ERROR ˹ϵ +* @note ע᲻ڲ򷵻ط˹ϵ +*/ +UINT8 elm_PrepareCheckACofSwichPos(UINT16 ACID) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 switchCnt = 0u; + UINT8 tmpSwPos = SWITCH_POSITION_INVALID; + const AxisSwitchStruct* pSwitch = NULL; + + /** ȡΰĵ */ + switchCnt = GetAxisSwitchSum(ACID); + pSwitch = GetAxisSwitchIdStru(ACID); + + if (NULL != pSwitch) + { + /** жϵǷԤ*/ + for (cycle = 0u; cycle < switchCnt; cycle++) + { + tmpSwPos = GetSwitchCurPosition(pSwitch[cycle].SwitchId); + + if (tmpSwPos != pSwitch[cycle].SwitchPosition) + { + break; + } + } + + /** úֵ */ + if (cycle == switchCnt) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + else + { + /** ݲѯ󣬷ز˹ϵ */ + } + + return ret; +} + +/** +* @brief ĺóͨ־λ +* @param[in] UINT16 ACID ID +* @param[out] +* @return +* @note +*/ +void elm_PrepareClearSwPassTrainFlag(UINT16 ACID) +{ + /*- ֲ */ + UINT16 phyId = 0u; + UINT8 cycle = 0u; + UINT8 acCnt = 0u; + const UINT16* acIDBuff = NULL; + + /** ȡζӦ */ + phyId = GetAxisSecRelativePhySecId(ACID); + + /** ȡΰļ */ + acCnt = GetPAxisSectionSum(phyId); + acIDBuff = GetPAxisSectionIdBuf(phyId); + + if (NULL == acIDBuff) + { + (void)aam_ClearACPassTrainFlag(ACID); + } + else + { + for (cycle = 0u; cycle < acCnt; cycle++) + { + (void)aam_ClearACPassTrainFlag(acIDBuff[cycle]); + } + } +} + +/** +* @brief ȡεռ״̬ +* @param[in] UINT16 ACID ID +* @param[out] +* @return SECTION_OCCUPY_YES ռ + SECTION_OCCUPY_NO ο +* @note +*/ +UINT8 elm_PrepareACRelPhyStatus(UINT16 ACID) +{ + /*- ֲ */ + UINT8 ret = SECTION_OCCUPY_YES; + UINT16 phyId = 0u; + phyId = elm_PrepareACRelPhyId(ACID); + + /** ѯ״̬ */ + ret = GetPhySecCurOccupyState(phyId); + + if (SECTION_OCCUPY_NO == ret) + { + /** οУ*/ + } + else + { + /** Ϊռ */ + ret = SECTION_OCCUPY_YES; + } + + /** */ + return ret; +} + +/** +* @brief ȡɳ崻ʱ +* @param[in] +* @param[out] +* @return ʱ +* @note +*/ +UINT8 elm_PrepareCTFlyingRedunTime(void) +{ + return GetCTFlyingRedunCount(); +} + +/** +* @brief ӿڣȡǷںóͨ +* @param[in] UINT16 acID +* @param[out] +* @return AAM_CT_PASS κóͨ +AAM_UT_PASS λͨ +*/ +UINT8 elm_PreparACRelPhyPasTrainFlag(UINT16 acID) +{ + return aam_GetACRelPhyPassTrainFlag(acID); +} + +/** +* @brief ״̬ѯ֮ļ +* @param[in] LOD_STRU pointA λõA +* @param[in] LOD_STRU pointB λõB +* @param[out] UINT16 ACID[] ֮ļ +* @return ֮ļ +* @note pointAλõķΪָpointBķ +* creat by lxc 2022/6/17 +*/ +UINT8 elm_PrepACBtwPointsBySwitchSta(LOD_STRU pointA, LOD_STRU pointB, INOUT UINT16 ACID[MAX_AC_IN_TRAIN]) +{ + UINT16 wLinkNum = 0u; + UINT8 chDir = 0u; + UINT32 dwLen = UINT32_MAX; + UINT16 wAcNum = 0u; + UINT8 chFunRtn = CI_ERROR; + AxisSectionConfigDataStruct * pAxisTemp = NULL; + UINT16 szLink[LINK_SUM_MAX] = { 0u }; + UINT8 cSwtichSum = 0u; /* */ + DQU_POINT_STATUS_STRU szSwitchInfo[50] = {0u}; + + pAxisTemp = GetAxisSecConfigData(); + + if (NULL == ACID) + { + ;/* λݴ */ + } + else + { + + /* ȡе״̬ */ + cSwtichSum = GetLocalSwitchState(szSwitchInfo); + + if (UINT8_MAX != cSwtichSum) + { + /* ȡlink */ + dwLen = dsuLenByPointAndSwitch(&pointA, &pointB, cSwtichSum, szSwitchInfo, &wLinkNum, szLink, &chDir); + if (UINT32_MAX != dwLen) + { + ; + } + else + { + wLinkNum = 0u; + } + } + else + { + ; /* ȡʧ */ + } + + if (0u != wLinkNum) + {/* linkлȡ */ + chFunRtn = GetAxisSeqFromLinkSeq(szLink, wLinkNum, ACID, &wAcNum, SECTION_IN_ENVELOPE_SUM_MAX); + if ((CI_ERROR == chFunRtn )|| ( SECTION_IN_ENVELOPE_SUM_MAX < wAcNum)) + { + wAcNum = 0u; + } + else + { + ; + } + } + else + { + ; + } + } + + /** ֮ļ᲻SECTION_IN_ENVELOPE_SUM_MAXʽǿת */ + return (UINT8)wAcNum; +} + + +/** +* @brief жUINT16ǷUINT16ֵ +* @param[in] const UINT16 szSrcArray[] Դ +* @param[in] const UINT16 wSrcArrayLen +* @param[in] const UINT16 szDstArray[] жϵ +* @param[in] const UINT16 wDstArrayLen +* @return CI_SUCCESS ֵָڳͻΧ +* CI_ERROR ֵָڳͻΧ +* @note +*/ +UINT8 elm_PrepareUINT16ArrayInArray(const UINT16 szSrcArray[],const UINT16 wSrcArrayLen, const UINT16 szDstArray[], const UINT16 wDstArrayLen) +{ + /*- ֲ */ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0u; + + /** ڲУ */ + if ((NULL == szSrcArray) || (NULL == szDstArray) || (0u == wSrcArrayLen) || (0u == wDstArrayLen)) + { + /** ڲ */ + } + else + { + if (wDstArrayLen > wSrcArrayLen) + { + ; /* סʧ */ + } + else + { + /*- ĿֵǷָΧ */ + for (ii = 0u; ii < wDstArrayLen; ii++) + { + cRetVal = elm_PrepareInUINT16Array(szDstArray[ii], szSrcArray, wSrcArrayLen); + + if (CI_ERROR == cRetVal) + { + break; + } + } + + if (ii == wDstArrayLen) + { + cRetVal = CI_SUCCESS; + } + } + } + + /** */ + return cRetVal; +} + + +/** +* @brief ȡUCTܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ +* CI_ERROR ܹر +* @note +*/ +UINT8 elm_PrepareUCTSwitch(void) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chSwitch = FUNC_SWITCH_OFF; + chSwitch = GetCiFunctionSwitchConfig(FUNC_UCT_SWITCH); + if (FUNC_SWITCH_ON == chSwitch) + { + chRtn = CI_SUCCESS; + } + else + { + ; + } + return chRtn; +} + + +/** +* @brief ȡֽ +* @param[out] UINT16 szAcId[CUTOFF_POINT_SUM_MAX] +* @return 0~CUTOFF_POINT_SUM_MAX-1 ֽ +CUTOFF_POINT_SUM_MAX ʧ +* @note +*/ +UINT8 elm_PrepareCfpAc(UINT16 szAcId[CUTOFF_POINT_SUM_MAX]) +{ + UINT16 wCfpNum = 0u; + UINT16 wCfpIndex = 0u; + UINT8 chAcNum = 0u; + UINT16 wCfpId = 0u; + UINT16 wLinkId = 0u; + UINT16 wAcId = 0u; + wCfpNum = GetCfpSum(); + for (wCfpIndex = 0u; wCfpIndex < wCfpNum; wCfpIndex++) + { + wCfpId = GetCfpId(wCfpIndex); + wLinkId = GetCfpInFirstLink(wCfpId); + wAcId = GetLinkBelongAcId(wLinkId); + if (0u != wAcId) + { + szAcId[chAcNum++] = wAcId; + } + else + { + chAcNum = CUTOFF_POINT_SUM_MAX; + break; + } + } + return chAcNum; +} + +/** +* @brief ȡڿڼ,ڿʻ򱾿ķ +* @param[in] const UINT16 wBaseAc ׼ +* @param[out] UINT8 * pDir 뵽ķ +* @param[out] pFindAc[AC_MAXCNT_IN_SWITCH] ڼ +* pDirChangePointFlag 仯־ +* @return UINT8_MAX ѯʧ + 0~AC_MAXCNT_IN_SWITCH ѯɹ +* @note +*/ +UINT8 elm_PrepareCfpOtherTiocAc(const UINT16 wBaseAc, UINT8 * pDir, UINT16 pFindAc[AC_MAXCNT_IN_SWITCH], UINT8* pDirChangePointFlag) +{ + UINT8 ret = UINT8_MAX; + UINT8 cycle = 0u; + UINT8 acCnt = 0u; + UINT16 acIdbuff[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT8 funRet = CI_ERROR; + UINT8 OCId = 0; + UINT8 chDir = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + /** ڲϷУ */ + ASSERT_RET_VALUE(NULL == pDir,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == pFindAc,ret,0x0000000u); + + /** ߼ѯ */ + chDir = ELM_DIR_SAME; + acCnt = elm_PrepareAdjacentAC(wBaseAc, chDir, acIdbuff, &cDirectionPointFlag); + + if (UINT8_MAX == acCnt) + { + /** ѯʧܣֵʧ */ + } + else + { + /** жϼǷڱOC */ + funRet = elm_PrepareACIsSelf(acIdbuff[0u],&OCId); + + if (ELM_BELONG_OTHER == funRet) + { + /** Ϊֽ㣬÷ֵ*/ + if (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) + { + *pDir = chDir; + } + else + { + *pDir = ~chDir; + } + ret = acCnt; + for (cycle = 0u;cycle < acCnt;cycle++) + { + pFindAc[cycle] = acIdbuff[cycle]; + } + } + else + { + for (cycle = 0u;cycle < AC_MAXCNT_IN_SWITCH;cycle++) + { + acIdbuff[cycle] = 0u; + } + + /** ߼ѯ */ + chDir = ELM_DIR_CONVERT; + acCnt = elm_PrepareAdjacentAC(wBaseAc, chDir, acIdbuff, &cDirectionPointFlag); + + if (UINT8_MAX == acCnt) + { + /** ѯʧܣֵʧ */ + } + else + { + /** жϼǷڱOC */ + funRet = elm_PrepareACIsSelf(acIdbuff[0u],&OCId); + + if (ELM_BELONG_OTHER == funRet) + { + /** Ϊֽ㣬÷ֵ*/ + if (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) + { + *pDir = chDir; + } + else + { + *pDir = ~chDir; + } + ret = acCnt; + for (cycle = 0u;cycle < acCnt;cycle++) + { + pFindAc[cycle] = acIdbuff[cycle]; + } + } + else + { + /** ˼βǷֽᣬֵʧ*/ + } + } + } + + *pDirChangePointFlag = cDirectionPointFlag; + } + return ret; +} + + +/** +* @brief ȡгλλǷ߱ɸ +* @param[in] UINT16 trainID гID +* @param[out] +* @return ELM_TRAIN_IN_WLS_AREA гɸELM_TRAIN_OUT_WLS_AREA гɸ +* @note +*/ +UINT8 elm_PrePareTrainLOCAreaType(UINT16 trainID) +{ + UINT8 ret = ELM_TRAIN_IN_WLS_AREA; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT16 headOC = 0u; + UINT16 tailOC = 0u; + UINT8 headwlsAreaFlag = 0u; + UINT8 tailwlsAreaFlag = 0u; + LOD_STRU headLoc = {0u}; + LOD_STRU tailLoc = {0u}; + + /** ȡȫǰλ */ + funRtn = elm_PrepareMaxSafeHeadLoc(trainID, &headLoc); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x80000000u); + + /** ȡСȫλ */ + funRtn = elm_PrepareMinSafeTailLoc(trainID, &tailLoc); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x40000000u); + + if (0u == errorCode) + { + + /** ȡȫǰOC */ + headOC = GetLinkManageTiocById(headLoc.Lnk); + + /** ȡСȫOC */ + tailOC = GetLinkManageTiocById(tailLoc.Lnk); + + if ((0u == tailOC) || (0u == headOC)) + { + /** ѯʧ*/ + } + else + { + headwlsAreaFlag = GetWLScreenTypeById((UINT8)headOC); + tailwlsAreaFlag = GetWLScreenTypeById((UINT8)tailOC); + + if ((TIOC_WLSCTEEN_UNVALID == headwlsAreaFlag) && (TIOC_WLSCTEEN_UNVALID == tailwlsAreaFlag)) + { + ret = ELM_TRAIN_OUT_WLS_AREA; + } + else + { + /** ɸ */ + } + } + } + return ret; +} + +/** +* @brief ȡгǷתΪUCT +* @param[in] UINT16 trainID гID +* @param[out] +* @return 0x55:г粻תΪUCT磻0xaa:гתΪUCT +* @note +*/ +UINT8 elm_PrePareTrainCanUct(UINT16 trainID) +{ + UINT8 chRtn = 0x55u; + chRtn = GetTrainCanUct(trainID); + return chRtn; +} + + +/** +* @brief ȡг +* @param[in] UINT16 trainID гID +* @param[out] +* @return UINT8 +* @note +*/ +UINT8 elm_PrepareTrainACT(UINT16 trainID) +{ + return GetTrainActive(trainID); +} + +/** +* @brief жǷͬ +* @param[in] LOD_STRU strPointA +* @param[in] LOD_STRU strPointB +* @return CI_ERROR:ȽʧܣFLAG_SET:ͬFLAG_UNSET:ͬ +* @note +*/ +UINT8 elm_PrepareTwoPointsSameDir(const LOD_STRU strPointA, const LOD_STRU strPointB) +{ + return IsPointABSameDir(strPointA, strPointB); +} + +/** +* @brief ȡгСȫǰ +* @param[in] UINT16 wTrainId г +* @return Сȫǰ +* @note +*/ +UINT8 elm_PrepareTrainMinHeadDir(const UINT16 wTrainId) +{ + return GetTrainDir_MinHead(wTrainId); +} + +/** +* @brief ȡгȫ +* @param[in] UINT16 wTrainId г +* @return ȫ +* @note +*/ +UINT8 elm_PrepareTrainMaxTailDir(const UINT16 wTrainId) +{ + return GetTrainDir_MaxTail(wTrainId); +} + +/** +* @brief ȡ䷽仯 +* @param[in] LOD_STRU* pLODAStru +* @param[in] LOD_STRU* pLODBStru +* @return 仯 +* @note +*/ +UINT8 elm_PrepareDirChangNum(const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru) +{ + return GetDirChangeNumBtwPoints(pLODAStru, pLODBStru); +} + +/** +* @brief ݷ仯ת +* @param[in] UINT8 Dir +* @param[in] UINT8 wChangeNum 仯 +* @return תķ +* @note +*/ +UINT8 elm_PrepareDirByChangeNum(UINT8 Dir, UINT8 wChangeNum) +{ + return TransDirByChangeNum(Dir, wChangeNum); +} + +/** +* @brief жǷǰɸͨ(͸Ӷ) +* @param[in]UINT16 wTrainId гID +* @param[in]const LOD_STRU trainPos гȫλ +* @param[in]const LOD_STRU ACpos Ӧ˵λ +* @param[out] UINT32* errorCode ϼ¼ +* @return CI_SUCCESS ɸѡ +* CI_ERROR +* ADJUST_UCT ɸѡҪUCT +* Create: fan 2024 4.1 +*/ +UINT8 elm_PrepareHeadScreenCheck(UINT16 wTrainId, const LOD_STRU trainPos, const LOD_STRU ACpos,UINT32* errorCode) +{ + UINT8 retValue = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT32 tmpTrainLen = 0u; /*ǰг*/ + UINT16 wHeadAxis = 0u; /*IVOCṩǰ*/ + UINT8 wITEResult = 0u; /*IVOCṩǰITEʶ*/ + UINT16 tmpAxisId = 0u; /*id*/ + UINT16 tmpACId = 0u; /*id*/ + UINT32 tmpDis = 0u; /*˵㳤*/ + UINT8 trainDir = 0u; + UINT32 errorLog = 0u; + + if (NULL != errorCode) + { + errorLog = *errorCode; + + /** ȡСȫǰ*/ + tmpACId = elm_PrepareACOfMinSafeHeadLoc(wTrainId); + ASSER_ERROR(0u == tmpACId, errorLog, 0x08000000u); + + /** ȡ·С */ + tmpTrainLen = elm_PrepareTrainLength(LINE_MAX_TRAIN); + ASSER_ERROR((0u == tmpTrainLen) || (0xffffffffu == tmpTrainLen), errorLog, 0x01000000u); + + /** Сȫǰǰ˵ľ*/ + tmpDis = elm_PrepareDistanceBtwPoints(trainPos, ACpos); + ASSER_ERROR(0xffffffffu == tmpDis, errorLog, 0x00800000u); + + /** ȡгз */ + trainDir = elm_PrepareTrainMinHeadDir(wTrainId); + ASSER_ERROR(0u == trainDir, errorLog, 0x04000000u); + + /** ȡǰ*/ + funRet = elm_PrepareACHeadAxisId(tmpACId, trainDir, &tmpAxisId); + ASSER_ERROR(CI_ERROR == funRet, errorLog, 0x00004000u); + + /* ȡIVOCṩǰźʶ */ + wHeadAxis = GetTrainHeadITEScreen(wTrainId, &wITEResult); + ASSER_ERROR(0xffffU == wHeadAxis, errorLog, 0x00008000u); + + if ((0u == errorLog) && + ((tmpDis < tmpTrainLen) || + ((tmpAxisId == wHeadAxis) && (TRAIN_ITE_RESULT_NO == wITEResult)))) + { + /*СС ITEṩһ޳*/ + retValue = CI_SUCCESS; + } + else if (tmpDis < tmpTrainLen) + { + /*ҪǰUCT */ + retValue = ADJUST_UCT; + } + else + { + retValue = CI_ERROR; + } + *errorCode += errorLog; + } + else + { + retValue = CI_ERROR; + } + return retValue; +} + +/** +* @brief жǷɸͨ(͸Ӷ) +* @param[in]UINT16 wTrainId гID +* @param[in]const LOD_STRU trainPos гȫλ +* @param[in]const LOD_STRU ACpos Ӧ˵λ +* @param[out] UINT32* errorCode ϼ¼ +* @return CI_SUCCESS ɸѡ +* CI_ERROR +* ADJUST_UCT ɸѡҪUCT +* Create: fan 2024 4.1 +*/ +UINT8 elm_PrepareTailScreenCheck(UINT16 wTrainId, const LOD_STRU trainPos, const LOD_STRU ACpos, UINT32* errorCode) +{ + UINT8 retValue = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT32 tmpTrainLen = 0u; /*г*/ + UINT16 wTailAxis = 0u; /*IVOCṩļ*/ + UINT8 wITEResult = 0u; /*IVOCṩĺITEʶ*/ + UINT16 tmpAxisId = 0u; /*id*/ + UINT16 tmpACId = 0u; /*id*/ + UINT32 tmpDis = 0u; /*˵㳤*/ + UINT8 trainDir = 0u; + UINT32 errorLog = 0u; + + if (NULL != errorCode) + { + errorLog = *errorCode; + + /** ȡȫ*/ + tmpACId = elm_PrepareACOfMaxSafeTailLoc(wTrainId); + ASSER_ERROR(0u == tmpACId, errorLog, 0x08000000u); + + /** ȡ·С */ + tmpTrainLen = elm_PrepareTrainLength(LINE_MAX_TRAIN); + ASSER_ERROR((0u == tmpTrainLen) || (0xffffffffu == tmpTrainLen), errorLog, 0x01000000u); + + /** ȫ󷽼˵ľ*/ + tmpDis = elm_PrepareDistanceBtwPoints(trainPos, ACpos); + ASSER_ERROR(0xffffffffu == tmpDis, errorLog, 0x00800000u); + + /** ȡгз */ + trainDir = elm_PrepareTrainMaxTailDir(wTrainId); + ASSER_ERROR(0u == trainDir, errorLog, 0x04000000u); + + /** ȡ󷽷*/ + funRet = elm_PrepareACTailAxisId(tmpACId, trainDir, &tmpAxisId); + ASSER_ERROR(CI_ERROR == funRet, errorLog, 0x00004000u); + + /* ȡIVOCṩĺ󷽼źʶ */ + wTailAxis = GetTrainTailITEScreen(wTrainId, &wITEResult); + ASSER_ERROR(0xffffU == wTailAxis, errorLog, 0x00008000u); + + if ((0u == errorLog) && + ((tmpDis < tmpTrainLen) || + ((tmpAxisId == wTailAxis) && (TRAIN_ITE_RESULT_NO == wITEResult)))) + { + /*СС ITEṩһ޳*/ + retValue = CI_SUCCESS; + } + else if (tmpDis < tmpTrainLen) + { + /*ҪǰUCT */ + retValue = ADJUST_UCT; + } + else + { + retValue = CI_ERROR; + } + *errorCode += errorLog; + } + else + { + retValue = CI_ERROR; + } + return retValue; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/ELMDataPrepare.h b/TSCP/src/APP/ciapp/EnvelopeManage/ELMDataPrepare.h new file mode 100644 index 0000000..904f76e --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/ELMDataPrepare.h @@ -0,0 +1,801 @@ +/****************************************************************************** +** ļ: ELMDataPrepare.h +** : гģʱҪⲿ׼ͷļ壬Ϊʵģ +*******************************************************************************/ + +#ifndef ELM_DATA_PREPARE_H_ +#define ELM_DATA_PREPARE_H_ +#include "CommonConfig.h" + +#if (kPLATFORM==kWINDOWS) +#include +#include +#endif + + +#include "EnvelopeDefine.h" +#include "CutoffPointDataManage.h" +#include "AxisAssertManageAPI.h" + +#define ELM_AC_OCC (0x55u) /*ռ*/ +#define ELM_AC_FREE (0xaau) /*ο*/ + +#define LOC_BEFORE (0x01u) /*λǰ*/ +#define LOC_SAME (0x02u) /*λغ*/ +#define LOC_AFTER (0x03u) /*λں*/ + +#define ADJUST_UCT (0x02U) /*UCT*/ + +#define ELM_LOG_FATAL (0u) /** ά־--ά */ +#define ELM_LOG_ERROR (1u) /*ά־--󼶱*/ +#define ELM_LOG_WARING (2u) /*ά־--漶*/ +#define ELM_LOG_DEBUG (3u) /*ά־--Լ*/ +#define ELM_LOG_LEVEL ELM_LOG_DEBUG /*ά־--ǰ־*/ +#define ELM_PRINT_LEN (1280u) /* ά־ӡӡ 1024+256 */ + +#define ELM_BELONG_OWNER (0x55u) /* ڱOCϽ */ +#define ELM_BELONG_OTHER (0xaau) /* ڱOC */ + +#define ELM_COM_STATUS_OK (0x55u) /* ͨ״̬ȷ */ +#define ELM_COM_STATUS_ERROR (0xaau) /* ͨ״̬ */ + +#define ELM_NO_CUT (0x00u) /* δнȡ */ +#define ELM_HEAD_CUT (0x55u) /* ͷнȡ */ +#define ELM_TAIL_CUT (0xaau) /* βнȡ */ + +#define ELM_TRAIN_IN_WLS_AREA (0x55u) /** гλɸ */ +#define ELM_TRAIN_OUT_WLS_AREA (0xaau) /** гλòɸ */ + +/** ־ӡ */ +#define ELM_LOG_LOC(level,fmt,...) elm_PrintDebugInfo(level,fmt" line:%d fun:%s.\n",##__VA_ARGS__,__LINE__,__FUNCTION__); + +#define ELM_LOG(level,fmt,...) elm_PrintDebugInfo(level,fmt,##__VA_ARGS__); + +#if (kPLATFORM==kWINDOWS) +#define ELM_LOG_TIME(level,fmt,...) { \ + SYSTEMTIME sys; \ + GetLocalTime(&sys); \ + elm_PrintDebugInfo(level,fmt" time:%02d:%02d:%02d.%03d.\n",##__VA_ARGS__,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds); \ +} +#else +#define ELM_LOG_TIME(level,fmt,...) elm_PrintDebugInfo(level,fmt" time:%08d.\n",##__VA_ARGS__,TimeStamp); +#endif + +#if (kPLATFORM!=kWINDOWS) +extern unsigned long TimeStamp; +#endif + +extern UINT16 OutEnvelopeStrLen; /*Ҫӡİݳ*/ +extern UINT8 OutEnvelopeStr[MAX_ENVELOPE_LOG_NUM]; /*Ҫӡİ*/ + +/** elmģʹõİȫλýӿ*/ +typedef struct +{ + LOD_STRU startPos; /*ʼλ*/ + LOD_STRU endPos; /*նλ*/ +}ELM_TrainSafeLocStruct; + +/** elmģʹõļλýӿ*/ +typedef struct +{ + UINT8 dir; /** ʼָն˵ķ*/ + LOD_STRU startPos; /*ʼλ*/ + LOD_STRU endPos; /*նλ*/ +}ELM_AxisLocStruct; + + +/** + * @brief ӡϢ + * @param[in] const EnvelopeStruct* PEnvelpe ָ + * @return + * @note ־ӡ⺯־ӡ + */ +void elm_PrintfEnvelope(const EnvelopeStruct* PEnvelpe); + +/** + * @brief ӡDebugϢ + * @param[in] UINT8 level ־ + * @param[in] const char *fmt ӡϢ + * @return + * @note ͨⲿӿڣʵֱģĴӡ + */ +void elm_PrintDebugInfo(UINT8 level, const char *fmt, ...); + +/** + * @brief ͨгID׼гİȫϢ + * @param[in] UINT16 trainID гID + * @param[out] INOUT TrainSafeLocStruct* pTrainSafeLoc гȫ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note + */ +UINT8 elm_PrepareTrainSafeLoc(UINT16 trainID,INOUT ELM_TrainSafeLocStruct* pTrainSafeLoc); + +/** + * @brief ȡOCΧйڼε + * @param[out] OUT UINT16** pACIdBuff ID + * @return 0 ѯ + 1~AXIS_SECTION_SUM_MAX ѯȷ + * @note OCּ֧IDӳϵֱӻȡ + */ +UINT16 elm_PrepareACBuffIndexs(OUT const UINT16** pACIdBuff); + + + +/** + * @brief ͨεȡID + * @param[in] UINT16 ACBuffIndex λ + * @return ID + * @note + */ +UINT16 elm_PrepareACID(UINT16 ACBuffIndex); + + +/** + * @brief ͨIDȡε + * @param[in] UINT16 ACId ID + * @return λ + * @note + */ +UINT16 elm_PrepareACIndex(UINT16 ACId); + + +/** + * @brief ͨIDȡ״̬ + * @param[in] UINT16 ACID ID + * @return ELM_AC_OCC ռ + ELM_AC_FREE + * @note + */ +UINT8 elm_PrepareACStatus(UINT16 ACID); + +/** +* @brief ͨIDѯڲͨʱռ +* @param[in] UINT16 ACID ID +* @return SECTION_OCCUPY_YES ռ + SECTION_OCCUPY_NO ο +*/ +UINT8 elm_PrepareACofSwichPhyStatus(UINT16 ACID); + +/** + * @brief ͨIDҼλ + * @param[in] UINT16 ACID ID + * @param[in] UINT8 chDir ָյķ + * @param[out] ELM_AxisLocStruct* pACLoc λ + * @return CI_SUCCESS ѯȷسɹ + * CI_ERROR ѯ󣬷ʧ + * @note + */ +UINT8 elm_PrepareACLoc(UINT16 ACID, UINT8 chDir, ELM_AxisLocStruct* pACLoc); + + +/** + * @brief ͨIDͲѯѯlink + * @param[in] UINT16 ACID ID + * @param[out] UINT16 linkID[] link + * @return 0 Ƿ + 0 link + * @note linkʱղѯ˳򷵻 + */ +UINT8 elm_PrepareACrelLink(UINT16 ACID,UINT8 dir, INOUT UINT16 linkID[]); + + +/** + * @brief ѯ֮link + * @param[in] LOD_STRU pointA λõA + * @param[in] LOD_STRU pointB λõB + * @param[out] UINT16 linkID[] ֮link + * @return ֮link + * @note pointAλõķΪָpointBķ + */ +UINT16 elm_PrepareLinkBtwPoints(LOD_STRU pointA,LOD_STRU pointB,INOUT UINT16 linkID[]); + + +/** + * @brief ѯ֮ļ + * @param[in] LOD_STRU pointA λõA + * @param[in] LOD_STRU pointB λõB + * @param[out] UINT16 ACID[] ֮ļ + * @return ֮ļ + * @note pointAλõķΪָpointBķ + */ +UINT8 elm_PrepareACBtwPoints(LOD_STRU pointA,LOD_STRU pointB,INOUT UINT16 ACID[SECTION_IN_ENVELOPE_SUM_MAX]); + + +/** + * @brief ȡǰOCеͨųгID + * @param[out] UINT16 trainID[TRAIN_SUM_MAX_IN_OC] гID + * @return OCΧͨгID + * @note + */ +UINT8 elm_PrepareCommTrainID(INOUT UINT16 trainID[TRAIN_SUM_MAX_IN_OC]); + + +/** + * @brief ȡгͨ״̬ + * @param[in] UINT16 trainid + * @param[out] + * @return ELM_COM_STATUS_OK ͨ + * ELM_COM_STATUS_ERROR ͨ쳣 + * @note + */ +UINT8 elm_PrepareTrainCommStatus(IN UINT16 trainID); + +/** + * @brief ȡͨгλǷЧ + * @param[in] UINT16 trainid + * @param[out] + * @return CI_SUCCESS λЧ + * CI_ERROR λЧ + * @note + */ +UINT8 elm_PrepareTrainPosValid(IN UINT16 trainID); + + +/** + * @brief ȡλùϵ + * @param[in] LOD_STRU pointA λA + * @param[in] UINT8 dirAtoB λAָλB + * @param[in] LOD_STRU pointB λB + * @return LOC_BEFORE λBλAǰ + LOC_SAME λAλBغ + LOC_AFTER λAλB + Ƿ + * @note + */ +UINT8 elm_PrepareRelationBtwPoint(LOD_STRU pointA,UINT8 dirAtoB, LOD_STRU pointB); + + +/** + * @brief ѯǰ/󷽼 + * @param[in] UINT16 ACID ׼ID + * @param[in] UINT8 dir ѯ + * @param[out] UINT16 arACID[AC_MAXCNT_IN_SWITCH] ڼID + * param[out] UINT8* DirectionPointFlag Ƿз仯 DIRECTIONPOINT_FLAG_VALID + * @return UINT8_MAX ѯʧ + 0~AC_MAXCNT_IN_SWITCH ѯɹ + */ +UINT8 elm_PrepareAdjacentAC(UINT16 ACID, UINT8 dir, INOUT UINT16 arACID[AC_MAXCNT_IN_SWITCH], UINT8* DirectionPointFlag); + + +/** + * @brief ϲUINT16 + * @param[in] UINT16 dstBuffSize ĿĻС + * @param[in] UINT16 startIndex ĿĻʼַ + * @param[in] const UINT16 srcArray[] Դַ + * @param[in] UINT16 srcBuffSize ԴС + * @param[in] UINT16 mergeSize ϲС + * @param[out] UINT16 dstArray[] ĿĻ + * @return Ŀĺϲַ + * @note ϲʧܣĿĻС + */ +UINT16 elm_PrepareMergeUINT16Array(INOUT UINT16 dstArray[], UINT16 dstBuffSize, UINT16 startIndex, IN const UINT16 srcArray[], UINT16 srcBuffSize,UINT16 mergeSize); + + +/** + * @brief Ƚǰϵ + * @param[in] const EnvelopeStruct pEnvelopeA A + * @param[in] LOD_STRU* strPointA ׼ + * @param[in] const EnvelopeStruct* pEnvelopeB B + * @return 0x01 AڰBǰ + 0x02 BڰAǰ + 0x03 AB¹ϵ(() )( ()) ͣ () + 0x04 BA¹ϵ(() )( ()) ͣ () + 0x00 ޷Ƚλùϵ + * @note + */ +UINT8 elm_PrepareRelationBtwEnvelope(IN const EnvelopeStruct* pEnvelopeA, const LOD_STRU strPointBase, IN const EnvelopeStruct* pEnvelopeB); + + +/** + * @brief жֵǷUINT16ֵ + * @param[in] UINT16 targetValue ѯֵ + * @param[in] const UINT16 arValue[] ͻΧ + * @param[in] UINT16 buffsizeͻΧС + * @return CI_SUCCESS ֵָڳͻΧ + * CI_ERROR ֵָڳͻΧ + * @note + */ +UINT8 elm_PrepareInUINT16Array(UINT16 targetValue,const UINT16 arValue[],UINT16 buffsize); + + +/** + * @brief ͨȡ֮ľ + * @param[in] LOD_STRU pointA λA + * @param[in] LOD_STRU pointB λB + * @return ֮ľ루cm + * @note pointAΪ pointBΪյ + */ + UINT32 elm_PrepareDistanceBtwPoints(LOD_STRU pointA, LOD_STRU pointB); + + /** + * @brief ͨгIDȡг + * @param[in] + * @param[out] + * @return гcm + * @note 1ѯɹг򷵻·̳ + */ + UINT32 elm_PrepareTrainLength(UINT16 trainid); + + + /** + * @brief ȡгз + * @param[in] UINT16 trainid гID + * @param[out] + * @return ELM_DIR_SAME ɹ + * ELM_DIR_CONVERT ʧ + Ƿ + * @note + */ + UINT8 elm_PrepareTrainDir(UINT16 trainid); + + + /** + * @brief ѯгСȫǰǰ + * @param[in] UINT16 trainid гID + * @param[out] UINT16 acID[AC_MAXCNT_IN_SWITCH] + * @return ҳɹļ + * @note + */ + UINT8 elm_PrepareNextAcMinSafeHeadLoc(UINT16 trainid, OUT UINT16 acID[AC_MAXCNT_IN_SWITCH]); + + /** + * @brief ȡгȫǰλ + * @param[in] UINT16 trainid гID + * @param[out] LOD_STRU *pLoc гλ + * @return CI_SUCCESS ѯɹ + * CI_ERROR ѯʧ + * @note + */ + UINT8 elm_PrepareMaxSafeHeadLoc(UINT16 trainid, OUT LOD_STRU *pLoc); + + /** + * @brief ȡгСȫǰλ + * @param[in] UINT16 trainid гID + * @param[out] LOD_STRU *pLoc гλ + * @return CI_SUCCESS ѯɹ + * CI_ERROR ѯʧ + * @note + */ + UINT8 elm_PrepareMinSafeHeadLoc(UINT16 trainid, OUT LOD_STRU *pLoc); + + /** + * @brief ȡгȫǰ + * @param[in] UINT16 trainid гID + * @return ID + * @note + */ + UINT16 elm_PrepareACOfMaxSafeHeadLoc(UINT16 trainid); + + /** + * @brief ȡгСȫǰ + * @param[in] UINT16 trainid гID + * @return ID + * @note + */ + UINT16 elm_PrepareACOfMinSafeHeadLoc(UINT16 trainid); + + + /** + * @brief ѯгȫ󷽼 + * @param[in] UINT16 trainid гID + * @param[out] UINT16 acID[AC_MAXCNT_IN_SWITCH] + * @return ҳɹļ + * @note + */ + UINT8 elm_PrepareNextAcMaxSafeTailLoc(UINT16 trainid, OUT UINT16 acID[AC_MAXCNT_IN_SWITCH]); + + + /** + * @brief ȡгȫλ + * @param[in] UINT16 trainid гID + * @param[out] LOD_STRU *pLoc гλ + * @return CI_SUCCESS ѯɹ + * CI_ERROR ѯʧ + * @note + */ + UINT8 elm_PrepareMaxSafeTailLoc(UINT16 trainid, OUT LOD_STRU *pLoc); + + /** + * @brief ȡгСȫλ + * @param[in] UINT16 trainid гID + * @param[out] LOD_STRU *pLoc гλ + * @return CI_SUCCESS ѯɹ + * CI_ERROR ѯʧ + * @note + */ + UINT8 elm_PrepareMinSafeTailLoc(UINT16 trainid, OUT LOD_STRU *pLoc); + + /** + * @brief ȡгȫ + * @param[in] UINT16 trainid гID + * @return ID + * @note + */ + UINT16 elm_PrepareACOfMaxSafeTailLoc(UINT16 trainid); + + /** + * @brief ȡгСȫ + * @param[in] UINT16 trainid гID + * @return ID + * @note + */ + UINT16 elm_PrepareACOfMinSafeTailLoc(UINT16 trainid); + + + /** + * @brief ȡг״̬ + * @param[in] UINT16 trainid гID + * @param[out] + * @return TRAIN_SLEEP_YES ״̬ + TRAIN_SLEEP_NO δ״̬ + Ƿ + * @note + */ + UINT8 elm_PrepareTrainSleepStatus(UINT16 trainid); + + /** + * @brief ȡǷڱOC + * @param[in] UINT16 acID ID + * @param[out] UINT8 *pOCId OCid + * @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ + * @note + */ + UINT8 elm_PrepareACIsSelf(UINT16 acID,UINT8 *pOCId); + + +/** + * @brief ȡǷȫڱOC + * @param[in] const EnvelopeStruct* Ptemp + * @param[out] + * @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ + * @note + */ + UINT8 elm_PrepareEnvelopeIsSelf(IN const EnvelopeStruct* ptemp); + + +/** + * @brief ȡ[A,B]ΧȫڱOCķΧ[A',B'] + * @param[in] + * @param[out] LOD_STRU *pointA ȡֽ + * @param[out] LOD_STRU *pointB ȡֽ + * @param[out] UINT8* cutFlag ȡ־ + * @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ + * @note + */ + UINT8 elm_PrepareCutZoneInSelf(INOUT LOD_STRU *pointA,INOUT LOD_STRU *pointB, INOUT UINT8* cutFlag); + + + /** + * @brief ȡOCͨŵOCid + * @param[in] UINT8 **pOCIDbuff OCid + * @return OCͨ + * @note + */ + UINT8 elm_PrepareComOCID(IN const UINT8 **pOCIDbuff); + + + /** + * @brief ȡOCͨ״̬ + * @param[in] UINT8 OCID + * @return ELM_COM_STATUS_ERROR ͨ״̬ + ELM_COM_STATUS_OK ͨ״̬ȷ + * @note + */ + UINT8 elm_PrepareOCCommStatus(UINT8 OCID); + + + /** + * @brief ȡλõOC + * @param[in] const LOD_STRU *pointA Aλ + * @param[out] UINT8 *pOCId OC + * @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ + * @note + */ + UINT8 elm_PreparePointIsSelf(IN const LOD_STRU *pointA,UINT8 *pOCId); + + /** + * @brief ȡOC͵İϢ + * @param[in] UINT8 OCid OCid + * @param[out] CfpEnvelopeStruct *pInfEnvelope ӿڰϢ + * @return + * @note + */ + UINT8 elm_PrepareNextOcInfEnvelope(UINT8 OCid,CfpEnvelopeStruct *pInfEnvelope); + + /** + * @brief ȡӦϢַ + * @param[in] + * @param[out] + * @return + * @note + */ +const AxisAsserStruct* elm_PrepareAxisAssertInfoPtr(UINT16 ACID); + +/** + * @brief ȡȫλõĵλǷ񲻷˹ϵռñ־ + * @param[in] гID + * @param[out] + * @return CI_SUCCESS ˹ϵռ + * CI_ERROR ˹ϵռ + * @note + */ +UINT8 elm_PrepareTrainSafeHeadFlag(UINT16 trainId); + + + +/** + * @brief ȡID + * @param[in] UINT16 ACID Id + * @param[out] + * @return 0 ѯʧ + >0 ѯɹ + * @note + */ +UINT16 elm_PrepareACRelPhyId(UINT16 ACID); + + +/** + * @brief ȡ״̬ + * @param[in] ID + * @param[out] + * @return AAM_API_AC_ARB ARB + AAM_API_AC_REDUNARB ARB + AAM_API_AC_UT UT + AAM_API_AC_REDUNUT UT + * @note + */ +UINT8 elm_PrepareACAssertStatus(UINT16 ACID); + + +/** + * @brief ȡ״̬ + * @param[in] UINT16 ACID ID + * @param[out] + * @return AAM_UT_PASS ͨ + AAM_CT_PASS óͨ + * @note + */ +UINT8 elm_PrepareACPassTrainFlag(UINT16 ACID); + + + /** + * @brief жϼǷΪ + * @param[in] UINT16 ACID ID + * @param[out] + * @return CI_SUCCESS Ϊ + * CI_ERROR Ϊ + * @note + */ +UINT8 elm_PrepareACIsSwitchZone(UINT16 ACID); + +/** + * @brief жϼǷ˹ϵ + * @param[in] UINT16 ACID ID + * @param[out] + * @return CI_SUCCESS ˹ϵ + * CI_ERROR ˹ϵ + * @note ע᲻ڲ򷵻ط˹ϵ + */ +UINT8 elm_PrepareCheckACofSwichPos(UINT16 ACID); + +/** + * @brief ĺóͨ־λ + * @param[in] UINT16 ACID ID + * @param[out] + * @return + * @note + */ +void elm_PrepareClearSwPassTrainFlag(UINT16 ACID); + + +/** + * @brief ȡεռ״̬ + * @param[in] UINT16 ACID ID + * @param[out] + * @return SECTION_OCCUPY_YES ռ + SECTION_OCCUPY_NO ο + * @note + */ +UINT8 elm_PrepareACRelPhyStatus(UINT16 ACID); + + +/** + * @brief ȡɳ崻崻ʱ + * @param[in] + * @param[out] + * @return ʱ + * @note + */ +UINT8 elm_PrepareCTFlyingRedunTime(void); + +/** +* @brief ӿڣȡǷںóͨ +* @param[in] UINT16 acID +* @param[out] +* @return AAM_CT_PASS κóͨ +AAM_UT_PASS λͨ +*/ +UINT8 elm_PreparACRelPhyPasTrainFlag(UINT16 acID); + +/** +* @brief ״̬ѯ֮ļ +* @param[in] LOD_STRU pointA λõA +* @param[in] LOD_STRU pointB λõB +* @param[out] UINT16 ACID[] ֮ļ +* @return ֮ļ +* @note pointAλõķΪָpointBķ +* creat by lxc 2022/6/17 +*/ +UINT8 elm_PrepACBtwPointsBySwitchSta(LOD_STRU pointA, LOD_STRU pointB, INOUT UINT16 ACID[MAX_AC_IN_TRAIN]); + +/** +* @brief жUINT16ǷUINT16ֵ +* @param[in] const UINT16 szSrcArray[] Դ +* @param[in] const UINT16 wSrcArrayLen +* @param[in] const UINT16 szDstArray[] жϵ +* @param[in] const UINT16 wDstArrayLen +* @return CI_SUCCESS ֵָڳͻΧ +* CI_ERROR ֵָڳͻΧ +* @note +*/ +UINT8 elm_PrepareUINT16ArrayInArray(const UINT16 szSrcArray[], const UINT16 wSrcArrayLen, const UINT16 szDstArray[], const UINT16 wDstArrayLen); + + +/** +* @brief ȡUCTܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ +* CI_ERROR ܹر +* @note +*/ +UINT8 elm_PrepareUCTSwitch(void); + +/** + * @brief ȡֽ + * @param[out] UINT16 szAcId[CUTOFF_POINT_SUM_MAX] + * @return 0~CUTOFF_POINT_SUM_MAX-1 ֽ + CUTOFF_POINT_SUM_MAX ʧ + * @note + */ +UINT8 elm_PrepareCfpAc(UINT16 szAcId[CUTOFF_POINT_SUM_MAX]); + + +/** +* @brief ȡڿڼ,ڿʻ򱾿ķ +* @param[in] const UINT16 wBaseAc ׼ +* @param[out] UINT8 * pDir 뵽ķ +* @param[out] pFindAc[AC_MAXCNT_IN_SWITCH] ڼ +* pDirChangePointFlag 仯־ +* @return UINT8_MAX ѯʧ + 0~AC_MAXCNT_IN_SWITCH ѯɹ +* @note +*/ +UINT8 elm_PrepareCfpOtherTiocAc(const UINT16 wBaseAc, UINT8* pDir, UINT16 pFindAc[AC_MAXCNT_IN_SWITCH], UINT8* pDirChangePointFlag); + + + /** + * @brief ȡгλλǷ߱ɸ + * @param[in] UINT16 trainID гID + * @param[out] + * @return ELM_TRAIN_IN_WLS_AREA гɸELM_TRAIN_OUT_WLS_AREA гɸ + * @note + */ + UINT8 elm_PrePareTrainLOCAreaType(UINT16 trainID); + + /** + * @brief ȡгǷתΪUCT + * @param[in] UINT16 trainID гID + * @param[out] + * @return 0x55:г粻תΪUCT磻0xaa:гתΪUCT + * @note + */ + UINT8 elm_PrePareTrainCanUct(UINT16 trainID); + + /** + * @brief ȡг + * @param[in] UINT16 trainID гID + * @param[out] + * @return UINT8 + * @note + */ + UINT8 elm_PrepareTrainACT(UINT16 trainID); + + /** + * @brief жǷͬ + * @param[in] LOD_STRU strPointA + * @param[in] LOD_STRU strPointB + * @return CI_ERROR:ȽʧܣFLAG_SET:ͬFLAG_UNSET:ͬ + * @note + */ + UINT8 elm_PrepareTwoPointsSameDir(const LOD_STRU strPointA, const LOD_STRU strPointB); + + /** + * @brief ȡгСȫǰ + * @param[in] UINT16 wTrainId г + * @return Сȫǰ + * @note + */ + UINT8 elm_PrepareTrainMinHeadDir(const UINT16 wTrainId); + + /** + * @brief ȡгȫ + * @param[in] UINT16 wTrainId г + * @return ȫ + * @note + */ + UINT8 elm_PrepareTrainMaxTailDir(const UINT16 wTrainId); + + /** + * @brief ȡ䷽仯 + * @param[in] LOD_STRU* pLODAStru + * @param[in] LOD_STRU* pLODBStru + * @return 仯 + * @note + */ + UINT8 elm_PrepareDirChangNum(const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru); + + /** + * @brief ݷ仯ת + * @param[in] UINT8 Dir + * @param[in] UINT8 wChangeNum 仯 + * @return תķ + * @note + */ + UINT8 elm_PrepareDirByChangeNum(UINT8 Dir, UINT8 wChangeNum); + + /** + * @brief ͨIDǰӦ + * @param[in] UINT16 ACID ID + * @param[in] UINT8 chDir ָյķ + * @param[out] UINT16* AxisId ǰѯId + * @return CI_SUCCESS ѯȷسɹ + * CI_ERROR ѯ󣬷ʧ + * Create: fan 2024 3.2 + */ + UINT8 elm_PrepareACHeadAxisId(UINT16 ACID, UINT8 chDir, UINT16* AxisId); + + /** + * @brief ͨIDҺ󷽶Ӧ + * @param[in] UINT16 ACID ID + * @param[in] UINT8 chDir ָյķ + * @param[out] UINT16* AxisId 󷽲ѯId + * @return CI_SUCCESS ѯȷسɹ + * CI_ERROR ѯ󣬷ʧ + * Create: fan 2024 3.2 + */ + UINT8 elm_PrepareACTailAxisId(UINT16 ACID, UINT8 chDir, UINT16* AxisId); + + /** + * @brief жǷǰɸͨ(͸Ӷ) + * @param[in]UINT16 wTrainId гID + * @param[in]const LOD_STRU trainPos гȫλ + * @param[in]const LOD_STRU ACpos Ӧ˵λ + * @param[out] UINT32* errorCode ϼ¼ + * @return CI_SUCCESS ǰɸ CI_ERROR + * ADJUST_UCT ɸѡҪUCT + * Create: fan 2024 4.1 + */ + UINT8 elm_PrepareHeadScreenCheck(UINT16 wTrainId, const LOD_STRU trainPos, const LOD_STRU ACpos, UINT32* errorCode); + + /** + * @brief жǷɸͨ(͸Ӷ) + * @param[in]UINT16 wTrainId гID + * @param[in]const LOD_STRU trainPos гȫλ + * @param[in]const LOD_STRU ACpos Ӧ˵λ + * @param[out] UINT32* errorCode ϼ¼ + * @return CI_SUCCESS ɸѡ CI_ERROR + * ADJUST_UCT ɸѡҪUCT + * Create: fan 2024 4.1 + */ + UINT8 elm_PrepareTailScreenCheck(UINT16 wTrainId, const LOD_STRU trainPos, const LOD_STRU ACpos, UINT32* errorCode); +#endif /*ELM_DATA_PREPARE_H_*/ \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeDefine.h b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeDefine.h new file mode 100644 index 0000000..92b0706 --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeDefine.h @@ -0,0 +1,155 @@ +/****************************************************************************** +** ļ: EnvelopeDefine.h +** : гģضͷļгģelm + +*******************************************************************************/ + +#ifndef ENVELOPE_DEFINE_H_ +#define ENVELOPE_DEFINE_H_ + +#include "../Section/SectionDefine.h" +#include "CommonTypes.h" +#include "dquVobcCommonStru.h" +#include "dsuEmapDefine.h" +#include "CiSystemDefine.h" +#include "CommonMemory.h" +#include "TrainDefine.h" + +#ifdef WIN32 +#define ELM_DEBUG 1 +#endif + +/** ===========================궨================================== */ +#define LINE_MAX_TRAIN (255u) /* ·г,ҲΪسID() */ +#define TRAIN_SUM_MAX_IN_OC (40u) /*OCг()*/ +#define RESERVE_SUM_MAX (10u) /*Ԥİ*/ +#define ENVELOPE_SUM_MAX (AXIS_SECTION_SUM_MAX + TRAIN_SUM_MAX_IN_OC + RESERVE_SUM_MAX) /*г()*/ + +#define TRAIN_IN_ENVELOPE_SUM_MAX (15u) /*гаг()*/ +#define SECTION_IN_ENVELOPE_SUM_MAX (10u) /*га()*/ +#define SECTION_REL_ENVELOPE_SUM_MAX (15u) /*ιİ()*/ +#define TRAIN_REL_ENVELOPE_SUM_MAX (15u) /*гİ()*/ +#define MAX_ENVELOPE_LOG_NUM (10000U) /*־ӡС*/ + +#define ENVELOPE_UNEXIT (0x00u) /*ַռδʹã粻*/ +#define ENVELOPE_EXIT (0xaau) /*ַռʹã*/ + +#define TYPE_CT_ENVELOPE (1u) /*ͨų*/ +#define TYPE_UCT_ENVELOPE (2u) /*ʧͨų*/ +#define TYPE_UKT_ENVELOPE (3u) /*س*/ + +#define ENVELOPE_UNVAILD_INDEX (0u) /*ЧİID*/ + +#define OP_ADD (0x55u) /*ʽΪ*/ +#define OP_DEL (0xaau) /*ʽΪɾ*/ + +#define ELM_WORK_OK (0x55u) /*ģ*/ +#define ELM_WORK_ERROR (0xaau) /*ģ鲻*/ + +#define ELM_NO_SHUTDOWN (0x55u) /*ģ鲻Ҫ崻*/ +#define ELM_NEED_SHUTDOWN (0xaau) /*ģҪ崻*/ + + +#define ELM_BODY (0x00u) /**/ +#define ELM_HEAD (0x55u) /*ͷ*/ +#define ELM_TAIL (0xaau) /*β*/ +#define ELM_HEAD_AND_TAIL (0xccu) /** ͷβ */ + +#define ELM_TRUE (1u == 1u) /*ֵ*/ +#define ELM_FALSE (0u == 1u) /*ֵ*/ + +#define ELM_DIR_SAME EMAP_SAME_DIR /* 緽ͬ */ +#define ELM_DIR_CONVERT EMAP_CONVER_DIR /* 緽ͬ */ + +#define AC_MAXCNT_IN_SWITCH (5u) + +#define SHUT_DOWN_ALARM_TIME (5u) /*ɳ崻 ڳ */ + + +/** ===========================꺯================================== */ + +/* --ᵼºڲΨһڲж */ +#define ASSERT_RET_NO_VALUE(condition,errorCode) if((condition)) { \ + ELM_LOG_LOC(0u,"errno:0x%08x info:Input error.",errorCode);\ + return; \ + } \ + else { \ + /** */ \ + } +/* --ᵼºڲΨһڲж */ +#define ASSERT_RET_VALUE(condition,ret,errorCode) if((condition)) { \ + ELM_LOG_LOC(0u,"errno:0x%08x info:Input error.",errorCode);\ + return (ret);\ + }\ + else { \ + /** */ \ + } + + +/*ѭֹ,Ϊʱѭ*/ +#define ASSERT_BREAK(condition,err,errNo) if((condition)) { \ + (err) = (err) + (errNo); \ + break; \ + } \ + else { \ + /** */ \ + } + +/*ֵãΪʱֵΪCI_SUCCESSΪCI_ERROR*/ +#define ASSERT_SETRET(condition,ret,retOK,retError) if((condition)) { \ + (ret) = (retOK); \ + } \ + else { \ + (ret) = (retError); \ + } + +/**/ +#define ASSER_ERROR(condition,err,errNo) if((condition)) { \ + (err) = (err) + (errNo); \ + } \ + else { \ + /** */ \ + } + +/* ӡ */ +#define ASSER_DEBUG(condition,fun) if((condition)) { \ + fun; \ + } \ + else { \ + /** */ \ + } + + +/** ===========================ṹ嶨================================== */ +/** гṹ رҪע⣺˽仯һҪע޸ĸ溯*/ +typedef struct{ + UINT8 exitFlag; /*ڱʶ*/ + UINT8 envelopeType; /**/ + UINT16 id; /*ʶ*/ + UINT16 headTrainID; /*ǰгID*/ + UINT16 tailTrainID; /*гID*/ + LOD_STRU startPos; /*ʼλ*/ + LOD_STRU endPos; /*նλ*/ + UINT8 trianCnt; /*аг*/ + UINT16 trainID[TRAIN_IN_ENVELOPE_SUM_MAX]; /*агID*/ + UINT8 ACTPort[TRAIN_IN_ENVELOPE_SUM_MAX]; /*г */ + UINT8 ACCnt; /*AC*/ + UINT16 ACID[SECTION_IN_ENVELOPE_SUM_MAX]; /*AC ID*/ + UINT32 dwUCTToUKTStartCycNum; /*UCTתUKTʼڣȫͨųȷ*/ +} EnvelopeStruct; + +/** ӿʹõİ*/ +typedef struct{ + UINT8 envelopeType; /**/ + UINT16 id; /*гID*/ + UINT8 suspicHead; /*ǰ˿*/ + UINT8 suspicTail; /*˿*/ + LOD_STRU startPos; /*ʼλ*/ + LOD_STRU endPos; /*նλ*/ + UINT8 trianCnt; /*аг*/ + UINT16 trainID[TRAIN_IN_ENVELOPE_SUM_MAX]; /*агID*/ +} InfEnvelopeStruct; + + +#endif /*ENVELOPE_DEFINE_H_*/ + diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeLogicProcess.c b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeLogicProcess.c new file mode 100644 index 0000000..a164862 --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeLogicProcess.c @@ -0,0 +1,3233 @@ +/****************************************************************************** +** ļ: EnvelopeLogicProcess.c +** : ʵְ߼ҪʵֹúĶ壩 +*******************************************************************************/ + +#include "ELMDataPrepare.h" +#include "EnvelopeLogicProcess.h" +#include "AxisAssertManageAPI.h" +#include "dsuEmapDefine.h" +#include "DeviceDataManage.h" +#include "WholeLineScreenAPI.h" +#include "WLScreenDataManage.h" +#include "Convert.h" + + + +/*================================̬==============================*/ +static UINT8 elm_UKTAdjacentSwProtect(void); /** UKTڲ */ +static UINT8 elm_UTLosingProtect(void); /* UT*/ +static UINT8 elm_ACRelEnvelopeCheck(void); /** ӳϷУ */ +static void elm_FlyingProtect(void); /* UCT/CTɳ*/ + +static UINT16 elm_GetEnvelopTailACIDs(IN const EnvelopeStruct* pEnvelop,OUT UINT16 acID[AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH]); /* ȡβ󷽼 */ +static UINT16 elm_GetEnvelopHeadACIDs(IN const EnvelopeStruct* pEnvelop,OUT UINT16 acID[AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH]); /* ȡβǰ */ + + +/** + * @brief ̬UKTڲ + * @param[in] + * @param[out] + * @return CI_ERROR 󣬷ʧ + CI_SUCCESS ȷسɹ + * @note + */ +static UINT8 elm_UKTAdjacentSwProtect(void) +{ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT16 cycleAc = 0u; + UINT8 OCId = 0u; + UINT8 isSwitchZoneFlag = CI_SUCCESS; + UINT8 passTrainFlag = AAM_CT_PASS; + UINT16 acCnt = 0u; /*OCΧеļ*/ + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + UINT32 errorCode = 0u; + UINT8 acRelPhyOCC = SECTION_OCCUPY_YES; + UINT8 nearTrainType = AAM_BAD_NEAR; + UINT8 acSameCnt = 0u; + UINT8 acConvertCnt = 0u; + UINT16 acSameID[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 acConvertID[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + + /** ȡOCΧеļ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + ASSER_ERROR(NULL == pACIdbuff,errorCode,0x80000000u); + + if (NULL == pACIdbuff) + { + /** ܷ֧*/ + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:AC search error.",errorCode); + } + else + { + for (cycleAc = 0u; cycleAc < acCnt;cycleAc++) + { + /** жϼǷڱOC */ + funRet = elm_PrepareACIsSelf(pACIdbuff[cycleAc],&OCId); + + if (ELM_BELONG_OTHER == funRet) + { + /** ڱOC */ + } + else + { + /** ǷΪ */ + isSwitchZoneFlag = elm_PrepareACIsSwitchZone(pACIdbuff[cycleAc]); + + /** ȡóͨ־λ */ + passTrainFlag = elm_PreparACRelPhyPasTrainFlag(pACIdbuff[cycleAc]); + + /** ѯǷռ */ + acRelPhyOCC = elm_PrepareACRelPhyStatus(pACIdbuff[cycleAc]); + + /** ڲΪóͨ */ + if ((CI_SUCCESS == isSwitchZoneFlag) && (AAM_CT_PASS == passTrainFlag) && (SECTION_OCCUPY_YES == acRelPhyOCC)) + { + /** ѯǰ*/ + acSameCnt = elm_PrepareAdjacentAC(pACIdbuff[cycleAc], EMAP_SAME_DIR, acSameID, &cDirectionPointFlag); + + /** ѯ󷽼 */ + acConvertCnt = elm_PrepareAdjacentAC(pACIdbuff[cycleAc], EMAP_CONVER_DIR, acConvertID, &cDirectionPointFlag); + + /** жǷѯɹ */ + ASSERT_SETRET((UINT8_MAX == acSameCnt) || (UINT8_MAX == acConvertCnt),errorCode,0x40000000u,0U); + + if (0u != errorCode) + { + nearTrainType = AAM_BAD_NEAR; + errorCode = 0u; + } + else + { + /** ѯǰӽ*/ + nearTrainType = aam_SearchNearbyTrainType(pACIdbuff[cycleAc], EMAP_SAME_DIR, acSameCnt, acSameID); + } + + if (AAM_BAD_NEAR == nearTrainType) + { + elm_PrepareClearSwPassTrainFlag(pACIdbuff[cycleAc]); + ELM_LOG(ELM_LOG_FATAL,"info:Switch Zone AC%d Clear CT pass flag by PreAC UT.\n",pACIdbuff[cycleAc]); + } + else + { + /** ѯǰӽ*/ + nearTrainType = aam_SearchNearbyTrainType(pACIdbuff[cycleAc],EMAP_CONVER_DIR,acConvertCnt,acConvertID); + + if (AAM_BAD_NEAR == nearTrainType) + { + elm_PrepareClearSwPassTrainFlag(pACIdbuff[cycleAc]); + ELM_LOG(ELM_LOG_FATAL,"info:Switch Zone AC%d Clear CT pass flag by backAC UT.\n",pACIdbuff[cycleAc]); + } + else + { + /** ޻ӽ */ + } + } + } + else + { + /** 账 */ + } + } + } + + /** úֵ*/ + ASSERT_SETRET(cycleAc == acCnt,ret,CI_SUCCESS,CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:AC%d search Adjacent AC info error.",errorCode,pACIdbuff[cycleAc])); + } + + /** */ + return ret; +} + +/** + * @brief ̬UTɳ߶ + * @param[in] + * @param[out] + * @return CI_ERROR 󣬷ʧ + CI_SUCCESS ȷسɹ + * @note + */ +static UINT8 elm_UTLosingProtect(void) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRet = CI_ERROR; + UINT8 checkFlag = CI_ERROR; + UINT16 cycleAc = 0u; + UINT8 tmpACStatus = ELM_AC_FREE; + UINT8 OCId = 0u; + UINT16 acCnt = 0u; /*OCΧеļ*/ + UINT16 tmpAcIndex = 0u; + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + UINT8 acRelEnvelopeCnt = 0u; + UINT8 acAssertStatus = AAM_API_AC_UT; + UINT16 acRelEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + + /** ȡOCΧеļ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + ASSER_ERROR(NULL == pACIdbuff,errorCode,0x08000000u); + + if (NULL == pACIdbuff) + { + /** ܷ֧*/ + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:AC search error.",errorCode); + } + else + { + for (cycleAc = 0u; cycleAc < acCnt;cycleAc++) + { + /** жϼǷڱOC */ + funRet = elm_PrepareACIsSelf(pACIdbuff[cycleAc],&OCId); + + if (ELM_BELONG_OTHER == funRet) + { + /** ڱOC */ + } + else + { + /** ȡ״̬ */ + tmpACStatus = elm_PrepareACStatus(pACIdbuff[cycleAc]); + + if (ELM_AC_OCC == tmpACStatus) + { + /** ͨҼ*/ + tmpAcIndex = elm_PrepareACIndex(pACIdbuff[cycleAc]); + + /** ͨȡİ */ + acRelEnvelopeCnt = elm_GetACRelEnvelopeCnt(tmpAcIndex, acRelEnvelopeID); + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX == acRelEnvelopeCnt,errorCode,0x04000000u); + + /** ȡ״̬ */ + acAssertStatus = elm_PrepareACAssertStatus(pACIdbuff[cycleAc]); + + if (acRelEnvelopeCnt > 0u) + { + /** ռüڰ磬Ϊȷ*/ + } + else if ((AAM_API_AC_ARB == acAssertStatus) || (AAM_API_AC_REDUNARB == acAssertStatus) || (AAM_API_AC_REDUNUT == acAssertStatus)) + { + /** ARBڼ䣬*/ + } + else + { + /** жϼǷռް磬Ƚ*/ + checkFlag = aam_CheckACEnterRedun(pACIdbuff[cycleAc]); + + if (CI_ERROR == checkFlag) + { + aam_SetACEnterRedun(pACIdbuff[cycleAc]); + ELM_LOG(ELM_LOG_FATAL,"info:AC%d Enter Redun.",pACIdbuff[cycleAc]); + } + else + { + /** ռްδ࣬ */ + ASSERT_BREAK(ELM_AC_OCC == tmpACStatus,errorCode,0x02000000u); + } + } + } + else + { + /** У*/ + } + + } + } + + /** úֵ*/ + ASSERT_SETRET(cycleAc == acCnt,ret,CI_SUCCESS,CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:AC%d UKT ELM Lose.",errorCode,pACIdbuff[cycleAc])); + } + + /** */ + return ret; +} + +/** + * @brief ̬ӳϷУ + * @param[in] + * @param[out] + * @return CI_ERROR 󣬷ʧ + CI_SUCCESS ȷسɹ + * @note + */ +static UINT8 elm_ACRelEnvelopeCheck(void) +{ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT16 cycleAc = 0u; + UINT8 cycleElm = 0u; + const EnvelopeStruct *pTemp = NULL; + UINT8 OCId = 0u; + UINT16 acCnt = 0u; /*OCΧеļ*/ + UINT16 tmpAcIndex = 0u; + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + UINT8 acRelEnvelopeCnt = 0u; + UINT16 acRelEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + UINT32 errorCode = 0u; + + /** ȡOCΧеļ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + ASSERT_RET_VALUE(NULL == pACIdbuff,ret,0x80000000u); + + for (cycleAc = 0u; cycleAc < acCnt;cycleAc++) + { + /** жϼǷڱOC */ + funRet = elm_PrepareACIsSelf(pACIdbuff[cycleAc],&OCId); + + if (ELM_BELONG_OTHER == funRet) + { + /** ڱOC */ + } + else + { + /** ͨҼ*/ + tmpAcIndex = elm_PrepareACIndex(pACIdbuff[cycleAc]); + + /** ͨȡİ */ + acRelEnvelopeCnt = elm_GetACRelEnvelopeCnt(tmpAcIndex, acRelEnvelopeID); + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX <= acRelEnvelopeCnt,errorCode,0x40000000u); + + for(cycleElm = 0u; cycleElm < acRelEnvelopeCnt;cycleElm++) + { + pTemp = elm_GetEnvelopeInfoPtr(acRelEnvelopeID[cycleElm]); + ASSERT_BREAK(NULL == pTemp,errorCode,0x00000000u); + } + + /** жϼϹİǷ񶼴 */ + ASSERT_BREAK(cycleElm != acRelEnvelopeCnt,errorCode,0x40000000u); + } + } + + /** úֵ*/ + ASSERT_SETRET(cycleAc == acCnt,ret,CI_SUCCESS,CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:AC%d Rel ELM lose.",errorCode,pACIdbuff[cycleAc])); + + /** */ + return ret; +} + +/** + * @brief ̬CTɳ + * @param[in] + * @param[out] + * @return + * @note + */ +static void elm_FlyingProtect(void) +{ + /*- ֲ */ + UINT16 cycle = 0u; /*ѭ*/ + UINT8 maxShutdownRedunTime = 0u; + UINT8 chCTCheck = CI_ERROR; /*CT*/ + UINT16 trainCnt = 0U; /*г*/ + UINT16 ii = 0U; + UINT32 dwCurCyc = Get2oo2CurCycleNum(); + UINT32 dwFlyStartCyc = 0U; + UINT16 wTrainId = 0U; + UINT8 chTimeCheck = 0u; + UINT32 dwFlyOverCyc = 0U; + + chCTCheck = elm_FlyingProtect_CT(); /*CTɳ*/ + elm_FlyingProtect_UCT();/*UCTɳɾΪUKT*/ + + trainCnt = GetTrainSum(); + /** ɳ崻 */ + if (CI_SUCCESS == chCTCheck) + { + /** δɳɳ崻ʱ */ + } + else + { + /** ȡõķɳ崻ʱ */ + maxShutdownRedunTime = elm_PrepareCTFlyingRedunTime(); + + for (ii = 0U; ii < trainCnt; ii++) + { + wTrainId = GetTrainId(ii); + if (0U != wTrainId) + { + dwFlyStartCyc = GetTrainStartFlyProtectCycNum(wTrainId); + chTimeCheck = SystemOverTimeCheck(dwFlyStartCyc, (UINT32)maxShutdownRedunTime); + if (CI_TIME_OUT== chTimeCheck) + { + SetFlyProtectOverCyc(dwCurCyc); /*ɳ־*/ + } + else + { + ; /*δʱ*/ + } + } + } + } + + dwFlyOverCyc = GetFlyProtectOverCyc(); + chTimeCheck = SystemOverTimeCheck(dwFlyOverCyc, SHUT_DOWN_ALARM_TIME); + if (CI_TIME_NO != chTimeCheck) + { + debug_infor_printf((const)"\n GATEWAY_FLY_SHUT_DOWN . StartCyc_:%d _CurCyc_:%d\n", dwFlyOverCyc, dwCurCyc); + if (CI_TIME_OUT == chTimeCheck) + { + SetPlatOverFlag();/*ʱ䵽 崻־*/ + } + } + else + { + ; /*崻*/ + } +} + +/** + * @brief ̬ȡβ󷽼 + * @param[in] + * @param[out] + * @return + * @note ڼΪĿβΪ + */ +static UINT16 elm_GetEnvelopTailACIDs(IN const EnvelopeStruct* pEnvelop,OUT UINT16 acID[AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH]) +{ + UINT16 ret = UINT16_MAX; + UINT8 cycle = 0u; + UINT16 tmpPhyId = 0u; + UINT16 ACrelPhyId = 0; + UINT16 tmpACCnt = 0u; + UINT16 tmpACId[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 tmpSearchACCnt = 0u; + UINT16 tmpSearchACId[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 mergeACIndex = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + /*_ ڲ */ + ASSERT_RET_VALUE(NULL == pEnvelop,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == acID,ret,0x40000000u); + + /** ѯβID*/ + ACrelPhyId = elm_PrepareACRelPhyId(pEnvelop->ACID[0u]); + tmpACId[tmpACCnt++] = pEnvelop->ACID[0u]; + + if (0u == ACrelPhyId) + { + /** ݴ*/ + } + else + { + /*_ һβͬͬһεļ*/ + for (cycle = 1u; cycle < pEnvelop->ACCnt; cycle++) + { + tmpPhyId = elm_PrepareACRelPhyId(pEnvelop->ACID[cycle]); + + if (ACrelPhyId == tmpPhyId) + { + tmpACId[tmpACCnt++] = pEnvelop->ACID[cycle]; + } + else + { + /** ͬͬһ*/ + break; + } + } + + + /*_ ڶҳβ󷽼 */ + for (cycle = 0u; cycle < tmpACCnt; cycle++) + { + /* ѯ󷽼*/ + tmpSearchACCnt = elm_PrepareAdjacentAC(tmpACId[cycle], (UINT8)(~(pEnvelop->startPos.Dir)), tmpSearchACId, &cDirectionPointFlag); + + if (AC_MAXCNT_IN_SWITCH >= tmpSearchACCnt) + { + /** ϲβ󷽵ļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(acID,(UINT16)(AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH),mergeACIndex,tmpSearchACId,AC_MAXCNT_IN_SWITCH,tmpSearchACCnt); + } + else + { + break; + } + } + + + /** úֵ*/ + if ((cycle == tmpACCnt) && ((UINT16)(AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH) >= mergeACIndex)) + { + ret = mergeACIndex; + } + else + { + /** */ + } + } + + return ret; +} + +/** + * @brief ̬ȡβ󷽼 + * @param[in] + * @param[out] + * @return + * @note ڼΪĿβΪ + */ +static UINT16 elm_GetEnvelopHeadACIDs(IN const EnvelopeStruct* pEnvelop,OUT UINT16 acID[AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH]) +{ + UINT16 ret = UINT16_MAX; + UINT8 cycle = 0u; + UINT16 tmpPhyId = 0u; + UINT16 ACrelPhyId = 0u; + UINT16 tmpACCnt = 0u; + UINT16 tmpACId[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 tmpSearchACCnt = 0u; + UINT16 tmpSearchACId[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 mergeACIndex = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + /*_ ڲ */ + ASSERT_RET_VALUE(NULL == pEnvelop,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == acID,ret,0x40000000u); + ASSERT_RET_VALUE(0u == pEnvelop->ACCnt,ret,0x20000000u); + + + /** ѯβID*/ + ACrelPhyId = elm_PrepareACRelPhyId(pEnvelop->ACID[pEnvelop->ACCnt - 1u]); + tmpACId[tmpACCnt++] = pEnvelop->ACID[pEnvelop->ACCnt - 1u]; + + if (0u == ACrelPhyId) + { + /** ݴ*/ + } + else + { + /*_ һͷͬͬһεļ*/ + for (cycle = 1u; cycle < pEnvelop->ACCnt; cycle++) + { + tmpPhyId = elm_PrepareACRelPhyId(pEnvelop->ACID[pEnvelop->ACCnt - cycle - 1u]); + + if (ACrelPhyId == tmpPhyId) + { + tmpACId[tmpACCnt++] = pEnvelop->ACID[pEnvelop->ACCnt - cycle - 1u]; + } + else + { + /** ͬͬһ*/ + break; + } + } + + + /*_ ڶҳͷǰ */ + for (cycle = 0u; cycle < tmpACCnt; cycle++) + { + /* ѯǰ*/ + tmpSearchACCnt = elm_PrepareAdjacentAC(tmpACId[cycle], pEnvelop->endPos.Dir, tmpSearchACId, &cDirectionPointFlag); + + if (AC_MAXCNT_IN_SWITCH >= tmpSearchACCnt) + { + /** ϲͷǰļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(acID,AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH,mergeACIndex,tmpSearchACId,AC_MAXCNT_IN_SWITCH,tmpSearchACCnt); + } + else + { + break; + } + } + + + /** úֵ*/ + if ((cycle == tmpACCnt) && ((AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH) >= mergeACIndex)) + { + ret = mergeACIndex; + } + else + { + /** */ + } + } + + return ret; +} + +/** + * @brief ȡָ᷶ΧΧڵİϢ + * @param[in] const UINT16 acID[] + * @param[in] UINT8 acCnt + * @param[out] UINT16 envelopeID[TRAIN_SUM_MAX_IN_OC] ID洢 + * @return TRAIN_SUM_MAX_IN_OC ִд + 0 ~ TRAIN_SUM_MAX_IN_OC ִгɹ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_MergeEnvelope(IN const UINT16 acID[], UINT8 acCnt, INOUT UINT16 envelopeID[TRAIN_SUM_MAX_IN_OC]) +{ + /*- ߱ */ + UINT8 ret = TRAIN_SUM_MAX_IN_OC; + UINT8 cycle = 0u; + UINT16 mergeIndex = 0u; + UINT8 merCnt = 0u; + UINT8 acRelEnvelopeCnt = 0u; + UINT16 acRelEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + UINT16 tempACIndex = 0u; + UINT32 errorCode = 0u; /**/ + + /** ڲУ */ + if ((NULL == acID) || (NULL == envelopeID) || (0u == acCnt)) + { + /** ڲ*/ + errorCode += 0x08000000u; + } + else + { + /** */ + for (cycle = 0u;cycle < TRAIN_SUM_MAX_IN_OC;cycle++) + { + envelopeID[cycle] = ENVELOPE_UNVAILD_INDEX; + } + + /** м */ + for (cycle = 0u;cycle < acCnt; cycle++) + { + /** ͨIDȡ */ + tempACIndex = elm_PrepareACIndex(acID[cycle]); + + /** ȡϹİ */ + acRelEnvelopeCnt = elm_GetACRelEnvelopeCnt(tempACIndex,acRelEnvelopeID); + + /** жǷҪѭ */ + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX == acRelEnvelopeCnt,errorCode,0x04000000u); + + /** ۼӰ */ + merCnt = merCnt + acRelEnvelopeCnt; + + /** жǷѭ*/ + ASSERT_BREAK(merCnt > TRAIN_SUM_MAX_IN_OC,errorCode,0x02000000u); + + /** ϲ */ + mergeIndex = elm_PrepareMergeUINT16Array(envelopeID,TRAIN_SUM_MAX_IN_OC,mergeIndex,acRelEnvelopeID,SECTION_REL_ENVELOPE_SUM_MAX,acRelEnvelopeCnt); + + /** жǷѭ*/ + ASSERT_BREAK(mergeIndex != merCnt,errorCode,0x01000000u); + } + + /** ÷ֵ */ + ASSERT_SETRET(cycle == acCnt,ret,merCnt,TRAIN_SUM_MAX_IN_OC); + } + + /** */ + return ret; +} + + +/** + * @brief ȡڵİ + * @param[in] UINT16 envelopeId + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + * @note + * 1EnvelopeManageAPI.cֵļУ޸ + */ +UINT8 elm_GetNearestEnvelope(UINT16 envelopeId,OUT UINT16 *preEnvelope,OUT UINT16 *backEnvelope) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; /**/ + const EnvelopeStruct* pEnvelop = NULL; + UINT8 envelopeCnt = 0u; /* */ + UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] = {0u}; /*ID*/ + UINT16 acCnt = 0u; /** ǰ*/ + UINT16 acID[AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH] = {0u}; + UINT8 acStatus = ELM_AC_OCC; + UINT16 mergeACIndex = 0u; + UINT16 mergeACCntMax = (SECTION_IN_ENVELOPE_SUM_MAX + 2U * AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH); + UINT16 mergeACID[SECTION_IN_ENVELOPE_SUM_MAX + 2U * AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH] = {0u}; + UINT8 includeCnt = 0u; + UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] = {0u}; /** غϵİid */ + + /** ȡг */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeId); + + /** жϰǷȷ*/ + if ((NULL == pEnvelop) || (NULL == preEnvelope) || (NULL == backEnvelope)) + { + /** ô*/ + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x08000000u); + } + else + { + /** ȡβռ״̬ */ + acStatus = elm_PrepareACStatus(pEnvelop->ACID[0]); + + /** жϰβǷռãռãҪѯһ*/ + if (ELM_AC_OCC == acStatus) + { + /* ѯ󷽼ᣬβռãڵĿΪȷȻˣҪѯȫβڼ*/ + acCnt = elm_GetEnvelopTailACIDs(pEnvelop,acID); + + /** ϲβ󷽵ļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID,mergeACCntMax,mergeACIndex,acID,(AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH),acCnt); + + /** Ⱥϲļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID,mergeACCntMax,mergeACIndex,pEnvelop->ACID,SECTION_IN_ENVELOPE_SUM_MAX,pEnvelop->ACCnt); + + /** ô*/ + ASSER_ERROR(mergeACIndex > mergeACCntMax,errorCode,0x04000000u); + + } + else + { + /** Ⱥϲļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID,mergeACCntMax,mergeACIndex,pEnvelop->ACID,SECTION_IN_ENVELOPE_SUM_MAX,pEnvelop->ACCnt); + + /** ô*/ + ASSER_ERROR(mergeACIndex > mergeACCntMax,errorCode,0x02000000u); + } + + if (0u == errorCode) + { + /** ȡͷռ״̬ */ + acStatus = elm_PrepareACStatus(pEnvelop->ACID[pEnvelop->ACCnt -1U]); + + /** жϰͷǷռãռãҪѯһ */ + if (ELM_AC_OCC == acStatus) + { + /* ѯǰ,˴ѯĿڼʵһĴΪͷѹ˲ռãֱӽɾǴ˴һΪͳһƣһ*/ + acCnt = elm_GetEnvelopHeadACIDs(pEnvelop,acID); + + /** ϲͷǰļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID,mergeACCntMax,mergeACIndex,acID,(AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH),acCnt); + + /** ô*/ + ASSER_ERROR(mergeACIndex > mergeACCntMax,errorCode,0x04000000u); + + } + else + { + /** 账*/ + } + + /** жǷɹ */ + if (0u == errorCode) + { + /** ȡǰİ */ + envelopeCnt = elm_MergeEnvelope(mergeACID,(UINT8)mergeACIndex,arEnvelopID); + + /** ȡǰ*/ + funRet = elm_SearchNearestEnvelope(pEnvelop,arEnvelopID,envelopeCnt,preEnvelope,backEnvelope,&includeCnt,includeELMid); + + /** ô*/ + ASSER_ERROR(CI_SUCCESS != funRet,errorCode,0x08000000u); + } + else + { + /** ѯ */ + } + } + else + { + /** ѯ */ + } + } + + /** ÷ֵ*/ + ASSERT_SETRET(0u== errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + + +/** + * @brief UKT + * @param[in] UINT16 ACIndex + * @param[in] LOD_STRU startPoint λ + * @param[in] LOD_STRU endPoint յλ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_AddUKTEnvelope(UINT16 ACIndex, LOD_STRU startPoint, LOD_STRU endPoint) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; /* ֵ */ + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; /**/ + UINT16 buffIndex = ENVELOPE_UNVAILD_INDEX; /** 绺ַ */ + EnvelopeStruct tmpEnvelope = {0u}; /*ʱ*/ + + /** һ */ + funRet = elm_CreateEnveLope(TYPE_UKT_ENVELOPE,LINE_MAX_TRAIN,startPoint,endPoint,0u,0u,&tmpEnvelope); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x80000000u); + + /** ڶȡõİ洢λ */ + buffIndex = elm_GetEnvelopeValidIndex(); + ASSER_ERROR(ENVELOPE_UNVAILD_INDEX == buffIndex,errorCode,0x40000000u); + + /** жϰλǷȷ*/ + if (ENVELOPE_UNVAILD_INDEX != buffIndex) + { + /** ðΨһʶ*/ + tmpEnvelope.id = buffIndex; + + /** ӵ洢*/ + funRet = elm_SetEnvelopeByIndex(&tmpEnvelope,buffIndex); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x20000000u); + + /** ᵽӳϵ */ + funRet = elm_SetACRelEnvelopeMap(OP_ADD,ACIndex,buffIndex); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x10000000u); + + /** ά־--󼶱 */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:UKT Add error.\n",errorCode)); + } + else + { + /** ά־--󼶱 */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:UKT create error.\n",errorCode)); + } + + /** ú */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + + /** */ + return ret; + +} + + +/** + * @brief ɾָUKT + * @param[in] const EnvelopeStruct* pEnvelope ɾİ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_DeleteUKTEnvelope(IN const EnvelopeStruct* pEnvelope) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT16 tmpACIndex = 0u; + UINT32 errorCode = 0u; + + if ((NULL == pEnvelope) || (1U != pEnvelope->ACCnt)) + { + /** ڲ*/ + errorCode = errorCode + 0x01000000u; + } + else + { + /** ͨIDȡ */ + tmpACIndex = elm_PrepareACIndex(pEnvelope->ACID[0]); + + /** ᵽӳϵ */ + funRet = elm_SetACRelEnvelopeMap(OP_DEL,tmpACIndex,pEnvelope->id); + errorCode = (CI_ERROR == funRet) ? (errorCode + 0x08000000u) : ((errorCode + 0x00000000u)); + + /** հռ */ + funRet = elm_ClearEnvelope(pEnvelope->id); + errorCode = (CI_ERROR == funRet) ? (errorCode + 0x02000000u) : ((errorCode + 0x00000000u)); + } + + /** ú */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + + /** */ + return ret; +} + +/** + * @brief ɾϹİ + * @param[in] UINT8 acBelongFlag OC־ + * @param[in] UINT16 AcID ID + * @return CI_ERROR + CI_SUCCESS ȷ + * @note + * 1˺ֻܽɾDZOCΧļΣ򷵻ʧ + * 2EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_DeleteACRelEnvelope(UINT8 acBelongFlag,UINT16 AcID) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 acRelEnvelopeCnt = 0u; + UINT8 cycle = 0u; + UINT8 cycleAC = 0u; + UINT8 funRtn = CI_ERROR; + UINT16 tmpACindex = 0u; + UINT32 errorCode = 0u; + const EnvelopeStruct *pEnvelope = NULL; + EnvelopeStruct acRelEnvelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + + /** жϼǷڱOC */ + if (ELM_BELONG_OTHER == acBelongFlag) + { + /** ѯϹİ */ + acRelEnvelopeCnt = elm_CopyEnvelopeInAC(AcID,acRelEnvelopeInfo); + ASSER_ERROR(SECTION_REL_ENVELOPE_SUM_MAX == acRelEnvelopeCnt,errorCode,0x80000000u) + + /** жǷѯɹ */ + if (0u == errorCode) + { + /** ȡϵİ */ + for (cycle = 0u; cycle < acRelEnvelopeCnt; cycle++) + { + /** ȡϢ */ + pEnvelope = &acRelEnvelopeInfo[cycle]; + + /** жǷѯʧ */ + ASSERT_BREAK(NULL == pEnvelope, errorCode, 0x40000000u); + + /** жϰ */ + if ((TYPE_UKT_ENVELOPE == pEnvelope->envelopeType) && (1u == acRelEnvelopeCnt)) + { + funRtn = elm_DeleteUKTEnvelope(pEnvelope); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + } + else if ((TYPE_UCT_ENVELOPE == pEnvelope->envelopeType) || (TYPE_CT_ENVELOPE == pEnvelope->envelopeType)) + { + /** ΧڵļᣬӳϵUKT磨ռӣ*/ + for (cycleAC = 0u; cycleAC < pEnvelope->ACCnt;cycleAC++) + { + /** ȡ */ + tmpACindex = elm_PrepareACIndex(pEnvelope->ACID[cycleAC]); + + /** ӳϵ */ + (void)elm_SetACRelEnvelopeMap(OP_DEL,tmpACindex,pEnvelope->id); + } + /** հռ */ + (void)elm_ClearEnvelope(pEnvelope->id); + } + else + { + /** ܷ֧*/ + ASSER_ERROR(NULL == pEnvelope,errorCode,0x10000000u) + } + } + + /** ӡϢ */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Delete Ac%d rel envelope error.",errorCode,AcID)) + } + else + { + /** ѯ*/ + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Get ACID%d rel envelope info error!",errorCode,AcID) + } + } + else + { + /** OC */ + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR) + + /** */ + return ret; +} + + +/** + * @brief ӹϰ + * @param[in] UINT16 acID + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + * 1˺ʵռްļӹϰ + * 2EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_AddUKTEnvelopeInAC(UINT16 acID) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funFlag = CI_ERROR; + UINT16 tmpAcIndex = 0u; + UINT8 tmpStatus = ELM_AC_OCC; + UINT8 acRelEnvelopeCnt = 0u; + UINT16 acRelEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + UINT32 errorCode = 0u; + ELM_AxisLocStruct tmpLoc = {0u}; + + /** ͨIDȡ״̬*/ + tmpStatus = elm_PrepareACStatus(acID); + + if (ELM_AC_OCC == tmpStatus) + { + /** ͨҼ*/ + tmpAcIndex = elm_PrepareACIndex(acID); + + /** ͨȡİ */ + acRelEnvelopeCnt = elm_GetACRelEnvelopeCnt(tmpAcIndex, acRelEnvelopeID); + + /** ҰǷȷ*/ + if (SECTION_REL_ENVELOPE_SUM_MAX == acRelEnvelopeCnt) + { + errorCode = (CI_ERROR == funFlag) ? (errorCode + 0x80000000u) : ((errorCode + 0x00000000u)); + + /** ά־--󼶱*/ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:ac%d rel envelope cnt error,acIndex:%d",errorCode,acID,tmpAcIndex)) + } + else if (0u == acRelEnvelopeCnt) + { + /** ͨIDҼλ--ĿǰARBUCT磬ֱռþUKT*/ + funFlag = elm_PrepareACLoc(acID,ELM_DIR_SAME,&tmpLoc); + errorCode = (CI_ERROR == funFlag) ? (errorCode + 0x40000000u) : ((errorCode + 0x00000000u)); + + /** UKT*/ + funFlag = elm_AddUKTEnvelope(tmpAcIndex,tmpLoc.startPos,tmpLoc.endPos); + errorCode = (CI_ERROR == funFlag) ? (errorCode + 0x20000000u) : ((errorCode + 0x00000000u)); + + /** ϵĺó־λ */ + aam_SetEnvelopeEnterFlag(AAM_ENVELOPE_ENTER_ERROR,LINE_MAX_TRAIN,acID,LINE_MAX_TRAIN); + + /** ά־--󼶱*/ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:ac%d add UKT error,acIndex:%d",errorCode,acID,tmpAcIndex)) + } + else + { + /** 账*/ + } + } + else + { + /** ϵĺó־λ */ + aam_SetEnvelopeEnterFlag(AAM_ENVELOPE_ENTER_ERROR,LINE_MAX_TRAIN,acID,LINE_MAX_TRAIN); + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR) + + /** */ + return ret; +} + +/** + * @brief UCTCT + * @param[in] UINT8 Flag Ƿӹ 0xffʱӹϰ磻ʱӹϰ + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return + * @note + * 1ֻгڱOCʱŴʱǰ˽вֻڴ + * 2EnvelopeManageAPI.cֵļУδ޸ + * 3޸bug YF0083-100 + */ +UINT8 elm_ClearCTOrUCTEnvelope(UINT8 Flag,UINT16 envelopeID) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + const EnvelopeStruct* pEnvelop = NULL; + UINT32 errorCode = 0u; + UINT16 tmpACindex = 0u; + UINT8 funcReturn = CI_ERROR; + + /** ȡϢ */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeID); + + if (NULL == pEnvelop) + { + ASSER_ERROR(CI_ERROR == ret,errorCode,0x80000000u) + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:input error!",errorCode) + } + else if((TYPE_UCT_ENVELOPE == pEnvelop->envelopeType) || (TYPE_CT_ENVELOPE == pEnvelop->envelopeType)) + { + /** ΧڵļᣬӳϵUKT磨ռӣ*/ + for (cycle = 0u; cycle < pEnvelop->ACCnt;cycle++) + { + /** ȡ */ + tmpACindex = elm_PrepareACIndex(pEnvelop->ACID[cycle]); + + /** ӳϵ */ + funcReturn = elm_SetACRelEnvelopeMap(OP_DEL,tmpACindex,envelopeID); + + /** ȡǷӹϰ־λ */ + if (UINT8_MAX == Flag) + { + /** ӹϰ*/ + } + else + { + /** ӹϰ*/ + funcReturn = elm_AddUKTEnvelopeInAC(pEnvelop->ACID[cycle]); + } + } + + if (TYPE_CT_ENVELOPE == pEnvelop->envelopeType) + { + /** гİID */ + funRet = elm_SetTrainRelEnvelopeMap(OP_DEL,pEnvelop->trainID[0], pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x20000000u); + } + else + { + for (cycle = 0u; cycle < pEnvelop->trianCnt;cycle++) + { + /** гİID */ + funRet = elm_SetTrainRelEnvelopeMap(OP_DEL,pEnvelop->trainID[cycle], pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x10000000u); + } + } + + /** հռ */ + funRet = elm_ClearEnvelope(pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x40000000u); + } + else + { + /** 账 */ + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR) + return ret; +} + +/** + * @brief ɾUCTCT + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_DeleteCTOrUCTEnvelope(UINT16 envelopeID) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + const EnvelopeStruct* pEnvelop = NULL; + UINT32 errorCode = 0u; + UINT16 tmpACindex = 0u; + + /** ȡϢ */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeID); + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelop,ret,0x80000000u); + + if((TYPE_UCT_ENVELOPE == pEnvelop->envelopeType) || (TYPE_CT_ENVELOPE == pEnvelop->envelopeType)) + { + /** ϳǰ󷽰 */ + funRet = elm_ProcessFaultElmNear(envelopeID); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x40000000u); + + /** ΧڵļᣬӳϵUKT磨ռӣ*/ + for (cycle = 0u; cycle < pEnvelop->ACCnt;cycle++) + { + /** ȡ */ + tmpACindex = elm_PrepareACIndex(pEnvelop->ACID[cycle]); + + /** ӳϵ */ + funRet = elm_SetACRelEnvelopeMap(OP_DEL,tmpACindex,envelopeID); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x20000000u); + + /** ӹϰ*/ + funRet = elm_AddUKTEnvelopeInAC(pEnvelop->ACID[cycle]); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x10000000u); + } + + if (TYPE_CT_ENVELOPE == pEnvelop->envelopeType) + { + /** гİID */ + funRet = elm_SetTrainRelEnvelopeMap(OP_DEL,pEnvelop->trainID[0], pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x08000000u); + } + else + { + for (cycle = 0u; cycle < pEnvelop->trianCnt;cycle++) + { + /** гİID */ + funRet = elm_SetTrainRelEnvelopeMap(OP_DEL,pEnvelop->trainID[cycle], pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x04000000u); + } + } + + /** հռ */ + funRet = elm_ClearEnvelope(pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x02000000u); + } + else + { + /** 账 */ + } + + /** úֵ */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Delete UCT/CT envelope%d info error.",errorCode,envelopeID)); + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + +/** + * @brief OC͵İϢ뵽ڴ + * @param[in] UINT8 OCid OC id + * @param[out] + * @return + * @note + * 1˺ֻܽɾDZOCΧļΣ򷵻ʧ + */ +void elm_AddNextOCEnvelopetoBuff(UINT8 OCid) +{ + /*-ֲ*/ + UINT8 envelopeCnt = 0u; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + UINT8 cycleAC = 0u; + UINT16 ACIndex = 0u; + UINT16 buffIndex = ENVELOPE_UNVAILD_INDEX; + UINT32 errorCode = 0u; + EnvelopeStruct tempEnvelope = {0u}; + CfpEnvelopeStruct InfEnvelope[SECTION_REL_ENVELOPE_SUM_MAX * ONE_OTHER_CFP_SUM_MAX] = {0u}; + + /** ȡOC͵İϢ */ + envelopeCnt = elm_PrepareNextOcInfEnvelope(OCid,InfEnvelope); + + /** еİ磬ӵ */ + for (cycle = 0u;cycle < envelopeCnt;cycle++) + { + /** ջ*/ + (void)CommonMemSet(&tempEnvelope, (UINT32)sizeof(EnvelopeStruct),0, (UINT32)sizeof(EnvelopeStruct)); + + /** ưϢ.ӿںϷУ鱣ֶ֤βԽ*/ + tempEnvelope.envelopeType = InfEnvelope[cycle].envelopeType; + tempEnvelope.headTrainID = InfEnvelope[cycle].headTrainID; + tempEnvelope.tailTrainID = InfEnvelope[cycle].tailTrainID; + tempEnvelope.startPos = InfEnvelope[cycle].startPos; + tempEnvelope.endPos = InfEnvelope[cycle].endPos; + tempEnvelope.trianCnt = InfEnvelope[cycle].trianCnt; + (void)CommonMemCpy(&tempEnvelope.trainID[0], (UINT32)(sizeof(UINT16)*tempEnvelope.trianCnt),&InfEnvelope[cycle].trainID[0], (UINT32)(sizeof(UINT16)*tempEnvelope.trianCnt)); + (void)CommonMemCpy(&tempEnvelope.ACTPort[0], (UINT32)(sizeof(UINT8) * tempEnvelope.trianCnt), &InfEnvelope[cycle].ACTPort[0], (UINT32)(sizeof(UINT8) * tempEnvelope.trianCnt)); + tempEnvelope.ACCnt = InfEnvelope[cycle].ACCnt; + (void)CommonMemCpy(&tempEnvelope.ACID[0], (UINT32)(sizeof(UINT16)*tempEnvelope.ACCnt),&InfEnvelope[cycle].ACID[0], (UINT32)(sizeof(UINT16)*tempEnvelope.ACCnt)); + + + /** ȡõİ洢λ */ + buffIndex = elm_GetEnvelopeValidIndex(); + ASSER_ERROR(ENVELOPE_UNVAILD_INDEX == buffIndex,errorCode,0x80000000u); + + /** жϰλǷȷ*/ + if (ENVELOPE_UNVAILD_INDEX != buffIndex) + { + /** ðΨһʶ*/ + tempEnvelope.id = buffIndex; + + /** ӵ洢*/ + funRet = elm_SetEnvelopeByIndex(&tempEnvelope,buffIndex); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x40000000u); + + /** ᵽӳϵ */ + for (cycleAC = 0u; cycleAC < tempEnvelope.ACCnt; cycleAC++) + { + /** ȡ */ + ACIndex = elm_PrepareACIndex(tempEnvelope.ACID[cycleAC]); + funRet = elm_SetACRelEnvelopeMap(OP_ADD,ACIndex,buffIndex); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x20000000u); + } + + /** ά־--󼶱 */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:next oC ELM Add error.\n",errorCode)) + } + else + { + /** ά־--󼶱 */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:next oC ELM create error.\n",errorCode)); + } + } + + /** */ + if (0u != errorCode) + { + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Add NextOC Envelope to Buff error.\n",errorCode) + } + else + { + /** ȷ */ + } +} + + +/** + * @brief ˢOCΧڵİϢ + * @param[in] + * @param[out] + * @return + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_RefreshNextOCEnvelope(void) +{ + /*- ֲ */ + UINT16 acCnt = 0u; /*OCΧеļ*/ + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + UINT8 comOCCnt = 0u; /* ͨOC */ + const UINT8 *pOCIdbuff = NULL; + UINT32 errorCode = 0u; + UINT16 cycleAc = 0u; + UINT8 cycleOC = 0u; + UINT8 acBelongFlag = ELM_BELONG_OTHER; + UINT8 acBelongOCid = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 commStatusFlag = ELM_COM_STATUS_ERROR; + + /** ȡOCΧеļ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + + /** ȡOCͨŵOC */ + comOCCnt = elm_PrepareComOCID(&pOCIdbuff); + + if ((NULL == pACIdbuff) || ((0u != comOCCnt) && (NULL == pOCIdbuff))) + { + /** ܷ֧*/ + errorCode = errorCode + 0x80000000u; + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Get ACID and Comoc Buff error!", errorCode) + } + else + { + if (0u != comOCCnt) + { + /** һмᣬɾDZOCΧİ*/ + for (cycleAc = 0u; cycleAc < acCnt; cycleAc++) + { + /** ȡOC*/ + acBelongFlag = elm_PrepareACIsSelf(pACIdbuff[cycleAc], &acBelongOCid); + + /** жϲѯǷȷ */ + if (0u == acBelongFlag) + { + /** ܷ֧*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Get ACID%d belong OCid%d error!", pACIdbuff[cycleAc], acBelongOCid) + ASSERT_BREAK(0u == acBelongFlag, errorCode, 0x40000000u) + } + else if (ELM_BELONG_OWNER == acBelongFlag) + { + /** ڱOCд */ + } + else + { + /** ɾϵİϢ */ + funRtn = elm_DeleteACRelEnvelope(acBelongFlag, pACIdbuff[cycleAc]); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x20000000u) + } + } + + /** ɹˢ*/ + if (0u == errorCode) + { + /** ڶмᣬOCͨŴӹϰ */ + for (cycleAc = 0u; cycleAc < acCnt; cycleAc++) + { + /** ȡOC*/ + acBelongFlag = elm_PrepareACIsSelf(pACIdbuff[cycleAc], &acBelongOCid); + + /** жϲѯǷȷ */ + if (0u == acBelongFlag) + { + /** ܷ֧*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Get ACID%d belong OCid%d error!", pACIdbuff[cycleAc], acBelongOCid) + ASSERT_BREAK(0u == acBelongFlag, errorCode, 0x10000000u) + } + else if (ELM_BELONG_OWNER == acBelongFlag) + { + /** ڱOCд */ + } + else + { + /** ȡͨ״̬ */ + commStatusFlag = elm_PrepareOCCommStatus(acBelongOCid); + + /** жͨ״̬ */ + if (ELM_COM_STATUS_OK == commStatusFlag) + { + /** ͨˢOCϢ */ + } + else + { + /** ӹϰ */ + (void)elm_AddUKTEnvelopeInAC(pACIdbuff[cycleAc]); + } + } + } + + + /** ȡOCİϢ */ + for (cycleOC = 0u; cycleOC < comOCCnt; cycleOC++) + { + /** ȡͨ״̬ */ + commStatusFlag = elm_PrepareOCCommStatus(pOCIdbuff[cycleOC]); + + /** жͨ״̬ */ + if (ELM_COM_STATUS_OK == commStatusFlag) + { + /** ͨȡOCϢˢ */ + elm_AddNextOCEnvelopetoBuff(pOCIdbuff[cycleOC]); + } + else + { + /** 账 */ + } + } + + } + else + { + /** ܷ֧*/ + } + } + else + { + ; + } + } + + + /** */ + if (0u != errorCode) + { + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Set Envelope from NextOC error!",errorCode) + } + else + { + /** ȷ */ + } +} + +/** + * @brief άϢӡ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_MaintenanceInfo(void) +{ + /*- ֲ */ + UINT16 cycle = 0u; + UINT8 funRet = ENVELOPE_UNEXIT; + const EnvelopeStruct* pTemp = NULL; + UINT16 acCnt = 0u; + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + UINT16 tmpAcIndex = 0u; + UINT8 tmpACStatus = ELM_AC_OCC; + UINT8 acRelEnvelopeCnt = 0u; + UINT8 OcID = 0u; + UINT16 acRelEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + UINT8 cycleEnvelope = 0u; + UINT8 cycleTrain = 0u; + UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] = {0u}; /*гİ*/ + UINT8 relEnvelopeCnt = TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + const AxisAsserStruct* pAcAssertInfo = NULL; + UINT8 isSelfFlag = ELM_BELONG_OWNER; + UINT8 outString[MAX_ENVELOPE_LOG_NUM] = { 0U }; + UINT16 outStringLength = 0U; + + ELM_LOG(ELM_LOG_DEBUG,"MaintenanceInfo:\n"); + + /** ӡȫɸάϢ */ + wls_PrintfWLScreenInfo(); + + /*- ӡаϢ*/ + for (cycle = 1u; cycle < ENVELOPE_SUM_MAX; cycle++) + { + funRet = elm_IsEnvelopeExit(cycle); + if (ENVELOPE_EXIT == funRet) + { + pTemp = elm_GetEnvelopeInfoPtr(cycle); + elm_PrintfEnvelope(pTemp); + } + else + { + /** */ + } + } + + if (0U == OutEnvelopeStrLen) + { + ; + } + else + { +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nEnvelopeLogData:%d\nEnvelpeid(2)-envelopeType-PEnvelpeheadTrainID(2)-PEnvelpetailTrainID(2)-PEnvelpetrianCnt-PEnvelpetrainID(2)-[PEnvelpetrainID(2)-rrmRequst-curAct-nextSta(2)-runDir-lastAct-rrmReply-rrmReason]-startPosLnk(2)-startPosOff(4)-startPosDir-endPosLnk(2)-endPosOff(4)-endPosDir-PEnvelpeACCnt-PEnvelpeACID-UCTToUKTStartCycNum(4)", OutEnvelopeStrLen); + debug_out_array(0xAA, OutEnvelopeStr, OutEnvelopeStrLen); + +#endif + +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0, "\nEnvelopeLogData:%d", OutEnvelopeStrLen); + Out_Array_Buffer(0, "\nPEnvelpeid(2)-envelopeType-PEnvelpeheadTrainID(2)-PEnvelpetailTrainID(2)-PEnvelpetrianCnt-PEnvelpetrainID(2)-[PEnvelpetrainID(2)-rrmRequst-curAct-nextSta(2)-runDir-lastAct-rrmReply-rrmReason]-startPosLnk(2)-startPosOff(4)-startPosDir-endPosLnk(2)-endPosOff(4)-endPosDir-PEnvelpeACCnt-PEnvelpeACID-UCTToUKTStartCycNum(4):%d", OutEnvelopeStrLen); + Out_Array_Buffer(16, OutEnvelopeStr, OutEnvelopeStrLen); + +#endif + + CleanString(OutEnvelopeStr); + OutEnvelopeStrLen = 0U; + } + + /*- ӡмӳϵ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + for (cycle = 0u; cycle < acCnt; cycle++) + { + tmpAcIndex = elm_PrepareACIndex(pACIdbuff[cycle]); + acRelEnvelopeCnt = elm_GetACRelEnvelopeCnt(tmpAcIndex, acRelEnvelopeID); + tmpACStatus = elm_PrepareACStatus(pACIdbuff[cycle]); + pAcAssertInfo = elm_PrepareAxisAssertInfoPtr(pACIdbuff[cycle]); + isSelfFlag = elm_PrepareACIsSelf(pACIdbuff[cycle],&OcID); + +#if ELM_DEBUG + if (isSelfFlag == ELM_BELONG_OWNER) + { +#else + if ((NULL != pAcAssertInfo) && (((acRelEnvelopeCnt > 0u) && (acRelEnvelopeCnt < SECTION_REL_ENVELOPE_SUM_MAX)) || + (ELM_AC_OCC == tmpACStatus))) + { +#endif + + ShortToChar(pACIdbuff[cycle], &outString[outStringLength]); /*ID*/ + outStringLength += 2U; + ShortToChar(tmpAcIndex, &outString[outStringLength]); /*ID*/ + outStringLength += 2U; + outString[outStringLength] = OcID; /*ID*/ + outStringLength++; + outString[outStringLength] = acRelEnvelopeCnt; /*ιİ*/ + outStringLength++; + + for (cycleEnvelope = 0u; cycleEnvelope < acRelEnvelopeCnt; cycleEnvelope++) + { + ShortToChar(acRelEnvelopeID[cycleEnvelope], &outString[outStringLength]); /*ιİID*/ + outStringLength += 2U; + } + + outString[outStringLength] = tmpACStatus; /*ռ״̬*/ + outStringLength++; + outString[outStringLength] = pAcAssertInfo->acAssertStatus; /*ARB״̬*/ + outStringLength++; + outString[outStringLength] = pAcAssertInfo->redunOverCanArb; /*ARB־*/ + outStringLength++; + outString[outStringLength] = pAcAssertInfo->AxisCommBadArbFlag; /*ͨжϿARB־*/ + outStringLength++; + outString[outStringLength] = pAcAssertInfo->passTrainFlag; /*κóͨ־*/ + outStringLength++; + ShortToChar(pAcAssertInfo->passTrainID, &outString[outStringLength]); /*κóͨгID*/ + outStringLength += 2U; + outString[outStringLength] = pAcAssertInfo->redunTime; /*ռʱ*/ + outStringLength++; + outString[outStringLength] = pAcAssertInfo->headEnterTrainCnt; /*νгͷ*/ + outStringLength++; + + for (cycleTrain = 0u; cycleTrain < pAcAssertInfo->headEnterTrainCnt; cycleTrain++) + { + ShortToChar(pAcAssertInfo->headEnterTrainId[cycleTrain], &outString[outStringLength]); /*γͷгID*/ + outStringLength += 2U; + } + + outString[outStringLength] = pAcAssertInfo->tailEnterTrainCnt; /*νгβ*/ + outStringLength++; + for (cycleTrain = 0u; cycleTrain < pAcAssertInfo->tailEnterTrainCnt; cycleTrain++) + { + ShortToChar(pAcAssertInfo->tailEnterTrainId[cycleTrain], &outString[outStringLength]); /*γβгID*/ + outStringLength += 2U; + } + } + else + { + /** */ + } + } + + if (0u == outStringLength) + { + ; + } + else + { +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nACData:%d\nACId(2)-ACIdIndex(2)-CiId-ACRelEnvelopeCnt-ACRelEnvelopeID(2)-ACOccStatus-ACARBStatus-redunOverCanArb-AxisCommBadArbFlag-PassCtFlag-PassCtId(2)-OccRedunTime-HeadEnterTrainCnt-HeadEnterTrainId(2)-TailEnterTrainCnt-TailEnterTrainId(2)", outStringLength); + debug_out_array(0xAA, outString, outStringLength); + +#endif + +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0, "\nACData:%d", outStringLength); + Out_Array_Buffer(0, "\nACId(2)-ACIdIndex(2)-CiId-ACRelEnvelopeCnt-ACRelEnvelopeID(2)-ACOccStatus-ACARBStatus-PassCtFlag-PassCtId(2)-OccRedunTime-HeadEnterTrainCnt-HeadEnterTrainId(2)-TailEnterTrainCnt-TailEnterTrainId(2):%d", outStringLength); + Out_Array_Buffer(16, outString, outStringLength); + +#endif + + CleanString(outString); + outStringLength = 0U; + } + + /*- ӡгӳϵ */ + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + relEnvelopeCnt = elm_GetRelELIdByTrainID(cycle,relEnvelopeID); + + if (0U != relEnvelopeCnt) + { + ShortToChar(cycle, &outString[outStringLength]); /*гID*/ + outStringLength += 2U; + outString[outStringLength] = relEnvelopeCnt; /*гİ*/ + outStringLength += 1U; + + for (cycleTrain = 0u; cycleTrain < relEnvelopeCnt;cycleTrain++) + { + ShortToChar(relEnvelopeID[cycleTrain], &outString[outStringLength]); /*гİID*/ + outStringLength += 2U; + } + } + } + + if (0u == outStringLength) + { + ; + } + else + { +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nTrainEnvelopData:%d\nTrainCnt-TrainId(2)-RelEnvelopeCnt(2)-RelEnvelopeId(2)", outStringLength); + debug_out_array(0xAA, outString, outStringLength); + +#endif + +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0, "\nTrainEnvelopData:%d", outStringLength); + Out_Array_Buffer(0, "\nTrainCnt-TrainId(2)-RelEnvelopeCnt(2)-RelEnvelopeId(2):%d", outStringLength); + Out_Array_Buffer(16, outString, outStringLength); + +#endif + } +} + + +/** + * @brief ֪ + * @param[in] UINT8 envelopeType + * @param[in] UINT16 TrainID ID + * @param[in] LOD_STRU startPoint ʼλ + * @param[in] LOD_STRU endPoint ֹλ + * @param[in] UINT16 headTrainID ǰгID + * @param[in] UINT16 tailTrainID гID + * @param[out] EnvelopeStruct *pEnvelope + * @return CI_SUCCESS 紴ȷسɹ + * CI_ERROR 紴ʧܣʧ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_CreateEnveLope(UINT8 envelopeType,UINT16 TrainID, LOD_STRU startPoint,LOD_STRU endPoint,UINT16 headTrainID,UINT16 tailTrainID, \ + INOUT EnvelopeStruct *pEnvelope) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + + /** ڲУ*/ + if (NULL == pEnvelope) + { + /** pEnvelopeϷ*/ + } + else if ((TYPE_CT_ENVELOPE != envelopeType) && (TYPE_UCT_ENVELOPE != envelopeType) && (TYPE_UKT_ENVELOPE != envelopeType)) + { + /** envelopeTypeϷ */ + } + else if ((TrainID > LINE_MAX_TRAIN)||(headTrainID > LINE_MAX_TRAIN) || (tailTrainID > LINE_MAX_TRAIN)) + { + /** headTrainIDtailTrainIDϷ */ + } + else + { + /*- */ + pEnvelope->envelopeType = envelopeType; + pEnvelope->startPos = startPoint; + pEnvelope->endPos = endPoint; + pEnvelope->headTrainID = headTrainID; + pEnvelope->tailTrainID = tailTrainID; + pEnvelope->trainID[pEnvelope->trianCnt] = TrainID; + pEnvelope->ACTPort[pEnvelope->trianCnt] = elm_PrepareTrainACT(TrainID); + pEnvelope->trianCnt++; + + /** ѯ֮ļ*/ + pEnvelope->ACCnt = elm_PrepareACBtwPoints(startPoint,endPoint,&(pEnvelope->ACID[0])); + + /** ÷ֵ*/ + ret = ((0u == pEnvelope->ACCnt) || (SECTION_IN_ENVELOPE_SUM_MAX == pEnvelope->ACCnt)) ? CI_ERROR: CI_SUCCESS; + } + + /** */ + return ret; +} + + +/** + * @brief ѯ׼ǰİ + * @param[in] const EnvelopeStruct* pEnvelop ׼ + * @param[in] const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] Ƚϵİ + * @param[in] UINT8 envelopeCnt Ƚϵİ + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @param[out] UINT8 *includeCnt İ + * @param[out] UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] İID + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + 0xffu غϰ + + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_SearchNearestEnvelope(IN const EnvelopeStruct* pEnvelop, IN const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC], UINT8 envelopeCnt, OUT UINT16 *preEnvelope, OUT UINT16 *backEnvelope, OUT UINT8 *includeCnt, OUT UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC]) +{ + + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + const EnvelopeStruct* pHead = NULL; + const EnvelopeStruct* pTail = NULL; + const EnvelopeStruct* pTemp = NULL; + UINT8 cycle = 0u; + UINT8 funRet = 0u; + + /** ڲж */ + if ((NULL == pEnvelop) || (NULL == arEnvelopID) || (NULL == preEnvelope) || (NULL == backEnvelope) || (NULL == includeCnt) || (NULL == includeELMid)) + { + /** ڲУ */ + errorCode = errorCode + 0x80000000u; + ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:input error!", errorCode) + } + else + { + /** α磬ǰ */ + for (cycle = 0u; cycle < envelopeCnt; cycle++) + { + /** ͨIDҰϢ */ + pTemp = elm_GetEnvelopeInfoPtr(arEnvelopID[cycle]); + + /** жǷ˳ */ + ASSERT_BREAK(NULL == pTemp, errorCode, 0x04000000U); + + /** жϰǷΪ*/ + if (pTemp->id == pEnvelop->id) + { + /** */ + } + else if ((TYPE_CT_ENVELOPE == pTemp->envelopeType) && (TYPE_CT_ENVELOPE == pEnvelop->envelopeType) && + (pTemp->trainID[0] == pEnvelop->trainID[0])) + { + /** ֽ㴦 */ + } + else + { + /** Ƚλùϵ */ + funRet = elm_PrepareRelationBtwEnvelope(pEnvelop, pEnvelop->startPos, pTemp); + + /** жǷ˳ */ + ASSERT_BREAK(0x00u == funRet, errorCode, 0x02000000u); + + if (0x02u == funRet) + { + if (NULL == pHead) + { + pHead = pTemp; + } + else if (pTemp->id == pHead->id) + { + /** */ + } + else + { + funRet = elm_PrepareRelationBtwEnvelope(pHead, pEnvelop->startPos, pTemp); + /** жǷ˳ */ + ASSERT_BREAK(0x00u == funRet, errorCode, 0x01000000u); + + /** жǷҪǰ*/ + if (0x01u == funRet) + { + pHead = pTemp; + } + else + { + /** Ҫ*/ + } + } + } + else if (0x01u == funRet) + { + if (NULL == pTail) + { + pTail = pTemp; + } + else if (pTemp->id == pTail->id) + { + /** */ + } + else + { + funRet = elm_PrepareRelationBtwEnvelope(pTail, pEnvelop->startPos, pTemp); + /** жǷ˳ */ + ASSERT_BREAK(0x00u == funRet, errorCode, 0x00800000u); + + /** жǷҪǰ*/ + if (0x02u == funRet) + { + pTail = pTemp; + } + else + { + /** Ҫ*/ + } + } + } + else if ((TRAIN_SUM_MAX_IN_OC > (*includeCnt)) && ((0x03u == funRet) || (0x04u == funRet))) + { + includeELMid[(*includeCnt)] = pTemp->id; + (*includeCnt) += 1u; + } + else + { + /** Ƚϲȫ*/ + ret = CI_ERROR; + break; + } + } + } + + /** úֵ*/ + if ((cycle == envelopeCnt) && (0u == (*includeCnt))) + { + (*preEnvelope) = (NULL == pHead) ? 0u : pHead->id; + (*backEnvelope) = (NULL == pTail) ? 0u : pTail->id; + ret = CI_SUCCESS; + } + else if ((cycle == envelopeCnt) && (0u != (*includeCnt))) + { + (*preEnvelope) = (NULL == pHead) ? 0u : pHead->id; + (*backEnvelope) = (NULL == pTail) ? 0u : pTail->id; + ret = 0xffu; + } + else + { + /** */ + } + } + + return ret; +} + + +/** + * @brief ϵİϢ + * @param[in] UINT16 acID + * @param[out] EnvelopeStruct envelopeInfo[] ϵİϢ + * @return 0 ϲڰ + 0СSECTION_REL_ENVELOPE_SUM_MAX ϰ + SECTION_REL_ENVELOPE_SUM_MAXִд + * @note + */ +UINT8 elm_CopyEnvelopeInAC(UINT16 acID,INOUT EnvelopeStruct envelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX]) +{ + /*- ֲ */ + UINT8 ret = SECTION_REL_ENVELOPE_SUM_MAX; + UINT8 cycle = 0u; + UINT8 tempCnt = 0u; + UINT16 tmpACIndex = 0u; + UINT16 tmpEnvelopID[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + const EnvelopeStruct* tmpEnvelope = NULL; + + /** ڲϷУ*/ + if (NULL == envelopeInfo) + { + /** ڲ*/ + } + else + { + /** ͨIDȡ */ + tmpACIndex = elm_PrepareACIndex(acID); + + /** ȡİϢ*/ + tempCnt = elm_GetACRelEnvelopeCnt(tmpACIndex,tmpEnvelopID); + + if (SECTION_REL_ENVELOPE_SUM_MAX == tempCnt) + { + /** ѯ*/ + } + else + { + for (cycle = 0u; cycle < tempCnt; cycle++) + { + tmpEnvelope = elm_GetEnvelopeInfoPtr(tmpEnvelopID[cycle]); + (void)CommonMemCpy(&envelopeInfo[cycle], (UINT32)sizeof(EnvelopeStruct),tmpEnvelope, (UINT32)sizeof(EnvelopeStruct)); + } + ret = tempCnt; + } + + } + + /** */ + return ret; +} + + +/** + * @brief ȡڰλ + * @param[in] UINT16 ACid мᣨмΪ緶ΧڵļΣ + * @param[in] const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ + * @param[in] UINT8 newACCnt ռõİ + * @param[out] + * @return UINT8_MAX + ELM_HEAD_AND_TAIL ڰͷڰβ + ELM_HEAD ڰͷ + ELM_TAIL ڰβ + ELM_BODY ڰ + * @note + * 1½2022421 + */ +UINT8 elm_GetACOfEnvelopePos(UINT16 ACid, IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX],UINT8 newACCnt) +{ + /*- ֲ */ + UINT8 ret = (UINT8)UINT8_MAX; + UINT16 tmpPhyId = 0u; + UINT16 tmpHeadPhyId = 0u; + UINT16 tmpTailPhyId = 0u; + + /*- ڲж */ + ASSERT_RET_VALUE(NULL == newACID,ret,0x80000000u); + ASSERT_RET_VALUE(((UINT8)SECTION_IN_ENVELOPE_SUM_MAX < newACCnt) || (0u == newACCnt),ret,0x40000000u); + + /** ȡм */ + tmpPhyId = elm_PrepareACRelPhyId(ACid); + tmpHeadPhyId = elm_PrepareACRelPhyId(newACID[newACCnt - 1u]); + tmpTailPhyId = elm_PrepareACRelPhyId(newACID[0u]); + + if ((0u == tmpPhyId) || (0u == tmpHeadPhyId) || (0u == tmpTailPhyId)) + { + /** ݴ */ + } + else if((tmpPhyId == tmpHeadPhyId) && (tmpPhyId == tmpTailPhyId)) + { + /** ڰͷڰβ*/ + ret = (UINT8)ELM_HEAD_AND_TAIL; + } + else if (tmpPhyId == tmpHeadPhyId) + { + /** ڰͷڰβ*/ + ret = (UINT8)ELM_HEAD; + } + else if (tmpPhyId == tmpTailPhyId) + { + /** ڰβ*/ + ret = (UINT8)ELM_TAIL; + } + else + { + /** ڰ */ + ret = (UINT8)ELM_BODY; + } + + /** */ + return ret; +} + + +/** + * @brief ɾлɵİϢ + * @param[in] const EnvelopeStruct* pEnvelop + * @param[in] UINT16 trainid гID + * @param[in] UINT8 cutFlag ȡʶ + * @param[out] + * @return CI_ERROR ѯʧ + * CI_SUCCESS ѯɹ + * @note + */ +UINT8 elm_ClearHanderOverEnvelope(IN const EnvelopeStruct* pEnvelop,UINT16 trainid) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + UINT32 errorCode = 0u; + UINT32 toHeadDis = UINT32_MAX; + UINT32 toTailDIs = UINT32_MAX; + ELM_TrainSafeLocStruct tmpSafeLoc = { 0u }; /* ȫλʱ洢 */ + + /** ȡгİȫλ*/ + funRet = elm_PrepareTrainSafeLoc(trainid, &tmpSafeLoc); + + /*- ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelop,ret,0x80000000u); + /** ѯͷβڰյľ*/ + toHeadDis = elm_PrepareDistanceBtwPoints(pEnvelop->endPos,tmpSafeLoc.endPos); + toTailDIs = elm_PrepareDistanceBtwPoints(pEnvelop->endPos,tmpSafeLoc.startPos); + ASSERT_RET_VALUE((UINT32_MAX == toHeadDis) || (UINT32_MAX == toTailDIs),ret,0x40000000u); + + for (cycle = 0u; cycle < pEnvelop->ACCnt; cycle++) + { + /** dzβҪжǷк */ + if (toTailDIs < toHeadDis) + { + /** óβ*/ + aam_SetEnvelopeEnterFlag(AAM_ENVELOPE_TAIL_EXIT,pEnvelop->tailTrainID,pEnvelop->ACID[cycle],trainid); + } + else if(toTailDIs > toHeadDis) + { + /** óͷ*/ + aam_SetEnvelopeEnterFlag(AAM_ENVELOPE_HEAD_EXIT,pEnvelop->headTrainID,pEnvelop->ACID[cycle],trainid); + } + else + { + /** лгδнȡ */ + aam_SetEnvelopeEnterFlag(AAM_ENVELOPE_ENTER_ERROR,LINE_MAX_TRAIN,pEnvelop->ACID[cycle],trainid); + } + } + + if (0u == errorCode) + { + if ((toTailDIs < toHeadDis) && (0u == pEnvelop->tailTrainID)) + { + /** ޺˳β壬ӹϰ*/ + funRet = elm_ClearCTOrUCTEnvelope(UINT8_MAX, pEnvelop->id); + } + else if ((toTailDIs > toHeadDis) && (0u == pEnvelop->headTrainID)) + { + /** ǰ˳β壬ӹϰ*/ + funRet = elm_ClearCTOrUCTEnvelope(UINT8_MAX, pEnvelop->id); + } + else + { + /** ӹϰ*/ + funRet = elm_ClearCTOrUCTEnvelope(0u, pEnvelop->id); + } + + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x20000000u); /*ô*/ + } + else + { + /** ʧܣش */ + } + + /*_ úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + + + +/** + * @brief ȫ + * @param[in] + * @param[out] + * @return + * @note 1ģ鴦󣬵ȫ࣬ռüᶼóUKTϢá + 2ģ鴦ȷCT緶Χڼ᲻ȫУCTɳ + 3ģ鴦ȷΧCTȻڰ磨CT + 4ģ鴦ȷΧռüȻڰUT/CTࣨUT + */ +void elm_SafeProtectProcess(void) +{ + /*- ֲ */ + UINT8 workFlag = ELM_WORK_ERROR; + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; + + /** ģ־λ */ + workFlag = elm_GetELMWorkFlag(); + + /** ģ鲻ģ³ʼ */ + if (ELM_WORK_ERROR == workFlag) + { + /** Ѿ޷ ٽз */ + } + else + { + /** UKTڲ */ + funRet = elm_UKTAdjacentSwProtect(); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x80000000u); + + /** UT*/ + funRet = elm_UTLosingProtect(); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x40000000u); + + /** CT/UCTɳ--崻*/ + elm_FlyingProtect(); + + /** OCΧڵļӳϷУ */ + funRet = elm_ACRelEnvelopeCheck(); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x20000000u); + + if (0u != errorCode) + { + /** ð粻ȷ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:ELM is treated with safety protection.",errorCode); + } + else + { + /** 紦ȷ */ + } + } +} + +/** + * @brief ǷUTռãڼ䲻UTռã + * @param[in] UINT16 ACID ID + * @param[out] + * @return CI_ERROR UTռ + CI_SUCCESS UTռ + * @note + */ +UINT8 elm_CheckACIsUTOcc(UINT16 ACID) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT16 tmpAcIndex = 0u; + UINT8 cycle = 0u; + UINT8 acRelEnvelopeCnt = 0u; + UINT16 acRelEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + const EnvelopeStruct* pEnvelop = NULL; + UINT32 errorCode = 0u; + + /** ͨҼ*/ + tmpAcIndex = elm_PrepareACIndex(ACID); + + /** ͨȡİ */ + acRelEnvelopeCnt = elm_GetACRelEnvelopeCnt(tmpAcIndex, acRelEnvelopeID); + + if (SECTION_REL_ENVELOPE_SUM_MAX == acRelEnvelopeCnt) + { + /** ѯ*/ + errorCode += 0x80000000u; + } + else + { + /** İ */ + for (cycle = 0u; cycle < acRelEnvelopeCnt; cycle++) + { + /** ȡг */ + pEnvelop = elm_GetEnvelopeInfoPtr(acRelEnvelopeID[cycle]); + + /** ȡг˳ѭ*/ + ASSERT_BREAK(NULL == pEnvelop,errorCode,0x40000000u); + + /** UKTΪUTռã˳ѭ */ + ASSERT_BREAK(TYPE_UKT_ENVELOPE == pEnvelop->envelopeType,errorCode,0x00000000u); + } + + /** úֵ */ + ASSERT_SETRET(cycle == acRelEnvelopeCnt,ret,CI_SUCCESS,CI_ERROR); + } + + /** */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Check Ac%d UT occ error",errorCode,ACID)); + return ret; +} + +/** + * @brief UCT/CTϰǰ + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return CI_SUCCESS ɹ + * CI_ERROR ʧ + * @note + */ +UINT8 elm_ProcessFaultElmNear(UINT16 envelopeID) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + const EnvelopeStruct* pEnvelop = NULL; + const EnvelopeStruct* pTemp = NULL; + UINT16 preEnvelopeid = 0u; + UINT16 backEnvelopeid = 0u; + UINT32 errorCode = 0u; + UINT8 cDir = 0U; /*緽*/ + + /** ȡϢ */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeID); + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelop,ret,0x80000000u); + + /** ѯǰͺ󷽰*/ + funRet = elm_GetNearestEnvelope(envelopeID,&preEnvelopeid,&backEnvelopeid); + + /** жϷѯɹ*/ + if (CI_SUCCESS == funRet) + { + /*- ذǰ*/ + pTemp = elm_GetEnvelopeInfoPtr(preEnvelopeid); + if ((NULL != pTemp) && (TYPE_UKT_ENVELOPE != pTemp->envelopeType))/*UKTǰ˿ɣ봦*/ + { + cDir = elm_DirIsSameELMWithELM(pTemp, pEnvelop); /*Ƚ緽*/ + + if (ELM_DIR_SAME == cDir) + { + (void)elm_SetEnvelopeTailTrainID(pTemp->id, LINE_MAX_TRAIN); + } + else if (ELM_DIR_CONVERT == cDir) + { + (void)elm_SetEnvelopeHeadTrainID(pTemp->id, LINE_MAX_TRAIN); + } + else + { + ; /**/ + } + } + else + { + /** 账 */ + } + + /*- ذ*/ + pTemp = elm_GetEnvelopeInfoPtr(backEnvelopeid); + + if ((NULL != pTemp) && (TYPE_UKT_ENVELOPE != pTemp->envelopeType))/*UKT粻ܽ봦*/ + { + cDir = elm_DirIsSameELMWithELM(pTemp, pEnvelop); /*Ƚ緽*/ + + if (ELM_DIR_SAME == cDir) + { + (void)elm_SetEnvelopeHeadTrainID(pTemp->id, LINE_MAX_TRAIN); + } + else if (ELM_DIR_CONVERT == cDir) + { + (void)elm_SetEnvelopeTailTrainID(pTemp->id, LINE_MAX_TRAIN); + } + else + { + ; /**/ + } + } + else + { + /** 账 */ + } + + /** ɹ÷ֵ */ + ret = CI_SUCCESS; + } + else + { + /** ѯǰ󳵴 */ + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x40000000u); + } + + /** */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Search NearBy train error.",errorCode)); + return ret; +} + + +/** + * @brief жϰAзǷBзͬ + * @param[in] const EnvelopeStruct* pEnvelopA A + * @param[in] const EnvelopeStruct* pEnvelopB B + * @param[out] + * @return ELM_DIR_SAME ɹ + * ELM_DIR_CONVERT ʧ + Ƿ + * @note ޣĿǰúδǷ仯 + */ +UINT8 elm_DirIsSameELMWithELM(const EnvelopeStruct* pEnvelopA, const EnvelopeStruct* pEnvelopB) +{ + UINT8 ret = 0u; + UINT8 cDirChangeNum = 0U; + UINT8 cResidue = 0U; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelopA,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == pEnvelopB,ret,0x40000000u); + + cDirChangeNum = elm_PrepareDirChangNum(&(pEnvelopA->startPos), &(pEnvelopB->startPos)); + if (UINT8_MAX != cDirChangeNum) + { + /*ݷ仯÷ֵ*/ + cResidue = cDirChangeNum % 2U; + if (0U == cResidue) + { + /*ڻż仯*/ + ASSERT_SETRET(pEnvelopA->startPos.Dir == pEnvelopB->startPos.Dir, ret, ELM_DIR_SAME, ELM_DIR_CONVERT); + } + else + { + /*仯*/ + ASSERT_SETRET(pEnvelopA->startPos.Dir == pEnvelopB->startPos.Dir, ret, ELM_DIR_CONVERT, ELM_DIR_SAME); + } + } + else + { + /**/ + } + + return ret; +} + +/** + * @brief ̬¼ϵгϢ + * @param[in] IN const EnvelopeStruct* pEnvelop Ϣ + * @param[in] const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ + * @param[in] UINT8 newACCnt ռõİ + * @param[in] UINT8 cutFlag ȡ־λ + * @return CI_SUCCESS ȷسɹ + * CI_ERROR 󣬷ʧ + * @note + * 1½2022421,ֻܸCTʹ + */ +UINT8 elm_RefreshACseqInfoForCT(IN const EnvelopeStruct* pEnvelop,IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX],UINT8 newACCnt,UINT8 cutFlag) +{ + /*- ֲ */ + UINT8 ret = (UINT8)CI_ERROR; + UINT8 cycle = 0u; + UINT8 funValid = CI_ERROR; + UINT8 posFlag = (UINT8)UINT8_MAX; + UINT16 trainid = (UINT16)LINE_MAX_TRAIN; + UINT32 errorCode = 0u; + + /*- ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelop,ret,0x80000000u); + ASSERT_RET_VALUE(0u == newACCnt,ret,0x40000000u); + ASSERT_RET_VALUE((0u == pEnvelop->trainID[0]) || ((UINT16)LINE_MAX_TRAIN == pEnvelop->trainID[0]),ret,0x20000000u); + ASSERT_RET_VALUE((ELM_HEAD_CUT != cutFlag) && (ELM_TAIL_CUT != cutFlag) && (ELM_NO_CUT != cutFlag),ret,0x10000000u); + + /** ͨųID */ + trainid = pEnvelop->trainID[0]; + + + for (cycle = 0u; cycle < newACCnt;cycle++) + { + /** ʼִ*/ + funValid = CI_SUCCESS; + + /** ȡڰеλ */ + posFlag = elm_GetACOfEnvelopePos(newACID[cycle],newACID,newACCnt); + + switch(posFlag) + { + case ELM_HEAD_AND_TAIL: + { + if (ELM_HEAD_CUT == cutFlag) + { + /** β֣β*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_TAIL_ENTER,pEnvelop->tailTrainID,newACID[cycle],trainid); + } + else if (ELM_TAIL_CUT == cutFlag) + { + /** ͷ֣ͷ*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_HEAD_ENTER,pEnvelop->tailTrainID,newACID[cycle],trainid); + } + else + { + /** ͷ֣ͷ*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_HEAD_ENTER,pEnvelop->headTrainID,newACID[cycle],trainid); + /** β֣β*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_TAIL_ENTER,pEnvelop->tailTrainID,newACID[cycle],trainid); + } + + break; + } + case ELM_HEAD: + { + /** ֣ͷ*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_HEAD_ENTER,pEnvelop->headTrainID,newACID[cycle],trainid); + break; + } + case ELM_TAIL: + { + /** β֣β*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_TAIL_ENTER,pEnvelop->tailTrainID,newACID[cycle],trainid); + break; + } + case ELM_BODY: + { + /** ֣ͷ*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_HEAD_ENTER,pEnvelop->headTrainID,newACID[cycle],trainid); + break; + } + default: + { + /** ܷ֧ */ + funValid = CI_ERROR; + break; + } + } + + /** жǷҪѭ */ + ASSERT_BREAK(CI_ERROR == funValid,errorCode,0x08000000u); + } + + /*_ úֵ */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:Refresh elm_seq In ac%d error,posFlag %d.",errorCode,pEnvelop->ACID[cycle],posFlag)); + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + + +/** + * @brief ¼ϵUCTϢ + * @param[in] IN const EnvelopeStruct* pEnvelop Ϣ + * @return CI_SUCCESS ȷسɹ + * CI_ERROR 󣬷ʧ + * @note + */ +UINT8 elm_RefreshACseqInfoForUCT(IN const EnvelopeStruct* pEnvelop) +{ + UINT8 ret = CI_ERROR; + UINT8 cylceAC = 0u; + UINT8 cycleTrain = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelop,ret,0x80000000u); + + /** UCT緶ΧгͷͳΣUCTͳһгIDʶ򵥣пܻΪɾϵгϢкóͨ*/ + for (cylceAC = 0u; cylceAC < pEnvelop->ACCnt;cylceAC++) + { + for (cycleTrain = 0u; cycleTrain < pEnvelop->trianCnt;cycleTrain++) + { + /** ͷ֣ͷ*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_HEAD_ENTER,pEnvelop->headTrainID,pEnvelop->ACID[cylceAC],pEnvelop->trainID[cycleTrain]); + /** β֣β*/ + aam_SetEnvelopeEnterFlag((UINT8)AAM_ENVELOPE_TAIL_ENTER,pEnvelop->tailTrainID,pEnvelop->ACID[cylceAC],pEnvelop->trainID[cycleTrain]); + } + } + + /** úֵ */ + ret = CI_SUCCESS; + + return ret; +} + + +/** + * @brief UCTᴦ + * @param[in] UINT8 flag 巽ʽ + * @param[in] const EnvelopeStruct* pEnvelope Ϣ + * @param[in] UINT16 acID Id + * @param[out] + * @return CI_SUCCESS ȷسɹ + * CI_ERROR 󣬷ʧ + * @note + */ +UINT8 elm_UCTEnvelopeLeaveAC(UINT8 flag,IN const EnvelopeStruct* pEnvelope,UINT16 acID) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE((ELM_TAIL != flag) && (ELM_HEAD != flag),ret,0x80000000u); + ASSERT_RET_VALUE(NULL == pEnvelope,ret,0x40000000u); + + if (ELM_HEAD == flag) + { + for (cycle = 0u; cycle < pEnvelope->trianCnt; cycle++) + { + /** гϢ */ + aam_ClearACEnvelopeEnterInfo(acID,pEnvelope->trainID[cycle]); + } + + (void)aam_ClearACPassTrainFlag(acID); + ELM_LOG_LOC(ELM_LOG_FATAL,"info:Clear AC%d CT Pass Flag because UCT%d",acID,pEnvelope->id); + } + else + { + for (cycle = pEnvelope->trianCnt; 0u != cycle; cycle--) + { + /** гϢ */ + aam_ClearACEnvelopeEnterInfo(acID,pEnvelope->trainID[cycle - 1u]); + } + + (void)aam_ClearACPassTrainFlag(acID); + ELM_LOG_LOC(ELM_LOG_FATAL,"info:Clear AC%d CT Pass Flag because UCT%d",acID,pEnvelope->id); + } + + /** úֵ*/ + ret = CI_SUCCESS; + return ret; +} + + +/** + * @brief UCT˵ΪĶ˵ + * @param[in] UINT8 headorTail ͷǰβ + * @param[in] UINT16 acId ID + * @param[in] EnvelopeStruct* ptemp ַָ + * @param[out] + * @return CI_ERROR + * CI_SUCCESS ȷ + * @note + */ + UINT8 elm_SetUCTEnvelopeDot(UINT8 headorTail,UINT16 acId,IN const EnvelopeStruct* ptemp) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + ELM_AxisLocStruct acpos = {0u}; + UINT8 cDir = 0U; + + /** ڲУ */ + ASSERT_RET_VALUE((ELM_HEAD != headorTail) && (ELM_TAIL != headorTail), ret, 0x80000000u); + ASSERT_RET_VALUE(NULL == ptemp,ret,0x40000000u); + + /** ͷ/βѡʹõķ */ + cDir = ELM_HEAD == headorTail ? ptemp->endPos.Dir : ptemp->startPos.Dir; + + /** ȡĶ˵λ */ + funRtn = elm_PrepareACLoc(acId, cDir, &acpos); + + if (CI_SUCCESS == funRtn) + { + if (ELM_HEAD == headorTail) + { + ret = elm_SetEnvelopeLoc(ptemp->id,ptemp->startPos,acpos.endPos); + } + else + { + ret = elm_SetEnvelopeLoc(ptemp->id,acpos.startPos,ptemp->endPos); + } + } + else + { + /** ѯ */ + } + + return ret; + } + + + /** + * @brief ѯڰİָ˵İ + * @param[in] UINT8 flagͷǰβ + * @param[in] const EnvelopeStruct* pBase ׼ + * @param[in] UINT8 includeCnt ڰİ + * @param[in] UINT16 includeELM[TRAIN_SUM_MAX_IN_OC] ڰİid + * @param[out] UINT16 *pEnvelopeid,ҵİID + * @return CI_ERROR ѯʧ + CI_SUCCESSѯȷ + * @note + */ + UINT8 elm_SearchNearstEnvInInclude(UINT8 flag,IN const EnvelopeStruct* pBase,UINT8 includeCnt,UINT16 includeELM[TRAIN_SUM_MAX_IN_OC],OUT UINT16 *pEnvelopeid) + { + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 cycle = 0u; + UINT32 disHead = 0u; + UINT32 disTail = 0u; + UINT32 maxDisBtwHeadAndTail = 0u; + UINT32 maxDis = 0u; + const EnvelopeStruct *pTemp = NULL; + const EnvelopeStruct *pOut = NULL; + + + /** ڲУ */ + ASSERT_RET_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag), ret, 0x80000000u); + ASSERT_RET_VALUE(NULL == pBase, ret, 0x40000000u); + ASSERT_RET_VALUE(NULL == includeELM, ret, 0x20000000u); + ASSERT_RET_VALUE(NULL == pEnvelopeid, ret, 0x10000000u); + + for (cycle = 0u; cycle < includeCnt; cycle++) + { + /** ȡUCTĵַָ */ + pTemp = elm_GetEnvelopeInfoPtr(includeELM[cycle]); + ASSERT_BREAK(NULL == pTemp,errorCode,0x08000000u); + + if (ELM_HEAD == flag) + { + /** ȡյ׼ͷľ */ + disHead = elm_PrepareDistanceBtwPoints(pTemp->endPos,pBase->endPos); + disTail = elm_PrepareDistanceBtwPoints(pTemp->startPos,pBase->endPos); + } + else + { + /** ȡյ׼βľ */ + disHead = elm_PrepareDistanceBtwPoints(pTemp->endPos,pBase->startPos); + disTail = elm_PrepareDistanceBtwPoints(pTemp->startPos,pBase->startPos); + } + + /** ȡֵ */ + maxDisBtwHeadAndTail = disHead > disTail ? disHead : disTail; + + if (maxDis <= maxDisBtwHeadAndTail) + { + pOut = pTemp; + maxDis = maxDisBtwHeadAndTail; + } + else + { + /** */ + } + } + + if ((0u == errorCode) && (NULL != pOut)) + { + *pEnvelopeid = pOut->id; + } + else + { + /** 账 */ + } + /** úֵ */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Search Nearest Train In Base%d error.\n",errorCode,pBase->id)); + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; + } + + /** + * @brief ˢег + * @param[in] + * @param[out] + * @return + * @note + */ + void elm_RefreshTrainConstrolStatus(void) + { + UINT32 errorCode = 0u; + UINT16 cycle = 0u; + UINT8 cFunRetVal = CI_ERROR; + UINT8 headNeedScreen = NEED_SCREEN; + UINT8 tailNeedScreen = NEED_SCREEN; + UINT8 trainStatus = OFFLINE_CONFIRM_STATUS; + UINT8 relEnvelopeCnt= TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] = {0u}; /*гİ*/ + const EnvelopeStruct *pEnvelopeInfo = NULL; + const WLTrainStatusInfoStruct* pTemp = NULL; + + /* ڵĵ״̬óڵ״̬ */ + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + pTemp = wls_GetCurTrainStatusInfo(cycle); + ASSER_ERROR(NULL == pTemp,errorCode,0x80000000u); + + if (NULL != pTemp) + { + cFunRetVal = wls_SetLastTrainStatusInfo(cycle, pTemp); + ASSER_ERROR(CI_ERROR == cFunRetVal,errorCode,0x40000000u); + } + else + { + /** */ + } + } + + /** ˢ±г״̬Ϣ */ + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + trainStatus = wls_GetTrainControlStatus(cycle); + + if (OFFLINE_CONFIRM_STATUS != trainStatus) + { + wls_SetTrainControlStatus(cycle,OUT_CONTROL_STATUS,NEED_SCREEN,NEED_SCREEN); + } + else + { + /* */ + } + } + + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + relEnvelopeCnt = elm_GetRelELIdByTrainID(cycle,relEnvelopeID); + + if (1u == relEnvelopeCnt) + { + /** UCT籾δʵѱ */ + pEnvelopeInfo = elm_GetEnvelopeInfoPtr(relEnvelopeID[0u]); + + if ((NULL != pEnvelopeInfo) && + ((TYPE_CT_ENVELOPE == pEnvelopeInfo->envelopeType) || (TYPE_UCT_ENVELOPE == pEnvelopeInfo->envelopeType))) + { + headNeedScreen = LINE_MAX_TRAIN == pEnvelopeInfo->headTrainID ? NEED_SCREEN : UNNEED_SCREEN; + tailNeedScreen = LINE_MAX_TRAIN == pEnvelopeInfo->tailTrainID ? NEED_SCREEN : UNNEED_SCREEN; + + wls_SetTrainControlStatus(cycle,IN_CONTROL_STATUS,headNeedScreen,tailNeedScreen); + } + else + { + /* 账 */ + } + } + else + { + /* 账 */ + } + } + } + + + /** + * @brief жгǷΪ߳ + * @param[in] UINT16 trainID,гID + * @param[in] UINT8 headNeedScreen, Ҫǰɸ־ + * @param[in] UINT8 tailNeedScreen, Ҫβɸ־ + * @param[out] + * @return + * @note ȫǰСȫOCȫɸΪ߳ + */ + void elm_JudgeTrainOffline(UINT16 trainID, UINT8 headNeedScreen,UINT8 tailNeedScreen) + { + UINT8 funRtn = CI_ERROR; + + /** ȡгλǷɸ */ + funRtn = elm_PrePareTrainLOCAreaType(trainID); + + if (ELM_TRAIN_OUT_WLS_AREA == funRtn) + { + wls_SetTrainControlStatus(trainID,OFFLINE_CONFIRM_STATUS,headNeedScreen,tailNeedScreen); + } + else + { + /** 봦 */ + } + } + + /** + * @brief ɾUCTCT粻⴦ǰǰ/ + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + */ + UINT8 elm_DeleteCTOrUCTUndoSuspic(UINT16 envelopeID) + { + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + const EnvelopeStruct* pEnvelop = NULL; + UINT32 errorCode = 0u; + UINT16 tmpACindex = 0u; + + /** ȡϢ */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeID); + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelop, ret, 0x80000000u); + + if ((TYPE_UCT_ENVELOPE == pEnvelop->envelopeType) || (TYPE_CT_ENVELOPE == pEnvelop->envelopeType)) + { + /** ΧڵļᣬӳϵUKT磨ռӣ*/ + for (cycle = 0u; cycle < pEnvelop->ACCnt; cycle++) + { + /** ȡ */ + tmpACindex = elm_PrepareACIndex(pEnvelop->ACID[cycle]); + + /** ӳϵ */ + funRet = elm_SetACRelEnvelopeMap(OP_DEL, tmpACindex, envelopeID); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x20000000u); + + /** ӹϰ*/ + funRet = elm_AddUKTEnvelopeInAC(pEnvelop->ACID[cycle]); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x10000000u); + } + + if (TYPE_CT_ENVELOPE == pEnvelop->envelopeType) + { + /** гİID */ + funRet = elm_SetTrainRelEnvelopeMap(OP_DEL, pEnvelop->trainID[0], pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x08000000u); + } + else + { + for (cycle = 0u; cycle < pEnvelop->trianCnt; cycle++) + { + /** гİID */ + funRet = elm_SetTrainRelEnvelopeMap(OP_DEL, pEnvelop->trainID[cycle], pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x04000000u); + } + } + + /** հռ */ + funRet = elm_ClearEnvelope(pEnvelop->id); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x02000000u); + } + else + { + /** 账 */ + } + + /** úֵ */ + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Delete UCT/CT envelope%d info error.", errorCode, envelopeID)); + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + return ret; + } + + /** + * @brief ȡڵıг + * @param[in] UINT16 envelopeId + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + * @note + * by cgh 20240514 ĿǰֻRRM + */ + UINT8 elm_GetNearEnvelopRelSameTra(UINT16 envelopeId, OUT UINT16* preEnvelope, OUT UINT16* backEnvelope) + { + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; /**/ + const EnvelopeStruct* pEnvelop = NULL; + UINT8 envelopeCnt = 0u; /* */ + UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] = { 0u }; /*ID*/ + UINT16 acCnt = 0u; /** ǰ*/ + UINT16 acID[AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT8 acStatus = ELM_AC_OCC; + UINT16 mergeACIndex = 0u; + UINT16 mergeACCntMax = (SECTION_IN_ENVELOPE_SUM_MAX + 2U * AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH); + UINT16 mergeACID[SECTION_IN_ENVELOPE_SUM_MAX + 2U * AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT8 includeCnt = 0u; + UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] = { 0u }; /** غϵİid */ + + /** ȡг */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeId); + + /** жϰǷȷ*/ + if ((NULL == pEnvelop) || (NULL == preEnvelope) || (NULL == backEnvelope)) + { + /** ô*/ + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x08000000u); + } + else + { + /** ȡβռ״̬ */ + acStatus = elm_PrepareACStatus(pEnvelop->ACID[0]); + + /** жϰβǷռãռãҪѯһ*/ + if (ELM_AC_OCC == acStatus) + { + /* ѯ󷽼ᣬβռãڵĿΪȷȻˣҪѯȫβڼ*/ + acCnt = elm_GetEnvelopTailACIDs(pEnvelop, acID); + + /** ϲβ󷽵ļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID, mergeACCntMax, mergeACIndex, acID, (AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH), acCnt); + + /** Ⱥϲļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID, mergeACCntMax, mergeACIndex, pEnvelop->ACID, SECTION_IN_ENVELOPE_SUM_MAX, pEnvelop->ACCnt); + + /** ô*/ + ASSER_ERROR(mergeACIndex > mergeACCntMax, errorCode, 0x04000000u); + + } + else + { + /** Ⱥϲļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID, mergeACCntMax, mergeACIndex, pEnvelop->ACID, SECTION_IN_ENVELOPE_SUM_MAX, pEnvelop->ACCnt); + + /** ô*/ + ASSER_ERROR(mergeACIndex > mergeACCntMax, errorCode, 0x02000000u); + } + + if (0u == errorCode) + { + /** ȡͷռ״̬ */ + acStatus = elm_PrepareACStatus(pEnvelop->ACID[pEnvelop->ACCnt - 1U]); + + /** жϰͷǷռãռãҪѯһ */ + if (ELM_AC_OCC == acStatus) + { + /* ѯǰ,˴ѯĿڼʵһĴΪͷѹ˲ռãֱӽɾǴ˴һΪͳһƣһ*/ + acCnt = elm_GetEnvelopHeadACIDs(pEnvelop, acID); + + /** ϲͷǰļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID, mergeACCntMax, mergeACIndex, acID, (AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH), acCnt); + + /** ô*/ + ASSER_ERROR(mergeACIndex > mergeACCntMax, errorCode, 0x04000000u); + + } + else + { + /** 账*/ + } + + /** жǷɹ */ + if (0u == errorCode) + { + /** ȡǰİ */ + envelopeCnt = elm_MergeEnvelope(mergeACID, (UINT8)mergeACIndex, arEnvelopID); + + /** ȡǰ*/ + funRet = elm_FindNearSameTrainEnvelop(pEnvelop, arEnvelopID, envelopeCnt, preEnvelope, backEnvelope, &includeCnt, includeELMid); + + /** ô*/ + ASSER_ERROR(CI_SUCCESS != funRet, errorCode, 0x08000000u); + } + else + { + /** ѯ */ + } + } + else + { + /** ѯ */ + } + } + + /** ÷ֵ*/ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + return ret; + } + + /** + * @brief ѯ׼ǰı + * @param[in] const EnvelopeStruct* pEnvelop ׼ + * @param[in] const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] Ƚϵİ + * @param[in] UINT8 envelopeCnt Ƚϵİ + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @param[out] UINT8 *includeCnt İ + * @param[out] UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] İID + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + 0xffu غϰ + + * @note + * by cgh 20240514 ĿǰֻRRM + */ + UINT8 elm_FindNearSameTrainEnvelop(IN const EnvelopeStruct* pEnvelop, IN const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC], UINT8 envelopeCnt, OUT UINT16* preEnvelope, OUT UINT16* backEnvelope, OUT UINT8* includeCnt, OUT UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC]) + { + + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + const EnvelopeStruct* pHead = NULL; + const EnvelopeStruct* pTail = NULL; + const EnvelopeStruct* pTemp = NULL; + UINT8 cycle = 0u; + UINT8 funRet = 0u; + + /** ڲж */ + if ((NULL == pEnvelop) || (NULL == arEnvelopID) || (NULL == preEnvelope) || (NULL == backEnvelope) || (NULL == includeCnt) || (NULL == includeELMid)) + { + /** ڲУ */ + errorCode = errorCode + 0x80000000u; + ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:input error!", errorCode) + } + else + { + /** α磬ǰ */ + for (cycle = 0u; cycle < envelopeCnt; cycle++) + { + /** ͨIDҰϢ */ + pTemp = elm_GetEnvelopeInfoPtr(arEnvelopID[cycle]); + + /** жǷ˳ */ + ASSERT_BREAK(NULL == pTemp, errorCode, 0x04000000U); + + /** жϰǷΪ*/ + if (pTemp->id == pEnvelop->id) + { + /** */ + } + else if (pTemp->trainID[0] != pEnvelop->trainID[0]) + { + /**DZ */ + } + else + { + /** Ƚλùϵ */ + funRet = elm_PrepareRelationBtwEnvelope(pEnvelop, pEnvelop->startPos, pTemp); + + /** жǷ˳ */ + ASSERT_BREAK(0x00u == funRet, errorCode, 0x02000000u); + + if (0x02u == funRet) + { + if (NULL == pHead) + { + pHead = pTemp; + } + else if (pTemp->id == pHead->id) + { + /** */ + } + else + { + funRet = elm_PrepareRelationBtwEnvelope(pHead, pEnvelop->startPos, pTemp); + /** жǷ˳ */ + ASSERT_BREAK(0x00u == funRet, errorCode, 0x01000000u); + + /** жǷҪǰ*/ + if (0x01u == funRet) + { + pHead = pTemp; + } + else + { + /** Ҫ*/ + } + } + } + else if (0x01u == funRet) + { + if (NULL == pTail) + { + pTail = pTemp; + } + else if (pTemp->id == pTail->id) + { + /** */ + } + else + { + funRet = elm_PrepareRelationBtwEnvelope(pTail, pEnvelop->startPos, pTemp); + /** жǷ˳ */ + ASSERT_BREAK(0x00u == funRet, errorCode, 0x00800000u); + + /** жǷҪǰ*/ + if (0x02u == funRet) + { + pTail = pTemp; + } + else + { + /** Ҫ*/ + } + } + } + else if ((TRAIN_SUM_MAX_IN_OC > (*includeCnt)) && ((0x03u == funRet) || (0x04u == funRet))) + { + includeELMid[(*includeCnt)] = pTemp->id; + (*includeCnt) += 1u; + } + else + { + /** Ƚϲȫ*/ + ret = CI_ERROR; + break; + } + } + } + + /** úֵ*/ + if ((cycle == envelopeCnt) && (0u == (*includeCnt))) + { + (*preEnvelope) = (NULL == pHead) ? 0u : pHead->id; + (*backEnvelope) = (NULL == pTail) ? 0u : pTail->id; + ret = CI_SUCCESS; + } + else if ((cycle == envelopeCnt) && (0u != (*includeCnt))) + { + (*preEnvelope) = (NULL == pHead) ? 0u : pHead->id; + (*backEnvelope) = (NULL == pTail) ? 0u : pTail->id; + ret = 0xffu; + } + else + { + /** */ + } + } + + return ret; + } + + /** + * CTɳ + * ˵ + * ֵ CI_ERROR ڷɳ CI_SUCCESS + * BY fan 20241017 + */ + UINT8 elm_FlyingProtect_CT(void) + { + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT16 cycle = 0u; /*ѭ*/ + UINT16 cycleAc = 0u; + UINT8 trainCnt = 0u; /*ͨų*/ + UINT16 trainID[TRAIN_SUM_MAX_IN_OC] = { 0u }; /*ͨųID*/ + UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] = { 0u }; /*гİ*/ + UINT16 relEnvelopeCnt = TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + UINT16 tmpHeadAc = 0u; + UINT16 tmpTailAC = 0u; + UINT8 tmpHeadACStatus = ELM_AC_FREE; + UINT8 tmpTailACStatus = ELM_AC_FREE; + UINT8 tmpACStatus = ELM_AC_FREE; + const EnvelopeStruct* pEnvelop = NULL; + UINT32 errorCode = 0u; + UINT32 dwCurCyc = Get2oo2CurCycleNum(); + UINT32 maxShutdownRedunTime = (UINT32)elm_PrepareCTFlyingRedunTime(); + UINT32 dwFlyStartCyc = 0U; + UINT8 chTimeCheck = 0U; + UINT8 flyCheck = 0U; + /** CTɳ*/ + trainCnt = elm_PrepareCommTrainID(trainID); + + /** еͨų */ + for (cycle = 0u; cycle < trainCnt; cycle++) + { + /** ȡͨųӦİid */ + relEnvelopeCnt = elm_GetRelELIdByTrainIDAndType(TYPE_CT_ENVELOPE, trainID[cycle], relEnvelopeID); + + /** ȡг */ + pEnvelop = elm_GetEnvelopeInfoPtr(relEnvelopeID[0u]); + + /** ڣ*/ + if (NULL != pEnvelop) + { + /** жǷɳ */ + for (cycleAc = 0u; cycleAc < pEnvelop->ACCnt; cycleAc++) + { + /** ȡ״̬ */ + tmpACStatus = elm_PrepareACStatus(pEnvelop->ACID[cycleAc]); + + /** ռãѭ */ + ASSERT_BREAK(ELM_AC_OCC == tmpACStatus, errorCode, 0x00000000u); + } + + if (cycleAc != pEnvelop->ACCnt) + { + /*CTռü */ + SetTrainStartFlyProtectCycNum(trainID[cycle], 0U); + } + else + { + /** Ƿֽİ磬ֻа룬ʵֶδ룬ȡСȫǰȫ*/ + errorCode = 0u; + + tmpHeadAc = elm_PrepareACOfMaxSafeTailLoc(trainID[cycle]); + tmpTailAC = elm_PrepareACOfMinSafeHeadLoc(trainID[cycle]); + ASSER_ERROR((0u == tmpHeadAc) || (0u == tmpTailAC), errorCode, 0x10000000u); + + tmpHeadACStatus = elm_PrepareACStatus(tmpHeadAc); + tmpTailACStatus = elm_PrepareACStatus(tmpTailAC); + ASSER_ERROR((ELM_AC_FREE == tmpHeadACStatus) && (ELM_AC_FREE == tmpTailACStatus), errorCode, 0x08000000u); + if (0U != errorCode) + { + SetTrainStartFlyProtectCycNum(trainID[cycle], dwCurCyc); + dwFlyStartCyc = GetTrainStartFlyProtectCycNum(trainID[cycle]); + chTimeCheck = SystemOverTimeCheck(dwFlyStartCyc, (UINT32)maxShutdownRedunTime); + if (CI_TIME_OUT == chTimeCheck) + { + elm_AddFlyingTrain(trainID[cycle], pEnvelop->id); + } + flyCheck++; + } + else + { + SetTrainStartFlyProtectCycNum(trainID[cycle], 0U); + } + } + } + else + { + /** CTģз */ + } + } + if (0U == flyCheck) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + return ret; + } + + /** + * UCTɳ + * ˵ + * ֵ + * edit cgh 20241028 + */ + void elm_FlyingProtect_UCT(void) + { + UINT16 cycleAc = 0u; + UINT16 cycleELM = 0u; + UINT8 tmpACStatus = ELM_AC_FREE; + const EnvelopeStruct* pEnvelop = NULL; + UINT8 IsOwnFlag = ELM_BELONG_OWNER; + UINT32 errorCode = 0u; + UINT32 dwCurCyc = Get2oo2CurCycleNum(); + UINT32 maxShutdownRedunTime = (UINT32)elm_PrepareCTFlyingRedunTime(); + UINT32 dwFlyStartCyc = 0U; + UINT8 chTimeCheck = 0U; + + /** еUCT */ + for (cycleELM = 1u; cycleELM < ENVELOPE_SUM_MAX; cycleELM++) + { + /** ȡϢַ */ + pEnvelop = elm_GetEnvelopeInfoPtr(cycleELM); + + if ((NULL == pEnvelop) || (TYPE_UCT_ENVELOPE != pEnvelop->envelopeType)) + { + /** 粻ڻ߷UCT*/ + } + else + { + /** жϰǷڱOC */ + IsOwnFlag = elm_PrepareEnvelopeIsSelf(pEnvelop); + + if (ELM_BELONG_OTHER == IsOwnFlag) + { + /** DZOCΧڵİ磬账 */ + } + else + { + /** жǷɳ */ + for (cycleAc = 0u; cycleAc < pEnvelop->ACCnt; cycleAc++) + { + /** ȡ״̬ */ + tmpACStatus = elm_PrepareACStatus(pEnvelop->ACID[cycleAc]); + + /** ռãѭ */ + ASSERT_BREAK(ELM_AC_OCC == tmpACStatus, errorCode, 0x00000000u); + + } + if (cycleAc != pEnvelop->ACCnt) + { + /** ˵UCTռü */ + SetTrainFlyProStartCycNum(pEnvelop->trainID[0], 0U); + } + else + { + SetTrainFlyProStartCycNum(pEnvelop->trainID[0], dwCurCyc); + dwFlyStartCyc = GetTrainStartFlyProtectCycNum(pEnvelop->trainID[0]); + chTimeCheck = SystemOverTimeCheck(dwFlyStartCyc, (UINT32)maxShutdownRedunTime); + if (CI_TIME_OUT == chTimeCheck) + { + SetTrainFlyProStartCycNum(pEnvelop->trainID[0], 0U); + /*óͨUCTɾΪUKTɳں*/ + elm_DeleteUctPassFlag(pEnvelop->id); + (void)elm_DeleteCTOrUCTEnvelope(pEnvelop->id); + + debug_infor_printf((const)"\n UCT_FlyingProtect DeleteCTOrUCTEnvelope\n"); + } + } + } + } + } + } + + /** +* ɾUCTóͨ־ +* ˵UINT16 envelopeId id +* ֵ +* by cgh 20241028 +*/ +void elm_DeleteUctPassFlag(UINT16 envelopeId) +{ + UINT8 jj = 0U; + const EnvelopeStruct* pEnvelop = NULL; + + /** ȡϢַ */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeId); + if (NULL != pEnvelop) + { + for (jj = 0U; jj < pEnvelop->ACCnt; jj++) + { + (void)aam_ClearACPassTrainFlag(pEnvelop->ACID[jj]); + } + } + else + { + ; /**/ + } + +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeLogicProcess.h b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeLogicProcess.h new file mode 100644 index 0000000..5f9623f --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeLogicProcess.h @@ -0,0 +1,489 @@ +/****************************************************************************** +** ļ: EnvelopeLogicProcess.h +** : ʵְ߼Ҫʵְ +*******************************************************************************/ + +#ifndef ENVELOPE_LOGIC_PROCESS_H_ +#define ENVELOPE_LOGIC_PROCESS_H_ + +#include "EnvelopeDefine.h" +#include "ELMDataPrepare.h" +#include "EnvelopeManage.h" + +/** + * @brief ȡָ᷶ΧΧڵİϢ + * @param[in] const UINT16 acID[] + * @param[in] UINT8 acCnt + * @param[out] UINT16 envelopeID[TRAIN_SUM_MAX_IN_OC] ID洢 + * @return TRAIN_SUM_MAX_IN_OC ִд + 0 ~ TRAIN_SUM_MAX_IN_OC ִгɹ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_MergeEnvelope(IN const UINT16 acID[], UINT8 acCnt, INOUT UINT16 envelopeID[TRAIN_SUM_MAX_IN_OC]); + +/** + * @brief ȡڵİ + * @param[in] UINT16 envelopeId + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_GetNearestEnvelope(UINT16 envelopeId,OUT UINT16 *preEnvelope,OUT UINT16 *backEnvelope); + +/** + * @brief UKT + * @param[in] UINT16 ACIndex + * @param[in] LOD_STRU startPoint λ + * @param[in] LOD_STRU endPoint յλ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_AddUKTEnvelope(UINT16 ACIndex, LOD_STRU startPoint, LOD_STRU endPoint); + + +/** + * @brief ɾָUKT + * @param[in] const EnvelopeStruct* pEnvelope ɾİ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_DeleteUKTEnvelope(IN const EnvelopeStruct* pEnvelope); + +/** + * @brief ɾϹİ + * @param[in] UINT8 acBelongFlag OC־ + * @param[in] UINT16 AcID ID + * @return CI_ERROR + CI_SUCCESS ȷ + * @note + * 1˺ֻܽɾDZOCΧļΣ򷵻ʧ + * 2EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_DeleteACRelEnvelope(UINT8 acBelongFlag,UINT16 AcID); + +/** + * @brief ӹϰ + * @param[in] UINT16 acID + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + * 1˺ʵռްļӹϰ + * 2EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_AddUKTEnvelopeInAC(UINT16 acID); + +/** + * @brief UCTCT + * @param[in] UINT8 Flag Ƿӹ 0xffʱӹϰ磻ʱӹϰ + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return + * @note + * 1ֻгڱOCʱŴʱǰ˽вֻڴ + * 2EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_ClearCTOrUCTEnvelope(UINT8 Flag,UINT16 envelopeID); + +/** + * @brief ɾUCTCT + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_DeleteCTOrUCTEnvelope(UINT16 envelopeID); + +/** + * @brief OC͵İϢ뵽ڴ + * @param[in] UINT8 OCid OC id + * @param[out] + * @return + * @note + * 1˺ֻܽɾDZOCΧļΣ򷵻ʧ + */ +void elm_AddNextOCEnvelopetoBuff(UINT8 OCid); + +/** + * @brief ˢOCΧڵİϢ + * @param[in] + * @param[out] + * @return + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_RefreshNextOCEnvelope(void); + + +/** + * @brief سٹ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_UKTEnvelopeTrack(void); + +/** + * @brief CTٴ + * @note ȫǰ᣺һCT粻һCT磻һCT粻ԽһUCT磻UKTļ᲻ܴCTUCT + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_CTEnvelopeTrack(void); + +/** + * @brief ̬UTٴ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_UCTEnvelopeTrack(void); + +/** + * @brief UCTָ + * @param[in] UINT16 trainid гID + * @param[out] + * @return + * @note + */ +void elm_UCTEnvelopeRecover(UINT16 trainid); + + +/** + * @brief гɸѡ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_TrainScreen(void); + +/** + * @brief ȫɸ + * @param[in] + * @param[out] + * @return + * @note + */ +void elm_WLScreenProcess(void); + + +/** + * @brief ݼռÿ״̬UKT + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_ProcessFreeAC(void); + +/** + * @brief άϢӡ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_MaintenanceInfo(void); + + +/** + * @brief ֪ + * @param[in] UINT8 envelopeType + * @param[in] UINT16 TrainID ID + * @param[in] LOD_STRU startPoint ʼλ + * @param[in] LOD_STRU endPoint ֹλ + * @param[in] UINT16 headTrainID ǰгID + * @param[in] UINT16 tailTrainID гID + * @param[out] EnvelopeStruct *pEnvelope + * @return CI_SUCCESS 紴ȷسɹ + * CI_ERROR 紴ʧܣʧ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_CreateEnveLope(UINT8 envelopeType,UINT16 TrainID, LOD_STRU startPoint,LOD_STRU endPoint,UINT16 headTrainID,UINT16 tailTrainID, \ + INOUT EnvelopeStruct *pEnvelope); + +/** + * @brief ѯ׼ǰİ + * @param[in] const EnvelopeStruct* pEnvelop ׼ + * @param[in] const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] Ƚϵİ + * @param[in] UINT8 envelopeCnt Ƚϵİ + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @param[out] UINT8 *includeCnt İ + * @param[out] UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] İID + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +UINT8 elm_SearchNearestEnvelope(IN const EnvelopeStruct* pEnvelop, IN const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC], UINT8 envelopeCnt, OUT UINT16 *preEnvelope, OUT UINT16 *backEnvelope, OUT UINT8 *includeCnt, OUT UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC]); + + +/** + * @brief ϵİϢ + * @param[in] UINT16 acID + * @param[out] EnvelopeStruct envelopeInfo[] ϵİϢ + * @return 0 ϲڰ + 0СSECTION_REL_ENVELOPE_SUM_MAX ϰ + SECTION_REL_ENVELOPE_SUM_MAXִд + * @note + */ +UINT8 elm_CopyEnvelopeInAC(UINT16 acID,INOUT EnvelopeStruct envelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX]); + + +/** + * @brief ȡڰλ + * @param[in] UINT16 ACid мᣨмΪ緶ΧڵļΣ + * @param[in] const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ + * @param[in] UINT8 newACCnt ռõİ + * @param[out] + * @return UINT8_MAX + ELM_HEAD_AND_TAIL ڰͷڰβ + ELM_HEAD ڰͷ + ELM_TAIL ڰβ + ELM_BODY ڰ + * @note + * 1½2022421 + */ +UINT8 elm_GetACOfEnvelopePos(UINT16 ACid, IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX],UINT8 newACCnt); + + +/** + * @brief ɾлɵİϢ + * @param[in] const EnvelopeStruct* pEnvelop + * @param[in] UINT16 trainid гID + * @param[out] + * @return CI_ERROR ѯʧ + * CI_SUCCESS ѯɹ + * @note + */ +UINT8 elm_ClearHanderOverEnvelope(IN const EnvelopeStruct* pEnvelop,UINT16 trainid); + + +/** + * @brief ȫ + * @param[in] + * @param[out] + * @return + * @note + */ +void elm_SafeProtectProcess(void); + + +/** + * @brief ǷUTռãڼ䲻UTռã + * @param[in] UINT16 ACID ID + * @param[out] + * @return CI_ERROR UTռ + CI_SUCCESS UTռ + * @note + */ +UINT8 elm_CheckACIsUTOcc(UINT16 ACID); + + +/** + * @brief ϰǰ + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return CI_SUCCESS ɹ + * CI_ERROR ʧ + * @note + */ +UINT8 elm_ProcessFaultElmNear(UINT16 envelopeID); + + +/** + * @brief жϰAзǷBзͬ + * @param[in] const EnvelopeStruct* pEnvelopA A + * @param[in] const EnvelopeStruct* pEnvelopB B + * @param[out] + * @return ELM_DIR_SAME ͬ + * ELM_DIR_CONVERT ෴ + Ƿ + * @note ޣĿǰúδǷ仯 + */ +UINT8 elm_DirIsSameELMWithELM(const EnvelopeStruct* pEnvelopA, const EnvelopeStruct* pEnvelopB); + + +/** + * @brief ¼ϵCTϢ + * @param[in] IN const EnvelopeStruct* pEnvelop Ϣ + * @param[in] const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX] ռõİУдӰβָͷ + * @param[in] UINT8 newACCnt ռõİ + * @param[in] UINT8 cutFlag ȡ־λ + * @return CI_SUCCESS ȷسɹ + * CI_ERROR 󣬷ʧ + * @note + * 1½2022421,ֻܸCTʹ + */ +UINT8 elm_RefreshACseqInfoForCT(IN const EnvelopeStruct* pEnvelop,IN const UINT16 newACID[SECTION_IN_ENVELOPE_SUM_MAX],UINT8 newACCnt,UINT8 cutFlag); + + +/** + * @brief ¼ϵUCTϢ + * @param[in] IN const EnvelopeStruct* pEnvelop Ϣ + * @return CI_SUCCESS ȷسɹ + * CI_ERROR 󣬷ʧ + * @note + */ +UINT8 elm_RefreshACseqInfoForUCT(IN const EnvelopeStruct* pEnvelop); + +/** + * @brief UCTᴦ + * @param[in] UINT8 flag 巽ʽ + * @param[in] const EnvelopeStruct* pEnvelope Ϣ + * @param[in] UINT16 acID Id + * @param[out] + * @return CI_SUCCESS ȷسɹ + * CI_ERROR 󣬷ʧ + * @note na + */ +UINT8 elm_UCTEnvelopeLeaveAC(UINT8 flag,IN const EnvelopeStruct* pEnvelope,UINT16 acID); + +/** + * @brief UCT˵ΪĶ˵ + * @param[in] UINT8 headorTail ͷǰβ + * @param[in] UINT16 acId ID + * @param[out] EnvelopeStruct* ptemp ַָ + * @return CI_ERROR + * CI_SUCCESS ȷ + * @note + */ +UINT8 elm_SetUCTEnvelopeDot(UINT8 headorTail,UINT16 acId,IN const EnvelopeStruct* ptemp); + +/** + * @brief ѯڰİָ˵İ + * @param[in] UINT8 flagͷǰβ + * @param[in] const EnvelopeStruct* pBase ׼ + * @param[in] UINT8 includeCnt ڰİ + * @param[in] UINT16 includeELM[TRAIN_SUM_MAX_IN_OC] ڰİid + * @param[out] UINT16 *pEnvelopeid,ҵİID + * @return CI_ERROR ѯʧ + CI_SUCCESSѯȷ + * @note + */ + UINT8 elm_SearchNearstEnvInInclude(UINT8 flag,IN const EnvelopeStruct* pBase,UINT8 includeCnt,UINT16 includeELM[TRAIN_SUM_MAX_IN_OC],OUT UINT16 *pEnvelopeid); + + /** + * @brief ˢег + * @param[in] + * @param[out] + * @return + * @note + */ + void elm_RefreshTrainConstrolStatus(void); + + /** + * @brief жгǷΪ߳ + * @param[in] UINT16 trainID,гID + * @param[in] UINT8 headNeedScreen, Ҫǰɸ־ + * @param[in] UINT8 tailNeedScreen, Ҫβɸ־ + * @param[out] + * @return + * @note ȫǰСȫOCȫɸΪ߳ + */ + void elm_JudgeTrainOffline(UINT16 trainID, UINT8 headNeedScreen,UINT8 tailNeedScreen); + + /** + * @brief ɾUCTCT粻⴦ǰǰ/ + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + */ + UINT8 elm_DeleteCTOrUCTUndoSuspic(UINT16 envelopeID); + + /** + * @brief ȡڵıг + * @param[in] UINT16 envelopeId + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + * @note + * by cgh 20240514 ĿǰֻRRM + */ + UINT8 elm_GetNearEnvelopRelSameTra(UINT16 envelopeId, OUT UINT16* preEnvelope, OUT UINT16* backEnvelope); + + /** + * @brief ѯ׼ǰı + * @param[in] const EnvelopeStruct* pEnvelop ׼ + * @param[in] const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] Ƚϵİ + * @param[in] UINT8 envelopeCnt Ƚϵİ + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @param[out] UINT8 *includeCnt İ + * @param[out] UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] İID + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + 0xffu غϰ + + * @note + * by cgh 20240514 ĿǰֻRRM + */ + UINT8 elm_FindNearSameTrainEnvelop(IN const EnvelopeStruct* pEnvelop, IN const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC], UINT8 envelopeCnt, OUT UINT16* preEnvelope, OUT UINT16* backEnvelope, OUT UINT8* includeCnt, OUT UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC]); + + /** + * @brief C׷BUT + * @param[in] UINT16 envelopeID г + * @param[in] UINT16 wTrainId гID + * @return + * @note by cgh 20240815 + */ + void elm_DealNoCGFollowUt(UINT16 wEnvelopeID, UINT16 wTrainId); + + /** +* @brief ɸѡͨ־ +* @param[in] UINT16 wTrainId гID +* @return +* @note by cgh 20240815 +*/ + void elm_ClearVirScreenPassFlag(UINT16 wTrainId); + + /** +* @brief ɸѡͨ־ල +* @param[in] UINT16 wTrainId гID +* @return +* @note by cgh 20240822 +*/ + void elm_VirScreenPassMonitor(void); + + /** + * @brief ɸѡɾUCTɸѡᲿֺUCT + * @param[in] const EnvelopeStruct* ptemp Ϣָ + * @param[out] + * @return CI_ERROR 0 + * CI_SUCCESS 1 + * @note Created By LQ 2024.07.14 + */ +UINT8 elm_ScreenUctCfpFreeProc(const EnvelopeStruct* ptemp); + +/** +* CTɳ +* ˵ +* ֵ CI_ERROR ڷɳ CI_SUCCESS +* BY fan 20241017 (elm_FlyingProtect𿪽Ӷ) +*/ +UINT8 elm_FlyingProtect_CT(void); + +/** +* UCTɳ +* ˵ +* ֵ +* edit cgh 20241028 +*/ +void elm_FlyingProtect_UCT(void); + +/** +* ɾUCTóͨ־ +* ˵UINT16 envelopeId id +* ֵ +* by cgh 20241028 +*/ +void elm_DeleteUctPassFlag(UINT16 envelopeId); + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManage.c b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManage.c new file mode 100644 index 0000000..1a5bc9b --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManage.c @@ -0,0 +1,1493 @@ +#include "EnvelopeManage.h" + + +/*- ̬ݶ */ +static UINT8 gs_ELMWorkFlag = ELM_WORK_ERROR; /** ־*/ +static EnvelopeStruct gs_arEnvelope[ENVELOPE_SUM_MAX] = {0u}; /*洢ռ*/ +static EnvelopeMapStruct gs_arACRelEnvelopeMap[AXIS_SECTION_SUM_MAX] = {0u}; /*İӳ*/ +static TrainMapStruct gs_arTrainRelEnvelopeMap[LINE_MAX_TRAIN] = {0u}; /*гIDתгİӳ*/ + +/** + * @brief ҪĿڴǷڿڴ + * @param[in] MemAreaStruct targetArea ҪĿڴ + * @param[in] MemAreaStruct valiArea ڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ҪĿڴȫڿڴʱΪϷ + ڴһҿ + Ŀڴõһҿ + */ +UINT8 elm_IsMemAreaOK(MemAreaStruct targetArea,MemAreaStruct valiArea) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; /*ֵ*/ + + /** жڴǷڿڴ */ + if ((targetArea.pStartVaild >= valiArea.pStartVaild) && + (targetArea.pStartVaild <= targetArea.pEndVaild) && + (targetArea.pEndVaild <= valiArea.pEndVaild)) + { + /** ڴڿڴڣ÷ֵΪȷ */ + ret = CI_SUCCESS; + } + else + { + /** ڴڿڴڣش */ + } + + /** غִн*/ + return ret; +} + +/** + * @brief ڴǷȷ + * @param[in] EnvelopeStruct *pEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ַָͨСҪİڴǷڿõĵַռ + */ +UINT8 elm_IsEnvelopeMemOK(IN EnvelopeStruct *pEnvelope, UINT16 size) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + MemAreaStruct valiArea = {0u}; /*ڴ*/ + MemAreaStruct targetArea = {0u}; /*Ŀڴ*/ + + /** жڲǷȷ */ + if (NULL == pEnvelope) + { + /** ڲ󣬷ش*/ + } + else + { + /*- ÿõַռ */ + valiArea.pStartVaild = &gs_arEnvelope[0]; + valiArea.pEndVaild = &gs_arEnvelope[ENVELOPE_SUM_MAX]; + + /*- Ŀڴռ*/ + targetArea.pStartVaild = pEnvelope; + targetArea.pEndVaild = pEnvelope + size; + + /*- ڴϷԼ*/ + ret = elm_IsMemAreaOK(targetArea,valiArea); + } + + /** غִн*/ + return ret; + +} + +/** + * @brief İӳڴǷȷ + * @param[in] EnvelopeMapStruct *pRelEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ַָͨСҪİڴǷڿõĵַռ + */ +UINT8 elm_IsACRelEnvelopeMapMemOK(IN EnvelopeMapStruct *pRelEnvelope, UINT16 size) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + MemAreaStruct valiArea = {0u}; /*ڴ*/ + MemAreaStruct targetArea = {0u}; /*Ŀڴ*/ + + /** жڲǷȷ */ + if (NULL == pRelEnvelope) + { + /** ڲ󣬷ش*/ + } + else + { + /*- ÿõַռ */ + valiArea.pStartVaild = &gs_arACRelEnvelopeMap[0]; + valiArea.pEndVaild = &gs_arACRelEnvelopeMap[AXIS_SECTION_SUM_MAX]; + + /*- Ŀڴռ*/ + targetArea.pStartVaild = pRelEnvelope; + targetArea.pEndVaild = pRelEnvelope + size; + + /*- ڴϷԼ*/ + ret = elm_IsMemAreaOK(targetArea,valiArea); + } + + /** غִн*/ + return ret; + +} + + +/** + * @brief İӳڴǷȷ + * @param[in] TrainMapStruct *pRelEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ַָͨСҪİڴǷڿõĵַռ + */ +UINT8 elm_IsTrainRelEnvelopeMapMemOK(IN TrainMapStruct *pRelEnvelope, UINT16 size) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + MemAreaStruct valiArea = {0u}; /*ڴ*/ + MemAreaStruct targetArea = {0u}; /*Ŀڴ*/ + + /** жڲǷȷ */ + if (NULL == pRelEnvelope) + { + /** ڲ󣬷ش*/ + } + else + { + /*- ÿõַռ */ + valiArea.pStartVaild = &gs_arTrainRelEnvelopeMap[0]; + valiArea.pEndVaild = &gs_arTrainRelEnvelopeMap[LINE_MAX_TRAIN]; + + /*- Ŀڴռ*/ + targetArea.pStartVaild = pRelEnvelope; + targetArea.pEndVaild = pRelEnvelope + size; + + /*- ڴϷԼ*/ + ret = elm_IsMemAreaOK(targetArea,valiArea); + } + + /** غִн*/ + return ret; + +} + +/** + * @brief жǷȷ + * @param[in] UINT16 EnvelopeID ID + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS IDϷسɹ + * CI_ERROR IDǷʧ + * @note + */ +UINT8 elm_IsEnvelopeIDOK(UINT16 EnvelopeID) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; /*ֵ*/ + + /** жϰIDǷϷ*/ + if ((ENVELOPE_UNVAILD_INDEX != EnvelopeID) && (EnvelopeID < ENVELOPE_SUM_MAX)) + { + /** IDϷ÷ֵΪɹ*/ + ret = CI_SUCCESS; + } + else + { + /** IDϷ*/ + } + return ret; +} + +/** + * @brief жϰǷ + * @param[in] UINT16 EnvelopeID ID + * @return ENVELOPE_UNEXIT 粻 + * ENVELOPE_EXIT + * @note ͨжϰ洢ռǷռãжϰǷ + */ +UINT8 elm_IsEnvelopeExit(UINT16 EnvelopeID) +{ + /*- ֲ */ + UINT8 ret = ENVELOPE_UNEXIT; /*ֵ*/ + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(EnvelopeID); + + /*- IDȷ򷵻ذռǷڱʶ*/ + if (CI_SUCCESS == funRet) + { + ret = gs_arEnvelope[EnvelopeID].exitFlag; + } + else + { + /**/ + } + + return ret; +} + +/** + * @brief жϰϢǷȷ + * @param[in] const EnvelopeMapStruct *pRelEnvelope Ϣ + * @param[in] UINT16 EnvelopeID ID + * @return CI_SUCCESS IDϷسɹ + * CI_ERROR IDǷʧ + * @note + */ +UINT8 elm_IsEnvelopeInfoOk(IN const EnvelopeStruct *pEnvelope,UINT16 EnvelopeID) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + + /** жڲǷȷ*/ + if (NULL == pEnvelope) + { + /** ָǷ*/ + } + else + { + /** жϰϢǷϷ */ + if ((pEnvelope->id == EnvelopeID) && + ((TYPE_UKT_ENVELOPE == pEnvelope->envelopeType) || (TYPE_UCT_ENVELOPE == pEnvelope->envelopeType) || (TYPE_CT_ENVELOPE == pEnvelope->envelopeType)) && + (pEnvelope->ACCnt > 0u)) + { + /** Ϸ÷ֵΪȷ*/ + ret = CI_SUCCESS; + } + else + { + /** Ƿ÷ֵΪ*/ + ret = CI_ERROR; + } + } + + /** */ + return ret; +} + + +/** + * @brief ð洢ռ + * @param[in] EnvelopeStruct *pEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_ResetEnvelope(INOUT EnvelopeStruct *pEnvelope, UINT16 size) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + + /*- ָǷϷ */ + ret = elm_IsEnvelopeMemOK(pEnvelope,size); + + /** жǷԽгʼ*/ + if (CI_SUCCESS == ret) + { + /** ʼӦڴΪ0*/ + (void)CommonMemSet(pEnvelope, (UINT32)(sizeof(EnvelopeStruct)*size),0u, (UINT32)(sizeof(EnvelopeStruct)*size)); + ret = CI_SUCCESS; + } + else + { + /** ڴǷд*/ + } + + /** غִн*/ + return ret; +} + +/** + * @brief üİӳ + * @param[in] EnvelopeMapStruct *pEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_ResetACRelEnvelopeMap(INOUT EnvelopeMapStruct *pRelEnvelopeMap, UINT16 size) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + + /*- ָǷϷ */ + ret = elm_IsACRelEnvelopeMapMemOK(pRelEnvelopeMap,size); + + /** жǷԽгʼ*/ + if (CI_SUCCESS == ret) + { + /** ʼӦڴΪ0*/ + (void)CommonMemSet(pRelEnvelopeMap, (UINT32)(sizeof(EnvelopeMapStruct)*size),0u, (UINT32)(sizeof(EnvelopeMapStruct)*size)); + ret = CI_SUCCESS; + } + else + { + /** ڴǷд*/ + } + + /** غִн*/ + return ret; +} + +/** + * @brief гİӳ + * @param[in] UINT16 *pEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_ResetTrainRelEnvelopeMap(INOUT TrainMapStruct *pRelEnvelopeMap, UINT16 size) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + + /*- ָǷϷ */ + ret = elm_IsTrainRelEnvelopeMapMemOK(pRelEnvelopeMap,size); + + /** жǷԽгʼ*/ + if (CI_SUCCESS == ret) + { + /** ʼгIDתгİӳ*/ + (void)CommonMemSet(pRelEnvelopeMap, (UINT32)(sizeof(TrainMapStruct)*size),0u, (UINT32)(sizeof(TrainMapStruct)*size)); + ret = CI_SUCCESS; + } + else + { + /** ڴǷд*/ + } + + /** غִн*/ + return ret; +} + + +/** + * @brief ʼ洢ռ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_InitEnvelope(void) +{ + return elm_ResetEnvelope(&gs_arEnvelope[0],ENVELOPE_SUM_MAX); +} + +/** + * @brief ʼİӳ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_InitACRelEnvelopeMap(void) +{ + return elm_ResetACRelEnvelopeMap(&gs_arACRelEnvelopeMap[0],AXIS_SECTION_SUM_MAX); +} + +/** + * @brief ʼгİӳ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_InitTrainRelEnvelopeMap(void) +{ + return elm_ResetTrainRelEnvelopeMap(&gs_arTrainRelEnvelopeMap[0],LINE_MAX_TRAIN); +} + + +/** + * @brief ðģǷ + * @param[in] UINT8 workFlag + * @note + */ +void elm_SetELMWorkFlag(UINT8 workFlag) +{ + if (ELM_WORK_OK == workFlag) + { + gs_ELMWorkFlag = workFlag; + } + else + { + gs_ELMWorkFlag = ELM_WORK_ERROR; + } + +} + + + +/** + * @brief ð洢ռñʶ + * @param[in] UINT16 index ± + * @param[in] UINT8 value Ҫõֵ + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeValidFlag(UINT16 index,UINT8 value) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; /*ֵ*/ + + + /**ڲϷУ*/ + if ((0u != index) && (index < ENVELOPE_SUM_MAX) && + ((ENVELOPE_UNEXIT == value) || (ENVELOPE_EXIT == value))) + { + /** ð洢ռ */ + gs_arEnvelope[index].exitFlag = value; + ret = CI_SUCCESS; + } + else + { + /** ڲУʧܣ*/ + } + return ret; +} + + +/** + * @brief ¼ιİ + * @param[in] UINT8 flag ʶ + * @param[in] UINT16 buffIndex + * @param[in] UINT16 envelopeID ID + * @return CI_SUCCESS ɾɹسɹ + * CI_ERROR ɾ󣬷ʧ + * @note IDʹ洢ռһ + ӳ䵽洢ռ䣬ʹüε + */ +UINT8 elm_SetACRelEnvelopeMap(UINT8 flag,UINT16 ACIndex,UINT16 envelopeID) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 continueCycle = 0u; + UINT16 tempEnvelopeID = 0u; + + /** ڲУ */ + if (((OP_ADD != flag) && (OP_DEL != flag)) || + (ACIndex >= AXIS_SECTION_SUM_MAX)) + { + /** ڲ󣬷ش*/ + } + else + { + if (OP_ADD == flag) + { + /** ϴڰ򲻸*/ + for (cycle = 0u; cycle < gs_arACRelEnvelopeMap[ACIndex].envelopeCnt;cycle++) + { + tempEnvelopeID = gs_arACRelEnvelopeMap[ACIndex].envelopeId[cycle]; + if (tempEnvelopeID == envelopeID) + { + break; + } + } + + if ((cycle == gs_arACRelEnvelopeMap[ACIndex].envelopeCnt) && (gs_arACRelEnvelopeMap[ACIndex].envelopeCnt < (SECTION_REL_ENVELOPE_SUM_MAX - 1u))) + { + gs_arACRelEnvelopeMap[ACIndex].envelopeId[cycle] = envelopeID; + gs_arACRelEnvelopeMap[ACIndex].envelopeCnt++; + } + else + { + /** 账*/ + } + ret = CI_SUCCESS; + } + else + { + /** ϴڰ򲻸*/ + for (cycle = 0u; cycle < gs_arACRelEnvelopeMap[ACIndex].envelopeCnt;cycle++) + { + tempEnvelopeID = gs_arACRelEnvelopeMap[ACIndex].envelopeId[cycle]; + if (tempEnvelopeID == envelopeID) + { + gs_arACRelEnvelopeMap[ACIndex].envelopeId[cycle] = 0u; + break; + } + } + + /** Ų*/ + if (cycle == gs_arACRelEnvelopeMap[ACIndex].envelopeCnt) + { + /** ϲҪɾУ*/; + } + else if (cycle == (gs_arACRelEnvelopeMap[ACIndex].envelopeCnt - 1u)) + { + /** Ų,1*/ + gs_arACRelEnvelopeMap[ACIndex].envelopeCnt--; + ret = CI_SUCCESS; + } + else + { + /** Ų*/ + for (continueCycle = cycle; continueCycle < (gs_arACRelEnvelopeMap[ACIndex].envelopeCnt - 1u); continueCycle++) + { + gs_arACRelEnvelopeMap[ACIndex].envelopeId[continueCycle] = gs_arACRelEnvelopeMap[ACIndex].envelopeId[continueCycle + 1U]; + } + + /** 1*/ + gs_arACRelEnvelopeMap[ACIndex].envelopeCnt--; + ret = CI_SUCCESS; + } + } + } + return ret; +} + +/** + * @brief гİ + * @param[in] UINT16 trainID гID + * @param[in] UINT16 envelopeID ID + * @return CI_SUCCESS ɾɹسɹ + * CI_ERROR ɾ󣬷ʧ + * @note + */ +UINT8 elm_SetTrainRelEnvelopeMap(UINT8 flag,UINT16 trainID,UINT16 envelopeID) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 continueCycle = 0u; + UINT16 tempEnvelopeID = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE((OP_ADD != flag) && (OP_DEL != flag),ret,0x80000000u); + ASSERT_RET_VALUE((0u == trainID) || (trainID >= LINE_MAX_TRAIN),ret,0x40000000u); + ASSERT_RET_VALUE(ENVELOPE_UNVAILD_INDEX == envelopeID,ret,0x20000000u); + + if (OP_ADD == flag) + { + /** ϴڰ򲻸*/ + for (cycle = 0u; cycle < gs_arTrainRelEnvelopeMap[trainID].envelopeCnt;cycle++) + { + tempEnvelopeID = gs_arTrainRelEnvelopeMap[trainID].envelopeId[cycle]; + if (tempEnvelopeID == envelopeID) + { + break; + } + } + + if ((cycle == gs_arTrainRelEnvelopeMap[trainID].envelopeCnt) && (gs_arTrainRelEnvelopeMap[trainID].envelopeCnt < (TRAIN_REL_ENVELOPE_SUM_MAX - 1u))) + { + gs_arTrainRelEnvelopeMap[trainID].envelopeId[cycle] = envelopeID; + gs_arTrainRelEnvelopeMap[trainID].envelopeCnt++; + ret = CI_SUCCESS; + } + else + { + /** 账*/ + } + } + else + { + /** ϴڰ򲻸*/ + for (cycle = 0u; cycle < gs_arTrainRelEnvelopeMap[trainID].envelopeCnt;cycle++) + { + tempEnvelopeID = gs_arTrainRelEnvelopeMap[trainID].envelopeId[cycle]; + if (tempEnvelopeID == envelopeID) + { + gs_arTrainRelEnvelopeMap[trainID].envelopeId[cycle] = 0u; + break; + } + } + + /** Ų*/ + if (cycle == gs_arTrainRelEnvelopeMap[trainID].envelopeCnt) + { + /** ϲҪɾУ*/; + } + else if (cycle == (gs_arTrainRelEnvelopeMap[trainID].envelopeCnt - 1u)) + { + /** Ų,1*/ + gs_arTrainRelEnvelopeMap[trainID].envelopeCnt--; + ret = CI_SUCCESS; + } + else + { + /** Ų*/ + for (continueCycle = cycle; continueCycle < (gs_arTrainRelEnvelopeMap[trainID].envelopeCnt - 1u); continueCycle++) + { + gs_arTrainRelEnvelopeMap[trainID].envelopeId[continueCycle] = gs_arTrainRelEnvelopeMap[trainID].envelopeId[continueCycle + 1U]; + } + + /** 1*/ + gs_arTrainRelEnvelopeMap[trainID].envelopeCnt--; + ret = CI_SUCCESS; + } + } + + /** */ + return ret; +} + +/** + * @brief ָռϴ洢 + * @param[in] const EnvelopeStruct *pSrcEnnelope Ҫ洢İַ + * @param[in] UINT16 index Ҫ洢Ŀڴ + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeByIndex(IN const EnvelopeStruct *pSrcEnnelope,UINT16 index) +{ + UINT8 ret = CI_ERROR; + + /** Ƿȷ */ + ret = elm_IsEnvelopeIDOK(index); + + /** жڲǷȷ */ + if ((NULL == pSrcEnnelope) || (CI_ERROR == ret)) + { + /** ڲУʧ */ + } + else + { + /** ڴ */ + ret = CommonMemCpy(&gs_arEnvelope[index], (UINT32)sizeof(EnvelopeStruct),pSrcEnnelope, (UINT32)sizeof(EnvelopeStruct)); + + if (CI_SUCCESS == ret) + { + /** ðռ䱻ʹ */ + ret = elm_SetEnvelopeValidFlag(index,ENVELOPE_EXIT); + } + } + return ret; +} + + +/** + * @brief ðյλ + * @param[in] UINT16 envelopid ID + * @param[in] LOD_STRU startPoint λ + * @param[in] LOD_STRU endPoint յλ + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeLoc(UINT16 envelopid,LOD_STRU startPoint,LOD_STRU endPoint) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(envelopid); + + if ((CI_SUCCESS == funRet) && (gs_arEnvelope[envelopid].id == envelopid)) + { + gs_arEnvelope[envelopid].startPos = startPoint; + gs_arEnvelope[envelopid].endPos = endPoint; + ret = CI_SUCCESS; + } + else + { + /** ڲȷ*/ + } + return ret; +} + +/** + * @brief ð㷽 + * @param[in] UINT16 envelopid ID + * @param[in] UINT8 cStartDir 㷽 + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + */ +UINT8 elm_SetEnvelopeStartDir(UINT16 envelopid, UINT8 cStartDir) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(envelopid); + + if ((CI_SUCCESS == funRet) && (gs_arEnvelope[envelopid].id == envelopid) + && ((EMAP_SAME_DIR == cStartDir) || (EMAP_CONVER_DIR == cStartDir))) + { + gs_arEnvelope[envelopid].startPos.Dir = cStartDir; + ret = CI_SUCCESS; + } + else + { + /** ڲȷ*/ + } + + return ret; +} + +/** + * @brief ðյ㷽 + * @param[in] UINT16 envelopid ID + * @param[in] UINT8 cEndDir յ㷽 + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + */ +UINT8 elm_SetEnvelopeEndDir(UINT16 envelopid, UINT8 cEndDir) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(envelopid); + + if ((CI_SUCCESS == funRet) && (gs_arEnvelope[envelopid].id == envelopid) + && ((EMAP_SAME_DIR == cEndDir) || (EMAP_CONVER_DIR == cEndDir))) + { + gs_arEnvelope[envelopid].endPos.Dir = cEndDir; + ret = CI_SUCCESS; + } + else + { + /** ڲȷ*/ + } + + return ret; +} + +/** + * @brief ðļϢ + * @param[in] UINT16 envelopid ID + * @param[in] LOD_STRU startPoint λ + * @param[in] LOD_STRU endPoint յλ + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeACInfo(UINT16 envelopid,UINT8 acCnt,IN const UINT16 acID[SECTION_IN_ENVELOPE_SUM_MAX]) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(envelopid); + + /** жǷϢ*/ + if ((CI_SUCCESS == funRet) && (gs_arEnvelope[envelopid].id == envelopid)) + { + /*- ¼Ϣ */ + (void)CommonMemSet(gs_arEnvelope[envelopid].ACID, (UINT32)(sizeof(UINT16) * gs_arEnvelope[envelopid].ACCnt), 0u , (UINT32)(sizeof(UINT16) * gs_arEnvelope[envelopid].ACCnt)); + (void)CommonMemCpy(gs_arEnvelope[envelopid].ACID, (UINT32)(sizeof(UINT16) * SECTION_IN_ENVELOPE_SUM_MAX) , acID , (UINT32)(sizeof(UINT16) * acCnt)); + gs_arEnvelope[envelopid].ACCnt = acCnt; + ret = CI_SUCCESS; + } + else + { + /** ڲ */ + } + return ret; +} + + +/** + * @brief ðǰг + * @param[in] INT16 envelopid id + * @param[in] UINT16 tainid гid + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeHeadTrainID(UINT16 envelopid,UINT16 tainid) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(envelopid); + + /** жǷϢ*/ + if ((CI_SUCCESS == funRet) && (gs_arEnvelope[envelopid].id == envelopid)) + { + gs_arEnvelope[envelopid].headTrainID = tainid; + ret = CI_SUCCESS; + } + else + { + /** ڲ */ + } + return ret; +} + +/** + * @brief ðг + * @param[in] INT16 envelopid id + * @param[in] UINT16 tainid гid + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeTailTrainID(UINT16 envelopid,UINT16 tainid) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(envelopid); + + /** жǷϢ*/ + if ((CI_SUCCESS == funRet) && (gs_arEnvelope[envelopid].id == envelopid)) + { + gs_arEnvelope[envelopid].tailTrainID = tainid; + ret = CI_SUCCESS; + } + else + { + /** ڲ */ + } + return ret; +} + + +/** + * @brief ð + * @param[in] UINT16 envelopeId id + * @param[in] UINT8 envelopType + * @param[out] + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeType(UINT16 envelopeId,UINT8 envelopType) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(envelopeId); + + /** ڲУ */ + ASSERT_RET_VALUE(CI_ERROR == funRet,ret,0x80000000u); + ASSERT_RET_VALUE((TYPE_UKT_ENVELOPE != envelopType) && (TYPE_UCT_ENVELOPE != envelopType) && (TYPE_CT_ENVELOPE != envelopType),ret,0x40000000u); + + + /** ð */ + gs_arEnvelope[envelopeId].envelopeType = envelopType; + ret = CI_SUCCESS; + + return ret; +} + +/** + * @brief ðģǷ + * @return ELM_WORK_ERROR + ELM_WORK_OK + * @note + */ +UINT8 elm_GetELMWorkFlag(void) +{ + return gs_ELMWorkFlag; +} + + +/** + * @brief ȡõĴ洢ռ± + * @param[in] + * @param[out] + * @return ENVELOPE_UNVAILD_INDEX ޿õĴ洢ռ± + ENVELOPE_UNVAILD_INDEX ϷĿõ 洢ռ± + * @note + */ +UINT16 elm_GetEnvelopeValidIndex(void) +{ + /*- ֲ*/ + UINT16 ret = ENVELOPE_UNVAILD_INDEX; /** */ + UINT16 cycle = 0u; + + /** ҿõĿռ*/ + for (cycle = 1u; cycle < ENVELOPE_SUM_MAX;cycle++) + { + /**жϿռǷ*/ + if (ENVELOPE_UNEXIT == gs_arEnvelope[cycle].exitFlag) + { + /**ռãؿÿռ˳ѭ*/ + ret = cycle; + break; + } + else + { + /**һõĿռ*/ + } + } + + return ret; +} + +/** + * @brief гIDİϢӳַ + * @param[in] UINT16 trainID гID + * @return İַ + * @note 󣬷NULL + */ +const TrainMapStruct * elm_GetTrainRelEnvelopeMapPtr(UINT16 trainID) +{ + const TrainMapStruct * ret = NULL; + + /** ڲУ */ + ASSERT_RET_VALUE((0u == trainID) || (trainID >= LINE_MAX_TRAIN),ret,0x80000000u); + + ret = &gs_arTrainRelEnvelopeMap[trainID]; + return ret; +} + + +/** + * @brief ȡгIDİϢ + * @param[in] UINT16 trainID гID + * @param[out] UINT16 envelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] İID + * @return İ + * @note 󣬷TRAIN_REL_ENVELOPE_SUM_MAX + */ +UINT8 elm_GetRelELIdByTrainID(UINT16 trainID, UINT16 envelopeID[TRAIN_REL_ENVELOPE_SUM_MAX]) +{ + UINT8 ret = TRAIN_REL_ENVELOPE_SUM_MAX; + UINT8 cycle = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE((0u == trainID) || (trainID >= LINE_MAX_TRAIN),ret,0x80000000u); + ASSERT_RET_VALUE(NULL == envelopeID,ret,0x40000000u); + ASSERT_RET_VALUE(TRAIN_REL_ENVELOPE_SUM_MAX <= gs_arTrainRelEnvelopeMap[trainID].envelopeCnt,ret,0x10000000u); + + for (cycle = 0u; cycle < gs_arTrainRelEnvelopeMap[trainID].envelopeCnt;cycle++) + { + envelopeID[cycle] = gs_arTrainRelEnvelopeMap[trainID].envelopeId[cycle]; + } + ret = gs_arTrainRelEnvelopeMap[trainID].envelopeCnt; + return ret; +} + +/** + * @brief ȡгIDĶӦ͵İϢ + * @param[in] UINT8 envelopeType + * @param[in] UINT16 trainID гID + * @param[out] UINT16 envelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] İID + * @return İ + * @note 󣬷TRAIN_REL_ENVELOPE_SUM_MAX + */ +UINT8 elm_GetRelELIdByTrainIDAndType(UINT8 envelopeType, UINT16 trainID, UINT16 envelopeID[TRAIN_REL_ENVELOPE_SUM_MAX]) +{ + UINT8 ret = TRAIN_REL_ENVELOPE_SUM_MAX; + UINT8 cycle = 0u; + UINT8 sucFlag = 0u; + UINT8 elmCnt = 0u; + const EnvelopeStruct *pTemp = NULL; + + /** ڲУ */ + ASSERT_RET_VALUE((0u == trainID) || (trainID >= LINE_MAX_TRAIN),ret,0x80000000u); + ASSERT_RET_VALUE((TYPE_CT_ENVELOPE != envelopeType) && (TYPE_UCT_ENVELOPE != envelopeType),ret,0x40000000u); + ASSERT_RET_VALUE(NULL == envelopeID,ret,0x20000000u); + ASSERT_RET_VALUE(TRAIN_REL_ENVELOPE_SUM_MAX <= gs_arTrainRelEnvelopeMap[trainID].envelopeCnt,ret,0x10000000u); + + /** */ + for (cycle = 0u; cycle < TRAIN_REL_ENVELOPE_SUM_MAX; cycle++) + { + envelopeID[cycle] = ENVELOPE_UNVAILD_INDEX; + } + + /*- ѯİID */ + for (cycle = 0u; cycle < gs_arTrainRelEnvelopeMap[trainID].envelopeCnt;cycle++) + { + pTemp = elm_GetEnvelopeInfoPtr(gs_arTrainRelEnvelopeMap[trainID].envelopeId[cycle]); + + if (NULL == pTemp) + { + /** гİIDмһЧİID */ + break; + } + else if (pTemp->envelopeType == envelopeType) + { + /** ¼гİ*/ + envelopeID[elmCnt] = gs_arTrainRelEnvelopeMap[trainID].envelopeId[cycle]; + elmCnt++; + } + else + { + /** ЧİIDϰͣ */ + sucFlag = 1u; + } + } + + /** ֵ */ + if (cycle == gs_arTrainRelEnvelopeMap[trainID].envelopeCnt) + { + if (TYPE_CT_ENVELOPE == envelopeType) + { + if ((0u == sucFlag) && ((0u == elmCnt) || (1u == elmCnt))) + { + ret = elmCnt; + } + else + { + /** ˵ͨųUCT */ + ret = TRAIN_REL_ENVELOPE_SUM_MAX; + } + } + else + { + ret = elmCnt; + } + } + else + { + /** ʧ */ + for (cycle = 0u; cycle < TRAIN_REL_ENVELOPE_SUM_MAX;cycle++) + { + envelopeID[cycle] = ENVELOPE_UNVAILD_INDEX; + } + ret = TRAIN_REL_ENVELOPE_SUM_MAX; + } + + return ret; +} + +/** + * @brief ȡİͰID + * @param[in] UINT16 ACIndex + * @param[out] UINT16 envelopeId[SECTION_REL_ENVELOPE_SUM_MAX] İID + * @return İ + * @note 󣬷SECTION_REL_ENVELOPE_SUM_MAX + * bug 20220420 wqm ӳ޼ + */ +UINT8 elm_GetACRelEnvelopeCnt(UINT16 ACIndex,INOUT UINT16 envelopeId[SECTION_REL_ENVELOPE_SUM_MAX]) +{ + /*- ֲ */ + UINT8 ret = SECTION_REL_ENVELOPE_SUM_MAX; + + if ((0U == ACIndex) || ( AXIS_SECTION_SUM_MAX<=ACIndex) || (NULL == envelopeId)) + { + /** ڲ */ + } + else + { + /* bug 20220420 wqm ӳ޼*/ + /** жϰǷ*/ + if (SECTION_REL_ENVELOPE_SUM_MAX < gs_arACRelEnvelopeMap[ACIndex].envelopeCnt) + { + /** ʱҲӦÿСİIDշ*/ + (void)CommonMemSet(&envelopeId[0], (UINT32)(sizeof(UINT16) * SECTION_REL_ENVELOPE_SUM_MAX), 0u, (UINT32)(sizeof(UINT16) * SECTION_REL_ENVELOPE_SUM_MAX)); + + /** ID */ + (void)CommonMemCpy(&envelopeId[0], (UINT32)(sizeof(UINT16) * SECTION_REL_ENVELOPE_SUM_MAX), \ + &gs_arACRelEnvelopeMap[ACIndex].envelopeId[0], (UINT32)(sizeof(UINT16) * SECTION_REL_ENVELOPE_SUM_MAX)); + + /** شʧ*/ + ret = SECTION_REL_ENVELOPE_SUM_MAX; + + } + /** жǷڰ */ + else if (0u != gs_arACRelEnvelopeMap[ACIndex].envelopeCnt) + { + /** շ*/ + (void)CommonMemSet(&envelopeId[0], (UINT32)(sizeof(UINT16) * SECTION_REL_ENVELOPE_SUM_MAX), 0u , (UINT32)(sizeof(UINT16) * SECTION_REL_ENVELOPE_SUM_MAX)); + + /** ID */ + (void)CommonMemCpy(&envelopeId[0], (UINT32)(sizeof(UINT16) * gs_arACRelEnvelopeMap[ACIndex].envelopeCnt), \ + &gs_arACRelEnvelopeMap[ACIndex].envelopeId[0], (UINT32)(sizeof(UINT16) * gs_arACRelEnvelopeMap[ACIndex].envelopeCnt)); + + /** ÷ֵ*/ + ret = gs_arACRelEnvelopeMap[ACIndex].envelopeCnt; + + } + else + { + /** 追÷ֵ */ + ret = gs_arACRelEnvelopeMap[ACIndex].envelopeCnt; + } + + } + + /** */ + return ret; +} + + + +/** + * @brief ͨIDȡϢ + * @param[in] UINT16 envelopeId ID + * @return Ϣ洢ַ + * @note IDͰһ£ָֻʹãָͨ޸ĶӦֵ + ˺޷ʵֳڲΨһ߲鱣֤û ͨע򲻷 + */ +const EnvelopeStruct* elm_GetEnvelopeInfoPtr(UINT16 envelopeId) +{ + /*- ֲ */ + UINT8 funRet = ENVELOPE_UNEXIT; + const EnvelopeStruct* ret = NULL; + + /** жϰǷ */ + funRet = elm_IsEnvelopeExit(envelopeId); + + if (ENVELOPE_UNEXIT == funRet) + { + ret = NULL; + } + else + { + funRet = elm_IsEnvelopeInfoOk(&gs_arEnvelope[envelopeId], envelopeId); + + if (CI_ERROR == funRet) + { + ret = NULL; + } + else + { + ret = &gs_arEnvelope[envelopeId]; + } + } + return ret; +} + + + +/** + * @brief ָ + * @param[in] UINT16 envelopeId ID + * @return CI_SUCCESS ɹ + * CI_ERROR + * @note + */ +UINT8 elm_ClearEnvelope(UINT16 envelopeId) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT8 funRet = CI_ERROR; + + /** жϰIDǷȷ */ + funRet = elm_IsEnvelopeIDOK(envelopeId); + + if (CI_SUCCESS == funRet) + { + ret = elm_ResetEnvelope(&gs_arEnvelope[envelopeId], 1u); + } + else + { + /** ڲ*/ + } + return ret; +} + + +/** + * @brief гID뵽г + * @param[in] UINT8 flag ջͷջβ + * @param[in] UINT8 trainId гID + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return + * @note + */ +UINT8 elm_PushToTrainSeq(UINT8 flag,UINT16 envelopeID,UINT16 trainId) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + const EnvelopeStruct* pTempconst = NULL; /* IDĺϷж */ + EnvelopeStruct* pTemp = NULL; /* ָ洢ַ */ + + pTempconst = elm_GetEnvelopeInfoPtr(envelopeID); + + /** ڲ */ + ASSERT_RET_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag),ret,0x80000000u); + ASSERT_RET_VALUE(NULL == pTempconst,ret,0x40000000u); + ASSERT_RET_VALUE((0u == trainId) || (trainId > LINE_MAX_TRAIN),ret,0x20000000u); /** пԴӰسID */ + + /** ȡĵַ */ + pTemp = &gs_arEnvelope[envelopeID]; + + if ((NULL != pTemp ) && (pTemp->trianCnt < (TRAIN_IN_ENVELOPE_SUM_MAX - 1u))) + { + if (ELM_HEAD == flag) + { + pTemp->trainID[pTemp->trianCnt] = trainId; + pTemp->trianCnt++; + } + else + { + /** Ų */ + for (cycle = pTemp->trianCnt; 0u != cycle; cycle--) + { + pTemp->trainID[cycle] = pTemp->trainID[cycle - 1u]; + } + pTemp->trainID[0u] = trainId; + pTemp->trianCnt++; + } + ret = CI_SUCCESS; + } + else + { + /** ַռ䲻ԣռ䲻*/ + } + + return ret; +} + +/** + * @brief гɾгID + * @param[in] UINT16 envelopeID ID + * @param[in] UINT8 trainId гID + * @param[out] + * @return + * @note + */ +UINT8 elm_DeleteTrainFromSeq(UINT16 envelopeID,UINT16 trainId) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 index = 0u; + UINT8 trainCnt = 0u; + const EnvelopeStruct* pTempconst = NULL; /* IDĺϷж */ + EnvelopeStruct* pTemp = NULL; /* ָ洢ַ */ + + pTempconst = elm_GetEnvelopeInfoPtr(envelopeID); + + /** ڲ */ + ASSERT_RET_VALUE(NULL == pTempconst,ret,0x80000000u); + ASSERT_RET_VALUE((0u == trainId) || (trainId > LINE_MAX_TRAIN),ret,0x40000000u); /** пԴӰسID */ + + /** ȡĵַ */ + pTemp = &gs_arEnvelope[envelopeID]; + + /** ȡ */ + trainCnt = pTemp->trianCnt; + + /** ɾID */ + for (cycle = 0; cycle < trainCnt;cycle++) + { + if (pTemp->trainID[cycle] == trainId) + { + pTemp->trainID[cycle] = 0u; + pTemp->trianCnt--; + break; + } + else + { + /** ɾ */ + } + } + + /** ƶ */ + for (cycle = 0; cycle < trainCnt;cycle++) + { + if (0u == pTemp->trainID[cycle]) + { + /** */ + } + else + { + pTemp->trainID[index] = pTemp->trainID[cycle]; + /** ַƫ */ + index++; + } + } + + ret = CI_SUCCESS; + return ret; +} + + +/** + * @brief ļջнͷβ + * @param[in] UINT8 flag ջͷջβе + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return CI_SUCCESS ɹ + * CI_ERROR + * @note + */ +UINT8 elm_PopEnvelopACSeq(UINT8 flag, UINT16 envelopeID) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 acCnt = 0u; + UINT8 funRet = ENVELOPE_UNEXIT; + + /** ڲУ */ + ASSERT_RET_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag),ret,0x80000000u); + + /** жϰǷ */ + funRet = elm_IsEnvelopeExit(envelopeID); + + if ((ENVELOPE_EXIT == funRet) && (0u < gs_arEnvelope[envelopeID].ACCnt) && (gs_arEnvelope[envelopeID].ACCnt < (SECTION_IN_ENVELOPE_SUM_MAX - 1u))) + { + if (ELM_HEAD == flag) + { + acCnt = gs_arEnvelope[envelopeID].ACCnt; + gs_arEnvelope[envelopeID].ACID[acCnt-1u] = 0u; + gs_arEnvelope[envelopeID].ACCnt--; + } + else + { + gs_arEnvelope[envelopeID].ACID[0u] = 0u; + gs_arEnvelope[envelopeID].ACCnt--; + + for (cycle = 0u; cycle < gs_arEnvelope[envelopeID].ACCnt ; cycle++) + { + gs_arEnvelope[envelopeID].ACID[cycle] = gs_arEnvelope[envelopeID].ACID[cycle+1u]; + gs_arEnvelope[envelopeID].ACID[cycle+1u] = 0u; + } + } + + /** úֵ*/ + ret = CI_SUCCESS; + } + else + { + /** 粻ڣ򲻴 */ + } + + return ret; +} + + +/** + * @brief ļջнͷѹβѹ + * @param[in] UINT8 flag ջͷջβе + * @param[in] UINT16 envelopeID ID + * @param[in] UINT16 ACID ID + * @param[out] + * @return CI_SUCCESS ɹ + * CI_ERROR + * @note + */ +UINT8 elm_PushEnvelopeACSeq(UINT8 flag, UINT16 envelopeID,UINT16 ACID) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 acCnt = 0u; + UINT8 funRet = ENVELOPE_UNEXIT; + + /** ڲУ */ + ASSERT_RET_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag),ret,0x80000000u); + + /** жϰǷ */ + funRet = elm_IsEnvelopeExit(envelopeID); + + if ((ENVELOPE_EXIT == funRet) && (gs_arEnvelope[envelopeID].ACCnt < (SECTION_IN_ENVELOPE_SUM_MAX - 1u))) + { + if (ELM_HEAD == flag) + { + acCnt = gs_arEnvelope[envelopeID].ACCnt; + gs_arEnvelope[envelopeID].ACID[acCnt] = ACID; + gs_arEnvelope[envelopeID].ACCnt++; + } + else + { + /** Ų */ + for (cycle = gs_arEnvelope[envelopeID].ACCnt; 0u != cycle; cycle--) + { + gs_arEnvelope[envelopeID].ACID[cycle] = gs_arEnvelope[envelopeID].ACID[cycle - 1u]; + } + + gs_arEnvelope[envelopeID].ACID[0u] = ACID; + gs_arEnvelope[envelopeID].ACCnt++; + } + + ret = CI_SUCCESS; + } + else + { + /** 粻ڣ򲻴 */ + } + return ret; +} + +/** + * @brief ðгļ + * @param[in] UINT16 envelopeID ID + * @param[in] UINT8 trainId гID + * @param[in] UINT8 ACTPort г + * @param[out] + * @return + * @note + */ +void elm_SetTrainACTPortInELM(UINT16 envelopeID,UINT16 trainId,UINT8 ACTPort) +{ + UINT8 cycle = 0u; + UINT8 funRet = ENVELOPE_UNEXIT; + + /** жϰǷ */ + funRet = elm_IsEnvelopeExit(envelopeID); + + if (ENVELOPE_EXIT == funRet) + { + for (cycle = 0u; cycle < gs_arEnvelope[envelopeID].trianCnt;cycle++) + { + if (gs_arEnvelope[envelopeID].trainID[cycle] == trainId) + { + gs_arEnvelope[envelopeID].ACTPort[cycle] = ACTPort; + break; + } + else + { + /** */ + } + } + } + else + { + /** 粻ڣ */ + } +} + + + +/** + * @brief ȡгļ + * @param[in] UINT16 envelopeID ID + * @param[in] UINT8 trainId гID + * @param[out] + * @return UINT8 г + * @note + */ +UINT8 elm_GetTrainACTPortInELM(UINT16 envelopeID,UINT16 trainId) +{ + UINT8 ret = 0u; + UINT8 cycle = 0u; + UINT8 funRet = ENVELOPE_UNEXIT; + + /** жϰǷ */ + funRet = elm_IsEnvelopeExit(envelopeID); + + if (ENVELOPE_EXIT == funRet) + { + for (cycle = 0u; cycle < gs_arEnvelope[envelopeID].trianCnt;cycle++) + { + if (gs_arEnvelope[envelopeID].trainID[cycle] == trainId) + { + ret = gs_arEnvelope[envelopeID].ACTPort[cycle]; + break; + } + else + { + /** */ + } + } + } + else + { + /** 粻ڣ */ + } + return ret; +} + +/** + * @brief UCTתUKTʼʱ + * @param[in] UINT16 wEnvelopid ID + * @param[in] UINT8 dwCycNum ں + * @return CI_SUCCESS 1 óɹ + * CI_ERROR 0 ʧ + * note Created By LQ 2024.07.14 + */ +UINT8 elm_SetUCTToUKTStartCycNum(UINT16 wEnvelopid, UINT32 dwCycNum) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cFunRetVal = CI_ERROR; + + /** жϰIDǷȷ */ + cFunRetVal = elm_IsEnvelopeIDOK(wEnvelopid); + + if ((CI_SUCCESS == cFunRetVal) && (gs_arEnvelope[wEnvelopid].id == wEnvelopid)) + { + gs_arEnvelope[wEnvelopid].dwUCTToUKTStartCycNum = dwCycNum; + cRetVal = CI_SUCCESS; + } + else + { + /*ηǷʧ*/ + } + + return cRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManage.h b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManage.h new file mode 100644 index 0000000..1a749de --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManage.h @@ -0,0 +1,447 @@ +/****************************************************************************** +** ļ: EnvelopeManage.h +** : гģ鹦ܴͷļͷļĺģʹãṩ +*******************************************************************************/ + +#ifndef ENVELOPE_MANAGE_H_ +#define ENVELOPE_MANAGE_H_ + +#include "EnvelopeDefine.h" +#include "ELMDataPrepare.h" + + +/*ӳ䵽ӳ*/ +typedef struct { + UINT8 envelopeCnt; /**/ + UINT16 envelopeId[SECTION_REL_ENVELOPE_SUM_MAX]; /*ID*/ +}EnvelopeMapStruct; + + +/* гӳ䵽ӳ */ +typedef struct { + UINT8 envelopeCnt; /**/ + UINT16 envelopeId[TRAIN_REL_ENVELOPE_SUM_MAX]; /*ID*/ +}TrainMapStruct; + +/*ڴ,ҿԼڴ÷Χ*/ +typedef struct{ + const void * pStartVaild; + const void * pEndVaild; +}MemAreaStruct; + + +/** +* @brief ҪĿڴǷڿڴ +* @param[in] MemAreaStruct targetArea ҪĿڴ +* @param[in] MemAreaStruct valiArea ڴ +* @return CI_SUCCESS Ҫڴȷسɹ +* CI_ERROR Ҫڴ󣬷ʧ +* @note ҪĿڴȫڿڴʱΪϷ +ڴһҿ +Ŀڴõһҿ +*/ +UINT8 elm_IsMemAreaOK(MemAreaStruct targetArea, MemAreaStruct valiArea); + +/** +* @brief ڴǷȷ +* @param[in] EnvelopeStruct *pEnvelope Ҫڴʼַ +* @param[in] UINT16 size Ҫڴ +* @return CI_SUCCESS Ҫڴȷسɹ +* CI_ERROR Ҫڴ󣬷ʧ +* @note ַָͨСҪİڴǷڿõĵַռ +*/ +UINT8 elm_IsEnvelopeMemOK(IN EnvelopeStruct *pEnvelope, UINT16 size); + +/** +* @brief İӳڴǷȷ +* @param[in] EnvelopeMapStruct *pRelEnvelope Ҫڴʼַ +* @param[in] UINT16 size Ҫڴ +* @return CI_SUCCESS Ҫڴȷسɹ +* CI_ERROR Ҫڴ󣬷ʧ +* @note ַָͨСҪİڴǷڿõĵַռ +*/ +UINT8 elm_IsACRelEnvelopeMapMemOK(IN EnvelopeMapStruct *pRelEnvelope, UINT16 size); + + +/** +* @brief İӳڴǷȷ +* @param[in] TrainMapStruct *pRelEnvelope Ҫڴʼַ +* @param[in] UINT16 size Ҫڴ +* @return CI_SUCCESS Ҫڴȷسɹ +* CI_ERROR Ҫڴ󣬷ʧ +* @note ַָͨСҪİڴǷڿõĵַռ +*/ +UINT8 elm_IsTrainRelEnvelopeMapMemOK(IN TrainMapStruct *pRelEnvelope, UINT16 size); + +/** +* @brief жǷȷ +* @param[in] UINT16 EnvelopeID ID +* @param[in] UINT16 size Ҫڴ +* @return CI_SUCCESS IDϷسɹ +* CI_ERROR IDǷʧ +* @note +*/ +UINT8 elm_IsEnvelopeIDOK(UINT16 EnvelopeID); + + +/** +* @brief жϰϢǷȷ +* @param[in] const EnvelopeMapStruct *pRelEnvelope Ϣ +* @param[in] UINT16 EnvelopeID ID +* @return CI_SUCCESS IDϷسɹ +* CI_ERROR IDǷʧ +* @note +*/ +UINT8 elm_IsEnvelopeInfoOk(IN const EnvelopeStruct *pEnvelope, UINT16 EnvelopeID); + + +/** +* @brief ð洢ռ +* @param[in] EnvelopeStruct *pEnvelope Ҫڴʼַ +* @param[in] UINT16 size Ҫڴ +* @return CI_SUCCESS Ҫڴȷسɹ +* CI_ERROR Ҫڴ󣬷ʧ +* @note ָİռʼ0 +*/ +UINT8 elm_ResetEnvelope(INOUT EnvelopeStruct *pEnvelope, UINT16 size); + +/** +* @brief üİӳ +* @param[in] EnvelopeMapStruct *pEnvelope Ҫڴʼַ +* @param[in] UINT16 size Ҫڴ +* @return CI_SUCCESS Ҫڴȷسɹ +* CI_ERROR Ҫڴ󣬷ʧ +* @note ָİռʼ0 +*/ +UINT8 elm_ResetACRelEnvelopeMap(INOUT EnvelopeMapStruct *pRelEnvelopeMap, UINT16 size); + +/** +* @brief гİӳ +* @param[in] UINT16 *pEnvelope Ҫڴʼַ +* @param[in] UINT16 size Ҫڴ +* @return CI_SUCCESS Ҫڴȷسɹ +* CI_ERROR Ҫڴ󣬷ʧ +* @note ָİռʼ0 +*/ +UINT8 elm_ResetTrainRelEnvelopeMap(INOUT TrainMapStruct *pRelEnvelopeMap, UINT16 size); + +/** + * @brief ʼ洢ռ + * @param[in] EnvelopeStruct *pEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_InitEnvelope(void); + +/** + * @brief ʼİӳ + * @param[in] EnvelopeMapStruct *pEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_InitACRelEnvelopeMap(void); + +/** + * @brief ʼгİӳ + * @param[in] EnvelopeMapStruct *pEnvelope Ҫڴʼַ + * @param[in] UINT16 size Ҫڴ + * @return CI_SUCCESS Ҫڴȷسɹ + * CI_ERROR Ҫڴ󣬷ʧ + * @note ָİռʼ0 + */ +UINT8 elm_InitTrainRelEnvelopeMap(void); + + +/** + * @brief жϰǷ + * @param[in] UINT16 EnvelopeID ID + * @return ENVELOPE_UNEXIT 粻 + * ENVELOPE_EXIT + * @note ͨжϰ洢ռǷռãжϰǷ + */ +UINT8 elm_IsEnvelopeExit(UINT16 EnvelopeID); + + +/** + * @brief ָռϴ洢 + * @param[in] const EnvelopeStruct *pSrcEnnelope Ҫ洢İַ + * @param[in] UINT16 index Ҫ洢Ŀڴ + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeByIndex(IN const EnvelopeStruct *pSrcEnnelope,UINT16 index); + + +/** + * @brief ¼ιİ + * @param[in] UINT8 flag ʶ + * @param[in] UINT16 ACIndex + * @param[in] UINT16 envelopeID ID + * @return + * @note IDʹ洢ռһ + ӳ䵽洢ռ䣬ʹüε + */ +UINT8 elm_SetACRelEnvelopeMap(UINT8 flag,UINT16 ACIndex,UINT16 envelopeID); + + +/** + * @brief гİ + * @param[in] UINT8 flag ʶ + * @param[in] UINT16 trainID гID + * @param[in] UINT16 envelopeID ID + * @return CI_SUCCESS ɾɹسɹ + * CI_ERROR ɾ󣬷ʧ + * @note עֻбTIOCڵİг֮ӳϵ + */ +UINT8 elm_SetTrainRelEnvelopeMap(UINT8 flag,UINT16 trainID,UINT16 envelopeID); + +/** + * @brief ð洢ռñʶ + * @param[in] UINT16 index ± + * @param[in] UINT8 value Ҫõֵ + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeValidFlag(UINT16 index,UINT8 value); + + +/** + * @brief ðյλ + * @param[in] UINT16 envelopid ID + * @param[in] LOD_STRU startPoint λ + * @param[in] LOD_STRU endPoint յλ + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeLoc(UINT16 envelopid,LOD_STRU startPoint,LOD_STRU endPoint); + +/** + * @brief ð㷽 + * @param[in] UINT16 envelopid ID + * @param[in] UINT8 cStartDir 㷽 + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + */ +UINT8 elm_SetEnvelopeStartDir(UINT16 envelopid, UINT8 cStartDir); + +/** + * @brief ðյ㷽 + * @param[in] UINT16 envelopid ID + * @param[in] UINT8 cEndDir յ㷽 + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + */ +UINT8 elm_SetEnvelopeEndDir(UINT16 envelopid, UINT8 cEndDir); + +/** + * @brief ðļϢ + * @param[in] UINT16 envelopid ID + * @param[in] LOD_STRU startPoint λ + * @param[in] LOD_STRU endPoint յλ + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeACInfo(UINT16 envelopid,UINT8 acCnt,IN const UINT16 acID[SECTION_IN_ENVELOPE_SUM_MAX]); + + +/** + * @brief ðǰг + * @param[in] INT16 envelopid id + * @param[in] UINT16 tainid гid + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeHeadTrainID(UINT16 envelopid,UINT16 tainid); + +/** + * @brief ðг + * @param[in] UINT16 envelopid id + * @param[in] UINT16 tainid гid + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeTailTrainID(UINT16 envelopid,UINT16 tainid); + +/** + * @brief ð + * @param[in] UINT16 envelopid id + * @param[in] UINT8 envelopType + * @param[out] + * @return CI_SUCCESS óɹسɹ + * CI_ERROR ô󣬷ʧ + * @note + */ +UINT8 elm_SetEnvelopeType(UINT16 envelopeId,UINT8 envelopType); + +/** + * @brief ðģǷ + * @param[in] UINT8 workFlag + * @note + */ +void elm_SetELMWorkFlag(UINT8 workFlag); + +/** + * @brief ðģǷ + * @return ELM_WORK_ERROR + ELM_WORK_OK + * @note + */ +UINT8 elm_GetELMWorkFlag(void); + + + +/** + * @brief ȡõĴ洢ռ± + * @param[in] + * @param[out] + * @return ENVELOPE_UNVAILD_INDEX ޿õĴ洢ռ± + ENVELOPE_UNVAILD_INDEX ϷĿõ 洢ռ± + * @note + */ +UINT16 elm_GetEnvelopeValidIndex(void); + +/** + * @brief гIDİϢӳַ + * @param[in] UINT16 trainID гID + * @return İַ + * @note 󣬷NULL + */ +const TrainMapStruct * elm_GetTrainRelEnvelopeMapPtr(UINT16 trainID); + +/** + * @brief ȡгIDİϢ + * @param[in] UINT16 trainID гID + * @param[out] UINT16 envelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] İID + * @return İ + * @note 󣬷TRAIN_REL_ENVELOPE_SUM_MAX + */ +UINT8 elm_GetRelELIdByTrainID(UINT16 trainID, UINT16 envelopeID[TRAIN_REL_ENVELOPE_SUM_MAX]); + +/** + * @brief ͨгIDȡ洢ַ + * @param[in] UINT8 envelopeType + * @param[in] UINT16 trainID гID + * @param[out] UINT16 envelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] İID + * @return İ + * @note 󣬷TRAIN_REL_ENVELOPE_ERROR_CNT + */ +UINT8 elm_GetRelELIdByTrainIDAndType(UINT8 envelopeType, UINT16 trainID, UINT16 envelopeID[TRAIN_REL_ENVELOPE_SUM_MAX]); + + +/** + * @brief ȡİͰID + * @param[in] UINT16 ACIndex + * @param[out] UINT16 envelopeId[SECTION_REL_ENVELOPE_SUM_MAX] İID + * @return İ + * @note 󣬷SECTION_REL_ENVELOPE_SUM_MAX + */ +UINT8 elm_GetACRelEnvelopeCnt(UINT16 ACIndex,INOUT UINT16 envelopeId[SECTION_REL_ENVELOPE_SUM_MAX]); + + +/** + * @brief ͨIDȡϢ + * @param[in] UINT16 envelopeId ID + * @return Ϣ洢ַ + * @note IDͰһ£ָֻʹãָͨ޸ĶӦֵ + */ +const EnvelopeStruct* elm_GetEnvelopeInfoPtr(UINT16 envelopeId); + + +/** + * @brief ָ + * @param[in] UINT16 envelopeId ID + * @return CI_SUCCESS ɹ + * CI_ERROR + * @note + */ +UINT8 elm_ClearEnvelope(UINT16 envelopeId); + + +/** + * @brief гID뵽г + * @param[in] UINT8 flag ջͷջβ + * @param[in] UINT8 trainId гID + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return + * @note + */ +UINT8 elm_PushToTrainSeq(UINT8 flag,UINT16 envelopeID,UINT16 trainId); + +/** + * @brief гɾгID + * @param[in] UINT16 envelopeID ID + * @param[in] UINT8 trainId гID + * @param[out] + * @return + * @note + */ +UINT8 elm_DeleteTrainFromSeq(UINT16 envelopeID,UINT16 trainId); + + +/** + * @brief ļջнͷβ + * @param[in] UINT8 flag ջͷջβе + * @param[in] UINT16 envelopeID ID + * @param[out] + * @return CI_SUCCESS ɹ + * CI_ERROR + * @note + */ +UINT8 elm_PopEnvelopACSeq(UINT8 flag, UINT16 envelopeID); + +/** + * @brief ļջнͷѹβѹ + * @param[in] UINT8 flag ջͷջβе + * @param[in] UINT16 envelopeID ID + * @param[in] UINT16 ACID ID + * @param[out] + * @return CI_SUCCESS ɹ + * CI_ERROR + * @note + */ +UINT8 elm_PushEnvelopeACSeq(UINT8 flag, UINT16 envelopeID,UINT16 ACID); + + +/** + * @brief ðгļ + * @param[in] UINT16 envelopeID ID + * @param[in] UINT8 trainId гID + * @param[in] UINT8 ACTPort г + * @param[out] + * @return + * @note + */ +void elm_SetTrainACTPortInELM(UINT16 envelopeID,UINT16 trainId,UINT8 ACTPort); + +/** + * @brief ȡгļ + * @param[in] UINT16 envelopeID ID + * @param[in] UINT8 trainId гID + * @param[out] + * @return UINT8 г + * @note + */ +UINT8 elm_GetTrainACTPortInELM(UINT16 envelopeID,UINT16 trainId); + +/** + * @brief UCTתUKTʼʱ + * @param[in] UINT16 wEnvelopid ID + * @param[in] UINT8 dwCycNum ں + * @return CI_SUCCESS 1 óɹ + * CI_ERROR 0 ʧ + * note Created By LQ 2024.07.14 + */ +UINT8 elm_SetUCTToUKTStartCycNum(UINT16 wEnvelopid, UINT32 dwCycNum); + +#endif /*ENVELOPE_MANAGE_H_*/ diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManageAPI.c b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManageAPI.c new file mode 100644 index 0000000..1bc3872 --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManageAPI.c @@ -0,0 +1,1203 @@ +/******************************************************** +* +* EnvelopeManageAPI.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2022-04-15 +* ߣ +* Ӧóӿ +* ޸ļ¼ +* +********************************************************/ +#include "EnvelopeManageAPI.h" +#include "EnvelopeManage.h" +#include "ELMDataPrepare.h" +#include "EnvelopeLogicProcess.h" +#include "../DataManage/DeviceDataManage.h" +#include "WholeLineScreenAPI.h" +#include "../AxisSort/AxisSort.h" + +/*================================̬==============================*/ +static UINT8 elm_InitEnvelopeInOC(void); /* ʼOCڵмΪس */ +static s_TRAIN_ENVELOPE_ID CTTrainEnvelope; /*CTг*/ +static s_TRAIN_ENVELOPE_ID SleepTrainEnvelope; /*߳Ϣ */ +static s_TRAIN_ENVELOPE_ID FaultTrainEnvelope; /*ϳϢ */ + +/** + * @brief ̬ʼOCڵмΪس + * @return CI_SUCCESS ϵʼɹ + * CI_ERROR ϵʼʧ + * @note + */ +static UINT8 elm_InitEnvelopeInOC(void) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; /*ֵ*/ + UINT8 funFlag = CI_ERROR; /*ִзֵ*/ + UINT16 cycle = 0u; + UINT32 errorCode = 0u; /**/ + UINT16 acCnt = 0u; /*OCΧеļ*/ + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + + /** ȡOCΧеļ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + + if (0u == acCnt) + { + /** ѯʧܣOCΧڲܲڼ */ + errorCode = errorCode + 0x08000000u; + } + else + { + /** OCеļ*/ + for (cycle = 0u; cycle < acCnt; cycle++) + { + /*- ռļUKT */ + funFlag = elm_AddUKTEnvelopeInAC(pACIdbuff[cycle]); + ASSERT_BREAK(CI_ERROR == funFlag,errorCode,0x04000000u); + } + } + + /** úֵ*/ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + + /** */ + return ret; +} + + + +/** + * @brief ӿڣгģϵʼ + * @return CI_SUCCESS ϵʼɹ + * CI_ERROR ϵʼʧ + * @note OCϵʱ + */ +UINT8 elm_Init(void) +{ + /*- ֲ*/ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + + /** ʼгռõİ洢ռ */ + ret = elm_InitEnvelope(); + ASSER_ERROR(CI_ERROR == ret,errorCode,0x80000000u); + + /** ʼİӳ*/ + ret = elm_InitACRelEnvelopeMap(); + ASSER_ERROR(CI_ERROR == ret,errorCode,0x40000000u); + + /** ʼгİӳ*/ + ret = elm_InitTrainRelEnvelopeMap(); + ASSER_ERROR(CI_ERROR == ret,errorCode,0x20000000u); + + /** ʼOCڵмΪس*/ + ret = elm_InitEnvelopeInOC(); + ASSER_ERROR(CI_ERROR == ret,errorCode,0x10000000u); + + /** ʼ*/ + ret = aam_Init(); + ASSER_ERROR(CI_ERROR == ret,errorCode,0x08000000u); + + /** жʼǷִгɹ*/ + if (0u == errorCode) + { + /** ð */ + elm_SetELMWorkFlag(ELM_WORK_OK); + ret = CI_SUCCESS; + } + else + { + /** ¼Ϣ--ӡ淶ݶ*/ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ret = CI_ERROR; + } + + return ret; +} + + +/** + * @brief ӿڣгģں + * @param[in] + * @param[out] + * @return + * @note гҪCT硢UT缰س + * س缴ͨųUT磬Ҳ޷жΪϣüΪس + * CT缴ͨгȫλγɵİ + * UT缴ʧͨųг + */ +void elm_MainProcess(void) +{ + UINT8 workFlag = ELM_WORK_ERROR; + UINT8 funRtn = CI_ERROR; + + ELM_LOG_TIME(ELM_LOG_FATAL,"\n==================ElM Start at %d=======================",Get2oo2CurCycleNum()); + ELM_LOG(ELM_LOG_FATAL,"Process info:\n"); + + /** ģ־λ */ + workFlag = elm_GetELMWorkFlag(); + + /** ģ鲻ģ³ʼ */ + if (ELM_WORK_ERROR == workFlag) + { + ELM_LOG_LOC(ELM_LOG_ERROR,"Last perid ELM error,need to reset ELM.") + /** ³ʼ */ + funRtn = elm_Init(); + } + else + { + /** ģ */ + aam_MainProcess(); + + /** ˢOCΧڵİϢ */ + elm_RefreshNextOCEnvelope(); + + /** UKTٴ */ + elm_UKTEnvelopeTrack(); + + /** ȫɸж */ + wls_MainProcess(); + + /** ȫɸ */ + elm_WLScreenProcess(); + + /** CTٴ */ + elm_CTEnvelopeTrack(); + + /** UCTٴ */ + elm_UCTEnvelopeTrack(); + + /*гλüල״̬UCT֮󣬽AGUCT޷BGгල⣩*/ + TrainPosMonitorProc(); + + /*ɸѡ־ල*/ + elm_VirScreenPassMonitor(); + + /** гɸѡ */ + elm_TrainScreen(); + + /** ռUKT */ + elm_ProcessFreeAC(); + + /** 簲ȫ*/ + elm_SafeProtectProcess(); + + /** ˢг״̬ */ + elm_RefreshTrainConstrolStatus(); + + /** ģ־λ */ + workFlag = elm_GetELMWorkFlag(); + + /** ģ鲻ģ³ʼ */ + if (ELM_WORK_ERROR == workFlag) + { + ELM_LOG_LOC(ELM_LOG_ERROR,"ELM error,need to reset ELM.") + + /** ³ʼ */ + funRtn = elm_Init(); + } + else + { + /** ȷ*/ + funRtn = CI_SUCCESS; + } + } + + if (CI_SUCCESS == funRtn) + { + /** дɹ */ + } + else + { + /** ÷ʧܣ崻*/ + SetPlatOverFlag(); + ASSER_DEBUG(CI_ERROR == funRtn,ELM_LOG_LOC(ELM_LOG_ERROR,"Envelope reset error to shutdown.")); + } + + /** άϢӡ*/ + elm_MaintenanceInfo(); + + ELM_LOG_TIME(ELM_LOG_FATAL,"\n==================ElM END=======================") +} + + +/** + * @brief ӿڣͨIDҼϵİϢ + * @param[in] UINT16 acID + * @param[out] EnvelopeStruct envelopeInfo[] ϵİϢ + * @return 0 ϲڰ + 0СSECTION_REL_ENVELOPE_SUM_MAX ϰ + SECTION_REL_ENVELOPE_SUM_MAXִд + * @note + */ +UINT8 elm_GetEnvelopeInAC(UINT16 acID,INOUT EnvelopeStruct envelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX]) +{ + + return elm_CopyEnvelopeInAC(acID,envelopeInfo); +} + +/** + * @brief ӿڣͨIDҼϵİIDϢ + * @param[in] UINT16 acID + * @param[out] UINT16 envelopeIDs[] ϵİϢ + * @return 0 ϲڰ + 0СSECTION_REL_ENVELOPE_SUM_MAX ϰ + Ƿأִд + * @note + */ +UINT8 elm_GetEnvelopeIDsInAC(UINT16 acID,INOUT UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX]) +{ + UINT8 ret = SECTION_REL_ENVELOPE_SUM_MAX; + UINT16 tmpACIndex = 0u; + + /** ڲϷУ*/ + if (NULL == envelopeIDs) + { + /** ڲ*/ + } + else + { + /** ͨIDȡ */ + tmpACIndex = elm_PrepareACIndex(acID); + + /** ȡϵİID */ + ret = elm_GetACRelEnvelopeCnt(tmpACIndex,envelopeIDs); + } + + return ret; +} + + +/** + * @brief ӿڣȡ·еİϢ + * @param[out] UINT16 envelopeID[ENVELOPE_SUM_MAX] ID + * @return 0 ڰ + 0 ~ ENVELOPE_SUM_MAX-1 + ENVELOPE_SUM_MAX Ƿ + * @note + */ +UINT16 elm_GetAllEnvelope(OUT UINT16 envelopeID[ENVELOPE_SUM_MAX]) +{ + /*- ֲ */ + UINT16 ret = ENVELOPE_SUM_MAX; + UINT16 cycle = 0u; + UINT16 envelopeCnt = 0u; + UINT8 vaildFlag = ENVELOPE_UNEXIT; + + /** жڲǷȷ */ + if (NULL == envelopeID) + { + /** ں */ + } + else + { + /** а */ + for (cycle = 1u;cycle < ENVELOPE_SUM_MAX; cycle++) + { + /** ȡռʹñ־*/ + vaildFlag = elm_IsEnvelopeExit(cycle); + + /** жϰǷЧ */ + if (ENVELOPE_EXIT == vaildFlag) + { + /** ID */ + envelopeID[envelopeCnt++] = cycle; + } + else + { + /** 軺*/ + } + } + + /** */ + ret = envelopeCnt; + } + + return ret; +} + +/** +* ܣͨų߳ϳг´洢 +* +* ȫֱstatic s_TRAIN_ENVELOPE_ID CTTrainEnvelope; CTг +* static s_TRAIN_ENVELOPE_ID SleepTrainEnvelope; ߳Ϣ +* static s_TRAIN_ENVELOPE_ID FaultTrainEnvelope; ߳Ϣ * +* fan 2024.06.12 +*/ +void UpdateTrainEnvelope(void) +{ + /*- ֲ */ + UINT16 cycle = 0u; + UINT16 dwCTEnvlpCnt = 0U; + UINT16 dwFaultTrainEnvlpCnt = 0U; + UINT16 dwSleepTrainEnvlpCnt = 0U; + UINT8 vaildFlag = ENVELOPE_UNEXIT; + const EnvelopeStruct* PTempEnvelope = NULL; + UINT8 chLocalId = 0u; + UINT16 wOrgnTioc = 0u; + UINT16 wTmpTioc = 0u; + UINT16 wTmpLinkId = 0U; + UINT16 wOrgnLinkId = 0u; + UINT8 chSleepState = 0u; + + /*մ洢İϢ*/ + CTTrainEnvelope.ELNum = 0U; + SleepTrainEnvelope.ELNum = 0U; + FaultTrainEnvelope.ELNum = 0U; + (void)CommonMemSet(CTTrainEnvelope.TrainEnveLopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX), 0U, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX)); + (void)CommonMemSet(SleepTrainEnvelope.TrainEnveLopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX), 0U, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX)); + (void)CommonMemSet(FaultTrainEnvelope.TrainEnveLopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX), 0U, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX)); + + chLocalId = GetSystemParaLocalCiId(); + /*а */ + for (cycle = 1u; cycle < ENVELOPE_SUM_MAX; cycle++) + { + /** ȡռʹñ־*/ + vaildFlag = elm_IsEnvelopeExit(cycle); + + /** жϰǷЧ */ + if (ENVELOPE_EXIT == vaildFlag) + { + /* ໺ID */ + PTempEnvelope = elm_GetEnvelopeInfoPtr(cycle); + if (NULL != PTempEnvelope) + { + wTmpLinkId = PTempEnvelope->endPos.Lnk; + wOrgnLinkId = PTempEnvelope->startPos.Lnk; + + + wTmpTioc = GetLinkManageTiocById(wTmpLinkId); + wOrgnTioc = GetLinkManageTiocById(wOrgnLinkId); + + chSleepState = GetTrainSleepState(PTempEnvelope->trainID[0]); + if ((wTmpTioc == chLocalId) && (wOrgnTioc == chLocalId)) + { + if ((TYPE_CT_ENVELOPE == PTempEnvelope->envelopeType) + && (TRAIN_SLEEP_YES == chSleepState)) + { + SleepTrainEnvelope.TrainEnveLopeID[dwSleepTrainEnvlpCnt++] = cycle; + } + else if (TYPE_CT_ENVELOPE == PTempEnvelope->envelopeType) + { + CTTrainEnvelope.TrainEnveLopeID[dwCTEnvlpCnt++] = cycle; + } + else + { + /*ͨųչϳ*/ + FaultTrainEnvelope.TrainEnveLopeID[dwFaultTrainEnvlpCnt++] = cycle; + } + } + else + { + ; /**/ + } + } + } + else + { + ; /** 軺*/ + } + } + /*¼*/ + CTTrainEnvelope.ELNum = dwCTEnvlpCnt; + SleepTrainEnvelope.ELNum = dwSleepTrainEnvlpCnt; + FaultTrainEnvelope.ELNum = dwFaultTrainEnvlpCnt; +} + +/** +* ܣȡͨų +* @param[out] UINT16 envelopeID[ENVELOPE_SUM_MAX] ID +* ȫֱstatic s_TRAIN_ENVELOPE_ID CTTrainEnvelope; CTг +* ֵ 0 ~ ENVELOPE_SUM_MAX-1 ENVELOPE_SUM_MAX Ƿ +* fan 2024.06.12 +*/ +UINT16 elm_GetCTEnvelope(OUT UINT16 envelopeID[ENVELOPE_SUM_MAX]) +{ + UINT16 ret = ENVELOPE_SUM_MAX; + if (NULL != envelopeID) + { + ret = CTTrainEnvelope.ELNum; + (void)CommonMemCpy(envelopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX), (const)CTTrainEnvelope.TrainEnveLopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX)); + } + else + { + ; /*ηǷ*/ + } + return ret; +} + +/** +* ܣȡ߳ +* @param[out] UINT16 envelopeID[ENVELOPE_SUM_MAX] ID +* ȫֱstatic s_TRAIN_ENVELOPE_ID SleepTrainEnvelope; CTг +* ֵ 0 ~ ENVELOPE_SUM_MAX-1 ENVELOPE_SUM_MAX Ƿ +* fan 2024.06.12 +*/ +UINT16 elm_GetSleepEnvelope(OUT UINT16 envelopeID[ENVELOPE_SUM_MAX]) +{ + UINT16 ret = ENVELOPE_SUM_MAX; + if (NULL != envelopeID) + { + ret = SleepTrainEnvelope.ELNum; + (void)CommonMemCpy(envelopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX), (const)SleepTrainEnvelope.TrainEnveLopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX)); + } + else + { + ; /*ηǷ*/ + } + return ret; +} + +/** +* ܣȡϳ +* @param[out] UINT16 envelopeID[ENVELOPE_SUM_MAX] ID +* ȫֱstatic s_TRAIN_ENVELOPE_ID FaultTrainEnvelope; CTг +* ֵ 0 ~ ENVELOPE_SUM_MAX-1 ENVELOPE_SUM_MAX Ƿ +* fan 2024.06.12 +*/ +UINT16 elm_GetFaultEnvelope(OUT UINT16 envelopeID[ENVELOPE_SUM_MAX]) +{ + UINT16 ret = ENVELOPE_SUM_MAX; + if (NULL != envelopeID) + { + ret = FaultTrainEnvelope.ELNum; + (void)CommonMemCpy(envelopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX), (const)FaultTrainEnvelope.TrainEnveLopeID, (UINT32)(sizeof(UINT16)*ENVELOPE_SUM_MAX)); + } + else + { + ; /*ηǷ*/ + } + return ret; +} + +/** + * @brief ӿڣͨIDȡϢ + * @param[in] UINT16 envelopeID ID + * @return ǿ ѯȷϢ + NULL ѯ + * @note + */ +const EnvelopeStruct* elm_GetEnvelopeInfoByID(UINT16 envelopeID) +{ + return elm_GetEnvelopeInfoPtr(envelopeID); +} + + +/** + * @brief ӿڣͨгIDȡİID + * @param[in] UINT16 trainID гID + * @return ǿ ѯȷϢ + NULL ѯ + * @note עֻCT + */ +const EnvelopeStruct* elm_GetEnvelopeInfoByTrainID(UINT16 trainID) +{ + const EnvelopeStruct* ret = NULL; + UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] = {0u}; /*гİ*/ + UINT16 relEnvelopeCnt = TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + + /** ͨгIDȡгİID*/ + relEnvelopeCnt = elm_GetRelELIdByTrainIDAndType(TYPE_CT_ENVELOPE,trainID,relEnvelopeID); + + if (1u == relEnvelopeCnt) + { + ret = elm_GetEnvelopeInfoPtr(relEnvelopeID[0u]); + } + else + { + /** */ + } + return ret; +} + + +/** + * @brief ӿڣͨIDתɽӿҪİϢ + * @param[in] UINT16 envelopeID ID + * @param[out] InfEnvelopeStruct *pInfEnvelope תĽӿڰϢ + * @return CI_SUCCESS ȡɹ + CI_ERROR ȡʧ + * @note ӿڻȡʧܣҪȫദ֪ͨггɸ֪г + */ +UINT8 elm_ConvertEnvelopeInfo(UINT16 envelopeID,IN InfEnvelopeStruct *pInfEnvelope) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + const EnvelopeStruct* PTempEnvelope = NULL; + + /** ͨIDȡϢ */ + PTempEnvelope = elm_GetEnvelopeInfoPtr(envelopeID); + + /** жڲǷȷ */ + if ((NULL != PTempEnvelope) && (NULL != pInfEnvelope)) + { + /*- תɽӿϢ */ + pInfEnvelope->envelopeType = PTempEnvelope->envelopeType; + pInfEnvelope->id = PTempEnvelope->id; + pInfEnvelope->startPos = PTempEnvelope->startPos; + pInfEnvelope->endPos = PTempEnvelope->endPos; + pInfEnvelope->suspicHead = (0u != PTempEnvelope->headTrainID) ? (UINT8)CI_IVOC_HEAD_SCREEN_UNKNOW : (UINT8)CI_IVOC_HEAD_SCREEN_PASS; + pInfEnvelope->suspicTail = (0u != PTempEnvelope->tailTrainID) ? (UINT8)CI_IVOC_TAIL_SCREEN_UNKNOW : (UINT8)CI_IVOC_TAIL_SCREEN_PASS; + pInfEnvelope->trianCnt = PTempEnvelope->trianCnt; + (void)CommonMemCpy(pInfEnvelope->trainID, (UINT32)sizeof(pInfEnvelope->trainID), PTempEnvelope->trainID, (UINT32)sizeof(PTempEnvelope->trainID)); + ret = CI_SUCCESS; + } + else + { + /** ڲ */ + } + + /** */ + return ret; +} + + +/** + * @brief ӿڣģ + * @param[out] UINT8 *pDataBuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ݵij + * @note + */ +UINT32 elm_GetTransferData(OUT UINT8 *pDataBuff,UINT32 curIndex) +{ + /*- ֲ */ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex; + UINT16 cycle = 0u; + UINT16 envelopeCnt = 0u; + UINT32 envelopeCntIndex = 0u; + UINT16 envelopeID[ENVELOPE_SUM_MAX] = {0u}; + const EnvelopeStruct *pEnvelope = NULL; + UINT32 errorCode = 0u; + UINT32 acRelEnvelpeCntIndex = 0u; + UINT16 copyAcCnt = 0u; + UINT16 trainRelEnvelopeCnt = 0u; + UINT8 acRelEnvelpeCnt = 0u; + UINT16 acRelenvelopeId[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + const TrainMapStruct * relEnvelopePtr = NULL; + + if (NULL != pDataBuff) + { + /** ģʶ */ + pDataBuff[copyIndex++] = (UINT8)'E'; + pDataBuff[copyIndex++] = (UINT8)'L'; + pDataBuff[copyIndex++] = (UINT8)'M'; + + + /** ȡģǷб־ */ + pDataBuff[copyIndex++] = elm_GetELMWorkFlag(); + + /** ȡ */ + envelopeCnt = elm_GetAllEnvelope(envelopeID); + envelopeCntIndex = copyIndex; + copyIndex += 2u; + + for (cycle = 0u;cycle < envelopeCnt;cycle++) + { + /** ȡָ*/ + pEnvelope = elm_GetEnvelopeInfoPtr(envelopeID[cycle]); + + /** жָǷΪ */ + ASSERT_BREAK(NULL == pEnvelope,errorCode,0x40000000u) + + /** ڱʶ*/ + pDataBuff[copyIndex++] = pEnvelope->exitFlag; + + /** */ + pDataBuff[copyIndex++] = pEnvelope->envelopeType; + + /** ʶ */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(UINT16),&(pEnvelope->id), (UINT32)sizeof(UINT16)); + copyIndex += (UINT32)sizeof(UINT16); + + /** ǰгID */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(UINT16),&(pEnvelope->headTrainID), (UINT32)sizeof(UINT16)); + copyIndex += (UINT32)sizeof(UINT16); + + /** гID */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(UINT16),&(pEnvelope->tailTrainID), (UINT32)sizeof(UINT16)); + copyIndex += (UINT32)sizeof(UINT16); + + /** ʼλ */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(LOD_STRU),&(pEnvelope->startPos), (UINT32)sizeof(LOD_STRU)); + copyIndex += (UINT32) sizeof(LOD_STRU); + + /** նλ */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(LOD_STRU),&(pEnvelope->endPos), (UINT32)sizeof(LOD_STRU)); + copyIndex += (UINT32)sizeof(LOD_STRU); + + /** аг */ + pDataBuff[copyIndex++] = pEnvelope->trianCnt; + + /** агID */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)(sizeof(UINT16)*pEnvelope->trianCnt),&(pEnvelope->trainID[0]), (UINT32)(sizeof(UINT16)*pEnvelope->trianCnt)); + copyIndex += (UINT32)sizeof(UINT16)*pEnvelope->trianCnt; + + /** аг */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)(sizeof(UINT8)*pEnvelope->trianCnt),&(pEnvelope->ACTPort[0]), (UINT32)(sizeof(UINT8)*pEnvelope->trianCnt)); + copyIndex += (UINT32)sizeof(UINT8)*pEnvelope->trianCnt; + + /** AC */ + pDataBuff[copyIndex++] = pEnvelope->ACCnt; + + /** агID */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)(sizeof(UINT16)*pEnvelope->ACCnt),&(pEnvelope->ACID[0]), (UINT32)(sizeof(UINT16)*pEnvelope->ACCnt)); + copyIndex += (UINT32)sizeof(UINT16)*pEnvelope->ACCnt; + + /** UCTתUKTʼʱ */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(UINT32), &(pEnvelope->dwUCTToUKTStartCycNum), (UINT32)sizeof(UINT32)); + copyIndex += (UINT32)sizeof(UINT32); + } + + /** жǷȷ */ + if (0u == errorCode) + { + /** ð */ + (void)CommonMemCpy(&pDataBuff[envelopeCntIndex], (UINT32)sizeof(UINT16), &envelopeCnt , (UINT32)sizeof(UINT16)); + + /** üӳ */ + acRelEnvelpeCntIndex = copyIndex; + copyIndex += 2u; + + /** İӳ */ + for (cycle = 1u; cycle < AXIS_SECTION_SUM_MAX;cycle++) + { + /** ͨȡİϢ */ + acRelEnvelpeCnt = elm_GetACRelEnvelopeCnt(cycle,acRelenvelopeId); + + /** жǷѯ */ + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX == acRelEnvelpeCnt,errorCode,0x20000000u) + + /** жϼϹİǷڣ򲻿*/ + if (0u == acRelEnvelpeCnt) + { + /** ᲻磬п */ + } + else + { + /** */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(UINT16),&cycle, (UINT32)sizeof(UINT16)); + copyIndex += (UINT32)sizeof(UINT16); + + /** ϵİϢ */ + pDataBuff[copyIndex++] = acRelEnvelpeCnt; + + /** ӳİID */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)(sizeof(UINT16)*acRelEnvelpeCnt),&acRelenvelopeId[0], (UINT32)(sizeof(UINT16)*acRelEnvelpeCnt)); + copyIndex += (UINT32)(sizeof(UINT16)*acRelEnvelpeCnt); + + /** 1*/ + copyAcCnt++; + } + } + + /** жϼӳǷ񿽱ɹ */ + if (0u == errorCode) + { + /** üӳ */ + (void)CommonMemCpy(&pDataBuff[acRelEnvelpeCntIndex], (UINT32)sizeof(UINT16), ©AcCnt , (UINT32)sizeof(UINT16)); + + /** гӳ*/ + trainRelEnvelopeCnt = LINE_MAX_TRAIN; + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(UINT16), &trainRelEnvelopeCnt , (UINT32)sizeof(UINT16)); + copyIndex += (UINT32)sizeof(UINT16); + + /** гİӳ */ + for (cycle = 1u; cycle < LINE_MAX_TRAIN;cycle++) + { + /** ͨгIDȡгİ */ + relEnvelopePtr = elm_GetTrainRelEnvelopeMapPtr(cycle); + ASSERT_BREAK(NULL == relEnvelopePtr,errorCode,0x10000000u); + + /** гİ */ + pDataBuff[copyIndex++] = relEnvelopePtr->envelopeCnt; + + /** гİϢ */ + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)(sizeof(UINT16) * relEnvelopePtr->envelopeCnt), &(relEnvelopePtr->envelopeId[0u]) , (UINT32)(sizeof(UINT16) * relEnvelopePtr->envelopeCnt)); + copyIndex += (UINT32)(sizeof(UINT16) * relEnvelopePtr->envelopeCnt); + } + + if (cycle == LINE_MAX_TRAIN) + { + /** */ + copyIndex = aam_GetTransferData(pDataBuff,copyIndex); + + /** ÷ֵֵ */ + ret = copyIndex; + ELM_LOG(ELM_LOG_FATAL,"info:ELM Transfer dataIndex:%d.dataLen:%d.\n",copyIndex,copyIndex - curIndex); + } + else + { + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Transfer train id:%d rel envelope info error.",errorCode,cycle); + } + } + else + { + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Transfer acindex%d rel envelope info error.",errorCode,cycle); + } + } + else + { + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Transfer envelope info error.",errorCode); + } + } + else + { + /** ڲԣпֱӷ */ + ASSER_ERROR(NULL == pDataBuff,errorCode,0x80000000u) + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Input info error.",errorCode); + } + return ret; +} + +/** + * @brief ӿڣģ + * @param[in] const UINT8 *pDatabuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @param[in] UINT32 len ݵij + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + */ +UINT32 elm_SetTransferData(IN const UINT8 *pDatabuff,UINT32 curIndex,UINT32 len) +{ + /*- ֲ */ + UINT32 ret = curIndex; + UINT8 funRtn = CI_ERROR; + UINT8 cycleELM = 0u; + UINT32 setIndex = curIndex; + UINT16 cycle = 0u; + UINT16 envelopeCnt = 0u; + EnvelopeStruct EnvelopeInfo = {0u}; + UINT32 errorCode = 0u; + UINT16 copyAcCnt = 0u; + UINT16 ACBuffIndex = 0u; + UINT8 acRelEnvelpeCnt = 0u; + UINT8 cycleEnvelpeId = 0u; + UINT16 acRelenvelopeId = 0u; + UINT16 relEnvelopeCnt = TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + UINT16 relEnvelopeID[TRAIN_IN_ENVELOPE_SUM_MAX] = {0u}; /*гİ*/ + + + if ((NULL == pDatabuff) || (curIndex >= len)) + { + /** ڲ */ + ASSER_ERROR(CI_ERROR == ret,errorCode,0x80000000u) + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Input info error,curindex:%d,len:%d.",errorCode,curIndex,len) + } + else + { + if ((UINT8)'E' == pDatabuff[setIndex]) + { + setIndex++; + if ((UINT8)'L' == pDatabuff[setIndex]) + { + setIndex++; + if ((UINT8)'M' == pDatabuff[setIndex]) + { + setIndex++; + /** ELMģ־λ */ + elm_SetELMWorkFlag(pDatabuff[setIndex++]); + + /** ȡ */ + (void)CommonMemCpy(&envelopeCnt, (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += (UINT32)sizeof(UINT16); + + /** հϢ*/ + (void)elm_InitEnvelope(); + + /** Ϣ */ + for (cycle = 0u; cycle < envelopeCnt; cycle++) + { + /** ջռ */ + (void)CommonMemSet(&EnvelopeInfo, (UINT32)sizeof(EnvelopeStruct), 0, (UINT32)sizeof(EnvelopeStruct)); + + /** ڱʶ*/ + EnvelopeInfo.exitFlag = pDatabuff[setIndex++]; + + /** */ + EnvelopeInfo.envelopeType = pDatabuff[setIndex++]; + + /** ʶ */ + (void)CommonMemCpy(&(EnvelopeInfo.id), (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += (UINT32)sizeof(UINT16); + + /** ǰгID */ + (void)CommonMemCpy(&(EnvelopeInfo.headTrainID), (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += (UINT32)sizeof(UINT16); + + /** гID */ + (void)CommonMemCpy(&(EnvelopeInfo.tailTrainID), (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += (UINT32)sizeof(UINT16); + + /** ʼλ */ + (void)CommonMemCpy(&(EnvelopeInfo.startPos), (UINT32)sizeof(LOD_STRU), &pDatabuff[setIndex], (UINT32)sizeof(LOD_STRU)); + setIndex += (UINT32)sizeof(LOD_STRU); + + /** նλ */ + (void)CommonMemCpy(&(EnvelopeInfo.endPos), (UINT32)sizeof(LOD_STRU), &pDatabuff[setIndex], (UINT32)sizeof(LOD_STRU)); + setIndex += (UINT32)sizeof(LOD_STRU); + + /** аг */ + EnvelopeInfo.trianCnt = pDatabuff[setIndex++]; + + /** агID */ + (void)CommonMemCpy(&(EnvelopeInfo.trainID[0]), (UINT32)(sizeof(UINT16)*EnvelopeInfo.trianCnt), &pDatabuff[setIndex], (UINT32)(sizeof(UINT16)*EnvelopeInfo.trianCnt)); + setIndex += (UINT32)(sizeof(UINT16)*EnvelopeInfo.trianCnt); + + /** аг */ + (void)CommonMemCpy(&(EnvelopeInfo.ACTPort[0]), (UINT32)(sizeof(UINT8)*EnvelopeInfo.trianCnt), &pDatabuff[setIndex], (UINT32)(sizeof(UINT8)*EnvelopeInfo.trianCnt)); + setIndex += (UINT32)(sizeof(UINT8)*EnvelopeInfo.trianCnt); + + /** AC */ + EnvelopeInfo.ACCnt = pDatabuff[setIndex++]; + + /** агID */ + (void)CommonMemCpy(&(EnvelopeInfo.ACID[0]), (UINT32)(sizeof(UINT16)*EnvelopeInfo.ACCnt), &pDatabuff[setIndex], (UINT32)(sizeof(UINT16)*EnvelopeInfo.ACCnt)); + setIndex += (UINT32)sizeof(UINT16)*EnvelopeInfo.ACCnt; + + /** UCTתUKTʼʱ */ + (void)CommonMemCpy(&(EnvelopeInfo.dwUCTToUKTStartCycNum), (UINT32)sizeof(UINT32), &pDatabuff[setIndex], (UINT32)sizeof(UINT32)); + setIndex += (UINT32)sizeof(UINT32); + + /** ӵ绺ռ */ + funRtn = elm_SetEnvelopeByIndex(&EnvelopeInfo, EnvelopeInfo.id); + + /** жǷȷ */ + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x40000000u); + } + + /** жϸϢǷȷ */ + if (0u == errorCode) + { + /** ռӳ*/ + (void)elm_InitACRelEnvelopeMap(); + + /** ȡļӳ */ + (void)CommonMemCpy(©AcCnt, (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += 2u; + + /** İӳ */ + for (cycle = 0u; cycle < copyAcCnt; cycle++) + { + /** ȡ */ + (void)CommonMemCpy(&ACBuffIndex, (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += (UINT32)sizeof(UINT16); + + /** ȡİ */ + acRelEnvelpeCnt = pDatabuff[setIndex++]; + + /** üİID*/ + for (cycleEnvelpeId = 0u; cycleEnvelpeId < acRelEnvelpeCnt; cycleEnvelpeId++) + { + /** ȡID */ + (void)CommonMemCpy(&acRelenvelopeId, (UINT32)sizeof(UINT16), &pDatabuff[setIndex], (UINT32)sizeof(UINT16)); + setIndex += (UINT32)sizeof(UINT16); + + /** ð */ + funRtn = elm_SetACRelEnvelopeMap(OP_ADD, ACBuffIndex, acRelenvelopeId); + + /** жǷȷ */ + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x40000000u); + } + + /** жǷȷ */ + ASSERT_BREAK(cycleEnvelpeId != acRelEnvelpeCnt, errorCode, 0x20000000u); + } + + /** жǷɹ */ + if (0u == errorCode) + { + /** гӳ*/ + (void)elm_InitTrainRelEnvelopeMap(); + + /** 2ֽڵг */ + setIndex += (UINT32)sizeof(UINT16); + + /** гİӳ */ + for (cycle = 1; cycle < LINE_MAX_TRAIN; cycle++) + { + /** ջ */ + (void)CommonMemSet(&relEnvelopeID[0u], (UINT32)sizeof(relEnvelopeID), 0u, (UINT32)sizeof(relEnvelopeID)); + + /** ȡгİ */ + relEnvelopeCnt = pDatabuff[setIndex++]; + + /** ȡгİϢ */ + (void)CommonMemCpy(&relEnvelopeID[0u], (UINT32)(sizeof(UINT16) * relEnvelopeCnt), &pDatabuff[setIndex], (UINT32)(sizeof(UINT16) * relEnvelopeCnt)); + setIndex += (UINT32)sizeof(UINT16) * relEnvelopeCnt; + + /** гӵڴ */ + for (cycleELM = 0u; cycleELM < relEnvelopeCnt; cycleELM++) + { + funRtn = elm_SetTrainRelEnvelopeMap(OP_ADD, cycle, relEnvelopeID[cycleELM]); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + + ASSERT_BREAK(relEnvelopeCnt != cycleELM, errorCode, 0x08000000u); + } + + if (0u == errorCode) + { + /** üϢ*/ + setIndex = aam_SetTransferData(pDatabuff, setIndex, len); + + /** ÷ֵ */ + ASSERT_SETRET(setIndex <= len, ret, setIndex, ret); + ELM_LOG(ELM_LOG_FATAL, "info:ELM Set dataIndex%d.dataLen:%d.\n", setIndex, len); + } + else + { + /** ӡϢ */ + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Set Train Rel Envelope Map info error.", errorCode); + } + + } + else + { + /** ӡϢ */ + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Set ac Rel Envelope Map info error.", errorCode); + } + } + else + { + /** ӡϢ */ + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Set envelope info error.", errorCode); + } + + } + else + { + /** ʹ */ + ASSER_ERROR(CI_ERROR == ret, errorCode, 0x40000000u); + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:TransferData type:%c error.", errorCode, pDatabuff[curIndex]); + } + } + else + { + /** ʹ */ + ASSER_ERROR(CI_ERROR == ret, errorCode, 0x40000000u); + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:TransferData type:%c error.", errorCode, pDatabuff[curIndex]); + } + } + else + { + /** ʹ */ + ASSER_ERROR(CI_ERROR == ret, errorCode, 0x40000000u); + ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:TransferData type:%c error.", errorCode, pDatabuff[curIndex]); + } + } + return ret; +} + +/** + * @brief ӿڣ֪ + * @param[in] UINT8 envelopeType + * @param[in] UINT16 TrainID ID + * @param[in] LOD_STRU startPoint ʼλ + * @param[in] LOD_STRU endPoint ֹλ + * @param[in] UINT16 headTrainID ǰгID + * @param[in] UINT16 tailTrainID гID + * @param[out] EnvelopeStruct *pEnvelope + * @return CI_SUCCESS 紴ȷسɹ + * CI_ERROR 紴ʧܣʧ + * @note + */ +UINT8 elm_BuildEnveLope(UINT8 envelopeType,UINT16 TrainID, LOD_STRU startPoint,LOD_STRU endPoint,UINT16 headTrainID,UINT16 tailTrainID, \ + INOUT EnvelopeStruct *pEnvelope) +{ + return elm_CreateEnveLope(envelopeType,TrainID,startPoint,endPoint,headTrainID,tailTrainID,pEnvelope); +} + + +/** + * @brief ӿڣѯ׼ǰİ + * @param[in] const EnvelopeStruct* pEnvelop ׼ + * @param[in] const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] Ƚϵİ + * @param[in] UINT8 envelopeCnt Ƚϵİ + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + * @note + */ +UINT8 elm_GetNearestBaseOnEnvelope(IN const EnvelopeStruct* pEnvelop, IN const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC], UINT8 envelopeCnt, OUT UINT16 *preEnvelope, OUT UINT16 *backEnvelope) +{ + UINT8 ret = CI_ERROR; + UINT8 includeCnt = 0u; + UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] = {0u}; /** غϵİid */ + UINT8 fuRtn = 0u; + + /** õײ㺯 */ + fuRtn = elm_SearchNearestEnvelope(pEnvelop,arEnvelopID,envelopeCnt,preEnvelope,backEnvelope,&includeCnt,includeELMid); + + /** úֵ */ + ASSERT_SETRET(CI_SUCCESS == fuRtn,ret,CI_SUCCESS,CI_ERROR); + + return ret; +} + +/** +* @brief ӿڣгעʱӦ +* @param[in] wId гID +* @return +* @note +*/ +void elm_LogoutDel(UINT16 wTrainId) +{ + UINT16 relEnvelopeCnt = TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] = {0u}; /*гİ*/ + UINT8 funRet = 0u; + UINT16 trainid = 0u; + UINT8 headNeedScreen = NEED_SCREEN; + UINT8 tailNeedScreen = NEED_SCREEN; + const EnvelopeStruct* pEnvelop = NULL; + UINT32 errorCode = 0u; + + if (LINE_MAX_TRAIN < wTrainId) + { + trainid = wTrainId & 0x00ffu; + } + else + { + trainid = wTrainId; + } + + /** ȡϢ */ + relEnvelopeCnt = elm_GetRelELIdByTrainIDAndType(TYPE_CT_ENVELOPE,trainid,relEnvelopeID); + pEnvelop = elm_GetEnvelopeInfoPtr(relEnvelopeID[0]); + if ( NULL == pEnvelop) + { + /** δڸó磬*/ + } + else + { + /** ɾл */ + funRet = elm_ClearHanderOverEnvelope(pEnvelop,trainid); + + /** ߳ */ + headNeedScreen = (LINE_MAX_TRAIN == pEnvelop->headTrainID) ? NEED_SCREEN : UNNEED_SCREEN; + tailNeedScreen = (LINE_MAX_TRAIN == pEnvelop->tailTrainID) ? NEED_SCREEN : UNNEED_SCREEN; + elm_JudgeTrainOffline(trainid,headNeedScreen,tailNeedScreen); + + if (CI_ERROR == funRet) + { + /** ɾCT磬UKT */ + funRet = elm_DeleteCTOrUCTEnvelope(relEnvelopeID[0]); + ELM_LOG(ELM_LOG_ERROR,"errno:0x%08x info:clear train%d ELM error by Cancel.",errorCode,trainid); + + /** жǷɹ */ + if (CI_ERROR == funRet) + { + /** ðģ鴦 */ + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x8000000u); + ELM_LOG(ELM_LOG_ERROR,"errno:0x%08x info:clear train%d ELM error by Cancel need to retset ELM.",errorCode,trainid); + elm_SetELMWorkFlag(ELM_WORK_ERROR); + } + else + { + /** */ + } + } + else + { + /** ɹ */ + } + } +} + + +/** + * @brief ӿڣȡгİ + * @param[in] UINT16 wTrainId гID + * @param[out] UINT16 envelopeId[TRAIN_REL_ENVELOPE_SUM_MAX] гİ + * @return UINT8 + TRAIN_REL_ENVELOPE_SUM_MAX ѯʧ + 0 ~ TRAIN_REL_ENVELOPE_SUM_MAX ѯɹ + * @note + */ +UINT8 elm_GetTrainRelELM(UINT16 wTrainId,OUT UINT16 envelopeId[TRAIN_REL_ENVELOPE_SUM_MAX]) +{ + UINT8 ret = TRAIN_REL_ENVELOPE_SUM_MAX; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == envelopeId,ret,0x80000000u); + + /** ȡϢ */ + ret = elm_GetRelELIdByTrainID(wTrainId,envelopeId); + + return ret; +} + +/** + * @brief һʱUKT + * @param[in] UINT16 acID ID + * UINT8 Dir 緽 + * @param[out] EnvelopeStruct* pEnvelope İ + * @return 1 ɹ + * 0 ʧ + */ +UINT8 elm_CreatTempUKTEnvelope(UINT16 acID, UINT8 Dir, EnvelopeStruct* pEnvelope) +{ + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT32 errorCode = 0u; + ELM_AxisLocStruct AcLoc = { 0u }; + + /** ڲУ */ + ASSERT_RET_VALUE(((0U == acID) || (AXIS_SECTION_SUM_MAX < acID)), ret, 0x80000000u); + ASSERT_RET_VALUE(NULL == pEnvelope, ret, 0x40000000u); + ASSERT_RET_VALUE(((EMAP_SAME_DIR != Dir) && (EMAP_CONVER_DIR != Dir)), ret, 0x20000000u); + + /** ȡλ */ + funRtn = elm_PrepareACLoc(acID, Dir, &AcLoc); + + if (CI_ERROR == funRtn) + { + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + ELM_LOG(ELM_LOG_ERROR, "errno:0x%08x info:Get AC%d Loc error.\n", errorCode, acID); + } + else + { + /** */ + funRtn = elm_BuildEnveLope(TYPE_UKT_ENVELOPE, LINE_MAX_TRAIN, AcLoc.startPos, AcLoc.endPos, 0u, 0u, pEnvelope); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000u); + ASSER_DEBUG(CI_ERROR == funRtn, ELM_LOG(ELM_LOG_ERROR, "errno:0x%08x info:AC%d Create temp envelope error.\n", errorCode, acID)); + } + + /** ÷ֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR) + + return ret; +} + +/** +* @brief ȡڵİ +* @param[in] UINT16 envelopeId +* @param[out] UINT16 *preEnvelope ǰid +* @param[out] UINT16 *backEnvelope id +* @return CI_ERROR ѯʧ +CI_SUCCESS ѯɹ +* @note +* 1elm_GetNearestEnvelope ӿں +*/ +UINT8 elm_GetNearestEnvelopeApi(UINT16 envelopeId, OUT UINT16 *preEnvelope, OUT UINT16 *backEnvelope) +{ + return elm_GetNearestEnvelope(envelopeId, preEnvelope, backEnvelope); +} + +/** +* @brief ȡǷȫڱOC +* @param[in] const EnvelopeStruct* Ptemp +* @param[out] +* @return ELM_BELONG_OTHER OC +ELM_BELONG_OWNER ڱOC +CI_ERRORǷ +* @note +*/ +UINT8 elm_PrepareEnvelopeIsSelfApi(IN const EnvelopeStruct* ptemp) +{ + return elm_PrepareEnvelopeIsSelf(ptemp); +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManageAPI.h b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManageAPI.h new file mode 100644 index 0000000..670d3e4 --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeManageAPI.h @@ -0,0 +1,234 @@ +/****************************************************************************** +** ļ: EnvelopeManageAPI.h +** : гģӿͷļ +*******************************************************************************/ + +#ifndef ENVELOPE_MANAGE_API_H_ +#define ENVELOPE_MANAGE_API_H_ +#include "EnvelopeDefine.h" + +/** + * @brief ӿڣгģϵʼ + * @return CI_SUCCESS ϵʼɹ + * CI_ERROR ϵʼʧ + * @note OCϵʱ + */ +UINT8 elm_Init(void); + +/** + * @brief ӿڣгģں + * @param[in] + * @param[out] + * @return + * @note гҪCT硢UT缰س + * س缴ͨųUT磬Ҳ޷жΪϣüΪس + * CT缴ͨгȫλγɵİ + * UT缴ʧͨųг + */ +void elm_MainProcess(void); + + +/** + * @brief ӿڣͨIDҼϵİϢ + * @param[in] UINT16 acID + * @param[out] EnvelopeStruct envelopeInfo[] ϵİϢ + * @return 0 ϲڰ + 0СSECTION_REL_ENVELOPE_SUM_MAX ϰ + Ƿأִд + * @note + */ +UINT8 elm_GetEnvelopeInAC(UINT16 acID,INOUT EnvelopeStruct envelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX]); + + +/** + * @brief ӿڣͨIDҼϵİIDϢ + * @param[in] UINT16 acID + * @param[out] UINT16 envelopeIDs[] ϵİϢ + * @return 0 ϲڰ + 0СSECTION_REL_ENVELOPE_SUM_MAX ϰ + Ƿأִд + * @note + */ +UINT8 elm_GetEnvelopeIDsInAC(UINT16 acID,INOUT UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX]); + + +/** +* @brief ӿڣȡ·еİϢ +* @param[out] UINT16 envelopeID[ENVELOPE_SUM_MAX] ID +* @return 0 ڰ +0 ~ ENVELOPE_SUM_MAX-1 +ENVELOPE_SUM_MAX Ƿ +* @note +*/ +UINT16 elm_GetAllEnvelope(OUT UINT16 envelopeID[ENVELOPE_SUM_MAX]); + +/** +* ܣͨų߳ϳг´洢 +* +* ȫֱstatic s_TRAIN_ENVELOPE_ID CTTrainEnvelope; CTг +* static s_TRAIN_ENVELOPE_ID SleepTrainEnvelope; ߳Ϣ +* static s_TRAIN_ENVELOPE_ID FaultTrainEnvelope; ߳Ϣ * +* fan 2024.06.12 +*/ +void UpdateTrainEnvelope(void); + +/** +* ܣȡͨų +* @param[out] UINT16 envelopeID[ENVELOPE_SUM_MAX] ID +* ȫֱstatic s_TRAIN_ENVELOPE_ID CTTrainEnvelope; CTг +* ֵ 0 ~ ENVELOPE_SUM_MAX-1 ENVELOPE_SUM_MAX Ƿ +* fan 2024.06.12 +*/ +UINT16 elm_GetCTEnvelope(OUT UINT16 envelopeID[ENVELOPE_SUM_MAX]); + +/** +* ܣȡ߳ +* @param[out] UINT16 envelopeID[ENVELOPE_SUM_MAX] ID +* ȫֱstatic s_TRAIN_ENVELOPE_ID SleepTrainEnvelope; CTг +* ֵ 0 ~ ENVELOPE_SUM_MAX-1 ENVELOPE_SUM_MAX Ƿ +* fan 2024.06.12 +*/ +UINT16 elm_GetSleepEnvelope(OUT UINT16 envelopeID[ENVELOPE_SUM_MAX]); + +/** +* ܣȡϳ +* @param[out] UINT16 envelopeID[ENVELOPE_SUM_MAX] ID +* ȫֱstatic s_TRAIN_ENVELOPE_ID FaultTrainEnvelope; CTг +* ֵ 0 ~ ENVELOPE_SUM_MAX-1 ENVELOPE_SUM_MAX Ƿ +* fan 2024.06.12 +*/ +UINT16 elm_GetFaultEnvelope(OUT UINT16 envelopeID[ENVELOPE_SUM_MAX]); + +/** + * @brief ӿڣͨIDȡϢ + * @param[in] UINT16 envelopeID ID + * @return ǿ ѯȷϢ + NULL ѯ + * @note + */ +const EnvelopeStruct* elm_GetEnvelopeInfoByID(UINT16 envelopeID); + + +/** + * @brief ӿڣͨгIDȡİID + * @param[in] UINT16 trainID гID + * @return ǿ ѯȷϢ + NULL ѯ + * @note + */ +const EnvelopeStruct* elm_GetEnvelopeInfoByTrainID(UINT16 trainID); + + + +/** + * @brief ӿڣͨIDתɽӿҪİϢ + * @param[in] UINT16 envelopeID ID + * @param[out] InfEnvelopeStruct *pInfEnvelope תĽӿڰϢ + * @return CI_SUCCESS ȡɹ + CI_ERROR ȡʧ + * @note + */ +UINT8 elm_ConvertEnvelopeInfo(UINT16 envelopeID,IN InfEnvelopeStruct *pInfEnvelope); + + +/** + * @brief ӿڣģ + * @param[out] UINT8 *pDataBuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ݵij + * @note + */ +UINT32 elm_GetTransferData(OUT UINT8 *pDataBuff,UINT32 curIndex); + +/** + * @brief ӿڣģ + * @param[in] const UINT8 *pDatabuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @param[in] UINT32 len ݵij + * @return ȡ + * @note + */ +UINT32 elm_SetTransferData(IN const UINT8 *pDatabuff,UINT32 curIndex,UINT32 len); + + +/** + * @brief ӿڣ֪ + * @param[in] UINT8 envelopeType + * @param[in] UINT16 TrainID ID + * @param[in] LOD_STRU startPoint ʼλ + * @param[in] LOD_STRU endPoint ֹλ + * @param[in] UINT16 headTrainID ǰгID + * @param[in] UINT16 tailTrainID гID + * @param[out] EnvelopeStruct *pEnvelope + * @return CI_SUCCESS 紴ȷسɹ + * CI_ERROR 紴ʧܣʧ + * @note + */ +UINT8 elm_BuildEnveLope(UINT8 envelopeType,UINT16 TrainID, LOD_STRU startPoint,LOD_STRU endPoint,UINT16 headTrainID,UINT16 tailTrainID, \ + INOUT EnvelopeStruct *pEnvelope); + +/** + * @brief ӿڣѯ׼ǰİ + * @param[in] const EnvelopeStruct* pEnvelop ׼ + * @param[in] const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] Ƚϵİ + * @param[in] UINT8 envelopeCnt Ƚϵİ + * @param[out] UINT16 *preEnvelope ǰid + * @param[out] UINT16 *backEnvelope id + * @return CI_ERROR ѯʧ + CI_SUCCESS ѯɹ + * @note + */ +UINT8 elm_GetNearestBaseOnEnvelope(IN const EnvelopeStruct* pEnvelop,IN const UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC],UINT8 envelopeCnt,OUT UINT16 *preEnvelope,OUT UINT16 *backEnvelope); + +/** +* @brief ӿڣгעʱӦ +* @param[in] wId гID +* @return +* @note +*/ +void elm_LogoutDel(UINT16 wTrainId); + + +/** + * @brief ӿڣȡгİ + * @param[in] UINT16 wTrainId гID + * @param[out] UINT16 envelopeId[TRAIN_REL_ENVELOPE_SUM_MAX] гİ + * @return UINT8 гİ + * @note + */ +UINT8 elm_GetTrainRelELM(UINT16 wTrainId,OUT UINT16 envelopeId[TRAIN_REL_ENVELOPE_SUM_MAX]); + +/** + * @brief һʱUKT + * @param[in] UINT16 acID ID + * UINT8 Dir 緽 + * @param[out] EnvelopeStruct* pEnvelope İ + * @return 1 ɹ + * 0 ʧ + */ +UINT8 elm_CreatTempUKTEnvelope(UINT16 acID, UINT8 Dir, EnvelopeStruct* pEnvelope); + +/** +* @brief ȡڵİ +* @param[in] UINT16 envelopeId +* @param[out] UINT16 *preEnvelope ǰid +* @param[out] UINT16 *backEnvelope id +* @return CI_ERROR ѯʧ +CI_SUCCESS ѯɹ +* @note +* 1elm_GetNearestEnvelope ӿں +*/ +UINT8 elm_GetNearestEnvelopeApi(UINT16 envelopeId, OUT UINT16 *preEnvelope, OUT UINT16 *backEnvelope); + +/** +* @brief ȡǷȫڱOC +* @param[in] const EnvelopeStruct* Ptemp +* @param[out] +* @return ELM_BELONG_OTHER OC +ELM_BELONG_OWNER ڱOC +CI_ERRORǷ +* @note +*/ +UINT8 elm_PrepareEnvelopeIsSelfApi(IN const EnvelopeStruct* ptemp); + +#endif /*ENVELOPE_MANAGE_API_H_*/ diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeScreen.c b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeScreen.c new file mode 100644 index 0000000..e637825 --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/EnvelopeScreen.c @@ -0,0 +1,688 @@ +/****************************************************************************** +** ļ: EnvelopeScreen.c +** : ɸѡ +*******************************************************************************/ + +#include "EnvelopeLogicProcess.h" +#include "WholeLineScreenAPI.h" +#include "TrainDataManage.h" + + +/*================================̬==============================*/ +static UINT8 elm_ProcessUCTAfterScreen(UINT8 flag,IN const EnvelopeStruct* pTemp,IN const EnvelopeStruct* pEnvelop); /** ɸѡUCTĴ*/ +static void elm_AdjustUCTPointAfterScreen(UINT8 flag, UINT16 ACID, LOD_STRU basePose, IN const EnvelopeStruct* pEnvelop); /** ɸѡUCTλõ*/ +static UINT8 elm_TrainScreenByRecover(UINT8 flag,IN const EnvelopeStruct* pEnvelop); /** ǰгͨŻָʱĿɸѡ */ +static void elm_TrainHeadScreen(IN const EnvelopeStruct* pEnvelop); /* гǰɸѡ */ +static void elm_TrainTailScreen(IN const EnvelopeStruct* pEnvelop); /* гɸѡ */ + + +/** + * @brief ɸѡUCTĴ + * @param[in] UINT8 flag ־λ + * @param[in] IN const EnvelopeStruct* pTemp, UKT + * @param[in] IN const EnvelopeStruct* pEnvelop CT + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ɹ + * @note + */ +static UINT8 elm_ProcessUCTAfterScreen(UINT8 flag,IN const EnvelopeStruct* pTemp,IN const EnvelopeStruct* pEnvelop) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 cycleTrain = 0u; + UINT8 selfFlag = ELM_BELONG_OTHER; + UINT16 tmpACIndex = 0u; + UINT16 tmpACID = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (NULL == pEnvelop),ret,0x80000000u); + ASSERT_RET_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag),ret,0x40000000u); + + /** ȡҪɾļID */ + tmpACID = (ELM_TAIL == flag) ? pTemp->ACID[0u] : pTemp->ACID[pTemp->ACCnt - 1u]; + + /** ɾᵽӳ */ + tmpACIndex = elm_PrepareACIndex(tmpACID); + funRtn = elm_SetACRelEnvelopeMap(OP_DEL,tmpACIndex,pTemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + /** óβ*/ + funRtn = elm_UCTEnvelopeLeaveAC(flag,pTemp,tmpACID); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x10000000u); + + /** ,β,԰˲Ҫŵ*/ + funRtn = elm_PopEnvelopACSeq(flag,pTemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x08000000u); + + if (0u == pTemp->ACCnt) + { + /** жϰǷڱOC */ + selfFlag = elm_PrepareEnvelopeIsSelf(pTemp); + + if (ELM_BELONG_OWNER == selfFlag) + { + /** гӳϵ*/ + for (cycleTrain = 0u; cycleTrain < pTemp->trianCnt;cycleTrain++) + { + /** гİID */ + funRtn = elm_SetTrainRelEnvelopeMap(OP_DEL,pTemp->trainID[cycleTrain], pTemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x04000000u); + } + } + else + { + /** DZOCΧڵİ磬ӳϵ */ + } + + /** հռ */ + ELM_LOG(ELM_LOG_FATAL,"info:delete UCT%d because of CT%d Screen.\n",pTemp->id,pEnvelop->id); + funRtn = elm_ClearEnvelope(pTemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x02000000u); + + } + else + { + /** ¼ */ + tmpACID = (ELM_TAIL == flag) ? pTemp->ACID[0u] : pTemp->ACID[pTemp->ACCnt - 1u]; + + funRtn = elm_SetUCTEnvelopeDot(flag,tmpACID,pTemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x01000000u); + + funRtn = elm_ScreenUctCfpFreeProc(pTemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00800000u); + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d Process error after CT%d Screen.!",errorCode,pTemp->id,pEnvelop->id)); + return ret; +} + + +/** + * @brief ɸѡUCTλõ + * @param[in] UINT8 flag ͷͰβʶ + * @param[in] const EnvelopeStruct* pEnvelop г + * @param[out] + * @return + * @note + */ +static void elm_AdjustUCTPointAfterScreen(UINT8 flag, UINT16 ACID,LOD_STRU basePose,IN const EnvelopeStruct* pEnvelop) +{ + UINT32 errorCode = 0u; + UINT8 cycleElm = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 dirCheck = 0u; + UINT32 disHead = 0u; + UINT32 disTail = 0u; + UINT32 minDisBtwHeadAndTail = 0u; + UINT32 minDis = 0xffffffffu; + const EnvelopeStruct* pTemp = NULL; + const EnvelopeStruct* pOut = NULL; + UINT8 envelopeCnt = 0u; /* */ + UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] = {0u}; /*ID*/ + + /** ڲУ */ + ASSERT_RET_NO_VALUE(NULL == pEnvelop,0x80000000u); + ASSERT_RET_NO_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag),0x40000000u); + + /** ѯԷֽ㴦ϵİϢ */ + envelopeCnt = elm_MergeEnvelope(&ACID,1u,arEnvelopID); + + /** жϰǷUCT */ + for (cycleElm = 0u; cycleElm < envelopeCnt; cycleElm++) + { + /** ȡĵַָ */ + pTemp = elm_GetEnvelopeInfoPtr(arEnvelopID[cycleElm]); + + if ((NULL != pTemp) && (TYPE_UCT_ENVELOPE == pTemp->envelopeType)) + { + /** UCT */ + break; + } + else + { + /** */ + } + } + + if (cycleElm == envelopeCnt) + { + /** ˵ɸѡϲUKT磬账 */ + } + else + { + /** ѯɸѡİ */ + for (cycleElm = 0; cycleElm < envelopeCnt;cycleElm++) + { + /** ȡUCTĵַָ */ + pTemp = elm_GetEnvelopeInfoPtr(arEnvelopID[cycleElm]); + ASSERT_BREAK(NULL == pTemp,errorCode,0x08000000u); + + /** ȡյֽľ */ + disHead = elm_PrepareDistanceBtwPoints(pTemp->endPos,basePose); + disTail = elm_PrepareDistanceBtwPoints(pTemp->startPos,basePose); + minDisBtwHeadAndTail = disHead > disTail ? disTail : disHead; + + if ((minDis >= minDisBtwHeadAndTail) && (TYPE_UCT_ENVELOPE == pTemp->envelopeType)) + { + pOut = pTemp; + minDis = minDisBtwHeadAndTail; + } + else if ((minDis >= minDisBtwHeadAndTail) && (TYPE_UCT_ENVELOPE != pTemp->envelopeType)) + { + /** ˵UCTں*/ + pOut = NULL; + minDis = minDisBtwHeadAndTail; + } + else + { + /** */ + } + } + + if (NULL != pOut) + { + /** ѯλùϵ */ + dirCheck = elm_DirIsSameELMWithELM(pEnvelop,pOut); + ASSER_ERROR(0u == dirCheck,errorCode,0x10000000u); + + if (ELM_HEAD == flag) + { + if ((ELM_DIR_SAME == dirCheck) && (pOut->ACID[0u] == ACID)) + { + funRtn = elm_ProcessUCTAfterScreen(ELM_TAIL,pOut,pEnvelop); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x08000000u); + } + else if ((ELM_DIR_CONVERT == dirCheck) && (pOut->ACID[pOut->ACCnt - 1u] == ACID)) + { + funRtn = elm_ProcessUCTAfterScreen(ELM_HEAD,pOut,pEnvelop); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x04000000u); + } + else + { + /** 账 */ + } + } + else + { + if ((ELM_DIR_CONVERT == dirCheck) && (pOut->ACID[0u] == ACID)) + { + funRtn = elm_ProcessUCTAfterScreen(ELM_TAIL,pOut,pEnvelop); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00800000u); + } + else if ((ELM_DIR_SAME == dirCheck) && (pOut->ACID[pOut->ACCnt - 1u] == ACID)) + { + funRtn = elm_ProcessUCTAfterScreen(ELM_HEAD,pOut,pEnvelop); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00400000u); + } + else + { + /** 账 */ + } + } + } + } + + if(0u != errorCode) + { + /** UCTʧ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:CT%d after Screen to Adjust UCTPoint errorELM need reset !",errorCode,pEnvelop->id); + } + else + { + /** ȷ*/ + } +} + + +/** + * @brief ̬ǰ/гͨŻָʱĿɸѡ + * @param[in] UINT8 flag ͷͰβʶ + * @param[in] const EnvelopeStruct* pEnvelop г + * @param[out] + * @return CI_ERROR ޷Ϊǰ/гͨŻָɸѡ + CI_SUCCESS ǰ/гͨŻָɸѡ + * @note + */ +static UINT8 elm_TrainScreenByRecover(UINT8 flag,IN const EnvelopeStruct* pEnvelop) +{ + UINT8 ret = CI_ERROR; + UINT8 comstatus = ELM_COM_STATUS_ERROR; + UINT16 tmpTrainID = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pEnvelop,ret,0x80000000u); + ASSERT_RET_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag),ret,0x40000000u); + + /** ȡǰ/г */ + if (ELM_HEAD == flag) + { + tmpTrainID = pEnvelop->headTrainID; + } + else + { + tmpTrainID = pEnvelop->tailTrainID; + } + + /** ȡгͨ״̬ */ + comstatus = elm_PrepareTrainCommStatus(tmpTrainID); + + /** úֵ */ + ASSERT_SETRET(ELM_COM_STATUS_OK == comstatus,ret,CI_SUCCESS,CI_ERROR); + + return ret; +} + + +/** + * @brief ̬гǰɸѡ + * @param[in] const EnvelopeStruct* pEnvelop г + * @param[out] + * @return + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +static void elm_TrainHeadScreen(IN const EnvelopeStruct* pEnvelop) +{ + /*- ֲ */ + UINT32 errorCode = 0u; /* */ + UINT8 acCnt = 0u; /* гСȫǰǰ*/ + UINT16 acID[AC_MAXCNT_IN_SWITCH] = {0u}; /* гСȫǰǰ*/ + UINT8 funRet = CI_ERROR; /* ֵ */ + UINT16 tmpACId = 0u; /*id*/ + UINT8 cycleAc = 0u; /*ѭ*/ + UINT8 acStatus = ELM_AC_OCC; /*ռ״̬*/ + UINT8 phyStatus = SECTION_OCCUPY_YES; /*ͨռ״̬*/ + UINT8 trainDir = 0u; + LOD_STRU tmpLoc = {0u}; /*Сȫǰ*/ + ELM_AxisLocStruct tmpACLoc = {0u}; /* ˵λ*/ + UINT8 screenCheck = CI_ERROR; /* ֵ */ + UINT8 chTrainNvramFlag = 0U;/*гNVRAM־*/ + UINT8 chTrainPosMonitorState = 0U;/*гλüල־*/ + + /** ڲУ */ + ASSERT_RET_NO_VALUE(NULL == pEnvelop,0x80000000u); + + /** ǰгͨŻָʱĿɸѡ */ + funRet = elm_TrainScreenByRecover(ELM_HEAD,pEnvelop); + chTrainNvramFlag = GetTrainNvramPosFlag(pEnvelop->trainID[0]); + chTrainPosMonitorState = GetTrainPosMonitorState(pEnvelop->trainID[0]); + + /** ɸѡ */ + if (CI_ERROR == funRet) + { + /** ѯСȫǰǰ*/ + acCnt = elm_PrepareNextAcMinSafeHeadLoc(pEnvelop->trainID[0],acID); + ASSER_ERROR((0u == acCnt) || (AC_MAXCNT_IN_SWITCH < acCnt),errorCode, 0x40000000u); + + /*- жǰǷ */ + for (cycleAc = 0u; cycleAc < acCnt; cycleAc++) + { + /** ȡ״̬ */ + acStatus = elm_PrepareACStatus(acID[cycleAc]); + + /** жǷҪ˳ѭ */ + ASSERT_BREAK(ELM_AC_OCC == acStatus,errorCode,0x20000000u); + + /*ΪΣͨʱҪȫвŸǰɸͨ*/ + phyStatus = elm_PrepareACofSwichPhyStatus(acID[cycleAc]); + + /** жǷҪ˳ѭ */ + ASSERT_BREAK(SECTION_OCCUPY_YES == phyStatus, errorCode, 0x00400000u); + } + + /** СȫǰǰǷڰȫ*/ + funRet = elm_PrepareInUINT16Array(acID[0],pEnvelop->ACID,pEnvelop->ACCnt); + if (CI_SUCCESS == funRet) + { + /** жǰǷΪȫͷ,ͬǰɸȫ̫ռãӦdzͣµʱôǰɸҲǿԵ*/ + funRet = elm_PrepareInUINT16Array(pEnvelop->ACID[pEnvelop->ACCnt - 1U],acID,acCnt); + ASSER_ERROR(CI_ERROR == funRet,errorCode, 0x10000000u); + } + else + { + /** ɼɸѡ*/ + } + + /** ȡСȫǰ*/ + tmpACId = elm_PrepareACOfMinSafeHeadLoc(pEnvelop->trainID[0]); + ASSER_ERROR(0u == tmpACId,errorCode, 0x08000000u); + + /** ȡгз */ + trainDir = elm_PrepareTrainMinHeadDir(pEnvelop->trainID[0]); + ASSER_ERROR(0u == trainDir,errorCode, 0x04000000u); + + /** ȡ˵λ*/ + funRet = elm_PrepareACLoc(tmpACId,trainDir,&tmpACLoc); + ASSER_ERROR(CI_ERROR == funRet,errorCode, 0x02000000u); + + /** ȡСȫǰλ */ + funRet = elm_PrepareMinSafeHeadLoc(pEnvelop->trainID[0],&tmpLoc); + ASSER_ERROR(CI_ERROR == funRet,errorCode, 0x01000000u); + + screenCheck = elm_PrepareHeadScreenCheck(pEnvelop->trainID[0], tmpLoc,tmpACLoc.endPos,&errorCode); + + if ((0u == errorCode) && (CI_SUCCESS == screenCheck) && ((TRAIN_NVRAM_POS_FLAG_NO == chTrainNvramFlag) + || ((TRAIN_NVRAM_POS_FLAG_YES == chTrainNvramFlag) && (TRAIN_POS_MONITOR_VALID == chTrainPosMonitorState)))) + { + /** ǰUCT */ + elm_AdjustUCTPointAfterScreen(ELM_HEAD,tmpACId,tmpACLoc.endPos,pEnvelop); + + /** ǰ */ + funRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, 0u); + ASSER_ERROR(CI_ERROR == funRet,errorCode, 0x00200000u); + + /** ά־--Լ*/ + ELM_LOG_LOC(ELM_LOG_FATAL,"info:Train%d,delete Head suspicious.",pEnvelop->trainID[0]); + } + else + { + if (ADJUST_UCT == screenCheck) + { + /** ǰUCT */ + elm_AdjustUCTPointAfterScreen(ELM_HEAD,tmpACId,tmpACLoc.endPos,pEnvelop); + } + else + { + /** */ + } + + /** ޷ɸѡ*/ + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:Train%d can't delete Head suspicious.",errorCode,pEnvelop->trainID[0]); + } + } + else + { + if ((TRAIN_NVRAM_POS_FLAG_NO == chTrainNvramFlag) + || ((TRAIN_NVRAM_POS_FLAG_YES == chTrainNvramFlag) && (TRAIN_POS_MONITOR_VALID == chTrainPosMonitorState))) + { + /** ά־--Լ*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Train%d,delete Head suspicious by headTrain%d recover.", pEnvelop->trainID[0], pEnvelop->headTrainID); + + /** ǰ */ + funRet = elm_SetEnvelopeHeadTrainID(pEnvelop->id, 0u); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x00100000u); + } + else + { + + } + } +} + + +/** + * @brief ̬гɸѡ + * @param[in] const EnvelopeStruct* pEnvelop г + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +static void elm_TrainTailScreen(IN const EnvelopeStruct* pEnvelop) +{ + /*- ֲ */ + UINT32 errorCode = 0u; /* */ + UINT8 acCnt = 0u; /* гСȫǰǰ*/ + UINT16 acID[AC_MAXCNT_IN_SWITCH] = {0u}; /* гСȫǰǰ*/ + UINT8 funRet = CI_ERROR; /* ֵ */ + UINT16 tmpACId = 0u; /*id*/ + UINT8 cycleAc = 0u; /*ѭ*/ + UINT8 acStatus = ELM_AC_OCC; /*ռ״̬*/ + UINT8 phyStatus = SECTION_OCCUPY_YES; /*ͨռ״̬*/ + UINT8 trainDir = 0u; + LOD_STRU tmpLoc = {0u}; /*Сȫǰ*/ + ELM_AxisLocStruct tmpACLoc = {0u}; /* ˵λ*/ + UINT8 screenCheck = CI_ERROR; /* ֵ */ + UINT8 chTrainNvramFlag = 0U;/*гNVRAM־*/ + UINT8 chTrainPosMonitorState = 0U;/*гλüල־*/ + + /** ڲУ */ + ASSERT_RET_NO_VALUE(NULL == pEnvelop,0x80000000u); + + /** ǰгͨŻָʱĿɸѡ */ + funRet = elm_TrainScreenByRecover(ELM_TAIL,pEnvelop); + chTrainNvramFlag = GetTrainNvramPosFlag(pEnvelop->trainID[0]); + chTrainPosMonitorState = GetTrainPosMonitorState(pEnvelop->trainID[0]); + + /** ɸѡ */ + if (CI_ERROR == funRet) + { + /** ѯȫ󷽼*/ + acCnt = elm_PrepareNextAcMaxSafeTailLoc(pEnvelop->trainID[0],acID); + ASSER_ERROR((0u == acCnt) || (AC_MAXCNT_IN_SWITCH < acCnt),errorCode, 0x40000000u); + + /*- жϺ󷽼Ƿ */ + for (cycleAc = 0u; cycleAc < acCnt; cycleAc++) + { + /** ȡ״̬ */ + acStatus = elm_PrepareACStatus(acID[cycleAc]); + + /** жǷҪ˳ѭ */ + ASSERT_BREAK(ELM_AC_OCC == acStatus,errorCode,0x20000000u); + + /*ΪΣͨʱҪȫвŸɸͨ*/ + phyStatus = elm_PrepareACofSwichPhyStatus(acID[cycleAc]); + + /** жǷҪ˳ѭ */ + ASSERT_BREAK(SECTION_OCCUPY_YES == phyStatus, errorCode, 0x00400000u); + } + + /** ȫ󷽼Ƿڰȫ*/ + funRet = elm_PrepareInUINT16Array(acID[0],pEnvelop->ACID,pEnvelop->ACCnt); + if (CI_SUCCESS == funRet) + { + /** ȫ󷽼ǷΪȫ󷽼*/ + funRet = elm_PrepareInUINT16Array(pEnvelop->ACID[0],acID,acCnt); + ASSER_ERROR(CI_ERROR == funRet,errorCode, 0x10000000u); + } + else + { + /** ɼɸѡ*/ + } + + /** ȡȫ*/ + tmpACId = elm_PrepareACOfMaxSafeTailLoc(pEnvelop->trainID[0]); + ASSER_ERROR(0u == tmpACId,errorCode, 0x08000000u); + + /** ȡгз */ + trainDir = elm_PrepareTrainMaxTailDir(pEnvelop->trainID[0]); + ASSER_ERROR(0u == trainDir,errorCode, 0x04000000u); + + /** ȡ˵λ*/ + funRet = elm_PrepareACLoc(tmpACId,trainDir,&tmpACLoc); + ASSER_ERROR(CI_ERROR == funRet,errorCode, 0x02000000u); + + /** ȡȫλ */ + funRet = elm_PrepareMaxSafeTailLoc(pEnvelop->trainID[0],&tmpLoc); + ASSER_ERROR(CI_ERROR == funRet,errorCode, 0x01000000u); + + screenCheck = elm_PrepareTailScreenCheck(pEnvelop->trainID[0], tmpLoc, tmpACLoc.startPos, &errorCode); + + if ((0u == errorCode) && (CI_SUCCESS == screenCheck) && ((TRAIN_NVRAM_POS_FLAG_NO == chTrainNvramFlag) + || ((TRAIN_NVRAM_POS_FLAG_YES == chTrainNvramFlag) && (TRAIN_POS_MONITOR_VALID == chTrainPosMonitorState)))) + { + /** UCT */ + elm_AdjustUCTPointAfterScreen(ELM_TAIL,tmpACId,tmpACLoc.startPos,pEnvelop); + + /** ú */ + funRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, 0u); + ASSER_ERROR(CI_ERROR == funRet,errorCode, 0x00200000u); + + /** ά־--Լ*/ + ELM_LOG_LOC(ELM_LOG_FATAL,"info:Train%d,delete Tail suspicious.\n",pEnvelop->trainID[0]); + } + else + { + if (ADJUST_UCT == screenCheck) + { + /** UCT */ + elm_AdjustUCTPointAfterScreen(ELM_TAIL,tmpACId,tmpACLoc.startPos,pEnvelop); + } + else + { + /** */ + } + + /** ޷ɸѡ*/ + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:Train%d can't delete Tail suspicious.",errorCode,pEnvelop->trainID[0]); + } + } + else + { + if ((TRAIN_NVRAM_POS_FLAG_NO == chTrainNvramFlag) + || ((TRAIN_NVRAM_POS_FLAG_YES == chTrainNvramFlag) && (TRAIN_POS_MONITOR_VALID == chTrainPosMonitorState))) + { + /** ά־--Լ*/ + ELM_LOG_LOC(ELM_LOG_FATAL, "info:Train%d,delete Tail suspicious by tailTrain%d recover.", pEnvelop->trainID[0], pEnvelop->tailTrainID); + + /** ǰ */ + funRet = elm_SetEnvelopeTailTrainID(pEnvelop->id, 0u); + ASSER_ERROR(CI_ERROR == funRet, errorCode, 0x00100000u); + } + else + { + ; + } + + } + +} + +/** + * @brief гɸѡ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_TrainScreen(void) +{ + UINT16 cycle = 0u; + UINT8 vaildFlag = ENVELOPE_UNEXIT; + UINT32 errorCode = 0u; + UINT8 comstatus = 0U; + const EnvelopeStruct* pEnvelop = NULL; + + for (cycle = 1u; cycle < ENVELOPE_SUM_MAX; cycle++) + { + /** ȡռʹñ־*/ + vaildFlag = elm_IsEnvelopeExit(cycle); + + if (ENVELOPE_EXIT == vaildFlag) + { + /** ȡĵַ */ + pEnvelop = elm_GetEnvelopeInfoPtr(cycle); + + /** жϰַǷȷ */ + ASSERT_BREAK(NULL == pEnvelop,errorCode,0x08000000u); + /** ȡгͨ״̬ */ + comstatus = elm_PrepareTrainCommStatus(pEnvelop->trainID[0u]); + /*CTͨŽɸѡ*/ + if ((TYPE_CT_ENVELOPE == pEnvelop->envelopeType)&&(ELM_COM_STATUS_OK ==comstatus)) + { + /** жǰǷ */ + if (0u != pEnvelop->headTrainID) + { + /** ǰɸѡ*/ + elm_TrainHeadScreen(pEnvelop); + } + else + { + /** 账 */ + } + + /** жϺǷ*/ + if (0u != pEnvelop->tailTrainID) + { + /** ɸѡ*/ + elm_TrainTailScreen(pEnvelop); + } + else + { + /** 账 */ + } + + } + else + { + /** ɸѡ*/ + } + } + else + { + /** ɸѡ*/ + } + + } + +} + + + +/** + * @brief ȫɸ + * @param[in] + * @param[out] + * @return + * @note + */ +void elm_WLScreenProcess(void) +{ + UINT16 cycle; + UINT8 wlsFlag = WHOLE_LINE_SCREEN_UNVAILD; + UINT8 relEnvelopeCnt= TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] = {0u}; /*гİ*/ + const EnvelopeStruct *pEnvelopeInfo = NULL; + + /** ȡȫɸ־ */ + wlsFlag = wls_GetWLScreenPermitFlag(); + + if (WHOLE_LINE_SCREEN_VAILD == wlsFlag) + { + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + relEnvelopeCnt = elm_GetRelELIdByTrainID(cycle,relEnvelopeID); + + if (1u == relEnvelopeCnt) + { + /** UCT籾δѱ */ + pEnvelopeInfo = elm_GetEnvelopeInfoPtr(relEnvelopeID[0u]); + + if ((NULL != pEnvelopeInfo) && + ((TYPE_CT_ENVELOPE == pEnvelopeInfo->envelopeType) || (TYPE_UCT_ENVELOPE == pEnvelopeInfo->envelopeType))) + { + ELM_LOG(ELM_LOG_FATAL,"info:ELM%d WLS Process,",pEnvelopeInfo->id); + if (LINE_MAX_TRAIN == pEnvelopeInfo->headTrainID) + { + ELM_LOG(ELM_LOG_FATAL," delete Head suspicious,"); + (void)elm_SetEnvelopeHeadTrainID(pEnvelopeInfo->id,0u); + } + else + { + /* */ + } + + if (LINE_MAX_TRAIN == pEnvelopeInfo->tailTrainID) + { + ELM_LOG(ELM_LOG_FATAL," delete Tail suspicious,"); + (void)elm_SetEnvelopeTailTrainID(pEnvelopeInfo->id,0u); + } + else + { + /* */ + } + ELM_LOG(ELM_LOG_FATAL,"\n"); + } + } + else + { + /* 账 */ + } + } + } + else + { + /** */ + } +} diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/UCTEnvelopeTrack.c b/TSCP/src/APP/ciapp/EnvelopeManage/UCTEnvelopeTrack.c new file mode 100644 index 0000000..3bc3b34 --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/UCTEnvelopeTrack.c @@ -0,0 +1,3921 @@ +/****************************************************************************** +** ļ: UCTEnvelopeTrack.c +** : ʵUCT׷ٴ +** עUCTʱʧܣݸºİеȫڵǰͷ/βֻпвŻسԭ + ԭ򱻴ƣҪصȥ߲鵼ȫĴ +*******************************************************************************/ + +#include "EnvelopeLogicProcess.h" +#include "LinkConfigDataManage.h" +#include "AxisSectionConfigDataManage.h" +#include "EnvelopeManageAPI.h" + +#define SWITCH_ZONE_OCC_AND_ERROR 0x55u /* ռ˹ϵ*/ +#define SWITCH_ZONE_FREE_AND_ERROR 0xaau /* ˹ϵ*/ +#define SWITCH_ZONE_OK 0xffu /* ˹ϵȷ*/ + +#define UCT_LEAVE_REFRESH 0x55u /* UCTˢ³ */ +#define UCT_LEAVE_SPLIT 0xaau /* UCTָ */ + + +/*================================̬==============================*/ +static void elm_ProcessByELMLeave(const UINT8 flag, UINT8 ACCnt, UINT16 ACBuff[SECTION_IN_ENVELOPE_SUM_MAX]); +static UINT8 elm_CheckSwitchInEnvelope(const EnvelopeStruct* ptemp); /* ڵĵ*/ + +static UINT8 elm_CheckEnvelopeMergeValid(UINT8 flag,const EnvelopeStruct* pBase, const EnvelopeStruct* pMerge); /* UCT۱ЧԼ */ +static UINT8 elm_UCTEnvelopePreMerge(const EnvelopeStruct* pBase, const EnvelopeStruct* pMerge); /* UCTǰ۱*/ +static UINT8 elm_UCTEnvelopeBackMerge(const EnvelopeStruct* pBase, const EnvelopeStruct* pMerge); /* UCT۱ */ +static UINT8 elm_UCTEnvelopeMerge(UINT8 flag,const EnvelopeStruct* pBase, const EnvelopeStruct* pMerge); /* UCT۱ */ /* UCT۱ */ + + +static void elm_HandleUCTHandoverFinished(UINT16 ownCutAcid,UINT16 OwnsideELMid,UINT16 OutsideELMid); /* UCTлɴ */ +static UINT8 elm_HandleCloneOfHandover(UINT16 OwnACID,UINT8 dirHandover,UINT16 OwnsideELMid,UINT16 OutsideELMid, UINT8 cDirChangePointFlag); /* ֽ㴦¡ */ +static UINT8 elm_SearchNearstTrainInCutPoint(UINT16 OwnACID, UINT8 dirHandover, UINT8 nextACCnt, UINT16 nextACIDBuff[AC_MAXCNT_IN_SWITCH], OUT UINT16 *pOwnsideELMid, OUT UINT16 *pOutsideELMid, UINT8 cDirChangePointFlag); /* ѯֽ㸽ӽг */ +static UINT8 elm_UCTEnvelopeCloneByHandOver(void); /* UCTѱ--гл*/ + +static const EnvelopeStruct* elm_GetUCTRealEnvelope(UINT16 trainid,UINT8 relEnvelopeCnt,IN UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX]); /*ȡָͨŵUCTλƥUCTϢ*/ +static UINT8 elm_CreateRevoverEnvelope(UINT16 trainId,OUT EnvelopeStruct *pMid,OUT UINT8 *cutFlag); /*ڻָͨųλãֳͨų*/ +static UINT8 elm_SplitByUCTRevover(IN const EnvelopeStruct *pBase,OUT EnvelopeStruct *pMid,OUT EnvelopeStruct *pPre,OUT EnvelopeStruct *pBack); /*ڻָͨųİǰUCT*/ +static void elm_ClearFormerUCTEnvelope(IN const EnvelopeStruct *pBase); /*ɾǰUCT*/ +static void elm_AddSplitEnvelopToRAM(IN EnvelopeStruct *pTemp,UINT8 cutFlag); /*Ӱ絽洢*/ +static UINT8 elm_UCTEnvelopeSplit(UINT16 trainId, IN const EnvelopeStruct* pBase); /*ͨųָʱUCT*/ + +static void elm_RefreshUCTofACMapInfo(IN const EnvelopeStruct *ptemp); /** ˢUCTӳ */ +static UINT8 elm_UCTEnvelopeHeadHandle(UINT8 endlineFlag,IN const EnvelopeStruct *ptemp,UINT16 headACId,UINT16 preEnvelopeId, UINT8 cDirChangedFlag); /* UCTͷнӽĴ*/ +static UINT8 elm_UCTEnvelopeHeadMoving(const EnvelopeStruct* ptemp); /* UCTͷƶ*/ +static UINT8 elm_UCTEnvelopeTailHandle(UINT8 endlineFlag,IN const EnvelopeStruct *ptemp,UINT16 tailACId,UINT16 backEnvelopeId, UINT8 cDirChangedFlag); /* UCTβнӽĴ*/ +static UINT8 elm_UCTEnvelopeTailMoving(const EnvelopeStruct* ptemp); /* UCTβƶ*/ +static UINT8 elm_UCTEnvelopeMoving(const EnvelopeStruct* ptemp); /* UCTUCTн */ + +static UINT8 elm_ConvertToUCTCheck(const EnvelopeStruct* ptemp); /** CTתUCT */ +static UINT8 elm_UCTEnvelopeCreate(const EnvelopeStruct* ptemp); /* UCT紴 */ +static UINT8 elm_UCTEnvelopeRefresh(const EnvelopeStruct* ptemp); + +static UINT8 elm_UCTRecoverCheckElmNear(const UINT16 trainId, OUT UINT8 szFlag[TRAIN_REL_ENVELOPE_SUM_MAX], const UINT8 chEnvelopeCount, const UINT16 szEnvelopeId[TRAIN_REL_ENVELOPE_SUM_MAX]); /* UCTָڰѯ */ + +static UINT8 elm_UCTToUKTCheck(const EnvelopeStruct* ptemp); /*ȫͨųϢUCTתUKTǷ*/ + +/** + * @brief ļᴦ + * @param[in] UINT8 ACCnt + * @param[in] UINT16 ACBuff[SECTION_IN_ENVELOPE_SUM_MAX] ID洢 + * @param[out] + * @return + * @note 1UCTָʱسسμϣᵼ° + 2UCTгָسسμϣᵼ° + */ +static void elm_ProcessByELMLeave(const UINT8 flag, UINT8 ACCnt,UINT16 ACBuff[SECTION_IN_ENVELOPE_SUM_MAX]) +{ + UINT32 errorCode = 0u; + UINT8 cycle = 0u; + UINT8 acOCcStatus = ELM_AC_OCC; + UINT8 passFlag = AAM_UT_PASS; + UINT8 funRtn = CI_ERROR; + + /** ڲУ */ + ASSERT_RET_NO_VALUE(ACCnt >= SECTION_IN_ENVELOPE_SUM_MAX,0x80000000u); + ASSERT_RET_NO_VALUE(NULL == ACBuff,0x40000000u); + + /** ļ޺óͨ״̬ΪռõļUKT */ + for (cycle = 0u; cycle < ACCnt; cycle++) + { + /** ȡռ״̬ */ + acOCcStatus = elm_PrepareACStatus(ACBuff[cycle]); + + /** ȡóͨ־λ */ + passFlag = aam_GetACPassTrainFlag(ACBuff[cycle]); + + /* жǷUKT */ + if ((ELM_AC_OCC == acOCcStatus) && (AAM_CT_PASS != passFlag)) + { + /*- ռļUKT */ + funRtn = elm_AddUKTEnvelopeInAC(ACBuff[cycle]); + + /** жǷִȷ */ + if (CI_ERROR == funRtn) + { + /** ִдҪøģ޷־λ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:ELM Leave Process,ac%d add UKT error.", errorCode, ACBuff[cycle])); + } + else + { + /** ȷ*/ + } + } + else if ((ELM_AC_OCC == acOCcStatus) && (UCT_LEAVE_SPLIT == flag)) + { + /** ״̬ */ + aam_SetACEnterRedun(ACBuff[cycle]); + } + else + { + /** */ + } + } +} + +/** + * @brief ڵĵ״̬ + * @param[in] const EnvelopeStruct* ptemp Ϣָ + * @param[out] + * @return SWITCH_ZONE_OCC_AND_ERROR ռ˹ϵ + SWITCH_ZONE_FREE_AND_ERROR ˹ϵ + SWITCH_ZONE_OK ˹ϵȷ + * @note + */ +static UINT8 elm_CheckSwitchInEnvelope(const EnvelopeStruct* ptemp) +{ + UINT8 ret = SWITCH_ZONE_OCC_AND_ERROR; + UINT8 cycle = 0u; + UINT8 switchFlag = CI_ERROR; + UINT8 OccStatus = ELM_AC_OCC; + UINT8 midStatus = 0u; + UINT32 errorCode = 0u; + + /** ڲ */ + ASSERT_RET_VALUE(NULL == ptemp,ret,0x80000000u); + + /** еļ */ + for (cycle = 0u; cycle < ptemp->ACCnt;cycle++) + { + /** ȡռ״̬ */ + OccStatus = elm_PrepareACStatus(ptemp->ACID[cycle]); + + /** ȡĵ˹ϵ */ + switchFlag = elm_PrepareCheckACofSwichPos(ptemp->ACID[cycle]); + + if (ELM_AC_OCC == OccStatus) + { + /** ռλòϣѭ */ + ASSERT_BREAK(CI_ERROR == switchFlag,errorCode,0x20000000u); + } + else + { + if (CI_ERROR == switchFlag) + { + /** λò,ѭ */ + midStatus = 1u; + } + else + { + /** ϵ*/ + } + } + } + + /** úֵ */ + if (cycle == ptemp->ACCnt) + { + ret = (1u == midStatus) ? SWITCH_ZONE_FREE_AND_ERROR : SWITCH_ZONE_OK; + } + else + { + /** */ + } + + return ret; +} + + +/** + * @brief жǷ۱ + * @param[in] UINT8 flag, ۱䷽ʽELM_HEAD ׼ǰڿɾ۱磬ELM_TAIL ׼󷽴ڿɾ۱磩 + * @param[in] EnvelopeStruct* pBase, ׼ + * @param[in] EnvelopeStruct* pMerge, ϲ + * @param[out] + * @return 0x00u ʧ,ܺϲ + 0x55u سɹ,гȫһ + 0xaau سɹ,гȫһ + * @note + * UCTʱڸٵгȫһ£ɾ۱һUCT + * UCTʱڸٵгȫһ£ɾ۱һUCT + * UCTʱڵгȥغγгУɾ۱һUCT + * ʱ۱ + */ +static UINT8 elm_CheckEnvelopeMergeValid(UINT8 flag, const EnvelopeStruct* pBase, const EnvelopeStruct* pMerge) +{ + UINT8 ret = CI_ERROR; + UINT8 baseIndex = 0u; + UINT8 mergeIndex = 0u; + UINT8 cycleBase = 0u; + UINT8 cycleMerge = 0u; + UINT8 mergeFlag = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pBase,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == pMerge,ret,0x40000000u); + ASSERT_RET_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag),ret,0x20000000u); + + /** жڵгǷȫһ*/ + if (pBase->trianCnt == pMerge->trianCnt) + { + for (cycleBase = 0u; cycleBase < pBase->trianCnt;cycleBase++) + { + if (pBase->trainID[cycleBase] != pMerge->trainID[cycleBase]) + { + break; + } + } + + if (cycleBase == pBase->trianCnt) + { + /** ˵ڵгȫһ£Ժϲ*/ + ret = 0x55u; + } + else + { + /** ȫһ£ж*/ + } + } + else + { + /** ȫһ*/ + } + + if (0x55u != ret) + { + /** ˵ڵгȫһ£ҪжǷϲ */ + if (ELM_HEAD == flag) + { + baseIndex = 0u; + for (cycleMerge = 0u; cycleMerge < pMerge->trianCnt;cycleMerge++) + { + if ((0u == mergeFlag) && (pMerge->trainID[cycleMerge] != pBase->trainID[0u])) + { + /** */ + } + else + { + /** ͬг*/ + mergeFlag = 1u; + + if ((pMerge->trainID[cycleMerge] != pBase->trainID[baseIndex++])) + { + /** ˵ڲͬгУѭ*/ + break; + } + } + } + + /** ÷ֵ */ + ASSERT_SETRET(cycleMerge == pMerge->trianCnt,ret,0xaau,0x00u); + } + else + { + mergeIndex = 0u; + for (cycleBase = 0u; cycleBase < pBase->trianCnt;cycleBase++) + { + if ((0u == mergeFlag) && (pBase->trainID[cycleBase] != pMerge->trainID[0u])) + { + /** */ + } + else + { + /** ͬг*/ + mergeFlag = 1u; + + if ((pBase->trainID[cycleBase] != pMerge->trainID[mergeIndex++])) + { + /** ˵ڲͬгУѭ*/ + break; + } + } + } + + /** ÷ֵ */ + ASSERT_SETRET(cycleMerge == pBase->trianCnt,ret,0xaau,0x00u); + } + + } + else + { + /** ȫһ */ + } + + return ret; +} + + +/** + * @brief UCTǰ۱ + * @param[in] EnvelopeStruct* pBase, ׼ + * @param[in] EnvelopeStruct* pMerge, ǰ + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS سɹ + * @note + * ׼ǰ۱ڰмܲس´ + * 1׼ǰͬУ緶Χϲ׼ڵгתɺ˿ɣǰڵгб + * 2׼ǰ練У緶Χϲ׼ڵгڵǰڵгǰڵгתɻ׼ǰ,׼ڵгб֣ + * 3׼ǰ練У緶Χϲ׼ڵгСǰڵг׼ڵгתǰǰɣǰڵгб֣ + * ׼ǰ۱Ҿ۱ڰм䲻سֱӽо۱䣬緶Χϲڵгкϲ + */ +static UINT8 elm_UCTEnvelopePreMerge(const EnvelopeStruct* pBase, const EnvelopeStruct* pMerge) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 dirCheck = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pBase,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == pMerge,ret,0x40000000u); + + /** ĿǰΪ + 緽ͬɾUCT絼ΪUKTǰUCTȾϺ˿ + 緽෴ɾUCT絼ΪUKTǰUCTȾǰ˿ + */ + dirCheck = elm_DirIsSameELMWithELM(pBase,pMerge); + if (ELM_DIR_SAME == dirCheck) + { + /** ǰú˿ */ + funRtn = elm_SetEnvelopeTailTrainID(pMerge->id,LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + /** ۱书ʱԤ۱ʱɾUCT */ + ELM_LOG(ELM_LOG_FATAL,"info:Delete UCT%d because of Pre UCT:%d SameDir Nearby.\n",pBase->id,pMerge->id); + funRtn = elm_DeleteCTOrUCTEnvelope(pBase->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x10000000u); + } + else + { + /** ǰǰ˿ */ + funRtn = elm_SetEnvelopeHeadTrainID(pMerge->id,LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x08000000u); + + /** ۱书ʱԤ۱ʱɾUCT */ + ELM_LOG(ELM_LOG_FATAL,"info:Delete both UCT:%d-%d because of Pre UCT:%d unSameDir Nearby.\n",pBase->id,pMerge->id,pMerge->id); + funRtn = elm_DeleteCTOrUCTEnvelope(pBase->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x04000000u); + funRtn = elm_DeleteCTOrUCTEnvelope(pMerge->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x02000000u); + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:UCT pre Merge error.",errorCode)); + return ret; +} + +/** + * @brief UCT۱ + * @param[in] EnvelopeStruct* pBase, ׼ + * @param[in] EnvelopeStruct* pMerge, + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS سɹ + * @note + * ׼ǰ۱ڰмܲس´ + * 1׼ǰͬ/У緶Χϲڵгתɺ˿ɣ׼ڵгб + * ׼ǰ۱Ҿ۱ڰм䲻سֱӽо۱䣬緶Χϲڵгкϲ + */ +static UINT8 elm_UCTEnvelopeBackMerge(const EnvelopeStruct* pBase, const EnvelopeStruct* pMerge) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pBase,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == pMerge,ret,0x40000000u); + + /** ĿǰΪ + 緽ͬ/෴ɾUCT絼ΪUKTǰUCTȾϺ˿ + */ + + /** ǰú˿ */ + funRtn = elm_SetEnvelopeTailTrainID(pBase->id,LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + /** ۱书ʱԤ۱ʱɾUCT */ + ELM_LOG(ELM_LOG_FATAL,"info:Delete UCT%d because of back UCT:%d Nearby.\n",pMerge->id,pBase->id); + funRtn = elm_DeleteCTOrUCTEnvelope(pMerge->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x08000000u); + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:UCT back Merge error.",errorCode)); + return ret; +} + +/** + * @brief UCT۱ + * @param[in] UINT8 flag, ۱䷽ʽ0x55 ׼ǰڿɾ۱磬0xaa ׼󷽴ڿɾ۱磩 + * @param[in] EnvelopeStruct* pBack, + * @param[in] EnvelopeStruct* pFront, ǰ + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS سɹ + * @note + */ +static UINT8 elm_UCTEnvelopeMerge(UINT8 flag,const EnvelopeStruct* pBase, const EnvelopeStruct* pMerge) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT32 errorCode = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pBase,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == pMerge,ret,0x40000000u); + ASSERT_RET_VALUE((ELM_HEAD != flag) && (ELM_TAIL != flag),ret,0x20000000u); + + /** ǰ۱ */ + if (ELM_HEAD == flag) + { + /** ǰ۱*/ + funRtn = elm_UCTEnvelopePreMerge(pBase,pMerge); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + } + else + { + + /** ۱*/ + funRtn = elm_UCTEnvelopeBackMerge(pBase,pMerge); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x08000000u); + } + + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + + +/** + * @brief UCTлɴ + * @param[in] UINT16 ownCutAcid ֽ㴦ID + * @param[in] UINT16 OwnsideELMid ֽ㴦ӽֽ㴦İID + * @param[in] UINT16 OutsideELMid ֽ㴦Էӽֽ㴦İID + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS سɹ + * @note + */ +static void elm_HandleUCTHandoverFinished(UINT16 ownCutAcid,UINT16 OwnsideELMid,UINT16 OutsideELMid) +{ + UINT32 errorCode = 0u; + UINT8 DelValid = 0xffu; + UINT8 cycle = 0u; + UINT8 acOccStatus = ELM_AC_OCC; + UINT8 funRtn = CI_ERROR; + UINT8 envelopeCnt = 0u; /* */ + UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] = {0u}; /*ID*/ + const EnvelopeStruct *pOwn = NULL; + const EnvelopeStruct *pNext = NULL; + + /** жǷҪлȥUCT */ + pOwn = elm_GetEnvelopeInfoPtr(OwnsideELMid); + pNext = elm_GetEnvelopeInfoPtr(OutsideELMid); + + if ((NULL != pOwn) && (NULL != pNext) && (TYPE_UCT_ENVELOPE == pOwn->envelopeType)) + { + /** жUCTǷȫ */ + for (cycle = 0u; cycle < pOwn->ACCnt;cycle++) + { + acOccStatus = elm_PrepareACStatus(pOwn->ACID[cycle]); + ASSERT_BREAK(ELM_AC_OCC == acOccStatus,errorCode,0u); + } + + if (cycle == pOwn->ACCnt) + { + if ((TYPE_CT_ENVELOPE == pNext->envelopeType) && (1u == pOwn->trianCnt) && + (pNext->trainID[0u] == pOwn->trainID[0u])) + { + DelValid = 0x55u; + } + else if(TYPE_UCT_ENVELOPE == pNext->envelopeType) + { + /** ۱ұегڶԷUCT */ + funRtn = elm_CheckEnvelopeMergeValid(ELM_HEAD,pOwn,pNext); + + /** ðǷɾ */ + DelValid = (0x55u == funRtn) ? 0x55u : 0xffu; + + } + else if (TYPE_UKT_ENVELOPE == pNext->envelopeType) + { + /** ˵Է޷¡UKT׷٣Ҳɾ*/ + DelValid = 0x55u; + } + else + { + /** 账 */ + } + + if (0x55u == DelValid) + { + ELM_LOG(ELM_LOG_FATAL,"info:UCT%d handover finished.\n",pOwn->id); + /* лóͨ */ + for (cycle = 0u; cycle < pOwn->ACCnt; cycle++) + { + (void)aam_ClearACPassTrainFlag(pOwn->ACID[cycle]); + } + elm_ClearFormerUCTEnvelope(pOwn); + } + else + { + /** 账 */ + } + } + else + { + /** UCTǿ,账 */ + } + } + else + { + /** ѯֽ㴦ϵİϢ */ + envelopeCnt = elm_MergeEnvelope(&ownCutAcid,1u,arEnvelopID); + + if (TRAIN_SUM_MAX_IN_OC == envelopeCnt) + { + /** ѯ󣬲*/ + } + else + { + /** ʱֽUCTϲʱŻ */ + pOwn = elm_GetEnvelopeInfoPtr(arEnvelopID[0u]); + if ((NULL != pOwn) && (TYPE_UCT_ENVELOPE == pOwn->envelopeType) && (1u == envelopeCnt)) + { + ELM_LOG(ELM_LOG_FATAL,"info:UCT%d handover finished.\n",pOwn->id); + /* лóͨ */ + for (cycle = 0u; cycle < pOwn->ACCnt; cycle++) + { + (void)aam_ClearACPassTrainFlag(pOwn->ACID[cycle]); + } + elm_ClearFormerUCTEnvelope(pOwn); + } + else + { + /** */ + } + } + } +} + +/** + * @brief ֽ㴦¡ + * @param[in] UINT16 OwnACID ֽ㱾 + * UINT8 dirHandover ƽ + * UINT16 OwnsideELMid ֽ㴦ӽֽ㴦İID + * UINT8 cDirChangePointFlag ֽǷΪ仯־ + * @param[in] UINT16 OutsideELMid ֽ㴦Էӽֽ㴦İID + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS سɹ + * @note + */ +static UINT8 elm_HandleCloneOfHandover(UINT16 OwnACID, UINT8 dirHandover, UINT16 OwnsideELMid, UINT16 OutsideELMid, UINT8 cDirChangePointFlag) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 dirCheck = 0u; + UINT8 cloneFlag = 0u; + const EnvelopeStruct* pOwnSide = NULL; + const EnvelopeStruct* pOutSide = NULL; + EnvelopeStruct cloneElm = { 0u }; + EnvelopeStruct tempElm = { 0u }; + ELM_AxisLocStruct AcLoc = { 0u }; + ELM_AxisLocStruct cOwnAcLoc = { 0u }; + UINT8 cDirChangeNum = 0U; /*仯*/ + UINT8 cDirChangeNumBtwCAndOwn = 0U; /*ֽᵽķ仯*/ + UINT8 cOwnQueryDir = 0U; + UINT8 cOutQueryDir = 0U; + UINT8 cTempElmFlag = FLAG_UNSET; + UINT16* pLinkIDBuf = NULL; + ELM_TrainSafeLocStruct safeLoc = { 0U }; + UINT8 chFunRtn = CI_ERROR; + + /** ڲУ*/ + ASSERT_RET_VALUE(((0U == OwnACID) || (AXIS_SECTION_SUM_MAX < OwnACID)), ret, 0x80000000u); + ASSERT_RET_VALUE((ELM_DIR_SAME != dirHandover) && (ELM_DIR_CONVERT != dirHandover), ret, 0x80000000u); + ASSERT_RET_VALUE(((DIRECTIONPOINT_FLAG_VALID != cDirChangePointFlag) && (DIRECTIONPOINT_FLAG_INVALID != cDirChangePointFlag)), ret, 0x80000000u); + + /** ȡϢ */ + pOwnSide = elm_GetEnvelopeInfoPtr(OwnsideELMid); + pOutSide = elm_GetEnvelopeInfoPtr(OutsideELMid); + + if ((NULL == pOutSide) || (TYPE_UCT_ENVELOPE != pOutSide->envelopeType)) + { + /** ˵ⷽUCTӽ */ + } + else if ((NULL == pOwnSide) || (TYPE_UCT_ENVELOPE != pOwnSide->envelopeType)) + { + /** ˵ްռ,¡ֽⷽUCTϢ */ + funRtn = CommonMemCpy(&cloneElm, (UINT32)sizeof(EnvelopeStruct), pOutSide, (UINT32)sizeof(EnvelopeStruct)); + ASSER_ERROR(0u == funRtn, errorCode, 0x40000000u); + + /*ڰʱʱ*/ + if (NULL == pOwnSide) + { + /*Ϊգʱ*/ + funRtn = elm_CreatTempUKTEnvelope(OwnACID, EMAP_SAME_DIR, &tempElm); + pOwnSide = &tempElm; /*ʱΪֽ㴦磬ڲѯԷķ仯*/ + + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00400000u); + ASSERT_SETRET(CI_ERROR == funRtn, cTempElmFlag, FLAG_UNSET, FLAG_SET); /*ɹλ*/ + } + else + { + /*ڰ磬ʱ*/ + } + + /*ȷԷڷֽ㴦㷽*/ + cDirChangeNum = elm_PrepareDirChangNum(&(pOutSide->startPos), &(pOwnSide->startPos)); /*жϷ仯*/ + + /*ѯ絽ֽ㷽任*/ + pLinkIDBuf = GetAxisLinkIdBuf(OwnACID); + cOwnAcLoc.startPos.Lnk = pLinkIDBuf[0U]; + cOwnAcLoc.startPos.Off = 1u; + cDirChangeNumBtwCAndOwn = elm_PrepareDirChangNum(&(cOwnAcLoc.startPos), &(pOwnSide->startPos)); /*ȷֽ㵽֮ķ仯*/ + + cDirChangeNum = cDirChangeNum - cDirChangeNumBtwCAndOwn; /*ǿֽȻз仯㣬ᵼ¶Էʼ˵ķת*/ + + cOwnQueryDir = elm_PrepareDirByChangeNum(pOutSide->startPos.Dir, cDirChangeNum); /*ȷ㷽򣬿ǶԷ仯Լֽ㴦仯ķCTڱַ仯ظ*/ + + if ((0U != cDirChangeNum) && (DIRECTIONPOINT_FLAG_VALID == cDirChangePointFlag)) + { + cDirChangeNum--; /*ѯԷķ仯ʱֽ㣬ֽΪ仯㣬ȥ*/ + } + else + { + /**/ + } + cOutQueryDir = elm_PrepareDirByChangeNum(pOutSide->startPos.Dir, cDirChangeNum); /*ȷԷڶԷֽᴦ㷽*/ + + /** жǷ񱾷ͨųڷĽӽUCT IDһһclone */ + if (TYPE_CT_ENVELOPE == pOwnSide->envelopeType) + { + + if (dirHandover != cOutQueryDir) + { + cloneFlag = (cloneElm.trainID[0u] == pOwnSide->trainID[0u]) ? 0u : 1u; + } + else + { + + cloneFlag = (cloneElm.trainID[cloneElm.trianCnt - 1u] == pOwnSide->trainID[0u]) ? 0u : 1u; + } + } + else if ((0u != pOutSide->headTrainID) && (0u != pOutSide->tailTrainID)) + { + /** ⷽUCTǰɣп¡ */ + cloneFlag = 0u; + ELM_LOG(ELM_LOG_FATAL, "info:can't Clone because UCT%d has head and tail suspicious.\n", pOutSide->id); + } + else + { + /** ռް */ + cloneFlag = 1u; + } + + ASSER_ERROR((0U == cOwnQueryDir) || (0U == cOutQueryDir), errorCode, 0x00200000u); + ASSERT_SETRET((0U == cOwnQueryDir) || (0U == cOutQueryDir), cloneFlag, 0U, cloneFlag); /*֤ЧЧ*/ + + if (1u == cloneFlag) + { + /** λ */ + funRtn = elm_PrepareACLoc(OwnACID, cOwnQueryDir, &AcLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + /** ʼUCTλ */ + cloneElm.startPos = AcLoc.startPos; + cloneElm.endPos = AcLoc.endPos; + cloneElm.startPos.Dir = cOwnQueryDir; + cloneElm.endPos.Dir = cOwnQueryDir; + + /** ݱUCTλ */ + if ((NULL != pOwnSide) && (TYPE_CT_ENVELOPE == pOwnSide->envelopeType)) + { + /** ѯķ*/ + dirCheck = elm_DirIsSameELMWithELM(&cloneElm, pOwnSide); + + /** ȡλ*/ + if (dirHandover == cOutQueryDir) + { + if (ELM_DIR_SAME == dirCheck) + { + chFunRtn = elm_PrepareTrainSafeLoc(pOwnSide->trainID[0U], &safeLoc); + if (CI_SUCCESS == chFunRtn) + { + cloneElm.endPos = safeLoc.startPos; + } + else + { + ; /*ֳʼλ*/ + } + } + else + { + chFunRtn = elm_PrepareTrainSafeLoc(pOwnSide->trainID[0U], &safeLoc); + if (CI_SUCCESS == chFunRtn) + { + cloneElm.endPos = safeLoc.endPos; + } + else + { + ; /*ֳʼλ*/ + } + } + } + else + { + if (ELM_DIR_SAME == dirCheck) + { + chFunRtn = elm_PrepareTrainSafeLoc(pOwnSide->trainID[0U], &safeLoc); + if (CI_SUCCESS == chFunRtn) + { + cloneElm.startPos = safeLoc.endPos; + } + else + { + ; /*ֳʼλ*/ + } + } + else + { + chFunRtn = elm_PrepareTrainSafeLoc(pOwnSide->trainID[0U], &safeLoc); + if (CI_SUCCESS == chFunRtn) + { + cloneElm.startPos = safeLoc.startPos; + } + else + { + ; /*ֳʼλ*/ + } + } + } + } + else + { + /** Ҫ */ + } + /*CTʱķ*/ + cloneElm.startPos.Dir = cOwnQueryDir; + cloneElm.endPos.Dir = cOwnQueryDir; + /** °*/ + funRtn = CommonMemSet(cloneElm.ACID, (UINT32)(sizeof(UINT16)*SECTION_IN_ENVELOPE_SUM_MAX), 0u, (UINT32)(sizeof(UINT16)*SECTION_IN_ENVELOPE_SUM_MAX)); + cloneElm.ACCnt = elm_PrepareACBtwPoints(cloneElm.startPos, cloneElm.endPos, &(cloneElm.ACID[0])); + ASSER_ERROR((0u == funRtn) || (0u == cloneElm.ACCnt), errorCode, 0x10000000u); + + /** ӵڴ*/ + elm_AddSplitEnvelopToRAM(&cloneElm, ELM_NO_CUT); + ASSER_DEBUG(0u == errorCode, ELM_LOG(ELM_LOG_FATAL, "info:Clone UCT%d base UCT%d.\n", cloneElm.id, pOutSide->id)); + + /** ǰ˼ */ + if ((NULL == pOwnSide) || ((TYPE_UKT_ENVELOPE == pOwnSide->envelopeType) && (FLAG_SET == cTempElmFlag))) + { + /** 账 */ + } + else if ((TYPE_UKT_ENVELOPE == pOwnSide->envelopeType) && (FLAG_UNSET == cTempElmFlag)) /*ʱUKT*/ + { + if (dirHandover == cOutQueryDir) + { + funRtn = elm_SetEnvelopeHeadTrainID(cloneElm.id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000u); + } + else + { + funRtn = elm_SetEnvelopeTailTrainID(cloneElm.id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000u); + } + } + else + { + /** ѯķ*/ + dirCheck = elm_DirIsSameELMWithELM(&cloneElm, pOwnSide); + + /** ȡλ*/ + if (dirHandover == cOutQueryDir) + { + if (((ELM_DIR_CONVERT == dirCheck) && ((cloneElm.trainID[cloneElm.trianCnt - 1u] == pOwnSide->headTrainID) || (0u == pOwnSide->headTrainID))) + || ((ELM_DIR_SAME == dirCheck) && ((cloneElm.trainID[cloneElm.trianCnt - 1u] == pOwnSide->tailTrainID) || (0u == pOwnSide->tailTrainID)))) + { + /** 账*/ + } + else + { + funRtn = elm_SetEnvelopeHeadTrainID(cloneElm.id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x04000000u); + } + } + else + { + if (((ELM_DIR_SAME == dirCheck) && ((cloneElm.trainID[0u] == pOwnSide->headTrainID) || (0u == pOwnSide->headTrainID))) + || ((ELM_DIR_CONVERT == dirCheck) && ((cloneElm.trainID[0u] == pOwnSide->tailTrainID) || (0u == pOwnSide->tailTrainID)))) + { + /** 账*/ + } + else + { + funRtn = elm_SetEnvelopeTailTrainID(cloneElm.id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x02000000u); + } + } + } + + /** ԵUKT */ + if ((NULL != pOwnSide) && (TYPE_UKT_ENVELOPE == pOwnSide->envelopeType) && (FLAG_UNSET == cTempElmFlag)) /*ʱUKTó*/ + { + /** ԵUCT */ + funRtn = elm_DeleteUKTEnvelope(pOwnSide); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x01000000u); + } + else + { + /** 账 */ + } + } + else + { + /** Ҫ¡ */ + } + } + else + { + /** ѯķ*/ + dirCheck = elm_DirIsSameELMWithELM(pOutSide, pOwnSide); + + /*ȷԷڷֽ㴦㷽*/ + cDirChangeNum = elm_PrepareDirChangNum(&(pOutSide->startPos), &(pOwnSide->startPos)); /*жϷ仯*/ + + /*ѯ絽ֽ㷽任*/ + pLinkIDBuf = GetAxisLinkIdBuf(OwnACID); + cOwnAcLoc.startPos.Lnk = pLinkIDBuf[0U]; + cOwnAcLoc.startPos.Off = 1u; + cDirChangeNumBtwCAndOwn = elm_PrepareDirChangNum(&(cOwnAcLoc.startPos), &(pOwnSide->startPos)); /*ȷֽ㵽֮ķ仯*/ + + cDirChangeNum = cDirChangeNum - cDirChangeNumBtwCAndOwn; /*ǿֽȻз仯㣬ᵼ¶Էʼ˵ķת*/ + + if ((0U != cDirChangeNum) && (DIRECTIONPOINT_FLAG_VALID == cDirChangePointFlag)) + { + cDirChangeNum--; /*ѯԷķ仯ʱֽ㣬ֽΪ仯㣬ȥ*/ + } + else + { + /**/ + } + cOutQueryDir = elm_PrepareDirByChangeNum(pOutSide->startPos.Dir, cDirChangeNum); /*ȷԷڶԷֽᴦ㷽*/ + + if (0U != cOutQueryDir) + { + if ((ELM_DIR_SAME == dirCheck) && (1u == pOutSide->trianCnt) && (pOwnSide->trianCnt == pOutSide->trianCnt) && (pOwnSide->trainID[0u] == pOutSide->trainID[0u])) + { + /** ͬһUCTлɱ־Ⱦ */ + if ((dirHandover != cOutQueryDir) && (0u != pOutSide->headTrainID)) + { + (void)elm_SetEnvelopeHeadTrainID(pOwnSide->id, LINE_MAX_TRAIN); + } + else if ((dirHandover == cOutQueryDir) && (0u != pOutSide->tailTrainID)) + { + (void)elm_SetEnvelopeTailTrainID(pOwnSide->id, LINE_MAX_TRAIN); + } + else + { + /** 账 */ + } + } + else + { + ELM_LOG(ELM_LOG_FATAL, "info:UCT%d can't merge UCT%d,becasue:%02x,%d-%d,%d-%d.\n", pOwnSide->id, pOutSide->id, dirCheck, pOwnSide->trianCnt, \ + pOutSide->trianCnt, pOwnSide->trainID[0u], pOutSide->trainID[0u]); + + /** ɾUCT */ + funRtn = elm_DeleteCTOrUCTEnvelope(OwnsideELMid); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00800000u); + if (dirHandover == cOutQueryDir) + { + (void)elm_SetEnvelopeHeadTrainID(pOutSide->id, LINE_MAX_TRAIN); + } + else + { + (void)elm_SetEnvelopeTailTrainID(pOutSide->id, LINE_MAX_TRAIN); + } + } + } + else + { + ASSER_ERROR(0U == cOwnQueryDir, errorCode, 0x00100000u); + } + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Clone UCT%d base next UCT%d error.\n", errorCode, pOutSide->id)); + return ret; +} + +/** + * @brief ѯֽ㸽ӽг + * @param[in] UINT16 OwnACID ֽ㴦 + * @param[in] UINT8 dirHandover 뵽ķ + * @param[in] UINT8 nextACCnt Էֽ㴦 + * @param[in] UINT16 nextACIDBuff[AC_MAXCNT_IN_SWITCH] Էֽ㴦ID + * @param[in] cDirChangePointFlag 仯־ + * @param[out] UINT16 *pOwnsideELMid ӽֽ㴦гID + * @param[out] UINT16 *pOutsideELMid Էӽֽ㴦гID + * @return CI_ERROR ʧ + CI_SUCCESS سɹ + * @note + */ +static UINT8 elm_SearchNearstTrainInCutPoint(UINT16 OwnACID, UINT8 dirHandover, UINT8 nextACCnt, UINT16 nextACIDBuff[AC_MAXCNT_IN_SWITCH], OUT UINT16 *pOwnsideELMid, OUT UINT16 *pOutsideELMid, UINT8 cDirChangePointFlag) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 cycle = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 envelopeCnt = 0u; /* */ + UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] = { 0u }; /*ID*/ + const EnvelopeStruct* pTemp = NULL; + const EnvelopeStruct* pOut = NULL; + UINT16 preEnvelopeid = 0u; + UINT16 backEnvelopeid = 0u; + UINT32 disHead = 0u; + UINT32 disTail = 0u; + UINT32 minDisBtwHeadAndTail = 0u; + UINT32 minDis = 0xffffffffu; + ELM_AxisLocStruct AcLoc = { 0u }; + UINT8 includeCnt = 0u; + UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] = { 0u }; /** غϵİid */ + UINT16 szAxleIncLinkIdBuff[AXIS_INCLUDE_LINK_SUM_MAX] = { 0u }; + LOD_STRU lodStrPointA = { 0U }; + LOD_STRU lodStrPointB = { 0U }; + UINT8 cDirChangeNum = 0U; /*仯*/ + UINT8 cQueryDir = 0U; + UINT8 dirOwnToC = 0U; /*Էֽ㣬ڱڵķ*/ + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == nextACIDBuff) || (NULL == pOwnsideELMid) || (NULL == pOutsideELMid), ret, 0x80000000u); + ASSERT_RET_VALUE((ELM_DIR_SAME != dirHandover) && (ELM_DIR_CONVERT != dirHandover), ret, 0x40000000u); + ASSERT_RET_VALUE((0u == nextACCnt) && (AC_MAXCNT_IN_SWITCH <= nextACCnt), ret, 0x20000000u); + + /** ѯԷֽ㴦ϵİϢ */ + envelopeCnt = elm_MergeEnvelope(nextACIDBuff, nextACCnt, arEnvelopID); + + /** жϰǷUCT */ + for (cycle = 0u; cycle < envelopeCnt; cycle++) + { + /** ȡĵַָ */ + pTemp = elm_GetEnvelopeInfoPtr(arEnvelopID[cycle]); + + if ((NULL != pTemp) && (TYPE_UCT_ENVELOPE == pTemp->envelopeType)) + { + /** UCT */ + break; + } + else + { + /** */ + } + } + + if (cycle == envelopeCnt) + { + /** UCTӽ账 */ + *pOwnsideELMid = 0u; + *pOutsideELMid = 0u; + } + else if ((cycle != envelopeCnt) && (1u == nextACCnt)) + { + /*³ʼ*/ + if (DIRECTIONPOINT_FLAG_VALID == cDirChangePointFlag) + { + dirOwnToC = ~dirHandover; /*з仯㣬ҪʼѰĵķ*/ + } + else + { + dirOwnToC = dirHandover; /*޷仯㣬ת*/ + } + /** λ */ + funRtn = elm_PrepareACLoc(OwnACID, dirOwnToC, &AcLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + for (cycle = 0; cycle < envelopeCnt; cycle++) + { + /** ȡUCTĵַָ */ + pTemp = elm_GetEnvelopeInfoPtr(arEnvelopID[cycle]); + ASSERT_BREAK(NULL == pTemp, errorCode, 0x08000000u); + + /** ȡյֽľ */ + disHead = elm_PrepareDistanceBtwPoints(pTemp->endPos, AcLoc.startPos); + disTail = elm_PrepareDistanceBtwPoints(pTemp->startPos, AcLoc.startPos); + minDisBtwHeadAndTail = disHead > disTail ? disTail : disHead; + + if (minDis > minDisBtwHeadAndTail) + { + pOut = pTemp; + minDis = minDisBtwHeadAndTail; + } + else + { + /** */ + } + } + + /** жǷѯɹ */ + ASSER_ERROR(NULL == pOut, errorCode, 0x04000000u); + if (0u != errorCode) + { + /** ˵ʧ*/ + } + else if (TYPE_UCT_ENVELOPE == pOut->envelopeType) + { + /** ⷽid */ + *pOutsideELMid = pOut->id; + + /** ȡUCTĵַָ */ + pTemp = elm_GetEnvelopeInfoPtr(arEnvelopID[0u]); + + /** ѯֽ㴦ϵİϢ */ + envelopeCnt = elm_MergeEnvelope(&OwnACID, 1u, arEnvelopID); + + /** ѯUCTǰг*/ + funRtn = elm_SearchNearestEnvelope(pOut, arEnvelopID, envelopeCnt, &preEnvelopeid, &backEnvelopeid, &includeCnt, includeELMid); + ASSER_ERROR(CI_SUCCESS != funRtn, errorCode, 0x02000000u); + + /** ñӽֽİ */ + funRtn = elm_PrepareACrelLink(nextACIDBuff[0U], DIR_SAME, szAxleIncLinkIdBuff); /*ȡlink*/ + if (CI_SUCCESS == funRtn) + { + lodStrPointA.Lnk = pOut->startPos.Lnk; + lodStrPointA.Off = pOut->startPos.Off; + + lodStrPointB.Lnk = szAxleIncLinkIdBuff[0]; + lodStrPointB.Off = 1U; + + cDirChangeNum = elm_PrepareDirChangNum(&lodStrPointA, &lodStrPointB); /*ȡֽķ仯*/ + + cQueryDir = elm_PrepareDirByChangeNum(pOut->startPos.Dir, cDirChangeNum); /*ݷ仯ıѯ*/ + if (0U != cQueryDir) + { + if (cQueryDir == dirHandover) + { + *pOwnsideELMid = preEnvelopeid; + } + else + { + *pOwnsideELMid = backEnvelopeid; + } + + ELM_LOG(ELM_LOG_FATAL, "OutsideUCT:%d need to merge[%d,%d-%d] OwnUCT:%d in AC%d.\n", *pOutsideELMid, envelopeCnt, preEnvelopeid, backEnvelopeid, *pOwnsideELMid, OwnACID); + } + else + { + /*޲*/ + } + } + else + { + /** ѯʧ*/ + } + } + else + { + /** UCTӽ账 */ + *pOwnsideELMid = 0u; + *pOutsideELMid = 0u; + } + } + else + { + /** UCTռõļβĿܷ֧ */ + errorCode += 0x08000000u; + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Search Nearest Train In CutPoint error.\n", errorCode)); + return ret; +} + + +/** + * @brief UCTѱ--гл + * @param[in] + * @param[out] + * @return + * @note + */ +static UINT8 elm_UCTEnvelopeCloneByHandOver(void) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 cycle = 0u; + UINT8 cycleAC = 0u; + UINT8 acCnt = 0u; + UINT16 acIDBuff[CUTOFF_POINT_SUM_MAX] = {0u}; + UINT8 acOccStatus = ELM_AC_OCC; + UINT8 nextACCnt = 0u; + UINT8 searchDir = 0u; + UINT16 nextACIDBuff[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 OwnsideELMid = 0u; + UINT16 OutsideELMid = 0u; + UINT8 cDirChangePointFlag = DIRECTIONPOINT_FLAG_INVALID; + + /** ȡֽ㴦OCΧļ*/ + acCnt = elm_PrepareCfpAc(acIDBuff); + ASSER_ERROR(CUTOFF_POINT_SUM_MAX == acCnt,errorCode,0x80000000u); + + for (cycle = 0u; cycle < acCnt; cycle++) + { + cDirChangePointFlag = DIRECTIONPOINT_FLAG_INVALID; /*ÿһΣһα־*/ + + /** ѯֽOCļΣѯOCεķ */ + nextACCnt = elm_PrepareCfpOtherTiocAc(acIDBuff[cycle], &searchDir, nextACIDBuff, &cDirChangePointFlag); + ASSERT_BREAK(UINT8_MAX == nextACCnt,errorCode,0x40000000u); + + /** ѯڼǷռ */ + for (cycleAC = 0u; cycleAC < nextACCnt; cycleAC++) + { + /** ȡռ*/ + acOccStatus = elm_PrepareACStatus(nextACIDBuff[cycleAC]); + ASSERT_BREAK(ELM_AC_OCC == acOccStatus,errorCode,0x00000000u); + } + + if (cycleAC == nextACCnt) + { + /** ڼУ账 */ + } + else + { + /** ѯֽ㸽ӽг */ + funRtn = elm_SearchNearstTrainInCutPoint(acIDBuff[cycle],searchDir,nextACCnt,nextACIDBuff,&OwnsideELMid,&OutsideELMid, cDirChangePointFlag); + ASSERT_BREAK(CI_ERROR == funRtn,errorCode,0x20000000u); + + if (CI_SUCCESS == funRtn) + { + /** ȡռ*/ + acOccStatus = elm_PrepareACStatus(acIDBuff[cycle]); + + if (ELM_AC_FREE == acOccStatus) + { + /** UCTлɴ */ + elm_HandleUCTHandoverFinished(acIDBuff[cycle],OwnsideELMid,OutsideELMid); + } + else + { + /** ֽ㴦¡ */ + funRtn = elm_HandleCloneOfHandover(acIDBuff[cycle],searchDir,OwnsideELMid,OutsideELMid, cDirChangePointFlag); + ASSERT_BREAK(CI_ERROR == funRtn,errorCode,0x10000000u); + } + } + else + { + /** OC UCTʧܣOCʱȴɰãŻ*/ + } + } + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:UCT Envelope Clone By HandOver error.\n",errorCode)); + return ret; +} + +/** + * @brief ȡָͨŵUCTλƥUCTϢ + * @param[in] UINT16 trainid гID + * @param[in] UINT8 relEnvelopeCnt гUCT + * @param[in] UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] гUCTID + * @param[out] + * @return NULL ѯʧ + NULL ѯɹƥUCTϢ + * @note + */ +static const EnvelopeStruct* elm_GetUCTRealEnvelope(UINT16 trainid,UINT8 relEnvelopeCnt,IN UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX]) +{ + const EnvelopeStruct* ret = NULL; + const EnvelopeStruct* pTemp = NULL; + UINT8 cycle = 0u; + UINT16 trainHeadAc = 0u; + UINT16 trainTailAc = 0u; + UINT8 headRtn = CI_ERROR; + UINT8 tailRtn = CI_ERROR; + UINT32 errorCode = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == relEnvelopeID,ret,0x80000000u); + + /** ȡгȫǰ */ + trainHeadAc = elm_PrepareACOfMaxSafeHeadLoc(trainid); + /** ȡгСȫ */ + trainTailAc = elm_PrepareACOfMinSafeTailLoc(trainid); + + if ((0u == trainHeadAc) || (0u == trainTailAc)) + { + /** ѯʧ */ + errorCode += 0x40000000u; + } + else + { + for (cycle = 0u; cycle < relEnvelopeCnt; cycle++) + { + /** ȡĵַ*/ + pTemp = elm_GetEnvelopeInfoPtr(relEnvelopeID[cycle]); + ASSERT_BREAK(NULL == pTemp,errorCode,0x20000000u); + + /** жСȫǰǷڰ */ + headRtn = elm_PrepareInUINT16Array(trainHeadAc,pTemp->ACID,pTemp->ACCnt); + tailRtn = elm_PrepareInUINT16Array(trainTailAc,pTemp->ACID,pTemp->ACCnt); + + if ((CI_SUCCESS == headRtn) || (CI_SUCCESS == tailRtn )) + { + /** CTֻһUCTڽлָ */ + ASSERT_BREAK(NULL != ret,errorCode,0x10000000u); + + /** CTUCT÷ֵ */ + ret = pTemp; + } + else + { + /** */ + } + } + + if (cycle == relEnvelopeCnt) + { + /** ˵ȷ*/ + } + else + { + ret = NULL; + } + } + + /** */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:Get tain%d real ELM error!",errorCode,trainid)); + return ret; +} + + +/** + * @brief ڻָͨųλãֳͨų + * @param[in] UINT16 trainId + * @param[out] EnvelopeStruct *pMid ֵͨų + * @param[out] UINT8 *cutFlag ȡ־ + * @return + * @note + */ +static UINT8 elm_CreateRevoverEnvelope(UINT16 trainId,OUT EnvelopeStruct *pMid,OUT UINT8 *cutFlag) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + ELM_TrainSafeLocStruct tmpSafeLoc = {0u}; /* ȫλʱ洢 */ + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pMid,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == cutFlag,ret,0x40000000u); + + /** ȡгİȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(trainId,&tmpSafeLoc); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + ELM_LOG(ELM_LOG_FATAL,"info:Recover Train%d,safeT:%d-%d-%02x,safeH:%d-%d-%02x.\n",trainId,tmpSafeLoc.startPos.Lnk,tmpSafeLoc.startPos.Off,tmpSafeLoc.startPos.Dir, \ + tmpSafeLoc.endPos.Lnk,tmpSafeLoc.endPos.Off,tmpSafeLoc.endPos.Dir); + + /** ԰нȡ */ + funRtn = elm_PrepareCutZoneInSelf(&(tmpSafeLoc.startPos),&(tmpSafeLoc.endPos),cutFlag); + ASSER_ERROR((ELM_BELONG_OTHER != funRtn) && (ELM_BELONG_OWNER != funRtn) ,errorCode,0x10000000u); + ELM_LOG(ELM_LOG_FATAL,"info:CUT Recover Train%d,safeT:%d-%d-%02x,safeH:%d-%d-%02x.\n",trainId,tmpSafeLoc.startPos.Lnk,tmpSafeLoc.startPos.Off,tmpSafeLoc.startPos.Dir, \ + tmpSafeLoc.endPos.Lnk,tmpSafeLoc.endPos.Off,tmpSafeLoc.endPos.Dir); + + /** CT */ + funRtn = CommonMemSet(pMid, (UINT32)sizeof(EnvelopeStruct), 0u , (UINT32)sizeof(EnvelopeStruct)); + ASSER_ERROR(0u == funRtn ,errorCode,0x08000000u); + + if (0u == errorCode) + { + funRtn = elm_CreateEnveLope(TYPE_CT_ENVELOPE,trainId,tmpSafeLoc.startPos,tmpSafeLoc.endPos,LINE_MAX_TRAIN,LINE_MAX_TRAIN,pMid); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x04000000u); + + /** ð类 */ + pMid->exitFlag = ENVELOPE_EXIT; + } + else + { + /** ʧ */ + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + +/** + * @brief ڻָͨųİǰUCT + * @param[in] const EnvelopeStruct *pBase ׼ + * @param[out] EnvelopeStruct *pMid ָͨŵİ + * @param[out] EnvelopeStruct *pPre ǰUCT + * @param[out] EnvelopeStruct *pBack UCT + * @return CI_ERROR ʧ + CI_SUCCESS ֳɹ + * @note + */ +static UINT8 elm_SplitByUCTRevover(IN const EnvelopeStruct *pBase,OUT EnvelopeStruct *pMid,OUT EnvelopeStruct *pPre,OUT EnvelopeStruct *pBack) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = 0u; + UINT8 cycle = 0u; + UINT8 dirCheck = 0u; + UINT8 splitFlag = 0u; + EnvelopeStruct pTempOne = {0u}; /** ֺUCT */ + EnvelopeStruct pTempTwo = {0u}; /** ǰUCT */ + UINT8 cDirChangeNum = 0U; /*仯*/ + UINT8 cTempElmDir = 0U; /*Ƿ仯İ緽*/ + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pBase,ret,0x80000000u); + ASSERT_RET_VALUE((NULL == pMid) || (ENVELOPE_EXIT != pMid->exitFlag),ret,0x40000000u); + ASSERT_RET_VALUE(NULL == pPre,ret,0x20000000u); + ASSERT_RET_VALUE(NULL == pBack,ret,0x10000000u); + + /** Ƚķ */ + dirCheck = elm_DirIsSameELMWithELM(pMid,pBase); + ASSER_ERROR(0u == dirCheck,errorCode,0x08000000u); + + /** ԭʼCT */ + if (0u == errorCode) + { + /** геIJ */ + for (cycle = 0u;cycle < pBase->trianCnt;cycle++) + { + if (pBase->trainID[cycle] == pMid->trainID[0u]) + { + splitFlag = 1u; + } + else + { + if (0u == splitFlag) + { + pTempOne.trainID[pTempOne.trianCnt++] = pBase->trainID[cycle]; + } + else + { + pTempTwo.trainID[pTempTwo.trianCnt++] = pBase->trainID[cycle]; + } + } + } + + /** pTempOneյ */ + if (0u < pTempOne.trianCnt) + { + if (ELM_DIR_SAME == dirCheck) + { + (void)elm_PrepareMinSafeTailLoc(pMid->trainID[0u],&pTempOne.endPos); + } + else + { + (void)elm_PrepareMaxSafeHeadLoc(pMid->trainID[0u],&pTempOne.endPos); + } + + cDirChangeNum = elm_PrepareDirChangNum(&pTempOne.endPos, &pBase->endPos); + cTempElmDir = elm_PrepareDirByChangeNum(pBase->endPos.Dir, cDirChangeNum); /*ȷֺĺ󷽰յ㷽*/ + ASSER_ERROR(0U == cTempElmDir, errorCode, 0x00400000u); + + pTempOne.endPos.Dir = cTempElmDir; + pTempOne.startPos = pBase->startPos; + pTempOne.headTrainID = 0u; + pTempOne.tailTrainID = pBase->tailTrainID; + + /** ѯ緶Χļ */ + pTempOne.envelopeType = TYPE_UCT_ENVELOPE; + pTempOne.ACCnt = elm_PrepareACBtwPoints(pTempOne.startPos,pTempOne.endPos,&(pTempOne.ACID[0])); + ASSER_ERROR((0u == pTempOne.ACCnt) || (SECTION_IN_ENVELOPE_SUM_MAX == pTempOne.ACCnt),errorCode,0x04000000u); + } + else + { + /** */ + } + + /** pTempTwoյ */ + if (0u < pTempTwo.trianCnt) + { + if (ELM_DIR_SAME == dirCheck) + { + (void)elm_PrepareMaxSafeHeadLoc(pMid->trainID[0u],&pTempTwo.startPos); + } + else + { + (void)elm_PrepareMinSafeTailLoc(pMid->trainID[0u],&pTempTwo.startPos); + } + + cDirChangeNum = elm_PrepareDirChangNum(&pBase->startPos, &pTempTwo.startPos); + cTempElmDir = elm_PrepareDirByChangeNum(pBase->startPos.Dir, cDirChangeNum); /*ȷֺǰ㷽*/ + ASSER_ERROR(0U == cTempElmDir, errorCode, 0x00200000u); + + pTempTwo.startPos.Dir = cTempElmDir; + pTempTwo.endPos = pBase->endPos; + pTempTwo.headTrainID = pBase->headTrainID; + pTempTwo.tailTrainID = 0u; + + /** ѯ緶Χļ */ + pTempTwo.envelopeType = TYPE_UCT_ENVELOPE; + pTempTwo.ACCnt = elm_PrepareACBtwPoints(pTempTwo.startPos,pTempTwo.endPos,&(pTempTwo.ACID[0])); + ASSER_ERROR((0u == pTempTwo.ACCnt) || (SECTION_IN_ENVELOPE_SUM_MAX == pTempTwo.ACCnt),errorCode,0x02000000u); + + } + else + { + /** */ + } + } + else + { + /** 緽޷Ƚ */ + } + + /** òֺǰUCT硢UCT缰CTǰ/гID*/ + if (0u == errorCode) + { + if (pTempOne.trianCnt > 0U) + { + funRtn = CommonMemCpy(pBack, (UINT32)sizeof(EnvelopeStruct) , &pTempOne , (UINT32)sizeof(EnvelopeStruct)); + ASSER_ERROR(0u == funRtn,errorCode,0x01000000u); + pBack->exitFlag = ENVELOPE_EXIT; + + if (ELM_DIR_SAME == dirCheck) + { + pMid->tailTrainID = pBack->trainID[pBack->trianCnt - 1u]; + } + else + { + pMid->headTrainID = pBack->trainID[pBack->trianCnt - 1u]; + } + } + else + { + if (ELM_DIR_SAME == dirCheck) + { + pMid->tailTrainID = pBase->tailTrainID; + } + else + { + pMid->headTrainID = pBase->tailTrainID; + } + } + + if (pTempTwo.trianCnt > 0U) + { + funRtn = CommonMemCpy(pPre, (UINT32)sizeof(EnvelopeStruct),&pTempTwo, (UINT32)sizeof(EnvelopeStruct)); + ASSER_ERROR(0u == funRtn,errorCode,0x00800000u); + pPre->exitFlag = ENVELOPE_EXIT; + + if (ELM_DIR_SAME == dirCheck) + { + pMid->headTrainID = pBase->trainID[0u]; + } + else + { + pMid->tailTrainID = pBack->trainID[0u]; + } + } + else + { + if (ELM_DIR_SAME == dirCheck) + { + pMid->headTrainID = pBase->headTrainID; + } + else + { + pMid->tailTrainID = pBase->headTrainID; + } + } + } + else + { + /** ʧ*/ + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d Split to UCT error!",errorCode,pBase->id)); + + return ret; +} + + +/** + * @brief ɾǰUCT + * @param[in] IN const EnvelopeStruct *pBase + * @param[out] + * @return + * @note ʧܣ + */ +static void elm_ClearFormerUCTEnvelope(IN const EnvelopeStruct *pBase) +{ + UINT8 cycleAC = 0u; + UINT8 cycleTrain = 0u; + UINT32 errorCode = 0u; + UINT8 funRet = CI_ERROR; + UINT16 tmpACindex = 0u; + + if (NULL != pBase) + { + /** ΧڵļᣬӳϵUKT磨ռӣ*/ + for (cycleAC = 0u; cycleAC < pBase->ACCnt;cycleAC++) + { + /** ȡ */ + tmpACindex = elm_PrepareACIndex(pBase->ACID[cycleAC]); + + /** ӳϵ */ + funRet = elm_SetACRelEnvelopeMap(OP_DEL,tmpACindex,pBase->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x40000000u); + + /** ϰĽϢ */ + for (cycleTrain = 0u; cycleTrain < pBase->trianCnt;cycleTrain++) + { + aam_ClearACEnvelopeEnterInfo(pBase->ACID[cycleAC],pBase->trainID[cycleTrain]); + } + } + + /** гӳϵ*/ + for (cycleTrain = 0u; cycleTrain < pBase->trianCnt;cycleTrain++) + { + /** гİID */ + funRet = elm_SetTrainRelEnvelopeMap(OP_DEL,pBase->trainID[cycleTrain], pBase->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x20000000u); + } + + /** հռ */ + funRet = elm_ClearEnvelope(pBase->id); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x10000000u); + } + else + { + errorCode += 0x80000000u; + } + + if (0u == errorCode) + { + /** ȷ*/ + } + else + { + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:Clear Former UCT%d error!",errorCode); + } +} + +/** + * @brief Ӱ絽洢 + * @param[in] EnvelopeStruct *pTemp Ϣ + * @param[in] UINT8 cutFlag ȡ־λ + * @param[out] + * @return + * @note ʧܣ + */ +static void elm_AddSplitEnvelopToRAM(IN EnvelopeStruct *pTemp,UINT8 cutFlag) +{ + UINT32 errorCode = 0u; + UINT8 funRet = CI_ERROR; + UINT8 cycle = 0u; + UINT16 buffIndex = ENVELOPE_UNVAILD_INDEX; /** 绺ַ */ + UINT16 tmpACIndex = 0u; + + /** ڲУ */ + ASSER_ERROR((NULL == pTemp) || (ENVELOPE_EXIT != pTemp->exitFlag) || ((TYPE_UCT_ENVELOPE != pTemp->envelopeType) && (TYPE_CT_ENVELOPE != pTemp->envelopeType)),errorCode,0x80000000u); + ASSER_ERROR((ELM_HEAD_CUT != cutFlag) && (ELM_TAIL_CUT != cutFlag) && (ELM_NO_CUT != cutFlag),errorCode,0x40000000u); + + /** ȡõİ洢λ */ + buffIndex = elm_GetEnvelopeValidIndex(); + ASSER_ERROR(ENVELOPE_UNVAILD_INDEX == buffIndex,errorCode,0x10000000u); + + /** жϰλǷȷ*/ + if (0u == errorCode) + { + /** ðΨһʶ*/ + pTemp->id = buffIndex; + + /** ӵ洢*/ + funRet = elm_SetEnvelopeByIndex(pTemp,buffIndex); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x08000000u); + + /** ӳβʼ*/ + for (cycle = 0u; cycle < pTemp->ACCnt; cycle++) + { + /** ͨIDȡ */ + tmpACIndex = elm_PrepareACIndex(pTemp->ACID[cycle]); + + /** ᵽӳϵ */ + funRet = elm_SetACRelEnvelopeMap(OP_ADD,tmpACIndex,buffIndex); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x04000000u); + } + + /** Ϣ*/ + if (TYPE_UCT_ENVELOPE == pTemp->envelopeType) + { + funRet = elm_RefreshACseqInfoForUCT(pTemp); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x02000000u); + } + else + { + funRet = elm_RefreshACseqInfoForCT(pTemp,pTemp->ACID,pTemp->ACCnt,cutFlag); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x02000000u); + } + + /** г */ + for (cycle = 0;cycle < pTemp->trianCnt;cycle++) + { + funRet = elm_SetTrainRelEnvelopeMap(OP_ADD,pTemp->trainID[cycle],buffIndex); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x01000000u); + } + } + else + { + /** ޿õİ洢ռ䣬ܷ֧ð紦ģ쳣 */ + } + + if (0u == errorCode) + { + /** ȷ*/ + } + else + { + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Add Split Envelop To RAM error.",errorCode); + } +} + + +/** + * @brief ͨųָʱUCT + * @param[in] UINT16 trainId гID + * @param[in] const EnvelopeStruct* pBase ׼ + * @param[out] + * @return CI_ERROR ʧ + CI_SUCCESS ֳɹ + * @note + * ͷ/βָѱһUCTһCT + * мгָѱUCTһCT + */ +static UINT8 elm_UCTEnvelopeSplit(UINT16 trainId, IN const EnvelopeStruct* pBase) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = 0; + UINT32 errorCode = 0u; + UINT8 cutFlag = ELM_NO_CUT; + UINT8 cycle = 0u; + UINT8 acCnt = 0u; + UINT16 acIdBuff[SECTION_IN_ENVELOPE_SUM_MAX] = {0u}; + EnvelopeStruct preUCTELM = {0u}; /** ǰUCT */ + EnvelopeStruct backUCTELM = {0u}; /** ֺUCT */ + EnvelopeStruct midCTELM = {0u}; /** ͨŻָCT */ + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pBase,ret,0x80000000u); + + /** ڻָͨгֳCT */ + funRtn = elm_CreateRevoverEnvelope(trainId,&midCTELM,&cutFlag); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x40000000u); + + /** ڲֵCTǰUCTIJ */ + funRtn = elm_SplitByUCTRevover(pBase,&midCTELM,&preUCTELM,&backUCTELM); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + if (0u == errorCode) + { + /** ȱݲǰUCT */ + for (cycle = 0u; cycle < pBase->ACCnt;cycle++) + { + acIdBuff[acCnt++] = pBase->ACID[cycle]; + } + + elm_ClearFormerUCTEnvelope(pBase); + elm_AddSplitEnvelopToRAM(&midCTELM,cutFlag); + + if (ENVELOPE_EXIT == preUCTELM.exitFlag) + { + elm_AddSplitEnvelopToRAM(&preUCTELM,cutFlag); + } + else + { + /** */ + } + + if (ENVELOPE_EXIT == backUCTELM.exitFlag) + { + elm_AddSplitEnvelopToRAM(&backUCTELM,cutFlag); + } + else + { + /** */ + } + + /** ļ޺óͨ״̬ΪռõļUKT */ + elm_ProcessByELMLeave(UCT_LEAVE_SPLIT, acCnt,acIdBuff); + + ELM_LOG(ELM_LOG_FATAL,"info:UCT%d split to CT:%d-%02x,pre_UCT:%d-%02x,back_UCT:%d-%02x.\n",pBase->id,midCTELM.id,midCTELM.exitFlag,\ + preUCTELM.id,preUCTELM.exitFlag,backUCTELM.id,backUCTELM.exitFlag); + } + else + { + /** ¡ʧ */ + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + +/** + * @brief ˢUCTӳ + * @param[in] const EnvelopeStruct *ptemp + * @param[out] + * @return + * @note + */ +static void elm_RefreshUCTofACMapInfo(IN const EnvelopeStruct *ptemp) +{ + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT16 tmpACIndex = 0u; + UINT8 cycle = 0u; + UINT8 tmpCnt = 0u; + UINT8 acCnt = 0u; + UINT16 acIdBuff[SECTION_IN_ENVELOPE_SUM_MAX] = {0u}; + UINT8 tmpSearchACCnt; /**/ + UINT16 tmpSearchACID[SECTION_IN_ENVELOPE_SUM_MAX] = {0u}; /*ID*/ + + /** ڲУ */ + ASSERT_RET_NO_VALUE((NULL == ptemp) || (0u == ptemp->ACCnt),0x80000000u); + + /*- ȡȫ緶Χļ*/ + tmpSearchACCnt = elm_PrepareACBtwPoints(ptemp->startPos,ptemp->endPos, tmpSearchACID); + ASSER_ERROR((0u == tmpSearchACCnt) || (SECTION_IN_ENVELOPE_SUM_MAX == tmpSearchACCnt),errorCode,0x40000000u); /*ô*/ + + if (0u == errorCode) + { + /** ȱݲǰUCT */ + for (cycle = 0u; cycle < ptemp->ACCnt;cycle++) + { + acIdBuff[acCnt++] = ptemp->ACID[cycle]; + } + + /** ɾӳϢ */ + tmpCnt = ptemp->ACCnt; + for (cycle = tmpCnt; 0u != cycle; cycle--) + { + /** ɾᵽӳ */ + tmpACIndex = elm_PrepareACIndex(ptemp->ACID[cycle - 1u]); + funRtn = elm_SetACRelEnvelopeMap(OP_DEL,tmpACIndex,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + /** ɾڵļ */ + funRtn = elm_PopEnvelopACSeq(ELM_HEAD,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x10000000u); + } + + /** ӳϵ */ + tmpCnt = tmpSearchACCnt; + for (cycle = 0u; cycle < tmpCnt; cycle++) + { + /** ǰ*/ + funRtn = elm_PushEnvelopeACSeq(ELM_HEAD,ptemp->id,tmpSearchACID[cycle]); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x08000000u); + + /** Ӱ絽ӳ */ + tmpACIndex = elm_PrepareACIndex(tmpSearchACID[cycle]); + funRtn = elm_SetACRelEnvelopeMap(OP_ADD,tmpACIndex,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x04000000u); + } + } + else + { + /** */ + } + + /** ˺Dzˡ */ + if (0u != errorCode) + { + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Refresh UCT%d of ACMap Info error.",errorCode,ptemp->id); + } + else + { + /** ȷ */ + elm_ProcessByELMLeave(UCT_LEAVE_REFRESH, acCnt,acIdBuff); + } +} + +/** + * @brief UCTͷнӽĴ + * @param[in] UINT8 endlineFlag ͷ߱ʶ + * const EnvelopeStruct *ptemp, UCT + * UINT16 headACId ǰ + * UINT16 preEnvelopeId ǰ + * UINT8 cDirChangedFlag 仯־ + * @param[out] + * @return CI_ERROR ִд + 0x55u,ִȷ޷ټ + 0xaau,ִȷɼ + * @note + */ +static UINT8 elm_UCTEnvelopeHeadHandle(UINT8 endlineFlag, IN const EnvelopeStruct *ptemp, UINT16 headACId, UINT16 preEnvelopeId, UINT8 cDirChangedFlag) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 dirCheck = 0u; + UINT16 tmpACIndex = 0u; + LOD_STRU trainLoc = { 0u }; + UINT8 selfFlag = 0u; + UINT8 ocid = 0u; + UINT16 LocACId = 0u; + UINT8 OccStatus = ELM_AC_OCC; + UINT8 pointBelong = ELM_BELONG_OWNER; + const EnvelopeStruct *pPretemp = NULL; + ELM_TrainSafeLocStruct safeLoc = { 0U }; + UINT16 wLinkId = 0U; + UINT16 * pLinkBuf = NULL; + UINT8 chBgUtSwitch = FUNC_SWITCH_OFF; + UINT16 wNextLinkId = 0U; + UINT8 chBgAtt = 0U; + UINT16 wAgLink = 0U; + UINT16 wSwitchId = 0U; + UINT8 cDirectionPointFlag = 0U; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == ptemp, ret, 0x80000000u); + ASSERT_RET_VALUE(((DIRECTIONPOINT_FLAG_VALID != cDirChangedFlag) && (DIRECTIONPOINT_FLAG_INVALID != cDirChangedFlag)), ret, 0x80000000u); + pPretemp = elm_GetEnvelopeInfoPtr(preEnvelopeId); + + if (CI_SUCCESS == endlineFlag) + { + /** ǰΪ·ͷ*/ + } + else + { + /** жǰǷڱOC*/ + pointBelong = elm_PrepareACIsSelf(headACId, &ocid); + + /** ȡ״̬ */ + OccStatus = elm_PrepareACStatus(headACId); + } + + /** ǰΪDZOC */ + if (ELM_BELONG_OTHER == pointBelong) + { + /** ǰΪDZOC*/ + if (NULL == pPretemp) + { + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + else if (TYPE_UKT_ENVELOPE == pPretemp->envelopeType) + { + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00010000u); + } + else if (TYPE_CT_ENVELOPE == pPretemp->envelopeType) + { + /** ȡķǷһ */ + dirCheck = elm_DirIsSameELMWithELM(pPretemp, ptemp); + + /** ȡǷڱOC */ + selfFlag = elm_PrepareEnvelopeIsSelf(pPretemp); + + /** ǰ˼ */ + if (ELM_DIR_SAME == dirCheck) + { + /** λô */ + if (ELM_BELONG_OTHER == selfFlag) + { + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + else + { + /*ȡгȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(pPretemp->trainID[0U], &safeLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00200000u); + trainLoc = safeLoc.startPos; + + /*UCT׷CTСΪ׷ȫβ*/ + /** ڱOC°λ*/ + funRtn = elm_SetEnvelopeLoc(ptemp->id, ptemp->startPos, trainLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00020000u); + } + + /** ǰ˼ */ + if (0u != pPretemp->tailTrainID) + { + if (ptemp->trainID[ptemp->trianCnt - 1u] == pPretemp->trainID[0u]) + { + /** ˵UCTͷǰͨųͬһ˳ֻڷֽ㴦,UCTȾǰͨųǰгID */ + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, pPretemp->headTrainID); + } + else if (ptemp->trainID[ptemp->trianCnt - 1u] == pPretemp->tailTrainID) + { + /** 账*/ + } + else + { + /** UCTȾǰ˿ */ + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + } + else + { + /** ӿ */ + funRtn = elm_SetEnvelopeTailTrainID(pPretemp->id, ptemp->trainID[ptemp->trianCnt - 1u]); /*UCT꣬һ£Ϊǰú*/ + } + } + else + { + /** λô */ + if (ELM_BELONG_OTHER == selfFlag) + { + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + else + { + /*ȡгȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(pPretemp->trainID[0U], &safeLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00080000u); + trainLoc = safeLoc.endPos; + + /*UCT׷CTӴǰΪ׷ȫβ*/ + /** ڱOC°λ*/ + trainLoc.Dir = ~trainLoc.Dir; + funRtn = elm_SetEnvelopeLoc(ptemp->id, ptemp->startPos, trainLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00020000u); + } + + /** ǰ */ + if (0u != pPretemp->headTrainID) + { + if (ptemp->trainID[ptemp->trianCnt - 1u] == pPretemp->trainID[0u]) + { + /** ˵UCTͷǰͨųͬһ˳ֻڷֽ㴦 */ + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, pPretemp->tailTrainID); + } + else if (ptemp->trainID[ptemp->trianCnt - 1u] == pPretemp->headTrainID) + { + /** 账*/ + } + else + { + /** UCTȾǰ˿ */ + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00004000u); + } + } + else + { + /** ӿ */ + funRtn = elm_SetEnvelopeHeadTrainID(pPretemp->id, ptemp->trainID[ptemp->trianCnt - 1u]); /*UCT꣬෴Ϊǰǰ*/ + } + } + } + else + { + /** жǷΪͬһUCTǰ˿ */ + funRtn = elm_CheckEnvelopeMergeValid(ELM_HEAD, ptemp, pPretemp); + if (0x55u == funRtn) + { + /** ǰ˿ */ + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, pPretemp->headTrainID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00002000u); + } + else + { + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00001000u); + } + + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00000800u); + } + ret = 0x55u; + } + else + { + if ((NULL == pPretemp) || (TYPE_UKT_ENVELOPE == pPretemp->envelopeType)) + { + if (NULL == pPretemp) + { + if ((ELM_AC_FREE == OccStatus) || (CI_SUCCESS == endlineFlag)) + { + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + /** ˵°β磬Ҫ */ + ret = 0x55u; + } + else + { + if (ptemp->ACCnt < (SECTION_IN_ENVELOPE_SUM_MAX - 1u)) + { + /** ǰ*/ + funRtn = elm_PushEnvelopeACSeq(ELM_HEAD, ptemp->id, headACId); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x40000000u); + + /** Ӱ絽ӳ */ + tmpACIndex = elm_PrepareACIndex(headACId); + funRtn = elm_SetACRelEnvelopeMap(OP_ADD, tmpACIndex, ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + /*жϰͷǷҪ仯*/ + if (DIRECTIONPOINT_FLAG_VALID == cDirChangedFlag) + { + /*ڷ仯㣬ðյ㷽*/ + funRtn = elm_SetEnvelopeEndDir(ptemp->id, ~ptemp->endPos.Dir); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + else + { + /**/ + } + + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + /** Ҫжǰ */ + ret = 0xaau; + } + else + { + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + } + } + else + { + if (ptemp->ACCnt < (SECTION_IN_ENVELOPE_SUM_MAX - 1u)) + { + /** ǰ*/ + funRtn = elm_PushEnvelopeACSeq(ELM_HEAD, ptemp->id, headACId); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x40000000u); + + /** Ӱ絽ӳ */ + tmpACIndex = elm_PrepareACIndex(headACId); + funRtn = elm_SetACRelEnvelopeMap(OP_ADD, tmpACIndex, ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + /*жϰͷǷҪ仯*/ + if (DIRECTIONPOINT_FLAG_VALID == cDirChangedFlag) + { + /*ڷ仯㣬ðյ㷽*/ + funRtn = elm_SetEnvelopeEndDir(ptemp->id, ~ptemp->endPos.Dir); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + else + { + /**/ + } + + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + /** UCTȾǰ˿ */ + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000u); + + /** UKT类CTԵ */ + funRtn = elm_DeleteUKTEnvelope(pPretemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x04000000u); + + /** Ҫжǰ */ + ret = 0xaau; + } + else + { + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + } + + /** üϰ */ + funRtn = elm_RefreshACseqInfoForUCT(ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x02000000u); + + } + else if (TYPE_CT_ENVELOPE == pPretemp->envelopeType) + { + pLinkBuf = GetAxisLinkIdBuf(ptemp->ACID[0]); + wLinkId = pLinkBuf[0]; + chBgAtt = GetLinkRelPhySecAGorBGAttr(wLinkId); + wAgLink = GetBGLinkRelAGLinkId(wLinkId); + chBgUtSwitch = GetNoCGFollowUtSwitch(); + wNextLinkId = FindAdjacentLinkIDSafe(wLinkId, ptemp->endPos.Dir, &wSwitchId, &cDirectionPointFlag); + if ((FUNC_SWITCH_ON == chBgUtSwitch) && (LINK_REL_PHYSEC_BG == chBgAtt) && (wNextLinkId == wAgLink) && ((pPretemp->startPos.Lnk == wAgLink) || (pPretemp->endPos.Lnk == wAgLink))) + {/* BUT׷ٿش򿪣UCTB죬A죬CTA죬˳ */ + ret = 0x55u; + } + else + { + /** ȡķǷһ */ + dirCheck = elm_DirIsSameELMWithELM(pPretemp, ptemp); + + if (0u == dirCheck) + { + /** 緽Ƚʧ */ + errorCode += 0x01000000u; + } + else + { + /** λ */ + if (ELM_DIR_SAME == dirCheck) + { + /** */ + LocACId = pPretemp->ACID[0u]; + + /*ȡгȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(pPretemp->trainID[0U], &safeLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00200000u); + /*UCT׷CTСΪ׷ȫβ*/ + trainLoc = safeLoc.startPos; + + if (0u != pPretemp->tailTrainID) + { + if (ptemp->trainID[ptemp->trianCnt - 1u] == pPretemp->tailTrainID) + { + /** 账*/ + } + else + { + /** UCTȾǰ˿ */ + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00100000u); + } + } + else + { + /** ӿ */ + funRtn = elm_SetEnvelopeTailTrainID(pPretemp->id, ptemp->trainID[ptemp->trianCnt - 1u]); /*UCT꣬һ£Ϊǰú*/ + } + } + else + { + /** յ */ + LocACId = pPretemp->ACID[pPretemp->ACCnt - 1u]; + + /*ȡгȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(pPretemp->trainID[0U], &safeLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00200000u); + /*UCT׷CTӴǰΪ׷ȫͷ*/ + trainLoc = safeLoc.endPos; + trainLoc.Dir = ~trainLoc.Dir; + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00080000u); + + if (0u != pPretemp->headTrainID) + { + if (ptemp->trainID[ptemp->trianCnt - 1u] == pPretemp->headTrainID) + { + /** 账*/ + } + else + { + /** UCTȾǰ˿ */ + funRtn = elm_SetEnvelopeHeadTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00040000u); + } + } + else + { + /** ӿ */ + funRtn = elm_SetEnvelopeHeadTrainID(pPretemp->id, ptemp->trainID[ptemp->trianCnt - 1u]); /*UCT꣬෴Ϊǰǰ*/ + } + } + + /** UCTмᣬȾǰCT糵λڼ */ + if ((LocACId == headACId) && (ELM_AC_FREE == OccStatus)) + { + /** ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD, ptemp->ACID[ptemp->ACCnt - 1u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00020000u); + } + else + { + /** ڱOC°λ*/ + funRtn = elm_SetEnvelopeLoc(ptemp->id, ptemp->startPos, trainLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00020000u); + } + + /** ¼ӳϵ */ + elm_RefreshUCTofACMapInfo(ptemp); + + /** üϰ */ + funRtn = elm_RefreshACseqInfoForUCT(ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00010000u); + + ret = 0x55u; + } + } + } + else + { + /** UCTϲ */ + funRtn = elm_UCTEnvelopeMerge(ELM_HEAD, ptemp, pPretemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00010000u); + ret = 0x55u; + } + } + + /** úֵ */ + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:UCT%d head ELM track error!", errorCode, ptemp->id)); + ASSERT_SETRET(0u == errorCode, ret, ret, CI_ERROR); + + return ret; +} + +/** + * @brief UCTͷƶ + * @param[in] const EnvelopeStruct *ptemp UCT + * @return CI_ERROR ִд + 0x55u,ִȷ޷ټ + 0xaau,ִȷɼ + * @note UCT紴UCTͷ꣺ + * 1UCTڼռҲUKT磬UCT꣬ͷΪüԶ˶˵㴦 + 2UCTβڼοУUCTлͷΪüԶ˶˵㴦 + 3UCTڼռҴUKT磬UCT꣬ͷΪüԶ˶˵㴦ɱ־ + 4UCTڼռҴCT磬UCT꣬ͷԽCTȫΧɵķΧ + */ +static UINT8 elm_UCTEnvelopeHeadMoving(const EnvelopeStruct *ptemp) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 endLineFlag = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT8 cycle = 0u; + UINT8 cycleAC = 0u; + UINT8 OccStatus = ELM_AC_OCC; + UINT8 tmpACCnt = 0u; + UINT16 tmpACIndex = 0u; + UINT16 preEnvelope = 0u; + UINT16 backEnvelope = 0u; + UINT8 acSameCnt = 0u; + UINT16 acSameID[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT8 envelopeCnt = 0u; /* */ + UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] = {0u}; /*ID*/ + UINT16 mergeACIndex = 0u; + UINT16 mergeACID[SECTION_IN_ENVELOPE_SUM_MAX + AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 mergeACCntMax = (SECTION_IN_ENVELOPE_SUM_MAX + AC_MAXCNT_IN_SWITCH); + UINT8 includeCnt = 0u; + UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] = {0u}; /** غϵİid */ + UINT8 cHeadDirChangeFlag = DIRECTIONPOINT_FLAG_INVALID; /*ͷ仯־*/ + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == ptemp,ret,0x80000000u); + + /** ռûͷٱһᣬUCTȫд */ + tmpACCnt = ptemp->ACCnt; + + for (cycle = tmpACCnt; 1u != cycle; cycle--) + { + /** ȡռ״̬ */ + OccStatus = elm_PrepareACStatus(ptemp->ACID[cycle - 1u]); + + if (ELM_AC_FREE == OccStatus) + { + /** ɾᵽӳ */ + tmpACIndex = elm_PrepareACIndex(ptemp->ACID[cycle - 1u]); + funRtn = elm_SetACRelEnvelopeMap(OP_DEL,tmpACIndex,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x40000000u); + + /** óͷ*/ + funRtn = elm_UCTEnvelopeLeaveAC(ELM_HEAD,ptemp,ptemp->ACID[cycle - 1u]); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + acSameCnt = elm_PrepareAdjacentAC(ptemp->ACID[ptemp->ACCnt - 1u], ~ptemp->endPos.Dir, acSameID, &cHeadDirChangeFlag); + /*ͷسʱʱ°յ㷽*/ + if (DIRECTIONPOINT_FLAG_VALID == cHeadDirChangeFlag) + { + /*ڷ仯㣬ðյ㷽*/ + funRtn = elm_SetEnvelopeEndDir(ptemp->id, ~ptemp->endPos.Dir); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00100000u); + } + else + { + /*ڷ仯㣬*/ + } + + /** ,ͷ,԰˲Ҫŵ*/ + funRtn = elm_PopEnvelopACSeq(ELM_HEAD,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x10000000u); + } + else + { + break; + } + } + + if (tmpACCnt != cycle) + { + /** ˵UCTǰڿмᣬ³ͷλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD,ptemp->ACID[ptemp->ACCnt - 1u],ptemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00400000u); + ret = 0x55; + } + else + { + /** ѯյǰ */ + acSameCnt = elm_PrepareAdjacentAC(ptemp->ACID[ptemp->ACCnt - 1u], ptemp->endPos.Dir, acSameID, &cHeadDirChangeFlag); + ASSER_ERROR(UINT8_MAX == acSameCnt,errorCode,0x04000000u); + + if (UINT8_MAX != acSameCnt) + { + /** жǰǷ */ + for (cycleAC = 0u; cycleAC < acSameCnt; cycleAC++) + { + /** ȡ״̬ */ + OccStatus = elm_PrepareACStatus(acSameID[cycleAC]); + + /** ״̬ռãѭ */ + ASSERT_BREAK(ELM_AC_OCC == OccStatus,errorCode,0u); + } + + /** ǰеʱҪͷλ*/ + if(1u >= acSameCnt) + { + /** ϲļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID,mergeACCntMax,mergeACIndex,ptemp->ACID,SECTION_IN_ENVELOPE_SUM_MAX,ptemp->ACCnt); + + /** ϲͷǰļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID,mergeACCntMax,mergeACIndex,acSameID,(AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH),acSameCnt); + + /** ô*/ + ASSER_ERROR(mergeACIndex > mergeACCntMax,errorCode,0x04000000u); + + if (0u == errorCode) + { + /** ȡڰİ */ + envelopeCnt = elm_MergeEnvelope(mergeACID,(UINT8)mergeACIndex,arEnvelopID); + + /** ѯǰӽİ*/ + funRtn = elm_SearchNearestEnvelope(ptemp,arEnvelopID,envelopeCnt,&preEnvelope,&backEnvelope,&includeCnt,includeELMid); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x02000000u); + + /** UCTк˿ʱسָͨţҪһ */ + if ((0xffu == funRtn) && (LINE_MAX_TRAIN == ptemp->headTrainID) && (0u == preEnvelope) && (0u != includeCnt)) + { + funRtn = elm_SearchNearstEnvInInclude(ELM_TAIL,ptemp,includeCnt,includeELMid,&preEnvelope); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x01000000u); + } + else if ((0xffu == funRtn) && (LINE_MAX_TRAIN == ptemp->tailTrainID)) + { + /** سں󷽻ָ˴ */ + } + else + { + /** 账 */ + ASSER_ERROR(CI_SUCCESS != funRtn,errorCode,0x00800000u); + } + + /** ѯɹ */ + if (0u == errorCode) + { + endLineFlag = (0u == acSameCnt) ? CI_SUCCESS : CI_ERROR; + funRtn = elm_UCTEnvelopeHeadHandle(endLineFlag,ptemp,acSameID[0u],preEnvelope, cHeadDirChangeFlag); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00400000u); + + if (CI_ERROR != funRtn) + { + /** ÷ֵΪֵ */ + ret = funRtn; + } + else + { + /** ʧ */ + ret = CI_ERROR; + } + + } + else + { + /** ѯ󷽰ʧ */ + } + } + else + { + /** ܷ֧ϲļ */ + } + + if (0u == acSameCnt) + { + /** ѯͷ */ + ret = 0x55u; + } + else + { + /** */ + } + } + else + { + if (cycleAC == acSameCnt) + { + /** ǰĿҿУ */ + ret = 0x55u; + } + else + { + /** ǰռĿUCT޷*/ + ASSER_ERROR(acSameCnt > 1u,errorCode,0x00200000u); + } + } + } + else + { + /** ѯʧ */ + } + } + + /** úֵ */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d Head Moving error!",errorCode,ptemp->id)); + ASSERT_SETRET(0u == errorCode,ret,ret,CI_ERROR); + + return ret; +} + + + +/** + * @brief UCTβнӽĴ + * @param[in] UINT8 endlineFlag ͷ߱ʶ + * const EnvelopeStruct *ptemp, UCT + * UINT16 tailACId 󷽼 + * UINT16 backEnvelopeId 󷽰 + * UINT8 cDirChangedFlag 仯־ + * @param[out] + * @return CI_ERROR ִд + 0x55u,ִȷ޷ټ + 0xaau,ִȷɼ + * @note + */ +static UINT8 elm_UCTEnvelopeTailHandle(UINT8 endlineFlag, const EnvelopeStruct *ptemp, UINT16 tailACId, UINT16 backEnvelopeId, UINT8 cDirChangedFlag) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT8 dirCheck = 0u; + UINT16 tmpACIndex = 0u; + UINT8 pointBelong = ELM_BELONG_OWNER; + UINT8 selfFlag = 0u; + UINT8 ocid = 0u; + UINT16 LocACId = 0u; + UINT8 OccStatus = ELM_AC_OCC; + LOD_STRU trainLoc = { 0u }; + const EnvelopeStruct *pBacktemp = NULL; + UINT32 errorCode = 0u; + ELM_TrainSafeLocStruct safeLoc = { 0u }; /*гȫλ*/ + UINT16 wLinkId = 0U; + UINT16 * pLinkBuf = NULL; + UINT8 chBgUtSwitch = FUNC_SWITCH_OFF; + UINT16 wNextLinkId = 0U; + UINT8 chBgAtt = 0U; + UINT16 wAgLink = 0U; + UINT16 wSwitchId = 0U; + UINT8 cDirectionPointFlag = 0U; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == ptemp, ret, 0x80000000u); + ASSERT_RET_VALUE(((DIRECTIONPOINT_FLAG_VALID != cDirChangedFlag) && (DIRECTIONPOINT_FLAG_INVALID != cDirChangedFlag)), ret, 0x80000000u); + pBacktemp = elm_GetEnvelopeInfoPtr(backEnvelopeId); + + if (CI_SUCCESS == endlineFlag) + { + /** ͷ߲ */ + } + else + { + /** жϺ󷽼ǷڱOC*/ + pointBelong = elm_PrepareACIsSelf(tailACId, &ocid); + + /** ȡ״̬ */ + OccStatus = elm_PrepareACStatus(tailACId); + } + + + if (ELM_BELONG_OTHER == pointBelong) + { + /** ǰΪDZOC*/ + if (NULL == pBacktemp) + { + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + else if (TYPE_UKT_ENVELOPE == pBacktemp->envelopeType) + { + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + funRtn = elm_SetEnvelopeTailTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00010000u); + } + else if (TYPE_CT_ENVELOPE == pBacktemp->envelopeType) + { + /** ȡķǷһ */ + dirCheck = elm_DirIsSameELMWithELM(pBacktemp, ptemp); + + /** ȡǷڱOC */ + selfFlag = elm_PrepareEnvelopeIsSelf(pBacktemp); + + /** ˼ */ + if (ELM_DIR_SAME == dirCheck) + { + /** λô */ + if (ELM_BELONG_OTHER == selfFlag) + { + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + else + { + /*ȡгȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(pBacktemp->trainID[0u], &safeLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00400000u); + trainLoc = safeLoc.endPos; + + /*UCT׷CTӴǰΪ׷ȫͷ*/ + /** ڱOC°λ*/ + funRtn = elm_SetEnvelopeLoc(ptemp->id, trainLoc, ptemp->endPos); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00040000u); + } + + /** ˼ */ + if (0u != pBacktemp->headTrainID) + { + if (ptemp->trainID[0u] == pBacktemp->trainID[0u]) + { + /** UCTβCTͬһUCTȾCTĺгID˳ֻڷֽ*/ + funRtn = elm_SetEnvelopeTailTrainID(ptemp->id, pBacktemp->tailTrainID); + } + if (ptemp->trainID[0u] == pBacktemp->headTrainID) + { + /** 账*/ + } + else + { + /** UCTȾϺ˿ */ + funRtn = elm_SetEnvelopeTailTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + } + else + { + /** ӿ */ + funRtn = elm_SetEnvelopeHeadTrainID(pBacktemp->id, ptemp->trainID[0u]); /*ͬCTΪ󳵣ǰ*/ + } + } + else + { + /** λô */ + if (ELM_BELONG_OTHER == selfFlag) + { + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + } + else + { + /*ȡгȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(pBacktemp->trainID[0u], &safeLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00100000u); + trainLoc = safeLoc.startPos; + + /*UCT׷CTСΪ׷ȫβ*/ + /** ڱOC°λ*/ + trainLoc.Dir = ~trainLoc.Dir; + funRtn = elm_SetEnvelopeLoc(ptemp->id, trainLoc, ptemp->endPos); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00040000u); + } + + /** ˼*/ + if (0u != pBacktemp->tailTrainID) + { + if (ptemp->trainID[0u] == pBacktemp->trainID[0u]) + { + /** UCTβCTͬһUCTȾCTĺгID˳ֻڷֽ*/ + funRtn = elm_SetEnvelopeTailTrainID(ptemp->id, pBacktemp->headTrainID); + } + if (ptemp->trainID[0u] == pBacktemp->tailTrainID) + { + /** 账*/ + } + else + { + /** UCTȾϺ˿ */ + funRtn = elm_SetEnvelopeTailTrainID(pBacktemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00004000u); + } + } + else + { + /** ӿ */ + funRtn = elm_SetEnvelopeTailTrainID(pBacktemp->id, ptemp->trainID[0u]); /*෴CTUCT룬ú*/ + } + } + + } + else + { + /** жǷΪͬһUCTǰ˿ */ + funRtn = elm_CheckEnvelopeMergeValid(ELM_TAIL, ptemp, pBacktemp); + + if (0x55u == funRtn) + { + /** ǰ˿ */ + } + else + { + funRtn = elm_SetEnvelopeTailTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00002000u); + } + + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00001000u); + } + ret = 0x55u; + } + else + { + if ((NULL == pBacktemp) || (TYPE_UKT_ENVELOPE == pBacktemp->envelopeType)) + { + if (NULL == pBacktemp) + { + if ((ELM_AC_FREE == OccStatus) || (CI_SUCCESS == endlineFlag)) + { + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + /** ˵°β磬Ҫ */ + ret = 0x55u; + } + else + { + if (ptemp->ACCnt < (SECTION_IN_ENVELOPE_SUM_MAX - 1u)) + { + /** */ + funRtn = elm_PushEnvelopeACSeq(ELM_TAIL, ptemp->id, tailACId); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x40000000u); + + /** Ӱ絽ӳ */ + tmpACIndex = elm_PrepareACIndex(tailACId); + funRtn = elm_SetACRelEnvelopeMap(OP_ADD, tmpACIndex, ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + /*жǷ°㷽*/ + if (DIRECTIONPOINT_FLAG_VALID == cDirChangedFlag) + { + /*ڷ仯㣬ð㷽*/ + funRtn = elm_SetEnvelopeStartDir(ptemp->id, ~ptemp->startPos.Dir); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + else + { + /**/ + } + + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + /** ҪǰǷ񻹴ռü*/ + ret = 0xaau; + } + else + { + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + } + } + else + { + if (ptemp->ACCnt < (SECTION_IN_ENVELOPE_SUM_MAX - 1u)) + { + /** */ + funRtn = elm_PushEnvelopeACSeq(ELM_TAIL, ptemp->id, tailACId); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x40000000u); + + /** Ӱ絽ӳ */ + tmpACIndex = elm_PrepareACIndex(tailACId); + funRtn = elm_SetACRelEnvelopeMap(OP_ADD, tmpACIndex, ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + /*жǷ°㷽*/ + if (DIRECTIONPOINT_FLAG_VALID == cDirChangedFlag) + { + /*ڷ仯㣬ð㷽*/ + funRtn = elm_SetEnvelopeStartDir(ptemp->id, ~ptemp->startPos.Dir); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + else + { + /**/ + } + + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + /** UCTȾϺ˿ */ + funRtn = elm_SetEnvelopeTailTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000u); + + /** UKT类CTԵ */ + funRtn = elm_DeleteUKTEnvelope(pBacktemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x04000000u); + + /** ҪǰǷ񻹴ռü*/ + ret = 0xaau; + } + else + { + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + } + + + /** üϰ */ + funRtn = elm_RefreshACseqInfoForUCT(ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x02000000u); + + } + else if (TYPE_CT_ENVELOPE == pBacktemp->envelopeType) + { + pLinkBuf = GetAxisLinkIdBuf(ptemp->ACID[0]); + wLinkId = pLinkBuf[0]; + chBgAtt = GetLinkRelPhySecAGorBGAttr(wLinkId); + wAgLink = GetBGLinkRelAGLinkId(wLinkId); + chBgUtSwitch = GetNoCGFollowUtSwitch(); + wNextLinkId = FindAdjacentLinkIDSafe(wLinkId, ~ptemp->startPos.Dir, &wSwitchId, &cDirectionPointFlag); + if ((FUNC_SWITCH_ON == chBgUtSwitch) && (LINK_REL_PHYSEC_BG == chBgAtt) && (wNextLinkId == wAgLink) && ((pBacktemp->startPos.Lnk == wAgLink) || (pBacktemp->endPos.Lnk == wAgLink))) + {/* BUT׷ٿش򿪣UCTB죬A죬CTA죬˳ */ + ret = 0x55u; + } + else + { + /** ȡķǷһ */ + dirCheck = elm_DirIsSameELMWithELM(pBacktemp, ptemp); + + if (0u == dirCheck) + { + /** 緽Ƚϲһ */ + } + else + { + /** λ */ + if (ELM_DIR_SAME == dirCheck) + { + /** յ */ + LocACId = pBacktemp->ACID[pBacktemp->ACCnt - 1u]; + + /*ȡгȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(pBacktemp->trainID[0u], &safeLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00400000u); + /*UCT׷CTӴǰΪ׷ȫͷ*/ + trainLoc = safeLoc.endPos; + + if (0u != pBacktemp->headTrainID) + { + if (ptemp->trainID[0u] == pBacktemp->headTrainID) + { + /** 账*/ + } + else + { + /** UCTȾϺ˿ */ + funRtn = elm_SetEnvelopeTailTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00200000u); + } + } + else + { + /** ӿ */ + funRtn = elm_SetEnvelopeHeadTrainID(pBacktemp->id, ptemp->trainID[0u]); /*ͬCTΪ󳵣ǰ*/ + } + } + else + { + /** յ */ + LocACId = pBacktemp->ACID[0u]; + + /*ȡгȫλ*/ + funRtn = elm_PrepareTrainSafeLoc(pBacktemp->trainID[0u], &safeLoc); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00100000u); + /*UCT׷CTСΪ׷ȫβ*/ + trainLoc = safeLoc.startPos; + trainLoc.Dir = ~trainLoc.Dir; + + if (0u != pBacktemp->tailTrainID) + { + if (ptemp->trainID[0u] == pBacktemp->tailTrainID) + { + /** 账*/ + } + else + { + /** UCTȾϺ˿ */ + funRtn = elm_SetEnvelopeTailTrainID(ptemp->id, LINE_MAX_TRAIN); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00080000u); + } + } + else + { + /** ӿ */ + funRtn = elm_SetEnvelopeTailTrainID(pBacktemp->id, ptemp->trainID[0u]); /*෴CTUCT룬ú*/ + } + } + + /** UCTмᣬȾǰCT糵λڼ */ + if ((LocACId == tailACId) && (ELM_AC_FREE == OccStatus)) + { + /** ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL, ptemp->ACID[0u], ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00040000u); + } + else + { + /** ڱOC°λ*/ + funRtn = elm_SetEnvelopeLoc(ptemp->id, trainLoc, ptemp->endPos); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00040000u); + } + + /** ¼ӳϵ */ + elm_RefreshUCTofACMapInfo(ptemp); + + /** üϰ */ + funRtn = elm_RefreshACseqInfoForUCT(ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00020000u); + + ret = 0x55u; + } + } + } + else + { + /** UCTϲ */ + funRtn = elm_UCTEnvelopeMerge(ELM_TAIL, ptemp, pBacktemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00020000u); + ret = 0x55u; + } + } + + /** úֵ */ + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errorCode:0x%08x info:UCT%d tail ELM track error!", errorCode, ptemp->id)); + ASSERT_SETRET(0u == errorCode, ret, ret, CI_ERROR); + + return ret; +} + + +/** + * @brief UCTβƶ + * @param[in] const EnvelopeStruct *ptemp UCT + * @return CI_ERROR ִд + 0x55u,ִȷ޷ټ + 0xaau,ִȷɼ + * @note UCT紴UCTβ꣺ + * 1UCTڼռҲUKT磬UCT꣬βΪüԶ˶˵㴦 + 2UCTβڼοУUCTлβΪüԶ˶˵㴦 + 3UCTڼռҴUKT磬UCT꣬βΪüԶ˶˵㴦ɱ־ + 4UCTڼռҴCT磬UCT꣬βԽCTСȫǰΧɵķΧ + */ +static UINT8 elm_UCTEnvelopeTailMoving(const EnvelopeStruct *ptemp) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 endLineFlag = CI_ERROR; + UINT8 cycle = 0u; + UINT8 cycleAC = 0u; + UINT8 OccStatus = ELM_AC_OCC; + UINT8 tmpACCnt = 0u; + UINT16 tmpACIndex = 0u; + UINT16 preEnvelope = 0u; + UINT16 backEnvelope = 0u; + UINT8 acConvertCnt = 0u; + UINT16 acConvertID[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT8 envelopeCnt = 0u; /* */ + UINT16 arEnvelopID[TRAIN_SUM_MAX_IN_OC] = {0u}; /*ID*/ + UINT16 mergeACIndex = 0u; + UINT16 mergeACID[SECTION_IN_ENVELOPE_SUM_MAX + AC_MAXCNT_IN_SWITCH] = {0u}; + UINT16 mergeACCntMax = (SECTION_IN_ENVELOPE_SUM_MAX + AC_MAXCNT_IN_SWITCH); + UINT8 includeCnt = 0u; + UINT16 includeELMid[TRAIN_SUM_MAX_IN_OC] = {0u}; /** غϵİid */ + UINT8 cTailDirChangeFlag = DIRECTIONPOINT_FLAG_INVALID; /*β仯־*/ + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == ptemp,ret,0x80000000u); + + /** ռûβ,ٱһᣬUCTȫд */ + tmpACCnt = ptemp->ACCnt; + + for (cycle = 0u; (0u != tmpACCnt) && (cycle < (tmpACCnt - 1u)); cycle++) + { + /** ȡռ״̬ */ + OccStatus = elm_PrepareACStatus(ptemp->ACID[0u]); + + if (ELM_AC_FREE == OccStatus) + { + /** ɾᵽӳ */ + tmpACIndex = elm_PrepareACIndex(ptemp->ACID[0u]); + funRtn = elm_SetACRelEnvelopeMap(OP_DEL,tmpACIndex,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x40000000u); + + /** óβ*/ + funRtn = elm_UCTEnvelopeLeaveAC(ELM_TAIL,ptemp,ptemp->ACID[0u]); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + acConvertCnt = elm_PrepareAdjacentAC(ptemp->ACID[0u], ptemp->startPos.Dir, acConvertID, &cTailDirChangeFlag); + /*βسʱʱ°㷽*/ + if (DIRECTIONPOINT_FLAG_VALID == cTailDirChangeFlag) + { + /*ڷ仯㣬ð㷽*/ + funRtn = elm_SetEnvelopeStartDir(ptemp->id, ~ptemp->startPos.Dir); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00100000u); + } + else + { + /*ڷ仯㣬*/ + } + + /** ,β,԰˲Ҫŵ*/ + funRtn = elm_PopEnvelopACSeq(ELM_TAIL,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x10000000u); + } + else + { + break; + } + } + + if (0u != cycle) + { + /** ˵UCT󷽴ڿмᣬ³βλ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL,ptemp->ACID[0u],ptemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x08000000u); + ret = 0x55; + } + else + { + /** ѯ󷽼 */ + acConvertCnt = elm_PrepareAdjacentAC(ptemp->ACID[0u], ~ptemp->startPos.Dir, acConvertID, &cTailDirChangeFlag); + ASSER_ERROR(UINT8_MAX == acConvertCnt,errorCode,0x04000000u); + + if (UINT8_MAX != acConvertCnt) + { + /** жϺ󷽼Ƿ */ + for (cycleAC = 0u; cycleAC < acConvertCnt; cycleAC++) + { + /** ȡ״̬ */ + OccStatus = elm_PrepareACStatus(acConvertID[cycleAC]); + + /** ״̬ռãѭ */ + ASSERT_BREAK(ELM_AC_OCC == OccStatus,errorCode,0u); + } + + /** 󷽼λȷҪβλ */ + if(1u >= acConvertCnt) + { + /** ϲβ󷽵ļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID,mergeACCntMax,mergeACIndex,acConvertID,(AC_MAXCNT_IN_SWITCH * AC_MAXCNT_IN_SWITCH),acConvertCnt); + + /** ϲļ */ + mergeACIndex = elm_PrepareMergeUINT16Array(mergeACID,mergeACCntMax,mergeACIndex,ptemp->ACID,SECTION_IN_ENVELOPE_SUM_MAX,ptemp->ACCnt); + + /** ô*/ + ASSER_ERROR(mergeACIndex > mergeACCntMax,errorCode,0x04000000u); + + if (0u == errorCode) + { + /** ȡڰİ */ + envelopeCnt = elm_MergeEnvelope(mergeACID,(UINT8)mergeACIndex,arEnvelopID); + + /** ѯӽİ*/ + funRtn = elm_SearchNearestEnvelope(ptemp,arEnvelopID,envelopeCnt,&preEnvelope,&backEnvelope,&includeCnt,includeELMid); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x02000000u); + + /** UCTк˿ʱسָͨţҪһ */ + if ((0xffu == funRtn) && (LINE_MAX_TRAIN == ptemp->tailTrainID) && (0u == backEnvelope) && (0u != includeCnt)) + { + funRtn = elm_SearchNearstEnvInInclude(ELM_TAIL,ptemp,includeCnt,includeELMid,&backEnvelope); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x01000000u); + } + else if ((0xffu == funRtn) && (LINE_MAX_TRAIN == ptemp->headTrainID)) + { + /** سǰָ˴ */ + } + else + { + /** 账 */ + ASSER_ERROR(CI_SUCCESS != funRtn,errorCode,0x00800000u); + } + + /** ѯɹ */ + if (0u == errorCode) + { + endLineFlag = (0u == acConvertCnt) ? CI_SUCCESS : CI_ERROR; + funRtn = elm_UCTEnvelopeTailHandle(endLineFlag,ptemp,acConvertID[0u],backEnvelope, cTailDirChangeFlag); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00400000u); + + if (CI_ERROR != funRtn) + { + /** ÷ֵΪֵ */ + ret = funRtn; + } + else + { + /** ʧ */ + ret = CI_ERROR; + } + } + else + { + /** ѯ󷽰ʧ */ + } + } + else + { + /** ܷ֧ϲļ */ + } + } + else + { + if (cycleAC == acConvertCnt) + { + /** ˵󷽲Ŀ*/ + ret = 0x55u; + } + else + { + /** 󷽵ռĿUCT޷*/ + ASSER_ERROR(acConvertCnt > 1u,errorCode,0x00200000u); + } + } + } + else + { + /** ѯʧ */ + } + } + + /** úֵ */ + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d tail Moving error!",errorCode,ptemp->id)); + ASSERT_SETRET(0u == errorCode,ret,ret,CI_ERROR); + + return ret; +} + + +/** + * @brief UCTˢ + * @param[in] const EnvelopeStruct* ptemp Ϣָ + * @param[out] + * @return CI_ERROR ʧ + * CI_SUCCESS ɹ + * @note + */ +static UINT8 elm_UCTEnvelopeRefresh(const EnvelopeStruct* ptemp) +{ + UINT8 ret = CI_ERROR; + UINT8 tailMovingFlag = CI_ERROR; + UINT8 headMovingFlag = CI_ERROR; + UINT8 isOwnFlag = ELM_BELONG_OWNER; + UINT8 movedCnt = 0u; + UINT32 errorCode = 0u; + + /** ڲϷУ */ + ASSERT_RET_VALUE(NULL == ptemp,ret,0x80000000u); + + /** жϰǷڱOC */ + isOwnFlag = elm_PrepareEnvelopeIsSelf(ptemp); + + if (ELM_BELONG_OTHER == isOwnFlag) + { + /** ڱOC账 */ + } + else + { + /** β */ + do + { + tailMovingFlag = elm_UCTEnvelopeTailMoving(ptemp); + movedCnt++; + } while ((0xaaU == tailMovingFlag) && (movedCnt < SECTION_IN_ENVELOPE_SUM_MAX)); + + /** жϰβ */ + ASSER_ERROR((CI_ERROR == tailMovingFlag) || (SECTION_IN_ENVELOPE_SUM_MAX == movedCnt),errorCode,0x40000000u); + + if (CI_ERROR != tailMovingFlag) + { + movedCnt = 0u; + + /** ͷ */ + do + { + headMovingFlag = elm_UCTEnvelopeHeadMoving(ptemp); + movedCnt++; + } while ((0xaaU == headMovingFlag) && (movedCnt < SECTION_IN_ENVELOPE_SUM_MAX)); + + /** жϰβ */ + ASSER_ERROR((CI_ERROR == headMovingFlag) || (SECTION_IN_ENVELOPE_SUM_MAX == movedCnt),errorCode,0x20000000u); + } + else + { + /** */ + } + + /** ٺUCTǰɣɾUCT磨޷ȷUCTгегָʱгǰϵ޷бȽϣ */ + if(((0u != ptemp->headTrainID) && (LINE_MAX_TRAIN != ptemp->headTrainID)) || + ((0u != ptemp->tailTrainID) && (LINE_MAX_TRAIN != ptemp->tailTrainID))) + { + errorCode += 0x10000000u; + ELM_LOG_LOC(ELM_LOG_FATAL,"errorCode:0x%08x info:UCT%d head and tail suspicious flag error!",errorCode,ptemp->id); + } + else if ((0u != ptemp->headTrainID) && (0u != ptemp->tailTrainID)) + { + errorCode += 0x08000000u; + ELM_LOG_LOC(ELM_LOG_FATAL,"errorCode:0x%08x info:UCT%d has head and tail suspicious!",errorCode,ptemp->id); + } + else + { + /** 账 */ + } + } + + if (0u == errorCode) + { + /** UCTû */ + ret = CI_SUCCESS; + } + else + { + /** UCTʧܣȫ*/ + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d Refresh error,convert to UKT!",errorCode,ptemp->id); + ret = elm_DeleteCTOrUCTEnvelope(ptemp->id); + ASSER_ERROR(CI_ERROR == ret,errorCode,0x08000000u); + ASSER_DEBUG(CI_ERROR == ret,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT convert to UKT error!",errorCode)); + } + + /** ֵ */ + return ret; +} + +/** + * @brief UCTн + * @param[in] const EnvelopeStruct* ptemp Ϣָ + * @param[out] + * @return CI_ERROR ʧ + * CI_SUCCESS ɹ + * @note UCT紴ڼռãUCT꣺ + * 1UCTڼռҲUKT磬UCT꣬ͷ/βΪüԶ˶˵㴦 + 2UCTͷ/βڼοУUCTлͷ/βΪü˶˵㴦 + 3UCTڼռҴUKT磬UCT꣬ͷ/βΪüԶ˶˵㴦ɱ־ + 4UCTڼռҴCT磬UCT꣬ͷ/βCTСȫȫǰΧɵķΧ + */ +static UINT8 elm_UCTEnvelopeMoving(const EnvelopeStruct* ptemp) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = SWITCH_ZONE_OCC_AND_ERROR; + UINT32 errorCode = 0u; + + /** ڵĵϵ */ + funRtn = elm_CheckSwitchInEnvelope(ptemp); + + if (SWITCH_ZONE_OK == funRtn) + { + /** λ÷˹ϵн */ + funRtn = elm_UCTEnvelopeRefresh(ptemp); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x80000000u); + + funRtn = elm_UCTToUKTCheck(ptemp); /*ȫͨųϢUCTǷҪתΪUKT*/ + if (CI_SUCCESS == funRtn) + { + ELM_LOG(ELM_LOG_FATAL, "info:Delete UCT[%d] because of line comm train.\n", ptemp->id); + funRtn = elm_DeleteCTOrUCTEnvelope(ptemp->id); /*UCTегȫͨųҳʱUCTתΪUKT*/ + } + else + { + /*UCTегȫͨųлδʱ*/ + } + } + else if (SWITCH_ZONE_OCC_AND_ERROR == funRtn) + { + /** ڵռĿUCTҪѱ,ĿǰȴΪɾUKT */ + ELM_LOG(ELM_LOG_FATAL,"info:Delete UCT[%d] because of switch pos error and occ.\n",ptemp->id); + funRtn = elm_DeleteCTOrUCTEnvelope(ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x40000000u); + } + else + { + /** ڵĿгռѹļóUKT */ + ELM_LOG(ELM_LOG_FATAL,"info:Delete UCT[%d] because of switch pos error and free.\n",ptemp->id); + funRtn = elm_DeleteCTOrUCTEnvelope(ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT[%d] Moving error!",errorCode,ptemp->id)); + + return ret; +} + + +/** + * @brief CTתUCT + * @param[in] const EnvelopeStruct* ptemp + * @param[out] + * @return CI_ERROR תʧ + * CI_SUCCESS תɹ + * @note CTתUCTʱҪ㣺 + 1ǰ˿ + 2ڰĵĿռã + 3Ϊ߳, + 4гС·С + */ +static UINT8 elm_ConvertToUCTCheck(const EnvelopeStruct* ptemp) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = SWITCH_ZONE_OCC_AND_ERROR; + UINT32 errorCode = 0U; + UINT32 trainLength = 0U; + UINT8 chCanUct = FLAG_SET; + UINT32 minTrainLength = 0U; + UINT32 dwTempLength = 0U; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == ptemp,ret,0x80000000U); + + if (LINE_MAX_TRAIN == ptemp->headTrainID) + { + /** ǰгΪϳ򲻿תUCT */ + ASSER_ERROR(LINE_MAX_TRAIN == ptemp->headTrainID,errorCode,0x40000000U); + } + else + { + funRtn = elm_CheckSwitchInEnvelope(ptemp); + ASSER_ERROR(SWITCH_ZONE_OCC_AND_ERROR == funRtn,errorCode,0x20000000U); + } + + if (0U == errorCode) + { + /** ȡгǷתΪUCT */ + chCanUct = elm_PrePareTrainCanUct(ptemp->trainID[0U]); + ASSER_ERROR(FLAG_SET == chCanUct, errorCode, 0x10000000U); + } + else + { + ; /* תΪUCT */ + } + + if (0U == errorCode) + { + /* by cgh 20240111 UCTԭгȴ50m */ + trainLength = elm_PrepareTrainLength(ptemp->trainID[0U]); + minTrainLength = elm_PrepareTrainLength(LINE_MAX_TRAIN); + + dwTempLength = ((2U * minTrainLength) > 5000U) ? (2U * minTrainLength) : 5000U; + + ASSER_ERROR(trainLength <= dwTempLength, errorCode, 0x08000000U); + } + else + { + ; /* תΪUCT */ + } + + /** úֵ */ + ASSERT_SETRET(0U == errorCode,ret,CI_SUCCESS,CI_ERROR); + ASSER_DEBUG(0U != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:ELM%d can't convert to UCT!",errorCode,ptemp->id)); + return ret; +} + + + +/** + * @brief UCT紴 + * @param[in] + * @param[out] + * @return CI_ERROR ʧ + * CI_SUCCESS ɹ + * @note UCT紴ʱȻó֮ǰCT + * 1UCTʼʱгȫͼռýгʼλȷرģȫβΪ˵㣬βλüΪȫβ + */ +static UINT8 elm_UCTEnvelopeCreate(const EnvelopeStruct* ptemp) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT8 comstatus = ELM_COM_STATUS_ERROR; + UINT8 zoneFlag = CI_ERROR; + UINT8 UCTSwitch = CI_ERROR; + UINT8 cycle = 0u; + UINT8 OccStatus = ELM_AC_OCC; + UINT8 tempACCnt = 0u; + UINT16 tmpACIndex = 0u; + UINT32 errorCode = 0u; + UINT8 cNearAcNum = 0U; /*AC*/ + UINT16 cNearAcIdBuf[AC_MAXCNT_IN_SWITCH] = { 0U }; /*ACID*/ + UINT8 cHeadDirChangeFlag = DIRECTIONPOINT_FLAG_INVALID; /*ͷ仯־*/ + UINT8 cTailDirChangeFlag = DIRECTIONPOINT_FLAG_INVALID; /*β仯־*/ + + /** ȡTIOCΧ */ + zoneFlag = elm_PrepareEnvelopeIsSelf(ptemp); + + /** ڲж */ + ASSERT_RET_VALUE(CI_ERROR == zoneFlag,ret,0x80000000u); + + /** ȡгͨ״̬ */ + comstatus = elm_PrepareTrainCommStatus(ptemp->trainID[0u]); + + if ((ELM_COM_STATUS_OK == comstatus) || (ELM_BELONG_OTHER == zoneFlag)) + { + /** ͨг账*/ + } + else + { + /** ȡUCTܿ */ + UCTSwitch = elm_PrepareUCTSwitch(); + + if (CI_ERROR == UCTSwitch) + { + /** гռѹļóUKT */ + ELM_LOG(ELM_LOG_FATAL,"info:train%d loseCOmmon,process to UKT.\n",ptemp->trainID[0u]); + funRtn = elm_DeleteCTOrUCTEnvelope(ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x40000000u); + } + else + { + ELM_LOG(ELM_LOG_FATAL,"info:train%d loseCOmmon,process to UCT.\n",ptemp->trainID[0u]); + + /** CTתUCT */ + funRtn = elm_ConvertToUCTCheck(ptemp); + + if (CI_ERROR == funRtn) + { + /** гռѹļóUKT */ + funRtn = elm_DeleteCTOrUCTEnvelope(ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + } + else + { + /** İ */ + funRtn = elm_SetEnvelopeType(ptemp->id,TYPE_UCT_ENVELOPE); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x10000000u); + + ELM_LOG(ELM_LOG_FATAL,"info:UCT:%d init S:%d-%d-%d E:%d-%d-%d.\n", ptemp->id, ptemp->startPos.Lnk, ptemp->startPos.Off, ptemp->startPos.Dir, \ + ptemp->endPos.Lnk, ptemp->endPos.Off, ptemp->endPos.Dir); + + /** ռûͷ */ + tempACCnt = ptemp->ACCnt; + for (cycle = tempACCnt; 1u != cycle; cycle--) + { + /** ȡռ״̬ */ + OccStatus = elm_PrepareACStatus(ptemp->ACID[ptemp->ACCnt - 1u]); + + if (ELM_AC_OCC == OccStatus) + { + if (tempACCnt == cycle) + { + /** ˵ͷռã账굽˵㣬°סͨųUCTƶ곡 */ + } + else + { + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD,ptemp->ACID[ptemp->ACCnt - 1u],ptemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x08000000u); + } + break; + } + else + { + /** ɾᵽӳ */ + tmpACIndex = elm_PrepareACIndex(ptemp->ACID[ptemp->ACCnt - 1u]); + funRtn = elm_SetACRelEnvelopeMap(OP_DEL,tmpACIndex,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x04000000u); + + /** óͷ*/ + funRtn = elm_UCTEnvelopeLeaveAC(ELM_HEAD,ptemp,ptemp->ACID[ptemp->ACCnt - 1u]); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x02000000u); + + /*ͷسʱݷ仯°յ㷽*/ + cNearAcNum = elm_PrepareAdjacentAC(ptemp->ACID[ptemp->ACCnt - 1u], ~ptemp->endPos.Dir, cNearAcIdBuf, &cHeadDirChangeFlag); + if (DIRECTIONPOINT_FLAG_VALID == cHeadDirChangeFlag) + { + /*ڷ仯㣬ðյ㷽*/ + funRtn = elm_SetEnvelopeEndDir(ptemp->id, ~ptemp->endPos.Dir); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00010000u); + } + else + { + /*ڷ仯㣬*/ + } + + /** ,ͷ,԰˲Ҫŵ */ + funRtn = elm_PopEnvelopACSeq(ELM_HEAD,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x01000000u); + + /** λ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_HEAD,ptemp->ACID[ptemp->ACCnt - 1u],ptemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00800000u); + } + } + + /** ռûβ */ + tempACCnt = ptemp->ACCnt; + for (cycle = 0u; ((0u != tempACCnt) && (cycle < (tempACCnt - 1u))); cycle++) + { + /** ȡռ״̬ */ + OccStatus = elm_PrepareACStatus(ptemp->ACID[0u]); + + if (ELM_AC_OCC == OccStatus) + { + if (0u == cycle) + { + /** ˵βռã账굽˵㣬°סͨųUCTƶ곡 */ + } + else + { + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL,ptemp->ACID[0u],ptemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00400000u); + } + break; + } + else + { + /** ɾᵽӳ */ + tmpACIndex = elm_PrepareACIndex(ptemp->ACID[0u]); + funRtn = elm_SetACRelEnvelopeMap(OP_DEL,tmpACIndex,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00200000u); + + /** óβ*/ + funRtn = elm_UCTEnvelopeLeaveAC(ELM_TAIL,ptemp,ptemp->ACID[0u]); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00100000u); + + /*βسʱݷ仯°յ㷽*/ + cNearAcNum = elm_PrepareAdjacentAC(ptemp->ACID[0u], ptemp->startPos.Dir, cNearAcIdBuf, &cTailDirChangeFlag); + if (DIRECTIONPOINT_FLAG_VALID == cTailDirChangeFlag) + { + /*ڷ仯㣬ð㷽*/ + funRtn = elm_SetEnvelopeStartDir(ptemp->id, ~ptemp->startPos.Dir); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + else + { + /*ڷ仯㣬*/ + } + + /** ,β,԰˲Ҫŵ*/ + funRtn = elm_PopEnvelopACSeq(ELM_TAIL,ptemp->id); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00080000u); + + /** λ */ + funRtn = elm_SetUCTEnvelopeDot(ELM_TAIL,ptemp->ACID[0u],ptemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00040000u); + } + } + } + + if (0u == errorCode) + { + /** UCTٴ */ + funRtn = elm_UCTEnvelopeMoving(ptemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x00020000u); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d Moving error!",errorCode,ptemp->id)); + } + else + { + /** UCT紴ʧ */ + } + } + } + + /** ÷ֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + + +/** + * @brief UCTٴ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + * 22022719գʵUCT繦 + */ +void elm_UCTEnvelopeTrack(void) +{ + /*- ֲ */ + UINT16 envelopeIndex = 0u; + UINT8 vaildFlag = ENVELOPE_UNEXIT; + UINT8 funRtn = CI_ERROR; + const EnvelopeStruct* pTemp = NULL; + UINT32 errorCode = 0u; + + /** а磬ͨųгͨ״̬д */ + for (envelopeIndex = 1u; envelopeIndex < ENVELOPE_SUM_MAX; envelopeIndex++) + { + /** ȡռʹñ־*/ + vaildFlag = elm_IsEnvelopeExit(envelopeIndex); + + /** жϰǷЧ */ + if (ENVELOPE_EXIT == vaildFlag) + { + /** ȡϢַ */ + pTemp = elm_GetEnvelopeInfoPtr(envelopeIndex); + + if (NULL == pTemp) + { + /** ֵܳij */ + } + else + { + if (TYPE_CT_ENVELOPE == pTemp->envelopeType) + { + /** UCT紴*/ + funRtn = elm_UCTEnvelopeCreate(pTemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x80000000u); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:ELM%d Create UCT error!",errorCode,envelopeIndex)); + } + else if (TYPE_UCT_ENVELOPE == pTemp->envelopeType) + { + /** UCTٴ */ + funRtn = elm_UCTEnvelopeMoving(pTemp); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x40000000u); + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d Moving error!",errorCode,envelopeIndex)); + } + else + { + /** 账 */ + } + } + } + else + { + /** ڰ磬Ҫ*/ + } + + /** жǷִǷ */ + ASSERT_BREAK(0u != errorCode,errorCode,0u); + } + + /** Էֽ㴦 */ + funRtn = elm_UCTEnvelopeCloneByHandOver(); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + if(0u != errorCode) + { + /** UCTʧ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:elm_UCTEnvelopeTrack errorELM need reset !",errorCode); + } + else + { + /** ȷ*/ + } +} + +/** + * @brief UCTָ + * @param[in] UINT16 trainid гID + * @param[out] + * @return + * @note Ŀǰڲֺͺϲδʵ֣UCTָʱֻһUCT + */ +void elm_UCTEnvelopeRecover(UINT16 trainid) +{ + UINT8 funRtn = CI_ERROR; + UINT8 cycle = 0; + UINT16 tmpELMId = 0u; + UINT8 relEnvelopeCnt = TRAIN_REL_ENVELOPE_SUM_MAX; /*гİ*/ + UINT16 relEnvelopeID[TRAIN_REL_ENVELOPE_SUM_MAX] = {0u}; /*гİ*/ + const EnvelopeStruct* pRealUCTELM = NULL; /* гλöӦİ */ + + UINT32 errorCode = 0u; /* */ + UINT8 szFlag[TRAIN_REL_ENVELOPE_SUM_MAX] = { 0u }; + + /** ȡUCTİId */ + relEnvelopeCnt = elm_GetRelELIdByTrainIDAndType(TYPE_UCT_ENVELOPE,trainid,relEnvelopeID); + + /** ȡָͨŵгλǷЧ*/ + funRtn = elm_PrepareTrainPosValid(trainid); + + if ((0u == relEnvelopeCnt) || (TRAIN_REL_ENVELOPE_SUM_MAX == relEnvelopeCnt)) + { + /** ܲij*/ + errorCode += 0x80000000u; + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d recoveer error!",errorCode,trainid); + } + else if (CI_ERROR == funRtn) + { + /** гͨŻָλЧ*/ + ELM_LOG(ELM_LOG_FATAL,"info:UCT%d recoveer error by Pos unvalid!.\n",trainid); + } + else + { + /** гİҵλöӦİϢ */ + pRealUCTELM = elm_GetUCTRealEnvelope(trainid,relEnvelopeCnt,relEnvelopeID); + ASSER_ERROR(NULL == pRealUCTELM,errorCode,0x40000000u); + + if (NULL != pRealUCTELM) + { + tmpELMId = pRealUCTELM->id; + + /** ƥİв */ + funRtn = elm_UCTEnvelopeSplit(trainid,pRealUCTELM); + ASSER_ERROR(NULL == pRealUCTELM,errorCode,0x20000000u); + + /** ָUCTɾ */ + for (cycle = 0u; cycle < relEnvelopeCnt; cycle++) + { + if (relEnvelopeID[cycle] != tmpELMId) + { + funRtn = elm_DeleteTrainFromSeq(relEnvelopeID[cycle],trainid); + ASSERT_BREAK(CI_ERROR == funRtn,errorCode,0x10000000u); + } + } + } + else + { + /** ѯʧܣȫ࣬гصUCT絼ȫദ */ + funRtn = elm_UCTRecoverCheckElmNear(trainid, szFlag, relEnvelopeCnt, relEnvelopeID); + } + + if (0u == errorCode) + { + /** ȷ*/ + } + else + { + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d recoveer error!",errorCode,trainid); + + for (cycle = 0u; cycle < relEnvelopeCnt; cycle++) + { + if ((CI_SUCCESS == funRtn) && (FLAG_SET == szFlag[cycle])) + {/* ˵λòгλãΪԽֱָֽɾ磬ڰ硣 */ + funRtn = elm_DeleteCTOrUCTUndoSuspic(relEnvelopeID[cycle]); + } + else + { + funRtn = elm_DeleteCTOrUCTEnvelope(relEnvelopeID[cycle]); + } + + ASSERT_BREAK(CI_ERROR == funRtn,errorCode,0x08000000u); + } + + if (cycle == relEnvelopeCnt) + { + /** ȫദɹ*/ + } + else + { + /** ģ޷ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errorCode:0x%08x info:UCT%d recover error to reset!",errorCode,trainid); + } + } + } +} + +/** +* @brief UCTָʱжڰǷΪ硣 +* @param[in] const UINT16 trainId ָUCTгID +* @param[in] const UINT8 chEnvelopeCount ׼ +* @param[in] const UINT16 szEnvelopeId[TRAIN_REL_ENVELOPE_SUM_MAX] ׼ID +* @param[out] OUT UINT8 szFlag[TRAIN_REL_ENVELOPE_SUM_MAX] ǷҪ +* @param[out] +* @return CI_SUCCESS ɹ +* CI_ERROR ʧ +* @note +*/ +static UINT8 elm_UCTRecoverCheckElmNear(const UINT16 trainId, OUT UINT8 szFlag[TRAIN_REL_ENVELOPE_SUM_MAX], const UINT8 chEnvelopeCount, const UINT16 szEnvelopeId[TRAIN_REL_ENVELOPE_SUM_MAX]) +{ + + /*- ֲ */ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRet = CI_ERROR; + const EnvelopeStruct* pTempPre = NULL; + const EnvelopeStruct* pTempBack = NULL; + UINT16 preEnvelopeid = 0u; + UINT16 backEnvelopeid = 0u; + UINT8 ii = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == szFlag, ret, 0x80000000u); + ASSERT_RET_VALUE(NULL == szEnvelopeId, ret, 0x40000000u); + + for (ii = 0u; ii < chEnvelopeCount; ii++) + { + /** ѯǰͺ󷽰*/ + funRet = elm_GetNearestEnvelope(szEnvelopeId[ii], &preEnvelopeid, &backEnvelopeid); + + /** жϷѯɹ*/ + if (CI_SUCCESS == funRet) + { + /*- ڰ*/ + pTempPre = elm_GetEnvelopeInfoPtr(preEnvelopeid); + + /*- ڰ*/ + pTempBack = elm_GetEnvelopeInfoPtr(backEnvelopeid); + + if (((NULL != pTempPre) && (trainId == pTempPre->trainID[0])) + || ((NULL != pTempBack) && (trainId == pTempBack->trainID[0]))) + { + szFlag[ii] = FLAG_SET; + } + else + { + ; /** 账 */ + } + } + else + { + /** ѯǰ󳵴 */ + ASSERT_BREAK(CI_ERROR == funRet, errorCode, 0x20000000u); + } + } + ASSERT_SETRET(ii == chEnvelopeCount, ret, CI_SUCCESS, CI_ERROR); + + /** */ + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:UCT Recover Check Envelope Near error.", errorCode)); + return ret; +} + +/** + * @brief ȫͨųϢUCTתUKTǷ + * @param[in] const EnvelopeStruct* ptemp Ϣָ + * @param[out] + * @return CI_ERROR 0 + * CI_SUCCESS 1 + * @note Created By LQ 2024.07.14 + */ +static UINT8 elm_UCTToUKTCheck(const EnvelopeStruct* ptemp) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 cIsOwnFlag = ELM_BELONG_OWNER; /*ڱ־*/ + LineCommTrainStruct strLineCommTrain = { 0U }; /*ȫͨųṹ*/ + UINT8 cTimeCheckFlag = CI_TIME_NO; + UINT32 dwRcAndTmcTransBadEnsureCnt = 0U; /*RCTMCͨжжʱ*/ + UINT32 dwCurCycNum = 0U; /*ǰϵͳں*/ + UINT8 cFunRtn = CI_ERROR; + + ASSERT_RET_VALUE(NULL == ptemp, cRetVal, 0x80000000U); + + cIsOwnFlag = elm_PrepareEnvelopeIsSelf(ptemp); + + if (ELM_BELONG_OTHER == cIsOwnFlag) + { + /*粻ڱRC账*/ + } + else + { + strLineCommTrain = GetLineCommTrainData(); /*ȡȫͨųϢ*/ + + for (ii = 0U; ii < strLineCommTrain.cCommTrainNum; ii++) + { + if (strLineCommTrain.szCommTrainNumID[ii] == ptemp->trainID[0U]) + { + dwRcAndTmcTransBadEnsureCnt = GetTiocAndTmcTransBadEnsureCnt(); + dwRcAndTmcTransBadEnsureCnt *= 2U; /*ʹͨжʱ*/ + cTimeCheckFlag = SystemOverTimeCheck(ptemp->dwUCTToUKTStartCycNum, dwRcAndTmcTransBadEnsureCnt); + + if (CI_TIME_NO == cTimeCheckFlag) + { + ELM_LOG(ELM_LOG_FATAL, "info:UCT[%d] To UKT Start.\n", ptemp->id); + + dwCurCycNum = Get2oo2CurCycleNum(); + cFunRtn = elm_SetUCTToUKTStartCycNum(ptemp->id, dwCurCycNum); /*δʱ¼UCTתUKTʼΪǰ*/ + + ASSER_DEBUG(CI_SUCCESS != cFunRtn, ELM_LOG_LOC(ELM_LOG_ERROR, "info:UCT[%d] To UKT Start Time[%d] Set Error!", ptemp->id, dwCurCycNum)); + } + else if (CI_TIME_OUT == cTimeCheckFlag) + { + ELM_LOG(ELM_LOG_FATAL, "info:UCT[%d] To UKT TimeOut.\n", ptemp->id); + cRetVal = CI_SUCCESS; /*ʱɽUCTתΪUKTسɹ*/ + } + else + { + /*δʱ*/ + } + break; + } + else + { + /**/ + } + } + + /**** ʱУUCTǷһֱȫͨų ****/ + if (0U != ptemp->dwUCTToUKTStartCycNum) + { + if ((0U != strLineCommTrain.cCommTrainNum) && (ii != strLineCommTrain.cCommTrainNum)) + { + /*ʼʱUCTȫͨųУ*/ + } + else + { + cFunRtn = elm_SetUCTToUKTStartCycNum(ptemp->id, 0U); /*ʼʱUCT粻ȫͨųУUCTתUKTʼʱ䣬ʧ*/ + ASSER_DEBUG(CI_SUCCESS != cFunRtn, ELM_LOG_LOC(ELM_LOG_ERROR, "info:UCT[%d] To UKT Start Time[%d] Set Error!", ptemp->id, 0U)); + } + } + else + { + /*δʱ*/ + } + } + + return cRetVal; +} + +/** +* @brief ɸѡɾUCTɸѡᲿֺUCT +* @param[in] const EnvelopeStruct* ptemp Ϣָ +* @param[out] +* @return CI_ERROR 0 +* CI_SUCCESS 1 +* @note Created By LQ 2024.07.14 +*/ +UINT8 elm_ScreenUctCfpFreeProc(const EnvelopeStruct* ptemp) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 cycle = 0u; + UINT8 cycleAC = 0u; + UINT8 acCnt = 0u; + UINT16 acIDBuff[CUTOFF_POINT_SUM_MAX] = { 0u }; + UINT8 acOccStatus = ELM_AC_OCC; + UINT8 nextACCnt = 0u; + UINT8 searchDir = 0u; + UINT16 nextACIDBuff[AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT16 OwnsideELMid = 0u; + UINT16 OutsideELMid = 0u; + UINT8 cDirChangePointFlag = DIRECTIONPOINT_FLAG_INVALID; + + /** ȡֽ㴦OCΧļ*/ + acCnt = elm_PrepareCfpAc(acIDBuff); + ASSER_ERROR(CUTOFF_POINT_SUM_MAX == acCnt, errorCode, 0x80000000u); + + for (cycle = 0u; cycle < acCnt; cycle++) + { + cDirChangePointFlag = DIRECTIONPOINT_FLAG_INVALID; /*ÿһΣһα־*/ + acOccStatus = elm_PrepareACStatus(acIDBuff[cycle]); + if ((1U == ptemp->ACCnt) && (ptemp->ACID[0] == acIDBuff[cycle]) && (ELM_AC_FREE == acOccStatus)) + {/* UCTһΣڷֽ㣬ҷֽο */ + /** ѯֽOCļΣѯOCεķ */ + nextACCnt = elm_PrepareCfpOtherTiocAc(acIDBuff[cycle], &searchDir, nextACIDBuff, &cDirChangePointFlag); + ASSERT_BREAK(UINT8_MAX == nextACCnt, errorCode, 0x40000000u); + + /** ѯڼǷռ */ + for (cycleAC = 0u; cycleAC < nextACCnt; cycleAC++) + { + /** ȡռ*/ + acOccStatus = elm_PrepareACStatus(nextACIDBuff[cycleAC]); + ASSERT_BREAK(ELM_AC_OCC == acOccStatus, errorCode, 0x00000000u); + } + + if (cycleAC == nextACCnt) + { + /** ڼУ账 */ + } + else + { + /** ѯֽ㸽ӽг */ + funRtn = elm_SearchNearstTrainInCutPoint(acIDBuff[cycle], searchDir, nextACCnt, nextACIDBuff, &OwnsideELMid, &OutsideELMid, cDirChangePointFlag); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x20000000u); + + if (CI_SUCCESS == funRtn) + { + /** UCTлɴ */ + elm_HandleUCTHandoverFinished(acIDBuff[cycle], OwnsideELMid, OutsideELMid); + } + else + { + /** OC UCTʧܣOCʱȴɰãŻ*/ + } + } + } + else + { + ; /* */ + } + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + ASSER_DEBUG(0u != errorCode, ELM_LOG_LOC(ELM_LOG_ERROR, "errno:0x%08x info:Screen UCT Envelope Cfp Process error.\n", errorCode)); + return ret; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/EnvelopeManage/UKTEnvelopeTrack.c b/TSCP/src/APP/ciapp/EnvelopeManage/UKTEnvelopeTrack.c new file mode 100644 index 0000000..adacf52 --- /dev/null +++ b/TSCP/src/APP/ciapp/EnvelopeManage/UKTEnvelopeTrack.c @@ -0,0 +1,186 @@ +/****************************************************************************** +** ļ: UKTEnvelopeTrack.c +** : ʵUKT׷ٴ +*******************************************************************************/ +#include "EnvelopeLogicProcess.h" + +/** + * @brief سٹ + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_UKTEnvelopeTrack(void) +{ + /*- ֲ */ + UINT8 funFlag = CI_ERROR; /*ִзֵ*/ + UINT16 cycle = 0u; + UINT32 errorCode = 0u; /**/ + UINT16 acCnt = 0u; /*OCΧеļ*/ + UINT8 OCId = 0u; + UINT8 acStatus = ELM_AC_OCC; + UINT8 acAssertStatus = AAM_API_AC_UT; + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + + /** ȡOCΧеļ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + + /** жǷѯɹ */ + if (0u == acCnt) + { + /** ѯʧܣOCΧڲܲڼ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + errorCode = errorCode + 0x80000000u; + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Get ACID Buff error!",errorCode) + } + else + { + /** OCеļ*/ + for (cycle = 0u; cycle < acCnt; cycle++) + { + /** жϼǷڱOC */ + funFlag = elm_PrepareACIsSelf(pACIdbuff[cycle],&OCId); + + if (ELM_BELONG_OTHER == funFlag) + { + /** ڱOC */ + } + else + { + /** ȡռ״̬ */ + acStatus = elm_PrepareACStatus(pACIdbuff[cycle]); + + if (ELM_AC_OCC == acStatus) + { + /** ȡʱ */ + acAssertStatus = elm_PrepareACAssertStatus(pACIdbuff[cycle]); + + if ((AAM_API_AC_ARB == acAssertStatus) || (AAM_API_AC_REDUNARB == acAssertStatus) || (AAM_API_AC_REDUNUT == acAssertStatus)) + { + /** ڼ䣬ӹϰ*/ + ELM_LOG(ELM_LOG_FATAL,"info:ac%d no add UKT because AssertStatus:%d.\n",pACIdbuff[cycle],acAssertStatus); + } + else + { + /*- ռļUKT */ + funFlag = elm_AddUKTEnvelopeInAC(pACIdbuff[cycle]); + + /** жǷִȷ */ + if (CI_ERROR == funFlag) + { + /** ִдҪøģ޷־λ */ + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ASSER_ERROR(CI_ERROR == funFlag,errorCode,0x40000000u) + ASSER_DEBUG(0u != errorCode,ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:ac%d add UKT error.",errorCode,pACIdbuff[cycle])) + } + else + { + /** ȷ*/ + } + } + } + else + { + /** в */ + } + } + } + } +} + +/** + * @brief ݼռÿ״̬UKT + * @note + * 1EnvelopeManageAPI.cֵļУδ޸ + */ +void elm_ProcessFreeAC(void) +{ + /*- ֲ */ + UINT8 funRtn = CI_ERROR; + UINT8 OCId = 0u; + UINT16 cycle = 0u; + UINT32 errorCode = 0u; /**/ + UINT16 acCnt = 0u; /*OCΧеļ*/ + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + UINT16 tmpAcIndex = 0u; + UINT8 tmpStatus = ELM_AC_OCC; + UINT8 cycleELM = 0u; + UINT8 acRelEnvelopeCnt = 0u; + UINT16 acRelEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + const EnvelopeStruct* pEnvelope = NULL; + + /** ȡOCΧеļ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + + /** жǷѯɹ */ + if (0u == acCnt) + { + /** ѯʧܣOCΧڲܲڼ */ + errorCode = errorCode + 0x80000000u; + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Get ACID Buff error!",errorCode) + } + else + { + /** OCеļ*/ + for (cycle = 0u; cycle < acCnt; cycle++) + { + /** жϼǷڱOC */ + funRtn = elm_PrepareACIsSelf(pACIdbuff[cycle],&OCId); + + if (ELM_BELONG_OWNER == funRtn) + { + /** ͨҼ*/ + tmpAcIndex = elm_PrepareACIndex(pACIdbuff[cycle]); + + /** ͨIDȡ״̬*/ + tmpStatus = elm_PrepareACStatus(pACIdbuff[cycle]); + + /** ͨȡİ */ + acRelEnvelopeCnt = elm_GetACRelEnvelopeCnt(tmpAcIndex, acRelEnvelopeID); + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX == acRelEnvelopeCnt,errorCode,0x40000000u); + + /** ҰֻһжǷΪUKT磬ǣ*/ + if (ELM_AC_FREE== tmpStatus) + { + /** ɾмϵUKT磬һ϶ֻһUKT磬Ǵ˴*/ + for (cycleELM = 0u; cycleELM < acRelEnvelopeCnt; cycleELM++) + { + /** ȡָ*/ + pEnvelope = elm_GetEnvelopeInfoPtr(acRelEnvelopeID[0]); + ASSERT_BREAK(NULL == pEnvelope,errorCode,0x20000000u); + + if (TYPE_UKT_ENVELOPE == pEnvelope->envelopeType) + { + (void)elm_DeleteUKTEnvelope(pEnvelope); + } + else + { + /** 账*/ + } + } + + /** жϴǷɹ */ + ASSERT_BREAK(cycleELM != acRelEnvelopeCnt,errorCode,0x10000000u); + } + else + { + /** 账*/ + } + } + else + { + /** DZOCᣬ*/ + } + } + + if (cycle == acCnt) + { + /** */ + } + else + { + elm_SetELMWorkFlag(ELM_WORK_ERROR); + ELM_LOG_LOC(ELM_LOG_ERROR,"errno:0x%08x info:Clear AC%d ELM error!",errorCode,pACIdbuff[cycle]); + } + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/FloodGate/FloodGateConfigDataManage.c b/TSCP/src/APP/ciapp/FloodGate/FloodGateConfigDataManage.c new file mode 100644 index 0000000..cb1f9ee --- /dev/null +++ b/TSCP/src/APP/ciapp/FloodGate/FloodGateConfigDataManage.c @@ -0,0 +1,492 @@ +/******************************************************** +* +* FloodGateConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-24 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "FloodGateConfigDataManage.h" + + + + +FloodGateConfigDataStruct FloodGateConfigDataStru[FLOOD_GATE_SUM_MAX]; /*ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiFloodGateIdBuf[FLOOD_GATE_SUM_MAX] = {0u}; /*屾IDӳ*/ +INT16 FloodGateCurSum = 0; /*ŵǰ*/ +UINT16 TotalFloodGateNum = 0u;/*͸*/ + +/* +* ȡŵǰ +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ŵǰ +*/ +UINT16 GetFloodGateCurSum(void) +{ + UINT16 floodCurSum = 0u; + if ((INT16)FLOOD_GATE_SUM_MAX <= FloodGateCurSum) + { + floodCurSum = FLOOD_GATE_SUM_MAX; + } + else if (0 > FloodGateCurSum) + { + floodCurSum = 0u; + } + else + { + floodCurSum = (UINT16)FloodGateCurSum; + } + return floodCurSum; +} + +/* +* ȡָ±ӦķID +* ˵ const UINT16 bufIndex, ± +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT16 GetFloodGateId(const UINT16 bufIndex) +{ + UINT16 floodGateId = CI_ERROR; + + UINT16 curSum = GetTotalFloodGateCurSum(); + + if (bufIndex < curSum) + { + floodGateId = LocalCiFloodGateIdBuf[bufIndex]; + } + + return floodGateId; +} + + +/* +* ȡָID± +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT16 GetFloodGateBufIndex(const UINT16 floodGateId) +{ + UINT16 returnValue = FLOOD_GATE_SUM_MAX; + + if ((floodGateId >=1u) && (floodGateId < FLOOD_GATE_SUM_MAX)) + { + returnValue = floodGateId; + } + else + { + returnValue = 0u; + } + return returnValue; +} + + +/* +* ȡָ±ӦĹ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT16 GetFloodGateCloseApplyRelayId(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 closeApplyRelayId = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + closeApplyRelayId = FloodGateConfigDataStru[bufIndex].CloseApplyRelayId; + } + else + { + /*޲*/ + } + return closeApplyRelayId; +} + +/* +* ȡָ±ӦĿռ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT16 GetFloodGateOpenLockRelayId(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 openLockRelayId = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + openLockRelayId = FloodGateConfigDataStru[bufIndex].OpenLockRelayId; + } + else + { + /*޲*/ + } + return openLockRelayId; +} + +/* +* ȡָ±Ӧ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT16 GetFloodGateAllowRequestRelayId(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 allowRequestRelayId = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + allowRequestRelayId = FloodGateConfigDataStru[bufIndex].AllowCloseRelayId; + } + else + { + /*޲*/ + } + return allowRequestRelayId; +} +/* +* ȡָIDID +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT8 GetFloodGateBelongCiId(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 belongCiId = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + belongCiId = FloodGateConfigDataStru[bufIndex].BelongCiId; + } + else + { + /*޲*/ + } + return belongCiId; +} + +/* +* ķ +* ˵ +* ֵ 1,ɹ +* 0u,ʧ +*/ +UINT8 FloodGateConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 floodGateConfigDataSum = 0u; /*豸*/ + UINT8 returnValue = CI_SUCCESS; + + /*Զ۷·Id*/ + floodGateConfigDataSum = GetFloodGateCurSum(); + TotalFloodGateNum = floodGateConfigDataSum; + if (floodGateConfigDataSum >= FLOOD_GATE_SUM_MAX) + {/**/ + + returnValue = CI_ERROR; + } + else + { + for (ii = 0u; ii < FLOOD_GATE_SUM_MAX; ii++) + { + if (jj == floodGateConfigDataSum) + {/*Ч*/ + + break; + } + + if (FloodGateConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + + LocalCiFloodGateIdBuf[jj] = FloodGateConfigDataStru[ii].FloodGateId; + jj++; + } + } + } + + return returnValue; +} + +/* +* ȡ͸Լŵǰ +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ŵǰ +*/ +UINT16 GetTotalFloodGateCurSum(void) +{ + UINT16 retVal = 0u; + if (TotalFloodGateNum >= FLOOD_GATE_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = TotalFloodGateNum; + } + return retVal; +} + +/* +* +* ˵ +* UINT16 floodGateSum, ķ +* const UINT16 *floodGateIdBuff, ID +* ֵ 0u-ʧ 1-ɹ +*/ +UINT8 AddExtendFloodGateIdDataManage(UINT16 floodGateSum,const UINT16 *floodGateIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal =1u; + + if ((TotalFloodGateNum + floodGateSum) >= FLOOD_GATE_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = TotalFloodGateNum; + TotalFloodGateNum += floodGateSum; + for(ii = 0u;ii< floodGateSum;ii++) + { + LocalCiFloodGateIdBuf[index+ii] = floodGateIdBuff[ii];/*׷ӵLocalCiFloodGateIdBuf*/ + } + } + + return retVal; +} + + +/* +* ȡָIDŽӽ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ӽ +*/ +UINT16 GetFloodGateAccessPhySecNum(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + reVal = FloodGateConfigDataStru[bufIndex].AccessPhySecNum; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ȡָIDŽӽϢṹ +* ˵ const UINT16 floodGateId, ID +* ֵ NULL: ȡʧ +* !NULL: ӽνṹ +*/ +FloodGateAccessPhySecStruct* GetFloodGateAccessPhyDataStru(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + FloodGateAccessPhySecStruct* pPhysecIdStr = NULL; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + pPhysecIdStr = FloodGateConfigDataStru[bufIndex].AccessPhySecStru; + } + else + { + /*޲*/ + } + return pPhysecIdStr; +} + + +/* +* ȡָIDŷ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT16 GetFloodGateProtectPhySecNum(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + reVal = FloodGateConfigDataStru[bufIndex].ProtectPhySecNum; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ȡָIDŷIdָ +* ˵ const UINT16 floodGateId, ID +* ֵ NULL: ȡʧ +* !NULL: Idָ +*/ +UINT16* GetFloodGateProtectPhyIDBuf(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *pPhysecIdBuf = NULL; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + pPhysecIdBuf = FloodGateConfigDataStru[bufIndex].ProtectPhySecIdBuf; + } + else + { + /*޲*/ + } + return pPhysecIdBuf; +} +/* +* ȡָIDID +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT8 GetFloodGateBelongVirCiId(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 belongVirCiId = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + belongVirCiId = FloodGateConfigDataStru[bufIndex].BelongVirId; + } + else + { + /*޲*/ + } + return belongVirCiId; +} + +/* +* ȡָIDŽӽ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ӽ +*/ +UINT16 GetFloodGateAccessAxisNum(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + reVal = FloodGateConfigDataStru[bufIndex].AccessAxisNum; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ȡָIDŽӽIdָ +* ˵ const UINT16 floodGateId, ID +* ֵ NULL: ȡʧ +* !NULL: ӽIdָ +*/ +UINT16* GetFloodGateAccessAxisIDBuf(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *pPhysecIdBuf = NULL; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + pPhysecIdBuf = FloodGateConfigDataStru[bufIndex].AccessAxisId; + } + else + { + /*޲*/ + } + return pPhysecIdBuf; +} + +/* +* ȡָIDŷ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT16 GetFloodGateProtectAxisNum(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + reVal = FloodGateConfigDataStru[bufIndex].ProtectAxisNum; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ȡָIDŷIdָ +* ˵ const UINT16 floodGateId, ID +* ֵ NULL: ȡʧ +* !NULL: Idָ +*/ +UINT16* GetFloodGateProtectAxisIDBuf(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *pPhysecIdBuf = NULL; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (1u <= bufIndex) + { + pPhysecIdBuf = FloodGateConfigDataStru[bufIndex].ProtectAxisId; + } + else + { + /*޲*/ + } + return pPhysecIdBuf; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/FloodGate/FloodGateConfigDataManage.h b/TSCP/src/APP/ciapp/FloodGate/FloodGateConfigDataManage.h new file mode 100644 index 0000000..b4379c7 --- /dev/null +++ b/TSCP/src/APP/ciapp/FloodGate/FloodGateConfigDataManage.h @@ -0,0 +1,225 @@ +/******************************************************** +* +* FloodGateConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-24 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _FLOODGATE_CONFIG_DATA_MANAGE_H_ +#define _FLOODGATE_CONFIG_DATA_MANAGE_H_ + + +#include "FloodGateDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +/*߼ιߵ豸ṹ*/ +typedef struct S_FloodGate_AccessPhySec +{ + UINT16 AccessPhySecId; /*ӽID*/ + UINT8 AccessPhySecDir; /*ӽνӽ*/ +} FloodGateAccessPhySecStruct; + +/*ݽṹ*/ +typedef struct S_FloodGateConfigDataStruct +{ + UINT16 FloodGateId; /*ID (ֶ)*/ + UINT16 CloseApplyRelayId; /*̵ID (ֶ)*/ + UINT16 OpenLockRelayId; /*ռ̵ID (ֶ)*/ + UINT16 AllowCloseRelayId; /*ż̵ID (ֶ)*/ + + UINT16 AccessPhySecNum; /*Žӽ㣩*/ + FloodGateAccessPhySecStruct AccessPhySecStru[FLOOD_GATE_PROTECT_PHYSECTION_NUM_MAX]; + + UINT16 AccessAxisNum; /*Žӽ*/ + UINT16 AccessAxisId[FLOOD_GATE_ACCESS_AXIS_NUM_MAX]; /*ŽӽID*/ + + UINT16 ProtectPhySecNum; /*ŷ㣩*/ + UINT16 ProtectPhySecIdBuf[FLOOD_GATE_ACCESS_PHYSECTION_NUM_MAX]; /*ŷid飨㣩*/ + + UINT16 ProtectAxisNum; /*ŷ*/ + UINT16 ProtectAxisId[FLOOD_GATE_PROTECT_AXIS_NUM_MAX]; /*ŷID*/ + UINT8 BelongCiId; /* 㣺 ID */ + UINT8 BelongVirId; /*ID*/ +} FloodGateConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern FloodGateConfigDataStruct FloodGateConfigDataStru[FLOOD_GATE_SUM_MAX]; /*ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiFloodGateIdBuf[FLOOD_GATE_SUM_MAX]; /*屾IDӳ*/ +extern INT16 FloodGateCurSum; /*ŵǰ*/ +extern UINT16 TotalFloodGateNum;/*͸*/ + + +/* +* ȡŵǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ŵǰ +*/ +UINT16 GetFloodGateCurSum(void); + +/* +* ȡָ±ӦķID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetFloodGateId(const UINT16 bufIndex); + +/* +* ȡָID± +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetFloodGateBufIndex(const UINT16 floodGateId); + +/* +* ȡָ±ӦĹ̵ID +* ˵ const UINT16 floodGateId, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetFloodGateCloseApplyRelayId(const UINT16 floodGateId); + +/* +* ȡָ±ӦĿռ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetFloodGateOpenLockRelayId(const UINT16 floodGateId); + +/* +* ȡָ±Ӧ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetFloodGateAllowRequestRelayId(const UINT16 floodGateId); +/* +* ȡָIDID +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetFloodGateBelongCiId(const UINT16 floodGateId); + + +/* +* ķ +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 FloodGateConfigDataManage(void); + +/* +* +* ˵ +* UINT16 floodGateSum, ķ +* const UINT16 *floodGateIdBuff, ID +* ֵ 0-ʧ 1-ɹ +*/ +UINT8 AddExtendFloodGateIdDataManage(UINT16 floodGateSum,const UINT16 *floodGateIdBuff); + + +/* +* ȡ͸Լŵǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ŵǰ +*/ +UINT16 GetTotalFloodGateCurSum(void); + +/* +* ȡָIDŽӽ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ӽ +*/ +UINT16 GetFloodGateAccessPhySecNum(const UINT16 floodGateId); + +/* +* ȡָIDŽӽϢṹ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ӽνṹ +*/ +FloodGateAccessPhySecStruct* GetFloodGateAccessPhyDataStru(const UINT16 floodGateId); + +/* +* ȡָIDŷ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT16 GetFloodGateProtectPhySecNum(const UINT16 floodGateId); + + +/* +* ȡָIDŷIdָ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Idָ +*/ +UINT16* GetFloodGateProtectPhyIDBuf(const UINT16 floodGateId); + +/* +* ȡָIDID +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT8 GetFloodGateBelongVirCiId(const UINT16 floodGateId); + +/* +* ȡָIDŽӽ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT16 GetFloodGateAccessAxisNum(const UINT16 floodGateId); + +/* +* ȡָIDŽӽIdָ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Idָ +*/ +UINT16* GetFloodGateAccessAxisIDBuf(const UINT16 floodGateId); + +/* +* ȡָIDŷ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT16 GetFloodGateProtectAxisNum(const UINT16 floodGateId); + +/* +* ȡָIDŷIdָ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Idָ +*/ +UINT16* GetFloodGateProtectAxisIDBuf(const UINT16 floodGateId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/FloodGate/FloodGateDataManage.c b/TSCP/src/APP/ciapp/FloodGate/FloodGateDataManage.c new file mode 100644 index 0000000..3df8cf9 --- /dev/null +++ b/TSCP/src/APP/ciapp/FloodGate/FloodGateDataManage.c @@ -0,0 +1,755 @@ +/******************************************************** +* +* FloodGateDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2020-6-24 +* ߣ +* Ŷ̬ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "FloodGateDataManage.h" +#include "CommonMemory.h" + + +FloodGateDataStruct FloodGateDataStru[FLOOD_GATE_SUM_MAX]; /*Ŷ̬*/ + + +/* +* ȡݽṹָ +* ˵ +* ֵ + FloodGateDataStruct * +*/ +FloodGateDataStruct *GetFloodGateData(void) +{ + return FloodGateDataStru; +} + + +/* +* ȡָIDſ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ſ״̬ +*/ +UINT8 GetFloodGateCurOpenLockState(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡԶ۷±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].CurOpenLockStateFromFYM; + } + else + { + /*޲*/ + } + + return reVal; +} + +/* +* ָIDſ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0u: ʧ +*/ +UINT8 SetFloodGateCurOpenLockState(const UINT16 floodGateId,const UINT8 openLockSt) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡԶ۷±*/ + + if (0u < bufIndex) + { + if ((FLOOD_GATE_OPENLOCK == openLockSt) || (FLOOD_GATE_NOT_OPENLOCK == openLockSt)) + {/*״̬Ϊաδա*/ + FloodGateDataStru[bufIndex].CurOpenLockStateFromFYM = openLockSt; + reVal = CI_SUCCESS; + } + } + else + { + /*޲*/ + } + return reVal; +} + + +/* +* ȡָIDŹ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Ź״̬ +*/ +UINT8 GetFloodGateCurCloseRequestSta(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].CurCloseRequestStateFromFYM; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDŹ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0u: ʧ +*/ +UINT8 SetFloodGateCurCloseRequestSta(const UINT16 floodGateId,const UINT8 closeReqSt) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + if ((FLOOD_GATE_CLOSEREQ == closeReqSt) || (FLOOD_GATE_NOT_CLOSEREQ == closeReqSt)) + {/*״̬Ϊ󡿻޹*/ + FloodGateDataStru[bufIndex].CurCloseRequestStateFromFYM = closeReqSt; + reVal = CI_SUCCESS; + } + + } + else + { + /*޲*/ + } + return reVal; +} + + + +/* +* ȡָIDŵǰͬ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ͬ״̬ +*/ +UINT8 GetFloodGateCurAgreeCloseOutSta(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].CurAgreeCloseStateOut; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDŵǰͬ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0u: ʧ +*/ +UINT8 SetFloodGateCurAgreeCloseOutSta(const UINT16 floodGateId,const UINT8 agreeCloseSt) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + if ((FLOOD_GATE_AGREE_CLOSE == agreeCloseSt) || (FLOOD_GATE_NOT_AGREE_CLOSE == agreeCloseSt)) + {/*ͬŵ״̬Ϊͬرա򡾲ͬرա*/ + FloodGateDataStru[bufIndex].CurAgreeCloseStateOut = agreeCloseSt; + reVal = CI_SUCCESS; + } + } + else + { + /*޲*/ + } + return reVal; +} + + +/* +* ȡָIDzcظ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Ź״̬ +*/ +UINT8 GetFloodGateCurZCAgrCloseAck(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].CurAgreeCloseAckFromZC; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDzcظ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0u: ʧ +*/ +UINT8 SetFloodGateCurZCAgrCloseAck(const UINT16 floodGateId,const UINT8 allowCloseSt) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + if ((FLOOD_GATE_ALLOWCLOSE_ZC == allowCloseSt) || (FLOOD_GATE_NOT_ALLOWCLOSE_ZC == allowCloseSt)) + {/*ɵ״̬Ϊš򡾲š*/ + FloodGateDataStru[bufIndex].CurAgreeCloseAckFromZC = allowCloseSt; + reVal = CI_SUCCESS; + } + } + else + { + /*޲*/ + } + return reVal; +} + + +/* +* ȡָIDŵǰͬŲɼ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ͬ״̬ +*/ +UINT8 GetFloodGateCurAgreeCloseSta(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].CurAgreeCloseStateIn; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDŵǰͬŲɼ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0u: ʧ +*/ +UINT8 SetFloodGateCurAgreeCloseSta(const UINT16 floodGateId,const UINT8 agreeCloseSt) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + if ((FLOOD_GATE_AGREE_CLOSE == agreeCloseSt) || (FLOOD_GATE_NOT_AGREE_CLOSE == agreeCloseSt)) + {/*ͬŵIJɼ״̬Ϊͬرա򡾲ͬرա*/ + FloodGateDataStru[bufIndex].CurAgreeCloseStateIn = agreeCloseSt; + reVal = CI_SUCCESS; + } + } + else + { + /*޲*/ + } + return reVal; +} + + +/* +* ȡָIDŵǰ߼ϵĹ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ״̬ +*/ +UINT8 GetFloodGateCurLogicCloseState(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 floodStateKS = 0u;/**/ + UINT8 floodStateGQ = 0u;/**/ + UINT8 floodStateYG = 0u;/*йر*/ + + UINT8 reVal = FLOOD_GATE_CLOSE;/*ʼΪŹ*/ + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + /*ǿ й ɵرգ֮һΪ״̬Ϊر*/ + + floodStateKS = FloodGateDataStru[bufIndex].CurOpenLockStateFromFYM; + floodStateGQ = FloodGateDataStru[bufIndex].CurCloseRequestStateFromFYM; + floodStateYG = FloodGateDataStru[bufIndex].CurAgreeCloseStateIn; + + if (FLOOD_GATE_OPENLOCK == floodStateKS) + { + reVal = FLOOD_GATE_OPEN;/*Ϊţ֮⵼ȫ(0uֵ)Ϊǹ*/ + } + else + { + reVal = FLOOD_GATE_CLOSE; + } + + if (FLOOD_GATE_OPEN == reVal) + { + if (FLOOD_GATE_NOT_CLOSEREQ == floodStateGQ) + { + reVal = FLOOD_GATE_OPEN;/*޹Ϊţ֮⵼ȫ(0uֵ)Ϊǹ*/ + } + else + { + reVal = FLOOD_GATE_REQ_CLOSE; + } + } + else + { + /*޲*/ + } + + if (FLOOD_GATE_OPEN == reVal) + { + if (FLOOD_GATE_NOT_AGREE_CLOSE == floodStateYG) + { + reVal = FLOOD_GATE_OPEN;/*ͬرΪţ֮⵼ȫ(0uֵ)Ϊǹ*/ + } + else + { + reVal = FLOOD_GATE_ALLOW_CLOSE; + } + } + else + { + /*޲*/ + } + + } + else + { + /*޲*/ + } + return reVal; +} + + +/* +* ȡָIDYGJ߿ʼʱ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Ż߿ʼʱ +*/ +UINT32 GetFloodGateCurYGJCrosLStartCnt(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].CurYGJCrossLineStartCount; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDYGJ߿ʼʱ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0u: ʧ +*/ +UINT8 SetFloodGateCurYGJCrosLStartCnt(const UINT16 floodGateId,const UINT32 crossLineStartCount) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + FloodGateDataStru[bufIndex].CurYGJCrossLineStartCount = crossLineStartCount; + reVal = CI_SUCCESS; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ȡָIDŷŽӽռѹʱſʼʱ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Ż߿ʼʱ +*/ +UINT32 GetFloodGateDelayCloseStartCnt(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].CurFloodGateDelayCloseStartCyc; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDŷŽӽռѹʱſʼʱ +* ˵ const UINT16 floodGateId, ID +* const UINT32 floodGateDelayCloseStartCount ӳٹʼ +* ֵ void +*/ +void SetFloodGateDelayCloseStartCnt(const UINT16 floodGateId, const UINT32 floodGateDelayCloseStartCount) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + FloodGateDataStru[bufIndex].CurFloodGateDelayCloseStartCyc = floodGateDelayCloseStartCount; + } + else + { + /*޲*/ + } +} + +/* +* ȡָIDŹг +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Źг +*/ +UINT8 GetFloodGateCloseApplyIvocSum(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].FloodGateCloseApplyIvocSum; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDŹг +* ˵ const UINT16 floodGateId, ID +* const UINT8 wTrainSum ,Źг +* ֵ void +*/ +void SetFloodGateCloseApplyIvocSum(const UINT16 floodGateId, const UINT8 wTrainSum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + FloodGateDataStru[bufIndex].FloodGateCloseApplyIvocSum = wTrainSum; + } + else + { + /*޲*/ + } +} +/* +* ȡָIDŹгID +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ŹгID +*/ +UINT16* GetFloodGateCloseApplyIvocId(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *applyIvocBuf = NULL; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + applyIvocBuf = FloodGateDataStru[bufIndex].FloodGateCloseApplyIvocId; + } + else + { + /*޲*/ + } + return applyIvocBuf; +} + +/* +* ָIDŹгID +* ˵ const UINT16 floodGateId, ID +* const UINT16* applyIvocBuf гIDַ +* ֵ void +*/ +void SetFloodGateCloseApplyIvocId(const UINT16 floodGateId, const UINT16* applyIvocBuf) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + (void)CommonMemSet(FloodGateDataStru[bufIndex].FloodGateCloseApplyIvocId, + (UINT32)(sizeof(UINT16)*FLOOD_GATE_APPLY_TRAIN_SUM_MAX), + 0U, (UINT32)(sizeof(UINT16)*FLOOD_GATE_APPLY_TRAIN_SUM_MAX)); /*ȳ壬ֹ*/ + + (void)CommonMemCpy(FloodGateDataStru[bufIndex].FloodGateCloseApplyIvocId, /*ֵгID*/ + (UINT32)(sizeof(UINT16)*FLOOD_GATE_APPLY_TRAIN_SUM_MAX), + applyIvocBuf, (UINT32)(sizeof(UINT16)*FLOOD_GATE_APPLY_TRAIN_SUM_MAX)); + } +} + +/* +* ȡָIDгͬŹṹ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: гͬŹṹ +*/ +FloodGateTrainAnsStruct* GetFloodGateCloseFromIvocStru(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + FloodGateTrainAnsStruct* retVal = NULL; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + retVal = FloodGateDataStru[bufIndex].FloodGateCloseFromIvocStru; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ָIDгͬŹ־ +* ˵ UINT16 floodGateId, ID +* UINT16 wTrainId, гID +* UINT8 agreeFlag ű־ +* ֵ void +*/ +void SetFloodGateAllowCloseFlagIVOC(UINT16 floodGateId, UINT16 wTrainId, UINT8 agreeFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 trainSumIndex = 0U; + UINT8 ii = 0U; + UINT8 retVal = CI_ERROR; + UINT8 chIvocSum = 0U; + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + chIvocSum = GetFloodGateCloseAnsIvocSum(floodGateId); /*ȡǰѾͬг*/ + + if ((0u < bufIndex) && ((FLOOD_GATE_ALLOWCLOSE_IVOC == agreeFlag) || (FLOOD_GATE_NOT_ALLOWCLOSE_IVOC == agreeFlag))) + { + if (FLOOD_GATE_ALLOWCLOSE_IVOC == agreeFlag) + { + /*ͬIJҪ룬δͬģȴ*/ + retVal = CI_SUCCESS; + trainSumIndex = chIvocSum; + for (ii = 0U; ii < chIvocSum; ii++) + { + if (FloodGateDataStru[bufIndex].FloodGateCloseFromIvocStru[ii].wTrainId == wTrainId) + { + retVal = CI_ERROR; /*Ѵг,һظˣٴ*/ + break; + } + } + + if (CI_SUCCESS == retVal) + { + FloodGateDataStru[bufIndex].FloodGateCloseFromIvocStru[trainSumIndex].wTrainId = wTrainId; + FloodGateDataStru[bufIndex].FloodGateCloseFromIvocStru[trainSumIndex].wFloodGateCloseIvocFlag = agreeFlag; /*־ʱ򣬲ʼѯʵгǷ񶼻ظͬ*/ + chIvocSum++; + SetFloodGateCloseAnsIvocSum(floodGateId, chIvocSum); + } + } + else + { + ; /*δͬ⣬*/ + } + } + else + { + /*޲*/ + } +} + +/* +* ָIDгͬŹ־ +* ˵ UINT16 floodGateId, ID +* ֵ void +*/ +void ClearFloodGateAllowClosFlagIVOC(UINT16 floodGateId) +{ + UINT8 chIvocSum = 0U; + UINT16 bufIndex = 0u; /*±*/ + UINT8 ii = 0U; + + chIvocSum = GetFloodGateCloseAnsIvocSum(floodGateId); /*ȡǰѾͬг*/ + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + if ((0U < bufIndex) && (0U < chIvocSum)) + { + for (ii = 0U; ii < chIvocSum; ii++) + { + FloodGateDataStru[bufIndex].FloodGateCloseFromIvocStru[ii].wTrainId = 0U; + FloodGateDataStru[bufIndex].FloodGateCloseFromIvocStru[ii].wFloodGateCloseIvocFlag = FLOOD_GATE_NOT_ALLOWCLOSE_IVOC; + } + SetFloodGateCloseAnsIvocSum(floodGateId, 0U); + } +} +/* +* ȡָIDŽӽǷUTռѹ־ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ŽӽǷUTռѹ־ +*/ +UINT8 GetFloodGateAccessUTFlag(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].FloodGateAccessUTFlag; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDŽӽǷUTռѹ־ +* ˵ const UINT16 floodGateId, ID +* const UINT8 accessUTFlagǷUTռѹ־ +* ֵ void +*/ +void SetFloodGateAccessUTFlag(const UINT16 floodGateId, const UINT8 accessUTFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + if ((FLOOD_GATE_ACCESS_UT_YES == accessUTFlag) || (FLOOD_GATE_ACCESS_UT_NO == accessUTFlag)) + {/*ܻߴCT*/ + FloodGateDataStru[bufIndex].FloodGateAccessUTFlag = accessUTFlag; + } + } + else + { + /*޲*/ + } +} +/* +* ȡָIDгظг +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: гظг +*/ +UINT8 GetFloodGateCloseAnsIvocSum(const UINT16 floodGateId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + reVal = FloodGateDataStru[bufIndex].FloodGateCloseAnsIvocSum; + } + else + { + /*޲*/ + } + return reVal; +} + +/* +* ָIDгظг +* ˵ const UINT16 floodGateId, ID +* const UINT8 wTrainSum ,гظг +* ֵ void +*/ +void SetFloodGateCloseAnsIvocSum(const UINT16 floodGateId, const UINT8 wTrainSum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + + if (0u < bufIndex) + { + FloodGateDataStru[bufIndex].FloodGateCloseAnsIvocSum = wTrainSum; + } + else + { + /*޲*/ + } +} + diff --git a/TSCP/src/APP/ciapp/FloodGate/FloodGateDataManage.h b/TSCP/src/APP/ciapp/FloodGate/FloodGateDataManage.h new file mode 100644 index 0000000..1a1b249 --- /dev/null +++ b/TSCP/src/APP/ciapp/FloodGate/FloodGateDataManage.h @@ -0,0 +1,294 @@ +/******************************************************** +* +* FloodGateDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2020-6-24 +* ߣ +* Ŷ̬ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _FLOODGATE_DATA_MANAGE_H_ +#define _FLOODGATE_DATA_MANAGE_H_ + +#include "FloodGateDefine.h" +#include "FloodGateConfigDataManage.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" + + +/*гͬŹṹ*/ +typedef struct S_FloodGate_CloseTrainAns +{ + UINT16 wTrainId; /*гID*/ + UINT8 wFloodGateCloseIvocFlag; /*Źͬ־*/ +} FloodGateTrainAnsStruct; + +/*ݽṹ*/ +typedef struct S_FloodGateDataStruct +{ + UINT16 FloodGateId; /*ID (ʼֶ)*/ + + UINT8 CurOpenLockStateFromFYM; /*ǰ״̬ (ֶ̬)FLOOD_GATE_OPENLOCKFLOOD_GATE_NOT_OPENLOCK*/ + UINT8 CurCloseRequestStateFromFYM; /*ǰ״ֶ̬̬ΣFLOOD_GATE_CLOSEREQFLOOD_GATE_NOT_CLOSEREQ*/ + + /*ŹȫУҹ̵Чʱ*/ + UINT8 CurAgreeCloseAckFromZC;/*ǰzcظɣFLOOD_GATE_ALLOWCLOSE_ZCFLOOD_GATE_NOT_ALLOWCLOSE_ZC*/ + + + UINT8 CurAgreeCloseStateIn; /*ǰͬ״ֶ̬̬Σ:FLOOD_GATE_AGREE_CLOSEFLOOD_GATE_NOT_AGREE_CLOSE*/ + /*ǰͬ״̬ۺ + * 1ǰ״̬ + * + * 2CIǷ2ַΪһ㣬2 + * 1zcͨŹʱҷŹȫ + * 2zcͨʱҷȫУZCظŹرЧ + * + * 1ΪǰΪǣ2㣬ǰͬ״̬Ϊͬ⣻ + */ + UINT8 CurAgreeCloseStateOut; /*ǰͬ״ֶ̬̬Σ:FLOOD_GATE_AGREE_CLOSEFLOOD_GATE_NOT_AGREE_CLOSE*/ + + UINT32 CurYGJCrossLineStartCount;/*ǰYGJ߿ʼʱ*/ + + UINT32 CurFloodGateDelayCloseStartCyc; /*Žӽռѹʱſʼʱ*/ + UINT8 FloodGateCloseApplyIvocSum; /*Źг*/ + UINT16 FloodGateCloseApplyIvocId[FLOOD_GATE_APPLY_TRAIN_SUM_MAX]; /*ŹгID*/ + + UINT8 FloodGateCloseAnsIvocSum; /*Źгظ*/ + FloodGateTrainAnsStruct FloodGateCloseFromIvocStru[FLOOD_GATE_APPLY_TRAIN_SUM_MAX]; /*гͬŹṹ*/ + UINT8 FloodGateAccessUTFlag; /*ŽӽǷзͨų־*/ +} FloodGateDataStruct; + +/*******************************ȫֱ*******************************/ +extern FloodGateDataStruct FloodGateDataStru[FLOOD_GATE_SUM_MAX]; /*Ŷ̬*/ + +/* +* ȡݽṹָ +* ˵ +* ֵ + FloodGateDataStruct * +*/ +FloodGateDataStruct *GetFloodGateData(void); + +/* +* ȡָIDſ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: ſ״̬ +*/ +UINT8 GetFloodGateCurOpenLockState(const UINT16 floodGateId); + + +/* +* ָIDſ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0: ʧ +*/ +UINT8 SetFloodGateCurOpenLockState(const UINT16 floodGateId,const UINT8 openLockSt); + +/* +* ȡָIDŹ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: Ź״̬ +*/ +UINT8 GetFloodGateCurCloseRequestSta(const UINT16 floodGateId); + + +/* +* ָIDŹ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0: ʧ +*/ +UINT8 SetFloodGateCurCloseRequestSta(const UINT16 floodGateId,const UINT8 closeReqSt); + + + +/* +* ȡָIDŵǰͬ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: ͬ״̬ +*/ +UINT8 GetFloodGateCurAgreeCloseOutSta(const UINT16 floodGateId); + + +/* +* ָIDŵǰͬ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0: ʧ +*/ +UINT8 SetFloodGateCurAgreeCloseOutSta(const UINT16 floodGateId,const UINT8 agreeCloseSt); + +/* +* ȡָIDŵǰͬŲɼ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: ͬ״̬ +*/ +UINT8 GetFloodGateCurAgreeCloseSta(const UINT16 floodGateId); + +/* +* ָIDŵǰͬŲɼ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0: ʧ +*/ +UINT8 SetFloodGateCurAgreeCloseSta(const UINT16 floodGateId,const UINT8 agreeCloseSt); + + +/* +* ȡָIDzcظ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: Ź״̬ +*/ +UINT8 GetFloodGateCurZCAgrCloseAck(const UINT16 floodGateId); + +/* +* ָIDzcظ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0: ʧ +*/ +UINT8 SetFloodGateCurZCAgrCloseAck(const UINT16 floodGateId,const UINT8 allowCloseSt); + + +/* +* ȡָIDŵǰ߼ϵĹ״̬ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetFloodGateCurLogicCloseState(const UINT16 floodGateId); + +/* +* ȡָIDYGJ߿ʼʱ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: Ż߿ʼʱ +*/ +UINT32 GetFloodGateCurYGJCrosLStartCnt(const UINT16 floodGateId); + +/* +* ָIDYGJ߿ʼʱ +* ˵ const UINT16 floodGateId, ID +* ֵ 1: ɹ +* 0: ʧ +*/ +UINT8 SetFloodGateCurYGJCrosLStartCnt(const UINT16 floodGateId,const UINT32 crossLineStartCount); + +/* +* ȡָIDŷŽӽռѹʱſʼʱ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Ż߿ʼʱ +*/ +UINT32 GetFloodGateDelayCloseStartCnt(const UINT16 floodGateId); + +/* +* ָIDŷŽӽռѹʱſʼʱ +* ˵ const UINT16 floodGateId, ID +* const UINT32 floodGateDelayCloseStartCount ӳٹʼ +* ֵ void +*/ +void SetFloodGateDelayCloseStartCnt(const UINT16 floodGateId, const UINT32 floodGateDelayCloseStartCount); + +/* +* ȡָIDŹг +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: Źг +*/ +UINT8 GetFloodGateCloseApplyIvocSum(const UINT16 floodGateId); + +/* +* ָIDŹг +* ˵ const UINT16 floodGateId, ID +* const UINT8 wTrainSum ,Źг +* ֵ void +*/ +void SetFloodGateCloseApplyIvocSum(const UINT16 floodGateId, const UINT8 wTrainSum); + +/* +* ȡָIDŹгID +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ŹгID +*/ +UINT16* GetFloodGateCloseApplyIvocId(const UINT16 floodGateId); + +/* +* ָIDŹгID +* ˵ const UINT16 floodGateId, ID +* const UINT16* applyIvocBuf гIDַ +* ֵ void +*/ +void SetFloodGateCloseApplyIvocId(const UINT16 floodGateId, const UINT16* applyIvocBuf); + +/* +* ȡָIDгͬŹṹ +* ˵ const UINT16 floodGateId, ID +* ֵ 0: ȡʧ +* >0: гͬŹṹ +*/ +FloodGateTrainAnsStruct* GetFloodGateCloseFromIvocStru(const UINT16 floodGateId); + + +/* +* ָIDгͬŹ־ +* ˵ UINT16 floodGateId, ID +* UINT16 wTrainId, гID +* UINT8 agreeFlag ű־ +* ֵ void +*/ +void SetFloodGateAllowCloseFlagIVOC(UINT16 floodGateId, UINT16 wTrainId, UINT8 agreeFlag); + + +/* +* ָIDгͬŹ־ +* ˵ UINT16 floodGateId, ID +* ֵ void +*/ +void ClearFloodGateAllowClosFlagIVOC(UINT16 floodGateId); + +/* +* ȡָIDŽӽǷUTռѹ־ +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ŽӽǷUTռѹ־ +*/ +UINT8 GetFloodGateAccessUTFlag(const UINT16 floodGateId); + +/* +* ָIDŽӽǷUTռѹ־ +* ˵ const UINT16 floodGateId, ID +* const UINT8 accessUTFlagǷUTռѹ־ +* ֵ void +*/ +void SetFloodGateAccessUTFlag(const UINT16 floodGateId, const UINT8 accessUTFlag); + +/* +* ȡָIDгظг +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: гظг +*/ +UINT8 GetFloodGateCloseAnsIvocSum(const UINT16 floodGateId); + +/* +* ָIDгظг +* ˵ const UINT16 floodGateId, ID +* const UINT8 wTrainSum ,гظг +* ֵ 0u: ȡʧ +* >0u: гظг +*/ +void SetFloodGateCloseAnsIvocSum(const UINT16 floodGateId, const UINT8 wTrainSum); + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/FloodGate/FloodGateDefine.h b/TSCP/src/APP/ciapp/FloodGate/FloodGateDefine.h new file mode 100644 index 0000000..609dc96 --- /dev/null +++ b/TSCP/src/APP/ciapp/FloodGate/FloodGateDefine.h @@ -0,0 +1,68 @@ +/******************************************************** +* +* FloodGateDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-24 +* ߣ +* ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _FLOODGATE_DEFINE_H_ +#define _FLOODGATE_DEFINE_H_ + + + + +/*ֵ*/ +#define FLOOD_GATE_SUM_MAX ((UINT16)50) /*ֵ*/ + +/*״̬*/ +#define FLOOD_GATE_STATE_OPEN ((UINT8)0x55) /*ſ״̬*/ +#define FLOOD_GATE_STATE_CLOSE ((UINT8)0xaa) /*Źر״̬*/ + +#define FLOOD_GATE_PROTECT_PHYSECTION_NUM_MAX ((UINT8)100U) /*ŷ*/ +#define FLOOD_GATE_ACCESS_PHYSECTION_NUM_MAX ((UINT8)100U) /*Žӽ*/ + +#define FLOOD_GATE_OPENLOCK ((UINT8)0xaa) /*-*/ +#define FLOOD_GATE_NOT_OPENLOCK ((UINT8)0x55) /*-δ*/ + +#define FLOOD_GATE_CLOSEREQ ((UINT8)0xaa) /*-*/ +#define FLOOD_GATE_NOT_CLOSEREQ ((UINT8)0x55) /*-޹*/ + +#define FLOOD_GATE_APPLYCLOSE_ZC ((UINT8)0xaa) /*zcط*/ +#define FLOOD_GATE_NOT_APPLYCLOSE_ZC ((UINT8)0x55) /*zcط*/ + +#define FLOOD_GATE_ALLOWCLOSE_ZC ((UINT8)0xaa) /*ZCظ*/ +#define FLOOD_GATE_NOT_ALLOWCLOSE_ZC ((UINT8)0x55) /*ZCظ󣺲*/ + +#define FLOOD_GATE_ALLOWCLOSE_IVOC ((UINT8)0xaa) /*IVOCظ*/ +#define FLOOD_GATE_NOT_ALLOWCLOSE_IVOC ((UINT8)0x55) /*IVOCظ󣺲*/ + +#define FLOOD_GATE_AGREE_CLOSE ((UINT8)0xaa) /*ǰͬ״̬ͬ*/ +#define FLOOD_GATE_NOT_AGREE_CLOSE ((UINT8)0x55) /*ǰͬ״̬ͬ*/ + +#define FLOOD_GATE_ACCESS_UT_YES ((UINT8)0x55) /*ŽӽUTռѹ*/ +#define FLOOD_GATE_ACCESS_UT_NO ((UINT8)0xAA) /*ŽӽUTռѹCT*/ + +#define FLOOD_GATE_OPEN ((UINT8)0x55) /*ſ*/ +#define FLOOD_GATE_CLOSE ((UINT8)0xaa) /*Ź*/ +/*ʹ*/ +#define FLOOD_GATE_REQ_CLOSE ((UINT8)0x5a) /*ر*/ +#define FLOOD_GATE_ALLOW_CLOSE ((UINT8)0xa5) /*ͬ*/ + + +#define FLOOD_GATE_YGJ_CROSS_LINE_MAX_COUNT ((UINT8)5) /*Ż߳*/ + +#define FLOOD_GATE_ACCESS_AXIS_NUM_MAX ((UINT8)100U) /*Źӽ*/ +#define FLOOD_GATE_PROTECT_AXIS_NUM_MAX ((UINT8)100U) /*Ź*/ +#define FLOOD_GATE_APPLY_TRAIN_SUM_MAX ((UINT8)80U) /*Լظг-ʹ*/ + +#define FLOOD_GATE_ACCESS_DIR ((UINT8)0x55) /*Žӽνӽ-LINKͬ*/ +#define FLOOD_GATE_AWAY_DIR ((UINT8)0xaa) /*Žӽνӽ-LINK*/ +#define FLOOD_GATE_DEFAULT_DIR ((UINT8)0xff) /*Žӽνӽ-ĬϷ*/ + +#endif diff --git a/TSCP/src/APP/ciapp/Garagedoor/GaragedoorConfigDataManage.c b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorConfigDataManage.c new file mode 100644 index 0000000..cb96097 --- /dev/null +++ b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorConfigDataManage.c @@ -0,0 +1,679 @@ +/******************************************************** +* +* GaragedoorConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-17 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "GaragedoorConfigDataManage.h" +#include "LinkConfigDataManage.h" +#include "SignalConfigDataManage.h" + + +GaragedoorConfigDataStruct GaragedoorConfigDataStru[GARAGE_DOOR_SUM_MAX]; /*峵ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiGaragedoorIdBuf[GARAGE_DOOR_SUM_MAX] = {0u}; /*屾IDӳ*/ +INT16 GaragedoorCurSum = 0; /*ŵǰ*/ + + + + +/* +* ȡŵǰ +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ŵǰ +*/ +UINT16 GetGaragedoorSum(void) +{ + UINT16 garagedoorCurSum = 0u; + + if ((INT16)GARAGE_DOOR_SUM_MAX <= GaragedoorCurSum) + { + garagedoorCurSum = GARAGE_DOOR_SUM_MAX; + } + else if (0 > GaragedoorCurSum) + { + garagedoorCurSum = 0u; + } + else + { + garagedoorCurSum = (UINT16)GaragedoorCurSum; + } + return garagedoorCurSum; +} + +/* +* ȡָ±ӦijID +* ˵ const UINT16 bufIndex, ± +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT16 GetGaragedoorId(const UINT16 bufIndex) +{ + UINT16 garagedoorId = CI_ERROR; + if (bufIndex < GetGaragedoorSum()) + { + garagedoorId = LocalCiGaragedoorIdBuf[bufIndex]; + } + return garagedoorId; +} + +/* +* ȡָID +* ˵ const UINT16 garagedoorId, ID +* ֵ GARAGE_DOOR_SUM_MAX: ȡʧ +* = 1u) && (garagedoorId < GARAGE_DOOR_SUM_MAX)) + { + index = garagedoorId; + } + else + { + index = GARAGE_DOOR_SUM_MAX; + } + + return index; +} + +/* +* ȡָIDID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT8 GetGaragedoorBelongCiId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 belongCiId = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + belongCiId = GaragedoorConfigDataStru[bufIndex].BelongCiId; + } + return belongCiId; +} + +/* +* ȡָIDſż̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ſż̵ID +*/ +UINT16 GetGaragedoorOpenRelayId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 garagedoorRelayId = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + garagedoorRelayId = GaragedoorConfigDataStru[bufIndex].GardoorOpenRelayId; + } + + return garagedoorRelayId; +} + +/* +* ȡָIDŹż̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: Źż̵ID +*/ +UINT16 GetGardoorCloseRelayId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 garagedoorRelayId = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + garagedoorRelayId = GaragedoorConfigDataStru[bufIndex].GardoorCloseRelayId; + } + + return garagedoorRelayId; +} + +/* +* ȡָIDſ̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ſ̵ID +*/ +UINT16 GetGardoorOpenOrderRelayId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 garagedoorRelayId = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + garagedoorRelayId = GaragedoorConfigDataStru[bufIndex].GardoorOpenOrderRelayId; + } + + return garagedoorRelayId; +} + +/* +* ȡָIDŹ̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: Ź̵ID +*/ +UINT16 GetGardoorCloseOrderRelayId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 garagedoorRelayId = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + garagedoorRelayId = GaragedoorConfigDataStru[bufIndex].GardoorCloseOrderRelayId; + } + + return garagedoorRelayId; +} + +/* +* ȡָIDģʽ״̵̬ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ģʽ״̵̬ID +*/ +UINT16 GetGardoorModeStateRelayId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorModeStateRelayId; + } + + return reVal; +} + +/* +* ȡָIDŹ״̵̬ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ״̵̬ID +*/ +UINT16 GetGardoorFaultStateRelayId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorFaultStateRelayId; + } + + return reVal; +} + +/* +* ȡָID·̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ·̵ID +*/ +UINT16 GetGardoorPangLuRelayId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorPangLuRelayId; + } + + return reVal; +} + +/* +* ȡָIDſ״̬ڵ̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: غ̵ID +*/ +UINT16 GetGardoorKGHRelayId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorKGHRelayId; + } + + return reVal; +} + + +/* +* ȡָIDŷźŻ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: źŻ +*/ +UINT16 GetGardoorProtectSigSum(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].signalSum; + } + + return reVal; +} + +/* +* ±ȡָIDŷźŻID +* ˵ const UINT16 garagedoorId, ID +* const UINT16 sigIndex, źŻ± +* ֵ 0u: ȡʧ +* >0u: źŻID +*/ +UINT16 GetGardoorProtectSigIdByIndex(const UINT16 garagedoorId,const UINT16 sigIndex) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if (sigIndex < GaragedoorConfigDataStru[bufIndex].signalSum) + { + reVal = GaragedoorConfigDataStru[bufIndex].signalIdBuff[sigIndex]; + } + } + return reVal; +} + +/* +* ȡָIDspks +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: SPKS +*/ +UINT16 GetGarageSpksSum(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorSpksSum; + } + + return reVal; +} + +/* +* ±ȡָIDspksID +* ˵ const UINT16 garagedoorId, ID +* const UINT16 spksIndex, spks± +* ֵ 0u: ȡʧ +* >0u: SPKS ID +*/ +UINT16 GetGarageSpksIdBuff(const UINT16 garagedoorId,const UINT16 spksIndex) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if (spksIndex < GaragedoorConfigDataStru[bufIndex].GardoorSpksSum) + { + reVal = GaragedoorConfigDataStru[bufIndex].spksIdBuff[spksIndex]; + } + } + + return reVal; +} + + +/* +* ȡָIDŹ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT16 GetGardoorphySecSum(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorphySecSum; + } + + return reVal; +} + +/* +* ±ȡָIDID +* ˵ const UINT16 garagedoorId, ID +* const UINT16 phyIndex, ± +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT16 GetGardoorphySecBuf(const UINT16 garagedoorId,const UINT16 phyIndex) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if (phyIndex < GaragedoorConfigDataStru[bufIndex].GardoorphySecSum) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorphySecBuf[phyIndex]; + } + } + + return reVal; +} +/* +* ij +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 GaragedoorConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 garagedoorConfigDataSum = 0u; /**/ + UINT8 returnValue = CI_SUCCESS; + + /*泵ID*/ + garagedoorConfigDataSum = GetGaragedoorSum(); + if (garagedoorConfigDataSum >= GARAGE_DOOR_SUM_MAX) + {/**/ + + returnValue = CI_ERROR; + } + else + { + for (ii = 0u; ii < GARAGE_DOOR_SUM_MAX; ii++) + { + if (jj == garagedoorConfigDataSum) + {/*Ч*/ + + break; + } + + if (GaragedoorConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + + LocalCiGaragedoorIdBuf[jj] = GaragedoorConfigDataStru[ii].GaragedoorId; + jj++; + } + } + } + + return returnValue; +} + +/* +* ȡָIDŹ· +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: · +*/ +UINT8 GetGardoorRouteSum(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorRouteSum; + } + + return reVal; +} + + +/* +* ȡָIDŹ·ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ·ID +*/ +UINT16* GetGardoorRouteIdBuf(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* reVal = NULL; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].GardoorRouteBuf; + } + + return reVal; +} + + +/* +* ȡָIDID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT8 GetGaragedoorBelongVirCiId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 belongVirCiId = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + belongVirCiId = GaragedoorConfigDataStru[bufIndex].BelongVirCiId; + } + return belongVirCiId; +} + +/* +* ȡָIDŶӦAID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0 ʧ + >0 AID +* BY LC +*/ +UINT16 GetGarageDoorAKuPhySec(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 phySecIdA = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + phySecIdA = GaragedoorConfigDataStru[bufIndex].phySecAKUId; + } + return phySecIdA; +} + +/* +* ȡָID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0 ʧ + 0x55 м + 0xaa ϴ +*/ +UINT8 GetGarageDoorAttribute(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 flag = 0U; + UINT8 attribute = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + flag = GaragedoorConfigDataStru[bufIndex].depotAttribute; + } + + if (1U == flag) + { + attribute = GARAGE_DOOR_ATTRIBUTE_LJK; + } + else if (2U == flag) + { + attribute = GARAGE_DOOR_ATTRIBUTE_XCK; + } + else + { + attribute = CI_ERROR; + } + return attribute; +} + +/* +* ȡָIDŷźŻID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: źŻID +*/ +UINT16* GetGardoorProtectSigId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* reVal = NULL; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorConfigDataStru[bufIndex].signalIdBuff; + } + return reVal; +} + +/* +* ȡָIDųźŻ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT8 GetGardoorProOutDir(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16* proSignalIdBuff = NULL; + UINT8 reVal = CI_ERROR; + UINT8 proSignalOutDir = 0U; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + /*ȡźŻ*/ + proSignalIdBuff = GetGardoorProtectSigId(garagedoorId); + if (NULL != proSignalIdBuff) + { + proSignalOutDir = GetSignalDirection(proSignalIdBuff[0]); + if ((DIR_SAME == proSignalOutDir) || (DIR_CONVERT == proSignalOutDir)) + { + reVal = proSignalOutDir; + } + else + { + /* Ч*/ + } + } + else + { + /*ѯʧ*/ + } + } + return reVal; +} + + +/* +* ȡָIDlink +* ˵ const UINT16 garagedoorId, ID +* ֵ linkID +* BY LC +*/ +UINT16 GetGardoorPointLink(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 gdLink = 0U; + + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + gdLink = GaragedoorConfigDataStru[bufIndex].GardoorLinkId; + } + + return gdLink; +} + +/* +* ȡָIDlinkƫ +* ˵ const UINT16 garagedoorId, ID +* ֵ ƫ +* BY LC +*/ +UINT32 GetGardoorPointLinkOffset(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 gdLinkOffest = 0U; + + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + gdLinkOffest = GaragedoorConfigDataStru[bufIndex].GardoorOffset; + } + + return gdLinkOffest; +} + + diff --git a/TSCP/src/APP/ciapp/Garagedoor/GaragedoorConfigDataManage.h b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorConfigDataManage.h new file mode 100644 index 0000000..c4d594c --- /dev/null +++ b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorConfigDataManage.h @@ -0,0 +1,296 @@ +/******************************************************** +* +* GaragedoorConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-17 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _GARAGE_DOOR_CONFIG_DATA_MANAGE_H_ +#define _GARAGE_DOOR_CONFIG_DATA_MANAGE_H_ + + +#include "GaragedoorDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*Žӿݽṹ*/ +typedef struct S_GaragedoorConfigDataStruct +{ + UINT16 GaragedoorId; /*ID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 BelongVirCiId; /*ID*/ + UINT16 GardoorOpenRelayId; /*ſż̵ID*/ + UINT16 GardoorCloseRelayId; /*Źż̵ID*/ + UINT16 GardoorOpenOrderRelayId; /*ſ̵ID*/ + UINT16 GardoorCloseOrderRelayId; /*Ź̵ID*/ + UINT16 GardoorModeStateRelayId; /*ģʽ״̵̬ID*/ + UINT16 GardoorFaultStateRelayId; /*Ź״̵̬ID*/ + UINT16 GardoorPangLuRelayId; /*·̵ID*/ + UINT16 GardoorKGHRelayId; /*ſ״̬ڵ̵ID*/ + UINT16 phySecAKUId; /*ŶӦAID*/ + UINT8 depotAttribute; /**/ + UINT16 signalSum; /* źŻ */ + UINT16 signalIdBuff[GARAGE_DOOR_SIG_MAX]; /* źŻID */ + UINT16 GardoorphySecSum; /*Ź*/ + UINT16 GardoorphySecBuf[GARAGE_DOOR_PHY_SEC_MAX];/*ŹID*/ + UINT16 GardoorSpksSum; /* SPKS */ + UINT16 spksIdBuff[GARAGE_DOOR_SPKS_MAX]; /* SPKSID */ + UINT8 GardoorRouteSum; /*ŹĽ·*/ + UINT16 GardoorRouteBuf[GARAGE_DOOR_ROUTE_MAX]; /*ŹĽ·ID*/ + UINT16 GardoorLinkId; /*Link*/ + UINT32 GardoorOffset; /*Linkƫ*/ +} GaragedoorConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern GaragedoorConfigDataStruct GaragedoorConfigDataStru[GARAGE_DOOR_SUM_MAX]; /*峵ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiGaragedoorIdBuf[GARAGE_DOOR_SUM_MAX]; /*屾IDӳ*/ +extern INT16 GaragedoorCurSum; /*ŵǰ*/ + +/* +* ȡŵǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ŵǰ +*/ +UINT16 GetGaragedoorSum(void); + +/* +* ȡָ±ӦijID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetGaragedoorId(const UINT16 bufIndex); + +/* +* ȡָID +* ˵ const UINT16 garagedoorId, ID +* ֵ GARAGE_DOOR_SUM_MAX: ȡʧ +* 0: ID +*/ +UINT8 GetGaragedoorBelongCiId(const UINT16 garagedoorId); + +/* +* ȡָIDſż̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetGaragedoorOpenRelayId(const UINT16 garagedoorId); + +/* +* ȡָIDŹż̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetGardoorCloseRelayId(const UINT16 garagedoorId); + +/* +* ȡָIDſ̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetGardoorOpenOrderRelayId(const UINT16 garagedoorId); + +/* +* ȡָIDŹ̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetGardoorCloseOrderRelayId(const UINT16 garagedoorId); + +/* +* ȡָIDģʽ״̵̬ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ģʽ״̵̬ID +*/ +UINT16 GetGardoorModeStateRelayId(const UINT16 garagedoorId); + +/* +* ȡָIDŹ״̵̬ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ״̵̬ID +*/ +UINT16 GetGardoorFaultStateRelayId(const UINT16 garagedoorId); + +/* +* ȡָID·̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ·̵ID +*/ +UINT16 GetGardoorPangLuRelayId(const UINT16 garagedoorId); + +/* +* ȡָIDſ״̬ڵ̵ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: غ̵ID +*/ +UINT16 GetGardoorKGHRelayId(const UINT16 garagedoorId); + +/* +* ȡָIDŷźŻ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: źŻ +*/ +UINT16 GetGardoorProtectSigSum(const UINT16 garagedoorId); + +/* +* ±ȡָIDŷźŻID +* ˵ const UINT16 garagedoorId, ID +* const UINT16 sigIndex, źŻ± +* ֵ 0: ȡʧ +* >0: źŻID +*/ +UINT16 GetGardoorProtectSigIdByIndex(const UINT16 garagedoorId,const UINT16 sigIndex); + + +/* +* ȡָIDspks +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: SPKS +*/ +UINT16 GetGarageSpksSum(const UINT16 garagedoorId); + +/* +* ±ȡָIDspksID +* ˵ const UINT16 garagedoorId, ID +* const UINT16 spksIndex, spks± +* ֵ 0: ȡʧ +* >0: SPKS ID +*/ +UINT16 GetGarageSpksIdBuff(const UINT16 garagedoorId,const UINT16 spksIndex); + +/* +* ȡָIDŹ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 GetGardoorphySecSum(const UINT16 garagedoorId); + +/* +* ±ȡָIDID +* ˵ const UINT16 garagedoorId, ID +* const UINT16 phyIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetGardoorphySecBuf(const UINT16 garagedoorId,const UINT16 phyIndex); +/* +* ij +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 GaragedoorConfigDataManage(void); +/* +* ȡָIDŹ· +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetGardoorRouteSum(const UINT16 garagedoorId); + +/* +* ±ȡָIDŹ·ID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetGardoorRouteIdBuf(const UINT16 garagedoorId); + +/* +* ȡָIDID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ID +*/ +UINT8 GetGaragedoorBelongVirCiId(const UINT16 garagedoorId); + +/* +* ȡָIDŶӦAID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0 ʧ + >0 AID +*/ +UINT16 GetGarageDoorAKuPhySec(const UINT16 garagedoorId); + +/* +* ȡָID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0 ʧ + 1 м + 2 ϴ +*/ +UINT8 GetGarageDoorAttribute(const UINT16 garagedoorId); + +/* +* ȡָIDŷźŻID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: źŻID +*/ +UINT16* GetGardoorProtectSigId(const UINT16 garagedoorId); + + +/* +* ȡָIDųźŻ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT8 GetGardoorProOutDir(const UINT16 garagedoorId); + +/* +* ȡָIDlink +* ˵ const UINT16 garagedoorId, ID +* ֵ linkID +* BY LC +*/ +UINT16 GetGardoorPointLink(const UINT16 garagedoorId); + +/* +* ȡָIDlinkƫ +* ˵ const UINT16 garagedoorId, ID +* ֵ ƫ +* BY LC +*/ +UINT32 GetGardoorPointLinkOffset(const UINT16 garagedoorId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDataManage.c b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDataManage.c new file mode 100644 index 0000000..f4b4614 --- /dev/null +++ b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDataManage.c @@ -0,0 +1,1261 @@ +/******************************************************** +* +* GaragedoorDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-17 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "GaragedoorDataManage.h" +#include "ELMDataPrepare.h" +#include "WLScreenDataPrepare.h" + +GaragedoorDataStruct GaragedoorDataStru[GARAGE_DOOR_SUM_MAX]; /*峵ݽṹ*/ + + +/* +* ȡָ +* ˵ +* ֵ + GaragedoorDataStruct * +*/ +GaragedoorDataStruct *GetGaragedoorData(void) +{ + return GaragedoorDataStru; +} + +/* +* ȡָID״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ״̬ +*/ +UINT8 GetGaragedoorState(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 garagedoorState = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + garagedoorState = GaragedoorDataStru[bufIndex].GaragedoorState; + } + return garagedoorState; +} + + +/* +* ָID״̬ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 garagedoorState, ״̬ +* ֵ 0u: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorState(const UINT16 garagedoorId, const UINT8 garagedoorState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if ((GARAGE_DOOR_STATE_OPEN == garagedoorState) || (GARAGE_DOOR_STATE_CLOSE == garagedoorState) + || (GARAGE_DOOR_STATE_UNVALID == garagedoorState)) + { + GaragedoorDataStru[bufIndex].GaragedoorState = garagedoorState; /*״̬*/ + + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + } + else + { + returnValue = CI_ERROR; + } + return returnValue; +} + +/* +* ȡָIDű־,ZC +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ȡݳɹ +*/ +UINT8 GetGaragedoorAllowCloseFlag(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ·±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorDataStru[bufIndex].GaragedoorAllowCloseFlag; + } + + return reVal; + +} + +/* +* ָIDű־ ZC +* ˵ const UINT16 garagedoorId, ID +* ֵ +* +*/ +void SetGaragedoorAllowCloseFlag(const UINT16 garagedoorId, const UINT8 allowCloseFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ·±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if ((GARAGE_DOOR_ALLOW_CLOSE_YES == allowCloseFlag) || (GARAGE_DOOR_ALLOW_CLOSE_NO == allowCloseFlag)) + { + + GaragedoorDataStru[bufIndex].GaragedoorAllowCloseFlag = allowCloseFlag; /*ű־*/ + + } + } +} + +/* +* ȡָIDű־,IVOC +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ȡݳɹ +*/ +UINT8 GetGaragedoorAllowCloseFlagIVOC(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ·±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorDataStru[bufIndex].GDAllowCloseFlagIVOC; + } + + return reVal; + +} + +/* +* ָIDű־ IVOC +* ˵ const UINT16 garagedoorId, ID +* ֵ +* +*/ +void SetGaragedoorAllowCloseFlagIVOC(const UINT16 garagedoorId, const UINT8 allowCloseFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ·±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if ((GARAGE_DOOR_ALLOW_CLOSE_YES == allowCloseFlag) || (GARAGE_DOOR_ALLOW_CLOSE_NO == allowCloseFlag)) + { + + GaragedoorDataStru[bufIndex].GDAllowCloseFlagIVOC = allowCloseFlag; /*ű־*/ + + } + } +} + + +/* +* ȡAӽŵгID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: гID +* LC +*/ +UINT16 GetGaragedoorNearestTrainId(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ·±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorDataStru[bufIndex].GDAkuNearestTrainId; + } + + return reVal; + +} + +/* +* AӽŵгID +* ˵ const UINT16 garagedoorId, ID +* const UINT16 trainId гID +* ֵ +* LC +*/ +void SetGaragedoorNearestTrainId(const UINT16 garagedoorId, const UINT16 trainId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ·±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if (UINT16_MAX!= trainId) + { + + GaragedoorDataStru[bufIndex].GDAkuNearestTrainId = trainId; /*ű־*/ + + } + } +} + +/* +* ȡָIDģʽ״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ȡģʽ״̬ +*/ +UINT8 GetGaragedoorModeState(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorDataStru[bufIndex].GaragedoorModeState; + } + return reVal; +} + + + +/* +* ָIDģʽ״̬ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 garagedoorModeState, ģʽ״̬ +* ֵ 0u: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorModeState(const UINT16 garagedoorId, const UINT8 garagedoorModeState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if ((GARAGE_DOOR_STATE_MODE_REMOTE == garagedoorModeState) || (GARAGE_DOOR_STATE_MODE_LOCAL == garagedoorModeState)) + { + GaragedoorDataStru[bufIndex].GaragedoorModeState = garagedoorModeState; /*ģʽ״̬*/ + + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + } + + return returnValue; +} + +/* +* ȡָIDŹ״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ + GARAGE_DOOR_FAULT_TRUE ŹΪ + GARAGE_DOOR_FAULT_FALSE ŹΪ + CI_ERROR ȡʧ +*/ +UINT8 GetGaragedoorFaultState(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorDataStru[bufIndex].GaragedoorFaultState; + } + + return reVal; +} + + + +/* +* ָIDŹ״̬ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 garagedoorFaultState, Ź״̬ +* ֵ 0u: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorFaultState(const UINT16 garagedoorId, const UINT8 garagedoorFaultState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if ((GARAGE_DOOR_FAULT_TRUE == garagedoorFaultState) || (GARAGE_DOOR_FAULT_FALSE == garagedoorFaultState)) + { + GaragedoorDataStru[bufIndex].GaragedoorFaultState = garagedoorFaultState; /*Ź״̬*/ + + returnValue = CI_SUCCESS; + } + + } + + return returnValue; +} + +/* +* ȡָID·״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ + GARAGE_DOOR_PANGLU_TRUE ·Ϊ + GARAGE_DOOR_PANGLU_FALSE ·Ϊ + CI_ERROR ȡʧ +*/ +UINT8 GetGaragedoorPangLuState(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + reVal = GaragedoorDataStru[bufIndex].GaragedoorPangLuState; + } + + return reVal; +} + +/* +* ָID·״̬ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 garagedoorPangLuState, ·״̬ +* ֵ 0u: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorPangLuState(const UINT16 garagedoorId, const UINT8 garagedoorPangLuState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if ((GARAGE_DOOR_PANGLU_TRUE == garagedoorPangLuState) || (GARAGE_DOOR_PANGLU_FALSE == garagedoorPangLuState)) + { + GaragedoorDataStru[bufIndex].GaragedoorPangLuState = garagedoorPangLuState; /*·״̬*/ + + returnValue = CI_SUCCESS; + } + } + + return returnValue; +} + + + +/* +* ȡָID״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: GARAGE_DOOR_DRV_OPEN GARAGE_DOOR_DRV_CLOSE GARAGE_DOOR_DRV_NULL +*/ +UINT8 GetDrvGaragedoorState(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + ret = GaragedoorDataStru[bufIndex].drvDoorState; + } + + return ret; +} + +/* +* ָID״̬ +* ˵ const UINT16 garagedoorId, ID +* UINT8 drvState , ״̬ +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: óɹ +*/ +UINT8 SetDrvGaragedoorState(const UINT16 garagedoorId,const UINT8 drvState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if((GARAGE_DOOR_DRV_OPEN == drvState) || (GARAGE_DOOR_DRV_CLOSE == drvState) || (GARAGE_DOOR_DRV_NULL == drvState)) + { + GaragedoorDataStru[bufIndex].drvDoorState = drvState; + ret = CI_SUCCESS; + } + } + + return ret; +} + + + +/* +* ȡָID״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ״̬ +*/ +UINT8 GetGrgdoorCmdProcessState(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + ret = GaragedoorDataStru[bufIndex].cmdProcessState; + } + + return ret; +} +/* +* ָID״̬ +* ˵ const UINT16 garagedoorId, ID +* UINT8 state , ״̬ +* ֵ 0u: ʧ +* >0u: óɹ +*/ +UINT8 SetGrgdoorCmdProcessState(const UINT16 garagedoorId,UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + if((GARAGE_DOOR_CMD_OPEN == state) || (GARAGE_DOOR_CMD_CLOSE == state) || (GARAGE_DOOR_CMD_NULL == state)) + { + GaragedoorDataStru[bufIndex].cmdProcessState = state; + ret = CI_SUCCESS; + } + } + + return ret; +} + +#if 0 +/* +* г״̬ +* ˵ +* UINT8 state , ״̬ +* ֵ 0u: ʧ +* >0u: óɹ +*/ +UINT8 SetAllGrgdoorCmdProcessState(const UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_SUCCESS; + UINT8 tmpRet = CI_SUCCESS; + UINT8 ii = 0u; + UINT16 doorId = 0u; + for (ii=0u;ii 0u ) + { + tmpRet = SetGrgdoorCmdProcessState(doorId, state); + if (CI_ERROR == tmpRet) + { + ret = tmpRet; + } + } + } + + return ret; +} +#endif + +/* +* ָIDŵȴZCʼʱ +* ˵ const UINT16 garagedoorId, ID +* const UINT32 startCycNum, ʼں +* ֵ +* +*/ +void SetWaiteZCResponseStartCycNum(const UINT16 garagedoorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + GaragedoorDataStru[bufIndex].waiteZCResponseStartCycNum = startCycNum; /*ʼں*/ + } + +} +/* +* ȡָIDŵȴZCʼʱ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ȡɹ +*/ +UINT32 GetWaiteZCResponseStartCycNum(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 ret = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + ret = GaragedoorDataStru[bufIndex].waiteZCResponseStartCycNum; + } + + return ret; +} + +/* +* ָIDŵȴIVOCʼʱ +* ˵ const UINT16 garagedoorId, ID +* const UINT32 startCycNum, ʼں +* ֵ +* BY LC +*/ +void SetWaiteIVOCResponseStartCycNum(const UINT16 garagedoorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + GaragedoorDataStru[bufIndex].waiteIVOCResponseStartCycNum = startCycNum; /*ʼں*/ + } + +} +/* +* ȡָIDŵȴIVOCʼʱ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ȡɹ +* BY LC +*/ +UINT32 GetWaiteIVOCResponseStartCycNum(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 ret = 0u; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + ret = GaragedoorDataStru[bufIndex].waiteIVOCResponseStartCycNum; + } + + return ret; +} + +/* +* ȡָIDŹʼں +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: رճʼں +*/ +UINT32 GetGaragedoorCloseStartCycNum(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + retVal = GaragedoorDataStru[bufIndex].GaragedoorCloseStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDŹʼں +* ˵ const UINT16 garagedoorId, ID +* const UINT32 startCycNum, رճʼں +* ֵ void +*/ +void SetGaragedoorCloseStartCycNum(const UINT16 garagedoorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + GaragedoorDataStru[bufIndex].GaragedoorCloseStartCycNum = startCycNum; /*Źʼں*/ + } + else + { + ; /**/ + } +} + +/* +* ȡָIDſʼں +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: 򿪳ʼں +*/ +UINT32 GetGaragedoorOpenStartCycNum(const UINT16 garagedoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + retVal = GaragedoorDataStru[bufIndex].GaragedoorOpenStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDſʼں +* ˵ const UINT16 garagedoorId, ID +* const UINT32 startCycNum, 򿪳ʼں +* ֵ 0u: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorOpenStartCycNum(const UINT16 garagedoorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetGaragedoorConfigBufIndex(garagedoorId); /*ȡ±*/ + + if (bufIndex < GARAGE_DOOR_SUM_MAX) + { + GaragedoorDataStru[bufIndex].GaragedoorOpenStartCycNum = startCycNum; /*ſʼں*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDڼ +* ˵ const UINT16 garagedoorId, ID +* UINT16 adjacentACID[GARAGE_DOOR_ADJACENT_AXIS] ڼ +* ֵ 0u: ȡʧ +* >0u: ڼĿ +* BY LC +*/ +UINT8 GetGarageDoorAdjacentAC(const UINT16 garagedoorId, OUT UINT16 adjacentACID[GARAGE_DOOR_ADJACENT_AXIS]) +{ + UINT8 retval = 0U; + UINT8 keepWork = CI_ERROR; + UINT16 phySecAId = 0U; /*ŶӦAID*/ + UINT8 phyAxisSecNum = 0U; /*ι*/ + UINT16* pPhyAxisIDBuf = NULL; /*ιID*/ + UINT8 i = 0U; + UINT8 indexAC = 0U; + UINT16* proSignalIdBuff = NULL; /*źŻ*/ + UINT8 outSignalDir = 0U; /*źŻ*/ + UINT8 attribute = 0U; /**/ + UINT8 adjacentACNumLJK = 0U; + UINT16 tmpACIdLJK[AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT8 adjacentACNumXCK = 0U; + UINT16 tmpACIdXCK[AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT8 cDirectionPointFlag = 0U; /*ѯǷз仯*/ + + if ((NULL != adjacentACID) && (0U != garagedoorId) && (GARAGE_DOOR_SUM_MAX > garagedoorId)) + { + keepWork = CI_SUCCESS; + /*ҳAΰ*/ + phySecAId = GetGarageDoorAKuPhySec(garagedoorId); + if (0U != phySecAId) + { + phyAxisSecNum = GetPAxisSectionSum(phySecAId);/*ȡι*/ + pPhyAxisIDBuf = GetPAxisSectionIdBuf(phySecAId);/*ȡιID*/ + /*A޵ֻһ*/ + if ((1U == phyAxisSecNum)&&(NULL!= pPhyAxisIDBuf)) + { + adjacentACID[indexAC] = pPhyAxisIDBuf[0]; + indexAC++; + } + else + { + /*ʧ*/ + keepWork = CI_ERROR; + } + } + else + { + /*ѯŶӦAIDʧ*/ + keepWork = CI_ERROR; + } + + /*ڼ*/ + if (CI_SUCCESS == keepWork) + { + attribute = GetGarageDoorAttribute(garagedoorId); + + /*м ѯⷽڵһ*/ + if (GARAGE_DOOR_ATTRIBUTE_LJK == attribute) + { + /*ȡźŻ*/ + outSignalDir = GetGardoorProOutDir(garagedoorId); + /*źŻһ*/ + adjacentACNumLJK = elm_PrepareAdjacentAC(pPhyAxisIDBuf[0], outSignalDir, tmpACIdLJK, &cDirectionPointFlag); + if ((1U == adjacentACNumLJK) && (UINT8_MAX != adjacentACNumLJK)) + {/*ѯһɹ*/ + adjacentACID[indexAC] = tmpACIdLJK[0]; + indexAC++; + } + else + { + keepWork = CI_ERROR; + } + } + /*ϴ 򶼲ѯڵһ*/ + else if (GARAGE_DOOR_ATTRIBUTE_XCK == attribute) + { + /*ѯ*/ + adjacentACNumXCK = elm_PrepareAdjacentAC(pPhyAxisIDBuf[0], EMAP_CONVER_DIR, tmpACIdXCK, &cDirectionPointFlag); + if ((1U == adjacentACNumXCK) && (UINT8_MAX != adjacentACNumXCK)) + { + adjacentACID[indexAC] = tmpACIdXCK[0]; + indexAC++; + } + else + { + keepWork = CI_ERROR; + } + (void)CommonMemSet(tmpACIdXCK, (UINT32)sizeof(tmpACIdXCK), 0, (UINT32)sizeof(tmpACIdXCK)); + /*ѯ*/ + adjacentACNumXCK = elm_PrepareAdjacentAC(pPhyAxisIDBuf[0], EMAP_SAME_DIR, tmpACIdXCK, &cDirectionPointFlag); + if ((1U == adjacentACNumXCK) && (UINT8_MAX != adjacentACNumXCK)) + { + adjacentACID[indexAC] = tmpACIdXCK[0]; + indexAC++; + } + else + { + keepWork = CI_ERROR; + } + } + else + { + /*Ч*/ + keepWork = CI_ERROR; + } + } + } + else + { + /*ʧ*/ + } + + if (CI_SUCCESS == keepWork) + { + retval = indexAC; + } + else + { + retval = 0U; + } + + return retval; +} + + +/* +* ָǷڳAϵ߹ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 axisNum Ŀ +* UINT16 axisID[GARAGE_DOOR_ADJACENT_AXIS] +* ֵ 0u: ʧ +* 1u: ͨ +* BY LC +*/ +UINT8 CheckGarageDoorSleepAC(const UINT16 garagedoorId, UINT16 axisID) +{ + UINT8 i = 0U; + UINT16 gdAkuPhySecId = 0U; + UINT16 tmpPhySecId = 0U; + UINT8 retval = CI_ERROR; + UINT8 sleepFlag = 0U; /*߹жϱ־*/ + UINT8 tmpLinkcnt = 0u; + const UINT16* pLinkIdBuf = NULL; + + /*ȡlink*/ + tmpLinkcnt = GetAxisLinkSum(axisID); + pLinkIdBuf = GetAxisLinkIdBuf(axisID); + if ((AXIS_SECTION_SUM_MAX > axisID) && (0U != axisID) && (0U != tmpLinkcnt) && (NULL != pLinkIdBuf)) + { + gdAkuPhySecId = GetGarageDoorAKuPhySec(garagedoorId); + + /*ȡ*/ + tmpPhySecId = elm_PrepareACRelPhyId(axisID); + /*ж߹*/ + sleepFlag = IsLinkSwTrack(pLinkIdBuf[0]); + + if (gdAkuPhySecId != tmpPhySecId) + { + /*ռѹβΪA*/ + retval = CI_ERROR; + } + else + { + /*Aϰlink߹*/ + if (CI_SUCCESS==sleepFlag) + { + retval = CI_SUCCESS; + } + else + { + /*ռѹβ߹*/ + retval = CI_ERROR; + } + + } + } + else + { + retval = CI_ERROR; + } + return retval; +} + + +/* +* ȡAǷΪVBTCռ +* ˵ const UINT16 garagedoorId, ID +* +* ֵ 0u: VBTCռ +* 1u: VBTCռû޳ +* BY LC +*/ +UINT8 CheckGarageDoorAKuIsCTOccu(const UINT16 garagedoorId) +{ + UINT8 i = 0U; + UINT16 gdAkuPhySecId = 0U; + UINT8 phySecStatus = 0U; + UINT8 retval = CI_ERROR; + UINT8 cPhySecIncLogSecSum = 0U; /*ΰ߼*/ + UINT16* pPhySecIncLogSecId = NULL; /*ΰ߼ID*/ + UINT8 logOccuState = 0U; + + gdAkuPhySecId = GetGarageDoorAKuPhySec(garagedoorId); + + + if ((0U != gdAkuPhySecId) && (PHYSICAL_SECTION_SUM_MAX > gdAkuPhySecId)) + { + retval = CI_SUCCESS; + /*ȡι߼Ϣ*/ + cPhySecIncLogSecSum = GetPhySecIncLogSecSum(gdAkuPhySecId); + pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(gdAkuPhySecId); + + for ( i = 0U; i < cPhySecIncLogSecSum; i++) + { + logOccuState = GetLogSecCurCtOrUtOccupyState(pPhySecIncLogSecId[i]); + if ((LOGICSECTION_OCCUPY_NO == logOccuState) || (LOGICSECTION_OCCUPY_CT == logOccuState)) + { + /*߼οлCTռã*/ + + } + else + { + retval = CI_ERROR; + break; + } + + } + } + + return retval; +} + +/* +* ȡAǷռ +* ˵ const UINT16 garagedoorId, ID +* +* ֵ 0u: ռ +* 1u: δռ +*/ +UINT8 GetGarageDoorAKuIsOccu(const UINT16 garagedoorId) +{ + UINT8 i = 0U; + UINT16 gdAkuPhySecId = 0U; + UINT8 phySecStatus = 0U; + UINT8 retval = CI_ERROR; + + gdAkuPhySecId = GetGarageDoorAKuPhySec(garagedoorId); + if ((0U != gdAkuPhySecId) && (PHYSICAL_SECTION_SUM_MAX > gdAkuPhySecId)) + { + phySecStatus = GetPhySecCurOccupyState(gdAkuPhySecId); + if (SECTION_OCCUPY_NO == phySecStatus) + { + retval = CI_SUCCESS; + } + else + { + /*Ϊ״̬ʧ*/ + } + } + + return retval; +} + + + +/* ȡŹĴѰ״̬ķ· +* ˵ const UINT16 garagedoorId, ID + UINT16 routeId[GARAGE_DOOR_ROUTE_MAX] ѰĽ·ID +* ֵ ѰĽ· +*/ +UINT8 GetProRouteInTransactState(const UINT16 garagedoorId, OUT UINT16 routeId[GARAGE_DOOR_ROUTE_MAX]) +{ + UINT16* routeIdbuff = NULL; /*·*/ + UINT8 routeNum = 0U; /*·*/ + UINT8 i = 0U; + UINT8 transactFlag = CI_ERROR; /*·δ־־*/ + UINT8 transactNum = 0U; + + routeNum = GetGardoorRouteSum(garagedoorId); + routeIdbuff = GetGardoorRouteIdBuf(garagedoorId); + + if ((0U != routeNum) && (NULL != routeIdbuff)) + { + /*Ѱķ·*/ + for (i = 0U; i < routeNum; i++) + { + transactFlag = CheckRouteTransactState(routeIdbuff[i]); + if (ROUTE_TRANSACT_NO != transactFlag) + { + /*·Ѱ*/ + routeId[transactNum] = routeIdbuff[i]; + transactNum++; + + } + else + { + /*·δ*/ + } + + } + } + return transactNum; +} + + +/* ѯA복ӽг +* ˵ const UINT16 garagedoorId, ID +* ֵ !=UINT16_MAX гID +* UINT16_MAX ѯʧ +* BY LC +*/ +UINT16 FindNearestTrainInAKuPhy(const UINT16 garagedoorId) +{ + UINT16 phySecAKuId = 0U; + UINT8 cPhySecIncLogSecSum = 0U; /*ΰ߼*/ + UINT16* pPhySecIncLogSecId = NULL; /*ΰ߼ID*/ + UINT8 i = 0U; + UINT8 j = 0U; + UINT8 wTrainNum = 0U; + UINT16 wTrainIdBuff[SIZE_MAX_TRAINOFAC] = { 0U }; + UINT8 tmpLogState = 0U; + UINT8 retVal = CI_ERROR; + UINT32 dwLen = 0U; + + UINT32 minLen = UINT32_MAX; + UINT16 minTrainId = 0U; + LOD_STRU gDPoint = { 0U }; /*λ*/ + LOD_STRU trainMinTailPoint = { 0U }; /*гСλ*/ + UINT8 keepwork = CI_ERROR; + + + gDPoint.Lnk = GetGardoorPointLink(garagedoorId); + gDPoint.Off = GetGardoorPointLinkOffset(garagedoorId); + + phySecAKuId = GetGarageDoorAKuPhySec(garagedoorId); + cPhySecIncLogSecSum = GetPhySecIncLogSecSum(phySecAKuId); + pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(phySecAKuId); + + if ((0U != cPhySecIncLogSecSum) && (NULL != pPhySecIncLogSecId)) + { + keepwork = CI_SUCCESS; + + /* ȡAռѹ߼ */ + for (i = 0U; i < cPhySecIncLogSecSum; i++) + { + tmpLogState= GetLogSecCurCtOrUtOccupyState(pPhySecIncLogSecId[i]); + if (LOGICSECTION_OCCUPY_NO == tmpLogState) + { + /**/ + } + else + { + /*ջ*/ + (void)CommonMemSet(wTrainIdBuff, (UINT32)sizeof(wTrainIdBuff), 0u, (UINT32)sizeof(wTrainIdBuff)); + wTrainNum = 0U; + + /*ȡ߼г*/ + wTrainNum = GetLogSecTrainId(pPhySecIncLogSecId[i], &wTrainIdBuff); + + for (j = 0; j < wTrainNum; j++) + { + if (NAME_FAILUREAREA != wTrainIdBuff[j]) + { + trainMinTailPoint.Lnk= GetTrainMinTailLink(wTrainIdBuff[j]); + trainMinTailPoint.Off= GetTrainMinTailOffset(wTrainIdBuff[j]); + + dwLen = elm_PrepareDistanceBtwPoints(trainMinTailPoint, gDPoint); + if (minLen > dwLen) + { + minLen = dwLen; + minTrainId = wTrainIdBuff[j]; + } + } + } + if (UINT32_MAX == minLen) + { + keepwork = CI_ERROR; + } + + } + + + if (CI_ERROR == keepwork) + { + minTrainId = UINT16_MAX; + break; + } + + } + } + return minTrainId; +} + + + +/* гӽһ޿ +* ˵ UINT16 garageDoorId +* UINT16 trainId гID +* ֵ CI_ERROR ڿ +* CI_SUCCESS ޿ +* BY LC +*/ +UINT8 CheckNearestTrainScreen(const UINT16 garageDoorId, const UINT16 trainId, const UINT8 functionId, const UINT8 sendLevel) +{ + UINT8 retVal = CI_ERROR; + LOD_STRU pointMaxHead = { 0U }; + LOD_STRU pointMinTail = { 0U }; + LOD_STRU pointGD = { 0U }; + UINT16 linkNum = 0U; + UINT16 szLinkIdBuf[100u] = { 0u }; + UINT8 chDir = 0U; + UINT32 dwLenMaxHead = 0U; + UINT32 dwLenMinTail = 0U; + UINT8 flag = CI_ERROR; + UINT16 phySecAku = 0U; + UINT16 AxisAku = 0U; + UINT16* axisSecIdBuf = NULL; /*ΰIDָ*/ + UINT8 axisSectionSum = 0U; + + phySecAku = GetGarageDoorAKuPhySec(garageDoorId); + axisSecIdBuf = GetPAxisSectionIdBuf(phySecAku); /*ȡΰIDָ*/ + axisSectionSum = GetPAxisSectionSum(phySecAku); /*ȡΰĿ*/ + + pointMaxHead.Lnk = GetTrainMaxHeadLink(trainId); + pointMaxHead.Off = GetTrainMaxHeadOffset(trainId); + pointMinTail.Lnk = GetTrainMinTailLink(trainId); + pointMinTail.Off = GetTrainMinTailOffset(trainId); + pointGD.Lnk = GetGardoorPointLink(garageDoorId); + pointGD.Off = GetGardoorPointLinkOffset(garageDoorId); + dwLenMaxHead = dsuLenByPoint(&pointMaxHead, &pointGD, &linkNum, szLinkIdBuf, &chDir); + dwLenMinTail = dsuLenByPoint(&pointMinTail, &pointGD, &linkNum, szLinkIdBuf, &chDir); + + + if (dwLenMaxHead > dwLenMinTail) + { + /*ѯ*/ + flag = elm_CheckTrainTailTrain(axisSecIdBuf[0],trainId); + if (FLAG_SET == flag) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_TRAIN_VOBC, trainId, ETYPE_GDOOR_TRAIN_TAILSCREEN, flag, sendLevel); + } + } + else + { + /*ѯǰ*/ + flag = elm_CheckTrainheadTrain(axisSecIdBuf[0], trainId); + + if (FLAG_SET == flag) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_TRAIN_VOBC, trainId, ETYPE_GDOOR_TRAIN_HEADSCREEN, flag, sendLevel); + } + } + + + return retVal; +} + + +/* гǷѹ +* ˵ UINT16 garageDoorId +* UINT16 trainId гID +* ֵ CI_ERROR ѹ +* CI_SUCCESS δѹ +* BY LC +*/ +UINT8 CheckNearestTrainKuaya(const UINT16 garageDoorId, const UINT16 trainId, const UINT8 functionId, const UINT8 sendLevel) +{ + UINT8 retVal = CI_ERROR; + LOD_STRU pointMaxHead = { 0U }; + LOD_STRU pointMinTail = { 0U }; + struct_PathPoint pointGD = { 0U }; + UINT16 wLinkNum = 0U; + str_Zone strTrainZone = { 0u }; + + + pointMaxHead.Lnk = GetTrainMaxHeadLink(trainId); + pointMaxHead.Off = GetTrainMaxHeadOffset(trainId); + pointMinTail.Lnk = GetTrainMinTailLink(trainId); + pointMinTail.Off = GetTrainMinTailOffset(trainId); + + + strTrainZone.Dir = GetTrainDir(trainId); + strTrainZone.pStart.wLinkId = pointMaxHead.Lnk; + strTrainZone.pStart.dwOffset = pointMaxHead.Off; + strTrainZone.pEnd.wLinkId = pointMinTail.Lnk; + strTrainZone.pEnd.dwOffset = pointMinTail.Off; + + retVal = DsuLinkSeqBtwPoints(&strTrainZone.pStart, &strTrainZone.pEnd, &strTrainZone.Dir, &wLinkNum, strTrainZone.pLinkSeq.szLinkId); + strTrainZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + + pointGD.wLinkId = GetGardoorPointLink(garageDoorId); + pointGD.dwOffset = GetGardoorPointLinkOffset(garageDoorId); + + + retVal=IsPointInPath(pointGD, strTrainZone); + + + + if (CI_SUCCESS== retVal) + { + /*δѹ*/ + } + else + { + /*ѹ*/ + retVal = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_TRAIN_VOBC, trainId, ETYPE_GDOOR_TRAIN_KUAYAGD, 0U, sendLevel); + } + + + return retVal; +} + +/* 鳵ڼǷ +* ˵ UINT16 garageDoorId +* * UINT16* pDevId յIDΣ +* UINT8* pDevState ״̬Σ +* ֵ CI_ERROR +* CI_SUCCESS δ +* BY LC +*/ +UINT8 CheckGDAdjacentACLockState(const UINT16 garageDoorId,UINT16* pDevId, UINT8* pDevState) +{ + UINT8 retVal = CI_ERROR; + UINT16 adjacentACID[GARAGE_DOOR_ADJACENT_AXIS] = { 0U }; /*ڼID*/ + UINT8 adjacentACNum = 0U; /*ڼ*/ + UINT8 i = 0U; + UINT16 phySecId = 0U; + UINT8 phyLockState = 0U; + /*ѯŵڼᡪŶӦAΰἰⷽһ*/ + adjacentACNum = GetGarageDoorAdjacentAC(garageDoorId, adjacentACID); + if ((0U != adjacentACNum) && (GARAGE_DOOR_ADJACENT_AXIS > adjacentACNum) && (NULL != pDevId) && (NULL != pDevState)) + {/*ڼѯɹ*/ + retVal = CI_SUCCESS; + /*ڼᣬɸѡռõڼ*/ + for (i = 0U; i < adjacentACNum; i++) + { + phySecId = GetAxisSecRelativePhySecId(adjacentACID[i]); + + phyLockState = GetPhySecLockState(phySecId); + + if (PHYSICAL_SECTION_LOCK_NO == phyLockState) + { + /*˼δգ*/ + } + else + { + *pDevId = phySecId; + *pDevState = phyLockState; + /*գʧ*/ + retVal = CI_ERROR; + break; + } + } + } + else + { + /*ѯʧ*/ + } + return retVal; +} + + diff --git a/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDataManage.h b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDataManage.h new file mode 100644 index 0000000..2c9c7e3 --- /dev/null +++ b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDataManage.h @@ -0,0 +1,387 @@ +/******************************************************** +* +* GaragedoorDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-17 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _GARAGEDOOR_DATA_MANAGE_H_ +#define _GARAGEDOOR_DATA_MANAGE_H_ + +#include "GaragedoorDefine.h" +#include "GaragedoorConfigDataManage.h" +#include "CommonTypes.h" +#include "../DataManage/DeviceDataManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*ݽṹ*/ +typedef struct S_GaragedoorDataStruct +{ + UINT16 GaragedoorId; /*ID (ʼֶ)*/ + UINT8 GaragedoorState; /*״̬ (ֶ̬)*/ + UINT8 GaragedoorAllowCloseFlag; /*ű־ZC*/ + UINT8 GDAllowCloseFlagIVOC; /*ű־IVOC*/ + UINT16 GDAkuNearestTrainId; /*Aӽг*/ + UINT8 GaragedoorModeState; /*ģʽ״̬*/ + UINT8 GaragedoorFaultState; /*Ź״̬*/ + UINT8 GaragedoorPangLuState; /*·״̬*/ + UINT8 drvDoorState; /* ״̬*/ + UINT8 cmdProcessState; /* ״̬ */ + UINT32 drvDoorStartCycle; /* ʼʱ,Ԥ */ + UINT32 waiteZCResponseStartCycNum; /*ȴZCʼʱ*/ + UINT32 waiteIVOCResponseStartCycNum; /*ȴIVOCʼʱ*/ + UINT32 GaragedoorOpenStartCycNum; /*Ŵ򿪿ʼ (ֶ̬)*/ + UINT32 GaragedoorCloseStartCycNum; /*Źرտʼ (ֶ̬)*/ +} GaragedoorDataStruct; + + +extern GaragedoorDataStruct GaragedoorDataStru[GARAGE_DOOR_SUM_MAX]; /*峵ݽṹ*/ + +/* +* ȡָ +* ˵ +* ֵ + GaragedoorDataStruct * +*/ +GaragedoorDataStruct *GetGaragedoorData(void); + +/* +* ȡָID״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetDrvGaragedoorState(const UINT16 garagedoorId); +/* +* ָID״̬ +* ˵ const UINT16 garagedoorId, ID +* UINT8 drvState , ״̬ +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: óɹ +*/ +UINT8 SetDrvGaragedoorState(const UINT16 garagedoorId,const UINT8 drvState); + +/* +* ȡָID״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetGrgdoorCmdProcessState(const UINT16 garagedoorId); +/* +* ָID״̬ +* ˵ const UINT16 garagedoorId, ID +* UINT8 drvState , ״̬ +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 SetGrgdoorCmdProcessState(const UINT16 garagedoorId,UINT8 state); + + +/* +* ȡָID״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetGaragedoorState(const UINT16 garagedoorId); + +/* +* ָID״̬ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 garagedoorState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorState(const UINT16 garagedoorId, const UINT8 garagedoorState); + +/* +* ȡָIDű־ ZC +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 GetGaragedoorAllowCloseFlag(const UINT16 garagedoorId); + + +/* +* ָIDű־ ZC +* ˵ const UINT16 garagedoorId, ID +* ֵ +* +*/ +void SetGaragedoorAllowCloseFlag(const UINT16 garagedoorId, const UINT8 allowCloseFlag); + +/* +* ȡָIDű־,IVOC +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ȡݳɹ +*/ +UINT8 GetGaragedoorAllowCloseFlagIVOC(const UINT16 garagedoorId); + +/* +* ָIDű־ IVOC +* ˵ const UINT16 garagedoorId, ID +* ֵ +* +*/ +void SetGaragedoorAllowCloseFlagIVOC(const UINT16 garagedoorId, const UINT8 allowCloseFlag); + +/* +* ȡAӽŵгID +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: гID +* LC +*/ +UINT16 GetGaragedoorNearestTrainId(const UINT16 garagedoorId); + +/* +* AӽŵгID +* ˵ const UINT16 garagedoorId, ID +* const UINT16 trainId гID +* ֵ +* LC +*/ +void SetGaragedoorNearestTrainId(const UINT16 garagedoorId, const UINT16 trainId); + +#if 0 +/* +* г״̬ +* ˵ +* UINT8 state , ״̬ +* ֵ 0: ʧ +* >0: óɹ +*/ +UINT8 SetAllGrgdoorCmdProcessState(const UINT8 state); +#endif + +/* +* ָIDģʽ״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetGaragedoorModeState(const UINT16 garagedoorId); +/* +* ָIDģʽ״̬ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 garagedoorModeState, ģʽ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorModeState(const UINT16 garagedoorId, const UINT8 garagedoorModeState); + +/* +* ȡָIDŹ״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ + GARAGE_DOOR_FAULT_TRUE ŹΪ + GARAGE_DOOR_FAULT_FALSE ŹΪ + GARAGE_DOOR_FAULT_NULL Ź״̬Ч +*/ +UINT8 GetGaragedoorFaultState(const UINT16 garagedoorId); + +/* +* ָIDŹ״̬ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 garagedoorFaultState, Ź״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorFaultState(const UINT16 garagedoorId, const UINT8 garagedoorFaultState); + +/* +* ȡָID·״̬ +* ˵ const UINT16 garagedoorId, ID +* ֵ + GARAGE_DOOR_PANGLU_TRUE ·Ϊ + GARAGE_DOOR_PANGLU_FALSE ·Ϊ + CI_ERROR ȡʧ +*/ +UINT8 GetGaragedoorPangLuState(const UINT16 garagedoorId); + +/* +* ָID·״̬ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 garagedoorPangLuState, Ź״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorPangLuState(const UINT16 garagedoorId, const UINT8 garagedoorPangLuState); + + +/* +* ָIDŵȴZCʼʱ +* ˵ const UINT16 garagedoorId, ID +* const UINT32 startCycNum, ʼں +* ֵ +* +*/ +void SetWaiteZCResponseStartCycNum(const UINT16 garagedoorId, const UINT32 startCycNum); +/* +* ȡָIDŵȴZCʼʱ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT32 GetWaiteZCResponseStartCycNum(const UINT16 garagedoorId); + +/* +* ָIDŵȴIVOCʼʱ +* ˵ const UINT16 garagedoorId, ID +* const UINT32 startCycNum, ʼں +* ֵ +* BY LC +*/ +void SetWaiteIVOCResponseStartCycNum(const UINT16 garagedoorId, const UINT32 startCycNum); + +/* +* ȡָIDŵȴIVOCʼʱ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ȡɹ +* BY LC +*/ +UINT32 GetWaiteIVOCResponseStartCycNum(const UINT16 garagedoorId); + + +/* +* ȡָIDŹʼں +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: رճʼں +*/ +UINT32 GetGaragedoorCloseStartCycNum(const UINT16 garagedoorId); + +/* +* ָIDŹʼں +* ˵ const UINT16 garagedoorId, ID +* const UINT32 startCycNum, رճʼں +* ֵ void +*/ +void SetGaragedoorCloseStartCycNum(const UINT16 garagedoorId, const UINT32 startCycNum); +/* +* ȡָIDſʼں +* ˵ const UINT16 garagedoorId, ID +* ֵ 0: ȡʧ +* >0: 򿪳ʼں +*/ +UINT32 GetGaragedoorOpenStartCycNum(const UINT16 garagedoorId); + +/* +* ָIDſʼں +* ˵ const UINT16 garagedoorId, ID +* const UINT32 startCycNum, 򿪳ʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetGaragedoorOpenStartCycNum(const UINT16 garagedoorId, const UINT32 startCycNum); + +/* +* ȡָIDڼ +* ˵ const UINT16 garagedoorId, ID +* ֵ 0u: ȡʧ +* >0u: ڼĿ +*/ +UINT8 GetGarageDoorAdjacentAC(const UINT16 garagedoorId, OUT UINT16 adjacentACID[GARAGE_DOOR_ADJACENT_AXIS]); + + + +/* +* ָǷڳAϵ߹ +* ˵ const UINT16 garagedoorId, ID +* const UINT8 axisNum Ŀ +* UINT16 axisID[GARAGE_DOOR_ADJACENT_AXIS] +* ֵ 0u: ʧ +* 1u: ͨ +* BY LC +*/ +UINT8 CheckGarageDoorSleepAC(const UINT16 garagedoorId, UINT16 axisID); + +/* +* ȡAǷΪVBTCռ +* ˵ const UINT16 garagedoorId, ID +* +* ֵ 0u: VBTCռ +* 1u: VBTCռû޳ +* BY LC +*/ +UINT8 CheckGarageDoorAKuIsCTOccu(const UINT16 garagedoorId); + +/* +* ȡAǷռ +* ˵ const UINT16 garagedoorId, ID +* +* ֵ 0u: ռ +* 1u: δռ +*/ +UINT8 GetGarageDoorAKuIsOccu(const UINT16 garagedoorId); + +/* ȡŹĴѰ״̬ķ· +* ˵ const UINT16 garagedoorId, ID + UINT16 routeId[GARAGE_DOOR_ROUTE_MAX] ѰĽ·ID +* ֵ ѰĽ· +*/ +UINT8 GetProRouteInTransactState(const UINT16 garagedoorId, OUT UINT16 routeId[GARAGE_DOOR_ROUTE_MAX]); + + + +/* ѯA복ӽг +* ˵ const UINT16 garagedoorId, ID +* ֵ !=UINT16_MAX гID +* UINT16_MAX ѯʧ +* BY LC +*/ +UINT16 FindNearestTrainInAKuPhy(const UINT16 garagedoorId); + + + + +/* гӽһ޿ +* ˵ UINT16 garageDoorId +* UINT16 trainId гID +* ֵ CI_ERROR ڿ +* CI_SUCCESS ޿ +* BY LC +*/ +UINT8 CheckNearestTrainScreen(const UINT16 garageDoorId, const UINT16 trainId, const UINT8 functionId, const UINT8 sendLevel); + + +/* гǷѹ +* ˵ UINT16 garageDoorId +* UINT16 trainId гID +* ֵ CI_ERROR ѹ +* CI_SUCCESS δѹ +* BY LC +*/ +UINT8 CheckNearestTrainKuaya(const UINT16 garageDoorId, const UINT16 trainId, const UINT8 functionId, const UINT8 sendLevel); + +/* 鳵ڼǷ +* ˵ UINT16 garageDoorId +* * UINT16* pDevId յIDΣ +* UINT8* pDevState ״̬Σ +* ֵ CI_ERROR +* CI_SUCCESS δ +* BY LC +*/ +UINT8 CheckGDAdjacentACLockState(const UINT16 garageDoorId, UINT16* pDevId, UINT8* pDevState); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDefine.h b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDefine.h new file mode 100644 index 0000000..4e0de2e --- /dev/null +++ b/TSCP/src/APP/ciapp/Garagedoor/GaragedoorDefine.h @@ -0,0 +1,59 @@ +/******************************************************** +* +* GaragedoorDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-17 +* ߣ +* ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _GARAGE_DOOR_CONFIG_H_ +#define _GARAGE_DOOR_CONFIG_H_ + + + + +/*ֵ*/ +#define GARAGE_DOOR_SUM_MAX ((UINT16)80) /*峵ֵ*/ +#define GARAGE_DOOR_SIG_MAX ((UINT16)6) /* źŻ */ +#define GARAGE_DOOR_ENTER_ROUTE_MAX ((UINT16)10) /* · */ +#define GARAGE_DOOR_EXIT_ROUTE_MAX ((UINT16)8) /* · */ +#define GARAGE_DOOR_SPKS_MAX ((UINT16)4) /*ŶӦSPKSֵ*/ +#define GARAGE_DOOR_PHY_SEC_MAX ((UINT16)20) /* Ź */ +#define GARAGE_DOOR_ROUTE_MAX ((UINT16)18) /* Ź· */ +#define GARAGE_DOOR_ADJACENT_AXIS ((UINT16)5) /* Źڼ */ + + +/*״̬*/ +#define GARAGE_DOOR_STATE_OPEN ((UINT8)0x55) /*Ŵ*/ +#define GARAGE_DOOR_STATE_CLOSE ((UINT8)0xaa) /*Źر*/ +#define GARAGE_DOOR_STATE_UNVALID ((UINT8)0xff) /*ŷǿҲǹ״̬*/ +#define GARAGE_DOOR_STATE_MODE_LOCAL ((UINT8)0xaa) /*űģʽ״̬*/ +#define GARAGE_DOOR_STATE_MODE_REMOTE ((UINT8)0x55) /*Զģʽ״̬*/ + +/* ر״̬ */ +#define GARAGE_DOOR_ALLOW_CLOSE_YES ((UINT8)0x55) /*ر*/ +#define GARAGE_DOOR_ALLOW_CLOSE_NO ((UINT8)0xaa) /*Ųر*/ + +/* ״̬ */ +#define GARAGE_DOOR_DRV_OPEN ((UINT8)0x55) /* Ŵ*/ +#define GARAGE_DOOR_DRV_CLOSE ((UINT8)0xAA) /* Źر*/ +#define GARAGE_DOOR_DRV_NULL ((UINT8)0xFF) /* Ч */ + +#define GARAGE_DOOR_CMD_OPEN ((UINT8)0x55) /* Ŵ*/ +#define GARAGE_DOOR_CMD_CLOSE ((UINT8)0xAA) /* Źر*/ +#define GARAGE_DOOR_CMD_NULL ((UINT8)0xFF) /* Ч */ + +#define GARAGE_DOOR_FAULT_TRUE ((UINT8)0x55) /*ŹΪ*/ +#define GARAGE_DOOR_FAULT_FALSE ((UINT8)0xAA) /* ŹΪ*/ + +#define GARAGE_DOOR_PANGLU_TRUE ((UINT8)0x55) /*·Ϊ*/ +#define GARAGE_DOOR_PANGLU_FALSE ((UINT8)0xAA) /* ·Ϊ*/ + +#define GARAGE_DOOR_ATTRIBUTE_LJK ((UINT8)0x55) /*ԣм*/ +#define GARAGE_DOOR_ATTRIBUTE_XCK ((UINT8)0xaa) /*ԣϴ*/ +#endif diff --git a/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTCommonDataPacketHead.c b/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTCommonDataPacketHead.c new file mode 100644 index 0000000..be74c30 --- /dev/null +++ b/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTCommonDataPacketHead.c @@ -0,0 +1,369 @@ +/******************************************************** +* +* HLHTCommonDataPacketHead.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-10-21 +* ߣ Ʒ +* ͨͨñͷУ鼰ϢЧԼ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ +#include "HLHTCommonDataPacketHead.h" +#include "../DataManage/DeviceConfigDataManage.h" +#include "../QueryFiles/dquCIInterFace.h" + +/************************************************************************************************************* +* յͨϢʱ,ϢʣЧ +* + const UINT16 maxMsgValidTime ĿԼĸϢЧ ; + const UINT32 CurrentOwnSN ĵǰں + const UINT32 SNPeriod ͨڣCIϵͳУΪӦõ + const HLHTGALInfoStruct *pRecvCommonPackage ͨϢͷ + const UINT32 srcRecvCiMsgSN,Էϴյı + const UINT32 srcCrntOwnMsgSN,Էʱ䵱ǰ + const UINT32 srcPreOwnMsgSN,Էϴյʱ䵱ʱ + const UINT32 srcPeriod,Էͨ +* . +* ֵRemainValidity ϢʣЧ +*************************************************************************************************************/ +INT32 HLHTCommonMsgRemainingValidity( + const UINT32 MaxMsgValidTime, + const UINT32 CurrentOwnSN, + const UINT32 SNPeriod, + const UINT32 srcRecvCiMsgSN, + const UINT32 srcCrntOwnMsgSN, + const UINT32 srcPreOwnMsgSN, + const UINT32 srcPeriod) +{ + INT32 RemainValidity = 0; + + if((SNPeriod<=0u) || (srcPeriod <=0u)) + { + RemainValidity = -1; + } + else if( MaxMsgValidTime <= 0u ) + { + RemainValidity = -1; + } + else if(srcRecvCiMsgSN > CurrentOwnSN) + { + RemainValidity = -1; + } + else if(srcPreOwnMsgSN > srcCrntOwnMsgSN) + { + RemainValidity = -1; + } + else if (((INT32)CurrentOwnSN - (INT32)(srcRecvCiMsgSN))*((INT32)(SNPeriod)) - + ((INT32)(srcCrntOwnMsgSN)-(INT32)(srcPreOwnMsgSN))*((INT32)(srcPeriod)) <= 0) + { + RemainValidity = (INT32)MaxMsgValidTime - (((INT32)CurrentOwnSN - (INT32)(srcRecvCiMsgSN))*((INT32)SNPeriod)); + } + else + { + /*ͨյϢеĻظ"һ"ϢʱRcvOppSN,ܵӳ, + ټȥϢڶԷ豸ڵʱ,Ӷõ˫Ĵӳ,Ϊӳʹ*/ + RemainValidity = (INT32)MaxMsgValidTime - (((INT32)CurrentOwnSN - (INT32)(srcRecvCiMsgSN))*((INT32)(SNPeriod)) - + ((INT32)(srcCrntOwnMsgSN)-(INT32)(srcPreOwnMsgSN))*((INT32)(srcPeriod))); + } + return RemainValidity; +} + +/************************************************************************* +* : յͨϢͷϢϷԼ +* : UINT16 LocalDevName ͷ豸 +* UINT16 RemoteDevName շ豸 +* UINT16 DevInterfaceType 豸豸ӿ +* UINT8 prtrlVer ӿЭ汾 +* HLHTGALInfoStruct *pMICommonPackage CI͸VOBCͨϢͷ +* UINT16 logId VOBC 1˻2˱ʶ +* UINT8 devType ͨ豸 +* : UINT32 *pErrorCode CIӿеĹϺ. +* : . +* ȫֱ: .. +* ֵ: +HLHT_HEAD_SUCCESS (0x55) ͨͷȷ +HLHT_HEAD_ERROR (0xaa) ͨͷ +HLHT_HEAD_INIT (0x33) ͷǻͨʼͨ֡ +*************************************************************************/ +UINT8 HLHTRecvCommonPacketHeadCheck(UINT16 LocalDevName, UINT16 RemoteDevName, UINT16 DevInterfaceType, UINT8 prtrlVer, HLHTGALInfoStruct *pMICommonPackage, UINT32 *pErrorCode,UINT16 logId,UINT8 devType) +{ + UINT8 retVal = CI_ERROR; + UINT32 LocalEtcsId = 0u; /*ͷʶ*/ + UINT32 RemoteEtcsId = 0u; /*շʶ*/ + UINT32 emapVer = 0U;/*Ӧʹõĵӵͼ汾*/ + UINT8 emapCheckVer = 0U; /*ӵͼ汾У*/ + UINT8 chRet = 0U; + + /*ÿζ*/ + *pErrorCode = 0u; + + /*жϸϢǷںϷΧ,ֻҪдӦ*/ + if (pMICommonPackage->devInterInfoType != DevInterfaceType) + { + *pErrorCode |= GAL_COMPARE_INFO_TYPE_ERR; + } + else + { + ; + } + + /*ͷУ*/ + chRet = dquDevName2HlhtId(LocalDevName, logId, &LocalEtcsId); + if ((CI_ERROR == chRet) || (pMICommonPackage->sourceId != LocalEtcsId)) + { + *pErrorCode |= GAL_COMPARE_SEND_FLAG_ERR; + } + else + { + ; + } + + /*շУ*/ + chRet = dquDevName2HlhtId(RemoteDevName, logId, &RemoteEtcsId); + if ((CI_ERROR == chRet) || (pMICommonPackage->destId != RemoteEtcsId)) + { + *pErrorCode |= GAL_COMPARE_RECV_FLAG_ERR; + } + else + { + ; + } + + emapCheckVer = GetCiEmapCheckVer((UINT8)RemoteDevName, &emapVer, devType); + if (CI_SUCCESS == emapCheckVer) + { + /*ӵͼ汾УϢ(4ֽCRCȽ)*/ + if (emapVer != pMICommonPackage->emapVerCrc) + { + *pErrorCode |= GAL_COMPARE_EMAP_VER_COMP_ERR; + } + else + { + ; + } + } + else + { + *pErrorCode |= GAL_COMPARE_EMAP_VER_COMP_ERR; + } + +#if 0 + else + { + /*ȽϽһ,Уʧ*/ + vCIDBVerCmpRst = CBTC_FALSE; + /*ATSӿеӵͼ汾VOBCIJһ,¼˴ԭ*/ + /*ݲ֧,ҽӿ̶TO BE DONE 20160817*/ + /**pErrorCode |= CI_COMPACK_EMAP_VER_COMP_ERR;*/ + } +#endif + + /* кźϷԼ, (2^31-1u)*/ + if ((1u > pMICommonPackage->crntOwnMsgSN) || (((UINT32)0x7FFFFFFF) < pMICommonPackage->crntOwnMsgSN) + || (1u > pMICommonPackage->recvOppMsgSN) || (((UINT32)0x7FFFFFFF) < pMICommonPackage->recvOppMsgSN) + || (1u > pMICommonPackage->preOwnMsgSN) || (((UINT32)0x7FFFFFFF) < pMICommonPackage->preOwnMsgSN)) + { + *pErrorCode |= GAL_COMPARE_MSG_BDS_SN_ERR; + } + else + { + ; + } + + /* Э汾 */ + if (prtrlVer != pMICommonPackage->prtclVer) + { + *pErrorCode |= GAL_COMPARE_PROTOCOL_VER_ERR; + } + else + { + ; + } + + /* Ӧݳ */ + if (0u >= pMICommonPackage->totalDataLen) + { + *pErrorCode |= GAL_COMPARE_APP_LEN_ERR; + } + else + { + ; + } + /*ͨϢͨ*/ + if (0u == pMICommonPackage->comPeriod) + { + *pErrorCode |= GAL_COMPARE_COM_PERIOD; + } + else + { + ; + } + + /*ӿϢûз,ȷ;򷵻ش*/ + if (0u == *pErrorCode) + { + /*ӿȫȷ,ȷ*/ + retVal = HLHT_HEAD_SUCCESS; + } + else if (GAL_COMPARE_MSG_BDS_SN_ERR == *pErrorCode) + { + if ((0u < pMICommonPackage->crntOwnMsgSN) && (UINT32_MAX == pMICommonPackage->recvOppMsgSN) && (UINT32_MAX == pMICommonPackage->preOwnMsgSN)) + {/*˵Էûյ֡ǰ֡dzʼ֡*/ + retVal = HLHT_HEAD_INIT; + } + else + { + retVal = HLHT_HEAD_ERROR; + } + } + else + { + retVal = HLHT_HEAD_ERROR; + } + + return retVal; +} + +/************************************************************************* +* : յCIͨϢͷϢϷԼ +* : UINT16 LocalDevName ͷ豸 +* UINT16 RemoteDevName շ豸 +* UINT16 DevInterfaceType 豸豸ӿ +* UINT8 prtrlVer ӿЭ汾 +* HLHTGALInfoStruct *pMICommonPackage CI͸VOBCͨϢͷ +* UINT16 logId VOBC 1˻2˱ʶ +* UINT8 devType ͨ豸 +* : UINT32 *pErrorCode CIӿеĹϺ. +* : . +* ȫֱ: .. +* ֵ: +HLHT_HEAD_SUCCESS (0x55) ͨͷȷ +HLHT_HEAD_ERROR (0xaa) ͨͷ +HLHT_HEAD_INIT (0x33) ͷǻͨʼͨ֡ +*************************************************************************/ +UINT8 HLHTCiCommonPacketHeadCheck(UINT16 LocalDevName, UINT16 RemoteDevName, UINT16 DevInterfaceType, UINT8 prtrlVer, HLHTGALInfoStruct* pMICommonPackage, UINT32* pErrorCode, UINT16 logId, UINT8 devType) +{ + UINT8 retVal = CI_ERROR; + UINT32 LocalEtcsId = 0u; /*ͷʶ*/ + UINT32 RemoteEtcsId = 0u; /*շʶ*/ + UINT32 emapVer = 0U;/*Ӧʹõĵӵͼ汾*/ + UINT8 emapCheckVer = 0U; /*ӵͼ汾У*/ + UINT8 chRet = 0U; + UINT8 localCiId = 0u; /*ID*/ + + localCiId = GetSystemParaLocalCiId(); + + /*ÿζ*/ + *pErrorCode = 0u; + + /*жϸϢǷںϷΧ,ֻҪдӦ*/ + if (pMICommonPackage->devInterInfoType != DevInterfaceType) + { + *pErrorCode |= GAL_COMPARE_INFO_TYPE_ERR; + } + else + { + ; + } + + /*ͷУ*/ + chRet = dquDevName2HlhtId(LocalDevName, logId, &LocalEtcsId); + if ((CI_ERROR == chRet) || (pMICommonPackage->sourceId != LocalEtcsId)) + { + *pErrorCode |= GAL_COMPARE_SEND_FLAG_ERR; + } + else + { + ; + } + + /*շУ*/ + chRet = dquDevName2HlhtId(RemoteDevName, logId, &RemoteEtcsId); + if ((CI_ERROR == chRet) || (pMICommonPackage->destId != RemoteEtcsId)) + { + *pErrorCode |= GAL_COMPARE_RECV_FLAG_ERR; + } + else + { + ; + } + + emapVer = GetCiTranCiDataCheckVer(localCiId, LocalDevName); /*ȡϵͳݰ汾*/ + + /*ӵͼ汾УϢ(4ֽCRCȽ)*/ + if (emapVer != pMICommonPackage->emapVerCrc) + { + *pErrorCode |= GAL_COMPARE_EMAP_VER_COMP_ERR; + } + else + { + ; + } + + /* кźϷԼ, (2^31-1u)*/ + if ((1u > pMICommonPackage->crntOwnMsgSN) || (((UINT32)0x7FFFFFFF) < pMICommonPackage->crntOwnMsgSN) + || (1u > pMICommonPackage->recvOppMsgSN) || (((UINT32)0x7FFFFFFF) < pMICommonPackage->recvOppMsgSN) + || (1u > pMICommonPackage->preOwnMsgSN) || (((UINT32)0x7FFFFFFF) < pMICommonPackage->preOwnMsgSN)) + { + *pErrorCode |= GAL_COMPARE_MSG_BDS_SN_ERR; + } + else + { + ; + } + + /* Э汾 */ + if (prtrlVer != pMICommonPackage->prtclVer) + { + *pErrorCode |= GAL_COMPARE_PROTOCOL_VER_ERR; + } + else + { + ; + } + + /* Ӧݳ */ + if (0u >= pMICommonPackage->totalDataLen) + { + *pErrorCode |= GAL_COMPARE_APP_LEN_ERR; + } + else + { + ; + } + /*ͨϢͨ*/ + if (0u == pMICommonPackage->comPeriod) + { + *pErrorCode |= GAL_COMPARE_COM_PERIOD; + } + else + { + ; + } + + /*ӿϢûз,ȷ;򷵻ش*/ + if (0u == *pErrorCode) + { + /*ӿȫȷ,ȷ*/ + retVal = HLHT_HEAD_SUCCESS; + } + else if (GAL_COMPARE_MSG_BDS_SN_ERR == *pErrorCode) + { + if ((0u < pMICommonPackage->crntOwnMsgSN) && (UINT32_MAX == pMICommonPackage->recvOppMsgSN) && (UINT32_MAX == pMICommonPackage->preOwnMsgSN)) + {/*˵Էûյ֡ǰ֡dzʼ֡*/ + retVal = HLHT_HEAD_INIT; + } + else + { + retVal = HLHT_HEAD_ERROR; + } + } + else + { + retVal = HLHT_HEAD_ERROR; + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTCommonDataPacketHead.h b/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTCommonDataPacketHead.h new file mode 100644 index 0000000..28e0433 --- /dev/null +++ b/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTCommonDataPacketHead.h @@ -0,0 +1,113 @@ +/******************************************************** +* +* HLHTCommonDataPacketHead.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-10-21 +* ߣ Ʒ +* ͨͨñͷУͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _HLHTCOMMONDATAPACKETHEAD_H_ +#define _HLHTCOMMONDATAPACKETHEAD_H_ + + +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" + +#define HLHT_HEAD_SUCCESS ((UINT8)0x55) /*ͨͷȷ*/ +#define HLHT_HEAD_ERROR ((UINT8)0xaa) /*ͨͷ*/ +#define HLHT_HEAD_INIT ((UINT8)0x33) /*ͷǻͨʼͨ֡*/ + +/*************************************ͨñͷϢУԭ**************************************/ +#define GAL_COMPARE_INFO_TYPE_ERR ((UINT32)0x00000001) /*GALͨϢнӿϢʹ*/ +#define GAL_COMPARE_SEND_FLAG_ERR ((UINT32)0x00000002) /*GALͨϢзͷʶϢ*/ +#define GAL_COMPARE_RECV_FLAG_ERR ((UINT32)0x00000004) /*GALͨϢнշ־Ϣ*/ +#define GAL_COMPARE_EMAP_VER_COMP_ERR ((UINT32)0x00000008) /*GALͨϢеӵͼ汾űȽʧ*/ +#define GAL_COMPARE_MSG_BDS_SN_ERR ((UINT32)0x00000010) /*GALͨϢбԷյһϢʱкŴ*/ +#define GAL_COMPARE_MSG_SN_ERR ((UINT32)0x00000020) /*GALͨϢжԷϢкżյһϢʱкŴ*/ +#define GAL_COMPARE_PROTOCOL_VER_ERR ((UINT32)0x00000040) /*GALͨϢЭ汾Ŵ*/ +#define GAL_COMPARE_APP_LEN_ERR ((UINT32)0x00000080) /*GALͨϢӦòݳЧ*/ +#define GAL_COMPARE_COM_PERIOD ((UINT32)0x00000100)/*GALͨϢͨڴ*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*ͨͨñͷ*/ +typedef struct S_HLHTGALInfoStruct +{ + UINT16 devInterInfoType; /*豸ӿϢ*/ + UINT16 totalDataLen; /*Ӧñܳ*/ + UINT16 comPeriod; /*ͨڣλms*/ + UINT8 prtclVer; /*Э汾*/ + UINT32 sourceId; /*ԴIDͷʶϢ*/ + UINT32 destId; /*ĿIDշʶϢ*/ + UINT32 emapVerCrc; /*ӵͼ汾УϢ32λCRC*/ + UINT32 crntOwnMsgSN; /*Ϣкţ¼ͱϢʱڼͷÿڽ1*/ + UINT32 recvOppMsgSN; /*ԷϢкţ¼յԷһϢеĶԷϢк*/ + UINT32 preOwnMsgSN; /*յһϢʱкţ¼յԷһϢʱڼ*/ +} HLHTGALInfoStruct; + +/************************************************************************************************************* +* յͨϢʱ,ϢʣЧ +* +const UINT16 maxMsgValidTime ĿԼĸϢЧ ; +const UINT32 CurrentOwnSN ĵǰں +const UINT32 SNPeriod ͨڣCIϵͳУΪӦõ +const HLHTGALInfoStruct *pRecvCommonPackage ͨϢͷ +const UINT32 srcRecvCiMsgSN,Էϴյı +const UINT32 srcCrntOwnMsgSN,Էʱ䵱ǰ +const UINT32 srcPreOwnMsgSN,Էϴյʱ䵱ʱ +const UINT32 srcPeriod,Էͨ +* . +* ֵRemainValidity ϢʣЧ +*************************************************************************************************************/ +INT32 HLHTCommonMsgRemainingValidity(const UINT32 MaxMsgValidTime, const UINT32 CurrentOwnSN, const UINT32 SNPeriod, const UINT32 srcRecvCiMsgSN, const UINT32 srcCrntOwnMsgSN, const UINT32 srcPreOwnMsgSN, const UINT32 srcPeriod); + +/************************************************************************* +* : յͨϢͷϢϷԼ +* : UINT16 LocalDevName ͷ豸 +* UINT16 RemoteDevName շ豸 +* UINT16 DevInterfaceType 豸豸ӿ +* UINT8 prtrlVer ӿЭ汾 +* HLHTGALInfoStruct *pMICommonPackage CI͸VOBCͨϢͷ +* UINT16 logId VOBC 1˻2˱ʶ +* UINT8 devType ͨ豸 +* : UINT32 *pErrorCode CIӿеĹϺ. +* : . +* ȫֱ: .. +* ֵ: +HLHT_HEAD_SUCCESS (0x55) ͨͷȷ +HLHT_HEAD_ERROR (0xaa) ͨͷ +HLHT_HEAD_INIT (0x33) ͷǻͨʼͨ֡ +*************************************************************************/ +UINT8 HLHTRecvCommonPacketHeadCheck(UINT16 LocalDevName, UINT16 RemoteDevName, UINT16 DevInterfaceType, UINT8 prtrlVer, HLHTGALInfoStruct *pMICommonPackage, UINT32 *pErrorCode,UINT16 logId,UINT8 devType); + +/************************************************************************* +* : յCIͨϢͷϢϷԼ +* : UINT16 LocalDevName ͷ豸 +* UINT16 RemoteDevName շ豸 +* UINT16 DevInterfaceType 豸豸ӿ +* UINT8 prtrlVer ӿЭ汾 +* HLHTGALInfoStruct *pMICommonPackage CI͸VOBCͨϢͷ +* UINT16 logId VOBC 1˻2˱ʶ +* UINT8 devType ͨ豸 +* : UINT32 *pErrorCode CIӿеĹϺ. +* : . +* ȫֱ: .. +* ֵ: +HLHT_HEAD_SUCCESS (0x55) ͨͷȷ +HLHT_HEAD_ERROR (0xaa) ͨͷ +HLHT_HEAD_INIT (0x33) ͷǻͨʼͨ֡ +*************************************************************************/ +UINT8 HLHTCiCommonPacketHeadCheck(UINT16 LocalDevName, UINT16 RemoteDevName, UINT16 DevInterfaceType, UINT8 prtrlVer, HLHTGALInfoStruct* pMICommonPackage, UINT32* pErrorCode, UINT16 logId, UINT8 devType); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTHeadContexManage.c b/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTHeadContexManage.c new file mode 100644 index 0000000..c34711f --- /dev/null +++ b/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTHeadContexManage.c @@ -0,0 +1,1185 @@ +/******************************************************** +* +* HLHTHeadContexManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-12-17 +* ߣ Ʒ +* ͨͷݹ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ +#include "HLHTHeadContexManage.h" +#include "CiSystemDefine.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "CommonMemory.h" + +HLHTHeadContextStru ciHLHTHeadCtxs[CI_SUM_MAX]={0};/*뱾CIͨŵCIͨͷ*/ +HLHTHeadContextStru vobcHLHTHeadCtxs[VOBC_SUM_MAX]={0};/*뱾CIͨŵVOBCͨͷ*/ +HLHTHeadContextStru vobcBackupHLHTHeadCtxs[VOBC_BACKUP_SUM_MAX] = { 0 };/*뱾CIͨŵĺģʽVOBCͨͷ*/ +HLHTHeadContextStru zcHLHTHeadCtxs[ZC_SUM_MAX]={0};/*뱾CIͨŵZCͨͷ*/ +HLHTHeadContextStru ocHLHTHeadCtxs[OC_SUM_MAX]={0};/*뱾CIͨŵOCͨͷ*/ +HLHTHeadContextStru axleHLHTHeadCtxs[AXLE_SUM_MAX] = { 0 };/*뱾CIͨŵļϵͳͨͷ*/ +HLHTHeadContextStru tmcHLHTHeadCtxs[TMC_SUM_MAX] = { 0 };/*뱾TIOCͨŵTMCͨͷ*/ +HLHTHeadContextStru IteHLHTHeadCtxs[ITE_SUM_MAX][VOBC_INC_ITE_SUM_MAX] = { 0U };/*뱾TIOCͨŵITEͨͷ*/ + +/* +* :غij豸͵ںĻͨͷ +* ˵: + const UINT8 devType:豸 + UINT16 *devMaxSum:ڲ,ij豸͵ + HLHTHeadContextStru **hlhtHeadCtxPtr:ڲ,ij豸͵Ļͨͷָ +* ֵ: + CI_ERROR:ȡʧ +* CI_SUCCESS:ȡɹ +*/ +static UINT8 GetHLHTHeadCtxTmepVars(const UINT8 devType, UINT16 *devMaxSum, HLHTHeadContextStru **hlhtHeadCtxPtr); +/* +* :ͬϵͳĻͨͨͷʱЧԴ +* ˵: + const UINT32 timeoutSnCount,Ч + const UINT32 timeoutSpan,Чʱ + HLHTHeadContextStru headCtxs[],ͨͷ + const UINT8 headCount,ͨͷ +* ֵ: + +*/ +static void ProcHlhtHeadCtxTimeOutDiffSys(const UINT32 timeoutSnCount, const UINT32 timeoutSpan, HLHTHeadContextStru headCtxs[], const UINT16 headCount); + +/* +* :ȡij豸һθCIʱ䵱ǰ +* ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID +* ֵ: + ij豸һθCIʱ䵱ǰ,0uΪЧֵ +*/ +UINT32 GetHLHTHeadCtxSrcCrntSN(const UINT8 devType, const UINT8 devId) +{ + UINT32 retVal = 0u; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum)) + { + retVal = tempHeadCtxPtr[devId].sourceCrntOwnMsgSN; + } + else + { + retVal = 0u; + } + } + else + { + /*޲*/ + } + return retVal; +} +/* +* :ȡij豸һθCIʱдϴյCI䵱ʱ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +* ֵ: +ij豸һθCIʱдϴյCI䵱ʱ,0uΪЧֵ +*/ +UINT32 GetHLHTHeadCtxSrcOwnSN(const UINT8 devType, const UINT8 devId) +{ + UINT32 retVal = 0u; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum)) + { + if (tempHeadCtxPtr[devId].sourceId == devId) + { + retVal = tempHeadCtxPtr[devId].sourcePreOwnMsgSN; + } + else + { + retVal = 0u; + } + } + else + { + retVal = 0u; + } + } + else + { + /*޲*/ + } + + return retVal; +} +/* +* :ȡCIյij豸ʱCIʱ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +* ֵ: +CIյij豸ʱʱ,0uΪЧֵ +*/ +UINT32 GetHLHTHeadCtxCiRcvSN(const UINT8 devType, const UINT8 devId) +{ + UINT32 retVal = 0u; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + retVal = tempHeadCtxPtr[devId].ciPreRecvOwnSn; + } + else + { + retVal = 0u; + } + } + else + { + /*޲*/ + } + return retVal; +} +/* +* :ijCIͨŵ豸ͨ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +const UINT16 period:ͨ +* ֵ: + +*/ +void SetHLHTHeadCtxComPeriod(const UINT8 devType, const UINT8 devId, const UINT16 period) +{ + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + tempHeadCtxPtr[devId].sourceId = devId; + tempHeadCtxPtr[devId].sourceComPeriod = period; + + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } +} +/* +* :CIյij豸ʱͨͷĶԷǰں +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +const UINT16 srcCrntSN:Էǰں +* ֵ: + +*/ +void SetHLHTHeadCtxSrcCrntSN(const UINT8 devType, const UINT8 devId, const UINT32 srcCrntSN) +{ + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + if (tempHeadCtxPtr[devId].sourceId == devId) + { + tempHeadCtxPtr[devId].sourceId = devId; + tempHeadCtxPtr[devId].sourceCrntOwnMsgSN = srcCrntSN; + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } +} +/* +* :ij豸һյCIʱCIǰ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +const UINT16 srcOppSN:ԷһյCIʱCIǰ +* ֵ: +CI_SUCCESS:ɹ +CI_ERROR:ʧ +*/ +void SetHLHTHeadCtxSrcOppSN(const UINT8 devType, const UINT8 devId, const UINT32 srcOppSN) +{ + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + tempHeadCtxPtr[devId].sourceId = devId; + tempHeadCtxPtr[devId].sourceRecvOppMsgSN = srcOppSN; + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } +} +/* +* :ij豸һյCIʱĵǰ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +const UINT16 srcOwnSN:ij豸һյCIʱĵǰ +* ֵ: +CI_SUCCESS:ɹ +CI_ERROR:ʧ +*/ +void SetHLHTHeadCtxSrcOwnSN(const UINT8 devType, const UINT8 devId, const UINT32 srcOwnSN) +{ + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum)) + { + tempHeadCtxPtr[devId].sourceId = devId; + tempHeadCtxPtr[devId].sourcePreOwnMsgSN = srcOwnSN; + + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } +} +/* +* :CIյʱCI +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +const UINT16 ciRcvSn:CIյʱCI +* ֵ: +CI_SUCCESS:ɹ +CI_ERROR:ʧ +*/ +void SetHLHTHeadCtxCiRcvSN(const UINT8 devType, const UINT8 devId, const UINT32 ciRcvSn) +{ + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + tempHeadCtxPtr[devId].sourceId = devId; + tempHeadCtxPtr[devId].ciPreRecvOwnSn = ciRcvSn; + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } +} + +/* +* :ɾij豸Ļͨͷ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +* ֵ: + +*/ +void ClearHlhtHeadCtx(const UINT8 devType, const UINT8 devId) +{ + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + (void)CommonMemSet(&tempHeadCtxPtr[devId], (UINT32)sizeof(HLHTHeadContextStru), 0u , (UINT32)sizeof(HLHTHeadContextStru)); + + tempHeadCtxPtr[devId].sourceCrntOwnMsgSN = UINT32_MAX; + tempHeadCtxPtr[devId].ciPreRecvOwnSn = UINT32_MAX; + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } + +} + + +/* +* :ʼ +* ˵: +*const UINT8 devType:豸 +*/ +void InitHlhtHeadCtx(const UINT8 devType) +{ + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + UINT16 i = 0u; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + for (i = 0u; i < maxDevSum; i++) + { + (void)CommonMemSet(&tempHeadCtxPtr[i], (UINT32)sizeof(HLHTHeadContextStru), 0u, (UINT32)sizeof(HLHTHeadContextStru)); + /* ʼGALͷΪ״̬ */ + tempHeadCtxPtr[i].sourceCrntOwnMsgSN = UINT32_MAX; + tempHeadCtxPtr[i].ciPreRecvOwnSn = UINT32_MAX; + } + } + else + { + /*޲*/ + } +} + +/* +* ͨͨñͷʱЧ +* ˵ + +* ֵ + +*/ +void ProcHlhtHeadCtxTimeOut(void) +{ + UINT32 timeoutSnCount = 0U; + UINT32 timeoutSpan = 0U; + + /*VOBCͨñͷʱЧ*/ + timeoutSnCount = GetCiAndVobcTransBadEnsureCnt(); + timeoutSpan = GetCiAndVobcTransBadEnsureTime(); + ProcHlhtHeadCtxTimeOutDiffSys(timeoutSnCount, timeoutSpan, vobcHLHTHeadCtxs, VOBC_SUM_MAX); + + /*ʹVOBCͨжʱ䴦ITEͨñͷʱЧ*/ + ProcIteHlhtHeadCtxTimeOut(timeoutSnCount, timeoutSpan); + + /*ģʽVOBCͨñͷʱЧ*/ + timeoutSnCount = GetVobcCiBackUpCommErrorCount(); + timeoutSpan = GetVobcCiBackUpCommErrorTime(); + ProcHlhtHeadCtxTimeOutDiffSys(timeoutSnCount, timeoutSpan, vobcBackupHLHTHeadCtxs, VOBC_BACKUP_SUM_MAX); + + /*CIͨñͷʱЧ*/ + timeoutSnCount = GetCiAndCiTransBadEnsureCnt(); + timeoutSpan = GetCiAndCiTransmitBadEnsureTime(); + ProcHlhtHeadCtxTimeOutDiffSys(timeoutSnCount, timeoutSpan, ciHLHTHeadCtxs, CI_SUM_MAX); + + /*CIͨŵZCͨñͷʱЧ*/ + timeoutSnCount = GetCiAndZcTransBadEnsureCnt(); + timeoutSpan = GetCiAndZcTransmitBadEnsureTime(); + ProcHlhtHeadCtxTimeOutDiffSys(timeoutSnCount, timeoutSpan, zcHLHTHeadCtxs, ZC_SUM_MAX); + + /*TIOCͨŵTMCͨñͷʱЧ*/ + timeoutSnCount = GetTiocAndTmcTransBadEnsureCnt(); + timeoutSpan = GetTiocAndTmcTransBadEnsureTime(); + ProcHlhtHeadCtxTimeOutDiffSys(timeoutSnCount, timeoutSpan, tmcHLHTHeadCtxs, TMC_SUM_MAX); + + /*OCͨűͷʱЧ*/ + timeoutSnCount = GetCiAndOcTransmitBadEnsureCnt(); + timeoutSpan = GetCiAndOcTransmitBadEnsureTime(); + ProcHlhtHeadCtxTimeOutDiffSys(timeoutSnCount, timeoutSpan, ocHLHTHeadCtxs, OC_SUM_MAX); + + /*AXLEͨűͷʱЧ*/ + timeoutSnCount = GetCiAndAxleTransBadEnsureCnt(); + timeoutSpan = GetCiAndAxleTransBadEnsureTime(); + ProcHlhtHeadCtxTimeOutDiffSys(timeoutSnCount, timeoutSpan, axleHLHTHeadCtxs, AXLE_SUM_MAX); +} +/* +* 豸ͣþ߱ʼͨŻͨͷ豸ID +* ˵ +const UINT8 devType, 豸 +UINT8* devIdBuf, 洢豸ŵ +const UINT8 devIdBufMaxLen, devIdBufֹڷԽ +UINT8* devSum,豸ŵ +UINT16* devLogIdBuf 洢豸߼ID +* ֵ +CI_SUCCESS:óɹ +CI_ERROR:ʧ +*/ +UINT8 GetHlhtInitHeadDevsByDevType(const UINT8 devType, UINT8* devIdBuf, const UINT8 devIdBufMaxLen, UINT8* devSum, UINT16* devLogIdBuf) +{ + UINT8 retVal = CI_ERROR; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT16 i = 0U; + UINT8 tempDevSum = 0u; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if ((devIdBuf != NULL) && (CI_SUCCESS == HLHTHeadVal)) + { + if (devIdBufMaxLen >= maxDevSum) + { + for (i = 0u;i < maxDevSum;i++) + { + if ((UINT32_MAX == tempHeadCtxPtr[i].sourceRecvOppMsgSN) && (UINT32_MAX == tempHeadCtxPtr[i].sourcePreOwnMsgSN)) + {/*˵ͨͷǶԷûյciκʱci͵֡ıͷʼͨűͷ*/ + devIdBuf[tempDevSum] = tempHeadCtxPtr[i].sourceId; + devLogIdBuf[tempDevSum] = tempHeadCtxPtr[i].logId; + tempDevSum++; + } + else + { + /*޲*/ + } + } + + retVal = CI_SUCCESS; + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } + + /*Ϊڲֵ*/ + if (CI_SUCCESS == retVal) + { + *devSum = tempDevSum; + } + else + { + *devSum = 0u; + } + + return retVal; +} + +/* +* :غij豸͵ںĻͨͷ +* ˵: +const UINT8 devType:豸 +UINT16 *devMaxSum:ڲ,ij豸͵ +HLHTHeadContextStru **hlhtHeadCtxPtr:ڲ,ij豸͵Ļͨͷָ +* ֵ: +CI_ERROR:ȡʧ +* CI_SUCCESS:ȡɹ +*/ +static UINT8 GetHLHTHeadCtxTmepVars(const UINT8 devType, UINT16 *devMaxSum, HLHTHeadContextStru **hlhtHeadCtxPtr) +{ + UINT8 retVal = CI_ERROR; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + + if ((CI_SYSTEM_TYPE_CI == devType)) + { + maxDevSum = CI_SUM_MAX; + tempHeadCtxPtr = ciHLHTHeadCtxs; + + retVal = CI_SUCCESS; + } + else if (CI_SYSTEM_TYPE_VOBC == devType) + { + maxDevSum = VOBC_SUM_MAX; + tempHeadCtxPtr = vobcHLHTHeadCtxs; + + retVal = CI_SUCCESS; + } + else if (CI_SYSTEM_TYPE_VOBC_BACKUP == devType) + { + maxDevSum = VOBC_BACKUP_SUM_MAX; + tempHeadCtxPtr = vobcBackupHLHTHeadCtxs; + + retVal = CI_SUCCESS; + } + else if (CI_SYSTEM_TYPE_ZC == devType) + { + maxDevSum = ZC_SUM_MAX; + tempHeadCtxPtr = zcHLHTHeadCtxs; + + retVal = CI_SUCCESS; + } + else if (CI_SYSTEM_TYPE_OC == devType) + { + maxDevSum = OC_SUM_MAX; + tempHeadCtxPtr = ocHLHTHeadCtxs; + + retVal = CI_SUCCESS; + } + else if (CI_SYSTEM_TYPE_AXIS == devType) + { + maxDevSum = AXLE_SUM_MAX; + tempHeadCtxPtr = axleHLHTHeadCtxs; + + retVal = CI_SUCCESS; + } + else if (CI_SYSTEM_TYPE_TMC == devType) + { + maxDevSum = TMC_SUM_MAX; + tempHeadCtxPtr = tmcHLHTHeadCtxs; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + *devMaxSum = maxDevSum; + *hlhtHeadCtxPtr = tempHeadCtxPtr; + + return retVal; +} +/* +* :ͬϵͳĻͨͨͷʱЧԴ +* ˵: +const UINT32 timeoutSnCount,Ч +const UINT32 timeoutSpan,Чʱ +HLHTHeadContextStru headCtxs[],ͨͷ +const UINT8 headCount,ͨͷ +* ֵ: + +*/ +static void ProcHlhtHeadCtxTimeOutDiffSys(const UINT32 timeoutSnCount, const UINT32 timeoutSpan, HLHTHeadContextStru headCtxs[], const UINT16 headCount) +{ + UINT32 curSn = Get2oo2CurCycleNum(); + UINT16 i = 0U; + HLHTHeadContextStru tempHeadCtx = { 0u }; + UINT8 headValid = 0u; + INT32 remainValidiy;/*ʣʱ*/ + + if (NULL != headCtxs) + { + for (i = 0u;i < headCount;i++) + { + headValid = 1u; /*ΪЧ*/ + tempHeadCtx = headCtxs[i]; + + if (0u != tempHeadCtx.sourceId) + {/*˵ǸЧıͷ*/ + if ((UINT32_MAX == tempHeadCtx.sourceRecvOppMsgSN) && (UINT32_MAX == tempHeadCtx.sourcePreOwnMsgSN)) + {/*˵Էûյciκʱci͵֡*/ + if ((curSn - tempHeadCtx.ciPreRecvOwnSn) > timeoutSnCount) + {/*ͨųʱʱ䣬ҲҪ*/ + headValid = 0u; + } + else + { + ; /**/ + } + } + else + { + /*㱨ͷʱЧ*/ + remainValidiy = HLHTCommonMsgRemainingValidity(timeoutSpan, curSn, GetSystemParaAppCycleTime(), tempHeadCtx.sourceRecvOppMsgSN, tempHeadCtx.sourceCrntOwnMsgSN, tempHeadCtx.sourcePreOwnMsgSN, tempHeadCtx.sourceComPeriod); + + if (remainValidiy <= 0) + { + headValid = 0u; + } + else + { + ; /**/ + } + } + + if (0u == headValid) + { + if (headCtxs == axleHLHTHeadCtxs) /*ϵͳжʱ,GALԷ,յԷʱ,0xFFFFFFFF*/ + { + headCtxs[i].logId = 0u; + headCtxs[i].sourceRecvOppMsgSN = 0u; + headCtxs[i].sourcePreOwnMsgSN = 0u; + headCtxs[i].sourceComPeriod = 0u; + headCtxs[i].sourceCrntOwnMsgSN = 0xFFFFFFFFu; + headCtxs[i].ciPreRecvOwnSn = 0xFFFFFFFFu; + } + else + { + (void)CommonMemSet(&(headCtxs[i]), (UINT32)sizeof(HLHTHeadContextStru), 0u, (UINT32)sizeof(HLHTHeadContextStru)); + headCtxs[i].sourceCrntOwnMsgSN = 0xFFFFFFFFu; + headCtxs[i].ciPreRecvOwnSn = 0xFFFFFFFFu; + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + } + else + { + ; /**/ + } +} + +/* +* :ȡijCIͨŵ豸ĻͨͷϢǷڲЧ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +* ֵ: +CI_ERROR: +* CI_SUCCESS: +*/ +UINT8 GetHLHTHeadCtxValid(const UINT8 devType, const UINT8 devId) +{ + UINT8 retVal = CI_ERROR; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum)) + { + if ((tempHeadCtxPtr[devId].sourceId == devId) && + (UINT32_MAX != tempHeadCtxPtr[devId].sourceRecvOppMsgSN) && + (UINT32_MAX !=tempHeadCtxPtr[devId].sourcePreOwnMsgSN)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* :жϺģʽʼ֡ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +* ֵ: +CI_ERROR: +* CI_SUCCESS: +*/ +UINT8 BackupHeadCheckValid(const UINT8 devType, const UINT8 devId) +{ + UINT8 retVal = CI_ERROR; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + UINT32 curSn = Get2oo2CurCycleNum(); + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if ((CI_SUCCESS == HLHTHeadVal) && (CI_SYSTEM_TYPE_VOBC_BACKUP ==devType)) + { + if ((0u < devId) && (devId < maxDevSum)) + { + if ((tempHeadCtxPtr[devId].sourceId == devId) && + (UINT32_MAX == tempHeadCtxPtr[devId].sourceRecvOppMsgSN) && + (UINT32_MAX == tempHeadCtxPtr[devId].sourcePreOwnMsgSN)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + if (CI_ERROR == retVal) + { + debug_infor_printf((const)"\n CurCycle:%d devID:%d devId:%d sourceRecvOppMsgSN:%d sourcePreOwnMsgSN:%d\n", curSn, devType, devId, tempHeadCtxPtr[devId].sourceRecvOppMsgSN, tempHeadCtxPtr[devId].sourcePreOwnMsgSN); + } + else + { + ; /**/ + } + return retVal; +} + +/* +* :ȡijCIͨŵ豸ĻͨͷϢǷ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +* ֵ: +CI_ERROR: +* CI_SUCCESS: +*/ +UINT8 GetHLHTHeadCtxExistance(const UINT8 devType,const UINT8 devId) +{ + UINT8 retVal = CI_ERROR; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + if ((tempHeadCtxPtr[devId].sourceId == devId)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* :CIյʱԷLogId +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +const UINT16 ciRcvLogId:CIյʱԷLogId +* ֵ: +CI_SUCCESS:ɹ +CI_ERROR:ʧ +*/ +void SetHLHTHeadCtxCiRcvLogId(const UINT8 devType, const UINT8 devId, const UINT16 ciRcvLogId) +{ + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + tempHeadCtxPtr[devId].sourceId = devId; + tempHeadCtxPtr[devId].logId = ciRcvLogId; + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } +} + +/* +* :ȡij豸ϴյCIʱCI +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +* ֵ: +ij豸ϴյCIʱCI,0uΪЧֵ +*/ +UINT32 GetHLHTHeadCtxSrcOppSN(const UINT8 devType, const UINT8 devId) +{ + UINT32 retVal = 0u; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + if (tempHeadCtxPtr[devId].sourceId == devId) + { + retVal = tempHeadCtxPtr[devId].sourceRecvOppMsgSN; + } + else + { + retVal = 0u; + } + } + else + { + retVal = 0u; + } + } + else + { + /*޲*/ + } + return retVal; +} + +/* +* :ȡij豸ͨ +* ˵: +const UINT8 devType:豸 +const UINT8 devId:豸ID +* ֵ: +ijͨ +*/ +UINT32 GetHLHTHeadCtxComPeriod(const UINT8 devType, const UINT8 devId) +{ + UINT32 retVal = 0u; + UINT16 maxDevSum = 0u; + HLHTHeadContextStru *tempHeadCtxPtr = NULL; + UINT8 HLHTHeadVal = CI_ERROR; + + HLHTHeadVal = GetHLHTHeadCtxTmepVars(devType, &maxDevSum, &tempHeadCtxPtr); + if (CI_SUCCESS == HLHTHeadVal) + { + if ((0u < devId) && (devId < maxDevSum) ) + { + if (tempHeadCtxPtr[devId].sourceId == devId) + { + retVal = tempHeadCtxPtr[devId].sourceComPeriod; + } + else + { + retVal = 0u; + } + } + else + { + retVal = 0u; + } + } + else + { + /*޲*/ + } + return retVal; +} + +/* +* ָITEĻͨͷ +* ˵const UINT8 iteId ITE ID +* const UINT16 iteLogId ITE߼ID +* const HLHTGALInfoStruct* strHlhtGalHead õITEͨͷ +* ֵ +* Created By LQ 2024.06.05 +*/ +void SetIteHLHTHeadCtx(const UINT8 iteId, const UINT16 iteLogId, const HLHTGALInfoStruct* pstrHlhtGalHead) +{ + UINT16 wIndex = 0U; + UINT32 dwCurCycNum = 0U; /*ǰ*/ + + if ((0U < iteId) && (ITE_SUM_MAX > iteId) && (0U < iteLogId) && (VOBC_INC_ITE_SUM_MAX >= iteLogId) && (NULL != pstrHlhtGalHead)) + { + dwCurCycNum = Get2oo2CurCycleNum(); + wIndex = iteLogId - 1U; + IteHLHTHeadCtxs[iteId][wIndex].sourceId = iteId; + IteHLHTHeadCtxs[iteId][wIndex].logId = iteLogId; + IteHLHTHeadCtxs[iteId][wIndex].sourceComPeriod = pstrHlhtGalHead->comPeriod; + IteHLHTHeadCtxs[iteId][wIndex].sourceCrntOwnMsgSN = pstrHlhtGalHead->crntOwnMsgSN; + IteHLHTHeadCtxs[iteId][wIndex].sourceRecvOppMsgSN = pstrHlhtGalHead->recvOppMsgSN; + IteHLHTHeadCtxs[iteId][wIndex].sourcePreOwnMsgSN = pstrHlhtGalHead->preOwnMsgSN; + IteHLHTHeadCtxs[iteId][wIndex].ciPreRecvOwnSn = dwCurCycNum; + } + else + { + /**/ + } +} + +/* +* ȡָITEĻͨͷ +* ˵const UINT8 iteId ITE ID +* const UINT16 iteLogId ITE߼ID +* ֵNULL ȡʧ +* NULL ȡݳɹ +* Created By LQ 2024.06.05 +*/ +HLHTHeadContextStru* GetIteHLHTHeadCtx(const UINT8 iteId, const UINT16 iteLogId) +{ + HLHTHeadContextStru* pstrRetVal = NULL; + UINT16 wIndex = 0U; + + if ((0U < iteId) && (ITE_SUM_MAX > iteId) && (0U < iteLogId) && (VOBC_INC_ITE_SUM_MAX >= iteLogId)) + { + wIndex = iteLogId - 1U; + pstrRetVal = &IteHLHTHeadCtxs[iteId][wIndex]; + } + else + { + /**/ + } + + return pstrRetVal; +} + +/* +* ɾָITEĻͨͷ +* ˵const UINT8 devId ITE ID +* const UINT16 logId ITE߼ID +* ֵ +* Created By LQ 2024.06.05 +*/ +void ClearIteHlhtHeadCtx(const UINT8 devId, const UINT16 logId) +{ + UINT16 wIndex = 0U; + + if ((0U < devId) && (ITE_SUM_MAX > devId) && (0U < logId) && (VOBC_INC_ITE_SUM_MAX >= logId)) + { + wIndex = logId - 1U; + (void)CommonMemSet(&IteHLHTHeadCtxs[devId][wIndex], (UINT32)sizeof(HLHTHeadContextStru), 0U, (UINT32)sizeof(HLHTHeadContextStru)); + + IteHLHTHeadCtxs[devId][wIndex].sourceCrntOwnMsgSN = UINT32_MAX; + IteHLHTHeadCtxs[devId][wIndex].ciPreRecvOwnSn = UINT32_MAX; + } + else + { + /**/ + } +} + +/* +* УITEͨͷϢǷЧ +* ˵const UINT8 cIteId ITE ID +* const UINT16 wIteLogId ITE߼ID +* ֵCI_ERROR 0 Ч +* CI_SUCCESS 1 Ч +* Created By LQ 2024.06.06 +*/ +UINT8 CheckIteHLHTHeadCtxValid(const UINT8 cIteId, const UINT16 wIteLogId) +{ + UINT8 retVal = CI_ERROR; + UINT16 wIndex = 0U; + + if ((0U < cIteId) && (ITE_SUM_MAX > cIteId) && (0U < wIteLogId) && (VOBC_INC_ITE_SUM_MAX >= wIteLogId)) + { + wIndex = wIteLogId - 1U; + if ((IteHLHTHeadCtxs[cIteId][wIndex].sourceId == cIteId) && + (UINT32_MAX != IteHLHTHeadCtxs[cIteId][wIndex].sourceRecvOppMsgSN) && + (UINT32_MAX != IteHLHTHeadCtxs[cIteId][wIndex].sourcePreOwnMsgSN)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; /*ȡITEͨͷϢ0ʧ*/ + } + + return retVal; +} + +/* +* ȡ߱ʼͨŻͨͷITEID +* ˵UINT8* cIteNum ʼͨŵITEΣ +* UINT8 pIteIdBuf[ITE_TO_CI_SUM_MAX] ʼͨŵITE IDΣ +* UINT16 pIteLogIdBuf[ITE_TO_CI_SUM_MAX] ʼͨŵITE߼IDΣ +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 óɹ +* Created By LQ 2024.06.08 +*/ +UINT8 GetIteHlhtInitHeadDevs(UINT8* cIteNum, UINT8 pIteIdBuf[ITE_TO_CI_SUM_MAX], UINT16 pIteLogIdBuf[ITE_TO_CI_SUM_MAX]) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 cDevSum = 0U; + + if ((NULL != cIteNum) && (NULL != pIteIdBuf) && (NULL != pIteLogIdBuf)) + { + for (ii = 0U; ii < ITE_SUM_MAX; ii++) + { + for (jj = 0U; jj < VOBC_INC_ITE_SUM_MAX; jj++) + { + if ((UINT32_MAX == IteHLHTHeadCtxs[ii][jj].sourceRecvOppMsgSN) && (UINT32_MAX == IteHLHTHeadCtxs[ii][jj].sourcePreOwnMsgSN)) + { + /*ӳʼͨŵITEͨͷ*/ + pIteIdBuf[cDevSum] = IteHLHTHeadCtxs[ii][jj].sourceId; + pIteLogIdBuf[cDevSum] = IteHLHTHeadCtxs[ii][jj].logId; + cDevSum++; + } + else + { + /*޲*/ + } + } + } + + *cIteNum = cDevSum; /*ʼͨŵITE*/ + + cRetVal = CI_SUCCESS; + } + else + { + /*ηǷ*/ + } + + return cRetVal; +} + +/* +* ITEͨͷʱЧԴ +* ˵const UINT32 dwTimeoutSnCount Ч +* const UINT32 dwTimeoutSpan Чʱ +* ֵ +* Created By LQ 2024.06.11 +*/ +void ProcIteHlhtHeadCtxTimeOut(const UINT32 dwTimeoutSnCount, const UINT32 dwTimeoutSpan) +{ + UINT32 dwCurCycNum = 0U; + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT8 cHeadValidFlag = CI_ERROR; /*ͷЧ־*/ + INT32 dwRemainValidiy = 0; /*ʣʱ*/ + UINT32 dwAppCycle = 0U; /*Ӧ*/ + + dwCurCycNum = Get2oo2CurCycleNum(); + dwAppCycle = GetSystemParaAppCycleTime(); + for (ii = 0U; ii < ITE_SUM_MAX; ii++) + { + for (jj = 0U; jj < VOBC_INC_ITE_SUM_MAX; jj++) + { + cHeadValidFlag = CI_SUCCESS; /*ÿѭһΣʼΪЧ*/ + + if (0U != IteHLHTHeadCtxs[ii][jj].sourceId) + { + /*ЧͷжʱЧ*/ + if ((UINT32_MAX == IteHLHTHeadCtxs[ii][jj].sourceRecvOppMsgSN) && (UINT32_MAX == IteHLHTHeadCtxs[ii][jj].sourcePreOwnMsgSN)) + { + /*˵Էûյciκʱci͵֡*/ + if ((dwCurCycNum - IteHLHTHeadCtxs[ii][jj].ciPreRecvOwnSn) > dwTimeoutSnCount) + { + cHeadValidFlag = CI_ERROR; /*ͨųʱʱ䣬Ҫͷ*/ + } + else + { + /*δʱͷ*/ + } + } + else + { + /*㱨ͷʱЧ*/ + dwRemainValidiy = HLHTCommonMsgRemainingValidity(dwTimeoutSpan, dwCurCycNum, dwAppCycle, IteHLHTHeadCtxs[ii][jj].sourceRecvOppMsgSN, IteHLHTHeadCtxs[ii][jj].sourceCrntOwnMsgSN, IteHLHTHeadCtxs[ii][jj].sourcePreOwnMsgSN, IteHLHTHeadCtxs[ii][jj].sourceComPeriod); + + if (dwRemainValidiy <= 0) + { + cHeadValidFlag = CI_ERROR; /*ͨųʱʱ䣬Ҫͷ*/ + } + else + { + /*δʱͷ*/ + } + } + + if (CI_SUCCESS == cHeadValidFlag) + { + /*δʱͷ*/ + } + else + { + /*ʱͷ*/ + (void)CommonMemSet(&(IteHLHTHeadCtxs[ii][jj]), (UINT32)sizeof(HLHTHeadContextStru), 0U, (UINT32)sizeof(HLHTHeadContextStru)); + IteHLHTHeadCtxs[ii][jj].sourceCrntOwnMsgSN = UINT32_MAX; + IteHLHTHeadCtxs[ii][jj].ciPreRecvOwnSn = UINT32_MAX; + } + } + else + { + /*Чͷ*/ + } + } + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTHeadContexManage.h b/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTHeadContexManage.h new file mode 100644 index 0000000..2cc1fa0 --- /dev/null +++ b/TSCP/src/APP/ciapp/HLHTMsgHead/HLHTHeadContexManage.h @@ -0,0 +1,293 @@ +/******************************************************** +* +* HLHTHeadContexManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-12-17 +* ߣ Ʒ +* ͨͷݹ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _HLHT_HEAD_CONTEX_MANAGE_H_ +#define _HLHT_HEAD_CONTEX_MANAGE_H_ + + +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "HLHTCommonDataPacketHead.h" +#include "ParsePackITEData.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /*ͨͷݽṹ*/ + typedef struct S_HLHTHeadContextStru + { + UINT16 sourceComPeriod; /*CIݵһͨڣλms*/ + UINT8 sourceId; /*CIݵһID*/ + UINT16 logId; /*CIݵһ߼IDĿǰͨ4IP VOBCʹ*/ + UINT32 sourceCrntOwnMsgSN; /*CIݵһͱʱǰSN*/ + UINT32 sourceRecvOppMsgSN; /*CIݵһϴյCIʱCISN*/ + UINT32 sourcePreOwnMsgSN; /*CIݵһϴյCIʱSN*/ + + UINT32 ciPreRecvOwnSn;/*CIյʱSN*/ + } HLHTHeadContextStru; + + /*******************************ȫֱ*******************************/ + extern HLHTHeadContextStru ciHLHTHeadCtxs[CI_SUM_MAX];/*뱾CIͨŵCIͨͷ*/ + extern HLHTHeadContextStru vobcHLHTHeadCtxs[VOBC_SUM_MAX];/*뱾CIͨŵVOBCͨͷ*/ + extern HLHTHeadContextStru vobcBackupHLHTHeadCtxs[VOBC_BACKUP_SUM_MAX];/*뱾CIͨŵĺģʽVOBCͨͷ*/ + extern HLHTHeadContextStru zcHLHTHeadCtxs[ZC_SUM_MAX];/*뱾CIͨŵZCͨͷ*/ + extern HLHTHeadContextStru ocHLHTHeadCtxs[OC_SUM_MAX];/*뱾CIͨŵOCͨͷ*/ + extern HLHTHeadContextStru axleHLHTHeadCtxs[AXLE_SUM_MAX];/*뱾CIͨŵļϵͳͨͷ*/ + extern HLHTHeadContextStru tmcHLHTHeadCtxs[TMC_SUM_MAX];/*뱾TIOCͨŵTMCͨͷ*/ + extern HLHTHeadContextStru IteHLHTHeadCtxs[ITE_SUM_MAX][VOBC_INC_ITE_SUM_MAX];/*뱾TIOCͨŵITEͨͷ*/ + + /* + * :ȡij豸һθCIʱ䵱ǰ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + ij豸һθCIʱ䵱ǰ,0ΪЧֵ + */ + UINT32 GetHLHTHeadCtxSrcCrntSN(const UINT8 devType, const UINT8 devId); + /* + * :ȡij豸һθCIʱдϴյCI䵱ʱ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + ij豸һθCIʱдϴյCI䵱ʱ,0ΪЧֵ + */ + UINT32 GetHLHTHeadCtxSrcOwnSN(const UINT8 devType, const UINT8 devId); + /* + * :ȡCIյij豸ʱCIʱ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + CIյij豸ʱʱ,0ΪЧֵ + */ + UINT32 GetHLHTHeadCtxCiRcvSN(const UINT8 devType, const UINT8 devId); + /* + * :ijCIͨŵ豸ͨ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + const UINT16 period:ͨ + * ֵ: + + */ + void SetHLHTHeadCtxComPeriod(const UINT8 devType, const UINT8 devId, const UINT16 period); + /* + * :CIյij豸ʱͨͷĶԷǰں + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + const UINT16 srcCrntSN:Էǰں + * ֵ: + + */ + void SetHLHTHeadCtxSrcCrntSN(const UINT8 devType, const UINT8 devId, const UINT32 srcCrntSN); + /* + * :ij豸һյCIʱCIǰ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + const UINT16 srcOppSN:ԷһյCIʱCIǰ + * ֵ: + + */ + void SetHLHTHeadCtxSrcOppSN(const UINT8 devType, const UINT8 devId, const UINT32 srcOppSN); + /* + * :ij豸һյCIʱĵǰ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + const UINT16 srcOwnSN:ij豸һյCIʱĵǰ + * ֵ: + + */ + void SetHLHTHeadCtxSrcOwnSN(const UINT8 devType, const UINT8 devId, const UINT32 srcOwnSN); + /* + * :CIյʱCI + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + const UINT16 ciRcvSn:CIյʱCI + * ֵ: + + */ + void SetHLHTHeadCtxCiRcvSN(const UINT8 devType, const UINT8 devId, const UINT32 ciRcvSn); + /* + * :ɾij豸Ļͨͷ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + + */ + void ClearHlhtHeadCtx(const UINT8 devType, const UINT8 devId); + + /* + * :ʼ + * ˵: + *const UINT8 devType:豸 + */ + void InitHlhtHeadCtx(const UINT8 devType); + /* + * ͨͨñͷʱЧ + * ˵ + + * ֵ + + */ + void ProcHlhtHeadCtxTimeOut(void); + /* + * 豸ͣþ߱ʼͨŻͨͷ豸ID + * ˵ + const UINT8 devType, 豸 + UINT8* devIdBuf, 洢豸ŵ + const UINT8 devIdBufMaxLen, devIdBufֹڷԽ + UINT8* devSum,豸ŵ + UINT16* devLogIdBuf 洢豸߼ID + * ֵ + CI_SUCCESS:óɹ + CI_ERROR:ʧ + */ + UINT8 GetHlhtInitHeadDevsByDevType(const UINT8 devType, UINT8* devIdBuf, const UINT8 devIdBufMaxLen, UINT8* devSum, UINT16* devLogIdBuf); + + /* + * :ȡijCIͨŵ豸ĻͨͷϢǷڲЧ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + CI_ERROR: + * CI_SUCCESS: + */ + UINT8 GetHLHTHeadCtxValid(const UINT8 devType, const UINT8 devId); + + /* + * :жϺģʽʼ֡ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + CI_ERROR: + * CI_SUCCESS: + */ + UINT8 BackupHeadCheckValid(const UINT8 devType, const UINT8 devId); + + /* + * :ȡijCIͨŵ豸ĻͨͷϢǷ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + CI_ERROR: + * CI_SUCCESS: + */ + UINT8 GetHLHTHeadCtxExistance(const UINT8 devType,const UINT8 devId); + + /* + * :CIյʱԷLogId + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + const UINT16 ciRcvLogId:CIյʱԷLogId + * ֵ: + CI_SUCCESS:ɹ + CI_ERROR:ʧ + */ + void SetHLHTHeadCtxCiRcvLogId(const UINT8 devType, const UINT8 devId, const UINT16 ciRcvLogId); + + /* + * :ȡij豸ϴյCIʱCI + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + ij豸ϴյCIʱCI,0uΪЧֵ + */ + UINT32 GetHLHTHeadCtxSrcOppSN(const UINT8 devType, const UINT8 devId); + + /* + * :ȡij豸ͨ + * ˵: + const UINT8 devType:豸 + const UINT8 devId:豸ID + * ֵ: + ijͨ + */ + UINT32 GetHLHTHeadCtxComPeriod(const UINT8 devType, const UINT8 devId); + + /* + * ָITEĻͨͷ + * ˵const UINT8 iteId ITE ID + * const UINT16 iteLogId ITE߼ID + * const HLHTGALInfoStruct* strHlhtGalHead õITEͨͷ + * ֵ + * Created By LQ 2024.06.05 + */ + void SetIteHLHTHeadCtx(const UINT8 iteId, const UINT16 iteLogId, const HLHTGALInfoStruct* pstrHlhtGalHead); + + /* + * ȡָITEĻͨͷ + * ˵const UINT8 iteId ITE ID + * const UINT16 iteLogId ITE߼ID + * ֵNULL ȡʧ + * NULL ȡݳɹ + * Created By LQ 2024.06.05 + */ + HLHTHeadContextStru* GetIteHLHTHeadCtx(const UINT8 iteId, const UINT16 iteLogId); + + /* + * ɾָITEĻͨͷ + * ˵const UINT8 devId ITE ID + * const UINT16 logId ITE߼ID + * ֵ + * Created By LQ 2024.06.05 + */ + void ClearIteHlhtHeadCtx(const UINT8 devId, const UINT16 logId); + + /* + * УITEͨͷϢǷЧ + * ˵const UINT8 cIteId ITE ID + * const UINT16 wIteLogId ITE߼ID + * ֵCI_ERROR 0 Ч + * CI_SUCCESS 1 Ч + * Created By LQ 2024.06.06 + */ + UINT8 CheckIteHLHTHeadCtxValid(const UINT8 cIteId, const UINT16 wIteLogId); + + /* + * ȡ߱ʼͨŻͨͷITEID + * ˵UINT8* cIteNum ʼͨŵITEΣ + * UINT8 pIteIdBuf[ITE_TO_CI_SUM_MAX] ʼͨŵITE IDΣ + * UINT16 pIteLogIdBuf[ITE_TO_CI_SUM_MAX] ʼͨŵITE߼IDΣ + * ֵCI_ERROR 0 ʧ + * CI_SUCCESS 1 óɹ + * Created By LQ 2024.06.08 + */ + UINT8 GetIteHlhtInitHeadDevs(UINT8* cIteNum, UINT8 pIteIdBuf[ITE_TO_CI_SUM_MAX], UINT16 pIteLogIdBuf[ITE_TO_CI_SUM_MAX]); + + /* + * ITEͨͷʱЧԴ + * ˵const UINT32 dwTimeoutSnCount Ч + * const UINT32 dwTimeoutSpan Чʱ + * ֵ + * Created By LQ 2024.06.11 + */ + void ProcIteHlhtHeadCtxTimeOut(const UINT32 dwTimeoutSnCount, const UINT32 dwTimeoutSpan); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/IO/DeviceRelayDataProcess.c b/TSCP/src/APP/ciapp/IO/DeviceRelayDataProcess.c new file mode 100644 index 0000000..8734fe7 --- /dev/null +++ b/TSCP/src/APP/ciapp/IO/DeviceRelayDataProcess.c @@ -0,0 +1,15130 @@ +/******************************************************** +* +* DeviceRelayDataProcess.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-09-21 +* ߣ +* 豸ݹ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + +#include "DeviceRelayDataProcess.h" +#include "EnvelopeManageAPI.h" +#include "EnvelopeManage.h" +#include "SignalConfigDataManage.h" +#include "../SGBJ/SGBJConfigDataManage.h" +#include "InterlockCommonManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "AxisAssertManage.h" +#include "AxisAssertDataPrepare.h" + +/*źŻ̵ʱʱ()*/ +#define SIG_RELAY_DRV_DELAY_TIME ((UINT32)3) + +void SpksRelayToPhySecFlockStatus(void); +UINT8 GetCloseSignaleColor(const UINT8 color); + +/* @brief жռǷռü */ +static void IsOccPhyHasOccAc(void); + + +/* +* ָID̵ +* ˵ void +* ֵ +*/ +static void DriveSwitchRelayState(const UINT16 switchId, const UINT8 driveSwitchPos); +/* zt ɾش 2022-02-15 */ +/******************************źŻؼ̵****************************/ + + + +/******************************OC豸****************************/ + +/* +* OC豸 +* ˵ void +* ֵ void +*/ +void OcSwitchDeviceOutput(void) +{ + UINT16 switchCurSum = 0u; /*Ŀ*/ + UINT8 localCiId = 0u; /*ID*/ + + UINT16 switchId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*ID*/ + UINT16 ii = 0u; /*ѭ*/ + + UINT8 curSwitchPos = SWITCH_POSITION_INVALID; /*ǰλ*/ + UINT8 driveSwitchPos = SWITCH_DRIVE_POS_INVALID; /*λ*/ + UINT8 curExpDrvSwitchPos = SWITCH_DRIVE_POS_INVALID; /*λ*/ + UINT8 preExpDrvSwitchPos = SWITCH_DRIVE_POS_INVALID; /*λ*/ + + UINT8 timeState = CI_TIME_NO; /*ʱ״̬*/ + + UINT8 switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_FALSE; /*߷״̬*/ + + UINT8 preSwitchDrivingState = SWIT_DRIV_IDLE_TIME; /*֮ǰĵ״̬*/ + UINT8 curSwitchDrivingState = SWIT_DRIV_IDLE_TIME; /*ǰĵ״̬*/ + + UINT8 SwitchDanCaoPosition = SWITCH_POSITION_INVALID;/*λ*/ + UINT8 lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ:0x55:ǹ콻ͨ0xAA:콻ͨ*/ + UINT32 curNum = Get2oo2CurCycleNum(); + UINT8 chSwitchJichaState = 0U;/*״̬*/ + + switchCurSum = GetSwitchCurSum(); /*ȡ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + + /*ٵ߼*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + SwitchDanCaoPosition = GetSwitchDanCaoPostition(switchId); + + if (SwitchDanCaoPosition == SWITCH_POSITION_DINGWEI) + {/*λ*/ + (void)SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_DINGWEI); + } + else if (SwitchDanCaoPosition == SWITCH_POSITION_FANWEI) + {/*λ*/ + (void)SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_FANWEI); + }/* zt ɾش 2022-02-15 */ + else + { + /*ʲôҲ*/ + } + } + } + }/*for*/ + + /*λô*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + curSwitchPos = GetSwitchCurPosition(switchId);/*ȡǰλ*/ + + curExpDrvSwitchPos = GetSwitchExpDrvPosition(switchId);/*ȡǰλ*/ + + /* zt ɾش 2022-02-15 */ + if (((curSwitchPos == SWITCH_POSITION_DINGWEI) && (curExpDrvSwitchPos == SWITCH_DRIVE_POS_DINGWEI)) + || ((curSwitchPos == SWITCH_POSITION_FANWEI) && (curExpDrvSwitchPos == SWITCH_DRIVE_POS_FANWEI)) + ) + {/*λпʱɼJTYJa GZJ»TYJ*/ + (void)SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);/*Ȼλ,λΪЧ*/ + } + } + } + + }/*for*/ + + /*״̬*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + + curExpDrvSwitchPos = GetSwitchExpDrvPosition(switchId);/*ȡǰλ*/ + + preExpDrvSwitchPos = GetSwitchPreExpDrvPosition(switchId);/*ȡ֮ǰλ*/ + + preSwitchDrivingState = GetSwitchDrivingState(switchId);/*ȡ֮ǰʵ״̬*/ + + if (SWITCH_DRIVE_POS_INVALID == curExpDrvSwitchPos) + {/*ǰλЧ*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_IDLE_TIME);/*õ״̬Ϊ*/ + } + else + {/*ǰλЧ*/ + if (curExpDrvSwitchPos == preExpDrvSwitchPos) + {/*ƶǷѾʱ*//* zt ɾش 2022-02-15 */ + if (CI_TRADITION_RAILWAY == lineIdentity) + { /*нͨ*/ + timeState = SystemOverTimeCheck(GetSwitchMoveStartCycNum(switchId), GetSystemParaSwDrvCuoFengCnt()); + } + else + { + /**/ + } + + if (CI_TIME_NO == timeState) + {/*δ*/ + if (SWIT_DRIV_IDLE_TIME == preSwitchDrivingState) + {/*֮ǰĵ״̬Ϊ*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_WAIT_TIME);/*Ҫ,δʼ,һ,֮ǰ״̬Ϊ״̬,õ״̬Ϊȴ*/ + } + else if (SWIT_DRIV_PEAK_TIME == preSwitchDrivingState) + {/*֮ǰĵ״̬Ϊ߷*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_PEAK_TIME);/*Ҫ,δʼ,ijЩ,֮ǰ״̬Ϊ߷״̬,Ȼõ״̬Ϊ߷*/ + + switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_TRUE;/*õ߷״̬ΪTRUE,ʾҪĵе߷״̬*/ + } + else + { + /**/ + } + } + else if (CI_TIME_IN == timeState) + {/*,ڴ*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_PEAK_TIME);/*Ҫ,ѿʼ,֮ǰ״̬,õ״̬Ϊ߷*/ + + switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_TRUE;/*õ߷״̬ΪTRUE,ʾҪĵе߷״̬*/ + } + else if (CI_TIME_OUT == timeState) + {/*,Ѷȹ*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_FLAT_TIME);/*Ҫ,ѿʼʱ,֮ǰ״̬,õ״̬Ϊƽ*/ + } + else + { + /*ʲôҲ*/ + } + } + else + { + SetSwitchDrivingState(switchId, SWIT_DRIV_WAIT_TIME);/*õ״̬Ϊȴ*/ + } + } + } + } + }/*for*/ + + /*߼*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + curExpDrvSwitchPos = GetSwitchExpDrvPosition(switchId); + + curSwitchDrivingState = GetSwitchDrivingState(switchId); + + /*״̬*/ + if (SWIT_DRIV_IDLE_TIME == curSwitchDrivingState) + {/*״̬Ϊ*/ + /*ǰ״̬*/ + SetSwitchDrivePostion(switchId, SWITCH_DRIVE_POS_INVALID); + } + else if (SWIT_DRIV_WAIT_TIME == curSwitchDrivingState) + {/*״̬Ϊȴ*/ + if (SWIT_DRIV_PEAK_TIME_FALSE == switDrivPeakTimeState) + {/*ǰûе߷״̬*/ + SetSwitchDrivePostion(switchId, curExpDrvSwitchPos);/*Ϊû߷״̬,ʼ*/ + + SetSwitchDrivingState(switchId, SWIT_DRIV_PEAK_TIME);/*ʼ,õΪ߷״̬*/ + + switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_TRUE;/*õ߷״̬ΪTRUE,ʾҪĵе߷״̬*/ + } + else + { + SetSwitchDrivePostion(switchId, SWITCH_DRIVE_POS_INVALID); + } + } + else if (SWIT_DRIV_PEAK_TIME == curSwitchDrivingState) + {/*״̬Ϊ߷*/ + SetSwitchDrivePostion(switchId, curExpDrvSwitchPos); + + switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_TRUE;/*õ߷״̬ΪTRUE,ʾҪĵе߷״̬*/ + } + else if (SWIT_DRIV_FLAT_TIME == curSwitchDrivingState) + {/*״̬Ϊƽ*/ + SetSwitchDrivePostion(switchId, curExpDrvSwitchPos);/*ƽ״̬¼*/ + } + else + { + /*ʲôҲ*/ + } + } + } + }/*for*/ + + /*̵ɴ*/ +#if 0 + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + /*̵*/ + + /*λ*/ + driveSwitchPos = GetSwitchDrivePostion(switchId); + /* zt ɾش 2022-02-15 */ + if (CI_TRADITION_RAILWAY == lineIdentity) + { /*нͨ*/ + DriveSwitchRelayState(switchId, driveSwitchPos); + } + else + { + } + + + } + + } + + }/*for*/ +#endif + + /*ڽн,λ*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + curExpDrvSwitchPos = GetSwitchExpDrvPosition(switchId); + + /*λ*/ + SetSwitchPreExpDrvPosition(switchId, curExpDrvSwitchPos); + } + + } + }/*for*/ + + /*λ,Ϊ˫ԭ,"λ""λ"*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + /*λ*/ + (void)SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + /*ʱλ*/ + SetSwitchDrivOvtmDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + } + + } + }/*for*/ + + /* zt ɾش 2022-02-15 */ + + /*нõһЧλ*/ + for (ii = 0U; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + if ((belongCiId == localCiId) && (0u != localCiId)) + { + driveSwitchPos = GetSwitchDrivePostion(switchId); + if ((SWITCH_DRIVE_POS_DINGWEI == driveSwitchPos) || (SWITCH_DRIVE_POS_FANWEI == driveSwitchPos)) + { + (void)SetSwitchLastValidDrvPos(switchId, driveSwitchPos); + (void)SetSwitchLastValidPosDrivCycNum(switchId, curNum); + } + + chSwitchJichaState = GetSwitchPrompylyAlarmInfo(switchId); + /*ֻо̬Ͷ̬ãòһֱΪ0*/ + SetSwitchJichaState(switchId, chSwitchJichaState); + } + } + } +} + + + + + +/******************************OC豸봦****************************/ +/* +* ȡOC豸״̬ +* ˵ + UINT16 switchIdid +* ֵ +* ((UINT8)0x01) λ +* ((UINT8)0x02) λ +* ((UINT8)0x04) Ŀ +* ((UINT8)0x08) ƶ +*/ +UINT8 GetOcSwitchState(UINT16 switchId) +{ + UINT8 rtnSwitchState = 0u; + UINT16 belongOcId = 0u; /*oc ID*/ + UINT16 i = 0u; + UINT8 k = 0U; + UINT8 BoardStateErrCheck = 0U; /*忨ڹϼ*/ + UINT8 BoardStateOtherErrCheck = 0U; /*忨ڿǡ*/ + UINT8 BoardStateOpenCapCheck = 0U; /*忨ڿ״̬*/ + UINT8 flagFind = 0u; + UINT16 indexFind = 0u; + UINT8 switchBlockLinkState = 0u; /*״̬*/ + UINT8 switchBoardNum = 0U; + belongOcId = GetSwitchBelongOcId(switchId);/*ȡOc id*/ + + if ((0u < belongOcId) && (OC_SUM_MAX > belongOcId)) + { + /*m_OcToCiOrginDataArr[belongOcId].OcDevices*/ + for (i = 0u; i < m_SwitchNum; i++) + { + if (m_Switches[i].DeviceId == switchId) + { + flagFind = 1u; + indexFind = i; + break; + } + } + } + if (1u == flagFind) + { + rtnSwitchState = m_Switches[indexFind].DeviceState; + switchBoardNum = m_Switches[indexFind].BoardNum; + for (k = 0; k < switchBoardNum; k++) + { + if (0u != m_Switches[indexFind].BoardState[k]) + { + BoardStateErrCheck++; + if (0u == (m_Switches[indexFind].BoardState[k] & OC_SWITCH_OTHER_BJ_STATE)) + { + BoardStateOtherErrCheck++; + if (OC_SWITCH_OPEN_CAP_STATE == m_Switches[indexFind].BoardState[k]) + { + BoardStateOpenCapCheck++; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + /*忨״̬⣬õ״̬ΪĿ*/ + if (BoardStateErrCheck == switchBoardNum) + { + /*Ŀ*/ + rtnSwitchState = OC_SWITCH_POSITION_SIKAI; + + /*õϱ־*/ + SetSwitchFaultState(m_Switches[indexFind].DeviceId, SWITCH_FAULT_STATE_YES); + + /*ȡȡ״̬*/ + switchBlockLinkState = GetCancelOrRcvrBlockLinkSta(); + + /*ڰ忨ֻзDZ*/ + if (0u != BoardStateOtherErrCheck) + { + /*忨״̬һϵǿ״̬*/ + if (0u != BoardStateOpenCapCheck) + { + /*òɼ״̬*/ + rtnSwitchState = m_Switches[indexFind].DeviceState; + } + /*˵ڷ*/ + else + { + if (CANCEL_SWITCH_BLOCK_LINK == switchBlockLinkState) + { + /*òɼ״̬*/ + rtnSwitchState = m_Switches[indexFind].DeviceState; + } + } + } + /**/ + else + { + /**/ + } + } + else + { + /*õϱ־*/ + SetSwitchFaultState(m_Switches[indexFind].DeviceId, SWITCH_FAULT_STATE_NO); + } + } + switch (rtnSwitchState) + { + case OC_SWITCH_POSITION_DINGWEI: + rtnSwitchState = SWITCH_POSITION_DINGWEI; + break; + case OC_SWITCH_POSITION_FANWEI: + rtnSwitchState = SWITCH_POSITION_FANWEI; + break; + case OC_SWITCH_POSITION_SIKAI: + rtnSwitchState = SWITCH_POSITION_SIKAI; + break; + case OC_SWITCH_POSITION_MOVE: + rtnSwitchState = SWITCH_POSITION_MOVE; + break; + default: + rtnSwitchState = SWITCH_POSITION_SIKAI; + break; + } + return rtnSwitchState; +} + +/* +* OC豸ɼ״̬->߼״̬ +* ˵ void +* ֵ void +*/ +void OcSwitchDeviceInput(void) +{ + UINT16 switchCurSum = 0u; /*Ŀ*/ + switchCurSum = GetSwitchCurSum(); /*ȡ*/ + + /*еλ*/ + SetAllSingleSwitchCurPosition(switchCurSum); + + /*õǰ߼λ*/ + UpdataSwitchCurPostion(switchCurSum); + + /*ݵǰ߼λѡ*/ + ClearSwitchMessageByCurPostion(switchCurSum); +} + +/******************************OCźŻ豸****************************/ +/* +* OCźŻ豸 +* ˵ void +* ֵ void +*/ +void OcSignalDeviceOutput(void) +{ + UINT16 signalCurSum = 0u; /*źŻĿ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*źŻID*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT8 curDrvColor = 0u; /*źŻǰɫ*/ + UINT8 curShowColor = 0u; /*źŻǰʾɫ*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 signalIsfushiFlag = 0u; + UINT8 overTimeCheckResult = 0U;/*ʱ*/ + UINT32 signalDriOpenStartCyc = 0U;/*źŻʼ*/ + UINT32 signalDriOpenTimeCount = 0U;/*źŻųʱ*/ + UINT32 signalDriCloseStartCyc = 0U;/*źŻرʼ*/ + UINT32 signalDriCloseTimeCount = 0U;/*źŻرճʱ*/ + UINT8 driveRetVal = 0U; + UINT32 jkjValidCycNum = 0u; + UINT8 jkjRelayValidFlag = 0u; + + signalCurSum = GetSignalCurSum(); /*ȡźŻ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + /*źŻ*/ + for (ii = 0u; ii < signalCurSum; ii++) + { + signalId = 0u; /*źŻID*/ + belongCiId = 0u; /*źŻID*/ + curDrvColor = 0u; /*źŻǰɫ*/ + + signalId = GetSignalId(ii); /*ȡźŻID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((0u != localCiId) && (belongCiId == localCiId) && (0u < signalId) && (signalId <= SIGNAL_SUM_MAX)) + { + /***ʱ***/ + curDrvColor = GetSignalCurDriveColor(signalId); /*ȡźŻǰɫ*/ + + if (SIGNAL_DRIVECOLOUR_NULL == curDrvColor) + {/*źŻЧ*/ + jkjRelayValidFlag = GetCiJkjFlag(); + jkjValidCycNum = GetJkjRelayValidCycNum(); + curShowColor = GetSignalCurColor(signalId); + if (((SIGNAL_SHOWCOLOUR_REDYELLOW == curShowColor) || (SIGNAL_SHOWCOLOUR_RED_WHITE == curShowColor)) && + (JKJ_REYLAY_VALID == jkjRelayValidFlag) && (jkjValidCycNum > 0u)) + { + /*źſʱӦЧ֮˹źſţִ*/ + } + else + { + driveRetVal = DriveSignalClose(signalId); /*źŻر*/ + if (CI_ERROR == driveRetVal) + { + } + } + } + + curDrvColor = GetSignalCurDriveColor(signalId); /*ȡźŻǰɫ*/ + + if ((SIGNAL_DRIVECOLOUR_RED == curDrvColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == curDrvColor)) + {/*źŻر*/ + + signalDriCloseStartCyc = GetSignalDriveCloseStartCycNum(signalId); + signalDriCloseTimeCount = GetSystemParaSignalCloseCyc(); + overTimeCheckResult = SystemOverTimeCheck(signalDriCloseStartCyc,signalDriCloseTimeCount); + if (CI_TIME_OUT == overTimeCheckResult) + {/*źŻرճʱ*/ + signalIsfushiFlag = GetSignalIsfushiFlag(signalId); + if(SIGNALTYPE_FUSHI_YES != signalIsfushiFlag)/*ʾźŻرճʱ崻*/ + { + /*xxxxx崻 źŻرճʱ*/ + SetPlatOverFlag(); /*ƽ̨崻*/ + + SetErrorData(EFUNC_PLAT_OVER, CI_DEVICE_TYPE_SIGNAL, signalId, ETYPE_SIG_CLOSE_OVER_TIME, curDrvColor, ESEND_LEVEL_ZERO);/*¼崻*/ + } + } + } + else + {/*źŻ״̬*/ + signalDriOpenStartCyc = GetSignalDriveOpenStartCycNum(signalId); + signalDriOpenTimeCount = GetSystemParaSignalOpenCyc(); + overTimeCheckResult = SystemOverTimeCheck(signalDriOpenStartCyc,signalDriOpenTimeCount); + if (CI_TIME_OUT == overTimeCheckResult) + {/*źſ״̬*/ + + driveRetVal = DriveSignalClose(signalId);/*źŻر*/ + if (CI_ERROR == driveRetVal) + { + /*źŹرʧ*/ + } + } + } + + + /***źŻ̵***/ +#if 0 + if (SIGNAL_VIRTUAL_NO == signalVirtualAttr) + {/*źŻŽ̵*/ + /*źŻؼ̵ִе*/ + if (CI_ERROR == SetSignalRelayState(signalId)) + { + + } + } +#endif + + /*ɫһɫͬһ仯ɫ*/ + if (GetSignalCurDriveColor(signalId) != GetSignalPreDriveColor(signalId)) + { + (void)SetSignalPreChangedDriveColor(signalId, GetSignalPreDriveColor(signalId)); + } + + /*֮ǰʾɫźŻ൱ڸ߼״̵̬״̬*/ + (void)SetSignalPreDriveColor(signalId, GetSignalCurDriveColor(signalId)); + } + + } +} + + + +/******************************OCźŻ豸봦****************************/ + +/* +* ȡOCźŻ豸ɫ +* ˵ + UINT16 signalIdźŻid +* ֵ void +*/ +UINT8 GetOcSignalColor(UINT16 signalId) +{ + UINT8 rtnSigColor = SIGNAL_SHOWCOLOUR_INVALID; + UINT8 belongOcId = 0u; /*źŻoc ID*/ + UINT16 i = 0u; + UINT8 flagFind = 0u; + UINT16 indexFind = 0u; + UINT8 sigPreDriveColor = 0u;/*źŻ֮ǰɫ*/ + UINT8 sigCurShowColor = 0u;/*źŻǰʾɫ*/ + UINT8 sigColorLevel = 0u;/*źŻɫ*/ + UINT8 funSwitchGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*ʾ̻ƹܿǷ*/ + UINT8 ciType = GetLocalCiType(); + UINT8 signalState = 0U; + + belongOcId = (UINT8)GetSignalBelongOcId(signalId);/*ȡźŻOc id*/ + + if ((0u < belongOcId) && (OC_SUM_MAX> belongOcId)) + { + /*m_OcToCiOrginDataArr[belongOcId].OcDevices*/ + for (i = 0u; i < m_SignalNum; i++) + { + if (CI_SIGNAL_MAX > i) + { + if (m_Signals[i].DeviceId == signalId) + { + flagFind = 1u; + indexFind = i; + break; + } + else + { + ; + } + } + else + { + ; + } + } + + } + else + { + ; + } + if (1u == flagFind) + { + /*ӴOCźŻAϵBϵִа״̬쳣źŻ״̬Ϊ*/ + if ((0u != m_Signals[indexFind].BoardState[0]) && (0u != m_Signals[indexFind].BoardState[1])) + { + SetOcSignalStartCycNum(m_Signals[indexFind].DeviceId, 0); + rtnSigColor = GetOcBoardFaultSignalColor(m_Signals[indexFind].DeviceId, belongOcId); + } + else + { + /*Ϣ*/ + SetSignalBoardState(m_Signals[indexFind].DeviceId, OC_SIGNAL_BOARD_FAULT_NO); + /**/ + if (OC_SIGNAL_SHOWCOLOR_ALL_CLOSE == m_Signals[indexFind].DeviceState)/**/ + { + /*ƣȡ֮ǰɫ*/ + sigPreDriveColor = GetSignalPreDriveColor(m_Signals[indexFind].DeviceId); + + sigColorLevel = GetSignalColorLevel(sigPreDriveColor); + + if ((SIGNAL_LIGHT_EXTICT_STATE_NO == sigColorLevel) && (FUNC_SWITCH_OFF == funSwitchGreenYellow)) + { + /*OCȫ̼ʱ*/ + SetOcSignalStartCycNum(m_Signals[indexFind].DeviceId, 0); + /*źŻɫΪƲô*/ + if (SIGNAL_SHOWCOLOUR_INVALID == sigPreDriveColor) + { + rtnSigColor = SIGNAL_SHOWCOLOUR_REDCLOSE; + } + else + { + rtnSigColor = sigPreDriveColor; + } + } + else + { + /*õǰɫ*/ + rtnSigColor = SetSignalColorOcAllOff(m_Signals[indexFind].DeviceId); + + } + +#if 0 + /*֮ǰĻߺ*/ + if ((SIGNAL_DRIVECOLOUR_YELLOWCLOSE == sigPreDriveColor) || + (SIGNAL_DRIVECOLOUR_REDCLOSE == sigPreDriveColor) || + (SIGNAL_DRIVECOLOUR_GREENCLOSE == sigPreDriveColor)) + { + rtnSigColor = sigPreDriveColor; + } + else if (SIGNAL_SHOWCOLOUR_INVALID == sigPreDriveColor) + { + rtnSigColor = SIGNAL_SHOWCOLOUR_RED; + } + else + { + rtnSigColor = SIGNAL_SHOWCOLOUR_RED; + } +#endif + } + else if ((OC_SIGNAL_SHOWCOLOR_BLUE == m_Signals[indexFind].DeviceState) && (FUNC_SWITCH_ON == funSwitchGreenYellow) &&(CI_TYPE_CLD != ciType)) + { + /*人ش򿪣ȡ仯֮ǰɫ*/ + sigPreDriveColor = GetSignalPreDriveColor(m_Signals[indexFind].DeviceId); + + sigColorLevel = GetSignalColorLevel(sigPreDriveColor); + /*OCȫ̼ʱ*/ + SetOcSignalStartCycNum(m_Signals[indexFind].DeviceId, 0); + + if (SIGNAL_LIGHT_EXTICT_STATE_NO == sigColorLevel) + { + /*źŻɫΪƲô*/ + if (SIGNAL_SHOWCOLOUR_INVALID == sigPreDriveColor) + { + rtnSigColor = SIGNAL_SHOWCOLOUR_RED; + } + else + { + rtnSigColor = sigPreDriveColor; + } + } + else + { + /*õǰɫ*/ + rtnSigColor = GetSignalCurColor(m_Signals[indexFind].DeviceId); + + } + } + else + { + /*OCȫ̼ʱ*/ + SetOcSignalStartCycNum(m_Signals[indexFind].DeviceId, 0); + signalState = m_Signals[indexFind].DeviceState; + sigPreDriveColor = GetSignalPreDriveColor(m_Signals[indexFind].DeviceId); + sigCurShowColor = GetSignalCurColor(m_Signals[indexFind].DeviceId); + switch (signalState) + {/*ocźŻɫתɼźŻʾɫ*/ + case OC_SIGNAL_SHOWCOLOR_RED: + rtnSigColor = SIGNAL_SHOWCOLOUR_RED; + break; + case OC_SIGNAL_SHOWCOLOR_YELLOW: + if ((FUNC_SWITCH_ON == funSwitchGreenYellow) && + ((SIGNAL_DRIVECOLOUR_GREENYELLOW == sigPreDriveColor)|| (SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW == sigPreDriveColor) + || (SIGNAL_DRIVECOLOUR_RED == sigPreDriveColor) || (SIGNAL_DRIVECOLOUR_GREEN == sigPreDriveColor))) + { + rtnSigColor = sigCurShowColor; + } + else + { + rtnSigColor = SIGNAL_SHOWCOLOUR_YELLOW; + } + break; + case OC_SIGNAL_SHOWCOLOR_REDYELLOW: + rtnSigColor = SIGNAL_SHOWCOLOUR_REDYELLOW; + break; + case OC_SIGNAL_SHOWCOLOR_GREEN: + if ((FUNC_SWITCH_ON == funSwitchGreenYellow) && + ((SIGNAL_DRIVECOLOUR_GREENYELLOW == sigPreDriveColor) || (SIGNAL_DRIVECOLOUR_DOUBLE_GREEN == sigPreDriveColor) || (SIGNAL_DRIVECOLOUR_RED == sigPreDriveColor))) + { + rtnSigColor = sigCurShowColor; + } + else + { + rtnSigColor = SIGNAL_SHOWCOLOUR_GREEN; + } + break; + case OC_SIGNAL_SHOWCOLOR_WHITE: + rtnSigColor = SIGNAL_SHOWCOLOUR_WHITE; + break; + case OC_SIGNAL_SHOWCOLOR_YELLOW2: + rtnSigColor = sigCurShowColor; + break; + case OC_SIGNAL_SHOWCOLOR_GREEN2: + rtnSigColor = sigCurShowColor; + break; + case OC_SIGNAL_SHOWCOLOR_REDWHITE: + rtnSigColor = SIGNAL_SHOWCOLOUR_RED_WHITE; + break; + case OC_SIGNAL_SHOWCOLOR_BLUE: + rtnSigColor = SIGNAL_SHOWCOLOUR_RED; + break; + case OC_SIGNAL_SHOWCOLOR_GREENYELLOW: + rtnSigColor = SIGNAL_SHOWCOLOUR_GREENYELLOW; + break; + case OC_SIGNAL_SHOWCOLOR_DOUBLEYELLOW: + rtnSigColor = SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW; + break; + case OC_SIGNAL_SHOWCOLOR_DOUBLEGREEN: + rtnSigColor = SIGNAL_SHOWCOLOUR_DOUBLE_GREEN; + break; + case OC_SIGNAL_SHOWCOLOR_RED_BREAK: + rtnSigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + break; + case OC_SIGNAL_SHOWCOLOR_YELLOW_BREAK: + rtnSigColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK; + break; + case OC_SIGNAL_SHOWCOLOR_GREEN_BREAK: + rtnSigColor = SIGNAL_SHOWCOLOUR_GREENBREAK; + break; + case OC_SIGNAL_SHOWCOLOR_WHITE_BREAK: + rtnSigColor = SIGNAL_SHOWCOLOUR_WHITEBREAK; + break; + case OC_SIGNAL_SHOWCOLOR_BLUE_BREAK: + /* ޸:by pfq 2022.03.28 ƶ˿źŻԵ⣬ƶ˿ת*/ + /*޸ 人Ϊ*/ + if (CI_TYPE_CLD != ciType) + { + rtnSigColor = SIGNAL_SHOWCOLOUR_BLUEBREAK; + } + else + { + rtnSigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + } + break; + case OC_SIGNAL_SHOWCOLOR_YELLOW_2_BREAK: + rtnSigColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK; + break; + case OC_SIGNAL_SHOWCOLOR_GREEN_2_BREAK: + rtnSigColor = SIGNAL_SHOWCOLOUR_GREENBREAK; + break; + default: + /*by cgh 20230703 YF0083-772:OCrcźŻ״̬ΪǷֵbbrcźŻԸΪ*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + break; + } + } + } + } + return rtnSigColor; +} +/* +* źŻ˫ϵ忨ϣźŻǰɫ +* ˵ + UINT16 signalIdźŻid + UINT8 ocId OC ID +* ֵ źŻɫ +*/ +UINT8 GetOcBoardFaultSignalColor(UINT16 signalId, UINT8 ocId) +{ + UINT8 stateSignalOpen = 0u; + UINT8 transmitState = 0u; + UINT8 rtnSigColor = 0u; + UINT8 sigPreDriveColor = 0u; + UINT8 sigMaintainState = 0u; + UINT8 funSwitchGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*ʾ̻ƹܿǷ*/ + transmitState = GetCiTransmitState(CI_SYSTEM_TYPE_OC, ocId); + /*ͨ*/ + if(TRANSMIT_STATE_GOOD == transmitState) + { + /*ñϢ*/ + SetSignalBoardState(signalId,OC_SIGNAL_BOARD_FAULT_YES); + stateSignalOpen = GetSignalLightExtinctState(signalId); + /*CBTCģʽ&&źŻά޵״̬ Ӱʹ--WGY 20220705*/ + sigMaintainState = GetSignalMaintainState(signalId); + sigPreDriveColor = GetSignalPreDriveColor(signalId); + if((SIGNAL_LIGHT_EXTICT_STATE_NO == stateSignalOpen)&&(MAINTAIN_STATE_NO == sigMaintainState) && (FUNC_SWITCH_OFF == funSwitchGreenYellow)) + { + /*ƣȡ֮ǰɫ*/ + + /*֮ǰЧ*/ + if (SIGNAL_SHOWCOLOUR_INVALID == sigPreDriveColor) + { + rtnSigColor = SIGNAL_SHOWCOLOUR_REDCLOSE; + } + else + { + rtnSigColor = sigPreDriveColor; + } + } + else + { + /*ú*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + } + } + /*ͨ쳣*/ + else + { + /*ȡ*/ + SetSignalBoardState(signalId,OC_SIGNAL_BOARD_FAULT_NO); + /*ú*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + + } + return rtnSigColor; +} + +/* +* źŻ£OCȫźŻɫ +* ˵ + UINT16 signalIdźŻid +* ֵ źŻɫ +*/ +UINT8 SetSignalColorOcAllOff(const UINT16 signalId) +{ + /*ʼ*/ + UINT8 signalCurColor = 0u; + UINT8 rtnSigColor = 0u; + UINT32 signalCycNum = 0u; + UINT32 curCycNum = 0u; + UINT8 checkCycOut = 0u; + UINT8 preDriveColor = 0u; + UINT32 signalRongrenNum = 0u; + UINT8 funSwitchGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*ʾ̻ƹܿǷ*/ + /*ȡǰɫΪźŻǰɫδ£ǻȡһɫ*/ + signalCurColor = GetSignalCurColor(signalId); + curCycNum = Get2oo2CurCycleNum(); + + /*ʱõǰɫΪһɫ*/ + signalCycNum = GetOcSignalStartCycNum(signalId); + /*ȡϵͳõOCźŻȫʱ*/ + signalRongrenNum = GetSigCollectRongernCount(); + checkCycOut = SystemOverTimeCheck(signalCycNum,signalRongrenNum); + /*δʱ*/ + if(CI_TIME_NO == checkCycOut) + { + /*ɫ*/ + rtnSigColor = signalCurColor; + SetOcSignalStartCycNum(signalId,curCycNum); + } + /*ʱ*/ + else if(CI_TIME_OUT == checkCycOut) + { + /*ȡ֮ǰɫ*/ + preDriveColor = GetSignalPreDriveColor(signalId); + debug_infor_printf((const)"ALL CLOSE curCyc%d, SignalStartCycNum%d preDriveColor:%d \n.", curCycNum, signalCycNum, preDriveColor); + switch(preDriveColor) + { + case SIGNAL_DRIVECOLOUR_RED: + /*ú*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + break; + case SIGNAL_DRIVECOLOUR_YELLOW: + /*ûƶ*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK; + break; + case SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW: + case SIGNAL_DRIVECOLOUR_GREENYELLOW: + /*˫ ̻ ȫûƶ*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK; + break; + case SIGNAL_DRIVECOLOUR_DOUBLE_GREEN: + /*˫ȫ̶*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_GREENBREAK; + break; + case SIGNAL_DRIVECOLOUR_GREEN: + /*̶*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_GREENBREAK; + break; + /*ơ*/ + case SIGNAL_DRIVECOLOUR_REDYELLOW: + case SIGNAL_DRIVECOLOUR_RED_WHITE: + /*ú*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + break; + case SIGNAL_DRIVECOLOUR_WHITE: + /*ð׶*/ + rtnSigColor = SIGNAL_SHOWCOLOUR_WHITEBREAK; + break; + case SIGNAL_DRIVECOLOUR_GREENCLOSE: + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE: + case SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE: + /*̻ȫûƶ*/ + if (FUNC_SWITCH_ON == funSwitchGreenYellow) + { + rtnSigColor = SIGNAL_SHOWCOLOUR_BLUEBREAK; + } + else + { + rtnSigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + } + break; + default: + /*״̬ ˴ɴ֧*/ + break; + } + } + else + { + /*ɫ*/ + rtnSigColor = signalCurColor; + } + return rtnSigColor; +} + +/* +* OCźŻ豸ɼ״̬->߼״̬ +* ˵ void +* ֵ void +*/ +void OcSignalDeviceInput(void) +{ + UINT16 signalCurSum = 0u; /*źŻĿ*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT8 localCiId = 0u; + UINT16 ii = 0u; + UINT8 belongCiId = 0u; /*źŻID*/ + UINT8 signalVirtualAttr = 0u; + UINT8 signalCurColor = 0u; /*źŻǰʾɫ*/ + UINT8 signalPreDrvColor = 0u;/*źŻ֮ǰɫ*/ + UINT16 signalDetainRelayId = 0u;/*źŻӲ߿۳1 ID*/ + UINT16 detainCutRelayId = 0u; /*۳·̵1 ID*/ + UINT8 relayBelongCIId = 0u; + UINT16 signalDetainRelayId_2 = 0u;/*źŻӲ߿۳2 ID*/ + UINT8 DetainRelayId_2BelongCIId = 0u; + UINT16 detainCutRelayId_2 = 0u; /*۳·̵2 ID*/ + UINT8 cheakdetain_1 = CI_ERROR; + UINT8 cheakdetain_2 = CI_ERROR; + UINT8 sigOpenCloseState = 0u; + UINT8 sigPreOpenCloseState = 0u; + UINT32 diffColorCycNum = 0u; + UINT32 curCycNum = 0U; + UINT8 driveRetVal = 0U; + UINT8 signalDetainBtnActFlag = SIGNAL_ZFS_BTN_ACT_FLAG_NO; /*۳ť1־*/ + UINT8 funcswitchZfsBtn = 0U; /*ǷΪԸʽť*/ + UINT8 addCiToCiCmdFlag = CI_ERROR; /*Ƿ*/ + UINT32 signalDriveNewSigStartCyc = 0u; /*źŻźʼں*/ + UINT32 signalDiffCyc = 0U; /*źſɫһ*/ + + curCycNum= Get2oo2CurCycleNum(); + signalCurSum = GetTotalSignalCurNum(); /*ȡźŻ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + funcswitchZfsBtn = GetCiFunctionSwitchConfig(FUNC_ZIFUSHI_BUTTON); + + /*źŻ*/ + for (ii = 0u; ii < signalCurSum; ii++) + { + signalId = GetSignalId(ii); + belongCiId = GetSignalBelongCiId(signalId); + signalVirtualAttr = GetSignalVirtualAttr(signalId); /*ȡźŻ*/ + cheakdetain_1 = CI_ERROR; /*жϿ۳֮ǰȽ־Ϊ*/ + cheakdetain_2 = CI_ERROR; + + addCiToCiCmdFlag = CI_ERROR; + /*ȡ۳̵1 */ + signalDetainRelayId = GetSignalDetainRelayId(signalId); + relayBelongCIId = GetRelayBelongCiId(signalDetainRelayId);/*۳̵1ID*/ + detainCutRelayId = GetSignalDetainCutRelayId(signalId); + + if (FUNC_SWITCH_ON != funcswitchZfsBtn) /*Ըʽ۳ť*/ + { + /*۳̵2 ״̬ȡ*/ + signalDetainRelayId_2 = GetSignalDetainRelayId_2(signalId); + DetainRelayId_2BelongCIId = GetRelayBelongCiId(signalDetainRelayId_2); + detainCutRelayId_2 = GetSignalDetainCutRelayId_2(signalId); + /*۳̵ڱ*/ + if (relayBelongCIId == localCiId) + { + if ((0u != signalDetainRelayId) && (UINT16_MAX != signalDetainRelayId)) + { + cheakdetain_1 = CheakDeatainState(detainCutRelayId, signalDetainRelayId); + addCiToCiCmdFlag = CI_SUCCESS; + } + } + else + { + /*޲*/ + } + if (DetainRelayId_2BelongCIId == localCiId) + { + if ((0u != signalDetainRelayId_2) && (UINT16_MAX != signalDetainRelayId_2)) + { + /*Ӳ߿۳̵2 Ч*/ + cheakdetain_2 = CheakDeatainState(detainCutRelayId_2, signalDetainRelayId_2); + addCiToCiCmdFlag = CI_SUCCESS; + } + } + else + { + } + } + else /*Ըʽ۳ť*/ + { + if ((relayBelongCIId == localCiId) || (belongCiId == localCiId)) + { + SignalZfsDetainBtnPro(signalId); + SignalZfsCancelDetainBtnPro(signalId); + signalDetainBtnActFlag = GetSignalDetainBtnActFlag(signalId); + if (SIGNAL_ZFS_BTN_ACT_FLAG_NO != signalDetainBtnActFlag) + { + cheakdetain_1 = CI_SUCCESS; + } + else + { + cheakdetain_1 = CI_ERROR; + } + addCiToCiCmdFlag = CI_SUCCESS; + } + else + { + /**/ + } + } + + if ((0u != localCiId) && (belongCiId == localCiId) && (0u < signalId) && (SIGNAL_SUM_MAX >= signalId)) + { + /*ȡźŻʾɫ*/ + if (SIGNAL_VIRTUAL_YES == signalVirtualAttr) + {/*źŻǰʾɫΪ֮ǰɫ*/ + signalCurColor = GetSignalPreDriveColor(signalId); + } + else if (SIGNAL_VIRTUAL_NO == signalVirtualAttr) + { + signalCurColor = GetOcSignalColor(signalId);/*ȡOCźŻɫ*/ + } + else + { + /*Ҫ*/ + } + + + /*źŻЧ*/ + signalDriveNewSigStartCyc = GetSignalDriveNewSigStartCycNum(signalId); + if (signalDriveNewSigStartCyc == curCycNum) + { + /*ǰźŻ˴Ч*/ + } + else + { + /*źŻЧ*/ + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_NULL); + } + + /*õǰʾɫ*/ + OcSetSignalCurColor(signalId, signalCurColor); + + /*źŻǰǿŵģ֮ǰҲţɫ͵ǰɫͬر*/ + sigOpenCloseState = GetSignalOpenCloseState(signalCurColor); + if (SIGNAL_OPEN == sigOpenCloseState) + { + signalPreDrvColor = GetSignalPreDriveColor(signalId);/*ȡźŻ֮ǰɫ*/ + sigPreOpenCloseState = GetSignalOpenCloseState(signalPreDrvColor); + if ((SIGNAL_OPEN == sigPreOpenCloseState) && (signalPreDrvColor != signalCurColor)) + {/*֮ǰҺ͵ǰɫͬ*/ + diffColorCycNum = GetSignalDiffColorOpenStartCyc(signalId); + curCycNum = Get2oo2CurCycleNum(); + if (0u == diffColorCycNum) + { + (void)SetSignalDiffColorOpenStartCyc(signalId, Get2oo2CurCycleNum());/*źŻɫڵǰɫʼ*/ + } + else + { + /*жǷ񳬹*/ + if (SIGNAL_DRIVECOLOUR_GREENYELLOW == signalPreDrvColor) + { + /*̻Ʋýϳʱ ת̻/˫/˫ƱͲÿʱ ת̻Ҳøʱ*/ + signalDiffCyc = GetSystemParaSignalOpenCyc(); + } + else + { + signalDiffCyc = (UINT32)SIGNAL_RELAY_ACTION_TIMEMAX; + } + if ((curCycNum - diffColorCycNum) >= signalDiffCyc) + {/*ʱ*/ + driveRetVal = DriveSignalClose(signalId);/*ر*/ + if (CI_ERROR == driveRetVal) + { + /*źŹرʧ*/ + } + + (void)SetSignalDiffColorOpenStartCyc(signalId, 0u);/*źŻɫڵǰɫʼ*/ + } + else + { + /*ûгʱ̣*/ + } + } + } + else + { + (void)SetSignalDiffColorOpenStartCyc(signalId, 0u);/*źŻɫڵǰɫʼ*/ + } + } + else + { + (void)SetSignalDiffColorOpenStartCyc(signalId, 0u);/*źŻɫڵǰɫʼ*/ + } + + /*źŻӲ߿۳״̬*/ + if ((CI_SUCCESS == cheakdetain_1) || (CI_SUCCESS == cheakdetain_2)) + { + SetSignalRelayDetainFlag(signalId, SIGNAL_RELAY_DETAIN_YES); + } + else + { + if (((relayBelongCIId == localCiId) || (UINT16_MAX == signalDetainRelayId) || (0u == signalDetainRelayId)) && + ((DetainRelayId_2BelongCIId == localCiId) || (UINT16_MAX == signalDetainRelayId_2) || (0u == signalDetainRelayId_2))) + { + SetSignalRelayDetainFlag(signalId, SIGNAL_RELAY_DETAIN_NO); + } + else + { + /*˷֧ۣDZĿ۳ťڼáȡ۳־*/ + } + } + } + /*źŻDZ*/ + else if ((0u != localCiId) && (belongCiId != localCiId) && (0u < signalId) && (SIGNAL_SUM_MAX >= signalId)) + { + if (CI_SUCCESS == addCiToCiCmdFlag) + { + /*źŻӲ߿۳״̬*/ + if ((CI_SUCCESS == cheakdetain_1) || (CI_SUCCESS == cheakdetain_2)) + { + /*ӿ۳*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE_DETAIN, signalId, SIGNAL_DETAIN_CI_RELAY_YES, belongCiId); + } + else + { + /*δ۳*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE_DETAIN, signalId, SIGNAL_DETAIN_CI_RELAY_NO, belongCiId); + } + } + else + { + /**/ + } + } + else + { + /*޲*/ + } + } +} + +/* +* Ըʽ۳ť +* ˵ const UINT16 signalId źŻID +* ֵ +*/ +void SignalZfsDetainBtnPro(const UINT16 signalId) +{ + UINT16 detainBtnRelayId = 0U; /*۳ťɼ̵1ID*/ + UINT8 localCiId = 0U; /*ID*/ + UINT8 detainRelayBelongCiId = 0U; /*۳ťɼ̵1CI*/ + UINT8 detainRelayCollState = 0U; /*۳ťɼ̵1״̬*/ + UINT8 relayDetainValidFlag = 0U; /*Ӳ߿۳Ч־*/ + UINT32 cycnow = 0U; /*ǰ*/ + UINT32 zfsBtnRelayCollCycNum = 0U; /*Ըʽť̵ɼ*/ + UINT32 zfsBtnRelayFaultCycNum = 0U; /*Ըʽť̵ж*/ + UINT32 detainBtnPressCycNum = 0U; /*۳ť1*/ + UINT8 btnPressValidTime = CI_TIME_NO; /*ťʱǷﵽЧʱ*/ + UINT8 btnPressFaultTime = CI_TIME_NO; /*ťʱǷﵽʱ*/ + UINT8 detainBtnErrorFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; + + detainBtnRelayId = GetSignalDetainRelayId(signalId); + localCiId = GetSystemParaLocalCiId(); + detainRelayBelongCiId = GetRelayBelongCiId(detainBtnRelayId); + + /*̵IDЧ̵ڱ*/ + if ((0U != detainBtnRelayId) && (UINT16_MAX != detainBtnRelayId) + && (localCiId == detainRelayBelongCiId) && (0U != detainRelayBelongCiId)) + { + relayDetainValidFlag = GetCiFunctionSwitchConfig(FUNC_RELAY_DETAIN_VALID_FLAG); + detainRelayCollState = GetRelayCollState(detainBtnRelayId); /*ȡ۳ť̵1ɼ״̬*/ + + if (((DOWN_VALID == relayDetainValidFlag) && (RELAY_STATE_DOWN == detainRelayCollState)) + || ((UP_VALID == relayDetainValidFlag) && (RELAY_STATE_UP == detainRelayCollState))) + { + detainBtnPressCycNum = GetDetainBtnPressCycNum(signalId); + if (0U == detainBtnPressCycNum) + { + cycnow = Get2oo2CurCycleNum(); + SetDetainBtnPressCycNum(signalId, cycnow); /*ðť*/ + } + } + else + { + SetDetainBtnPressCycNum(signalId, 0U); + } + + detainBtnPressCycNum = GetDetainBtnPressCycNum(signalId); + zfsBtnRelayCollCycNum = GetSelfButCollCount(); + btnPressValidTime = SystemOverOrEqualTimeCheck(detainBtnPressCycNum, zfsBtnRelayCollCycNum); + detainBtnErrorFlag = GetSignalDetainBtnErrFlag(signalId); + + /*ťʱﵽжϲɼЧʱδϣÿ۳ťЧ*/ + if ((CI_TIME_OUT == btnPressValidTime) && (SIGNAL_ZFS_BTN_ERR_FLAG_YES != detainBtnErrorFlag)) + { + SetSignalDetainBtnActFlag(signalId, SIGNAL_ZFS_BTN_ACT_FLAG_YES); /*۳ť1*/ + } + else + { + /**/ + } + + zfsBtnRelayFaultCycNum = GetSelfButErrCount(); + btnPressFaultTime = SystemOverTimeCheck(detainBtnPressCycNum, zfsBtnRelayFaultCycNum); + if (CI_TIME_OUT == btnPressFaultTime) + { + SetSignalDetainBtnErrFlag(signalId, SIGNAL_ZFS_BTN_ERR_FLAG_YES); + } + else + { + SetSignalDetainBtnErrFlag(signalId, SIGNAL_ZFS_BTN_ERR_FLAG_NO); + } + } + else + { + /**/ + } +} + +/* +* Ըʽȡ۳ť +* ˵ const UINT16 signalId źŻID +* ֵ +*/ +void SignalZfsCancelDetainBtnPro(const UINT16 signalId) +{ + UINT16 wSignalIdIndex = 0U; /*źŻ±*/ + UINT16 cancelDetainBtnRelayId = 0U; /*ȡ۳ťɼ̵ID*/ + UINT8 localCiId = 0U; /*ID*/ + UINT8 cancelDetainRelayBelongCiId = 0U; /*ȡ۳ťɼ̵CI*/ + UINT32 zfsBtnRelayCollCycNum = 0U; /*Ըʽť̵ɼ*/ + UINT32 zfsBtnRelayFaultCycNum = 0U; /*Ըʽť̵ж*/ + UINT32 zfsBtnRelayErrTrigCycNum = 0U; /*Ըʽť̵󴥷ж*/ + UINT32 cancelDetainBtnPressCycNum = 0U; /*ȡ۳ť*/ + UINT32 cancelDetErrTrigPressCycNum = 0U; /*ȡ۳ť󴥷*/ + UINT8 cancelDetainBtnValidFlag = SIGNAL_CANCEL_DETAIN_VALID_NO; /*ȡ۳ťЧ־*/ + UINT8 btnPressValidTime = CI_TIME_NO; /*ťʱǷﵽЧʱ*/ + UINT8 btnPressFaultTime = CI_TIME_NO; /*ťʱǷﵽʱ*/ + UINT8 btnPressErrTrigTime = CI_TIME_NO; /*ťʱǷﵽ󴥷ʱ*/ + UINT8 detainBtnErrorFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; /*۳ťϱ־*/ + + wSignalIdIndex = GetSignalConfigBufIndex(signalId); + + if (SIGNAL_SUM_MAX > wSignalIdIndex) + { + cancelDetainBtnRelayId = GetSignalCancelDetainBtnRelayId(signalId); + localCiId = GetSystemParaLocalCiId(); + cancelDetainRelayBelongCiId = GetRelayBelongCiId(cancelDetainBtnRelayId); + + if ((0U != cancelDetainBtnRelayId) && (UINT16_MAX != cancelDetainBtnRelayId) && (localCiId == cancelDetainRelayBelongCiId) && (0U != localCiId)) + { + /***** 1.ȡ۳ť/󴥷ںͲɼ̵״̬ *****/ + DetZfsCancelBtnPressStateProc(signalId, cancelDetainBtnRelayId); + + /***** 2.ȡ۳ťЧ־ *****/ + DetZfsCancelBtnActFlagProc(signalId, cancelDetainBtnRelayId); + + /***** 3.۳ť־ȡ۳ťЧ־ *****/ + cancelDetainBtnValidFlag = GetCancelDetainBtnValidFlag(signalId); + cancelDetainBtnPressCycNum = GetCancelDetainBtnPressCycNum(signalId); + zfsBtnRelayCollCycNum = GetSelfButCollCount(); + btnPressValidTime = SystemOverTimeCheck(cancelDetainBtnPressCycNum, zfsBtnRelayCollCycNum); /*жȡťʱǷﵽЧʱ*/ + zfsBtnRelayFaultCycNum = GetSelfCancelButErrCount(); + btnPressFaultTime = SystemOverTimeCheck(cancelDetainBtnPressCycNum, zfsBtnRelayFaultCycNum); /*жȡťʱǷﵽʱ*/ + detainBtnErrorFlag = GetSignalDetainBtnErrFlag(signalId); /*ȡ۳ťϱ־*/ + + if ((SIGNAL_CANCEL_DETAIN_VALID_YES == cancelDetainBtnValidFlag) && (CI_TIME_OUT == btnPressValidTime) && (CI_TIME_OUT != btnPressFaultTime)) + { + /*ȡ۳ťЧҰťʱﵽжϲɼЧʱδﵽжʱ䣬ÿ۳ť־Чȡ۳ťЧ*/ + SetSignalDetainBtnActFlag(signalId, SIGNAL_ZFS_BTN_ACT_FLAG_NO); + SetCancelDetainBtnValidFlag(signalId, SIGNAL_CANCEL_DETAIN_VALID_NO); + } + else if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO != detainBtnErrorFlag) && ((CI_TIME_OUT != btnPressValidTime) || (CI_TIME_OUT == btnPressFaultTime))) + { + /*۳ťңȡ۳ťʱδﵽжϲɼЧʱﵽжʱ䣩ÿ۳ť־Ч*/ + SetSignalDetainBtnActFlag(signalId, SIGNAL_ZFS_BTN_ACT_FLAG_YES); + } + else + { + /**/ + } + + /***** 4.ȡ۳ťϱ־ *****/ + cancelDetErrTrigPressCycNum = GetCancelDetErrTrigPressCycNum(signalId); + zfsBtnRelayErrTrigCycNum = GetSelfCancelButErrTriggerCount(); + btnPressErrTrigTime = SystemOverTimeCheck(cancelDetErrTrigPressCycNum, zfsBtnRelayErrTrigCycNum); /*жȡť󴥷ʱǷﵽ󴥷ʱ*/ + + if ((CI_TIME_OUT == btnPressFaultTime) || (CI_TIME_OUT == btnPressErrTrigTime)) + { + /*ȡ۳ťʱﵽжϹЧʱȡ۳ť󴥷ʱﵽж󴥷Чʱ䣬ȡ۳ťϱ־Ч*/ + SetSignalCancelDetainBtnErrFlag(signalId, SIGNAL_ZFS_BTN_ERR_FLAG_YES); + } + else + { + SetSignalCancelDetainBtnErrFlag(signalId, SIGNAL_ZFS_BTN_ERR_FLAG_NO); + } + } + else + { + /*̵ID/DZ*/ + } + } + else + { + /*ηǷ*/ + } +} + +/* +* Ըʽȡ۳ť״̬ +* ˵ const UINT16 wSignalId źŻID +* const UINT16 wCancelDetBtnRelayId ȡ۳ťɼ̵ID +* ֵ +* Created By LQ 2024.05.09 +*/ +void DetZfsCancelBtnPressStateProc(const UINT16 wSignalId, const UINT16 wCancelDetBtnRelayId) +{ + UINT16 wSignalIdIndex = 0U; /*źŻ±*/ + UINT16 wRelayIdIndex = 0U; /*̵±*/ + UINT8 cCancelDetRelayCollState = 0U; /*ȡ۳ťɼ̵״̬*/ + UINT8 cDetainBtnActFlag = SIGNAL_ZFS_BTN_ACT_FLAG_NO; /*۳ť־*/ + UINT8 cCancelDetRelayDownState = SIGNAL_RELAY_ERROR_DOWN_YES; /*ȡ۳ťɼ̵״̬*/ + UINT32 dwCancelDetBtnPressCycNum = 0U; /*ȡ۳ť*/ + UINT32 dwCancelDetErrTrigPressCycNum = 0U; /*ȡ۳ť󴥷*/ + UINT32 dwCurCycNum = 0U; /*ǰ*/ + UINT16 wRelayBelongOcId = 0U; /*̵OC*/ + UINT8 cOcCommState = TRANSMIT_STATE_BAD; /*OCͨ״̬*/ + UINT8 cABoardState = RELAY_BOARD_FAULT_YES; /*Aϵ忨״̬*/ + UINT8 cBBoardState = RELAY_BOARD_FAULT_YES; /*Bϵ忨״̬*/ + + wSignalIdIndex = GetSignalConfigBufIndex(wSignalId); + wRelayIdIndex = GetRelayConfigBufIndex(wCancelDetBtnRelayId); + + if ((SIGNAL_SUM_MAX > wSignalIdIndex) && ( RELAY_SUM_MAX > wRelayIdIndex)) + { + cCancelDetRelayCollState = GetRelayCollState(wCancelDetBtnRelayId); /*ȡȡ۳ť̵1ɼ״̬*/ + + if (RELAY_STATE_UP == cCancelDetRelayCollState) + { + /** ̵𣬸ȡ۳ť/󴥷 **/ + cDetainBtnActFlag = GetSignalDetainBtnActFlag(wSignalId); + cCancelDetRelayDownState = GetCancelDetainRelayDownState(wSignalId); /*ȡȡ۳ťɼ̵״̬*/ + dwCancelDetBtnPressCycNum = GetCancelDetainBtnPressCycNum(wSignalId); /*ȡȡ۳ťʱ*/ + dwCancelDetErrTrigPressCycNum = GetCancelDetErrTrigPressCycNum(wSignalId); /*ȡȡ۳ť󴥷ʱ*/ + dwCurCycNum = Get2oo2CurCycleNum(); + + if ((SIGNAL_ZFS_BTN_ACT_FLAG_YES == cDetainBtnActFlag) && (SIGNAL_RELAY_ERROR_DOWN_NO == cCancelDetRelayDownState)) + { + /** ۳ť־Чȡ۳ťɼ̵״̬Ϊ£OCͨҴһϵ忨״̬ȡ۳ťʱ **/ + if ((0U == dwCancelDetBtnPressCycNum) && (0U == dwCancelDetErrTrigPressCycNum)) + { + SetCancelDetainBtnPressCycNum(wSignalId, dwCurCycNum); /*ȡ۳ťʱΪڣ󴥷²ͬʱڣ*/ + } + else + { + /**/ + } + } + else + { + /** ۳ť־Чȡ۳ťɼ̵״̬£OCͨжϻϵ忨״̬ϣȡ۳ť󴥷ʱ **/ + if ((0U == dwCancelDetBtnPressCycNum) && (0U == dwCancelDetErrTrigPressCycNum)) + { + SetCancelDetErrTrigPressCycNum(wSignalId, dwCurCycNum); /*ȡ۳ť󴥷ʱΪڣ󴥷²ͬʱڣ*/ + } + else + { + /**/ + } + } + } + else + { + /** ̵£ȡ۳ťɼ̵״̬ **/ + wRelayBelongOcId = GetRelayBelongOCId(wCancelDetBtnRelayId); + cOcCommState = GetCiTransmitState(CI_SYSTEM_TYPE_OC, (UINT8)wRelayBelongOcId); /*ȡOCͨ״̬*/ + cABoardState = GetRelayACollBoardState(wCancelDetBtnRelayId); /*ȡAϵ忨״̬*/ + cBBoardState = GetRelayBCollBoardState(wCancelDetBtnRelayId); /*ȡBϵ忨״̬*/ + + if ((TRANSMIT_STATE_GOOD == cOcCommState) && ((RELAY_BOARD_FAULT_NO == cABoardState) || (RELAY_BOARD_FAULT_NO == cBBoardState))) + { + /*OCͨһϵ忨״̬ü̵*/ + SetCancelDetainRelayDownState(wSignalId, SIGNAL_RELAY_ERROR_DOWN_NO); + } + else + { + /*OCͨ쳣ϵ忨״̬ϣü̵ͨ쳣*/ + SetCancelDetainRelayDownState(wSignalId, SIGNAL_RELAY_ERROR_DOWN_YES); + } + + /** ̵£ȡ۳ťں󴥷 **/ + SetCancelDetainBtnPressCycNum(wSignalId, 0U); + SetCancelDetErrTrigPressCycNum(wSignalId, 0U); + } + } + else + { + /*ηǷ*/ + } +} + +/* +* Ըʽȡ۳ť־ +* ˵ const UINT16 wSignalId źŻID +* const UINT16 wCancelDetBtnRelayId ȡ۳ťɼ̵ID +* ֵ +* Created By LQ 2024.05.09 +*/ +void DetZfsCancelBtnActFlagProc(const UINT16 wSignalId, const UINT16 wCancelDetBtnRelayId) +{ + UINT16 wSignalIdIndex = 0U; /*źŻ±*/ + UINT16 wRelayIdIndex = 0U; /*̵±*/ + UINT8 cDetainBtnActFlag = SIGNAL_ZFS_BTN_ACT_FLAG_NO; /*۳ť־*/ + UINT8 cDetainValidFlag = 0U; /*Ӳ߿۳Ч־*/ + UINT16 wDetainBtnRelayId = 0U; /*۳ťɼ̵ID*/ + UINT8 cDetainRelayCollState = 0U; /*۳ťɼ̵״̬*/ + UINT8 cDetainBtnErrorFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; /*۳ťϱ־*/ + UINT8 cCancelDetRelayCollState = 0U; /*ȡ۳ťɼ̵״̬*/ + UINT8 cCancelDetRelayDownState = SIGNAL_RELAY_ERROR_DOWN_YES; /*ȡ۳ťɼ̵״̬*/ + + wSignalIdIndex = GetSignalConfigBufIndex(wSignalId); + wRelayIdIndex = GetRelayConfigBufIndex(wCancelDetBtnRelayId); + + if ((SIGNAL_SUM_MAX > wSignalIdIndex) && (RELAY_SUM_MAX > wRelayIdIndex)) + { + cDetainBtnActFlag = GetSignalDetainBtnActFlag(wSignalId); /*ȡ۳ť־*/ + cDetainValidFlag = GetCiFunctionSwitchConfig(FUNC_RELAY_DETAIN_VALID_FLAG); /*ȡӰ۳Ч־*/ + wDetainBtnRelayId = GetSignalDetainRelayId(wSignalId); + cDetainRelayCollState = GetRelayCollState(wDetainBtnRelayId); /*ȡ۳ťɼ̵״̬*/ + cDetainBtnErrorFlag = GetSignalDetainBtnErrFlag(wSignalId); + cCancelDetRelayCollState = GetRelayCollState(wCancelDetBtnRelayId); /*ȡȡ۳ťɼ̵״̬*/ + cCancelDetRelayDownState = GetCancelDetainRelayDownState(wSignalId); /*ȡȡ۳ťɼ̵״̬*/ + + if ((SIGNAL_ZFS_BTN_ACT_FLAG_YES == cDetainBtnActFlag) && (((DOWN_VALID == cDetainValidFlag) && (RELAY_STATE_UP == cDetainRelayCollState)) + || ((UP_VALID == cDetainValidFlag) && (RELAY_STATE_DOWN == cDetainRelayCollState)) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == cDetainBtnErrorFlag)) + && (RELAY_STATE_DOWN == cCancelDetRelayCollState) && (SIGNAL_RELAY_ERROR_DOWN_NO == cCancelDetRelayDownState)) + { + /*۳ťЧ(۳ţ̌)ȡ۳ťɼ̵Ϊ£ȡ۳ťЧ*/ + SetCancelDetainBtnValidFlag(wSignalId, SIGNAL_CANCEL_DETAIN_VALID_YES); + } + else if (((((DOWN_VALID == cDetainValidFlag) && (RELAY_STATE_UP != cDetainRelayCollState)) + || ((UP_VALID == cDetainValidFlag) && (RELAY_STATE_DOWN != cDetainRelayCollState))) + && (SIGNAL_ZFS_BTN_ERR_FLAG_YES != cDetainBtnErrorFlag)) || (SIGNAL_RELAY_ERROR_DOWN_NO != cCancelDetRelayDownState)) + { + /*۳ťδ̧δϣȡ۳ťɼ̵£ȡ۳ťЧ*/ + SetCancelDetainBtnValidFlag(wSignalId, SIGNAL_CANCEL_DETAIN_VALID_NO); + } + else + { + /**/ + } + } + else + { + /*ηǷ*/ + } +} + +/******************************OC spksָʾ****************************/ +/* +* OC spksָʾƺspks·ָʾ +* ˵ void +* ֵ void +*/ +void SpksDisplayDrivOutput(void) +{ + UINT16 spksCurSum = 0u; /*spksǰĿĬΪÿspksָʾ*/ + UINT16 spksCollId = 0u; /*spksɼ̵ ID*/ + UINT8 tmpCollRelayColState = 0u; /*spksɼ̵״̬*/ + UINT8 tmpCutRelayColState = 0u; /*spks·̵״̬*/ + UINT16 spksDisplayId = 0u; /*spksָʾƼ̵ID*/ + UINT16 spksId = 0u; /*spks ID*/ + UINT16 cutSpksId = 0u; /*spks·ť̵ ID*/ + UINT16 cutSpksDisplayId = 0u; /*spks·ָʾƼ̵ID*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 chLocalCiId = 0u; /*ID*/ + UINT8 devBlongCiId = 0u; /*豸ID*/ + UINT32 spksflockStartNum = 0u; + UINT32 dwSpksIndicDelayCount = 0u; + UINT8 checkCycOut = 0u; + + spksCurSum = GetSpksSum(); /*ȡspksĬΪÿspksжӦָʾ*/ + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + /*ȴspksϽĻָʾƣSPKSSPKSʾ״̬*/ + for(ii = 0u; ii < spksCurSum; ii++) + { + spksId = GetSpksIdByIndex(ii); /*ȡspks ID*/ + devBlongCiId = GetSpksBelongCiId(spksId); /*ȡ豸ID*/ + if(chLocalCiId == devBlongCiId) + { + TotalSpksOutsideDisPlayProc(spksId);/*spksϽspksָʾ*/ + } + } + + for (ii = 0u; ii < spksCurSum; ii++) + { + spksId = GetSpksIdByIndex(ii); /*ȡspks ID*/ + + spksCollId = GetSpksColRelayId(spksId); /*ȡspksɼ̵ID*/ + tmpCollRelayColState = GetRelayCollState(spksCollId);/*ȡspksɼ̵״̬*/ + spksDisplayId = GetSpksDisRelayId(spksId); /*spks IDȡspksָʾID*/ + + cutSpksId = GetSpksCutRelayId(spksId); /*ȡspks·ť̵ID*/ + cutSpksDisplayId = GetSpksCutDisRelayId(spksId); /*spks IDȡspks·ָʾID*/ + + devBlongCiId = GetSpksBelongCiId(spksId); /*ȡ豸ID*/ + + if ((0u != cutSpksId) && (UINT16_MAX != cutSpksId)) + { + tmpCutRelayColState = GetRelayCollState(cutSpksId);/*ȡspks·ť̵״̬*/ + } + else + { + /*spksûspks·ť̵*/ + } + if (chLocalCiId == devBlongCiId) /*ֻ*/ + { + /*spksָʾ*/ + if ((0u != spksDisplayId) && (UINT16_MAX != spksDisplayId)) + {/*spksָʾƼ̵Ч*/ + if (RELAY_STATE_DOWN == tmpCollRelayColState) + { + /*SPKS̵ºʱ*/ + spksflockStartNum = GetSpksflockStartNum(spksId);/*ȡSPKSʼ*/ + dwSpksIndicDelayCount = GetSpksIndicDelayCount();/*ȡʱ*/ + checkCycOut = SystemOverTimeCheck(spksflockStartNum,dwSpksIndicDelayCount); + if(CI_TIME_OUT == checkCycOut)/*ʱ*/ + { + (void)SetRelayDriveState(spksDisplayId, RELAY_STATE_UP); /*ָʾ*/ + } + else + { + (void)SetRelayDriveState(spksDisplayId,RELAY_STATE_DOWN); /*ָʾ*/ + } + } + else if (RELAY_STATE_UP == tmpCollRelayColState) + { + (void)SetRelayDriveState(spksDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + else + { + (void)SetRelayDriveState(spksDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + else + { + /*spksûָʾƼ̵*/ + } + + /*spks·ָʾ*/ + if ((0u != cutSpksDisplayId) && (UINT16_MAX != cutSpksDisplayId)) + {/*spks·ťЧ·ťָʾƼ̵Ч*/ + if (RELAY_STATE_UP == tmpCutRelayColState) + { + (void)SetRelayDriveState(cutSpksDisplayId, RELAY_STATE_UP); /*ָʾ*/ + } + else if (RELAY_STATE_DOWN == tmpCutRelayColState) + { + (void)SetRelayDriveState(cutSpksDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + else + { + (void)SetRelayDriveState(cutSpksDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + else + { + /*spksû·ťû·ťָʾƼ̵*/ + } + /*spksָʾ*/ + spksflockStartNum = GetSpksflockStartNum(spksId); + SpksOutsideDisPlayDriv(spksId,spksflockStartNum); + } + else + { + /*DZ豸*/ + } + SetDriveOutDisFlag(spksId,TOTALSPKSDRIVE_INVALID); + } +} + + +/***********************OC SPKSŽ̵****************************/ +/* +* OC spksŽ +* ˵ void +* ֵ void +*/ +void SpksMenjinJSDrivOutput(void) +{ + UINT16 mjjsCurSum = 0U; /*Ž̵*/ + UINT16 curspksId = 0U; /*spks ID*/ + UINT16 mjjsRalayId = 0U; /*Ž̵ ID*/ + UINT16 ii = 0U; /*ѭ*/ + UINT16 jj = 0U; /*ѭ*/ + UINT8 currelSpkscount = 0U; /*ǰŽ̵ӦSPKS*/ + UINT8 checkflag = 0U; + UINT8 chRtn = CI_ERROR; + UINT8 chBelongCIId = 0u; + UINT16 chMJId = 0u; + UINT8 localCIId = 0u; + + localCIId = GetSystemParaLocalCiId(); + /*ȡǰŽ̵*/ + mjjsCurSum = GetMjjsSum(); + + /*Ž̵*/ + for (ii = 0u; ii < mjjsCurSum; ii++) + { + chMJId = GetMJIdByIndex(ii); + chBelongCIId = GetMjBelongCIID(chMJId); + + /*ֻŽ*/ + if (chBelongCIId == localCIId) + { + checkflag = 0u; /*жϱ־ʼ*/ + mjjsRalayId = GetMjjsRelayId(chMJId); /*ȡӦŽ̵ID*/ + currelSpkscount = GetSpksCountByMjID(chMJId); + /*Ž̵Ч*/ + if ((0u != mjjsRalayId) && (UINT16_MAX != mjjsRalayId)) + { + /*Ž̵SPKS*/ + for (jj = 0u; jj < currelSpkscount; jj++) + { + + curspksId = GetSpksIdByMjjsIndex(chMJId, jj); /*ȡӦSPKSID*/ + /*ǷڼSPKS*/ + checkflag |= MJrelSpksMJStateProcess(curspksId); + } + /*SPKSѼ*/ + if (1u == checkflag) + { + chRtn = SetRelayDriveState(mjjsRalayId, RELAY_STATE_UP); /*Ž̵*/ + if (CI_ERROR == chRtn) + { + ; /*ü̵״̬ʧ*/ + } + } + else + { + chRtn = SetRelayDriveState(mjjsRalayId, RELAY_STATE_DOWN); /*Ž̵*/ + if (CI_ERROR == chRtn) + { + ; /*ü̵״̬ʧ*/ + } + } + } + else + { + } + } + } +} + +/* +* ŽspksǷ񼤻߼ж +* ˵ void +* ֵ CI_SUCCESS +* CI_ERROR δ +*/ +UINT8 MJrelSpksMJStateProcess(UINT16 spksId) +{ + UINT8 spksState = 0U; /*spks״̬*/ + UINT8 spksCutState = 0U; /*spks·״̬*/ + UINT8 chLocalCiId = 0U; /*ID*/ + UINT8 devBlongCiId = 0U; /*豸ID*/ + + UINT32 spksflockStartNum = 0U; /*SPKSʼ*/ + UINT32 mjjsDelayCount = 0U; /*Žʱ*/ + UINT8 checkCycOut = 0U; /*ʱж*/ + UINT8 retval = CI_ERROR; + + + /*ȡID*/ + chLocalCiId = GetSystemParaLocalCiId(); + /*ȡSPKSť״̬*/ + spksState = GetSpksState(spksId); + /*ȡSPKS·ť״̬*/ + spksCutState = GetSpksCutState(spksId); + + /*жSPKSǷ񼤻*/ + if ((SPKS_STATUS_YES == spksState) && (SPKS_CUT_NO == spksCutState)) + { + devBlongCiId = GetSpksBelongCiId(spksId); /*ȡ豸ID*/ + if (chLocalCiId == devBlongCiId) /*ֻ*/ + { + /*ӳʱж*/ + spksflockStartNum = GetSpksflockStartNum(spksId);/*ȡSPKSʼ*/ + mjjsDelayCount = GetMjjsOpenDelayCount();/*ȡŽʱ*/ + checkCycOut = SystemOverTimeCheck(spksflockStartNum, mjjsDelayCount); + if (CI_TIME_OUT == checkCycOut)/*ʱ*/ + { + retval = CI_SUCCESS; + + } + else + { + /*δ*/ + } + } + else + { + /*DZ*/ + } + } + else + { + /*ʧ*/ + } + + return retval; +} + + +/******************************OC esbָʾ****************************/ +/* +* OC esbָʾƺesb·ָʾ +* ˵ void +* ֵ void +*/ +void EsbDisplayDrivOutput(void) +{ + UINT16 esbCurSum = 0u; /*esbǰĿĬΪÿesbָʾ*/ + UINT16 esbCollId = 0u; /*esbɼ̵ ID*/ + UINT8 tmpCollRelayColState = 0u; /*esbɼ̵״̬*/ + UINT8 tmpCutRelayColState = 0u; /*esb·̵״̬*/ + UINT16 esbDisplayRelayId = 0u; /*esbָʾƼ̵ID*/ + UINT16 esbPlatformDisRelayId = 0U; /*esbվָ̨ʾƼ̵ID*/ + UINT16 cutEsbId = 0u; /*esb·ť̵ ID*/ + UINT16 cutEsbDisplayId = 0u; /*esb·ָʾƼ̵ID*/ + UINT8 chLocalCiId = 0u; /*ID*/ + UINT16 esbId = 0u; /*esb ID*/ + UINT8 devBlongCiId = 0u; /*豸ID*/ + UINT16 ii = 0u; /*ѭ*/ + + UINT8 esbState = ESB_STATE_VALID_NO; /*ر״̬*/ + UINT8 funcswitchZfsBtn = 0U; /*Ըʽť*/ + + esbCurSum = GetEsbSum(); /*ȡesbĬΪÿesbжӦָʾ*/ + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + funcswitchZfsBtn = GetCiFunctionSwitchConfig(FUNC_ZIFUSHI_BUTTON); + + for (ii = 0u; ii < esbCurSum; ii++) + { + esbId = GetEsbId(ii); /*ȡesb ID*/ + esbCollId = GetEsbRelayId(esbId); /*ȡesbɼ̵ID*/ + tmpCollRelayColState = GetRelayCollState(esbCollId);/*ȡesbɼ̵״̬*/ + esbDisplayRelayId = GetEsbDisRelayId(esbId); /*esb IDȡesbָʾID*/ + esbPlatformDisRelayId = GetEsbPlatformDisRelayId(esbId); /*esb IDȡesbվָ̨ʾƼ̵ID*/ + + cutEsbId = GetEsbCutRelayId(esbId); /*ȡesb·ť̵ID*/ + cutEsbDisplayId = GetEsbCutDisRelayId(esbId); /*esb IDȡesb·ָʾID*/ + devBlongCiId = GetEsbBelongCiId(esbId); /*ȡ豸ID*/ + + if ((0u != cutEsbId) && (UINT16_MAX != cutEsbId)) + { + tmpCutRelayColState = GetRelayCollState(cutEsbId);/*ȡesb·ť̵״̬*/ + } + else + { + /*esbûesb·ť̵*/ + } + + if (chLocalCiId == devBlongCiId) /*ֻ*/ + { + if (FUNC_SWITCH_ON == funcswitchZfsBtn) /*ԸʽESBָʾƼ̵*/ + { + esbState = GetEsbState(esbId); + /*ESBָʾ״̬*/ + if ((0u != esbDisplayRelayId) && (UINT16_MAX != esbDisplayRelayId)) + { + if (ESB_STATE_VALID_YES == esbState) + { + (void)SetRelayDriveState(esbDisplayRelayId, RELAY_STATE_UP); /*ESBָʾ*/ + } + else + { + (void)SetRelayDriveState(esbDisplayRelayId, RELAY_STATE_DOWN); /*δESBָʾ*/ + } + } + else + { + /*ûESBָʾƣ*/ + } + + /*ESBվָ̨ʾ״̬*/ + if ((0u != esbPlatformDisRelayId) && (UINT16_MAX != esbPlatformDisRelayId)) + { + /*ESBָʾ״̬*/ + if (ESB_STATE_VALID_YES == esbState) + { + (void)SetRelayDriveState(esbPlatformDisRelayId, RELAY_STATE_UP); /*ESBվָ̨ʾ*/ + } + else + { + (void)SetRelayDriveState(esbPlatformDisRelayId, RELAY_STATE_DOWN); /*δESBվָ̨ʾ*/ + } + } + else + { + /*ûESBվָ̨ʾƣ*/ + } + } + else + { + /*ԸʽesbָʾƼ̵*/ + if ((0u != esbDisplayRelayId) && (UINT16_MAX != esbDisplayRelayId)) + { + /*esbָʾƼ̵Ч*/ + if (RELAY_STATE_DOWN == tmpCollRelayColState) + { + (void)SetRelayDriveState(esbDisplayRelayId, RELAY_STATE_UP); /*ָʾ*/ + } + else if (RELAY_STATE_UP == tmpCollRelayColState) + { + (void)SetRelayDriveState(esbDisplayRelayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + else + { + (void)SetRelayDriveState(esbDisplayRelayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + else + { + /*esbťûָʾƼ̵*/ + } + + /*ESBվָ̨ʾ״̬̫ԭ1Ŀ*/ + if ((0u != esbPlatformDisRelayId) && (UINT16_MAX != esbPlatformDisRelayId)) + { + /*ESBָʾ״̬*/ + if (RELAY_STATE_DOWN == tmpCollRelayColState) + { + (void)SetRelayDriveState(esbPlatformDisRelayId, RELAY_STATE_UP); /*ָʾ*/ + } + else if (RELAY_STATE_UP == tmpCollRelayColState) + { + (void)SetRelayDriveState(esbPlatformDisRelayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + else + { + (void)SetRelayDriveState(esbPlatformDisRelayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + else + { + /*ûESBվָ̨ʾƣ*/ + } + + if ((0u != cutEsbDisplayId) && (UINT16_MAX != cutEsbDisplayId)) + {/*esb·ť·ťָʾƼ̵Ч*/ + if (RELAY_STATE_UP == tmpCutRelayColState) + { + (void)SetRelayDriveState(cutEsbDisplayId, RELAY_STATE_UP); /*ָʾ*/ + } + else if (RELAY_STATE_DOWN == tmpCutRelayColState) + { + (void)SetRelayDriveState(cutEsbDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + else + { + (void)SetRelayDriveState(cutEsbDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + else + { + /*esbû·ťû·ťָʾƼ̵*/ + } + } + } + else + { + /*DZ豸*/ + } + } +} + + + +/******************************OC ۳·ָʾ****************************/ +/* +* OC ۳Ϳ۳·ָʾ +* ˵ void +* ֵ void +*/ +void DetainDisplayDrivOutput(void) +{ + UINT16 signalCurSum = 0u; /*۳·ָʾƵǰĿ*/ + UINT16 signalDetainRelayId = 0u; /*۳ť̵ ID*/ + UINT16 signalCutDetainRelayId = 0u; /*۳·ť̵ ID*/ + UINT16 cutDetainDisplayId = 0u; /*۳·ָʾƼ̵ID*/ + UINT16 signalDetainDisplayId = 0u; /*۳ָʾƼ̵ID*/ + UINT8 localCiId = 0u; /*ID*/ + UINT16 signalId = 0u; /*źŻ ID*/ + UINT8 devBlongCiId = 0u; /*豸ID*/ + UINT8 cutRelayBelongCi = 0u; + UINT8 cutBsRelayBelongCi = 0u; + UINT8 detainRelayBelongCi = 0u; + UINT8 detainBsRelayBelongCi = 0u; + UINT16 ii = 0u; /*ѭ*/ + + UINT16 signalDetainRelayId_2 = 0u; /*۳ť̵2 ID */ + UINT16 signalCutDetainRelayId_2 = 0u; /*۳·ť̵2 ID*/ + UINT16 cutDetainDisplayId_2 = 0u; /*۳·ָʾƼ̵2 ID*/ + UINT16 signalDetainDisplayId_2 = 0u; /*۳ָʾƼ̵2 ID*/ + + UINT8 cutRelay_2BelongCi = 0u; + UINT8 cutBsRelay_2BelongCi = 0u; + UINT8 detainRelay_2BelongCi = 0u; + UINT8 detainBsRelay_2BelongCi = 0u; + + UINT8 funcswitchZfsBtn = 0U; /*Ըʽť*/ + + signalCurSum = GetTotalSignalCurNum(); /*ȡźŻ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + funcswitchZfsBtn = GetCiFunctionSwitchConfig(FUNC_ZIFUSHI_BUTTON); + + for (ii = 0u; ii < signalCurSum; ii++) + { + signalId = GetSignalId(ii); + signalCutDetainRelayId = GetSignalDetainCutRelayId(signalId); /*ȡ۳·ť̵ID*/ + cutDetainDisplayId = GetSignalDetainCutDisRelayId(signalId); /*ݿ۳̵IDȡ۳ָʾID*/ + + signalDetainDisplayId = GetSignalDetainDisRelayId(signalId); + signalDetainRelayId = GetSignalDetainRelayId(signalId); + + signalDetainRelayId_2 = GetSignalDetainRelayId_2(signalId); + signalCutDetainRelayId_2 = GetSignalDetainCutRelayId_2(signalId); + cutDetainDisplayId_2 = GetSignalDetainCutDisRelayId_2(signalId); + signalDetainDisplayId_2 = GetSignalDetainDisRelayId_2(signalId); + + devBlongCiId = GetSignalBelongCiId(signalId); /*ȡ豸ID*/ + if (localCiId == devBlongCiId) /*ֻ*/ + { + if (FUNC_SWITCH_ON != funcswitchZfsBtn) + { + /*Ըʽ۳ťʾƴ*/ + DriveDetainBsRelay(signalId, signalCutDetainRelayId, cutDetainDisplayId, signalDetainRelayId, signalDetainDisplayId); + DriveDetainBsRelay(signalId, signalCutDetainRelayId_2, cutDetainDisplayId_2, signalDetainRelayId_2, signalDetainDisplayId_2); + } + else + { + /*Ըʽ۳ťʾƴ*/ + DriveZfsDetainBsRelay(signalId, signalDetainDisplayId); + } + } + else + { + if (FUNC_SWITCH_ON != funcswitchZfsBtn)/*Ըʽ۳ťʾƴ*/ + { + /*ȡ̵*/ + detainRelayBelongCi = GetRelayBelongCiId(signalDetainRelayId); /*۳̵CI*/ + detainBsRelayBelongCi = GetRelayBelongCiId(signalDetainDisplayId); /*۳ʾCI*/ + detainRelay_2BelongCi = GetRelayBelongCiId(signalDetainRelayId_2); + detainBsRelay_2BelongCi = GetRelayBelongCiId(signalDetainDisplayId_2); + cutRelayBelongCi = GetRelayBelongCiId(signalCutDetainRelayId); /*۳·CI*/ + cutBsRelayBelongCi = GetRelayBelongCiId(cutDetainDisplayId); /*۳·ʾCI*/ + /*м̵ڱ*/ + if ((cutRelayBelongCi == localCiId) && (cutBsRelayBelongCi == localCiId) && + (detainRelayBelongCi == localCiId) && (detainBsRelayBelongCi == localCiId)) + { + /*ʾƴ*/ + DriveDetainBsRelay(signalId, signalCutDetainRelayId, cutDetainDisplayId, signalDetainRelayId, signalDetainDisplayId); + } + + cutRelay_2BelongCi = GetRelayBelongCiId(signalCutDetainRelayId_2); + cutBsRelay_2BelongCi = GetRelayBelongCiId(cutDetainDisplayId_2); + /*м̵ڱ*/ + if ((cutRelay_2BelongCi == localCiId) && (cutBsRelay_2BelongCi == localCiId) && + (detainRelay_2BelongCi == localCiId) && (detainBsRelay_2BelongCi == localCiId)) + { + /*ʾƴ*/ + DriveDetainBsRelay(signalId, signalCutDetainRelayId_2, cutDetainDisplayId_2, signalDetainRelayId_2, signalDetainDisplayId_2); + } + } + else + { + /*Ըʽ۳ťʾƴ*/ + DriveZfsDetainBsRelay(signalId, signalDetainDisplayId); + } + } + } +} + +/* +* ۳ָʾơ۳·ָʾ +* ˵const UINT16 signalCutDetainRelayId, ۳·̵ID +* const UINT16 cutDetainDisplayId, ۳·ʾƼ̵ID +* const UINT16 signalDetainRelayId, ۳̵ID +* const UINT16 signalDetainDisplayId, ۳ʾƼ̵ID +* const UINT16 signalId, źŻID +* +* ֵ +* +*/ +void DriveDetainBsRelay(const UINT16 signalId, const UINT16 signalCutDetainRelayId, const UINT16 cutDetainDisplayId, const UINT16 signalDetainRelayId, const UINT16 signalDetainDisplayId) +{ + /*ʼ*/ + UINT8 tmpCutRelayColState = 0u; /*·̵ɼ״̬*/ + UINT8 tmpCollRelayColState = 0u; /*۳̵ɼ*/ + UINT8 relayDetainValidFlag = 0u; + UINT8 signalDetainFlag = 0u; /*źŻ۳־*/ + UINT8 relayDrivState = 0u; /*̵״̬*/ + + /*Ӳ߿۳·ťָʾƼ̵*/ + if ((0u != signalCutDetainRelayId) && (UINT16_MAX != signalCutDetainRelayId) && (0u != cutDetainDisplayId) && (UINT16_MAX != cutDetainDisplayId)) + {/*Ӳ߿۳·̵Ϳ۳·ťָʾƼ̵Ч*/ + tmpCutRelayColState = GetRelayCollState(signalCutDetainRelayId);/*ȡ۳·ť̵״̬*/ + if (RELAY_STATE_UP == tmpCutRelayColState) + { + (void)SetRelayDriveState(cutDetainDisplayId, RELAY_STATE_UP); /*ָʾ*/ + } + else if (RELAY_STATE_DOWN == tmpCutRelayColState) + { + (void)SetRelayDriveState(cutDetainDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + else + { + (void)SetRelayDriveState(cutDetainDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + else + { + /*źŻûп۳·ťûп۳·ťָʾƣ*/ + } + + /*Ӳ߿۳ťָʾƼ̵*/ + if ((0u != signalDetainRelayId) && (UINT16_MAX != signalDetainRelayId) && (0u != signalDetainDisplayId) && (UINT16_MAX != signalDetainDisplayId)) + {/*Ӳ߿۳̵Ϳ۳ťָʾƼ̵Ч*/ + + relayDetainValidFlag = GetCiFunctionSwitchConfig(FUNC_RELAY_DETAIN_VALID_FLAG);/*ȡӲ߿۳Ч־*/ + tmpCollRelayColState = GetRelayCollState(signalDetainRelayId);/*ȡ۳̵ɼ״̬*/ + signalDetainFlag = GetSignalDetainFlag(signalId); /*ȡźŻ۳־*/ + relayDrivState = GetRelayDriveState(signalDetainDisplayId); /*ȡ۳ָʾƼ̵״̬*/ + if (((UP_VALID == relayDetainValidFlag) && (RELAY_DRIVE_STATE_UP == tmpCollRelayColState)) + || ((DOWN_VALID == relayDetainValidFlag) && (RELAY_DRIVE_STATE_DOWN == tmpCollRelayColState))) /*̵,۳*/ + { + (void)SetRelayDriveState(signalDetainDisplayId, RELAY_STATE_UP); /*ָʾ*/ + } + else if (((UP_VALID == relayDetainValidFlag) && (RELAY_DRIVE_STATE_DOWN == tmpCollRelayColState)) + || ((DOWN_VALID == relayDetainValidFlag) && (RELAY_DRIVE_STATE_UP == tmpCollRelayColState))) /*̵,δ۳*/ + { + if ((SIGNAL_DETAIN_YES == signalDetainFlag) || (SIGNAL_DETAIN_XIANDI_ATSAUTO == signalDetainFlag) || (SIGNAL_DETAIN_ATS == signalDetainFlag) || (SIGNAL_DETAIN_ATS_AUTO == signalDetainFlag) || (SIGNAL_DETAIN_XIANDI == signalDetainFlag)) + { + /*۳ҲҪָʾ*/ + (void)SetRelayDriveState(signalDetainDisplayId, RELAY_STATE_UP); /*ָʾ*/ + } + else + { + /*̵û*/ + if (RELAY_DRIVE_STATE_NULL == relayDrivState) + { + /*Ӳ߿۳۳δʵʩָʾ*/ + (void)SetRelayDriveState(signalDetainDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + } + else /*̵״̬Ч۳*/ + { + if ((SIGNAL_DETAIN_YES == signalDetainFlag) || (SIGNAL_DETAIN_XIANDI_ATSAUTO == signalDetainFlag) || (SIGNAL_DETAIN_ATS == signalDetainFlag) || (SIGNAL_DETAIN_ATS_AUTO == signalDetainFlag) || (SIGNAL_DETAIN_XIANDI == signalDetainFlag)) + { + /*۳ҲҪָʾ*/ + (void)SetRelayDriveState(signalDetainDisplayId, RELAY_STATE_UP); /*ָʾ*/ + } + else + { + /*̵û*/ + if (RELAY_DRIVE_STATE_NULL == relayDrivState) + { + /*Ӳ߿۳۳δʵʩָʾ*/ + (void)SetRelayDriveState(signalDetainDisplayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + } + } + else + { + /*źŻûп۳ťûп۳ťָʾƣ*/ + } +} + +/* +* Ըʽ۳ָʾ +* ˵const UINT16 signalId, źŻID +* const UINT16 signalDetainDisplayId, ۳ʾƼ̵1ID +* ֵ +* +*/ +void DriveZfsDetainBsRelay(const UINT16 signalId, const UINT16 signalDetainDisplayId) +{ + UINT8 localCiId = 0U; /*ID*/ + UINT8 detainBsRelayBelongCi = 0u; /*۳ʾƼ̵CI*/ + UINT8 detainBtnActFlag = SIGNAL_ZFS_BTN_ACT_FLAG_NO; /*۳ť1־*/ + + localCiId = GetSystemParaLocalCiId(); + detainBsRelayBelongCi = GetRelayBelongCiId(signalDetainDisplayId); + + /*Ӳ߿۳ťָʾ1̵*/ + if ((0u != signalDetainDisplayId) && (UINT16_MAX != signalDetainDisplayId) && (0U != localCiId) && (localCiId == detainBsRelayBelongCi)) + { + /*ȡԸʽ۳ť1־*/ + detainBtnActFlag = GetSignalDetainBtnActFlag(signalId); + + /*ÿ۳ָʾ1״̬*/ + if (SIGNAL_ZFS_BTN_ACT_FLAG_YES == detainBtnActFlag) + { + (void)SetRelayDriveState(signalDetainDisplayId, RELAY_STATE_UP); /*۳ť۳ָʾ*/ + } + else + { + (void)SetRelayDriveState(signalDetainDisplayId, RELAY_STATE_DOWN); /*۳ťδ۳ָʾ*/ + } + } + else + { + /*źŻûп۳ťָʾƣ*/ + } +} + +/* +* ܸλʾ +* ˵ void +* ֵ void +*/ +void PhyZFWBsRelayDriveOutput(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 phyId = 0u; + UINT16 ZFWShowRelayId = 0u; + UINT8 ZFWShowDriState = 0u; + UINT8 ZFWRelayState = 0u; + UINT16 ZFWRelayId = 0u; + UINT16 phyCurSum = 0u; + UINT8 localCiId = 0u; /*ID*/ + UINT8 phyBlongCiId = 0u; /*豸ID*/ + + /**/ + phyCurSum = GetPhySecCurSum(); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + for (i = 0u; i < phyCurSum; i++) + { + /*ID*/ + phyId = GetPhySecId(i); + phyBlongCiId = GetPhySecBelongCiId(phyId); + /*DZ*/ + if (phyBlongCiId == localCiId) + { + /*ȡ̵ID*/ + ZFWRelayId = GetPhySecZFWRelayId(phyId); + ZFWShowRelayId = GetPhySecZFWShowRelayId(phyId); + ZFWRelayState = GetRelayCollState(ZFWRelayId); + /*ܸλʾƴ*/ + if (0u < ZFWShowRelayId) + { + ZFWShowDriState = GetRelayDriveState(ZFWShowRelayId); + /*ܸλ,̵*/ + if (RELAY_STATE_UP == ZFWRelayState) + { + /*ʾ*/ + (void)SetRelayDriveState(ZFWShowRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /*û*/ + if (RELAY_DRIVE_STATE_NULL == ZFWShowDriState) + { + /*ʾ*/ + (void)SetRelayDriveState(ZFWShowRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + } + else + { + /**/ + } + } + } +} + + +/* +* źŻ̵״̬->߼״̬ +* ˵ const UINT32 curCycleNum, ǰں +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +void SignalRelayToDeviceStateProc(void) +{ + UINT16 signalCurSum = 0u; /*źŻĿ*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT8 localCiId = 0u; /*ID*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 signalBelongCi = 0u; /*źŻID*/ + UINT8 signalCurColor = 0u; /*źŻǰʾɫ*/ + UINT8 signalVirtualAttr = 0u;/*źŻ*/ + UINT8 signalPreDrvColor = 0u;/*źŻ֮ǰɫ*/ + UINT16 signalDetainRelayId = 0u;/*źŻӲ߿۳ID*/ + UINT8 tmpRelayColState = 0u;/*̵ɼ״̬*/ + + UINT8 sendLvl = ESEND_LEVEL_ZERO;/*ͼ*/ + UINT8 funcId = EFUNC_SIGNAL_RELAY_TO_DEVICE;/*ID*/ + UINT8 relayDetainValidFlag = 0u;/*Ӳ߿۳־*/ + + UINT16 detainRelayId = 0u;/*۳̵ID*/ + UINT8 relayBelongCIId = 0u;/*̵ID*/ + UINT8 relayCollState = 0u;/*̵ɼ״̬*/ + UINT8 signalType = 0u;/*źŻ*/ + UINT8 signalBlockOpenColor = 0u;/*źŻ󱸿ɫ*/ + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + + UINT16 lxRelayId = 0u; /*гźż̵ID*/ + UINT8 lxRelaySta = RELAY_STATE_DOWN; /*гźż̵״̬*/ + UINT8 lxBelongCi = 0u;/*гźż̵*/ + + signalCurSum = GetTotalSignalCurNum(); /*ȡźŻ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + + /*źŻ*/ + for (ii = 0u; ii < signalCurSum; ii++) + { + signalId = 0u; /*źŻID*/ + signalBelongCi = 0u; /*źŻID*/ + + signalId = GetSignalId(ii); /*ȡźŻID*/ + signalBelongCi = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + signalVirtualAttr = GetSignalVirtualAttr(signalId); /*ȡźŻ*/ + + + if ((0u == signalId) || (signalId > SIGNAL_SUM_MAX) || (localCiId == 0u)) + { + /*źŻidϷ߱IDΪ0u,*/ + } + else if (signalBelongCi == localCiId) + { + /*ȡźŻʾɫ*/ + if (SIGNAL_VIRTUAL_YES == signalVirtualAttr) + {/*źŻǰʾɫΪ֮ǰɫ*/ + signalCurColor = GetSignalPreDriveColor(signalId); + } + else if (SIGNAL_VIRTUAL_NO == signalVirtualAttr) + { + signalCurColor = GetSignalShowColor(signalId); + } + else + { + /*޲*/ + } + + /*źŻЧ*/ + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_NULL); + + if (signalCurColor != SIGNAL_SHOWCOLOUR_INVALID) + {/*ɫЧ*/ + + /*õǰʾɫ*/ + (void)SetSignalCurColor(signalId, signalCurColor); + } + else + {/*ɫЧ*/ + + /*õǰʾɫ*/ + (void)SetSignalCurColor(signalId, signalCurColor); + } + + /*źŻǰǿŵģ֮ǰҲţɫ͵ǰɫͬر*/ + if (GetSignalOpenCloseState(signalCurColor) == SIGNAL_OPEN) + { + signalPreDrvColor = GetSignalPreDriveColor(signalId);/*ȡźŻ֮ǰɫ*/ + /*¼źŲɼ*/ + if (0u == GetSignalCollOpenStartCycNum(signalId)) + { + (void)SetSignalCollOpenStartCycNum(signalId, Get2oo2CurCycleNum()); + } + if ((GetSignalOpenCloseState(signalPreDrvColor) == SIGNAL_OPEN) && (signalPreDrvColor != signalCurColor)) + {/*֮ǰҺ͵ǰɫͬ*/ + if (0u == GetSignalDiffColorOpenStartCyc(signalId)) + { + (void)SetSignalDiffColorOpenStartCyc(signalId, Get2oo2CurCycleNum());/*źŻɫڵǰɫʼ*/ + } + else + { + /*жǷ񳬹*/ + if ((Get2oo2CurCycleNum() - GetSignalDiffColorOpenStartCyc(signalId)) >= SIGNAL_RELAY_ACTION_TIMEMAX) + {/*ʱ*/ + (void)DriveSignalClose(signalId);/*ر*/ + SetErrorData(funcId, CI_DEVICE_TYPE_SIGNAL, signalId, ETYPE_SIG_START_OPEN_STATE, SIGNAL_CLOSE, sendLvl); + (void)SetSignalDiffColorOpenStartCyc(signalId, 0u);/*źŻɫڵǰɫʼ*/ + } + else + { + /*ûгʱ̣*/ + } + } + } + else + { + (void)SetSignalDiffColorOpenStartCyc(signalId, 0u);/*źŻɫڵǰɫʼ*/ + } + } + else + { + (void)SetSignalDiffColorOpenStartCyc(signalId, 0u);/*źŻɫڵǰɫʼ*/ + /*źŲɼ*/ + (void)SetSignalCollOpenStartCycNum(signalId, 0u); + } + + /*人ֻɼʾг̵*/ + SetNoDriveSignalCurColor(signalId); + /*źŻӲ߿۳״̬*/ + signalDetainRelayId = GetSignalDetainRelayId(signalId); + if ((0u != signalDetainRelayId) && (UINT16_MAX != signalDetainRelayId)) + {/*Ӳ߿۳̵Ч*/ + + relayBelongCIId = GetRelayBelongCiId(signalDetainRelayId);/*۳̵ID*/ + if (relayBelongCIId == localCiId) + {/*Ӳ߿۳̵Ϊ*/ + tmpRelayColState = GetRelayCollState(signalDetainRelayId);/*ȡ۳̵ɼ״̬*/ + + relayDetainValidFlag = GetCiFunctionSwitchConfig(FUNC_RELAY_DETAIN_VALID_FLAG);/*ȡӲ߿۳Ч־*/ + + if (DOWN_VALID == relayDetainValidFlag) + {/*Ч*/ + if (RELAY_DRIVE_STATE_DOWN == tmpRelayColState) + {/*̵£۳*/ + SetSignalRelayDetainFlag(signalId, SIGNAL_RELAY_DETAIN_YES); + } + else if (RELAY_DRIVE_STATE_UP == tmpRelayColState) + {/*̵δ۳*/ + SetSignalRelayDetainFlag(signalId, SIGNAL_RELAY_DETAIN_NO); + } + else + {/*ǷֵΪӲ߿۳*/ + SetSignalRelayDetainFlag(signalId, SIGNAL_RELAY_DETAIN_YES); + } + } + else + { + /*Ч*/ + if (RELAY_DRIVE_STATE_UP == tmpRelayColState) + {/*̵𣺿۳*/ + SetSignalRelayDetainFlag(signalId, SIGNAL_RELAY_DETAIN_YES); + } + else if (RELAY_DRIVE_STATE_DOWN == tmpRelayColState) + {/*̵£δ۳*/ + SetSignalRelayDetainFlag(signalId, SIGNAL_RELAY_DETAIN_NO); + } + else + {/*ǷֵΪӲ߿۳*/ + SetSignalRelayDetainFlag(signalId, SIGNAL_RELAY_DETAIN_YES); + } + } + } + + } + else + { + /*do nothing*/ + } + } + else if (signalBelongCi != localCiId) + {/*źŻ뱾ͬ*/ + commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*źŻͨ״̬*/ + /*źŻڱźŻ۳̵ڱ*/ + detainRelayId = GetSignalDetainRelayId(signalId); + if (detainRelayId > 0u) + { + relayBelongCIId = GetRelayBelongCiId(detainRelayId);/*۳̵ID*/ + if (relayBelongCIId == localCiId) + {/*źŻ۳̵ڱ*/ + relayCollState = GetRelayCollState(detainRelayId);/*ȡ̵ɼ״̬*/ + relayDetainValidFlag = GetCiFunctionSwitchConfig(FUNC_RELAY_DETAIN_VALID_FLAG);/*ȡӲ߿۳Ч־*/ + + if (DOWN_VALID == relayDetainValidFlag) + {/*Ч*/ + if (RELAY_DRIVE_STATE_DOWN == relayCollState) + {/*̵£۳*/ +#if 0 + SetSignalRelayDetainFlag(signalId,SIGNAL_RELAY_DETAIN_YES); +#endif + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE_DETAIN, signalId, SIGNAL_DETAIN_CI_RELAY_YES, signalBelongCi); + } + else if (RELAY_DRIVE_STATE_UP == relayCollState) + {/*̵δ۳*/ +#if 0 + SetSignalRelayDetainFlag(signalId,SIGNAL_RELAY_DETAIN_NO); +#endif + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE_DETAIN, signalId, SIGNAL_DETAIN_CI_RELAY_NO, signalBelongCi); + } + else + { + /*Ƿֵ*/ + } + } + else + { + /*Ч*/ + if (RELAY_DRIVE_STATE_UP == relayCollState) + {/*̵𣺿۳*/ +#if 0 + SetSignalRelayDetainFlag(signalId,SIGNAL_RELAY_DETAIN_YES); +#endif + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE_DETAIN, signalId, SIGNAL_DETAIN_CI_RELAY_YES, signalBelongCi); + } + else if (RELAY_DRIVE_STATE_DOWN == relayCollState) + {/*̵£δ۳*/ +#if 0 + SetSignalRelayDetainFlag(signalId,SIGNAL_RELAY_DETAIN_NO); +#endif + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE_DETAIN, signalId, SIGNAL_DETAIN_CI_RELAY_NO, signalBelongCi); + } + else + { + /*Ƿֵ*/ + } + } + } + } + + if ((TRANSMIT_STATE_BAD == commState) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*źŻͨжϣ̵ּ֧ӿڣ԰ѸźŻLXJ״̬תΪźŻɫ*/ + lxRelayId = GetSignalRepLxRelayId(signalId); + if (lxRelayId > 0u) + { + lxBelongCi = GetRelayBelongCiId(lxRelayId); + if (lxBelongCi == localCiId) + {/*гźż̵Ϊ̵*/ + lxRelaySta = GetRelayCollState(lxRelayId);/*źŻгźż̵ɼ״̬*/ + if (RELAY_STATE_UP == lxRelaySta) + { + signalType = GetSignalType(signalId);/*ȡźŻ*/ + signalBlockOpenColor = GetSignalBlockOpenColorValue((UINT16)signalType);/*ȡźŻ󱸿ɫ*/ + + (void)SetSignalCurColor(signalId, signalBlockOpenColor);/*źŻǰɫ*/ + } + else if (RELAY_STATE_DOWN == lxRelaySta) + { + (void)SetSignalCurColor(signalId, SIGNAL_DRIVECOLOUR_RED);/*߼̵£źŻʾ*/ + } + else + {/*̵״̬Ƿú*/ + (void)SetSignalCurColor(signalId, SIGNAL_DRIVECOLOUR_RED); + } + } + + } + } + } + else + { + /**/ + } + + } +} + + +/* +* źŻ߼״̬->̵״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +void SignalDeviceToRelayStateProc(void) +{ + UINT16 signalCurSum = 0u; /*źŻĿ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT8 curDrvColor = 0u; /*źŻǰɫ*/ + UINT8 curShowColor = 0u; /*źŻǰʾɫ*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 signalVirtualAttr = 0u;/*źŻ*/ + + UINT16 firDsRelayId = 0u; /*1˿̵ID */ + UINT16 secDsRelayId = 0u; /*2˿̵ID*/ + UINT16 lxRelayId = 0u; /*гźż̵ID*/ + UINT16 zxRelayId = 0u; /*źż̵ID*/ + UINT16 yxRelayId = 0u; /*źż̵ID*/ + UINT16 dxRelayId = 0u; /*źż̵ID*/ + UINT16 yellowRelayId = 0u; /*ƵƼ̵ID*/ + UINT16 greenRelayId = 0u; /*̵Ƽ̵ID*/ + UINT16 blueRelayId = 0u; /*Ƽ̵ID*/ + UINT16 replxRelayId = 0u; /*ʾгźż̵ID*/ + UINT16 ddRelayId = 0u; /*Ƽ̵ID*/ + + UINT32 jkjValidCycNum = 0u; + UINT8 jkjRelayValidFlag = 0u; + UINT8 checkRes = CI_TIME_OUT; + UINT32 sigCycle = 0u; + UINT32 sysParaCycle = 0u; + UINT8 tmpRet = CI_ERROR; + UINT8 sigColor = SIGNAL_SHOWCOLOUR_INVALID; + + UINT8 signalBelongCi = 0u; /*źŻID*/ + UINT8 commState = 0u;/*ͨ״̬*/ + UINT16 detainDriveRelayId = 0u;/*۳̵ID*/ + UINT8 detainDriveRelayBelongCi = 0u;/*۳μ̵*/ + UINT8 neighbourSignalDetainDrive = 0u;/*վźŻ۳*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 relayDetainValidFlag = 0u;/*Ӳ߿۳־*/ + UINT8 signalIsfushiFlag = 0u; + + signalCurSum = GetTotalSignalCurNum(); /*ȡźŻ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + firDsRelayId = GetSignalFirstDsRelayId(signalId); /*ȡźŻ1˿̵ID*/ + secDsRelayId = GetSignalSecondDsRelayId(signalId); /*ȡźŻ2˿̵ID*/ + lxRelayId = GetSignalLxRelayId(signalId); /*ȡźŻгźż̵ID*/ + zxRelayId = GetSignalZxRelayId(signalId); /*ȡźŻźż̵ID*/ + yxRelayId = GetSignalYxRelayId(signalId); /*ȡźŻźż̵ID*/ + dxRelayId = GetSignalDxRelayId(signalId); /*ȡźŻźż̵ID*/ + yellowRelayId = GetSignalYellowRelayId(signalId); /*ƵƼ̵ID*/ + greenRelayId = GetSignalGreenRelayId(signalId); /*̵Ƽ̵ID*/ + blueRelayId = GetSignalBlueRelayId(signalId); /*Ƽ̵ID*/ + replxRelayId = GetSignalRepLxRelayId(signalId); /*ʾг̵ID*/ + ddRelayId = GetSignalDdRelayId(signalId); /*ȡźŻƼ̵ID*/ + + /*źŻ*/ + for (ii = 0u; ii < signalCurSum; ii++) + { + signalId = 0u; /*źŻID*/ + signalBelongCi = 0u; /*źŻID*/ + curDrvColor = 0u; /*źŻǰɫ*/ + + signalId = GetSignalId(ii); /*ȡźŻID*/ + signalBelongCi = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + signalVirtualAttr = GetSignalVirtualAttr(signalId);/*ȡźŻ*/ + + if ((0u == signalId) || (signalId > SIGNAL_SUM_MAX) || (localCiId == 0u)) + { + /*źŻidϷ߱IDΪ0u,*/ + } + else if (signalBelongCi == localCiId) + { + /***ʱ***/ + curDrvColor = GetSignalCurDriveColor(signalId); /*ȡźŻǰɫ*/ + if (SIGNAL_DRIVECOLOUR_NULL == curDrvColor) + {/*źŻЧ*/ + jkjRelayValidFlag = GetCiJkjFlag(); + jkjValidCycNum = GetJkjRelayValidCycNum(); + curShowColor = GetSignalCurColor(signalId); + if (((SIGNAL_SHOWCOLOUR_REDYELLOW == curShowColor) || (SIGNAL_SHOWCOLOUR_RED_WHITE == curShowColor)) && + (JKJ_REYLAY_VALID == jkjRelayValidFlag) && (jkjValidCycNum > 0u) ) + { + /*źſʱӦЧ֮˹źſţִźŹر߼崻*/ + } + else + { + /*ֻвɼжϳ˸ʾLXJ̵IDȫΪ0u人5-8*/ + if ((0u == firDsRelayId) && (0u == secDsRelayId) && (0u == lxRelayId) && (0u == zxRelayId) + && (0u == yxRelayId) && (0u == dxRelayId) && (0u == yellowRelayId) && (0u == greenRelayId) + && (0u == blueRelayId) && (0u == ddRelayId) && (0u != replxRelayId)) + { + /*ֻвɼ*/ + } + else + { + tmpRet = DriveSignalClose(signalId); /*źŻر*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + } + } + } + curDrvColor = GetSignalCurDriveColor(signalId); /*ȡźŻǰɫ*/ + + + if ((SIGNAL_DRIVECOLOUR_RED == curDrvColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == curDrvColor)) + {/*źŻر*/ + sigCycle = GetSignalDriveCloseStartCycNum(signalId); + sysParaCycle = GetSystemParaSignalCloseCyc(); + checkRes = SystemOverTimeCheck(sigCycle, sysParaCycle); + if (CI_TIME_OUT == checkRes) + {/*źŻرճʱ*/ + + signalIsfushiFlag = GetSignalIsfushiFlag(signalId); + if (SIGNALTYPE_FUSHI_YES != signalIsfushiFlag)/*ʾźŻرճʱ崻*/ + { + /*xxxxx崻 źŻرճʱ*/ + SetPlatOverFlag(); /*ƽ̨崻*/ + SetErrorData(EFUNC_PLAT_OVER, CI_DEVICE_TYPE_SIGNAL, signalId, ETYPE_SIG_CLOSE_OVER_TIME, curDrvColor, ESEND_LEVEL_ZERO);/*¼崻*/ + } + } + } + else + {/*źŻ״̬*/ + sigCycle = GetSignalDriveOpenStartCycNum(signalId); + sysParaCycle = GetSystemParaSignalOpenCyc(); + checkRes = SystemOverTimeCheck(sigCycle, sysParaCycle); + if (CI_TIME_OUT == checkRes) + {/*źſ״̬*/ + + tmpRet = DriveSignalClose(signalId);/*źŻر*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + } + } + + + /***źŻ̵***/ + + if (SIGNAL_VIRTUAL_NO == signalVirtualAttr) + {/*źŻŽ̵*/ + tmpRet = SetSignalRelayState(signalId); + if (CI_ERROR == tmpRet) + { + /*źŻؼ̵ִе*/ + } + } + + /*֮ǰʾɫźŻ൱ڸ߼״̵̬״̬*/ + sigColor = GetSignalCurDriveColor(signalId); + tmpRet = SetSignalPreDriveColor(signalId, sigColor); + if (CI_ERROR == tmpRet) + { + /**/ + } + } + else if (signalBelongCi != localCiId) + {/*źŻ뱾ͬ*/ + commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*źŻͨ״̬*/ + detainDriveRelayId = GetSignalDetainDriveRelayId(signalId); + detainDriveRelayBelongCi = GetRelayBelongCiId(detainDriveRelayId); + if ((detainDriveRelayBelongCi == localCiId) && (TRANSMIT_STATE_BAD == commState) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + {/*۳̵Ϊ źŻͨжϣ̵ּ֧ӿ*/ + neighbourSignalDetainDrive = GetSignalNeighbourDetainDrive(signalId); + if (NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES == neighbourSignalDetainDrive) + {/*۳Ч*/ + relayDetainValidFlag = GetCiFunctionSwitchConfig(FUNC_RELAY_DETAIN_VALID_FLAG);/*ȡӲ߿۳Ч־*/ + + if (DOWN_VALID == relayDetainValidFlag) + {/*Ч*/ + (void)SetRelayDriveState(detainDriveRelayId, RELAY_DRIVE_STATE_DOWN); + } + else + { + /*Ч*/ + (void)SetRelayDriveState(detainDriveRelayId, RELAY_DRIVE_STATE_UP); + } + } + else + {/*۳ȡ*/ + relayDetainValidFlag = GetCiFunctionSwitchConfig(FUNC_RELAY_DETAIN_VALID_FLAG);/*ȡӲ߿۳Ч־*/ + + if (DOWN_VALID == relayDetainValidFlag) + {/*Ч*/ + (void)SetRelayDriveState(detainDriveRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /*Ч*/ + (void)SetRelayDriveState(detainDriveRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + } + + } + else + { + /**/ + } + } +} + + +/* +* źŻϢָIDźŻ̵ +* ˵ const UINT16 signalId +* ֵ 0u:ʧ +* >0u:óɹ +*/ +UINT8 SetSignalRelayState(const UINT16 signalId) +{ + UINT8 bCiSwitchShowGreenYellow = FUNC_SWITCH_OFF;/*ciʾ̻ƿ,Ĭǹرյ*/ + + UINT16 firDsRelayId = 0u; /*1˿̵ID */ + UINT16 secDsRelayId = 0u; /*2˿̵ID*/ + UINT16 lxRelayId = 0u; /*гźż̵ID*/ + UINT16 zxRelayId = 0u; /*źż̵ID*/ + UINT16 yxRelayId = 0u; /*źż̵ID*/ + UINT16 ddRelayId = 0u; /*Ƽ̵ID*/ + UINT16 dxRelayId = 0u; /*źż̵ID*/ + UINT16 yellowRelayId = 0u; /*ƵƼ̵ID*/ + UINT16 greenRelayId = 0u; /*̵Ƽ̵ID*/ + UINT16 blueRelayId = 0u; /*Ƽ̵ID*/ + + UINT8 firDsRelaySta = RELAY_STATE_DOWN; /*1˿̵״̬ */ + UINT8 secDsRelaySta = RELAY_STATE_DOWN; /*2˿̵״̬*/ + UINT8 lxRelaySta = RELAY_STATE_DOWN; /*гźż̵״̬*/ + UINT8 zxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 yxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 ddRelaySta = RELAY_STATE_DOWN; /*Ƽ̵״̬*/ + UINT8 dxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 yellowRelaySta = RELAY_STATE_DOWN; /*ƵƼ̵״̬*/ + UINT8 greenRelaySta = RELAY_STATE_DOWN; /*̵Ƽ̵״̬*/ + UINT8 blueRelaySta = RELAY_STATE_DOWN; /*Ƽ̵״̬*/ + + UINT8 signalType = GetSignalType(signalId); /*źŻ߼*/ + UINT8 curDrvColor = GetSignalCurDriveColor(signalId); /*źŻǰɫ*/ + UINT8 OldDriveColor = GetSignalOldDriveColor(signalId); /*źŻǰɫ*/ + + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 drvNewSigStartCycNum = GetSignalDriveNewSigStartCycNum(signalId); + + firDsRelayId = GetSignalFirstDsRelayId(signalId); /*ȡźŻ1˿̵ID*/ + secDsRelayId = GetSignalSecondDsRelayId(signalId); /*ȡźŻ2˿̵ID*/ + lxRelayId = GetSignalLxRelayId(signalId); /*ȡźŻгźż̵ID*/ + zxRelayId = GetSignalZxRelayId(signalId); /*ȡźŻźż̵ID*/ + yxRelayId = GetSignalYxRelayId(signalId); /*ȡźŻźż̵ID*/ + dxRelayId = GetSignalDxRelayId(signalId); /*ȡźŻźż̵ID*/ + ddRelayId = GetSignalDdRelayId(signalId); /*ȡźŻƼ̵ID*/ + yellowRelayId = GetSignalYellowRelayId(signalId); /*ƵƼ̵ID*/ + greenRelayId = GetSignalGreenRelayId(signalId); /*̵Ƽ̵ID*/ + blueRelayId = GetSignalBlueRelayId(signalId); /*Ƽ̵ID*/ + + firDsRelaySta = GetRelayCollState(firDsRelayId); /*ȡźŻ1˿̵״̬*/ + secDsRelaySta = GetRelayCollState(secDsRelayId); /*ȡźŻ2˿̵״̬*/ + ddRelaySta = GetRelayCollState(ddRelayId); /*ȡźŻƼ̵״̬*/ + lxRelaySta = GetRelayCollState(lxRelayId); /*ȡźŻгźż̵״̬*/ + yxRelaySta = GetRelayCollState(yxRelayId); /*ȡźŻźż̵״̬*/ + zxRelaySta = GetRelayCollState(zxRelayId); /*ȡźŻźż̵״̬*/ + dxRelaySta = GetRelayCollState(dxRelayId); /*ȡźŻźż̵״̬*/ + yellowRelaySta = GetRelayCollState(yellowRelayId); + greenRelaySta = GetRelayCollState(greenRelayId); + blueRelaySta = GetRelayCollState(blueRelayId); + + bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow); + + switch (signalType) + { + case SIGNAL_TYPE_4_ALL_NOYINDAO_ZX: /* 0x2A ʾơ 졢̡*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_GREENCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(yellowRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_GREEN: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(yellowRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(yellowRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_GREENYELLOW: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(yellowRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(yellowRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_YELLOW: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(yellowRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_REDCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(yellowRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(yellowRelayId, RELAY_STATE_DOWN); + break; + } + default: + /*ɴ֧*/ + break; + } + + } + else + { + /*޲*/ + } + break; + } + case SIGNAL_TYPE_4_NOGREEN_NOYINDAO_ZX:/*0x2B ʾ̵ơɵƵƣ졢*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_YELLOW: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_REDCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + break; + } + + default: + /*ɴ֧*/ + break; + } + } + } + break; + case SIGNAL_TYPE_5_NOGREEN_YINDAO_CD:/*0x2C ʾ̵ơɵ˫Ƶƣ졢ơ̡ס˫*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_RED_WHITE: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_UP); + break; + } + + default: + /*ɴ֧*/ + break; + } + } + } + break; + case SIGNAL_TYPE_5_NOY_NOYINDAO_CD:/*0x2D ʾƵơ졢̡˫̡*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_GREEN: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_DOUBLE_GREEN: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_WHITE: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(zxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + + default: + /*ɴ֧*/ + break; + } + } + } + break; + case SIGNAL_TYPE_4_ALL_NOYINDAO_CD: /* 0x2E ʾ*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_GREEN: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_YELLOW: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_WHITE: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + + default: + /*ɴ֧*/ + break; + } + } + } + break; + case SIGNAL_TYPE_5_NOY_NOYINDAO_WB: /* 0x2f λźŻƵƣס*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_DOUBLE_GREEN: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_WHITE: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + + default: + /*ɴ֧*/ + break; + } + } + } + break; + case SIGNAL_TYPE_3_RGG_CD:/*0x30 3λ졢˫*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_DOUBLE_GREEN: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + break; + } + + default: + /*ɴ֧*/ + break; + } + } + } + break; + case SIGNAL_TYPE_3_RGG_NOGREEN_CD: /* 0x31 3λ졢˫̵̡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_GREEN: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + break; + } + + default: + /*ɴ֧*/ + break; + } + } + break; + case SIGNAL_TYPE_3_NOGREENWHITE_CD: /* 0x32 3λ̡졢ף̡׵*/ + { + + /*û*/ + } + break; + case SIGNAL_TYPE_4_ALL_NOYINDAO_NOYELLOWONLY_ZX: /*0x33վźŻ(ơ̡졢ĵλλɵƵ)*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_GREENCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_GREEN: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_GREENYELLOW: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_REDCLOSE: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(greenRelayId, RELAY_STATE_DOWN); + break; + } + default: + { + /*ɴ֧*/ + break; + } + } + } + break; + } + case SIGNAL_TYPE_4_NOGREENBLUE_NOYINDAO_ZX: /*0x34źŻơ̡졢ĵλ̡ƣɵƵƣ*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_YELLOW: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + break; + } + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + break; + } + default: + { + /*ɴ֧*/ + break; + } + } + } + break; + } + case SIGNAL_TYPE_3_ALL_NOYINDAO_CD: /*0x35źŻ(ơ)̣*/ + { + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_GREEN: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN); + break; + } + case SIGNAL_DRIVECOLOUR_WHITE: + { + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN); + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_UP); + break; + } + default: + { + /*ɴ֧*/ + break; + } + } + break; + } + case SIGNAL_TYPE_1_ALL_END: /*0x36 ʾͷ赲źŻ*/ + {/*û*/ + break; + } + + case SIGNAL_TYPE_THREE_ALL_YINDAO:/*ʾ졢 ̡ ơƣ*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + if ((SIGNAL_DRIVECOLOUR_GREEN == OldDriveColor) || (SIGNAL_DRIVECOLOUR_GREENCLOSE == OldDriveColor)) + { + if (SIG_RELAY_DRV_DELAY_TIME > (curCycleNum - drvNewSigStartCycNum)) + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + break; + case SIGNAL_DRIVECOLOUR_REDCLOSE:/**/ + if ((SIGNAL_DRIVECOLOUR_GREEN == OldDriveColor) || (SIGNAL_DRIVECOLOUR_GREENCLOSE == OldDriveColor)) + { + if (SIG_RELAY_DRV_DELAY_TIME > (curCycleNum - drvNewSigStartCycNum)) + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + break; + case SIGNAL_DRIVECOLOUR_GREEN:/**/ + if ((SIGNAL_DRIVECOLOUR_RED == OldDriveColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == OldDriveColor)) + { + if (SIG_RELAY_DRV_DELAY_TIME > (curCycleNum - drvNewSigStartCycNum)) + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + break; + case SIGNAL_DRIVECOLOUR_GREENCLOSE:/**/ + if ((SIGNAL_DRIVECOLOUR_RED == OldDriveColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == OldDriveColor)) + { + if (SIG_RELAY_DRV_DELAY_TIME > (curCycleNum - drvNewSigStartCycNum)) + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + break; + case SIGNAL_DRIVECOLOUR_YELLOW:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDYELLOW:/*Ƶ*/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + returnValue = CI_ERROR; + break; + } + break; + + case SIGNAL_TYPE_THREE_ALL_NOYINDAO:/*ʾ졢 ̡ ƣ*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + if ((SIGNAL_DRIVECOLOUR_GREEN == OldDriveColor) || (SIGNAL_DRIVECOLOUR_GREENCLOSE == OldDriveColor)) + { + if (SIG_RELAY_DRV_DELAY_TIME > (curCycleNum - drvNewSigStartCycNum)) + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + break; + case SIGNAL_DRIVECOLOUR_REDCLOSE:/**/ + if ((SIGNAL_DRIVECOLOUR_GREEN == OldDriveColor) || (SIGNAL_DRIVECOLOUR_GREENCLOSE == OldDriveColor)) + { + if (SIG_RELAY_DRV_DELAY_TIME > (curCycleNum - drvNewSigStartCycNum)) + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + } + break; + case SIGNAL_DRIVECOLOUR_GREEN:/**/ + if ((SIGNAL_DRIVECOLOUR_RED == OldDriveColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == OldDriveColor)) + { + if (SIG_RELAY_DRV_DELAY_TIME > (curCycleNum - drvNewSigStartCycNum)) + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + } + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + } + break; + case SIGNAL_DRIVECOLOUR_GREENCLOSE:/**/ + if ((SIGNAL_DRIVECOLOUR_RED == OldDriveColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == OldDriveColor)) + { + if (SIG_RELAY_DRV_DELAY_TIME > (curCycleNum - drvNewSigStartCycNum)) + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + } + } + else + { + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + } + break; + case SIGNAL_DRIVECOLOUR_YELLOW:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalZxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_THREE_NOGREEN_YINDAO:/*ʾ̵ƣ졢ơƣ*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOW:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDYELLOW:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO:/*ʾ̵졢ƣ*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOW:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_THREE_NOYELLOW_YINDAO:/*źŻ(ʾ޻Ƶƣ)*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_GREEN:/**/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDYELLOW:/**/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_THREE_ALL_YINDAO_NOY:/*źŻ(ʾƣɵƵƣ)*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_GREEN:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_GREENCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDYELLOW:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO:/*ʾƵ졢̣*/ + case SIGNAL_TYPE_TWO_ALL_NOYINDAO:/*ʾ졢̣*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_GREEN:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_GREENCLOSE:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_UP);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDdRelayId(signalId), RELAY_STATE_DOWN);/*Ƽ̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_TWO_NOGREEN_NOYINDAO:/*ʾ̵ƣ*/ + if (SIGNAL_DRIVECOLOUR_RED == curDrvColor) + { /**/ + + (void)SetRelayDriveState(GetSignalFirstDsRelayId(signalId), RELAY_STATE_UP);/*1˿̵*/ + } + else + {/**/ + + (void)SetRelayDriveState(GetSignalFirstDsRelayId(signalId), RELAY_STATE_UP);/*1˿̵*/ + returnValue = CI_ERROR; + } + break; + case SIGNAL_TYPE_DIAOCHE:/*źŻ*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_WHITE:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_JINKUCHUKU:/*źŻ*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_WHITE:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOW:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + returnValue = CI_ERROR; + break; + } + break; + + case SIGNAL_TYPE_TWO_JINKU_RGY:/*/źŻ(ʾ),ơ̵ƺƵ*/ + /**/ + break; + case SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL:/*źŻ(ʾ̵ƣ)*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOW:/**/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDYELLOW:/**/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_THREE_DIAOCHE_YINDAO:/*δźŻ(ʾ׵ƣ)*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_WHITE:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + break; + case SIGNAL_DRIVECOLOUR_RED_WHITE:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_THREE_JINKU_YINDAO: /*źŻʾ*/ /*»źŻ2019.1.15*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_WHITE:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDYELLOW:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOW:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_UP);/*гźż̵*/ + break; + default:/**/ + (void)SetRelayDriveState(GetSignalDxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalYxRelayId(signalId), RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(GetSignalLxRelayId(signalId), RELAY_STATE_DOWN);/*гźż̵*/ + returnValue = CI_ERROR; + break; + } + break; + case SIGNAL_TYPE_THREE_JINKU_OFF: /*źŻʾҿcgh-ϲCID-3037-8*/ + switch (curDrvColor) + { + case SIGNAL_DRIVECOLOUR_RED: + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN);/*Ƽ̵*/ + break; + case SIGNAL_DRIVECOLOUR_WHITE: + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN);/*Ƽ̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDYELLOW:/**/ + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_UP);/*źż̵*/ + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN);/*Ƽ̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOW: + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN);/*Ƽ̵*/ + break; + case SIGNAL_DRIVECOLOUR_REDCLOSE: + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP);/*Ƽ̵*/ + break; + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE: + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_UP);/*гźż̵*/ + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_UP);/*Ƽ̵*/ + break; + default: + (void)SetRelayDriveState(dxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(yxRelayId, RELAY_STATE_DOWN);/*źż̵*/ + (void)SetRelayDriveState(lxRelayId, RELAY_STATE_DOWN);/*гźż̵*/ + (void)SetRelayDriveState(ddRelayId, RELAY_STATE_DOWN);/*Ƽ̵*/ + returnValue = CI_ERROR; + break; + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + + +/* +* ݼ̵ɼݻȡָIDźŻĵǰʾɫ +* ˵ const UINT16 signalId +* ֵ 0u: SIGNAL_SHOWCOLOUR_INVALID +* >0u: ǰʾɫ +*/ +UINT8 GetSignalShowColor(const UINT16 signalId) +{ + UINT16 firDsRelayId = 0u; /*1˿̵ID */ + UINT16 secDsRelayId = 0u; /*2˿̵ID*/ + UINT16 lxRelayId = 0u; /*гźż̵ID*/ + UINT16 zxRelayId = 0u; /*źż̵ID*/ + UINT16 yxRelayId = 0u; /*źż̵ID*/ + UINT16 ddRelayId = 0u; /*Ƽ̵ID*/ + UINT16 dxRelayId = 0u; /*źż̵ID*/ + UINT16 yellowRelayId = 0u; /*ƵƼ̵ID*/ + UINT16 greenRelayId = 0u; /*̵Ƽ̵ID*/ + UINT16 blueRelayId = 0u; /*Ƽ̵ID*/ + + UINT8 signalType = 0u; /*źŻƵ·*/ + UINT8 returnValue = 0u;/*ֵ*/ + UINT8 bCiSwitchShowGreenYellow = FUNC_SWITCH_OFF;/*ciʾ̻ƿ,Ĭǹرյ*/ + + UINT8 firDsRelaySta = RELAY_STATE_DOWN; /*1˿̵״̬ */ + UINT8 secDsRelaySta = RELAY_STATE_DOWN; /*2˿̵״̬*/ + UINT8 lxRelaySta = RELAY_STATE_DOWN; /*гźż̵״̬*/ + UINT8 zxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 yxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 ddRelaySta = RELAY_STATE_DOWN; /*Ƽ̵״̬*/ + UINT8 dxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 yellowRelaySta = RELAY_STATE_DOWN; /*ƵƼ̵״̬*/ + UINT8 greenRelaySta = RELAY_STATE_DOWN; /*̵Ƽ̵״̬*/ + + firDsRelayId = GetSignalFirstDsRelayId(signalId); /*ȡźŻ1˿̵ID*/ + secDsRelayId = GetSignalSecondDsRelayId(signalId); /*ȡźŻ2˿̵ID*/ + lxRelayId = GetSignalLxRelayId(signalId); /*ȡźŻгźż̵ID*/ + zxRelayId = GetSignalZxRelayId(signalId); /*ȡźŻźż̵ID*/ + yxRelayId = GetSignalYxRelayId(signalId); /*ȡźŻźż̵ID*/ + dxRelayId = GetSignalDxRelayId(signalId); /*ȡźŻźż̵ID*/ + ddRelayId = GetSignalDdRelayId(signalId); /*ȡźŻƼ̵ID*/ + yellowRelayId = GetSignalYellowRelayId(signalId); /*ƵƼ̵ID*/ + greenRelayId = GetSignalGreenRelayId(signalId); /*̵Ƽ̵ID*/ + blueRelayId = GetSignalBlueRelayId(signalId); /*Ƽ̵ID*/ + + + signalType = GetSignalType(signalId); /*ȡźŻ߼*/ + + firDsRelaySta = GetRelayCollState(firDsRelayId); /*ȡźŻ1˿̵״̬*/ + secDsRelaySta = GetRelayCollState(secDsRelayId); /*ȡźŻ2˿̵״̬*/ + ddRelaySta = GetRelayCollState(ddRelayId); /*ȡźŻƼ̵״̬*/ + lxRelaySta = GetRelayCollState(lxRelayId); /*ȡźŻгźż̵״̬*/ + yxRelaySta = GetRelayCollState(yxRelayId); /*ȡźŻźż̵״̬*/ + zxRelaySta = GetRelayCollState(zxRelayId); /*ȡźŻźż̵״̬*/ + dxRelaySta = GetRelayCollState(dxRelayId); /*ȡźŻźż̵״̬*/ + yellowRelaySta = GetRelayCollState(yellowRelayId); + greenRelaySta = GetRelayCollState(greenRelayId); + + if (0u == ddRelayId) + { + returnValue = GetNoDDJSignalColor(signalId); + } + else + { + bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow); + switch (signalType) + { + case SIGNAL_TYPE_4_ALL_NOYINDAO_ZX:/*0x2A ʾơ 졢̡*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_UP == greenRelaySta) && (RELAY_STATE_DOWN == yellowRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*г̵𡢻Ƶ¡1˿¡2˿*/ + returnValue = SIGNAL_SHOWCOLOUR_GREENCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_UP == greenRelaySta) && (RELAY_STATE_DOWN == yellowRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN; /*̵*/ + } + else if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == yellowRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*̻*/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == yellowRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*̻*/ + } + else if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == zxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_UP == yellowRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == zxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_UP == yellowRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == yellowRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == yellowRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + } + case SIGNAL_TYPE_4_NOGREEN_NOYINDAO_ZX:/*0x2B ʾ̵ơɵƵƣ졢*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_5_NOGREEN_YINDAO_CD:/*0x2C ʾ̵ơɵ˫Ƶƣ졢ơ̡ס˫*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW;/*˫Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED_WHITE;/*׵*/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_5_NOY_NOYINDAO_CD: /* 0x2D ʾƵơ졢̡˫̡*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == zxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/*̵*/ + } + else if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == zxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_DOUBLE_GREEN;/*˫̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == zxRelaySta) && (RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/*׵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == zxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_4_ALL_NOYINDAO_CD: /*0x2E ʾ*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == greenRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/*̵*/ + } + else if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/*׵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_5_NOY_NOYINDAO_WB: /* 0x2f λźŻƵƣס*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_DOUBLE_GREEN;/*˫̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/*׵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_3_RGG_CD: /* 0x30 3λ졢˫*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_DOUBLE_GREEN; /*˫̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED; /**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_3_RGG_NOGREEN_CD: /*0x31 3λ졢˫̵̡*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN; /*̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED; /**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_3_NOGREENWHITE_CD: /* 0x32 3λ̡졢ף̡׵*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED; /**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_4_ALL_NOYINDAO_NOYELLOWONLY_ZX:/* 0x33 վźŻ(ơ̡졢ĵλλɵƵ)*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == greenRelaySta) && (RELAY_STATE_DOWN == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*̵*/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == greenRelaySta) && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/*̵*/ + } + else if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*̻Ƶ*/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*̻Ƶ*/ + } + else if ((RELAY_STATE_UP == ddRelaySta) && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_4_NOGREENBLUE_NOYINDAO_ZX:/*0x34 źŻơ̡졢ĵλ̡ƣɵƵƣ*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_3_ALL_NOYINDAO_CD:/*0x35 źŻ(ơ)̣*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/*̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/*׵*/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + + break; + } + case SIGNAL_TYPE_1_ALL_END:/*0x36 ʾͷ赲źŻ*/ + { + if (RELAY_STATE_UP == firDsRelaySta) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + + break; + } + case SIGNAL_TYPE_THREE_ALL_YINDAO:/*ʾ졢ơ̡ƣ*/ + { + if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵¡гźż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵гźż̵¡źŻ¡1˿̵¡2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == zxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵¡гźż̵źż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == zxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵гźż̵źż̵¡źŻ¡1˿̵¡2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*Ƽ̵¡гźż̵¡źŻ1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵¡гźż̵źż̵źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵гźż̵źż̵źŻ¡1˿̵¡2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREENCLOSE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_THREE_ALL_NOYINDAO:/*ʾ졢ợ*/ + { + + + if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*Ƽ̵¡гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + {/*Ƽ̵гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == zxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*Ƽ̵¡гźż̵źż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == zxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + {/*Ƽ̵гźż̵źż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*Ƽ̵¡гźż̵źż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + {/*Ƽ̵гźż̵źż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREENCLOSE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_THREE_NOGREEN_YINDAO:/*ʾ̵ƣ졢ơƣ*/ + { + if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵¡гźż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵гźż̵¡źŻ¡1˿̵¡2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵¡гźż̵źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*Ƽ̵гźż̵źŻ¡1˿̵¡2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*Ƽ̵¡гźż̵¡źŻ1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO:/*ʾ̵졢ƣ*/ + { + if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*Ƽ̵¡гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + {/*Ƽ̵гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*Ƽ̵¡гźż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + {/*Ƽ̵гźż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_THREE_NOYELLOW_YINDAO:/*źŻ(ʾ޻Ƶƣ)*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵¡źŻ1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_THREE_ALL_YINDAO_NOY:/*źŻ(ʾƣɵƵƣ)*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_DOWN == ddRelaySta)) + {/*гźż̵¡źŻ¡1˿̵2˿̵¡Ƽ̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_UP == ddRelaySta)) + {/*гźż̵¡źŻ¡1˿̵¡2˿̵¡Ƽ̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_DOWN == ddRelaySta)) + {/*гźż̵źŻ¡1˿̵2˿̵¡Ƽ̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_UP == ddRelaySta)) + {/*гźż̵źŻ¡1˿̵¡2˿̵¡Ƽ̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREENCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta) + && (RELAY_STATE_DOWN == ddRelaySta)) + {/*гźż̵¡źŻ1˿̵2˿̵𡢵Ƽ̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO:/*ʾƵ졢̣*/ + case SIGNAL_TYPE_TWO_ALL_NOYINDAO:/*ʾ졢̣*/ + { + if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*Ƽ̵¡гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + {/*Ƽ̵гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_DOWN == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*Ƽ̵¡гźż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_UP == ddRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta)) + {/*Ƽ̵гźż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREENCLOSE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_TWO_NOGREEN_NOYINDAO:/*ʾ̵ƣ죩*/ + if (RELAY_STATE_UP == firDsRelaySta) + {/*1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + case SIGNAL_TYPE_DIAOCHE:/*źŻ졢ף*/ + if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + case SIGNAL_TYPE_JINKUCHUKU:/*źŻ*/ + { + if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵¡гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵¡гźż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + + case SIGNAL_TYPE_TWO_JINKU_RGY:/*/źŻ(ʾ),ơ̵ƺƵ*/ + { + if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta)) + {/*гźż̵ && źż̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta)) + {/*гźż̵ && źż̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta)) + {/*гźż̵ && źż̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL:/*źŻ(ʾ̵ƣ)*/ + { + if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵ && źż̵ && 1˿̵ && 2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵ && źż̵ && 1˿̵ && 2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵ && źż̵ && 1˿̵ && 2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_THREE_DIAOCHE_YINDAO:/*δźŻ(ʾ׵ƣ)*/ + { + if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*źż̵¡źż̵¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*źż̵źż̵¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*źż̵¡źż̵1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED_WHITE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + } + break; + case SIGNAL_TYPE_THREE_JINKU_YINDAO: /*źŻʾ*/ /*»źŻ2019.1.15*/ + { + if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵𡢵źż̵¡źż̵¡1˿̵2˿̵*/ + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + { /*гźż̵¡źż̵źż̵¡1˿̵2˿̵*/ + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + { /*гźż̵¡źż̵¡źż̵¡1˿̵2˿̵*/ + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵¡źż̵¡źż̵1˿̵2˿̵*/ + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/*Ƶ*/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; /*Ч̵*/ + } + } + break; + case SIGNAL_TYPE_THREE_JINKU_OFF:/*cgh-ϲCID-3037-8*/ + if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_DOWN == ddRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_DOWN == ddRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_DOWN == ddRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta) + && (RELAY_STATE_DOWN == ddRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_UP == ddRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_REDCLOSE;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_DOWN == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta) + && (RELAY_STATE_UP == ddRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; /*Ч̵*/ + } + break; + default: + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + break; + } + + + } + /* ˿̵δã⴦ ΪߵĵźŻûе˿ */ + if (firDsRelayId == 0u) + { + returnValue = GetRelayToDeviceSignalColor(signalId); + } + + return returnValue; +} + + +/******************************ؼ̵****************************/ + +/* +* µ߼״̬ +* ˵ const UINT32 curCycleNum, ǰں +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +void SwitchRelayToDeviceStateProc(void) +{ + UINT16 switchCurSum = 0u; /*Ŀ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT16 switchId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*ID*/ + UINT16 DbRelayId = 0u; /*̵ID*/ + UINT16 FbRelayId = 0u; /*̵ID*/ + UINT16 YcRelayId = 0u; /*ʲټ̵ID*/ + UINT16 DcRelayId = 0u; /*ټ̵ID*/ + UINT16 FcRelayId = 0u; /*ټ̵ID*/ + UINT16 ZDbRelayId = 0u; /*̵ܶID*/ + UINT16 ZFbRelayId = 0u; /*̵ܷID*/ + UINT16 DFHRelayId = 0u; /*DFH̵*/ + UINT8 YcRelayState = 0u; /*ʲټ̵״̬*/ + UINT8 DbRelayState = 0u; /*̵״̬*/ + UINT8 FbRelayState = 0u; /*̵״̬*/ + UINT8 ZDbRelayState = 0u; /*̵ܶ״̬*/ + UINT8 ZFbRelayState = 0u; /*̵ܷ״̬*/ + UINT8 DFHRelayState = 0u; /*̵״̬*/ + UINT16 ii = 0u; /*ѭ*/ + UINT32 DfhRelayCycNum = 0u; /*̵Чں*/ + UINT32 YcRelayCycNum = 0u; /*ʲټ̵Чں*/ + UINT32 SigleYcRelayCycNum = 0u; /*ʲټ̵Чں*/ + UINT32 curCycNum = 0u; + UINT32 DfhRelayValidMaxTimeCount = 0u; /*̵Чֵ*/ + + UINT8 checkRes = CI_TIME_OUT; + UINT8 tmpRet = CI_ERROR; + UINT8 curSwitchPos = SWITCH_POSITION_INVALID; /*ǰλ*/ + UINT8 drvSwitchPos = SWITCH_DRIVE_POS_INVALID; /*ǰλ*/ + UINT8 SwitchDanCaoPos = SWITCH_POSITION_INVALID; /*λ*/ + UINT8 chTiocSysMode = 0U; + UINT8 timeState = CI_TIME_NO; /*ʱ״̬*/ + UINT8 chDsnLinSwitch = 0U; + + chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + DfhRelayValidMaxTimeCount = GetDHFRelayValidTimeCount();/*ȡ̵Чֵ*/ + switchCurSum = GetSwitchCurSum(); /*ȡ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + curCycNum = Get2oo2CurCycleNum(); /*ȡǰ*/ + + if (FUNC_SWITCH_ON == chDsnLinSwitch) + { + chTiocSysMode = GetTiocSystemMode(); + } + /**/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = 0u; /*ID*/ + belongCiId = 0u; /*ID*/ + DbRelayId = 0u; /*̵ID*/ + FbRelayId = 0u; /*̵ID*/ + YcRelayId = 0u; /*ʲټ̵ID*/ + DcRelayId = 0u; /*ټ̵ID*/ + FcRelayId = 0u; /*ټ̵ID*/ + ZDbRelayId = 0u; /*̵ܶID*/ + ZFbRelayId = 0u; /*̵ܷID*/ + DFHRelayId = 0u; /*̵ID*/ + YcRelayState = 0u; /*ʲټ̵״̬*/ + DbRelayState = 0u; /*̵״̬*/ + FbRelayState = 0u; /*̵״̬*/ + ZDbRelayState = 0u; /*̵ܶ״̬*/ + ZFbRelayState = 0u; /*̵ܷ״̬*/ + DFHRelayState = 0u; /*̵״̬*/ + + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u != switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + DbRelayId = GetSwitchDbRelayId(switchId); /*ȡλʾ̵ID*/ + FbRelayId = GetSwitchFbRelayId(switchId); /*ȡλʾ̵ID*/ + YcRelayId = GetSwitchYcRelayId(switchId); /*ȡʲټ̵ID*/ + DcRelayId = GetSwitchDcRelayId(switchId); /*ȡټ̵ID*/ + FcRelayId = GetSwitchFcRelayId(switchId); /*ȡټ̵ID*/ + ZDbRelayId = GetSwitchZDbRelayId(switchId); /*ȡܶλʾ̵ID*/ + ZFbRelayId = GetSwitchZFbRelayId(switchId); /*ȡܷλʾ̵ID*/ + DFHRelayId = GetSwitchDFHRelayId(switchId); /*ȡDFH̵ID*/ + + if (REVERSE_MODE_SHADOW == chTiocSysMode) + { + /*ӰģʽʹӰģʽ̵*/ + DbRelayId = GetSwitchShadowDbRelayId(switchId); + FbRelayId = GetSwitchShadowFbRelayId(switchId); + ZDbRelayId = DbRelayId; + ZFbRelayId = FbRelayId; + DFHRelayId = 0u; + } + /*µλ*/ + YcRelayState = GetRelayCollState(YcRelayId); /*ʲټ̵״̬*/ + DbRelayState = GetRelayCollState(DbRelayId); /*̵״̬*/ + FbRelayState = GetRelayCollState(FbRelayId); /*̵״̬*/ + ZDbRelayState = GetRelayCollState(ZDbRelayId); /*̵ܶ״̬*/ + ZFbRelayState = GetRelayCollState(ZFbRelayId); /*̵ܷ״̬*/ + DFHRelayState = GetRelayCollState(DFHRelayId); /*̵״̬*/ + /*õǰλúƶ*/ + + if (ZDbRelayState == ZFbRelayState) + {/*ʧʾ*/ + if (RELAY_STATE_UP == ZDbRelayState) + {/*̵ܶΪĿ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + tmpRet = SetSwitchYCRelayValidCycNum(switchId, 0u); /*YC̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + } + else + { + /*ʲټ̵IDΪ0u*/ + if (0u != YcRelayId) + { + YcRelayCycNum = GetSwitchYCRelayValidCycNum(switchId); /*YC̵״̬*/ + + if (RELAY_STATE_UP == YcRelayState) + {/*ʲ*/ + tmpRet = SetSwitchYCRelayValidCycNum(switchId, 0u); /*YC̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + if ((RELAY_STATE_DOWN == ZDbRelayState) && (RELAY_STATE_DOWN == ZFbRelayState)) + {/*ƶ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_MOVE);/*õǰλΪƶ*/ + tmpRet = SetSwitchDFHRelayValidCycNum(switchId, 0u); /*DHF̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + } + else + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õλΪĿ*/ + } + } + else + { + if (0u == YcRelayCycNum) + {/*δʱʼ*/ + tmpRet = SetSwitchYCRelayValidCycNum(switchId, curCycNum); + if (CI_ERROR == tmpRet) + { + /**/ + } + else + { + YcRelayCycNum = GetSwitchYCRelayValidCycNum(switchId); /*YC̵״̬*/ + } + } + checkRes = SystemOverTimeCheck(YcRelayCycNum, DfhRelayValidMaxTimeCount); + if (CI_TIME_OUT == checkRes) + { /*ȫֵ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õĿ*/ + } + } + } + else + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õλΪĿ*/ + } + } + } + else + {/*ʾЧ*/ + tmpRet = SetSwitchYCRelayValidCycNum(switchId, 0u); /*YC̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + if ((0u == DFHRelayId) || (UINT16_MAX == DFHRelayId)) + {/*DFH̵Ч,жDFH̵״̬*/ + if ((RELAY_STATE_UP == ZDbRelayState) + && (RELAY_STATE_DOWN == ZFbRelayState)) + {/*ܷܶ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_DINGWEI);/*õλ*/ + + if (SWITCH_DRIVE_POS_DINGWEI == GetSwitchDrivePostion(switchId)) + {/*Ѿƶλ*/ + (void)SetRelayDriveState(YcRelayId, RELAY_STATE_DOWN);/*ʲټ̵*/ + (void)SetRelayDriveState(DcRelayId, RELAY_STATE_DOWN);/*öټ̵*/ + (void)SetRelayDriveState(FcRelayId, RELAY_STATE_DOWN);/*÷ټ̵*/ + } + } + else if ((RELAY_STATE_UP == ZFbRelayState) + && (RELAY_STATE_DOWN == ZDbRelayState)) + {/*ܷܶ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_FANWEI);/*õλ*/ + + drvSwitchPos = GetSwitchDrivePostion(switchId); + if (SWITCH_DRIVE_POS_FANWEI == drvSwitchPos) + {/*Ѿƶλ*/ + (void)SetRelayDriveState(YcRelayId, RELAY_STATE_DOWN);/*ʲټ̵*/ + (void)SetRelayDriveState(DcRelayId, RELAY_STATE_DOWN);/*öټ̵*/ + (void)SetRelayDriveState(FcRelayId, RELAY_STATE_DOWN);/*÷ټ̵*/ + } + } + else + {/*޴*/ + + /*ȫֵ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õĿ*/ + } + } + else + { + DfhRelayCycNum = GetSwitchDFHRelayValidCycNum(switchId); /*DFH̵״̬*/ + + if (RELAY_STATE_UP == DFHRelayState) + { + if (0u == DfhRelayCycNum) + {/*δʱʼ*/ + tmpRet = SetSwitchDFHRelayValidCycNum(switchId, curCycNum); + if (CI_ERROR == tmpRet) + { + /**/ + } + else + { + DfhRelayCycNum = GetSwitchDFHRelayValidCycNum(switchId); /*DFH̵״̬*/ + } + } + checkRes = SystemOverTimeCheck(DfhRelayCycNum, DfhRelayValidMaxTimeCount); + if (CI_TIME_OUT == checkRes) + { /*ȫֵ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õĿ*/ + } + } + else if (RELAY_STATE_DOWN == DFHRelayState) + {/*DFH̵Ϊ״̬*/ + tmpRet = SetSwitchDFHRelayValidCycNum(switchId, 0u); /*DHF̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + else + { + if ((RELAY_STATE_UP == ZDbRelayState) + && (RELAY_STATE_DOWN == ZFbRelayState)) + {/*ܷܶ¡DFH*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_DINGWEI);/*õλ*/ + + drvSwitchPos = GetSwitchDrivePostion(switchId); + if (SWITCH_DRIVE_POS_DINGWEI == drvSwitchPos) + {/*Ѿƶλ*/ + (void)SetRelayDriveState(YcRelayId, RELAY_STATE_DOWN);/*ʲټ̵*/ + (void)SetRelayDriveState(DcRelayId, RELAY_STATE_DOWN);/*öټ̵*/ + (void)SetRelayDriveState(FcRelayId, RELAY_STATE_DOWN);/*÷ټ̵*/ + } + } + else if ((RELAY_STATE_UP == ZFbRelayState) + && (RELAY_STATE_DOWN == ZDbRelayState)) + {/*ܷܶ¡DFH*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_FANWEI);/*õλ*/ + + drvSwitchPos = GetSwitchDrivePostion(switchId); + if (SWITCH_DRIVE_POS_FANWEI == drvSwitchPos) + {/*Ѿƶλ*/ + (void)SetRelayDriveState(YcRelayId, RELAY_STATE_DOWN);/*ʲټ̵*/ + (void)SetRelayDriveState(DcRelayId, RELAY_STATE_DOWN);/*öټ̵*/ + (void)SetRelayDriveState(FcRelayId, RELAY_STATE_DOWN);/*÷ټ̵*/ + } + } + else + {/*޴*/ + /*ȫֵ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õĿ*/ + } + } + } + else + { + /*ȫֵ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õĿ*/ + } + } + } + + /*µλ*/ + + /*õǰλúƶ*/ + if (DbRelayState == FbRelayState) + {/*ʧʾ*/ + if (RELAY_STATE_UP == DbRelayState) + {/*̵ΪĿ*/ + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + tmpRet = SetSingleSwitchYCRelayValCyc(switchId, 0u); /*YC̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + } + else + { + /*ʲټ̵*/ + if (0u != YcRelayId) + { + SigleYcRelayCycNum = GetSingleSwitchYCRelayValCyc(switchId); /*YC̵״̬*/ + + if (RELAY_STATE_UP == YcRelayState) + {/*ʲ*/ + tmpRet = SetSingleSwitchYCRelayValCyc(switchId, 0u); /*YC̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_MOVE);/*õǰλΪƶ*/ + tmpRet = SetSigleSwitchDFHRelayValCyc(switchId, 0u); /*DHF̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + } + else + {/*ƶ״̬*/ + if (0u == SigleYcRelayCycNum) + {/*δʱʼ*/ + tmpRet = SetSingleSwitchYCRelayValCyc(switchId, curCycNum); + if (CI_ERROR == tmpRet) + { + /**/ + } + else + { + SigleYcRelayCycNum = GetSingleSwitchYCRelayValCyc(switchId); /*YC̵״̬*/ + } + } + checkRes = SystemOverTimeCheck(SigleYcRelayCycNum, DfhRelayValidMaxTimeCount); + if (CI_TIME_OUT == checkRes) + { /*ȫֵ*/ + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õǰλΪĿ*/ + } + } + } + else + { + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õǰλΪĿ*/ + } + } + } + else + {/*ʾЧ*/ + tmpRet = SetSingleSwitchYCRelayValCyc(switchId, 0u); /*YC̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + + if (RELAY_STATE_UP == DbRelayState) + {/*̵*/ + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_DINGWEI);/*õλ*/ + } + else if (RELAY_STATE_UP == FbRelayState) + {/*̵*/ + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_FANWEI);/*õλ*/ + } + else + {/*޴*/ + + /*ȫֵ*/ + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI);/*õĿ*/ + } + } + /*һδΪ˼鵥ٵǷʱ*/ + + /*ʱǷѾʱ*/ + timeState = SystemOverTimeCheck(GetSwitchDriveStartCycNum(switchId), GetSystemParaSwitchDriveCyc()); + + if (CI_TIME_OUT == timeState) + {/*ʱ䳬ʱ*/ + + /*õǰλ*/ + drvSwitchPos = GetSwitchDrivePostion(switchId); + + /*ȡλ*/ + SwitchDanCaoPos = GetSwitchDanCaoPostition(switchId); + + if (((SWITCH_DRIVE_POS_DINGWEI == drvSwitchPos) && (SWITCH_POSITION_DINGWEI == SwitchDanCaoPos)) || + ((SWITCH_DRIVE_POS_FANWEI == drvSwitchPos) && (SWITCH_POSITION_FANWEI == SwitchDanCaoPos))) + { + /*Чλ*/ + (void)SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + } + + /*õʱλ*/ + SetSwitchDrivOvtmDrvPosition(switchId, drvSwitchPos); + SetSwitchPreExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);/*֮ǰλ*/ + SetSwitchDrivePostion(switchId, SWITCH_DRIVE_POS_INVALID);/*ʵλ*/ + } + + /*һδΪ˼鵥ٵǷλ*/ + + /*ٴλȡλ*/ + SwitchDanCaoPos = GetSwitchDanCaoPostition(switchId); + + /*ȡǰλ*/ + curSwitchPos = GetSwitchCurPosition(switchId); + + if ((SwitchDanCaoPos == curSwitchPos) && (SWITCH_POSITION_INVALID != SwitchDanCaoPos)) + {/*λ*/ + /*Чλ*/ + (void)SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + } + } + } + }/*for*/ +} + +/* zt ɾش 2022-02-15 */ +/* +* ָID̵ +* ˵ void +* ֵ +*/ +static void DriveSwitchRelayState(const UINT16 switchId, const UINT8 driveSwitchPos) +{ + UINT8 curSwitchPos = SWITCH_POSITION_INVALID; /*ǰλ*/ + if (driveSwitchPos == SWITCH_DRIVE_POS_DINGWEI) + {/*λ*/ + /*õһεЧλúʼ*/ + (void)SetSwitchLastValidDrvPos(switchId, driveSwitchPos); + (void)SetSwitchLastValidPosDrivCycNum(switchId, Get2oo2CurCycleNum()); + (void)SetRelayDriveState(GetSwitchYcRelayId(switchId), RELAY_STATE_UP);/*ʲټ̵*/ + (void)SetRelayDriveState(GetSwitchDcRelayId(switchId), RELAY_STATE_UP);/*öټ̵*/ + (void)SetRelayDriveState(GetSwitchFcRelayId(switchId), RELAY_STATE_DOWN);/*÷ټ̵*/ + } + else if (driveSwitchPos == SWITCH_DRIVE_POS_FANWEI) + {/*λ*/ + /*õһεЧλúʼ*/ + (void)SetSwitchLastValidDrvPos(switchId, driveSwitchPos); + (void)SetSwitchLastValidPosDrivCycNum(switchId, Get2oo2CurCycleNum()); + (void)SetRelayDriveState(GetSwitchYcRelayId(switchId), RELAY_STATE_UP);/*ʲټ̵*/ + (void)SetRelayDriveState(GetSwitchDcRelayId(switchId), RELAY_STATE_DOWN);/*öټ̵*/ + (void)SetRelayDriveState(GetSwitchFcRelayId(switchId), RELAY_STATE_UP);/*÷ټ̵*/ + } + else if (driveSwitchPos == SWITCH_DRIVE_POS_INVALID) + { + /*ǰλ*/ + curSwitchPos = GetSwitchCurPosition(switchId); + + if (curSwitchPos == SWITCH_POSITION_JICHA) + {/**/ + (void)SetRelayDriveState(GetSwitchYcRelayId(switchId), RELAY_STATE_DOWN);/*ʲټ̵*/ + (void)SetRelayDriveState(GetSwitchDcRelayId(switchId), RELAY_STATE_DOWN);/*öټ̵*/ + (void)SetRelayDriveState(GetSwitchFcRelayId(switchId), RELAY_STATE_DOWN);/*÷ټ̵*/ + } + else + { + /*̵ּ״̬*/ + } + } + else + { + /*޴*/ + (void)SetRelayDriveState(GetSwitchYcRelayId(switchId), RELAY_STATE_DOWN);/*ʲټ̵*/ + (void)SetRelayDriveState(GetSwitchDcRelayId(switchId), RELAY_STATE_DOWN);/*öټ̵*/ + (void)SetRelayDriveState(GetSwitchFcRelayId(switchId), RELAY_STATE_DOWN);/*÷ټ̵*/ + } +} +/* +* µ̵״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +void SwitchDeviceToRelayStateProc(void) +{ + UINT16 switchCurSum = 0u; /*Ŀ*/ + UINT8 localCiId = 0u; /*ID*/ + + UINT16 switchId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*ID*/ + UINT16 ii = 0u; /*ѭ*/ + + UINT8 curSwitchPos = SWITCH_POSITION_INVALID; /*ǰλ*/ + UINT8 driveSwitchPos = SWITCH_DRIVE_POS_INVALID; /*λ*/ + UINT8 curExpDrvSwitchPos = SWITCH_DRIVE_POS_INVALID; /*λ*/ + UINT8 preExpDrvSwitchPos = SWITCH_DRIVE_POS_INVALID; /*λ*/ + + UINT8 timeState = CI_TIME_NO; /*ʱ״̬*/ + + UINT8 switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_FALSE; /*߷״̬*/ + + UINT8 preSwitchDrivingState = SWIT_DRIV_IDLE_TIME; /*֮ǰĵ״̬*/ + UINT8 curSwitchDrivingState = SWIT_DRIV_IDLE_TIME; /*ǰĵ״̬*/ + + UINT8 SwitchDanCaoPosition = SWITCH_POSITION_INVALID;/*λ*/ + UINT8 lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ:0x55:ǹ콻ͨ0xAA:콻ͨ*/ + UINT8 chSwitchJichaState = 0U;/*״̬*/ + + switchCurSum = GetSwitchCurSum(); /*ȡ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + /*ٵ߼*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + SwitchDanCaoPosition = GetSwitchDanCaoPostition(switchId); + + if (SwitchDanCaoPosition == SWITCH_POSITION_DINGWEI) + {/*λ*/ + (void)SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_DINGWEI); + } + else if (SwitchDanCaoPosition == SWITCH_POSITION_FANWEI) + {/*λ*/ + (void)SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_FANWEI); + }/* zt ɾش 2022-02-15 */ + else + { + /*ʲôҲ*/ + } + } + } + }/*for*/ + + /*λô*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + curSwitchPos = GetSwitchCurPosition(switchId);/*ȡǰλ*/ + + curExpDrvSwitchPos = GetSwitchExpDrvPosition(switchId);/*ȡǰλ*/ + + /* zt ɾش 2022-02-15 */ + if (((curSwitchPos == SWITCH_POSITION_DINGWEI) && (curExpDrvSwitchPos == SWITCH_DRIVE_POS_DINGWEI)) + || ((curSwitchPos == SWITCH_POSITION_FANWEI) && (curExpDrvSwitchPos == SWITCH_DRIVE_POS_FANWEI))) + {/*λпʱɼJTYJa GZJ»TYJ*/ + (void)SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);/*Ȼλ,λΪЧ*/ + } + } + } + + }/*for*/ + + /*״̬*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + + curExpDrvSwitchPos = GetSwitchExpDrvPosition(switchId);/*ȡǰλ*/ + + preExpDrvSwitchPos = GetSwitchPreExpDrvPosition(switchId);/*ȡ֮ǰλ*/ + + preSwitchDrivingState = GetSwitchDrivingState(switchId);/*ȡ֮ǰʵ״̬*/ + + if (SWITCH_DRIVE_POS_INVALID == curExpDrvSwitchPos) + {/*ǰλЧ*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_IDLE_TIME);/*õ״̬Ϊ*/ + } + else + {/*ǰλЧ*/ + if (curExpDrvSwitchPos == preExpDrvSwitchPos) + {/*ƶǷѾʱ*//* zt ɾش 2022-02-15 */ + if (CI_TRADITION_RAILWAY == lineIdentity) + { /*нͨ*/ + timeState = SystemOverTimeCheck(GetSwitchMoveStartCycNum(switchId), GetSystemParaSwDrvCuoFengCnt()); + } + else + { + + } + + if (CI_TIME_NO == timeState) + {/*δ*/ + if (SWIT_DRIV_IDLE_TIME == preSwitchDrivingState) + {/*֮ǰĵ״̬Ϊ*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_WAIT_TIME);/*Ҫ,δʼ,һ,֮ǰ״̬Ϊ״̬,õ״̬Ϊȴ*/ + } + else if (SWIT_DRIV_PEAK_TIME == preSwitchDrivingState) + {/*֮ǰĵ״̬Ϊ߷*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_PEAK_TIME);/*Ҫ,δʼ,ijЩ,֮ǰ״̬Ϊ߷״̬,Ȼõ״̬Ϊ߷*/ + + switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_TRUE;/*õ߷״̬ΪTRUE,ʾҪĵе߷״̬*/ + } + else + { + /*޲*/ + } + } + else if (CI_TIME_IN == timeState) + {/*,ڴ*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_PEAK_TIME);/*Ҫ,ѿʼ,֮ǰ״̬,õ״̬Ϊ߷*/ + + switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_TRUE;/*õ߷״̬ΪTRUE,ʾҪĵе߷״̬*/ + } + else if (CI_TIME_OUT == timeState) + {/*,Ѷȹ*/ + SetSwitchDrivingState(switchId, SWIT_DRIV_FLAT_TIME);/*Ҫ,ѿʼʱ,֮ǰ״̬,õ״̬Ϊƽ*/ + } + else + { + /*ʲôҲ*/ + } + } + else + { + SetSwitchDrivingState(switchId, SWIT_DRIV_WAIT_TIME);/*õ״̬Ϊȴ*/ + } + } + } + } + }/*for*/ + + /*߼*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + curExpDrvSwitchPos = GetSwitchExpDrvPosition(switchId); + + curSwitchDrivingState = GetSwitchDrivingState(switchId); + + /*״̬*/ + if (SWIT_DRIV_IDLE_TIME == curSwitchDrivingState) + {/*״̬Ϊ*/ + /*ǰ״̬*/ + SetSwitchDrivePostion(switchId, SWITCH_DRIVE_POS_INVALID); + } + else if (SWIT_DRIV_WAIT_TIME == curSwitchDrivingState) + {/*״̬Ϊȴ*/ + if (SWIT_DRIV_PEAK_TIME_FALSE == switDrivPeakTimeState) + {/*ǰûе߷״̬*/ + SetSwitchDrivePostion(switchId, curExpDrvSwitchPos);/*Ϊû߷״̬,ʼ*/ + + SetSwitchDrivingState(switchId, SWIT_DRIV_PEAK_TIME);/*ʼ,õΪ߷״̬*/ + + switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_TRUE;/*õ߷״̬ΪTRUE,ʾҪĵе߷״̬*/ + } + else + { + SetSwitchDrivePostion(switchId, SWITCH_DRIVE_POS_INVALID); + } + } + else if (SWIT_DRIV_PEAK_TIME == curSwitchDrivingState) + {/*״̬Ϊ߷*/ + SetSwitchDrivePostion(switchId, curExpDrvSwitchPos); + + switDrivPeakTimeState = SWIT_DRIV_PEAK_TIME_TRUE;/*õ߷״̬ΪTRUE,ʾҪĵе߷״̬*/ + } + else if (SWIT_DRIV_FLAT_TIME == curSwitchDrivingState) + {/*״̬Ϊƽ*/ + SetSwitchDrivePostion(switchId, curExpDrvSwitchPos);/*ƽ״̬¼*/ + } + else + { + /*ʲôҲ*/ + } + } + } + }/*for*/ + + /*̵ɴ*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + /*̵*/ + + /*λ*/ + driveSwitchPos = GetSwitchDrivePostion(switchId); + /* zt ɾش 2022-02-15 */ + if (CI_TRADITION_RAILWAY == lineIdentity) + { /*нͨ*/ + DriveSwitchRelayState(switchId, driveSwitchPos); + } + else + { + } + + + } + + } + + }/*for*/ + + /*ڽн,λ*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + curExpDrvSwitchPos = GetSwitchExpDrvPosition(switchId); + + /*λ*/ + SetSwitchPreExpDrvPosition(switchId, curExpDrvSwitchPos); + } + + } + }/*for*/ + + /*λ,Ϊ˫ԭ,"λ""λ"*/ + for (ii = 0u; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0u != localCiId)) + { + /*λ*/ + (void)SetSwitchExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + /*ʱλ*/ + SetSwitchDrivOvtmDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID); + + chSwitchJichaState = GetSwitchPrompylyAlarmInfo(switchId); + /*ֻо̬Ͷ̬ãòһֱΪ0*/ + SetSwitchJichaState(switchId, chSwitchJichaState); + } + + } + }/*for*/ + + /* zt ɾش 2022-02-15 */ + +} + +/******************************ؼ̵****************************/ + +/* +* ռ״̬ +* ˵ const UINT32 curCycleNum, ǰں +* ֵ void +*/ +void PhySecRelayToDeviceStateProc(void) +{ + UINT16 phySecCurSum = 0u; /*Ŀ*/ + + UINT16 phySecId = 0u; /*ID*/ + UINT8 lockState = 0u;/*״̬*/ + UINT8 phyBelongCi = 0u; /*ID*/ + UINT16 gdRelayId = 0u; /*ι̵ID*/ + UINT16 wGdRelayId2 = 0U; /*˹ι̵ID2*/ + UINT16 ii = 0u; /*ѭ*/ + UINT16 preResetRelayId = 0u; /*μԤλ״̵̬ID*/ + UINT8 gdJdqState = 0u;/*̵״̬*/ + UINT8 chGdJdqState2 = 0u;/*̵״̬*/ + UINT8 presetJdqState = 0u;/*Ԥλ̵״̬*/ + + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 localCi = GetSystemParaLocalCiId();/**/ + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + UINT16 repGdRelayId = 0u;/*ӹ̵ID*/ + UINT8 repGdRelayBelongCi = 0u;/**/ + UINT8 goExec = CI_ERROR;/*Ƿִ*/ + UINT8 chDsnLinSwitch = 0U; + + chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + phySecCurSum = GetTotalPhySecCurNum(); /*ȡ*/ + + /**/ + for (ii = 0u; ii < phySecCurSum; ii++) + { + phySecId = 0u; /*ID*/ + phyBelongCi = 0u; /*ID*/ + gdRelayId = 0u; /*ι̵ID*/ + + + phySecId = GetPhySecId(ii); /*ȡID*/ + phyBelongCi = GetPhySecBelongCiId(phySecId); /*ȡID*/ + + if ((0u == phySecId) || (phySecId > PHYSICAL_SECTION_SUM_MAX)) + { + goExec = CI_ERROR; + } + else + { + goExec = CI_SUCCESS; + } + + if (CI_SUCCESS == goExec) + { + if ((phyBelongCi == localCi) && (localCi > 0u)) + { + gdRelayId = GetPhySecGdRelayId(phySecId); /*ȡι̵ID*/ + + gdJdqState = GetRelayCollState(gdRelayId);/*ȡ̵ɼ״̬*/ + if (FUNC_SWITCH_ON != chDsnLinSwitch) + { + if (RELAY_STATE_UP == gdJdqState) + {/*μ̵*/ + + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_NO);/*ùβɼ״̬*/ + + } + else if (RELAY_STATE_DOWN == gdJdqState) + {/*μ̵*/ + + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ùβɼ״̬ռ*/ + + } + else + {/*ڵ״̬*/ + /*ȫֵ*/ + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ùβɼ״̬ռ*/ + } + } + else + { + /*˹᲻*/ + if ((UINT16_MAX != gdRelayId) && (0U != gdRelayId)) + { + wGdRelayId2 = GetPhySecGdRelayId2(phySecId); /*ȡι̵ID*/ + + chGdJdqState2 = GetRelayCollState(wGdRelayId2);/*ȡ̵ɼ״̬*/ + if ((UINT16_MAX != wGdRelayId2) && (0U != wGdRelayId2)) + { + if ((RELAY_STATE_UP == gdJdqState) && (RELAY_STATE_UP == chGdJdqState2)) + {/*μ̵*/ + + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_NO);/*ùβɼ״̬*/ + + } + else if ((RELAY_STATE_DOWN == gdJdqState) && (RELAY_STATE_DOWN == chGdJdqState2)) + {/*μ̵*/ + + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ùβɼ״̬ռ*/ + + } + else + { + /*ȫֵ*/ + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ùβɼ״̬ռ*/ + + } + } + else + { + /*˹˫̵ȫֵ*/ + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ùβɼ״̬ռ*/ + } + } + else + { + /*Ϊ˹޼ᣬùռѹͨųռѹ ÿ*/ + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_NO);/*ùβɼ״̬*/ + } + } + preResetRelayId = GetPhySecPreResetRelayId(phySecId);/*ȡμԤλ״̵̬ID*/ + + presetJdqState = GetRelayCollState(preResetRelayId); + + if (0u != preResetRelayId) + {/*Ԥλ״̵̬IDЧ*/ + if (RELAY_STATE_UP == presetJdqState) + {/*Ԥλ̵*/ + SetPhySecPreResetState(phySecId, PHYSICAL_SECTION_PRE_RESET_YES); /*üԤλ״̬Ч*/ + } + else if (RELAY_STATE_DOWN == presetJdqState) + {/*Ԥλ̵*/ + SetPhySecPreResetState(phySecId, PHYSICAL_SECTION_PRE_RESET_NO); /*üԤλ״̬Ч*/ + } + else + {/*̵ɼ״̬Ϊ쳣ֵ*/ + SetPhySecPreResetState(phySecId, PHYSICAL_SECTION_PRE_RESET_NO); /*üԤλ״̬Ч*/ + } + } + else + { + /*Ԥλ״̵̬IDЧִ*/ + } + } + else if ((phyBelongCi != localCi) && (localCi > 0u)) + { + + repGdRelayId = GetPhySecRepGdRelayId(phySecId); + if (repGdRelayId > 0u) + { + repGdRelayBelongCi = GetRelayBelongCiId(repGdRelayId); + + commState = GetLocalCiAndOtherCiTransSta(phyBelongCi);/*ͨͨ״̬*/ + + if ((repGdRelayBelongCi == localCi) && (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + gdJdqState = GetRelayCollState(repGdRelayId);/*ȡ̵ɼ״̬*/ + + if (RELAY_STATE_UP == gdJdqState) + {/*μ̵*/ + + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_NO);/*ùβɼ״̬*/ +#if 0 + SetPhySecCurMergeState(phySecId, SECTION_OCCUPY_NO); + SetPhySecPreMergeState(phySecId, SECTION_OCCUPY_NO); +#endif + lockState = GetPhySecLockState(phySecId); + if (PHYSICAL_SECTION_LOCK_START == lockState) + { + SetPhySecLockState(phySecId, PHYSICAL_SECTION_LOCK_NO, 0, 0); + } + } + else if (RELAY_STATE_DOWN == gdJdqState) + {/*μ̵*/ + + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ùβɼ״̬ռ*/ + SetPhySecCurMergeState(phySecId, SECTION_OCCUPY_YES); + SetPhySecPreMergeState(phySecId, SECTION_OCCUPY_YES); + } + else + {/*ڵ״̬*/ + /*ȫֵ*/ + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ùβɼ״̬ռ*/ + } + + + } + } + } + else + { + /**/ + } + + } + + +} +} + +/* +* μḴλ̵״̬ +* ˵ void +* ֵ void +*/ +void PhySecResetToRelayStateProc(void) +{ + UINT8 const functionId = EFUNC_PHYSEC_RESET_TO_RELAY_STATE_PROC; /**/ + UINT16 phySecId = 0u; /*ID*/ + UINT16 ii = 0u; + UINT16 retValid = CI_ERROR; /*ܸλ̵״̬ЧֵĬΪЧ*/ + UINT8 retGeneralResetFlag = CI_PHYSEC_GENERAL_RESET_NO; + UINT8 localCi = 0u;/*CI*/ + UINT16 relayZFWId = 0u; /*ܸλ̵ID*/ + UINT8 relayZFWState = CI_ERROR; + UINT8 relayDrvAddrA = 0u; + UINT8 relayDrvPosA = 0u; + UINT8 relayDrvAddrB = 0u; + UINT8 relayDrvPosB = 0u; + UINT32 relayZFWCycNum = 0u; + UINT32 rZFWValidCycNum = 0u; + UINT32 rZFWcmdStartCycNum = 0u; + UINT32 curCycNum = 0u; + UINT8 checkRelayRes = CI_TIME_OUT; + UINT8 checkZFWValidRes = CI_TIME_OUT; + UINT8 checkZFWcmdRes = CI_TIME_OUT; + UINT8 tmpRet = CI_ERROR; + UINT8 occupyState = 0u; /*ռ״̬*/ + UINT32 startCycNum = 0u; /*ʼں*/ + UINT8 resetType = 0u; /*Ḵλ*/ + UINT8 preResetState = 0u; /*Ԥλ״̬*/ + UINT8 overTimeCheck = 0u; + + localCi = GetSystemParaLocalCiId(); + relayZFWId = GetZFWRelayId(localCi); /*ܸλ̵ID*/ + retGeneralResetFlag = GetPhySecGeneralResetFlag(); /*ȡμܸλ̵״̬Ч*/ + if (relayZFWId > 0u) + { + relayZFWState = GetRelayCollState(relayZFWId); /*ZFWJ̵ɼ״̬*/ + relayDrvAddrA = GetRelayDrvAddrA(relayZFWId); /*ZFWJ̵Aϵַ*/ + relayDrvPosA = GetRelayDrvPosA(relayZFWId); /*ZFWJ̵Aϵλ*/ + relayDrvAddrB = GetRelayDrvAddrB(relayZFWId); /*ZFWJ̵Bϵַ*/ + relayDrvPosB = GetRelayDrvPosB(relayZFWId); /*ZFWJ̵Bϵλ*/ + + relayZFWCycNum = GetRelayStateUpdateCycNum(relayZFWId); /*ZFWJ̵״̬*/ + rZFWValidCycNum = GetZFWValidCycNum(); /*ZFWJ״̬Ч*/ + curCycNum = Get2oo2CurCycleNum(); + rZFWcmdStartCycNum = GetZFWcmdStartCycNum(); + if ((RELAY_STATE_UP == relayZFWState)) + {/*ɼZFWJ*/ + if (CI_PHYSEC_GENERAL_RESET_YES == retGeneralResetFlag) + {/*ɼZFWJյܸλ*/ + tmpRet = SetRelayStateUpdateCycNum(relayZFWId, 0u); /*ZFWܸλ̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + retValid = CI_ERROR; + } + else + { + checkZFWValidRes = SystemOverTimeCheck(rZFWValidCycNum, GetZFWJRelayDriveTimeCount()); + if (CI_TIME_NO == checkZFWValidRes) + {/*δʱʼ*/ + SetZFWValidCycNum(curCycNum); /*ZFWܸλЧ*/ + /*Чִмܸλ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_UP);/*üܸλ̵*/ + retValid = CI_SUCCESS; + } + else if (CI_TIME_OUT == checkZFWValidRes) + {/*ܸλʱ*/ + SetZFWValidCycNum(0u); /*ZFWܸλЧ*/ + /*ִȡܸλ*/ + SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_NO); /*μܸλ̵״̬Ч*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_DOWN);/*üܸλ̵*/ + retValid = CI_ERROR; + } + else + {/*Чִмܸλ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_UP);/*üܸλ̵*/ + retValid = CI_SUCCESS; + } + } + } + else + {/*ɼZFWJδյܸλ*/ + checkRelayRes = SystemOverTimeCheck(relayZFWCycNum, ZFWJ_REYLAY_VALID_CYCLE_NUM); + if (CI_TIME_NO == checkRelayRes) + {/*δʱʼ*/ + tmpRet = SetRelayStateUpdateCycNum(relayZFWId, curCycNum);/*ZFWJܸλ̵Ч*/ + if (CI_ERROR == tmpRet) + { + /**/ + retValid = CI_ERROR; + } + } + else if (CI_TIME_OUT == checkRelayRes) + {/*ܸλʱ*/ + if ((relayDrvAddrA > 0u) && (relayDrvPosA > 0u) && (relayDrvAddrB > 0u) && (relayDrvPosB > 0u)) + {/*ûZFWJڲɼZFWJʱӸֵصıʾܸλ̵ߡ*/ + retValid = CI_ERROR; + SetZfwjHunXianFLag(ZFWJ_HUN_XIAN_YES); + } + else + {/*δZFWJɼԼִмḴλ*/ + retValid = CI_SUCCESS; + } + } + else + {/*δʱ*/ + retValid = CI_ERROR; + } + SetZFWValidCycNum(0u); /*ZFWܸλЧ*/ + /*ִȡܸλ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_DOWN);/*üܸλ̵*/ + } + } + else + {/*ɼZFWJ£ִмḴλ߼*/ + retValid = CI_ERROR; + tmpRet = SetRelayStateUpdateCycNum(relayZFWId, 0u); /*ZFWܸλ̵Чʼں*/ + + if (CI_ERROR == tmpRet) + { + /**/ + } + else + { + SetZFWValidCycNum(0u); /*ZFWܸλЧ*/ + if (CI_PHYSEC_GENERAL_RESET_YES == retGeneralResetFlag) + {/*Чִмܸλ*/ + /*յܸλʼ*/ + checkZFWcmdRes = SystemOverTimeCheck(rZFWcmdStartCycNum, ZFWJ_REYLAY_VALID_CYCLE_NUM); + if (CI_TIME_OUT == checkZFWcmdRes) + {/*ܸλʱ*/ + /*Чִмܸλ*/ + SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_NO); /*ܸλЧ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_DOWN);/*üܸλ̵*/ + } + else + {/*δʱ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_UP);/*üܸλ̵*/ + } + } + else + {/*Чִмܸλ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_DOWN);/*üܸλ̵*/ + } + } + } + } + else + {/*ܸλ̵ִмḴλ*/ + retValid = CI_SUCCESS; + } + + if (CI_SUCCESS == retValid) + {/*ЧִмḴλ*/ + for (ii = 0u; ii < GetPhySecCurSum(); ii++) + { + retValid = CI_ERROR; /*ܸλ̵״̬ЧֵλΪЧ*/ + phySecId = GetPhySecId(ii);/*ȡID*/ + + startCycNum = GetPhySecResetStartCycNum(phySecId); + if (startCycNum > 0u) /*Ḵλ*/ + { + occupyState = GetPhySecCurOccupyState(phySecId); + if (SECTION_OCCUPY_NO == occupyState) /*ɼ*/ + { + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + } + else /*ɼռ*/ + { + occupyState = GetPhySecCurTxOccupyState(phySecId); /*m by yt޸ȱݣʼͨųռãڼḴλУͨųռúδ⣬202283*/ + if (LOGICSECTION_OCCUPY_TX == occupyState) /*ͨųռ*/ + { + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, phySecId, ETYPE_PS_NO_UT_CT_OCU_STATE, occupyState, ESEND_LEVEL_ATS); + } + else + { + overTimeCheck = SystemOverTimeCheck(GetPhySecResetStartCycNum(phySecId), GetSystemParaSectionResetCount()); + if (CI_TIME_OUT == overTimeCheck) + {/*μḴλʱ*/ + + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ +#if 0 + SetCiSendCmdBackInfoData(CI_BACK_PSEC_RESET_ERROR, CI_DEVICE_TYPE_PHYSEC, phySecId, 0u, 0u);/*Ḵλʧ*/ +#endif + + } + else + { + retValid = GetZFWValidByPhySecId(phySecId); /*ȡμܸλ̵״̬Ч*/ + if (CI_SUCCESS == retValid) /*ЧִмḴλ*/ + { + resetType = GetPhySecSectionResetType(phySecId); + if (PHYSICAL_SECTION_PRE_RESET_NO == resetType) /*ֱӸλ*/ + { + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_UP);/*üḴλ̵*/ + } + else if (PHYSICAL_SECTION_PRE_RESET_YES == resetType) /*Ԥλ*/ + { + preResetState = GetPhySecPreResetState(phySecId); + if (PHYSICAL_SECTION_PRE_RESET_NO == preResetState) /*Ԥλδɹ*/ + { + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_UP);/*üḴλ̵*/ + } + else /*Ԥλɹ*/ + { + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + } + } + else /**/ + { + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + } + } + else /*Ч*/ + { + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + SetCiSendCmdBackInfoData(CI_BACK_PSEC_RESET_ZFW_ERROR, CI_DEVICE_TYPE_PHYSEC, phySecId, 0u, 0u);/*Ḵλʧܣܸλ̵*/ + } + } + } + } + } + } +} +} +/* +* μḴλ̵״̬ +* ˵ void +* ֵ void +*/ +void PhySecResetToRelayStateProc_Vir(UINT8 virCIid) +{ + UINT8 const functionId = EFUNC_PHYSEC_RESET_TO_RELAY_STATE_PROC; /**/ + UINT16 phySecId = 0u; /*ID*/ + UINT16 ii = 0u; + UINT16 retValid = CI_ERROR; /*ܸλ̵״̬ЧֵĬΪЧ*/ + UINT8 retGeneralResetFlag = CI_PHYSEC_GENERAL_RESET_NO; + UINT8 localCi = 0u;/*CI*/ + UINT16 relayZFWId = 0u; /*ܸλ̵ID*/ + UINT8 relayZFWState = CI_ERROR; + UINT8 relayDrvAddrA = 0u; + UINT8 relayDrvPosA = 0u; + UINT8 relayDrvAddrB = 0u; + UINT8 relayDrvPosB = 0u; + UINT32 relayZFWCycNum = 0u; + UINT32 rZFWValidCycNum = 0u; + UINT32 rZFWcmdStartCycNum = 0u; + UINT32 curCycNum = 0u; + UINT8 checkRelayRes = CI_TIME_OUT; + UINT8 checkZFWValidRes = CI_TIME_OUT; + UINT8 checkZFWcmdRes = CI_TIME_OUT; + UINT8 tmpRet = CI_ERROR; + UINT8 occupyState = 0u; /*ռ״̬*/ + UINT32 startCycNum = 0u; /*ʼں*/ + UINT8 resetType = 0u; /*Ḵλ*/ + UINT8 preResetState = 0u; /*Ԥλ״̬*/ + UINT8 overTimeCheck = 0u; + UINT8 belongVirCIid = 0u; + + localCi = GetSystemParaLocalCiId(); + relayZFWId = GetZFWRelayId_UseVirCI(localCi, virCIid); /*ܸλ̵ID*/ + retGeneralResetFlag = GetVirCIZfwFlag(virCIid); /*ȡμܸλ̵״̬Ч*/ + if (relayZFWId > 0u) + { + relayZFWState = GetRelayCollState(relayZFWId); /*ZFWJ̵ɼ״̬*/ + relayDrvAddrA = GetRelayDrvAddrA(relayZFWId); /*ZFWJ̵Aϵַ*/ + relayDrvPosA = GetRelayDrvPosA(relayZFWId); /*ZFWJ̵Aϵλ*/ + relayDrvAddrB = GetRelayDrvAddrB(relayZFWId); /*ZFWJ̵Bϵַ*/ + relayDrvPosB = GetRelayDrvPosB(relayZFWId); /*ZFWJ̵Bϵλ*/ + + relayZFWCycNum = GetRelayStateUpdateCycNum(relayZFWId); /*ZFWJ̵״̬*/ + + rZFWValidCycNum = GetVirCIZfwValidCycNum(virCIid);/*ZFWJ״̬Ч*/ + curCycNum = Get2oo2CurCycleNum(); + rZFWcmdStartCycNum = GetVirCIZfwStartCycNum(virCIid); + if ((RELAY_STATE_UP == relayZFWState)) + {/*ɼZFWJ*/ + if (CI_PHYSEC_GENERAL_RESET_YES == retGeneralResetFlag) + {/*ɼZFWJյܸλ*/ + tmpRet = SetRelayStateUpdateCycNum(relayZFWId, 0u); /*ZFWܸλ̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + retValid = CI_ERROR; + } + else + { + checkZFWValidRes = SystemOverTimeCheck(rZFWValidCycNum, GetZFWJRelayDriveTimeCount()); + if (CI_TIME_NO == checkZFWValidRes) + {/*δʱʼ*/ + SetVirCIZfwValidCycNum(virCIid, curCycNum); /*ZFWܸλЧ*/ + /*Чִмܸλ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_UP);/*üܸλ̵*/ + retValid = CI_SUCCESS; + } + else if (CI_TIME_OUT == checkZFWValidRes) + {/*ܸλʱ*/ + SetVirCIZfwValidCycNum(virCIid, 0u); /*ZFWܸλЧ*/ + /*ִȡܸλ*/ + SetPhySecZfwManage(virCIid, CI_PHYSEC_GENERAL_RESET_NO); /*μܸλ̵״̬Ч*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_DOWN);/*üܸλ̵*/ + retValid = CI_ERROR; + } + else + {/*Чִмܸλ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_UP);/*üܸλ̵*/ + retValid = CI_SUCCESS; + } + } + } + else + {/*ɼZFWJδյܸλ*/ + checkRelayRes = SystemOverTimeCheck(relayZFWCycNum, ZFWJ_REYLAY_VALID_CYCLE_NUM); + if (CI_TIME_NO == checkRelayRes) + {/*δʱʼ*/ + tmpRet = SetRelayStateUpdateCycNum(relayZFWId, curCycNum);/*ZFWJܸλ̵Ч*/ + if (CI_ERROR == tmpRet) + { + /**/ + retValid = CI_ERROR; + } + } + else if (CI_TIME_OUT == checkRelayRes) + {/*ܸλʱ*/ + if ((relayDrvAddrA > 0u) && (relayDrvPosA > 0u) && (relayDrvAddrB > 0u) && (relayDrvPosB > 0u)) + {/*ûZFWJڲɼZFWJʱӸֵصıʾܸλ̵ߡ*/ + retValid = CI_ERROR; + SetVirCIZfwHunxianFlag(virCIid, ZFWJ_HUN_XIAN_YES); + } + else + {/*δZFWJɼԼִмḴλ*/ + retValid = CI_SUCCESS; + } + } + else + {/*δʱ*/ + retValid = CI_ERROR; + } + SetVirCIZfwValidCycNum(virCIid, 0u); /*ZFWܸλЧ*/ + /*ִȡܸλ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_DOWN);/*üܸλ̵*/ + } + } + else + {/*ɼZFWJ£ִмḴλ߼*/ + retValid = CI_ERROR; + tmpRet = SetRelayStateUpdateCycNum(relayZFWId, 0u); /*ZFWܸλ̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + else + { + SetVirCIZfwValidCycNum(virCIid, 0u); /*ZFWܸλЧ*/ + if (CI_PHYSEC_GENERAL_RESET_YES == retGeneralResetFlag) + {/*Чִмܸλ*/ + /*յܸλʼ*/ + checkZFWcmdRes = SystemOverTimeCheck(rZFWcmdStartCycNum, ZFWJ_REYLAY_VALID_CYCLE_NUM); + if (CI_TIME_OUT == checkZFWcmdRes) + {/*ܸλʱ*/ + /*Чִмܸλ*/ + SetPhySecZfwManage(virCIid, CI_PHYSEC_GENERAL_RESET_NO); /*ܸλЧ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_DOWN);/*üܸλ̵*/ + } + else + {/*δʱ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_UP);/*üܸλ̵*/ + } + } + else + {/*Чִмܸλ*/ + (void)SetRelayDriveState(relayZFWId, RELAY_STATE_DOWN);/*üܸλ̵*/ + } + } + } + } + else + {/*ܸλ̵ִмḴλ*/ + retValid = CI_SUCCESS; + } + + if (CI_SUCCESS == retValid) + {/*ЧִмḴλ*/ + for (ii = 0u; ii < GetPhySecCurSum(); ii++) + { + retValid = CI_ERROR; /*ܸλ̵״̬ЧֵλΪЧ*/ + phySecId = GetPhySecId(ii);/*ȡID*/ + belongVirCIid = GetPhySecBelongVirCiId(phySecId); + + startCycNum = GetPhySecResetStartCycNum(phySecId); + if ((startCycNum > 0u) && (belongVirCIid == virCIid)) /*Ḵλ*/ + { + occupyState = GetPhySecCurOccupyState(phySecId); + if (SECTION_OCCUPY_NO == occupyState) /*ɼ*/ + { + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + } + else /*ɼռ*/ + { + occupyState = GetPhySecCurTxOccupyState(phySecId); /*m by yt޸ȱݣʼͨųռãڼḴλУͨųռúδ⣬202283*/ + if (LOGICSECTION_OCCUPY_TX == occupyState) /*ͨųռ*/ + { + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, phySecId, ETYPE_PS_NO_UT_CT_OCU_STATE, occupyState, ESEND_LEVEL_ATS); + } + else + { + overTimeCheck = SystemOverTimeCheck(GetPhySecResetStartCycNum(phySecId), GetSystemParaSectionResetCount()); + if (CI_TIME_OUT == overTimeCheck) + {/*μḴλʱ*/ + + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ +#if 0 + SetCiSendCmdBackInfoData(CI_BACK_PSEC_RESET_ERROR, CI_DEVICE_TYPE_PHYSEC, phySecId, 0u, 0u);/*Ḵλʧ*/ +#endif + + } + else + { + retValid = GetZFWValidByPhySecId(phySecId); /*ȡμܸλ̵״̬Ч*/ + if (CI_SUCCESS == retValid) /*ЧִмḴλ*/ + { + resetType = GetPhySecSectionResetType(phySecId); + if (PHYSICAL_SECTION_PRE_RESET_NO == resetType) /*ֱӸλ*/ + { + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_UP);/*üḴλ̵*/ + } + else if (PHYSICAL_SECTION_PRE_RESET_YES == resetType) /*Ԥλ*/ + { + preResetState = GetPhySecPreResetState(phySecId); + if (PHYSICAL_SECTION_PRE_RESET_NO == preResetState) /*Ԥλδɹ*/ + { + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_UP);/*üḴλ̵*/ + } + else /*Ԥλɹ*/ + { + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + } + } + else /**/ + { + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + } + } + else /*Ч*/ + { + SetPhySecResetStartCycNum(phySecId, 0u);/*޸ļḴλʼں*/ + (void)SetRelayDriveState(GetPhySecFWRelayId(phySecId), RELAY_STATE_DOWN);/*üḴλ̵*/ + SetCiSendCmdBackInfoData(CI_BACK_PSEC_RESET_ZFW_ERROR, CI_DEVICE_TYPE_PHYSEC, phySecId, 0u, 0u);/*Ḵλʧܣܸλ̵*/ + } + } + } + } + } + } +} +} + +/* +* μḴλ̵״̬ +* ˵ void +* ֵ void +*/ +void UpDataAllPhySecResetRelay_VirCI(void) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + UINT8 virCIid = 0u; + + virNum = GetVirtualCINum(); + for (i = 0u; i < virNum; i++) + { + virCIid = GetVirtualCIid(i); + if (0u < virCIid) + { + PhySecResetToRelayStateProc_Vir(virCIid); + } + } +} + +/******************************վ̨ؼ̵****************************/ + +/* +* ߼״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +void PsdRelayToDeviceStateProc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 psdSum = 0u; /*psd*/ + UINT16 psdId = 0u; /*ID*/ + UINT16 psdDoorRelayId = 0u; /*ſ״̵̬ID*/ + UINT16 wPsdDoorRelayId2 = 0u; /*ſ״̵̬ID*/ + UINT16 psdMutualLockRelayId = 0u;/*̵ID*/ + UINT16 wPsdMutualLockRelayId2 = 0u;/*̵ID*/ + UINT16 psdButtonRelayId = 0u; /*Űť̵*/ + UINT16 psdReopenButtonRelayId = 0u; /*PSDŰť̵*/ + UINT16 psdDepartureButtonRelayId = 0u; /*վ̨ť̵*/ + UINT8 psdDriState = 0u; /*һ״̬*/ + UINT16 psdRemoraId = 0u; /*ϰ̵*/ + UINT16 mutualLockId = 0u; /*϶̽⻥̵ID*/ + UINT8 chPsdRemoraState = 0U; + UINT8 chGapDecMutualLockState = 0U; + UINT8 chMutualLockState = 0U; + UINT8 chMutualLock2State = 0U; + UINT8 chPsdCloseState = 0U; + UINT8 chPsdClose2State = 0U; + UINT8 chPsdButtonState = 0U; + UINT8 chPsdReOpenRelayState = 0U; + UINT8 reVal = CI_SUCCESS; + UINT8 relayCollState = 0u; + UINT8 buttonState = 0u; + UINT32 buttonPressCycNum = 0U; + UINT32 curCycNum = 0U; + + UINT8 chPsdVirtualState = 0U; + UINT32 dwCycNum = 0U; + UINT8 chDsnLinSwitch = 0U; + + + chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + + psdSum = GetPsdSum(); + for (ii = 0u; ii < psdSum; ii++) + { + psdId = GetPsdId(ii); + if (0u == psdId) + { + reVal = CI_ERROR; + } + else + { + chPsdVirtualState = GetPsdVirtualAttribute(psdId); + if (PSD_VIRTUAL_ATTR_YES == chPsdVirtualState) + {/*ſ״̬²һ״̬*/ + psdDriState = GetPsdPreDriveState(psdId);/*ȡһ״̬*/ + if (PSD_DRIVE_STATE_OPEN == psdDriState) + {/**/ + reVal = SetPsdState(psdId,PSD_STATE_OPEN); + } + else if (PSD_DRIVE_STATE_CLOSE == psdDriState) + {/**/ + reVal = SetPsdState(psdId,PSD_STATE_CLOSE); + } + else + { + /*ʲô*/ + } + /*6by lyjŴʵPCB,POB,DPBť°ť״̬*/ + /*TSCIϲ 20221208-lc*/ + if (CI_SUCCESS == reVal) + { + psdButtonRelayId = GetDoorButtonRelayId(psdId); + /*Űť״̬*/ + if ((0u != psdButtonRelayId) && (UINT16_MAX != psdButtonRelayId)) + {/*PCBť̵IDЧ*/ + relayCollState = GetRelayCollState(psdButtonRelayId); + if (RELAY_STATE_UP == relayCollState) + { + buttonPressCycNum = GetPCBPressCycNum(psdId); + curCycNum = Get2oo2CurCycleNum(); + if (0U == buttonPressCycNum) + {/*δʱʼ*/ + (void)SetPCBPressCycNum(psdId, curCycNum); + } + buttonState = SetPsdButtonState(psdId, PSD_BUTTON_STATE_DOWN); + if (CI_ERROR == buttonState) + { + reVal = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + (void)SetPCBPressCycNum(psdId, 0u); /*PCBʼں*/ + buttonState = SetPsdButtonState(psdId, PSD_BUTTON_STATE_UP); + if (CI_ERROR == buttonState) + { + reVal = CI_ERROR; + } + } + else + { + (void)SetPCBPressCycNum(psdId, 0u); /*PCBʼں*/ + reVal = CI_ERROR; + } + } + else + {/*Щ·PSDPCBťPCBť̵IDЧcontinueִ*/ + } + } + + if (CI_SUCCESS == reVal) + { + psdReopenButtonRelayId = GetPsdReOpenRelayId(psdId); + /*ſŰť״̬*/ + if ((0u != psdReopenButtonRelayId) && (UINT16_MAX != psdReopenButtonRelayId)) + {/*վ̨Űť̵IDЧ*/ + relayCollState = GetRelayCollState(psdReopenButtonRelayId); + if (RELAY_STATE_UP == relayCollState) + { + buttonPressCycNum = GetPOBPressCycNum(psdId); + curCycNum = Get2oo2CurCycleNum(); + if (0U == buttonPressCycNum) + {/*δʱʼ*/ + (void)SetPOBPressCycNum(psdId, curCycNum); + } + buttonState = SetPsdOpenButtonState(psdId, PSD_OPEN_BUTTON_STATE_VALID); + if (CI_ERROR == buttonState) + { + reVal = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + (void)SetPOBPressCycNum(psdId, 0u); /*POBʼں*/ + buttonState = SetPsdOpenButtonState(psdId, PSD_OPEN_BUTTON_STATE_INVALID); + if (CI_ERROR == buttonState) + { + reVal = CI_ERROR; + } + } + else + { + (void)SetPOBPressCycNum(psdId, 0u); /*POBʼں*/ + reVal = CI_ERROR; + } + } + else + {/*Щ·PSDÿŰť̵continueִ*/ + } + } + + if (CI_SUCCESS == reVal) + { + psdDepartureButtonRelayId = GetPsdDeparConfmRelayId(psdId); + /*ŷť״̬*/ + if ((0u != psdDepartureButtonRelayId) && (UINT16_MAX != psdDepartureButtonRelayId)) + {/*վ̨ť̵IDЧ*/ + relayCollState = GetRelayCollState(psdDepartureButtonRelayId); + if (RELAY_STATE_UP == relayCollState) + { + buttonPressCycNum = GetPSBPressCycNum(psdId); + curCycNum = Get2oo2CurCycleNum(); + if (0U == buttonPressCycNum) + {/*δʱʼ*/ + (void)SetPSBPressCycNum(psdId, curCycNum); + } + buttonState = SetPsdDepartButtonState(psdId, PLATFORM_DEPAR_BUTTON_STATE_VALID); + if (CI_ERROR == buttonState) + { + reVal = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + (void)SetPSBPressCycNum(psdId, 0u); /*PSBʼں*/ + buttonState = SetPsdDepartButtonState(psdId, PLATFORM_DEPAR_BUTTON_STATE_INVALID); + if (CI_ERROR == buttonState) + { + reVal = CI_ERROR; + } + } + else + { + (void)SetPSBPressCycNum(psdId, 0u); /*PSBʼں*/ + reVal = CI_ERROR; + } + } + else + {/*Щ·PSD÷ť̵continueִ*/ + } + } + } + else + {/*ʵŲü̵״̬»״̬PCBť״̬*/ + psdMutualLockRelayId = GetPsdMutualLockRelayId(psdId); + wPsdMutualLockRelayId2 = GetPsdMutualLockRelayId2(psdId); + if (psdMutualLockRelayId > 0u) + { + if (FUNC_SWITCH_ON != chDsnLinSwitch) + {/*״̬*/ + chMutualLockState = GetRelayCollState(psdMutualLockRelayId); + if (RELAY_STATE_DOWN == chMutualLockState) + { + reVal = SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_NO); + + } + else if (RELAY_STATE_UP == chMutualLockState) + { + reVal = SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_YES); + + } + else + { + reVal = CI_ERROR; + } + } + else + { + /*˹·״̬ж*/ + chMutualLockState = GetRelayCollState(psdMutualLockRelayId); + chMutualLock2State = GetRelayCollState(wPsdMutualLockRelayId2); + if ((RELAY_STATE_DOWN == chMutualLockState) + && (RELAY_STATE_DOWN == chMutualLock2State)) + { + reVal = SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_NO); + } + else if ((RELAY_STATE_UP == chMutualLockState) + && (RELAY_STATE_UP == chMutualLock2State)) + { + reVal = SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_YES); + } + else + { + reVal = SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_NO); + } + } + } + + + if (reVal == CI_SUCCESS) + { + psdDoorRelayId = GetPsdStateRelayId(psdId); + wPsdDoorRelayId2 = GetPsdStateRelayId2(psdId); + if (psdDoorRelayId > 0u) + { + if (FUNC_SWITCH_ON != chDsnLinSwitch) + {/*ſ״̬*/ + chPsdCloseState = GetRelayCollState(psdDoorRelayId); + if (RELAY_STATE_UP == chPsdCloseState) + { + reVal = SetPsdState(psdId, PSD_STATE_CLOSE); + + } + else if (RELAY_STATE_DOWN == chPsdCloseState) + { + reVal = SetPsdState(psdId, PSD_STATE_OPEN); + + } + else + { + reVal = CI_ERROR; + } + } + else + { + chPsdCloseState = GetRelayCollState(psdDoorRelayId); + chPsdClose2State = GetRelayCollState(wPsdDoorRelayId2); + if ((RELAY_STATE_UP == chPsdCloseState) && (RELAY_STATE_UP == chPsdClose2State)) + { + reVal = SetPsdState(psdId, PSD_STATE_CLOSE); + + } + else if ((RELAY_STATE_DOWN == chPsdCloseState) && (RELAY_STATE_DOWN == chPsdClose2State)) + { + reVal = SetPsdState(psdId, PSD_STATE_OPEN); + + } + else + { + reVal = SetPsdState(psdId, PSD_STATE_OPEN); + } + } + } + + } + + if (reVal == CI_SUCCESS) + { + psdButtonRelayId = GetDoorButtonRelayId(psdId); + /*Űť״̬*/ + if ((0u != psdButtonRelayId) && (UINT16_MAX != psdButtonRelayId)) + {/*PCBť̵IDЧ*/ + chPsdButtonState = GetRelayCollState(psdButtonRelayId); + if (RELAY_STATE_UP == chPsdButtonState) + { + dwCycNum = GetPCBPressCycNum(psdId); + if (0u == dwCycNum) + {/*δʱʼ*/ + (void)SetPCBPressCycNum(psdId, Get2oo2CurCycleNum()); + } + reVal = SetPsdButtonState(psdId, PSD_BUTTON_STATE_DOWN); + } + else if (RELAY_STATE_DOWN == chPsdButtonState) + { + (void)SetPCBPressCycNum(psdId, 0u); /*PCBʼں*/ + reVal = SetPsdButtonState(psdId, PSD_BUTTON_STATE_UP); + } + else + { + (void)SetPCBPressCycNum(psdId, 0u); /*PCBʼں*/ + reVal = CI_ERROR; + } + } + else + {/*Щ·PSDPCBťPCBť̵IDЧcontinueִ*/ + } + + } + if (reVal == CI_SUCCESS) + { + psdRemoraId = GetPsdObtacleRelayId(psdId); + /*ϰ״̬£»2018.11.07*/ + if ((0u != psdRemoraId) && (UINT16_MAX != psdRemoraId)) + {/*ϰ̵IDЧ*/ + chPsdRemoraState = GetRelayCollState(psdRemoraId); + if (RELAY_STATE_UP == chPsdRemoraState) + { /*ϰ̵ʾϰ±ʾϰ*/ + reVal = SetPsdRemoraState(psdId, PSD_REMORA_NO); + } + else if (RELAY_STATE_DOWN == chPsdRemoraState) + { + reVal = SetPsdRemoraState(psdId, PSD_REMORA_YES); + } + else + { + reVal = CI_ERROR; + } + } + } + if (reVal == CI_SUCCESS) + { /*϶̽⻥Ϣ*/ + mutualLockId = GetPsdGapDetMuLockelayId(psdId); + /*ϰ״̬£»2018.11.07*/ + if ((0u != mutualLockId) && (UINT16_MAX != mutualLockId)) + {/*ϰ̵IDЧ*/ + chGapDecMutualLockState = GetRelayCollState(mutualLockId); + if (RELAY_STATE_UP == chGapDecMutualLockState) + { /*϶̽⻥ʾѻ±ʾ޻*/ + reVal = SetJXTCMutualLockState(psdId, JXTC_MUTUALLOCK_REMOVE_YES); + } + else if (RELAY_STATE_DOWN == chGapDecMutualLockState) + { + reVal = SetJXTCMutualLockState(psdId, JXTC_MUTUALLOCK_REMOVE_NO); + } + else + { + reVal = CI_ERROR; + } + } + + } + if (reVal == CI_SUCCESS) + { + psdReopenButtonRelayId = GetPsdReOpenRelayId(psdId); + /*ſŰť״̬*/ + if ((0u != psdReopenButtonRelayId) && (UINT16_MAX != psdReopenButtonRelayId)) + {/*վ̨Űť̵IDЧ*/ + chPsdReOpenRelayState = GetRelayCollState(psdReopenButtonRelayId); + if (RELAY_STATE_UP == chPsdReOpenRelayState) + { + dwCycNum = GetPOBPressCycNum(psdId); + if (0u == dwCycNum) + {/*δʱʼ*/ + (void)SetPOBPressCycNum(psdId, Get2oo2CurCycleNum()); + } + reVal = SetPsdOpenButtonState(psdId, PSD_OPEN_BUTTON_STATE_VALID); + } + else if (RELAY_STATE_DOWN == chPsdReOpenRelayState) + { + (void)SetPOBPressCycNum(psdId, 0u); /*POBʼں*/ + reVal = SetPsdOpenButtonState(psdId, PSD_OPEN_BUTTON_STATE_INVALID); + } + else + { + (void)SetPOBPressCycNum(psdId, 0u); /*POBʼں*/ + reVal = CI_ERROR; + } + } + else + {/*Щ·PSDÿŰť̵continueִ*/ + } + + } + + if (reVal == CI_SUCCESS) + {/*PDBť״̬-PSLſPDBťȷPDBťһĴ*/ + reVal = PsdCleFarePDBRelToDevStaProc(psdId); + } + + if (reVal == CI_SUCCESS) + {/*ȷŰť״̬*//*by cgh 20230526*/ + reVal = PsdCleFarePCBRelToDevStaProc(psdId); + } + } + + } + if (reVal == CI_ERROR) + { + break; + } + } +} + +#if 0 +/* +* ״̬תƴ +* ˵ void +* ֵ void +*/ +void PsdStateTransferProc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; + UINT16 psdId = 0u; /*ID*/ + UINT8 vobcToCiDataSum = GetVobcToCiSum(); + UINT16* routeIdBuf = NULL; + UINT8* PsdOpenedBeforeSigCloseFlagBuf = NULL; + RouteNearPhySectionStruct* routeNearPhySectionStruct = NULL; + UINT16 phySecId = 0u; + UINT8 routeSum = 0u; + + + VobcToCiDataStruct* vobcToCiDataStru = GetVobcToCiDataStru(); + for (ii = 0u; ii < vobcToCiDataSum; ii++) + { + for (jj = 0u; jj < vobcToCiDataStru[ii].PsdSum; jj++) + { + psdId = vobcToCiDataStru[ii].PsdData[jj].PsdId; + /*״̬תƴ*/ + switch (GetPsdStateTransferFlag(psdId)) + { + case PSD_INITIAL_STATE: + SetBuildedOutStationRouteSum(psdId, 0u); + break; + case PSD_OPEN_CMD: + if ((Get2oo2CurCycleNum() - vobcToCiDataStru[ii].PsdData[jj].CmdStartCycNum) > GetCiAndVobcTransBadEnsureCnt()) + {/*Ѿʱ*/ + if (PSD_STATE_OPEN != GetPsdState(psdId)) + {/*ŻδɹPsdStateTransferFlag ָɳʼ״̬*/ + SetPsdStateTransferFlag(psdId, PSD_INITIAL_STATE); + SetBuildedOutStationRouteSum(psdId, 0u); + } + } + else + {/*δʱ*/ + if (PSD_STATE_OPEN == GetPsdState(psdId)) + {/*ųɹPsdStateTransferFlag תƵųɹ״̬*/ + SetPsdStateTransferFlag(psdId, PSD_OPEN_STATE); + + } + } + break; + case PSD_OPEN_STATE: + CalculatePsdOpenedLeadToSignalCloseRoute(psdId, 0u);/*ſ³վ·źŹرյijվ·м¼*/ + if ((Get2oo2CurCycleNum() - vobcToCiDataStru[ii].PsdData[jj].CmdStartCycNum) > GetCiAndVobcTransBadEnsureCnt()) + {/*Ѿʱ*/ + if ((PSD_STATE_CLOSE == GetPsdState(psdId)) || + (PSD_MUTUALLOCK_REMOVE_YES == GetPsdMutualLockRemoveState(psdId))) + {/*ûյȴرգPsdStateTransferFlag ָɳʼ״̬*/ + SetPsdStateTransferFlag(psdId, PSD_INITIAL_STATE); + SetBuildedOutStationRouteSum(psdId, 0u); + } + } + break; + case PSD_CLOSE_CMD: + if ((Get2oo2CurCycleNum() - vobcToCiDataStru[ii].PsdData[jj].CmdStartCycNum) > GetCiAndVobcTransBadEnsureCnt()) + {/*Ѿʱ*/ + if ((PSD_STATE_CLOSE != GetPsdState(psdId)) && + (PSD_MUTUALLOCK_REMOVE_YES != GetPsdMutualLockRemoveState(psdId))) + { /*ѾʱδɹرգPsdStateTransferFlag ָɳʼ״̬*/ + SetPsdStateTransferFlag(psdId, PSD_INITIAL_STATE); + SetBuildedOutStationRouteSum(psdId, 0u); + } + + + } + else + { + if ((PSD_STATE_CLOSE == GetPsdState(psdId)) || + (PSD_MUTUALLOCK_REMOVE_YES == GetPsdMutualLockRemoveState(psdId))) + {/*ųɹرգPsdStateTransferFlag תƵųɹر״̬*/ + SetPsdStateTransferFlag(psdId, PSD_CLOSE_STATE); + } + + } + break; + case PSD_CLOSE_STATE: + /*ʲôҲ*/ + break; + default: + break; + } + + /*źؿ*/ + if (PSD_CLOSE_STATE == GetPsdStateTransferFlag(psdId)) + {/*״̬תһ*/ + routeSum = GetBuildedOutStationRouteSum(psdId); /*ȡŴɳվ·źŹرյijվ·Ŀ*/ + routeIdBuf = GetBuildedOutStationRouteIdBuf(psdId);/*ȡŴɳվ·źŹرյijվ·Id*/ + PsdOpenedBeforeSigCloseFlagBuf = GetPsdOpenBeforeOutStationRouteIsBuildedFlagBuf(psdId); + if ((1 == routeSum) && (PSD_OPEN_BEFORE_SIG_CLOSE_NO == PsdOpenedBeforeSigCloseFlagBuf[0u])) + {/*һѾijվ·(Զ· && źŹرſ֮):Դ˳վ·ؿźż봦*/ + + routeNearPhySectionStruct = GetRouteBlocNearPhySectionStru(routeIdBuf[0u]);/*ȡ·ӽνṹ*/ + if (NULL != routeNearPhySectionStruct) + {/*ڽӽ*/ + phySecId = routeNearPhySectionStruct[0u].NearPhySecIdBuf[0u];/*ȡӽεһID*/ + if (0u == phySecId) + {/*һIDΪ0u*/ + SetPsdStateTransferFlag(psdId, PSD_INITIAL_STATE); + SetBuildedOutStationRouteSum(psdId, 0u); + } + else + {/*ҵӽεһID*/ + if (0u != GetSecCurOccupyStartCycNum(phySecId)) + {/*г˳ռѹվ̨*/ + SetRouteRepeatOpenFlag(routeIdBuf[0u], ROUTE_REPEATOPEN_SET_YES); /*ý·źؿ־*/ + SetRouteOpenSigStartCycNum(routeIdBuf[0u], Get2oo2CurCycleNum()); /*źſʱ*/ + SetPsdStateTransferFlag(psdId, PSD_INITIAL_STATE); + SetBuildedOutStationRouteSum(psdId, 0u); + } + else + {/*ռü˳ռ*/ + SetPsdStateTransferFlag(psdId, PSD_INITIAL_STATE); + SetBuildedOutStationRouteSum(psdId, 0u); + } + } + } + else + {/*ڽӽ*/ + SetPsdStateTransferFlag(psdId, PSD_INITIAL_STATE); + SetBuildedOutStationRouteSum(psdId, 0u); + } + + } + else + {/*δվ· || 1վ· :ؿź*/ + SetPsdStateTransferFlag(psdId, PSD_INITIAL_STATE); + SetBuildedOutStationRouteSum(psdId, 0u); + } + } + } + } + + + +} +#endif + + +/* +* ż̵״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +UINT8 PsdDeviceToRelayStateProc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 psdSum = 0u; /*psd*/ + UINT16 psdId = 0u; /*ID*/ + UINT16 psdKMRelayId = 0u;/*ż̵ID*/ + UINT16 tmpPsdKMRelayId = 0u;/*ż̵ID*/ + UINT16 psdGMRelayId = 0u;/*ż̵ID*/ + UINT16 psdEditGroupInfo = 0u;/*űϢ*/ + UINT8 vobcInterFlag = 0u;/*vobcӿڱʶ*/ + UINT16 startJXTCRelayId = 0u; /*϶̵̽ID*/ + UINT16 stopJXTCRelayId = 0u; /*ֹͣ϶̵̽ID*/ + UINT16 vobcDoorStateRelayId = 0u; /*Ź״̵̬ID*/ + UINT8 reVal = CI_SUCCESS; + UINT8 doorState = 0u;/*״̵̬*/ + UINT8 JXCTInterfaceType = 0u; + UINT8 psdDriveState = 0u; + UINT8 JXTCStartState = 0u; + UINT8 JXTCStopState = 0u; + UINT8 psdVirtualState = 0u; + UINT8 relayFlag = CI_ERROR; + + vobcInterFlag = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡVOBCӿڱʶ*/ + + + psdSum = GetPsdSum(); + for (ii = 0u; ii < psdSum; ii++) + { + psdId = GetPsdId(ii); + psdVirtualState = GetPsdVirtualAttribute(psdId); + if (PSD_VIRTUAL_ATTR_NO == psdVirtualState) + {/*Ųؼ̵*/ + psdEditGroupInfo = GetPsdEditGroupInfoFromPsdData(psdId); + /*鶨ͳһ*/ + if ((LINE_HLHT == vobcInterFlag) || (LINE_FAOHLHT == vobcInterFlag) || (LINE_FAOHLHT_ONESELF == vobcInterFlag) || (LINE_FAOHLHT_ONESELFSECOND == vobcInterFlag)) + { + /*ͨFAOͨıϢVOBC*/ + } + else if (LINE_FAO == vobcInterFlag) + { + if (PSD_FOUR_EDIT_GROUP_FAO_YF == psdEditGroupInfo)/*෿4*/ + { + psdEditGroupInfo = PSD_FOUR_EDIT_GROUP; + } + else if (PSD_SIX_EDIT_GROUP_FAO_YF == psdEditGroupInfo)/*෿6*/ + { + psdEditGroupInfo = PSD_SIX_EDIT_GROUP; + } + else + { + /*Ϣ*/ + } + } + else + { + /*·Ϣdo nothing*/ + } + + if (PSD_FOUR_EDIT_GROUP == psdEditGroupInfo) + {/*ı*/ + psdKMRelayId = GetFourGroupPsdOpenDrvRelayId(psdId); + } + else if (PSD_SIX_EDIT_GROUP == psdEditGroupInfo) + {/**/ + psdKMRelayId = GetSixGroupPsdOpenDrvRelayId(psdId); + } + else if (PSD_EIGHT_EDIT_GROUP == psdEditGroupInfo) + {/*˱*/ + psdKMRelayId = GetEightGroupPsdOpenDrvRelayId(psdId); + } + else + {/*Ч*/ + psdKMRelayId = 0u; + } + psdGMRelayId = GetPsdCloseDriveRelayId(psdId); + psdDriveState = GetPsdDriveState(psdId); + + if (PSD_DRIVE_STATE_CLOSE == psdDriveState)/*Ϊ*/ + { + relayFlag = SetRelayDriveState(psdGMRelayId, RELAY_DRIVE_STATE_UP); + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + else + { + tmpPsdKMRelayId = GetFourGroupPsdOpenDrvRelayId(psdId); + if (tmpPsdKMRelayId > 0u) + { + relayFlag = SetRelayDriveState(tmpPsdKMRelayId, RELAY_DRIVE_STATE_DOWN); + /*пż̵*/ + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + + } + tmpPsdKMRelayId = GetSixGroupPsdOpenDrvRelayId(psdId); + if (tmpPsdKMRelayId > 0u) + { + relayFlag = SetRelayDriveState(tmpPsdKMRelayId, RELAY_DRIVE_STATE_DOWN); + /*пż̵*/ + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + } + + + tmpPsdKMRelayId = GetEightGroupPsdOpenDrvRelayId(psdId); + if (tmpPsdKMRelayId > 0u) + { + /*пż̵*/ + relayFlag = SetRelayDriveState(tmpPsdKMRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + } + + } + } + else if (PSD_DRIVE_STATE_OPEN == psdDriveState)/*Ϊ*/ + { + if (0u != psdKMRelayId) + {/*ȡ̵Ч*/ + /*޸ǰʱӦVOBCĿPSDЧ*/ + /*޸ĺ󣺶ʱжǷ״̬仯*/ + relayFlag = SetRelayDriveState(psdGMRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + else + { + relayFlag = SetRelayDriveState(psdKMRelayId, RELAY_DRIVE_STATE_UP); + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + } + + + } + } + else if (PSD_DRIVE_STATE_INVALID == psdDriveState) + {/*Ч*/ + relayFlag = SetRelayDriveState(psdGMRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + else + { + tmpPsdKMRelayId = GetFourGroupPsdOpenDrvRelayId(psdId); + if (tmpPsdKMRelayId > 0u) + { + /*пż̵*/ + relayFlag = SetRelayDriveState(tmpPsdKMRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + + } + tmpPsdKMRelayId = GetSixGroupPsdOpenDrvRelayId(psdId); + if (tmpPsdKMRelayId > 0u) + { + /*пż̵*/ + relayFlag = SetRelayDriveState(tmpPsdKMRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + } + + + tmpPsdKMRelayId = GetEightGroupPsdOpenDrvRelayId(psdId); + if (tmpPsdKMRelayId > 0u) + { + /*пż̵*/ + relayFlag = SetRelayDriveState(tmpPsdKMRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*ż̵*/ + reVal = CI_ERROR; + } + } + } + } + else + {/*Ӧֵֵ*/ + reVal = CI_ERROR; + } + + if ((LINE_FAOHLHT == vobcInterFlag)||(LINE_CC == vobcInterFlag) || (LINE_FAOHLHT_ONESELF == vobcInterFlag) || (LINE_FAOHLHT_ONESELFSECOND == vobcInterFlag)) + {/*ǰֻлͨFAO·м϶̽⹦*/ + /*VOBC϶ֹ̽ͣ϶̽Ӧ̵*/ + startJXTCRelayId = GetPsdDetStartRelayId(psdId); /*ȡ϶̵̽ID*/ + stopJXTCRelayId = GetPsdDetStopRelayId(psdId); /*ȡֹͣ϶̵̽ID*/ + JXCTInterfaceType = GetCiFunctionSwitchConfig(FUNC_JXTC_INTERFACE_MODE);/*ȡӿڷʽ*/ + /*϶̵̽IDЧ*/ + if ((0u != startJXTCRelayId) && (0u != stopJXTCRelayId)) + { + /**/ + if (FUNC_SWITCH_ON == JXCTInterfaceType) + { + /*ֹͣ*/ + ProcessJXTCPulseInterfStartDrv(startJXTCRelayId, stopJXTCRelayId, psdId); + ProcessJXTCPulseInterfStopDrv(startJXTCRelayId, stopJXTCRelayId, psdId); + + } + /*ƽģʽ*/ + else + { + JXTCStartState = GetStartDetectionState(psdId); + JXTCStopState = GetStopDetectionState(psdId); + if (JXTC_START_DETECTION_YES == JXTCStartState) + { + if (0u == GetStartDetectionCycNum(psdId)) + {/*δʱ̵̽*/ + SetStartDetectionCycNum(psdId, Get2oo2CurCycleNum()); + } + relayFlag = SetRelayDriveState(startJXTCRelayId, RELAY_DRIVE_STATE_UP); + if (CI_ERROR == relayFlag) + {/*̵̽*/ + reVal = CI_ERROR; + } + else + { + relayFlag = SetRelayDriveState(stopJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*̵ֹͣ̽*/ + reVal = CI_ERROR; + } + } + } + else + { + SetStartDetectionCycNum(psdId, 0u); /*϶̽⿪ʼʱ*/ + relayFlag = SetRelayDriveState(startJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*̵̽*/ + reVal = CI_ERROR; + } + } + + /*ֹͣ϶̵̽IDЧ*/ + if (JXTC_STOP_DETECTION_YES == JXTCStopState) + { /*ֹͣ̽״̬ʱ̵ֹͣ̽*/ + relayFlag = SetRelayDriveState(stopJXTCRelayId, RELAY_DRIVE_STATE_UP); + if (CI_ERROR == relayFlag) + {/*̵ֹͣ̽*/ + reVal = CI_ERROR; + } + else + { + relayFlag = SetRelayDriveState(startJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*̵̽*/ + reVal = CI_ERROR; + } + } + } + else + { + relayFlag = SetRelayDriveState(stopJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*̵ֹͣ̽*/ + reVal = CI_ERROR; + } + } + } + } + + vobcDoorStateRelayId = GetPsdDoorStateRelayId(psdId); /*ȡŹ״̵̬ID*/ + if (0u != vobcDoorStateRelayId) + {/*ȡŹ״̵̬IDЧ*/ + doorState = GetVOBCDoorState(psdId); + if (PSD_DOOR_CLOSEDANDLOCKED_VALID == doorState) + {/*Ź״̬Ϊر*/ + relayFlag = SetRelayDriveState(vobcDoorStateRelayId, RELAY_DRIVE_STATE_UP); + if (CI_ERROR == relayFlag) + {/*Źż̵*/ + reVal = CI_ERROR; + } + } + else if (PSD_DOOR_CLOSEDANDLOCKED_INVALID == doorState) + {/*Ź״̬Ϊǹر*/ + relayFlag = SetRelayDriveState(vobcDoorStateRelayId, RELAY_DRIVE_STATE_DOWN); + if (CI_ERROR == relayFlag) + {/*ֹͣŹż̵*/ + reVal = CI_ERROR; + } + } + else + { + /*Ź״̬Ч޲̵*/ + } + } + /*վ̨ͣȵƴ*/ + StationCearPassenagerProcess(psdId); + /*by cgh ɶ--ȷ䷢ťָʾƴ*/ + PsdCleFarePDBFlashProcess(psdId); + /*ɶ132730ٿ/ٹŰťʾƴ*/ + PsdOpenAndCloseBsdProc(psdId); + /*by cgh Ƶʹ*/ + PsdVideoQkDriveStateProc(psdId); + } + } + else + { + /*ŻԻȡʧ*/ + } + } + + return reVal; +} + +/* +* ϶̽ӿڷʽ +* ˵ UINT16 startJXTCRelayId ̵ + UINT16 stopJXTCRelayId ̵ֹͣ + UINT16 psdId ID +* ֵ +*/ +void ProcessJXTCPulseInterfStartDrv(UINT16 startJXTCRelayId, UINT16 stopJXTCRelayId, UINT16 psdId) +{ + /*ʼ*/ + UINT32 JXTCStarCycNum = 0u; + UINT8 JXTCState = 0u; /*϶̽״̬*/ + UINT8 jxtcStarFlag = 0u; + UINT8 startRelayState = 0u; /*̵״̬*/ + UINT32 JXTCdriveCount = 0u; + UINT8 secStopTimeState = 0u; + UINT32 JXTCStartCount = 0u; + UINT32 CIPresentCycNum = 0u; + UINT8 jxtcStopCmdState = 0u; + UINT8 jxtcStartCmdState = 0u; + + + /*ȡʼֵ*/ + JXTCStarCycNum = GetStartDetectionCycNum(psdId); + CIPresentCycNum = Get2oo2CurCycleNum(); + jxtcStartCmdState = GetStartDetectionState(psdId); + jxtcStopCmdState = GetStopDetectionState(psdId); + jxtcStarFlag = GetJXTCDriveStartFlag(psdId); + + /*϶̽*/ + if ((JXTC_START_DETECTION_YES == jxtcStartCmdState) && (JXTC_STOP_DETECTION_NO == jxtcStopCmdState)) + { + /*δֹͣ*/ + SetJXTCDriveStopFlag(psdId, JXTC_DRIVE_START_STOP_NO); + /*϶̽־δ*/ + if (JXTC_DRIVE_START_STOP_NO == jxtcStarFlag) + { + if (0u == JXTCStarCycNum) + {/*δʱ̵̽*/ + SetStartDetectionCycNum(psdId, CIPresentCycNum); + } + + /*ֹͣ*/ + (void)SetRelayDriveState(stopJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + + /*ȡ϶̽״̬ʼ״̬״̬״̬*/ + JXTCState = GetJXTCStartState(psdId); + /*ʼ״̬*/ + if (JXTC_NO_DRIVE_STATE == JXTCState) + { + /*ʱʱ*/ + SetJXTCStartUpCycNum(psdId, 0u); + /*̵*/ + (void)SetRelayDriveState(startJXTCRelayId, RELAY_DRIVE_STATE_UP); + + /*ɼ*/ + startRelayState = GetRelayCollState(startJXTCRelayId); + if (RELAY_STATE_UP == startRelayState) + { + /*ü϶̽⿪ʼ̵*/ + SetJXTCStartUpCycNum(psdId, CIPresentCycNum); + /*״̬2*/ + SetJXTCStartState(psdId, JXTC_DRIVE_UP_KEEP_STATE); + } + } + /*2һʱ*/ + else if (JXTC_DRIVE_UP_KEEP_STATE == JXTCState) + { + /**/ + (void)SetRelayDriveState(startJXTCRelayId, RELAY_DRIVE_STATE_UP); + /*ʱ*/ + JXTCStartCount = GetJXTCStartUpCycNum(psdId); + JXTCdriveCount = GetJXTCPulseContinueTimeCount(); + secStopTimeState = SystemOverTimeCheck(JXTCStartCount, JXTCdriveCount); + startRelayState = GetRelayCollState(startJXTCRelayId); + /*ʱ*/ + if (CI_TIME_OUT == secStopTimeState) + { + /*3*/ + SetJXTCStartState(psdId, JXTC_DRIVE_DOWN_STATE); + } + else + { + /*ɼ£ز1*/ + if (RELAY_STATE_DOWN == startRelayState) + { + SetJXTCStartState(psdId, JXTC_NO_DRIVE_STATE); + } + } + } + /*3ز£ת*/ + else if (JXTC_DRIVE_DOWN_STATE == JXTCState) + { + /**/ + (void)SetRelayDriveState(startJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + startRelayState = GetRelayCollState(startJXTCRelayId); + /*ɼ*/ + if (RELAY_STATE_DOWN == startRelayState) + { + /*ص1*/ + SetJXTCStartState(psdId, JXTC_NO_DRIVE_STATE); + /*־*/ + SetJXTCDriveStartFlag(psdId, JXTC_DRIVE_START_STOP_YES); + } + } + else + { + /*1*/ + SetJXTCStartState(psdId, JXTC_NO_DRIVE_STATE); + } + } + } + /*϶̽Ч*/ + else + { + SetStartDetectionCycNum(psdId, 0u); /*϶̽⿪ʼʱ*/ + (void)SetRelayDriveState(startJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + /*ʱΪ1*/ + SetJXTCStartState(psdId, JXTC_NO_DRIVE_STATE); + SetJXTCStartUpCycNum(psdId, 0u); + /*û*/ + SetJXTCDriveStartFlag(psdId, JXTC_DRIVE_START_STOP_NO); + } +} + +/* +* ϶̽ӿڷʽֹͣ +* ˵ UINT16 startJXTCRelayId ̵ + UINT16 stopJXTCRelayId ̵ֹͣ + UINT16 psdId ID +* ֵ +*/ +void ProcessJXTCPulseInterfStopDrv(UINT16 startJXTCRelayId, UINT16 stopJXTCRelayId, UINT16 psdId) +{ + /*ʼ*/ + UINT8 JXTCState = 0u; + UINT8 stopRelayState = 0u; + UINT32 CIPresentCycNum = 0u; + UINT32 JXTCStopCount = 0u; + UINT32 JXTCdriveCount = 0u; + UINT8 secStopTimeState = 0u; + UINT8 jxtcStopFlag = 0u; + UINT8 jxtcStopCmdState = 0u; + UINT8 jxtcStartCmdState = 0u; + + jxtcStopCmdState = GetStopDetectionState(psdId); + jxtcStartCmdState = GetStartDetectionState(psdId); + CIPresentCycNum = Get2oo2CurCycleNum(); + jxtcStopFlag = GetJXTCDriveStopFlag(psdId); + + /*϶ֹ̽ͣЧ*/ + if ((JXTC_STOP_DETECTION_YES == jxtcStopCmdState) && (JXTC_START_DETECTION_NO == jxtcStartCmdState)) + { + /*ò*/ + SetJXTCDriveStartFlag(psdId, JXTC_DRIVE_START_STOP_NO); + /*δֹͣ*/ + if (JXTC_DRIVE_START_STOP_NO == jxtcStopFlag) + { + /**/ + (void)SetRelayDriveState(startJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + /*ȡ϶̽״̬*/ + JXTCState = GetJXTCStopState(psdId); + if (JXTC_NO_DRIVE_STATE == JXTCState) + { + /*ʱʱ*/ + SetJXTCStopUpCycNum(psdId, 0u); + /*ֹͣ*/ + (void)SetRelayDriveState(stopJXTCRelayId, RELAY_DRIVE_STATE_UP); + + stopRelayState = GetRelayCollState(stopJXTCRelayId); + if (RELAY_STATE_UP == stopRelayState) + { + /*ü϶̽⿪ʼ̵*/ + SetJXTCStopUpCycNum(psdId, CIPresentCycNum); + /*״̬2*/ + SetJXTCStopState(psdId, JXTC_DRIVE_UP_KEEP_STATE); + } + } + /*2һʱ*/ + else if (JXTC_DRIVE_UP_KEEP_STATE == JXTCState) + { + /*ֹͣ*/ + (void)SetRelayDriveState(stopJXTCRelayId, RELAY_DRIVE_STATE_UP); + /*ʱ*/ + JXTCStopCount = GetJXTCStopUpCycNum(psdId); + JXTCdriveCount = GetJXTCPulseContinueTimeCount(); + secStopTimeState = SystemOverTimeCheck(JXTCStopCount, JXTCdriveCount); + stopRelayState = GetRelayCollState(stopJXTCRelayId); + /*ʱ*/ + if (CI_TIME_OUT == secStopTimeState) + { + /*3*/ + SetJXTCStopState(psdId, JXTC_DRIVE_DOWN_STATE); + } + else + { + /*ɼ£ص1*/ + if (RELAY_STATE_DOWN == stopRelayState) + { + /*ص1*/ + SetJXTCStopState(psdId, JXTC_NO_DRIVE_STATE); + } + } + } + /*3ز״̬*/ + else if (JXTC_DRIVE_DOWN_STATE == JXTCState) + { + /*ֹͣ*/ + (void)SetRelayDriveState(stopJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + stopRelayState = GetRelayCollState(stopJXTCRelayId); + /*ɼ*/ + if (RELAY_STATE_DOWN == stopRelayState) + { + /*ص1*/ + SetJXTCStopState(psdId, JXTC_NO_DRIVE_STATE); + /*ֹͣ*/ + SetJXTCDriveStopFlag(psdId, JXTC_DRIVE_START_STOP_YES); + } + } + else + { + /*1*/ + SetJXTCStopState(psdId, JXTC_NO_DRIVE_STATE); + } + } + } + /*϶ֹ̽ͣЧ*/ + else + { + (void)SetRelayDriveState(stopJXTCRelayId, RELAY_DRIVE_STATE_DOWN); + /*ʱΪ1*/ + SetJXTCStopState(psdId, JXTC_NO_DRIVE_STATE); + SetJXTCStopUpCycNum(psdId, 0u); + SetJXTCDriveStopFlag(psdId, JXTC_DRIVE_START_STOP_NO); + } +} + + +/* +* ϴ̵״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +UINT8 WashMachineDevToRelayStaProc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 washMachineSum = 0u; /*ϴ*/ + UINT16 washMachineId = 0u; /*ϴID*/ + UINT16 WashTrainRequestRelayId = 0u; /*ϴ̵*/ + UINT16 TrainHeadStopSteadyRelayId = 0u; /*ͷͣȼ̵*/ + UINT16 TrainTailStopSteadyRelayId = 0u; /*βͣȼ̵*/ + UINT16 pauseTrainWashRelayId = 0u; /*ͣϴ̵*/ + UINT16 passRequestRelayId = 0u; /*̵ͨ*/ + UINT8 retVal = CI_SUCCESS; + UINT8 lineIdentity = 0u; /*CI-VOBCӿڱʶ*/ + + UINT8 xtaLogicState = 0u;/*ϴͬⰴť߼״̬*/ + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡCI-VOBCӿڱʶ*/ + + washMachineSum = GetWashMachineSum(); /*ȡϴǰ*/ + + for (ii = 0u; ii < washMachineSum; ii++) + { + + washMachineId = GetWashMachineId(ii); + if (CI_ERROR == washMachineId) + { + retVal = CI_ERROR; + } + if (CI_SUCCESS == retVal) + { + WashTrainRequestRelayId = GetWashTrainRequestRelayId(washMachineId); /*ȡϴ̵ϷΪϴͬ״̵̬*/ + + if (0u != WashTrainRequestRelayId) + {/*ϴ̵IDЧ*/ + if (LINE_HLHT == lineIdentity) + {/*ͨ·ϴ̵̵ͨͬXTJ*/ + xtaLogicState = GetWashmachineXTALogicState(washMachineId); + if (XTA_STATE_PRESS_DOWN == xtaLogicState) + {/*CI鵽ͬⰴť߼״̬£ϴ̵ͬ*/ + if (CI_ERROR == SetRelayDriveState(WashTrainRequestRelayId, RELAY_STATE_UP)) + {/*̵ͨͬ*/ + retVal = CI_ERROR; + } + } + else + {/*ϴ̵ͬ*/ + if (CI_ERROR == SetRelayDriveState(WashTrainRequestRelayId, RELAY_STATE_DOWN)) + {/*̵ͨͬ*/ + retVal = CI_ERROR; + } + } + } + else + {/*·*/ + if (WASHMACHINE_DRVSTATE_REQ_TRUE == GetWashTrainRequestDrvState(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(WashTrainRequestRelayId, RELAY_STATE_UP)) + {/*ϴ̵*/ + retVal = CI_ERROR; + } + } + else if (WASHMACHINE_DRVSTATE_REQ_FALSE == GetWashTrainRequestDrvState(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(WashTrainRequestRelayId, RELAY_STATE_DOWN)) + {/*ϴ̵*/ + retVal = CI_ERROR; + } + } + else + { + if (CI_ERROR == SetRelayDriveState(WashTrainRequestRelayId, RELAY_STATE_DOWN)) + {/*ϴ̵*/ + retVal = CI_ERROR; + } + } + } + } + else + { + /*δøü̵ִ*/ + } + + } + if (CI_SUCCESS == retVal) + { + TrainHeadStopSteadyRelayId = GetTrainHeadStopSteadyRelayId(washMachineId); /*ȡͷϴλͣȼ̵*/ + + if (0u != TrainHeadStopSteadyRelayId) + {/*ͷϴλͣȼ̵IDЧ*/ + if (WASHMACHINE_HEAD_STEADY_YES == GetTrainHeadStopSteadyDrvState(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(TrainHeadStopSteadyRelayId, RELAY_STATE_UP)) + {/*ͷͣȼ̵*/ + retVal = CI_ERROR; + } + } + else if (WASHMACHINE_HEAD_STEADY_NO == GetTrainHeadStopSteadyDrvState(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(TrainHeadStopSteadyRelayId, RELAY_STATE_DOWN)) + {/*ͷͣȼ̵**/ + retVal = CI_ERROR; + } + + } + else + { + if (CI_ERROR == SetRelayDriveState(TrainHeadStopSteadyRelayId, RELAY_STATE_DOWN)) + {/*ͷͣȼ̵**/ + retVal = CI_ERROR; + } + + } + } + else + { + /*δøü̵ִ*/ + } + + } + if (CI_SUCCESS == retVal) + { + TrainTailStopSteadyRelayId = GetTrainTailStopSteadyRelayId(washMachineId); /*ȡβϴλͣȼ̵*/ + + if (0u != TrainTailStopSteadyRelayId) + {/*βϴλͣȼ̵IDЧ*/ + if (WASHMACHINE_TAIL_STEADY_YES == GetTrainTailStopSteadyDrvState(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(TrainTailStopSteadyRelayId, RELAY_STATE_UP)) + {/*βͣȼ̵*/ + retVal = CI_ERROR; + } + } + else if (WASHMACHINE_TAIL_STEADY_NO == GetTrainTailStopSteadyDrvState(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(TrainTailStopSteadyRelayId, RELAY_STATE_DOWN)) + {/*βͣȼ̵*/ + retVal = CI_ERROR; + } + + } + else + { + if (CI_ERROR == SetRelayDriveState(TrainTailStopSteadyRelayId, RELAY_STATE_DOWN)) + {/*βͣȼ̵*/ + retVal = CI_ERROR; + } + } + } + else + { + /*δøü̵ִ*/ + } + + } + if (CI_SUCCESS == retVal) + { + pauseTrainWashRelayId = GetPauseTrainWashRelayId(washMachineId); /*ȡͣϴ̵*/ + + if (0u != pauseTrainWashRelayId) + {/*ͣϴ̵IDЧ*/ + if (WASHMACHINE_PAUSE_DRVREQ_TRUE == GetPauseTrainWashRequestDrvSta(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(pauseTrainWashRelayId, RELAY_STATE_UP)) + {/*ͣϴ̵*/ + retVal = CI_ERROR; + } + } + else if (WASHMACHINE_PAUSE_DRVREQ_FALSE == GetPauseTrainWashRequestDrvSta(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(pauseTrainWashRelayId, RELAY_STATE_DOWN)) + {/*ͣϴ̵*/ + retVal = CI_ERROR; + } + } + else + { + if (CI_ERROR == SetRelayDriveState(pauseTrainWashRelayId, RELAY_STATE_DOWN)) + {/*ͣϴ̵*/ + retVal = CI_ERROR; + } + } + } + else + { + /*δøü̵ִ*/ + } + + } + if (CI_SUCCESS == retVal) + { + passRequestRelayId = GetPassRequestRelayId(washMachineId); /*ȡ̵ͨ*/ + + if (0u != passRequestRelayId) + {/*̵ͨ*/ + if (PASS_WASHMACHINE_DRVREQ_TRUE == GetPassWashMachineReqDrvSta(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(passRequestRelayId, RELAY_STATE_UP)) + {/*̵ͨ*/ + retVal = CI_ERROR; + } + } + else if (PASS_WASHMACHINE_DRVREQ_FALSE == GetPassWashMachineReqDrvSta(washMachineId)) + { + if (CI_ERROR == SetRelayDriveState(passRequestRelayId, RELAY_STATE_DOWN)) + {/*̵ͨ*/ + retVal = CI_ERROR; + } + } + else + { + if (CI_ERROR == SetRelayDriveState(passRequestRelayId, RELAY_STATE_DOWN)) + {/*̵ͨ*/ + retVal = CI_ERROR; + } + } + } + else + { + /*δøü̵ִ*/ + } + + } + if (CI_SUCCESS == retVal) + { + /*ϴģʽ̵*/ + retVal = WashMachineWorkModeRelayProc(washMachineId); + } + + if (CI_SUCCESS == retVal) + { + /*ϴӦ̵*/ + retVal = DownWashDevToRelayStaProc(washMachineId); + } + } + + return retVal; +} + +/* +* ½ͣť߼״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +UINT8 EsbRelayToDeviceStateProc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 esbSum = 0u; /*esb*/ + UINT16 esbId = 0u; /*ͣťID*/ + UINT16 esbRelayId = 0u;/*ͣť̵ID*/ + UINT16 wEsbRelayId2 = 0u;/*ͣť̵ID*/ + UINT8 reVal = CI_ERROR; + UINT8 relaySta = 0u; + UINT16 esbRepRelayId = 0u;/*esbӼ̵ID*/ + UINT8 esbBelongCi = 0u;/*esb*/ + UINT8 esbRepRelayBelongCi = 0u;/*esbӼ̵*/ + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 localCi = GetSystemParaLocalCiId();/**/ + UINT16 esbCutRelayId = 0u;/*ͣť·̵ID*/ + UINT8 chEsbVirtualAtt = 0U; + UINT8 chEsbCutRelayState = 0U; + UINT8 chEsbRelayState = 0U; + UINT8 chEsbRelay2State = 0U; + UINT8 chDsnLinSwitch = 0U; + UINT8 funcswitchZfsBtn = 0U; /*Ըʽť*/ + + chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + funcswitchZfsBtn = GetCiFunctionSwitchConfig(FUNC_ZIFUSHI_BUTTON); + + esbSum = GetTotalEsbCurNum(); + + for (ii = 0u; ii < esbSum; ii++) + { + esbId = GetEsbId(ii); + if (CI_ERROR == esbId) + { + reVal = CI_ERROR; + } + else + { + chEsbVirtualAtt = GetEsbVirtualAttribute(esbId); + if (ESB_VIRTUAL_ATTR_YES != chEsbVirtualAtt) + {/*Ϊ豸Ųɼ̵״̬*/ + esbRelayId = GetEsbRelayId(esbId); + wEsbRelayId2 = GetEsbRelayId2(esbId); + esbBelongCi = GetEsbBelongCiId(esbId);/*esb*/ + if (esbBelongCi == localCi) + {/*esbΪ*/ + if (FUNC_SWITCH_ON != chDsnLinSwitch) + { + if (FUNC_SWITCH_ON == funcswitchZfsBtn) + { + /*Ըʽͣť*/ + EsbZfsBtnProc(esbId); + EsbZfsCancelBtnProc(esbId); + } + else + { + /*ȡԸʽESBǰõ״̬*/ + chEsbRelayState = GetEsbCurNeedSetState(esbId); + reVal = SetEsbState(esbId, chEsbRelayState); + } + } + else + { + chEsbRelayState = GetRelayCollState(esbRelayId); + chEsbRelay2State = GetRelayCollState(wEsbRelayId2); + if ((RELAY_STATE_DOWN == chEsbRelayState) && (RELAY_STATE_DOWN == chEsbRelay2State)) + { + reVal = SetEsbState(esbId, ESB_STATE_VALID_YES); + } + else if ((RELAY_STATE_UP == chEsbRelayState) && (RELAY_STATE_UP == chEsbRelay2State)) + { + reVal = SetEsbState(esbId, ESB_STATE_VALID_NO); + } + else + { + reVal = SetEsbState(esbId, ESB_STATE_VALID_YES); + } + } + /*·״̬*/ + esbCutRelayId = GetEsbCutRelayId(esbId); + if (0u != esbCutRelayId) + { /*û·ťʱ*/ + chEsbCutRelayState = GetRelayCollState(esbCutRelayId); + if (RELAY_STATE_DOWN == chEsbCutRelayState) + { + SetEsbCutState(esbId, ESB_CUT_NO); + } + else if (RELAY_STATE_UP == chEsbCutRelayState) + { + SetEsbCutState(esbId, ESB_CUT_YES); + } + else + { + SetEsbCutState(esbId, ESB_CUT_NO); + reVal = CI_ERROR; + } + } + } + else + {/*esbΪ*/ + esbRepRelayId = GetEsbRepRelayId(esbId); + if (esbRepRelayId > 0u) + { + esbRepRelayBelongCi = GetRelayBelongCiId(esbRepRelayId); + commState = GetLocalCiAndOtherCiTransSta(esbBelongCi);/*ͨͨ״̬*/ + if ((esbRepRelayBelongCi == localCi) && (TRANSMIT_STATE_BAD == commState) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*esbӼ̵ڱұesbͨжϣ̵ּ֧ӿڴ*/ + relaySta = GetRelayCollState(esbRepRelayId); + if (RELAY_STATE_DOWN == relaySta) + { + reVal = SetEsbState(esbId, ESB_STATE_VALID_YES); + + } + else if (RELAY_STATE_UP == relaySta) + { + reVal = SetEsbState(esbId, ESB_STATE_VALID_NO); + + } + else + { + reVal = SetEsbState(esbId, ESB_STATE_VALID_YES); + } + } + } + + + } + + } + } + } + + return reVal; +} + + +/* +* Spksť߼״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +UINT8 SpksRelayToDeviceStateProc(void) +{ + UINT16 ii = 0u; /* α */ + UINT16 tmpSpksSum = 0u; /* Spks */ + UINT16 spksId = 0u; /* SpksID */ + UINT16 spksRelayId = 0u;/* Spksɼ̵ID */ + UINT16 spksCutRelayId = 0u;/* Spksɼ̵ID */ + UINT8 ret = CI_ERROR; + + UINT8 spksBelongCi = 0u;/*spks*/ + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 localCi = GetSystemParaLocalCiId();/**/ + UINT16 spksRepRelayId = 0u;/*spksӼ̵ID*/ + UINT8 spksRepRelayBelongCi = 0u;/*spksӼ̵*/ + UINT8 relaySta = 0u; + UINT8 execRes = 0u; + UINT32 curCycNum = Get2oo2CurCycleNum(); + UINT8 spksVirAttribute = 0U; + UINT8 spksRetVlaue = 0U; + UINT8 chStartFlock = CI_START_FLOCK_YES; + tmpSpksSum = GetTotalSpksCurNum();/*SPKS*/ + for (ii = 0u; ii < tmpSpksSum; ii++) + { + spksId = GetSpksIdByIndex(ii); + if (spksId > 0u) + { + ret = CI_SUCCESS; + spksVirAttribute = GetSpksVirtualAttribute(spksId); + if (SPKS_VIRTUAL_ATTR_NO == spksVirAttribute) + {/*Ϊ豸Ųɼ̵״̬*/ + spksRelayId = GetSpksColRelayId(spksId); + if (spksRelayId > 0u) + { + + spksBelongCi = GetSpksBelongCiId(spksId); + if (spksBelongCi == localCi) + { + relaySta = GetRelayCollState(spksRelayId); + if (RELAY_STATE_DOWN == relaySta) + { + spksRetVlaue = SetSpksState(spksId,SPKS_STATUS_YES); + if(CI_ERROR == spksRetVlaue) + { + } + SetSpksflockStartNum(spksId,curCycNum); + } + else if (RELAY_STATE_UP == relaySta) + { + spksRetVlaue = SetSpksState(spksId,SPKS_STATUS_NO); + if(CI_ERROR == spksRetVlaue) + { + } + SetSpksflockStartNum(spksId,0U); + } + else + { + ret = CI_ERROR; + } + /*·״̬*/ + spksCutRelayId = GetSpksCutRelayId(spksId); + if (0U != spksCutRelayId) + { /*û·ťʱ*/ + relaySta = GetRelayCollState(spksCutRelayId); + if (RELAY_STATE_DOWN == relaySta) + { + SetSpksCutState(spksId, SPKS_CUT_NO); + } + else if (RELAY_STATE_UP == relaySta) + { + SetSpksCutState(spksId, SPKS_CUT_YES); + } + else + { + ret = CI_ERROR; + } + } + } + else + {/*spksڱ*/ + spksRepRelayId = GetSpksRepRelayId(spksId); + + if (spksRepRelayId > 0u) + { + spksRepRelayBelongCi = GetRelayBelongCiId(spksRepRelayId); + commState = GetLocalCiAndOtherCiTransSta(spksBelongCi);/*ͨͨ״̬*/ + if ((localCi == spksRepRelayBelongCi) && (TRANSMIT_STATE_BAD == commState) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + relaySta = GetRelayCollState(spksRepRelayId); + if (RELAY_STATE_DOWN == relaySta) + { + execRes = SetSpksState(spksId, SPKS_STATUS_YES); + SetSpksflockStartNum(spksId,curCycNum); + if (CI_ERROR == execRes) + { + debug_infor_printf((const)"SetSpksState %d,%d error.", spksId, relaySta); + } + } + else if (RELAY_STATE_UP == relaySta) + { + execRes = SetSpksState(spksId, SPKS_STATUS_NO); + SetSpksflockStartNum(spksId,0u); + if (CI_ERROR == execRes) + { + debug_infor_printf((const)"SetSpksState %d,%d error.", spksId, relaySta); + } + } + else + { + ret = CI_ERROR; + } + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } + } + } + else + { + /*޲*/ + } + + + } + else + { + /*޲*/ + } + } + else + { + ret = CI_ERROR; + } + if (CI_ERROR == ret) + { + break; + } + else + { + /*޲*/ + } + } + chStartFlock = GetStartFLockFlag(); + if (CI_START_FLOCK_NO == chStartFlock) + { /* ȫվ״̬ſԽ߼μη״̬ж */ + SpksRelayToLogSecFlockStatus(); + SpksRelayToPhySecFlockStatus(); + + } + else + { + /*޲*/ + } + return ret; + + +} + +/* +* SPKS״̬η״̬ +* ˵ UINT16 phySecId +* ֵ +*/ +void SpksRelayToPhySecFlockStatus(void) +{ + UINT16 phySecCurSum = 0U; /* Ŀ*/ + UINT8 spksNum = 0U; /* spks */ + UINT16 spksId = 0U; /* spksID */ + + UINT16 phySecId = 0U; /* ID */ + UINT16 ii = 0U; /* ѭ */ + UINT16 jj = 0U; /* ѭ */ + UINT8 spksState = 0U; + UINT8 spksCutState = 0U; + UINT8 secFlockType = 0U; + UINT8 retValue = CI_ERROR; + + + phySecCurSum = GetPhySecCurSum(); /*ȡ*/ + + /**/ + for (ii = 0U; ii < phySecCurSum; ii++) + { + phySecId = 0U; /*ID*/ + phySecId = GetPhySecId(ii); /*ȡID*/ + + if ((0U != phySecId) && (phySecId < PHYSICAL_SECTION_SUM_MAX)) + { + spksNum = GetPhySecSpksSum(phySecId); /*ȡιSPKSĿ*/ + for (jj = 0U; jj < spksNum; jj++) + { + spksId = GetPhySecSpksIdBySpksIdx(phySecId, jj); + if (0u< spksId) + { + spksState = GetSpksState(spksId); + spksCutState = GetSpksCutState(spksId); + if ((SPKS_STATUS_YES == spksState) && (SPKS_CUT_YES != spksCutState)) + { /*·ť̵Ϊ0Uʱʱ·ť״̬Ϊ0UҲӦΪ״̬20180726*/ + retValue = SetPhySecFLockState(phySecId, PHYSICAL_SECTION_FLOCK_YES); + if (CI_ERROR == retValue) + { + /*η״̬ʧ*/ + } + secFlockType = GetPhySecFLockType(phySecId); + if (PHY_SEC_FLOCK_TYPE_CMD == secFlockType) + { + SetPhySecFLockType(phySecId, PHY_SEC_FLOCK_TYPE_SPKSCMD);/*SPKS η */ + } + else if (PHY_SEC_FLOCK_TYPE_NONE == secFlockType) + { + SetPhySecFLockType(phySecId, PHY_SEC_FLOCK_TYPE_SPKS);/*¼ηSPKSµ*/ + } + else + { + /*ѾSPKS*/ + } + + break; + } + } + } +#if 0 + secFLockState = GetPhySecFLockState(phySecId); + if (PHYSICAL_SECTION_FLOCK_YES == secFLockState) + { + routeSum = GetRouteCurSum();/*ȡ·*/ + for (kk = 0U; kk < routeSum; kk++) + { + routeId = GetRouteId(kk);/*ȡ·ID*/ + + reVal = CheckCancleAutoFlag(routeId, phySecId);/*ǷԶ־ڱĵ·ȡԶ־*/ + + if (CI_SUCCESS == reVal) + { + dataIdBuf = GetRouteSectionData(routeId); + checkSum = GetRoutePhysicalSectionSum(routeId); + proRouteId = GetPhySecProLockRouteIdBuf(phySecId); + proRouteIdSum = GetPhySecProLockRouteSum(phySecId); + flag = 0U; /*ÿ·һ*/ + for (ll = 0U; ll < checkSum; ll++) + { /*»󣬵ηȡεĽ·Զԣ2018.9.17*/ + if ((0U != proRouteIdSum) && (NULL != proRouteId)) + { + for (i = 0U; i < proRouteIdSum; i++) + { /*·бΰ*/ + if ((phySecId == dataIdBuf[ll].PhysicalSectionId) || (routeId == proRouteId[i])) + { /*·źŻȡý·Զ*/ + retValue = CancleAutoFlag(routeId); + if (CI_ERROR == retValue) + { /*ȡԶ*/ + SetErrorData(EFUNC_SET_SECTION_FLOCK, CI_DEVICE_TYPE_PHYSEC, phySecId, ETYPE_PS_FLOCK_STATE, PHYSICAL_SECTION_FLOCK_YES, ESEND_LEVEL_ATS); + + } + flag = 1U; + break; + } + + } + } + else + { /*·Σֻ·ڷ*/ + if (phySecId == dataIdBuf[ll].PhysicalSectionId) + { /*·źŻȡý·Զ*/ + retValue = CancleAutoFlag(routeId); + if (CI_ERROR == retValue) + { /*ȡԶ*/ + SetErrorData(EFUNC_SET_SECTION_FLOCK, CI_DEVICE_TYPE_PHYSEC, phySecId, ETYPE_PS_FLOCK_STATE, PHYSICAL_SECTION_FLOCK_YES, ESEND_LEVEL_ATS); + + } + flag = 1U; + } + + } + + if (1U == flag) + { + break; + } + } + } + } + } +#endif + /*˴жϴûз */ + if ((jj == spksNum) && (0u< jj)) + { + secFlockType = GetPhySecFLockType(phySecId); + if (PHY_SEC_FLOCK_TYPE_SPKSCMD == secFlockType) + { + SetPhySecFLockType(phySecId, PHY_SEC_FLOCK_TYPE_CMD);/*зηȡ ͽΪ*/ + } + else if (PHY_SEC_FLOCK_TYPE_SPKS == secFlockType) + { + retValue = SetPhySecFLockState(phySecId, PHYSICAL_SECTION_FLOCK_NO); + if (CI_ERROR == retValue) + { + /*η״̬ʧ*/ + } + SetPhySecFLockType(phySecId, PHY_SEC_FLOCK_TYPE_NONE);/*ó޷*/ + } + else + { + /*зηȡ*/ + } + } + else + { + /*޲*/ + } + } + } +} + + +/* +* ³ŵ߼״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +UINT8 GaragedoorRelayToDevStaProc(void) +{ + UINT16 ii = 0u; /* α */ + UINT16 garagedoorSum = 0u; /* Garagedoor */ + UINT16 garagedoorId = 0u; /* Garagedoor ID */ + UINT16 garagedoorOpenRelayId = 0u;/* Garagedoorɼż̵ID */ + UINT16 garagedoorCloseRelayId = 0u;/* Garagedoorɼż̵ID */ + UINT16 garagedoorModeRelayId = 0u;/* Garagedoorɼģʽ̵ID */ + UINT16 garagedoorFaultRelayId = 0u;/* Garagedoorϼ̵ID */ + UINT16 garagedoorPangLuRelayId = 0u;/* Garagedoor·̵ID */ + UINT16 garagedoorKGHRelayId = 0u;/* Garagedoor״̬ڵ̵ID */ + UINT8 doorState = 0u; + UINT8 doorDrvState = 0u; + + UINT8 gdOpenRelayState = 0U;/*Garagedoorɼż̵״̬*/ + UINT8 gdCloseRelayState = 0U;/*Garagedoorɼż̵״̬*/ + UINT8 gdKGHRelayState = 0U;/*Garagedoor״̬ڵ̵״̬*/ + UINT8 gdPangLuRelayState = 0U;/*Garagedoor·̵״̬*/ + UINT8 gdGuZhangRelayState = 0U;/*Garagedoorϼ̵״̬*/ + UINT8 gdModeRelayState = 0U; /*ģʽ̵״̬*/ + UINT8 ret = CI_ERROR; + + + garagedoorSum = GetGaragedoorSum(); + if (GARAGE_DOOR_SUM_MAX > garagedoorSum) + { + ret = CI_SUCCESS; + for (ii = 0u; ii < garagedoorSum; ii++) + { + garagedoorId = GetGaragedoorId(ii); + if (CI_ERROR == garagedoorId) + { + ret = CI_ERROR; + } + else + { + garagedoorOpenRelayId = GetGaragedoorOpenRelayId(garagedoorId); + garagedoorCloseRelayId = GetGardoorCloseRelayId(garagedoorId); + garagedoorModeRelayId = GetGardoorModeStateRelayId(garagedoorId); + garagedoorFaultRelayId = GetGardoorFaultStateRelayId(garagedoorId); + garagedoorPangLuRelayId = GetGardoorPangLuRelayId(garagedoorId); + garagedoorKGHRelayId = GetGardoorKGHRelayId(garagedoorId); + + gdOpenRelayState = GetRelayCollState(garagedoorOpenRelayId); + gdCloseRelayState = GetRelayCollState(garagedoorCloseRelayId); + gdKGHRelayState = GetRelayCollState(garagedoorKGHRelayId); + gdPangLuRelayState = GetRelayCollState(garagedoorPangLuRelayId); + gdGuZhangRelayState = GetRelayCollState(garagedoorFaultRelayId); + gdModeRelayState = GetRelayCollState(garagedoorModeRelayId); + + + /*״̬жģʽֻڿź·̵̵δ*/ + if ((0U != garagedoorOpenRelayId) && (0U != garagedoorPangLuRelayId) + && (0U == garagedoorCloseRelayId) && (0U == garagedoorModeRelayId) && (0U == garagedoorFaultRelayId) && (0U == garagedoorKGHRelayId)) + { + ret = GDRelayToDeviceStateOnlyOpenPL(garagedoorId); + + } + else + { + /* ״̬ : ֻſ̵ Źؼ̵ֻһ + * ſ: ſ̵ Źؼ̵ Ź: ſ̵ Źؼ̵ + */ + + /*ſ*/ + if ((RELAY_STATE_DOWN == gdOpenRelayState) && (RELAY_STATE_UP == gdCloseRelayState) + && (RELAY_STATE_DOWN == gdKGHRelayState) && (RELAY_STATE_DOWN == gdPangLuRelayState)) + /*ſ&&Źء&&غ&&·*/ + { + ret = SetGaragedoorState(garagedoorId, GARAGE_DOOR_STATE_CLOSE); + + } + else if (((RELAY_STATE_UP == gdOpenRelayState) && (RELAY_STATE_DOWN == gdCloseRelayState) + && (RELAY_STATE_DOWN == gdKGHRelayState)) || (RELAY_STATE_UP == gdPangLuRelayState)) + /*(ſ&&Źء&&غ)||·*/ + { + ret = SetGaragedoorState(garagedoorId, GARAGE_DOOR_STATE_OPEN); + + } + else + { + ret = SetGaragedoorState(garagedoorId, GARAGE_DOOR_STATE_UNVALID); + + } + } + /*ģʽ*/ + if (CI_SUCCESS == ret) + { + if (RELAY_STATE_DOWN == gdModeRelayState) + { + ret = SetGaragedoorModeState(garagedoorId, GARAGE_DOOR_STATE_MODE_LOCAL); + + } + else if (RELAY_STATE_UP == gdModeRelayState) + { + ret = SetGaragedoorModeState(garagedoorId, GARAGE_DOOR_STATE_MODE_REMOTE); + + } + else + { + /*δü̵̵ɼΪģʽ*/ + ret = SetGaragedoorModeState(garagedoorId, GARAGE_DOOR_STATE_MODE_LOCAL); + } + } + else + { + ; + } + /*Ź*/ + if (CI_SUCCESS == ret) + { + if (RELAY_STATE_DOWN == gdGuZhangRelayState) + { + ret = SetGaragedoorFaultState(garagedoorId, GARAGE_DOOR_FAULT_TRUE); + + } + else + { + ret = SetGaragedoorFaultState(garagedoorId, GARAGE_DOOR_FAULT_FALSE); + + } + } + else + { + ; + } + + /*·*/ + if (CI_SUCCESS == ret) + { + if (RELAY_STATE_UP == gdPangLuRelayState) + { + ret = SetGaragedoorPangLuState(garagedoorId, GARAGE_DOOR_PANGLU_TRUE); + + } + else + { + ret = SetGaragedoorPangLuState(garagedoorId, GARAGE_DOOR_PANGLU_FALSE); + + } + } + else + { + ; + } + + + /* ŵλ״̬ */ + doorDrvState = GetDrvGaragedoorState(garagedoorId); + doorState = GetGaragedoorState(garagedoorId); + if (((GARAGE_DOOR_DRV_OPEN == doorDrvState) && (GARAGE_DOOR_STATE_OPEN == doorState)) + || ((GARAGE_DOOR_DRV_CLOSE == doorDrvState) && (GARAGE_DOOR_STATE_CLOSE == doorState))) + { + ret = SetDrvGaragedoorState(garagedoorId, GARAGE_DOOR_DRV_NULL); + } + else + { + ; + } + + } + } + } + else + { + ret = CI_ERROR; + } + return ret; +} + +/* +* ³ŵ߼״̬(ÿš·̵) +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +UINT8 GDRelayToDeviceStateOnlyOpenPL(const UINT16 garagedoorId) +{ + UINT16 garagedoorOpenRelayId = 0u;/* Garagedoorɼż̵ID */ + UINT16 garagedoorPangLuRelayId = 0u;/* Garagedoor·̵ID */ + + UINT8 gdOpenRelayState = 0U;/*Garagedoorɼż̵״̬*/ + UINT8 gdPangLuRelayState = 0U;/*Garagedoor·̵״̬*/ + UINT8 ret = CI_ERROR; + + garagedoorOpenRelayId = GetGaragedoorOpenRelayId(garagedoorId); + garagedoorPangLuRelayId = GetGardoorPangLuRelayId(garagedoorId); + + gdOpenRelayState = GetRelayCollState(garagedoorOpenRelayId); + gdPangLuRelayState = GetRelayCollState(garagedoorPangLuRelayId); + + + /*ſ״̬*/ + if ((RELAY_STATE_DOWN == gdOpenRelayState) && (RELAY_STATE_DOWN == gdPangLuRelayState)) + { + ret = SetGaragedoorState(garagedoorId, GARAGE_DOOR_STATE_CLOSE); + + } + else if ((RELAY_STATE_UP == gdOpenRelayState) || (RELAY_STATE_UP == gdPangLuRelayState)) + { + ret = SetGaragedoorState(garagedoorId, GARAGE_DOOR_STATE_OPEN); + + } + else + { + ret = SetGaragedoorState(garagedoorId, GARAGE_DOOR_STATE_UNVALID); + + } + return ret; +} + +/* +* ³ż̵״̬ +* ˵ void +* ֵ +*/ +void GaragedoorDevToRelayStaProc(void) +{ + UINT16 ii = 0u; /* α */ + UINT16 garagedoorSum = 0u; /* Garagedoor */ + UINT16 garagedoorId = 0u; /* Garagedoor ID */ + UINT16 relayId = 0u; + UINT8 doorDrvState = 0u; + + garagedoorSum = GetGaragedoorSum(); + for (ii = 0u; ii < garagedoorSum; ii++) + { + garagedoorId = GetGaragedoorId(ii); + doorDrvState = GetDrvGaragedoorState(garagedoorId); + + if (GARAGE_DOOR_DRV_OPEN == doorDrvState) + { + /*ȡſż̵ID*/ + relayId = GetGardoorOpenOrderRelayId(garagedoorId); + + if (GARAGE_DOOR_STATE_OPEN == GetGaragedoorState(garagedoorId)) + { + /*״̬ΪѴ ¼Ŀʼ */ + (void)SetGaragedoorOpenStartCycNum(garagedoorId, 0u); + } + else + { + if (CI_TIME_OUT == SystemOverTimeCheck(GetGaragedoorOpenStartCycNum(garagedoorId), GetSysParaGaragedoorOperateCnt())) + { + /*ʱ ¼Ŀʼ ̵ֹͣ Ϣ*/ + (void)SetGaragedoorOpenStartCycNum(garagedoorId, 0u); + (void)SetRelayDriveState(relayId, RELAY_DRIVE_STATE_DOWN); + SetCiSendCmdBackInfoData(CI_BACK_GARAGEDOOR_TIMEOUT, CI_DEVICE_TYPE_GARAGEDOOR, garagedoorId, 0u, 0u);/*Ŷʱ*/ + + (void)SetDrvGaragedoorState(garagedoorId, GARAGE_DOOR_DRV_NULL); + } + else + { + /*ûгʱ ſ*/ + (void)SetRelayDriveState(relayId, RELAY_DRIVE_STATE_UP); + } + } + } + else if (GARAGE_DOOR_DRV_CLOSE == doorDrvState) + { + /*ȡŹż̵ID*/ + relayId = GetGardoorCloseOrderRelayId(garagedoorId); + + if (GARAGE_DOOR_STATE_CLOSE == GetGaragedoorState(garagedoorId)) + { + /*״̬Ϊѹر ¼Ŀʼ */ + SetGaragedoorCloseStartCycNum(garagedoorId, 0u); + } + else + { + if (CI_TIME_OUT == SystemOverTimeCheck(GetGaragedoorCloseStartCycNum(garagedoorId), GetSysParaGaragedoorOperateCnt())) + { + /*ʱ ¼Ŀʼ ̵ֹͣ Ϣ*/ + SetGaragedoorCloseStartCycNum(garagedoorId, 0u); + (void)SetRelayDriveState(relayId, RELAY_DRIVE_STATE_DOWN); + SetCiSendCmdBackInfoData(CI_BACK_GARAGEDOOR_TIMEOUT, CI_DEVICE_TYPE_GARAGEDOOR, garagedoorId, 0u, 0u);/*Ŷʱ*/ + + (void)SetDrvGaragedoorState(garagedoorId, GARAGE_DOOR_DRV_NULL); + } + else + { + /*ûгʱ Ź*/ + (void)SetRelayDriveState(relayId, RELAY_DRIVE_STATE_UP); + } + } + } + else + { + (void)SetGaragedoorOpenStartCycNum(garagedoorId, 0u); + SetGaragedoorCloseStartCycNum(garagedoorId, 0u); + } + } +} + +/* +* ·ŵ豸߼״̬ +* ˵ void +* ֵ void +*/ +void FloodGateRelayToDeviceStateProc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 floodGateSum = 0u; /**/ + UINT16 floodGateId = 0u; /*ID*/ + UINT32 curCycle = 0u;/*ǰ*/ + UINT8 localCi = 0u; + UINT8 belongCi = 0u; + + UINT8 tmpExecRes = CI_ERROR;/*ʱִн*/ + UINT8 reVal = CI_ERROR;/*ֵ*/ + + + UINT16 closeApplyRelayId = 0u;/*̵id*/ + UINT16 openLockRelayId = 0u; /*ռ̵id*/ + UINT16 allowCloseRelayId = 0u; /*ż̵id*/ + + UINT8 closeApplyRelayState = 0u;/*̵״̬*/ + UINT8 openLockRelayState = 0u; /*ռ̵״̬*/ + UINT8 allowCloseRelayState = 0u; /*ż̵״̬*/ + + curCycle = Get2oo2CurCycleNum(); + floodGateSum = GetFloodGateCurSum(); + localCi = GetSystemParaLocalCiId();/**/ + for (ii = 0u; ii < floodGateSum; ii++) + { + floodGateId = GetFloodGateId(ii); + + /*֤id벻Ϊ0u*/ + if (CI_ERROR == floodGateId) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + {/*֤űΪ*/ + belongCi = GetFloodGateBelongCiId(floodGateId); + + if (belongCi == localCi) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + + if (CI_SUCCESS == reVal) + { + openLockRelayId = GetFloodGateOpenLockRelayId(floodGateId);/*ȡſռ̵id*/ + closeApplyRelayId = GetFloodGateCloseApplyRelayId(floodGateId);/*ȡŹ̵id*/ + allowCloseRelayId = GetFloodGateAllowRequestRelayId(floodGateId);/*ȡйż̵id*/ + + /*·ſ״̬*/ + if (openLockRelayId > 0u) + { + openLockRelayState = GetRelayCollState(openLockRelayId);/*·ſ״̬*/ + + if (RELAY_STATE_UP == openLockRelayState) + {/*KSJ̬ţΪ*/ + tmpExecRes = SetFloodGateCurOpenLockState(floodGateId, FLOOD_GATE_OPENLOCK); + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else if (RELAY_STATE_DOWN == openLockRelayState) + {/*KSJ£Ϊǿ*/ + tmpExecRes = SetFloodGateCurOpenLockState(floodGateId, FLOOD_GATE_NOT_OPENLOCK);/*ǿ*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else + {/*ǷֵȲҲ£Ϊȫ࣬ǿ*/ + tmpExecRes = SetFloodGateCurOpenLockState(floodGateId, FLOOD_GATE_NOT_OPENLOCK);/*ǿ*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + } + + /*·Ź״̬*/ + if (closeApplyRelayId > 0u) + { + closeApplyRelayState = GetRelayCollState(closeApplyRelayId);/*·Ź״̬*/ + + if (RELAY_STATE_UP == closeApplyRelayState) + {/*GQJΪй*/ + tmpExecRes = SetFloodGateCurCloseRequestSta(floodGateId, FLOOD_GATE_CLOSEREQ);/*й*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else if (RELAY_STATE_DOWN == closeApplyRelayState) + {/*GQJ̬£Ϊ޹*/ + tmpExecRes = SetFloodGateCurCloseRequestSta(floodGateId, FLOOD_GATE_NOT_CLOSEREQ);/*޹*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else + {/*ǷֵȲҲ£Ϊȫ࣬й*/ + tmpExecRes = SetFloodGateCurCloseRequestSta(floodGateId, FLOOD_GATE_CLOSEREQ);/*й*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + } + + /*·Ųɼ״̬*/ + if (allowCloseRelayId > 0u) + { + allowCloseRelayState = GetRelayCollState(allowCloseRelayId);/*·Ź״̬*/ + + if (RELAY_STATE_UP == allowCloseRelayState) + {/*YGJ̬£Ϊ*/ + tmpExecRes = SetFloodGateCurAgreeCloseSta(floodGateId, FLOOD_GATE_AGREE_CLOSE); + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else if (RELAY_STATE_DOWN == allowCloseRelayState) + {/*YGJ£Ϊ*/ + tmpExecRes = SetFloodGateCurAgreeCloseSta(floodGateId, FLOOD_GATE_NOT_AGREE_CLOSE);/**/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else + {/*ǷֵȲҲ£Ϊ*/ + tmpExecRes = SetFloodGateCurAgreeCloseSta(floodGateId, FLOOD_GATE_NOT_AGREE_CLOSE);/**/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + } + + + + + + + } + } +} + +/* +* ·ż̵״̬ +* ˵ void +* ֵ +*/ +void FloodGateDeviceToRelayStateProc(void) +{ + UINT16 ii = 0u; /* α */ + UINT16 floodGateSum = 0u; /* Garagedoor */ + UINT16 floodGateId = 0u; /* Garagedoor ID */ + UINT16 floodGateAgreeCloseRelayId = 0u; + UINT8 floodGateAgreeCloseState = 0u; + + UINT32 startCount = 0u;/*ʼ*/ + UINT8 ygjDrvState = 0u;/*YGJ״̬*/ + UINT8 ygjCollState = 0u;/*YGJɼ״̬*/ + + UINT8 localCi = 0u; + UINT8 belongCi = 0u; + + UINT8 reVal = CI_ERROR; + UINT8 exeVal = 0u;/*ִн*/ + UINT32 curCycle = 0u;/*ǰ*/ + INT32 deltCycle = 0;/*ڲֵ*/ + + localCi = GetSystemParaLocalCiId();/**/ + floodGateSum = GetFloodGateCurSum(); + curCycle = Get2oo2CurCycleNum();/*ǰ*/ + + for (ii = 0u; ii < floodGateSum; ii++) + { + floodGateId = GetFloodGateId(ii); + + /*֤id벻Ϊ0u*/ + if (CI_ERROR == floodGateId) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + {/*֤űΪ*/ + belongCi = GetFloodGateBelongCiId(floodGateId); + + if (belongCi == localCi) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + /*÷ż̵״̬*/ + if (CI_SUCCESS == reVal) + { + floodGateAgreeCloseState = GetFloodGateCurAgreeCloseOutSta(floodGateId);/*״̬*/ + floodGateAgreeCloseRelayId = GetFloodGateAllowRequestRelayId(floodGateId); + if (FLOOD_GATE_AGREE_CLOSE == floodGateAgreeCloseState) + {/*ţ*/ + (void)SetRelayDriveState(floodGateAgreeCloseRelayId, RELAY_DRIVE_STATE_UP); + } + else if (FLOOD_GATE_NOT_AGREE_CLOSE == floodGateAgreeCloseState) + {/*ţ*/ + (void)SetRelayDriveState(floodGateAgreeCloseRelayId, RELAY_DRIVE_STATE_DOWN); + } + else + {/*Ƿֵ*/ + (void)SetRelayDriveState(floodGateAgreeCloseRelayId, RELAY_DRIVE_STATE_DOWN); + } + + /*ӷYGJ߱жϣû𣬵ǻز𣬱*/ + + /*жǷߣû𣬵ز*/ + ygjDrvState = GetRelayDriveState(floodGateAgreeCloseRelayId);/*YGJ״̬*/ + ygjCollState = GetRelayCollState(floodGateAgreeCloseRelayId);/*YGJɼ״̬*/ + + if ((RELAY_STATE_UP == ygjCollState) && (RELAY_DRIVE_STATE_DOWN == ygjDrvState)) + {/*YGJ£زл*/ + startCount = GetFloodGateCurYGJCrosLStartCnt(floodGateId); + + if (0u == startCount) + { + exeVal = SetFloodGateCurYGJCrosLStartCnt(floodGateId, curCycle); + if (CI_ERROR == exeVal) + { + debug_infor_printf((const)"SetFloodGateCurYGJCrossLineStartCount %d cnt %d faile.", floodGateId, curCycle); + } + } + else + {/*ʼڲΪ0uʱжǷ߳5ڣ5ڱ*/ + deltCycle = (INT32)(curCycle - startCount);/*߳*/ + if (deltCycle == (INT32)FLOOD_GATE_YGJ_CROSS_LINE_MAX_COUNT)/*ڻڣֻһΣֹϱATS*/ + { + SetErrorData(EFUNC_FloodGateDeviceToRelayStateProc, CI_DEVICE_TYPE_FLOODGATE, floodGateId, + ETYPE_FLOOD_GATE_YGJ_CROSS_LINE, 0u, ESEND_LEVEL_ATS);/*Ż߱*/ + } + } + } + else + {/*ûлߣʼ*/ + exeVal = SetFloodGateCurYGJCrosLStartCnt(floodGateId, 0u); + if (CI_ERROR == exeVal) + { + debug_infor_printf((const)"SetFloodGateCurYGJCrossLineStartCount %d cnt 0 faile.", floodGateId); + } + } + + + + } + + + + } +} + + + +/* +* ϴ߼״̬ +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +UINT8 WashMachineToDeviceStateProc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 washMachineSum = 0u; /*ϴ*/ + UINT16 washMachineId = 0u; /*ϴID*/ + UINT16 washMachineReadyRelayId = 0u; /*ϴ̵ID*/ + UINT16 washMachineReVeriRelayId = 0u; /*ϴȷϼ̵ID*/ + UINT16 headWashAllowRelayId = 0u; /*ϴͷϴ̵ID*/ + UINT16 emergencyStopRelayId = 0u; /*ϴгͣID*/ + UINT16 tailWashAllowRelayId = 0u; /*ϴβϴ̵ID*/ + UINT16 outWashTrainPortAllowRelayId = 0u; /*ϴϴ̵ID*/ + UINT8 ret = CI_SUCCESS; + UINT8 lineIdentity = 0u; /*CI-VOBCӿڱʶ*/ + UINT8 xtaCurState = 0u;/*ϴͬⰴťǰ״̬*/ + UINT8 xtaPreStae = 0u;/*ϴͬⰴť֮ǰ״̬*/ + UINT8 xtaLogicState = 0u;/*ϴͬⰴť߼״̬*/ + UINT32 pressDownCycle = 0u;/**/ + UINT32 curCycle = 0u;/*ǰ*/ + INT32 deltCycle = 0;/*ʱڲֵ*/ + UINT16 washModeBackRelayId = 0U; + UINT8 washModeState = 0U; + UINT8 retRsult = 0U; + UINT8 relayCollState = 0U; + UINT8 cleanXTAPressDownCyc = 0U; + UINT16 wDownWashAllowRelayId = 0U;/*ģʽϴͬⰴť̵*/ + UINT16 wDownWashAllowPassRelayId = 0U;/*ģʽϴͬͨť̵*/ + UINT8 chDownWashAllowState = 0U;/*ģʽϴͬ״̬*/ + UINT8 chDownWashAllowPassState = 0U;/*ģʽϴͬͨ״̬*/ + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡCI-VOBCӿڱʶ*/ + curCycle = Get2oo2CurCycleNum(); + washMachineSum = GetWashMachineSum(); + for (ii = 0u; ii < washMachineSum; ii++) + { + washMachineId = GetWashMachineId(ii); + if (CI_ERROR == washMachineId) + { + ret = CI_ERROR; + } + + if (CI_SUCCESS == ret) + { + /*ϴȷ״̬*/ + washMachineReVeriRelayId = GetWashMachineReqVerifyRelayId(washMachineId); + if (0U != washMachineReVeriRelayId) + {/*ϴȷϼ̵IDЧ*/ + relayCollState = GetRelayCollState(washMachineReVeriRelayId); + if (RELAY_STATE_UP == relayCollState) + { + retRsult = SetWashMachineRequestVerifySta(washMachineId, WASHMACHINE_COL_REQUEST_VALID); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + retRsult = SetWashMachineRequestVerifySta(washMachineId, WASHMACHINE_COL_REQUEST_INVALID); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + } + else + { + /*øü̵ִ*/ + } + } + + if (CI_SUCCESS == ret) + { + /*ͷϴ״̬*/ + headWashAllowRelayId = GetHeadWashAllowRelayId(washMachineId); + if (0U != headWashAllowRelayId) + { + /*ϴͷϴ̵IDЧ*/ + relayCollState = GetRelayCollState(headWashAllowRelayId); + if (RELAY_STATE_UP == relayCollState) + { + retRsult = SetHeadWashAllowState(washMachineId, WASHMACHINE_COL_HEADWASH_YES); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + retRsult = SetHeadWashAllowState(washMachineId, WASHMACHINE_COL_HEADWASH_NO); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + } + else + { + /*øü̵ִ*/ + } + } + + if (CI_SUCCESS == ret) + { + /*βϴ״̬*/ + tailWashAllowRelayId = GetTailWashAllowRelayId(washMachineId); + if (0U != tailWashAllowRelayId) + { + /*ϴβϴ̵IDЧ*/ + relayCollState = GetRelayCollState(tailWashAllowRelayId); + if (RELAY_STATE_UP == relayCollState) + { + retRsult = SetTailWashAllowState(washMachineId, WASHMACHINE_COL_TAILWASH_YES); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + retRsult = SetTailWashAllowState(washMachineId, WASHMACHINE_COL_TAILWASH_NO); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + } + else + { + /*øü̵ִ*/ + } + } + + if (CI_SUCCESS == ret) + { + /*ϴ״̬*/ + emergencyStopRelayId = GetTrainEmergencyStopRelayId(washMachineId); + if (0U != emergencyStopRelayId) + { + relayCollState = GetRelayCollState(emergencyStopRelayId); + /*ϴг̵ͣIDЧ*/ + if (RELAY_STATE_UP == relayCollState) + { + if (LINE_FAO == lineIdentity) + {/*FAO·*/ + retRsult = SetTrainEmergencyStopState(washMachineId, WASHMACHINE_COL_FALUT_NO); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) + || (LINE_CC == lineIdentity)) + {/*FAO+HLHT·*/ + retRsult = SetTrainEmergencyStopState(washMachineId, WASHMACHINE_COL_FALUT_NO_2); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + {/*·*/ + ret = CI_ERROR; + } + + } + else if (RELAY_STATE_DOWN == relayCollState) + { + if (LINE_FAO == lineIdentity) + {/*FAO·*/ + retRsult = SetTrainEmergencyStopState(washMachineId, WASHMACHINE_COL_FALUT_YES); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) + || (LINE_CC == lineIdentity)) + {/*FAO+HLHT·*/ + retRsult = SetTrainEmergencyStopState(washMachineId, WASHMACHINE_COL_FALUT_YES_2); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + {/*·*/ + ret = CI_ERROR; + } + + } + else + { + ret = CI_ERROR; + } + } + else + { + /*øü̵ִ*/ + } + } + if (CI_SUCCESS == ret) + { + /*ϴ״̬£ϷΪϴͬⰴť״̬*/ + washMachineReadyRelayId = GetWashMachineReadyRelayId(washMachineId); + if (0U != washMachineReadyRelayId) + { + if (LINE_HLHT == lineIdentity) + {/*HLHT·*/ + relayCollState = GetRelayCollState(washMachineReadyRelayId); + /*ϴ̵IDЧ*/ + if (RELAY_STATE_UP == relayCollState) + { + retRsult = SetWashMachineReadyState(washMachineId, WASHMACHINE_COL_READY_YES); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == GetRelayCollState(washMachineReadyRelayId)) + { + retRsult = SetWashMachineReadyState(washMachineId, WASHMACHINE_COL_READY_NO); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + + + xtaCurState = GetWashmachineXTACurState(washMachineId);/*ȡϴͬⰴťǰ״̬*/ + + if (xtaCurState != CI_ERROR) + { + retRsult = SetWashmachineXTAPreState(washMachineId, xtaCurState);/*õǰ״̬֮ǰ״̬*/ + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + + relayCollState = GetRelayCollState(washMachineReadyRelayId); + /*ϴϴͬⰴťǰ״̬֮ǰ״̬,Ϊ£ Ϊ̧*/ + if (RELAY_STATE_UP == relayCollState) + { + retRsult = SetWashmachineXTACurState(washMachineId, XTA_STATE_PRESS_DOWN); + /*XTAǰ״̬,Ϊ*/ + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + retRsult = SetWashmachineXTACurState(washMachineId, XTA_STATE_RAISE_UP); + /*XTAǰ״̬,Ϊ̧*/ + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + else + { + /*̧ʱ尴ʱ*/ + cleanXTAPressDownCyc = SetWashMachineXTAPressDownCyc(washMachineId, 0U); + if (CI_ERROR == cleanXTAPressDownCyc) + { + /*ϴϴͬťʧ*/ + } + } + } + else + { + ret = CI_ERROR; + } + + } + else + { + relayCollState = GetRelayCollState(washMachineReadyRelayId); + if (RELAY_STATE_UP == relayCollState) + { + retRsult = SetWashMachineReadyState(washMachineId, WASHMACHINE_COL_READY_YES); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + retRsult = SetWashMachineReadyState(washMachineId, WASHMACHINE_COL_READY_NO); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + } + + } + else + { + /*øü̵ִ*/ + } + } + + if (CI_SUCCESS == ret) + { + /*ϴ״̬*/ + outWashTrainPortAllowRelayId = GetTrainOutWashPortAllowRelay(washMachineId); + if (0U != outWashTrainPortAllowRelayId) + { + /*ϴϴ̵IDЧ*/ + relayCollState = GetRelayCollState(outWashTrainPortAllowRelayId); + if (RELAY_STATE_UP == relayCollState) + { + if (LINE_FAO == lineIdentity) + {/*FAO·*/ + retRsult = SetTrainOutWashPortAllowSta(washMachineId, WASHMACHINE_COL_OUT_YES); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) + || (LINE_CC == lineIdentity)) + {/*FAO+HLHT·*/ + retRsult = SetTrainOutWashPortAllowSta(washMachineId, WASHMACHINE_COL_OUT_YES_2); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + {/*·*/ + ret = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + if (LINE_FAO == lineIdentity) + {/*FAO·*/ + retRsult = SetTrainOutWashPortAllowSta(washMachineId, WASHMACHINE_COL_OUT_NO); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) + || (LINE_CC == lineIdentity)) + {/*FAO+HLHT·*/ + retRsult = SetTrainOutWashPortAllowSta(washMachineId, WASHMACHINE_COL_OUT_NO_2); + if (CI_ERROR == retRsult) + { + ret = CI_ERROR; + } + } + else + {/*·*/ + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + } + else + { + /*øü̵ִ*/ + } + } + + + if (CI_SUCCESS == ret) + {/*ϴϴͬⰴťڡ̧*/ + + if (LINE_HLHT == lineIdentity) + {/*HLHT·*/ + xtaLogicState = GetWashmachineXTALogicState(washMachineId); + + if (XTA_STATE_PRESS_DOWN == xtaLogicState) + {/*ϴͬⰴť߼״̬Ϊʱ*/ + cleanXTAPressDownCyc = SetWashMachineXTAPressDownCyc(washMachineId, 0U); + if (CI_ERROR == cleanXTAPressDownCyc) + { + /*ϴϴͬťʧ*/ + } + } + else if (XTA_STATE_RAISE_UP == xtaLogicState) + {/*ϴͬⰴť߼״̬Ϊ̧ʱ,*/ + xtaPreStae = GetWashmachineXTAPreState(washMachineId); + xtaCurState = GetWashmachineXTACurState(washMachineId); + if ((xtaCurState != CI_ERROR) && (xtaPreStae != CI_ERROR)) + {/*״̬Чʱ*/ + if ((XTA_STATE_PRESS_DOWN == xtaCurState) && (XTA_STATE_RAISE_UP == xtaPreStae)) + {/*ǰ£֮ǰ̧,°*/ + ret = SetWashMachineXTAPressDownCyc(washMachineId, curCycle); + } + + + } + } + else + {/*߼״̬Ƿϴͬⰴť/̧*/ + cleanXTAPressDownCyc = SetWashMachineXTAPressDownCyc(washMachineId, 0U); + if (CI_ERROR == cleanXTAPressDownCyc) + { + /*ϴϴͬťʧ*/ + } + } + } + else + { + /*·*/ + } + + } + + if (CI_SUCCESS == ret) + {/*ϴͬⰴť߼״ֻ̬°£ֵ̧صȡ*/ + pressDownCycle = GetWashMachineXTAPressDownCyc(washMachineId);/*ȡ*/ + xtaCurState = GetWashmachineXTACurState(washMachineId); + if ((pressDownCycle > 0U) && (XTA_STATE_PRESS_DOWN == xtaCurState)) + { + if (curCycle > pressDownCycle) + {/*ǰڴڰڣȷΪֵ*/ + deltCycle = (INT32)(curCycle - pressDownCycle); + if (deltCycle >= PRESSING_TIME_MIN)/*3*/ + { + ret = SetWashmachineXTALogicState(washMachineId, XTA_STATE_PRESS_DOWN);/*߼״̬Ϊ*/ + } + } + } + } + if (CI_SUCCESS == ret) + {/*cgh-ϲCID-3037-9*/ + washModeBackRelayId = GetWashModeBackRelayId(washMachineId); + if ((0U != washModeBackRelayId) && (UINT16_MAX != washModeBackRelayId)) + { + washModeState = GetRelayCollState(washModeBackRelayId); + /*̵*/ + if (RELAY_STATE_UP == washModeState) + { + /*öϴģʽ*/ + SetWashModeState(washMachineId, XTA_MODE_STATE_UP); + } + else + { + /*ͨϴģʽ*/ + SetWashModeState(washMachineId, XTA_MODE_STATE_DOWN); + } + } + else + { + /*ģʽ*/ + SetWashModeState(washMachineId, XTA_MODE_STATE_NO); + } + } + + if (CI_SUCCESS == ret) + { + wDownWashAllowRelayId = GetDownWashAllowRelayId(washMachineId); + if ((0U != wDownWashAllowRelayId) && (UINT16_MAX != wDownWashAllowRelayId)) + { + chDownWashAllowState = GetRelayCollState(wDownWashAllowRelayId); + /*̵*/ + if (RELAY_STATE_UP == chDownWashAllowState) + { + /*ýģʽϴͬ״̬Ϊ*/ + SetDownWashAllowState(washMachineId, WASH_COL_STATE_ALLOW_YES); + } + else + { + /*ýģʽϴͬ״̬Ϊ*/ + SetDownWashAllowState(washMachineId, WASH_COL_STATE_ALLOW_NO); + } + } + else + { + /*ýģʽϴͬ״̬Ϊ*/ + SetDownWashAllowState(washMachineId, WASH_COL_STATE_ALLOW_NO); + } + } + + if (CI_SUCCESS == ret) + { + wDownWashAllowPassRelayId = GetDownWashAllowPassRelayId(washMachineId); + if ((0U != wDownWashAllowPassRelayId) && (UINT16_MAX != wDownWashAllowPassRelayId)) + { + chDownWashAllowPassState = GetRelayCollState(wDownWashAllowPassRelayId); + /*̵*/ + if (RELAY_STATE_UP == chDownWashAllowPassState) + { + /*ýģʽϴͬͨ״̬Ϊ*/ + SetDownWashAllowPassState(washMachineId, WASH_COL_STATE_ALLOW_PASS_YES); + } + else + { + /*ýģʽϴͬͨ״̬Ϊ*/ + SetDownWashAllowPassState(washMachineId, WASH_COL_STATE_ALLOW_PASS_NO); + } + } + else + { + /*ýģʽϴͬͨ״̬Ϊ*/ + SetDownWashAllowPassState(washMachineId, WASH_COL_STATE_ALLOW_PASS_NO); + } + } + } + + return ret; +} + + +/* +* ݼ̵ɼݻȡָIDźŻʾɫ +* ˵ const UINT16 signalId +* ֵ 0u: SIGNAL_SHOWCOLOUR_INVALID +* >0u: ǰʾɫ +*/ +UINT8 GetRelayToDeviceSignalColor(const UINT16 signalId) +{ + UINT16 lxRelayStatus = 0u; /*гźż̵ID*/ + UINT16 zxRelayStatus = 0u; /*źż̵ID*/ + UINT16 yxRelayStatus = 0u; /*źż̵ID*/ + UINT16 ddRelayStatus = 0u; /*Ƽ̵ID*/ + UINT16 dxRelayStatus = 0u; /*źż̵ID*/ + UINT8 fengDengType = 0u; /*źŻ*/ + UINT8 returnValue = 0u;/*ֵ*/ + + lxRelayStatus = GetRelayCollState(GetSignalLxRelayId(signalId)); /*ȡźŻгźż̵ID*/ + zxRelayStatus = GetRelayCollState(GetSignalZxRelayId(signalId)); /*ȡźŻźż̵ID*/ + yxRelayStatus = GetRelayCollState(GetSignalYxRelayId(signalId)); /*ȡźŻźż̵ID*/ + dxRelayStatus = GetRelayCollState(GetSignalDxRelayId(signalId)); /*ȡźŻźż̵ID*/ + ddRelayStatus = GetRelayCollState(GetSignalDdRelayId(signalId)); /*ȡźŻƼ̵ID*/ + fengDengType = GetSignalFengDengType(signalId); /*ȡźŻ߼*/ + + + if ((RELAY_STATE_UP == lxRelayStatus) + && (RELAY_STATE_DOWN != zxRelayStatus) + && (RELAY_STATE_UP != yxRelayStatus) + && (CI_ERROR == dxRelayStatus)) + {/*̵ƣ + * гźż̵̵Ĭ̬źż̵ޡźŻ»ޡ + * Ƿ̵ơ޵źż̵ + * ֻLXJ÷ֻ֧LXJƵ + */ + if (SIGNAL_TYPE_FENG_GREEN != fengDengType) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN; /*̵*/ + + } + else + { /*̵*/ + returnValue = SIGNAL_SHOWCOLOUR_YELLOW; /*Ƶ*/ + } + } + else if ((RELAY_STATE_UP == lxRelayStatus) + && (RELAY_STATE_UP != zxRelayStatus) + && (RELAY_STATE_UP != yxRelayStatus) + && (RELAY_STATE_UP != dxRelayStatus)) + {/*ƵƣLXJ, zxj»ޣDXJ»ޣYXJ»ޡ + * ֻLXJ÷֧ + */ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW; /*Ƶ*/ + + } + else if ((RELAY_STATE_UP != lxRelayStatus) + && (RELAY_STATE_DOWN != zxRelayStatus) + && (RELAY_STATE_UP != yxRelayStatus) + && (RELAY_STATE_UP != dxRelayStatus)) + {/*ƣ + * øü̵̵״̬Ϊ·Ĭ̬ZXJ: LXJ: YXJ: DXJ: + * û״̬ȡCI_ERRORֻҪжǷ Ĭ״̬෴״̬ + */ + returnValue = SIGNAL_SHOWCOLOUR_RED; /**/ + + } + else if ((RELAY_STATE_DOWN == lxRelayStatus) + && (RELAY_STATE_UP == yxRelayStatus) + && (CI_ERROR == dxRelayStatus)) + {/*ƵƣLXJ£YXJ״̬״̬Ĭ״̬,DXJ + * + */ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW; /*Ƶ*/ + } + else if ((RELAY_STATE_UP != lxRelayStatus) + && (CI_ERROR == zxRelayStatus) + && (CI_ERROR == yxRelayStatus) + && (RELAY_STATE_UP == dxRelayStatus)) + {/*׵ƣгźż̵»ޡźż̵ޡźŻޡźż̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_WHITE; /*׵*/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + + /* ,Ϊ */ + if (RELAY_STATE_UP == ddRelayStatus) + { + if ((returnValue != SIGNAL_SHOWCOLOUR_WHITE) && (returnValue != SIGNAL_SHOWCOLOUR_REDYELLOW)) + { + /*Ƽ̵Ϊ*/ + returnValue = GetCloseSignaleColor(returnValue); /**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; /* Ƶ,׵Ʋ */ + } + } + + return returnValue; +} + +/* +* ɫȡӦ״̬ +* ˵ const UINT8 color +* ֵ 0u: SIGNAL_SHOWCOLOUR_INVALID +* >0u: ǰʾɫ +*/ +UINT8 GetCloseSignaleColor(const UINT8 color) +{ + UINT8 ret = SIGNAL_SHOWCOLOUR_INVALID; + switch (color) + { + case SIGNAL_SHOWCOLOUR_RED: + ret = SIGNAL_SHOWCOLOUR_REDCLOSE; + break; + case SIGNAL_SHOWCOLOUR_YELLOW: + ret = SIGNAL_SHOWCOLOUR_YELLOWCLOSE; + break; + case SIGNAL_SHOWCOLOUR_GREEN: + ret = SIGNAL_SHOWCOLOUR_GREENCLOSE; + break; + default: + /*ɴ֧*/ + break; + } + + return ret; +} + +/* +* ݼ̵ɼݻȡָIDźŻʾɫ-ûDDJ⴦ +* ˵ const UINT16 signalId +* ֵ 0u: SIGNAL_SHOWCOLOUR_INVALID +* >0u: ǰʾɫ +*/ +UINT8 GetNoDDJSignalColor(const UINT16 signalId) +{ + UINT16 firDsRelayId = 0u; /*1˿̵ID */ + UINT16 secDsRelayId = 0u; /*2˿̵ID*/ + UINT16 lxRelayId = 0u; /*гźż̵ID*/ + UINT16 zxRelayId = 0u; /*źż̵ID*/ + UINT16 yxRelayId = 0u; /*źż̵ID*/ + UINT16 dxRelayId = 0u; /*źż̵ID*/ + UINT16 yellowRelayId = 0u; /*ƵƼ̵ID*/ + UINT16 greenRelayId = 0u; /*̵Ƽ̵ID*/ + UINT16 blueRelayId = 0u; /*Ƽ̵ID*/ + UINT8 signalType = 0u; /*źŻƵ·*/ + UINT8 returnValue = 0u;/*ֵ*/ + UINT8 bCiSwitchShowGreenYellow = FUNC_SWITCH_OFF;/*ciʾ̻ƿ,Ĭǹرյ*/ + + UINT8 firDsRelaySta = RELAY_STATE_DOWN; /*1˿̵״̬*/ + UINT8 secDsRelaySta = RELAY_STATE_DOWN; /*2˿̵״̬*/ + UINT8 lxRelaySta = RELAY_STATE_DOWN; /*гźż̵״̬*/ + UINT8 zxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 yxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 dxRelaySta = RELAY_STATE_DOWN; /*źż̵״̬*/ + UINT8 yellowRelaySta = RELAY_STATE_DOWN; /*ƵƼ̵״̬*/ + UINT8 greenRelaySta = RELAY_STATE_DOWN; /*̵Ƽ̵״̬*/ + UINT8 blueRelaySta = RELAY_STATE_DOWN; /*Ƽ̵״̬*/ + + firDsRelayId = GetSignalFirstDsRelayId(signalId); /*ȡźŻ1˿̵ID*/ + secDsRelayId = GetSignalSecondDsRelayId(signalId); /*ȡźŻ2˿̵ID*/ + lxRelayId = GetSignalLxRelayId(signalId); /*ȡźŻгźż̵ID*/ + zxRelayId = GetSignalZxRelayId(signalId); /*ȡźŻźż̵ID*/ + yxRelayId = GetSignalYxRelayId(signalId); /*ȡźŻźż̵ID*/ + dxRelayId = GetSignalDxRelayId(signalId); /*ȡźŻźż̵ID*/ + yellowRelayId = GetSignalYellowRelayId(signalId); /*ƵƼ̵ID*/ + greenRelayId = GetSignalGreenRelayId(signalId); /*̵Ƽ̵ID*/ + blueRelayId = GetSignalBlueRelayId(signalId); /*Ƽ̵ID*/ + + signalType = GetSignalType(signalId); /*ȡźŻ߼*/ + + firDsRelaySta = GetRelayCollState(firDsRelayId); /*ȡźŻ1˿̵״̬*/ + secDsRelaySta = GetRelayCollState(secDsRelayId); /*ȡźŻ2˿̵״̬*/ + lxRelaySta = GetRelayCollState(lxRelayId); /*ȡźŻгźż̵״̬*/ + yxRelaySta = GetRelayCollState(yxRelayId); /*ȡźŻźż̵״̬*/ + zxRelaySta = GetRelayCollState(zxRelayId); /*ȡźŻźż̵״̬*/ + dxRelaySta = GetRelayCollState(dxRelayId); /*ȡźŻźż̵״̬*/ + yellowRelaySta = GetRelayCollState(yellowRelayId); + greenRelaySta = GetRelayCollState(greenRelayId); + blueRelaySta = GetRelayCollState(blueRelayId); + + bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow); + + switch (signalType) + { + case SIGNAL_TYPE_5_NOGREEN_YINDAO_CD:/*0x2C ʾ̵ơɵ˫Ƶƣ졢ơ̡ס˫*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW;/*˫Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED_WHITE;/*׵*/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + + } + break; + } + case SIGNAL_TYPE_5_NOY_NOYINDAO_CD:/*0x2D ʾƵơ졢̡˫̡*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == zxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/*̵*/ + } + else if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == zxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_DOUBLE_GREEN;/*˫̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == zxRelaySta) && (RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/*׵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == zxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + } + break; + } + case SIGNAL_TYPE_4_ALL_NOYINDAO_CD:/*0x2E ʾ*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == greenRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/*̵*/ + } + else if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/*׵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == greenRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + + } + break; + } + case SIGNAL_TYPE_5_NOY_NOYINDAO_WB:/*0x2f λźŻƵƣס*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_DOUBLE_GREEN;/*˫̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/*׵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + + } + break; + } + case SIGNAL_TYPE_3_RGG_CD:/*0x30 3λ졢˫*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == dxRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_DOUBLE_GREEN; /*˫̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == dxRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED; /**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + + } + break; + } + case SIGNAL_TYPE_3_RGG_NOGREEN_CD:/*0x31 3λ졢˫̵̡*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN; /*̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED; /**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + + } + break; + } + case SIGNAL_TYPE_3_NOGREENWHITE_CD:/*0x32 3λ̡졢ף̡׵*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED; /**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + + } + break; + } + + case SIGNAL_TYPE_4_NOGREENBLUE_NOYINDAO_ZX:/*0x34 źŻơ̡졢ĵλ̡ƣɵƵƣ*/ + { + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + + } + break; + } + case SIGNAL_TYPE_3_ALL_NOYINDAO_CD:/*0x35 źŻ(ơ)̣*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) && (RELAY_STATE_DOWN == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/*̵*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) && (RELAY_STATE_UP == dxRelaySta) && (RELAY_STATE_UP == firDsRelaySta)) + { + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/*׵*/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + break; + } + case SIGNAL_TYPE_1_ALL_END:/*0x36 ʾͷ赲źŻ*/ + { + if (RELAY_STATE_UP == firDsRelaySta) + { + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID;/*Ч*/ + } + break; + } + case SIGNAL_TYPE_THREE_ALL_YINDAO:/*ʾ졢ơ̡ƣ*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == zxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵źż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵¡źŻ1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵źż̵źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_THREE_ALL_NOYINDAO:/*ʾ졢ợ*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == zxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*гźż̵źż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == zxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*гźż̵źż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_THREE_NOGREEN_YINDAO:/*ʾ̵ƣ졢ơƣ*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵¡źŻ1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO:/*ʾ̵졢ƣ*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*гźż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_THREE_NOYELLOW_YINDAO:/*źŻ(ʾ޻Ƶƣ)*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵¡źŻ1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_THREE_ALL_YINDAO_NOY:/*źŻ(ʾƣɵƵ)*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵¡źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵źŻ¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵¡źŻ1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO:/*ʾƵ졢̣*/ + case SIGNAL_TYPE_TWO_ALL_NOYINDAO:/*ʾ졢̣*/ + { + if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*гźż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_TWO_NOGREEN_NOYINDAO:/*ʾ̵ƣ죩*/ + { + if (RELAY_STATE_UP == firDsRelaySta) + {/*1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_DIAOCHE:/*źŻ졢ף*/ + { + if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_JINKUCHUKU:/*źŻ*/ + { + if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵¡гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵гźż̵¡1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta)) + {/*źż̵¡гźż̵1˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_TWO_JINKU_RGY:/*/źŻ(ʾ),ơ̵ƺƵ*/ + { + if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta)) + {/*гźż̵ && źż̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_GREEN;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta)) + {/*гźż̵ && źż̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta)) + {/*гźż̵ && źż̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL:/*źŻ(ʾ̵ƣ)*/ + { + if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵ && źż̵ && 1˿̵ && 2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵ && źż̵ && 1˿̵ && 2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/*Ƶ*/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵ && źż̵ && 1˿̵ && 2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_THREE_DIAOCHE_YINDAO:/*δźŻ(ʾ׵ƣ)*/ + { + if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*źż̵¡źż̵¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*źż̵źż̵¡1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else if ((RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*źż̵¡źż̵1˿̵2˿̵*/ + + returnValue = SIGNAL_SHOWCOLOUR_RED_WHITE;/**/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + } + break; + } + case SIGNAL_TYPE_THREE_JINKU_YINDAO: /*źŻʾ*/ /*»źŻ2019.1.15*/ + { + if ((RELAY_STATE_UP == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + {/*гźż̵𡢵źż̵¡źż̵¡1˿̵2˿̵*/ + returnValue = SIGNAL_SHOWCOLOUR_YELLOW;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_UP == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + { /*гźż̵¡źż̵źż̵¡1˿̵2˿̵*/ + returnValue = SIGNAL_SHOWCOLOUR_WHITE;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_DOWN == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_DOWN == secDsRelaySta)) + { /*гźż̵¡źż̵¡źż̵¡1˿̵2˿̵*/ + returnValue = SIGNAL_SHOWCOLOUR_RED;/**/ + } + else if ((RELAY_STATE_DOWN == lxRelaySta) + && (RELAY_STATE_DOWN == dxRelaySta) + && (RELAY_STATE_UP == yxRelaySta) + && (RELAY_STATE_UP == firDsRelaySta) + && (RELAY_STATE_UP == secDsRelaySta)) + {/*гźż̵¡źż̵¡źż̵1˿̵2˿̵*/ + returnValue = SIGNAL_SHOWCOLOUR_REDYELLOW;/*Ƶ*/ + } + else + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; /*Ч̵*/ + } + break; + } + default: + { + returnValue = SIGNAL_SHOWCOLOUR_INVALID; + break; + } + } + return returnValue; +} + + +/* +* ½·ĵͬ߼״̬ +* ˵ void +* ֵ void +*/ +void RouteDCTYRelayToDeviceStateProc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 routeCurSum = 0u; /*·*/ + UINT16 routeId = 0u; /*·ID*/ + UINT8 localCi = 0u; + UINT8 belongCi = 0u; + + UINT8 tmpExecRes = CI_ERROR;/*ʱִн*/ + UINT8 reVal = CI_ERROR;/*ֵ*/ + + + UINT16 routeDCTYId = 0u;/*̵ͬid*/ + UINT16 routeDCQJId = 0u; /*̵id*/ + + + UINT8 relayCollState = 0u;/*̵ɼ״̬*/ + + routeCurSum = GetRouteCurSum(); + localCi = GetSystemParaLocalCiId();/**/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = GetRouteId(ii); + + /*֤·id벻Ϊ0u*/ + if (0u == routeId) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + {/*֤·Ϊ*/ + belongCi = GetRouteBelongCiId(routeId); + + if (belongCi == localCi) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + + if (CI_SUCCESS == reVal) + { + routeDCQJId = GetRouteDCQJId(routeId);/*ȡ·̵id*/ + + if (routeDCQJId > 0u) + { + relayCollState = GetRelayCollState(routeDCQJId); + if (RELAY_STATE_UP == relayCollState) + { + tmpExecRes = SetRouteDCQState(routeId, ROUTE_DCQ_REQUEST);/*е*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + tmpExecRes = SetRouteDCQState(routeId, ROUTE_DCQ_NOT_REQUEST);/*£ûе*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else + { + /*Ƿֵ*/ + tmpExecRes = SetRouteDCQState(routeId, ROUTE_DCQ_NOT_REQUEST);/*Ƿֵ´ûе*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + } + + routeDCTYId = GetRouteDCTAJId(routeId);/*ȡ·̵ͬid*/ + + if (routeDCTYId > 0u) + { + relayCollState = GetRelayCollState(routeDCTYId); + if (RELAY_STATE_UP == relayCollState) + { + tmpExecRes = SetRouteDCTYState(routeId, ROUTE_DCT_AGREE);/*𣬵ͬ*/ + + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else if (RELAY_STATE_DOWN == relayCollState) + { + tmpExecRes = SetRouteDCTYState(routeId, ROUTE_DCT_NOT_AGREE);/*£ͬ*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + else + { + /*Ƿֵ*/ + tmpExecRes = SetRouteDCTYState(routeId, ROUTE_DCT_NOT_AGREE);/*£ͬ*/ + if (CI_ERROR == tmpExecRes) + { + /**/ + } + } + } + } + } +} + + +/* +* µ̵ͬ״̬ +* ˵ void +* ֵ +*/ +void RouteDCTYToRelayStateProc(void) +{ + UINT16 ii = 0u; /* α */ + UINT16 routeSum = 0u; /* · */ + UINT16 routeId = 0u; /* ID */ + UINT8 routeType = 0u;/*·*/ + UINT16 routeDCQRelayId = 0u; + UINT8 routeDCQState = 0u; + + UINT8 localCi = 0u; + UINT8 belongCi = 0u; + + UINT8 reVal = CI_ERROR; + + localCi = GetSystemParaLocalCiId();/**/ + routeSum = GetRouteCurSum(); + + for (ii = 0u; ii < routeSum; ii++) + { + routeId = GetRouteId(ii); + + /*֤·id벻Ϊ0*/ + if (0u == routeId) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + {/*֤·Ϊ*/ + belongCi = GetRouteBelongCiId(routeId); + + if (belongCi == localCi) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + {/*·Ϊ·*/ + routeType = GetRouteType(routeId); + if (ROUTE_TYPE_DIAOCHE == routeType) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + { + routeDCQState = GetRouteDCQState(routeId); + + routeDCQRelayId = GetRouteDCQJId(routeId); + + if (routeDCQRelayId > 0u) + {/*·̵id0u*/ + if (ROUTE_DCQ_REQUEST == routeDCQState) + {/*еõ̵Ϊ*/ + (void)SetRelayDriveState(routeDCQRelayId, RELAY_DRIVE_STATE_UP); + } + else + {/*޵õ̵Ϊ*/ + (void)SetRelayDriveState(routeDCQRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + } + + } +} + +/* +* ֻвɼгźż̵״̬źŻɫ +* ˵ const UINT16 signalId :źŻID +* ֵ +*/ +void SetNoDriveSignalCurColor(const UINT16 signalId) +{ + UINT16 firDsRelayId = 0u; /*1˿̵ID */ + UINT16 secDsRelayId = 0u; /*2˿̵ID*/ + UINT16 lxRelayId = 0u; /*гźż̵ID*/ + UINT16 zxRelayId = 0u; /*źż̵ID*/ + UINT16 yxRelayId = 0u; /*źż̵ID*/ + UINT16 dxRelayId = 0u; /*źż̵ID*/ + UINT16 yellowRelayId = 0u; /*ƵƼ̵ID*/ + UINT16 greenRelayId = 0u; /*̵Ƽ̵ID*/ + UINT16 blueRelayId = 0u; /*Ƽ̵ID*/ + UINT16 replxRelayId = 0u; /*ʾгźż̵ID*/ + UINT16 ddRelayId = 0u; /*Ƽ̵ID*/ + UINT8 blockOpenColor = 0u; /*ģʽҪɫ*/ + UINT8 signalType = 0u; /*źŻƵ·*/ + UINT8 repLxRelaySta = RELAY_STATE_DOWN; /*ʾгźż̵״̬*/ + + firDsRelayId = GetSignalFirstDsRelayId(signalId); /*ȡźŻ1˿̵ID*/ + secDsRelayId = GetSignalSecondDsRelayId(signalId); /*ȡźŻ2˿̵ID*/ + lxRelayId = GetSignalLxRelayId(signalId); /*ȡźŻгźż̵ID*/ + zxRelayId = GetSignalZxRelayId(signalId); /*ȡźŻźż̵ID*/ + yxRelayId = GetSignalYxRelayId(signalId); /*ȡźŻźż̵ID*/ + dxRelayId = GetSignalDxRelayId(signalId); /*ȡźŻźż̵ID*/ + yellowRelayId = GetSignalYellowRelayId(signalId); /*ƵƼ̵ID*/ + greenRelayId = GetSignalGreenRelayId(signalId); /*̵Ƽ̵ID*/ + blueRelayId = GetSignalBlueRelayId(signalId); /*Ƽ̵ID*/ + replxRelayId = GetSignalRepLxRelayId(signalId); + ddRelayId = GetSignalDdRelayId(signalId); /*ȡźŻƼ̵ID*/ + signalType = GetSignalType(signalId); /*ȡźŻ߼*/ + repLxRelaySta = GetRelayCollState(replxRelayId); /*ȡʾгźż̵̵״̬*/ + + /*ֻвɼжϳLXJ̵IDȫΪ0u人5-8*/ + if ((0u == firDsRelayId) && (0u == secDsRelayId) && (0u == lxRelayId) && (0u == zxRelayId) + && (0u == yxRelayId) && (0u == dxRelayId) && (0u == yellowRelayId) && (0u == greenRelayId) + && (0u == blueRelayId) && (0u != replxRelayId)) + { + if (RELAY_STATE_UP == repLxRelaySta) + { + /*ȡźŻģʽɫ*/ + blockOpenColor = GetSignalBlockOpenColorValue((UINT16)signalType); + /*õɫ*/ + (void)SetSignalCurColor(signalId, blockOpenColor); + } + else + { + /*ú*/ + (void)SetSignalCurColor(signalId, SIGNAL_SHOWCOLOUR_RED); + } + } + +} + +/* +* ȡԶ־Ƿִ +* ˵ const UINT16 routeId :·ID +* const UINT16 phySecId :ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* ڷڱ·ڱģԶ־ +*/ +UINT8 CheckCancleAutoFlag(const UINT16 routeId, const UINT16 phySecId) +{ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 reVal = CI_ERROR; + UINT8 routeBelongCiId = 0u; + + UINT8 phySecBelongVirCiId = 0u; + UINT8 routeBelongVirCiId = 0u; + UINT8 localCiId = GetSystemParaLocalCiId(); + + routeBelongCiId = GetRouteBelongCiId(routeId); + if (routeBelongCiId == localCiId) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + phySecBelongVirCiId = GetPhySecBelongVirCiId(phySecId); + routeBelongVirCiId = GetRouteBelongVirCiId(routeId); + if ((phySecBelongVirCiId == routeBelongVirCiId) && (0U != routeBelongVirCiId)) + { + reVal = CI_SUCCESS; + } + } + else + { + reVal = CI_SUCCESS; + } + } + return reVal; +} + + +/* +* 豸ɼ״̬߼״̬ +* ˵ void +* ֵ +* +*/ +void ConnectLineRelayToDevStateProc(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT8 devType = 0u; + UINT16 devId = 0u; + UINT8 devIsThisLine = 0u; /*豸Ƿ񱾽·*/ + UINT8 relayColleState = 0u; + UINT16 relayId = 0u; + UINT8 localCiId = 0u; + UINT8 belongCi = 0u; + UINT16 dbRelayId = 0u; + UINT16 fbRelayId = 0u; + UINT16 dsRelayId = 0u; + UINT16 dsQRelayId = 0u; + UINT16 dsHRelayId = 0u; + UINT16 byPassRelayId = 0u; + UINT8 dbRelayState = 0u; + UINT8 fbRelayState = 0u; + UINT8 dsRelayState = 0u; + UINT8 dsQRelayState = 0u; + UINT8 dsHRelayState = 0u; + UINT8 byPassRelayState = 0u; + UINT16 ocConnetDataDevNum = 0u; + UINT16 LxrelayId = 0u; + UINT16 YxrelayId = 0u; + UINT16 DxrelayId = 0u; + UINT8 LxrelayColleState = 0u; + UINT8 YxrelayColleState = 0u; + UINT8 DxrelayColleState = 0u; + OcConnetDataCfgStruct* pOcConnetDataCfgStru = NULL; + UINT8 chBlocOpenColor = 0U; + + /*ȡϢ*/ + ocConnetDataDevNum = GetOcConnetDataDevNum(); + pOcConnetDataCfgStru = GetOcConnetDataCfgStruc(); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if ((0u < ocConnetDataDevNum) && (OC_LIAISON_DEV_SUM_MAX > ocConnetDataDevNum) && (NULL != pOcConnetDataCfgStru)) + { + for (i = 0u; i < ocConnetDataDevNum; i++) + { + /*豸Ϣ*/ + devId = pOcConnetDataCfgStru[i].DevId; + devType = pOcConnetDataCfgStru[i].DevType; + /*źŻLXJ*/ + if (CI_DEVICE_TYPE_SIGNAL == devType) + { + devIsThisLine = GetSignalIsThisLineState(devId); + if (DEV_IS_THIS_LINE_NO == devIsThisLine) + {/*DZ·*/ + /*ȡ̵ɼ״̬豸*/ + belongCi = GetSignalBelongCiId(devId); + if (belongCi == localCiId) + { + LxrelayId = GetSignalLxRelayId(devId); + YxrelayId = GetSignalYxRelayId(devId); + DxrelayId = GetSignalDxRelayId(devId); + + LxrelayColleState = GetRelayCollState(LxrelayId); + YxrelayColleState = GetRelayCollState(YxrelayId); + DxrelayColleState = GetRelayCollState(DxrelayId); + + if (RELAY_STATE_UP == LxrelayColleState) + { + /*̵쳣*/ + if ((RELAY_STATE_UP == YxrelayColleState) || (RELAY_STATE_UP == DxrelayColleState)) + { + /*ú*/ + (void)SetSignalCurColor(devId, SIGNAL_SHOWCOLOUR_RED); + } + else + { + /*ú󱸿ɫպ󱸿ʾ*/ + chBlocOpenColor = GetSignalBlockOpenColorValue(devId); + if (0U != chBlocOpenColor) + { + (void)SetSignalCurColor(devId, chBlocOpenColor); + } + else + { + /*ûƵ*/ + (void)SetSignalCurColor(devId, SIGNAL_SHOWCOLOUR_YELLOW); + } + } + } + else if (RELAY_STATE_UP == YxrelayColleState) + { + /*̵쳣*/ + if ((RELAY_STATE_UP == LxrelayColleState) || (RELAY_STATE_UP == DxrelayColleState)) + { + /*ú*/ + (void)SetSignalCurColor(devId, SIGNAL_SHOWCOLOUR_RED); + } + else + { + /*úƵ*/ + (void)SetSignalCurColor(devId, SIGNAL_SHOWCOLOUR_REDYELLOW); + } + } + else if (RELAY_STATE_UP == DxrelayColleState) + { + /*̵쳣*/ + if ((RELAY_STATE_UP == LxrelayColleState) || (RELAY_STATE_UP == YxrelayColleState)) + { + /*ú*/ + (void)SetSignalCurColor(devId, SIGNAL_SHOWCOLOUR_RED); + } + else + { + /*ð׵*/ + (void)SetSignalCurColor(devId, SIGNAL_SHOWCOLOUR_WHITE); + } + } + else + { + /*ú*/ + (void)SetSignalCurColor(devId, SIGNAL_SHOWCOLOUR_RED); + } + } + } + } + /*GJ*/ + else if (CI_DEVICE_TYPE_PHYSEC == devType) + { + /*ȡϢ*/ + belongCi = GetPhySecBelongCiId(devId); + relayId = GetPhySecGdRelayId(devId); + relayColleState = GetRelayCollState(relayId); + devIsThisLine = GetPhyIsThisLineState(devId); + if (DEV_IS_THIS_LINE_NO == devIsThisLine) + {/*DZ·*/ + if (belongCi == localCiId) + { + if (RELAY_STATE_UP == relayColleState) + { + /*ο*/ + SetPhySecCurOccupyState(devId, SECTION_OCCUPY_NO); + } + else + { + /*ռ*/ + SetPhySecCurOccupyState(devId, SECTION_OCCUPY_YES); + } + } + } + } + /**/ + else if (CI_DEVICE_TYPE_SWITCH == devType) + { + /*ȡϢ*/ + belongCi = GetSwitchBelongCiId(devId); + devIsThisLine = GetSwitchIsThisLineState(devId); + dbRelayId = GetSwitchDbRelayId(devId); + fbRelayId = GetSwitchFbRelayId(devId); + dsRelayId = GetSwitchDsRelayId(devId); + dsQRelayId = GetSwitchDsQRelayId(devId); + dsHRelayId = GetSwitchDsHRelayId(devId); + byPassRelayId = GetSwitchByPassRelayId(devId); + + /*̵״̬*/ + dbRelayState = GetRelayCollState(dbRelayId); + fbRelayState = GetRelayCollState(fbRelayId); + dsRelayState = GetRelayCollState(dsRelayId); + dsQRelayState = GetRelayCollState(dsQRelayId); + dsHRelayState = GetRelayCollState(dsHRelayId); + byPassRelayState = GetRelayCollState(byPassRelayId); + + if (DEV_IS_THIS_LINE_NO == devIsThisLine) + { + /*DZ·*/ + if (belongCi == localCiId) + { + /*ID0*/ + if ((0u < dbRelayId) && (0u < fbRelayId)) + { + /*µλ*/ + if ((RELAY_STATE_UP == dbRelayState) && (RELAY_STATE_DOWN == fbRelayState)) + { + /*õλ*/ + SetSwitchCurPosition(devId, SWITCH_POSITION_DINGWEI); + /*õλ*/ + SetSingleSwitchCurPosition(devId, SWITCH_POSITION_DINGWEI); + } + else if ((RELAY_STATE_DOWN == dbRelayState) && (RELAY_STATE_UP == fbRelayState)) + { + /*õλ*/ + SetSwitchCurPosition(devId, SWITCH_POSITION_FANWEI); + /*õλ*/ + SetSingleSwitchCurPosition(devId, SWITCH_POSITION_FANWEI); + } + else + { + /*õĿ*/ + SetSwitchCurPosition(devId, SWITCH_POSITION_SIKAI); + /*õλ*/ + SetSingleSwitchCurPosition(devId, SWITCH_POSITION_SIKAI); + + } + } + /*·̵0*/ + if (0u < byPassRelayId) + { + /*·״̬*/ + if (RELAY_STATE_UP == byPassRelayState) + { + /*·״̬*/ + SetConnetSwitchByPassState(devId, SWITCH_BYPASS_YES); + } + else + { + /*δ·״̬*/ + SetConnetSwitchByPassState(devId, SWITCH_BYPASS_NO); + } + } + + /*Ϊ0*/ + if (0u != dsRelayId) + { + if (RELAY_STATE_UP == dsRelayState) + { + /*δ*/ + SetConnetSwitchDsState(devId, CONNECT_SWITCH_DANSUO_NO); + } + else + { + /*õ*/ + SetConnetSwitchDsState(devId, CONNECT_SWITCH_DANSUO_YES); + } + } + /*ǰڵ̵*/ + else + { + /*ǰڵ̵*/ + if ((0u != dsQRelayId) && ((0u != dsHRelayId))) + { + /*ǰ𣬺*/ + if ((RELAY_STATE_UP == dsQRelayState) && (RELAY_STATE_DOWN == dsHRelayState)) + { + /*δ*/ + SetConnetSwitchDsState(devId, CONNECT_SWITCH_DANSUO_NO); + } + else + { + /*õ*/ + SetConnetSwitchDsState(devId, CONNECT_SWITCH_DANSUO_YES); + } + } + } + } + } + else if (DEV_IS_THIS_LINE_YES == devIsThisLine) + { + if (belongCi == localCiId) + { + /*·̵0*/ + if (0u < byPassRelayId) + { + /*·״̬*/ + if (RELAY_STATE_UP == byPassRelayState) + { + /*·״̬*/ + SetConnetSwitchByPassState(devId, SWITCH_BYPASS_YES); + } + else + { + /*δ·״̬*/ + SetConnetSwitchByPassState(devId, SWITCH_BYPASS_NO); + } + } + } + } + else + { + ; /**/ + } + } + else + { + /**/ + } + } + } +} + +/* +* 豸߼״̵̬״̬ +* ˵ void +* ֵ +* +*/ +void UpdateConnectDriveRelayOutput(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT8 devType = 0u; + UINT16 devId = 0u; + UINT16 relayId = 0u; /*̵*/ + UINT16 LxrelayId = 0u; /*̵*/ + UINT16 YxrelayId = 0u; /*̵*/ + UINT16 DxrelayId = 0u; /*̵*/ + UINT16 LxCollerelayId = 0u; /*ɼ̵*/ + UINT16 YxCollerelayId = 0u; /*ɼ̵*/ + UINT16 DxCollerelayId = 0u; /*ɼ̵*/ + UINT16 colleRelayId = 0u; /*ɼ̵*/ + UINT8 devIsThisLine = 0u; /*豸Ƿ񱾽·*/ + UINT16 dbRelayId = 0u; /*̵*/ + UINT16 fbRelayId = 0u; /*̵*/ + UINT16 dsRelayId = 0u; /*̵*/ + UINT16 dbColleRelayId = 0u; /*ɼ̵*/ + UINT16 fbColleRelayId = 0u; /*ɼ̵*/ + UINT16 dsColleRelayId = 0u; /*ɼ̵*/ + UINT8 localCiId = 0u; + UINT8 belongCi = 0u; + UINT8 devState = 0u; /*豸״̬*/ + UINT8 signalColor = 0u; + UINT16 ocConnetDataDevNum = 0u; + UINT8 switchBypassState = 0U; /*··״̬*/ + UINT8 switchCurPosition = 0U; /*ǰ״̬*/ + UINT16 switchPhySecId = 0U; /**/ + UINT8 switchPhyOccupyState = 0U; /*ռ״̬ںռ״̬*/ + UINT32 switchBypassWaitCycSum = 0U; /*·ߵδʱȡ·ȴ*/ + UINT32 switchBypassStartCycNum = 0U; /*ߵ·δʱȡʼ*/ + UINT32 curCycle = 0U; + UINT8 checkTimeState = CI_TIME_NO; + OcConnetDataCfgStruct* pOcConnetDataCfgStru = NULL; + UINT8 ciToAtsSendFlag = 0U; + + /*ȡϢ*/ + ocConnetDataDevNum = GetOcConnetDataDevNum(); + pOcConnetDataCfgStru = GetOcConnetDataCfgStruc(); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + switchBypassWaitCycSum = GetSwitchBypassWaitCount(); /*ȡ·ߵδʱȡ·ȴʱ*/ + curCycle = Get2oo2CurCycleNum(); /*ȡǰ*/ + + if ((0u < ocConnetDataDevNum) && (OC_LIAISON_DEV_SUM_MAX > ocConnetDataDevNum) && (NULL != pOcConnetDataCfgStru)) + { + for (i = 0u; i < ocConnetDataDevNum; i++) + { + /*豸Ϣ*/ + devId = pOcConnetDataCfgStru[i].DevId; + devType = pOcConnetDataCfgStru[i].DevType; + /*źŻLXJ*/ + if (CI_DEVICE_TYPE_SIGNAL == devType) + { + belongCi = GetSignalBelongCiId(devId); + if (belongCi == localCiId) + { + devIsThisLine = GetSignalIsThisLineState(devId); + + /*·*/ + if (DEV_IS_THIS_LINE_YES == devIsThisLine) + { + /*źŻϢ*/ + signalColor = GetSignalCurColor(devId); + devState = GetSignalOpenCloseState(signalColor); + LxrelayId = GetSignalLxDrvRelayId(devId); + YxrelayId = GetSignalYxDrvRelayId(devId); + DxrelayId = GetSignalDxDrvRelayId(devId); + + /*źſ*/ + if (SIGNAL_OPEN == devState) + { + if (SIGNAL_SHOWCOLOUR_REDYELLOW == signalColor) + { + /*YXJ*/ + (void)SetRelayDriveState(YxrelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(LxrelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(DxrelayId, RELAY_DRIVE_STATE_DOWN); + } + else if ((SIGNAL_SHOWCOLOUR_WHITE == signalColor) || (SIGNAL_SHOWCOLOUR_RED_WHITE == signalColor)) + { + /*DXJ*/ + (void)SetRelayDriveState(DxrelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(LxrelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(YxrelayId, RELAY_DRIVE_STATE_DOWN); + } + else + { + /*LXJ*/ + (void)SetRelayDriveState(LxrelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(YxrelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(DxrelayId, RELAY_DRIVE_STATE_DOWN); + } + } + else + { + /*LXJ,YXJ,DXJ*/ + (void)SetRelayDriveState(LxrelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(YxrelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(DxrelayId, RELAY_DRIVE_STATE_DOWN); + } + + /*Ƿһ£һ±*/ + LxCollerelayId = GetSignalLxRelayId(devId); + ProcessCoupleRelayHunXianState(LxrelayId, LxCollerelayId); + + YxCollerelayId = GetSignalYxRelayId(devId); + ProcessCoupleRelayHunXianState(YxrelayId, YxCollerelayId); + + DxCollerelayId = GetSignalDxRelayId(devId); + ProcessCoupleRelayHunXianState(DxrelayId, DxCollerelayId); + } + else + { + /**/ + } + } + } + /*GJ*/ + else if (CI_DEVICE_TYPE_PHYSEC == devType) + { + /*ȡϢ*/ + belongCi = GetPhySecBelongCiId(devId); + devIsThisLine = GetPhyIsThisLineState(devId); + + if (belongCi == localCiId) + { + /*·*/ + if (DEV_IS_THIS_LINE_YES == devIsThisLine) + { + /*ȡεǰɼ״̬*/ + devState = GetPhySecCurOccupyState(devId); + relayId = GetPhySecGdDrvRelayId(devId); + + if (SECTION_OCCUPY_NO == devState) + { + /*GJ*/ + (void)SetRelayDriveState(relayId, RELAY_DRIVE_STATE_UP); + } + else + { + /**/ + (void)SetRelayDriveState(relayId, RELAY_DRIVE_STATE_DOWN); + } + + /*Ƿһ£һ±*/ + colleRelayId = GetPhySecGdRelayId(devId); + ProcessCoupleRelayHunXianState(relayId, colleRelayId); + } + else + { + /**/ + } + } + } + /**/ + else if (CI_DEVICE_TYPE_SWITCH == devType) + { + /*ȡϢ*/ + belongCi = GetSwitchBelongCiId(devId); + devIsThisLine = GetSwitchIsThisLineState(devId); + dbRelayId = GetSwitchDbDrvRelayId(devId); + fbRelayId = GetSwitchFbDrvRelayId(devId); + dsRelayId = GetSwitchDsDrvRelayId(devId); + + if (belongCi == localCiId) + { + /*·*/ + if (DEV_IS_THIS_LINE_YES == devIsThisLine) + { + /*ȡ״̬*/ + devState = GetSwitchLockStatus(devId); + /*õ̵״̬*/ + if ((SWITCH_LOCK_STATUS_DANSUO == devState) || (SWITCH_LOCK_STATUS_DAP == devState)) + { + /**/ + (void)SetRelayDriveState(dsRelayId, RELAY_DRIVE_STATE_DOWN); + } + else + { + /**/ + (void)SetRelayDriveState(dsRelayId, RELAY_DRIVE_STATE_UP); + } + /*õλü̵״̬*/ + SetConnectSwitchPosRelayDrvSta(devId, dbRelayId, fbRelayId); + + /*鱾·ڵĵǷ··ҪǷڶλδռѹʼʱ*/ + switchBypassState = GetConnetSwitchByPassState(devId); + if (SWITCH_BYPASS_YES == switchBypassState) + { + switchCurPosition = GetSwitchCurPosition(devId); + switchPhySecId = GetSwitchPhySectionId(devId); + switchPhyOccupyState = GetPhySecCurMergeState(switchPhySecId); + switchBypassStartCycNum = GetSwitchBypassStartCycNum(devId); /*ȡָIDߵ·δʱȡʼ*/ + ciToAtsSendFlag = GetCiToAtsByPassNoCancelFlag(devId); + if ((SWITCH_POSITION_DINGWEI == switchCurPosition) && (SECTION_OCCUPY_NO == switchPhyOccupyState)) + {/*λҿУʼʱʱATS·δʱȡ*/ + + checkTimeState = SystemOverTimeCheck(switchBypassStartCycNum, switchBypassWaitCycSum); + + if (CI_TIME_NO == checkTimeState) + { + SetSwitchBypassStartCycNum(devId, curCycle); /*ָIDߵ·δʱȡʼ*/ + } + else if (CI_TIME_OUT == checkTimeState) + { + /*ATSߵ·δʱȡ*/ + if (CI_ATS_SW_BYPASS_NOCANCEL_NO == ciToAtsSendFlag) + { + SetCiSendCmdBackInfoData(CI_BACK_SWT_BYPASS_CANCEL_NO, CI_DEVICE_TYPE_SWITCH, devId, 0u, 0u); + SetCiToAtsByPassNoCancelFlag(devId, CI_ATS_SW_BYPASS_NOCANCEL_YES); /*ATSٷͱֻһ*/ + } + else + { + /*ѷ͹ٷ*/ + } + } + else + { + ; /*δʱ*/ + } + } + else + { + /*ʱȴٿʱ¼ʱ*/ + SetSwitchBypassStartCycNum(devId, 0U); + SetCiToAtsByPassNoCancelFlag(devId, CI_ATS_SW_BYPASS_NOCANCEL_NO); /*巢ͼ¼*/ + } + } + else + { + /*δ·ʼں*/ + SetSwitchBypassStartCycNum(devId, 0U); + SetCiToAtsByPassNoCancelFlag(devId, CI_ATS_SW_BYPASS_NOCANCEL_NO); /*巢ͼ¼*/ + } + + /*Ƿһ£һ±*/ + dbColleRelayId = GetSwitchDbRelayId(devId); + ProcessCoupleRelayHunXianState(dbRelayId, dbColleRelayId); + + fbColleRelayId = GetSwitchFbRelayId(devId); + ProcessCoupleRelayHunXianState(fbRelayId, fbColleRelayId); + + dsColleRelayId = GetSwitchDsRelayId(devId); + ProcessCoupleRelayHunXianState(dsRelayId, dsColleRelayId); + } + } + } + else + { + /**/ + } + } + } +} + +/* +* ߵ̵״̬ +* ˵ const UINT16 devId 豸ID +* const UINT16 dbRelayId ̵ID +* const UINT16 fbRelayId ̵ID +* ֵ +* +*/ +void SetConnectSwitchPosRelayDrvSta(const UINT16 devId, const UINT16 dbRelayId, const UINT16 fbRelayId) +{ + UINT8 devState = 0u; /*豸״̬*/ + + devState = GetSwitchCurPosition(devId); + /*ID0 */ + if ((0u < dbRelayId) && (0u < fbRelayId)) + { + if (SWITCH_POSITION_DINGWEI == devState) + { + /*𡢷*/ + (void)SetRelayDriveState(dbRelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(fbRelayId, RELAY_DRIVE_STATE_DOWN); + } + else if (SWITCH_POSITION_FANWEI == devState) + { + /*¡*/ + (void)SetRelayDriveState(dbRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(fbRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /**/ + (void)SetRelayDriveState(dbRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(fbRelayId, RELAY_DRIVE_STATE_DOWN); + } + } +} + +/* +* Ƿ״̬ +* ˵ +* +* ֵ 1ǻ״̬ +* 0״̬ +* +*/ +UINT8 CheckRelayHunXiandState(const UINT16 relayId) +{ + /*ʼ*/ + UINT8 relayColleState = 0u; + UINT8 relayDriveState = 0u; + UINT8 retValue = CI_ERROR; + UINT32 curCycNum = 0u; + UINT8 checkRelayRes = 0u; + UINT32 relayCycNum = 0u; + + curCycNum = Get2oo2CurCycleNum(); + + if (0u < relayId) + { + retValue = CI_SUCCESS; + /*ȡ̵״̬*/ + relayColleState = GetRelayCollState(relayId); /*ɼ״̬*/ + relayDriveState = GetRelayDriveState(relayId); /*״̬*/ + + /**/ + if((RELAY_DRIVE_STATE_DOWN == relayDriveState) || (RELAY_DRIVE_STATE_NULL == relayDriveState)) + { + /**/ + if (RELAY_STATE_UP == relayColleState) + { + relayCycNum = GetRelayHunXianStarCycNum(relayId); + checkRelayRes = SystemOverTimeCheck(relayCycNum, RELAY_HUNXIAN_NUM); + /*δʱ*/ + if (CI_TIME_NO == checkRelayRes) + { + SetRelayHunXianStarCycNum(relayId, curCycNum);/*ü̵Ч*/ + } + /*ʱ*/ + else if (CI_TIME_OUT == checkRelayRes) + { + retValue = CI_ERROR; + } + else + { + /*ʱУسɹ*/ + } + } + else + { + SetRelayHunXianStarCycNum(relayId, 0u);/*ü̵Ч*/ + } + } + /*߼*/ + else + { + SetRelayHunXianStarCycNum(relayId, 0u);/*ü̵Ч*/ + } + } + return(retValue); +} + +/* +* µװ״̬ +* ˵ void +* ֵ +*/ +void RvrsCutRlyToDvicSttPrc(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 wReverseCutSum = 0u; /*豸*/ + UINT16 wReverseCutId = 0u; /*豸ID*/ + UINT16 wReverseCutRelayId = 0u;/*豸̵ID*/ + UINT8 reVal = CI_ERROR; + UINT8 chRelayState = 0u; + UINT8 chReverseCutState = 0U; + UINT8 chAllReverseCutState = 0U; + UINT8 localCi = GetSystemParaLocalCiId();/**/ + UINT8 chBelongCiId = 0U; + + wReverseCutSum = GetReverseCutCurSum(); + + for (ii = 0u; ii < wReverseCutSum; ii++) + { + wReverseCutId = GetReverseCutId(ii); + if (CI_ERROR == wReverseCutId) + { + reVal = CI_ERROR; + } + else + { + + wReverseCutRelayId = GetReverseCutRelayId(wReverseCutId); + chBelongCiId = GetRelayBelongCiId(wReverseCutRelayId);/*esb*/ + if (chBelongCiId == localCi) + { + /*̵Ϊ*/ + chRelayState = GetRelayCollState(wReverseCutRelayId); + if (RELAY_STATE_DOWN == chRelayState) + { + SetReverseCutState(wReverseCutId, REVERSE_DEVICE_CUT_STATE_DOWN); + } + else if (RELAY_STATE_UP == chRelayState) + { + SetReverseCutState(wReverseCutId, REVERSE_DEVICE_CUT_STATE_UP); + } + else + { + SetReverseCutState(wReverseCutId, REVERSE_DEVICE_CUT_STATE_DOWN); + } + + } + } + } + + for (ii = 0u; ii < wReverseCutSum; ii++) + { + wReverseCutId = GetReverseCutId(ii); + if (CI_ERROR == wReverseCutId) + { + reVal = CI_ERROR; + } + else + { + chBelongCiId = GetReverseCutBelongCiId(wReverseCutId);/*esb*/ + if (chBelongCiId == localCi) + { + /*̵Ϊ*/ + chReverseCutState = GetReverseCutState(wReverseCutId); + if (REVERSE_DEVICE_CUT_STATE_DOWN == chReverseCutState) + { + chAllReverseCutState |= REVERSE_DEVICE_CUT_STATE_DOWN; + } + else if (REVERSE_DEVICE_CUT_STATE_UP == chReverseCutState) + { + chAllReverseCutState |= REVERSE_DEVICE_CUT_STATE_UP; + } + else + { + chAllReverseCutState |= REVERSE_DEVICE_CUT_STATE_DOWN; + } + + } + } + } + + if (REVERSE_DEVICE_CUT_STATE_UP != chAllReverseCutState) + { + if (0U != chAllReverseCutState) + { + SetTiocSystemMode(REVERSE_MODE_SHADOW); + } + else + { + + } + } + else + { + SetTiocSystemMode(REVERSE_MODE_MAIN); + } + + ReverseCutReasonProcess(); +} + +/* +* Ƿɵԭ +* ˵ void +* ֵ +*/ +void ReverseCutReasonProcess(void) +{ + UINT8 deviceSum = 0u;/*ͨ豸*/ + UINT8* pDeviceIdBuf = NULL;/*ͨ豸ID*/ + UINT16 ii = 0U; + UINT8 chCommState = 0U; + UINT16 wTrainSum = 0U; + UINT16 wTrainId = 0U; + UINT8 chLocalCiId = 0U; + UINT8 chCanntCutReason = 0U; + UINT8 chTiocSystemMode = 0U; + chLocalCiId = GetSystemParaLocalCiId(); + + /*ǰɵԭ*/ + SetTiocCanntCutReason(0U); + chTiocSystemMode = GetTiocSystemMode(); + if (REVERSE_MODE_MAIN != chTiocSystemMode) + { + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC); /*ȡͨOC豸*/ + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); /*ȡͨOC豸ID*/ + + if (pDeviceIdBuf != NULL) + { + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > deviceSum) + { + /*Чж*/ + for (ii = 0u; ii < deviceSum; ii++) + {/*뱾CIͨŵOCϵͳ*/ + /*CIͨ״̬*/ + (void)UpdateCiTransmitState(chLocalCiId, CI_SYSTEM_TYPE_OC, pDeviceIdBuf[ii]); + chCommState = GetCiTransmitState(CI_SYSTEM_TYPE_OC, pDeviceIdBuf[ii]); + + if (TRANSMIT_STATE_GOOD != chCommState) + { + SetTiocCanntCutReason(REVERSE_REASON_OC_COMM_ERR); + break; + } + } + } + } + else + { + SetTiocCanntCutReason(REVERSE_REASON_OC_COMM_ERR); + } + + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); /*ȡͨOC豸*/ + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); /*ȡͨOC豸ID*/ + + if (pDeviceIdBuf != NULL) + { + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > deviceSum) + { + /*Чж*/ + for (ii = 0u; ii < deviceSum; ii++) + {/*뱾CIͨŵOCϵͳ*/ + /*CIͨ״̬*/ + (void)UpdateCiTransmitState(chLocalCiId, CI_SYSTEM_TYPE_AXIS, pDeviceIdBuf[ii]); + chCommState = GetCiTransmitState(CI_SYSTEM_TYPE_AXIS, pDeviceIdBuf[ii]); + + if (TRANSMIT_STATE_GOOD != chCommState) + { + SetTiocCanntCutReason(REVERSE_REASON_AXLE_COMM_ERR); + break; + } + } + } + } + else + { + /*ûмϵͳ˴*/ + } + + wTrainSum = GetTrainSum(); + + for (ii = 0U; ii < wTrainSum; ii++) + { + wTrainId = GetTrainId(ii); + /** ȡгͨ״̬*/ + chCommState = GetTrainTransitmitStat(wTrainId); + + /** жͨ״̬Ƿ*/ + if ((TRAIN_COMM_STATE_GOOD == chCommState) + || (TRAIN_COMM_STATE_UNKNOWN == chCommState)) + { + ; /**/ + } + else + { + SetTiocCanntCutReason(REVERSE_REASON_IVOC_COMM_ERR); + } + } + + chCanntCutReason = GetTiocCanntCutReason(); + + if (0U != chCanntCutReason) + { + SetTiocSystemCutState(REVERSE_CUT_STATE_EXCEPTION); + } + else + { + SetTiocSystemCutState(REVERSE_CUT_STATE_NORMAL); + } + } + else + { + SetTiocSystemCutState(REVERSE_CUT_STATE_DEFAULT); + } +} + +/* +* TIOCӰģʽ豸 +* ˵ void +* ֵ void +*/ +void TiocSysShadowDeviceOutputProc(void) +{ + UINT16 wSwitchCurSum = 0u; /*Ŀ*/ + UINT16 wSignalCurSum = 0U; /*źŻĿ*/ + UINT16 wPsdCurSum = 0U; /*Ŀ*/ + + UINT8 chLocalCiId = 0u; /*ID*/ + + UINT16 wDeviceId = 0u; /*ID*/ + UINT8 chBelongCiId = 0u; /*ID*/ + UINT16 ii = 0u; /*ѭ*/ + + chLocalCiId = GetSystemParaLocalCiId(); + + + wSwitchCurSum = GetSwitchCurSum(); + wSignalCurSum = GetSignalCurSum(); + wPsdCurSum = GetPsdSum(); + for (ii = 0u; ii < wSwitchCurSum; ii++) + { + wDeviceId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < wDeviceId) && (SWITCH_SUM_MAX > wDeviceId)) + { + chBelongCiId = GetSwitchBelongCiId(wDeviceId); /*ȡID*/ + if ((chBelongCiId == chLocalCiId) && (0u != chLocalCiId)) + { + (void)SetSwitchExpDrvPosition(wDeviceId, SWITCH_DRIVE_POS_INVALID); + (void)SetSwitchDrivePostion(wDeviceId, SWITCH_DRIVE_POS_INVALID); + (void)SetSwitchDanCaoPosition(wDeviceId, SWITCH_DRIVE_POS_INVALID); + } + else + { + ; + } + } + else + { + ; + } + } + + for (ii = 0u; ii < wSignalCurSum; ii++) + { + wDeviceId = GetSignalId(ii); /*ȡźŻID*/ + + if ((0u < wDeviceId) && (SIGNAL_SUM_MAX > wDeviceId)) + { + chBelongCiId = GetSignalBelongCiId(wDeviceId); /*ȡźŻID*/ + if ((chBelongCiId == chLocalCiId) && (0u != chLocalCiId)) + { + SetSignalCurDriveColor(wDeviceId, SIGNAL_DRIVECOLOUR_NULL); + } + else + { + ; + } + } + else + { + ; + } + } + + for (ii = 0u; ii < wPsdCurSum; ii++) + { + wDeviceId = GetPsdId(ii); /*ȡID*/ + + if ((0u < wDeviceId) && (PSD_SUM_MAX > wDeviceId)) + { + /*ȡID*/ + chBelongCiId = GetPsdBelongCiId(wDeviceId); + if ((chBelongCiId == chLocalCiId) && (0u != chLocalCiId)) + { + SetPsdDriveState(wDeviceId, PSD_DRIVE_STATE_INVALID); + SetStartDetectionState(wDeviceId, JXTC_START_DETECTION_NO); + SetStopDetectionState(wDeviceId, JXTC_STOP_DETECTION_NO); + } + else + { + ; + } + } + else + { + ; + } + } + +} + + +/* +* ǰʱռ +* ˵ UINT16 ACID ID +* ֵ AXIS_SECTION_OCCUPY_YES ռ + AXIS_SECTION_OCCUPY_NO + 0x00u Ҫݵ˹ϵ +*/ +static UINT8 ProcessACStatusSpecial(UINT16 ACID) +{ + UINT8 ret = AXIS_SECTION_OCCUPY_YES; + UINT8 funRtn = UINT8_MAX; + UINT8 cycle = 0u; + UINT8 chLogSecCnt = 0u; + UINT8 TrainLockCnt = 0u; + UINT8 LogSecLockCnt = 0u; + UINT8 sameAdjoinStatus = LOGICSECTION_OCCUPY_UT; + UINT8 convertAdjoinStatus = LOGICSECTION_OCCUPY_UT; + UINT16* pLogSecCntBuff = NULL; + const EnvelopeStruct* pELMInfo = NULL; + UINT8 envelopeCnt = CI_ERROR; + UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + + chLogSecCnt = GetAxisSecLogSectionSum(ACID); + pLogSecCntBuff = GetAxisSecLogSectionIdBuf(ACID); + + if ((0u == chLogSecCnt) || (NULL == pLogSecCntBuff)) + { + /** עҪɾifж */ + ret = AXIS_SECTION_OCCUPY_YES; + } + else + { + /** ȡΰİ磬UKT磬Ҫοкſɱ */ + envelopeCnt = elm_GetEnvelopeIDsInAC(ACID,envelopeIDs); + for (cycle = 0u; cycle < envelopeCnt; cycle++) + { + pELMInfo = elm_GetEnvelopeInfoPtr(envelopeIDs[cycle]); + + if ((NULL == pELMInfo) || (TYPE_UKT_ENVELOPE == pELMInfo->envelopeType)) + { + break; + } + else + { + /** */ + } + } + + if (cycle != envelopeCnt) + { + /** ˵ڴUKT磬ռ */ + ret = AXIS_SECTION_OCCUPY_YES; + } + else + { + for (cycle = 0u;cycle < chLogSecCnt; cycle++) + { + /** ȡ߼αյ */ + TrainLockCnt = GetLogSecTrainInfoSum(pLogSecCntBuff[cycle]); + + if (0U < TrainLockCnt) + { + LogSecLockCnt++; + } + } + + if ((0u != LogSecLockCnt) && (LogSecLockCnt != chLogSecCnt)) + { + /** Դͷţаռãռ */ + if (0u == envelopeCnt) + { + /** ѯ߼ռ״̬ */ + sameAdjoinStatus = GetACAdjoinLogSecStatus(EMAP_SAME_DIR,ACID); + convertAdjoinStatus = GetACAdjoinLogSecStatus(EMAP_CONVER_DIR,ACID); + + if ((LOGICSECTION_OCCUPY_UT == sameAdjoinStatus) || (LOGICSECTION_OCCUPY_UT == convertAdjoinStatus)) + { + ret = AXIS_SECTION_OCCUPY_YES; + } + else + { + /* ˳ӳٽҳӳͷԴϣλλΪ޳޷ռãλΪUTӽ޷ռ + ռ޼ռ÷òᶼռãλΪóͨARBλΪ޺óͨUT,ΪλUKT絼¶λ޷ռ */ + ret = 0x00u; + } + } + else + { + ret = AXIS_SECTION_OCCUPY_YES; + } + } + else + { + /** ԴȫδͷŻδ */ + if (0u != envelopeCnt) + { + ret = AXIS_SECTION_OCCUPY_YES; + } + else + { + /** ѯ߼ռ״̬ */ + sameAdjoinStatus = GetACAdjoinLogSecStatus(EMAP_SAME_DIR,ACID); + convertAdjoinStatus = GetACAdjoinLogSecStatus(EMAP_CONVER_DIR,ACID); + + if ((LOGICSECTION_OCCUPY_UT == sameAdjoinStatus) || (LOGICSECTION_OCCUPY_UT == convertAdjoinStatus)) + { + ret = 0x00u; + } + else + { + /** ޻ӽжϲԴǷз䣬δݵ˹ϵռã*/ + funRtn = GetACRelSwLogSecLock(ACID); + + if (UINT8_MAX == funRtn) + { + ret = AXIS_SECTION_OCCUPY_YES; + } + else if (CI_SUCCESS == funRtn) + { + ret = AXIS_SECTION_OCCUPY_NO; + } + else + { + ret = 0x00u; + } + } + } + } + } + } + return ret; +} + + +/* +* ϵռ䵽 +* ˵ void +* ֵ void +*/ +void ProcessPhyOCcStateToAxisSection(void) +{ + UINT16 cycle = 0u; + UINT16 acCnt = 0u; + UINT16* pACBuff = NULL; + UINT8 chSwitch = FUNC_SWITCH_OFF; + UINT8 setFlag = FLAG_UNSET; + UINT8 chFunRtn = CI_ERROR; + UINT16 wPhyId = 0u; + UINT8 chOccState = SECTION_OCCUPY_YES; + AxisSwitchStruct* pSwitchInfo = NULL; + UINT8 chSwitchNum = 0u; + UINT8 chLogSecCnt = 0u; + UINT8 chSpecialHandle = AXIS_SECTION_OCCUPY_YES; + UINT8 chIndex = 0u; + UINT8 chSwitchPos = 0u; + UINT8 chHitTimes = 0u; + UINT16 wACindex = 0U; + + /** ȡϢ*/ + acCnt = GetLocalCiAxisSectionIdBuf(&pACBuff); + + for (cycle = 0u; cycle < acCnt; cycle++) + { + /** ñ */ + setFlag = FLAG_UNSET; + chHitTimes = 0u; + + /** жֱ칦ܿǷ */ + chSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH); + + if (FUNC_SWITCH_ON == chSwitch) + { + chFunRtn = IsAcFree(pACBuff[cycle]); + if (CI_ERROR == chFunRtn) + { + setFlag = FLAG_SET; + } + } + else + { + /** */ + } + + if (FLAG_SET == setFlag) + { + SetAxisOccupyState(pACBuff[cycle], AXIS_SECTION_OCCUPY_YES); + } + else + { + /* ȡϢ */ + wPhyId = GetAxisSecRelativePhySecId(pACBuff[cycle]); + chOccState = GetPhySecCurOccupyState(wPhyId); + + if (SECTION_OCCUPY_NO == chOccState) + { + /* οУֱӷؼο */ + SetAxisOccupyState(pACBuff[cycle], AXIS_SECTION_OCCUPY_NO); + } + else + { + /* ȡĵϢ */ + chSwitchNum = GetAxisSwitchSum(pACBuff[cycle]); + pSwitchInfo = GetAxisSwitchIdStru(pACBuff[cycle]); + + if ((0u == chSwitchNum) || (AXIS_INCLUDE_SWITCH_SUM_MAX < chSwitchNum) || (NULL == pSwitchInfo)) + { + /** ռãϵϷռ */ + /* ռãҸüβռ */ + SetAxisOccupyState(pACBuff[cycle], AXIS_SECTION_OCCUPY_YES); + } + else + { + /** ȡΰ߼Σ߼Ϊ1Ϊʽ */ + chLogSecCnt = GetAxisSecLogSectionSum(pACBuff[cycle]); + chSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + + if ((chLogSecCnt > 1u) && (FUNC_SWITCH_ON == chSwitch)) + { + /** ·ǰ⴦ */ + chSpecialHandle = ProcessACStatusSpecial(pACBuff[cycle]); + } + else + { + chSpecialHandle = 0x00u; + } + + if (0x00U == chSpecialHandle) + { + /** Ҫݵ˹ϵ */ + for (chIndex = 0u; chIndex < chSwitchNum; chIndex++) + { + chSwitchPos = GetSwitchCurPosition(pSwitchInfo[chIndex].SwitchId); + if ((SWITCH_POSITION_DINGWEI != chSwitchPos) && (SWITCH_POSITION_FANWEI != chSwitchPos)) + {/* ռãĿмռ */ + break; + } + else + { + if (chSwitchPos == pSwitchInfo[chIndex].SwitchPosition) + { + chHitTimes++; + } + else + { + ; + } + } + } + if (chIndex < chSwitchNum) + { + SetAxisOccupyState(pACBuff[cycle], AXIS_SECTION_OCCUPY_YES); + } + else + { + if (chHitTimes == chSwitchNum) + { + /* ռãĿеλռ */ + SetAxisOccupyState(pACBuff[cycle], AXIS_SECTION_OCCUPY_YES); + } + else + { + SetAxisOccupyState(pACBuff[cycle], AXIS_SECTION_OCCUPY_NO); + } + } + } + else if (AXIS_SECTION_OCCUPY_NO == chSpecialHandle) + { + SetAxisOccupyState(pACBuff[cycle], AXIS_SECTION_OCCUPY_NO); + } + else + { + SetAxisOccupyState(pACBuff[cycle], AXIS_SECTION_OCCUPY_YES); + } + } + } + } + } + + /* ռǷռü */ + IsOccPhyHasOccAc(); + + /*¼ARB־*/ + for (cycle = 0u; cycle < acCnt; cycle++) + { + wACindex = aam_PrepareACIndex(pACBuff[cycle]); + /*ռ ARB־Ϊ0x55*/ + chOccState = GetAxisOccupyState(pACBuff[cycle]); + if (AXIS_SECTION_OCCUPY_NO == chOccState) + { + aam_SetAxisRedunCanArbFlag(wACindex, REDUN_OVER_ARB_YES); + } + else + { + ; /*ռʱ־ڼϴ*/ + } + } +} + +/** +* @brief жռǷռü +* @param +* @return +*/ +static void IsOccPhyHasOccAc(void) +{ + UINT16 wPhyNum = 0u; + UINT8 chAcNum = 0u; + UINT8 chAcIndex = 0u; + UINT16 * pAcId = NULL; + UINT16 wPhyId = 0u; + UINT16 wPhyIndex = 0u; + UINT8 chPhyOccState = SECTION_OCCUPY_YES; + UINT8 chAcOccState = AXIS_SECTION_OCCUPY_YES; + + /* ȡ */ + wPhyNum = GetTotalPhySecCurNum(); + for (wPhyIndex = 0u; wPhyIndex < wPhyNum; wPhyIndex++) + { + wPhyId = GetPhySecId(wPhyIndex); + chPhyOccState = GetPhySecCurOccupyState(wPhyId); + + if (SECTION_OCCUPY_NO != chPhyOccState) + { + /* ȡΰ */ + chAcNum = GetPAxisSectionSum(wPhyId); + pAcId = GetPAxisSectionIdBuf(wPhyId); + + if ((0u == chAcNum) || (NULL == pAcId)) + { + /* ݲѯʼ */ + } + else + { + /* ռ */ + for (chAcIndex = 0u; chAcIndex < chAcNum; chAcIndex++) + { + chAcOccState = GetAxisOccupyState(pAcId[chAcIndex]); + if (AXIS_SECTION_OCCUPY_YES == chAcOccState) + { + /* ռãѭ */ + break; + } + else + { + ; /* οм */ + } + } + + if (chAcIndex == chAcNum) + { + debug_infor_printf((const)"phy%d of ac lose occ.\n",wPhyId); + for (chAcIndex = 0u; chAcIndex < chAcNum; chAcIndex++) + { + /* ռ޼ռãʧ */ + SetAxisOccupyState(pAcId[chAcIndex],AXIS_SECTION_OCCUPY_YES); + } + } + else + { + ; + } + } + } + else + { + /** 账 */ + } + } +} + +/* +* ȡESBǰҪõ״̬ +* ˵UINT16 esbId ESB ID +* +* ֵ ESB_STATE_VALID_YES״̬ΪЧ +* ESB_STATE_VALID_NO״̬ΪЧ +* CI_ERROR: ȡʧ +* cgh-ϲCID-2349-3 +*/ +UINT8 GetEsbCurNeedSetState(UINT16 esbId) +{ + UINT16 esbRelayId = 0u; /*esb̵ID*/ + UINT16 ESSRelayId = 0u; /*ͣؼ̵ID*/ + UINT16 esbRelayState = 0u; /*esb̵ɼ״̬*/ + UINT16 ESSRelayState = 0u; /*ͣؼ̵ɼ״̬*/ + UINT8 resultVal = CI_ERROR;/*ֵ*/ + UINT8 curEsbDriveState = 0u; /*ǰesbؼ̵״̬*/ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + if (bufIndex < ESB_SUM_MAX) + { + esbRelayId = GetEsbRelayId(esbId); + esbRelayState = GetRelayCollState(esbRelayId); + ESSRelayId = GetESSRelayId(esbId); + /*ͣؼ̵ʱesb״̬esbɼ̵ͣزɼ̵״̬ͬ*/ + if ((0u < ESSRelayId) && (ESSRelayId < UINT16_MAX)) + { + ESSRelayState = GetRelayCollState(ESSRelayId); + if ((RELAY_STATE_DOWN == esbRelayState) || (RELAY_STATE_DOWN == ESSRelayState)) + { + resultVal = ESB_STATE_VALID_YES; /*esbɼ̵ͣزɼ̵һesbЧ*/ + } + else if ((RELAY_STATE_UP == esbRelayState) && (RELAY_STATE_UP == ESSRelayState)) + { + curEsbDriveState = GetEsbRelateRelayDriveProState(esbId); /*ȡesbؼ̵ǰ״̬*/ + if ((ESB_PEPDOWN_ESSUP_TWO_STATE == curEsbDriveState) || (ESB_FAULT_SIX_STATE == curEsbDriveState)) + {/*״̬2ֱӻָPEPesbȻЧ,һֱ״̬6ǻɵESSPEPΪesbЧ*/ + resultVal = ESB_STATE_VALID_YES; + } + else + { + resultVal = ESB_STATE_VALID_NO; /*esbɼ̵ͽͣزɼ̵ҵǰ״̬״̬2esbЧ*/ + } + } + else + { + resultVal = CI_ERROR; /*ڵֵʧܲesb״̬*/ + } + } + else + { + /*ͣؼ̵ʱesb״ֻ̬esbɼ̵״̬*/ + if (RELAY_STATE_DOWN == esbRelayState) + { + resultVal = ESB_STATE_VALID_YES; /*esbɼ̵ʱЧ*/ + } + else if (RELAY_STATE_UP == esbRelayState) + { + resultVal = ESB_STATE_VALID_NO; /*esbɼ̵ʱЧ*/ + } + else + { + resultVal = CI_ERROR; /*ڵֵʧܲesb״̬*/ + } + } + } + else + { + resultVal = CI_ERROR; /*esb IDϷʧܲesb״̬*/ + } + + return resultVal; +} + +/* +* OC ESSPEPµơȵƺͷ̵ +* ˵ void +* ֵ void +* cgh-ϲCID-2349-3cgh-ϲCID-3037-1 +*/ +void EsbRelateDelayDriveOutputProc(void) +{ + /*ʼ*/ + UINT16 esbCurSum = 0u; + UINT8 localCiId = 0u; /*ID*/ + UINT16 esbId = 0u; /*esb ID*/ + UINT8 devBlongCiId = 0u; /*豸ID*/ + UINT16 esbBuzzRelayId = 0u; /*esb̵ID*/ + UINT16 esbCutoffBuzzRelayId = 0U; /*esbг̵ID*/ + UINT8 esbCutState = 0u; + UINT8 esbState = 0u; + UINT8 esbBuzzDriveState = 0u; /*esb̵״̬*/ + UINT8 esbCutoffBuzzDriveState = 0u; /*esbг̵״̬*/ + UINT16 i = 0u; /*ѭ*/ + UINT16 ESSRelayId = 0u; /*ESS ID*/ + + UINT8 funcswitchZfsBtn = 0U; /*Ըʽť*/ + + esbCurSum = GetEsbSum(); /*ȡesb*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + funcswitchZfsBtn = GetCiFunctionSwitchConfig(FUNC_ZIFUSHI_BUTTON); + + if (0U < esbCurSum) + { + /*ȡESB״̬Ϣ*/ + for (i = 0u; i < esbCurSum; i++) + { + esbId = GetEsbId(i); + devBlongCiId = GetEsbBelongCiId(esbId); /*ȡ豸ID*/ + /*ESBDZ*/ + if (localCiId == devBlongCiId) + { + if (FUNC_SWITCH_ON == funcswitchZfsBtn) /*ԸʽESB̵*/ + { + /*ԸʽESB̵״̬*/ + esbBuzzRelayId = GetEsbBuzzRelayId(esbId); + if ((0u < esbBuzzRelayId) && (UINT16_MAX > esbBuzzRelayId)) + { + esbState = GetEsbState(esbId); + if (ESB_STATE_VALID_YES == esbState) + { + /**/ + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + esbBuzzDriveState = GetRelayDriveState(esbBuzzRelayId); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + /*δ*/ + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + } + + /*ԸʽESBг̵״̬*/ + esbCutoffBuzzRelayId = GetEsbCutoffBuzzRelayId(esbId); + if ((0U < esbCutoffBuzzRelayId) && (UINT16_MAX > esbCutoffBuzzRelayId)) + { + esbState = GetEsbState(esbId); + if (ESB_STATE_VALID_YES == esbState) + { + /*г*/ + (void)SetRelayDriveState(esbCutoffBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + else + { + esbCutoffBuzzDriveState = GetRelayDriveState(esbCutoffBuzzRelayId); + if (RELAY_DRIVE_STATE_NULL == esbCutoffBuzzDriveState) + { + /*δг*/ + (void)SetRelayDriveState(esbCutoffBuzzRelayId, RELAY_DRIVE_STATE_UP); + } + } + } + } + else /*ԸʽESB̵*/ + { + /*ȡ·ť״̬ESB״̬*/ + esbCutState = GetEsbCutState(esbId); + esbState = GetEsbState(esbId); + esbBuzzRelayId = GetEsbBuzzRelayId(esbId); /*esb IDȡesbID*/ + ESSRelayId = GetESSRelayId(esbId); /*esb IDȡESS̵ID*/ + /*ESS̵ʱ״̬תؼ̵״̬*/ + if ((0U < ESSRelayId) && (ESSRelayId < UINT16_MAX)) + { + EsbRelateDelayDriveStateManage(esbId); + } + else + { + /*ESS̵ʱesb״̬״̬*/ + if (0u < esbBuzzRelayId) + { + /*״̬*/ + esbBuzzDriveState = GetRelayDriveState(esbBuzzRelayId); + /*δ·ҽ*/ + if ((ESB_CUT_NO == esbCutState) && (ESB_STATE_VALID_YES == esbState)) + { + /**/ + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /*û*/ + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + /**/ + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + } + + /*÷ԸʽESBг̵״̬̫ԭ1Ŀ*/ + esbCutoffBuzzRelayId = GetEsbCutoffBuzzRelayId(esbId); + if ((0U < esbCutoffBuzzRelayId) && (UINT16_MAX > esbCutoffBuzzRelayId)) + { + /*δ·*/ + if ((ESB_CUT_NO == esbCutState) && (ESB_STATE_VALID_YES == esbState)) + { + /*г*/ + (void)SetRelayDriveState(esbCutoffBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + else + { + esbCutoffBuzzDriveState = GetRelayDriveState(esbCutoffBuzzRelayId); + if (RELAY_DRIVE_STATE_NULL == esbCutoffBuzzDriveState) + { + /*δг*/ + (void)SetRelayDriveState(esbCutoffBuzzRelayId, RELAY_DRIVE_STATE_UP); + } + } + } + else + { + /*δ÷г̵*/ + } + } + } + } + } + } +} + + +/* +* OC ESSPEPµơȵƺͷ̵״̬ +* ˵ UINT16 esbId ESB ID +* ֵ void +* cgh-ϲCID-2349-3 +*/ +void EsbRelateDelayDriveStateManage(UINT16 esbId) +{ + /*ʼ*/ + UINT16 esbRelayId = 0u; /*esbɼ̵ ID*/ + UINT8 esbCutState = 0u; /*esb·״̬*/ + UINT8 esbRelayState = 0u; /*esbɼ̵״̬*/ + UINT16 ESSRelayId = 0u; /*ESS ID*/ + UINT8 ESSRelayState = 0u; /*ESS ̵״̬*/ + UINT8 esbRelateDelayDriveState = 0u; /*esbؼ̵״̬*/ + UINT16 esbSteadyIndicatRelayId = 0u; /*esbȵƼ̵ID*/ + UINT16 esbFlashIndicatRelayId = 0u; /*esbƼ̵ID*/ + UINT16 esbBuzzRelayId = 0u; /*esb̵ID*/ + UINT16 bufIndex = 0u; /*±*/ + UINT8 esbBuzzDriveState = 0u; /*esbǷ*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + esbRelayId = GetEsbRelayId(esbId); /*ȡesbɼ̵ID*/ + esbRelayState = GetRelayCollState(esbRelayId); /*ȡesb̵ɼ״̬*/ + esbCutState = GetEsbCutState(esbId); /*ȡesb·״̬*/ + ESSRelayId = GetESSRelayId(esbId); /*ȡESS̵ID*/ + ESSRelayState = GetRelayCollState(ESSRelayId); /*ȡESS̵ɼ״̬*/ + esbSteadyIndicatRelayId = GetESSSteadyIndicatRelayId(esbId); /*ȡESSȵƼ̵ID*/ + esbFlashIndicatRelayId = GetESSFlashIndicatRelayId(esbId); /*ȡESSƼ̵ID*/ + esbBuzzRelayId = GetEsbBuzzRelayId(esbId); /*ȡesbID*/ + esbRelateDelayDriveState = GetEsbRelateRelayDriveProState(esbId); /*ȡesbؼ̵״̬*/ + esbBuzzDriveState = GetRelayDriveState(esbBuzzRelayId); + + switch (esbRelateDelayDriveState) + { + case ESB_PEPUP_ESSUP_INITION_STA: + /*ʼ״̬ȵơƺͷ*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + /*һվһESBֻеվ̨û²ſ*/ + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + if ((RELAY_STATE_DOWN == esbRelayState) && (RELAY_STATE_UP == ESSRelayState)) + { + /*PEPº״̬ת״̬2*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSUP_TWO_STATE); + } + else if ((RELAY_STATE_UP == esbRelayState) && (RELAY_STATE_DOWN == ESSRelayState)) + { + /*ESSº״̬ת״̬5*/ + SetEsbRelateRelayDriveProState(esbId, ESB_TWOPEPUP_ESSDOWN_FIVE_STATE); + } + else if ((RELAY_STATE_DOWN == esbRelayState) && (RELAY_STATE_DOWN == ESSRelayState)) + { + /*δOCͨʱOCͨжϺת״̬3*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSDOWN_THREE_STATE); + } + else + { + /*ڳʼ״̬°PEPESSͣλ״̬ת*/ + } + break; + case ESB_PEPDOWN_ESSUP_TWO_STATE: + if (ESB_CUT_NO == esbCutState) + { + /*״̬2ʱָʾ*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /*·֮κα̵*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + if ((RELAY_STATE_DOWN == esbRelayState) && (RELAY_STATE_DOWN == ESSRelayState)) + { + /*ʱʹESSͣλ״̬ת״̬3*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSDOWN_THREE_STATE); + } + else if ((RELAY_STATE_UP == esbRelayState) && (RELAY_STATE_UP == ESSRelayState)) + { + /*ʱֱӸλPEPǷת״̬6*/ + SetEsbRelateRelayDriveProState(esbId, ESB_FAULT_SIX_STATE); + } + else + { + /*״̬2ʱֻת*/ + } + break; + case ESB_PEPDOWN_ESSDOWN_THREE_STATE: + if (ESB_CUT_NO == esbCutState) + { + /*״̬3ʱָʾȵ*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + /*һվһESBֻеվ̨û²ſ*/ + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + else + { + /*·֮κα̵*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + if ((RELAY_STATE_DOWN == esbRelayState) && (RELAY_STATE_UP == ESSRelayState)) + { + /*ʱʹESSȥλص״̬2*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSUP_TWO_STATE); + } + else if ((RELAY_STATE_UP == esbRelayState) && (RELAY_STATE_DOWN == ESSRelayState)) + { + /*ʱʹPEPָص״̬4*/ + SetEsbRelateRelayDriveProState(esbId, ESB_ONEPEPUP_ESSDOWN_FOUR_STATE); + } + else if ((RELAY_STATE_UP == esbRelayState) && (RELAY_STATE_UP == ESSRelayState)) + { + /*ESSPEPͬʱתʼ״̬*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPUP_ESSUP_INITION_STA); + } + else + { + /*״̬3ʱֻת*/ + } + break; + case ESB_ONEPEPUP_ESSDOWN_FOUR_STATE: + if (ESB_CUT_NO == esbCutState) + { + /*PEPȰ֮ESSͣλٻָPEPʱָʾ˸Ϊ״̬4*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /*·֮κα̵*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + if ((RELAY_STATE_UP == esbRelayState) && (RELAY_STATE_UP == ESSRelayState)) + { + /*ʱʹESSȥλָʼ״̬*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPUP_ESSUP_INITION_STA); + } + else if ((RELAY_STATE_DOWN == esbRelayState) && (RELAY_STATE_DOWN == ESSRelayState)) + { + /*ʱʹPEP£ת״̬3*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSDOWN_THREE_STATE); + } + else + { + /*״̬4ʱֻת*/ + } + break; + case ESB_TWOPEPUP_ESSDOWN_FIVE_STATE: + if (ESB_CUT_NO == esbCutState) + { + /*ʹESSͣλPEPʱָʾȵΪ״̬5ʱ״̬4PEPESS̵״̬һµDZһ + ֱʹESSȥλָʼ״̬*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + /*һվһESBֻеվ̨û²ſ*/ + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + else + { + /*·֮κα̵*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + if ((RELAY_STATE_UP == esbRelayState) && (RELAY_STATE_UP == ESSRelayState)) + { + /*ֱӲESSλȥλָʼ״̬*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPUP_ESSUP_INITION_STA); + } + else if ((RELAY_STATE_DOWN == esbRelayState) && (RELAY_STATE_DOWN == ESSRelayState)) + { + /*ٲPEPʹ֮£ת״̬3*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSDOWN_THREE_STATE); + } + else + { + /*״̬5ʱֻת*/ + } + break; + case ESB_FAULT_SIX_STATE: + if (ESB_CUT_NO == esbCutState) + { + /*ֻڰPEPֱӻָPEPŻת״̬ʱȻESSPEPģESBЧ + Ҫָʾ*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /*·֮κα̵*/ + (void)SetRelayDriveState(esbSteadyIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(esbFlashIndicatRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_DRIVE_STATE_NULL == esbBuzzDriveState) + { + (void)SetRelayDriveState(esbBuzzRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + if ((RELAY_STATE_DOWN == esbRelayState) && (RELAY_STATE_UP == ESSRelayState)) + { + /*ٰPEPص״̬2̽вת״̬2*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSUP_TWO_STATE); + } + else if ((RELAY_STATE_UP == esbRelayState) && (RELAY_STATE_DOWN == ESSRelayState)) + { + /*ٰESSΪESSµģմ˲̽вת״̬4*/ + SetEsbRelateRelayDriveProState(esbId, ESB_ONEPEPUP_ESSDOWN_FOUR_STATE); + } + else + { + /*״̬6ʱֻת*/ + } + break; + default: + /*ڵ״̬*/ + break; + } + } +} + +/* +* Ƿʱ +* ˵ const UINT16 relayId ̵ID +* +* ֵ 1ʱ״̬ +* 0ʱ +* cgh-ϲCID-2349-4 +*/ +UINT8 CheckRelayDriveOutTimeState(const UINT16 relayId) +{ + /*ʼ*/ + UINT8 relayColleState = 0u; + UINT8 relayDriveState = 0u; + UINT8 retValue = CI_ERROR; + UINT32 curCycNum = 0u; + UINT8 checkRelayRes = 0u; + UINT32 relayCycNum = 0u; + + curCycNum = Get2oo2CurCycleNum(); + + + retValue = CI_SUCCESS; + /*ȡ̵״̬*/ + relayColleState = GetRelayCollState(relayId); /*ɼ״̬*/ + relayDriveState = GetRelayDriveState(relayId); /*״̬*/ + + /**/ + if (RELAY_DRIVE_STATE_UP == relayDriveState) + { + /*ɼ*/ + if (RELAY_STATE_DOWN == relayColleState) + { + relayCycNum = GetRelayDriveStartCycNum(relayId); + checkRelayRes = SystemOverTimeCheck(relayCycNum, RELAY_DRIVE_MAX_NUM); + /*δʱ*/ + if (CI_TIME_NO == checkRelayRes) + { + SetRelayDriveStartCycNum(relayId, curCycNum);/*ü̵Ч*/ + } + /*ʱ*/ + else if (CI_TIME_OUT == checkRelayRes) + { + retValue = CI_ERROR; + } + else + { + /*ʱУسɹ*/ + } + } + else + { + SetRelayDriveStartCycNum(relayId, 0u);/*ü̵Ч*/ + } + } + else if ((RELAY_DRIVE_STATE_DOWN == relayDriveState) || (RELAY_DRIVE_STATE_NULL == relayDriveState)) + { + /*ɼ*/ + if (RELAY_STATE_UP == relayColleState) + { + relayCycNum = GetRelayDriveStartCycNum(relayId); + checkRelayRes = SystemOverTimeCheck(relayCycNum, RELAY_DRIVE_MAX_NUM); + /*δʱ*/ + if (CI_TIME_NO == checkRelayRes) + { + SetRelayDriveStartCycNum(relayId, curCycNum);/*ü̵Ч*/ + } + /*ʱ*/ + else if (CI_TIME_OUT == checkRelayRes) + { + retValue = CI_ERROR; + } + else + { + /*ʱУسɹ*/ + } + } + else + { + SetRelayDriveStartCycNum(relayId, 0u);/*ü̵Ч*/ + } + } + else + { + SetRelayDriveStartCycNum(relayId, 0u);/*ü̵Ч*/ + } + + return retValue; +} + + +/* +* Ƿʱ +* ˵ const UINT16 psdId ID +* const UINT8 psdDriveState psd״̬ +* ֵ 0xffʱ״̬ +* 0x55 δ +* 0xaa δ +* cgh-ϲCID-2349-4 +*/ +UINT8 CheckPsdDriveOutTimeState(const UINT16 psdId) +{ + /*ʼ*/ + UINT8 retValue = UINT8_MAX; + UINT32 curCycNum = 0u; + UINT8 psdState = 0u; + UINT32 driveStartCycNum = 0u; + UINT8 OverTimeCheck = 0u; + UINT8 psdDriveState = 0u; + UINT32 psdDrivOpenMaxCount = 0u; + UINT32 psdDrivCloseMaxCount = 0u; + + curCycNum = Get2oo2CurCycleNum(); + if (0u < psdId) + { + psdState = GetPsdState(psdId); + psdDriveState = GetPsdDriveState(psdId); + /*ݵǰ״̬ʼʱ*/ + if (PSD_DRIVE_STATE_OPEN == psdDriveState) + {/**/ + SetPsdDriveCloseStartCycNum(psdId, 0u);/*0ʼ*/ + if (PSD_STATE_OPEN != psdState) + { + driveStartCycNum = GetPsdDriveOpenStartCycNum(psdId); + psdDrivOpenMaxCount = GetPsdDrivOpenMaxCount(); + OverTimeCheck = SystemOverTimeCheck(driveStartCycNum, psdDrivOpenMaxCount); + + /*δʱ*/ + if (CI_TIME_NO == OverTimeCheck) + { + SetPsdDriveOpenStartCycNum(psdId, curCycNum);/*ü̵Ч*/ + } + } + else + { + SetPsdDriveOpenStartCycNum(psdId, 0u);/*0ʼ*/ + } + } + else if (PSD_DRIVE_STATE_CLOSE == psdDriveState) + {/**/ + SetPsdDriveOpenStartCycNum(psdId, 0u);/*0ʼ*/ + if (PSD_STATE_CLOSE != psdState) + { + driveStartCycNum = GetPsdDriveCloseStartCycNum(psdId); + psdDrivCloseMaxCount = GetPsdDrivCloseMaxCount(); + OverTimeCheck = SystemOverTimeCheck(driveStartCycNum, psdDrivCloseMaxCount); + + /*δʱ*/ + if (CI_TIME_NO == OverTimeCheck) + { + SetPsdDriveCloseStartCycNum(psdId, curCycNum);/*0ʼ*/ + } + } + else + { + SetPsdDriveCloseStartCycNum(psdId, 0u);/*0ʼ*/ + } + } + else + {/*״̬*/ + SetPsdDriveOpenStartCycNum(psdId, 0u);/*0ſʼ*/ + SetPsdDriveCloseStartCycNum(psdId, 0u);/*0ſʼ*/ + } + /*Ƿʱ*/ + driveStartCycNum = GetPsdDriveOpenStartCycNum(psdId); + if (0u < driveStartCycNum) + {/**/ + psdDrivOpenMaxCount = GetPsdDrivOpenMaxCount(); + OverTimeCheck = SystemOverTimeCheck(driveStartCycNum, psdDrivOpenMaxCount); + + if (CI_TIME_OUT == OverTimeCheck) + { + retValue = PSD_OPEN_OUT_TIME;/*ؿųʱ*/ + SetPsdDriveOpenStartCycNum(psdId, 0u);/*0ʼڣһ*/ + } + else + { + /*ʱУسɹ*/ + } + } + else + { + driveStartCycNum = GetPsdDriveCloseStartCycNum(psdId); + if (0u < driveStartCycNum) + { + /**/ + psdDrivCloseMaxCount = GetPsdDrivCloseMaxCount(); + OverTimeCheck = SystemOverTimeCheck(driveStartCycNum, psdDrivCloseMaxCount); + + /*ʱ*/ + if (CI_TIME_OUT == OverTimeCheck) + { + retValue = PSD_CLOSE_OUT_TIME;/*عرճʱ*/ + SetPsdDriveCloseStartCycNum(psdId, 0u);/*0ʼڣһ*/ + } + else + { + /*ʱУسɹ*/ + } + + } + } + } + return(retValue); +} + +/* +* ȡ̵Ƿɼһ +* ˵ const UINT16 relayId, ̵ID + const UINT8 foreNodeColl ǰ״̬ + const UINT8 backNodeColl ״̬ +* ֵ 0: ɼһ +* >0: һ +*cgh-ϲCID-2349-4 +*/ +UINT8 CheckRelayDriAndCollDiffSeat(const UINT16 relayId, const UINT8 foreNodeColl, const UINT8 backNodeColl) +{ + + UINT8 colMode = 0; /*ɼ*/ + UINT8 returnValue = CI_ERROR;/*ֵ*/ + UINT8 relayDriveState = 0u; + + returnValue = CheckRelayDriveOutTimeState(relayId); + + if (CI_ERROR == returnValue)/*ʱ*/ + { + returnValue = CI_SUCCESS; + relayDriveState = GetRelayDriveState(relayId); + colMode = GetRelayCollectMode(relayId); + if (RELAY_DRIVE_STATE_UP == relayDriveState) + {/**/ + switch (colMode) + { + case RELAY_COLL_MODE_FORE: + /*ǰڵɼ*/ + if (RELAY_STATE_UP == foreNodeColl) + { + } + else + { + returnValue = CI_ERROR; + } + break; + + case RELAY_COLL_MODE_BACK: + /*ڵɼ*/ + if (RELAY_STATE_DOWN == backNodeColl)/*´̵ʱ*/ + { + } + else + { + returnValue = CI_ERROR; + } + break; + case RELAY_COLL_MODE_DOUBLE: + /*˫ڵɼ*/ + if ((RELAY_STATE_UP == foreNodeColl) && (RELAY_STATE_DOWN == backNodeColl)) + {/*ǰɼ,*/ + } + else + { + returnValue = CI_ERROR; + } + break; + default: + /*ɴ֧*/ + break; + } + } + else if ((RELAY_DRIVE_STATE_DOWN == relayDriveState) || (RELAY_DRIVE_STATE_NULL == relayDriveState)) + {/**/ + switch (colMode) + { + case RELAY_COLL_MODE_FORE: + /*ǰڵɼ*/ + if (RELAY_STATE_DOWN == foreNodeColl) + { + } + else + { + returnValue = CI_ERROR; + } + break; + + case RELAY_COLL_MODE_BACK: + /*ڵɼ*/ + if (RELAY_STATE_UP == backNodeColl)/*̵ʱ*/ + { + } + else + { + returnValue = CI_ERROR; + } + break; + case RELAY_COLL_MODE_DOUBLE: + /*˫ڵɼ*/ + if ((RELAY_STATE_DOWN == foreNodeColl) && (RELAY_STATE_UP == backNodeColl)) + {/*ǰɼ,𣬼̵*/ + } + else + { + returnValue = CI_ERROR; + } + break; + default: + /*ɴ֧*/ + break; + + } + } + else + {/**/ + + } + } + return returnValue; +} + +/* +* ȡPSDǷɼһ +* ˵ const UINT16 psdId, PSD ID +* ֵ 0xff: ޱ +* 0x55: ɼһ +* 0xaa: ɼһ +*cgh-ϲCID-2349-4 +*/ +UINT8 CheckPsdDriAndCollDiff(const UINT16 psdId) +{ + UINT8 returnValue = UINT8_MAX;/*ֵ*/ + UINT8 psdDriveState = 0u; + UINT16 kmj8Id = 0u;/*8KMJ*/ + UINT16 kmj6Id = 0u;/*6KMJ*/ + UINT16 kmj4Id = 0u;/*4KMJ*/ + UINT16 gmjId = 0u;/*GMJ*/ + UINT8 checkVal = 0u; + + psdDriveState = GetPsdDriveState(psdId); + kmj4Id = GetFourGroupPsdOpenDrvRelayId(psdId); + kmj6Id = GetSixGroupPsdOpenDrvRelayId(psdId); + kmj8Id = GetEightGroupPsdOpenDrvRelayId(psdId); + gmjId = GetPsdCloseDriveRelayId(psdId); + + if (PSD_DRIVE_STATE_OPEN == psdDriveState) + { + checkVal = 1u; + checkVal *= CheckRelayDriveOutTimeState(kmj4Id); + checkVal *= CheckRelayDriveOutTimeState(kmj6Id); + checkVal *= CheckRelayDriveOutTimeState(kmj8Id); + checkVal *= CheckRelayDriveOutTimeState(gmjId); + + if (0u == checkVal) + { + returnValue = PSD_OPEN_DRVANDCOLL_DIFF;/*ɼһ*/ + } + + } + else if (PSD_DRIVE_STATE_CLOSE == psdDriveState) + { + checkVal = 1u; + checkVal *= CheckRelayDriveOutTimeState(kmj4Id); + checkVal *= CheckRelayDriveOutTimeState(kmj6Id); + checkVal *= CheckRelayDriveOutTimeState(kmj8Id); + checkVal *= CheckRelayDriveOutTimeState(gmjId); + + if (0u == checkVal) + { + returnValue = PSD_CLOSE_DRVANDCOLL_DIFF;/*ɼһ*/ + } + } + else + { + /*Ĭֵ*/ + } + return returnValue; +} + +/* +* Spksťָʾƴ +* ˵ UINT16 spksId ID +* +* ֵ void +*/ +void TotalSpksOutsideDisPlayProc(UINT16 spksId) +{ + UINT8 reVal = CI_ERROR; + UINT8 spksIncludeSpksNum = 0u; + UINT16* pSpksIncludeSpksIdBuf = NULL; + UINT16 ii = 0u; + UINT16 contrlspksId = 0u;/*SPKS id*/ + UINT32 spksflockStartNum = 0u; + UINT8 spksSate = 0u; + UINT8 spksCutState = 0u; + UINT32 spksIndicDelayCount = 0u; + UINT16 outsideRelayId = 0u; + UINT8 checkCycOut = 0u; + UINT8 totalSpksDriveFlag = TOTALSPKSDRIVE_INVALID; + if (0u < spksId) + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + spksIncludeSpksNum = GetSpksIncludeSpksNum(spksId); + pSpksIncludeSpksIdBuf = GetSpksIncludeSpksIdBuf(spksId); + + if ((0u < spksIncludeSpksNum) && (NULL != pSpksIncludeSpksIdBuf)) + { + } + else + { + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + { + for (ii = 0; ii < spksIncludeSpksNum; ii++)/*spksϽspks*/ + { + contrlspksId = pSpksIncludeSpksIdBuf[ii];/*ܿspks id*/ + totalSpksDriveFlag = GetDriveOutDisFlag(contrlspksId); + if (0u < contrlspksId) + { + /*SPKSť,δ·*/ + spksSate = GetSpksState(spksId); + spksCutState = GetSpksCutState(spksId); + spksflockStartNum = GetSpksflockStartNum(spksId);/*ȡSPKSʼ*/ + if ((SPKS_STATUS_YES == spksSate) && (SPKS_CUT_NO == spksCutState)) + { + /*spks£Ͻspks ָʾƵ*/ + outsideRelayId = GetSpksOutsideRelayId(contrlspksId);/*ָʾ*/ + if ((0u < outsideRelayId) && (UINT16_MAX != outsideRelayId)) + { + spksIndicDelayCount = GetSpksIndicDelayCount();/*ȡʱ*/ + checkCycOut = SystemOverTimeCheck(spksflockStartNum, spksIndicDelayCount); + if (CI_TIME_OUT == checkCycOut) + { + (void)SetRelayDriveState(outsideRelayId, RELAY_STATE_UP); /*ָʾ*/ + SetDriveOutDisFlag(contrlspksId, TOTALSPKSDRIVE_YES);/*SPKSЧSPKSSPKSƱ־*/ + } + else + { + /*ָʾƱ֮ǰ״̬1spks£򱣳ָspksָʾ״̬*/ + } + } + } + else + { + if (TOTALSPKSDRIVE_YES != totalSpksDriveFlag) + { + SetDriveOutDisFlag(contrlspksId, TOTALSPKSDRIVE_NO);/*־ûбyesΪNO*/ + } + } + } + } + } +} + +/* +* SPKSָʾ +* ˵ UINT16 contrlspksId SPKS ID +* UINT32 spksflockStartNum spksʼ +* ֵ void +*/ + +void SpksOutsideDisPlayDriv(UINT16 contrlspksId, UINT32 spksflockStartNum) +{ + UINT8 reVal = CI_ERROR; + UINT8 spksSate = 0u; + UINT16 outsideRelayId = 0u; + UINT32 spksIndicDelayCount = 0u; + UINT8 checkCycOut = 0u; + UINT8 spksCutState = 0u; + UINT8 totalSpksDriveFlag = 0u; + + if (0u < contrlspksId) + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + outsideRelayId = GetSpksOutsideRelayId(contrlspksId);/*ָʾ*/ + if ((0u < outsideRelayId) && (UINT16_MAX != outsideRelayId)) + { + /*ָʾƴڣ*/ + } + else + { + reVal = CI_ERROR; + } + + } + + if (CI_SUCCESS == reVal) + { + spksSate = GetSpksState(contrlspksId);/*spks״̬*/ + spksCutState = GetSpksCutState(contrlspksId);/*·״̬*/ + totalSpksDriveFlag = GetDriveOutDisFlag(contrlspksId); + if ((SPKS_STATUS_YES == spksSate) && (SPKS_CUT_NO == spksCutState) && (TOTALSPKSDRIVE_YES != totalSpksDriveFlag)) + {/*spksָʾƽspksδ·SPKSδ״̬µ*/ + spksIndicDelayCount = GetSpksIndicDelayCount();/*ȡʱ*/ + checkCycOut = SystemOverTimeCheck(spksflockStartNum, spksIndicDelayCount); + if (CI_TIME_OUT == checkCycOut) + { + (void)SetRelayDriveState(outsideRelayId, RELAY_STATE_UP); /*ָʾ*/ + } + else + { + (void)SetRelayDriveState(outsideRelayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + } + else + { + if (TOTALSPKSDRIVE_YES != totalSpksDriveFlag) + { + (void)SetRelayDriveState(outsideRelayId, RELAY_STATE_DOWN); /*ָʾ*/ + } + else + { + /*SPKSSPKSָʾ*/ + } + } + + } +} + +/* +* жӲ۳Ƿִ +* ˵ const UINT16 detainCutRelayId ·̵ + const UINT16 signalDetainRelayId ۳̵ + +* ֵ CI_ERROR: ִ +* CI_SUCCESS: ִ +* +*/ +UINT8 CheakDeatainState(UINT16 detainCutRelayId, UINT16 signalDetainRelayId) +{ + UINT8 relayDetainValidFlag = 0u; + UINT8 tmpRelayColState = 0u; + UINT16 detainCutState = 0u; /*۳·״̬*/ + UINT8 detainCutBelongCi = 0u; + UINT8 localCiId = 0u; + UINT8 ret = CI_SUCCESS; /*ؽ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + relayDetainValidFlag = GetCiFunctionSwitchConfig(FUNC_RELAY_DETAIN_VALID_FLAG);/*ȡӲ߿۳Ч־*/ + tmpRelayColState = GetRelayCollState(signalDetainRelayId);/*ȡ۳̵ɼ״̬*/ + + if (((UP_VALID == relayDetainValidFlag) && (RELAY_DRIVE_STATE_UP == tmpRelayColState)) + || ((DOWN_VALID == relayDetainValidFlag) && (RELAY_DRIVE_STATE_DOWN == tmpRelayColState))) /*̵,۳*/ + { + if ((0u != detainCutRelayId) && (UINT16_MAX != detainCutRelayId)) /*·̵*/ + { + detainCutState = GetRelayCollState(detainCutRelayId);/*ȡ۳·̵ɼ״̬*/ + detainCutBelongCi = GetRelayBelongCiId(detainCutRelayId); + /*۳·̵ڱ*/ + if (detainCutBelongCi == localCiId) + { + + if (RELAY_DRIVE_STATE_DOWN == detainCutState) /*·Ч,۳*/ + { + ret = CI_SUCCESS; + } + else if (RELAY_DRIVE_STATE_UP == detainCutState) /*·Ч,δ۳*/ + { + ret = CI_ERROR; + } + else /*·Ч,۳*/ + { + ret = CI_SUCCESS; + } + } + } + else /*·̵,۳*/ + { + ret = CI_SUCCESS; + } + + } + else if (((UP_VALID == relayDetainValidFlag) && (RELAY_DRIVE_STATE_DOWN == tmpRelayColState)) + || ((DOWN_VALID == relayDetainValidFlag) && (RELAY_DRIVE_STATE_UP == tmpRelayColState))) /*̵,δ۳*/ + { + ret = CI_ERROR; + } + else /*̵״̬Ч۳*/ + { + ret = CI_SUCCESS; + } + + return ret; +} + +/* +* ȡ߱ESBǰҪõ״̬ +* ˵UINT16 esbId ESB ID +* +* ֵ ESB_STATE_VALID_YES״̬ΪЧ +* ESB_STATE_VALID_NO״̬ΪЧ +* CI_ERROR: ȡʧ +* cgh-ϲCID-3037-1 +*/ +UINT8 GetVirEsbCurNeedSetState(UINT16 esbId) +{ + UINT8 esbRelayState = 0U; /*esb̵ɼ״̬*/ + UINT8 essRelayState = 0U; /*ͣؼ̵ɼ״̬*/ + UINT8 resultVal = CI_ERROR;/*ֵ*/ + UINT8 curEsbDriveState = 0U; /*ǰesbؼ̵״̬*/ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + if (bufIndex < ESB_SUM_MAX) + { + esbRelayState = GetEsbAutualState(esbId);/*ȡESBť״̬*/ + essRelayState = GetEssState(esbId);/*ȡESSť״̬*/ + + /*ͣťʱesb״̬esbťʵ״̬ESS״̬ͬ*/ + if ((ESB_STATE_VALID_YES == esbRelayState) || (ESB_STATE_STOP_FLAG == essRelayState)) + { + resultVal = ESB_STATE_VALID_YES; /*esbɼ̵ͣزɼ̵һesbЧ*/ + } + else if ((ESB_STATE_VALID_NO == esbRelayState) && (ESB_STATE_GO_FLAG == essRelayState)) + { + curEsbDriveState = GetEsbRelateRelayDriveProState(esbId); /*ȡesbؼ̵ǰ״̬*/ + if (ESB_FAULT_SIX_STATE == curEsbDriveState) + {/*һֱ״̬6ǻɵESSPEPΪesbЧ*/ + resultVal = ESB_STATE_VALID_YES; + } + else + { + resultVal = ESB_STATE_VALID_NO; + } + } + else + { + resultVal = CI_ERROR; /*ڵֵʧܲesb״̬*/ + } + + } + else + { + resultVal = CI_ERROR; /*esb IDϷʧܲesb״̬*/ + } + + return resultVal; +} +/* +* ESB߼ +* ˵ +* ֵ void +* cgh-ϲCID-3037-1 +*/ +void VirtualEsbLogicProcess(void) +{ + /*ʼ*/ + UINT16 esbCurSum = 0U; + UINT8 localCiId = 0U; /*ID*/ + UINT16 esbId = 0U; /*esb ID*/ + UINT8 devBlongCiId = 0U; /*豸ID*/ + UINT16 i = 0U; /*ѭ*/ + UINT8 localCiType = 0U; /**/ + UINT16 EssSteadyMaskIdFlag = ESS_MASK_NO; /*Essȵλñ־*/ + UINT16 EssFlashMaskIdFlag = ESS_MASK_NO; /*Essȵλñ־*/ + UINT8 esbSetState = 0U; + UINT8 chEsbbVirtualAttribute = 0U; + + esbCurSum = GetEsbSum(); /*ȡesb*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + localCiType = GetLocalCiType();/*ȡ*/ + if (0U < esbCurSum) + { + /*ȡESB״̬Ϣ*/ + for (i = 0U; i < esbCurSum; i++) + { + esbId = GetEsbId(i); + devBlongCiId = GetEsbBelongCiId(esbId); /*ȡ豸ID*/ + /*ȡǰESB*/ + chEsbbVirtualAttribute = GetEsbVirtualAttribute(esbId); + + if ((localCiId == devBlongCiId) && (CI_TYPE_SCX == localCiType) + && (ESB_VIRTUAL_ATTR_YES == chEsbbVirtualAttribute)) + { + /*ȡָESBӦESSȵλID*/ + EssSteadyMaskIdFlag = GetEssSteadyCiToAtsMaskFlag(esbId); + /*ȡָESBӦESSλID*/ + EssFlashMaskIdFlag = GetEssFlashCiToAtsMaskFlag(esbId); + if ((ESS_MASK_YES == EssSteadyMaskIdFlag) && (ESS_MASK_YES == EssFlashMaskIdFlag)) + { + /*ESBش*/ + VirEsbRelateDelayDriStaManage(esbId); + /*ESBESS״̬ں*/ + esbSetState = GetVirEsbCurNeedSetState(esbId); + + } + else + { + /*ȡESBť״̬*/ + esbSetState = GetEsbAutualState(esbId); + + } + /*ESB״̬*/ + (void)SetEsbState(esbId, esbSetState); + + } + else + { + ; /*DZԳ߲*/ + } + + } + } +} +/* +* OC ESSPEPµơȵƺͷ̵״̬ +* ˵ UINT16 esbId ESB ID +* ֵ void +* עcgh-ϲCID-3037-1 +*/ +void VirEsbRelateDelayDriStaManage(UINT16 esbId) +{ + /*ʼ*/ + UINT8 esbRelateDelayDriveState = 0U; /*esbؼ̵״̬*/ + UINT16 bufIndex = 0U; /*±*/ + UINT8 EsbRelayState = 0U; + UINT8 ESSRelayState = 0U; + bufIndex = GetEsbConfigBufIndex(esbId); /*ȡ±*/ + + if (bufIndex < ESB_SUM_MAX) + { + esbRelateDelayDriveState = GetEsbRelateRelayDriveProState(esbId); /*ȡesbؼ̵״̬*/ + EsbRelayState = GetEsbAutualState(esbId);/*ȡESBť״̬*/ + ESSRelayState = GetEssState(esbId);/*ȡESSť״̬*/ + + switch (esbRelateDelayDriveState) + { + case ESB_PEPUP_ESSUP_INITION_STA: + /*ʼ״̬ȵơƶ*/ + SetEsbRelateEssSteadyState(esbId, ESB_STATE_LIGHT_STATE_N); + SetEsbRelateEssFlashState(esbId, ESB_STATE_LIGHT_STATE_N); + + if ((ESB_STATE_VALID_YES == EsbRelayState) && (ESB_STATE_GO_FLAG == ESSRelayState)) + { + /*PEP¡ESSȥλ״̬ת״̬2*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSUP_TWO_STATE); + } + else if ((ESB_STATE_VALID_NO == EsbRelayState) && (ESB_STATE_STOP_FLAG == ESSRelayState)) + { + /*ESSͣλº״̬ת״̬5*/ + SetEsbRelateRelayDriveProState(esbId, ESB_TWOPEPUP_ESSDOWN_FIVE_STATE); + } + else + { + /*ڳʼ״̬°PEPESSͣλ״̬ת*/ + } + break; + case ESB_PEPDOWN_ESSUP_TWO_STATE: + + /*״̬2ʱָʾ*/ + SetEsbRelateEssSteadyState(esbId, ESB_STATE_LIGHT_STATE_N); + SetEsbRelateEssFlashState(esbId, ESB_STATE_LIGHT_STATE_Y); + + if ((ESB_STATE_VALID_YES == EsbRelayState) && (ESB_STATE_STOP_FLAG == ESSRelayState)) + { + /*ʱʹESSͣλ״̬ת״̬3*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSDOWN_THREE_STATE); + } + else if ((ESB_STATE_VALID_NO == EsbRelayState) && (ESB_STATE_GO_FLAG == ESSRelayState)) + { + /*ʱֱӸλPEPǷת״̬6*/ + SetEsbRelateRelayDriveProState(esbId, ESB_FAULT_SIX_STATE); + } + else + { + /*״̬2ʱֻת*/ + } + break; + case ESB_PEPDOWN_ESSDOWN_THREE_STATE: + + /*״̬3ʱָʾȵ*/ + SetEsbRelateEssSteadyState(esbId, ESB_STATE_LIGHT_STATE_Y); + SetEsbRelateEssFlashState(esbId, ESB_STATE_LIGHT_STATE_N); + + if ((ESB_STATE_VALID_YES == EsbRelayState) && (ESB_STATE_GO_FLAG == ESSRelayState)) + { + /*ʱʹESSȥλص״̬2*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSUP_TWO_STATE); + } + else if ((ESB_STATE_VALID_NO == EsbRelayState) && (ESB_STATE_STOP_FLAG == ESSRelayState)) + { + /*ʱʹPEPָص״̬4*/ + SetEsbRelateRelayDriveProState(esbId, ESB_ONEPEPUP_ESSDOWN_FOUR_STATE); + } + else + { + /*״̬3ʱֻת*/ + } + break; + case ESB_ONEPEPUP_ESSDOWN_FOUR_STATE: + + /*PEPȰ֮ESSͣλٻָPEPָʾ˸Ϊ״̬4*/ + SetEsbRelateEssSteadyState(esbId, ESB_STATE_LIGHT_STATE_N); + SetEsbRelateEssFlashState(esbId, ESB_STATE_LIGHT_STATE_Y); + + if ((ESB_STATE_VALID_NO == EsbRelayState) && (ESB_STATE_GO_FLAG == ESSRelayState)) + { + /*ʱʹESSȥλָʼ״̬*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPUP_ESSUP_INITION_STA); + } + else if ((ESB_STATE_VALID_YES == EsbRelayState) && (ESB_STATE_STOP_FLAG == ESSRelayState)) + { + /*ʱʹPEP£ת״̬3*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSDOWN_THREE_STATE); + } + else + { + /*״̬4ʱֻת*/ + } + break; + case ESB_TWOPEPUP_ESSDOWN_FIVE_STATE: + + /*ʹESSͣλPEPʱָʾȵΪ״̬5ʱ״̬4PEPESS̵״̬һµDZһ + ֱʹESSȥλָʼ״̬*/ + SetEsbRelateEssSteadyState(esbId, ESB_STATE_LIGHT_STATE_Y); + SetEsbRelateEssFlashState(esbId, ESB_STATE_LIGHT_STATE_N); + if ((ESB_STATE_VALID_NO == EsbRelayState) && (ESB_STATE_GO_FLAG == ESSRelayState)) + { + /*ֱӲESSλȥλָʼ״̬*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPUP_ESSUP_INITION_STA); + } + else if ((ESB_STATE_VALID_YES == EsbRelayState) && (ESB_STATE_STOP_FLAG == ESSRelayState)) + { + /*ٲPEPʹ֮£ת״̬3*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSDOWN_THREE_STATE); + } + else + { + /*״̬5ʱֻת*/ + } + break; + case ESB_FAULT_SIX_STATE: + + /*ֻڰPEPֱӻָPEPŻת״̬ʱȻESSPEPģESBЧָʾ*/ + SetEsbRelateEssSteadyState(esbId, ESB_STATE_LIGHT_STATE_N); + SetEsbRelateEssFlashState(esbId, ESB_STATE_LIGHT_STATE_Y); + + if ((ESB_STATE_VALID_YES == EsbRelayState) && (ESB_STATE_GO_FLAG == ESSRelayState)) + { + /*ٰPEPص״̬2̽вת״̬2*/ + SetEsbRelateRelayDriveProState(esbId, ESB_PEPDOWN_ESSUP_TWO_STATE); + } + else if ((ESB_STATE_VALID_NO == EsbRelayState) && (ESB_STATE_STOP_FLAG == ESSRelayState)) + { + /*ٰESSΪESSµģմ˲̽вת״̬4*/ + SetEsbRelateRelayDriveProState(esbId, ESB_ONEPEPUP_ESSDOWN_FOUR_STATE); + } + else + { + /*״̬6ʱֻת*/ + } + break; + default: + /*ڵ״̬*/ + break; + } + } +} +/* +* ȡʾźŻɫ +* ˵ const UINT8 signalColor, źŻɫ +* ֵ 0x01 :0x02:ƣ0x04: +*cgh-ϲCID-3037-3 +*/ +UINT8 GetFushiSignalDriveColor(const UINT8 signalColor) +{ + UINT8 reVal = CI_ERROR; + + /*Ƶ*/ + if (SIGNAL_SHOWCOLOUR_YELLOW == signalColor) + { + reVal = SIGNAL_DRIVECOLOUR_YELLOW; + } + else if (SIGNAL_SHOWCOLOUR_GREEN == signalColor) + { + reVal = SIGNAL_DRIVECOLOUR_GREEN; + } + else + { + reVal = SIGNAL_SHOWCOLOUR_REDCLOSE; + } + return reVal; +} +/* +* վ̨ȷϰťȵƼ̵ +* ˵ const UINT16 psdId, ID +* ֵ +*cgh-ϲCID-3037-7 +*/ +void StationCearPassenagerProcess(const UINT16 psdId) +{ + UINT8 clearPassenagerFlag = 0U; /*ͱ־*/ + UINT16 QKSteadyLightRelayId = 0U; /*ȷϰťȵƼ̵ID*/ + UINT8 QKButtonRelayState = 0U; /*ȷϰť̵״̬*/ + UINT16 QKFlashLightRelayId = 0U; /*ȷϰťƼ̵ID*/ + UINT16 QKButtonRelayId = 0U; /*ȷϰť̵ID*/ + UINT16 psdRelativePhySecId = 0U; /*ŹID*/ + UINT8 secState = 0U; /*״̬*/ + UINT8 psdState = 0U; /*״̬*/ + UINT8 steadyLightFlag = 0U; /*ͰťȵƱ־*/ + + clearPassenagerFlag = GetClearPassenagerFlag(psdId); /*ȡͱ־*/ + QKSteadyLightRelayId = GetQKASteadyLightRelayId(psdId);/*ȡͰťȷȵƼ̵ID*/ + QKFlashLightRelayId = GetQKAFlashLightRelayId(psdId); /*ȡͰťȷƼ̵ID*/ + if (ATS_TO_CI_PLATFORM_QK_YES == clearPassenagerFlag) + { + psdRelativePhySecId = GetPsdRelatedPhySecId(psdId); /*ȡŹID*/ + secState = GetPhySecCurOccupyState(psdRelativePhySecId); /*ȡεǰռ״̬*/ + if (SECTION_OCCUPY_NO == secState) + { + /*վ̨֮ȵƼ̵*/ + if ((0U != QKSteadyLightRelayId) && (UINT16_MAX != QKSteadyLightRelayId)) + { + (void)SetRelayDriveState(QKSteadyLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + + if ((0U != QKFlashLightRelayId) && (UINT16_MAX != QKFlashLightRelayId)) + { + (void)SetRelayDriveState(QKFlashLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + /*վ̨֮ͱ־Ч*/ + SetClearPassenagerFlag(psdId, ATS_TO_CI_PLATFORM_QK_NO); + SetSteadyLightFlag(psdId, QK_BUTTON_STEADY_LIGHT_NO); /*ͰťȵƱ־*/ + } + else + { + /*վ̨гռ*/ + psdState = GetPsdState(psdId); /*ȡ״̬*/ + if (PSD_STATE_OPEN == psdState) + { + /*յVOBCĿվ̨/IBPϲųŴ״̬Ϊ򿪣Ͱťȷϼ̵״̬ȵƺƼ̵״̬*/ + QKButtonRelayId = GetQKButtonRelayId(psdId); /*ȡȷϰť̵ID*/ + QKButtonRelayState = GetRelayCollState(QKButtonRelayId); /*ȡȷϰť̵״̬*/ + steadyLightFlag = GetSteadyLightFlag(psdId); + /*ȷϰťԸʽģ̵֮3s£Ͱťȵƺȵ*/ + if ((RELAY_DRIVE_STATE_UP == QKButtonRelayState) || (QK_BUTTON_STEADY_LIGHT_YES == steadyLightFlag)) + { + /*վ̨ȷϰť̵ȷϰťȵƼ̵*/ + if ((0U != QKSteadyLightRelayId) && (UINT16_MAX != QKSteadyLightRelayId)) + { + (void)SetRelayDriveState(QKSteadyLightRelayId, RELAY_DRIVE_STATE_UP); + } + + if ((0U != QKFlashLightRelayId) && (UINT16_MAX != QKFlashLightRelayId)) + { + (void)SetRelayDriveState(QKFlashLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + SetSteadyLightFlag(psdId, QK_BUTTON_STEADY_LIGHT_YES); /*ͰťȵƱ־*/ + } + else if (RELAY_DRIVE_STATE_DOWN == QKButtonRelayState) + { + /*վ̨ȷϰť̵£ȷϰťƼ̵*/ + if ((0U != QKSteadyLightRelayId) && (UINT16_MAX != QKSteadyLightRelayId)) + { + (void)SetRelayDriveState(QKSteadyLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + + if ((0U != QKFlashLightRelayId) && (UINT16_MAX != QKFlashLightRelayId)) + { + (void)SetRelayDriveState(QKFlashLightRelayId, RELAY_DRIVE_STATE_UP); + } + } + else + { + /**/ + } + } + else + { + /*ȵ֮󣬳ţδվ̨֮ǰһֱȵ*/ + steadyLightFlag = GetSteadyLightFlag(psdId); + if (QK_BUTTON_STEADY_LIGHT_YES == steadyLightFlag) + { + /*վ̨ȷϰť̵ȷϰťȵƼ̵*/ + if ((0U != QKSteadyLightRelayId) && (UINT16_MAX != QKSteadyLightRelayId)) + { + (void)SetRelayDriveState(QKSteadyLightRelayId, RELAY_DRIVE_STATE_UP); + } + + if ((0U != QKFlashLightRelayId) && (UINT16_MAX != QKFlashLightRelayId)) + { + (void)SetRelayDriveState(QKFlashLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + } + } + } + else + { + /*վ̨ûͱ־ʱȵƼ̵Ч̵*/ + if ((0U != QKSteadyLightRelayId) && (UINT16_MAX != QKSteadyLightRelayId)) + { + (void)SetRelayDriveState(QKSteadyLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + + if ((0U != QKFlashLightRelayId) && (UINT16_MAX != QKFlashLightRelayId)) + { + (void)SetRelayDriveState(QKFlashLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + } +} + +/* +* ŶӦȷŰť״̬ںPDBʾƻ +* ˵ const UINT16 wPsdId ID +* ֵ 0u: ʧ +* 1: ³ɹ +* cgh޸ijɶ +*/ +UINT8 PsdCleFarePCBRelToDevStaProc(const UINT16 wPsdId) +{ + UINT8 reVal = CI_ERROR; + UINT32 dwCycNum = 0U; /*ȷPCBť*/ + UINT16 wCleFarePCBButRelayId = 0U; /*ȷŰť̵ID*/ + UINT8 chCleFarePCBButRelaySta = 0U; /*ȷŰť̵״̬*/ + UINT8 chCheckTimeState = 0U; /*ȷŰťɼЧ־*/ + UINT32 dwSelfCollSnCount = 0U; /*ԸʽťӦ̵ɼЧ*/ + + if ((0u == wPsdId) || (PSD_SUM_MAX <= wPsdId)) + { + reVal = CI_ERROR; + } + else + {/*ȷŰť״̬*//*by cgh 20230526*/ + reVal = CI_SUCCESS; + wCleFarePCBButRelayId = GetCleFarePCBButRelayId(wPsdId); + if ((0u != wCleFarePCBButRelayId) && (UINT16_MAX != wCleFarePCBButRelayId)) + {/*ȷPCBť̵IDЧ*/ + chCleFarePCBButRelaySta = GetRelayCollState(wCleFarePCBButRelayId); + dwCycNum = GetCleFarePCBPressCycNum(wPsdId); + /*ȷPCBťΪԸʽťӦ̵ɼ3ڲΪ---*/ + if (RELAY_STATE_UP == chCleFarePCBButRelaySta) + { + if (0u == dwCycNum) + {/*δʱм䶶ʼ*/ + reVal = SetCleFarePCBPressCycNum(wPsdId, Get2oo2CurCycleNum()); + } + } + else if (RELAY_STATE_DOWN == chCleFarePCBButRelaySta) + {/*ȷPCBʼں*/ + reVal = SetCleFarePCBPressCycNum(wPsdId, 0u); + } + else + {/*ɼ״̬Ч*/ + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + /*Ϊǰݼ̵״̬ıȷPCBťڣٴλȡһ*/ + dwCycNum = GetCleFarePCBPressCycNum(wPsdId); + /*ԸʽťӦ̵ɼЧ*/ + dwSelfCollSnCount = GetSelfButCollCount(); + /*ʱʱ*/ + chCheckTimeState = SystemOverTimeCheck(dwCycNum, dwSelfCollSnCount); + /*ʱʱ*/ + if (CI_TIME_OUT == chCheckTimeState) + {/*ȷPCBťﵽҪ()ȷPCBť״̬ť״̬*/ + reVal = SetCleFarePCBButtonState(wPsdId, QK_PSD_BUTTON_STATE_DOWN); + reVal &= SetCleFarePCBButKeepState(wPsdId, QK_PSD_BUTTON_STATE_DOWN); + } + else + {/*ȷPCBťﲻҪ()PCBţ̌ȷPCBť״̬δ*/ + reVal = SetCleFarePCBButtonState(wPsdId, QK_PSD_BUTTON_STATE_UP); + } + } + else + {/*ɼЧ,ȷPCBť״̬δ*/ + reVal = SetCleFarePCBPressCycNum(wPsdId, 0u); + reVal &= SetCleFarePCBButtonState(wPsdId, QK_PSD_BUTTON_STATE_UP); + reVal &= SetCleFarePCBButKeepState(wPsdId, QK_PSD_BUTTON_STATE_UP); + } + } + else + { + reVal = CI_SUCCESS; /*Щ·PSDȷPCBťȷPCBť̵IDЧcontinueִ*/ + } + } + return reVal; +} + +/* +* ŶӦȷ䷢ťָʾ߼״̬ +* ˵ const UINT16 wPsdId ID +* ֵ 0u: ʧ +* 1: ³ɹ +* cgh޸ijɶ +*/ +UINT8 PsdCleFarePDBRelToDevStaProc(const UINT16 wPsdId) +{ + UINT8 reVal = CI_ERROR; + UINT32 dwCycNum = 0U; /*PDBť*/ + UINT16 wPDBButRelayId = 0U; /*PDBť̵ID*/ + UINT8 chPDBButRelaySta = 0U; /*PDBť̵״̬*/ + UINT8 chCheckTimeState = 0U; /*PDBťɼЧ־*/ + UINT32 dwSelfCollSnCount = 0U; /*ԸʽťӦ̵ɼЧ*/ + + if ((0u == wPsdId) || (PSD_SUM_MAX <= wPsdId)) + { + reVal = CI_ERROR; + } + else + {/*ť״̬*//*by cgh 20230529*/ + reVal = CI_SUCCESS; + wPDBButRelayId = GetPsdDeparConfmRelayId(wPsdId); + if ((0u != wPDBButRelayId) && (UINT16_MAX != wPDBButRelayId)) + {/*ȷPDBť̵IDЧ*/ + chPDBButRelaySta = GetRelayCollState(wPDBButRelayId); + dwCycNum = GetPSBPressCycNum(wPsdId); + /*PDBťΪԸʽťӦ̵ɼ3ڲΪ---*/ + if (RELAY_STATE_UP == chPDBButRelaySta) + { + if (0u == dwCycNum) + {/*δʱм䶶ʼ*/ + reVal = SetPSBPressCycNum(wPsdId, Get2oo2CurCycleNum()); + } + } + else if (RELAY_STATE_DOWN == chPDBButRelaySta) + {/*PDBʼں*/ + reVal = SetPSBPressCycNum(wPsdId, 0u); + } + else + {/*ɼ״̬Ч*/ + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + /*Ϊǰݼ̵״̬ıPDBťڣٴλȡһ*/ + dwCycNum = GetPSBPressCycNum(wPsdId); + /*ԸʽťӦ̵ɼЧ*/ + dwSelfCollSnCount = GetSelfButCollCount(); + /*ʱʱ*/ + chCheckTimeState = SystemOverTimeCheck(dwCycNum, dwSelfCollSnCount); + /*ʱʱ*/ + if (CI_TIME_OUT == chCheckTimeState) + {/*PDBťﵽҪ()PDBť״̬ЧͬʱȷPCBť¼״̬*/ + reVal = SetPsdDepartButtonState(wPsdId, PLATFORM_DEPAR_BUTTON_STATE_VALID); + reVal &= SetCleFarePCBButKeepState(wPsdId, QK_PSD_BUTTON_STATE_UP); + } + else + {/*PDBťﲻҪ()PDBţ̌PDBť״̬Ч*/ + reVal = SetPsdDepartButtonState(wPsdId, PLATFORM_DEPAR_BUTTON_STATE_INVALID); + } + } + else + {/*ɼЧ,PDBťЧ*/ + reVal = SetPSBPressCycNum(wPsdId, 0u); + reVal &= SetPsdDepartButtonState(wPsdId, PLATFORM_DEPAR_BUTTON_STATE_INVALID); + } + } + else + { + reVal = CI_SUCCESS; /*Щ·PSDPDBťPDBť̵IDЧcontinueִ*/ + } + } + return reVal; +} + +/* +* ȷ䷢ťָʾƴ +* ˵ const UINT16 psdId, ID +* ֵ +*cgh޸ijɶ +*/ +void PsdCleFarePDBFlashProcess(const UINT16 psdId) +{ + UINT8 chCleFarePCBButKeepState = 0U;/*ȷŰť״̬*/ + UINT16 wCleFareFlaLigRelayId = 0U; /*ȷ䰴ťָʾƼ̵ID*/ + UINT16 wPsdRelativePhySecId = 0U; /*ŹID*/ + UINT8 chSecState = 0U; /*״̬*/ + UINT8 chPsdState = 0U; /*״̬*/ + UINT8 chMutualLockState = 0U;/*Ż״̬*/ + + chCleFarePCBButKeepState = GetCleFarePCBButKeepState(psdId); + wCleFareFlaLigRelayId = GetCleFarePDBFlaLigRelayId(psdId); /*ȷ䰴ťָʾƼ̵ID*/ + if ((0U != wCleFareFlaLigRelayId) && (UINT16_MAX != wCleFareFlaLigRelayId)) + {/*ȷ䰴ťָʾƼ̵IDЧʱд*/ + if (QK_PSD_BUTTON_STATE_DOWN == chCleFarePCBButKeepState) + {/*ȷŰť״̬Ϊ²к*/ + wPsdRelativePhySecId = GetPsdRelatedPhySecId(psdId); /*ȡŹID*/ + chSecState = GetPhySecCurOccupyState(wPsdRelativePhySecId); /*ȡεǰռ״̬*/ + if (SECTION_OCCUPY_NO == chSecState) + {/*վ̨ռãȷPDBťָʾƼ̵£ȷPDBťָʾƲƱ־*/ + (void)SetRelayDriveState(wCleFareFlaLigRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetCleFarePDBFlaLigFlag(psdId, QK_BUTTON_FLASH_LIGHT_NO); + } + else + { + /*վ̨гռ*/ + chPsdState = GetPsdState(psdId); /*ȡ״̬*/ + chMutualLockState = GetPsdMutualLockRemoveState(psdId);/*ȡŻ״̬*/ + + if ((PSD_STATE_CLOSE == chPsdState) || (PSD_MUTUALLOCK_REMOVE_YES == chMutualLockState)) + { + /*վ̨гռãŹرջлȷPDBťָʾƼ̵ȷPDBťָʾƱ־*/ + (void)SetRelayDriveState(wCleFareFlaLigRelayId, RELAY_DRIVE_STATE_UP); + (void)SetCleFarePDBFlaLigFlag(psdId, QK_BUTTON_FLASH_LIGHT_YES); + } + else + { + /*վ̨гռãŴûлȷPDBťָʾƼ̵£ȷPDBťָʾƲƱ־*/ + (void)SetRelayDriveState(wCleFareFlaLigRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetCleFarePDBFlaLigFlag(psdId, QK_BUTTON_FLASH_LIGHT_NO); + + } + } + } + else + {/*ȷPCBŰť״̬Ϊ£ȷPDBťָʾƼ̵£ȷPDBťָʾƲƱ־*/ + + (void)SetRelayDriveState(wCleFareFlaLigRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetCleFarePDBFlaLigFlag(psdId, QK_BUTTON_FLASH_LIGHT_NO); + } + } +} + +/* +* Ըʽͣť +* ˵UINT16 esbId ESB ID +* ֵ +*/ +void EsbZfsBtnProc(UINT16 esbId) +{ + UINT16 esbRelayId = 0u; /*esb̵ID*/ + UINT8 localCiId = 0U; /*ID*/ + UINT8 esbRelayBelongCiId = 0U; /*esbɼ̵1CI*/ + UINT8 esbRelayCollState = 0U; /*esbťɼ̵1״̬*/ + UINT32 cycnow = 0U; /*ǰ*/ + UINT32 zfsBtnRelayCollCycNum = 0U; /*Ըʽť̵жϲɼЧ*/ + UINT32 zfsBtnRelayFaultCycNum = 0U; /*Ըʽť̵жϹ*/ + UINT32 esbPressCycNum = 0U; /*رհť*/ + UINT8 btnPressValidTime = CI_TIME_NO; /*ťʱǷﵽЧʱ*/ + UINT8 btnPressFaultTime = CI_TIME_NO; /*ťʱǷﵽʱ*/ + UINT8 esbErrorFlag = ESB_ERROR_FLAG_NO; /*ESBϱ־*/ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetEsbConfigBufIndex(esbId); + + if (bufIndex < ESB_SUM_MAX) + { + /***** Ըʽͣť *****/ + esbRelayId = GetEsbRelayId(esbId); + esbRelayBelongCiId = GetRelayBelongCiId(esbRelayId); + localCiId = GetSystemParaLocalCiId(); + if ((0U != esbRelayId) && (UINT16_MAX != esbRelayId) && (esbRelayBelongCiId == localCiId)) + { + esbRelayCollState = GetRelayCollState(esbRelayId); /*ȡESB̵ɼ״̬*/ + if (RELAY_STATE_DOWN == esbRelayCollState) + { + esbPressCycNum = GetEsbPressCycNum(esbId); + if (0U == esbPressCycNum) + { + cycnow = Get2oo2CurCycleNum(); + SetEsbPressCycNum(esbId, cycnow); + } + else + { + /*Ѽ¼ťڣ˴¼*/ + } + } + else + { + SetEsbPressCycNum(esbId, 0U); + } + + esbPressCycNum = GetEsbPressCycNum(esbId); + zfsBtnRelayCollCycNum = GetSelfButCollCount(); + btnPressValidTime = SystemOverOrEqualTimeCheck(esbPressCycNum, zfsBtnRelayCollCycNum); + esbErrorFlag = GetEsbErrFlag(esbId); + if ((CI_TIME_OUT == btnPressValidTime) && (ESB_ERROR_FLAG_YES != esbErrorFlag)) + { + /*ťʱﵽжϲɼЧʱδϣýرЧ*/ + (void)SetEsbState(esbId, ESB_STATE_VALID_YES); + } + else + { + /**/ + } + + zfsBtnRelayFaultCycNum = GetSelfButErrCount(); + btnPressFaultTime = SystemOverTimeCheck(esbPressCycNum, zfsBtnRelayFaultCycNum); + if (CI_TIME_OUT == btnPressFaultTime) + { + SetEsbErrFlag(esbId, ESB_ERROR_FLAG_YES); + } + else + { + SetEsbErrFlag(esbId, ESB_ERROR_FLAG_NO); + } + } + else + { + /*̵ID/DZ*/ + } + } + else + { + /*󣬲*/ + } +} + +/* +* Ըʽȡͣť +* ˵UINT16 esbId ESB ID +* ֵ +*/ +void EsbZfsCancelBtnProc(UINT16 esbId) +{ + UINT16 wEsbIdIndex = 0U; /*ESB±*/ + UINT16 wRelayIdIndex = 0U; /*̵±*/ + UINT16 cancelEsbRelayId = 0u; /*ȡesb̵ID*/ + UINT8 localCiId = 0U; /*ID*/ + UINT8 cancelEsbRelayBelongCiId = 0U; /*ȡesbɼ̵1CI*/ + UINT32 zfsBtnRelayCollCycNum = 0U; /*Ըʽť̵жϲɼЧ*/ + UINT32 zfsBtnRelayFaultCycNum = 0U; /*Ըʽť̵жϹ*/ + UINT32 zfsBtnRelayErrTriggerCycNum = 0U; /*Ըʽť̵ж󴥷*/ + UINT32 cancelEsbPressCycNum = 0U; /*ȡرհť*/ + UINT32 cancelEsbErrTriggerPressCycNum = 0U; /*ȡرհť󴥷*/ + UINT8 cancelEsbValidFlag = ESB_CANCEL_VALID_NO; /*ȡرհťЧ־*/ + UINT8 btnPressValidTime = CI_TIME_NO; /*ťʱǷﵽЧʱ*/ + UINT8 btnPressFaultTime = CI_TIME_NO; /*ťʱǷﵽʱ*/ + UINT8 btnPressErrTriggerTime = CI_TIME_NO; /*ťʱǷﵽ󴥷ʱ*/ + UINT8 esbErrorFlag = ESB_ERROR_FLAG_NO; + + wEsbIdIndex = GetEsbConfigBufIndex(esbId); + + if (wEsbIdIndex < ESB_SUM_MAX) + { + /***** Ըʽȡͣť *****/ + cancelEsbRelayId = GetCancelEsbRelayId(esbId); + wRelayIdIndex = GetRelayConfigBufIndex(cancelEsbRelayId); + cancelEsbRelayBelongCiId = GetRelayBelongCiId(cancelEsbRelayId); + localCiId = GetSystemParaLocalCiId(); + + if ((wRelayIdIndex < RELAY_SUM_MAX) && (localCiId == cancelEsbRelayBelongCiId) && (0U != localCiId)) + { + /***** 1.ȡرհť/󴥷ںͲɼ̵״̬ *****/ + EsbZfsCancelBtnPressStateProc(esbId, cancelEsbRelayId); + + /***** 2.ȡرհťЧ־ *****/ + EsbZfsCancelBtnValidFlagProc(esbId, cancelEsbRelayId); + + /***** 3.״̬ȡرհťЧ־ *****/ + cancelEsbValidFlag = GetCancelEsbValidFlag(esbId); + cancelEsbPressCycNum = GetCancelEsbPressCycNum(esbId); + zfsBtnRelayCollCycNum = GetSelfButCollCount(); + btnPressValidTime = SystemOverTimeCheck(cancelEsbPressCycNum, zfsBtnRelayCollCycNum); + zfsBtnRelayFaultCycNum = GetSelfCancelButErrCount(); + btnPressFaultTime = SystemOverTimeCheck(cancelEsbPressCycNum, zfsBtnRelayFaultCycNum); + esbErrorFlag = GetEsbErrFlag(esbId); + + if ((ESB_CANCEL_VALID_YES == cancelEsbValidFlag) && (CI_TIME_OUT == btnPressValidTime) && (CI_TIME_OUT != btnPressFaultTime)) + { + /*ȡرհťЧҰťʱﵽжϲɼЧʱδﵽжʱ䣬ýرЧȡرհťЧ*/ + (void)SetEsbState(esbId, ESB_STATE_VALID_NO); + SetCancelEsbValidFlag(esbId, ESB_CANCEL_VALID_NO); + } + else if ((ESB_ERROR_FLAG_NO != esbErrorFlag) && ((CI_TIME_OUT != btnPressValidTime) || (CI_TIME_OUT == btnPressFaultTime))) + { + /*رհťңȡرհťʱδЧť¹ϣýرЧ*/ + (void)SetEsbState(esbId, ESB_STATE_VALID_YES); + } + else + { + /**/ + } + + /***** 4.ȡرհťϱ־ *****/ + cancelEsbErrTriggerPressCycNum = GetCancelEsbErrTrigPressCycNum(esbId); /*ȡȡť󴥷*/ + zfsBtnRelayErrTriggerCycNum = GetSelfCancelButErrTriggerCount(); /*ȡԸʽȡť󴥷жʱ*/ + btnPressErrTriggerTime = SystemOverTimeCheck(cancelEsbErrTriggerPressCycNum, zfsBtnRelayErrTriggerCycNum); + + if ((CI_TIME_OUT == btnPressFaultTime) || (CI_TIME_OUT == btnPressErrTriggerTime)) + { + /*ȡťʱﵽжʱ󴥷ʱﵽ󴥷жʱ䣬ȡͣťϱ־*/ + SetCancelEsbErrFlag(esbId, ESB_ERROR_FLAG_YES); + } + else + { + SetCancelEsbErrFlag(esbId, ESB_ERROR_FLAG_NO); + } + } + else + { + /*̵ID/DZ*/ + } + } + else + { + /*󣬲*/ + } +} + +/* +* Ըʽͣťȡť״̬ +* ˵const UINT16 wEsbId ESB ID +* const UINT16 wCancelEsbRelayId ESBȡťɼ̵ID +* ֵ +* Created By LQ 2024.05.09 +*/ +void EsbZfsCancelBtnPressStateProc(const UINT16 wEsbId, const UINT16 wCancelEsbRelayId) +{ + UINT16 wEsbIdIndex = 0U; /*ESB±*/ + UINT16 wRelayIdIndex = 0U; /*̵±*/ + UINT8 cCancelRelayCollState = 0U; /*ȡesbťɼ̵״̬*/ + UINT8 cEsbState = ESB_STATE_VALID_NO; /*ر״̬*/ + UINT8 cCancelEsbRelayDownState = ESB_RELAY_ERROR_DOWN_YES; /*ȡرհť̵״̬*/ + UINT32 dwCancelBtnPressCycNum = 0U; /*ȡرհť*/ + UINT32 dwCancelBtnErrTrigPressCycNum = 0U; /*ȡرհť󴥷*/ + UINT32 dwCurCycNum = 0U; /*ǰ*/ + UINT16 wRelayBelongOcId = 0U; /*̵OC*/ + UINT8 cOcCommState = TRANSMIT_STATE_BAD; /*OCͨ״̬*/ + UINT8 cABoardState = RELAY_BOARD_FAULT_YES; /*Aϵ忨״̬*/ + UINT8 cBBoardState = RELAY_BOARD_FAULT_YES; /*Bϵ忨״̬*/ + + wEsbIdIndex = GetEsbConfigBufIndex(wEsbId); + wRelayIdIndex = GetRelayConfigBufIndex(wCancelEsbRelayId); + + if ((wEsbIdIndex < ESB_SUM_MAX) && (wRelayIdIndex < RELAY_SUM_MAX)) + { + cCancelRelayCollState = GetRelayCollState(wCancelEsbRelayId); /*ȡȡ۳ť̵ɼ״̬*/ + + if (RELAY_STATE_UP == cCancelRelayCollState) + { + /** ̵𣬸ȡرհť/󴥷 **/ + cEsbState = GetEsbState(wEsbId); /*ȡESB״̬*/ + cCancelEsbRelayDownState = GetCancelEsbRelayDownState(wEsbId); /*ȡȡťɼ̵״̬*/ + dwCancelBtnPressCycNum = GetCancelEsbPressCycNum(wEsbId); /*ȡȡť*/ + dwCancelBtnErrTrigPressCycNum = GetCancelEsbErrTrigPressCycNum(wEsbId); /*ȡȡť󴥷*/ + dwCurCycNum = Get2oo2CurCycleNum(); + + if ((ESB_STATE_VALID_YES == cEsbState) && (ESB_RELAY_ERROR_DOWN_NO == cCancelEsbRelayDownState)) + { + /*Ч֮ǰȡرհťɼ̵״̬OCͨҰ忨״̬ȡرհť*/ + if ((0U == dwCancelBtnPressCycNum) && (0U == dwCancelBtnErrTrigPressCycNum)) + { + SetCancelEsbPressCycNum(wEsbId, dwCurCycNum); /*º󴥷²ͬʱ*/ + } + else + { + /**/ + } + } + else + { + /*Ч֮ǰȡرհťɼ̵δ״̬OCͨжϻ˫ϵ忨״̬쳣ȡرհť󴥷*/ + if ((0U == dwCancelBtnPressCycNum) && (0U == dwCancelBtnErrTrigPressCycNum)) + { + SetCancelEsbErrTrigPressCycNum(wEsbId, dwCurCycNum); /*º󴥷²ͬʱ*/ + } + else + { + /**/ + } + } + } + else + { + /** ̵£ȡرհťɼ̵״̬ **/ + wRelayBelongOcId = GetRelayBelongOCId(wCancelEsbRelayId); + cOcCommState = GetCiTransmitState(CI_SYSTEM_TYPE_OC, (UINT8)wRelayBelongOcId); /*ȡOCͨ״̬*/ + cABoardState = GetRelayACollBoardState(wCancelEsbRelayId); /*ȡAϵ忨״̬*/ + cBBoardState = GetRelayBCollBoardState(wCancelEsbRelayId); /*ȡBϵ忨״̬*/ + + if ((TRANSMIT_STATE_GOOD == cOcCommState) && ((RELAY_BOARD_FAULT_NO == cABoardState) || (RELAY_BOARD_FAULT_NO == cBBoardState))) + { + /*OCͨһϵ忨״̬ü̵*/ + SetCancelEsbRelayDownState(wEsbId, ESB_RELAY_ERROR_DOWN_NO); + } + else + { + /*OCͨ쳣ϵ忨״̬ϣü̵ͨ쳣*/ + SetCancelEsbRelayDownState(wEsbId, ESB_RELAY_ERROR_DOWN_YES); + } + + /** ̵£ȡرհťں󴥷 **/ + SetCancelEsbPressCycNum(wEsbId, 0U); + SetCancelEsbErrTrigPressCycNum(wEsbId, 0U); + } + } + else + { + /*ηǷ*/ + } +} + +/* +* ԸʽͣťȡťЧ־ +* ˵const UINT16 wEsbId ESB ID +* const UINT16 wCancelEsbRelayId ESBȡťɼ̵ID +* ֵ +* Created By LQ 2024.05.09 +*/ +void EsbZfsCancelBtnValidFlagProc(const UINT16 wEsbId, const UINT16 wCancelEsbRelayId) +{ + UINT16 wEsbIdIndex = 0U; /*ESB±*/ + UINT16 wRelayIdIndex = 0U; /*̵±*/ + UINT8 cEsbState = ESB_STATE_VALID_NO; /*ر״̬*/ + UINT16 wEsbRelayId = 0U; /*ESBɼ̵ID*/ + UINT8 cEsbRelayCollState = 0U; /*ESBɼ̵״̬*/ + UINT8 cEsbErrorFlag = ESB_ERROR_FLAG_NO; /*ESBϱ־*/ + UINT8 cCancelEsbRelayCollState = 0U; /*ESBȡťɼ̵״̬*/ + UINT8 cCancelEsbRelayDownState = ESB_RELAY_ERROR_DOWN_YES; /*ESBȡť̵״̬*/ + + wEsbIdIndex = GetEsbConfigBufIndex(wEsbId); + wRelayIdIndex = GetRelayConfigBufIndex(wCancelEsbRelayId); + + if ((wEsbIdIndex < ESB_SUM_MAX) && (wRelayIdIndex < RELAY_SUM_MAX)) + { + cEsbState = GetEsbState(wEsbId); /*ȡESB״̬*/ + wEsbRelayId = GetEsbRelayId(wEsbId); + cEsbRelayCollState = GetRelayCollState(wEsbRelayId); /*ȡESB̵ɼ״̬*/ + cEsbErrorFlag = GetEsbErrFlag(wEsbId); /*ȡESBťϱ־*/ + cCancelEsbRelayCollState = GetRelayCollState(wCancelEsbRelayId); /*ȡESBȡť̵ɼ״̬*/ + cCancelEsbRelayDownState = GetCancelEsbRelayDownState(wEsbId); /*ȡESBȡťɼ̵״̬*/ + + if ((ESB_STATE_VALID_YES == cEsbState) && ((RELAY_STATE_UP == cEsbRelayCollState) || (ESB_ERROR_FLAG_YES == cEsbErrorFlag)) + && (RELAY_STATE_DOWN == cCancelEsbRelayCollState) && (ESB_RELAY_ERROR_DOWN_NO == cCancelEsbRelayDownState)) + { + /*رЧ(رհťɼ̵ť)ȡرհťɼ̵Ϊ£ȡرհťЧ*/ + SetCancelEsbValidFlag(wEsbId, ESB_CANCEL_VALID_YES); + } + else if (((RELAY_STATE_UP != cEsbRelayCollState) && (ESB_ERROR_FLAG_YES != cEsbErrorFlag)) || (ESB_RELAY_ERROR_DOWN_NO != cCancelEsbRelayDownState)) + { + /*رհťɼ̵δδϣȡťɼ̵״̬£ȡرհťЧ*/ + SetCancelEsbValidFlag(wEsbId, ESB_CANCEL_VALID_NO); + } + else + { + /**/ + } + } + else + { + /*ηǷ*/ + } +} + +/* +* SPKS״̬߼SPKS״̬ +* ˵ +* ֵ +* by cgh 20230919 ߼η״̬ڸATSʾ +*/ +void SpksRelayToLogSecFlockStatus(void) +{ + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 wLogSecCurSum = 0U; /* ߼Ŀ*/ + UINT16 wLogSecId = 0U; /* ߼ID*/ + UINT8 chLogSecSpksSum = 0U;/*߼ιSPKSĿ*/ + UINT16 wLogSecSpksId = 0U;/*߼ιSPKS ID*/ + UINT8 chSpksState = 0U;/*߼ιSPKS״̬*/ + UINT8 chSpksCutState = 0U;/*߼ιSPKS·״̬*/ + + wLogSecCurSum = GetLogicSecCurSum(); /*ȡ߼*/ + + /*߼*/ + for (ii = 0U; ii < wLogSecCurSum; ii++) + { + wLogSecId = 0U; /*߼ID*/ + wLogSecId = GetLogicSecId(ii); /*ȡ߼ID*/ + + if ((0U != wLogSecId) && (wLogSecId < LOGIC_SECTION_SUM_MAX)) + { + chLogSecSpksSum = GetLogSecSpksSum(wLogSecId); /*ȡ߼ιSPKSĿ*/ + for (jj = 0U; jj < chLogSecSpksSum; jj++) + { + wLogSecSpksId = GetLogSecSpksIdBySpksIdx(wLogSecId, jj); + if (0U < wLogSecSpksId) + { + chSpksState = GetSpksState(wLogSecSpksId); + chSpksCutState = GetSpksCutState(wLogSecSpksId); + if ((SPKS_STATUS_NO != chSpksState) && (SPKS_CUT_YES != chSpksCutState)) + { + SetLogSecSpksFLockState(wLogSecId, LOGIC_SECTION_SPKS_FLOCK_YES); + break; + } + } + } + + /*˴жϴûз */ + if ((jj == chLogSecSpksSum) && (0u < jj)) + { + SetLogSecSpksFLockState(wLogSecId, LOGIC_SECTION_SPKS_FLOCK_NO); + } + else + { + /*޲*/ + } + } + } +} + +/* +* ٿ/Űťָʾƴ +* ˵ const UINT16 psdId, ID +* ֵ +* ɶ132730󡪡2023.09.21 +*/ +void PsdOpenAndCloseBsdProc(const UINT16 psdId) +{ + UINT16 wPcbBsdRelayId = 0U; /*PCBťʾƼ̵*/ + UINT16 wPobBsdRelayId = 0U; /*POBťʾƼ̵*/ + UINT32 dwBtnPressInvalidCycNum = 0U; /*ť³ʧЧ*/ + UINT32 dwPcbPressStartCycNum = 0U; /*PCBʼ*/ + UINT32 dwPobPressStartCycNum = 0U; /*POBʼ*/ + UINT8 cPcbstate = 0U; /*PCB״̬*/ + UINT8 cPobstate = 0U; /*POB״̬*/ + UINT8 cBtnPressTimeCheck = 0U; + + if ((0U != psdId) && (PSD_SUM_MAX != psdId)) + { + dwBtnPressInvalidCycNum = GetPsdButtonPressCount(); /*ȡPSDť³ʧЧ*/ + + /*ٹŰťָʾ*/ + wPcbBsdRelayId = GetPsdPcbRelayId(psdId); + if ((0U != wPcbBsdRelayId) && (RELAY_SUM_MAX != wPcbBsdRelayId)) + { + dwPcbPressStartCycNum = GetPCBPressCycNum(psdId); + cBtnPressTimeCheck = SystemOverTimeCheck(dwPcbPressStartCycNum, dwBtnPressInvalidCycNum); + cPcbstate = GetPsdButtonState(psdId); + + if (CI_TIME_OUT == cBtnPressTimeCheck) + { + (void)SetRelayDriveState(wPcbBsdRelayId, RELAY_DRIVE_STATE_DOWN); /*³ʱָʾ*/ + } + else + { + if (PSD_BUTTON_STATE_UP == cPcbstate) + { + (void)SetRelayDriveState(wPcbBsdRelayId, RELAY_DRIVE_STATE_DOWN); /*δδʱָʾ*/ + } + else if (PSD_BUTTON_STATE_DOWN == cPcbstate) + { + (void)SetRelayDriveState(wPcbBsdRelayId, RELAY_DRIVE_STATE_UP); /*δʱָʾ*/ + } + else + { + /**/ + } + } + + } + else + { + /*δñʾƼ̵*/ + } + + /*ٿŰťָʾ*/ + wPobBsdRelayId = GetPsdPobBsdRelayId(psdId); + if ((0U != wPobBsdRelayId) && (RELAY_SUM_MAX != wPobBsdRelayId)) + { + dwPobPressStartCycNum = GetPOBPressCycNum(psdId); + cBtnPressTimeCheck = SystemOverTimeCheck(dwPobPressStartCycNum, dwBtnPressInvalidCycNum); + cPobstate = GetPsdOpenButtonState(psdId); + + if (CI_TIME_OUT == cBtnPressTimeCheck) + { + (void)SetRelayDriveState(wPobBsdRelayId, RELAY_DRIVE_STATE_DOWN); /*³ʱָʾ*/ + } + else + { + if (PSD_OPEN_BUTTON_STATE_INVALID == cPobstate) + { + (void)SetRelayDriveState(wPobBsdRelayId, RELAY_DRIVE_STATE_DOWN); /*δδʱָʾ*/ + } + else if (PSD_OPEN_BUTTON_STATE_VALID == cPobstate) + { + (void)SetRelayDriveState(wPobBsdRelayId, RELAY_DRIVE_STATE_UP); /*δʱָʾ*/ + } + else + { + /**/ + } + } + } + else + { + /*δñʾƼ̵*/ + } + } + else + { + /*ηǷ*/ + } +} + +/* +* ̵Ƿʱ-ʱʱ +* ˵ const UINT16 relayId ̵ID +* const UINT32 dwTimeOutCycCount ʱ +* ֵ 1ʱ״̬ +* 0ʱ +* by cgh 20230923 +*/ +UINT8 CheckRelayDriveOutTime(const UINT16 wRelayId, const UINT32 dwTimeOutCycCount) +{ + UINT8 chRelayColleState = 0U;/*̵ɼ״̬*/ + UINT8 chrelayDriveState = 0U;/*̵״̬*/ + UINT8 chRetValue = CI_ERROR; + UINT32 dwCurCycNum = 0U;/*ϵͳǰ*/ + UINT8 checkRelayRes = 0U;/*̵ʱ*/ + UINT32 dwRelayCycNum = 0U;/*̵ʼ*/ + + if ((0U != wRelayId) && (RELAY_SUM_MAX != wRelayId)) + { + chRetValue = CI_SUCCESS; + dwCurCycNum = Get2oo2CurCycleNum(); + /*ȡ̵״̬*/ + chRelayColleState = GetRelayCollState(wRelayId); /*ɼ״̬*/ + chrelayDriveState = GetRelayDriveState(wRelayId); /*״̬*/ + + /**/ + if (RELAY_DRIVE_STATE_UP == chrelayDriveState) + { + /*ɼ*/ + if (RELAY_STATE_DOWN == chRelayColleState) + { + dwRelayCycNum = GetRelayDriveStartCycNum(wRelayId); + checkRelayRes = SystemOverTimeCheck(dwRelayCycNum, dwTimeOutCycCount); + /*δʱ*/ + if (CI_TIME_NO == checkRelayRes) + { + SetRelayDriveStartCycNum(wRelayId, dwCurCycNum);/*ü̵Ч*/ + } + /*ʱ*/ + else if (CI_TIME_OUT == checkRelayRes) + { + chRetValue = CI_ERROR; + } + else + { + /*ʱУسɹ*/ + } + } + else + { + SetRelayDriveStartCycNum(wRelayId, 0U);/*ü̵Ч*/ + } + } + else if ((RELAY_DRIVE_STATE_DOWN == chrelayDriveState) || (RELAY_DRIVE_STATE_NULL == chrelayDriveState)) + { + /*ɼ*/ + if (RELAY_STATE_UP == chRelayColleState) + { + dwRelayCycNum = GetRelayDriveStartCycNum(wRelayId); + checkRelayRes = SystemOverTimeCheck(dwRelayCycNum, dwTimeOutCycCount); + /*δʱ*/ + if (CI_TIME_NO == checkRelayRes) + { + SetRelayDriveStartCycNum(wRelayId, dwCurCycNum);/*ü̵Ч*/ + } + /*ʱ*/ + else if (CI_TIME_OUT == checkRelayRes) + { + chRetValue = CI_ERROR; + } + else + { + /*ʱУسɹ*/ + } + } + else + { + SetRelayDriveStartCycNum(wRelayId, 0U);/*ü̵Ч*/ + } + } + else + { + SetRelayDriveStartCycNum(wRelayId, 0U);/*ü̵Ч*/ + } + } + else + { + ; /*̵IDϷ*/ + } + + + return chRetValue; +} + +/******************************ⱨ****************************/ +/* +* ⱨ +* ˵ void +* ֵ void +* ɶⱨ2023.09.23 by LQ +*/ +void SGBJDriveOutputProc(void) +{ + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 wSGBJCurSum = 0U; /*ⱨ*/ + UINT16 wSGBJId = 0U; /*ⱨID*/ + UINT16 wSGBJRelRelayId = 0U; /*ⱨ̵ID1*/ + UINT16 wSGBJRelRelayId_2 = 0U; /*ⱨ̵ID2*/ + UINT16 wSGBJRelRouteNum = 0U; /*ⱨ·*/ + UINT16 wSGBJRelRouteId = 0U; /*ⱨ·ID*/ + UINT16* pSGBJRelRouteIdBuf = NULL; /*ⱨ·ṹ*/ + UINT8 cRouteState = 0U; /*ⱨ·״̬*/ + UINT8 cLocalCiId = 0U; /*ID*/ + UINT8 cSGBJBlongCiId = 0U; /*ⱨID*/ + UINT8 cRouteDrvSGBJFlag = ROUTE_DRIVE_SGBJ_INVALID; /*·ⱨ־*/ + UINT8 cSGBJNeedDriveFlag = FLAG_UNSET; /*ⱨ豻־*/ + + wSGBJCurSum = GetSGBJCurSum(); /*ȡspksĬΪÿspksжӦָʾ*/ + cLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + for (ii = 0U; ii < wSGBJCurSum; ii++) + { + cSGBJNeedDriveFlag = FLAG_UNSET; /*ÿһһα־*/ + wSGBJId = GetSGBJIdByIndex(ii); + cSGBJBlongCiId = GetSGBJBelongCiId(wSGBJId); + wSGBJRelRelayId = GetSGBJRelayId(wSGBJId); + wSGBJRelRelayId_2 = GetSGBJRelayId_2(wSGBJId); + + if ((0U != cLocalCiId) && (cLocalCiId == cSGBJBlongCiId) + && (0U != wSGBJRelRelayId) && (RELAY_SUM_MAX != wSGBJRelRelayId) + && (0U != wSGBJRelRelayId_2) && (RELAY_SUM_MAX != wSGBJRelRelayId_2)) + { + /*ڵⱨ*/ + wSGBJRelRouteNum = GetSGBJRelRouteNum(wSGBJId); + pSGBJRelRouteIdBuf = GetSGBJRelRouteIdBuf(wSGBJId); + + /*й·ȷǷڽ·ⱨ*/ + for (jj = 0U; jj < wSGBJRelRouteNum; jj++) + { + wSGBJRelRouteId = pSGBJRelRouteIdBuf[jj]; + cRouteState = GetRouteState(wSGBJRelRouteId); + + if ((ROUTE_STATE_FIRST_LOCK == cRouteState) || (ROUTE_STATE_FIRST_LOCKERR == cRouteState) + || (ROUTE_STATE_YUXIAN_LOCK == cRouteState) || (ROUTE_STATE_YUXIAN_OPEN == cRouteState) + || (ROUTE_STATE_NEAR_LOCK == cRouteState) || (ROUTE_STATE_NEAR_LOCKERR == cRouteState) || (ROUTE_STATE_NEAR_OPEN == cRouteState) + || (ROUTE_STATE_LEAD_LOCK == cRouteState) || (ROUTE_STATE_LEAD_LOCKERR == cRouteState) || (ROUTE_STATE_LEAD_OPEN == cRouteState) + || (ROUTE_STATE_AUTO_UNLOCK == cRouteState) || (ROUTE_STATE_AUTO_UNLOCKERR == cRouteState) || (ROUTE_STATE_DELAY_UNLOCK == cRouteState)) + { + /*·չδУ·ǷҪⱨ*/ + RouteNeedDriveSGBJCheck(wSGBJRelRouteId); /*У·ǷҪⱨ*/ + cRouteDrvSGBJFlag = GetRouteDriveSGBJFlag(wSGBJRelRouteId); + + if (ROUTE_DRIVE_SGBJ_VALID == cRouteDrvSGBJFlag) + { + cSGBJNeedDriveFlag = FLAG_SET; /*ڽ·ⱨֹͣ*/ + break; + } + else + { + /**/ + } + } + else + { + cSGBJNeedDriveFlag = FLAG_UNSET; /*·δջڽУⱨ*/ + } + } + + if (FLAG_SET == cSGBJNeedDriveFlag) + { + (void)SetRelayDriveState(wSGBJRelRelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(wSGBJRelRelayId_2, RELAY_DRIVE_STATE_UP); + } + else + { + (void)SetRelayDriveState(wSGBJRelRelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(wSGBJRelRelayId_2, RELAY_DRIVE_STATE_DOWN); + } + } + else + { + /*DZⱨ̵*/ + } + } +} + + +/* +* ü̵ʼ +* ˵ const UINT16 relayId ̵ID +* ֵ +* by cgh 20230930 +*/ +void SetRelayDriveStartCyc(const UINT16 wRelayId) +{ + UINT8 chRelayColleState = 0U;/*̵ɼ״̬*/ + UINT8 chrelayDriveState = 0U;/*̵״̬*/ + UINT32 dwCurCycNum = 0U;/*ϵͳǰ*/ + UINT32 dwRelayCycNum = 0U;/*̵ʼ*/ + + if ((0U != wRelayId) && (RELAY_SUM_MAX != wRelayId)) + { + dwCurCycNum = Get2oo2CurCycleNum(); + /*ȡ̵״̬*/ + chRelayColleState = GetRelayCollState(wRelayId); /*ɼ״̬*/ + chrelayDriveState = GetRelayDriveState(wRelayId); /*״̬*/ + + /**/ + if (RELAY_DRIVE_STATE_UP == chrelayDriveState) + { + /*ɼ*/ + if (RELAY_STATE_DOWN == chRelayColleState) + { + dwRelayCycNum = GetRelayDriveStartCycNum(wRelayId); + if (0U == dwRelayCycNum) + { + SetRelayDriveStartCycNum(wRelayId, dwCurCycNum);/*ü̵Ч*/ + } + else + { + ;/*Чı*/ + } + } + else + { + SetRelayDriveStartCycNum(wRelayId, 0U);/*ü̵Ч*/ + } + } + else if ((RELAY_DRIVE_STATE_DOWN == chrelayDriveState) || (RELAY_DRIVE_STATE_NULL == chrelayDriveState)) + { + /*ɼ*/ + if (RELAY_STATE_UP == chRelayColleState) + { + dwRelayCycNum = GetRelayDriveStartCycNum(wRelayId); + if (0U == dwRelayCycNum) + { + SetRelayDriveStartCycNum(wRelayId, dwCurCycNum);/*ü̵Ч*/ + } + else + { + ;/*Чı*/ + } + + } + else + { + SetRelayDriveStartCycNum(wRelayId, 0U);/*ü̵Ч*/ + } + } + else + { + SetRelayDriveStartCycNum(wRelayId, 0U);/*ü̵Ч*/ + } + } + else + { + ; /*̵IDϷ*/ + } +} + +/* +* еλ +* ˵ UINT16 switchCurSum +* ֵ +*/ +void SetAllSingleSwitchCurPosition(UINT16 switchCurSum) +{ + UINT8 localCiId = 0U; /*ID*/ + UINT16 switchId = 0U; /*ID*/ + UINT8 belongCiId = 0U; /*ID*/ + UINT16 ii = 0U; /*ѭ*/ + UINT8 chSwitchColPos = SWITCH_POSITION_INVALID; /*ǰλ*/ + UINT8 chSwitchTolPos = SWITCH_POSITION_INVALID; /*̺λ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + for (ii = 0U; ii < switchCurSum; ii++) + { + switchId = 0U; /*ID*/ + belongCiId = 0U; /*ID*/ + + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0U != switchId) && (SWITCH_SUM_MAX > switchId)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId == localCiId) && (0U != localCiId)) + { + chSwitchColPos = GetOcSwitchState(switchId); + SetSwitchCollPos(switchId, chSwitchColPos); + chSwitchTolPos = GetSwitchCollToleratePos(switchId); + SetSingleSwitchCurPosition(switchId, chSwitchTolPos);/*õλ*/ + } + } + } +} + +/* +* õǰ߼λ +* ˵ UINT16 switchCurSum +* ֵ +*/ +void UpdataSwitchCurPostion(UINT16 switchCurSum) +{ + UINT8 localCiId = 0U; /*ID*/ + UINT16 switchId = 0U; /*ID*/ + UINT8 singleSwitchPos = 0U; /*λ*/ + UINT8 belongCiId = 0U; /*ID*/ + UINT16 ii = 0U; /*ѭ*/ + UINT16 switch2ndId = 0U; + UINT8 singleSwitch2ndPos = 0U; /*˫λ*/ + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + for (ii = 0U; ii < switchCurSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + if ((0U != switchId) && (SWITCH_SUM_MAX > switchId)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + if ((belongCiId == localCiId) && (0U != localCiId)) + { + switch2ndId = GetDSwitchOtherId(switchId); + singleSwitchPos = GetSingleSwitchCurPosition(switchId); + if (0U == switch2ndId) + {/*λþʹǰλ*/ + SetSwitchCurPosition(switchId, singleSwitchPos); + } + else + {/*˫Ҫλö㣬ȷλãһĿ*/ + singleSwitch2ndPos = GetSingleSwitchCurPosition(switch2ndId); + switch (singleSwitchPos) + { + case SWITCH_POSITION_DINGWEI: /*ǰλ*/ + if (SWITCH_POSITION_DINGWEI == singleSwitch2ndPos) + {/*һ˫ǰλ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_DINGWEI); /*λõ߼λΪλ*/ + } + else if (SWITCH_POSITION_MOVE == singleSwitch2ndPos) + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_MOVE); + } + else if (SWITCH_POSITION_JICHA == singleSwitch2ndPos) + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_JICHA); + } + else + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + } + break; + case SWITCH_POSITION_FANWEI: /*ǰλ*/ + if (SWITCH_POSITION_FANWEI == singleSwitch2ndPos) + {/*һ˫ǰλ*/ + SetSwitchCurPosition(switchId, SWITCH_POSITION_FANWEI); /*λõ߼λΪλ*/ + } + else if (SWITCH_POSITION_MOVE == singleSwitch2ndPos) + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_MOVE); + } + else if (SWITCH_POSITION_JICHA == singleSwitch2ndPos) + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_JICHA); + } + else + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + } + break; + case SWITCH_POSITION_MOVE: /*ǰƶ*/ + if ((SWITCH_POSITION_DINGWEI == singleSwitch2ndPos) || (SWITCH_POSITION_FANWEI == singleSwitch2ndPos) || (SWITCH_POSITION_MOVE == singleSwitch2ndPos)) + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_MOVE); + } + else if (SWITCH_POSITION_JICHA == singleSwitch2ndPos) + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_JICHA); + } + else + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + } + break; + case SWITCH_POSITION_SIKAI: /*ǰĿ*/ + if (SWITCH_POSITION_JICHA == singleSwitch2ndPos) + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_JICHA); + } + else + { + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + } + break; + case SWITCH_POSITION_JICHA: + SetSwitchCurPosition(switchId, SWITCH_POSITION_JICHA); + break; + default: + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + break; + } + } + } + } + } +} + +/* +* ݵǰ߼λѡ +* ˵ UINT16 switchCurSum +* ֵ +*/ +void ClearSwitchMessageByCurPostion(UINT16 switchCurSum) +{ + UINT8 localCiId = 0U; /*ID*/ + UINT16 switchId = 0U; /*ID*/ + UINT8 belongCiId = 0U; /*ID*/ + UINT16 ii = 0U; /*ѭ*/ + UINT8 curSwitchPos = SWITCH_POSITION_INVALID; /*ǰλ*/ + UINT8 drvSwitchPos = SWITCH_DRIVE_POS_INVALID; /*ǰλ*/ + UINT8 SwitchDanCaoPos = SWITCH_POSITION_INVALID; /*λ*/ + + UINT8 timeState = CI_TIME_NO; /*ʱ״̬*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + for (ii = 0U; ii < switchCurSum; ii++) + { + switchId = 0U; /*ID*/ + belongCiId = 0U; /*ID*/ + + switchId = GetSwitchId(ii); /*ȡID*/ + if ((0U != switchId) && (SWITCH_SUM_MAX > switchId)) + { + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + if ((belongCiId == localCiId) && (0U != localCiId)) + { + /*ʱǷѾʱ*/ + timeState = SystemOverTimeCheck(GetSwitchDriveStartCycNum(switchId), GetSystemParaSwitchDriveCyc()); + + if (CI_TIME_OUT == timeState) + {/*ʱ䳬ʱ*/ + + /*õǰλ*/ + drvSwitchPos = GetSwitchDrivePostion(switchId); + + /*ȡλ*/ + SwitchDanCaoPos = GetSwitchDanCaoPostition(switchId); + + if (((SWITCH_DRIVE_POS_DINGWEI == drvSwitchPos) && (SWITCH_POSITION_DINGWEI == SwitchDanCaoPos)) || + ((SWITCH_DRIVE_POS_FANWEI == drvSwitchPos) && (SWITCH_POSITION_FANWEI == SwitchDanCaoPos))) + { + /*Чλ*/ + (void)SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + } + + /*õʱλ*/ + SetSwitchDrivOvtmDrvPosition(switchId, drvSwitchPos); + SetSwitchPreExpDrvPosition(switchId, SWITCH_DRIVE_POS_INVALID);/*֮ǰλ*/ + SetSwitchDrivePostion(switchId, SWITCH_DRIVE_POS_INVALID);/*ʵλ*/ + } + + /*һδΪ˼鵥ٵǷλ*/ + + /*ٴλȡλ*/ + SwitchDanCaoPos = GetSwitchDanCaoPostition(switchId); + + /*ȡǰλ*/ + curSwitchPos = GetSwitchCurPosition(switchId); + + if ((SwitchDanCaoPos == curSwitchPos) && (SWITCH_POSITION_INVALID != SwitchDanCaoPos)) + {/*λ*/ + /*Чλ*/ + (void)SetSwitchDanCaoPosition(switchId, SWITCH_POSITION_INVALID); + } + } + } + } +} + +/* +* ϴģʽ̵״̬ +* ˵ const UINT16 washMachineId ϴID +* ֵ 0u: ʧ +* 1: ³ɹ +* by cgh 20231108 +*/ +UINT8 WashMachineWorkModeRelayProc(const UINT16 washMachineId) +{ + UINT8 chReval = CI_ERROR; + UINT8 chWashMachineWorkModeDrvState = WASHMACHINE_WORKMODE_INVALID_DRV;/*ϴģʽ״̬*/ + UINT16 washWorkModeBackRelayId = 0U;/*ϴģʽɼ̵*/ + UINT16 washWorkModeRelayId = 0U;/*ϴģʽ̵*/ + UINT8 chwashModeRelayColl = 0U;/*ϴģʽ̵ɼ״̬*/ + UINT32 dwRelayDriveStartCyc = 0U;/*̵ʼ*/ + UINT8 chRelayDriveOutTiomeCheck = 0U;/*̵ʱ*/ + + if ((0U < washMachineId) && (WASHMACHINE_SUM_MAX > washMachineId)) + { + /*ȽϴģʽΪĬ*/ + SetWashWorkModeBackState(washMachineId, WASH_WORKMODE_BACK_DEFAULT); + washWorkModeBackRelayId = GetWashModeBackRelayId(washMachineId); + washWorkModeRelayId = GetWashModeRelayId(washMachineId); + + if ((0U != washWorkModeBackRelayId) && (0U != washWorkModeRelayId)) + { + chWashMachineWorkModeDrvState = GetWashMachineWorkModeDrvState(washMachineId); + chwashModeRelayColl = GetRelayCollState(washWorkModeBackRelayId); + + if (WASHMACHINE_WORKMODE_ALL_DRV == chWashMachineWorkModeDrvState) + { + /*ȫϴϴģʽ̵*/ + chReval = SetRelayDriveState(washWorkModeRelayId, RELAY_DRIVE_STATE_UP); + if (RELAY_STATE_UP == chwashModeRelayColl) + { + /*ǰɼ״̬һ£Ӧģʽóɹ*/ + SetWashWorkModeBackState(washMachineId,WASH_WORKMODE_BACK_ALL_OK); + } + else + { + ; /*״̬*/ + } + /*ɼһ£ڴ˺õںΪ0Ч*/ + SetWorkModeRelayDriveStartCyc(washMachineId); + } + else if (WASHMACHINE_WORKMODE_SIDE_DRV == chWashMachineWorkModeDrvState) + { + /*ϴϴģʽ̵*/ + chReval = SetRelayDriveState(washWorkModeRelayId, RELAY_DRIVE_STATE_DOWN); + if (RELAY_STATE_DOWN == chwashModeRelayColl) + { + /*ǰɼ״̬һ£Ӧģʽóɹ*/ + SetWashWorkModeBackState(washMachineId, WASH_WORKMODE_BACK_SIDE_OK); + } + else + { + ; /*״̬*/ + } + /*ɼһ£ڴ˺õںΪ0Ч*/ + SetWorkModeRelayDriveStartCyc(washMachineId); + } + else if (WASHMACHINE_WORKMODE_DEFAULT_DRV == chWashMachineWorkModeDrvState) + { + /*Ĭϴģʽ̵Ϊǰɼ״̬*/ + chReval = SetRelayDriveState(washWorkModeRelayId, chwashModeRelayColl); + /*Ҫгʱжϣһں0*/ + SetWashWorkModeRelayDrvCycle(washMachineId, 0U); + } + else + { + /*ϴЧCIתڲĬ״̬͵ƽЧ*/ + chReval = SetRelayDriveState(washWorkModeRelayId, RELAY_DRIVE_STATE_DOWN); + /*Ҫгʱжϣһں0*/ + SetWashWorkModeRelayDrvCycle(washMachineId, 0U); + } + + dwRelayDriveStartCyc = GetWashWorkModeRelayDrvCycle(washMachineId); + /*ϴģʽ̵Ƿʱ*/ + chRelayDriveOutTiomeCheck = SystemOverTimeCheck(dwRelayDriveStartCyc,RELAY_DRIVE_MAX_NUM); + if ((CI_TIME_NO == chRelayDriveOutTiomeCheck) || (CI_TIME_IN == chRelayDriveOutTiomeCheck)) + { + /*δʱ˵ǰѾɼһ£ӦģʽѾùﲻظ*/ + /*ʱУ˵ǰɼʱһ£öӦģʽΪOXOO*/ + } + else + { + /*ʱҪöӦģʽʧܷ*/ + if (WASHMACHINE_WORKMODE_ALL_DRV == chWashMachineWorkModeDrvState) + { + SetWashWorkModeBackState(washMachineId, WASH_WORKMODE_BACK_ALL_NO); + } + else if (WASHMACHINE_WORKMODE_SIDE_DRV == chWashMachineWorkModeDrvState) + { + SetWashWorkModeBackState(washMachineId, WASH_WORKMODE_BACK_SIDE_NO); + } + else + { + ; /*ģʽʧ*/ + } + } + } + else + { + /*ûм̵ִУϴģʽΪ0X00*/ + chReval = CI_SUCCESS; + } + } + else + { + ; /*ʧ*/ + } + + return chReval; +} + +/* +* ½ģʽϴ̵״̬ +* ˵ const UINT16 washMachineId ϴID +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ³ɹ +* by cgh 20231113 +*/ +UINT8 DownWashDevToRelayStaProc(const UINT16 washMachineId) +{ + UINT8 chReval = CI_ERROR; + UINT16 wDownWashAllowLightRelayId = 0U;/*ϴָͬʾƼ̵ID*/ + UINT8 chDownWashAllowState = 0U;/*ϴͬ״̬*/ + UINT16 wDownWashRelateRouteId = 0U;/*ģʽϴ߿̨ʾƹ·ID*/ + UINT8 chDownWashRelRoute1CheckType = 0U;/*ģʽϴ߿̨ʾƹ·״̬*/ + UINT16 wDownWashControlLightRelayId = 0U;/*ģʽϴ߿̨ʾƼ̵ID*/ + UINT8 chDownWashRelRouteCheckResult = 0U;/*ģʽ·״̬*/ + + if ((0U < washMachineId) && (WASHMACHINE_SUM_MAX > washMachineId)) + { + chReval = CI_SUCCESS; + + wDownWashAllowLightRelayId = GetDownWashAllowLightRelayId(washMachineId); + + if (0U != wDownWashAllowLightRelayId) + { + chDownWashAllowState = GetDownWashAllowState(washMachineId); + if (WASH_COL_STATE_ALLOW_YES == chDownWashAllowState) + { + /*ģʽϴͬⰴť£ϴָͬʾƼ̵*/ + chReval = SetRelayDriveState(wDownWashAllowLightRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /*ģʽϴͬⰴť£ϴָͬʾƼ̵*/ + chReval = SetRelayDriveState(wDownWashAllowLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + else + { + ; /*޼̵*/ + } + + if (CI_SUCCESS == chReval) + { + /*ģʽϴ߿̨ʾ1̵*/ + wDownWashControlLightRelayId = GetDownWashRelRoute1LightRelay(washMachineId); + + if (0U != wDownWashControlLightRelayId) + { + wDownWashRelateRouteId = GetDownWashRelateRoute1Id(washMachineId); + chDownWashRelRoute1CheckType = GetDownWashRelRoute1CheckType(washMachineId); + chDownWashRelRouteCheckResult = DownWashRelRouteStateCheck(wDownWashRelateRouteId, chDownWashRelRoute1CheckType); + + if (CI_SUCCESS == chDownWashRelRouteCheckResult) + { + /*ģʽϴ߿̨ʾ1·ͼָͨʾƼ̵*/ + chReval = SetRelayDriveState(wDownWashControlLightRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + chReval = SetRelayDriveState(wDownWashControlLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + else + { + ; /*޼̵*/ + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == chReval) + { + /*ģʽϴ߿̨ʾ2̵*/ + wDownWashControlLightRelayId = GetDownWashRelRoute2LightRelay(washMachineId); + + if (0U != wDownWashControlLightRelayId) + { + wDownWashRelateRouteId = GetDownWashRelateRoute2Id(washMachineId); + chDownWashRelRoute1CheckType = GetDownWashRelRoute2CheckType(washMachineId); + chDownWashRelRouteCheckResult = DownWashRelRouteStateCheck(wDownWashRelateRouteId, chDownWashRelRoute1CheckType); + + if (CI_SUCCESS == chDownWashRelRouteCheckResult) + { + /*ģʽϴ߿̨ʾ1·ͼָͨʾƼ̵*/ + chReval = SetRelayDriveState(wDownWashControlLightRelayId, RELAY_DRIVE_STATE_UP); + } + else + { + chReval = SetRelayDriveState(wDownWashControlLightRelayId, RELAY_DRIVE_STATE_DOWN); + } + } + else + { + ; /*޼̵*/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + return chReval; +} + +/* +* ģʽϴ߹·״̬ +* ˵ const UINT16 wRouteId ·ID +* const UINT8 chCheckType · +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ³ɹ +* by cgh 20231113 +*/ +UINT8 DownWashRelRouteStateCheck(const UINT16 wRouteId,const UINT8 chCheckType) +{ + UINT8 chReval = CI_ERROR; + UINT8 chRouteState = 0U;/*·״̬*/ + UINT8 chRouteType = 0U;/*·*/ + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + chRouteType = GetRouteType(wRouteId); + if (ROUTE_TYPE_DIAOCHE == chRouteType) + { + chRouteState = GetRouteState(wRouteId); + + if ((WASH_REL_ROUTE_OPEN_STATE == chCheckType) && + ((ROUTE_STATE_YUXIAN_OPEN == chRouteState) || (ROUTE_STATE_NEAR_OPEN == chRouteState))) + { + /*Ϊ·״̬ҵǰ·״̬ΪԤȿšӽţͨ*/ + chReval = CI_SUCCESS; + } + else if (WASH_REL_ROUTE_LOCK_STATE == chCheckType) + { + if ((ROUTE_STATE_IDLE == chRouteState) || (ROUTE_STATE_FIRST_XUANPAI == chRouteState) + || (ROUTE_STATE_XUANPAI == chRouteState)) + { + /*·״̬Ϊ· || ·ѡ || ·ѡ ˵·δգ鲻ͨ*/ + + } + else + { + /*·״̬Ϊգͨ*/ + chReval = CI_SUCCESS; + } + } + else + { + ; /*·ͷǷʧ*/ + } + + } + else + { + ;/*ǵ·ʧ*/ + } + } + else + { + ; /*ӿУ鲻ͨʧ*/ + } + + return chReval; +} + +/* +* ̵IDǷ״̬ +* ˵const UINT16 drvRelayId ̵ID +* const UINT16 collectRelayId ɼ̵ID +* ֵ 1ǻ״̬ +* 0״̬ +* +*/ +void ProcessCoupleRelayHunXianState(const UINT16 drvRelayId, const UINT16 collectRelayId) +{ + /*ʼ*/ + UINT8 relayColleState = 0u; + UINT8 relayDriveState = 0u; + UINT8 retValue = CI_ERROR; + UINT32 curCycNum = 0u; + UINT8 checkRelayRes = 0u; + UINT32 relayCycNum = 0u; + + curCycNum = Get2oo2CurCycleNum(); + + if ((0U < drvRelayId)&&(0U< collectRelayId)) + { + retValue = CI_SUCCESS; + /*ȡ̵״̬*/ + relayColleState = GetRelayCollState(collectRelayId); /*ɼ״̬*/ + relayDriveState = GetRelayDriveState(drvRelayId); /*״̬*/ + + /**/ + if ((RELAY_DRIVE_STATE_DOWN == relayDriveState) || (RELAY_DRIVE_STATE_NULL == relayDriveState)) + { + /**/ + if (RELAY_STATE_UP == relayColleState) + { + relayCycNum = GetRelayHunXianStarCycNum(drvRelayId); + checkRelayRes = SystemOverTimeCheck(relayCycNum, RELAY_HUNXIAN_NUM); + /*δʱ*/ + if (CI_TIME_NO == checkRelayRes) + { + SetRelayHunXianStarCycNum(drvRelayId, curCycNum);/*ü̵Ч*/ + } + /*ʱ*/ + else if (CI_TIME_OUT == checkRelayRes) + { + retValue = CI_ERROR; + } + else + { + /*ʱУسɹ*/ + } + } + else + { + SetRelayHunXianStarCycNum(drvRelayId, 0u);/*ü̵Ч*/ + } + } + /*߼*/ + else + { + SetRelayHunXianStarCycNum(drvRelayId, 0u);/*ü̵Ч*/ + } + + if (CI_ERROR == retValue) + { + /*ü̵״̬*/ + SetRelayHunXianState(drvRelayId, RELAY_HUNXIAN_STATE_YES); + } + else + { + /*ü̵δ״̬*/ + SetRelayHunXianState(drvRelayId, RELAY_HUNXIAN_STATE_NO); + } + } +} + +/* +* ϴģʽ̵ʼ +* ˵ const UINT16 washMachineId ϴID +* ֵ +* by cgh 20231208 +*/ +void SetWorkModeRelayDriveStartCyc(const UINT16 washMachineId) +{ + UINT8 chRelayColleState = 0U;/*̵ɼ״̬*/ + UINT8 chrelayDriveState = 0U;/*̵״̬*/ + UINT32 dwCurCycNum = 0U;/*ϵͳǰ*/ + UINT32 dwRelayCycNum = 0U;/*̵ʼ*/ + UINT16 washWorkModeBackRelayId = 0U;/*ϴģʽɼ̵*/ + UINT16 washWorkModeRelayId = 0U;/*ϴģʽ̵*/ + + if ((0U < washMachineId) && (WASHMACHINE_SUM_MAX > washMachineId)) + { + washWorkModeBackRelayId = GetWashModeBackRelayId(washMachineId); + washWorkModeRelayId = GetWashModeRelayId(washMachineId); + + if ((0U != washWorkModeBackRelayId) && (RELAY_SUM_MAX != washWorkModeBackRelayId) && (0U != washWorkModeRelayId) && (RELAY_SUM_MAX != washWorkModeRelayId)) + { + dwCurCycNum = Get2oo2CurCycleNum(); + /*ȡ̵״̬*/ + chRelayColleState = GetRelayCollState(washWorkModeBackRelayId); /*ɼ״̬*/ + chrelayDriveState = GetRelayDriveState(washWorkModeRelayId); /*״̬*/ + + /**/ + if (RELAY_DRIVE_STATE_UP == chrelayDriveState) + { + /*ɼ*/ + if (RELAY_STATE_DOWN == chRelayColleState) + { + dwRelayCycNum = GetWashWorkModeRelayDrvCycle(washMachineId); + if (0U == dwRelayCycNum) + { + SetWashWorkModeRelayDrvCycle(washMachineId, dwCurCycNum);/*ü̵Ч*/ + } + else + { + ;/*Чı*/ + } + } + else + { + SetWashWorkModeRelayDrvCycle(washMachineId, 0U);/*ü̵Ч*/ + } + } + else if ((RELAY_DRIVE_STATE_DOWN == chrelayDriveState) || (RELAY_DRIVE_STATE_NULL == chrelayDriveState)) + { + /*ɼ*/ + if (RELAY_STATE_UP == chRelayColleState) + { + dwRelayCycNum = GetWashWorkModeRelayDrvCycle(washMachineId); + if (0U == dwRelayCycNum) + { + SetWashWorkModeRelayDrvCycle(washMachineId, dwCurCycNum);/*ü̵Ч*/ + } + else + { + ;/*Чı*/ + } + + } + else + { + SetWashWorkModeRelayDrvCycle(washMachineId, 0U);/*ü̵Ч*/ + } + } + else + { + SetWashWorkModeRelayDrvCycle(washMachineId, 0U);/*ü̵Ч*/ + } + } + else + { + ; /*̵IDϷ*/ + } + } + else + { + ; /*ϴIDϷ*/ + } +} + +/* +* Ƶ״̬ +* ˵ const UINT16 wPsdId, ID +* ֵ +* by cgh 20231214 +*/ +void PsdVideoQkDriveStateProc(const UINT16 wPsdId) +{ + UINT8 chVideoQkDriveState = 0U;/*Ƶ״̬*/ + UINT16 wPsdVideoQkLight1RelayId = 0U;/*ͰťƵָʾ1̵̣*/ + UINT16 wPsdVideoQkLight2RelayId = 0U;/*ͰťƵָʾ2죩̵*/ + + if ((0U < wPsdId) && (PSD_SUM_MAX > wPsdId)) + { + chVideoQkDriveState = GePsdVideoQkDriveState(wPsdId); + wPsdVideoQkLight1RelayId = GetPsdVideoQkLight1RelayId(wPsdId); /*ͰťƵָʾ1̵̣*/ + wPsdVideoQkLight2RelayId = GetPsdVideoQkLight2RelayId(wPsdId); /*ͰťƵָʾ2죩̵*/ + + if ((0U != wPsdVideoQkLight1RelayId) && (UINT16_MAX != wPsdVideoQkLight1RelayId) + && (0U != wPsdVideoQkLight2RelayId) && (UINT16_MAX != wPsdVideoQkLight2RelayId)) + { + /*̵ò*/ + if (VIDEO_QK_DRIVE_STATE_NO == chVideoQkDriveState) + { + /*Ƶ״̬Ϊ---ɫ£*/ + (void)SetRelayDriveState(wPsdVideoQkLight1RelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(wPsdVideoQkLight2RelayId, RELAY_DRIVE_STATE_DOWN); + + } + else if (VIDEO_QK_DRIVE_STATE_HAVE == chVideoQkDriveState) + { + /*Ƶ״̬Ϊ---ɫº*/ + (void)SetRelayDriveState(wPsdVideoQkLight1RelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(wPsdVideoQkLight2RelayId, RELAY_DRIVE_STATE_UP); + + } + else if (VIDEO_QK_DRIVE_STATE_TESTING == chVideoQkDriveState) + { + /*Ƶ״̬Ϊ---ɫ*/ + (void)SetRelayDriveState(wPsdVideoQkLight1RelayId, RELAY_DRIVE_STATE_UP); + (void)SetRelayDriveState(wPsdVideoQkLight2RelayId, RELAY_DRIVE_STATE_UP); + } + else + { + /*Ƶ״̬ΪЧ---º£*/ + (void)SetRelayDriveState(wPsdVideoQkLight1RelayId, RELAY_DRIVE_STATE_DOWN); + (void)SetRelayDriveState(wPsdVideoQkLight2RelayId, RELAY_DRIVE_STATE_DOWN); + } + } + else + { + ; /*òϷ*/ + } + } + else + { + /*ηǷ*/ + } +} + +/* +* ɼ̴(Դ״̬ĵɼĿ3ڵ) +* ˵ const UINT16 switchId ID +* ֵ ̺λ +* Create: fan 20250317 +*/ +UINT8 GetSwitchCollToleratePos(const UINT16 switchId) +{ + UINT8 chSwitchColPos = 0u; + UINT8 chSwitch1CollTolerateState = CI_ERROR; /*ɷ̼*/ + UINT8 chSwitch2CollTolerateState = CI_ERROR;/*˫һ˿ɷ̼*/ + UINT32 curCycNum = 0u; + UINT32 switchCollTolerateCycNum = 0u; + UINT8 retPos = 0u; + UINT8 timeState = 0U; + UINT8 switchCurPosition = 0u; + UINT8 faultFlag = GetSwitchFaultState(switchId); /*ȡǷ忨*/ + UINT16 switch2ndId = GetDSwitchOtherId(switchId); /*˫*/ + UINT32 TolerateCycNum = 0U; /*־ӡʹ*/ + curCycNum = Get2oo2CurCycleNum(); + chSwitchColPos = GetSwitchCollPos(switchId); + + + switchCurPosition = GetSingleSwitchCurPosition(switchId); + if ((SWITCH_POSITION_DINGWEI == switchCurPosition) || (SWITCH_POSITION_FANWEI == switchCurPosition))/*ǰλλ*/ + { + if (SWITCH_POSITION_SIKAI == chSwitchColPos) + { + if (SWITCH_FAULT_STATE_NO == faultFlag) /*忨޹*/ + { + chSwitch1CollTolerateState = CheckSwitchCollTolerateState(switchId); + chSwitch2CollTolerateState = CheckSwitchCollTolerateState(switch2ndId); + if ((CI_SUCCESS == chSwitch1CollTolerateState) || (CI_SUCCESS == chSwitch2CollTolerateState)) + { /*||||ʱ||Ծ||*/ + switchCollTolerateCycNum = GetSwitchCollTolerateCycNum(switchId); + if (0u == switchCollTolerateCycNum) + { + SetSwitchCollTolerateCycNum(switchId, curCycNum); + } + else + { + /*޴*/ + } + } + else + { + /*㣬ֹͣ*/ + SetSwitchCollTolerateCycNum(switchId, 0u); + } + } + else + { + /*ֹͣ*/ + SetSwitchCollTolerateCycNum(switchId, 0u); + } + } + else + { + /*ɼ*/ + SetSwitchCollTolerateCycNum(switchId, 0u); + } + } + else + { + /*λã*/ + SetSwitchCollTolerateCycNum(switchId, 0u); + } + TolerateCycNum = GetSwitchCollTolerateCycNum(switchId); + debug_infor_printf((const)"\n SwitchCollTolerate Switch ID:%d, TolerateCycNumNum%d \n.", switchId, TolerateCycNum); + switchCollTolerateCycNum = GetSwitchCollTolerateCycNum(switchId); + timeState = SystemOverTimeCheck(switchCollTolerateCycNum, COLLTOLERATE_CYCNUM);/*2*/ + if (CI_TIME_NO == timeState) /*δʱ*/ + { + retPos = chSwitchColPos; + } + else if (CI_TIME_IN == timeState)/**/ + { + retPos = switchCurPosition; + } + else + { + retPos = chSwitchColPos;/*ʱ*/ + } + return retPos; +} + +/* +* Ƿ +* ˵ const UINT16 switchId ID +* ֵ CI_SUCCESSں CI_ERROR ҪĿ +* Create: fan 20250317 +*/ +UINT8 CheckSwitchCollTolerateState(UINT16 switchId) +{ + UINT8 chRet = CI_ERROR; + UINT16 switchPhySecId = 0u; /**/ + UINT8 phySecLockState = 0u; /*״̬*/ + UINT8 switchLockStatus = 0u; /*״̬*/ + UINT8 phySecJumpLockState = 0u; /*Ծ״̬*/ + if((0U != switchId) && (switchId < SWITCH_SUM_MAX)) + { + switchPhySecId = GetSwitchPhySectionId(switchId); + phySecLockState = GetPhySecLockState(switchPhySecId); + phySecJumpLockState = GetPhySecJumpLockState(switchPhySecId); + + switchLockStatus = GetSwitchLockStatus(switchId); + + + if ((PHYSICAL_SECTION_LOCK_NORMAL == phySecLockState) + || (PHYSICAL_SECTION_LOCK_PROTECT == phySecLockState) + || (PHYSICAL_SECTION_LOCK_DELAY == phySecLockState) + || (PHYSICAL_SECTION_JUMP_LOCK_YES == phySecJumpLockState) + || (SWITCH_LOCK_STATUS_PROTECT == switchLockStatus) + || (SWITCH_LOCK_STATUS_DAP == switchLockStatus) + ) + { /*||||ʱ||Ծ||*/ + chRet = CI_SUCCESS; + } + else + { + chRet = CI_ERROR; /**/ + } + } + else + { + chRet = CI_ERROR; + } + + return chRet; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/IO/DeviceRelayDataProcess.h b/TSCP/src/APP/ciapp/IO/DeviceRelayDataProcess.h new file mode 100644 index 0000000..8602f09 --- /dev/null +++ b/TSCP/src/APP/ciapp/IO/DeviceRelayDataProcess.h @@ -0,0 +1,860 @@ +/******************************************************** +* +* DeviceRelayDataProcess.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-09-21 +* ߣ +* 豸ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ +#ifndef _DEVICE_RELAY_DATA_PROCESS_H_ +#define _DEVICE_RELAY_DATA_PROCESS_H_ + +#include "../DataManage/DeviceDataManage.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Section/AxisSectionConfigDataManage.h" +#include "../Section/AxisSectionDataManage.h" +#include "../Section/LogicSectionConfigDataManage.h" +#include "../Section/LogicSectionDataManage.h" +#include "../psd/PSDConfigDataManage.h" +#include "../psd/PSDDataManage.h" +#include "../esb/ESBConfigDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../error/ErrorDataManage.h" +#include "../ParsePack/CiInterfaceDefine.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../ParsePack/ParsePackVobcData.h" +#include "../Route/RouteDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../Garagedoor/GaragedoorConfigDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" +#include "../WashMachine/WashMachineConfigDataManage.h" +#include "../WashMachine/WashMachineDataManage.h" +#include "../ParsePack/ParsePackOcData.h" +#include "ReverseCutDataManage.h" +#include "ReverseCutConfigDataManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + + + +/******************************źŻؼ̵****************************/ + +/* +* źŻ̵״̬->߼״̬ +* ˵ const UINT32 curCycleNum, ǰں +* ֵ 0: ʧ +* 1: ³ɹ +*/ +void SignalRelayToDeviceStateProc(void); + + +/* +* źŻ߼״̬->̵״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +void SignalDeviceToRelayStateProc(void); + + +/* +* źŻϢָIDźŻ̵ +* ˵ const UINT16 signalId +* ֵ 0:ʧ +* >0:óɹ +*/ +UINT8 SetSignalRelayState(const UINT16 signalId); + + +/* +* ݼ̵ɼݻȡָIDźŻĵǰʾɫ +* ˵ const UINT16 signalId +* ֵ 0: ȡ +* >0: ǰʾɫ +*/ +UINT8 GetSignalShowColor(const UINT16 signalId); + +/* +* źŻ˫ϵ忨ϣźŻǰɫ +* ˵ + UINT16 signalIdźŻid + UINT8 ocId OC ID +* ֵ źŻɫ +*/ +UINT8 GetOcBoardFaultSignalColor(UINT16 signalId, UINT8 ocId); + +/* +* źŻ£OCȫźŻɫ +* ˵ + UINT16 signalIdźŻid +* ֵ źŻɫ +*/ +UINT8 SetSignalColorOcAllOff(const UINT16 signalId); + +/******************************ؼ̵****************************/ + +/* +* µ߼״̬ +* ˵ const UINT32 curCycleNum, ǰں +* ֵ 0: ʧ +* 1: ³ɹ +*/ +void SwitchRelayToDeviceStateProc(void); +/* zt ɾش 2022-02-15 */ +/* +* µ̵״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +void SwitchDeviceToRelayStateProc(void); + + +/******************************ؼ̵****************************/ + +/* +* ռ״̬ +* ˵ const UINT32 curCycleNum, ǰں +* ֵ void +*/ +void PhySecRelayToDeviceStateProc(void); + +/* +* μḴλ̵״̬ +* ˵ void +* ֵ void +*/ +void PhySecResetToRelayStateProc(void); +/* +* μḴλ̵״̬ +* ˵ void +* ֵ void +*/ +void PhySecResetToRelayStateProc_Vir(UINT8 virCIid); +/* +* μḴλ̵״̬ +* ˵ void +* ֵ void +*/ +void UpDataAllPhySecResetRelay_VirCI(void); + +/******************************վ̨ؼ̵****************************/ + +/* +* ߼״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +void PsdRelayToDeviceStateProc(void); +#if 0 +/* +* ״̬תƴ +* ˵ void +* ֵ void +*/ +void PsdStateTransferProc(void); +#endif +/* +* ż̵״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 PsdDeviceToRelayStateProc(void); + +/* +* ϴ̵״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 WashMachineDevToRelayStaProc(void); + +/* +* ½ͣť߼״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 EsbRelayToDeviceStateProc(void); + +/* +* ³ŵ߼״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 GaragedoorRelayToDevStaProc(void); + +/* +* ³ŵ߼״̬(ÿš·̵) +* ˵ void +* ֵ 0u: ʧ +* 1: ³ɹ +*/ +UINT8 GDRelayToDeviceStateOnlyOpenPL(const UINT16 garagedoorId); + +/* +* ³ż̵״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +void GaragedoorDevToRelayStaProc(void); + +/* +* ϴ߼״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 WashMachineToDeviceStateProc(void); +/* +* Spksť߼״̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 SpksRelayToDeviceStateProc(void); +/* +* ݼ̵ɼݻȡָIDźŻʾɫ +* ˵ const UINT16 signalId +* ֵ 0: SIGNAL_SHOWCOLOUR_INVALID +* >0: ǰʾɫ +*/ +UINT8 GetRelayToDeviceSignalColor(const UINT16 signalId); +/* +* ݼ̵ɼݻȡָIDźŻʾɫ-ûDDJ⴦ +* ˵ const UINT16 signalId +* ֵ 0: SIGNAL_SHOWCOLOUR_INVALID +* >0: ǰʾɫ +*/ +UINT8 GetNoDDJSignalColor(const UINT16 signalId); + +/* +* ·ŵ豸߼״̬ +* ˵ void +* ֵ void +*/ +void FloodGateRelayToDeviceStateProc(void); + + +/* +* ·ż̵״̬ +* ˵ void +* ֵ +*/ +void FloodGateDeviceToRelayStateProc(void); + +/* +* ½·ĵͬ߼״̬ +* ˵ void +* ֵ void +*/ +void RouteDCTYRelayToDeviceStateProc(void); + +/* +* µ̵ͬ״̬ +* ˵ void +* ֵ +*/ +void RouteDCTYToRelayStateProc(void); + +/* +* ֻвɼгźż̵״̬źŻɫ +* ˵ const UINT16 signalId :źŻID +* ֵ +*/ +void SetNoDriveSignalCurColor(const UINT16 signalId); + +/* +* OCźŻ豸ɼ״̬->߼״̬ +* ˵ void +* ֵ void +* +*/ +void OcSignalDeviceInput(void); + +/* +* OC豸ɼ״̬->߼״̬ +* ˵ void +* ֵ void +*/ +void OcSwitchDeviceInput(void); + + +/* +* OCźŻ豸 +* ˵ void +* ֵ void +*/ +void OcSignalDeviceOutput(void); + +/* +* OC豸 +* ˵ void +* ֵ void +*/ +void OcSwitchDeviceOutput(void); + +/* +* ȡOCźŻ豸ɫ +* ˵ + UINT16 signalIdźŻid +* ֵ void +*/ +UINT8 GetOcSignalColor(UINT16 signalId); + +/* +* ȡOC豸ɫ +* ˵ + UINT16 signalIdźŻid +* ֵ void +*/ +UINT8 GetOcSwitchState(UINT16 switchId); + +/* +* ϶̽ӿڷʽ +* ˵ UINT16 startJXTCRelayId ̵ + UINT16 stopJXTCRelayId ̵ֹͣ + UINT16 psdId ID +* ֵ +*/ +void ProcessJXTCPulseInterfStartDrv (UINT16 startJXTCRelayId, UINT16 stopJXTCRelayId, UINT16 psdId); + +/* +* ϶̽ӿڷʽֹͣ +* ˵ UINT16 startJXTCRelayId ̵ + UINT16 stopJXTCRelayId ̵ֹͣ + UINT16 psdId ID +* ֵ +*/ +void ProcessJXTCPulseInterfStopDrv(UINT16 startJXTCRelayId, UINT16 stopJXTCRelayId, UINT16 psdId); + + +/******************************OC spksָʾ****************************/ +/* +* OC spksָʾƺspks·ָʾ +* ˵ void +* ֵ void +*/ +void SpksDisplayDrivOutput(void); + +/***********************OC SPKSŽ̵****************************/ +/* +* OC spksŽ +* ˵ void +* ֵ void +*/ +void SpksMenjinJSDrivOutput(void); + +/* +* OC ŽspksǷ񼤻߼ж +* ˵ void +* ֵ void +*/ +UINT8 MJrelSpksMJStateProcess(UINT16 spksId); + +/******************************OC esbָʾ****************************/ +/* +* OC esbָʾƺesb·ָʾ +* ˵ void +* ֵ void +*/ +void EsbDisplayDrivOutput(void); + + +/******************************OC ۳·ָʾ****************************/ +/* +* OC ۳Ϳ۳·ָʾ +* ˵ void +* ֵ void +*/ +void DetainDisplayDrivOutput(void); + +/* +* ȡԶ־Ƿִ +* ˵ const UINT16 routeId :·ID +* const UINT16 phySecId :ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +UINT8 CheckCancleAutoFlag(const UINT16 routeId,const UINT16 phySecId); + +/* +* 豸ɼ״̬߼״̬ +* ˵ void +* ֵ +* +*/ +void ConnectLineRelayToDevStateProc(void); + +/* +* ߵ̵״̬ +* ˵ const UINT16 devId 豸ID +* const UINT16 dbRelayId ̵ID +* const UINT16 fbRelayId ̵ID +* ֵ +* +*/ +void SetConnectSwitchPosRelayDrvSta(const UINT16 devId, const UINT16 dbRelayId, const UINT16 fbRelayId); + +/* +* 豸߼״̵̬״̬ +* ˵ void +* ֵ +* +*/ +void UpdateConnectDriveRelayOutput(void); + +/* +* Ƿ״̬ +* ˵ +* +* ֵ 1ǻ״̬ +* 0״̬ +* +*/ +UINT8 CheckRelayHunXiandState(const UINT16 relayId); + +/* +* ܸλʾ +* ˵ void +* ֵ void +*/ +void PhyZFWBsRelayDriveOutput(void); + +/* +* ۳ָʾơ۳·ָʾ +* ˵const UINT16 signalCutDetainRelayId, ۳·̵ID +* const UINT16 cutDetainDisplayId, ۳·ʾƼ̵ID +* const UINT16 signalDetainRelayId, ۳̵ID +* const UINT16 signalDetainDisplayId, ۳ʾƼ̵ID +* const UINT16 signalId, źŻID +* +* ֵ +* +*/ +void DriveDetainBsRelay(const UINT16 signalId, const UINT16 signalCutDetainRelayId, const UINT16 cutDetainDisplayId, const UINT16 signalDetainRelayId, const UINT16 signalDetainDisplayId); + + +/* +* µװ״̬ +* ˵ void +* ֵ +*/ +void RvrsCutRlyToDvicSttPrc(void); + +/* +* Ƿɵԭ +* ˵ void +* ֵ +*/ +void ReverseCutReasonProcess(void); + + +/* +* TIOCӰģʽ豸 +* ˵ void +* ֵ void +*/ +void TiocSysShadowDeviceOutputProc(void); + + +/* +* ϵռ䵽 +* ˵ void +* ֵ void +*/ +void ProcessPhyOCcStateToAxisSection(void); + +/* +* ȡESBǰҪõ״̬ +* ˵UINT16 esbId ESB ID +* +* ֵ ESB_STATE_VALID_YES״̬ΪЧ +* ESB_STATE_VALID_NO״̬ΪЧ +* CI_ERROR: ȡʧ +* cgh-ϲCID-2349-3 +*/ +UINT8 GetEsbCurNeedSetState(UINT16 esbId); +/* +* OC ESSPEPµơȵƺͷ̵ +* ˵ void +* ֵ void +* cgh-ϲCID-2349-3 +*/ +void EsbRelateDelayDriveOutputProc(void); + + +/* +* OC ESSPEPµơȵƺͷ̵״̬ +* ˵ UINT16 esbId ESB ID +* ֵ void +* cgh-ϲCID-2349-3 +*/ +void EsbRelateDelayDriveStateManage(UINT16 esbId); + +/* +* Ƿʱ +* ˵ const UINT16 relayId ̵ID +* +* ֵ 1ʱ״̬ +* 0ʱ +* cgh-ϲCID-2349-4 +*/ +UINT8 CheckRelayDriveOutTimeState(const UINT16 relayId); +/* +* Ƿʱ +* ˵ const UINT16 psdId ID +* const UINT8 psdDriveState psd״̬ +* ֵ 0xffʱ״̬ +* 0x55 δ +* 0xaa δ +* cgh-ϲCID-2349-4 +*/ +UINT8 CheckPsdDriveOutTimeState(const UINT16 psdId); + +/* +* ȡ̵Ƿɼһ +* ˵ const UINT16 relayId, ̵ID + const UINT8 foreNodeColl ǰ״̬ + const UINT8 backNodeColl ״̬ +* ֵ 0: ɼһ +* >0: һ +*cgh-ϲCID-2349-4 +*/ +UINT8 CheckRelayDriAndCollDiffSeat(const UINT16 relayId, const UINT8 foreNodeColl, const UINT8 backNodeColl); + +/* +* ȡPSDǷɼһ +* ˵ const UINT16 psdId, PSD ID +* ֵ 0xff: ޱ +* 0x55: ɼһ +* 0xaa: ɼһ +*cgh-ϲCID-2349-4 +*/ +UINT8 CheckPsdDriAndCollDiff(const UINT16 psdId); + + +/* +* Spksťָʾƴ +* ˵ UINT16 spksId ID +* ֵ void +*/ +void TotalSpksOutsideDisPlayProc(UINT16 spksId); + +/* +* SPKSָʾ +* ˵ UINT16 contrlspksId spksId ID +* UINT32 spksflockStartNum spksʼ +* ֵ void +*/ + +void SpksOutsideDisPlayDriv(UINT16 contrlspksId, UINT32 spksflockStartNum); + +/* +* жӲ۳Ƿִ +* ˵ const UINT16 detainCutRelayId ·̵ + const UINT16 signalDetainRelayId ۳̵ + +* ֵ CI_ERROR: ִ +* CI_SUCCESS: ִ +* +*/ +UINT8 CheakDeatainState(UINT16 detainCutRelayId, UINT16 signalDetainRelayId); + +/* +* ȡ߱ESBǰҪõ״̬ +* ˵UINT16 esbId ESB ID +* +* ֵ ESB_STATE_VALID_YES״̬ΪЧ +* ESB_STATE_VALID_NO״̬ΪЧ +* CI_ERROR: ȡʧ +* cgh-ϲCID-3037-1 +*/ +UINT8 GetVirEsbCurNeedSetState(UINT16 esbId); +/* +* ESB߼ +* ˵ +* ֵ void +* cgh-ϲCID-3037-1 +*/ +void VirtualEsbLogicProcess(void); +/* +* OC ESSPEPµơȵƺͷ̵״̬ +* ˵ UINT16 esbId ESB ID +* ֵ void +* עcgh-ϲCID-3037-1 +*/ +void VirEsbRelateDelayDriStaManage(UINT16 esbId); +/* +* ȡʾźŻɫ +* ˵ const UINT8 signalColor, źŻɫ +* ֵ 0x01 :0x02:ƣ0x04: +*cgh-ϲCID-3037-3 +*/ +UINT8 GetFushiSignalDriveColor(const UINT8 signalColor); + +/* +* վ̨ȷϰťȵƼ̵ +* ˵ const UINT16 psdId, ID +* ֵ +*cgh-ϲCID-3037-7 +*/ +void StationCearPassenagerProcess(const UINT16 psdId); + +/* +* ŶӦȷŰťָʾ߼״̬ +* ˵ const UINT16 wPsdId ID +* ֵ 0u: ʧ +* 1: ³ɹ +* * cgh޸ijɶ +*/ +UINT8 PsdCleFarePCBRelToDevStaProc(const UINT16 wPsdId); + +/* +* ŶӦȷ䷢ťָʾ߼״̬ +* ˵ const UINT16 wPsdId ID +* ֵ 0u: ʧ +* 1: ³ɹ +* cgh޸ijɶ +*/ +UINT8 PsdCleFarePDBRelToDevStaProc(const UINT16 wPsdId); + +/* +* ȷ䷢ťָʾƴ +* ˵ const UINT16 psdId, ID +* ֵ +*cgh޸ijɶ +*/ +void PsdCleFarePDBFlashProcess(const UINT16 psdId); + +/* +* Ըʽ۳ť +* ˵ const UINT16 signalId źŻID +* ֵ +*/ +void SignalZfsDetainBtnPro(const UINT16 signalId); + +/* +* Ըʽȡ۳ť +* ˵ const UINT16 signalId źŻID +* ֵ +*/ +void SignalZfsCancelDetainBtnPro(const UINT16 signalId); + +/* +* Ըʽȡ۳ť״̬ +* ˵ const UINT16 wSignalId źŻID +* const UINT16 wCancelDetBtnRelayId ȡ۳ťɼ̵ID +* ֵ +* Created By LQ 2024.05.09 +*/ +void DetZfsCancelBtnPressStateProc(const UINT16 wSignalId, const UINT16 wCancelDetBtnRelayId); + +/* +* Ըʽȡ۳ť־ +* ˵ const UINT16 wSignalId źŻID +* const UINT16 wCancelDetBtnRelayId ȡ۳ťɼ̵ID +* ֵ +* Created By LQ 2024.05.09 +*/ +void DetZfsCancelBtnActFlagProc(const UINT16 wSignalId, const UINT16 wCancelDetBtnRelayId); + +/* +* Ըʽ۳ָʾ +* ˵const UINT16 signalId, źŻID +* const UINT16 signalDetainDisplayId, ۳ʾƼ̵1ID +* ֵ +* +*/ +void DriveZfsDetainBsRelay(const UINT16 signalId, const UINT16 signalDetainDisplayId); + +/* +* Ըʽͣť +* ˵UINT16 esbId ESB ID +* ֵ +*/ +void EsbZfsBtnProc(UINT16 esbId); + +/* +* Ըʽȡͣť +* ˵UINT16 esbId ESB ID +* ֵ +*/ +void EsbZfsCancelBtnProc(UINT16 esbId); + +/* +* Ըʽͣťȡť״̬ +* ˵const UINT16 wEsbId ESB ID +* const UINT16 wCancelEsbRelayId ESBȡťɼ̵ID +* ֵ +* Created By LQ 2024.05.09 +*/ +void EsbZfsCancelBtnPressStateProc(const UINT16 wEsbId, const UINT16 wCancelEsbRelayId); + +/* +* ԸʽͣťȡťЧ־ +* ˵const UINT16 wEsbId ESB ID +* const UINT16 wCancelEsbRelayId ESBȡťɼ̵ID +* ֵ +* Created By LQ 2024.05.09 +*/ +void EsbZfsCancelBtnValidFlagProc(const UINT16 wEsbId, const UINT16 wCancelEsbRelayId); + +/* +* SPKS״̬߼SPKS״̬ +* ˵ +* ֵ +* by cgh 20230919 ߼η״̬ڸATSʾ +*/ +void SpksRelayToLogSecFlockStatus(void); + +/* +* ٿ/Űťָʾƴ +* ˵ const UINT16 psdId, ID +* ֵ +* ɶ132730󡪡2023.09.21 +*/ +void PsdOpenAndCloseBsdProc(const UINT16 psdId); + +/* +* ̵Ƿʱ-ʱʱ +* ˵ const UINT16 relayId ̵ID +* const UINT32 dwTimeOutCycCount ʱ +* ֵ 1ʱ״̬ +* 0ʱ +* by cgh 20230923 +*/ +UINT8 CheckRelayDriveOutTime(const UINT16 wRelayId, const UINT32 dwTimeOutCycCount); + +/* +* ⱨ +* ˵ void +* ֵ void +* ɶⱨ2023.09.23 by LQ +*/ +void SGBJDriveOutputProc(void); + +/* +* ü̵ʼ +* ˵ const UINT16 relayId ̵ID +* ֵ +* by cgh 20230930 +*/ +void SetRelayDriveStartCyc(const UINT16 wRelayId); + +/* +* еλ +* ˵ UINT16 switchCurSum +* ֵ +*/ +void SetAllSingleSwitchCurPosition(UINT16 switchCurSum); + +/* +* õǰ߼λ +* ˵ UINT16 switchCurSum +* ֵ +*/ +void UpdataSwitchCurPostion(UINT16 switchCurSum); + +/* +* ݵǰ߼λѡ +* ˵ UINT16 switchCurSum +* ֵ +*/ +void ClearSwitchMessageByCurPostion(UINT16 switchCurSum); + +/* +* ϴģʽ̵״̬ +* ˵ const UINT16 washMachineId ϴID +* ֵ 0u: ʧ +* 1: ³ɹ +* by cgh 20231108 +*/ +UINT8 WashMachineWorkModeRelayProc(const UINT16 washMachineId); + +/* +* ½ģʽϴ̵״̬ +* ˵ const UINT16 washMachineId ϴID +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ³ɹ +* by cgh 20231113 +*/ +UINT8 DownWashDevToRelayStaProc(const UINT16 washMachineId); + +/* +* ģʽϴ߹·״̬ +* ˵ const UINT16 wRouteId ·ID +* const UINT8 chCheckType · +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ³ɹ +* by cgh 20231113 +*/ +UINT8 DownWashRelRouteStateCheck(const UINT16 wRouteId, const UINT8 chCheckType); + +/* +* ̵IDǷ״̬ +* ˵const UINT16 drvRelayId ̵ID +* const UINT16 collectRelayId ɼ̵ID +* +*/ +void ProcessCoupleRelayHunXianState(const UINT16 drvRelayId, const UINT16 collectRelayId); + +/* +* ϴģʽ̵ʼ +* ˵ const UINT16 washMachineId ϴID +* ֵ +* by cgh 20231208 +*/ +void SetWorkModeRelayDriveStartCyc(const UINT16 washMachineId); + +/* +* Ƶ״̬ +* ˵ const UINT16 wPsdId, ID +* ֵ +* by cgh 20231214 +*/ +void PsdVideoQkDriveStateProc(const UINT16 wPsdId); + +/* +* ɼ̴(Դ״̬ĵɼĿ3ڵ) +* ˵ const UINT16 switchId ID +* ֵ ̺λ +* Create: fan 20250317 +*/ +UINT8 GetSwitchCollToleratePos(const UINT16 switchId); + +/* +* Ƿ +* ˵ const UINT16 switchId ID +* ֵ CI_SUCCESSں CI_ERROR ҪĿ +* Create: fan 20250317 +*/ +UINT8 CheckSwitchCollTolerateState(UINT16 switchId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/IO/InputDataProcess.c b/TSCP/src/APP/ciapp/IO/InputDataProcess.c new file mode 100644 index 0000000..f2f9167 --- /dev/null +++ b/TSCP/src/APP/ciapp/IO/InputDataProcess.c @@ -0,0 +1,12202 @@ +/******************************************************** +* +* InputDataProcess.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-07 +* ߣ +* ݴ +* ޸ļ¼ +* +********************************************************/ + + +#include "InputDataProcess.h" +#include "../HLHTMsgHead/HLHTHeadContexManage.h" +#include "../Initial/InitialProcess.h" +#include "../ParsePack/ParsePackPSCData.h" +#include "../ParsePack/ParsePackTmcData.h" +#include "../ParsePack/ParsePackVobcData.h" +#include "EnvelopeManageAPI.h" +#include "OutputDataProcess.h" +#include "RRMManageAPI.h" +#include "WLBrakeDataManage.h" +#include "NonAutoReturnDataManage.h" +#include "../IO/DeviceRelayDataProcess.h" +#include "MSCP_APP_API.h" + +extern PlatformToCiDataStruct platformToCiDataStru[PLATFORM_TO_CI_SUM_MAX]; /*վ̨CIͨݽṹ*/ +extern unsigned long TimeStamp = 0u; + +/* +* ͨVOBC +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void HLHTVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* FAOVOBC +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void FAOVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* Źرؿź +* ˵ const UINT16 routeId,ҪؿźŵĽ· + const UINT16 psdID½·ؿźŵPSD +* ֵ void +*/ +static void PsdOpenSignal(const UINT16 routeId, const UINT16 psdId); + +/* +* +* ˵ void +* ֵ void +*/ +static void ProcessPsdData(void); + +/* +* ͸źؿ +* ˵ const UINT16 signalId źŻID +* UINT8* toCiId ĿID +* ֵ CI_SUCCESS: ͨ +* CI_ERROR: ʧ +*/ +static UINT8 RouteReturnToThroughCondCheck(const UINT16 signalId,UINT8* toCiId); + +/* +* źؿ +* ˵ const UINT16 signalId źŻID +* const UINT8 fromCiId ԴID +* ֵ CI_SUCCESS: ɹ +* CI_ERROR: ʧ +*/ +static UINT8 RouteReturnToThroughCmdProc(const UINT16 signalId,const UINT8 fromCiId); + +/* +* Գ +* ˵ const UINT16 devId豸ID +* const UINT8 CMDType: +* ֵ CI_SUCCESS: ɹ +* CI_ERROR: ʧ +* cgh-ϲCID-2341-6 +*/ +static UINT8 VirtualDevCmdProc(const UINT16 devId,const UINT8 CMDType); + +/* +* УԳ豸 +* ˵ const UINT16 devId豸ID +* const UINT8 CMDType: +* ֵ CI_SUCCESS: Уɹ +* CI_ERROR: Уʧ +* cgh-ϲCID-2341-6cgh-ϲCID-2539-2 +*/ +static UINT8 VirtualDevCmdCiIdCheck(const UINT16 devId, const UINT8 CMDType); + +/* +* óԳ豸̬ +* ˵ +* ֵ void +*/ +static void ResetTrainTestDevState(const UINT8 ciId); + +/* +* ͨʱͨı +* ˵ +* ֵ void +*/ +static void ClearSignalOvlpCmdHlht(void); + +/* +* ӿ +* ˵ +* ֵ void +*/ +static void ProcessTctCiCmd(void); + +/* +* ͨӿ +* ˵ +* ֵ void +*/ +static void ProcessHlhtCiCmd(void); + +/* +* ûͨ豸״̬ +* ˵UINT8 const ciId,ͨCI +* ֵ void +*/ +static void ResetCiDevStateHlht(UINT8 const ciId); + +/* +* HLHT+FAOVOBC +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void HLHTFAOVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru); +/* +* VOBCͣϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void StopSteadyDataProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* VOBC֤ͣϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void StopensureDataProc(VobcToCiDataStruct* vobcToCiDataStru); + + +/* +* VOBCȡԴϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void ResourceCancelDataProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* IVOC +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void IvocInputDataProcCC(VobcToCiDataStruct* pstIvocToCiData); + + +/* +* ˢг +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* qw.liu 2022-02-26 +*/ +static void IvocInputRefreshTrain(const VobcToCiDataStruct stIvocToCiData); + +/* +* г +* ˵ vobcToCiDataStruVOBCݽṹ +* ֵ void +* qw.liu 2022-02-26 +*/ +static void IvocInputCmdProc(const VobcToCiDataStruct stIvocToCiData); + +/* +* @func гʧͨ +* @param vobcToCiDataStruVOBCݽṹ +* @retrun void +* @create qw.liu 2022-08-13 +*/ +static void ProcessIvocLoseCom(const VobcToCiDataStruct stIvocToCiData); + +/* +* IVOC۷ʼֵ +* ˵ trainIdгID +* ֵ +*/ +static void IvocNonAutoRtnProcess(const UINT16 trainId); + +/* +* IVOCŹرȷϴ +* ˵vobcToCiDataStruVOBCݽṹָ +* ֵ void +* BY LC +*/ +static void IvocFloodGateCloseProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* VobcгӿϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20240614 +*/ +static void VobcConnectDataProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* VobcгϢ +* ˵ UINT16 wTrainIdVOBCid +* ֵ void +* by cgh 20240614 +*/ +static void VobcConnectDataClear(const UINT16 wTrainId); + +/* +* Vobc󱸽ӿϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20240710 +*/ +static void VobcBackUpConnectDataProc(VobcBackUpToCiDataStruct* vobcToCiDataStru); + +/* +* VOBCͣϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* fan 20240815 +*/ +static void BackupStopSteadyDataProc(VobcBackUpToCiDataStruct* vobcToCiDataStru); +/* +* +* ˵ void +* ֵ void +*/ +void InputDataProcess(void) +{ + UINT8 localCiType = GetLocalCiType(); + UINT8 localCiPattern = GetLocalCiPattern(); + UINT8 chSwitch = 0u; + UINT8 cRcWorkMode = 0U; + + signed long long cost[20] = {0U}; + chSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH); + cRcWorkMode = GetLocalRcWorkMode(); + + cost[0] = MSCP_GetTick(); +#if (kPLATFORM==kVXWORKS) + (void)ProcessPlatformNetData(); +#endif + if (CI_PATTERN_TRADITIONAL == localCiPattern) + { + /*IO*/ + (void)ProcessIoToCiData(); + } + else if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern)/*ȫ*/ + { + /*OC*/ + (void)ProcessOcToCiRelayData(); + debug_infor_printf((const)"\nprocess oc_relay end\n"); + } + else + { + /**/ + } + +#ifdef PLATFORM_2OO2 + + if (CI_PATTERN_TRADITIONAL== localCiPattern) + {/*ͳ*/ + /*IOCI֡*/ + ResetIoToCiData(); + } + else + {/*ȫ*/ + /*OCCI*/ + ProcessOcToCiData(); + } + +#endif + cost[1] = MSCP_GetTick(); + /*ᵽCI*/ + ProcessAxleToCiData(); + +#if 0 + /*ͣϢΪδͣ,ֹùUTռѹͣϢZC֮ͣλϢͣϢһֱڣ޷*/ + ResetPhySecStopSteadyInfo(); +#endif + + /*ͨͨñͷ*/ + ProcHlhtHeadCtxTimeOut(); + + /*ͨʱͨı*/ + ClearSignalOvlpCmdHlht(); + + /*CI*/ + ProcessCiToCiData(); + + if (RC_WORK_MODE_CI == cRcWorkMode) + { + /*ZC*/ + ProcessZcToCiData(); + } + else + { + /*TMCTIOC*/ + ProcessTmcToTiocData(); + } + cost[2] = MSCP_GetTick(); + /*ITE*/ + ProcessIteToCiData(); + cost[3] = MSCP_GetTick(); + /*VOBC*/ + ProcessVobcToCiData(); + cost[4] = MSCP_GetTick(); + /*ͨVOBC*/ + ProcessVobcBackupToCiData(); + + /*гABLռñ־*/ + TrainPhyAblTagUpdate(); + + /*PSDϵͳ*/ + ProcessPlatformToCiData(); + + /*PSCϵͳ*/ + ProcessPscToCiData(); + + /*豸״̬*/ + ProcessDeviceLogicState(); + + /**/ + ProcessPsdData(); + + /*LEU*/ + ProcessLeuToCiData(); + + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + + /*ϵռ䵽 */ + ProcessPhyOCcStateToAxisSection(); + + /* ȫ߽ƶ */ + WlbAtsCmdProc(); + + /* г */ + TrainMainProc(); + cost[5] = MSCP_GetTick(); + /*гԴ*/ + (void)TrainResRecycle(); + if (FUNC_SWITCH_ON == chSwitch) + { + /* гռѹμ */ + ToaMainProc(); + } + else + { + ; + } + /** */ + elm_MainProcess(); + + cost[6] = MSCP_GetTick(); + /** ԶRM */ + rrm_MainProcess(); + + /* ñARB״̬ */ + SetPhySecArbStateProc(); + + /**/ + as_MainProcess(); + + /*ỵռ״̬*/ + AxisSecUtOccpyUpdate(); + + /*״̬ж*/ + ssp_MainProcess(); + cost[7] = MSCP_GetTick(); + } + /* ߼ARB״̬ */ + SetLgcArbStateProc(); + /*ں״̬*/ + UpdatePhySectionMergeLogicState(); + + /*ں߼CTռϢ*/ + UpdateLogSectionCTOccupyState(); + + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + /* źŻ */ + (void)SignalLightUpProc(); + } + else + { + /**/ + } + + /*ˢźŻʪ־*/ + UpdateHumidRailFlag(); + + /*ATS*/ + if ((CI_TYPE_ZX == localCiType) || (CI_TYPE_SCX == localCiType)) + { + /*ߴ*/ + (void)ProcessAtsOrXianDiToCiData(); + } + else + { + /*δ*/ + (void)ProcessAtsOrXianDiToCiDataCld(); + } + + (void)UpdataAtsDeviceCommState(); + + (void)ProcessAtsOrXDToCiReturnToTRCmd();/*漰źؿ*/ + /*cgh-ϲCID-3037-1 ESB״̬*/ + VirtualEsbLogicProcess(); + cost[8] = MSCP_GetTick(); + debug_infor_printf((const)"\n OutnetProcess :%dms ProcessAxleToCiData:%dms ProcessVobcBackupToCiData :%dms ProcessDeviceLogicState:%dms TrainMainProc:%dms as_MainProcess:%dms ssp_MainProcess:%dms VirtualEsbLogicProcess:%dms \n",(cost[1]-cost[0])/1000,(cost[2]-cost[1])/1000,(cost[3]-cost[2])/1000,(cost[4]-cost[3])/1000,(cost[5]-cost[4])/1000,(cost[6]-cost[5])/1000, (cost[7] - cost[6]) / 1000, (cost[8] - cost[7]) / 1000); +} + + +/* +* IOCI +* ˵ void +* ֵ 0u:ʧ +* 1:ɹ +*/ +UINT8 ProcessIoToCiData(void) +{ + IoDataStruct* CollBoardDataStru_ForProcess = NULL; /*ɼ̵*/ + UINT8 CollBroadStruCurSum_ForProcess = 0u; /*ɼ̵ṹ*/ + UINT8 BoardAddress_ForProcess = 0u; /*ɼ̵ǰַ*/ + UINT8 PosValue_ForProcess = 0u; /*ɼ̵ǰַIJɼֵ*/ + UINT8 ColRelayInfo = 0u; /*ɼϢ ȷAϵBϵǰɼǺɼ*/ + UINT16 RelayId = 0u; /*ǰɼַͲɼλöӦļ̵ID*/ + UINT8 ii = 0u; /*ɼ̵ַ*/ + UINT8 jj = 0u; /*ǰַļ̵λ*/ + UINT16 kk = 0u; /*α*/ + UINT16 relaySum = 0u; /*̵*/ + UINT8 returnValue = CI_SUCCESS; /*ֵĬϳɹ*/ + UINT8 SystemParaLocalCiId = 0u; /*ID*/ + UINT8 RelayBelongCiId = 0u; /*ָID̵ID*/ + UINT8 ProcessRelayCollState_ret = 0u; + UINT8 funValue = 0u; + + debug_infor_printf((const)"ProcessIoToCiData start at %d",TimeStamp); + + CollBroadStruCurSum_ForProcess = GetCollBroadStruCurSum(); + if (0u == CollBroadStruCurSum_ForProcess) + { + returnValue = CI_ERROR; + } + else + { + CollBoardDataStru_ForProcess = GetCollBoardDataStruct(); + for (ii = 0u; ii < CollBroadStruCurSum_ForProcess; ii++) + { + BoardAddress_ForProcess = CollBoardDataStru_ForProcess[ii].BoardAddress; + + for (jj = 0u; jj < BOARD_POS_MAX; jj++) + { + PosValue_ForProcess = CollBoardDataStru_ForProcess[ii].PosValueBuf[jj]; + RelayId = GetColRelayID(0,BoardAddress_ForProcess, (UINT8)(jj)); + ColRelayInfo = GetColRelayInfo(0,BoardAddress_ForProcess, (UINT8)(jj)); + + if (0u != RelayId) + { + /*޼̵ݵIJɼ*/ + if ((RELAY_STATE_UP == PosValue_ForProcess) || (RELAY_STATE_DOWN == PosValue_ForProcess)) + { + switch (ColRelayInfo) + { + case RELAY_COLL_FORENODE_A: + funValue = SetForeNodeACollState(RelayId, PosValue_ForProcess); + if (CI_ERROR == funValue) + { + returnValue = CI_ERROR; + } + break; + case RELAY_COLL_FORENODE_B: + funValue = SetForeNodeBCollState(RelayId, PosValue_ForProcess); + if (CI_ERROR == funValue) + { + returnValue = CI_ERROR; + } + break; + case RELAY_COLL_BACKNODE_A: + funValue = SetBackNodeACollState(RelayId, PosValue_ForProcess); + if (CI_ERROR == funValue) + { + returnValue = CI_ERROR; + } + break; + case RELAY_COLL_BACKNODE_B: + funValue = SetBackNodeBCollState(RelayId, PosValue_ForProcess); + if (CI_ERROR == funValue) + { + returnValue = CI_ERROR; + } + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + returnValue = CI_ERROR; + } + } + + + } + if (CI_ERROR == returnValue) + { + break; + } + } + + debug_infor_printf((const)"ColRelayInfo at %d",TimeStamp); + + if (CI_SUCCESS == returnValue) + { + relaySum = GetRelayCurSum(); + SystemParaLocalCiId = GetSystemParaLocalCiId(); + for (kk = 0u; kk < relaySum; kk++) + { + RelayId = GetRelayId(kk); + RelayBelongCiId = GetRelayBelongCiId(RelayId); + if (SystemParaLocalCiId == RelayBelongCiId) + { + ProcessRelayCollState_ret = ProcessRelayCollState(RelayId); + /*DZ*/ + if (CI_ERROR == ProcessRelayCollState_ret) + { +#if 0 + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM,CI_DEVICE_TYPE_RELAY,RelayId, ETYPE_SYSTEM_REL_UPDATA_ERROR,CI_ERROR,ESEND_LEVEL_ZERO); +#endif + } + else + { + /*ֵһ*/ + } + } + } + + } + } + + + debug_infor_printf((const)"ProcessIoToCiData end at %d",TimeStamp); + + return returnValue; +} + +/* +* AxleCI +* ˵ void +* ֵ void +*/ +void ProcessAxleToCiData(void) +{ + UINT8 returnValue = CI_ERROR; /*ֵĬϳɹ*/ + AxisToCiDataStruct* CollAxisDataStru = NULL; /*ͨŲɼ*/ + UINT8 axisCommSum = 0u; /*ͨż*/ + UINT8* pAxisSysIdBuf = NULL; /*ͨż*/ + UINT16 ii = 0u; /*ѭ*/ + UINT16 jj = 0u; /*ѭ*/ + UINT8 localCiId = 0u; /*CI ID*/ + UINT8 axisSysId = 0u;/*ϵͳid*/ + UINT8 tranAxisCommState = TRANSMIT_STATE_BAD;/*ͨ״̬*/ + UINT16 secId = 0u; /*ID*/ + UINT8 colAxisRelaySta = RELAY_STATE_DOWN; /*״̬*/ + UINT8 secOccupySta = SECTION_OCCUPY_YES; /*ռ״̬*/ + UINT8 acFty = 0u; /*ϵͳ*/ + UINT32 dwCurCycNum = 0U; + UINT32 dwLastRecvAxisDataCycNum = 0U; /*յݵ*/ + UINT32 dwCommBadEnsureCount = 0U; /*жϼͨжȷ*/ + + CollAxisDataStru = GetCollAxisDataStruct(); + axisCommSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); + pAxisSysIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); + + if ((NULL != CollAxisDataStru) && (NULL != pAxisSysIdBuf)) + { + returnValue = CI_SUCCESS; + } + + if (CI_SUCCESS == returnValue) + { + localCiId = GetSystemParaLocalCiId(); + for (ii = 0u; ii < axisCommSum; ii++) + { + axisSysId = pAxisSysIdBuf[ii]; + (void)UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_AXIS, axisSysId); + + tranAxisCommState = GetCiTransmitState(CI_SYSTEM_TYPE_AXIS, axisSysId); + if (TRANSMIT_STATE_GOOD == tranAxisCommState) + { + if(axisSysId 0u) && (deviceIdBuf != NULL)) + {/*Чж*/ + for (ii = 0u; ii < deviceSum; ii++) + {/*뱾CIͨŵOCϵͳ*/ + /*CIͨ״̬*/ + transmitReval = UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_OC, deviceIdBuf[ii]); + if (CI_ERROR == transmitReval) + { + /*ͨ״̬ʧ*/ + } + } + } + + for (ii = 0u; ii < m_OcToCiOrginDataNum; ii++) + { + pTempOc = &m_OcToCiOrginDataArr[ii]; + + if (GetCiIdByOcId(pTempOc->OcId) == localCiId) + { + if ((curCycle - pTempOc->ComStartCycle > ciocBadComCycle) || + (pTempOc->RecvErrorDevTypeCycle > ciocBadComCycle) + )/*CIOCͨųʱյ豸ݳ10*/ + { + debug_infor_printf((const)"OC_COM:break, com_cycle:%d startCycle:%d RecvErrorDevTypeCycle:%d\n", Get2oo2CurCycleNum(), pTempOc->ComStartCycle, pTempOc->RecvErrorDevTypeCycle); + /*1.źŻɼóɺ 2.ѵóĿ 3.ѹں״̬Ϊռ 4.Ѽ̵ɼ״̬Ϊ */ + for (jj = 0u; jj < pTempOc->OcDeviceNum; jj++) + { + if (pTempOc->OcDevices[jj].DeviceType == OC_DEVICE_TYPE_SIGNAL)/*źŻ*/ + { + pTempOc->OcDevices[jj].DeviceState = OC_SIGNAL_SHOWCOLOR_RED_BREAK;/**/ + } + else if (pTempOc->OcDevices[jj].DeviceType == OC_DEVICE_TYPE_SWITCH)/**/ + { + pTempOc->OcDevices[jj].DeviceState = OC_SWITCH_POSITION_SIKAI;/*Ŀ*/ + for (chSwitchZzjIndex = 0U; chSwitchZzjIndex < pTempOc->OcDevices[jj].chSwitchIncldeZzjNum; chSwitchZzjIndex++) + { + pTempOc->OcDevices[jj].szSwitchIncldeZzjState[chSwitchZzjIndex] = OC_SWITCH_POSITION_SIKAI; + } + } + else + { + /**/ + } + + } + + /*תźŻ״̬*/ + for (jj = 0u; jj < CI_SIGNAL_MAX; jj++) + { + if (m_Signals[jj].OcId == pTempOc->OcId) + { + m_Signals[jj].DeviceState = OC_SIGNAL_SHOWCOLOR_RED_BREAK;/**/ + } + } + /*תĵ״̬*/ + for (jj = 0u; jj < CI_SWITCH_MAX; jj++) + { + if (m_Switches[jj].OcId == pTempOc->OcId) + { + m_Switches[jj].DeviceState = OC_SWITCH_POSITION_SIKAI;/*Ŀ*/ + /*õ忨Ϊ*/ + for (j = 0U; j < MAX_OC_SWITCH_INCLUDE_BOARD_NUM; j++) + { + m_Switches[jj].BoardState[j] = 0xffU; + } + } + } + + /*ѹ״̬Ϊռ*/ + for (jj = 0u; jj < m_GdNum; jj++) + { + if (m_Gds[jj].OcId == pTempOc->OcId) + {/*ͨųʱABϵںϵ״̬Ϊι*/ + m_Gds[jj].GdState1 = OC_GD_STATE_FAULT; + m_Gds[jj].GdState2 = OC_GD_STATE_FAULT; + m_Gds[jj].BoardState1 = (UINT8)0xff; + m_Gds[jj].BoardState2 = (UINT8)0xff; + m_Gds[jj].GdMergeState = OC_GD_STATE_FAULT; + } + } + + pTempCollBoardData_ForProcess = m_OcConvertedPtDataArr[pTempOc->OcId].BoardDatas;/*ȡתλ*/ + + for (j = 0u; j < m_OcConvertedPtDataArr[pTempOc->OcId].OcBoardNum; j++)/*еİ忨*/ + { + for (ind = 0u; ind < OC_COLL_BOARD_POS_NUM; ind++) + { + pTempCollBoardData_ForProcess[j].PosValueBuf[ind] = RELAY_STATE_DOWN;/*м̵OC_RELAY_DOWN*/ + } + + } + + pTempOc->PowerAState = (UINT8)0xff; + pTempOc->PowerBState = (UINT8)0xff; + pTempOc->OCDevFaultState = (UINT8)0xff; + pTempOc->FanState = (UINT8)0xff; + + curSwapBoardNum = pTempOc->OCBoardSwapSysNum; + pTempOc->OCBoardSwapSysNum = 0U; /*OCϵ忨ʼΪ*/ + for (j = 0U; j < curSwapBoardNum; j++) + { + pTempOc->SwapSysBoardId[j] = 0U; + } + /*OCͨжϣȷPCBť״̬*/ + SetAllCleFarePCBButKeepSta(pTempOc->OcId,QK_PSD_BUTTON_STATE_UP); + } + else + { + /*OCͨʱҪOCϵ忨ϢATSʾϵİ忨*/ + curSwapBoardNum = pTempOc->OCBoardSwapSysNum; + for (kk = 0U; kk < curSwapBoardNum; kk++) + { + swapBoardId = pTempOc->SwapSysBoardId[kk]; + deviceOCAndBoardId = (UINT16)((pTempOc->OcId << 8U)) + swapBoardId; + if (0U != swapBoardId) + { + SetCiSendCmdBackInfoData(CI_BACK_OC_BOARD_SWAPSYS, CI_DEVICE_TYPE_OC_BOARD, deviceOCAndBoardId, 0U, 0U);/*OC忨ϵ*/ + } + } + } + } + } +} + +/* +* OCCIļ̵ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ProcessOcToCiRelayData(void) +{ + UINT8 returnValue =CI_ERROR; + CollBoardData* pTempCollBoardData_ForProcess = NULL; + UINT8 BoardAddress_ForProcess = 0u; /*忨ַ*/ + UINT8 cBoardState = RELAY_BOARD_FAULT_YES; /*忨״̬ʼΪ*/ + UINT8 PosValue_ForProcess = 0u; /*ɼ̵ǰַIJɼֵ:*/ + UINT16 RelayId = 0u; /*ǰɼַͲɼλöӦļ̵ID*/ + UINT8 ColRelayInfo = 0u; /*ɼϢ ȷAϵBϵǰɼǺɼ*/ + UINT8 i = 0u; + UINT8 j = 0u; + UINT16 ocId = 0u; + UINT8 k = 0u; + UINT16 kk = 0u; + UINT16 relaySum = 0u; + UINT8 SystemParaLocalCiId = 0u; /*ID*/ + UINT8 RelayBelongCiId = 0u; + UINT8 ProcessRelayCollState_ret = 0u; + UINT8 funValue = 0u; + + for (i = 0u; i < OC_SUM_MAX; i++) /*ָID̵ID*/ + { + if (LocalOcIds[i] > 0u)/*oc id Ч*/ + { + ocId = LocalOcIds[i]; + if (OC_SUM_MAX> ocId ) + { + returnValue = CI_SUCCESS; + pTempCollBoardData_ForProcess = m_OcConvertedPtDataArr[ocId].BoardDatas; + for (j = 0u; j < m_OcConvertedPtDataArr[ocId].OcBoardNum; j++)/*еOC忨*/ + { + BoardAddress_ForProcess = pTempCollBoardData_ForProcess[j].BoardAddress;/*忨ַ*/ + cBoardState = pTempCollBoardData_ForProcess[j].BoardState; /*忨״̬*/ + + for (k = 0u; k < BOARD_POS_MAX; k++) + { + PosValue_ForProcess = pTempCollBoardData_ForProcess[j].PosValueBuf[k];/*ֵ*/ + RelayId = GetColRelayID((UINT8)ocId,BoardAddress_ForProcess, k); + ColRelayInfo = GetColRelayInfo((UINT8)ocId,BoardAddress_ForProcess, k);/*ɼϢǰڵA/ǰڵB/ڵA/ڵB*/ + if (0u != RelayId )/*̵idΪ0*/ + { + if ((RELAY_STATE_UP == PosValue_ForProcess) || (RELAY_STATE_DOWN == PosValue_ForProcess)) + { + switch (ColRelayInfo) + { + case RELAY_COLL_FORENODE_A:/*ǰڵAϵ*/ + SetRelayACollBoardState(RelayId, cBoardState); /*Aϵ忨״̬*/ + funValue = SetForeNodeACollState(RelayId, PosValue_ForProcess); + if (CI_ERROR == funValue) + { + returnValue = CI_ERROR; + } + else + { + ; + } + break; + case RELAY_COLL_FORENODE_B:/*ǰڵBϵ*/ + SetRelayBCollBoardState(RelayId, cBoardState); /*Bϵ忨״̬*/ + funValue = SetForeNodeBCollState(RelayId, PosValue_ForProcess); + if (CI_ERROR == funValue) + { + returnValue = CI_ERROR; + } + else + { + ; + } + break; + case RELAY_COLL_BACKNODE_A:/*ڵAϵ*/ + SetRelayACollBoardState(RelayId, cBoardState); /*Aϵ忨״̬*/ + funValue = SetBackNodeACollState(RelayId, PosValue_ForProcess); + if (CI_ERROR == funValue) + { + returnValue = CI_ERROR; + } + else + { + ; + } + break; + case RELAY_COLL_BACKNODE_B:/*ڵBϵ*/ + SetRelayBCollBoardState(RelayId, cBoardState); /*Bϵ忨״̬*/ + funValue = SetBackNodeBCollState(RelayId, PosValue_ForProcess); + if (CI_ERROR == funValue) + { + returnValue = CI_ERROR; + } + else + { + ; + } + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + returnValue = CI_ERROR; + } + } + else + { + ; + } + if (CI_ERROR == returnValue) + { + break; + } + else + { + ; + } + }/*for (k=0;k0)oc id Ч*/ + else + { + ; + } + }/*for (i=0;itsrInputInfoStru.cTsrValidFlag)) + { + /*ʱȷϱ־*/ + if (CI_TSR_SURE_YES != cTsrSureFlag) + { + SetTsrSureFlag(CI_TSR_SURE_YES); + } + reVal = SetLocalTsrData(pZcToCiDataStru->tsrInputInfoStru.cTsrSum, pZcToCiDataStru->tsrInputInfoStru.szTsrInfo, + pZcToCiDataStru->tsrInputInfoStru.cAllLineTsrState, pZcToCiDataStru->tsrInputInfoStru.cAllLineTsrSpeed); + } + } + else + { + reVal = CI_ERROR; + } + } + + /*ZC͵ĽƶϢ*/ + if (reVal == CI_SUCCESS) + { + if (NULL != pZcToCiDataStru) + { + if ((1u == dataValidFlag) && + ((0x55U == pZcToCiDataStru->esbInputInfoStruct.cWlbValidFlag) || (0xAAU == pZcToCiDataStru->esbInputInfoStruct.cWlbValidFlag))) + { + WlbZcCmdProc(pZcToCiDataStru->esbInputInfoStruct.cWlbValidFlag, pZcToCiDataStru->esbInputInfoStruct.cSecEbSum, pZcToCiDataStru->esbInputInfoStruct.wEbPhySecId); + } + else + { + ; /*Ч*/ + } + } + else + { + reVal = CI_ERROR; + } + } + + /*ZC͵ѩģʽϢ*/ + if (reVal == CI_SUCCESS) + { + if ((1u == dataValidFlag)&&(ZC_TSR_VALID == pZcToCiDataStru->tsrInputInfoStru.cTsrValidFlag)) + { + if ((CI_ALL_SNOW_VALID == pZcToCiDataStru->cSnowValidFlag) || (CI_ALL_SNOW_UNVALID == pZcToCiDataStru->cSnowValidFlag)) + { + /* ѩģʽ */ + SetAllSnowModel(pZcToCiDataStru->cSnowValidFlag); + SetLocalAreaSnowInfo(pZcToCiDataStru->cAreaSnowPlatFormNum, pZcToCiDataStru->szAreaSnowPlatFormId); /*±ѩ״̬Ϣ*/ + SetLocalSnowModel(pZcToCiDataStru->chLocalSnowValidFlag); + } + } + else + { + reVal = CI_ERROR; + } + } + else + { + ; + } + + /*ZC͵ITEȫгϢ*/ + if (reVal == CI_SUCCESS) + { + if ((1u == dataValidFlag) && (ZC_TSR_VALID == pZcToCiDataStru->tsrInputInfoStru.cTsrValidFlag) && ((CI_ITE_LINE_CUT_VALID == pZcToCiDataStru->cIteLineCutState) + || (CI_ITE_LINE_CUT_INVALID == pZcToCiDataStru->cIteLineCutState) || (CI_ITE_LINE_CUT_DEFAULT == pZcToCiDataStru->cIteLineCutState))) + { + /* ITEȫг״̬ */ + SetIteLineCutState(pZcToCiDataStru->cIteLineCutState); + } + else + { + reVal = CI_ERROR; + } + } + else + { + /**/ + } + } +} +#endif + +/* +* TMCTIOC +* ˵ void +* ֵ void +*/ +void ProcessTmcToTiocData(void) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cLocalTiocId = 0u; + UINT8 cTsrSureFlag = CI_TSR_SURE_NO; + TmcToTiocDataStruct* pTmcInputData = NULL; + UINT8 deviceSum = 0u; + UINT8* deviceIdBuf = NULL; + UINT8 ii = 0u; + UINT8 cTransState = 0U; /*TMCͨ״̬*/ + + /*ֶTMCͨ״̬*/ + cLocalTiocId = GetSystemParaLocalCiId(); + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_TMC); /*ȡͨTMC豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_TMC); /*ȡͨTMC豸ID*/ + if ((0u != cLocalTiocId) && (0u != deviceSum) && (TRANSMIT_OBJECT_DEVICE_SUM_MAX >= deviceSum) && (NULL != deviceIdBuf)) + { + for (ii = 0u; ii < deviceSum; ii++) + { + cRetVal = UpdateCiTransmitState(cLocalTiocId, CI_SYSTEM_TYPE_TMC, deviceIdBuf[ii]); + } + /* ͨ״̬Ӱ촦÷֧Ϊɹ */ + cRetVal = CI_SUCCESS; + + cTransState = GetCiTransmitState(CI_SYSTEM_TYPE_TMC, deviceIdBuf[0]); /*RCһTMCͨ*/ + + if (TRANSMIT_STATE_GOOD == cTransState) + { + /*TMCͨ*/ + } + else + { + ClearLineCommTrainData(); /*TMCͨжϣش洢ȫͨųϢ*/ + } + } + else + { + cRetVal = CI_ERROR; + } + + + if (CI_SUCCESS == cRetVal) + { + + /* жǷҪTMC͵ʱϢ */ + pTmcInputData = GetTmcToTiocData(); + cTsrSureFlag = GetTsrSureFlag(); + + if (NULL != pTmcInputData) + { + if (0x55u == pTmcInputData->tsrInputInfoStru.cTsrValidFlag) + { + /* ȡȷ */ + if (CI_TSR_SURE_YES != cTsrSureFlag) + { + SetTsrSureFlag(CI_TSR_SURE_YES); + } + /* յTMC͵ʱЧϢ,ʱ */ + cRetVal = SetLocalTsrData(pTmcInputData->tsrInputInfoStru.cTsrSum, pTmcInputData->tsrInputInfoStru.szTsrInfo, pTmcInputData->tsrInputInfoStru.cAllLineTsrState, pTmcInputData->tsrInputInfoStru.cAllLineTsrSpeed); + } + else + { + /* δյЧϢ֮ǰ */ + } + } + else + { + cRetVal = CI_ERROR; + } + } + + /* ѩģʽ */ + if (CI_SUCCESS == cRetVal) + { + if (0x55u == pTmcInputData->tsrInputInfoStru.cTsrValidFlag) + { + if ((CI_ALL_SNOW_VALID == pTmcInputData->cSnowValidFlag) || (CI_ALL_SNOW_UNVALID == pTmcInputData->cSnowValidFlag)) + { + /* ѩģʽ */ + SetAllSnowModel(pTmcInputData->cSnowValidFlag); + SetLocalAreaSnowInfo(pTmcInputData->cAreaSnowPlatFormNum, pTmcInputData->szAreaSnowPlatFormId); /*±ѩ״̬Ϣ*/ + } + } + } + + /* ITEȫг״̬ */ + if (CI_SUCCESS == cRetVal) + { + if ((0x55U == pTmcInputData->tsrInputInfoStru.cTsrValidFlag) && ((CI_ITE_LINE_CUT_VALID == pTmcInputData->cIteLineCutState) || (CI_ITE_LINE_CUT_INVALID == pTmcInputData->cIteLineCutState))) + { + /* ITEȫг״̬ */ + SetIteLineCutState(pTmcInputData->cIteLineCutState); + } + else + { + /**/ + } + } + else + { + /**/ + } + + /*ȫͨųϢ*/ + if (CI_SUCCESS == cRetVal) + { + if (0x55U == pTmcInputData->tsrInputInfoStru.cTsrValidFlag) + { + /*ȫͨųϢ*/ + ProcessLineCommTrainData(pTmcInputData->cLineCtNum, pTmcInputData->szLineCtId); + } + else + { + /**/ + } + } + else + { + /**/ + } + + /* */ + ClearTmcToTiocData(); +} +/* +* VOBCCI +* ˵ void +* ֵ void +* ޸bug YF0083-100219 +*/ +void ProcessVobcToCiData(void) +{ + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 kk = 0u; + UINT16 wRouteIndex = 0u; + UINT16 wRouteSum = 0u; + UINT8 vobcToCiDataSum = GetVobcToCiSum(); + VobcToCiDataStruct* vobcToCiDataStru = GetVobcToCiDataStru(); + UINT8 chLineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡ·ʶ*/ + UINT8 dataValid = 0u; + UINT8 bufIndex = 0u; + UINT16 psdId = 0u; + UINT8 localCiId = 0u; + UINT8 belongCiId = 0u; + UINT8 deviceSum =0u;/*ͨ豸*/ + UINT8* deviceIdBuf = NULL;/*ͨ豸ID*/ + UINT8 platformId = 0u; + UINT16 platformPsdId = 0u; + UINT16 wRouteId = 0u; + UINT16 wTrainId = 0u; + UINT32 dwDelayTime = 0u; + UINT32 dwVobcBrkTime = 0u; + UINT16 phySecCurSum = 0u; + UINT16 deviceId = 0u; + UINT8 funRet = CI_ERROR; + UINT8 getResult = CI_ERROR; + UINT8 chRCMode = GetLocalRcWorkMode(); + UINT32 dwCurCycNum = 0U; + UINT32 dwTransmitBadEnsureCount = 0U; /*CIVOBCͨжжʱ*/ + UINT8 cTrainReportState = 0U; + UINT8 cCheckFlag = CI_ERROR; + + localCiId = GetSystemParaLocalCiId(); + dwCurCycNum = Get2oo2CurCycleNum(); + dwTransmitBadEnsureCount = GetCiAndVobcTransBadEnsureCnt(); + + if (LINE_CC == chLineIdentity) + { + ClearTrainCanUctFlag(); + } + else + { + ; /* dz· */ + } + /*VOBCϸPSDϢ*/ + for(bufIndex = 0u;bufIndex < PSD_SUM_MAX;bufIndex++) + {/*PSDṹ*/ + psdId = PsdDataStru[bufIndex].PsdId; + + if (GetPsdBelongCiId(psdId) == localCiId) + {/*ڱPSDŴ*/ + if ((dwCurCycNum - PsdDataStru[bufIndex].CmdSetCycle) > dwTransmitBadEnsureCount) + {/*ǰPSDGetCiAndVobcTransBadEnsureCnt()δյκVOBCڸPSDĿϢ򿪡رպͲѯPSDĹϸ*/ + PsdDataStru[bufIndex].SrcVobcId = 0u; + PsdDataStru[bufIndex].PsdCmd = PSD_DEFAULT_CONTROL_CMD; + PsdDataStru[bufIndex].CmdSetCycle = 0u; + PsdDataStru[bufIndex].psdEditGroupInfo = 0u;/*Ϣ*/ + PsdDataStru[bufIndex].VOBCDoorState = PSD_DOOR_CLOSEDANDLOCKED_INVALID; + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PLATFORM); /*ȡͨPSD豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PLATFORM); /*ȡͨPSD豸ID*/ + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + {/*Чж*/ + for (ii = 0u;ii < deviceSum;ii++) + {/*뱾CIͨŵվ̨ϵͳ*/ + platformId = deviceIdBuf[ii]; + for (jj = 0u;jj < platformToCiDataStru[platformId].psdSum;jj++) + {/*վ̨ϵͳPSDĿ*/ + platformPsdId = platformToCiDataStru[platformId].psdDataStr[jj].PsdId; + if (psdId == platformPsdId) + {/*ҵӦվ̨ϵͳϢVOBC͵ĹϸϢ*/ + platformToCiDataStru[platformId].psdDataStr[jj].doorHaveOrNot = PSD_HAVE_TRAIN_DOOR_NO;/*VOBCͨжϺ󣬰޳ϢΪ޳*/ + platformToCiDataStru[platformId].psdDataStr[jj].faultIsolationRequestInfo = 0u;/*VOBCͨжϺ󣬽VOBCPSDΪ޸*/ + platformToCiDataStru[platformId].psdDataStr[jj].doorEditGroupInfo = 0u; /*Ϣ*/ + } + } + } + } + } + } + } + + if (RC_WORK_MODE_TIOC == chRCMode) + {/*TIOC*/ + + /* ֮ǰ֤ͣϢԴȡϢ */ + phySecCurSum = GetPhySecCurSum(); + for (ii = 0u; ii < phySecCurSum; ii++) + { + deviceId = GetPhySecId(ii); + SetPhySecStopSteadyFlag(deviceId, PHYSICAL_SECTION_STOPSTEADY_NO);/*δͣ*/ + } + wRouteSum = GetRouteCurSum(); + for (wRouteIndex = 0u; wRouteIndex < wRouteSum; wRouteIndex++) + { + wRouteId = GetRouteId(ii); + belongCiId = GetRouteBelongCiId(wRouteId); + if (belongCiId == localCiId) + { + /*ý·δյ֤ͣ*/ + SetRouteStopensureFlag(wRouteId, ROUTE_STOPENSURE_NO); + + /*ý·Դȡ*/ + SetRouteResourceCancelFlag(wRouteId, ROUTE_RESOURCECANCEL_NO); + } + else + { + /**/ + } + } + } + else if (RC_WORK_MODE_CI == chRCMode) + {/*CI*/ + /*֤ͣϢZCλ*/ + } + else + { + /*޴*/ + } + + + for (ii = 0u; ii < vobcToCiDataSum; ii++) + { + wTrainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + vobcToCiDataStru[ii].VobcId; + if (LINE_FAO == chLineIdentity)/*FAO·*/ + {/*жVOBCCIͨж*/ + if((dwCurCycNum - vobcToCiDataStru[ii].ComStartCycle) > dwTransmitBadEnsureCount) + { + dataValid = 0u; + } + else + { + dataValid = 1u; + } + + + } + else if ((LINE_HLHT == chLineIdentity) || (LINE_FAOHLHT == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity))/*ͨ·򣨻ͨ+FAO·*/ + { + /*ͨ·ʹϢʣЧжCIVOBCͨǷж*/ + getResult = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru[ii].VobcId)); + if (CI_ERROR == getResult) + { + dataValid = 0u; + } + else + {/*ϢЧ*/ + dataValid = 1u; + } + } + else if (LINE_CC == chLineIdentity) + { + /* · */ + dwDelayTime = GetVobcMsgDelayTime(wTrainId); + dwVobcBrkTime = GetCiAndVobcTransBadEnsureTime(); + if (dwDelayTime > dwVobcBrkTime) + { + dwDelayTime = dwVobcBrkTime; + } + funRet = SetTrainMsgDelayTime(wTrainId, dwDelayTime); + /*ͨ·ʹϢʣЧжCIVOBCͨǷж*/ + getResult = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru[ii].VobcId)); + if ((CI_ERROR == getResult) || (CI_ERROR == funRet)) + { + dataValid = 0u; + } + else + {/*ϢЧ*/ + dataValid = 1u; + } + } + else + { + /*·ʹ*/ + } + + if (1u == dataValid) + { + if (dwCurCycNum == vobcToCiDataStru[ii].ComStartCycle) + { + /*PSD*/ + for (jj = 0u; ((jj < vobcToCiDataStru[ii].PsdSum) && (jj < VOBC_TO_CI_TRAIN_PSD_MAX)); jj++) + { + /*֮ǰδʵֵվ̨ʾ̵Ŀǰ޴ע͵δ*/ +#if 0 + /*Ӹֵط*/ + SetCiSendCmdBackInfoData(CI_BACK_TRAIN_DOOR_STATE, CI_DEVICE_TYPE_PSD, vobcToCiDataStru[ii].PsdData[jj].PsdId, 0u, 0u); +#endif + /*»VOBCCIһֱͨţ¹ϸϢ޷ڴ˼յһVOBCĿǷʱ*/ + if ((dwCurCycNum - vobcToCiDataStru[ii].PsdData[kk].CmdStartCycNum) > dwTransmitBadEnsureCount) + { + ClearPsdVobcContext(vobcToCiDataStru[ii].VobcId); + break; + } + if (vobcToCiDataStru[ii].PsdData[jj].PsdId != PSD_INVALID_ID) + {/*PSD IDЧ*/ + if ((LINE_FAOHLHT == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity)) + { + switch (vobcToCiDataStru[ii].PsdData[jj].CmdType) + { + case VOBCTOCI_COMMAND_TYPE_PSDOPEN:/**/ + SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDOPEN); + if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u) + { + if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX) + { + PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo; + } + } + break; + case VOBCTOCI_COMMAND_TYPE_PSDCLOSE:/**/ + SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDCLOSE); + if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u) + { + if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX) + { + PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo; + } + } + break; + case VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT:/*ѯ*/ + SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT); + if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u) + { + if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX) + { + PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo; + } + } + break; + default: + /*ѯ*/ + break; + } + + /*϶̽⴦ֹͣ϶̽⣻¼϶̽⿪ʼʱ*/ + if (VOBC_CI_GAP_DETECT_CMD_START == vobcToCiDataStru[ii].PsdData[jj].gapDetectCmd) + {/*϶̽*/ + /*̽Чֹͣ̽Ч*/ + SetStartDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_START_DETECTION_YES); + SetStopDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_STOP_DETECTION_NO); + } + else if (VOBC_CI_GAP_DETECT_CMD_STOP == vobcToCiDataStru[ii].PsdData[jj].gapDetectCmd) + {/*ֹͣ϶̽*/ + /*ֹͣ̽Ч̽Ч*/ + SetStartDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_START_DETECTION_NO); + SetStopDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_STOP_DETECTION_YES); + } + else + { + /*do nothing*/ + } + + /*϶̽⴦CIյVOBCŹرճ״̬Źż̵*/ + if (VOBC_CI_DOOR_CLOSEDANDLOCKED == vobcToCiDataStru[ii].PsdData[jj].VOBCDoorState) + {/*ŹرŵVOBC״̬ر*/ + SetVOBCDoorState(vobcToCiDataStru[ii].PsdData[jj].PsdId, PSD_DOOR_CLOSEDANDLOCKED_VALID); + } + else if (VOBC_CI_DOOR_NOTCLOSEDANDLOCKED == vobcToCiDataStru[ii].PsdData[jj].VOBCDoorState) + {/*ŹرŵVOBC״̬δر*/ + SetVOBCDoorState(vobcToCiDataStru[ii].PsdData[jj].PsdId, PSD_DOOR_CLOSEDANDLOCKED_INVALID); + } + else + { + /*do nothing*/ + } + } + else if ((LINE_HLHT == chLineIdentity) || (LINE_FAO == chLineIdentity)) + { + switch (vobcToCiDataStru[ii].PsdData[jj].CmdType) + { + case VOBCTOCI_COMMAND_TYPE_PSDOPEN: + SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDOPEN); + if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u) + { + if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX) + { + PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo; + } + } + break; + case VOBCTOCI_COMMAND_TYPE_PSDCLOSE: + SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDCLOSE); + if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u) + { + if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX) + { + PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo; + } + } + break; + case VOBCTOCI_COMMAND_TYPE_PSDCHECK: + SetPsdVobcCmd(vobcToCiDataStru[ii].PsdData[jj].PsdId, vobcToCiDataStru[ii].VobcId, VOBCTOCI_COMMAND_TYPE_PSDCHECK); + if (vobcToCiDataStru[ii].PsdData[jj].PsdId > 0u) + { + if (vobcToCiDataStru[ii].PsdData[jj].PsdId < PSD_SUM_MAX) + { + PsdDataStru[vobcToCiDataStru[ii].PsdData[jj].PsdId].psdEditGroupInfo = vobcToCiDataStru[ii].trainEditGroupInfo; + } + } + break; + default: + /*ѯ*/ + break; + } + } + else + { + /*·ʹ*/ + } +#if 0 + if ((VOBCTOCI_COMMAND_TYPE_PSDCLOSE == vobcToCiDataStru[ii].PsdData[jj].CmdType) && + (PSD_STATE_OPEN == GetPsdState(vobcToCiDataStru[ii].PsdData[jj].PsdId)) && + (0u == GetStartDetectionCycNum(vobcToCiDataStru[ii].PsdData[jj].PsdId))) + { /*״̬Ϊ򿪣ʱյ͵Ĺһûʼʱ*/ + /*̽̽Чֹͣ̽Ч*/ + SetStartDetectionCycNum(vobcToCiDataStru[ii].PsdData[jj].PsdId, Get2oo2CurCycleNum()); + SetStartDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_START_DETECTION_YES); + SetStopDetectionState(vobcToCiDataStru[ii].PsdData[jj].PsdId, JXTC_STOP_DETECTION_NO); + } +#endif + + } + } + } + else + { + /*δյݣ*/ + } + + if((LINE_FAO == chLineIdentity) && (dwCurCycNum == vobcToCiDataStru[ii].ComStartCycle))/*FAO·*/ + { + FAOVOBCDataProc(&(vobcToCiDataStru[ii]));/*ڴFAOVOBCϴ*/ + } + else if (LINE_HLHT == chLineIdentity)/*ͨ·*/ + { + HLHTVOBCDataProc(&(vobcToCiDataStru[ii])); + } + else if ((LINE_FAOHLHT == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity))/*ͨ+FAO·*/ + { + HLHTFAOVOBCDataProc(&(vobcToCiDataStru[ii])); + } + else if (LINE_CC == chLineIdentity) + { + IvocInputDataProcCC(&(vobcToCiDataStru[ii])); /* IVOC*/ + cTrainReportState = GetTrainReportState(vobcToCiDataStru[ii].VobcId); + if (BIT_VAL_00000001B == ((cTrainReportState >> 3U) & BIT_VAL_00000001B)) + { + cCheckFlag = CI_SUCCESS; /*MMIʪ죬־óɹ*/ + } + else + { + /*MMIʪ죬*/ + } + } + else + { + /*Ŀǰֽ֧ӿڣFAOӿڡHLHTӿڡFAO+HLHTӿڣdataValidЧǰ£÷֧*/ + } + } + else + { + if ((LINE_FAO == chLineIdentity) || (LINE_HLHT == chLineIdentity) || (LINE_FAOHLHT == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity)) + { + /*PSDɾVOBCϢ*/ + ClearPsdVobcContext(vobcToCiDataStru[ii].VobcId); + + /*г͵ͣϢ*/ + ClearVobcStopSteadyData(vobcToCiDataStru[ii].VobcId); + + /*ϴVOBC״̬*/ + ClearWashVobcDriveState(&(vobcToCiDataStru[ii])); + + /*гӿϢ*/ + VobcConnectDataClear(vobcToCiDataStru[ii].VobcId); + } + else if (LINE_CC == chLineIdentity) + { + /*PSDɾVOBCϢ*/ + ClearPsdVobcContext(vobcToCiDataStru[ii].VobcId); + ProcessIvocLoseCom(vobcToCiDataStru[ii]); + + /*ϴVOBC״̬*/ + ClearWashVobcDriveState(&(vobcToCiDataStru[ii])); + + /*гӿϢ*/ + VobcConnectDataClear(vobcToCiDataStru[ii].VobcId); + } + else + { + ; /*·ݲ*/ + } + /*ɾVOBCCI*/ + (void)RemoveVobcToCiMsgAt((UINT8)ii); + ii--; + vobcToCiDataSum = GetVobcToCiSum(); + } + } + + if (CI_SUCCESS == cCheckFlag) + { + /*гMMIʪ״̬ñʪЧ*/ + SetLocalSnowModel(CI_LOCAL_SNOW_VALID); + } + else + { + /*гMMIʪ״̬ñʪЧ*/ + SetLocalSnowModel(CI_LOCAL_SNOW_UNVALID); + } +} + +/* +* ģʽVOBCCI +* ˵ void +* ֵ void +* ޸bug YF0083-100219 +*/ +void ProcessVobcBackupToCiData(void) +{ + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT8 backUpValid = CI_ERROR; + UINT8 mainValid = CI_ERROR; + UINT16 psdId = 0U; /*psd ID*/ + UINT8 psdCmdType = 0U; /*psd */ + UINT16 wBufIndex = 0u; /**/ + UINT16 trainId = 0U; /*ȡгID*/ + UINT32 curCycNum = 0U; + UINT32 dwRcvCycNum = 0U; + UINT8 headCheck = CI_ERROR; + UINT8 psdCmdCode = 0U; + + curCycNum = Get2oo2CurCycleNum(); + for (ii = 0U; ii < VOBC_BACKUP_TO_CI_SUM_MAX; ii++) + { + if (0U != VobcBackUpToCiDataStru[ii].VobcId) + { + /*ʹûͨͷжCIVOBCͨǷЧ*/ + backUpValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(VobcBackUpToCiDataStru[ii].VobcId)); + /*ʹûͨͷжCIVOBCͨǷЧ*/ + mainValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC, (UINT8)(VobcBackUpToCiDataStru[ii].VobcId)); + trainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC_BACKUP * 256U)) + VobcBackUpToCiDataStru[ii].VobcId; + dwRcvCycNum = VobcBackUpToCiDataStru[ii].ComStartCycle; + + /*ͨʧЧҺͨЧʱúͨ*/ + if((CI_SUCCESS != mainValid) && ( CI_SUCCESS == backUpValid)) + { + /* vobdidЧ ͨЧ ſ*/ + if (dwRcvCycNum == curCycNum) + { + /*վ̨ſ гϢ*/ + psdCmdCode = VobcBackUpToCiDataStru[ii].psdCmdCode; + + for (jj = 0U; jj < VobcBackUpToCiDataStru[ii].PsdSum; jj++) + { + psdId = VobcBackUpToCiDataStru[ii].PsdData[jj].PsdId; + psdCmdType = VobcBackUpToCiDataStru[ii].PsdData[jj].CmdType; + wBufIndex = GetPsdConfigBufIndex(psdId); /*ȡָID*/ + if ((0u < wBufIndex) && (PSD_SUM_MAX > wBufIndex)) + { + if ((VOBCTOCI_COMMAND_TYPE_PSDOPEN == psdCmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == psdCmdType)) + { + SetPsdVobcCmd(psdId, trainId, psdCmdType); + PsdDataStru[wBufIndex].psdEditGroupInfo = psdCmdCode; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + + /*ͨӿݴ*/ + VobcBackUpConnectDataProc(&VobcBackUpToCiDataStru[ii]); + + /*󱸳ͣϢ*/ + BackupStopSteadyDataProc(&VobcBackUpToCiDataStru[ii]); + + } + } + else + { + /*PSDɾúͨvobcϢ*/ + ClearPsdVobcContext(trainId); + + /*жǷʼͨ֡*/ + headCheck = BackupHeadCheckValid(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(VobcBackUpToCiDataStru[ii].VobcId)); + + if ((CI_SUCCESS != backUpValid) && (CI_SUCCESS != mainValid)) + { + /*ǰ󱸽ӿϢ*/ + VobcConnectDataClear(VobcBackUpToCiDataStru[ii].VobcId); + } + else + { + ; /**/ + } + + if ((CI_SUCCESS != headCheck)&& (CI_SUCCESS != backUpValid)) + /*dzʼ֡ҺͨУʧ*/ + { + (void)memset(&(VobcBackUpToCiDataStru[ii]), 0, sizeof(VobcBackUpToCiDataStruct));/*ڴ棬ֹ*/ + } + } + } + else + { + ; /**/ + } + } +} + +/* +* PSDCI +* ˵ void +* ֵ void +*/ +void ProcessPlatformToCiData(void) +{ + UINT8 stationSum = 0u; + UINT8 * idBuf = NULL; + UINT8 ii; + UINT8 transmitState = 0u; + stationSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PLATFORM); /*ȡCIϵͳͨŵվ̨ϵͳ*/ + idBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PLATFORM); /*ȡCIϵͳͨŵվ̨ϵͳID*/ + for(ii = 0u;ii < stationSum;ii++) + { + transmitState = GetCiTransmitState(CI_SYSTEM_TYPE_PLATFORM,idBuf[ii]);/*ȡ뵱ǰPSDͨ״̬*/ + if(TRANSMIT_STATE_GOOD != transmitState) + {/*ǰͨŹϣݵȫ*/ + (void)SetPlatformToCiDefaultDataStru(idBuf[ii]); + } + } +} + + +/* +* PSCϵͳ +* ˵ void +* ֵ void +*/ +void ProcessPscToCiData(void) +{ + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 localCiId = 0u; + UINT8 deviceSum =0u;/*ͨ豸*/ + UINT8* deviceIdBuf = NULL;/*ͨ豸ID*/ + UINT8 pscId = 0u; + UINT8 psdCiId = 0u; + UINT16 pscPsdId = 0u; + UINT8 psdUpdateType = GetCiFunctionSwitchConfig(FUCN_IF_PSC); /*ȡǷPSCͨŷʽ 0x55VOBC״̬ 0xaaPSC״̬*/ + UINT8 transmitState = 0u; + UINT8 transmitReval = CI_ERROR; + PSCToCiDataStruct* pscToCiDataStru = GetPscToCiDataStru(); + localCiId = GetSystemParaLocalCiId(); + + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PSC); /*ȡͨPSC豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PSC); /*ȡͨPSC豸ID*/ + + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + {/*Чж*/ + for (ii = 0u; ii < deviceSum; ii++) + {/*뱾CIͨŵվ̨ϵͳ*/ + pscId = deviceIdBuf[ii]; + /*CIͨ״̬*/ + transmitReval = UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_PSC, deviceIdBuf[ii]); + + if(CI_SUCCESS == transmitReval) + { + transmitState = GetCiTransmitState(CI_SYSTEM_TYPE_PSC, deviceIdBuf[ii]); + } + if(TRANSMIT_STATE_GOOD != transmitState) + {/*ǰͨŹϣݵȫ*/ + (void)SetPscToCiDefaultDataStru(deviceIdBuf[ii]); + } + /*ATSȷ¶ӦĻ״̬*/ + UpdateAtsPscPlFlagData(deviceIdBuf[ii]); + /*PSCϵͳIDϷ*/ + if(PSC_TO_CI_SUM_MAX > pscId) + { + for (jj = 0u; jj < pscToCiDataStru[pscId].psdSum; jj++) + {/*վ̨ϵͳPSDĿ*/ + pscPsdId = pscToCiDataStru[pscId].psdDataStr[jj].psdId; + psdCiId = GetPsdBelongCiId(pscPsdId); + /*ҵӦվ̨ϵͳϢ*/ + if((0u!=pscPsdId) && (PSD_STATE_FROM_PSC == psdUpdateType) && (psdCiId == localCiId)) + {/*PSCյ״̬ƸţǰΪPSC״̬*/ + if (PSD_VIRTUAL_ATTR_YES == GetPsdVirtualAttribute(pscPsdId)) + {/*ſ״̬²PSC״̬*/ + /*ʲô*/ + } + else + {/*ʵŲPSC״̬»״̬*/ + if((PSD_MUTUALLOCK_REMOVE_YES == pscToCiDataStru[pscId].psdDataStr[jj].psdMLockState) + && (PSD_MUTUALLOCK_REMOVE_YES == pscToCiDataStru[pscId].psdDataStr[jj].psdAtsMlockState)) + { + /*״̬*/ + (void)SetPsdMutualLockRemoveState(pscPsdId, PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES); + } + else if((PSD_MUTUALLOCK_REMOVE_YES == pscToCiDataStru[pscId].psdDataStr[jj].psdMLockState) + && (PSD_MUTUALLOCK_REMOVE_NO == pscToCiDataStru[pscId].psdDataStr[jj].psdAtsMlockState)) + { + /*̵ɼ*/ + (void)SetPsdMutualLockRemoveState(pscPsdId, PSD_MUTUALLOCK_REMOVE_YES); + } + else if(((PSD_MUTUALLOCK_REMOVE_NO == pscToCiDataStru[pscId].psdDataStr[jj].psdMLockState) + || (PSD_MUTUALLOCK_REMOVE_DEFAULT == pscToCiDataStru[pscId].psdDataStr[jj].psdMLockState)) + && (PSD_MUTUALLOCK_REMOVE_YES == pscToCiDataStru[pscId].psdDataStr[jj].psdAtsMlockState)) + { + /*ATSȷ*/ + (void)SetPsdMutualLockRemoveState(pscPsdId, PSD_ATS_MUTUALLOCK_REMOVE_YES); + } + else + { + (void)SetPsdMutualLockRemoveState(pscPsdId, PSD_MUTUALLOCK_REMOVE_NO); + } + /*ſ״̬*/ + if (PSD_STATE_CLOSE_VIETNAM == pscToCiDataStru[pscId].psdDataStr[jj].psdState) + { + (void)SetPsdState(pscPsdId, PSD_STATE_CLOSE); + } + else if (PSD_STATE_OPEN_VIETNAM == pscToCiDataStru[pscId].psdDataStr[jj].psdState) + { + (void)SetPsdState(pscPsdId, PSD_STATE_OPEN); + } + else + {/*ſ״̬ĬϿ*/ + (void)SetPsdState(pscPsdId, PSD_STATE_OPEN); + } + } + } + } + } + pscId = 0u;/*pscId*/ + } + } +} + + +/* +* ATSȷPSC·ϵͳ״̬ +* ˵ UINT8 pscId PSCϵͳID +* ֵ void +*/ + +void UpdateAtsPscPlFlagData(UINT8 pscId) +{ + /*ʼ*/ + UINT8 i = 0u; + UINT8 getPscPlFlag = 0u; + UINT8 psdVirArr = 0u; + PSCToCiDataStruct* pscToCiDataStru = GetPscToCiDataStru();/*᷵NULL*/ + + /**/ + if(PSC_TO_CI_SUM_MAX > pscId) + { + for(i = 0u; i < pscToCiDataStru[pscId].psdSum; i++) + { + /*ȡȷϱ־*/ + getPscPlFlag = GetPsdPscPlFlag(pscToCiDataStru[pscId].psdDataStr[i].psdId); + psdVirArr = GetPsdVirtualAttribute(pscToCiDataStru[pscId].psdDataStr[i].psdId); + if(CI_PSC_PL_CONFIRM_YES == getPscPlFlag) + { + /*ATSȷ·״̬*/ + if (PSD_VIRTUAL_ATTR_YES != psdVirArr) + {/*Ų*/ + pscToCiDataStru[pscId].psdDataStr[i].psdState = PSD_STATE_CLOSE_VIETNAM;/*״̬ҪҪã*/ + pscToCiDataStru[pscId].psdDataStr[i].psdAtsMlockState = PSD_MUTUALLOCK_REMOVE_YES; + } + } + else + { + if (PSD_VIRTUAL_ATTR_YES != psdVirArr) + {/*Ų*/ + pscToCiDataStru[pscId].psdDataStr[i].psdAtsMlockState = PSD_MUTUALLOCK_REMOVE_NO; + } + } + } + } +} + +/* +* ATSֵصCI +* ˵ void +* ֵ 0u:ʧ +* 1:ɹ +*/ +UINT8 ProcessAtsOrXianDiToCiData(void) +{ + CommandDataStruct* AtsOrXianDiToCiCmdStru = NULL; /*atsֵص*/ + UINT16 AtsOrXianDiToCiCmdSum = 0u; /*atsֵص*/ + UINT16 CmdDeviceId = 0u; /*atsֵص漰豸ID*/ + UINT8 cmdDevType = 0u; /*atsֵص漰豸*/ + UINT8 cmdType = 0u; /*atsֵص*/ + UINT32 commandId = 0u; /*id*/ + UINT16 terminalId = 0u; /*նid*/ + UINT16 ii = 0u; /*α*/ + UINT8 localCiType = GetLocalCiType(); + UINT8 checkRetVal = CI_FALSE; + UINT16 cmd_idx = 0u; + UINT16 wATSToCiCmdReturnToTRCurSum = 0u;/*źؿĿ*/ + UINT8 flag = 0u;/*źؿǷѴ洢־*/ + CommandDataStruct* pATSToCiCmdReturnToTRData = NULL;/*źؿ洢ṹ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT16 signalOutSecId = 0u; /*źŻⷽ*/ + UINT16 returnRouteId = 0u; /*۷·*/ + UINT16 throughRouteId = 0u; /*ͨ·*/ + UINT8 returnRouteIdBelongCiId = 0u;/*۷·ID*/ + UINT8 throughRouteIdBelongCiId = 0u;/*ͨ·ID*/ + UINT8 signalBelongCi = 0u; + UINT8 functionId = EFUNC_ZX_ProcessAtsOrXianDiToCiData; + + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT16 sigDetainDriveRelayId = 0u;/*źŻ۳̵*/ + UINT8 detainDriveRelayBelongCi = 0u;/*۳̵*/ + + UINT8 startFLockFlag =0u; + UINT8 startLockFlag = 0u; + UINT8 ciTrainTestState =0u; + UINT8 allSwitchYLockFlag = 0u; + UINT8 OrderCheckReVal = 0u; + UINT8 belongVirCIid = 0u; + UINT8 virCiID = 0u; + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT16 routeCmdSum = 0u; /*һյĽ·*/ + UINT16 saveRouteCmdSum = 0u; /*洢·*/ + UINT16 j = 0u; + CommandDataStruct SaveAtsRouteSetCmdStru[ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX] = {0}; /*洢atsֵص·*/ + UINT8 allSignalBrightState = 0u; + UINT16 trainId = 0U; /*صгID*/ + UINT8 cDsnLineSwitch = FUNC_SWITCH_OFF;/* ֵ֧ʿ·־λ */ + UINT8 cShadowMainMode = REVERSE_MODE_SHADOW;/* Ӱģʽ״̬ */ + UINT8 cLogSecSeqDir = CI_SYSTEM_DIRECTION_NONE; /* ߼з */ + UINT8 cFunRetVal = CI_ERROR; /* պֵжϱ */ + UINT16 recordErrorNum = 0u; + UINT8 cLogSecSum = 0U; /*߼*/ + UINT16* pLogSecIdBuff = NULL; /*߼ID*/ + UINT16 OverlapRouteId = 0U; + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + /*ATS*/ + AtsOrXianDiToCiCmdSum = GetCiRevCmdStruCurSum(); + AtsOrXianDiToCiCmdStru = GetCiRevCmdDataStruct(); + + if ((NULL == AtsOrXianDiToCiCmdStru) || (0u == AtsOrXianDiToCiCmdSum)) + { + /*CIδյATS*/ + return CI_ERROR; + } + cDsnLineSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + cShadowMainMode = GetTiocSystemMode(); + + if ((FUNC_SWITCH_ON == cDsnLineSwitch) && (REVERSE_MODE_SHADOW == cShadowMainMode)) + { + /* ǰΪӰģʽֻ۳ */ + for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam >> 16); + cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam >> 8); + commandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id; + virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid; + cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType; + /*жǷΪ۳*/ + + switch (cmdType) + { + case ATS_CMD_KOUCHE_SET_ATS: + /*ATS۳ص*/ + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + + if (signalBelongCi == localCiId) + {/*źŻ뱾idͬ*/ + DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_ATS); + } + else + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_ATS, signalBelongCi); + + sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*ȡźŻ۳̵ID*/ + if (0u < sigDetainDriveRelayId) + { + detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId); + } + commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*ͨͨ״̬*/ + if ((TRANSMIT_STATE_BAD == commState) && (detainDriveRelayBelongCi == localCiId) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + {/*ͨ״̬ж źŻ۳̵ڱ̵ּ֧ӿڹܿѴ*/ + SetSignalNeighbourDetainDrive(CmdDeviceId, NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES);/*ÿ۳*/ + } + } + break; + + case ATS_CMD_KOUCHE_CANCEL_ATS: + /*ȡATS۳ؿź*/ + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + if (signalBelongCi == localCiId) + {/*źŻ뱾idͬ*/ + DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_ATS_NO); + } + else + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_ATS_NO, signalBelongCi); + sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*ȡźŻ۳̵ID*/ + if (0u < sigDetainDriveRelayId) + { + detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId); + } + if ((detainDriveRelayBelongCi == localCiId)) + {/*źŻ۳̵ڱ*/ + SetSignalNeighbourDetainDrive(CmdDeviceId, NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO);/*ȡ۳*/ + } + } + break; + + case ATS_CMD_KOUCHE_SET_XIANDI: + /*ֵؿ۳ص*/ + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + + if (signalBelongCi == localCiId) + {/*źŻ뱾idͬ,źŻ۳̵IDڱ*/ + DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_XIANDI); + } + else + {/*߼˼̵ӿڣұźŻͨжϣ۳̵紫ݿ۳*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_XIANDI, signalBelongCi); + + sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*ȡźŻ۳̵ID*/ + if (0u < sigDetainDriveRelayId) + { + detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId); + } + commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*ͨͨ״̬*/ + if ((TRANSMIT_STATE_BAD == commState) && (detainDriveRelayBelongCi == localCiId) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + {/*ͨ״̬ж źŻ۳̵ڱ̵ּ֧ӿڹܿѴ*/ + SetSignalNeighbourDetainDrive(CmdDeviceId, NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES);/*ÿ۳*/ + } + + } + break; + + case ATS_CMD_KOUCHE_CANCEL_XIANDI: + /*ȡֵؿ۳ؿź*/ + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + if (signalBelongCi == localCiId) + {/*źŻ뱾idͬ*/ + DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_XIANDI_NO); + } + else + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_XIANDI_NO, signalBelongCi); + sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*ȡźŻ۳̵ID*/ + if (0u < sigDetainDriveRelayId) + { + detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId); + } + if ((detainDriveRelayBelongCi == localCiId)) + {/*źŻ۳̵ڱ*/ + SetSignalNeighbourDetainDrive(CmdDeviceId, NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO);/*ȡ۳*/ + } + } + break; + default: + /* ޴ */ + break; + } + + } + + /**/ + ClearCiRevCmdData();/*CIݶ*/ + } + else + { + startFLockFlag = GetStartFLockFlag(); + if ((CI_START_FLOCK_YES == startFLockFlag)) + { + for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8); + commandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id; + virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid; + cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType; + /*жȫվ*/ + if (ATS_CMD_STARTFLOCK_UNLOCK_ONE == cmdType) + { + + + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + ClearCiRevCmdData();/*CIݶ*/ + + return CI_SUCCESS; + } + else if (ATS_CMD_STARTFLOCK_UNLOCK_TWO == cmdType) + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȫվ*/ + SetStartFLockUnLockLogicManage(); + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + + + ClearCiRevCmdData();/*CIݶ*/ + + return CI_SUCCESS; + } + else if (ATS_CMD_GET_CTRL_POWER == cmdType) + { + SetCtrlPower(virCiID, CONTRAL_POWER_YES, CmdDeviceId, cmdDevType); + /*δ֮ǰҲԻȡȨATSһҪȡRTUĿȨﲻ*/ + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, 0u, 0u, virCiID); + } + else if (ATS_CMD_RELEASE_CTRL_POWER == cmdType) + { + ReleaseCtrlPower(virCiID, CONTRAL_POWER_NO, CmdDeviceId, cmdDevType);/*δ֮ǰҲͷȨ*/ + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, 0u, 0u, virCiID); + } + else + { + continue; + } + } + + /*δϵ*/ + ClearCiRevCmdData();/*CIݶ*/ + + return CI_ERROR; + } + else if (CI_START_FLOCK_ERROR == startFLockFlag) + { + + /*ʧ*/ + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_ERROR; + } + else + { + /*ϵ*/ + } + + /*жϵ*/ + startLockFlag = GetStartLockFlag(); + if (CI_START_LOCK_YES == startLockFlag) + { + for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8); + commandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id; + virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid; + cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType; + if (ATS_CMD_BUTTON_STARTUP_UNLOCK == cmdType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID); + + /*ϵ*/ + SetStartupUnLockLogicManage(); + + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_SUCCESS; + } + else + { + /**/ + } + } + + + /*δϵ*/ + ClearCiRevCmdData();/*CIݶ*/ + + return CI_ERROR; + } + else if (CI_START_LOCK_ERROR == startLockFlag) + { + /*ʧ*/ + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_ERROR; + } + else + { + /*ϵ*/ + } + + /* жԳǷѾԳģʽδԳģʽκδ */ + ciTrainTestState = GetCiTrainTestStatus(); + if ((localCiType == CI_TYPE_SCX) && (CI_TRAIN_TEST_ON != ciTrainTestState)) + { + for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8); + commandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id; + virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid; + cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType; + /* жԳ */ + if (ATS_CMD_APPLY_TRY_TRAIN == cmdType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID); + + /* ʼԳģʽ */ + StartTrianTestManage(); + + ClearCiRevCmdData();/*CIݶ*/ + + return CI_SUCCESS; + } + else if (ATS_CMD_CANCEL_TRY_TRAIN == cmdType) + {/*ŻԳֵԳͣǽ·ǰԳֵؿȡԳ*/ + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID); + + /* ȡԳ */ + StopTrianTestManage(); + + ClearCiRevCmdData();/*CIݶ*/ + + return CI_SUCCESS; + } + else if (ATS_CMD_CI_MODE_CHANGE == cmdType) + { + /*ŻδԳģʽ֮ǰлȨ*/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + SetVirCImode(virCiID, (UINT8)CmdDeviceId); + ClearCiRevCmdData();/*CIݶ*/ + return CI_SUCCESS; + } + else + { + SetCiModeFlag((UINT8)CmdDeviceId); + ClearCiRevCmdData();/*CIݶ*/ + return CI_SUCCESS; + } + } + else + { + /*δԳģʽЧ*/ + SetErrorData(functionId,CI_DEVICE_TYPE_CMD,cmdType,ETYPE_TRAIN_TEST_OFF,0,ESEND_LEVEL_ATS); + } + } + + /*δϵ*/ + ClearCiRevCmdData();/*CIݶ*/ + + return CI_ERROR; + } + else + { + /**/ + } + + /*жȫվ*/ + /**/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + DealallSwitchYLockOrder_Vir(); + } + else + { + allSwitchYLockFlag = GetAllSwitchYLockFlag(); + if (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockFlag) + {/*ȡ*/ + for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8); + commandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id; + virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid; + cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType; + if (ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE == cmdType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + } + else if (ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO == cmdType) + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȡ*/ + SetCiYLockManage(CI_ALL_SWITCH_YLOCK_NO); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*ʲô*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + } + else if (ATS_CMD_SIGNAL_YINDAO_OPEN == cmdType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID); + /*źſ*/ + SetYLockSignalOpenStateManage(virCiID,CmdDeviceId); + } + else if (ATS_CMD_CI_MODE_CHANGE == cmdType) + {/*վغͽվл20161103*/ + + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID); + + if ((CI_MODE_CI_LOCAL == CmdDeviceId) || (CI_MODE_CONSTRA_LOCAL == CmdDeviceId) || ((CI_MODE_APPLAY_LOCAL == CmdDeviceId))) + {/*ǿվغվءл*/ + SetCiModeFlag((UINT8)CmdDeviceId); + } + } + else + { + SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD, cmdDevType, CmdDeviceId, 0U, (UINT32)AtsOrXianDiToCiCmdStru[ii].CommandType);/*Ч*/ + } + + /*δȡ*/ + ClearCiRevCmdData();/*CIݶ*/ + } + } + else + {/**/ + for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8); + commandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id; + cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType; + virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid; + if (ATS_CMD_SWITCH_ZONGSUO_SET_ONE == cmdType) + { + + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + /*CIݶ*/ + ClearCiRevCmdData(); + + } + else if (cmdType == ATS_CMD_SWITCH_ZONGSUO_SET_TWO) + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /**/ + SetCiYLockManage(CI_ALL_SWITCH_YLOCK_YES); + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + + + + /*CIݶ*/ + ClearCiRevCmdData(); + } + else + { + /*棬ȷǷ*/ + } + } + } + /*û*/ + } + + + /***********************************/ + AtsOrXianDiToCiCmdSum = GetCiRevCmdStruCurSum(); + for (ii = 0u; ii < AtsOrXianDiToCiCmdSum; ii++) + { + /*ǰֽڴ豸IDֽڴ豸*/ + CmdDeviceId = (UINT16)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>16u); + cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8u); /*Ӧ豸*/ + cLogSecSeqDir = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam & 0xFFu); + commandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id; + virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid; + cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType; + trainId = AtsOrXianDiToCiCmdStru[ii].wTrainIdParam; /*صгID*/ + cLogSecSum = AtsOrXianDiToCiCmdStru[ii].chLogicSecSum; + pLogSecIdBuff = AtsOrXianDiToCiCmdStru[ii].wLogicSecData; + recordErrorNum = GetErrorDataCurSum(); + /*յϢж*/ + OrderCheckReVal = CheckIsGeneralOrder(AtsOrXianDiToCiCmdStru[ii].CommandType); + + if(CI_SUCCESS == OrderCheckReVal) + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType,0u,0u,virCiID); + } + switch (AtsOrXianDiToCiCmdStru[ii].CommandType) + { + + case ATS_CMD_ROUTE_PUTONG_SET: + /*·*/ + routeCmdSum++; + /*С4·*/ + if(ATS_ROUTE_SET_PROCESS_MAX >= routeCmdSum) + { + /*ͨ·*/ + belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + SetCommonRouteLogicManage(CmdDeviceId); + } + } + else + { + if(ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > saveRouteCmdSum) + { + /*洢һִ*/ + SaveAtsRouteSetCmdStru[saveRouteCmdSum++] = AtsOrXianDiToCiCmdStru[ii]; + } + } + break; + + case ATS_CMD_ROUTE_YINDAO_SET: + /*·*/ + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + SetLeadRouteLogicManage(CmdDeviceId); + } + break; + + case ATS_CMD_ROUTE_ZONGQUXIAO: + /*ȡ*/ + belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + RouteZongQuXiaoLogicManage(CmdDeviceId); + } + break; + + case ATS_CMD_ROUTE_ZONGRENJIE: + /*˽*/ + belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + RouteZongRenJieLogicManage(CmdDeviceId); + } + break; + + case ATS_CMD_SECTION_FAULT_UNLOCK: + /*ιϽ*/ + PhySecFaultUnlockLogicManage(CmdDeviceId,virCiID); + break; + + case ATS_CMD_SIGNAL_REPEAT_OPEN: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid =GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /*źؿ*/ + RepeatOpenSignalLogicManage(CmdDeviceId); + } + } + break; + + case ATS_CMD_SIGNAL_YINDAO_OPEN: + /*ź*/ + belongVirCIid =GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + OpenLeadSignalLogicManage(CmdDeviceId); + } + break; + + case ATS_CMD_SIGNAL_FENGSUO_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { /*źŷ*/ + belongVirCIid =GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /*źŷ*/ + SetSignalFLockLogicManage(CmdDeviceId); + } + } + break; + + case ATS_CMD_SIGNAL_FENGSUO_CANCEL: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /*źŽ*/ + CancelSignalFLockLogicManage(CmdDeviceId); + } + } + break; + + case ATS_CMD_SWITCH_FENGSUO_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /**/ + SetSwitchFLockLogicManage(CmdDeviceId); + } + } + break; + + case ATS_CMD_SWITCH_FENGSUO_CANCEL: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /**/ + CancelSwitchFLockLogicManage(CmdDeviceId); + } + } + break; + + case ATS_CMD_SWITCH_DINGWEI_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /*ܶλ*/ + SetSwitchPositionLogicManage(CmdDeviceId, SWITCH_POSITION_DINGWEI); + } + } + break; + + case ATS_CMD_SWITCH_FANWEI_SET: + + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /*ܷλ*/ + SetSwitchPositionLogicManage(CmdDeviceId, SWITCH_POSITION_FANWEI); + } + } + break; + + case ATS_CMD_SWITCH_DANSUO_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /**/ + SetSwitchDLockLogicManage(CmdDeviceId); + } + } + break; + + case ATS_CMD_SWITCH_DANSUO_CANCEL: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + /**/ + CancelSwitchDLockLogicManage(CmdDeviceId); + } + } + break; + + case ATS_CMD_AUTO_ROUTE_SET: + /*Զ·*/ + SetAutoRouteLogicManage(CmdDeviceId,virCiID); + break; + + case ATS_CMD_AUTO_ROUTE_CANCEL: + /*ȡԶ·*/ + CancelAutoRouteLogicManage(CmdDeviceId,virCiID); + break; + + case ATS_CMD_AUTO_RETURN_SET: + /*Զ۷*/ + SetAutoReturnLogicManage(CmdDeviceId,virCiID); + break; + + case ATS_CMD_AUTO_RETURN_CANCEL: + /*ȡԶ۷*/ + CancelAutoReturnLogicManage(CmdDeviceId,virCiID); + break; + case ATS_CMD_ALL_AUTO_RETURN_SET: + /*ȫԶ۷*/ + SetAllAutoReturnLogicManage(CmdDeviceId,virCiID); + break; + + case ATS_CMD_ALL_AUTO_RETURN_CANCEL: + /*ȡȫԶ۷*/ + CancelAllAutoReturnLogicManage(CmdDeviceId,virCiID); + break; + + case ATS_CMD_SWIT_QIANG_DINGWEI_ONE: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID); + break; + + case ATS_CMD_SWIT_QIANG_DINGWEI_TWO: + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*ǿⶨλ*/ + (void)ForceSetSwitchPositionManage(CmdDeviceId,SWITCH_POSITION_DINGWEI); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID); + break; + + case ATS_CMD_SWIT_QIANG_FANWEI_ONE: + + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID); + break; + + case ATS_CMD_SWIT_QIANG_FANWEI_TWO: + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId); + if(CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*ǿⷴλ*/ + (void)ForceSetSwitchPositionManage(CmdDeviceId,SWITCH_POSITION_FANWEI); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID); + + break; + + case ATS_CMD_ALL_SIG_BRIGHT_SET_ONE: + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + + break; + + case ATS_CMD_ALL_SIG_BRIGHT_SET_TWO: + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȫ*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + SetVirCIAllSignalBrightState(virCiID,CI_ALL_SIGNAL_BRIGHT_YES); + } + else + { + SetAllSignalBrightFlag(CI_ALL_SIGNAL_BRIGHT_YES); + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + + break; + + case ATS_CMD_ALLSIGBRIGHT_CANCEL_ONE: + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + + break; + + case ATS_CMD_ALLSIGBRIGHT_CANCEL_TWO: + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȫȡ*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + SetVirCIAllSignalBrightState(virCiID,CI_ALL_SIGNAL_BRIGHT_NO); + } + else + { + SetAllSignalBrightFlag(CI_ALL_SIGNAL_BRIGHT_NO); + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + + break; + + case ATS_CMD_RETURN_TO_LIECHE: + /*۷תͨ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + signalOutSecId = GetSignalOutFirstPhySecId(CmdDeviceId); + returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId); + if (0u != returnRouteId) + { + if (ROUTE_TYPE_RETURN == GetConfigRouteType(returnRouteId)) + { + throughRouteId = GetRouteThroughRouteId(returnRouteId);/*ȡ۷·Ӧͨ·ID*/ + returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId);/*ȡ۷·ID*/ + throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId);/*ȡͨ·ID*/ + + if (0u != throughRouteId) + { + if ((throughRouteIdBelongCiId != localCiId) || (returnRouteIdBelongCiId != localCiId)) + {/*۷·ͨ·ڱ*/ + /*¼ATSֵط͵źؿڱźؿ*/ + wATSToCiCmdReturnToTRCurSum = GetATSToCiCmdRtnToTRCurSum(); + pATSToCiCmdReturnToTRData = GetATSorXDToCiCmdRtnToTRData(); + for (cmd_idx = 0u;cmd_idx < wATSToCiCmdReturnToTRCurSum;cmd_idx++) + { + if ((ATS_CMD_RETURN_TO_LIECHE == pATSToCiCmdReturnToTRData[cmd_idx].CommandType) + && (pATSToCiCmdReturnToTRData[cmd_idx].CommandParam == AtsOrXianDiToCiCmdStru[ii].CommandParam)) + {/*źؿѴ*/ + flag = 1; + break; + } + } + if (0u == flag) + {/*źؿӵṹ*/ + ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandType = ATS_CMD_RETURN_TO_LIECHE; + ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandParam = AtsOrXianDiToCiCmdStru[ii].CommandParam; + ATSorXDToCiCmdReturnToTRCurSum++; + } + } + else + { + SetThroughRouteManage(CmdDeviceId); + } + } + } + } + break; + + case ATS_CMD_KOUCHE_SET_ATS: + /*ATS۳ص*/ + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + + if (signalBelongCi == localCiId) + {/*źŻ뱾idͬ*/ + DetainLogicManage(CmdDeviceId,SIGNAL_DETAIN_ATS); + } + else + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE,CmdDeviceId,SIGNAL_DETAIN_ATS,signalBelongCi); + + sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*ȡźŻ۳̵ID*/ + if (0u < sigDetainDriveRelayId) + { + detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId); + } + commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*ͨͨ״̬*/ + if ((TRANSMIT_STATE_BAD == commState) && (detainDriveRelayBelongCi == localCiId) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + {/*ͨ״̬ж źŻ۳̵ڱ̵ּ֧ӿڹܿѴ*/ + SetSignalNeighbourDetainDrive(CmdDeviceId,NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES);/*ÿ۳*/ + } + } + break; + + case ATS_CMD_KOUCHE_CANCEL_ATS: + /*ȡATS۳ؿź*/ + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + if (signalBelongCi == localCiId) + {/*źŻ뱾idͬ*/ + DetainLogicManage(CmdDeviceId,SIGNAL_DETAIN_ATS_NO); + } + else + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE,CmdDeviceId,SIGNAL_DETAIN_ATS_NO,signalBelongCi); + sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*ȡźŻ۳̵ID*/ + if (0u < sigDetainDriveRelayId) + { + detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId); + } + if ((detainDriveRelayBelongCi == localCiId)) + {/*źŻ۳̵ڱ*/ + SetSignalNeighbourDetainDrive(CmdDeviceId,NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO);/*ȡ۳*/ + } + } + break; + + case ATS_CMD_KOUCHE_SET_XIANDI: + /*ֵؿ۳ص*/ + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + + if (signalBelongCi == localCiId) + {/*źŻ뱾idͬ,źŻ۳̵IDڱ*/ + DetainLogicManage(CmdDeviceId,SIGNAL_DETAIN_XIANDI); + } + else + {/*߼˼̵ӿڣұźŻͨжϣ۳̵紫ݿ۳*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE,CmdDeviceId,SIGNAL_DETAIN_XIANDI,signalBelongCi); + + sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*ȡźŻ۳̵ID*/ + if (0u < sigDetainDriveRelayId) + { + detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId); + } + commState = GetLocalCiAndOtherCiTransSta(signalBelongCi);/*ͨͨ״̬*/ + if ((TRANSMIT_STATE_BAD == commState) && (detainDriveRelayBelongCi == localCiId) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + {/*ͨ״̬ж źŻ۳̵ڱ̵ּ֧ӿڹܿѴ*/ + SetSignalNeighbourDetainDrive(CmdDeviceId,NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES);/*ÿ۳*/ + } + + } + break; + + case ATS_CMD_KOUCHE_CANCEL_XIANDI: + /*ȡֵؿ۳ؿź*/ + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + if (signalBelongCi == localCiId) + {/*źŻ뱾idͬ*/ + DetainLogicManage(CmdDeviceId,SIGNAL_DETAIN_XIANDI_NO); + } + else + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE,CmdDeviceId,SIGNAL_DETAIN_XIANDI_NO,signalBelongCi); + sigDetainDriveRelayId = GetSignalDetainDriveRelayId(CmdDeviceId);/*ȡźŻ۳̵ID*/ + if (0u < sigDetainDriveRelayId) + { + detainDriveRelayBelongCi = GetRelayBelongCiId(sigDetainDriveRelayId); + } + if ((detainDriveRelayBelongCi == localCiId)) + {/*źŻ۳̵ڱ*/ + SetSignalNeighbourDetainDrive(CmdDeviceId,NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO);/*ȡ۳*/ + } + } + break; + + case ATS_CMD_PHYSEC_RESET_ONE: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID); + break; + + case ATS_CMD_PHYSEC_RESET_TWO: + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)) + { + checkRetVal = AFFIRM_SUCCESS; + /*μḴλ*/ + SetSectionResetLogicManage(CmdDeviceId, PHYSICAL_SECTION_PRE_RESET_NO); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID); + break; + + case ATS_CMD_BUTTON_SET_STOPCHECK:/*ֹͣ*/ + + /*ֹͣ*/ + SetStopCheckM(); + break; + + case ATS_CMD_BUTTON_CANCEL_STOPCHECK:/*ȡֹͣ*/ + + /*ȡֹͣ*/ + CancelStopCheckM(); + break; + + case ATS_CMD_BUTTON_NONROUTE_SET:/*ǽ·*/ + + /*ǽ·ѡ*/ + SetNonRouteM((UINT8)CmdDeviceId); + break; + + case ATS_CMD_BUTTON_NONROUTE_CANCEL:/*ǽ·ȡ*/ + + /*ȡǽ·*/ + CancelNonRouteM((UINT8)CmdDeviceId); + break; + + case ATS_CMD_BUTTON_NONROUTE_FAULT:/*ǽ·ȡ*/ + + /*ǽ·ȡ*/ + FaultCancelNonRouteM((UINT8)CmdDeviceId); + break; +#if 0 + + /*·dzεĹ*/ + case ATS_CMD_ROUTE_CHANGDIAO_SET:/*·*/ + + /*·*/ + SetZuHeRouteLogicM(CmdDeviceId); + break; +#endif + + case ATS_CMD_APPLY_TRY_TRAIN:/* Գť */ + + /* Գť,÷֧ */ + + break; + case ATS_CMD_CANCEL_TRY_TRAIN:/* Գť */ + + /* Գť */ + StopTrianTestManage(); + break; + case ATS_CMD_LINSHIXIANSU_CLEAR:/*ʱ*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + /*ָȡʱٴ*/ + CancleLinShiXianSuManage_Vir(virCiID); + } + else + { /*ȡʱٴ*/ + (void)CancleLinShiXianSuManage(); + } + break; + case ATS_CMD_CI_MODE_CHANGE: + /* ģʽ */ + if(FUNC_SWITCH_ON == includeVirFlag) + { + SetVirCImode(virCiID,(UINT8)CmdDeviceId); + } + else + { + SetCiModeFlag((UINT8)CmdDeviceId); + } + break; + /* zt ɾش 2022-02-15 */ + case ATS_CMD_AUTO_TRIGGER_SET: + SetAutoTriggerLogicManage(virCiID,AUTO_TRIGGER_SET_YES); + break; + case ATS_CMD_CANCLE_AUTO_TRIGGER_SET: + CancelAutoTriggerLogicManage(virCiID, AUTO_TRIGGER_SET_NO); + break; + case ATS_CMD_SET_UP_OVERLAP: /*ν*/ + OverlapRouteId = AtsOrXianDiToCiCmdStru[ii].OverLapRouteID; + if (0U < OverlapRouteId) + { + SetAtsLockOverlapHaveRouteId(CmdDeviceId, OverlapRouteId); + } + else + { + SetAtsExpectLockOverlapIdProc(CmdDeviceId, ATS_LOCK_OVERLAP); + } + break; + case LABOR_CMD_SET_UP_OVERLAP: /*˹ν*/ + SetAtsExpectLockOverlapIdProc(CmdDeviceId,LABOR_LOCK_OVERLAP); + break; + case LABOR_CMD_CANCEL_OVERLAP_ONE: /*˹һ*/ + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + break; + case LABOR_CMD_CANCEL_OVERLAP_TWO: /*˹ζ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*˹*/ + (void)LaborUnlockOverlapProc((UINT8)CmdDeviceId); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID); + + break; + case ATS_CMD_SWITCH_DINGWEI_TEST_ONE: /*λһ*/ + + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID); + + break; + case ATS_CMD_SWITCH_DINGWEI_TEST_TWO: /*λԶ*/ + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*λ*/ + SetSwitchTestLogicManage(ATS_CMD_SWITCH_DINGWEI_TEST_TWO); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID); + break; + case ATS_CMD_SWITCH_FANWEI_TEST_ONE: /*λһ*/ + + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID); + + break; + case ATS_CMD_SWITCH_FANWEI_TEST_TWO: /*λԶ*/ + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*λ*/ + SetSwitchTestLogicManage(ATS_CMD_SWITCH_FANWEI_TEST_TWO); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID); + break; + case ATS_CMD_SET_PSD_BUTTON_PANGLU: /* վ̨ȫŰť· */ + belongVirCIid = GetPsdbelongVirCIid(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if(CI_SUCCESS == OrderCheckReVal) + { + (void)SetPsdButtonPangluState(CmdDeviceId,PSD_BUTTON_PANGLU_STATE_VALID); + } + break; + case ATS_CMD_CANCEL_PSD_BUTTON_PANGLU: /* رվ̨ȫŰť· */ + belongVirCIid = GetPsdbelongVirCIid(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if(CI_SUCCESS == OrderCheckReVal) + { + (void)SetPsdButtonPangluState(CmdDeviceId,PSD_BUTTON_PANGLU_STATE_INVALID); + } + break; +#if 0 + case ATS_CMD_ONEKEY_OPEN_ALL_GARAGE_DOORS:/*һп*/ + SetAllGrgdoorCmdProcessState(GARAGE_DOOR_CMD_OPEN); + break; + case ATS_CMD_ONEKEY_CLOSE_ALL_GARAGE_DOORS:/*һп*/ + SetAllGrgdoorCmdProcessState(GARAGE_DOOR_CMD_CLOSE); + break; +#endif + case ATS_CMD_SECTION_FENGSUO_SET: /*η*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)) + { + /*η*/ + (void)SetSectionFLockLogicManage(CmdDeviceId); + + } + break; + + case ATS_CMD_SECTION_FENGSUO_CANCEL: /*ν*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)) + { + /*ν*/ + (void)CancelSectionFLockLogicManage(CmdDeviceId); + } + break; + + case ATS_CMD_PHYSEC_PRE_RESET_ONE: /*Ԥλһ*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID); + break; + + case ATS_CMD_PHYSEC_PRE_RESET_TWO: /*Ԥλ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if((CI_TRUE == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)) + { + checkRetVal = AFFIRM_SUCCESS; + /*μԤλ*/ + SetSectionResetLogicManage(CmdDeviceId, PHYSICAL_SECTION_PRE_RESET_YES); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID); + break; + + case ATS_CMD_PHYSEC_GENERAL_RESET_SET: /*ܸλ*/ + /*ܸλ*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + SetPhySecZfwManage(virCiID,CI_PHYSEC_GENERAL_RESET_YES); /*ܸλЧ*/ + } + else + { + SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_YES); + } + break; + case ATS_CMD_PHYSEC_GENERAL_RESET_CANCEL: /*ȡܸλ*/ + /*ȡܸλ*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + SetPhySecZfwManage(virCiID,CI_PHYSEC_GENERAL_RESET_NO); /*ܸλЧ*/ + } + else + { + SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_NO); + } + break; + case ATS_CMD_CICI_NET_TO_RELAY_ONE:/*ӿת̵ӿһ*/ + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + } + break; + case ATS_CMD_CICI_NET_TO_RELAY_TWO:/*ӿת̵ӿڶ*/ + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ü̵ӿڵȷ״̬*/ + SetCiCiRelayInterfConfirmFlag(CICI_RELAY_INTERFACE_CONFIRM_YES); + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + } + break; + case ATS_CMD_PSC_PL_ONE: /*PSC·״̬һȷ*/ + /*һȷID*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + break; + case ATS_CMD_PSC_PL_TWO: /*PSC·״̬ȷ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*PSC·ȷϱ־*/ + SetCiPscPlConfirmFlag(CI_PSC_PL_CONFIRM_YES,CmdDeviceId); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*һȷID*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + break; + case ATS_CMD_QUXIAO_PSC_PL_ONE:/*ȡATS·һȷ*/ + /*һȷID*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + break; + case ATS_CMD_QUXIAO_PSC_PL_TWO: /*ȡATS·ȷ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*PSC·ȡ־*/ + SetCiPscPlConfirmFlag(CI_PSC_PL_CONFIRM_NO,CmdDeviceId); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*һȷID*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsOrXianDiToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + break; + /*Զ·*/ + case ATS_CMD_ROUTE_GROUP_AUTO_SET: + /*Զ·*/ + belongVirCIid = GetGroupAutoRouteBelongVirCIid(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if(CI_SUCCESS == OrderCheckReVal) + { + SetGroupAutoRouteLogicManage(CmdDeviceId); + } + break; + /*Զ·ȡ*/ + case ATS_CMD_ROUTE_GROUP_AUTO_CANCLE: + /*ȡԶ·*/ + belongVirCIid = GetGroupAutoRouteBelongVirCIid(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if(CI_SUCCESS == OrderCheckReVal) + { + CancleGroupAutoRouteLogicManage(CmdDeviceId); + } + break; + + + + case ATS_CMD_SIGNALMAINTAINSTATE_ONE: /*źŻά޵һ*/ + /*һȷID*/ + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + if(CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,checkRetVal,virCiID); + break; + case ATS_CMD_SIGNALMAINTAINSTATE_TWO: /*źŻά޵ƶ*/ + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + if((CI_SUCCESS == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)) + { + SetSignalMaintainState(CmdDeviceId,MAINTAIN_STATE_YES);/*źŻά޵*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*ʧϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + break; + + + + case ATS_CMD_CANCEL_SIG_MAINTAIN_ONE: /*ȡźŻά޵һ*/ + /*һȷID*/ + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + allSignalBrightState = GetALLSignalMaintainState(belongVirCIid);/*鲻ȫվά޵źŻ״̬*/ + if((CI_SUCCESS == OrderCheckReVal)&&(CI_ALL_SIGNAL_BRIGHT_NO == allSignalBrightState)) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,checkRetVal,virCiID); + break; + case ATS_CMD_CANCEL_SIG_MAINTAIN_TWO: /*ȡźŻά޵ƶ*/ + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID,belongVirCIid,cmdType,CmdDeviceId);/*ִܷ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + allSignalBrightState = GetALLSignalMaintainState(belongVirCIid);/*鲻ȫվά޵źŻ״̬*/ + if((CI_SUCCESS == checkRetVal)&&(CI_SUCCESS == OrderCheckReVal)&&(CI_ALL_SIGNAL_BRIGHT_NO == allSignalBrightState)) + { + SetSignalMaintainState(CmdDeviceId,MAINTAIN_STATE_NO);/*ȡźŻά޵*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*ʧϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + break; + /*ȡת޻һ*/ + case ATS_CMD_CANCEL_SW_ALARM_ONE: + /*һ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + break; + /*ȡת޻*/ + case ATS_CMD_CANCEL_SW_ALARM_TWO: + /*һζ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȡת޻״̬*/ + SetCancelOrRcvrBlockLinkSta(CANCEL_SWITCH_BLOCK_LINK); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + + } + else + { + /*ʧϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + break; + /*ָת޻һ*/ + case ATS_CMD_RECOVER_SW_ALARM_ONE: + /*һ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + break; + /*ָת޻*/ + case ATS_CMD_RECOVER_SW_ALARM_TWO: + /*һζ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ûָת޻״̬*/ + SetCancelOrRcvrBlockLinkSta(RECOVER_SWITCH_BLOCK_LINK); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*ʧϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + break; + case ATS_CMD_ROUTE_AUTO_TRIGGER_SET: + SetSigleRouteAutoTriggerManage(virCiID, CmdDeviceId, AUTO_TRIGGER_SET_YES); /*ָ·Զ־*/ + break; + case ATS_CMD_ROUTE_CANCLE_AUTO_TRIGGER: + CancelSigleRouteAutoTrigger(virCiID, CmdDeviceId, AUTO_TRIGGER_SET_NO); /*ȡָ·Զ־*/ + break; + case ATS_CMD_STATION_QK_SET: + SetClearPassenagerManage(CmdDeviceId, ATS_TO_CI_PLATFORM_QK_YES); /*ͱ־*/ + break; + /*¼ WQM 20220303*/ + case ATS_CMD_ROUTE_APPLY: + /*·*/ + routeCmdSum++; + /*С4·*/ + if (ATS_ROUTE_SET_PROCESS_MAX >= routeCmdSum) + { + /*·*/ + belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + RouteApplyLogicManage(CmdDeviceId, trainId); + } + } + else + { + if (ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > saveRouteCmdSum) + { + /*洢һִ*/ + SaveAtsRouteSetCmdStru[saveRouteCmdSum++] = AtsOrXianDiToCiCmdStru[ii]; + } + } + break; + case ATS_CMD_GET_CTRL_POWER: /*lc-20221208ϲ*/ + SetCtrlPower(virCiID, CONTRAL_POWER_YES, CmdDeviceId, cmdDevType);/*ȡȨ*/ + break; + case ATS_CMD_RELEASE_CTRL_POWER: /*lc-20221208ϲ*/ + ReleaseCtrlPower(virCiID, CONTRAL_POWER_NO, CmdDeviceId, cmdDevType);/*ͷȨ*/ + break; + +#if 0 + case ATS_CMD_SET_PHYSEC_ERR: + /* ùг */ + SetBreakPhySecWithTrainInfo(CmdDeviceId, trainId, cTrainDir); + break; + case ATS_CMD_CANCEL_PHYSEC_FIRST: + /* ȡгһ*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID); + break; + case ATS_CMD_CANCEL_PHYSEC_SECOND: + /* TODO: ȡιռö*/ + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetPhySecBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /* ȡг */ + UnLockBreakPhySecWithTrainInfo(CmdDeviceId, trainId, cTrainDir); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID); + break; +#endif + case ATS_CMD_ROUTE_APPLY_CANCLE: + /*ȡԴ*/ + belongVirCIid = GetRouteBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + RouteCancelResLogicManage(CmdDeviceId,trainId); + } + break; + case ATS_CMD_ROUTE_PART_APPLY: + /*벿·*/ + RoutePartApplyLogicManage(cLogSecSeqDir, trainId, cLogSecSum, pLogSecIdBuff); + break; + case ATS_CMD_OPEN_XIANSU_SIGNAL_FIRST: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + if (CI_TRUE == checkRetVal) + { + belongVirCIid =GetSignalBelongVirCiId (CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID); + break; + + case ATS_CMD_OPEN_XIANSU_SIGNAL_SECOND: + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*ź*/ + OpenXianSuSignalLogicManage(CmdDeviceId); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsOrXianDiToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID); + break; + /*ؿ*/ + case ATS_CMD_OPEN_XIANSU_SIGNAL_SPECIAL: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, cmdType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*ź*/ + OpenXianSuSignalLogicManage(CmdDeviceId); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + break; + /*ATSԶ۳*/ + case ATS_CMD_KOUCHE_SET_ATS_AUTO: + { + signalBelongCi = GetSignalBelongCiId(CmdDeviceId); + + if (signalBelongCi == localCiId) + {/*źŻ*/ + /*ATSԶ۳*/ + DetainLogicManage(CmdDeviceId, SIGNAL_DETAIN_ATS_AUTO); + } + else + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_KOUCHE, CmdDeviceId, SIGNAL_DETAIN_ATS_AUTO, signalBelongCi); + } + break; + } + + + + default: + cFunRetVal = VirtualDevCmdProc(CmdDeviceId, AtsOrXianDiToCiCmdStru[ii].CommandType);/*Գ豸״̬*/ + if (CI_ERROR == cFunRetVal) + { + SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD, cmdDevType, CmdDeviceId, 0u, (UINT32)AtsOrXianDiToCiCmdStru[ii].CommandType);/*Ч*/ + } + break; + } + /*cgh-ϲCID-2349-5*/ + SetErrorDataBelongVirCiId(recordErrorNum, virCiID); + } + + ClearCiRevCmdData();/*CIݶ*/ + /*Ľ·*/ + if(0u < saveRouteCmdSum) + { + for(j = 0u; j < saveRouteCmdSum; j++) + { + /**/ + CiRevCmdDataStru[j] = SaveAtsRouteSetCmdStru[j]; + } + /*¼洢һڽ·*/ + CiRevCmdStruCurSum = saveRouteCmdSum; + } + } + return CI_SUCCESS; +} + +/* +* εATSֵصCI +* ˵ void +* ֵ 0u:ʧ +* 1:ɹ +*/ +UINT8 ProcessAtsOrXianDiToCiDataCld(void) +{ + CommandDataStruct* AtsToCiCmdStru = NULL; /*ats*/ + UINT16 AtsToCiCmdSum = 0u; /*ats*/ + UINT16 CmdDeviceId = 0u; /*ats漰豸ID*/ + UINT8 cmdDevType = 0u; /*ats漰豸*/ + UINT32 commandId = 0u; /*id*/ + UINT16 terminalId = 0u; /*նid*/ + UINT16 ii = 0u; /*α*/ + UINT8 checkRetVal = CI_FALSE; + UINT16 jkjRelayId = GetJkjRelayId(); + UINT8 jkjRelayValidFlag = 0u; + + UINT8 localCiId = 0u; /*ID*/ + UINT16 signalOutSecId = 0u; /*źŻⷽ*/ + UINT16 returnRouteId = 0u; /*۷·*/ + UINT16 throughRouteId = 0u; /*ͨ·*/ + UINT8 returnRouteIdBelongCiId = 0u;/*۷·ID*/ + UINT8 throughRouteIdBelongCiId = 0u;/*ͨ·ID*/ + UINT16 cmd_idx = 0u; + UINT16 wATSToCiCmdReturnToTRCurSum = 0u;/*źؿĿ*/ + UINT8 flag = 0u;/*źؿǷѴ洢־*/ + CommandDataStruct* pATSToCiCmdReturnToTRData = NULL;/*źؿ洢ṹ*/ + UINT8 startFLockFlag = 0u; + UINT8 startLockFlag = 0u; + UINT8 allSwitchYLockFlag = 0u; + UINT8 checkReVal = 0u; + UINT16 routeCmdSum = 0u; /*һյĽ·*/ + UINT8 virCiID= 0u; + UINT16 saveRouteCmdSum = 0u; /*洢·*/ + UINT16 j = 0u; + CommandDataStruct SaveAtsRouteSetCmdStru[ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX] = {0}; /*洢atsֵص·*/ + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT16 recordErrorNum = 0u; + UINT8 OrderCheckReVal = 0u; + UINT8 belongVirCIid = 0u; + UINT16 trainId = 0U; + UINT16 OverlapRouteId = 0U; + UINT8 cLogSecSeqDir = CI_SYSTEM_DIRECTION_NONE; /* ߼з */ + UINT8 cLogSecSum = 0U; /*߼*/ + UINT16* pLogSecIdBuff = NULL; /*߼ID*/ + + /*ATS*/ + AtsToCiCmdSum = GetCiRevCmdStruCurSum(); + AtsToCiCmdStru = GetCiRevCmdDataStruct(); + + if (NULL == AtsToCiCmdStru) + { + /*CIδյATS*/ + return CI_ERROR; + } + + jkjRelayValidFlag = GetCiJkjFlag(); + /*Ӧ̵̼Ч״̬*/ + if ((jkjRelayId > 0u) && (JKJ_REYLAY_VALID == jkjRelayValidFlag)) + { + for (ii = 0u; ii < AtsToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8); + commandId = AtsToCiCmdStru[ii].CommandId; + terminalId = AtsToCiCmdStru[ii].termial_id; + virCiID = AtsToCiCmdStru[ii].VirCIid; + trainId = AtsToCiCmdStru[ii].wTrainIdParam; + recordErrorNum = GetErrorDataCurSum(); + if (0u != AtsToCiCmdStru[ii].CommandType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID); + + /*¼*/ + SetErrorData(EFUNC_PARSE_ATS2CI_DATA,CI_DEVICE_TYPE_RELAY,jkjRelayId,ETYPE_JKJ_WORK,RELAY_STATE_DOWN,ESEND_LEVEL_ATS); + + /*CIݶ*/ + ClearCiRevCmdData(); + + /*cgh-ϲCID-2349-5*/ + SetErrorDataBelongVirCiId(recordErrorNum, virCiID); + return CI_ERROR; + } + else + { + /**/ + } + } + } + else + { + ; + } + + startFLockFlag = GetStartFLockFlag(); + if (CI_START_FLOCK_YES == startFLockFlag) + { + for (ii = 0u; ii < AtsToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8); + commandId = AtsToCiCmdStru[ii].CommandId; + terminalId = AtsToCiCmdStru[ii].termial_id; + virCiID = AtsToCiCmdStru[ii].VirCIid; + /*жȫվ*/ + if (ATS_CMD_STARTFLOCK_UNLOCK_ONE == AtsToCiCmdStru[ii].CommandType) + { + /*һID*/ + + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + ClearCiRevCmdData();/*CIݶ*/ + + return CI_SUCCESS; + } + else if (ATS_CMD_STARTFLOCK_UNLOCK_TWO == AtsToCiCmdStru[ii].CommandType) + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȫվ*/ + SetStartFLockUnLockLogicManage(); + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*ûյȷ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + + /*յϢ*/ + + ClearCiRevCmdData();/*CIݶ*/ + + return CI_SUCCESS; + } + else if (ATS_CMD_GET_CTRL_POWER == AtsToCiCmdStru[ii].CommandType) + { + SetCtrlPower(virCiID, CONTRAL_POWER_YES, CmdDeviceId, cmdDevType); + /*δ֮ǰҲԻȡȨATSһҪȡRTUĿȨﲻ*/ + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, 0u, 0u, virCiID); + } + else if (ATS_CMD_RELEASE_CTRL_POWER == AtsToCiCmdStru[ii].CommandType) + { + ReleaseCtrlPower(virCiID, CONTRAL_POWER_NO, CmdDeviceId, cmdDevType);/*δ֮ǰҲͷȨ*/ + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, 0u, 0u, virCiID); + } + else + { + continue; + } + } + + /*δϵ*/ + ClearCiRevCmdData();/*CIݶ*/ + + return CI_ERROR; + } + else if (CI_START_FLOCK_ERROR == startFLockFlag) + { + + /*ʧ*/ + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_ERROR; + } + else + { + /*ϵ*/ + } + + /*жϵ*/ + startLockFlag = GetStartLockFlag(); + if (CI_START_LOCK_YES == startLockFlag) + { + for (ii = 0u; ii < AtsToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8); + commandId = AtsToCiCmdStru[ii].CommandId; + terminalId = AtsToCiCmdStru[ii].termial_id; + virCiID = AtsToCiCmdStru[ii].VirCIid; + if (ATS_CMD_BUTTON_STARTUP_UNLOCK == AtsToCiCmdStru[ii].CommandType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID); + + /*ϵ*/ +#if 0 + StartupUnlockM(); +#endif + SetStartupUnLockLogicManage(); + + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_SUCCESS; + } + else + { + continue; + } + } + + + /*δϵ*/ + ClearCiRevCmdData();/*CIݶ*/ + + return CI_ERROR; + } + else if (CI_START_LOCK_ERROR == startLockFlag) + { + /*ʧ*/ + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_ERROR; + } + else + { + /*ϵ*/ + } + + if(FUNC_SWITCH_ON == includeVirFlag) + { + DealallSwitchYLockOrder_Vir(); + } + else + { + /*жȫվ*/ + allSwitchYLockFlag = GetAllSwitchYLockFlag(); + if (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockFlag) + {/*ȡ*/ + for (ii = 0u; ii < AtsToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8); + commandId = AtsToCiCmdStru[ii].CommandId; + terminalId = AtsToCiCmdStru[ii].termial_id; + virCiID = AtsToCiCmdStru[ii].VirCIid; + if (AtsToCiCmdStru[ii].CommandType == ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE) + { + + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_SUCCESS; + } + else if (ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO == AtsToCiCmdStru[ii].CommandType) + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȡ*/ + SetCiYLockManage(CI_ALL_SWITCH_YLOCK_NO); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + /*ȡһȷID*/ + } + else + { + /*ʲô*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + + /*յϢ*/ + + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_SUCCESS; + } + else if (ATS_CMD_SIGNAL_YINDAO_OPEN == AtsToCiCmdStru[ii].CommandType) + { + /*յϢ*/ + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID); + + + /*źſ*/ + SetYLockSignalOpenStateManage(virCiID,CmdDeviceId); + } + else if (ATS_CMD_CI_MODE_CHANGE == AtsToCiCmdStru[ii].CommandType) + {/*վغͽվл20161103*/ + /*ǰֽڴ豸IDֽڴ豸*/ + + + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID); + + if ((CI_MODE_CI_LOCAL == CmdDeviceId) || (CI_MODE_CONSTRA_LOCAL == CmdDeviceId) ||(CI_MODE_APPLAY_LOCAL == CmdDeviceId)) + {/*ǿվغվءл*/ + /**/ + SetCiModeFlag((UINT8)CmdDeviceId); + } + } + else + { + SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD, cmdDevType, CmdDeviceId, 0U, (UINT32)AtsToCiCmdStru[ii].CommandType);/*Ч*/ + } + } + + /*δȡ*/ + ClearCiRevCmdData();/*CIݶ*/ + + return CI_ERROR; + } + else + {/**/ + for (ii = 0u; ii < AtsToCiCmdSum; ii++) + { + CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8); + commandId = AtsToCiCmdStru[ii].CommandId; + terminalId = AtsToCiCmdStru[ii].termial_id; + virCiID = AtsToCiCmdStru[ii].VirCIid; + if (ATS_CMD_SWITCH_ZONGSUO_SET_ONE == AtsToCiCmdStru[ii].CommandType) + { + + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_SUCCESS; + } + else if (ATS_CMD_SWITCH_ZONGSUO_SET_TWO == AtsToCiCmdStru[ii].CommandType) + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /**/ + SetCiYLockManage(CI_ALL_SWITCH_YLOCK_YES); + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + + /*յϢ*/ + + /*CIݶ*/ + ClearCiRevCmdData(); + + return CI_SUCCESS; + } + else + { + continue; + } + } + + /*û*/ + } + } + + + +/***********************************/ + AtsToCiCmdSum = GetCiRevCmdStruCurSum(); + for (ii = 0u; ii < AtsToCiCmdSum; ii++) + { + /*ǰֽڴ豸IDֽڴ豸*/ + CmdDeviceId = (UINT16)(AtsToCiCmdStru[ii].CommandParam>>16); + cmdDevType = (UINT8)(AtsToCiCmdStru[ii].CommandParam>>8); + commandId = AtsToCiCmdStru[ii].CommandId; + terminalId = AtsToCiCmdStru[ii].termial_id; + virCiID = AtsToCiCmdStru[ii].VirCIid; + trainId = AtsToCiCmdStru[ii].wTrainIdParam; + cLogSecSeqDir = (UINT8)(AtsToCiCmdStru[ii].CommandParam & 0xFFu); + cLogSecSum = AtsToCiCmdStru[ii].chLogicSecSum; + pLogSecIdBuff = AtsToCiCmdStru[ii].wLogicSecData; + + /*յϢ*/ + checkReVal = CheckIsGeneralOrder(AtsToCiCmdStru[ii].CommandType); + if(CI_SUCCESS == checkReVal) + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,0u,0u,virCiID); + } + + switch (AtsToCiCmdStru[ii].CommandType) + { + case ATS_CMD_CI_MODE_CHANGE: + if(FUNC_SWITCH_ON == includeVirFlag) + { + /* ģʽ */ + SetVirCImode(virCiID,(UINT8)CmdDeviceId); + } + else + { + /* ģʽ */ + SetCiModeFlag((UINT8)CmdDeviceId); + } + break; + + case ATS_CMD_ROUTE_PUTONG_SET: + /*·*/ + routeCmdSum++; + /*С4·*/ + if(ATS_ROUTE_SET_PROCESS_MAX >= routeCmdSum) + { + /*ͨ·*/ + SetCommonRouteLogicManage(CmdDeviceId); + } + else + { + if(ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > saveRouteCmdSum) + { + /*洢һִ*/ + SaveAtsRouteSetCmdStru[saveRouteCmdSum++] = AtsToCiCmdStru[ii]; + } + } + break; + + case ATS_CMD_ROUTE_YINDAO_SET: + /*·*/ + SetLeadRouteM(CmdDeviceId); + break; + + case ATS_CMD_ROUTE_ZONGQUXIAO: + /*ȡ*/ + ZongQuXiaoRouteM(CmdDeviceId); + break; + + case ATS_CMD_ROUTE_APPLY_CANCLE: + /*յ0x093ִȡ GC0081-849*/ + ZongQuXiaoRouteM(CmdDeviceId); + break; + + case ATS_CMD_ROUTE_ZONGRENJIE: + /*˽*/ + ZongRenJieRouteM(CmdDeviceId); + break; + + case ATS_CMD_SECTION_FAULT_UNLOCK: + /*ιϽ*/ +#if 0 + SectionFaultUnlockM(CmdDeviceId); +#endif + PhySecFaultUnlockLogicManage(CmdDeviceId,virCiID); + break; + + case ATS_CMD_SIGNAL_REPEAT_OPEN: + + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /*źؿ*/ + RepeatOpenSignalM(CmdDeviceId); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_SIGNAL_YINDAO_OPEN: + /*ź*/ + OpenLeadSignalLogicManage(CmdDeviceId); + break; + + case ATS_CMD_SIGNAL_FENGSUO_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /*źŷ*/ + SetSignalFengSuoM(CmdDeviceId); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_SIGNAL_FENGSUO_CANCEL: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /*źŽ*/ + CancelSignalFengSuoM(CmdDeviceId); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_SWITCH_FENGSUO_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /**/ + SetSwitchFengSuoM(CmdDeviceId); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_SWITCH_FENGSUO_CANCEL: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /**/ + CancelSwitchFengSuoM(CmdDeviceId); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_SWITCH_DINGWEI_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /*ܶλ*/ + SetSwitchPositionM(CmdDeviceId, SWITCH_POSITION_DINGWEI); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_SWITCH_FANWEI_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /*ܷλ*/ + SetSwitchPositionM(CmdDeviceId, SWITCH_POSITION_FANWEI); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_SWITCH_DANSUO_SET: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /**/ + SetSwitchDanSuoM(CmdDeviceId); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_SWITCH_DANSUO_CANCEL: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /**/ + CancelSwitchDanSuoM(CmdDeviceId); + } + else + { + /*ʲô*/ + } + break; + + case ATS_CMD_RETURN_TO_LIECHE: + /*۷תͨ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + signalOutSecId = GetSignalOutFirstPhySecId(CmdDeviceId); + returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId); + if (0u != returnRouteId) + { + if (ROUTE_TYPE_RETURN == GetConfigRouteType(returnRouteId)) + { + throughRouteId = GetRouteThroughRouteId(returnRouteId);/*ȡ۷·Ӧͨ·ID*/ + returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId);/*ȡ۷·ID*/ + throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId);/*ȡͨ·ID*/ + + if (0u != throughRouteId) + { + if ((throughRouteIdBelongCiId != localCiId) || (returnRouteIdBelongCiId != localCiId)) + {/*۷·ͨ·ڱ*/ + /*¼ATSֵط͵źؿڱźؿ*/ + wATSToCiCmdReturnToTRCurSum = GetATSToCiCmdRtnToTRCurSum(); + pATSToCiCmdReturnToTRData = GetATSorXDToCiCmdRtnToTRData(); + for (cmd_idx = 0u; cmd_idx < wATSToCiCmdReturnToTRCurSum; cmd_idx++) + { + if ((ATS_CMD_RETURN_TO_LIECHE == pATSToCiCmdReturnToTRData[cmd_idx].CommandType) + && (pATSToCiCmdReturnToTRData[cmd_idx].CommandParam == AtsToCiCmdStru[ii].CommandParam)) + {/*źؿѴ*/ + flag = 1u; + break; + } + } + if (0u == flag) + {/*źؿӵṹ*/ + ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandType = ATS_CMD_RETURN_TO_LIECHE; + ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandId = AtsToCiCmdStru[ii].CommandId; + ATSorXDToCiCmdRtnToTRDataStru[wATSToCiCmdReturnToTRCurSum].CommandParam = AtsToCiCmdStru[ii].CommandParam; + ATSorXDToCiCmdReturnToTRCurSum++; + } + } + else + { + SetThroughRouteManage(CmdDeviceId); + } + } + } + } + break; + + case ATS_CMD_BUTTON_SET_STOPCHECK:/*ֹͣ*/ + + /*ֹͣ*/ + SetStopCheckFlag(); + break; + + case ATS_CMD_BUTTON_CANCEL_STOPCHECK:/*ȡֹͣ*/ + + /*ȡֹͣ*/ + CancelStopCheckFlag(); + break; + + case ATS_CMD_BUTTON_NONROUTE_SET:/*ǽ·*/ +#if 0 + if (CmdDeviceId == 0u) + { + CmdDeviceId = 1; + } +#endif + /*ǽ·ѡ*/ + SetNonRouteM((UINT8)CmdDeviceId); + break; + + case ATS_CMD_BUTTON_NONROUTE_CANCEL:/*ǽ·ȡ*/ +#if 0 + if (CmdDeviceId == 0u) + { + CmdDeviceId = 1; + } +#endif + /*ȡǽ·*/ + CancelNonRouteM((UINT8)CmdDeviceId); + break; + + case ATS_CMD_BUTTON_NONROUTE_FAULT:/*ǽ·ȡ*/ +#if 0 + if (CmdDeviceId == 0u) + { + CmdDeviceId = 1; + } +#endif + /*ǽ·ȡ*/ + FaultCancelNonRouteM((UINT8)CmdDeviceId); + break; + + case ATS_CMD_PHYSEC_RESET_ONE: + + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + if(CI_TRUE == checkRetVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID); + break; + + case ATS_CMD_PHYSEC_RESET_TWO: + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*μḴλ*/ + SetSectionResetLogicManage(CmdDeviceId, PHYSICAL_SECTION_PRE_RESET_NO); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID); + break; + + case ATS_CMD_ROUTE_CHANGDIAO_SET:/*·*/ + + /*·*/ + SetZuHeRouteLogicM(CmdDeviceId); + break; + + case ATS_CMD_ROUTE_CHANGDIAO_CANCEL:/*ȡ·*/ + + /*ȡ·*/ + CancelZuHeRouteLogicM(CmdDeviceId); + break; + case ATS_CMD_GARAGE_DOOR_OPEN:/*ſ*/ + + /*ſ*/ + SetGarageDoorOpenLogicM(CmdDeviceId); + break; + + case ATS_CMD_GARAGE_DOOR_CLOSE:/*Ź*/ + + /*Ź*/ + SetGarageDoorCloseLogicM(CmdDeviceId); + break; + case ATS_CMD_ROUTE_ZUHELIECHE_SET: /*г·*/ + + /*г·*/ + SetZuHeRouteLogicM(CmdDeviceId); + break; + case ATS_CMD_ROUTE_ZUHELIECHE_CANCEL: /*ȡг·*/ + /*ȡг·*/ + CancelZuHeLieCheRouteLogicM(CmdDeviceId); + break; + /* zt ɾش 2022-02-15 */ + case ATS_CMD_SET_UP_OVERLAP: /*ν*/ + OverlapRouteId = AtsToCiCmdStru[ii].OverLapRouteID; + if (0U < OverlapRouteId) + { + SetAtsLockOverlapHaveRouteId(CmdDeviceId, OverlapRouteId); + } + else + { + SetAtsExpectLockOverlapIdProc(CmdDeviceId, ATS_LOCK_OVERLAP); + } + break; + case LABOR_CMD_SET_UP_OVERLAP: /*˹ν*/ + SetAtsExpectLockOverlapIdProc(CmdDeviceId,LABOR_LOCK_OVERLAP); + break; + case LABOR_CMD_CANCEL_OVERLAP_ONE: /*˹һ*/ + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + + break; + case LABOR_CMD_CANCEL_OVERLAP_TWO: /*˹ζ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*˹*/ + (void)LaborUnlockOverlapProc((UINT8)CmdDeviceId); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID); + break; +#if 0 + case ATS_CMD_ONEKEY_OPEN_ALL_GARAGE_DOORS:/*һп*/ + SetAllGrgdoorCmdProcessState(GARAGE_DOOR_CMD_OPEN); + break; + case ATS_CMD_ONEKEY_CLOSE_ALL_GARAGE_DOORS:/*һп*/ + SetAllGrgdoorCmdProcessState(GARAGE_DOOR_CMD_CLOSE); + break; +#endif + case ATS_CMD_SECTION_FENGSUO_SET: /*η*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /*η*/ + (void)SetSectionFLockLogicManage(CmdDeviceId); + } + break; + + case ATS_CMD_SECTION_FENGSUO_CANCEL: /*ν*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + /*ν*/ + (void)CancelSectionFLockLogicManage(CmdDeviceId); + } + break; + + case ATS_CMD_PHYSEC_PRE_RESET_ONE: /*Ԥλһ*/ + /*һȷID*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + if(CI_TRUE == checkRetVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,checkRetVal,virCiID); + break; + + case ATS_CMD_PHYSEC_PRE_RESET_TWO: /*Ԥλ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, CmdDeviceId); + + if(CI_TRUE == checkRetVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*μԤλ*/ + SetSectionResetLogicManage(CmdDeviceId, PHYSICAL_SECTION_PRE_RESET_YES); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,checkRetVal,virCiID); + break; + + case ATS_CMD_CANCEL_XICHE: /*ȡϴ*/ + CancelWashWorkLogicM(); + break; + + case ATS_CMD_PHYSEC_GENERAL_RESET_SET: /*ܸλ*/ + /*ܸλ*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + SetPhySecZfwManage(virCiID,CI_PHYSEC_GENERAL_RESET_YES); /*ܸλЧ*/ + } + else + { + SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_YES); /*ܸλЧ*/ + } + break; + + case ATS_CMD_PHYSEC_GENERAL_RESET_CANCEL: /*ȡܸλ*/ + /*ȡܸλ*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + SetPhySecZfwManage(virCiID,CI_PHYSEC_GENERAL_RESET_NO); + } + else + { + SetPhySecGeneralResetFlag(CI_PHYSEC_GENERAL_RESET_NO); /*ܸλЧ*/ + } + break; + case ATS_CMD_CICI_NET_TO_RELAY_ONE:/*ӿת̵ӿһ*/ + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + } + break; + case ATS_CMD_CICI_NET_TO_RELAY_TWO:/*ӿת̵ӿڶ*/ + { + + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ü̵ӿڵȷ״̬*/ + SetCiCiRelayInterfConfirmFlag(CICI_RELAY_INTERFACE_CONFIRM_YES); + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*ʲô*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + } + break; + /*ȡת޻һ*/ + case ATS_CMD_CANCEL_SW_ALARM_ONE: + /*һ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + break; + /*ȡת޻*/ + case ATS_CMD_CANCEL_SW_ALARM_TWO: + /*һζ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȡת޻״̬*/ + SetCancelOrRcvrBlockLinkSta(CANCEL_SWITCH_BLOCK_LINK); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + break; + /*ָת޻һ*/ + case ATS_CMD_RECOVER_SW_ALARM_ONE: + /*һ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + break; + /*ָת޻*/ + case ATS_CMD_RECOVER_SW_ALARM_TWO: + /*һζ*/ + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ûָת޻״̬*/ + SetCancelOrRcvrBlockLinkSta(RECOVER_SWITCH_BLOCK_LINK); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,AtsToCiCmdStru[ii].CommandType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + break; + case ATS_CMD_ROUTE_APPLY: + /*·*/ + routeCmdSum++; + /*С4·*/ + if (ATS_ROUTE_SET_PROCESS_MAX >= routeCmdSum) + { + /*·*/ + RouteApplyLogicManage(CmdDeviceId, trainId); + } + else + { + if (ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > saveRouteCmdSum) + { + /*洢һִ*/ + SaveAtsRouteSetCmdStru[saveRouteCmdSum++] = AtsToCiCmdStru[ii]; + } + } + break; + case ATS_CMD_ALL_SIG_BRIGHT_SET_ONE: + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID); + break; + + case ATS_CMD_ALL_SIG_BRIGHT_SET_TWO: + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + /*ȫ*/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + SetVirCIAllSignalBrightState(virCiID, CI_ALL_SIGNAL_BRIGHT_YES); + } + else + { + SetAllSignalBrightFlag(CI_ALL_SIGNAL_BRIGHT_YES); + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_SUCCESS, virCiID); + + } + else + { + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_FAIL, virCiID); + } + + break; + + case ATS_CMD_ALLSIGBRIGHT_CANCEL_ONE: + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, AFFIRM_SUCCESS, virCiID); + break; + + case ATS_CMD_ALLSIGBRIGHT_CANCEL_TWO: + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + /*ȫȡ*/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + SetVirCIAllSignalBrightState(virCiID, CI_ALL_SIGNAL_BRIGHT_NO); + } + else + { + SetAllSignalBrightFlag(CI_ALL_SIGNAL_BRIGHT_NO); + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_SUCCESS, virCiID); + } + else + { + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, AFFIRM_FAIL, virCiID); + } + break; + case ATS_CMD_OPEN_XIANSU_SIGNAL_FIRST: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID); + break; + + case ATS_CMD_OPEN_XIANSU_SIGNAL_SECOND: + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*ź*/ + OpenXianSuSignalLogicManage(CmdDeviceId); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID); + break; + /*ؿ*/ + case ATS_CMD_OPEN_XIANSU_SIGNAL_SPECIAL: + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, CmdDeviceId); + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSignalBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*ź*/ + OpenXianSuSignalLogicManage(CmdDeviceId); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + break; + case ATS_CMD_SWIT_QIANG_DINGWEI_ONE: + /*ǿⶨλһ*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID); + break; + + case ATS_CMD_SWIT_QIANG_DINGWEI_TWO: + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*ǿⶨλ*/ + (void)ForceSetSwitchPositionManage(CmdDeviceId, SWITCH_POSITION_DINGWEI); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID); + break; + + case ATS_CMD_SWIT_QIANG_FANWEI_ONE: + /*ǿⷴλһ*/ + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_FIRST, checkRetVal, virCiID); + break; + + case ATS_CMD_SWIT_QIANG_FANWEI_TWO: + checkRetVal = CheckSecondOrderValid(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, virCiID); + if (CI_SUCCESS == checkRetVal) + { + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, CmdDeviceId); + + if (CI_TRUE == checkRetVal) + { + belongVirCIid = GetSwitchBelongVirCiId(CmdDeviceId); + OrderCheckReVal = CheckOrderWhetherDoing(virCiID, belongVirCIid, AtsToCiCmdStru[ii].CommandType, CmdDeviceId); + if (CI_SUCCESS == OrderCheckReVal) + { + checkRetVal = AFFIRM_SUCCESS; + /*ǿⷴλ*/ + (void)ForceSetSwitchPositionManage(CmdDeviceId, SWITCH_POSITION_FANWEI); + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + } + else + { + checkRetVal = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(commandId, CmdDeviceId, cmdDevType, terminalId, AtsToCiCmdStru[ii].CommandType, RESPONSE_SECOND, checkRetVal, virCiID); + + break; + case ATS_CMD_ROUTE_PART_APPLY: + /*벿·*/ + RoutePartApplyLogicManageCLD(cLogSecSeqDir, trainId, cLogSecSum, pLogSecIdBuff); + break; + case ATS_CMD_GET_CTRL_POWER: + /*ȡȨ*/ + SetCtrlPower(virCiID, CONTRAL_POWER_YES, CmdDeviceId, cmdDevType); + break; + case ATS_CMD_RELEASE_CTRL_POWER: + /*ͷȨ*/ + ReleaseCtrlPower(virCiID, CONTRAL_POWER_NO, CmdDeviceId, cmdDevType); + break; + default: + { + SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD,0u,0u,0u,AtsToCiCmdStru[ii].CommandType);/*Ч*/ + break; + } + + } + /*cgh-ϲCID-2349-5*/ + SetErrorDataBelongVirCiId(recordErrorNum, virCiID); + } + + ClearCiRevCmdData();/*CIݶ*/ + /*Ľ·*/ + if(0u < saveRouteCmdSum) + { + for(j = 0u; j < saveRouteCmdSum; j++) + { + /**/ + CiRevCmdDataStru[j] = SaveAtsRouteSetCmdStru[j]; + } + /*¼洢һڽ·*/ + CiRevCmdStruCurSum = saveRouteCmdSum; + } + + return CI_SUCCESS; +} + +/* +* ںϹ״̬ +* ˵ void +* ֵ void +*/ +void OcProcessMergeABGdState(void) +{ + UINT16 ii = 0u; + for (ii = 0u; ii < m_GdNum; ii++) + { + if ((OC_BOARD_STATE_NORMAL == m_Gds[ii].BoardState1) && (OC_BOARD_STATE_NORMAL == m_Gds[ii].BoardState2)) + {/*ϵ忨״̬ʵʩں*/ + if ((OC_GD_STATE_OCCUPY == m_Gds[ii].GdState1) && (OC_GD_STATE_OCCUPY == m_Gds[ii].GdState2)) + {/*1ϵ2ϵռ*/ + m_Gds[ii].GdMergeState = OC_GD_STATE_OCCUPY; + } + else if ((OC_GD_STATE_IDLE == m_Gds[ii].GdState1) && (OC_GD_STATE_OCCUPY == m_Gds[ii].GdState2)) + {/*1ϵ壬2ϵռ*/ + m_Gds[ii].GdMergeState = OC_GD_STATE_IDLE; + } + else if ((OC_GD_STATE_OCCUPY == m_Gds[ii].GdState1) && (OC_GD_STATE_IDLE == m_Gds[ii].GdState2)) + {/*1ϵռ,2ϵ*/ + m_Gds[ii].GdMergeState = OC_GD_STATE_IDLE; + } + else if ((OC_GD_STATE_IDLE == m_Gds[ii].GdState1) && (OC_GD_STATE_IDLE == m_Gds[ii].GdState2)) + {/*1ϵ,2ϵ*/ + m_Gds[ii].GdMergeState = OC_GD_STATE_IDLE; + } + else + {/*Ƿռ*/ + m_Gds[ii].GdMergeState = OC_GD_STATE_OCCUPY; + } + } + else if ((OC_BOARD_STATE_NORMAL != m_Gds[ii].BoardState1) && (OC_BOARD_STATE_NORMAL == m_Gds[ii].BoardState2)) + {/*1ϵϣ2ϵ2ϵ*/ + if ((OC_GD_STATE_IDLE == m_Gds[ii].GdState2) || (OC_GD_STATE_OCCUPY == m_Gds[ii].GdState2) || + (OC_GD_STATE_FAULT == m_Gds[ii].GdState2)) + { + m_Gds[ii].GdMergeState = m_Gds[ii].GdState2; + } + else + {/*Ƿռ*/ + m_Gds[ii].GdMergeState = OC_GD_STATE_OCCUPY; + } + } + else if (OC_BOARD_STATE_NORMAL == m_Gds[ii].BoardState1) + {/*1ϵ2ϵϣ1ϵ*/ + if ((OC_GD_STATE_IDLE == m_Gds[ii].GdState1) || (OC_GD_STATE_OCCUPY == m_Gds[ii].GdState1) || + (OC_GD_STATE_FAULT == m_Gds[ii].GdState1)) + { + m_Gds[ii].GdMergeState = m_Gds[ii].GdState1; + } + else + {/*Ƿռ*/ + m_Gds[ii].GdMergeState = OC_GD_STATE_OCCUPY; + } + } + else + {/*1ϵ2ϵϣȫ*/ + m_Gds[ii].GdMergeState = OC_GD_STATE_FAULT; + } + + } +} + +/* +* OCABϵɼ״̬ +* ˵ void +* ֵ void +*/ +void OcResetGdABCollState(void) +{ + UINT16 ii = 0u; + for (ii = 0u; ii < m_GdNum; ii++) + { + m_Gds[ii].GdState1 = OC_GD_STATE_OCCUPY; + m_Gds[ii].GdState2 = OC_GD_STATE_OCCUPY; + } +} + +/* +* ¾OCɼ״̬ +* ˵ void +* ֵ void +*/ +void OcUpdateSpecificGdCollState(void) +{ + UINT16 phySecCurSum = 0u; /*Ŀ*/ + UINT8 localCiId = 0u; /*ID*/ + + UINT16 phySecId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*ID*/ + UINT16 jj = 0u; + + phySecCurSum = GetPhySecCurSum(); /*ȡ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + for (jj = 0u; jj < m_GdNum; jj++) + { + phySecId = m_Gds[jj].GdDeviceId; + belongCiId = GetPhySecBelongCiId(phySecId); + if ((0u == phySecId) || (phySecId > PHYSICAL_SECTION_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + continue; + } + if (OC_GD_STATE_OCCUPY == m_Gds[jj].GdMergeState) + { + SetPhySecCurOcGdOccupyState(phySecId, SECTION_OCCUPY_YES);/*ռ*/ +#ifdef USE_OC_GD_AS_PHY_COLL + + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ռ*/ +#endif + } + else if (OC_GD_STATE_IDLE == m_Gds[jj].GdMergeState) + { + SetPhySecCurOcGdOccupyState(phySecId, SECTION_OCCUPY_NO);/**/ +#ifdef USE_OC_GD_AS_PHY_COLL + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_NO);/**/ +#endif + } + else if (OC_GD_STATE_FAULT == m_Gds[jj].GdMergeState) + { + SetPhySecCurOcGdOccupyState(phySecId, SECTION_OCCUPY_FAULT); + } + else + { + /*Чֵռ*/ + SetPhySecCurOcGdOccupyState(phySecId, SECTION_OCCUPY_YES);/*ռ*/ +#ifdef USE_OC_GD_AS_PHY_COLL + SetPhySecCurOccupyState(phySecId, SECTION_OCCUPY_YES);/*ռ*/ +#endif + } + } + +} + + +/* +* ںϼϵͳOCϵͳβɼ״̬ +* ˵ void +* ֵ void +*/ +void MergeAxleOcGdPhyState(void) +{ + UINT16 ii = 0u; + UINT16 phyId = 0u; + UINT8 belongCiId = 0u; + UINT8 localCiId = 0u; + UINT8 axisGdState = SECTION_OCCUPY_YES; + UINT8 ocGdState = SECTION_OCCUPY_YES; + for (ii = 0u; ii < GetPhySecCurSum(); ii++) + { + phyId = GetPhySecId(ii); + belongCiId = GetPhySecBelongCiId(phyId); + localCiId = GetSystemParaLocalCiId(); + if (belongCiId == localCiId) + { + axisGdState = GetPhySecCurAxisGdOccupyState(phyId); + + ocGdState = GetPhySecCurOcGdOccupyState(phyId); + + if ((SECTION_OCCUPY_FAULT != axisGdState) && (SECTION_OCCUPY_FAULT != ocGdState)) + {/*ɼĹ״̬ocɼĹ״̬ǹ̬ں*/ + if (axisGdState == ocGdState) + { + SetPhySecCurOccupyState(phyId, ocGdState); + } + else + {/*һ£ռ*/ + SetPhySecCurOccupyState(phyId, SECTION_OCCUPY_YES); + } + } + else if ((SECTION_OCCUPY_FAULT == axisGdState) && (SECTION_OCCUPY_FAULT != ocGdState)) + {/*ɼ״̬ϣocɼϣoc*/ + SetPhySecCurOccupyState(phyId, ocGdState); + } + else if ((SECTION_OCCUPY_FAULT != axisGdState) && (SECTION_OCCUPY_FAULT == ocGdState)) + {/*ɼ״̬ϣocɼϣż*/ + SetPhySecCurOccupyState(phyId, axisGdState); + } + else if ((SECTION_OCCUPY_FAULT == axisGdState) && (SECTION_OCCUPY_FAULT == ocGdState)) + {/*ɼ״̬ϣocɼϣţռ*/ + SetPhySecCurOccupyState(phyId, SECTION_OCCUPY_YES); + } + else + { + /**/ + SetPhySecCurOccupyState(phyId, SECTION_OCCUPY_YES); + } + } + } +} + +/* +* OCβɼ״̬ +* ˵ void +* ֵ void +*/ +void OcPhyStateToDeviceStatePro(void) +{ + /*ȴOCεں*/ + OcProcessMergeABGdState(); + + /*OCABϵɼ״̬*/ + OcResetGdABCollState(); + + /*Ѵoc忨ɼoc״̬ΪOC״̬*/ + OcUpdateSpecificGdCollState(); +} + +/* +* 豸߼״̬ +* ˵ void +* ֵ void +*/ +void ProcessDeviceLogicState(void) +{ + UINT8 chLineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ*/ + UINT8 acFty = GetCiFunctionSwitchConfig(FUNC_SWITCH_AC_FACTORY); + UINT8 CiPattern = 0u; + UINT8 chDsnLinSwitch = 0U; + + chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + CiPattern = GetLocalCiPattern(); + + if (CI_PATTERN_TRADITIONAL == CiPattern)/*ͳ*/ + { + /*źŻ߼״̬*/ + SignalRelayToDeviceStateProc(); + } + else if (CI_PATTERN_FULL_ELECTRONIC == CiPattern)/*ȫ*/ + { + if (FUNC_SWITCH_ON == chDsnLinSwitch) + { + SignalRelayToDeviceStateProc(); + } + else + { + /*ȫģʽ£źŻ߼״̬*/ + /******************************************************************************/ + OcSignalDeviceInput();/*ocźŻ豸״̬*/ + } + } + else + { + /**/ + } + + if ((m_GdNum > 0u)|| ((AXIS_TYPE_YONGLIE==acFty)|| (AXIS_TYPE_KEANDA == acFty))) /*йӿ*/ + { + /*¹βɼ״̬*/ + OcPhyStateToDeviceStatePro(); + + /*ںϼռúOCռ*/ + MergeAxleOcGdPhyState(); + } + else /*޹*/ + { + /*ռ״̬*/ + PhySecRelayToDeviceStateProc(); + } + + /*µ߼״̬*/ + if (CI_TRADITION_RAILWAY == chLineIdentity) + {/*ǹ콻ͨ·*/ + + if (CI_PATTERN_TRADITIONAL == CiPattern)/*ͳ*/ + { + SwitchRelayToDeviceStateProc(); + } + else if (CI_PATTERN_FULL_ELECTRONIC == CiPattern)/*ȫ*/ + { + if (FUNC_SWITCH_ON == chDsnLinSwitch) + { + SwitchRelayToDeviceStateProc(); + } + else + { + /*ȫģʽ£µ߼״̬*/ + /******************************************************************************/ + OcSwitchDeviceInput(); + } + } + else + { + /**/ + } + }/* zt ɾش 2022-02-15 */ + else + { + + } + /*ȫ*/ + if(CI_PATTERN_FULL_ELECTRONIC == CiPattern) + { + /*߼״̬*/ + ConnectLineRelayToDevStateProc(); + } + + /*߼״̬*/ + PsdRelayToDeviceStateProc(); + + /*½ͣť߼״̬*/ + (void)EsbRelayToDeviceStateProc(); + +#if 0 + /*״̬תƴ*/ + PsdStateTransferProc(); +#endif + + /* spks */ + (void)SpksRelayToDeviceStateProc(); + + /*źŻʱٴ*/ + SignalLinShiXianSuFlagCalculate(); + + /*Ŵ*/ + (void)GaragedoorRelayToDevStaProc(); + + /*ϴ*/ + (void)WashMachineToDeviceStateProc(); + + /*Ŵ*/ + FloodGateRelayToDeviceStateProc(); + + /*ͬ⴦*/ + RouteDCTYRelayToDeviceStateProc(); + + if (FUNC_SWITCH_ON == chDsnLinSwitch) + { + /*豸̵*/ + RvrsCutRlyToDvicSttPrc(); + } +} + + +/* +* λ߼ +* ˵ +* const UINT8 systemType, ϵͳ豸 +* const UINT8* maskBuf, λ +* const UINT16 maskSum, λ +* ֵ 0u: ʧ +* 1: ɹ +*/ +UINT8 MaskDataProcess(const UINT8 systemType,const UINT8* maskBuf, const UINT16 maskSum) +{ + UINT16 maskId = 0u; /*λID*/ + UINT16 index = 0u; /*±*/ + UINT8 DeviceType = 0u; /*豸*/ + UINT8 MaskType = 0u; /*λ*/ + UINT16 DeviceId = 0u; /*豸ID*/ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; + UINT16 maskConfigSum = 0u; /*λλ*/ + UINT8 indicatorContainRelaySum = 0u;/*ʾư̵Ŀ*/ + UINT16* indicatorContainRelayIdBuf = NULL;/*ʾư̵ID*/ + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + + UINT8 funcSwitchJumpLockDriveSwitch = 0u;/*ܿأԾǷ*/ + UINT32 curCycle = 0u;/*ǰ*/ + + UINT16 phyNum = 0u; + UINT16 phyId = 0u; + UINT16 axisSecId = 0u;/*id*/ + UINT8 phyBelongCiId = 0u; + UINT8 ciid = 0u; + UINT16 phyAxisSecNum = 0u; + UINT16 *pPhyAxisIDBuf = NULL; + UINT16 numAxisHaveJumpLockApply = 0u;/*Ծ*/ + UINT8 applyFlag = 0u;/*־*/ + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 signalLightExtinctRet = 0U; + UINT8 cLogSecTsrState = LOGSEC_LSXS_SET_STATE_NO; + UINT8 chRtnIndcDevId = 0U;/*۷ָʾ豸ID*/ + + ciid = GetSystemParaLocalCiId();/*ȡID*/ + phyNum = GetPhySecCurSum(); + + funcSwitchJumpLockDriveSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH); + curCycle = Get2oo2CurCycleNum(); + + maskConfigSum = GetReceiveMaskSum(systemType); + if (maskConfigSum > maskSum) + { + returnValue = CI_ERROR; + return returnValue; + } + + for (ii = 0u; ii < maskConfigSum; ii++) + { + maskId = (UINT16)(ii + 1U);/*λID*/ + index = GetMaskIndex(CI_SYSTEM_TYPE_ZC, CI_SYSTEM_TYPE_CI, maskId); + if (index != 0u) + { + DeviceType = GetReceiveMaskDeviceType(systemType, index); + DeviceId = GetReceiveMaskDeviceId(systemType, index); + MaskType = GetReceiveMaskType(systemType, index); + } + else + { + continue; + } + + + switch (DeviceType) + { + case CI_DEVICE_TYPE_SWITCH: + /*豸*/ + + break; + case CI_DEVICE_TYPE_SIGNAL: + /*źŻ豸*/ + switch (MaskType) + { + case MASK_TYPE_SIGNAL_OPENSTATE:/*źŻ״̬λ*/ + break; + case MASK_TYPE_SIGNAL_LIGHTSTATE:/*źŻ״̬λ*/ + if (1U == maskBuf[ii]) + {/*źŻǿ*/ + + signalLightExtinctRet = SetSignalLightExtinctState(DeviceId, SIGNAL_LIGHT_EXTICT_STATE_NO); + if (CI_ERROR == signalLightExtinctRet) + { + /*źŻʧ*/ + } + } + else + {/*źŻ*/ + + signalLightExtinctRet = SetSignalLightExtinctState(DeviceId, SIGNAL_LIGHT_EXTICT_STATE_YES); + if (CI_ERROR == signalLightExtinctRet) + { + /*źŻʧ*/ + } + } + break; + case MASK_ZC_CI_TYPE_SIGNAL_OCCUPYED:/*ͨųѹźŻλ*/ + if (1U == maskBuf[ii]) + {/*ͨųѹźŻ*/ + + (void)SetSignalCrossState(DeviceId, SIGNAL_CROSS_STATE_YES);/*ͨųѹźŻ*/ + } + else + { + + (void)SetSignalCrossState(DeviceId, SIGNAL_CROSS_STATE_NO);/*ͨųδѹźŻ*/ + } + break; + case MASK_ZC_CI_SIG_ENGINEERV_NEAR:/*źŻ̳ӽλ*/ + if (1u == maskBuf[ii]) + { + + SetSigEngineerVehicleNearSte(DeviceId, SIG_ENGINEERVEHICNEAR_STE_YES);/*źŻ̳ӽλ*/ + } + else + { + + SetSigEngineerVehicleNearSte(DeviceId, SIG_ENGINEERVEHICNEAR_STE_NO); + } + break; + case MASK_CI_ZC_SIG_ENGINCROSS_STE:/*źŻ̳ѹرλ*/ + break; + default: + returnValue = CI_ERROR; + break; + } + break; + case CI_DEVICE_TYPE_PHYSEC: + /*豸*/ + + switch (MaskType) + { + case MASK_TYPE_LOGICSECTION_UTOCCUPY:/*ͨųռλ*/ + break; + case MASK_TYPE_LOGICSECTION_CTOCCUPY:/*ͨųռλ*/ + break; + case MASK_TYPE_PHYSECTION_ROUTELOCK:/*ν·λ*/ + break; + case MASK_TYPE_AXISSECTION_ARB:/*ARB״̬λ*/ + if (1U == maskBuf[ii]) + { + SetAxisSecArbState(DeviceId, AXIS_SECTION_ARB_YES);/*üARB*/ + } + else + { + SetAxisSecArbState(DeviceId, AXIS_SECTION_ARB_NO);/*üδARB*/ + } + break; + case MASK_TYPE_LIECHE_STOPSTATE:/*гͣϢ״̬λ*/ + if (maskBuf[ii] == 1u) + {/*гͣ*/ + + SetPhySecStopSteadyFlag(DeviceId, PHYSICAL_SECTION_STOPSTEADY_YES);/*ͣ*/ + } + else + { + + SetPhySecStopSteadyFlag(DeviceId, PHYSICAL_SECTION_STOPSTEADY_NO);/*δͣ*/ + } + break; + case MASK_TYPE_PHYSECTION_JUMPLOCK_APPLY:/*Ծλ*/ + if (1u == maskBuf[ii]) + {/*ZCԾ*/ + SetAxisSecJumpLockApplyFlag(DeviceId,AXIS_SECTION_JUMPLOCK_APPLY_YES);/*üԾ*/ + (void)SetAxisSecJumpLockApplyCylce(DeviceId,curCycle);/*üԾں*/ + } + else + { + SetAxisSecJumpLockApplyFlag(DeviceId,AXIS_SECTION_JUMPLOCK_APPLY_NO);/*üԾ*/ + } + break; + case MASK_TYPE_PHYSECTION_JUMPLOCK_CANCEL:/*Ծȡλ*/ + if (1u == maskBuf[ii]) + {/*ZCȡԾ*/ + (void)SetAxisSecJLockCancelApplyFlag(DeviceId,AXSEC_CANCEL_JUMPLOCK_APPLY_YES);/*üȡԾ*/ + (void)SetAxisSecJumpLockApplyCylce(DeviceId, 0U);/*Ծں*/ + } + else + { + (void)SetAxisSecJLockCancelApplyFlag(DeviceId,AXSEC_CANCEL_JUMPLOCK_APPLY_NO);/*üȡԾ*/ + } + break; + default: + returnValue = CI_ERROR; + break; + } + break; + case CI_DEVICE_TYPE_LOGICSEC: + /*߼豸*/ + switch (MaskType) + { + case MASK_TYPE_LOGICSECTION_UTOCCUPY:/*߼ηͨųռλ*/ + if (maskBuf[ii] == 1u) + {/*߼״̬Ϊ*/ + + /*ͨųռλѾÿлͨųռã*/ + SetLogSecMask(DeviceId ,LOGIC_MASK_NO); + } + else + { + SetLogSecMask(DeviceId ,LOGIC_MASK_UT); + } + break; + case MASK_TYPE_LOGICSECTION_CTOCCUPY:/*߼ͨųռλ*/ + if (maskBuf[ii] == 1u) + {/*߼״̬Ϊ*/ + SetLogSecMask(DeviceId ,LOGIC_MASK_NO); + + } + else + { + SetLogSecMask(DeviceId ,LOGIC_MASK_CT); + } + break; + + case MASK_TYPE_LOGICSECTION_TXOCCUPY:/*߼ͨųռλ,A by yt 2022519*/ /*TSCIϲ 20221208-lc*/ + if (1u == maskBuf[ii]) + { + SetLogSecTXOccupyState(DeviceId, LOGICSECTION_OCCUPY_TX); + + } + else + { + SetLogSecTXOccupyState(DeviceId, LOGICSECTION_OCCUPY_NO_TX); + } + break; + + case MASK_TYPE_LOGICSECTION_LINSHIXIANSU_SET:/*߼ʱλ*/ + if(1u == maskBuf[ii]) + {/*߼δʱ*/ + SetLogSecLinShiXianSuState(DeviceId, LOGSEC_LSXS_SET_STATE_NO); + } + else + {/*߼ʱ*/ + cLogSecTsrState = GetLogSecLinShiXianSuSetState(DeviceId); + + SetLogSecLinShiXianSuState(DeviceId, LOGSEC_LSXS_SET_STATE_YES); + + if (LOGSEC_LSXS_SET_STATE_YES != cLogSecTsrState) + { + ClearLgcSecBelongRtXsCfm(DeviceId); + } + } + break; + + default: + returnValue = CI_ERROR; + break; + } + break; + case CI_DEVICE_TYPE_OVERLAP: + /*豸*/ + + break; + case CI_DEVICE_TYPE_PLATFORM: + /*վ̨豸*/ + switch (MaskType) + { + case MASK_TYPE_PLAT_AUTORETURNSIG_FLASH:/*վ̨۷λ*/ + case MASK_TYPE_PLAT_AUTORETURNSIG_STEADY:/*վ̨۷ȵλ*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + DealAutoReturnMask_UseVirCI(DeviceId,maskBuf,MaskType,ii); + } + else + { + for (jj = 0u; jj < GetIndicatorCurSum(); jj++ ) + { + if ((DeviceId == GetIndicatorId(jj)) + && (INDICATOR_TYPE_EXPRESS_RETURN == GetIndicatorType(DeviceId))) + {/*豸IDӦָʾΪ۷*/ + indicatorContainRelaySum = GetIndicatorRelaySum(DeviceId); + indicatorContainRelayIdBuf = GetIndicatorRelayIdBuf(DeviceId); + if ((3u != indicatorContainRelaySum)||(NULL == indicatorContainRelayIdBuf)) + {/*̵ݴ*/ + + returnValue = CI_ERROR; + break; + } + else + {/*̵ȷ*/ + chRtnIndcDevId = GetIndicatorRelNonReturnId(DeviceId); + if (MaskType == MASK_TYPE_PLAT_AUTORETURNSIG_FLASH) + {/*λһ̵λ*/ + + if (maskBuf[ii] == 1u) + {/**/ + SetAutoRtnIndictFlashState(chRtnIndcDevId,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*״̬Ч*/ + } + else + {/**/ + SetAutoRtnIndictFlashState(chRtnIndcDevId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*״̬Ч*/ + } + } + else + {/*ȵλڶ̵λ*/ + + if (maskBuf[ii] == 1u) + {/*ȵ*/ + SetAutoRtnIndictSteadyState(chRtnIndcDevId,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*ȵ״̬Ч*/ + } + else + {/*ȵ*/ + SetAutoRtnIndictSteadyState(chRtnIndcDevId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*ȵ״̬Ч*/ + } + } + } + } + } + } + break; + case MASK_TYPE_ESP_STATE:/*վ̨رհť״̬λ*/ + break; + case MASK_TYPE_PSD_STATE:/*վ̨״̬λ-ZC,LEU*/ + break; + case MASK_TYPE_PSD_STATE_ATS:/*վ̨״̬λ-ATS*/ + break; + case MASK_TYPE_MUTUALLOCK_STATE: + break; + default: + returnValue = CI_ERROR; + break; + } + break; + case CI_DEVICE_TYPE_ROUTE: + if (MASK_TYPE_ROUTE_STOPENABLEE_STATUS == MaskType) /*֤ͣλ*/ + { + if (maskBuf[ii] == 1u) + { + SetRouteStopensureFlag(DeviceId,ROUTE_STOPENSURE_YES); + } + else + { + SetRouteStopensureFlag(DeviceId,ROUTE_STOPENSURE_NO); + + } + } + + break; + + case CI_DEVICE_TYPE_GARAGEDOOR: + if (MASK_TYPE_GARAGEDOOR_ALLOWCLOSE_STATE == MaskType) /*λ*/ + { + if (maskBuf[ii] == 1u) + { + SetGaragedoorAllowCloseFlag(DeviceId,GARAGE_DOOR_ALLOW_CLOSE_YES); + } + else + { + SetGaragedoorAllowCloseFlag(DeviceId,GARAGE_DOOR_ALLOW_CLOSE_NO); + + } + } + + break; + + case CI_DEVICE_TYPE_FLOODGATE:/**/ + { + if (MASK_TYPE_FLOODGATE_YXGM_FROMZC == MaskType) + { + if (1u == maskBuf[ii]) + { + (void)SetFloodGateCurZCAgrCloseAck(DeviceId,FLOOD_GATE_ALLOWCLOSE_ZC); + } + else + { + (void)SetFloodGateCurZCAgrCloseAck(DeviceId,FLOOD_GATE_NOT_ALLOWCLOSE_ZC); + } + } + } + break; + default: + returnValue = CI_ERROR; + break; + } + + } + + + if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch) + {/*Ծش򿪣ŴͬһζԾմ*/ + for (ii = 0u; ii < phyNum; ii++) + { + phyId = GetPhySecId(ii); + phyBelongCiId = GetPhySecBelongCiId(phyId); + phyAxisSecNum = GetPAxisSectionSum(phyId);/*ȡι*/ + pPhyAxisIDBuf = GetPAxisSectionIdBuf(phyId);/*ȡιID*/ + numAxisHaveJumpLockApply = 0u; + if (NULL != pPhyAxisIDBuf) + { + if (phyBelongCiId == ciid) + {/*ڱ*/ + for (jj=0u;jj 1u) + {/*һζԾ*/ + /*εеļ붼óδ*/ + for (jj=0u;jj 0u)) + ||(((belongCiId != localCiId) && (localCiId > 0u) + &&(TRANSMIT_STATE_BAD == commState) + &&(CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag) + &&(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)))) + { + /*ʼΪռ*/ + mergeOccuState = SECTION_OCCUPY_NO; + phySecOccuChangeTimeState = CI_TIME_OUT; + + /*ȡ״̬V2.0 汾ARB*/ + arbState = GetArbState(phySectionId); + + allLogicSecOccustate = GetLogicSecOccuState(phySectionId); + + phySecCurCollOccuState = GetPhySecCurOccupyState(phySectionId); + + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + chSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH); + if (FUNC_SWITCH_ON == chSwitch) + { + if (SECTION_OCCUPY_NO == phySecCurCollOccuState) + { + /* ɼ״̬ںгռ */ + chFunRtn = IsPhyFree(phySectionId); + if (CI_ERROR == chFunRtn) + { + phySecCurCollOccuState = SECTION_OCCUPY_YES; + } + else + { + ; + } + } + else + { + ; + } + } + else + { + ; /* ɼռںϹռ */ + } + } + else + { + pSourceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*ȡ뱾ͨŵZCIDĿǰһֻһZCͨ*/ + + if (pSourceIdBuf != NULL) + { + /*ZCͨ״̬*/ + (void)UpdateCiTransmitState(localCi, CI_SYSTEM_TYPE_ZC, pSourceIdBuf[0]); + zcCommState = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_ZC, pSourceIdBuf[0]); + /*ͨ쳣*/ + if (CI_ERROR == zcCommState) + { + comunicationState = TRANSMIT_STATE_BAD; + } + else + { + comunicationState = TRANSMIT_STATE_GOOD; + } + } + } + + phySecPreOccuState = GetPhySecCurMergeState(phySectionId); + + routeId = GetPhySecRLockBelongRouteId(phySectionId); + + routePhySecSum = GetRoutePhysicalSectionSum(routeId); + routePSSecStru = GetRouteSectionData(routeId); + + preSecId = 0u; + for (jj = 0u; jj < routePhySecSum; jj++) + { + if (routePSSecStru[jj].PhysicalSectionId == phySectionId) + {/*ҵ·еĸ*/ + + if (jj > 0u) + {/*ǵһ*/ + + preSecId = routePSSecStru[jj - 1U].PhysicalSectionId; + } + else + { + routeNearPSSecStru = GetRouteBlocNearPhySectionStru(routeId); + if (NULL != routeNearPSSecStru) + { + preSecId = routeNearPSSecStru[0].NearPhySecIdBuf[0]; + } + else + { + preSecId = 0u; + } + + } + break; + + } + } + + + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + if (AXIS_SECTION_ARB_YES == arbState) + { + /*ARBЧ ߼*/ + if (SECTION_OCCUPY_NO == allLogicSecOccustate) + { + /*߼ο*/ + /*ں״̬*/ + mergeOccuState = SECTION_OCCUPY_NO; + andMergeOccuState = SECTION_OCCUPY_NO; + } + else + { + /*ں״̬ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + andMergeOccuState = SECTION_OCCUPY_YES; + } + } + else + { + /*ARBЧ ߼мΪ*/ + if ((SECTION_OCCUPY_NO == phySecCurCollOccuState) || (SECTION_OCCUPY_NO == allLogicSecOccustate)) + { + /*ں״̬*/ + mergeOccuState = SECTION_OCCUPY_NO; + } + else + { + /*ں״̬ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + } + + /*ռԭ*/ + /*ARBЧ ߼ռüΪռ*/ + if ((SECTION_OCCUPY_YES == phySecCurCollOccuState) || (SECTION_OCCUPY_YES == allLogicSecOccustate)) + { + /*ں״̬ռ*/ + andMergeOccuState = SECTION_OCCUPY_YES; + } + else + { + /*ں״̬*/ + andMergeOccuState = SECTION_OCCUPY_NO; + } + + + } + } + else + { + /*ZCϢںռ״̬*/ + if (comunicationState == TRANSMIT_STATE_BAD) + { + /*ͨʧ*/ + if (phySecCurCollOccuState == SECTION_OCCUPY_NO) + { + /*ǰβɼ״̬*/ + /*ں״̬*/ + mergeOccuState = SECTION_OCCUPY_NO; + andMergeOccuState = SECTION_OCCUPY_NO; + } + else + { + /*ں״̬ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + andMergeOccuState = SECTION_OCCUPY_YES; + } + } + else if (comunicationState == TRANSMIT_STATE_GOOD) + { + /*ͨ*/ + if (arbState == AXIS_SECTION_ARB_YES) + { + /*ARBЧ ߼*/ + if (allLogicSecOccustate == SECTION_OCCUPY_NO) + { + /*߼ο*/ + /*ں״̬*/ + mergeOccuState = SECTION_OCCUPY_NO; + andMergeOccuState = SECTION_OCCUPY_NO; + } + else + { + /*ں״̬ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + andMergeOccuState = SECTION_OCCUPY_YES; + } + } + else + { + /*ARBЧ ߼мΪ*/ + if ((phySecCurCollOccuState == SECTION_OCCUPY_NO) || (allLogicSecOccustate == SECTION_OCCUPY_NO)) + { + /*ں״̬*/ + mergeOccuState = SECTION_OCCUPY_NO; + } + else + { + /*ں״̬ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + } + + /*ռԭ*/ + /*ARBЧ ߼ռüΪռ*/ + if (PHY_SEC_MANAGED_BY_ZC_YES == physecManagedByZcFlag) + {/*ZCϽ*/ + if ((phySecCurCollOccuState == SECTION_OCCUPY_YES) || (allLogicSecOccustate == SECTION_OCCUPY_YES)) + { + /*ں״̬ռ*/ + andMergeOccuState = SECTION_OCCUPY_YES; + } + else + { + /*ں״̬*/ + andMergeOccuState = SECTION_OCCUPY_NO; + } + } + else if (PHY_SEC_MANAGED_BY_ZC_NO == physecManagedByZcFlag) + {/*βZCϽռòɼ״̬*/ + andMergeOccuState = phySecCurCollOccuState; + } + else + {/*ռòɼ״̬*/ + andMergeOccuState = phySecCurCollOccuState; + } + + } + } + else + { + /* ͨŲȷ */ + /* 쳣 */ + /*ں״̬Ϊɼ״̬*/ + mergeOccuState = phySecCurCollOccuState; + andMergeOccuState = phySecCurCollOccuState; + } + } + + /* ȡռõмʱ */ + secOccupy2IdleTimeReal = GetSecOccuToClearStartCycNum(phySectionId); + /*ռõں*/ + if ((SECTION_OCCUPY_YES == phySecPreOccuState ) && (SECTION_OCCUPY_NO == mergeOccuState)) + { + + /*ռñ*/ + phySecOccuChangeTimeState = SystemOverTimeCheck(secOccupy2IdleTimeReal, secOccupy2IdleTimeSysPara); + + if (CI_TIME_NO == phySecOccuChangeTimeState ) + { + /*仯ʱδ üʱ*/ + SetSecOccuToClearStartCycNum(phySectionId, dwSystemCyc); + + /*ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + } + else if (CI_TIME_IN == phySecOccuChangeTimeState ) + { + /*仯ʱδ*/ + /*ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + } + else if (CI_TIME_OUT == phySecOccuChangeTimeState) + { + /*仯ʱ䵽ʱ*/ + /*ʱ*/ + SetSecOccuToClearStartCycNum(phySectionId, 0u); + + /*ο*/ + mergeOccuState = SECTION_OCCUPY_NO; + + } + else + { + /**/ + } + } + else if((SECTION_OCCUPY_YES == mergeOccuState) && (0u != secOccupy2IdleTimeReal)) + { + /*ں״̬Ҫʱ*/ + SetSecOccuToClearStartCycNum(phySectionId, 0u); + } + else + { + /*ں״̬*/ + } + + + /*ںռ״̬*/ + SetPhySecCurMergeState(phySectionId,mergeOccuState); + + /*ռԭռ״̬ ֻжʱʹ ڽ δʱ*/ + SetPhySecCurAndMergeState(phySectionId,andMergeOccuState); + + /* αռüʱ */ + if ((SECTION_OCCUPY_NO == phySecPreOccuState) && (SECTION_OCCUPY_YES == mergeOccuState)) + { + /*бռ*/ + /*ɿбռֹͣ־ٴαռѹֹͣΪЧ*/ + SetPhySectionStopCheckFlag(phySectionId, PHYSICAL_STOPCHECK_SET_NO); + + /*εһͬʱռʱռÿʼʱ*/ + if (routeId > 0u) + {/*ν·*/ + + phySecCurOccuState = GetPhySecCurMergeState(preSecId); + if ((0u != preSecId) && + (SECTION_OCCUPY_YES == phySecCurOccuState)) + {/*һͬʱռ*/ + + /*ռÿʼʱ*/ + SetSecCurOccupyStartCycNum(phySectionId, dwSystemCyc); + /*UTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc); + } + + } + + } + else if ((SECTION_OCCUPY_YES == phySecPreOccuState) && (SECTION_OCCUPY_NO == mergeOccuState)) + { + /*ռñ*/ + /*źŻڷһΪмΣռó岻ӦرźŻ˴Ϊ⴦֮ǰ״̬Ϊ, + ǰһΪռʱΪռ*/ + dwSecCurOccupyCyc = GetSecCurOccupyStartCycNum(phySectionId); + cPhySecLjkFlag = GetPhySecLjkFlag(phySectionId); + cPhySecStopCheckFlag = GetPhySectionStopCheckFlag(phySectionId); + phySecCurOccuState = GetPhySecCurMergeState(preSecId); + if((0u == dwSecCurOccupyCyc) + && (PHYSICAL_SECTION_LJK_YES == cPhySecLjkFlag) + && (PHYSICAL_STOPCHECK_SET_YES == cPhySecStopCheckFlag) + && (SECTION_OCCUPY_NO == phySecCurOccuState)) + { + SetPhySecPreMergeState(phySectionId, SECTION_OCCUPY_NO); + } + /*ȡռÿʼʱ*/ + SetSecCurOccupyStartCycNum(phySectionId, 0u); + + /*ȡUTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(phySectionId, 0u); + } + else + { + /*ʱ*/ + } + + phySecCurOccuState = GetPhySecCurMergeState(phySectionId); + if(SECTION_OCCUPY_YES == phySecCurOccuState) + { + curUtOrCtOccFlag = GetPhySecCurCtOrUtOccupyState(phySectionId); /*ȡεǰCTUTռ״̬*/ + utOrCtOccFlag = GetPhySecPreOccState(phySectionId); /*ȡ֮ǰCTUTռ״̬*/ + dwSecUtOrCtOccuCyc = GetSecUtOrCtOccuStartCycNum(phySectionId); + /*ʱУγռ״̬仯ҽѿʼʱ*/ + if((utOrCtOccFlag != curUtOrCtOccFlag) && (0u != dwSecUtOrCtOccuCyc)) + { + /*UTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc); + } + else if (LOGICSECTION_OCCUPY_UT == curUtOrCtOccFlag) + { + /*UTռѹ ABL UTCTռÿʼʱ*/ + chCurAblFlag = GetPhySecABLTrainFlag(phySectionId); + chPreAblFlag = GetPhySecPreABLTrainFlag(phySectionId); + if (chCurAblFlag != chPreAblFlag) + { + SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc); + } + } + else + { + /*ιУ·һγռδ仯ʱ*/ + } + /*ռ״̬Ϊ֮ǰռ״̬*/ + SetPhySecPreOccState(phySectionId, curUtOrCtOccFlag); + } + else + { + SetPhySecPreOccState(phySectionId, LOGICSECTION_OCCUPY_NO); + } + + if(SECTION_OCCUPY_NO == phySecCurOccuState) + { + /*ȡUTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(phySectionId, 0u); + } + + } +#if 0 + else if ((belongCiId != localCiId) && (localCiId > 0u) && + (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface) + ) + { + /*ʼ*/ + mergeOccuState = SECTION_OCCUPY_NO; + phySecOccuChangeTimeState = CI_TIME_OUT; + + /*ȡ״̬ԤARB״̬ʱ*/ + arbState = AXIS_SECTION_ARB_NO; + allLogicSecOccustate = GetLogicSecOccuState(phySectionId); + + phySecCurCollOccuState = GetPhySecCurOccupyState(phySectionId); + phySecPreOccuState = GetPhySecCurMergeState(phySectionId); + + routeId = GetPhySecRLockBelongRouteId(phySectionId); + + routePhySecSum = GetRoutePhysicalSectionSum(routeId); + routePSSecStru = GetRouteSectionData(routeId); + preSecId = 0u; + for (jj = 0u; jj < routePhySecSum; jj++) + { + if (routePSSecStru[jj].PhysicalSectionId == phySectionId) + {/*ҵ·еĸ*/ + + if (jj > 0u) + {/*ǵһ*/ + + preSecId = routePSSecStru[jj - 1].PhysicalSectionId; + } + else + { + routeNearPSSecStru = GetRouteBlocNearPhySectionStru(routeId); + if (routeNearPSSecStru != NULL) + { + preSecId = routeNearPSSecStru[0u].NearPhySecIdBuf[0u]; + } + else + { + preSecId = 0u; + } + + } + break; + + } + } + + /*ͨ*/ + if (AXIS_SECTION_ARB_YES == arbState) + { + /*ARBЧ ߼*/ + if (SECTION_OCCUPY_NO == allLogicSecOccustate) + { + /*߼ο*/ + /*ں״̬*/ + mergeOccuState = SECTION_OCCUPY_NO; + } + else + { + /*ں״̬ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + } + } + else + { + /*ARBЧ ߼мΪ*/ + if ((SECTION_OCCUPY_NO == phySecCurCollOccuState) || (SECTION_OCCUPY_NO == allLogicSecOccustate)) + { + /*ں״̬*/ + mergeOccuState = SECTION_OCCUPY_NO; + } + else + { + /*ں״̬ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + } + + /*ռԭ*/ + /*ARBЧ ߼ռüΪռ*/ + if ((SECTION_OCCUPY_YES == phySecCurCollOccuState) || (SECTION_OCCUPY_YES == allLogicSecOccustate)) + { + /*ں״̬ռ*/ + andMergeOccuState = SECTION_OCCUPY_YES; + } + else + { + /*ں״̬*/ + andMergeOccuState = SECTION_OCCUPY_NO; + } + + } + + /* ȡռõں */ + secOccupy2IdleTimeReal = GetSecOccuToClearStartCycNum(phySectionId); + /*ռõں*/ + if ((SECTION_OCCUPY_YES == phySecPreOccuState) && (SECTION_OCCUPY_NO == mergeOccuState)) + { + secOccupy2IdleTimeSysPara = GetSystemParaOccuToIdleCyc(); + /*ռñ*/ + phySecOccuChangeTimeState = SystemOverTimeCheck(secOccupy2IdleTimeReal, secOccupy2IdleTimeSysPara); + + if (CI_TIME_NO == phySecOccuChangeTimeState ) + { + /*仯ʱδ üʱ*/ + SetSecOccuToClearStartCycNum(phySectionId, dwSystemCyc); + + /*ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + } + else if (CI_TIME_IN == phySecOccuChangeTimeState ) + { + /*仯ʱδ*/ + /*ռ*/ + mergeOccuState = SECTION_OCCUPY_YES; + } + else if (CI_TIME_OUT == phySecOccuChangeTimeState) + { + /*仯ʱ䵽ʱ*/ + /*ʱ*/ + SetSecOccuToClearStartCycNum(phySectionId, 0u); + + /*ο*/ + mergeOccuState = SECTION_OCCUPY_NO; + + } + } + else if ((SECTION_OCCUPY_YES == mergeOccuState) && (0u != secOccupy2IdleTimeReal)) + { + /*ں״̬Ҫʱ*/ + SetSecOccuToClearStartCycNum(phySectionId, 0u); + } + else + { + /*ں״̬*/ + } + + + /*ںռ״̬*/ + SetPhySecCurMergeState(phySectionId,mergeOccuState); + + /*ռԭռ״̬ ֻжʱʹ ڽ δʱ*/ + SetPhySecCurAndMergeState(phySectionId,andMergeOccuState); + + /* αռüʱ */ + if ((SECTION_OCCUPY_NO == phySecPreOccuState) && (SECTION_OCCUPY_YES == mergeOccuState)) + { + /*бռ*/ + /*ɿбռֹͣ־ٴαռѹֹͣΪЧ*/ + SetPhySectionStopCheckFlag(phySectionId, PHYSICAL_STOPCHECK_SET_NO); + + /*εһͬʱռʱռÿʼʱ*/ + if (routeId > 0u) + {/*ν·*/ + phySecCurOccuState = GetPhySecCurMergeState(preSecId); + if ((preSecId != 0u) && + (SECTION_OCCUPY_YES == phySecCurOccuState)) + {/*һͬʱռ*/ + + /*ռÿʼʱ*/ + SetSecCurOccupyStartCycNum(phySectionId, dwSystemCyc); + /*UTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc); + + } + + } + + } + else if ((SECTION_OCCUPY_YES == phySecPreOccuState) && (SECTION_OCCUPY_NO == mergeOccuState)) + { + /*ռñ*/ + /*źŻڷһΪмΣռó岻ӦرźŻ˴Ϊ⴦֮ǰ״̬Ϊ, + ǰһΪռʱΪռ*/ + + dwSecCurOccupyCyc = GetSecCurOccupyStartCycNum(phySectionId); + cPhySecLjkFlag = GetPhySecLjkFlag(phySectionId); + cPhySecStopCheckFlag = GetPhySectionStopCheckFlag(phySectionId); + phySecCurOccuState = GetPhySecCurMergeState(preSecId); + + if ((0u == dwSecCurOccupyCyc) + && (PHYSICAL_SECTION_LJK_YES == cPhySecLjkFlag) + && (PHYSICAL_STOPCHECK_SET_YES == cPhySecStopCheckFlag) + && (SECTION_OCCUPY_NO == phySecCurOccuState)) + { + SetPhySecPreMergeState(phySectionId, SECTION_OCCUPY_NO); + } + /*ȡռÿʼʱ*/ + SetSecCurOccupyStartCycNum(phySectionId, 0u); + + /*ȡUTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(phySectionId, 0u); + } + else + { + /*ʱ*/ + } + + phySecCurOccuState = GetPhySecCurMergeState(phySectionId); + if(SECTION_OCCUPY_YES == phySecCurOccuState) + { + curUtOrCtOccFlag = GetPhySecCurCtOrUtOccupyState(phySectionId); /*ȡεǰCTUTռ״̬*/ + utOrCtOccFlag = GetPhySecPreOccState(phySectionId); /*ȡ֮ǰCTUTռ״̬*/ + dwSecUtOrCtOccuCyc = GetSecUtOrCtOccuStartCycNum(phySectionId); + /*ʱУγռ״̬仯ҽѿʼʱ*/ + if((utOrCtOccFlag != curUtOrCtOccFlag) && (0u != dwSecUtOrCtOccuCyc)) + { + /*UTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(phySectionId, dwSystemCyc); + } + else + { + /*ιУ·һγռδ仯ʱ*/ + } + /*ռ״̬Ϊ֮ǰռ״̬*/ + SetPhySecPreOccState(phySectionId, curUtOrCtOccFlag); + } + else + { + SetPhySecPreOccState(phySectionId, LOGICSECTION_OCCUPY_NO); + } + + phySecCurOccuState = GetPhySecCurMergeState(phySectionId); + if(SECTION_OCCUPY_NO == phySecCurOccuState) + { + /*ȡUTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(phySectionId, 0u); + } + } +#endif + else + { + /**/ + } + + } + } +} + + +/* +* ں߼CTռϢ +* ˵ void +* ֵ void +* ޸bug YF0083-126 +* : ±Ϊ +*/ +void UpdateLogSectionCTOccupyState(void) +{ + UINT16 phySecId = 0u;/*ID*/ + UINT16 wPhySecSum = GetTotalPhySecCurNum();/*Ŀ*/ + UINT16 logicSecSum = 0u;/*߼Ŀ*/ + UINT16* logicSecIdBuf = NULL;/*Id*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 localCiId = GetSystemParaLocalCiId();/*ȡID*/ + + UINT8 phyBelongCi = 0u;/**/ + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + UINT8 phyMergeOccupyState = 0u; + UINT8 logSecPreOccState = 0u; + UINT8 LogSecOccupyState = 0u; /*ָ߼ռ״̬*/ + + for (ii = 0u; ii < wPhySecSum; ii++) + { + phySecId =GetPhySecId (ii);/*ȡID*/ + phyBelongCi = GetPhySecBelongCiId(phySecId); + + + logicSecSum = GetPhySecIncLogSecSum(phySecId);/*ȡ߼Ŀ*/ + logicSecIdBuf = GetPhySecIncLogSecIdBuf(phySecId);/*ȡ߼νṹ*/ + phyMergeOccupyState = GetPhySecCurMergeState(phySecId); + if (phyBelongCi == localCiId) + { + if (SECTION_OCCUPY_NO == phyMergeOccupyState) + {/*ںϺο*/ + + + for (jj = 0u; jj < logicSecSum; jj++) + { + logSecPreOccState = GetLogSecCurCtOrUtOccupyState(logicSecIdBuf[jj]); + SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState); + /*ں߼εռϢ*/ + SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_NO);/*߼ο*/ + +#if 0 + /*ɾ߼εCTռϢתֵصгռݣ*/ + DeleteLogSecCTInfo(logicSecIdBuf[jj]); +#endif + } + } + else + {/*ںϺռ*/ + + + for (jj = 0u; jj < logicSecSum; jj++) + { + logSecPreOccState = GetLogSecCurCtOrUtOccupyState(logicSecIdBuf[jj]); + LogSecOccupyState = GetLogSecOccupyState(logicSecIdBuf[jj]); + if (LOGICSECTION_OCCUPY_CT == LogSecOccupyState) + {/*߼ΪCTռ*/ + SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState); + SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_CT);/*߼CTռ*/ + } + else if (LOGICSECTION_OCCUPY_UT == LogSecOccupyState) + {/*߼ΪUTռ*/ + SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState); + SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_UT);/*߼UTռ*/ + } + else if (LOGICSECTION_OCCUPY_NO == LogSecOccupyState) + {/*߼ο*/ + SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState); + SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_NO);/*߼ο*/ + } + else + {/*쳣״̬*/ + SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState); + SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_UT);/*߼UTռ*/ + } + + } + } + } + else + { + commState = GetLocalCiAndOtherCiTransSta(phyBelongCi);/*ͨͨ״̬*/ + + if ((localCiId !=phyBelongCi) && (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣ߼״̬*/ + + + if (SECTION_OCCUPY_NO == phyMergeOccupyState) + { + for (jj = 0u; jj < logicSecSum; jj++) + { + logSecPreOccState = GetLogSecCurCtOrUtOccupyState(logicSecIdBuf[jj]); + SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState); + /*ں߼εռϢ*/ + SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_NO);/*߼ο*/ + +#if 0 + /*ɾ߼εCTռϢתֵصгռݣ*/ + DeleteLogSecCTInfo(logicSecIdBuf[jj]); +#endif + } + } + else + { + for (jj = 0u; jj < logicSecSum; jj++) + { + logSecPreOccState = GetLogSecCurCtOrUtOccupyState(logicSecIdBuf[jj]); + SetLogSecPreOccupyState(logicSecIdBuf[jj],logSecPreOccState); + /*ں߼εռϢ*/ + SetLogSecCurOccupyState(logicSecIdBuf[jj], LOGICSECTION_OCCUPY_UT);/*߼UTռ*/ + + } + } + } + } + } +} + + +/* +* LEUCIݣȡLEUϱ־λ +* ˵ void +* ֵ void +*/ +void ProcessLeuToCiData(void) +{ + UINT8 leuFaultFlagArray[LEU_TO_CI_SUM_MAX];/*LEUϱ־*/ + UINT16 ii = 0u;/*α*/ + LeuToCiDataStruct* LeuToCiData = NULL; + UINT16 leuSum = GetLeuToCiSum();/*CIͨŵLEUĿ*/ + UINT8 tranCiNum = 0u; + UINT8* tranCiIdBuf = NULL; + UINT8 jj = 0u; + UINT16 wTempLeuSum = 0U; + UINT8 localCiId = GetSystemParaLocalCiId(); + (void)memset(leuFaultFlagArray,1,LEU_TO_CI_SUM_MAX); + LeuToCiData = GetLeuToCiDataStru();/*LEU-CIͨ*/ + + /*ȡCIͨŵLEU*/ + tranCiNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_LEU); + tranCiIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_LEU); + + for (ii = 0u;ii < leuSum;ii++) + {/*CIͨŵLEUݽṹеĹϱ־*/ + /*allState bit0Ϊ״̬bit1Ϊͨл*/ + leuFaultFlagArray[ii] = ((LeuToCiData[ii].allState) & ((UINT8)0x01)); + + if (1U == leuFaultFlagArray[ii]) + { + wTempLeuSum++; + } + else + { + ; /**/ + } + + /*LEUϱ,յLEUű*/ + if ((0u == leuFaultFlagArray[ii]) && (LeuToCiData[ii].errorToAtsFlag == LEU_TO_ATS_ERRORFLAG_YES)) + { + /*¼*/ + SetErrorData(EFUNC_LEU_CI_COMM_FAULT, CI_DEVICE_TYPE_LEU, LeuToCiData[ii].idInfo[2], + ETYPE_LEU_CI_COMM_ALL_STATE_FAULT, INDICATOR_TYPE_LEU_FAULT_YES, ESEND_LEVEL_ZERO); + } + else + { + /*LEU״̬ͨLEU-CIͨű*/ + if ((1U == leuFaultFlagArray[ii]) && (0u == (LeuToCiData[ii].allState >> 1u & 0x01u)) + && (LeuToCiData[ii].errorToAtsFlag == LEU_TO_ATS_ERRORFLAG_YES)) + { + /* ¼ */ + /*UINT8 SetErrorData(const UINT8 FunctionId, const UINT8 DeviceType, const UINT16 DeviceId, + const UINT8 DeviceStateType, const UINT8 DeviceState,const UINT8 SendLevel)*/ + SetErrorData(EFUNC_LEU_CI_COMM_FAULT, CI_DEVICE_TYPE_LEU, LeuToCiData[ii].idInfo[2], + ETYPE_LEU_CI_COMM_CHANNEL_SWITCH_FAULT, INDICATOR_TYPE_LEU_FAULT_YES, ESEND_LEVEL_ZERO); + } + else + { + ; /**/ + } + } + /*ͨŵLEUı־*/ + ClearAllErrorFlag(); + } + + if (wTempLeuSum == leuSum) + { + leuFaultFlag = INDICATOR_TYPE_LEU_FAULT_NO; /*ͨŵLEUδ*/ + } + else + { + leuFaultFlag = INDICATOR_TYPE_LEU_FAULT_YES; /*һLEUϣ־Ϊ*/ + } + + for (jj = 0u; jj < tranCiNum; jj++) + { + (void)UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_LEU, tranCiIdBuf[jj]); + } +} +/* +* +* ˵ void +* ֵ void +*/ +static void ProcessPsdData(void) +{ + UINT16 i = 0u; /**/ + UINT16 psdId = 0u; /*ID*/ + UINT16 psdCnt=GetPsdSum(); /*PSD*/ + UINT16 vobcId = 0u; /*VOBC ID*/ + UINT8 psdCmd = VOBCTOCI_COMMAND_TYPE_PSDCHECK; /*PSD*/ + UINT16 psdRePhyId = 0u; /*PSDID*/ + UINT8 localCi = GetSystemParaLocalCiId(); /*ID*/ + UINT8 psdUpdateType = GetCiFunctionSwitchConfig(FUCN_IF_PSC); /*ȡǷPSCͨŷʽ 0x55VOBC״̬ 0xaaPSC״̬*/ + UINT8 chLineIdentity = 0u; + UINT8 belongCiId = 0u; + UINT8 phySecCurMergeState = 0u; + UINT8 curPsdDrvState = 0u; + UINT8 psdVitual = 0U; + UINT32 dwCurCycNum = 0U; + UINT32 dwCmdSetCycNum = 0U; /*PSD*/ + UINT32 dwTransmitBadEnsureCount = 0U; /*CIVOBCͨжжʱ*/ + + dwCurCycNum = Get2oo2CurCycleNum(); + dwTransmitBadEnsureCount = GetCiAndVobcTransBadEnsureCnt(); + chLineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡ·ʶ*/ + + for (i = 0u;i < psdCnt;i++) + { + psdId = GetPsdId(i); + belongCiId = GetPsdBelongCiId(psdId); + if ((0u != psdId) && (PSD_INVALID_ID != psdId) && (belongCiId == localCi)) + {/*ЧPSD id*/ + psdRePhyId = GetPsdRelatedPhySecId(psdId); + phySecCurMergeState = GetPhySecCurMergeState(psdRePhyId); + if (SECTION_OCCUPY_YES != phySecCurMergeState) + { + /*վ̨Ѿûгü*/ + ResetPsdData(psdId); + if((LINE_FAOHLHT == chLineIdentity) || (LINE_CC == chLineIdentity) || (LINE_FAOHLHT_ONESELF == chLineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == chLineIdentity)) + { + SetStartDetectionCycNum(psdId,0u); + /*ֹͣ̽Ч̽Ч*/ + SetStartDetectionState(psdId,JXTC_START_DETECTION_NO); + SetStopDetectionState(psdId,JXTC_STOP_DETECTION_YES); + } + else + { + ; + } + } + else + { +#if 0 + if (PSD_MUTUALLOCK_REMOVE_YES == lockRmSta) + {/**/ + if (PSD_STATE_OPEN == psdSta) + {/*ſ*/ + if (PSD_DRIVE_STATE_OPEN == lastDriSta) + { + + } + else if (PSD_DRIVE_STATE_CLOSE == lastDriSta) + { + closedRoute = GetPsdClosedRouteId(psdId); + if (0u != closedRoute) + {/*Ŵ򿪵źŹرյĽ·*/ + PsdOpenSignal(closedRoute, psdId); + } + + SetPsdClosedRouteId(psdId, 0u); + } + else + { + SetPsdClosedRouteId(psdId, 0u); + } + } + else + {/*Ź*/ + if (PSD_DRIVE_STATE_OPEN == lastDriSta) + { + + } + else if (PSD_DRIVE_STATE_CLOSE == lastDriSta) + { + closedRoute = GetPsdClosedRouteId(psdId); + if (0u != closedRoute) + {/*Ŵ򿪵źŹرյĽ·*/ + PsdOpenSignal(closedRoute, psdId); + } + + SetPsdClosedRouteId(psdId, 0u); + } + else + { + SetPsdClosedRouteId(psdId, 0u); + } + } + } + else + { + if (PSD_STATE_OPEN == psdSta) + {/*ſ*/ + if (PSD_DRIVE_STATE_OPEN == lastDriSta) + { + groupPsdId = GetPsdGroupPsdId(psdId); + closedRoute = GetPsdClosedRouteId(groupPsdId); + if ((groupPsdId > 0u) && (closedRoute > 0u)) + { + /* ͬPSDѼ¼վ·ӵPSD*/ + SetPsdClosedRouteId(psdId, closedRoute); + } + else + { + /*ŶӦijվ·ʼźſ*/ + outStationRouteSum = GetPsdRalatedOutStationRouteSum(psdId); /*ȡŹվ·Ŀ*/ + outStationRouteIdBuf = GetPsdRalatedOutStationRouteIdBuf(psdId); /*ȡŹվ·ID*/ + for (j = 0u; j < outStationRouteSum; j++) + { + if (CI_ERROR == AutoSignalOrRouteValid(outStationRouteIdBuf[j])) + {/*Զ*/ + routeState = GetRouteState(outStationRouteIdBuf[j]); /*ȡվ·״̬*/ + if ((ROUTE_STATE_YUXIAN_OPEN == routeState) || (ROUTE_STATE_NEAR_OPEN == routeState)) + {/*·ڿ״̬*/ + SetPsdClosedRouteId(psdId, outStationRouteIdBuf[j]); + } + else + { + if ((ROUTE_STATE_NEAR_LOCKERR == routeState) || (ROUTE_STATE_YUXIAN_LOCK == routeState)) + { + /*鿴صĿ۳ؿʶǷЧ*/ + + if ((ROUTE_DETAIN_CLOSE_SIG_YES == GetRouteDetainToRouteCloseFlag(outStationRouteIdBuf[j])) + || (ROUTE_DETAIN_RE_OPEN_SIG_YES == GetRouteDetainReOpenSigFlag(outStationRouteIdBuf[j]))) + { + SetPsdClosedRouteId(psdId, outStationRouteIdBuf[j]); + } + else + { + /*鿴SPKSźؿʶǷЧ*/ + if ((ROUTE_CLOSE_SPKS_YES == GetSPKSToRouteCloseFlag(outStationRouteIdBuf[j])) + || (ROUTE_SPKS_RE_OPEN_SIG_YES == GetRouteSpksReOpenSigFlag(outStationRouteIdBuf[j]))) + { + SetPsdClosedRouteId(psdId, outStationRouteIdBuf[j]); + } + } + } + } + } + } + } + } + else if (PSD_DRIVE_STATE_CLOSE == lastDriSta) + { + + } + else + { + SetPsdClosedRouteId(psdId, 0u); + } + } + else + { + if (PSD_DRIVE_STATE_OPEN == lastDriSta) + { + SetPsdClosedRouteId(psdId, 0u); + } + else if (PSD_DRIVE_STATE_CLOSE == lastDriSta) + { + closedRoute = GetPsdClosedRouteId(psdId); + if (0u != closedRoute) + {/*Ŵ򿪵źŹرյĽ·*/ + PsdOpenSignal(closedRoute, psdId); + } + + SetPsdClosedRouteId(psdId, 0u); + } + else + { + SetPsdClosedRouteId(psdId, 0u); + } + } + } +#endif + curPsdDrvState = GetPsdDriveState(psdId); + SetPsdPreDriveState(psdId,curPsdDrvState); + /*ɱPSD״̬*/ + SetPsdDriveState(psdId,PSD_DRIVE_STATE_INVALID);/*ĬЧȫ*/ + + vobcId = GetPsdVobcId(psdId); + psdVitual = GetPsdVirtualAttribute(psdId); + if ((0u != vobcId) && ((PSD_STATE_FROM_VOBC == psdUpdateType) || (PSD_VIRTUAL_ATTR_YES == psdVitual))) + {/*VOBCƸŻpsdΪ*/ + dwCmdSetCycNum = GetPsdCmdSetCycle(psdId); + if ((0U != dwCmdSetCycNum) && ((dwCurCycNum - dwCmdSetCycNum) <= dwTransmitBadEnsureCount)) + {/*ڴVOBCʱΪȻҪƸ*/ + psdCmd = GetPsdVobcCmd(psdId); + if (VOBCTOCI_COMMAND_TYPE_PSDOPEN == psdCmd) + {/*CIյVOBCĴPSDʱжPSDĿ״̬*/ + SetPsdDriveState(psdId, PSD_DRIVE_STATE_OPEN); + } + else if (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == psdCmd) + {/*CIյVOBCĹرPSDʱжPSDĿ״̬*/ + SetPsdDriveState(psdId, PSD_DRIVE_STATE_CLOSE); + } + else + {/*Ч,κδ*/ + } + } + else + { + /**/ + } + } + else + { + /**/ + } + } + } + else + { + /**/ + } + } +} + +#if 0 +/* +* Źرؿź +* ˵ const UINT16 routeId,ҪؿźŵĽ· +* ֵ void +*/ +static void PsdOpenSignal(const UINT16 routeId, const UINT16 psdId) +{ + UINT8 routeState; + RouteNearPhySectionStruct * routeNearPhySectionStruct = NULL; + UINT16 phySecId; + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + if((ROUTE_STATE_YUXIAN_LOCK==routeState)||(ROUTE_STATE_NEAR_LOCKERR==routeState)) + {/*·Ȼ*/ + routeNearPhySectionStruct = GetRouteBlocNearPhySectionStru(routeId);/*ȡ·ӽνṹ*/ + if(NULL != routeNearPhySectionStruct) + {/*ڽӽ*/ + phySecId = routeNearPhySectionStruct[0u].NearPhySecIdBuf[0u];/*ȡӽεһID*/ + if(0u != phySecId) + {/*һIDΪ0u*/ + if(0u != GetSecCurOccupyStartCycNum(phySecId)) + {/*г˳ռѹվ̨*/ +#if 0 + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_YES); /*ý·źؿ־*/ + SetRouteOpenSigStartCycNum(routeId, Get2oo2CurCycleNum()); /*źſʱ*/ +#endif + /*ؿ־£ؿڽ·׶ͳһ*/ + SetPsdToBeOpenedRoute(psdId, routeId); + } + } + } + } +} +#endif + +/* +* ͨVOBC +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void HLHTVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + if (NULL != vobcToCiDataStru) + { + ClearVobcStopSteadyData(vobcToCiDataStru->VobcId); + StopSteadyDataProc(vobcToCiDataStru); /*VOBCͣϢ*/ + } +} +/* +* VOBCͣϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* ޸bug YF0083-100 +*/ +static void StopSteadyDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT16 psdRelatedPhySecId = 0u;/*VOBC͵ĹIDӦID*/ + UINT32 currCycleNum = 0u; + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + /*CTUTռ״̬Ϊ޳״̬*/ + UINT8 utOrCtOccFlag = SECTION_OCCUPY_YES; + UINT8 phyBelongCiId = 0u; + UINT8 chRCMode = GetLocalRcWorkMode(); + if (NULL != vobcToCiDataStru) + { + if (VOBC_CI_STOP_TW == vobcToCiDataStru->trainStopSteadyState) + {/*ֻյVOBC͵ͣϢʱͣϢ*/ + currCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + /*VOBC͵ĹIDȡӦPSDID*/ + /*ѯŶձݹIDȡID*/ + psdRelatedPhySecId = GetTrackToPhySectionId(vobcToCiDataStru->trackSecID); + if(currCycleNum==vobcToCiDataStru->stopSteadyStartCycNum) + {/*յЧ*/ + phyBelongCiId = GetPhySecBelongCiId(psdRelatedPhySecId); + if (localCiId == phyBelongCiId) + {/*ȡεǰռ״̬*/ + /*ÿڵijʼ׶ΣÿζᱻóδͣȡVOBCZCͣϢ㣬һCIͣȣΪͣȡ*/ + utOrCtOccFlag = GetPhySecPreOccState(psdRelatedPhySecId); + if (LOGICSECTION_OCCUPY_UT == utOrCtOccFlag) + { + SetPhySecStopSteadyFlag(psdRelatedPhySecId, PHYSICAL_SECTION_STOPSTEADY_YES);/*ͣ*/ + SetPhyStopSteadyTrainId(psdRelatedPhySecId, vobcToCiDataStru->VobcId); /*ͣιгID*/ + } + else if (LOGICSECTION_OCCUPY_CT == utOrCtOccFlag) + { + if (RC_WORK_MODE_TIOC == chRCMode) + {/*TIOC*/ + SetPhySecStopSteadyFlag(psdRelatedPhySecId, PHYSICAL_SECTION_STOPSTEADY_YES);/*ͣ*/ + } + else if (RC_WORK_MODE_CI == chRCMode) + {/*CI*/ + /*ZCϢͣ*/ + } + else + { + ; /*ģʽ*/ + } + + + } + else + { + /*г͹*/ + } + } + + } + } + } +} + +/* +* VOBC֤ͣϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void StopensureDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + UINT8 cRouteCiId = 0u; + UINT16 wTrainId = 0u; + UINT32 dwCyc = 0u; + UINT8 ii = 0U; + + if (NULL != vobcToCiDataStru) + { + for (ii = 0U; ii < vobcToCiDataStru->chTrainStopAssureNum; ii++) + { + cRouteCiId = GetRouteBelongCiId(vobcToCiDataStru->szTrainStopRouteId[ii]); + if ((0u != cRouteCiId) + && (0u != localCiId) + && (localCiId == cRouteCiId)) + { + wTrainId = GetRouteStopEnassureTrainId(vobcToCiDataStru->szTrainStopRouteId[ii]); + dwCyc = GetRouteStopEnassureCyc(vobcToCiDataStru->szTrainStopRouteId[ii]); + + if ((vobcToCiDataStru->VobcId == (wTrainId & 0xffu)) && (dwCyc == vobcToCiDataStru->szTrainStopRouteCyc[ii]) && (0u != wTrainId) && (0U != dwCyc)) + { + /* ֤ͣд· */ + SetRouteStopensureFlag(vobcToCiDataStru->szTrainStopRouteId[ii], ROUTE_STOPENSURE_YES); + } + else + { + + } + debug_infor_printf((const)"StopensureInfo:VobcId:%x, wTrainId:%x, Cyc:%x, TrainStopRouteCyc =%x\n", vobcToCiDataStru->VobcId, wTrainId, dwCyc, vobcToCiDataStru->szTrainStopRouteCyc[ii]); + } + } + } +} + +/* +* VOBCȡԴϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void ResourceCancelDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + UINT8 cRouteCiId = 0u; + UINT16 wTrainId = 0u; + UINT32 dwCyc = 0u; + UINT8 ii = 0U; + UINT8 jj = 0U; + + UINT16 wRouteInLgcSecSum = 0U; + UINT16 *pRouteInLgcSecBuf = NULL; + if (NULL != vobcToCiDataStru) + { + for (ii = 0U; ii < vobcToCiDataStru->chResourcesCancelNum; ii++) + { + cRouteCiId = GetRouteBelongCiId(vobcToCiDataStru->szResourcesCancelRouteId[ii]); + wRouteInLgcSecSum = GetRouteLogSectionSum(vobcToCiDataStru->szResourcesCancelRouteId[ii]); + pRouteInLgcSecBuf = GetRouteLogSectionIdBuf(vobcToCiDataStru->szResourcesCancelRouteId[ii]); + if ((0u != cRouteCiId) + && (0u != localCiId) + && (localCiId == cRouteCiId) + && (NULL != pRouteInLgcSecBuf)) + { + wTrainId = GetRouteResourceCancelTrainId(vobcToCiDataStru->szResourcesCancelRouteId[ii]); /*ȡѯIDǷVOBCһ*/ + dwCyc = GetRouteResourceCancelCyc(vobcToCiDataStru->szResourcesCancelRouteId[ii]); /*ںǷһ*/ + + if ((vobcToCiDataStru->VobcId == (wTrainId & 0xffU)) && (dwCyc == vobcToCiDataStru->szResourcesCancelRouteCyc[ii]) && (0u != wTrainId) && (0u != dwCyc)) + { +#if 0 + /* ԴȡϢд· */ + SetRouteResourceCancelFlag(vobcToCiDataStru->szResourcesCancelRouteId[ii], ROUTE_RESOURCECANCEL_YES); +#endif + SetRouteResourceCancelTrainId(vobcToCiDataStru->szResourcesCancelRouteId[ii], 0U); /*ѯ*/ + SetRouteResourceCancelCyc(vobcToCiDataStru->szResourcesCancelRouteId[ii], 0U); + SetRouteResCancelDelayFlag(vobcToCiDataStru->szResourcesCancelRouteId[ii], RUUTE_RESCANCEL_DELAY_NO); /*ʱ־*/ + /*ɾгԴ*/ + for (jj = 0U; jj < wRouteInLgcSecSum; jj++) + { + RemoveLogSecTrainInfoById(pRouteInLgcSecBuf[jj], wTrainId); + } + } + else + { + + } + debug_infor_printf((const)"ResourcecancelInfo:VobcId:%x, wTrainId:%x, Cyc:%x, TrainStopRouteCyc =%x\n", vobcToCiDataStru->VobcId, wTrainId, dwCyc, vobcToCiDataStru->szTrainStopRouteCyc[ii]); + } + } + } +} +/* +* FAOVOBC +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void FAOVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + if (NULL != vobcToCiDataStru) + { + UINT16 washMachineCurSum = GetWashMachineSum(); /*ȡǰϴ*/ + UINT16 washMachineId = 0u; + UINT16 curVOBCId = 0u; + + /*ǰΪһһȫԶϴ*/ + if(1U == washMachineCurSum) + {/*һ̨ȫԶϴ*/ + washMachineId = GetWashMachineId(0u); /*ȡȫԶϴID*/ + } + + curVOBCId = GetWashMachineCurVobcID(washMachineId);/*ȡϴǰϴVOBC ID*/ + + if (0u == curVOBCId) + {/*ֻеǰûгϴҵʱõǰϴVOBC ID*/ + SetWashMachineCurVobcID(washMachineId,vobcToCiDataStru->VobcId);/*ϴǰϴVOBC ID*/ + + curVOBCId = GetWashMachineCurVobcID(washMachineId);/*ٴλȡϴǰϴVOBC ID*/ + } + + if ((0u != curVOBCId) && (curVOBCId == vobcToCiDataStru->VobcId))/*ϴǰϴVOBC IDЧҵǰǸVOBC*/ + { + if((WASHMACHINE_DRVSTATE_REQ_FALSE == vobcToCiDataStru->washTrainRequest) + && (WASHMACHINE_HEAD_STEADY_NO == vobcToCiDataStru->headWashStopSteadyInfo) + && (WASHMACHINE_TAIL_STEADY_NO == vobcToCiDataStru->tailWashStopSteadyInfo) + && (PASS_WASHMACHINE_REQUEST_INVALID == vobcToCiDataStru->passWashMachineRequest)) + {/*ϴЧΪϴϴҵ*/ + SetWashMachineCurVobcID(washMachineId,0u);/*ǰϴVOBC ID*/ + /*ϴ״̬*/ + SetWashTrainRequestDrvState(washMachineId,WASHMACHINE_DRVSTATE_REQ_FALSE); + SetTrainHeadStopSteadyDrvState(washMachineId,WASHMACHINE_HEAD_STEADY_NO); + SetTrainTailStopSteadyDrvState(washMachineId,WASHMACHINE_TAIL_STEADY_NO); + SetPassWashMachineReqtDrvSta(washMachineId,PASS_WASHMACHINE_DRVREQ_FALSE); + } + else + { + if(WASHMACHINE_DRVSTATE_REQ_TRUE == vobcToCiDataStru->washTrainRequest) + {/*ϴЧ*/ + if(1u == washMachineCurSum) + { + SetWashTrainRequestDrvState(washMachineId,WASHMACHINE_DRVSTATE_REQ_TRUE); + } + } + else + { + if(1u == washMachineCurSum) + { + SetWashTrainRequestDrvState(washMachineId,WASHMACHINE_DRVSTATE_REQ_FALSE); + } + } + + if(WASHMACHINE_HEAD_STEADY_YES == vobcToCiDataStru->headWashStopSteadyInfo) + {/*ͷͣЧ*/ + if(1u == washMachineCurSum) + { + SetTrainHeadStopSteadyDrvState(washMachineId,WASHMACHINE_HEAD_STEADY_YES); + } + } + else + { + if(1u == washMachineCurSum) + { + SetTrainHeadStopSteadyDrvState(washMachineId,WASHMACHINE_HEAD_STEADY_NO); + } + } + + if(WASHMACHINE_TAIL_STEADY_YES == vobcToCiDataStru->tailWashStopSteadyInfo) + {/*βͣЧ*/ + if(1u == washMachineCurSum) + { + SetTrainTailStopSteadyDrvState(washMachineId,WASHMACHINE_TAIL_STEADY_YES); + } + } + else + { + if(1u == washMachineCurSum) + { + SetTrainTailStopSteadyDrvState(washMachineId,WASHMACHINE_TAIL_STEADY_NO); + } + } + + if(PASS_WASHMACHINE_DRVREQ_TRUE == vobcToCiDataStru->passWashMachineRequest) + {/*ͨϴЧ*/ + if (1u == washMachineCurSum) + { + SetPassWashMachineReqtDrvSta(washMachineId,PASS_WASHMACHINE_DRVREQ_TRUE); + } + } + else + { + if (1u == washMachineCurSum) + { + SetPassWashMachineReqtDrvSta(washMachineId,PASS_WASHMACHINE_DRVREQ_FALSE); + } + } + } + } + else + { + if (0u == curVOBCId) + {/*ǰûVOBCϴ*/ + /*ϴ״̬*/ + if (1u == washMachineCurSum) + { + SetWashTrainRequestDrvState(washMachineId,WASHMACHINE_DRVSTATE_REQ_FALSE); + SetTrainHeadStopSteadyDrvState(washMachineId,WASHMACHINE_HEAD_STEADY_NO); + SetTrainTailStopSteadyDrvState(washMachineId,WASHMACHINE_TAIL_STEADY_NO); + SetPassWashMachineReqtDrvSta(washMachineId,PASS_WASHMACHINE_DRVREQ_FALSE); + } + } + else + { + /*ǰvobcIdvobcIdȣ*/ + } + } + } +} + +/* +* ATSֵصCIźؿ +* ˵ void +* ֵ 0u:ʧ +* 1:ɹ +*/ +UINT8 ProcessAtsOrXDToCiReturnToTRCmd(void) +{ + /*жǷźؿźؿ*/ + UINT16 tmpCmdCurSum = 0u; + CommandDataStruct* pATSToCiCmdReturnToTRData = NULL; + UINT16 signalId = 0u; + UINT8 retVal = CI_ERROR; + UINT8 checkResult = CI_ERROR; + UINT16 ii = 0u; + UINT8 toCiId = 0u; + + tmpCmdCurSum = GetATSToCiCmdRtnToTRCurSum();/*ȡźؿĿ*/ + pATSToCiCmdReturnToTRData = GetATSorXDToCiCmdRtnToTRData();/*ȡźؿṹ*/ + + if (0u < tmpCmdCurSum) + {/*źؿ*/ + for (ii = 0u; ii < tmpCmdCurSum;ii++) + { + signalId = (UINT16)(pATSToCiCmdReturnToTRData[ii].CommandParam>>16); + + /*źؿ*/ + checkResult = RouteReturnToThroughCondCheck(signalId,&toCiId); + if (CI_SUCCESS == checkResult) + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_SIGNAL_SPEC_OPEN_APPLY, signalId, 0u, toCiId);/*źؿ*/ + retVal = CI_SUCCESS; + } + else + { + /*źؿ*/ /*źؿ*/ + (void)RemoveReturnToTRCmdAt(ii); + retVal = CI_ERROR; + } + } + } + return retVal; +} +/* +* ͸źؿ +* ˵ const UINT16 signalId źŻID +* const UINT8* toCiId ĿID +* ֵ CI_SUCCESS: ͨ +* CI_ERROR: ʧ +*/ +static UINT8 RouteReturnToThroughCondCheck(const UINT16 signalId,UINT8* toCiId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 retVal = CI_SUCCESS; /*ֵ*/ + UINT16 signalOutSecId = 0u; /*źŻⷽ*/ + UINT16 signalInSecId = 0u; /*źŻڷ*/ + UINT16 returnRouteId = 0u; /*۷·*/ + UINT16 throughRouteId = 0u; /*ͨ·*/ + UINT16 nextRouteId = 0u; /*һ·*/ + UINT8 returnRouteIdBelongCiId = 0u; + UINT8 throughRouteIdBelongCiId = 0u; + UINT8 returnRouteDirection = 0u; + UINT16 reRouteNormalLockPhy = 0u; + UINT8 phyMergeState = 0u; + UINT16 nextRouteLockPhy = 0u; + UINT8 nextRouteDirection = 0u; + UINT8 haveDirChangeAfterRoute = 0u; + UINT8 haveDirChangeInRoute = 0u; + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + signalOutSecId = GetSignalOutFirstPhySecId(signalId); + signalInSecId = GetSignalInFirstLockedPhySecId(signalId); + + returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId); + nextRouteId = GetPhySecRLockBelongRouteId(signalInSecId); + throughRouteId = GetRouteThroughRouteId(returnRouteId); + returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId); + throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId); + + *toCiId = returnRouteIdBelongCiId; + + if ((returnRouteId == 0u)||(nextRouteId == 0u) || (returnRouteIdBelongCiId == localCiId) ||(throughRouteIdBelongCiId==localCiId)) + { + /*·Ч || ·ڱ*/ + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + /*ȡ·Ϣ*/ + reRouteNormalLockPhy = GetRouteFirstNormalLockSection(returnRouteId); + phyMergeState = GetPhySecCurMergeState(signalOutSecId); + nextRouteLockPhy = GetPhySecLockState(signalInSecId); + + /*۷·һաҡռá*/ + if ((reRouteNormalLockPhy == signalOutSecId) && + (SECTION_OCCUPY_YES == phyMergeState)) + { + /*һ·һ*/ + if (PHYSICAL_SECTION_LOCK_NORMAL == nextRouteLockPhy) + { + /*ȡս·*/ + nextRouteDirection = GetRouteDirection(nextRouteId); + returnRouteDirection = GetRouteDirection(returnRouteId); + + haveDirChangeAfterRoute = GetRouteHaveDirChangePointAfter(returnRouteId); + haveDirChangeInRoute = GetRouteHaveDirChangePointIn(returnRouteId); + + /*·󷽻·ڴڷ仯*/ + if((ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeAfterRoute) || + (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute)) + { + if(CI_SYSTEM_DIRECTION_UP == returnRouteDirection) + { + returnRouteDirection = CI_SYSTEM_DIRECTION_DOWN; + } + else if(CI_SYSTEM_DIRECTION_DOWN == returnRouteDirection) + { + returnRouteDirection = CI_SYSTEM_DIRECTION_UP; + } + else + { + /**/ + } + } + /*ͬ*/ + if(nextRouteDirection == returnRouteDirection) + { + if(0u != throughRouteId) + {/*returnRouteIdthroughRouteId0u˵returnRouteIdȷʵ۷·throughRouteIdͨ·Ҵʱ۷δͨ·*/ + retVal = CI_SUCCESS; + } + else + { + /*źؿؿź,ʱreturnRouteIdͨ·ID*/ + /*ؿһ·ź*/ + RepeatOpenSignalLogicManage(signalId); + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + + return retVal; +} + +/* +* źؿ +* ˵ const UINT16 signalId źŻID +* const UINT8 fromCiId ԴID +* ֵ CI_SUCCESS: ɹ +* CI_ERROR: ʧ +*/ +static UINT8 RouteReturnToThroughCmdProc(const UINT16 signalId,const UINT8 fromCiId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 retVal = CI_ERROR; /*ֵ*/ + + UINT16 signalOutSecId = 0u; /*źŻⷽ*/ + UINT16 signalInSecId = 0u; /*źŻڷ*/ + UINT16 returnRouteId = 0u; /*۷·*/ + UINT16 throughRouteId = 0u; /*ͨ·*/ + UINT16 nextRouteId = 0u; /*һ·*/ + UINT8 returnRouteState = 0u; + UINT8 returnRouteIdBelongCiId = 0u; + UINT8 throughRouteIdBelongCiId = 0u; + UINT8 returnRouteDirection = 0u; + UINT16 reRouteNormalLockPhy = 0u; + UINT8 phyMergeState = 0u; + UINT16 nextRouteLockPhy = 0u; + UINT16 lockPhyBelongRoute = 0u; + UINT8 nextRouteDirection = 0u; + UINT8 haveDirChangeAfterRoute = 0u; + UINT8 haveDirChangeInRoute = 0u; + UINT8 saveReRouteDir = 0u; + UINT8 throughRouteDir = 0u; + UINT16 wLastLgcSecId = 0U; + UINT8 chTrainSum = 0u; + LogicTrainResStruct * pstLgcResInfo = NULL; + LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + + if ((0u < signalId) && (signalId < SIGNAL_SUM_MAX)) + { + retVal = CI_SUCCESS; + } + + if (CI_SUCCESS == retVal) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != fromCiId) || (0u == fromCiId)) + { + retVal = CI_ERROR; + } + } + if (CI_SUCCESS == retVal) + { + signalOutSecId = GetSignalOutFirstPhySecId(signalId); + signalInSecId = GetSignalInFirstLockedPhySecId(signalId); + + returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId); + nextRouteId = GetPhySecRLockBelongRouteId(signalInSecId); + throughRouteId = GetRouteThroughRouteId(returnRouteId); + returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId); + throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId); + + if ((0u == returnRouteId) || (0u == nextRouteId) || (0u == throughRouteId) + || (returnRouteIdBelongCiId != localCiId) || (throughRouteIdBelongCiId != localCiId)) + { + /*·Ч || ·ڱ */ + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + /*ȡ·Ϣ*/ + reRouteNormalLockPhy = GetRouteFirstNormalLockSection(returnRouteId); + phyMergeState = GetPhySecCurMergeState(signalOutSecId); + nextRouteLockPhy = GetPhySecLockState(signalInSecId); + /*۷·һաҡռá*/ + if ((reRouteNormalLockPhy == signalOutSecId) && + (SECTION_OCCUPY_YES == phyMergeState)) + { + + /*һ·һ*/ + if (PHYSICAL_SECTION_LOCK_NORMAL == nextRouteLockPhy) + { + /*ȡս·*/ + lockPhyBelongRoute = GetPhySecRLockBelongRouteId(signalInSecId); + nextRouteDirection = GetRouteDirection(lockPhyBelongRoute); + returnRouteDirection = GetRouteDirection(returnRouteId); + throughRouteDir = GetRouteDirection(throughRouteId); /*۷·Ӧͨ·*/ + + haveDirChangeAfterRoute = GetRouteHaveDirChangePointAfter(returnRouteId); + haveDirChangeInRoute = GetRouteHaveDirChangePointIn(returnRouteId); + + saveReRouteDir = returnRouteDirection; /*·ʵʷ*/ + + /*·󷽻·ڴڷ仯*/ + if((ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeAfterRoute) || + (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute) ) + { + if(CI_SYSTEM_DIRECTION_UP == returnRouteDirection) + { + returnRouteDirection = CI_SYSTEM_DIRECTION_DOWN; + } + else if(CI_SYSTEM_DIRECTION_DOWN == returnRouteDirection) + { + returnRouteDirection = CI_SYSTEM_DIRECTION_UP; + } + else + { + /**/ + } + } + /*ͬ*/ + if(nextRouteDirection == returnRouteDirection) + { + /*۷·*/ + returnRouteState = GetRouteState(returnRouteId); + + wLastLgcSecId = GetRouteInLastLogSecId(returnRouteId); + chTrainSum = GetLogSecTrainInfoSum(wLastLgcSecId); + pstLgcResInfo = GetLogSecTrainInfo(wLastLgcSecId); + if (NULL != pstLgcResInfo) + { + (void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct)*LOGIC_SECTION_RES_SUM_MAX)); + } + SetLogSecLockState(wLastLgcSecId, LOG_SECTION_LOCK_NO, returnRouteId, saveReRouteDir); + + SetPhySecLockState(signalOutSecId, PHYSICAL_SECTION_LOCK_NO, returnRouteId, saveReRouteDir); + SetRouteStateManage(returnRouteId, ROUTE_STATE_IDLE); + + /*ڵǰ·*/ + SetLogSecLockState(wLastLgcSecId, LOG_SECTION_LOCK_NORMAL, throughRouteId, throughRouteDir); + + if (NULL != pstLgcResInfo) + { + CpyLgcSecResTrain(wLastLgcSecId, chTrainSum, stTmpResInfo); + } + /* ߼ԴΪ۷ */ + SetLogSecAllTrainReturnState(wLastLgcSecId, LOGIC_SECTION_TRAIN_RETURN_NO); + + /*ͨ·*/ + SetPhySecLockState(signalOutSecId,PHYSICAL_SECTION_LOCK_NORMAL,throughRouteId,throughRouteDir); + SetRouteStateManage(throughRouteId,returnRouteState); + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* Գ +* ˵ const UINT16 devId豸ID +* const UINT8 CMDType: +* ֵ CI_SUCCESS: ɹ +* CI_ERROR: ʧ +* cgh-ϲCID-2341-6cgh-ϲCID-2539-2 +*/ +static UINT8 VirtualDevCmdProc(const UINT16 devId,const UINT8 CMDType) +{ + UINT8 localCiType = GetLocalCiType();/*ȡ*/ + UINT8 cRetVal = CI_ERROR; + UINT8 psdVirtualAttribute = GetPsdVirtualAttribute(devId); + UINT8 esbVirtualAttribute = GetEsbVirtualAttribute(devId); + UINT8 spksVirtualAttribute = GetSpksVirtualAttribute(devId); + + if ((0u < devId) && (0u < CMDType)) + { + if (CI_TYPE_SCX == localCiType) + {/*Գ*/ + cRetVal = VirtualDevCmdCiIdCheck(devId, CMDType); + if (CI_SUCCESS == cRetVal) /*ɹִ*/ + { + switch (CMDType) + { + case SCX_ATS_CMD_PSD_OPEN:/**/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute) + { + cRetVal = SetPsdState(devId, PSD_STATE_OPEN); + } + break; + case SCX_ATS_CMD_PSD_CLOSE:/*ر*/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute) + { + cRetVal = SetPsdState(devId, PSD_STATE_CLOSE); + } + break; + case SCX_ATS_CMD_PSD_ISOLATE:/*Źϸ*/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute) + { + SetPsdIsolateState(devId, PSD_FAULT_ISOLATION_SCX); + cRetVal = CI_SUCCESS; + } + break; + case SCX_ATS_CMD_PSD_ISOLATE_CANCEL:/*ȡŹϸ*/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute) + { + SetPsdIsolateState(devId, 0u); + cRetVal = CI_SUCCESS; + } + break; + case SCX_ATS_CMD_PSD_REMOVE:/*Ż*/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute) + { + cRetVal = SetPsdMutualLockRemoveState(devId, PSD_MUTUALLOCK_REMOVE_YES); + } + break; + case SCX_ATS_CMD_PSD_REMOVE_CANCEL:/*ȡŻ*/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute) + { + cRetVal = SetPsdMutualLockRemoveState(devId, PSD_MUTUALLOCK_REMOVE_NO); + } + break; + case SCX_ATS_CMD_ESB_PRESS:/*ESB*/ + if (ESB_VIRTUAL_ATTR_YES == esbVirtualAttribute) + { + SetEsbAutualState(devId, ESB_STATE_VALID_YES); + cRetVal = CI_SUCCESS; + } + break; + case SCX_ATS_CMD_ESB_CANCEL:/*ESBȡ*/ + if (ESB_VIRTUAL_ATTR_YES == esbVirtualAttribute) + { + /*7.1 ޸ESB״̬*/ + SetEsbAutualState(devId, ESB_STATE_VALID_NO); + cRetVal = CI_SUCCESS; + } + break; + case SCX_ATS_CMD_ESS_GO_POSITION: /*ESSȥλ*/ + if (ESB_VIRTUAL_ATTR_YES == esbVirtualAttribute) + { + SetEssState(devId, ESB_STATE_GO_FLAG); + cRetVal = CI_SUCCESS; + } + break; + case SCX_ATS_CMD_ESS_STOP_POSITION: /*ESSͣλ*/ + if (ESB_VIRTUAL_ATTR_YES == esbVirtualAttribute) + { + SetEssState(devId, ESB_STATE_STOP_FLAG); + cRetVal = CI_SUCCESS; + } + break; + case SCX_ATS_CMD_AUTO_RETURN_SET:/*۷*/ + SetVirtualZDZFButtonState(VIRTUAL_ZDZFAJ_BUTTON_YES); + cRetVal = CI_SUCCESS; + break; + case SCX_ATS_CMD_AUTO_RETURN_CANCEL:/*ȡ۷*/ + SetVirtualZDZFButtonState(VIRTUAL_ZDZFAJ_BUTTON_NO); + cRetVal = CI_SUCCESS; + break; + case SCX_ATS_CMD_SPKS_PRESS:/*SPKS*/ + if (SPKS_VIRTUAL_ATTR_YES == spksVirtualAttribute) + { + SetPhySecSpksFLockBySpksId(devId, SPKS_STATUS_YES); + cRetVal = CI_SUCCESS; + } + break; + case SCX_ATS_CMD_SPKS_CANCEL:/*SPKSȡ*/ + if (SPKS_VIRTUAL_ATTR_YES == spksVirtualAttribute) + { + SetPhySecSpksFLockBySpksId(devId, SPKS_STATUS_NO); + cRetVal = CI_SUCCESS; + } + break; + case SCX_ATS_CMD_PCB_BUTTON_PRESS:/*PCBť*/ + /*PCB IDΪPSD ID;ֱPCBť״̬*/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute) + { + cRetVal = SetPsdButtonState(devId, PSD_BUTTON_STATE_DOWN); + } + break; + case SCX_ATS_CMD_PCB_BUTTON_CANCEL:/*ȡPCBť*/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute) + { + cRetVal = SetPsdButtonState(devId, PSD_BUTTON_STATE_UP); + } + break; + default: + ;/* ʧ */ + break; + } + } + } + else + { + ;/* ʧ */ + } + } + return cRetVal; +} + +/* +* УԳ豸 +* ˵ const UINT16 devId豸ID +* const UINT8 CMDType: +* ֵ CI_SUCCESS: Уɹ +* CI_ERROR: Уʧ +*/ +static UINT8 VirtualDevCmdCiIdCheck(const UINT16 devId, const UINT8 CMDType) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 localCi = 0u; + UINT8 wDevBelongCiId = 0U; /*豸ID*/ + + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + if ((0u < devId) && (0u < CMDType)) + { + switch (CMDType) + { + case SCX_ATS_CMD_PSD_OPEN:/**/ + case SCX_ATS_CMD_PSD_CLOSE:/*ر*/ + case SCX_ATS_CMD_PSD_ISOLATE:/*Źϸ*/ + case SCX_ATS_CMD_PSD_ISOLATE_CANCEL:/*ȡŹϸ*/ + case SCX_ATS_CMD_PSD_REMOVE:/*Ż*/ + case SCX_ATS_CMD_PSD_REMOVE_CANCEL:/*ȡŻ*/ + case SCX_ATS_CMD_PCB_BUTTON_PRESS:/*PCBť*/ + case SCX_ATS_CMD_PCB_BUTTON_CANCEL:/*ȡPCBť*/ + wDevBelongCiId = GetPsdBelongCiId(devId); + break; + case SCX_ATS_CMD_ESB_PRESS:/*ESB*/ + case SCX_ATS_CMD_ESB_CANCEL:/*ESBȡ*/ + case SCX_ATS_CMD_ESS_GO_POSITION: /*ESSȥλ*/ + case SCX_ATS_CMD_ESS_STOP_POSITION: /*ESSͣλ*/ + wDevBelongCiId = GetEsbBelongCiId(devId); + break; + case SCX_ATS_CMD_AUTO_RETURN_SET:/*۷*/ + case SCX_ATS_CMD_AUTO_RETURN_CANCEL:/*ȡ۷*/ + cRetVal = CI_SUCCESS; /*豸IDȥ*/ + break; + case SCX_ATS_CMD_SPKS_PRESS:/*SPKS*/ + case SCX_ATS_CMD_SPKS_CANCEL:/*SPKSȡ*/ + wDevBelongCiId = GetSpksBelongCiId(devId); + break; + default: + ; /*ʧ*/ + break; + } + + if ((0U != wDevBelongCiId) && (localCi == wDevBelongCiId)) + { + cRetVal = CI_SUCCESS; /*豸ID豸ΪسɹЧ*/ + } + else + { + ; /**/ + } + } + return cRetVal; +} +/* +* óԳ豸̬ +* ˵const UINT8 ciId ID +* ֵ void +*/ +static void ResetTrainTestDevState(const UINT8 ciId) +{ + /*Գ복βͨŽӿڣΪλԳߣԳ״̬*/ + UINT8 localCiType = GetLocalCiType(); + UINT8 interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*ȡԳ복νӿڷʽ*/ + + if (0u != ciId) + {/*IDЧ*/ + if ((SCX_CLD_INTERFACE_COMM == interfaceType)||(SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*Գ복βͨŽӿ*/ + if ((CI_TYPE_SCX == localCiType) && (CI_TYPE_CLD == GetCiType(ciId))) + {/*ΪԳߣ복ͨж*/ + SetCommTrainTestSCXYSKJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID); + } + else if ((CI_TYPE_CLD == localCiType) && (CI_TYPE_SCX == GetCiType(ciId))) + {/*ΪΣԳͨж*/ + SetCommTrainTestCLDSQJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID); + } + else + { + /*ʲô*/ + } + } + } +} + +/* +* ͨʱͨı +* ˵ +* ֵ void +*/ +static void ClearSignalOvlpCmdHlht(void) +{ + UINT8 deviceSum = 0u; + UINT8 *deviceIdBuf = NULL; + UINT8 dstCiId = 0u; + CiTransmitStruct *transStruPtr = NULL; + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 tempSigId = 0u; + UINT8 localCi = GetSystemParaLocalCiId(); + + deviceSum = GetCiTransmitSpecifySysDevSum(Get2oo2SheBeiType()); /*ȡͨCI豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(Get2oo2SheBeiType()); /*ȡͨCI豸ID*/ + + if ((deviceIdBuf != NULL) && (deviceSum > 0u)) + { + for (i = 0u;i < deviceSum;i++) + { + dstCiId = deviceIdBuf[i]; + transStruPtr = GetDstCiTransInfo(dstCiId); + + if (NULL != transStruPtr) + { + for (j = 0u;j < transStruPtr->signalNum;j++) + { + tempSigId = transStruPtr->signalIdBuf[j]; + + if (GetSignalBelongCiId(tempSigId)!=localCi) + { + SetSignalPLockCommand(tempSigId, SIGNAL_PLOCK_CMD_NONE); + } + } + } + } + } +} + +/* +* ӿ +* ˵ +* ֵ void +*/ +static void ProcessTctCiCmd(void) +{ + ToCiCommandDataStruct* CiRecvCiCmdStru = NULL; /*յṹ*/ + UINT16 CiRecvCiCmdSum = 0u; /*յ*/ + UINT16 deviceId = 0u; /*豸ID*/ + UINT16 deviceRelativeId = 0u; /*豸ID*/ + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT16 ii = 0u; /*α*/ + UINT8 jj = 0U; + UINT8 neiborCiType = 0u; + UINT8 devState = 0u; + UINT8 retVal = CI_ERROR; + UINT16 psdId = 0u; + UINT8 psdVobcCmd = 0u; + UINT16 wRouteId = 0u; + UINT16 wRouteState = 0U; + UINT16 wSwitchLockState = 0U; + UINT16 wLogSecId = 0u; + UINT16 wTrainId = 0u; + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + UINT8 belongCiId = 0u; + UINT8 phySecUseState = 0u; + UINT16 phySecUseRouteId = 0u; + UINT8 switchMoveValidState = 0u; + UINT8 localCiType = 0u; + UINT16 lockBelongRouteId = 0u; + UINT8 belongvirCI = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 cmdType =0U; + UINT8 cCiRecvCiDrCmdSum = 0U; + ToCiDrCmdDataStruct* pCiRecvCiDrCmdStru = NULL; + UINT32 dwCurCycNum = 0U; + UINT16 deviceId2 = 0U; + UINT16 routeCurSum = 0U; + UINT16 wRouteLockedOverlapId = 0U; /*·չı*/ + UINT8 chRouteBelCiId = 0U;/*·*/ + UINT8 cOverlapBelongCiId = 0U; /**/ + UINT8 chPhySecUseCheck = 0U;/*ü*/ + UINT16 wProPhySecUseRouteId = 0U;/*·*/ + UINT8 chPhySecType = 0U;/**/ + + /*CIܵ*/ + CiRecvCiCmdSum = GetCiRecvCiCmdStruCurSum(); + CiRecvCiCmdStru = GetCiRecvCiCmdDataStruct(); + dwCurCycNum = Get2oo2CurCycleNum(); + + if ((NULL == CiRecvCiCmdStru) || (0u == CiRecvCiCmdSum)) + { + /*δյ*/ + } + else + { + for (ii = 0u; ii < CiRecvCiCmdSum; ii++) + { + /*յ*/ + if (dwCurCycNum == CiRecvCiCmdStru[ii].CycleNo) + { + /*ж*/ + switch (CiRecvCiCmdStru[ii].CommandID) + { + case CI_CMD_PHYSEC_USING_APPLY: + /**/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*·ID*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if (localCiId == belongCiId) + {/**/ + phySecUseState = GetPhySecUseState(deviceId); + phySecUseRouteId = GetPhySecUseRouteId(deviceId); + chPhySecUseCheck = CheckPhysecUseState(deviceId, deviceRelativeId); + wProPhySecUseRouteId = GetPhySecProtectUseRouteId(deviceId); + chPhySecType = GetPhySecType(deviceId); + + if ((PHYSICAL_SECTION_USING_NO == phySecUseState) + || ((PHYSICAL_SECTION_USING_YES == phySecUseState) && ((deviceRelativeId == phySecUseRouteId) + ||((0U == phySecUseRouteId) && (0U < wProPhySecUseRouteId) && (PHYSICAL_SEC_TYPE_SWITCH == chPhySecType) && (CI_SUCCESS == chPhySecUseCheck))))) + { + /*δûָ·deviceRelativeId*/ + SetPhySecUseState(deviceId, PHYSICAL_SECTION_USING_YES, deviceRelativeId);/**/ + } + else + { + /*ʧܷ*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_REPLAY_FAILURE, deviceId, phySecUseRouteId, CiRecvCiCmdStru[ii].SourceCiId);/*ʧܷ*/ + } + } + else + { + /*ڱ*/ + } + break; + case CI_CMD_PHYSEC_USING_REPLAY_FAILURE: + /*ʧӦ*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*αý·ID*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if (localCiId == belongCiId) + {/**/ + + /**/ + } + else + { + /*DZβſɶ*/ + SetPhySecUseState(deviceId, PHYSICAL_SECTION_USING_NO, deviceRelativeId); + } + break; + case CI_CMD_PHYSEC_USING_CANCEL: + /*ȡ*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*αý·ID*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if (localCiId == belongCiId) + {/**/ + phySecUseState = GetPhySecUseState(deviceId); + phySecUseRouteId = GetPhySecUseRouteId(deviceId); + if ((PHYSICAL_SECTION_USING_YES == phySecUseState) + && (deviceRelativeId == phySecUseRouteId)) + {/*δʱΪ״̬ý·Ϊָ·Param2*/ + + SetPhySecUseState(deviceId, PHYSICAL_SECTION_USING_NO, deviceRelativeId);/*ȡ*/ + } + else + { + /*ȡ÷*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_REPLAY_FAILURE, deviceId, phySecUseRouteId, CiRecvCiCmdStru[ii].SourceCiId);/*ʧܷ*/ + } + } + else + { + /*DZβ*/ + } + break; + case CI_CMD_PROSW_SEC_USING_APPLY: + /**/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*·ID*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if (localCiId == belongCiId) + {/**/ + phySecUseState = GetPhySecUseState(deviceId); + phySecUseRouteId = GetPhySecProtectUseRouteId(deviceId); + chPhySecUseCheck = CheckPhysecUseState(deviceId, deviceRelativeId); + if ((PHYSICAL_SECTION_USING_NO == phySecUseState) + || ((PHYSICAL_SECTION_USING_YES == phySecUseState) && (CI_SUCCESS == chPhySecUseCheck))) + { + SetPhySecProtectUseState(deviceId, PHYSICAL_SECTION_USING_YES, deviceRelativeId);/**/ + } + else + { + /*ʧܷ*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_FAIL, deviceId, phySecUseRouteId, CiRecvCiCmdStru[ii].SourceCiId);/*ʧܷ*/ + } + } + else + { + /*ڱ*/ + } + break; + case CI_CMD_PROSW_SEC_USING_FAIL: + /*ʧ*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*·ID*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if (localCiId == belongCiId) + {/**/ + + /**/ + } + else + { + /*DZβſɶ*/ + SetPhySecProtectUseState(deviceId, PHYSICAL_SECTION_USING_NO, deviceRelativeId); + } + break; + case CI_CMD_PROSW_SEC_USING_CANCEL: + /*ȡ*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*·ID*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if (localCiId == belongCiId) + {/**/ + phySecUseState = GetPhySecUseState(deviceId); + phySecUseRouteId = GetPhySecProtectUseRouteId(deviceId); + if ((PHYSICAL_SECTION_USING_YES == phySecUseState) + && (deviceRelativeId == phySecUseRouteId)) + {/*δʱΪ״̬ý·Ϊָ·Param2*/ + + SetPhySecProtectUseState(deviceId, PHYSICAL_SECTION_USING_NO, deviceRelativeId);/*ȡ*/ + } + else + { + /*ȡ÷*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_FAIL, deviceId, phySecUseRouteId, CiRecvCiCmdStru[ii].SourceCiId);/*ʧܷ*/ + } + } + else + { + /*DZβ*/ + } + break; + case CI_CMD_SWITCH_DRIVE: + /**/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*ID*/ + deviceRelativeId = GetSwitchPhySectionId(deviceId);/*ID*/ + belongCiId = GetSwitchBelongCiId(deviceId); + if (localCiId == belongCiId) + {/**/ + + switchMoveValidState = GetSwitchMoveValidState(deviceId, SWITCH_OPER_NO_DANCAO, sendLevel); + if ((CI_SUCCESS == switchMoveValidState) + && ((SWITCH_POSITION_DINGWEI == CiRecvCiCmdStru[ii].Param2) || (SWITCH_POSITION_FANWEI == CiRecvCiCmdStru[ii].Param2))) + {/*ɲЧԼͨλparam2Ϊλλ*/ + /*õλ*/ + funRtn = SwitchDriveProcess(deviceId, (UINT8)CiRecvCiCmdStru[ii].Param2); + } + else + { + /**/ + } + } + else + { + /*DZβ*/ + } + break; + case CI_CMD_SIGNAL_SPEC_OPEN_APPLY: + /*źؿ*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*źŻID*/ + /*Ƿźؿؽ·״̬*/ + (void)RouteReturnToThroughCmdProc(deviceId, CiRecvCiCmdStru[ii].SourceCiId); + break; + case CI_CMD_KOUCHE:/*۳*/ + { + deviceId = CiRecvCiCmdStru[ii].Param1;/*źŻID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*۳*/ + belongCiId = GetSignalBelongCiId(deviceId); + + if ((belongCiId == localCiId) && (0U != localCiId)) + { + DetainLogicManage(deviceId, (UINT8)deviceRelativeId); + } + else + { + /*DZźŻ*/ + } + } + break; + case CI_CMD_KOUCHE_DETAIN:/*Ӳ߿۳*/ + { + deviceId = CiRecvCiCmdStru[ii].Param1;/*źŻID*/ + + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*۳*/ + + (void)SetSignalRelayDetainCmd(deviceId, (UINT8)deviceRelativeId);/*źŻӲ߿۳*/ + + DetainLogicManage(deviceId, (UINT8)deviceRelativeId); + } + break; + case CI_CMD_TRAIN_TEST_APPLY: + /*ԳԳ*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*Գ豸ID*/ + neiborCiType = (UINT8)(CiRecvCiCmdStru[ii].Param2 & ((UINT16)0x00FF));/**/ + devState = (UINT8)(CiRecvCiCmdStru[ii].Param2 >> 8);/*豸״̬*/ + localCiType = GetLocalCiType(); + if ((CI_TYPE_CLD == localCiType) && (CI_TYPE_SCX == neiborCiType)) + {/*ΪԳ*/ + if ((COMM_TRAIN_TEST_SQAJ_SCX == deviceId) && ((COMM_TRAIN_TEST_DEV_STATE_VALID == devState) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == devState))) + {/*豸IDΪSQAJ*/ + SetCommTrainTestCLDSQJStatus(devState); + } + else + {/*豸Ч*/ + SetCommTrainTestCLDSQJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID); + } + } + break; + case CI_CMD_TRAIN_TEST_ALLOW_STATUS: + /*Գ͵Գ״̬*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/*Գ豸ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*Գ豸״̬*/ + if (CI_TYPE_SCX == GetLocalCiType()) + {/*ΪԳ*/ + if ((COMM_TRAIN_TEST_TYSJ_CLD == deviceId) && ((COMM_TRAIN_TEST_DEV_STATE_VALID == deviceRelativeId) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == deviceRelativeId))) + {/*豸IDΪTYSJ*/ + SetCommTrainTestSCXYSKJStatus((UINT8)(deviceRelativeId)); + } + else + { + SetCommTrainTestSCXYSKJStatus((UINT8)(COMM_TRAIN_TEST_DEV_STATE_INVALID)); + } + } + break; + /*PSC·*/ + case CI_CMD_SET_PSC_PL: + deviceId = CiRecvCiCmdStru[ii].Param1;/*PSD ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*PSC ID*/ + /*·*/ + SetNearCiPscPlFlag(deviceId, deviceRelativeId, CI_PSC_PL_CONFIRM_YES); + break; + /*ȡPSC·*/ + case CI_CMD_QX_PSC_PL: + deviceId = CiRecvCiCmdStru[ii].Param1;/*PSD ID*/ + deviceRelativeId = CiRecvCiCmdStru[ii].Param2;/*PSC ID*/ + /*ȡ·*/ + SetNearCiPscPlFlag(deviceId, deviceRelativeId, CI_PSC_PL_CONFIRM_NO); + break; + case CI_CMD_SECTION_FAULT_UNLOCK: + deviceId = CiRecvCiCmdStru[ii].Param1;/*ID*/ + if (0u < deviceId) + { + lockBelongRouteId = GetPhySecRLockBelongRouteId(deviceId); /*ȡν··ID*/ + belongvirCI = GetRouteBelongVirCiId(lockBelongRouteId); + /*͵ιϽ*/ + PhySecFaultUnlockLogicManage(deviceId, belongvirCI); + } + break; + /*Զźȡ*/ + case CI_CMD_AUTO_SIG_ROUTE_CANCLE: + deviceId = CiRecvCiCmdStru[ii].Param1;/*·ID*/ + /*Ч*/ + SetCancleAutoSigCmdFlag(deviceId, AUTO_ROUTE_CANCLE_CMD_YES); + /*ԶźʧЧ*/ + retVal = SetRouteAutoSigLoseEfficacyFlag(deviceId, ROUTE_AUTOSIG_LOSE_REVSET_YES); + if (CI_ERROR == retVal) + { + /**/ + } + break; + /*ԶźŽ·Զ*/ + case CI_CMD_SET_AUTO_SIG_ROUTE_VALID: + deviceId = CiRecvCiCmdStru[ii].Param1;/*·ID*/ + /*ԶźŽ·ԶЧ*/ + retVal = SetRouteAutoSigLoseEfficacyFlag(deviceId, ROUTE_AUTOSIG_LOSE_SET_NO); + if (CI_ERROR == retVal) + { + /**/ + } + break; + case CI_CMD_PSD_VOBC_CMD_TO_CI:/*psdvobc*/ + psdId = CiRecvCiCmdStru[ii].Param1;/*psd id*/ + psdVobcCmd = (UINT8)CiRecvCiCmdStru[ii].Param2;/*psdvobc*/ + SetPsdVobcCmd(psdId, 0u, psdVobcCmd); + break; + case CI_CMD_LOCK_OVERLAP_CMD:/*͵İ*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/* id*/ + cmdType = (UINT8)CiRecvCiCmdStru[ii].Param2;/**/ + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + wRouteId = GetRouteId(ii); /*ȡ·ID*/ + funRtn = checkExpOverlapBelongToRtOrNot(wRouteId, deviceId); + if (CI_SUCCESS == funRtn) + { + break; /*ij·*/ + } + } + if (CI_SUCCESS == funRtn) + { + if ((ATS_LOCK_OVERLAP == cmdType) || (LABOR_LOCK_OVERLAP == cmdType)) + { + SetAtsExpectLockOverlapIdProc(deviceId, cmdType);/*ýα־*/ + } + } + else + { + /*۲ɴ */ + } + break; + case LOCK_OVERLAP_HAVE_ROUTE_CMD: + deviceId = CiRecvCiCmdStru[ii].Param1;/* id*/ + deviceId2 = CiRecvCiCmdStru[ii].Param2;/*·id*/ + if (0u < deviceId2) + { + funRtn =checkExpOverlapBelongToRtOrNot(deviceId2, deviceId); + if (CI_SUCCESS == funRtn) + { + /*idڽ·*/ + SetAtsLockOverlapHaveRouteId(deviceId, deviceId2);/*δ·ID*/ + } + else + { + debug_infor_printf((const)"LOCK_OVERLAP_HAVE_ROUTE_CMD Ovlp Not Belong to the Route, OvlpId: %d\n", deviceId); + } + } + else + { + /*nothing do*/ + } + break; + + case CI_CMD_UNLOCK_OVERLAP_CMD:/*͵Ľ*/ + deviceId = CiRecvCiCmdStru[ii].Param1;/* id*/ + /*˹*/ + (void)LaborUnlockOverlapProc((UINT8)deviceId); + + break; +#if 0 + case CI_CMD_ROUTE_OVERLAP_LOGSEC_LOCK:/*·*/ + wRouteId = CiRecvCiCmdStru[ii].Param1;/*·ID*/ + wTrainId = CiRecvCiCmdStru[ii].Param2;/*гID*/ + SetLgcSecResTrnIdOtherTiocRt(wRouteId, wTrainId); + /*յӻظ*/ + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_OVERLAP_LOCK_REPLAY, wRouteId, wTrainId, CiRecvCiCmdStru[ii].SourceCiId); + break; + + case CI_CMD_ROUTE_OVERLAP_LOCK_REPLAY: + wRouteId = CiRecvCiCmdStru[ii].Param1;/*·ID*/ + wTrainId = CiRecvCiCmdStru[ii].Param2;/*гID*/ + cOtherCiId = GetRouteResReqOtherCIId(wRouteId); + + if (cOtherCiId == CiRecvCiCmdStru[ii].SourceCiId) + { + SetRouteOvlapShrCiId(wRouteId, 0U); + RemoveRouteReqResTrain(wRouteId, wTrainId); + + } + break; +#endif + + case CI_CMD_LOGSEC_LOCK:/*·߼*/ + wLogSecId = CiRecvCiCmdStru[ii].Param1;/*߼ID*/ + wTrainId = CiRecvCiCmdStru[ii].Param2;/*гID*/ + /*յ󣬼Դɽշж*/ + AddLogSecTrainResFromCI(wLogSecId, wTrainId); + + /*յӻظ*/ +#if 0 + AddCiSendToCiCmdInfo(CI_CMD_LOGSEC_LOCK_REPLAY, wLogSecId, wTrainId, CiRecvCiCmdStru[ii].SourceCiId); +#endif + break; +#if 0 + case CI_CMD_LOGSEC_LOCK_REPLAY: + wLogSecId = CiRecvCiCmdStru[ii].Param1;/*߼ID*/ + wTrainId = CiRecvCiCmdStru[ii].Param2;/*гID*/ + cOtherCiId = GetLogSecResReqOtherCIId(wLogSecId); + + if (cOtherCiId == CiRecvCiCmdStru[ii].SourceCiId) + { + /* ֹͣԴ */ + SetLogSecResReqOtherCIId(wLogSecId, 0u); + SetLogSecResReqTrainId(wLogSecId, 0u); + } + break; +#endif + case CI_CMD_ROUTE_LOGIC_LOCK_CANCEL:/*߼ν*/ + wLogSecId = CiRecvCiCmdStru[ii].Param1;/*߼ID*/ + wTrainId = CiRecvCiCmdStru[ii].Param2;/*гID*/ + SetLogSecTrainRelease(wLogSecId, wTrainId, TRAIN_LEVEL_VBTC); + + break; + case CI_CMD_ROUTE_NOTVBTC_LOGIC_LOCK_CANCEL:/*VBTC߼ͷŲ*/ + wLogSecId = CiRecvCiCmdStru[ii].Param1;/*߼ID*/ + wTrainId = CiRecvCiCmdStru[ii].Param2;/*гID*/ + SetLogSecTrainRelease(wLogSecId, wTrainId, TRAIN_LEVEL_UR); + + break; +#if 0 + case CI_CMD_RT_OVRLP_RES_SHR:/*Դ־*/ + wRouteId = CiRecvCiCmdStru[ii].Param1;/*߼ID*/ + wOverlapId = CiRecvCiCmdStru[ii].Param2;/*гID*/ + SetRouteOvlpOtherCiShrFlg(wRouteId, wOverlapId, LOGIC_SECTION_RES_SHARE_YES); + AddCiSendToCiCmdInfo(CI_CMD_RT_OVRLP_SHR_REPLY, wRouteId, wOverlapId, CiRecvCiCmdStru[ii].SourceCiId); + break; + + case CI_CMD_RT_OVRLP_SHR_REPLY:/*Դ־ظ*/ + wRouteId = CiRecvCiCmdStru[ii].Param1;/*·ID*/ + SetRouteOvlapShrCiId(wRouteId, 0U); + break; +#endif + case CI_CMD_DR_ROUTE_STATE: + wRouteId = CiRecvCiCmdStru[ii].Param1; + wRouteState = CiRecvCiCmdStru[ii].Param2; + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId) && ((ROUTE_STATE_IDLE == wRouteState) || (ROUTE_STATE_HALF_UNLOCK == wRouteState))) + { + SetRouteStateManage(wRouteId, (UINT8)wRouteState); + } + else + { + /**/ + } + break; + + case CI_CMD_DR_SWITCH_PLOCK_CANCEL: + wRouteId = CiRecvCiCmdStru[ii].Param1; + wSwitchLockState = CiRecvCiCmdStru[ii].Param2; + if ((0U != wRouteId) && (0U != wSwitchLockState)) + { + SetRouteRelProSwitchLockSta(wRouteId, (UINT8)wSwitchLockState); + } + else + { + /**/ + } + break; + case CI_CMD_PHYSEC_PLOCK_ROUTE_CMD: + deviceId = CiRecvCiCmdStru[ii].Param1; /*ID*/ + deviceId2 = CiRecvCiCmdStru[ii].Param2; /*·ID*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if ((localCiId != belongCiId) && (0U != localCiId) && (0U != belongCiId)) + { + SetPhySecPLockRouteId(deviceId, deviceId2); + } + else + { + /*Σ*/ + } + break; + case CI_CMD_LOGSEC_PLOCK_ROUTE_CMD: + deviceId = CiRecvCiCmdStru[ii].Param1; /*߼ID*/ + deviceId2 = CiRecvCiCmdStru[ii].Param2; /*·ID*/ + belongCiId = GetLogSecBelongCiId(deviceId); + if ((localCiId != belongCiId) && (0U != localCiId) && (0U != belongCiId)) + { + SetLogSecPLockRouteId(deviceId, deviceId2); + } + else + { + /*Σ*/ + } + break; + case CI_CMD_ROUTE_LOCKED_OVERLAP: + deviceId = CiRecvCiCmdStru[ii].Param1; /*·ID*/ + deviceId2 = CiRecvCiCmdStru[ii].Param2; /*ID*/ + belongCiId = GetRouteBelongCiId(deviceId); + if ((localCiId == belongCiId) && (0U != localCiId)) + { + wRouteLockedOverlapId = GetRouteOverlapLockedId(deviceId); + if ((0U != wRouteLockedOverlapId) && (0U == deviceId2)) + { + SetOverlapUnlockApplyFlag(wRouteLockedOverlapId, UNLOCK_OVERLAP_APPLY_NO); /*α־*/ + } + else + { + /**/ + } + + SetRouteOverlapLockedId(deviceId, deviceId2); /*ý·չı*/ + } + else + { + /*DZ·*/ + } + break; + case CI_CMD_ROUTE_NEAR_STATE_SEARCH: + /*·ӽ״̬ѯ*/ + deviceId = CiRecvCiCmdStru[ii].Param1; + chRouteBelCiId = GetRouteBelongCiId(deviceId); + retVal = GetRouteOtherCiNearSecState(deviceId); + if (CI_SUCCESS == retVal) + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_ROUTE_NEAR_STATE_REPLAY, deviceId, ROUTE_NEAR_SEC_NOT_HAVE_UT, chRouteBelCiId); + } + else + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_ROUTE_NEAR_STATE_REPLAY, deviceId, ROUTE_NEAR_SEC_HAVE_UT, chRouteBelCiId); + } + break; + case CI_CMD_ROUTE_NEAR_STATE_REPLAY: + /*·ӽ״̬ظ*/ + deviceId = CiRecvCiCmdStru[ii].Param1; + deviceId2 = CiRecvCiCmdStru[ii].Param2; + SetRouteNearSecSearchState(deviceId, deviceId2); + break; + case CI_CMD_ROUTE_SEC_LOCK_APPLY: + /*·*/ + deviceId = CiRecvCiCmdStru[ii].Param1; + deviceId2 = CiRecvCiCmdStru[ii].Param2; + + RouteSecLockApplyCmdProc(deviceId, deviceId2); + break; + case CI_CMD_OLP_PROSWT_USE_APPLY: + /*η봦*/ + deviceId = CiRecvCiCmdStru[ii].Param1; /*ID*/ + deviceId2 = CiRecvCiCmdStru[ii].Param2; /*ID*/ + OtherCiOlpProSwUseApplyPro(deviceId, deviceId2); + break; + case CI_CMD_OLP_PROSWT_USE_CANCEL: + /*ηȡ*/ + deviceId = CiRecvCiCmdStru[ii].Param1; /*ID*/ + deviceId2 = CiRecvCiCmdStru[ii].Param2; /*ID*/ + OtherCiOlpProSwUseCancelPro(deviceId, deviceId2); + break; + case CI_CMD_OLP_PROSWT_USE_FAILURE: + /*ηʧܷ*/ + deviceId = CiRecvCiCmdStru[ii].Param1; /*ID*/ + deviceId2 = CiRecvCiCmdStru[ii].Param2; /*ID*/ + belongCiId = GetSwitchBelongCiId(deviceId); + cOverlapBelongCiId = GetOverlapBelongCiId(deviceId2); + if ((localCiId != belongCiId) && (localCiId == cOverlapBelongCiId)) + { + SetSwitchUsingState(deviceId, SWITCH_USING_NO, deviceId2); /*Ϣ*/ + } + else + { + /**/ + } + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + /*ǵ*/ + } + } + } + + cCiRecvCiDrCmdSum = GetCiRecvCiDrCmdStruCurSum(); + pCiRecvCiDrCmdStru = GetCiRecvCiDrCmdDataStruct(); + + if ((NULL == pCiRecvCiDrCmdStru) || (0u == cCiRecvCiDrCmdSum)) + { + /*δյ̬·*/ + } + else + { + for (jj = 0u; jj < cCiRecvCiDrCmdSum; jj++) + { + /**/ + if (dwCurCycNum == pCiRecvCiDrCmdStru[jj].CycleNo) + { + SetRoutePartApplyFromCi(pCiRecvCiDrCmdStru + jj); /*Ķ̬·*/ + } + else + { + /*ǵ*/ + } + } + } + + /*յ*/ + ClearCiRevCiCmdData(); + ClearCiRevCiDrCmdData(); +} + +/* +* ͨӿ +* ˵ +* ֵ void +*/ +static void ProcessHlhtCiCmd(void) +{ + UINT16 signalCurSum = 0u; + UINT8 localCiId = 0u; + UINT16 signalInd = 0u;/*źŻʱ*/ + UINT16 signalId = 0u;/*źŻID*/ + UINT8 belongCiId = 0u; + UINT8 SigPLockCmd = SIGNAL_PLOCK_CMD_NONE; + UINT8 overlapIdSum = 0u;/*źŻı*/ + UINT16 *pOverlapIdBuf = NULL;/*źŻıID*/ + UINT8 protectLockDirect = 0u;/*źŻķͳһӪ*/ + + signalCurSum = GetSignalCurSum(); /*ȡźŻ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + /*źŻ*/ + for (signalInd = 0u; signalInd < signalCurSum; signalInd++) + { + signalId = GetSignalId(signalInd); /*ȡźŻID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡ·ID*/ + + if (belongCiId == localCiId) + { + SigPLockCmd = GetSignalPLockCommand(signalId); + + overlapIdSum = GetSignalProSecIdSum(signalId); + + pOverlapIdBuf = GetSignalProSecIdBuf(signalId); + protectLockDirect = GetSignalOperDirection(signalId); + + if (SIGNAL_PLOCK_CMD_CREATE == SigPLockCmd) + { + (void)LockLocalOvlpManageHlht(overlapIdSum, pOverlapIdBuf, protectLockDirect); + } + else if (SIGNAL_PLOCK_CMD_CANCEL == SigPLockCmd) + { + (void)UnLockLocalOvlpManageHlht(overlapIdSum, pOverlapIdBuf); + } + else if (SIGNAL_PLOCK_CMD_NONE == SigPLockCmd) + { + ; + } + else + { + /*޲*/ + } + } + else + { + ; /*޲*/ + } + } +} + +/* +* ûͨ豸״̬ +* ˵UINT8 const ciId,ͨCI +* ֵ void +*/ +static void ResetCiDevStateHlht(UINT8 const ciId) +{ + CiTransmitStruct *transStruPtr = NULL; + UINT16 ii = 0u; + UINT16 bufInx = 0u; + UINT16 zcjIdt = 0u; + + /*ͨCI͸ı*/ + transStruPtr = GetSrcCiTransInfo(ciId); + if (NULL != transStruPtr) + { + for(ii = 0u; ii < transStruPtr->signalNum; ii++) + { + SetSignalPLockCommand(transStruPtr->signalIdBuf[ii], SIGNAL_PLOCK_CMD_NONE); + /*ñЧ*/ + SetSignalProSecValid(transStruPtr->signalIdBuf[ii], SIGNAL_PRO_SEC_INVALID); + } + + for(ii = 0u; ii < transStruPtr->zcjNum; ii++) + { + zcjIdt = transStruPtr->zcjIdBuf[ii]; + + bufInx = GetRelayConfigBufIndex(zcjIdt); /*ȡ̵±*/ + + RelayDataStru[bufInx].RelayId = zcjIdt;/*ڳʼʱûгʼCIļ̵ݣRelayDataStru[bufInx].RelayIdΪЧֵ˴ֵ̬*/ + + RelayDataStru[bufInx].RelayCollState = RELAY_STATE_DOWN; + } + } + + ResetDynamicStateHlht(ciId); +} + +/* +* PSDɾijVOBC +* ˵ UINT16 vobcId VOBCṹVobcId +* ֵ +*/ +void ClearPsdVobcContext(const UINT16 vobcId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 psdId = 0u; + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 deviceSum =0u;/*ͨ豸*/ + UINT8* deviceIdBuf = NULL;/*ͨ豸ID*/ + UINT8 platformId = 0u; + UINT8 psdSum = 0u; + UINT16 platformPsdId = 0u; + + for(bufIndex=0u;bufIndex 0u) && (deviceIdBuf != NULL)) + {/*Чж*/ + for (ii = 0u; ii < deviceSum; ii++) + {/*뱾CIͨŵվ̨ϵͳ*/ + platformId = deviceIdBuf[ii]; + psdSum = platformToCiDataStru[platformId].psdSum; + for (jj = 0u; jj < psdSum; jj++) + {/*վ̨ϵͳPSDĿ*/ + platformPsdId = platformToCiDataStru[platformId].psdDataStr[jj].PsdId; + if (psdId == platformPsdId) + {/*ҵӦվ̨ϵͳϢVOBC͵ĹϸϢ*/ + platformToCiDataStru[platformId].psdDataStr[jj].doorHaveOrNot = PSD_HAVE_TRAIN_DOOR_NO;/*VOBCͨжϺ󣬰޳ϢΪ޳*/ + platformToCiDataStru[platformId].psdDataStr[jj].faultIsolationRequestInfo = 0u;/*VOBCͨжϺ󣬽VOBCPSDΪ޸*/ + platformToCiDataStru[platformId].psdDataStr[jj].doorEditGroupInfo = 0u; /*Ϣ*/ + break; + } + else + { + ; /**/ + } + } + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (PsdDataStru[bufIndex].wVideoQkRelateVobcId == vobcId) + { + /*Ƶ״̬гID*/ + PsdDataStru[bufIndex].chVideoQkDriveState = VIDEO_QK_DRIVE_STATE_INVALID; + PsdDataStru[bufIndex].wVideoQkRelateVobcId = 0U; + } + else + { + ; /**/ + } + } +} + +/* +* HLHT+FAOVOBC +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void HLHTFAOVOBCDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + if (NULL != vobcToCiDataStru) + { + UINT16 washMachineCurSum = GetWashMachineSum(); /*ȡǰϴ*/ + UINT16 washMachineId = 0u; + UINT16 curVOBCId = 0u; + UINT32 dwCurCycNum = 0U; + + /*ͣϢڸ*/ + ClearVobcStopSteadyData(vobcToCiDataStru->VobcId);/*ȳͣϢ*/ + StopSteadyDataProc(vobcToCiDataStru); /*VOBCͣϢ*/ + + dwCurCycNum = Get2oo2CurCycleNum(); + if (dwCurCycNum == vobcToCiDataStru->ComStartCycle) + { + /*ǰΪһһȫԶϴ*/ + if (1U == washMachineCurSum) + {/*һ̨ȫԶϴ*/ + washMachineId = GetWashMachineId(0u); /*ȡȫԶϴID*/ + } + + curVOBCId = GetWashMachineCurVobcID(washMachineId);/*ȡϴǰϴVOBC ID*/ + + if (0u == curVOBCId) + {/*ֻеǰûгϴҵʱõǰϴVOBC IDͬʱVOBC IDvobcCIϢΪȫԶϴ + ֹVOBCCI֡ҲVOBC ID*/ + if (VOBC_CI_INFO_TYPE_FAO_INFO == vobcToCiDataStru->appInfoType) + { + SetWashMachineCurVobcID(washMachineId, vobcToCiDataStru->VobcId);/*ϴǰϴVOBC ID*/ + } + + + curVOBCId = GetWashMachineCurVobcID(washMachineId);/*ٴλȡϴǰϴVOBC ID*/ + } + + if ((0u != curVOBCId) && (curVOBCId == vobcToCiDataStru->VobcId))/*ϴǰϴVOBC IDЧҵǰǸVOBC*/ + { + if ((WASHMACHINE_DRVSTATE_REQ_FALSE == vobcToCiDataStru->washTrainRequest) + && (WASHMACHINE_HEAD_STEADY_NO == vobcToCiDataStru->headWashStopSteadyInfo) + && (WASHMACHINE_TAIL_STEADY_NO == vobcToCiDataStru->tailWashStopSteadyInfo) + && (PASS_WASHMACHINE_REQUEST_INVALID == vobcToCiDataStru->passWashMachineRequest) + && (PAUSE_TRAIN_WASH_REQUEST_INVALID == vobcToCiDataStru->washPauseRequest)) + {/*ϴЧΪϴϴҵ*/ + SetWashMachineCurVobcID(washMachineId, 0u);/*ǰϴVOBC ID*/ + /*ϴ״̬*/ + SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE); + SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO); + SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO); + SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE); + SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE); + SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV); + } + else + { + if (WASHMACHINE_DRVSTATE_REQ_TRUE == vobcToCiDataStru->washTrainRequest) + {/*ϴЧ*/ + if (1U == washMachineCurSum) + { + SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_TRUE); + /*ϴЧVOBC·ϴģʽ״̬*/ + SetWashMachineWorkModeDrvState(washMachineId, vobcToCiDataStru->chWashMachineWorkMode); + } + else + { + /*ϴ*/ + } + } + else + { + if (1U == washMachineCurSum) + { + SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE); + /*ϴЧϴģʽ״̬Ч*/ + SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV); + } + else + { + /*ϴ*/ + } + } + + if (WASHMACHINE_HEAD_STEADY_YES == vobcToCiDataStru->headWashStopSteadyInfo) + {/*ͷͣЧ*/ + if (1U == washMachineCurSum) + { + SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_YES); + } + } + else + { + if (1U == washMachineCurSum) + { + SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO); + } + } + + if (WASHMACHINE_TAIL_STEADY_YES == vobcToCiDataStru->tailWashStopSteadyInfo) + {/*βͣЧ*/ + if (1U == washMachineCurSum) + { + SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_YES); + } + } + else + { + if (1U == washMachineCurSum) + { + SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO); + } + } + + if (WASHMACHINE_PAUSE_DRVREQ_TRUE == vobcToCiDataStru->washPauseRequest) + {/*ͣϴЧ*/ + if (1U == washMachineCurSum) + { + SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_TRUE); + } + } + else + { + if (1U == washMachineCurSum) + { + SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE); + } + } + + if (PASS_WASHMACHINE_DRVREQ_TRUE == vobcToCiDataStru->passWashMachineRequest) + {/*ͨϴЧ*/ + if (1U == washMachineCurSum) + { + SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_TRUE); + } + } + else + { + if (1U == washMachineCurSum) + { + SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE); + } + } + } + } + else + { + if (0u == curVOBCId) + {/*ǰûVOBCϴ*/ + /*ϴ״̬*/ + if (1u == washMachineCurSum) + { + SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE); + SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO); + SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO); + SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE); + SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE); + SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV); + } + } + } + /*ƵϢ*/ + VobcVideoQkDataProc(vobcToCiDataStru); + + /*гӿݴ*/ + VobcConnectDataProc(vobcToCiDataStru); + } + else + { + /*δյгݣ*/ + } + } +} + +/* +* ±̵ӿȷ״̬ +* ˵ void +* ֵ void +*/ +void UpdateRelayInterfaceConfirmFlag(void) +{ + UINT8 localCi = 0u;/*ID*/ + UINT8 localCiType = 0u;/**/ + + UINT8 jj = 0u; + UINT8 tranCiState = 0u; + UINT8 sameLineFlag = SAME_LINE_ERR;/*CIǷͬһ·*/ + UINT8* pCiIdBuf = NULL; + UINT8 ciSum = 0u; + UINT8 dstCIType = 0u;/*Ŀ*/ + + UINT8 allCommState = CI_ERROR; + + localCi = GetSystemParaLocalCiId();/*ID*/ + localCiType = GetLocalCiType();/**/ + + /*ͨж*/ + + ciSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI); /*ȡͨ豸*/ + pCiIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI);/*ȡͱͨŵID*/ + + for (jj = 0u;jj>16); + cmdDevType = (UINT8)(AtsOrXianDiToCiCmdStru[ii].CommandParam>>8); + commandId = AtsOrXianDiToCiCmdStru[ii].CommandId; + terminalId = AtsOrXianDiToCiCmdStru[ii].termial_id; + virCiID = AtsOrXianDiToCiCmdStru[ii].VirCIid; + cmdType = AtsOrXianDiToCiCmdStru[ii].CommandType; + allSwitchYLockFlag = GetVirCIAllSwitchYLockState(virCiID); + if (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockFlag) + { + if (ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE == cmdType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + } + else if (ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO == cmdType) + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /*ȡ*/ + SetCiYLockManage_UseVirCI(CI_ALL_SWITCH_YLOCK_NO,virCiID); + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + /*ʲô*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + } + else if (ATS_CMD_SIGNAL_YINDAO_OPEN == cmdType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID); + /*źſ*/ + SetYLockSignalOpenStateManage(virCiID,CmdDeviceId); + } + else if (ATS_CMD_CI_MODE_CHANGE == cmdType) + {/*վغͽվл20161103*/ + /*ǰֽڴ豸IDֽڴ豸*/ + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId, cmdDevType, terminalId, cmdType,0u,0u,virCiID); + if ((CI_MODE_CI_LOCAL == CmdDeviceId) || (CI_MODE_CONSTRA_LOCAL == CmdDeviceId) || ((CI_MODE_APPLAY_LOCAL == CmdDeviceId))) + {/*ǿվغվءл*/ + /**/ + SetVirCImode(virCiID,(UINT8)CmdDeviceId); + } + } + else + { + SetCiSendCmdBackInfoData(CI_BACK_INVALID_CMD, cmdDevType, CmdDeviceId, 0U, (UINT32)AtsOrXianDiToCiCmdStru[ii].CommandType);/*Ч*/ + } + ClearCiRevCmdData();/*CIݶ*/ + } + else + { + if (ATS_CMD_SWITCH_ZONGSUO_SET_ONE == cmdType) + { + /*յϢ*/ + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_FIRST,AFFIRM_SUCCESS,virCiID); + /*CIݶ*/ + ClearCiRevCmdData(); + } + else if (ATS_CMD_SWITCH_ZONGSUO_SET_TWO == cmdType) + { + checkRetVal = CheckSecondOrderValid(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,virCiID); + if(CI_SUCCESS == checkRetVal) + { + /**/ + SetCiYLockManage_UseVirCI(CI_ALL_SWITCH_YLOCK_YES,virCiID); + + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_SUCCESS,virCiID); + } + else + { + SetCiSendCmdBackData_OrderBack(commandId,CmdDeviceId,cmdDevType,terminalId,cmdType,RESPONSE_SECOND,AFFIRM_FAIL,virCiID); + } + /*CIݶ*/ + ClearCiRevCmdData(); + + } + else + { + /**/ + } + } + } + } +} +/* +* ID豸IDǷҪִ +* ˵ UINT8 virCIid ID +* UINT8 belongVirCIid 豸ID +* UINT8 orderType +* UINT16 deiceID ID +* ֵ CI_ERROR ִУCI_SUCCESS ִ +*/ +UINT8 CheckOrderWhetherDoing(UINT8 virCIid,UINT8 belongVirCIid,UINT8 orderType,UINT16 deiceID) +{ + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 result = CI_ERROR; + if(FUNC_SWITCH_ON == includeVirFlag) + { + if((virCIid == belongVirCIid)&&(0u < virCIid)) + { + result = CI_SUCCESS; + } + else + { + SetErrorData(EFUNC_CHECKORDERWHETHERDO,orderType,deiceID,virCIid,belongVirCIid,ESEND_LEVEL_ZERO);/*δִУ·δִԭ*/ + result = CI_ERROR; + } + } + else + { + result = CI_SUCCESS; + } + return result; +} + +/* +* Զ۷ƣȵλ +* ˵ UINT16 DeviceId ָʾID +* UINT16*maskBuf λ +* UINT8 MaskType λ +* ֵ +*/ +void DealAutoReturnMask_UseVirCI(UINT16 DeviceId,UINT16*maskBuf,UINT8 MaskType,UINT16 index) +{ + UINT16 LocalCIbaojingDengNum = 0u;/*ʾID*/ + UINT16 LocalCIBaojingdengWId = 0u;/*ʾñID*/ + UINT8 LocalCIBaojingdengType = 0u; + UINT8 indicatorID = 0u; + UINT8 belongVirCI = 0u; + UINT16 jj= 0u; + UINT8 indicatorContainRelaySum = 0u; + UINT8 indicatorDevId = 0U; + + LocalCIbaojingDengNum = GetLocalCIBaojingdengNum(); + for (jj = 0u; jj < LocalCIbaojingDengNum; jj++ ) + { + LocalCIBaojingdengWId = GetLocalCIBaojingdengWId(jj); + LocalCIBaojingdengType = GetLocalCIIndicatorIDOrType(jj); + if ((DeviceId == LocalCIBaojingdengWId) && (INDICATOR_TYPE_EXPRESS_RETURN == LocalCIBaojingdengType)) + {/*豸IDӦָʾΪ۷*/ + indicatorID = GetLocalCIIndicatorIDOrType(jj); + belongVirCI = (UINT8)GetLocalCIBaojingdengBelongVir(jj); + indicatorDevId = GetIndicatorRelNonReturnId(DeviceId); + + indicatorContainRelaySum = GetVirCIIndicConfDataRelaySum(belongVirCI,indicatorID); + + + if (3u != indicatorContainRelaySum) + {/*̵ݴ*/ + + } + else + {/*̵ȷ*/ + if (MaskType == MASK_TYPE_PLAT_AUTORETURNSIG_FLASH) + {/*λһ̵λ*/ + + if (1u == maskBuf[index]) + {/**/ + SetVirCIautoRtnIndictFlashState(indicatorDevId,belongVirCI,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*״̬Ч*/ + } + else + {/**/ + SetVirCIautoRtnIndictFlashState(indicatorDevId,belongVirCI,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*״̬Ч*/ + } + } + else + {/*ȵλڶ̵λ*/ + + if (1u == maskBuf[index]) + {/*ȵ*/ + SetVirCIautoRtnIndictSteadyState(indicatorDevId,belongVirCI,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*ȵ״̬Ч*/ + } + else + {/*ȵ*/ + SetVirCIautoRtnIndictSteadyState(indicatorDevId,belongVirCI,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*ȵ״̬Ч*/ + } + } + } + + break; + } + } +} + + + +/* +* ȡȫվά޵״̬ +* ˵ UINT8 virCIid ID +* ֵ ά޵״̬ +*/ +UINT8 GetALLSignalMaintainState(UINT8 virCIid) +{ + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 result = CI_ERROR; + + if(FUNC_SWITCH_ON == includeVirFlag) + { + if(0u < virCIid) + { + result = GetVirCIAllSignalBrightState(virCIid); + } + } + else + { + result = GetAllSignalBrightFlag(); + } + return result; +} + + +/* +* IVOC +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void IvocInputDataProcCC(VobcToCiDataStruct* pstIvocToCiData) +{ + UINT32 dwCurCycNum = 0U; + UINT32 dwRcvCycNum = 0U; + UINT8 chFunRtn = CI_ERROR; + UINT8 chLevel = 0u; + UINT16 trainId = 0U; + const EnvelopeStruct* pElmTemp = NULL; + UINT8 chTrainVirHeadScreenFlag = 0U;/*ǰɸͨ־*/ + UINT8 chTrainVirTailScreenFlag = 0U;/*ɸͨ־*/ + + if (NULL != pstIvocToCiData) + { + + dwRcvCycNum = pstIvocToCiData->ComStartCycle; + dwCurCycNum = Get2oo2CurCycleNum(); + trainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + pstIvocToCiData->VobcId; + if (IVOC_CI_INFO_TYPE_CONTROL == pstIvocToCiData->appInfoType) + { + /*ÿTIOC룬ÿڶҪˢгϢ*/ + IvocInputRefreshTrain(*pstIvocToCiData); + } + if (dwRcvCycNum == dwCurCycNum) + { + if (IVOC_CI_INFO_TYPE_CONTROL == pstIvocToCiData->appInfoType) + { + IvocNonAutoRtnProcess(trainId); + /*ˢгϢ TODO*/ + StopSteadyDataProc(pstIvocToCiData); /*VOBCͣϢ*/ + + /*֤ͣϢ */ + StopensureDataProc(pstIvocToCiData); /*VOBC֤ͣ*/ + + /*ȡԴϢ*/ + ResourceCancelDataProc(pstIvocToCiData); /*VOBCȡԴϢ*/ + + /*IVOCϢ*/ + IvocUnLockOverlapProc(pstIvocToCiData); + + /*IVOCŹȷϢ*/ + IvocFloodGateCloseProc(pstIvocToCiData); + + /*ŹرȷϢ*/ + IvocGarageDoorCloseProc(pstIvocToCiData); + + /*Ϣ*/ + IvocInputCmdProc(*pstIvocToCiData); + + /*ϴϢ*/ + IvocWashDataProc(pstIvocToCiData); + + /*ƵϢ*/ + VobcVideoQkDataProc(pstIvocToCiData); + + /*гӿݴ*/ + VobcConnectDataProc(pstIvocToCiData); + } + else if(IVOC_CI_INFO_TYPE_LOGOUT_ASK == pstIvocToCiData->appInfoType) + { + if (IVOC_CI_LOGOUT_NORMAL == pstIvocToCiData->chLogOutState) + { + chFunRtn = IsPointManaged(pstIvocToCiData->wTrainMaxSafeHeadLink, pstIvocToCiData->dwTrainMaxSafeHeadOffset); + chFunRtn &= IsPointManaged(pstIvocToCiData->wTrainMinSafeTailLink, pstIvocToCiData->dwTrainMinSafeTailOffset); + chFunRtn &= IsPointManaged(pstIvocToCiData->wTrainMinSafeHeadLink, pstIvocToCiData->dwTrainMinSafeHeadOffset); + chFunRtn &= IsPointManaged(pstIvocToCiData->wTrainMaxSafeTailLink, pstIvocToCiData->dwTrainMaxSafeTailOffset); + + chFunRtn &= SetTrainMaxHeadLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMaxSafeHeadLink); + chFunRtn &= SetTrainMaxTailLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMaxSafeTailLink); + chFunRtn &= SetTrainMaxHeadOffset(pstIvocToCiData->VobcId, pstIvocToCiData->dwTrainMaxSafeHeadOffset); + chFunRtn &= SetTrainMaxTailOffset(pstIvocToCiData->VobcId, pstIvocToCiData->dwTrainMaxSafeTailOffset); + chFunRtn &= SetTrainMinHeadLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMinSafeHeadLink); + chFunRtn &= SetTrainMinTailLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMinSafeTailLink); + chFunRtn &= SetTrainMinHeadOffset(pstIvocToCiData->VobcId, pstIvocToCiData->dwTrainMinSafeHeadOffset); + chFunRtn &= SetTrainMinTailOffset(pstIvocToCiData->VobcId, pstIvocToCiData->dwTrainMinSafeTailOffset); + + if (CI_SUCCESS == chFunRtn) + {/* гʻ뱾ע */ + elm_LogoutDel(pstIvocToCiData->VobcId); + ClearTrainInfo(pstIvocToCiData->VobcId); + } + else + { + ; /* ޲ */ + } + } + else if(IVOC_CI_LOGOUT_SLEEP == pstIvocToCiData->chLogOutState) + { + chLevel = GetTrainLevel(pstIvocToCiData->VobcId); + chFunRtn = IsLinkSwTrack(pstIvocToCiData->wTrainMaxSafeHeadLink); + pElmTemp = elm_GetEnvelopeInfoByTrainID(pstIvocToCiData->VobcId); + chTrainVirHeadScreenFlag = GetTrainVirHeadScreenPassFlag(pstIvocToCiData->VobcId); + chTrainVirTailScreenFlag = GetTrainVirTailScreenPassFlag(pstIvocToCiData->VobcId); + + if ((TRAIN_LEVEL_VBTC == chLevel) && (CI_SUCCESS == chFunRtn) + && ((NULL != pElmTemp) && (((0u == pElmTemp->headTrainID) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirHeadScreenFlag)) + && ((0u == pElmTemp->tailTrainID) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirTailScreenFlag)))) + && ((pstIvocToCiData->wTrainMaxSafeHeadLink == pstIvocToCiData->wTrainMinSafeTailLink) + && (pstIvocToCiData->wTrainMinSafeTailLink == pstIvocToCiData->wTrainMinSafeHeadLink) + && (pstIvocToCiData->wTrainMinSafeHeadLink == pstIvocToCiData->wTrainMaxSafeTailLink))) + { + SetTrainSleepState(pstIvocToCiData->VobcId, TRAIN_SLEEP_YES); + SetTrainSleepLink(pstIvocToCiData->VobcId, pstIvocToCiData->wTrainMaxSafeHeadLink); + SetTrainSleepCancleFlag(pstIvocToCiData->VobcId, TRAIN_SLEEP_CANCLE_NO); + debug_infor_printf((const)"Train:%x set sleep\n", pstIvocToCiData->VobcId); + } + else + { + debug_infor_printf((const)"Train:%x Sleep error level:%d sw:%d hl:%d hl:%d tl:%d tl:%d\n", pstIvocToCiData->VobcId,\ + chLevel, chFunRtn, pstIvocToCiData->wTrainMaxSafeHeadLink, pstIvocToCiData->wTrainMinSafeHeadLink, \ + pstIvocToCiData->wTrainMaxSafeTailLink, pstIvocToCiData->wTrainMinSafeTailLink); + } + } + else + { + /* ޲ */ + ; + } + } + else + { + ; /**/ + } + } + } +} + +/* +* ˢг +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* qw.liu 2022-02-26 +*/ +static void IvocInputRefreshTrain(const VobcToCiDataStruct stIvocToCiData) +{ + UINT16 wTrainId = 0U; + UINT32 dwCurCycle = 0U; + UINT8 chIndex = 0U; + TrainEaStru szTmp[EA_MAX_NUM] = { 0U }; + UINT8 chRet = 0U; + + dwCurCycle = Get2oo2CurCycleNum(); + + wTrainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + stIvocToCiData.VobcId; + chRet = SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_GOOD); + chRet &= SetTrainDir(wTrainId, stIvocToCiData.trainDirection); + chRet &= SetTrainSpeed(wTrainId, stIvocToCiData.wTrainSpeed); + chRet &= SetTrainSpeedDir(wTrainId, stIvocToCiData.chSpeedDir); + chRet &= SetTrainLevel(wTrainId, stIvocToCiData.chTrainLevel); + chRet &= SetTrainMaxHeadLink(wTrainId, stIvocToCiData.wTrainMaxSafeHeadLink); + chRet &= SetTrainMaxTailLink(wTrainId, stIvocToCiData.wTrainMaxSafeTailLink); + chRet &= SetTrainMaxHeadOffset(wTrainId, stIvocToCiData.dwTrainMaxSafeHeadOffset); + chRet &= SetTrainMaxTailOffset(wTrainId, stIvocToCiData.dwTrainMaxSafeTailOffset); + chRet &= SetTrainMinHeadLink(wTrainId, stIvocToCiData.wTrainMinSafeHeadLink); + chRet &= SetTrainMinTailLink(wTrainId, stIvocToCiData.wTrainMinSafeTailLink); + chRet &= SetTrainMinHeadOffset(wTrainId, stIvocToCiData.dwTrainMinSafeHeadOffset); + chRet &= SetTrainMinTailOffset(wTrainId, stIvocToCiData.dwTrainMinSafeTailOffset); + chRet &= SetTrainOtherPointDir(wTrainId, stIvocToCiData.trainDirection); /*гȫˡСȫǰˡȫǰ˵з*/ + SetTrainMsgFromTiocId(wTrainId, 0U); + SetTrainSleepCancleFlag(wTrainId, TRAIN_SLEEP_CANCLE_YES); + +#if 0 + chRet &= SetGroupTrainOtherId(wTrainId, stIvocToCiData.wGroupOtherTrainId); + chRet &= SetGroupTrainRunState(wTrainId, stIvocToCiData.chGroupRunState); + chRet &= SetGroupTrainRelation(wTrainId, stIvocToCiData.chGroupTrainReat); +#endif + + if (dwCurCycle == stIvocToCiData.ComStartCycle) + { + chRet &= SetTrainZeroState(wTrainId, stIvocToCiData.chTrainZeroState); + SetTrainMode(wTrainId, stIvocToCiData.chTrainMode); + SetTrainWakeState(wTrainId, stIvocToCiData.chTrainWakeState); + SetTrainReportState(wTrainId, stIvocToCiData.chTrainReportState); /*г㱨״̬*/ + SetTrainHeadScreenConfirm(wTrainId, stIvocToCiData.chTrainHeadScreenConfirm); + SetTrainTailScreenConfirm(wTrainId, stIvocToCiData.chTrainTailScreenConfirm); + SetTrainEaNum(wTrainId, stIvocToCiData.chEaNum); + + for (chIndex = 0U; chIndex < stIvocToCiData.chEaNum; chIndex++) + { + szTmp[chIndex].wEaTrainId = stIvocToCiData.stEaInfo[chIndex].wDeviceId; + szTmp[chIndex].chAgreeState = stIvocToCiData.stEaInfo[chIndex].chDeviceStatus; + szTmp[chIndex].dwBuildCyc = stIvocToCiData.stEaInfo[chIndex].dwBuildCyc; + } + SetTrainEaInfo(wTrainId, szTmp); + + if (VOBC_CI_STOP_TW == stIvocToCiData.trainStopSteadyState) + { + SetTrainStopSteadyState(wTrainId, TRAIN_SS_YES); + } + else + { + SetTrainStopSteadyState(wTrainId, TRAIN_SS_NO); + } + + SetTrainActive(wTrainId, stIvocToCiData.chActive); + SetTrainRrmRqst(wTrainId, stIvocToCiData.chRrmReq); + SetTrainAtsLgcStation(wTrainId, stIvocToCiData.wNextStation); + SetTrainDerailment(wTrainId, stIvocToCiData.chDerailment); + SetHeadAxisId(wTrainId, stIvocToCiData.wHeadAxisId); + SetHeadITEResult(wTrainId, stIvocToCiData.wHeadITEResult); + SetTailAxisId(wTrainId, stIvocToCiData.wTailAxisId); + SetTailITEResult(wTrainId, stIvocToCiData.wTailITEResult); + } + else + { + /*δյгݣˢгϢ*/ + } + + if (CI_ERROR == chRet) + { + debug_infor_printf((const)"IvocInputRefreshTrain ERROR TrainID:%d\n", wTrainId); + } + else + { + /**/ + } +} + +/* +* г +* ˵ vobcToCiDataStruVOBCݽṹ +* ֵ void +* qw.liu 2022-02-26 +* ޸bug YF0083-100 +*/ +static void IvocInputCmdProc(const VobcToCiDataStruct stIvocToCiData) +{ + UINT16 wCmdSum = 0U; + UINT8 chCmdType = 0U; + UINT8 chCmdDevSum = 0U; + UINT16 wCmdDevId = 0U; + UINT16 wTrainId = 0U; + UINT8 chTrainLevel = 0U; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT8 cLogSecBelongCiId = 0u; + UINT16 wRouteId = 0u; + UINT16 wBufIndex = 0U; + UINT8 cRouteBelongCiId = 0u; + UINT8 cLocalCiId = 0u; + UINT8 funcSwitchJumpLockDriveSwitch = 0U; + UINT8 sameTrnId = CI_ERROR; + UINT8 logBelongCiId = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 belongVirCiId = 0U; + UINT8 devBelongCiId = 0U; + UINT8 chVirCIBelLocCiCheck = CI_ERROR;/*IDǷڱʵϽ*/ + UINT16 wLogRouteId = 0U; /*̬·ID*/ + UINT8 chExistEaCmd = CI_ERROR; /*Ƿɢ*/ + + wTrainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + stIvocToCiData.VobcId; + cLocalCiId = GetSystemParaLocalCiId(); + + funcSwitchJumpLockDriveSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH); + + wCmdSum = stIvocToCiData.wIvocCmdNum; + + if (IVOC_CI_CMD_MAX > wCmdSum) + { + for (ii = 0U; ii < wCmdSum; ii++) + { + chCmdType = stIvocToCiData.stCmdInfo[ii].chCmdType; + chCmdDevSum = stIvocToCiData.stCmdInfo[ii].chCmdDevNum; + if (IVOC_CI_CMD_DEVICE_MAX > chCmdDevSum) + { + switch(chCmdType) + { + case IVOC_CI_CMD_TYPE_RES_APPLY: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + /*ΪӦ߼ г־*/ + wLogRouteId = GetLogSecBelongLogRouteId(wCmdDevId, wTrainId); + if (0U != wLogRouteId) + { /*̬·߼*/ + SetLogRouteLogSecTrainLockApply(wCmdDevId, wTrainId); + } + else + { + /*޶̬·гԴʱŽͨ·Դļ飬ѽж̬·гԴ봦ִͨ·Դ봦*/ + SetLogSecTrainLockApply(wCmdDevId, wTrainId); + } + } + break; + } + case IVOC_CI_CMD_TYPE_RES_RELEASE: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj];/*߼*/ + wLogRouteId = GetLogSecBelongLogRouteId(wCmdDevId, wTrainId); + if (0U != wLogRouteId) + { /*̬·߼*/ + SetLogSecTrainRelease(wCmdDevId, wTrainId, 0U); + } + else + { + /*޶̬··*/ + wRouteId = GetLogSecLockBelongRoute(wCmdDevId); + cRouteBelongCiId = GetRouteBelongCiId(wRouteId); + cLogSecBelongCiId = GetLogSecBelongCiId(wCmdDevId); + if ((cLocalCiId == cLogSecBelongCiId) && (cLocalCiId == cRouteBelongCiId) && (0U != cRouteBelongCiId)) + { + /*ΪӦ߼ͷгʹñ־*/ + SetLogSecTrainRelease(wCmdDevId, wTrainId, 0U); + } + else if ((cLocalCiId == cLogSecBelongCiId) && (cLocalCiId != cRouteBelongCiId) && (0U != cRouteBelongCiId)) + {/*߼ΣVBTC ·DZ-*/ + chTrainLevel = GetTrainLevel(wTrainId); + if (TRAIN_LEVEL_VBTC == chTrainLevel) + { + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_LOGIC_LOCK_CANCEL, wCmdDevId, wTrainId, cRouteBelongCiId); + } + else + { + /*VBTC ߼ν*/ + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_NOTVBTC_LOGIC_LOCK_CANCEL, wCmdDevId, wTrainId, cRouteBelongCiId); + } + } + else + { + /**/ + ; + } + } + } + break; + } + case IVOC_CI_CMD_TYPE_PSD_OPEN_FOUR: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + + wBufIndex = GetPsdConfigBufIndex(wCmdDevId); /*ȡ±*/ + if (0u < wBufIndex) + { + if (PSD_SUM_MAX > wBufIndex) + { + SetPsdVobcCmd(wCmdDevId, wTrainId, VOBCTOCI_COMMAND_TYPE_PSDOPEN); + PsdDataStru[wBufIndex].psdEditGroupInfo = PSD_FOUR_EDIT_GROUP; + } + } + } + break; + } + case IVOC_CI_CMD_TYPE_PSD_OPEN_SIX: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + + wBufIndex = GetPsdConfigBufIndex(wCmdDevId); /*ȡ±*/ + if (0u < wBufIndex) + { + if (PSD_SUM_MAX > wBufIndex) + { + SetPsdVobcCmd(wCmdDevId, wTrainId, VOBCTOCI_COMMAND_TYPE_PSDOPEN); + PsdDataStru[wBufIndex].psdEditGroupInfo = PSD_SIX_EDIT_GROUP; + } + } + } + break; + } + case IVOC_CI_CMD_TYPE_PSD_OPEN_EIGHT: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + + wBufIndex = GetPsdConfigBufIndex(wCmdDevId); /*ȡ±*/ + if (0u < wBufIndex) + { + if (PSD_SUM_MAX > wBufIndex) + { + SetPsdVobcCmd(wCmdDevId, wTrainId, VOBCTOCI_COMMAND_TYPE_PSDOPEN); + PsdDataStru[wBufIndex].psdEditGroupInfo = PSD_EIGHT_EDIT_GROUP; + } + } + } + break; + } + case IVOC_CI_CMD_TYPE_PSD_CLOSE: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + wBufIndex = GetPsdConfigBufIndex(wCmdDevId); /*ȡ±*/ + if (0u < wBufIndex) + { + if (PSD_SUM_MAX > wBufIndex) + { + SetPsdVobcCmd(wCmdDevId, wTrainId, VOBCTOCI_COMMAND_TYPE_PSDCLOSE); + PsdDataStru[wBufIndex].psdEditGroupInfo = PSD_FOUR_EDIT_GROUP; + } + } + } + break; + } + /** ߼Ծ */ + case IVOC_CI_CMD_TYPE_JUMP_LOCK_APPLY: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + logBelongCiId = GetLogSecBelongCiId(wCmdDevId); + /** ߼ڱTIOC */ + if (logBelongCiId == cLocalCiId) + { + /** ԾгID */ + SetLogSecJumpLockTrainId(wCmdDevId, wTrainId); +#if 0 + /** Ծܿش */ + if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch) + { + axisSecId = GetLgcSecRelativeAxleSecId(wCmdDevId); + switchSum = GetAxisSwitchSum(axisSecId); + /** ߼ι */ + if (0u < switchSum) + { + /** ߼ιļԾ־ں */ + SetAxisSecJumpLockApplyFlag(axisSecId, AXIS_SECTION_JUMPLOCK_APPLY_YES);/*üԾ*/ + SetAxisSecJumpLockCancelApplyFlag(axisSecId, AXSEC_CANCEL_JUMPLOCK_APPLY_NO);/*üԾͷ*/ + SetAxisSecJumpLockApplyCylce(axisSecId, curCycle);/*üԾں*/ + } + else + { + /** ߼Ծ߼ */ + LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_YES); + } + } + else + {/* ĬϹܿز */ + /** ߼Ծ߼ */ + LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_YES); + } +#endif + /** жԾгIDԾгIDǷͬ */ + sameTrnId = JudgeLogSecJumpLockRelTrainId(wCmdDevId, wTrainId); + /** ͬ */ + if (CI_SUCCESS == sameTrnId) + { + /** ߼Ծ߼ */ + LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_YES); + } + else + { + /** */ + } + } + else + { + /** DZTIOC߼Ծ */ + } + } + break; + } + /** ߼Ծͷ */ + case IVOC_CI_CMD_TYPE_JUMP_LOCK_RELEASE: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + logBelongCiId = GetLogSecBelongCiId(wCmdDevId); + /** ߼ڱTIOC */ + if (logBelongCiId == cLocalCiId) + { + /** жԾͷгIDԾгIDǷͬ */ + sameTrnId = JudgeLogSecJumpLockRelTrainId(wCmdDevId, wTrainId); + /** ͬ */ + if (CI_SUCCESS == sameTrnId) + { + /** ԾгID */ + ClearLogSecJumpLockTrainId(wCmdDevId); +#if 0 + /** Ծܿش */ + if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch) + { + axisSecId = GetLgcSecRelativeAxleSecId(wCmdDevId); + switchSum = GetAxisSwitchSum(axisSecId); + if (0u < switchSum) + { + /** ߼ιļԾͷű־ */ + SetAxisSecJumpLockApplyFlag(axisSecId, AXIS_SECTION_JUMPLOCK_APPLY_NO);/*üԾ*/ + SetAxisSecJumpLockCancelApplyFlag(axisSecId, AXSEC_CANCEL_JUMPLOCK_APPLY_YES);/*üȡԾ*/ + } + else + { + /** ߼Ծ߼ */ + LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_NO); + } + } + else + {/* ĬϹܿز */ + /** ߼Ծ߼ */ + LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_NO); + } +#endif + /** ߼Ծ߼ */ + LogJumpLockCmdManage(wCmdDevId, LOGIC_SECTION_JUMP_LOCK_NO); + } + else + { + /** ͷгδԾգ */ + } + } + else + { + /** ߼ڱTIOC */ + } + } + break; + } + /*̬*/ + case IVOC_CI_CMD_TYPE_DYTEST_REQ: + { + SetTrainDynCmd(wTrainId, TRAIN_CMD_DYM_YES); + break; + } + /*̬ȡ*/ + case IVOC_CI_CMD_TYPE_DYTEST_CANCEL: + { + SetTrainDynCmd(wTrainId, TRAIN_CMD_DYM_NO); + DelTrainDyTesting(wTrainId); + break; + } + case IVOC_CI_CMD_GAP_DETECT_START: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + + SetStartDetectionState(wCmdDevId, JXTC_START_DETECTION_YES); + SetStopDetectionState(wCmdDevId, JXTC_STOP_DETECTION_NO); + } + break; + } + case IVOC_CI_CMD_GAP_DETECT_STOP: + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + + SetStartDetectionState(wCmdDevId, JXTC_START_DETECTION_NO); + SetStopDetectionState(wCmdDevId, JXTC_STOP_DETECTION_YES); + } + break; + } + case IVOC_CI_CMD_TYPE_EA_BUILD: + { + SetTrainEaCmd(wTrainId, EA_PROTECT_BUILD); + /*ɢ*/ + chExistEaCmd = CI_SUCCESS; + break; + } + case IVOC_CI_CMD_NON_RETURN_STEADY: + { + + if (FUNC_SWITCH_ON == includeVirFlag) + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + belongVirCiId = GetNonAutoBelongVirCiId(wCmdDevId); + chVirCIBelLocCiCheck = GetVirCIBelongLocalCI(belongVirCiId); + if (CI_ERROR == chVirCIBelLocCiCheck) + { + break; + } + else + { + ; /*ڱϽ*/ + } + } + if (jj == chCmdDevSum) + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + SetNonRtnCmdSetTrainId(wCmdDevId, wTrainId); + + SetVirCIautoRtnIndictFlashState(wCmdDevId,belongVirCiId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*״̬ΪЧ*/ + SetVirCIautoRtnIndictSteadyState(wCmdDevId,belongVirCiId, VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*ȵ״̬ΪЧ*/ + } + + } + else + { + /*ڷDZ豸*/ + } + } + else + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + devBelongCiId = GetNonAutoBelongCiId(wCmdDevId); + if (cLocalCiId == devBelongCiId) + { + ; + } + else + { + break; + } + } + if (jj == chCmdDevSum) + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + SetNonRtnCmdSetTrainId(wCmdDevId, wTrainId); + SetAutoRtnIndictFlashState(wCmdDevId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*״̬Ч*/ + SetAutoRtnIndictSteadyState(wCmdDevId,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*ȵ״̬Ч*/ + } + } + else + { + /*ڷDZ豸*/ + } + } + break; + } + case IVOC_CI_CMD_NON_RETURN_FLASH: + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + belongVirCiId = GetNonAutoBelongVirCiId(wCmdDevId); + chVirCIBelLocCiCheck = GetVirCIBelongLocalCI(belongVirCiId); + if (CI_ERROR == chVirCIBelLocCiCheck) + { + break; + } + else + { + ; /*ڱϽ*/ + } + } + if (jj == chCmdDevSum) + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + SetNonRtnCmdSetTrainId(wCmdDevId, wTrainId); + + SetVirCIautoRtnIndictFlashState(wCmdDevId,belongVirCiId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*״̬ΪЧ*/ + SetVirCIautoRtnIndictSteadyState(wCmdDevId,belongVirCiId, VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*ȵ״̬ΪЧ*/ + } + } + else + { + /*ڷDZ豸*/ + } + } + else + { + + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + devBelongCiId = GetNonAutoBelongCiId(wCmdDevId); + if (cLocalCiId == devBelongCiId) + { + ; + } + else + { + break; + } + } + if (jj == chCmdDevSum) + { + for (jj = 0U; jj < chCmdDevSum; jj++) + { + wCmdDevId = stIvocToCiData.stCmdInfo[ii].wCmdDevId[jj]; + SetNonRtnCmdSetTrainId(wCmdDevId, wTrainId); + + SetAutoRtnIndictFlashState(wCmdDevId,VOBCTOCIAUTORTN_INDICT_MASK_VALID);/*״̬Ч*/ + SetAutoRtnIndictSteadyState(wCmdDevId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*ȵ״̬Ч*/ + } + } + else + { + /*ڷDZ豸*/ + } + } + break; + } + case IVOC_CI_CMD_TYPE_EMD_BUILD: + { + SetTrainEaCmd(wTrainId, EA_PROTECT_BUILD); + /*ɢ*/ + chExistEaCmd = CI_SUCCESS; + break; + } + default: + /*ɴ֧*/ + break; + } + } + } + + if (CI_SUCCESS == chExistEaCmd) + { + /*ɢ*/ + SetTrainEaCmdState(wTrainId, TRAIN_EA_CMD_STATE_VALID); + } + else + { + /*ɢ*/ + SetTrainEaCmdState(wTrainId, TRAIN_EA_CMD_STATE_INVALID); + } +#if 0 + /**Ծܿش򿪣ͬһζ߼Ծմ*/ + if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch) + { + for (ii = 0u; ii < phyNum; ii++) + { + phyId = GetPhySecId(ii); + phyBelongCiId = GetPhySecBelongCiId(phyId); + phyAxisSecNum = GetPAxisSectionSum(phyId);/*ȡι*/ + pPhyAxisIDBuf = GetPAxisSectionIdBuf(phyId);/*ȡιID*/ + numAxisHaveJumpLockApply = 0u; + if (NULL != pPhyAxisIDBuf) + { + if (phyBelongCiId == cLocalCiId) + {/*ڱ*/ + for (jj = 0u; jj 1u) + {/*һζԾ*/ + /*εеļ붼óδ*/ + for (jj = 0u; jj < phyAxisSecNum; jj++) + { + axisSecId = pPhyAxisIDBuf[jj]; + SetAxisSecJumpLockApplyFlag(axisSecId, AXIS_SECTION_JUMPLOCK_APPLY_NO); + SetAxisSecJumpLockApplyCylce(axisSecId, 0u); + } + } + } + + } + + } + } +#endif + } +} + +/* +* @func гʧͨ +* @param vobcToCiDataStruVOBCݽṹ +* @retrun void +* @create qw.liu 2022-08-13 +*/ +static void ProcessIvocLoseCom(const VobcToCiDataStruct stIvocToCiData) +{ + /**ʼ*/ + UINT16 wTrainId = 0U; + UINT8 chTrainTransmitState = 0U; + UINT8 trainMsgFromTiocId = 0u; + UINT8 chLjkExistDBSwitch = 0U; + UINT8 chVirHeadScreenPassFlag = 0U;/*ǰɸ־*/ + UINT8 chVirTailScreenPassFlag = 0U;/*ɸ־*/ + +#if 0 + UINT32 dwRecvIvocCount = 0U; + const UINT32 dwIvoc = GetCiAndVobcTransBadEnsureCnt(); + dwRecvIvocCount = stIvocToCiData.ComStartCycle; + chTimeState = SystemOverTimeCheck(dwRecvIvocCount, dwIvoc); +#endif + wTrainId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + stIvocToCiData.VobcId; + chTrainTransmitState = GetTrainTransitmitStat(wTrainId); + if ((TRAIN_COMM_STATE_UNKNOWN != chTrainTransmitState) + && (TRAIN_COMM_STATE_BAD!= chTrainTransmitState)) + { + trainMsgFromTiocId = GetTrainMsgFromTiocId(wTrainId); + /**ͨųϢTIOC*/ + if (0u == trainMsgFromTiocId) + { + (void)SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_BAD); + if ((IVOC_CI_INFO_TYPE_LOGOUT_ASK != stIvocToCiData.appInfoType) + && (IVOC_CI_LOGOUT_SLEEP != stIvocToCiData.chLogOutState)) + { + SetTrainSleepState(wTrainId, TRAIN_SLEEP_NO); + SetTrainSleepLink(wTrainId, 0u); + debug_infor_printf((const)"Train%x delete sleep state because comm bad.\n", wTrainId); + } + else + { + ; /**/ + } + } + else + { + + } + SetTrainDynCmd(wTrainId, TRAIN_CMD_DYM_NO); + DelTrainDyTesting(wTrainId); + + /*۷óΪʼֵ*/ + IvocNonAutoRtnProcess(wTrainId); + + chLjkExistDBSwitch = GetCiFunctionSwitchConfig(FUNC_LJK_EXIST_DB); + /*DB·ͨɸѡ־пɿԼ򳵻ATSԭɸѡ*/ + chVirHeadScreenPassFlag = GetTrainVirHeadScreenPassFlag(wTrainId); + chVirTailScreenPassFlag = GetTrainVirTailScreenPassFlag(wTrainId); + + if ((FUNC_SWITCH_OFF == chLjkExistDBSwitch) + || (TRAIN_VIR_SCREEN_PASS_FLAG_INVALID == chVirHeadScreenPassFlag) + || (TRAIN_VIR_SCREEN_PASS_FLAG_INVALID == chVirTailScreenPassFlag)) + { + /*DBһɸѡ־Ч˵ɸѡ*/ + SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainFullEnterLjkCycNum(wTrainId, 0U); + SetTrainEnterLjkLinkId(wTrainId, 0U); + } + else + { + ; + } + + SetTrainReportState(wTrainId, 0U); /*гͨжʱг㱨״̬Ϊ0*/ + + SetTrainDerailment(wTrainId, TRAIN_DERAIL_NO); + /*ͨжɢ״̬ΪЧ*/ + SetTrainEaCmdState(wTrainId, TRAIN_EA_CMD_STATE_INVALID); + } +} + +/* +* IVOC۷ʼֵ +* ˵ trainIdгID +* ֵ +*/ +static void IvocNonAutoRtnProcess(const UINT16 trainId) +{ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT16 ii = 0U; + UINT16 nonReturnSum = 0U; + UINT16 nonAutoReturnId = 0U; + UINT16 cmdSetTrainId = 0U; + UINT8 virCiId = 0U; + + if (0U != trainId) + { + nonReturnSum = GetNonAutoReturnCurSum(); + for (ii = 0U; ii < nonReturnSum; ii++) + { + nonAutoReturnId = GetNonReturnId(ii); + cmdSetTrainId = GetNonRtnCmdSetTrainId(nonAutoReturnId); + if (cmdSetTrainId == trainId) + + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + virCiId = GetNonAutoBelongVirCiId(nonAutoReturnId); + + SetVirCIautoRtnIndictFlashState(nonAutoReturnId,virCiId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*״̬ΪЧ*/ + SetVirCIautoRtnIndictSteadyState(nonAutoReturnId,virCiId, VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*ȵ״̬ΪЧ*/ + } + else + { + SetAutoRtnIndictFlashState(nonAutoReturnId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*״̬Ч*/ + SetAutoRtnIndictSteadyState(nonAutoReturnId,VOBCTOCIAUTORTN_INDICT_MASK_INVALID);/*ȵ״̬Ч*/ + } + SetNonRtnCmdSetTrainId(nonAutoReturnId,0U); + } + } + } +} + +/* +* IVOCδ +* ˵vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void IvocUnLockOverlapProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 localCiId = 0U; /*ID*/ + UINT8 cOverlapBelongCiId = 0U; /*CI*/ + UINT16 wTrainId = 0U; + UINT32 dwUnlockOverlapStartCyc = 0U; /*εʼں*/ + UINT8 ii = 0U; + + localCiId = GetSystemParaLocalCiId(); + + if (NULL != vobcToCiDataStru) + { + for (ii = 0U; ii < vobcToCiDataStru->cAllowUnlockOverlapNum; ii++) + { + cOverlapBelongCiId = GetOverlapBelongCiId(vobcToCiDataStru->szAllowUnlockOverlapId[ii]); + + if ((0U != cOverlapBelongCiId) && (localCiId == cOverlapBelongCiId)) /*ı*/ + { + wTrainId = GetOverlapUnlockApplyTrainId(vobcToCiDataStru->szAllowUnlockOverlapId[ii]); /*ȡгID*/ + dwUnlockOverlapStartCyc = GetReqIvocUnlockStartCycNum(vobcToCiDataStru->szAllowUnlockOverlapId[ii]); /*ȡʼں*/ + + if ((0U != wTrainId) && (vobcToCiDataStru->VobcId == wTrainId) + && (0U != dwUnlockOverlapStartCyc) && (vobcToCiDataStru->szAllowUnlockOverlapStartCyc[ii] == dwUnlockOverlapStartCyc)) + { + SetOverlapUnlockApplyTrainId(vobcToCiDataStru->szAllowUnlockOverlapId[ii], 0U); + SetReqIvocUnlockStartCycNum(vobcToCiDataStru->szAllowUnlockOverlapId[ii], 0U); + SetOverlapIvocAllowUnlockFlag(vobcToCiDataStru->szAllowUnlockOverlapId[ii], IVOC_ALLOW_UNLOCK_OVERLAP_YES); /*ñгͬ*/ + } + else + { + /*㣬*/ + } + } + else + { + /*DZΣ*/ + } + } + } + else + { + /**/ + } +} + +/* +* IVOCϴϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20231109 +*/ +static void IvocWashDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT16 washMachineCurSum = 0U;/*ǰϴ*/ + UINT16 washMachineId = 0U;/*ϴID*/ + UINT16 wCurVobcId = 0U;/*ǰVOBC ID*/ + + if (NULL != vobcToCiDataStru) + { + /*ȡǰϴ*/ + washMachineCurSum = GetWashMachineSum(); + + /*ǰΪһһȫԶϴ*/ + if (1U == washMachineCurSum) + {/*һ̨ȫԶϴ*/ + washMachineId = GetWashMachineId(0U); + /*ȡϴǰϴVOBC ID*/ + wCurVobcId = GetWashMachineCurVobcID(washMachineId); + + if (0U == wCurVobcId) + { + /*ֻеǰûгϴҵϴЧʱõǰϴVOBC IDͬʱVOBC IDvobcCIϢȷֹVOBCCI֡ҲVOBC ID*/ + if (IVOC_CI_INFO_TYPE_CONTROL == vobcToCiDataStru->appInfoType) + { + SetWashMachineCurVobcID(washMachineId, vobcToCiDataStru->VobcId);/*ϴǰϴVOBC ID*/ + } + else + { + ; /*ϢͲȷ*/ + } + + /*ٴλȡϴǰϴVOBC ID*/ + wCurVobcId = GetWashMachineCurVobcID(washMachineId); + } + else + { + ; /**/ + } + + /*ϴǰǸVOBC*/ + if (wCurVobcId == vobcToCiDataStru->VobcId) + { + /*ϴ״̬*/ + SetIvocWashDriveState(vobcToCiDataStru, washMachineId); + } + else + { + ; /*Ϣ*/ + } + } + else + { + ; /*ϴޣϴIDֵ*/ + } + } + else + { + ; /**/ + } +} + +/* +* IVOCϴ״̬ +* ˵ vobcToCiDataStruVOBCݽṹָ +* const UINT16 washMachineId ϴID +* ֵ void +* by cgh 20231110 +*/ +static void SetIvocWashDriveState(VobcToCiDataStruct* vobcToCiDataStru,const UINT16 washMachineId) +{ + if ((NULL != vobcToCiDataStru) && (0U < washMachineId) && (WASHMACHINE_SUM_MAX > washMachineId)) + { + if ((WASHMACHINE_DRVSTATE_REQ_FALSE == vobcToCiDataStru->washTrainRequest) + && (WASHMACHINE_HEAD_STEADY_NO == vobcToCiDataStru->headWashStopSteadyInfo) + && (WASHMACHINE_TAIL_STEADY_NO == vobcToCiDataStru->tailWashStopSteadyInfo) + && (PASS_WASHMACHINE_REQUEST_INVALID == vobcToCiDataStru->passWashMachineRequest) + && (PAUSE_TRAIN_WASH_REQUEST_INVALID == vobcToCiDataStru->washPauseRequest)) + { + ClearWashVobcDriveState(vobcToCiDataStru); + } + else + { + if (WASHMACHINE_DRVSTATE_REQ_TRUE == vobcToCiDataStru->washTrainRequest) + { + /*ϴЧ*/ + SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_TRUE); + /*ϴЧVOBC·ϴģʽ״̬*/ + SetWashMachineWorkModeDrvState(washMachineId, vobcToCiDataStru->chWashMachineWorkMode); + } + else + { + SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE); + /*ϴЧϴģʽ״̬Ч*/ + SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV); + } + + if (WASHMACHINE_HEAD_STEADY_YES == vobcToCiDataStru->headWashStopSteadyInfo) + { + /*ͷͣЧ*/ + SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_YES); + } + else + { + SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO); + } + + if (WASHMACHINE_TAIL_STEADY_YES == vobcToCiDataStru->tailWashStopSteadyInfo) + { + /*βͣЧ*/ + SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_YES); + } + else + { + SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO); + } + + if (WASHMACHINE_PAUSE_DRVREQ_TRUE == vobcToCiDataStru->washPauseRequest) + { + /*ͣϴЧ*/ + SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_TRUE); + } + else + { + SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE); + } + + if (PASS_WASHMACHINE_DRVREQ_TRUE == vobcToCiDataStru->passWashMachineRequest) + { + /*ͨϴЧ*/ + SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_TRUE); + } + else + { + SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE); + } + } + } + else + { + ; /**/ + } +} + +/* +* ϴVOBC״̬ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20231110 +*/ +void ClearWashVobcDriveState(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT16 washMachineCurSum = 0U;/*ǰϴ*/ + UINT16 washMachineId = 0U;/*ϴID*/ + UINT16 wCurVobcId = 0U;/*ǰVOBC ID*/ + + if (NULL != vobcToCiDataStru) + { + /*ȡǰϴ*/ + washMachineCurSum = GetWashMachineSum(); + + /*ǰΪһһȫԶϴ*/ + if (1U == washMachineCurSum) + {/*һ̨ȫԶϴ*/ + washMachineId = GetWashMachineId(0U); + /*ȡϴǰϴVOBC ID*/ + wCurVobcId = GetWashMachineCurVobcID(washMachineId); + + if (wCurVobcId == vobcToCiDataStru->VobcId) + { + SetWashMachineCurVobcID(washMachineId, 0U);/*ǰϴVOBC ID*/ + /*ϴ״̬*/ + SetWashTrainRequestDrvState(washMachineId, WASHMACHINE_DRVSTATE_REQ_FALSE); + SetTrainHeadStopSteadyDrvState(washMachineId, WASHMACHINE_HEAD_STEADY_NO); + SetTrainTailStopSteadyDrvState(washMachineId, WASHMACHINE_TAIL_STEADY_NO); + SetPauseTrainWashRequestDrvSta(washMachineId, WASHMACHINE_PAUSE_DRVREQ_FALSE); + SetPassWashMachineReqtDrvSta(washMachineId, PASS_WASHMACHINE_DRVREQ_FALSE); + SetWashMachineWorkModeDrvState(washMachineId, WASHMACHINE_WORKMODE_INVALID_DRV); + } + else + { + ;/*Ϣ*/ + } + } + else + { + ; /*ϴޣϴIDֵ*/ + } + } + else + { + ; /**/ + } +} + + +/* +* IVOCŹرȷϴ +* ˵vobcToCiDataStruVOBCݽṹָ +* ֵ void +* BY LC +*/ +static void IvocGarageDoorCloseProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 localCiId = 0U; /*ID*/ + UINT8 wBelongCiId = 0U; /*CI*/ + UINT16 wGarageDoorId = 0U; + UINT32 dwGDCloseApplyStartCyc = 0U; /*رճŵʼں*/ + UINT8 ii = 0U; + UINT16 wTrainId = 0U; /*Aӽг*/ + + + localCiId = GetSystemParaLocalCiId(); + + if (NULL != vobcToCiDataStru) + { + for (ii = 0U; ii < vobcToCiDataStru->cAllowCloseGarageGateNum; ii++) + { + wBelongCiId = GetGaragedoorBelongCiId(vobcToCiDataStru->szAllowCloseGarageGateId[ii]); + + if ((0U != wBelongCiId) && (localCiId == wBelongCiId)) /*ij*/ + { + wGarageDoorId = vobcToCiDataStru->szAllowCloseGarageGateId[ii]; /*ȡȷϹرյijID*/ + dwGDCloseApplyStartCyc = GetWaiteIVOCResponseStartCycNum(wGarageDoorId); /*ȡIVOCرյʼں*/ + wTrainId = GetGaragedoorNearestTrainId(wGarageDoorId); + if ((0U != wGarageDoorId) && (GARAGE_DOOR_SUM_MAX != wGarageDoorId) + && (0U != dwGDCloseApplyStartCyc) && (vobcToCiDataStru->szAllowCloseGarageGateCyc[ii] == dwGDCloseApplyStartCyc) + && (wTrainId == vobcToCiDataStru->VobcId) && (0U != wTrainId)) + { + SetGaragedoorAllowCloseFlagIVOC(wGarageDoorId, GARAGE_DOOR_ALLOW_CLOSE_YES); + } + else + { + /**/ + } + } + else + { + /*DZΣ*/ + } + } + } + else + { + /**/ + } +} + +/* +* IVOCŹرȷϴ +* ˵vobcToCiDataStruVOBCݽṹָ +* ֵ void +* BY LC +*/ +static void IvocFloodGateCloseProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 localCiId = 0U; /*ID*/ + UINT8 cFloodGateBelongCiId = 0U; /*CI*/ + UINT16 wFloodGateId = 0U; + UINT32 dwFloodGateCloseApplyStartCyc = 0U; /*Źʼں(ʱʼ)*/ + UINT8 ii = 0U; + + localCiId = GetSystemParaLocalCiId(); + + if (NULL != vobcToCiDataStru) + { + for (ii = 0U; ii < vobcToCiDataStru->cAllowCloseFloodGateNum; ii++) + { + cFloodGateBelongCiId = GetFloodGateBelongCiId(vobcToCiDataStru->szAllowCloseFloodGateId[ii]); + + if ((0U != cFloodGateBelongCiId) && (localCiId == cFloodGateBelongCiId)) /*ķ*/ + { + wFloodGateId = vobcToCiDataStru->szAllowCloseFloodGateId[ii]; /*ȡȷϹرյķID*/ + dwFloodGateCloseApplyStartCyc = GetFloodGateDelayCloseStartCnt(wFloodGateId); /*ȡIVOCرյʼںţʱʼں*/ + + if ((0U != wFloodGateId) && (FLOOD_GATE_SUM_MAX != wFloodGateId) + && (0U != dwFloodGateCloseApplyStartCyc) && (vobcToCiDataStru->szAllowCloseFloodGateCyc[ii] == dwFloodGateCloseApplyStartCyc)) + { + SetFloodGateAllowCloseFlagIVOC(wFloodGateId, vobcToCiDataStru->VobcId, FLOOD_GATE_ALLOWCLOSE_IVOC); + } + else + { + SetFloodGateAllowCloseFlagIVOC(wFloodGateId, vobcToCiDataStru->VobcId, FLOOD_GATE_NOT_ALLOWCLOSE_IVOC); + } + } + else + { + /*DZΣ*/ + } + } + } + else + { + /**/ + } +} + +/* +* VobcƵϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20231214 +*/ +static void VobcVideoQkDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT16 wPsdSum = 0U;/**/ + UINT16 ii = 0U; + UINT16 wPsdId = 0U;/*ID*/ + UINT16 wPsdVideoQkRelateVobcId = 0U;/*Ƶ͹VOBC ID*/ + + if (NULL != vobcToCiDataStru) + { + if (VIDEO_QK_STATE_DEFAULT == vobcToCiDataStru->chVideoQkState) + { + /*Ƶ״̬ΪĬֵҪƵ״̬ΪЧ*/ + wPsdSum = GetPsdSum(); + for (ii = 0U; ii < wPsdSum; ii++) + { + wPsdId = GetPsdId(ii); + if ((0U < wPsdId) && (PSD_SUM_MAX > wPsdId)) + { + wPsdVideoQkRelateVobcId = GePsdVideoQkRelateVobcId(wPsdId); + + if (wPsdVideoQkRelateVobcId == vobcToCiDataStru->VobcId) + { + /*öӦгƵ״̬ΪЧ*/ + SetPsdVideoQkDriveState(wPsdId,VIDEO_QK_DRIVE_STATE_INVALID); + SetPsdVideoQkRelateVobcId(wPsdId, 0U); + } + else + { + ; /*ûжԴŽƵͣ״̬*/ + } + } + else + { + ; /*IDϷ*/ + } + } + } + else if(VIDEO_QK_STATE_TESTING == vobcToCiDataStru->chVideoQkState) + { + /*Ƶ״̬Ϊ*/ + if (VIDEO_QK_RESULT_TESTDEFAULT == vobcToCiDataStru->chVideoQkResult) + { + /*ƵͽΪĬ*/ + SetRelatePsdVideoQkDriveState(vobcToCiDataStru->wVideoQkRelatePsdId1, vobcToCiDataStru->wVideoQkRelatePsdId2, VIDEO_QK_DRIVE_STATE_TESTING, vobcToCiDataStru->VobcId); + + } + else if (VIDEO_QK_RESULT_TESTNO == vobcToCiDataStru->chVideoQkResult) + { + /*ƵͽΪѼ*/ + SetRelatePsdVideoQkDriveState(vobcToCiDataStru->wVideoQkRelatePsdId1, vobcToCiDataStru->wVideoQkRelatePsdId2, VIDEO_QK_DRIVE_STATE_NO, vobcToCiDataStru->VobcId); + } + else if (VIDEO_QK_RESULT_TESTHAVE == vobcToCiDataStru->chVideoQkResult) + { + /*ƵͽΪѼ*/ + SetRelatePsdVideoQkDriveState(vobcToCiDataStru->wVideoQkRelatePsdId1, vobcToCiDataStru->wVideoQkRelatePsdId2, VIDEO_QK_DRIVE_STATE_HAVE, vobcToCiDataStru->VobcId); + } + else + { + ; /*Ƿ״̬*/ + } + } + else + { + ; /*Ƿ״̬*/ + } + } + else + { + ; /**/ + } +} + +/* +* ùPSDƵ״̬ +* ˵ const UINT16 wPsdId1 ID1 +* const UINT16 wPsdId2 ID2 +* const UINT8 chSetState Ƶ״̬ +* const UINT16 wRelateVobcId Ƶ͹VOBC ID +* ֵ void +* by cgh 20231214 +*/ +void SetRelatePsdVideoQkDriveState(const UINT16 wPsdId1, const UINT16 wPsdId2,const UINT8 chSetState,const UINT16 wRelateVobcId) +{ + if ((PSD_SUM_MAX > wPsdId1) && (PSD_SUM_MAX > wPsdId2)) + { + /*IDΪ0ֵֻ*/ + if (0U != wPsdId1) + { + SetPsdVideoQkDriveState(wPsdId1,chSetState); + SetPsdVideoQkRelateVobcId(wPsdId1, wRelateVobcId); + } + else + { + ; /*ƵIDΪ0״̬*/ + } + + if (0U != wPsdId2) + { + /*öӦгƵȷ״̬ΪѼ*/ + SetPsdVideoQkDriveState(wPsdId2,chSetState); + SetPsdVideoQkRelateVobcId(wPsdId2, wRelateVobcId); + } + else + { + ; /*ƵIDΪ0״̬*/ + } + } + else + { + ; /*IDϷд*/ + } +} + +/* +* ӦгڶӦϵͣϢ +* ˵ UINT16 wTrainId гID +* ֵ void +*/ +void ClearVobcStopSteadyData(UINT16 wTrainId) +{ + UINT16 phySecCurSum = 0U; + UINT16 ii = 0U; + UINT16 deviceId = 0U; + UINT16 PhyStopSteadyTrainId = 0U; + phySecCurSum = GetPhySecCurSum(); + /* ζӦгͣϢ */ + for (ii = 0U; ii < phySecCurSum; ii++) + { + deviceId = GetPhySecId(ii); + PhyStopSteadyTrainId = GetPhyStopSteadyTrainId(deviceId); + + /*ӦͣϢ*/ + if ((0U != PhyStopSteadyTrainId) && (wTrainId == PhyStopSteadyTrainId)) + { + SetPhySecStopSteadyFlag(deviceId, PHYSICAL_SECTION_STOPSTEADY_NO);/*δͣ*/ + SetPhyStopSteadyTrainId(deviceId, 0U); /*ϵijID*/ + } + else + { + ; /*δͣȵijID֤гδڴϷͣ*/ + } + } +} + +/* +* VobcǰλϢ +* ˵ const UINT16 wTrainId гID +* ֵ void +* by cgh 20240606 +*/ +void VobcHeadTrainDataProc(const UINT16 wTrainId) +{ + UINT8 chReval = CI_ERROR; + TrainIteDataStruct* strTrainIteData = NULL; + UINT16 wHeadTrainId = 0U;/*ǰID*/ + HeadTrainLocStru strTempHeadTrainLocData = { 0U };/*ʱǰλ*/ + UINT16 wTrainMaxHeadLink = 0U;/*ǰLINK*/ + UINT32 dwTrainMaxHeadOffect = 0U;/*ǰƫ*/ + UINT16 wTrainMinTailLink = 0U;/*СLINK*/ + UINT32 dwTrainMinTailOffect = 0U;/*Сƫ*/ + UINT8 chTrainDir = 0U;/*г*/ + UINT32 dwVobcHlhtId = 0U;/*гͨID*/ + UINT16 wTrainIndex = 0U;/*гID*/ + UINT16 wVobcDevName = 0U; + UINT8 chDir = 0U;/*Ӫ*/ + UINT8 chNvramPosFlag = TRAIN_NVRAM_POS_FLAG_YES; + + wTrainIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wTrainIndex) + { + wVobcDevName = GetTrainHeadTrainId(wTrainId); + wHeadTrainId = GetTrainBufIndex(wVobcDevName); + if (TRAIN_SUM_MAX > wHeadTrainId) + { + chReval = dquDevName2HlhtId(wVobcDevName, 0U, &dwVobcHlhtId); + if (CI_SUCCESS == chReval) + { + wTrainMaxHeadLink = GetAblTrainMaxHeadLink(wHeadTrainId); + dwTrainMaxHeadOffect = GetAblTrainMaxHeadOffset(wHeadTrainId); + wTrainMinTailLink = GetAblTrainMinTailLink(wHeadTrainId); + dwTrainMinTailOffect = GetAblTrainMinTailOffset(wHeadTrainId); + chTrainDir = GetAblTrainDir(wHeadTrainId); + chDir = ConvertLogicDirToRun(chTrainDir); + strTrainIteData = GetTrainIteData(wHeadTrainId); + + chNvramPosFlag = GetTrainNvramPosFlag(wHeadTrainId); + if (TRAIN_NVRAM_POS_FLAG_NO == chNvramPosFlag) + { + /*NVRAMλÿŲżλã÷Ĭֵ*/ + if ((0U != wTrainMaxHeadLink) && (0U != wTrainMinTailLink)) + { + /*ЧֵӿѾУ*/ + strTempHeadTrainLocData.wHeadVobcId = dwVobcHlhtId; + strTempHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_ATP; + strTempHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = chDir; + strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = wTrainMaxHeadLink; + strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = dwTrainMaxHeadOffect; + strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = wTrainMinTailLink; + strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = dwTrainMinTailOffect; + strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = 0U; + strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = 0U; + strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = TRAIN_DIR_DEF; + strTempHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = UINT16_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = UINT16_MAX; + } + else if (NULL != strTrainIteData) + { + /*ITEݻȡɹĶЧ*/ + if (0U != strTrainIteData[0].wTrainHeadLinkId) + { + strTempHeadTrainLocData.wHeadVobcId = dwVobcHlhtId; + strTempHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_ITE; + strTempHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = TRAIN_DIR_DEF; + strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = 0U; + strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = 0U; + strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = strTrainIteData[0].wTrainHeadLinkId; + strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = strTrainIteData[0].dwTrainHeadLinkOffset; + strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = strTrainIteData[0].wTrainTailLinkId; + strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = strTrainIteData[0].dwTrainTailLinkOffset; + strTempHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = strTrainIteData[0].cTrainDir; + strTempHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = strTrainIteData[0].wForWardOffset; + strTempHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = strTrainIteData[0].wBackOffset; + } + else if (0U != strTrainIteData[1].wTrainHeadLinkId) + { + strTempHeadTrainLocData.wHeadVobcId = dwVobcHlhtId; + strTempHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_ITE; + strTempHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = TRAIN_DIR_DEF; + strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = 0U; + strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = 0U; + strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = strTrainIteData[1].wTrainHeadLinkId; + strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = strTrainIteData[1].dwTrainHeadLinkOffset; + strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = strTrainIteData[1].wTrainTailLinkId; + strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = strTrainIteData[1].dwTrainTailLinkOffset; + strTempHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = strTrainIteData[1].cTrainDir; + strTempHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = strTrainIteData[1].wForWardOffset; + strTempHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = strTrainIteData[1].wBackOffset; + } + else + { + chReval = CI_ERROR; + } + } + else + { + chReval = CI_ERROR; + } + } + else + { + chReval = CI_ERROR; + } + } + else + { + chReval = CI_ERROR; + } + + } + else + { + chReval = CI_ERROR; + } + + if (CI_ERROR == chReval) + { + /*Ĭֵ*/ + ClearVobcHeadTrainData(wTrainId); + } + else + { + SetTrainHeadTrainLocData(wTrainId, strTempHeadTrainLocData); /*Ч*/ + } + } + else + { + ; /**/ + } +} + +/* +* VobcǰλϢ +* ˵ const UINT16 wTrainId гID +* ֵ void +* by cgh 20240606 +*/ +static void ClearVobcHeadTrainData(const UINT16 wTrainId) +{ + HeadTrainLocStru strTempHeadTrainLocData = { 0U };/*ʱǰλ*/ + UINT16 wTrainIndex = 0U;/*гID*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wTrainIndex) + { + strTempHeadTrainLocData.wHeadVobcId = UINT32_MAX; + strTempHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_DEFAULT; + strTempHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = TRAIN_DIR_DEF; + strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = 0U; + strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = 0U; + strTempHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = 0U; + strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = 0U; + strTempHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = UINT32_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = TRAIN_DIR_DEF; + strTempHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = UINT16_MAX; + strTempHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = UINT16_MAX; + + SetTrainHeadTrainLocData(wTrainId, strTempHeadTrainLocData); + } + else + { + ; /**/ + } +} + +/* +* ITECI +* ˵void +* ֵ void +* Created By LQ 2024.06.06 +*/ +void ProcessIteToCiData(void) +{ + UINT8 ii = 0U; + UINT8 cIteNum = 0U; /*CIͨŵITE*/ + IteToCiDataStruct* pstrIteToCiData = NULL; /*CIͨŵITEṹָ*/ + UINT8 cFuncCheckFlag = CI_ERROR; + UINT16 wTrainId = 0U; /*ITEгID*/ + UINT8 cNeedKeepIteNum = 0U; /*ͨŵITE*/ + UINT32 dwCurCycNum = 0U; + + cIteNum = GetIteToCiSum(); + pstrIteToCiData = GetIteToCiDataStru(); + + if ((0U != cIteNum) && (NULL != pstrIteToCiData)) + { + for (ii = 0U; ii < cIteNum; ii++) + { + wTrainId = pstrIteToCiData[ii].wIteId & 0x00FFU; + cFuncCheckFlag = CheckIteHLHTHeadCtxValid((UINT8)pstrIteToCiData[ii].wIteId, pstrIteToCiData[ii].wIteLogId); /*ʹûͨͷжCIITEͨǷЧ*/ + + if (CI_SUCCESS == cFuncCheckFlag) + { + dwCurCycNum = Get2oo2CurCycleNum(); + if (dwCurCycNum == pstrIteToCiData[ii].dwComStartCycCount) + { + /*յITEݣITEݴгITEݽṹ*/ + SetIteTrainHeadLinkId(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].wTrainHeadLinkId); + SetIteTrainHeadLinkOffset(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].dwTrainHeadLinkOffset); + SetIteTrainTailLinkId(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].wTrainTailLinkId); + SetIteTrainTailLinkOffset(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].dwTrainTailLinkOffset); + SetIteTrainDir(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].cTrainDir); + SetIteTrainForWardOffset(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].wForWardOffset); + SetIteTrainBackOffset(wTrainId, pstrIteToCiData[ii].wIteLogId, pstrIteToCiData[ii].wBackOffset); + } + else + { + /*ǵڵITE*/ + } + + (void)CommonMemCpy(&(pstrIteToCiData[cNeedKeepIteNum]), (UINT32)sizeof(IteToCiDataStruct), &(pstrIteToCiData[ii]), (UINT32)sizeof(IteToCiDataStruct)); + cNeedKeepIteNum++; + } + else + { + /*ITEͨ쳣ӦгITEݽṹ壬ITEͨŽṹ*/ + ClearTrainIteInfo(wTrainId, pstrIteToCiData[ii].wIteLogId); + } + } + + if (cNeedKeepIteNum != cIteNum) + { + RemoveIteToCiMsgAt(cNeedKeepIteNum); /*ͨжϵITE*/ + } + else + { + /*ͨ쳣ITE*/ + } + } + else + { + /*ͨITE*/ + } +} + +/* +* ATS豸ͨ״̬ +* ˵ void +* ֵ +* by cgh 20240614 +*/ +void UpdataAtsDeviceCommState(void) +{ + /*ʼ*/ + UINT8 chLocalCiId = 0U; + UINT16 j = 0u; + UINT8 deviceSum = 0u; /*ͨ豸*/ + UINT8* pDeviceIdBuf = NULL; /*豸ID*/ + + chLocalCiId = GetSystemParaLocalCiId(); + /*ֵϵͳͨ״̬*/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_XIANDI); + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_XIANDI); + + if ((NULL != pDeviceIdBuf) && (0U != deviceSum)) + { + for (j = 0u; j < deviceSum; j++) + { + (void)UpdateCiTransmitState(chLocalCiId, CI_SYSTEM_TYPE_XIANDI, pDeviceIdBuf[j]); + } + } + else + { + ; + } + + /*ATSϵͳͨ״̬*/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_ATS); + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ATS); + + if ((NULL != pDeviceIdBuf) && (0u != deviceSum)) + { + for (j = 0u; j < deviceSum; j++) + { + (void)UpdateCiTransmitState(chLocalCiId, CI_SYSTEM_TYPE_ATS, pDeviceIdBuf[j]); + } + } + else + { + ; + } +} + +/* +* VobcгӿϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20240614 +*/ +static void VobcConnectDataProc(VobcToCiDataStruct* vobcToCiDataStru) +{ + if (NULL != vobcToCiDataStru) + { + SetAblTrainDir(vobcToCiDataStru->VobcId, vobcToCiDataStru->trainDirection); + SetAblTrainMaxHeadLink(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainMaxSafeHeadLink); + SetAblTrainMaxHeadOffset(vobcToCiDataStru->VobcId, vobcToCiDataStru->dwTrainMaxSafeHeadOffset); + SetAblTrainMinTailLink(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainMinSafeTailLink); + SetAblTrainMinTailOffset(vobcToCiDataStru->VobcId, vobcToCiDataStru->dwTrainMinSafeTailOffset); + + SetTrainHeadSigId(vobcToCiDataStru->VobcId, vobcToCiDataStru->wHeadSigId); + SetTrainHeadTrainId(vobcToCiDataStru->VobcId, vobcToCiDataStru->wHeadVobcId); + + SetTrainNvramPosFlag(vobcToCiDataStru->VobcId, vobcToCiDataStru->chNvramPosFlag); + + SetTrainLevel(vobcToCiDataStru->VobcId, vobcToCiDataStru->chTrainLevel); + } + else + { + ; /**/ + } +} + +/* +* VobcгϢ +* ˵ UINT16 wTrainIdVOBCid +* ֵ void +* by cgh 20240614 +*/ +static void VobcConnectDataClear(const UINT16 wTrainId) +{ + if ((TRAIN_SUM_MAX > wTrainId) && (0U < wTrainId)) + { + SetAblTrainMaxHeadLink(wTrainId, 0U); + SetAblTrainMaxHeadOffset(wTrainId, UINT32_MAX); + SetAblTrainMinTailLink(wTrainId, 0U); + SetAblTrainMinTailOffset(wTrainId, UINT32_MAX); + + SetTrainHeadSigId(wTrainId, 0U); + SetTrainHeadTrainId(wTrainId, TRAIN_ID_MAX); + /*ǰгλϢ*/ + ClearVobcHeadTrainData(wTrainId); + + /*FAOHLHTӿںϢ֡*/ + ClearBackUpTrainInfo(wTrainId); + } + else + { + ; /**/ + } +} + +/* +* Vobc󱸽ӿϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20240710 +*/ +static void VobcBackUpConnectDataProc(VobcBackUpToCiDataStruct* vobcToCiDataStru) +{ + if (NULL != vobcToCiDataStru) + { + SetAblTrainDir(vobcToCiDataStru->VobcId, vobcToCiDataStru->trainDirection); + SetAblTrainMaxHeadLink(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainMaxSafeHeadLink); + SetAblTrainMaxHeadOffset(vobcToCiDataStru->VobcId, vobcToCiDataStru->dwTrainMaxSafeHeadOffset); + SetAblTrainMinTailLink(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainMinSafeTailLink); + SetAblTrainMinTailOffset(vobcToCiDataStru->VobcId, vobcToCiDataStru->dwTrainMinSafeTailOffset); + + SetTrainHeadSigId(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainHeadCurSignalId); + SetTrainHeadTrainId(vobcToCiDataStru->VobcId, vobcToCiDataStru->wTrainHeadTrainId); + + SetTrainNvramPosFlag(vobcToCiDataStru->VobcId, vobcToCiDataStru->chNvramPosFlag); + SetTrainLevel(vobcToCiDataStru->VobcId, vobcToCiDataStru->chTrainLevel); + } + else + { + ; /**/ + } +} + +/* +* VOBCͣϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* fan 20240815 +*/ +static void BackupStopSteadyDataProc(VobcBackUpToCiDataStruct* vobcToCiDataStru) +{ + UINT16 psdRelatedPhySecId = 0u;/*VOBC͵ĹIDӦID*/ + UINT32 currCycleNum = 0u; + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + /*CTUTռ״̬Ϊ޳״̬*/ + UINT8 utOrCtOccFlag = SECTION_OCCUPY_YES; + UINT8 phyBelongCiId = 0u; + currCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + if (NULL != vobcToCiDataStru) + { + if (currCycleNum == vobcToCiDataStru->stopSteadyStartCycNum) + {/*յЧ*/ + + ClearVobcStopSteadyData(vobcToCiDataStru->VobcId);/*֮ǰͣϢ*/ + + /*ͣϢVOBC봦*/ + if (VOBC_CI_STOP_TW == vobcToCiDataStru->chStopSteadyState) + {/*ֻյVͣϢʱͣϢ*/ + + /*ѯŶձݹIDȡID*/ + psdRelatedPhySecId = GetTrackToPhySectionId(vobcToCiDataStru->trackSecID); + + phyBelongCiId = GetPhySecBelongCiId(psdRelatedPhySecId); + + if (localCiId == phyBelongCiId) + {/*ȡεǰռ״̬*/ + /*ÿڵijʼ׶ΣÿζᱻóδͣȡVOBCZCͣϢ㣬һCIͣȣΪͣȡ*/ + utOrCtOccFlag = GetPhySecPreOccState(psdRelatedPhySecId); + if (LOGICSECTION_OCCUPY_UT == utOrCtOccFlag) + { + SetPhySecStopSteadyFlag(psdRelatedPhySecId, PHYSICAL_SECTION_STOPSTEADY_YES);/*ͣ*/ + SetPhyStopSteadyTrainId(psdRelatedPhySecId, vobcToCiDataStru->VobcId); /*ͣιгID*/ + } + else if (LOGICSECTION_OCCUPY_CT == utOrCtOccFlag) + { + ;/*쳣ͬһCT ݺͨͣ*/ + } + else + { + /*г͹*/ + } + } + + } + } + } +} + +/* +* ˢʪ־ +* ˵ +* ֵ +* edit By cgh 2024.10.30 +*/ +void UpdateHumidRailFlag(void) +{ + UINT8 cFuncSwitch = FUNC_SWITCH_OFF; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 wCurPhySecNum = 0U; + UINT16 wPhySecId = 0U; + UINT8 cAllHumidRailState = CI_ALL_SNOW_UNVALID; /*ʪ״̬*/ + UINT8 cAreaHumidRailNum = 0U; /*ʪ*/ + UINT32* pAreaHumidRailId = NULL; + ToCiAreaSnowStruct* pRecvCiAreaHumidRail = NULL; /*͵ʪϢ*/ + UINT16 wCurSignalNum = 0U; + UINT16 wSignalId = 0U; + UINT16 wInFstPhySecId = 0U; /*źڷһID*/ + UINT8 cInFstPSInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO; + UINT16 wOutFstPhySecId = 0U; /*źⷽһID*/ + UINT8 cOutFstPSInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO; + UINT8 cLocalHumidRailState = CI_LOCAL_SNOW_UNVALID; /*ʪ״̬*/ + + cFuncSwitch = GetCiFunctionSwitchConfig(FUNC_ZQX_CHECK_HUMID_RAIL); + if (FUNC_SWITCH_ON == cFuncSwitch) + { + /****** εʪ־ ******/ + wCurPhySecNum = GetPhySecCurSum(); + for (ii = 0U; ii < wCurPhySecNum; ii++) + { + wPhySecId = GetPhySecId(ii); + SetPhySecInHumidRailFlag(wPhySecId, PHYSEC_IN_HUMID_RAIL_NO); /*־ٸʪ췶Χȷʪ־*/ + } + + cAllHumidRailState = GetAllSnowModel(); + cLocalHumidRailState = GetLocalSnowModel(); + + if ((CI_ALL_SNOW_VALID == cAllHumidRailState) || (CI_LOCAL_SNOW_VALID == cLocalHumidRailState)) + { + /*** ȫʪģʽ״̬Ч򱾵ʪ״̬Чεʪ־ΪЧ ***/ + for (ii = 0U; ii < wCurPhySecNum; ii++) + { + wPhySecId = GetPhySecId(ii); + SetPhySecInHumidRailFlag(wPhySecId, PHYSEC_IN_HUMID_RAIL_YES); + } + } + else + { + /*** ʪ ***/ + cAreaHumidRailNum = GetLocalAreaSnowNum(); + pAreaHumidRailId = GetLocalAreaSnowId(); + if ((0U != cAreaHumidRailNum) && (LOCAL_AREA_SNOW_SUM_MAX >= cAreaHumidRailNum) && (NULL != pAreaHumidRailId)) + { + /*ʪ죬ڱʪ־ΪЧ*/ + for (jj = 0U; jj < cAreaHumidRailNum; jj++) + { + SetPlatFormRelPSHumidRailFlag(pAreaHumidRailId[jj]); + } + } + else + { + /*ʪ죬*/ + } + + /*** ڼ͵ʪ ***/ + pRecvCiAreaHumidRail = GetCiRecvAreaSnowInfo(); + if (NULL != pRecvCiAreaHumidRail) + { + for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++) + { + /*ڿʪ츲бΣڱʪ־ΪЧ*/ + for (jj = 0U; jj < pRecvCiAreaHumidRail[ii].cPlatFormNum; jj++) + { + SetPlatFormRelPSHumidRailFlag(pRecvCiAreaHumidRail[ii].dwPlatFormId[jj]); + } + } + } + else + { + /**/ + } + } + + /****** źŻʪ־ ******/ + wCurSignalNum = GetSignalCurSum(); + for (ii = 0U; ii < wCurSignalNum; ii++) + { + wSignalId = GetSignalId(ii); + SetSignalInHumidRailFlag(wSignalId, SIGNAL_IN_HUMID_RAIL_NO); /*־ٸʪ췶ΧȷźŻʪ־*/ + + wInFstPhySecId = GetSignalInFirstPhySecId(wSignalId, 0U); /*ȡźŻⷽһʪ־*/ + cInFstPSInHumidRailFlag = GetPhySecInHumidRailFlag(wInFstPhySecId); + wOutFstPhySecId = GetSignalOutFirstPhySecId(wSignalId); + cOutFstPSInHumidRailFlag = GetPhySecInHumidRailFlag(wOutFstPhySecId); + + if ((PHYSEC_IN_HUMID_RAIL_YES == cInFstPSInHumidRailFlag) || (PHYSEC_IN_HUMID_RAIL_YES == cOutFstPSInHumidRailFlag)) + { + SetSignalInHumidRailFlag(wSignalId, SIGNAL_IN_HUMID_RAIL_YES); /*źŻڷһλⷽһʪ־ЧźŻʪ־Ч*/ + } + else + { + /**/ + } + } + } + else + { + /*عرգκźŻʪ״̬*/ + } +} + +/* +* · +* ˵ const UINT16 wCurRLockRouteId ǰ·ID + const UINT16 wPreRLockRouteId ֮ǰ·ID +* ֵ +* by cgh 20241204 +*/ +void RouteSecLockApplyCmdProc(const UINT16 wCurRLockRouteId, const UINT16 wPreRLockRouteId) +{ + UINT8 phySecSum = 0U; /**/ + UINT8 curLockState = 0U; /*εǰ״̬*/ + UINT16 validRouteId = 0U; /*ҪЧ·ID*/ + UINT8 ii = 0U; /**/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT8 chRouteDir = 0U;/*·*/ + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT8 chTrainSum = 0U; + LogicTrainResStruct* pstLgcResInfo = NULL; + LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + + if ((0U == wCurRLockRouteId) && (0U != wPreRLockRouteId)) + { + /*߼··*/ + LogRouteCleanOldLogSecLockProc(wPreRLockRouteId); + LogRouteCleanOldPhySecLockProc(wPreRLockRouteId); + } + else if ((0U == wPreRLockRouteId) && (0U != wCurRLockRouteId)) + { + /*·߼·*/ + OtherPartRouteCleanLogRouteProc(wCurRLockRouteId); + } + else + { + phySecSum = GetRoutePhysicalSectionSum(wCurRLockRouteId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(wCurRLockRouteId); /*ȡ·*/ + if ((0U != phySecSum) && (NULL != pPhySecDataStru)) + { + chRouteDir = GetRouteDirection(wCurRLockRouteId); + for (ii = 0U; ii < phySecSum; ii++) + { + curLockState = 0U; + curLockState = GetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId); /*ȡεǰ״̬*/ + + if ((PHYSICAL_SECTION_LOCK_NORMAL == curLockState) + || (PHYSICAL_SECTION_LOCK_DELAY == curLockState) + || (PHYSICAL_SECTION_LOCK_EXCEPT == curLockState)) + { /*||ʱ||*/ + + validRouteId = GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId); /*ȡ·ID*/ + + if (wPreRLockRouteId == validRouteId) + { + SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, validRouteId, 0U); /*δ*/ + SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NORMAL, wCurRLockRouteId, chRouteDir); /*״̬*/ + } + else + { + ; + } + } + else + { + ; + } + } + + if ((0U < validRouteId) && (validRouteId != wCurRLockRouteId)) + { + /*·ڱ*/ + /*ν·Ľ·13AB*/ + DealValidRouteState(validRouteId); + } + else if(validRouteId == wCurRLockRouteId) + { + DealValidRouteState(wPreRLockRouteId); /*ֽ··Ϊг*/ + } + else + { + /**/ + } + + /*ȡ·߼Ϣ*/ + logSectionSum = GetRouteLogSectionSum(wCurRLockRouteId); + pLogIdBuff = GetRouteLogSectionIdBuf(wCurRLockRouteId); + + /*ݺϷ*/ + if (NULL != pLogIdBuff) + { + for (ii = 0u; ii < logSectionSum; ii++) + { + + curLockState = 0U; + /*ȡǰ״̬*/ + curLockState = GetLogSecLockState(pLogIdBuff[ii]); + /*ջʱ*/ + if ((LOG_SECTION_LOCK_NORMAL == curLockState) + || (LOG_SECTION_LOCK_DELAY == curLockState) + || (LOG_SECTION_LOCK_EXCEPT == curLockState)) + { + validRouteId = GetLogSecLockBelongRoute(pLogIdBuff[ii]); + if (wPreRLockRouteId == validRouteId) + { + chTrainSum = GetLogSecTrainInfoSum(pLogIdBuff[ii]); + pstLgcResInfo = GetLogSecTrainInfo(pLogIdBuff[ii]); + if (NULL != pstLgcResInfo) + { + (void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct) * LOGIC_SECTION_RES_SUM_MAX)); + SetLogSecLockState(pLogIdBuff[ii], LOG_SECTION_LOCK_NO, validRouteId, 0U);/*֮ǰ·δ*/ + /*ڵǰ·*/ + SetLogSecLockState(pLogIdBuff[ii], LOG_SECTION_LOCK_NORMAL, wCurRLockRouteId, chRouteDir); + + CpyLgcSecResTrain(pLogIdBuff[ii], chTrainSum, stTmpResInfo);/*߼гԴϢ*/ + } + else + { + ; + } + } + else + { + ; /*ԼIJ*/ + } + } + else + { + ; + } + } + } + else + { + ; + } + } + else + { + /**/ + } + } +} + +/* +* ߼··߼մ +* ˵const UINT16 wPreRouteId ԭ·ID +* ֵ +* Created By LQ 2025.03.10 +*/ +void LogRouteCleanOldLogSecLockProc(const UINT16 wPreRouteId) +{ + UINT16 wRouteIndex = 0U; + UINT16 wLogSecSum = 0U; /*·߼*/ + UINT16* pLogSecIdBuff = NULL; /*·߼ID*/ + UINT8 ii = 0U; + UINT8 cCurRouteLockState = 0U; /*߼εǰ·״̬*/ + UINT8 cCurRouteLockDir = 0U; /*߼εǰ·շ*/ + UINT16 wValidRouteId = 0U; /*ҪĽ·ID*/ + UINT8 cCurLogLockState = 0U; /*߼εǰ߼·״̬*/ + UINT8 cCurLogLockDir = 0U; /*߼εǰ߼·շ*/ + UINT8 cResTrainSum = 0U; /*߼Դг*/ + LogicTrainResStruct* pstLgcResInfo = NULL; /*߼ԴϢ*/ + LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + + wRouteIndex = GetRouteConfigBufIndex(wPreRouteId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > wRouteIndex) + { + wLogSecSum = GetRouteLogSectionSum(wPreRouteId); /*ȡ·߼Ϣ*/ + pLogSecIdBuff = GetRouteLogSectionIdBuf(wPreRouteId); + if ((0U < wLogSecSum) && (NULL != pLogSecIdBuff)) + { + for (ii = 0U; ii < wLogSecSum; ii++) + { + cCurRouteLockState = GetLogSecLockState(pLogSecIdBuff[ii]); /*ȡǰ·״̬*/ + cCurRouteLockDir = GetLogSecLockDir(pLogSecIdBuff[ii]); + wValidRouteId = GetLogSecLockBelongRoute(pLogSecIdBuff[ii]); + cCurLogLockState = GetLogSecLogLockState(pLogSecIdBuff[ii]); + cCurLogLockDir = GetLogSecLogLockDir(pLogSecIdBuff[ii]); + + if (((LOG_SECTION_LOCK_NORMAL == cCurRouteLockState) || (LOG_SECTION_LOCK_DELAY == cCurRouteLockState) || (LOG_SECTION_LOCK_EXCEPT == cCurRouteLockState)) + && (wPreRouteId == wValidRouteId) && (LOG_SECTION_LOGLOCK_NORMAL == cCurLogLockState) && (cCurRouteLockDir != cCurLogLockDir)) + { + /*ǰ߼αԭ·ұ߼·շ෴Ϊ߼··ԭ·״̬*/ + cResTrainSum = GetLogSecTrainInfoSum(pLogSecIdBuff[ii]); + pstLgcResInfo = GetLogSecTrainInfo(pLogSecIdBuff[ii]); + if (NULL != pstLgcResInfo) + { + (void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct) * LOGIC_SECTION_RES_SUM_MAX)); + SetLogSecLockState(pLogSecIdBuff[ii], LOG_SECTION_LOCK_NO, wValidRouteId, 0U); /*֮ǰ·δ*/ + + CpyLgcSecResTrain(pLogSecIdBuff[ii], cResTrainSum, stTmpResInfo); /*߼гԴϢ*/ + } + else + { + /*ȡʧܣ*/ + } + } + else + { + /**/ + } + } + } + else + { + /*ȡ·߼Ϣʧܣ*/ + } + } + else + { + /*ηǷ*/ + } +} + +/* +* ߼··մ +* ˵const UINT16 wPreRouteId ԭ·ID +* ֵ +* Created By LQ 2025.03.10 +*/ +void LogRouteCleanOldPhySecLockProc(const UINT16 wPreRouteId) +{ + UINT16 wRouteIndex = 0U; + UINT8 cPhySecSum = 0U; /*·*/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*·νṹָ*/ + UINT8 ii = 0U; + UINT8 cCurPhySecRLockState = 0U; /*εǰ·״̬*/ + UINT16 wPhySecRLockRouteId = 0U; /*ν··ID*/ + UINT16 wValidRouteId = 0U; /*ҪЧ·ID*/ + UINT8 cPhyIncLgcSecSum = 0U; /*ΰ߼*/ + UINT16* pPhyIncLgcSecBuf = NULL; /*ΰ߼ID*/ + UINT8 jj = 0U; + UINT8 cCurLogSecRLockState = 0U; /*߼εǰ·״̬*/ + UINT16 wLgcRLockRouteId = 0U; /*߼ν··ID*/ + + wRouteIndex = GetRouteConfigBufIndex(wPreRouteId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > wRouteIndex) + { + cPhySecSum = GetRoutePhysicalSectionSum(wPreRouteId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(wPreRouteId); /*ȡ·*/ + + if ((0U < cPhySecSum) && (NULL != pPhySecDataStru)) + { + for (ii = 0U; ii < cPhySecSum; ii++) + { + cCurPhySecRLockState = GetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId); /*ȡεǰ״̬*/ + wPhySecRLockRouteId = GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId); /*ȡ·ID*/ + + if (((PHYSICAL_SECTION_LOCK_NORMAL == cCurPhySecRLockState) || (PHYSICAL_SECTION_LOCK_DELAY == cCurPhySecRLockState) || (PHYSICAL_SECTION_LOCK_EXCEPT == cCurPhySecRLockState)) + && (wPreRouteId == wPhySecRLockRouteId)) + { + /*αԭ·||ʱ||գΰ߼Ƿδ*/ + cPhyIncLgcSecSum = GetPhySecIncLogSecSum(pPhySecDataStru[ii].PhysicalSectionId); + pPhyIncLgcSecBuf = GetPhySecIncLogSecIdBuf(pPhySecDataStru[ii].PhysicalSectionId); + if ((0U < cPhyIncLgcSecSum) && (NULL != pPhyIncLgcSecBuf)) + { + for (jj = 0U; jj < cPhyIncLgcSecSum; jj++) + { + cCurLogSecRLockState = GetLogSecLockState(pPhyIncLgcSecBuf[jj]); + wLgcRLockRouteId = GetLogSecLockBelongRoute(pPhyIncLgcSecBuf[jj]); + if ((LOG_SECTION_LOCK_NO == cCurLogSecRLockState) && (0U == wLgcRLockRouteId)) + { + /*δգ*/ + } + else + { + break; + } + } + + if (jj == cPhyIncLgcSecSum) + { + SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, wPreRouteId, 0U); /*δ*/ + } + else + { + /**/ + } + + wValidRouteId = wPhySecRLockRouteId; + } + else + { + /**/ + } + } + else + { + ; + } + } + + if ((0U < wValidRouteId) && (wValidRouteId == wPreRouteId)) + { + /*ν·Ľ·*/ + for (ii = 0U; ii < cPhySecSum; ii++) + { + wPhySecRLockRouteId = GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId); + if (wPreRouteId == wPhySecRLockRouteId) + { + break; + } + else + { + ; + } + } + + if (ii == cPhySecSum) + { + (void)SetRouteState(wPreRouteId, ROUTE_STATE_IDLE); + /*ȡ·ķ*/ + SetRouteRelProSwitchLockSta(wPreRouteId, SWITCH_LOCK_PROTECT_CANCEL); + } + else + { + (void)SetRouteState(wPreRouteId, ROUTE_STATE_HALF_UNLOCK); /*ǰ·գý·״̬Ϊֽ·ȴ*/ + } + } + else + { + ; /**/ + } + } + else + { + /*ȡʧܣ*/ + } + } + else + { + /*ηǷ*/ + } +} + +/* +* ֽ·߼· +* ˵const UINT16 wCurRouteId ǰ·ID +* ֵ +* Created By LQ 2025.03.10 +*/ +void OtherPartRouteCleanLogRouteProc(const UINT16 wCurRouteId) +{ + UINT16 wRouteIndex = 0U; + UINT16 wLogSecSum = 0U; /*·߼*/ + UINT16* pLogSecIdBuff = NULL; /*·߼ID*/ + UINT8 ii = 0U; + UINT8 cCurRouteLockState = 0U; /*߼εǰ·״̬*/ + UINT8 cCurRouteLockDir = 0U; /*߼εǰ·շ*/ + UINT16 wCurRLockRouteId = 0U; /*ǰյĽ·ID*/ + UINT8 cCurLogLockState = 0U; /*߼εǰ߼·״̬*/ + UINT8 cCurLogLockDir = 0U; /*߼εǰ߼·շ*/ + UINT8 LogSecLockBelLogRouteSum = 0U; + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT16 wValidRouteId = 0U; /*ҪĽ·ID*/ + UINT8 cFuncRet = CI_ERROR; + UINT16 LogicalRouteInLogSecSum = 0U; + UINT16* wLogicalRouteInLogSecIdBuf = NULL; + UINT16 jj = 0U; + UINT8 LogLockBelLogRouteSum = 0U; + LogSecLockBelLogRouteStruct* pstLogLockBelLogRouteData = NULL; + UINT8 kk = 0U; + + wRouteIndex = GetRouteConfigBufIndex(wCurRouteId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > wRouteIndex) + { + wLogSecSum = GetRouteLogSectionSum(wCurRouteId); /*ȡ·߼Ϣ*/ + pLogSecIdBuff = GetRouteLogSectionIdBuf(wCurRouteId); + if ((0U < wLogSecSum) && (NULL != pLogSecIdBuff)) + { + for (ii = 0U; ii < wLogSecSum; ii++) + { + cCurRouteLockState = GetLogSecLockState(pLogSecIdBuff[ii]); /*ȡǰ·״̬*/ + cCurRouteLockDir = GetLogSecLockDir(pLogSecIdBuff[ii]); + wCurRLockRouteId = GetLogSecLockBelongRoute(pLogSecIdBuff[ii]); + cCurLogLockState = GetLogSecLogLockState(pLogSecIdBuff[ii]); + cCurLogLockDir = GetLogSecLogLockDir(pLogSecIdBuff[ii]); + LogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(pLogSecIdBuff[ii]); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(pLogSecIdBuff[ii]); + + if ((LOG_SECTION_LOCK_NORMAL == cCurRouteLockState) && (wCurRouteId == wCurRLockRouteId) && (LOG_SECTION_LOGLOCK_NORMAL == cCurLogLockState) + && (cCurRouteLockDir != cCurLogLockDir) && (1U == LogSecLockBelLogRouteSum) && (NULL != szLogSecLockBelLogRouteData)) + { + /*߼αǰ·ұ߼·յ߼·Ϊ1߼ε߼״̬*/ + wValidRouteId = szLogSecLockBelLogRouteData[0U].wLogSecLockBelLogRouteId; + SetLogSecLogLockState(pLogSecIdBuff[ii], LOG_SECTION_LOGLOCK_NO, szLogSecLockBelLogRouteData[0U].wLogSecLockBelLogRouteDir); /*߼ε߼״̬*/ + + cFuncRet = DelLogSecBelongLogRouteId(pLogSecIdBuff[ii], wValidRouteId); /*߼յ·*/ + + if (CI_SUCCESS == cFuncRet) + { + LogicalRouteInLogSecSum = GetLogicalRouteInLogSecSum(wValidRouteId); + wLogicalRouteInLogSecIdBuf = GetLogicalRouteInLogSecId(wValidRouteId); + if ((0U < LogicalRouteInLogSecSum) && (NULL != wLogicalRouteInLogSecIdBuf)) + { + for (jj = 0U; jj < LogicalRouteInLogSecSum; jj++) + { + LogLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogicalRouteInLogSecIdBuf[jj]); + pstLogLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogicalRouteInLogSecIdBuf[jj]); + + if (NULL != pstLogLockBelLogRouteData) + { + /*ȷǰ߼·Ƿ񻹴*/ + for (kk = 0U; kk < LogLockBelLogRouteSum; kk++) + { + if (wValidRouteId == pstLogLockBelLogRouteData[kk].wLogSecLockBelLogRouteId) + { + break; /*߼α߼·߼գֹͣ*/ + } + } + } + + if (kk != LogLockBelLogRouteSum) + { + break; /*·лڱ߼·߼գԽ˽·ΪУҪͷ*/ + } + else + { + /**/ + } + } + + if (jj == LogicalRouteInLogSecSum) + { + /*߼·߼ζδգѾ߼·һ߼Σø߼·Уĵȳͷ*/ + SetLogRouteStateManage(wValidRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + else + { + /*߼գ߼·*/ + } + } + else + { + /**/ + } + } + else + { + /**/ + } + } + else + { + /**/ + } + } + } + else + { + /*ȡ·߼Ϣʧܣ*/ + } + } + else + { + /*ηǷ*/ + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/IO/InputDataProcess.h b/TSCP/src/APP/ciapp/IO/InputDataProcess.h new file mode 100644 index 0000000..f8f28ad --- /dev/null +++ b/TSCP/src/APP/ciapp/IO/InputDataProcess.h @@ -0,0 +1,458 @@ +/******************************************************** +* +* InputDataProcess.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-07 +* ߣ +* ݴ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _INPUT_DATA_PROCESS_H_ +#define _INPUT_DATA_PROCESS_H_ + + + +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../ParsePack/ParsePackIoData.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../Transmit/TransmitDefine.h" +#if 0 +#include "../ParsePack/ParsePackZcData.h" +#endif +#include "../ParsePack/ParsePackCiData.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../ParsePack/ParsePackIoData.h" +#include "../ParsePack/ParsePackVobcData.h" +#include "../ParsePack/ParsePackPlatformData.h" +#include "../ParsePack/ParsePackLeuData.h" +#include "../ParsePack/CiInterfaceDefine.h" +#include "../LogicManage/InterlockLogicManage.h" +#include "../Signal/SignalDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "./DeviceRelayDataProcess.h" +#include "../LogicManage/TradInterlockLogicManage.h" +#include "../Initial/InitialProcess.h" +#include "../Route/RouteDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../WashMachine/WashMachineDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../ERROR/ErrorDefine.h" +#include "dquIdmapQuery.h" +#include "../VirtualDevice/VirtualDevDataManage.h" +#include "../ParsePack/ParsePackAxleData.h" +#include "../Train/TrainDataManage.h" +#include "../ParsePack/ParsePackZcData.h" +#include "../AxisSort/AxisSort_api.h" +#include "../SectionStateProcess/SectionStateProcess_api.h" +#include "../ParsePack/ParsePackITEData.h" +#include "../PSD/PSDDataManage.h" +#include "SectionDefine.h" + +#define USE_OC_GD_AS_PHY_COLL /*궨壺ʹOC״̬Ϊβɼ*/ +#undef USE_OC_GD_AS_PHY_COLL + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +* +* ˵ void +* ֵ void +*/ +void InputDataProcess(void); + +/* +* IOCI +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ProcessIoToCiData(void); +#if 1 +/* +* ZCCI +* ˵ void +* ֵ +* +*/ +void ProcessZcToCiData(void); +#endif +/* +* TMCTIOC +* ˵ void +* ֵ 0u:ʧ +* 1:ɹ +*/ +void ProcessTmcToTiocData(void); +/* +* VOBCCI +* ˵ void +* ֵ void +*/ +void ProcessVobcToCiData(void); + +/* +* ģʽVOBCCI +* ˵ void +* ֵ void +* ޸bug YF0083-100219 +*/ +void ProcessVobcBackupToCiData(void); + +/* +* PSDCI +* ˵ void +* ֵ void +*/ +void ProcessPlatformToCiData(void); + +/* +* PSCϵͳ +* ˵ void +* ֵ void +*/ +void ProcessPscToCiData(void); + +/* +* ATSֵصCI +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ProcessAtsOrXianDiToCiData(void); + +/* +* εATSֵصCI +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ProcessAtsOrXianDiToCiDataCld(void); + +/* +* 豸߼״̬ +* ˵ void +* ֵ void +*/ +void ProcessDeviceLogicState(void); + +/* +* λ߼ +* ˵ +* const UINT8 systemType, ϵͳ豸 +* const UINT8* maskBuf, λ +* const UINT16 maskSum, λ +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 MaskDataProcess(const UINT8 systemType, const UINT8* maskBuf, const UINT16 maskSum); + +/* +* CICI +* ˵ void +* ֵ +* +*/ +void ProcessCiToCiData(void); + +/* +* ں߼״̬ +* ˵ void +* ֵ void +*/ +void UpdatePhySectionMergeLogicState(void); + +/* +* ں߼CTռϢ +* ˵ void +* ֵ void +*/ +void UpdateLogSectionCTOccupyState(void); + +/* +* LEUCIݣȡLEUϱ־λ +* ˵ void +* ֵ void +*/ +void ProcessLeuToCiData(void); + + +/* +* ATSֵصCIźؿ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ProcessAtsOrXDToCiReturnToTRCmd(void); + +/* +* PSDɾijVOBC +* ˵ UINT16 vobcId VOBCṹVobcId +* ֵ +*/ +void ClearPsdVobcContext(const UINT16 vobcId); + + +/* +* ±̵ӿȷ״̬ +* ˵ void +* ֵ void +*/ +void UpdateRelayInterfaceConfirmFlag(void); + +/* +* ATSȷPSC·ϵͳ״̬ +* ˵ UINT8 pscId PSCϵͳID +* ֵ void +*/ + +void UpdateAtsPscPlFlagData(UINT8 pscId); + +/* +* OCCIļ̵ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ProcessOcToCiRelayData(void); + +/* +* OCCI֡ +* ˵ void +* ֵ void +*/ +void ProcessOcToCiData(void); + +/* +* ںABϵ״̬ +* ˵ void +* ֵ void +*/ +void OcProcessMergeABGdState(void); + +/* +* OCβɼ״̬ +* ˵ void +* ֵ void +*/ +void OcPhyStateToDeviceStatePro(void); +/* +* OCABϵɼ״̬ +* ˵ void +* ֵ void +*/ +void OcResetGdABCollState(void); + +/* +* ¾OCɼ״̬ +* ˵ void +* ֵ void +*/ +void OcUpdateSpecificGdCollState(void); + +/* +* AxleCI +* ˵ void +* ֵ void +*/ +void ProcessAxleToCiData(void); + +/* +* ںϼϵͳOCϵͳβɼ״̬ +* ˵ void +* ֵ void +*/ +void MergeAxleOcGdPhyState(void); +/* +* ǷΪͨ߱ +* ˵ void +* ֵ void +*/ +UINT8 CheckIsGeneralOrder(UINT8 OrderType); +/* +* ʱ +* ˵ void +* ֵ +*/ +void SetComBadLinShiXianSuState_Vir(void); +/* +* +* ˵ void +* ֵ +*/ +void DealallSwitchYLockOrder_Vir(void); +/* +* ID豸IDǷҪִ +* ˵ UINT8 virCIid ID +* UINT8 belongVirCIid 豸ID +* UINT8 orderType +* UINT16 deiceID ID +* ֵ CI_ERROR ִУCI_SUCCESS ִ +*/ +UINT8 CheckOrderWhetherDoing(UINT8 virCIid,UINT8 belongVirCIid,UINT8 orderType,UINT16 deiceID); +/* +* Զ۷ƣȵλ +* ˵ UINT16 DeviceId ָʾID +* UINT16*maskBuf λ +* UINT8 MaskType λ +* ֵ +*/ +void DealAutoReturnMask_UseVirCI(UINT16 DeviceId,UINT16*maskBuf,UINT8 MaskType,UINT16 index); +/* +* ȡȫվά޵״̬ +* ˵ UINT8 virCIid ID +* ֵ ά޵״̬ +*/ +UINT8 GetALLSignalMaintainState(UINT8 virCIid); + +/* +* IVOCδ +* ˵vobcToCiDataStruVOBCݽṹָ +* ֵ void +*/ +static void IvocUnLockOverlapProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* IVOCϴϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20231109 +*/ +static void IvocWashDataProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* IVOCϴ״̬ +* ˵ vobcToCiDataStruVOBCݽṹָ +* const UINT16 washMachineId ϴID +* ֵ void +* by cgh 20231110 +*/ +static void SetIvocWashDriveState(VobcToCiDataStruct* vobcToCiDataStru, const UINT16 washMachineId); + +/* +* ϴVOBC״̬ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20231110 +*/ +void ClearWashVobcDriveState(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* IVOCŹرȷϴ +* ˵vobcToCiDataStruVOBCݽṹָ +* ֵ void +* BY LC +*/ +static void IvocGarageDoorCloseProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* VobcƵϢ +* ˵ vobcToCiDataStruVOBCݽṹָ +* ֵ void +* by cgh 20231214 +*/ +static void VobcVideoQkDataProc(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* ùPSDƵ״̬ +* ˵ const UINT16 wPsdId1 ID1 +* const UINT16 wPsdId2 ID2 +* const UINT8 chSetState Ƶ״̬ +* const UINT16 wRelateVobcId Ƶ͹VOBC ID +* ֵ void +* by cgh 20231214 +*/ +void SetRelatePsdVideoQkDriveState(const UINT16 wPsdId1, const UINT16 wPsdId2, const UINT8 chSetState, const UINT16 wRelateVobcId); + +/* +* ӦгڶӦϵͣϢ +* ˵ UINT16 wTrainId гID +* ֵ void +*/ +void ClearVobcStopSteadyData(UINT16 wTrainId); + +/* +* VobcǰλϢ +* ˵ const UINT16 wTrainId гID +* ֵ void +* by cgh 20240606 +*/ +void VobcHeadTrainDataProc(const UINT16 wTrainId); + +/* +* VobcǰλϢ +* ˵ const UINT16 wTrainId гID +* ֵ void +* by cgh 20240606 +*/ +static void ClearVobcHeadTrainData(const UINT16 wTrainId); + +/* +* ITECI +* ˵void +* ֵ void +* Created By LQ 2024.06.06 +*/ +void ProcessIteToCiData(void); + +/* +* ATS豸ͨ״̬ +* ˵ void +* ֵ +* by cgh 20240614 +*/ +void UpdataAtsDeviceCommState(void); + +/* +* ˢʪ־ +* ˵ +* ֵ +* Created By LQ 2024.09.20 +*/ +void UpdateHumidRailFlag(void); + +/* +* · +* ˵ const UINT16 wCurRLockRouteId ǰ·ID + const UINT16 wPreRLockRouteId ֮ǰ·ID +* ֵ +* by cgh 20241204 +*/ +void RouteSecLockApplyCmdProc(const UINT16 wCurRLockRouteId, const UINT16 wPreRLockRouteId); + +/* +* ߼··߼մ +* ˵const UINT16 wPreRouteId ԭ·ID +* ֵ +* Created By LQ 2025.03.10 +*/ +void LogRouteCleanOldLogSecLockProc(const UINT16 wPreRouteId); + +/* +* ߼··մ +* ˵const UINT16 wPreRouteId ԭ·ID +* ֵ +* Created By LQ 2025.03.10 +*/ +void LogRouteCleanOldPhySecLockProc(const UINT16 wPreRouteId); + +/* +* ֽ·߼· +* ˵const UINT16 wCurRouteId ǰ·ID +* ֵ +* Created By LQ 2025.03.10 +*/ +void OtherPartRouteCleanLogRouteProc(const UINT16 wCurRouteId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/IO/OutputDataProcess.c b/TSCP/src/APP/ciapp/IO/OutputDataProcess.c new file mode 100644 index 0000000..4354cee --- /dev/null +++ b/TSCP/src/APP/ciapp/IO/OutputDataProcess.c @@ -0,0 +1,8540 @@ +/********************************************************* +* +* OutputDataProcess.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-07 +* ߣ +* ݴ +* ޸ļ¼ +* +********************************************************/ + + +#include "OutputDataProcess.h" +#include "../LogicProcess/InterlockLogicCheck.h" +#include "../ParsePack/ParsePackPSCData.h" +#include "InterlockLogicManage.h" +#include "../DataManage/PlatDataManage.h" +#include "../ParsePack/ParsePackVobcData.h" +#include "HLHTHeadContexManage.h" +#include "../EnvelopeManage/EnvelopeManageAPI.h" +#include "../RemoteRM/RRMDataPrepare.h" +#include "NonAutoReturnDataManage.h" +#include "InputDataProcess.h" + + + +/* +* ղ״ָ̬ʾƹμ +* ˵ UINT16 phySecId ID +* +* ֵ CI_SUCCESS ɹ +CI_ERROR ʧ +*/ +UINT8 ZhaoChaIndictorRelPhySecCheck(UINT16 phySecId); + +/* +* ղ״ָ̬ʾ״̬ +* ˵ UINT16 indicatorId ָʾID +* +* ֵ +*/ +void SetZhaoChaIndictorComSta_Vir(UINT8 virCIid,UINT8 indicatorId); + +/* +* վģʽָʾ +* ˵ void +* ֵ void +*/ +void SetCiModeIndicatorState_Vir(UINT8 virCIid,UINT8 indicatorId); + +/* +* ԳԳ״̵̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 TrainTestStatusToDevStateProc(void); + +/* +* ۷ָʾƵƺȵ״̵̬״̬ +* ˵ +* ֵ +*/ +static void AutoRtnIndictStaToDevStateProc(void); + +/* +* +* ˵ void +* ֵ void +*/ +void OutputDataProcess(void) +{ + UINT8 retVal = CI_ERROR; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 CiPattern = 0u; + UINT8 chDsnLinSwitch = 0U; + UINT8 chTiocSysMode = 0U; + + chTiocSysMode = GetTiocSystemMode(); + chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + CiPattern = GetLocalCiPattern(); + + if (REVERSE_MODE_MAIN != chTiocSysMode) + { + /*źŻգ豸˹᲻漰*/ + TiocSysShadowDeviceOutputProc(); + } + if (CI_PATTERN_TRADITIONAL == CiPattern) + {/*ͳ*/ + /*µ̵״̬*/ + SwitchDeviceToRelayStateProc(); + + /*źŻ̵״̬*/ + SignalDeviceToRelayStateProc(); + } + else if (CI_PATTERN_FULL_ELECTRONIC == CiPattern) + { + if (FUNC_SWITCH_ON == chDsnLinSwitch) + { + /*˹·ʹü̵źŻ*/ + /*µ̵״̬*/ + SwitchDeviceToRelayStateProc(); + + /*źŻ̵״̬*/ + SignalDeviceToRelayStateProc(); + } + else + { + /*ʾźŻʾ*/ + DriveFushiSignal(); + + /**/ + OcSwitchDeviceOutput(); + + /*źŻ*/ + OcSignalDeviceOutput(); + } + /*spksָʾ*/ + SpksDisplayDrivOutput(); + + /*esbָʾ*/ + EsbDisplayDrivOutput(); + + /*esbȵơƺͷ*/ + EsbRelateDelayDriveOutputProc(); + + /*Ž̵*/ + SpksMenjinJSDrivOutput(); + + /*۳ָʾ*/ + DetainDisplayDrivOutput(); + + /*ܸλʾ*/ + PhyZFWBsRelayDriveOutput(); + /*豸߼״̵̬״̬*/ + UpdateConnectDriveRelayOutput(); + + /*ⱨ*/ + SGBJDriveOutputProc(); + } + else + { + /*޲*/ + } + /*ż̵״̬*/ + (void)PsdDeviceToRelayStateProc(); + + /*ϴ̵״̬*/ + (void)WashMachineDevToRelayStaProc(); + + /*¼Ḵλ̵״̬*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { /**/ + UpDataAllPhySecResetRelay_VirCI(); + } + else + { + PhySecResetToRelayStateProc(); + } + + /*ǽ·̵״̬*/ + NonRouteRelayStateProc(); + + /* ż̵״̬ */ + GaragedoorDevToRelayStaProc(); + + /*ż̵״̬*/ + FloodGateDeviceToRelayStateProc(); + + /*·̵ͬ״̬*/ + RouteDCTYToRelayStateProc(); + + /* Գ Գ̵ */ + retVal = TrainTestStatusToDevStateProc(); + if (CI_ERROR == retVal) + { + /*ʱ*/ + } + else + { + ; + } + /*ָʾ״̬*/ + if(FUNC_SWITCH_ON == includeVirFlag) + {/*ʹñ*/ + AutoRtnIndictStatusProc_VirCI(); + } + else + { + /*۷Ƶȵ״̬*/ + AutoRtnIndictStaToDevStateProc(); + } + + /*۷̵ճ״̬*/ + RtnRealyAdhesionStatePro(); + + /*豸*/ + VirtualDeviceOutputProc(); + + + /*ָʾ״̬*/ + if(FUNC_SWITCH_ON == includeVirFlag) + {/**/ + OutPutIndicatorState_UseVirCI(); + } + else + { + IndicatorStateProc(); + OcStationIndicStateProc(); + } + + CiToCiOutputCmdProc(); + + CutoffPointOutput(); + + /*CIATSϢ*/ + CiToAtsBackInfoProcess(); + + /*¹ղ*/ + UpdateFaultLockZhaoChaDrive(); + /*ղղ*/ + UpdateZhaoChaCheckZhaoChaDrive(); + + /*̵״̬*/ + SetDriveRelayHunXianState(); + + /*гݴ*/ + UpdateTrainEnvelope(); + + /*гݴ*/ + VobcBackUpOutputProcess(); +} + +/* +* CIATSϢ +* ˵ void +* ֵ +*/ +void CiToAtsBackInfoProcess(void) +{ + /*ݴ*/ + ErrorCodeDataProcess(); + + /*ʱϢ*/ + TimeDataFeedBackProcess(); + + /*PSDʱ*/ + PsdDriveOutTimeToAts(); + + /*ϢͳһID߱ID*/ + AddCiSendBackDataCIid(); +} + + +/* +* ݴ +* ˵ void +* ֵ +*/ +void ErrorCodeDataProcess(void) +{ + UINT16 errorCodeCurSum = 0u; /*Ŀ*/ + UINT8 backInfoParam = 0u; /*Ϣ*/ + ErrorDataStruct* errorCodeStu = NULL; /**/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 errorCodeData[RECORD_BUF_MAX] = {0};/*ӡݻ7ΪṹС*/ + UINT16 errorCodeDataLen = 0u; + + errorCodeCurSum = GetErrorDataCurSum(); /*ȡ*/ + + /**/ + for (ii = 0u; ii < errorCodeCurSum; ii++) + { + + errorCodeStu = GetErrorData(ii); /*ȡ*/ + + if (errorCodeStu != NULL) + { + if (CI_SUCCESS == CiToAtsBackInfoFunctionJudge(errorCodeStu->FunctionId,errorCodeStu->DeviceType)) + { /*跴ATS*/ + + /*ȡATSϢ*/ + backInfoParam = GetAtsBackInfoParam(errorCodeStu->FunctionId,errorCodeStu->DeviceStateType, errorCodeStu->DeviceState); + + if ((backInfoParam > 0u) && (errorCodeStu->SendLevel == ESEND_LEVEL_ATS)) + { + errorCodeDataTransCmdBack(backInfoParam, errorCodeStu->DeviceType, errorCodeStu->DeviceId, errorCodeStu->VirCIid); + } +#ifdef LOGPRINT/*־ӡ*/ + + + if (RECORD_BUF_MAX > errorCodeDataLen + 8U) + { + errorCodeData[errorCodeDataLen++] = errorCodeStu->FunctionId; + errorCodeData[errorCodeDataLen++] = errorCodeStu->DeviceType; + ShortToChar(errorCodeStu->DeviceId, &errorCodeData[errorCodeDataLen]); + errorCodeDataLen += 2U; + errorCodeData[errorCodeDataLen++] = errorCodeStu->DeviceStateType; + errorCodeData[errorCodeDataLen++] = errorCodeStu->DeviceState; + errorCodeData[errorCodeDataLen++] = errorCodeStu->SendLevel; + errorCodeData[errorCodeDataLen++] = errorCodeStu->VirCIid; + } + +#endif + } + } + else + { + } + } +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + + if (errorCodeDataLen > 0U) + { + debug_infor_printf((const)"\nErrorCode:%d\nFunctionId-DeviceType-DeviceId(2)-DeviceStateType-DeviceState-SendLevel-virCIid\n",errorCodeDataLen); + debug_out_array(0xAA,errorCodeData,errorCodeDataLen); + } + +#endif/*ƽ̨ӡ*/ + +#endif +} + + + +/* +* ȡATSϢ +* ˵ +* const UINT8 functionId id +* const UINT8 deviceStateType, 豸״̬ +* const UINT8 deviceState, 豸״̬ +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetAtsBackInfoParam(const UINT8 functionId,const UINT8 deviceStateType, const UINT8 deviceState) +{ + UINT8 returnValue = 0u;/*ֵ*/ + switch (deviceStateType) + { + /*·Ϸ*/ + case ETYPE_ROUTE_LEVEL: + if (ROUTE_LEVEL_CBTC==deviceState ) + { + returnValue = CI_BACK_ROUTE_LEVEL_CBTC; /*·ලΪʽ*/ + } + else + { + returnValue = CI_BACK_ROUTE_LEVEL_BLOC; /*·ලΪCBTC*/ + } + break; + + case ETYPE_ROUTE_TYPE: + returnValue = CI_BACK_ROUTE_TYPE_ERROR; /*·쳣*/ + break; + + case ETYPE_ROUTE_STATE: + if (EFUNC_ROUTE_ZRJ_DEAL == functionId) + { + returnValue = CI_BACK_ROUTE_UNLOCK_FAIL;/*·*/ + } + else + { + returnValue = CI_BACK_ROUTE_STATE_ERROR; /*·*/ + } + break; + + case ETYPE_ROUTE_LEAD_PROPERTY: + returnValue = CI_BACK_ROUTE_LEAD_ERROR; /*·Ϊ*/ + break; + + case ETYPE_ROUTE_CANCEL: + returnValue = CI_BACK_ROUTE_CANCEL; /*·ȡ*/ + break; + + case ETYPE_ROUTE_OVERLAP_UNLOCK: + returnValue = CI_BACK_ROUTE_OVERLAP_LOCK_NO; /*·δ*/ + break; + + case ETYPE_ROUTE_OVERLAP_OCCUPY: + returnValue = CI_BACK_ROUTE_OVERLAP_OCCUPY; /*·ռ*/ + break; + case ETYPE_RETURN_ROUTE_STATE: + returnValue = CI_BACK_RETURN_ROUTE_STATE_ERROR;/*۷·׷ٰ*/ + break; + case ETYPE_ROUTE_XUANPAI_OVERTIME: + returnValue = CI_BACK_ROUTE_XUANPAI_OVERTIME;/*·ѡųʱ*/ + break; + + /*źŻϷ*/ + case ETYPE_SIG_START_OPEN_STATE: + if (SIGNAL_OPEN==deviceState ) + { + returnValue = CI_BACK_SIG_START_OPEN; /*·ʼźŻ*/ + } + else + { + returnValue = CI_BACK_SIG_START_CLOSE; /*·ʼźŻر*/ + } + break; + + case ETYPE_SIG_FLOCK_STATE: + if (SIGNAL_FENGSUO_YES==deviceState ) + { + returnValue = CI_BACK_SIG_FLOCK_YES; /*źŻ*/ + } + else if(SIGNAL_FENGSUO_NO == deviceState) + { + returnValue = CI_BACK_SIG_FLOCK_NO; /*źŻδ*/ + } + else + { + /*ѷ*/ + returnValue = CI_BACK_SIG_FLOCK_YES; /*źŻ*/ + } + break; + + case ETYPE_SIG_ENEMY_STATE: + returnValue = CI_BACK_SIG_ENEMY_OPEN; /*·жźŻ*/ + break; + + case ETYPE_SIG_NEED_CLOSE_STATE: + returnValue = CI_BACK_SIG_NEED_CLOSE; /*·رźδر*/ + break; + + case ETYPE_SIG_NEED_OPEN_STATE: + returnValue = CI_BACK_SIG_NEED_OPEN; /*·迪źδ*/ + break; + + case ETYPE_SIG_ONE_OPEN_STATE: + returnValue = CI_BACK_SIG_ONE_OPEN; /*·ͬʱźſ*/ + break; + + case ETYPE_SIG_OPEN_OVERTIME: + returnValue = CI_BACK_SIG_OPEN_OT; /*źŻųʱ*/ + break; + + case ETYPE_SIG_CLOSE_OVER_TIME: + returnValue = CI_BACK_SIG_CLOSE_OT; /*źŻرճʱ*/ + break; + + case ETYPE_SIG_RETURN_OPENED_STATE: + returnValue = CI_BACK_AS_RETR_ENDSIG_RT_SET;/*ԸźŻΪնźŻ۷·Ѿ*/ + break; + + case ETYPE_SIG_LEAD_ALL_LOCK: + returnValue = CI_BACK_SIG_LEAD_OPEN_FAIL; /*źſ㣬ȫվ·*/ + break; + + /*ιϷ*/ + case ETYPE_PS_MERGY_OCU_STATE: + if (SECTION_OCCUPY_YES==deviceState ) + { + returnValue = CI_BACK_PSEC_OCU_YES; /*ռ*/ + } + else + { + returnValue = CI_BACK_PSEC_OCU_NO; /*ο*/ + } + break; + + case ETYPE_PS_LOCK_STATE: + if (PHYSICAL_SECTION_LOCK_NO==deviceState ) + { + returnValue = CI_BACK_PSEC_LOCK_NO; /*δ*/ + } + else + { + returnValue = CI_BACK_PSEC_LOCK_YES; /**/ + } + break; + case ETYPE_PS_JUMP_LOCK: + if (PHYSICAL_SECTION_JUMP_LOCK_YES == deviceState) + { + returnValue = CI_BACK_PSEC_JUMP_LOCK_YES; /*Ծ*/ + } + break; + + case ETYPE_PS_INTRU_OCU_STATE: + returnValue = CI_BACK_PSEC_INTRU; /*ռ*/ + break; + + case ETYPE_PS_RUNLOCK_ERROR: + returnValue = CI_BACK_PSEC_RUNLOCK_ERROR; /*۷쳣*/ + break; + + case ETYPE_PS_AUNLOCK_ERROR: + returnValue = CI_BACK_PSEC_AUNLOCK_ERROR; /*Զ쳣*/ + break; + + case ETYPE_PS_USE_STATE: + returnValue = CI_BACK_PSEC_USE; /**/ + break; + + case ETYPE_PS_FLOCK_STATE: + if (OTHER_CI_PHYSICAL_FENGSUO_NO == deviceState) + { + returnValue = CI_BACK_PSEC_UNFLOCK; /*δ*/ + } + else + { + returnValue = CI_BACK_PSEC_FLOCK; /*ѷ*/ + } + break; + + case ETYPE_PS_UNFLOCK_STATE: + returnValue = CI_BACK_PSEC_UNFLOCK; /*δ*/ + break; + + /*Ϸ*/ + case ETYPE_SWT_YLOCK_STATE: + if (SWITCH_LOCK_YINZONG_YES==deviceState ) + { + returnValue = CI_BACK_SWT_YLOCK_YES; /**/ + } + else + { + returnValue = CI_BACK_SWT_YLOCK_NO; /*δ*/ + } + break; + + case ETYPE_SWT_FLOCK_STATE: + if (SWITCH_LOCK_FENGSUO_YES==deviceState ) + { + returnValue = CI_BACK_SWT_FLOCK_YES; /**/ + } + else + { + returnValue = CI_BACK_SWT_FLOCK_NO; /*δ*/ + } + break; + + case ETYPE_SWT_LOCK_STATUS: + if (SWITCH_LOCK_STATUS_DANSUO==deviceState ) + { + returnValue = CI_BACK_SWT_DLOCK_YES; /**/ + } + else if (SWITCH_LOCK_STATUS_PROTECT==deviceState ) + { + returnValue = CI_BACK_SWT_PLOCK_YES; /**/ + } + else if (SWITCH_LOCK_STATUS_DANSUO_NO==deviceState ) + { + returnValue = CI_BACK_SWT_DLOCK_NO; /*δ*/ + } + else if (SWITCH_LOCK_STATUS_PROTECT_NO==deviceState ) + { + returnValue = CI_BACK_SWT_PLOCK_NO; /*δ*/ + } + else + { + returnValue = CI_BACK_SWT_DLOCK_YES; /**/ + } + break; + + case ETYPE_SWT_POSTION_STATE: + returnValue = CI_BACK_SWT_POS_ERROR; /*λô*/ + break; + + case ETYPE_SWT_MOVE_INVALID: + returnValue = CI_BACK_SWT_MOVE_VALID; /*ɶ*/ + break; + + case ETYPE_SWT_MOVE_OVERTIME: + returnValue = CI_BACK_SWT_MOVE_OT; /*ʱ*/ + break; + + case ETYPE_SWT_USE_STATE: /**/ + { + if (SWITCH_USING_YES == deviceState) + { + returnValue = CI_BACK_SWT_USING; + } + + break; + } + case ETYPE_SWT_MOVE_STATE: /*ᶯ״̬*/ + { + if (SWITCH_MOVE_FAIL == deviceState) + { + returnValue = CI_BACK_SWT_MOVE_ERR; + } + + break; + } + /* zt ɾش 2022-02-15 */ + + /*̵Ϸ*/ + case ETYPE_THAT_ZHAOCHA: + returnValue = CI_BACK_REL_ZHAOCHA_UP; /*Զղ̵*/ + break; + case ETYPE_THIS_ZHAOCHA: + returnValue = CI_BACK_REL_ZHAOCHA_UP; /*ղ̵*/ + break; + case ETYPE_CANCLE_ZHAOCHA: + returnValue = CI_BACK_CANCEL_ZHAOCHA; /*ȡղ̵*/ + break; + case ETYPE_PS_ZHAOCHA_CHECK: + returnValue = CI_BACK_PHYSEC_ZHAOCHA; /*ղ鲻*/ + break; + case ETYPE_JKJ_WORK: + returnValue = CI_BACK_JKJ_VALID; + break; + /*վ̨Ϸ*/ + case ETYPE_ESB_VALID: + returnValue = CI_BACK_PLA_ESB_ESBVALID; /*ťЧ*/ + break; + + case ETYPE_PSD_CLOSE_NO: + returnValue = CI_BACK_PLA_PSD_OPEN; /*δر*/ + break; + + case ETYPE_PSD_MUTUALLOCK: + returnValue = CI_BACK_PLA_PSD_MUTULLOCK; /*Ż*/ + break; + + case ETYPE_PLAT_DETAIN: + returnValue = CI_BACK_PLA_DETAIN; /*վ̨۳*/ + break; + + case ETYPE_WASH_MACHINE_UNVALID: /* ϴδ */ + returnValue = CI_BACK_WASH_MACHINE_UNVALID; + break; + case ETYPE_OTHER_GARAGEDOOR_OPEN_NO: /* δ */ + returnValue = CI_BACK_OTHER_GARAGEDOOR_OPEN_NO; + break; + case ETYPE_OTHER_SIGNAL_OPEN_CHECK: /* źſʧ */ + returnValue = CI_BACK_OTHER_SIGNAL_OPEN_CHECK; + break; + case ETYPE_OTHER_SIGNAL_CHECK: /* źŻʧ */ + returnValue = CI_BACK_OTHER_SIGNAL_CHECK; + break; + case ETYPE_OTHER_SWITCH_POSITION_ERROR: /* ָλ */ + returnValue = CI_BACK_OTHER_SWITCH_POSITION_ERROR; + break; + case ETYPE_SPKS_STATE_UP: /* SPKSť */ + returnValue = CI_BACK_SPKS_STATE_UP; + break; + case ETYPE_GARAGEDOOR_STATE_MODE_LOCAL: /* ſģʽΪ */ + returnValue = CI_BACK_GARAGEDOOR_STATE_MODE_LOCAL; + break; + case ETYPE_GARAGEDOOR_FAULT: /* Ź״̬ */ + returnValue = CI_BACK_GARAGEDOOR_BAD; + break; + case ETYPE_GARDOOR_NOT_RECV_ZC_GMXK: /* ŹرδյZCظر */ + returnValue = CI_BACK_GARDOOR_NOT_RECV_ZC_GMXK; + break; + /*ϵͳ*/ + case ETYPE_SYSTEM_SIGNAL_OPEN: + returnValue = CI_BACK_SYSTEM_SIGNAL_OPEN; /*δźŻ*/ + break; + + case ETYPE_SYSTEM_EXCEPT: + returnValue = CI_BACK_SYSTEM_EXCEPT; /*ϵͳ״̬쳣*/ + break; + + case ETYPE_SYSTEM_STARTLOCKE_ERROR: + returnValue = CI_BACK_STARTLOCKE_ERROR; /*ϵʧ*/ + break; + + case ETYPE_SYSTEM_REL_UPDATA_ERROR: + returnValue = CI_BACK_REL_UPDATA_ERROR; /*̵ʧ*/ + break; + + case ETYPE_SYSTEM_SIG_UPDATA_ERROR: + returnValue = CI_BACK_SIG_UPDATA_ERROR; /*źŻʧ*/ + break; + + case ETYPE_SYSTEM_SEC_UPDATA_ERROR: + returnValue = CI_BACK_SEC_UPDATA_ERROR; /*θʧ*/ + break; + + case ETYPE_SYSTEM_SWT_UPDATA_ERROR: + returnValue = CI_BACK_SWT_UPDATA_ERROR; /*ʧ*/ + break; + + case ETYPE_LEU_CI_COMM_ALL_STATE_FAULT: + returnValue = CI_BACK_LEU_ALL_STATE__FAULT; /*LEUCIͨ״̬ϱ*/ + break; + + case ETYPE_LEU_CI_COMM_CHANNEL_SWITCH_FAULT: + returnValue = CI_BACK_LEU_CHANNEL_SWITCH_FAULT; /*LEUCIͨл*/ + break; + + case ETYPE_COMM_WITH_VOBC: + case ETYPE_COMM_WITH_ZC: + case ETYPE_COMM_WITH_CI: + case ETYPE_COMM_WITH_TMC: + returnValue = deviceState; /*VOBCZCCITMCCIͨʧܱ*/ + break; + case ETYPE_COMM_WITH_NEIGHBOUR_CI: + returnValue = CI_BACK_COMM_CI_GOOD;/*ͨŶ*/ + break; + + case ETYPE_OTHER_WASH_LINE_NOT_ALLOW: + returnValue = CI_BACK_WASH_LINE_ALLOW_NOT; /*㣺ϴδͬϴ*/ + break; + + case ETYPE_FLOODGATE_OPENLOCKSTATE:/*豸״̬ͣ*/ + returnValue = CI_BACK_FLOOD_GATE_CLOSE; + break; + case ETYPE_FLOODGATE_CLOSEREQSTATE:/*豸״̬ͣ*/ + returnValue = CI_BACK_FLOOD_GATE_REQ_CLOSE; + break; + case ETYPE_FLOODGATE_AGREECLOSESTATE:/*豸״̬ͣͬر*/ + returnValue = CI_BACK_FLOOD_ALLOW_CLOSE; + break; + case ETYPE_FLOODGATE_CLOSESTATE:/*Ź״̬-ʹ*/ + if (FLOOD_GATE_REQ_CLOSE == deviceState) + { + returnValue = CI_BACK_FLOOD_GATE_REQ_CLOSE; + } + else if (FLOOD_GATE_ALLOW_CLOSE == deviceState) + { + returnValue = CI_BACK_FLOOD_ALLOW_CLOSE; + } + else + { + returnValue = CI_BACK_FLOOD_GATE_CLOSE; + } + break; + + case ETYPE_SIG_ENDSIGNAL_DS:/*źŻ˿*/ + { + if (SIGNAL_SHOWCOLOUR_REDBREAK == deviceState) + { + returnValue = CI_BACK_ROUTE_END_SIGNAL_REDBREAK; + } + else + { + } + } + break; + + case ETYPE_DCTY_NOT_SATIFY:/*ͬⲻ*/ + { + returnValue = CI_BACK_DCTY_NOT_SATISFY; + } + break; + case ETYPE_DCTY_REOPEN_TIMING_BREAK:/*㣬ͬؿʱж*/ + { + returnValue = CI_BACK_DCTY_REOPEN_TIMING_BREAK; + } + break; + case ETYPE_TRAIN_TEST_OFF:/*δԳģʽЧ*/ + { + returnValue = CI_BACK_TRAIN_TEST_OFF; + } + break; + case ETYPE_DCTY_REOPEN_TIMEOUT:/*·XXȴͬⳬʱ*/ + { + returnValue = CI_BACK_DCTY_REOPEN_TIMEOUT; + } + break; + case ETYPE_FLOOD_GATE_YGJ_CROSS_LINE:/*YGJ߱*/ + { + returnValue = CI_BACK_FLOOD_GATE_YGJ_CROSS_LINE; + } + break; + case ETYPE_COMM_WITH_PSC: /*CIPSCͨ*/ + { + returnValue = CI_BACK_CIPSC_GOOD; + } + break; + case ETYPE_PSC_CONFIRM_PL_STATE: /*PSCӦվ̨û·־*/ + { + returnValue = CI_BACK_PSC_NO_CONFIRM; + } + break; + case ETYPE_PS_NO_UT_CT_OCU_STATE: /*γռ״̬(޳/UT/CT)*/ + switch (functionId) + { + case EFUNC_SET_SEC_RESET_LOGIC_MANAGE: /*Ḵλ߼*/ + returnValue = CI_BACK_PSEC_RESET_OP_INVALID_CT_ERROR; /*CTռüḴλЧ*/ + break; + case EFUNC_PHYSEC_RESET_TO_RELAY_STATE_PROC: /*μḴλ̵״̬*/ + returnValue = CI_BACK_PSEC_RESET_IN_CT; /*ḴλCTռ*/ + break; + default: + if ((LOGICSECTION_OCCUPY_UT == deviceState) || (LOGICSECTION_OCCUPY_CT == deviceState)) + { + returnValue = CI_BACK_PSEC_OCU_YES; /*ռ*/ + } + else + { + returnValue = 0u; + } + break; + } + break; + case ETYPE_GROUP_AUTO_ROUTE_STATE: /*Զ·ʧ*/ + returnValue = CI_BACK_GROUP_AUTO_ROUTE_SET_ERR; /*ʧ*/ + break; + case ETYPE_SIG_YDROUTE_SEARCH_ERR: /*·ʧ*/ + returnValue = CI_BACK_SIG_YDROUTE_SEARCH_ERR; /*ʧ*/ + break; + case ETYPE_OVERLAP_LABORUNLOCK_FAIL: /*˹ʧ*/ + returnValue = LOCK_OVELAP_OUT_CANNOT; /*˹ʧ*/ + break; + case ETYPE_LOGSEC_LOCK_STATE: /*߼״̬ᶯʹã*/ + returnValue = CI_BACK_PSEC_LOCK_YES; + break; + case ETYPE_LOGSEC_OCC_STATE: /*߼ռ״̬ᶯʹã*/ + if (SECTION_OCCUPY_NO == deviceState) + { + returnValue = CI_BACK_PSEC_OCU_NO; + } + else + { + returnValue = CI_BACK_PSEC_OCU_YES; + } + break; + case ETYPE_LOGSEC_XIANSU_STATE: + returnValue = CI_BACK_LGC_SEC_XIANSU_SET; + break; + case ETYPE_AUTO_ROUTE_FLAG: /* Զͨ· */ + if (AUTO_ROUTE_DICHU_AUTOROUTE == deviceState) + { + returnValue = CI_BACK_AUTO_ROUTE_DICHU_ROUTE_SET; + } + else if (AUTO_ROUTE_DICHU_AUTOREROUTE == deviceState) + { + returnValue = CI_BACK_AUTO_RETURN_DICHU_ROUTE_SET; + } + else if (AUTO_ROUTE_DICHU_ALLAUTOREROUTE == deviceState) + { + returnValue = CI_BACK_ALLAUTO_RETURN_DICHU_ROUTE_SET; + } + else if (AUTO_ROUTE_DICHU_COMMROUTE == deviceState) + { + returnValue = CI_BACK_COMMON_ROUTE_SET; + } + else if (AUTO_ROUTE_HAVE_BLOCK == deviceState) + { + returnValue = CI_BACK_AUTO_ROUTE_HAVE_BLOCK; + } + else + { + returnValue = CI_BACK_AUTO_ROUTE_FLOOD_STATE_ERR; + } + break; + case ETYPE_AUTO_RETURN_FLAG: /* Զ۷ */ + if (AUTO_RETURN_DICHU_AUTOROUTE == deviceState) + { + returnValue = CI_BACK_AUTO_ROUTE_DICHU_ROUTE_SET; + } + else if (AUTO_RETURN_DICHU_AUTOREROUTE == deviceState) + { + returnValue = CI_BACK_AUTO_RETURN_DICHU_ROUTE_SET; + } + else if (AUTO_RETURN_DICHU_ALLAUTOROUTE == deviceState) + { + returnValue = CI_BACK_ALLAUTO_RETURN_DICHU_ROUTE_SET; + } + else if (AUTO_RETURN_DICHU_COMMROUTE == deviceState) + { + returnValue = CI_BACK_COMMON_ROUTE_SET; + } + else if (AUTO_RETURN_HAVE_BLOCK == deviceState) + { + returnValue = CI_BACK_AUTO_RETURN_HAVE_BLOCK; + } + else + { + returnValue = CI_BACK_AUTO_RETURN_FLOOD_STATE_ERR; + } + break; + case ETYPE_ALL_AUTO_RETURN_FLAG: /* ȫԶ۷ */ + if (ALL_AUTO_RETURN_DICHU_AUTOR == deviceState) + { + returnValue = CI_BACK_AUTO_ROUTE_DICHU_ROUTE_SET; + } + else if (ALL_AUTO_RETURN_DICHU_AUTORETR == deviceState) + { + returnValue = CI_BACK_AUTO_RETURN_DICHU_ROUTE_SET; + } + else if (ALL_AUTO_RETURN_DICHU_ALLAUTOR == deviceState) + { + returnValue = CI_BACK_ALLAUTO_RETURN_DICHU_ROUTE_SET; + } + else if (ALL_AUTO_RETURN_DICHU_COMMR == deviceState) + { + returnValue = CI_BACK_COMMON_ROUTE_SET; + } + else if (ALL_AUTO_RETURN_HAVE_BLOCK == deviceState) + { + returnValue = CI_BACK_ALLAUTO_RETURN_HAVE_BLOCK; + } + else + { + returnValue = CI_BACK_ALLAUTO_RETURN_FLOOD_STATE_ERR; + } + break; + + case ETYPE_OTHER_ROUTE_CHECK: + returnValue = CI_BACK_OTHER_ROUTE_NOT_OPEN; /*·迪Ž·δ*/ + break; + case ETYPE_OTHER_DOWNWASH_NOT_ALLOW_PASS: + returnValue = CI_BACK_WASH_PASS_ALLOW_NOT; /*ϴ/δͬͨ*/ + break; + default:/*ݴ*/ + returnValue = 0U; + break; + } + + return returnValue; +} + + +/* +* ȡATSϢж +* ˵ const UINT8 functionId, ID +* ֵ +CI_ERROR ȡʧ +CI_SUCCESS ȡɹ +*/ +UINT8 CiToAtsBackInfoFunctionJudge(const UINT8 functionId,const UINT8 deviceType) +{ + if ((functionId > 0u) && (deviceType>0u) ) + { + return CI_SUCCESS; + } + else + { + return CI_ERROR; + } +} + + +/* +* ָʾ״̬ +* ˵ void +* ֵ void +*/ +void IndicatorStateProc(void) +{ + UINT16 devCurSum = 0u; /*豸*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devType = 0u; /*豸*/ + UINT8 devRelaySum = 0u; /*豸̵*/ + UINT16* devRelayIdBuf = NULL; /*̵IDbuf*/ + UINT16 apply_1_Id = 0u; /*ԳID*/ + UINT16 allow_1_Id = 0u; /*ԳID*/ + UINT16 over_1_Id = 0u; /*ԳID*/ + + UINT16 apply_2_Id = 0u; /*ԳID*/ + UINT16 allow_2_Id = 0u; /*ԳID*/ + UINT16 over_2_Id = 0u; /*ԳID*/ + UINT16 jkj_valid_Id = 0u; /*Ӧ̵̼ЧID*/ + + UINT16 sysFirstId = 0u; /*ƽ̨һϵID*/ + UINT16 sysSecondId = 0u; /*ƽ̨ϵID*/ + UINT8 computerId = 0u; /*ƽ̨ID*/ + UINT8 runMode = 0u; /*ģʽ*/ + UINT8 selfState = 0u; /*״̬*/ + UINT8 otherState = 0u; /*״̬*/ + UINT16 applyRelay_1_Id = 0u; /*Գ̵1 ID*/ + UINT16 allowRelay_1_Id = 0u; /*Գ̵1 ID*/ + + UINT16 applyRelay_2_Id = 0u; /*Գ̵2 ID*/ + UINT16 allowRelay_2_Id = 0u; /*Գ̵2 ID*/ + + UINT8 faultFlag = 0u;/*ϱ־ 0Ϊδ*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT16 kk = 0u;/**/ + UINT16 deviceCurSum = 0u; /*Ŀ*/ + UINT16 deviceId = 0u; /*ID*/ + UINT8 interfaceType = 0u; /*Գ복νӿڷʽ*/ + + UINT8 leuNum = 0u;/*뱾CIͨŵLEU*/ + UINT8 leuState = 0u;/*LEU״̬*/ + + UINT8 nonRouteId = 0u;/*ǽ·id*/ + UINT8 jkjRelayValidFlag = 0u; + + UINT8 relayConfirmFlag = 0u;/*̵ӿȷϱ־*/ + + UINT8 dianshiLinshixiansuFlag = 0u;/*ʽʱ*/ + UINT8 redDsFlag = 0u; /*ƶ˿*/ + UINT8 greenDsFlag = 0u; /*̵ƶ˿*/ + UINT8 yellowDsFlag = 0u; /*Ƶƶ˿*/ + UINT8 whiteDsFlag = 0u; /*׵ƶ˿*/ + UINT8 redYellowDsFlag= 0u; /*Ƶƶ˿*/ + UINT8 redWhiteDsFlag= 0u; /*׵ƶ˿*/ + UINT8 greenYellowDsFlag= 0u; /*̻Ƶƶ˿*/ + UINT8 doubleGreenDsFlag= 0u; /*˫̵ƶ˿*/ + UINT8 doubleYellowDsFlag = 0u; /*˫Ƶƶ˿*/ + UINT8 switchBlockLinkState = 0u; /*״̬*/ + UINT8 nonRouteRunModeById = 0u; + UINT8 relayHunXianState = 0u; + UINT16 RelayId = 0u; + UINT8 relayBelongCi = 0u; + UINT16 relaySum = 0u; + UINT8 localCiId = 0u; + UINT8 relayCollState = 0U; /*̵ɼ״̬*/ + UINT8 commStatus = 0U; /*ͨͨ״̬*/ + UINT8 chVirtualZDZFButtonState = 0U;/*۷ť״̬*/ + UINT8 chStartFlockFlag = 0U; + UINT8 chAllSwitchYlockFlag = 0U; + UINT8 chStartLockFlag = 0U; + UINT8 chStopCheckFlag = 0U; + UINT8 chLocalCiType = 0U; + UINT8 chCommuState = 0U; + UINT8 chDevStateRtn = 0U; + UINT8 chDevStateRtn2 = 0U; + UINT8 chNonRouteState = 0U; + UINT8 chNonRouteMode = 0U; + UINT8 chBjdDeviceId = 0U;/*豸ID*/ + UINT8 chNonReturnAdhesionState = 0U;/*۷ճ״̬*/ + UINT8 cCommAxisNum = 0U; /*뱾ͨŹϵļϵͳ*/ + UINT8* pAxisSysIdBuf = NULL; + UINT8 mm = 0U; + + dianshiLinshixiansuFlag = GetCiFunctionSwitchConfig(FUNC_DIANSHI_LINSHIXIANSU_FLAG); + devCurSum = GetIndicatorCurSum(); /*ȡָʾǰ*/ + interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*ȡԳ복νӿڷʽ*/ + localCiId = GetSystemParaLocalCiId(); + chLocalCiType = GetLocalCiType(); + for (ii = 0u; ii < devCurSum; ii++) + { + devRelaySum = 0u; + devRelayIdBuf = NULL; + + devId = GetIndicatorId(ii); /*ȡָʾID*/ + devType = GetIndicatorType(devId); /*ȡ豸*/ + chBjdDeviceId = GetIndicatorDevId(devId); + + /*###ơ###*/ + if ((INDICATOR_TYPE_ALARM_RONGSI == devType) || + (INDICATOR_TYPE_ALARM_GDGZ == devType) || + (INDICATOR_TYPE_ALARM_RONGSI_qujian2 == devType) + ) + { /*˿ || ϱ*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + continue; + } + else + { + ; + } + + if (RELAY_STATE_UP == GetRelayCollState(devRelayIdBuf[0])) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ޱ*/ + } + } + else if ((INDICATOR_TYPE_POWER_SCREEN == devType)|| + (INDICATOR_TYPE_ALARM_XICHEJI == devType)|| + (INDICATOR_TYPE_READY_XICHEJI == devType) || + (INDICATOR_TYPE_ALARM_DUANSI_qujian2 == devType) || + (INDICATOR_TYPE_POWER_SCREEN_qujian2 == devType) + ) + {/* Դ || ϴ ̵ || ϴ״̬*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + continue; + } + else + { + ; + } + + if (RELAY_STATE_UP == GetRelayCollState(devRelayIdBuf[0])) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ޱ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + } + } + else if (INDICATOR_TYPE_ALARM_DUANSI == devType) + {/*˿ */ + + SignaDsBreakAlarmIndicator(devId); + } + else if (INDICATOR_TYPE_ALARM_GDTD == devType) + { /*ͣ籨*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ʼޱ*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + continue; + } + else + { + ; + } + + + for (jj = 0u; jj < devRelaySum; jj++) + { + if (RELAY_STATE_DOWN == GetRelayCollState(devRelayIdBuf[jj])) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + break; + } + else + { + ; + } + + } + + if (INDICATOR_SHOW_YES == GetIndicatorState(devId)) + { /*б*/ + } + else + { /*ޱ*/ + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ޱ*/ + } + } + else if ((INDICATOR_TYPE_UPS_FAULT == devType) || + (INDICATOR_TYPE_UPS2_FAULT == devType) + ) + { /*UPSָʾ UPS2ָʾ*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*UPSָʾЧݴ*/ + continue; + } + else + { + ; + } + + + if (RELAY_STATE_UP == GetRelayCollState(devRelayIdBuf[0])) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*UPSָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*UPSָʾЧ*/ + } + } + + /*###ָʾơ###*/ + else if ((INDICATOR_TYPE_EXPRESS_MAINP == devType) ||(INDICATOR_TYPE_EXPRESS_BACKP == devType) + || (INDICATOR_TYPE_EXPRESS_MAINP_2 == devType) || (INDICATOR_TYPE_EXPRESS_BACKP_2 == devType)) + { /*Դָʾ || Դָʾ*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*õԴ*/ + continue; + } + else + { + ; + } + + + if (RELAY_STATE_UP == GetRelayCollState(devRelayIdBuf[0])) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*õԴЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*õԴ*/ + } + } + else if ((INDICATOR_TYPE_EXPRESS_ZHAOCHA1 == devType) || + (INDICATOR_TYPE_EXPRESS_ZHAOCHA2 == devType) || + (INDICATOR_TYPE_EXPRESS_ZHAOCHA3 == devType) || + (INDICATOR_TYPE_EXPRESS_ZHAOCHA4 == devType) || + (INDICATOR_TYPE_EXPRESS_ZHAOCHA5 == devType)) + { /*ղָʾ*/ + + SetZhaoChaIndictorCommonState(devId); +#if 0 + if (GetIndicatorAvalibleFlag(devId) == INDICATOR_DATA_VALID) + {/*ղЧ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else if (GetIndicatorAvalibleFlag(devId) == INDICATOR_DATA_PHYSEC) + {/*ղָʾЧ*/ + + /*ʼ*/ + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡղ*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡղID*/ + + if ((0 == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + continue; + } + else + { + ; + } + + + for (jj = 0; jj < devRelaySum; jj++) + { + /*̵ղ*/ + if (GetRouteThatZhaoChaRelayId(devRelayIdBuf[jj]) == 0) + { + } + else + { + if (GetRelayCollState(GetRouteThatZhaoChaRelayId(devRelayIdBuf[jj])) == RELAY_STATE_DOWN) + {/*Զղ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + break; + } + else + { + ; + } + } + + /*·ղ*/ + relativeDeviceIdSum = GetRouteThatZhaoChaPhySecSum(devRelayIdBuf[jj]); + if (relativeDeviceIdSum > 0) + {/*·ղ*/ + + relativeDeviceIdBuf = GetRouteThatZhaoChaPhySecIdBuf(devRelayIdBuf[jj]); + for (kk = 0; kk < relativeDeviceIdSum; kk++) + { + if (GetRouteState(relativeDeviceIdBuf[kk]) == ROUTE_STATE_IDLE) + { + } + else + { + /*·ղ鲻*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + break; + } + } + } + else + { + } + } + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } +#endif + } + else if (INDICATOR_TYPE_EXPRESS_2OO2_I == devType) + { /*һϵ״ָ̬ʾ*/ + + sysFirstId = devId; + } + else if (INDICATOR_TYPE_EXPRESS_2OO2_II == devType) + { /*ϵ״ָ̬ʾ*/ + + sysSecondId = devId; + } +#if 0 + else if (INDICATOR_TYPE_EXPRESS_START_UNLOCK == devType) + { /*ϵ״ָ̬ʾ*/ + if (CI_START_LOCK_YES == GetStartLockFlag()) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } +#endif + else if ((INDICATOR_TYPE_EXPRESS_NONROUTE == devType) || (INDICATOR_TYPE_EXPRESS_NONROUTE_2 == devType)) + { /*ǽ·1 ǽ·2*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*÷ǽ·ָʾЧݴ*/ + continue; + } + else + { + ; + } + + + if (NONROUTE_STATE_IDLE == GetNonRouteStateById((UINT8)(devRelayIdBuf[0]))) + { + /*δǽ·*/ + SetIndicatorState(devId, INDICATOR_SHOW_NONROUTE_NOSET); /*ָʾЧ*/ + } + else if ((NONROUTE_STATE_LOCK == GetNonRouteStateById((UINT8)(devRelayIdBuf[0]))) || + (NONROUTE_STATE_LOCKERR == GetNonRouteStateById((UINT8)(devRelayIdBuf[0]))) || + (NONROUTE_STATE_OPEN == GetNonRouteStateById((UINT8)(devRelayIdBuf[0]))))/*ǽ·//ǽ·*/ + { + /*ǽ·*/ + SetIndicatorState(devId, INDICATOR_SHOW_NONROUTE_LOCK); /*ָʾЧ*/ + } + else + { + /* ǽ·ջʱڼ*/ + SetIndicatorState(devId, INDICATOR_SHOW_NONROUTE_SETING); /*ָʾЧ*/ + } + } + else if (INDICATOR_TYPE_EXPRESS_STOP_CHECK == devType) + { /*ֹͣ״ָ̬ʾ*/ + chStopCheckFlag = GetStopCheckFlag(); + if (ROUTE_STOPCHECK_SET_YES == chStopCheckFlag) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + else if (INDICATOR_TYPE_SWITCH_JICHA == devType) + { /*״ָ̬ʾ*/ + deviceCurSum = GetSwitchCurSum(); + for (jj = 0u; jj < deviceCurSum; jj++) + { + deviceId = GetSwitchId(jj); + if ((SWITCH_POSITION_JICHA == GetSingleSwitchCurPosition(deviceId)) && + (CI_TRUE == CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, deviceId))) + { /*Էɽߵĵ*/ + break; + } + else + { + ; + } + } + + if (deviceCurSum == jj) + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + } + else if (INDICATOR_TYPE_GD_DAD == devType) + { /*Źָʾ*/ + deviceCurSum = GetGaragedoorSum(); + for (jj = 0u; jj < deviceCurSum; jj++) + { + deviceId = GetGaragedoorId(jj); + if (GARAGE_DOOR_FAULT_TRUE == GetGaragedoorFaultState(deviceId)) + { + break; + } + else + { + ; + } + } + + if (deviceCurSum == jj) + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + } + else if (INDICATOR_TYPE_EXPRESS_SC_APP == devType) + { /*Գָʾ1*/ + nonRouteId = GetNonRouteIdByIndicatorId(devId); + if (nonRouteId >0u) + { + if(CI_TYPE_SCX == chLocalCiType) + { + /* Գ */ + apply_1_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelay_1_Id = GetSCXDrvApplyTryRelayIdById(nonRouteId); /*Գ̵ID*/ + } + else + { + ; + } + } + else + { + /* */ + apply_1_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelay_1_Id = GetNonRouteAppTryRelayIdById(nonRouteId); /*Գ̵ID*/ + } + else + { + ; + } + } + } + else + { + ; + } + + } + else if (INDICATOR_TYPE_EXPRESS_SC_APP_2 == devType) + { /*Գָʾ2*/ + nonRouteId = GetNonRouteIdByIndicatorId(devId); + if (nonRouteId >0u) + { + if(CI_TYPE_SCX == chLocalCiType) + { + /* Գ */ + apply_2_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelay_2_Id = GetSCXDrvApplyTryRelayIdById(nonRouteId); /*Գ̵ID*/ + } + else + { + ; + } + } + else + { + /* */ + apply_2_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelay_2_Id = GetNonRouteAppTryRelayIdById(nonRouteId); /*Գ̵ID*/ + } + else + { + ; + } + } + } + + } + else if (INDICATOR_TYPE_EXPRESS_SC_ALW == devType) + { /*Գָʾ1*/ + + nonRouteId = GetNonRouteIdByIndicatorId(devId); + if (nonRouteId>0u) + { + + if(CI_TYPE_SCX == chLocalCiType) + { + allow_1_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + allowRelay_1_Id = GetSCXColAgreeTryRelayIdById(nonRouteId); /*Գ̵1ID*/ + } + else + { + ; + } + } + else + { /* */ + allow_1_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + allowRelay_1_Id = GetNonRouteAgreeTryRelayIdById(nonRouteId); /*Գ̵1ID*/ + } + else + { + ; + } + } + } + } + else if (INDICATOR_TYPE_EXPRESS_SC_ALW_2 == devType) + { /*Գָʾ2*/ + + nonRouteId = GetNonRouteIdByIndicatorId(devId); + if (nonRouteId>0u) + { + + if(CI_TYPE_SCX == chLocalCiType) + { + allow_2_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + allowRelay_2_Id = GetSCXColAgreeTryRelayIdById(nonRouteId); /*Գ̵2ID*/ + } + else + { + ; + } + } + else + { /* */ + allow_2_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + allowRelay_2_Id = GetNonRouteAgreeTryRelayIdById(nonRouteId); /*Գ̵2ID*/ + } + else + { + ; + } + } + } + } + else if (INDICATOR_TYPE_EXPRESS_SC_END == devType) + { /*Գָʾ1*/ + + over_1_Id = devId; + } + else if (INDICATOR_TYPE_EXPRESS_SC_END_2 == devType)/*Գָʾ2*/ + { + over_2_Id = devId; + } + else if (INDICATOR_TYPE_JKJ_VALID == devType)/*Ӧ̵̼Чָʾ*/ + { + jkj_valid_Id = devId; + } + else if (INDICATOR_TYPE_SIGNAL_FAULT_CLOSE == devType) + {/*źŻϹرձ*/ + + for (jj = 0u; jj < GetSignalCurSum(); jj++) + { + deviceId = GetSignalId(jj); + /*ȡ˿˿״̬*/ + redDsFlag = GetSignalDsBreakFlag(deviceId); + greenDsFlag = GetSignalGreenDsBreakFlag(deviceId); + yellowDsFlag = GetSignalYellowDsBreakFlag(deviceId); + whiteDsFlag = GetSignalWhiteDsBreakFlag(deviceId); + redYellowDsFlag = GetSignalRedYellowDsBreakFlag(deviceId); + redWhiteDsFlag = GetSignalRedWhiteDsBreakFlag(deviceId); + greenYellowDsFlag = GetSignalGreenYellowDsBreakFlag(deviceId); + doubleGreenDsFlag = GetSignalDoubleGreenDsBreakFlag(deviceId); + doubleYellowDsFlag = GetSigDoubleYellowDsBreakFlag(deviceId); + + if (((SIGNAL_DS_BREAK_YES == redDsFlag) || (SIGNAL_DS_BREAK_YES == greenDsFlag) + || (SIGNAL_DS_BREAK_YES == yellowDsFlag) || (SIGNAL_DS_BREAK_YES == whiteDsFlag) + || (SIGNAL_DS_BREAK_YES == redYellowDsFlag) || (SIGNAL_DS_BREAK_YES == redWhiteDsFlag) + || (SIGNAL_DS_BREAK_YES == greenYellowDsFlag) || (SIGNAL_DS_BREAK_YES == doubleGreenDsFlag) + || (SIGNAL_DS_BREAK_YES == doubleYellowDsFlag)) + && (CI_TRUE == CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, deviceId))) + {/*źŻڹϹر*/ + + faultFlag = 1u;/*źŻϱ־*/ + break; + } + else + { + ; + } + } + + if (faultFlag == 0u) + {/*źŻδ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_NO);/*ָʾЧ*/ + } + else + {/*źŻ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_YES);/*ָʾЧ*/ + } + + } + else if (INDICATOR_TYPE_CIDEVICE_FAULT == devType) + {/*豸ϱ*/ + chCommuState = Get2oo2CiAndIoCommState(); + if (TRANSMIT_2OO2_STATE_GOOD == chCommuState) + {/*IO ͨ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_IOCOMM_OK);/*ָʾͨ*/ + } + else + {/*IO ͨŹ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_IOCOMM_BAD);/*ָʾͨŹ*/ + } + } + else if (INDICATOR_TYPE_EXPRESS_RETURN == devType) + {/*۷ָʾ*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if ((3u !=devRelaySum)||(NULL ==devRelayIdBuf)) + {/*ݲ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + else if (GetRelayDriveState(devRelayIdBuf[0]) == RELAY_STATE_UP) + {/**/ + + if (GetRelayDriveState(devRelayIdBuf[1]) == RELAY_STATE_DOWN) + { + + SetIndicatorState(devId, INDICATOR_SHOW_RETURN_FLASH);/*ñʾ*/ + } + else + { + /*ȵ */ + SetIndicatorState(devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + } + else if (GetRelayDriveState(devRelayIdBuf[0]) == RELAY_STATE_DOWN) + {/**/ + + if (GetRelayDriveState(devRelayIdBuf[1]) == RELAY_STATE_UP) + {/*ȵ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_RETURN_LIGHT);/*ñʾȵ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + } + else + { + /**/ + SetIndicatorState(devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + + } + else if (INDICATOR_TYPE_AUTORTN_ADHESION == devType) + { + /*۷ťճ״ָ̬ʾ*/ + chNonReturnAdhesionState = CheckNonReturnExistAdhesion(chBjdDeviceId); + if (RTN_RELAY_ADHESION_YES == chNonReturnAdhesionState) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES);/*ñʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO);/*ñʾЧ*/ + } + } + else if (INDICATOR_TYPE_COMM_LEU == devType) + {/*LEUͨ״̬*/ + +#if 0 + if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_LEU,0)) + {/*LEU ͨ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN);/*ָʾͨ*/ + } + else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_LEU,0)) + {/*LEU ͨһ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_COMM_YELLOW);/*ָʾͨһ*/ + } +#endif + leuNum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_LEU); + for (kk =0u;kk= devType)) + {/*devType-INDICATOR_TYPE_COMM_CI_FIRST+1ͨ״̬*/ + + devRelaySum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_CI); + jj = devType - INDICATOR_TYPE_COMM_CI_FIRST; + if (devRelaySum > jj) + { + if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_CI,(UINT8)jj)) + {/*ϵjj+1 ͨ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN);/*ָʾͨ*/ + } + else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_CI,(UINT8)jj)) + {/*jj+1 ͨһ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_COMM_YELLOW);/*ָʾͨһ*/ + } + else + {/*jj+1 ͨŹ*/ + + SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);/*ָʾͨж*/ + } + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED);/*ָʾͨж*/ + } + } + else if (INDICATOR_TYPE_STATUS_START_FLOCK == devType) + {/* ȫվ */ + chStartFlockFlag = GetStartFLockFlag(); + if (CI_START_FLOCK_YES == chStartFlockFlag) + { + /* ʾȫվ״̬ */ + SetIndicatorState(devId, INDICATOR_SHOW_CI_FLOCAK_YES);/*ȫվʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_CI_FLOCAK_NO);/*ȫվʾЧ*/ + } + + } + else if (INDICATOR_TYPE_YINDAOZONGSUO == devType) + {/* ״̬*/ + chAllSwitchYlockFlag = GetAllSwitchYLockFlag(); + if (SWITCH_LOCK_YINZONG_YES == chAllSwitchYlockFlag) + { + /* ʾ״̬*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES);/*Ч*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO);/*Ч*/ + } + + } + else if (INDICATOR_TYPE_STATUS_START_LOCK == devType) + { + /* ϵ״̬ */ + chStartLockFlag = GetStartLockFlag(); + if (CI_START_LOCK_NO == chStartLockFlag) + { + /* ʾȫվϵ״̬ */ + SetIndicatorState(devId, INDICATOR_SHOW_CI_STARTLOCK_YES);/*ϵʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_CI_STARTLOCK_NO); + } + } + else if ((INDICATOR_TYPE_COMM_PSD_START <= devType) && (devType <= INDICATOR_TYPE_COMM_PSD_FIFTH)) + { + /* PSD ͨ״̬ */ + if (GetIndicatorAvalibleFlag(devType) != INDICATOR_DATA_VALID) + { + /* Ч״̬ */ + SetPSDCommonState(devId,devType); + } + } + else if (INDICATOR_TYPE_STATUS_DISPLAY_LINSHIXIANSU == devType) + { + if(HAVE_DIANSHILINSHIXIANSU == dianshiLinshixiansuFlag) + { + /* ˹ȡʱٰťʾ */ + chDevStateRtn = GetLabourCancelLinShiXianState(); + if (LINSHIXIANSU_COMM_BAD_STATE == chDevStateRtn) + { + /* ʾ˹ȡʱٰť */ + SetIndicatorState(devId, INDICATOR_SHOW_CI_LIMIT_YES); + } + else + { /* ʾ˹ȡʱٰť */ + SetIndicatorState(devId, INDICATOR_SHOW_CI_LIMIT_NO); + } + } + else + { + /* ʾ˹ȡʱٰť */ + SetIndicatorState(devId, INDICATOR_SHOW_CI_LIMIT_NO); + } + + } + else if (INDICATOR_TYPE_STATUS_CI_MODE == devType) + { /*ģʽָʾ*/ + SetCiModeIndicatorState(devId); + + } + else if ((INDICATOR_TYPE_PCB1 == devType) ||(INDICATOR_TYPE_PCB2 == devType) || + (INDICATOR_TYPE_PCB3 == devType) ||(INDICATOR_TYPE_PCB4 == devType) || + (INDICATOR_TYPE_PCB5 == devType) ||(INDICATOR_TYPE_PCB6 == devType)) + {/*PCBť״ָ̬ʾ*/ + devRelaySum = GetIndicatorRelaySum(devId); /*ȡ豸*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡ豸ID bufPSD ID*/ + + if ((0u != devRelaySum) && (NULL != devRelayIdBuf)) + {/*豸Ч*/ + chDevStateRtn = GetPsdButtonState(devRelayIdBuf[0]); + chDevStateRtn2 = GetPsdVirtualAttribute(devRelayIdBuf[0]); + if ((PSD_BUTTON_STATE_DOWN == chDevStateRtn) && + (PSD_VIRTUAL_ATTR_YES == chDevStateRtn2)) + { /*PSDPCB*/ + + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ðť״̬ʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else if ((INDICATOR_TYPE_PSD1_ISOLATE == devType) ||(INDICATOR_TYPE_PSD2_ISOLATE == devType) || + (INDICATOR_TYPE_PSD3_ISOLATE == devType) ||(INDICATOR_TYPE_PSD4_ISOLATE == devType) || + (INDICATOR_TYPE_PSD5_ISOLATE == devType) ||(INDICATOR_TYPE_PSD6_ISOLATE == devType)) + {/*PSDϸ״ָ̬ʾ*/ + devRelaySum = GetIndicatorRelaySum(devId); /*ȡ豸*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡ豸ID bufPSD ID*/ + + if ((0u != devRelaySum) && (NULL != devRelayIdBuf)) + {/*豸Ч*/ + chDevStateRtn = GetPsdIsolateState(devRelayIdBuf[0]); + chDevStateRtn2 = GetPsdVirtualAttribute(devRelayIdBuf[0]); + if ((PSD_FAULT_ISOLATION_SCX == chDevStateRtn) && (PSD_VIRTUAL_ATTR_YES == chDevStateRtn2)) + { /*PSDĹϸϢЧ*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ðť״̬ʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else if (INDICATOR_TYPE_AUTORTN_BTN == devId) + {/*Գ۷ť״ָ̬ʾ*/ + chVirtualZDZFButtonState = GetVirtualZDZFButtonState(); + if (VIRTUAL_ZDZFAJ_BUTTON_YES == chVirtualZDZFButtonState) + {/*ť*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ðť״̬ʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else if (INDICATOR_TYPE_ALL_SIG_BRIGHT == devType) + {/*ȫվ״ָ̬ʾ*/ + chDevStateRtn = GetAllSignalBrightFlag(); + if (CI_ALL_SIGNAL_BRIGHT_YES == chDevStateRtn) + {/*ȫվ״̬Ч*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ȫվƱʾЧ*/ + } + else + {/*ȫվ״̬Ч*/ + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ȫվƱʾЧ*/ + } + } + else if (INDICATOR_TYPE_AUTO_TRIGGE == devType) + { /*Զ־*/ + chDevStateRtn = CheckAutoTriggerIndicatFlag(0U); + if (CI_SUCCESS == chDevStateRtn) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ԶʾЧ*/ + } + else + {/*ȫվ״̬Ч*/ + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ԶʾЧ*/ + } + } + else if ((INDICATOR_TYPE_XICHEJI_ALLOW_STATE == devType) + || (INDICATOR_TYPE_DOWNWASH_ALLOW_PASS_STATE == devType)) + {/* FAO·ͬϴ״ָ̬ʾ||ģʽϴָͬʾ||ģʽϴָͬͨʾ */ + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID bufӦ̵ͨͬXTJ*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + chDevStateRtn = GetRelayCollState(devRelayIdBuf[0]); + if (RELAY_STATE_UP == chDevStateRtn) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + } + else if (INDICATOR_TYPE_GENERAL_RESET_VALID == devType) + { + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID bufӦܸλ̵ZFWJ*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + chDevStateRtn = GetRelayCollState(devRelayIdBuf[0]); + if (RELAY_STATE_UP == chDevStateRtn) + { /*̵*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + } + else if (INDICATOR_TYPE_ATS_CONFIRM_RELAY_INTERFACE == devType) + {/*̵ӿȷ״ָ̬ʾ*/ + relayConfirmFlag = GetCiCiRelayInterfConfirmFlag(); + if (CICI_RELAY_INTERFACE_CONFIRM_YES == relayConfirmFlag) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + else if(INDICATOR_TYPE_RELAY_HUNXIAN == devType) + { + relaySum = GetRelayCurSum(); + for(jj = 0u; jj < relaySum;jj++) + { + RelayId = GetRelayId(jj); + relayBelongCi = GetRelayBelongCiId(RelayId); + if(relayBelongCi == localCiId) + { + relayHunXianState = GetRelayHunXianState(RelayId); + if(RELAY_HUNXIAN_STATE_YES == relayHunXianState) + { + break; + } + } + } + if(RELAY_HUNXIAN_STATE_YES == relayHunXianState) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + /*ÿ־״̬*/ + SetZfwjHunXianFLag(ZFWJ_HUN_XIAN_NO); + } + /*ȡת޻ָʾ*/ + else if(INDICATOR_TYPE_SWITCH_BLOCK_LINK == devType) + { + /*ȡȡ״̬*/ + switchBlockLinkState = GetCancelOrRcvrBlockLinkSta(); + if(CANCEL_SWITCH_BLOCK_LINK == switchBlockLinkState) + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + } + else if ((INDICATOR_TYPE_UPS_DCGD == devType) || + (INDICATOR_TYPE_UPS_DCDY == devType)) + { /*cgh-ϲCID-3037-3UPSع || UPSصѹ*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if ((0U == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*úƱ*/ + } + else + { + relayCollState = GetRelayCollState(devRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*̵*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ú*/ + } + + } + + } + else if (INDICATOR_TYPE_PORT_RONGSI == devType) + { + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + relayCollState = GetRelayCollState(devRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧޱ*/ + } + } + } + else if ((INDICATOR_TYPE_UPS1_PL == devType)|| (INDICATOR_TYPE_UPS2_PL == devType)) + {/*UPS·ָʾ*/ + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧʾUPSδ·*/ + } + else + { + relayCollState = GetRelayCollState(devRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*·̵*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧޱ*/ + } + } + } + else if (INDICATOR_TYPE_COMM_DEVICE == devType) + { + /*ͨ豸״ָ̬ʾƣͨͨ״̬*/ + commStatus = CheckRCICommCCUDeviceStatue(); + if (CI_SUCCESS == commStatus) + { + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + } + else if (INDICATOR_TYPE_COMM_AXIS == devType) + { + /*ϵͳͨ״̬*/ + cCommAxisNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); + pAxisSysIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); + + if ((0U < cCommAxisNum) && (NULL != pAxisSysIdBuf)) + { + for (mm = 0U; mm < cCommAxisNum; mm++) + { + commStatus = GetCiTransmitState(CI_SYSTEM_TYPE_AXIS, pAxisSysIdBuf[mm]); + + if (TRANSMIT_STATE_GOOD == commStatus) + { + SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN); /*ָʾͨ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED); /*ͨŹϣָʾͨŹ*/ + break; /*һϣΪͨŹϣڴ˴ѭ*/ + } + } + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED); + } + } + else + { + /**/ + } + } + + /*****ƽ̨12ϵָʾ*****/ + +#ifdef PLATFORM_2OO2 + + if ((sysFirstId > 0U) && (sysSecondId > 0U)) + { + computerId = Get2oo2ComputerId(); /*ȡƽ̨ID*/ + runMode = Get2oo2ProcessMode(); /*ȡƽ̨ģʽ*/ + runMode|= Get2oo2OhterProcessMode(); + if ((computerId > 0U) && (runMode > 0U)) + { + selfState = ((runMode) & ((UINT8)0xF0)) >> 4; + otherState = (runMode) & ((UINT8)0x0F); + + debug_infor_printf((const)"computerId %d selfState %d otherState %d\n", computerId, selfState, otherState); + if (1U == computerId)/*1ϵ*/ + { + if(0x0aU == selfState) + { + SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_MAIN); /*ָʾ1ϵΪ*/ + } + else if (0x05U == selfState) + { + SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_BACKUP); /*ָʾ1ϵΪ*/ + } + else + { + SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ1ϵ*/ + } + + if(0x0aU == otherState) + { + SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_MAIN); /*ָʾ2ϵΪ*/ + } + else if (0x05U == otherState) + { + SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_BACKUP); /*ָʾ2ϵΪ*/ + } + else + { + SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ2ϵ*/ + } + } + else if (2U == computerId) + { + if(0x0aU == selfState) + { + SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_MAIN); /*ָʾ2ϵΪ*/ + } + else if (0x05U == selfState) + { + SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_BACKUP); /*ָʾ2ϵΪ*/ + } + else + { + SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ2ϵ*/ + } + + if(0x0aU == otherState) + { + SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_MAIN); /*ָʾ1ϵΪ*/ + } + else if (0x05U == otherState) + { + SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_BACKUP); /*ָʾ1ϵΪ*/ + } + else + { + SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ1ϵ*/ + } + } + else + {/**/ + } + } + else + { + SetIndicatorState(sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ1ϵ*/ + SetIndicatorState(sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ2ϵ*/ + } + } + +#endif + + + + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_NO); /*ʼԳָʾЧ*/ + SetIndicatorState(allow_1_Id, INDICATOR_SHOW_NO); /*ʼͬԳָʾЧ*/ + SetIndicatorState(over_1_Id, INDICATOR_SHOW_NO); /*ʼԳָʾЧ*/ + + SetIndicatorState(apply_2_Id, INDICATOR_SHOW_NO); /*ʼԳָʾЧ*/ + SetIndicatorState(allow_2_Id, INDICATOR_SHOW_NO); /*ʼͬԳָʾЧ*/ + SetIndicatorState(over_2_Id, INDICATOR_SHOW_NO); /*ʼԳָʾЧ*/ + + SetIndicatorState(jkj_valid_Id, INDICATOR_SHOW_NO); /*ʼӦָʾЧ*/ + /* Ĭ״̬ΪָʾЧ*/ + if(CI_TYPE_CLD == chLocalCiType) + { + if (jkj_valid_Id > 0u) + { + jkjRelayValidFlag = GetCiJkjFlag(); /*JKJӦ̵̼Ч־*/ + /*Ӧ̵̼Ч״̬*/ + if (JKJ_REYLAY_VALID == jkjRelayValidFlag) + { + SetIndicatorState(jkj_valid_Id, INDICATOR_SHOW_YES); /*ýӦָʾЧ*/ + } + else + { + SetIndicatorState(jkj_valid_Id, INDICATOR_SHOW_NO); /*ýӦָʾЧ*/ + } + } + + /*ǽ·ָʾ*/ + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ߲ü̵ӿ*/ + if ((apply_1_Id > 0u) && (allow_1_Id > 0u) && (over_1_Id > 0u) && (applyRelay_1_Id > 0u) && (allowRelay_1_Id > 0u)) + { + + if ((RELAY_STATE_DOWN == GetRelayCollState(applyRelay_1_Id)) && + (RELAY_STATE_DOWN == GetRelayCollState(allowRelay_1_Id))) + { /*Գ̵&&Գ̵*/ + + nonRouteId = GetNonRouteIdByIndicatorId(apply_1_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + if (NONROUTE_STATE_IDLE == chNonRouteState) + { /*ǽ·*/ + + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_YES); /*ԳָʾЧ*/ + } + else if (NONROUTE_STATE_XUANPAI == chNonRouteState) + { /*ǽ·ѡ*/ + nonRouteRunModeById = GetNonRouteRunModeById(nonRouteId); + if (NONROUTE_RUN_MODE_APPLY == nonRouteRunModeById) + { /*źģʽ*/ + + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_YES); /*ԳָʾЧ*/ + } + else + { + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + else + { + /*޲*/ + } + } + else + { + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + + if (RELAY_STATE_UP == GetRelayCollState(allowRelay_1_Id)) + { /*Գ̵*/ + nonRouteId = GetNonRouteIdByIndicatorId(allow_1_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + if ((NONROUTE_STATE_LOCK == chNonRouteState) ||(NONROUTE_STATE_OPEN == chNonRouteState)) + { /*ǽ·||ǽ·*/ + + if ((NONROUTE_CANCEL_FLAG_YES == GetNonRouteCancelFlagById(nonRouteId)) || + (NONROUTE_CANCEL_FLAG_YES == GetNonRouteHaveCancelFlagById(nonRouteId))) + { + SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_NO); /*ͬԳָʾЧ*/ + } + else + { + SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_YES); /*ͬԳָʾЧ*/ + } + } + } + else + { + SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_NO); /*ͬԳָʾЧ*/ + } + } + + if (RELAY_STATE_UP == GetRelayCollState(applyRelay_1_Id)) + { /*Գ̵*/ + nonRouteId = GetNonRouteIdByIndicatorId(apply_1_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + chNonRouteMode = GetNonRouteRunModeById(nonRouteId); + if ((NONROUTE_STATE_OPEN == chNonRouteState) || + (NONROUTE_STATE_LOCKERR == chNonRouteState) || + (NONROUTE_STATE_FAULTDELAY_UNLOCK == chNonRouteState) || + (NONROUTE_STATE_DELAY_UNLOCK == chNonRouteState)) + { /*ǽ·ʱ||ǽ·||ǽ·||ǽ·ʱ*/ + + if (NONROUTE_RUN_MODE_APPLY == chNonRouteMode) + {/*źģʽ*/ + + SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_YES); /*ýԳָʾЧ*/ + } + else + {/*Գģʽ*/ + + SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + + } + else + { + ; + } + } + else + { + SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + } + + + if ((apply_2_Id > 0u) && (allow_2_Id > 0u) && (over_2_Id > 0u) && (applyRelay_2_Id > 0u) && (allowRelay_2_Id > 0u)) + { + + if ((RELAY_STATE_DOWN == GetRelayCollState(applyRelay_2_Id)) && + (RELAY_STATE_DOWN == GetRelayCollState(allowRelay_2_Id))) + { /*Գ̵&&Գ̵*/ + + nonRouteId = GetNonRouteIdByIndicatorId(apply_2_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + if (NONROUTE_STATE_IDLE == chNonRouteState) + { /*ǽ·*/ + + SetIndicatorState(apply_2_Id, INDICATOR_SHOW_SC_YES); /*ԳָʾЧ*/ + } + else if (NONROUTE_STATE_XUANPAI == chNonRouteState) + { /*ǽ·ѡ*/ + nonRouteRunModeById = GetNonRouteRunModeById(nonRouteId); + if (NONROUTE_RUN_MODE_APPLY == nonRouteRunModeById) + { /*źģʽ*/ + + SetIndicatorState(apply_2_Id, INDICATOR_SHOW_SC_YES); /*ԳָʾЧ*/ + } + else + { + SetIndicatorState(apply_2_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + else + { + /*޲*/ + } + } + else + { + SetIndicatorState(apply_2_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + + if (RELAY_STATE_UP == GetRelayCollState(allowRelay_2_Id)) + { /*Գ̵*/ + nonRouteId = GetNonRouteIdByIndicatorId(allow_2_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + if ((NONROUTE_STATE_LOCK == chNonRouteState) || + (NONROUTE_STATE_OPEN == chNonRouteState)) + { /*ǽ·||ǽ·*/ + + if ((NONROUTE_CANCEL_FLAG_YES == GetNonRouteCancelFlagById(nonRouteId)) || + (NONROUTE_CANCEL_FLAG_YES == GetNonRouteHaveCancelFlagById(nonRouteId))) + { + SetIndicatorState(allow_2_Id, INDICATOR_SHOW_SC_NO); /*ͬԳָʾЧ*/ + } + else + { + SetIndicatorState(allow_2_Id, INDICATOR_SHOW_SC_YES); /*ͬԳָʾЧ*/ + } + } + else + { + ; + } + } + else + { + SetIndicatorState(allow_2_Id, INDICATOR_SHOW_SC_NO); /*ͬԳָʾЧ*/ + } + } + + if (RELAY_STATE_UP == GetRelayCollState(applyRelay_2_Id)) + { /*Գ̵*/ + nonRouteId = GetNonRouteIdByIndicatorId(apply_2_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + chNonRouteMode = GetNonRouteRunModeById(nonRouteId); + if ((NONROUTE_STATE_OPEN == chNonRouteState) || + (NONROUTE_STATE_LOCKERR == chNonRouteState) || + (NONROUTE_STATE_FAULTDELAY_UNLOCK == chNonRouteState) || + (NONROUTE_STATE_DELAY_UNLOCK == chNonRouteState)) + { /*ǽ·ʱ||ǽ·||ǽ·||ǽ·ʱ*/ + + if (NONROUTE_RUN_MODE_APPLY == chNonRouteMode) + {/*źģʽ*/ + + SetIndicatorState(over_2_Id, INDICATOR_SHOW_SC_YES); /*ýԳָʾЧ*/ + } + else + {/*Գģʽ*/ + + SetIndicatorState(over_2_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + + } + else + { + ; + } + } + else + { + SetIndicatorState(over_2_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + } + } + else + {/*Գ߲ͨŽӿ*/ + chDevStateRtn = GetCommTrainTestCLDSQJStatus(); + chDevStateRtn2 = GetCommTrainTestCLDTYSJStatus(); + if ((COMM_TRAIN_TEST_DEV_STATE_VALID == chDevStateRtn) && + (COMM_TRAIN_TEST_DEV_STATE_INVALID == chDevStateRtn2)) + { /*Գ״̬Ч&&Գ״̬Ч*/ + nonRouteId = GetNonRouteIdByIndicatorId(apply_1_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + chNonRouteMode = GetNonRouteRunModeById(nonRouteId); + if (NONROUTE_STATE_IDLE == chNonRouteState) + { /*ǽ·*/ + + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_YES); /*ԳָʾЧ*/ + } + else if (NONROUTE_STATE_XUANPAI == chNonRouteState) + { /*ǽ·ѡ*/ + + if (NONROUTE_RUN_MODE_APPLY == chNonRouteMode) + { /*źģʽ*/ + + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_YES); /*ԳָʾЧ*/ + } + else + { + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + else + { + /*޲ */ + } + } + else + { + SetIndicatorState(apply_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + + if (COMM_TRAIN_TEST_DEV_STATE_VALID == chDevStateRtn2) + { /*Գ״̬Ч*/ + nonRouteId = GetNonRouteIdByIndicatorId(allow_1_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + if ((NONROUTE_STATE_LOCK == chNonRouteState) || + (NONROUTE_STATE_OPEN == chNonRouteState)) + { /*ǽ·||ǽ·*/ + + if ((NONROUTE_CANCEL_FLAG_YES == GetNonRouteCancelFlagById(nonRouteId)) || + (NONROUTE_CANCEL_FLAG_YES == GetNonRouteHaveCancelFlagById(nonRouteId))) + { + SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_NO); /*ͬԳָʾЧ*/ + } + else + { + SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_YES); /*ͬԳָʾЧ*/ + } + } + else + { + ; + } + } + else + { + SetIndicatorState(allow_1_Id, INDICATOR_SHOW_SC_NO); /*ͬԳָʾЧ*/ + } + } + else + { + ; + } + + if (COMM_TRAIN_TEST_DEV_STATE_INVALID == chDevStateRtn) + { /*Գ״̬Ч*/ + nonRouteId = GetNonRouteIdByIndicatorId(over_1_Id); + if (nonRouteId > 0u) + { + chNonRouteState = GetNonRouteStateById(nonRouteId); + chNonRouteMode = GetNonRouteRunModeById(nonRouteId); + if ((NONROUTE_STATE_OPEN == chNonRouteState) || + (NONROUTE_STATE_LOCKERR == chNonRouteState) || + (NONROUTE_STATE_FAULTDELAY_UNLOCK == chNonRouteState) || + (NONROUTE_STATE_DELAY_UNLOCK == chNonRouteState)) + { /*ǽ·ʱ||ǽ·||ǽ·||ǽ·ʱ*/ + + if (NONROUTE_RUN_MODE_APPLY == chNonRouteMode) + {/*źģʽ*/ + + SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_YES); /*ýԳָʾЧ*/ + } + else + {/*Գģʽ*/ + + SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + + } + else + { + ; + } + } + else + { + SetIndicatorState(over_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + else + { + ; + } + } + + } + else/*Ͳdz*/ + { + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + /* Գ ͬԳ ָʾ ߲øָʾƣallowid = 0,Գж */ + if ((allow_1_Id > 0u) && (allowRelay_1_Id > 0u)) + { + if (RELAY_STATE_UP == GetRelayCollState(allowRelay_1_Id)) + { /*ͬԳԳ̵*/ + SetIndicatorState(allow_1_Id,INDICATOR_SHOW_SC_YES); + } + else + { + SetIndicatorState(allow_1_Id,INDICATOR_SHOW_SC_NO); /*ղͬԳ̵ʱرźŻ*/ + + } + } + else + { + ; + } + + + /* Գ Գָʾ */ + if ((apply_1_Id>0u) && (applyRelay_1_Id > 0u)) + { + if (RELAY_STATE_UP == GetRelayCollState(applyRelay_1_Id)) + { /* Գ Գ̵*/ + SetIndicatorState(apply_1_Id,INDICATOR_SHOW_SC_YES); + } + else + { + SetIndicatorState(apply_1_Id,INDICATOR_SHOW_SC_NO); + } + } + else + { + ; + } + } + else + {/*Գ복βͨŽӿ*/ + if (CI_TYPE_SCX == GetLocalCiType()) + {/*ΪԳ*/ + /*ͬԳָʾ*/ + if (allow_1_Id > 0u)/*߲øָʾƣallowid = 0,Գж*/ + { + if (COMM_TRAIN_TEST_DEV_STATE_VALID == GetCommTrainTestSCXYSKJStatus()) + { /*ͬԳ豸״̬Ч*/ + SetIndicatorState(allow_1_Id,INDICATOR_SHOW_SC_YES); + } + else + { + SetIndicatorState(allow_1_Id,INDICATOR_SHOW_SC_NO); /*ղͬԳ̵ʱرźŻ*/ + + } + } + else + { + ; + } + + /* Գ Գָʾ */ + if (apply_1_Id>0u) + { + if (COMM_TRAIN_TEST_DEV_STATE_VALID == GetCommTrainTestSCXSQAJStatus()) + { /* Գ 豸״̬Ч*/ + SetIndicatorState(apply_1_Id,INDICATOR_SHOW_SC_YES); + } + else + { + SetIndicatorState(apply_1_Id,INDICATOR_SHOW_SC_NO); + } + } + else + { + ; + } + + } + else + { + ; + } + } + } +} + + +/* +* ָʾ״̬ +* ˵ void +* ֵ void +*/ +void IndicatorStateProc_UseVirCI(UINT8 virCIid) +{ + UINT8 devCurSum = 0u; /*豸*/ + UINT8 devId = 0u; /*豸ID*/ + UINT8 devType = 0u; /*豸*/ + UINT8 devRelaySum = 0u; /*豸̵*/ + UINT16* pDevRelayIdBuf = NULL; /*̵IDbuf*/ + UINT8 belongVirCIid = 0u; + UINT8 avalibleFlag = 0u; + + UINT16 apply_1_Id = 0u; /*ԳID*/ + UINT16 allow_1_Id = 0u; /*ԳID*/ + UINT16 over_1_Id = 0u; /*ԳID*/ + + UINT16 apply_2_Id = 0u; /*ԳID*/ + UINT16 allow_2_Id = 0u; /*ԳID*/ + UINT16 over_2_Id = 0u; /*ԳID*/ + UINT16 jkj_valid_Id = 0u; /*Ӧ̵̼ЧID*/ + + UINT16 sysFirstId = 0u; /*ƽ̨һϵID*/ + UINT16 sysSecondId = 0u; /*ƽ̨ϵID*/ + UINT8 computerId = 0u; /*ƽ̨ID*/ + UINT8 runMode = 0u; /*ģʽ*/ + UINT8 selfState = 0u; /*״̬*/ + UINT8 otherState = 0u; /*״̬*/ + UINT16 applyRelay_1_Id = 0u; /*Գ̵1 ID*/ + UINT16 allowRelay_1_Id = 0u; /*Գ̵1 ID*/ + + UINT16 applyRelay_2_Id = 0u; /*Գ̵2 ID*/ + UINT16 allowRelay_2_Id = 0u; /*Գ̵2 ID*/ + + UINT8 faultFlag = 0u;/*ϱ־ 0Ϊδ*/ + UINT8 ii = 0u; + UINT16 jj = 0u; + UINT16 kk = 0u;/**/ + UINT16 deviceCurSum = 0u; /*Ŀ*/ + UINT16 deviceId = 0u; /*ID*/ + UINT8 interfaceType = 0u; /*Գ복νӿڷʽ*/ + + UINT8 leuNum = 0u;/*뱾CIͨŵLEU*/ + UINT8 leuState = 0u;/*LEU״̬*/ + + UINT16 nonRouteId = 0u;/*ǽ·id*/ + UINT8 jkjRelayValidFlag = 0u; + + UINT8 relayConfirmFlag = 0u;/*̵ӿȷϱ־*/ + + UINT8 redDsFlag = 0u; /*ƶ˿*/ + UINT8 greenDsFlag = 0u; /*̵ƶ˿*/ + UINT8 yellowDsFlag = 0u; /*Ƶƶ˿*/ + UINT8 whiteDsFlag = 0u; /*׵ƶ˿*/ + UINT8 redYellowDsFlag= 0u; /*Ƶƶ˿*/ + UINT8 redWhiteDsFlag= 0u; /*׵ƶ˿*/ + UINT8 greenYellowDsFlag= 0u; /*̻Ƶƶ˿*/ + UINT8 doubleGreenDsFlag= 0u; /*˫̵ƶ˿*/ + UINT8 doubleYellowDsFlag = 0u; /*˫Ƶƶ˿*/ + + UINT8 nonRouteState = 0u; /*ǽ·״̬*/ + UINT8 relayCollState = 0u;/*̵ɼ*/ + UINT8 relayDrivState = 0u;/*̵*/ + UINT8 stopCheckFlag = 0u; + UINT8 dianshiLinshixiansuFlag = GetCiFunctionSwitchConfig(FUNC_DIANSHI_LINSHIXIANSU_FLAG);/*ʽʱ*/ + UINT8 singleSwitchCurPosition = 0u; + UINT8 checkReVal = 0u; + UINT8 garagedoorFaultState = 0u;/*״̬*/ + UINT8 localCiType = 0u; + UINT16 signalNum = 0u; + UINT8 commState = 0u; + UINT8 startFLockFlag = 0u; + UINT8 virCIAllSwitchYLockState = 0u; + UINT8 startLockFlag = 0u; + UINT8 VirCILabourCancelLinShiXianSta = 0u; + UINT8 psdButtonState = 0u; + UINT8 psdVirtualAttribute = 0u; + UINT32 psdIsolateState = 0u; + UINT8 virtualZDZFButtonState = 0u; + UINT8 allSignalBrightState = 0u; + UINT8 autoTriggerFlag = 0u; + UINT8 applyRelayCollState = 0u; + UINT8 allowRelayCollState = 0u; + UINT8 NonRouteState = 0u; + UINT8 NonRouteRunMode = 0u; + UINT8 NonRouteCancelFlag = 0u; + UINT8 NonRouteHaveCancelFlag = 0u; + + UINT8 CommTrainTestCLDSQJStatus= 0u; + UINT8 CommTrainTestCLDTYSJStatus = 0u; + + UINT8 CommTrainTestSCXYSKJStatus = 0u; + UINT8 CommTrainTestSCXSQAJStatus = 0u; + UINT8 switchBlockLinkState = 0u; + UINT8 relayHunXianState = 0u; + UINT16 RelayId = 0u; + UINT8 relayBelongCi = 0u; + UINT16 relaySum = 0u; + UINT8 localCiId = 0u; + UINT8 chBjdDeviceId = 0U;/*豸ID*/ + UINT8 chNonReturnAdhesionState = 0U;/*۷ճ״̬*/ + UINT8 cCommAxisNum = 0U; + UINT8 mm = 0U; + UINT8 commStatus = 0U; + + devCurSum = GetVirCIIndicatorConfigDataNum(virCIid); /*ȡָʾǰ*/ + interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*ȡԳ복νӿڷʽ*/ + localCiId = GetSystemParaLocalCiId(); + + for (ii = 0u; ii < devCurSum; ii++) + { + devRelaySum = 0u; + pDevRelayIdBuf = NULL; + + devId = GetVirCIlocalCiIndicatorId(virCIid,ii);/*ȡָʾID*/ + devType = GetVirCIIndicatorType(virCIid,devId); /*ȡ豸*/ + chBjdDeviceId = GetVirCIIndicatorDevId(virCIid,devId); + + avalibleFlag = GetVirCIIndicConfDataAvalFlag(virCIid,devId);/*ָʾÿ*/ + + /*###ơ###*/ + if ((INDICATOR_TYPE_ALARM_RONGSI == devType) || + (INDICATOR_TYPE_ALARM_GDGZ == devType) || + (INDICATOR_TYPE_ALARM_RONGSI_qujian2 == devType) + ) + { /*˿ || ϱ*/ + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId,INDICATOR_SHOW_YES); /*ñ*/ + + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ñ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ޱ*/ + } + } + } + else if ((INDICATOR_TYPE_POWER_SCREEN == devType)|| + (INDICATOR_TYPE_ALARM_XICHEJI == devType)|| + (INDICATOR_TYPE_READY_XICHEJI == devType) || + (INDICATOR_TYPE_ALARM_DUANSI_qujian2 == devType) || + (INDICATOR_TYPE_POWER_SCREEN_qujian2 == devType) + ) + {/* Դ || ϴ ̵ || ϴ״̬*/ + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ñ*/ + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ޱ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ñ*/ + } + } + } + else if (INDICATOR_TYPE_ALARM_DUANSI == devType) + {/*˿ */ + + SignaDsBreakAlarmIndicator_Vir(virCIid,devId); + } + else if (INDICATOR_TYPE_ALARM_GDTD == devType) + { /*ͣ籨*/ + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ʼޱ*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ñ*/ + } + else + { + for (jj = 0u; jj < devRelaySum; jj++) + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[jj]); + if (RELAY_STATE_DOWN == relayCollState) + { /*̵*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ñ*/ + break; + } + } + } + } + else if ((INDICATOR_TYPE_UPS_FAULT == devType) || + (INDICATOR_TYPE_UPS2_FAULT == devType) + ) + { /*UPSָʾ UPS2ָʾ*/ + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*UPSָʾЧݴ*/ + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*UPSָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*UPSָʾЧ*/ + } + } + } + + /*###ָʾơ###*/ + else if ((INDICATOR_TYPE_EXPRESS_MAINP == devType) ||(INDICATOR_TYPE_EXPRESS_BACKP == devType) + || (INDICATOR_TYPE_EXPRESS_MAINP_2 == devType) || (INDICATOR_TYPE_EXPRESS_BACKP_2 == devType)) + { /*Դָʾ || Դָʾ*/ + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*õԴ*/ + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*õԴЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*õԴ*/ + } + } + } + else if ((INDICATOR_TYPE_EXPRESS_ZHAOCHA1 == devType) || + (INDICATOR_TYPE_EXPRESS_ZHAOCHA2 == devType) || + (INDICATOR_TYPE_EXPRESS_ZHAOCHA3 == devType) || + (INDICATOR_TYPE_EXPRESS_ZHAOCHA4 == devType) || + (INDICATOR_TYPE_EXPRESS_ZHAOCHA5 == devType)) + { /*ղָʾ*/ + + SetZhaoChaIndictorComSta_Vir(virCIid,devId); + } + else if (INDICATOR_TYPE_EXPRESS_2OO2_I == devType) + { /*һϵ״ָ̬ʾ*/ + + sysFirstId = devId;/*洦*/ + } + else if (INDICATOR_TYPE_EXPRESS_2OO2_II == devType) + { /*ϵ״ָ̬ʾ*/ + + sysSecondId = devId;/*洦*/ + } + else if ((INDICATOR_TYPE_EXPRESS_NONROUTE == devType) || (INDICATOR_TYPE_EXPRESS_NONROUTE_2 == devType)) + { /*ǽ·1 ǽ·2*/ + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*÷ǽ·ָʾЧݴ*/ + } + else + { + nonRouteState = GetNonRouteStateById((UINT8)(pDevRelayIdBuf[0])); + if (NONROUTE_STATE_IDLE == nonRouteState) + { + /*δǽ·*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NONROUTE_NOSET); /*ָʾЧ*/ + } + else if ((NONROUTE_STATE_LOCK == nonRouteState) || + (NONROUTE_STATE_LOCKERR == nonRouteState) || + (NONROUTE_STATE_OPEN == nonRouteState))/*ǽ·//ǽ·*/ + { + /*ǽ·*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NONROUTE_LOCK); /*ָʾЧ*/ + } + else + { + /* ǽ·ջʱڼ*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NONROUTE_SETING); /*ָʾЧ*/ + } + } + } + else if (INDICATOR_TYPE_EXPRESS_STOP_CHECK == devType) + { /*ֹͣ״ָ̬ʾ*/ + stopCheckFlag = GetStopCheckFlag(); + if (ROUTE_STOPCHECK_SET_YES == stopCheckFlag) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + else if (INDICATOR_TYPE_SWITCH_JICHA == devType) + { /*״ָ̬ʾ*/ + deviceCurSum = GetSwitchCurSum(); + for (jj = 0u; jj < deviceCurSum; jj++) + { + deviceId = GetSwitchId(jj); + belongVirCIid = GetSwitchBelongVirCiId(deviceId); + singleSwitchCurPosition = GetSingleSwitchCurPosition(deviceId); + checkReVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SWITCH, deviceId); + if ((SWITCH_POSITION_JICHA == singleSwitchCurPosition) && (CI_TRUE == checkReVal)&&(belongVirCIid == virCIid)) + { /*Էɽߵĵ*/ + break; + } + } + + if (deviceCurSum == jj) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + } + else if (INDICATOR_TYPE_GD_DAD == devType) + { /*Źָʾ*/ + deviceCurSum = GetGaragedoorSum(); + if(INDICATOR_DATA_RELAY == avalibleFlag) + { + for (jj = 0u; jj < deviceCurSum; jj++) + { + deviceId = GetGaragedoorId(jj); + garagedoorFaultState = GetGaragedoorFaultState(deviceId); + if (GARAGE_DOOR_FAULT_TRUE == garagedoorFaultState) + { + break; + } + } + + if (deviceCurSum == jj) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + + } + else if (INDICATOR_TYPE_EXPRESS_SC_APP == devType) + { /*Գָʾ1*/ + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid,devId); + if (0u < nonRouteId) + { + localCiType = GetLocalCiType(); + if(CI_TYPE_SCX == localCiType) + { + /* Գ */ + apply_1_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelay_1_Id = GetSCXDrvApplyTryRelayIdById((UINT8)nonRouteId); /*Գ̵ID*/ + } + } + else + { + /* */ + apply_1_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelay_1_Id = GetNonRouteAppTryRelayIdById((UINT8)nonRouteId); /*Գ̵ID*/ + } + } + } + + } + else if (INDICATOR_TYPE_EXPRESS_SC_APP_2 == devType) + { /*Գָʾ2*/ + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid,devId); + if (0u < nonRouteId) + { + + if(CI_TYPE_SCX == GetLocalCiType()) + { + /* Գ */ + apply_2_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelay_2_Id = GetSCXDrvApplyTryRelayIdById((UINT8)nonRouteId); /*Գ̵ID*/ + } + } + else + { + /* */ + apply_2_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelay_2_Id = GetNonRouteAppTryRelayIdById((UINT8)nonRouteId); /*Գ̵ID*/ + } + } + } + + } + else if (INDICATOR_TYPE_EXPRESS_SC_ALW == devType) + { /*Գָʾ1*/ + + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid,devId); + if (0u < nonRouteId) + { + localCiType = GetLocalCiType(); + if(CI_TYPE_SCX == localCiType) + { + allow_1_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + allowRelay_1_Id = GetSCXColAgreeTryRelayIdById((UINT8)nonRouteId); /*Գ̵1ID*/ + } + } + else + { /* */ + allow_1_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + allowRelay_1_Id = GetNonRouteAgreeTryRelayIdById((UINT8)nonRouteId); /*Գ̵1ID*/ + } + } + } + } + else if (INDICATOR_TYPE_EXPRESS_SC_ALW_2 == devType) + { /*Գָʾ2*/ + + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid,devId); + if (0u < nonRouteId) + { + localCiType = GetLocalCiType(); + if(CI_TYPE_SCX == localCiType) + { + allow_2_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + allowRelay_2_Id = GetSCXColAgreeTryRelayIdById((UINT8)nonRouteId); /*Գ̵2ID*/ + } + } + else + { /* */ + allow_2_Id = devId; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + allowRelay_2_Id = GetNonRouteAgreeTryRelayIdById((UINT8)nonRouteId); /*Գ̵2ID*/ + } + } + } + } + else if (INDICATOR_TYPE_EXPRESS_SC_END == devType) + { /*Գָʾ1*/ + + over_1_Id = devId; + } + else if (INDICATOR_TYPE_EXPRESS_SC_END_2 == devType)/*Գָʾ2*/ + { + over_2_Id = devId; + } + else if (INDICATOR_TYPE_JKJ_VALID == devType)/*Ӧ̵̼Чָʾ*/ + { + jkj_valid_Id = devId; + } + else if (INDICATOR_TYPE_SIGNAL_FAULT_CLOSE == devType) + {/*źŻϹرձ*/ + signalNum = GetSignalCurSum(); + for (jj = 0u; jj < signalNum; jj++) + { + deviceId = GetSignalId(jj); + belongVirCIid = GetSignalBelongVirCiId(deviceId); + /*ȡ˿˿״̬*/ + redDsFlag = GetSignalDsBreakFlag(deviceId); + greenDsFlag = GetSignalGreenDsBreakFlag(deviceId); + yellowDsFlag = GetSignalYellowDsBreakFlag(deviceId); + whiteDsFlag = GetSignalWhiteDsBreakFlag(deviceId); + redYellowDsFlag = GetSignalRedYellowDsBreakFlag(deviceId); + redWhiteDsFlag = GetSignalRedWhiteDsBreakFlag(deviceId); + greenYellowDsFlag = GetSignalGreenYellowDsBreakFlag(deviceId); + doubleGreenDsFlag = GetSignalDoubleGreenDsBreakFlag(deviceId); + doubleYellowDsFlag = GetSigDoubleYellowDsBreakFlag(deviceId); + + checkReVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, deviceId); + if (((SIGNAL_DS_BREAK_YES == redDsFlag) || (SIGNAL_DS_BREAK_YES == greenDsFlag) + || (SIGNAL_DS_BREAK_YES == yellowDsFlag) || (SIGNAL_DS_BREAK_YES == whiteDsFlag) + || (SIGNAL_DS_BREAK_YES == redYellowDsFlag) || (SIGNAL_DS_BREAK_YES == redWhiteDsFlag) + || (SIGNAL_DS_BREAK_YES == greenYellowDsFlag) || (SIGNAL_DS_BREAK_YES == doubleGreenDsFlag) + || (SIGNAL_DS_BREAK_YES == doubleYellowDsFlag)) + && (CI_TRUE == checkReVal)&&(virCIid == belongVirCIid)) + {/*źŻڹϹر*/ + + faultFlag = 1u;/*źŻϱ־*/ + break; + } + } + + if (0u == faultFlag) + {/*źŻδ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO);/*ָʾЧ*/ + } + else + {/*źŻ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES);/*ָʾЧ*/ + } + + } + else if (INDICATOR_TYPE_CIDEVICE_FAULT == devType) + {/*豸ϱ*/ + commState = Get2oo2CiAndIoCommState(); + if (TRANSMIT_2OO2_STATE_GOOD == commState) + {/*IO ͨ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_IOCOMM_OK);/*ָʾͨ*/ + } + else + {/*IO ͨŹ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_IOCOMM_BAD);/*ָʾͨŹ*/ + } + + + } + else if (INDICATOR_TYPE_EXPRESS_RETURN == devType) + {/*۷ָʾ*/ + if(INDICATOR_DATA_RELAY ==avalibleFlag) + { + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId);/*ȡؼ̵ID buf*/ + + if ((3u !=devRelaySum)||(NULL ==pDevRelayIdBuf)) + {/*ݲ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + else + { + relayDrivState = GetRelayDriveState(pDevRelayIdBuf[0]); + if (RELAY_STATE_UP == relayDrivState) + {/**/ + relayDrivState = GetRelayDriveState(pDevRelayIdBuf[1]); + if (RELAY_STATE_DOWN == relayDrivState) + { + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_FLASH);/*ñʾ*/ + } + else + { + /*ȵ */ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + } + else if (RELAY_STATE_DOWN == relayDrivState) + {/**/ + relayDrivState = GetRelayDriveState(pDevRelayIdBuf[1]); + if (RELAY_STATE_UP == relayDrivState) + {/*ȵ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_LIGHT);/*ñʾȵ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + } + else + { + /**/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + } + } + else + { + /**/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_RETURN_NORMAL);/*ñʾƳ̬*/ + } + + + } + else if (INDICATOR_TYPE_AUTORTN_ADHESION == devType) + { + /*۷ťճ״ָ̬ʾ*/ + chNonReturnAdhesionState = CheckNonReturnExistAdhesion(chBjdDeviceId); + if (RTN_RELAY_ADHESION_YES == chNonReturnAdhesionState) + { + SetVirCIIndicatorState(virCIid, devId, INDICATOR_SHOW_YES);/*ñʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid, devId, INDICATOR_SHOW_NO);/*ñʾЧ*/ + } + + + } + else if (INDICATOR_TYPE_COMM_LEU == devType) + {/*LEUͨ״̬*/ + + + + leuNum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_LEU); + for (kk =0u;kk= devType)) + {/*devType-INDICATOR_TYPE_COMM_CI_FIRST+1ͨ״̬*/ + + devRelaySum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_CI); + jj = devType - INDICATOR_TYPE_COMM_CI_FIRST; + if (devRelaySum > jj) + { + commState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_CI,(UINT8)jj); + if (TRANSMIT_2OO2_STATE_GOOD == commState) + {/*ϵjj+1 ͨ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_GREEN);/*ָʾͨ*/ + } + else if (TRANSMIT_2OO2_STATE_LINK == commState) + {/*jj+1 ͨһ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_YELLOW);/*ָʾͨһ*/ + } + else + {/*jj+1 ͨŹ*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_RED);/*ָʾͨж*/ + } + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_COMM_RED);/*ָʾͨж*/ + } + } + else if (INDICATOR_TYPE_STATUS_START_FLOCK == devType) + {/* ȫվ */ + startFLockFlag = GetStartFLockFlag(); + if (CI_START_FLOCK_YES == startFLockFlag) + { + /* ʾȫվ״̬ */ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_FLOCAK_YES);/*ȫվʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_FLOCAK_NO);/*ȫվʾЧ*/ + } + } + else if (INDICATOR_TYPE_YINDAOZONGSUO == devType) + {/* ״̬*/ + virCIAllSwitchYLockState = GetVirCIAllSwitchYLockState(virCIid); + if (SWITCH_LOCK_YINZONG_YES == virCIAllSwitchYLockState) + { + /* ʾ״̬*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES);/*Ч*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO);/*Ч*/ + } + + } + else if (INDICATOR_TYPE_STATUS_START_LOCK == devType) + { + /* ϵ״̬ */ + startLockFlag = GetStartLockFlag(); + if (CI_START_LOCK_NO == startLockFlag) + { + /* ʾȫվ״̬ */ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_STARTLOCK_YES);/*ϵʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_STARTLOCK_NO); + } + } + else if ((INDICATOR_TYPE_COMM_PSD_START <= devType) && (devType <= INDICATOR_TYPE_COMM_PSD_FIFTH)) + { + /* PSD ͨ״̬ */ + avalibleFlag = GetVirCIIndicConfDataAvalFlag(virCIid,devId); + if (INDICATOR_DATA_VALID != avalibleFlag) + { + /* Ч״̬ */ + SetPSDCommonState_UseVirCI(virCIid,devId,devType); + } + } + else if (INDICATOR_TYPE_STATUS_DISPLAY_LINSHIXIANSU == devType) + { + if(HAVE_DIANSHILINSHIXIANSU == dianshiLinshixiansuFlag) + { + /* ˹ȡʱٰťʾ */ + VirCILabourCancelLinShiXianSta = GetVirCILabourCancelLSXianSta(virCIid); + if (LINSHIXIANSU_COMM_BAD_STATE == VirCILabourCancelLinShiXianSta) + { + /* ʾ˹ȡʱٰť */ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_LIMIT_YES); + } + else + { /* ʾ˹ȡʱٰť */ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_LIMIT_NO); + } + } + else + { + /* ʾ˹ȡʱٰť */ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_CI_LIMIT_NO); + } + + } + else if (INDICATOR_TYPE_STATUS_CI_MODE == devType) + { /*ģʽָʾ*/ + SetCiModeIndicatorState_Vir(virCIid,devId); + + } + else if ((INDICATOR_TYPE_PCB1 == devType) ||(INDICATOR_TYPE_PCB2 == devType) || + (INDICATOR_TYPE_PCB3 == devType) ||(INDICATOR_TYPE_PCB4 == devType) || + (INDICATOR_TYPE_PCB5 == devType) ||(INDICATOR_TYPE_PCB6 == devType)) + {/*PCBť״ָ̬ʾ*/ + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + + if ((0u != devRelaySum) && (NULL != pDevRelayIdBuf)) + {/*豸Ч*/ + psdButtonState = GetPsdButtonState(pDevRelayIdBuf[0]); + psdVirtualAttribute = GetPsdVirtualAttribute(pDevRelayIdBuf[0]); + if ((PSD_BUTTON_STATE_DOWN == psdButtonState) && + (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)) + { /*PSDPCB*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ðť״̬ʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else if ((INDICATOR_TYPE_PSD1_ISOLATE == devType) ||(INDICATOR_TYPE_PSD2_ISOLATE == devType) || + (INDICATOR_TYPE_PSD3_ISOLATE == devType) ||(INDICATOR_TYPE_PSD4_ISOLATE == devType) || + (INDICATOR_TYPE_PSD5_ISOLATE == devType) ||(INDICATOR_TYPE_PSD6_ISOLATE == devType)) + {/*PSDϸ״ָ̬ʾ*/ + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + + if ((0u != devRelaySum) && (NULL != pDevRelayIdBuf)) + {/*豸Ч*/ + psdIsolateState = GetPsdIsolateState(pDevRelayIdBuf[0]); + psdVirtualAttribute = GetPsdVirtualAttribute(pDevRelayIdBuf[0]); + if ((PSD_FAULT_ISOLATION_SCX == psdIsolateState) && (PSD_VIRTUAL_ATTR_YES == psdVirtualAttribute)) + { /*PSDĹϸϢЧ*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ðť״̬ʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else if (INDICATOR_TYPE_AUTORTN_BTN == devType) + {/*Գ۷ť״ָ̬ʾ*/ + if(INDICATOR_DATA_RELAY ==avalibleFlag) + { + virtualZDZFButtonState = GetVirtualZDZFButtonState(); + if (VIRTUAL_ZDZFAJ_BUTTON_YES == virtualZDZFButtonState) + {/*ť*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ðť״̬ʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ðť״̬ʾЧ*/ + } + + } + else if (INDICATOR_TYPE_ALL_SIG_BRIGHT == devType) + {/*ȫվ״ָ̬ʾ*/ + allSignalBrightState = GetVirCIAllSignalBrightState(virCIid); + if (CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightState) + {/*ȫվ״̬Ч*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ȫվƱʾЧ*/ + } + else + {/*ȫվ״̬Ч*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ȫվƱʾЧ*/ + } + } + else if (INDICATOR_TYPE_AUTO_TRIGGE == devType) + { /*Զ־*/ + autoTriggerFlag = CheckAutoTriggerIndicatFlag(virCIid); + if (CI_SUCCESS == autoTriggerFlag) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ԶʾЧ*/ + } + else + {/*ȫվ״̬Ч*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ԶʾЧ*/ + } + } + else if ((INDICATOR_TYPE_XICHEJI_ALLOW_STATE == devType) + || (INDICATOR_TYPE_DOWNWASH_ALLOW_PASS_STATE == devType)) + {/* FAO·ͬϴ״ָ̬ʾ||ģʽϴָͬʾ||ģʽϴָͬͨʾ */ + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID bufӦ̵ͨͬXTJ*/ + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + } + else if (INDICATOR_TYPE_GENERAL_RESET_VALID == devType) + { + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID bufӦܸλ̵ZFWJ*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + } + else if (INDICATOR_TYPE_ATS_CONFIRM_RELAY_INTERFACE == devType) + {/*̵ӿȷ״ָ̬ʾ*/ + if(INDICATOR_DATA_RELAY ==avalibleFlag) + { + relayConfirmFlag = GetCiCiRelayInterfConfirmFlag(); + if (CICI_RELAY_INTERFACE_CONFIRM_YES == relayConfirmFlag) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + + } + else if(INDICATOR_TYPE_RELAY_HUNXIAN == devType) + { + /*ȡ߱־*/ + if(INDICATOR_DATA_RELAY ==avalibleFlag) + { + relaySum = GetRelayCurSum(); + for(jj = 0u; jj < relaySum;jj++) + { + RelayId = GetRelayId(jj); + relayBelongCi = GetRelayBelongCiId(RelayId); + if(relayBelongCi == localCiId) + { + relayHunXianState = GetRelayHunXianState(RelayId); + if(RELAY_HUNXIAN_STATE_YES == relayHunXianState) + { + break; + } + } + } + if(RELAY_HUNXIAN_STATE_YES == relayHunXianState) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + /*ÿ־״̬*/ + SetVirCIZfwHunxianFlag(virCIid,ZFWJ_HUN_XIAN_NO); + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + } + /*ȡת޻ָʾ*/ + else if(INDICATOR_TYPE_SWITCH_BLOCK_LINK == devType) + { + /*ȡȡ״̬*/ + switchBlockLinkState = GetCancelOrRcvrBlockLinkSta(); + if(CANCEL_SWITCH_BLOCK_LINK == switchBlockLinkState) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ָʾЧʱԺɫӦȡ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ָʾЧʱɫɫ*/ + } + } + else if ((INDICATOR_TYPE_UPS_DCGD == devType) || + (INDICATOR_TYPE_UPS_DCDY == devType)) + { /*UPSع || UPSصѹ*/ + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if ((0U == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*úƱ*/ + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*̵*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ú*/ + } + + } + + } + else if (INDICATOR_TYPE_COMM_AXIS == devType) + { + /*ϵͳͨ״̬*/ + cCommAxisNum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_AXIS); + for (mm = 0U; mm < cCommAxisNum; mm++) + { + commStatus = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_AXIS, mm); + + if ((TRANSMIT_2OO2_STATE_LINK == commStatus) || (TRANSMIT_2OO2_STATE_GOOD == commStatus)) + { + SetIndicatorState(devId, INDICATOR_SHOW_COMM_GREEN); /*ָʾͨ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_COMM_RED); /*ͨŹϣָʾͨŹ*/ + break; /*һϣΪͨŹϣڴ˴ѭ*/ + } + } + } + else + { + /**/ + } + } + + /*****ƽ̨12ϵָʾ*****/ + +#ifdef PLATFORM_2OO2 + + if ((sysFirstId > 0U) && (sysSecondId > 0U)) + { + computerId = Get2oo2ComputerId(); /*ȡƽ̨ID*/ + runMode = Get2oo2ProcessMode(); /*ȡƽ̨ģʽ*/ + runMode |= Get2oo2OhterProcessMode(); + if ((computerId > 0U) && (runMode > 0U)) + { + selfState = ((runMode) & ((UINT8)0xF0)) >> 4; + otherState = (runMode) & ((UINT8)0x0F); + + if(1U == computerId)/*1ϵ*/ + { + if(0x0aU == selfState) + { + SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_MAIN); /*ָʾ1ϵΪ*/ + } + else if (0x05U == selfState) + { + SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_BACKUP); /*ָʾ1ϵΪ*/ + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ1ϵ*/ + } + + if(0x0aU == otherState) + { + SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_MAIN); /*ָʾ2ϵΪ*/ + } + else if (0x05U == otherState) + { + SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_BACKUP); /*ָʾ2ϵΪ*/ + } + else + { + SetVirCIIndicatorState(virCIid,(UINT8)sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ2ϵ*/ + } + } + else if(2U == computerId) + { + if(0x0aU == selfState) + { + SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_MAIN); /*ָʾ2ϵΪ*/ + } + else if (0x05U == selfState) + { + SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_BACKUP); /*ָʾ2ϵΪ*/ + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ2ϵ*/ + } + + if(0x0aU == otherState) + { + SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_MAIN); /*ָʾ1ϵΪ*/ + } + else if (0x05U == otherState) + { + SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_BACKUP); /*ָʾ1ϵΪ*/ + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ1ϵ*/ + } + } + else + {/**/ + } + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)sysFirstId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ1ϵ*/ + SetVirCIIndicatorState(virCIid, (UINT8)sysSecondId, INDICATOR_SHOW_2OO2_FAULT); /*ָʾ2ϵ*/ + } + } + +#endif + + + + SetVirCIIndicatorState(virCIid, (UINT8)apply_1_Id, INDICATOR_SHOW_NO); /*ʼԳָʾЧ*/ + SetVirCIIndicatorState(virCIid, (UINT8)allow_1_Id, INDICATOR_SHOW_NO); /*ʼͬԳָʾЧ*/ + SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_NO); /*ʼԳָʾЧ*/ + + SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_NO); /*ʼԳָʾЧ*/ + SetVirCIIndicatorState(virCIid, (UINT8)allow_2_Id, INDICATOR_SHOW_NO); /*ʼͬԳָʾЧ*/ + SetVirCIIndicatorState(virCIid, (UINT8)over_2_Id, INDICATOR_SHOW_NO); /*ʼԳָʾЧ*/ + + SetVirCIIndicatorState(virCIid, (UINT8)jkj_valid_Id, INDICATOR_SHOW_NO); /*ʼӦָʾЧ*/ + /* Ĭ״̬ΪָʾЧ*/ + localCiType = GetLocalCiType(); + if(CI_TYPE_CLD == localCiType) + { + if (0u < jkj_valid_Id) + { + jkjRelayValidFlag = GetCiJkjFlag(); /*JKJӦ̵̼Ч־*/ + /*Ӧ̵̼Ч״̬*/ + if (JKJ_REYLAY_VALID == jkjRelayValidFlag) + { + SetVirCIIndicatorState(virCIid, (UINT8)jkj_valid_Id, INDICATOR_SHOW_YES); /*ýӦָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)jkj_valid_Id, INDICATOR_SHOW_NO); /*ýӦָʾЧ*/ + } + } + + + /*ǽ·ָʾ*/ + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ߲ü̵ӿ*/ + if ((apply_1_Id > 0u) && (allow_1_Id > 0u) && (over_1_Id > 0u) && (applyRelay_1_Id > 0u) && (allowRelay_1_Id > 0u)) + { + applyRelayCollState = GetRelayCollState(applyRelay_1_Id); + allowRelayCollState = GetRelayCollState(allowRelay_1_Id); + if ((RELAY_STATE_DOWN == applyRelayCollState) && + (RELAY_STATE_DOWN == allowRelayCollState)) + { /*Գ̵&&Գ̵*/ + + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_1_Id); + if (0u 0u) + { + NonRouteState = GetNonRouteStateById((UINT8)nonRouteId); + if ((NONROUTE_STATE_OPEN == NonRouteState) || + (NONROUTE_STATE_LOCKERR == NonRouteState) || + (NONROUTE_STATE_FAULTDELAY_UNLOCK == NonRouteState) || + (NONROUTE_STATE_DELAY_UNLOCK == NonRouteState)) + { /*ǽ·ʱ||ǽ·||ǽ·||ǽ·ʱ*/ + NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId); + if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode) + {/*źģʽ*/ + + SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_YES); /*ýԳָʾЧ*/ + } + else + {/*Գģʽ*/ + + SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + + } + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)over_1_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + } + + + if ((apply_2_Id > 0u) && (allow_2_Id > 0u) && (over_2_Id > 0u) && (applyRelay_2_Id > 0u) && (allowRelay_2_Id > 0u)) + { + applyRelayCollState = GetRelayCollState(applyRelay_2_Id); + allowRelayCollState = GetRelayCollState(allowRelay_2_Id); + if ((RELAY_STATE_DOWN == applyRelayCollState) && + (RELAY_STATE_DOWN == allowRelayCollState)) + { /*Գ̵&&Գ̵*/ + + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_2_Id); + if (0u < nonRouteId) + { + NonRouteState = GetNonRouteStateById((UINT8)nonRouteId); + if (NONROUTE_STATE_IDLE == NonRouteState) + { /*ǽ·*/ + + SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_SC_YES); /*ԳָʾЧ*/ + } + else if (NONROUTE_STATE_XUANPAI == NonRouteState) + { /*ǽ·ѡ*/ + NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId); + if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode ) + { /*źģʽ*/ + + SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_SC_YES); /*ԳָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + else + { + /*޲*/ + } + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)apply_2_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + relayCollState = GetRelayCollState(allowRelay_2_Id); + if (RELAY_STATE_UP == relayCollState) + { /*Գ̵*/ + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)allow_2_Id); + if (0u < nonRouteId) + { + NonRouteState = GetNonRouteStateById((UINT8)nonRouteId); + if ((NONROUTE_STATE_LOCK == NonRouteState) || + (NONROUTE_STATE_OPEN == NonRouteState)) + { /*ǽ·||ǽ·*/ + NonRouteCancelFlag = GetNonRouteCancelFlagById((UINT8)nonRouteId); + NonRouteHaveCancelFlag = GetNonRouteHaveCancelFlagById((UINT8)nonRouteId); + if ((NONROUTE_CANCEL_FLAG_YES == NonRouteCancelFlag) || + (NONROUTE_CANCEL_FLAG_YES == NonRouteHaveCancelFlag)) + { + SetVirCIIndicatorState(virCIid, (UINT8)allow_2_Id, INDICATOR_SHOW_SC_NO); /*ͬԳָʾЧ*/ + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)allow_2_Id, INDICATOR_SHOW_SC_YES); /*ͬԳָʾЧ*/ + } + } + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)allow_2_Id, INDICATOR_SHOW_SC_NO); /*ͬԳָʾЧ*/ + } + } + + relayCollState = GetRelayCollState(applyRelay_2_Id); + if (RELAY_STATE_UP == relayCollState) + { /*Գ̵*/ + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_2_Id); + if (0u < nonRouteId) + { + NonRouteState = GetNonRouteStateById((UINT8)nonRouteId); + if ((NONROUTE_STATE_OPEN == NonRouteState) || + (NONROUTE_STATE_LOCKERR == NonRouteState) || + (NONROUTE_STATE_FAULTDELAY_UNLOCK == NonRouteState) || + (NONROUTE_STATE_DELAY_UNLOCK == NonRouteState)) + { /*ǽ·ʱ||ǽ·||ǽ·||ǽ·ʱ*/ + NonRouteRunMode = GetNonRouteRunModeById((UINT8)nonRouteId); + if (NONROUTE_RUN_MODE_APPLY == NonRouteRunMode) + {/*źģʽ*/ + + SetVirCIIndicatorState(virCIid, (UINT8)over_2_Id, INDICATOR_SHOW_SC_YES); /*ýԳָʾЧ*/ + } + else + {/*Գģʽ*/ + + SetVirCIIndicatorState(virCIid, (UINT8)over_2_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + + } + } + else + { + SetVirCIIndicatorState(virCIid, (UINT8)over_2_Id, INDICATOR_SHOW_SC_NO); /*ԳָʾЧ*/ + } + } + } + } + else + {/*Գ߲ͨŽӿ*/ + CommTrainTestCLDSQJStatus = GetCommTrainTestCLDSQJStatus(); + CommTrainTestCLDTYSJStatus = GetCommTrainTestCLDTYSJStatus(); + if ((COMM_TRAIN_TEST_DEV_STATE_VALID == CommTrainTestCLDSQJStatus) && + (COMM_TRAIN_TEST_DEV_STATE_INVALID == CommTrainTestCLDTYSJStatus)) + { /*Գ״̬Ч&&Գ״̬Ч*/ + nonRouteId = GetNonRouteIdByIndictId_Vir(virCIid, (UINT8)apply_1_Id); + if (0u NonRouteId) + { + nonRouteBelongCiId = GetnonRouteIdbelongCIid(pNonRoute->NonRouteId); + /*ҵǽ·*/ + if (nonRouteBelongCiId == localCiId) + { + if (NONROUTE_STATE_OPEN == pNonRoute->NonRouteState) + { /*ǽ·*/ + + if ((NONROUTE_RUN_MODE_APPLY == pNonRoute->RunMode) && (SCX_CLD_INTERFACE_RELAY == interfaceType)) + { /*źģʽԳ복βü̵ӿ*/ + agreeTryTrainRelayId = GetNonRouteAgreeTryRelayIdById(pNonRoute->NonRouteId); + (void)SetRelayDriveState(agreeTryTrainRelayId, RELAY_DRIVE_STATE_UP); /*ͬԳ̵*/ + } + else if ((NONROUTE_RUN_MODE_APPLY == pNonRoute->RunMode) && (SCX_CLD_INTERFACE_COMM == interfaceType)) + {/*źģʽԳ복βͨŽӿ*/ + SetCommTrainTestCLDTYSJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID);/*TYSJ״̬Ч*/ + } + else if ((NONROUTE_RUN_MODE_APPLY == pNonRoute->RunMode) && (SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*źģʽԳ복βôڽӿ*/ + SetCommTrainTestCLDTYSJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID);/*TYSJ״̬Ч*/ + } + else + { + /**/ + } + } + else + {/*ηǽ·ǿ״̬ʱԳ߲ͬԳ̵ӿڣͬԳ̵£ںڣͬԳЧ״̬*/ + + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*̵ӿ*/ + /*ǽ·ͬԳ̵ ǽ·ͬԳ̵̬£൱ڻָĬ̬*/ + agreeTryTrainRelayId = GetNonRouteAgreeTryRelayIdById(pNonRoute->NonRouteId); + (void)SetRelayDriveState(agreeTryTrainRelayId, RELAY_DRIVE_STATE_DOWN); + } + else if ((SCX_CLD_INTERFACE_COMM == interfaceType) || (SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + { + SetCommTrainTestCLDTYSJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID);/*TYSJ״̬Ч*/ + } + else + { + ; /**/ + } + } + + break; + } + } + + } + } + + #if 0 + if ((NONROUTE_STATE_LOCK == GetNonRouteState()) || + (NONROUTE_STATE_OPEN == GetNonRouteState())) + { /*ǽ·||ǽ·*/ + + if ((NONROUTE_RUN_MODE_APPLY == GetNonRouteRunMode()) && (SCX_CLD_INTERFACE_RELAY == interfaceType)) + { /*źģʽԳ복βü̵ӿ*/ + + (void)SetRelayDriveState(GetNonRouteAgreeTryTrainRelayId(), RELAY_STATE_UP); /*ͬԳ̵*/ + } + else if ((NONROUTE_RUN_MODE_APPLY == GetNonRouteRunMode()) && (SCX_CLD_INTERFACE_COMM == interfaceType)) + {/*źģʽԳ복βͨŽӿ*/ + SetCommTrainTestCLDTYSJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID);/*TYSJ״̬Ч*/ + } + else + { + /**/ + } + } + else + { + /**/ + } + #endif +} + +/* +* ʱݴ +* ˵ void +* ֵ +*/ +void TimeDataFeedBackProcess(void) +{ + UINT16 deviceId = 0u; /*豸ID*/ + UINT16 deviceSum = 0u; /*豸*/ + UINT16 ii = 0u; /*α*/ + UINT8 localCiId = 0u; + UINT8 chComCycNumForCiToXianDi = 0U;/*ͨڼ¼*/ + UINT8 wFloodGateBelongCiId = 0U; /*ID*/ + + localCiId = GetSystemParaLocalCiId(); + chComCycNumForCiToXianDi = GetComCycNumForCiToOtherSys(LastCmdSourceSysType); + if (0U == chComCycNumForCiToXianDi) + { + /*˽źڷһιϵʱ*/ + deviceSum = GetRouteCurSum();/*·*/ + for (ii = 0u; ii < deviceSum; ii++) + { + deviceId = GetRouteId(ii);/*·ID*/ + if (localCiId == GetRouteBelongCiId(deviceId)) + {/*ִн·ؼʱݼ*/ + RouteTimeDataBackProcess(deviceId); + } + } + /*εʱ*/ + deviceSum = GetTotalPhySecCurNum();/**/ + for (ii = 0u; ii < deviceSum; ii++) + { + deviceId = GetPhySecId(ii);/*ID*/ + /*ʽʱ*/ + PhySecTimeDataBackProcess(deviceId); + } + /*ʱ*/ + deviceSum = GetOverlapCurSum(); + for (ii = 0u; ii < deviceSum; ii++) + { + deviceId = GetOverlapId(ii); + OverlapTimeDataBackProcess(deviceId); + } + + /*ܸλ̵ʱ*/ + ZFWJTimeDataBackProcess(); + + for (ii = 0u; ii < NONROUTE_ID_NUM_MAX; ii++) + { + NonRouteDataStruct* pNonRoute = GetNonRouteDataPtr() + ii; + /*ǽ·ȡʱ*/ + NonRouteTimeDataBackProcess(pNonRoute); + } + + /*ʱرյʱ*/ + deviceSum = GetFloodGateCurSum(); + for (ii = 0u; ii < deviceSum; ii++) + { + deviceId = GetFloodGateId(ii); + wFloodGateBelongCiId = GetFloodGateBelongCiId(deviceId); + if (localCiId == wFloodGateBelongCiId) + { + FloodGateTimeDataBackProcess(deviceId); + } + } + } + else + {/*ATSִֵд˼*/ + /*ִУÿһںŷʱ*/ + ; + } +} + +/* +* PSDͨ״ָ̬ʾ״̬ +* ˵ UINT16 indicatorId ָʾID +* UINT8 devType ָʾ +* ֵ +*/ +void SetPSDCommonState(UINT16 indicatorId ,UINT8 devType) +{ + UINT8 devRelaySum = 0u; + UINT8 index = 0u; + + devRelaySum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_PLATFORM); /*ȡCIͨŵվ̨PSDϵͳ*/ + index = devType - INDICATOR_TYPE_COMM_PSD_START; /*ȡָʾָͬʾеλƫ*/ + if (devRelaySum > index) + { + if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PLATFORM,(UINT8)index)) + {/*ϵjj+1վ̨PSDϵͳ ͨ*/ + + SetIndicatorState(indicatorId, INDICATOR_SHOW_COMM_GREEN); /*ָʾͨ*/ + } + else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PLATFORM,(UINT8)index)) + {/*jj+1վ̨PSDϵͳ ͨһ*/ + + SetIndicatorState(indicatorId, INDICATOR_SHOW_COMM_YELLOW); /*ָʾͨһ*/ + } + else + {/*jj+1վ̨PSDϵͳ ͨŹ*/ + + SetIndicatorState(indicatorId, INDICATOR_SHOW_COMM_RED); /*ָʾͨж*/ + } + } + else + { + SetIndicatorState(indicatorId, INDICATOR_SHOW_COMM_RED); /*ָʾͨж*/ + } +} +/* +* PSDͨ״ָ̬ʾ״̬ +* ˵ UINT16 indicatorId ָʾID +* UINT8 devType ָʾ +* ֵ +*/ +void SetPSDCommonState_UseVirCI(UINT8 virCIid,UINT8 indicatorId ,UINT8 devType) +{ + UINT8 devRelaySum = 0u; + UINT8 index = 0u; + + devRelaySum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_PLATFORM); /*ȡCIͨŵվ̨PSDϵͳ*/ + index = devType - INDICATOR_TYPE_COMM_PSD_START; /*ȡָʾָͬʾеλƫ*/ + if (devRelaySum > index) + { + if (TRANSMIT_2OO2_STATE_GOOD == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PLATFORM,(UINT8)index)) + {/*ϵjj+1վ̨PSDϵͳ ͨ*/ + + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_COMM_GREEN); /*ָʾͨ*/ + } + else if (TRANSMIT_2OO2_STATE_LINK == Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PLATFORM,(UINT8)index)) + {/*jj+1վ̨PSDϵͳ ͨһ*/ + + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_COMM_YELLOW); /*ָʾͨһ*/ + } + else + {/*jj+1վ̨PSDϵͳ ͨŹ*/ + + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_COMM_RED); /*ָʾͨж*/ + } + } + else + { + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_COMM_RED); /*ָʾͨж*/ + } +} + +/* +* ղ״ָ̬ʾƹμ +* ˵ UINT16 phySecId ID +* +* ֵ CI_SUCCESS ɹ +CI_ERROR ʧ +*/ +UINT8 ZhaoChaIndictorRelPhySecCheck(UINT16 phySecId) +{ + + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT8 thatZhaoChaPhySecSum = 0u; + UINT16 routeId = 0u; + UINT16 * phySecIdBuf = NULL; + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 funRetVal = 0u; + UINT8 retVal = CI_SUCCESS; + + + + for(ii = 0u ;ii < GetRouteCurSum();ii++) + {/*н·*/ + routeId = GetRouteId(ii); + if(GetRouteBelongCiId(routeId) == GetSystemParaLocalCiId()) + {/*˽·ڱ*/ + thatZhaoChaPhySecSum = GetRouteThatZhaoChaPhySecSum(routeId); /*ȡ·ղĿ*/ + phySecIdBuf = GetRouteThatZhaoChaPhySecIdBuf(routeId); /*ȡ·ղID*/ + + if(0u != thatZhaoChaPhySecSum) + {/*˽·ղ*/ + for(jj = 0u ;jj < thatZhaoChaPhySecSum;jj++) + {/*еղ*/ + + if(phySecIdBuf[jj] == phySecId) + {/*ҵһղε·:αղĽ·*/ + break; + } + } + if(jj < thatZhaoChaPhySecSum) + { + funRetVal = RoutePhySecZhaoChaCheck(routeId,phySecId,&devId,&devState);/*ղ߼*/ + if(CI_ERROR == funRetVal) + {/*ղεһ·(),ѯ·*/ + retVal = CI_ERROR; + + break; + } + } + } + + + } + + + } + + return retVal; + +} + + +/* +* ղ״ָ̬ʾ״̬ +* ˵ UINT16 indicatorId ָʾID +* +* ֵ +*/ +void SetZhaoChaIndictorCommonState(UINT16 indicatorId) +{ + UINT8 devRelaySum = 0u; + UINT16 * devRelayIdBuf = NULL; + UINT8 jj = 0u; + if (GetIndicatorAvalibleFlag(indicatorId) == INDICATOR_DATA_VALID) + {/*ղЧ*/ + + SetIndicatorState(indicatorId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else if (GetIndicatorAvalibleFlag(indicatorId) == INDICATOR_DATA_PHYSEC) + {/*ղָʾЧ*/ + + /*ʼ*/ + SetIndicatorState(indicatorId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + + devRelaySum = GetIndicatorRelaySum(indicatorId); /*ȡղ*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(indicatorId); /*ȡղID*/ + + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + for (jj = 0u; jj < devRelaySum; jj++) + { + if(CI_ERROR == ZhaoChaIndictorRelPhySecCheck(devRelayIdBuf[jj])) + { + SetIndicatorState(indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + break; + } + } + + } + + } + else if(GetIndicatorAvalibleFlag(indicatorId) == INDICATOR_DATA_RELAY) + { + SetIndicatorState(indicatorId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + devRelaySum = GetIndicatorRelaySum(indicatorId); /*ȡղ̵*/ + devRelayIdBuf = GetIndicatorRelayIdBuf(indicatorId); /*ȡղ̵ID*/ + if ((0u == devRelaySum) || (NULL == devRelayIdBuf)) + { + SetIndicatorState(indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + for (jj = 0u; jj < devRelaySum; jj++) + { + if(RELAY_STATE_DOWN == GetRelayCollState(devRelayIdBuf[jj])) + { + SetIndicatorState(indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + break; + } + } + } + } + else + { + SetIndicatorState(indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } +} + +/* +* ղ״ָ̬ʾ״̬ +* ˵ UINT16 indicatorId ָʾID +* +* ֵ +*/ +void SetZhaoChaIndictorComSta_Vir(UINT8 virCIid,UINT8 indicatorId) +{ + UINT8 devRelaySum = 0u; + UINT16 * pDevRelayIdBuf = NULL; + UINT8 jj = 0u; + UINT8 avalibleFlag = 0u; + UINT8 zhaoChaCheck = CI_ERROR; + avalibleFlag = GetVirCIIndicConfDataAvalFlag(virCIid,indicatorId); + if (INDICATOR_DATA_VALID == avalibleFlag) + {/*ղЧ*/ + + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + } + else if (INDICATOR_DATA_PHYSEC == avalibleFlag) + {/*ղָʾЧ*/ + + /*ʼ*/ + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,indicatorId); /*ȡղ*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,indicatorId); /*ȡղID*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + for (jj = 0u; jj < devRelaySum; jj++) + { + zhaoChaCheck = ZhaoChaIndictorRelPhySecCheck(pDevRelayIdBuf[jj]); + if(CI_ERROR == zhaoChaCheck) + { + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + break; + } + } + + } + + } + else if(INDICATOR_DATA_RELAY == avalibleFlag) + { + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_NO); /*ָʾЧ*/ + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,indicatorId); /*ȡղ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,indicatorId); /*ȡղ̵ID*/ + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } + else + { + for (jj = 0u; jj < devRelaySum; jj++) + { + if(RELAY_STATE_DOWN == GetRelayCollState(pDevRelayIdBuf[jj])) + { + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + break; + } + } + } + } + else + { + SetVirCIIndicatorState(virCIid,indicatorId, INDICATOR_SHOW_YES); /*ָʾЧ*/ + } +} + + + +/* +* վģʽָʾ +* ˵ void +* ֵ void +*/ +void SetCiModeIndicatorState(UINT16 indicatorId) +{ + UINT8 ciModeFlag = GetCiModeFlag(); + + switch (ciModeFlag) + { + case CI_MODE_CONSTRA_LOCAL: /* ǿվ */ + SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_CONSTRA_LOCAL); + break; + case CI_MODE_CI_LOCAL: /* ģʽ */ + SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_CI_LOCAL); + break; + case CI_MODE_ATS: /* ң */ + SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_ATS); + break; + case CI_MODE_CONSOLE: /* Ԫ̨ */ + SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_CONSOLE); + break; + case CI_MODE_APPLAY_LOCAL: /* վ */ + SetIndicatorState(indicatorId,INDICATOR_SHOW_CI_MODE_APPLAY_LOCAL); + break; + default: + /*ɴ֧*/ + break; + } +} +/* +* վģʽָʾ +* ˵ void +* ֵ void +*/ +void SetCiModeIndicatorState_Vir(UINT8 virCIid,UINT8 indicatorId) +{ + UINT8 ciModeFlag = GetVirCImode(virCIid); + + switch (ciModeFlag) + { + case CI_MODE_CONSTRA_LOCAL: /* ǿվ */ + SetVirCIIndicatorState(virCIid, indicatorId,INDICATOR_SHOW_CI_MODE_CONSTRA_LOCAL); + break; + case CI_MODE_CI_LOCAL: /* ģʽ */ + SetVirCIIndicatorState(virCIid, indicatorId,INDICATOR_SHOW_CI_MODE_CI_LOCAL); + break; + case CI_MODE_ATS: /* ң */ + SetVirCIIndicatorState(virCIid,indicatorId,INDICATOR_SHOW_CI_MODE_ATS); + break; + case CI_MODE_CONSOLE: /* Ԫ̨ */ + SetVirCIIndicatorState(virCIid,indicatorId,INDICATOR_SHOW_CI_MODE_CONSOLE); + break; + case CI_MODE_APPLAY_LOCAL: /* վ */ + SetVirCIIndicatorState(virCIid,indicatorId,INDICATOR_SHOW_CI_MODE_APPLAY_LOCAL); + break; + default: + /*ɴ֧*/ + break; + } +} + + +/* +* ԳԳ״̵̬ +* ˵ void +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 TrainTestStatusToDevStateProc(void) +{ + UINT8 ret = CI_SUCCESS; + UINT8 ciType = GetLocalCiType(); + UINT8 trainTestStatus = GetCiTrainTestStatus(); + UINT8 interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*ȡԳ복νӿڷʽ*/ + UINT16 wDrvApplyTryTrainRelayId = 0U;/*ԳԳ̵ID*/ + UINT8 ii=0U; + + for (;iiNonRouteId); + if ((CI_TRAIN_TEST_START == trainTestStatus) || (CI_TRAIN_TEST_ON == trainTestStatus)) + { + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿʱ̵*/ + /* Գ̵ */ + (void)SetRelayDriveState(wDrvApplyTryTrainRelayId,RELAY_STATE_UP); + } + else if ((SCX_CLD_INTERFACE_COMM == interfaceType)||(SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*Գ복βͨŽӿ*/ + SetCommTrainTestSCXSQAJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID);/*SQAJЧӦڼ̵ӿڵSQAJ*/ + } + else + { + /*ڵĽӿڷʽ*/ + } + } + else + { + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿʱ̵*/ + /* Գ״̬Գ̵ */ + (void)SetRelayDriveState(wDrvApplyTryTrainRelayId,RELAY_STATE_DOWN); + } + else if ((SCX_CLD_INTERFACE_COMM == interfaceType)||(SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*Գ복βͨŽӿ*/ + SetCommTrainTestSCXSQAJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID);/*SQAJЧӦڼ̵ӿڵSQAJ*/ + } + else + { + /*ڵĽӿڷʽ*/ + } + } + } + else + { + ret = CI_SUCCESS; + } + } + } + + return ret; +} + + +/* +* ղ̵״̬ +* ˵ void +* ֵ void +*/ +void VirtualRelayStateProc(void) +{ + UINT16 relaySum = 0u; + UINT16 relayIndx = 0u; + UINT16 bufIndx = 0u; + UINT16 relayId = 0u; + UINT8 relayVirtAttr = 0u; + UINT8 relayDrivStat = 0u; + UINT8 chLocalCi = GetSystemParaLocalCiId(); + UINT8 chRelayBelongCi = 0U; + relaySum = GetTotalRelayCurNum(); + + for (relayIndx = 0u; relayIndx < relaySum; relayIndx++) + { + relayId = GetRelayId(relayIndx); + chRelayBelongCi = GetRelayBelongCiId(relayId); + if (chLocalCi == chRelayBelongCi) + { + relayVirtAttr = GetRelayVirtAttr(relayId); + + if(RELAY_VIRTUAL_ATTR_YES == relayVirtAttr) + { + relayDrivStat = GetRelayDriveState(relayId); + bufIndx = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if(RELAY_DRIVE_STATE_UP == relayDrivStat) + { + RelayDataStru[bufIndx].RelayCollState = RELAY_STATE_UP; + } + else if(RELAY_DRIVE_STATE_DOWN == relayDrivStat) + { + RelayDataStru[bufIndx].RelayCollState = RELAY_STATE_DOWN; + } + else + { + RelayDataStru[bufIndx].RelayCollState = RELAY_STATE_DOWN; + } + } + } + } + + return; +} + +/* +* ۷ָʾƵƺȵ״̵̬״̬ +* ˵ +* ֵ +*/ +static void AutoRtnIndictStaToDevStateProc(void) +{ + UINT16 DeviceId = 0u; /*豸ID*/ + UINT16 jj = 0u; /*α*/ + UINT8 indicatorContainRelaySum = 0u;/*ʾư̵Ŀ*/ + UINT16* indicatorContainRelayIdBuf = NULL;/*ʾư̵ID*/ + UINT8 relayVirtAttr = 0u; + UINT8 belongCiId = 0u; + UINT8 localCiId = 0u; + UINT8 zDZFDevType =0u; + UINT8 indicatorType =0u; + UINT8 flashState =0u; + UINT8 steadyState =0u; + UINT16 indictorCurNum = GetIndicatorCurSum(); + UINT8 indictorDevId = 0U; + + for (jj = 0u; jj < indictorCurNum; jj++ ) + { + DeviceId = GetIndicatorId(jj);/*ȡָʾID*/ + indicatorType = GetIndicatorType(DeviceId); + if (INDICATOR_TYPE_EXPRESS_RETURN == indicatorType) + {/*豸IDӦָʾΪ۷*/ + indicatorContainRelaySum = GetIndicatorRelaySum(DeviceId); + indicatorContainRelayIdBuf = GetIndicatorRelayIdBuf(DeviceId); + indictorDevId = GetIndicatorRelNonReturnId(DeviceId);/*ȡָʾ豸ID*/ + if ((3u != indicatorContainRelaySum)||(NULL == indicatorContainRelayIdBuf)) + {/*̵ݴ*/ + break; + } + + localCiId = GetSystemParaLocalCiId(); + belongCiId = GetVirtualZDZFBelongCiId(); + zDZFDevType = GetVirtualZDZFDevType(); + flashState = GetAutoRtnIndictFlashState((UINT16)indictorDevId);/*ȡָʾ״̬*/ + steadyState = GetAutoRtnIndictSteadyState((UINT16)indictorDevId);/*ȡָʾȵ״̬*/ + if ((belongCiId == localCiId) && (CI_DEVICE_TYPE_AUTORETURN == zDZFDevType)) + {/*۷ťΪ豸*/ + /*۷ťΪ豸̵ֱ״̬*/ + relayVirtAttr = GetRelayVirtAttr(indicatorContainRelayIdBuf[0]); + /*ٴȷ̵*/ + if(RELAY_VIRTUAL_ATTR_YES == relayVirtAttr) + { + if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == flashState) + {/*״̬Ч*/ + (void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*Ƽ̵*/ + SetRelayCollState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*Ƽ̵ɼ*/ + } + else + { + (void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*Ƽ̵*/ + SetRelayCollState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*Ƽ̵ɼ*/ + } + } + else + { + (void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*Ƽ̵*/ + } + + relayVirtAttr = GetRelayVirtAttr(indicatorContainRelayIdBuf[1]); + /*ٴȷ̵*/ + if(RELAY_VIRTUAL_ATTR_YES == relayVirtAttr) + { + if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == steadyState) + {/*ȵ״̬Ч*/ + (void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*ȵƼ̵*/ + SetRelayCollState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*ȵƼ̵ɼ*/ + } + else + { + (void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*ȵƼ̵*/ + SetRelayCollState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*ȵƼ̵ɼ*/ + } + } + else + { + (void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*ȵƼ̵*/ + } + } + else + {/*۷ʵ豸*/ + if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == flashState) + {/*״̬Ч*/ + (void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_UP);/*Ƽ̵*/ + } + else + { + (void)SetRelayDriveState(indicatorContainRelayIdBuf[0], RELAY_DRIVE_STATE_DOWN);/*Ƽ̵*/ + } + + if (VOBCTOCIAUTORTN_INDICT_MASK_VALID == steadyState) + {/*ȵ״̬Ч*/ + (void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_UP);/*ȵƼ̵*/ + } + else + { + (void)SetRelayDriveState(indicatorContainRelayIdBuf[1], RELAY_DRIVE_STATE_DOWN);/*ȵƼ̵*/ + } + } + } + } +} +/* +* ۷ָʾƵƺȵ״̵̬״̬ +* ˵ +* ֵ +*/ +static void AutoRtnIndictStatusProc_VirCI(void) +{ + UINT8 DeviceId = 0u; /*豸ID*/ + UINT8 jj = 0u; /*α*/ + UINT8 indicatorContainRelaySum = 0u;/*ʾư̵Ŀ*/ + UINT16* indicatorContainRelayIdBuf = NULL;/*ʾư̵ID*/ + UINT8 relayVirtAttr = 0u; + UINT8 belongCiId = 0u; + UINT8 localCiId = 0u; + UINT8 zDZFDevType =0u; + UINT8 indicatorType =0u; + UINT8 flashState =0u; + UINT8 steadyState =0u; + UINT8 chIndicatorCurSum = 0u; + UINT8 virNum = 0u; + UINT8 virCIid=0u; + UINT8 i= 0u; + UINT8 indictorDevId = 0U; + + virNum = GetVirtualCINum(); + for(i=0u;i 0u) + { + relayDriveState = GetRelayDriveState(relayId);/*ȡ̵״̬*/ + routeBelongCi = GetRouteBelongCiId(routeId); + commState = GetLocalCiAndOtherCiTransSta(routeBelongCi);/*ͨͨ״̬*/ + /*ڱ·ұڼ̵ӿڣ + ӪԱ·ȷϼ̵ӿ*/ + if ((localCi == phyBelongCi) && (routeBelongCi != localCi) && + (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)) + { + if (PHYSICAL_SECTION_LOCK_EXCEPT != lockState) + {/*δ*/ + if(RELAY_DRIVE_STATE_NULL== relayDriveState) + {/*δ*/ + execRes = SetRelayDriveState(relayId, RELAY_STATE_UP); + if (CI_ERROR == execRes) + { + /*¼*/ + } + } + } + else + {/*գ*/ + (void)SetRelayDriveState(relayId, RELAY_STATE_DOWN); + relayCollState = GetRelayCollState(relayId); + if (RELAY_STATE_DOWN != relayCollState) + { /*ղ̵δ*/ + + } + } + } + + } + } + } + } + + + } + } + } +} +/* +* ùܿжźŻ˿˿ +* ˵ UINT16 devId ָʾID +* ֵ void +*/ +void SignaDsBreakAlarmIndicator(UINT16 devId) +{ + UINT8 devRelaySum = 0u; /*豸̵*/ + UINT16* pDevRelayIdBuf = NULL; /*̵IDbuf*/ + UINT8 dSValidFlag = 0u; + UINT8 relayCollState = 0u; + + devRelaySum = GetIndicatorRelaySum(devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetIndicatorRelayIdBuf(devId); /*ȡؼ̵ID buf*/ + + if (NULL == pDevRelayIdBuf) + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + dSValidFlag = GetCiFunctionSwitchConfig(FUNC_SIGNAL_ALARM_DUANSI_FLAG); + /*ܿΪ0xAA-˿̵𱨾*/ + if(FUNC_SWITCH_ON == dSValidFlag) + { + if (RELAY_STATE_DOWN == relayCollState) + { /*̵²*/ + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ޱ*/ + + } + else + {/*̵*/ + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + } + } + else + { + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetIndicatorState(devId, INDICATOR_SHOW_NO); /*ޱ*/ + } + else + { + SetIndicatorState(devId, INDICATOR_SHOW_YES); /*ñ*/ + } + } + } +} +/* +* ùܿжźŻ˿˿ +* ˵ UINT16 devId ָʾID +* ֵ void +*/ +void SignaDsBreakAlarmIndicator_Vir(UINT8 virCIid ,UINT8 devId) +{ + UINT8 devRelaySum = 0u; /*豸̵*/ + UINT16* pDevRelayIdBuf = NULL; /*̵IDbuf*/ + UINT8 dSValidFlag = 0u; + UINT8 relayCollState = 0u; + + devRelaySum = GetVirCIIndicConfDataRelaySum(virCIid,devId); /*ȡؼ̵*/ + pDevRelayIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,devId); /*ȡؼ̵ID buf*/ + + if ((0u == devRelaySum) || (NULL == pDevRelayIdBuf)) + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ñ*/ + } + else + { + relayCollState = GetRelayCollState(pDevRelayIdBuf[0]); + dSValidFlag = GetCiFunctionSwitchConfig(FUNC_SIGNAL_ALARM_DUANSI_FLAG); + /*ܿΪ0xAA-˿̵𱨾*/ + if(FUNC_SWITCH_ON == dSValidFlag) + { + if (RELAY_STATE_DOWN == relayCollState) + { /*̵²*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ޱ*/ + + } + else + {/*̵*/ + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ñ*/ + } + } + else + { + if (RELAY_STATE_UP == relayCollState) + { /*̵*/ + + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_NO); /*ޱ*/ + } + else + { + SetVirCIIndicatorState(virCIid,devId, INDICATOR_SHOW_YES); /*ñ*/ + } + } + } +} + +/* +* +* ˵ void +* ֵ void +*/ +void CiToCiOutputCmdProc(void) +{ + UINT16 routeId = 0u; + UINT8 routeLevel = 0u; /*·ȼ*/ + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 routeBelongCiId = 0u; /*·ID*/ + UINT8 checkSum = 0u; + RouteOtherCheckStruct *pDataOtherCiDevBuf = NULL; + RouteOtherCheckStruct *pTmpOtherCiDevInfo = NULL; + UINT16 psdId = 0u; + UINT8 psdBelongCiId = 0u; + UINT16 ii = 0u; /*ѭ*/ + UINT16 iOtherCiIndex = 0u; /*ѭ*/ + UINT8 tmpPsdVobcCmd = 0U; + UINT16 wCurPhySecNum = 0U; /**/ + UINT16 wCurLogSecNum = 0U; /*߼*/ + UINT16 wSecId = 0U; + UINT16 wSecRLockBelongRoute = 0U; /*ν··*/ + UINT16 wSecPLockBelongRoute = 0U; /*η·*/ + UINT8 cCmdSendFlag = CI_ERROR; + UINT16 wOtherCiPLockRouteId = 0U; /*CI͵η·ID*/ + UINT16 wRouteLockedOverlapId = 0U; /*·չıID*/ + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + localCiId = GetSystemParaLocalCiId(); + + /*·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = GetRouteId(ii); + routeBelongCiId = GetRouteBelongCiId(routeId); + /*·ȼ*/ + routeLevel = GetRouteLevel(routeId); + + if (ROUTE_LEVEL_BLOC == routeLevel) + { + checkSum = GetRouteBlocOtherCiSum(routeId); + pDataOtherCiDevBuf = GetRouteBlocOtherCiBuf(routeId); + } + else if (ROUTE_LEVEL_CBTC == routeLevel) + { + checkSum = GetRouteCbtcOtherCiSum(routeId); + pDataOtherCiDevBuf = GetRouteCbtcOtherCiBuf(routeId); + } + else + { + checkSum = 0u; + pDataOtherCiDevBuf = NULL; + } + if ((0u != checkSum) && (NULL != pDataOtherCiDevBuf)) + { + /**/ + for (iOtherCiIndex = 0u;iOtherCiIndex < checkSum;iOtherCiIndex++) + { + if(ROUTE_OHTER_CHECK_SUM_MAX <= iOtherCiIndex) + { + break; + } + pTmpOtherCiDevInfo = &pDataOtherCiDevBuf[iOtherCiIndex]; + /*·IDΪ 豸Ϊ*/ + if ((CI_DEVICE_TYPE_PSD == pTmpOtherCiDevInfo->DevType) && + (routeBelongCiId != localCiId)) + { + psdId = pTmpOtherCiDevInfo->DevId;/*ID*/ + psdBelongCiId = GetPsdBelongCiId(psdId); + if (psdBelongCiId == localCiId) + { + tmpPsdVobcCmd = GetPsdVobcCmd(psdId);/*PSDVOBC*/ + + AddCiSendToCiCmdInfo(CI_CMD_PSD_VOBC_CMD_TO_CI,psdId,tmpPsdVobcCmd,routeBelongCiId); + } + + } + } + } + } + + /*Ҫ͵ķ·*/ + wCurPhySecNum = GetPhySecCurSum(); + for (ii = 0U; ii < wCurPhySecNum; ii++) + { + wSecId = GetPhySecId(ii); + cCmdSendFlag = GetPhySecPLockRouteCmdSendFlag(wSecId); /*жǷҪη·*/ + + if (CI_SUCCESS == cCmdSendFlag) + { + wSecPLockBelongRoute = GetPhySecPLockBelongRouteId(wSecId); /*ȡη·ID*/ + wSecRLockBelongRoute = GetPhySecRLockBelongRouteId(wSecId); + routeBelongCiId = GetRouteBelongCiId(wSecRLockBelongRoute); /*ȡν··CI*/ + AddCiSendToCiCmdInfo(CI_CMD_PHYSEC_PLOCK_ROUTE_CMD, wSecId, wSecPLockBelongRoute, routeBelongCiId); /*ӷ·ID*/ + + wOtherCiPLockRouteId = GetPhySecOtherCiPLockRouteId(wSecId); /*ȡCI͵η·ID*/ + if (0U != wSecPLockBelongRoute) + { + wRouteLockedOverlapId = GetRouteOverlapLockedId(wSecPLockBelongRoute); /*ȡ·չı*/ + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_LOCKED_OVERLAP, wSecPLockBelongRoute, wRouteLockedOverlapId, routeBelongCiId); /*ӽ·չı*/ + + if (0U != wOtherCiPLockRouteId) + { + /*Ŀη·뱾η·һ£Ŀ·չı*/ + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_LOCKED_OVERLAP, wOtherCiPLockRouteId, 0U, routeBelongCiId); + } + else + { + /**/ + } + } + else + { + /*޷·Ŀ·չı*/ + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_LOCKED_OVERLAP, wOtherCiPLockRouteId, 0U, routeBelongCiId); + } + } + else + { + /*㣬*/ + } + } + + /*߼Ҫ͵ķ·*/ + wCurLogSecNum = GetLogicSecCurSum(); + for (ii = 0U; ii < wCurLogSecNum; ii++) + { + wSecId = GetLogicSecId(ii); + cCmdSendFlag = GetLogSecPLockRouteCmdSendFlag(wSecId); /*жǷҪ߼η·*/ + + if (CI_SUCCESS == cCmdSendFlag) + { + wSecPLockBelongRoute = GetLogSecPLockRouteId(wSecId); /*ȡ߼η·ID*/ + wSecRLockBelongRoute = GetLogSecLockBelongRoute(wSecId); + routeBelongCiId = GetRouteBelongCiId(wSecRLockBelongRoute); /*ȡ߼ν··CI*/ + AddCiSendToCiCmdInfo(CI_CMD_LOGSEC_PLOCK_ROUTE_CMD, wSecId, wSecPLockBelongRoute, routeBelongCiId); + } + else + { + /*㣬*/ + } + } +} + + +/* +* ʹõָʾƴ +* ˵ void +* ֵ void +*/ +void OutPutIndicatorState_UseVirCI(void) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + UINT8 virCIid=0u; + + virNum = GetVirtualCINum(); + for(i=0u;i groupAutoRouteId)) + { + /*ȡԶ·Ϣ*/ + autoRouteSum = GetGroupAutoRouteHasRouteSum(groupAutoRouteId); + pAutoRouteIdBuf = GetGroupAutoRouteHasRouteIdBuff(groupAutoRouteId); + + /*Զ·*/ + if(0u != autoRouteSum) + { + routeSum = GetAutoRouteIncludeRouteSum(pAutoRouteIdBuf[0]);/*ý··Ŀ*/ + pRouteIdBuf = GetAutoRouteIncludeRouteBuf(pAutoRouteIdBuf[0]);/*ȡԶ·ӦĻ·*/ + if((0u != routeSum) && (NULL != pRouteIdBuf)) + { + reVal = GetRouteBelongVirCiId(pRouteIdBuf[0]);/*ɸý·屾Զ·*/ + } + else + { + ; + } + } + } + return reVal; +} + +/********************************************* +*ܣղղ +*˵ +*ֵ +*********************************************/ +void UpdateZhaoChaCheckZhaoChaDrive(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 localCiId = 0u; + UINT16 zhaochaRelayId = 0u; + UINT8 zhaoChaIdBelongCi = 0u; + UINT8 spksState = 0u; + UINT8 relayDriveState = 0u; + UINT8 fLockState = 0u; + UINT8 funcSwitchSupportRelayInterface = 0u;/*Ƿ̵ּ֧ӿ*/ + UINT16 zhaochaCheckNum = 0u; + ZhaochaCheckConfigDataStruct* pZhaochaCheckConfigDataStru = NULL; + + /*ȡϢ*/ + localCiId = GetSystemParaLocalCiId(); + pZhaochaCheckConfigDataStru = GetZhaochaCheckConfigDataStru(); + zhaochaCheckNum = GetZhaochaCheckConfigDataNum(); + /*Ƿ̵ּ֧ӿ*/ + funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + + /*̵ּ֧ӿ*/ + if(FUNC_SWITCH_ON == funcSwitchSupportRelayInterface) + {/*ǿ*/ + if (NULL != pZhaochaCheckConfigDataStru) + { + for(i = 0u; i < zhaochaCheckNum;i++) + { + if(ZHAOCHA_CHECK_SUM_MAX > i) + { + zhaochaRelayId = pZhaochaCheckConfigDataStru[i].ZhaochaRelayId; + if((0u < zhaochaRelayId) && (RELAY_SUM_MAX > zhaochaRelayId)) + { + zhaoChaIdBelongCi = GetRelayBelongCiId(zhaochaRelayId); + /*ղ̵ڱ*/ + if(zhaoChaIdBelongCi == localCiId) + { + + for(j = 0u; j < pZhaochaCheckConfigDataStru[i].ZhaochaCheckSum; j++) + { + if(ZHAOCHA_CHECK_TYPE_SUN_MAX > j) + { + + relayDriveState = GetRelayDriveState(zhaochaRelayId);/*ȡ̵״̬*/ + /*SPKS*/ + if((ZHAOCHA_CHECK_SPKS_YES == pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].CheckType) && + (CI_DEVICE_TYPE_SPKS == pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].DevType)) + { + /*ȡSPKS״̬*/ + spksState = GetSpksState(pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].DevId); + if(SPKS_STATUS_YES == spksState) + { + /*SPKS£ղ̵*/ + (void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_DOWN); + break; + } + else + { + /*Ч*/ + if(RELAY_DRIVE_STATE_NULL == relayDriveState) + { + (void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_UP); + } + } + } + else if((ZHAOCHA_CHECK_PHY_FLOCK_YES == pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].CheckType) && + (CI_DEVICE_TYPE_PHYSEC == pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].DevType)) + { + fLockState = GetPhySecFLockState(pZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[j].DevId); + /**/ + if(PHYSICAL_SECTION_FLOCK_YES == fLockState) + { + (void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_DOWN); + break; + } + else + { + /*Ч*/ + if(RELAY_DRIVE_STATE_NULL == relayDriveState) + { + (void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_UP); + } + } + } + else + { + /*쳣ȫ*/ + (void)SetRelayDriveState(zhaochaRelayId, RELAY_DRIVE_STATE_DOWN); + SetErrorData(EFUNC_UPDATE_ZHAOCHA_CHECK,CI_DEVICE_TYPE_RELAY,zhaochaRelayId,ETYPE_DATA_CFG_ERR,0,ESEND_LEVEL_ZERO); + break; + } + } + } + } + } + } + } + } + } +} + +/********************************************* +*ܣ豸״̬ +*˵ +*ֵ +*********************************************/ +void VirtualDeviceOutputProc(void) +{ + /*̵״̬*/ + VirtualRelayStateProc(); + + /*źŻ״̬*/ + VirtualSignalStateProc(); +} + +/********************************************* +*ܣ豸״̬ +*˵ +*ֵ +*********************************************/ +void VirtualSignalStateProc(void) +{ + UINT16 signalSum = 0u; + UINT16 signalIndx = 0u; + UINT16 signalId = 0u; + UINT16 bufIndex = 0u; + UINT8 signalVirtAttr = 0u; + UINT8 signalDrivColor = 0u; + UINT8 localId = 0u; + UINT8 signalBelongCi = 0u; + + SignalDataStruct * pTempSignalDataStruct = NULL; + + signalSum = GetSignalCurSum(); /*ȡźŻǰ*/ + localId = GetSystemParaLocalCiId(); + for (signalIndx = 0u; signalIndx < signalSum; signalIndx++) + { + signalId = GetSignalId(signalIndx); + signalBelongCi = GetSignalBelongCiId(signalId); + if (localId == signalBelongCi) + { + signalVirtAttr = GetSignalVirtualAttr(signalId); + + if(SIGNAL_VIRTUAL_YES == signalVirtAttr) /*źŻΪźŻ*/ + { + signalDrivColor = GetSignalCurDriveColor(signalId); + bufIndex = GetSignalConfigBufIndex(signalId); + pTempSignalDataStruct = GetSignalData(); + if(NULL != pTempSignalDataStruct) + { + pTempSignalDataStruct[bufIndex].CurColor = signalDrivColor; + } + } + } + } +} + +/* +* ̵״̬ +* ˵ +* ֵ +* +*/ +void SetDriveRelayHunXianState(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 relayId = 0u; + UINT8 localCiId = 0u; + UINT8 relayBelongCi = 0u; + UINT16 relaySum = 0u; + UINT8 relayDrvAddrA = 0u; /*忨ַ*/ + UINT8 relayDrvPosA = 0u; /*λ*/ + UINT8 relayDrvAddrB = 0u; + UINT8 relayDrvPosB = 0u; + UINT8 collectMode = 0u; + UINT8 retValue = CI_ERROR; + + /*ȡϢ*/ + relaySum = GetRelayCurSum(); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + for(i = 0u; i < relaySum;i++) + { + relayId = GetRelayId(i); + relayBelongCi = GetRelayBelongCiId(relayId); + if(relayBelongCi == localCiId) + { + /*ȡ̵ַϢ*/ + relayDrvAddrA = GetRelayDrvAddrA(relayId); + relayDrvPosA = GetRelayDrvPosA(relayId); + relayDrvAddrB = GetRelayDrvAddrB(relayId); + relayDrvPosB = GetRelayDrvPosB(relayId); + + /*ȡɼʽ*/ + collectMode = GetRelayCollectMode(relayId); + + /*̵*/ + if((relayDrvAddrA > 0u) && (relayDrvPosA > 0u) && (relayDrvAddrB > 0u) && (relayDrvPosB > 0u) + && (collectMode > 0u)) + { + /*߼*/ + retValue = CheckRelayHunXiandState(relayId); + if(CI_ERROR == retValue) + { + /*ü̵״̬*/ + SetRelayHunXianState(relayId,RELAY_HUNXIAN_STATE_YES); + } + else + { + /*ü̵δ״̬*/ + SetRelayHunXianState(relayId,RELAY_HUNXIAN_STATE_NO); + } + } + } + else + { + /**/ + } + } +} + +/* +* ȡ˹ʱ +* ˵ +* const UINT16 overlapId id +* const UINT16 OverlapUnLockCount ʱ +* const UINT32 startCycNum ʼ +* ֵ ʱ +* +*/ +UINT16 GetOverlapUnlockBackTime(const UINT16 overlapId, UINT16 OverlapUnLockCount, const UINT32 startCycNum) +{ + UINT16 autotimeData = 0u; + UINT16 labortimeData = 0u; + INT32 deltCount = 0; + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 appCycTime = GetSystemParaAppCycleTime();/*ȡ*/ + UINT32 laborUnlockStartCycNum = 0u; + UINT32 laborUnlockOverlapTimeCount =0u; + UINT16 returnTime = 0u; + + + /*Զʱ*/ + deltCount = (INT32)(curCycleNum - startCycNum); + if((deltCount >= 0) && (deltCount <= (INT32)OverlapUnLockCount))/*ʱֵںΧ*/ + { + autotimeData = (UINT16)(((OverlapUnLockCount + startCycNum - curCycleNum)* appCycTime)/1000U) ; + } + + + + /*˹ʱ*/ + laborUnlockStartCycNum = GetlaborUnlockStartCycNum(overlapId); + + if(0u < laborUnlockStartCycNum)/*Ѿ˹*/ + { + deltCount = (INT32)(curCycleNum - laborUnlockStartCycNum); + laborUnlockOverlapTimeCount =GetlabarUnlockOverlapTimeCount(); + if((deltCount >= 0) && (deltCount <= (INT32)laborUnlockOverlapTimeCount))/*ʱֵںΧ*/ + { + labortimeData = (UINT16)(((laborUnlockOverlapTimeCount + laborUnlockStartCycNum- curCycleNum)* appCycTime)/1000U) ; + + } + } + + + + if(0u < laborUnlockStartCycNum)/*Ѿ˹*/ + { + /*Ƚʱ䣬СġΪڽ߼Сʱ*/ + if(autotimeData > labortimeData) + { + returnTime = labortimeData; + } + else + { + returnTime = autotimeData; + } + } + else + { + returnTime = autotimeData; + } + + return returnTime; +} + +/* +* źŻǰɫʾźŻ +* ˵ +* ֵ +* ע⣺ +*/ +void DriveFushiSignal(void) +{ + UINT16 ii = 0u; + UINT16 signalCurSum = 0u; + UINT16 signalId = 0u; + UINT8 fushiSignalNum = 0u; + UINT16* pFushiSignalIdBuf = NULL; + UINT8 lightExtinctState = 0u; + UINT8 signalMaintainState = 0u; + UINT8 checkflag = 0u; + UINT8 signalColor = 0u; + UINT8 ciPattern = 0u;/*ģʽ*/ + UINT32 SignalStartCycNum = 0u; + UINT8 jj = 0u; + UINT8 fushiSignalCurColor = 0u; + UINT8 openCloseStat = 0u; + UINT8 fushiDrivColor = 0u; + + signalCurSum = GetSignalCurSum();/*ڱźŻ*/ + for (ii = 0u; ii < signalCurSum; ii++) + { + checkflag = 0u; + signalId = 0u; + fushiSignalNum = 0u; + pFushiSignalIdBuf = NULL; + signalMaintainState = 0u; + lightExtinctState = 0u; + signalMaintainState = 0u; + signalColor = 0u; + ciPattern = 0u; + SignalStartCycNum = 1u; + + signalId = GetSignalId(ii); + + fushiSignalNum = GetSignalFushiSignalNum(signalId); + pFushiSignalIdBuf = GetSignalFushiSignalIdBuf(signalId);/*ȡʾźŻID*/ + if ((0u < fushiSignalNum) && (NULL != pFushiSignalIdBuf))/*źŻиʾźŻ*/ + { + lightExtinctState = GetSignalLightExtinctState(signalId);/*ȡźŻ״̬*/ + signalMaintainState = GetSignalMaintainState(signalId);/*ȡźŻά޵״̬*/ + if ((SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) || (MAINTAIN_STATE_YES == signalMaintainState)) + {/*ƻά޵*/ + checkflag = 1u; + } + } + + /*źŻǷڿ״̬*/ + if (1u == checkflag) + { + signalColor = GetSignalCurColor(signalId); + if ((SIGNAL_SHOWCOLOUR_GREEN == signalColor) || + (SIGNAL_SHOWCOLOUR_YELLOW == signalColor)) + { /*̵||Ƶ*/ + /*źſ*/ + } + else + { + checkflag = 0u;/*鲻ͨ*/ + } + } + + /*źŻʵǷڿ״̬*/ + if (1u == checkflag) + { + ciPattern = GetLocalCiPattern();/*ȡģʽͬģʽв̷ͬʽ*/ + + if (CI_PATTERN_FULL_ELECTRONIC == ciPattern) /*ȫ*/ + { + SignalStartCycNum = GetOcSignalStartCycNum(signalId);/*ȡOCȫ*/ + } + else if (CI_PATTERN_TRADITIONAL == ciPattern) + { + SignalStartCycNum = GetSigRelayActStartCycNum(signalId); + } + else + { + checkflag = 0u;/*鲻ͨ*/ + } + + if (1u == checkflag) + { + if (0u == SignalStartCycNum) + {/*Ϊ0ǰụ̂źһ¡ͨ*/ + } + else + { + checkflag = 0u;/*鲻ͨ*/ + } + } + } + + /*ϼͨʼʾźŻ*/ + if (1u == checkflag) + { + /*źŻɫȡʾźŻɫ*/ + fushiDrivColor = GetFushiSignalDriveColor(signalColor); + if ((0u < fushiSignalNum) && (NULL != pFushiSignalIdBuf))/*źŻиʾźŻ*/ + { + for (jj = 0u; jj < fushiSignalNum; jj++) + { + fushiSignalCurColor = GetSignalCurColor(pFushiSignalIdBuf[jj]);/*ȡʾźŻǰɫ*/ + openCloseStat = GetSignalOpenCloseState(fushiSignalCurColor); + if (SIGNAL_CLOSE == openCloseStat) + { + SetSignalCurDriveColor(pFushiSignalIdBuf[jj], fushiDrivColor);/*źŻʾɫʾźŻɫ*/ + } + else + {/*ǰʾźŻǿŵ*/ + if (fushiSignalCurColor != signalColor)/*ǰʾźŻʾɫźŻͬ*/ + { + SetSignalCurDriveColor(pFushiSignalIdBuf[jj], SIGNAL_DRIVECOLOUR_REDCLOSE); + } + else + { + SetSignalCurDriveColor(pFushiSignalIdBuf[jj], fushiDrivColor);/*źŻʾɫʾźŻɫ*/ + } + } + } + } + } + else + { + if ((0u < fushiSignalNum) && (NULL != pFushiSignalIdBuf))/*źŻиʾźŻ*/ + { + for (jj = 0u; jj < fushiSignalNum; jj++) + { + SetSignalCurDriveColor(pFushiSignalIdBuf[jj], SIGNAL_DRIVECOLOUR_REDCLOSE);/**/ + } + + } + } + } +} + +/* +* ԶʾǷƱ־ +* ˵ UINT8 virCiId ID +* ֵ CI_SUCCESS +* CI_ERROR +*/ +UINT8 CheckAutoTriggerIndicatFlag(UINT8 virCiId) +{ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT16 ii = 0U; + UINT16 routeCurSum = 0U; /*·Ŀ*/ + UINT16 routeId = 0U; /*·ID*/ + UINT8 routeAutoTriggerFlag = 0U; /*·Զ־*/ + UINT8 localCiId = 0U; + UINT8 routeBelongCiId = 0U; + UINT8 routeBelongVirCiId = 0U; + UINT8 flag = 0U; /*ǷԶ־*/ + UINT8 retIndicatFlag = CI_ERROR; /*ָʾǷƱ־*/ + + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + localCiId = GetSystemParaLocalCiId(); + + /*·*/ + for (ii = 0U; ii < routeCurSum; ii++) + { + routeId = GetRouteId(ii); /*ȡ·ID*/ + routeAutoTriggerFlag = GetRouteAutoTriggerFlag(routeId); /*ȡ·Զ־*/ + + if (FUNC_SWITCH_ON == includeVirFlag) + { + if (0U < virCiId) + { + routeBelongVirCiId = GetRouteBelongVirCiId(routeId); /*ȡ·ID*/ + if (virCiId == routeBelongVirCiId) + { + /*ֻҪһԶ·Զ־Զʾƣ*/ + if (AUTO_TRIGGER_SET_YES == routeAutoTriggerFlag) + { + flag = 1u; + retIndicatFlag = CI_SUCCESS; + } + } + } + } + else + { + routeBelongCiId = GetRouteBelongCiId(routeId); + if (localCiId == routeBelongCiId) + { + /*ֻҪһԶ·Զ־Զʾƣ*/ + if (AUTO_TRIGGER_SET_YES == routeAutoTriggerFlag) + { + flag = 1u; + retIndicatFlag = CI_SUCCESS; + } + } + } + if (1u == flag) + { + break; + } + } + return retIndicatFlag; +} +/* +* ָʾ״̬ +* ˵ void +* ֵ void +* cgh-ϲCID-3037-3 +*/ +void OcStationIndicStateProc(void) +{ + UINT16 devCurSum = GetOCStationIndicCurSum(); /*ȡOCվʾƵǰ*/ + UINT8 indicId = 0U; + UINT8 ocid = 0U; + UINT16 relayId = 0U; + UINT8 relayState = 0U; + UINT16 ii = 0U; + + for (ii = 0; ii < devCurSum; ii++) + { + + indicId = GetOCStationIndicIdByIndex(ii); + ocid = GetOCStationIndicOcIdByIndex(ii); + relayId = GetOCStationIndicRelayId(ocid, indicId); /*ȡָʾID*/ + + if ((0U != relayId) && (UINT16_MAX != relayId))/*ָʾЧ*/ + { + relayState = GetRelayCollState(relayId); + if (RELAY_STATE_UP == relayState) + { + SetOCStationIndicState(ocid, indicId, INDICATOR_SHOW_YES); + } + else + { + SetOCStationIndicState(ocid, indicId, INDICATOR_SHOW_NO); + } + } + else + { + SetOCStationIndicState(ocid, indicId, INDICATOR_SHOW_NO); + } + } +} + +/* +* ·ʱ +* ˵ const UINT16 wRouteId ·ID +* ֵ void +* cgh-ŻʱȦӶ +*/ +void RouteTimeDataBackProcess(const UINT16 wRouteId) +{ + UINT32 dwAppCycTime = 0U;/**/ + UINT32 dwCurCycleNum = 0U;/*ǰ*/ + UINT16 wTimeData = 0U;/*ĵʱʱ*/ + UINT32 dwDelayUnlockStartCycNum = 0U;/*·ʱʼں*/ + UINT32 dwLeadRouteFaultOpenCount = 0U;/*·ڷιźſų*/ + UINT32 dwRouteDelayCount = 0U;/*·ʱ*/ + UINT32 dwLeadFaultOpenStartCycNum = 0U;/*··ڷźſʼں*/ + + dwAppCycTime = GetSystemParaAppCycleTime();/*ȡں*/ + dwCurCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + dwLeadRouteFaultOpenCount = GetSystemParaLeadFaultOpenCyc(); + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + dwDelayUnlockStartCycNum = GetRouteDelayUnlockStartCycNum(wRouteId); + dwLeadFaultOpenStartCycNum = GetRouteLeadFaultOpenStartCyc(wRouteId); + + dwRouteDelayCount = GetRouteDelayCycleCount(wRouteId); + + if (0U < dwDelayUnlockStartCycNum) + {/*ʱʱ*/ + if ((dwCurCycleNum - dwDelayUnlockStartCycNum) <= dwRouteDelayCount) + { + wTimeData = (UINT16)(((dwRouteDelayCount + dwDelayUnlockStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U); + if (wTimeData > UINT8_MAX) + { /*ʱʱ䳬ֵʱͬһڷһΪֽڣһΪֽ*/ + /*˽ʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_ZONGRENJIE_HIGH, CI_DEVICE_TYPE_ROUTE, wRouteId, (UINT8)(wTimeData >> 8), 0U); + } + SetCiSendCmdBackInfoData(CI_BACK_COUNT_ZONGRENJIE, CI_DEVICE_TYPE_ROUTE, wRouteId, (UINT8)wTimeData, 0U); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + /*źڷһιϵʱ*/ + if (0U < dwLeadFaultOpenStartCycNum) + {/*źſʱʱ*/ + wTimeData = (UINT16)(((dwLeadRouteFaultOpenCount + dwLeadFaultOpenStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U); + /*˽ʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_LEAD, CI_DEVICE_TYPE_ROUTE, wRouteId, (UINT8)wTimeData, 0U); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ʱ +* ˵ const UINT16 wPhySecId ID +* ֵ void +* cgh-ŻʱȦӶ +*/ +void PhySecTimeDataBackProcess(const UINT16 wPhySecId) +{ +#if 0 + /*ǰ߼ιڶ0Ԥ*/ + UINT16 wPhyBelRouteId = 0U;/*·ID*/ + UINT8 chPhyBelRouteType = 0U;/*·*/ + UINT32 dwAppCycTime = 0U;/**/ + UINT32 dwCurCycleNum = 0U;/*ǰ*/ + UINT16 wTimeData = 0U;/*ĵʱʱ*/ + UINT32 dwDelayUnlockStartCycNum = 0U;/*ʽʼں*/ + UINT32 dwBlocRouteDelayCount = 0U;/*ʽ·ʱ*/ + UINT32 dwFaultUnlockCount = 0U;/*׹ʽʱ*/ + + dwAppCycTime = GetSystemParaAppCycleTime();/*ȡں*/ + dwCurCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + dwBlocRouteDelayCount = GetSystemParaBlocRouteDelayCyc(); + dwFaultUnlockCount = GetSystemParaFaultUnlockCyc(); + + if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId)) + { + wPhyBelRouteId = GetPhySecRLockBelongRouteId(wPhySecId); + chPhyBelRouteType = GetRouteType(wPhyBelRouteId); + dwDelayUnlockStartCycNum = GetPhySecFaultUnlockStartCycNum(wPhySecId); + + if (0U < dwDelayUnlockStartCycNum) + {/*ʽʱʱ*/ + + if ((ROUTE_TYPE_LIECHE == chPhyBelRouteType) || (ROUTE_TYPE_RETURN == chPhyBelRouteType)) + {/*г·۷·ʽʱ45s*/ + + if ((dwCurCycleNum - dwDelayUnlockStartCycNum) <= dwBlocRouteDelayCount) + { + wTimeData = (UINT16)(((dwBlocRouteDelayCount + dwDelayUnlockStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000); + + /*ʽʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_SECFAULT, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)wTimeData, 0U); + } + } + else if (ROUTE_TYPE_DIAOCHE == chPhyBelRouteType) + {/*·ʽʱ30s*/ + + if (dwCurCycleNum - dwDelayUnlockStartCycNum <= dwFaultUnlockCount) + { + wTimeData = (UINT16)(((dwFaultUnlockCount + dwDelayUnlockStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000); + /*ʽʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_SECFAULT, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)wTimeData, 0U); + } + } + else + { + /*·Ͳ*/ + } + } + } +#endif + UINT8 chLogSectionSum = 0U;/*ΰ߼Ŀ*/ + UINT16* pPhyIncLogId = NULL; /*ΰ߼ID*/ + UINT8 ii = 0U; + UINT32 dwDelayUnlockStartCycNum = 0U;/*߼ʽʱʼں*/ + UINT32 dwAppCycTime = 0U;/**/ + UINT32 dwCurCycleNum = 0U;/*ǰ*/ + UINT16 wTimeData = 0U;/*ĵʱʱ*/ + UINT32 dwBlocRouteDelayCount = 0U;/*ʽ·ʱ*/ + UINT16 wPhyBackFlag = 0U;/*ηʱ־*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chPhyBelongCiId = 0U;/*ID*/ + + dwAppCycTime = GetSystemParaAppCycleTime();/*ȡں*/ + dwCurCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + dwBlocRouteDelayCount = GetSystemParaBlocRouteDelayCyc(); + chLocalCiId = GetSystemParaLocalCiId(); + + if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId)) + { + + chPhyBelongCiId = GetPhySecBelongCiId(wPhySecId); + if (chLocalCiId == chPhyBelongCiId) + { + chLogSectionSum = GetPhySecIncLogSecSum(wPhySecId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(wPhySecId); + if (NULL != pPhyIncLogId) + { + for (ii = 0U; ii < chLogSectionSum; ii++) + { + dwDelayUnlockStartCycNum = GetLogDelayErrlockStartCycNum(pPhyIncLogId[ii]); + if (0U < dwDelayUnlockStartCycNum) + {/*αһ·գҵӦ߼ʱںЧֱεʱ־*/ + /*ε߼αͬ·գ·ʽͬһε߼ʱͬʱãҵһñ־*/ + wPhyBackFlag = 1U; + break; + } + } + if (1U == wPhyBackFlag) + {/*ʽʱʱ*/ + if (dwCurCycleNum - dwDelayUnlockStartCycNum <= dwBlocRouteDelayCount) + { + wTimeData = (UINT16)(((dwBlocRouteDelayCount + dwDelayUnlockStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U); + if (wTimeData > UINT8_MAX) + { /*ʱʱ䳬ֵʱͬһڷһΪֽڣһΪֽ*/ + /*ʽʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_HALF_SECUNLO_HIGH, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)(wTimeData >> 8), 0U); + } + SetCiSendCmdBackInfoData(CI_BACK_COUNT_HALF_SECUNLO, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)wTimeData, 0U); + SetPhyErrUnlockTime(wPhySecId, wTimeData); + } + } + else + { + /*ʱ߼ ʽ⵹ʱ*/ + SetPhyErrUnlockTime(wPhySecId, 0U); + } + } + } + else + { + /*˴ȡʱʱ*/ + wTimeData = GetPhyErrUnlockTime(wPhySecId); + if (0U < wTimeData) + { + if (wTimeData > UINT8_MAX) + {/*ʱʱ䳬ֵʱͬһڷһΪֽڣһΪֽ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_HALF_SECUNLO_HIGH, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)(wTimeData >> 8), 0U); + } + SetCiSendCmdBackInfoData(CI_BACK_COUNT_HALF_SECUNLO, CI_DEVICE_TYPE_PHYSEC, wPhySecId, (UINT8)wTimeData, 0U); + } + } + } +} + +/* +* ʱ +* ˵ const UINT16 wPhySecId ID +* ֵ void +* cgh-ŻʱȦӶ +*/ +void OverlapTimeDataBackProcess(const UINT16 wOverlapId) +{ + UINT8 chOverlapBelongCiId = 0U;/**/ + UINT16* pOverlapPhySecBuf = NULL;/*ΰID*/ + UINT16 wTimeData = 0U;/*ĵʱʱ*/ + UINT16 wOverlapBelongRouteId = 0U;/*·ID*/ + UINT8 wOverlapBelongRouteCiId = 0U;/*·*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT16 wRouteLastPhySectionId = 0U;/*·һID*/ + UINT32 dwUtCtStartOccuCount = 0U; /*ָIDUTCTռʼں*/ + UINT16 wRLockBelongRouteId = 0U;/*ָIDν··ID*/ + UINT8 chTmpRouteBelongCiId = 0U;/*·ɱ*/ + UINT8 chUtOrCtOccFlag = 0U;/*CTUTռ״̬*/ + UINT32 dwRelyonStartCycNum = 0U;/*ʼʱ*/ + UINT32 dwUtOverlapUnLockCount = 0U;/*utͣ*/ + UINT32 dwCtOverlapUnLockCount = 0U; /*CTռý·һµĽͣ*/ + UINT16 wRouteStopSteadyPhySecId = 0U;/*·ͣID*/ + UINT16 wOverlapAllClearRes = CI_ERROR;/*οм־*/ + UINT16 wTmpOvlpOccuSecId = 0U;/*ʱúijڲвֵ*/ + UINT8 chTmpOvlpOccuSecSta = 0U;/*ʱúijڲвֵ*/ + UINT8 chFuncSwitchSendTime = 0u;/*CBTCǷͱνʱ*/ + UINT8 chABLFlag = 0U; /*·ABLռñ־*/ + + chLocalCiId = GetSystemParaLocalCiId(); + chFuncSwitchSendTime = GetCiFunctionSwitchConfig(FUNC_SWITCH_SEND_UNLOCK_OVERLEP_TIMER_COUNTDOWN); + + if ((0U < wOverlapId) && (OVERLAP_SUM_MAX > wOverlapId)) + { + chOverlapBelongCiId = GetOverlapBelongCiId(wOverlapId); + pOverlapPhySecBuf = GetOverlapPhySecIdBuf(wOverlapId); + wOverlapBelongRouteId = GetOverlapBelongRouteId(wOverlapId); + + /*ȡЧ*/ + if ((0U < wOverlapBelongRouteId) && (NULL != pOverlapPhySecBuf)) + { + wOverlapBelongRouteCiId = GetRouteBelongCiId(wOverlapBelongRouteId); + /*ڱ*/ + if (chLocalCiId == chOverlapBelongCiId) + { + wRouteLastPhySectionId = GetRouteLastPhySectionId(wOverlapBelongRouteId); + dwUtCtStartOccuCount = GetSecUtOrCtOccuStartCycNum(wRouteLastPhySectionId); + /*·˳ռѹһεʼ*/ + if (0U UINT8_MAX) + {/*ʱʱ䳬ֵʱͬһڷһΪֽڣһΪֽ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_OVERLAP_UNLOCK_HIGH, CI_DEVICE_TYPE_PHYSEC, pOverlapPhySecBuf[0], (UINT8)(wTimeData >> 8), 0U); + + } + SetCiSendCmdBackInfoData(CI_BACK_COUNT_OVERLAP_UNLOCK, CI_DEVICE_TYPE_PHYSEC, pOverlapPhySecBuf[0], (UINT8)wTimeData, 0U); + } + SetOverlapUnlockTime(wOverlapId, wTimeData); + } + else + { + SetOverlapUnlockTime(wOverlapId, 0U);/*ʱΪٴռʱҪռÿʼʱΪʱο¼ʱ*/ + } + } + else + { + if (chLocalCiId == wOverlapBelongRouteCiId)/*·ڱ*/ + { + /*˴ȡʱʱ*/ + wTimeData = GetOverlapUnlockTime(wOverlapId); + if (0U < wTimeData) + { + if (wTimeData > UINT8_MAX) + {/*ʱʱ䳬ֵʱͬһڷһΪֽڣһΪֽ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_OVERLAP_UNLOCK_HIGH, CI_DEVICE_TYPE_PHYSEC, pOverlapPhySecBuf[0], (UINT8)(wTimeData >> 8), 0U); + } + SetCiSendCmdBackInfoData(CI_BACK_COUNT_OVERLAP_UNLOCK, CI_DEVICE_TYPE_PHYSEC, pOverlapPhySecBuf[0], (UINT8)wTimeData, 0U); + } + } + else + { + /*޲*/ + } + } + } + else + { + SetOverlapUnlockTime(wOverlapId, 0U);/*ûգ0*/ + } + } + else + { + SetOverlapUnlockTime(wOverlapId, 0U);/*ûգ0*/ + } +} +/* +* ܸλ̵ʱ +* ˵ void +* ֵ void +* cgh-ŻʱȦӶ +*/ +void ZFWJTimeDataBackProcess(void) +{ + UINT8 jj = 0U; + UINT8 chIncludeVirFlag = 0U;/*ֿ֧*/ + UINT8 chVirCiNum = 0U;/*ȡĿ*/ + UINT8 chVirCiId = 0U;/*ID*/ + UINT32 dwAppCycTime = 0U;/**/ + UINT32 dwCurCycleNum = 0U;/*ǰ*/ + UINT8 chLocalCiId = 0U;/*ǰID*/ + UINT16 wRelayZFWId = 0U;/*ܸλ̵ID*/ + UINT32 dwZFWJDriveTimeCount = 0U;/*ܸλʧЧ*/ + UINT32 dwZFWValidCycNum = 0U;/*ܸλ̵Ч*/ + UINT32 dwCycleCost = 0U;/*ʱ*/ + UINT16 wTimeData = 0U;/*ĵʱʱ*/ + + dwAppCycTime = GetSystemParaAppCycleTime();/*ȡں*/ + dwCurCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + chLocalCiId = GetSystemParaLocalCiId(); + chIncludeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + dwZFWJDriveTimeCount = GetZFWJRelayDriveTimeCount(); + + if (FUNC_SWITCH_ON == chIncludeVirFlag) + { + chVirCiNum = GetVirtualCINum(); + for (jj = 0u; jj < chVirCiNum; jj++) + { + chVirCiId = GetVirtualCIid(jj); + wRelayZFWId = GetZFWRelayId_UseVirCI(chLocalCiId, chVirCiId); /*ܸλ̵ID*/ + if (wRelayZFWId > 0u) + { + dwZFWValidCycNum = GetVirCIZfwValidCycNum(chVirCiId); + /*ZFWJ״̬Ч*/ + dwCycleCost = dwCurCycleNum - dwZFWValidCycNum; + if ((0U < dwCycleCost) && (dwCycleCost <= dwZFWJDriveTimeCount) && (dwZFWValidCycNum > 0U)) + { + wTimeData = (UINT16)(((dwZFWJDriveTimeCount + dwZFWValidCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U); + /*ӼܸλťЧʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_ZFWJ_VALID, CI_DEVICE_TYPE_RELAY, wRelayZFWId, (UINT8)wTimeData, 0U); + } + } + } + } + else + { + wRelayZFWId = GetZFWRelayId(chLocalCiId); /*ܸλ̵ID*/ + if (wRelayZFWId > 0u) + { + dwZFWValidCycNum = GetZFWValidCycNum(); + /*ZFWJ״̬Ч*/ + dwCycleCost = dwCurCycleNum - dwZFWValidCycNum; + if ((0U < dwCycleCost) && (dwCycleCost <= dwZFWJDriveTimeCount) && (dwZFWValidCycNum > 0U)) + { + wTimeData = (UINT16)(((dwZFWJDriveTimeCount + dwZFWValidCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U); + /*ӼܸλťЧʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_ZFWJ_VALID, CI_DEVICE_TYPE_RELAY, wRelayZFWId, (UINT8)wTimeData, 0U); + } + } + } +} + +/* +* ǽ·ʱ +* ˵ NonRouteDataStruct* pNonRoute ǽ·ݽṹ +* ֵ void +* cgh-ŻʱȦӶ +*/ +void NonRouteTimeDataBackProcess(NonRouteDataStruct* pNonRoute) +{ + UINT32 dwAppCycTime = 0U;/**/ + UINT32 dwCurCycleNum = 0U;/*ǰ*/ + UINT32 dwNonRouDelayUnlockCount = 0U;/*ǽ·ʱ*/ + UINT16 wTimeData = 0U;/*ĵʱʱ*/ + + dwAppCycTime = GetSystemParaAppCycleTime();/*ȡں*/ + dwCurCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + dwNonRouDelayUnlockCount = GetSystemParaNonRDelayUnlockCnt(); + + if (NULL != pNonRoute) + { + /*ǽ·ȡʱ*/ + if (pNonRoute->DelayUnlockStartCycleNum > 0u) + {/*ǽ·ȡʱ*/ + + if ((dwCurCycleNum - pNonRoute->DelayUnlockStartCycleNum) <= dwNonRouDelayUnlockCount) + { + wTimeData = (UINT16)(((dwNonRouDelayUnlockCount + pNonRoute->DelayUnlockStartCycleNum - dwCurCycleNum) * dwAppCycTime) / 1000U); + /*˽ʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_CANCEL_NONROUTE, CI_DEVICE_TYPE_NONROUTE, pNonRoute->NonRouteId, (UINT8)wTimeData, 0U); + } + } + } +} + +/* +* ʱʱ +* ˵ const UINT16 wFloodGateId ID +* ֵ void +*/ +void FloodGateTimeDataBackProcess(const UINT16 wFloodGateId) +{ + UINT32 dwAppCycTime = 0U;/**/ + UINT32 dwCurCycleNum = 0U;/*ǰ*/ + UINT32 FloodGateDelayCloseCount = 0U;/*ʱر*/ + UINT32 dwFloodGateCloseStartCycNum = 0u; /*ʱرʼں*/ + UINT16 wTimeData = 0U;/*ĵʱʱ*/ + + dwAppCycTime = GetSystemParaAppCycleTime();/*ȡں*/ + dwCurCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + FloodGateDelayCloseCount = GetFloodGateDelayCloseCount(); + + if ((0U < wFloodGateId) && (FLOOD_GATE_SUM_MAX > wFloodGateId)) + { + dwFloodGateCloseStartCycNum = GetFloodGateDelayCloseStartCnt(wFloodGateId); + if (0U < dwFloodGateCloseStartCycNum) + { + if ((dwCurCycleNum - dwFloodGateCloseStartCycNum) <= FloodGateDelayCloseCount) + { + wTimeData = (UINT16)(((FloodGateDelayCloseCount + dwFloodGateCloseStartCycNum - dwCurCycleNum) * dwAppCycTime) / 1000U); + if (wTimeData > UINT8_MAX) + { /*ʱʱ䳬ֵʱͬһڷһΪֽڣһΪֽ*/ + /*ӷʱżʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_COUNT_FLOODGATE_CLOSE_HIGH, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, (UINT8)(wTimeData >> 8), 0U); + } + SetCiSendCmdBackInfoData(CI_BACK_COUNT_FLOODGATE_CLOSE, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, (UINT8)wTimeData, 0U); + } + } + } +} + + +/* +* гϢ +* ˵ void +* ֵ +*/ +void VobcBackUpOutputProcess(void) +{ + UINT8 ii = 0U; + UINT16 wTrainId = 0U;/*гID*/ + UINT8 chMainValid = 0U;/*гͨ״̬*/ + UINT16 wVobcId = 0U;/*VOBC ID*/ + UINT8 chBackUpValid = 0U;/*ͨЧ־*/ + + for (ii = 0U; ii < TRAIN_SUM_MAX; ii++) + { + wTrainId = GetTrainId(ii); + + chBackUpValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(wTrainId & 0x00ffU)); + chMainValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_VOBC, (UINT8)(wTrainId & 0x00ffU)); + wVobcId = 0U; + + + if ((CI_SUCCESS == chMainValid) || (CI_SUCCESS == chBackUpValid)) + { + /*ȼһ³ڽ·Ƿз*/ + wVobcId = wTrainId & 0x00ffU; + + VobcLocReverseRouteCheck(wVobcId); + + /*гǰû߱ͨЧ гǰλ*/ + VobcHeadTrainDataProc(wVobcId); + + /*ݷ͹510ͨãҪ*/ + /*Ҫ͵ĺгϢȻ¼*/ + ClearBackUpTrainInfo(wVobcId); + + /*߼μ*/ + VobcBackUpLogSecManage(wVobcId); + + /*Լǰн·㼰۷߼μ*/ + VobcBackUpRouteManage(wVobcId); + + /*Psd Esb Ϣ*/ + VobcBackUpPsdEsbManage(wVobcId); + +#if 0 + /*Ϣ*/ + VoBcBackUpSwitchManage(&VobcBackUpToCiDataStru[ii]); +#endif + + /*μ*/ + VobcBackUpProSecManage(wVobcId); + + /*Ϣ*/ + VobcBackUpXiansuSecManage(wVobcId); + + + /*½·߼οϢ*/ + VobcBackUpRouteNoOccuManage(wVobcId); + } + else + { + ; /*ͨŵij*/ + } + } +} + +/* +* г߼Ϣ +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240710 +*/ +void VobcBackUpLogSecManage(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 TrainMinSafeTailLink = 0U; + UINT16 LinkRelatedPhySecId = 0U; + UINT16 TrainMaxSafeHeadLink = 0U; + UINT16 wTrainHeadLogSecRLockId = 0U; + struct_PathPoint start = { 0U }; /*г߼*/ + struct_PathPoint end = { 0U }; /*г߼յ*/ + UINT16 wTrainOccLogSum = 0U; /*г߼*/ + UINT16 wTrainOccLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*гռѹ߼ID*/ + UINT8 chVobcBackUpLogSum = 0U; /*󱸷͵߼*/ + UINT16 wVobcBackUpLogID[TRAIN_ABL_LOGSEC_SUM] = { 0U }; /*󱸷͵߼*/ + ABLTrainRelLogStru ablVobcBackUpLogSecStr[TRAIN_ABL_LOGSEC_SUM] = { 0U }; + UINT16 RouteLogSectionSum = 0u; /*ͷڽ·߼*/ + UINT16* RouteLogSectionIdBuf = NULL; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 chVobcBackUpRouteSum = 0U; /*Ҫͺг·(¼)*/ + UINT16 wVobcBackUpRouteID = 0U; /*߼·ID*/ + ABLTrainRelAllRouteStru ablVobcBackUpRouteStr[TRAIN_ABL_ALLROUTE_SUM] = { 0U }; + UINT8 wFlag = 0U; /*ʼ¼·ı־*/ + UINT16 wTrainHeadBelongLogSec = 0U; /*ͷ߼ID*/ + UINT8 chLogSecBelSendRange = CI_ERROR;/*ʼΪڴ䷶Χ*/ + UINT8 chTrainAblRelLogSecNum = 0U;/*Ҫ͵߼Ŀ*/ + + if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + /*βڽ·*/ + TrainMinSafeTailLink = GetAblTrainMinTailLink(wTrainId); + LinkRelatedPhySecId = GetLinkRelatedPhySec(TrainMinSafeTailLink); + start.wLinkId = TrainMinSafeTailLink; + start.dwOffset = GetAblTrainMinTailOffset(wTrainId); + + /*ͷڽ·*/ + TrainMaxSafeHeadLink = GetAblTrainMaxHeadLink(wTrainId); + end.wLinkId = TrainMaxSafeHeadLink; + end.dwOffset = GetAblTrainMaxHeadOffset(wTrainId); + /*ͷڵ߼*/ + wTrainHeadBelongLogSec = GetPointBelongLogSec(end); + wTrainHeadLogSecRLockId = GetLogSecLockBelongRoute(wTrainHeadBelongLogSec); + chRetVal = GetLogSecBtwTwoPoints(start, end, &wTrainOccLogSum, wTrainOccLogID); + + if (CI_SUCCESS == chRetVal) + { + /*¼ABLг߼*/ + SetTrainAblOcculogData(wTrainId, (UINT8)wTrainOccLogSum, wTrainOccLogID); + /*¼ABLгͷ߼*/ + SetTrainAblMaxHeadLogId(wTrainId, wTrainHeadBelongLogSec); + + /*¼µ߼ID*/ + chVobcBackUpLogSum = (UINT8)wTrainOccLogSum; + (void)CommonMemCpy(wVobcBackUpLogID, (UINT32)(sizeof(UINT16)*TRAIN_ABL_LOGSEC_SUM), wTrainOccLogID, (UINT32)(sizeof(UINT16)*wTrainOccLogSum)); + /*鳵ͷڽ·߼*/ + RouteLogSectionSum = GetRouteLogSectionSum(wTrainHeadLogSecRLockId); + RouteLogSectionIdBuf = GetRouteLogSectionIdBuf(wTrainHeadLogSecRLockId); + + + /*㳵ͷڽ·(նźŻ)ʣµȫ߼*/ + for (ii = 0U; ii < RouteLogSectionSum; ii++) + { + if ((wTrainHeadBelongLogSec == RouteLogSectionIdBuf[ii]) && (0U == wFlag)) + { + wFlag = 1U; /*·߼Σ鵽˳ͷ߼λãпʼ¼Ҫ͵߼*/ + for (jj = 0U; jj < chVobcBackUpLogSum; jj++) + { + if (RouteLogSectionIdBuf[ii] == wVobcBackUpLogID[jj]) + { + break; /*ͷѴ룬ٴ*/ + } + } + /*ͷδ룬Ҫһ*/ + if ((jj == chVobcBackUpLogSum) && (TRAIN_ABL_LOGSEC_SUM > chVobcBackUpLogSum)) + { + wVobcBackUpLogID[chVobcBackUpLogSum] = RouteLogSectionIdBuf[ii]; + chVobcBackUpLogSum++; + } + } + else + { + + } + /*ҵ˳ͷʼ棬ͷ߼Ѵ룬ٴ*/ + if ((1U == wFlag) && (TRAIN_ABL_LOGSEC_SUM > chVobcBackUpLogSum) && (wTrainHeadBelongLogSec != RouteLogSectionIdBuf[ii])) + { + wVobcBackUpLogID[chVobcBackUpLogSum] = RouteLogSectionIdBuf[ii]; + chVobcBackUpLogSum++; + } + } + + /*Ҫ͵߼Ϣ*/ + for (ii = 0U; ii < chVobcBackUpLogSum; ii++) + { + chLogSecBelSendRange = CheckLogSecBelSendRange(wVobcBackUpLogID[ii]); + if (CI_ERROR == chLogSecBelSendRange) + { + ablVobcBackUpLogSecStr[chTrainAblRelLogSecNum].chAblRelLogSecDir = GetLogSecLockDir(wVobcBackUpLogID[ii]); + ablVobcBackUpLogSecStr[chTrainAblRelLogSecNum].wAblRelLogSecId = wVobcBackUpLogID[ii]; + chTrainAblRelLogSecNum++; + } + else + { + ;/**/ + } + } + + SetTrainAblRelLogSecNum(wTrainId, chTrainAblRelLogSecNum); /*Ҫ͵߼*/ + SetTrainAblRelLogSecData(wTrainId, ablVobcBackUpLogSecStr); + + if (0U != wTrainHeadLogSecRLockId) + { + /*ý½·Ϣ*/ + for (ii = 0U; ii < wTrainOccLogSum; ii++) + { + wVobcBackUpRouteID = GetLogSecLockBelongRoute(wTrainOccLogID[ii]); + for (jj = 0U; jj < chVobcBackUpRouteSum; jj++) + { + if (wVobcBackUpRouteID == ablVobcBackUpRouteStr[jj].wAblRelRouteId) + { + break; /*ȥأֹ·*/ + } + } + + if ((jj == chVobcBackUpRouteSum) && (TRAIN_ABL_ALLROUTE_SUM > chVobcBackUpRouteSum) && (0U != wVobcBackUpRouteID)) + { + ablVobcBackUpRouteStr[chVobcBackUpRouteSum].wAblRelRouteId = wVobcBackUpRouteID; + ablVobcBackUpRouteStr[chVobcBackUpRouteSum].chAblRelTrainInFlag = TRAIN_ABL_ROUTE_FLAG_YES; + chVobcBackUpRouteSum++; + } + } + SetTrainAblAllRouteNum(wTrainId, chVobcBackUpRouteSum); + SetTrainAblRelAllRouteData(wTrainId, ablVobcBackUpRouteStr); + } + else + { + ; /*ͷڵĿӽ½·*/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* гͽ·Ϣ(۷·Ҫ¼۷߼Ϣ) +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240710 +*/ +void VobcBackUpRouteManage(const UINT16 wTrainId) +{ + UINT16 TrainMaxSafeHeadLink = 0U; + UINT16 wTrainHeadLogSecRLockId = 0U; + UINT8 wFlag = 1U; + UINT16 RouteLeavePhySecId = 0U; /*·ȥ*/ + UINT16 chVobcBackUpRouteId = 0U; + UINT8 ablVobcBackUpRouteNum = 0U; + ABLTrainRelAllRouteStru ablVobcBackUpRouteStr[TRAIN_ABL_ALLROUTE_SUM] = { 0U }; + ABLTrainRelAllRouteStru* ablVobcBackUpTrainRouteStr = NULL; + UINT8 RouteState = 0U; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 mm = 0U; + UINT16 chVobcBackReturnRouteId = 0U; + UINT8 RouteType = 0U; + UINT8 ablVobcBackUpReturnLogSum = 0U; + UINT16 ablVobcBackUpReturnLogBuf[TRAIN_ABL_RETURNLOGSEC_SUM] = { 0U }; + UINT16 RouteLastPhySectionId = 0u; + UINT16 nlockSectionId = 0U; + UINT16 validReturnSigId = 0U; + UINT16* PhySecIncLogSecIdBuf = NULL; + UINT8 PhySecIncLogSecSum = 0U; + UINT16 chPreRouteEndSignalId = 0U; + UINT16 chNextRouteStartSignalId = 0U; + UINT8 chLocalCiId = 0U; + UINT16 wOutFirstPhySec = 0U; + UINT16 wTrainHeadBelongLogSec = 0U; + UINT8 chRouteCiId = 0U; + UINT8 chPhyCiId = 0U; + UINT8 chTrainLocReverseRouteFlag = 0U; + UINT8 chRouteReverseFlag = 0U; + UINT8 chRouteLevel = 0U; + struct_PathPoint end = { 0U }; /*г߼յ*/ + + if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + chLocalCiId = GetSystemParaLocalCiId(); + /*ͷڽ·*/ + TrainMaxSafeHeadLink = GetAblTrainMaxHeadLink(wTrainId); + end.wLinkId = TrainMaxSafeHeadLink; + end.dwOffset = GetAblTrainMaxHeadOffset(wTrainId); + /*ͷڵ߼*/ + wTrainHeadBelongLogSec = GetPointBelongLogSec(end); + wTrainHeadLogSecRLockId = GetLogSecLockBelongRoute(wTrainHeadBelongLogSec); + + ablVobcBackUpRouteNum = GetTrainAblAllRouteNum(wTrainId); + ablVobcBackUpTrainRouteStr = GetTrainAblRelAllRouteData(wTrainId); + + /*½·ֲ*/ + (void)CommonMemCpy(ablVobcBackUpRouteStr, (UINT32)(sizeof(ABLTrainRelAllRouteStru)*TRAIN_ABL_ALLROUTE_SUM), + ablVobcBackUpTrainRouteStr, (UINT32)(sizeof(ABLTrainRelAllRouteStru)*ablVobcBackUpRouteNum)); + + /*鳵ͷڽ·ͣΪ۷·ҪȥΪ۷Ľ·*/ + RouteType = GetRouteType(wTrainHeadLogSecRLockId); + + if (ROUTE_TYPE_RETURN == RouteType) + { + nlockSectionId = GetRouteFirstNormalLockSection(wTrainHeadLogSecRLockId); /*һڵǰ·ġա*/ + validReturnSigId = GetValidReturnSinalId(wTrainHeadLogSecRLockId, nlockSectionId); /*Ч۷źŻ*/ + RouteLeavePhySecId = GetSignalInFirstLockedPhySecId(validReturnSigId); /*۳Σ۷·ȥ*/ + chPreRouteEndSignalId = validReturnSigId; /*۷·նźŻΪ۳źŻ*/ + } + else + { + /*鳵ͷڽ·ȥΣ²ѯ·*/ + RouteLeavePhySecId = GetRouteLeavePhySecId(wTrainHeadLogSecRLockId); + chPreRouteEndSignalId = GetRouteEndSignalId(wTrainHeadLogSecRLockId); + } + chTrainLocReverseRouteFlag = GetTrainLocReverseRouteFlag(wTrainId); + /*ѯͷǰĽ· Ϊ·ʱѯ*/ + while ((1U == wFlag)&&(TRAIN_LOC_REV_ROUTE_FLAG_NO ==chTrainLocReverseRouteFlag)) + { + chVobcBackUpRouteId = GetPhySecRLockBelongRouteId(RouteLeavePhySecId); + chRouteCiId = GetRouteBelongCiId(chVobcBackUpRouteId); + RouteState = GetRouteState(chVobcBackUpRouteId); + chNextRouteStartSignalId = GetRouteStartSignalId(chVobcBackUpRouteId); + wOutFirstPhySec = GetSignalOutFirstPhySecId(chNextRouteStartSignalId); + chPhyCiId = GetPhySecBelongCiId(wOutFirstPhySec); + chRouteReverseFlag = GetRouteReverseProperty(chVobcBackUpRouteId); + chRouteLevel = GetRouteLevel(chVobcBackUpRouteId); + + if ((ROUTE_STATE_NEAR_OPEN == RouteState) && (TRAIN_ABL_ALLROUTE_SUM > ablVobcBackUpRouteNum) + && (chVobcBackUpRouteId != wTrainHeadLogSecRLockId) /*ȥյĽ·Ϊ½·ֹ۷½·*/ + && (chNextRouteStartSignalId == chPreRouteEndSignalId) + && (ROUTE_LEVEL_BLOC == chRouteLevel) + && (ROUTE_REVERSE_PROPERTY_NO ==chRouteReverseFlag) /*ǰ·Ϊ·*/ + && ((chPhyCiId == chLocalCiId) || (chRouteCiId == chLocalCiId))) + {/*Ƚһս·ʼźŻΪǰһ·ֹźŻ(۳źŻ)֤ȥյĽ·ͳͷһ£һ··ⷽһһڱ*/ + /*·ӽţ·ID*/ + ablVobcBackUpRouteStr[ablVobcBackUpRouteNum].wAblRelRouteId = chVobcBackUpRouteId; + ablVobcBackUpRouteStr[ablVobcBackUpRouteNum].chAblRelTrainInFlag = TRAIN_ABL_ROUTE_FLAG_NO; + ablVobcBackUpRouteNum++; + + /*½·ȥ,½·նźŻ*/ + RouteLeavePhySecId = GetRouteLeavePhySecId(chVobcBackUpRouteId); + chPreRouteEndSignalId = GetRouteEndSignalId(chVobcBackUpRouteId); + + wFlag = 1U; + } + else + { + wFlag = 0U; /*·Ϊӽţ·ޣ½·۷۷Ľ·û죬ѭ*/ + } + } + SetTrainAblAllRouteNum(wTrainId, ablVobcBackUpRouteNum); + SetTrainAblRelAllRouteData(wTrainId, ablVobcBackUpRouteStr); + + /*Ҫ͵н·Ƿ۷·۷·Ҫ͵۷߼*/ + for (ii = 0U; ii < ablVobcBackUpRouteNum; ii++) + { + chVobcBackReturnRouteId = ablVobcBackUpTrainRouteStr[ii].wAblRelRouteId; + RouteType = GetRouteType(chVobcBackReturnRouteId); + /*۷·۷߼Σ۷*/ + if (ROUTE_TYPE_RETURN == RouteType) + { + RouteLastPhySectionId = GetRouteLastPhySectionId(chVobcBackReturnRouteId); + PhySecIncLogSecSum = GetPhySecIncLogSecSum(RouteLastPhySectionId); + PhySecIncLogSecIdBuf = GetPhySecIncLogSecIdBuf(RouteLastPhySectionId); + /*۷·۷δ*/ + if (TRAIN_ABL_RETURNLOGSEC_SUM > ablVobcBackUpReturnLogSum) + { + for (jj = 0U; jj < PhySecIncLogSecSum; jj++) + { + for (mm = 0U; mm < ablVobcBackUpReturnLogSum; mm++) + { + if (PhySecIncLogSecIdBuf[jj] == ablVobcBackUpReturnLogBuf[mm]) + { + break;/*Ѿ*/ + } + else + { + ; /**/ + } + } + if (ablVobcBackUpReturnLogSum == mm) + { + /*˵δظ*/ + ablVobcBackUpReturnLogBuf[ablVobcBackUpReturnLogSum] = PhySecIncLogSecIdBuf[jj]; + ablVobcBackUpReturnLogSum++; + } + else + { + ; /*Ѿڲ*/ + } + } + } + else + { + ; /*Ҫ͵۷߼*/ + } + } + else + { + ; /*۷·۷Ϣ*/ + } + } + + SetTrainAblRelReturnLogNum(wTrainId, ablVobcBackUpReturnLogSum); + SetTrainAblRelReturnLogId(wTrainId, ablVobcBackUpReturnLogBuf); + } + else + { + ; /**/ + } +} + +/* +* гͱϢ +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240710 +*/ +void VobcBackUpProSecManage(const UINT16 wTrainId) +{ + UINT8 chReval = CI_ERROR; + UINT8 chAblRouteNum = 0U;/*ABLгӦ·Ŀ*/ + ABLTrainRelAllRouteStru* pAblRouteData = NULL;/*ABLгӦ·*/ + UINT8 ii = 0U; + UINT16 wRouteOverlapLockId = 0U;/*·ձID*/ + ABLTrainRelProSecStru szTempProSecData[TRAIN_ABL_PROSEC_SUM] = {0U};/*ʱ*/ + UINT8 chAblProSecNum = 0U;/*Ŀ*/ + UINT8 chOverlapLogSecSum = 0U;/*ζӦ߼Ŀ*/ + UINT16* wOverlapLogSecIdBuf = NULL;/*ζӦ߼ID*/ + UINT8 chAblProSecLockDir = 0U;/*շ*/ + UINT8 chLogSecProResUseState = 0U;/*߼αԴ״̬*/ + UINT8 jj = 0U; + + if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + /*ÿھݣ*/ + ClearTrainAblRelXiansuData(wTrainId); + + chAblRouteNum = GetTrainAblAllRouteNum(wTrainId); + pAblRouteData = GetTrainAblRelAllRouteData(wTrainId); + + if ((TRAIN_ABL_ALLROUTE_SUM >= chAblRouteNum) && (NULL != pAblRouteData)) + { + for (ii = 0U; ii < chAblRouteNum; ii++) + { + wRouteOverlapLockId = GetRouteOverlapLockedId(pAblRouteData[ii].wAblRelRouteId); + if (0U != wRouteOverlapLockId) + { + chOverlapLogSecSum = GetOverlapLogicSectionSum(wRouteOverlapLockId); + wOverlapLogSecIdBuf = GetOverlapLogicSectionBuf(wRouteOverlapLockId); + + if((0U < chOverlapLogSecSum) && (NULL != wOverlapLogSecIdBuf)) + { + /*߼αԴ״̬ʱѾӦԴ˴ֱӻȡһ߼οü*/ + chLogSecProResUseState = GetLogSecProResUseState(wOverlapLogSecIdBuf[0]); + /*м䲻仯·ͱ֮з仯㣻շΪʵշ*/ + chAblProSecLockDir = GetLogSecLockDir(wOverlapLogSecIdBuf[0U]); + + if ((TRAIN_ABL_PROSEC_SUM > chAblProSecNum) && (LOGIC_SECTION_PRO_RES_USABLE == chLogSecProResUseState)) + { + szTempProSecData[chAblProSecNum].wAblRelProSecId = wRouteOverlapLockId; + szTempProSecData[chAblProSecNum].chAblRelProSecDir = chAblProSecLockDir; + chAblProSecNum++; + } + else + { + ; /*״̬ò*/ + } + + /*ͨʱҪӱ*/ + for (jj = 0U; jj < chOverlapLogSecSum; jj++) + { + AddXiansuPhySecData(wOverlapLogSecIdBuf[jj], wTrainId); + } + } + } + else + { + ; /*˽·ӱ*/ + } + } + + /*洢Ŀ*/ + SetTrainAblRelProSecNum(wTrainId, chAblProSecNum); + SetTrainAblRelProSecData(wTrainId, szTempProSecData); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* гϢ +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240710 +*/ +void VobcBackUpXiansuSecManage(const UINT16 wTrainId) +{ + UINT8 chAblLogSecNum = 0U;/*ABLгӦ߼Ŀ*/ + ABLTrainRelLogStru* pAblLogSecData = NULL;/*ABLгӦ߼*/ + UINT8 chAblRouteNum = 0U;/*ABLгӦ·Ŀ*/ + ABLTrainRelAllRouteStru* pAblRouteData = NULL;/*ABLгӦ·*/ + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT16 wRouteLogSecNum = 0U;/*·߼Ŀ*/ + UINT16* szRouteLogSecIdBuf = NULL;/*·߼ID*/ + UINT8 chOverlopSum = 0U;/*Ŀ*/ + UINT16 wRouteLeavePhySecId = 0U;/*·ȥID*/ + UINT16 wRouteInLastLogSecId = 0U;/*·һ߼ID*/ + UINT8 chPhySecType = 0U;/**/ + UINT16 wLgcSecOrgnLink = 0U;/*߼ʼLINK*/ + UINT16 wLgcSecTmnLink = 0U; /*߼նLINK*/ + UINT16 wStopAreaId = 0U;/*ͣ*/ + UINT8 chRouteLeaveLogSecSum = 0U;/*·ȥζӦ߼Ŀ*/ + UINT16* wRouteLeaveLogSecId = NULL;/*·ȥζӦ߼Id*/ + + if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + /*߼ζӦ*/ + chAblLogSecNum = GetTrainAblRelLogSecNum(wTrainId); + pAblLogSecData = GetTrainAblRelLogData(wTrainId); + + debug_infor_printf((const)"TrainAblRelLogSecNum:num = %d\n", chAblLogSecNum); + + if ((TRAIN_ABL_LOGSEC_SUM >= chAblLogSecNum) && (NULL != pAblLogSecData)) + { + for (ii = 0U; ii < chAblLogSecNum; ii++) + { + debug_infor_printf((const)"GetTrainAblRelLogData:ID = %d\n", pAblLogSecData[ii].wAblRelLogSecId); + AddXiansuPhySecData(pAblLogSecData[ii].wAblRelLogSecId, wTrainId); + } + } + else + { + ; /**/ + } + + /*ӷdz½·ص*/ + chAblRouteNum = GetTrainAblAllRouteNum(wTrainId); + pAblRouteData = GetTrainAblRelAllRouteData(wTrainId); + + debug_infor_printf((const)"chAblRouteAfterNum:num = %d\n", chAblRouteNum); + + if ((0U < chAblRouteNum) && (TRAIN_ABL_ALLROUTE_SUM >= chAblRouteNum) && (NULL != pAblRouteData)) + { + for (ii = 0U; ii < chAblRouteNum; ii++) + { + debug_infor_printf((const)"GetTrainAblRelAllRouteAfterData:ID = %d\n", pAblRouteData[ii].wAblRelRouteId); + wRouteLogSecNum = GetRouteLogSectionSum(pAblRouteData[ii].wAblRelRouteId); + szRouteLogSecIdBuf = GetRouteLogSectionIdBuf(pAblRouteData[ii].wAblRelRouteId); + + if ((MAX_ROUTE_IN_LT_NUM > wRouteLogSecNum) && (NULL != szRouteLogSecIdBuf)) + { + if (TRAIN_ABL_ROUTE_FLAG_NO == pAblRouteData[ii].chAblRelTrainInFlag) + { + for (jj = 0U; jj < wRouteLogSecNum; jj++) + { + AddXiansuPhySecData(szRouteLogSecIdBuf[jj], wTrainId); + } + } + else + { + ; /**/ + } + + } + else + { + ; /**/ + } + + + /*·һΪͣҽ·ޱΣվ޲εϢҲҪ*/ + chOverlopSum = GetRouteOverlapSum(pAblRouteData[ii].wAblRelRouteId); + wRouteLeavePhySecId = GetRouteLeavePhySecId(pAblRouteData[ii].wAblRelRouteId); + chPhySecType = GetPhySecType(wRouteLeavePhySecId); + wRouteInLastLogSecId = GetRouteInLastLogSecId(pAblRouteData[ii].wAblRelRouteId); + + wLgcSecOrgnLink = GetLgcSecOrgnLink(wRouteInLastLogSecId); + wLgcSecTmnLink = GetLgcSecTmnlLink(wRouteInLastLogSecId); + + if ((0U != wLgcSecOrgnLink) && (wLgcSecOrgnLink == wLgcSecTmnLink)) + { + wStopAreaId = GetLinkStopAreaId(wLgcSecOrgnLink); /*ȡlinkͣID*/ + } + else + { + ; /*·һβͣ*/ + } + + if ((0U == chOverlopSum) && (PHYSICAL_SEC_TYPE_NOSWITCH == chPhySecType) && (0U != wStopAreaId)) + { + chRouteLeaveLogSecSum = GetPhySecIncLogSecSum(wRouteLeavePhySecId); + wRouteLeaveLogSecId = GetPhySecIncLogSecIdBuf(wRouteLeavePhySecId); + + if ((PHYSICAL_INCLUDE_LOG_SUM_MAX > chRouteLeaveLogSecSum) && (NULL != wRouteLeaveLogSecId)) + { + for (jj = 0U; jj < chRouteLeaveLogSecSum; jj++) + { + /*ޱұⷽΪ޲,ҽ·һΪͣ*/ + AddXiansuPhySecData(wRouteLeaveLogSecId[jj], wTrainId); + } + } + else + { + ; + } + } + else + { + ; /**/ + } + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ʱ +* ˵ const UINT16 wPhySecId ߼ID +* const UINT16 wTrainId гID +* ֵ +*/ +void AddXiansuPhySecData(const UINT16 wLogSecId,const UINT16 wTrainId) +{ + UINT16 wSpeed = 0U; + UINT16 wLogSecRelPhySecId = 0U;/*߼ιID*/ + UINT8 chPhySecFlockState = 0U;/*η״̬*/ + UINT8 chPhySecFlockType = 0U;/*η*/ + UINT8 chPhySecAreaUrgentState = 0U;/*ƶ״̬*/ + UINT8 chAddFlag = CI_ERROR;/*ӱ־*/ + UINT8 chTsrDataSpeed = 0U;/*ʱٶȡֵ*/ + UINT8 chAblXiansuPhyNum = 0U;/*ʱĿ*/ + ABLTrainRelXianSuStru* pTempXiansuPhySecData = NULL;/*ʱĿ*/ + UINT8 ii = 0U; + ABLTrainRelXianSuStru strAddXiansuPhySecData = {0U};/**/ + + if ((0U < wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId)) + { + wLogSecRelPhySecId = GetLgcSecRelativePhySecId(wLogSecId); + + if ((0U < wLogSecRelPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wLogSecRelPhySecId)) + { + chPhySecFlockState = GetPhySecFLockState(wLogSecRelPhySecId); + chPhySecFlockType = GetPhySecFLockType(wLogSecRelPhySecId); + chPhySecAreaUrgentState = GetPhySecAreaUrgentState(wLogSecRelPhySecId); + + if (((PHYSICAL_SECTION_FLOCK_YES == chPhySecFlockState) && ((PHY_SEC_FLOCK_TYPE_CMD == chPhySecFlockType) || (PHY_SEC_FLOCK_TYPE_SPKSCMD == chPhySecFlockType))) + || (PHYSEC_AREA_URGENT_YES == chPhySecAreaUrgentState)) + { + chAddFlag = CI_SUCCESS; + wSpeed = 0U; + } + else + { + /*ʵֵ*/ + chTsrDataSpeed = GetPhySecMinXiansuSpeed(wLogSecRelPhySecId); + + if ((0U != chTsrDataSpeed) && (UINT8_MAX != chTsrDataSpeed)) + { + chAddFlag = CI_SUCCESS; + wSpeed = (UINT16)chTsrDataSpeed; + } + else + { + ; /*ٻǷ*/ + } + } + + chAblXiansuPhyNum = GetTrainAblRelXianSuNum(wTrainId); + pTempXiansuPhySecData = GetTrainAblRelXiansuData(wTrainId); + + if ((TRAIN_ABL_XIANSUSEC_SUM > chAblXiansuPhyNum) && (NULL != pTempXiansuPhySecData) && (CI_SUCCESS == chAddFlag)) + { + for (ii = 0U; ii < chAblXiansuPhyNum; ii++) + { + if (wLogSecRelPhySecId == pTempXiansuPhySecData[ii].wAblRelXianSuPhySecId) + { + if (0U == wSpeed) + { + /*0˵˹ƶͬʱЧʱ٣ҪȡֵΪ0*/ + strAddXiansuPhySecData.wAblRelXianSuPhySecId = wLogSecRelPhySecId; + strAddXiansuPhySecData.chAblRelXianSuValue = 0U; + SetTrainAblRelIndexXiansuData(wTrainId, ii, strAddXiansuPhySecData); + } + else if (wSpeed < pTempXiansuPhySecData[ii].chAblRelXianSuValue) + { + /*ٱԭҪС޸ΪС*/ + strAddXiansuPhySecData.wAblRelXianSuPhySecId = wLogSecRelPhySecId; + strAddXiansuPhySecData.chAblRelXianSuValue = wSpeed; + SetTrainAblRelIndexXiansuData(wTrainId, ii, strAddXiansuPhySecData); + } + else + { + /*ֻҪԭ洢˾Ͳٱ޸*/ + ; + } + break; + } + else + { + ; /**/ + } + } + + if (chAblXiansuPhyNum == ii) + { + /*˵ǰ޴εʱϢ*/ + strAddXiansuPhySecData.wAblRelXianSuPhySecId = wLogSecRelPhySecId; + strAddXiansuPhySecData.chAblRelXianSuValue = wSpeed; + + /*ʱҪ*/ + SetTrainAblRelXiansuData(wTrainId, strAddXiansuPhySecData); + } + else + { + ; /*Ѵڣ*/ + } + } + else + { + ; /**/ + } + + } + else + { + ; /*Ϸ*/ + } + } + else + { + ; /**/ + } +} + + +/* +* гŻESBϢ +* ˵ UINT16 wTrainId гid +* ֵ +*/ +void VobcBackUpPsdEsbManage(UINT16 wTrainId) +{ + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT8 funRetPsd = CI_ERROR; + UINT8 funRetEsb = CI_ERROR; + UINT8 chAblPsdNum = 0U;/*ABLгӦĿ*/ + UINT8 chAblEsbNum = 0U;/*ABLгӦťĿ*/ + + UINT8 chAblLogNum = 0U; /*г߼Ŀ*/ + UINT16 chRouteLogNum = 0u; /*·߼Ŀ*/ + ABLTrainRelPsdStru tmpABLTrainPsdData[TRAIN_ABL_PSD_SUM] = { 0U };/*ABLгPSDʱ*/ + ABLTrainRelEsbStru tmpABLTrainEsbData[TRAIN_ABL_ESB_SUM] = { 0U };/*ABLгEsbʱ*/ + UINT16 tmplogSecData[2*MAX_ROUTE_IN_LT_NUM] = { 0 };/*г߼ʱ*/ + ABLTrainRelLogStru* pAblLogData = NULL; /*ABLг߼*/ + ABLTrainRelAllRouteStru* pAblRouteData = NULL;/*ABLгӦ·*/ + UINT8 chAblRouteNum = 0U;/*ABLгӦ·Ŀ*/ + + UINT16 logSecId = 0U;/*߼ID*/ + UINT8 logSecSum = 0U; /*߼*/ + UINT16* pLogSecBuff = NULL; + + pAblLogData = GetTrainAblRelLogData(wTrainId); + chAblLogNum = GetTrainAblRelLogSecNum(wTrainId); + /**/ + + SetTrainAblRelPsdNum(wTrainId, 0); + SetTrainAblRelPsdData(wTrainId, tmpABLTrainPsdData); + SetTrainAblRelEsbNum(wTrainId, 0); + SetTrainAblRelEsbId(wTrainId, tmpABLTrainEsbData); + + debug_infor_printf((const)"ABLESB_PSDInfo: Train :%d\n", wTrainId); + /*ӽ߼*/ + if ((NULL != pAblLogData) && (TRAIN_ABL_LOGSEC_SUM >= chAblLogNum)) + { + for (ii = 0U; ii < chAblLogNum; ii++) + { + tmplogSecData[logSecSum] = pAblLogData[ii].wAblRelLogSecId; + logSecSum++; + } + } + else + { + ; /*Դ߼*/ + } + + /*ӷdz½·߼*/ + chAblRouteNum = GetTrainAblAllRouteNum(wTrainId); + pAblRouteData = GetTrainAblRelAllRouteData(wTrainId); + + if ((TRAIN_ABL_ALLROUTE_SUM >= chAblRouteNum) && (NULL != pAblRouteData)) + { + for (ii = 0U; ii < chAblRouteNum; ii++) + { + if (TRAIN_ABL_ROUTE_FLAG_NO == pAblRouteData[ii].chAblRelTrainInFlag) + { + /*ȡ·߼*/ + chRouteLogNum = GetRouteLogSectionSum(pAblRouteData[ii].wAblRelRouteId); + pLogSecBuff = GetRouteLogSectionIdBuf(pAblRouteData[ii].wAblRelRouteId); + if ((0U < chRouteLogNum) && (NULL != pLogSecBuff)) + { /*߼*/ + for (jj = 0U; jj < chRouteLogNum; jj++) + { + logSecId = pLogSecBuff[jj]; + tmplogSecData[logSecSum] = logSecId; + logSecSum++; + } + } + else + { + ; /*Ƿֵ*/ + } + } + else + { + ; /* Ѵ*/ + } + } + } + else + { + ; /*޿ý·*/ + } + + /*߼ 洢ӦPSDSEBݲȥ*/ + if (0U < logSecSum) + { + for (ii = 0U; ii < logSecSum; ii++) + { + logSecId = tmplogSecData[ii]; + /*洢PSDĿ*/ + funRetPsd = AddABLPsdInfo(logSecId, tmpABLTrainPsdData, chAblPsdNum); + if (0U != funRetPsd) + { + chAblPsdNum+= funRetPsd; /*ӳɹ*/ + debug_infor_printf((const)"\n--(logSec:%d -PsdNum :%d)\n", logSecId, funRetPsd); + } + else + { + ; /*PSD״̬Ƿӻ*/ + } + /*ESBӲȥ*/ + funRetEsb = AddABLEsbInfo(logSecId, tmpABLTrainEsbData, chAblEsbNum); + if (0U != funRetEsb) + { + chAblEsbNum+= funRetEsb; /*ӳɹ*/ + debug_infor_printf((const)"\n--(logSec:%d -EsbNum :%d)\n", logSecId, funRetEsb); + } + else + { + ; /*ESD״̬Ƿӻ*/ + } + } + } + else + { + ; /*Դ߼*/ + } + + /*洢PSDĿ*/ + SetTrainAblRelPsdNum(wTrainId, chAblPsdNum); + SetTrainAblRelPsdData(wTrainId, tmpABLTrainPsdData); + + /*洢ESBĿ*/ + SetTrainAblRelEsbNum(wTrainId, chAblEsbNum); + SetTrainAblRelEsbId(wTrainId, tmpABLTrainEsbData); +} + +/* +* : ߼PSDϢ +* ˵ const UINT16 , logSecID ߼ID +* ABLTrainRelPsdStru* tmpAblPsdData PsdϢ +* UINT8 ablPsdNum Psd +* ֵ >0ӵĸ 0:ߴ +*/ +UINT8 AddABLPsdInfo(const UINT16 logSecID, ABLTrainRelPsdStru* tmpAblPsdData, const UINT8 ablPsdNum) +{ + UINT8 tmpPsdNumSum = 0U; + UINT8 index = 0U; + UINT8 keepwork = CI_ERROR; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 chFlag = CI_SUCCESS; + UINT8 chLogPsdNum = 0U; /*߼PsdĿ*/ + UINT8 chPsdMutualLockStat = 0U; /**/ + /*PSD*/ + UINT16 PsdId = 0U; + UINT8 PsdState = 0U; + UINT8 chCheckResult = 0U;/**/ + + if ((0U == logSecID) ||(LOGIC_SECTION_SUM_MAX < logSecID)|| (NULL == tmpAblPsdData)) + { + keepwork = CI_ERROR; + } + else + { + keepwork = CI_SUCCESS; + } + + if (CI_SUCCESS == keepwork) + { + chLogPsdNum = GetLogSecPsdSum(logSecID); + /*߼ԴPSD*/ + if (LOGSEC_RELATE_PSD_MAX >= chLogPsdNum) + { + for (ii = 0U; ii < chLogPsdNum; ii++) + { + PsdId = GetLogSecPsdByIdx(logSecID, ii); + if (0U < PsdId) + { + chCheckResult = CheckPsdBelSendRange(PsdId); + if (CI_ERROR == chCheckResult) + { + PsdState = GetPsdState(PsdId); + /*ȥ*/ + chFlag = CI_SUCCESS; + index = ablPsdNum + tmpPsdNumSum; + for (jj = 0U; jj < index; jj++) + { + if (tmpAblPsdData[jj].wAblRelPsdId == PsdId) + { + chFlag = CI_ERROR; + break; + } + } + + /*Ҫ*/ + if (CI_SUCCESS == chFlag) + { + if (TRAIN_ABL_PSD_SUM > index) + { + chPsdMutualLockStat = GetPsdMutualLockRemoveState(PsdId); + if ((PSD_STATE_CLOSE == PsdState) || (PSD_MUTUALLOCK_REMOVE_YES == chPsdMutualLockStat)) + { + PsdState = CI_IVOC_PSD_STATE_CLOSE; + } + else + { + PsdState = CI_IVOC_PSD_STATE_OPEN;/*״̬ǷŴ*/ + } + tmpAblPsdData[index].wAblRelPsdId = PsdId; + tmpAblPsdData[index].chAblRelPsdSta = PsdState; + debug_infor_printf((const)"--(Psd : -%d )", PsdId); + tmpPsdNumSum++; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + else + { + ; /*䷶Χ*/ + } + + } + } + } + else + { + ; /*򲻿*/ + } + } + return tmpPsdNumSum; +} + +/* +* : ij߼ESBϢ +* ˵ const UINT16 , logSecID ߼ID +* ABLTrainRelEsbStru* tmpAblEsbData EsbϢ +* UINT8 ablEsbNum Esb +* ֵ >0ӵĸ 0:ߴ +*/ +UINT8 AddABLEsbInfo(const UINT16 logSecID, ABLTrainRelEsbStru* tmpAblEsbData, const UINT8 ablEsbNum) +{ + UINT8 tmpEsbNumSum = 0U; + UINT8 index = 0U; + UINT8 keepWork = CI_ERROR; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 chFlag = CI_SUCCESS; + UINT8 chLogEsbNum = 0U; /*߼EsbĿ*/ + UINT8 chCheckResult = 0U;/**/ + UINT8 chEsbCutState = 0U; + + /*ESB*/ + UINT16 EsbId = 0U; + UINT8 EsbState = 0U; + + if ((0U == logSecID) || (LOGIC_SECTION_SUM_MAX < logSecID) || (NULL ==tmpAblEsbData)) + { + keepWork = CI_ERROR; + } + else + { + keepWork = CI_SUCCESS; + } + + if (CI_SUCCESS == keepWork) + { + chLogEsbNum = GetLogSecEsbSum(logSecID); + /*߼ԴESB*/ + if (LOGSEC_RELATE_ESB_MAX >= chLogEsbNum) + { + for (ii = 0U; ii < chLogEsbNum; ii++) + { + EsbId = GetLogSecEsbByIdx(logSecID, ii); + if ((0U < EsbId) && (ESB_SUM_MAX > EsbId)) + { + chCheckResult = CheckEsbBelSendRange(EsbId); + if (CI_ERROR == chCheckResult) + { + EsbState = GetEsbState(EsbId); + chEsbCutState = GetEsbCutState(EsbId); + /*ȥ*/ + chFlag = CI_SUCCESS; + index = tmpEsbNumSum + ablEsbNum; + for (jj = 0U; jj < index; jj++) + { + if (tmpAblEsbData[jj].wAblRelEsbId == EsbId) + { + chFlag = CI_ERROR; + break; + } + } + + /*Ҫ*/ + if (CI_SUCCESS == chFlag) + { + if ((TRAIN_ABL_ESB_SUM > index) && + ((ESB_STATE_VALID_YES == EsbState) || (ESB_STATE_VALID_NO == EsbState)) + && ((ESB_CUT_YES == chEsbCutState) || (ESB_CUT_NO == chEsbCutState))) + { + tmpAblEsbData[index].wAblRelEsbId = EsbId; + + if (ESB_CUT_YES == chEsbCutState) + { + EsbState = CI_IVOC_ESB_STATE_INVALID; + } + else + { + if (ESB_STATE_VALID_NO == EsbState) + { + EsbState = CI_IVOC_ESB_STATE_INVALID; + } + else + { + EsbState = CI_IVOC_ESB_STATE_VALID; + } + } + + tmpAblEsbData[index].chAblRelEsbSta = EsbState; + debug_infor_printf((const)"--(Esb : -%d )", EsbId); + tmpEsbNumSum++; + } + else + { + ; /*״̬ò*/ + } + } + else + { + ; /**/ + } + } + else + { + ; /*ڴ䷶Χ*/ + } + } + else + { + ; /*ݷǷ*/ + } + } + } + else + { + ; /*򲻿*/ + } + } + return tmpEsbNumSum; +} + +#if 0 +/* +* г͵Ϣ +* ˵ VobcBackUpToCiDataStruct* VobcBackUpToCiDataStr гϢṹ +* ֵ +* Create: fan 2024.4.12 +*/ +void VoBcBackUpSwitchManage(VobcBackUpToCiDataStruct* VobcBackUpToCiDataStr) +{ + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT16 wlogSecId = 0U; /*߼Id*/ + UINT16 wLogSecRelPhySecId = 0U; /*߼ι*/ + UINT16 wRouteId = 0u; + UINT16 wTrainId = VobcBackUpToCiDataStr->VobcId; + UINT16 switchId = 0U; + UINT8 funRet = 0U; /*ӵֵ*/ + UINT8 chAddSwitchRet = 0U;/*l߼εֵ*/ + UINT8 keepWork = CI_ERROR; + UINT8 chPhySwitchNum = 0U; /*εĿ*/ + UINT16* wPhySwitchBuf = NULL; /*ε*/ + UINT16 wlogNum = 0U; /*߼Ŀ*/ + UINT16* wLogSecBuf = NULL; /*߼*/ + + UINT16 wOverlapId = 0U; /*·ձ*/ + + UINT8 chAblSwitchNum = 0U;/*ABLгĿ*/ + UINT8 chAblLogNum = 0U; /*г߼Ŀ*/ + UINT8 chAblRouteNum = 0U;/*ABLгӦ·Ŀ*/ + UINT16 wSwitchSum = 0U; /*Ŀ*/ + ABLTrainRelAllRouteStru* pAblRouteData = NULL;/*ABLгӦ·*/ + ABLTrainRelSwitchStru tmpABLTrainSwitchData[TRAIN_ABL_SWITCH_SUM] = { 0U };/*ABLгʱ*/ + ABLTrainRelLogStru* pAblLogData = NULL; /*ABLг߼*/ + + + pAblLogData = GetTrainAblRelLogData(wTrainId); + chAblLogNum = GetTrainAblRelLogSecNum(wTrainId); + debug_infor_printf((const)"ABLSwitchInfo: Train :%d", wTrainId); + if ((TRAIN_ABL_LOGSEC_SUM >= chAblLogNum) && (NULL != pAblLogData)) + { + keepWork = CI_SUCCESS; + for (ii = 0U; ii < chAblLogNum; ii++) + { + wlogSecId = pAblLogData[ii].wAblRelLogSecId; + wLogSecRelPhySecId = GetLgcSecRelativePhySecId(wlogSecId); + /*ȡ߼ι*/ + if ((0U < wLogSecRelPhySecId) && ( PHYSICAL_SECTION_SUM_MAX>wLogSecRelPhySecId)) + { + /*ι*/ + chPhySwitchNum = GetPhyIncludeSwitchSum(wLogSecRelPhySecId); + wPhySwitchBuf = GetPhySecIncludeSwitch(wLogSecRelPhySecId); + if ((NULL != wPhySwitchBuf) &&(0U < chPhySwitchNum)) + { + for (jj = 0U; jj < chPhySwitchNum; jj++) + { + switchId = wPhySwitchBuf[jj]; + funRet = AddABLSwitchInfo(switchId, tmpABLTrainSwitchData, chAblSwitchNum); + if (CI_SUCCESS == funRet) + { + chAblSwitchNum++; /*ӳɹ*/ + debug_infor_printf((const)"-( %d, PhySec: %d)", switchId, wLogSecRelPhySecId); + } + else + { + ; /*ݷǷ*/ + } + } + } + } + else + { + /*ݷǷ*/ + keepWork = CI_ERROR; + } + } + } + else + { + /*Դ߼ݷǷ*/ + keepWork = CI_ERROR; + } + + /*ӱε&dz½·صĵ*/ + chAblRouteNum = GetTrainAblAllRouteNum(wTrainId); + pAblRouteData = GetTrainAblRelAllRouteData(wTrainId); + + if ((TRAIN_ABL_ALLROUTE_SUM >= chAblRouteNum) && (NULL != pAblRouteData)) + { + for (ii = 0U; ii < chAblRouteNum; ii++) + { + if (TRAIN_ABL_ROUTE_FLAG_NO == pAblRouteData[ii].chAblRelTrainInFlag) + { + /*ȡdz½·߼*/ + wlogNum = GetRouteLogSectionSum(pAblRouteData[ii].wAblRelRouteId); + wLogSecBuf = GetRouteLogSectionIdBuf(pAblRouteData[ii].wAblRelRouteId); + + if ((NULL != wLogSecBuf) && (0U < wlogNum)&&(MAX_ROUTE_IN_LT_NUM>=wlogNum)) + { + chAddSwitchRet = AddLogBelongPhySecABLSwitchInfo(wlogNum, wLogSecBuf, tmpABLTrainSwitchData, chAblSwitchNum); + chAblSwitchNum += chAddSwitchRet; /**/ + } + } + else + { + ; /*߼εѴ*/ + } + + /*ȡεĵĵ*/ + wOverlapId = GetRouteOverlapLockedId(pAblRouteData[ii].wAblRelRouteId); + if (0U < wOverlapId) + { + wlogNum = (UINT16)GetOverlapLogicSectionSum(wOverlapId); + wLogSecBuf = GetOverlapLogicSectionBuf(wOverlapId); + if ((NULL != wLogSecBuf) && (0U < wlogNum) && (OVLP_LOGICSECTION_SUM_MAX >= wlogNum)) + { + chAddSwitchRet = AddLogBelongPhySecABLSwitchInfo(wlogNum, wLogSecBuf, tmpABLTrainSwitchData, chAblSwitchNum); + chAblSwitchNum += chAddSwitchRet; /**/ + } + } + else + { + ; /*ޱβ*/ + } + } + } + else + { + /*г·ݷǷ*/ + keepWork = CI_ERROR; + } + /*жϳͷ*/ + wLogSecRelPhySecId = GetLinkRelatedPhySec(VobcBackUpToCiDataStr->wTrainMaxSafeHeadLink); + wRouteId = GetPhySecRLockBelongRouteId(wLogSecRelPhySecId); + if ((PHYSICAL_SECTION_SUM_MAX < wLogSecRelPhySecId) || (0U == wLogSecRelPhySecId)) + { + keepWork = CI_ERROR; + } + else if (0u == wRouteId) + { + /*ͷս·ӱڿе*/ + debug_infor_printf((const)"-( Train Head PhySec Not Lock)"); + wSwitchSum = GetTotalSwitchCurNum(); + if (SWITCH_SUM_MAX >= wSwitchSum) + { + for (ii = 0U; ii < wSwitchSum; ii++) + { + switchId = GetSwitchId(ii); + + funRet = AddABLSwitchInfo(switchId, tmpABLTrainSwitchData, chAblSwitchNum); + if (CI_SUCCESS == funRet) + { + chAblSwitchNum++; /*ӳɹ*/ + } + } + } + } + else + { + ; /**/ + } + debug_infor_printf((const)"\n"); + if (CI_SUCCESS == keepWork) + { + /*洢*/ + SetTrainAblRelSwitchNum(wTrainId, chAblSwitchNum); + SetTrainAblRelSwitchData(wTrainId, tmpABLTrainSwitchData); + } +} + + +/* +* ABL +* ˵ const UINT16 switchID, ID +* ABLTrainRelSwitchStru* tmpAblSwitchData Ϣ +* UINT8 tmpSwitchNum ӵ +* ֵ CI_SUCCESS CI_ERRORδı +* Create: fan 2024.4.12 +*/ +UINT8 AddABLSwitchInfo(const UINT16 switchID, ABLTrainRelSwitchStru* tmpAblSwitchData, UINT16 tmpSwitchNum) +{ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 switchState = 0U; + UINT8 chAblSwitchState = 0U; + UINT16 wTotalSwitchSum = 0U; /*Ŀ*/ + UINT16 switchCheckId = 0U; + + + if ((NULL == tmpAblSwitchData)||(0U == switchID)) + { + retVal = CI_ERROR; /*μʧ*/ + } + else + { + retVal = CI_SUCCESS; + /*ǷѾ*/ + for (ii = 0U; ii < tmpSwitchNum; ii++) + { + if (switchID == tmpAblSwitchData[ii].wAblRelSwitchId) + { + retVal = CI_ERROR; + break; + } + } + } + if (CI_SUCCESS == retVal) + { + retVal = CI_ERROR; + /*ڱڿ*/ + wTotalSwitchSum = GetTotalSwitchCurNum(); + if (SWITCH_SUM_MAX >= wTotalSwitchSum) + { + for (ii = 0U; ii < wTotalSwitchSum; ii++) + { + switchCheckId = GetSwitchId(ii); + if (switchCheckId == switchID) + { + retVal = CI_SUCCESS;/*ҵ*/ + break; + } + else + { + ; /**/ + } + } + } + } + + /*δӣ״̬*/ + if (CI_SUCCESS == retVal) + { + switchState = GetSwitchCurPosition(switchID); + switch (switchState) + { + case SWITCH_POSITION_DINGWEI: + chAblSwitchState = CI_IVOC_SWITCH_POSTION_DING; + break; + case SWITCH_POSITION_FANWEI: + chAblSwitchState = CI_IVOC_SWITCH_POSTION_FAN; + break; + case SWITCH_POSITION_JICHA: + case SWITCH_POSITION_MOVE: + case SWITCH_POSITION_SIKAI: + case SWITCH_POSITION_INVALID: + chAblSwitchState = CI_IVOC_SWITCH_POSTION_SHIBIAO; + break; + default: + /*״̬*/ + retVal = CI_ERROR; + break; + } + } + + if (CI_SUCCESS == retVal) + { + if (TRAIN_ABL_SWITCH_SUM > tmpSwitchNum) + { + tmpAblSwitchData[tmpSwitchNum].wAblRelSwitchId = switchID; + tmpAblSwitchData[tmpSwitchNum].chAblRelSwitchSta = chAblSwitchState; + } + else + { + /**/ + retVal = CI_ERROR; + } + } + return retVal; +} + +/* +* ߼ȫ +* ˵ +* : UINT8 logSecNum ߼ UINT16* logSecBuf +* : ABLTrainRelSwitchStru* tmpAblSwitchData Ϣ UINT8* chAblSwitchNum +* ֵ >0ӵĸ 0: +* Create: fan 2024.5.21 +*/ +UINT8 AddLogBelongPhySecABLSwitchInfo(UINT16 logSecNum, UINT16* logSecBuf, ABLTrainRelSwitchStru* tmpAblSwitchData, UINT8 chAblSwitchNum) +{ + UINT8 chAddNum= 0U; + UINT16 ii= 0U; + UINT8 jj = 0U; + UINT16 wLogSecRelPhySecId = 0U; + UINT8 chPhySwitchNum = 0U; /*εĿ*/ + UINT16* wPhySwitchBuf = NULL; /*ε*/ + UINT16 switchId = 0U; + UINT8 funRet = CI_ERROR; + if ((NULL != logSecBuf) && (NULL != tmpAblSwitchData)) + { + for (ii = 0U; ii < logSecNum; ii++) + { + wLogSecRelPhySecId = GetLgcSecRelativePhySecId(logSecBuf[ii]); + /*ȡ߼ι*/ + if ((0U < wLogSecRelPhySecId) && (PHYSICAL_SECTION_SUM_MAX>wLogSecRelPhySecId)) + { + /*ι*/ + chPhySwitchNum = GetPhyIncludeSwitchSum(wLogSecRelPhySecId); + wPhySwitchBuf = GetPhySecIncludeSwitch(wLogSecRelPhySecId); + if ((NULL != wPhySwitchBuf) && (0U < chPhySwitchNum)) + { + for (jj = 0U; jj < chPhySwitchNum; jj++) + { + switchId = wPhySwitchBuf[jj]; + funRet = AddABLSwitchInfo(switchId, tmpAblSwitchData, chAblSwitchNum+ chAddNum); + if (CI_SUCCESS == funRet) + { + chAddNum++; /*ӳɹ*/ + debug_infor_printf((const)"-( %d, PhySec: %d)", switchId, wLogSecRelPhySecId); + } + else + { + ; /*ݷǷ*/ + } + } + } + } + else + { + ; /**/ + } + } + } + + return chAddNum; +} +#endif + +/* +* гλ÷· +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240711 +*/ +void VobcLocReverseRouteCheck(const UINT16 wTrainId) +{ + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + struct_PathPoint start = { 0U }; /*г߼*/ + struct_PathPoint end = { 0U }; /*г߼յ*/ + UINT16 wTrainOccLogSum = 0U; /*г߼*/ + UINT16 wTrainOccLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*гռѹ߼ID*/ + UINT16 wVobcBackUpRouteID = 0U;/*·*/ + UINT8 chRouteReverseFlag = 0U;/*·־*/ + + if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + /*ÿΪĬ*/ + SetTrainLocReverseRouteFlag(wTrainId, TRAIN_LOC_REV_ROUTE_FLAG_NONE); + /*βλ*/ + start.wLinkId = GetAblTrainMinTailLink(wTrainId); + start.dwOffset = GetAblTrainMinTailOffset(wTrainId); + + /*ͷλ*/ + end.wLinkId = GetAblTrainMaxHeadLink(wTrainId); + end.dwOffset = GetAblTrainMaxHeadOffset(wTrainId); + chRetVal = GetLogSecBtwTwoPoints(start, end, &wTrainOccLogSum, wTrainOccLogID); + + if (CI_SUCCESS == chRetVal) + { + for (ii = 0U; ii < wTrainOccLogSum; ii++) + { + wVobcBackUpRouteID = GetLogSecLockBelongRoute(wTrainOccLogID[ii]); + + if ((0U < wVobcBackUpRouteID) && (ROUTE_SUM_MAX > wVobcBackUpRouteID)) + { + /*н·ڣ޷ҵñʶΪ*/ + SetTrainLocReverseRouteFlag(wTrainId, TRAIN_LOC_REV_ROUTE_FLAG_NO); + chRouteReverseFlag = GetRouteReverseProperty(wVobcBackUpRouteID); + + if (ROUTE_REVERSE_PROPERTY_YES == chRouteReverseFlag) + { + SetTrainLocReverseRouteFlag(wTrainId, TRAIN_LOC_REV_ROUTE_FLAG_YES); + break; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + } + else + { + ; + } + } + else + { + ; + } +} + + +/* +* гͽ½·߼οϢ +* ˵ const UINT16 wTrainId гID +* ֵ +* by LC +*/ +void VobcBackUpRouteNoOccuManage(const UINT16 wTrainId) +{ + UINT16 ablMaxheadLogSecId = 0U; + UINT16 logBelongRouteId = 0U; + UINT8 checkFlag = CI_ERROR; + UINT16 wOverlapId = 0U; + UINT16 farLogSecId = 0U; + UINT16 lastOverlapLogId = 0U; + UINT16 leaveLogicSecId = 0U; + UINT8 overlapSum = 0U; + UINT8 cEnvelopeNum = 0U; /*гİ*/ + UINT16 szEnvelopeId[TRAIN_REL_ENVELOPE_SUM_MAX] = { 0U }; /*гİID*/ + struct_PathPoint strEnd = { 0U }; + UINT16 wEndLgcId = 0U; + UINT16 wFrontEid = 0U; + UINT16 wBackEid = 0U; + UINT8 chFlag = 0U; + const EnvelopeStruct* pstrEnvelop = NULL; /*гİṹ*/ + const EnvelopeStruct* pFrontEnvelop = NULL; /*гİṹ*/ + + if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + /*鳵ͷռѹǰǷ*/ + cEnvelopeNum = elm_GetTrainRelELM(wTrainId, szEnvelopeId); + if (1U == cEnvelopeNum) + { + pstrEnvelop = elm_GetEnvelopeInfoByID(szEnvelopeId[0U]); + if (NULL != pstrEnvelop) + { + if (0U == pstrEnvelop[0U].headTrainID) + { + checkFlag = rrm_PrepareForwardTrain(pstrEnvelop); + } + else + { + /*ǰ˿ɣʧ*/ + debug_infor_printf((const)"VobcBackUpRouteNoOccuManage: HeadTrain Keyi"); + } + } + } + else if (0U == cEnvelopeNum) + { + /*δѯ磬ĬֵFFFF*/ + farLogSecId = UINT16_MAX; + } + else + { + /*0U*/ + } + + /*鳵ͷڽ·źŻնǷռѹ*/ + if (CI_SUCCESS == checkFlag) + { + checkFlag = VobcBackUpRouteNoOccuCheck(wTrainId); + } + else + { + /*ʧ*/ + debug_infor_printf((const)"VobcBackUpRouteNoOccuManage: Have Another HeadTrain "); + } + + /*·ռ*/ + if (CI_SUCCESS == checkFlag) + { + /*ȡͷڽ·*/ + ablMaxheadLogSecId = GetTrainAblMaxHeadLogId(wTrainId); + logBelongRouteId = GetLogSecLockBelongRoute(ablMaxheadLogSecId); + if ((0U < logBelongRouteId) && (ROUTE_SUM_MAX > logBelongRouteId)) + { + wOverlapId = GetRouteOverlapLockedId(logBelongRouteId); + overlapSum = GetRouteOverlapSum(logBelongRouteId); + + /*·ڱգ鱣ռ*/ + if (0U < wOverlapId) + { + checkFlag = VobcBackUpOverlapNoOccuCheck(wOverlapId, &lastOverlapLogId); + if (CI_SUCCESS == checkFlag) + { + farLogSecId = lastOverlapLogId; + } + else + { + debug_infor_printf((const)"VobcBackUpRouteNoOccuManage: Overlop Have Occu "); + } + } + /*·δñ*/ + else if(0U== overlapSum) + { + /*·Ƿվֱ*/ + checkFlag = FindRouteLeaveAxis(logBelongRouteId); + /**/ + if (CI_SUCCESS == checkFlag) + { + leaveLogicSecId = GetRouteLeaveLogicSecId(logBelongRouteId); + checkFlag = TrainLeaveLogSecABLTrainCheck(leaveLogicSecId); + if (CI_SUCCESS == checkFlag) + { + /*һȥ߼ռüͨͨ*/ + farLogSecId = leaveLogicSecId; + } + else + { + /*ȥδռãʧ*/ + debug_infor_printf((const)"VobcBackUpRouteNoOccuManage: Leave LogSec Have Occu "); + } + } + /*δ*/ + else + { + /*ؽ·һ߼*/ + farLogSecId = GetRouteInLastLogSecId(logBelongRouteId); + } + + } + else + { + /*δգ0U*/ + debug_infor_printf((const)"VobcBackUpRouteNoOccuManage: OverLop Not Lock "); + } + + } + else + { + /*ѯʧ*/ + } + } + else + { + /*·ռãʧ*/ + debug_infor_printf((const)"VobcBackUpRouteNoOccuManage: Route Logsec Occu "); + } + } + + /* ABLΪUCT糡ӷ */ + if ((0U != farLogSecId) && (UINT16_MAX != farLogSecId)) + { + strEnd.wLinkId = pstrEnvelop->endPos.Lnk; + strEnd.dwOffset = pstrEnvelop->endPos.Off; + wEndLgcId = GetPointBelongLogSec(strEnd); + if (wEndLgcId != farLogSecId) + {/* ն߼βDzѯ߼ */ + checkFlag = elm_GetNearestEnvelopeApi(pstrEnvelop->id, &wFrontEid, &wBackEid); + if (CI_SUCCESS != checkFlag) + {/* ѯǰʧܣΪǰռ */ + farLogSecId = 0U; + } + else + { + pFrontEnvelop = elm_GetEnvelopeInfoByID(wFrontEid); + chFlag = elm_PrepareEnvelopeIsSelfApi(pFrontEnvelop); + if ((NULL == pFrontEnvelop) + || (pFrontEnvelop->trainID[0] == pstrEnvelop->trainID[0]) + || (ELM_BELONG_OWNER == chFlag)) + { + ; /* */ + } + else + {/* ǰ粻DZ磬Ϊǰռ */ + farLogSecId = 0U; + } + } + } + else + { + ; /* */ + } + } + + /*Զ߼*/ + SetTrainAblNoOccuFarLogId(wTrainId, farLogSecId); + +} + + +/* +* гڽ·Ƿ +* ˵ const UINT16 wTrainId гID +* ֵ CI_SUCCESS ռ +* CI_ERROR ռ +* by LC +*/ +UINT8 VobcBackUpRouteNoOccuCheck(const UINT16 wTrainId) +{ + UINT16* trainOccuLogSecId = NULL; + UINT8 trainOccuLogSecSum = 0U; + UINT8 chAblLogSecNum = 0U;/*ABLгӦ߼Ŀ*/ + ABLTrainRelLogStru* pAblLogSecData = NULL;/*ABLгӦ߼*/ + UINT8 i = 0U; + UINT8 j = 0U; + UINT8 k = 0U; + UINT8 retVal = CI_ERROR; + UINT8 tmpOccuState = 0U; + UINT16 maxHeadLogSecId = 0U; + UINT16 maxHeadPhySecId = 0U; + UINT8 cPhySecIncLogSecSum = 0U; /*ΰ߼*/ + UINT16* pPhySecIncLogSecId = NULL; /*ΰ߼ID*/ + + if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + /*ȡ·߼*/ + trainOccuLogSecId = GetTrainAblOcculogIdBuff(wTrainId); + trainOccuLogSecSum = GetTrainAblOcculogIdSum(wTrainId); + + /*ȡ·ֱ·ն߼*/ + chAblLogSecNum = GetTrainAblRelLogSecNum(wTrainId); + pAblLogSecData = GetTrainAblRelLogData(wTrainId); + retVal = CI_SUCCESS; + + maxHeadLogSecId= GetTrainAblMaxHeadLogId(wTrainId); + maxHeadPhySecId = GetLgcSecRelativePhySecId(maxHeadLogSecId); + + /*ȡͷι߼Ϣ*/ + cPhySecIncLogSecSum = GetPhySecIncLogSecSum(maxHeadPhySecId); + pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(maxHeadPhySecId); + + if ((NULL != trainOccuLogSecId) && (NULL != pAblLogSecData) && (0U != trainOccuLogSecSum) && (0U != chAblLogSecNum) && (0U != cPhySecIncLogSecSum) && (NULL != pPhySecIncLogSecId)) + { + /*µ·ն߼*/ + for (i = 0U; i < chAblLogSecNum; i++) + { + for (j = 0U; j < trainOccuLogSecSum; j++) + { + if (pAblLogSecData[i].wAblRelLogSecId == trainOccuLogSecId[j]) + { + /*гΣռ*/ + break; + } + else + { + ; + } + } + for ( k = 0U; k < cPhySecIncLogSecSum; k++) + { + if (pAblLogSecData[i].wAblRelLogSecId == pPhySecIncLogSecId[k]) + { + /*гͷΣռ*/ + break; + } + else + { + ; + } + } + + + + /*߼βгΣҲڳͷڵ*/ + if ((j == trainOccuLogSecSum) && (k == cPhySecIncLogSecSum)) + { + tmpOccuState = GetLogSecCurCtOrUtOccupyState(pAblLogSecData[i].wAblRelLogSecId); + + if (LOGICSECTION_OCCUPY_NO != tmpOccuState) + { + /*߼δռãʧ*/ + retVal = CI_ERROR; + } + else + { + /**/ + } + + } + if (CI_ERROR == retVal) + { + /**/ + break; + } + else + { + /**/ + } + } + } + else + { + /*ʧ*/ + } + } + else + { + /*ʧ*/ + } + return retVal; +} + + +/* +* гڽ·Ƿ +* ˵ const UINT16 wTrainId гID +* const UINT16 overLogSecId һ߼IDΣ +* ֵ CI_SUCCESS +* CI_ERROR ռ +* by LC +*/ +UINT8 VobcBackUpOverlapNoOccuCheck(const UINT16 wOverlapId, UINT16* overLogSecId) +{ + UINT8 overlapLogNum = 0U; /*ΰ߼*/ + UINT16* OverlapLogIdBuff = NULL; /*ΰ߼ID*/ + UINT8 occuState = 0U; + UINT8 i = 0U; + UINT8 retVal = CI_ERROR; + UINT16 farAxisSecId = 0U; /*Զ˼*/ + UINT16 axisLogicSecSum = 0u; /*߼Ŀ*/ + UINT16* axisLogicSecIdBuf = NULL; /*߼Id*/ + UINT8 overlapLockDir = 0U; + UINT8 overlogicLockDir = 0U; + + if ((NULL != overLogSecId) && (0U != wOverlapId)) + { + overlapLogNum = GetOverlapLogicSectionSum(wOverlapId); + OverlapLogIdBuff = GetOverlapLogicSectionBuf(wOverlapId); + + + if (NULL != OverlapLogIdBuff) + { + retVal = CI_SUCCESS; + for (i = 0U; i < overlapLogNum; i++) + { + occuState = GetLogSecCurCtOrUtOccupyState(OverlapLogIdBuff[i]); + if (LOGICSECTION_OCCUPY_NO != occuState) + { + /*߼δռãʧ*/ + retVal = CI_ERROR; + break; + } + else + { + /**/ + } + } + + if (CI_SUCCESS == retVal) + { + /*ռãһ߼ID*/ + farAxisSecId = GetOverlapFarLogicSecID(wOverlapId); /*Զ˼*/ + if (0U != farAxisSecId) + { + axisLogicSecSum = GetAxisSecLogSectionSum(farAxisSecId); /*ȡΰ߼Ŀ*/ + axisLogicSecIdBuf = GetAxisSecLogSectionIdBuf(farAxisSecId); /*ȡΰ߼*/ + if (NULL != axisLogicSecIdBuf) + { + overlapLockDir = GetLogSecLockDir(axisLogicSecIdBuf[0]); + overlogicLockDir = ConvertDirectionToLogic(overlapLockDir); + /*շ߼ͬ*/ + if (DIR_SAME == overlogicLockDir) + { + *overLogSecId = axisLogicSecIdBuf[axisLogicSecSum - 1]; + } + else if (DIR_CONVERT == overlogicLockDir) + { + *overLogSecId = axisLogicSecIdBuf[0]; + } + else + { + /*ѯʧ*/ + *overLogSecId = 0U; + retVal = CI_ERROR; + } + + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + /*ѯʧ*/ + } + } + else + { + /*ѯʧ*/ + } + } + else + { + /*ѯʧ*/ + } + + return retVal; +} + + +/* +* Ƿվֱ +* ˵ const UINT16 routeId ·ID +* ֵ CI_SUCCESS +* CI_ERROR δ +* by LC +*/ +UINT8 FindRouteLeaveAxis(const UINT16 routeId) +{ + UINT16 leaveLogicSecId = 0U; + UINT8 logBelogAxisNum = 0u; + UINT16* logBelogAxisBuff = NULL; + UINT16 phySecId = 0U; + UINT8 phySwitchSum = 0U; + UINT8 checkOtherSum = 0U; + RouteOtherCheckStruct* dataOtherCiDevBuf = NULL; + UINT8 i = 0U; + UINT8 retVal = CI_ERROR; + + if ((0U < routeId) && (ROUTE_SUM_MAX > routeId) ) + { + + /*ȡ·ⷽһȥ߼*/ + leaveLogicSecId = GetRouteLeaveLogicSecId(routeId); + + /*߼ιļ*/ + logBelogAxisNum = GetLgcSecRelativeAxleSecSum(leaveLogicSecId); + logBelogAxisBuff = GetLgcSecRltvAxleSecIdBuf(leaveLogicSecId); + + /*ȥ߼ι*/ + phySecId = GetLgcSecRelativePhySecId(leaveLogicSecId); + phySwitchSum = GetPhyIncludeSwitchSum(phySecId); /*ΰĵ*/ + + /*վȥΪ޲*/ + if ((0U == phySwitchSum) && (1U == logBelogAxisNum)) + { + + /*ȡʽ*/ + checkOtherSum = GetRouteBlocOtherCiSum(routeId); + dataOtherCiDevBuf = GetRouteBlocOtherCiBuf(routeId); + + + if (NULL != dataOtherCiDevBuf) + { + for (i = 0U; i < checkOtherSum; i++) + { + /*ʽվֱ*/ + if ((CI_DEVICE_TYPE_AXISSEC == dataOtherCiDevBuf[i].DevType) && (dataOtherCiDevBuf[i].DevId == logBelogAxisBuff[0])) + { + retVal = CI_SUCCESS; + break; + } + + } + } + else + { + /*ѯʧ*/ + } + + } + else + { + /*ȥδڵѯʧ*/ + } + } + else + { + /*ѯʧ*/ + } + return retVal; +} + +/* +* ۷̵ճ״̬ +* ˵ void +* ֵ +* by cgh 20240904 +*/ +void RtnRealyAdhesionStatePro(void) +{ + UINT16 wNonAutoReturnCurSum = 0U;/*ǰ۷*/ + UINT16 wNonAutoReturnId = 0U;/*۷ID*/ + UINT16 ii = 0U; + UINT16 wNonRtnAdhesionRealyId = 0U;/*۷ť̵*/ + UINT8 chRelayCollState = 0U;/*̵ɼ״̬*/ + UINT32 dwCycNum = 0U; + UINT32 dwNonRtnRelayUpCycNum = 0U;/*۷ťʼں*/ + UINT32 dwRelayAdhesionCount = 0U;/*̵жճ*/ + UINT8 chRelayVirtAttr = 0U;/*̵*/ + UINT8 chTimeCheckFlag = 0U;/*ʱ־*/ + + wNonAutoReturnCurSum = GetNonAutoReturnCurSum(); + + for (ii = 0U; ii < wNonAutoReturnCurSum; ii++) + { + wNonAutoReturnId = GetNonReturnId(ii); + wNonRtnAdhesionRealyId = GetNonRtnAdhesionRealyId(wNonAutoReturnId); + chRelayVirtAttr = GetRelayVirtAttr(wNonRtnAdhesionRealyId); + + if ((0U != wNonRtnAdhesionRealyId) && (RELAY_VIRTUAL_ATTR_NO == chRelayVirtAttr)) + { + /*0˵Чʵ۷*/ + chRelayCollState = GetRelayCollState(wNonRtnAdhesionRealyId); + + if (RELAY_STATE_UP == chRelayCollState) + { + dwCycNum = Get2oo2CurCycleNum(); + dwNonRtnRelayUpCycNum = GetNonRtnRelayUpCycNum(wNonAutoReturnId); + dwRelayAdhesionCount = GetdwNonReturnBtnErrEnsureCount(); + + if (0U == dwNonRtnRelayUpCycNum) + { + SetNonRtnRelayUpCycNum(wNonAutoReturnId, dwCycNum); + } + else + { + + chTimeCheckFlag = SystemOverTimeCheck(dwNonRtnRelayUpCycNum, dwRelayAdhesionCount); + + if (CI_TIME_OUT == chTimeCheckFlag) + { + SetNonRtnAdhesionState(wNonAutoReturnId, RTN_RELAY_ADHESION_YES); + } + else + { + ; /**/ + } + } + } + else + { + /*̵ںճ־*/ + SetNonRtnRelayUpCycNum(wNonAutoReturnId,0U); + SetNonRtnAdhesionState(wNonAutoReturnId, RTN_RELAY_ADHESION_NO); + } + } + else + { + ; + } + } +} + diff --git a/TSCP/src/APP/ciapp/IO/OutputDataProcess.h b/TSCP/src/APP/ciapp/IO/OutputDataProcess.h new file mode 100644 index 0000000..5e89466 --- /dev/null +++ b/TSCP/src/APP/ciapp/IO/OutputDataProcess.h @@ -0,0 +1,463 @@ +/******************************************************** +* +* OutputDataProcess.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-07 +* ߣ +* ݴͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _OUTPUT_DATA_PROCESS_H_ +#define _OUTPUT_DATA_PROCESS_H_ + + +#include "../ERROR/ErrorDefine.h" +#include "../ERROR/ErrorDataManage.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../ParsePack/CiInterfaceDefine.h" +#include "../ParsePack/ParsePackLeuData.h" +#include "../DataManage/DeviceDataManage.h" +#include "../DataManage/PlatDataManage.h" +#include "./DeviceRelayDataProcess.h" +#include "../Indicator/IndicatorConfigDataManage.h" +#include "../Indicator/IndicatorDataManage.h" +#include "../Indicator/IndicatorDefine.h" +#include "../NonRoute/NonRouteConfigDataManage.h" +#include "../NonRoute/NonRouteDataManage.h" +#include "../NonRoute/NonRouteDefine.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../Transmit/TransmitStateDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../LogicProcess/InterlockLogicCheck.h" +#include "../VirtualDevice/VirtualDevDataManage.h" +#include "../QueryFiles/dquCIInterFace.h" +#include "../DiffLineDev/DiffLineDevConfigDataManage.h" +#include "../Relay/RelayDataManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +* +* ˵ void +* ֵ void +*/ +void OutputDataProcess(void); + +/* +* CIATSϢ +* ˵ void +* ֵ +*/ +void CiToAtsBackInfoProcess(void); + +/* +* ݴ +* ˵ void +* ֵ +*/ +void ErrorCodeDataProcess(void); + + +/* +* ȡATSϢ +* ˵ +* const UINT8 functionId id +* const UINT8 deviceStateType, 豸״̬ +* const UINT8 deviceState, 豸״̬ +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetAtsBackInfoParam(const UINT8 functionId,const UINT8 deviceStateType, const UINT8 deviceState); + +/* +* ȡATSϢж +* ˵ const UINT8 functionId, ID + const UINT8 deviceType +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 CiToAtsBackInfoFunctionJudge(const UINT8 functionId,const UINT8 deviceType); + +/* +* ָʾ״̬ +* ˵ void +* ֵ void +*/ +void IndicatorStateProc(void); + +/* +* ָʾ״̬ +* ˵ void +* ֵ void +*/ +void IndicatorStateProc_UseVirCI(UINT8 virCIid); + +/* +* ǽ·̵״̬ +* ˵ void +* ֵ void +*/ +void NonRouteRelayStateProc(void); + +/* +* ʱݴ +* ˵ void +* ֵ +*/ +void TimeDataFeedBackProcess(void); + +/* +* ղ̵״̬ +* ˵ void +* ֵ void +*/ +void VirtualRelayStateProc(void); + +/* +* ¹ղ +* ˵ void +* ֵ void +*/ +void UpdateFaultLockZhaoChaDrive(void); + +/* +* ùܿжźŻ˿˿ +* ˵ UINT16 devId ָʾID +* ֵ void +*/ +void SignaDsBreakAlarmIndicator(UINT16 devId); +/* +* ùܿжźŻ˿˿ +* ˵ UINT16 devId ָʾID +* ֵ void +*/ +void SignaDsBreakAlarmIndicator_Vir(UINT8 virCIid,UINT8 devId); + +/* +* +* ˵ void +* ֵ void +*/ +void CiToCiOutputCmdProc(void); + +/* +* ۷ָʾƵƺȵ״̵̬״̬ +* ˵ +* ֵ +*/ +static void AutoRtnIndictStatusProc_VirCI(void); +/* +* ȡԶ·ID +* ˵ groupAutoRouteId Զ·ID +* ֵ ID +* ˵Զ·ΪԶ·ĵһ· +*/ +UINT8 GetGroupAutoRouteBelongVirCIid(UINT16 groupAutoRouteId); + +/********************************************* +*ܣղղ +*˵ +*ֵ +*********************************************/ +void UpdateZhaoChaCheckZhaoChaDrive(void); + +/********************************************* +*ܣ豸״̬ +*˵ +*ֵ +*********************************************/ +void VirtualDeviceOutputProc(void); + +/********************************************* +*ܣ豸״̬ +*˵ +*ֵ +*********************************************/ +void VirtualSignalStateProc(void); + +/* +* ̵״̬ +* ˵ +* ֵ +* +*/ +void SetDriveRelayHunXianState(void); +/* +* ȡ˹ʱ +* ˵ +* const UINT16 overlapId id +* const UINT16 OverlapUnLockCount ʱ +* const UINT32 startCycNum ʼ +* ֵ ʱ +* +*/ +UINT16 GetOverlapUnlockBackTime(const UINT16 overlapId, UINT16 OverlapUnLockCount, const UINT32 startCycNum); +/* +* źŻǰɫʾźŻ +* ˵ +* ֵ +* ע⣺ +*/ +void DriveFushiSignal(void); + +/* +* ԶʾǷƱ־ +* ˵ UINT8 virCiId ID +* ֵ CI_SUCCESS +* CI_ERROR +*/ +UINT8 CheckAutoTriggerIndicatFlag(UINT8 virCiId); +/* +* ָʾ״̬ +* ˵ void +* ֵ void +*/ +void OcStationIndicStateProc(void); + +/* +* PSDͨ״ָ̬ʾ״̬ +* ˵ UINT16 indicatorId ָʾID +* UINT8 devType ָʾ +* ֵ +*/ +void SetPSDCommonState(UINT16 indicatorId ,UINT8 devType); +/* +* PSDͨ״ָ̬ʾ״̬ +* ˵ UINT16 indicatorId ָʾID +* UINT8 devType ָʾ +* ֵ +*/ +void SetPSDCommonState_UseVirCI(UINT8 virCIid,UINT8 indicatorId ,UINT8 devType); + +/* +* ղ״ָ̬ʾ״̬ +* ˵ UINT16 indicatorId ָʾID +* +* ֵ +*/ +void SetZhaoChaIndictorCommonState(UINT16 indicatorId); + +/* +* վģʽָʾ +* ˵ void +* ֵ void +*/ +void SetCiModeIndicatorState(UINT16 indicatorId); + +/* +* ʹõָʾƴ +* ˵ void +* ֵ void +*/ +void OutPutIndicatorState_UseVirCI(void); + +/* +* ·ʱ +* ˵ const UINT16 wRouteId ·ID +* ֵ void +* cgh-ŻʱȦӶ +*/ +void RouteTimeDataBackProcess(const UINT16 wRouteId); +/* +* ʱ +* ˵ const UINT16 wPhySecId ID +* ֵ void +* cgh-ŻʱȦӶ +*/ +void PhySecTimeDataBackProcess(const UINT16 wPhySecId); + +/* +* ʱ +* ˵ const UINT16 wPhySecId ID +* ֵ void +* cgh-ŻʱȦӶ +*/ +void OverlapTimeDataBackProcess(const UINT16 wOverlapId); +/* +* ܸλ̵ʱ +* ˵ void +* ֵ void +* cgh-ŻʱȦӶ +*/ +void ZFWJTimeDataBackProcess(void); + +/* +* ǽ·ʱ +* ˵ NonRouteDataStruct* pNonRoute ǽ·ݽṹ +* ֵ void +* cgh-ŻʱȦӶ +*/ +void NonRouteTimeDataBackProcess(NonRouteDataStruct* pNonRoute); + +/* +* ʱʱ +* ˵ const UINT16 wFloodGateId ID +* ֵ void +*/ +void FloodGateTimeDataBackProcess(const UINT16 wFloodGateId); + +/* +* гϢ +* ˵ void +* ֵ +*/ +void VobcBackUpOutputProcess(void); + +/* +* г߼Ϣ +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240710 +*/ +void VobcBackUpLogSecManage(const UINT16 wTrainId); + +/* +* гͽ·Ϣ(۷·Ҫ¼۷߼Ϣ) +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240710 +*/ +void VobcBackUpRouteManage(const UINT16 wTrainId); + +/* +* гͱϢ +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240710 +*/ +void VobcBackUpProSecManage(const UINT16 wTrainId); + +/* +* гϢ +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240710 +*/ +void VobcBackUpXiansuSecManage(const UINT16 wTrainId); + +/* +* ʱ +* ˵ const UINT16 wPhySecId ߼ID +* const UINT16 wTrainId гID +* ֵ +*/ +void AddXiansuPhySecData(const UINT16 wLogSecId, const UINT16 wTrainId); + +/* +* гŻESBϢ +* ˵ UINT16 wTrainId гid +* ֵ +*/ +void VobcBackUpPsdEsbManage(UINT16 wTrainId); + +/* +* : ߼PSDϢ +* ˵ const UINT16 , logSecID ߼ID +* ABLTrainRelPsdStru* tmpAblPsdData PsdϢ +* UINT8 ablPsdNum Psd +* ֵ >0ӵĸ 0:ߴ +*/ +UINT8 AddABLPsdInfo(const UINT16 logSecID, ABLTrainRelPsdStru* tmpAblPsdData, const UINT8 ablPsdNum); + +/* +* : ij߼ESBϢ +* ˵ const UINT16 , logSecID ߼ID +* ABLTrainRelEsbStru* tmpAblEsbData EsbϢ +* UINT8 ablEsbNum Esb +* ֵ >0ӵĸ 0:ߴ +*/ +UINT8 AddABLEsbInfo(const UINT16 logSecID, ABLTrainRelEsbStru* tmpAblEsbData, const UINT8 ablEsbNum); + +# if 0 +/* +* г͵Ϣ +* ˵ VobcBackUpToCiDataStruct* VobcBackUpToCiDataStrгϢṹ +* ֵ +*/ +void VoBcBackUpSwitchManage(VobcBackUpToCiDataStruct* VobcBackUpToCiDataStr); + +/* +* ABL +* ˵ const UINT16 switchID, ID +* ABLTrainRelSwitchStru* tmpAblSwitchData Ϣ +* UINT8 tmpSwitchNum ӵ +* ֵ CI_SUCCESS CI_ERRORδı +*/ +UINT8 AddABLSwitchInfo(const UINT16 switchID, ABLTrainRelSwitchStru* tmpAblSwitchData, UINT16 tmpSwitchNum); + +/* +* ߼ȫ +* ˵ +* : UINT8 logSecNum ߼ UINT16* logSecBuf +* : ABLTrainRelSwitchStru* tmpAblSwitchData Ϣ UINT8* chAblSwitchNum +* ֵ >0ӵĸ 0: +* Create: fan 2024.5.21 +*/ +UINT8 AddLogBelongPhySecABLSwitchInfo(UINT16 logSecNum, UINT16* logSecBuf, ABLTrainRelSwitchStru* tmpAblSwitchData, UINT8 chAblSwitchNum); +#endif + +/* +* гλ÷· +* ˵ const UINT16 wTrainId гID +* ֵ +* by cgh 20240711 +*/ +void VobcLocReverseRouteCheck(const UINT16 wTrainId); + + +/* +* гͽ½·߼οϢ +* ˵ const UINT16 wTrainId гID +* ֵ +* by LC +*/ +void VobcBackUpRouteNoOccuManage(const UINT16 wTrainId); + +/* +* гڽ·Ƿ +* ˵ const UINT16 wTrainId гID +* ֵ CI_SUCCESS ռ +* CI_ERROR ռ +* by LC +*/ +UINT8 VobcBackUpRouteNoOccuCheck(const UINT16 wTrainId); + +/* +* гڽ·Ƿ +* ˵ const UINT16 wTrainId гID +* const UINT16 overLogSecId һ߼IDΣ +* ֵ CI_SUCCESS +* CI_ERROR ռ +* by LC +*/ +UINT8 VobcBackUpOverlapNoOccuCheck(const UINT16 wOverlapId, UINT16* overLogSecId); + +/* +* Ƿվֱ +* ˵ const UINT16 routeId ·ID +* ֵ CI_SUCCESS +* CI_ERROR δ +* by LC +*/ +UINT8 FindRouteLeaveAxis(const UINT16 routeId); + +/* +* ۷̵ճ״̬ +* ˵ void +* ֵ +* by cgh 20240904 +*/ +void RtnRealyAdhesionStatePro(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Indicator/IndicatorConfigDataManage.c b/TSCP/src/APP/ciapp/Indicator/IndicatorConfigDataManage.c new file mode 100644 index 0000000..78b6264 --- /dev/null +++ b/TSCP/src/APP/ciapp/Indicator/IndicatorConfigDataManage.c @@ -0,0 +1,459 @@ +/******************************************************** +* +* IndicatorConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-26 +* ߣ +* ָʾݹ +* +********************************************************/ + +#include "IndicatorConfigDataManage.h" +#include "../VirtualDevice/VirtualDevDataManage.h" + + + +IndicatorConfigDataStruct IndicatorConfigDataStru[INDICATOR_SUM_MAX]; /*ָʾýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiIndicatorIdBuf[INDICATOR_SUM_MAX] = {0u};/*屾ָʾIDӳ*/ +INT16 IndicatorCurSum = 0; /*ָʾǰ*/ + +OCStationIndicConfigDataStru g_OCStationIndicConfigDataStru[INDICATOR_SUM_MAX] = { 0u }; +UINT16 g_OCStationIndicatorCurSum = 0; /*OCվվͷǼվָʾ,漰棬ȡֵΧ0-1000*/ + + + +/* +* ȡָʾǰ +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ǰ +*/ +UINT16 GetIndicatorCurSum(void) +{ + UINT16 reVal = 0u; + + if ((INT16)INDICATOR_SUM_MAX <= IndicatorCurSum) + { + reVal = INDICATOR_SUM_MAX; + } + else if (0 > IndicatorCurSum) + { + reVal = 0u; + } + else + { + reVal = (UINT16)IndicatorCurSum; + } + + return reVal; +} + + + +/* +* ȡָ±ӦָʾID +* ˵ const UINT16 bufIndex, ± +* ֵ 0u: ȡʧ +* >0u: ָʾID +*/ +UINT16 GetIndicatorId(const UINT16 bufIndex) +{ + UINT16 reVal = CI_ERROR; + + if (bufIndex < GetIndicatorCurSum()) + { + reVal = LocalCiIndicatorIdBuf[bufIndex]; + } + + return reVal; +} + +/* +* ȡָIDָʾ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ +* +*/ +UINT16 GetIndicatorConfigBufIndex(const UINT16 indicatorId) +{ + UINT16 reVal = INDICATOR_SUM_MAX; + + if ((indicatorId >= 1u) && (indicatorId < INDICATOR_SUM_MAX)) + { + reVal = indicatorId; + } + + return reVal; +} + + +/* +* ȡָIDָʾ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ +* +*/ +UINT8 GetIndicatorType(const UINT16 indicatorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetIndicatorConfigBufIndex(indicatorId); /*ȡָʾؼ̵±*/ + + if (bufIndex < INDICATOR_SUM_MAX) + { + reVal = IndicatorConfigDataStru[bufIndex].IndicatorType; + } + + return reVal; +} + + +/* +* ȡָIDָʾID +* ˵ const UINT16 indicatorId, ָʾID +* ֵ +* +*/ +UINT8 GetIndicatorRelaySum(const UINT16 indicatorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetIndicatorConfigBufIndex(indicatorId); /*ȡָʾؼ̵±*/ + + if (bufIndex < INDICATOR_SUM_MAX) + { + reVal = IndicatorConfigDataStru[bufIndex].IdSum; + } + + return reVal; +} + + +/* +* ȡָIDָʾIdַ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ +* +*/ +UINT16* GetIndicatorRelayIdBuf(const UINT16 indicatorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* reVal = NULL; + + bufIndex = GetIndicatorConfigBufIndex(indicatorId); /*ȡָʾ±*/ + + if (bufIndex < INDICATOR_SUM_MAX) + { + reVal = IndicatorConfigDataStru[bufIndex].IdBuf; + } + return reVal; +} + +/* +* ָʾ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 IndicatorConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 indicatorConfigDataSum = 0u; /*ָʾ豸*/ + UINT8 reVal = CI_ERROR; + + /*indicatorId*/ + indicatorConfigDataSum = GetIndicatorCurSum(); + if (indicatorConfigDataSum >= INDICATOR_SUM_MAX) + {/**/ + + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + for (ii = 0u; ii < INDICATOR_SUM_MAX; ii++) + { + if (jj == indicatorConfigDataSum) + {/*Ч*/ + + break; + } + + if (IndicatorConfigDataStru[ii].IndicatorId != 0u) + {/*òΪЧ*/ + + LocalCiIndicatorIdBuf[jj] = IndicatorConfigDataStru[ii].IndicatorId; + jj++; + } + } + } + + return reVal; +} + +/* +* ȡָʾЧ־ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ ָʾЧ +*/ +UINT8 GetIndicatorAvalibleFlag(const UINT16 indicatorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = INDICATOR_DATA_VALID; + + bufIndex = GetIndicatorConfigBufIndex(indicatorId); /*ȡָʾ±*/ + + if (bufIndex < INDICATOR_SUM_MAX) + { + reVal = IndicatorConfigDataStru[bufIndex].AvalibleFlag; + } + return reVal; +} + + + +/* +* ȡָʾƶӦķǽ·id +* ˵ UINT16 indicatorId, ָʾID +* ֵ ǽ·id +*/ +UINT8 GetNonRouteIdByIndicatorId(UINT16 indicatorId) +{ + UINT8 nonRouteId = 0u; + + if(indicatorId < INDICATOR_SUM_MAX) + { + IndicatorConfigDataStruct light = IndicatorConfigDataStru[indicatorId]; + if(light.IdSum>=2u) + { + nonRouteId = (UINT8)(light.IdBuf[1]); + } + else if (light.IdSum == 1u) + { + nonRouteId = (UINT8)(light.IdBuf[0]); + } + else + { + /**/ + } + } + else + { + ; + } + + return nonRouteId; +} +/* +* ȡָʾƶӦķǽ·id +* ˵ UINT16 indicatorId, ָʾID +* ֵ ǽ·id +*/ +UINT16 GetNonRouteIdByIndictId_Vir(UINT8 virCIid,UINT8 indicatorId) +{ + UINT16 nonRouteId = 0u; + UINT16 * pNonRouteIdBuf = NULL; + UINT8 nonRouteSum = 0u; + nonRouteSum = GetVirCIIndicConfDataRelaySum(virCIid,indicatorId); + pNonRouteIdBuf = GetVirCIIndicConfDataRelayBuf(virCIid,indicatorId); + + if(NULL !=pNonRouteIdBuf) + { + if(2u <= nonRouteSum) + { + nonRouteId = pNonRouteIdBuf[1]; + } + else if(1u == nonRouteSum) + { + nonRouteId = pNonRouteIdBuf[0]; + } + else + { + nonRouteId = 0u; + } + } + return nonRouteId; +} +/* +* ȡOCվָʾ +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ǰ +* cgh-ϲECI11.0: +*/ +UINT16 GetOCStationIndicCurSum(void) +{ + UINT16 reVal = 0u; + + if (INDICATOR_SUM_MAX >= g_OCStationIndicatorCurSum) + { + reVal = (UINT16)g_OCStationIndicatorCurSum; + } + + return reVal; +} +/* +* ȡOCվָʾID +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +UINT8 GetOCStationIndicIdByIndex(UINT16 index) +{ + UINT16 indicNum = GetOCStationIndicCurSum(); + UINT16 i = 0u; + UINT8 reVal = 0u; + + if (indicNum > index) + { + reVal = g_OCStationIndicConfigDataStru[index].IndicatorId; + } + return reVal; +} +/* +* ȡOCվָʾOC +* ˵ void +* ֵ 0u: ȡʧ +* >0u: OC ID +* cgh-ϲECI11.0: +*/ +UINT8 GetOCStationIndicOcIdByIndex(UINT16 index) +{ + UINT16 indicNum = GetOCStationIndicCurSum(); + UINT16 i = 0u; + UINT8 reVal = 0u; + + if (indicNum > index) + { + reVal = g_OCStationIndicConfigDataStru[index].OcId; + } + return reVal; +} +/* +* ָʾIDȡӦ̵ID +* ˵ UINT8 ocid OCID +* UINT8 indicId ָʾID +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +UINT16 GetOCStationIndicRelayId(UINT8 ocid, UINT8 indicId) +{ + UINT16 indicNum = GetOCStationIndicCurSum(); + UINT16 i = 0u; + UINT16 relayId = 0u; + for (i = 0u; i < indicNum; i++) + { + if ((indicId == g_OCStationIndicConfigDataStru[i].IndicatorId) + && (ocid == g_OCStationIndicConfigDataStru[i].OcId)) + { + if (0u < g_OCStationIndicConfigDataStru[i].IdSum) + { + relayId = g_OCStationIndicConfigDataStru[i].IdBuf[0]; + } + break; + } + + } + return relayId; +} +/* +* ָʾIDȡָʾ +* ˵ UINT8 ocid OCID +* UINT8 indicId ָʾID +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +UINT8 GetOCStationIndicType(UINT8 ocid, UINT8 indicId) +{ + UINT16 indicNum = GetOCStationIndicCurSum(); + UINT16 i = 0u; + UINT8 reVal = 0u; + for (i = 0u; i < indicNum; i++) + { + if ((indicId == g_OCStationIndicConfigDataStru[i].IndicatorId) + && (ocid == g_OCStationIndicConfigDataStru[i].OcId)) + { + reVal = g_OCStationIndicConfigDataStru[i].IndicatorType; + break; + } + + } + return reVal; +} + +/* +* ݱIDȡ豸ID +* ˵ UINT16 indicatorId +* ֵ 0u: ȡʧ +* >0u: 豸ID +*/ +UINT8 GetIndicatorDevId(UINT16 indicatorId) +{ + UINT8 reVal = 0U; + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetIndicatorConfigBufIndex(indicatorId); /*ȡָʾؼ̵±*/ + + if (INDICATOR_SUM_MAX != bufIndex) + { + /*ʾΪ۷ָʾ豸IDԴUPSָʾơԴԴUPSع硢UPSصѹȣسվID*/ + reVal = IndicatorConfigDataStru[bufIndex].BjdDeviceId; + } + else + { + reVal = 0U; + } + if (UINT8_MAX == reVal) + { + reVal = 0U;/*ô󷵻㣬ȡֵֻ0~254*/ + } + return reVal; +} + +/* +* ݱIDȡ۷豸ID +* ˵ UINT16 indicatorId +* ֵ 0u: ȡʧ +* >0u: 豸ID +* by cgh 20240910 +*/ +UINT8 GetIndicatorRelNonReturnId(UINT16 indicatorId) +{ + + UINT16 wRetVal = CI_ERROR; + UINT16 NonAutoReturnCurSum = 0U; + UINT16 ii = 0U; + UINT16 wNonAutoRtnId = 0U; + UINT16 wCurNonAutoRtnRlyId = 0U; + + if ((0U < indicatorId) && (INDICATOR_SUM_MAX > indicatorId)) + { + NonAutoReturnCurSum = GetNonAutoReturnCurSum(); + for (ii = 0U; ii < NonAutoReturnCurSum; ii++) + { + wNonAutoRtnId = GetNonReturnId(ii); + wCurNonAutoRtnRlyId = GetNonRtnRlyId(wNonAutoRtnId); + if (indicatorId == wCurNonAutoRtnRlyId) + { + wRetVal = wNonAutoRtnId; /*۷ID*/ + break; + } + else + { + ; /**/ + } + } + } + else + { + /*μʧܣʧ*/ + } + + return wRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Indicator/IndicatorConfigDataManage.h b/TSCP/src/APP/ciapp/Indicator/IndicatorConfigDataManage.h new file mode 100644 index 0000000..a9fe270 --- /dev/null +++ b/TSCP/src/APP/ciapp/Indicator/IndicatorConfigDataManage.h @@ -0,0 +1,192 @@ +/******************************************************** +* +* IndicatorConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-26 +* ߣ +* ָʾݹͷļ +* +********************************************************/ + +#ifndef _INDICATOR_CONFIG_DATA_MANAGE_H_ +#define _INDICATOR_CONFIG_DATA_MANAGE_H_ + + +#include "IndicatorDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ʾƱݽṹ*/ +typedef struct S_IndicatorConfigDataStruct +{ + UINT16 IndicatorId; /*ָʾID (ֶ)*/ + UINT8 IndicatorType; /*ָʾ (ֶ)*/ + UINT8 AvalibleFlag;/*ָʾЧ־λ 0x55Ч 0xAA· 0xAA̵*/ + UINT8 IdSum; /*Id(ֶ)*/ + UINT16 IdBuf[INDICATOR_RELAY_SUM_MAX]; /*ID (ֶ)*/ + UINT8 BjdDeviceId; /*豸ID*/ +} IndicatorConfigDataStruct; + +/*cgh-ϲECI11.0:OCվʾ OCվָһվCI+OCֵعվվOCвǼֵعվվ*/ +typedef struct S_OCStationIndicConfigDataStru +{ + UINT8 OcId;/*OCվOCid*/ + UINT8 IndicatorId; /*ָʾID (ֶ)*/ + UINT8 IndicatorType; /*ָʾ (ֶ)*/ + UINT8 IdSum; /*Id(ֶ)*/ + UINT16 IdBuf[INDICATOR_RELAY_SUM_MAX]; /*ID (ֶ)*/ +} OCStationIndicConfigDataStru; + +extern IndicatorConfigDataStruct IndicatorConfigDataStru[INDICATOR_SUM_MAX]; /*ָʾýṹ*/ +extern UINT16 LocalCiIndicatorIdBuf[INDICATOR_SUM_MAX];/*屾ָʾIDӳ*/ +extern INT16 IndicatorCurSum; /*ָʾǰ*/ + +extern OCStationIndicConfigDataStru g_OCStationIndicConfigDataStru[INDICATOR_SUM_MAX]; +extern UINT16 g_OCStationIndicatorCurSum; /*OCվվͷǼվָʾ*/ + +/* +* ȡָʾǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetIndicatorCurSum(void); + +/* +* ȡָ±ӦָʾID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ָʾID +*/ +UINT16 GetIndicatorId(const UINT16 bufIndex); + +/* +* ȡָIDָʾ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ +* +*/ +UINT16 GetIndicatorConfigBufIndex(const UINT16 indicatorId); + +/* +* ȡָIDָʾ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ +* +*/ +UINT8 GetIndicatorType(const UINT16 indicatorId); + +/* +* ȡָIDָʾID +* ˵ const UINT16 indicatorId, ָʾID +* ֵ +* +*/ +UINT8 GetIndicatorRelaySum(const UINT16 indicatorId); + +/* +* ȡָIDָʾIDַ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ +* +*/ +UINT16* GetIndicatorRelayIdBuf(const UINT16 indicatorId); + +/* +* ָʾ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 IndicatorConfigDataManage(void); + +/* +* ȡָʾЧ־ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ ָʾЧ +*/ +UINT8 GetIndicatorAvalibleFlag(const UINT16 indicatorId); + +/* +* ȡָʾƶӦķǽ·id +* ˵ UINT16 indicatorId, ָʾID +* ֵ ǽ·id +*/ +UINT8 GetNonRouteIdByIndicatorId(UINT16 indicatorId); +/* +* ȡָʾƶӦķǽ·id +* ˵ UINT16 indicatorId, ָʾID +* ֵ ǽ·id +*/ +UINT16 GetNonRouteIdByIndictId_Vir(UINT8 virCIid,UINT8 indicatorId); + +/* +* ȡOCվָʾID +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +UINT8 GetOCStationIndicIdByIndex(UINT16 index); +/* +* ȡOCվָʾOC +* ˵ void +* ֵ 0u: ȡʧ +* >0u: OC ID +* cgh-ϲECI11.0: +*/ +UINT8 GetOCStationIndicOcIdByIndex(UINT16 index); +/* +* ȡOCվָʾ +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ǰ +* cgh-ϲECI11.0: +*/ +UINT16 GetOCStationIndicCurSum(void); +/* +* ָʾIDȡӦ̵ID +* ˵ UINT8 ocid OCID +* UINT8 indicId ָʾID +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +UINT16 GetOCStationIndicRelayId(UINT8 ocid, UINT8 indicId); +/* +* ָʾIDȡָʾ +* ˵ UINT8 ocid OCID +* UINT8 indicId ָʾID +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +UINT8 GetOCStationIndicType(UINT8 ocid, UINT8 indicId); + +/* +* ݱIDȡ豸ID +* ˵ UINT16 indicatorId +* ֵ 0u: ȡʧ +* >0u: 豸ID +*/ +UINT8 GetIndicatorDevId(UINT16 indicatorId); + +/* +* ݱIDȡ۷豸ID +* ˵ UINT16 indicatorId +* ֵ 0u: ȡʧ +* >0u: 豸ID +* by cgh 20240910 +*/ +UINT8 GetIndicatorRelNonReturnId(UINT16 indicatorId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Indicator/IndicatorDataManage.c b/TSCP/src/APP/ciapp/Indicator/IndicatorDataManage.c new file mode 100644 index 0000000..22b2522 --- /dev/null +++ b/TSCP/src/APP/ciapp/Indicator/IndicatorDataManage.c @@ -0,0 +1,127 @@ +/******************************************************** +* +* IndicatorDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-26 +* ߣ +* ָʾݹ +* ޸ļ¼ +* +********************************************************/ + +#include "IndicatorDataManage.h" + + + +IndicatorDataStruct IndicatorDataStru[INDICATOR_SUM_MAX]; /*ָʾݽṹ*/ +OCStationIndicDataStru g_OCStationIndicDataStru[INDICATOR_SUM_MAX] = { 0u }; /*OCվվͷǼվָʾ*/ + +/* +* ȡָIDָʾ״̬ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ 0u: ȡʧ +* >0u: +*/ +UINT8 GetIndicatorState(const UINT16 indicatorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetIndicatorConfigBufIndex(indicatorId); /*ȡָʾ±*/ + + if (bufIndex < INDICATOR_SUM_MAX) + { + reVal = IndicatorDataStru[bufIndex].IndicatorState; + } + else + { + reVal = CI_ERROR; + } + + return reVal; +} + + +/* +* ָIDָʾ״̬ +* ˵ const UINT16 indicatorId, ָʾID +* const UINT8 indicatorState, ָʾ״̬ +* ֵ +* +*/ +void SetIndicatorState(const UINT16 indicatorId, const UINT8 indicatorState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetIndicatorConfigBufIndex(indicatorId); /*ȡָʾ±*/ + + if (bufIndex < INDICATOR_SUM_MAX) + { + IndicatorDataStru[bufIndex].IndicatorState = indicatorState; /*ָʾ״̬*/ + } + +} +/* +* OCIDָʾIDȡָʾ״̬ +* ˵ UINT8 ocid OCID +* UINT8 indicId ָʾID +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +UINT8 GetOCStationIndicState(UINT8 ocid, UINT8 indicId) +{ + UINT16 indicNum = GetOCStationIndicCurSum(); + UINT16 i = 0u; + UINT8 reVal = 0u; + for (i = 0u; i < indicNum; i++) + { + if ((indicId == g_OCStationIndicDataStru[i].IndicatorId) + && (ocid == g_OCStationIndicDataStru[i].ocid)) + { + reVal = g_OCStationIndicDataStru[i].IndicatorState; + break; + } + + } + return reVal; +} +/* +* OCIDָʾIDָʾ״̬ +* ˵ UINT8 ocid OCID +* UINT8 indicId ָʾID +* UINT8 state ״̬ +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +void SetOCStationIndicState(UINT8 ocid, UINT8 indicId, UINT8 state) +{ + UINT16 indicNum = GetOCStationIndicCurSum(); + UINT16 i = 0u; + for (i = 0u; i < indicNum; i++) + { + if ((indicId == g_OCStationIndicDataStru[i].IndicatorId) + && (ocid == g_OCStationIndicDataStru[i].ocid)) + { + g_OCStationIndicDataStru[i].IndicatorState = state; + break; + } + + } +} +/* +* ȡOCվ豸ָʾƵƽṹ +* ˵ +* +* ֵ OCվ豸ָʾƵƽṹ +* cgh-ϲECI11.0: +*/ +OCStationIndicDataStru* GetOCStationIndicDataStru(void) +{ + return g_OCStationIndicDataStru; +} + + + + diff --git a/TSCP/src/APP/ciapp/Indicator/IndicatorDataManage.h b/TSCP/src/APP/ciapp/Indicator/IndicatorDataManage.h new file mode 100644 index 0000000..acb86a0 --- /dev/null +++ b/TSCP/src/APP/ciapp/Indicator/IndicatorDataManage.h @@ -0,0 +1,99 @@ +/******************************************************** +* +* IndicatorDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-26 +* ߣ +* ָʾݹͷļ +* +********************************************************/ + +#ifndef _INDICATOR_DATA_MANAGE_H_ +#define _INDICATOR_DATA_MANAGE_H_ + + +#include "IndicatorDefine.h" +#include "IndicatorConfigDataManage.h" +#include "CommonTypes.h" + + + + +#ifdef __cplusplus +extern "C" { +#endif + +/*ָʾݽṹ*/ +typedef struct S_IndicatorDataStruct +{ + UINT16 IndicatorId; /*ָʾID (ʼֶ)*/ + UINT8 IndicatorState; /*ָʾ״̬ (ֶ̬)*/ +} IndicatorDataStruct; +/*OCվָʾݽṹ*/ +typedef struct S_OCStationIndicDataStru +{ + UINT8 ocid; + UINT8 IndicatorId; /*ָʾID (ʼֶ)*/ + UINT8 IndicatorState; /*ָʾ״̬ (ֶ̬)*/ +} OCStationIndicDataStru; + + +extern IndicatorDataStruct IndicatorDataStru[INDICATOR_SUM_MAX]; /*ָʾݽṹ*/ +extern OCStationIndicDataStru g_OCStationIndicDataStru[INDICATOR_SUM_MAX]; /*OCվָʾ*/ + + + +/* +* ȡָIDָʾ״̬ +* ˵ const UINT16 indicatorId, ָʾID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetIndicatorState(const UINT16 indicatorId); + +/* +* ָIDָʾ״̬ +* ˵ const UINT16 indicatorId, ָʾID +* const UINT8 indicatorState, ָʾ״̬ +* ֵ +* +*/ +void SetIndicatorState(const UINT16 indicatorId, const UINT8 indicatorState); + +/* +* OCIDָʾIDȡָʾ״̬ +* ˵ UINT8 ocid OCID +* UINT8 indicId ָʾID +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +UINT8 GetOCStationIndicState(UINT8 ocid, UINT8 indicId); +/* +* OCIDָʾIDָʾ״̬ +* ˵ UINT8 ocid OCID +* UINT8 indicId ָʾID +* UINT8 state ״̬ +* ֵ 0u: ȡʧ +* >0u: ָʾID +* cgh-ϲECI11.0: +*/ +void SetOCStationIndicState(UINT8 ocid, UINT8 indicId, UINT8 state); +/* +* ȡOCվ豸ָʾƵƽṹ +* ˵ +* +* ֵ OCվ豸ָʾƵƽṹ +* cgh-ϲECI11.0: +*/ +OCStationIndicDataStru* GetOCStationIndicDataStru(void); + + + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Indicator/IndicatorDefine.h b/TSCP/src/APP/ciapp/Indicator/IndicatorDefine.h new file mode 100644 index 0000000..2e422db --- /dev/null +++ b/TSCP/src/APP/ciapp/Indicator/IndicatorDefine.h @@ -0,0 +1,201 @@ +/******************************************************** +* +* IndicatorDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-26 +* ߣ +* ָʾͷļ +* +********************************************************/ + +#ifndef _INDICATOR_DEFINE_H_ +#define _INDICATOR_DEFINE_H_ + + + +/*ֵ*/ +#define INDICATOR_SUM_MAX ((UINT16)1000) /*ָʾ,ÿ40ָʾƣܹ20 */ +#define INDICATOR_RELAY_SUM_MAX ((UINT16)5) /*ָʾؼ̵*/ +#define RTNINDICATOR_SUM_MAX ((UINT8)2U) /*һ۷*/ + +/*ָʾ*/ +#define INDICATOR_TYPE_ALARM_DUANSI ((UINT8)0x01) /*˿*/ +#define INDICATOR_TYPE_ALARM_RONGSI ((UINT8)0x02) /*߹˿*/ +#define INDICATOR_TYPE_POWER_SCREEN ((UINT8)0x03) /*Դ*/ +#define INDICATOR_TYPE_SIGNAL_FAULT_CLOSE ((UINT8)0x04) /*źŻϹرձ*/ +#define INDICATOR_TYPE_CIDEVICE_FAULT ((UINT8)0x05) /*豸ϱ*/ +#define INDICATOR_TYPE_UPS_FAULT ((UINT8)0x08) /*UPSָʾ*/ +#define INDICATOR_TYPE_UPS_DCGD ((UINT8)0x09) /*UPSع*/ +#define INDICATOR_TYPE_UPS_DCDY ((UINT8)0x0a) /*UPSصѹ*/ + +#define INDICATOR_TYPE_ALARM_GDTD ((UINT8)0x06) /*ͣ籨*/ +#define INDICATOR_TYPE_ALARM_GDGZ ((UINT8)0x07) /*ϱ*/ + +#define INDICATOR_TYPE_COMM_LEU ((UINT8)0x11) /*LEUͨ״̬*/ +#define INDICATOR_TYPE_COMM_ZC ((UINT8)0x12) /*ZCͨ״̬*/ + +#define INDICATOR_TYPE_LEU_FAULT_NO ((UINT8)0x01) /*LEU޹*/ +#define INDICATOR_TYPE_LEU_FAULT_YES ((UINT8)0x00) /*LEU*/ + + +#define INDICATOR_TYPE_EXPRESS_2OO2_I ((UINT8)0x13) /*һϵ״̬*/ +#define INDICATOR_TYPE_EXPRESS_2OO2_II ((UINT8)0x14) /*ϵ״̬*/ +#define INDICATOR_TYPE_EXPRESS_MAINP ((UINT8)0x15) /*Դ1*/ +#define INDICATOR_TYPE_EXPRESS_MAINP_2 ((UINT8)0x0b) /*Դ2*/ +#define INDICATOR_TYPE_EXPRESS_BACKP ((UINT8)0x16) /*Դ1*/ +#define INDICATOR_TYPE_EXPRESS_BACKP_2 ((UINT8)0x0c) /*Դ2*/ + +#define INDICATOR_TYPE_COMM_CI_FIRST ((UINT8)0x17) /*һͨ״̬*/ +/*һIDΪ0x1A20180810޸ԭ»ߴŸׯվ3ͨţ֮ǰĺ궨0x18*/ +#define INDICATOR_TYPE_COMM_CI_LAST ((UINT8)0x1A) /*һͨ״̬һIDΪ0x1A20180810*/ + +#if 0 +#define INDICATOR_TYPE_EXPRESS_START_UNLOCK 0x1a /*ϵ״̬*/ +#endif + +#define INDICATOR_TYPE_EXPRESS_NONROUTE ((UINT8)0x1c) /* ǽ·*/ +#define INDICATOR_TYPE_EXPRESS_STOP_CHECK ((UINT8)0x1d) /* ֹͣ״̬*/ +#define INDICATOR_TYPE_EXPRESS_SC_APP ((UINT8)0x1e) /* Գ*/ +#define INDICATOR_TYPE_EXPRESS_SC_ALW ((UINT8)0x1f) /* Գ*/ +#define INDICATOR_TYPE_EXPRESS_SC_END ((UINT8)0x20) /* Գ*/ +#define INDICATOR_TYPE_EXPRESS_RETURN ((UINT8)0x21) /* ۷*/ +#define INDICATOR_TYPE_ALARM_XICHEJI ((UINT8)0x22) /* ϴ״̬ */ +#define INDICATOR_TYPE_YINDAOZONGSUO ((UINT8)0x23) /* ״̬ */ +#define INDICATOR_TYPE_SWITCH_JICHA ((UINT8)0x24) /* ״̬ */ +#define INDICATOR_TYPE_GD_DAD ((UINT8)0x25) /* Źϱ״̬ */ +#define INDICATOR_TYPE_XICHEJI_ALLOW_STATE ((UINT8)0x26) /* FAO·ͬϴ״ָ̬ʾ */ +#define INDICATOR_TYPE_DOWNWASH_ALLOW_PASS_STATE ((UINT8)0x29) /* ģʽϴָͬͨʾ */ + +#define INDICATOR_TYPE_ATS_CONFIRM_RELAY_INTERFACE ((UINT8)0x27) /*̵ӿȷ״ָ̬ʾ*/ + +#define INDICATOR_TYPE_EXPRESS_ZHAOCHA1 ((UINT8)0x30) /*ղ1*/ +#define INDICATOR_TYPE_EXPRESS_ZHAOCHA2 ((UINT8)0x31) /*ղ2*/ +#define INDICATOR_TYPE_EXPRESS_ZHAOCHA3 ((UINT8)0x32) /*ղ3*/ +#define INDICATOR_TYPE_EXPRESS_ZHAOCHA4 ((UINT8)0x33) /*ղ4*/ +#define INDICATOR_TYPE_EXPRESS_ZHAOCHA5 ((UINT8)0x34) /*ղ5*/ + +#define INDICATOR_TYPE_COMM_PSD_START ((UINT8)0x40) /* һPSDͨ */ +#define INDICATOR_TYPE_COMM_PSD_SECOND ((UINT8)0x41) /* ڶPSDͨ */ +#define INDICATOR_TYPE_COMM_PSD_THIRD ((UINT8)0x42) /* PSDͨ */ +#define INDICATOR_TYPE_COMM_PSD_FOURTH ((UINT8)0x43) /* ĸPSDͨ */ +#define INDICATOR_TYPE_COMM_PSD_FIFTH ((UINT8)0x44) /* PSDͨ */ +#if 0 +#define INDICATOR_TYPE_COMM_PSD_END 0x44 /* һPSDͨ */ +#endif +#define INDICATOR_TYPE_STATUS_CI_MODE ((UINT8)0x50) /* ģʽ״̬ */ +#define INDICATOR_TYPE_STATUS_START_FLOCK ((UINT8)0x51) /* ȫվ״̬ */ +#define INDICATOR_TYPE_STATUS_START_LOCK ((UINT8)0x52) /* ϵ״̬ */ +#define INDICATOR_TYPE_STATUS_DISPLAY_LINSHIXIANSU ((UINT8)0x53) /* ʱʾ */ +#define INDICATOR_TYPE_READY_XICHEJI ((UINT8)0x54) /* ϴ״̬ */ +#define INDICATOR_TYPE_ALL_SIG_BRIGHT ((UINT8)0x56) /* ȫվ״̬ */ +#define INDICATOR_TYPE_AUTO_TRIGGE ((UINT8)0x57) /*Զ־*/ + +/*» 豸23*/ +#define INDICATOR_TYPE_ALARM_DUANSI_qujian2 ((UINT8)0x58) /*˿*/ +#define INDICATOR_TYPE_ALARM_RONGSI_qujian2 ((UINT8)0x59) /*˿*/ +#define INDICATOR_TYPE_POWER_SCREEN_qujian2 ((UINT8)0x5a) /*Դ*/ +#define INDICATOR_TYPE_UPS2_FAULT ((UINT8)0x5b) /*UPS2ָʾ*/ +#define INDICATOR_TYPE_JKJ_VALID ((UINT8)0x5c) /*ӦЧָʾ*/ +#define INDICATOR_TYPE_SWITCH_BLOCK_LINK ((UINT8)0x5d) /*ת޻ָʾ*/ + +#define INDICATOR_TYPE_PSD1_ISOLATE ((UINT8)0x80) /*ԳPSD1ϸָʾ*/ +#define INDICATOR_TYPE_PSD2_ISOLATE ((UINT8)0x81) /*ԳPSD2ϸָʾ*/ +#define INDICATOR_TYPE_PSD3_ISOLATE ((UINT8)0x82) /*ԳPSD3ϸָʾ*/ +#define INDICATOR_TYPE_PSD4_ISOLATE ((UINT8)0x83) /*ԳPSD4ϸָʾ*/ +#define INDICATOR_TYPE_PSD5_ISOLATE ((UINT8)0x84) /*ԳPSD5ϸָʾ*/ +#define INDICATOR_TYPE_PSD6_ISOLATE ((UINT8)0x85) /*ԳPSD6ϸָʾ*/ + +#define INDICATOR_TYPE_PCB1 ((UINT8)0x86) /*ԳPCB1ťָʾ*/ +#define INDICATOR_TYPE_PCB2 ((UINT8)0x87) /*ԳPCB2ťָʾ*/ +#define INDICATOR_TYPE_PCB3 ((UINT8)0x88) /*ԳPCB3ťָʾ*/ +#define INDICATOR_TYPE_PCB4 ((UINT8)0x89) /*ԳPCB4ťָʾ*/ +#define INDICATOR_TYPE_PCB5 ((UINT8)0x8A) /*ԳPCB5ťָʾ*/ +#define INDICATOR_TYPE_PCB6 ((UINT8)0x8B) /*ԳPCB6ťָʾ*/ + +#define INDICATOR_TYPE_AUTORTN_BTN ((UINT8)0x8C) /*Գ۷ť״ָ̬ʾ*/ + +/*ӿڹ˿*/ +#define INDICATOR_TYPE_PORT_RONGSI ((UINT8)0x5e) /*ӿڹ˿Ϣ*/ +/*UPS·ָʾ*/ +#define INDICATOR_TYPE_UPS1_PL ((UINT8)0x5f) /*UPS1·ָʾ*/ +#define INDICATOR_TYPE_UPS2_PL ((UINT8)0x60) /*UPS2·ָʾ*/ + +/*Դָʾơ20231211*/ +#define INDICATOR_TYPE_COMM_DEVICE ((UINT8)0x61) /*ͨ豸״ָ̬ʾ*/ + +/**********************************ָʾ**********************************/ +#define INDICATOR_TYPE_EXPRESS_NONROUTE_2 ((UINT8)0x8d) /* ǽ·2*/ +#define INDICATOR_TYPE_EXPRESS_SC_APP_2 ((UINT8)0x8e) /* Գ2*/ +#define INDICATOR_TYPE_EXPRESS_SC_ALW_2 ((UINT8)0x8f) /* Գ2*/ +#define INDICATOR_TYPE_EXPRESS_SC_END_2 ((UINT8)0x90) /* Գ2*/ +#define INDICATOR_TYPE_GENERAL_RESET_VALID ((UINT8)0x91) /*ܸλťʾ*/ +#define INDICATOR_TYPE_RELAY_HUNXIAN ((UINT8)0x92) /*̵߱ʾ*/ +#define INDICATOR_TYPE_AUTORTN_ADHESION ((UINT8)0x62) /*۷ťճ״ָ̬ʾ*/ +#define INDICATOR_TYPE_COMM_AXIS ((UINT8)0x96) /*ͨ״̬1-мͨ3-ڼͨ쳣*/ + + +/*ָʾʾ״̬*/ +#define INDICATOR_SHOW_NO ((UINT8)0x55) /*ʾЧ*/ +#define INDICATOR_SHOW_YES ((UINT8)0xaa) /*ʾЧ*/ + + +#define INDICATOR_SHOW_2OO2_MAIN ((UINT8)0x01) /**/ +#define INDICATOR_SHOW_2OO2_BACKUP ((UINT8)0x02) /**/ +#define INDICATOR_SHOW_2OO2_FAULT ((UINT8)0x03) /**/ + +#define INDICATOR_SHOW_RETURN_NORMAL ((UINT8)0x01) /*̬*/ +#define INDICATOR_SHOW_RETURN_FLASH ((UINT8)0x02) /**/ +#define INDICATOR_SHOW_RETURN_LIGHT ((UINT8)0x03) /*ȵ*/ + +#define INDICATOR_SHOW_NONROUTE_NOSET ((UINT8)0x01) /*δ*/ +#define INDICATOR_SHOW_NONROUTE_SETING ((UINT8)0x02) /**/ +#define INDICATOR_SHOW_NONROUTE_LOCK ((UINT8)0x03) /**/ + +#define INDICATOR_SHOW_COMM_GREEN ((UINT8)0x01) /*ȫͨ*/ +#define INDICATOR_SHOW_COMM_YELLOW ((UINT8)0x02) /*ͨ*/ +#define INDICATOR_SHOW_COMM_RED ((UINT8)0x03) /*ȫͨж*/ + +#define INDICATOR_SHOW_IOCOMM_OK ((UINT8)0x55) /*IOͨ*/ +#define INDICATOR_SHOW_IOCOMM_BAD ((UINT8)0xaa) /*IOͨж*/ + +#define INDICATOR_DATA_VALID ((UINT8)0x55) /*ָʾЧ*/ +#define INDICATOR_DATA_RELAY ((UINT8)0xaa) /*ָʾƼ̵Ч*/ +#define INDICATOR_DATA_PHYSEC ((UINT8)0xbb) /*ָʾЧ*/ +#define INDICATOR_DATA_STATION ((UINT8)0xdd) /*ָʾȻվЧ*/ + +#define INDICATOR_SHOW_CI_MODE_CONSTRA_LOCAL ((UINT8)0x55) /* ָʾʾǿվ */ +#define INDICATOR_SHOW_CI_MODE_CONSOLE ((UINT8)0x71) /* ָʾʾ̨ */ +#define INDICATOR_SHOW_CI_MODE_ATS ((UINT8)0xAA) /* ָʾʾң */ +#define INDICATOR_SHOW_CI_MODE_CI_LOCAL ((UINT8)0xFF) /* ָʾʾ */ +#define INDICATOR_SHOW_CI_MODE_APPLAY_LOCAL ((UINT8)0xBB) /* ָʾʾվ */ + +#define INDICATOR_SHOW_CI_FLOCAK_YES ((UINT8)0xAA) /* ȫվ*/ +#define INDICATOR_SHOW_CI_FLOCAK_NO ((UINT8)0x55) /* ȫվ*/ + +#define INDICATOR_SHOW_CI_STARTLOCK_YES ((UINT8)0xAA) /* ϵ*/ +#define INDICATOR_SHOW_CI_STARTLOCK_NO ((UINT8)0x55) /* ϵ*/ + +#define INDICATOR_SHOW_CI_LIMIT_YES ((UINT8)0x55) /* ʱ*/ +#define INDICATOR_SHOW_CI_LIMIT_NO ((UINT8)0xAA) /* */ + +#define INDICATOR_SHOW_SC_NO ((UINT8)0x55) /*ԳָʾʾЧ*/ +#define INDICATOR_SHOW_SC_YES ((UINT8)0xaa) /*ԳָʾʾЧ*/ + +#define INDIC_POWER_I_1 ((UINT8)0x01) /*һ·Դ1*/ +#define INDIC_POWER_I_2 ((UINT8)0x02) /*һ·Դ2*/ +#define INDIC_POWER_II_1 ((UINT8)0x03) /*·Դ1*/ +#define INDIC_POWER_II_2 ((UINT8)0x04) /*·Դ2*/ + +#define CLOASE_STATE ((UINT8)0x01) /*պ*/ +#define BREAK_STATE ((UINT8)0x02) /*Ͽ*/ + +/*Դʾ*/ +#define INDICATOR_SHOW_POWER_NORMAL ((UINT8)0x55) /* */ +#define INDICATOR_SHOW_POWER_MODBAD ((UINT8)0xaa) /*Դģ */ +#define INDICATOR_SHOW_POWER_BAD ((UINT8)0xbb) /*Դ */ + +#define INDICATOR_SHOW_COMM_GOOD ((UINT8)0x55) /*ͨ豸״̬ */ +#define INDICATOR_SHOW_COMM_BAD ((UINT8)0xaa) /*ͨ豸״̬ */ + +#endif + diff --git a/TSCP/src/APP/ciapp/Initial/ConfigDataReadManage.c b/TSCP/src/APP/ciapp/Initial/ConfigDataReadManage.c new file mode 100644 index 0000000..b3ce226 --- /dev/null +++ b/TSCP/src/APP/ciapp/Initial/ConfigDataReadManage.c @@ -0,0 +1,3429 @@ +/******************************************************** +* +* ConfigDataReadManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 +* ߣ +* ļ +* ޸ļ¼ +* +********************************************************/ + +#include "ConfigDataReadManage.h" + + + +extern TransmitRelationDataStruct TransmitRelaDataStru[TRANSMIT_OBJECT_SUM_MAX]; +extern UINT16 TransmitRelaDataCurSum; /*ͨŹϵݵǰ*/ +extern CiTransmitStruct ciTransmitStruct[CI_SUM_MAX]; /* 豸ӿ */ +extern EaConfigStru g_szEaConfig[EA_CFG_SUM_MAX]; +extern UINT16 g_eaConfigNum; + +extern AxisSectionConfigDataStruct g_szEaAcConfig[AXIS_SECTION_SUM_MAX]; /* ȫ߼ */ +extern UINT16 g_eaAcConfigNum; + +INT16 trackCheckRes = -1; +INT16 g_ret = -1; + + +/* + ݽṹͳһʼ + ˵ + ֵ 0u,ʼʧܣ1uʼɹ + *cgh-ϲCID-2539-6 +*/ +UINT8 InitAllStaticDataStr(void) +{ + UINT8 chRtn = 0u; + + /*·ݽṹ*/ + chRtn = CommonMemSet(RouteConfigDataStru, (UINT32)(ROUTE_SUM_MAX * sizeof(RouteConfigDataStruct)), 0u, (UINT32)(ROUTE_SUM_MAX * sizeof(RouteConfigDataStruct))); + + /*ȫԶ۷ýṹ*/ + chRtn &= CommonMemSet(AllAutoReturnConfigDataStru, (UINT32)(ALL_AUTO_RETURN_SUM_MAX * sizeof(AllAutoReturnConfigDataStruct)), 0u, (UINT32)(ALL_AUTO_RETURN_SUM_MAX * sizeof(AllAutoReturnConfigDataStruct))); + + /*Զ۷ýṹ*/ + chRtn &= CommonMemSet(AutoReturnConfigDataStru, (UINT32)(AUTO_RETURN_SUM_MAX * sizeof(AutoReturnConfigDataStruct)), 0u, (UINT32)(AUTO_RETURN_SUM_MAX * sizeof(AutoReturnConfigDataStruct))); + + /*Զ·ýṹ*/ + chRtn &= CommonMemSet(AutoRouteConfigDataStru, (UINT32)(AUTO_ROUTE_SUM_MAX * sizeof(AutoRouteConfigDataStruct)), 0u, (UINT32)(AUTO_ROUTE_SUM_MAX * sizeof(AutoRouteConfigDataStruct))); + + /*Զ·ýṹ*/ + chRtn &= CommonMemSet(GroupAutoRouteConfigDataStru, (UINT32)(GROUP_AUTO_ROUTE_SUM_MAX * sizeof(GroupAutoRouteConfigDataStruct)), 0u, (UINT32)(GROUP_AUTO_ROUTE_SUM_MAX * sizeof(GroupAutoRouteConfigDataStruct))); + + /*洢CIʹõĵӵͼ汾*/ + chRtn &= CommonMemSet(gEmapCiConfigStrus, (UINT32)(CI_SUM_MAX * sizeof(EmapCiConfigStru)), 0u, (UINT32)(CI_SUM_MAX * sizeof(EmapCiConfigStru))); + + /*ESBýṹ*/ + chRtn &= CommonMemSet(EsbConfigDataStru, (UINT32)(ESB_SUM_MAX * sizeof(EsbConfigDataStruct)), 0u, (UINT32)(ESB_SUM_MAX * sizeof(EsbConfigDataStruct))); + + /*ýṹ*/ + chRtn &= CommonMemSet(FloodGateConfigDataStru, (UINT32)(FLOOD_GATE_SUM_MAX * sizeof(FloodGateConfigDataStruct)), 0u, (UINT32)(FLOOD_GATE_SUM_MAX * sizeof(FloodGateConfigDataStruct))); + + /*ýṹ*/ + chRtn &= CommonMemSet(GaragedoorConfigDataStru, (UINT32)(GARAGE_DOOR_SUM_MAX * sizeof(GaragedoorConfigDataStruct)), 0u, (UINT32)(GARAGE_DOOR_SUM_MAX * sizeof(GaragedoorConfigDataStruct))); + + /*ָʾýṹ*/ + chRtn &= CommonMemSet(IndicatorConfigDataStru, (UINT32)(INDICATOR_SUM_MAX * sizeof(IndicatorConfigDataStruct)), 0u, (UINT32)(INDICATOR_SUM_MAX * sizeof(IndicatorConfigDataStruct))); + + /*ݽṹ*/ + chRtn &= CommonMemSet(InvSecConfigDataStru, (UINT32)(INVA_SECT_N_COND_SWIT_SUM_MAX * sizeof(InvSecConfigDataStruct)), 0u, (UINT32)(INVA_SECT_N_COND_SWIT_SUM_MAX * sizeof(InvSecConfigDataStruct))); + + /*CIվATSλ*/ + chRtn &= CommonMemSet(CiToAtsMaskConfigDataStru, (UINT32)(CI_TO_ATS_MASK_SUM_MAX * sizeof(MaskConfigDataStruct)), 0u, (UINT32)(CI_TO_ATS_MASK_SUM_MAX * sizeof(MaskConfigDataStruct))); + + /*CIվZCλ*/ + chRtn &= CommonMemSet(CiToZcMaskConfigDataStru, (UINT32)(CI_TO_ZC_MASK_SUM_MAX * sizeof(MaskConfigDataStruct)), 0u, (UINT32)(CI_TO_ZC_MASK_SUM_MAX * sizeof(MaskConfigDataStruct))); + + /*ZCվCIλ*/ + chRtn &= CommonMemSet(ZcToCiMaskConfigDataStru, (UINT32)(ZC_TO_CI_MASK_SUM_MAX * sizeof(MaskConfigDataStruct)), 0u, (UINT32)(ZC_TO_CI_MASK_SUM_MAX * sizeof(MaskConfigDataStruct))); + + /*CILEUλ*/ + chRtn &= CommonMemSet(CiToLeuMaskConfigDataStru, (UINT32)(CI_TO_LEU_MASK_SUM_MAX * sizeof(MaskConfigDataStruct)), 0u, (UINT32)(CI_TO_LEU_MASK_SUM_MAX * sizeof(MaskConfigDataStruct))); + + /*ǽ·ݽṹ*/ + chRtn &= CommonMemSet(NonRouteConfigDataStruArr, (UINT32)(NONROUTE_ID_NUM_MAX * sizeof(NonRouteConfigDataStruct)), 0u, (UINT32)(NONROUTE_ID_NUM_MAX * sizeof(NonRouteConfigDataStruct))); + + /*OVERLAPýṹ*/ + chRtn &= CommonMemSet(OverlapConfigDataStru, (UINT32)(OVERLAP_SUM_MAX * sizeof(OverlapConfigDataStruct)), 0u, (UINT32)(OVERLAP_SUM_MAX * sizeof(OverlapConfigDataStruct))); + + /*վ̨ſýṹ*/ + chRtn &= CommonMemSet(PscConfigDataStru, (UINT32)(PSC_SUM_MAX * sizeof(PscConfigDataStruct)), 0u, (UINT32)(PSC_SUM_MAX * sizeof(PscConfigDataStruct))); + + /*ýṹ*/ + chRtn &= CommonMemSet(PsdConfigDataStru, (UINT32)(PSD_SUM_MAX * sizeof(PsdConfigDataStruct)), 0u, (UINT32)(PSD_SUM_MAX * sizeof(PsdConfigDataStruct))); + + /*̵ݽṹ*/ + chRtn &= CommonMemSet(RelayConfigDataStru, (UINT32)(RELAY_SUM_MAX * sizeof(RelayConfigDataStruct)), 0u, (UINT32)(RELAY_SUM_MAX * sizeof(RelayConfigDataStruct))); + + /*·ýṹ*/ + chRtn &= CommonMemSet(ReverseRouteConfigDataStru, (UINT32)(ROUTE_SUM_MAX * sizeof(ReverseRouteConfigDataStruct)), 0u, (UINT32)(ROUTE_SUM_MAX * sizeof(ReverseRouteConfigDataStruct))); + + /*·ݽṹ*/ + chRtn &= CommonMemSet(LongRouteConfigDataStru, (UINT32)(ROUTE_LONG_SUM_MAX * sizeof(LongRouteConfigDataStruct)), 0u, (UINT32)(ROUTE_LONG_SUM_MAX * sizeof(LongRouteConfigDataStruct))); + + /*ݽṹ*/ + chRtn &= CommonMemSet(AxisSectionConfigDataStru, (UINT32)(AXIS_SECTION_SUM_MAX * sizeof(AxisSectionConfigDataStruct)), 0u, (UINT32)(AXIS_SECTION_SUM_MAX * sizeof(AxisSectionConfigDataStruct))); + + /*߼ݽṹ*/ + chRtn &= CommonMemSet(LogicSectionConfigDataStru, (UINT32)(LOGIC_SECTION_SUM_MAX * sizeof(LogicSectionConfigDataStruct)), 0u, (UINT32)(LOGIC_SECTION_SUM_MAX * sizeof(LogicSectionConfigDataStruct))); + + /*ýṹ*/ + chRtn &= CommonMemSet(PhysicalSectionConfigDataStru, (UINT32)(PHYSICAL_SECTION_SUM_MAX * sizeof(PhysicalSectionConfigDataStruct)), 0u, (UINT32)(PHYSICAL_SECTION_SUM_MAX * sizeof(PhysicalSectionConfigDataStruct))); + + /*źŻýṹ*/ + chRtn &= CommonMemSet(SignalConfigDataStru, (UINT32)(SIGNAL_SUM_MAX * sizeof(SignalConfigDataStruct)), 0u, (UINT32)(SIGNAL_SUM_MAX * sizeof(SignalConfigDataStruct))); + + /* SPKSݽṹ */ + chRtn &= CommonMemSet(spksDataConfigBuff, (UINT32)(SPKS_SUM_MAX * sizeof(SpksDataConfigStruct)), 0u, (UINT32)(SPKS_SUM_MAX * sizeof(SpksDataConfigStruct))); + + /* Žݽṹ */ + chRtn &= CommonMemSet(MjDataConfigBuff, (UINT32)(MJ_SUM_MAX * sizeof(MJDataConfigStruct)), 0u, (UINT32)(MJ_SUM_MAX * sizeof(MJDataConfigStruct))); + + /*ýṹ*/ + chRtn &= CommonMemSet(SwitchConfigDataStru, (UINT32)(SWITCH_SUM_MAX * sizeof(SwitchConfigDataStruct)), 0u, (UINT32)(SWITCH_SUM_MAX * sizeof(SwitchConfigDataStruct))); + + /*ϴýṹ*/ + chRtn &= CommonMemSet(WashMachineConfigDataStru, (UINT32)(WASHMACHINE_SUM_MAX * sizeof(WashMachineConfigDataStruct)), 0u, (UINT32)(WASHMACHINE_SUM_MAX * sizeof(WashMachineConfigDataStruct))); + + /*ⱨݽṹ*/ + chRtn &= CommonMemSet(SGBJConfigDataStru, (UINT32)(SGBJ_SUM_MAX * sizeof(SGBJConfigDataStruct)), 0u, (UINT32)(SGBJ_SUM_MAX * sizeof(SGBJConfigDataStruct))); + + return chRtn; +} + +/* +* ļ +* ˵ +* ֵ 0u,ɹ +* 1,ݸֵʧ +* 2,ѯʼʧ +* 3,ʧ +* 4,ID +* 5,͸ʧ +*/ +UINT8 ReadConfigureData(void) +{ + UINT8 rtnVal = 0u; + UINT8 virCINum =0u; + UINT8 virCIid = 0u; + UINT8 i = 0u; + INT16 indicatorNum = 0; + UINT8 initAllRet = 0u; + UINT8 includeVirFlag= 0u; + UINT8 retValue = 0u; + UINT8 CiPattern = 0u; + UINT8 chInitAllStaticDataStrRtn = 0u; + UINT8 RtnTemp = 0u; + + + + initAllRet = InitAll((const)DataPath); + if (LocalCiId == 0u) + { +#ifdef PLATFORM_2OO2 + + (void)printf("LocalCiId Error\n"); + debug_infor_printf((const)"LocalCiId Error\n"); +#endif + rtnVal = 4u; + } + + /*ʼѯ*/ + else if (1u != initAllRet) + { +#ifdef PLATFORM_2OO2 + + (void)printf("InitAll Error\n"); + debug_infor_printf((const)"InitAll Error\n"); +#endif + /*ѯʧ*/ + rtnVal = 2u; + } + else + { + /*̬ݽṹʼ*/ + chInitAllStaticDataStrRtn = InitAllStaticDataStr(); + if (1u == chInitAllStaticDataStrRtn) + {/*cgh-ϲCID-2539-6*/ + if (0u == rtnVal) + { + /*ݲΪṹֵַΪݽṹ*/ + RelayCurSum = ReadRelayConfigData(LocalCiId, RelayConfigDataStru); /*̵ݷRelayCurSumͬ*/ + if (-1 == RelayCurSum) + { + rtnVal = 7u;/*ȡ̵ʧ*/ + debug_infor_printf((const)"ReadRelayConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + SignalCurSum = ReadSignalConfigData(LocalCiId, SignalConfigDataStru); /*źŻ*/ + if (-1 == SignalCurSum) + { + rtnVal = 8u;/*ȡźŻʧ*/ + debug_infor_printf((const)"ReadSignalConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + WashMachineCurSum = ReadWashMachineConfigData(LocalCiId, WashMachineConfigDataStru); /*ȡϴ*/ + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + SwitchCurSum = ReadSwitchConfigData(LocalCiId, SwitchConfigDataStru); /**/ + if (-1 == SwitchCurSum) + { + rtnVal = 9u;/*ȡʧ*/ + debug_infor_printf((const)"ReadSwitchConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + PhysicalSectionCurSum = ReadPhySicalSectionConfigData(LocalCiId, PhysicalSectionConfigDataStru);/**/ + if (-1 == PhysicalSectionCurSum) + { + rtnVal = 10u;/*ȡʧ*/ + debug_infor_printf((const)"ReadPhySicalSectionConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + AxisSectionCurSum = ReadAxisSectionConfigData(LocalCiId, AxisSectionConfigDataStru, &g_eaAcConfigNum, g_szEaAcConfig); /**/ + if (-1 == AxisSectionCurSum) + { + rtnVal = 11u;/*ȡʧ*/ + debug_infor_printf((const)"ReadAxisSectionConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + trackCheckRes = ReadTrackSectionConfigData(PhysicalSectionConfigDataStru);/*ȡ*/ + if (-1 == trackCheckRes) + { + rtnVal = 25u;/*ȡʧ*/ + debug_infor_printf((const)"ReadTrackSectionConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + LogicSectionCurSum = ReadLogicSectionConfigData(LocalCiId, LogicSectionConfigDataStru); /*߼*/ + if (-1 == LogicSectionCurSum) + { + rtnVal = 12u;/*ȡ߼ʧ*/ + debug_infor_printf((const)"ReadLogicSectionConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + EsbCurSum = ReadEsbConfigData(LocalCiId, EsbConfigDataStru); /*ͣť*/ + if (-1 == EsbCurSum) + { + rtnVal = 13u;/*ȡͣťʧ*/ + debug_infor_printf((const)"ReadEsbConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + PsdCurSum = ReadPsdConfigData(LocalCiId, PsdConfigDataStru); /**/ + if (-1 == PsdCurSum) + { + rtnVal = 14u;/*ȡpsdʧ*/ + debug_infor_printf((const)"ReadPsdConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + RouteCurSum = ReadRouteConfigData(LocalCiId, RouteConfigDataStru); /*·*/ + if (-1 == RouteCurSum) + { + rtnVal = 15u;/*ȡ·ʧ*/ + debug_infor_printf((const)"ReadRouteConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + AutoRouteCurSum = ReadAutoRouteConfigData(LocalCiId, AutoRouteConfigDataStru); /*Զͨ·*/ + if (-1 == AutoRouteCurSum) + { + rtnVal = 16u;/*ȡԶͨ·ʧ*/ + debug_infor_printf((const)"ReadAutoRouteConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + AutoReturnCurSum = ReadAutoReturnConfigData(LocalCiId, AutoReturnConfigDataStru); /*Զ۷·*/ + if (-1 == AutoReturnCurSum) + { + rtnVal = 17u;/*ȡԶ۷·ʧ*/ + debug_infor_printf((const)"ReadAutoReturnConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + ReverseRouteCurSum = ReadReverseRouteConfigData(LocalCiId, ReverseRouteConfigDataStru); /*·*/ + if (-1 == ReverseRouteCurSum) + { + rtnVal = 18u;/*ȡ۷·ʧ*/ + debug_infor_printf((const)"ReadReverseRouteConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + LongRouteCurSum = ReadLongRouteConfigData(LongRouteConfigDataStru); /*·*/ + if (-1 == LongRouteCurSum) + { + rtnVal = 19u;/*ȡ·ʧ*/ + debug_infor_printf((const)"ReadLongRouteConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + if (FUNC_SWITCH_ON == includeVirFlag) + { + virCINum = GetVirtualCINum(); + for (i = 0u; i < virCINum; i++) + { + virCIid = GetVirtualCIid(i); + + indicatorNum = ReadIndicatorConfigData_Vir(LocalCiId, virCIid, g_VirtualCIStructData.virtualCi[i].IndicatorConfigData); + + if (0 > indicatorNum) + { + rtnVal = 20u;/*ȡָʾƱʧ*/ + debug_infor_printf((const)"ReadIndicatorConfigData_Vir fail."); + } + else + { + SetVirCIIndicatorConfigDataNum(virCIid, (UINT8)indicatorNum); + } + + } + } + else + { + IndicatorCurSum = ReadIndicatorConfigData(LocalCiId, IndicatorConfigDataStru); /*ָʾƱ*/ + if (-1 == IndicatorCurSum) + { + rtnVal = 20u;/*ȡָʾƱʧ*/ + debug_infor_printf((const)"ReadIndicatorConfigData fail."); + } + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + OverlapCurSum = ReadOverlapConfigData(LocalCiId, OverlapConfigDataStru); /**/ + if (-1 == OverlapCurSum) + { + rtnVal = 21u;/*ʧ*/ + debug_infor_printf((const)"ReadOverlapConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + g_ret = ReadCutoffPointConfigData(LocalCiId, g_szCfpConfig); + if (-1 == g_ret) + { + rtnVal = 27u;/*ʧ*/ + debug_infor_printf((const)"ReadCutoffPointConfigData fail."); + } + else if (0 < g_ret) + { + gCfpConfigSum = (UINT16)g_ret; + } + else + { + /*޲*/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + g_ret = ReadReverseCutConfigData(LocalCiId, gstReverseCutCfgData); + if (-1 == g_ret) + { + rtnVal = 28u;/*ʧ*/ + debug_infor_printf((const)"ReadReverseCutConfigData fail."); + } + else if (0 < g_ret) + { + gReverseCutCfgSum = g_ret; + } + else + { + /*޲*/ + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + TransmitRelaDataCurSum = ReadTransmitRelationConfigData(LocalCiId, TransmitRelaDataStru); /*ͨŹϵ*/ + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + CiToAtsMaskCurSum = ReadCiToAtsMaskConfigData(LocalCiId, CiToAtsMaskConfigDataStru); /*CI-ATS*/ + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + CiToZcMaskCurSum = ReadCiToZcMaskConfigData(LocalCiId, CiToZcMaskConfigDataStru); /*CI-ZC*/ + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + ZcToCiMaskCurSum = ReadZcToCiMaskConfigData(LocalCiId, ZcToCiMaskConfigDataStru); /*ZC-CI*/ + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + CiToLeuMaskCurSum = ReadCiToLeuMaskConfigData(LocalCiId, CiToLeuMaskConfigDataStru); /*CI-LEU*/ + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + AllAutoReturnCurSum = ReadAllAutoReturnConfigData(LocalCiId, AllAutoReturnConfigDataStru); /*ȫԶ۷·*/ + if (-1 == AllAutoReturnCurSum) + { + rtnVal = 22u;/*ȫԶ۷·ʧ*/ + debug_infor_printf((const)"ReadAllAutoReturnConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + GaragedoorCurSum = ReadGaragedoorConfigData(LocalCiId, GaragedoorConfigDataStru); /**/ + if (-1 == GaragedoorCurSum) + { + rtnVal = 23u;/*ʧ*/ + debug_infor_printf((const)"ReadGaragedoorConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + spksSum = ReadSpksConfigData(LocalCiId, spksDataConfigBuff); /* SPKS */ + if (-1 == spksSum) + { + rtnVal = 24u;/*SPKS ʧ*/ + debug_infor_printf((const)"ReadSpksConfigData fail."); + } + + else + { + ; /**/ + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + ciTransNum = ReadCiTransConfigData(LocalCiId, ciTransmitStruct); /* ݶȡ */ + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + + gmjSum = ReadMJConfigData(LocalCiId, MjDataConfigBuff); /*Ž*/ + if (-1 == gmjSum) + { + rtnVal = 37u;/*Žʧ*/ + debug_infor_printf((const)"Read MenjinData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + + if (0u == rtnVal) + { + InvSecSum = ReadInvaSectionConfigData(LocalCiId, InvSecConfigDataStru); /**/ + if (-1 == InvSecSum) + { + rtnVal = 6u; + debug_infor_printf((const)"ReadConfigureData errcode =%d, invSec exceed Index", rtnVal); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + {/*ȡŵ*/ + FloodGateCurSum = ReadFloodGateConfigData(LocalCiId, FloodGateConfigDataStru); + if (-1 == FloodGateCurSum) + { + rtnVal = 25u; + debug_infor_printf((const)"ReadConfigureData errcode =%d, floodGate exceed Index", rtnVal); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + + if (0u == rtnVal) + { + PscCurSum = ReadPscConfigData(LocalCiId, PscConfigDataStru); /*վ̨ſ*/ + if (-1 == PscCurSum) + { + rtnVal = 26u;/*ȡpscʧ*/ + debug_infor_printf((const)"ReadPscConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + gNonReturnCurSum = ReadNonReturnConfigData(LocalCiId, NonReturnConfigDataStru); /*վ̨ſ*/ + if (-1 == gNonReturnCurSum) + { + rtnVal = 27u;/*ȡ۷ʧ*/ + debug_infor_printf((const)"ReadNonReturnConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + DiffLineDevSum = ReadDiffLineDevConfigData(LocalCiId, &DiffLineDevData); + + ReadEmapCiConfig(gEmapCiConfigStrus);/*ȡCIĵӵͼУ汾*/ + + RtnTemp = ReadVirtualDevicesInit(PsdConfigDataStru, EsbConfigDataStru, spksDataConfigBuff, RelayConfigDataStru, IndicatorConfigDataStru);/*豸*/ /*豸*/ + if (0u == RtnTemp) + { + rtnVal = 1u; + debug_infor_printf((const)"VirtualDevicesInit Error\n"); + } + else + { + ; /*ִ*/ + } +#if 0u + /**/ + if (ReadCiFuncSwitchConfigData(&CiFuncSwitConfStru) != 1) + { + /**/ + } +#endif + + /*ǽ·*/ + NonRouteCurSum = ReadNonRouteConfigData(NonRouteConfigDataStruArr); + } + else + { + ; /**/ + } + + /*ⱨ*/ + if (0u == rtnVal) + { + SGBJCurSum = ReadSGBJConfigData(LocalCiId, SGBJConfigDataStru); + if (-1 == SGBJCurSum) + { + rtnVal = 38U; /*ȡⱨʧ*/ + debug_infor_printf((const)"ReadSGBJConfigData fail."); + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + /*ϵͳ*/ + if (0u == ReadSystemParamConfDataNew(LocalCiId, &SystemParameterStruNew)) + { +#ifdef PLATFORM_2OO2 + + (void)printf("SystemParameterConfigData Error\n"); + debug_infor_printf((const)"SystemParameterConfigData Error\n"); +#endif + rtnVal = 1u; + } + else + { + /*Ӧ̵̼*/ + JkjRelayId = ReadJkjRelayId(LocalCiId); + + /*ͷŲѯĶ̬ռ*/ + FreeMem(); + + if (1u == DeviceDataManage()) + {/*ʧ*/ +#ifdef PLATFORM_2OO2 + + (void)printf("DeviceDataManage Error\n"); + +#endif + rtnVal = 3u; + } + else if (1u == NeibourToLocalDevConfDataManage(LocalCiId)) + {/*͸ʧ*/ +#ifdef PLATFORM_2OO2 + + (void)printf("NeibourToLocalDeviceDataManage Error\n"); + debug_infor_printf((const)"NeibourToLocalDeviceDataManage Error\n"); +#endif + rtnVal = 5u; + + } + else + {/*ݳɹ*/ + rtnVal = 0u; + } + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + {/*ȡźŻͶӦɫ*/ + g_ret = ReadSignalDrvTypeOpenColorCfg(); + if (-1 == g_ret) + { + rtnVal = 30u; + debug_infor_printf((const)"ReadSignalDrvTypeOpenColorConfig errcode =%d, floodGate exceed Index", rtnVal); + } + else + { + rtnVal = 0u; + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + {/*ȡԶ·*/ + g_ret = ReadGroupAutoRouteConfigData(GroupAutoRouteConfigDataStru); + if (-1 == g_ret) + { + rtnVal = 31u; + debug_infor_printf((const)"ReadGroupAutoRouteConfigData errcode =%d, GroupAutoRoute", rtnVal); + } + else + { + rtnVal = 0u; + } + } + else + { + ; /**/ + } + if (0u == rtnVal) + { + g_ret = ReadZhaochaCheckConfigData(); + if (-1 == g_ret) + { + rtnVal = 32u; + debug_infor_printf((const)"ReadZhaochaCheckConfigData errcode =%d, ZhaochaCheckConfigData", rtnVal); + } + else + { + rtnVal = 0u; + } + } + else + { + ; /**/ + } + + /* linkݶȡ 2022.02.28 */ + if (0u == rtnVal) + { + /*ȡLINK*/ + g_ret = ReadLinkConfigData(g_szLinkConfigData); + if (-1 == g_ret) + { + rtnVal = 33u; + debug_infor_printf((const)"ReadLinkConfigData errcode =%d, ReadLinkConfigData", rtnVal); + } + else + { + g_linkNum = (UINT16)g_ret; + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + /*ȡ*/ + g_ret = ReadEaConfigData(g_szEaConfig); + if (-1 == g_ret) + { + rtnVal = 37u; + debug_infor_printf((const)"ReadEaConfigData errcode =%d, ReadEaConfigData", rtnVal); + } + else + { + g_eaConfigNum = (UINT16)g_ret; + } + } + else + { + ; /**/ + } + + /* ݶȡ 2022.03.11 */ + if (0u == rtnVal) + { + /*ȡ*/ + g_ret = ReadAxisConfigData(g_szAxisData); + if (-1 == g_ret) + { + rtnVal = 36u; + debug_infor_printf((const)"ReadAxisConfigData errcode =%d, ReadAxisConfigData", rtnVal); + } + else + { + g_axisNum = (UINT16)g_ret; + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + /*ZCĿ*/ + g_ret = (INT16)CheckCiHaveZcSumErr(LocalCiId); + if (1 < g_ret) + { + rtnVal = 34u; + debug_infor_printf((const)"CheckCiHaveZcSumErr errcode =%d, CheckCiHaveZcSumErr", rtnVal); + } + } + else + { + ; /**/ + } + + CiPattern = GetLocalCiPattern(); + + /*ȫ*/ + if (CI_PATTERN_FULL_ELECTRONIC == CiPattern) + { + if (0u == rtnVal) + { + retValue = OcConnectConfigDataStructInit(); + + if (CI_SUCCESS == retValue) + { + /*ȡ*/ + g_ret = OcConnectConfigDataToDevStruct(SignalConfigDataStru, PhysicalSectionConfigDataStru, SwitchConfigDataStru, OcConnetDataCfgStru, RelayConfigDataStru); + if (-1 == g_ret) + { + rtnVal = 35u; + debug_infor_printf((const)"OcConnectConfigDataToDevStruct errcode =%d, OcConnectConfigDataToDevStruct", rtnVal); + } + } + else + { + rtnVal = 35u; + debug_infor_printf((const)"OcConnectConfigDataStructInit errcode =%d, OcConnectConfigDataStructInit", rtnVal); + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + /*CIñȡźŻ븴ʾźŻϵ*/ + g_ret = (INT16)ReadSigWithFushiSigRelatData((const)DataPath); + + if (0 == g_ret) + { + debug_infor_printf((const)"ReadSigWithFushiSigRelatData fail.\r\n"); + rtnVal = 35u; + } + } + + if (0u == rtnVal) + { + /*CIñȡSPKSϽSPKSϵ*/ + g_ret = (INT16)ReadTotalSpksWithSpksRelatData((const)DataPath); + + if (0 == g_ret) + { + debug_infor_printf((const)"ReadTotalSpksWithSpksRelatData fail.\r\n"); + rtnVal = 36u; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (0u == rtnVal) + { + /*ȡArb鷶Χ*/ + g_ret = (INT16)PhySectionNearConfigDataManage(); + if (0 == g_ret) + { + debug_infor_printf((const)"PhySectionNearConfigDataManage Error\n"); + rtnVal = 37u; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + else + { + /*̬ݽṹʼʧ*/ +#ifdef PLATFORM_2OO2 + + (void)printf("InitAllStaticDataStr Error\n"); + debug_infor_printf((const)"InitAllStaticDataStr Error\n"); +#endif + rtnVal = 2u; + } + + + } + + return rtnVal; +} + + +/* +* 豸 +* ˵ +* ֵ 0u,ɹ +* >0u,ʧ +*/ +UINT8 DeviceDataManage(void) +{ + UINT8 rtValue = 0u; + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 reval = CI_ERROR; + /*̵*/ + if (CI_ERROR == RelayConfigDataManage()) + { + rtValue = 1u; + } + + /*źŻ*/ + else if (CI_ERROR == SignalConfigDataManage()) + { + rtValue = 1u; + } + + /**/ + else if (CI_ERROR == SwitchConfigDataManage()) + { + rtValue = 1u; + } + + /**/ + else if (CI_ERROR == AxisSectionConfigDataManage()) + { + rtValue = 1u; + } + + /*߼*/ + else if (CI_ERROR == LogicSectionConfigDataManage()) + { + rtValue = 1u; + } + + /**/ + else if (CI_ERROR == PhySectionConfigDataManage()) + { + rtValue = 1u; + } + + /*·*/ + else if (CI_ERROR == RouteConfigDataManage()) + { + rtValue = 1u; + } + + /*Զ۷·*/ + else if (CI_ERROR == AutoReturnConfigDataManage()) + { + rtValue = 1u; + } + + /*·*/ + else if(CI_ERROR == ReverseRouteConfigDataManage()) + { + rtValue = 1u; + } + /*Զ·*/ + else if (CI_ERROR == AutoRouteConfigDataManage()) + { + rtValue = 1u; + } + + /**/ + else if (CI_ERROR == OverlapConfigDataManage()) + { + rtValue = 1u; + } + + /*Esb*/ + else if (CI_ERROR == EsbConfigDataManage()) + { + rtValue = 1u; + } + + /*Psd*/ + else if (CI_ERROR == PsdConfigDataManage()) + { + rtValue = 1u; + } + /*Ž*/ + else if (CI_ERROR == MjConfigDataManage()) + { + rtValue = 1u; + } + + + /*ָʾ*/ + /*ȫԶ۷·*/ + else if (CI_ERROR == AllAutoReturnConfigDataManage()) + { + rtValue = 1u; + } + /*·*/ + else if (CI_ERROR == LongRouteConfigDataManage()) + { + rtValue = 1u; + } + /**/ + else if (CI_ERROR == GaragedoorConfigDataManage()) + { + rtValue = 1u; + } + /*SPKS*/ + else if (CI_ERROR == SpksConfigDataManage()) + { + rtValue = 1u; + } + /*ϴ*/ + else if(CI_ERROR == WashMachineConfigDataManage()) + { + rtValue = 1u; + } + /**/ + else if (CI_ERROR == FloodGateConfigDataManage()) + { + rtValue = 1u; + } + else if(CI_ERROR == SetInvSecAndConSwiBufInd()) + { + rtValue = 1u; + } + else + { + rtValue = 0u; + } + if(FUNC_SWITCH_ON == includeVirFlag) + { + reval = InitVirCIlocalCiIndicatorIdBuf(); + if(CI_ERROR == reval) + { + rtValue = 1u; + } + } + else + { + reval = IndicatorConfigDataManage(); + if(CI_ERROR == reval) + { + rtValue = 1u; + } + } + + if (0U == rtValue) + { + reval = CutoffPointConfigDataManage(); + if (CI_ERROR == reval) + { + rtValue = 1u; + } + } + + if (0U == rtValue) + { + reval = ReverseCutConfigDataManage(); + if (CI_ERROR == reval) + { + rtValue = 1u; + } + } + + if (0U == rtValue) + { + reval = SGBJConfigDataManage(); + if (CI_ERROR == reval) + { + rtValue = 1u; + } + } + + return rtValue; +} +/* +* ȡָԶ·IDִԶ· +* ˵ UINT16 autoRouteRouteIdָԶ·ID +* UINT8 routeType · +* ֵ CI_ERRORʧ CI_SUCCESSɹ +*/ +UINT8 SetautoRouteOpposedRoute(UINT16 autoRouteRouteId,UINT8 routeType) +{ + UINT16 ii = 0u; + UINT16 jj = 0u; /*α*/ + UINT16 kk = 0u; /*α*/ + UINT8 indexA = 0u; /**/ + UINT8 indexB = 0u; /**/ + UINT8 indexC = 0u; /**/ + UINT8 indexD = 0u; /**/ + UINT8 indexE = 0u; /**/ + UINT8 indexF = 0u; /**/ + UINT8 indexG = 0u; /**/ + UINT8 indexH = 0u; /**/ + UINT8 indexI = 0u; /**/ + + UINT16 autoRouteSum = 0u; /*Զͨ·*/ + UINT16 autoReturnSum = 0u; /*Զ۷·*/ + UINT16 allAutoReturnSum = 0u; /*ȫԶ۷·*/ + UINT16 otherAutoRouteId = 0u; /*Զͨ·ID*/ + + UINT8 returnValue = CI_ERROR; + autoRouteSum = GetAutoRouteRouteCurSum();/*Զ·Ŀ*/ + autoReturnSum = GetAutoReturnRouteCurSum();/*Զ۷·Ŀ*/ + allAutoReturnSum = GetAllAutoReturnRouteCurSum();/*ȫԶ۷·Ŀ*/ + if ((autoRouteSum >= AUTO_ROUTE_SUM_MAX) || (autoReturnSum >= AUTO_RETURN_SUM_MAX)) + {/**/ + returnValue = CI_ERROR; + } + else + { + switch (routeType) + { + case ROUTE_AUTOROUTE_NORMAL: + for (jj = 0u; jj < autoRouteSum; jj++) + {/*Զ·Զ·*/ + + otherAutoRouteId = GetAutoRouteRouteId(jj);/*ȡļиµԶͨ·ID*/ + + if (autoRouteRouteId == otherAutoRouteId) + {/*ȥ·*/ + } + else + { + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_AUTOROUTE_NORMAL,otherAutoRouteId,ROUTE_AUTOROUTE_NORMAL)) + { + AutoRouteConfigDataStru[autoRouteRouteId].AutoRouteOpposedRouteIdBuf[indexA++] = otherAutoRouteId; + } + + } + + } + for (kk = 0u; kk < autoReturnSum; kk++) + {/*Զ۷·*/ + + otherAutoRouteId = GetAutoReturnRouteId(kk);/*ȡļиµԶͨ·ID*/ + + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_AUTOROUTE_NORMAL,otherAutoRouteId,ROUTE_AUTOROUTE_RETURN)) + { + AutoRouteConfigDataStru[autoRouteRouteId].AutoRouteOpposedReturnIdBuf[indexB++] = otherAutoRouteId; + } + } + + for (ii = 0u; ii < allAutoReturnSum; ii++) + {/*ȫԶ۷·*/ + + otherAutoRouteId = GetAllAutoReturnRouteId(ii);/*ȡļиµȫԶ۷·ID*/ + + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_AUTOROUTE_NORMAL,otherAutoRouteId,ROUTE_ALLAUTOROUTE_RETURN)) + { + AutoRouteConfigDataStru[autoRouteRouteId].AutoRouteOpposedAllReturnIdBuf[indexC++] = otherAutoRouteId; + } + } + + AutoRouteConfigDataStru[autoRouteRouteId].AutoRouteOpposedRouteIdSum = indexA; + AutoRouteConfigDataStru[autoRouteRouteId].AutoRouteOpposedReturnIdSum = indexB; + AutoRouteConfigDataStru[autoRouteRouteId].AutoRouteOpposedAllReturnIdSum = indexC; + break; + case ROUTE_AUTOROUTE_RETURN: + for (jj = 0u; jj < autoRouteSum; jj++) + {/*Զͨ·*/ + + otherAutoRouteId = GetAutoRouteRouteId(jj);/*ȡļиµԶ۷·ID*/ + + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_AUTOROUTE_RETURN,otherAutoRouteId,ROUTE_AUTOROUTE_NORMAL)) + {/*Զ۷·Զ·ִ*/ + AutoReturnConfigDataStru[autoRouteRouteId].AutoReturnOpposedRouteIdBuf[indexD++] = otherAutoRouteId; + } + + } + for (kk = 0u; kk < autoReturnSum; kk++) + {/*Զ۷·Զ۷·*/ + + otherAutoRouteId = GetAutoReturnRouteId(kk);/*ȡļиµԶͨ·ID*/ + + if (autoRouteRouteId == otherAutoRouteId) + {/*ȥ·*/ + } + else + { + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_AUTOROUTE_RETURN,otherAutoRouteId,ROUTE_AUTOROUTE_RETURN)) + {/*Զ۷·Զ۷·ִ*/ + AutoReturnConfigDataStru[autoRouteRouteId].AutoReturnOpposedReturnIdBuf[indexE++] = otherAutoRouteId; + } + } + } + + for (ii = 0u; ii < allAutoReturnSum; ii++) + {/*ȫԶ۷·*/ + + otherAutoRouteId = GetAllAutoReturnRouteId(ii);/*ȡļиµȫԶ۷·ID*/ + + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_AUTOROUTE_RETURN,otherAutoRouteId,ROUTE_ALLAUTOROUTE_RETURN)) + { + AutoReturnConfigDataStru[autoRouteRouteId].AutoReturnOpposedAllReturnIdBuf[indexF++] = otherAutoRouteId; + } + } + AutoReturnConfigDataStru[autoRouteRouteId].AutoReturnOpposedRouteIdSum = indexD; + AutoReturnConfigDataStru[autoRouteRouteId].AutoReturnOpposedReturnIdSum = indexE; + AutoReturnConfigDataStru[autoRouteRouteId].AutoReturnOpposedAllReturnIdSum = indexF; + + break; + case ROUTE_ALLAUTOROUTE_RETURN: + for (jj = 0u; jj < autoRouteSum; jj++) + {/*Զͨ·*/ + + otherAutoRouteId = GetAutoRouteRouteId(jj);/*ȡļиµԶͨ·ID*/ + + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_ALLAUTOROUTE_RETURN,otherAutoRouteId,ROUTE_AUTOROUTE_NORMAL)) + {/*Զͨ·ȫԶ·ִ*/ + AllAutoReturnConfigDataStru[autoRouteRouteId].AllAutoReturnOpposedRouteIdBuf[indexG++] = otherAutoRouteId; + } + } + for (kk = 0u; kk < autoReturnSum; kk++) + {/*Զ۷·*/ + + otherAutoRouteId = GetAutoReturnRouteId(kk);/*ȡļиµԶ۷·ID*/ + + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_ALLAUTOROUTE_RETURN,otherAutoRouteId,ROUTE_AUTOROUTE_RETURN)) + { + AllAutoReturnConfigDataStru[autoRouteRouteId].AllAutoReturnOpposedReturnIdBuf[indexH++] = otherAutoRouteId; + } + } + + for (ii = 0u; ii < allAutoReturnSum; ii++) + {/*ȫԶ۷·ȫԶ۷·*/ + + otherAutoRouteId = GetAllAutoReturnRouteId(ii);/*ȡļиµȫԶ۷·ID*/ + + if (autoRouteRouteId == otherAutoRouteId) + {/*ȥ·*/ + } + else + { + /*жǷͻ*/ + if (CI_SUCCESS == AutoRouteIsOpposed(autoRouteRouteId,ROUTE_ALLAUTOROUTE_RETURN,otherAutoRouteId,ROUTE_ALLAUTOROUTE_RETURN)) + { + AllAutoReturnConfigDataStru[autoRouteRouteId].AllAutoReturnOpposedAllRtnIdBuf[indexI++] = otherAutoRouteId; + } + } + } + + AllAutoReturnConfigDataStru[autoRouteRouteId].AllAutoReturnOpposedRouteIdSum = indexG; + AllAutoReturnConfigDataStru[autoRouteRouteId].AllAutoReturnOpposedReturnIdSum = indexH; + AllAutoReturnConfigDataStru[autoRouteRouteId].AllAutoReturnOpposedAllRtnIdSum = indexI; + break; + default: + /*ԶԻԶԴ */ + break; + } + returnValue = CI_SUCCESS; + } + return returnValue; +} + +/* +* жָIDԶ·Ƿִ +* ˵ UINT16 autoRouteRouteIdָԶ·ID + UINT16 otherAutoRouteIdһԶ·ID +* ֵ CI_ERROR: ִ +* CI_SUCCESS: ִ +*/ +UINT8 AutoRouteIsOpposed(UINT16 autoRouteId,UINT8 routeType,UINT16 otherAutoRouteId,UINT8 otherRouteType) +{ + UINT16 kk = 0u; /*α*/ + UINT16 qq = 0u; /*α*/ + UINT16 nn = 0u; /*α*/ + + UINT8 routeSum = 0u; /*Զ··Ŀ (ֶ)*/ + UINT16 *routeIdBuf = NULL; /*Զ··ID (ֶ)*/ + UINT8 otherRouteSum = 0u; /*һԶ··Ŀ (ֶ)*/ + UINT16 *otherRouteIdBuf = NULL; /*һԶ··ID (ֶ)*/ + UINT8 opposeRouteSum = 0u; + UINT16 *opposeRouteBuf = NULL; /*ִĻ·*/ + UINT8 returnValue = CI_ERROR; + if ((routeType == ROUTE_AUTOROUTE_NORMAL) && (otherRouteType == ROUTE_AUTOROUTE_NORMAL)) + { + routeSum = GetAutoRouteIncludeRouteSum(autoRouteId);/*ý··Ŀ*/ + routeIdBuf = GetAutoRouteIncludeRouteBuf(autoRouteId);/*ȡԶ·ӦĻ·*/ + + otherRouteSum = GetAutoRouteIncludeRouteSum(otherAutoRouteId);/*һ··Ŀ*/ + otherRouteIdBuf = GetAutoRouteIncludeRouteBuf(otherAutoRouteId);/*ȡԶ·ӦĻ·*/ + } + else if ((routeType == ROUTE_AUTOROUTE_NORMAL) && (otherRouteType == ROUTE_AUTOROUTE_RETURN)) + { + routeSum = GetAutoRouteIncludeRouteSum(autoRouteId);/*ý··Ŀ*/ + routeIdBuf = GetAutoRouteIncludeRouteBuf(autoRouteId);/*ȡԶ·ӦĻ·*/ + + otherRouteSum = GetAutoReturnIncludeRouteSum(otherAutoRouteId);/*һ۷··Ŀ*/ + otherRouteIdBuf = GetAutoReturnIncludeRouteBuf(otherAutoRouteId);/*ȡԶ۷·ӦĻ·*/ + } + else if ((routeType == ROUTE_AUTOROUTE_NORMAL) && (otherRouteType == ROUTE_ALLAUTOROUTE_RETURN)) + { + routeSum = GetAutoRouteIncludeRouteSum(autoRouteId);/*ý··Ŀ*/ + routeIdBuf = GetAutoRouteIncludeRouteBuf(autoRouteId);/*ȡȫԶ·ӦĻ·*/ + otherRouteSum = GetAllAutoReturnIncludeRouteSum(otherAutoRouteId);/*һȫԶ۷··Ŀ*/ + otherRouteIdBuf = GetAllAutoReturnIncludeRouteBuf(otherAutoRouteId);/*ȡȫԶ۷·ӦĻ·*/ + } + else if ((routeType == ROUTE_AUTOROUTE_RETURN) && (otherRouteType == ROUTE_AUTOROUTE_NORMAL)) + { + routeSum = GetAutoReturnIncludeRouteSum(autoRouteId);/*۷··Ŀ*/ + routeIdBuf = GetAutoReturnIncludeRouteBuf(autoRouteId);/*ȡԶ۷·ӦĻ·*/ + + otherRouteSum = GetAutoRouteIncludeRouteSum(otherAutoRouteId);/*һ··Ŀ*/ + otherRouteIdBuf = GetAutoRouteIncludeRouteBuf(otherAutoRouteId);/*ȡԶ·ӦĻ·*/ + } + else if ((routeType == ROUTE_AUTOROUTE_RETURN) && (otherRouteType == ROUTE_AUTOROUTE_RETURN)) + { + routeSum = GetAutoReturnIncludeRouteSum(autoRouteId);/*۷··Ŀ*/ + routeIdBuf = GetAutoReturnIncludeRouteBuf(autoRouteId);/*ȡԶ۷·ӦĻ·*/ + + otherRouteSum = GetAutoReturnIncludeRouteSum(otherAutoRouteId);/*һ۷··Ŀ*/ + otherRouteIdBuf = GetAutoReturnIncludeRouteBuf(otherAutoRouteId);/*ȡԶ۷·ӦĻ·*/ + } + else if ((routeType == ROUTE_AUTOROUTE_RETURN) && (otherRouteType == ROUTE_ALLAUTOROUTE_RETURN)) + { + routeSum = GetAutoReturnIncludeRouteSum(autoRouteId);/*۷··Ŀ*/ + routeIdBuf = GetAutoReturnIncludeRouteBuf(autoRouteId);/*ȡԶ۷·ӦĻ·*/ + otherRouteSum = GetAllAutoReturnIncludeRouteSum(otherAutoRouteId);/*һȫԶ۷··Ŀ*/ + otherRouteIdBuf = GetAllAutoReturnIncludeRouteBuf(otherAutoRouteId);/*ȡȫԶ۷·ӦĻ·*/ + } + else if ((routeType == ROUTE_ALLAUTOROUTE_RETURN) && (otherRouteType == ROUTE_ALLAUTOROUTE_RETURN)) + { + routeSum = GetAllAutoReturnIncludeRouteSum(autoRouteId);/*ȫԶ۷··Ŀ*/ + routeIdBuf = GetAllAutoReturnIncludeRouteBuf(autoRouteId);/*ȡȫԶԶ۷·ӦĻ·*/ + otherRouteSum = GetAllAutoReturnIncludeRouteSum(otherAutoRouteId);/*һȫԶ۷··Ŀ*/ + otherRouteIdBuf = GetAllAutoReturnIncludeRouteBuf(otherAutoRouteId);/*ȡȫԶ۷·ӦĻ·*/ + } + else if ((routeType == ROUTE_ALLAUTOROUTE_RETURN) && (otherRouteType == ROUTE_AUTOROUTE_RETURN)) + { + routeSum = GetAllAutoReturnIncludeRouteSum(autoRouteId);/*ȫԶ۷··Ŀ*/ + routeIdBuf = GetAllAutoReturnIncludeRouteBuf(autoRouteId);/*ȡȫԶԶ۷·ӦĻ·*/ + otherRouteSum = GetAutoReturnIncludeRouteSum(otherAutoRouteId);/*һԶ۷··Ŀ*/ + otherRouteIdBuf = GetAutoReturnIncludeRouteBuf(otherAutoRouteId);/*ȡԶ۷·ӦĻ·*/ + } + else if ((routeType == ROUTE_ALLAUTOROUTE_RETURN) && (otherRouteType == ROUTE_AUTOROUTE_NORMAL)) + { + routeSum = GetAllAutoReturnIncludeRouteSum(autoRouteId);/*ȫԶ۷··Ŀ*/ + routeIdBuf = GetAllAutoReturnIncludeRouteBuf(autoRouteId);/*ȡȫԶԶ۷·ӦĻ·*/ + otherRouteSum = GetAutoRouteIncludeRouteSum(otherAutoRouteId);/*һԶͨ··Ŀ*/ + otherRouteIdBuf = GetAutoRouteIncludeRouteBuf(otherAutoRouteId);/*ȡԶͨ·ӦĻ·*/ + } + else + { + /**/ + } + + for (kk = 0u; kk < routeSum; kk++) + {/*ָIDԶ··*/ + + for (qq = 0u; qq < otherRouteSum; qq++) + {/*һԶ··*/ + if (routeIdBuf[kk] == otherRouteIdBuf[qq]) + {/*жһԶ·Ƿͬ·*/ + returnValue = CI_SUCCESS;/*ִͬ*/ + break; + } + else + { + /*ͬ*/ + opposeRouteSum = GetRouteOpposedRouteIdSum(otherRouteIdBuf[qq]); + opposeRouteBuf = GetRouteOpposedRouteIdBuf(otherRouteIdBuf[qq]);/*ȡû·ִ·*/ + for (nn = 0u; nn < opposeRouteSum; nn++) + { + + if (routeIdBuf[kk] == opposeRouteBuf[nn]) + { + returnValue = CI_SUCCESS;/*ý·ڲͬ·ĵִ·֮Уִ*/ + break; + } + } + } + if (CI_SUCCESS == returnValue) + {/*ִֹͣңʡʱ*/ + break; + } + } + if (CI_SUCCESS == returnValue) + {/*ִֹͣңʡʱ*/ + break; + } + } + + return returnValue; +} +/* +* +* ˵ AxisSectionConfigDataStruct* AxisSectionConfigStru, νṹ + UINT16 physecSum, + const UINT16 *physecIdBuff, ID + UINT8 DataNum +* DataNum +* ֵ +*/ +UINT8 AddExtendAxisSecIdDataManage(AxisSectionConfigDataStruct* AxisSectionConfigStru, UINT16 physecSum,const UINT16 *physecIdBuff) +{ + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT16 ll = 0u; + UINT16 mm = 0U; + UINT8 retVal = 1u; + UINT16 index = 0u; /*±*/ + UINT8 axisSecSum = 0u; + UINT16* pAxisSecIdBuf = NULL; + UINT8 cFuncRet = CI_ERROR; + for(ii = 0u;ii< physecSum;ii++) + { /*ȡļϢļIDӵṹ*/ + axisSecSum = GetPAxisSectionSum(physecIdBuff[ii]); + pAxisSecIdBuf = GetPAxisSectionIdBuf(physecIdBuff[ii]); + if ((0u == axisSecSum) || (NULL == pAxisSecIdBuf)) + { + retVal = 0u; /**/ + } + else + { + index = totalAxisNum; + totalAxisNum += axisSecSum; + for (jj = 0u; jj < axisSecSum; jj++) + { + for (ll=0u;ll< AXIS_SECTION_SUM_MAX;ll++) + { + if (pAxisSecIdBuf[jj] == dquCICfgDtStr.AxisSctCfgDtStr[ll].AxisSectionId) + { + AxisSectionConfigStru[pAxisSecIdBuf[jj]] = dquCICfgDtStr.AxisSctCfgDtStr[ll]; + LocalCiAxisSectionIdBuf[index + jj] = dquCICfgDtStr.AxisSctCfgDtStr[ll].AxisSectionId; + + /*ʼڼʹ泵*/ + AxisSectionConfigStru[pAxisSecIdBuf[jj]].chLinkLine = AXIS_SEC_LINK_LINE_NO; + AxisSectionConfigStru[pAxisSecIdBuf[jj]].chEntrance = AXIS_SEC_ENTRANCE_NO; + AxisSectionConfigStru[pAxisSecIdBuf[jj]].chStorageLineProperty = AXIS_SEC_STORAGE_LINE_NO; + for (mm = 0U; mm < dquCICfgDtStr.wLinkLineCfgDtLen; mm++) + { + if (pAxisSecIdBuf[jj] == dquCICfgDtStr.LinkLineCfgDtStr[mm].wAxisSecId) + { + + if (0x55U == dquCICfgDtStr.LinkLineCfgDtStr[mm].cLinkLineType) + { + /* */ + AxisSectionConfigStru[pAxisSecIdBuf[jj]].chLinkLine = AXIS_SEC_LINK_LINE_YES; + } + else + { + /**/ + } + + if (0x55U == dquCICfgDtStr.LinkLineCfgDtStr[mm].cInType) + { + /* */ + AxisSectionConfigStru[pAxisSecIdBuf[jj]].chEntrance = AXIS_SEC_ENTRANCE_YES; + debug_infor_printf((const)"AddExtendAxisSecIdDataManage: AC[%d] Init Entrance", pAxisSecIdBuf[jj]); + } + else + { + /*DZΣжڼεĴ泵*/ + } + + if (0x55U == dquCICfgDtStr.LinkLineCfgDtStr[mm].cStorageLineType) + { + /* 泵 */ + AxisSectionConfigStru[pAxisSecIdBuf[jj]].chStorageLineProperty = AXIS_SEC_STORAGE_LINE_YES; + } + else + { + /**/ + } + break; + } + else + { + ; + } + } + + break; + } + } + + cFuncRet = EnsureAxleBorderAtrr(pAxisSecIdBuf[jj]); + if (CI_SUCCESS == cFuncRet) + { + AxisSectionConfigStru[pAxisSecIdBuf[jj]].cBorderAttr = AXIS_BORDER_AXLE_YES; + } + else + { + AxisSectionConfigStru[pAxisSecIdBuf[jj]].cBorderAttr = AXIS_BORDER_AXLE_NO; + } + } + } + + } + if (totalAxisNum >= AXIS_SECTION_SUM_MAX) + { + retVal = 0u; + } + return retVal; +} + + + +/********************************************* +*ܣȡźŻɫ +*˵void +*ֵ-1ȡʧ + 0uȡɹ +*********************************************/ +INT8 ReadSignalDrvTypeOpenColorCfg(void) +{ + INT8 rtnValue = -1; + + UINT8 funcRtn = 0u; + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 j = 0u; + UINT8 blockOpenColorNum = 0u; + UINT32 excelId = 0u; /*excel id*/ + UINT32 sheetId = 0u; /*sheet id*/ + UINT32 rowLen = 0u; /*г*/ + UINT8 localCiPattern = 0u; /*CIģʽ*/ + + localCiPattern = GetLocalCiPattern(); + if (CI_PATTERN_TRADITIONAL == localCiPattern) + { + excelId = CI_DATA_TYPE; + sheetId = RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID; + rowLen = LEN_RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID; + } + else + { + excelId = OC_DATA_TYPE; + sheetId = OC_RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID; + rowLen = OC_LEN_RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID; + } + + /*ȡ ̵ */ + funcRtn = dquGetConfigData((const)DataPath, excelId, sheetId,&pDataAddr,&DataSize); + if(funcRtn == 0u) + { + /*ʧ*/ + rtnValue = -1; + } + else + {/*óɹ*/ + rtnValue = 0; + } + + if (0 == rtnValue) + { + /*ø*/ + if(DataSize% rowLen != 0u) + { + rtnValue = -1; + debug_infor_printf((const)"\nCI_RELAY_DATA,RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID,len %d not equal to fs", rowLen); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(excelId <<8)+ sheetId,PRINT_ONCE); + } + } + + if (0 == rtnValue) + { + SignalTypeNum = (UINT16)(DataSize/ rowLen); + /*ڴΪЧ*/ + (void)memset(SignalTypeOpenColorConfigStru, 0x00,sizeof(SignalDrvTypeOpenColorConfig) * SIGNAL_MAX_DRVCOLL_TYPE_NUM); + + /*ݵ źŻͺ󱸿ɫýṹ */ + for(j=0u;j= SIGNAL_MAX_DRVCOLL_TYPE_NUM) + { + rtnValue = -1; + break; + } + + SignalTypeOpenColorConfigStru[j].SignalId = dquCiShortFromChar(pDataAddr); + pDataAddr +=2; + SignalTypeOpenColorConfigStru[j].BlockOpenColorValue[0u] = (UINT8)dquCiShortFromChar(pDataAddr); + pDataAddr +=2; + SignalTypeOpenColorConfigStru[j].BlockOpenColorValue[1] = (UINT8)dquCiShortFromChar(pDataAddr); + pDataAddr +=2; + SignalTypeOpenColorConfigStru[j].BlockOpenColorValue[2] = (UINT8)dquCiShortFromChar(pDataAddr); + pDataAddr +=2; + + } + + } + + return rtnValue; +} + +/********************************************* +*ܣղ̵ṹ +*˵ +*ֵ-1ʧܣ0ɹ +*********************************************/ +INT8 ReadZhaochaCheckConfigData(void) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 realRowCount = 0u; /*ʵʱݵ*/ + UINT16 realRowLen = 0u; /*ʵʱݵһеij*/ + UINT8 CheckType; /**/ + UINT8 DevType; /* 豸 (ֶ)*/ + UINT16 DevId; + INT8 rtnValue = -1; + + + /*ȡ Ĭг */ + funcRtn = dquGetConfigDataNew((const)DataPath, CI_DATA_TYPE, RELAY_ZHAOCHA_CI_CHECK_ID,&pDataAddr,&DataSize,&realRowCount); + if(0u == funcRtn) + { + /*ʧ*/ + rtnValue = 0; + debug_infor_printf((const)"\nRELAY_ZHAOCHA_CI_CHECK_ID NO IN FS\n"); + } + else + { + rtnValue = 0; + if((0u != DataSize) && (0u != realRowCount)) + { + if(0u != (DataSize % realRowCount)) + { + debug_infor_printf((const)"\n CI_DATA_TYPE,RELAY_ZHAOCHA_CI_CHECK_ID len %d %d not equal to fs\n",DataSize,realRowCount); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_DATA_TYPE<<8u)+RELAY_ZHAOCHA_CI_CHECK_ID,PRINT_ONCE); + rtnValue = -1; + } + else + { + /*ʵһеֽڳ*/ + realRowLen = (UINT16)DataSize / realRowCount; + /*ڴΪЧ*/ + (void)memset(ZhaochaCheckConfigDataStru, 0x00,sizeof(ZhaochaCheckConfigDataStruct) *realRowCount); + /*д*/ + CiCheckZhaoChaRelayNum = realRowCount; + + for(i = 0u; i < realRowCount; i++) + { + if(ZHAOCHA_CHECK_SUM_MAX > i) + { + ZhaochaCheckConfigDataStru[i].ZhaochaRelayId = dquCiShortFromChar(pDataAddr); + pDataAddr += 2; + for(j = 0u; j < ZHAOCHA_CHECK_TYPE_SUN_MAX; j++) + { + CheckType = *(pDataAddr); + pDataAddr += 1; + DevType = *(pDataAddr); + pDataAddr += 1; + DevId = dquCiShortFromChar(pDataAddr); + pDataAddr += 2; + + /*д*/ + if((UINT8_MAX != CheckType) && (0u != CheckType) &&(UINT8_MAX != DevType) && (0u != DevType) + &&(UINT16_MAX != DevId) && (0u != DevId)) + { + /*Ϸֵ*/ + ZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[ZhaochaCheckConfigDataStru[i].ZhaochaCheckSum].CheckType = CheckType; + ZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[ZhaochaCheckConfigDataStru[i].ZhaochaCheckSum].DevType = DevType; + ZhaochaCheckConfigDataStru[i].ZhaochaCheckTypeBuf[ZhaochaCheckConfigDataStru[i].ZhaochaCheckSum].DevId = DevId; + ZhaochaCheckConfigDataStru[i].ZhaochaCheckSum++; + } + else + { + /*޲*/ + } + } + + } + else + { + /*޲*/ + } + } + + } + + } + else + { + /**/ + } + } + return rtnValue; +} + +/* +*ܣжϱZCĿ +*˵ciIdID +*ֵͨŹϵ +*/ +UINT8 CheckCiHaveZcSumErr(const UINT8 ciId) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT8 retValue = CI_ERROR; + + for(i = 0u; i < TRANSMIT_OBJECT_SUM_MAX; i++) + { + /**/ + if(ciId == TransmitRelaDataStru[i].CiId) + { + /*ҵZCĿ*/ + if(CI_SYSTEM_TYPE_ZC == TransmitRelaDataStru[i].SystemType) + { + retValue = TransmitRelaDataStru[i].DeviceSum; + break; + } + } + } + return(retValue); +} + +/* +* ߽ӿڼ̵ñݳʼӦ豸 +* ˵ SignalConfigDataStruct* pSignalCfgData źŻṹ +* PhysicalSectionConfigDataStruct* pPhyCfgData νṹ +* SwitchConfigDataStruct* pSwitchCfgData ṹ +* OcConnetDataCfgStruct* pConnectCfgData ݽṹ +* RelayConfigDataStruct* pRelayCfgData ̵ṹ +* ֵ 0ɹ-1ʧ +* NOTEbug YF0083-224 +*/ +INT8 OcConnectConfigDataToDevStruct(SignalConfigDataStruct* pSignalCfgData, PhysicalSectionConfigDataStruct* pPhyCfgData, SwitchConfigDataStruct* pSwitchCfgData, OcConnetDataCfgStruct* pConnectCfgData, RelayConfigDataStruct* pRelayCfgData) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 k = 0u; + UINT16 m = 0U; + INT8 retValue = -1; + + if ((NULL != pSignalCfgData) && (NULL != pPhyCfgData) && (NULL != pSwitchCfgData) && ((NULL != pConnectCfgData))) + { + retValue = 0; + for (i = 0u; i < OcConnetDataDevNum; i++) + { + if (CI_DEVICE_TYPE_SIGNAL == pConnectCfgData[i].DevType) + { + /*ʼźŻ*/ + for (j = 0u; j < SIGNAL_SUM_MAX; j++) + { + if ((pSignalCfgData[j].SignalId == pConnectCfgData[i].DevId) && (0u != pSignalCfgData[j].SignalId)) + { + pSignalCfgData[j].SignalIsThisLine = pConnectCfgData[i].DevIsThisLine; + /*LXJ*/ + for (k = 0u; k < OC_LIAISON_RELAY_SUM_MAX; k++) + { + if (SIGNAL_LXJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSignalCfgData[j].LxRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pSignalCfgData[j].LxDrvRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + else if (SIGNAL_YXJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSignalCfgData[j].YxRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pSignalCfgData[j].YxDrvRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + else if (SIGNAL_DXJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSignalCfgData[j].DxRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pSignalCfgData[j].DxDrvRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + else + { + ; /**/ + } + } + break; + } + } + } + /*ʼ*/ + else if (CI_DEVICE_TYPE_PHYSEC == pConnectCfgData[i].DevType) + { + for (j = 0u; j < PHYSICAL_SECTION_SUM_MAX; j++) + { + if ((pPhyCfgData[j].PhysicalSectionId == pConnectCfgData[i].DevId) && (0u != pPhyCfgData[j].PhysicalSectionId)) + { + pPhyCfgData[j].PhyIsThisLine = pConnectCfgData[i].DevIsThisLine; + + for (k = 0u; k < OC_LIAISON_RELAY_SUM_MAX; k++) + { + /*GJ*/ + if (PHY_GJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pPhyCfgData[j].GdRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pPhyCfgData[j].GdDrvRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + } + break; + } + } + } + /*ʼ*/ + else if (CI_DEVICE_TYPE_SWITCH == pConnectCfgData[i].DevType) + { + for (j = 0u; j < SWITCH_SUM_MAX; j++) + { + if ((pSwitchCfgData[j].SwitchId == pConnectCfgData[i].DevId) && (0u != pSwitchCfgData[j].SwitchId)) + { + pSwitchCfgData[j].SwitchIsThisLine = pConnectCfgData[i].DevIsThisLine; + for (k = 0u; k < OC_LIAISON_RELAY_SUM_MAX; k++) + { + /*DBJ*/ + if (SWITCH_DBJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSwitchCfgData[j].DbRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pSwitchCfgData[j].DbDrvRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + /*FBJ*/ + else if (SWITCH_FBJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSwitchCfgData[j].FbRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pSwitchCfgData[j].FbDrvRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + /*DSJ*/ + else if (SWITCH_DSJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSwitchCfgData[j].DsRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pSwitchCfgData[j].DsDrvRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + /*DSQJ*/ + else if (SWITCH_DSQJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSwitchCfgData[j].DsQRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pSwitchCfgData[j].DsDrvQRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + /*DSHJ*/ + else if (SWITCH_DSHJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSwitchCfgData[j].DsHRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + pSwitchCfgData[j].DsDrvHRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId; + } + /*PYPASS*/ + else if (SWITCH_BYPASSJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + pSwitchCfgData[j].ByPassRelayId = pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId; + } + else + { + /**/ + } + + } + + break; + } + } + } + /*ʼղ*/ + else if (CI_DEVICE_TYPE_ZHAOCHA == pConnectCfgData[i].DevType) + { + for (k = 0u; k < OC_LIAISON_RELAY_SUM_MAX; k++) + { + if (CHECK_ZCJ_TYPE == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayType) + { + for (j = 0U; j < RELAY_SUM_MAX; j++) + { + /*߽ӿڼ̵Ͳɼ̵ͬʱ򣬲ϲɼ̵ϵĴ,ϲΪ·DZ·ֻвɼ*/ + if ((pRelayCfgData[j].RelayId == pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId) + && (0U != pRelayCfgData[j].RelayId) + && (pConnectCfgData[i].OcConnetRelayDataBuf[k].RelayId != pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId) + && (DEV_IS_THIS_LINE_YES == pConnectCfgData[i].DevIsThisLine)) + { + if (0U != pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId) + { + for (m = 0U; m < RELAY_SUM_MAX; m++) + { + if (pRelayCfgData[m].RelayId == pConnectCfgData[i].OcConnetRelayDataBuf[k].DrvRelayId) + { + pRelayCfgData[j].BelongDrvOcId = pRelayCfgData[m].BelongDrvOcId; + pRelayCfgData[j].DrvAddrA = pRelayCfgData[m].DrvAddrA; + pRelayCfgData[j].DrvPosA = pRelayCfgData[m].DrvPosA; + pRelayCfgData[j].DrvAddrB = pRelayCfgData[m].DrvAddrB; + pRelayCfgData[j].DrvPosB = pRelayCfgData[m].DrvPosB; + pRelayCfgData[m].RelayId = 0U; + pRelayCfgData[m].BelongOcId = 0U; + pRelayCfgData[m].BelongDrvOcId = 0U; + pRelayCfgData[m].DrvAddrA = 0U; + pRelayCfgData[m].DrvAddrB = 0U; + pRelayCfgData[m].DrvPosA = 0U; + pRelayCfgData[m].DrvPosB = 0U; + break; + } + } + } + } + } + } + } + } + else + { + /**/ + } + } + } + else + { + /*ʧ*/ + retValue = -1; + } + return(retValue); +} + + +/********************************************* +*ܣʼOC ߽ӿڼ̵ñ +*˵void +*ֵ1ɹ0ʧ +*********************************************/ +UINT8 OcConnectConfigDataStructInit(void) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 realRowCount = 0u; /*ʵʱݵ*/ + UINT8 rtnValue = 0u; + + + /*ȡ*/ + /*ȡ Ĭг */ + funcRtn = dquGetConfigDataNew((const)DataPath, OC_DATA_TYPE, OC_LIAISON_RELAY_ID,&pDataAddr,&DataSize,&realRowCount); + if(0u == funcRtn) + { + /*ʧ*/ + rtnValue = 1u; + debug_infor_printf((const)"\nOC_LIAISON_RELAY_ID NO IN FS\n"); + } + else + { + rtnValue = 1u; + /**/ + if((0u != DataSize) && (0u != realRowCount)) + { + if(0u != (DataSize % realRowCount)) + { + debug_infor_printf((const)"\n OC_DATA_TYPE,OC_LIAISON_RELAY_ID len %d %d not equal to fs\n",DataSize,realRowCount); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_DATA_TYPE<<8)+OC_LIAISON_RELAY_ID,PRINT_ONCE); + rtnValue = 0u; + } + else + { + /*д豸*/ + OcConnetDataDevNum = realRowCount; + /*ڴΪЧ*/ + (void)memset(OcConnetDataCfgStru, 0x00,sizeof(OcConnetDataCfgStruct) *OC_LIAISON_DEV_SUM_MAX); + + for(i = 0u; i < realRowCount; i++) + { + if(OC_LIAISON_DEV_SUM_MAX > i) + { + OcConnetDataCfgStru[i].DevType = *(pDataAddr); + pDataAddr += 1; + OcConnetDataCfgStru[i].DevId = dquCiShortFromChar(pDataAddr); + pDataAddr += 2; + for(j = 0u; j < OC_LIAISON_RELAY_SUM_MAX; j++) + { + OcConnetDataCfgStru[i].OcConnetRelayDataBuf[j].RelayType = *(pDataAddr); + pDataAddr += 1; + OcConnetDataCfgStru[i].OcConnetRelayDataBuf[j].RelayId = dquCiShortFromChar(pDataAddr); + pDataAddr += 2; + OcConnetDataCfgStru[i].OcConnetRelayDataBuf[j].DrvRelayId = dquCiShortFromChar(pDataAddr); + pDataAddr += 2; + } + OcConnetDataCfgStru[i].DevIsThisLine = *(pDataAddr); + pDataAddr += 1; + } + else + { + /*޲*/ + } + } + } + } + else + { + /**/ + } + } + return(rtnValue); +} + +/********************************************* +*ܣȡ̬ +*˵UINT32* pConfigDataAdderBuf ̬ݴŵַ,UINT16 pConfigDataLenBuf ̬ݳȴŵַ,UINT16 wBufMaxLen +*ֵ̬ +*********************************************/ +UINT16 GetTiocDeviceConfigData(UINT32* pConfigDataAddrBuf,UINT16* pConfigDataLenBuf,UINT16 wBufMaxLen) +{ + UINT16 wRetSum = 0u; + UINT16 wTmpConfigDataSum = 0u; + UINT16 wTmpLen = 0u; + + if ((NULL != pConfigDataAddrBuf) && (NULL != pConfigDataLenBuf) && (0u != wBufMaxLen) && (UINT16_MAX != wBufMaxLen)) + { + /* ǰڵAϵ忨 */ + wTmpLen = wTmpConfigDataSum + 1u; + + pConfigDataAddrBuf[wTmpConfigDataSum] = BoardConfigForeNodeA; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(BoardConfigStruct) * BOARD_MAX_ADDR); + wTmpConfigDataSum++; + + + + /* ǰڵBϵ忨 */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = BoardConfigForeNodeB; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(BoardConfigStruct) * BOARD_MAX_ADDR); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ڵAϵ忨 */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = BoardConfigBackNodeA; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(BoardConfigStruct) * BOARD_MAX_ADDR); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ڵBϵ忨 */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = BoardConfigBackNodeB; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(BoardConfigStruct) * BOARD_MAX_ADDR); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ̵ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = RelayConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(RelayConfigDataStruct) * RELAY_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ̵ID */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiRelayIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * RELAY_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ̵ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &RelayCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* źŻ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = SignalConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(SignalConfigDataStruct) * SIGNAL_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + + /* źŻID */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiSignalIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * SIGNAL_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* źŻ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &SignalCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(INT16)); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ϴ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = WashMachineConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(WashMachineConfigDataStruct) * WASHMACHINE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ϴID */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiWashMachineIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * WASHMACHINE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ϴ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &WashMachineCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = SwitchConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(SwitchConfigDataStruct) * SWITCH_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ID */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiSwitchIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * SWITCH_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &SwitchCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = PhysicalSectionConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(PhysicalSectionConfigDataStruct) * PHYSICAL_SECTION_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Id */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiPhysicalSectionIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * PHYSICAL_SECTION_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &PhysicalSectionCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = AxisSectionConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(AxisSectionConfigDataStruct) * AXIS_SECTION_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiAxisSectionIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * AXIS_SECTION_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &AxisSectionCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + + /* ߼*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LogicSectionConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(LogicSectionConfigDataStruct) * LOGIC_SECTION_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ߼ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiLogicSectionIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * LOGIC_SECTION_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ߼*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &LogicSectionCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = OverlapConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(OverlapConfigDataStruct) * OVERLAP_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiOverlapIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * OVERLAP_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &OverlapCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = PsdConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(PsdConfigDataStruct) * PSD_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiPsdIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * PSD_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &PsdCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ͣť*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = EsbConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(EsbConfigDataStruct) * ESB_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ͣťID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiEsbIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * ESB_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ͣť*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &EsbCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ǽ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &NonRouteCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ǽ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = NonRouteConfigDataStruArr; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(NonRouteConfigDataStruct) * NONROUTE_ID_NUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = RouteConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(RouteConfigDataStruct) * ROUTE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiRouteIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * ROUTE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &RouteCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ۷·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = AutoReturnConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(AutoReturnConfigDataStruct)*AUTO_RETURN_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ۷·ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiAutoReturnIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16)*AUTO_RETURN_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ۷·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &AutoReturnCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = AutoRouteConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(AutoRouteConfigDataStruct) * AUTO_ROUTE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ·ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiAutoRouteIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * AUTO_ROUTE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &AutoRouteCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = ReverseRouteConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(ReverseRouteConfigDataStruct) * ROUTE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiReverseRouteIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * REVERSE_ROUTE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &ReverseRouteCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LongRouteConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(LongRouteConfigDataStruct) * ROUTE_LONG_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·ǰ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &LongRouteCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ͨŹϵ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = TransmitRelaDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(TransmitRelationDataStruct) * TRANSMIT_OBJECT_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ͨŹϵ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &TransmitRelaDataCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ָʾ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = IndicatorConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(IndicatorConfigDataStruct) * INDICATOR_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ָʾƸ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &IndicatorCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ۷·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = AllAutoReturnConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(AllAutoReturnConfigDataStruct) * ALL_AUTO_RETURN_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ۷·ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiAllAutoReturnIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * ALL_AUTO_RETURN_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ۷·*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &AllAutoReturnCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = GaragedoorConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(GARAGE_DOOR_SUM_MAX * sizeof(GaragedoorConfigDataStruct)); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiGaragedoorIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(GARAGE_DOOR_SUM_MAX * sizeof(UINT16)); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /**/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &GaragedoorCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*SPKS*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = spksDataConfigBuff; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(SpksDataConfigStruct) * SPKS_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*SPKS*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = spksDataConfigIdxBuff; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * SPKS_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*SPKS*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &spksSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*վ̨ſϵͳ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = PscConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(PscConfigDataStruct) * PSC_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*վ̨ſϵͳ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &PscCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /**/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = FloodGateConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(FloodGateConfigDataStruct) * FLOOD_GATE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = LocalCiFloodGateIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * FLOOD_GATE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /**/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &FloodGateCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*ֽ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = g_szCfpConfig; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(CfpConfigStru) * CUTOFF_POINT_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + + /*ֽID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = gszCfpId; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * CUTOFF_POINT_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*ֽ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &gCfpConfigSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16)); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /**/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = gstReverseCutCfgData; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(ReverseCutCfgDataStru) * REVERSE_CUT_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + + /*豸ID*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = gReverseCutCfgIdBuf; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(UINT16) * REVERSE_CUT_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*豸*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &gReverseCutCfgSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*λ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = CiToAtsMaskConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(MaskConfigDataStruct) * CI_TO_ATS_MASK_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*λ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &CiToAtsMaskCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*λ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = CiToLeuMaskConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(MaskConfigDataStruct) * CI_TO_LEU_MASK_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /*λ*/ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &CiToLeuMaskCurSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Ӧ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &JkjRelayId; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + + /* ӿ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = ciTransmitStruct; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(CiTransmitStruct) * CI_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &ciTransNum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = InvSecConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(InvSecConfigDataStruct) * INVA_SECT_N_COND_SWIT_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &InvSecSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(INT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ·豸 */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &DiffLineDevData; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(DiffLineDevStruct); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* 豸 */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &DiffLineDevSum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &totalAxisNum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ϵͳ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &SystemParameterStruNew; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(SystemParameterStructNew); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* õźŻ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &SignalTypeNum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* źŻͺ󱸿ɫýṹ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = SignalTypeOpenColorConfigStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(SignalDrvTypeOpenColorConfig) * SIGNAL_MAX_DRVCOLL_TYPE_NUM); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* Զ·ýṹ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = GroupAutoRouteConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(GroupAutoRouteConfigDataStruct) * GROUP_AUTO_ROUTE_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* ղ */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = ZhaochaCheckConfigDataStru; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(ZhaochaCheckConfigDataStruct) * ZHAOCHA_CHECK_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* link */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = g_szLinkConfigData; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(LinkDataConfigStru) * LINK_SUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* link */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &g_linkNum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = g_szAxisData; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)(sizeof(AxisConfigStru) * AXIS_NUM_MAX); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + /* */ + wTmpLen = wTmpConfigDataSum + 1u; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAddrBuf[wTmpConfigDataSum] = &g_axisNum; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + /* ޴ */ + } + + wRetSum = wTmpConfigDataSum; + } + else + { + ;/* ޴ */ + } + + + return wRetSum; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Initial/ConfigDataReadManage.h b/TSCP/src/APP/ciapp/Initial/ConfigDataReadManage.h new file mode 100644 index 0000000..76ac73b --- /dev/null +++ b/TSCP/src/APP/ciapp/Initial/ConfigDataReadManage.h @@ -0,0 +1,167 @@ +/******************************************************** +* +* ConfigDataReadManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 +* ߣ +* +* ޸ļ¼ +* +********************************************************/ + +#ifndef _INTERLOCK_DATA_CONFIGDATAREADMANAGE_H_ +#define _INTERLOCK_DATA_CONFIGDATAREADMANAGE_H_ + + +#include "../AutoRoute/AutoRouteConfigDataManage.h" +#include "../AutoReturn/AutoReturnConfigDataManage.h" +#include "../AutoRoute/AutoRouteConfigDataManage.h" +#include "../ESB/ESBConfigDataManage.h" +#include "../psd/PSDConfigDataManage.h" +#include "../PSD/PSDDataManage.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Section/AxisSectionConfigDataManage.h" +#include "../Section/LogicSectionConfigDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Overlap/OverlapConfigDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../WashMachine/WashMachineConfigDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../System/SystemParameterManage.h" +#include "../System/CiSystemDefine.h" +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../Transmit/TransmitStateDataManage.h" +#include "../NonRoute/NonRouteConfigDataManage.h" +#include "../Route/LongRouteConfigDataManage.h" +#include "../Indicator/IndicatorConfigDataManage.h" +#include "../QueryFiles/dquCIInterFace.h" +#include "../DataManage/DeviceDataManage.h" +#include "../System/SystemConfigDefine.h" +#include "../Garagedoor/GaragedoorConfigDataManage.h" +#include "../spks/SpksConfigDataManage.h" +#include "../FloodGate/FloodGateConfigDataManage.h" +#include "../AllAutoReturn/AllAutoReturnConfigDataManage.h" +#include "../InvadeSection/InvadeSectionConfigDataManage.h" +#include "../InvadeSection/InvadeSectionDataManage.h" +#include "../DataManage/DeviceConfigDataManage.h" +#include "../PSC/PSCConfigDataManage.h" +#include "../Section/LinkConfigDataManage.h" +#include "../NonAutoReturn/NonAutoReturnConfigDataManage.h" +#include "../QueryFiles/dquCIReadCommonChar.h" +#include "../Indicator/IndicatorConfigDataManage.h" +#include "../CutoffPoint/CutoffPointConfigDataManage.h" +#include "../DiffLineDev/DiffLineDevConfigDataManage.h" +#include "../ParsePack/ParsePackCommon.h" +#include "../ParsePack/ParsePackVobcData.h" +#include "../ParsePack/ParsePackCiData.h" +#include "../Route/LongRouteConfigDataManage.h" +#include "../SGBJ/SGBJConfigDataManage.h" +#include "../VirtualDevice/VirtualDevDataManage.h" + +extern INT16 trackCheckRes; +extern INT16 g_ret; + +/* + ݽṹͳһʼ + ˵ + ֵ 0u,ʼʧܣ1uʼɹ + *cgh-ϲCID-2539-6 +*/ +UINT8 InitAllStaticDataStr(void); + +/* +* ļ +* ˵ +* ֵ 0,ɹ +* 1,ݸֵʧ +* 2,ѯʼʧ +* 3,ʧ +* 4,ID +*/ +UINT8 ReadConfigureData(void); + + +/* +* 豸 +* ˵ +* ֵ 0,ɹ +* >0,ʧ +*/ +UINT8 DeviceDataManage(void); +/* +* ȡָԶ·IDִԶ· +* ˵ UINT16 autoRouteRouteIdָԶ·ID +* ֵ CI_ERRORʧ CI_SUCCESSɹ +*/ +UINT8 SetautoRouteOpposedRoute(UINT16 autoRouteRouteId,UINT8 routeType); + +/* +* жָIDԶ·Ƿִ +* ˵ UINT16 autoRouteRouteIdָԶ·ID + UINT16 otherAutoRouteIdһԶ·ID +* ֵ CI_ERROR: ִ +* CI_SUCCESS: ִ +*/ +UINT8 AutoRouteIsOpposed(UINT16 autoRouteId,UINT8 routeType,UINT16 otherAutoRouteId,UINT8 otherRouteType); +/* +* ESB +* ˵ logSecSum ߼ +* logSecIdBuff ͸߼ID +* ֵ +*/ +UINT8 AddExtendAxisSecIdDataManage(AxisSectionConfigDataStruct* AxisSectionConfigStru, UINT16 physecSum,const UINT16 *physecIdBuff); + +/********************************************* +*ܣȡźŻɫ +*˵void +*ֵźŻ +*********************************************/ +INT8 ReadSignalDrvTypeOpenColorCfg(void); + +/********************************************* +*ܣղ̵ṹ +*˵ +*ֵ-1ʧܣ0ɹ +*********************************************/ +INT8 ReadZhaochaCheckConfigData(void); + +/* +*ܣжϱZCĿ +*˵ciIdID +*ֵͨŹϵ +*/ +UINT8 CheckCiHaveZcSumErr(const UINT8 ciId); + +/********************************************* +*ܣʼOC ߽ӿڼ̵ñ +*˵void +*ֵ1ɹ0ʧ +*********************************************/ +UINT8 OcConnectConfigDataStructInit(void); + +/* +* ߽ӿڼ̵ñݳʼӦ豸 +* ˵ SignalConfigDataStruct* pSignalCfgData źŻṹ +* PhysicalSectionConfigDataStruct* pPhyCfgData νṹ +* SwitchConfigDataStruct* pSwitchCfgData ṹ +* OcConnetDataCfgStruct* pConnectCfgData ݽṹ +* RelayConfigDataStruct* pRelayCfgData ̵ṹ +* ֵ 0ɹ-1ʧ +* NOTEbug YF0083-224 +*/ +INT8 OcConnectConfigDataToDevStruct(SignalConfigDataStruct* pSignalCfgData, PhysicalSectionConfigDataStruct* pPhyCfgData, SwitchConfigDataStruct* pSwitchCfgData, OcConnetDataCfgStruct* pConnectCfgData, RelayConfigDataStruct* pRelayCfgData); + +/********************************************* +*ܣȡ̬ +*˵UINT32* pConfigDataAdderBuf ̬ݴŵַ,UINT16 pConfigDataLenBuf ̬ݳȴŵַ,UINT16 wBufMaxLen +*ֵ̬ +*********************************************/ +UINT16 GetTiocDeviceConfigData(UINT32* pConfigDataAddrBuf, UINT16* pConfigDataLenBuf, UINT16 wBufMaxLen); +#endif + + + + diff --git a/TSCP/src/APP/ciapp/Initial/InitialProcess.c b/TSCP/src/APP/ciapp/Initial/InitialProcess.c new file mode 100644 index 0000000..94075f3 --- /dev/null +++ b/TSCP/src/APP/ciapp/Initial/InitialProcess.c @@ -0,0 +1,3195 @@ +/******************************************************** +* +* InitialProcess.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-06-29 +* ߣ +* ݳʼļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#include "InitialProcess.h" +#include "CutoffPointDataManage.h" +#include "AxisSort_api.h" +#include "SectionStateProcess_api.h" +#include "HLHTHeadContexManage.h" +#include "WLBrakeDataManage.h" +#include "NonAutoReturnConfigDataManage.h" +#include "../Deployment/DeploymentExtern.h" +#include "NonAutoReturnDataManage.h" + +/****************************ʼ̬ݶ********************************************/ +extern TransmitRelationDataStruct TransmitRelaDataStru[TRANSMIT_OBJECT_SUM_MAX]; /*ѶͨŹϵݽṹ*/ +extern TransmitStateDataStruct TransmitStateDataStru[TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX]; /*Ѷͨ״̬ṹ*/ +extern UINT16 TransmitRelaDataCurSum; /*ͨŹϵݵǰ*/ +extern UINT16 TransmitStateDataCurSum; /*ͨŹϵ״̬ݵǰ*/ + +extern DSU_DATA_LEN_STRU dsuDataLenStru; /*¼ȡDSUеĸݵ*/ +extern DSU_STATIC_HEAD_STRU dsuStaticHeadStru; /*¼ȡDSUݿÿֽṹͷָ*/ + +/*--------------------------- */ + /* ڲ*/ +UINT8 SetAutoSignalId(void); + + +/* +* ʼźŻĽ·־ +* ˵ UINT16 signalId źŻID +* ֵ void +* +*/ +void SetSignalLeadRouteCbtcFlag(UINT16 signalId); +/*--------------------------- */ +/* +* ʼ߼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialProcess(void) +{ + UINT8 ret = CI_SUCCESS; + UINT8 sheBeiInit = 0u; + UINT8 chSwitch = 0u; + UINT8 cRcWorkMode = 0U; + UINT32 rccycleTime = 0U; + UINT8 cCheckFlag = CI_ERROR; + + /*ƽ̨ʼ*/ + if (0U == Initial2oo2Interface()) + { + ret = CI_ERROR; + } + + /*ȡ*/ + if (0u != ReadConfigureData()) + { +#ifdef PLATFORM_2OO2 + + (void)printf("ReadConfigureData Error\n"); + debug_infor_printf((const)"ReadConfigureData Error\n"); +#endif + + ret = CI_ERROR; + + + } + + cRcWorkMode = GetLocalRcWorkMode(); + + + if (CI_SUCCESS == ret) + { + SystemParaTimeToCycleCount(); + } + + + /*ʼ·*/ + if (CI_SUCCESS == ret) + { + if (CI_ERROR == InitialRouteData()) + { + ret = CI_ERROR; + } + } + + /*ʼ·*/ + if (CI_SUCCESS == ret) + { + InitialLongRouteData(); + } + + /*ʼźŻ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialSignalData()) + { + ret = CI_ERROR; + } + } + /*ʼϴ*/ + if(CI_SUCCESS == ret) + { + if(CI_ERROR == InitialWashMachineData()) + { + ret = CI_ERROR; + } + } + /*ʼ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialSwitchData()) + { + ret = CI_ERROR; + } + } + + /*ʼ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialPhySectionData()) + { + ret = CI_ERROR; + } + } + /*ʼ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialAxisSectionData()) + { + ret = CI_ERROR; + } + } + /*ʼ߼*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialLogicSectionData()) + { + ret = CI_ERROR; + } + } + /*ʼͣť*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialEsbData()) + { + ret = CI_ERROR; + } + } + /*ʼ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialPsdData()) + { + ret = CI_ERROR; + } + } + /*ʼվ̨*/ + if(CI_SUCCESS == ret) + { + if(CI_ERROR == InitialPlatformData()) + { + ret = CI_ERROR; + } + } + /*ʼվ̨ſ*/ + if(CI_SUCCESS == ret) + { + if(CI_ERROR == InitialPscToCiData()) + { + ret = CI_ERROR; + } + } + /*ʼ̵*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialRelayData()) + { + ret = CI_ERROR; + } + } + + /*ʼ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialOverlapData()) + { + ret = CI_ERROR; + } + } + /*ʼԶ۷*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialAutoReturnRouteData()) + { + ret = CI_ERROR; + } + } + + /*ʼԶͨ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialAutoRouteRouteData()) + { + ret = CI_ERROR; + } + } + /*ʼǽ·*/ + InitialNonRouteData(); + + /*ʼָʾ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialIndicatorStateData()) + { + ret = CI_ERROR; + } + } + /*ʼͨ״̬*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialTransmitStateData()) + { + ret = CI_ERROR; + } + } + /*ʼ״̬ȨID*/ + if(CI_SUCCESS == ret) + { +#if 0 + if (CI_ERROR == InitialPhySecIdBufOfOtherCi()) + { + ret = CI_ERROR; + } +#else + if (CI_ERROR == InitPhySecIdBufOfOtherCiByConf()) + { + ret = CI_ERROR; + } +#endif + + } + + /*ʼ跢͵ȥ߼·ID*/ + if (CI_SUCCESS == ret) + { + if (CI_ERROR == InitLeaveLogIdBufOfOtherCiByConf()) + { + ret = CI_ERROR; + } + + } + + /*ʼ跢͵Ҫ״̬Ľ·*/ + if (CI_SUCCESS == ret) + { + cCheckFlag = InitNeedCheckSwitchStaRoute(); + if (CI_SUCCESS == cCheckFlag) + { + + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + debug_infor_printf((const)"InitNeedCheckSwitchStaRoute Error\n"); + } + } + + /*ʼҪɱ״̬ı*/ + if (CI_SUCCESS == ret) + { + cCheckFlag = InitNeedCheckProSwtStaOverlap(); + if (CI_SUCCESS == cCheckFlag) + { + /*ʼ*/ + } + else + { + ret = CI_ERROR; + debug_infor_printf((const)"InitNeedCheckProSwtStaOverlap Error\n"); + } + } + else + { + /**/ + } + + /*ʼҪõķϢ*/ + if (CI_SUCCESS == ret) + { + cCheckFlag = InitNeedOlapUsingOtherCiProSw(); + if (CI_SUCCESS == cCheckFlag) + { + /*ʼ*/ + } + else + { + ret = CI_ERROR; + debug_infor_printf((const)"InitNeedOlapUsingOtherCiProSw Error\n"); + } + } + else + { + /**/ + } + + /*ʼȫԶ۷*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialAllAutoReturnRouteData()) + { + ret = CI_ERROR; + } + } + /*ʼ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialGaragedoorData()) + { + ret = CI_ERROR; + } + } + /*ʼSPKS*/ + if(CI_SUCCESS == ret) + { + sheBeiInit = SpksDataManageInit(); + if (CI_ERROR == sheBeiInit) + { + ret = CI_ERROR; + } + } + + /*ʼESB*/ + if (CI_SUCCESS == ret) + { + if (CI_ERROR == EsbDataManageInit()) + { + ret = CI_ERROR; + } + } + + /*ʼ*/ + if(CI_SUCCESS == ret) + { + if (CI_ERROR == InitialFloodGateData()) + { + ret = CI_ERROR; + } + } + + + /*ʼгģ*/ + if (CI_SUCCESS == ret) + { + ret = TrainDataModuleInit(); + } + + + /* ʼֽ */ + if (CI_SUCCESS == ret) + { + ret = CutoffPointDataManageInit(); + } + + /* ʼ豸 */ + if (CI_SUCCESS == ret) + { + ret = ReverseCutDataManageInit(); + } + + + /* ʼ۷ */ + if (CI_SUCCESS == ret) + { + ret = NonReturnConfigDataManage(); + } + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + /*ʼ̬· TIOCģʽ³ʼ*/ + InitialDynamicRouteData(); + /*ʼ߼· TIOCģʽ³ʼ*/ + InitialLogicalRouteData(); + + if (CI_SUCCESS == ret) + { + chSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH); + if (FUNC_SWITCH_ON == chSwitch) + { + ret = ToaInit(); + } + else + { + ; + } + } + else + { + ; + } + + /*ʼ*/ + if (CI_SUCCESS == ret) + { + as_Init(); + ret = elm_Init(); + ssp_Init(); + + } + } + else + { + ; /* ޴ */ + } + + /*ʼȫɸ*/ + if (CI_SUCCESS == ret) + { + ret = wls_Init(); + } + + /*ʼɢ*/ + if (CI_SUCCESS == ret) + { + ret = EaConfigInit(); + WlbInit(); + } + + if (CI_SUCCESS == ret) + { + /*ʼOC*/ + InitOcData(); + + /*ʼoc豸*/ + InitOcDevices(); + + ret = InitAxleToCiDataStru(); + } + if (CI_SUCCESS == ret) + {/*cgh-ϲCID-3037-3*/ + /*ʼṹ*/ + InitCtrlPowerStru(); + /*ʼOCվָʾ*/ + ret = InitialOCStationIndicStaData(); + } + + if (CI_SUCCESS == ret) + { + /*ʼ۷ָʾ״̬*/ + ret = InitialRtnIndicStaData(); + } + + + if (CI_SUCCESS == ret) + {/*ʼƽ̨͵ͨءչ*/ + InitPlatDataStru(); + } + + if (CI_SUCCESS == ret) + {/*ʼLEU*/ + (void)InitLEUDataStru(); + } + /*ʼ豸ӡ*/ + (void)RecordDeviceDataLog(CI_ERROR); + +#ifdef SCADE_MODE + InitScadeCiConfigData(); +#endif + +/*˳Ӫ*/ +#if (kPLATFORM==kVXWORKS) + rccycleTime = GetSystemParaAppCycleTime(); + /*ʼ˳Ӫ*/ + Deploy_Init((UINT16)rccycleTime,debug_infor_printf); +#endif + + TiocTransCtInit(); + + return ret; +} + +/* +* ʼźŻ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialSignalData(void) +{ + UINT16 signalDataSum = 0u; /*źŻ*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 routeSum = 0u; /*·*/ + UINT16 routeId = 0u; /*·ID*/ + UINT8 belongCiId = 0u; /*źŻCIid*/ + UINT16 ciToLeuMaskSum = 0u; /*CI-LEUλ*/ + UINT16 startSignalId = 0u; /*ʼźŻID*/ + UINT8 ret = CI_SUCCESS; + + UINT8 localCi = 0u;/*CI*/ + UINT8 sameLine = SAME_LINE_ERR;/*źŻ뱾CIǷͬһ·*/ + UINT16 outSecId = 0u;/*źŻⷽ*/ + UINT8 outSecCiId = 0u;/*źŻⷽCIʱ*/ + UINT8 outSecSameLine = SAME_LINE_ERR;/*źŻⷽ뱾CIǷͬһ·*/ + UINT16 detainBtnRelayId = 0U; /*۳ťɼ̵1ID*/ + UINT8 wRouteLeadProperty = 0U; + + localCi = GetSystemParaLocalCiId(); + + signalDataSum = GetTotalSignalCurNum(); /*͸źŻĿ*/ + ciToLeuMaskSum = GetSendMaskSum(CI_SYSTEM_TYPE_LEU); + + if (signalDataSum >= SIGNAL_SUM_MAX) + {/**/ + ret = CI_ERROR; + } + else + { + for (ii = 0u; ii < signalDataSum; ii++) + { + signalId = GetSignalId(ii); /*ȡļиµźŻID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻ*/ + detainBtnRelayId = GetSignalDetainRelayId(signalId); + SignalDataStru[signalId].SignalId = signalId; + SignalDataStru[signalId].FLockState = SIGNAL_FENGSUO_NO; /*źŻ״̬(δ/) */ + SignalDataStru[signalId].LightExtinctState = SIGNAL_LIGHT_EXTICT_STATE_YES; /*źŻ״̬(/) */ + SignalDataStru[signalId].PreColor = SIGNAL_SHOWCOLOUR_REDBREAK; /*źŻ֮ǰʾɫ */ + SignalDataStru[signalId].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK; /*źŻǰʾɫ */ + SignalDataStru[signalId].OldDriveColor = SIGNAL_DRIVECOLOUR_NULL; /*źŻɫ仯֮ǰ,źŻʾɫ*/ + SignalDataStru[signalId].PreDriveColor = SIGNAL_DRIVECOLOUR_NULL; /*֮ǰ()źŻʾɫ */ + SignalDataStru[signalId].CurDriveColor = SIGNAL_DRIVECOLOUR_NULL; /*ǰ()źŻʾɫ */ + SignalDataStru[signalId].DriveNewSigStartCycNum = 0u; /*źŻʾɫʼ*/ + SignalDataStru[signalId].DsBreakFlag = SIGNAL_DS_BREAK_NO; /*Ƶ˿˿־ */ + SignalDataStru[signalId].GreenDsBreakFlag = SIGNAL_DS_BREAK_NO; /*̵Ƶ˿˿־ */ + SignalDataStru[signalId].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO; /*ƵƵ˿˿־ */ + SignalDataStru[signalId].WhiteDsBreakFlag = SIGNAL_DS_BREAK_NO; /*׵Ƶ˿˿־ */ + SignalDataStru[signalId].RedYellowDsBreakFlag = SIGNAL_DS_BREAK_NO; /*ƵƵ˿˿־ */ + SignalDataStru[signalId].RedWhiteDsBreakFlag = SIGNAL_DS_BREAK_NO; /*׵Ƶ˿˿־ */ + SignalDataStru[signalId].GreenYellowDsBreakFlag = SIGNAL_DS_BREAK_NO; /*̻ƵƵ˿˿־ */ + SignalDataStru[signalId].DoubleGreenDsBreakFlag = SIGNAL_DS_BREAK_NO; /*˫̵Ƶ˿˿־ */ + SignalDataStru[signalId].DoubleYellowDsBreakFlag = SIGNAL_DS_BREAK_NO; /*˫ƵƵ˿˿־ */ + SignalDataStru[signalId].BlueDsBreakFlag = SIGNAL_DS_BREAK_NO; /*˿˿־ */ + SignalDataStru[signalId].DriveSigOpenStartCycNum = 0u; /*źŻʼ */ + SignalDataStru[signalId].DriveSigCloseStartCycNum = 0u; /*źŻرʼ */ + SignalDataStru[signalId].CollSigOpenStartCycNum = 0u; /*ɼźŻʼ */ + SignalDataStru[signalId].SignalCrossState = SIGNAL_CROSS_STATE_NO; /*ͨųѹͨźŻ״̬*/ + SignalDataStru[signalId].SignalLeadProperty = SIGNAL_LEAD_PROPERTY_NO; /*źŻ*/ + SignalDataStru[signalId].SignalLeadRouteCbtcFlag = 0U; /*źŻ·CBTCǷCBTCı־ÿźŻȳʼΪ0U*/ + SignalDataStru[signalId].SignalYLockOpenState = SIGNAL_CLOSE; /*źŹر*/ + SignalDataStru[signalId].AtsDetainFlag = SIGNAL_DETAIN_NO; /*Atsδ˹۳*/ + SignalDataStru[signalId].AtsDetainFlagAuto = SIGNAL_DETAIN_NO; /*AtsδԶ۳*/ + SignalDataStru[signalId].XiandiDetainFlag = SIGNAL_DETAIN_NO; /*ֵδ۳*/ + SignalDataStru[signalId].RealyDetainFlag = SIGNAL_RELAY_DETAIN_NO; /*źŻӲδ۳*/ + SignalDataStru[signalId].RelayActaionStartCycNum = 0u; /*źŻ̵ʼ*/ + SignalDataStru[signalId].AutoRouteId = 0u; /* ʼΪԶź */ + SignalDataStru[signalId].PLockCommand = SIGNAL_PLOCK_CMD_NONE; /*ҲⱣ*/ + SignalDataStru[signalId].DiffColorOpenStartCycNum = 0u; /*źŻǰɫĿ꿪ɫʼ*/ + SignalDataStru[signalId].SignalLightOnStateCycCount = SIGNAL_LIGHTON_MID_COUNT; /*źŻյǿƵǿ״ֵ̬*/ + SignalDataStru[signalId].RelayDetainCmd = SIGNAL_DETAIN_CI_RELAY_NO;/*ʼɲ۳*/ + SignalDataStru[signalId].NeighbourSignalDetainDrive = NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO;/*վźŻ۳*/ + SignalDataStru[signalId].MaintainLightState = MAINTAIN_STATE_NO;/*źŻά޵״̬*/ + SignalDataStru[signalId].wSignalLightUpLinkIdSum = 0U; + (void)CommonMemSet(SignalDataStru[signalId].szSignalLightUpLinkIdBuf, (UINT32)sizeof(SignalDataStru[signalId].szSignalLightUpLinkIdBuf),0U, (UINT32)sizeof(SignalDataStru[signalId].szSignalLightUpLinkIdBuf)); + SignalDataStru[signalId].wSignalLightUpTrainId = 0U; + if ((0U == detainBtnRelayId) || (UINT16_MAX == detainBtnRelayId)) + { + SignalDataStru[signalId].DetainBtnActivateFlag = SIGNAL_ZFS_BTN_ACT_FLAG_NO; /*Ըʽδÿ۳ť̵ʼ۳ťδ*/ + } + else + { + SignalDataStru[signalId].DetainBtnActivateFlag = SIGNAL_ZFS_BTN_ACT_FLAG_YES; /*۳ť1־*/ + } + SignalDataStru[signalId].DetainBtnErrFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; /*۳ťϱ־*/ + SignalDataStru[signalId].CancelDetainBtnErrFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; /*ȡ۳ťϱ־*/ + SignalDataStru[signalId].DetainBtnPressCycNum = 0U; /*۳ť1*/ + SignalDataStru[signalId].CancelDetainBtnPressCycNum = 0U; /*ȡ۳ť*/ + SignalDataStru[signalId].CancelDetainErrTrigPressCycNum = 0U; /*ȡ۳ť󴥷*/ + SignalDataStru[signalId].CancelDetainBtnValidFlag = SIGNAL_CANCEL_DETAIN_VALID_NO; /*ȡ۳ťЧ־*/ + SignalDataStru[signalId].CancelDetainRelayDownState = SIGNAL_RELAY_ERROR_DOWN_YES; /*ȡ۳ťɼ̵״̬ʼΪ쳣*/ + SignalDataStru[signalId].LogRouteSignalErrCloseFlag = LOG_ROUTE_SIGNAL_CLOSE_NOERR; /*ʼΪδ쳣رձ־(߼·쳣رʹ)*/ + SignalDataStru[signalId].VobcCroSigInPhyOccSta = SECTION_OCCUPY_NO; /*ʼźŻڷһΪУռѹٸZCȷϢ*/ + SignalDataStru[signalId].cSleepTrainLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_NO; /*ʼ߳źŻ־Ч*/ + SignalDataStru[signalId].cInHumidRailFlag = SIGNAL_IN_HUMID_RAIL_NO; + + /*ʼźŻʱ״̬Ч*/ + SignalDataStru[signalId].LinShiXianSuSetFlag = SIGNAL_LINSHIXIANSUSET_STATE_YES;/*ʱЧ*/ + + + routeSum = GetRouteCurSum(); + for (jj = 0u; jj < routeSum; jj++) + { + routeId = GetRouteId(jj);/*routeIdлõ*/ + startSignalId = GetRouteStartSignalId(routeId); + if (signalId == startSignalId) + { + wRouteLeadProperty = GetRouteLeadProperty(routeId); + if ((SignalDataStru[signalId].SignalLeadProperty == SIGNAL_LEAD_PROPERTY_NO) + && ((ROUTE_LEAD_PROPERTY_YES == wRouteLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == wRouteLeadProperty))) + { + /*źŻ*/ + SignalDataStru[signalId].SignalLeadProperty = SIGNAL_LEAD_PROPERTY_YES; + } + else + { + /**/ + } + } + else + { + ; + } + } + + SetSignalLeadRouteCbtcFlag(signalId); + + sameLine = IsSameLineCI(localCi, belongCiId);/*жǷǻͨߵźŻ*/ + + if (SAME_LINE_YES == sameLine) + { + outSecId = GetSignalOutFirstPhySecId(signalId); + /*ԸźŻΪնźŻĽ·ڻͨ·óЧԼ·óЧԭڣԼĽӿڲжϱεЧ*/ + if (0u < outSecId) + { + outSecCiId = GetPhySecBelongCiId(outSecId); + + if (0u < outSecCiId) + { + outSecSameLine = IsSameLineCI(localCi, outSecCiId);/*·뱾CIǷͬһ·*/ + + if (SAME_LINE_YES == outSecSameLine) + { + SignalDataStru[signalId].ProSecValid = SIGNAL_PRO_SEC_VALID;/*óЧ*/ + } + else + { + SignalDataStru[signalId].ProSecValid = SIGNAL_PRO_SEC_INVALID;/*óЧȫ*/ + } + } + else + { + SignalDataStru[signalId].ProSecValid = SIGNAL_PRO_SEC_INVALID;/*óЧȫ*/ + } + } + else + { + SignalDataStru[signalId].ProSecValid = SIGNAL_PRO_SEC_INVALID;/*óЧȫ*/ + } + } + else if (SAME_LINE_NO == sameLine) + { + SignalDataStru[signalId].ProSecValid = SIGNAL_PRO_SEC_INVALID;/*źŻ黥ͨCIܣĬñЧ*/ + } + else + { + SignalDataStru[signalId].ProSecValid = SIGNAL_PRO_SEC_INVALID;/*óЧȫ*/ + } + } + + /* Զź */ + if (CI_SUCCESS != SetAutoSignalId()) + { + ret = CI_ERROR; + } + else + { + ; + } + } + + + + return ret; +} + + +/* +* ʼϴ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialWashMachineData(void) +{ + UINT16 washMachineDataSum = 0u; /*ϴ*/ + UINT16 washMachinelId = 0u; /*ϴID*/ + UINT16 ii = 0u; /*α*/ + + UINT8 ret = CI_ERROR; + + washMachineDataSum = GetWashMachineSum();/*ֵ WASHMACHINE_SUM_MAX᷵0*/ + + for (ii = 0u; ii < washMachineDataSum; ii++) + { + washMachinelId = GetWashMachineId(ii); + WashMachineDataStru[washMachinelId].CurVobcId = 0u; + WashMachineDataStru[washMachinelId].WashMachineId = washMachinelId; + WashMachineDataStru[washMachinelId].WashMachineReadyState = WASHMACHINE_COL_READY_NO; + WashMachineDataStru[washMachinelId].WashMachineRequestVerifyState = WASHMACHINE_COL_REQUEST_INVALID; + WashMachineDataStru[washMachinelId].TrainEmergencyStopState = WASHMACHINE_COL_FALUT_YES; + WashMachineDataStru[washMachinelId].HeadWashAllowState = WASHMACHINE_COL_HEADWASH_NO; + WashMachineDataStru[washMachinelId].TailWashAllowState = WASHMACHINE_COL_TAILWASH_NO; + WashMachineDataStru[washMachinelId].WashTrainRequestDrvState = WASHMACHINE_DRVSTATE_REQ_FALSE; + WashMachineDataStru[washMachinelId].TrainHeadStopSteadyDrvState = WASHMACHINE_HEAD_STEADY_NO; + WashMachineDataStru[washMachinelId].TrainTailStopSteadyDrvState = WASHMACHINE_TAIL_STEADY_NO; + WashMachineDataStru[washMachinelId].TrainOutWashTrainPortAllowState = WASHMACHINE_COL_OUT_NO; + WashMachineDataStru[washMachinelId].PauseTrainWashRequestDrvState = WASHMACHINE_PAUSE_DRVREQ_FALSE; + WashMachineDataStru[washMachinelId].PaseWashMachineRequesDrvtState = PASS_WASHMACHINE_DRVREQ_FALSE; + WashMachineDataStru[washMachinelId].WashMachineWorkModeDrvtState = WASHMACHINE_WORKMODE_INVALID_DRV; + WashMachineDataStru[washMachinelId].WashWorkModeRelayDrvCycle = 0U; + WashMachineDataStru[washMachinelId].WashmachineXTACurState = XTA_STATE_RAISE_UP;/*ϴͬⰴťǰ״̬ʼΪ̧*/ + WashMachineDataStru[washMachinelId].WashmachineXTAPreState = XTA_STATE_RAISE_UP;/*ϴͬⰴť֮ǰ״̬ʼΪ̧*/ + WashMachineDataStru[washMachinelId].WashmachineXTALogicState = XTA_STATE_RAISE_UP;/*ϴͬⰴť߼״̬ʼΪ̧*/ + WashMachineDataStru[washMachinelId].WashmachineXTAPressDownCycle = 0u;/*ϴͬⰴťڣʼΪ0*/ + WashMachineDataStru[washMachinelId].WashModeState = XTA_MODE_STATE_NO;/*ϴģʽʼΪOXFF*/ + WashMachineDataStru[washMachinelId].chSetWashWorkModeBack = WASH_WORKMODE_BACK_DEFAULT;/*ϴģʽʼΪOX00*/ + WashMachineDataStru[washMachinelId].chDownWashAllowState = WASH_COL_STATE_ALLOW_NO;/*ģʽϴͬ״̬*/ + WashMachineDataStru[washMachinelId].chDownWashAllowPassState = WASH_COL_STATE_ALLOW_PASS_NO;/*ģʽϴͬͨ״̬*/ + + } + ret = CI_SUCCESS; + return ret; +} + + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialSwitchData(void) +{ + UINT16 switchDataSum = 0u; /**/ + UINT16 switchId = 0u; /*ID*/ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT8 reVal = CI_ERROR; + + switchDataSum = GetTotalSwitchCurNum(); /*͸ĵĿ*/ + /*ֵSWITCH_SUM_MAX᷵0*/ + for (ii = 0u; ii < switchDataSum; ii++) + { + switchId = GetSwitchId(ii);/*ȡļиµĵID*/ + + SwitchDataStru[switchId].SwitchId = switchId; + SwitchDataStru[switchId].YLockState = SWITCH_LOCK_YINZONG_NO; + SwitchDataStru[switchId].LockStatus = SWITCH_LOCK_STATUS_NO; + SwitchDataStru[switchId].FLockState = SWITCH_LOCK_FENGSUO_NO; + SwitchDataStru[switchId].SwitchPrePosition = SWITCH_POSITION_SIKAI; + SwitchDataStru[switchId].SwitchCurPosition = SWITCH_POSITION_SIKAI; + SwitchDataStru[switchId].SingleSwitchCurPosition = SWITCH_POSITION_SIKAI; + SwitchDataStru[switchId].SwitchDrivePos = SWITCH_DRIVE_POS_INVALID; + SwitchDataStru[switchId].SwitchExpDrvPos = SWITCH_DRIVE_POS_INVALID; + SwitchDataStru[switchId].switchPreExpDrvPos = SWITCH_DRIVE_POS_INVALID; + SwitchDataStru[switchId].SwitMoveStartCycNum = 0u; + SwitchDataStru[switchId].SwitDriveStartCycNum = 0u; + SwitchDataStru[switchId].chSwitchDrivedFlag = SWITCH_DRIVED_FLAG_NO; + SwitchDataStru[switchId].SwitchDanCaoPostition = SWITCH_POSITION_INVALID; + SwitchDataStru[switchId].switchDrivingState = SWIT_DRIV_IDLE_TIME; + SwitchDataStru[switchId].switchDrivOvtmDrvPos = SWITCH_DRIVE_POS_INVALID; + SwitchDataStru[switchId].switchFaultState = SWITCH_FAULT_STATE_YES; + /* zt ɾش 2022-02-15 */ + SwitchDataStru[switchId].switchKRState = SWITCH_KERAO_STATE_YES; + SwitchDataStru[switchId].switchLastValidDrvPosCycleNum = 0u; + SwitchDataStru[switchId].switchLastValidDrvPos = SWITCH_DRIVE_POS_INVALID; + SwitchDataStru[switchId].UsingBelongOverlapId = 0u; + SwitchDataStru[switchId].DFHRelayValidCycNum = 0u; + SwitchDataStru[switchId].SigleDFHRelayValidCycNum = 0u; + SwitchDataStru[switchId].PLockedRouteNum = 0u; + SwitchDataStru[switchId].PLockedLogRouteNum = 0u; + SwitchDataStru[switchId].PLockedOverlapNum = 0u; + SwitchDataStru[switchId].PLockedNonRouteNum = 0u; + SwitchDataStru[switchId].YCRelayValidCycNum = 0u; + SwitchDataStru[switchId].SigleYCRelayValidCycNum = 0u; + SwitchDataStru[switchId].ConnetSwitchDsState = CONNECT_SWITCH_DANSUO_NO; + SwitchDataStru[switchId].SwitchByPassState = SWITCH_BYPASS_NO; + SwitchDataStru[switchId].SwitchBypassStartCycNum = 0u; + SwitchDataStru[switchId].chSwitchJichaState = 0U; + SwitchDataStru[switchId].cSwitchUsingState = SWITCH_USING_NO; + SwitchDataStru[switchId].SwitchCollTolerateCycNum = 0U; + SwitchDataStru[switchId].SwitchColPosition = SWITCH_POSITION_SIKAI; + SwitchDataStru[switchId].switchFaultState = SWITCH_FAULT_STATE_YES; /*Ϊ忨*/ + /*ʼյĽ·Ρǽ·*/ + for (jj=0; jj zcToCiMaskSum) + { + LogicSectionDataStru[logicSectionId].LinShiXianSuSetFlag = LOGSEC_LSXS_SET_STATE_INVALID; + } + else + { + ; + } + } + + } + else + { + reVal = CI_ERROR; + } + } + + return reVal; +} + + + +/* +* ʼͣť +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialEsbData(void) +{ + UINT16 esbDataSum = 0u; /*ͣť*/ + UINT16 esbId = 0u; /*ͣťID*/ + UINT16 ii = 0u; /*α*/ + UINT8 reVal = CI_ERROR; + + esbDataSum = GetTotalEsbCurNum(); /*͸ESBĿ*/ + /*ֵڵESB_SUM_MAX᷵0*/ + + /*ͣťID??*/ + + + for (ii = 0u; ii < esbDataSum; ii++) + { + esbId = GetEsbId(ii);/*ȡļиµĽͣťID*/ + + EsbDataStru[esbId].EsbId = esbId; + EsbDataStru[esbId].EsbState = ESB_STATE_VALID_NO; + } + + reVal = CI_SUCCESS; + return reVal; +} + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialFloodGateData(void) +{ + UINT16 floodGateDataSum = 0u; /**/ + UINT16 floodGateId = 0u; /*ID*/ + UINT16 ii = 0u; /*α*/ + UINT8 jj = 0U; + UINT8 reVal = CI_ERROR; + + floodGateDataSum = GetTotalFloodGateCurSum();/*͸ķĿ*/ + /*ֵڵFLOOD_GATE_SUM_MAX᷵0*/ + + for (ii = 0u; ii < floodGateDataSum; ii++) + { + floodGateId = GetFloodGateId(ii); + + if ((0u < floodGateId) && (FLOOD_GATE_SUM_MAX> floodGateId)) + { + FloodGateDataStru[floodGateId].FloodGateId = floodGateId; + FloodGateDataStru[floodGateId].CurAgreeCloseAckFromZC = FLOOD_GATE_NOT_ALLOWCLOSE_ZC; + FloodGateDataStru[floodGateId].CurAgreeCloseStateIn = FLOOD_GATE_NOT_AGREE_CLOSE; + FloodGateDataStru[floodGateId].CurAgreeCloseStateOut = FLOOD_GATE_NOT_AGREE_CLOSE; + FloodGateDataStru[floodGateId].CurCloseRequestStateFromFYM = FLOOD_GATE_NOT_CLOSEREQ; + FloodGateDataStru[floodGateId].CurOpenLockStateFromFYM = FLOOD_GATE_NOT_OPENLOCK; + FloodGateDataStru[floodGateId].CurYGJCrossLineStartCount = 0u;/*߿ʼʱΪ0*/ + FloodGateDataStru[floodGateId].CurFloodGateDelayCloseStartCyc = 0u;/*ŽӽռѹʱſʼʱΪ0*/ + FloodGateDataStru[floodGateId].FloodGateCloseApplyIvocSum = 0u;/*ŹгΪ0*/ + for (jj = 0U; jj < FLOOD_GATE_APPLY_TRAIN_SUM_MAX; jj++) + { + FloodGateDataStru[floodGateId].FloodGateCloseApplyIvocId[jj] = 0u;/*ŹгIDΪ0*/ + FloodGateDataStru[floodGateId].FloodGateCloseFromIvocStru[jj].wTrainId = 0u; /*ŹŻظгIDΪ0*/ + FloodGateDataStru[floodGateId].FloodGateCloseFromIvocStru[jj].wFloodGateCloseIvocFlag = FLOOD_GATE_NOT_ALLOWCLOSE_IVOC; /*ŹŻظ־Ϊ*/ + } + FloodGateDataStru[floodGateId].FloodGateAccessUTFlag = FLOOD_GATE_ACCESS_UT_YES;/*ŽӽռѹǷUTռѹ־*/ + FloodGateDataStru[floodGateId].FloodGateCloseAnsIvocSum = 0u;/*ŹŻظгΪ0*/ + } + else + { + ; + } + } + reVal = CI_SUCCESS; + return reVal; +} + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialPsdData(void) +{ + UINT16 psdDataSum = 0u; /**/ + UINT16 psdId = 0u; /*ID*/ + UINT16 ii = 0u; /*α*/ + UINT8 reVal = CI_ERROR; + UINT8 psdVirtual = 0u; + UINT16 wPsdButtenRelayId = 0u; + UINT16 wCleFarePCBButRelayId = 0U;/*ȷŰť̵ID*/ + + psdDataSum = GetTotalPsdCurNum();/*͸PsdĿ*/ + /*ֵڵPSD_SUM_MAX᷵0*/ + + /*ID??*/ + + for (ii = 0u; ii < psdDataSum; ii++) + { + psdId = (UINT8)GetPsdId((UINT8)ii);/*ȡļиµID*/ + + psdVirtual = GetPsdVirtualAttribute(psdId); + + PsdDataStru[psdId].PsdId = psdId; + PsdDataStru[psdId].psdEditGroupInfo = 0u;/*psdϢʼΪ0*/ + PsdDataStru[psdId].PsdState = PSD_STATE_OPEN; + + wPsdButtenRelayId = GetDoorButtonRelayId(psdId); + if ((0u == wPsdButtenRelayId) || (UINT16_MAX == wPsdButtenRelayId)) + { + PsdDataStru[psdId].DoorButtonState = PSD_BUTTON_STATE_UP; + } + else + { + PsdDataStru[psdId].DoorButtonState = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + + wPsdButtenRelayId = GetPsdReOpenRelayId(psdId); + if ((0u == wPsdButtenRelayId) || (UINT16_MAX == wPsdButtenRelayId)) + { + PsdDataStru[psdId].doorOpenButtonState = PSD_OPEN_BUTTON_STATE_INVALID; + } + else + { + PsdDataStru[psdId].doorOpenButtonState = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + + wPsdButtenRelayId = GetPsdDeparConfmRelayId(psdId); + if ((0u == wPsdButtenRelayId) || (UINT16_MAX == wPsdButtenRelayId)) + { + PsdDataStru[psdId].doorDepartButtonState = PLATFORM_DEPAR_BUTTON_STATE_INVALID; + } + else + { + PsdDataStru[psdId].doorDepartButtonState = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + + PsdDataStru[psdId].PsdDriveState = PSD_DRIVE_STATE_INVALID; + PsdDataStru[psdId].PsdPreDriveState = PSD_DRIVE_STATE_INVALID; + PsdDataStru[psdId].MutualLockRemoveState = PSD_MUTUALLOCK_REMOVE_NO; + PsdDataStru[psdId].PsdButtonPangluState = PSD_RELATED_BUTTON_STATE_DEFAULT; + /*վ̨ųʼر*/ + if (PSD_VIRTUAL_ATTR_YES == psdVirtual) + { + PsdDataStru[psdId].PsdState = PSD_STATE_CLOSE; + } + else + { + ; + } + + PsdDataStru[psdId].SrcVobcId = 0u; + PsdDataStru[psdId].PsdCmd = PSD_DEFAULT_CONTROL_CMD; + PsdDataStru[psdId].CmdSetCycle = 0u; + PsdDataStru[psdId].CmdSetCyclePsc = 0u; + + PsdDataStru[psdId].PsdRemoraState = PSD_REMORA_NO; + PsdDataStru[psdId].JXTCMutualLockState = JXTC_MUTUALLOCK_REMOVE_YES; + PsdDataStru[psdId].StartDetectionCycNum = 0u; + PsdDataStru[psdId].StartDetectionState = JXTC_START_DETECTION_NO; + PsdDataStru[psdId].StopDetectionState = JXTC_STOP_DETECTION_YES; + PsdDataStru[psdId].VOBCDoorState = PSD_DOOR_CLOSEDANDLOCKED_INVALID; + PsdDataStru[psdId].PCBPressCycNum = 0u; + PsdDataStru[psdId].POBPressCycNum = 0u; + PsdDataStru[psdId].PSBPressCycNum = 0u; + PsdDataStru[psdId].PscPlConfirmFlag = CI_PSC_PL_CONFIRM_NO; + PsdDataStru[psdId].JXTCStartState = JXTC_NO_DRIVE_STATE; + PsdDataStru[psdId].JXTCStartCycNum = 0u; + PsdDataStru[psdId].JXTCStopState = JXTC_NO_DRIVE_STATE; + PsdDataStru[psdId].JXTCStopCycNum = 0u; + PsdDataStru[psdId].JXTCStartFlag = JXTC_DRIVE_START_STOP_NO; + PsdDataStru[psdId].JXTCStopFlag = JXTC_DRIVE_START_STOP_NO; + PsdDataStru[psdId].psdDriveOpenStartNum = 0u; + PsdDataStru[psdId].psdDriveCloseStartNum = 0u; + PsdDataStru[psdId].clearPassengerFlag = ATS_TO_CI_PLATFORM_QK_NO; + PsdDataStru[psdId].steadyLightFlag = QK_BUTTON_STEADY_LIGHT_NO; + + PsdDataStru[psdId].dwCleFarePCBPressCycNum = 0U; + /*ȷPCBť״̬ʼ*/ + wCleFarePCBButRelayId = GetCleFarePCBButRelayId(psdId); + if ((0u == wCleFarePCBButRelayId) || (UINT16_MAX == wCleFarePCBButRelayId)) + { + PsdDataStru[psdId].chCleFarePCBButtonState = QK_PSD_BUTTON_STATE_UP; + PsdDataStru[psdId].chCleFarePCBButKeepState = QK_PSD_BUTTON_STATE_UP; + } + else + { + PsdDataStru[psdId].chCleFarePCBButtonState = PSD_RELATED_BUTTON_STATE_DEFAULT; + PsdDataStru[psdId].chCleFarePCBButKeepState = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + /*ȷPDBťָʾ״̬ʼ*/ + PsdDataStru[psdId].chCleFarePDBFlaLigFlag = QK_BUTTON_FLASH_LIGHT_NO; + + /*Ƶ״̬ʼΪЧгID0*/ + PsdDataStru[psdId].chVideoQkDriveState = VIDEO_QK_DRIVE_STATE_INVALID; + PsdDataStru[psdId].wVideoQkRelateVobcId = 0U; + } + reVal = CI_SUCCESS; + return reVal; +} + +/* +* ʼ̵ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialRelayData(void) +{ + UINT16 relaySum = 0u; /*̵*/ + UINT16 relayId = 0u; /*̵ID*/ + UINT16 ii = 0u; /*α*/ + UINT8 belongCiId = 0u; /*ID*/ + UINT8 reVal = CI_SUCCESS; + + relaySum = GetRelayCurSum(); + belongCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if (relaySum >= RELAY_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + /*ڻͨղӿڵʵ̵֣ķʽRelayDataStruлļ̵ڱCIĴʽCI̵IDΪRelayDataStru±ꡣ + CIļ̵ĬϳʼΪDOWNǰȫġԣĿǰRelayDataStruаļ̵֣ڱCIʵ̵ڱCI̵ڻͨCI̵*/ + for (ii = 0u;ii= OVERLAP_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < overlapSum; ii++) + { + overlapId = GetOverlapId(ii);/*ȡļиµıID*/ + + OverlapDataStru[overlapId].OverlapId = overlapId; + OverlapDataStru[overlapId].BelongRouteId = 0u; + OverlapDataStru[overlapId].UnlockStartCycNum = 0u; + OverlapDataStru[overlapId].XuanPaiStartCycNum = 0u; + OverlapDataStru[overlapId].OverlapUnlockApplyFlag = UNLOCK_OVERLAP_APPLY_NO; + OverlapDataStru[overlapId].wOverlapUnlockApplyTrainId = 0U; + OverlapDataStru[overlapId].dwReqIvocUnLockStartCycNum = 0U; + OverlapDataStru[overlapId].cIvocAllowUnlockFlag = IVOC_ALLOW_UNLOCK_OVERLAP_NO; + OverlapDataStru[overlapId].OverlapCanLaborUnlockFlag = CANNOT_LABOR_UNLOCK_OVERLAP; + OverlapDataStru[overlapId].OverlapLaborUnlockSetState = LABOR_UNLOCK_OVERLAP_NO; + OverlapDataStru[overlapId].laborUnlockStartCycNum = 0u; + OverlapDataStru[overlapId].atsOrlaborLockFlag = LOCK_OVERLAP_CMD_NO; + OverlapDataStru[overlapId].lockStartCycNum = 0u; + OverlapDataStru[overlapId].overlapUnlockTime = 0u; + OverlapDataStru[overlapId].laborLockOverlapCmd = LOCK_OVERLAP_CMD_NO; + OverlapDataStru[overlapId].cProSwitchCheckResultFlag = PROSWITCH_CHECK_RESULT_DEFAULT; + OverlapDataStru[overlapId].cProSwitchCheckStartFlag = PROSWITCH_CHECK_START_INVALID; + } + } + + return reVal; +} + +/* +* ʼ· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialRouteData(void) +{ + UINT16 routeSum = 0u; /*·*/ + UINT16 throughRouteId = 0u; /*۷תͨ·ID*/ + UINT16 routeId = 0u; /*·ID*/ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT8 reVal = CI_SUCCESS; + UINT8 k = 0u; /**/ + + routeSum = GetRouteCurSum();/*͸Ľ·Ŀ*/ + if (routeSum >= ROUTE_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + (void)memset(RouteDataStru,0,sizeof(RouteDataStru)); + for (ii = 0u; ii < routeSum; ii++) + { + routeId = GetRouteId(ii);/*ȡµĽ·ID*/ + + if (routeId != 0u) + { + RouteDataStru[routeId].RouteId = routeId; + RouteDataStru[routeId].RouteState = ROUTE_STATE_IDLE;/*·*/ + RouteDataStru[routeId].RoutePreLevel = ROUTE_LEVEL_BLOC; + RouteDataStru[routeId].RouteLevel = ROUTE_LEVEL_BLOC; + RouteDataStru[routeId].RouteLevelChangeCyc = 0U; + RouteDataStru[routeId].AutoRouteId = 0u; + RouteDataStru[routeId].AutoReturnId = 0u; + + RouteDataStru[routeId].XuanPaiStartCycNum = 0u; + RouteDataStru[routeId].RouteLockStartCycNum = 0u; + RouteDataStru[routeId].OverlapLockStartCycNum = 0u; + RouteDataStru[routeId].RouteOpenSigStatrtCycNum = 0u; + RouteDataStru[routeId].DelayUnlockStartCycNum = 0u; + RouteDataStru[routeId].LeadFaultOpenStartCycNum = 0u; + RouteDataStru[routeId].OverlapLockedId = 0u; + RouteDataStru[routeId].ZongQuXiaoFlag = ROUTE_ZONGQUXIAO_SET_NO; + RouteDataStru[routeId].ZongRenJieFlag = ROUTE_ZONGRENJIE_SET_NO; + RouteDataStru[routeId].RepeatOpenFlag = ROUTE_REPEATOPEN_SET_NO; + RouteDataStru[routeId].StopCheckFlag = ROUTE_STOPCHECK_SET_NO; + RouteDataStru[routeId].StopKeepCheckFlag = ROUTE_STOPCHECK_SET_NO; + RouteDataStru[routeId].BelongLongRouteId = 0u; + RouteDataStru[routeId].ThroughRouteId = 0u; + RouteDataStru[routeId].AllAutoReturnId = 0u; + RouteDataStru[routeId].StopensureFlag = ROUTE_STOPENSURE_NO; + RouteDataStru[routeId].RouteAssoSwitSingOperStat = SWITCH_SINGLE_OPERATED_FALSE; + RouteDataStru[routeId].RouteInnerSwitDrivState = SWITCH_IN_DRIVING_FALSE; + RouteDataStru[routeId].RouteAssocSwitDrivState = SWITCH_IN_DRIVING_FALSE; + RouteDataStru[routeId].RouteStateFlag = ROUTE_STATE_FLAG_NO; + RouteDataStru[routeId].TrainEnterFlag = ROUTE_TRAIN_ENTER_FLAG_NO; + RouteDataStru[routeId].ZongRenJieDelayType = ROUTE_ZRJ_DELAY_TYPE_INVALID; + RouteDataStru[routeId].RecoverOpenState = ROUTE_RECOVER_STA_INIT; + RouteDataStru[routeId].TrainEnterRouteFlag = TRAIN_ENTER_ROUTE_FLAG_NO; + RouteDataStru[routeId].atsExptLkOverlapId = 0u; + RouteDataStru[routeId].NeedOpenNotTrueRepeatFlag = ROUTE_NEEDOPEN_REOPEN_NO;/*ʼΪؿ*/ + RouteDataStru[routeId].NeedOpenNotTrueRepeatStartCount = 0u;/*迪Ųʱؿʼ*/ + RouteDataStru[routeId].DCQState = ROUTE_DCQ_NOT_REQUEST;/*޵*/ + RouteDataStru[routeId].DCTYState = ROUTE_DCT_NOT_AGREE; /*޵ͬ*/ + RouteDataStru[routeId].CancleDelayflag = ROUTE_ZQX_DELAY_NO; /*ȡ·ʱ*/ + RouteDataStru[routeId].AutoSigCancleState = AUTO_ROUTE_CANCLE_NO; /*Զźȡ״̬ΪЧ*/ + RouteDataStru[routeId].CancleAutoSigCmd = AUTO_ROUTE_CANCLE_CMD_NO; /*ԶźȡЧ*/ + RouteDataStru[routeId].wStopEnsureTrainId = 0u; + RouteDataStru[routeId].dwStopEnsureCyc = 0u; + RouteDataStru[routeId].cResReqOtherCIId = 0u; + for (k = 0u; k < ROUTE_APPLY_RECD_TRAIN_SUM_MAX; k++) + { + RouteDataStru[routeId].wszResReqTrainId[k] = 0u; + } + RouteDataStru[routeId].ITSRouteApplyTrainIdSum = 0u; + for (k = 0u; k < ROUTE_APPLY_RECD_TRAIN_SUM_MAX; k++) + { + RouteDataStru[routeId].ITSRouteApplyTrainIdBuf[k] = 0u; + } + /*cgh-ϲCID-2539-10*/ + RouteDataStru[routeId].OverlapNeedCIlockFlag = OVERLAPCILOCK_NO; /*ձ־Ч*/ + RouteDataStru[routeId].OverlapLockProcFlag = OVERLAP_LOCK_PROC_NO; /*βչ*/ + RouteDataStru[routeId].GroupRouteCmdFlag = ROUTE_GROUPROUTE_CMD_NO; /*·Ͻ·־*/ + RouteDataStru[routeId].AutoTriggerFlag = AUTO_TRIGGER_SET_NO; /*·ûԶ־*/ + RouteDataStru[routeId].dwFirstElockStartCycNum = 0U; /*·һյ߼ʱιʼں*/ + RouteDataStru[routeId].cRelZuHeRouteSGBJDelayFlag = ROUTE_SGBJ_DELAY_OPEN_VALID; /*Ͻ·ⱨʱ־Ч*/ + RouteDataStru[routeId].dwDelayOpenStartCycNum = 0U; /*ⱨ·ʱʱʼ*/ + RouteDataStru[routeId].cRouteNeedDriveSGBJFlag = ROUTE_DRIVE_SGBJ_INVALID; /*·ⱨ־Ч*/ + RouteDataStru[routeId].cRouteDrivedSGBJFlag = ROUTE_HAS_DRIVED_SGBJ_INVALID; /*ʼ·δⱨ*/ + RouteDataStru[routeId].chRouteNearSecSearchState = ROUTE_NEAR_SEC_HAVE_UT; /*ʼ·ӽβѯ״̬Ϊйϳ*/ + RouteDataStru[routeId].chRouteApplySwitchCheckFlag = ROUTE_APPLY_SWITCH_CHECK_DEF; /*ʼ·ڿ־*/ + } + } + + /*۷תͨ·ID*/ + for (ii = 0u; ii < routeSum; ii++) + { + routeId = GetRouteId(ii);/*ȡļиµĽ·ID*/ + + if (routeId != 0u) + { + + /*ýṹн·ȥID*/ + if (RouteConfigDataStru[routeId].RouteLeavePhySecId == 0u) + { + RouteConfigDataStru[routeId].RouteLeavePhySecId = (UINT16)0xFFFF; + } + /*·ԶźЧ־*/ + if(ROUTE_AUTOSIG_PROPERTY_NO == RouteConfigDataStru[routeId].AutoSigProperty) + {/*·߱ԶźԣԶźʧЧ־䲻*/ + RouteDataStru[routeId].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_SET_INVALID; + } + else if(ROUTE_AUTOSIG_PROPERTY_YES == RouteConfigDataStru[routeId].AutoSigProperty) + {/*·߱ԶźԣʼΪԶźЧ*/ + RouteDataStru[routeId].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_SET_NO; + } + else + {/*ΪԶźʧЧ־䲻*/ + RouteDataStru[routeId].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_SET_INVALID; + } + + /*۷·*/ + if (ROUTE_TYPE_RETURN == GetConfigRouteType(routeId)) + { + for (jj = 0u; jj < routeSum; jj++) + { + throughRouteId = GetRouteId(jj);/*ȡļиµĽ·ID*/ + + /*۷·ʼնźŻͬͨ·*/ + if ((GetRouteStartSignalId(routeId) == GetRouteStartSignalId(throughRouteId)) + && (GetRouteEndSignalId(routeId) == GetRouteEndSignalId(throughRouteId)) + && (ROUTE_TYPE_LIECHE == GetConfigRouteType(throughRouteId))) + { + RouteDataStru[routeId].ThroughRouteId = throughRouteId; + break; + } + } + } + } + + } + } + + return reVal; +} + +/* +* ʼ· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +void InitialLongRouteData(void) +{ + UINT16 longRouteSum = 0u; /*·*/ + UINT16 ii = 0u; /*α*/ + UINT16 longRouteId = 0u; + longRouteSum = GetLongRouteCurSum(); + + for (ii = 0u; ii <= longRouteSum; ii++) + { + longRouteId = GetLongRouteId(ii); + LongRouteDataStru[longRouteId].LongRouteId = longRouteId; + LongRouteDataStru[longRouteId].LongRouteState = ROUTE_LONG_STATE_IDLE;/*·*/ + LongRouteDataStru[longRouteId].LongXuanPaiStartCycNum = 0u; + } + +} + +/* +* ʼǽ· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +void InitialNonRouteData(void) +{ + /*NonRouteDataStru.CancelFlag = NONROUTE_CANCEL_FLAG_NO; + NonRouteDataStru.DelayUnlockStartCycleNum = 0; + NonRouteDataStru.HaveCancelFlag = NONROUTE_CANCEL_FLAG_NO; + NonRouteDataStru.NonRouteState = NONROUTE_STATE_IDLE; + NonRouteDataStru.RunMode = NONROUTE_RUN_MODE_APPLY; + NonRouteDataStru.SigOpenStartCycleNum = 0; + NonRouteDataStru.XuanPaiStartCycleNum = 0;*/ + UINT8 i=0u; + + NonRouteConfigDataStruct *pNonRouteCfgPtr = NULL; + + pNonRouteCfgPtr= GetNonRouteConfigDataPtr();/*᷵NULL*/ + + for (; iNonRouteId].NonRouteId = pConfig->NonRouteId; + NonRouteDataStruArr[pConfig->NonRouteId].CancelFlag = NONROUTE_CANCEL_FLAG_NO; + NonRouteDataStruArr[pConfig->NonRouteId].DelayUnlockStartCycleNum = 0u; + NonRouteDataStruArr[pConfig->NonRouteId].HaveCancelFlag = NONROUTE_CANCEL_FLAG_NO; + NonRouteDataStruArr[pConfig->NonRouteId].NonRouteState = NONROUTE_STATE_IDLE; + NonRouteDataStruArr[pConfig->NonRouteId].RunMode = NONROUTE_RUN_MODE_APPLY; + NonRouteDataStruArr[pConfig->NonRouteId].SigOpenStartCycleNum = 0u; + NonRouteDataStruArr[pConfig->NonRouteId].XuanPaiStartCycleNum = 0u; + + + } +} + +/* +* ʼԶ۷· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialAutoReturnRouteData(void) +{ + UINT16 autoReturnRouteSum = 0u; /*Զ۷·*/ + UINT16 autoReturnRouteId = 0u; /*Զ۷·ID*/ + UINT16 ii = 0u; /*α*/ + UINT8 reVal = CI_ERROR; + + autoReturnRouteSum = GetAutoReturnRouteCurSum(); + + if (autoReturnRouteSum >= AUTO_RETURN_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + for (ii = 0u; ii < autoReturnRouteSum; ii++) + { + autoReturnRouteId = GetAutoReturnRouteId(ii);/*ȡļиµԶ۷·ID*/ + + AutoReturnDataStru[autoReturnRouteId].AutoReturnId = autoReturnRouteId; + AutoReturnDataStru[autoReturnRouteId].AutoReturnSetFlag = AUTO_RETURN_SET_NO; + reVal &= SetautoRouteOpposedRoute(autoReturnRouteId,ROUTE_AUTOROUTE_RETURN); + } + } + + return reVal; +} + +/* +* ʼԶͨ· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialAutoRouteRouteData(void) +{ + UINT16 autoRouteRouteSum = 0u; /*Զͨ·*/ + UINT16 autoRouteRouteId = 0u; /*Զͨ·ID*/ + UINT16 ii = 0u; /*α*/ + UINT8 reVal = CI_ERROR; + + autoRouteRouteSum = GetAutoRouteRouteCurSum(); + + if (autoRouteRouteSum >= AUTO_ROUTE_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + for (ii = 0u; ii < autoRouteRouteSum; ii++) + { + autoRouteRouteId = GetAutoRouteRouteId(ii);/*ȡļиµԶͨ·ID*/ + + AutoRouteDataStru[autoRouteRouteId].AutoRouteId = autoRouteRouteId; + AutoRouteDataStru[autoRouteRouteId].AutoRouteSetFlag = AUTO_ROUTE_SET_NO; + reVal &= SetautoRouteOpposedRoute(autoRouteRouteId,ROUTE_AUTOROUTE_NORMAL); + } + } + + return reVal; +} + +/* +* ʼʾƱ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialIndicatorStateData(void) +{ + UINT16 configStruSum = 0u; /**/ + UINT16 indicatorId = 0u; + UINT16 ii = 0u; + UINT8 kk = 0u;/*α*/ + UINT8 reVal = CI_SUCCESS; + UINT8 j = 0u; + UINT8 virCINum = 0u; + UINT8 virCIid = 0u; + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + + if(FUNC_SWITCH_ON == includeVirFlag) + { + /**/ + virCINum = GetVirtualCINum(); + for(j=0u;(j < virCINum)&&(j indicatorId)) + { + g_VirtualCIStructData.virtualCi[j].IndicatorData[indicatorId].IndicatorId = indicatorId; + g_VirtualCIStructData.virtualCi[j].IndicatorData[indicatorId].IndicatorState = 0u; + } + } + } + } + else + { + configStruSum = GetIndicatorCurSum(); + if (configStruSum >= INDICATOR_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < configStruSum; ii++) + { + indicatorId = GetIndicatorId(ii); + + IndicatorDataStru[indicatorId].IndicatorId = indicatorId; + IndicatorDataStru[indicatorId].IndicatorState = 0u; + } + } + } + + + return reVal; +} + +/* +* ʼͨ״̬ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialTransmitStateData(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT8 reVal = CI_SUCCESS; + + if (TransmitRelaDataCurSum >= TRANSMIT_OBJECT_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + /*ʼͨ״̬*/ + TransmitStateDataCurSum = 0u; + for (ii = 0u; ii < TransmitRelaDataCurSum; ii++) + { + for (jj = 0u; jj < TransmitRelaDataStru[ii].DeviceSum; jj++) + { + TransmitStateDataStru[TransmitStateDataCurSum].chLocalCiId = TransmitRelaDataStru[ii].CiId; + TransmitStateDataStru[TransmitStateDataCurSum].DeviceType = TransmitRelaDataStru[ii].SystemType; + TransmitStateDataStru[TransmitStateDataCurSum].DeviceId = TransmitRelaDataStru[ii].DeviceIdBuf[jj]; + TransmitStateDataStru[TransmitStateDataCurSum].RecvDataCycNum = 0u; + TransmitStateDataStru[TransmitStateDataCurSum].transmitState = TRANSMIT_STATE_BAD; + TransmitStateDataStru[TransmitStateDataCurSum].RecvDataRedCycNum = 0u; + TransmitStateDataStru[TransmitStateDataCurSum].RecvDataBlueCycNum = 0u; + TransmitStateDataStru[TransmitStateDataCurSum].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + TransmitStateDataCurSum++; + } + } + + InitHlhtHeadCtx(CI_SYSTEM_TYPE_TMC); + InitHlhtHeadCtx(CI_SYSTEM_TYPE_AXIS); + } + + return reVal; +} + +/* +* ʼ״̬ȨID +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialPhySecIdBufOfOtherCi(void) +{ + UINT16 routeSum = 0u; /*·*/ + UINT16 routeId = 0u; /*·ID*/ + UINT16 overlapSum = 0u; /**/ + UINT16 overlapId = 0u; /*ID*/ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; + UINT16 kk = 0u; + UINT8 belongCiId = 0u; /*ID*/ + RoutePhysicalSectionStruct* routePhySecData = NULL; /*·*/ + UINT8 routePhySecSum = 0u; /*·Ŀ*/ + UINT16* overlapPhySecIdBuf = NULL; /*·ID*/ + UINT8 overlapPhySecSum = 0u; /*·Ŀ*/ + UINT8 phySecSum = 0u; /*״̬*/ + UINT8 reVal = CI_SUCCESS; + UINT8 chOverlapCiId = 0U; + routeSum = GetRouteCurSum(); + + if (routeSum >= ROUTE_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + belongCiId = GetSystemParaLocalCiId(); + + for (ii = 0u; ii < routeSum; ii++) + { + routeId = GetRouteId(ii);/*ȡļиµĽ·ID*/ + + if (GetRouteBelongCiId(routeId) == belongCiId) + { + routePhySecSum = GetRoutePhysicalSectionSum(routeId);/*·Ŀ*/ + routePhySecData = GetRouteSectionData(routeId); /*·*/ + + if ((routePhySecSum == 0u) || (routePhySecData == NULL)) + { + /*·*/ + } + else + { + for (jj = 0u; jj < ((UINT16)routePhySecSum); jj++) + {/*·аµ*/ + + PhySecIdBufOfOtherCi[PhySecIdBufSumhOfOtherCi] = routePhySecData[jj].PhysicalSectionId; + PhySecIdBufSumhOfOtherCi++; + } + } + } + + + } + + overlapSum = GetOverlapCurSum(); + + if (overlapSum >= OVERLAP_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < overlapSum; ii++) + { + overlapId = GetOverlapId(ii);/*ȡļиµOverlapID*/ + chOverlapCiId = GetOverlapBelongCiId(overlapId); + if (chOverlapCiId == belongCiId) + { + + overlapPhySecSum = GetOverlapPhySecSum(overlapId); /*·Ŀ*/ + overlapPhySecIdBuf = GetOverlapPhySecIdBuf(overlapId); /*·ID*/ + for (jj = 0u; jj < ((UINT16)overlapPhySecSum); jj++) + {/*·аµ*/ + + PhySecIdBufOfOtherCi[PhySecIdBufSumhOfOtherCi] = overlapPhySecIdBuf[jj]; + PhySecIdBufSumhOfOtherCi++; + } + } + } + + /*ظ*/ + phySecSum = PhySecIdBufSumhOfOtherCi; + for (ii = 0u; ii < ((UINT16)PhySecIdBufSumhOfOtherCi); ii++) + { + for (jj = ii + 1u; jj < ((UINT16)PhySecIdBufSumhOfOtherCi); jj++) + { + if (PhySecIdBufOfOtherCi[ii] == PhySecIdBufOfOtherCi[jj]) + {/*ظ*/ + + /*ظ*/ + for (kk = jj; kk < ((UINT16)PhySecIdBufSumhOfOtherCi); kk++) + { + PhySecIdBufOfOtherCi[kk] = PhySecIdBufOfOtherCi[kk + 1U]; + } + + PhySecIdBufSumhOfOtherCi = PhySecIdBufSumhOfOtherCi - 1U;/*޸*/ + } + } + } + } + } + + + return reVal; +} + +/* +* 豸̬ +* ˵const UINT8 ciId, ID +* ֵ void +*/ +void ResetDynamicState(const UINT8 ciId) +{ + UINT16 ii = 0u; + UINT16 devId = 0u;/*IdId豸IdΪ豸ԻڣIdΪ̬ԣһΪ0Ͳܸ*/ + UINT16 devLen = 0u; + UINT8 devState = 0u; + UINT16 throughRtId = 0u; + UINT16 OverlapLockedId = 0u; + UINT16 logicSectionDataSum = 0u; /*߼*/ + UINT16 logicSectionId = 0u; /*߼ID*/ + UINT8 belongCiId = 0u; + UINT16 phyId = 0u; + UINT8 neighbourSignalDetainDrive = 0u;/*վźŻ۳*/ + + UINT16 floodGateId = 0u;/*Id*/ + UINT16 floodGateSum = 0u;/**/ + + UINT8 phyBelongCi = 0u; + UINT16 phySecRepGj = 0u;/*θӹ̵*/ + UINT16 phySecRepGjBelongCi = 0u;/*θGJ*/ + UINT16 routeBelongCi = 0u; + UINT8 commState = 0u;/*ͨ״̬*/ + UINT8 psdVirtual = 0u; + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 localCi = GetSystemParaLocalCiId();/**/ + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + UINT16 wCfpSum = 0u; + UINT16 wCfpId = 0u; + UINT16 wCfpOtherCiid = 0U; /*ֽID*/ + UINT8 chOverlapCiId = 0u; + UINT32 dwCurCyc = Get2oo2CurCycleNum(); + UINT8 chSearchCiId = 0U;/*ѯID*/ + UINT8 chRouteSwitchBelCiCheck = 0U;/*·Ƿȫڽ·*/ + UINT8 chRouteStateFlag = 0U; + UINT8 chOthCiRouteExistLocalCiSw = 0U;/*·Ƿڱ*/ + UINT8 cOverlapRelProSwNum = 0U; /*ιķ*/ + OverlapProtectSwitchStruct* pOverlapRelProSwStru = NULL; /*ιķϢ*/ + UINT8 jj = 0U; + + + /*÷DZ̬*/ + for(ii = 1u; ii < SWITCH_SUM_MAX; ii++) + { + + devId = (ii); + devLen = (UINT16)sizeof(SwitchDataStruct); + if(GetSwitchBelongCiId(devId) == ciId) + { + /*DZ*/ + SwitchDataStru[devId].SwitchId = devId; + + SwitchDataStru[devId].YLockState = SWITCH_LOCK_YINZONG_NO; + SwitchDataStru[devId].LockStatus = SWITCH_LOCK_STATUS_NO; + SwitchDataStru[devId].FLockState = SWITCH_LOCK_FENGSUO_NO; + SwitchDataStru[devId].SwitchPrePosition = SWITCH_POSITION_SIKAI; + SwitchDataStru[devId].SwitMoveStartCycNum = 0u; + SwitchDataStru[devId].chSwitchDrivedFlag = SWITCH_DRIVED_FLAG_NO; + SwitchDataStru[devId].ConnetSwitchDsState = CONNECT_SWITCH_DANSUO_NO; + SwitchDataStru[devId].SwitchByPassState = SWITCH_BYPASS_NO; + SwitchDataStru[devId].chSwitchJichaState = 0U; + + SwitchDataStru[devId].SwitchCurPosition = SWITCH_POSITION_JICHA; /*ǰλ*/ + SwitchDataStru[devId].SingleSwitchCurPosition = SWITCH_POSITION_JICHA; /*ǰλ*/ + SwitchDataStru[devId].SwitchDanCaoPostition = SWITCH_POSITION_INVALID; /*λΪЧ*/ + SwitchDataStru[devId].cSwitchUsingState = SWITCH_USING_NO; /*״̬Ϊδ*/ + SwitchDataStru[devId].UsingBelongOverlapId = 0U; /*IDΪ0*/ + SwitchDataStru[devId].SwitchCollTolerateCycNum = 0U; /*ʹ*/ + SwitchDataStru[devId].SwitchColPosition = SWITCH_POSITION_SIKAI; + SwitchDataStru[devId].switchFaultState = SWITCH_FAULT_STATE_YES; /*Ϊ忨*/ + } + } + + /*÷DZζ̬*/ + for(ii = 1u; ii < PHYSICAL_SECTION_SUM_MAX; ii++) + { + + devId = (ii); + devLen = (UINT16)sizeof(PhysicalSectionDataStruct); + if(GetPhySecBelongCiId(devId) == LocalCiId) + { + if((0u !=PhysicalSectionDataStru[ii].RLockBelongRouteId) &&(ciId == GetRouteBelongCiId(PhysicalSectionDataStru[ii].RLockBelongRouteId)) ) + { + PhysicalSectionDataStru[ii].LockState = PHYSICAL_SECTION_LOCK_EXCEPT; + } + } + else if(GetPhySecBelongCiId(devId) == ciId) + { + /*DZ*/ + phyBelongCi = GetPhySecBelongCiId(PhysicalSectionDataStru[ii].PhysicalSectionId); + phySecRepGj = GetPhySecRepGdRelayId(PhysicalSectionDataStru[ii].PhysicalSectionId); + phySecRepGjBelongCi = GetRelayBelongCiId(phySecRepGj);/*ȡӹ̵*/ + commState = GetLocalCiAndOtherCiTransSta(phyBelongCi);/*ͨͨ״̬*/ + + + /* ջ߷ջʱιʱյDZ򲻱䣬쳣 + */ + if((0u !=PhysicalSectionDataStru[ii].RLockBelongRouteId) &&(LocalCiId != GetRouteBelongCiId(PhysicalSectionDataStru[ii].RLockBelongRouteId)) ) + { + PhysicalSectionDataStru[ii].LockState = PHYSICAL_SECTION_LOCK_EXCEPT; + } + + PhysicalSectionDataStru[ii].FLockState = PHYSICAL_SECTION_FLOCK_YES; + PhysicalSectionDataStru[ii].SecUseBelongRouteId = 0u; + PhysicalSectionDataStru[ii].SecProUseBelongRouteId = 0u; + PhysicalSectionDataStru[ii].SecUseState = PHYSICAL_SECTION_USING_NO; + PhysicalSectionDataStru[ii].StopSteadyFlag = PHYSICAL_SECTION_STOPSTEADY_NO; + PhysicalSectionDataStru[ii].chABLTrainFlag = PHYSICAL_SECTION_ABLOCCUPY_YES; + PhysicalSectionDataStru[ii].chPreABLTrainFlag = PHYSICAL_SECTION_ABLOCCUPY_NO; + PhysicalSectionDataStru[ii].dwAblTagSetCyc = dwCurCyc; + SetPhySecUTTrainFlag(PhysicalSectionDataStru[ii].PhysicalSectionId, PHYSICAL_AXIS_UT_YES); /*λռñ־*/ + + if ((localCi !=phyBelongCi) && (TRANSMIT_STATE_BAD == commState) && + (localCi ==phySecRepGjBelongCi)&& + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*뱾ͬθӹ̵Ϊ + ұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣԲռ*/ + } + else + { + PhysicalSectionDataStru[ii].PreMergeOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].CurMergeOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].PreAndMergeOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].CurAndMergeOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].PreOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].CurOccupyState = SECTION_OCCUPY_YES; + } + + PhysicalSectionDataStru[ii].ArbState = AXIS_SECTION_ARB_NO; + PhysicalSectionDataStru[ii].JumpLockState = PHYSICAL_SECTION_JUMP_LOCK_NO; + PhysicalSectionDataStru[ii].FLockType = PHY_SEC_FLOCK_TYPE_NONE; + PhysicalSectionDataStru[ii].JumpLockStateToZC = PHYSICAL_SECTION_JUMP_LOCK_NO; + PhysicalSectionDataStru[ii].wPhyErrUnlockTime = 0U; + } + else + { + /* ָ򲻴 */ + } + + } + + logicSectionDataSum = GetTotalLogSecCurNum();/*͸߼Ŀ*/ + /*÷DZ߼ζ̬*/ + for(ii = 0u; ii < logicSectionDataSum; ii++) + { + logicSectionId = GetLogicSecId(ii);/*ȡļиµ߼ID*/ + belongCiId = GetLogSecBelongCiId(logicSectionId); + + phyId = GetLgcSecRelativePhySecId(logicSectionId); + + /*DZ*/ + phyBelongCi = GetPhySecBelongCiId(phyId); + phySecRepGj = GetPhySecRepGdRelayId(phyId); + phySecRepGjBelongCi = GetRelayBelongCiId(phySecRepGj);/*ȡӹ̵*/ + commState = GetLocalCiAndOtherCiTransSta(phyBelongCi);/*ͨͨ״̬*/ + + /*߼ڱ*/ + if(belongCiId == LocalCiId) + { + /*·0*/ + if(0u != LogicSectionDataStru[logicSectionId].LogLockBelongRoute) + { + routeBelongCi = GetRouteBelongCiId(LogicSectionDataStru[logicSectionId].LogLockBelongRoute); + /*·*/ + if(routeBelongCi == ciId) + { + LogicSectionDataStru[logicSectionId].LogLockState = LOG_SECTION_LOCK_EXCEPT; + } + } + + } + else if(belongCiId == ciId) + { + + /*·0*/ + if(0u != LogicSectionDataStru[logicSectionId].LogLockBelongRoute) + { + routeBelongCi = GetRouteBelongCiId(LogicSectionDataStru[logicSectionId].LogLockBelongRoute); + /*·*/ + if(routeBelongCi != LocalCiId) + { + LogicSectionDataStru[logicSectionId].LogLockState = LOG_SECTION_LOCK_EXCEPT; + } + } + + if (LOG_SECTION_LOGLOCK_NORMAL == LogicSectionDataStru[logicSectionId].LogSecLogLockState) + { + LogicSectionDataStru[logicSectionId].LogSecLogLockState = LOG_SECTION_LOGLOCK_EXCEPT; /*ͨţ߼յ߼Ϊ߼쳣*/ + } + + if ((localCi !=phyBelongCi) && (TRANSMIT_STATE_BAD == commState) && + (localCi ==phySecRepGjBelongCi)&& + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*뱾ͬθӹ̵Ϊ + ұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣԲռ*/ + } + else + { + /*DZ*/ + /* ڲŻ 20220421 wqm ޸ĺֵSECTION_OCCUPY_YESΪLOGICSECTION_OCCUPY_UT */ + LogicSectionDataStru[logicSectionId].PreOccupyState = LOGICSECTION_OCCUPY_UT; + LogicSectionDataStru[logicSectionId].CurOccupyState = LOGICSECTION_OCCUPY_UT; + LogicSectionDataStru[logicSectionId].OccupyState = LOGICSECTION_OCCUPY_UT; /*ռ״̬*/ + LogicSectionDataStru[logicSectionId].TXOccupyState = LOGICSECTION_OCCUPY_NO_TX; /*TSCIϲ 20221208-lc*/ + } + /*߼Σռáʱ١δARB*/ + LogicSectionDataStru[logicSectionId].LinShiXianSuSetFlag= LOGSEC_LSXS_SET_STATE_YES; /*߼ʱ״̬*/ + LogicSectionDataStru[logicSectionId].chLinShiXianSuSetSpeed = 0U; /*߼ʱٶֵ*/ + LogicSectionDataStru[logicSectionId].chXianSuRemoveState = LOGIC_XIANSU_REMOVE_NO; + LogicSectionDataStru[logicSectionId].chArbState = LGC_SECTION_ARB_NO; /* δARB */ + LogicSectionDataStru[logicSectionId].chAblRelLogSecUsableFlag = LOGIC_ABLNEAR_USE_FLAG_NO; + LogicSectionDataStru[logicSectionId].cRouteLeaveLogFlag = LOGSEC_LEAVE_LOGSEC_REPLY_NO; /*ȥABLг鲻ͨ*/ + LogicSectionDataStru[logicSectionId].chLogicProResUsable = LOGIC_SECTION_PRO_RES_UNUSABLE; + } + else + { + /**/ + } + } + + /*÷DZźŻ̬*/ + for(ii = 1u; ii < SIGNAL_SUM_MAX; ii++) + { + devId = (ii); + devLen = (UINT16)sizeof(SignalDataStruct); + if(GetSignalBelongCiId(devId) == ciId) + { + neighbourSignalDetainDrive = GetSignalNeighbourDetainDrive(devId);/**/ + /*DZ*/ + (void)memset(&SignalDataStru[ii], 0 ,devLen); + + SignalDataStru[devId].SignalId = devId; + SignalDataStru[devId].NeighbourSignalDetainDrive = neighbourSignalDetainDrive; + /*źŻ״̬++źŻʱ ۳վͬʱ۳*/ + SetSignalFLockState(devId, SIGNAL_FENGSUO_YES); /*źŻ״̬*/ + SignalDataStru[devId].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK; /*źŻ */ + SetSignalLinShiXianSuSetFlag(devId, SIGNAL_LINSHIXIANSUSET_STATE_YES); /*źŻʱ*/ + SetSignalDetainState(devId, SIGNAL_DETAIN_YES); /*źŻ۳*/ + SetSignalRelayDetainFlag(devId, SIGNAL_RELAY_DETAIN_YES); /*źŻӲ߿۳״̬*/ + SetSignalDetainBtnActFlag(devId, SIGNAL_ZFS_BTN_ACT_FLAG_YES); /*źŻ۳ťЧ״̬*/ + /*ڻͨжϱεЧԣԼCICIжϡΪ˱֤ĶСԶڷǻͨźŻ䱣ЧһֱΪЧӰ߼*/ + SetSignalProSecValid(devId,SIGNAL_PRO_SEC_VALID); + } + } + + /*÷DZŶ̬*/ + for(ii = 1u; ii < PSD_SUM_MAX; ii++) + { + + devId = (ii); + devLen = (UINT16)sizeof(PsdDataStruct); + if(GetPsdBelongCiId(devId) == ciId) + { + /*DZ*/ + (void)memset(&PsdDataStru[ii], 0 ,devLen); + PsdDataStru[devId].PsdId = devId; + /*״̬ſ+δ*/ + PsdDataStru[devId].PsdState = PSD_STATE_OPEN; + psdVirtual = GetPsdVirtualAttribute(devId); + if (PSD_VIRTUAL_ATTR_YES == psdVirtual) + { + PsdDataStru[devId].PsdState = PSD_STATE_CLOSE; + } + PsdDataStru[devId].MutualLockRemoveState = PSD_MUTUALLOCK_REMOVE_NO; + } + } + + /*÷DZͣť̬*/ + for(ii = 1u; ii < ESB_SUM_MAX; ii++) + { + + devId = (ii); + devLen = (UINT16)sizeof(EsbDataStruct); + if(GetEsbBelongCiId(devId) == ciId) + { + /*DZ*/ + (void)memset(&EsbDataStru[ii], 0 ,devLen); + EsbDataStru[devId].EsbId = devId; + /*ESB״̬*/ + (void)SetEsbState(devId,ESB_STATE_VALID_YES); /*Ч*/ + } + } + + /*÷DZ·̬*/ + for (ii = 1u; ii < ROUTE_SUM_MAX; ii++) + { + + devId = (ii); + devLen = (UINT16)sizeof(RouteDataStruct); + belongCiId = GetRouteBelongCiId(devId); + devState = RouteDataStru[ii].RouteState; + + if (ciId == belongCiId) + { + /*DZ + εɱ(:ԷĽ·״̬ǰ + ΪԷĽ·ڱ) + ·״̬ϢΪ˫ͨжϺ󣬱εĴԺǰһ¡ + ֹͨжϺⱣΡ + + * ޸ģڽ·е״̬¡ͨжҪ·óɰȫ״̬ + * ޸20160511ԶԶ쳣ֽ·״̬ðȫ̬ + ·״̬ΪԶԶ쳣ðȫ̬󣬽·ı޷ + */ + throughRtId = GetRouteThroughRouteId(devId); + OverlapLockedId = GetRouteOverlapLockedId(devId); + if ((devState != ROUTE_STATE_XUANPAI) && + (devState != ROUTE_STATE_LEAD_XUANPAI) && + (devState != ROUTE_STATE_FIRST_LOCK) && + (devState != ROUTE_STATE_FIRST_LOCKERR) && + (devState != ROUTE_STATE_YUXIAN_OPEN) && + (devState != ROUTE_STATE_YUXIAN_LOCK) && + (devState != ROUTE_STATE_NEAR_OPEN) && + (devState != ROUTE_STATE_NEAR_LOCK) && + (devState != ROUTE_STATE_NEAR_LOCKERR) && + (devState != ROUTE_STATE_AUTO_UNLOCK) && + (devState != ROUTE_STATE_AUTO_UNLOCKERR) && + (devState != ROUTE_STATE_DELAY_UNLOCK)) + { + (void)memset(&RouteDataStru[ii], 0, devLen); + RouteDataStru[devId].RouteId = devId; + RouteDataStru[devId].ThroughRouteId = throughRtId; + RouteDataStru[devId].OverlapLockedId = OverlapLockedId; + } + else + { + ; + } + } + else + { + ; /**/ + } + + /*״̬׷ٰ־ԿԻȡʹ*/ + chRouteStateFlag = RouteDataStru[ii].RouteStateFlag; + + if ((ROUTE_STATE_XUANPAI == devState) + || (((ROUTE_STATE_AUTO_UNLOCK == devState) || (ROUTE_STATE_AUTO_UNLOCKERR == devState)) && (ROUTE_STATE_FLAG_YES == chRouteStateFlag)) + || (ROUTE_STATE_LEAD_XUANPAI == devState)) + { + if (ciId == belongCiId) + { + chOthCiRouteExistLocalCiSw = GetOthCiRouteExistLocalCiSw(devId); + if (0U != chOthCiRouteExistLocalCiSw) + { + /*ͽ·ͨжϣý·־ͨ*/ + SetRouteApplySwitchCheckFlag(devId, ROUTE_APPLY_SWITCH_CHECK_NO); + } + else + { + /*޵*/ + ; + } + + } + else if (localCi == belongCiId) + { + chRouteSwitchBelCiCheck = CheckRouteSwitchBelCi(devId, &chSearchCiId); + if (CI_SUCCESS == chRouteSwitchBelCiCheck) + { + /*ȫ*/ + chRouteSwitchBelCiCheck = CheckRouteProSwitchBelCi(devId, &chSearchCiId); + if (CI_SUCCESS == chRouteSwitchBelCiCheck) + { + /*ȫ*/ + ; + } + else + { + /*зӦ*/ + if ((ciId == chSearchCiId) && (0U != chSearchCiId)) + { + SetRouteApplySwitchCheckFlag(devId, ROUTE_APPLY_SWITCH_CHECK_NO); + } + else + { + ; /*Ǻͷжϣ*/ + } + } + } + else + { + /*еӦ*/ + if ((ciId == chSearchCiId) && (0U != chSearchCiId)) + { + SetRouteApplySwitchCheckFlag(devId, ROUTE_APPLY_SWITCH_CHECK_NO); + } + else + { + ; /*Ǻ͵жϣ*/ + } + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + } + for (ii = 1u; ii < SPKS_SUM_MAX; ii ++) + { + devId = (ii); + devLen = (UINT16)sizeof(SpksDataStruct); + if(GetSpksBelongCiId(devId) == ciId) + { + /*DZ*/ + spksDataBuff[devId].status = SPKS_STATUS_YES; /*SPKS״̬*/ + spksDataBuff[devId].cutStatus = SPKS_CUT_NO; /*SPKS·״̬δ*/ + } + } + /*̵״̬*/ + for (ii = 0u; ii < RELAY_SUM_MAX; ii ++) + { + devId = (ii); + devLen = (UINT16)sizeof(RelayDataStruct); + if(ciId == dquCICfgDtStr.RelayCfgDtStr[devId].BelongCiId) + { + /*DZ*/ + SetRelayCollState(dquCICfgDtStr.RelayCfgDtStr[devId].RelayId,RELAY_STATE_DOWN);/*ղ̵ɼ״̬¡*/ + } + } + + /*״̬*/ + floodGateSum = GetTotalFloodGateCurSum(); + for (ii=0u;ii 0u) && (floodGateId < FLOOD_GATE_SUM_MAX)) + { + FloodGateDataStru[floodGateId].CurAgreeCloseAckFromZC = FLOOD_GATE_NOT_ALLOWCLOSE_ZC; + FloodGateDataStru[floodGateId].CurAgreeCloseStateIn = FLOOD_GATE_NOT_AGREE_CLOSE; + FloodGateDataStru[floodGateId].CurAgreeCloseStateOut = FLOOD_GATE_NOT_AGREE_CLOSE; + FloodGateDataStru[floodGateId].CurCloseRequestStateFromFYM = FLOOD_GATE_NOT_CLOSEREQ; + FloodGateDataStru[floodGateId].CurOpenLockStateFromFYM = FLOOD_GATE_NOT_OPENLOCK; + FloodGateDataStru[floodGateId].CurYGJCrossLineStartCount = 0u;/*߿ʼʱΪ0*/ + } + } + + /*÷DZζ̬*/ + for(ii = 1u; ii < OVERLAP_SUM_MAX; ii++) + { + devId = (ii); + devLen = (UINT16)sizeof(OverlapDataStruct); + chOverlapCiId = GetOverlapBelongCiId(devId); + if((chOverlapCiId == ciId) && (devId > 0u) && (devId < OVERLAP_SUM_MAX)) + { + OverlapDataStru[devId].BelongRouteId = 0u; + OverlapDataStru[devId].UnlockStartCycNum = 0u; + OverlapDataStru[devId].XuanPaiStartCycNum = 0u; + OverlapDataStru[devId].OverlapUnlockApplyFlag = UNLOCK_OVERLAP_APPLY_NO; + OverlapDataStru[devId].wOverlapUnlockApplyTrainId = 0U; + OverlapDataStru[devId].dwReqIvocUnLockStartCycNum = 0U; + OverlapDataStru[devId].cIvocAllowUnlockFlag = IVOC_ALLOW_UNLOCK_OVERLAP_NO; + OverlapDataStru[devId].OverlapCanLaborUnlockFlag = CANNOT_LABOR_UNLOCK_OVERLAP; + OverlapDataStru[devId].OverlapLaborUnlockSetState = LABOR_UNLOCK_OVERLAP_NO; + OverlapDataStru[devId].laborUnlockStartCycNum = 0u; + OverlapDataStru[devId].atsOrlaborLockFlag = LOCK_OVERLAP_CMD_NO; + OverlapDataStru[devId].lockStartCycNum = 0u; + OverlapDataStru[devId].overlapUnlockTime = 0u; + OverlapDataStru[devId].laborLockOverlapCmd = LOCK_OVERLAP_CMD_NO; + OverlapDataStru[devId].cProSwitchCheckResultFlag = PROSWITCH_CHECK_RESULT_INVALID; + OverlapDataStru[devId].cProSwitchCheckStartFlag = PROSWITCH_CHECK_START_INVALID; + } + else if ((chOverlapCiId == localCi) && (devId > 0U) && (devId < OVERLAP_SUM_MAX)) + { + cOverlapRelProSwNum = GetOverlapRelatedProtSwitSum(devId); /*ȡιķϢ*/ + pOverlapRelProSwStru = GetOverlapRelatedProtSwitStru(devId); + + if ((0U != cOverlapRelProSwNum) && (NULL != pOverlapRelProSwStru)) + { + for (jj = 0U; jj < cOverlapRelProSwNum; jj++) + { + belongCiId = GetSwitchBelongCiId(pOverlapRelProSwStru[jj].ProtectSwitchId); + if (ciId == belongCiId) + { + if (PROSWITCH_CHECK_START_VALID == OverlapDataStru[devId].cProSwitchCheckStartFlag) + { + /*δУ־Ϊ0x55ʧܣڱռʱΪֻѸñ־תΪ0xFFĬֵ*/ + OverlapDataStru[devId].cProSwitchCheckResultFlag = PROSWITCH_CHECK_RESULT_INVALID; + } + else + { + /*βУ־־޷ص0xFF״̬*/ + } + break; + } + else + { + /*ǶԷ÷־*/ + } + } + } + else + { + /*޷÷־*/ + } + } + else + { + + } + } + + /* İϢ */ + wCfpSum = GetCfpSum(); + for (ii = 0u; ii < wCfpSum; ii++) + { + wCfpId = GetCfpId(ii); + wCfpOtherCiid = GetCfpOtherTioc(wCfpId); + if (wCfpOtherCiid == ciId) + { + SetCfpOtherOcENum(wCfpId, 0u); + } + else + { + ; + } + } + /*Զͨ·*/ + /*cgh-ϲCID-2539-7*/ + for (ii = 1u; ii < AUTO_ROUTE_SUM_MAX; ii++) + { + devId = ii; + belongCiId = GetAutoRouteBelongCiId(devId); + if (belongCiId == ciId) + { + /*DZ״̬*/ + AutoRouteDataStru[devId].AutoRouteSetFlag = AUTO_ROUTE_SET_NO; /*Զ·δ*/ + } + } +} + +/* +* Զ·ͶӦԶźID +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 SetAutoSignalId(void) +{ + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT16 routeId = 0u; + UINT8 result = CI_SUCCESS; + UINT8 routeAutoSigProperty = 0u; /*·Զź*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT16 ii = 0u; + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + /* + * ĿĽźŻԶźŽ·ID: ·ݽ·Խжϣ·ԶźţȡʼźŻID + * øźŻΪԶźŻ·IDõӦС + * + */ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = GetRouteId(ii); /* ȡ·ID */ + routeAutoSigProperty = GetRouteAutoSigProperty(routeId); /* ȡ·Զź*/ + if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty) /*Զź */ + { + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + if(CI_ERROR == SetSignalAutoRouteId(startSignalId,routeId)) + { + result = CI_ERROR; + break; + } + } + else + { + /* Զźţʲô */ + } + } + return result; +} + + +/* +* ʼȫԶ۷· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialAllAutoReturnRouteData(void) +{ + UINT16 allAutoReturnRouteSum = 0u; /*Զ۷·*/ + UINT16 allAutoReturnRouteId = 0u; /*Զ۷·ID*/ + UINT16 ii = 0u; /*α*/ + UINT8 returnValue = CI_SUCCESS; + + allAutoReturnRouteSum = GetAllAutoReturnRouteCurSum(); + + if (allAutoReturnRouteSum >= ALL_AUTO_RETURN_SUM_MAX) + {/**/ + returnValue = CI_ERROR; + } + else + { + for (ii = 0u; ii < allAutoReturnRouteSum; ii++) + { + allAutoReturnRouteId = GetAllAutoReturnRouteId(ii);/*ȡļиµԶ۷·ID*/ + + AllAutoReturnDataStru[allAutoReturnRouteId].AllAutoReturnId = allAutoReturnRouteId; + AllAutoReturnDataStru[allAutoReturnRouteId].AllAutoReturnSetFlag = ALL_AUTO_RETURN_SET_NO; + returnValue &= SetautoRouteOpposedRoute(allAutoReturnRouteId,ROUTE_ALLAUTOROUTE_RETURN); + } + } + + return returnValue; +} + + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialGaragedoorData(void) +{ + UINT16 garagedoorDataSum = 0u; /**/ + UINT16 garagedoorId = 0u; /*ID*/ + UINT16 ii = 0u; /*α*/ + UINT8 returnValue = CI_SUCCESS; + + garagedoorDataSum = GetGaragedoorSum(); + + if (garagedoorDataSum >= GARAGE_DOOR_SUM_MAX) + {/**/ + returnValue = CI_ERROR; + } + else + { + for (ii = 0u; ii < garagedoorDataSum; ii++) + { + garagedoorId = GetGaragedoorId(ii);/*ȡļиµijID*/ + + GaragedoorDataStru[garagedoorId].GaragedoorId = garagedoorId; /*ID (ʼֶ)*/ + GaragedoorDataStru[garagedoorId].GaragedoorState = GARAGE_DOOR_STATE_CLOSE; /*״̬ (ֶ̬)*/ + GaragedoorDataStru[garagedoorId].GaragedoorModeState = GARAGE_DOOR_STATE_MODE_LOCAL; /*ģʽ״̬*/ + GaragedoorDataStru[garagedoorId].GaragedoorFaultState = GARAGE_DOOR_FAULT_TRUE; /*Ź״̬*/ + GaragedoorDataStru[garagedoorId].GDAkuNearestTrainId = NAME_FAILUREAREA; /*AӽŵгID*/ + GaragedoorDataStru[garagedoorId].GaragedoorAllowCloseFlag = GARAGE_DOOR_ALLOW_CLOSE_NO; /*ű־ZC*/ + GaragedoorDataStru[garagedoorId].GDAllowCloseFlagIVOC = GARAGE_DOOR_ALLOW_CLOSE_NO; /*ű־IVOC*/ + GaragedoorDataStru[garagedoorId].drvDoorState = GARAGE_DOOR_DRV_NULL; /* ״̬*/ + GaragedoorDataStru[garagedoorId].cmdProcessState = GARAGE_DOOR_CMD_NULL; /* ״̬ */ + GaragedoorDataStru[garagedoorId].drvDoorStartCycle = 0u; /* ʼʱ,Ԥ */ + GaragedoorDataStru[garagedoorId].waiteZCResponseStartCycNum = 0u; /*ȴZCʼʱ*/ + GaragedoorDataStru[garagedoorId].waiteIVOCResponseStartCycNum = 0u; /*ȴIVOCʼʱ*/ + GaragedoorDataStru[garagedoorId].GaragedoorOpenStartCycNum = 0u; /*Ŵ򿪿ʼ*/ + GaragedoorDataStru[garagedoorId].GaragedoorCloseStartCycNum = 0u; /*Źرտʼ*/ + GaragedoorDataStru[garagedoorId].GaragedoorPangLuState = GARAGE_DOOR_PANGLU_FALSE; /*·״̬*/ + } + + } + + return returnValue; +} + +/* +* ûͨ豸̬ +* ˵const UINT8 ciId, ID +* ֵ void +*/ +void ResetDynamicStateHlht(const UINT8 ciId) +{ + UINT16 ii = 0u; + UINT16 devId = 0u;/*IdId豸IdΪ豸ԻڣIdΪ̬ԣһΪ0Ͳܸ*/ + UINT16 devLen = 0u; + + /*÷DZ̬*/ + for (ii = 1u; ii < SWITCH_SUM_MAX; ii++) + { + + devId = (ii); + devLen = (UINT16)sizeof(SwitchDataStruct); + if (GetSwitchBelongCiId(devId) == ciId) + { + /*DZ*/ + (void)memset(&SwitchDataStru[ii], 0, devLen); + SwitchDataStru[devId].SwitchId = devId; + + /*õǰλ */ + SwitchDataStru[devId].SwitchCurPosition = SWITCH_POSITION_JICHA; /*ǰλ*/ + SwitchDataStru[devId].SingleSwitchCurPosition = SWITCH_POSITION_JICHA; /*ǰλ*/ + } + } + + /*÷DZζ̬*/ + for (ii = 1u; ii < PHYSICAL_SECTION_SUM_MAX; ii++) + { + devId = (ii); + devLen = (UINT16)sizeof(PhysicalSectionDataStruct); + if (GetPhySecBelongCiId(devId) == ciId) + { + PhysicalSectionDataStru[ii].FLockState = PHYSICAL_SECTION_FLOCK_YES; + PhysicalSectionDataStru[ii].SecUseBelongRouteId = 0u; + PhysicalSectionDataStru[ii].SecProUseBelongRouteId = 0u; + PhysicalSectionDataStru[ii].SecUseState = PHYSICAL_SECTION_USING_NO; + PhysicalSectionDataStru[ii].StopSteadyFlag = PHYSICAL_SECTION_STOPSTEADY_NO; + PhysicalSectionDataStru[ii].PreMergeOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].CurMergeOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].PreAndMergeOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].CurAndMergeOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].PreOccupyState = SECTION_OCCUPY_YES; + PhysicalSectionDataStru[ii].CurOccupyState = SECTION_OCCUPY_YES; + } + } + + /*÷DZ߼ζ̬*/ + for (ii = 1u; ii < LOGIC_SECTION_SUM_MAX; ii++) + { + devId = (ii); + devLen = (UINT16)sizeof(LogicSectionDataStruct); + if (GetLogSecBelongCiId(devId) == ciId) + { + /*DZ*/ + /* ڲŻ 20220421 wqm ޸ĺֵSECTION_OCCUPY_YESΪLOGICSECTION_OCCUPY_UT */ + LogicSectionDataStru[ii].PreOccupyState = LOGICSECTION_OCCUPY_UT; + LogicSectionDataStru[ii].CurOccupyState = LOGICSECTION_OCCUPY_UT; + LogicSectionDataStru[ii].OccupyState = LOGICSECTION_OCCUPY_UT; /*ռ״̬*/ + /*߼Σռ+ʱ*/ + LogicSectionDataStru[ii].LinShiXianSuSetFlag = LOGSEC_LSXS_SET_STATE_YES; /*߼ʱ״̬*/ + } + } + + /*÷DZźŻ̬*/ + for (ii = 1u; ii < SIGNAL_SUM_MAX; ii++) + { + devId = (ii); + devLen = (UINT16)sizeof(SignalDataStruct); + if (GetSignalBelongCiId(devId) == ciId) + { + /*DZ*/ + (void)memset(&SignalDataStru[ii], 0, devLen); + SignalDataStru[devId].SignalId = devId; + /*źŻ״̬++źŻʱ ۳վͬʱ۳*/ + SetSignalFLockState(devId, SIGNAL_FENGSUO_YES); /*źŻ״̬*/ + SignalDataStru[devId].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK; /*źŻ */ + SetSignalLinShiXianSuSetFlag(devId, SIGNAL_LINSHIXIANSUSET_STATE_YES); /*źŻʱ*/ + SetSignalDetainState(devId, SIGNAL_DETAIN_YES); /*źŻ۳*/ + SetSignalProSecValid(devId,SIGNAL_PRO_SEC_INVALID);/*Ч*/ + } + } + + /*÷DZŶ̬*/ + for (ii = 1u; ii < PSD_SUM_MAX; ii++) + { + + devId = (ii); + devLen = (UINT16)sizeof(PsdDataStruct); + if (GetPsdBelongCiId(devId) == ciId) + { + /*DZ*/ + (void)memset(&PsdDataStru[ii], 0, devLen); + PsdDataStru[devId].PsdId = devId; + /*״̬ſ+δ*/ + PsdDataStru[devId].PsdState = PSD_STATE_OPEN; + PsdDataStru[devId].MutualLockRemoveState = PSD_MUTUALLOCK_REMOVE_NO; + } + } + + /*÷DZͣť̬*/ + for (ii = 1u; ii < ESB_SUM_MAX; ii++) + { + + devId = (ii); + devLen = (UINT16)sizeof(EsbDataStruct); + if (GetEsbBelongCiId(devId) == ciId) + { + /*DZ*/ + (void)memset(&EsbDataStru[ii], 0, devLen); + EsbDataStru[devId].EsbId = devId; + /*ESB״̬*/ + (void)SetEsbState(devId, ESB_STATE_VALID_YES); /*Ч*/ + } + } + + for (ii = 1u; ii < SPKS_SUM_MAX; ii++) + { + devId = (ii); + devLen = (UINT16)sizeof(SpksDataStruct); + if (GetSpksBelongCiId(devId) == ciId) + { + /*DZ*/ + spksDataBuff[devId].status = SPKS_STATUS_YES; /*SPKS״̬*/ + spksDataBuff[devId].cutStatus = SPKS_CUT_NO; /*SPKS·״̬δ*/ + } + } +} + +/* +* ʼOc +* ˵void +* ֵ void +*/ +void InitOcData(void) +{ + UINT16 i = 0U; + UINT16 j = 0U; + UINT16 k = 0U; + /*ʼm_OcConvertedPtDataArr*/ + for (i = 0U; i < OC_SUM_MAX; i++) + { + m_OcConvertedPtDataArr[i].OcBoardNum = 0u; + m_OcConvertedPtDataArr[i].OcId = 0u; + for (j = 0U; j < Oc_Max_Board_Num; j++) + { + m_OcConvertedPtDataArr[i].BoardDatas[j].BoardAddress = 0u; + m_OcConvertedPtDataArr[i].BoardDatas[j].BoardState = RELAY_BOARD_FAULT_YES; /*ʼ忨*/ + for (k = 0U; k < OC_COLL_BOARD_POS_NUM; k++) + { + m_OcConvertedPtDataArr[i].BoardDatas[j].PosValueBuf[k] = 0u; + } + + } + } + /*ʼm_OcToCiOrginDataArr*/ + for (i = 0U; i < OC_SUM_MAX; i++) + { + m_OcToCiOrginDataNum = 0u; + m_OcToCiOrginDataArr[i].ComStartCycle = 0u; + m_OcToCiOrginDataArr[i].OcId = 0u; + m_OcToCiOrginDataArr[i].OcDeviceNum = 0u; + m_OcToCiOrginDataArr[i].OcDIBoardDataNum = 0u; + m_OcToCiOrginDataArr[i].OcDOBoardNum = 0u; + m_OcToCiOrginDataArr[i].OcSORBoardNum = 0u; + m_OcToCiOrginDataArr[i].OcGdNum = 0u; + m_OcToCiOrginDataArr[i].RecvErrorDevTypeCycle = 0u; + + m_OcToCiOrginDataArr[i].PowerAState = (UINT8)0xFF; + m_OcToCiOrginDataArr[i].PowerBState = (UINT8)0xFF; + m_OcToCiOrginDataArr[i].OCDevFaultState = (UINT8)0xFF; + m_OcToCiOrginDataArr[i].FanState = (UINT8)0xFF;/*״̬ʼΪ*/ + m_OcToCiOrginDataArr[i].OCBoardSwapSysNum = 0U; /*OCϵ忨ʼΪ*/ + for (j = 0U; j < MAX_OC_DEVICE_NUM; j++) + { + m_OcToCiOrginDataArr[i].SwapSysBoardId[j] = 0U; + } + + } +} +/* +* ʼ +* ˵void +* ֵ void +*/ +void InitLocalCIHaveVirCI_UseVirCI(void) +{ + UINT8 localCIid = 0u; + UINT16 i= 0u; + UINT8 j = 0u; + UINT8 virCINum = 0u; + localCIid = GetSystemParaLocalCiId(); + + for(i=0u;i virCINum)) + { + g_VirtualCIStructData.virtualCi[virCINum++].virtualCiId= (UINT8)dsuStaticHeadStru.pLinkStru[i].wBelongVirtualCI; + } + } + } + g_VirtualCIStructData.virtualCiNum = virCINum; + + for(j=0u;j= INDICATOR_SUM_MAX) + {/**/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + for (ii = 0; ii < configStruSum; ii++) + { + g_OCStationIndicDataStru[ii].ocid = g_OCStationIndicConfigDataStru[ii].OcId; + g_OCStationIndicDataStru[ii].IndicatorId = g_OCStationIndicConfigDataStru[ii].IndicatorId; + g_OCStationIndicDataStru[ii].IndicatorState = INDICATOR_SHOW_NO; + } + } + return reVal; +} + +/* +* ʼźŻĽ·־ +* ˵ UINT16 signalId źŻID +* ֵ void +* +*/ +void SetSignalLeadRouteCbtcFlag(UINT16 signalId) +{ + UINT16 jj = 0u; /*α*/ + UINT16 routeSum = 0u; /*·*/ + UINT16 routeId = 0u; /*·ID*/ + UINT16 startSignalId = 0u; /*ʼźŻID*/ + UINT8 wRouteLeadProperty = 0U; /*·*/ + + routeSum = GetRouteCurSum(); + for (jj = 0u; jj < routeSum; jj++) + { + routeId = GetRouteId(jj);/*routeIdлõ*/ + startSignalId = GetRouteStartSignalId(routeId); + if (signalId == startSignalId) + { + wRouteLeadProperty = GetRouteLeadProperty(routeId); + + if ((ROUTE_LEAD_PROPERTY_YES == wRouteLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == wRouteLeadProperty)) + { + if (((0U == SignalDataStru[signalId].SignalLeadRouteCbtcFlag) || (SIGNAL_LEADROUTE_ALLCBTC == SignalDataStru[signalId].SignalLeadRouteCbtcFlag)) + && (ROUTE_LEAD_PROPERTY_CBTC_YES == wRouteLeadProperty)) + { + SignalDataStru[signalId].SignalLeadRouteCbtcFlag = SIGNAL_LEADROUTE_ALLCBTC; + } + else if (((0U == SignalDataStru[signalId].SignalLeadRouteCbtcFlag) || (SIGNAL_LEADROUTE_ALL_NO_CBTC == SignalDataStru[signalId].SignalLeadRouteCbtcFlag)) + && (ROUTE_LEAD_PROPERTY_YES == wRouteLeadProperty)) + { + SignalDataStru[signalId].SignalLeadRouteCbtcFlag = SIGNAL_LEADROUTE_ALL_NO_CBTC; + } + else + { + SignalDataStru[signalId].SignalLeadRouteCbtcFlag = SIGNAL_LEADROUTE_CBTC_ANDNO; /*źŻĽ·CBTCģҲзCBEC*/ + } + } + else + { + ; /*ֻԵĽ·Ҫȥô˱־·˱־òţ账*/ + } + } + else + { + ; + } + } +} + + +/* +* ʼƽ̨͵ͨءչ +* ˵void +* ֵ void +*/ +void InitPlatDataStru(void) +{ + /*CCUA*/ + RecvHeartDataStru.voltageA_CCA = 0U; /*24VAԴ_ѹ*1000*/ + RecvHeartDataStru.voltageB_CCA = 0U; /*24VBԴ_ѹ*1000*/ + RecvHeartDataStru.currentA_CCA = 0U; /*24VAԴ_*1000*/ + RecvHeartDataStru.currentB_CCA = 0U; /*24VVԴ_*1000*/ + RecvHeartDataStru.voltageCoup_CCA = 0U; /*24VԴ_ѹ*1000*/ + RecvHeartDataStru.currentCoup_CCA = 0U; /*24VԴ_*1000*/ + RecvHeartDataStru.temperature_CCA = 0U; /*¶ֵ*1000*/ + RecvHeartDataStru.check_EEPROM_CCA = 0U; /*EEPROM洢*/ + RecvHeartDataStru.commStartCycle_CCA = 0U; /*ͨ*/ + /*CCUB*/ + RecvHeartDataStru.voltageA_CCB = 0U; /*24VAԴ_ѹ*1000*/ + RecvHeartDataStru.voltageB_CCB = 0U; /*24VBԴ_ѹ*1000*/ + RecvHeartDataStru.currentA_CCB = 0U; /*24VAԴ_*1000*/ + RecvHeartDataStru.currentB_CCB = 0U; /*24VVԴ_*1000*/ + RecvHeartDataStru.voltageCoup_CCB = 0U; /*24VԴ_ѹ*1000*/ + RecvHeartDataStru.currentCoup_CCB = 0U; /*24VԴ_*1000*/ + RecvHeartDataStru.temperature_CCB = 0U; /*¶ֵ*1000*/ + RecvHeartDataStru.check_EEPROM_CCB = 0U; /*EEPROM洢*/ + RecvHeartDataStru.commStartCycle_CCB = 0U; /*ͨ*/ + /*SEBA*/ + RecvHeartDataStru.commStartCycle_SEBA = 0U; /*ͨ*/ + /*SEBB*/ + RecvHeartDataStru.commStartCycle_SEBB = 0U; /*ͨ*/ +} + + +/* +* ʼLEUCI +* ˵void +* ֵ سʼ +*/ +UINT8 InitLEUDataStru(void) +{ + UINT8 tranCiNum = 0u; + UINT8* tranCiIdBuf = NULL; + UINT8 reVal = CI_ERROR; + UINT8 jj = 0U; + UINT8 ii = 0U; + + tranCiNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_LEU); + tranCiIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_LEU); + + if (LEU_TO_CI_SUM_MAX < tranCiNum) + { + reVal = CI_ERROR; /*ޣʧ*/ + } + else + { + reVal = CI_SUCCESS; + for (jj = 0u; jj < tranCiNum; jj++) + { + LeuToCiDataStru[jj].allState = 0U; /*ʼ״̬*/ + + /*ʼIDʾ*/ + for (ii = 0U; ii < 3U; ii++) + { + LeuToCiDataStru[jj].idInfo[ii] = 0U; + } + /*ʼLEU״̬*/ + LeuToCiDataStru[jj].leuType = 0U; + LeuToCiDataStru[jj].toQianjiComState = 0U; + LeuToCiDataStru[jj].boardState = 0U; + + /*ʼ״̬*/ + for (ii = 0U; ii < 4U; ii++) + { + LeuToCiDataStru[jj].outState[ii] = 0U; + } + /*ʼλϢ*/ + for (ii = 0U; ii < 12U; ii++) + { + LeuToCiDataStru[jj].maskInfo[ii] = 0U; + } + /*ʼATS־*/ + LeuToCiDataStru[jj].errorToAtsFlag = LEU_TO_ATS_ERRORFLAG_NO; + } + } + + return reVal; +} + +/* +* ʼ۷ָʾ״̬ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +* by cgh 20240904 +*/ +UINT8 InitialRtnIndicStaData(void) +{ + UINT16 wNonAutoReturnCurSum = 0U;/*۷ǰĿ*/ + UINT16 wNonAutoReturnId = 0U;/*۷ID*/ + UINT16 ii = 0U; + UINT8 chReval = CI_ERROR; + UINT8 jj = 0u; + UINT8 kk = 0U; + UINT8 rtnIndicatorSum = 0U; + UINT16 indicatorType = 0U; + UINT16 wNonRtnIndicatorId = 0U;/*۷ʾID*/ + UINT8 chRelaySum = 0U; /*̵*/ + UINT16* pRelayIdBuf = NULL; /*̵*/ + + wNonAutoReturnCurSum = GetNonAutoReturnCurSum(); + + if (NON_AUTO_RETURN_SUM_MAX > wNonAutoReturnCurSum) + { + chReval = CI_SUCCESS; + + for (ii = 0U; ii < wNonAutoReturnCurSum; ii++) + { + wNonAutoReturnId = GetNonReturnId(ii); + NonReturnDataStru[wNonAutoReturnId].IndicatorDevID = wNonAutoReturnId; + NonReturnDataStru[wNonAutoReturnId].cmdSetTrainId = 0U; + NonReturnDataStru[wNonAutoReturnId].VobcToCIAutoRtnIndicFlashState = VOBCTOCIAUTORTN_INDICT_MASK_INVALID; + NonReturnDataStru[wNonAutoReturnId].VobcToCIAutoRtnIndicSteadyState = VOBCTOCIAUTORTN_INDICT_MASK_INVALID; + + wNonRtnIndicatorId = GetNonRtnRlyId(wNonAutoReturnId); + + /*۷ָʾ۷ť*/ + chRelaySum = GetIndicatorRelaySum(wNonRtnIndicatorId); + pRelayIdBuf = GetIndicatorRelayIdBuf(wNonRtnIndicatorId); + if ((3U != chRelaySum) || (NULL == pRelayIdBuf) || (RELAY_SUM_MAX < pRelayIdBuf[2])) + { + /*δ۷̵*/ + } + else + { + NonReturnDataStru[wNonAutoReturnId].RtnRelayAdhesionState.AdhesionRealyId = pRelayIdBuf[2]; + NonReturnDataStru[wNonAutoReturnId].RtnRelayAdhesionState.AdhesionState = RTN_RELAY_ADHESION_NO; + NonReturnDataStru[wNonAutoReturnId].RtnRelayAdhesionState.RelayUpCycNum = 0U; + + } + } + } + else + { + ; /*ʧ*/ + } + + if (CI_SUCCESS == chReval) + { + for (jj = 0; jj < g_VirtualCIStructData.virtualCiNum; jj++) + { + /*ָʾ豸IDֵ*/ + for (kk = 0U; kk < g_VirtualCIStructData.virtualCi[jj].IndicatorConfigDataNum; kk++) + { + indicatorType = g_VirtualCIStructData.virtualCi[jj].IndicatorConfigData[kk].IndicatorType; + if ((INDICATOR_TYPE_EXPRESS_RETURN == indicatorType) && (RTNINDICATOR_SUM_MAX > rtnIndicatorSum)) + { + g_VirtualCIStructData.virtualCi[jj].VirCIRtnIndicatorStaData[rtnIndicatorSum].VirCiIndicatorDevId = g_VirtualCIStructData.virtualCi[jj].IndicatorConfigData[kk].BjdDeviceId; + rtnIndicatorSum++; + } + else + { + ; + } + + if (RTNINDICATOR_SUM_MAX <= rtnIndicatorSum) + { + /*һֻ۷ָʾID*/ + break; + } + else + { + ; + } + } + /*ÿ۷ָʾ״̬ʼΪЧ*/ + for (kk = 0U; kk < RTNINDICATOR_SUM_MAX; kk++) + { + if (RTNINDICATOR_SUM_MAX > rtnIndicatorSum) + {/*û۷ָʾ豸ֻһʱݳʼΪ0*/ + g_VirtualCIStructData.virtualCi[jj].VirCIRtnIndicatorStaData[rtnIndicatorSum].VirCiIndicatorDevId = 0U; + rtnIndicatorSum++; + } + else + { + ; + } + + g_VirtualCIStructData.virtualCi[jj].VirCIRtnIndicatorStaData[kk].VirCiFlashState = VOBCTOCIAUTORTN_INDICT_MASK_INVALID; + g_VirtualCIStructData.virtualCi[jj].VirCIRtnIndicatorStaData[kk].VirCiSteadyState = VOBCTOCIAUTORTN_INDICT_MASK_INVALID; + } + } + } + else + { + ; + } + + return chReval; +} diff --git a/TSCP/src/APP/ciapp/Initial/InitialProcess.h b/TSCP/src/APP/ciapp/Initial/InitialProcess.h new file mode 100644 index 0000000..60f890a --- /dev/null +++ b/TSCP/src/APP/ciapp/Initial/InitialProcess.h @@ -0,0 +1,337 @@ +/******************************************************** +* +* InitialProcess.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-06-29 +* ߣ +* ݳʼͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _INITIAL_PROCESS_H_ +#define _INITIAL_PROCESS_H_ + +#include "./ConfigDataReadManage.h" +#include "../AutoReturn/AutoReturnConfigDataManage.h" +#include "../AutoReturn/AutoReturnDataManage.h" +#include "../esb/ESBConfigDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../psd/PSDConfigDataManage.h" +#include "../PSD/PSDDataManage.h" +#include "../Overlap/OverlapConfigDataManage.h" +#include "../Overlap/OverlapDataManage.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../Route/RouteDataManage.h" +#include "../Route/LongRouteDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Section/AxisSectionConfigDataManage.h" +#include "../Section/AxisSectionDataManage.h" +#include "../Section/LogicSectionConfigDataManage.h" +#include "../Section/LogicSectionDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" +#include "../Transmit/TransmitStateDataManage.h" +#include "../System/SystemParameterManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../ParsePack/ParsePackCiData.h" +#include "../NonRoute/NonRouteDataManage.h" +#include "../Route/LongRouteConfigDataManage.h" +#include "../Route/LongRouteDataManage.h" +#include "../AllAutoReturn/AllAutoReturnConfigDataManage.h" +#include "../AllAutoReturn/AllAutoReturnDataManage.h" +#include "../Garagedoor/GaragedoorConfigDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" +#include "../WashMachine/WashMachineConfigDataManage.h" +#include "../WashMachine/WashMachineDataManage.h" +#include "../ParsePack/ParsePackPlatformData.h" +#include "../SPKS/SpksDataManage.h" +#include "../DiffLineDev/DiffLineDevConfigDataManage.h" +#include "../FloodGate/FloodGateDataManage.h" +#include "../FloodGate/FloodGateDefine.h" +#include "../ParsePack/ParsePackOcData.h" +#include "../ParsePack/ParsePackAxleData.h" +#include "../ParsePack/ParsePackPSCData.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../ParsePack/ParsePackLeuData.h" +#include "../ReverseCut/ReverseCutDataManage.h" +#include "../Route/DynamicRouteDataManage.h" +#include "../LogicManage/InterlockLogicManage.h" +#include "../EnvelopeManage/EnvelopeManageAPI.h" +#include "../WLScreen/WholeLineScreenAPI.h" +#include "../Indicator/IndicatorConfigDataManage.h" +#include "../QueryFiles/dquCIInit.h" +#include "../ESB/ESBDataManage.h" +#include "../AutoRoute/AutoRouteDataManage.h" +#include "../NonAutoReturn/NonAutoReturnDataManage.h" +#include "../VirtualDevice/VirtualDevDataManage.h" + +#ifdef SCADE_MODE +#include "../LogicManage/General/LogicManageScadeInterface.h" +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +* ʼ߼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialProcess(void); + +/* +* ʼźŻ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialSignalData(void); + +/* +* ʼϴ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialWashMachineData(void); + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialSwitchData(void); + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialPhySectionData(void); + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialAxisSectionData(void); + +/* +* ʼ߼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialLogicSectionData(void); + +/* +* ʼͣť +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialEsbData(void); + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialPsdData(void); + +/* +* ʼ̵ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialRelayData(void); + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialOverlapData(void); + +/* +* ʼ· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialRouteData(void); + +/* +* ʼ· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +void InitialLongRouteData(void); + +/* +* ʼǽ· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +void InitialNonRouteData(void); + +/* +* ʼԶ۷· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialAutoReturnRouteData(void); + +/* +* ʼԶͨ· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialAutoRouteRouteData(void); + +/* +* ʼʾƱ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialIndicatorStateData(void); + +/* +* ʼͨ״̬ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialTransmitStateData(void); + +/* +* ʼ״̬ȨID +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialPhySecIdBufOfOtherCi(void); + +/* +* 豸̬ +* ˵const UINT8 ciId, ID +* ֵ void +*/ +void ResetDynamicState(const UINT8 ciId); + + +/* +* ʼȫԶ۷· +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialAllAutoReturnRouteData(void); + + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialGaragedoorData(void); + +/* +* ûͨ豸̬ +* ˵const UINT8 ciId, ID +* ֵ void +*/ +void ResetDynamicStateHlht(const UINT8 ciId); + +/* +* ʼ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +*/ +UINT8 InitialFloodGateData(void); + +/* +* ʼOc +* ˵void +* ֵ void +*/ +void InitOcData(void); + +/* +* ʼ +* ˵void +* ֵ void +*/ +void InitLocalCIHaveVirCI_UseVirCI(void); + +/* +* ʼݽṹ +* ˵void +* ֵ void +*/ +void InitCtrlPowerStru(void); +/* +* ʼOCվʾƱ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +* +* cgh-ϲCID-3037-3 +*/ +UINT8 InitialOCStationIndicStaData(void); + +/* +* ʼƽ̨͵ͨءչ +* ˵void +* ֵ void +*/ +void InitPlatDataStru(void); + +/* +* ʼLEUCI +* ˵void +* ֵ سʼ +*/ +UINT8 InitLEUDataStru(void); + +/* +* ʼ۷ָʾ״̬ +* ˵ void +* ֵ 0: ʼʧ +* 1; ʼɹ +* by cgh 20240904 +*/ +UINT8 InitialRtnIndicStaData(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionConfigDataManage.c b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionConfigDataManage.c new file mode 100644 index 0000000..770df10 --- /dev/null +++ b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionConfigDataManage.c @@ -0,0 +1,214 @@ +/******************************************************** +* +* InvadeSectionConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2015-12-11 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "InvadeSectionConfigDataManage.h" + +InvSecConfigDataStruct InvSecConfigDataStru[INVA_SECT_N_COND_SWIT_SUM_MAX]; /*ݽṹ*/ + +INT16 InvSecSum = 0; /**/ + +UINT16 IdToIndMap[INVA_SECT_N_COND_SWIT_SUM_MAX]; /*ӳ*/ + +/* +: +: UINT16 invSecAndConSwiId μID +: +ֵ: (0u, INVA_SECT_N_COND_SWIT_SUM_MAX) + INVA_SECT_N_COND_SWIT_SUM_MAX ȡʧ +*/ +static UINT16 GetInvSecAndConSwiBufInd(const UINT16 invSecAndConSwiId) +{ + UINT16 retVal = INVA_SECT_N_COND_SWIT_SUM_MAX; + + if( (INVA_SECT_N_COND_SWIT_MIN_ID <= invSecAndConSwiId) && + ( INVA_SECT_N_COND_SWIT_SUM_MAX > invSecAndConSwiId)) + { + retVal = invSecAndConSwiId; + } + + return retVal; +} + + +/* +: μIDݵ +: +: +ֵ: CI_ERROR ʧ + CI_SUCCESS óɹ +*/ +UINT8 SetInvSecAndConSwiBufInd(void) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 invSecAndConSwiSum = 0u; /**/ + + /*·ID*/ + invSecAndConSwiSum = GetInvSecAndConSwiSum(); + if (invSecAndConSwiSum >= INVA_SECT_N_COND_SWIT_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < INVA_SECT_N_COND_SWIT_SUM_MAX; ii++) + { + if (jj == invSecAndConSwiSum) + {/*Ч*/ + + break; + } + if ((INVA_SECT_N_COND_SWIT_MIN_ID <= InvSecConfigDataStru[ii].InvSecAndConSwiId) && + ( INVA_SECT_N_COND_SWIT_SUM_MAX > InvSecConfigDataStru[ii].InvSecAndConSwiId)&& + (jj < INVA_SECT_N_COND_SWIT_SUM_MAX)) + { + IdToIndMap[jj] = InvSecConfigDataStru[ii].InvSecAndConSwiId; + jj ++; + } + + + } + retVal = CI_SUCCESS; + } + + return retVal; +} + + +/* +: +: +: +ֵ: [1, 65535] + 0u λȡʧ +*/ +UINT16 GetInvSecAndConSwiSum(void) +{ + UINT16 retVal = INVA_SECT_N_COND_SWIT_SUM_MAX; + + if ((INT16)INVA_SECT_N_COND_SWIT_SUM_MAX <= InvSecSum) + { + InvSecSum = (INT16)INVA_SECT_N_COND_SWIT_SUM_MAX; + } + else if(0 < InvSecSum) + { + retVal = 0u; + } + else + { + retVal = (UINT16)InvSecSum; + } + + return retVal; +} + +/* +: ID +: UINT16 invSecAndConSwiId μID +: +ֵ: [1, 65535]ID + 0u ȡʧ +*/ +UINT16 GetInvaSectId(UINT16 invSecAndConSwiId) +{ + UINT16 retVal = 0u; + UINT16 index = 0u; + + index = GetInvSecAndConSwiBufInd(invSecAndConSwiId); + + if(index < INVA_SECT_N_COND_SWIT_SUM_MAX) + { + retVal = InvSecConfigDataStru[index].InvaSectId; + } + + return retVal; +} + +/* +: +: UINT16 invSecAndConSwiId μID +: +ֵ: [1, 65535] + 0u ȡʧ +*/ +UINT16 GetInvaSectsCondSwitSum(UINT16 invSecAndConSwiId) +{ + UINT16 retVal = 0u; + UINT16 index = 0u; + + index = GetInvSecAndConSwiBufInd(invSecAndConSwiId); + + if(index < INVA_SECT_N_COND_SWIT_SUM_MAX) + { + retVal = InvSecConfigDataStru[index].CondSwitDataSum; + } + + return retVal; +} + +/* +: ָεָID +: UINT16 invSecAndConSwiId μID + INT16 ConSwiInd +: +ֵ: [1, 65535]ID + 0u ȡʧ +*/ +UINT16 GetInvaSectsCondSwitId(UINT16 invSecAndConSwiId, INT16 ConSwiInd) +{ + UINT16 retVal = 0u; + UINT16 index = 0u; + + index = GetInvSecAndConSwiBufInd(invSecAndConSwiId); + + if((index < INVA_SECT_N_COND_SWIT_SUM_MAX) && (ConSwiInd < (INT16)COND_SWITCH_SUM_MAX)) + { + retVal = InvSecConfigDataStru[index].CondSwitDataBuff[ConSwiInd].CondSwitId; + } + + return retVal; +} + +/* +: ָεָ״̬ +: UINT16 invSecAndConSwiId μID + INT16 ConSwiInd +: +ֵ: [1, 65535]״̬ + 0u ȡʧ +*/ +UINT16 GetInvaSectsCondSwitStat(UINT16 invSecAndConSwiId, INT16 ConSwiInd) +{ + UINT16 retVal = 0u; + UINT16 index = 0u; + + index = GetInvSecAndConSwiBufInd(invSecAndConSwiId); + + if((index < INVA_SECT_N_COND_SWIT_SUM_MAX) && (ConSwiInd < (INT16)COND_SWITCH_SUM_MAX)) + { + retVal = InvSecConfigDataStru[index].CondSwitDataBuff[ConSwiInd].CondSwitStat; + } + + return retVal; +} + +/* +* ȡ޵ +* ˵ void +* ֵ ޵ +*/ +InvSecConfigDataStruct* GetInvSecConfigData(void) +{ + return InvSecConfigDataStru; +} + diff --git a/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionConfigDataManage.h b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionConfigDataManage.h new file mode 100644 index 0000000..ea1f5d5 --- /dev/null +++ b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionConfigDataManage.h @@ -0,0 +1,118 @@ +/******************************************************** +* +* InvadeSectionConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2015-10-11 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ +#ifndef __INVADESECTION_CONFIG_DATA_MANAGE_H_ +#define __INVADESECTION_CONFIG_DATA_MANAGE_H_ + +#include "InvadeSectionDefine.h" +#include "../Route/RouteDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*ݽṹ*/ +typedef struct S_CondSwitDataStruct +{ + UINT16 CondSwitId; /*ID */ + UINT16 CondSwitStat; /*״̬*/ +}CondSwitDataStruct; + +/*μݽṹ*/ +typedef struct S_InvSecConfigDataStruct +{ + UINT16 InvSecAndConSwiId; /*ID*/ + UINT16 InvaSectId; /*ID (ֶ)*/ + UINT16 CondSwitDataSum; /**/ + CondSwitDataStruct CondSwitDataBuff[COND_SWITCH_SUM_MAX]; /**/ + UINT8 CondSwitLockDir; /**/ +}InvSecConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern InvSecConfigDataStruct InvSecConfigDataStru[INVA_SECT_N_COND_SWIT_SUM_MAX]; /*ݽṹ*/ + +extern INT16 InvSecSum; /**/ + +extern UINT16 IdToIndMap[INVA_SECT_N_COND_SWIT_SUM_MAX]; /*ӳ*/ + +/* +: μIDݵ +: +: +ֵ: CI_ERROR ʧ + CI_SUCCESS óɹ +*/ +UINT8 SetInvSecAndConSwiBufInd(void); + +/* +: +: +: +ֵ: [1, 65535] + 0 ȡʧ +*/ +UINT16 GetInvSecAndConSwiSum(void); + +/* +: ID +: INT16 InvSecInd +: +ֵ: [1, 65535]ID + 0 ȡʧ +*/ +UINT16 GetInvaSectId(UINT16 invSecAndConSwiId); + +/* +: +: UINT16 invSecAndConSwiId μID +: +ֵ: [1, 65535] + 0 ȡʧ +*/ +UINT16 GetInvaSectsCondSwitSum(UINT16 invSecAndConSwiId); + +/* +: ָεָID +: INT16 InvSecInd + INT16 ConSwiInd +: +ֵ: [1, 65535]ID + 0 ȡʧ +*/ +UINT16 GetInvaSectsCondSwitId(UINT16 invSecAndConSwiId, INT16 ConSwiInd); + +/* +: ָεָ״̬ +: INT16 InvSecInd + INT16 ConSwiInd +: +ֵ: [1, 65535]״̬ + 0 ȡʧ +*/ +UINT16 GetInvaSectsCondSwitStat(UINT16 invSecAndConSwiId, INT16 ConSwiInd); + +/* +* ȡ޵ +* ˵ void +* ֵ ޵ +*/ +InvSecConfigDataStruct* GetInvSecConfigData(void); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDataManage.c b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDataManage.c new file mode 100644 index 0000000..49bb871 --- /dev/null +++ b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDataManage.c @@ -0,0 +1,14 @@ +/******************************************************** +* +* InvadeSectionDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2015-10-11 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "InvadeSectionDataManage.h" + + diff --git a/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDataManage.h b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDataManage.h new file mode 100644 index 0000000..10867c2 --- /dev/null +++ b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDataManage.h @@ -0,0 +1,34 @@ +/******************************************************** +* +* InvadeSectionDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2015-12-11 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef __INVADESECTION_DATA_MANAGE_H_ +#define __INVADESECTION_DATA_MANAGE_H_ + +#include "InvadeSectionDefine.h" +#include "InvadeSectionDataManage.h" +#include "CommonTypes.h" +#include "../DataManage/DeviceDataManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDefine.h b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDefine.h new file mode 100644 index 0000000..71be56f --- /dev/null +++ b/TSCP/src/APP/ciapp/InvadeSection/InvadeSectionDefine.h @@ -0,0 +1,24 @@ +/******************************************************** +* +* InvadeSectionDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2015-12-11 +* ߣ +* ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef __INVADESECTION_DEFINE_H_ +#define __INVADESECTION_DEFINE_H_ + +#define INVA_SECT_N_COND_SWIT_SUM_MAX ((UINT16)300) /*Ŀ*/ + +#define COND_SWITCH_SUM_MAX ((UINT16)16) /*һĿ,*/ + +#define INVA_SECT_N_COND_SWIT_MIN_ID ((UINT16)1) /*ĿСID*/ + +#endif + diff --git a/TSCP/src/APP/ciapp/LogRecord/LogRecord.c b/TSCP/src/APP/ciapp/LogRecord/LogRecord.c new file mode 100644 index 0000000..c10e128 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogRecord/LogRecord.c @@ -0,0 +1,2915 @@ +/******************************************************** +* +* LogRecord.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2011-09-22 +* ߣ +* ݶȡ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#include "LogRecord.h" +#include "../ParsePack/ParsePackVobcData.h" +#include + + +UINT8 colString[RELAY_SUM_MAX] = {0u};/*ɼ*/ +UINT16 colStringLength = 0u; +UINT8 drvString[RELAY_SUM_MAX] = {0u};/**/ +UINT16 drvStringLength = 0u; +AxisSectionDataStruct Record_AxisSecDataStru[AXIS_SECTION_SUM_MAX];/*ο*/ +SignalDataStruct Record_SignalDataStru[SIGNAL_SUM_MAX];/*οźŻ̬*/ +EsbDataStruct Record_EsbDataStru[ESB_SUM_MAX]; /*οESB̬*/ +SwitchDataStruct Record_SwitchDataStru[SWITCH_SUM_MAX];/*ο̬*/ +PhysicalSectionDataStruct Record_PhysicalSectionDataStru[PHYSICAL_SECTION_SUM_MAX];/*οζ̬*/ +RouteDataStruct Record_RouteDataStru[ROUTE_SUM_MAX];/*ο·̬*/ +NonRouteDataStruct Record_NonRouteDataStru[NONROUTE_ID_NUM_MAX]; /*οǽ·̬*/ +LogicSectionDataStruct Record_LogicSecDataStru[LOGIC_SECTION_SUM_MAX];/*ο߼ζ̬*/ +WashMachineDataStruct Record_WashMachineDataStru[WASHMACHINE_SUM_MAX]; /*οϴ̬*/ +PsdDataStruct Record_PsdDataStru[PSD_SUM_MAX];/*οŶ̬*/ +GaragedoorDataStruct Record_GaragedoorDataStru[GARAGE_DOOR_SUM_MAX]; /*οݽṹ*/ +FloodGateDataStruct Record_FloodGateDataStru[FLOOD_GATE_SUM_MAX]; /**/ +OverlapDataStruct Record_OverlapDataStru[OVERLAP_SUM_MAX];/*οζ̬*/ +VirCIKeyDataStru Record_VirCIKeyDataStru[VIRTUAL_CI_MAX]= {0u};/*¼ؼ*/ +VirCIKeyDataStru newVirCIKeyDataStru[VIRTUAL_CI_MAX]= {0u}; +SpksDataStruct Record_spksDataBuff[SPKS_SUM_MAX] = { 0u }; +TrainInfoStru Record_TrainInfo[TRAIN_SUM_MAX] = { 0u }; +CfpDataStru Record_CfpInfo[CUTOFF_POINT_SUM_MAX] = { 0u }; +TsrDataStruct Record_TsrInfo[TSR_MAX_SUM] = { 0u }; /* οʱٶ̬ */ +OCStationIndicDataStru Record_OCStationIndicBuff[INDICATOR_SUM_MAX] = { 0u }; +LogicalRouteDataStruct Record_LogicalRouteDataStru[ROUTE_LOGICAL_SUM_MAX] = { 0U }; +NonAutoReturnDataStruct Record_NonReturnDataStru[NON_AUTO_RETURN_SUM_MAX] = { 0U }; + +UINT8 outString[1024*1024] = {0u};/*ȽϺ豸ӡݻ*/ +extern QueueStruct logPrintfQue; /*־ӡ*/ +UINT16 logIndex = 0u; /*־*/ + +#ifdef PLATFORM_LABVIEW_DEBUG + +WORD hour=0u;/*ȫֱжǷ񴴽ļ*/ +WORD day=0u;/*ȫֱжǷ񴴽ļ*/ +const signed char LogPath[10]= "C:\\CI_Log"; /*־ӡ洢Ŀ¼*/ +UINT8 str[50]=""; /*ļϲļ·*/ +UINT8 printFilePath[70]="";/*ļȫ·*/ + +/* +* ȡϵͳʱ +* ˵ UINT8 flag ѡʱʽ +* char *timeformat ʱṹ +* ֵ void +*/ +SYSTEMTIME getcurrentTime(UINT8 flag, UINT8 *timeformat) +{ + UINT8 outstr[128]; + UINT8 strr1[30]; + + SYSTEMTIME sys; + GetLocalTime(&sys); + + memset(outstr,0x0,sizeof(outstr)); + + if (flag==1) + { + sprintf(strr1,"%4d_",sys.wYear); + strcat(outstr,strr1); + sprintf(strr1,"%02d_",sys.wMonth); + strcat(outstr,strr1); + sprintf(strr1,"%02d",sys.wDay); + strcat(outstr,strr1); + } + else if (flag==2) + { + sprintf(strr1,"%02d_",sys.wHour); + strcat(outstr,strr1); + sprintf(strr1,"%02d_",sys.wMinute); + strcat(outstr,strr1); + sprintf(strr1,"%02d",sys.wSecond); + strcat(outstr,strr1); + } + else + { + sprintf(strr1,"%4d",sys.wYear); + strcat(outstr,strr1); + sprintf(strr1,"%02d",sys.wMonth); + strcat(outstr,strr1); + sprintf(strr1,"%02d ",sys.wDay); + strcat(outstr,strr1); + sprintf(strr1,"%02d:",sys.wHour); + strcat(outstr,strr1); + sprintf(strr1,"%02d:",sys.wMinute); + strcat(outstr,strr1); + sprintf(strr1,"%02d:",sys.wSecond); + strcat(outstr,strr1); + sprintf(strr1,"%02d",sys.wMilliseconds); + strcat(outstr,strr1); + } + strcpy(timeformat,outstr); + return sys; +} + +/* +* ´ӡļ· +* ˵ void +* ֵ 0: ·ʧ +* 1: ·ɹ +*/ +UINT8 UpdatePrintFilePath(void) +{ + UINT8 timeformat[30];/*ϵͳʱϢ*/ + SYSTEMTIME currentTimeStruct;/*ǰʱ*/ + UINT8 ciIdChar[6];/*IDתַ*/ + + if (_access(LogPath,0)==-1)/*жstrָʾļǷڣ-1Ϊ*/ + { + mkdir(LogPath); + } + currentTimeStruct = getcurrentTime(3,timeformat);/*ɵǰʱṹ*/ + if (day!=currentTimeStruct.wDay)/*ǰʱṹȫֱ첻ͬȫֱΪգÿһļ*/ + { + /*λλ·*/ + strcpy(str,LogPath); + strcat(str, "\\"); + getcurrentTime(1,timeformat); + strcat(str,timeformat); + + if (_access(str,0)==-1) + { + mkdir(str); + } + + /*ģʽΪλ(C||SCADE)·*/ + strcat(str, "\\"); + #ifdef SCADE_MODE + strcat(str, "SCADE_MODE"); + #else + strcat(str, "C_MODE"); + #endif + + if (_access(str,0)==-1) + { + mkdir(str); + } + + /*վΪλ·*/ + strcat(str,"\\"); + sprintf(ciIdChar, "CI_%d", GetSystemParaLocalCiId()); + strcat(str, ciIdChar); + + if (_access(str,0)==-1) + { + mkdir(str); + } + day=currentTimeStruct.wDay; + } + if (hour!=currentTimeStruct.wHour)/*ÿСʱһļ*/ + { + memset(printFilePath,0,70); + strcpy(printFilePath,str); + getcurrentTime(2,timeformat); + strcat(printFilePath,"\\"); + strcat(printFilePath,timeformat); + strcat(printFilePath,".txt"); + hour=currentTimeStruct.wHour; + } + else if (hour==currentTimeStruct.wHour) + { + + } + else + { + memset(printFilePath,0,70); + return CI_ERROR; + } + + return CI_SUCCESS; +} + +/* +* ȡļ· +* ˵ void +* ֵ NULL: ȡļ·ʧ +* NULL: ȡļ·ɹ +*/ +UINT8* GetFileString(void) +{ + if (strlen(printFilePath) == 0) + { + return NULL; + } + else + { + return printFilePath; + } +} + +/* +* ӡݶк ƽ̨ӡһ +* ˵ const UINT8 printMode, ӡģʽ:10ʮ,16ʮ,8˽,2,0ַ +* UINT8 printData[], ӡݶ +* UINT32 printDataLen, ӡݳȻ׼ĸʽֵ +* ֵ 0:ӡʧ +* 1:ӡɹ +*/ +UINT8 Out_Array_Buffer(const UINT8 printMode, UINT8 printData[], UINT32 printDataLen) +{ + FILE *fp = NULL; + UINT16 ii = 0; + UINT16 jj = 0; + UINT16 insertIndex = printDataLen; + UINT8 pData[RECORD_BUF_MAX] = {0}; + UINT8 tailD[RECORD_BUF_MAX] = {0}; + UINT8 decimal[10] = {0}; + + if (printDataLen > RECORD_BUF_MAX) + {/*ӡݳȹ*/ + + return CI_ERROR; + } + else + {/*ӡݺ*/ + + if (printFilePath == NULL) + {/*ӡ·*/ + + return CI_ERROR; + + } + else + { + if ((fp = fopen(printFilePath,"a")) == NULL) + {/*ļʧ*/ + + return CI_ERROR; + } + else + { + switch (printMode) + { + case 2:/*ƴӡ*/ + for (ii = 0; ii < printDataLen; ii++) + { + if (ii == 0) + { + fprintf(fp,"%08b",printData[ii]); + } + else + { + fprintf(fp,"-%08b",printData[ii]); + } + } + break; + case 8:/*˽ƴӡ*/ + for (ii = 0; ii < printDataLen; ii++) + { + if (ii == 0) + { + fprintf(fp,"%03o",printData[ii]); + } + else + { + fprintf(fp,"-%03o",printData[ii]); + } + } + break; + case 10:/*ʮƴӡ*/ + for (ii = 0; ii < printDataLen; ii++) + { + if (ii == 0) + { + fprintf(fp,"%d",printData[ii]); + } + else + { + fprintf(fp,"-%d",printData[ii]); + } + } + break; + case 16:/*ʮƴӡ*/ + for (ii = 0; ii < printDataLen; ii++) + { + if (ii == 0) + { + fprintf(fp,"%02x",printData[ii]); + } + else + { + fprintf(fp,"-%02x",printData[ii]); + } + } + break; + case 0:/*0Ĭϴӡַ*/ + memset(pData,0,RECORD_BUF_MAX); + memset(tailD,0,RECORD_BUF_MAX); + memcpy(pData,printData,strlen(printData)); + + /*ҵһ%d||%xλ*/ + for (ii = 0; ii < strlen(printData); ii++) + { + if ((pData[ii] == '%') + && (ii+1 < (UINT16)strlen(printData))) + { + if (pData[ii+1] == 'd') + { + insertIndex = ii; + ltoa(printDataLen,decimal,10); + break; + } + else if (pData[ii+1] == 'x') + { + insertIndex = ii; + ltoa(printDataLen,decimal,16); + break; + } + else + { + } + + } + } + + if ((insertIndex < strlen(printData)) && (strlen(decimal) > 0)) + {/*ڽת*/ + + memcpy(tailD,&pData[insertIndex+2],strlen(printData)-insertIndex-2); + memcpy(&pData[insertIndex],decimal,strlen(decimal)); + insertIndex+=strlen(decimal); + memcpy(&pData[insertIndex],tailD,strlen(tailD)); + } + else + { + + } + fprintf(fp,"%s",pData); + + break; + default:/*ӡǷ*/ + fprintf(fp,"ERROR:printMode error %d\n",printMode); + return CI_ERROR; + break; + } + } + + fprintf(fp,"\n"); + fclose(fp); + } + + + return CI_SUCCESS; + } +} + +#endif + +/* +* ̵ɼݴӡӿں +* ˵ UINT8* thisString, +* ֵ 0: ӡʧ +* 1: ӡɹ +*/ + +UINT8 RecordCollectDataLog(UINT8* thisString) +{ + UINT8 returnValue = CI_SUCCESS; + UINT8 chFunRtn = 0u; + + chFunRtn = RelayComPare(colString, thisString, 0u); + + if (0u != chFunRtn) + {/*б仯*/ + returnValue = 1u; + +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nRelayCollectData:%d",colStringLength); + debug_out_array(0xAA, colString, colStringLength); + +#endif +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0, "\nRelayCollectData:%d",colStringLength); + Out_Array_Buffer(16,colString,colStringLength); +#endif + + } + else + { + returnValue = CI_SUCCESS; + } + + return returnValue; +} + +/* +* ̵ݴӡӿں +* ˵ UINT8* thisString, +* ֵ 0: ӡʧ +* 1: ӡɹ +*/ + +UINT8 RecordDriverDataLog(UINT8* thisString) +{ + UINT8 returnValue = CI_SUCCESS; + UINT8 chFunRtn = 0u; + + chFunRtn = RelayComPare(drvString, thisString, 4u); + + if (0u != chFunRtn) + {/*Աб仯*/ +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nRelayDriveData:%d",drvStringLength); + debug_out_array(0xAA, drvString, drvStringLength); + +#endif +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0, "\nRelayDriveData:%d",drvStringLength); + Out_Array_Buffer(16,drvString,drvStringLength); + +#endif + } + else + { + returnValue = CI_SUCCESS; + } + + + return returnValue; +} + +/* +* 豸״̬ݴӡӿں +* ˵ UINT8 Flag, ӡ־ +* ֵ 0: ӡʧ +* 1: ӡɹ +*/ + +UINT8 RecordDeviceDataLog(UINT8 Flag) +{ + + UINT16 outStringLength = 0u; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 kk = 0U; + UINT16 deviceId = 0u; + UINT16 wTrainId = 0u; + UINT8 returnValue = CI_SUCCESS;/*ֵ*/ + UINT8 comparaResult = 0u;/*ȽϽ*/ + UINT16 floodGateTotalSum = 0u;/**/ + AxisSectionDataStruct* newAxisSecData = GetAxisSecData(); + SignalDataStruct* newSignalData = GetSignalData(); + SwitchDataStruct* newSwitchData = GetSwitchData(); + PhysicalSectionDataStruct* newPhysicalSectionData = GetPhySecData(); + RouteDataStruct* newRouteData = GetRouteData(); + NonRouteDataStruct* newNonRouteDataStru = GetNonRouteDataPtr(); + LogicSectionDataStruct* newLogicSecData = GetLogicSecData(); + WashMachineDataStruct* newWashMachineData = GetWashMachineData(); + PsdDataStruct * newPsdData = GetPsdData(); + GaragedoorDataStruct* newGaragedoorData = GetGaragedoorData(); /*ȡݽṹ*/ + FloodGateDataStruct *pNewFloodGateData = GetFloodGateData(); /*ȡݽṹ*/ + OverlapDataStruct* newOverlapData = GetOverlapData(); + TrainInfoStru* pNewTrainInfoData = GetTrainInfoData(); + TsrDataStruct* pNewTsrInfo = GetTsrData(); /* ʱϢ */ + CfpDataStru * pNewCfpData = GetCfpData(); + SpksDataStruct* pNewSpksData = GetSpksData(); + OCStationIndicDataStru* pNewOCStationIndicData = GetOCStationIndicDataStru(); + EsbDataStruct* pNewEsbData = GetEsbData(); + LogicalRouteDataStruct* pNewLogicalRouteDataStru = GetLogicalRouteStr(); + UINT16 wCfpId = 0u; + UINT8 chEnIndex = 0u; + UINT8 chTrainIndex = 0u; + UINT16 deviceNum = 0u; + UINT8 localCiType = 0u; + UINT16 wNonAutoReturnCurSum = 0U;/*۷ťǰ*/ + NonAutoReturnDataStruct* pNonAutoReturnData = NULL;/*۷ݽṹָ*/ + + + /*************************************ӡ********************************************/ + /*ӡ*/ + deviceNum = GetTotalPhySecCurNum(); + for (ii = 0u; ii < deviceNum; ii++)/*͸Ŀ*/ + { + + /*Ƚ*/ + deviceId = GetPhySecId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_PhysicalSectionDataStru[deviceId]), (UINT16)sizeof(PhysicalSectionDataStruct), + (UINT8*)(&newPhysicalSectionData[deviceId]), (UINT16)sizeof(PhysicalSectionDataStruct)); + + + if(0u != comparaResult) + {/*Ƚݲһ*/ + + if (CI_ERROR != Flag) + { + /**************ӡϢ****************/ + + ShortToChar(newPhysicalSectionData[deviceId].PhysicalSectionId,&outString[outStringLength]);/*ID*/ + outStringLength += 2u; + outString[outStringLength++] = newPhysicalSectionData[deviceId].SecUseState;/*״̬*/ + ShortToChar(newPhysicalSectionData[deviceId].SecUseBelongRouteId,&outString[outStringLength]);/*·ID*/ + outStringLength += 2u; + ShortToChar(newPhysicalSectionData[deviceId].SecProUseBelongRouteId, &outString[outStringLength]);/*·ID*/ + outStringLength += 2u; + outString[outStringLength++] = newPhysicalSectionData[deviceId].LockState;/*״̬*/ + ShortToChar(newPhysicalSectionData[deviceId].RLockBelongRouteId,&outString[outStringLength]);/*·ID*/ + outStringLength += 2u; + ShortToChar(newPhysicalSectionData[deviceId].PLockBelongRouteId,&outString[outStringLength]);/*·ID*/ + outStringLength += 2u; + outString[outStringLength++] = newPhysicalSectionData[deviceId].LockDirection;/*շ*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].FLockState;/*״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].PreOccupyState;/*֮ǰɼ״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].CurOccupyState;/*ǰɼ״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].PreMergeOccupyState;/*֮ǰںռ״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].CurMergeOccupyState;/*ǰںռ״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].PreAndMergeOccupyState;/*֮ǰռںռ״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].CurAndMergeOccupyState;/*ǰռںռ״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].StopSteadyFlag;/*ͣ״̬Ϣ*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].ArbState;/*ARB״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].ProtectSecLockDelayTimeFlag;/*ʱ־(ֶ̬)*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].StopCheckFlag; /*ֹͣ־(δ/) (ֶ̬)*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].JumpLockState; /*Ծ״̬ (ֶ̬)*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].JumpLockDelayUnlockFlag; /*Ծʱñ־(ֶ̬)*/ + LongToChar(newPhysicalSectionData[deviceId].SecJumpDelayUnlockStartCycNum,&outString[outStringLength]);/*Ծʱʼ (ֶ̬)*/ + outStringLength += 4u; + LongToChar(newPhysicalSectionData[deviceId].SecColOccupyStartCycNum, &outString[outStringLength]);/*βɼռÿʼ*/ + outStringLength += 4u; + LongToChar(newPhysicalSectionData[deviceId].SecCurOccupyStartCycNum,&outString[outStringLength]);/*εǰռÿʼ*/ + outStringLength += 4u; + LongToChar(newPhysicalSectionData[deviceId].SecOccuToClearStartCycNum,&outString[outStringLength]);/*ռñпʼ*/ + outStringLength += 4u; + LongToChar(newPhysicalSectionData[deviceId].AutoUnlockStartCycNum,&outString[outStringLength]);/*Զʱʼ*/ + outStringLength += 4u; + LongToChar(newPhysicalSectionData[deviceId].FaultUnlockStartCycNum,&outString[outStringLength]);/*ʽʱʼ*/ + outStringLength += 4u; + LongToChar(newPhysicalSectionData[deviceId].SectionResetStartCycNum,&outString[outStringLength]);/*μḴλʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newPhysicalSectionData[deviceId].FLockType; /*ηԭ,SPKSԭ*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].UtOrCtOccFlag; /*ȡռñ־*/ + ShortToChar(newPhysicalSectionData[deviceId].SecProUseBelongRouteId,&outString[outStringLength]);/*·ID*/ + outStringLength += 2u; + ShortToChar(newPhysicalSectionData[deviceId].wPhyErrUnlockTime, &outString[outStringLength]);/*ʽʱʱ*/ + outStringLength += 2u; + outString[outStringLength++] = newPhysicalSectionData[deviceId].cAreaUrgentBrakeState; /*ƶ״̬*/ + ShortToChar(newPhysicalSectionData[deviceId].StopSteadyTrainId, &outString[outStringLength]);/*ͣȹгID*/ + outStringLength += 2u; + outString[outStringLength++] = newPhysicalSectionData[deviceId].chABLTrainFlag; /*ABLгռ״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].chPreABLTrainFlag; /*֮ǰABLгռ״̬*/ + outString[outStringLength++] = newPhysicalSectionData[deviceId].cPhySecInHumidRailFlag; /*ʪ־0x55 Ч0xAA Ч*/ + } + } + } + + if (0u == outStringLength) + { + } + else + { + #ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nPhySectionData:%d\nPhysicalSectionId(2)-SecUseState-SecUseBelongRouteId(2)-LockState-RLockBelongRouteId(2)-PLockBelongRouteId(2)-LockDirection-FLockState-PreOccupyState-CurOccupyState-PreMergeOccupyState-CurMergeOccupyState-PreAndMergeOccupyState-CurAndMergeOccupyState-StopSteadyFlag-ArbState-ProtectSecLockDelayTimeFlag-StopCheckFlag-JumpLockState-JumpLockDelayUnlockFlag-SecJumpDelayUnlockStartCycNum(4)-SecCurOccupyStartCycNum(4)-SecOccuToClearStartCycNum(4)-AutoUnlockStartCycNum(4)-FaultUnlockStartCycNum(4)-SectionResetStartCycNum(4)-FLockType:%d",(UINT16)sizeof(PhysicalSectionDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + + #endif + + + #ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0,"\nPhySectionData:%d",(UINT16)sizeof(PhysicalSectionDataStruct)); + Out_Array_Buffer(0,"PhysicalSectionId(2)-SecUseState-SecUseBelongRouteId(2)-LockState-RLockBelongRouteId(2)-PLockBelongRouteId(2)-LockDirection-FLockState-PreOccupyState-CurOccupyState-PreMergeOccupyState-CurMergeOccupyState-StopSteadyFlag-SecCurOccupyStartCycNum(4)-SecOccuToClearStartCycNum(4)-AutoUnlockStartCycNum(4)-FaultUnlockStartCycNum(4)-SectionResetStartCycNum(4):%d",outStringLength); + Out_Array_Buffer(16,outString,outStringLength); + + #endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + + /*************************************ӡźŻ********************************************/ + /*ӡźŻ*/ + deviceNum = GetTotalSignalCurNum(); + for (ii = 0u; ii < deviceNum; ii++)/*͸źŻĿ*/ + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetSignalId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_SignalDataStru[deviceId]), (UINT16)sizeof(SignalDataStruct), + (UINT8*)(&newSignalData[deviceId]), (UINT16)sizeof(SignalDataStruct)); + + if (0u==comparaResult) + {/*Ƚһ*/ + + } + else if (1u==comparaResult ) + {/*Ƚݲһ*/ + + if (CI_ERROR != Flag) + { + /**************ӡϢ****************/ + + ShortToChar(newSignalData[deviceId].SignalId,&outString[outStringLength]);/*źŻID*/ + outStringLength += 2u; + outString[outStringLength++] = newSignalData[deviceId].FLockState;/*״̬*/ + outString[outStringLength++] = newSignalData[deviceId].LightExtinctState;/*״̬*/ + outString[outStringLength++] = newSignalData[deviceId].PreColor;/*֮ǰʾɫ*/ + outString[outStringLength++] = newSignalData[deviceId].CurColor;/*ǰʾɫ*/ + outString[outStringLength++] = newSignalData[deviceId].PreDriveColor;/*֮ǰɫ*/ + outString[outStringLength++] = newSignalData[deviceId].CurDriveColor;/*ǰɫ*/ + outString[outStringLength++] = newSignalData[deviceId].DsBreakFlag;/*˿˿־״̬*/ + LongToChar(newSignalData[deviceId].DriveSigOpenStartCycNum,&outString[outStringLength]);/*źŻʼ*/ + outStringLength += 4u; + LongToChar(newSignalData[deviceId].DriveSigCloseStartCycNum,&outString[outStringLength]);/*źŻرʼ*/ + outStringLength += 4u; + LongToChar(newSignalData[deviceId].CollSigOpenStartCycNum,&outString[outStringLength]); /*ɼźŻʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newSignalData[deviceId].SignalCrossState;/*źŻѹ״̬*/ + outString[outStringLength++] = newSignalData[deviceId].SignalYLockOpenState;/*źſ״̬*/ + outString[outStringLength++] = newSignalData[deviceId].AtsDetainFlag;/*Ats˹۳־*/ + outString[outStringLength++] = newSignalData[deviceId].AtsDetainFlagAuto;/*AtsԶ۳־*/ + outString[outStringLength++] = newSignalData[deviceId].XiandiDetainFlag;/*ֵؿ۳־*/ + LongToChar(newSignalData[deviceId].RelayActaionStartCycNum,&outString[outStringLength]);/*źŻ̵ʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newSignalData[deviceId].PLockCommand;/*ͨ*/ + outString[outStringLength++] = newSignalData[deviceId].ProSecValid;/*ͨЧ*/ + outString[outStringLength++] = newSignalData[deviceId].OldDriveColor;/*źŻɫ仯֮ǰ,źŻʾɫ (ֶ̬) */ + LongToChar(newSignalData[deviceId].DriveNewSigStartCycNum, &outString[outStringLength]);/*źŻʾɫʼ*/ + outStringLength += 4u; + LongToChar(newSignalData[deviceId].SignalLightOnStateCycCount, &outString[outStringLength]); /*źŻյǿƵǿ״ֵ̬*/ + outStringLength += 4u; + outString[outStringLength++] = newSignalData[deviceId].RealyDetainFlag;/*Ӳ߿۳־*/ + outString[outStringLength++] = newSignalData[deviceId].RelayDetainCmd;/*Ӳ߿۳־*/ + outString[outStringLength++] = newSignalData[deviceId].NeighbourSignalDetainDrive; /*վźŻ۳*/ + outString[outStringLength++] = newSignalData[deviceId].GreenDsBreakFlag;/*̵˿˿־״̬*/ + outString[outStringLength++] = newSignalData[deviceId].YellowDsBreakFlag;/*Ƶ˿˿־״̬*/ + outString[outStringLength++] = newSignalData[deviceId].WhiteDsBreakFlag;/*׵˿˿־״̬*/ + outString[outStringLength++] = newSignalData[deviceId].RedYellowDsBreakFlag;/*Ƶ˿˿־״̬*/ + outString[outStringLength++] = newSignalData[deviceId].RedWhiteDsBreakFlag;/*׵˿˿־״̬*/ + outString[outStringLength++] = newSignalData[deviceId].GreenYellowDsBreakFlag;/*̻Ƶ˿˿־״̬*/ + outString[outStringLength++] = newSignalData[deviceId].DoubleGreenDsBreakFlag;/*˫̵˿˿־״̬*/ + outString[outStringLength++] = newSignalData[deviceId].DoubleYellowDsBreakFlag;/*˫Ƶ˿˿־״̬*/ + outString[outStringLength++] = newSignalData[deviceId].MaintainLightState;/*źŻά޵״̬*/ + + if (MAX_SIGNAL_LIGHTUPLINK_NUM < newSignalData[deviceId].wSignalLightUpLinkIdSum) + { + /* Ϸ */ + ShortToChar(0u, &outString[outStringLength]);/*źŻlink*/ + outStringLength += 2u; + } + else + { + /* Ϸ */ + ShortToChar(newSignalData[deviceId].wSignalLightUpLinkIdSum, &outString[outStringLength]);/*źŻlink*/ + outStringLength += 2u; + + for (jj = 0u; jj < newSignalData[deviceId].wSignalLightUpLinkIdSum; jj++) + { + ShortToChar(newSignalData[deviceId].szSignalLightUpLinkIdBuf[jj], &outString[outStringLength]);/*źŻlink*/ + outStringLength += 2u; + } + } + + outString[outStringLength++] = newSignalData[deviceId].DetainBtnActivateFlag; /*۳ť־*/ + outString[outStringLength++] = newSignalData[deviceId].DetainBtnErrFlag; /*۳ťϱ־*/ + outString[outStringLength++] = newSignalData[deviceId].CancelDetainBtnErrFlag; /*ȡ۳ťϱ־*/ + outString[outStringLength++] = newSignalData[deviceId].CancelDetainBtnValidFlag; /*ȡ۳ťЧ־*/ + outString[outStringLength++] = newSignalData[deviceId].CancelDetainRelayDownState; /*ȡ۳ťɼ̵״̬*/ + LongToChar(newSignalData[deviceId].DetainBtnPressCycNum, &outString[outStringLength]); /*۳ť*/ + outStringLength += 4u; + LongToChar(newSignalData[deviceId].CancelDetainBtnPressCycNum, &outString[outStringLength]); /*ȡ۳ť*/ + outStringLength += 4u; + LongToChar(newSignalData[deviceId].CancelDetainErrTrigPressCycNum, &outString[outStringLength]); /*ȡ۳ť󴥷*/ + outStringLength += 4u; + ShortToChar(newSignalData[deviceId].wSignalLightUpTrainId, &outString[outStringLength]);/*źŻνӽгID*/ + outStringLength += 2u; + outString[outStringLength++] = newSignalData[deviceId].cSleepTrainLightUpFlag; /*߳źŻ־0x55 Ч0xAA Ч*/ + outString[outStringLength++] = newSignalData[deviceId].cInHumidRailFlag; /*źŻʪ־0x55 Ч0xAA Ч*/ + } + } + else + { + returnValue = CI_ERROR; + } + } + + if (0u == outStringLength) + { + } + else + { + #ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nSignalData:%d\nSignalId(2)-FLockState-LightExtinctState-PreColor-CurColor-PreDriveColor-CurDriveColor-DsBreakFlag-DriveSigOpenStartCycNum(4)-DriveSigCloseStartCycNum(4)-CollSigOpenStartCycNum(4)-SignalCrossState-SignalYLockOpenState-AtsDetainFlag-XiandiDetainFlag-RelayActaionStartCycNum(4)-PLockCommand-ProSecValid-OldDriveColor-DriveNewSigStartCycNum(4)-SignalLightOnStateCycCount(4):%d",(UINT16)sizeof(SignalDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + #endif + + #ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0,"\nSignalData:%d",(UINT16)sizeof(SignalDataStruct)); + Out_Array_Buffer(0,"SignalId(2)-FLockState-LightExtinctState-PreColor-CurColor-PreDriveColor-CurDriveColor-DsBreakFlag-DriveSigOpenStartCycNum(4)-DriveSigCloseStartCycNum(4)-CollSigOpenStartCycNum(4)-SignalCrossState-SignalYLockOpenState-AtsDetainFlag-XiandiDetainFlag:%d",outStringLength); + Out_Array_Buffer(16,outString,outStringLength); + + #endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + /*************************************ӡESB********************************************/ + /*ӡESB*/ + deviceNum = GetTotalEsbCurNum(); + for (ii = 0u; ii < deviceNum; ii++)/*͸ESBĿ*/ + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetEsbId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_EsbDataStru[deviceId]), (UINT16)sizeof(EsbDataStruct), + (UINT8*)(&pNewEsbData[deviceId]), (UINT16)sizeof(EsbDataStruct)); + + if (0u == comparaResult) + {/*Ƚһ*/ + + } + else if (1u == comparaResult) + {/*Ƚݲһ*/ + + if (CI_ERROR != Flag) + { + /**************ӡϢ****************/ + + ShortToChar(pNewEsbData[deviceId].EsbId, &outString[outStringLength]);/*ESBID*/ + outStringLength += 2u; + outString[outStringLength++] = pNewEsbData[deviceId].EsbState;/*ͣť״̬ (ֶ̬)-ESSPEPں״̬*/ + outString[outStringLength++] = pNewEsbData[deviceId].EssState;/*Essť״̬ (ֶ̬)--Բž߱*/ + outString[outStringLength++] = pNewEsbData[deviceId].EsbActualState;/*ESBͣť״̬--ATŞ/״̬Բž߱*/ + outString[outStringLength++] = pNewEsbData[deviceId].CutStatus;/*ͣť·״̬*/ + outString[outStringLength++] = pNewEsbData[deviceId].EsbRelateRelayDriveState;/*ͣơȵƺͷ̵״̬*/ + outString[outStringLength++] = pNewEsbData[deviceId].EssSteadyState;/*ESSȵ״̬ATS--0x55 Ҫȵƣ0xaaҪȵ*/ + outString[outStringLength++] = pNewEsbData[deviceId].EssFlashState;/*ESS״̬ATS--0x55 Ҫƣ0xaaҪ*/ + outString[outStringLength++] = pNewEsbData[deviceId].EsbErrorFlag;/*Ըʽͣťϱ־0x55δϣ0xaa*/ + outString[outStringLength++] = pNewEsbData[deviceId].CancelEsbErrorFlag;/*Ըʽȡͣťϱ־0x55δϣ0xaa*/ + outString[outStringLength++] = pNewEsbData[deviceId].CancelEsbValidFlag;/*ȡرհťЧ־0x55Ч0xaaЧ*/ + outString[outStringLength++] = pNewEsbData[deviceId].CancelEsbRelayDownState;/*ȡرհťɼ̵״̬0x55ɼ£0xaaͨ쳣*/ + LongToChar(pNewEsbData[deviceId].EsbPressCycNum, &outString[outStringLength]);/*رհť*/ + outStringLength += 4u; + LongToChar(pNewEsbData[deviceId].CancelEsbPressCycNum, &outString[outStringLength]);/*ȡرհť*/ + outStringLength += 4u; + LongToChar(pNewEsbData[deviceId].CancelEsbErrTriggerPressCycNum, &outString[outStringLength]);/*ȡرհť󴥷*/ + outStringLength += 4U; + } + } + else + { + returnValue = CI_ERROR; + } + } + + if (0u == outStringLength) + { + } + else + { +#ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nEsbData:%d\nEsbId(2)-EsbState-EssState-EsbActualState-CutStatus-EsbRelateRelayDriveState-EssSteadyState-EssFlashState-CancelEsbErrorFlag-CancelEsbValidFlag-EsbPressCycNum(4)-CancelEsbPressCycNum(4):%d", (UINT16)sizeof(SignalDataStruct), outStringLength); + + debug_out_array(0xAA, outString, outStringLength); +#endif + +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0, "\nSignalData:%d", (UINT16)sizeof(SignalDataStruct)); + Out_Array_Buffer(0, "SignalId(2)-FLockState-LightExtinctState-PreColor-CurColor-PreDriveColor-CurDriveColor-DsBreakFlag-DriveSigOpenStartCycNum(4)-DriveSigCloseStartCycNum(4)-CollSigOpenStartCycNum(4)-SignalCrossState-SignalYLockOpenState-AtsDetainFlag-XiandiDetainFlag:%d", outStringLength); + Out_Array_Buffer(16, outString, outStringLength); + +#endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + + /*************************************ӡ********************************************/ + /*ӡ*/ + deviceNum = GetTotalSwitchCurNum(); + for (ii = 0u; ii < deviceNum; ii++)/*͸ĵĿ*/ + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetSwitchId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_SwitchDataStru[deviceId]), (UINT16)sizeof(SwitchDataStruct), + (UINT8*)(&newSwitchData[deviceId]), (UINT16)sizeof(SwitchDataStruct)); + + if (0u==comparaResult) + {/*Ƚһ*/ + + } + else if (1u==comparaResult ) + {/*Ƚݲһ*/ + + if (CI_ERROR != Flag) + { + /**************ӡϢ****************/ + + ShortToChar(newSwitchData[deviceId].SwitchId,&outString[outStringLength]);/*ID*/ + outStringLength += 2u; + outString[outStringLength++] = newSwitchData[deviceId].YLockState;/*״̬*/ + outString[outStringLength++] = newSwitchData[deviceId].LockStatus;/*״̬*/ + outString[outStringLength++] = newSwitchData[deviceId].FLockState;/*״̬*/ + outString[outStringLength++] = newSwitchData[deviceId].SwitchPrePosition;/*֮ǰλ*/ + outString[outStringLength++] = newSwitchData[deviceId].SwitchCurPosition;/*ǰλ*/ + outString[outStringLength++] = newSwitchData[deviceId].SingleSwitchCurPosition;/*ǰλ*/ + outString[outStringLength++] = newSwitchData[deviceId].SwitchDrivePos;/*λ*/ + outString[outStringLength++] = newSwitchData[deviceId].SwitchDanCaoPostition;/*λ*/ + LongToChar(newSwitchData[deviceId].SwitMoveStartCycNum,&outString[outStringLength]);/*ʼں*/ + outStringLength += 4u; + LongToChar(newSwitchData[deviceId].SwitDriveStartCycNum,&outString[outStringLength]);/*ʼں*/ + outStringLength += 4u; + outString[outStringLength++] = newSwitchData[deviceId].chSwitchDrivedFlag;/*־*/ + outString[outStringLength++] = newSwitchData[deviceId].SwitchExpDrvPos;/*λ*/ + outString[outStringLength++] = newSwitchData[deviceId].switchPreExpDrvPos;/*֮ǰλ*/ + outString[outStringLength++] = newSwitchData[deviceId].switchDrivingState;/*״̬*/ + outString[outStringLength++] = newSwitchData[deviceId].switchDrivOvtmDrvPos;/*ʱλ*/ + /* zt ɾش 2022-02-15 */ + outString[outStringLength++] = newSwitchData[deviceId].switchLastValidDrvPos;/*Ч״̬*/ + LongToChar(newSwitchData[deviceId].switchLastValidDrvPosCycleNum,&outString[outStringLength]);/*Ч״̬ʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newSwitchData[deviceId].cSwitchUsingState; /*״̬0x11δã0x22ã0x44ã0x88ȡ*/ + ShortToChar(newSwitchData[deviceId].UsingBelongOverlapId,&outString[outStringLength]);/*øõıID*/ + outStringLength += 2u; + outString[outStringLength++] = newSwitchData[deviceId].PLockedRouteNum;/*յĽ·ID*/ + for (jj=0;jj= newRouteData[deviceId].chResReqTrainSum) + { + outString[outStringLength++] = newRouteData[deviceId].chResReqTrainSum; /*ԴID*/ + for (jj = 0u; jj < newRouteData[deviceId].chResReqTrainSum; jj++) + { + ShortToChar(newRouteData[deviceId].wszResReqTrainId[jj], &outString[outStringLength]);/*ԴгID*/ + outStringLength += 2u; + } + } + else + { + outString[outStringLength++] = 0u; /*ԴID*/ + } + + if (ROUTE_APPLY_RECD_TRAIN_SUM_MAX >= newRouteData[deviceId].ITSRouteApplyTrainIdSum) + { + outString[outStringLength++] = newRouteData[deviceId].ITSRouteApplyTrainIdSum; /*ITS·гID¼*/ + + for (jj = 0u; jj < newRouteData[deviceId].ITSRouteApplyTrainIdSum; jj++) + { + ShortToChar(newRouteData[deviceId].ITSRouteApplyTrainIdBuf[jj], &outString[outStringLength]);/*ͨITS·¼гID*/ + outStringLength += 2u; + } + + } + else + { + outString[outStringLength++] = 0u; + } + + /*ɶ־*/ + outString[outStringLength++] = newRouteData[deviceId].HalfRouteDataSt.HalfRouteSwitchMoveValid; + + if (MAX_ROUTE_IN_LT_NUM > newRouteData[deviceId].HalfRouteDataSt.RouteLockLgcSecNum) + { + /*߼*/ + outString[outStringLength++] = newRouteData[deviceId].HalfRouteDataSt.RouteLockLgcSecNum; + /*߼ID*/ + for (jj = 0u; jj < newRouteData[deviceId].HalfRouteDataSt.RouteLockLgcSecNum; jj++) + { + ShortToChar(newRouteData[deviceId].HalfRouteDataSt.RouteLockLgcSecIdBuf[jj], &outString[outStringLength]);/*ͨITS·¼гID*/ + outStringLength += 2u; + } + + } + else + { + outString[outStringLength++] = 0u; + } + /*гID*/ + ShortToChar(newRouteData[deviceId].HalfRouteDataSt.HalfResReqTrainId, &outString[outStringLength]);/*ͨITS·¼гID*/ + outStringLength += 2u; + + if (ROUTE_TRAIN_LOC_MAX_LGC_SUM >= newRouteData[deviceId].HalfRouteDataSt.TrainLocLgcSecNum) + { + /*гԴ*/ + outString[outStringLength++] = newRouteData[deviceId].HalfRouteDataSt.TrainLocLgcSecNum; + + for (jj = 0u; jj < newRouteData[deviceId].HalfRouteDataSt.TrainLocLgcSecNum; jj++) + { + /*гԴ߼ID*/ + ShortToChar(newRouteData[deviceId].HalfRouteDataSt.TrainLocLgcSecIdBuf[jj], &outString[outStringLength]);/*ͨITS·¼гID*/ + outStringLength += 2u; + } + + } + else + { + outString[outStringLength++] = 0u; + } + LongToChar(newRouteData[deviceId].dwFirstElockStartCycNum, &outString[outStringLength]); /*·һյ߼ʱιʼں*/ + outStringLength += 4u; + + outString[outStringLength++] = newRouteData[deviceId].cRelZuHeRouteSGBJDelayFlag; /*Ͻ·ⱨǷʱ־*/ + + LongToChar(newRouteData[deviceId].dwDelayOpenStartCycNum, &outString[outStringLength]); /*ⱨ·ʱʱʼ*/ + outStringLength += 4u; + + outString[outStringLength++] = newRouteData[deviceId].cRouteNeedDriveSGBJFlag; /*·ⱨ־*/ + + outString[outStringLength++] = newRouteData[deviceId].cRouteDrivedSGBJFlag; /*·ⱨ־0x55 δ0xAA */ + outString[outStringLength++] = newRouteData[deviceId].chRouteNearSecSearchState; /*·ӽβѯ״̬Ƿйϳ*/ + outString[outStringLength++] = newRouteData[deviceId].chRouteApplySwitchCheckFlag; /*·ڿ־*/ + } + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { + #ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nRouteData:%d\nRouteId(2)-RouteState-RouteLevel-ZongQuXiaoFlag-ZongRenJieFlag-RepeatOpenFlag-StopCheckFlag-AutoRouteId(2)-AutoReturnId(2)-BelongLongRouteId(2)-XuanPaiStartCycNum(4)-RouteLockStartCycNum(4)-OverlapLockStartCycNum(4)-RouteOpenSigStatrtCycNum(4)-DelayUnlockStartCycNum(4)-LeadFaultOpenStartCycNum(4)-AllAutoReturnId(2)-StopensureFlag-StopKeepCheckFlag-RouteStateFlag-TrainEnterFlag-ZongRenJieDelayType-RecoverOpenState-OverlapLockedId-atsExptLkOverlapId:%d",(UINT16)sizeof(RouteDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + #endif + + #ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0,"\nRouteData:%d",(UINT16)sizeof(RouteDataStruct)); + Out_Array_Buffer(0,"RouteId(2)-RouteState-RouteLevel-ZongQuXiaoFlag-ZongRenJieFlag-RepeatOpenFlag-StopCheckFlag-AutoRouteId(2)-AutoReturnId(2)-BelongLongRouteId(2)-XuanPaiStartCycNum(4)-RouteLockStartCycNum(4)-OverlapLockStartCycNum(4)-RouteOpenSigStatrtCycNum(4)-DelayUnlockStartCycNum(4)-LeadFaultOpenStartCycNum(4)-AllAutoReturnId(2)-StopensureFlag:%d",outStringLength); + Out_Array_Buffer(16,outString,outStringLength); + + #endif + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + + /*************************************ӡǽ·********************************************/ + /*ӡǽ·*/ + localCiType = GetLocalCiType(); + if (CI_TYPE_CLD == localCiType) + {/**/ + + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + return returnValue; + } + + for (ii=0u;iiNonRouteId;/*ǽ·ID*/ + outString[outStringLength++] = (newNonRouteDataStru+ii)->NonRouteState;/*ǽ·״̬*/ + outString[outStringLength++] = (newNonRouteDataStru+ii)->HaveCancelFlag;/*ǽ·ȡ־*/ + outString[outStringLength++] = (newNonRouteDataStru+ii)->CancelFlag;/*ǽ·ȡ־*/ + outString[outStringLength++] = (newNonRouteDataStru+ii)->RunMode;/*ǽ·ģʽ*/ + LongToChar((newNonRouteDataStru+ii)->XuanPaiStartCycleNum,&outString[outStringLength]);/*ѡʼ*/ + outStringLength += 4u; + LongToChar((newNonRouteDataStru+ii)->SigOpenStartCycleNum,&outString[outStringLength]);/*źſʼ*/ + outStringLength += 4u; + LongToChar((newNonRouteDataStru+ii)->DelayUnlockStartCycleNum,&outString[outStringLength]);/*ǰǽ·ʱ*/ + outStringLength += 4u; + + } + + + + } + else + {/*Ƚϴ*/ + + returnValue = CI_ERROR; + } + } + + } + else + { + /*dzӡ*/ + } + + + + if (outStringLength == 0u) + { + } + else + { + #ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nNonRouteData:%d\nNonRouteId-NonRouteState-HaveCancelFlag-CancelFlag-RunMode-XuanPaiStartCycleNum(4)-SigOpenStartCycleNum(4)-DelayUnlockStartCycleNum(4):%d",(UINT16)sizeof(NonRouteDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + + #endif + + #ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0,"\nNonRouteData:%d",(UINT16)sizeof(NonRouteDataStruct)); + Out_Array_Buffer(0,"NonRouteId-NonRouteState-HaveCancelFlag-CancelFlag-RunMode-XuanPaiStartCycleNum(4)-SigOpenStartCycleNum(4)-DelayUnlockStartCycleNum(4):%d",outStringLength); + Out_Array_Buffer(16,outString,outStringLength); + + #endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + + + /*************************************ӡ߼********************************************/ + /*ӡ߼*/ + deviceNum = GetTotalLogSecCurNum(); + for (ii = 0u; ii < deviceNum; ii++)/*͸߼Ŀ*/ + { + if (CI_SUCCESS !=returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetLogicSecId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_LogicSecDataStru[deviceId]), (UINT16)sizeof(LogicSectionDataStruct), + (UINT8*)(&newLogicSecData[deviceId]), (UINT16)sizeof(LogicSectionDataStruct)); + + if (0u==comparaResult) + {/*Ƚһ*/ + + } + else if (1u==comparaResult ) + {/*Ƚݲһ*/ + + if (CI_ERROR==Flag) + {/*ӡ豸*/ + + } + else + { + /**************ӡϢ****************/ + + ShortToChar(newLogicSecData[deviceId].LogicSectionId,&outString[outStringLength]);/*߼ID*/ + outStringLength += 2u; + outString[outStringLength++] = newLogicSecData[deviceId].PreOccupyState;/*߼֮ǰռ״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].CurOccupyState;/*߼εǰռ״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].LinShiXianSuSetFlag;/*߼ʱ*/ + outString[outStringLength++] = newLogicSecData[deviceId].OccupyState;/*߼ռ״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].LogLockState;/*߼״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].LogLockDir;/*߼շ*/ + outString[outStringLength++] = newLogicSecData[deviceId].chResShareFlag;/*߼ι־ 0x55 0xAAǹ*/ + ShortToChar(newLogicSecData[deviceId].LogLockBelongRoute,&outString[outStringLength]);/*߼·*/ + outStringLength += 2u; + LongToChar(newLogicSecData[deviceId].LogUnlockStartCycNum,&outString[outStringLength]);/*߼ʱں*/ + outStringLength += 4u; + ShortToChar(newLogicSecData[deviceId].wPLockBelongRouteId, &outString[outStringLength]);/*յĽ·*/ + outStringLength += 2u; + + outString[outStringLength++] = newLogicSecData[deviceId].cResReqOtherCIId;/*ԴID*/ + ShortToChar(newLogicSecData[deviceId].wResReqTrainId, &outString[outStringLength]);/*ԴгID*/ + outStringLength += 2u; + ShortToChar(newLogicSecData[deviceId].JumpLockTrainId, &outString[outStringLength]);/*ͷԾгID*/ + outStringLength += 2u; + outString[outStringLength++] = newLogicSecData[deviceId].LogJumpLockState;/*߼Ծ״̬ 0x55 δգ0xAA */ + outString[outStringLength++] = newLogicSecData[deviceId].LogJumpLockDelayUnlockFlag;/*߼Ծʱñ־ 0x55 δã0xaa */ + LongToChar(newLogicSecData[deviceId].LogSecJumpDelayUnlockStartCyc, &outString[outStringLength]);/*߼Ծʱʼں*/ + outStringLength += 4u; + outString[outStringLength++] = newLogicSecData[deviceId].LogSecJumpLockPermFlag;/*߼Ծ־ 0x55 0xaa ֹ*/ + + + if (LOGIC_SECTION_RES_SUM_MAX < newLogicSecData[deviceId].chTrainInfoSum) + { + /* Ϸ */ + outString[outStringLength++] = 0u;/*߼Դ*/ + } + else + { + outString[outStringLength++] = newLogicSecData[deviceId].chTrainInfoSum;/*߼Դ*/ + for (jj = 0u; jj < newLogicSecData[deviceId].chTrainInfoSum; jj++) + { + ShortToChar(newLogicSecData[deviceId].szTrainResData[jj].wTrainId, &outString[outStringLength]);/*гID*/ + outStringLength += 2u; + + outString[outStringLength++] = newLogicSecData[deviceId].szTrainResData[jj].chTrainApplyState;/*г״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].szTrainResData[jj].chLogicResUsable;/*гԴ״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].szTrainResData[jj].chLogicReturnState;/*۷߼α־*/ + outString[outStringLength++] = newLogicSecData[deviceId].szTrainResData[jj].chLogicUnlockState;/*г״̬*/ + LongToChar(newLogicSecData[deviceId].szTrainResData[jj].dwRcvUnlockCmdCyc, &outString[outStringLength]);/*߼ʱں*/ + outStringLength += 4u; + } + } + LongToChar(newLogicSecData[deviceId].LogErrlockStartCycNum, &outString[outStringLength]);/*߼ʱùʼں*/ + outStringLength += 4U; + outString[outStringLength++] = newLogicSecData[deviceId].chLogicProResUsable;/*߼ηԴ״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].chLogicSpksFLockState;/*߼αSPKS״̬*/ + + if (LOGSEC_RELATE_ROUTE_SUM_MAX >= newLogicSecData[deviceId].chLogSecLockBelLogRouteSum) + { + outString[outStringLength++] = newLogicSecData[deviceId].chLogSecLockBelLogRouteSum; /*߼߼·*/ + for (kk = 0U; kk < newLogicSecData[deviceId].chLogSecLockBelLogRouteSum; kk++) + { + ShortToChar(newLogicSecData[deviceId].szLogSecLockBelLogRouteData[kk].wLogSecLockBelLogRouteId, &outString[outStringLength]); /*߼߼·ID*/ + outStringLength += 2u; + outString[outStringLength++] = newLogicSecData[deviceId].szLogSecLockBelLogRouteData[kk].chLogSecLockBelLogRouteState; /*߼߼·״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].szLogSecLockBelLogRouteData[kk].wLogSecLockBelLogRouteDir; /*߼α߼·յķID*/ + } + } + else + { + outString[outStringLength++] = 0U; /*߼߼·ޣ*/ + } + + outString[outStringLength++] = newLogicSecData[deviceId].LogSecLogLockState; /*߼߼״̬*/ + outString[outStringLength++] = newLogicSecData[deviceId].LogSecLogLockDir; /*߼߼շ*/ + outString[outStringLength++] = newLogicSecData[deviceId].chLinShiXianSuSetSpeed; /*߼ʱֵ*/ + outString[outStringLength++] = newLogicSecData[deviceId].chAblRelLogSecUsableFlag; /*ABLг߼ʹñ־*/ + outString[outStringLength++] = newLogicSecData[deviceId].cRouteLeaveLogFlag; /*ȥABLг־*/ + } + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { + #ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nLogicSecData:%d\nLogicSectionId(2)-PreOccupyState-CurOccupyState-LinShiXianSuSetFlag:%d",(UINT16)sizeof(LogicSectionDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + + #endif + + #ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0,"\nLogicSecData:%d",(UINT16)sizeof(LogicSectionDataStruct)); + Out_Array_Buffer(0,"LogicSectionId(2)-PreOccupyState-CurOccupyState:%d",outStringLength); + Out_Array_Buffer(16,outString,outStringLength); + + #endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + /*************************************ӡϴ********************************************/ + /*ӡϴ*/ + for (ii = 0u; ii < GetWashMachineSum(); ii++) + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetWashMachineId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_WashMachineDataStru[deviceId]), (UINT16)sizeof(WashMachineDataStruct), + (UINT8*)(&newWashMachineData[deviceId]), (UINT16)sizeof(WashMachineDataStruct)); + + if (0u==comparaResult) + {/*Ƚһ*/ + + } + else if (1u==comparaResult ) + {/*Ƚݲһ*/ + + if (CI_ERROR==Flag) + {/*ӡ豸*/ + + } + else + { + /**************ӡϢ****************/ + + ShortToChar(newWashMachineData[deviceId].WashMachineId,&outString[outStringLength]);/*ϴID*/ + outStringLength += 2u; + outString[outStringLength++] = newWashMachineData[deviceId].WashMachineReadyState;/*ϴ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].WashMachineRequestVerifyState;/*ϴȷ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].TrainEmergencyStopState;/*гͣ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].HeadWashAllowState;/*ͷϴ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].TailWashAllowState;/*βϴ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].WashTrainRequestDrvState;/*ϴ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].TrainHeadStopSteadyDrvState;/*ͷͣ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].TrainTailStopSteadyDrvState;/*βͣ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].TrainOutWashTrainPortAllowState;/*ϴ״̬*/ + ShortToChar(newWashMachineData[deviceId].CurVobcId, &outString[outStringLength]);/*ǰϴVOBC ID*/ + outStringLength += 2u; + + outString[outStringLength++] = newWashMachineData[deviceId].PauseTrainWashRequestDrvState;/*ͣϴ״̬(ֶ̬:)*/ + outString[outStringLength++] = newWashMachineData[deviceId].PaseWashMachineRequesDrvtState;/*ͨϴ״̬(ֶ̬:)*/ + + outString[outStringLength++] = newWashMachineData[deviceId].WashmachineXTACurState;/*ϴͬⰴťǰ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].WashmachineXTAPreState;/*ϴͬⰴť״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].WashmachineXTALogicState;/*ϴť߼״̬*/ + LongToChar(newWashMachineData[deviceId].WashmachineXTAPressDownCycle,&outString[outStringLength]);/*ϴϴͬⰴťʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newWashMachineData[deviceId].WashMachineWorkModeDrvtState;/*ϴϴģʽ״̬(ֶ̬:)*/ + outString[outStringLength++] = newWashMachineData[deviceId].WashModeState;/*ϴϴģʽɼ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].chSetWashWorkModeBack;/*ϴģʽ*/ + outString[outStringLength++] = newWashMachineData[deviceId].chDownWashAllowState;/*ģʽϴͬ״̬*/ + outString[outStringLength++] = newWashMachineData[deviceId].chDownWashAllowPassState;/*ģʽϴͬͨ״̬*/ + LongToChar(newWashMachineData[deviceId].WashWorkModeRelayDrvCycle, &outString[outStringLength]);/*ϴģʽ̵ʼں*/ + outStringLength += 4u; + } + + } + else + { + returnValue = CI_ERROR; + } + + } + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nWashMechineData:%d\nWashMachineId(2)-WashMachineReadyState-WashMachineRequestVerifyState-TrainEmergencyStopState-HeadWashAllowState-TailWashAllowState-WashTrainRequestDrvState-TrainHeadStopSteadyDrvState-TrainTailStopSteadyDrvState-TrainOutWashTrainPortAllowState-CurVobcId(2):%d",(UINT16)sizeof(LogicSectionDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + +#endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + + /*************************************ӡPSD״̬********************************************/ + /*ӡ״̬*/ + deviceNum = GetTotalPsdCurNum(); + for (ii = 0u; ii < deviceNum; ii++)/*͸PsdĿ*/ + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetPsdId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_PsdDataStru[deviceId]), (UINT16)sizeof(PsdDataStruct), + (UINT8*)(&newPsdData[deviceId]), (UINT16)sizeof(PsdDataStruct)); + + if (0u==comparaResult) + {/*Ƚһ*/ + + } + else if (1u==comparaResult ) + {/*Ƚݲһ*/ + + if (CI_ERROR==Flag) + {/*ӡ豸*/ + + } + else + { + /**************ӡϢ****************/ + + ShortToChar(newPsdData[deviceId].PsdId,&outString[outStringLength]);/*PSD ID*/ + outStringLength += 2u; + ShortToChar(newPsdData[deviceId].psdEditGroupInfo,&outString[outStringLength]);/*PSD Ϣ*/ + outStringLength += 2u; + outString[outStringLength++] = newPsdData[deviceId].DoorButtonState;/*Űť״̬*/ + outString[outStringLength++] = newPsdData[deviceId].MutualLockRemoveState;/*Ż״̬*/ + outString[outStringLength++] = newPsdData[deviceId].PsdDriveState;/*״̬*/ + outString[outStringLength++] = newPsdData[deviceId].PsdState;/*״̬*/ + ShortToChar(newPsdData[deviceId].SrcVobcId,&outString[outStringLength]);/*ŵĵǰVOBC ID*/ + outStringLength += 2u; + outString[outStringLength++] = newPsdData[deviceId].PsdCmd;/*ŵ*/ + LongToChar(newPsdData[deviceId].CmdSetCycle,&outString[outStringLength]);/**/ + outStringLength += 4u; + LongToChar(newPsdData[deviceId].CmdSetCyclePsc,&outString[outStringLength]);/*psc״̬*/ + outStringLength += 4u; + outString[outStringLength++] = newPsdData[deviceId].doorOpenButtonState;/*վ̨Űť״̬*/ + outString[outStringLength++] = newPsdData[deviceId].doorDepartButtonState;/*վ̨ť״̬*/ + outString[outStringLength++] = newPsdData[deviceId].PsdButtonPangluState;/*վ̨Űť·״̬*/ + outString[outStringLength++] = newPsdData[deviceId].PsdRemoraState;/*ϰ״̬*/ + outString[outStringLength++] = newPsdData[deviceId].JXTCMutualLockState;/*϶̽⻥״̬*/ + LongToChar(newPsdData[deviceId].StartDetectionCycNum,&outString[outStringLength]);/*̽*/ + outStringLength += 4u; + outString[outStringLength++] = newPsdData[deviceId].StartDetectionState;/*̽״̬*/ + outString[outStringLength++] = newPsdData[deviceId].StopDetectionState; /*ֹͣ̽״̬*/ + outString[outStringLength++] = newPsdData[deviceId].VOBCDoorState; /*VOBC״̬*/ + LongToChar(newPsdData[deviceId].PCBPressCycNum,&outString[outStringLength]);/*PCBʼ*/ + outStringLength += 4u; + LongToChar(newPsdData[deviceId].POBPressCycNum,&outString[outStringLength]);/*POBʼ*/ + outStringLength += 4u; + LongToChar(newPsdData[deviceId].PSBPressCycNum,&outString[outStringLength]);/*PSBʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newPsdData[deviceId].PscPlConfirmFlag; /*ATSȷ·־*/ + outString[outStringLength++] = newPsdData[deviceId].JXTCStartState; /*ӿڼ϶̽״̬*/ + LongToChar(newPsdData[deviceId].JXTCStartCycNum,&outString[outStringLength]);/*ӿڼ϶̽ʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newPsdData[deviceId].JXTCStopState; /*ӿڼ϶ֹ̽ͣ״̬*/ + LongToChar(newPsdData[deviceId].JXTCStopCycNum,&outString[outStringLength]);/*ӿڼ϶ֹ̽ͣʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newPsdData[deviceId].JXTCStartFlag; /*־*/ + outString[outStringLength++] = newPsdData[deviceId].JXTCStopFlag; /*ֹͣ־*/ + + LongToChar(newPsdData[deviceId].dwCleFarePCBPressCycNum, &outString[outStringLength]);/*ȷŰťʼ*/ + outStringLength += 4u; + outString[outStringLength++] = newPsdData[deviceId].chCleFarePCBButtonState; /*ȷŰť״̬*/ + outString[outStringLength++] = newPsdData[deviceId].chCleFarePCBButKeepState; /*ȷŰť״̬*/ + outString[outStringLength++] = newPsdData[deviceId].chCleFarePDBFlaLigFlag; /*ȷPDBťָʾƱ־*/ + outString[outStringLength++] = newPsdData[deviceId].chVideoQkDriveState; /*Ƶ״̬*/ + ShortToChar(newPsdData[deviceId].wVideoQkRelateVobcId, &outString[outStringLength]);/*ƵͶӦгID*/ + outStringLength += 2u; + } + + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nPsdData:%d\nPsdId(2)-psdEditGroupInfo(2)-DoorButtonState-MutualLockRemoveState-PsdDriveState-PsdState-SrcVobcId(2)-PsdCmd-CmdSetCycle(4)-CmdSetCyclePsc(4)-doorOpenButtonState-doorDepartButtonState-PsdButtonPangluState-PsdRemoraState-JXTCMutualLockState-StartDetectionCycNum(4)-StartDetectionState-StopDetectionState-VOBCDoorState-PCBPressCycNum(4)-POBPressCycNum(4)-PSBPressCycNum(4):%d",(UINT16)sizeof(PsdDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + +#endif + + + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + /*************************************ӡ********************************************/ + /*ӡ*/ + deviceNum = GetGaragedoorSum(); + for (ii = 0u; ii < deviceNum; ii++) + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetGaragedoorId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_GaragedoorDataStru[deviceId]), (UINT16)sizeof(GaragedoorDataStruct), + (UINT8*)(&newGaragedoorData[deviceId]), (UINT16)sizeof(GaragedoorDataStruct)); + + if (0u==comparaResult) + {/*Ƚһ*/ + + } + else if (1u==comparaResult ) + {/*Ƚݲһ*/ + + if (CI_ERROR==Flag) + {/*ӡ豸*/ + + } + else + { + /**************ӡϢ****************/ + + ShortToChar(newGaragedoorData[deviceId].GaragedoorId,&outString[outStringLength]);/*ID (ʼֶ)*/ + outStringLength += 2u; + outString[outStringLength++] = newGaragedoorData[deviceId].GaragedoorState; /*״̬ (ֶ̬)*/ + outString[outStringLength++] = newGaragedoorData[deviceId].GaragedoorAllowCloseFlag; /*ű־ZC*/ + outString[outStringLength++] = newGaragedoorData[deviceId].GDAllowCloseFlagIVOC; /*ű־IVOC*/ + outString[outStringLength++] = newGaragedoorData[deviceId].GaragedoorModeState; /*ģʽ״̬*/ + outString[outStringLength++] = newGaragedoorData[deviceId].GaragedoorFaultState; /*Ź״̬*/ + outString[outStringLength++] = newGaragedoorData[deviceId].GaragedoorPangLuState; /*·״̬*/; + outString[outStringLength++] = newGaragedoorData[deviceId].drvDoorState; /* ״̬*/ + outString[outStringLength++] = newGaragedoorData[deviceId].cmdProcessState; /* ״̬ */ + LongToChar(newGaragedoorData[deviceId].waiteZCResponseStartCycNum,&outString[outStringLength]);/* ȴZCʼʱ */ + outStringLength += 4u; + LongToChar(newGaragedoorData[deviceId].waiteIVOCResponseStartCycNum, &outString[outStringLength]);/* ȴIVOCʼʱ */ + outStringLength += 4u; + LongToChar(newGaragedoorData[deviceId].GaragedoorOpenStartCycNum,&outString[outStringLength]);/* Ŵ򿪿ʼ */ + outStringLength += 4u; + LongToChar(newGaragedoorData[deviceId].GaragedoorCloseStartCycNum,&outString[outStringLength]);/* Źرտʼ */ + outStringLength += 4u; + } + + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nGaragedoorData:%d\nGaragedoorId(2)-GaragedoorState-GaragedoorAllowCloseFlag-GaragedoorModeState-drvDoorState-cmdProcessState-waiteZCResponseStartCycNum(4)-GaragedoorOpenStartCycNum(4)-GaragedoorCloseStartCycNum(4):%d",(UINT16)sizeof(GaragedoorDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + +#endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + + /*************************************ӡ******************************************************/ + /*ӡ*/ + floodGateTotalSum = GetTotalFloodGateCurSum(); + for (ii = 0u; ii < floodGateTotalSum; ii++) + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetFloodGateId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_FloodGateDataStru[deviceId]), (UINT16)sizeof(FloodGateDataStruct), + (UINT8*)(&pNewFloodGateData[deviceId]), (UINT16)sizeof(FloodGateDataStruct)); + + if (0u==comparaResult ) + {/*Ƚһ*/ + + } + else if (1u==comparaResult ) + {/*Ƚݲһ*/ + + if (CI_ERROR==Flag ) + {/*ӡ豸*/ + + } + else + { + /**************ӡϢ****************/ + + ShortToChar(pNewFloodGateData[deviceId].FloodGateId,&outString[outStringLength]);/*ID (ʼֶ)*/ + outStringLength += 2u; + outString[outStringLength++] = pNewFloodGateData[deviceId].CurOpenLockStateFromFYM; /*ǰ״̬ (ֶ̬)*/ + outString[outStringLength++] = pNewFloodGateData[deviceId].CurCloseRequestStateFromFYM; /*ǰ״̬*/ + + outString[outStringLength++] = pNewFloodGateData[deviceId].CurAgreeCloseAckFromZC; /*ǰzcظ״̬*/ + outString[outStringLength++] = pNewFloodGateData[deviceId].CurAgreeCloseStateIn; /*ǰͬŲɼ״̬*/; + outString[outStringLength++] = pNewFloodGateData[deviceId].CurAgreeCloseStateOut; /* ǰͬ״ֶ̬̬Σ*/ + + outString[outStringLength++] = pNewFloodGateData[deviceId].FloodGateCloseApplyIvocSum; /*Źг*/ + for (jj = 0u; jj < pNewFloodGateData[deviceId].FloodGateCloseApplyIvocSum; jj++) + { + ShortToChar(pNewFloodGateData[deviceId].FloodGateCloseApplyIvocId[jj], &outString[outStringLength]);/*ŹгID*/ + outStringLength += 2u; + } + + outString[outStringLength++] = pNewFloodGateData[deviceId].FloodGateCloseAnsIvocSum; /*Źгظг*/ + for (jj = 0u; jj < pNewFloodGateData[deviceId].FloodGateCloseAnsIvocSum; jj++) + { + ShortToChar(pNewFloodGateData[deviceId].FloodGateCloseFromIvocStru[jj].wTrainId, &outString[outStringLength]);/*гͬŹгID*/ + outStringLength += 2u; + outString[outStringLength++] = pNewFloodGateData[deviceId].FloodGateCloseFromIvocStru[jj].wFloodGateCloseIvocFlag; /*гͬŹ״̬*/ + } + } + + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + + debug_infor_printf((const)"\nFloodGateData:%d\FloodGateId(2)-CurOpenLockState(1)-CurCloseRequest(1)-CurApplyCloseCmdToZC(1)-CurAgreeCloseAckFromZC(1)-CurAgreeCloseStateIn(1)- CurAgreeCloseStateOut(1):%d",(UINT16)sizeof(GaragedoorDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + +#endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + /*************************************ӡ********************************************/ + /*ӡ*/ + deviceNum = GetOverlapCurSum(); + for (ii = 0u; ii < deviceNum; ii++)/*͸ıĿ*/ + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + deviceId = GetOverlapId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_OverlapDataStru[deviceId]), (UINT16)sizeof(OverlapDataStruct), + (UINT8*)(&newOverlapData[deviceId]), (UINT16)sizeof(OverlapDataStruct)); + + if (0u==comparaResult) + {/*Ƚһ*/ + + } + else if (1u==comparaResult ) + {/*Ƚݲһ*/ + + if (CI_ERROR != Flag) + { + /**************ӡϢ****************/ + + ShortToChar(newOverlapData[deviceId].OverlapId,&outString[outStringLength]);/*ID*/ + outStringLength += 2u; + ShortToChar(newOverlapData[deviceId].BelongRouteId,&outString[outStringLength]);/*·ID*/ + outStringLength += 2u; + LongToChar(newOverlapData[deviceId].UnlockStartCycNum,&outString[outStringLength]);/*νʼں*/ + outStringLength += 4u; + LongToChar(newOverlapData[deviceId].XuanPaiStartCycNum,&outString[outStringLength]);/*ѡſʼں*/ + outStringLength += 4u; + outString[outStringLength++] = newOverlapData[deviceId].OverlapUnlockApplyFlag;/*ZCν־*/ + outString[outStringLength++] = newOverlapData[deviceId].OverlapCanLaborUnlockFlag;/*ο˹־*/ + outString[outStringLength++] = newOverlapData[deviceId].OverlapLaborUnlockSetState;/*˹״̬*/ + + LongToChar(newOverlapData[deviceId].laborUnlockStartCycNum,&outString[outStringLength]);/*˹ں*/ + outStringLength += 4U; + + outString[outStringLength++] = newOverlapData[deviceId].atsOrlaborLockFlag;/*ATS˹ձ־*/ + + LongToChar(newOverlapData[deviceId].lockStartCycNum,&outString[outStringLength]);/*ճɹں*/ + outStringLength += 4U; + + ShortToChar(newOverlapData[deviceId].overlapUnlockTime,&outString[outStringLength]);/*ʱ*/ + outStringLength += 2U; + outString[outStringLength++] = newOverlapData[deviceId].laborLockOverlapCmd;/*˹ձ־*/ + + ShortToChar(newOverlapData[deviceId].wOverlapUnlockApplyTrainId, &outString[outStringLength]);/*εгID*/ + outStringLength += 2U; + + LongToChar(newOverlapData[deviceId].dwReqIvocUnLockStartCycNum, &outString[outStringLength]);/*ʼں*/ + outStringLength += 4U; + + outString[outStringLength++] = newOverlapData[deviceId].cProSwitchCheckResultFlag;/*־0xFFĬֵ0x55ʧܣ0xAAɹ*/ + + outString[outStringLength++] = newOverlapData[deviceId].cProSwitchCheckStartFlag;/*鿪ʼ־0x55鿪ʼ0xAAֹͣ*/ + } + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nOverlapData:%d\nOverlapId(2)-BelongRouteId(2)-UnlockStartCycNum(4)-XuanPaiStartCycNum(4)-OverlapUnlockApplyFlag:%d",(UINT16)sizeof(OverlapDataStruct),outStringLength); + + debug_out_array(0xAA, outString, outStringLength); +#endif + +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0,"\nOverlapData:%d",(UINT16)sizeof(OverlapDataStruct)); + Out_Array_Buffer(0,"OverlapId(2)-BelongRouteId(2)-UnlockStartCycNum(4)-XuanPaiStartCycNum(4)-OverlapUnlockApplyFlag:%d",outStringLength); + Out_Array_Buffer(16,outString,outStringLength); + +#endif + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + + /*************************************ӡVobcToCiDataStru********************************************/ + deviceNum = (UINT8)GetVobcToCiSum(); + + if (0u < deviceNum) + { + + for (ii=0;iiwEaTrainId, &outString[outStringLength]);/*ɢгID*/ + outStringLength += 2u; + outString[outStringLength++] = pNewTrainInfoData[deviceId].strTrainEaInfo->chAgreeState; /*״̬*/ + LongToChar(pNewTrainInfoData[deviceId].strTrainEaInfo->dwBuildCyc, &outString[outStringLength]);/*ں*/ + outStringLength += 4u; + } + outString[outStringLength++] = pNewTrainInfoData[deviceId].chEaCmd; /*ɢ*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chTrainCanUct; /*гתΪUCT־״̬תΪδΪFLAG_SETʱΪFLAG_UNSET*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chActive; /*г*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chRrmRqst; /*RRM*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chRrmState; /*RRMȨ״̬*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chRrmReson; /*RRMԭ*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chRrmResonFromOtherRc; /*RCRRMԭ*/ + ShortToChar(pNewTrainInfoData[deviceId].wAtsLgcStation, &outString[outStringLength]);/*һ߼վ̨ID*/ + outStringLength += 2u; + ShortToChar(pNewTrainInfoData[deviceId].wNextTioc, &outString[outStringLength]);/*һTIOCţRRM*/ + outStringLength += 2u; + outString[outStringLength++] = pNewTrainInfoData[deviceId].chDerailment; /*ѹ״̬*/ + ShortToChar(pNewTrainInfoData[deviceId].wHeadAxisId, &outString[outStringLength]);/*ǰ*/ + outStringLength += 2u; + outString[outStringLength++] = pNewTrainInfoData[deviceId].wHeadITEResult; /*ǰITEʶ*/ + ShortToChar(pNewTrainInfoData[deviceId].wTailAxisId, &outString[outStringLength]);/*󷽼*/ + outStringLength += 2u; + outString[outStringLength++] = pNewTrainInfoData[deviceId].wTailITEResult; /*ITEʶ*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chNvramPosFlag;/* NVNAMλñʶ*/ + + LongToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.wHeadVobcId, &outString[outStringLength]);/*ǰID*/ + outStringLength += 4u; + outString[outStringLength++] = pNewTrainInfoData[deviceId].strHeadTrainLocData.chHeadTrainLocFlag; /*λñʶ*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir;/* гз С*/ + ShortToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink, &outString[outStringLength]);/*гȫǰlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset, &outString[outStringLength]);/*гȫǰƫ*/ + outStringLength += 4u; + ShortToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink, &outString[outStringLength]);/*гСȫlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset, &outString[outStringLength]);/*гСȫƫ*/ + outStringLength += 4u; + + ShortToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink, &outString[outStringLength]);/*гȫǰlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset, &outString[outStringLength]);/*гȫǰƫ*/ + outStringLength += 4u; + ShortToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink, &outString[outStringLength]);/*гСȫlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset, &outString[outStringLength]);/*гСȫƫ*/ + outStringLength += 4u; + + outString[outStringLength++] = pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainIteLoc.chTrainDir;/* гз*/ + ShortToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss, &outString[outStringLength]);/*λǰ*/ + outStringLength += 2u; + ShortToChar(pNewTrainInfoData[deviceId].strHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss, &outString[outStringLength]);/*λ*/ + outStringLength += 2u; + + ShortToChar(pNewTrainInfoData[deviceId].szTrainIteData[0].wTrainHeadLinkId, &outString[outStringLength]);/*гȫǰlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].szTrainIteData[0].dwTrainHeadLinkOffset, &outString[outStringLength]);/*гȫǰƫ*/ + outStringLength += 4u; + ShortToChar(pNewTrainInfoData[deviceId].szTrainIteData[0].wTrainTailLinkId, &outString[outStringLength]);/*гСȫlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].szTrainIteData[0].dwTrainTailLinkOffset, &outString[outStringLength]);/*гСȫƫ*/ + outStringLength += 4u; + + outString[outStringLength++] = pNewTrainInfoData[deviceId].szTrainIteData[0].cTrainDir;/* гз*/ + ShortToChar(pNewTrainInfoData[deviceId].szTrainIteData[0].wForWardOffset, &outString[outStringLength]);/*λǰ*/ + outStringLength += 2u; + ShortToChar(pNewTrainInfoData[deviceId].szTrainIteData[0].wBackOffset, &outString[outStringLength]);/*λ*/ + outStringLength += 2u; + + ShortToChar(pNewTrainInfoData[deviceId].szTrainIteData[1].wTrainHeadLinkId, &outString[outStringLength]);/*гȫǰlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].szTrainIteData[1].dwTrainHeadLinkOffset, &outString[outStringLength]);/*гȫǰƫ*/ + outStringLength += 4u; + ShortToChar(pNewTrainInfoData[deviceId].szTrainIteData[1].wTrainTailLinkId, &outString[outStringLength]);/*гСȫlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].szTrainIteData[1].dwTrainTailLinkOffset, &outString[outStringLength]);/*гСȫƫ*/ + outStringLength += 4u; + + outString[outStringLength++] = pNewTrainInfoData[deviceId].szTrainIteData[1].cTrainDir;/* гз*/ + ShortToChar(pNewTrainInfoData[deviceId].szTrainIteData[1].wForWardOffset, &outString[outStringLength]);/*λǰ*/ + outStringLength += 2u; + ShortToChar(pNewTrainInfoData[deviceId].szTrainIteData[1].wBackOffset, &outString[outStringLength]);/*λ*/ + outStringLength += 2u; + ShortToChar(pNewTrainInfoData[deviceId].wTrainHeadSigId, &outString[outStringLength]);/*ǰźŻID*/ + outStringLength += 2u; + ShortToChar(pNewTrainInfoData[deviceId].wTrainHeadTrainId, &outString[outStringLength]);/*ǰID*/ + outStringLength += 2u; + outString[outStringLength++] = pNewTrainInfoData[deviceId].chTrainLocReverseRouteFlag;/* гλ÷·־*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chAblTrainDir;/* ABLгз*/ + ShortToChar(pNewTrainInfoData[deviceId].wAblTrainMaxHeadLink, &outString[outStringLength]);/*ABLгȫǰlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].dwAblTrainMaxHeadOffset, &outString[outStringLength]);/*ABLгȫǰƫ*/ + outStringLength += 4u; + ShortToChar(pNewTrainInfoData[deviceId].wAblTrainMinTailLink, &outString[outStringLength]);/*ABLгСȫlink*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].dwAblTrainMinTailOffset, &outString[outStringLength]);/*ABLгСȫƫ*/ + outStringLength += 4u; + outString[outStringLength++] = pNewTrainInfoData[deviceId].chVirHeadScreenPassFlag; /*ǰɸͨ־*/ + outString[outStringLength++] = pNewTrainInfoData[deviceId].chVirTailScreenPassFlag; /*ɸͨ־*/ + ShortToChar(pNewTrainInfoData[deviceId].wEnterLjkLinkId, &outString[outStringLength]);/*гʻмLINK*/ + outStringLength += 2u; + LongToChar(pNewTrainInfoData[deviceId].dwTrainFullEnterLjkCycNum, &outString[outStringLength]);/*гȫʻмں*/ + outStringLength += 4u; + + outString[outStringLength++] = pNewTrainInfoData[deviceId].chTrainPosMonitorState; /*гλüල״̬0x55 ලЧ0xAA ලЧ0xCC ලλòһ*/ + ShortToChar(pNewTrainInfoData[deviceId].wTrainPosMonitorInLink, &outString[outStringLength]); /*гλüලЧʱlink*/ + outStringLength += 2U; + outString[outStringLength] = pNewTrainInfoData[deviceId].chTrainReportState; /*г㱨״̬*/ + outStringLength++; + outString[outStringLength++] = pNewTrainInfoData[deviceId].chEaCmdState; /*ɢ״̬0x55 Ч0xAA Ч*/ + } + + + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nTrainData:%d\nwTrainId(2)-chTrainInZone-chTrainLevel-chTrainModel-dwIvocCycle(4)-chTrainDir-wTrainMaxHeadLink(2)-dwTrainMaxHeadOffset(4)-wTrainMinHeadLink(2)-dwTrainMinHeadOffset(4)-wTrainMaxTailLink(2)-dwTrainMinTailOffset(4)-chSpeedDir-wTrainSpeed(2)-chTransmitStat-chHeadScreenStat-chTailScreenStat-wHeadLink(2)-dwHeadOffset(4)-chHeadDir-wTailLink(2):%d", (UINT16)sizeof(TrainInfoStru), outStringLength); + + debug_out_array(0xAA, outString, outStringLength); +#endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + /*************************************ӡ߽********************************************/ + /*ӡ߽*/ + deviceNum = GetCfpSum();/* ȡ߽ */ + for (ii = 0u; ii < deviceNum; ii++) + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + /*Ƚ*/ + wCfpId = GetCfpId(ii); + deviceId = GetCfpBufIndex(wCfpId); + comparaResult = DeviceCompara((UINT8*)(&Record_CfpInfo[deviceId]), (UINT16)sizeof(CfpDataStru), + (UINT8*)(&pNewCfpData[deviceId]), (UINT16)sizeof(CfpDataStru)); + + if (0u == comparaResult) + {/*Ƚһ*/ + + } + else if (1u == comparaResult) + {/*Ƚݲһ*/ + + if (CI_ERROR == Flag) + {/*ӡ豸*/ + + } + else + { + /**************ӡϢ****************/ + ShortToChar(pNewCfpData[deviceId].wId, &outString[outStringLength]);/*߽ID*/ + outStringLength += 2u; + + ShortToChar(pNewCfpData[deviceId].otherTiocTrainInfo.wTrainId, &outString[outStringLength]);/*߽յTIOCгID*/ + outStringLength += 2u; + + outString[outStringLength++] = pNewCfpData[deviceId].otherTiocTrainInfo.chTrainLevel;/* ߽յTIOCгм */ + + LongToChar(pNewCfpData[deviceId].otherTiocTrainInfo.dwDis, &outString[outStringLength]);/* ߽յTIOCг */ + outStringLength += 4u; + + ShortToChar(pNewCfpData[deviceId].localTiocTrainInfo.wTrainId, &outString[outStringLength]);/*߽㷢͸TIOCгID*/ + outStringLength += 2u; + + outString[outStringLength++] = pNewCfpData[deviceId].localTiocTrainInfo.chTrainLevel;/* ߽㷢͸TIOCгм */ + + LongToChar(pNewCfpData[deviceId].localTiocTrainInfo.dwDis, &outString[outStringLength]);/* ߽㷢͸TIOCг */ + outStringLength += 4u; + + outString[outStringLength++] = pNewCfpData[deviceId].chLocalTiocEnvelopeNum;/* ߽㷢͸TIOC */ + + for (chEnIndex = 0u; chEnIndex < pNewCfpData[deviceId].chLocalTiocEnvelopeNum; chEnIndex++) + { + outString[outStringLength++] = pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].envelopeType;/* */ + + ShortToChar(pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].headTrainID, &outString[outStringLength]);/*ǰID*/ + outStringLength += 2u; + + ShortToChar(pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].tailTrainID, &outString[outStringLength]);/*ID*/ + outStringLength += 2u; + + ShortToChar(pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].startPos.Lnk, &outString[outStringLength]);/*link*/ + outStringLength += 2u; + + LongToChar(pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].startPos.Off, &outString[outStringLength]);/*ƫ*/ + outStringLength += 4u; + + outString[outStringLength++] = pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].startPos.Dir;/* 㷽 */ + + ShortToChar(pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].endPos.Lnk, &outString[outStringLength]);/*յlink*/ + outStringLength += 2u; + + LongToChar(pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].endPos.Off, &outString[outStringLength]);/*յƫ*/ + outStringLength += 4u; + + outString[outStringLength++] = pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].endPos.Dir;/* յ㷽 */ + + outString[outStringLength++] = pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].trianCnt;/* г */ + + for (chTrainIndex = 0u; chTrainIndex < pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].trianCnt; chTrainIndex++) + { + ShortToChar(pNewCfpData[deviceId].szLocalEnvelope[chEnIndex].trainID[chTrainIndex], &outString[outStringLength]);/*гID*/ + outStringLength += 2u; + } + } + + outString[outStringLength++] = pNewCfpData[deviceId].szCfpRRMData.cRrmSrcRcId;/* ֽRRMԴRC ID */ + + ShortToChar(pNewCfpData[deviceId].szCfpRRMData.wRrmTrainId, &outString[outStringLength]);/*ֽRRMгID*/ + outStringLength += 2u; + + ShortToChar(pNewCfpData[deviceId].szCfpRRMData.wRrmTrainNextStaId, &outString[outStringLength]);/*ֽRRMվ̨ID*/ + outStringLength += 2u; + + outString[outStringLength++] = pNewCfpData[deviceId].szCfpRRMData.chRrmSrcApplyState;/* ֽRRMԴRC״̬ */ + outString[outStringLength++] = pNewCfpData[deviceId].szCfpRRMData.chRrmDstAllowState;/* ֽRRMĿRC״̬ */ + + outString[outStringLength] = pNewCfpData[deviceId].cSignalLightUpFlag; /* ֽźŻƱ־ */ + outStringLength++; + } + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nCfpData:%d\nwCfpId(2)-RecvTrainId(2)-RecvTrainLevel-RecvTrainDis(4)-SendTrainId(2)-SendTrainLevel-SendTrainDis(4)-SendEnNum-SendEnInfo(n)-RecvEnNum-RecvEnInfo(n)-RrmSrcRcId-RrmTrainId(2)-RrmTrainNextStaId(2)-RrmSrcApplyState-chRrmDstAllowState:%d", (UINT16)sizeof(CfpDataStru), outStringLength); + + debug_out_array(0xAA, outString, outStringLength); +#endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + + /*************************************ӡʱϢ********************************************/ + deviceNum = GetTsrSum();/* ȡʱϢ */ + for (ii = 0u; ii < deviceNum; ii++) + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + + comparaResult = DeviceCompara((UINT8*)(&Record_TsrInfo[deviceId]), (UINT16)sizeof(TsrDataStruct), + (UINT8*)(&pNewTsrInfo[deviceId]), (UINT16)sizeof(TsrDataStruct)); + + if (0u == comparaResult) + {/*Ƚһ*/ + + } + else if (1u == comparaResult) + {/*Ƚݲһ*/ + + if (CI_ERROR == Flag) + {/*ӡ豸*/ + + } + else + { + /**************ӡϢ****************/ + outString[outStringLength] = (UINT8)deviceNum; /* ʱ */ + outStringLength++; + + outString[outStringLength] = pNewTsrInfo[ii].cSpeed; /* ٶ */ + outStringLength++; + + outString[outStringLength] = pNewTsrInfo[ii].cLogSecSum; /* ߼ */ + outStringLength++; + + for (chEnIndex = 0u; chEnIndex = pNewLogicalRouteDataStru[ii].wLogRouteInLogSecSum) + { + outString[outStringLength++] = (UINT8)pNewLogicalRouteDataStru[ii].wLogRouteInLogSecSum; /*߼·߼*/ + for (jj = 0U; jj < pNewLogicalRouteDataStru[ii].wLogRouteInLogSecSum; jj++) + { + ShortToChar(pNewLogicalRouteDataStru[ii].szLogRouteInLogSecIdBuf[jj], &outString[outStringLength]); /*߼·߼ID*/ + outStringLength += 2U; + } + } + else + { + outString[outStringLength++] = 0U; /*߼·߼ޣӡ*/ + } + + if (MAX_ROUTE_IN_LT_NUM >= pNewLogicalRouteDataStru[ii].routeInSwitOtherPosLogSecSum) + { + outString[outStringLength++] = (UINT8)pNewLogicalRouteDataStru[ii].routeInSwitOtherPosLogSecSum; /*߼·ڵķǽ·߼*/ + for (jj = 0U; jj < pNewLogicalRouteDataStru[ii].routeInSwitOtherPosLogSecSum; jj++) + { + ShortToChar(pNewLogicalRouteDataStru[ii].routeInSwitOtherPosLogSecIdBuf[jj], &outString[outStringLength]); /*߼·ڵķǽ·߼ID*/ + outStringLength += 2U; + } + } + else + { + outString[outStringLength++] = 0U; /*߼·ڵķǽ·߼ޣӡ*/ + } + + if (MAX_ROUTE_IN_LT_NUM >= pNewLogicalRouteDataStru[ii].routeOutLogSecSum) + { + outString[outStringLength++] = (UINT8)pNewLogicalRouteDataStru[ii].routeOutLogSecSum; /*߼·ιķǽ·ҷǵ߼*/ + for (jj = 0U; jj < pNewLogicalRouteDataStru[ii].routeOutLogSecSum; jj++) + { + ShortToChar(pNewLogicalRouteDataStru[ii].routeOutLogSecSumIdBuf[jj], &outString[outStringLength]); /*߼·ιķǽ·ҷǵ߼ID*/ + outStringLength += 2U; + } + } + else + { + outString[outStringLength++] = 0U; /*߼·ιķǽ·ҷǵ߼ޣӡ*/ + } + + if (MAX_ROUTE_IN_LT_NUM >= pNewLogicalRouteDataStru[ii].wLogRouteTrainLogSecSum) + { + outString[outStringLength++] = (UINT8)pNewLogicalRouteDataStru[ii].wLogRouteTrainLogSecSum; /*߼·г߼*/ + for (jj = 0U; jj < pNewLogicalRouteDataStru[ii].wLogRouteTrainLogSecSum; jj++) + { + ShortToChar(pNewLogicalRouteDataStru[ii].szLogRouteTrainLogSecIdBuf[jj], &outString[outStringLength]); /*߼·г߼ID*/ + outStringLength += 2U; + } + } + else + { + outString[outStringLength++] = 0U; /*߼·г߼ޣӡ*/ + } + } + } + else + { + returnValue = CI_ERROR; + } + } + + if (0U == outStringLength) + { + } + else + { +#ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nLogicalRouteData:%d, length:%d", (UINT16)sizeof(LogicalRouteDataStruct), outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + +#endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0U; + } + + /*************************************ӡ۷******************************************************/ + /*ӡ۷*/ + wNonAutoReturnCurSum = GetNonAutoReturnCurSum(); + for (ii = 0u; ii < wNonAutoReturnCurSum; ii++) + { + if (CI_SUCCESS != returnValue) + { + returnValue = CI_ERROR; + break; + } + pNonAutoReturnData = GetNonReturnData(); + + /*Ƚ*/ + deviceId = GetNonReturnId(ii); + comparaResult = DeviceCompara((UINT8*)(&Record_NonReturnDataStru[deviceId]), (UINT16)sizeof(NonAutoReturnDataStruct), + (UINT8*)(&pNonAutoReturnData[deviceId]), (UINT16)sizeof(NonAutoReturnDataStruct)); + + if (0u == comparaResult) + {/*Ƚһ*/ + + } + else if (1u == comparaResult) + {/*Ƚݲһ*/ + + if (CI_ERROR == Flag) + {/*ӡ豸*/ + + } + else + { + /**************ӡϢ****************/ + outString[outStringLength++] = pNonAutoReturnData[deviceId].IndicatorDevID; /*ָʾ豸ID*/ + ShortToChar(pNonAutoReturnData[deviceId].cmdSetTrainId, &outString[outStringLength]);/*гID*/ + outStringLength += 2u; + outString[outStringLength++] = pNonAutoReturnData[deviceId].VobcToCIAutoRtnIndicFlashState; /*ظ۷ָʾ״̬*/ + outString[outStringLength++] = pNonAutoReturnData[deviceId].VobcToCIAutoRtnIndicSteadyState; /*ظ۷ָʾȵ״̬*/ + ShortToChar(pNonAutoReturnData[deviceId].RtnRelayAdhesionState.AdhesionRealyId, &outString[outStringLength]);/*ճ̵ID*/ + outStringLength += 2u; + outString[outStringLength++] = pNonAutoReturnData[deviceId].RtnRelayAdhesionState.AdhesionState; /*̵ճ״̬*/ + LongToChar(pNonAutoReturnData[deviceId].RtnRelayAdhesionState.RelayUpCycNum, &outString[outStringLength]); /*̵*/ + outStringLength += 4U; + + } + + } + else + { + returnValue = CI_ERROR; + } + } + + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nNonAutoReturnData:%d", (UINT16)sizeof(NonAutoReturnDataStruct), outStringLength); + + debug_out_array(0xAA, outString, outStringLength); + +#endif + + /*մӡ*/ + CleanString(outString); + outStringLength = 0u; + } + + return returnValue; + +} + +/* +* ̵Ƚ +* ˵ const UINT8* lastString, һַ +* const UINT8* thisString, ַ +* UINT8 rec, 0Ϊɼ4Ϊ +* ֵ 0: ޱ仯 +* 1: б仯 +*/ +UINT8 RelayComPare(UINT8* lastString, const UINT8* thisString, UINT8 rec) +{ + UINT16 ii = 0u; + UINT16 BoardSum = 0u;/*̵*/ + UINT16 boradDataLen = 0u;/*̵峤*/ + UINT8 comPareFlag = 0u;/*ݶԱȽĬޱ仯*/ + UINT8 retVal = 0u; + if ((lastString == NULL) || (thisString == NULL)) + {/*ָΪղӡ*/ + + retVal = 0u; + } + else + { + switch (rec) + { + case 0:/*ɼ*/ + + BoardSum = GetColRelayStructSum();/*ɼṹ*/ + + boradDataLen = BOARD_COLL_DATA_LEN + 1u;/*ɼ̵ÿַ2ֽ*/ + + colStringLength = BoardSum * boradDataLen; + break; + case 4:/**/ + + BoardSum = GetDrvRelayStructSum();/*ṹ*/ + + boradDataLen = BOARD_DRV_DATA_LEN + 1u;/*̵ÿַ2ֽ*/ + + drvStringLength = BoardSum * boradDataLen; + break; + default:/**/ + + break; + } + + for (ii = 0u; ii < BoardSum * boradDataLen; ii++) + { + if (thisString[ii] == lastString [ii]) + { + /*ͬ*/ + } + else + { + /**/ + lastString[ii] = thisString[ii]; + + comPareFlag = 1u;/*б仯*/ + + } + } + + if (comPareFlag == 0u) + {/*ޱ仯*/ + + retVal = 0u; + } + else + {/*б仯*/ + + retVal = 1u; + } + } + return retVal; +} + +/* +* ַ +* ˵ UINT8* str +* ֵ void +*/ +void CleanString(UINT8* str) +{ + UINT16 ii = 0u; + + while (str[ii] != (UINT8)'\0') + { + str[ii++] = (UINT8)'\0'; + } +} + +/* +* Ա豸 +* ˵ UINT8* deviceStruAddr1, 豸1Ľṹ׵ַ +* const UINT16 deviceStruLen1, 豸1Ľṹݳ +* const UINT8* deviceStruAddr2, 豸2Ľṹ׵ַ +* const UINT16 deviceStruLen2, 豸2Ľṹݳ +* ֵ 0: һ +* 1: ݲһ +* 2: ṹͲһ +*/ +UINT8 DeviceCompara(UINT8* deviceStruAddr1, const UINT16 deviceStruLen1, + const UINT8* deviceStruAddr2, const UINT16 deviceStruLen2) +{ + UINT16 ii = 0u; + UINT8 returnValue = 0u;/*ʼһ*/ + + if ((deviceStruAddr1 == NULL) || (deviceStruAddr2 == NULL)) + {/*ַΪNULL*/ + + returnValue = 0u; + } + else + { + if (deviceStruLen1 != deviceStruLen2) + { + /*ݽṹһ*/ + returnValue = 2u; + } + else + { + for (ii = 0u; ii < deviceStruLen1; ii++) + { + if (deviceStruAddr1[ii] != deviceStruAddr2[ii]) + { + /*ݲһ*/ + returnValue = 1u; + break; + } + } + + /**/ + if (0u != returnValue) + { + for (ii = 0u; ii < deviceStruLen1; ii++) + { + deviceStruAddr1[ii] = deviceStruAddr2[ii]; + } + } + } + + } + + + + + return returnValue; +} +/* +* ȡؼ +* ˵ +* ֵ +*/ +void GetVirCIKeyDataStru(void) +{ + UINT8 ii = 0u; + UINT8 jj = 0U; + + for(ii=0u;ii ii)&&(SIGNAL_EQUAL_ROUTE_MAX_SUM >ii); ii++) + { + routeId = starSigRouteBuf[ii]; + routeLeadProperty = GetRouteLeadProperty(routeId); + if ((ROUTE_LEAD_PROPERTY_YES == routeLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == routeLeadProperty)) + { + switchSum = GetRouteSwitchSum(routeId); + switchBuf = GetRouteSwitchData(routeId); + protSwitchSum = GetRouteRelatedProtectSwitchSum(routeId); + protSwitchBuf = GetRouteRelatedProtSwitchData(routeId); + if ((NULL != switchBuf) && (NULL != protSwitchBuf)) + { + if (0u < switchSum) + { + for (jj = 0u; jj < switchSum; jj++) /*ҳλõĽ·*/ + { + switchPosition = GetSwitchCurPosition(switchBuf[jj].SwitchId); + if (switchPosition == switchBuf[jj].SwitchPosition) + { + flag = 1u; + + } + else + { + flag = 0u; + break; /*һ˳*/ + } + } + switchPosition = 0u; /*ǰλ*/ + if (1u == flag) + { + if (0u < protSwitchSum) + { + for (kk = 0u; kk < protSwitchSum; kk++) /*ҳλõĽ·*/ + { + switchPosition = GetSwitchCurPosition(protSwitchBuf[kk].ProtectSwitchId); + if (switchPosition == protSwitchBuf[kk].ProtectPosition) + { + flag = 1u; + } + else + { + flag = 0u; + break; /*һ˳*/ + } + } + } + } + if (1u == flag) + { + routeIdBuf[routeSum] = routeId; + routeSum++; + } + } + else /*·,ֻһ*/ + { + routeIdBuf[routeSum] = routeId; + routeSum++; + } + } + } + } + if (0u == routeSum) /*δҵ*/ + { + /* ¼ */ + SetErrorData(EFUNC_LEAD_ROUTE_MANAGE_ERROR,CI_DEVICE_TYPE_SIGNAL,signalId,ETYPE_SIG_YDROUTE_SEARCH_ERR,0,ESEND_LEVEL_ATS); + + } + for(jj = 0u; jj < routeSum; jj++) + { + + routeType = GetRouteType(routeIdBuf[jj]); /*ȡ·*/ + leadProperty = GetRouteLeadProperty(routeIdBuf[jj]); /*ȡ·*/ + + if ((routeSum > 1u) && (ROUTE_TYPE_LIECHE == routeType) + && ((ROUTE_LEAD_PROPERTY_YES == leadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == leadProperty))) + { + /*·һΪг·һΪ۷·,г·ҿ*/ + reVal = routeIdBuf[jj]; + } + else if ((1u == routeSum) && ((ROUTE_TYPE_LIECHE == routeType) || (ROUTE_TYPE_RETURN == routeType)) + && ((ROUTE_LEAD_PROPERTY_YES == leadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == leadProperty))) + { + reVal = routeIdBuf[jj]; + } + else if ((1u == routeSum) && (ROUTE_TYPE_DIAOCHE == routeType) + && ((ROUTE_LEAD_PROPERTY_YES == leadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == leadProperty))) + {/*·Ϊ·ʼźŻ*/ + reVal = routeIdBuf[jj]; + } + else + { + /**/ + } + if (0u != reVal) + { + break; + } + } + } + + + } + + + return reVal; +} + +/* +* ·֮ǰռ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERROR:ʧ +* CI_SUCCESS:ɹ +*/ +UINT8 CleanRoutePhySecPreOccupyState(const UINT16 routeId) +{ + UINT8 ii = 0u; + UINT8 PhySecSum = 0u; + UINT16 PhySecId = 0u; + RoutePhysicalSectionStruct* routePhySecStru = NULL; + + if ((0u == routeId) || (ROUTE_SUM_MAX<=routeId )) + { + return CI_ERROR; + } + else + { + ; + } + + PhySecSum = GetRoutePhysicalSectionSum(routeId); + routePhySecStru = GetRouteSectionData(routeId); + + if (0u == PhySecSum) + { + return CI_ERROR; + } + else + { + ; + } + + if (ROUTE_PHYSICALSECTION_SUM_MAX>=PhySecSum ) + { + for (ii = 0u; ii < PhySecSum; ii++) + { + PhySecId = routePhySecStru[ii].PhysicalSectionId; + + CleanPhySecPreMergeState(PhySecId); + } + + /*ӽ֮ǰռ*/ + PhySecId = GetSignalOutFirstPhySecId(GetRouteStartSignalId(routeId)); + CleanPhySecPreMergeState(PhySecId); + +#if 0 + /*ȥ֮ǰռ*/ + PhySecId = GetRouteLeavePhySecId(routeId); + CleanPhySecPreMergeState(PhySecId); +#endif + + return CI_SUCCESS; + } + else + { + return CI_ERROR; + } +} + +/* +* ý·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 useState, ״̬ +* ֵ +*/ +void SetRoutePhySectionOccupyState(const UINT16 routeId, const UINT8 setUseState) +{ + UINT8 phySecSum = 0u; /**/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 ii = 0u; /**/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT8 reVal = CI_ERROR; + UINT16 routeProSwitchSum = 0u;/*·*/ + RouteProtectSwitchStruct* pRouteProSwitchData = NULL;/*·*/ + UINT16 switchId = 0u;/*ID*/ + UINT16 phyId = 0u;/*ID*/ + UINT8 curUseState = 0u;/*״̬*/ + UINT8 phySecBelongId = 0u;/*ID*/ + + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + phySecSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(routeId); /*ȡ·*/ + + routeProSwitchSum = GetRouteRelatedProtectSwitchSum(routeId);/*ȡ·*/ + pRouteProSwitchData = GetRouteRelatedProtSwitchData(routeId);/*ȡ·*/ + + if ((setUseState != PHYSICAL_SECTION_USING_YES) && + (setUseState != PHYSICAL_SECTION_USING_NO)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + + if ((0u == localCiId) || (0u == phySecSum) || (NULL == pPhySecDataStru)) + { + reVal = CI_ERROR; + } + } + + + + if (CI_SUCCESS == reVal) + {/*·ڵãȡ*/ + for (ii= 0u; ii < phySecSum; ii++) + { + phySecBelongId = GetPhySecBelongCiId(pPhySecDataStru[ii].PhysicalSectionId); + curUseState = GetPhySecUseState(pPhySecDataStru[ii].PhysicalSectionId); + + commState = GetLocalCiAndOtherCiTransSta(phySecBelongId);/*ͨͨ״̬*/ + + if (PHYSICAL_SECTION_USING_YES == setUseState) + { /**/ + + if (localCiId == phySecBelongId) + { /**/ + /*ֱ*/ + SetPhySecUseState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_USING_YES, routeId); + } + else + { + if ((TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣֱøΪ*/ + SetPhySecUseState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_USING_YES, routeId); + } + else + { + /*DZ*/ + /**/ + SetPhySecUseState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_USING_APPLY, routeId); + + } + } + } + else + { /*δ*/ + + if (localCiId == phySecBelongId) + { /**/ + + /*δ*/ + SetPhySecUseState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_USING_NO, routeId); + } + else + { /*DZ*/ + if ((TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣֱøΪδ*/ + SetPhySecUseState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_USING_NO, routeId); + } + else + { + SetPhySecUseState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_USING_CANCEL, routeId); + } + } + } + } + } + + if (CI_SUCCESS == reVal) + {/*ȡ*/ + for (ii= 0u; ii < routeProSwitchSum; ii++) + { + switchId = pRouteProSwitchData[ii].ProtectSwitchId; + + phyId = GetSwitchPhySectionId(switchId); + curUseState = GetPhySecUseState(phyId); + phySecBelongId = GetPhySecBelongCiId(phyId); + + commState = GetLocalCiAndOtherCiTransSta(phySecBelongId);/*ͨͨ״̬*/ + + if (PHYSICAL_SECTION_USING_YES == setUseState) + { /**/ + + if (localCiId == phySecBelongId) + { /**/ + + /*η*/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_YES, routeId); + } + else + { /*DZ*/ + if ((TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣø״̬*/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_YES, routeId); + } + else + { + /**/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_APPLY, routeId); + } + } + } + else + { /*δ*/ + + if (localCiId == phySecBelongId) + { /**/ + + /*δ*/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_NO, routeId); + } + else + { /*DZ*/ + if ((TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣԲø״̬*/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_NO, routeId); + } + else + { + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_CANCEL, routeId); + } + } + } + } + } +} + +/* +* ý·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRoutePhySectionLockState(const UINT16 routeId, const UINT8 lockState) +{ + UINT8 phySecSum = 0U; /**/ + UINT8 curLockState = 0U; /*εǰ״̬*/ + UINT16 validRouteId = 0U; /*ҪЧ·ID*/ + UINT8 ii = 0U; /**/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT8 chKeepFlag = CI_ERROR;/*ִб־*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chRouteBelCiId = 0U;/*·ID*/ + UINT8 chRouteDir = 0U;/*·*/ + UINT8 chRLockBelOtherCiFlag = CI_ERROR;/*·־*/ + UINT8 chRouteBelOtherCiId = 0U;/*·ID*/ + + phySecSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(routeId); /*ȡ·*/ + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if (NULL == pPhySecDataStru) + { + ; /**/ + } + else + { + chKeepFlag = CI_SUCCESS; + chRouteDir = GetRouteDirection(routeId); + for (ii = 0u; ii < phySecSum; ii++) + { + if (PHYSICAL_SECTION_LOCK_NORMAL == lockState) + { /**/ + + curLockState = 0u; + curLockState = GetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId); /*ȡεǰ״̬*/ + + if ((PHYSICAL_SECTION_LOCK_NORMAL == curLockState) + || (PHYSICAL_SECTION_LOCK_DELAY == curLockState) + || (PHYSICAL_SECTION_LOCK_EXCEPT == curLockState)) + { /*||ʱ||*/ + + validRouteId = GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId); /*ȡ·ID*/ + SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, validRouteId, 0U); /*δ*/ + + chRouteBelCiId = GetRouteBelongCiId(validRouteId); + if ((chLocalCiId != chRouteBelCiId) && (0U != chLocalCiId)) + { + chRouteBelOtherCiId = chRouteBelCiId; + chRLockBelOtherCiFlag = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; + } + + SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, lockState, routeId, chRouteDir); /*״̬*/ + } + else if (PHYSICAL_SECTION_LOCK_NO == lockState) + { + SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, lockState, routeId, chRouteDir); /*״̬*/ + } + else if (PHYSICAL_SECTION_LOCK_EXCEPT == lockState) + { + SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, lockState, routeId, chRouteDir); /*״̬*/ + } + else + { + /*״̬*/ + chKeepFlag = CI_ERROR; + } + } + + + if ((CI_SUCCESS == chKeepFlag) && (0U < validRouteId) && (validRouteId != routeId) && (CI_ERROR == chRLockBelOtherCiFlag)) + { + /*·ڱ*/ + /*ν·Ľ·*/ + DealValidRouteState(validRouteId); + } + else if(CI_SUCCESS == chRLockBelOtherCiFlag) + { + AddCiSendToCiCmdInfo((UINT8)CI_CMD_ROUTE_SEC_LOCK_APPLY, routeId, validRouteId, chRouteBelOtherCiId); + } + else + { + ; /**/ + } + } +} + +/* +* ý·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockCommand, ״̬ +* ֵ void +*/ +void SetRouteRelProSwitchLockSta(const UINT16 routeId, const UINT8 lockCommand) +{ + UINT8 ii = 0u; /**/ + UINT8 retVal = CI_SUCCESS; /*ֵ*/ + UINT16 protectSwitchId = 0u; /*ID*/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct* routeProtectSwitchStru = NULL; /**/ + + routeProtectSwitchSum = GetRouteRelatedProtectSwitchSum(routeId); /*ȡĿ*/ + routeProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId); /*ȡ*/ + + if (NULL == routeProtectSwitchStru) + { + retVal = CI_ERROR; + } + else + { + } + + if((SWITCH_LOCK_PROTECT_SET != lockCommand) && (SWITCH_LOCK_PROTECT_CANCEL != lockCommand)) + { + retVal = CI_ERROR; + } + else + { + } + + if (CI_SUCCESS == retVal) + { + for (ii= 0u; ii < routeProtectSwitchSum; ii++) + { + protectSwitchId = routeProtectSwitchStru[ii].ProtectSwitchId; + SetSwitchLockStatus(SWITCH_PLOCKTYPE_ROUTE,routeId,protectSwitchId, lockCommand); /*õ״̬*/ + /*RC 13.0.0 ޣ˫һ*/ +#if 0 + if (SWITCH_TYPE_DOUBLE == GetSwitchType(protectSwitchId)) + { /*˫*/ + SetSwitchLockStatus(SWITCH_PLOCKTYPE_ROUTE,routeId,GetDSwitchOtherId(protectSwitchId), lockCommand); /*õ״̬*/ + } + else + { + } +#endif + } + } + else + { + retVal = CI_ERROR; + } +} + +/* +* ·ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 RouteFirstXuanProc(const UINT16 routeId) +{ + UINT8 phySecSum = 0u; /**/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 ii = 0u; /**/ + UINT8 waitSetFlag = 0u; /*ȴñ־*/ + UINT8 waitCancelFlag = 0u; /*ȴȡñ־*/ + UINT8 setFlag = 0u; /*ñ־*/ + UINT8 cancelFlag = 0u; /*δñ־*/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT8 chAllPhyBelCiCheck = CI_ERROR;/*·ڷ*/ + UINT8 reval = CI_ERROR; + UINT8 chPhySecUseState = 0U;/*״̬*/ + UINT8 chRouteProSwitchSum = 0U; /*Ŀ*/ + RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL; /**/ + UINT16 wProSwRelPhySecId = 0U;/*ID*/ + + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + phySecSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(routeId); /*ȡ·*/ + chRouteProSwitchSum = GetRouteRelatedProtectSwitchSum(routeId); + pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId); + + + if ((0u == localCiId) || (NULL == pPhySecDataStru) || (NULL == pRouteProtectSwitchStru)) + { + reval = CI_ERROR; + } + else + { + reval = CI_SUCCESS; + } + + if (CI_SUCCESS == reval) + { + for (ii = 0u; ii < phySecSum; ii++) + { + chPhySecUseState = GetPhySecUseState(pPhySecDataStru[ii].PhysicalSectionId); + + if (PHYSICAL_SECTION_USING_APPLY == chPhySecUseState) + { + waitSetFlag = 1u; + } + else if (PHYSICAL_SECTION_USING_CANCEL == chPhySecUseState) + { + waitCancelFlag = 1u; + } + else if (PHYSICAL_SECTION_USING_YES == chPhySecUseState) + { + setFlag = 1u; + } + else + { + cancelFlag = 1u; + } + } + + for (ii = 0u; ii < chRouteProSwitchSum; ii++) + { + wProSwRelPhySecId = GetSwitchPhySectionId(pRouteProtectSwitchStru[ii].ProtectSwitchId); + chPhySecUseState = GetPhySecUseState(wProSwRelPhySecId); + + if (PHYSICAL_SECTION_USING_APPLY == chPhySecUseState) + { + waitSetFlag = 1u; + } + else if (PHYSICAL_SECTION_USING_CANCEL == chPhySecUseState) + { + waitCancelFlag = 1u; + } + else if (PHYSICAL_SECTION_USING_YES == chPhySecUseState) + { + setFlag = 1u; + } + else + { + cancelFlag = 1u; + } + } + + if ((0u == waitSetFlag) && (0u == waitCancelFlag) && (1u == setFlag) && (0u == cancelFlag)) + { /**/ + + reval = CI_SUCCESS; + } + else if ((0u == waitSetFlag) && (0u == waitCancelFlag) && (0u == setFlag) && (1u == cancelFlag)) + { /*δ*/ + + reval = CI_ERROR; + } + else if ((1u == waitSetFlag) && (0u == waitCancelFlag) && (1u == setFlag) && (0u == cancelFlag)) + { /*&&ȴ*/ + + reval = RETURN_FIRSTXUANPAI_ERR_WAIT; + } + else if ((0u == waitSetFlag) && (1u == waitCancelFlag) && (0u == setFlag) && (1u == cancelFlag)) + { /*δ&&ȴȡ*/ + + reval = RETURN_FIRSTXUANPAI_ERR_WAIT; + } + else if ((0u == waitSetFlag) && (0u == waitCancelFlag) && (1u == setFlag) && (1u == cancelFlag)) + { /*&&δ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + reval = CI_ERROR; + } + else + { + chAllPhyBelCiCheck = RouteAllPhyBelongCiCheck(routeId); + if (CI_SUCCESS == chAllPhyBelCiCheck) + {/*by cgh 20230606 - ɶ27ν·ڳΣȫ*/ + + if ((1U == waitSetFlag) && (0U == waitCancelFlag) && (0U == setFlag) && (0U == cancelFlag)) + { /*ȴ*/ + + reval = RETURN_FIRSTXUANPAI_ERR_WAIT; + } + else if ((0U == waitSetFlag) && (1U == waitCancelFlag) && (0U == setFlag) && (0U == cancelFlag)) + { /*ȴȡ*/ + + reval = RETURN_FIRSTXUANPAI_ERR_WAIT; + } + else + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + reval = CI_ERROR; + } + } + else + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + reval = CI_ERROR; + } + } + } + return reval; +} + +/* +* ιϽ߼ +* ˵ const UINT16 phySectionId, ID +* ֵ void +*/ +void PhySecFaultUnlockLogicManage(const UINT16 phySectionId,const UINT8 virCIid) +{ + UINT8 phySecLockState = 0U; /*״̬*/ + UINT16 lockBelongRouteId = 0U; /*·ID*/ + UINT8 routeBelongCi = 0U;/*·*/ + UINT8 routeState = 0U; /*·״̬*/ + UINT8 localCiId = 0U; /*ID*/ + UINT8 localCiType = GetLocalCiType(); + UINT16 routeLastSwiPhySecId = 0U; /*·Զ˵ID*/ + UINT8 routeAutoSig = 0U;/*·Զź*/ + UINT8 recoverFlag = 0U;/*ָ־*/ + UINT8 phyFaultUnLockRes = 0U;/*ιϽ*/ + UINT8 routeDir = 0U;/*·*/ + UINT8 routePhySecHaveUnLock = 0U;/*·Ƿѽ*/ + UINT8 routeType = 0U;/*·*/ + + UINT8 phyBelongCi = 0U;/**/ + UINT8 commState = 0U;/*ͨ״̬*/ + /*̵ּ֧ӿڹܿǷѴ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + UINT8 neighbourCi = 0U;/*ID*/ + UINT8 havePhySecFromNeighbourCi = 0U;/*Ƿ*/ + + UINT8 goExec = CI_ERROR; + UINT8 autoTriggerType = 0U; + UINT8 belongvirCIid = 0U; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 chPhyIncLogSum = 0U; /*߼Ŀ*/ + UINT16* pPhyIncLogId = NULL; /*ΰ߼ID*/ + UINT16 wLogLockBelongRouteId = 0U; /*߼·ID*/ + UINT8 ii = 0U; + UINT8 chPhyAllUnlockFlag = 0U;/*ΰ߼Ҫȫ־*/ + UINT8 chRouteLogSecHaveUnLock = 0U;/*߼·Ѿȫ*/ + + if ((0u == phySectionId) || (phySectionId >= PHYSICAL_SECTION_SUM_MAX)) + { + /*IDЧ*/ + goExec = CI_ERROR; + } + else + { + /*ǷԼʽ*/ + goExec = PhySecFaultUnlockRouteCheck(phySectionId, virCIid); + } + + if (CI_SUCCESS == goExec) + { + lockBelongRouteId = GetPhySecRLockBelongRouteId(phySectionId); /*ȡν··ID*/ + LogRouteErrLockFaultManage(phySectionId);/*߼·ʽ⴦*/ + DelayErrLockCmdDeal(phySectionId);/*λ۷·ʽʱιϴ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + routeBelongCi = GetRouteBelongCiId(lockBelongRouteId); + + + if ((localCiId == routeBelongCi)&& (localCiId > 0u)) + {/*·ڱ*/ + + goExec = CheckPhySecFaultUnlockCanDo(phySectionId,virCIid); + if(CI_SUCCESS == goExec) + { + routeState = GetRouteState(lockBelongRouteId); + if ((ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState)) + { /*·״̬Ϊ Ԥȿ||ӽ*/ + routeAutoSig = GetRouteAutoSigProperty(lockBelongRouteId); + if(ROUTE_AUTOSIG_PROPERTY_YES != routeAutoSig) + { + (void)DriveSignalClose(GetRouteStartSignalId(lockBelongRouteId)); /*źŹر*/ + + /*ý·Զ·Ч*/ + SetAutoRouteSetFlag(GetRouteAutoRouteId(lockBelongRouteId), AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(GetRouteAutoReturnId(lockBelongRouteId), AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(lockBelongRouteId), ALL_AUTO_RETURN_SET_NO); + autoTriggerType = GetAutoTriggerType(lockBelongRouteId); + if (ROUTE_TYPE_AUTO_TRIGGER == autoTriggerType) + {/**/ + SetRouteAutoTriggerFlag(lockBelongRouteId, AUTO_TRIGGER_SET_NO); + } + } + } + else if (ROUTE_STATE_LEAD_OPEN == routeState) + {/*·״̬Ϊ */ + (void)DriveSignalClose(GetRouteStartSignalId(lockBelongRouteId)); /*źŹر*/ + } + else + { + phySecLockState = GetPhySecLockState(phySectionId); /*ȡ״̬*/ + /* Ż룺жPSDSPKS۳µźŹرգؿ־λȴؿʱյʽʱؿ־ */ + recoverFlag = GetRouteRecoverOpenFlag(lockBelongRouteId); + if(ROUTE_RECOVER_STA_WAIT == recoverFlag) + {/*ؿȴʱιգؿ־*/ + SetRouteOpenSigStartCycNum(lockBelongRouteId, 0u); /*źſʱ*/ + + SetRouteRepeatOpenFlag(lockBelongRouteId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteXianSuConfirmStt(lockBelongRouteId, ROUTE_XIANSU_CONFIRM_NO); + + SetRouteRecoverState(lockBelongRouteId, ROUTE_RECOVER_STA_STAY);/*ֹ߼ؿ*/ + } + + if ((PHYSICAL_SECTION_LOCK_EXCEPT != phySecLockState) && (ROUTE_STATE_HALF_UNLOCKDELAY != routeState)) + {/*״̬Ϊ"쳣"*/ + SetCiSendCmdBackInfoData(CI_BACK_PSEC_QGJ_UNLOCK, CI_DEVICE_TYPE_PHYSEC, phySectionId, 0u, 0u); + } + else + {/*Ϊʱ*/ + if ((ROUTE_STATE_AUTO_UNLOCKERR == routeState) || (ROUTE_STATE_IDLE == routeState)) + { + /*һ·Σʱ崻ὫΪա + ڱεĹ״̬״̬Ϊ + 쳣գ·״̬Ϊ ROUTE_STATE_IDLEΪʽΣ + ROUTE_STATE_IDLE == routeState + */ + + /*ʽ̹*/ + phyFaultUnLockRes = PhySecFaultUnlockLogicProcess(phySectionId); + if (CI_SUCCESS == phyFaultUnLockRes) + { /*ɹ*/ + routeDir = GetRouteDirection(lockBelongRouteId); + chPhyIncLogSum = GetPhySecIncLogSecSum(phySectionId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(phySectionId); + SetPhySecLockState(phySectionId, PHYSICAL_SECTION_LOCK_NO, lockBelongRouteId, routeDir); /*δ*/ + + if (NULL != pPhyIncLogId) + { + for (ii = 0U; ii < chPhyIncLogSum; ii++) + { + wLogLockBelongRouteId = GetLogSecLockBelongRoute(pPhyIncLogId[ii]); + if (lockBelongRouteId != wLogLockBelongRouteId) + { + chPhyAllUnlockFlag = 1U; + break; + } + } + } + if (1U != chPhyAllUnlockFlag) + { + /*ͬʱڱ·յ߼δ*/ + SetPhyIncludeLogLockState(phySectionId, LOG_SECTION_LOCK_NO, lockBelongRouteId); + } + else + { + /*ͬʱе߼δ*/ + SetPhyIncAllLogLockState(phySectionId, LOG_SECTION_LOCK_NO); + } + + chRouteLogSecHaveUnLock = CheckRouteLogSecHaveUnLock(wLogLockBelongRouteId); + if (CI_SUCCESS == chRouteLogSecHaveUnLock) + { + /*ȫν*/ + SetRouteStateManage(wLogLockBelongRouteId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + + routeLastSwiPhySecId = GetRouteLastSwichPhySecId(lockBelongRouteId); + if (phySectionId == routeLastSwiPhySecId) + {/*·*/ + SetRouteRelProSwitchLockSta(lockBelongRouteId, SWITCH_LOCK_PROTECT_CANCEL);/*ȡ·ķ*/ + } + + havePhySecFromNeighbourCi = RouteHavePhySecBelongOtherCi(lockBelongRouteId, &neighbourCi); + + if ((1u== havePhySecFromNeighbourCi) && (neighbourCi > 0u)) + {/*·*/ + commState = GetLocalCiAndOtherCiTransSta(neighbourCi); + + } + if ((1U== havePhySecFromNeighbourCi) && (neighbourCi > 0u) && + (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + {/*,ұͨжϣ̵ּ֧ӿڹܿѴ򿪣Ҽ̵ӿȷ*/ + routePhySecHaveUnLock = CheckLocalCiRoutePhySecUnLock(lockBelongRouteId); + } + else + { + routePhySecHaveUnLock = CheckRoutePhySecHaveUnLock(lockBelongRouteId); + } + if (CI_SUCCESS == routePhySecHaveUnLock) + { + /*ý·Զ·Ч*/ + SetAutoRouteSetFlag(GetRouteAutoRouteId(lockBelongRouteId), AUTO_ROUTE_SET_NO); + + SetAutoReturnSetFlag(GetRouteAutoReturnId(lockBelongRouteId), AUTO_RETURN_SET_NO); + + SetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(lockBelongRouteId), ALL_AUTO_RETURN_SET_NO); + + if (ROUTE_TYPE_AUTO_TRIGGER == GetAutoTriggerType(lockBelongRouteId)) + {/**/ + SetRouteAutoTriggerFlag(lockBelongRouteId, AUTO_TRIGGER_SET_NO); + } + + SetRouteStateManage(lockBelongRouteId, ROUTE_STATE_IDLE); /*ȫý·*/ + } + else + { + /*,ǰΪ·ķһΣʽ⵱ǰκΪ޲*/ + routeType = GetRouteType(lockBelongRouteId); + if ((CI_TYPE_CLD == localCiType) && (ROUTE_TYPE_DIAOCHE == routeType)) + {/*ε·ʽ⴦*/ + (void)CLDPhySectionFaultUnlockDeal(phySectionId,lockBelongRouteId); + } + } + + } + + } + } + } + } + + } + else if ((localCiId != routeBelongCi) && (localCiId > 0u)) + {/*·ΪұIDϷ*/ + /*̵ӿ£ʽڱ·飺 + 1. ڱ / + 2. ̵ӿ / + 3. ̵ӿȷ / + 4. ·ͨж / + 5. ʽͨPhySecFaultUnlockLogicProcess + 1~5ͨʽΣ + 6. ·ڱζУδգ·״̬ΪС + */ + phyBelongCi = GetPhySecBelongCiId(phySectionId); + + commState = GetLocalCiAndOtherCiTransSta(routeBelongCi); + + if ((phyBelongCi == localCiId) && (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + phyFaultUnLockRes = PhySecFaultUnlockLogicProcess(phySectionId); + if (CI_SUCCESS == phyFaultUnLockRes) + { /*ɹ*/ + routeDir = GetRouteDirection(lockBelongRouteId); + SetPhySecLockState(phySectionId, PHYSICAL_SECTION_LOCK_NO, lockBelongRouteId, routeDir); /*δ*/ + /*ͬʱڱ·յ߼δ*/ + SetPhyIncludeLogLockState(phySectionId,LOG_SECTION_LOCK_NO,lockBelongRouteId); + routeLastSwiPhySecId = GetRouteLastSwichPhySecId(lockBelongRouteId); + if (phySectionId == routeLastSwiPhySecId) + {/*·*/ + SetRouteRelProSwitchLockSta(lockBelongRouteId, SWITCH_LOCK_PROTECT_CANCEL);/*ȡ·ķ*/ + } + + /*̵ӿ¼DZĽ·ڣڱǷѽ*/ + routePhySecHaveUnLock = CheckNoLocalCiRoutePhySecUnLock(lockBelongRouteId); + if (CI_SUCCESS == routePhySecHaveUnLock) + { + SetRouteStateManage(lockBelongRouteId, ROUTE_STATE_IDLE); /*ȫνý·*/ + } + else + { + /*,ǰΪ·ķһΣʽ⵱ǰκΪ޲*/ + routeType = GetRouteType(lockBelongRouteId); + if ((CI_TYPE_CLD == localCiType) && (ROUTE_TYPE_DIAOCHE == routeType)) + {/*ε·ʽ⴦*/ + (void)CLDPhySectionFaultUnlockDeal(phySectionId,lockBelongRouteId); + } + } + + + } + } + else if((phyBelongCi == localCiId)&&(TRANSMIT_STATE_GOOD == commState)) + { + if(FUNC_SWITCH_ON == includeVirFlag) + { + belongvirCIid = GetPhySecBelongVirCiId(phySectionId); + if((belongvirCIid == virCIid)&&(0u != virCIid))/*ʽֵزڲܲ*/ + { + /*·ڱʱιϽ */ + AddCiSendToCiCmdInfo(CI_CMD_SECTION_FAULT_UNLOCK,phySectionId,0u,routeBelongCi); + } + } + else + { + /*·ڱʱιϽ */ + AddCiSendToCiCmdInfo(CI_CMD_SECTION_FAULT_UNLOCK,phySectionId,0u,routeBelongCi); + } + } + else + { + /*쳣ʽ*/ + } + } + else + {/*쳣*/ + + } + + } + +} + +/* +* ·ڵһռõ֮ǰó쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetRoutePhySecExpLockToOccupy(const UINT16 routeId) +{ + UINT8 phySecSum = 0u; /**/ + UINT8 ii = 0u; /**/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + + + phySecSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(routeId); /*ȡ·*/ + + + if (NULL == pPhySecDataStru) + { + return; + } + else + { + ; + } + + + for (ii = 0u; ii < phySecSum; ii++) + { + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(pPhySecDataStru[ii].PhysicalSectionId))/*жϷŵǰ棬֤ǰռõβᱻó쳣*/ + { + break; + } + else + { + ; + } + + SetPhySecLockState(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, GetRouteDirection(routeId)); /*״̬*/ + + /*ͬʱڱ·յ߼쳣*/ + SetPhyIncludeLogLockState(pPhySecDataStru[ii].PhysicalSectionId,LOG_SECTION_LOCK_EXCEPT,routeId); + } +} + +/* +* жϽ·ʼźŻⷽͬʱռѹ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERRORͬʱռѹ +* CI_SUCCESSͬʱռѹ +*/ +UINT8 RouteInOutSecOccupy(const UINT16 routeId) +{ + UINT16 startSigId = 0u; /*·ʼźŻID*/ + UINT16 outPhySecId = 0u; /*źŻⷽһID*/ + UINT16 inPhySecId = 0u; /*źŻڷһID*/ + + UINT8 retResult = CI_ERROR; + + startSigId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + if (0u == startSigId) + { + retResult = CI_ERROR; + } + else + { + inPhySecId = GetSignalInFirstPhySecId(startSigId,routeId); /*źŻڷһID*/ + outPhySecId = GetSignalOutFirstPhySecId(startSigId); /*źŻⷽһID*/ + + if (0u == inPhySecId) + { + retResult = CI_ERROR; + } + else + { + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(inPhySecId)) + { /*ڷռ*/ + + if (0u == outPhySecId) + { + retResult = CI_SUCCESS; + } + else + { + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(outPhySecId)) + { /*ⷽռ*/ + + retResult = CI_SUCCESS; + } + } + } + } + } + + return retResult; +} + +/* +* жǷҪгʻ·־Ҫ +* ˵ const UINT16 routeId·ID +* ֵ void +*/ +void TryClearRouteTrainEnterFlag(UINT16 routeId) +{ + UINT16 tempDevId = 0u; /*豸ID*/ + UINT8 tempDevSta = 0u; /*豸״̬*/ + + if (0u != routeId) + { + /*·״̬ΪУǽ·ξûռãгʻ־*/ + if (ROUTE_STATE_IDLE == GetRouteState(routeId)) + { + SetRouteTrainEnterFlag(routeId, ROUTE_TRAIN_ENTER_FLAG_NO); + } + else + { + if (CI_SUCCESS == RouteAllSecOccuClearCheck(routeId, &tempDevId, &tempDevSta)) + { + SetRouteTrainEnterFlag(routeId, ROUTE_TRAIN_ENTER_FLAG_NO); + } + } + } +} + +#if 0 +/* +* ۳SPKSPSDźŹرؿ +* ˵ const UINT16 routeId·ID +* ֵ void +*/ +void RouteAutoReOpenProc(const UINT16 routeId) +{ + UINT8 routeState; /*·״̬*/ + UINT16 startSig; /*·ʼźŻID*/ + UINT16 *psdBuf = NULL; /*źŻPSD ID*/ + UINT8 psdSum = 0u; /*źŻPSDĿ*/ + + UINT8 psdFlag = 0u; + UINT8 detainFlag = 0u; + UINT8 spksFlag = 0u; + UINT8 toOpenFlag = 0u; + UINT8 i; + UINT16 psdCloseRoute, psdReOpenRoute; + + if (0u != routeId) + { + routeState = GetRouteState(routeId); + startSig = GetRouteStartSignalId(routeId); + psdBuf = GetSignalRelatedPsdBuf(startSig); + psdSum = GetSignalRelatedPsdSum(startSig); + /*ֻΪֳжϵһ߼οΪ˶гƽм*/ + if (((ROUTE_STATE_NEAR_LOCKERR == routeState) || (ROUTE_STATE_YUXIAN_LOCK == routeState)) && (GetLogSecCurOccupyState(GetRouteInFirstLogSecId(routeId)) == LOGICSECTION_OCCUPY_NO)) + { + if ((NULL == psdBuf)|| (0u == psdSum)) + { + psdFlag = 1u; + } + else + { + psdFlag = 1u; + for (i = 0u;i < psdSum;i++) + { + psdCloseRoute = GetPsdClosedRouteId(psdBuf[i]); + psdReOpenRoute = GetPsdToBeOpenedRoute(psdBuf[i]); + + if (routeId == psdReOpenRoute) + { + /*һЧpsdźؿĽ·״̬*/ + SetPsdToBeOpenedRoute(psdBuf[i], 0u); + toOpenFlag = 1u;/*ؿ*/ + } + else + { + if ((0u == psdReOpenRoute) && (0u == psdCloseRoute)) + { + /*do nothing*/ + } + else + {/*PSDδָ*/ + psdFlag = 0u; + + break; + } + } + } + } + + detainFlag = 1u; + if (ROUTE_DETAIN_RE_OPEN_SIG_YES == GetRouteDetainReOpenSigFlag(routeId)) + { + /*һЧ*/ + SetRouteDetainReOpenSigFlag(routeId, ROUTE_DETAIN_RE_OPEN_SIG_NO); + toOpenFlag = 1u;/*ؿ*/ + } + else + { + if (ROUTE_DETAIN_CLOSE_SIG_YES == GetRouteDetainToRouteCloseFlag(routeId)) + {/*۳δָ*/ + detainFlag = 0u; + } + } + + spksFlag = 1u; + if (ROUTE_SPKS_RE_OPEN_SIG_YES == GetRouteSpksReOpenSigFlag(routeId)) + { + /*һЧ*/ + SetRouteSpksReOpenSigFlag(routeId, ROUTE_SPKS_RE_OPEN_SIG_NO); + toOpenFlag = 1u;/*ؿ*/ + } + else + { + if (ROUTE_CLOSE_SPKS_YES == GetSPKSToRouteCloseFlag(routeId)) + {/*spksδָ*/ + spksFlag = 0u; + } + } + + if ((1u == psdFlag) && (1u == detainFlag) && (1u == spksFlag) && (1u == toOpenFlag)) + { + SetRouteOpenSigStartCycNum(routeId, Get2oo2CurCycleNum()); + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_YES);/*ý·źؿ־*/ + } + } + else + { + /*ԶؿźŵijѾ㣬ҪйԶؿźŵı*/ + SetSPKSToRouteCloseFlag(routeId, ROUTE_CLOSE_SPKS_NO); + SetRouteSpksReOpenSigFlag(routeId, ROUTE_SPKS_RE_OPEN_SIG_NO); + + SetRouteDetainCloseFlag(routeId, ROUTE_DETAIN_CLOSE_SIG_NO); + SetRouteDetainReOpenSigFlag(routeId, ROUTE_DETAIN_RE_OPEN_SIG_NO); + + if (NULL != psdBuf) + { + for (i = 0u;i < psdSum;i++) + { + psdCloseRoute = GetPsdClosedRouteId(psdBuf[i]); + psdReOpenRoute = GetPsdToBeOpenedRoute(psdBuf[i]); + + if ((routeId == psdCloseRoute) || (routeId == psdReOpenRoute)) + { + SetPsdClosedRouteId(psdBuf[i], 0u); + SetPsdToBeOpenedRoute(psdBuf[i], 0u); + } + } + } + } + } +} +#endif +/* +* ·쳣δ +* ˵ const UINT16 routeId·ID +* ֵ +*/ +void RouteExpLockContinue(UINT16 routeId) +{ + UINT16 dwRouteLogSum = 0U; /*ý·߼Ŀ*/ + UINT16* pRouteLogId = NULL; /*·߼ID*/ + UINT16 i = 0U; + UINT16 wFirstNormalLockLogId = 0U;/*һյ߼id*/ + UINT8 chLogSecState = 0U;/*߼״̬*/ + UINT16 wLockRouteId = 0U;/*߼·ID*/ + UINT16 wRelativePhySecId = 0U;/*߼*/ + UINT16 wRelativePhyLockRoute = 0U; /*߼ι·*/ + + /*·һռõǰѾû̹Ҫһյİ׹ó̹֤ûܼ*/ + dwRouteLogSum = GetRouteLogSectionSum(routeId); /*ý·Ŀ*/ + pRouteLogId = GetRouteLogSectionIdBuf(routeId); /*·*/ + + for (i = 0u;i < dwRouteLogSum;i++) + { + chLogSecState = GetLogSecLockState(pRouteLogId[i]); + wLockRouteId = GetLogSecLockBelongRoute(pRouteLogId[i]); + + if ((LOG_SECTION_LOCK_NORMAL == chLogSecState) && (wLockRouteId == routeId)) + { + if (0u == wFirstNormalLockLogId) + { + wFirstNormalLockLogId = pRouteLogId[i];/*¼·ڵһյ*/ + } + } + + if (((LOG_SECTION_LOCK_EXCEPT == chLogSecState)) && (wLockRouteId == routeId)) + { + break; + } + } + + if (i == dwRouteLogSum) + {/*˵·Ѿ̹*/ + if (0u != wFirstNormalLockLogId) + { + wRelativePhySecId = GetLgcSecRelativePhySecId(wFirstNormalLockLogId); + wRelativePhyLockRoute = GetPhySecRLockBelongRouteId(wRelativePhySecId); + if (SECTION_OCCUPY_NO == GetPhySecCurMergeState(wRelativePhySecId)) + { + if (routeId == wRelativePhyLockRoute) + {/*߼·Ϊ·ͬʱ쳣*/ + SetPhySecLockState(wRelativePhySecId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, GetRouteDirection(routeId)); + } + else + { + /*ͬʱιմ*/ + } + /*ͬʱڱ·յ߼쳣*/ + SetPhyIncludeLogLockState(wRelativePhySecId,LOG_SECTION_LOCK_EXCEPT,routeId); + } + } + } +} + +/* +* SPKSPSD۳ָؿźŴ +* ˵ const UINT16 routeId·ID +* ֵ void +*/ +void RouteRecoverOpenProc(const UINT16 routeId) +{ + UINT8 routeState; /*·״̬*/ + UINT8 recoverState = ROUTE_RECOVER_STA_STAY;/*ǰָؿ״̬*/ + UINT8 errType = CI_ERROR; + UINT8 localCiType = GetLocalCiType();/**/ + + routeState = GetRouteState(routeId); + recoverState = GetRouteRecoverOpenFlag(routeId); + + if ((ROUTE_STATE_NEAR_LOCKERR == routeState) || (ROUTE_STATE_YUXIAN_LOCK == routeState) || (ROUTE_STATE_FIRST_LOCKERR == routeState)) + { + if (ROUTE_RECOVER_STA_WAIT == recoverState) + { + if ((CI_TYPE_ZX == localCiType) || (CI_TYPE_SCX == localCiType)) + { + errType = RecoverOpenRouteCheck(routeId); + } + else + { + errType = RecoverOpenRouteCheckCLD(routeId); + } + + if (errType == CI_SUCCESS) + { + SetRouteOpenSigStartCycNum(routeId, Get2oo2CurCycleNum()); + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_YES); /*ý·źؿ־*/ + + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_INIT);/*һЧֹؿ*/ + } + else if (errType == CI_ROUTE_RECOVER_ERR) + { + /*ȴ*/ + } + else + { + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY);/*һPSDSPKS۳㣬·ָ״̬Ϊɻָ*/ + } + } + } + +} + +/* ATSֵձ +* ˵ const UINT16 expLkOverlapId, ATSֵط͵ID +* ֵ void +*/ +void SetAtsExpectLockOverlapIdProc(const UINT16 expLkOverlapId,const UINT8 lockType) +{ + /*н·жϽ·ǷñΣҽ·״̬Ƿձ + ý·ձΡ*/ + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT16 ii = 0u; + UINT16 routeOverlapSum = 0u; /*·Ŀ*/ + UINT16 routeId = 0u; /*·ID*/ + UINT16 routedLockOverlapId = 0u; /*·չOverlapId*/ + UINT8 retVal = CI_SUCCESS; /*ִм*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 preOverlepId = 0u; + UINT32 startXuanPaiCyc = 0u; + UINT16 phySectionId = 0u; + UINT8 phySectionSta = 0u; + UINT8 flag = 0u; + UINT8 belongCiId = 0u; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 virCIid = 0u; + UINT8 ciCtrModeFlag = 0u; + + if ((0u == expLkOverlapId) || (UINT16_MAX == expLkOverlapId)) + {/*жЧ*/ + retVal = CI_ERROR; + } + + /*жǷҪݱν*/ + if (CI_SUCCESS == retVal) + { + belongCiId = GetOverlapBelongCiId(expLkOverlapId); + + if(localCiId != belongCiId) + { + if(0u < belongCiId) + { + AddCiSendToCiCmdInfo(CI_CMD_LOCK_OVERLAP_CMD,expLkOverlapId,lockType,belongCiId);/*ν*/ + } + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = GetRouteId(ii); /*ȡ·ID*/ + + if ((0u == routeId) || (routeId > ROUTE_SUM_MAX)) + { + /*·IDЧִ*/ + } + else + { + routeOverlapSum = GetRouteOverlapSum(routeId); /*ȡ·ıĿ*/ + + if (routeOverlapSum >= 1u) + {/*ֻе·ıĿڵ1ʱATSֵزŷձID*/ + /*IDǷڵǰ· ҽ·δչ*/ + if (1u == checkExpOverlapBelongToRtOrNot(routeId,expLkOverlapId)) + {/*յıIDڽ·ıID*/ + flag = 1u;/*һƥ䵽ˣΪ1*/ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + /*add by shl*/ + if (retVal == CI_SUCCESS) + { + preOverlepId = GetRouteAtsExpLkOverlapId(routeId); + + if (preOverlepId > 0u) + { + startXuanPaiCyc = GetOverlapXuanPaiStartCycNum(preOverlepId); + if (startXuanPaiCyc > 0u) + { + retVal = CI_ERROR; + } + } + } + /*жϵǰģʽǷӦձ*/ + if (CI_SUCCESS == retVal) + { + virCIid= GetOverlapBelongVirCiId(expLkOverlapId); + if(FUNC_SWITCH_ON == includeVirFlag) + { + ciCtrModeFlag = GetVirCImode(virCIid);/*ȡģʽ*/ + } + else + { + ciCtrModeFlag = GetCiModeFlag(); /*ȡģʽ*/ + } + + if((CI_MODE_CI_LOCAL ==ciCtrModeFlag)||(0u ==ciCtrModeFlag))/*ػ߻ȡ󣬷ֵزӦ˹*/ + { + retVal = CI_ERROR; + } + } + + /*add by shl*/ + + if (CI_SUCCESS == retVal) + { + + routedLockOverlapId = GetRouteOverlapLockedId(routeId); /*ȡ·չID*/ + + if (0u == routedLockOverlapId) + { + /*жϽ·״̬Ƿձձ*/ + routeState = GetRouteState(routeId); + + if ((routeState == ROUTE_STATE_FIRST_XUANPAI) || + (routeState == ROUTE_STATE_XUANPAI) || + (routeState == ROUTE_STATE_FIRST_LOCK) || + (routeState == ROUTE_STATE_FIRST_LOCKERR) || + (routeState == ROUTE_STATE_YUXIAN_OPEN) || + (routeState == ROUTE_STATE_YUXIAN_LOCK) || + (routeState == ROUTE_STATE_NEAR_OPEN) || + (routeState == ROUTE_STATE_NEAR_LOCK) || + (routeState == ROUTE_STATE_NEAR_LOCKERR) || + (routeState == ROUTE_STATE_AUTO_UNLOCK) || + (routeState == ROUTE_STATE_HALF_UNLOCK) + ) + {/*ָID·ձID*/ + if(LABOR_LOCK_OVERLAP == lockType)/*˹*/ + { + SetOverlapAtsOrlaborLockCmdFlag(expLkOverlapId,LOCK_OVERLAP_CMD_YES);/*ñ־ڱνʱ*/ + SetOverlaplaborLockCmdFlag(expLkOverlapId,LOCK_OVERLAP_CMD_YES);/*˹ձ־˹һЧ*/ + } + else if(ATS_LOCK_OVERLAP == lockType)/*ATS*/ + { + phySectionId = GetRouteLastPhySectionId(routeId); + phySectionSta = GetPhySecCurMergeState(phySectionId); + if(SECTION_OCCUPY_YES==phySectionSta) + { + SetOverlapAtsOrlaborLockCmdFlag(expLkOverlapId,LOCK_OVERLAP_CMD_YES);/*ñ־*/ + } + } + else + { + /*ʲôҲ*/ + } + SetRouteAtsExpLkOverlapId(routeId,expLkOverlapId); + SetOverlapFromSetRouteCmdFlag(expLkOverlapId, OVERLAP_ROUTE_FLAG_NO);/*־*/ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + + } + + } + + } + } + } + if(0U == flag) + {/*͵βκν·ıλ߽·ձδ*/ + /*ֵ*/ + SetErrorData(EFUNC_SetAtsExpectLockOverlapIdProc, CI_DEVICE_TYPE_OVERLAP, expLkOverlapId, ETYPE_ROUTE_OVERLAP_UNLOCK, 0U, ESEND_LEVEL_ATS); + } + + } +} + +/* +* ιϽ +* ˵ const UINT16 phySectionId, ID +* const UINT8 virCIid Rtu(ֵ) ID +* ֵ CI_ERROR CI_SUCCESS +*/ +UINT8 CheckPhySecFaultUnlockCanDo(const UINT16 phySectionId,const UINT8 virCIid) +{ + UINT16 lockBelongRouteId = 0u; /*·ID*/ + UINT8 reVal = CI_ERROR; + UINT8 belongvirCIid = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 isErrLock = CI_ERROR; + UINT8 phyLockState = 0U; + + + if ((0u == phySectionId) || (PHYSICAL_SECTION_SUM_MAX <= phySectionId)) + { + /*IDЧ*/ + reVal = CI_ERROR; + } + else + { + lockBelongRouteId = GetPhySecRLockBelongRouteId(phySectionId); /*ȡν··ID*/ + + if ((0u == lockBelongRouteId) || (ROUTE_SUM_MAX <= lockBelongRouteId)) + { + /*·IDЧ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + } + if(CI_SUCCESS == reVal) + { + if(FUNC_SWITCH_ON == includeVirFlag) + { + belongvirCIid = GetRouteBelongVirCiId(lockBelongRouteId); + if(0u < virCIid) + { + if(virCIid == belongvirCIid) + { + reVal = CI_SUCCESS; /*Rtu(ֵ)ԲڱĽ·յʽ⣬۸ǷڸRtu*/ + } + else + { + belongvirCIid = GetPhySecBelongVirCiId(phySectionId); + if(belongvirCIid == virCIid) + { + reVal = CI_SUCCESS;/*·յģڸRtuϲʽ*/ + } + else + { + reVal = CI_ERROR; + } + } + } + else + { + reVal = CI_ERROR; + } + + } + else + { + reVal = CI_SUCCESS; + } + } + + /*˳·쳣*/ + if (CI_SUCCESS == reVal) + { + isErrLock = RouteFirstLockErrCheck(lockBelongRouteId); + phyLockState = GetPhySecLockState(phySectionId); + /*һյǹ*/ + if (CI_SUCCESS == isErrLock ) + { + /*´Ϊ*/ + if (PHYSICAL_SECTION_LOCK_EXCEPT == phyLockState) + { + /*ɽ*/ + } + else + { + /*ʧܣδ˳*/ + reVal = CI_ERROR; + SetCiSendCmdBackInfoData(CI_BACK_PSEC_QGJ_LOCKERROR, CI_DEVICE_TYPE_PHYSEC, phySectionId, 0U, 0U); + } + } + else + { + /*ִ*/ + } + } + + return reVal; +} + +/* +* ý·߼״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteLogSectionLockState(const UINT16 routeId, const UINT8 lockState) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT8 curLockState = 0u; /*εǰ״̬*/ + UINT16 validRouteId = 0u; + UINT8 routeDir = 0u; + UINT8 validRouteDir = 0u; + UINT8 chTrainSum = 0U; + LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + LogicTrainResStruct *pstLgcResInfo = NULL; + /*ȡ·߼Ϣ*/ + logSectionSum = GetRouteLogSectionSum(routeId); + pLogIdBuff = GetRouteLogSectionIdBuf(routeId); + routeDir = GetRouteDirection(routeId); + + + /*ݺϷ*/ + if((0u != logSectionSum) && (NULL != pLogIdBuff)) + { + for(i = 0u; i < logSectionSum; i++) + { + /**/ + if(LOG_SECTION_LOCK_NORMAL == lockState) + { + curLockState = 0u; + /*ȡǰ״̬*/ + curLockState = GetLogSecLockState(pLogIdBuff[i]); + /*ջʱ*/ + if((LOG_SECTION_LOCK_NORMAL == curLockState) || (LOG_SECTION_LOCK_DELAY == curLockState)) + { + validRouteId = GetLogSecLockBelongRoute(pLogIdBuff[i]); + validRouteDir = GetRouteDirection(validRouteId); + /*֮ǰ·δ*/ + chTrainSum = GetLogSecTrainInfoSum(pLogIdBuff[i]); + pstLgcResInfo = GetLogSecTrainInfo(pLogIdBuff[i]); + if (NULL != pstLgcResInfo) + { + (void)ComMemCopy(pstLgcResInfo, stTmpResInfo,(UINT16)(sizeof(LogicTrainResStruct)*LOGIC_SECTION_RES_SUM_MAX)); + } + SetLogSecLockState(pLogIdBuff[i],LOG_SECTION_LOCK_NO,validRouteId,validRouteDir);/*֮ǰ·δ*/ + } + + /*ڵǰ·*/ + SetLogSecLockState(pLogIdBuff[i],LOG_SECTION_LOCK_NORMAL,routeId,routeDir); + + if (NULL != pstLgcResInfo) + { + CpyLgcSecResTrain(pLogIdBuff[i], chTrainSum, stTmpResInfo);/*߼гԴϢ*/ + } + } + /*δ*/ + else if(LOG_SECTION_LOCK_NO == lockState) + { + SetLogSecLockState(pLogIdBuff[i],LOG_SECTION_LOCK_NO,routeId,routeDir); + } + /*ι*/ + else if (LOG_SECTION_LOCK_EXCEPT == lockState) + { + SetLogSecLockState(pLogIdBuff[i],LOG_SECTION_LOCK_EXCEPT,routeId,routeDir); + } + else + { + /**/ + } + } + } + else + { + /**/ + } +} + +/* +* @brief ý·Դ־ +* @param const UINT16 wRouteId, ·ID +* const UINT8 chShrFlag, ״̬ +* @return void +*/ +void SetRouteLgcSecShareFlag(const UINT16 wRouteId, const UINT8 chShrFlag) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT8 chLogLockState = 0u; + + /*ȡ·߼Ϣ*/ + logSectionSum = GetRouteLogSectionSum(wRouteId); + pLogIdBuff = GetRouteLogSectionIdBuf(wRouteId); + + /*ݺϷ*/ + if ((MAX_ROUTE_IN_LT_NUM >logSectionSum) + && (NULL != pLogIdBuff)) + { + /*Ϸ*/ + for (i = 0u; i < logSectionSum; i++) + { + if (LOGIC_SECTION_RES_SHARE_NO == chShrFlag) + {/*·ʱղ÷ǹԴ*/ + chLogLockState = GetLogSecLockState(pLogIdBuff[i]); + if (LOG_SECTION_LOCK_NO == chLogLockState) + { + /*߼ιԴ־*/ + SetLogSecResShareFlag(pLogIdBuff[i], chShrFlag); + } + else + { + ; /*ʱ÷ǹԴ*/ + } + } + else + { + /*߼ιԴ־*/ + SetLogSecResShareFlag(pLogIdBuff[i], chShrFlag); + } + } + + } + else + { + /**/ + } +} + +/* +* @brief ý·ιԴ־ +* @param const UINT16 wRouteId, ·ID +* const UINT16 wOverlapId ID +* const UINT8 chShrFlag, ״̬ +* @return void +*/ +void SetRouteOvlpOtherCiShrFlg(const UINT16 wRouteId, const UINT16 wOverlapId,const UINT8 chShrFlag) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 wOverlapIncLgcIdSum = 0U; + UINT16 *pOverLapIncLgcIdBuf = NULL; + UINT16 wRouteLockedOverlapId = 0U; + UINT8 chOverlapBelongCiId = 0U; + UINT8 chLocalCiId = 0U; + + chLocalCiId = GetSystemParaLocalCiId(); + + + wRouteLockedOverlapId = GetRouteOverlapLockedId(wRouteId); + chOverlapBelongCiId = GetOverlapBelongCiId(wRouteLockedOverlapId); + + + if ((0U != wRouteLockedOverlapId) && (wOverlapId== wRouteLockedOverlapId)) + { + if ((chLocalCiId == chOverlapBelongCiId) + && (0U != chLocalCiId)) + { + wOverlapIncLgcIdSum = GetOverlapLogicSectionSum(wRouteLockedOverlapId); + pOverLapIncLgcIdBuf = GetOverlapLogicSectionBuf(wRouteLockedOverlapId); + + if ((OVLP_LOGICSECTION_SUM_MAX > wOverlapIncLgcIdSum) + && (NULL != pOverLapIncLgcIdBuf)) + { + for (i = 0u; i < wOverlapIncLgcIdSum; i++) + { + /*ñ߼ιԴ־*/ + SetLogSecResShareFlag(pOverLapIncLgcIdBuf[i], chShrFlag); + } + } + } + else + { + ; /**/ + } + } +} + +/* +* ݽ·״̬ر־ +* ˵ const UINT16 routeId ·ID +* ֵ void +* cgh-ϲCID-2341-5 +*/ +void ClearSomeFlagDependRouteState(const UINT16 routeId) +{ + UINT8 routeState = GetRouteState(routeId); + UINT16 startSignalId = 0u; + UINT16 EnginVehicCroCloBelongRoute = 0u; + + /*̳ѹź·,̳ѹ״̬*/ + if ((ROUTE_STATE_YUXIAN_LOCK != routeState) + && (ROUTE_STATE_NEAR_LOCK != routeState) + && (ROUTE_STATE_NEAR_LOCKERR != routeState) + && (ROUTE_STATE_DELAY_UNLOCK != routeState) + && (ROUTE_STATE_AUTO_UNLOCK != routeState) + && (ROUTE_STATE_AUTO_UNLOCKERR != routeState) + && (ROUTE_STATE_LEAD_LOCK != routeState) + && (ROUTE_STATE_LEAD_LOCKERR != routeState) + && (ROUTE_LONG_STATE_LOCK != routeState))/*·״̬*/ + { + + startSignalId = GetRouteStartSignalId(routeId); + EnginVehicCroCloBelongRoute = GetEnginVehicCroCloBelongRoute(startSignalId); + + if (EnginVehicCroCloBelongRoute == routeId) + { + SetSigEnginVehicCrossCloseSte(startSignalId, ENGIN_VEHIC_CROSSCLOSE_STE_NO);/*ݽ·״̬̳ѹ״̬*/ + SetEnginVehicCroCloBelongRoute(startSignalId, 0u);/*̳ѹź·*/ + } + + } + + /*·״̬·Ͻ·־*/ + if ((ROUTE_STATE_YUXIAN_LOCK != routeState) + && (ROUTE_STATE_NEAR_LOCK != routeState) + && (ROUTE_STATE_FIRST_LOCK != routeState) + && (ROUTE_STATE_FIRST_LOCKERR != routeState) + && (ROUTE_STATE_NEAR_LOCKERR != routeState) + && (ROUTE_STATE_YUXIAN_OPEN != routeState) + && (ROUTE_STATE_NEAR_OPEN != routeState) + )/*·ڳ쳣ԤգԤȿţӽգӽţӽ쳣*/ + { + SetRouteGroupRouteCmdFlag(routeId, ROUTE_GROUPROUTE_CMD_NO); /*·Ͻ·־*/ + } +} + +/* +* λ۷·ʽʱιϴ +* ˵ const UINT16 phySectionId ID +* ֵ void +* cgh-20230508 +*/ +void DelayErrLockCmdDeal(const UINT16 phySectionId) +{ + UINT8 chPhyIncLogSum = 0U; /*߼Ŀ*/ + UINT16* pPhyIncLogId = NULL; /*ΰ߼ID*/ + UINT8 ii = 0U; /*ΰ߼ѭ*/ + UINT16 wLogLockBelongRouteId = 0U; /*߼·ID*/ + UINT8 chLogSecLockState = 0U; /*߼״̬*/ + UINT16 wFirstNormalLockLogId = 0U; /*·һյ߼ID*/ + UINT8 chLogLockRouteState = 0U; /*߼·״̬*/ + UINT16 wPhyLockBelongRouteId = 0U;/*·*/ + UINT8 chPhyLockState = 0U;/*״̬*/ + UINT8 chPhyLockRouteState = 0U;/*·״̬*/ + UINT8 chPhySecCurMergeState = 0U;/*ں״̬*/ + + + chPhyIncLogSum = GetPhySecIncLogSecSum(phySectionId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(phySectionId); + wPhyLockBelongRouteId = GetPhySecRLockBelongRouteId(phySectionId); + chPhySecCurMergeState = GetPhySecCurMergeState(phySectionId); + chPhyLockState = GetPhySecLockState(phySectionId); + + if ((NULL != pPhyIncLogId) && (SECTION_OCCUPY_NO == chPhySecCurMergeState)) + { + for (ii = 0U; ii < chPhyIncLogSum; ii++) + { + wLogLockBelongRouteId = GetLogSecLockBelongRoute(pPhyIncLogId[ii]); + if (wLogLockBelongRouteId >= ROUTE_SUM_MAX) + { + /*·IDЧ*/ + break; + } + else + { + /*߼*/ + } + + chLogLockRouteState = GetRouteState(wLogLockBelongRouteId); + chLogSecLockState = GetLogSecLockState(pPhyIncLogId[ii]); + wFirstNormalLockLogId = GetRouteFirstNormalLockLogId(wLogLockBelongRouteId); + if ((ROUTE_STATE_HALF_UNLOCK == chLogLockRouteState) && (LOG_SECTION_LOCK_NORMAL == chLogSecLockState) && (wFirstNormalLockLogId == pPhyIncLogId[ii])) + { + /*߼·ڵȴ˹&&&&߼ǶӦ·һյ߼,򽫸οʼϽʱöӦ·״̬*/ + /*ý·״̬Ϊ߼ʱ״̬·һյ߼ʱιʼں*/ + SetRouteStateManage(wLogLockBelongRouteId, ROUTE_STATE_HALF_UNLOCKDELAY); + + /*by cgh 20231002 뵱ǰ߼·ͬҵǰֻһ߼δ״̬ʱҪյĽ·״̬Ϊ߼ʱ״̬*/ + chPhyLockRouteState = GetRouteState(wPhyLockBelongRouteId); + if ((0U != wPhyLockBelongRouteId) && (wLogLockBelongRouteId != wPhyLockBelongRouteId) + && (ROUTE_STATE_HALF_UNLOCK == chPhyLockRouteState) && (PHYSICAL_SECTION_LOCK_NORMAL == chPhyLockState)) + { + SetRouteStateManage(wPhyLockBelongRouteId, ROUTE_STATE_HALF_UNLOCKDELAY); + } + + } + else + { + /*޲*/ + } + } + } +} + + +/* +* ý·״̬, Ҫִ߼մ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteHalfPhySectionLockState(const UINT16 routeId, const UINT8 lockState) +{ + UINT8 phySecSum = 0u; /**/ + UINT8 curLockState = 0u; /*εǰ״̬*/ + UINT16 validRouteId = 0u; /*ҪЧ·ID*/ + UINT8 ii = 0u; /**/ + UINT8 jj = 0U; + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT16 szRouteHalfPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; + UINT8 phyLgcSecSum = 0U; + UINT8 keepWork = CI_ERROR; + UINT16 *pPhyLgcSecBuf = NULL; + UINT16 lgcRLockId = 0U; + + + phySecSum = GetRouteHalfPhysicalSecData(routeId, szRouteHalfPhySecData); + if (0u == phySecSum) + { + keepWork = CI_ERROR; + } + else + { + keepWork = CI_SUCCESS; + + for (ii = 0u; ii < phySecSum; ii++) + { + + phyLgcSecSum = GetPhySecIncLogSecSum(szRouteHalfPhySecData[ii]); + pPhyLgcSecBuf = GetPhySecIncLogSecIdBuf(szRouteHalfPhySecData[ii]); + if (PHYSICAL_SECTION_LOCK_NORMAL == lockState) + { /**/ + + curLockState = 0u; + curLockState = GetPhySecLockState(szRouteHalfPhySecData[ii]); /*ȡεǰ״̬*/ + + if ((PHYSICAL_SECTION_LOCK_NORMAL == curLockState) + || (PHYSICAL_SECTION_LOCK_DELAY == curLockState) + || (PHYSICAL_SECTION_LOCK_EXCEPT == curLockState)) + { /*||ʱ||*/ + for (jj = 0U; jj < phyLgcSecSum; jj++) + { + lgcRLockId = GetLogSecLockBelongRoute(pPhyLgcSecBuf[jj]); + if ((0U == lgcRLockId) || (lgcRLockId == routeId)) + { + ; /*ڱ·δգִ*/ + } + else + { + break; + } + } + + if (jj == phyLgcSecSum) + { + validRouteId = GetPhySecRLockBelongRouteId(szRouteHalfPhySecData[ii]); /*ȡ·ID*/ + + SetPhySecLockState(szRouteHalfPhySecData[ii], PHYSICAL_SECTION_LOCK_NO, validRouteId, GetRouteDirection(validRouteId)); /*δ*/ + SetPhySecLockState(szRouteHalfPhySecData[ii], lockState, routeId, GetRouteDirection(routeId)); /*״̬*/ + } + else + { + ; /*ִ*/ + } + } + else if((PHYSICAL_SECTION_LOCK_NO ==curLockState)|| + (PHYSICAL_SECTION_LOCK_PROTECT == curLockState)) + { + SetPhySecLockState(szRouteHalfPhySecData[ii], lockState, routeId, GetRouteDirection(routeId)); /*״̬*/ + } + else + { + keepWork = CI_ERROR; + } + + } + else if (PHYSICAL_SECTION_LOCK_NO == lockState) + { + SetPhySecLockState(szRouteHalfPhySecData[ii], lockState, routeId, GetRouteDirection(routeId)); /*״̬*/ + } + else if (PHYSICAL_SECTION_LOCK_EXCEPT == lockState) + { + SetPhySecLockState(szRouteHalfPhySecData[ii], lockState, routeId, GetRouteDirection(routeId)); /*״̬*/ + } + else + { + /*״̬*/ + keepWork = CI_ERROR; + } + + if (CI_ERROR == keepWork) + { + break; + } + } + } + + if (CI_SUCCESS == keepWork) + { + phySecSum = 0u; + pPhySecDataStru = NULL; + /*ν·Ľ·*/ + if ((0u < validRouteId) && (validRouteId != routeId)) + { + + + phySecSum = GetRoutePhysicalSectionSum(validRouteId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(validRouteId); /*ȡ·*/ + + if ((0u == phySecSum) || (NULL == pPhySecDataStru)) + { + keepWork = CI_ERROR; + + } + else + { + ; + } + } + else + { + keepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == keepWork) + { + for (ii = 0u; ii < phySecSum; ii++) + { + + if (validRouteId == GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId)) + { + break; + } + else + { + ; + } + } + + if (ii == phySecSum) + { + (void)SetRouteState(validRouteId, ROUTE_STATE_IDLE); + /*ȡ·ķ*/ + SetRouteRelProSwitchLockSta(validRouteId, SWITCH_LOCK_PROTECT_CANCEL); + + } + } +} + +/* +* ý·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 useState, ״̬ +* ֵ +*/ +void SetRouteHalfPhySecUsingState(const UINT16 routeId, const UINT8 setUseState) +{ + UINT8 phySecSum = 0u; /**/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 ii = 0u; /**/ + UINT16 szPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; + UINT8 reVal = CI_ERROR; + UINT16 routeProSwitchSum = 0u;/*·*/ + RouteProtectSwitchStruct szRouteProSwitchData[ROUTE_PROTECTSWI_SUM_MAX] = {0U};/*·*/ + UINT16 switchId = 0u;/*ID*/ + UINT16 phyId = 0u;/*ID*/ + UINT8 curUseState = 0u;/*״̬*/ + UINT8 phySecBelongId = 0u;/*ID*/ + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + phySecSum = GetRouteHalfPhysicalSecData(routeId, szPhySecData); /*ȡ·*/ + + + routeProSwitchSum = GetRouteHalfProSwData(routeId, szRouteProSwitchData);/*ȡ·*/ + + if ((setUseState != PHYSICAL_SECTION_USING_YES) && + (setUseState != PHYSICAL_SECTION_USING_NO)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + + if ((0u == localCiId) || (0u == phySecSum) ) + { + reVal = CI_ERROR; + } + } + + + + if (CI_SUCCESS == reVal) + {/*·ڵãȡ*/ + for (ii = 0u; ii < phySecSum; ii++) + { + phySecBelongId = GetPhySecBelongCiId(szPhySecData[ii]); + curUseState = GetPhySecUseState(szPhySecData[ii]); + + + if (PHYSICAL_SECTION_USING_YES == setUseState) + { /**/ + + if (localCiId == phySecBelongId) + { /**/ + /*ֱ*/ + SetPhySecUseState(szPhySecData[ii], PHYSICAL_SECTION_USING_YES, routeId); + } + else + { + /*DZ*/ + if (PHYSICAL_SECTION_USING_NO == curUseState) + {/*ǰ״̬Ϊno*/ + /**/ + SetPhySecUseState(szPhySecData[ii], PHYSICAL_SECTION_USING_APPLY, routeId); + } + else + { + /*״̬*/ + + } + } + } + else + { /*δ*/ + + if (localCiId == phySecBelongId) + { /**/ + + /*δ*/ + SetPhySecUseState(szPhySecData[ii], PHYSICAL_SECTION_USING_NO, routeId); + } + else + { /*DZ*/ + + if ((PHYSICAL_SECTION_USING_YES == curUseState) || + (PHYSICAL_SECTION_USING_APPLY == curUseState)) + {/*·ѡʱ·ʱʧܣ·ΪãҲȡ*/ + /*ȡ*/ + SetPhySecUseState(szPhySecData[ii], PHYSICAL_SECTION_USING_CANCEL, routeId); + } + else + { + /*״̬*/ + + } + + } + } + } + } + + if (CI_SUCCESS == reVal) + {/*ȡ*/ + for (ii = 0u; ii < routeProSwitchSum; ii++) + { + switchId = szRouteProSwitchData[ii].ProtectSwitchId; + + phyId = GetSwitchPhySectionId(switchId); + curUseState = GetPhySecUseState(phyId); + phySecBelongId = GetPhySecBelongCiId(phyId); + + + if (PHYSICAL_SECTION_USING_YES == setUseState) + { /**/ + + if (localCiId == phySecBelongId) + { /**/ + + /*η*/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_YES, routeId); + } + else + { /*DZ*/ + if (PHYSICAL_SECTION_USING_NO == curUseState) + { + /**/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_APPLY, routeId); + } + else + { + /*״̬*/ + + } + } + } + else + { /*δ*/ + + if (localCiId == phySecBelongId) + { /**/ + + /*δ*/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_NO, routeId); + } + else + { /*DZ*/ + if ((PHYSICAL_SECTION_USING_YES == curUseState) || + (PHYSICAL_SECTION_USING_APPLY == curUseState)) + {/*·ѡʱ·ʱʧܣ·ΪãҲȡ*/ + /*ȡ*/ + SetPhySecProtectUseState(phyId, PHYSICAL_SECTION_USING_CANCEL, routeId); + } + else + { + /*״̬*/ + + } + } + } + } + } +} + +/* +* ý·߼״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteHalfLogSecLockState(const UINT16 routeId, const UINT8 lockState) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT8 curLockState = 0u; /*εǰ״̬*/ + UINT16 validRouteId = 0u; + UINT8 routeDir = 0u; + UINT8 validRouteDir = 0u; + UINT8 chTrainSum = 0U; + UINT8 funcRet = 0U; + LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + LogicTrainResStruct *pstLgcResInfo = NULL; + /*ȡ·߼Ϣ*/ + logSectionSum =GetHalfRouteLockLgcSecSum (routeId); + pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId); + routeDir = GetRouteDirection(routeId); + + + /*ݺϷ*/ + if ((0u != logSectionSum) && (NULL != pLogIdBuff)) + { + for (i = 0u; i < logSectionSum; i++) + { + /**/ + if (LOG_SECTION_LOCK_NORMAL == lockState) + { + funcRet = CheckLgcSecNotInTrainLoc(routeId, pLogIdBuff[i]); + if (CI_SUCCESS == funcRet) + { + curLockState = 0u; + /*ȡǰ״̬*/ + curLockState = GetLogSecLockState(pLogIdBuff[i]); + if ((LOG_SECTION_LOCK_NORMAL == curLockState) || (LOG_SECTION_LOCK_DELAY == curLockState)) + { + validRouteId = GetLogSecLockBelongRoute(pLogIdBuff[i]); + validRouteDir = GetRouteDirection(validRouteId); + /*֮ǰ·δ*/ + chTrainSum = GetLogSecTrainInfoSum(pLogIdBuff[i]); + pstLgcResInfo = GetLogSecTrainInfo(pLogIdBuff[i]); + if (NULL != pstLgcResInfo) + { + (void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct)*LOGIC_SECTION_RES_SUM_MAX)); + } + SetLogSecLockState(pLogIdBuff[i], LOG_SECTION_LOCK_NO, validRouteId, validRouteDir); + } + + /*ڵǰ·*/ + SetLogSecLockState(pLogIdBuff[i], LOG_SECTION_LOCK_NORMAL, routeId, routeDir); + + if (NULL != pstLgcResInfo) + { + CpyLgcSecResTrain(pLogIdBuff[i], chTrainSum, stTmpResInfo); + } + } + } + /*δ*/ + else if (LOG_SECTION_LOCK_NO == lockState) + { + SetLogSecLockState(pLogIdBuff[i], LOG_SECTION_LOCK_NO, routeId, routeDir); + } + /**/ + else if (LOG_SECTION_LOCK_EXCEPT == lockState) + { + SetLogSecLockState(pLogIdBuff[i], LOG_SECTION_LOCK_EXCEPT, routeId, routeDir); + } + else + { + /**/ + } + } + } + else + { + /**/ + } +} + +/* +* @brief ý·ֹԴ־ +* @param const UINT16 wRouteId, ·ID +* const UINT8 chShrFlag, ״̬ +* @return void +*/ +void SetRouteHalfLgcSecShareFlag(const UINT16 wRouteId, const UINT8 chShrFlag) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT8 chLogLockState = 0u; + UINT8 funcRet = 0U; + + /*ȡ·߼Ϣ*/ + logSectionSum =GetHalfRouteLockLgcSecSum (wRouteId); + pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(wRouteId); + + + /*ݺϷ*/ + if ((MAX_ROUTE_IN_LT_NUM >logSectionSum) + && (NULL != pLogIdBuff)) + { + /*Ϸ*/ + for (i = 0u; i < logSectionSum; i++) + { + funcRet = CheckLgcSecNotInTrainLoc(wRouteId, pLogIdBuff[i]); + if (CI_SUCCESS == funcRet) + { + if (LOGIC_SECTION_RES_SHARE_NO == chShrFlag) + {/*·ʱղ÷ǹԴ*/ + chLogLockState = GetLogSecLockState(pLogIdBuff[i]); + if (LOG_SECTION_LOCK_NO == chLogLockState) + { + /*߼ιԴ־*/ + SetLogSecResShareFlag(pLogIdBuff[i], chShrFlag); + } + else + { + ; /*ʱ÷ǹԴ*/ + } + } + else + { + /*߼ιԴ־*/ + SetLogSecResShareFlag(pLogIdBuff[i], chShrFlag); + } + } + } + + } + else + { + /**/ + } +} + +/* +* +* ý·ַ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockCommand, ״̬ +* ֵ void +*/ +void SetRouteHalfProSwLockState(const UINT16 routeId, const UINT8 lockCommand) +{ + UINT8 ii = 0u; /**/ + UINT16 protectSwitchId = 0u; /*ID*/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = {0U}; /**/ + + routeProtectSwitchSum =GetRouteHalfProSwData(routeId, routeProtectSwitchStru); /*ȡ*/ + + if ((0U != routeProtectSwitchSum) + && ((SWITCH_LOCK_PROTECT_SET == lockCommand) || (SWITCH_LOCK_PROTECT_CANCEL == lockCommand))) + { + + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + protectSwitchId = routeProtectSwitchStru[ii].ProtectSwitchId; + SetSwitchLockStatus(SWITCH_PLOCKTYPE_ROUTE, routeId, protectSwitchId, lockCommand); /*õ״̬*/ + /*RC 13.0.0 ޣ˫һ*/ +#if 0 + if (SWITCH_TYPE_DOUBLE == GetSwitchType(protectSwitchId)) + { /*˫*/ + SetSwitchLockStatus(SWITCH_PLOCKTYPE_ROUTE, routeId, GetDSwitchOtherId(protectSwitchId), lockCommand); /*õ״̬*/ + } + else + { + } +#endif + } + } + else + { + ; /*Ϊ0Ϸ*/ + } +} + +/* +* ·ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 RouteHalfFirstXuanProc(const UINT16 routeId) +{ + UINT8 phySecSum = 0u; /**/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 ii = 0u; /**/ + UINT8 waitSetFlag = 0u; /*ȴñ־*/ + UINT8 waitCancelFlag = 0u; /*ȴȡñ־*/ + UINT8 setFlag = 0u; /*ñ־*/ + UINT8 cancelFlag = 0u; /*δñ־*/ + UINT8 phySecUseStt = 0U; + UINT16 szPhySecIdBuf[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; + UINT8 retVal = CI_ERROR; + UINT8 cPhySecBelongCiId = 0U; /*CI*/ + UINT8 cPhyBelongOtherCiNum = 0U; /**/ + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + phySecSum =GetRouteHalfPhysicalSecData (routeId, szPhySecIdBuf); /*ȡ·*/ + + if ((0u == localCiId) || (0U == phySecSum)) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + + if (CI_SUCCESS == retVal) + { + for (ii = 0u; ii < phySecSum; ii++) + { + phySecUseStt = GetPhySecUseState(szPhySecIdBuf[ii]); + if (PHYSICAL_SECTION_USING_APPLY == phySecUseStt) + { + waitSetFlag = 1u; + } + else if (PHYSICAL_SECTION_USING_CANCEL == phySecUseStt) + { + waitCancelFlag = 1u; + } + else if (PHYSICAL_SECTION_USING_YES == phySecUseStt) + { + setFlag = 1u; + } + else + { + cancelFlag = 1u; + } + + cPhySecBelongCiId = GetPhySecBelongCiId(szPhySecIdBuf[ii]); + if ((cPhySecBelongCiId != localCiId) && (0U != cPhySecBelongCiId)) + { + cPhyBelongOtherCiNum++; + } + else + { + /**/ + } + } + + if ((0u == waitSetFlag) && (0u == waitCancelFlag) && (1u == setFlag) && (0u == cancelFlag)) + { /**/ + + retVal= CI_SUCCESS; + } + else if ((0u == waitSetFlag) && (0u == waitCancelFlag) && (0u == setFlag) && (1u == cancelFlag)) + { /*δ*/ + + retVal = CI_ERROR; + } + else if ((1u == waitSetFlag) && (0u == waitCancelFlag) && (1u == setFlag) && (0u == cancelFlag)) + { /*&&ȴ*/ + + retVal = RETURN_FIRSTXUANPAI_ERR_WAIT; + } + else if ((0u == waitSetFlag) && (1u == waitCancelFlag) && (0u == setFlag) && (1u == cancelFlag)) + { /*δ&&ȴȡ*/ + + retVal = RETURN_FIRSTXUANPAI_ERR_WAIT; + } + else if ((0u == waitSetFlag) && (0u == waitCancelFlag) && (1u == setFlag) && (1u == cancelFlag)) + { /*&&δ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + retVal = CI_ERROR; + } + else + { + if (phySecSum == cPhyBelongOtherCiNum) /*ؽ·ȫ*/ + { + if ((1U == waitSetFlag) && (0U == waitCancelFlag) && (0U == setFlag) && (0U == cancelFlag)) + { + retVal = RETURN_FIRSTXUANPAI_ERR_WAIT; /*ȴȡ*/ + } + else if ((0U == waitSetFlag) && (1U == waitCancelFlag) && (0U == setFlag) && (0U == cancelFlag)) + { + retVal = RETURN_FIRSTXUANPAI_ERR_WAIT; /*ȴȡ*/ + } + else + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + retVal = CI_ERROR; + } + } + else + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + retVal = CI_ERROR; + } + } + } + + return retVal; +} + + +/* +* ý·г״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteTrainLocLogSecState(const UINT16 routeId, const UINT8 lockState) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT8 curLockState = 0u; /*εǰ״̬*/ + UINT16 validRouteId = 0u; + UINT8 routeDir = 0u; + UINT8 validRouteDir = 0u; + UINT8 chTrainSum = 0U; + UINT8 funcRet = 0U; + LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + LogicTrainResStruct *pstLgcResInfo = NULL; + UINT8 keepWork = CI_ERROR; + UINT16 cPhySecId = 0U; + UINT16 wPhySecRLockRouteId = 0U; /*ν··ID*/ + UINT16 wByLogSecDelRouteId = 0U; /*ͨ߼γĽ·ID*/ + UINT16 wByPhySecDelRouteId = 0U; /*ͨγĽ·ID*/ + + /*ȡ·߼Ϣ*/ + logSectionSum = GetHalfRouteTrainLocLgcSecNum(routeId); + pLogIdBuff = GetHalfRouteTrainLocLgcSecIdBuf(routeId); + routeDir = GetRouteDirection(routeId); + + /*ݺϷ*/ + if ((0u != logSectionSum) && (NULL != pLogIdBuff)) + { + for (i = 0u; i < logSectionSum; i++) + { + /**/ + funcRet = CheckLgcSecInHalfRoute(routeId, pLogIdBuff[i]); + if (CI_SUCCESS == funcRet) + { + if (LOG_SECTION_LOCK_NORMAL == lockState) + { + curLockState = 0u; + /*ȡǰ״̬*/ + curLockState = GetLogSecLockState(pLogIdBuff[i]); + if ((LOG_SECTION_LOCK_NORMAL == curLockState) || (LOG_SECTION_LOCK_DELAY == curLockState)) + { + validRouteId = GetLogSecLockBelongRoute(pLogIdBuff[i]); + validRouteDir = GetRouteDirection(validRouteId); + /*֮ǰ·δ*/ + chTrainSum = GetLogSecTrainInfoSum(pLogIdBuff[i]); + pstLgcResInfo = GetLogSecTrainInfo(pLogIdBuff[i]); + if (NULL != pstLgcResInfo) + { + (void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct) * LOGIC_SECTION_RES_SUM_MAX)); + } + SetLogSecLockState(pLogIdBuff[i], LOG_SECTION_LOCK_NO, validRouteId, validRouteDir); + + cPhySecId = GetLgcSecRelativePhySecId(pLogIdBuff[i]); + wPhySecRLockRouteId = GetPhySecRLockBelongRouteId(cPhySecId); + if (validRouteId == wPhySecRLockRouteId) + { + /*ԭ·գͨ߼γԭ·*/ + wByPhySecDelRouteId = validRouteId; + + if (wByLogSecDelRouteId == wPhySecRLockRouteId) + { + wByLogSecDelRouteId = 0U; /*Ҫͨ߼γĽ·*/ + } + else + { + /**/ + } + } + else if ((validRouteId != wPhySecRLockRouteId) && ((0U == wByPhySecDelRouteId) || (wByPhySecDelRouteId != wByLogSecDelRouteId))) + { + wByLogSecDelRouteId = validRouteId; /*YF0083-1953ǰ߼յηԭ·գҪڴг߼ʱԭ·*/ + } + else + { + /**/ + } + } + + /*ڵǰ·*/ + SetLogSecLockState(pLogIdBuff[i], LOG_SECTION_LOCK_NORMAL, routeId, routeDir); + + if (NULL != pstLgcResInfo) + { + CpyLgcSecResTrain(pLogIdBuff[i], chTrainSum, stTmpResInfo); + } + + /*߼߼״̬*/ + keepWork = LogSecLockInHalfRouteProcess(pLogIdBuff[i], routeId); + if (CI_ERROR == keepWork) + { + break; /*߼·쳣ٴ*/ + } + } + /*δ*/ + else if (LOG_SECTION_LOCK_NO == lockState) + { + SetLogSecLockState(pLogIdBuff[i], LOG_SECTION_LOCK_NO, routeId, routeDir); + } + /**/ + else if (LOG_SECTION_LOCK_EXCEPT == lockState) + { + SetLogSecLockState(pLogIdBuff[i], LOG_SECTION_LOCK_EXCEPT, routeId, routeDir); + } + else + { + /**/ + } + } + } + + if (0U != wByLogSecDelRouteId) + { + CleanOldRouteProcByLogSec(wByLogSecDelRouteId); /*ֽ·ͨ߼γԭ·*/ + } + else + { + /*Ľ·*/ + } + } + else + { + /**/ + } +} + +/* +* ý·г״̬, Ҫִ߼մ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteTrainLocPhySecState(const UINT16 routeId, const UINT8 lockState) +{ + UINT8 phySecSum = 0U; /**/ + UINT8 curLockState = 0U; /*εǰ״̬*/ + UINT8 validRouteSum = 0U; + UINT16 validRouteIdBuf[ROUTE_TRAIN_LOC_MAX_SUM] = {0U}; /*ҪЧ·ID*/ + UINT16 validRouteId = 0U; + UINT8 ii = 0u; /**/ + UINT8 jj = 0U; + UINT16 phySecRLockId = 0U; + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT16 szRouteHalfPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; + UINT8 phyLgcSecSum = 0U; + UINT8 keepWork = CI_ERROR; + UINT16 *pPhyLgcSecBuf = NULL; + UINT16 lgcRLockId = 0U; + + UINT8 cLocalCiId = 0U; + UINT8 cRouteBelongCiId = 0U; + + + + phySecSum = GetRouteTrainLocPhySecData(routeId, szRouteHalfPhySecData); + if (0u == phySecSum) + { + keepWork = CI_ERROR; + } + else + { + keepWork = CI_SUCCESS; + } + + if (CI_SUCCESS == keepWork) + { + for (ii = 0u; ii < phySecSum; ii++) + { + + phyLgcSecSum = GetPhySecIncLogSecSum(szRouteHalfPhySecData[ii]); + pPhyLgcSecBuf = GetPhySecIncLogSecIdBuf(szRouteHalfPhySecData[ii]); + if (PHYSICAL_SECTION_LOCK_NORMAL == lockState) + { /**/ + + curLockState = 0u; + curLockState = GetPhySecLockState(szRouteHalfPhySecData[ii]); /*ȡεǰ״̬*/ + + if ((PHYSICAL_SECTION_LOCK_NORMAL == curLockState) || + (PHYSICAL_SECTION_LOCK_DELAY == curLockState)) + { /*||ʱ*/ + for (jj = 0U; jj < phyLgcSecSum; jj++) + { + lgcRLockId = GetLogSecLockBelongRoute(pPhyLgcSecBuf[jj]); + if ((0U == lgcRLockId) || (lgcRLockId == routeId)) + { + ; /*ڱ·δգִ*/ + } + else + { + break; + } + } + + validRouteId = GetPhySecRLockBelongRouteId(szRouteHalfPhySecData[ii]); /*ȡ·ID*/ + /*¼Ч·ID*/ + if (jj == phyLgcSecSum) + { + SetPhySecLockState(szRouteHalfPhySecData[ii], PHYSICAL_SECTION_LOCK_NO, validRouteId, GetRouteDirection(validRouteId)); /*δ*/ + SetPhySecLockState(szRouteHalfPhySecData[ii], lockState, routeId, GetRouteDirection(routeId)); /*״̬*/ + + } + else + { + + } + + for (jj = 0U; jj < validRouteSum; jj++) + { + if ((validRouteId == validRouteIdBuf[jj])&&(validRouteId!= routeId)) + { + /*ȥ*/ + break; + } + } + + if (validRouteSum == jj) + { + /*δظ*/ + if (ROUTE_TRAIN_LOC_MAX_SUM > validRouteSum) + { + validRouteIdBuf[validRouteSum++] = validRouteId; + } + else + { + keepWork = CI_ERROR; + } + } + } + else if (PHYSICAL_SECTION_LOCK_NO == curLockState) + { + SetPhySecLockState(szRouteHalfPhySecData[ii], lockState, routeId, GetRouteDirection(routeId)); /*״̬*/ + } + else + { + keepWork = CI_ERROR; + } + + } + else if (PHYSICAL_SECTION_LOCK_NO == lockState) + { + SetPhySecLockState(szRouteHalfPhySecData[ii], lockState, routeId, GetRouteDirection(routeId)); /*״̬*/ + } + else if (PHYSICAL_SECTION_LOCK_EXCEPT == lockState) + { + SetPhySecLockState(szRouteHalfPhySecData[ii], lockState, routeId, GetRouteDirection(routeId)); /*״̬*/ + } + else + { + /*״̬*/ + keepWork = CI_ERROR; + } + + if (CI_ERROR == keepWork) + { + break; + } + } + } + + + if (CI_SUCCESS == keepWork) + { + /*ν·Ľ·*/ + for (ii = 0U; ii < validRouteSum; ii++) + { + if ((0u < validRouteIdBuf[ii]) && (validRouteIdBuf[ii] != routeId)) + { + phySecSum = 0u; + pPhySecDataStru = NULL; + + phySecSum = GetRoutePhysicalSectionSum(validRouteIdBuf[ii]); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(validRouteIdBuf[ii]); /*ȡ·*/ + + if ((0u == phySecSum) || (NULL == pPhySecDataStru)) + { + keepWork = CI_ERROR; + + } + else + { + for (jj = 0u; jj < phySecSum; jj++) + { + phySecRLockId = GetPhySecRLockBelongRouteId(pPhySecDataStru[jj].PhysicalSectionId); + if (validRouteIdBuf[ii] == phySecRLockId) + { + break; + } + else + { + ; + } + } + + cLocalCiId = GetSystemParaLocalCiId(); + cRouteBelongCiId = GetRouteBelongCiId(validRouteIdBuf[ii]); + if (jj == phySecSum) + { + if ((0U != cLocalCiId) && (cLocalCiId == cRouteBelongCiId)) + { + (void)SetRouteState(validRouteIdBuf[ii], ROUTE_STATE_IDLE); + /*ȡ·ķ*/ + SetRouteRelProSwitchLockSta(validRouteIdBuf[ii], SWITCH_LOCK_PROTECT_CANCEL); + } + else + { + /*RC춯̬·*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_ROUTE_SEC_LOCK_APPLY, routeId, validRouteIdBuf[ii], cRouteBelongCiId); + } + } + else + { + if ((0U != cLocalCiId) && (cLocalCiId == cRouteBelongCiId)) + { + (void)SetRouteState(validRouteIdBuf[ii], ROUTE_STATE_HALF_UNLOCK); + } + else + { + /*RC춯̬·*/ + AddCiSendToCiCmdInfo(CI_CMD_DR_ROUTE_STATE, validRouteIdBuf[ii], (UINT16)ROUTE_STATE_HALF_UNLOCK, cRouteBelongCiId); + } + } + } + } + } + } + + +} +/* +* ȡָ·һյ߼ʱʼں +* ˵ const UINT16 routeId, ·ID +* +* ֵ 0: ȡʧ +* >0: ·һյ߼ʱʼں +*/ +UINT32 GetRouFirDelayErlockStaCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + UINT16 wFirstNormalLockLogId = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + wFirstNormalLockLogId = GetRouteFirstNormalLockLogId(routeId); + retVal = GetLogDelayErrlockStartCycNum(wFirstNormalLockLogId); + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָ·һյ߼ʱʼں +* ˵const UINT16 routeId, ·ID +* const UINT32 startCycNum ʼں +* ֵ +* +*/ +void SetRouFirDelayErlockStaCycNum(const UINT16 routeId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 wFirstNormalLockLogId = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + wFirstNormalLockLogId = GetRouteFirstNormalLockLogId(routeId); + SetLogDelayErrlockStartCycNum(wFirstNormalLockLogId, startCycNum); + } + else + { + /**/ + } +} + +/* +* У·ǷҪⱨ +* ˵const UINT16 routeId ·ID +* ֵ +*/ +void RouteNeedDriveSGBJCheck(const UINT16 routeId) +{ + UINT8 ii = 0U; + UINT16 wStartSigId = 0U; /*·ʼźŻID*/ + UINT16 wInStorePhySecId = 0U; /*ڵһΣмԣ*/ + UINT16 wOutStorePhySecId = 0U; /*һΣмԣ*/ + UINT8 cInStorePhySecCurOccState = 0U; /*ڵһεǰռ״̬*/ + UINT8 cOutStorePhySecCurOccState = 0U; /*һεǰռ״̬*/ + UINT8 cOutStorePhySecPreOccState = 0U; /*һ֮ǰռ״̬*/ + UINT16 wPhySecLockedBelongRoute = 0U; /*·*/ + UINT8 cRouteIncPhySecNum = 0U; /*·*/ + RoutePhysicalSectionStruct* pRouteIncPhySecStr = NULL; /*·*/ + UINT8 cPhySecLJKproperty = 0U; /*м*/ + UINT16 wOutFstPhySecId = 0U; /*·ⷽһID*/ + UINT8 cOutFstPhySecCurOccState = 0U; /*źŻⷽһεǰռ״̬*/ + UINT8 cRouteTrainEnterFlag = 0U; /*·гʻ־*/ + UINT8 cSGBJDelayOpenFlag = 0U; /*·ⱨʱű־*/ + UINT8 cPhySecLockState = 0U; /*״̬*/ + UINT8 cRouteDriveSGBJFlag = ROUTE_DRIVE_SGBJ_INVALID; /*·ⱨ־*/ + UINT8 cDrivedSGBJFlag = ROUTE_HAS_DRIVED_SGBJ_INVALID; /*·ⱨ־*/ + + if ((0U < routeId) && (ROUTE_SUM_MAX > routeId)) + { + cSGBJDelayOpenFlag = GetRouteSGBJDelayFlag(routeId); + cRouteIncPhySecNum = GetRoutePhysicalSectionSum(routeId); + pRouteIncPhySecStr = GetRouteSectionData(routeId); + + if ((0U != cRouteIncPhySecNum) && (NULL != pRouteIncPhySecStr)) + { + if (ROUTE_SGBJ_DELAY_OPEN_INVALID == cSGBJDelayOpenFlag) + { + /*·ⷽһξмԵⱨ־ռѹⷽһʱⱨгʻڷһκֹͣⱨ*/ + for (ii = 0U; ii < cRouteIncPhySecNum; ii++) + { + /*Ѱҽ·ڵĿһ*/ + cPhySecLJKproperty = GetPhySecLjkFlag(pRouteIncPhySecStr[ii].PhysicalSectionId); /*ȡм*/ + if ((PHYSICAL_SECTION_LJK_YES == cPhySecLJKproperty) && (0U < ii)) + { + /*ҵһмΣ¼ⷽһΣֹͣ*/ + wInStorePhySecId = pRouteIncPhySecStr[ii].PhysicalSectionId; + wOutStorePhySecId = pRouteIncPhySecStr[ii - 1U].PhysicalSectionId; + break; + } + else + { + /**/ + } + } + + if ((0U != wInStorePhySecId) && (0U != wOutStorePhySecId)) + { + cInStorePhySecCurOccState = GetPhySecCurMergeState(wInStorePhySecId); + cOutStorePhySecCurOccState = GetPhySecCurMergeState(wOutStorePhySecId); + cOutStorePhySecPreOccState = GetPhySecPreMergeState(wOutStorePhySecId); + + /*ݿⷽռ״̬Ƿⱨ*/ + if (SECTION_OCCUPY_NO != cOutStorePhySecCurOccState) + { + wPhySecLockedBelongRoute = GetPhySecRLockBelongRouteId(wOutStorePhySecId); + if (wPhySecLockedBelongRoute == routeId) + { + /*һηǿұ·գý·ⱨ־Ч*/ + SetRouteDriveSGBJFlag(routeId, ROUTE_DRIVE_SGBJ_VALID); + } + else + { + /*δ·գⱨ޸ȱYF0083-2338+YF0083-2299г1ͨDG-AʻAG1г2ͨDG-BʻAG2ʱAG1ⱨ⣩*/ + } + } + else if ((SECTION_OCCUPY_NO != cInStorePhySecCurOccState) && (SECTION_OCCUPY_NO != cOutStorePhySecPreOccState)) + { + /*ڵһεǰǿҿһ֮ǰǿУý·ⱨ־Ч*/ + SetRouteDriveSGBJFlag(routeId, ROUTE_DRIVE_SGBJ_INVALID); + } + else + { + /**/ + } + } + else + { + /*δҵһΣ*/ + } + } + else + { + /*·/ⷽһξмԵⱨ־·ⱨгȫʻ·ֹͣⱨ*/ + wStartSigId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + wOutFstPhySecId = GetSignalOutFirstPhySecId(wStartSigId); /*źŻⷽһID*/ + + if (0U != wOutFstPhySecId) + { + cOutFstPhySecCurOccState = GetPhySecCurMergeState(wOutFstPhySecId); + cRouteTrainEnterFlag = GetRouteTrainEnterFlag(routeId); + cRouteDriveSGBJFlag = GetRouteDriveSGBJFlag(routeId); /*ȡ·ǰⱨ־*/ + + /*ݽ·гʻ־ⷽһռ״̬Ƿⱨ*/ + if ((ROUTE_TRAIN_ENTER_FLAG_YES == cRouteTrainEnterFlag) && (SECTION_OCCUPY_NO == cOutFstPhySecCurOccState)) + { + /*·гʻ־Чҽ·ⷽһεǰУý·ⱨ־Ч*/ + SetRouteDriveSGBJFlag(routeId, ROUTE_DRIVE_SGBJ_INVALID); + if (ROUTE_DRIVE_SGBJ_VALID == cRouteDriveSGBJFlag) + { + SetRouteHasDrivedSGBJFlag(routeId, ROUTE_HAS_DRIVED_SGBJ_VALID); /*ý·ⱨ*/ + } + else + { + /*δ*/ + } + } + else + { + cPhySecLockState = GetPhySecLockState(pRouteIncPhySecStr[cRouteIncPhySecNum - 1U].PhysicalSectionId); /*ȡ·ڷһε״̬*/ + if ((PHYSICAL_SECTION_LOCK_NORMAL != cPhySecLockState) && (SECTION_OCCUPY_NO == cOutFstPhySecCurOccState)) + { + /*·ڷһβΪգʱгʻ־ⱨ־Чⱨڴʱֱ*/ + SetRouteDriveSGBJFlag(routeId, ROUTE_DRIVE_SGBJ_INVALID); + if (ROUTE_DRIVE_SGBJ_VALID == cRouteDriveSGBJFlag) + { + SetRouteHasDrivedSGBJFlag(routeId, ROUTE_HAS_DRIVED_SGBJ_VALID); /*ý·ⱨ*/ + } + else + { + /*δ*/ + } + } + else + { + cDrivedSGBJFlag = GetRouteHasDrivedSGBJFlag(routeId); /*·ⱨ־*/ + if (ROUTE_HAS_DRIVED_SGBJ_INVALID == cDrivedSGBJFlag) + { + /*δⱨгδʻ·ⷽһռý·ⱨ־Ч*/ + SetRouteDriveSGBJFlag(routeId, ROUTE_DRIVE_SGBJ_VALID); + } + else + { + /*г1AGȫBGг2ֽAGʱBGⱨٴα*/ + } + } + } + } + else + { + /*ȡⷽIDʧܣ*/ + } + } + } + else + { + /*ȡ·Σ*/ + } + } + else + { + /*ηǷʧ*/ + } +} + +/* +* ߼ιϽ߼ +* ˵ const UINT16 wPhySectionId, ID +* const UINT8 chVirCIid Rtu(ֵ) ID +* ֵ void +* by cgh 20231002 +*/ +void LogicSecFaultUnlockLogicManage(const UINT16 wPhySectionId, const UINT8 chVirCIid) +{ + UINT8 ii = 0U; + UINT8 chGoExec = CI_ERROR; + UINT8 chPhyIncLogSum = 0U;/*ΰ߼Ŀ*/ + UINT16* pPhyIncLogId = NULL;/*ΰ߼ID*/ + UINT16 wLogLockBelongRouteId = 0U;/*߼·*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chRouteBelongCiId = 0U;/*·ID*/ + + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + chPhyIncLogSum = GetPhySecIncLogSecSum(wPhySectionId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(wPhySectionId); + + if (NULL != pPhyIncLogId) + { + /*߼·ʽ߼*/ + LogRouteErrLockFaultManage(wPhySectionId); + + for (ii = 0U; ii < chPhyIncLogSum; ii++) + { + wLogLockBelongRouteId = GetLogSecLockBelongRoute(pPhyIncLogId[ii]); + if ((0U < wLogLockBelongRouteId) && (ROUTE_SUM_MAX > wLogLockBelongRouteId)) + { + DelayErrLockCmdDeal(wPhySectionId);/*λ۷·ʽʱιϴ*/ + } + else + { + ; + } + + /*߼ʽ߼*/ + chGoExec = CheckLogSecFaultUnlockCanDo(pPhyIncLogId[ii], chVirCIid); + chRouteBelongCiId = GetRouteBelongCiId(wLogLockBelongRouteId); + if ((chLocalCiId == chRouteBelongCiId) && (0U < chLocalCiId) && (CI_SUCCESS == chGoExec)) + { + /*·ڱ*/ + LocalCiLogSecFaultUnlockProcess(pPhyIncLogId[ii], chVirCIid); + } + else if ((chLocalCiId != chRouteBelongCiId) && (0U < chLocalCiId)) + { + /*·ڱ*/ + OtherCiLogSecFaultUnlockProcess(pPhyIncLogId[ii], chVirCIid); + } + else + { + ; /*쳣*/ + } + } + } + else + { + ; /**/ + } +} + +/* +* ߼ιϽ߼-·ڱ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chVirCIid Rtu(ֵ) ID +* ֵ void +* by cgh 20231002 +*/ +void LocalCiLogSecFaultUnlockProcess(const UINT16 wLogSectionId, const UINT8 chVirCIid) +{ + UINT16 wLogLockBelongRouteId = 0U;/*߼·*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chRouteState = 0U;/*·״̬*/ + UINT8 chRouteAutoSig = 0U;/*·Զź*/ + UINT16 wRouteStartSigId = 0U;/*·ʼźŻID*/ + UINT16 wRouteAutoRouteId = 0U;/*·ӦԶ·ID*/ + UINT16 wRouteAutoReturnId = 0U;/*·ӦԶ۷·ID*/ + UINT16 wRouteAllAutoReturnId = 0U;/*·ӦȫԶ۷·ID*/ + UINT8 chAutoTriggerType = 0U;/*·Զ*/ + UINT8 chLogSecLockState = 0U;/*߼״̬*/ + UINT8 chRouteRecoverFlag = 0U;/*·źؿ־*/ + UINT8 chLogFaultUnLockRes = 0U;/*߼ιϽ*/ + UINT8 chLogSecBelongRouteDir = 0U;/*߼·*/ + UINT8 chHaveLogSecFromOtherCi = 0U;/*·Ƿ߼*/ + UINT8 chNeighbourCi = 0U;/*ID*/ + UINT8 chCommState = 0U;/*ͨ״̬*/ + UINT8 chFuncSwitch = 0U; /*Ƿ̵ּ֧ӿ*/ + UINT8 chConfirmRelayInterfaceFlag = 0U;/*̵ӿȷ״̬*/ + UINT8 chRouteLogSecHaveUnLock = 0u;/*·߼Ƿѽ*/ + + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + wLogLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + chFuncSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + chConfirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + if ((0U < wLogLockBelongRouteId) && (ROUTE_SUM_MAX > wLogLockBelongRouteId)) + { + chRouteState = GetRouteState(wLogLockBelongRouteId); + chRouteAutoSig = GetRouteAutoSigProperty(wLogLockBelongRouteId); + wRouteStartSigId = GetRouteStartSignalId(wLogLockBelongRouteId); + wRouteAutoRouteId = GetRouteAutoRouteId(wLogLockBelongRouteId); + wRouteAutoReturnId = GetRouteAutoReturnId(wLogLockBelongRouteId); + wRouteAllAutoReturnId = GetRouteAllAutoReturnId(wLogLockBelongRouteId); + chAutoTriggerType = GetAutoTriggerType(wLogLockBelongRouteId); + + if (((ROUTE_STATE_YUXIAN_OPEN == chRouteState) || (ROUTE_STATE_NEAR_OPEN == chRouteState)) && (ROUTE_AUTOSIG_PROPERTY_YES != chRouteAutoSig)) + { + /*·״̬ΪԤȿŻ߽ӽţԶź*/ + (void)DriveSignalClose(wRouteStartSigId); /*źŹر*/ + /*ý·ԶЧ*/ + SetAutoRouteSetFlag(wRouteAutoRouteId, AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(wRouteAutoReturnId, AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(wRouteAllAutoReturnId, ALL_AUTO_RETURN_SET_NO); + if (ROUTE_TYPE_AUTO_TRIGGER == chAutoTriggerType) + { + SetRouteAutoTriggerFlag(wLogLockBelongRouteId, AUTO_TRIGGER_SET_NO); + } + } + else if (ROUTE_STATE_LEAD_OPEN == chRouteState) + { + (void)DriveSignalClose(wRouteStartSigId); /*źŹر*/ + } + else + { + chLogSecLockState = GetLogSecLockState(wLogSectionId); + chRouteRecoverFlag = GetRouteRecoverOpenFlag(wLogLockBelongRouteId); + /*PSDSPKS۳µźŹرգؿ־λȴؿʱյʽʱؿ־*/ + if (ROUTE_RECOVER_STA_WAIT == chRouteRecoverFlag) + {/*ؿȴʱιգؿ־*/ + SetRouteOpenSigStartCycNum(wLogLockBelongRouteId, 0U); /*źſʱ*/ + + SetRouteRepeatOpenFlag(wLogLockBelongRouteId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteXianSuConfirmStt(wLogLockBelongRouteId, ROUTE_XIANSU_CONFIRM_NO); + + SetRouteRecoverState(wLogLockBelongRouteId, ROUTE_RECOVER_STA_STAY);/*ֹ߼ؿ*/ + } + + if ((LOG_SECTION_LOCK_EXCEPT != chLogSecLockState) && (ROUTE_STATE_HALF_UNLOCKDELAY != chRouteState)) + { + /*߼״̬Ϊ"쳣"ҽ·״̬ҲΪʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_PSEC_QGJ_UNLOCK, CI_DEVICE_TYPE_LOGICSEC, wLogSectionId, 0U, 0U); + } + else + { + /*Ϊʱ*/ + if ((ROUTE_STATE_AUTO_UNLOCKERR == chRouteState) || (ROUTE_STATE_IDLE == chRouteState)) + { + /*һ·Σʱ崻ὫΪա + ڱεĹ״̬״̬Ϊ + 쳣գ·״̬Ϊ ROUTE_STATE_IDLEΪʽΣ + ROUTE_STATE_IDLE == routeState*/ + + /*ʽ̹*/ + chLogFaultUnLockRes = LogSecFaultUnlockLogicProcess(wLogSectionId); + if (CI_SUCCESS == chLogFaultUnLockRes) + { + chLogSecBelongRouteDir = GetRouteDirection(wLogLockBelongRouteId); + SetLogSecLockState(wLogSectionId, LOG_SECTION_LOCK_NO, wLogLockBelongRouteId, chLogSecBelongRouteDir); + /*·յʱιϽ߼˴*/ + + chHaveLogSecFromOtherCi = RouteHaveLogSecBelongOtherCi(wLogLockBelongRouteId, &chNeighbourCi); + if ((1U == chHaveLogSecFromOtherCi) && (0U < chNeighbourCi)) + { + chCommState = GetLocalCiAndOtherCiTransSta(chNeighbourCi); + } + if ((1U == chHaveLogSecFromOtherCi) && (0U < chNeighbourCi) && (TRANSMIT_STATE_BAD == chCommState) + && (CICI_RELAY_INTERFACE_CONFIRM_YES == chConfirmRelayInterfaceFlag) && + (FUNC_SWITCH_ON == chFuncSwitch)) + { + /*,ұͨжϣ̵ּ֧ӿڹܿѴ򿪣Ҽ̵ӿȷ*/ + chRouteLogSecHaveUnLock = CheckLocalCiRouteLogSecUnLock(wLogLockBelongRouteId); + } + else + { + chRouteLogSecHaveUnLock = CheckRouteLogSecHaveUnLock(wLogLockBelongRouteId); + } + if (CI_SUCCESS == chRouteLogSecHaveUnLock) + { + /*·*/ + SetRouteRelProSwitchLockSta(wLogLockBelongRouteId, SWITCH_LOCK_PROTECT_CANCEL);/*ȡ·ķ*/ + /*ý·ԶЧ*/ + SetAutoRouteSetFlag(wRouteAutoRouteId, AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(wRouteAutoReturnId, AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(wRouteAllAutoReturnId, ALL_AUTO_RETURN_SET_NO); + if (ROUTE_TYPE_AUTO_TRIGGER == chAutoTriggerType) + { + SetRouteAutoTriggerFlag(wLogLockBelongRouteId, AUTO_TRIGGER_SET_NO); + } + /*ȫν*/ + SetRouteStateManage(wLogLockBelongRouteId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + else + { + /*,ݲ߼ʽ*/ + ; + } + } + } + } + } + } +} + +/* +* ߼ιϽ߼-· +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chVirCIid Rtu(ֵ) ID +* ֵ void +* by cgh 20231002 +*/ +void OtherCiLogSecFaultUnlockProcess(const UINT16 wLogSectionId, const UINT8 chVirCIid) +{ + UINT8 chLogSecBelongCiId = 0U;/*߼ID*/ + UINT16 wLogLockBelongRouteId = 0U;/*߼·Id*/ + UINT8 chRouteBelongCiId = 0U;/*·ID*/ + UINT8 chCommState = 0U;/*ͨ״̬*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chFuncSwitch = 0U; /*Ƿ̵ּ֧ӿ*/ + UINT8 chConfirmRelayInterfaceFlag = 0U;/*̵ӿȷ״̬*/ + UINT8 chLogFaultUnLockRes = 0U;/*߼ιϽ*/ + UINT8 chLogSecBelongRouteDir = 0U;/*߼·*/ + UINT8 chRouteLogSecHaveUnLock = 0u;/*·߼Ƿѽ*/ + UINT8 chIncludeVirFlag = 0U;/*Ƿ֧*/ + UINT8 chBelongVirCiId = 0U;/*߼ID*/ + UINT16 wLogSecBelongPhySecId = 0U;/*߼ID*/ + + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + wLogLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + chFuncSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + chIncludeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + chConfirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + if ((0U < wLogLockBelongRouteId) && (ROUTE_SUM_MAX > wLogLockBelongRouteId)) + { + chLogSecBelongCiId = GetLogSecBelongCiId(wLogSectionId); + chRouteBelongCiId = GetRouteBelongCiId(wLogLockBelongRouteId); + chCommState = GetLocalCiAndOtherCiTransSta(chRouteBelongCiId); + if ((chLocalCiId == chLogSecBelongCiId) && (TRANSMIT_STATE_BAD == chCommState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == chConfirmRelayInterfaceFlag) && + (FUNC_SWITCH_ON == chFuncSwitch)) + { + chLogFaultUnLockRes = LogSecFaultUnlockLogicProcess(wLogSectionId); + if (CI_SUCCESS == chLogFaultUnLockRes) + { + chLogSecBelongRouteDir = GetRouteDirection(wLogLockBelongRouteId); + SetLogSecLockState(wLogSectionId, LOG_SECTION_LOCK_NO, wLogLockBelongRouteId, chLogSecBelongRouteDir); + /*·յʱιϽ߼˴*/ + chRouteLogSecHaveUnLock = CheckRouteLogSecUnLock(wLogLockBelongRouteId); + if (CI_SUCCESS == chRouteLogSecHaveUnLock) + { + SetRouteRelProSwitchLockSta(wLogLockBelongRouteId, SWITCH_LOCK_PROTECT_CANCEL);/*ȡ·ķ*/ + SetRouteStateManage(wLogLockBelongRouteId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + } + else + { + /*,ݲ߼ʽ*/ + ; + } + } + else if ((chLocalCiId == chLogSecBelongCiId) && (TRANSMIT_STATE_GOOD == chCommState)) + { + wLogSecBelongPhySecId = GetLgcSecRelativePhySecId(wLogSectionId); + if (FUNC_SWITCH_ON == chIncludeVirFlag) + { + chBelongVirCiId = GetLogSecBelongVirCiId(wLogSectionId); + if ((chVirCIid == chBelongVirCiId) && (0U != chVirCIid)) + { + /*·ڱʱιϽ */ + AddCiSendToCiCmdInfo(CI_CMD_SECTION_FAULT_UNLOCK, wLogSecBelongPhySecId, 0U, chRouteBelongCiId); + } + } + else + { + /*·ڱʱιϽ */ + AddCiSendToCiCmdInfo(CI_CMD_SECTION_FAULT_UNLOCK, wLogSecBelongPhySecId, 0U, chRouteBelongCiId); + + } + } + else + { + ; /*쳣ʽ*/ + } + } +} + +/* +* ߼ιϽ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chVirCIid Rtu(ֵ) ID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +*/ +UINT8 CheckLogSecFaultUnlockCanDo(const UINT16 wLogSectionId, const UINT8 chVirCIid) +{ + UINT16 wLockBelongRouteId = 0U; /*·ID*/ + UINT8 reVal = CI_ERROR; + UINT8 chBelongvirCIid = 0U; + UINT8 chIncludeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + if ((0u == wLogSectionId) || (LOGIC_SECTION_SUM_MAX <= wLogSectionId)) + { + /*߼IDЧ*/ + reVal = CI_ERROR; + } + else + { + wLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); /*ȡ߼ν··ID*/ + + if ((0U == wLockBelongRouteId) || (ROUTE_SUM_MAX <= wLockBelongRouteId)) + { + /*·IDЧ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + } + if (CI_SUCCESS == reVal) + { + if (FUNC_SWITCH_ON == chIncludeVirFlag) + { + chBelongvirCIid = GetRouteBelongVirCiId(wLockBelongRouteId); + if (0U < chVirCIid) + { + if (chVirCIid == chBelongvirCIid) + { + reVal = CI_SUCCESS; /*Rtu(ֵ)ԲڱĽ·յ߼ʽ⣬۸߼ǷڸRtu*/ + } + else + { + chBelongvirCIid = GetLogSecBelongVirCiId(wLogSectionId); + if (chVirCIid == chBelongvirCIid) + { + reVal = CI_SUCCESS;/*߼·յģڸ߼Rtuϲʽ*/ + } + else + { + reVal = CI_ERROR; + } + } + } + else + { + reVal = CI_ERROR; + } + + } + else + { + reVal = CI_SUCCESS; + } + } + + return reVal; +} + +/* +* ʽʧźŹر +* ˵ const UINT16 wPhySectionId ID +* ֵ +* cgh-20231011 +*/ +void SecFaultUnlockDrvRelSigClose(const UINT16 wPhySectionId) +{ + UINT16 wPhySecLockBelRouteId = 0U;/*·*/ + UINT8 chRouteState = 0U;/*·״̬*/ + UINT8 chRouteAutoSig = 0U;/*·Զź*/ + UINT16 wRouteStartSigId = 0U;/*·ʼźŻID*/ + UINT16 wRouteAutoRouteId = 0U;/*·ӦԶ·ID*/ + UINT16 wRouteAutoReturnId = 0U;/*·ӦԶ۷·ID*/ + UINT16 wRouteAllAutoReturnId = 0U;/*·ӦȫԶ۷·ID*/ + UINT8 chAutoTriggerType = 0U;/*·Զ*/ + UINT8 chPhyIncLogSum = 0U; /*߼Ŀ*/ + UINT16* pPhyIncLogId = NULL; /*ΰ߼ID*/ + UINT8 ii = 0U; /*ΰ߼ѭ*/ + UINT8 jj = 0U; /*߼߼·Ŀ*/ + UINT8 wLogLockBelLogRouteSum = 0U; /*߼߼·Ŀ*/ + LogSecLockBelLogRouteStruct* pLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT16 wBeginSigId = 0U;/*ʼźŻID*/ + UINT8 chSigOpenState = 0U;/*źŻ״̬*/ + UINT8 chStartSigCurColor = 0U;/*źŻǰʾɫ*/ + + if ((0U == wPhySectionId) || (PHYSICAL_SECTION_SUM_MAX < wPhySectionId)) + { + ; /*IDЧִ*/ + } + else + { + wPhySecLockBelRouteId = GetPhySecRLockBelongRouteId(wPhySectionId); /*ȡν··ID*/ + + if ((ROUTE_SUM_MAX < wPhySecLockBelRouteId) || (0U == wPhySecLockBelRouteId)) + { + ; /*·IDЧִ*/ + } + else + { + chRouteState = GetRouteState(wPhySecLockBelRouteId); + chRouteAutoSig = GetRouteAutoSigProperty(wPhySecLockBelRouteId); + wRouteStartSigId = GetRouteStartSignalId(wPhySecLockBelRouteId); + wRouteAutoRouteId = GetRouteAutoRouteId(wPhySecLockBelRouteId); + wRouteAutoReturnId = GetRouteAutoReturnId(wPhySecLockBelRouteId); + wRouteAllAutoReturnId = GetRouteAllAutoReturnId(wPhySecLockBelRouteId); + chAutoTriggerType = GetAutoTriggerType(wPhySecLockBelRouteId); + + if (((ROUTE_STATE_YUXIAN_OPEN == chRouteState) || (ROUTE_STATE_NEAR_OPEN == chRouteState) || (ROUTE_STATE_LEAD_OPEN == chRouteState)) + && (ROUTE_AUTOSIG_PROPERTY_YES != chRouteAutoSig)) + { + /*·״̬ΪԤȿŻ߽ӽŻţԶź*/ + (void)DriveSignalClose(wRouteStartSigId); /*źŹر*/ + /*ý·ԶЧ*/ + SetAutoRouteSetFlag(wRouteAutoRouteId, AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(wRouteAutoReturnId, AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(wRouteAllAutoReturnId, ALL_AUTO_RETURN_SET_NO); + if (ROUTE_TYPE_AUTO_TRIGGER == chAutoTriggerType) + { + SetRouteAutoTriggerFlag(wPhySecLockBelRouteId, AUTO_TRIGGER_SET_NO); + } + } + else + { + ; /**/ + } + + chPhyIncLogSum = GetPhySecIncLogSecSum(wPhySectionId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(wPhySectionId); + if (NULL != pPhyIncLogId) + { + for (ii = 0U; ii < chPhyIncLogSum; ii++) + { + wLogLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(pPhyIncLogId[ii]); + pLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(pPhyIncLogId[ii]); + if (NULL != pLogSecLockBelLogRouteData) + { + /*߼߼·ʱ߼߼״ֻ̬Ϊ߼ջ߼쳣*/ + for (jj = 0U; jj < wLogLockBelLogRouteSum; jj++) + { + wBeginSigId = GetLogicalRouteRelateBeginSigId(pLogSecLockBelLogRouteData[jj].wLogSecLockBelLogRouteId); + if ((0U < wBeginSigId) && (SIGNAL_SUM_MAX > wBeginSigId)) + { + chStartSigCurColor = GetSignalCurColor(wBeginSigId); + chSigOpenState = GetSignalOpenCloseState(chStartSigCurColor); + if (SIGNAL_OPEN == chSigOpenState) + { + (void)DriveSignalClose(wBeginSigId); /*źŹر*/ + } + else + { + ; /**/ + } + } + else + { + ; /*ʼźŻ*/ + } + } + } + else + { + ; /**/ + } + } + } + else + { + ; /**/ + } + } + } +} + +/* +* ߼·źſŴ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERRORʧ +* CI_SUCCESSɹ +*/ +UINT8 KeepOpenLogRouteSignalProc(const UINT16 wLogRouteId) +{ + UINT8 returnValue = CI_ERROR; /*ֵ*/ + UINT16 wLogSignalId = 0U; /*߼·źŻ*/ + UINT16* LogSecIdBuff = NULL; + UINT8 chRouteFirstLgcTrainSum = 0U; + UINT16 wSignalInFirstLogSecId = 0U; + + wLogSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + returnValue = KeepLogRouteSignalProcess(wLogRouteId); + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + + /*ݿźŷֵ*/ + if (CI_SUCCESS == returnValue) + { + DriveLogRouteSignalOpen(wLogRouteId); /*޳ѹֿżֿͨź*/ + } + else if (LOG_ROUTE_TRAIN_CROSS == returnValue) + { + /*һ߼εгϢһ߼жгԴʱź*/ + chRouteFirstLgcTrainSum = GetLogSecTrainInfoSum(LogSecIdBuff[0U]); + + if (1U < chRouteFirstLgcTrainSum) + { + ; /*źŻд*/ + } + else + { + DriveLogRouteSignalClose(wLogSignalId); /*һ߼ֻһгԴҿѹ߼·źŻ,߻ȡûг(쳣)ź*/ + } + } + else + { + wSignalInFirstLogSecId = GetLogSecLockBelongRoute(LogSecIdBuff[0U]); + if (0U != wSignalInFirstLogSecId) + { + /*źŻڷһ߼α·գźŻάźŻ״̬*/ + } + else + { + DriveLogRouteSignalClose(wLogSignalId); + /*쳣رյı־*/ + SetLogRouteSignalErrCloseFlag(wLogSignalId, LOG_ROUTE_SIGNAL_CLOSE_ERR); + } + } + return returnValue; +} + + +/* +* ߼·źſŴ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERRORʧ +* CI_SUCCESSɹ +*/ +UINT8 OpenLogRouteSignalProc(const UINT16 wLogRouteId) +{ + UINT8 returnValue = CI_ERROR; /*ֵ*/ + UINT16 wLogSignalId = 0U; /*߼·źŻ*/ + + wLogSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + returnValue = OpenLogRouteSignalProcess(wLogRouteId); + + if (CI_SUCCESS == returnValue) + { + DriveLogRouteSignalOpen(wLogRouteId); + } + else + { + /*ż鲻ͨ*/ + /*쳣ֿ߳ѹźŻ*/ + DriveLogRouteSignalClose(wLogSignalId); + } + + return returnValue; +} +/** +* @brief ѯгСǰ߼·λ(гСǰ) +* @param UINT16 wTrainId гID +* @param UINT16 wLogRouteId ߼·ID +* @return 0ѯʧ +* 1гδʻ· +* 2гͷʻ·δѹ +* 3гѹźŻ +* 4гȫʻ· +* 5гͷ· +*/ +UINT8 dsuLogRouteTrainCrossSignal(const UINT16 wTrainId, const UINT16 wLogRouteId) +{ + UINT8 chRtnVal = CI_ERROR; + UINT16 wStartSignal = 0u; + UINT8 chRouteDir = 0u; + struct_PathPoint strTrainMinHead = { 0u }; + struct_PathPoint strTrainMinTail = { 0u }; + str_Zone strRouteZone = { 0u }; + str_Zone strTrainZone = { 0u }; + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 wLogId = 0U; + RouteSwitchStruct pRouteSwitchStruct[ROUTE_SWITCH_SUM_MAX] = { 0U }; /*·ĵID*/ + UINT8 chSwitchNum = 0u; + UINT8 chIndex = 0u; + str_PointInArea strRouteSwitch = { 0u }; + UINT16 wLinkNum = 0u; + UINT8 chFunRtn = 0u; + UINT32 dwLen = UINT32_MAX; + UINT32 dwSglCrossLen = 0u; /*ѹ */ + UINT8 chDirTemp = 0u; + LOD_STRU sLODTrain = { 0U }; /*гǰλ*/ + LOD_STRU sLODRoute = { 0U }; /*·ʼλ*/ + UINT8 wLogLockDir = 0U; + + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + logSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + wLogId = LogSecIdBuff[logSecSum - 1U]; /*ȡһ߼*/ + + wStartSignal = GetLogicalRouteRelateBeginSigId(wLogRouteId); + chRouteDir = GetSignalDirection(wStartSignal); /*·źŻȷźŻڷһlink */ + + strTrainMinHead.wLinkId = GetTrainMinHeadLink(wTrainId); + strTrainMinHead.dwOffset = GetTrainMinHeadOffset(wTrainId); + strTrainMinTail.wLinkId = GetTrainMinTailLink(wTrainId); + strTrainMinTail.dwOffset = GetTrainMinTailOffset(wTrainId); + + strRouteZone.Dir = chRouteDir; + strRouteZone.pStart.wLinkId = GetSignalProtectLink(wStartSignal); + strRouteZone.pStart.dwOffset = GetSignalProtectLinkOff(wStartSignal); + + wLogLockDir = GetLogSecLogLockDir(wLogId); + wLogLockDir = ConvertDirectionToLogic(wLogLockDir); /*Ӫת߼*/ + if (DIR_SAME == wLogLockDir) + { + /*ͬȡյ*/ + strRouteZone.pEnd.wLinkId = GetLgcSecTmnlLink(wLogId); + strRouteZone.pEnd.dwOffset = GetLgcSecTmnlOffset(wLogId); + } + else if (DIR_CONVERT == wLogLockDir) + { + /*ȡ*/ + strRouteZone.pEnd.wLinkId = GetLgcSecOrgnLink(wLogId); + strRouteZone.pEnd.dwOffset = GetLgcSecOrgnOffset(wLogId); + } + else + { + chRtnVal = CI_ERROR; + } + + strTrainZone.Dir = GetTrainDir(wTrainId); + strTrainZone.pStart.wLinkId = strTrainMinTail.wLinkId; + strTrainZone.pStart.dwOffset = strTrainMinTail.dwOffset; + strTrainZone.pEnd.wLinkId = strTrainMinHead.wLinkId; + strTrainZone.pEnd.dwOffset = strTrainMinHead.dwOffset; + + chSwitchNum = GetLogRouteSWData(wLogRouteId, pRouteSwitchStruct); /*ڰ·ڵĵ*/ + if ((DIR_SAME == chRouteDir) || (DIR_CONVERT == chRouteDir)) + { + chRtnVal = CI_SUCCESS; + } + else + { + ;/* βϷ */ + } + if (CI_SUCCESS == chRtnVal) + { + chRtnVal = CheckLinkValid(strTrainMinHead.wLinkId, strTrainMinHead.dwOffset); + chRtnVal &= CheckLinkValid(strTrainMinTail.wLinkId, strTrainMinTail.dwOffset); + chRtnVal &= CheckLinkValid(strRouteZone.pStart.wLinkId, strRouteZone.pStart.dwOffset); + chRtnVal &= CheckLinkValid(strRouteZone.pEnd.wLinkId, strRouteZone.pEnd.dwOffset); + } + else + { + ;/* βϷ */ + } + if (CI_SUCCESS == chRtnVal) + { + for (chIndex = 0u; chIndex < chSwitchNum; chIndex++) + { + strRouteSwitch.SwitchInfo[chIndex].pointID = pRouteSwitchStruct[chIndex].SwitchId; + strRouteSwitch.SwitchInfo[chIndex].status = pRouteSwitchStruct[chIndex].SwitchPosition; + } + strRouteSwitch.SwitchNum = chSwitchNum; + /* ȡ·link */ + chRtnVal = dsuLinkSeqInAreaBaseSwitchInfo(strRouteZone.pStart, strRouteZone.pEnd, strRouteZone.Dir, &strRouteSwitch, &strRouteZone.pLinkSeq); + chRtnVal &= DsuLinkSeqBtwPoints(&strTrainZone.pStart, &strTrainZone.pEnd, &strTrainZone.Dir, &wLinkNum, strTrainZone.pLinkSeq.szLinkId); + strTrainZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + } + else + { + ; + } + if (CI_SUCCESS == chRtnVal) + { + chFunRtn = IsPointInPath(strTrainMinHead, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + /* гСȫǰ˲ڽ·ڣжгβ */ + chFunRtn = IsPointInPath(strTrainMinTail, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + chRtnVal = TRAIN_ENTER_ROUTE_NO;/* гβڽ· */ + chFunRtn = IsPointInPath(strRouteZone.pStart, strTrainZone); + if (CI_ERROR == chFunRtn) + { + chFunRtn = IsPointInPath(strRouteZone.pEnd, strTrainZone); + if (CI_ERROR == chFunRtn) + { + chRtnVal = TRAIN_ENTER_ROUTE_TAIL; + } + else + { + ; + } + } + else + { + ; + } + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_TAIL;/* гͷڽ·ڣβڽ· */ + } + } + else + { + /* гСȫͷڽ· */ + + /*жСβڲڽ·*/ + chFunRtn = IsPointInPath(strTrainMinTail, strRouteZone); + + /*жСβڽ·*/ + if (CI_SUCCESS == chFunRtn) + { + + dwLen = DsuAPointToBPoint(&strRouteZone.pStart, &strTrainMinHead, &chDirTemp); + dwSglCrossLen = (UINT32)GetSigCrossMaxLen() * 100U; + + if (0U == dwLen) + { + sLODTrain.Lnk = strTrainZone.pStart.wLinkId; + sLODTrain.Off = strTrainZone.pStart.dwOffset; + sLODTrain.Dir = strTrainZone.Dir; + sLODRoute.Lnk = strRouteZone.pStart.wLinkId; + sLODRoute.Off = strRouteZone.pStart.dwOffset; + sLODRoute.Dir = strRouteZone.Dir; + chFunRtn = IsPointABSameDir(sLODTrain, sLODRoute); + + if (FLAG_SET == chFunRtn) + { + /*гʻ·Ϊгͷʻ*/ + chRtnVal = TRAIN_ENTER_ROUTE_HEAD;/* гͷʻ*/ + } + else + { + chRtnVal = CI_ERROR; /*෴ʧ*/ + } + + } + else if ((UINT32_MAX == dwLen) || (chDirTemp != chRouteDir)) + { + chRtnVal = CI_ERROR;/* ѯ */ + } + else if (dwLen > dwSglCrossLen) + { + chRtnVal = TRAIN_ENTER_ROUTE_CROSS;/* гѹźŻ */ + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_HEAD;/* гͷʻ·δѹ */ + } + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_FULL;/* гȫʻ· */ + } + } + } + else + { + ; + } + return chRtnVal; +} + +/** +* @brief ѯгСǰ߼·λ(гСǰ) +* @param UINT16 wTrainId гID +* @param UINT16 wLogRouteId ߼·ID +* @return 0ѯʧ +* 1гδʻ· +* 2гͷʻ·δѹ +* 3гѹʼźŻ +* 4гȫʻ· +* 5гͷ· +*/ +UINT8 dsuLogRouteMinHeadTrainCrosSig(const UINT16 wTrainId, const UINT16 wLogRouteId) +{ + UINT8 chRtnVal = CI_ERROR; + UINT16 wStartSignal = 0u; + UINT8 chRouteDir = 0u; + struct_PathPoint strTrainMinHead = { 0u }; + struct_PathPoint strTrainMinTail = { 0u }; + str_Zone strRouteZone = { 0u }; + str_Zone strTrainZone = { 0u }; + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 wLogId = 0U; + RouteSwitchStruct pRouteSwitchStruct[ROUTE_SWITCH_SUM_MAX] = { 0U }; /*·ĵID*/ + UINT8 chSwitchNum = 0u; + UINT8 chIndex = 0u; + str_PointInArea strRouteSwitch = { 0u }; + UINT16 wLinkNum = 0u; + UINT8 chFunRtn = 0u; + UINT32 dwLen = UINT32_MAX; + UINT32 dwSglCrossLen = 0u; + UINT8 chDirTemp = 0u; + LOD_STRU sLODTrain = { 0U }; /*гǰλ*/ + LOD_STRU sLODRoute = { 0U }; /*·ʼλ*/ + UINT8 wLogLockDir = 0U; + + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + logSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + wLogId = LogSecIdBuff[logSecSum - 1U]; /*ȡһ߼*/ + + wStartSignal = GetLogicalRouteRelateBeginSigId(wLogRouteId); + chRouteDir = GetSignalDirection(wStartSignal); /*·źŻȷźŻڷһlink */ + + strTrainMinHead.wLinkId = GetTrainMinHeadLink(wTrainId); + strTrainMinHead.dwOffset = GetTrainMinHeadOffset(wTrainId); + strTrainMinTail.wLinkId = GetTrainMinTailLink(wTrainId); + strTrainMinTail.dwOffset = GetTrainMinTailOffset(wTrainId); + + strRouteZone.Dir = chRouteDir; + strRouteZone.pStart.wLinkId = GetSignalProtectLink(wStartSignal); + strRouteZone.pStart.dwOffset = GetSignalProtectLinkOff(wStartSignal); + wLogLockDir = GetLogSecLogLockDir(wLogId); + wLogLockDir = ConvertDirectionToLogic(wLogLockDir); /*Ӫת߼*/ + if (DIR_SAME == wLogLockDir) + { + /*ͬȡյ*/ + strRouteZone.pEnd.wLinkId = GetLgcSecTmnlLink(wLogId); + strRouteZone.pEnd.dwOffset = GetLgcSecTmnlOffset(wLogId); + } + else if (DIR_CONVERT == wLogLockDir) + { + /*ȡ*/ + strRouteZone.pEnd.wLinkId = GetLgcSecOrgnLink(wLogId); + strRouteZone.pEnd.dwOffset = GetLgcSecOrgnOffset(wLogId); + } + else + { + chRtnVal = CI_ERROR; + } + + strTrainZone.Dir = GetTrainDir(wTrainId); + strTrainZone.pStart.wLinkId = strTrainMinTail.wLinkId; + strTrainZone.pStart.dwOffset = strTrainMinTail.dwOffset; + strTrainZone.pEnd.wLinkId = strTrainMinHead.wLinkId; + strTrainZone.pEnd.dwOffset = strTrainMinHead.dwOffset; + + chSwitchNum = GetLogRouteSWData(wLogRouteId, pRouteSwitchStruct); /*ڰ·ڵĵ*/ + if ((DIR_SAME == chRouteDir) || (DIR_CONVERT == chRouteDir)) + { + chRtnVal = CI_SUCCESS; + } + else + { + ;/* βϷ */ + } + if (CI_SUCCESS == chRtnVal) + { + chRtnVal = CheckLinkValid(strTrainMinHead.wLinkId, strTrainMinHead.dwOffset); + chRtnVal &= CheckLinkValid(strTrainMinTail.wLinkId, strTrainMinTail.dwOffset); + chRtnVal &= CheckLinkValid(strRouteZone.pStart.wLinkId, strRouteZone.pStart.dwOffset); + chRtnVal &= CheckLinkValid(strRouteZone.pEnd.wLinkId, strRouteZone.pEnd.dwOffset); + } + else + { + ;/* βϷ */ + } + if (CI_SUCCESS == chRtnVal) + { + for (chIndex = 0u; chIndex < chSwitchNum; chIndex++) + { + strRouteSwitch.SwitchInfo[chIndex].pointID = pRouteSwitchStruct[chIndex].SwitchId; + strRouteSwitch.SwitchInfo[chIndex].status = pRouteSwitchStruct[chIndex].SwitchPosition; + } + strRouteSwitch.SwitchNum = chSwitchNum; + /* ȡ·link */ + chRtnVal = dsuLinkSeqInAreaBaseSwitchInfo(strRouteZone.pStart, strRouteZone.pEnd, strRouteZone.Dir, &strRouteSwitch, &strRouteZone.pLinkSeq); + chRtnVal &= DsuLinkSeqBtwPoints(&strTrainZone.pStart, &strTrainZone.pEnd, &strTrainZone.Dir, &wLinkNum, strTrainZone.pLinkSeq.szLinkId); + strTrainZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + } + else + { + ; + } + if (CI_SUCCESS == chRtnVal) + { + chFunRtn = IsPointInPath(strTrainMinHead, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + /* гСȫǰ˲ڽ·ڣжгβ */ + chFunRtn = IsPointInPath(strTrainMinTail, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + chRtnVal = TRAIN_ENTER_ROUTE_NO;/* гβڽ· */ + chFunRtn = IsPointInPath(strRouteZone.pStart, strTrainZone); + if (CI_ERROR == chFunRtn) + { + chFunRtn = IsPointInPath(strRouteZone.pEnd, strTrainZone); + if (CI_ERROR == chFunRtn) + { + dwSglCrossLen = (UINT32)GetSigCrossMaxLen() * 100U; + dwLen = DsuAPointToBPoint(&strRouteZone.pStart, &strTrainMinHead, &chDirTemp); + if ((dwLen > dwSglCrossLen) && ((chDirTemp == chRouteDir))) + { + /*ͷʻ·βڽ·ڣ鳵ͷѹ룬ڿѹѹ*/ + chRtnVal = TRAIN_ENTER_ROUTE_CROSS;/* гѹźŻ */ + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_TAIL; + } + } + else + { + ; + } + } + else + { + ; + } + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_TAIL;/* гͷڽ·ڣβڽ· */ + } + } + else + { + /* гСȫͷڽ· */ + chFunRtn = IsPointInPath(strTrainMinTail, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + dwSglCrossLen = (UINT32)GetSigCrossMaxLen() * 100U; + dwLen = DsuAPointToBPoint(&strRouteZone.pStart, &strTrainMinHead, &chDirTemp); + + if (0U == dwLen) + { + sLODTrain.Lnk = strTrainZone.pStart.wLinkId; + sLODTrain.Off = strTrainZone.pStart.dwOffset; + sLODTrain.Dir = strTrainZone.Dir; + sLODRoute.Lnk = strRouteZone.pStart.wLinkId; + sLODRoute.Off = strRouteZone.pStart.dwOffset; + sLODRoute.Dir = strRouteZone.Dir; + chFunRtn = IsPointABSameDir(sLODTrain, sLODRoute); + + if (FLAG_SET == chFunRtn) + { + /*гʻ·Ϊгͷʻ*/ + chRtnVal = TRAIN_ENTER_ROUTE_HEAD;/* гͷʻ*/ + } + else + { + chRtnVal = CI_ERROR; /*෴ʧ*/ + } + + } + else if ((UINT32_MAX == dwLen) || (chDirTemp != chRouteDir)) + { + chRtnVal = CI_ERROR;/* ѯ */ + } + else if (dwLen > dwSglCrossLen) + { + chRtnVal = TRAIN_ENTER_ROUTE_CROSS;/* гѹźŻ */ + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_HEAD;/* гͷʻ·δѹ */ + } + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_FULL;/* гȫʻ· */ + } + } + } + else + { + ; + } + return chRtnVal; +} + + +/* +* ߼·űźż鴦 +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERRORʧ +* CI_SUCCESSɹ +* ϱ룺 EFUNC_KeepLogRouteSignalProcess +*/ +UINT8 KeepLogRouteSignalProcess(const UINT16 wLogRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_KeepLogRouteSignalProcess; + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*鱨ATSͣȻռ鿪ŵάźſŹУһֱ*/ + UINT8 devState = 0u; /*豸״̬*/ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + /* ߼ */ + /* ·ලģʽΪCBTC*/ + devState = GetLogicalRouteLevel(wLogRouteId); + if (ROUTE_LEVEL_CBTC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wLogRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·š*/ + devState = GetLogicalRouteState(wLogRouteId); + if (ROUTE_LOGICAL_STATE_OPEN == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wLogRouteId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteSignalCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղ(Ԥ)*/ + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteSwitchCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteFloodGateCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ӷ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenLogRoutePlatformCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteSectionCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (LOG_ROUTE_TRAIN_CROSS == checkResult) + { + /*гѹͨ*/ + reResult = LOG_ROUTE_TRAIN_CROSS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + return reResult; +} + +/* +* ߼·źż鴦 +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERRORʧ +* CI_SUCCESSɹ +* ϱ룺 EFUNC_LogRouteSignalProcess +*/ +UINT8 OpenLogRouteSignalProcess(const UINT16 wLogRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_OpenLogRouteSignalProcess; + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*鱨ATSͣȻռ鿪ŵάźſŹУһֱ*/ + UINT8 devState = 0u; /*豸״̬*/ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + /* ߼ */ + /* ·ලģʽΪCBTC*/ + devState = GetLogicalRouteLevel(wLogRouteId); + if (ROUTE_LEVEL_CBTC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wLogRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·ա*/ + devState = GetLogicalRouteState(wLogRouteId); + if ((ROUTE_LOGICAL_STATE_LOCK == devState) || (ROUTE_LOGICAL_STATE_LOCKERR == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wLogRouteId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenLogRouteSignalCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /*ղ(Ԥ)*/ + /*żΣͽӷͬάźŻļ*/ + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteSwitchCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteFloodGateCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ӷ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenLogRoutePlatformCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteSectionCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (LOG_ROUTE_TRAIN_CROSS == checkResult) + { + /*гѹͨ*/ + reResult = LOG_ROUTE_TRAIN_CROSS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + return reResult; +} +/* +* ߼·źŻ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ void +*/ +void DriveLogRouteSignalOpen(const UINT16 wLogRouteId) +{ + UINT16 wLogSignalId = 0U; /*߼·źŻ*/ + UINT8 oriDriveColor = 0u; /*·Ӧźſɫ*/ + UINT8 lightExtinctState = 0u;/*źŻϢ*/ + UINT8 signalIsfushiFlag = 0u; + UINT8 signalCurDriveColor = 0u; + + wLogSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + oriDriveColor = GetLogicalRouteOpenColor(wLogRouteId); /*ȡ߼·ɫ*/ + lightExtinctState = GetSignalLightExtinctState(wLogSignalId);/*źŻ״̬*/ + + signalIsfushiFlag = GetSignalIsfushiFlag(wLogSignalId); + signalCurDriveColor = GetSignalCurDriveColor(wLogSignalId); + if ((0u == wLogSignalId) || (SIGNAL_SUM_MAX <= wLogSignalId)) + { + /**/ + } + else + { + if ((SIGNAL_DRIVECOLOUR_NULL == signalCurDriveColor) && (SIGNALTYPE_FUSHI_YES != signalIsfushiFlag) + && (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState)) + {/*δźŻ߼·źŻֻCBTCµźŻ*/ + switch (oriDriveColor) + { + case SIGNAL_SHOWCOLOUR_GREENCLOSE: + SetSignalCurDriveColor(wLogSignalId, SIGNAL_DRIVECOLOUR_GREENCLOSE); + break; + case SIGNAL_SHOWCOLOUR_YELLOWCLOSE: + SetSignalCurDriveColor(wLogSignalId, SIGNAL_DRIVECOLOUR_YELLOWCLOSE); + break; + default: /*Чɫд*/ + break; + } + } + } +} + +/* +* ߼·źŻر +* ˵ const UINT16 wLogSignalId, źŻID +* ֵ void +*/ +void DriveLogRouteSignalClose(const UINT16 wLogSignalId) +{ + UINT8 allSignalBrightFlag = 0u; /*ȫվƱ־*/ + UINT8 belongVirCIid = 0u; + UINT8 signalIsfushiFlag = 0u; + UINT8 lightExtinctState = 0u; + UINT8 sigalMaintainState = 0u; + UINT8 detainOpenRedBright = 0u; + UINT8 signalDetainFlag = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + if ((0u == wLogSignalId) || (SIGNAL_SUM_MAX <= wLogSignalId)) + { + /**/ + } + else + { + /**/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCIid = GetSignalBelongVirCiId(wLogSignalId); + allSignalBrightFlag = GetVirCIAllSignalBrightState(belongVirCIid); /*ȫվƱ־*/ + } + else + { + allSignalBrightFlag = GetAllSignalBrightFlag(); /*ȫվƱ־*/ + } + + /*ʲôʱ򣬸ʾźŻرն*/ + signalIsfushiFlag = GetSignalIsfushiFlag(wLogSignalId); + if (SIGNALTYPE_FUSHI_YES == signalIsfushiFlag) + { + /*ǸźŻ*/ + SetSignalCurDriveColor(wLogSignalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + else + { + lightExtinctState = GetSignalLightExtinctState(wLogSignalId); + sigalMaintainState = GetSignalMaintainState(wLogSignalId);/*źŻά޵״̬*/ + + if ((CI_ALL_SIGNAL_BRIGHT_YES == allSignalBrightFlag) || + (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) || + (MAINTAIN_STATE_YES == sigalMaintainState) + ) + {/*Ϣ*/ + + SetSignalCurDriveColor(wLogSignalId, SIGNAL_DRIVECOLOUR_RED); + } + else if (SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) + { + detainOpenRedBright = GetCiFunctionSwitchConfig(FUNC_DETAIN_OPEN_RED); + if (FUNC_SWITCH_ON == detainOpenRedBright) + { /*˿۳󿪷ź*/ + signalDetainFlag = GetSignalDetainFlag(wLogSignalId); + if (SIGNAL_DETAIN_NO == signalDetainFlag) + { + SetSignalCurDriveColor(wLogSignalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + else + { + SetSignalCurDriveColor(wLogSignalId, SIGNAL_DRIVECOLOUR_RED); + } + + } + else + { + SetSignalCurDriveColor(wLogSignalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + } + else + {/*δյܵźŻϢ*/ + + SetSignalCurDriveColor(wLogSignalId, SIGNAL_DRIVECOLOUR_RED); + } + } + } +} + +/* +* ߼·ලȷ +* ˵ const UINT16 wLogRouteId ߼·ID +* ֵ ROUTE_LEVEL_BLOC ʽ +* ROUTE_LEVEL_CBTC CBTC +* Created by LQ 2023/10/11 +*/ +void LogicRouteLevelConfirmProcess(const UINT16 wLogRouteId) +{ + UINT8 cLogicRouteLevel = ROUTE_LEVEL_BLOC; + UINT8 cSignalOpenState = 0U; /*źŻ״̬*/ + UINT8 cMaintainState = 0U; /*źŻά޵״̬*/ + UINT16 signalId = 0U; + + signalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + if ((0U < signalId) && (SIGNAL_SUM_MAX > signalId)) + { + cSignalOpenState = GetSignalLightExtinctState(signalId); + cMaintainState = GetSignalMaintainState(signalId); + + if ((SIGNAL_LIGHT_EXTICT_STATE_NO == cSignalOpenState) && (MAINTAIN_STATE_NO == cMaintainState)) + { + cLogicRouteLevel = ROUTE_LEVEL_CBTC; /*·ʼźŻơҲά޵״̬CBTC*/ + } + else + { + cLogicRouteLevel = ROUTE_LEVEL_BLOC; /*·ʼźŻơά޵״̬صʽ*/ + } + } + else + { + cLogicRouteLevel = ROUTE_LEVEL_BLOC; /*źŻIDǷصʽ*/ + } + SetLogicalRouteLevel(wLogRouteId, cLogicRouteLevel); /*߼·ල*/ +} + +/* +* ߼··ʽʱ߼߼ϴ +* ˵ const UINT16 wLogSectionId ߼ID +* ֵ void +* cgh-20231012 +*/ +void LogRouteErrLockCmdDeal(const UINT16 wLogSectionId) +{ + UINT8 chLogSecBelLogRouteSum = 0U;/*߼߼·Ŀ*/ + LogSecLockBelLogRouteStruct* szLogSecBelLogRouteData = NULL;/*߼߼·*/ + UINT16 wLogSecBelLogRouteId = 0U;/*߼߼·ID*/ + UINT8 ii = 0U; + UINT8 chLogSecLogLockState = 0U; /*߼߼״̬*/ + UINT16 wFirstNormalLockLogId = 0U; /*߼·һյ߼ID*/ + UINT8 chLogSecLockBelLogRouteSta = 0U; /*·״̬*/ + UINT16 wLogSecRelatePhyId = 0U;/*߼ιID*/ + UINT8 chPhySecCurMergeState = 0U;/*εǰں״̬*/ + UINT16 wLogRouteRelateSigId = 0U;/*߼·źŻ*/ + UINT8 chKeepFlag = 0U;/*ִб־*/ + + if ((0U < wLogSectionId) && (LOGIC_SECTION_SUM_MAX > wLogSectionId)) + { + chLogSecBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSectionId); + szLogSecBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSectionId); + if (NULL != szLogSecBelLogRouteData) + { + for (ii = 0U; ii < chLogSecBelLogRouteSum; ii++) + { + chKeepFlag = 0U; + wLogSecBelLogRouteId = szLogSecBelLogRouteData[ii].wLogSecLockBelLogRouteId; + + if (ROUTE_LOGICAL_SUM_MAX < wLogSecBelLogRouteId) + { + /*߼·IDЧ*/ + break; + } + else + { + chLogSecLockBelLogRouteSta = GetLogicalRouteState(wLogSecBelLogRouteId); + chLogSecLogLockState = GetLogSecLogLockState(wLogSectionId); + wFirstNormalLockLogId = GetLogRouteFirNormalLockLogId(wLogSecBelLogRouteId); + wLogSecRelatePhyId = GetLgcSecRelativePhySecId(wLogSectionId); + chPhySecCurMergeState = GetPhySecCurMergeState(wLogSecRelatePhyId); + wLogRouteRelateSigId = GetLogicalRouteRelateBeginSigId(wLogSecBelLogRouteId); + + if ((0U < wLogRouteRelateSigId) && (SIGNAL_SUM_MAX > wLogRouteRelateSigId)) + { + chKeepFlag = 1U; + } + else + { + if (wFirstNormalLockLogId == wLogSectionId) + { + /*߼·ʼźŻЧҪѯһյǰһδ*/ + chKeepFlag = CheckLogRouteLogSecLastSecLock(wLogSecBelLogRouteId, wLogSectionId); + } + else + { + /*ǵһյ߼Σ*/ + chKeepFlag = 1U; + } + + } + +#if 1 + if ((1U == chKeepFlag) && ((ROUTE_LOGICAL_STATE_UNLOCKWAIT == chLogSecLockBelLogRouteSta) || (ROUTE_LOGICAL_STATE_LOCKERR == chLogSecLockBelLogRouteSta)) && + (LOG_SECTION_LOGLOCK_NORMAL == chLogSecLogLockState) && (wFirstNormalLockLogId == wLogSectionId) && (SECTION_OCCUPY_NO == chPhySecCurMergeState)) +#endif +#if 0 + if ((1U == chKeepFlag) && (LOG_SECTION_LOGLOCK_NORMAL == chLogSecLogLockState) + && (wFirstNormalLockLogId == wLogSectionId) && (SECTION_OCCUPY_NO == chPhySecCurMergeState)) +#endif + { + /*߼߼·״̬Ϊȴ쳣&&߼߼״̬Ϊ߼ + &&߼ǶӦ߼·һյ&&߼ζӦΪռ*/ + SetLogRouteStateManage(wLogSecBelLogRouteId, ROUTE_LOGICAL_STATE_UNLOCKDELAY); + } + else + { + ; /**/ + } + } + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ߼·ιϽݴ +* ˵ const UINT16 wLogSectionId, ߼ID +* ֵ void +* by cgh 20231013 +*/ +void LogRouteErrLockFaultProcess(const UINT16 wLogSectionId) +{ + UINT8 chLogSecLockBelLogRouteSum = 0U;/*߼߼·Ŀ*/ + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT16 wLogSecBelLogRouteId = 0U;/*߼߼·ID*/ + UINT8 ii = 0U; + UINT8 chLogRouteState = 0U;/*߼·״̬*/ + UINT16 wLogRouteRelateBeginSigId = 0U;/*߼·ʼźŻID*/ + UINT8 chLogSecLogLockState = 0U;/*߼߼״̬*/ + UINT16 wLogSecRelatePhyId = 0U;/*߼ιID*/ + UINT8 chPhySecCurMergeState = 0U;/*εǰں״̬*/ + UINT8 chLogLockDir = 0U;/*߼߼·*/ + + if ((0U < wLogSectionId) && (LOGIC_SECTION_SUM_MAX > wLogSectionId)) + { + chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSectionId); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSectionId); + + if (NULL != szLogSecLockBelLogRouteData) + { + for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++) + { + wLogSecBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId; + if ((0U < wLogSecBelLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wLogSecBelLogRouteId)) + { + chLogRouteState = GetLogicalRouteState(wLogSecBelLogRouteId); + if (ROUTE_LOGICAL_STATE_OPEN == chLogRouteState) + { + /*߼·ʼźŻźŻţʱҪرźŻ*/ + wLogRouteRelateBeginSigId = GetLogicalRouteRelateBeginSigId(wLogSecBelLogRouteId); + if ((0U < wLogRouteRelateBeginSigId) && (SIGNAL_SUM_MAX > wLogRouteRelateBeginSigId)) + { + (void)DriveSignalClose(wLogRouteRelateBeginSigId); /*źŹر*/ + /*߼·Ӧʽʱ߼ι*/ + + /*رźԺ߼·״̬Ϊȴִʱ*/ + SetLogRouteStateManage(wLogSecBelLogRouteId, ROUTE_LOGICAL_STATE_UNLOCKWAIT); + LogRouteErrLockCmdDeal(wLogSectionId); + } + else + { + ; /**/ + } + } + else + { + chLogSecLogLockState = GetLogSecLogLockState(wLogSectionId); + + if ((LOG_SECTION_LOGLOCK_EXCEPT != chLogSecLogLockState) && (ROUTE_LOGICAL_STATE_UNLOCKDELAY != chLogRouteState)) + { + /*߼״̬Ϊ"쳣"ҽ·״̬ҲΪʱ*/ + SetCiSendCmdBackInfoData(CI_BACK_PSEC_QGJ_UNLOCK, CI_DEVICE_TYPE_LOGICSEC, wLogSectionId, 0U, 0U); + } + else + { + wLogSecRelatePhyId = GetLgcSecRelativePhySecId(wLogSectionId); + chPhySecCurMergeState = GetPhySecCurMergeState(wLogSecRelatePhyId); + if ((LOG_SECTION_LOGLOCK_EXCEPT == chLogSecLogLockState) && (SECTION_OCCUPY_NO == chPhySecCurMergeState)) + { + + chLogLockDir = GetLogicalRouteDir(wLogSecBelLogRouteId); + SetLogSecLogLockState(wLogSectionId, LOG_SECTION_LOGLOCK_NO, chLogLockDir); + /*߼·ǰ߼Ѿ쳣߼·Ҫ쳣*/ + LogRouteExpLockContinue(wLogSecBelLogRouteId); + /*߼·*/ + ErrLockFaultUnLockLogRoute(wLogSectionId, wLogSecBelLogRouteId); + } + else + { + ; /**/ + } + } + } + } + else + { + ; /**/ + } + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ߼·߼ιϴ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ void +* by cgh 20231013 +*/ +void LogRouteExpLockContinue(const UINT16 wLogRouteId) +{ + UINT8 chReVal = CI_ERROR; + UINT16 wLogRouteInLogSecSum = 0U;/*߼·߼Ŀ*/ + UINT16* szLogRouteInLogSecIdBuf = NULL;/*߼·߼ID*/ + UINT16 ii = 0U; + UINT8 chLogSecLogLockState = 0U;/*߼߼״̬*/ + UINT16 wFirstNormalLockLogId = 0U;/*һյ߼id*/ + UINT16 wLogSecRelatePhyId = 0U;/*߼ιID*/ + UINT8 chPhySecCurMergeState = 0U;/*εǰں״̬*/ + UINT16 wOtherLogRouteId = 0U;/*߼·ID*/ + + if ((0U < wLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wLogRouteId)) + { + wLogRouteInLogSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + szLogRouteInLogSecIdBuf = GetLogicalRouteInLogSecId(wLogRouteId); + + if (NULL != szLogRouteInLogSecIdBuf) + { + for (ii = 0U; ii < wLogRouteInLogSecSum; ii++) + { + chReVal = CheckLogSecLockBelLogRoute(szLogRouteInLogSecIdBuf[ii], wLogRouteId); + if (CI_SUCCESS == chReVal) + { + chLogSecLogLockState = GetLogSecLogLockState(szLogRouteInLogSecIdBuf[ii]); + + if (LOG_SECTION_LOGLOCK_NORMAL == chLogSecLogLockState) + { + if (0U == wFirstNormalLockLogId) + { + wFirstNormalLockLogId = szLogRouteInLogSecIdBuf[ii]; + } + else + { + ; /*еһյ߼*/ + } + } + else if (LOG_SECTION_LOGLOCK_EXCEPT == chLogSecLogLockState) + { + /*쳣*/ + break; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + + if (wLogRouteInLogSecSum == ii) + { + if (0U != wFirstNormalLockLogId) + { + wOtherLogRouteId = wLogRouteId;/*߼·*/ + } + else + { + /*һµǰ߼·һ߼ι߼·δ*/ + wFirstNormalLockLogId = GetOtherLogRouteFirNormalLogId(szLogRouteInLogSecIdBuf[wLogRouteInLogSecSum-1U], wLogRouteId,&wOtherLogRouteId); + } + /*˵߼·ڲڹ*/ + if ((0U != wFirstNormalLockLogId) && (0U < wOtherLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wOtherLogRouteId)) + { + wLogSecRelatePhyId = GetLgcSecRelativePhySecId(wFirstNormalLockLogId); + chPhySecCurMergeState = GetPhySecCurMergeState(wLogSecRelatePhyId); + + if (SECTION_OCCUPY_NO == chPhySecCurMergeState) + { + /*һ߼ζӦڱ߼·յ߼ξ쳣*/ + SetPhyIncLogSecLogLockState(wLogSecRelatePhyId, LOG_SECTION_LOGLOCK_EXCEPT, wOtherLogRouteId); + } + else + { + ; /*ռѹ*/ + } + } + else + { + ; /*ѾûյΣ*/ + } + } + else + { + ; /*йβ*/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ȡ߼·һյ߼ID +* ˵ const UINT16 wLogSecId ߼ID + const UINT16 wLogRouteId, ߼·ID + UINT16* wOtherLogRouteId ߼·ID +* ֵ ߼·һյ߼ID +* by cgh 20231020 +*/ +UINT16 GetOtherLogRouteFirNormalLogId(const UINT16 wLogSecId, const UINT16 wLogRouteId, UINT16* wOtherLogRouteId) +{ + UINT16 wFirstNormalLockLogId = 0U;/*߼·һյ߼ID*/ + UINT16 chReVal = 0U; + UINT16 wLogRouteInLogSecSum = 0U;/*߼·߼Ŀ*/ + UINT16* szLogRouteInLogSecIdBuf = NULL;/*߼·߼ID*/ + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 chLogSecLogLockState = 0U;/*߼߼״̬*/ + UINT8 chLogSecLockBelLogRouteSum = 0U;/*߼߼·Ŀ*/ + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT16 wLogSecBelLogRouteId = 0U;/*߼߼·ID*/ + + chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSecId); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSecId); + *wOtherLogRouteId = 0U; + + if (NULL != szLogSecLockBelLogRouteData) + { + for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++) + { + wLogSecBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId; + if ((0U < wLogSecBelLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wLogSecBelLogRouteId) && (wLogRouteId != wLogSecBelLogRouteId)) + { + wLogRouteInLogSecSum = GetLogicalRouteInLogSecSum(wLogSecBelLogRouteId); + szLogRouteInLogSecIdBuf = GetLogicalRouteInLogSecId(wLogSecBelLogRouteId); + + if (NULL != szLogRouteInLogSecIdBuf) + { + for (jj = 0U; jj < wLogRouteInLogSecSum; jj++) + { + chReVal = CheckLogSecLockBelLogRoute(szLogRouteInLogSecIdBuf[jj], wLogSecBelLogRouteId); + if (CI_SUCCESS == chReVal) + { + chLogSecLogLockState = GetLogSecLogLockState(szLogRouteInLogSecIdBuf[jj]); + + if (LOG_SECTION_LOGLOCK_NORMAL == chLogSecLogLockState) + { + if (0U == wFirstNormalLockLogId) + { + wFirstNormalLockLogId = szLogRouteInLogSecIdBuf[jj]; + } + else + { + ; /*еһյ߼*/ + } + } + else if (LOG_SECTION_LOGLOCK_EXCEPT == chLogSecLogLockState) + { + /*쳣*/ + break; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + + if (wLogRouteInLogSecSum == jj) + { + /*˵߼·ڲڹ*/ + if (0U != wFirstNormalLockLogId) + { + *wOtherLogRouteId = wLogSecBelLogRouteId; + /*߼·ҵһյ߼Σݣ*/ + break; + } + else + { + ; /**/ + } + } + else + { + ; /*йβ*/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + } + else + { + ; /*ִ*/ + } + return wFirstNormalLockLogId; +} + +/* +* ȡָ߼·һ߼յ߼ʱʼں +* ˵ const UINT16 wLogRouteId, ߼·ID +* +* ֵ 0: ȡʧ +* >0: ߼·һ߼յ߼ʱʼں +* by cgh 20231017 +*/ +UINT32 GetLogRouFirDelayErLockStaCyc(const UINT16 wLogRouteId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + UINT16 wFirstNormalLockLogId = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ߼·±*/ + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + wFirstNormalLockLogId = GetLogRouteFirNormalLockLogId(wLogRouteId); + retVal = GetLogDelayErrlockStartCycNum(wFirstNormalLockLogId); + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָ߼·һ߼յ߼ʱʼں +* ˵const UINT16 wLogRouteId, ߼·ID +* const UINT32 startCycNum ʼں +* ֵ +* by cgh 20231017 +* +*/ +void SetLogRouFirDelayErLockStaCyc(const UINT16 wLogRouteId, const UINT32 startCycNum) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wFirstNormalLockLogId = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ߼·±*/ + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + wFirstNormalLockLogId = GetLogRouteFirNormalLockLogId(wLogRouteId); + SetLogDelayErrlockStartCycNum(wFirstNormalLockLogId, startCycNum); + } + else + { + /**/ + } +} + +/* +* ߼·ʽ +* ˵ const UINT16 wPhySectionId, ID +* ֵ void +* by cgh 20231002 +*/ +void LogRouteErrLockFaultManage(const UINT16 wPhySectionId) +{ + UINT8 ii = 0U; + UINT8 chPhyIncLogSum = 0U;/*ΰ߼Ŀ*/ + UINT16* pPhyIncLogId = NULL;/*ΰ߼ID*/ + UINT8 chLogRouteFirstLgcSecCheck = 0U;/*߼ǷΪ߼·յĵһμ*/ + + chPhyIncLogSum = GetPhySecIncLogSecSum(wPhySectionId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(wPhySectionId); + + if (NULL != pPhyIncLogId) + { + for (ii = 0U; ii < chPhyIncLogSum; ii++) + { + /*߼߼·գʱΪ߼·һյ߼βʽ*/ + chLogRouteFirstLgcSecCheck = LogSecLogRouteFirstLockCheck(pPhyIncLogId[ii]); + + if (CI_SUCCESS == chLogRouteFirstLgcSecCheck) + { + /*߼·Ӧʽʱ߼ι*/ + LogRouteErrLockCmdDeal(pPhyIncLogId[ii]); + } + else + { + SetErrorData(EFUNC_LOGSEC_FAULT_FIRST_SECLOCK, CI_DEVICE_TYPE_LOGICSEC, pPhyIncLogId[ii], + ETYPE_LOGSEC_FIRSTLOCK_STATE, chLogRouteFirstLgcSecCheck, ESEND_LEVEL_ZERO); + } + /*߼·ιϽ*/ + LogRouteErrLockFaultProcess(pPhyIncLogId[ii]); + } + } + else + { + ; /**/ + } +} + +/* ·IDıΰ +* ˵ const UINT16 expLkOverlapId, ATSֵط͵ID +* const UINT16 routeId ·ID +* ֵ +*/ +void SetAtsLockOverlapHaveRouteId(const UINT16 expLkOverlapId, const UINT16 routeId) +{ + UINT16 routeOverlapSum = 0U; /*·Ŀ*/ + UINT16 routedLockOverlapId = 0U; /*·չOverlapId*/ + UINT8 retVal = CI_SUCCESS; /*ֵ*/ + UINT8 routeState = 0U; /*·״̬*/ + UINT16 preOverlepId = 0U; + UINT32 startXuanPaiCyc = 0U; + UINT16 phySectionId = 0U; + UINT8 phySectionSta = 0U; + UINT8 belongCiId = 0U; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 virCIid = 0U; + UINT8 ciCtrModeFlag = 0U; + UINT8 routeStateFlag = 0U; + UINT8 flag = 0U; + + routeStateFlag = GetRouteStateFlag(routeId); + + if ((0U == expLkOverlapId) || (UINT16_MAX == expLkOverlapId)) + {/*жЧ*/ + retVal = CI_ERROR; + } + /*жǷҪݱν*/ + if (CI_SUCCESS == retVal) + { + belongCiId = GetOverlapBelongCiId(expLkOverlapId); + if (localCiId != belongCiId) + { + if (0U < belongCiId)/****************ӽӿ*/ + { + AddCiSendToCiCmdInfo(LOCK_OVERLAP_HAVE_ROUTE_CMD, expLkOverlapId, routeId, belongCiId);/*ν*/ + } + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + routeOverlapSum = GetRouteOverlapSum(routeId); /*ȡ·ıĿ*/ + if (0U < routeOverlapSum) + { + /*IDǷڵǰ·*/ + if (1U == checkExpOverlapBelongToRtOrNot(routeId, expLkOverlapId)) + {/*յıIDڽ·ıID*/ + flag = 1U; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + /*鵱ǰ·ıǷѡŹ*/ + if (CI_SUCCESS == retVal) + { + preOverlepId = GetRouteAtsExpLkOverlapId(routeId); + if (0U < preOverlepId) + { + startXuanPaiCyc = GetOverlapXuanPaiStartCycNum(preOverlepId); + if (0U < startXuanPaiCyc) + { + retVal = CI_ERROR; + } + else + { + /*ʲôҲ*/ + } + } + else + { + /*ʲôҲ*/ + } + } + /*жϵǰģʽǷӦձ*/ + if (CI_SUCCESS == retVal) + { + virCIid = GetOverlapBelongVirCiId(expLkOverlapId); + if (FUNC_SWITCH_ON == includeVirFlag) + { + ciCtrModeFlag = GetVirCImode(virCIid);/*ȡģʽ*/ + } + else + { + ciCtrModeFlag = GetCiModeFlag(); /*ȡģʽ*/ + } + + if ((CI_MODE_CI_LOCAL == ciCtrModeFlag) || (0U == ciCtrModeFlag))/*ػ߻ȡ󣬷ֵزӦ˹*/ + { + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + routedLockOverlapId = GetRouteOverlapLockedId(routeId); /*ȡ·չID*/ + + if (0U == routedLockOverlapId) + { + /*жϽ·״̬Ƿձձ*/ + routeState = GetRouteState(routeId); + + if ((ROUTE_STATE_FIRST_XUANPAI == routeState) + || (ROUTE_STATE_XUANPAI == routeState) + || (ROUTE_STATE_FIRST_LOCK == routeState) + || (ROUTE_STATE_FIRST_LOCKERR == routeState) + || (ROUTE_STATE_YUXIAN_OPEN == routeState) + || (ROUTE_STATE_YUXIAN_LOCK == routeState) + || (ROUTE_STATE_NEAR_OPEN == routeState) + || (ROUTE_STATE_NEAR_LOCK == routeState) + || (ROUTE_STATE_NEAR_LOCKERR == routeState) + || ((ROUTE_STATE_AUTO_UNLOCK == routeState) && (ROUTE_STATE_FLAG_YES == routeStateFlag)) + ) + {/*ָID·ձID*/ + /*ATSΣ˹*/ + phySectionId = GetRouteLastPhySectionId(routeId); + phySectionSta = GetPhySecCurMergeState(phySectionId); + if (SECTION_OCCUPY_YES == phySectionSta) + { + SetOverlapAtsOrlaborLockCmdFlag(expLkOverlapId, LOCK_OVERLAP_CMD_YES);/*ñ־ڱνʱ*/ + } + else + { + /*nothing do*/ + } + + SetRouteAtsExpLkOverlapId(routeId, expLkOverlapId);/*ձ*/ + + SetOverlapFromSetRouteCmdFlag(expLkOverlapId, OVERLAP_ROUTE_FLAG_YES);/*ñɽ·ʶ*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + ; /*ǰ·*/ + } + } + + } + + if (0U == flag) + {/*͵βκν·ı*/ + + /*ֵ*/ + SetErrorData(EFUNC_SetAtsLockOverlapHaveRouteId, CI_DEVICE_TYPE_OVERLAP, expLkOverlapId, ETYPE_ROUTE_OVERLAP_UNLOCK, 0U, ESEND_LEVEL_ATS); + + } + + } +} + + +/** +* @brief ֽ·߼߼մ +* @param const UINT16 wLogSecId ߼ID +* const UINT16 routeId ǰյĽ·ID +* @return CI_SUCCESSֽ·߼ճɹ +* CI_ERRORֽ·߼ʧ +*/ +UINT8 LogSecLockInHalfRouteProcess(const UINT16 wLogSecId, const UINT16 routeId) +{ + UINT8 funcRet = CI_ERROR; + UINT8 curLogLockState = 0u; /*εǰ߼״̬*/ + UINT8 validLogRouteIdBuf[ROUTE_LOGICAL_SUM_MAX] = { 0U }; /*ҪЧ߼·ID*/ + UINT8 LogSecLockBelLogRouteSum = 0U; + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 ii = 0U; + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT8 validRouteSum = 0U; /*߼·*/ + UINT16 validRouteId = 0u; /*ǰյĽ·*/ + UINT16 LogicalRouteInLogSecSum = 0U; + UINT16* wLogicalRouteInLogSecIdBuf = NULL; + UINT8 oldLogLockState = 0U; + UINT16 wRouteIndex = 0U; + UINT8 cLocalCiId = 0U; /*CI*/ + UINT8 cLogSecBelongCiId = 0U; /*߼CI*/ + UINT8 cPartRouteDir = 0U; /*ֽ·շ*/ + UINT8 cLogRouteDir = 0U; /*߼·շ*/ + + curLogLockState = GetLogSecLogLockState(wLogSecId); + LogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSecId); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSecId); + wRouteIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if ((NULL != szLogSecLockBelLogRouteData) && (ROUTE_SUM_MAX > wRouteIndex)) + { + funcRet = CI_SUCCESS; + + + if (0U < LogSecLockBelLogRouteSum) + { + if (LOG_SECTION_LOGLOCK_NORMAL == curLogLockState) + { + cLocalCiId = GetSystemParaLocalCiId(); + cLogSecBelongCiId = GetLogSecBelongCiId(wLogSecId); + if (cLocalCiId == cLogSecBelongCiId) + { + for (jj = 0U; jj < LogSecLockBelLogRouteSum; jj++) + { + /*߼߼ճ*/ + validRouteId = szLogSecLockBelLogRouteData[jj].wLogSecLockBelLogRouteId; + + SetLogSecLogLockState(wLogSecId, LOG_SECTION_LOGLOCK_NO, szLogSecLockBelLogRouteData[jj].wLogSecLockBelLogRouteDir); + + /*߼յ·*/ + funcRet = DelLogSecBelongLogRouteId(wLogSecId, validRouteId); + + if (CI_SUCCESS == funcRet) + { + for (kk = 0U; kk < validRouteSum; kk++) + { + if (validRouteId == validLogRouteIdBuf[kk]) + { + /*ȥ*/ + break; + } + } + if (validRouteSum == kk) + { + /*δظ*/ + if (ROUTE_LOGICAL_SUM_MAX > validRouteSum) + { + validLogRouteIdBuf[validRouteSum++] = (UINT8)validRouteId; + } + else + { + funcRet = CI_ERROR; /*߼·ޣʧܴ*/ + } + } + } + else + { + ; /*󣬲*/ + } + + if (CI_ERROR == funcRet) + { + break; + } + } + + if (CI_SUCCESS == funcRet) + { + /*߼·*/ + for (ii = 0U; ii < validRouteSum; ii++) + { + if (0U < validLogRouteIdBuf[ii]) + { + LogicalRouteInLogSecSum = GetLogicalRouteInLogSecSum(validLogRouteIdBuf[ii]); + wLogicalRouteInLogSecIdBuf = GetLogicalRouteInLogSecId(validLogRouteIdBuf[ii]); + + for (kk = 0U; kk < LogicalRouteInLogSecSum; kk++) + { + oldLogLockState = GetLogSecLogLockState(wLogicalRouteInLogSecIdBuf[kk]); + + if (LOG_SECTION_LOGLOCK_NO != oldLogLockState) + { + break; /*·л߼գԽ˽·ΪУҪͷ*/ + } + } + + if (kk == LogicalRouteInLogSecSum) + { + /*߼·߼ζδգѾ߼·һ߼Σø߼·Уĵȳͷ*/ + SetLogRouteStateManage(validLogRouteIdBuf[ii], ROUTE_LOGICAL_STATE_IDLE); + } + } + } + } + } + else + { + cPartRouteDir = GetRouteDirection(routeId); + cLogRouteDir = GetLogSecLogLockDir(wLogSecId); + if ((1U == LogSecLockBelLogRouteSum) && (cPartRouteDir != cLogRouteDir)) + { + /*߼α߼·գͨ*/ + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_SEC_LOCK_APPLY, routeId, 0U, cLogSecBelongCiId); + } + else + { + /**/ + } + } + } + } + else + { + ; /*߼߼յ߼Σֱӷسɹ*/ + } + + } + else + { + ; /*ݲϷʧ*/ + } + + return funcRet; +} + +/** +* @brief ȡ·˽ʱ +* @param const UINT16 wRouteId ·ID +* @return ·˽ʱ +* BY CGH 20240605 +*/ +UINT32 GetRouteDelayCycleCount(const UINT16 wRouteId) +{ + UINT32 dwReval = UINT32_MAX; + UINT8 chRouteLevel = 0U; /*·ල*/ + UINT8 chRouteType = 0U; /*·*/ + UINT8 chRouteBelCiId = 0U;/*·ID*/ + UINT8 chCiType = 0U; /**/ + OtherCiParaStruct otherCiParaStr = {0U}; + UINT8 chCbtcNearSecSum = 0U;/*CBTCӽĿ*/ + RouteNearLogicSectionStruct* pCbtcNearSecData = NULL;/*CBTCӽ*/ + UINT8 chBlocNearSecSum = 0U;/*ʽӽĿ*/ + RouteNearPhySectionStruct* BlocNearSecData = NULL;/*ʽӽ*/ + UINT8 ii = 0U; + UINT8 chLogSecBelongCiId = 0u;/*ID*/ + UINT32 dwTempDelayCyc = 0U;/*ʱʱ*/ + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + /*ȡ·ֶ̬*/ + chRouteLevel = GetRouteLevel(wRouteId); /*ȡ·ල*/ + chRouteType = GetRouteType(wRouteId); + chRouteBelCiId = GetRouteBelongCiId(wRouteId); + chCiType = GetCiType(chRouteBelCiId); + + if (ROUTE_TYPE_DIAOCHE == chRouteType) + { + dwReval = GetSystemParaFaultUnlockCyc(); /*ȡ·ʱ*/ + } + else + { + if (CI_TYPE_CLD == chCiType) + { + if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + dwReval = GetSystemParaCbtcRouteDelayCyc(); /*ȡCBTC·ʱ*/ + chCbtcNearSecSum = GetRouteCbtcNearSecConditionSum(wRouteId); /*ȡ·CBTCӽ߼Ŀ*/ + pCbtcNearSecData = GetRouteCbtcNearLogSectionStru(wRouteId);/*ȡ·CBTCӽ߼*/ + + if (NULL != pCbtcNearSecData) + { + for (ii = 0U; ii < chCbtcNearSecSum; ii++) + { + chLogSecBelongCiId = GetLogSecBelongCiId(pCbtcNearSecData[ii].NearLogicSecIdBuf[(pCbtcNearSecData[ii].NearLogicSecSum) - 1U]); + if ((0U != chLogSecBelongCiId) && (chRouteBelCiId != chLogSecBelongCiId)) + { + otherCiParaStr = GetOtherCiPara(chLogSecBelongCiId); + dwTempDelayCyc = otherCiParaStr.wOtherCiCTNearUnLockCyc; + if (dwReval < dwTempDelayCyc) + { + dwReval = dwTempDelayCyc; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + } + else + { + ; + } + } + else + { + /*ʽ*/ + dwReval = GetSystemParaBlocRouteDelayCyc(); /*ȡʽ·ʱ*/ + chBlocNearSecSum = GetRouteBlocNearSecConditionSum(wRouteId); /*ȡ·ʽӽ߼Ŀ*/ + BlocNearSecData = GetRouteBlocNearPhySectionStru(wRouteId);/*ȡ·ʽӽ߼*/ + + if (NULL != BlocNearSecData) + { + for (ii = 0U; ii < chBlocNearSecSum; ii++) + { + chLogSecBelongCiId = GetLogSecBelongCiId(BlocNearSecData[ii].BlocNearLogSecIdBuf[(BlocNearSecData[ii].BlocNearLogSecSum) - 1U]); + if ((0U != chLogSecBelongCiId) && (chRouteBelCiId != chLogSecBelongCiId)) + { + otherCiParaStr = GetOtherCiPara(chLogSecBelongCiId); + dwTempDelayCyc = otherCiParaStr.wOtherCiUTNearUnLockCyc; + if (dwReval < dwTempDelayCyc) + { + dwReval = dwTempDelayCyc; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + } + else + { + ; + } + } + } + else + { + if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + /*CBTC*/ + dwReval = GetSystemParaCbtcRouteDelayCyc(); /*ȡCBTC·ʱ*/ + } + else + { + /*ʽ*/ + dwReval = GetSystemParaBlocRouteDelayCyc(); /*ȡʽ·ʱ*/ + } + } + } + } + else + { + ; /*MAX*/ + } + + return dwReval; +} + +/* +* ֽ·ͨ߼ԭ· +* ˵const UINT16 wRouteId, ·ID +* ֵ +* Created By LQ 2024.09.10 +*/ +void CleanOldRouteProcByLogSec(const UINT16 wRouteId) +{ + UINT16 wRouteIndex = 0U; + UINT16 ii = 0U; + UINT16 wRouteIncLogSecNum = 0U; /*·߼*/ + UINT16* pRouteIncLogSecId = NULL; /*·߼ID*/ + UINT16 wLogSecRLockBelongRoute = 0U; /*߼ν··*/ + UINT8 cLocalCiId = 0U; + UINT8 cRouteBelongCiId = 0U; + + wRouteIndex = GetRouteConfigBufIndex(wRouteId); + + if (ROUTE_SUM_MAX > wRouteIndex) + { + wRouteIncLogSecNum = GetRouteLogSectionSum(wRouteId); /*ȡ·߼*/ + pRouteIncLogSecId = GetRouteLogSectionIdBuf(wRouteId); + + if ((0U != wRouteIncLogSecNum) && (NULL != pRouteIncLogSecId)) + { + /*·߼ΣǷ񻹴߼αǰ·*/ + for (ii = 0U; ii < wRouteIncLogSecNum; ii++) + { + wLogSecRLockBelongRoute = GetLogSecLockBelongRoute(pRouteIncLogSecId[ii]); + if (wRouteId != wLogSecRLockBelongRoute) + { + /**/ + } + else + { + break; /*߼αǰ·գֹͣ*/ + } + } + + cLocalCiId = GetSystemParaLocalCiId(); + cRouteBelongCiId = GetRouteBelongCiId(wRouteId); + + if (ii == wRouteIncLogSecNum) + { + /*·߼ξδ·գý·*/ + if ((0U != cLocalCiId) && (cLocalCiId == cRouteBelongCiId)) + { + SetRouteStateManage(wRouteId, ROUTE_STATE_IDLE); + SetRouteRelProSwitchLockSta(wRouteId, SWITCH_LOCK_PROTECT_CANCEL); + } + else + { + /*Ԥ*/ + } + } + else + { + /*·ڴ߼α·գ账*/ + } + } + else + { + /*ȡ·߼ʧܣ*/ + } + } + else + { + /*·IDǷ*/ + } +} + +/* +* Ч··״̬ +* ˵ const UINT16 wRouteId, ·ID +* ֵ void +* BY CGH 20241204 +*/ +void DealValidRouteState(const UINT16 wRouteId) +{ + UINT8 chRoutePhySecSum = 0U; /*·*/ + UINT8 ii = 0U; /**/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT16 wPhySecRLockBelRouteId = 0U;/*·*/ + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + chRoutePhySecSum = GetRoutePhysicalSectionSum(wRouteId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(wRouteId); /*ȡ·*/ + + if (NULL != pPhySecDataStru) + { + for (ii = 0u; ii < chRoutePhySecSum; ii++) + { + wPhySecRLockBelRouteId = GetPhySecRLockBelongRouteId(pPhySecDataStru[ii].PhysicalSectionId); + if (wRouteId == wPhySecRLockBelRouteId) + { + break; + } + else + { + ; + } + } + + if (ii == chRoutePhySecSum) + { + (void)SetRouteState(wRouteId, ROUTE_STATE_IDLE); + /*ȡ·ķ*/ + SetRouteRelProSwitchLockSta(wRouteId, SWITCH_LOCK_PROTECT_CANCEL); + } + else + { + /**/ + } + } + else + { + ; + } + } + else + { + ; + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/LogicManage/InterlockCommonManage.h b/TSCP/src/APP/ciapp/LogicManage/InterlockCommonManage.h new file mode 100644 index 0000000..c00d0e6 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicManage/InterlockCommonManage.h @@ -0,0 +1,535 @@ +/******************************************************** +* +* InterlockCommonManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2015-06-30 +* ߣ +* κ߹߼ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _INTERLOCK_LOGIC_COMMON_MANAGE_H_ +#define _INTERLOCK_LOGIC_COMMON_MANAGE_H_ + + + +#include "../System/SystemParameterManage.h" +#include "../System/CiSystemDefine.h" +#include "../Switch/SwitchDefine.h" +#include "../Switch/SwitchDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Signal/SignalDefine.h" +#include "../Signal/SignalDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Section/SectionDefine.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Route/RouteDefine.h" +#include "../Route/RouteDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../ERROR/ErrorDataManage.h" +#include "../ERROR/ErrorDefine.h" +#include "../DataManage/DeviceDataManage.h" +#include "../ParsePack/CiInterfaceDefine.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../LogicManage/InterlockLogicManage.h" +#include "../LogicManage/TradInterlockLogicManage.h" +#include "../Train/TrainDefine.h" +#include "LogicalRouteDataManage.h" + +#ifdef SCADE_MODE +#include "../LogicManage/General/LogicManageScadeInterface.h" +#else +#include "../LogicProcess/InterlockLogicProcess.h" +#include "../LogicProcess/TradInterlockLogicProcess.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* C01_·ලȷ */ +/* +* ·ලȷ +* ˵ const UINT16 routeId · +* ֵ ROUTE_LEVEL_BLOCʽ +* ROUTE_LEVEL_CBTCCBTC +* ϱ룺 EFC_ROUTE_LEVEL +*/ +UINT8 RouteLevelConfirmLogicProcess(const UINT16 routeId); +/* +* ȡָźŻID·ID +* ˵ const UINT16 signalId, źŻID +* ֵ routeIdBuf[jj] ·ID +* 0: ȡʧ +*/ +UINT16 GetStartSignalRouteId(const UINT16 signalId); + + +/* +* ·֮ǰռ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 CleanRoutePhySecPreOccupyState(const UINT16 routeId); + +/* +* ý·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 useState, ״̬ +* ֵ +*/ +void SetRoutePhySectionOccupyState(const UINT16 routeId, const UINT8 setUseState); + +/* +* ý·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRoutePhySectionLockState(const UINT16 routeId, const UINT8 lockState); + +/* +* ý·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockCommand, ״̬ +* ֵ void +*/ +void SetRouteRelProSwitchLockSta(const UINT16 routeId, const UINT8 lockCommand); + +/* +* ·ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 RouteFirstXuanProc(const UINT16 routeId); +/* +* ιϽ߼ +* ˵ const UINT16 phySectionId, ID +* ֵ void +*/ +void PhySecFaultUnlockLogicManage(const UINT16 phySectionId,const UINT8 virCIid); +/* +* ·ڵһռõ֮ǰó쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetRoutePhySecExpLockToOccupy(const UINT16 routeId); + +/* +* жϽ·ʼźŻⷽͬʱռѹ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERRORͬʱռѹ +* CI_SUCCESSͬʱռѹ +*/ +UINT8 RouteInOutSecOccupy(const UINT16 routeId); + +/* +* жǷҪгʻ·־Ҫ +* ˵ const UINT16 routeId·ID +* ֵ void +*/ +void TryClearRouteTrainEnterFlag(UINT16 routeId); +#if 0 +/* +* ۳SPKSPSDźŹرؿ +* ˵ const UINT16 routeId·ID +* ֵ void +*/ +void RouteAutoReOpenProc(const UINT16 routeId); +#endif +/* +* ·쳣δ +* ˵ const UINT16 routeId·ID +* ֵ +*/ +void RouteExpLockContinue(UINT16 routeId); + +/* +* SPKSPSD۳ָؿźŴ +* ˵ const UINT16 routeId·ID +* ֵ void +*/ +void RouteRecoverOpenProc(const UINT16 routeId); + +/* ATSֵձ +* ˵ const UINT16 expLkOverlapId, ATSֵط͵ID +* ֵ void +*/ +void SetAtsExpectLockOverlapIdProc(const UINT16 expLkOverlapId,const UINT8 lockType); + +/* +* ιϽ +* ˵ const UINT16 phySectionId, ID +* const UINT8 virCIid Rtu(ֵ) ID +* ֵ void +*/ +UINT8 CheckPhySecFaultUnlockCanDo(const UINT16 phySectionId,const UINT8 virCIid); + +/* +* ý·߼״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteLogSectionLockState(const UINT16 routeId, const UINT8 lockState); + +/* +* @brief ý·Դ־ +* @param const UINT16 wRouteId, ·ID +* const UINT8 chShrFlag, ״̬ +* @return void +*/ +void SetRouteLgcSecShareFlag(const UINT16 wRouteId, const UINT8 chShrFlag); +/* +* @brief ý·ιԴ־ +* @param const UINT16 wRouteId, ·ID +* const UINT16 wOverlapId ID +* const UINT8 chShrFlag, ״̬ +* @return void +*/ +void SetRouteOvlpOtherCiShrFlg(const UINT16 wRouteId, const UINT16 wOverlapId, const UINT8 chShrFlag); +/* +* ݽ·״̬ر־ +* ˵ const UINT16 routeId ·ID +* ֵ void +* cgh-ϲCID-2341-5 +*/ +void ClearSomeFlagDependRouteState(const UINT16 routeId); +/* +* λ۷·ʽʱιϴ +* ˵ const UINT16 phySectionId ID +* ֵ void +* cgh-20230508 +*/ +void DelayErrLockCmdDeal(const UINT16 phySectionId); + +/* +* ý·߼״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteHalfLogSecLockState(const UINT16 routeId, const UINT8 lockState); + +/* +* ý·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 useState, ״̬ +* ֵ +*/ +void SetRouteHalfPhySecUsingState(const UINT16 routeId, const UINT8 setUseState); + +/* +* @brief ý·ֹԴ־ +* @param const UINT16 wRouteId, ·ID +* const UINT8 chShrFlag, ״̬ +* @return void +*/ +void SetRouteHalfLgcSecShareFlag(const UINT16 wRouteId, const UINT8 chShrFlag); + +/* +* +* ý·ַ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockCommand, ״̬ +* ֵ void +*/ +void SetRouteHalfProSwLockState(const UINT16 routeId, const UINT8 lockCommand); + +/* +* ·ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 RouteHalfFirstXuanProc(const UINT16 routeId); +/* +* ý·г״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteTrainLocLogSecState(const UINT16 routeId, const UINT8 lockState); + +/* +* ý·г״̬, Ҫִ߼մ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteTrainLocPhySecState(const UINT16 routeId, const UINT8 lockState); +/* +* ȡָ·һյ߼ʱʼں +* ˵ const UINT16 routeId, ·ID +* +* ֵ 0: ȡʧ +* >0: ·һյ߼ʱʼں +*/ +UINT32 GetRouFirDelayErlockStaCycNum(const UINT16 routeId); +/* +* ָ·һյ߼ʱʼں +* ˵const UINT16 routeId, ·ID +* const UINT32 startCycNum ʼں +* ֵ +* +*/ +void SetRouFirDelayErlockStaCycNum(const UINT16 routeId, const UINT32 startCycNum); + +/* +* ý·״̬, Ҫִ߼մ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetRouteHalfPhySectionLockState(const UINT16 routeId, const UINT8 lockState); + +/* +* У·ǷҪⱨ +* ˵const UINT16 routeId ·ID +* ֵ +*/ +void RouteNeedDriveSGBJCheck(const UINT16 routeId); + +/* +* ߼ιϽ߼ +* ˵ const UINT16 wPhySectionId, ID +* const UINT8 chVirCIid Rtu(ֵ) ID +* ֵ void +* by cgh 20231002 +*/ +void LogicSecFaultUnlockLogicManage(const UINT16 wPhySectionId, const UINT8 chVirCIid); + +/* +* ߼ιϽ߼-·ڱ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chVirCIid Rtu(ֵ) ID +* ֵ void +* by cgh 20231002 +*/ +void LocalCiLogSecFaultUnlockProcess(const UINT16 wLogSectionId, const UINT8 chVirCIid); + +/* +* ߼ιϽ߼-· +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chVirCIid Rtu(ֵ) ID +* ֵ void +* by cgh 20231002 +*/ +void OtherCiLogSecFaultUnlockProcess(const UINT16 wLogSectionId, const UINT8 chVirCIid); + +/* +* ߼ιϽ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chVirCIid Rtu(ֵ) ID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +*/ +UINT8 CheckLogSecFaultUnlockCanDo(const UINT16 wLogSectionId, const UINT8 chVirCIid); + + +/* +* ʽʧźŹر +* ˵ const UINT16 wPhySectionId ID +* ֵ +* cgh-20231011 +*/ +void SecFaultUnlockDrvRelSigClose(const UINT16 wPhySectionId); + +/* +* ߼·źſŴ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERRORʧ +* CI_SUCCESSɹ +* ϱ룺 EFUNC_KEEP_CBTC_R_SIGNAL +*/ +UINT8 KeepOpenLogRouteSignalProc(const UINT16 wLogRouteId); + +/* +* ߼·źſŴ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERRORʧ +* CI_SUCCESSɹ +*/ +UINT8 OpenLogRouteSignalProc(const UINT16 wLogRouteId); + +/** +* @brief ѯгСǰ߼·λ(гСǰ) +* @param UINT16 wTrainId гID +* @param UINT16 wLogRouteId ߼·ID +* @return 0ѯʧ +* 1гδʻ· +* 2гͷʻ·δѹ +* 3гѹźŻ +* 4гȫʻ· +* 5гͷ· +*/ +UINT8 dsuLogRouteTrainCrossSignal(const UINT16 wTrainId, const UINT16 wLogRouteId); +/** +* @brief ѯгСǰ߼·λ(гСǰ) +* @param UINT16 wTrainId гID +* @param UINT16 wLogRouteId ߼·ID +* @return 0ѯʧ +* 1гδʻ· +* 2гͷʻ·δѹ +* 3гѹʼźŻ +* 4гȫʻ· +* 5гͷ· +*/ +UINT8 dsuLogRouteMinHeadTrainCrosSig(const UINT16 wTrainId, const UINT16 wLogRouteId); + +/* +* ߼·űźż鴦 +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERRORʧ +* CI_SUCCESSɹ +* ϱ룺 EFUNC_KEEP_CBTC_R_SIGNAL +*/ +UINT8 KeepLogRouteSignalProcess(const UINT16 wLogRouteId); + +/* +* ߼·źż鴦 +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERRORʧ +* CI_SUCCESSɹ +* ϱ룺 EFUNC_LogRouteSignalProcess +*/ +UINT8 OpenLogRouteSignalProcess(const UINT16 wLogRouteId); + +/* +* ߼·źŻ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ void +* ϱ룺 EFUNC_KEEP_CBTC_R_SIGNAL +*/ +void DriveLogRouteSignalOpen(const UINT16 wLogRouteId); + +/* +* ߼·źŻر +* ˵ const UINT16 wLogSignalId, źŻID +* ֵ void +* ϱ룺 EFUNC_KEEP_CBTC_R_SIGNAL +*/ +void DriveLogRouteSignalClose(const UINT16 wLogSignalId); + + +/* +* ߼·ලȷ +* ˵ const UINT16 signalId ʼźŻID +* ֵ void +* Created by LQ 2023/10/11 +*/ +void LogicRouteLevelConfirmProcess(const UINT16 wLogRouteId); + +/* +* ߼··ʽʱ߼߼ϴ +* ˵ const UINT16 wLogSectionId ߼ID +* ֵ void +* cgh-20231012 +*/ +void LogRouteErrLockCmdDeal(const UINT16 wLogSectionId); + +/* +* ߼·ιϽݴ +* ˵ const UINT16 wLogSectionId, ߼ID +* ֵ void +* by cgh 20231013 +*/ +void LogRouteErrLockFaultProcess(const UINT16 wLogSectionId); + +/* +* ߼·߼ιϴ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ void +* by cgh 20231013 +*/ +void LogRouteExpLockContinue(const UINT16 wLogRouteId); + +/* +* ȡ߼·һյ߼ID +* ˵ const UINT16 wLogSecId ߼ID + const UINT16 wLogRouteId, ߼·ID + UINT16* wOtherLogRouteId ߼·ID +* ֵ ߼·һյ߼ID +* by cgh 20231020 +*/ +UINT16 GetOtherLogRouteFirNormalLogId(const UINT16 wLogSecId, const UINT16 wLogRouteId, UINT16* wOtherLogRouteId); + +/* +* ȡָ߼·һ߼յ߼ʱʼں +* ˵ const UINT16 wLogRouteId, ߼·ID +* +* ֵ 0: ȡʧ +* >0: ߼·һ߼յ߼ʱʼں +* by cgh 20231017 +*/ +UINT32 GetLogRouFirDelayErLockStaCyc(const UINT16 wLogRouteId); + +/* +* ָ߼·һ߼յ߼ʱʼں +* ˵const UINT16 wLogRouteId, ߼·ID +* const UINT32 startCycNum ʼں +* ֵ +* by cgh 20231017 +* +*/ +void SetLogRouFirDelayErLockStaCyc(const UINT16 wLogRouteId, const UINT32 startCycNum); + +/* +* ߼·ʽ +* ˵ const UINT16 wPhySectionId, ID +* ֵ void +* by cgh 20231002 +*/ +void LogRouteErrLockFaultManage(const UINT16 wPhySectionId); + +/* ·IDıΰ +* ˵ const UINT16 expLkOverlapId, ATSֵط͵ID +* const UINT16 routeId ·ID +* ֵ +*/ +void SetAtsLockOverlapHaveRouteId(const UINT16 expLkOverlapId, const UINT16 routeId); + +/** +* @brief ֽ·߼߼մ +* @param const UINT16 wLogSecId ߼ID +* const UINT16 routeId ǰյĽ·ID +* @return CI_SUCCESSֽ·߼ճɹ +* CI_ERRORֽ·߼ʧ +*/ +UINT8 LogSecLockInHalfRouteProcess(const UINT16 wLogSecId, const UINT16 routeId); + +/** +* @brief ȡ·˽ʱ +* @param const UINT16 wRouteId ·ID +* @return ·˽ʱ +* BY CGH 20240605 +*/ +UINT32 GetRouteDelayCycleCount(const UINT16 wRouteId); + +/* +* ֽ·ͨ߼ԭ· +* ˵const UINT16 wRouteId, ·ID +* ֵ +* Created By LQ 2024.09.10 +*/ +void CleanOldRouteProcByLogSec(const UINT16 wRouteId); + +/* +* Ч··״̬ +* ˵ const UINT16 wRouteId, ·ID +* ֵ void +* BY CGH 20241204 +*/ +void DealValidRouteState(const UINT16 wRouteId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/LogicManage/InterlockLogicManage.c b/TSCP/src/APP/ciapp/LogicManage/InterlockLogicManage.c new file mode 100644 index 0000000..f8338e6 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicManage/InterlockLogicManage.c @@ -0,0 +1,15934 @@ +/******************************************************** +* +* InterlockLogicManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-10 +* ߣ +* ߼ +* ޸ļ¼ +* +********************************************************/ + +#include "InterlockLogicManage.h" +#include "../DataManage/DeviceConfigDataManage.h" +#include "RouteRecoverManage.h" +#include "../ParsePack/ParsePackPSCData.h" +#include "TrainDataManage.h" +#include "HLHTHeadContexManage.h" +#include "TrainOnAcManage.h" +#include "TrainDataManage.h" +#include "SectionStateProcess_define.h" +#include "DynamicRouteDataManage.h" +#include "LogicalRouteDataManage.h" +#include "../LogicProcess/LogicalRouteLogicCheck.h" +#include "../LogicManage/TradInterlockLogicManage.h" + + + + +void RouteAutoManage(const UINT16 routeId); +void CiTrainTestLogicManage(void); +void DriveAllSignaleRedClose(void); +/* +* ͨ·Overlap +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +static void LockRouteOverlapManageHlht(const UINT16 routeId); +/* +* ͨ·Overlap +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +static void UnlockRouteOverlapManageHlht(const UINT16 routeId); + +/* +* ͨ·ν״̬ж +* ˵ const UINT16 routeId, ·ID +* ֵ +0:ijһΣȫ +>0:ijһΣȫ +*/ +static UINT16 GetRouteLockedOvlpHlht(const UINT16 routeId); + +/* +* ΪͨCIձʱOverlap +* ˵ +* const UINT16 overlapId, ID +* const UINT8 lockState, ״̬ +* const UINT8 lockDirշ +* ֵ +*/ +static void SetOvlpLockStateForHlhtCi(const UINT16 overlapId, const UINT8 lockState, const UINT8 lockDir); + +/* +* TIOC߼ԾIVOCͬͨ״̬µĴ +* ˵const UINT16 logSectionId߼ID +const UINT16 trainId,гID +* ֵ void +* +*/ +static void TrainTransitmitStatJumpLockProcess(const UINT16 logSectionId, const UINT16 trainId); + +/* +* г߼Դس +* ˵ void +* ֵ +*/ +static void TrainLogicSecResRetreatManage(void); + +/* +* ־߼ +* ˵ UINT8 setFlag ־ + CI_ALL_SWITCH_YLOCK_YES + CI_ALL_SWITCH_YLOCK_NO +* ֵ void +*/ +void SetCiYLockManage(UINT8 setFlag) +{ + UINT8 yLockFlag = 0u; + + yLockFlag = GetAllSwitchYLockFlag(); + if ((CI_ALL_SWITCH_YLOCK_NO == setFlag) && + (CI_ALL_SWITCH_YLOCK_YES == yLockFlag)) + { + /*ȡ*/ + SetAllSwitchYLockFlag(setFlag); + } + else if ((setFlag == CI_ALL_SWITCH_YLOCK_YES) && + (CI_ALL_SWITCH_YLOCK_NO == GetAllSwitchYLockFlag())) + { + /**/ + SetAllSwitchYLockFlag(setFlag); + } + else + { + /**/ + } +} +/* +* ־߼ +* ˵ UINT8 setFlag ־ + const UINT8 virCIid ID +* ֵ void +*/ +void SetCiYLockManage_UseVirCI(UINT8 setFlag, const UINT8 virCIid) +{ + UINT8 yLockFlag = 0u; + + yLockFlag = GetVirCIAllSwitchYLockState(virCIid); + if ((CI_ALL_SWITCH_YLOCK_NO == setFlag) && + (CI_ALL_SWITCH_YLOCK_YES == yLockFlag)) + { + /*ȡ*/ + AllSwitchYLock_UseVirCI(virCIid, setFlag); + } + else if ((CI_ALL_SWITCH_YLOCK_YES == setFlag) && + (CI_ALL_SWITCH_YLOCK_NO == yLockFlag)) + { + /**/ + AllSwitchYLock_UseVirCI(virCIid, setFlag); + } + else + { + /**/ + } +} + +/* +* ߼ +* ˵ void +* ֵ +*/ +void InterlockLogicMainProc(void) +{ + UINT8 localCiType = GetLocalCiType(); + UINT8 cRcWorkMode = GetLocalRcWorkMode(); + + signed long long cost[20] = {0U}; + cost[0] = MSCP_GetTick(); + if ((CI_TYPE_ZX == localCiType) || (CI_TYPE_SCX == localCiType)) + { + /*ȫԶ۷·߼*/ + AllAutoReturnLogicManage(); +#if 0 + /*·߼*/ + RouteLogicManage(); +#endif + /*·ڱ·رźŻڱ*/ + NearCIRouteNeedCloseProce(); + /*cgh-ϲCID-2341-8εѡʼں, ·״̬·ѡʼ*/ + ClearOverlapXuanPaiStartCycNum(); + if (CI_TYPE_SCX == localCiType) + { + CiTrainTestLogicManage(); + } +#if 0 + /*ָʾ߼*/ + IndicatorLogicManage(); +#endif + + /*߼*/ + FloodLogicManage(); + + /*߼·״̬*/ + LogicalRouteProcess(); + } + else + { + /*Ӧ̹ܴ*/ + JKJRelayLogicProcess(); + + /*·߼*/ + LongRouteLogicProcess(); +#if 0 + /*·߼*/ + RouteLogicProcess(); +#endif + /*ǽ·߼*/ + NonRouteLogicProcess(); + + /* ߼ */ + GargeDoorLogicProcess(); + } + + /*̬Ͻ·߼߾֧֣*/ + DynamicRouteLogicProcess(); + + cost[1] = MSCP_GetTick(); + /*·߼*/ + RouteLogicManage(); + + /*·гͷŽ߼*/ + RouteTrainResUnlockManage(); + + cost[2] = MSCP_GetTick(); + + /*·*/ + RouteOtherCiSwitchManage(); + + /**/ + OverlapOtherCiProSwitchManage(); + + /*߼*/ + UnlockSwitchLogicManage(); + + /*߼Դ*/ + LogicSecResManage(); + cost[3] = MSCP_GetTick(); + + /*Ծ߼*/ + JumpLockManage(); + cost[4] = MSCP_GetTick(); + debug_infor_printf((const)"\n JKJRelayLogicProcess :%dms RouteLogicManage:%dms LogicSecResManage:%dms JumpLockManage:%dms \n",(cost[1]-cost[0])/1000,(cost[2]-cost[1])/1000,(cost[3]-cost[2])/1000,(cost[4]-cost[3])/1000); + +} + + +/* +* ·߼ +* ˵ void +* ֵ +*/ +void RouteLogicManage(void) +{ + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT8 localCiId = 0u; /*ID*/ + + UINT16 routeId = 0u; /*·ID*/ + UINT8 routeBelongCiId = 0u; /*·ID*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 routeLevel = 0u; /*·ල*/ + UINT8 zongQuXiaoFlag = 0u; /*·ȡ־*/ + UINT8 zongRenJieFlag = 0u; /*·˽־*/ + UINT8 routeStateFlag = ROUTE_STATE_FLAG_NO; /*·״̬תƱ־*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 sameLineCi = SAME_LINE_ERR; + UINT16 endSigId = 0u;/*·նźŻ*/ + UINT8 endSigCi = 0u;/*·նź*/ + UINT16 tempLockedOvlp = 0u;/*ʱͨ£·ijһΣζ״̬*/ + UINT16 rtLockedOvlp = 0u;/*·ǰյıID*/ + UINT32 curCycleNum = 0u; + UINT8 startLockState = 0u; + UINT8 startFlockFlag = 0u; + UINT8 rtVal = CI_ERROR; + UINT8 localCiType = GetLocalCiType(); + UINT8 flagExec = CI_ERROR;/*ִб־*/ + UINT8 virCIid = 0u; + UINT16 recordErrorNum = 0u; + + UINT8 cRcWorkMode = 0u; + + /* RCģʽ */ + cRcWorkMode = GetLocalRcWorkMode(); + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + curCycleNum = Get2oo2CurCycleNum(); /*ȡǰں*/ + + startLockState = GetStartLockFlag(); /*ȡϵ־*/ + startFlockFlag = GetStartFLockFlag(); /*ȡϵ־*/ + + + if (0u == localCiId) + { + rtVal = CI_ERROR; + } + else + { + rtVal = CI_SUCCESS; + } + + if (CI_SUCCESS == rtVal) + { + if ((CI_TYPE_ZX == localCiType) || (CI_TYPE_SCX == localCiType)) + {/*ߺԳ߼ȼϵּȫվ*/ + if ((CI_START_LOCK_NO != startLockState) || (CI_START_FLOCK_NO != startFlockFlag)) + {/*δȫվδϵ*/ + rtVal = CI_ERROR; + } + } + else + {/*νϵ*/ + if (GetStartLockFlag() != CI_START_LOCK_NO) + { /*δϵ*/ + + rtVal = CI_ERROR; + } + } + } + + + + if (CI_SUCCESS == rtVal) + { + /*źſŹ*/ + YLockSignalOpenManage(); + + if (CI_TYPE_CLD == localCiType) + { + /*ε;۷*/ + DTrainReturnUnlockP(); + } + } + + + if (CI_SUCCESS == rtVal) + { + /*·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = 0u; /*·ID*/ + routeBelongCiId = 0u; /*·ID*/ + routeState = 0u; /*·״̬*/ + routeLevel = 0u; /*·ල*/ + zongQuXiaoFlag = 0u; /*·ȡ־*/ + zongRenJieFlag = 0u; /*·˽־*/ + + routeId = GetRouteId(ii); /*ȡ·ID*/ + routeBelongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + /*cgh-ϲCID-2349-5*/ + virCIid = GetRouteBelongVirCiId(routeId); + recordErrorNum = GetErrorDataCurSum(); + if ((0u == routeId) || (routeId > ROUTE_SUM_MAX)) + { + flagExec = CI_ERROR; + } + else + { + flagExec = CI_SUCCESS; + } + + if (CI_SUCCESS == flagExec) + { + if (routeBelongCiId != localCiId) + { + /*жǷͬһ·*/ + sameLineCi = IsSameLineCI(routeBelongCiId, localCiId); + if (SAME_LINE_YES == sameLineCi) + {/*ͬһ·CIִнCIĴ߼*/ + /*************DZOverlap߼***************/ + /*վ䱣߼*/ + LockOverlapLogicManage(routeId); + + /**/ + UnlockOverlapLogicManage(routeId); + } + + /*****************·߼**********************/ + flagExec = CI_ERROR; + } + } + + if (CI_SUCCESS == flagExec) + { + /*ͨ£ν״̬ж*/ + endSigId = GetRouteEndSignalId(routeId); + endSigCi = GetSignalBelongCiId(endSigId); + sameLineCi = IsSameLineCI(localCiId, endSigCi); + + if (SAME_LINE_NO == sameLineCi) + { + tempLockedOvlp = GetRouteLockedOvlpHlht(routeId); + if (0u == tempLockedOvlp) + { + /*˵·ıѾδ״̬*/ + rtLockedOvlp = GetRouteOverlapLockedId(routeId); + if (rtLockedOvlp > 0u) + { + SetOverlapLockState(rtLockedOvlp, PHYSICAL_SECTION_LOCK_NO, routeId); /*Overlapδ*/ + } + } + } + + /*ȡ·ֶ̬*/ + zongQuXiaoFlag = GetRouteZongQuXiaoFlag(routeId); /*ȡ·ȡ־*/ + zongRenJieFlag = GetRouteZongRenJieFlag(routeId); /*ȡ·˽־*/ + routeStateFlag = GetRouteStateFlag(routeId); /* ȡ·״̬תƱ־*/ + + /*·ලȷ*/ + routeLevel = RouteLevelConfirmLogicProcess(routeId); + + /*ý·ල*/ + SetRouteLevel(routeId, routeLevel); + + /* ԶԶ·/Զ۷ */ + RouteAutoManage(routeId); + + /*·ź̿ſʼ*/ + SetClearKeepSignalTolerateCyc(routeId); + + routeState = GetRouteState(routeId); + + /*#####·״̬#####*/ + if (ROUTE_STATE_IDLE == routeState) + { /*·*/ + + RouteIdleManage(routeId); + } + else if (ROUTE_STATE_FIRST_XUANPAI == routeState) + {/*·Ԥѡ*/ + + RouteFirstXuanPaiManage(routeId); + } + else if (ROUTE_STATE_LEAD_FIRST_XUANPAI == routeState) + {/*Ԥѡ*/ + + LeadRouteFirstXuanPaiManage(routeId); + } + else if (ROUTE_STATE_XUANPAI == routeState) + { /*·ѡ*/ + + RouteXuanPaiManage(routeId); + } + else if (ROUTE_STATE_LEAD_XUANPAI == routeState) + { /*ѡ*/ + + LeadRouteXuanPaiManage(routeId); + } + else if (ROUTE_STATE_FIRST_LOCK == routeState) + { /*·*/ + + RouteFirstLockManage(routeId); + } + else if (ROUTE_STATE_FIRST_LOCKERR == routeState) + { /*·쳣*/ + + RouteFirstLockErrManage(routeId); + } + else if (ROUTE_STATE_YUXIAN_LOCK == routeState) + { /*Ԥ*/ + + RouteYuXianLockManage(routeId); + } + else if (ROUTE_STATE_YUXIAN_OPEN == routeState) + { /*Ԥȿ*/ + + RouteYuXianOpenManage(routeId); + } + else if (ROUTE_STATE_NEAR_LOCK == routeState) + { /*ӽ*/ + + RouteNearLockManage(routeId); + } + else if (ROUTE_STATE_NEAR_LOCKERR == routeState) + { /*ӽ쳣*/ + + RouteNearLockErrManage(routeId); + } + else if (ROUTE_STATE_NEAR_OPEN == routeState) + { /*ӽ*/ + + RouteNearOpenManage(routeId); + } + else if (ROUTE_STATE_DELAY_UNLOCK == routeState) + { /*ʱ*/ + + RouteDelayUnlockManage(routeId); + } + else if (ROUTE_STATE_AUTO_UNLOCK == routeState) + { /*Զ*/ + + RoutePhyOrLogSecAutoUnlocManage(routeId); + } + else if (ROUTE_STATE_AUTO_UNLOCKERR == routeState) + { /*Զ쳣*/ + + RoutePhySecAutoUnlockErrManage(routeId); + } + else if (ROUTE_STATE_LEAD_LOCK == routeState) + { /**/ + + RouteLeadLockManage(routeId); + } + else if (ROUTE_STATE_LEAD_OPEN == routeState) + { /**/ + + RouteLeadOpenManage(routeId); + } + else if (ROUTE_STATE_LEAD_LOCKERR == routeState) + { + /*쳣*/ + RouteLeadLockErrManage(routeId); + } +#if 0 + else if (ROUTE_STATE_HALF_FIRST_XUAN == routeState) + {/*Ԥѡ*/ + + RouteHalfFirstXuanManage(routeId); + } + else if (ROUTE_STATE_HALF_XUANPAI == routeState) + { /*ѡ*/ + + RouteHalfXuanPaiManage(routeId); + } +#endif + else if (ROUTE_STATE_HALF_LOCK == routeState) + { + /*·մ*/ + RouteHalfLockManage(routeId); + } + else if (ROUTE_STATE_HALF_UNLOCK == routeState) + { + /*·ս*/ + RouteHalfUnlockManage(routeId); + } + else if (ROUTE_STATE_HALF_UNLOCKDELAY == routeState) + { /*·һյ߼ʱι״̬*/ + RouteHalfUnlockDelayManage(routeId); + } + else + { + /*״̬쳣*/ + /*xxxxx 崻*/ + + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + EFUNC_LOGIC_MANAGE_SYETEM, + CI_ERROR, + ETYPE_SYSTEM_EXCEPT, + CI_ERROR, ESEND_LEVEL_ZERO); + } + + /*ȡ·״̬*/ + routeState = GetRouteState(routeId); + + if ((ROUTE_STATE_IDLE != routeState) && + (ROUTE_STATE_FIRST_XUANPAI != routeState) && + (ROUTE_STATE_XUANPAI != routeState) && + (ROUTE_STATE_LEAD_FIRST_XUANPAI != routeState) && + (ROUTE_STATE_LEAD_XUANPAI != routeState) && + (ROUTE_STATE_AUTO_UNLOCK != routeState) && + (ROUTE_STATE_AUTO_UNLOCKERR != routeState)) + { + /*·պгʻΪֹرźŴ*/ + (void)RouteOpenNeedCloseSignal(routeId); + } + + /*ղ״̬*/ + UpdateZhaoChaStateManage(routeId, routeState); + + TryClearRouteTrainEnterFlag(routeId); + + /*·г߼*/ + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + RouteNearestTrainRenJieManage(routeId); + } + /*#####·ȡ#####*/ + if (ROUTE_ZONGQUXIAO_SET_YES == zongQuXiaoFlag) + { /*Ѱȡ*/ + + RouteZongQuXiaoProc(routeId); + } + else if (ROUTE_ZONGRENJIE_SET_YES == zongRenJieFlag) + { /*Ѱ˽*/ + + RouteZongRenJieProc(routeId); + } + else + {/**/ + } + + /*************Overlap߼***************/ + /*վ䱣߼*/ + if (SAME_LINE_YES == sameLineCi) + { + LockOverlapLogicManage(routeId); + + /**/ + UnlockOverlapLogicManage(routeId); + } + else if (SAME_LINE_NO == sameLineCi) + { + LockRouteOverlapManageHlht(routeId); + UnlockRouteOverlapManageHlht(routeId); + } + else + { + /*޷жǷͬ·ްȫ*/ + } + + /*****************·߼********************/ + /*CBTCģʽ׷ٰ· + ޸ǰĽ·ѡŲɹʱὫ·״̬ΪУ + Ӷǰμ֮ǰյαΪδգڰȫ + ޸ĺֻеĽ·ճɹŽ֮ǰĽ·״̬תƣ򱣳ԭ·״̬*/ + if (ROUTE_STATE_FLAG_YES == routeStateFlag) + { + RouteStateFlagManage(routeId); + } + + + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + /*гȡԴʱ wei ȱݣԴȡ*/ + RouteCancelResApplyManage(routeId); + } + + RouteRecoverOpenProc(routeId); + /*ȡԶź*/ + CancleAutoSigCmdProcc(routeId); + /*cgh-ϲCID-2341-5ݽ·״̬ر־*/ + ClearSomeFlagDependRouteState(routeId); + /*cgh-ϲCID-2349-5*/ + SetErrorDataBelongVirCiId(recordErrorNum, virCIid);/*ErrorCodeID*/ + + } + + } + } +} + +/* +* ·ڱ·رźŻڱ +* ˵ void +* ֵ +*/ +void NearCIRouteNeedCloseProce(void) +{ + UINT16 i = 0u; + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT16 routeId = 0u; /*·ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 routeState = 0u; + UINT8 commState = 0u;/*ͨ״̬*/ + UINT8 funcSwitchSupportRelayInterface = 0u; + UINT8 confirmRelayInterfaceFlag = 0u; + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + for (i = 0u; i < routeCurSum; i++) + { + routeId = GetRouteId(i); /*ȡ·ID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if (localCiId != belongCiId) + { + /*ȡͨ״̵̬ӿ*/ + commState = GetLocalCiAndOtherCiTransSta(belongCiId); + funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + /*̵ӿȷ*/ + if ((TRANSMIT_STATE_BAD == commState) && (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag) + && (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /**/ + } + else + { + /*ȡ·״̬*/ + routeState = GetRouteState(routeId); + /*·״̬*/ + if ((ROUTE_STATE_IDLE != routeState) && + (ROUTE_STATE_FIRST_XUANPAI != routeState) && + (ROUTE_STATE_XUANPAI != routeState) && + (ROUTE_STATE_LEAD_FIRST_XUANPAI != routeState) && + (ROUTE_STATE_LEAD_XUANPAI != routeState) && + (ROUTE_STATE_AUTO_UNLOCK != routeState) && + (ROUTE_STATE_AUTO_UNLOCKERR != routeState)) + { + /*·պгʻΪֹرźŴ*/ + (void)RouteOpenNeedCloseSignal(routeId); + } + } + } + } +} + + +/* +* Զ· +* úڽ·УִС +* ݵǰ·״̬Լ·Զ· +* +* +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteAutoManage(const UINT16 routeId) +{ + + UINT8 autoRouteType = 0u; /*ȡԶ·:ͨԶ·Զ۷·*/ + UINT8 autoSigRouteType = 0u; /*ȡ·ǰǷΪԶźŽ·*/ + UINT8 autoReturnRouteType = 0u; + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 redDsFlag = 0u; + UINT8 greenDsFlag = 0u; + UINT8 yellowDsFlag = 0u; + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 checkRouteFlag = 0u; /* · */ + UINT8 autoRouteFlg = 0u; /* · */ + UINT8 autoTriggerType = 0u; /*Զ·*/ + UINT8 triggerFlag = AUTO_TRIGGER_SET_NO; /*Զ־*/ + UINT8 autoSigProperty = 0u; + UINT8 checkDSBreakLoseEfficacyFlag = 0u; /*Ƿ˿ԶźʧЧ*/ + UINT8 setRouteAutoFlag = 0u; + UINT8 autoReturnValid = 0u; + UINT8 routeTriggerOccu = 0u; + UINT8 phySectionUseState = 0u; + UINT16 routeAutoReturnId = 0u; + UINT8 virCIid = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + checkDSBreakLoseEfficacyFlag = GetCiFunctionSwitchConfig(FUNC_DS_BREAK_AUTOSIG_LOSE_EFFICACY_FLAG); + + autoSigProperty = GetRouteAutoSigProperty(routeId);/*ȡ·Զź*/ + + if ((ROUTE_AUTOSIG_PROPERTY_YES == autoSigProperty) && (ROUTE_AUTOSIG_DSBREAK_LOSE_EFFICACY == checkDSBreakLoseEfficacyFlag)) + { + /*ȡ·ʼźŻID*/ + startSignalId = GetRouteStartSignalId(routeId); + redDsFlag = GetSignalDsBreakFlag(startSignalId); + greenDsFlag = GetSignalGreenDsBreakFlag(startSignalId); + yellowDsFlag = GetSignalYellowDsBreakFlag(startSignalId); + + + + /*ʼźŻ˿*/ + if ((SIGNAL_DS_BREAK_YES == redDsFlag) || (SIGNAL_DS_BREAK_YES == greenDsFlag) + || (SIGNAL_DS_BREAK_YES == yellowDsFlag)) + { + /*ԶźʧЧ*/ + setRouteAutoFlag = SetRouteAutoSigLoseEfficacyFlag(routeId, ROUTE_AUTOSIG_LOSE_DSSET_YES); + if (CI_ERROR == setRouteAutoFlag) + { + /**/ + } + } + + startSignalCurColor = GetSignalCurColor(startSignalId); + openCloseState = GetSignalOpenCloseState(startSignalCurColor); + + if (SIGNAL_OPEN == openCloseState) + { + /*ԶźЧ*/ + setRouteAutoFlag = SetRouteAutoSigLoseEfficacyFlag(routeId, ROUTE_AUTOSIG_LOSE_DSSET_NO); + if (CI_ERROR == setRouteAutoFlag) + { + /**/ + } + } + } + /*Զ· || Զź :Զ*/ + autoRouteType = GetRouteAutoRouteSetState(routeId);/*ȡԶ·:ͨԶ·Զ۷·*/ + autoSigRouteType = GetRouteAutoSigSetState(routeId);/*ȡ·ǰǷΪԶźŽ·*/ + autoTriggerType = GetAutoTriggerType(routeId); + + triggerFlag = GetRouteAutoTriggerFlag(routeId);/*ȡ·Զ·*/ + /* + * Զͨ·: ֻҪý·Զ· + * Զ۷·ʱ: ·ֻҪͿ԰ + * ۳·ʱ򣬳⣬Ҫг۷ + * + */ + if ((ROUTE_AUTOROUTE_NORMAL == autoRouteType) || (ROUTE_AUTOSIGROUTE_YES == autoSigRouteType)) + { + /*Զ· || Զź*/ + checkRouteFlag = SetRouteProc(routeId); + if (CI_SUCCESS == checkRouteFlag) + { + autoRouteFlg = 1u; + } + } + else if (ROUTE_AUTOROUTE_RETURN == autoRouteType) + { + routeAutoReturnId = GetRouteAutoReturnId(routeId); + autoReturnRouteType = GetAutoReturnRouteType(routeAutoReturnId, routeId); + if (AUTO_RETURN_ROUTE_TYPE_IN == autoReturnRouteType) + { + /* · */ + checkRouteFlag = SetRouteProc(routeId); + if (CI_SUCCESS == checkRouteFlag) + { + autoRouteFlg = 1u; + } + } + else if (autoReturnRouteType == AUTO_RETURN_ROUTE_TYPE_OUT) + { + autoReturnValid = GetAutoReturnRebackRouteValid(routeId); + if (CI_SUCCESS == autoReturnValid) + { + /*Զ۷۳·*/ + /* · */ + checkRouteFlag = SetRouteProc(routeId); + if (CI_SUCCESS == checkRouteFlag) + { + autoRouteFlg = 1u; + } + } + } + else + { + /**/ + autoRouteFlg = 0u; + } + } + else if (AUTO_TRIGGER_SET_YES == triggerFlag) + { /*Զ·ô־*/ + /*гռѹ·Զ*/ + routeTriggerOccu = RouteTriggerOccu(routeId); + if (CI_SUCCESS == routeTriggerOccu) + { + checkRouteFlag = SetRouteProc(routeId); + if (CI_SUCCESS == checkRouteFlag) + { + autoRouteFlg = 1u; + } + } + } + else + { + /*ͨ·*/ + autoRouteFlg = 0u; + } + /* ·Ҫ״̬ */ + if (1U == autoRouteFlg) + { + phySectionUseState = RoutePhySectionUseLogicProcess(routeId); + /*·δü*/ + if (CI_SUCCESS == phySectionUseState) + { +#if 0 + /*ȫδ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_XUANPAI); /*-->ý·ѡ*/ + + /*·ѡ*/ + RouteFirstXuanPaiManage(routeId); +#else + SetCommonRouteLogicManage(routeId); +#endif + } + } + + /*Զͨ,Զ۷,ȫԶ۷,Զ */ + if ((ROUTE_AUTOROUTE_NORMAL == autoRouteType) + || (ROUTE_AUTOROUTE_RETURN == autoRouteType) + || (ROUTE_ALLAUTOROUTE_RETURN == autoRouteType) + || (ROUTE_TYPE_AUTO_TRIGGER == autoTriggerType)) + { + CrossCiAutoRouteFLockDevProc(routeId); + } +} +/* +* ·й +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteIdleManage(const UINT16 routeId) +{ + /* + * ú֣ƵԶ·RouteAutoManageڡ + * ״̬Ŀǰκδ + */ +#if 0 + UINT8 autoRouteType = 0u; + UINT8 autoReturnRouteType = 0u; + + /*Զ·Զ*/ + autoRouteType = GetRouteAutoRouteSetState(routeId); + + if (autoRouteType == ROUTE_AUTOROUTE_NORMAL) + { + /*Զ·*/ + + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { + /*ȫδ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_XUANPAI); /*-->ý·ѡ*/ + + /*·ѡ*/ + RouteFirstXuanPaiManage(routeId); + } + else + { + /**/ + + /*ԭ·״̬*/ + } + } + else if (autoRouteType == ROUTE_AUTOROUTE_RETURN) + { + autoReturnRouteType = GetAutoReturnRouteType(GetRouteAutoReturnId(routeId), routeId); + if (autoReturnRouteType == AUTO_RETURN_ROUTE_TYPE_IN) + { + /*Զ۷·*/ + + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { + /*ȫδ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_XUANPAI); /*-->ý·ѡ*/ + + /*·ѡ*/ + RouteFirstXuanPaiManage(routeId); + } + else + { + /**/ + + /*ԭ·״̬*/ + } + } + else if (autoReturnRouteType == AUTO_RETURN_ROUTE_TYPE_OUT) + { + if (GetAutoReturnRebackRouteValid(routeId) == CI_SUCCESS) + { + /*Զ۷۳·*/ + + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { + /*ȫδ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_XUANPAI); /*-->ý·ѡ*/ + + /*·ѡ*/ + RouteFirstXuanPaiManage(routeId); + } + else + { + /**/ + + /*ԭ·״̬*/ + } + } + else + { + /* ȴ۳*/ + } + } + else + { + /**/ + } + } + else + { + /*ͨ·*/ + } +#endif +} + + +/* +* ·ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstXuanPaiManage(const UINT16 routeId) +{ + UINT8 returnValueFunc1 = 0U; /*ֵ*/ + UINT8 returnValueFunc2 = 0U; /*ֵ*/ + UINT8 firstXuanPaiOvertime = 0U;/*ѡʱ*/ + UINT8 routeCheck = 0U; + UINT8 routeProperty = 0U; + UINT8 chFunctionId = 0U;/*뺯ID*/ + UINT8 chLocalCiType = 0U;/**/ + + routeCheck = SetRouteProc(routeId); + chLocalCiType = GetLocalCiType(); /*ȡ*/ + if (CI_TYPE_CLD == chLocalCiType) + { + chFunctionId = EFUNC_CommonRouteXuanPaiDeal; + } + else + { + chFunctionId = EFUNC_RouteFirstXuanPaiManage; + } + /*·*/ + if (CI_SUCCESS == routeCheck) + { /*ɹ*/ + firstXuanPaiOvertime = RouteFirstXuanOverTime(routeId); + if (OVERTIME_YES == firstXuanPaiOvertime) + {/*ѡʱ*/ + /*cgh - ϲCID - 2341 - 7 ޸ѡųʱ*/ + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + routeProperty = GetRouteReverseProperty(routeId); + if (ROUTE_REVERSE_PROPERTY_YES == routeProperty) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + + /*ӽ·ѡʱӡ*/ + SetErrorData(chFunctionId, CI_DEVICE_TYPE_ROUTE, routeId, + ETYPE_ROUTE_FIRST_XUANPAI_OVERTIME, ROUTE_STATE_FIRST_XUANPAI, ESEND_LEVEL_ZERO); + } + /*δʱ*/ + + /*·ѡ*/ + returnValueFunc1 = RouteFirstXuanProc(routeId); +#if 0 + returnValueFunc2 = RouteFirstXuanAutoSigProc(routeId); +#else + returnValueFunc2 = RouteFirstXuanAutoSigCancelPro(routeId); +#endif + if ((CI_ERROR == returnValueFunc1) || (CI_ERROR == returnValueFunc2)) + { + /*ʧ || ·ԶźŽ·ȡʧ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + } + else if ((CI_SUCCESS == returnValueFunc1) && (CI_SUCCESS == returnValueFunc2)) + { + /*óɹ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_XUANPAI); /*-->ý·ѡ*/ + + /*·ѡŴ*/ + RouteXuanPaiManage(routeId); + } + else if ((RETURN_FIRSTXUANPAI_ERR_WAIT == returnValueFunc1) || (RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT == returnValueFunc2)) + { + /*ȴ*/ + } + else + { + } + } + else + { + /*·ʧ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + + + } +} + + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteXuanPaiManage(const UINT16 routeId) +{ + UINT8 returnValue = CI_ERROR; /*ֵ*/ + UINT8 NeedForDrvRoutAssoSwit = SWITCH_NEED_DRIV_FALSE; /*ǷҪ*/ + UINT8 routSwitDrvOvtmFlag = 0U;/*·ڵǷʱ־*/ + UINT8 chkSwitchPos = CI_ERROR; + + returnValue = LockRouteProc(routeId); + + if ((CI_SUCCESS == returnValue) || (RETURN_LOCK_ERR_SWITPOS == returnValue)) + { + RouteXuanPaiCommonProcess(routeId, returnValue); + } + else if (RETURN_LOCK_ERR_WAIT_SWCHECK == returnValue) + { + /*ȴ״̬*/ + ; + } + else + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } +} + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LeadRouteXuanPaiManage(const UINT16 routeId) +{ + UINT8 returnValue = 0u; /*ֵ*/ + + UINT8 NeedForDrvRoutAssoSwit = SWITCH_NEED_DRIV_FALSE;/*ǷҪ*/ + + UINT8 routSwitDrvOvtmFlag = 0u;/*·ڵǷʱ־*/ + + /*·չ*/ + returnValue = LockLeadRouteLogicProcess(routeId); + + /*·λü*/ + NeedForDrvRoutAssoSwit = CheckRoutAssoSwitNeedDriv(routeId); + + routSwitDrvOvtmFlag = ChekRoutSwitDrivOvtmStat(routeId);/*·ڵǷʱ*/ + + if ((CI_SUCCESS == returnValue) && (SWITCH_NEED_DRIV_FALSE == NeedForDrvRoutAssoSwit)) + { + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + /*ճɹ*/ + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_LOCK); /*-->ý·*/ + + /*մ*/ + RouteLeadLockManage(routeId); + } + else if (((RETURN_LOCK_ERR_SWITPOS == returnValue) && (CI_SUCCESS == routSwitDrvOvtmFlag)) || + ((SWITCH_NEED_DRIV_TRUE == NeedForDrvRoutAssoSwit) && (CI_SUCCESS == returnValue))) + { /*λòȷ*//*ѡ·*/ + + /*·*/ + if (CI_ERROR == RouteLockDriveSwitch(routeId, NeedForDrvRoutAssoSwit)) + {/* ȡ */ + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + } + else if (RETURN_LOCK_ERR_WAIT_SWCHECK == returnValue) + { + /*ȴ״̬*/ + ; + } + else + { + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + /* ·ʧ */ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + +} + +/* +* · +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstLockManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 openCloseState = 0u; /*źŻŹر״̬*/ + UINT8 routeLevel = 0u; /*·ල*/ + UINT8 returnValue = 0u; /*Ƿִ*/ + UINT8 routeType = 0u;/*·*/ + UINT8 routeReverse = 0u; + UINT8 routeAirShaft = 0u; + + /* źʱ״̬*/ + UINT8 const routeTimeState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId), + GetSystemParaRouteOpenSigCyc()); + + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + openCloseState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId)); /*ȡ·ʼźŻŹر״̬*/ + routeLevel = GetRouteLevel(routeId); /*ȡ·ල*/ + + routeType = GetRouteType(routeId); + routeReverse = GetRouteReverseProperty(routeId); + routeAirShaft = GetAirShaftRouteType(routeId); + if ((ROUTE_LEVEL_BLOC == routeLevel) || + (ROUTE_TYPE_RETURN == routeType) || (ROUTE_TYPE_DIAOCHE == routeType) || + (ROUTE_REVERSE_PROPERTY_YES == routeReverse) || + (ROUTE_TYPE_AIRSHAFT == routeAirShaft)) + { + /*ʽ·۷··羮·*/ + if (ROUTE_OVERLAP_SET_NO == GetRouteOverlapLockFlag(routeId)) + { + /*·δ*/ + if (CI_TIME_OUT == routeTimeState) + { + /*źſųʱ*/ + SetErrorData(EFUNC_LOCK_BLOC_T_ROUTE, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_OVERLAP_UNLOCK, ROUTE_OVERLAP_SET_NO, ESEND_LEVEL_ATS); + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCKERR); /*-->ó쳣*/ + + returnValue = CI_ERROR; + } + else + { + /*δʱȴ,ʱźſż*/ + returnValue = CI_ERROR; + } + } + else + { + /*ûб*/ + + /*ռü*/ + returnValue = BlocOverlapOccClearProc(routeId); + if (CI_ERROR == returnValue) + { + /*ռ*/ + if (routeTimeState != CI_TIME_IN) + {/*ռóʱ*/ + SetErrorData(EFUNC_LOCK_BLOC_T_ROUTE, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_OVERLAP_UNLOCK, ROUTE_OVERLAP_SET_NO, ESEND_LEVEL_ATS); + debug_infor_printf((const)"\nRoute %d ovlerlap OccTimeOut.\n", routeId); + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCKERR); /*-->ó쳣*/ + } + + } + + } + } + else + { + returnValue = CI_SUCCESS; + } + + if (CI_SUCCESS == returnValue) + { + if (SIGNAL_OPEN == openCloseState) + { /*źſ*/ + + if (CI_SUCCESS == RouteHaveTrainNear(routeId)) + { + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_OPEN); /*ýӽ*/ + + RouteNearOpenManage(routeId); /*-->·ӽŹ*/ + } + else + { + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_OPEN); /*Ԥȿ*/ + + RouteYuXianOpenManage(routeId); /*·ԤȿŹ*/ + } + } + else + { /*źŹر*/ + + /*Ž·źŴ*/ + returnValue = OpenRouteSignalProc(routeId); + + if (CI_SUCCESS == returnValue) + { + /*ųɹ*/ + + /*ȴ*/ + } + else + { + /*ʧ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCKERR); /*-->ó쳣*/ + } + } + } + + +} + + +/* +* ·쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstLockErrManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 openCloseState = 0u; /*źŻŹر״̬*/ + + UINT8 needOpenNotTrueRepeatFlag = ROUTE_NEEDOPEN_REOPEN_NO;/*迪Ųʱؿ־*/ + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + openCloseState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId)); /*ȡ·ʼźŻŹر״̬*/ + + if (SIGNAL_OPEN == openCloseState) + { + /*źſ*/ + + if ((CI_SUCCESS == AutoSignalOrRouteValid(routeId)) || + (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId))) + { + /*źؿ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_OPEN); /*ý·״̬Ԥȿš*/ + + RouteYuXianOpenManage(routeId); /*·ԤȿŹ*/ + } + else + { + needOpenNotTrueRepeatFlag = GetRouteNeedOpenReopenFlag(routeId); + if (ROUTE_NEEDOPEN_REOPEN_YES == needOpenNotTrueRepeatFlag) + { +#if 0 + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0); +#endif + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_OPEN); /*ý·״̬Ԥȿš*/ + + RouteYuXianOpenManage(routeId); /*·ԤȿŹ*/ + } + else + { + /*źŻ쳣*/ + /*xxxxx崻*/ + + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_SIGNAL, + startSignalId, + ETYPE_SYSTEM_SIGNAL_OPEN, + openCloseState, ESEND_LEVEL_ZERO); + } + } + + } + else + { + /*źŹر*/ + + if (((CI_SUCCESS == AutoSignalOrRouteValid(routeId)) && (SIGNAL_DS_BREAK_NO == GetSignalDsBreakFlag(startSignalId))) || + (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId))) + { + /*ؿźźŴ*/ + (void)OpenRouteSignalProc(routeId); + } + else + { + /* ֽ·쳣״̬*/ + needOpenNotTrueRepeatFlag = GetRouteNeedOpenReopenFlag(routeId); + if (ROUTE_NEEDOPEN_REOPEN_YES == needOpenNotTrueRepeatFlag) + {/*迪㣬迪ؿ־Чʱ*/ + (void)OpenRouteSignalProc(routeId); + } + } + } +} + + +/* +* ·Ԥչ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteYuXianLockManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT8 startSignalPreDrvColor = 0u; /*ʼźŻɫ*/ + + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + startSignalCurColor = GetSignalCurColor(startSignalId); + startSignalPreDrvColor = GetSignalPreDriveColor(startSignalId); + + openCloseState = GetSignalOpenCloseState(startSignalCurColor); + + if (SIGNAL_OPEN == openCloseState) + {/*ʼźŻ*/ + if (SIGNAL_OPEN != GetSignalOpenCloseState(startSignalPreDrvColor)) + {/*֮ǰر*/ + /*رյźŻδر*/ + } + else + {/*֮ǰ*/ + if ((CI_SUCCESS == AutoSignalOrRouteValid(routeId)) || + (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId))) + { + /*Զ·źЧ||źؿЧ*/ + if (CI_SUCCESS == RouteHaveTrainNear(routeId)) + { /*·гӽ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ýӽ*/ + + RouteNearOpenManage(routeId); /*-->·ӽŹ*/ + } + else + { + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_OPEN); /*-->Ԥȿ*/ + + RouteYuXianOpenManage(routeId); /*·ԤȿŹ*/ + } + } + else + { + /*źŻ쳣*/ + /*xxxxx崻*/ + + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_SIGNAL, + startSignalId, + ETYPE_SYSTEM_SIGNAL_OPEN, + openCloseState, ESEND_LEVEL_ZERO); + } + } + } + else + { + /*źŹر*/ + + if (CI_SUCCESS == RouteHaveTrainNear(routeId)) + { + /*гӽ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + else + { + /*޳ӽ*/ + + if (((CI_SUCCESS == AutoSignalOrRouteValid(routeId)) && (SIGNAL_DS_BREAK_NO == GetSignalDsBreakFlag(startSignalId))) || + (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId))) + { + /*Զ·źЧ||źؿЧ*/ + + /*Ž·źŴ*/ + (void)OpenRouteSignalProc(routeId); + } + else + { + /*ؿԶź*/ + } + } + } +} + + +/* +* ·ԤȿŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteYuXianOpenManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 needOpenNotTrueRepeatFlag = ROUTE_NEEDOPEN_REOPEN_NO; + UINT8 curColor = 0u; + UINT8 sigState = 0u; + UINT8 funcId = EFUNC_RouteYuXianOpenManage;/*ID*/ + UINT8 checkResult = 0u; + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + curColor = GetSignalCurColor(startSignalId); + + sigState = GetSignalOpenCloseState(curColor); + + if (SIGNAL_OPEN == sigState) + { /*źſ*/ + needOpenNotTrueRepeatFlag = GetRouteNeedOpenReopenFlag(routeId); + if (ROUTE_NEEDOPEN_REOPEN_YES == needOpenNotTrueRepeatFlag) + { + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + } + /*ֿŽ·źŴ*/ + checkResult = KeepOpenRouteSignalProc(routeId); + if (CI_SUCCESS == checkResult) + { + /*ֳɹ*/ + checkResult = RouteHaveTrainNear(routeId); + if (CI_SUCCESS == checkResult) + { + /*·гӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ӽ*/ + + RouteNearOpenManage(routeId); /*-->·ӽŹ*/ + } + else + { + /*Ԥȿ*/ + return; + } + } + else + { + /*ʧ*/ + checkResult = RouteHaveTrainNear(routeId); + if (CI_SUCCESS == checkResult) + { + /*гӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + else + { + /*޳ӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_LOCK); /*-->Ԥ*/ + } + } + } + else + { + /*źŹر*/ + checkResult = RouteHaveTrainNear(routeId); + if (CI_SUCCESS == checkResult) + { + /*гӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + else + { + /*޳ӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_LOCK); /*-->Ԥ*/ + } + + /*źŻϹرձ*/ + SetErrorData(funcId, CI_DEVICE_TYPE_SIGNAL, startSignalId, ETYPE_SIG_START_OPEN_STATE, sigState, ESEND_LEVEL_ATS); + } +} + + +/* +* ·ӽ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +* mod ±淶ifж֮ǰнӣؿźźжǷӽ +*/ +void RouteNearLockErrManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT8 startSignalPreDrvColor = 0u; /*ʼźŻɫ*/ + UINT8 routeAutoState = 0u; + UINT16 sigInfirPhySecId = 0u;/*źŻڷһ*/ + UINT8 preOpenCloseState = 0U; /*ڿ״̬*/ + UINT8 autoSignalValid = 0U; /*·ԶźǷЧ*/ + UINT8 startSignalDsStat = 0U; + UINT8 routeRepeatStat = 0U; + UINT8 routeTrainNear = 0U; + /*ȡ·ʼźŻID*/ + startSignalId = GetRouteStartSignalId(routeId); + sigInfirPhySecId = GetSignalInFirstPhySecId(startSignalId, routeId); + + startSignalCurColor = GetSignalCurColor(startSignalId); + startSignalPreDrvColor = GetSignalPreDriveColor(startSignalId); + + openCloseState = GetSignalOpenCloseState(startSignalCurColor); + routeAutoState = GetRouteAutoRouteSetState(routeId); + + preOpenCloseState = GetSignalOpenCloseState(startSignalPreDrvColor); + + autoSignalValid = AutoSignalOrRouteValid(routeId); /*ԶźЧ־*/ + startSignalDsStat = GetSignalDsBreakFlag(startSignalId); /*źŻ˿־*/ + routeRepeatStat = GetRouteRepeatOpenFlag(routeId); /*·ؿ־*/ + routeTrainNear = RouteHaveTrainNear(routeId); /*·гӽ*/ + if (SIGNAL_OPEN == openCloseState) + {/*ʼźŻ*/ + if (SIGNAL_OPEN != preOpenCloseState) + {/*֮ǰر*/ + /*رյźŻδر*/ + } + else + {/*֮ǰ*/ + if ((CI_SUCCESS == autoSignalValid) || (ROUTE_REPEATOPEN_SET_YES == routeRepeatStat)) + { /*ԶźŻؿ*/ + + if (CI_SUCCESS == routeTrainNear) + {/*·гӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ýӽ*/ + + RouteNearOpenManage(routeId); /*-->·ӽŹ*/ + } + else + {/*·޳ӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_OPEN); /*-->Ԥȿ*/ + + RouteYuXianOpenManage(routeId); /*·ԤȿŹ*/ + } + } + else + { + /*ź쳣*/ + /*xxxxx崻*/ + + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_SIGNAL, + startSignalId, + ETYPE_SYSTEM_SIGNAL_OPEN, + openCloseState, ESEND_LEVEL_ZERO); + } + } + } + else + { + /*źŹر*/ +#if 0 + /*仯෿ڷһβٱ̹20171016*/ + /*źŻѹڷһοУõһιգֵطź쳣رգźŻڷһο*/ + if ((SIGNAL_CROSS_STATE_YES == GetSignalCrossState(startSignalId)) && (SECTION_OCCUPY_NO == GetPhySecCurMergeState(sigInfirPhySecId))) + { + /*Ӹֵطź쳣رգźŻڷһο*/ + SetCiSendCmdBackInfoData(CI_BACK_SIG_CLOSE_EXCEPT, CI_DEVICE_TYPE_SIGNAL, startSignalId, 0, 0); + /*ڷһι*/ + SetPhySecLockState(sigInfirPhySecId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, GetRouteDirection(routeId)); + /*-->Զ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + else + { + } +#endif + if (((CI_SUCCESS == autoSignalValid) && (SIGNAL_DS_BREAK_NO == startSignalDsStat)) || + (ROUTE_REPEATOPEN_SET_YES == routeRepeatStat)) + { + /*Զ·źЧ||źؿЧ*/ + + /*Ž·źŴ*/ + (void)OpenRouteSignalProc(routeId); + } + else + { + /*ؿź*/ + } + } +} + + +/* +* ·ӽŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearOpenManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 routeState = 0u; + UINT8 autoSigRouteType = 0u; + UINT16 errorCodeCurSum = 0u; /*Ŀ*/ + ErrorDataStruct* errorCodeStu = NULL; /**/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 curColor = 0u; + UINT8 sigState = 0u; + UINT8 funcId = EFUNC_RouteNearOpenManage;/*ID*/ + UINT8 checkResult = 0u; + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + curColor = GetSignalCurColor(startSignalId); + + sigState = GetSignalOpenCloseState(curColor); + + /*ʼźⷽͬʱռѹΪгʻ룻ע⣺ʻ־ֻ˽жϣгʻжϴڲ*/ + checkResult = RouteInOutSecOccupy(routeId); + if (CI_SUCCESS == checkResult) + { + SetRouteTrainEnterFlag(routeId, ROUTE_TRAIN_ENTER_FLAG_YES); + } + + if (SIGNAL_OPEN == sigState) + { /*źſ*/ + + /*ֿŽ·źŴ*/ + checkResult = KeepOpenRouteSignalProc(routeId); + if (CI_SUCCESS == checkResult) + { + /*ֳɹ*/ + return; + } + else + { + /*ʧ*/ + checkResult = RouteLTrainEnter(routeId); + if (CI_SUCCESS == checkResult) + { /*гʻ*/ + errorCodeCurSum = GetErrorDataCurSum(); /*ȡ*/ + /**/ + for (ii = 0u; ii < errorCodeCurSum; ii++) + { + errorCodeStu = GetErrorData(ii); /*ȡ*/ + + if (NULL != errorCodeStu) + { + + if ((EFUNC_KEEP_BLOC_T_SIGNAL == errorCodeStu->FunctionId) || (EFUNC_KEEP_BLOC_R_SIGNAL == errorCodeStu->FunctionId)) + {/*ʽг·źűֺ͵ʽ۷·źű*/ + /*ʽ·*/ + if ((CI_DEVICE_TYPE_PHYSEC == errorCodeStu->DeviceType) && (ETYPE_PS_MERGY_OCU_STATE == errorCodeStu->DeviceStateType)) + { /*ʻ룬ɾ*/ + DeleteErrorData(ii); + } + + } + else if ((EFUNC_KEEP_CBTC_T_SIGNAL == errorCodeStu->FunctionId) || (EFUNC_KEEP_CBTC_R_SIGNAL == errorCodeStu->FunctionId)) + { /*CBTC·*/ + if ((CI_DEVICE_TYPE_LOGICSEC == errorCodeStu->DeviceType) && (ETYPE_LOGSEC_OCC_STATE == errorCodeStu->DeviceStateType)) + {/*ʱΪѹ*/ + DeleteErrorData(ii); + } + + } + else if ((EFUNC_CLD_KEEP_L_TRAIN_ROUTE == errorCodeStu->FunctionId) || (EFUNC_CLD_KEEP_D_TRAIN_ROUTE == errorCodeStu->FunctionId)) + {/*г·͵·źű*/ + if (((CI_DEVICE_TYPE_PHYSEC == errorCodeStu->DeviceType) || (CI_DEVICE_TYPE_LOGICSEC == errorCodeStu->DeviceType)) && + (ETYPE_PS_MERGY_OCU_STATE == errorCodeStu->DeviceStateType)) + { /*ʻ룬ɾ*/ + DeleteErrorData(ii); + } + + } + else + { + /**/ + } + } + } + checkResult = AutoSignalOrRouteValid(routeId); + if (CI_SUCCESS == checkResult) + { /*Զ·źЧ*/ + routeState = GetRouteAutoRouteSetState(routeId); + autoSigRouteType = GetRouteAutoSigSetState(routeId);/*ȡ·ǰǷΪԶźŽ·*/ + + if ((routeState == ROUTE_AUTOROUTE_RETURN) || (routeState == ROUTE_ALLAUTOROUTE_RETURN) + || (autoSigRouteType == ROUTE_AUTOSIGROUTE_YES)) + { + /*Զ۷·ɽ*//*ԶźŰת״̬ߣڽӽ߼д*/ + + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCK); /*-->ýӽ*/ + } + else + { + + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + } + else + { + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCK); /*-->ýӽ*/ + } + } + else + { + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + } + } + else + { + /*źŹϹر*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + + /*źŻϹرձ*/ + SetErrorData(funcId, CI_DEVICE_TYPE_SIGNAL, startSignalId, ETYPE_SIG_START_OPEN_STATE, sigState, ESEND_LEVEL_ATS); + } +} + + +/* +* ·ӽչ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +#if 0 +void RouteNearLockManage(const UINT16 routeId) +{ + UINT16 phySectionId = 0u; /*ID*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 autoSigRouteState = 0u; /*ԶźŽ·״̬*/ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT8 startSignalPreDrvColor = 0u; /*ʼźŻɫ*/ + + /*ȡ·ʼźŻID*/ + startSignalId = GetRouteStartSignalId(routeId); + autoSigRouteState = GetRouteAutoSigSetState(routeId); /*ȡԶźŽ·״̬*/ + startSignalCurColor = GetSignalCurColor(startSignalId); + startSignalPreDrvColor = GetSignalPreDriveColor(startSignalId); + openCloseState = GetSignalOpenCloseState(startSignalCurColor); + + if ((SIGNAL_OPEN == openCloseState) && (startSignalCurColor != startSignalPreDrvColor)) + { + /*رյźŻδر*/ + return; + } + else if ((SIGNAL_OPEN == openCloseState) && (startSignalCurColor == startSignalPreDrvColor)) + { + if (ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) + { + + if (CI_SUCCESS == RouteHaveTrainNear(routeId)) + {/*·гӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ýӽ*/ + + RouteNearOpenManage(routeId); /*-->·ӽŹ*/ + } + else + {/*·޳ӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_OPEN); /*-->Ԥȿ*/ + + RouteYuXianOpenManage(routeId); /*·ԤȿŹ*/ + } + } + } + else + { /*ʼźŻر*/ + if (ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) + { + if (SIGNAL_DS_BREAK_NO == GetSignalDsBreakFlag(startSignalId)) + { + /*ԶźؿЧ*/ + + /*Ž·źŴ*/ + OpenRouteSignalProc(routeId); + + } + } + else + { + + /*·Զ*/ + returnValue = RouteFirstSecAutoUnlockLogicProcess(routeId, &phySectionId); + + if (phySectionId > 0u) + { + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + SetPhySecLockState(phySectionId, PHYSICAL_SECTION_LOCK_DELAY, routeId, GetRouteDirection(routeId)); /*ʱ*/ + + SetPhySecAutoUnlockStartCycNum(phySectionId, Get2oo2CurCycleNum()); /*ʱʼ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCK); /*-->Զ*/ + } + else if (RETURN_AUTOLOCK_ERR_EXCEPT == returnValue) + { /*쳣*/ + + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + else + { /*ʧ*/ + } + } + } + } +} +#endif + +/* @func ·ӽչ +* @param UINT16 routeId ·ID +* @return void +* @brief ߼ιΪֱӹ +*/ +void RouteNearLockManage(const UINT16 routeId) +{ + UINT16 phySectionId = 0u; /*ID*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 autoSigRouteState = 0u; /*ԶźŽ·״̬*/ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT8 startSignalPreDrvColor = 0u; /*ʼźŻɫ*/ + UINT16 fLockLogId = 0u; + UINT8 logCurOccupyState = 0u; + UINT8 logPreOccupyState = 0u; + UINT16 logSectionId = 0u; + UINT16 logBelongPhyId = 0u; + UINT8 routeDir = 0u; + UINT32 cycNum = 0u; + UINT8 chPhyIncSwitchSum = 0U; + UINT16* pPhySecSwitchId = NULL; + UINT8 chRoutePhysectionSum = 0U; /**/ + RoutePhysicalSectionStruct* pRouteSecStru = NULL; /**/ + UINT8 chRoutePhySecState = 0U;/*·εǰں״̬*/ + UINT8 chRoutePhySecType = 0U;/*·εǰ*/ + UINT8 chRouteType = 0u;/*·*/ + UINT16 validReturnSigId = 0U; /*Ч۷źŻ*/ + UINT16 returnSecId = 0U; /*۷*/ + UINT8 localCiType = 0U;/**/ + + localCiType = GetLocalCiType(); + /*ȡ·ʼźŻID*/ + startSignalId = GetRouteStartSignalId(routeId); + autoSigRouteState = GetRouteAutoSigSetState(routeId); /*ȡԶźŽ·״̬*/ + startSignalCurColor = GetSignalCurColor(startSignalId); + startSignalPreDrvColor = GetSignalPreDriveColor(startSignalId); + openCloseState = GetSignalOpenCloseState(startSignalCurColor); + cycNum = Get2oo2CurCycleNum(); + /*ȡ·*/ + routeDir = GetRouteDirection(routeId); + chRoutePhysectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + chRouteType = GetRouteType(routeId);/*ȡ·*/ + chRoutePhySecState = GetPhySecCurMergeState(pRouteSecStru[0].PhysicalSectionId);/*·εǰں״̬*/ + chRoutePhySecType = GetPhySecType(pRouteSecStru[0].PhysicalSectionId);/*·εǰ*/ + + if ((ROUTE_TYPE_DIAOCHE == chRouteType) && + (PHYSICAL_SEC_TYPE_NOSWITCH == chRoutePhySecType) && + (1u == chRoutePhysectionSum) && + (SECTION_OCCUPY_YES == chRoutePhySecState)) + { /*cghϲ··&&ֻһ&&޲&&ںռ*/ + + SetPhySecLockState(pRouteSecStru[0].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, routeId, routeDir); /*δ*/ + /*ͬʱڱ·յ߼δ*/ + SetPhyIncludeLogLockState(pRouteSecStru[0].PhysicalSectionId, LOG_SECTION_LOCK_NO, routeId); + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + else + { + + if (SIGNAL_OPEN == openCloseState) + {/*ʼźŻ*/ + if (SIGNAL_OPEN != GetSignalOpenCloseState(startSignalPreDrvColor)) + {/*֮ǰر*/ + /*رյźŻδر*/ + } + else + {/*֮ǰ*/ + if (ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) + { + if (CI_SUCCESS == RouteHaveTrainNear(routeId)) + {/*·гӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ýӽ*/ + + RouteNearOpenManage(routeId); /*-->·ӽŹ*/ + } + else + {/*·޳ӽ*/ + SetRouteStateManage(routeId, ROUTE_STATE_YUXIAN_OPEN); /*-->Ԥȿ*/ + + RouteYuXianOpenManage(routeId); /*·ԤȿŹ*/ + } + } + else + { + /*ӱelse֮޸ڣ20170210ա޸ԭֽ֧ӽ쳣ʱӦźؿ*/ + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ýӽ*/ + + RouteNearOpenManage(routeId); /*-->·ӽŹ*/ + } + else + { + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_SIGNAL, + startSignalId, + ETYPE_SYSTEM_SIGNAL_OPEN, + openCloseState, ESEND_LEVEL_ZERO); + } + } + } + } + else + { /*ʼźŻر*/ + if (ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) + { + if (SIGNAL_DS_BREAK_NO == GetSignalDsBreakFlag(startSignalId)) + { + (void)OpenRouteSignalProc(routeId); + } + else + { + /*˿ʱȴ*/ + } + } + else if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { + /*(ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId))޸ڣ20170209ա޸ԭֽ֧ӽ쳣ʱӦźؿ*/ + (void)OpenRouteSignalProc(routeId); + } + else + { + /*ȡ·յĵһ߼ռ״̬*/ + fLockLogId = GetRouteFirstNormalLockLogId(routeId); + logCurOccupyState = GetLogSecCurCtOrUtOccupyState(fLockLogId); + logPreOccupyState = GetLogSecPreCtOrUtOccupyState(fLockLogId); + + logBelongPhyId = GetLgcSecRelativePhySecId(fLockLogId); + chPhyIncSwitchSum = GetPhyIncludeSwitchSum(logBelongPhyId); + + pPhySecSwitchId = GetPhySecIncludeSwitch(logBelongPhyId); + + validReturnSigId = GetValidReturnSinalId(routeId, logBelongPhyId); + returnSecId = GetSignalOutFirstPhySecId(validReturnSigId); + /*߼εǰCTռã֮ǰCTռãǰ ߼βǵΣҷ۷·Ϊ۷·۷*/ + if (((LOGICSECTION_OCCUPY_CT == logCurOccupyState) || + ((LOGICSECTION_OCCUPY_NO == logCurOccupyState) && (LOGICSECTION_OCCUPY_CT == logPreOccupyState))) + && ((0U == chPhyIncSwitchSum) && (NULL != pPhySecSwitchId)) + && (((returnSecId != logBelongPhyId) && (0U != logBelongPhyId)) || ((ROUTE_TYPE_RETURN != chRouteType) && (0U == validReturnSigId))) + && (CI_TYPE_CLD != localCiType)) + { + /*߼ν*/ + returnValue = RouteLogSecAutoUnlockProcess(routeId, &logSectionId); + } + else + { + /*ν·Զ*/ + returnValue = RouteFirstSecAutoUnlockProcess(routeId, &phySectionId); + } + + /*ID0߼ε0*/ + if ((0u < phySectionId) && (0u == logSectionId)) + { + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + SetPhySecLockState(phySectionId, PHYSICAL_SECTION_LOCK_DELAY, routeId, routeDir); /*ʱ*/ + + /*ͬʱڱ·յ߼ʱ*/ + SetPhyIncludeLogLockState(phySectionId, LOG_SECTION_LOCK_DELAY, routeId); + + SetPhySecAutoUnlockStartCycNum(phySectionId, cycNum); /*ʱʼ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCK); /*-->Զ*/ + } + else if (RETURN_AUTOLOCK_ERR_EXCEPT == returnValue) + { /*쳣*/ + +#if 0 + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ +#endif + if (ROUTE_TYPE_DIAOCHE == chRouteType) + { + /*cgh 20230630 YF0083-991*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); + } + else + { + /*쳣*/ + SetPhySecLockState(phySectionId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, routeDir); + /*ͬʱڱ·յ߼쳣*/ + SetPhyIncludeLogLockState(phySectionId, LOG_SECTION_LOCK_EXCEPT, routeId); + /*-->Զ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + } + else if (CI_CANCLE_ZHAOCHA_FAIL == returnValue) + {/*ȡղ̵δ*/ + /*ý·ӽ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); + } + else + { /*ʧ*/ + } + } + /*߼ID0ε0*/ + else if ((0u == phySectionId) && (0u < logSectionId)) + { + /*ɹ*/ + if (CI_SUCCESS == returnValue) + { + /*߼ʱ*/ + SetLogSecLockState(logSectionId, LOG_SECTION_LOCK_DELAY, routeId, routeDir); + /*߼ʱʼں*/ + SetLogUnlockStartCycNum(logSectionId, cycNum); + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCK); /*-->Զ*/ + } + /*쳣*/ + else if (RETURN_AUTOLOCK_ERR_EXCEPT == returnValue) + { + /*ҵӦ*/ + logBelongPhyId = GetLgcSecRelativePhySecId(logSectionId); + routeDir = GetRouteDirection(routeId); + /*쳣*/ + SetPhySecLockState(logBelongPhyId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, routeDir); + /*ͬʱڱ·յ߼쳣*/ + SetPhyIncludeLogLockState(logBelongPhyId, LOG_SECTION_LOCK_EXCEPT, routeId); + /*-->Զ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + /*ȡղ̵δ*/ + else if (CI_CANCLE_ZHAOCHA_FAIL == returnValue) + { + /*ý·ӽ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); + } + else + { /*ʧ*/ + } + } + /**/ + else + { + /**/ + } + } + } + } +} + +/* +* ·ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteDelayUnlockManage(const UINT16 routeId) +{ + UINT8 routeLevel = 0u; /*·ල*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT32 delayStartCycNum = 0u; /*ʱʼں*/ + UINT32 delayTotalCycSum = 0u; /*ʱ*/ + UINT8 checkTimeState = CI_TIME_NO; + UINT8 zrjDelayType;/*·˽ʱ*/ + UINT8 routePreState = 0u;/*·֮ǰ״̬*/ + UINT8 zqxDelayflag = 0u;/*ȡʱ־*/ + UINT8 checkRouteCancle = 0u; + UINT8 checkZongRenJieRulst = 0u; + UINT16 wTrainId = 0u; + UINT16 wLastTrainId = 0u; + UINT32 curCycle = 0u; + UINT8 chRouteState = 0u; + + /*ȡ·ֶ̬*/ + routeLevel = GetRouteLevel(routeId); /*ȡ·ල*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + curCycle = Get2oo2CurCycleNum(); + chRouteState = GetRouteType(routeId); + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + if (SIGNAL_OPEN == GetSignalOpenCloseState(GetSignalCurColor(startSignalId))) + { /*źſ*/ + + return; + } + + delayStartCycNum = GetRouteDelayUnlockStartCycNum(routeId); /*ȡ·ʱʼ*/ + delayTotalCycSum = GetRouteDelayCycleCount(routeId); + + zrjDelayType = GetRouteZongRenJieDelayType(routeId);/*ý·˽ʱ*/ + /*ȡȡʱ־*/ + zqxDelayflag = GetRouteZongQuXiaoDelayFlag(routeId); + + /*·ȡ־*/ + if (ROUTE_ZQX_DELAY_YES == zqxDelayflag) + { + /*·ȡ*/ + checkRouteCancle = RouteCancelLogicProcess(routeId); + /*ȡ·*/ + if (CI_SUCCESS == checkRouteCancle) + { + /*ʱʱ*/ + checkTimeState = SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum); + /*ʱʱ*/ + if (CI_TIME_OUT == checkTimeState) + { + /*-->ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + /*ȡʱ*/ + SetRouteZongQuXiaoDelayFlag(routeId, ROUTE_ZQX_DELAY_NO); + } + else + { + /*ȴʱ*/ + } + + } + else + { + /*ó쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCKERR); + /*ȡʱ*/ + SetRouteZongQuXiaoDelayFlag(routeId, ROUTE_ZQX_DELAY_NO); + } + } + else + { + if (ROUTE_ZRJ_DELAY_TYPE_IDLE == zrjDelayType) + { + /*·ȡ*/ + checkRouteCancle = RouteCancelLogicProcess(routeId); + if (CI_SUCCESS == checkRouteCancle) + { + /*ȡɹ*/ + checkTimeState = SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum); + + if ((CI_TIME_OUT == checkTimeState) || (ROUTE_STOPENSURE_YES == GetRouteStopensureFlag(routeId))) + { + /*ʱյ֤ͣ*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + /* ѯгID */ + SetRouteStopEnsureTrainId(routeId, 0u); + SetRouteStopEnsureCyc(routeId, 0u); + } + else + { + /*ʱδδ*/ + wTrainId = GetRouteNearestTrainId(routeId); + wLastTrainId = GetRouteStopEnassureTrainId(routeId); + + if ((wTrainId != wLastTrainId) && (0u != wTrainId)) + { + /* ѯʻǰˣ */ + SetRouteStopEnsureTrainId(routeId, wTrainId); + SetRouteStopEnsureCyc(routeId, curCycle); + } + } + } + else + { /*ȡʧ*/ + routePreState = GetRoutePreState(routeId); + /* ѯгID */ + SetRouteStopEnsureTrainId(routeId, 0u); + SetRouteStopEnsureCyc(routeId, 0u); + if ((ROUTE_STATE_LEAD_LOCKERR == routePreState) || (ROUTE_STATE_LEAD_LOCK == routePreState)) + { + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_LOCKERR); /*-->쳣*/ + } + else if ((ROUTE_STATE_FIRST_LOCK == routePreState) || (ROUTE_STATE_YUXIAN_LOCK == routePreState) || (ROUTE_STATE_FIRST_LOCKERR == routePreState)) + { + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCKERR); /*-->ó쳣*/ + } + else + { + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + } + } + else if ((ROUTE_ZRJ_DELAY_TYPE_ALL_EXP == zrjDelayType) || (ROUTE_ZRJ_DELAY_TYPE_EXP_TO_OCCUPY == zrjDelayType)) + { + checkZongRenJieRulst = CheckRouteZongRenJieFeasibility(routeId); + if (CI_SUCCESS == checkZongRenJieRulst) + { + /*ȡɹ*/ + checkTimeState = SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum); + + if ((CI_TIME_OUT == checkTimeState) || (ROUTE_STOPENSURE_YES == GetRouteStopensureFlag(routeId))) + { + /*ʱյ֤ͣ*/ + + /*·α̹*/ + + if (ROUTE_ZRJ_DELAY_TYPE_ALL_EXP == zrjDelayType) + { + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_EXCEPT); + + /*·߼ζ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_EXCEPT); + } + else + { + /*ֻг߹İ׹̹*/ + SetRoutePhySecExpLockToOccupy(routeId); + } + + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + + /* ѯгID */ + SetRouteStopEnsureTrainId(routeId, 0u); + SetRouteStopEnsureCyc(routeId, 0u); + } + else + { + /*ʱδδ,ȡ·ڵгID*/ + wTrainId = GetRouteNearestTrainId(routeId); + + + wLastTrainId = GetRouteStopEnassureTrainId(routeId); + + if ((wTrainId != wLastTrainId) && (0u != wTrainId)) + { + /* ѯʻǰˣ */ + SetRouteStopEnsureTrainId(routeId, wTrainId); + SetRouteStopEnsureCyc(routeId, curCycle); + } + } + + } + else + { /*ȡʧ*/ + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + /* ѯгID */ + SetRouteStopEnsureTrainId(routeId, 0u); + SetRouteStopEnsureCyc(routeId, 0u); + } + } + else + { + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + } + } +} + + +/* +* ·Զ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RoutePhySecAutoUnlockManage(const UINT16 routeId) +{ + UINT16 phySectionId = 0u; /*ID*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 localCiType = 0u; + UINT16 sectionSum = 0u; /**/ + UINT16 sectionId = 0u; /*ID*/ + UINT8 sectionState = 0u; /*豸״̬*/ + UINT16 applyRelayId = 0u; /*Գ̵ID*/ + UINT16 allowRelayId = 0u; /*Գ̵ID*/ + UINT8 ii = 0u; + UINT8 expLockCancel = 0u; /*־λ*//*Ĭϲȡ쳣*/ + UINT8 kk = 0; + NonRouteDataStruct* pNonData = NULL; + UINT8 interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*ȡԳ복νӿڷʽ*/ + + /*·Զ*/ + returnValue = RouteOtherSecAutoUnlockProcess(routeId, &phySectionId); + + if (0u == phySectionId) + { + /*δҵ*/ + } + else + { + if (CI_SUCCESS == returnValue) + { /*νɹ*/ + SetPhySecLockState(phySectionId, PHYSICAL_SECTION_LOCK_DELAY, routeId, GetRouteDirection(routeId)); /*ʱ*/ + + /*ͬʱڱ·յ߼ʱ*/ + SetPhyIncludeLogLockState(phySectionId, LOG_SECTION_LOCK_DELAY, routeId); + + SetPhySecAutoUnlockStartCycNum(phySectionId, Get2oo2CurCycleNum()); /*ʱʼ*/ + } + else if (RETURN_AUTOLOCK_ERR_EXCEPT == returnValue) + { + /*쳣*/ + localCiType = GetLocalCiType(); + if (CI_TYPE_SCX == localCiType) + { + /*ȡǽ·id*/ + + for (; kk < NONROUTE_ID_NUM_MAX; kk++) + { + pNonData = GetNonRouteDataPtr() + kk; + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복βü̵ӿ*/ + applyRelayId = GetSCXDrvApplyTryRelayIdById(pNonData->NonRouteId); + allowRelayId = GetSCXColAgreeTryRelayIdById(pNonData->NonRouteId); + + if ((RELAY_STATE_DOWN == GetRelayCollState(applyRelayId)) && (RELAY_STATE_DOWN == GetRelayCollState(allowRelayId))) + { + sectionSum = GetPhySecCurSum(); + for (ii = 0u; ii < sectionSum; ii++) + { + sectionId = GetPhySecId(ii); /*ȡID*/ + sectionState = GetPhySecCurMergeState(sectionId); + + if (SECTION_OCCUPY_NO != sectionState) + { + break; + } + } + + if (ii == sectionSum) + { + expLockCancel = 1u; + } + } + } + else if ((SCX_CLD_INTERFACE_COMM == interfaceType) || (SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*Գ복ͨŽӿ*/ + if ((COMM_TRAIN_TEST_DEV_STATE_INVALID == GetCommTrainTestSCXSQAJStatus()) && (COMM_TRAIN_TEST_DEV_STATE_INVALID == GetCommTrainTestSCXYSKJStatus())) + {/*豸״̬ЧΪԳгʻ복*/ + sectionSum = GetPhySecCurSum(); + for (ii = 0u; ii < sectionSum; ii++) + { + sectionId = GetPhySecId(ii); /*ȡID*/ + sectionState = GetPhySecCurMergeState(sectionId); + + if (SECTION_OCCUPY_NO != sectionState) + { + break; + } + } + + if (ii == sectionSum) + {/*һռ*/ + expLockCancel = 1u; + } + } + } + else + { + /*޲*/ + } + } + } + + if (1u == expLockCancel) + { + /*ο,Գ⴦̹*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*ý·*/ + } + else + { + /*쳣*/ + SetPhySecLockState(phySectionId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, GetRouteDirection(routeId)); + /*ͬʱڱ·յ߼쳣*/ + SetPhyIncludeLogLockState(phySectionId, LOG_SECTION_LOCK_EXCEPT, routeId); + /*-->Զ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + return; + } + else + { + /*ʧ*/ + } + } +#if 0 + /*·ʱ*/ + PhySecDelayUnlockProc(routeId); +#endif +} + + +/* +* ·Զ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RoutePhySecAutoUnlockErrManage(const UINT16 routeId) +{ + UINT16 dlockLogId = 0u; + UINT32 logUnlockStartCycNum = 0u; + UINT32 phyUnlockStartCycNum = 0u; + UINT16 logBelongPhyId = 0u; + + /*ȡһʱ߼*/ + dlockLogId = GetRouteFirstDelayLockLogId(routeId); + logUnlockStartCycNum = GetLogUnlockStartCycNum(dlockLogId); + + /*ȡһʱ߼*/ + logBelongPhyId = GetLgcSecRelativePhySecId(dlockLogId); + + /*ȡʱں*/ + phyUnlockStartCycNum = GetPhySecAutoUnlockStartCycNum(logBelongPhyId); + + /*߼ʱʼںŴ0*/ + if ((dlockLogId > 0u) && (logUnlockStartCycNum > 0u)) + { + /*ʱ߼*/ + LogSecDelayUnlockProc(routeId); + } + /*˵ʱ*/ + else if ((dlockLogId > 0u) && (0u == logUnlockStartCycNum) && (phyUnlockStartCycNum > 0u)) + { + /*ʱ*/ + PhySecDelayUnlockProc(routeId); + } + else + { + /**/ + } + /*쳣δ*/ + RouteExpLockContinue(routeId); +} + + +/* +* ·չ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadLockManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT32 dwDelayOpenStartCyc = 0U; /*ⱨʱʼ*/ + UINT32 dwDelayOpenCycNum = 0U; /*ⱨʱ*/ + UINT8 cRouteCanOpenFlag = CI_ERROR; /*·ɿű־*/ + UINT8 cTimeCheckFlag = CI_TIME_NO; + UINT32 dwRouteSigOpenStartCyc = 0U; /*·źſʼ*/ + UINT32 dwCurCyc = 0U; + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + +#if 0 + if (RouteSecFlockVainCheck(routeId) == CI_ERROR) + { + /*η*/ + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_LOCKERR); /*쳣*/ + + return; + } +#endif + + if (SIGNAL_OPEN == GetSignalOpenCloseState(GetSignalCurColor(startSignalId))) + { /*źſ*/ + if (GetPhySecCurMergeState(GetSignalInFirstPhySecId(startSignalId, routeId)) == SECTION_OCCUPY_YES) + {/*ڷι*/ + SetRouteLeadFaultOpenStartCyc(routeId, Get2oo2CurCycleNum()); /*ʱʱ*/ + } + else + { + SetRouteLeadFaultOpenStartCyc(routeId, 0u); /*ʱʱ*/ + } + + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_OPEN); /**/ + + RouteLeadOpenManage(routeId);/*·Ź*/ + } + else + { /*źŹر*/ + dwDelayOpenStartCyc = GetRouteDelayOpenStartCyc(routeId); /*ȡ·ⱨʱʼں*/ + dwDelayOpenCycNum = GetSGBJRouteDelayOpenCount(); + cTimeCheckFlag = SystemOverTimeCheck(dwDelayOpenStartCyc, dwDelayOpenCycNum); + + if ((CI_TIME_OUT == cTimeCheckFlag) || (CI_TIME_NO == cTimeCheckFlag)) + { + dwRouteSigOpenStartCyc = GetRouteOpenSigStatrtCycNum(routeId); + if (0U == dwRouteSigOpenStartCyc) + { + dwCurCyc = Get2oo2CurCycleNum(); + SetRouteOpenSigStartCycNum(routeId, dwCurCyc); /*ⱨʱ½·źſʱδã˴ý·źſʱΪǰ*/ + } + else + { + /*·źſʼã*/ + } + SetRouteDelayOpenStartCyc(routeId, 0U); /*ⱨʱʼں*/ + cRouteCanOpenFlag = CI_SUCCESS; + } + else + { + /*ʱУ*/ + } + + returnValue = OpenLeadRouteLogicProcess(routeId); + + /*·źŴ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + if (CI_SUCCESS == cRouteCanOpenFlag) + { + DriveSignalOpen(startSignalId, routeId); /*·źſ*/ + } + else + { + /*ʱУ*/ + } +#if 0 + CleanRoutePhySecPreOccupyState(routeId); /*·֮ǰռ״̬*/ +#endif + } + else if (RETURN_OPEN_ERR_SIGOPEN == returnValue) + { /*رźδر*/ + (void)DriveSignalClose(startSignalId); /*źŹر*/ + } + else if (RELAY_STATE_WAITE == returnValue) + { + /*ȴ*/ + } + else + { /*ʧ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_LOCKERR); /*-->쳣*/ + } + } +} + + +/* +* ·쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadLockErrManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT8 startSignalPreDrvColor = 0u; /*ʼźŻɫ*/ + + + /*ȡ·ʼźŻID*/ + startSignalId = GetRouteStartSignalId(routeId); + + startSignalCurColor = GetSignalCurColor(startSignalId); + startSignalPreDrvColor = GetSignalPreDriveColor(startSignalId); + + openCloseState = GetSignalOpenCloseState(startSignalCurColor); + + if ((SIGNAL_OPEN == openCloseState) && (startSignalCurColor != startSignalPreDrvColor)) + { + /*رյźŻδر*/ + return; + } + else if ((SIGNAL_OPEN == openCloseState) && (startSignalCurColor == startSignalPreDrvColor)) + { + /*źſ*/ + + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { + /*źؿЧ*/ + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_OPEN); /*-->*/ + + RouteLeadOpenManage(routeId);/*·Ź*/ + } + else + { + /*ź쳣*/ + /*xxxxx崻*/ + + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_SIGNAL, + startSignalId, + ETYPE_SYSTEM_SIGNAL_OPEN, + openCloseState, ESEND_LEVEL_ZERO); + + } + } + else + { + /*źŹر*/ + + } +} + + +/* +* ·Ź +* ˵ const UINT16 routeId, ·ID +* ֵ void +* ޸bug YF0083-100 +*/ +void RouteLeadOpenManage(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 judgeOccupy = 0u; /*жʼźŻⷽǷͬʱռѹ*/ + UINT8 sigOpenCloseState = 0u; /*źŻŹر״̬*/ + UINT8 phyCurMergState = 0u; /*εǰں״̬*/ + UINT16 phySecId = 0u; /*ID*/ + UINT8 driveRetVal = 0U; + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + +#if 0 + if (RouteSecFlockVainCheck(routeId) == CI_ERROR) + { + /*η*/ + DriveSignalClose(startSignalId); /*źŹر*/ + + SetRouteLeadFaultOpenStartCyc(routeId, 0u); /*ʱʱ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_LOCKERR); /*쳣*/ + + return; + } +#endif + + /*ʼźⷽͬʱռѹΪгʻ룻ע⣺ʻ־ֻ˽жϣгʻжϴڲ*/ + judgeOccupy = RouteInOutSecOccupy(routeId); + if (CI_SUCCESS == judgeOccupy) + { + SetRouteTrainEnterFlag(routeId, ROUTE_TRAIN_ENTER_FLAG_YES); + } + + sigOpenCloseState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId)); + if (SIGNAL_OPEN == sigOpenCloseState) + { /*źſ*/ + + /*ֿ·źŴ*/ + returnValue = KeepLeadRouteLogicProcess(routeId); + + if (CI_SUCCESS == returnValue) + { /*ֳɹ*/ + + phySecId = GetSignalInFirstPhySecId(startSignalId, routeId); + phyCurMergState = GetPhySecCurMergeState(phySecId); + if (SECTION_OCCUPY_NO == phyCurMergState) + {/*ڷһδռ*/ + + SetRouteLeadFaultOpenStartCyc(routeId, 0u); /*ʱʱ*/ + } + + DriveSignalOpen(startSignalId, routeId); /*·źſ*/ + } + else + { /*ʧ*/ + /*cgh-ϲCID-2539-4*/ + driveRetVal = DriveSignalClose(startSignalId); /*·źŹر*/ + if (CI_ERROR == driveRetVal) + { + /*źŹرʧ*/ + } + + SetRouteLeadFaultOpenStartCyc(routeId, 0u); /*ʱʱ*/ + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_LOCKERR); /*-->쳣*/ + } + } + else + { + /*źŹر*/ + + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_LOCKERR); /*-->쳣*/ + /*źŻϹرձadd by yt 2022422*/ + SetErrorData(EFUNC_CLD_OPEN_LEAD_ROUTE, CI_DEVICE_TYPE_SIGNAL, startSignalId, ETYPE_SIG_START_OPEN_STATE, SIGNAL_CLOSE, ESEND_LEVEL_ATS); + } +} + + +/* +* · +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 SetRouteProc(const UINT16 routeId) +{ + UINT8 routeType = 0U; /*·*/ + UINT8 routeLevel = 0U; /*·ල*/ + UINT8 returnValue = CI_ERROR; /*ֵ*/ + UINT8 chLocalCiType = 0U; /**/ + UINT8 chStopCheckState = 0U;/*ֹͣ־*/ + UINT8 chRouteState = 0U;/*·״̬*/ + + routeType = GetRouteType(routeId); /*ȡ·*/ + routeLevel = GetRouteLevel(routeId); /*ȡ·ල*/ + chLocalCiType = GetLocalCiType(); /*ȡ*/ + chRouteState = GetRouteState(routeId); + + /*by cgh 20230720 ϲ߽·*/ + if (ROUTE_TYPE_LIECHE == routeType) + { + /*г·*/ + if ((CI_TYPE_ZX == chLocalCiType) || (CI_TYPE_SCX == chLocalCiType)) + { + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + { + /*г·߼*/ + returnValue = SetRevrLTrainRouteLogicProcess(routeId); + } + else + { + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + + /*CBTCг·߼*/ + returnValue = SetCbtcLTrainRouteLogicProcess(routeId); + } + else + { + /*ʽг·߼*/ + returnValue = SetBlocLTrainRouteLogicProcess(routeId); + } + } + } + else if (CI_TYPE_CLD == chLocalCiType) + { + returnValue = SetLTrainRouteP(routeId); + } + else + { + ; /*ЧͲ*/ + } + } + else if (ROUTE_TYPE_RETURN == routeType) + { + /*۷·*/ + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + { + /*۷·߼*/ + returnValue = SetReverseRtnRouteLogicProcess(routeId); + } + else + { + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + + /*CBTC۷·߼*/ + returnValue = SetCbtcReturnRouteLogicProcess(routeId); + } + else + { + /*ʽ۷·߼*/ + returnValue = SetBlocReturnRouteLogicProcess(routeId); + } + } + + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { + if (ROUTE_STATE_IDLE == chRouteState) + { + /*·---·еһΰʱý·ֹͣ־*/ + chStopCheckState = GetStopCheckFlag(); + SetRouteStopFlagManage(routeId, chStopCheckState); + } + + returnValue = SetDTrainRouteP(routeId); + if (CI_ERROR == returnValue) + { + SetRouteStopFlagManage(routeId, ROUTE_STOPCHECK_SET_NO);/*·ֹͣ־*/ + } + + } + else + { + ; /*δ֪*/ + } + return returnValue; +} + + + + +/* +* ·ѡ-ȡԶźŽ· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 + CI_SUCCESS:ȡɹ + CI_ERROR:ȡʧ + RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT:ȴȡ +*/ +UINT8 RouteFirstXuanAutoSigProc(const UINT16 routeId) +{ + UINT8 i = 0u; + UINT8 waitFlag = 0u;/*ȴȡ־*/ + UINT8 succFlag = 1u;/*ɹȡ־*/ + UINT8 failFlag = 0u;/*ȡʧܱ־*/ + UINT8 retVal = CI_ERROR;/*ֵ*/ + UINT8 funcRetVal = CI_SUCCESS;/*ֵ*/ + UINT8 autoSigRouteIncludeSum = 0u; + UINT16* autoSigRouteIncludeIdBuf = NULL; + UINT8 localCiId = 0u; + UINT8 routeBelongCi = 0u; + UINT8 commState = 0u; + UINT8 routeCancleState = 0u; + UINT8 routeReverseProperty = 0u; + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + routeReverseProperty = GetRouteReverseProperty(routeId); + if (ROUTE_REVERSE_PROPERTY_NO == routeReverseProperty) + {/*߱*/ + succFlag = 1u; + } + else + { + autoSigRouteIncludeSum = GetReverseRouteIncludeRouteSum(routeId);/*ȡ·ԶźŽ·*/ + autoSigRouteIncludeIdBuf = GetReverseRouteIncludeRouteBuf(routeId);/*ȡ·ԶźŽ·Id*/ + for (i = 0u; i < autoSigRouteIncludeSum; i++) + { + /*ȡԶź*/ + routeBelongCi = GetRouteBelongCiId(autoSigRouteIncludeIdBuf[i]); + + if (localCiId == routeBelongCi) + { + /*ԶźʧЧ*/ + (void)SetRouteAutoSigLoseEfficacyFlag(autoSigRouteIncludeIdBuf[i], ROUTE_AUTOSIG_LOSE_REVSET_YES); + funcRetVal = AutoSigRouteQuXiaoProc(autoSigRouteIncludeIdBuf[i]);/*ȡԶźŽ·*/ + } + else + { + /*ȡͨ״̬*/ + commState = GetLocalCiAndOtherCiTransSta(routeBelongCi); + /*ͨ״̬*/ + if (TRANSMIT_STATE_GOOD == commState) + { + /*Զźûȡȡ*/ + routeCancleState = GetAutoSigCancleState(autoSigRouteIncludeIdBuf[i]); + /*Ч*/ + if (AUTO_ROUTE_CANCLE_NO == routeCancleState) + { + /**/ + AddCiSendToCiCmdInfo(CI_CMD_AUTO_SIG_ROUTE_CANCLE, autoSigRouteIncludeIdBuf[i], 0, routeBelongCi); + funcRetVal = RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT; + } + /*ȡȴ*/ + else if (AUTO_ROUTE_CANCLE_WAIT == routeCancleState) + { + funcRetVal = RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT; + } + /*ȡɹ*/ + else if (AUTO_ROUTE_CANCLE_SUCCESS == routeCancleState) + { + funcRetVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + funcRetVal = CI_ERROR; + } + } + else + { + /*ʧ*/ + funcRetVal = CI_ERROR; + } + } + if (CI_SUCCESS == funcRetVal) + {/*ԶźŽ·ȡɹ*/ + succFlag = 1u; + } + else if (CI_ERROR == funcRetVal) + {/*ԶźŽ·ȡʧ*/ + failFlag = 1u; + } + else if (RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT == funcRetVal) + {/*ȴȡԶźŽ·*/ + waitFlag = 1u; + } + else + { + /**/ + } + } + } + + if (1u == failFlag) + {/*һԶźŽ·ȡʧܣ򷵻ʧ*/ + retVal = CI_ERROR; + } + else if (1u == waitFlag) + {/*һԶźŽ·ȴȡ򷵻صȴ*/ + retVal = RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT; + } + else if ((0u == failFlag) && (0u == waitFlag) && (1u == succFlag)) + {/*Զźȫȡɹ*/ + retVal = CI_SUCCESS; + } + else + { + /*޲*/ + } + + return retVal; +} + + + +/* +* ս· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 LockRouteProc(const UINT16 routeId) +{ + UINT8 routeType = 0U; /*·*/ + UINT8 routeLevel = 0U; /*·ල*/ + UINT8 returnValue = CI_ERROR; /*ֵ*/ + UINT8 chLocalCIType = 0U;/**/ + + routeType = GetRouteType(routeId); /*ȡ·*/ + routeLevel = GetRouteLevel(routeId); /*ȡ·ල*/ + chLocalCIType = GetLocalCiType(); + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + if ((CI_TYPE_ZX == chLocalCIType) || (CI_TYPE_SCX == chLocalCIType)) + { + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + + /*CBTCг·߼*/ + returnValue = LockCbtcLTrainRouteLogicProcess(routeId); + } + else + { + /*յʽг·߼*/ + returnValue = LockBlocLTrainRouteLogicProcess(routeId); + } + } + else if (CI_TYPE_CLD == chLocalCIType) + { + returnValue = LockLTrainRouteP(routeId); + } + else + { + ; /*ЧͲ*/ + } + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + returnValue = LockDTrainRouteP(routeId); + } + else if (ROUTE_TYPE_RETURN == routeType) + { + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + + /*CBTC۷·߼*/ + returnValue = LockCbtcReturnRouteLogicProcess(routeId); + } + else + { + /*յʽ۷·߼*/ + returnValue = LockBlocReturnRouteLogicProcess(routeId); + } + } + else + { + ; /*δ֪*/ + } + return returnValue; +} + +/* +* ATSս·Overlap +* ˵const UINT16 routeId, ·ID +* const UINT16 expLkOverlapId, ձID +* ֵ0 ʧ +* 1 ɹ +* 0x22 λô +* 0x30 ȴ +* 0x31 ȴ +*/ +UINT8 LockRouteOverlapAccdToAtsCmd(const UINT16 routeId, const UINT16 expLkOverlapId) +{/*·ΪFAOHLHTҽ·ձIDЧ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 retValue = CI_ERROR; /*ֵ*/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 devPreState = 0u; /*豸ǰһ״̬*/ + UINT8 overlapCurOccuState = 0u; /*εǰռ״̬*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT32 cycNum = Get2oo2CurCycleNum(); + UINT16 wOverlapLockRouteId = 0U;/*·*/ + UINT32 dwXuanpaiStartCycNum = 0U; /*εѡʼ*/ + UINT8 cTimeCheckFlag = CI_TIME_OUT; + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if (ROUTE_OVERLAP_SET_YES == GetRouteOverlapLockFlag(routeId)) + { /*·չسɹ*/ + retValue = CI_SUCCESS; + } + else + {/*·δչִ*/ + if (GetOverlapBelongCiId(expLkOverlapId) == localCiId) + { + /*ڱ*/ + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecCurOccupyState(devId); + devPreState = GetPhySecPreOccupyState(devId); + overlapCurOccuState = GetPhySecCurOccupyState(GetRouteLeavePhySecId(routeId)); + routeState = GetRouteState(routeId); + if ((SECTION_OCCUPY_NO == devState) && + (SECTION_OCCUPY_YES == devPreState) && + (SECTION_OCCUPY_NO == overlapCurOccuState) && + (PHYSICAL_SECTION_LOCK_NORMAL == GetPhySecLockState(devId)) && + (ROUTE_STATE_AUTO_UNLOCK == routeState) && + (GetSystemParaLocalCiId() != GetRouteBelongCiId(routeId)) + ) + { + SetProtectSecLockDelayTimeFlag(devId, PROTECTSECLOCKDELAY_YES); + SetPhySecLockDelayStartCycNum(devId, cycNum); /*ʱں*/ + } + + if (PROTECTSECLOCKDELAY_NO == GetProtectSecLockDelayTimeFlag(devId)) + { + /*ս·Overlap*/ + retValue = LockRouteOverlapLogicProcess(routeId, expLkOverlapId, ATS_LOCK_OVERLAP); + } + else if (((Get2oo2CurCycleNum() - GetPhySecLockDelayStartCycNum(devId)) > GetCiAndCiTransBadEnsureCnt()) + && (PROTECTSECLOCKDELAY_YES == GetProtectSecLockDelayTimeFlag(devId))) + { /*־óʱ־*/ + SetProtectSecLockDelayTimeFlag(devId, PROTECTSECLOCKDELAY_NO); + SetPhySecLockDelayStartCycNum(devId, 0); /*ʱں*/ + /*ս·Overlap*/ + retValue = LockRouteOverlapLogicProcess(routeId, expLkOverlapId, ATS_LOCK_OVERLAP); + } + else + { + /*δʱκβ*/ + retValue = CI_ERROR; + } + + if (CI_SUCCESS == retValue) + { /*ճɹ*/ + + /*Ϊ˽βظ·ʱڶ·ձǰһ·չıID + ڶյһ·ʱ޷*/ + wOverlapLockRouteId = GetOverlapBelongRouteId(expLkOverlapId); + if (0U < wOverlapLockRouteId) + { + SetRouteOverlapLockedId(wOverlapLockRouteId,0U); + } + else + { + ; /*Ϊ0*/ + } + + SetOverlapLockState(expLkOverlapId, PHYSICAL_SECTION_LOCK_PROTECT, routeId); /*Overlap*/ + + /*ñаĵý*/ + SetOverlapRelSwitchUsing(expLkOverlapId, SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(expLkOverlapId, 0); + SetOverlapProSwtCheckStartFlag(expLkOverlapId, PROSWITCH_CHECK_START_INVALID); /*ճɹ÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(expLkOverlapId, PROSWITCH_CHECK_RESULT_DEFAULT); /*ճɹ÷־ΪĬֵ*/ + SetOverlaplockSucessStartCycNum(expLkOverlapId, cycNum);/*ʼ*/ + } + else if (RETURN_WAIT_SWITCH_USING == retValue) + { + /*δãõ*/ + SetOverlapRelSwitchUsing(expLkOverlapId, SWITCH_USING_YES); + SetOverlapXuanPaiStartCycNum(expLkOverlapId, cycNum); + dwXuanpaiStartCycNum = GetOverlapXuanPaiStartCycNum(expLkOverlapId); + cTimeCheckFlag = SystemOverTimeCheck(dwXuanpaiStartCycNum, OVERLAP_USING_OVERTIME_CYC_NUM); /*Ƿʱ*/ + if (CI_TIME_OUT == cTimeCheckFlag) + { + /*óʱ*/ + SetOverlapRelSwitchUsing(expLkOverlapId, SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(expLkOverlapId, 0U); + retValue = CI_ERROR; + } + else + { + retValue = RETURN_WAIT_SWITCH_USING; + } + } + else if (RETURN_WAIT_SWITCH_CHECK == retValue) + { + /*üͨ÷鿪ʼ־Ϊʼ*/ + SetOverlapProSwtCheckStartFlag(expLkOverlapId, PROSWITCH_CHECK_START_VALID); + retValue = RETURN_WAIT_SWITCH_CHECK; + } + else if (RETURN_LOCK_ERR_SWITPOS == retValue) + { + SetOverlapRelSwitchUsing(expLkOverlapId, SWITCH_USING_YES); + SetOverlapXuanPaiStartCycNum(expLkOverlapId, cycNum); + retValue = ChekSwitDrivOvtm(expLkOverlapId); /*ҪʱǷʱ*/ + if (CI_SUCCESS == retValue) + { + /*overlap*/ + if (CI_ERROR == OverlapLockDriveSwitch(expLkOverlapId)) + { + /*β ȡ*/ + SetOverlapRelSwitchUsing(expLkOverlapId, SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(expLkOverlapId, 0U); + SetOverlapProSwtCheckStartFlag(expLkOverlapId, PROSWITCH_CHECK_START_INVALID); /*ʧܣ÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(expLkOverlapId, PROSWITCH_CHECK_RESULT_DEFAULT); /*ʧܣ÷־ΪĬֵ*/ + retValue = CI_ERROR; + } + else + { + retValue = RETURN_LOCK_ERR_SWITPOS; + } + } + else + { + /*ʱ ȡ*/ + SetOverlapRelSwitchUsing(expLkOverlapId, SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(expLkOverlapId, 0u); + SetOverlapProSwtCheckStartFlag(expLkOverlapId, PROSWITCH_CHECK_START_INVALID); /*ʱ÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(expLkOverlapId, PROSWITCH_CHECK_RESULT_DEFAULT); /*ʱ÷־ΪĬֵ*/ + SetErrorData(EFUNC_SWITCH_DRIVE_OUTTIME, CI_DEVICE_TYPE_SWITCH, expLkOverlapId, CI_DEVICE_TYPE_OVERLAP, SWITCH_POSITION_INVALID, ESEND_LEVEL_ZERO); + retValue = CI_ERROR; + SetRouteAtsExpLkOverlapId(routeId, 0u); /*ATSֵձID*/ + SetOverlapFromSetRouteCmdFlag(expLkOverlapId, OVERLAP_ROUTE_FLAG_NO);/*νɽ··־*/ + } + } + else + { + /*ռ鲻㣬ã򱣻εãұ޷գ½·޷*/ + SetOverlapRelSwitchUsing(expLkOverlapId, SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(expLkOverlapId, 0U); + SetOverlapProSwtCheckStartFlag(expLkOverlapId, PROSWITCH_CHECK_START_INVALID); /*ռ鲻㣬÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(expLkOverlapId, PROSWITCH_CHECK_RESULT_DEFAULT); /*ռ鲻㣬÷־ΪĬֵ*/ + retValue = CI_ERROR; + } + } + } + + return retValue; +} + +/* +* ·Overlap +* ˵const UINT16 routeId, ·ID +* ֵ0 ʧ +* 1 ɹ +* 0x22 λô +* 0x30 ȴ +* 0x31 ȴ +*/ +UINT8 LockRouteOverlapProc(const UINT16 routeId) +{ + UINT8 const localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + UINT8 returnValue = CI_ERROR; /*ֵ*/ + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + UINT8 ii = 0u; + UINT32 thisOverlapCycNum = 0u; + UINT8 cRouteOverlapLockFlag = ROUTE_OVERLAP_SET_NO; /*·ձ־*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 devPreState = 0u; /*豸ǰһ״̬*/ + UINT8 overlapState = 0u; /*״̬*/ + UINT8 routeState = 0u; + UINT16 wOverlapLockRouteId = 0U;/*·*/ + UINT32 dwCurCycNum = 0u; + UINT32 dwXuanPaiStartCycNum = 0U; /*εѡʼ*/ + UINT8 cTimeCheckFlag = CI_TIME_OUT; + UINT8 cKeepWorkFlag = CI_ERROR; + + overlapSum = GetRouteOverlapSum(routeId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(routeId); /*ȡOverlap ID BUF*/ + dwCurCycNum = Get2oo2CurCycleNum(); + cRouteOverlapLockFlag = GetRouteOverlapLockFlag(routeId); + if ((NULL == overlapIdBuf) || (ROUTE_OVERLAP_SET_YES == cRouteOverlapLockFlag)) + { + returnValue = CI_SUCCESS; /*ûбλ·չسɹ*/ + } + else + { + /*ֱյı*/ + cKeepWorkFlag = CI_SUCCESS; + for (ii = 0u; ii < overlapSum; ii++) + { + if (GetOverlapBelongCiId(overlapIdBuf[ii]) == localCiId) + { + /*ڱ*/ + + /* + *⣺ + * ijһ·˽·ıDZġгռѹһκ󣬱ıԶʱϡ + * ַɳ󣬽·һͻȻΪУʾΪ̹ʱδյԷĽ·һ + * 쳣Ϣά״̬ȻΪաʱֻԶձΣⲻʣΪ׷ж + * ձε + * Դ: νһʧȥг··״̬жϳ쳣ڱ + * ԸĽ·״̬Զ״̬ڷմȻ㣬˽ա + * 򲹶˼: 쳣ڱմմУȽ쳣״̬Ԥд + * Ԥгñ־λշΡ£߼ + * + * ԤжΪ + * ·һεǰδռã &&·һǰһ״̬Ϊռã &&εǰδռã &&·һεǰ״̬Ϊգ& (·״̬Զ״̬) + * ʱһ־ձҪ˱־ + * ָ־ʱΪ + * յԷĽ·һ쳣Ϣ󣬻ָ־ + * ³ֵ龰: + :CI1 CI5 + CI1·Z3-CD1·гռѹһZHG󣬱JK1GʱַɳZHGͻȻУJK1G + */ + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecCurOccupyState(devId); + devPreState = GetPhySecPreOccupyState(devId); + overlapState = GetPhySecCurOccupyState(GetRouteLeavePhySecId(routeId)); + routeState = GetRouteState(routeId); + if ((SECTION_OCCUPY_NO == devState) && + (SECTION_OCCUPY_YES == devPreState) && + (SECTION_OCCUPY_NO == overlapState) && + (PHYSICAL_SECTION_LOCK_NORMAL == GetPhySecLockState(devId)) && + (ROUTE_STATE_AUTO_UNLOCK == routeState) && + (GetSystemParaLocalCiId() != GetRouteBelongCiId(routeId)) + ) + { + SetProtectSecLockDelayTimeFlag(devId, PROTECTSECLOCKDELAY_YES); + SetPhySecLockDelayStartCycNum(devId, Get2oo2CurCycleNum()); /*ʱں*/ + } + else + { + ; + } + + if (PROTECTSECLOCKDELAY_NO == GetProtectSecLockDelayTimeFlag(devId)) + { + /*ս·Overlap*/ + returnValue = LockRouteOverlapLogicProcess(routeId, overlapIdBuf[ii], CI_LOCK_OVERLAP); + } + else if (((Get2oo2CurCycleNum() - GetPhySecLockDelayStartCycNum(devId)) > GetCiAndCiTransBadEnsureCnt()) + && (PROTECTSECLOCKDELAY_YES == GetProtectSecLockDelayTimeFlag(devId))) + { /*־óʱ־*/ + SetProtectSecLockDelayTimeFlag(devId, PROTECTSECLOCKDELAY_NO); + SetPhySecLockDelayStartCycNum(devId, 0); /*ʱں*/ + /*ս·Overlap*/ + returnValue = LockRouteOverlapLogicProcess(routeId, overlapIdBuf[ii], CI_LOCK_OVERLAP); + } + else + { + /*δʱκβ*/ + returnValue = CI_ERROR; + } + + if (CI_SUCCESS == returnValue) + { /*ճɹ*/ + + /*Ϊ˽βظ·ʱڶ·ձǰһ·չıID + ڶյһ·ʱ޷*/ + wOverlapLockRouteId = GetOverlapBelongRouteId(overlapIdBuf[ii]); + if (0U < wOverlapLockRouteId) + { + SetRouteOverlapLockedId(wOverlapLockRouteId, 0U); + } + else + { + ; /*Ϊ0*/ + } + + SetOverlapLockState(overlapIdBuf[ii], PHYSICAL_SECTION_LOCK_PROTECT, routeId); /*Overlap*/ + + /*ñаĵý*/ + SetOverlapRelSwitchUsing(overlapIdBuf[ii], SWITCH_USING_NO); /*ճɹ*/ + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], 0u); /*ճɹѡʼ*/ + SetOverlapProSwtCheckStartFlag(overlapIdBuf[ii], PROSWITCH_CHECK_START_INVALID); /*ճɹ÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(overlapIdBuf[ii], PROSWITCH_CHECK_RESULT_DEFAULT); /*ճɹ־ΪĬֵ*/ + cKeepWorkFlag = CI_ERROR; /*ֹͣ*/ + returnValue = CI_SUCCESS; + } + else if (RETURN_WAIT_SWITCH_USING == returnValue) + { + /*δãõ*/ + SetOverlapRelSwitchUsing(overlapIdBuf[ii], SWITCH_USING_YES); + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], dwCurCycNum); + dwXuanPaiStartCycNum = GetOverlapXuanPaiStartCycNum(overlapIdBuf[ii]); + cTimeCheckFlag = SystemOverTimeCheck(dwXuanPaiStartCycNum, OVERLAP_USING_OVERTIME_CYC_NUM); /*Ƿʱ*/ + if (CI_TIME_OUT == cTimeCheckFlag) + { + /*óʱ*/ + SetOverlapRelSwitchUsing(overlapIdBuf[ii], SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], 0U); + returnValue = CI_ERROR; + } + else + { + returnValue = RETURN_WAIT_SWITCH_USING; + } + cKeepWorkFlag = CI_ERROR; /*ֹͣ*/ + } + else if (RETURN_WAIT_SWITCH_CHECK == returnValue) + { + /*üͨ÷鿪ʼ־Ϊʼ*/ + SetOverlapProSwtCheckStartFlag(overlapIdBuf[ii], PROSWITCH_CHECK_START_VALID); /*ñη鿪ʼ־Ϊ鿪ʼδ*/ + cKeepWorkFlag = CI_ERROR; /*ֹͣ*/ + returnValue = RETURN_WAIT_SWITCH_CHECK; + } + else if (RETURN_LOCK_ERR_SWITPOS == returnValue) + { + SetOverlapRelSwitchUsing(overlapIdBuf[ii], SWITCH_USING_YES); + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], dwCurCycNum); + returnValue = ChekSwitDrivOvtm(overlapIdBuf[ii]); /*ҪʱǷʱ*/ + if (CI_SUCCESS == returnValue) + { + /*overlap*/ + if (CI_ERROR == OverlapLockDriveSwitch(overlapIdBuf[ii])) + { + /*β ȡ*/ + SetOverlapRelSwitchUsing(overlapIdBuf[ii], SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], 0U); + SetOverlapProSwtCheckStartFlag(overlapIdBuf[ii], PROSWITCH_CHECK_START_INVALID); /*ʧܣ÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(overlapIdBuf[ii], PROSWITCH_CHECK_RESULT_DEFAULT); /*ʧܣ÷־ΪĬֵ*/ + returnValue = CI_ERROR; + } + else + { + returnValue = RETURN_LOCK_ERR_SWITPOS; + } + } + else + { + /*ʱ ȡ*/ + SetOverlapRelSwitchUsing(overlapIdBuf[ii], SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], 0U); + SetOverlapProSwtCheckStartFlag(overlapIdBuf[ii], PROSWITCH_CHECK_START_INVALID); /*ʱ÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(overlapIdBuf[ii], PROSWITCH_CHECK_RESULT_DEFAULT); /*ʱ÷־ΪĬֵ*/ + SetErrorData(EFUNC_SWITCH_DRIVE_OUTTIME, CI_DEVICE_TYPE_SWITCH, overlapIdBuf[ii], CI_DEVICE_TYPE_OVERLAP, SWITCH_POSITION_INVALID, ESEND_LEVEL_ZERO); + returnValue = CI_ERROR; + } + cKeepWorkFlag = CI_ERROR; /*ֹͣ*/ + } + else + { + /*λʧܣԴҪλ*/ + thisOverlapCycNum = GetOverlapXuanPaiStartCycNum(overlapIdBuf[ii]); + if (thisOverlapCycNum != 0U) + { + SetOverlapRelSwitchUsing(overlapIdBuf[ii], SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], 0U); + SetOverlapProSwtCheckStartFlag(overlapIdBuf[ii], PROSWITCH_CHECK_START_INVALID); /*ռʧܣ÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(overlapIdBuf[ii], PROSWITCH_CHECK_RESULT_DEFAULT); /*ռʧܣ÷־ΪĬֵ*/ + cKeepWorkFlag = CI_ERROR; /*λùΪʱٳմҪλ*/ + returnValue = CI_ERROR; + } + } + } + else + { + ; + } + + if (CI_ERROR == cKeepWorkFlag) + { + break; + } + else + { + /*Σռ*/ + } + } + } + + return returnValue; +} + +/* +ձι +UINT8 overlapIdSum +UINT16 * pOverlapIdBuf IDָ +UINT8 PLockDirect շ + +CI_SUCCESS ɹ +CI_ERROR ʧ + +*/ +UINT8 LockLocalOvlpManageHlht(UINT8 overlapSum, UINT16* pOverlapIdBuf, UINT8 PLockDirect) +{ + UINT8 const localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 ii = 0u; + + if ((0u == overlapSum) || (NULL == pOverlapIdBuf)) + { + /*ûб*/ + return CI_SUCCESS; + } + + /*ձδ*/ + /*ֱյı*/ + for (ii = 0u; ii < overlapSum; ii++) + { + if (GetOverlapBelongCiId(pOverlapIdBuf[ii]) == localCiId) + { + /*ս·Overlap*/ + returnValue = LockLocalOvlpCheckHlht(pOverlapIdBuf[ii], PLockDirect); + + if (CI_SUCCESS == returnValue) + { /*ճɹ*/ + + SetOvlpLockStateForHlhtCi(pOverlapIdBuf[ii], PHYSICAL_SECTION_LOCK_PROTECT, PLockDirect); /*Overlap*/ + + return CI_SUCCESS; + } + else if (RETURN_LOCK_ERR_SWITPOS == returnValue) + { + /*overlap*/ + if (CI_ERROR == OverlapLockDriveSwitch(pOverlapIdBuf[ii])) + { + return CI_ERROR; + } + else + { + return RETURN_LOCK_ERR_SWITPOS; + } + } + else + { + /*ʧ*/ + } + } + } + return CI_ERROR; +} + + +/* +* Ž·źŴ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 OpenRouteSignalProc(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 routeLevel = 0u; /*·ල*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 errType = CI_ERROR;/*ʧʱĴ*/ + UINT8 recoverState = ROUTE_RECOVER_STA_STAY;/*ǰָؿ״̬*/ + UINT8 routeState = 0u;/*·״̬*/ + UINT32 curCycle = 0u;/*ǰ*/ + UINT8 needOpenNotTrueRepeatFlag = ROUTE_NEEDOPEN_REOPEN_NO;/*迪δ㣬ؿ־*/ + UINT32 needOpenRepeatStartCount = 0u;/*迪δ㣬ؿʼ*/ + UINT32 sysparaRepeatCount = 0u;/*ϵͳؿά*/ + UINT8 routeTimeState = CI_TIME_NO; + UINT32 dwDelayOpenStartCyc = 0U; /*ⱨʱʼ*/ + UINT32 dwDelayOpenCycNum = 0U; /*ⱨʱ*/ + UINT8 cRouteCanOpenFlag = CI_ERROR; /*·ɿű־*/ + UINT32 dwRouteSigOpenStartCyc = 0U; /*·źſʼ*/ + + routeType = GetRouteType(routeId); /*ȡ·*/ + routeLevel = GetRouteLevel(routeId); /*ȡ·ල*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + routeState = GetRouteState(routeId); + curCycle = Get2oo2CurCycleNum(); + + + if (CI_SUCCESS == AutoSignalOrRouteValid(routeId)) + { + /*ԶźŻԶ·Զÿʱ*/ + SetRouteOpenSigStartCycNum(routeId, Get2oo2CurCycleNum()); +#if 0 + SetOverlapLockStartCycNum(routeId,Get2oo2CurCycleNum()); /*ԶźĿǰɾμ*/ +#endif + } + + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + + returnValue = OpenCbtcLTrainRouteLogicProcess(routeId); /*CBTCг·*/ + errType = OpenCbtcLTrainRouteErrProcess(routeId, OPEN_CHECK_STEP_OPEN);/*ʧԭ*/ + } + else + { /*ʽ*/ + + returnValue = OpenBlocLTrainRouteLogicProcess(routeId); /*ŵʽг·*/ + errType = OpenBlocLTrainRouteErrProcess(routeId);/*ʧԭ*/ + } + + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + {/*·*/ + returnValue = OpenDTrainRouteP(routeId); /*ŵ·*/ + errType = OpenDTrainRouteErrP(routeId, OPEN_CHECK_STEP_OPEN); /*ʧԭ*/ + } + else if (ROUTE_TYPE_RETURN == routeType) + { /*۷·*/ + + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + + returnValue = OpenCbtcReturnRouteLogicProcess(routeId); /*CBTC۷·*/ + errType = OpenCbtcReturnRouteErrProcess(routeId, OPEN_CHECK_STEP_OPEN);/*ʧԭ*/ + } + else + { /*ʽ*/ + + returnValue = OpenBlocReturnRouteLogicProcess(routeId); /*ŵʽ۷·*/ + errType = OpenBlocReturnRouteErrProcess(routeId);/*ʧԭ*/ + } + } + else + {/**/ + } + + dwDelayOpenStartCyc = GetRouteDelayOpenStartCyc(routeId); /*ȡ·ⱨʱʼں*/ + dwDelayOpenCycNum = GetSGBJRouteDelayOpenCount(); + routeTimeState = SystemOverTimeCheck(dwDelayOpenStartCyc, dwDelayOpenCycNum); + + if ((CI_TIME_OUT == routeTimeState) || (CI_TIME_NO == routeTimeState)) + { + dwRouteSigOpenStartCyc = GetRouteOpenSigStatrtCycNum(routeId); + if (0U == dwRouteSigOpenStartCyc) + { + SetRouteOpenSigStartCycNum(routeId, curCycle); /*ⱨʱ½·źſʱδã˴ý·źſʱΪǰ*/ + } + else + { + /*·źſʼã*/ + } + + SetRouteDelayOpenStartCyc(routeId, 0U); /*ⱨʱʼں*/ + cRouteCanOpenFlag = CI_SUCCESS; + } + else + { + /*ʱУ*/ + } + + /*ݿźŷֵ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + if (CI_SUCCESS == cRouteCanOpenFlag) + { + DriveSignalOpen(startSignalId, routeId); /*źſ*/ + + /*㿪Ҳ·ָ״̬һν·״̬ת*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_INIT); + } + else + { + /*ȴʱź*/ + } + + returnValue = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_SIGOPEN == returnValue) + { /*رźδر*/ + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + returnValue = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_NEEDOPEN == returnValue) + {/*迪Ų*/ + (void) DriveSignalClose(startSignalId); + + if (ROUTE_STATE_FIRST_LOCK == routeState/**/) + { + /*ؿ־δŲؿʼʱ*/ + /*жг·迪źŻΪźŻҹر*/ + if (ROUTE_TYPE_LIECHE == routeType) + { + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_YES); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, curCycle); + } + else + { + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + } + } + else if (ROUTE_STATE_FIRST_LOCKERR == routeState/*쳣*/) + { + /*ȡؿ־*/ + /*鳬ʱ*/ + needOpenNotTrueRepeatFlag = GetRouteNeedOpenReopenFlag(routeId); + needOpenRepeatStartCount = GetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId); + sysparaRepeatCount = GetSystemParaRouteOpenSigCyc();/*迪ŵȴʱý·źſʱ*/ + if ((ROUTE_NEEDOPEN_REOPEN_YES == needOpenNotTrueRepeatFlag) && (0U < needOpenRepeatStartCount)) + { + /*鳬ʱʱ־*/ + /* źʱ״̬*/ + routeTimeState = SystemOverTimeCheck(needOpenRepeatStartCount, sysparaRepeatCount); + if (CI_TIME_OUT == routeTimeState)/*ʱ*/ + { + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + } + else if (CI_TIME_NO == routeTimeState)/*δʱ*/ + { + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + } + else if (CI_TIME_IN == routeTimeState)/*ʱ*/ + { + /*ؿ*/ + } + else + { + /*Ƿ*/ + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + } + /*Ϊڿ迪ŲʱԶؿУԣźԶؿ־ظ*/ + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + SetRouteOpenSigStartCycNum(routeId, 0); /*źſʱ*/ + } + else + { + /*迪Ųؿ־Ϊؿжźؿʧܣ˺ڽźؿж*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + } + } + else + { + /*迪Ųؿ־Ϊؿжźؿʧܣ˺ڽźؿж*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + } + returnValue = CI_ERROR; + } + else if (RELAY_STATE_WAITE == returnValue) + { + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + returnValue = CI_SUCCESS; /*ȴ*/ + } + else + { /*ʧ*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId, ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId, 0); + + if (CI_ROUTE_RECOVER_ERR == errType) + { + recoverState = GetRouteRecoverOpenFlag(routeId); + + if ((ROUTE_RECOVER_STA_INIT == recoverState) || (ROUTE_RECOVER_STA_WAIT == recoverState)) + { + /*·֮ǰڿɻָ״ֿ̬ɻָ״̬ȴָ*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_WAIT); + } + else + { + /*·֮ǰѾڲɻָ״ֲ̬ɻָ״ֹ̬ؿʹ·߱˻ָؿ*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY); + } + } + else + { + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY);/*һ㣬·䲻߱Զؿ*/ + } + + returnValue = CI_ERROR; + } + + return returnValue; +} + + +/* +* ֿŽ·źŴ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 KeepOpenRouteSignalProc(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 routeLevel = 0u; /*·ල*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 errType = CI_ERROR;/*ʧʱĴ*/ + UINT8 ciType = 0u; + UINT16 outPhySecId = 0u; /*źŻⷽһID*/ + UINT16 inPhySecId = 0u; /*źŻڷһID*/ + UINT8 inPhySecCurMergeState = 0U; + UINT8 inPhySecPreMergeState = 0U; + UINT8 outPhySecCurMergeState = 0U; + + routeType = GetRouteType(routeId); /*ȡ·*/ + routeLevel = GetRouteLevel(routeId); /*ȡ·ල*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + inPhySecId = GetSignalInFirstPhySecId(startSignalId, routeId); /*źŻڷһID*/ + outPhySecId = GetSignalOutFirstPhySecId(startSignalId); /*źŻⷽһID*/ + +#if 0 + if (RouteSecFlockVainCheck(routeId) == CI_ERROR || + RouteOverlapSecFlockVainCheck == CI_ERROR) + { + /*η*/ + DriveSignalClose(startSignalId); /*źŹر*/ + + return CI_ERROR; + } +#endif + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + + returnValue = KeepCbtcLTrainRouteLogicProcess(routeId); /*CBTCг·*/ + errType = KeepCbtcLTrainRouteErrProcess(routeId);/*ʧԭ*/ + } + else + { /*ʽ*/ + + returnValue = KeepBlocLTrainRouteLogicProcess(routeId); /*ֵʽг·*/ + errType = KeepBlocLTrainRouteErrProcess(routeId);/*ʧԭ*/ + } + + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { + returnValue = KeepDTrainRouteP(routeId); /*ֵ·ź*/ + errType = KeepDTrainRouteErrP(routeId);/*ʧԭ*/ + inPhySecCurMergeState = GetPhySecCurMergeState(inPhySecId); + inPhySecPreMergeState = GetPhySecPreMergeState(inPhySecId); + outPhySecCurMergeState = GetPhySecCurMergeState(outPhySecId); + /*жгʻ:ڷһεǰռ && ֮ǰУ && ʼźŻⷽһεǰռ*/ + if ((SECTION_OCCUPY_YES == inPhySecCurMergeState) && (SECTION_OCCUPY_NO == inPhySecPreMergeState)) + { + if ((0U == outPhySecId) || (SECTION_OCCUPY_YES == outPhySecCurMergeState)) + { + SetTrainEnterRouteFlag(routeId, TRAIN_ENTER_ROUTE_FLAG_YES); + } + } + } + else if (ROUTE_TYPE_RETURN == routeType) + { /*۷·*/ + + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + + returnValue = KeepCbtcReturnRouteLogicProcess(routeId); /*CBTC۷·*/ + errType = KeepCbtcReturnRouteErrProcess(routeId);/*ʧԭ*/ + } + else + { /*ʽ*/ + + returnValue = KeepBlocReturnRouteLogicProcess(routeId); /*ֵʽ۷·*/ + errType = KeepBlocReturnRouteErrProcess(routeId);/*ʧԭ*/ + } + } + else + {/**/ + } + + /*ݿźŷֵ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + (void)DriveSignalOpen(startSignalId, routeId); /*źſ*/ + + return CI_SUCCESS; + } + else + { /*ʧ*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + if (CI_ROUTE_RECOVER_ERR == errType) + { + /*·Ϊָؿص޷ֿţý·߱ȴָ*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_WAIT); + } + else + { + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY); + } + + return CI_ERROR; + } +} + + +/* +* ·ȡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongQuXiaoProc(const UINT16 routeId) +{ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 startSignalId = 0u; + UINT8 sigCurColor = SIGNAL_SHOWCOLOUR_INVALID; + UINT8 routeDelayUnlockflag = 0u; /* ·ʱ*/ + UINT8 checkRouteCancel = 0u; + UINT8 cSignalInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO; /*źŻʪ־*/ + + /*ȡ·ֶ̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + startSignalId = GetRouteStartSignalId(routeId); + sigCurColor = GetSignalCurColor(startSignalId); + + if (GetSignalOpenCloseState(sigCurColor) == SIGNAL_OPEN) + { + /*źδر*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + return; + } + else + { + /*źѹر*/ + + SetRouteZongQuXiaoFlag(routeId, ROUTE_ZONGQUXIAO_SET_NO); /*ȡ·ȡ־*/ + } + + cSignalInHumidRailFlag = GetSignalInHumidRailFlag(startSignalId); + if (PHYSEC_IN_HUMID_RAIL_NO == cSignalInHumidRailFlag) + { + /*ȡ·*/ + if ((ROUTE_STATE_XUANPAI == routeState) || (ROUTE_STATE_FIRST_XUANPAI == routeState)) + { + /*·ѡŻѡ*/ + + /*ȡ·ѡ*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + } + /*·||·쳣||·Ԥ*/ + else if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState)) + { + /* ȡ*/ + checkRouteCancel = RouteCancelLogicProcess(routeId); + /* ȡ·ʱ*/ + routeDelayUnlockflag = GetRouteNeedDelayUnlock(routeId); + if (CI_SUCCESS == checkRouteCancel) + { + /*Ҫʱ*/ + if (ROUTE_NEED_DELAY_UNLOCK == routeDelayUnlockflag) + { + /*ý·ʱ״̬*/ + SetRouteStateManage(routeId, ROUTE_STATE_DELAY_UNLOCK); + /*ʱ*/ + SetRouteZongQuXiaoDelayFlag(routeId, ROUTE_ZQX_DELAY_YES); + } + else + { + /*-->ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + } + } + else + { + /*·ȡ*/ + } + } + else if ((ROUTE_STATE_NEAR_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState)) + { + /*ӽ*/ + SetCiSendCmdBackInfoData(CI_BACK_ROUTE_NEAR_LOCK_YES, CI_DEVICE_TYPE_ROUTE, routeId, 0u, 0u); + } + else if ((ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_FIRST_XUANPAI == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState) || + (ROUTE_STATE_LEAD_XUANPAI == routeState)) + { + /*·ȡϢ*/ + } + else if (ROUTE_STATE_IDLE == routeState) + { + CancelLongRouteXuanPai(routeId); /*޸ȱYF0083-2370ȡʱ·Уȡ·ѡ*/ + } + else + { + /*δ*/ + SetCiSendCmdBackInfoData(CI_BACK_ROUTE_LOCK_NOTALL, CI_DEVICE_TYPE_ROUTE, routeId, 0u, 0u); + } + } + else + { + /*·ʼźŻʪ췶Χ·*/ + debug_infor_printf((const)"\n SignalInHumidRailFlag Valid,Not RouteZongQuXiaoProc \n"); + } +} + +/* +* ԶźŽ·ȡ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 AutoSigRouteQuXiaoProc(const UINT16 routeId) +{ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 startSignalId = 0u; + UINT8 retVal = CI_SUCCESS; + + /*ȡ·ֶ̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + startSignalId = GetRouteStartSignalId(routeId); + + if (GetSignalOpenCloseState(GetSignalCurColor(startSignalId)) == SIGNAL_OPEN) + {/*źδر*/ +#if 0 + if ((ROUTE_STATE_YUXIAN_OPEN == routeState) || (ROUTE_STATE_YUXIAN_LOCK == routeState)) + {/*(źſ) && (δгӽ)ʱſرԶźŻ*/ + + DriveSignalClose(startSignalId); /*źŹر*/ + retVal = RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT; + } + else + {/*(źſ) && (гӽ)ʱرԶźŻ*/ + retVal = CI_ERROR; + } +#endif + + + /*ӽռ*/ + if (CI_ERROR == RouteHaveTrainNear(routeId)) + { /*·δӽ*/ + if (CI_SUCCESS == RouteCancelLogicProcess(routeId)) + { + (void)DriveSignalClose(startSignalId); /*źŹر*/ + retVal = RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT; + } + else + { + retVal = CI_ERROR; + } + } + else + { /*·ӽ*/ + /*ӽ*/ + SetCiSendCmdBackInfoData(CI_BACK_ROUTE_NEAR_LOCK_YES, CI_DEVICE_TYPE_ROUTE, routeId, 0u, 0u); + retVal = CI_ERROR; + } + + + + } + else + {/*źѾر*/ + + /*ȡ·*/ + if ((ROUTE_STATE_XUANPAI == routeState) || (ROUTE_STATE_FIRST_XUANPAI == routeState)) + { + /*·ѡŻѡ*/ + + /*ȡ·ѡ*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + retVal = CI_SUCCESS; + } + else if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState)) + { + /*·||·쳣||·Ԥ ||Ԥȿ*/ + + /*Ԥȿ״̬ԭ:·ԶźŽ·֮ǰôԶźûļ + ROUTE_STATE_YUXIAN_OPEN--->ROUTE_STATE_YUXIAN_LOCK,ᵼԶźŽ·ȡ + ʧܡʵʱѾȡˡ + + ȡ֮ûӴ״̬Ϊ:ȡǷڽ·״̬֮ + */ + if (CI_SUCCESS == RouteCancelLogicProcess(routeId)) + { + /*ȡɹ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + retVal = CI_SUCCESS; + } + else + { + /*ȡʧ*/ + retVal = CI_ERROR; + } + } + else if ((ROUTE_STATE_NEAR_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState)) + { + + if (CI_ERROR == RouteHaveTrainNear(routeId)) + {/*ӽ޳ռãȡԶźŽ·*/ + if (CI_SUCCESS == RouteCancelLogicProcess(routeId)) + { + /*ȡɹ*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + retVal = CI_SUCCESS; + } + else + { + /*ȡʧ*/ + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else if (ROUTE_STATE_IDLE == routeState) + { + retVal = CI_SUCCESS; + } + else + { + /*ȡʧ*/ + retVal = CI_ERROR; + } + } + + return retVal; +} + +/* +* ·˽⴦ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongRenJieProc(const UINT16 routeId) +{ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 startSignalId = 0u; + UINT8 checkResult = CI_ERROR;/*Ƿгռ*/ + UINT16 firstOccuSecId = 0u;/*·ڷһռõID*/ + UINT8 devState = 0u; + UINT8 trainEnterSta = 0u;/*·гʻ־*/ + UINT8 checkZongRenJieResult = 0u; + UINT8 routeDelayUnlockflag = 0u; + UINT8 checkResultSecAndQXZC = 0u; /*RouteExceptLastSecOccuClrCheck˺ļ*/ + UINT8 cSignalColor = 0u; + UINT8 cSignalOpenState = 0u; + + /*ȡ·ֶ̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + startSignalId = GetRouteStartSignalId(routeId); + + cSignalColor = GetSignalCurColor(startSignalId); + cSignalOpenState = GetSignalOpenCloseState(cSignalColor); + + if (SIGNAL_OPEN == cSignalOpenState) + { + /*źδر*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ +#if 0 + SetRouteZongRenJieCloseFlag(routeId, ROUTE_ZRJ_CLOSE_FLAG_YES); /*·źŹر˽⵼*/ +#endif + return; + } + else + { + /*źѹر*/ + (void)SetRouteZongRenJieFlag(routeId, ROUTE_ZONGRENJIE_SET_NO); /*ȡ·˽־*/ +#if 0 + zrjCloseSigFlag = GetRouteZongRenJieCloseFlag(routeId); /*ȡ·˽źű־*/ + SetRouteZongRenJieCloseFlag(routeId, ROUTE_ZRJ_CLOSE_FLAG_NO); /**/ +#endif + } + + checkResult = RouteAllSecOccuClearCheck(routeId, &firstOccuSecId, &devState); + trainEnterSta = GetRouteTrainEnterFlag(routeId); + + /*˽·*/ + if ((ROUTE_STATE_XUANPAI == routeState) || (ROUTE_STATE_FIRST_XUANPAI == routeState)) + { + /*·ѡŻѡ*/ + + /*ȡ·ѡ*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + } + else if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState)) + { + /*·||·쳣||·Ԥ*/ + /*˽߼*/ + checkZongRenJieResult = CheckRouteZongRenJieFeasibility(routeId); + /* ȡ·ʱ*/ + routeDelayUnlockflag = GetRouteNeedDelayUnlock(routeId); + if (CI_SUCCESS == checkZongRenJieResult) + { + /*·Ҫʱ*/ + if (ROUTE_NEED_DELAY_UNLOCK == routeDelayUnlockflag) + { + /*·ռ*/ + if (CI_SUCCESS == checkResult) + { + /*-->ý·ʱ*/ + SetRouteStateManage(routeId, ROUTE_STATE_DELAY_UNLOCK); + /*·ռѹʱȫ*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_IDLE); + } + else + { + /* ·гռãжڷһ߼Ƿռ */ + if (ROUTE_TRAIN_ENTER_FLAG_NO == trainEnterSta) + {/*޳ʻ룬ȫ̹*/ + /*·α̹*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_EXCEPT); + + /*·߼ζ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_EXCEPT); + } + else + { + /*̹*/ + SetRoutePhySecExpLockToOccupy(routeId); + } + + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + } + else + { + + if (CI_SUCCESS == checkResult) + {/*ռ*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + else + { + if (ROUTE_TRAIN_ENTER_FLAG_NO == trainEnterSta) + {/*޳ʻ룬ȫ̹*/ + /*·α̹*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_EXCEPT); + + /*·߼ζ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_EXCEPT); + } + else + { + /*̹*/ + SetRoutePhySecExpLockToOccupy(routeId); + } + + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + } + } + else + { + /*·ȡ*/ + } + } + else if (ROUTE_STATE_NEAR_LOCKERR == routeState) + { + /*˽߼*/ + checkZongRenJieResult = CheckRouteZongRenJieFeasibility(routeId); + if (CI_SUCCESS == checkZongRenJieResult) + { + SetRouteStateManage(routeId, ROUTE_STATE_DELAY_UNLOCK); /*-->ý·ʱ*/ + + if (CI_SUCCESS == checkResult) + { + /*·ռѹʱȫ*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_IDLE); + } + else + { + /* ·гռ */ + if (ROUTE_TRAIN_ENTER_FLAG_NO == trainEnterSta) + { + /*гʻʱȫ̹*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_ALL_EXP); + } + else + { + /*ʱ󲿷̹һռѹ֮ǰα̹*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_EXP_TO_OCCUPY); + } + } + } + else + { + /*·ȡ*/ + } + } + else if ((ROUTE_STATE_LEAD_LOCK == routeState) || (ROUTE_STATE_LEAD_LOCKERR == routeState)) + { /*||쳣*/ + /*˽·ԭ޸20180809 + ·ڷлһռʱ + һռʻ룬ʱ*/ + + checkResultSecAndQXZC = RouteExceptLastSecOccuClrCheck(routeId); + if (CI_SUCCESS == checkResultSecAndQXZC) + { /*οлһռ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + else if ((ROUTE_TRAIN_ENTER_FLAG_NO == trainEnterSta) && (CI_ERROR_QXZC != checkResultSecAndQXZC)) + {/*˽·ʱȡղ̵δܽ·*/ + /*˽*/ + SetRouteStateManage(routeId, ROUTE_STATE_DELAY_UNLOCK); /*-->ý·ʱ*/ + /*ʱȫ*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_IDLE);/*ʱν*/ + } + else + { + /**/ + } + + } + else + { + /*·״̬*/ + /* ¼ */ + SetErrorData(EFUNC_ROUTE_ZRJ_DEAL, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, routeState, ESEND_LEVEL_ATS); + } +} + + +/* +ι +UINT8 overlapIdSum +UINT16 * pOverlapIdBuf IDָ + +CI_SUCCESS ɹ +CI_ERROR ʧ + +*/ +UINT8 UnLockLocalOvlpManageHlht(UINT8 overlapIdSum, UINT16* pOverlapIdBuf) +{ + UINT8 const localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + UINT8 retVal = CI_ERROR; + UINT16 overlapId = 0u; + UINT8 ii = 0u; + + if ((0u == overlapIdSum) || (NULL == pOverlapIdBuf)) + { + /*ûб*/ + retVal = CI_SUCCESS; + } + else + { + for (ii = 0u; ii < overlapIdSum; ii++) + { + overlapId = *(pOverlapIdBuf + ii); + + if (GetOverlapBelongCiId(overlapId) == localCiId) + { + /*·Overlap*/ + if (CI_SUCCESS == UnlockLocalOvlpCheckHlht(overlapId)) + { /*ɹ*/ + SetOvlpLockStateForHlhtCi(overlapId, PHYSICAL_SECTION_LOCK_NO, 0); /*Overlapδ*/ + + retVal = CI_SUCCESS; + + break; + } + else + { /*ʧ*/ + /**/ + } + } + } + } + + return retVal; +} + + +/* +* ·OVERLAP +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 UnlockRouteOverlapProc(const UINT16 routeId) +{ + UINT8 const localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + UINT16 unlockOverlapId = 0u; /*ID*/ + + UINT16 overlapId = 0u; + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 devCurMergeState = 0u; /*豸ںռ״̬*/ + UINT8 utOrCtOccFlag = 0u; /*CTUTռ״̬*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 routeBelongCi = 0u; /*·*/ + UINT16 wTrainId = 0u; /* г */ + UINT8 ret = CI_SUCCESS; + UINT8 cRcWorkMode = 0u; + UINT32 dwCurSysCycNum = 0U; /*ǰϵͳ*/ + UINT32 dwReqUnlockStartCycNum = 0U; /*ʼں*/ + + /* RCģʽ */ + cRcWorkMode = GetLocalRcWorkMode(); + dwCurSysCycNum = Get2oo2CurCycleNum(); + + if (ROUTE_OVERLAP_SET_YES != GetRouteOverlapLockFlag(routeId)) + { /*·δ*/ + + return CI_SUCCESS; + } + + overlapId = GetRouteOverlapLockedId(routeId); + + if (GetOverlapBelongCiId(overlapId) != localCiId) + { + /*ڱ*/ + return CI_ERROR; + } + + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecLockState(devId); + routeState = GetRouteState(routeId); + routeBelongCi = GetRouteBelongCiId(routeId); + devCurMergeState = GetPhySecCurMergeState(devId); + utOrCtOccFlag = GetPhySecPreOccState(devId); /*ȡCTUTռ״̬*/ + if ((PHYSICAL_SECTION_LOCK_NO != devState) && (GetRouteDirection(routeId) == GetPhySecLockDirection(devId)) && + (ROUTE_STATE_IDLE == routeState) && + (routeBelongCi != localCiId))/*20170222գ&&(GetRouteDirection(routeId)==GetPhySecLockDirection(devId))ԭгռѹʱ·Ѿʱ෴Ľ·ˣǴʱ֮ǰı޹*/ + { /* + *: ͽ·У·һڱʱ̹ʱ + Σ̫ʣΪ׷жϡ + жΪ + ·״̬У&&ý·ڱ&&һ״̬Ϊδգʱ + ³ֵ龰: + :CI1 CI5 + CI1·Z3-CD1·CI1崻ZHG1̹ұJK1GڣCI1JK1G + */ + } + else + { + ret = UnlockRouteOverlapLogicProcess(routeId, &unlockOverlapId, &wTrainId); + /*·Overlap*/ + if (CI_SUCCESS == ret) + { /*Խ*/ + SetOverlapLockState(unlockOverlapId, PHYSICAL_SECTION_LOCK_NO, routeId); /*Overlapδ*/ + return CI_SUCCESS; + } + else if (CI_UNLOCK_OVERLAP_REQURE == ret) + { + /*Էͽ*/ + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + /* ҪѯгбνûгԴռʱŽ */ + wTrainId = wTrainId & 0x00FFU; + SetOverlapUnlockApplyTrainId(unlockOverlapId, wTrainId); + + dwReqUnlockStartCycNum = GetReqIvocUnlockStartCycNum(unlockOverlapId); + if (0U == dwReqUnlockStartCycNum) + { + SetReqIvocUnlockStartCycNum(unlockOverlapId, dwCurSysCycNum); /*һʱںΪʼں*/ + } + else + { + /**/ + } + } + else if (RC_WORK_MODE_CI == cRcWorkMode) + { + /* TODO */ + SetOverlapUnlockApplyFlag(unlockOverlapId, UNLOCK_OVERLAP_APPLY_YES); + } + else + { + ; /* ޴ */ + } + } + else if (CI_ERROR == ret) + { + /*ʲôҲ*/ + } + else + { + /*ʲôҲ*/ + } + + wTrainId = GetOverlapUnlockApplyTrainId(unlockOverlapId); + + if (SECTION_OCCUPY_NO == devCurMergeState)/*ǰ*/ + { + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + if (0u != wTrainId) + { + /*ֹͣ*/ + SetOverlapUnlockApplyTrainId(unlockOverlapId, 0U); + SetReqIvocUnlockStartCycNum(unlockOverlapId, 0U); + /*ֹͣʱ*/ + SetSecUtOrCtOccuStartCycNum(devId, 0u); + } + } + else if (RC_WORK_MODE_CI == cRcWorkMode) + { + /* TODO */ + if (UNLOCK_OVERLAP_APPLY_YES == GetOverlapUnlockApplyFlag(unlockOverlapId))/*ǰZCͽ*/ + { + /*ֹͣ*/ + SetOverlapUnlockApplyFlag(unlockOverlapId, UNLOCK_OVERLAP_APPLY_NO); + /*ֹͣʱ*/ + SetSecUtOrCtOccuStartCycNum(devId, 0u); + } + } + else + { + ; /* ޴ */ + } + + } + else if ((SECTION_OCCUPY_YES == devCurMergeState) && (LOGICSECTION_OCCUPY_UT == utOrCtOccFlag))/*ǰUTռ*/ + { + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + if (0u != wTrainId) + { + /*ֹͣ*/ + SetOverlapUnlockApplyTrainId(unlockOverlapId, 0u); + SetReqIvocUnlockStartCycNum(unlockOverlapId, 0U); + } + } + else if (RC_WORK_MODE_CI == cRcWorkMode) + { + /* TODO */ + if (UNLOCK_OVERLAP_APPLY_YES == GetOverlapUnlockApplyFlag(unlockOverlapId))/*ǰZCͽ*/ + { + /*ֹͣ*/ + SetOverlapUnlockApplyFlag(unlockOverlapId, UNLOCK_OVERLAP_APPLY_NO); + } + } + else + { + ; /* ޴ */ + } + } + else + { + /*ʲôҲ*/ + } + } + return CI_ERROR; +} + + +/* +* ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void PhySecDelayUnlockProc(const UINT16 routeId) +{ + UINT16 phySectionId = 0u; /*ID*/ + UINT16 nextPhySectionId = 0u; /*һID*/ + UINT8 secLockState = 0u; /*״̬*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT16 routeLastSwiPhySecId = 0u; /*·Զ˵ID*/ + + UINT8 sectionSum = 0u; /*ý·*/ + RoutePhysicalSectionStruct* pRouteSecStru = NULL; /**/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + +/*·ʱ*/ + returnValue = PhySectionDelayUnlockProcess(routeId, &phySectionId); + + if (0u == phySectionId) + { + /**/ +#if 0/*߼νע͵*/ + /*ûʱ*/ + if (CI_SUCCESS == CheckRoutePhySecHaveUnLock(routeId)) + { + /*·ȫ*/ + if (ROUTE_STATE_FLAG_YES == GetRouteStateFlag(routeId)) + {/*CBTC׷ٰ·־Ч򲻸ı·״̬Զʱ·ȫ*/ + } + else + {/*CBTC׷ٰ·־Чý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + } +#endif + + } + else + { + /*ʱ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + SetPhySecLockState(phySectionId, PHYSICAL_SECTION_LOCK_NO, routeId, GetRouteDirection(routeId)); /*δ*/ + + /*ͬʱڱ·յ߼δ*/ + SetPhyIncludeLogLockState(phySectionId, LOG_SECTION_LOCK_NO, routeId); + + routeLastSwiPhySecId = GetRouteLastSwichPhySecId(routeId); + if (phySectionId == routeLastSwiPhySecId) + {/*·*/ + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_CANCEL);/*ȡ·ķ*/ + } + + /*һ޲*/ + if ((ROUTE_TYPE_DIAOCHE == GetRouteType(routeId)) && + (sectionSum >= 2u) && + (phySectionId == pRouteSecStru[sectionSum - 2U].PhysicalSectionId) && + (PHYSICAL_SEC_TYPE_NOSWITCH == GetPhySecType(pRouteSecStru[sectionSum - 1U].PhysicalSectionId))) + { /*· && 2 && ·ڶ && һ޲*/ + + SetPhySecLockState(pRouteSecStru[sectionSum - 1U].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, routeId, GetRouteDirection(routeId)); /*δ*/ + } + else + { + ; + } + + if (CI_SUCCESS == CheckRoutePhySecHaveUnLock(routeId)) + { + /*·ȫ*/ + if (ROUTE_STATE_FLAG_YES == GetRouteStateFlag(routeId)) + {/*CBTC׷ٰ·־Ч򲻸ı·״̬Զʱ·ȫ*/ + } + else + {/*CBTC׷ٰ·־Чý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + } + else + { + nextPhySectionId = GetRouteNextPhySecId(routeId, phySectionId); /*ȡһID*/ + secLockState = GetPhySecLockState(nextPhySectionId); /*ȡ״̬*/ + + if ((nextPhySectionId > 0u) && (PHYSICAL_SECTION_LOCK_DELAY == secLockState)) + { + /*һμʱ*/ + SetPhySecAutoUnlockStartCycNum(nextPhySectionId, Get2oo2CurCycleNum()); /*ʱʼ*/ + } + else + { + /*һδʱ*/ + } + } + } + else if (RETURN_DELAYUNLOCK_ERR_TIMECOUNT == returnValue) + { + /*ʱδ*/ + } + else + { + /*ʧ*/ + SetPhySecAutoUnlockStartCycNum(phySectionId, Get2oo2CurCycleNum()); /*ʱʼ*/ + } + } +} + + +/* +* ·гʻ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESSɹ +* ERROR ʧ +* mod by qw.liu ޸ı淶޸CBTCг·ʻж +*/ +UINT8 RouteLTrainEnter(const UINT16 routeId) +{ + UINT16 startSigId = 0u; /*·ʼźŻID*/ + UINT16 outPhySecId = 0u; /*źŻⷽһID*/ + UINT16 inPhySecId = 0u; /*źŻڷһID*/ + UINT8 routeLevel = 0u; + UINT8 routeType = 0u; + UINT8 routeCrossState = 0u; + UINT16 nextPhySecId = 0u; + UINT8 signalType = 0u; + UINT8 signalCrossCloseType = 0u; + UINT16 wszTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + UINT8 chTrainInfoSum = 0U; + UINT8 chDsnFuncSwitch = 0U; + + UINT8 chRetVal = CI_ERROR; + UINT8 chFuncRet = CI_ERROR; + UINT16 wDevId = 0U; + UINT8 chDevState = 0U; + UINT8 chRCMode = 0u; + UINT8 cRoutePreLevel = 0U; /*·֮ǰ*/ + UINT8 chLocalCiType = 0U;/**/ + + /* ߼ */ + + chDsnFuncSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH); + startSigId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + signalType = GetSignalType(startSigId); /*ȡźŻ߼*/ + signalCrossCloseType = GetSignalCrossCloseAttr(startSigId); /*ȡźŻѹص*/ + + if (0u == startSigId) + { + chRetVal = CI_ERROR; + } + else + { + chRetVal = CI_SUCCESS; + } + + if (CI_SUCCESS == chRetVal) + { + inPhySecId = GetSignalInFirstPhySecId(startSigId, routeId); /*źŻڷһID*/ + outPhySecId = GetSignalOutFirstPhySecId(startSigId); /*źŻⷽһID*/ + if (0u == inPhySecId) + { + chRetVal = CI_ERROR; + } + else + { + ; /*ִ*/ + } + } + else + { + ; + } + if (CI_SUCCESS == chRetVal) + { + routeType = GetRouteType(routeId); + + if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + /*źţȫԽźŻʱźŻⷽгźŻⷽδ·Ƿг³гڷһʱ*/ + if ((SECTION_OCCUPY_NO == GetPhySecCurMergeState(inPhySecId)) && + (SECTION_OCCUPY_YES == GetPhySecPreMergeState(inPhySecId))) + { /*ڷһο*/ + if ((outPhySecId == 0u) || ((SECTION_OCCUPY_YES == GetPhySecCurMergeState(outPhySecId)) && + (PHYSICAL_SEC_TYPE_NOSWITCH == GetPhySecType(outPhySecId)))) + { /*ⷽΪ0||ⷽεǰռ&&޲*/ + + nextPhySecId = GetRouteNextPhySecId(routeId, inPhySecId); /*ȡڷһεһID*/ + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(nextPhySecId)) + { + chRetVal = CI_SUCCESS; /*гʻ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(inPhySecId)) + { /*ڷһռ*/ + if (0u == outPhySecId) + { + chRetVal = CI_SUCCESS; /*гʻ*/ + } + else if (((SIGNAL_TYPE_JINKUCHUKU == signalType) || ((SIGNAL_TYPE_TWO_JINKU_RGY == signalType) || (SIGNAL_TYPE_THREE_JINKU_YINDAO == signalType))) + && ((SIGNAL_CROSS_ClOSE_YES == signalCrossCloseType) && (SECTION_OCCUPY_YES == GetPhySecCurMergeState(outPhySecId)))) + {/*ε·źŻڷһռеѹصʱΪгʻ*/ + chRetVal = CI_SUCCESS; /*гʻ*/ + } + else + { + if ((SECTION_OCCUPY_NO == GetPhySecCurMergeState(outPhySecId)) && + (SECTION_OCCUPY_YES == GetPhySecPreMergeState(outPhySecId))) + { /*ⷽεǰ&&֮ǰռ*/ + + chRetVal = CI_SUCCESS; /*гʻ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + + } + else + { /*ڷ֮ǰǰ*/ + + chRetVal = CI_ERROR; + } + } + else if ((ROUTE_TYPE_LIECHE == routeType) || (ROUTE_TYPE_RETURN == routeType)) + { + routeLevel = GetRouteLevel(routeId); + chRCMode = GetLocalRcWorkMode();/*ȡǰRCģʽ*/ + if (RC_WORK_MODE_TIOC == chRCMode) + { + if (ROUTE_LEVEL_CBTC == routeLevel) + { + chRetVal = RouteCbtcTiranEnterCheck(routeId);/*ڵù GetRouteReadyEnterTrainInfo*/ + } + else + { + chFuncRet = GetRouteReadyEnterTrainInfo(routeId, &chTrainInfoSum, wszTrainId); + cRoutePreLevel = GetRoutePreLevel(routeId); /*ȡ·֮ǰ*/ + if ((CI_ERROR == chFuncRet) || (1U < chTrainInfoSum) || (ROUTE_LEVEL_BLOC != cRoutePreLevel)) + { + chRetVal = CI_ERROR; /*׼ʻг1֮ǰ·ǵʽ𣬷0ʧ*/ + } + else + { + ; /*ԴΪ10 ͨ*/ + } + } + } + else if (RC_WORK_MODE_CI == chRCMode) + {/*CI*/ + + routeCrossState = GetSignalCrossState(startSigId); + if ((routeLevel == ROUTE_LEVEL_CBTC) && (routeCrossState == SIGNAL_CROSS_STATE_NO)) + { + /*CBTC·ǿѹźŻر*/ + chRetVal = CI_ERROR; + } + else + { + ;/*ͨ*/ + } + } + else + { + chRetVal = CI_ERROR;/*ģʽ󷵻ʧ*/ + } + + /*ⷽռѹ*/ + if (CI_SUCCESS == chRetVal) + { + chDevState = GetPhySecCurMergeState(inPhySecId); + if (SECTION_OCCUPY_YES == chDevState) + { /*ڷռã·ΪCBTCdzʱΪгٿѹ,ֻҪڷһεռѹùⷽ*/ + chLocalCiType = GetLocalCiType(); + if ((ROUTE_LEVEL_CBTC == routeLevel) && (CI_TYPE_CLD != chLocalCiType)) + { + chRetVal = CI_SUCCESS; + } + else + { + if (outPhySecId == 0u) + { + chRetVal = CI_SUCCESS; + } + else + { + chDevState = GetPhySecCurMergeState(outPhySecId); + if (SECTION_OCCUPY_YES == chDevState) + { /*ⷽռ*/ + + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ; + } + + if (FUNC_SWITCH_ON == chDsnFuncSwitch) + { + chFuncRet = RouteFaultOccuCheck(routeId, &wDevId, &chDevState); + if (CI_SUCCESS == chFuncRet) + { + chDevState = GetPhySecCurOccupyState(inPhySecId); + if (SECTION_OCCUPY_YES == chDevState) + { + + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + + +/* +* ·رźŴ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESSɹ +* ERROR ʧ +*/ +UINT8 RouteOpenNeedCloseSignal(const UINT16 routeId)/* liu 06-26*/ +{ + UINT8 needCloseSignalNum = 0u; + UINT16* needCloseSignalIdBuf = NULL; + UINT16 curSignalId = 0u; + UINT8 ii = 0u; + UINT8 localCiId = 0u; /*ID*/ + UINT8 closeFlag = 0u; /* Ҫرյı־ */ + UINT8 belongCiId = 0u; /*źŻID*/ + UINT8 driveRetVal = 0u; + + localCiId = GetSystemParaLocalCiId();/*ID*/ + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + return CI_ERROR; + } + + needCloseSignalNum = GetRouteOpenNeedCloseSigSum(routeId); + if (0u == needCloseSignalNum) + { + return CI_SUCCESS; + } + /* + * ҪرյźŻԶźţҪرգ + * ԶźŻѾźѾţȥر + * + */ + if (ROUTE_OPENNEEDCLOSESIG_SUM_MAX >= needCloseSignalNum) + { + needCloseSignalIdBuf = GetRouteOpenNeedCloseSigIdBuf(routeId); + for (ii = 0u; ii < needCloseSignalNum; ii++) + { + closeFlag = 0u; /* */ + curSignalId = needCloseSignalIdBuf[ii]; + belongCiId = GetSignalBelongCiId(curSignalId); + if (localCiId != belongCiId) + { + closeFlag = 0u; /* ȥر ,DZҲ*/ + } + else + { + closeFlag = 1u;/* ر */ + } + + if (closeFlag == 1u) + { + driveRetVal = DriveSignalClose(curSignalId); + if (CI_ERROR == driveRetVal) + { + return CI_ERROR; + } + } + } + + return CI_SUCCESS; + } + else + { + return CI_ERROR; + } +} + + +/* +* overlap +* ˵ const UINT16 overlapId, overlap ID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 OverlapLockDriveSwitch(const UINT16 overlapId)/* liu 06-26*/ +{ + UINT8 ii; + UINT8 switchSum = 0u; + UINT16 switchId = 0u; + UINT8 switchExpPosition = 0u; + UINT8 switchCurPosition = 0u; + UINT8 switchDancaoPosition = 0u; /*Чλ*/ + UINT8 retVal = CI_SUCCESS; + OverlapConditionSwitchStruct* conditionSwitchStru = NULL; + UINT8 overlapProtectSwitchSum = 0u; /*Ŀ*/ + OverlapProtectSwitchStruct* overlapProtectSwitchStru = NULL; /**/ + UINT8 cLocalCiId = 0U; + UINT8 cSwitchBelongCiId = 0U; + + cLocalCiId = GetSystemParaLocalCiId(); + + if ((0u == overlapId) || (overlapId >= OVERLAP_SUM_MAX)) + { + retVal = CI_ERROR; + } + + switchSum = GetOverlapSwitchSum(overlapId); + conditionSwitchStru = GetOverlapCondSwitchStruct(overlapId); + overlapProtectSwitchSum = GetOverlapRelatedProtSwitSum(overlapId); + overlapProtectSwitchStru = GetOverlapRelatedProtSwitStru(overlapId); + + if (NULL == conditionSwitchStru) + { + retVal = CI_ERROR; + } + + if (NULL == overlapProtectSwitchStru) + { + retVal = CI_ERROR; + } + + /**/ + for (ii = 0u; ii < switchSum; ii++) + { + switchId = conditionSwitchStru[ii].SwitchId; + cSwitchBelongCiId = GetSwitchBelongCiId(switchId); + if ((0U != cSwitchBelongCiId) && (cLocalCiId == cSwitchBelongCiId)) + { + switchExpPosition = conditionSwitchStru[ii].SwitchPosition; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + switchCurPosition = GetSwitchCurPosition(switchId); + if ((switchDancaoPosition == SWITCH_POSITION_INVALID) + || (switchDancaoPosition == switchExpPosition)) + { + /*Ч λ붯λһ*/ + } + else + { + /*ٵ෴λȡ·*/ + retVal = CI_ERROR; + break; + } + if ((switchExpPosition != SWITCH_POSITION_INVALID) && (switchCurPosition == switchExpPosition)) + { + /*λЧ λ뵱ǰλһ*/ + } + else + { + if (CI_ERROR == SwitchDriveProcess(switchId, switchExpPosition)) + { + retVal = CI_ERROR; + break; + } + } + } + else + { + /*DZ*/ + } + } + + if (CI_SUCCESS == retVal) + { + /*ι*/ + for (ii = 0u; ii < overlapProtectSwitchSum; ii++) + { + switchId = overlapProtectSwitchStru[ii].ProtectSwitchId; + cSwitchBelongCiId = GetSwitchBelongCiId(switchId); + if ((0U != cSwitchBelongCiId) && (cLocalCiId == cSwitchBelongCiId)) + { + switchExpPosition = overlapProtectSwitchStru[ii].ProtectPosition; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + switchCurPosition = GetSwitchCurPosition(switchId); + if ((switchDancaoPosition == SWITCH_POSITION_INVALID) + || (switchDancaoPosition == switchExpPosition)) + { + /*Ч λ붯λһ*/ + } + else + { + /*ٵ෴λȡ·*/ + retVal = CI_ERROR; + break; + } + if ((switchExpPosition != SWITCH_POSITION_INVALID) && (switchCurPosition == switchExpPosition)) + { + /*λЧ λ뵱ǰλһ*/ + } + else + { + if (CI_ERROR == SwitchDriveProcess(switchId, switchExpPosition)) + { + retVal = CI_ERROR; + break; + } + } + } + else + { + /*DZ*/ + } + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* Overlap״̬ +* ˵ const UINT16 overlapId, overlap ID +* const UINT8 lockState, ״̬ +* const UINT16 routeId, ·ID +* ֵ void +*/ +void SetOverlapLockState(const UINT16 overlapId, const UINT8 lockState, const UINT16 routeId) +{ + UINT8 phySecSum = 0u; /**/ + UINT16* pPhySecIdBuf = NULL; /*νṹָ*/ + UINT8 cLogicSectionSum = 0u; /*߼*/ + UINT16* pLogicSectionIdBuf = NULL; /*߼ID*/ + UINT8 ii = 0u; /**/ + UINT8 jj = 0U; + UINT8 rtVal = CI_ERROR; + UINT8 routeDir = 0u;/*·*/ + UINT8 haveDirChangeInRoute = 0u;/*·з仯*/ + UINT8 haveDirChangeAfterRoute = 0u;/*·ͱ֮з仯*/ + UINT8 cLogicSectionLockState = 0u; + UINT16 wRouteLastLogicSectionId = 0u; + UINT8 cTrainSum = 0u; + LogicTrainResStruct* pLogicTrainResData = NULL; + UINT16 wLockBelongRouteId = 0u;/*߼·ID*/ + + phySecSum = GetOverlapPhySecSum(overlapId); /*ȡoverlap*/ + pPhySecIdBuf = GetOverlapPhySecIdBuf(overlapId); /*ȡoverlapID*/ + + cLogicSectionSum = GetOverlapLogicSectionSum(overlapId); + pLogicSectionIdBuf = GetOverlapLogicSectionBuf(overlapId); + + wRouteLastLogicSectionId = GetRouteInLastLogSecId(routeId); + + + if ((0u == phySecSum) || (NULL == pPhySecIdBuf) + || (0u == cLogicSectionSum) || (NULL == pLogicSectionIdBuf) + || (0u == wRouteLastLogicSectionId)) + { + rtVal = CI_ERROR; + } + else + { + rtVal = CI_SUCCESS; + if ((PHYSICAL_SECTION_LOCK_PROTECT != lockState) && + (PHYSICAL_SECTION_LOCK_NO != lockState)) + { /*״̬Ч*/ + + rtVal = CI_ERROR; + } + } + + if (CI_SUCCESS == rtVal) + { + routeDir = GetRouteDirection(routeId); + haveDirChangeInRoute = GetRouteHaveDirChangePointIn(routeId); + haveDirChangeAfterRoute = GetRouteHaveDirChangePointAfter(routeId); + if ((ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute) || (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeAfterRoute)) + { + if (CI_SYSTEM_DIRECTION_UP == routeDir) + { + routeDir = CI_SYSTEM_DIRECTION_DOWN;/*֮ǰյģȡ*/ + } + else if (CI_SYSTEM_DIRECTION_DOWN == routeDir) + { + routeDir = CI_SYSTEM_DIRECTION_UP;/*շȡ*/ + } + else + { + /*ִе*/ + } + } + + /*Overlap״̬*/ + for (ii = 0u; ii < phySecSum; ii++) + { + SetPhySecLockState(pPhySecIdBuf[ii], lockState, routeId, routeDir); + } + + if (PHYSICAL_SECTION_LOCK_PROTECT == lockState) + { /**/ + + /*ñ·ID*/ + SetOverlapBelongRouteId(overlapId, routeId); + + /*ý·ձId*/ + SetRouteOverlapLockedId(routeId, overlapId); + + /*ñιΪ*/ + SetOverlapRelateProtSwLockSta(overlapId, SWITCH_LOCK_PROTECT_SET); +#if 0 + /*Overlapʱ*/ + SetOverlapLockStartCycNum(routeId, 0); +#endif + + /*صλ*/ + ClearOverlapSwitchDrivePos(overlapId); + + /*ιλ*/ + ClearOverlapSwitchDanCaoPos(overlapId); + + /*ճɹ˹ձ*/ + SetOverlaplaborLockCmdFlag(overlapId, LOCK_OVERLAP_CMD_NO); + + SetOverlapFromSetRouteCmdFlag(overlapId, OVERLAP_ROUTE_FLAG_NO);/*νɽ··־*/ + + /* ߼η */ + cLogicSectionLockState = LOG_SECTION_LOCK_PROTECT; + } + else if (PHYSICAL_SECTION_LOCK_NO == lockState) + { /*δ*/ + /*÷ս·IDΪ0*/ + SetOverlapBelongRouteId(overlapId, 0u); + + /*·ձId*/ + SetRouteOverlapLockedId(routeId, 0u); + /*α־*/ + SetOverlapUnlockApplyFlag(overlapId, UNLOCK_OVERLAP_APPLY_NO); + /*ȡιķ*/ + SetOverlapRelateProtSwLockSta(overlapId, SWITCH_LOCK_PROTECT_CANCEL); +#if 0 + /*÷νʼΪ0*/ + SetOverlapUnlockStartCycNum(overlapId, 0); +#endif + SetRouteAtsExpLkOverlapId(routeId, 0u); + + /*Ϊ˹*/ + SetOverlapCanLaborUnlockFlag(overlapId, CANNOT_LABOR_UNLOCK_OVERLAP); + /*˹ʼں*/ + SetlaborUnlockStartCycNum(overlapId, 0u); + /*˹*/ + SetOverlapLaborUnlockSetState(overlapId, LABOR_UNLOCK_OVERLAP_NO); + /**/ + CleanOverlapAtsOrlaborLockFlag(routeId, overlapId); + /*ʼ0*/ + SetOverlaplockSucessStartCycNum(overlapId, 0u); + + /*ñгIDΪ0*/ + SetOverlapUnlockApplyTrainId(overlapId, 0U); + + /*ñʼΪ0*/ + SetReqIvocUnlockStartCycNum(overlapId, 0U); + + SetOverlapFromSetRouteCmdFlag(overlapId, OVERLAP_ROUTE_FLAG_NO);/*νɽ··־*/ + + /*ñгͬ*/ + SetOverlapIvocAllowUnlockFlag(overlapId, IVOC_ALLOW_UNLOCK_OVERLAP_NO); + + /* ߼δ */ + cLogicSectionLockState = LOG_SECTION_LOCK_NO; + } + else + { + /**/ + } + + + if ((LOG_SECTION_LOCK_NO == cLogicSectionLockState) || (LOG_SECTION_LOCK_PROTECT == cLogicSectionLockState)) + { + /* ߼η״̬ */ + for (ii = 0u; ii < cLogicSectionSum; ii++) + { + SetLogSecLockState(pLogicSectionIdBuf[ii], cLogicSectionLockState, routeId, routeDir); +#if 0 + wLockBelongRouteId = GetLogSecLockBelongRoute(pLogicSectionIdBuf[ii]);/*߼·*/ + if ((LOGIC_SECTION_RES_SHARE_NO == chResShrFlag) && (0u != wLockBelongRouteId)) + { + /*Σʱ÷ǹ*/ + } + else + { + SetLogSecResShareFlag(pLogicSectionIdBuf[ii], chResShrFlag); + } +#endif + } + } + +#if 0 + if (LOG_SECTION_LOCK_PROTECT == cLogicSectionLockState) + { + /* Ϊգͬ·߼εгԴϢ */ + cTrainSum = GetLogSecTrainInfoSum(wRouteLastLogicSectionId); + pLogicTrainResData = GetLogSecTrainInfo(wRouteLastLogicSectionId); + + if ((0u != cTrainSum) && (NULL != pLogicTrainResData)) + { + for (ii = 0u; ii < cLogicSectionSum; ii++) + { + for (jj = 0u; jj < cTrainSum; jj++) + { + /* гӵε߼ */ + AddLogSecTrainRes(pLogicSectionIdBuf[ii], pLogicTrainResData[jj].wTrainId); + } + } + } + } + else if (LOG_SECTION_LOCK_NO == cLogicSectionLockState) + { + ReleaseOverlapRes(overlapId); + } + else + { + /*޲*/ + } +#endif + } +} + + + +/* +* ͨ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetCommonRouteLogicManage(const UINT16 routeId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 routeType = 0u; /*·*/ + UINT8 routeLevel = 0u; /*·*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 AirShaftType = 0u; /*羮·*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 triggerFlag = 0u; + UINT8 checkRetVal = CI_FALSE; + UINT16 startSignalId = 0u; + UINT8 sendLevel = 0u; /*Ϸͼ*/ + UINT8 virCIid = 0u; + UINT8 funcSwitch = 0u; /*ܿ*/ + UINT8 cRcWorkMode = 0u; + UINT8 cKeepWorkFlag = CI_ERROR; + UINT8 firstLogicOccuState = 0u; + UINT8 chLocalCiType = 0U;/**/ + UINT8 chSignalReOpenFunc = 0U; + + /*·ź쳣رգյ·ִźؿ 0xaaִ 0x55ִ*/ + chSignalReOpenFunc = GetCiFunctionSwitchConfig(FUNC_ROUTELOCK_OPEN_SIGNAL); + + /* RCģʽ */ + cRcWorkMode = GetLocalRcWorkMode(); + chLocalCiType = GetLocalCiType(); /*ȡ*/ + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + ; /* ޴ */ + } + else + { + cKeepWorkFlag = CI_SUCCESS;/*Go on*/ + } + if (CI_SUCCESS == cKeepWorkFlag) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + if ((belongCiId != localCiId) || (0u == localCiId)) + { + cKeepWorkFlag = CI_ERROR; + } + else + { + /*Go on*/ + } + } + if (CI_SUCCESS == cKeepWorkFlag) + { + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + routeType = GetRouteType(routeId); /*ȡ·*/ + routeLevel = GetRouteLevel(routeId); + routeState = GetRouteState(routeId); + triggerFlag = GetRouteAutoTriggerFlag(routeId); /*ȡ·Զ־*/ + + + } + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ȡڷŵһ߼ռ״̬ */ + firstLogicOccuState = GetLogSecCurOccupyState(GetRouteInFirstLogSecId(routeId)); + checkResult = SetRouteProc(routeId);/*Ƿ*/ + if (CI_ERROR == checkResult) + { + if ((CI_TYPE_ZX == chLocalCiType) || (CI_TYPE_SCX == chLocalCiType)) + { + if ((ROUTE_TYPE_LIECHE == routeType) && (ROUTE_REVERSE_PROPERTY_NO == GetRouteReverseProperty(routeId)) + && (ROUTE_LEVEL_CBTC == routeLevel) && (ROUTE_STATE_NEAR_LOCK == routeState)) + { + if (RC_WORK_MODE_CI == cRcWorkMode) + { + if (SECTION_OCCUPY_NO != firstLogicOccuState) + { + cKeepWorkFlag = CI_ERROR; + } + } + else + { + ; /* TIOCжڷŵһ߼ռ״̬ */ + } + } + else + { + if ((ROUTE_TYPE_LIECHE == routeType) && ((ROUTE_STATE_FIRST_LOCKERR == routeState) + || (ROUTE_STATE_YUXIAN_LOCK == routeState) || (ROUTE_STATE_NEAR_LOCKERR == routeState))) + { + ; /*by cgh 20230704 YF0083-562 ·գ쳣Ԥաӽ쳣߼ֱӵ·*/ + } + else + { + cKeepWorkFlag = CI_ERROR;/**/ + } + } + } + else + { + SetRouteStopFlagManage(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + cKeepWorkFlag = CI_ERROR;/*ΰ㣬ټ߼*/ + } + } + else + { + /*Go on*/ + } + } + + if (CI_SUCCESS == cKeepWorkFlag) + { + AirShaftType = GetAirShaftRouteType(routeId); + routeState = GetRouteState(routeId); + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*Ϊ·*/ + if (ROUTE_STATE_IDLE == routeState) + { + /*·*/ + + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { + /*ȫδ*/ + + /*Ƿ*/ + if (CI_SUCCESS == CheckRouteContainSwitchUseSta(routeId)) + { + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_XUANPAI); /*-->ý·ѡ*/ + } + else + { + /*ô룺*/ + SetErrorData(EFUNC_CHECK_SWITCH_USING, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_SWT_USE_STATE, SWITCH_USING_YES, ESEND_LEVEL_ATS); + } + } + } + else if (ROUTE_STATE_HALF_UNLOCK == routeState) + { + /*ֽ·ȴ*/ + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { + /*ȫδãý·*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_YES); + + SetRouteStateFlag(routeId, ROUTE_STATE_FLAG_YES); /*-->ý·״̬תƱ־Ч*/ + (void)SetRouteXuanPaiStartCycNum(routeId, 0U);/*ÿµЧҪ¼ѡʱ*/ + } + } + else + { + /**/ + } + } + else + { + if ((AutoSignalOrRouteValid(routeId) == CI_SUCCESS) || + (AUTO_TRIGGER_SET_YES == triggerFlag)) + { + /*Զ·Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + if ((routeLevel == ROUTE_LEVEL_CBTC) && (ROUTE_TYPE_AIRSHAFT != AirShaftType)) + {/* CBTCģʽΪ羮·*//*羮·׷ٰ·*/ + if (ROUTE_STATE_IDLE == routeState) + { + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { + /*ȫδ*/ + /*Ƿ*/ + if (CI_SUCCESS == CheckRouteContainSwitchUseSta(routeId)) + { + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_XUANPAI); /*-->ý·ѡ*/ + } + else + { + /*ô룺*/ + SetErrorData(EFUNC_CHECK_SWITCH_USING, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_SWT_USE_STATE, SWITCH_USING_YES, ESEND_LEVEL_ATS); + } + } + } + else if ((ROUTE_STATE_AUTO_UNLOCK == routeState) || (ROUTE_STATE_AUTO_UNLOCKERR == routeState) || (ROUTE_STATE_HALF_UNLOCK == routeState)) + { + /*·ԶԶ쳣ARBҹգֽ·ȴ*/ + + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { + /*ȫδ*/ + /*ý·*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_YES); + + SetRouteStateFlag(routeId, ROUTE_STATE_FLAG_YES); /*-->ý·״̬תƱ־Ч*/ + (void)SetRouteXuanPaiStartCycNum(routeId, 0u);/*ÿµЧҪ¼ѡʱ*/ + } + } + else if (ROUTE_STATE_NEAR_LOCK == routeState) + { + /*ӽٴΰ··״̬Ϊ·ATS·ʱֱԴͬ㿪ź*/ + /*ɾӦ½·*/ + DeleteSetRouteErrorData(); + + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCK); /*-->ý·*/ + } + else + { + if (FUNC_SWITCH_ON == chSignalReOpenFunc) + { + if ((ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || (ROUTE_STATE_FIRST_LOCKERR == routeState)) + { + /*·״̬ΪգԤա쳣ӽӽ쳣źؿ*/ + startSignalId = GetRouteStartSignalId(routeId); + checkRetVal = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, startSignalId); + + if (CI_TRUE == checkRetVal) + { + /*ɾӦ½·*/ + DeleteSetRouteErrorData(); + /*źؿ*/ + RepeatOpenSignalLogicManage(startSignalId); + } + } + else + { + /**/ + } + } + else + { + /*عرգ޴*/ + } + } + + } + else + { + if (ROUTE_STATE_IDLE == routeState) + { + /*·*/ + if (ROUTE_TYPE_AIRSHAFT == AirShaftType) + {/*羮·ȫδ*/ + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221008 ·ǰ⶯*/ + /*߼μοк״̬*/ + checkResult = RouteAllLogSecOccuClearCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + checkResult = BlockRouteLogSecLockValidCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState); + if (CI_ERROR == checkResult) + {/*羮·ɹӴ*/ + SetErrorData(EFUNC_SET_AIRSHAFT_ERROR, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + } + else + { + + } + } + else + { + /*羮·ɹӴ*/ + SetErrorData(EFUNC_SET_AIRSHAFT_ERROR, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + } + + } + else + {/*羮·ɹӴ*/ /*ԶźŻԶ·*/ + + SetErrorData(EFUNC_SET_AIRSHAFT_ERROR, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + } + } + else + { + /*μοк״̬*/ + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + checkResult = BlockRouteSecLockValidCheck(routeId, &devId, &devState); + if (CI_ERROR == checkResult) + {/*羮·ɹӴ*/ + + SetErrorData(EFUNC_SET_AIRSHAFT_ERROR, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + } + + } + else + {/*羮·ɹӴ*/ /*ԶźŻԶ·*/ + + SetErrorData(EFUNC_SET_AIRSHAFT_ERROR, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + } + } + + + if (CI_SUCCESS == checkResult) + { + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { + /*ȫδ*/ + /*Ƿ*/ + if (CI_SUCCESS == CheckRouteContainSwitchUseSta(routeId)) + { + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_XUANPAI); /*-->ý·ѡ*/ + } + else + { + /*ô룺*/ + SetErrorData(EFUNC_CHECK_SWITCH_USING, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_SWT_USE_STATE, SWITCH_USING_YES, ESEND_LEVEL_ATS); + } + + } + } + + } + else if (ROUTE_STATE_FIRST_XUANPAI != routeState) + { /*·Ԥѡʱκβȴ*//*ԶźźԶ·Ϣ*/ + SetErrorData(EFUNC_SET_AIRSHAFT_ERROR, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, routeState, sendLevel); + } + else + { + /**/ + } + + } + } + } + else + { + ; /* ޴ */ + } +} + + +/* +* ·߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +* edit cgh 20250224 +*/ +void SetLeadRouteLogicManage(const UINT16 signalId) +{ + UINT8 routeState = 0u; + UINT8 routeLevel = 0u; + UINT16 routeId = 0u; + UINT8 setleadRouteCheak = 0U; + UINT8 signalBrightFlag = 0u; + UINT8 cRcWorkMode = 0U; + UINT8 chUseStateCheck = 0U;/*״̬*/ + + + /* ȡϵͳģʽ */ + cRcWorkMode = GetLocalRcWorkMode(); + + signalBrightFlag = GetSignalMaintainState(signalId); /*ά޵*/ + routeId = GetStartSignalRouteId(signalId); + routeLevel = GetRouteLevel(routeId); /*ȡ·*/ + + if ((0u != routeId) && (routeId < ROUTE_SUM_MAX)) + { + if ((ROUTE_LEVEL_BLOC == routeLevel) + || ((RC_WORK_MODE_CI == cRcWorkMode) && (MAINTAIN_STATE_YES == signalBrightFlag))) + { + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + +#if 0 + if (RouteSecFlockVainCheck(routeId) == CI_ERROR) + { + /*η*/ + return; + } +#endif + + /* ·״̬Ϊ·С*/ + if (ROUTE_STATE_IDLE == routeState) + { + /*·*/ + setleadRouteCheak = SetLeadRouteP(routeId); + if (CI_SUCCESS == setleadRouteCheak) + {/*ͨ*/ + /*Ƿ*/ + chUseStateCheck = CheckRouteContainSwitchUseSta(routeId); + if (CI_SUCCESS == chUseStateCheck) + { + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_FIRST_XUANPAI); /*-->ѡ*/ + } + else + { + /*ô룺*/ + SetErrorData(EFUNC_CHECK_SWITCH_USING, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_SWT_USE_STATE, SWITCH_USING_YES, ESEND_LEVEL_ATS); + } + } + else + { + ; /*,·ʧܣںѼ¼*/ + } + + } + else + { + SetErrorData(EFUNC_LEAD_ROUTE_MANAGE_ERROR, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, routeState, ESEND_LEVEL_ATS); + } + } + else if (ROUTE_LEVEL_CBTC == routeLevel) + { + SetErrorData(EFUNC_LEAD_ROUTE_MANAGE_ERROR, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEVEL, routeLevel, ESEND_LEVEL_ATS); + } + else + { + /*Ԥ·ල*/ + } + + } +} + + +/* +* ·ȡ߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongQuXiaoLogicManage(const UINT16 routeId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 autoSigRouteState = 0u; /*ԶźŽ·״̬*/ + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + UINT8 ii = 0u; + UINT8 virCIid = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + autoSigRouteState = GetRouteAutoSigSetState(routeId);/*ȡ·Զź״̬*/ + + if (ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) + { /*Զź*/ + return; + } + + /*ý·ȡ־*/ + SetRouteZongQuXiaoFlag(routeId, ROUTE_ZONGQUXIAO_SET_YES); + + /*ý·Զ·Ч*/ + SetAutoRouteSetFlag(GetRouteAutoRouteId(routeId), AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(GetRouteAutoReturnId(routeId), AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(routeId), ALL_AUTO_RETURN_SET_NO); + if (ROUTE_TYPE_AUTO_TRIGGER == GetAutoTriggerType(routeId)) + {/**/ + SetRouteAutoTriggerFlag(routeId, AUTO_TRIGGER_SET_NO); + } + /* Ż룺жPSDSPKS۳µźŹرգؿ־λȴؿʱյȡʱؿ־ */ + if (GetRouteRecoverOpenFlag(routeId) == ROUTE_RECOVER_STA_WAIT) + { + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY);/*ֹ߼ؿ*/ + } + + overlapSum = GetRouteOverlapSum(routeId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(routeId); /*ȡOverlap ID BUF*/ + for (ii = 0u; ii < overlapSum; ii++) + { + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], 0u); + } +} + + +/* +* ·˽߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongRenJieLogicManage(const UINT16 routeId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 autoSigRouteState = 0u; /*ԶźŽ·״̬*/ + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + UINT8 ii = 0u; + UINT8 virCIid = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + autoSigRouteState = GetRouteAutoSigSetState(routeId); /*ȡ·Զź״̬*/ + + if (ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) + { /*Զź*/ + + return; + } + + /*ý·˽־*/ + (void)SetRouteZongRenJieFlag(routeId, ROUTE_ZONGRENJIE_SET_YES); + + /*ý·Զ·Ч*/ + SetAutoRouteSetFlag(GetRouteAutoRouteId(routeId), AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(GetRouteAutoReturnId(routeId), AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(routeId), ALL_AUTO_RETURN_SET_NO); + if (ROUTE_TYPE_AUTO_TRIGGER == GetAutoTriggerType(routeId)) + {/**/ + SetRouteAutoTriggerFlag(routeId, AUTO_TRIGGER_SET_NO); + } + /* Ż룺жPSDSPKS۳µźŹرգؿ־λȴؿʱյ˽ʱؿ־ */ + if (GetRouteRecoverOpenFlag(routeId) == ROUTE_RECOVER_STA_WAIT) + { + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY);/*ֹ߼ؿ*/ + } + + overlapSum = GetRouteOverlapSum(routeId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(routeId); /*ȡOverlap ID BUF*/ + for (ii = 0u; ii < overlapSum; ii++) + { + SetOverlapXuanPaiStartCycNum(overlapIdBuf[ii], 0u); + } +} + + +/* +* õ߼ +* ˵ UINT16 switchId, ID +* const UINT8 switchSetPos, λ +* ֵ void +*/ +void SetSwitchPositionLogicManage(const UINT16 switchId, const UINT8 switchSetPos) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 check_Result = CI_SUCCESS; + UINT8 lineType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡͨ·*/ + UINT8 chTemp = CI_ERROR; + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + if (CI_TRADITION_RAILWAY == lineType) + {/*ǹ·*/ + if ((switchSetPos != SWITCH_POSITION_DINGWEI) && (switchSetPos != SWITCH_POSITION_FANWEI)) + {/*λЧ*/ + check_Result = CI_ERROR; + } + else + {/*λЧ*/ + check_Result = CI_SUCCESS; + } + } /* zt ɾش 2022-02-15 */ + else + {/*ڵ·*/ + check_Result = CI_ERROR; + } + + if (CI_SUCCESS == check_Result) + {/*λЧ*/ + /*߼*/ + if (CI_SUCCESS == SetSwitchPositionLogicProcess(switchId, switchSetPos, 0U, &chTemp)) + { /*ɹ*/ + (void)SetSwitchDanCaoPosition(switchId, switchSetPos); /*õλñ־*/ + } + else + { /*ʧ*/ + /*Ӽ¼*/ + } + } +} + + +/* +* õ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void SetSwitchDLockLogicManage(const UINT16 switchId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + /*õ߼*/ + if (CI_SUCCESS == SetSwitchDLockLogicProcess(switchId)) + { /*ɹ*/ + + if (SWITCH_TYPE_DOUBLE == GetSwitchType(switchId)) + {/*˫*/ + + SetSwitchLockStatus(SWITCH_PLOCKTYPE_DANSUO, 0u, GetDSwitchOtherId(switchId), SWITCH_LOCK_DANSUO_SET); /*һ*/ + } + + SetSwitchLockStatus(SWITCH_PLOCKTYPE_DANSUO, 0u, switchId, SWITCH_LOCK_DANSUO_SET); /*ñ*/ + } + else + { /*ʧ*/ + + /*???Ӽ¼*/ + } +} + + +/* +* ȡ߼ +* ˵ const UINT16 switchId, ID +* ֵ +*/ +void CancelSwitchDLockLogicManage(const UINT16 switchId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + + /*ȡ߼*/ + if (CI_SUCCESS == CancelSwitchDLockLogicProcess(switchId)) + { /*ɹ*/ + + if (SWITCH_TYPE_DOUBLE == GetSwitchType(switchId)) + {/*˫*/ + + SetSwitchLockStatus(SWITCH_PLOCKTYPE_DANSUO, 0u, GetDSwitchOtherId(switchId), SWITCH_LOCK_DANSUO_CANCEL); /*ȡһ*/ + } + + SetSwitchLockStatus(SWITCH_PLOCKTYPE_DANSUO, 0u, switchId, SWITCH_LOCK_DANSUO_CANCEL); /*ȡ*/ + } + else + { /*ʧ*/ + + /*???Ӽ¼*/ + } +} + + +/* +* õ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void SetSwitchFLockLogicManage(const UINT16 switchId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 checkSum = 0u; + RouteSwitchStruct* routeSwitchStr = NULL; + UINT16 jj = 0u; + UINT16 ii = 0u; + UINT16 kk = 0u; + UINT16 routeSum = 0u; /*·Ŀ (ֶ)*/ + UINT16 routeId = 0u; + UINT16* overlapIdBuf = NULL; /*·ıID*/ + UINT8 overlapSum = 0u; /*·ıĿ*/ + OverlapConditionSwitchStruct* overlapCondSwitchStr = NULL; + UINT8 overlapSwitchSum = 0u; /**/ + RouteProtectSwitchStruct* pRouteProSwitchDataBuf = NULL;/*·ݽṹָ*/ + UINT8 routeProSwitchSum = 0u; /*·*/ + OverlapProtectSwitchStruct* pOverlapProSwitchDataBuf = NULL;/*ιݽṹָ*/ + UINT8 overlapProSwitchSum = 0u; /*ι*/ + + UINT16 doubleSwitchOtherId = 0u;/*˫һId*/ + UINT8 flagCancel = 0u;/*ȡ־*/ + UINT8 flagBreak = 0u;/*жϱ־*/ + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + + + /*õ߼*/ + if (CI_SUCCESS == SetSwitchFLockLogicProcess(switchId)) + { /*ɹ*/ + + if (SWITCH_TYPE_DOUBLE == GetSwitchType(switchId)) + {/*˫*/ + + SetSwitchFLockState(GetDSwitchOtherId(switchId), SWITCH_LOCK_FENGSUO_YES); /*һ*/ + } + + SetSwitchFLockState(switchId, SWITCH_LOCK_FENGSUO_YES); /*ñ*/ + + routeSum = GetRouteCurSum();/*ȡ·*/ + for (ii = 0u; ii < routeSum; ii++) + { /*пܱ·շգԲbreak*/ + routeId = GetRouteId(ii); /*ȡ·ID*/ + routeSwitchStr = GetRouteSwitchData(routeId); + checkSum = GetRouteSwitchSum(routeId); + overlapSum = GetRouteOverlapSum(routeId); + overlapIdBuf = GetRouteOverlapIdBuf(routeId); + doubleSwitchOtherId = GetDSwitchOtherId(switchId); + for (jj = 0u; jj < checkSum; jj++) + { + if ((switchId == routeSwitchStr[jj].SwitchId) || (GetDSwitchOtherId(switchId) == routeSwitchStr[jj].SwitchId)) + { /*·ĵʱȡý·Զ*/ + if (CI_ERROR == CancleAutoFlag(routeId)) + { + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_FLOCK_STATE, SWITCH_LOCK_FENGSUO_YES, ESEND_LEVEL_ATS); + } + break; + } + + } + + pRouteProSwitchDataBuf = GetRouteRelatedProtSwitchData(routeId); /*·ṹָ*/ + routeProSwitchSum = GetRouteRelatedProtectSwitchSum(routeId); /*·*/ + flagCancel = 0u; + if (NULL != pRouteProSwitchDataBuf) + {/*·ʱȡý·Զ*/ + for (jj = 0u; jj < routeProSwitchSum; jj++) + { + if ((switchId == pRouteProSwitchDataBuf[jj].ProtectSwitchId) || + (doubleSwitchOtherId == pRouteProSwitchDataBuf[jj].ProtectSwitchId)) + { + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_FLOCK_STATE, SWITCH_LOCK_FENGSUO_YES, ESEND_LEVEL_ATS); + break; + } + } + } + } + + flagBreak = 0u; + for (jj = 0u; jj < overlapSum; jj++) + { /*·εʱȡԶ*/ + overlapCondSwitchStr = GetOverlapCondSwitchStruct(overlapIdBuf[jj]); + overlapSwitchSum = GetOverlapSwitchSum(overlapIdBuf[jj]); + + if (NULL != overlapCondSwitchStr) + { + for (kk = 0u; kk < overlapSwitchSum; kk++) + { + if ((switchId == overlapCondSwitchStr[kk].SwitchId) || + (doubleSwitchOtherId == overlapCondSwitchStr[kk].SwitchId)) + {/*·ڵĵʱȡý·Զ*/ + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_FLOCK_STATE, SWITCH_LOCK_FENGSUO_YES, ESEND_LEVEL_ATS); + flagBreak = 1u; + break; + } + + } + } + } + + + pOverlapProSwitchDataBuf = GetOverlapRelatedProtSwitStru(overlapIdBuf[jj]); + overlapProSwitchSum = GetOverlapRelatedProtSwitSum(overlapIdBuf[jj]); + if (NULL != pOverlapProSwitchDataBuf) + { + for (kk = 0u; kk < overlapProSwitchSum; kk++) + { + if ((switchId == pOverlapProSwitchDataBuf[kk].ProtectSwitchId) || + (doubleSwitchOtherId == pOverlapProSwitchDataBuf[kk].ProtectSwitchId)) + {/*·ηʱȡý·Զ*/ + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_FLOCK_STATE, SWITCH_LOCK_FENGSUO_YES, ESEND_LEVEL_ATS); + flagBreak = 1u; + break; + } + + } + + } + + } + + if (1u == flagBreak) + { + break; + } + } + } + + } + else + { /*ʧ*/ + + /*???Ӽ¼*/ + } +} + + +/* +* ȡ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void CancelSwitchFLockLogicManage(const UINT16 switchId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + + /*ȡ߼*/ + if (CI_SUCCESS == CancelSwitchFLockLogicProcess(switchId)) + { /*ɹ*/ + + if (SWITCH_TYPE_DOUBLE == GetSwitchType(switchId)) + {/*˫*/ + + SetSwitchFLockState(GetDSwitchOtherId(switchId), SWITCH_LOCK_FENGSUO_NO); /*ȡһ*/ + } + + SetSwitchFLockState(switchId, SWITCH_LOCK_FENGSUO_NO); /*ȡ*/ + } + else + { /*ʧ*/ + + /*???Ӽ¼*/ + } +} + + +/* +* ؿź߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void RepeatOpenSignalLogicManage(const UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT16 routeId = 0u; /*·ID*/ + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 cSGBJDelayOpenFlag = 0U; /*ⱨʱű־*/ + UINT8 cRelZuHeSGBJDelayOpenFlag = 0U; /*Ͻ·ⱨʱű־*/ + UINT32 dwCurDelayOpenStartCycNum = 0U; /*·ⱨʱʼ*/ + UINT32 dwCurCycNum = 0U; + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + + /*·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = 0u; /*·ID*/ + belongCiId = 0u; /*·ID*/ + routeState = 0u; /*·״̬*/ + + + routeId = GetRouteId(ii); /*ȡ·ID*/ + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + continue; + } + + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + continue; + } + + if (signalId != GetRouteStartSignalId(routeId)) + { /*Ϊ·ʼźŻID*/ + + continue; + } + + + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + if ((routeState != ROUTE_STATE_FIRST_LOCKERR) && + (routeState != ROUTE_STATE_YUXIAN_LOCK) && + (routeState != ROUTE_STATE_NEAR_LOCKERR) && + (routeState != ROUTE_STATE_NEAR_LOCK)) + { /*·״̬Ϊ: 쳣&&Ԥ&&ӽ쳣&&ӽ޸ڣ20170209ԭ֧ڽӽʱӦźؿ*/ + if (ROUTE_STATE_DELAY_UNLOCK == routeState) + {/*˽ʱڼ䣬źؿЧ¼ϲֵغATSͷ*/ + SetErrorData(EFUNC_CANCLE_ROUTE, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR, ESEND_LEVEL_ATS); + } + continue; + + } + + if ((ROUTE_ZONGQUXIAO_SET_YES == GetRouteZongQuXiaoFlag(routeId)) || + (ROUTE_ZONGRENJIE_SET_YES == GetRouteZongRenJieFlag(routeId))) + { /*ȡ˽*/ + SetErrorData(EFUNC_CANCLE_ROUTE, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR, ESEND_LEVEL_ATS);/*ȡ˽ʱźؿЧ¼ϲֵغATSͷ*/ + return; + } + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_YES); /*ý·źؿ־*/ + + /*ATSȡԴIvocı־*/ + SetRouteZhefanJiesuoTrainId(routeId, 0U); + SetRouteZhefanJiesuoCyc(routeId, 0U); + + + dwCurCycNum = Get2oo2CurCycleNum(); + cSGBJDelayOpenFlag = GetRouteSGBJDelayFlag(routeId); + cRelZuHeSGBJDelayOpenFlag = GetRelZuHeRouteSGBJDelayFlag(routeId); + dwCurDelayOpenStartCycNum = GetRouteDelayOpenStartCyc(routeId); + + if ((0U == dwCurDelayOpenStartCycNum) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cSGBJDelayOpenFlag) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cRelZuHeSGBJDelayOpenFlag)) + { + SetRouteDelayOpenStartCyc(routeId, dwCurCycNum); + SetRouteOpenSigStartCycNum(routeId, 0U); /*ⱨʱ·źſʱ䣬ⱨʱ½·źſʱ䳬*/ + } + else if((ROUTE_SGBJ_DELAY_OPEN_VALID != cSGBJDelayOpenFlag) || (ROUTE_SGBJ_DELAY_OPEN_VALID != cRelZuHeSGBJDelayOpenFlag)) + { + SetRouteOpenSigStartCycNum(routeId, dwCurCycNum); /*·ⱨʱţźſʼʱ*/ + } + else + { + /*ʱʼڣ*/ + } +#if 0 + /* ñʱ */ + SetOverlapLockStartCycNum(routeId,Get2oo2CurCycleNum()); +#endif + + return; + } +} + +/* +* ź߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +* TIOC V2.0װŻźŻ=>жϽ·ලΪʽ +*/ +void OpenLeadSignalLogicManage(const UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT16 routeId = 0u; /*·ID*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 chKeepWork = CI_ERROR; + UINT8 chRouteLevel = 0U; + UINT16 wRouteStartSignalId = 0U; + UINT8 chSignalOpenCloseState = 0U; + UINT8 chTimeState = CI_TIME_OUT; + UINT8 chFunRet = CI_ERROR; + UINT8 signalBrightFlag = 0u; /*ά޵*/ + UINT8 cRcWorkMode = 0U; /*ϵͳģʽ */ + + /* ȡϵͳģʽ */ + cRcWorkMode = GetLocalRcWorkMode(); + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + chKeepWork = CI_ERROR; + } + else + { + chKeepWork = CI_SUCCESS; + } + + if (CI_SUCCESS == chKeepWork) + { + routeId = GetPhySecRLockBelongRouteId(GetSignalInFirstLockedPhySecId(signalId)); + signalBrightFlag = GetSignalMaintainState(signalId); + chRouteLevel = GetRouteLevel(routeId); + /* ʽCBTCCIģʽȫվƱ־Ч*/ + if ((ROUTE_LEVEL_BLOC == chRouteLevel) || ((ROUTE_LEVEL_CBTC == chRouteLevel) && (RC_WORK_MODE_CI == cRcWorkMode) && (MAINTAIN_STATE_YES == signalBrightFlag))) + { + chKeepWork = CI_SUCCESS; + } + else + { + SetErrorData(EFUNC_CLD_OPEN_LEAD_ROUTE, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEVEL, chRouteLevel, ESEND_LEVEL_ATS); + chKeepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepWork) + { + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + chKeepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepWork) + { + wRouteStartSignalId = GetRouteStartSignalId(routeId); + if (wRouteStartSignalId != signalId) + { + chKeepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepWork) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + chKeepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepWork) + { + belongCiId = GetRouteBelongCiId(routeId); + if (belongCiId != localCiId) + { + chKeepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepWork) + { + routeState = GetRouteState(routeId); + chSignalOpenCloseState = GetSignalOpenCloseState(GetSignalCurColor(signalId)); + chTimeState = SystemOverTimeCheck(GetRouteLeadFaultOpenStartCyc(routeId), GetSystemParaLeadFaultOpenCyc()); + if ((ROUTE_STATE_LEAD_LOCKERR == routeState) && + (SIGNAL_CLOSE == chSignalOpenCloseState)) + { + /*źؿ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_LOCK); /*ý·*/ + + } + else if ((ROUTE_STATE_LEAD_OPEN == routeState) && + (SIGNAL_OPEN == chSignalOpenCloseState) && + (CI_TIME_IN == chTimeState)) + { + /*źŰť*/ + + /*ÿʱ*/ + SetRouteLeadFaultOpenStartCyc(routeId, Get2oo2CurCycleNum()); + } + else if ((ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState)) + { + /*ת·*/ + + /*·쳣 + Ԥա + ӽ + ӽ쳣*/ + chFunRet = LockLeadRouteLogicProcess(routeId); + if (CI_SUCCESS == chFunRet) + { + /*ճɹ*/ + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_LOCK); /*ý·*/ + + } + else + { + /*ʧ*/ + + /*ԭ·״̬*/ + + } + } + else + { + if (ROUTE_STATE_DELAY_UNLOCK == routeState) + {/*·˽ʱڼ䣬źؿЧ¼ϲֵغATSͷ*/ + SetErrorData(EFUNC_CANCLE_ROUTE, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR, ESEND_LEVEL_ATS); + } + else + { + SetErrorData(EFUNC_OPEN_LEAD_SIGNAL, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, routeState, ESEND_LEVEL_ATS); + } + + } + } +} + + +/* +* źŻ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void SetSignalFLockLogicManage(const UINT16 signalId) +{ + UINT16 ii = 0u; + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT16 routeSum = 0u; /*·Ŀ (ֶ)*/ + UINT16 routeId = 0u; + UINT8 checkSum = 0u; + UINT16* dataIdBuf = NULL; + UINT16 jj = 0u; + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + return; + } + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + + return; + } + /*źŻ߼*/ + if (CI_SUCCESS == SetSignalFLockLogicProcess(signalId)) + { /*ɹ*/ + + SetSignalFLockState(signalId, SIGNAL_FENGSUO_YES); /*źŻ*/ + routeSum = GetRouteCurSum();/*ȡ·*/ + for (ii = 0u; ii < routeSum; ii++) + { + routeId = GetRouteId(ii); /*ȡ·ID*/ + dataIdBuf = GetRouteFengSuoSignalIdBuf(routeId); + checkSum = GetRouteFengSuoSignalSum(routeId); + for (jj = 0u; jj < checkSum; jj++) + { + if (signalId == dataIdBuf[jj]) + { /*·źŻȡý·Զ*/ + if (CI_ERROR == CancleAutoFlag(routeId)) + { + SetErrorData(EFUNC_SET_SIGNAL_FLOCK, CI_DEVICE_TYPE_SIGNAL, signalId, ETYPE_SIG_FLOCK_STATE, SIGNAL_FENGSUO_YES, ESEND_LEVEL_ATS); + + } + break; + } + + } + } + + } + else + { /*ʧ*/ + + /*???Ӽ¼*/ + } +} + + +/* +* ȡźŻ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void CancelSignalFLockLogicManage(const UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + + /*ȡźŻ߼*/ + if (CI_SUCCESS == CancelSignalFLockLogicProcess(signalId)) + { /*ɹ*/ + + SetSignalFLockState(signalId, SIGNAL_FENGSUO_NO); /*ȡźŻ*/ + } + else + { /*ʧ*/ + + /*???Ӽ¼*/ + } +} + +/* +* ϵ߼ +* ˵ void +* ֵ void +*/ +void SetStartupUnLockLogicManage(void) +{ + UINT16 phySecId = 0u; /*ID*/ + UINT16 phySecSum = 0u; /**/ + UINT16 logSecSum = 0u; /*߼*/ + UINT16 logSecId = 0u; + UINT8 logState = 0u; + UINT16 ii = 0u; /*α*/ + UINT8 retFlag = CI_ERROR; + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 logBelongCiId = 0u; + UINT8 startLockFlag = 0u; + UINT8 startFengsuoFlag = 0u; + UINT8 ciType = 0u; + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + ciType = GetCiType(localCiId); + startLockFlag = GetStartLockFlag(); + startFengsuoFlag = GetStartFLockFlag(); + + if (CI_TYPE_CLD == ciType) + { + if (CI_START_LOCK_YES == startLockFlag) + { + retFlag = CI_SUCCESS; + } + } + else + { + if ((CI_START_LOCK_YES == startLockFlag) && (CI_START_FLOCK_NO == startFengsuoFlag)) + { + retFlag = CI_SUCCESS; + } + } + + if (CI_SUCCESS == retFlag) + { + phySecSum = GetPhySecCurSum(); /*ȡ*/ + logSecSum = GetLogicSecCurSum(); /*ȡ߼*/ + + if ((0u != phySecSum) && (0u != logSecSum)) + { + + for (ii = 0u; ii < phySecSum; ii++) + {/**/ + belongCiId = 0u; /*·ID*/ + + phySecId = GetPhySecId(ii);/*ȡID*/ + belongCiId = GetPhySecBelongCiId(phySecId); + + if ((phySecId > 0u) && (phySecId < PHYSICAL_SECTION_SUM_MAX)) + { + if (belongCiId == localCiId) + { + + + if (PHYSICAL_SECTION_LOCK_START == GetPhySecLockState(phySecId)) + {/*ϵ*/ + + SetPhySecLockState(phySecId, PHYSICAL_SECTION_LOCK_NO, 0, 0);/*״̬Ϊδ*/ + } + else + { + /* ϵʧ */ + SetStartLockFlag(CI_START_LOCK_ERROR); + + /*¼ͷ͹*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_PHYSEC, + phySecId, + ETYPE_SYSTEM_STARTLOCKE_ERROR, + GetPhySecLockState(phySecId), ESEND_LEVEL_ATS); + + retFlag = CI_ERROR; + } + } + } + if (CI_ERROR == retFlag) + { + break; + } + } + + if (CI_SUCCESS == retFlag) + { + /*߼δ*/ + for (ii = 0u; ii < logSecSum; ii++) + { + logBelongCiId = 0u; /*·ID*/ + logSecId = GetLogicSecId(ii);/*ȡID*/ + logBelongCiId = GetLogSecBelongCiId(logSecId); + + /*߼ID*/ + if ((0u < logSecId) && (LOGIC_SECTION_SUM_MAX > logSecId)) + { + /*DZ*/ + if (logBelongCiId == localCiId) + { + logState = GetLogSecLockState(logSecId); + if (LOG_SECTION_LOCK_START == logState) + { + /*δ*/ + SetLogSecLockState(logSecId, LOG_SECTION_LOCK_NO, 0u, 0u); + } + else + { + /* ϵʧ */ + SetStartLockFlag(CI_START_LOCK_ERROR); + /*¼ͷ͹*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_LOGICSEC, + logSecId, + ETYPE_SYSTEM_STARTLOCKE_ERROR, + logState, ESEND_LEVEL_ATS); + + retFlag = CI_ERROR; + } + } + } + } + } + + } + else + { + /**/ + retFlag = CI_ERROR; + } + + + } + else + { + /**/ + retFlag = CI_ERROR; + } + + if (CI_SUCCESS == retFlag) + { + /* ϵɹ */ + SetStartLockFlag(CI_START_LOCK_NO); + } +} + + +/* +* ·״̬ù·״̬ñͨ +* ˵ + const UINT16 routeId, UINT8 routeState +* ֵ void +* edit cgh 20250224 +*/ +void SetRouteStateManage(const UINT16 routeId, UINT8 routeState) +{ + UINT8 setStateResult = 0u; + UINT8 virCIid = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 trainIdSum = 0u; /*гID*/ + UINT8 i = 0u; /**/ + UINT16* ptrainIdBuff = NULL; /*гID BUFF*/ + UINT8 keepWork = CI_ERROR; + UINT8 retVal = CI_ERROR; + UINT8 localCiType = 0U; + UINT32 curCycNum = 0U; + UINT16 wHalfResReqTrainId = 0U; + UINT8 cSGBJDelayOpenFlag = 0U; /*ⱨʱű־*/ + UINT8 cRelZuHeSGBJDelayOpenFlag = 0U; /*Ͻ·ⱨʱű־*/ + UINT32 dwCurDelayOpenStartCycNum = 0U; /*·ⱨʱʼ*/ + + localCiType = GetLocalCiType(); + curCycNum = Get2oo2CurCycleNum(); + + switch (routeState) + { + case ROUTE_STATE_IDLE: + /*·*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + /*ý·δ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + /*ָ·ITS·¼гIDϢ WQM 20220310*/ + ClearITSRouteApplyTrainIDInfo(routeId); + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + /*ȡ·ķ*/ + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_CANCEL); + /*ATSյıID*/ + SetRouteAtsExpLkOverlapId(routeId, 0u); + /*ý·߼ιԴ־*/ + SetRouteLgcSecShareFlag(routeId, LOGIC_SECTION_RES_SHARE_NO); + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + /*ý·0*/ + SetHalfRouteLockLgcSec(routeId, 0U, NULL); + /*гԴ0*/ + SetHalfRouteTrainLocLgcSec(routeId, 0U, NULL); + /*õɶ־*/ + SetHalfRouteSwitchMoveValid(routeId, ROUTE_HALF_SWITCH_MOVE_INVALID); + /*ԴгIDΪ0*/ + SetHalfRouteResReqTrainId(routeId, 0U); + + /*ùϽ·ⱨʱ־Ч*/ + SetRelZuHeRouteSGBJDelayFlag(routeId, ROUTE_SGBJ_DELAY_OPEN_VALID); + + /*ý·ⱨ־Ч*/ + SetRouteDriveSGBJFlag(routeId, ROUTE_DRIVE_SGBJ_INVALID); + + /*ý·δⱨ*/ + SetRouteHasDrivedSGBJFlag(routeId, ROUTE_HAS_DRIVED_SGBJ_INVALID); + + /*ý·־ΪĬ*/ + SetRouteApplySwitchCheckFlag(routeId, ROUTE_APPLY_SWITCH_CHECK_DEF); + + if (localCiType == CI_TYPE_CLD) + { + SetRouteStopFlagManage(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + if (GetRouteBelongLongRouteId(routeId) > 0u) + { + SetLongRouteStateDeal(GetRouteBelongLongRouteId(routeId), ROUTE_LONG_STATE_IDLE); /*-->ó·*/ + } + SetRouteBelongLongRouteId(routeId, 0u); /*·*/ + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_INIT);/*Ҳ·ָ״̬һν·״̬ת*/ + SetTrainEnterRouteFlag(routeId, TRAIN_ENTER_ROUTE_FLAG_NO);/*·кгʻ·־*/ + } + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_FIRST_XUANPAI: + /*·ѡ*/ + setStateResult = SetRouteState(routeId, routeState); + if (setStateResult == CI_SUCCESS) + { + /*ý·*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_YES); + + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_LEAD_FIRST_XUANPAI: + /*ѡ*/ + setStateResult = SetRouteState(routeId, routeState); + if (setStateResult == CI_SUCCESS) + { + /*ý·*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_YES); + + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + + case ROUTE_STATE_LEAD_XUANPAI: + /*·ѡ*/ + setStateResult = SetRouteState(routeId, routeState); + if (setStateResult == CI_SUCCESS) + { + /*·ûԤѡ̣ҲҪ*/ + /*ý·*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_YES); + + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + case ROUTE_STATE_HALF_FIRST_XUAN: + /*·ֳѡ*/ + setStateResult = SetRouteState(routeId, routeState); + if (setStateResult == CI_SUCCESS) + { + /*ý·*/ + SetRouteHalfPhySecUsingState(routeId, PHYSICAL_SECTION_USING_YES); + + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + case ROUTE_STATE_XUANPAI: + /*·ѡ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + + break; + case ROUTE_STATE_HALF_XUANPAI: + /*·ѡ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + + break; + case ROUTE_STATE_FIRST_LOCK: + /*·*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + /*ý·: */ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NORMAL); + + /*ý·߼: */ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NORMAL); + + /*ý·߼ιԴ־*/ + SetRouteLgcSecShareFlag(routeId, LOGIC_SECTION_RES_SHARE_YES); + /*ȡ¼ָ·ITS·гID,ӵյ߼Σָ·ITS·гIDϢ WQM 20220310*/ + trainIdSum = GetITSRouteApplyTrainIdSum(routeId); + ptrainIdBuff = GetITSRouteApplyTrainIdBuf(routeId); + /*гIDδԽ*/ + if ((0u < trainIdSum) && (ROUTE_APPLY_RECD_TRAIN_SUM_MAX >= trainIdSum) && (NULL != ptrainIdBuff)) + { + for (i = 0u; i < trainIdSum; i++) + { + SetRouteLogicSecResTrainId(routeId, ptrainIdBuff[i]); + } + ClearITSRouteApplyTrainIDInfo(routeId); + } + else + { + ;/* ޴ */ + } + + /*ý·: */ + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_SET); + + /*źſʱ*/ + SetRouteOpenSigStartCycNum(routeId, curCycNum); + + /*·صλ*/ + ClearRouteSwitchDrivePos(routeId); + + /*·صλ*/ + ClearRouteSwitchDanCaoPos(routeId); + + /*ⱨʱʼʱ*/ + cSGBJDelayOpenFlag = GetRouteSGBJDelayFlag(routeId); + cRelZuHeSGBJDelayOpenFlag = GetRelZuHeRouteSGBJDelayFlag(routeId); + dwCurDelayOpenStartCycNum = GetRouteDelayOpenStartCyc(routeId); + if ((0U == dwCurDelayOpenStartCycNum) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cSGBJDelayOpenFlag) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cRelZuHeSGBJDelayOpenFlag)) + { + SetRouteDelayOpenStartCyc(routeId, curCycNum); + SetRouteOpenSigStartCycNum(routeId, 0U); /*ⱨʱ·źſʱ䣬ⱨʱ½·źſʱ䳬*/ + } + else + { + /*ʱʱʼڣ*/ + } + + if (localCiType == CI_TYPE_CLD) + { + SetRouteBelongLongRouteId(routeId, 0u); /*·*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_INIT);/*ζգ׼ź*/ + } + + /*ý·־ΪĬ*/ + SetRouteApplySwitchCheckFlag(routeId, ROUTE_APPLY_SWITCH_CHECK_DEF); + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_HALF_LOCK: + /*·ֳ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + wHalfResReqTrainId = GetHalfRouteResReqTrainId(routeId); + /*ý·δ*/ + SetRouteHalfPhySecUsingState(routeId, PHYSICAL_SECTION_USING_NO); + + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + /*ý·߼: */ + SetRouteHalfLogSecLockState(routeId, LOG_SECTION_LOCK_NORMAL); + + /*ý·: */ + SetRouteHalfPhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NORMAL); + + + /*õɶ־*/ + SetHalfRouteSwitchMoveValid(routeId, ROUTE_HALF_SWITCH_MOVE_INVALID); + /*ý·߼ιԴ־*/ + SetRouteHalfLgcSecShareFlag(routeId, LOGIC_SECTION_RES_SHARE_YES); + + /*ӲгԴ*/ + SetRouteHalfLogSecResTrainId(routeId, wHalfResReqTrainId); + + + /*ý·ַ: */ + SetRouteHalfProSwLockState(routeId, SWITCH_LOCK_PROTECT_SET); + + + /*·صλ*/ + ClearRouteHalfSwitchDrivePos(routeId); + + /*·صλ*/ + ClearRouteHalfSwitchDanCaoPos(routeId); + + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + case ROUTE_STATE_FIRST_LOCKERR: + /*·쳣*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_YUXIAN_LOCK: + /*Ԥ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_YUXIAN_OPEN: + /*Ԥȿ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + /*źſʱ*/ + SetRouteOpenSigStartCycNum(routeId, 0); + + /*ȡ·źؿ־*/ + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); + + /*·֮ǰռ״̬*/ + (void)CleanRoutePhySecPreOccupyState(routeId); + + if ((CI_TYPE_CLD == localCiType) || (CI_TYPE_TCC == localCiType)) + { + (void)SetRouteStopKeepCheckFlag(routeId, GetRouteStopCheckFlag(routeId)); /*ý·ֹͣ鱣ֱ־*/ + (void)SetRouteStopCheckFlag(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + } + else + { + ; + } + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_NEAR_LOCK: + /*ӽ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_NEAR_LOCKERR: + /*ӽ쳣*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_NEAR_OPEN: + /*ӽ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + /*źſʱ*/ + SetRouteOpenSigStartCycNum(routeId, 0); + + /*ȡ·źؿ־*/ + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); + + /*·֮ǰռ״̬*/ + (void)CleanRoutePhySecPreOccupyState(routeId); + + if ((ROUTE_STOPCHECK_SET_YES == GetRouteStopCheckFlag(routeId)) && + ((CI_TYPE_CLD == localCiType) || (CI_TYPE_TCC == localCiType))) + { + (void)SetRouteStopKeepCheckFlag(routeId, GetRouteStopCheckFlag(routeId)); /*ý·ֹͣ鱣ֱ־*/ + (void)SetRouteStopCheckFlag(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + } + else + { + ; + } + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_DELAY_UNLOCK: + /*ʱ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_AUTO_UNLOCK: + /*Զ*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_HALF_UNLOCK: + /*·ս*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + /*ý·0*/ + SetHalfRouteLockLgcSec(routeId, 0U, NULL); + + /*гԴ0*/ + SetHalfRouteTrainLocLgcSec(routeId, 0U, NULL); + /*õɶ־*/ + SetHalfRouteSwitchMoveValid(routeId, ROUTE_HALF_SWITCH_MOVE_INVALID); + + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + case ROUTE_STATE_AUTO_UNLOCKERR: + /*Զ쳣*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + SetRouteXianSuConfirmStt(routeId, ROUTE_XIANSU_CONFIRM_NO); + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_LEAD_LOCK: + /**/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + /*źſʱ*/ + SetRouteOpenSigStartCycNum(routeId, Get2oo2CurCycleNum()); +#if 0 + /* ʱ */ + SetOverlapLockStartCycNum(routeId,0); +#endif + + /*ý·: */ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NORMAL); + + /*ý·߼: */ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NORMAL); + + /*ý·: */ + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_SET); + + /*ý·Զ·Ч*/ + SetAutoRouteSetFlag(GetRouteAutoRouteId(routeId), AUTO_ROUTE_SET_NO); + SetAutoReturnSetFlag(GetRouteAutoReturnId(routeId), AUTO_RETURN_SET_NO); + SetAllAutoReturnSetFlag(GetRouteAllAutoReturnId(routeId), ALL_AUTO_RETURN_SET_NO); + if (ROUTE_TYPE_AUTO_TRIGGER == GetAutoTriggerType(routeId)) + {/**/ + SetRouteAutoTriggerFlag(routeId, AUTO_TRIGGER_SET_NO); + } + else + { + ; + } + /*·صλ*/ + ClearRouteSwitchDrivePos(routeId); + + /*·صλ*/ + ClearRouteSwitchDanCaoPos(routeId); + + /*ⱨʱʼʱ*/ + cSGBJDelayOpenFlag = GetRouteSGBJDelayFlag(routeId); + dwCurDelayOpenStartCycNum = GetRouteDelayOpenStartCyc(routeId); + if ((0U == dwCurDelayOpenStartCycNum) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cSGBJDelayOpenFlag)) + { + SetRouteDelayOpenStartCyc(routeId, curCycNum); + SetRouteOpenSigStartCycNum(routeId, 0U); /*ⱨʱ·źſʱ䣬ⱨʱ½·źſʱ䳬*/ + } + else + { + /*ʱʱʼڣ*/ + } + + /*ý·־ΪĬ*/ + SetRouteApplySwitchCheckFlag(routeId, ROUTE_APPLY_SWITCH_CHECK_DEF); + + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_LEAD_LOCKERR: + /*쳣*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + /*ʱʱ*/ + SetRouteLeadFaultOpenStartCyc(routeId, 0u); + + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + + case ROUTE_STATE_LEAD_OPEN: + /**/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + /*źſʱ*/ + SetRouteOpenSigStartCycNum(routeId, 0u); + + /*ȡ·źؿ־*/ + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); + + /*·֮ǰռ״̬*/ + (void)CleanRoutePhySecPreOccupyState(routeId); + if ((localCiType == CI_TYPE_CLD) || (localCiType == CI_TYPE_TCC)) + { + (void)SetRouteStopKeepCheckFlag(routeId, GetRouteStopCheckFlag(routeId)); /*ý·ֹͣ鱣ֱ־*/ + (void)SetRouteStopCheckFlag(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + } + else + { + ; + } + keepWork = CI_SUCCESS; + } + else + { + /*·״̬쳣*/ + /*xxxxx崻*/ + } + break; + case ROUTE_STATE_HALF_UNLOCKDELAY: + /*гȫպ󣬻гʧͨź󵹼ʱʼ״̬*/ + setStateResult = SetRouteState(routeId, routeState); + if (CI_SUCCESS == setStateResult) + { + keepWork = CI_SUCCESS; + } + else + { + ; + } + break; + default: + + /*·״̬쳣*/ + /*xxxxx崻*/ + break; + } + + if (CI_SUCCESS == keepWork) + { + retVal = CI_SUCCESS; + } + else + { + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + EFUNC_LOGIC_MANAGE_SYETEM, + CI_ERROR, + ETYPE_SYSTEM_EXCEPT, + CI_ERROR, ESEND_LEVEL_ZERO); + retVal = CI_ERROR; + } +} + +/* +* ղ̵ +* ˵ + const UINT16 routeId, UINT8 routeState +* ֵ + CI_ERROR + CI_SUCCESS +*/ +void UpdateZhaoChaStateManage(const UINT16 routeId, UINT8 routeState) +{ + UINT16 wSelfRealyId = 0U;/*ǰģʽղ̵ID*/ + UINT16 wOtherRealyId = 0U;/*һģʽղ̵ID*/ + UINT8 relauDrvState = 0U; + UINT16 realyIdInterface = 0u; + UINT8 relauDrvStateInterface = 0u; + UINT8 endSignalBelongCi = 0u; + UINT8 localCi = 0u; + UINT8 commState = 0u;/*ͨ״̬*/ + UINT8 realyIdState = 0u; + UINT32 routeLockCycNum = 0u; + UINT32 timeOutCycCount = 0u; + UINT8 overTimeCheck = 0u; + UINT16 endSignalId = 0u; + UINT8 funcSwitchSupportRelayInterface = 0u; + UINT8 confirmRelayInterfaceFlag = 0u; + UINT8 chRouteLevel = 0U; + + /*·ලȷ*/ + chRouteLevel = GetRouteLevel(routeId); + + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + wSelfRealyId = GetRouteThisZhaoChaRelayId(routeId); /*ģʽղ̵ID*/ + wOtherRealyId = GetRouteCbtcThisZhaoChaRelayId(routeId); /*CBTCģʽղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + wSelfRealyId = GetRouteCbtcThisZhaoChaRelayId(routeId); /*CBTCģʽղ̵ID*/ + wOtherRealyId = GetRouteThisZhaoChaRelayId(routeId); /*ģʽղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + + /*ȡ̵ӿڱղID*/ + realyIdInterface = GetRouteRelayBenDuanZcIdOnRelay(routeId); + relauDrvStateInterface = GetRelayDriveState(realyIdInterface); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + endSignalId = GetRouteEndSignalId(routeId);/*·նźŻ*/ + endSignalBelongCi = GetSignalBelongCiId(endSignalId); + + /*ȡʱжϢ*/ + routeLockCycNum = GetRouteLockStartCycNum(routeId); + timeOutCycCount = GetSystemParaSignalCloseCyc(); + + /*ӿڱ˼̵*/ + if ((ROUTE_STATE_IDLE == routeState) || + (ROUTE_STATE_FIRST_XUANPAI == routeState) || + (ROUTE_STATE_XUANPAI == routeState) || + (ROUTE_STATE_LEAD_FIRST_XUANPAI == routeState) || + (ROUTE_STATE_LEAD_XUANPAI == routeState)) + { + /*· ģʽղ鶼*/ + + if (0U < wSelfRealyId) + { + relauDrvState = GetRelayDriveState(wSelfRealyId); + if (RELAY_DRIVE_STATE_NULL == relauDrvState) + { + (void)SetRelayDriveState(wSelfRealyId, RELAY_STATE_UP); + SetRelayDriveStartCyc(wSelfRealyId); + } + } + if (0U < wOtherRealyId) + { + relauDrvState = GetRelayDriveState(wOtherRealyId); + if (RELAY_DRIVE_STATE_NULL == relauDrvState) + { + (void)SetRelayDriveState(wOtherRealyId, RELAY_STATE_UP); + SetRelayDriveStartCyc(wOtherRealyId); + } + } + + } + else + { + /*· ģʽӦղ¡һģʽղ*/ + if (0U < wOtherRealyId) + { + relauDrvState = GetRelayDriveState(wOtherRealyId); + if (RELAY_DRIVE_STATE_NULL == relauDrvState) + { + (void)SetRelayDriveState(wOtherRealyId, RELAY_STATE_UP); + SetRelayDriveStartCyc(wOtherRealyId); + } + } + if (0U < wSelfRealyId) + { + (void)SetRelayDriveState(wSelfRealyId, RELAY_STATE_DOWN); + SetRelayDriveStartCyc(wSelfRealyId); + realyIdState = GetRelayCollState(wSelfRealyId); + if (RELAY_STATE_DOWN != realyIdState) + { + overTimeCheck = CheckRelayDriveOutTime(wSelfRealyId, timeOutCycCount); + if (CI_ERROR == overTimeCheck) + { + SetPlatOverFlag(); /*ƽ̨崻*/ + SetErrorData(EFUNC_PLAT_OVER, CI_DEVICE_TYPE_RELAY, wSelfRealyId, ETYPE_ZHAOCHA_ROUTE_OVERTIME, RELAY_STATE_UP, ESEND_LEVEL_ZERO);/*¼崻*/ + } + } + } + } + + /*̵ӿڼ̵*/ + if (0u < realyIdInterface) + { + /*ڱ*/ + if (endSignalBelongCi != localCi) + { + /*ȡͨ״̬*/ + commState = GetLocalCiAndOtherCiTransSta(endSignalBelongCi); + } + /*̵ӿϢ*/ + funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + if ((localCi != endSignalBelongCi) && (TRANSMIT_STATE_BAD == commState) + && (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag) + && (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + if ((ROUTE_STATE_IDLE == routeState) || + (ROUTE_STATE_FIRST_XUANPAI == routeState) || + (ROUTE_STATE_XUANPAI == routeState) || + (ROUTE_STATE_LEAD_FIRST_XUANPAI == routeState) || + (ROUTE_STATE_LEAD_XUANPAI == routeState)) + { + /*· ղ*/ + if (RELAY_DRIVE_STATE_NULL == relauDrvStateInterface) + { + (void)SetRelayDriveState(realyIdInterface, RELAY_STATE_UP); + + } + else + { + /**/ + } + } + else + { + (void)SetRelayDriveState(realyIdInterface, RELAY_STATE_DOWN); + realyIdState = GetRelayCollState(realyIdInterface); + if (RELAY_STATE_DOWN != realyIdState) + { + overTimeCheck = SystemOverTimeCheck(routeLockCycNum, timeOutCycCount); + if (CI_TIME_OUT == overTimeCheck) + { + SetPlatOverFlag(); /*ƽ̨崻*/ + SetErrorData(EFUNC_PLAT_OVER, CI_DEVICE_TYPE_RELAY, realyIdInterface, ETYPE_ZHAOCHA_ROUTE_OVERTIME, RELAY_STATE_UP, ESEND_LEVEL_ZERO);/*¼崻*/ + } + } + } + } + + } +} + +/* +* Զ·߼ +* ˵ const UINT16 autoRouteId, ·ID +* ֵ void +*/ +void SetAutoRouteLogicManage(const UINT16 autoRouteId, const UINT8 virCIid) +{ + UINT8 chkStatus = 0u;/*ʱ*/ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 chFunctionId = EFUNC_SET_AUTOROUTE;/*ID*/ + UINT8 chSendLevel = ESEND_LEVEL_ATS;/*ȼʼΪATS*/ + UINT8 routeSum = 0u; /*Զ··Ŀ (ֶ)*/ + UINT16* routeIdBuf = NULL; /*Զ··ID (ֶ)*/ + UINT8 ii = 0U; + + routeSum = GetAutoRouteIncludeRouteSum(autoRouteId);/*ý··Ŀ*/ + routeIdBuf = GetAutoRouteIncludeRouteBuf(autoRouteId);/*ȡԶ·ӦĻ·*/ + + if ((0u == autoRouteId) || (autoRouteId >= AUTO_ROUTE_SUM_MAX)) + { + chkStatus = CI_ERROR; + } + else + { + chkStatus = CI_SUCCESS; + } + + if (CI_SUCCESS == chkStatus) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + /*Զ··Ƿ򷵻ʧ*/ + chkStatus = CheckAutoRouteBelongVirCI(autoRouteId, virCIid); + } + } + + if (CI_SUCCESS == chkStatus) + { + chkStatus = AutoRouteIsOpposedCheck(autoRouteId,chFunctionId); + + } + + if (CI_SUCCESS == chkStatus) + { + chkStatus = ChekAutoRouteFlockState(autoRouteId); + if (CI_SUCCESS != chkStatus) + { + SetErrorData(chFunctionId, CI_DEVICE_TYPE_AUTOROUTE, autoRouteId, ETYPE_AUTO_ROUTE_FLAG, AUTO_ROUTE_HAVE_BLOCK, chSendLevel); + } + + } + + if (CI_SUCCESS == chkStatus) + { + chkStatus = AutoRouteFloodStateCheck(autoRouteId); + if (CI_SUCCESS != chkStatus) + { + SetErrorData(chFunctionId, CI_DEVICE_TYPE_AUTOROUTE, autoRouteId, ETYPE_AUTO_ROUTE_FLAG, AUTO_ROUTE_FLOOD_STATE_ERR, chSendLevel); + } + } + + if (CI_SUCCESS == chkStatus) + { + SetAutoRouteSetFlag(autoRouteId, AUTO_ROUTE_SET_YES); + + /*Զ·Ľ·*/ + if ((0U != routeSum) && (NULL != routeIdBuf)) + { + for ( ii = 0U; ii < routeSum; ii++) + { + /*ATSȡԴIvocı־гڵȴͷУ°·ĬϽʧܣ*/ + SetRouteZhefanJiesuoTrainId(routeIdBuf[ii], 0U); + SetRouteZhefanJiesuoCyc(routeIdBuf[ii], 0U); + } + } + } +} +/* +* ȡԶ·߼ +* ˵ const UINT16 autoRouteId, ·ID +* ֵ void +*/ +void CancelAutoRouteLogicManage(const UINT16 autoRouteId, const UINT8 virCIid) +{ + UINT8 reVal = CI_ERROR; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + if ((0u == autoRouteId) || (autoRouteId >= AUTO_ROUTE_SUM_MAX)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + reVal = CheckAutoRouteBelongVirCI(autoRouteId, virCIid); + } + + } + + if (CI_SUCCESS == reVal) + { + SetAutoRouteSetFlag(autoRouteId, AUTO_ROUTE_SET_NO); + } +} + + +/* +* Զ۷߼ +* ˵ const UINT16 autoReturnId, ·ID +* ֵ void +*/ +void SetAutoReturnLogicManage(const UINT16 autoReturnId, const UINT8 virCIid) +{ + UINT8 chkStatus = 0u;/*ʱ*/ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 chFunctionId = EFUNC_SET_AUTORETURN;/*ID*/ + UINT8 chSendLevel = ESEND_LEVEL_ATS;/*ȼʼΪATS*/ + + if ((0u == autoReturnId) || (autoReturnId >= AUTO_RETURN_SUM_MAX)) + { + chkStatus = CI_ERROR; + } + else + { + chkStatus = CI_SUCCESS; + } + if (CI_SUCCESS == chkStatus) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + chkStatus = CheckAutoReturnBelongVirCI(autoReturnId, virCIid); + } + } + if (CI_SUCCESS == chkStatus) + {/*Զ۷·ǷеִԶ·Ѱ*/ + chkStatus = AutoReturnIsOpposedCheck(autoReturnId, chFunctionId); + + } + + if (CI_SUCCESS == chkStatus) + {/*Զ۷·ڷźŻηķ*/ + chkStatus = ChekAutoReturnFlockState(autoReturnId); + if (CI_SUCCESS != chkStatus) + { + SetErrorData(chFunctionId, CI_DEVICE_TYPE_AUTORETURN, autoReturnId, ETYPE_AUTO_RETURN_FLAG, AUTO_RETURN_HAVE_BLOCK, chSendLevel); + } + + } + + if (CI_SUCCESS == chkStatus) + {/*Զ۷·ڷ״̬*/ + chkStatus = AutoReturnFloodStateCheck(autoReturnId); + if (CI_SUCCESS != chkStatus) + { + SetErrorData(chFunctionId, CI_DEVICE_TYPE_AUTORETURN, autoReturnId, ETYPE_AUTO_RETURN_FLAG, AUTO_RETURN_FLOOD_STATE_ERR, chSendLevel); + } + } + + if (CI_SUCCESS == chkStatus) + {/*мϣԶ*/ + SetAutoReturnSetFlag(autoReturnId, AUTO_RETURN_SET_YES); + } + + + + +} +/* +* ȡԶ۷߼ +* ˵ const UINT16 autoReturnId, ·ID +* ֵ void +*/ +void CancelAutoReturnLogicManage(const UINT16 autoReturnId, const UINT8 virCIid) +{ + UINT8 reVal = CI_ERROR; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + if ((1U > autoReturnId) || (autoReturnId >= AUTO_RETURN_SUM_MAX)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + if (CI_SUCCESS == reVal) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + reVal = CheckAutoReturnBelongVirCI(autoReturnId, virCIid); + } + } + if (CI_SUCCESS == reVal) + { + SetAutoReturnSetFlag(autoReturnId, AUTO_RETURN_SET_NO); + } +} + + +/* +* ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +void LockOverlapLogicManage(const UINT16 routeId) +{ + UINT8 routeState = 0u; + UINT8 overlapLockState = CI_ERROR; + UINT8 rtOverlapSum = 0u; /*·ıĿ*/ + UINT8 lockOverlapType = 0u; /*ձηʽʶ*/ + UINT16 atsCmdLkOverlapId = 0u; /*ATSֵձID*/ + UINT8 ciCtrModeFlag = 0u; /*ģʽ־*/ + UINT8 autoTriggerType = 0u; /*·Զ·*/ + UINT8 triggerFlag = 0u; /*·Զñ־*/ + UINT8 autoSignalOrRouteValid = 0u; + UINT8 virCIid = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 routeOverlapNum = 0u; + UINT16* pRouteOverlapIdbuf = NULL; + UINT8 routeOverlapNeedCIlockFlag = 0u; + UINT8 overlapLockProcFlag = 0u; + UINT8 overlapFromRouteFlag = 0U; + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + /*cgh-ϲCID-3037-4*/ + triggerFlag = GetRouteAutoTriggerFlag(routeId); /*ȡ·Զ־*/ + /*cgh-ϲCID-2539-10*/ + SetRouteOverlapNeedCIlockM(routeId);/*ǷҪÿձα־*/ + /* + ·Ϊ״̬ʱձΣ + ·쳣ԤȿšԤաӽšӽաӽ쳣Զֽ·ȴ + */ + if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_NEAR_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_AUTO_UNLOCK == routeState) || + (ROUTE_STATE_HALF_UNLOCK == routeState) + ) + { + rtOverlapSum = GetRouteOverlapSum(routeId); /*ȡ·Ŀ*/ + atsCmdLkOverlapId = GetRouteAtsExpLkOverlapId(routeId); /*ȡ·ATSձId*/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + /*cgh-ϲCID-2539-10*/ + routeOverlapNum = GetRouteOverlapSum(routeId); + pRouteOverlapIdbuf = GetRouteOverlapIdBuf(routeId); + if ((0u < routeOverlapNum) && (NULL != pRouteOverlapIdbuf)) + { + virCIid = GetOverlapBelongVirCiId(pRouteOverlapIdbuf[0]); + ciCtrModeFlag = GetVirCImode(virCIid);/*ȡģʽ*/ + } + } + else + { + ciCtrModeFlag = GetCiModeFlag(); /*ȡģʽ*/ + } + + lockOverlapType = GetOverlapLockTypeSwitch(); /*ȡձηʽ 0x02ձ 0x01ATSձ*/ + autoSignalOrRouteValid = AutoSignalOrRouteValid(routeId); + /*ȡ־*/ + routeOverlapNeedCIlockFlag = GetRouteOverlapNeedCIlockFlag(routeId); + overlapLockProcFlag = GetRouteOverlapLockProcFlag(routeId); + if ((FUNC_OVERLAP_LOCK_BY_CI == lockOverlapType) || (CI_MODE_CI_LOCAL == ciCtrModeFlag) + || (OVERLAPCILOCK_YES == routeOverlapNeedCIlockFlag) || (OVERLAP_LOCK_SELF_PROC_YES == overlapLockProcFlag) + || (CI_SUCCESS == autoSignalOrRouteValid) || (AUTO_TRIGGER_SET_YES == triggerFlag)) + { + /*ȡձηʽΪ0x55 ·ģʽ 򣨽·ֻһΣ򣨽·ΪԶ·ͨ۷ȫԶ۷|| Զ·ãʱĬϱ*/ + overlapLockState = LockRouteOverlapProc(routeId);/*Overlap*/ + if (CI_ERROR == overlapLockState) + {/*δɹ£ATS˹ִܷ*/ + /*cgh-ϲCID-2539-1չ*/ + SetRouteOverlapLockProcFlag(routeId, OVERLAP_LOCK_PROC_NO); + if ((CI_MODE_CI_LOCAL != ciCtrModeFlag) && (0u < ciCtrModeFlag) + && (FUNC_OVERLAP_LOCK_BY_ATS == lockOverlapType) && (1U <= rtOverlapSum) && (0U < atsCmdLkOverlapId)) /*ATSձ*/ + { + overlapLockState = LockRouteOverlapAccdToAtsCmd(routeId, atsCmdLkOverlapId); + } + } + else if ((RETURN_WAIT_SWITCH_USING == overlapLockState) || (RETURN_WAIT_SWITCH_CHECK == overlapLockState) || (RETURN_LOCK_ERR_SWITPOS == overlapLockState)) + { + /*ȴ/ȴ/λôձι-ñ־*/ + SetRouteOverlapLockProcFlag(routeId, OVERLAP_LOCK_SELF_PROC_YES); + } + else + { + /*չ*/ + SetRouteOverlapLockProcFlag(routeId, OVERLAP_LOCK_PROC_NO); + } + } + else if ((FUNC_OVERLAP_LOCK_BY_ATS == lockOverlapType) && (rtOverlapSum >= 1u) && (atsCmdLkOverlapId > 0u)) /*ATSձ*/ + {/*ȡձηʽΪ0xaa ·ATSս·Overlap*/ + overlapFromRouteFlag = GetOverlapFromSetRouteCmdFlag(atsCmdLkOverlapId); + if (OVERLAP_ROUTE_FLAG_YES == overlapFromRouteFlag) + { + if (ROUTE_STATE_AUTO_UNLOCK != routeState) + { + overlapLockState = LockRouteOverlapAccdToAtsCmd(routeId, atsCmdLkOverlapId); + } + else + {/*ʲôҲ*/ + } + } + else + {/*·־*/ + overlapLockState = LockRouteOverlapAccdToAtsCmd(routeId, atsCmdLkOverlapId); + } + + if (CI_ERROR == overlapLockState) + { + SetRouteOverlapLockProcFlag(routeId, OVERLAP_LOCK_PROC_NO); /*ý·չ*/ + } + else if ((RETURN_WAIT_SWITCH_USING == overlapLockState) || (RETURN_WAIT_SWITCH_CHECK == overlapLockState) || (RETURN_LOCK_ERR_SWITPOS == overlapLockState)) + { + /*ȴ/ȴ/λô·ATSձι*/ + SetRouteOverlapLockProcFlag(routeId, OVERLAP_LOCK_ATS_PROC_YES); + } + else + { + SetRouteOverlapLockProcFlag(routeId, OVERLAP_LOCK_PROC_NO); /*ý·չ*/ + } + } + else + { + /*ձ*/ + } + +#if 0 + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY); /*ȡ·ʶ*/ + rtOverlapSum = GetRouteOverlapSum(routeId); /*ȡ·Ŀ*/ + atsCmdLkOverlapId = GetRouteAtsExpLkOverlapId(routeId); /*ȡ·ATSձId*/ + ciCtrModeFlag = GetCiModeFlag(); /*ȡģʽ*/ + + if ((LINE_FAOHLHT == lineIdentity) && (rtOverlapSum > 1) && (atsCmdLkOverlapId > 0)) + {/*ͨFAO ·ATSս·Overlap*/ + overlapLockState = LockRouteOverlapAccdToAtsCmd(routeId, atsCmdLkOverlapId); + } + else + { + if ((LINE_FAOHLHT != lineIdentity) || ((LINE_FAOHLHT == lineIdentity) && (CI_MODE_CI_LOCAL == ciCtrModeFlag)) || (1 == rtOverlapSum) + || (CI_SUCCESS == AutoSignalOrRouteValid(routeId)) || ((ROUTE_TYPE_AUTO_TRIGGER == autoTriggerType) && (AUTO_TRIGGER_SET_YES == triggerFlag))) + {/*·ΪFAOHLHTFAOHLHT·վģʽ򣨽·ֻһΣ򣨽·ΪԶ·ͨ۷ȫԶ۷|| Զ·ãʱĬϱΣFAOHLHTǽվģʽ·ζ1ʱһֱȴATSձ*/ + overlapLockState = LockRouteOverlapProc(routeId);/*Overlap*/ + } + + } + retVal = overlapLockState; +#endif + } + else + { + overlapLockProcFlag = GetRouteOverlapLockProcFlag(routeId); + if ((OVERLAP_LOCK_SELF_PROC_YES == overlapLockProcFlag) || (OVERLAP_LOCK_ATS_PROC_YES == overlapLockProcFlag)) + { + /*д洢ں뱾ںŲһ£ʾΪ֧δ뵽ձ̣ñζԵ*/ + ClearOverlopUsing(routeId); + /*չ*/ + SetRouteOverlapLockProcFlag(routeId, OVERLAP_LOCK_PROC_NO); + /*״̬Overlap*/ + } + else + { + /*·βУ*/ + } + } +} + +/* +* ·ν߼ +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +void UnlockOverlapLogicManage(const UINT16 routeId) +{ + UINT8 const routeState = GetRouteState(routeId); + UINT8 overlapLockState = CI_ERROR; + + /* + ·Ϊ״̬ʱձΣ + ·Сӽšӽաӽ쳣Զ쳣Զ쳣ԤաԤȿšֽ·ȴ + */ + if ((routeState == ROUTE_STATE_IDLE) || + (routeState == ROUTE_STATE_NEAR_OPEN) || + (routeState == ROUTE_STATE_NEAR_LOCK) || + (routeState == ROUTE_STATE_NEAR_LOCKERR) || + (routeState == ROUTE_STATE_AUTO_UNLOCK) || + (routeState == ROUTE_STATE_AUTO_UNLOCKERR) || + (routeState == ROUTE_STATE_FIRST_LOCKERR) || + (routeState == ROUTE_STATE_YUXIAN_LOCK) || + (routeState == ROUTE_STATE_YUXIAN_OPEN) || + (routeState == ROUTE_STATE_HALF_UNLOCK)) + { + /*ԶźŻԶ·*/ + overlapLockState = UnlockRouteOverlapProc(routeId); + } + else + { + /**/ + } + +} + +/* +* ȫվ߼ +* ˵ void +* ֵ void +*/ +void SetStartFLockUnLockLogicManage(void) +{ + UINT16 phySecId = 0u; /*ID*/ + UINT16 phySecSum = 0u; /**/ + UINT16 ii = 0u; /*α*/ + + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + UINT8 tmpRet = CI_ERROR; + UINT8 tmpFState = PHYSICAL_SECTION_FLOCK_YES; + + UINT8 chStartFlockFlag = GetStartFLockFlag(); + if (CI_START_FLOCK_YES == chStartFlockFlag ) + { + /*δȫվ*/ + } + else + { + return; + } + + phySecSum = GetPhySecCurSum();/*ȡ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if (0u == phySecSum) + { + return; + } + + for (ii = 0u; ii < phySecSum; ii++) + {/**/ + belongCiId = 0u; /*·ID*/ + + phySecId = GetPhySecId(ii);/*ȡID*/ + belongCiId = GetPhySecBelongCiId(phySecId); + + if ((0u == phySecId) || (phySecId >= PHYSICAL_SECTION_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + continue; + } + + tmpFState = GetPhySecFLockState(phySecId); + + if (PHYSICAL_SECTION_FLOCK_YES == tmpFState) + {/*η*/ + + tmpRet = SetPhySecFLockState(phySecId, PHYSICAL_SECTION_FLOCK_NO);/*η״̬Ϊδ*/ + + if (CI_ERROR == tmpRet) + { + /*η*/ + } + } + else + { + /* ϵʧ */ + SetStartFLockFlag(CI_START_FLOCK_ERROR); + + /*¼ͷ͹*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_PHYSEC, + phySecId, + ETYPE_SYSTEM_STARTLOCKE_ERROR, + GetPhySecLockState(phySecId), ESEND_LEVEL_ATS); + + return; + } + } + + /*ȫվɹ*/ + SetStartFLockFlag(CI_START_FLOCK_NO); +} + +/* +* Ḵλ߼ +* ˵ const UINT16 phySecId, ID +* ֵ void +*/ +void SetSectionResetLogicManage(const UINT16 phySecId, const UINT8 resetType) +{ + UINT8 const functionId = EFUNC_SET_SEC_RESET_LOGIC_MANAGE; /**/ + UINT16 retValid = CI_ERROR; /*ܸλ̵״̬ЧֵĬΪЧ*/ + UINT8 occupyState = 0u; /*ռ״̬*/ + + if ((0u < phySecId) && (PHYSICAL_SECTION_SUM_MAX > phySecId)) + { + occupyState = GetPhySecCurOccupyState(phySecId); + if (SECTION_OCCUPY_YES == occupyState) /*ɼռ*/ + { + occupyState = GetPhySecCurTxOccupyState(phySecId); + if (LOGICSECTION_OCCUPY_TX == occupyState) /*CTռ*/ + { + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, phySecId, ETYPE_PS_NO_UT_CT_OCU_STATE, occupyState, ESEND_LEVEL_ATS); + } + else + { + retValid = GetZFWValidByPhySecId(phySecId); /*ȡμܸλ̵״̬Ч*/ + if (CI_SUCCESS == retValid) /*ЧִмḴλ*/ + { + SetPhySecSectionResetType(phySecId, resetType); + SetPhySecResetStartCycNum(phySecId, Get2oo2CurCycleNum());/*õǰںλḴλʼں*/ + } + else /*ЧḴλʧܣܸλ̵*/ + { + SetCiSendCmdBackInfoData(CI_BACK_PSEC_RESET_ZFW_ERROR, CI_DEVICE_TYPE_PHYSEC, phySecId, 0u, 0u); + } + } + } + else /*ռѹḴλʧܣȱYF0083-761,УȱYF0083-1068*/ + { + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, phySecId, ETYPE_PS_MERGY_OCU_STATE, occupyState, ESEND_LEVEL_ATS); + } + } +} + +/* +* ۷·Ϊͨ· +* ˵ const UINT16 signalId, ͨźŻID +* ֵ void +*/ +void SetThroughRouteManage(const UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + UINT16 signalOutSecId = 0u; /*źŻⷽ*/ + UINT16 signalInSecId = 0u; /*źŻڷ*/ + UINT16 returnRouteId = 0u; /*۷·*/ + UINT16 throughRouteId = 0u; /*ͨ·*/ + UINT16 nextRouteId = 0u; /*һ·*/ + UINT8 returnRouteState = 0u; /*۷·״̬*/ + UINT8 returnRouteIdBelongCiId = 0u;/*۷·ID*/ + UINT8 throughRouteIdBelongCiId = 0u;/*ͨ·ID*/ + UINT8 returnRouteDirection = 0u; + UINT16 reRouteNormalLockPhy = 0u; + UINT8 phyMergeState = 0u; + UINT16 nextRouteLockPhy = 0u; + UINT16 lockPhyBelongRoute = 0u; + UINT8 nextRouteDirection = 0u; + UINT8 haveDirChangeAfterRoute = 0u; + UINT8 haveDirChangeInRoute = 0u; + UINT8 saveReRouteDir = 0u; + UINT8 throughRouteDir = 0u; + UINT16 wLastLgcSecId = 0U; + UINT16 wTrainId = 0u; + UINT8 chTrainSum = 0u; + UINT16 wLogicSecId = 0u; + LogicTrainResStruct* pstLgcResInfo = NULL; + LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + + /*źŻIDϷ*/ + if ((0u == signalId) || (SIGNAL_SUM_MAX <= signalId)) + { + /**/ + } + else + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId == localCiId) && (localCiId != 0u)) + { + + signalOutSecId = GetSignalOutFirstPhySecId(signalId); + signalInSecId = GetSignalInFirstLockedPhySecId(signalId); + + returnRouteId = GetPhySecRLockBelongRouteId(signalOutSecId); + nextRouteId = GetPhySecRLockBelongRouteId(signalInSecId); + throughRouteId = GetRouteThroughRouteId(returnRouteId); + returnRouteIdBelongCiId = GetRouteBelongCiId(returnRouteId);/*ȡ۷·ID*/ + throughRouteIdBelongCiId = GetRouteBelongCiId(throughRouteId);/*ȡͨ·ID*/ + + if ((returnRouteId == 0u) || (nextRouteId == 0u) || (throughRouteId == 0u)) + { + /*·Ч,*/ + } + else + { + + /*ȡ·Ϣ*/ + reRouteNormalLockPhy = GetRouteFirstNormalLockSection(returnRouteId); + phyMergeState = GetPhySecCurMergeState(signalOutSecId); + nextRouteLockPhy = GetPhySecLockState(signalInSecId); + + /*۷·һաҡռá*/ + if ((reRouteNormalLockPhy == signalOutSecId) && + (SECTION_OCCUPY_YES == phyMergeState)) + { + /*һ·һ*/ + if (PHYSICAL_SECTION_LOCK_NORMAL == nextRouteLockPhy) + { + /*ȡս·*/ + lockPhyBelongRoute = GetPhySecRLockBelongRouteId(signalInSecId); + nextRouteDirection = GetRouteDirection(lockPhyBelongRoute); + returnRouteDirection = GetRouteDirection(returnRouteId); + throughRouteDir = GetRouteDirection(throughRouteId); /*۷·Ӧͨ·*/ + + haveDirChangeAfterRoute = GetRouteHaveDirChangePointAfter(returnRouteId); + haveDirChangeInRoute = GetRouteHaveDirChangePointIn(returnRouteId); + + saveReRouteDir = returnRouteDirection; /*·ʵʷ*/ + + /*·󷽻·ڴڷ仯*/ + if ((ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeAfterRoute) || + (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute)) + { + if (CI_SYSTEM_DIRECTION_UP == returnRouteDirection) + { + returnRouteDirection = CI_SYSTEM_DIRECTION_DOWN; + } + else if (CI_SYSTEM_DIRECTION_DOWN == returnRouteDirection) + { + returnRouteDirection = CI_SYSTEM_DIRECTION_UP; + } + else + { + /**/ + } + } + + /*ͬ*/ + if (nextRouteDirection == returnRouteDirection) + { + if ((localCiId == returnRouteIdBelongCiId) && (localCiId == throughRouteIdBelongCiId)) + {/*۷·ͨ·ڱ۷·кͨ·Զ*/ + + /*۷·*/ + returnRouteState = GetRouteState(returnRouteId); /*֮ǰ·δ*/ + wLastLgcSecId = GetRouteInLastLogSecId(returnRouteId); + + chTrainSum = GetLogSecTrainInfoSum(wLastLgcSecId); + pstLgcResInfo = GetLogSecTrainInfo(wLastLgcSecId); + if (NULL != pstLgcResInfo) + { + (void)ComMemCopy(pstLgcResInfo, stTmpResInfo, (UINT16)(sizeof(LogicTrainResStruct) * LOGIC_SECTION_RES_SUM_MAX)); + } + + + SetLogSecLockState(wLastLgcSecId, LOG_SECTION_LOCK_NO, returnRouteId, saveReRouteDir); + + + + SetPhySecLockState(signalOutSecId, PHYSICAL_SECTION_LOCK_NO, returnRouteId, saveReRouteDir); + SetRouteStateManage(returnRouteId, ROUTE_STATE_IDLE); + + /*ڵǰ·*/ + SetLogSecLockState(wLastLgcSecId, LOG_SECTION_LOCK_NORMAL, throughRouteId, throughRouteDir); + + + + if (NULL != pstLgcResInfo) + { + CpyLgcSecResTrain(wLastLgcSecId, chTrainSum, stTmpResInfo); + }/* ߼ԴΪ۷ */ + SetLogSecAllTrainReturnState(wLastLgcSecId, LOGIC_SECTION_TRAIN_RETURN_NO); + + + /*ͨ·*/ + SetPhySecLockState(signalOutSecId, PHYSICAL_SECTION_LOCK_NORMAL, throughRouteId, throughRouteDir); + SetRouteStateManage(throughRouteId, returnRouteState); + + /*ؿһ·ź*/ + RepeatOpenSignalLogicManage(signalId); + + + } + } + } + else + { + /**/ + } + } + else + { + /**/ + } + } + } + else + { + /**/ + } + } +} + + +/* +* źŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void SetYLockSignalOpenStateManage(UINT8 virCIid, UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 belongVirCIid = 0u; + UINT8 allSwitchYLockState = 0u; + UINT8 reVal = CI_ERROR; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + if ((0u == signalId) || (SIGNAL_SUM_MAX <= signalId)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + if (CI_SUCCESS == reVal) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + reVal = CI_ERROR; + } + } + if (CI_SUCCESS == reVal) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCIid = GetSignalBelongVirCiId(signalId); + if ((belongVirCIid == virCIid) && (0u != virCIid)) + { + allSwitchYLockState = GetVirCIAllSwitchYLockState(virCIid); + if (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockState) + { + SetSignalYLockOpenState(signalId, SIGNAL_OPEN); + } + } + } + else + { + allSwitchYLockState = GetAllSwitchYLockFlag(); + if (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockState) + { + SetSignalYLockOpenState(signalId, SIGNAL_OPEN); + } + } + } +} +/* +* õǿ߼ +* ˵ UINT16 switchId, ID +* const UINT8 switchSetPos, λ +* ֵ void +*/ +UINT8 ForceSetSwitchPositionManage(const UINT16 switchId, const UINT8 switchSetPos) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 retVal = 0U; + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + + if (CI_SUCCESS == retVal) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + retVal = CI_ERROR; + } + } + else + { + ; /**/ + } + if (CI_SUCCESS == retVal) + { + if (ForceSetSwitchPosLogicProcess(switchId, switchSetPos) == CI_SUCCESS) + { + retVal = SetSwitchDanCaoPosition(switchId, switchSetPos); /*õλñ־*/ + } + else + { + retVal = CI_ERROR; + } + } + else + { + ; /**/ + } + return retVal; +} + +#if 0 +/* +* ۳ҪؿijվźŻ־ +* ˵ UINT16 signalId, źŻID +* ֵ void +*/ +static void DetainCloseSignalProc(UINT16 signalId) +{ + UINT8 psdCloseSig = 0u; + UINT8 psdIdSum = 0u; + UINT16* psdIdBuf = NULL; + UINT16 curOutRoute = 0u;/*ǰվ·*/ + UINT16 psdReOpenRoute = 0u;/*PSDرպؿվ·*/ + UINT16 i = 0u; + UINT8 j = 0u; + UINT16* routeBuf = NULL; + UINT16 routeNum = 0u; + UINT8 routeSta = 0u;/*·״̬*/ + UINT8 wanZhengSuoBiFlag = 0u;/*ǽ·ǷѾ*/ + + routeBuf = GetStartSignalRouteBuf(signalId);/*ȡʼźŻͬĽ·ID*/ + routeNum = GetStartSignalRouteSum(signalId);/*ȡʼźŻͬĽ·Ŀ*/ + psdIdSum = GetSignalRelatedPsdSum(signalId);/*ȡԸźŻΪվźŻPSDID*/ + psdIdBuf = GetSignalRelatedPsdBuf(signalId);/*ȡԸźŻΪվźŻPSDID*/ + if ((routeNum > 0u) && (routeBuf != NULL)) + { + for (i = 0u; i < routeNum; i++) + { + routeSta = GetRouteState(routeBuf[i]);/*ȡ·״̬*/ + + if ((ROUTE_STATE_YUXIAN_OPEN == routeSta) || (ROUTE_STATE_NEAR_OPEN == routeSta)) + { + SetRouteDetainCloseFlag(routeBuf[i], ROUTE_DETAIN_CLOSE_SIG_YES); + + wanZhengSuoBiFlag = 1u; + } + else if ((ROUTE_STATE_NEAR_LOCKERR == routeSta) || (ROUTE_STATE_YUXIAN_LOCK == routeSta)) + {/*źŻΪVOBCPSDرյģʱҲѿ۳Ҫؿ־*/ + psdCloseSig = 0u; + + if ((psdIdSum > 0u) && (psdIdBuf != NULL)) + { + for (j = 0u; j < psdIdSum; j++) + { + curOutRoute = GetPsdClosedRouteId(psdIdBuf[j]); + psdReOpenRoute = GetPsdToBeOpenedRoute(psdIdBuf[j]); + if (((curOutRoute > 0u) && (curOutRoute == routeBuf[i])) || ((psdReOpenRoute > 0u) && (psdReOpenRoute == routeBuf[i]))) + { + /*˵֮ǰźŻʱΪVOBC򿪳Ŷرյ*/ + psdCloseSig = 1u; + + break; + } + } + } + if (1u == psdCloseSig) + { + SetRouteDetainCloseFlag(routeBuf[i], ROUTE_DETAIN_CLOSE_SIG_YES); + } + else + {/*źŻΪSPKSµźŻرյģʱҲѿ۳Ҫؿ־*/ + if ((ROUTE_CLOSE_SPKS_YES == GetSPKSToRouteCloseFlag(routeBuf[i])) || (ROUTE_SPKS_RE_OPEN_SIG_YES == GetRouteSpksReOpenSigFlag(routeBuf[i]))) + { + SetRouteDetainCloseFlag(routeBuf[i], ROUTE_DETAIN_CLOSE_SIG_YES); + } + } + + wanZhengSuoBiFlag = 1u; + } + else + { + /*ʲô*/ + } + + if (1u == wanZhengSuoBiFlag) + { + break; + } + } + } + +} +#endif + +/* +* ۳߼ +* ˵ const UINT16 signalId, źŻID +* const UINT8 SetState, ״̬ +* ֵ void +*/ +void DetainLogicManage(const UINT16 signalId, const UINT8 setState) +{ + UINT8 detainState = 0u; + UINT8 retResult = CI_SUCCESS; + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + retResult = CI_ERROR; + } + + if (CI_SUCCESS == retResult) + { + detainState = GetSignalDetainFlag(signalId); + if (SIGNAL_DETAIN_ATS == setState) + {/*ATS˹۳*/ + + if ((SIGNAL_DETAIN_NO == detainState) || (SIGNAL_DETAIN_XIANDI_ATSAUTO == detainState) || (SIGNAL_DETAIN_ATS_AUTO == detainState) || (SIGNAL_DETAIN_XIANDI == detainState) || (SIGNAL_RELAY_DETAIN_YES == detainState)) + {/*ǰ״̬Ϊδ۳ATSԶ۳򡾽ֵؿ۳Ӳ߿۳*/ + + retResult = SetSignalDetainFlag(signalId, setState); + } + else + { + retResult = CI_ERROR; + } + } + else if (SIGNAL_DETAIN_ATS_AUTO == setState) + {/*ATSԶ۳*/ + if ((SIGNAL_DETAIN_NO == detainState) || (SIGNAL_DETAIN_XIANDI == detainState) || (SIGNAL_RELAY_DETAIN_YES == detainState)) + {/*ǰ״̬Ϊδ۳򡾽ֵؿ۳Ӳ߿۳*/ + + retResult = SetSignalDetainFlag(signalId, setState); + } + else + { + /*ѰATS˹۳󣬲ٰԶ۳*/ + retResult = CI_ERROR; + } + } + else if (SIGNAL_DETAIN_XIANDI == setState) + {/*ֵذ۳*/ +#if 0 + /*۳ؿվźű־*/ + DetainCloseSignalProc(signalId); +#endif + + if ((SIGNAL_DETAIN_NO == detainState) || (SIGNAL_DETAIN_ATS == detainState) || (SIGNAL_DETAIN_ATS_AUTO == detainState) || (SIGNAL_RELAY_DETAIN_YES == detainState)) + {/*ǰ״̬Ϊδ۳򡾽ATS˹۳򡾽ATSԶ۳Ӳ߿۳*/ + + retResult = SetSignalDetainFlag(signalId, setState); + } + else + { + retResult = CI_ERROR; + } + } + else if (SIGNAL_DETAIN_ATS_NO == setState) + {/*ATSȡ۳*/ + if ((SIGNAL_DETAIN_YES == detainState) || (SIGNAL_DETAIN_XIANDI_ATSAUTO == detainState) || (SIGNAL_DETAIN_ATS == detainState) || (SIGNAL_DETAIN_ATS_AUTO == detainState) || (SIGNAL_RELAY_DETAIN_YES == detainState)) + {/*ǰ״̬Ϊ۳򡾽ATS˹۳򡾽ATSԶ۳Ӳ߿۳*/ + retResult = SetSignalDetainFlag(signalId, setState);/*ȡ۳*/ + } + else + { + retResult = CI_ERROR; + } + } + else if (SIGNAL_DETAIN_XIANDI_NO == setState) + {/*ֵذȡ۳*/ + if ((SIGNAL_DETAIN_YES == detainState) || (SIGNAL_DETAIN_XIANDI_ATSAUTO == detainState) || (SIGNAL_DETAIN_XIANDI == detainState) || (SIGNAL_RELAY_DETAIN_YES == detainState)) + {/*ǰ״̬Ϊ۳򡾽ֵؿ۳Ӳ߿۳*/ + retResult = SetSignalDetainFlag(signalId, setState);/*ȡ۳*/ + } + else + { + retResult = CI_ERROR; + } + } + else if (SIGNAL_DETAIN_CI_RELAY_YES == setState) + {/*Ӳ߿۳*/ + if ((SIGNAL_DETAIN_NO == detainState) || (SIGNAL_DETAIN_XIANDI == detainState) || + (SIGNAL_DETAIN_ATS == detainState) || (SIGNAL_DETAIN_ATS_AUTO == detainState) || + (SIGNAL_DETAIN_YES == detainState) || (SIGNAL_DETAIN_XIANDI_ATSAUTO == detainState)) + {/*ǰ״̬Ϊδ۳򡾽ֵؿ۳򡾽ATS˹۳򡾽ATSԶ۳ֵ+ATSԶ۳ֵ+ATS˹۳*/ + + retResult = SetSignalDetainFlag(signalId, setState); + SetSignalDetainBtnActFlag(signalId, SIGNAL_ZFS_BTN_ACT_FLAG_YES); /*źŻڱ۳ťDZյ۳ÿ۳ťЧ*/ + } + else + { + retResult = CI_ERROR; + } + } + else if (SIGNAL_DETAIN_CI_RELAY_NO == setState) + {/*Ӳ߲۳*/ + if (SIGNAL_RELAY_DETAIN_YES == detainState) + {/*ǰ״̬ΪӲ߿۳*/ + retResult = SetSignalDetainFlag(signalId, setState);/*ȡ۳*/ + SetSignalDetainBtnActFlag(signalId, SIGNAL_ZFS_BTN_ACT_FLAG_NO); /*źŻڱ۳ťDZյ۳ÿ۳ťЧ*/ + } + else + { + retResult = CI_ERROR; + } + } + else + { + retResult = CI_ERROR; + } + } + +#if 0 + if (CI_SUCCESS == retResult && SIGNAL_DETAIN_NO == GetSignalDetainFlag(signalId)) + {/*ATSֵؾδ۳*/ + routeBuf = GetStartSignalRouteBuf(signalId); + routeNum = GetStartSignalRouteSum(signalId); + for (i = 0u; i < routeNum; i++) + { + routeSta = GetRouteState(routeBuf[i]); + + if ((ROUTE_DETAIN_CLOSE_SIG_YES == GetRouteDetainToRouteCloseFlag(routeBuf[i])) && ((ROUTE_STATE_YUXIAN_LOCK == routeSta) || (ROUTE_STATE_NEAR_LOCKERR == routeSta))) + { + SetRouteDetainReOpenSigFlag(routeBuf[i], ROUTE_DETAIN_RE_OPEN_SIG_YES);/*ý·ȡ۳Ҫؿźű־*/ + SetRouteDetainCloseFlag(routeBuf[i], ROUTE_DETAIN_CLOSE_SIG_NO);/*һЧһȡ۳ؿźű־Ч۳½·źŹرձ־*/ + + break; + } + } + } +#endif + if (CI_ERROR == retResult) + { + debug_infor_printf((const)"DetainLogicManage ERROR signalId: %d State:%d \n",signalId,setState); + } +} +/* +* ȫԶ۷߼ +* ˵ const UINT16 allAutoReturnId, ·ID +* ֵ void +*/ +void SetAllAutoReturnLogicManage(const UINT16 allAutoReturnId, const UINT8 virCIid) +{ + UINT8 chkStatus = 0u;/*ʱ*/ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 chFunctionId = EFUNC_SET_ALLAUTORETURN;/*ID*/ + UINT8 chSendLevel = ESEND_LEVEL_ATS;/*ȼʼΪATS*/ + + if ((0u == allAutoReturnId) || (allAutoReturnId >= AUTO_ROUTE_SUM_MAX)) + { + chkStatus = CI_ERROR; + } + else + { + chkStatus = CI_SUCCESS; + } + if (CI_SUCCESS == chkStatus) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + chkStatus = CheckALLAutoReturnBelongVirCI(allAutoReturnId, virCIid); + } + } + + if (CI_SUCCESS == chkStatus) + {/*ȫԶ۷·ǷеִԶ·Ѱ*/ + chkStatus = AllAutoReturnIsOpposedCheck(allAutoReturnId, chFunctionId); + } + + if (CI_SUCCESS == chkStatus) + {/*ȫԶ۷·ڷźŻαεķ*/ + chkStatus = ChekAllAutoReturnFlockState(allAutoReturnId); + if (CI_SUCCESS != chkStatus) + { + SetErrorData(chFunctionId, CI_DEVICE_TYPE_ALLAUTORETURN, allAutoReturnId, ETYPE_ALL_AUTO_RETURN_FLAG, ALL_AUTO_RETURN_HAVE_BLOCK, chSendLevel); + } + + } + + if (CI_SUCCESS == chkStatus) + {/*ȫԶ۷·ڷ״̬*/ + chkStatus = AllAutoReturnFloodStateCheck(allAutoReturnId); + if (CI_SUCCESS != chkStatus) + { + SetErrorData(chFunctionId, CI_DEVICE_TYPE_ALLAUTORETURN, allAutoReturnId, ETYPE_ALL_AUTO_RETURN_FLAG, ALL_AUTO_RETURN_FLOOD_STATE_ERR, chSendLevel); + } + } + + if (CI_SUCCESS == chkStatus) + { + SetAllAutoReturnSetFlag(allAutoReturnId, ALL_AUTO_RETURN_SET_YES); + } + +} + +/* +* ȡȫԶ۷߼ +* ˵ const UINT16 allAutoReturnId, ·ID +* ֵ void +*/ +void CancelAllAutoReturnLogicManage(const UINT16 allAutoReturnId, const UINT8 virCIid) +{ + UINT8 reVal = CI_ERROR; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + if ((allAutoReturnId < 1u) || (allAutoReturnId >= ALL_AUTO_RETURN_SUM_MAX)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + if (CI_SUCCESS == reVal) + { + if (FUNC_SWITCH_ON == includeVirFlag) + { + reVal = CheckALLAutoReturnBelongVirCI(allAutoReturnId, virCIid); + } + } + if (CI_SUCCESS == reVal) + { + SetAllAutoReturnSetFlag(allAutoReturnId, ALL_AUTO_RETURN_SET_NO); + } +} +/* +* ȫԶ۷·߼ +* ˵ void +* ֵ +*/ +void AllAutoReturnLogicManage(void) +{ + UINT16 routeCurSum = 0u; /*ȫԶ۷·Ŀ*/ + UINT16 allAutoReturnRouteId = 0u; /*ȫԶ۷·ID*/ + + UINT8 routeLevel = 0u; /*·ල*/ + + UINT16 ii = 0u; /*ѭ*/ + UINT16 jj = 0u; + UINT8 autoRouteType = 0u; + UINT8 allAutoReturnIncludeSum = 0u; + UINT16* pAllAutoReturnIncludeBuf = NULL; + UINT8 startLockState = 0u; + UINT8 startFlockFlag = 0u; + + routeCurSum = GetAllAutoReturnRouteCurSum(); /*ȡȫԶ۷·*/ + + startLockState = GetStartLockFlag(); /*ȡϵ־*/ + startFlockFlag = GetStartFLockFlag(); /*ȡϵ־*/ + + + if ((CI_START_LOCK_NO != startLockState) || (CI_START_FLOCK_NO != startFlockFlag)) + {/*δȫվδϵ*/ + + } + else + { + + /*źſŹ*/ + YLockSignalOpenManage(); + + + /*ȫԶ۷·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + allAutoReturnRouteId = 0u; + routeLevel = 0u; /*·ල*/ + allAutoReturnIncludeSum = 0u; + pAllAutoReturnIncludeBuf = NULL; + allAutoReturnRouteId = GetAllAutoReturnRouteId(ii); + allAutoReturnIncludeSum = GetAllAutoReturnIncludeRouteSum(allAutoReturnRouteId); /*ȡĽ·Ŀ*/ + pAllAutoReturnIncludeBuf = GetAllAutoReturnIncludeRouteBuf(allAutoReturnRouteId); /*ȡ·ID*/ + + for (jj = 0u; jj < allAutoReturnIncludeSum; jj++) + { + autoRouteType = GetRouteAutoRouteSetState(pAllAutoReturnIncludeBuf[jj]); /*ȡ·ԣжǷΪȫԶ۷·*/ + if (ROUTE_ALLAUTOROUTE_RETURN == autoRouteType) /*ΪȫԶ۷·ִУһ·*/ + { + if ((0u != pAllAutoReturnIncludeBuf[jj]) && (pAllAutoReturnIncludeBuf[jj] < ROUTE_SUM_MAX)) + { + + + /*·ලȷ*/ + routeLevel = RouteLevelConfirmLogicProcess(pAllAutoReturnIncludeBuf[jj]); + + /*ý·ල*/ + SetRouteLevel(pAllAutoReturnIncludeBuf[jj], routeLevel); + + /* ԶȫԶ۷· */ + AllAutoReturnManage(pAllAutoReturnIncludeBuf[jj]); + +#if 0 + + /*#####·״̬#####*/ + if (ROUTE_STATE_IDLE == routeState) + { /*·*/ + + RouteIdleManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_FIRST_XUANPAI == routeState) + {/*·Ԥѡ*/ + + RouteFirstXuanPaiManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_XUANPAI == routeState) + { /*·ѡ*/ + + RouteXuanPaiManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_FIRST_LOCK == routeState) + { /*·*/ + + RouteFirstLockManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_FIRST_LOCKERR == routeState) + { /*·쳣*/ + + RouteFirstLockErrManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_YUXIAN_LOCK == routeState) + { /*Ԥ*/ + + RouteYuXianLockManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_YUXIAN_OPEN == routeState) + { /*Ԥȿ*/ + + RouteYuXianOpenManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_NEAR_LOCK == routeState) + { /*ӽ*/ + + RouteNearLockManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_NEAR_LOCKERR == routeState) + { /*ӽ쳣*/ + + RouteNearLockErrManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_NEAR_OPEN == routeState) + { /*ӽ*/ + + RouteNearOpenManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_DELAY_UNLOCK == routeState) + { /*ʱ*/ + + RouteDelayUnlockManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_AUTO_UNLOCK == routeState) + { /*Զ*/ + + RoutePhySecAutoUnlockManage(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_STATE_AUTO_UNLOCKERR == routeState) + { /*Զ쳣*/ + + RoutePhySecAutoUnlockErrManage(pAllAutoReturnIncludeBuf[jj]); + } + + else + { + /*״̬쳣*/ + /*xxxxx 崻*/ + + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + EFUNC_LOGIC_MANAGE_SYETEM, + CI_ERROR, + ETYPE_SYSTEM_EXCEPT, + CI_ERROR, ESEND_LEVEL_ZERO); + } + + /*ȡ·״̬*/ + routeState = GetRouteState(pAllAutoReturnIncludeBuf[jj]); + + if ((routeState != ROUTE_STATE_IDLE) && + (routeState != ROUTE_STATE_FIRST_XUANPAI) && + (routeState != ROUTE_STATE_XUANPAI) && + (routeState != ROUTE_STATE_LEAD_XUANPAI)) + { + /*·պرźŴ*/ + RouteOpenNeedCloseSignal(pAllAutoReturnIncludeBuf[jj]); + } + + /*#####·ȡ#####*/ + if (ROUTE_ZONGQUXIAO_SET_YES == zongQuXiaoFlag) + { /*Ѱȡ*/ + + RouteZongQuXiaoProc(pAllAutoReturnIncludeBuf[jj]); + } + else if (ROUTE_ZONGRENJIE_SET_YES == zongRenJieFlag) + { /*Ѱ˽*/ + + RouteZongRenJieProc(pAllAutoReturnIncludeBuf[jj]); + } + else + {/**/ + + } +#endif + } + } + } + } + } + +} +/* +* ȫԶ۷· +* úڽ·УִС +* ݵǰ·״̬Լ·Զ· +* +* +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void AllAutoReturnManage(const UINT16 routeId) +{ + + UINT8 autoRouteType = 0u; + UINT8 allAutoReturnRouteType = 0u; + + UINT8 autoRouteFlg = 0u; /* · */ + UINT16 allAutoReturnId = 0u; + UINT16* pAutoIncludeRouteIdbuf = NULL; + UINT8 autoIncludeRouteSum = 0u; + UINT8 ii = 0u; + UINT8 checkResult = 0u; + UINT8 routeValid = 0u; + + UINT16 startSigId = 0u;/*·ʼźŻID*/ + UINT16 outFirstSectionId = 0u;/*ⷽһID*/ + + UINT8 nearBlocSecConditionSum = 0u; /*ʽӽ*/ + RouteNearPhySectionStruct* nearPhySecStru = NULL; /*ӽνṹ*/ + + UINT32 orderOccupyStartCycle = 0u;/*˳ռÿʼ*/ + UINT8 hasNearSecFalg = 0u; /*Ƿнӽ*/ + UINT8 virCIid = GetRouteBelongVirCiId(routeId); + UINT16 recordErrorNum = GetErrorDataCurSum(); + UINT8 chPhySecSameFlag = 0U;/*ص־*/ + + /*ȫԶ·Զ*/ + autoRouteType = GetRouteAutoRouteSetState(routeId); + allAutoReturnId = GetRouteAllAutoReturnId(routeId); + + /* + * ȫԶ۷·: ·гӽͿ԰ + ·޳ӽжִ۳·ǷԿ԰· + * ۳·⣬Ҫг۷ϲҴʱһ۳·ʱ䳤 + */ + if (autoRouteType == ROUTE_ALLAUTOROUTE_RETURN) + { + allAutoReturnRouteType = GetAllAutoReturnRouteType(allAutoReturnId, routeId); + if (allAutoReturnRouteType == ALL_AUTO_RETURN_ROUTE_TYPE_IN) + { + checkResult = SetRouteProc(routeId); + if (CI_SUCCESS == checkResult) + { + nearBlocSecConditionSum = GetRouteBlocNearSecConditionSum(routeId); /*ȡBloc·ӽĿ*/ + nearPhySecStru = GetRouteBlocNearPhySectionStru(routeId); /*ȡBloc·ӽνṹ*/ + + if ((nearBlocSecConditionSum > 0u) && (NULL != nearPhySecStru)) + {/*нӽΣźŻⷽһΣȡһӽ*/ + if ((nearPhySecStru[0].NearPhySecIdBuf != NULL) && (nearPhySecStru[0].NearPhySecSum > 0u)) + { + hasNearSecFalg = 1u; + } + } + + /*нӽΣȡһӽεĵһΣûоȡźŻⷽһ*/ + if (1u == hasNearSecFalg) + { + outFirstSectionId = nearPhySecStru[0].NearPhySecIdBuf[0]; + } + else + { + startSigId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + outFirstSectionId = GetSignalOutFirstPhySecId(startSigId);/*ȡźŻⷽһID*/ + } + + orderOccupyStartCycle = GetSecCurOccupyStartCycNum(outFirstSectionId);/*ȡźŻⷽһռÿʼʱ*/ + + if (orderOccupyStartCycle > 0u) + {/*˳ռÿʼڴ0Ϊ˳ռãɰ*/ + autoRouteFlg = 1u; + } + else + { /*ж뱾۷·ִ۳·Ƿ㣬Կɰ·*/ + autoIncludeRouteSum = GetAllAutoReturnIncludeRouteSum(allAutoReturnId); + pAutoIncludeRouteIdbuf = GetAllAutoReturnIncludeRouteBuf(allAutoReturnId); + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + allAutoReturnRouteType = GetAllAutoReturnRouteType(allAutoReturnId, pAutoIncludeRouteIdbuf[ii]); + if (ALL_AUTO_RETURN_ROUTE_TYPE_OUT == allAutoReturnRouteType) + { + routeValid = GetAllAutoReturnOutRouteValid(pAutoIncludeRouteIdbuf[ii]); + /*޸ԭ򣺵۳Ľ·ת죬ʱĽ· + ȴתij۳ſɰ*/ + if (CI_SUCCESS == routeValid) + { +#if 0 + /*by cgh 20240320 ۳·ǰ·۳·صʱ·԰*/ + chPhySecSameFlag = CheckRoutePhySecSame(routeId, pAutoIncludeRouteIdbuf[ii]); + if (CI_SUCCESS == chPhySecSameFlag) + { + autoRouteFlg = 1u; + } + else + { + autoRouteFlg = 0u; /*ִ۳·*/ + break; + } +#endif + + autoRouteFlg = 0u; /*ִ۳·*/ + break; + } + else + { + autoRouteFlg = 1u; + } + } + } + } + } + } + else if (ALL_AUTO_RETURN_ROUTE_TYPE_OUT == allAutoReturnRouteType) + { + /*㱾·Ļϣжһ۳·ĴʱǷȱ·Ĵʱ䳤ȳԭ򣬱·ܰ*/ + checkResult = SetRouteProc(routeId); + + routeValid = GetAllAutoReturnOutRouteValid(routeId); + if ((CI_SUCCESS == routeValid) && (CI_SUCCESS == checkResult)) + { + autoRouteFlg = 1u; /*۳·*/ + } + else + { + autoRouteFlg = 0u; + } + } + else + { + /**/ + autoRouteFlg = 0u; + } + } + else + { + /*ͨ·*/ + autoRouteFlg = 0u; + } + /* ·Ҫ״̬ */ + if (1u == autoRouteFlg) + { + + /*·δü*/ + if (CI_SUCCESS == RoutePhySectionUseLogicProcess(routeId)) + { +#if 0 + /*ȫδ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_XUANPAI); /*-->ý·ѡ*/ + + /*·ѡ*/ + RouteFirstXuanPaiManage(routeId); +#else + SetCommonRouteLogicManage(routeId); +#endif + } +} + /*cgh-ϲCID-2349-5*/ + SetErrorDataBelongVirCiId(recordErrorNum, virCIid); +} + + +/* +* Գ +* +* +* ˵ void +* ֵ void +*/ +void StartTrianTestManage(void) +{ + UINT8 localCiType = GetLocalCiType(); + UINT8 trainTestStatus = GetCiTrainTestStatus(); + /* ԳͬʱδʼԳҵ£ŴԳ */ + if ((CI_TYPE_SCX == localCiType) && (CI_TRAIN_TEST_OFF == trainTestStatus)) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_START); + + } +} + +/* +* ȡԳ +* +* +* ˵ void +* ֵ void +*/ +void StopTrianTestManage(void) +{ + UINT8 localCiType = GetLocalCiType(); + UINT8 trainTestStatus = GetCiTrainTestStatus(); + /* ԳͬʱδʼԳҵ£ŴԳ */ + if ((CI_TYPE_SCX == localCiType)) + { + if (CI_TRAIN_TEST_ON == trainTestStatus) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_STOP); + } + else if (CI_TRAIN_TEST_START == trainTestStatus) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_OFF); + } + else + { + /* */ + } + } +} + +/* +* ȡʱ +* ˵ +* ֵ + CI_ERROR ʧ + CI_SUCCESS ɹ +*/ +UINT8 CancleLinShiXianSuManage(void) +{ + UINT16 ii; + UINT16 logSecId = 0u; + UINT8 state = 0u; + UINT8 retVal = 0u; + /*ͨ״̬*/ + UINT8 comunicationState = 0u; + UINT8 zcCommState = 0u; + UINT8 localCi = 0u; + UINT8* pSourceIdBuf = NULL; + UINT8 dianshiLinshixiansuFlag = 0U;/*Ƿֵ֧ʽʱ*/ + + + dianshiLinshixiansuFlag = GetCiFunctionSwitchConfig(FUNC_DIANSHI_LINSHIXIANSU_FLAG); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + pSourceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*ȡ뱾ͨŵZCID*/ + + if (pSourceIdBuf != NULL) + { + /*ZCͨ״̬*/ + (void)UpdateCiTransmitState(localCi, CI_SYSTEM_TYPE_ZC, pSourceIdBuf[0]); + zcCommState = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_ZC, pSourceIdBuf[0]); + /*ͨ쳣*/ + if (CI_ERROR == zcCommState) + { + comunicationState = TRANSMIT_STATE_BAD; + } + else + { + comunicationState = TRANSMIT_STATE_GOOD; + } + } + if ((TRANSMIT_STATE_GOOD != comunicationState) && (HAVE_DIANSHILINSHIXIANSU == dianshiLinshixiansuFlag)) + {/*ZCͨŹʱ˹ȡʱ*/ + for (ii = 0u; ii < GetLogicSecCurSum(); ii++) + { + logSecId = GetLogicSecId(ii); /*ȡ߼ID*/ + state = GetLogSecLinShiXianSuSetState(logSecId); /*ȡ߼ʱ״̬*/ + if (LOGSEC_LSXS_SET_STATE_INVALID != state) + {/*ʱ*/ + SetLogSecLinShiXianSuState(logSecId, LOGSEC_LSXS_SET_STATE_NO); /*ȡʱ*/ + } + } + retVal = CI_SUCCESS; + } + else + { + /*¼ͷ͹*/ + SetErrorData(EFUNC_CHECK_LABOUR_CANCEL_VALID, + CI_DEVICE_TYPE_LOGICSEC, + 0, + ETYPE_LOGSEC_LINSHIXIANSU_CANCLE_STATE, + GetLabourCancelLinShiXianState(), ESEND_LEVEL_ATS); + + retVal = CI_ERROR; + } + + LabourCancelLSXianStaMoveProc(LINSHIXIANSU_LABOURCANCLE_YES_STATE); /*˹ȡʱ״̬Ǩ*/ + return retVal; +} +/* +* ȡʱ +* ˵ +* ֵ void +*/ +void CancleLinShiXianSuManage_Vir(const UINT8 virCIid) +{ + UINT16 ii = 0u; + UINT16 logSecId = 0u; + UINT8 state = 0u; + /*ͨ״̬*/ + UINT8 comunicationState = 0u; + UINT8 zcCommState = 0u; + UINT8 localCi = 0u; + UINT8* pSourceIdBuf = NULL; + UINT8 belongVirCIid = 0u; + UINT8 labourCancelLinShiXianState = 0u; + UINT8 dianshiLinshixiansuFlag = 0U;/*Ƿֵ֧ʽʱ*/ + + dianshiLinshixiansuFlag = GetCiFunctionSwitchConfig(FUNC_DIANSHI_LINSHIXIANSU_FLAG); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + pSourceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*ȡ뱾ͨŵZCID*/ + labourCancelLinShiXianState = GetVirCILabourCancelLSXianSta(virCIid); + if (pSourceIdBuf != NULL) + { + /*ZCͨ״̬*/ + (void)UpdateCiTransmitState(localCi, CI_SYSTEM_TYPE_ZC, pSourceIdBuf[0]); + zcCommState = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_ZC, pSourceIdBuf[0]); + /*ͨ쳣*/ + if (CI_ERROR == zcCommState) + { + comunicationState = TRANSMIT_STATE_BAD; + } + else + { + comunicationState = TRANSMIT_STATE_GOOD; + } + } + if ((TRANSMIT_STATE_GOOD != comunicationState) && (HAVE_DIANSHILINSHIXIANSU == dianshiLinshixiansuFlag)) + {/*ZCͨŹʱֵ֧ʽʱ ˹ȡʱ*/ + for (ii = 0u; ii < GetLogicSecCurSum(); ii++) + { + logSecId = GetLogicSecId(ii); /*ȡ߼ID*/ + state = GetLogSecLinShiXianSuSetState(logSecId); /*ȡ߼ʱ״̬*/ + belongVirCIid = GetLogSecBelongVirCiId(logSecId); + if ((LOGSEC_LSXS_SET_STATE_INVALID != state) && (belongVirCIid == virCIid)) + {/*ʱ*/ + SetLogSecLinShiXianSuState(logSecId, LOGSEC_LSXS_SET_STATE_NO); /*ȡʱ*/ + } + } + } + else + { + + + /*¼ͷ͹,*/ + SetErrorData(EFUNC_CHECK_LABOUR_CANCEL_VALID, + CI_DEVICE_TYPE_LOGICSEC, + 0u, + ETYPE_LOGSEC_LINSHIXIANSU_CANCLE_STATE, + labourCancelLinShiXianState, ESEND_LEVEL_ATS); + + } + + LaborCancelLSXSXStaMoveProc_Vir(LINSHIXIANSU_LABOURCANCLE_YES_STATE, virCIid); /*˹ȡʱ״̬Ǩ*/ +} + + +/* +* Գ״̬߼ +* Գ״̬øúúҪʵԳ״̬ת +* ʼ״̬ -----|Գ} ---- >Գʼ ---- |ͬԳ| -->Գ --|Գ| --> Գ +* ---|Գ|-- ------------- | | +* -----------------------|ͬԳ| ------------------------------------------- +* +* +* ˵ +* ֵ +*/ +void CiTrainTestLogicManage(void) +{ + UINT8 trainTestStatus = GetCiTrainTestStatus(); + UINT8 interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*ȡԳ복νӿڷʽ*/ + + NonRouteDataStruct* pNonRoute = NULL; + UINT16 wCollAgreeTryTrainRelayId = 0U;/*Գ߲ɼͬԳ̵ID*/ + UINT8 chRelayCollState = 0U;/*ɼ̵״̬*/ + UINT8 ii = 0; + for (; ii < NONROUTE_ID_NUM_MAX; ii++) + { + pNonRoute = GetNonRouteDataPtr() + ii; + wCollAgreeTryTrainRelayId = GetSCXColAgreeTryRelayIdById(pNonRoute->NonRouteId); + chRelayCollState = GetRelayCollState(wCollAgreeTryTrainRelayId); + switch (trainTestStatus) + { + case CI_TRAIN_TEST_START: /* Գ */ + { + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복ʹü̵ӿ*/ + /* Գťº󣬲ɼͬԳ뵽Գ״̬ */ + if (RELAY_STATE_UP == chRelayCollState) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_ON); + } + } + else if ((SCX_CLD_INTERFACE_COMM == interfaceType) || (SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*Գ복ʹͨŽӿ*/ + if (COMM_TRAIN_TEST_DEV_STATE_VALID == GetCommTrainTestSCXYSKJStatus()) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_ON); + } + } + else if (SCX_NONELOCAL_MODE == interfaceType) + { + SetCommTrainTestSCXYSKJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID); + SetCommTrainTestSCXSQAJStatus(COMM_TRAIN_TEST_DEV_STATE_VALID); + SetCiTrainTestStatus(CI_TRAIN_TEST_ON); + } + else + { + /*ڵĽӿڷʽ*/ + } + } + break; + case CI_TRAIN_TEST_STOP: /* Գťȡ */ + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복ʹü̵ӿ*/ + if (RELAY_STATE_DOWN == chRelayCollState) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_OFF); + } + } + else if ((SCX_CLD_INTERFACE_COMM == interfaceType) || (SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*Գ복ʹͨŽӿ*/ + if (COMM_TRAIN_TEST_DEV_STATE_INVALID == GetCommTrainTestSCXYSKJStatus()) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_OFF); + } + } + else if (SCX_NONELOCAL_MODE == interfaceType) + { + SetCommTrainTestSCXYSKJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID); + SetCommTrainTestSCXSQAJStatus(COMM_TRAIN_TEST_DEV_STATE_INVALID); + SetCiTrainTestStatus(CI_TRAIN_TEST_OFF); + } + else + { + /*ڵĽӿڷʽ*/ + } + break; + case CI_TRAIN_TEST_ON: + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*Գ복ʹü̵ӿ*/ + /* Գ,δɼͬԳΪ˻Գ */ + if (RELAY_STATE_DOWN == chRelayCollState) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_START); + } + } + else if ((SCX_CLD_INTERFACE_COMM == interfaceType) || (SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*Գ복ʹͨŽӿ*/ + if (COMM_TRAIN_TEST_DEV_STATE_INVALID == GetCommTrainTestSCXYSKJStatus()) + { + SetCiTrainTestStatus(CI_TRAIN_TEST_START); + } + } + else + { + /*ڵĽӿڷʽ*/ + } + break; + default: + /*ɴ֧*/ + break; + } + + if (CI_TRAIN_TEST_ON != GetCiTrainTestStatus()) + { + DriveAllSignaleRedClose(); + } + } +} + +/* +* ź +* ˵ +* ֵ +*/ +void DriveAllSignaleRedClose(void) +{ + UINT16 signalSum = GetSignalCurSum(); + UINT16 ii = 0u; + for (ii = 0u; ii < signalSum; ii++) + { + UINT16 signalId = GetSignalId(ii); + /* */ + if (GetSignalBelongCiId(signalId) == GetSystemParaLocalCiId()) + { + SetSignalCurDriveColor(signalId, SIGNAL_DRIVECOLOUR_REDCLOSE); + } + } +} + +/* +* ·ѡ-ȡԶźŽ·ȴռͨ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 + CI_SUCCESS:ȡԶźŽ·ռɹ + CI_ERROR:ȡԶźŽ·ռʧ + RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT:ȴȡ +*/ +UINT8 RouteFirstXuanAutoSigCancelPro(const UINT16 routeId) +{ + UINT8 i = 0u;/*α*/ + UINT8 retVal = CI_ERROR;/*ֵ*/ + UINT8 funcRetVal = CI_SUCCESS;/*ֵ*/ + UINT8 autoSigRouteIncludeSum = 0u;/*·ԶźŽ·Ŀ*/ + UINT16* autoSigRouteIncludeIdBuf = NULL;/*·ԶźŽ·*/ + UINT16 devId = 0u;/*豸Id*/ + UINT8 devState = 0u;/*豸״̬*/ + UINT16 belongRouteId = 0u;/*·Id*/ + UINT8 checkSecLockResult = 0u;/*·ռ*/ + UINT8 funcSwitch = 0U; + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + if (ROUTE_REVERSE_PROPERTY_NO == GetRouteReverseProperty(routeId)) + {/*߱*/ + retVal = CI_SUCCESS; + } + else + { + funcRetVal = RouteFirstXuanAutoSigProc(routeId); + + autoSigRouteIncludeSum = GetReverseRouteIncludeRouteSum(routeId);/*ȡ·ԶźŽ·*/ + autoSigRouteIncludeIdBuf = GetReverseRouteIncludeRouteBuf(routeId);/*ȡ·ԶźŽ·Id*/ + + if (CI_SUCCESS == funcRetVal) + {/*ȡԶźŽ·ɹ鷴·״̬*/ + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221008 ·ǰ⶯*/ + checkSecLockResult = ReverseRouteLogSecLockValCheck(routeId, &devId, &devState); + } + else + { + checkSecLockResult = BlockRouteSecLockValidCheck(routeId, &devId, &devState); + } + + if (CI_SUCCESS == checkSecLockResult) + { + /* ͨ */ + retVal = CI_SUCCESS; + } + else + { + /*·ԶźŽ·жռδͨǷԶźŽ·򷵻صȴ򷵻ش*/ + belongRouteId = GetPhySecRLockBelongRouteId(devId); + if (belongRouteId == 0u) + { + /* 鿴Ƿڷ */ + belongRouteId = GetPhySecPLockBelongRouteId(devId); + } + if (belongRouteId != 0u) + { + for (i = 0u; i < autoSigRouteIncludeSum; i++) + { + if (belongRouteId == autoSigRouteIncludeIdBuf[i]) + { + /*ռδͨԶźŽ·*/ + retVal = RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT; /*ȴ־*/ + break; /*ֻҪԶźţ򷵻صȴ*/ + } + else + { + /*ռδͨβԶźŽ·*/ + retVal = CI_ERROR;/*־*/ + + } + } + } + else + { + retVal = CI_ERROR; + } + } + } + else if (RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT == funcRetVal) + { + /*ȴȡԶźŽ·򷵻صȴ*/ + retVal = RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT; /*ȴ־*/ + } + else + { + /*ȡԶźŽ·ʧܣ򷵻ش*/ + retVal = CI_ERROR;/*־*/ + } + + } + + return retVal; +} + +/* +* ·״̬תƹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteStateFlagManage(const UINT16 routeId) +{ + UINT8 returnValueFunc1 = 0u; /*ֵ*/ + UINT16 atsExpLkOverlapId = 0U; + UINT8 routeStateFlag = 0U; + UINT8 OverlapFromSetRouteCmdFlag = 0U; + UINT8 routeState = 0u; /*·״̬*/ + + /*·*/ + if (CI_SUCCESS == SetRouteProc(routeId)) + { /*ɹ*/ + + /*·ѡ*/ + returnValueFunc1 = RouteFirstXuanProc(routeId); + + if (CI_ERROR == returnValueFunc1) + { + /*ʧ */ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + SetRouteStateFlag(routeId, ROUTE_STATE_FLAG_NO); /*-->ý·״̬תƱ־Ч*/ + } + else if (CI_SUCCESS == returnValueFunc1) + { + /*óɹ*/ + if (GetRouteXuanPaiStartCycNum(routeId) == 0u) + { + (void)SetRouteXuanPaiStartCycNum(routeId, Get2oo2CurCycleNum()); + } + + /*·ѡŴ*/ + RouteXuanPaiStateManage(routeId); + } + else if (RETURN_FIRSTXUANPAI_ERR_WAIT == returnValueFunc1) + { + /*ȴ*/ + } + else + { + /*޲*/ + } + } + else + { + /*·ʧ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + SetRouteStateFlag(routeId, ROUTE_STATE_FLAG_NO); /*-->ý·״̬תƱ־Ч*/ + + } + + routeStateFlag = GetRouteStateFlag(routeId); + if (ROUTE_STATE_FLAG_NO == routeStateFlag) + { + atsExpLkOverlapId = GetRouteAtsExpLkOverlapId(routeId); + if (0U < atsExpLkOverlapId) + { + routeState = GetRouteState(routeId); + OverlapFromSetRouteCmdFlag = GetOverlapFromSetRouteCmdFlag(atsExpLkOverlapId); + if ((OVERLAP_ROUTE_FLAG_YES == OverlapFromSetRouteCmdFlag)&&((ROUTE_STATE_AUTO_UNLOCK== routeState)||(ROUTE_STATE_IDLE == routeState))) /*ATSİ·Dz׷٣ı*/ + { + /*ʧܰ־ɹ÷״̬ñ־*/ + SetOverlapFromSetRouteCmdFlag(atsExpLkOverlapId, OVERLAP_ROUTE_FLAG_NO); + SetRouteAtsExpLkOverlapId(routeId, 0u); /*ATSֵձID*/ + } + } + } +} + + +/* +* ·ѡ״̬תƹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +* modify 20221011 ·ǰ¹ +*/ +void RouteXuanPaiStateManage(const UINT16 routeId) +{ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 NeedForDrvRoutAssoSwit = SWITCH_NEED_DRIV_FALSE; /*ǷҪ*/ + UINT8 routSwitDrvOvtmFlag = 0u;/*·ڵǷʱ־*/ + + /*·չ*/ + returnValue = LockRouteProc(routeId); + + NeedForDrvRoutAssoSwit = CheckRoutAssoSwitNeedDriv(routeId);/*·ǷҪ*/ + + routSwitDrvOvtmFlag = ChekRoutSwitDrivOvtmStat(routeId);/*·ڵǷʱ*/ + + if ((CI_SUCCESS == returnValue) && (SWITCH_NEED_DRIV_FALSE == NeedForDrvRoutAssoSwit)) + { + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + /*ճɹ*/ + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCK); /*-->ý·*/ + + /*·*/ + RouteFirstLockManage(routeId); + SetRouteStateFlag(routeId, ROUTE_STATE_FLAG_NO); /*-->ý·״̬תƱ־Ч*/ + } + else if (((RETURN_LOCK_ERR_SWITPOS == returnValue) && (CI_SUCCESS == routSwitDrvOvtmFlag)) || + ((SWITCH_NEED_DRIV_TRUE == NeedForDrvRoutAssoSwit) && (CI_SUCCESS == returnValue))) + { + /*λòȷ*/ + + /*·*/ + if (CI_ERROR == RouteLockDriveSwitch(routeId, NeedForDrvRoutAssoSwit)) + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + /* ȡ */ + SetRouteStateFlag(routeId, ROUTE_STATE_FLAG_NO); /*-->ý·״̬תƱ־Ч*/ + } + } + else if (RETURN_LOCK_ERR_WAIT_SWCHECK == returnValue) + { + /*ȴ״̬*/ + ; + } + else + { + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + /* ·ʧ */ + SetRouteStateFlag(routeId, ROUTE_STATE_FLAG_NO); /*-->ý·״̬תƱ־Ч*/ + } + +} + +/* +* ͨ·Overlap +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +static void LockRouteOverlapManageHlht(const UINT16 routeId) +{ + UINT8 routeState = 0u; + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + UINT16 i = 0u; + UINT16 tempOvlpId = 0u; + + UINT8 swRet = CI_ERROR; + UINT8 ovlpSwSum = 0u; + OverlapConditionSwitchStruct* tempSwCondBuf = NULL; + + UINT16 swId = 0u; + UINT8 swCurPos = 0u; + UINT8 switchPos = 0u; + UINT16 j = 0u; + + UINT8 phyRet = CI_ERROR; + UINT8 phySecSum = 0u;/*ΰĿ*/ + UINT16* phySecBuf = NULL;/*ΰ*/ + UINT16 tempPhySec = 0u; + + UINT8 ovlpLocked = 0u; + + routeState = GetRouteState(routeId); + + overlapSum = GetRouteOverlapSum(routeId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(routeId); /*ȡOverlap ID BUF*/ + + if ((0u < overlapSum) && (NULL != overlapIdBuf)) + { + if ((routeState == ROUTE_STATE_FIRST_LOCK) || + (routeState == ROUTE_STATE_FIRST_LOCKERR) || + (routeState == ROUTE_STATE_YUXIAN_OPEN) || + (routeState == ROUTE_STATE_YUXIAN_LOCK) || + (routeState == ROUTE_STATE_NEAR_OPEN) || + (routeState == ROUTE_STATE_NEAR_LOCK) || + (routeState == ROUTE_STATE_NEAR_LOCKERR) || + (routeState == ROUTE_STATE_AUTO_UNLOCK) + ) + { + /*˵ȻҪձ*/ + if (ROUTE_OVERLAP_SET_YES != GetRouteOverlapLockFlag(routeId)) + { + /*˵λδ*/ + for (i = 0u; i < overlapSum; i++) + { + tempOvlpId = overlapIdBuf[i]; + + phyRet = CI_SUCCESS; + /**/ + phySecSum = GetOverlapPhySecSum(tempOvlpId); + phySecBuf = GetOverlapPhySecIdBuf(tempOvlpId); + if ((phySecSum > 0u) && (phySecBuf != NULL)) + { + for (j = 0u; j < phySecSum; j++) + { + tempPhySec = phySecBuf[j]; + + if ((0U < GetPhySecPLockBelongRouteId(tempPhySec)) && (GetPhySecLockDirection(tempPhySec) == GetRouteDirection(routeId))) + { + /*do nothing*/ + } + else + { + break; + } + } + + if (j < phySecSum) + { + phyRet = CI_ERROR; + } + } + else + { + phyRet = CI_ERROR; + } + + if (CI_SUCCESS == phyRet) + { + swRet = CI_SUCCESS; + ovlpSwSum = GetOverlapSwitchSum(tempOvlpId); + tempSwCondBuf = GetOverlapCondSwitchStruct(tempOvlpId); + if ((ovlpSwSum > 0u) && (tempSwCondBuf != NULL)) + { + /*ʼ*/ + for (j = 0u; j < ovlpSwSum; j++) + { + swId = tempSwCondBuf[j].SwitchId; + swCurPos = GetSwitchCurPosition(swId); + switchPos = tempSwCondBuf[j].SwitchPosition; + if (switchPos != swCurPos) + { + /*λòȷ*/ + swRet = CI_ERROR; + break; + } + } + } + } + + if ((CI_SUCCESS == swRet) && (CI_SUCCESS == phyRet)) + { + ovlpLocked = 1u; + break; + } + } + + if (1u == ovlpLocked) + { + /*ý·״̬*/ + SetOverlapLockState(tempOvlpId, PHYSICAL_SECTION_LOCK_PROTECT, routeId); /*Overlap*/ + } + else + { + /*˵λδ*/ + for (i = 0u; i < overlapSum; i++) + { + tempOvlpId = overlapIdBuf[i]; + + /*鱣Ƿ㻥ͨ*/ + if (CI_SUCCESS == LockOthCiOvlpCheckHlht(routeId, tempOvlpId)) + { + /*ֻҪһοɳգͻͨ·նźŻ*/ + SetSignalPLockCommand(GetRouteEndSignalId(routeId), SIGNAL_PLOCK_CMD_CREATE); + break; + } + } + } + } + } + } +} + + +/* +* ͨ·Overlap +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +static void UnlockRouteOverlapManageHlht(const UINT16 routeId) +{ + UINT8 routeState = 0u; + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + UINT16 i = 0u; + + UINT8 phySecSum = 0u;/*ΰĿ*/ + UINT16* phySecBuf = NULL;/*ΰ*/ + + UINT16 lockedOvlpId = 0u;/*IDΣڱ״̬*/ + + UINT16 const routeLastSecId = GetRouteLastPhySectionId(routeId); + UINT16 const secStopFlag = GetPhySecStopSteadyFlag(routeLastSecId); + UINT8 const secStopTimeState = SystemOverTimeCheck(GetSecCurOccupyStartCycNum(routeLastSecId), + GetSystemParaProtSecUnlockCyc()); + UINT8 const secLockState = GetPhySecLockState(routeLastSecId); + UINT8 toUnLock = 0u;/*ǷԽⱣ*/ + + routeState = GetRouteState(routeId); + + overlapSum = GetRouteOverlapSum(routeId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(routeId); /*ȡOverlap ID BUF*/ + + if ((0u < overlapSum) && (NULL != overlapIdBuf)) + { +#if 0 + for (i = 0u; i < overlapSum; i++) + { + tempOvlpId = overlapIdBuf[i]; + + /**/ + phySecSum = GetOverlapPhySecSum(tempOvlpId); + phySecBuf = GetOverlapPhySecIdBuf(tempOvlpId); + + for (j = 0u; j < phySecSum; j++) + { + if ((GetPhySecPLockBelongRouteId(phySecBuf[j]) > 0u) && (GetPhySecLockDirection(phySecBuf[j]) == GetRouteDirection(routeId))) + { + /*˵ڵλڽ·״̬*/ + } + else + { + break; + } + } + + if (j == phySecSum) + { + /*˵һΣڲΣŵǰ·ͬ򱣻*/ + break; +} + } +#endif + lockedOvlpId = GetRouteLockedOvlpHlht(routeId); + + if (lockedOvlpId > 0u) + {/*˵·ijһȻ״̬*/ + phySecSum = GetOverlapPhySecSum(lockedOvlpId); + phySecBuf = GetOverlapPhySecIdBuf(lockedOvlpId); + + for (i = 0u; i < phySecSum; i++) + { + if (GetPhySecCurMergeState(phySecBuf[i]) != SECTION_OCCUPY_NO) + { + break; + } + } + + if (i == phySecSum) + { +#if 0 + /*˵ڵȫ*/ + if ((PHYSICAL_SECTION_LOCK_NO == secLockState) || (GetRouteDirection(routeId) != GetPhySecLockDirection(routeLastSecId)) || ((secStopTimeState == CI_TIME_IN) && (secStopFlag == PHYSICAL_SECTION_STOPSTEADY_YES)) || (secStopTimeState == CI_TIME_OUT)) + { + SetSignalPLockCommand(GetRouteEndSignalId(routeId), SIGNAL_PLOCK_CMD_CANCEL); + } +#endif + + toUnLock = 0u;/*óɲԽⱣ*/ + + if (PHYSICAL_SECTION_LOCK_NO == secLockState) + { + /*һδԽ*/ + /* ֱӽ */ + toUnLock = 1u; + } + else + { + if (GetRouteDirection(routeId) == GetPhySecLockDirection(routeLastSecId)) + {/*˵·շ·ķͬ*/ + if (GetPhySecCurMergeState(routeLastSecId) == SECTION_OCCUPY_YES) + { + if (((PHYSICAL_SECTION_STOPSTEADY_YES == secStopFlag) && (CI_TIME_IN == secStopTimeState)) || (CI_TIME_OUT == secStopTimeState)) + { + toUnLock = 1u; + } + else + { + /*δͦͦȵʱδܽ*/ + } + } + else + { + /*һյδռãԽ*/ + } + } + else + { + /*һѾգοԽ*/ + toUnLock = 1u; + } + } + + if (1u == toUnLock) + { + SetSignalPLockCommand(GetRouteEndSignalId(routeId), SIGNAL_PLOCK_CMD_CANCEL); + } + } + } + } +} + +/* +* ΪͨCIձʱOverlap +* ˵ +* const UINT16 overlapId, ID +* const UINT8 lockState, ״̬ +* const UINT8 lockDirշ +* ֵ +*/ +static void SetOvlpLockStateForHlhtCi(const UINT16 overlapId, const UINT8 lockState, const UINT8 lockDir) +{ + UINT8 phySecSum = 0u; /**/ + UINT16* pPhySecIdBuf = NULL; /*νṹָ*/ + UINT8 ii = 0u; /**/ + UINT8 cLogicSectionSum = 0u; /*߼*/ + UINT16* pLogicSectionIdBuf = NULL; /*߼ID*/ + UINT8 cLogicSectionLockState = 0u; + + + phySecSum = GetOverlapPhySecSum(overlapId); /*ȡoverlap*/ + pPhySecIdBuf = GetOverlapPhySecIdBuf(overlapId); /*ȡoverlapID*/ + cLogicSectionSum = GetOverlapLogicSectionSum(overlapId); + pLogicSectionIdBuf = GetOverlapLogicSectionBuf(overlapId); + + + if (0u < phySecSum) + { + if ((PHYSICAL_SECTION_LOCK_PROTECT == lockState) || + (PHYSICAL_SECTION_LOCK_NO == lockState)) + { /*״̬Ч*/ + + /*Overlap״̬*/ + for (ii = 0u; ii < phySecSum; ii++) + { + SetPhySecLockState(pPhySecIdBuf[ii], lockState, UINT16_MAX, lockDir); + } + + if (PHYSICAL_SECTION_LOCK_PROTECT == lockState) + { /**/ + + /*ñ·ID*/ + SetOverlapBelongRouteId(overlapId, UINT16_MAX); + + /*ñιΪ*/ + SetOverlapRelateProtSwLockSta(overlapId, SWITCH_LOCK_PROTECT_SET); + + /*صλ*/ + ClearOverlapSwitchDrivePos(overlapId); + + /*ιλ*/ + ClearOverlapSwitchDanCaoPos(overlapId); + /* ߼η */ + cLogicSectionLockState = LOG_SECTION_LOCK_PROTECT; + + } + else + { /*δ*/ + /*÷ս·IDΪ0*/ + SetOverlapBelongRouteId(overlapId, 0u); + /*ȡιķ*/ + SetOverlapRelateProtSwLockSta(overlapId, SWITCH_LOCK_PROTECT_CANCEL); + /*α־*/ + SetOverlapUnlockApplyFlag(overlapId, UNLOCK_OVERLAP_APPLY_NO); + /* ߼δ */ + cLogicSectionLockState = LOG_SECTION_LOCK_NO; + + } + + + if ((LOG_SECTION_LOCK_NO == cLogicSectionLockState) || (LOG_SECTION_LOCK_PROTECT == cLogicSectionLockState)) + { + /* ߼η״̬ */ + for (ii = 0u; ii < cLogicSectionSum; ii++) + { + SetLogSecLockState(pLogicSectionIdBuf[ii], cLogicSectionLockState, UINT16_MAX, lockDir); + } + } + else + { + + } + } + else + { + ; + } + } + else + { + ; + } +} + +/* +* ͨ·ν״̬ж +* ˵ const UINT16 routeId, ·ID +* ֵ + 0:ijһΣȫ + >0:ijһΣȫ +*/ +static UINT16 GetRouteLockedOvlpHlht(const UINT16 routeId) +{ + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + UINT16 i = 0u, j = 0u; + UINT16 tempOvlpId = 0u; + + UINT8 phySecSum = 0u;/*ΰĿ*/ + UINT16* phySecBuf = NULL;/*ΰ*/ + + UINT16 lockOvlpId = 0u;/*ζڱյıID*/ + + overlapSum = GetRouteOverlapSum(routeId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(routeId); /*ȡOverlap ID BUF*/ + + if (0u < overlapSum) + { + for (i = 0u; i < overlapSum; i++) + { + tempOvlpId = overlapIdBuf[i]; + + /**/ + phySecSum = GetOverlapPhySecSum(tempOvlpId); + phySecBuf = GetOverlapPhySecIdBuf(tempOvlpId); + + for (j = 0u; j < phySecSum; j++) + { + if ((GetPhySecPLockBelongRouteId(phySecBuf[j]) > 0u) && (GetPhySecLockDirection(phySecBuf[j]) == GetRouteDirection(routeId))) + { + /*˵ڵλ״̬·ͬ*/ + } + else + { + break; + } + } + + if (j == phySecSum) + { + /*˵һΣڲΣŵǰ·ͬ򱣻*/ + break; + } + } + + if (i == overlapSum) + { + /*˵·бζδ״̬*/ + lockOvlpId = 0u; + } + else + { + lockOvlpId = tempOvlpId; + } + } + else + { + lockOvlpId = 0u;/*ޱΣΪ·ıδδ״̬*/ + } + + return lockOvlpId; +} + +/* +* ָOverlapIdеãδã +* ˵ UINT16 overlapId, ID +* UINT8 usingState Ƿ SWITCH_USING_YES SWITCH_USING_NOδ +*/ +void SetOverlapRelSwitchUsing(UINT16 overlapId, UINT8 usingState) +{ + UINT8 ii = 0U; + UINT8 overlapContainSwitchSum = 0u; + OverlapConditionSwitchStruct* pOverlapContainSwitchSumIdBuf = NULL; + UINT16 containSwitchId = 0u; + UINT16 proSwitchId = 0u; + + OverlapProtectSwitchStruct* pOverlapProSwitchBuf = NULL; + UINT16 overlapProSwitchSum = 0u; + UINT8 cLocalCiId = 0U; + UINT8 cSwitchBelongCiId = 0U; /**/ + UINT8 cCommState = 0U; /*ͨ״̬*/ + UINT8 cFuncSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); /*Ƿм̵ӿ*/ + UINT8 cConfirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag(); /*̵ӿȷ״̬*/ + UINT8 cSwitchCurUsingState = 0U; /*ǰ״̬*/ + + overlapContainSwitchSum = GetOverlapSwitchSum(overlapId);/*ȡڵĵ*/ + pOverlapContainSwitchSumIdBuf = GetOverlapCondSwitchStruct(overlapId);/*ȡڵĵ*/ + + overlapProSwitchSum = GetOverlapRelatedProtSwitSum(overlapId);/*ȡη*/ + pOverlapProSwitchBuf = GetOverlapRelatedProtSwitStru(overlapId);/*ȡη*/ + + cLocalCiId = GetSystemParaLocalCiId(); + + /* õ״̬ */ + if ((NULL != pOverlapContainSwitchSumIdBuf) && (NULL != pOverlapProSwitchBuf) && (0U != cLocalCiId)) + { + /*ڵ*/ + for (ii = 0U; ii < overlapContainSwitchSum; ii++) + { + /*ȡID*/ + containSwitchId = pOverlapContainSwitchSumIdBuf[ii].SwitchId; + + if (SWITCH_USING_YES == usingState) + { + /*õ*/ + SetSwitchUsingState(containSwitchId, SWITCH_USING_YES, overlapId); + } + else if (SWITCH_USING_NO == usingState) + { + /*õδ*/ + SetSwitchUsingState(containSwitchId, SWITCH_USING_NO, overlapId); + } + else + { + /**/ + } + } + + cFuncSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); /*Ƿм̵ӿڿ*/ + cConfirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag(); /*̵ӿȷ״̬*/ + + /*εķڿ*/ + for (ii = 0U; ii < overlapProSwitchSum; ii++) + { + proSwitchId = pOverlapProSwitchBuf[ii].ProtectSwitchId; + cSwitchCurUsingState = GetSwitchUsingState(proSwitchId); + cSwitchBelongCiId = GetSwitchBelongCiId(proSwitchId); + if (SWITCH_USING_YES == usingState) + { + if (cLocalCiId == cSwitchBelongCiId) + { + /*õ*/ + SetSwitchUsingState(proSwitchId, SWITCH_USING_YES, overlapId); + } + else + { + cCommState = GetLocalCiAndOtherCiTransSta(cSwitchBelongCiId); /*ͨ״̬*/ + if ((TRANSMIT_STATE_BAD == cCommState) && (CICI_RELAY_INTERFACE_CONFIRM_YES == cConfirmRelayInterfaceFlag) && (FUNC_SWITCH_ON == cFuncSwitch)) + { + /*õ*/ + SetSwitchUsingState(proSwitchId, SWITCH_USING_YES, overlapId); + } + else + { + if (SWITCH_USING_NO == cSwitchCurUsingState) + { + /*õ*/ + SetSwitchUsingState(proSwitchId, SWITCH_USING_APPLY, overlapId); + } + else + { + /*/ã*/ + } + } + } + } + else if (SWITCH_USING_NO == usingState) + { + if (cLocalCiId == cSwitchBelongCiId) + { + /*õδ*/ + SetSwitchUsingState(proSwitchId, SWITCH_USING_NO, overlapId); + } + else + { + cCommState = GetLocalCiAndOtherCiTransSta(cSwitchBelongCiId); /*ͨ״̬*/ + if ((TRANSMIT_STATE_BAD == cCommState) && (CICI_RELAY_INTERFACE_CONFIRM_YES == cConfirmRelayInterfaceFlag) && (FUNC_SWITCH_ON == cFuncSwitch)) + { + /*õδ*/ + SetSwitchUsingState(proSwitchId, SWITCH_USING_NO, overlapId); + } + else + { + if ((SWITCH_USING_YES == cSwitchCurUsingState) || (SWITCH_USING_APPLY == cSwitchCurUsingState)) + { + /*õȡ*/ + SetSwitchUsingState(proSwitchId, SWITCH_USING_CANCEL, overlapId); + } + else + { + /*δδã*/ + } + } + } + } + else + { + /**/ + } + } + } + else + { + /*μʧܣ*/ + } +} + +/* +* ȡָRouteIdеǷ +* ˵ UINT16 routeId, ·ID +* ֵ UINT8 Ƿ CI_ERROR CI_SUCCESSδ +*/ +UINT8 CheckRouteContainSwitchUseSta(UINT16 routeId) +{ + UINT8 ii = 0; + UINT8 jj = 0; + UINT8 const routeContainSwitchSum = GetRouteSwitchSum(routeId); + RouteSwitchStruct* const pRouteContainSwitchSumIdBuf = GetRouteSwitchData(routeId); + UINT8 overlapContainSwitchSum = 0u; + OverlapConditionSwitchStruct* overlapContainSwitchSumIdBuf = NULL; + UINT16 switchBelongOverlapId = 0u; + UINT16 AssocswitchBelongOverlapId = 0u; + + RouteProtectSwitchStruct* pRouteProSwitchData = NULL;/*·*/ + UINT16 routeProSwitchSum = 0u;/*·*/ + + OverlapProtectSwitchStruct* pOverlapProSwitchData = NULL;/*η*/ + UINT16 overlapProSwitchSum = 0u; + + UINT8 AssocswitchSum = 0u; /*Ŀ*/ + UINT8 kk = 0; /*ѭ*/ + UINT8 returnValue = CI_SUCCESS; + RouteAssocSwitchStruct routeAssocSwitchStru = { 0u }; /**/ + AssocswitchSum = GetRouteAssocSwitchSum(routeId); /*ȡ·Ŀ*/ + + pRouteProSwitchData = GetRouteRelatedProtSwitchData(routeId);/*ȡ·*/ + routeProSwitchSum = GetRouteRelatedProtectSwitchSum(routeId);/*ȡ·*/ + + /* õ״̬ */ + if ((NULL == pRouteContainSwitchSumIdBuf) || (NULL == pRouteProSwitchData)) + { + /*ָΪ*/ + } + else + { + /* һѱ 򷵻ѱ*/ + for (ii = 0U; ii < routeContainSwitchSum; ii++) + { + switchBelongOverlapId = GetSwitchBelongOverlapId(pRouteContainSwitchSumIdBuf[ii].SwitchId); + if (switchBelongOverlapId > 0u) + { + /*ID0 ʾб ֵΪCI_ERROR*/ + returnValue = CI_ERROR; + + /*ʱȻ ζԵλ·Եλһ 򷵻سɹ ·Գ*/ + /*õıIDȡñ*/ + overlapContainSwitchSum = GetOverlapSwitchSum(switchBelongOverlapId); + overlapContainSwitchSumIdBuf = GetOverlapCondSwitchStruct(switchBelongOverlapId); + + /*ΰе ҵһѭѭĵIDһµıΰ*/ + for (jj = 0U; jj < overlapContainSwitchSum; jj++) + { + if ((overlapContainSwitchSumIdBuf[jj].SwitchId == pRouteContainSwitchSumIdBuf[ii].SwitchId) && + (overlapContainSwitchSumIdBuf[jj].SwitchPosition == pRouteContainSwitchSumIdBuf[ii].SwitchPosition)) + { + /* ·Ըõλһ 򽫸ղŷصCI_ERRORΪCI_SUCCESS*/ + returnValue = CI_SUCCESS; + break; + } + } + if (CI_ERROR == returnValue) + {/*ûҵ*/ + overlapProSwitchSum = GetOverlapRelatedProtSwitSum(switchBelongOverlapId); + pOverlapProSwitchData = GetOverlapRelatedProtSwitStru(switchBelongOverlapId); + + if (NULL != pOverlapProSwitchData) + { + for (jj = 0U; jj < overlapProSwitchSum; jj++) + { + if ((pOverlapProSwitchData[jj].ProtectSwitchId == pRouteContainSwitchSumIdBuf[ii].SwitchId) && + (pOverlapProSwitchData[jj].ProtectPosition == pRouteContainSwitchSumIdBuf[ii].SwitchPosition)) + { + /* ·Ըõλһ 򽫸ղŷصCI_ERRORΪCI_SUCCESS*/ + returnValue = CI_SUCCESS; + break; + } + } + } + } + + if (CI_ERROR == returnValue) + { + break; + } + } + + } + + /*·*/ + if (CI_SUCCESS == returnValue) + { + for (ii = 0U; ii < routeProSwitchSum; ii++) + { + switchBelongOverlapId = GetSwitchBelongOverlapId(pRouteProSwitchData[ii].ProtectSwitchId); + if (switchBelongOverlapId > 0u) + { + /*ID0 ʾб ֵΪCI_ERROR*/ + returnValue = CI_ERROR; + + /*ʱȻ ζԵλ·Եλһ 򷵻سɹ ·Գ*/ + /*õıIDȡñ*/ + overlapContainSwitchSum = GetOverlapSwitchSum(switchBelongOverlapId); + overlapContainSwitchSumIdBuf = GetOverlapCondSwitchStruct(switchBelongOverlapId); + + /*ΰе ҵһѭѭĵIDһµıΰ*/ + for (jj = 0U; jj < overlapContainSwitchSum; jj++) + { + if ((overlapContainSwitchSumIdBuf[jj].SwitchId == pRouteProSwitchData[ii].ProtectSwitchId) && + (overlapContainSwitchSumIdBuf[jj].SwitchPosition == pRouteProSwitchData[ii].ProtectPosition)) + { + /* ·Ըõλһ 򽫸ղŷصCI_ERRORΪCI_SUCCESS*/ + returnValue = CI_SUCCESS; + break; + } + } + + if (CI_ERROR == returnValue) + {/*ûҵ*/ + overlapProSwitchSum = GetOverlapRelatedProtSwitSum(switchBelongOverlapId); + pOverlapProSwitchData = GetOverlapRelatedProtSwitStru(switchBelongOverlapId); + + if (NULL != pOverlapProSwitchData) + { + for (jj = 0U; jj < overlapProSwitchSum; jj++) + { + if ((pOverlapProSwitchData[jj].ProtectSwitchId == pRouteProSwitchData[ii].ProtectSwitchId) && + (pOverlapProSwitchData[jj].ProtectPosition == pRouteProSwitchData[ii].ProtectPosition)) + { + /* ·Ըõλһ 򽫸ղŷصCI_ERRORΪCI_SUCCESS*/ + returnValue = CI_SUCCESS; + break; + } + } + } + } + + if (CI_ERROR == returnValue) + { + break; + } + } + + } + } + + /**/ + if (CI_SUCCESS == returnValue) + { + for (kk = 0U; kk < AssocswitchSum; kk++) + { + GetRouteAssocSwitchData(routeId, kk, &routeAssocSwitchStru);/*ȡ*/ + + AssocswitchBelongOverlapId = GetSwitchBelongOverlapId(routeAssocSwitchStru.SwitchId); + if (AssocswitchBelongOverlapId > 0u) + { + returnValue = CI_ERROR; + /*ʱȻ ζԵλ·Եλһ 򷵻سɹ*/ + /*õıIDȡñ*/ + overlapContainSwitchSum = GetOverlapSwitchSum(AssocswitchBelongOverlapId); + overlapContainSwitchSumIdBuf = GetOverlapCondSwitchStruct(AssocswitchBelongOverlapId); + + /*ΰе ҵһѭѭĵIDһµıΰ*/ + for (jj = 0U; jj < overlapContainSwitchSum; jj++) + { + if ((overlapContainSwitchSumIdBuf[jj].SwitchId == routeAssocSwitchStru.SwitchId) && (overlapContainSwitchSumIdBuf[jj].SwitchPosition == routeAssocSwitchStru.SwitchPosition)) + { + /* ·Ըõλһ 򽫸ղŷصCI_ERRORΪCI_SUCCESS*/ + returnValue = CI_SUCCESS; + break; + } + } + if (CI_ERROR == returnValue) + { + break; + } + } + } + } + + } + + return returnValue; +} + +/* +* η߼ +* ˵ const UINT16 phySecId, ID +* ֵ void +*/ +UINT8 SetSectionFLockLogicManage(const UINT16 phySecId) +{ + UINT16 phySecSum = 0u; /**/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 retVal = CI_ERROR; + UINT8 flockState = 0u; /*η״̬*/ + UINT8 flockType = 0u; /*η*/ + UINT8 tmpRet = CI_ERROR; + UINT8 nonRouteFlag = 0U; + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetPhySecBelongCiId(phySecId); /*ȡID*/ + nonRouteFlag = CheckPhySecBelongNonRoute(phySecId);/*ǷѰǽ·*/ + + + if ((0u == phySecId) || (phySecId >= PHYSICAL_SECTION_SUM_MAX)) + { + retVal = CI_ERROR; + } + else + { + /*ͨ*/ + retVal = CI_SUCCESS; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + retVal = CI_ERROR; + } + else + { + /*ͨ*/ + } + + if (CI_SUCCESS == nonRouteFlag) + { + /*ǽ·Ѱ*/ + retVal = CI_ERROR; + SetErrorData(EFUNC_SET_SECTION_FLOCK, CI_DEVICE_TYPE_PHYSEC, phySecId, ETYPE_PS_NONROUTE_SET, nonRouteFlag, ESEND_LEVEL_ZERO); + } + else + { + /*ͨ*/ + } + + + if (CI_SUCCESS == retVal) + { + flockState = GetPhySecFLockState(phySecId); /*η״̬*/ + flockType = GetPhySecFLockType(phySecId); /*η*/ + + if (PHYSICAL_SECTION_FLOCK_NO == flockState) + {/*δ*/ + tmpRet = SetPhySecFLockState(phySecId, PHYSICAL_SECTION_FLOCK_YES);/*η״̬Ϊ*/ + if (CI_ERROR == tmpRet) + {/**/ + retVal = CI_ERROR; + } + else + { + SetPhySecFLockType(phySecId, PHY_SEC_FLOCK_TYPE_CMD);/*¼ηµ*/ + } + } + else if ((PHYSICAL_SECTION_FLOCK_YES == flockState) && (PHY_SEC_FLOCK_TYPE_SPKS == flockType)) + {/*η*/ + SetPhySecFLockType(phySecId, PHY_SEC_FLOCK_TYPE_SPKSCMD);/*¼ηSPKSµ*/ + } + else + { /*Ѿ÷״̬ѾSPKSη*/ + /*¼ͷ͹*/ + SetErrorData(EFUNC_SET_SECTION_FLOCK, + CI_DEVICE_TYPE_PHYSEC, + phySecId, + ETYPE_PS_FLOCK_STATE, + flockState, ESEND_LEVEL_ATS); + + retVal = CI_ERROR; + } + } + else + { + /*ʧ*/ + } + return retVal; +} + +/* +* ȡη߼ +* ˵ const UINT16 phySecId, ID +* ֵ void +*/ +UINT8 CancelSectionFLockLogicManage(const UINT16 phySecId) +{ + UINT16 phySecSum = 0u; /**/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 retVal = CI_ERROR; + UINT8 flockState = 0u; /*η״̬*/ + UINT8 flockType = 0u; /*η*/ + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetPhySecBelongCiId(phySecId); /*ȡID*/ + + if ((0u == phySecId) || (phySecId >= PHYSICAL_SECTION_SUM_MAX)) + { + retVal = CI_ERROR; + } + else + { + /*ͨ*/ + retVal = CI_SUCCESS; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + retVal = CI_ERROR; + } + else + { + /*ͨ*/ + } + + + + if (CI_SUCCESS == retVal) + { + flockState = GetPhySecFLockState(phySecId); /*η״̬*/ + flockType = GetPhySecFLockType(phySecId); /*η*/ + if (PHYSICAL_SECTION_FLOCK_YES == flockState) + { + if (PHY_SEC_FLOCK_TYPE_SPKSCMD == flockType) + {/*η*/ + SetPhySecFLockType(phySecId, PHY_SEC_FLOCK_TYPE_SPKS);/*óSPKS·*/ + } + else if (PHY_SEC_FLOCK_TYPE_CMD == flockType) + { + (void)SetPhySecFLockState(phySecId, PHYSICAL_SECTION_FLOCK_NO);/*η״̬Ϊδ*/ + SetPhySecFLockType(phySecId, PHY_SEC_FLOCK_TYPE_NONE);/*ó޷*/ + } + else + { + /*SPKSȡ*/ + } + } + else + {/*¼ͷ͹*/ + SetErrorData(EFUNC_SET_SECTION_FLOCK, + CI_DEVICE_TYPE_PHYSEC, + phySecId, + ETYPE_PS_UNFLOCK_STATE, + flockState, ESEND_LEVEL_ATS); + retVal = CI_ERROR; + } + } + else + { + /*ʧ*/ + } + return retVal; +} + + +/* +* ߼ +* ˵ void +* ֵ +*/ +void FloodLogicManage(void) +{ + UINT16 floodCurSum = 0u; + UINT16 ii = 0u;/*α*/ + UINT16 jj = 0u;/*α*/ + UINT16 kk = 0u;/*α*/ + UINT16 pp = 0u;/*α*/ + UINT8* pSourceIdBuf = NULL; /*ԴIDBuf*/ + UINT8 dataValidFlag = 0u; /*ЧԱʶ0Ч1Ч*/ + UINT16 floodId = 0u; + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 floodState = 0u; + UINT8 zcAgreeState = 0u; + + UINT16 routeSum = 0u; /*·Ŀ (ֶ)*/ + UINT16 routeId = 0u;/*·id*/ + UINT16* pRouteFloodIdBuf = NULL;/*·idָ*/ + UINT16 routeFloodSum = 0u;/*·*/ + UINT16* pOverlapFloodIdBuf = NULL;/*ιidָ*/ + UINT16 overlapFloodSum = 0u;/*ι*/ + UINT16* pRouteOverlapIdBuf = NULL;/*·idָ*/ + UINT16 routeOverlapSum = 0u;/*·*/ + + UINT8 flagCancel = 0u;/*ȡ־*/ + UINT8 flagBreak = 0u;/*жϱ־*/ + + UINT8 headValid = 0u; + + UINT8 floodGateBelongCI = 0u;/**/ + UINT8 routeBelongCI = 0u;/*·*/ + UINT8 localSysCI = 0u;/**/ + + UINT8 chkRes = CI_ERROR; + UINT32 FloodGateDelayCloseCycSum = 0U; /*Žӽռѹӳٹʱ*/ + UINT32 wFloodGateDelayCloseStartCyc = 0U; /*Žӽռѹӳٹʼʱ*/ + UINT8 checkTimeState = CI_TIME_NO; + UINT32 curCycle = 0U; + UINT8 wFloodGateCloseCheckFlag = 0U; + UINT8 cRcWorkMode = GetLocalRcWorkMode(); + UINT8 rtVal = CI_ERROR; + UINT8 ivocAgreeState = 0U; + UINT8 FloodGateAccessUTFlag = 0U; + UINT16 TempTrainIdBuf[FLOOD_GATE_APPLY_TRAIN_SUM_MAX] = { 0U }; + + localSysCI = GetSystemParaLocalCiId(); + floodCurSum = GetTotalFloodGateCurSum(); + FloodGateDelayCloseCycSum = GetFloodGateDelayCloseCount(); + curCycle = Get2oo2CurCycleNum(); /*ȡǰ*/ + + if (RC_WORK_MODE_CI == cRcWorkMode) + { + /*CIģʽ£ȼZCͨ*/ + pSourceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*ȡ뱾ͨŵZCIDĿǰһֻһZCͨ*/ + if (NULL != pSourceIdBuf) + { + headValid = GetHLHTHeadCtxValid(CI_SYSTEM_TYPE_ZC, (UINT8)(pSourceIdBuf[0u])); + + if (CI_ERROR == headValid) /*ʹGetZcMaskZcId()ȡZC IDΪZCݾ*/ + { + dataValidFlag = 0u; + } + else + {/*ϢЧ*/ + dataValidFlag = 1u; + } + } + } + else + { + + } + + for (ii = 0u; ii < floodCurSum; ii++) + { + floodId = GetFloodGateId(ii); + wFloodGateCloseCheckFlag = 0U; /*ÿų־*/ + if (0u < floodId) + { + floodGateBelongCI = GetFloodGateBelongCiId(floodId);/*ȡ*/ + + if (0u != floodGateBelongCI) + { + if (floodGateBelongCI == localSysCI) + {/*ֻƱķ*/ + floodState = GetFloodGateCurCloseRequestSta(floodId); + if (FLOOD_GATE_CLOSEREQ == floodState) + { + chkRes = FloodGateProtPhysecOccuCheck(floodId, &devId, &devState); /*Ƿռ*/ + if (CI_SUCCESS == chkRes) + { + chkRes = FloodGateAccessPhysecAcCheck(floodId, &devId, &devState); + wFloodGateDelayCloseStartCyc = GetFloodGateDelayCloseStartCnt(floodId); + checkTimeState = SystemOverTimeCheck(wFloodGateDelayCloseStartCyc, FloodGateDelayCloseCycSum); + if (CI_SUCCESS == chkRes) + {/*ӽοУгδӽǷʱڼ䣬δڣ*/ + if (CI_TIME_NO == checkTimeState) /*δʱ*/ + { + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_AGREE_CLOSE); /*δʱͬ*/ + } + else + { + wFloodGateCloseCheckFlag = 1U; /*ڼʱУҪִйż߼*/ + } + } + else + {/*ӽռѹңгӽUTռѹʱż*/ + + /*ӽҪʱͬʱZCӽڵIVOC͹*/ + if (CI_TIME_NO == checkTimeState) + { + /*ʼʱ*/ + SetFloodGateDelayCloseStartCnt(floodId, curCycle); + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_NOT_AGREE_CLOSE); /*տʼʱһڣδZCIVOC󣬴ʱͬ*/ + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { /*TIOCģʽ£ҪԽӽгرշ*/ + rtVal = SetFloodGateAcCloseApplyProc(floodId); /*Žӽгռѹг봦,ͬʱгǷΪͨųܷʧܣʱ*/ + if (CI_SUCCESS == rtVal) + { + SetFloodGateAccessUTFlag(floodId, FLOOD_GATE_ACCESS_UT_NO); + } + else + { + SetFloodGateAccessUTFlag(floodId, FLOOD_GATE_ACCESS_UT_YES); + } + } + } + wFloodGateCloseCheckFlag = 1U; /*ʼʱڼʱУҪִйż߼*/ + } + } + else + { + /*ʱ0*/ + SetFloodGateDelayCloseStartCnt(floodId, 0U); + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_NOT_AGREE_CLOSE); + ClearFloodGateAllowClosFlagIVOC(floodId); /*ܱгظ״̬*/ + } + } + else + { + /*ʱ0*/ + SetFloodGateDelayCloseStartCnt(floodId, 0U); + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_NOT_AGREE_CLOSE); + ClearFloodGateAllowClosFlagIVOC(floodId); /*ܱгظ״̬*/ + } + + if (1U == wFloodGateCloseCheckFlag) + { + if (CI_TIME_OUT == checkTimeState) + { + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_AGREE_CLOSE); /*ʱͬţʱ*/ + /*гϢ*/ + SetFloodGateCloseApplyIvocSum(floodId, 0U); + SetFloodGateCloseApplyIvocId(floodId, TempTrainIdBuf); + } + else + { + if (RC_WORK_MODE_CI == cRcWorkMode) + { + zcAgreeState = GetFloodGateCurZCAgrCloseAck(floodId); + if ((1u == dataValidFlag) && (FLOOD_GATE_ALLOWCLOSE_ZC == zcAgreeState)) + { /*ZCͨӽռѹҽӽʱʱڣյͬţͬرգʱͬ*/ + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_AGREE_CLOSE); + } + else + { + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_NOT_AGREE_CLOSE); + } + } + else + {/*TIOCģʽҪѯӽгŹ*/ + FloodGateAccessUTFlag = GetFloodGateAccessUTFlag(floodId); + if (FLOOD_GATE_ACCESS_UT_YES == FloodGateAccessUTFlag) + { + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_NOT_AGREE_CLOSE);/*طʱӽлܵĶгδгط󣬰ʱرߣʱͬ*/ + } + else + { + ivocAgreeState = GetFloodGateAccessCloseAskIVOC(floodId); + if (CI_SUCCESS == ivocAgreeState) + { + /*ʱڼյгţͬ*/ + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_AGREE_CLOSE); + } + else + { + (void)SetFloodGateCurAgreeCloseOutSta(floodId, FLOOD_GATE_NOT_AGREE_CLOSE); + } + } + } + } + } + } + + /*߼ŹرʱѹŵĽ·ŵıεĽ·Զȥ*/ + /*עַǷڱ*/ + routeSum = GetRouteCurSum();/*ȡ·*/ + for (jj = 0u; jj < routeSum; jj++) + { + routeId = GetRouteId(jj); /*ȡ·ID*/ + routeBelongCI = GetRouteBelongCiId(routeId);/*ȡ·*/ + pRouteFloodIdBuf = GetRouteFloodGateBuf(routeId); + routeFloodSum = GetRouteFloodGateSum(routeId); + pRouteOverlapIdBuf = GetRouteOverlapIdBuf(routeId); + routeOverlapSum = GetRouteOverlapSum(routeId); + chkRes = 0u; + + if ((0u != routeBelongCI) && (routeBelongCI == localSysCI)) + {/*·ڱȡ·Զ*/ + + /*ȡŹر״̬*/ + floodState = GetFloodGateCurLogicCloseState(floodId); + + if (FLOOD_GATE_OPEN != floodState) + { + /*·һIDΪţҷŹرգȡ·Զ*/ + if (0u < routeFloodSum) + { + if (NULL != pRouteFloodIdBuf) + { + for (kk = 0u; kk < routeFloodSum; kk++) + { + if (floodId == pRouteFloodIdBuf[kk]) + { + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_FLOODGATE, floodId, ETYPE_FLOODGATE_CLOSESTATE, floodState, ESEND_LEVEL_ZERO); + break; + } + } + } + } + else + { + /*pRouteFloodIdBufΪʱ⣬ʱȫ࣬ȡ·Զ*/ + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_FLOODGATE, floodId, ETYPE_FLOODGATE_CLOSESTATE, floodState, ESEND_LEVEL_ZERO); + } + } + } + + /*·Σ˽·ıιŹرգȡ·Զ*/ + flagBreak = 0u; + for (kk = 0u; kk < routeOverlapSum; kk++) + { + if (NULL != pRouteOverlapIdBuf) + { + pOverlapFloodIdBuf = GetOverlapFloodGateBuf(pRouteOverlapIdBuf[kk]); + overlapFloodSum = GetOverlapFloodGateSum(pRouteOverlapIdBuf[kk]); + if (overlapFloodSum > 0u) + { + if (NULL != pOverlapFloodIdBuf) + { + for (pp = 0u; pp < overlapFloodSum; pp++) + { + if (pOverlapFloodIdBuf[pp] == floodId) + { + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + flagBreak = 1u; + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_FLOODGATE, floodId, ETYPE_FLOODGATE_CLOSESTATE, floodState, ESEND_LEVEL_ZERO); + break; + } + } + } + if (1u == flagBreak) + { + break; + } + } + else + { + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_FLOODGATE, floodId, ETYPE_FLOODGATE_CLOSESTATE, floodState, ESEND_LEVEL_ZERO); + break; + } + } + + } + + } + else + { + /*pRouteOverlapIdBufΪʱ⣬ʱȫ࣬ȡ·Զ*/ + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(EFUNC_SET_SWITCH_FLOCK, CI_DEVICE_TYPE_FLOODGATE, floodId, ETYPE_FLOODGATE_CLOSESTATE, floodState, ESEND_LEVEL_ZERO); + } + } + } + } + } + + + } + } + } + } +} + + +/* +* ߼ +* ˵ void +* ֵ +*/ +void UnlockSwitchLogicManage(void) +{ + UINT16 j = 0U; + UINT16 ii = 0U; + UINT16 dwSwitchTotalSum = 0U; + UINT8 localCiId = 0U; /*ID*/ + UINT16 switchId = 0U; + UINT16 wDevId = 0U; + UINT8 chDevState = 0U; + UINT8 chFuncRet = 0U; + UINT8 chFuncRet1 = 0U; + UINT16 hostSwitchNum = 0U;/**/ + UINT16* pHostSwitchBuf = NULL;/*Idָ*/ + UINT16 hostSwitchId = 0U;/*ID*/ + UINT16 hostPhyId = 0U;/*ID*/ + UINT8 phyLockStatus = 0U;/*״̬*/ + UINT8 unlockFlag = 0U;/*־*/ + UINT8 funcSwitch = 0U; + UINT8 chPhySecLogLockState = 0U;/*߼״̬*/ + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + dwSwitchTotalSum = GetTotalSwitchCurNum(); /*޸YF0083-2507ν*/ + for (ii = 0u; ii < dwSwitchTotalSum; ii++) + { + switchId = GetSwitchId(ii); /*ȡID*/ + + if ((0u < switchId) && (switchId < SWITCH_SUM_MAX)) + { + /*Note޸YF0083-2507νSetSwitchLockStatus״̬ʱѶԵƣ˴жϵ*/ + hostSwitchNum = GetSwitchHostSwitchNum(switchId); + pHostSwitchBuf = GetSwitchHostSwitchIdBuf(switchId); + unlockFlag = 0u; + if ((hostSwitchNum > 0u) && (pHostSwitchBuf != NULL)) + { + for (j = 0u; j < hostSwitchNum; j++) + { + hostSwitchId = pHostSwitchBuf[j]; + + hostPhyId = GetSwitchPhySectionId(hostSwitchId);/*ȡĵID*/ + + if (0u == hostPhyId) + { + debug_infor_printf((const)"Error:hostSwitchId %d phySec is 0.\r\n", hostSwitchId); + } + + phyLockStatus = GetPhySecLockState(hostPhyId);/*ȡ״̬*/ + chFuncRet1 = GetSwitchLogSecLockState(hostSwitchId, &wDevId, &chDevState); + chPhySecLogLockState = PhySecLogLockStateCheck(hostPhyId); + + if ((PHYSICAL_SECTION_LOCK_NO == phyLockStatus) && (CI_SUCCESS == chFuncRet1) + && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState)) + {/*״̬Ϊδ(δ·߼δ·δ߼·)*/ + unlockFlag = 1u; + } + else + { + if (FUNC_SWITCH_ON == funcSwitch) + { + chFuncRet = GetSwitchLogSecLockState(hostSwitchId, &wDevId, &chDevState); + } + else + { + chFuncRet = CI_ERROR; + } + if (CI_SUCCESS == chFuncRet) + { + unlockFlag = 1u; + } + else + { + unlockFlag = 0u; + break; + } + + + } + } + } + + if (1u == unlockFlag) + {/**/ + debug_infor_printf((const)"UnLock switch:%d \r\n", switchId); + SetSwitchLockStatus(SWITCH_PLOCKTYPE_NOROUTE_NOOVERLAP_NONONROUTE, 0u, switchId, 0u); + } + } + } +} + +#if 0 +/* +* вԾ߼ +* ˵ void +* ֵ +*/ +void SwitchAxisSecJumpLockLogicManage(void) +{ + UINT8 funcSwitchJumpLockDriveSwitch = 0u;/*ܿأԾǷ*/ + + UINT16 axisSectionDataSum = 0u; /**/ + UINT16 axisSectionId = 0u; /*ID*/ + + UINT16 ii = 0u;/*־*/ + UINT16 jj = 0u;/*־*/ + + UINT8 applyFlag = 0u;/*־*/ + UINT8 cancelApplyFlag = 0u;/*ȡ־*/ + + UINT16 phyId = 0u;/*ID*/ + UINT8 phyUseState = 0u;/*״̬*/ + + UINT8 jumpLockState = 0u;/*Ծ״̬*/ + + UINT8 secBelongCi = 0u;/**/ + UINT8 localCi = 0u;/**/ + + UINT8 rtVal = 0u; /*ִзֵ*/ + + UINT8 logSecNum = 0u; + UINT16* pLogSecIdBuf = NULL; + UINT16 tmplogSecId = 0u; + UINT32 applyCycle = 0u;/*Ծ*/ + UINT32 curCycle = 0u;/*ǰں*/ + UINT8 switchSum = 0u; + UINT8 kk = 0u; + UINT8 mm = 0u; + UINT16 logicSecSum = 0u; + UINT16 logicSecId = 0u; + + + + localCi = GetSystemParaLocalCiId(); + funcSwitchJumpLockDriveSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH); + + + if (FUNC_SWITCH_ON == funcSwitchJumpLockDriveSwitch) + { + axisSectionDataSum = GetTotalAxisCurNum(); + + for (ii = 0u; ii < axisSectionDataSum; ii++) + { + curCycle = Get2oo2CurCycleNum(); + axisSectionId = GetAxisSecId(ii);/*ȡиµļID*/ + switchSum = GetAxisSwitchSum(axisSectionId); + applyFlag = GetAxisSecJumpLockApplyFlag(axisSectionId); + applyCycle = GetAxisSecJumpLockApplyCylce(axisSectionId); + cancelApplyFlag = GetAxisSecJumpLockCancelApplyFlag(axisSectionId); + + jumpLockState = GetAxisJumpLockState(axisSectionId);/*ȡԾ״̬*/ + + phyId = GetAxisSecRelativePhySecId(axisSectionId);/*ȡID*/ + phyUseState = GetPhySecUseState(phyId);/*ȡ״̬*/ + + secBelongCi = GetPhySecBelongCiId(phyId); + + logSecNum = GetAxisSecLogSectionSum(axisSectionId); /** ߼*/ + pLogSecIdBuf = GetAxisSecLogSectionIdBuf(axisSectionId); /** ߼ID*/ + + if ((0u < switchSum) && (secBelongCi == localCi) && (NULL != pLogSecIdBuf)) + {/*ΪŴ*/ + + /*Ծ״̬дѡŴմ*/ + switch (jumpLockState) + { + case AXIS_SECTION_JUMPLOCK_STATE_IDLE: + {/*οд*/ + + /** ԾУüι߼Ծδ */ + for (jj = 0u; jj < logSecNum; jj++) + { + tmplogSecId = pLogSecIdBuf[jj]; + SetLogSecJumpLockState(tmplogSecId, LOGIC_SECTION_JUMP_LOCK_NO); + } + + /*Ծ룬ûȡԾ*/ + /*Ծ״̬УδãԾ״̬תԾա*/ + if ((AXIS_SECTION_JUMPLOCK_APPLY_YES == applyFlag) && + (AXSEC_CANCEL_JUMPLOCK_APPLY_NO == cancelApplyFlag)) + {/*Ծ*/ + + if (PHYSICAL_SECTION_USING_NO == phyUseState) + {/*δ*/ + /**/ + SetPhySecUseState(phyId, PHYSICAL_SECTION_USING_YES, 0); + /*תΪѡ*/ + SetAxisJumpLockState(axisSectionId, AXIS_SECTION_JUMPLOCK_STATE_XUANPAI); + } + } + } + break; + + case AXIS_SECTION_JUMPLOCK_STATE_XUANPAI: + {/*ԾѡŴ*/ + + AxisJumpLockXuanPaiManage(axisSectionId); + } + break; + + case AXIS_SECTION_JUMPLOCK_STATE_LOCK: + {/*Ծմ*/ + + /*ռ飬ͨԾգ鲻ͨδԾ*/ + rtVal = LockAxisSecProc(axisSectionId);/*Ծ*/ + if (CI_SUCCESS == rtVal) + { + if ((AXIS_SECTION_JUMPLOCK_APPLY_YES == applyFlag) && + (AXSEC_CANCEL_JUMPLOCK_APPLY_NO == cancelApplyFlag) && + (curCycle == applyCycle)) + {/*Ծ룬߼Ծ*/ + for (jj = 0u; jj < logSecNum; jj++) + { + tmplogSecId = pLogSecIdBuf[jj]; + SetLogSecJumpLockState(tmplogSecId, LOGIC_SECTION_JUMP_LOCK_YES); + } + } + } + else + {/*֮ǰգʱڲάԾգZC*/ + SetPhySecJumpLockStateToZC(phyId, PHYSICAL_SECTION_JUMP_LOCK_NO); + } + + if ((AXIS_SECTION_JUMPLOCK_APPLY_NO == applyFlag) && + (AXSEC_CANCEL_JUMPLOCK_APPLY_YES == cancelApplyFlag)) + {/*ȡԾ*/ + + SetAxisJumpLockState(axisSectionId, AXIS_SECTION_JUMPLOCK_STATE_IDLE); + } + } + break; + + + default: + break; + } + } + else + { + /**޲λ߷DZβ*/ + } + + } + + /** ߼Ծ״̬Ծ״̬*/ + logicSecSum = GetLogicSecCurSum(); + if (LOGIC_SECTION_SUM_MAX > logicSecSum) + { + for (ii = 0u; ii < logicSecSum; ii++) + { + logicSecId = GetLogicSecId(ii); + SetLogRelaPhySecJumpLockSta(logicSecId); + } + } + else + { + /** */ + } +} + +} +#endif + +/* +* Ծ߼ +* ˵ void +* ֵ +*/ +void JumpLockManage(void) +{ + UINT8 chRCMode = GetLocalRcWorkMode(); + UINT8 chFunctionJumpDriveSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH); + UINT8 chLocalCiType = GetLocalCiType(); + + if (RC_WORK_MODE_TIOC == chRCMode) + { + /*߼Ծڼͨжϴ*/ + CheckLogSecJumpLockManage(); + } + else if (RC_WORK_MODE_CI == chRCMode) + { + if ((FUNC_SWITCH_ON == chFunctionJumpDriveSwitch) && (CI_TYPE_ZX == chLocalCiType)) + { + /*Ծ߼*/ + AxisSecJumpLockLogicManage(); + } + else + { + /*Ծ߼*/ + PhySecJumpLockLogicManage(); + } + } + else + { + /*ģʽ޴*/ + } + +} + +/* +* ڼ߼Ծ +* ˵ +* ֵ +*/ +void CheckLogSecJumpLockManage(void) +{ + UINT16 logicSecSum = 0u; + UINT16 logicSecId = 0u; + UINT8 logSecBelongCiId = 0u; + UINT8 checkResult = CI_ERROR; + UINT16 ii = 0u; + UINT8 logJumpLockState = LOGIC_SECTION_JUMP_LOCK_NO; + UINT8 localCi = 0u;/**/ + UINT16 logJumpLockTrainId = 0u; + + + localCi = GetSystemParaLocalCiId(); + logicSecSum = GetLogicSecCurSum(); + for (ii = 0U; ii < logicSecSum; ii++) + { + logicSecId = GetLogicSecId(ii); + logSecBelongCiId = GetLogSecBelongCiId(logicSecId); + logJumpLockState = GetLogSecJumpLockState(logicSecId); + if ((0U < logicSecId) && (UINT16_MAX > logicSecId)) + { + if (localCi == logSecBelongCiId) + { + if (LOGIC_SECTION_JUMP_LOCK_YES == logJumpLockState) + { + /** 鱾TIOC߼Ծ*/ + checkResult = CheckLogJumpLockApply(logicSecId); + if (CI_SUCCESS == checkResult) + { + /** 㣬Ծ־Ϊ */ + SetLogSecJumpLockPermFlag(logicSecId, LOGIC_JUMPUNLOCK_PERMISSIVE_YES); + } + else + { + /** 㣬Ծ־Ϊֹ */ + SetLogSecJumpLockPermFlag(logicSecId, LOGIC_JUMPUNLOCK_PERMISSIVE_NO); + } + } + else + { + /** ߼δԾգڼԾ*/ + } + + /** TIOCָIVOCͨ״̬µԾ*/ + logJumpLockTrainId = GetLogSecJumpLockTrainId(logicSecId); + if (0u != logJumpLockTrainId) + { + TrainTransitmitStatJumpLockProcess(logicSecId, logJumpLockTrainId); + } + else + { + /** */ + } + + SetLogRelaPhySecJumpLockSta(logicSecId); + + } + else + { + /** DZTIOC߼ΣԾ*/ + } + } + else + { + /** */ + } + + } + +} + +/* +* Ծ߼ +* ˵ void +* ֵ +*/ +void AxisSecJumpLockLogicManage(void) +{ + UINT16 axisSectionDataSum = 0u; /**/ + UINT16 axisSectionId = 0u; /*ID*/ + UINT16 ii = 0u;/*־*/ + UINT16 jj = 0u;/*־*/ + UINT8 applyFlag = 0u;/*־*/ + UINT8 cancelApplyFlag = 0u;/*ȡ־*/ + UINT16 phyId = 0u;/*ID*/ + UINT8 phyUseState = 0u;/*״̬*/ + UINT8 jumpLockState = 0u;/*Ծ״̬*/ + UINT8 secBelongCi = 0u;/**/ + UINT8 localCi = 0u;/**/ + UINT8 rtVal = 0u; /*ִзֵ*/ + UINT8 axisSecNum = 0u; + UINT16* pAxisSecIdBuf = NULL; + UINT16 cntAxisIdle = 0u; + UINT16 tmpAxisId = 0u; + UINT8 tmpAxisSecJumpLockState = 0u; + UINT32 applyCycle = 0u;/*Ծ*/ + UINT32 curCycle = 0u;/*ǰں*/ + UINT8 chPhySecJmpState = 0U; + + localCi = GetSystemParaLocalCiId(); + axisSectionDataSum = GetTotalAxisCurNum(); + + for (ii = 0u; ii < axisSectionDataSum; ii++) + { + curCycle = Get2oo2CurCycleNum(); + axisSectionId = GetAxisSecId(ii);/*ȡиµļID*/ + applyFlag = GetAxisSecJumpLockApplyFlag(axisSectionId); + applyCycle = GetAxisSecJumpLockApplyCylce(axisSectionId); + cancelApplyFlag = GetAxisSecJLockCancelApplyFlag(axisSectionId); + + jumpLockState = GetAxisJumpLockState(axisSectionId);/*ȡԾ״̬*/ + + phyId = GetAxisSecRelativePhySecId(axisSectionId);/*ȡID*/ + phyUseState = GetPhySecUseState(phyId);/*ȡ״̬*/ + + secBelongCi = GetPhySecBelongCiId(phyId); + + if (secBelongCi == localCi) + {/*ΪŴ*/ + /*Ծ״̬дѡŴմ*/ + switch (jumpLockState) + { + case AXIS_SECTION_JUMPLOCK_STATE_IDLE: + {/*οд*/ + /*ԾУҪд˼ιεмǷ񶼿УδԾ*/ + pAxisSecIdBuf = GetPAxisSectionIdBuf(phyId); + axisSecNum = GetPAxisSectionSum(phyId); + if (NULL != pAxisSecIdBuf) + { + cntAxisIdle = 0u; + for (jj = 0u; jj < axisSecNum; jj++) + { + tmpAxisId = pAxisSecIdBuf[jj]; + tmpAxisSecJumpLockState = GetAxisJumpLockState(tmpAxisId); + if (AXIS_SECTION_JUMPLOCK_STATE_IDLE == tmpAxisSecJumpLockState) + { + cntAxisIdle++; + } + } + if (cntAxisIdle == axisSecNum) + { + SetPhySecJumpLockState(phyId, PHYSICAL_SECTION_JUMP_LOCK_NO); + SetPhySecJumpLockStateToZC(phyId, PHYSICAL_SECTION_JUMP_LOCK_NO); + } + } + /*Ծ룬ûȡԾ*/ + /*Ծ״̬УδãԾ״̬תԾա*/ + if ((AXIS_SECTION_JUMPLOCK_APPLY_YES == applyFlag) && + (AXSEC_CANCEL_JUMPLOCK_APPLY_NO == cancelApplyFlag)) + {/*Ծ*/ + + if (PHYSICAL_SECTION_USING_NO == phyUseState) + {/*δ*/ + /**/ + SetPhySecUseState(phyId, PHYSICAL_SECTION_USING_YES, 0); + /*תΪѡ*/ + SetAxisJumpLockState(axisSectionId, AXIS_SECTION_JUMPLOCK_STATE_XUANPAI); + } + } + } + break; + + case AXIS_SECTION_JUMPLOCK_STATE_XUANPAI: + {/*ԾѡŴ*/ + + AxisJumpLockXuanPaiManage(axisSectionId); + } + break; + + case AXIS_SECTION_JUMPLOCK_STATE_LOCK: + {/*Ծմ*/ + /*ռ飬ͨԾգ鲻ͨδԾ*/ + rtVal = LockAxisSecProc(axisSectionId);/*Ծ*/ + if (CI_SUCCESS == rtVal) + { + if ((AXIS_SECTION_JUMPLOCK_APPLY_YES == applyFlag) && + (AXSEC_CANCEL_JUMPLOCK_APPLY_NO == cancelApplyFlag) && + (curCycle == applyCycle)) + {/*Ծ룬Ծ*/ + SetPhySecJumpLockState(phyId, PHYSICAL_SECTION_JUMP_LOCK_YES); + SetPhySecJumpLockStateToZC(phyId, PHYSICAL_SECTION_JUMP_LOCK_YES); + SetAxisInCludeLogJumpLockState(axisSectionId, LOGIC_SECTION_JUMP_LOCK_YES); + } + else + { + chPhySecJmpState = GetPhySecJumpLockState(phyId); + if ((PHYSICAL_SECTION_JUMP_LOCK_YES == chPhySecJmpState) && (0U < applyCycle)) + { + SetPhySecJumpLockStateToZC(phyId, PHYSICAL_SECTION_JUMP_LOCK_YES); + } + } + } + else + {/*֮ǰգʱڲάԾգZC*/ + SetPhySecJumpLockStateToZC(phyId, PHYSICAL_SECTION_JUMP_LOCK_NO); + } + if ((AXIS_SECTION_JUMPLOCK_APPLY_NO == applyFlag) && + (AXSEC_CANCEL_JUMPLOCK_APPLY_YES == cancelApplyFlag)) + {/*ȡԾ*/ + SetAxisJumpLockState(axisSectionId, AXIS_SECTION_JUMPLOCK_STATE_IDLE); + } + } + break; + default: + /*ɴ֧*/ + break; + } + } + } +} + + +/* +* ԾѡŹ +* ˵ const UINT16 axisSecId, ID +* ֵ void +*/ +void AxisJumpLockXuanPaiManage(const UINT16 axisSecId) +{ + UINT8 rtVal = 0u; /*ִзֵ*/ + UINT16 phyId = 0u;/*ID*/ + UINT8 axisSecSwitDrvOvtmFlag = 0u;/*ڵǷʱ־*/ + UINT8 const functionId = EFUNC_LockAxisSecProc;/**/ + UINT8 chPhySecFLockType = 0U;/*η*/ + + phyId = GetAxisSecRelativePhySecId(axisSecId);/*ȡID*/ + chPhySecFLockType = GetPhySecFLockType(phyId);/*ȡη*/ + + if (PHY_SEC_FLOCK_TYPE_NONE != chPhySecFLockType) + { + /*δڷ״̬*/ + AccToPhySecFlockTypeSetErrcode(phyId, functionId, ESEND_LEVEL_ZERO, chPhySecFLockType); + rtVal = CI_ERROR; + } + else + { + rtVal = CI_SUCCESS; + } + if (CI_SUCCESS == rtVal) + { + rtVal = LockAxisSecProc(axisSecId);/*Ծ*/ + } + axisSecSwitDrvOvtmFlag = ChekJumpLockSwitDrivOvtmStat(axisSecId);/*ڵǷʱ*/ + if (CI_SUCCESS == rtVal) + {/*ɹ*/ + SetAxisJumpLockState(axisSecId, AXIS_SECTION_JUMPLOCK_STATE_LOCK); + /*δ*/ + SetPhySecUseState(phyId, PHYSICAL_SECTION_USING_NO, 0); + } + else if ((RETURN_LOCK_ERR_SWITPOS == rtVal) && (CI_SUCCESS == axisSecSwitDrvOvtmFlag)) + {/*λôûгʱ*/ + /*Ծ*/ + rtVal = JumpLockDriveSwitch(axisSecId); + + if (CI_ERROR == rtVal) + { + /*δ*/ + SetPhySecUseState(phyId, PHYSICAL_SECTION_USING_NO, 0); + /*üԾ״̬*/ + SetAxisJumpLockState(axisSecId, AXIS_SECTION_JUMPLOCK_STATE_IDLE); + } + } + else + {/**/ + /*δ*/ + SetPhySecUseState(phyId, PHYSICAL_SECTION_USING_NO, 0); + /*üԾ״̬*/ + SetAxisJumpLockState(axisSecId, AXIS_SECTION_JUMPLOCK_STATE_IDLE); + } +} + + +/* +* ռμ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 LockAxisSecProc(const UINT16 axisSecId) +{ + UINT8 rtVal = CI_ERROR; /*ֵ*/ + + UINT8 const functionId = EFUNC_LockAxisSecProc;/**/ + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + UINT8 axisSecJumpLockState = 0u;/*״̬*/ + + + /*״̬ΪѡŻ*/ + axisSecJumpLockState = GetAxisJumpLockState(axisSecId); + if ((AXIS_SECTION_JUMPLOCK_STATE_XUANPAI == axisSecJumpLockState) || + (AXIS_SECTION_JUMPLOCK_STATE_LOCK == axisSecJumpLockState)) + { + /* ͨ */ + rtVal = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_AXISSEC, axisSecId, CI_DEVICE_TYPE_AXISSEC, axisSecJumpLockState, sendLevel); + /* ʧܷ */ + rtVal = CI_ERROR; + + } + + /*ԾμΪͨ*/ + if (CI_SUCCESS == rtVal) + { + rtVal = JumpLockSecStateCheck(axisSecId, functionId, sendLevel); + } + + /*ԾյΪͨ*/ + if (CI_SUCCESS == rtVal) + { + rtVal = JumpLockSwitchCheck(axisSecId, functionId, sendLevel);/*ֵΪɹ󡢵λô*/ + } + + return rtVal; +} + +/* +* 缯Զ·豸 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void CrossCiAutoRouteFLockDevProc(const UINT16 routeId) +{ + UINT8 const functionId = EFUNC_CROSS_CI_AUTOROUTE_FLOCK_DEV; /*־ID*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*־ͼ*/ + UINT8 isCancleAuto = 0u; /*Ƿȡ·Զ*/ + UINT8 fLockState = 0u; /*״̬*/ + UINT8 flagCancel = 0u; /*ȡ·ԶԱʶֵ*/ + UINT16 ii = 0u; /*ѭ*/ + UINT16 jj = 0u; /*ѭ*/ + UINT8 secSum = 0u; /*·(ֶ)*/ + RoutePhysicalSectionStruct* pSecStru = NULL; /*·(ֶ)*/ + UINT16* pSecIds = NULL; /*ΰIDб*/ + UINT8 overlapSum = 0u; /*·طĿ(ֶ)*/ + UINT16* pOverlapIds = NULL; /*·طID(ֶ)*/ + UINT16 overlapId = 0u; /*ID*/ + UINT8 fsSignalSum = 0u; /*·طźŻĿ(ֶ)*/ + UINT16* pFsSignalIds = NULL; /*·طźŻID(ֶ)*/ + + secSum = GetRoutePhysicalSectionSum(routeId); + pSecStru = GetRouteSectionData(routeId); + if (0u < secSum) /*,ָǿռ*/ + { + for (ii = 0u; ii < secSum; ii++) + { + fLockState = GetPhySecFLockState(pSecStru[ii].PhysicalSectionId); + if (PHYSICAL_SECTION_FLOCK_YES == fLockState) /*η*/ + { + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, pSecStru[ii].PhysicalSectionId, ETYPE_PS_FLOCK_STATE, fLockState, sendLevel); + } + isCancleAuto = 1u; /*ȡ·Զ*/ + break; /*˳*/ + } + else + { + ; + } + } + } + else + { + ; + } + + if (0u == isCancleAuto) /*δȡ·Զ*/ + { + overlapSum = GetRouteOverlapSum(routeId); + pOverlapIds = GetRouteOverlapIdBuf(routeId); + if ((0u < overlapSum) && (NULL != pOverlapIds)) /*,ָǿռ*/ + { + for (ii = 0u; ii < overlapSum; ii++) + { + overlapId = pOverlapIds[ii]; + secSum = GetOverlapPhySecSum(overlapId); + pSecIds = GetOverlapPhySecIdBuf(overlapId); + if ((0u < secSum) && (NULL != pSecIds)) /*,ָǿռ*/ + { + for (jj = 0u; jj < secSum; jj++) + { + fLockState = GetPhySecFLockState(pSecIds[jj]); + if (PHYSICAL_SECTION_FLOCK_YES == fLockState) /*η*/ + { + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, pSecIds[jj], ETYPE_PS_FLOCK_STATE, fLockState, sendLevel); + } + isCancleAuto = 1u; /*ȡ·Զ*/ + break; /*˳*/ + } + } + } + else + { + ; + } + if (1u == isCancleAuto) /*ȡ·Զ,˳*/ + { + break; + } + else + { + ; + } + } + } + else + { + ; + } + } + else + { + ; + } + + if (0U == isCancleAuto) /*δȡ·Զ*/ + { + fsSignalSum = GetRouteFengSuoSignalSum(routeId); + pFsSignalIds = GetRouteFengSuoSignalIdBuf(routeId); + if ((0u < fsSignalSum) && (NULL != pFsSignalIds)) /*,ָǿռ*/ + { + for (ii = 0u; ii < fsSignalSum; ii++) + { + fLockState = GetSignalFLockState(pFsSignalIds[ii]); + if (SIGNAL_FENGSUO_YES == fLockState) /*źŻ*/ + { + flagCancel = CancleAutoFlag(routeId); + if (CI_ERROR == flagCancel) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, pFsSignalIds[ii], ETYPE_SIG_FLOCK_STATE, fLockState, sendLevel); + } + else + { + ; + } + isCancleAuto = 1u; /*ȡ·Զ*/ + break; /*˳*/ + } + else + { + ; + } + } + } + else + { + ; + } + } + else + { + ; + } +} + + +/******************************̵ӿȷ״̬************************************************************/ + +/* +* ȡ̵ӿȷϱ־ +* ˵ void +* ֵ CICI_RELAY_INTERFACE_CONFIRM_NO ̵ӿδȷ +* CICI_RELAY_INTERFACE_CONFIRM_YES ̵δȷ +*/ +UINT8 GetCiCiRelayInterfConfirmFlag(void) +{ + return CiCiRelayInterfaceConfirmFlag; +} + +/* +* ü̵ӿȷϱ־ +* ˵ UINT8 setFlag,ñ־ +* ֵ void +*/ +void SetCiCiRelayInterfConfirmFlag(UINT8 setFlag) +{ + UINT8 localCi = 0u;/*ID*/ + UINT8 jj = 0u; + UINT8 tranCiState = 0u; + UINT8 sameLineFlag = SAME_LINE_ERR;/*CIǷͬһ·*/ + UINT8* pCiIdBuf = NULL; + UINT8 ciSum = 0u; + UINT8 dstCIType = 0u;/*Ŀ*/ + + UINT8 allCommState = CI_ERROR; + UINT8 funcId = EFUNC_SetCiCiRelayInterfaceConfirmFlag; + UINT8 sendLevel = ESEND_LEVEL_ATS; + + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + + if (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface) + { + if (CICI_RELAY_INTERFACE_CONFIRM_YES == setFlag) + { + localCi = GetSystemParaLocalCiId();/*ID*/ + + /*ͨŶȷʧ*/ + ciSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI); /*ȡͨ豸*/ + pCiIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI);/*ȡͱͨŵID*/ + + for (jj = 0u; jj < ciSum; jj++) + { + sameLineFlag = IsSameLineCI(localCi, pCiIdBuf[jj]); + + if (SAME_LINE_YES == sameLineFlag) + { + dstCIType = GetCiType(pCiIdBuf[jj]); + if (CI_TYPE_SCX != dstCIType) + { + tranCiState = GetCiTransmitState(CI_SYSTEM_TYPE_CI, pCiIdBuf[jj]); + + if (TRANSMIT_STATE_GOOD == tranCiState) + { + allCommState = CI_SUCCESS; + } + else + { + /*һͨжϾʹѭ*/ + allCommState = CI_ERROR; + + break; + } + } + } + } + if (CI_ERROR == allCommState) + {/*һͨжϣſ*/ + CiCiRelayInterfaceConfirmFlag = setFlag; + } + else + {/*ͨŶ*/ + SetErrorData(funcId, CI_SYSTEM_TYPE_CI, localCi, ETYPE_COMM_WITH_NEIGHBOUR_CI, allCommState, sendLevel); + } + + } + else if (CICI_RELAY_INTERFACE_CONFIRM_NO == setFlag) + { + CiCiRelayInterfaceConfirmFlag = setFlag; + } + else + { + /**/ + } + } + else + { + debug_infor_printf((const)"funcSwitchSupportRelayInterface not 0xaa\n"); + } +} + +/******************************̵ӿȷ״̬**************END*****************************************************/ +/* +* ݽ·״̬źű̿ſʼֵ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetClearKeepSignalTolerateCyc(const UINT16 routeId) +{ + UINT8 bCiSwitchShowGreenYellow = FUNC_SWITCH_OFF;/*̻ƿ*/ + UINT8 routeLevel = 0u;/*·ȼ*/ + UINT8 routeState = 0u;/*·״̬*/ + + bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow); + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + routeLevel = GetRouteLevel(routeId); + if (ROUTE_LEVEL_CBTC == routeLevel) + { + (void)SetRouteKeepSigTolerateCyc(routeId, 0u); + } + else if (ROUTE_LEVEL_BLOC == routeLevel) + { + routeState = GetRouteState(routeId); + if ((ROUTE_STATE_YUXIAN_OPEN != routeState) && (ROUTE_STATE_NEAR_OPEN != routeState)) + { + (void)SetRouteKeepSigTolerateCyc(routeId, 0u); + } + else + { + /*ʲôҲ*/ + } + } + else + { + /*ʲôҲ*/ + } + } + else + { + /*ʲôҲ*/ + } + +} + +/* +* PSC·״̬ȷϱ־ +* ˵ UINT8 setFlag,ñ־ +* UINT16 pscId PSC豸ID +* ֵ +*/ +void SetCiPscPlConfirmFlag(UINT8 setFlag, const UINT16 pscId) +{ + /*ʼ*/ + UINT8 i = 0u; + UINT8 j = 0u; + UINT8 lowBytePscId = 0u; + UINT16 savePscId = 0u; + UINT8 localCiId = 0u; + UINT8 deviceSum = 0u;/*ͨ豸*/ + UINT8* pDeviceIdBuf = NULL;/*ͨ豸ID*/ + UINT8 transmitState = 0u; + UINT8 pscSystemId = 0u; + UINT8 funcId = EFUNC_SETCIPSCPLCONFIRMFLAG; + UINT8 sendLevel = ESEND_LEVEL_ATS; + UINT8 psdCiId = 0u; + UINT8 psdAtsConfirmFlag = 0u; + UINT8 pscNoPlStateNum = 0u; + UINT8 localCiPsdNum = 0u; + UINT8 errorFlag = 0u; + UINT8 transmitReval = CI_ERROR; + PSCToCiDataStruct* pscToCiDataStru = GetPscToCiDataStru(); + + /*Աֵ*/ + savePscId = pscId; + lowBytePscId = (UINT8)(savePscId & 0x00FFU); + + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PSC); /*ȡͨPSC豸*/ + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PSC); /*ȡͨPSC豸ID*/ + localCiId = GetSystemParaLocalCiId();/*ȡCI ID*/ + + /**/ + if (NULL != pscToCiDataStru) + { + for (i = 0u; i < deviceSum; i++) + { + /*ƥPSC ID*/ + if (lowBytePscId == pDeviceIdBuf[i]) + { + pscSystemId = pDeviceIdBuf[i]; + /*PSCϵͳIDϷ*/ + if (PSC_TO_CI_SUM_MAX > pscSystemId) + { + /*CIͨ״̬*/ + transmitReval = UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_PSC, pscSystemId); + if (CI_SUCCESS == transmitReval) + { + transmitState = GetCiTransmitState(CI_SYSTEM_TYPE_PSC, pscSystemId); + } + /*·*/ + if (CI_PSC_PL_CONFIRM_YES == setFlag) + { + for (j = 0u; j < pscToCiDataStru[pscSystemId].psdSum; j++) + { + psdCiId = GetPsdBelongCiId(pscToCiDataStru[pscSystemId].psdDataStr[j].psdId); + if (psdCiId == localCiId) + { + /*ͨ쳣*/ + if (TRANSMIT_STATE_GOOD != transmitState) + { + /*öӦPSCϵͳӦPSD·״̬*/ + SetPsdPscConfirmFlag(pscToCiDataStru[pscSystemId].psdDataStr[j].psdId, setFlag); + } + else + { + errorFlag = 1u; + } + } + /*DZ*/ + else + { + /**/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_SET_PSC_PL, pscToCiDataStru[pscSystemId].psdDataStr[j].psdId, pscId, psdCiId); + } + } + if (1u == errorFlag) + { + /*CIӦPSCϵͳͨ״̬*/ + SetErrorData(funcId, CI_SYSTEM_TYPE_PSC, pscId, ETYPE_COMM_WITH_PSC, transmitState, sendLevel); + } + } + else + { + /*0*/ + pscNoPlStateNum = 0u; + localCiPsdNum = 0u; + for (j = 0u; j < pscToCiDataStru[pscSystemId].psdSum; j++) + { + psdCiId = GetPsdBelongCiId(pscToCiDataStru[pscSystemId].psdDataStr[j].psdId); + if (psdCiId == localCiId) + { + localCiPsdNum++; + /*ȡATSȷ·־*/ + psdAtsConfirmFlag = GetPsdPscPlFlag(pscToCiDataStru[pscSystemId].psdDataStr[j].psdId); + if (CI_PSC_PL_CONFIRM_YES == psdAtsConfirmFlag) + { + /*ȡȷϱ־*/ + SetPsdPscConfirmFlag(pscToCiDataStru[pscSystemId].psdDataStr[j].psdId, CI_PSC_PL_CONFIRM_NO); + } + else + { + /*·״̬*/ + pscNoPlStateNum++; + + } + } + /*DZ*/ + else + { + /**/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_QX_PSC_PL, pscToCiDataStru[pscSystemId].psdDataStr[j].psdId, pscId, psdCiId); + } + } + /*PSCµPSDPSC·״̬*/ + if (pscNoPlStateNum == localCiPsdNum) + { /**/ + SetErrorData(funcId, CI_SYSTEM_TYPE_PSC, pscId, ETYPE_PSC_CONFIRM_PL_STATE, CI_PSC_PL_CONFIRM_NO, sendLevel); + } + + } + } + /*ҵӦPSC IDѭ*/ + break; + } + } + } +} + +/* +* ݱοʼѡֵ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void ClearOverlopUsing(const UINT16 routeId) +{ + UINT8 overlapSum = 0u;/*Ŀ*/ + UINT16* pOverlapIdBuf = NULL;/**/ + UINT16 jj = 0u; + + overlapSum = GetRouteOverlapSum(routeId); /*ȡOverlap*/ + pOverlapIdBuf = GetRouteOverlapIdBuf(routeId); /*ȡOverlap ID BUF*/ + if ((NULL != pOverlapIdBuf) && (ROUTE_PROTECTSECGROUP_SUM_MAX >= overlapSum)) + { + for (jj = 0u; jj < overlapSum; jj++) + { + SetOverlapRelSwitchUsing(pOverlapIdBuf[jj], SWITCH_USING_NO); + SetOverlapXuanPaiStartCycNum(pOverlapIdBuf[jj], 0U); /*·״̬Уεѡʼ*/ + SetOverlapProSwtCheckStartFlag(pOverlapIdBuf[jj], PROSWITCH_CHECK_START_INVALID); /*·״̬У÷鿪ʼ־Ϊֹͣ*/ + SetOverlapProSwtCheckResultFlag(pOverlapIdBuf[jj], PROSWITCH_CHECK_RESULT_DEFAULT); /*־ΪĬֵ*/ + } + } +} + + +/* +*ܣԶͨ·Զ +*˵const UINT16 groupAutoRouteId Զ·ID +*ֵ +*/ +void SetGroupAutoRouteLogicManage(const UINT16 groupAutoRouteId) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT8 retCheck = CI_ERROR; + UINT16 groupAutoRouteSum = 0u; /*Զ·Զ·Ŀ (ֶ)*/ + UINT16* pgroupAutoRouteIdBuf = NULL; /*Զ·Զ··ID (ֶ)*/ + + if ((0u != groupAutoRouteId) && (GROUP_AUTO_ROUTE_SUM_MAX > groupAutoRouteId)) + { + /*ȡԶ·Ϣ*/ + groupAutoRouteSum = GetGroupAutoRouteHasRouteSum(groupAutoRouteId); + pgroupAutoRouteIdBuf = GetGroupAutoRouteHasRouteIdBuff(groupAutoRouteId); + + /*Զ·*/ + if (0u != groupAutoRouteSum) + { + for (i = 0u; i < groupAutoRouteSum; i++) + { + /*Զ·Զ·߼*/ + retCheck = GroupInAutoRouteConditionCheck(pgroupAutoRouteIdBuf[i]); + if (CI_ERROR == retCheck) + { + /*ѭ*/ + break; + } + } + /*ж󷵻ֵdzɹ*/ + if (CI_SUCCESS == retCheck) + { + for (i = 0u; i < groupAutoRouteSum; i++) + { + /*Զ*/ + SetAutoRouteSetFlag(pgroupAutoRouteIdBuf[i], AUTO_ROUTE_SET_YES); + } + } + else + { + /*ͱ*/ + SetErrorData(EFUNC_CHECK_GROUP_AUTO_ROUTE, CI_DEVICE_TYPE_GROUP_AUTO_ROUTE, groupAutoRouteId, ETYPE_GROUP_AUTO_ROUTE_STATE, CI_BACK_GROUP_AUTO_ROUTE_SET_ERR, ESEND_LEVEL_ATS); + } + } + else + { + ; + } + } + else + { + ; + } +} + +/* +*ܣȡԶͨ·Զ +*˵const UINT16 groupAutoRouteId Զ·ID +*ֵ +*/ +void CancleGroupAutoRouteLogicManage(const UINT16 groupAutoRouteId) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 groupAutoRouteSum = 0u; /*Զ·Զ·Ŀ (ֶ)*/ + UINT16* pgroupAutoRouteIdBuf = NULL; /*Զ·Զ··ID (ֶ)*/ + + if ((0u != groupAutoRouteId) && (GROUP_AUTO_ROUTE_SUM_MAX > groupAutoRouteId)) + { + /*ȡԶ·Ϣ*/ + groupAutoRouteSum = GetGroupAutoRouteHasRouteSum(groupAutoRouteId); + pgroupAutoRouteIdBuf = GetGroupAutoRouteHasRouteIdBuff(groupAutoRouteId); + + /*Զ·*/ + if (0u != groupAutoRouteSum) + { + for (i = 0u; i < groupAutoRouteSum; i++) + { + SetAutoRouteSetFlag(pgroupAutoRouteIdBuf[i], AUTO_ROUTE_SET_NO); + } + } + } +} +/* +* Զ·Ľ·Ƿڱ +* ˵ Զ·ID ID +* ֵ void +*/ +UINT8 CheckAutoRouteBelongVirCI(const UINT16 autoRouteId, const UINT8 virCIid) +{ + UINT8 autoIncludeRouteSum = 0u; + UINT16* pAutoIncludeRouteIdbuf = NULL; + UINT8 ii = 0u; + UINT8 belongVirCIid = 0u; + + UINT8 returnValue = CI_ERROR; + + autoIncludeRouteSum = GetAutoRouteIncludeRouteSum(autoRouteId); + pAutoIncludeRouteIdbuf = GetAutoRouteIncludeRouteBuf(autoRouteId); + if ((NULL == pAutoIncludeRouteIdbuf) || (AUTO_ROUTE_INCLROUTE_SUM_MAX < autoIncludeRouteSum)) + { + returnValue = CI_ERROR; + } + else + { + returnValue = CI_SUCCESS; + } + + if (CI_SUCCESS == returnValue) + { + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + belongVirCIid = GetRouteBelongVirCiId(pAutoIncludeRouteIdbuf[ii]); + if (virCIid != belongVirCIid) + { + returnValue = CI_ERROR; + break; + } + } + } + return returnValue; +} + +/* +* Զ۷·Ľ·Ƿ +* ˵ Զ·ID ID +* ֵ void +*/ +UINT8 CheckAutoReturnBelongVirCI(const UINT16 autoRouteId, const UINT8 virCIid) +{ + UINT8 autoIncludeRouteSum = 0u; + UINT16* pAutoIncludeRouteIdbuf = NULL; + UINT8 ii = 0u; + UINT8 belongVirCIid = 0u; + + UINT8 returnValue = CI_ERROR; + + autoIncludeRouteSum = GetAutoReturnIncludeRouteSum(autoRouteId); + pAutoIncludeRouteIdbuf = GetAutoReturnIncludeRouteBuf(autoRouteId); + if ((NULL == pAutoIncludeRouteIdbuf) || (AUTO_RETURN_INCLROUTE_SUM_MAX < autoIncludeRouteSum)) + { + returnValue = CI_ERROR; + } + else + { + returnValue = CI_SUCCESS; + } + + if (CI_SUCCESS == returnValue) + { + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + belongVirCIid = GetRouteBelongVirCiId(pAutoIncludeRouteIdbuf[ii]); + if (virCIid != belongVirCIid) + { + returnValue = CI_ERROR; + break; + } + } + } + return returnValue; +} +/* +* ȫԶ۷·Ľ·Ƿ +* ˵ Զ·ID ID +* ֵ void +*/ +UINT8 CheckALLAutoReturnBelongVirCI(const UINT16 allAutoRouteId, const UINT8 virCIid) +{ + UINT8 autoIncludeRouteSum = 0u; + UINT16* pAutoIncludeRouteIdbuf = NULL; + UINT8 ii = 0u; + UINT8 belongVirCIid = 0u; + + UINT8 returnValue = CI_ERROR; + + autoIncludeRouteSum = GetAllAutoReturnIncludeRouteSum(allAutoRouteId); + pAutoIncludeRouteIdbuf = GetAllAutoReturnIncludeRouteBuf(allAutoRouteId); + if ((NULL == pAutoIncludeRouteIdbuf) || (ALL_AUTO_RETURN_INCLROUTE_SUM_MAX < autoIncludeRouteSum)) + { + returnValue = CI_ERROR; + } + else + { + returnValue = CI_SUCCESS; + } + + if (CI_SUCCESS == returnValue) + { + for (ii = 0u; ii < autoIncludeRouteSum; ii++) + { + belongVirCIid = GetRouteBelongVirCiId(pAutoIncludeRouteIdbuf[ii]); + if (virCIid != belongVirCIid) + { + returnValue = CI_ERROR; + break; + } + } + } + return returnValue; +} + +/* +* ·λ߼Զ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RoutePhyOrLogSecAutoUnlocManage(const UINT16 routeId) +{ + /*ʼ*/ + UINT16 fLockLogId = 0u; /*·յĵһ߼*/ + UINT8 logCurOccupyState = 0u; + UINT8 logPreOccupyState = 0u; + UINT8 routeType = 0u; + UINT16 logBelongPhyId = 0u; + UINT16 validReturnSigId = 0u; /*Ч۷źŻ*/ + UINT16 returnSecId = 0u; /*۷*/ + UINT16 dlockLogId = 0u; + UINT32 logUnlockStartCycNum = 0u; + UINT32 phyUnlockStartCycNum = 0u; + UINT16 fLogBelongPhyId = 0u; + UINT8 chPhyIncSwitchSum = 0U; + UINT16* pPhySecSwitchId = NULL; + UINT8 localCiType = 0U;/**/ + + localCiType = GetLocalCiType(); + + + /*ȡ·յĵһ߼ռ״̬*/ + fLockLogId = GetRouteFirstNormalLockLogId(routeId); + logCurOccupyState = GetLogSecCurCtOrUtOccupyState(fLockLogId); + logPreOccupyState = GetLogSecPreCtOrUtOccupyState(fLockLogId); + + /*һյ߼*/ + fLogBelongPhyId = GetLgcSecRelativePhySecId(fLockLogId); + + chPhyIncSwitchSum = GetPhyIncludeSwitchSum(fLogBelongPhyId); + pPhySecSwitchId = GetPhySecIncludeSwitch(fLogBelongPhyId); + /*ȡ·Ϣ*/ + routeType = GetRouteType(routeId); + validReturnSigId = GetValidReturnSinalId(routeId, fLogBelongPhyId); + returnSecId = GetSignalOutFirstPhySecId(validReturnSigId); + + /*·һʱ߼*/ + dlockLogId = GetRouteFirstDelayLockLogId(routeId); + + /*ڵһյ߼Σ߼0˵·һ߼ʱУ*/ + if (fLockLogId > 0u) + { + /*۷·Ҵ۷Ρͨ·жӦ۷·Ҵ۷*/ + if (((ROUTE_TYPE_RETURN == routeType) && (fLogBelongPhyId == returnSecId)) || + ((ROUTE_TYPE_RETURN != routeType) && (0U 0u) && (logUnlockStartCycNum > 0u)) + { + /*ʱ߼*/ + LogSecDelayUnlockProc(routeId); + } + /*˵ʱ*/ + else if ((dlockLogId > 0u) && (0u == logUnlockStartCycNum) && (phyUnlockStartCycNum > 0u)) + { + /*ʱ*/ + PhySecDelayUnlockProc(routeId); + } + else + { + /**/ + } + +} + +/* +* ·߼Զ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLogSecAutoUnlockManage(const UINT16 routeId) +{ + /*ʼ*/ + UINT16 lockLogId = 0u; + UINT16 logBelongPhyId = 0u; + UINT8 routeDir = 0u; + UINT32 cycNum = 0u; + UINT8 returnValue = 0u; /*ֵ*/ + + + /*ν߼*/ + returnValue = RouteLogSecAutoUnlockProcess(routeId, &lockLogId); + cycNum = Get2oo2CurCycleNum(); + routeDir = GetRouteDirection(routeId); + /*δҵ*/ + if (0u == lockLogId) + { + /**/ + } + else + { + /*ɹ*/ + if (CI_SUCCESS == returnValue) + { + /*߼ʱ*/ + SetLogSecLockState(lockLogId, LOG_SECTION_LOCK_DELAY, routeId, routeDir); + /*߼ʱʼں*/ + SetLogUnlockStartCycNum(lockLogId, cycNum); + } + else if (RETURN_AUTOLOCK_ERR_EXCEPT == returnValue) + { + /*ҵӦ*/ + logBelongPhyId = GetLgcSecRelativePhySecId(lockLogId); +#if 0 + logBelongPhyId = GetAxisSecRelativePhySecId(logBelongAxisId); +#endif + /*쳣*/ + SetPhySecLockState(logBelongPhyId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, routeDir); + /*ͬʱڱ·յ߼쳣*/ + SetPhyIncludeLogLockState(logBelongPhyId, LOG_SECTION_LOCK_EXCEPT, routeId); + + /*-->Զ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + else + { + /**/ + } +} +} + + +/* +* ߼Դ +* ˵ void +* ֵ +*/ +void LogicSecResManage(void) +{ + UINT16 wLogicCurSum = 0U; + UINT8 localCiId = 0u; /*ID*/ + UINT16 wLogicPLockRouteId = 0u; /*߼ηս·ID*/ + UINT16 wLogicSecId = 0U; /*߼ID*/ + UINT16 wLogicSecBelongCiId = 0u; /*߼ID*/ + UINT8 routeLevel = 0u; /*·ල*/ + UINT16 wTrainId = 0U; + UINT16 ii = 0u; /*ѭ*/ + + UINT8 chLogicLockState = 0U;/*߼״̬*/ + UINT8 startLockState = 0u; + UINT8 startFlockFlag = 0u; + UINT8 rtVal = CI_ERROR; + UINT8 chFlagExec = CI_ERROR;/*ִб־*/ + UINT16 wOverlapId = 0u; + UINT8 cOtherCiId = 0u; + UINT8 chLogicSecProResCheckSta = CI_ERROR;/*߼ηԴԼ*/ + + wLogicCurSum = GetLogicSecCurSum(); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + startLockState = GetStartLockFlag(); /*ȡϵ־*/ + startFlockFlag = GetStartFLockFlag(); /*ȡϵ־*/ + + + if (0u == localCiId) + { + rtVal = CI_ERROR; + } + else + { + rtVal = CI_SUCCESS; + } + + if (CI_SUCCESS == rtVal) + { + + if ((CI_START_LOCK_NO != startLockState) || (CI_START_FLOCK_NO != startFlockFlag)) + {/*δȫվδϵ*/ + rtVal = CI_ERROR; + } + } + + if (CI_SUCCESS == rtVal) + { + /*߼*/ + for (ii = 0u; ii < wLogicCurSum; ii++) + { + wLogicSecBelongCiId = 0u; /*߼ID*/ + routeLevel = 0u; /*·ල*/ + chFlagExec = CI_ERROR; + chLogicSecProResCheckSta = CI_ERROR;/*߼ηԴԼ*/ + + wLogicSecId = GetLogicSecId(ii); + + wLogicPLockRouteId = GetLogSecPLockRouteId(wLogicSecId); + wLogicSecBelongCiId = GetLogSecBelongCiId(wLogicSecId); /*ȡ߼ID*/ + if ((0u == wLogicSecId) || (LOGIC_SECTION_SUM_MAX < wLogicSecId)) + { + chFlagExec = CI_ERROR; + } + else + { + chFlagExec = CI_SUCCESS; + } + + if (CI_SUCCESS == chFlagExec) + { + if (wLogicSecBelongCiId != localCiId) + { + chFlagExec = CI_ERROR; + } + else + { + ; /*ִ*/ + } + } + + if (CI_SUCCESS == chFlagExec) + { + /*ȡ·ֶ̬*/ + chLogicLockState = GetLogSecLockState(wLogicSecId); + + if ((0U < wLogicPLockRouteId) && ((LOG_SECTION_LOCK_PROTECT == chLogicLockState) + || (LOG_SECTION_LOCK_NORMAL == chLogicLockState) || (LOG_SECTION_LOCK_DELAY == chLogicLockState))) + { + /*߼αգ鱣ο*/ + wOverlapId = GetRouteOverlapLockedId(wLogicPLockRouteId); + /*ȡμ״̬*/ + chLogicSecProResCheckSta = OverlapUsableCheck(wOverlapId); + /*߼зգͨ*/ + if (CI_SUCCESS == chLogicSecProResCheckSta) + { + SetLogSecProResUseState(wLogicSecId, LOGIC_SECTION_PRO_RES_USABLE); + } + else + { + SetLogSecProResUseState(wLogicSecId, LOGIC_SECTION_PRO_RES_UNUSABLE); + } + } + else + { + SetLogSecProResUseState(wLogicSecId, LOGIC_SECTION_PRO_RES_UNUSABLE); + } + + /*г߼ϵԴ*/ + SetAllTrainLogicResUseable(wLogicSecId); + } + + if (CI_SUCCESS == chFlagExec) + { + /* ·Դ */ + cOtherCiId = GetLogSecResReqOtherCIId(wLogicSecId); + wTrainId = GetLogSecResReqTrainId(wLogicSecId); + if ((0u != cOtherCiId) && (cOtherCiId != localCiId) && (0u != wTrainId)) + { + SetLogSecResReqOtherCIId(wLogicSecId, 0); + SetLogSecResReqTrainId(wLogicSecId, 0); + AddCiSendToCiCmdInfo(CI_CMD_LOGSEC_LOCK, wLogicSecId, wTrainId, cOtherCiId); + } + } + } + /*ɺ󣬴гسԴ*/ + TrainLogicSecResRetreatManage(); + } +} + + +/* +* г߼Դس +* ˵ void +* ֵ +*/ +static void TrainLogicSecResRetreatManage(void) +{ + /**ʼ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT16 wTrainId = 0U; + UINT16 wTrainSum = 0U; + UINT16 wTrainIncLogicSecIdBuf[TRAIN_INCLUDE_RES_MAX_SUM] = { 0U }; + UINT16 wTrainIncLogcSecSum = 0U; + UINT16 wszTrainUsableLgcIdBuf[TRAIN_INCLUDE_RES_MAX_SUM] = { 0U }; + UINT16 wTrainUsableLgcSum = 0U; + UINT16 wszSetUnUsableLgcIdBuf[TRAIN_INCLUDE_RES_MAX_SUM * 2U] = { 0U }; + UINT16 wTrainUnUsableLgcSum = 0U; + UINT8 chTrainCommState = 0U; + + UINT8 chFuncRet = 0U; + UINT16 ii = 0u; /*ѭ*/ + UINT16 jj = 0u; /*ѭ*/ + UINT16 kk = 0U; /*ѭ*/ + UINT8 rtVal = CI_ERROR; + UINT8 chStartAdd = CI_ERROR; + UINT8 chTrainTailLogFlag = CI_ERROR; + UINT8 chFlagExec = CI_ERROR;/*ִб־*/ + UINT8 chLgcSecTrainApply = 0U; + UINT8 chTrainSleepState = 0U; + + struct_PathPoint stTrainTailPoint = { 0U }; + UINT16 wTrainMinTailLink = 0U; + UINT32 dwTrainMinTailOff = 0U; + UINT16 wTmpLogicId = 0U; + UINT8 chTmpLogicBelongCiId = 0U; + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + wTrainSum = GetTrainSum(); + rtVal = CI_SUCCESS; + if (CI_SUCCESS == rtVal) + { + /*·*/ + for (ii = 0u; ii < wTrainSum; ii++) + { + (void)CommonMemSet(wTrainIncLogicSecIdBuf, (UINT32)sizeof(wTrainIncLogicSecIdBuf), 0, (UINT32)sizeof(wTrainIncLogicSecIdBuf)); + (void)CommonMemSet(wszTrainUsableLgcIdBuf, (UINT32)sizeof(wszTrainUsableLgcIdBuf), 0, (UINT32)sizeof(wszTrainUsableLgcIdBuf)); + (void)CommonMemSet(wszSetUnUsableLgcIdBuf, (UINT32)sizeof(wszSetUnUsableLgcIdBuf), 0, (UINT32)sizeof(wszSetUnUsableLgcIdBuf)); + wTrainIncLogcSecSum = 0U; + wTrainUsableLgcSum = 0U; + wTrainUnUsableLgcSum = 0U; + + wTrainId = GetTrainId(ii); + chTrainCommState = GetTrainTransitmitStat(wTrainId); + chTrainSleepState = GetTrainSleepState(wTrainId); + chFlagExec = CI_SUCCESS; + chStartAdd = CI_ERROR; + wTrainMinTailLink = GetTrainMinTailLink(wTrainId); + dwTrainMinTailOff = GetTrainMinTailOffset(wTrainId); + stTrainTailPoint.wLinkId = wTrainMinTailLink; + stTrainTailPoint.dwOffset = dwTrainMinTailOff; + wTmpLogicId = GetPointBelongLogSec(stTrainTailPoint); + chTmpLogicBelongCiId = GetLogSecBelongCiId(wTmpLogicId); + if ((TRAIN_COMM_STATE_GOOD == chTrainCommState) + || ((TRAIN_SLEEP_YES == chTrainSleepState) && (TRAIN_COMM_STATE_BAD == chTrainCommState))) + { + chFuncRet = CalTrainFrontLogicSecSeq(wTrainId, &wTrainIncLogcSecSum, wTrainIncLogicSecIdBuf); + if (CI_SUCCESS != chFuncRet) + { + chFlagExec = CI_ERROR; + } + else + { + ; /*ִ*/ + } + } + if (CI_SUCCESS == chFlagExec) + { + chFuncRet = GetTrainUsableLogicSec(wTrainId, &wTrainUsableLgcSum, wszTrainUsableLgcIdBuf); + if (CI_SUCCESS != chFuncRet) + { + chFlagExec = CI_ERROR; + } + else + { + + ; /*ִ*/ + } + } + + if (CI_SUCCESS == chFlagExec) + { + chTrainTailLogFlag = CI_ERROR; + for (jj = 0U; jj < wTrainIncLogcSecSum; jj++) + { + /*ҵһгΣֹҲڷΧ²*/ + chLgcSecTrainApply = GetLogSecTrainApply(wTrainIncLogicSecIdBuf[jj], wTrainId); + if ((wTrainIncLogicSecIdBuf[jj] == wTmpLogicId) + || (localCiId != chTmpLogicBelongCiId)) + { + /*ӳβοʼ㿴Ƿг*/ + chTrainTailLogFlag = CI_SUCCESS; + } + else + { + ; /**/ + } + if (((CI_SUCCESS == chTrainTailLogFlag) + && (LOGIC_SECTION_TRAIN_APPLY_YES == chLgcSecTrainApply)) /*ܹҵ߼β*/ + || (CI_SUCCESS == chStartAdd)) /*Ѿӹ*/ + { + chStartAdd = CI_SUCCESS; + + for (kk = 0U; kk < wTrainUsableLgcSum; kk++) + { + if (wTrainIncLogicSecIdBuf[jj] == wszTrainUsableLgcIdBuf[kk]) + { + break; + } + else + { + ; /*ִ*/ + } + } + + } + else + { + /*ִ*/ + } + if ((kk == wTrainUsableLgcSum) && (CI_SUCCESS == chStartAdd)) + { + break; + } + else + { + ; /**/ + } + } + + /*ҵú󣬲ҵһõΣ¼ò*/ + (void)CommonMemCpy((void*)wszSetUnUsableLgcIdBuf, (UINT32)sizeof(wszSetUnUsableLgcIdBuf), (void*)(&wTrainIncLogicSecIdBuf[jj]), (UINT32)((wTrainIncLogcSecSum - jj) * sizeof(UINT16))); + wTrainUnUsableLgcSum = wTrainIncLogcSecSum - jj; + + for (jj = 0U; jj < wTrainUsableLgcSum; jj++) + { + for (kk = 0U; kk < wTrainIncLogcSecSum; kk++) + { + if (wTrainIncLogicSecIdBuf[kk] == wszTrainUsableLgcIdBuf[jj]) + { + break; + } + else + { + ; /*ִ*/ + } + } + + if (kk == wTrainIncLogcSecSum) + { + wszSetUnUsableLgcIdBuf[wTrainUnUsableLgcSum++] = wszTrainUsableLgcIdBuf[jj]; + } + } + + for (jj = 0U; jj < wTrainUnUsableLgcSum; jj++) + { + SetLogSecTrainUseState(wszSetUnUsableLgcIdBuf[jj], wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + } + } + } +} + +/* +* ·߼Դг +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLgcSecResUnlockManage(const UINT16 wRouteId) +{ + /*ʼ*/ + UINT8 chRouteState = 0u; + UINT8 chAutoSigRouteState = 0U; + UINT8 chStartSignalCurColor = 0U; + UINT8 chOpenCloseState = 0U; + UINT8 chRouteRepeatOpenFlag = 0U; + UINT16 wStartSignalId = 0U; + + /*ȡ·Ϣ*/ + chRouteState = GetRouteState(wRouteId); + wStartSignalId = GetRouteStartSignalId(wRouteId); + chAutoSigRouteState = GetRouteAutoSigSetState(wRouteId); /*ȡԶźŽ·״̬*/ + chStartSignalCurColor = GetSignalCurColor(wStartSignalId); + chOpenCloseState = GetSignalOpenCloseState(chStartSignalCurColor); + chRouteRepeatOpenFlag = GetRouteRepeatOpenFlag(wRouteId); + + if ((SIGNAL_OPEN == chOpenCloseState) && (ROUTE_STATE_HALF_UNLOCK != chRouteState) && (ROUTE_STATE_AUTO_UNLOCK != chRouteState)) + {/*ʼźŻ*/ + + } + else + { /*ʼźŻر*/ + if ((ROUTE_AUTOSIGROUTE_YES != chAutoSigRouteState) + && (ROUTE_REPEATOPEN_SET_YES != chRouteRepeatOpenFlag) + && ((ROUTE_STATE_AUTO_UNLOCK == chRouteState) + || (ROUTE_STATE_NEAR_LOCK == chRouteState) + || (ROUTE_STATE_HALF_UNLOCK == chRouteState))) /*ӦгͷŽ*/ + { + RouteLgcSecResUnlockProcess(wRouteId); + } + else /*ֻͷԴ*/ + { + + } + } + + /*TODO:ͷԴ*/ + + RouteLgcSecResReleaseProcess(wRouteId); +} + + +/* +* @brief ·߼ +* @param const UINT16 routeId ·ID +* const UINT16 trainId г +* @note WQM 20220307 +*/ +void RouteApplyLogicManage(const UINT16 routeId, const UINT16 trainId) +{ + UINT8 keepWork = CI_ERROR; + UINT8 routeCurState = ROUTE_STATE_IDLE; + UINT8 chRouteType = 0U; + + /** μ*/ + if ((0u == routeId) || (ROUTE_SUM_MAX <= routeId) || (TRAIN_ID_MIN >= trainId) || (TRAIN_ID_MAX <= trainId)) + { + keepWork = CI_ERROR; + } + else + { + keepWork = CI_SUCCESS; + } + if (CI_SUCCESS == keepWork) + { + chRouteType = GetRouteType(routeId); + if ((ROUTE_TYPE_LIECHE == chRouteType) + || (ROUTE_TYPE_RETURN == chRouteType)) + { + keepWork = CI_SUCCESS; + } + else + { + keepWork = CI_ERROR; + } + } + /** μϷɼִ*/ + if (CI_SUCCESS == keepWork) + { + routeCurState = GetRouteState(routeId); + + if ((ROUTE_STATE_YUXIAN_OPEN != routeCurState) && (ROUTE_STATE_NEAR_OPEN != routeCurState)) + { + /** ͨ·߼*/ + SetCommonRouteLogicManage(routeId); + } + else + { + /*·ѿţٰ·*/ + } + + routeCurState = GetRouteState(routeId); + + /** ·״̬Ϊ·򡾽·쳣ԤաԤȿš򡾽ӽ쳣򡾽ӽš*/ + if ((ROUTE_STATE_FIRST_LOCK == routeCurState) + || (ROUTE_STATE_FIRST_LOCKERR == routeCurState) + || (ROUTE_STATE_YUXIAN_LOCK == routeCurState) + || (ROUTE_STATE_YUXIAN_OPEN == routeCurState) + || (ROUTE_STATE_NEAR_LOCKERR == routeCurState) + || (ROUTE_STATE_NEAR_OPEN == routeCurState)) + { + /** ʱ߼δ״̬һֱý·߼ԴгID*/ + SetRouteLogicSecResTrainId(routeId, trainId); + } + /*·ӽźؿ*/ + else if (ROUTE_STATE_NEAR_LOCK == routeCurState) + { + /*ý·߼ԴгID*/ + } + /** ·ǡ·С״̬*/ + else if (ROUTE_STATE_IDLE != routeCurState) + { + /** ·ɹ߼λδգݲ߼гIDǼ¼ITS·гID߼ʱʹ*/ + SetITSRouteApplyTrainIDInfo(routeId, trainId); + } + /** ·У·δɹ*/ + else + { + /*账*/ + } + } + else + { + + } +} + +/* +* @brief 벿·߼ +* @param const UINT8 cLogSecSeqDir ߼з +* const UINT16 wTrainId г +* const UINT8 cLogSecSum ߼ +* const UINT16 pLogSecIdBuff[] ߼ +*/ +void RoutePartApplyLogicManage(const UINT8 cLogSecSeqDir, const UINT16 wTrainId, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[]) +{ + /*ֲʼ*/ + UINT8 keepWork = CI_ERROR; + UINT8 i = 0U; + UINT8 j = 0U; + UINT8 k = 0U; + UINT16 wVBTCOccLogSecSum = 0U; /*VBTCгռѹ߼*/ + UINT16 wVBTCOccLogSecID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*VBTCгռѹ߼ID*/ + UINT8 cRelatedSigSum = 0U; /*߼ιźŻ*/ + UINT16* pRelatedSigId = NULL; /*߼ιźŻID*/ + UINT8 cSignalProDir = 0U; /*źŻ*/ + UINT8 tempIndex = 0U; + UINT8 cEndSignalSum = 0U; /*߼ΰͬնźŻֺи*/ + UINT16 wEndSignalIdBuff[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*߼ΰͬնźŻID*/ + UINT8 cSplitLogSecSumBuff[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*ֺĸ߼а߼*/ + UINT16 wSplitLogSecIdBuff[ROUTE_SUBROUTE_SUM_MAX][MAX_ROUTE_IN_LT_NUM] = { 0U }; /*ֺĸ߼а߼ID*/ + UINT8 szQueryDir[UINT8_MAX] = { 0U }; /*߼ζӦIJѯ߼*/ + UINT8 cMatchedRouteSum = 0U; /*߼ƥɹĽ·RC·*/ + UINT16 wMatchedRouteIdBuff[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*߼ƥɹĽ·ID飬RC·*/ + UINT8 cDrSubSum = 0U; /*̬·ӽ·*/ + UINT16 wDrSubIdBuff[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*̬·ӽ·ID*/ + + struct_PathPoint start = { 0u }; /*г߼*/ + struct_PathPoint end = { 0u }; /*г߼յ*/ + UINT16 wCTOccLogSum = 0U; /*ͨг߼*/ + UINT16 wCTOccLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*ͨгռѹ߼ID*/ + UINT8 cHalfRouteSwitchMoveFlag = ROUTE_HALF_SWITCH_MOVE_INVALID; /*ؽ·ɶ־*/ + UINT8 cHalfRouteFlag = CI_ERROR; /*ؽ·־*/ + UINT16 wUsableDrId = 0U; /*СõĶ̬·ID*/ + UINT8 routeCurState = ROUTE_STATE_IDLE; /*·״̬*/ + UINT8 cCheckStep = 0U; /*¼еλãڴ*/ + UINT8 cLocalCiId = 0U; + UINT8 cRouteBelongCiId = 0U; + UINT8 cLogSecBelongCiId = 0U; + UINT16 wSigProLinkId = 0U; /*źŻlink*/ + UINT16* pLogSecIncLinkId = NULL; /*߼ΰlink*/ + LOD_STRU strCurPoint = { 0U }; + LOD_STRU strNxtPoint = { 0U }; + UINT8 cDirChangeNum = 0U; /*仯*/ + UINT8 cFirstLogSecDir = 0U; /*׸߼εIJѯӪ*/ + UINT8 cLogicRouteNum = 0U; /*ֳ߼·*/ + UINT8 szLrBelongCi[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*ֳ߼·*/ + UINT8 szLrDir[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*ֳ߼·ķ*/ + UINT16 szLrStartSignalId[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*ֳ߼·ʼźŻID*/ + UINT8 szLrIncLogSecNum[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*ֳ߼·߼*/ + UINT16 szLrIncLogSecId[ROUTE_SUBROUTE_SUM_MAX][MAX_ROUTE_IN_LT_NUM] = { 0U }; /*ֳ߼·߼ID*/ + UINT8 cEndSignalFlag = FLAG_UNSET; /*߼ǷնźŻ־ʼΪ*/ + UINT16 wLastEndSignalId = 0U; /*һеնźŻID*/ + UINT8 cLogicRouteFlag = FLAG_UNSET; /*һ߼ǷΪ߼·Ĭϲ*/ + UINT16 wUsableLogicRouteId = 0U; /*õС߼·ID*/ + UINT8 cCiType = 0U; /**/ + UINT8 cCommStateWithTrain = CI_ERROR; /*복ͨ״̬*/ + + cLocalCiId = GetSystemParaLocalCiId(); + + /*μ飨гIDݲ飩*/ + if (((CI_SYSTEM_DIRECTION_DOWN == cLogSecSeqDir) || (CI_SYSTEM_DIRECTION_UP == cLogSecSeqDir)) + && (0U != cLogSecSum) && (NULL != pLogSecIdBuff)) + { + keepWork = CI_SUCCESS; + } + else + { + keepWork = CI_ERROR; + } + + if (CI_SUCCESS == keepWork) + { + /*һ߼Ƿ*/ + keepWork = LogSecSeqIsContinuousCheck(cLogSecSeqDir, cLogSecSum, pLogSecIdBuff, szQueryDir); + cCheckStep++; + } + + if (CI_SUCCESS == keepWork) + { + /*ڶгԴǷȫзǷATS·зƥ*/ + keepWork = TrainResAndDirCheck(wTrainId, szQueryDir[0U], cLogSecSum, pLogSecIdBuff, &cHalfRouteSwitchMoveFlag, &wVBTCOccLogSecSum, wVBTCOccLogSecID); + cCheckStep++; + } + + if (CI_SUCCESS == keepWork) + { + /*߼*/ + for (i = 0U; i < cLogSecSum; i++) + { + /*ȡ߼ιźŻ/ID*/ + cRelatedSigSum = GetLogRelateEndSigSum(pLogSecIdBuff[i]); + pRelatedSigId = GetLogRelateEndSigData(pLogSecIdBuff[i]); + pLogSecIncLinkId = GetSecIntrudeLinkIdBuf(pLogSecIdBuff[i]); + cEndSignalFlag = FLAG_UNSET; /*ÿ߼һնźŻ־*/ + + /*ѡ߼ιźŻзATS·зͬźŻ߼*/ + if ((NULL != pRelatedSigId) && (NULL != pLogSecIncLinkId)) + { + for (j = 0U; j < cRelatedSigSum; j++) + { + cSignalProDir = GetSignalDirection(pRelatedSigId[j]); + wSigProLinkId = GetSignalProtectLink(pRelatedSigId[j]); + strCurPoint.Lnk = pLogSecIncLinkId[0U]; + strCurPoint.Off = 0U; + strNxtPoint.Lnk = wSigProLinkId; + strNxtPoint.Off = 0U; + cDirChangeNum = GetDirChangeNumBtwPoints(&strCurPoint, &strNxtPoint); /*ѯǰlinkźŻlinkķ仯*/ + cSignalProDir = TransDirByChangeNum(cSignalProDir, cDirChangeNum); + + if (cSignalProDir == szQueryDir[i]) + { + /*ԵǰźŻΪֽ㣬ֳ߼*/ + for (k = tempIndex; k < (i + 1U); k++) + { + wSplitLogSecIdBuff[cEndSignalSum][cSplitLogSecSumBuff[cEndSignalSum]] = pLogSecIdBuff[k]; /*洢ֵ߼ID*/ + cSplitLogSecSumBuff[cEndSignalSum]++; /*洢ǰֵ߼а߼*/ + } + + wLastEndSignalId = pRelatedSigId[j]; /*洢еնźŻIDΪһ߼·ʼźŻ*/ + wEndSignalIdBuff[cEndSignalSum] = pRelatedSigId[j]; /*洢ͬնźŻID*/ + cEndSignalSum++; + tempIndex = i + 1U; /*洢ǰλã´β߼е*/ + + cEndSignalFlag = FLAG_SET; /*߼δնźŻϴڱ־*/ + break; + } + else + { + /*ͬնźŻ*/ + } + } + + if ((i == (cLogSecSum - 1U)) && (FLAG_UNSET == cEndSignalFlag)) + { + /*һ߼βնźŻ߼ʣµ߼߼·߼*/ + for (k = tempIndex; k < cLogSecSum; k++) + { + cLogSecBelongCiId = GetLogSecBelongCiId(pLogSecIdBuff[k]); + + if ((0U == szLrBelongCi[cLogicRouteNum]) && (0U != cLogSecBelongCiId)) + { + szLrBelongCi[cLogicRouteNum] = cLogSecBelongCiId; /*Ϊһ߼·ӽ·*/ + szLrDir[cLogicRouteNum] = szQueryDir[k]; /*洢߼·ķ*/ + szLrStartSignalId[cLogicRouteNum] = wLastEndSignalId; /*洢߼·ʼźŻID*/ + wLastEndSignalId = 0U; /*һ߼·ʼźŻΪһеնźŻ߼·ʼźŻIDĬΪ0*/ + } + + if ((cLogSecBelongCiId != szLrBelongCi[cLogicRouteNum]) && (0U != cLogSecBelongCiId)) + { + cLogicRouteNum++; + szLrBelongCi[cLogicRouteNum] = cLogSecBelongCiId; /*Ϊ߼·ӽ·*/ + szLrDir[cLogicRouteNum] = szQueryDir[k]; /*洢߼·ķ*/ + szLrStartSignalId[cLogicRouteNum] = wLastEndSignalId; /*洢߼·ʼźŻID*/ + } + + szLrIncLogSecId[cLogicRouteNum][szLrIncLogSecNum[cLogicRouteNum]] = pLogSecIdBuff[k]; /*洢ֵ߼ID*/ + szLrIncLogSecNum[cLogicRouteNum]++; /*洢ǰֵ߼а߼*/ + } + + cLogicRouteNum++; + + keepWork = LogSecIsSwitchAndStopAreaCheck(pLogSecIdBuff[cLogSecSum - 1U]); /*һ߼εͣ*/ + } + } + else + { + keepWork = CI_ERROR; + } + + /*߼ǷԽ*/ + keepWork &= SeqNumAndIncLogSecNumCheck(cEndSignalSum, cSplitLogSecSumBuff); + keepWork &= SeqNumAndIncLogSecNumCheck(cLogicRouteNum, szLrIncLogSecNum); + + if (CI_ERROR == keepWork) + { + break; /*ʧܣֹͣ*/ + } + } + + cCheckStep++; + } + + if (CI_SUCCESS == keepWork) + { + /*IJ߼У·ƥ*/ + if (0U != cEndSignalSum) + { + keepWork = LogSecSeqAndRouteMatchCheck(cEndSignalSum, wEndSignalIdBuff, cSplitLogSecSumBuff, wSplitLogSecIdBuff, wMatchedRouteIdBuff, &cLogicRouteFlag); + + if (FLAG_UNSET == cLogicRouteFlag) + { + cMatchedRouteSum = cEndSignalSum; + } + else + { + /*δƥ׸д߼·߼*/ + for (k = 0U; k < cSplitLogSecSumBuff[0U]; k++) + { + szLrIncLogSecId[cLogicRouteNum][szLrIncLogSecNum[cLogicRouteNum]] = wSplitLogSecIdBuff[0U][k]; /*洢߼·߼ID*/ + szLrIncLogSecNum[cLogicRouteNum]++; /*洢߼·߼*/ + } + + cLogSecBelongCiId = GetLogSecBelongCiId(wSplitLogSecIdBuff[0U][0U]); + szLrBelongCi[cLogicRouteNum] = cLogSecBelongCiId; /*Ϊ߼·ӽ·*/ + szLrDir[cLogicRouteNum] = szQueryDir[0U]; /*洢߼·ķ*/ + szLrStartSignalId[cLogicRouteNum] = 0U; /*׸е߼·ʼźŻĬΪ0*/ + cLogicRouteNum++; + + keepWork = LogSecIsSwitchAndStopAreaCheck(szLrIncLogSecId[cLogicRouteNum - 1U][szLrIncLogSecNum[cLogicRouteNum - 1U] - 1U]); /*һ߼εͣ*/ + keepWork &= SeqNumAndIncLogSecNumCheck(cLogicRouteNum, szLrIncLogSecNum); /*У߼·߼Ƿ*/ + + /*ƥ·дڵ߼·Ϣ*/ + cMatchedRouteSum = cEndSignalSum - 1U; /*߼·ƥĽ·1*/ + for (k = 0U; k < cMatchedRouteSum; k++) + { + /*߼·ƥĵһ·IDΪ0ɾ*/ + wMatchedRouteIdBuff[k] = wMatchedRouteIdBuff[k + 1U]; + wMatchedRouteIdBuff[k + 1U] = 0U; + + for (j = 0U; j < cSplitLogSecSumBuff[k + 1U]; j++) + { + /*߼·轫ֳĵһ߼ɾӰӽ·߼*/ + wSplitLogSecIdBuff[k][j] = wSplitLogSecIdBuff[k + 1U][j]; + wSplitLogSecIdBuff[k + 1U][j] = 0U; + } + + cSplitLogSecSumBuff[k] = cSplitLogSecSumBuff[k + 1U]; /*ɾһ߼а߼*/ + cSplitLogSecSumBuff[k + 1U] = 0U; + } + } + } + + cCheckStep++; + } + + if (CI_SUCCESS == keepWork) + { + /*岽ͨųûǰ˿*/ + keepWork = CtTrainHeadSuspCheck(wTrainId, cLogSecSeqDir, pLogSecIdBuff[0U]); + cCheckStep++; + } + + if (CI_SUCCESS == keepWork) + { + /*ɸѡؽ··*/ + cCommStateWithTrain = GetTrainTransitmitStat(wTrainId); + + if (TRAIN_COMM_STATE_GOOD == cCommStateWithTrain) + { + end.wLinkId = GetTrainMaxHeadLink(wTrainId); + end.dwOffset = GetTrainMaxHeadOffset(wTrainId); + start.wLinkId = GetTrainMinTailLink(wTrainId); + start.dwOffset = GetTrainMinTailOffset(wTrainId); + keepWork = GetLogSecBtwTwoPoints(start, end, &wCTOccLogSum, wCTOccLogID); /*ȡͨų߼Ϣ˴ÿǷ*/ + } + else + { + wCTOccLogSum = 0U; /*ͨų*/ + } + + if (CI_SUCCESS == keepWork) + { + debug_infor_printf((const)"HalfRouteSwitchMoveFlag:0x%x\n", cHalfRouteSwitchMoveFlag); + debug_infor_printf((const)"Half Route Id:[ "); + /*̬·*/ + for (i = 0U; i < cMatchedRouteSum; i++) + { + cHalfRouteFlag = HalfRouteTypeCheck(i, wMatchedRouteIdBuff, wCTOccLogSum, wCTOccLogID, cLogicRouteFlag); + + /*ȷҪ߼вѯ*/ + cRouteBelongCiId = GetRouteBelongCiId(wMatchedRouteIdBuff[i]); + cCiType = GetCiType(cRouteBelongCiId); + if (0U == i) + { + tempIndex = 0U; + } + else + { + tempIndex += cSplitLogSecSumBuff[i - 1U]; + } + + if (CI_SUCCESS == cHalfRouteFlag) /*ؽ·*/ + { + if ((cLocalCiId == cRouteBelongCiId) && (0U != cLocalCiId)) + { + /*ؽ·ṹ*/ + SetHalfRouteSwitchMoveValid(wMatchedRouteIdBuff[i], cHalfRouteSwitchMoveFlag); /*ðؽ·ɶ־*/ + SetHalfRouteLockLgcSec(wMatchedRouteIdBuff[i], cSplitLogSecSumBuff[i], wSplitLogSecIdBuff[i]); /*ðؽ·յ߼*/ + SetHalfRouteResReqTrainId(wMatchedRouteIdBuff[i], wTrainId); /*÷ԴгID*/ + SetHalfRouteTrainLocLgcSec(wMatchedRouteIdBuff[i], (UINT8)wVBTCOccLogSecSum, wVBTCOccLogSecID); /*ðؽ·г߼*/ + + keepWork = HalfRoutePhySecUseLogicProcess(wMatchedRouteIdBuff[i]); /*ӽ·ü*/ + if (CI_SUCCESS == keepWork) + { + debug_infor_printf((const)"%d,", wMatchedRouteIdBuff[i]); + wDrSubIdBuff[cDrSubSum] = wMatchedRouteIdBuff[i]; + cDrSubSum++; + } + else + { + SetRouteStateManage(wMatchedRouteIdBuff[i], ROUTE_STATE_IDLE); /*ʧܣý·*/ + } + } + else if ((cLocalCiId != cRouteBelongCiId) && (0U != cLocalCiId) && (CI_TYPE_CLD != cCiType)) + { + /*ӵ͸dz̬·ṹ*/ + cFirstLogSecDir = ConvertLogicDirToRun(szQueryDir[tempIndex]); + AddCiSendToCiDrCmdHalfInfo(wTrainId, (UINT8)wVBTCOccLogSecSum, wVBTCOccLogSecID, cHalfRouteSwitchMoveFlag, 0U); + AddCiSendToCiDrCmdLogSecInfo(CICI_DR_CMD_HALF, cFirstLogSecDir, cSplitLogSecSumBuff[i], wSplitLogSecIdBuff[i], cRouteBelongCiId); + } + else + { + /**/ + } + } + else /*·*/ + { + keepWork = RoutePhySectionUseLogicProcess(wMatchedRouteIdBuff[i]); /*ӽ·ü*/ + if (CI_SUCCESS == keepWork) + { + if ((cLocalCiId == cRouteBelongCiId) && (0U != cLocalCiId)) + { + routeCurState = GetRouteState(wMatchedRouteIdBuff[i]); + /*·ǡ·С״̬*/ + if ((ROUTE_STATE_IDLE == routeCurState) || (ROUTE_STATE_HALF_UNLOCK == routeCurState)) + { + /*·ͨ¼ITS·гID߼ʱʹ*/ + SetITSRouteApplyTrainIDInfo(wMatchedRouteIdBuff[i], wTrainId); + } + else + { + /*账*/ + } + wDrSubIdBuff[cDrSubSum] = wMatchedRouteIdBuff[i]; + cDrSubSum++; + } + else if ((cLocalCiId != cRouteBelongCiId) && (0U != cLocalCiId)) + { + /*ӵ͸̬·ṹ*/ + cFirstLogSecDir = ConvertLogicDirToRun(szQueryDir[tempIndex]); + AddCiSendToCiDrCmdHalfInfo(wTrainId, (UINT8)wVBTCOccLogSecSum, wVBTCOccLogSecID, cHalfRouteSwitchMoveFlag, 0U); + AddCiSendToCiDrCmdLogSecInfo(CICI_DR_CMD_FULL, cFirstLogSecDir, cSplitLogSecSumBuff[i], wSplitLogSecIdBuff[i], cRouteBelongCiId); + } + else + { + /**/ + } + } + } + + if (CI_SUCCESS != keepWork) + { + break; /*ӽ·ʧܣ̬·ʧ*/ + } + } + debug_infor_printf((const)"]\n"); + + if ((CI_SUCCESS == keepWork) && (0U != cDrSubSum)) + { + /*ƥĽ·̬·*/ + wUsableDrId = GetUsableDrId(); + SetDrSubRoute(wUsableDrId, cDrSubSum, wDrSubIdBuff); + + debug_infor_printf((const)"Dynamic Sub Route Sum:%d, Dynamic Sub Route ID:[", cDrSubSum); + for (i = 0U; i < cDrSubSum; i++) + { + debug_infor_printf((const)"%d,", wDrSubIdBuff[i]); + } + debug_infor_printf((const)"]\n"); + } + + /*߼·*/ + for (i = 0U; i < cLogicRouteNum; i++) + { + if (0U == szLrStartSignalId[i]) + { + /*߼·ʼźŻΪ0迼ǷΪATSֽ·߼·ְĽ*/ + szLrStartSignalId[i] = LogicRouteAddStartSignalCheck(szLrIncLogSecId[i][0U], szLrDir[i], wTrainId); + } + + keepWork = CheckLogicRouteCbtcProperty(szLrIncLogSecNum[i], szLrIncLogSecId[i]); /*߼·߼εCBTC*/ + if (CI_SUCCESS == keepWork) + { + cCiType = GetCiType(szLrBelongCi[i]); + if ((cLocalCiId == szLrBelongCi[i]) && (0U != cLocalCiId)) + { + /*߼·߼·ṹ*/ + wUsableLogicRouteId = GetUsableLogicalRouteId(); + if (0U != wUsableLogicRouteId) + { + keepWork = RepeatSetLogicRouteCheck(szLrIncLogSecNum[i], szLrIncLogSecId[i], wTrainId); /*߼·Ƿظ*/ + + if (CI_SUCCESS == keepWork) + { + cLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + cFirstLogSecDir = ConvertLogicDirToRun(szLrDir[i]); /*߼תΪӪ*/ + + SetLogicalRouteBelongCiId(wUsableLogicRouteId, cLocalCiId); + SetLogicalRouteDir(wUsableLogicRouteId, cFirstLogSecDir); /*߼·*/ + SetLogicalRouteSwitchMoveFlag(wUsableLogicRouteId, cHalfRouteSwitchMoveFlag); /*߼·ɶ־*/ + SetLogicalRouteRelateBeginSigId(wUsableLogicRouteId, szLrStartSignalId[i]); /*߼·ʼźŻ*/ + LogicRouteLevelConfirmProcess(wUsableLogicRouteId); /*ȷ߼·ල*/ + SetLogRouteApplyResTrainData(wUsableLogicRouteId, wTrainId); /*ATSԴгID*/ + SetLogicalRouteInLogSecData(wUsableLogicRouteId, szLrIncLogSecNum[i], szLrIncLogSecId[i]); /*߼·߼*/ + SetLogicalRouteTrainLogSecData(wUsableLogicRouteId, wVBTCOccLogSecSum, wVBTCOccLogSecID); /*г°߼*/ + LogicRouteOpenColorProc(wUsableLogicRouteId); /*߼·ʼźŻɫ*/ + LogRouteOutLgcSecConfigDataInit(wUsableLogicRouteId); + + /*ͨ߼·״̬Ϊѡ߼·״̬*/ + keepWork = LogRoutePhySecUseLogicProcess(wUsableLogicRouteId); + if (CI_SUCCESS == keepWork) + { + SetLogRouteStateManage(wUsableLogicRouteId, ROUTE_LOGICAL_STATE_FIRST_XUANPAI); + + debug_infor_printf((const)"Dynamic Logic Route Set Is Success! Dynamic Logic Route ID:%d\n", wUsableLogicRouteId); + } + else + { + SetLogRouteStateManage(wUsableLogicRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + } + else + { + debug_infor_printf((const)"Dynamic Logic Route Set Is Error: LogicRoute Repeat Set!\n"); /*߼·ظͣ*/ + } + } + else + { + /*޿߼·*/ + debug_infor_printf((const)"Dynamic Logic Route Set Is Error: LogicRoute Is Not Idle!\n"); + } + } + else if ((cLocalCiId != szLrBelongCi[i]) && (0U != cLocalCiId) && (CI_TYPE_CLD != cCiType)) + { + /*ӵ͸߼·ṹ*/ + cFirstLogSecDir = ConvertLogicDirToRun(szLrDir[i]); + AddCiSendToCiDrCmdHalfInfo(wTrainId, (UINT8)wVBTCOccLogSecSum, wVBTCOccLogSecID, cHalfRouteSwitchMoveFlag, szLrStartSignalId[i]); + AddCiSendToCiDrCmdLogSecInfo((UINT8)CICI_DR_CMD_LOGIC, cFirstLogSecDir, szLrIncLogSecNum[i], szLrIncLogSecId[i], szLrBelongCi[i]); + } + else + { + /**/ + } + } + else + { + debug_infor_printf((const)"Dynamic Logic Route Set Is Error: LogSec Is Not CBTC Property!\n"); /*߼·ʧܣ߼ηCBTC*/ + } + } + } + + cCheckStep++; + } + + /*¼־*/ + if (CI_SUCCESS != keepWork) + { + /*ʧܣ¼־ + cCheckStepΪ0ʾУʧܣΪ1ʾ߼ԼʧܣΪ2ʾгԴͷʧܣΪ3ʾʧܣ + Ϊ4ʾƥ·ʧܣΪ5ʾسʧܣΪ6ʾ·ʧ*/ + debug_infor_printf((const)"Route Part Apply Error! Error Position Is [%d]\n", cCheckStep); + } +} + +/* +* ź߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +* note޸bug YF0083-200 +*/ +void OpenXianSuSignalLogicManage(const UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 chKeepWork = CI_ERROR; /*־λ*/ + UINT16 wSignalInFirstPhyId = 0U; + UINT16 wLockRouteId = 0U; + UINT16 wRouteStartSignalId = 0U; + UINT8 chRouteLevel = 0U; + UINT8 cRouteZongQuXiaoState = 0u; + UINT8 cRouteZongRenJieState = 0u; + + if ((0u == signalId) || (SIGNAL_SUM_MAX <= signalId)) + { + chKeepWork = CI_ERROR; + } + else + { + chKeepWork = CI_SUCCESS; + } + + if (CI_SUCCESS == chKeepWork) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + chKeepWork = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } + + if (CI_SUCCESS == chKeepWork) + { + + wSignalInFirstPhyId = GetSignalInFirstLockedPhySecId(signalId); + wLockRouteId = GetPhySecRLockBelongRouteId(wSignalInFirstPhyId);/*·ID*/ + if ((0u == wLockRouteId) || (ROUTE_SUM_MAX <= wLockRouteId)) + { + chKeepWork = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } + + if (CI_SUCCESS == chKeepWork) + { + chRouteLevel = GetRouteLevel(wLockRouteId); + + /*·ȼΪʽ·*/ + if (ROUTE_LEVEL_BLOC != chRouteLevel) + { + chKeepWork = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } + + if (CI_SUCCESS == chKeepWork) + { + /**·ںͽ·Ƿһ߼ʱ*/ + chKeepWork = CheckRouteLgsLinShiXianSuExist(wLockRouteId); + } + else + { + ; + } + + if (CI_SUCCESS == chKeepWork) + { + cRouteZongQuXiaoState = GetRouteZongQuXiaoFlag(wLockRouteId); + cRouteZongRenJieState = GetRouteZongRenJieFlag(wLockRouteId); + if ((ROUTE_ZONGQUXIAO_SET_YES == cRouteZongQuXiaoState) || + (ROUTE_ZONGRENJIE_SET_YES == cRouteZongRenJieState)) + { /*ȡ˽*/ + SetErrorData(EFUNC_CANCLE_ROUTE, CI_DEVICE_TYPE_ROUTE, wLockRouteId, ETYPE_ROUTE_CANCEL, CI_ERROR, ESEND_LEVEL_ATS);/*ȡ˽ʱźؿЧ¼ϲֵغATSͷ*/ + chKeepWork = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } + + if (CI_SUCCESS == chKeepWork) + { + wRouteStartSignalId = GetRouteStartSignalId(wLockRouteId); + if (signalId == wRouteStartSignalId) + { /*ǽ·ʼźŻID*/ + routeState = GetRouteState(wLockRouteId); /*ȡ·״̬*/ + + if ((ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_NEAR_LOCK == routeState)) + { /*·״̬Ϊ: 쳣||Ԥ||ӽ쳣||ӽ޸ڣ20170209ԭ֧ڽӽʱӦźؿ*/ + + SetRouteXianSuConfirmStt(wLockRouteId, ROUTE_XIANSU_CONFIRM_YES); + SetRouteRepeatOpenFlag(wLockRouteId, ROUTE_REPEATOPEN_SET_YES); /*ý·źؿ־*/ + + SetRouteOpenSigStartCycNum(wLockRouteId, Get2oo2CurCycleNum()); /*źſʱ*/ +#if 0 + SetOverlapLockStartCycNum(routeId,Get2oo2CurCycleNum()); /* ñʱ */ +#endif + } + else if (ROUTE_STATE_DELAY_UNLOCK == routeState) + {/*˽ʱڼ䣬źؿЧ¼ϲֵغATSͷ*/ + SetErrorData(EFUNC_CANCLE_ROUTE, CI_DEVICE_TYPE_ROUTE, wLockRouteId, ETYPE_ROUTE_CANCEL, CI_ERROR, ESEND_LEVEL_ATS); + } + else + { + ; /*DO NOTHING*/ + } + + } + else + { + ; + } + } + else + { + ; + } +} + +/* +* TIOC߼ԾIVOCͬͨ״̬µĴ +* ˵const UINT16 logSectionId߼ID + const UINT16 trainId,гID +* ֵ void +* +*/ +static void TrainTransitmitStatJumpLockProcess(const UINT16 logSectionId, const UINT16 trainId) +{ + UINT8 logSecJumpDelayUnlockFlag = LOGIC_JUMPUNLOCK_DELAY_SET_NO; + UINT32 startTimeCycle = 0u; + UINT32 secJumpLockDelayUnlockCount = 0u; + UINT8 overTimeCheck = CI_TIME_OUT; + UINT32 curCycle = 0u; + UINT8 trainTransmitState = TRAIN_COMM_STATE_UNKNOWN; + UINT16 bufIndex = 0u; /*±*/ + UINT8 localCi = 0u;/**/ + UINT8 logSecBelongCiId = 0u; + + + localCi = GetSystemParaLocalCiId(); + + curCycle = Get2oo2CurCycleNum(); + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** μ*/ + if ((LOGIC_SECTION_SUM_MAX > bufIndex) + && (TRAIN_ID_MIN < trainId) && (TRAIN_ID_MAX > trainId)) + { + logSecBelongCiId = GetLogSecBelongCiId(logSectionId); + if (localCi == logSecBelongCiId) + { + /** ȡIVOCTIOCͨ״̬*/ + trainTransmitState = GetTrainTransitmitStat(trainId); + /** ͨ״̬*/ + if (TRAIN_COMM_STATE_GOOD == trainTransmitState) + { + /** ָͨţʱ */ + /** Ծʱʼںźʱñ־*/ + SetLogSecJumpDelayUnlocStartCyc(logSectionId, 0u); + SetLogSecJumpDelayUnlockFlag(logSectionId, LOGIC_JUMPUNLOCK_DELAY_SET_NO); + } + else + { + /** ͨж */ + logSecJumpDelayUnlockFlag = GetLogSecJumpDelayUnlockFlag(logSectionId); + /** δʱ־ */ + if (LOGIC_JUMPUNLOCK_DELAY_SET_NO == logSecJumpDelayUnlockFlag) + { + /** Ծʱʼںźʱñ־*/ + SetLogSecJumpDelayUnlocStartCyc(logSectionId, curCycle); + SetLogSecJumpDelayUnlockFlag(logSectionId, LOGIC_JUMPUNLOCK_DELAY_SET_YES); + } + else + { + /** ʱ־жʱǷʱ */ + startTimeCycle = GetLogSecJumpDelayUnlocStartCyc(logSectionId); + secJumpLockDelayUnlockCount = GetSysParaSecJLokDelayUnlockCyc(); + overTimeCheck = SystemOverTimeCheck(startTimeCycle, secJumpLockDelayUnlockCount); + /** ѳʱ */ + if (CI_TIME_OUT == overTimeCheck) + { + /** ԾгID */ + ClearLogSecJumpLockTrainId(logSectionId); + /** Ծ־Ϊֹ */ + SetLogSecJumpLockPermFlag(logSectionId, LOGIC_JUMPUNLOCK_PERMISSIVE_NO); + /** ߼Ծδ*/ + SetLogSecJumpLockState(logSectionId, LOGIC_SECTION_JUMP_LOCK_NO); + /** ߼ιԾ״̬ */ + SetLogRelaPhySecJumpLockSta(logSectionId); + /** Ծʱʼںźʱñ־*/ + SetLogSecJumpDelayUnlocStartCyc(logSectionId, 0u); + SetLogSecJumpDelayUnlockFlag(logSectionId, LOGIC_JUMPUNLOCK_DELAY_SET_NO); + } + else + { + /** */ + } + } + } + } + else + { + /** ߼βڱ */ + } + } + else + { + /** */ + } +} + +/* +* ·ͱٴһʱٵ߼ +* ˵const UINT16 routeId·ID +* ֵ CI_ERROR δʱ + CI_SUCCESS һ߼ʱ +* wqm 20220809 +*/ +UINT8 CheckRouteLgsLinShiXianSuExist(const UINT16 routeId) +{ + UINT8 retValue = CI_ERROR; + UINT16 routeSectionSum = 0u; + UINT16* pRouteSectionDataBuf = NULL; + UINT16 overlapId = 0u; + UINT8 routeOvlapSectionSum = 0u; + UINT16* pRouteOvlapSectionDataBuf = NULL; + UINT16 i = 0u; + UINT8 j = 0u; + UINT16 logSecId = 0u; + UINT8 logSecState = 0u; + UINT8 wRouteRelSwitchNum = 0U; /*·ĵ*/ + RouteSwitchStruct* pRouteRelSwitchStr = NULL; /*·ĵṹ*/ + UINT16 wRouteRelSwitchId = 0U; /*·ĵID*/ + UINT8 wOvlpRelSwitchNum = 0U; /*ιĵ*/ + OverlapConditionSwitchStruct* pOvlpRelSwitchStr = NULL; /*ιĵṹ*/ + UINT16 wOvlpRelSwitchId = 0U; /*ιĵID*/ + UINT8 cCheckFlag = CI_SUCCESS; + UINT16 devId = 0U; + UINT8 devState = 0U; + + /** ȡ·߼κͽ·ΰ߼*/ + routeSectionSum = GetRouteLogSectionSum(routeId); + pRouteSectionDataBuf = GetRouteLogSectionIdBuf(routeId); + overlapId = GetRouteOverlapLockedId(routeId); + routeOvlapSectionSum = GetOverlapLogicSectionSum(overlapId); + pRouteOvlapSectionDataBuf = GetOverlapLogicSectionBuf(overlapId); + + /** ·߼ʱ״̬*/ + for (i = 0u; i < routeSectionSum; i++) + { + logSecId = pRouteSectionDataBuf[i]; + logSecState = GetLogSecLinShiXianSuSetState(logSecId); + if (logSecState == LOGSEC_LSXS_SET_STATE_YES) + { + /** ·һ߼ʱ*/ + break; + } + else + { + + } + } + /** ·߼ξδʱ,·ڵʱ״̬*/ + if (i == routeSectionSum) + { + retValue = CI_ERROR; + /** ·ΰ߼ʱ״̬*/ + for (j = 0u; j < routeOvlapSectionSum; j++) + { + logSecId = pRouteOvlapSectionDataBuf[j]; + logSecState = GetLogSecLinShiXianSuSetState(logSecId); + if (logSecState == LOGSEC_LSXS_SET_STATE_YES) + { + /** ·һ߼ʱ*/ + break; + } + else + { + + } + } + /** ·߼ξδʱ*/ + if (j == routeOvlapSectionSum) + { + /*·ڵ߼ʱ״̬*/ + wRouteRelSwitchNum = GetRouteSwitchSum(routeId); + pRouteRelSwitchStr = GetRouteSwitchData(routeId); + if ((0U != wRouteRelSwitchNum) && (NULL != pRouteRelSwitchStr)) + { + for (j = 0U; j < wRouteRelSwitchNum; j++) + { + devId = 0U; + devState = 0U; + wRouteRelSwitchId = pRouteRelSwitchStr[j].SwitchId; + cCheckFlag = SwitchRelLogSecLSXSStateCheck(wRouteRelSwitchId, &devId, &devState); + + if (CI_ERROR == cCheckFlag) + { + /*߼ʱ٣سɹ*/ + retValue = CI_SUCCESS; + break; + } + else + { + /**/ + } + } + } + else + { + /**/ + } + + /*ڵ߼ʱ״̬*/ + wOvlpRelSwitchNum = GetOverlapSwitchSum(overlapId); + pOvlpRelSwitchStr = GetOverlapCondSwitchStruct(overlapId); + if ((CI_SUCCESS != retValue) && (0U != wOvlpRelSwitchNum) && (NULL != pOvlpRelSwitchStr)) + { + cCheckFlag = CI_SUCCESS; + for (j = 0U; j < wOvlpRelSwitchNum; j++) + { + devId = 0U; + devState = 0U; + wOvlpRelSwitchId = pOvlpRelSwitchStr[j].SwitchId; + cCheckFlag = SwitchRelLogSecLSXSStateCheck(wOvlpRelSwitchId, &devId, &devState); + + if (CI_ERROR == cCheckFlag) + { + /*߼ʱ٣سɹ*/ + retValue = CI_SUCCESS; + break; + } + else + { + /**/ + } + } + } + else + { + /**/ + } + } + else + { + /** ·һ߼ʱ*/ + retValue = CI_SUCCESS; + } + } + else + { + /** ·һ߼ʱ*/ + retValue = CI_SUCCESS; + } + + return retValue; +} + +/* +* ·ȡԴ߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteCancelResLogicManage(const UINT16 wRouteId, const UINT16 wTrainId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 ii = 0u; + UINT8 chKeepWork = CI_ERROR; + UINT8 chTrainCommStt = 0U; + UINT16 wLgcLockBelongRouteId = 0U; + UINT8 chLgcTrainResSum = 0U; + LogicTrainResStruct* pLgcTrainResInfo = NULL; + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT32 curCycle = 0u; /*ƽ̨ں*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 autoSigRouteState = 0u; /*ԶźŽ·״̬*/ + + const UINT16 wRouteInLgcSecSum = GetRouteLogSectionSum(wRouteId); + const UINT16* pRouteInLgcSecBuf = GetRouteLogSectionIdBuf(wRouteId); + UINT16 wRouteNearestTrainId = GetRouteNODirNearestTrainId(wRouteId); /*ȡ·ӽг,г*/ + + UINT8 flagCancel = 0u;/*ȡ־*/ + + curCycle = Get2oo2CurCycleNum(); /*ȡƽ̨ں*/ + routeState = GetRouteState(wRouteId); /*ȡ·״̬*/ + + + if ((0u == wRouteId) || (ROUTE_SUM_MAX <= wRouteId)) + { + chKeepWork = CI_ERROR; + } + else + { + chKeepWork = CI_SUCCESS; + } + + if (CI_SUCCESS == chKeepWork) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(wRouteId); /*ȡ·ID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + chKeepWork = CI_ERROR; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +#if 0 + if (CI_SUCCESS == chKeepWork) + { + chRouteType = GetRouteType(wRouteId); /*ȡ·*/ + + if (ROUTE_TYPE_RETURN != chRouteType) + { + chKeepWork = CI_ERROR; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == chKeepWork) + { + chTrainZeroSpeStt = GetTrainZeroState(wTrainId); /*ȡгٱ־*/ + + if (TRAIN_SPEED_ZERO_YES != chTrainZeroSpeStt) + { + chKeepWork = CI_ERROR; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +#endif + if (CI_SUCCESS == chKeepWork) + { + chTrainCommStt = GetTrainTransitmitStat(wTrainId); /*ȡгͨ״̬*/ + + if (TRAIN_COMM_STATE_GOOD != chTrainCommStt) + { + chKeepWork = CI_ERROR; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + /*гԴ*/ + if (CI_SUCCESS == chKeepWork) + { + + if ((0U != wRouteInLgcSecSum) + && (MAX_ROUTE_IN_LT_NUM > wRouteInLgcSecSum)) + { + for (ii = 0U; ii < wRouteInLgcSecSum; ii++) + { + chLgcTrainResSum = GetLogSecTrainInfoSum(pRouteInLgcSecBuf[ii]); + if (0U < chLgcTrainResSum) /*·߼гԴ*/ + { + pLgcTrainResInfo = GetLogSecTrainInfoById(pRouteInLgcSecBuf[ii], wTrainId); + wLgcLockBelongRouteId = GetLogSecLockBelongRoute(pRouteInLgcSecBuf[ii]); + if ((NULL == pLgcTrainResInfo) || (wRouteId != wLgcLockBelongRouteId)) + { + chKeepWork = CI_ERROR; + } + else + { + ; /*ִ*/ + } + } + else + { + chKeepWork = CI_ERROR; + } + + if (CI_ERROR == chKeepWork) + { + break; + } + else + { + ; /*ִ*/ + } + } + } + else + { + chKeepWork = CI_ERROR;/*ʧ*/ + } + } + else + { + ; /**/ + } + + /*гǷΪӽ·г*/ + if (CI_SUCCESS == chKeepWork) + { + checkResult = RouteAllSecOccuClearCheck(wRouteId, &devId, &devState); /*·м*/ + wRouteNearestTrainId |= 0x1400U; /*ϳ*/ + autoSigRouteState = GetRouteAutoSigSetState(wRouteId); /*ȡ·Զź״̬*/ + + if (ROUTE_AUTOSIGROUTE_YES == autoSigRouteState) /*·ԶźŲ*/ + { + ;/**/ + } + else if (wRouteNearestTrainId == wTrainId) /*ATS·гΪһг(ӽ),20SȻ˽߼,϶Ӧгںţ߼з*/ + { + /*ȡԶͨ*/ + flagCancel = CancleAutoFlag(wRouteId); + + SetRouteZhefanJiesuoTrainId(wRouteId, wTrainId); /*Ҫ۷гID*/ + SetRouteZhefanJiesuoCyc(wRouteId, curCycle); /*Ҫ۷ں*/ + } + else /*ATS·ij,ҽ·Զź*/ + { + if (CI_SUCCESS != checkResult) /*·ռѹѯԴȡ*/ + { + /*ȡԴյظɾԴ,ʼʱһʱδӵȡԴظѯ*/ + SetRouteResourceCancelTrainId(wRouteId, wTrainId); + SetRouteResourceCancelCyc(wRouteId, curCycle); + SetRouteResCancelDelayFlag(wRouteId, RUUTE_RESCANCEL_DELAY_YES); + } + else + { + if ((ROUTE_STATE_XUANPAI == routeState) + || (ROUTE_STATE_FIRST_XUANPAI == routeState) + || (ROUTE_STATE_FIRST_LOCK == routeState) + || (ROUTE_STATE_FIRST_LOCKERR == routeState) + || (ROUTE_STATE_YUXIAN_LOCK == routeState) + || (ROUTE_STATE_YUXIAN_OPEN == routeState)) + { + /*·δӽգȡ߼*/ + RouteZongQuXiaoLogicManage(wRouteId); + } + else /*ӽ*/ + { + /*ȡԴɾԴгں*/ + SetRouteResourceCancelTrainId(wRouteId, wTrainId); + SetRouteResourceCancelCyc(wRouteId, curCycle); + SetRouteResCancelDelayFlag(wRouteId, RUUTE_RESCANCEL_DELAY_YES); + } + } + } + } + else + { + ; /**/ + } +} + +/* +* ·ѡǷʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +* OVERTIME_YESѡųʱ +* OVERTIME_NOѡδʱ +* cgh-ϲCID-2341-7 ޸ѡųʱ +*/ +UINT8 RouteFirstXuanOverTime(const UINT16 routeId) +{ + UINT8 rtVal = OVERTIME_NO; + UINT32 routeXuanPaiStartCycle = 0u;/*ѡʼ*/ + UINT8 stat = 0u; + routeXuanPaiStartCycle = GetRouteXuanPaiStartCycNum(routeId); + if (0u < routeXuanPaiStartCycle) + {/*ѡʼڴ0*/ + stat = SystemOverTimeCheck(routeXuanPaiStartCycle, ROUTE_CHUXUAN_OVERTIME_CYCLE_NUM); + if (CI_TIME_OUT == stat) + {/*ѡųʱ*/ + rtVal = OVERTIME_YES; + } + else + { + rtVal = OVERTIME_NO; + } + } + else + { + rtVal = OVERTIME_NO; + } + + return rtVal; +} + +/* +* εѡʼں +* ˵ +* +*޸ģcgh-ϲCID-2341-8 +*/ +void ClearOverlapXuanPaiStartCycNum(void) +{ + /*ʼ*/ + UINT16 i = 0; + UINT16 j = 0; + UINT8 overlapBelongCi = 0u; + UINT8 localCiId = 0u; + UINT16 overlapCurSum = 0u; + UINT16 overlapId = 0u; + UINT8 routeState = 0u; + UINT16 overlapRouteSum = 0u; + UINT16* overlapRouteBuf = NULL; + UINT8 Flag = 0u; + + localCiId = GetSystemParaLocalCiId(); + + + /*ȡ*/ + overlapCurSum = GetOverlapCurSum(); + for (i = 0u; i < overlapCurSum; i++) + { + Flag = 0u; + overlapId = GetOverlapId(i); + /*ȡ·Ϣ*/ + overlapRouteSum = GetOverlapRouteIdSum(overlapId); + overlapRouteBuf = GetOverlapRouteIdBuf(overlapId); + overlapBelongCi = GetOverlapBelongCiId(overlapId); + + /**/ + if (overlapBelongCi == localCiId) + { + if ((0u < overlapRouteSum) && (overlapRouteSum < OVERLAP_ROUTE_SUM_MAX) && (NULL != overlapRouteBuf)) + { + for (j = 0u; j < overlapRouteSum; j++) + { + routeState = GetRouteState(overlapRouteBuf[j]); + /*·ڿ*/ + if ((ROUTE_STATE_IDLE != routeState) && (ROUTE_STATE_FIRST_XUANPAI != routeState) + && (ROUTE_STATE_XUANPAI != routeState)) + { + debug_infor_printf((const)"\nROUTE IS LOCK routeId:%d overlapId:%d\n", overlapRouteBuf[j], overlapId); + Flag = 1u; + break; + } + else + { + /**/ + } + } + if (0u == Flag) + { + /*ѡ*/ + SetOverlapXuanPaiStartCycNum(overlapId, 0u); + } + } + } + } +} +/* +* ָIDηǸspksµµ +* ˵ const UINT16 phySectionId, ID +UINT8 *state spks״̬ +UINT16 *spksId spksId +* ֵ CI_SUCCESS: εspksµ +* CI_ERROR: ζӦspksȫδ»spksIdϷ +add by pfq 2022.04.21 +*/ +UINT8 CheckPhysecFlockReasonSpksId(const UINT16 phySectionId, UINT16* spksId, UINT8* state) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 retVal = CI_ERROR; + UINT8 phySecSpksSum = 0u; + UINT16 i = 0u; /*ѭ*/ + UINT16 tempSpksId = 0u; /*ȡζӦspksId*/ + UINT8 tempSpksState = 0u; /*ζӦspks״̬*/ + UINT8 tempSpksCutState = 0u; /*ζӦspks·״̬*/ + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + phySecSpksSum = GetPhySecSpksSum(phySectionId); /*ȡspks*/ + + for (i = 0u; i < phySecSpksSum; i++) + { + tempSpksId = GetPhySecSpksIdBySpksIdx(phySectionId, i); /*λȡζӦеspksId*/ + tempSpksState = GetSpksState(tempSpksId); /*ȡspks״̬*/ + tempSpksCutState = GetSpksCutState(tempSpksId); /*ȡspks·״̬*/ + if ((SPKS_STATUS_YES == tempSpksState) && (SPKS_CUT_YES != tempSpksCutState)) + {/*spksδ·*/ + *spksId = tempSpksId; + *state = tempSpksState; + retVal = CI_SUCCESS; /*ҵηĵһspks򷵻سɹѭ*/ + break; + } + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ˹δ +* ˵ const UINT8 overlapId ID +* ֵCI_ERROR ʧ +* CI_SUCCESS ɹ +* +*޸ģmpt 202239 ӱ˹߼ +*/ +UINT8 LaborUnlockOverlapProc(const UINT8 overlapId) +{ + /*ʼ*/ + UINT8 overlapBelongCi = 0u; + UINT8 localCiId = 0u; + UINT8 reVal = CI_ERROR; + UINT8 OverlapCanLaborUnlockFlag = 0u; + UINT32 cycNum = Get2oo2CurCycleNum(); + + + localCiId = GetSystemParaLocalCiId(); + + if ((0u < overlapId) && (0u < localCiId)) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + + overlapBelongCi = GetOverlapBelongCiId(overlapId); + if (localCiId == overlapBelongCi) + {/*ڱ*/ + OverlapCanLaborUnlockFlag = GetOverlapCanLaborUnlockFlag(overlapId); + if (CAN_LABOR_UNLOCK_OVERLAP == OverlapCanLaborUnlockFlag)/*δʱ˹*/ + { + SetOverlapLaborUnlockSetState(overlapId, LABOR_UNLOCK_OVERLAP_YES); + SetlaborUnlockStartCycNum(overlapId, cycNum);/*˹ʼں*/ + } + else + { + reVal = CI_ERROR; + } + } + else + { + if (0u < overlapBelongCi) + { + AddCiSendToCiCmdInfo(CI_CMD_UNLOCK_OVERLAP_CMD, overlapId, 0u, overlapBelongCi); + } + else + { + reVal = CI_ERROR; + } + } + } + + if (CI_SUCCESS != reVal) + { + /*ֵ*/ + SetCiSendCmdBackInfoData(UNLOCK_OVELAP_CANNOT, CI_DEVICE_TYPE_OVERLAP, overlapId, 0u, 0u); + } + return reVal; +} +/* +* ձα־ +* ˵ const UINT16 routeId, ·ID +* cgh-ϲCID-2539-10 ·վأ۱ʲô״̬ձ +*/ +void SetRouteOverlapNeedCIlockM(const UINT16 routeId) +{ + UINT8 routeBelongCIid = GetRouteBelongCiId(routeId); + UINT8 localCIid = GetSystemParaLocalCiId(); + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 virCIid = 0u; + UINT8 ciCtrModeFlag = 0u; + UINT8 setflag = 0u; + UINT8 triggerFlag = 0u; + UINT8 autoSignalOrRouteValid = 0u;/*Զ·߱־*/ + UINT8 groupRouteCmd = 0u; + UINT8 chTempCheckFlag = 0U;/*ʱ־*/ + + if (localCIid == routeBelongCIid) + { + /*ȡر־*/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + virCIid = GetRouteBelongVirCiId(routeId); + ciCtrModeFlag = GetVirCImode(virCIid);/*ȡģʽ*/ + } + else + { + ciCtrModeFlag = GetCiModeFlag(); + } + triggerFlag = GetRouteAutoTriggerFlag(routeId); /*ȡ·Զ־*/ + /*·վ£Ҫգøñ־*/ + if (CI_MODE_CI_LOCAL == ciCtrModeFlag)/**/ + { + setflag = 1u; + } + else + { + /*ʲôҲ*/ + } + /*·ԶҪգøñ־*/ + if (AUTO_TRIGGER_SET_YES == triggerFlag) + { + setflag = 1u; + } + else + { + /*ʲôҲ*/ + } + + /*·Զ·Ҫգøñ־*/ + autoSignalOrRouteValid = AutoSignalOrRouteValid(routeId); + if (CI_SUCCESS == autoSignalOrRouteValid) + { + setflag = 1u; + } + else + { + /*ʲôҲ*/ + } + + /*ȡ·г·*/ + groupRouteCmd = GetRouteGroupRouteCmdFlag(routeId); + if (ROUTE_GROUPROUTE_CMD_YES == groupRouteCmd) + { + setflag = 1u; + } + else + { + /*ʲôҲ*/ + } + + /*·ͽ·һս·һ£ٴձ*/ + chTempCheckFlag = CheakRouteHaveLockOverlap(routeId); + if (CI_SUCCESS == chTempCheckFlag) + { + setflag = 1u; + } + else + { + ; + } + + if (1u == setflag) + { + SetRouteOverlapNeedCIlockFlag(routeId, OVERLAPCILOCK_YES);/*ñҪձ־*/ + } + else + { + SetRouteOverlapNeedCIlockFlag(routeId, OVERLAPCILOCK_NO); + } + } + else + { + /*ʲôҲ*/ + } +} + +/* +* Ծ߼ +* ˵ void +* ֵ +* by-cgh-20230628 +*/ +void PhySecJumpLockLogicManage(void) +{ + UINT8 chTempcheck = 0U; + UINT16 ii = 0U; + UINT16 wAxisSectionDataSum = 0U;/*ǰĿ*/ + UINT16 wAxisSectionId = 0U;/*ID*/ + UINT8 chApplyFlag = 0U; /*Ծ־*/ + UINT8 chCancelApplyFlag = 0U; /*Ծȡ־*/ + UINT16 wPhyId = 0U;/*ID*/ + UINT32 dwApplyCycle = 0U;/*Ծں*/ + UINT8 chPhySecFLockType = 0U;/*η*/ + UINT8 chPhySecJempState = 0U;/*Ծ״̬*/ + + wAxisSectionDataSum = GetTotalAxisCurNum(); + + for (ii = 0U; ii < wAxisSectionDataSum; ii++) + { + wAxisSectionId = GetAxisSecId(ii);/*ȡиµļID*/ + chApplyFlag = GetAxisSecJumpLockApplyFlag(wAxisSectionId);/*Ծ־*/ + chCancelApplyFlag = GetAxisSecJLockCancelApplyFlag(wAxisSectionId);/*Ծȡ־*/ + wPhyId = GetAxisSecRelativePhySecId(wAxisSectionId);/*ȡID*/ + chPhySecJempState = GetPhySecJumpLockState(wPhyId); /*ȡԾ״̬*/ + + if (PHYSICAL_SECTION_JUMP_LOCK_NO == chPhySecJempState) + { + if ((AXIS_SECTION_JUMPLOCK_APPLY_YES == chApplyFlag) && (AXSEC_CANCEL_JUMPLOCK_APPLY_NO == chCancelApplyFlag)) + { + /*δԾգǰһԾȡ룬Ծ״̬*/ + chTempcheck = CheckJumpLockApply(wAxisSectionId); + if (CI_SUCCESS == chTempcheck) + { + chPhySecFLockType = GetPhySecFLockType(wPhyId); /*ȡη*/ + if ((PHY_SEC_FLOCK_TYPE_NONE == chPhySecFLockType)) + { + SetPhySecJumpLockState(wPhyId, PHYSICAL_SECTION_JUMP_LOCK_YES); + SetPhySecJumpLockStateToZC(wPhyId, PHYSICAL_SECTION_JUMP_LOCK_YES); + SetAxisInCludeLogJumpLockState(wAxisSectionId, LOGIC_SECTION_JUMP_LOCK_YES); + } + else + { + AccToPhySecFlockTypeSetErrcode(wPhyId, EFUNC_LockAxisSecProc, ESEND_LEVEL_ZERO, chPhySecFLockType); + } + } + } + } + else + { + dwApplyCycle = GetAxisSecJumpLockApplyCylce(wAxisSectionId); + if (0U < dwApplyCycle) + {/*ڴ0˵ZCûȡ*/ + chTempcheck = CheckJumpLockApply(wAxisSectionId); + if (CI_ERROR == chTempcheck) + { + /*֮ǰգʱڲάԾգZC*/ + SetPhySecJumpLockStateToZC(wPhyId, PHYSICAL_SECTION_JUMP_LOCK_NO); + } + else + { /*ڲգʱٴθZC*/ + + SetPhySecJumpLockStateToZC(wPhyId, PHYSICAL_SECTION_JUMP_LOCK_YES); + } + } + } + if ((AXIS_SECTION_JUMPLOCK_APPLY_NO == chApplyFlag) && + (AXSEC_CANCEL_JUMPLOCK_APPLY_YES == chCancelApplyFlag)) + {/*ȡԾ*/ + SetPhySecJumpLockState(wPhyId, PHYSICAL_SECTION_JUMP_LOCK_NO); + SetPhySecJumpLockStateToZC(wPhyId, PHYSICAL_SECTION_JUMP_LOCK_NO); + } + } +} + +/* +* ·쳣ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +* cgh:2023.05.06 +*/ +void RouteHalfUnlockDelayManage(const UINT16 routeId) +{ + UINT32 dwDelayStartCycNum = 0U; /*·ιϽʱʼ*/ + UINT32 dwDelayTotalCycSum = 0U; /*·ιϽʱ*/ + UINT8 chCheckTimeState = 0U; /*ʱ*/ + UINT8 chLogLockRouteIdDir = 0U; /*߼··*/ + UINT16 wFirstNormalLockLogId = 0U; /*·ڵһ߼id*/ + UINT16 wRelativePhySecId = 0U; /*·ڵһ߼ι*/ + UINT16 wRelativePhyLockRoute = 0U; /*·ڵһ߼ι·*/ + + wFirstNormalLockLogId = GetRouteFirstNormalLockLogId(routeId); + chLogLockRouteIdDir = GetRouteDirection(routeId); + dwDelayStartCycNum = GetRouFirstElockStaCycNum(routeId); /*ȡ߼ιϽʼ*/ + /*ʱʱ临˽ʱ*/ + dwDelayTotalCycSum = GetSystemParaBlocRouteDelayCyc(); /*ȡʽ·ʱ*/ + + /*ʱʱ*/ + chCheckTimeState = SystemOverTimeCheck(dwDelayStartCycNum, dwDelayTotalCycSum); + /*ʱʱ*/ + if (CI_TIME_OUT == chCheckTimeState) + {/*ùʱڵ߼δ----Ӧ߼쳣գ·Զ쳣*/ + wRelativePhySecId = GetLgcSecRelativePhySecId(wFirstNormalLockLogId); + wRelativePhyLockRoute = GetPhySecRLockBelongRouteId(wRelativePhySecId); + + if (routeId == wRelativePhyLockRoute) + {/*߼·Ϊ·ͬʱ쳣*/ + SetPhySecLockState(wRelativePhySecId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, chLogLockRouteIdDir); + } + else + { + /*ͬʱιմ*/ + } + + /*ͬʱڱ·յ߼쳣*/ + SetPhyIncludeLogLockState(wRelativePhySecId, LOG_SECTION_LOCK_EXCEPT, routeId); + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); /*-->ý·Զ쳣*/ + (void)SetRouFirstElockStaCycNum(routeId, 0U); + + } + else + { + /*ȴʱ*/ + } + +} + +/* +* ··ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteHalfFirstXuanManage(const UINT16 routeId) +{ + UINT8 returnValueFunc1 = 0u; /*ֵ*/ + UINT8 returnValueFunc2 = 0u; /*ֵ*/ + UINT8 firstXuanPaiOvertime = 0u;/*ѡʱ*/ + UINT8 routeCheck = 0u; + UINT8 routeProperty = 0u; + + routeCheck = SetRouteHalfProc(routeId); + + /*·*/ + if (CI_SUCCESS == routeCheck) + { /*ɹ*/ + firstXuanPaiOvertime = RouteFirstXuanOverTime(routeId); + if (OVERTIME_YES == firstXuanPaiOvertime) + {/*ѡʱ*/ + /*cgh - ϲCID - 2341 - 7 ޸ѡųʱ*/ + /*ý·δ*/ + SetRouteHalfPhySecUsingState(routeId, PHYSICAL_SECTION_USING_NO); + + routeProperty = GetRouteReverseProperty(routeId); + if (ROUTE_REVERSE_PROPERTY_YES == routeProperty) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + + /*ӽ·ѡʱӡ*/ + SetErrorData(EFUNC_PartialRouteFirstXuanPaiManage, CI_DEVICE_TYPE_ROUTE, routeId, + ETYPE_ROUTE_FIRST_XUANPAI_OVERTIME, ROUTE_DYNAMIC_STATE_FIRST_XUANPAI, ESEND_LEVEL_ZERO); + } + /*δʱ*/ + /* TODO ·ֵüԶźȡ*/ + /*·ѡ*/ + returnValueFunc1 = RouteHalfFirstXuanProc(routeId); +#if 0 + returnValueFunc2 = RouteFirstXuanAutoSigProc(routeId); +#else + returnValueFunc2 = RouteFirstXuanAutoSigCancelPro(routeId); +#endif + if ((CI_ERROR == returnValueFunc1) || (CI_ERROR == returnValueFunc2)) + { + /*ʧ || ·ԶźŽ·ȡʧ*/ + + /*ý·δ*/ + SetRouteHalfPhySecUsingState(routeId, PHYSICAL_SECTION_USING_NO); + + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + } + else if ((CI_SUCCESS == returnValueFunc1) && (CI_SUCCESS == returnValueFunc2)) + { + /*óɹ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_HALF_XUANPAI); /*-->ý·ѡ*/ + + /*·ѡŴ*/ + RouteHalfXuanPaiManage(routeId); + } + else if ((RETURN_FIRSTXUANPAI_ERR_WAIT == returnValueFunc1) || (RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT == returnValueFunc2)) + { + /*ȴ*/ + } + else + { + } + } + else + { + /*·ʧ*/ + + /*ý·δ*/ + SetRouteHalfPhySecUsingState(routeId, PHYSICAL_SECTION_USING_NO); + + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + } +} + +/* +* ֽ· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 SetRouteHalfProc(const UINT16 routeId) +{ + UINT8 returnValue = 0u; /*ֵ*/ + + returnValue = SetHalfTrainRouteLogicProcess(routeId); + + /*ݰֵ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + returnValue = CI_SUCCESS; + } + else + { /*ʧ*/ + + returnValue = CI_ERROR; + } + + return returnValue; +} + +/* +* ··ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteHalfXuanPaiManage(const UINT16 routeId) +{ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 routSwitDrvOvtmFlag = 0u;/*·ڵǷʱ־*/ + UINT8 chkSwitchPos = CI_ERROR; + UINT8 cLocalCiId = 0u; + UINT8 ciType = 0u;/*Ŀ*/ + + cLocalCiId = GetSystemParaLocalCiId(); + ciType = GetCiType(cLocalCiId); + + returnValue = LockRouteHalfProc(routeId); + + routSwitDrvOvtmFlag = ChekRouteHalfSwDrvOvTime(routeId);/*·ڵǷʱ*/ + + if (CI_SUCCESS == returnValue) + { + chkSwitchPos = ChekRouteHalfSwPosRight(routeId);/*λǷȷ*/ + + if (CI_SUCCESS == chkSwitchPos) + {/*λȷ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_HALF_LOCK); /*-->ý·*/ + + /*·մ*/ + RouteHalfLockManage(routeId); + } + else + { + + /*δλߴ豻*/ + if (CI_SUCCESS == routSwitDrvOvtmFlag) + {/*·ڷǷʱ*/ + + } + else + { + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRouteHalfPhySecUsingState(routeId, PHYSICAL_SECTION_USING_NO); /**/ + } + } + + } + else if ((RETURN_LOCK_ERR_SWITPOS == returnValue) && (CI_SUCCESS == routSwitDrvOvtmFlag)) + { + /*λòȷ*/ + + /*·*/ + if (CI_ERROR == RouteLockHalfDriveSwitch(routeId)) + { + /*ý·δ*/ + SetRouteHalfPhySecUsingState(routeId, PHYSICAL_SECTION_USING_NO); + + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + } + else + { + /*ý·δ*/ + SetRouteHalfPhySecUsingState(routeId, PHYSICAL_SECTION_USING_NO); + + if (ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(routeId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + /* ·ʧ */ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } +} + +/* +* +* ·չ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteHalfLockManage(const UINT16 routeId) +{ + UINT16 resReqTrainId = 0U; + UINT8 trainLocLogicSecSum = 0U; /*гԴ*/ + UINT8 halfRouteLogicSecSum = 0U; /*гԴ*/ + const UINT16* const pHalfLogicSecId = GetHalfRouteLockLgcSecIdBuf(routeId); /*гԴ*/ + const UINT16* const pTrainLocLogicSecId = GetHalfRouteTrainLocLgcSecIdBuf(routeId); /*гԴ*/ + trainLocLogicSecSum = GetHalfRouteTrainLocLgcSecNum(routeId); + resReqTrainId = GetHalfRouteResReqTrainId(routeId); + halfRouteLogicSecSum = GetHalfRouteLockLgcSecSum(routeId); + + if ((NULL == pTrainLocLogicSecId) || (NULL == pHalfLogicSecId)) + { + /*ܳ óǰѲѯrouteIdЧ,崻־*/ + SetPlatOverFlag(); + } + else if (0U == trainLocLogicSecSum) + { + /*гԴ벿״̬*/ + SetRouteStateManage(routeId, ROUTE_STATE_HALF_UNLOCK); + } + else + { + + /*гԴ*/ + SetRouteTrainLocLogSecState(routeId, LOG_SECTION_LOCK_NORMAL); + SetRouteTrainLocPhySecState(routeId, PHYSICAL_SECTION_LOCK_NORMAL); + /*½·״̬*/ + SetRouteStateManage(routeId, ROUTE_STATE_HALF_UNLOCK); +#if 0 + routeDir = GetRouteDirection(routeId); + trainDir = GetTrainDir(resReqTrainId); + trainCommStt = GetTrainTransitmitStat(resReqTrainId); + if (trainCommStt == TRAIN_COMM_STATE_GOOD) + { + if (routeDir == trainDir) + { + /*гԴ*/ + SetRouteTrainLocLogSecState(routeId, LOG_SECTION_LOCK_NORMAL); + SetRouteTrainLocPhySecState(routeId, PHYSICAL_SECTION_LOCK_NORMAL); + /*½·״̬*/ + SetRouteStateManage(routeId, ROUTE_STATE_HALF_UNLOCK); + } + else + { + /* г߼ */ + if (EMAP_SAME_DIR == trainDir) + { + end.wLinkId = GetTrainMaxHeadLink(resReqTrainId); + end.dwOffset = GetTrainMaxHeadOffset(resReqTrainId); + start.wLinkId = GetTrainMinTailLink(resReqTrainId); + start.dwOffset = GetTrainMinTailOffset(resReqTrainId); + } + + /* г߼ */ + else if (EMAP_CONVER_DIR == trainDir) + { + start.wLinkId = GetTrainMaxHeadLink(resReqTrainId); + start.dwOffset = GetTrainMaxHeadOffset(resReqTrainId); + end.wLinkId = GetTrainMinTailLink(resReqTrainId); + end.dwOffset = GetTrainMinTailOffset(resReqTrainId); + } + else + { + /*޲*/ + } + + /*ȡг߼/ID*/ + funcRet = GetLogSecBtwTwoPoints(start, end, &trainNowLgcSecSum, trainNowLgcSecId); + if (CI_SUCCESS == funcRet) + { + for (ii = 0U; ii < trainLocLogicSecSum; ii++) + { + for (jj = 0U; jj < trainNowLgcSecSum; jj++) + { + if (pTrainLocLogicSecId[ii] == trainNowLgcSecId[jj]) + { + break; + } + else + { + + } + } + + if (jj == trainNowLgcSecSum) + { + break; + } + } + if (trainLocLogicSecSum == ii) + { + /*гڵǰλã*/ + } + else + { + + /*·ҲΪhalf unlock*/ + SetTrainLocRouteHalfUnlock(routeId); + /*½·״̬*/ + SetRouteStateManage(routeId, ROUTE_STATE_HALF_UNLOCK); + + } + } + else + { + + /*·ҲΪhalf unlock*/ + SetTrainLocRouteHalfUnlock(routeId); + /*½·״̬*/ + SetRouteStateManage(routeId, ROUTE_STATE_HALF_UNLOCK); + + } + } + } + else + { + + /*·ҲΪhalf unlock*/ + SetTrainLocRouteHalfUnlock(routeId); + for (jj = 0U; jj < halfRouteLogicSecSum; jj++) + { + lgcSecRLockId = GetLogSecLockBelongRoute(pHalfLogicSecId[jj]); + if (lgcSecRLockId == routeId) + { + break; + /*ڱ·δգִ*/ + } + else + { + + } + } + + if (jj == halfRouteLogicSecSum) + { + /*гʧܣΣתΪ*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + } + else + { + /*гʧͨţֱӸ½·״̬*/ + SetRouteStateManage(routeId, ROUTE_STATE_HALF_UNLOCK); + } + +} +#endif + } + + +} + + +/* +* +* ·ս +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteHalfUnlockManage(const UINT16 routeId) +{ + /*TODO 󣬵ǰ账״̬гͷŲִ*/ +} +/* +* ս·· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 LockRouteHalfProc(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 retval = 0u; + + routeType = GetRouteType(routeId); /*ȡ·*/ + + if ((ROUTE_TYPE_LIECHE == routeType) + || (ROUTE_TYPE_RETURN == routeType)) + { + /*ս··߼*/ + returnValue = LockRouteHalfLogicProcess(routeId); + + } + else + { + /* ݲ*/ + } + + + + /*շֵ*/ + if (CI_SUCCESS == returnValue) + { + /*ճɹ*/ + + retval = CI_SUCCESS; + } + else if (RETURN_LOCK_ERR_SWITPOS == returnValue) + { /*λòȷ*/ + + retval = RETURN_LOCK_ERR_SWITPOS; + } + else + { /*ʧ*/ + + retval = CI_ERROR; + } + return retval; +} + +/* +* @brief CIIJ· +* ToCiDrCmdDataStruct pCiRecvCiDrCmdStru ̬·Ľṹ +* +* ֵ +*/ +void SetRoutePartApplyFromCi(ToCiDrCmdDataStruct* pCiRecvCiDrCmdStru) +{ + /*ֲʼ*/ + UINT8 keepWork = CI_ERROR; + UINT16 wMatchedRouteId = 0U; /*߼ƥɹĽ·ID*/ + UINT8 routeCurState = ROUTE_STATE_IDLE; /*·״̬*/ + UINT16 wUsableDrId = 0U; /*õС̬·ID*/ + UINT16 wUsableLogicRouteId = 0U; /*õС߼·ID*/ + UINT8 cCheckStep = 0U; /*¼еλãڴ*/ + UINT8 szQueryDir[UINT8_MAX] = { 0U }; /*߼ζӦIJѯ߼*/ + UINT8 cLocalCiId = 0U; /*ID*/ + + /*μ*/ + if (NULL == pCiRecvCiDrCmdStru) + { + /*Уʧܣ*/ + } + else + { + /*һ߼Ƿ*/ + keepWork = LogSecSeqIsContinuousCheck(pCiRecvCiDrCmdStru->cLogSecSeqDir, pCiRecvCiDrCmdStru->cLogSecSum, pCiRecvCiDrCmdStru->wLogSecIdBuff, szQueryDir); + cCheckStep++; + + if ((CI_SUCCESS == keepWork) && (CICI_DR_CMD_LOGIC != pCiRecvCiDrCmdStru->cCmdType)) + { + /*ڶΪ߼·ƥ·г·*/ + keepWork = MatchedRouteCheck(pCiRecvCiDrCmdStru->cLogSecSeqDir, pCiRecvCiDrCmdStru->cLogSecSum, pCiRecvCiDrCmdStru->wLogSecIdBuff, &wMatchedRouteId); + cCheckStep++; + } + else + { + /**/ + } + + if (CI_SUCCESS == keepWork) + { + /*ɸѡؽ··*/ + if (CICI_DR_CMD_HALF == pCiRecvCiDrCmdStru->cCmdType) + { + /*ؽ·ؽ·ṹ*/ + SetHalfRouteSwitchMoveValid(wMatchedRouteId, pCiRecvCiDrCmdStru->cSwitchMoveFlag); /*ðؽ·ɶ־*/ + SetHalfRouteLockLgcSec(wMatchedRouteId, pCiRecvCiDrCmdStru->cLogSecSum, pCiRecvCiDrCmdStru->wLogSecIdBuff); /*ðؽ·յ߼*/ + SetHalfRouteResReqTrainId(wMatchedRouteId, pCiRecvCiDrCmdStru->wTrainId); /*÷ԴгID*/ + SetHalfRouteTrainLocLgcSec(wMatchedRouteId, pCiRecvCiDrCmdStru->cTrainLocLogSecSum, pCiRecvCiDrCmdStru->wTrainLocLogSecIdBuff); /*ðؽ·г߼*/ + debug_infor_printf((const)"HalfRouteSwitchMoveFlag From CI: 0x%x\n", pCiRecvCiDrCmdStru->cSwitchMoveFlag); + + keepWork = HalfRoutePhySecUseLogicProcess(wMatchedRouteId); /*ӽ·ü*/ + if (CI_SUCCESS == keepWork) + { + /*ƥĽ·̬·*/ + wUsableDrId = GetUsableDrId(); + SetDrSubRoute(wUsableDrId, (UINT8)1U, &wMatchedRouteId); + + debug_infor_printf((const)"Dynamic Route Set From CI Is Success! Dynamic Sub Route ID From CI: %d\n", wMatchedRouteId); /*ɹ¼־*/ + } + else + { + SetRouteStateManage(wMatchedRouteId, ROUTE_STATE_IDLE); /*ʧܣý·*/ + } + } + else if (CICI_DR_CMD_FULL == pCiRecvCiDrCmdStru->cCmdType) + { + keepWork = RoutePhySectionUseLogicProcess(wMatchedRouteId); /*ӽ·ü*/ + if (CI_SUCCESS == keepWork) + { + /*·*/ + routeCurState = GetRouteState(wMatchedRouteId); + if ((ROUTE_STATE_IDLE == routeCurState) || (ROUTE_STATE_HALF_UNLOCK == routeCurState)) + { + /*·ͨ¼ITS·гID߼ʱʹ*/ + SetITSRouteApplyTrainIDInfo(wMatchedRouteId, pCiRecvCiDrCmdStru->wTrainId); + } + else + { + /*账*/ + } + + /*ƥĽ·̬·*/ + wUsableDrId = GetUsableDrId(); + SetDrSubRoute(wUsableDrId, (UINT8)1U, &wMatchedRouteId); + + debug_infor_printf((const)"Dynamic Route Set From CI Is Success! Dynamic Sub Route ID From CI: %d\n", wMatchedRouteId); /*ɹ¼־*/ + } + } + else if (CICI_DR_CMD_LOGIC == pCiRecvCiDrCmdStru->cCmdType) + { + /*߼·߼·ṹ*/ + wUsableLogicRouteId = GetUsableLogicalRouteId(); + if (0U != wUsableLogicRouteId) + { + keepWork = RepeatSetLogicRouteCheck(pCiRecvCiDrCmdStru->cLogSecSum, pCiRecvCiDrCmdStru->wLogSecIdBuff, pCiRecvCiDrCmdStru->wTrainId); /*߼·Ƿظ*/ + + if (CI_SUCCESS == keepWork) + { + cLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + SetLogicalRouteBelongCiId(wUsableLogicRouteId, cLocalCiId); + SetLogicalRouteDir(wUsableLogicRouteId, pCiRecvCiDrCmdStru->cLogSecSeqDir); /*߼·*/ + SetLogicalRouteSwitchMoveFlag(wUsableLogicRouteId, pCiRecvCiDrCmdStru->cSwitchMoveFlag); /*߼·ɶ־*/ + SetLogicalRouteRelateBeginSigId(wUsableLogicRouteId, pCiRecvCiDrCmdStru->wRelStartSignalId); /*߼·ʼźŻ*/ + LogicRouteLevelConfirmProcess(wUsableLogicRouteId); /*ȷ߼·ල*/ + SetLogRouteApplyResTrainData(wUsableLogicRouteId, pCiRecvCiDrCmdStru->wTrainId); /*ATSԴгID*/ + SetLogicalRouteInLogSecData(wUsableLogicRouteId, pCiRecvCiDrCmdStru->cLogSecSum, pCiRecvCiDrCmdStru->wLogSecIdBuff); /*߼·߼*/ + SetLogicalRouteTrainLogSecData(wUsableLogicRouteId, pCiRecvCiDrCmdStru->cTrainLocLogSecSum, pCiRecvCiDrCmdStru->wTrainLocLogSecIdBuff); /*г°߼*/ + LogicRouteOpenColorProc(wUsableLogicRouteId); /*߼·ʼźŻɫ*/ + LogRouteOutLgcSecConfigDataInit(wUsableLogicRouteId); + + /*ͨ߼·״̬Ϊѡ߼·״̬*/ + keepWork = LogRoutePhySecUseLogicProcess(wUsableLogicRouteId); + if (CI_SUCCESS == keepWork) + { + SetLogRouteStateManage(wUsableLogicRouteId, ROUTE_LOGICAL_STATE_FIRST_XUANPAI); + + debug_infor_printf((const)"Dynamic Logic Route Set From CI Is Success! Dynamic Logic Route ID: %d\n", wUsableLogicRouteId); /*ɹ¼־*/ + } + else + { + SetLogRouteStateManage(wUsableLogicRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + } + else + { + debug_infor_printf((const)"Dynamic Logic Route Set From CI Is Error: LogicRoute Repeat Set!\n"); /*߼·ظͣ*/ + } + } + else + { + /*޿߼·*/ + debug_infor_printf((const)"Dynamic Logic Route Set From CI Is Error: LogicRoute Is Not Idle!\n"); + } + } + else + { + /**/ + } + } + else + { + debug_infor_printf((const)"Route Part Apply From CI Is Error! Error Position Is [%d]\n", cCheckStep); /*ʧܣ¼־*/ + } + } +} + +/* +* ·ȡԴʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteCancelResApplyManage(const UINT16 routeId) +{ + UINT8 ResCancelflag = 0u; + UINT32 delayStartCycNum = 0u; /*ʱȡԴʼں*/ + UINT32 delayTotalCycSum = 0u; /*ʱȡԴ*/ + UINT8 checkTimeState = CI_TIME_NO; /*Ƿʱ״̬*/ + UINT16 wTrainId = 0u; /*ԴȡгID*/ + UINT8 chTrainCommStt = 0U; + UINT8 routeState = 0u; /*·״̬*/ + + + delayStartCycNum = GetRouteResourceCancelCyc(routeId); /*ȡԴȡʱں*/ + delayTotalCycSum = GetRouteResCancelApplyCyc(); /*ȡԴȡ*/ + wTrainId = GetRouteResourceCancelTrainId(routeId); /*ȡָ·ԴȡгID*/ + chTrainCommStt = GetTrainTransitmitStat(wTrainId); /*ȡгͨ״̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + + ResCancelflag = GetRouteResCancelDelayFlag(routeId); + + if (RUUTE_RESCANCEL_DELAY_YES == ResCancelflag) + { + /*ʱʱ*/ + checkTimeState = SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum); + + if ((CI_TIME_OUT == checkTimeState) || (TRAIN_COMM_STATE_GOOD != chTrainCommStt) || (ROUTE_STATE_IDLE == routeState)) + { + SetRouteResourceCancelTrainId(routeId, 0U); /**/ + SetRouteResourceCancelCyc(routeId, 0U); + SetRouteResCancelDelayFlag(routeId, RUUTE_RESCANCEL_DELAY_NO); /*ʱ־*/ + } + else + { + ; /*δʱ·δȡͨü*/ + } + } + else + { + ; /*δʱȡԴĴ*/ + } +} + +/* +* ·ѡͨô +* ˵ const UINT16 wRouteId, ·ID +* const UINT8 chLockRouteProcCheck ս· +* ֵ UINT8 +* by cgh 20230720 ȦӶȣ·ѡŽ׶εŲ˺ +*/ +void RouteXuanPaiCommonProcess(const UINT16 wRouteId, const UINT8 chLockRouteProcCheck) +{ + UINT8 chNeedForDrvRoutAssoSwit = SWITCH_NEED_DRIV_FALSE; /*ǷҪ*/ + UINT8 chRoutSwitDrvOvtmFlag = 0u;/*·ڵǷʱ־*/ + UINT8 chSwitchPos = CI_ERROR; + UINT8 chSwitchDrive = CI_ERROR; /**/ + UINT8 chLocalCIType = 0U; + UINT8 chReverseRouteProperty = 0U;/*·*/ + + chLocalCIType = GetLocalCiType(); + chReverseRouteProperty = GetRouteReverseProperty(wRouteId); + chNeedForDrvRoutAssoSwit = CheckRoutAssoSwitNeedDriv(wRouteId);/*·ǷҪ*/ + chRoutSwitDrvOvtmFlag = ChekRoutSwitDrivOvtmStat(wRouteId);/*·ڵǷʱ*/ + chSwitchPos = CheckRouteSwitchPosRight(wRouteId);/*λǷȷ*/ + + if ((CI_SUCCESS == chLockRouteProcCheck) && (SWITCH_NEED_DRIV_FALSE == chNeedForDrvRoutAssoSwit) && (CI_SUCCESS == chSwitchPos)) + { + /*·λȷ豻*/ + /*·鱻ٹʷ*/ + SetRoutAssoSwitSingOperStat(wRouteId, SWITCH_SINGLE_OPERATED_FALSE); + /*ճɹ*/ + SetRouteStateManage(wRouteId, ROUTE_STATE_FIRST_LOCK); /*-->ý·*/ + /*·*/ + RouteFirstLockManage(wRouteId); + + } + else if (((CI_SUCCESS == chLockRouteProcCheck) && (SWITCH_NEED_DRIV_TRUE == chNeedForDrvRoutAssoSwit)) || (RETURN_LOCK_ERR_SWITPOS == chLockRouteProcCheck)) + { + if (CI_SUCCESS == chRoutSwitDrvOvtmFlag) + { + chSwitchDrive = RouteLockDriveSwitch(wRouteId, chNeedForDrvRoutAssoSwit); + } + if ((CI_ERROR == chRoutSwitDrvOvtmFlag) || ((CI_SUCCESS == chRoutSwitDrvOvtmFlag) && (CI_ERROR == chSwitchDrive))) + { + /*·ڷʱδʱʧ*/ + SetRoutAssoSwitSingOperStat(wRouteId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetRouteStateManage(wRouteId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(wRouteId, PHYSICAL_SECTION_USING_NO); /**/ + + if (ROUTE_REVERSE_PROPERTY_YES == chReverseRouteProperty) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + + SetRevrRouteAutoSigInvalidFlag(wRouteId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + } + else + { + ; /**/ + } + } + else + { + SetRoutAssoSwitSingOperStat(wRouteId, SWITCH_SINGLE_OPERATED_FALSE);/*ٹʷ*/ + SetRoutePhySectionOccupyState(wRouteId, PHYSICAL_SECTION_USING_NO); /**/ + if (ROUTE_REVERSE_PROPERTY_YES == chReverseRouteProperty) + {/*·Ϊ·ָ·ԶźŽ·Զ*/ + SetRevrRouteAutoSigInvalidFlag(wRouteId, ROUTE_AUTOSIG_LOSE_SET_NO); + } + SetRouteStateManage(wRouteId, ROUTE_STATE_IDLE); /*-->ý·*/ + } +} + + +/* +* ·ijҪ˽·ʱʱ߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearestTrainRenJieManage(const UINT16 routeId) +{ + UINT16 wTrainId = 0U; /*·Ҫ˽гID*/ + UINT8 chTrainCommStt = 0U; /*гͨ״̬*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 checkTimeState = CI_TIME_NO; /*Ƿʱ״̬*/ + UINT32 delayStartCycNum = 0u; /*ʱȡԴʼں*/ + UINT32 delayTotalCycSum = 0u; /*ʱȡԴ*/ + UINT8 zongRenJieFlag = 0u; /*·˽־*/ + + UINT8 cRouteDir = CI_SYSTEM_DIRECTION_NONE; /*źŻ*/ + + UINT8 cTrainRunDir = CI_SYSTEM_DIRECTION_NONE; /*гз*/ + UINT16 cSignalId = 0u; + LOD_STRU pSignalProtePoint = { 0u }; /*źŻλ*/ + LOD_STRU pTrainMinTailPoint = { 0u }; /*гȫβλ*/ + UINT8 cDirChangedNum = 0U; /*仯*/ + + UINT16 startSignalId = 0U; /*·ʼźŻID*/ + UINT8 cSignalColor = 0U; /*·ʼźŻǰɫ*/ + UINT8 cSignalOpenState = 0U; /*·ʼźŻ״̬*/ + UINT16 wRouteNearestTrainId = GetRouteNODirNearestTrainId(routeId); /*ȡ·ӽг*/ + + + + wTrainId = GetRouteZhefanJiesuoTrainId(routeId); /*Ҫн·۷صгID*/ + chTrainCommStt = GetTrainTransitmitStat(wTrainId); /*ȡгͨ״̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + delayStartCycNum = GetRouteZhefanJiesuoCyc(routeId); /*ȡҪ۷ʼʱ*/ + delayTotalCycSum = GetRouteTrainRanJieDelayCyc(); /*ȡ·Ҫ۷*/ + zongRenJieFlag = GetRouteZongRenJieFlag(routeId); /*ȡ·˽־*/ + wRouteNearestTrainId |= 0x1400U; /*ϳ*/ + + + startSignalId = GetRouteStartSignalId(routeId); + cSignalColor = GetSignalCurColor(startSignalId); + cSignalOpenState = GetSignalOpenCloseState(cSignalColor); + + if (0U != wTrainId) + { + /*·ǰΪӽţźŹر*/ + if (SIGNAL_OPEN == cSignalOpenState) + { + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + if (ROUTE_STATE_NEAR_OPEN == routeState) + { + SetRouteStateManage(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + } + + /*ʱʱ*/ + checkTimeState = SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum); + + if ((CI_TIME_OUT == checkTimeState) || (TRAIN_COMM_STATE_GOOD != chTrainCommStt) + || (ROUTE_ZONGRENJIE_SET_YES == zongRenJieFlag) + || (wTrainId != wRouteNearestTrainId)) + { + /*֣20sʱʱҪ۷гͨŲã·˽⣬Ҫ۷гѾгˣٽнͬʱӦгIDں*/ + SetRouteZhefanJiesuoTrainId(routeId, 0U); + SetRouteZhefanJiesuoCyc(routeId, 0U); + } + else + { + /*δʱδ쳣ѯгǷ񻻷·*/ + cSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻ*/ + cRouteDir = GetSignalDirection(cSignalId);/*źŻ*/ + + cTrainRunDir = GetTrainDir(wTrainId); /*ȡг߼*/ + + /*ʼźŻλ*/ + pSignalProtePoint.Lnk = GetSignalProtectLink(cSignalId); + pSignalProtePoint.Off = GetSignalProtectLinkOff(cSignalId); + /*ȫβλ*/ + pTrainMinTailPoint.Lnk = GetTrainMinTailLink(wTrainId); + pTrainMinTailPoint.Off = GetTrainMinTailOffset(wTrainId); + + cDirChangedNum = GetDirChangeNumBtwPoints(&pSignalProtePoint, &pTrainMinTailPoint); /*鰲ȫβʼźŻλжٷ仯*/ + /*ݷ任ת*/ + cTrainRunDir = TransDirByChangeNum(cTrainRunDir, cDirChangedNum); + + if (((DIR_CONVERT != cTrainRunDir) && (DIR_SAME != cTrainRunDir)) + || ((DIR_CONVERT != cRouteDir) && (DIR_SAME != cRouteDir))) + { + /*쳣ٵȴ20s*/ + SetRouteZhefanJiesuoTrainId(routeId, 0U); /*Ҫ۷гID*/ + SetRouteZhefanJiesuoCyc(routeId, 0U); /*Ҫ۷ں*/ + } + else + { + if (cRouteDir != cTrainRunDir) /*гзͽ·룬Զ·ֱ۷*/ + { + /*г;۷·*/ + RouteZhongtuZhefanQuxiaoProc(routeId); + + /*ս·*/ + SetRouteZhefanJiesuoTrainId(routeId, 0U); /*Ҫ۷гID*/ + SetRouteZhefanJiesuoCyc(routeId, 0U); /*Ҫ۷ں*/ + } + else + { + ;/*гδķ򣬵гķ*/ + } + } + } + + } + else + { + ;/*δҪʱ˽Ľ·*/ + } +} + +/* +* ɾ·պٴΰ·ʱĴ +* ˵ void +* ֵ void +* by cgh 20230930 +*/ +void DeleteSetRouteErrorData(void) +{ + UINT16 wErrorCodeCurSum = 0U;/*뵱ǰ*/ + ErrorDataStruct* errorCodeStu = NULL; /**/ + + wErrorCodeCurSum = GetErrorDataCurSum(); /*ȡ*/ + if (0U < wErrorCodeCurSum) + { + errorCodeStu = GetErrorData(wErrorCodeCurSum - 1U); /*ȡ*/ + if (NULL != errorCodeStu) + { + /*1ǰʻCBTCг·ǷǷ羮· + 2ҽ·״̬Ϊӽӽ쳣Ԥա쳣ʱ + ٴΰ·ʱ·ʧ,󳵿׷ٰ·ʱܷ*/ + if (EFUNC_SET_CBTC_T_ROUTE == errorCodeStu->FunctionId) + { /*CBTC·*/ + if ((CI_DEVICE_TYPE_ROUTE == errorCodeStu->DeviceType) && (ETYPE_ROUTE_STATE == errorCodeStu->DeviceStateType)) + { + DeleteErrorData(wErrorCodeCurSum - 1U); + } + else + { + ; /**/ + } + } + else + { + ;/**/ + } + } + } + else + { + ; /*ûдݲ*/ + } +} +/* +* г߼Դ +* ˵ const UINT16 wLogSectionId, ߼ID +* ֵ VOID +*/ +void SetAllTrainLogicResUseable(const UINT16 wLogSectionId) +{ + UINT8 chLogicResTrainSum = 0U;/*ָ߼Դг*/ + UINT8 jj = 0u; /*ѭ*/ + UINT16 wTrainId = 0U; + UINT16 routeResourceCancelTrainId = 0U;/*ָ·ԴȡгID*/ + UINT16 wLogicRLockRouteId = 0u; /*߼ս·ID*/ + UINT8 chLogicApplyState = 0U;/*г߼״̬*/ + UINT8 chLogicLockState = 0U;/*߼״̬*/ + UINT8 chLogicSecCheckState = CI_ERROR;/*߼ԴԼ*/ + UINT8 chLogRouteLogicLockState = 0U; /*߼·߼״̬*/ + UINT8 chLogicSecLogRouteCheckState = CI_ERROR; /*߼·߼ԴԼ*/ + UINT16 wLogicRLockLogRouteId = 0U; /*߼߼·ID*/ + UINT8 chLogSecAblReverseProperty = 0U; /*߼ABL·*/ + + chLogicResTrainSum = GetLogSecTrainInfoSum(wLogSectionId); + wLogicRLockRouteId = GetLogSecLockBelongRoute(wLogSectionId); /*ȡ·ID*/ + + chLogicLockState = GetLogSecLockState(wLogSectionId); /*·״̬*/ + chLogRouteLogicLockState = GetLogSecLogLockState(wLogSectionId); /*߼·״̬*/ + if (LOGIC_SECTION_RES_SUM_MAX > chLogicResTrainSum) + { + if ((0U < wLogicRLockRouteId) && ((LOG_SECTION_LOCK_NORMAL == chLogicLockState) + || (LOG_SECTION_LOCK_DELAY == chLogicLockState))) + { + /*߼α·գ߼Դ*/ + chLogicSecCheckState = LogicSecResApplicabilityCheck(wLogSectionId); + if (CI_SUCCESS == chLogicSecCheckState) + { + SetLogSecAblUseFlag(wLogSectionId, LOGIC_ABLNEAR_USE_FLAG_YES); + } + else + { + SetLogSecAblUseFlag(wLogSectionId, LOGIC_ABLNEAR_USE_FLAG_NO); + } + } + else + { + /*գABL󱸷߼β*/ + SetLogSecAblUseFlag(wLogSectionId, LOGIC_ABLNEAR_USE_FLAG_NO); + } + + for (jj = 0U; jj < chLogicResTrainSum; jj++) + { + wTrainId = GetLogSecTrainIdByIndex(wLogSectionId, jj); + /*յԴȡ־*/ + wLogicRLockLogRouteId = GetLogSecBelongLogRouteId(wLogSectionId, wTrainId); /*г߼·ID*/ + routeResourceCancelTrainId = GetRouteResourceCancelTrainId(wLogicRLockRouteId); /*ȡָ·ԴȡгID*/ + + chLogicApplyState = GetLogSecTrainApply(wLogSectionId, wTrainId); + + if ((LOGIC_SECTION_TRAIN_APPLY_YES == chLogicApplyState) + && (routeResourceCancelTrainId != wTrainId)) /*ԴȡָѾƳԴ*/ + { + chLogSecAblReverseProperty = CheckLogSecAblReverseProperty(wLogSectionId, (wTrainId & 0x00FFU)); + + if ((LOG_SECTION_LOGLOCK_NORMAL == chLogRouteLogicLockState) && (0U < wLogicRLockLogRouteId)) + { + /*̬·գѯ߼Դ*/ + chLogicSecLogRouteCheckState = LogRouteLogSecResAppCheck(wLogSectionId, wLogicRLockLogRouteId); + + SetLogRouteLogicResUsable(wLogSectionId, wTrainId, chLogicSecLogRouteCheckState); + } + else if ((0U < wLogicRLockRouteId) && ((LOG_SECTION_LOCK_NORMAL == chLogicLockState) + || (LOG_SECTION_LOCK_DELAY == chLogicLockState)) && (CI_SUCCESS == chLogSecAblReverseProperty)) + { + /*߼··߼ԴʱҪгΪABL߼·Ϊ*/ + SetNormalRouteLogicResUsable(wLogSectionId, wTrainId, chLogicSecCheckState); + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); /*ڽ·*/ + } + } + else + { + /*гδ Ϊʹ*/ + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + } + } +} +/* +* ָг߼·߼Դ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* UINT8 wLogicSecLogRouteCheckState ߼οԼ鷵ֵ +* ֵ void +*/ +void SetLogRouteLogicResUsable(const UINT16 wLogSectionId, const UINT16 wTrnId, UINT8 wLogicSecLogRouteCheckState) +{ + UINT16 wLogicRLockLogRouteId = 0U; /*߼߼·ID*/ + UINT8 wLogRouteState = 0U; /*߼·״̬*/ + UINT8 chLogRouteLogicLockState = 0U; /*߼·߼״̬*/ + UINT8 chRouteTrainEnterFlag = 0U;/*гڽ·λ*/ + UINT16 wLogSignalId = 0U; /*߼·źŻ*/ + + wLogicRLockLogRouteId = GetLogSecBelongLogRouteId(wLogSectionId, wTrnId); + wLogRouteState = GetLogicalRouteState(wLogicRLockLogRouteId); + chLogRouteLogicLockState = GetLogSecLogLockState(wLogSectionId); + if ((0U != wLogSectionId) && (0U != wTrnId)) + { + if (LOG_SECTION_LOGLOCK_NORMAL == chLogRouteLogicLockState) + { + wLogSignalId = GetLogicalRouteRelateBeginSigId(wLogicRLockLogRouteId); + if (0U != wLogSignalId) + { + chRouteTrainEnterFlag = dsuLogRouteMinHeadTrainCrosSig(wTrnId, wLogicRLockLogRouteId); + } + else + { + chRouteTrainEnterFlag = TRAIN_ENTER_ROUTE_FULL; /*ʼźŻгѾȫʻ·*/ + } + if ((TRAIN_ENTER_ROUTE_NO == chRouteTrainEnterFlag) + || (TRAIN_ENTER_ROUTE_HEAD == chRouteTrainEnterFlag)) + { + if ((ROUTE_LOGICAL_STATE_OPEN == wLogRouteState)) + { + if (CI_SUCCESS == wLogicSecLogRouteCheckState) + { + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_USABLE); + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else if ((ROUTE_LOGICAL_STATE_UNLOCKWAIT==wLogRouteState) && (TRAIN_ENTER_ROUTE_NO == chRouteTrainEnterFlag)) + { + /*гѳ߼·һ߼εδ·ֵȴ״̬*/ + if (CI_SUCCESS == wLogicSecLogRouteCheckState) + { + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_USABLE); + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else if ((TRAIN_ENTER_ROUTE_FULL == chRouteTrainEnterFlag) + || (TRAIN_ENTER_ROUTE_TAIL == chRouteTrainEnterFlag) + || (TRAIN_ENTER_ROUTE_CROSS == chRouteTrainEnterFlag)) + { + if (CI_SUCCESS == wLogicSecLogRouteCheckState) + { + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_USABLE); + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else + { + /*״̬ ״̬쳣*/ + SetLogSecTrainUseState(wLogSectionId, wTrnId, LOGIC_SECTION_RES_UNUSABLE); + } + } +} + +/* +* ָг·߼Դ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrainId гID +* UINT8 wLogicSecCheckState ߼οԼ鷵ֵ +* ֵ void +*/ +void SetNormalRouteLogicResUsable(const UINT16 wLogSectionId, const UINT16 wTrainId, UINT8 wLogicSecCheckState) +{ + UINT8 chRouteTrainEnterFlag = 0U;/*гڽ·λ*/ + UINT8 chLogicLockState = 0U;/*߼״̬*/ + UINT16 wLogicRLockRouteId = 0u; /*߼ս·ID*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 routeLevel = 0U; /*·ල*/ + UINT8 chTrainMaxHeadCross = 0U;/*гǰǷʻ·־*/ + UINT16 autoRouteID = 0U; + UINT16 autoRouteSetFlag = AUTO_ROUTE_SET_NO; + UINT16 wLockBelongRouteId = 0U; /*··*/ + UINT16 wRouteLastLogSecId = 0U; /*·ڷһ߼*/ + + chLogicLockState = GetLogSecLockState(wLogSectionId); /*·״̬*/ + wLogicRLockRouteId = GetLogSecLockBelongRoute(wLogSectionId); /*ȡ·ID*/ + routeState = GetRouteState(wLogicRLockRouteId); /*ȡ·״̬*/ + routeLevel = GetRouteLevel(wLogicRLockRouteId); /*ȡ·ල*/ + autoRouteID = GetRouteAutoRouteId(wLogicRLockRouteId); + autoRouteSetFlag = GetAutoRouteSetFlag(autoRouteID); + + + if ((LOG_SECTION_LOCK_NORMAL == chLogicLockState) + || (LOG_SECTION_LOCK_DELAY == chLogicLockState)) + { + chRouteTrainEnterFlag = dsuTrainMinHeadCrossSignal(wTrainId, wLogicRLockRouteId); + + chTrainMaxHeadCross = dsuTrainCrossSignal(wTrainId, wLogicRLockRouteId);/*жгǰǷʻ·*/ + + /*гδڽ· гСǰ·δԽѹ*/ + if ((TRAIN_ENTER_ROUTE_NO == chRouteTrainEnterFlag) || (TRAIN_ENTER_ROUTE_HEAD == chRouteTrainEnterFlag)) + { + if ((ROUTE_STATE_YUXIAN_OPEN == routeState) + || (ROUTE_STATE_NEAR_OPEN == routeState) + || (ROUTE_STATE_HALF_UNLOCK == routeState)) + { + if (CI_SUCCESS == wLogicSecCheckState) + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_USABLE); + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else if ((ROUTE_STATE_AUTO_UNLOCK == routeState) && (TRAIN_ENTER_ROUTE_NO == chRouteTrainEnterFlag)) + { + /*гѳ·һ߼εδԴãֻһεĽ·ΪӽʱԴã*/ + if (CI_SUCCESS == wLogicSecCheckState) + { + wLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); /*ȡ߼·*/ + wRouteLastLogSecId = GetRouteInLastLogSecId(wLockBelongRouteId); /*ȡ·ڷһ߼ID*/ + if (wRouteLastLogSecId == wLogSectionId) + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_USABLE); /*·Զгڽ·ڣ·ڷһ߼Դ״̬*/ + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else if ((ROUTE_STATE_NEAR_LOCK == routeState) && + ((TRAIN_ENTER_ROUTE_HEAD == chTrainMaxHeadCross) || (TRAIN_ENTER_ROUTE_CROSS == chTrainMaxHeadCross))) + { + /*ʽ·гʻ·δѹʱѹرźţӽʱǰʻ·ҪԴ*/ + /*CBTC·гʻ·δѹʱѹرźţӽʱǰʻ·ҪԴ гʻʽ·ʹ·תΪCBTC·ҪԴȻ LC 20240626*/ + if (CI_SUCCESS == wLogicSecCheckState) + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_USABLE); + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else if ((ROUTE_STATE_NEAR_LOCKERR == routeState) && (AUTO_ROUTE_SET_YES == autoRouteSetFlag) && (TRAIN_ENTER_ROUTE_HEAD == chRouteTrainEnterFlag)) + { + /*Զͨ·гʻתΪӽ쳣޸гʻ·δѹʱԴõ LC20240625*/ + if (CI_SUCCESS == wLogicSecCheckState) + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_USABLE); + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + + } + /*гѹźŻ гȫڽ· гβڽ·*/ + else if ((TRAIN_ENTER_ROUTE_FULL == chRouteTrainEnterFlag) + || (TRAIN_ENTER_ROUTE_TAIL == chRouteTrainEnterFlag) + || (TRAIN_ENTER_ROUTE_CROSS == chRouteTrainEnterFlag)) + { + if (CI_SUCCESS == wLogicSecCheckState) + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_USABLE); + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } + } + else + { + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } +} + else + { + /*״̬ ״̬쳣*/ + SetLogSecTrainUseState(wLogSectionId, wTrainId, LOGIC_SECTION_RES_UNUSABLE); + } +} + +/* +* г;۷· +* ˵ const UINT16 routeId, ·ID +* ֵ void +* BY LC +*/ +void RouteZhongtuZhefanQuxiaoProc(const UINT16 routeId) +{ + UINT8 checkJiesuoResult = 0u; + + /*·ж*/ + checkJiesuoResult = CheckRouteZhefanJiesuo(routeId); + if (CI_SUCCESS == checkJiesuoResult) + { + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + } + else + { + /*·ܽ*/ + } + +} + +/* +* @brief 벿·߼Σ +* @param const UINT8 cLogSecSeqDir ߼з +* const UINT16 wTrainId г +* const UINT8 cLogSecSum ߼ +* const UINT16* pLogSecIdBuff ߼ +* Created By LQ 2024.09.05 +*/ +void RoutePartApplyLogicManageCLD(const UINT8 cLogSecSeqDir, const UINT16 wTrainId, const UINT8 cLogSecSum, const UINT16* pLogSecIdBuff) +{ + /*ֲʼ*/ + UINT16 wTrainIndex = 0U; + UINT8 keepWork = CI_ERROR; + UINT8 ii = 0U; + UINT8 cDrSubSum = 0U; /*̬·ӽ·*/ + UINT16 wDrSubIdBuff[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*̬·ӽ·ID*/ + UINT8 cCTOccLogSum = 0U; /*ͨг߼*/ + UINT16 szCTOccLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*ͨгռѹ߼ID*/ + UINT16 wUsableDrId = 0U; /*СõĶ̬·ID*/ + UINT8 cLocalCiId = 0U; + UINT8 cRouteBelongCiId = 0U; + UINT16 wMatchedRouteId = 0U; /*ƥĽ·*/ + UINT8 cCheckStep = 0U; /*¼еλãڴ*/ + + /*μ*/ + wTrainIndex = GetTrainBufIndex(wTrainId); + if (((CI_SYSTEM_DIRECTION_DOWN == cLogSecSeqDir) || (CI_SYSTEM_DIRECTION_UP == cLogSecSeqDir)) + && (TRAIN_SUM_MAX > wTrainIndex) && (0U != cLogSecSum) && (NULL != pLogSecIdBuff)) + { + keepWork = CI_SUCCESS; + } + else + { + keepWork = CI_ERROR; + } + + if (CI_SUCCESS == keepWork) + { + /*һ߼мгλã߼Ϊ߻ѹΨһδաгȫλ߻ѹ*/ + keepWork = LogSecSeqAndTrainPosCheckCLD(cLogSecSum, pLogSecIdBuff, wTrainId); + cCheckStep++; + } + else + { + /**/ + } + + if (CI_SUCCESS == keepWork) + { + /*ڶ߼Уƥг·*/ + keepWork = LogSecSeqAndRouteMatchCheckCLD(cLogSecSeqDir, pLogSecIdBuff[0], &wMatchedRouteId); + cCheckStep++; + } + else + { + /**/ + } + + if (CI_SUCCESS == keepWork) + { + /*ͨųûǰ˼˿*/ + keepWork = CtTrainSuspCheck(wTrainId); + cCheckStep++; + } + else + { + /**/ + } + + if (CI_SUCCESS == keepWork) + { + /*IJ·*/ + debug_infor_printf((const)"CLD Half Route Id[%d]\n", wMatchedRouteId); + + cLocalCiId = GetSystemParaLocalCiId(); + cRouteBelongCiId = GetRouteBelongCiId(wMatchedRouteId); + + if ((cLocalCiId == cRouteBelongCiId) && (0U != cLocalCiId)) + { + /*䲿ֽ·ṹ*/ + SetHalfRouteSwitchMoveValid(wMatchedRouteId, ROUTE_HALF_SWITCH_MOVE_INVALID); /*òֽ·ɶ־*/ + SetHalfRouteLockLgcSec(wMatchedRouteId, cLogSecSum, pLogSecIdBuff); /*òֽ·յ߼*/ + SetHalfRouteResReqTrainId(wMatchedRouteId, wTrainId); /*÷ԴгID*/ + SetHalfRouteTrainLocLgcSec(wMatchedRouteId, cCTOccLogSum, szCTOccLogID); /*òֽ·г߼*/ + + keepWork = HalfRoutePhySecUseLogicProcess(wMatchedRouteId); /*ֽ·ü*/ + if (CI_SUCCESS == keepWork) + { + wDrSubIdBuff[cDrSubSum] = wMatchedRouteId; + cDrSubSum++; + } + else + { + SetRouteStateManage(wMatchedRouteId, ROUTE_STATE_IDLE); /*ʧܣý·*/ + } + } + else + { + keepWork = CI_ERROR; /**/ + } + + if ((CI_SUCCESS == keepWork) && (0U != cDrSubSum)) + { + /*ƥĽ·̬·*/ + wUsableDrId = GetUsableDrId(); + SetDrSubRoute(wUsableDrId, cDrSubSum, wDrSubIdBuff); + + debug_infor_printf((const)"CLD Dynamic Sub Route Sum:%d, CLD Dynamic Sub Route ID:[", cDrSubSum); + for (ii = 0U; ii < cDrSubSum; ii++) + { + debug_infor_printf((const)"%d,", wDrSubIdBuff[ii]); + } + debug_infor_printf((const)"]\n"); + } + else + { + keepWork = CI_ERROR; /**/ + } + cCheckStep++; + } + else + { + /**/ + } + + /*¼־*/ + if (CI_SUCCESS != keepWork) + { + /*ʧܣ¼־ + cCheckStepΪ0ʾУʧܣΪ1ʾ߼кгλüʧܣΪ2ʾƥ·ʧܣΪ3ʾгǰ/ɸѡʧܣ + Ϊ4ʾ·ʧ*/ + debug_infor_printf((const)"CLD Route Part Apply Error! Error Position Is [%d]\n", cCheckStep); + } + else + { + /**/ + } +} + +/* +* · +* ˵ void +* ֵ +* by cgh 20241203 +*/ +void RouteOtherCiSwitchManage(void) +{ + UINT16 wRouteCurSum = 0U; /*·Ŀ*/ + UINT16 ii = 0U; + UINT8 chLocalCiId = 0U; /*ID*/ + UINT16 wRouteId = 0U; /*·ID*/ + UINT8 chRouteBelongCiId = 0U; /*·ID*/ + UINT8 chRouteState = 0U;/*·״̬*/ + UINT8 chRouteStateFlag = 0U;/*·״̬תƱ־*/ + UINT8 chRouteSwPosValidCheck = 0U;/*·*/ + UINT8 chResult = 0U;/**/ + UINT8 chTransmitStat = 0U;/*ͨ״̬*/ + UINT8 chRouteApplySwitchCheckFlag = 0U;/*·־*/ + UINT8 chOthCiRouteExistLocalCiSw = 0U;/*·Ƿڱ*/ + + wRouteCurSum = GetRouteCurSum(); /*ȡ·*/ + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + /*·*/ + for (ii = 0u; ii < wRouteCurSum; ii++) + { + wRouteId = 0U; + + wRouteId = GetRouteId(ii); + chRouteBelongCiId = GetRouteBelongCiId(wRouteId); + chOthCiRouteExistLocalCiSw = GetOthCiRouteExistLocalCiSw(wRouteId); + + if ((chLocalCiId != chRouteBelongCiId) && (0U != chLocalCiId) && (0U != chRouteBelongCiId) && (0U != chOthCiRouteExistLocalCiSw)) + { + chRouteState = GetRouteState(wRouteId); + chRouteStateFlag = GetRouteStateFlag(wRouteId); + + if ((ROUTE_STATE_XUANPAI == chRouteState) + || (((ROUTE_STATE_AUTO_UNLOCK == chRouteState) || (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState)) && (ROUTE_STATE_FLAG_YES == chRouteStateFlag)) + || (ROUTE_STATE_LEAD_XUANPAI == chRouteState)) + { + + /*ͨжʱ·״̬׷ٰ־άֵģʱжϵǰǷʧ*/ + chRouteApplySwitchCheckFlag = GetRouteApplySwitchCheckFlag(wRouteId); + + if ((ROUTE_APPLY_SWITCH_CHECK_YES == chRouteApplySwitchCheckFlag) || (ROUTE_APPLY_SWITCH_CHECK_DEF == chRouteApplySwitchCheckFlag)) + { + chRouteSwPosValidCheck = RouteOtherCiSwPosValidCheck(wRouteId); + if (CI_SUCCESS == chRouteSwPosValidCheck) + { + chResult = ChekRoutSwitDrivOvtmStat(wRouteId); + if (CI_SUCCESS == chResult) + { + chResult = RouteLockSwitchDanCaoCheck(wRouteId); + + if (CI_SUCCESS == chResult) + { + SetRouteApplySwitchCheckFlag(wRouteId, ROUTE_APPLY_SWITCH_CHECK_YES); + chResult = RouteRelAllSwitchPosCheck(wRouteId); + if (CI_SUCCESS == chResult) + { + ; /*λȷسɹ*/ + } + else + { + if (ROUTE_STATE_LEAD_XUANPAI != chRouteState) + { + /*·*/ + RouteDrvInnerSwitch(wRouteId, SWITCH_NEED_DRIV_TRUE); + } + else + { + /*·Ҫڹ涨λã*/ + SetRouteApplySwitchCheckFlag(wRouteId, ROUTE_APPLY_SWITCH_CHECK_NO); + } + } + + } + else + { + SetRouteApplySwitchCheckFlag(wRouteId, ROUTE_APPLY_SWITCH_CHECK_NO); + } + } + else + { + SetRouteApplySwitchCheckFlag(wRouteId, ROUTE_APPLY_SWITCH_CHECK_NO); + } + } + else + { + SetRouteApplySwitchCheckFlag(wRouteId, ROUTE_APPLY_SWITCH_CHECK_NO); + } + } + else + { + SetRouteApplySwitchCheckFlag(wRouteId, ROUTE_APPLY_SWITCH_CHECK_NO); + } + } + else + { + /*ý·־ΪĬ*/ + SetRouteApplySwitchCheckFlag(wRouteId, ROUTE_APPLY_SWITCH_CHECK_DEF); + } + } + else + { + ; /*·ԼID쳣*/ + } + } +} + +/* +* +* ˵void +* ֵ +* Created By LQ 2024.12.09 +*/ +void OverlapOtherCiProSwitchManage(void) +{ + UINT16 wOverlapCurSum = 0U; /*Ŀ*/ + UINT16 ii = 0U; + UINT8 cLocalCiId = 0U; /*ID*/ + UINT16 wOverlapId = 0U; /*ID*/ + UINT8 cOverlapBelongCiId = 0U; /*ID*/ + UINT8 cCheckResultFlag = PROSWITCH_CHECK_RESULT_INVALID; /*η־*/ + UINT8 cCheckStartFlag = PROSWITCH_CHECK_START_INVALID; /*η鿪ʼ־*/ + UINT8 cCheckResult = CI_ERROR; /**/ + + wOverlapCurSum = GetOverlapCurSum(); /*ȡ*/ + cLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + for (ii = 0u; ii < wOverlapCurSum; ii++) + { + wOverlapId = GetOverlapId(ii); + cOverlapBelongCiId = GetOverlapBelongCiId(wOverlapId); + + if ((cLocalCiId != cOverlapBelongCiId) && (0U != cLocalCiId) && (0U != cOverlapBelongCiId)) + { + cCheckResultFlag = GetOverlapProSwtCheckResultFlag(wOverlapId); /*ȡη־*/ + cCheckStartFlag = GetOverlapProSwtCheckStartFlag(wOverlapId); /*ȡη鿪ʼ־*/ + + if ((PROSWITCH_CHECK_RESULT_INVALID != cCheckResultFlag) && (PROSWITCH_CHECK_START_VALID == cCheckStartFlag)) + { + cCheckResult = OtherCiOvlpRelProSwMovValCheck(wOverlapId); /*ηɶԼ*/ + if (CI_SUCCESS == cCheckResult) + { + cCheckResult = ChekSwitDrivOvtm(wOverlapId); /*Ƿʱ*/ + if (CI_SUCCESS == cCheckResult) + { + cCheckResult = OverlapLockDriveSwitch(wOverlapId); /**/ + if (CI_SUCCESS == cCheckResult) + { + SetOverlapProSwtCheckResultFlag(wOverlapId, PROSWITCH_CHECK_RESULT_VALID); /*ɹñη־ɹ*/ + } + else + { + SetOverlapProSwtCheckResultFlag(wOverlapId, PROSWITCH_CHECK_RESULT_INVALID); /*ʧܣñη־ʧ*/ + } + } + else + { + SetOverlapProSwtCheckResultFlag(wOverlapId, PROSWITCH_CHECK_RESULT_INVALID); /*ʱñη־ʧ*/ + SetErrorData(EFUNC_SWITCH_DRIVE_OUTTIME, CI_DEVICE_TYPE_SWITCH, wOverlapId, CI_DEVICE_TYPE_OVERLAP, SWITCH_POSITION_INVALID, ESEND_LEVEL_ZERO); + } + } + else + { + SetOverlapProSwtCheckResultFlag(wOverlapId, PROSWITCH_CHECK_RESULT_INVALID); /*ɶԼʧܣñη־ʧ*/ + } + } + else + { + /*βлǰʧܣ*/ + } + } + else + { + /*ڱID쳣*/ + } + } +} + +/* +* ·гͷŽ߼ +* ˵ void +* ֵ +* by cgh 20250107 +*/ +void RouteTrainResUnlockManage(void) +{ + UINT16 wRouteCurSum = 0U; /*·Ŀ*/ + UINT8 chLocalCiId = 0U; /*ID*/ + UINT16 wRouteId = 0U; /*·ID*/ + UINT8 chRouteBelongCiId = 0U; /*·ID*/ + UINT16 ii = 0U; /*ѭ*/ + UINT8 chStartLockState = 0U; /*ϵ־*/ + UINT8 chStartFlockFlag = 0U; /*ϵ־*/ + UINT8 chLocalCiType = 0U; /**/ + UINT8 chFlagExec = CI_ERROR; /*ִб־*/ + UINT8 chRcWorkMode = 0U; /*RCģʽ*/ + + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + chRcWorkMode = GetLocalRcWorkMode(); + + if ((0U != chLocalCiId) && (RC_WORK_MODE_TIOC == chRcWorkMode)) + { + chFlagExec = CI_SUCCESS; + chLocalCiType = GetLocalCiType(); + chStartLockState = GetStartLockFlag(); /*ȡϵ־*/ + chStartFlockFlag = GetStartFLockFlag(); /*ȡϵ־*/ + + if ((CI_TYPE_ZX == chLocalCiType) || (CI_TYPE_SCX == chLocalCiType)) + { + /*ߺԳ߼ȼϵּȫվ*/ + if ((CI_START_LOCK_NO != chStartLockState) || (CI_START_FLOCK_NO != chStartFlockFlag)) + { + /*δȫվδϵ*/ + chFlagExec = CI_ERROR; + } + else + { + ; + } + } + else + {/*νϵ*/ + if (CI_START_LOCK_NO != chStartLockState) + { /*δϵ*/ + + chFlagExec = CI_ERROR; + } + else + { + ; + } + } + } + else + { + ; /*IDǷRCģʽִ*/ + } + + + + if (CI_SUCCESS == chFlagExec) + { + wRouteCurSum = GetRouteCurSum(); /*ȡ·*/ + + /*·*/ + for (ii = 0u; ii < wRouteCurSum; ii++) + { + wRouteId = 0U; /*·ID*/ + chRouteBelongCiId = 0U; /*·ID*/ + + wRouteId = GetRouteId(ii); /*ȡ·ID*/ + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + chRouteBelongCiId = GetRouteBelongCiId(wRouteId); /*ȡ·ID*/ + + if (chLocalCiId == chRouteBelongCiId) + { + RouteLgcSecResUnlockManage(wRouteId); + } + else + { + ; /*DZ*/ + } + } + else + { + ; /*·IDǷ*/ + } + } + } + else + { + ; /*ִ*/ + } +} + +/* +* ·ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +* by cgh 20250224 +*/ +void LeadRouteFirstXuanPaiManage(const UINT16 routeId) +{ + UINT8 returnValueFunc = 0U; /*ֵ*/ + UINT8 firstXuanPaiOvertime = 0U;/*ѡʱ*/ + UINT8 routeCheck = 0U; + UINT8 chFunctionId = EFUNC_LEAD_ROUTE_FIRST_XUANPAI;/*뺯ID*/ + + routeCheck = SetLeadRouteCheck(routeId); + + /*·*/ + if (CI_SUCCESS == routeCheck) + { + firstXuanPaiOvertime = RouteFirstXuanOverTime(routeId); + if (OVERTIME_YES == firstXuanPaiOvertime) + { + /*ѡʱ*/ + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + + /*ӽ·ѡʱӡ*/ + SetErrorData(chFunctionId, CI_DEVICE_TYPE_ROUTE, routeId, + ETYPE_ROUTE_FIRST_XUANPAI_OVERTIME, ROUTE_STATE_LEAD_FIRST_XUANPAI, ESEND_LEVEL_ZERO); + } + else + { + /*·ѡ*/ + returnValueFunc = RouteFirstXuanProc(routeId); + + if (CI_ERROR == returnValueFunc) + { + /*ʧ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + } + else if (CI_SUCCESS == returnValueFunc) + { + /*óɹ*/ + + SetRouteStateManage(routeId, ROUTE_STATE_LEAD_XUANPAI); /*-->ѡ*/ + + /*·ѡŴ*/ + LeadRouteXuanPaiManage(routeId); + } + else + { + ; /*ȴ*/ + } + } + } + else + { + /*·ʧ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + /*ý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/LogicManage/InterlockLogicManage.h b/TSCP/src/APP/ciapp/LogicManage/InterlockLogicManage.h new file mode 100644 index 0000000..d27a910 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicManage/InterlockLogicManage.h @@ -0,0 +1,1138 @@ +/******************************************************** +* +* InterlockLogicManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-10 +* ߣ +* ߼ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _INTERLOCK_LOGIC_MANAGE_H_ +#define _INTERLOCK_LOGIC_MANAGE_H_ + + +#include "../System/SystemParameterManage.h" +#include "../System/CiSystemDefine.h" +#include "../Switch/SwitchDefine.h" +#include "../Switch/SwitchDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Signal/SignalDefine.h" +#include "../Signal/SignalDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Section/SectionDefine.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Section/LogicSectionDataManage.h" +#include "../Section/LogicSectionConfigDataManage.h" +#include "../Section/AxisSectionDataManage.h" +#include "../Section/AxisSectionConfigDataManage.h" +#include "../Route/RouteDefine.h" +#include "../Route/RouteDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../PSD/PSDDataManage.h" +#include "../PSD/PSDConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../Overlap/OverlapDataManage.h" +#include "../Overlap/OverlapConfigDataManage.h" +#include "../ESB/ESBDataManage.h" +#include "../ESB/ESBConfigDataManage.h" +#include "../ERROR/ErrorDataManage.h" +#include "../ERROR/ErrorDefine.h" +#include "../AutoReturn/AutoReturnDataManage.h" +#include "../AutoRoute/AutoRouteDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../ParsePack/CiInterfaceDefine.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../LogicProcess/InterlockLogicCheck.h" +#include "../IO/DeviceRelayDataProcess.h" +#include "../AllAutoReturn/AllAutoReturnDataManage.h" +#include "../Garagedoor/GaragedoorConfigDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" +#include "../LogicManage/InterlockCommonManage.h" +#include "../LogicProcess/InterlockLogicProcess.h" +#include "../LogicProcess/TradInterlockLogicProcess.h" +#include "../LogicManage/TradInterlockLogicManage.h" + +#ifdef SCADE_MODE +#include "../LogicManage/General/LogicManageScadeInterface.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* +* ־߼ +* ˵ UINT8 setFlag ־ + CI_ALL_SWITCH_YLOCK_YES + CI_ALL_SWITCH_YLOCK_NO +* ֵ void +*/ +void SetCiYLockManage(UINT8 setFlag); + +/* +* ־߼ +* ˵ UINT8 setFlag ־ + const UINT8 virCIid ID +* ֵ void +*/ +void SetCiYLockManage_UseVirCI(UINT8 setFlag,const UINT8 virCIid); + +/* +* ߼ +* ˵ void +* ֵ +*/ +void InterlockLogicMainProc(void); + +/* +* ·߼ +* ˵ void +* ֵ +*/ +void RouteLogicManage(void); + + +/* +* ·й +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteIdleManage(const UINT16 routeId); + +/* +* ·ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstXuanPaiManage(const UINT16 routeId); + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteXuanPaiManage(const UINT16 routeId); + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LeadRouteXuanPaiManage(const UINT16 routeId); + +/* +* · +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstLockManage(const UINT16 routeId); + +/* +* ·쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstLockErrManage(const UINT16 routeId); + +/* +* ·Ԥչ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteYuXianLockManage(const UINT16 routeId); + +/* +* ·ԤȿŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteYuXianOpenManage(const UINT16 routeId); + +/* +* ·ӽ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearLockErrManage(const UINT16 routeId); + +/* +* ·ӽŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearOpenManage(const UINT16 routeId); + +/* +* ·ӽչ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearLockManage(const UINT16 routeId); + +/* +* ·ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteDelayUnlockManage(const UINT16 routeId); + +/* +* ·Զ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RoutePhySecAutoUnlockManage(const UINT16 routeId); + +/* +* ·Զ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RoutePhySecAutoUnlockErrManage(const UINT16 routeId); + +/* +* ·չ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadLockManage(const UINT16 routeId); + +/* +* ·쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadLockErrManage(const UINT16 routeId); + +/* +* ·Ź +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadOpenManage(const UINT16 routeId); + +/* +* · +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 SetRouteProc(const UINT16 routeId); + +/* +* ·ѡ-ȡԶźŽ· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 + CI_SUCCESS:ȡɹ + CI_ERROR:ȡʧ + RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT:ȴȡ +*/ +UINT8 RouteFirstXuanAutoSigProc(const UINT16 routeId); + +/* +* ս· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 LockRouteProc(const UINT16 routeId); + +/* +* ·Overlap +* ˵const UINT16 routeId, ·ID +* ֵ0 ʧ +* 1 ɹ +* 0x22 λô +* 0x30 ȴ +* 0x31 ȴ +*/ +UINT8 LockRouteOverlapProc(const UINT16 routeId); + +/* +ձι +UINT8 overlapSum +UINT16 * pOverlapIdBuf IDָ +UINT8 PLockDirect շ + +CI_SUCCESS ɹ +CI_ERROR ʧ + +*/ +UINT8 LockLocalOvlpManageHlht(UINT8 overlapSum, UINT16 * pOverlapIdBuf, UINT8 PLockDirect); + +/* +* Ž·źŴ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 OpenRouteSignalProc(const UINT16 routeId); +/* +* ֿŽ·źŴ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 KeepOpenRouteSignalProc(const UINT16 routeId); + +/* +* ·ȡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongQuXiaoProc(const UINT16 routeId); + +/* +* ԶźŽ·ȡ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 AutoSigRouteQuXiaoProc(const UINT16 routeId); + +/* +* ·˽⴦ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongRenJieProc(const UINT16 routeId); + + +/* +* ·OVERLAP +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 UnlockRouteOverlapProc(const UINT16 routeId); + +/* +ι +UINT8 overlapIdSum +UINT16 * pOverlapIdBuf IDָ + +CI_SUCCESS ɹ +CI_ERROR ʧ + +*/ +UINT8 UnLockLocalOvlpManageHlht(UINT8 overlapIdSum, UINT16 * pOverlapIdBuf); + + +/* +* ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void PhySecDelayUnlockProc(const UINT16 routeId); + + + +/* +* ·гʻ +* ˵ const UINT16 routeId, ·ID +* ֵ FUNCTION_SUCCESSɹ +* FUNCTION_RETURN_ERROR ʧ +*/ +UINT8 RouteLTrainEnter(const UINT16 routeId); + +/* +* ·رźŴ +* ˵ const UINT16 routeId, ·ID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 RouteOpenNeedCloseSignal(const UINT16 routeId); + + +/* +* overlap +* ˵ const UINT16 overlapId, overlap ID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 OverlapLockDriveSwitch(const UINT16 overlapId); + +/* +* Overlap״̬ +* ˵ const UINT16 overlapId, overlap ID +* const UINT8 lockState, ״̬ +* const UINT16 routeId, ·ID +* ֵ void +*/ +void SetOverlapLockState(const UINT16 overlapId, const UINT8 lockState, const UINT16 routeId); + +/* +* ͨ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetCommonRouteLogicManage(const UINT16 routeId); + +/* +* ·߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +* edit cgh 20250224 +*/ +void SetLeadRouteLogicManage(const UINT16 signalId); + +/* +* ·ȡ߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongQuXiaoLogicManage(const UINT16 routeId); + +/* +* ·˽߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongRenJieLogicManage(const UINT16 routeId); + +/* +* õ߼ +* ˵ UINT16 switchId, ID +* const UINT8 switchPos, λ +* ֵ void +*/ +void SetSwitchPositionLogicManage(const UINT16 switchId, const UINT8 switchSetPos); + +/* +* õ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void SetSwitchDLockLogicManage(const UINT16 switchId); + +/* +* ȡ߼ +* ˵ const UINT16 switchId, ID +* ֵ +*/ +void CancelSwitchDLockLogicManage(const UINT16 switchId); + +/* +* õ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void SetSwitchFLockLogicManage(const UINT16 switchId); + +/* +* ȡ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void CancelSwitchFLockLogicManage(const UINT16 switchId); + +/* +* ؿź߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void RepeatOpenSignalLogicManage(const UINT16 signalId); + +/* +* ź߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void OpenLeadSignalLogicManage(const UINT16 signalId); + + +/* +* źŻ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void SetSignalFLockLogicManage(const UINT16 signalId); + +/* +* ȡźŻ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void CancelSignalFLockLogicManage(const UINT16 signalId); + +/* +* ϵ߼ +* ˵ void +* ֵ void +*/ +void SetStartupUnLockLogicManage(void); + +/* +* ·״̬ù·״̬ñͨ +* ˵ + const UINT16 routeId, UINT8 routeState +* ֵ void +* edit cgh 20250224 +*/ +void SetRouteStateManage(const UINT16 routeId, UINT8 routeState); + +/* +* ղ̵ +* ˵ + const UINT16 routeId, UINT8 routeState +* ֵ + CI_ERROR + CI_SUCCESS +*/ +void UpdateZhaoChaStateManage(const UINT16 routeId, UINT8 routeState); + +/* +* Զ·߼ +* ˵ const UINT16 autoRouteId, ·ID +* ֵ void +*/ +void SetAutoRouteLogicManage(const UINT16 autoRouteId,const UINT8 virCIid); + +/* +* ȡԶ·߼ +* ˵ const UINT16 autoRouteId, ·ID +* ֵ void +*/ +void CancelAutoRouteLogicManage(const UINT16 autoRouteId,const UINT8 virCIid); + +/* +* Զ۷߼ +* ˵ const UINT16 autoReturnId, ·ID +* ֵ void +*/ +void SetAutoReturnLogicManage(const UINT16 autoReturnId,const UINT8 virCIid); + +/* +* ȡԶ۷߼ +* ˵ const UINT16 autoReturnId, ·ID +* ֵ void +*/ +void CancelAutoReturnLogicManage(const UINT16 autoReturnId,const UINT8 virCIid); + +#if 0 +/* +* ʽ׹Ϊ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetFultSectionErrorLock(const UINT16 routeId); +#endif + +/* +* ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +void LockOverlapLogicManage(const UINT16 routeId); + +/* +* ·ν߼ +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +void UnlockOverlapLogicManage(const UINT16 routeId); + +/* +* ȫվ߼ +* ˵ void +* ֵ void +*/ +void SetStartFLockUnLockLogicManage(void); + +/* +* Ḵλ߼ +* ˵ const UINT16 phySecId, ID +* ֵ void +*/ +void SetSectionResetLogicManage(const UINT16 phySecId, const UINT8 resetType); + +/* +* ۷·Ϊͨ· +* ˵ const UINT16 signalId, ͨźŻID +* ֵ void +*/ +void SetThroughRouteManage(const UINT16 signalId); + +/* +* źŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void SetYLockSignalOpenStateManage(UINT8 virCIid, UINT16 signalId); + +/* +* õǿ߼ +* ˵ UINT16 switchId, ID +* const UINT8 switchSetPos, λ +* ֵ void +*/ +UINT8 ForceSetSwitchPositionManage(const UINT16 switchId,const UINT8 switchSetPos); + +/* +* ۳߼ +* ˵ const UINT16 signalId, źŻID +* const UINT8 SetState, ״̬ +* ֵ void +*/ +void DetainLogicManage(const UINT16 signalId,const UINT8 setState); + +/* +* ȫԶ۷߼ +* ˵ const UINT16 allAutoReturnId, ·ID +* ֵ void +*/ +void SetAllAutoReturnLogicManage(const UINT16 allAutoReturnId,const UINT8 virCIid); + +/* +* ȡȫԶ۷߼ +* ˵ const UINT16 allAutoReturnId, ·ID +* ֵ void +*/ +void CancelAllAutoReturnLogicManage(const UINT16 allAutoReturnId,const UINT8 virCIid); +/* +* ȫԶ۷·߼ +* ˵ void +* ֵ +*/ +void AllAutoReturnLogicManage(void); +/* +* ȫԶ۷· +* úڽ·УִС +* ݵǰ·״̬Լ·Զ· +* +* +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void AllAutoReturnManage(const UINT16 routeId); + + +/* +* Գ +* +* +* ˵ void +* ֵ void +*/ +void StartTrianTestManage(void); + +/* +* ȡԳ +* +* +* ˵ void +* ֵ void +*/ +void StopTrianTestManage(void); + +/* +* ȡʱ +* ˵ +* ֵ + CI_ERROR ʧ + CI_SUCCESS ɹ +*/ +UINT8 CancleLinShiXianSuManage(void); +/* +* ȡʱ +* ˵ +* ֵ +* void +*/ +void CancleLinShiXianSuManage_Vir(const UINT8 virCIid); + +/* +* ·ѡ-ȡԶźŽ·ȴռͨ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 + CI_SUCCESS:ȡԶźŽ·ռɹ + CI_ERROR:ȡԶźŽ·ռʧ + RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT:ȴȡ +*/ +UINT8 RouteFirstXuanAutoSigCancelPro(const UINT16 routeId); +/* +* ·״̬תƹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteStateFlagManage(const UINT16 routeId); +/* +* ·ѡ״̬תƹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteXuanPaiStateManage(const UINT16 routeId); + +/* +* ָOverlapIdеãδã +* ˵ UINT16 overlapId, ID +* UINT8 usingState Ƿ SWITCH_USING_YES SWITCH_USING_NOδ +*/ +void SetOverlapRelSwitchUsing(UINT16 overlapId, UINT8 usingState); + +/* +* ȡָRouteIdеǷ +* ˵ UINT16 routeId, ·ID +* ֵ UINT8 Ƿ SWITCH_USING_YES SWITCH_USING_NOδ +*/ +UINT8 CheckRouteContainSwitchUseSta(UINT16 routeId); + +/* +* ATSս·Overlap +* ˵ const UINT16 routeId, ·ID +* const UINT16 expLkOverlapId, ձID +* ֵ UINT8 +* 1:ճɹûбλ򱣻չ +* 0:ʧ +* 0x22: λôҪ +*/ +UINT8 LockRouteOverlapAccdToAtsCmd(const UINT16 routeId, const UINT16 expLkOverlapId); + +/* +* η߼ +* ˵ const UINT16 phySecId, ID +* ֵ void +*/ +UINT8 SetSectionFLockLogicManage(const UINT16 phySecId); + +/* +* ȡη߼ +* ˵ const UINT16 phySecId, ID +* ֵ void +*/ +UINT8 CancelSectionFLockLogicManage(const UINT16 phySecId); + + +/* +* ߼ +* ˵ void +* ֵ +*/ +void FloodLogicManage(void); + +/* +* ߼ +* ˵ void +* ֵ +*/ +void UnlockSwitchLogicManage(void); +#if 0 +/* +* вԾ߼ +* ˵ void +* ֵ +*/ +void SwitchAxisSecJumpLockLogicManage(void); +#endif + +/* +* Ծ߼ +* ˵ void +* ֵ +*/ +void JumpLockManage(void); + +/* +* ڼ߼Ծ +* ˵ +* ֵ +*/ +void CheckLogSecJumpLockManage(void); + +/* +* Ծ߼ +* ˵ void +* ֵ +*/ +void AxisSecJumpLockLogicManage(void); + +/* +* ԾѡŹ +* ˵ const UINT16 axisSecId, ID +* ֵ void +*/ +void AxisJumpLockXuanPaiManage(const UINT16 axisSecId); + +/* +* Ծռδ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 LockAxisSecProc(const UINT16 axisSecId); + +/* +* 缯Զ·豸 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void CrossCiAutoRouteFLockDevProc(const UINT16 routeId); + + +/* +* ȡ̵ӿȷϱ־ +* ˵ void +* ֵ CICI_RELAY_INTERFACE_CONFIRM_NO ̵ӿδȷ +* CICI_RELAY_INTERFACE_CONFIRM_YES ̵δȷ +*/ +UINT8 GetCiCiRelayInterfConfirmFlag(void); + +/* +* ü̵ӿȷϱ־ +* ˵ UINT8 setFlag,ñ־ +* ֵ void +*/ +void SetCiCiRelayInterfConfirmFlag(UINT8 setFlag); +/* +* ݽ·״̬źű̿ſʼֵ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetClearKeepSignalTolerateCyc(const UINT16 routeId); + + +/* +* PSC·״̬ȷϱ־ +* ˵ UINT8 setFlag,ñ־ +* const UINT16 pscId +* ֵ +*/ +void SetCiPscPlConfirmFlag(UINT8 setFlag, const UINT16 pscId); + +/* +* ݱοʼѡֵ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void ClearOverlopUsing(const UINT16 routeId); + + +/* +* ·ڱ·رźŻڱ +* ˵ void +* ֵ +*/ +void NearCIRouteNeedCloseProce(void); + +/* +* Զ·Ľ·Ƿڱ +* ˵ Զ·ID ID +* ֵ void +*/ +UINT8 CheckAutoRouteBelongVirCI(const UINT16 autoRouteId,const UINT8 virCIid); +/* +* Զ۷·Ľ·Ƿ +* ˵ Զ·ID ID +* ֵ void +*/ +UINT8 CheckAutoReturnBelongVirCI(const UINT16 autoRouteId,const UINT8 virCIid); +/* +* ȫԶ۷·Ľ·Ƿ +* ˵ Զ·ID ID +* ֵ void +*/ +UINT8 CheckALLAutoReturnBelongVirCI(const UINT16 allAutoRouteId,const UINT8 virCIid); +/* +*ܣԶͨ·Զ +*˵const UINT16 groupAutoRouteId Զ·ID +*ֵ +*/ +void SetGroupAutoRouteLogicManage(const UINT16 groupAutoRouteId); + +/* +*ܣȡԶͨ·Զ +*˵const UINT16 groupAutoRouteId Զ·ID +*ֵ +*/ +void CancleGroupAutoRouteLogicManage(const UINT16 groupAutoRouteId); + +/* +* ·λ߼Զ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RoutePhyOrLogSecAutoUnlocManage(const UINT16 routeId); +/* +* ·߼Զ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLogSecAutoUnlockManage(const UINT16 routeId); + +/* +* ߼Դ +* ˵ void +* ֵ +*/ +void LogicSecResManage(void); + +/* +* @brief ·߼ +* @param const UINT16 routeId ·ID +* const UINT16 trainId г +* @note WQM 20220307 +*/ +void RouteApplyLogicManage(const UINT16 routeId, const UINT16 trainId); + +/* +* @brief 벿·߼ +* @param const UINT8 cLogSecSeqDir ߼з +* const UINT16 wTrainId г +* const UINT8 cLogSecSum ߼ +* const UINT16 pLogSecIdBuff[] ߼ +*/ +void RoutePartApplyLogicManage(const UINT8 cLogSecSeqDir, const UINT16 wTrainId, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[]); + +/* +* ·߼Դг +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLgcSecResUnlockManage(const UINT16 wRouteId); + +/* +* ź߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void OpenXianSuSignalLogicManage(const UINT16 signalId); + +/* +* ·ͱٴһʱٵ߼ +* ˵const UINT16 routeId·ID +* ֵ CI_ERROR δʱ + CI_SUCCESS һ߼ʱ +* wqm 20220809 +*/ +UINT8 CheckRouteLgsLinShiXianSuExist(const UINT16 routeId); + +/* +* ·ȡԴ߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteCancelResLogicManage(const UINT16 wRouteId, const UINT16 wTrainId); + +/* +* ·ѡǷʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +* OVERTIME_YESѡųʱ +* OVERTIME_NOѡδʱ +* cgh-ϲCID-2341-7 ޸ѡųʱ +*/ +UINT8 RouteFirstXuanOverTime(const UINT16 routeId); +/* +* εѡʼں +* ˵ +* +*޸ģcgh-ϲCID-2341-8 +*/ +void ClearOverlapXuanPaiStartCycNum(void); +/* +* ָIDηǸspksµµ +* ˵ const UINT16 phySectionId, ID +UINT8 *state spks״̬ +UINT8 *spksId spksId +* ֵ CI_SUCCESS: εspksµ +* CI_ERROR: ζӦspksȫδ»spksIdϷ +add by pfq 2022.04.21 +*/ +UINT8 CheckPhysecFlockReasonSpksId(const UINT16 phySectionId, UINT16* spksId, UINT8* state); +/* +* ˹δ +* ˵ const UINT8 overlapId ID +* ֵCI_ERROR ʧ +* CI_SUCCESS ɹ +* +*޸ģmpt 202239 ӱ˹߼ +*/ +UINT8 LaborUnlockOverlapProc(const UINT8 overlapId); +/* +* ձα־ +* ˵ const UINT16 routeId, ·ID +* cgh-ϲCID-2539-10 ·վأ۱ʲô״̬ձ +*/ +void SetRouteOverlapNeedCIlockM(const UINT16 routeId); + +/* +* Ծ߼ +* ˵ void +* ֵ +* by-cgh-20230628 +*/ + +void PhySecJumpLockLogicManage(void); + +/* +* ·쳣ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +* cgh:2023.05.06 +*/ +void RouteHalfUnlockDelayManage(const UINT16 routeId); + +/* +* ֽ· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 SetRouteHalfProc(const UINT16 routeId); + +/* +* ··ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteHalfFirstXuanManage(const UINT16 routeId); + +/* +* ··ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteHalfXuanPaiManage(const UINT16 routeId); + +/* +* ս·· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 LockRouteHalfProc(const UINT16 routeId); + +/* +* ·ȡԴʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteCancelResApplyManage(const UINT16 routeId); + +/* +* +* ·չ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteHalfLockManage(const UINT16 routeId); + +/* +* +* ·ս +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteHalfUnlockManage(const UINT16 routeId); + +/* +*@brief CIIJ· +* ToCiDrCmdDataStruct* pCiRecvCiDrCmdStru ̬·Ľṹ +* +* ֵ +*/ +void SetRoutePartApplyFromCi(ToCiDrCmdDataStruct* pCiRecvCiDrCmdStru); + +/* +* ·ѡͨô +* ˵ const UINT16 wRouteId, ·ID +* const UINT8 chLockRouteProcCheck ս· +* ֵ UINT8 +* by cgh 20230720 ȦӶȣ·ѡŽ׶εŲ˺ +*/ +void RouteXuanPaiCommonProcess(const UINT16 wRouteId, const UINT8 chLockRouteProcCheck); + +/* +* ·ijҪ˽·ʱʱ߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearestTrainRenJieManage(const UINT16 routeId); + +/* +* ɾ·պٴΰ·ʱĴ +* ˵ void +* ֵ void +* by cgh 20230930 +*/ +void DeleteSetRouteErrorData(void); + +/* +* г߼Դ +* ˵ const UINT16 wLogSectionId, ߼ID +* ֵ VOID +*/ +void SetAllTrainLogicResUseable(const UINT16 wLogSectionId); + +/* +* ָг߼·߼Դ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* UINT8 wLogicSecLogRouteCheckState ߼οԼ鷵ֵ +* ֵ void +*/ +void SetLogRouteLogicResUsable(const UINT16 wLogSectionId, const UINT16 wTrnId, UINT8 wLogicSecLogRouteCheckState); + +/* +* ָг·߼Դ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrainId гID +* UINT8 wLogicSecCheckState ߼οԼ鷵ֵ +* ֵ void +*/ +void SetNormalRouteLogicResUsable(const UINT16 wLogSectionId, const UINT16 wTrainId, UINT8 wLogicSecCheckState); + + +/* +* г;۷· +* ˵ const UINT16 routeId, ·ID +* ֵ void +* BY LC +*/ +void RouteZhongtuZhefanQuxiaoProc(const UINT16 routeId); + +/* +* @brief 벿·߼Σ +* @param const UINT8 cLogSecSeqDir ߼з +* const UINT16 wTrainId г +* const UINT8 cLogSecSum ߼ +* const UINT16* pLogSecIdBuff ߼ +* Created By LQ 2024.09.05 +*/ +void RoutePartApplyLogicManageCLD(const UINT8 cLogSecSeqDir, const UINT16 wTrainId, const UINT8 cLogSecSum, const UINT16* pLogSecIdBuff); + +/* +* · +* ˵ void +* ֵ +* by cgh 20241203 +*/ +void RouteOtherCiSwitchManage(void); + +/* +* +* ˵void +* ֵ +* Created By LQ 2024.12.09 +*/ +void OverlapOtherCiProSwitchManage(void); + +/* +* ·гͷŽ߼ +* ˵ void +* ֵ +* by cgh 20250107 +*/ +void RouteTrainResUnlockManage(void); + +/* +* ·ѡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +* by cgh 20250224 +*/ +void LeadRouteFirstXuanPaiManage(const UINT16 routeId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/LogicManage/RouteRecoverManage.c b/TSCP/src/APP/ciapp/LogicManage/RouteRecoverManage.c new file mode 100644 index 0000000..4431120 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicManage/RouteRecoverManage.c @@ -0,0 +1,4881 @@ +/******************************************************** +* +* RouteRecoverManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2017-01-04 +* ߣ +* ʵPSDSPKS۳ָؿźŵĹܡģҪɿźԼźűֽ׶ε飬е߼dzơ +* +* ʹע⣺ +* ޸ļ¼ +* 2017-01-04 ½ +* +********************************************************/ +#include "RouteRecoverManage.h" +#include "../LogicProcess/InterlockLogicCheck.h" +#include "../System/SystemConfigDefine.h" +#include "../LogicProcess/InterlockLogicProcess.h" +#include "../LogicProcess/TradInterlockLogicProcess.h" +#include "../LogicProcess/LogicalRouteLogicCheck.h" + +/* +* ·η +* ˵ UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 RouteSecFLockErrCheck(UINT16 const routeId); + +/* +* η״̬ЧԼ +* ˵ UINT16 const overlapId, OverlapID +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OverlapAllSecFLockValidErrCheck(UINT16 const overlapId); + +/* +* Cbtc·źű +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 KeepCbtcRouteSectionErrCheck(const UINT16 routeId); + +/* +* ŵ· +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 KeepDTrainRouteSectionErrCheck(const UINT16 routeId); + +/* +* ʽ·źű +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenBlocRouteOverlapErrCheck(const UINT16 routeId); + +/* +* ʽ·ź +* ˵ +* const UINT16 routeId, · +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenBlocRouteSectionErrCheck(const UINT16 routeId); + +/* +* Cbtc·źſ +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenCbtcRouteSectionErrCheck(const UINT16 routeId); + +/* +* ŵ· +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenDTrainRouteSectionErrCheck(const UINT16 routeId); + +/* +* г·飬 +* ˵ +* const UINT16 routeId, ·ID +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenLTrainRouteSectionErrCheck(const UINT16 routeId); + +/* +* +* ˵ UINT16 routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OtherCiValidErrCheck(UINT16 const routeId); + +/* +* ָг·źŻ +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +*/ +static UINT8 RecoverLTrainRouteSignalCheck(const UINT16 routeId); + +/* ָʽ·źŻ */ +/* +* ʽ·źŻ +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +*/ +static UINT8 RecoverBlocRouteSignalCheck(const UINT16 routeId); + +/* ָ·SPKS */ +/* +* ·Ч +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS ޲ + CI_ROUTE_RECOVER_ERR:SPKSµޣǵSPKSָؿź +*/ +static UINT8 RouteIntruSecVainSPKSErrCheck(const UINT16 routeId); + +/* +* ָ·ղ +* ˵ UINT16 const routeId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* RELAY_STATE_WAITE +*/ +static UINT8 RouteRelayZhaoChaErrCheck(UINT16 const routeId); + +/* +* CBTC·߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenCbtcLTrainRouteErrProcess(const UINT16 routeId, const UINT8 checkStep) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_OPEN_CT_ROUTE_ERR_ZX; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + /* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; + UINT8 routeReverseProperty = 0u; + UINT8 airShaftRouteType = 0u; + + /* ߼ */ + /* ·ලģʽΪCBTC*/ + + devState = GetRouteLevel(routeId); + if (ROUTE_LEVEL_CBTC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_LIECHE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* ·״̬Ϊ + · + ·쳣 + Ԥա + ӽ쳣 + ӽ + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_FIRST_LOCK == devState) || + (ROUTE_STATE_FIRST_LOCKERR == devState) || + (ROUTE_STATE_YUXIAN_LOCK == devState) || + (ROUTE_STATE_NEAR_LOCKERR == devState) || + (ROUTE_STATE_NEAR_LOCK == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) && + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + if (OPEN_CHECK_STEP_OPEN == checkStep) + { + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + } + else if (OPEN_CHECK_STEP_RECOVER == checkStep) + { + checkResult = RecoverBlocRouteSignalCheck(routeId); + } + else + { + checkResult = CI_ERROR; + } + + if (CI_ERROR == checkResult) + { + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + if (CI_SUCCESS == reResult) + { + routeReverseProperty = GetRouteReverseProperty(routeId); + airShaftRouteType = GetAirShaftRouteType(routeId); + if ((ROUTE_REVERSE_PROPERTY_YES == routeReverseProperty) || (ROUTE_TYPE_AIRSHAFT == airShaftRouteType)) + { /*·εռ״̬֮ǰڲռ״̬źų·ڷһΣźŻؿ*/ + /*羮·׷ٰʿӶԽ·ڷεռ״̬*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + } + else + { + ; + } + } + else + { + ; + } + + /* ź */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenCbtcRouteOtherSignalCheck(routeId, functionId, sendLevel); + /*ʧ ·迪δ,ʧ;reResultֵ*/ + if ((CI_ERROR == checkResult) || (RETURN_OPEN_ERR_NEEDOPEN == checkResult)) + { + reResult = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } + + /* ӷ(۳)*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (CI_ERROR == checkResult) + { + /*ʧܷؿؿ*/ + reResult = CI_ROUTE_RECOVER_ERR; + } + else + { + ; + } + } + else + { + ; + } + + /* */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenCbtcRouteSectionErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + return reResult; +} + +/* +* ŵʽ·߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenBlocLTrainRouteErrProcess(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_OPEN_UT_ROUTE_ERR_ZX; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + + + /* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; + + /* ߼ */ + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_LIECHE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + · + ·쳣 + Ԥա + ӽ쳣 + ӽ + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_FIRST_LOCK == devState) || + (ROUTE_STATE_FIRST_LOCKERR == devState) || + (ROUTE_STATE_YUXIAN_LOCK == devState) || + (ROUTE_STATE_NEAR_LOCKERR == devState) || + (ROUTE_STATE_NEAR_LOCK == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) && + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_SIGOPEN == checkResult) + {/*رҲΪϷ*/ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* ӷ(۳)*/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ROUTE_RECOVER_ERR; + } + } + + /* */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteSectionErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* · */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + /* */ + return reResult; +} + +/* +* CBTC۷·߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenCbtcReturnRouteErrProcess(const UINT16 routeId, const UINT8 checkStep) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_OPEN_CT_RETURN_ERR_ZX; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; + + /* ߼ */ + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(routeId); + if ((ROUTE_LEVEL_CBTC == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + + /* ·ǡ۷·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_RETURN == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* ·״̬Ϊ + · + ·쳣 + Ԥա + ӽ쳣 + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_FIRST_LOCK == devState) || + (ROUTE_STATE_FIRST_LOCKERR == devState) || + (ROUTE_STATE_YUXIAN_LOCK == devState) || + (ROUTE_STATE_NEAR_LOCKERR == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + else + { + ; + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) && + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + if (OPEN_CHECK_STEP_OPEN == checkStep) + { + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + } + else if (OPEN_CHECK_STEP_RECOVER == checkStep) + { + checkResult = RecoverBlocRouteSignalCheck(routeId); + } + else + { + checkResult = CI_ERROR; + } + + if (CI_ERROR == checkResult) + { + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* ·ռ״̬С*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_SIGOPEN == checkResult) + {/*رҲΪϷ*/ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + else + { + ; + } + + /* ӷ(۳)*/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ROUTE_RECOVER_ERR; + } + } + else + { + ; + } + + /* */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenCbtcRouteSectionErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + /* ͨ */ + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /* · */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + /* ͨ */ + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + /* ͨ */ + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /* */ + return reResult; +} + +/* +* ŵʽ۷·ź +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenBlocReturnRouteErrProcess(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_OPEN_UT_RETURN_ERR_ZX; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + UINT8 devId = 0u; /*豸Id*/ + + /* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; + UINT16 endSigId = 0u; /*ȡ;۷źŻID*/ + UINT8 endSigState = SIGNAL_OPEN; + + /* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ǡ۷·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_RETURN == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + · + ·쳣 + Ԥա + ӽ쳣 + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_FIRST_LOCK == devState) || + (ROUTE_STATE_FIRST_LOCKERR == devState) || + (ROUTE_STATE_YUXIAN_LOCK == devState) || + (ROUTE_STATE_NEAR_LOCKERR == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) && + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_SIGOPEN == checkResult) + {/*رҲΪϷ*/ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* ӷ(۳)*/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ROUTE_RECOVER_ERR; + } + } + + /* */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteSectionErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + /* ͨ */ + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* · */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + /* ͨ */ + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + /* ͨ */ + reResult = checkResult; + } + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + + /* */ + return reResult; +} + +/* +* CBTCгźű +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepCbtcLTrainRouteErrProcess(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_KEEP_CT_SIGNAL_ERR_ZX; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + /* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; + UINT8 routeReverseProperty = 0u; + UINT8 airShaftRouteType = 0u; + UINT16 routeFirstPhySectionId = 0u; + UINT16 trainEnteringRouteState = 0u; + UINT8 signalCrossState = 0u; + UINT8 rcWorkMode = 0U; /*rcģʽ*/ + rcWorkMode = GetLocalRcWorkMode(); + /* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(routeId); + if ((ROUTE_LEVEL_CBTC == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_LIECHE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /* ·״̬Ϊ + Ԥȿš + ӽš + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_YUXIAN_OPEN == devState) || + (ROUTE_STATE_NEAR_OPEN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) && + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepCBTCRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + routeReverseProperty = GetRouteReverseProperty(routeId); + airShaftRouteType = GetAirShaftRouteType(routeId); + if ((ROUTE_REVERSE_PROPERTY_YES == routeReverseProperty) || (ROUTE_TYPE_AIRSHAFT == airShaftRouteType)) + { /*·羮·Խ·ڷεռѹ״̬м*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + routeFirstPhySectionId = GetRouteFirstPhySectionId(routeId); + trainEnteringRouteState = GetTrainEnteringRouteState(routeId); + signalCrossState = GetSignalCrossState(GetRouteStartSignalId(routeId)); + if((devId == routeFirstPhySectionId) && ((CI_SUCCESS ==trainEnteringRouteState) && + (SIGNAL_CROSS_STATE_NO == signalCrossState))) + { + /*CBTC·гʻʱѹϢδ,ʱź*/ + reResult = CI_SUCCESS; + } + else + { + if (RC_WORK_MODE_CI == rcWorkMode) + { + if (devId == routeFirstPhySectionId) + { + reResult = CheckEngineerVehicleNear(routeId); /*Ƿǹ̳ӽĿѹ*/ + } + else + { + reResult = CI_ERROR; + } + + + if (CI_SUCCESS != reResult) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else if (RC_WORK_MODE_TIOC == rcWorkMode) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + /**/ + } + } + + } + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + } + } + /* ӷ(۳)*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (CI_ERROR == checkResult) + { + /*ʧܷؿؿ*/ + reResult = CI_ROUTE_RECOVER_ERR; + } + } + + /* */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = KeepCbtcRouteSectionErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + + /* */ + return reResult; +} + +/* +* ʽźű +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepBlocLTrainRouteErrProcess(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_KEEP_UT_SIGNAL_ERR_ZX; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + + /* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; + + /* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if ((ROUTE_LEVEL_BLOC == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_LIECHE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + Ԥȿš + ӽš + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_YUXIAN_OPEN == devState) || + (ROUTE_STATE_NEAR_OPEN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) && + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ӷ(۳)*/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ROUTE_RECOVER_ERR; + } + } + + /* */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteSectionErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* · */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + + /* */ + return reResult; +} + +/* +* CBTC۷·źű +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepCbtcReturnRouteErrProcess(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_KEEP_CT_RETURN_SIG_ERR_ZX; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; + + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + UINT16 routeFirstPhySectionId = 0u; + UINT8 trainEnteringRouteState =0u; + UINT8 signalCrossState = 0u; + UINT8 rcWorkMode = 0U; /*rcģʽ*/ + rcWorkMode = GetLocalRcWorkMode(); + devState = GetRouteLevel(routeId); + if (ROUTE_LEVEL_CBTC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ǡ۷·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_RETURN == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + Ԥȿš + ӽš + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_YUXIAN_OPEN == devState) || + (ROUTE_STATE_NEAR_OPEN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) && + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ռ״̬С*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + if (RC_WORK_MODE_TIOC == rcWorkMode) + { + checkResult = KeepCbtcReturnRouteSecOccCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else if(RC_WORK_MODE_CI == rcWorkMode) + { + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + routeFirstPhySectionId = GetRouteFirstPhySectionId(routeId); + trainEnteringRouteState = GetTrainEnteringRouteState(routeId); + signalCrossState = GetSignalCrossState(GetRouteStartSignalId(routeId)); + if ((devId == routeFirstPhySectionId) && ((CI_SUCCESS == trainEnteringRouteState) && + (SIGNAL_CROSS_STATE_NO == signalCrossState))) + { + /*CBTC۷·гʻʱѹϢδ,ʱź*/ + reResult = CI_SUCCESS; + } + else + { + if (devId == routeFirstPhySectionId) + { + reResult = CheckEngineerVehicleNear(routeId); /*Ƿǹ̳ӽĿѹ*/ + } + else + { + reResult = CI_ERROR; + } + + if (CI_SUCCESS != reResult) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + else + { + ; + } + + } + + } + } + else + { + reResult = CI_ERROR;/*ģʽ󷵻ʧ*/ + } + + } + + /* ӷ(۳)*/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ROUTE_RECOVER_ERR; + } + } + + /* */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = KeepCbtcRouteSectionErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* · */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + /* ͨ */ + reResult = checkResult; + } + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + + /* */ + return reResult; +} + +/* +* ʽ۷·źű +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepBlocReturnRouteErrProcess(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_KEEP_UT_RETURN_SIG_ERR_ZX; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + + /* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; + + /* ߼ */ + + /* ·ලģʽΪʽ*/ + + devState = GetRouteLevel(routeId); + if ((ROUTE_LEVEL_BLOC == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + + /* ·ǡ۷·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_RETURN == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + Ԥȿš + ӽš + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_YUXIAN_OPEN == devState) || + (ROUTE_STATE_NEAR_OPEN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag) && + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepBlocReturnSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ӷ(۳)*/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ROUTE_RECOVER_ERR; + } + } + + /* */ + if ((CI_ROUTE_RECOVER_ERR == reResult) || (CI_SUCCESS == reResult)) + { + checkResult = OpenBlocRouteSectionErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* · */ + if ((CI_ROUTE_RECOVER_ERR == reResult) || (CI_SUCCESS == reResult)) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + /* ͨ */ + reResult = checkResult; + } + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + + /* */ + return reResult; +} + +/* +* г·ź߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenLTrainRouteErrP(const UINT16 routeId, const UINT8 checkStep) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_OPEN_L_ERR_CLD; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 checkResult = CI_ERROR; + UINT8 reResult = CI_ERROR; + + /* */ + /*ȡ˽*/ + if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) || + (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + + + + + if (CI_SUCCESS == reResult) + { + devId = routeId; + devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId), GetSystemParaRouteOpenSigCyc()); + if (CI_TIME_OUT == devState) + { /*ѡųʱ*/ + reResult = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } + + + /*ź*/ + if (CI_SUCCESS == reResult) + { + if (OPEN_CHECK_STEP_OPEN == checkStep) + { + checkResult = OpenLTrainRouteSignalCheck(routeId, functionId, sendLevel); + } + else if (OPEN_CHECK_STEP_RECOVER == checkStep) + { + checkResult = RecoverLTrainRouteSignalCheck(routeId); + } + else + { + /* ʧܷ */ + checkResult = CI_ERROR; + } + + if (CI_ERROR == checkResult) + { + reResult = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } + + /**/ + if ((reResult == CI_SUCCESS) && (CI_ERROR == OpenLTrainRouteSwitchCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + ; + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_SIGOPEN == checkResult) + {/*رҲΪϷ*/ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + else + { + ; + } + + /**/ + if (reResult == CI_SUCCESS) + { + checkResult = OpenLTrainRouteSectionErrCheck(routeId); + if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + +/* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /* · */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + + if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + return reResult; +} + +/* +* ŵ·ź߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenDTrainRouteErrP(const UINT16 routeId, const UINT8 checkStep) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_OPEN_D_ERR_CLD; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_ERROR; + UINT8 checkResult = CI_ERROR; /*·ղ20150616*/ + + /* */ + /*ȡ˽*/ + UINT8 zqxflag = 0u; + UINT8 zrjflag = 0u; + zqxflag = GetRouteZongQuXiaoFlag(routeId); + zrjflag = GetRouteZongRenJieFlag(routeId); + + if ((ROUTE_ZONGQUXIAO_SET_YES == zqxflag) || + (ROUTE_ZONGRENJIE_SET_YES == zrjflag)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + if (CI_SUCCESS == reResult) + { + devId = routeId; + devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId), GetSystemParaRouteOpenSigCyc()); + if (CI_TIME_OUT == devState) + { /*ѡųʱ*/ + reResult = CI_ERROR; + } + } + + /*ź*/ + if (CI_SUCCESS == reResult) + { + if (OPEN_CHECK_STEP_OPEN == checkStep) + { + checkResult = OpenLTrainRouteSignalCheck(routeId, functionId, sendLevel); + } + else if (OPEN_CHECK_STEP_RECOVER == checkStep) + { + checkResult = RecoverLTrainRouteSignalCheck(routeId); + } + else + { + /* ʧܷ */ + checkResult = CI_ERROR; + } + + if (CI_ERROR == checkResult) + { + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + /* Ƿ */ + reResult = OpenLTrainRouteSwitchCheck(routeId, functionId, sendLevel); + } + + /* ź */ + if (CI_SUCCESS == reResult) + {/*ȴղҲΪǺϷ*/ + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_SIGOPEN == checkResult) + {/*رҲΪϷ*/ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenDTrainRouteSectionErrCheck(routeId); + if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR)) + { + /* ͨ */ + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + + if ((checkResult == CI_ERROR) || (checkResult == CI_ROUTE_RECOVER_ERR)) + { + /* ͨ */ + reResult = checkResult; + } + } + + /*ղȷ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + return reResult; +} + +/* +* г·ź߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepLTrainRouteErrP(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_KEEP_L_ERR_CLD; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_ERROR; + UINT8 checkResult = CI_ERROR; /*ʱ*/ + UINT8 zqxflag = 0u; + UINT8 zrjflag = 0u; + + /* */ + /*ȡ˽*/ + zqxflag = GetRouteZongQuXiaoFlag(routeId); + zrjflag = GetRouteZongRenJieFlag(routeId); + if ((ROUTE_ZONGQUXIAO_SET_YES == zqxflag) || + (ROUTE_ZONGRENJIE_SET_YES == zrjflag)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + /*·״̬Ԥȿš򡾽ӽš*/ + if (CI_SUCCESS == reResult) + { + devId = routeId; + devState = GetRouteState(devId); + if ((ROUTE_STATE_YUXIAN_OPEN != devState) && + (ROUTE_STATE_NEAR_OPEN != devState)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ź*/ + if (CI_SUCCESS == reResult) + { + /* ź*/ + reResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + } + + /**/ + if (CI_SUCCESS == reResult) + { + /* */ + reResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + } + + /*źŻ*/ + if (CI_SUCCESS == reResult) + { + /* źŻ */ + reResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenLTrainRouteSectionErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* · */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OpenBlocRouteOverlapErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OtherCiValidErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /*ղ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + return reResult; +} + +/* +* ֵ·ź߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepDTrainRouteErrP(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_KEEP_D_ERR_CLD; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; + UINT8 checkResult = CI_ERROR; /*ʱ*/ + UINT8 zrjflag = 0u; + UINT8 zqxflag = 0u; + /* */ + /*ȡ˽*/ + zqxflag = GetRouteZongQuXiaoFlag(routeId); + zrjflag = GetRouteZongRenJieFlag(routeId); + if ((ROUTE_ZONGQUXIAO_SET_YES == zqxflag) || + (ROUTE_ZONGRENJIE_SET_YES == zrjflag)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·״̬Ԥȿš򡾽ӽš*/ + if (CI_SUCCESS == reResult) + { + devId = routeId; + devState = GetRouteState(devId); + if ((ROUTE_STATE_YUXIAN_OPEN != devState) && + (ROUTE_STATE_NEAR_OPEN != devState)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ź*/ + if (CI_SUCCESS == reResult) + { + /* ʧܷ */ + reResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + } + + /**/ + if (CI_SUCCESS == reResult) + { + /* ʧܷ */ + reResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + } + + /*źŻ*/ + if (CI_SUCCESS == reResult) + { + /* ʧܷ */ + reResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /*·μ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = KeepDTrainRouteSectionErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* SPKS */ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteIntruSecVainSPKSErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /*ղ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = RouteRelayZhaoChaErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + return reResult; +} + +/* +* SPKSPSD۳ָ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 RecoverOpenRouteCheck(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 routeLevel = 0u; /*·ල*/ + UINT8 errType = CI_ERROR;/*ʧʱĴ*/ + + routeType = GetRouteType(routeId); /*ȡ·*/ + routeLevel = GetRouteLevel(routeId); /*ȡ·ල*/ + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + errType = OpenCbtcLTrainRouteErrProcess(routeId, OPEN_CHECK_STEP_RECOVER); + } + else + { /*ʽ*/ + errType = OpenBlocLTrainRouteErrProcess(routeId); + } + } + else if (ROUTE_TYPE_RETURN == routeType) + { /*۷·*/ + if (ROUTE_LEVEL_CBTC == routeLevel) + { /*CBTC*/ + errType = OpenCbtcReturnRouteErrProcess(routeId, OPEN_CHECK_STEP_RECOVER); + } + else + { /*ʽ*/ + errType = OpenBlocReturnRouteErrProcess(routeId); + } + } + else + {/**/ + errType = CI_ERROR; + } + + return errType; +} + +/* +* SPKSPSD۳ָ飬 +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 RecoverOpenRouteCheckCLD(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 errType = CI_ERROR;/*ʧʱĴ*/ + UINT8 jkjRelayValidFlag = 0u; /*ʼӦ̵̼Ч״̬*/ + UINT16 jkjRelayId = GetJkjRelayId(); + jkjRelayValidFlag = GetCiJkjFlag(); + routeType = GetRouteType(routeId); /*ȡ·*/ + if ((jkjRelayId > 0u) && (JKJ_REYLAY_VALID == jkjRelayValidFlag)) + {/*Ӧ̵̼Ч״̬,źؿ*/ + errType = CI_ERROR; + } + else if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + errType = OpenLTrainRouteErrP(routeId, OPEN_CHECK_STEP_RECOVER); /*г·*/ + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + + errType = OpenDTrainRouteErrP(routeId, OPEN_CHECK_STEP_RECOVER); /*ŵ·*/ + } + else + { /*·ʹ*/ + errType = CI_ERROR; + } + return errType; +} + + +/* +* +* ˵ UINT16 routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OtherCiValidErrCheck(UINT16 const routeId) +{ + /*·ȼ*/ + UINT8 const routeLevel = GetRouteLevel(routeId); + + /*ESB*/ + UINT8 checkSum = 0u; + RouteOtherCheckStruct *dataOtherCiDevBuf = NULL; + RouteOtherCheckStruct *tmpOtherCiDevInfo = NULL; + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 ret = CI_SUCCESS; + + /*·ʼźŻPSD*/ + UINT16 rtStartSigId = 0u;/*·ʼźŻID*/ + UINT8 psdSum = 0u;/*·ʼźŻPSD*/ + UINT16 *psdIdBuf = NULL;/*·ʼźŻPSD ID*/ + UINT16 j = 0u;/*·ʼźŻPSD ID±*/ + UINT8 toOpenCheckFlag = 0u;/*ָؿźŵ־*/ + UINT8 otherResult = 0u;/*ֵ*/ + UINT8 cFuncSwitchSpks = 0U; /*SPKSźؿ·𿪹*/ + + if (routeLevel == ROUTE_LEVEL_BLOC) + { + checkSum = GetRouteBlocOtherCiSum(routeId); + dataOtherCiDevBuf = GetRouteBlocOtherCiBuf(routeId); + } + else if (routeLevel == ROUTE_LEVEL_CBTC) + { + checkSum = GetRouteCbtcOtherCiSum(routeId); + dataOtherCiDevBuf = GetRouteCbtcOtherCiBuf(routeId); + } + else + { + checkSum = 0u; + dataOtherCiDevBuf = NULL; + + } + + /* ʼ */ + if ((0u != checkSum) && (NULL != dataOtherCiDevBuf)) + { + rtStartSigId = GetRouteStartSignalId(routeId);/*ý·ʼźŻ*/ + psdSum = GetSignalRelatedPsdSum(rtStartSigId);/*ý·ʼźŻPSD*/ + psdIdBuf = GetSignalRelatedPsdBuf(rtStartSigId);/*ý·ʼźŻPSD ID*/ + + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + tmpOtherCiDevInfo = &dataOtherCiDevBuf[i]; + + toOpenCheckFlag = 0u;/*ĬΪָؿ*/ + /*жϼΪSPKSDZźŻPSD*/ + if (CI_DEVICE_TYPE_SPKS == tmpOtherCiDevInfo->DevType) + { + cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS); + if ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == routeLevel))) + { + /*SPKSźؿ·𿪹ش򿪻򣨹رҽ·ΪCBTC*/ + toOpenCheckFlag = 1U; + } + else + { + toOpenCheckFlag = 0U; + } + } + else if (CI_DEVICE_TYPE_PSD == tmpOtherCiDevInfo->DevType) + { + if ((NULL != psdIdBuf) && (0u < psdSum)) + { + for (j = 0u;j < psdSum;j++) + { + if (psdIdBuf[j] == tmpOtherCiDevInfo->DevId) + { + toOpenCheckFlag = 1u; + break; + } + } + } + } + else + { + toOpenCheckFlag = 0u; + } + + /*ָм*/ + otherResult = OtherCiDevStatusCheck(routeId, tmpOtherCiDevInfo, &devId, &devState); + if ((otherResult == CI_ERROR) || (otherResult == CI_ROUTE_RECOVER_ERR)) + { + if (1u == toOpenCheckFlag) + { + if (CI_SUCCESS == ret) + { + ret = CI_ROUTE_RECOVER_ERR; + } + } + else + { + ret = CI_ERROR; + debug_infor_printf((const)"\n OtherCiValidErrCheck failed, CurCycle:%d, routeId:%d, DevType:%d, DevId:%d, DevStatus:%d\n", + Get2oo2CurCycleNum(),routeId, + tmpOtherCiDevInfo->DevType,tmpOtherCiDevInfo->DevId,tmpOtherCiDevInfo->DevStatus); + break; + } + } + } + } + + return ret; +} + +/* +* ·η +* ˵ UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 RouteSecFLockErrCheck(UINT16 const routeId) +{ + /* ·*/ + UINT8 const checkSum = GetRoutePhysicalSectionSum(routeId); + RoutePhysicalSectionStruct* const dataIdBuf = GetRouteSectionData(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 ret = CI_SUCCESS; + UINT8 fLockType = PHY_SEC_FLOCK_TYPE_NONE;/*ηͱ*/ + UINT8 cRouteLevel = ROUTE_LEVEL_BLOC; /*·*/ + UINT8 cFuncSwitchSpks = 0U; /*SPKSźؿ·𿪹*/ + + if (0u == checkSum) + { + /*ݴ*/ + ret = CI_ERROR; + } + else + { + /*ʼ*/ + for (i = 0u; ((i < checkSum) && (CI_ERROR != ret)); i++) + { + devId = dataIdBuf[i].PhysicalSectionId; + devState = GetPhySecFLockState(devId); + + /* ״̬δ״̬Ϊʧ */ + if (PHYSICAL_SECTION_FLOCK_NO == devState) + { + /**/ + } + else if (PHYSICAL_SECTION_FLOCK_YES ==devState ) + { + fLockType = GetPhySecFLockType(devId);/*η*/ + + if (PHY_SEC_FLOCK_TYPE_SPKS == fLockType) + { + if (CI_ERROR != ret) + { + cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS); + cRouteLevel = GetRouteLevel(routeId); + if ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel))) + { + /*SPKSźؿ·𿪹ش򿪻򣨹رҽ·ΪCBTC*/ + ret = CI_ROUTE_RECOVER_ERR; + } + else + { + ret = CI_ERROR; + } + } + else + { + ; + } + } + else + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + } + } + + /*ȫͨ*/ + return ret; +} + +/* +* η״̬ЧԼ +* ˵ UINT16 const overlapId, OverlapID +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OverlapAllSecFLockValidErrCheck(UINT16 const overlapId) +{ + /* overlap */ + UINT8 const checkSum = GetOverlapPhySecSum(overlapId); + UINT16* const dataIdBuf = GetOverlapPhySecIdBuf(overlapId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 ret = CI_SUCCESS; + + UINT8 fLockType = PHY_SEC_FLOCK_TYPE_NONE;/*ηͱ*/ + UINT8 cRouteLevel = ROUTE_LEVEL_BLOC; /*·*/ + UINT8 cFuncSwitchSpks = 0U; /*SPKSźؿ·𿪹*/ + UINT16 wBelongRouteId = 0U; /*·*/ + + if ((0U != overlapId) && (OVERLAP_SUM_MAX != overlapId)) + { + if (0u != checkSum) + { + /*ʼ*/ + + /* δ*/ + for (i = 0u; ((i < checkSum) && (CI_ERROR != ret)); i++) + { + devId = dataIdBuf[i]; + devState = GetPhySecFLockState(devId); + + /* ״̬δ״̬Ϊʧ */ + if (PHYSICAL_SECTION_FLOCK_NO == devState) + { + /**/ + } + else if (PHYSICAL_SECTION_FLOCK_YES == devState) + { + fLockType = GetPhySecFLockType(devId);/*η*/ + + if (PHY_SEC_FLOCK_TYPE_SPKS == fLockType) + { + wBelongRouteId = GetOverlapBelongRouteId(overlapId); + if ((CI_ERROR != ret) && (CI_ERROR != wBelongRouteId)) + { + cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS); + cRouteLevel = GetRouteLevel(wBelongRouteId); + if ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel))) + { + /*SPKSźؿ·𿪹ش򿪻򣨹رҽ·ΪCBTC*/ + ret = CI_ROUTE_RECOVER_ERR; + } + else + { + ret = CI_ERROR; + } + } + else + { + ; + } + } + else + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + } + } + else + { + ; + } + } + else + { + ret = CI_ERROR; /*δ*/ + } + + return ret; +} + +/* +* ŵ· +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 KeepDTrainRouteSectionErrCheck(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_KEEP_D_SEC_ERR_CHECK_CLD; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /* ߼ */ + + /* ·ռ״̬С ֹͣмβ */ + devId = 0u; + devState = 0u; + checkResult = CheckDTrainKeepSigPhySecOccupy(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + +/*ʹĺRouteIntruSecVainSPKSErrCheck*/ +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + + /* ·δ */ + if (CI_SUCCESS == reResult) + { + checkResult = RouteSecFLockErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /* ؽ */ + return reResult; +} + +/* +* г·飬 +* ˵ +* const UINT16 routeId, ·ID +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenLTrainRouteSectionErrCheck(const UINT16 routeId) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /* ߼ */ + + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + /* ·ռ״̬С*/ + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + +/*ʹĺRouteIntruSecVainSPKSErrCheck*/ +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ·δ */ + if (CI_SUCCESS == reResult) + { + checkResult = RouteSecFLockErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* ؽ */ + return reResult; +} + +/* +* ʽ·źű +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenBlocRouteOverlapErrCheck(const UINT16 routeId) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 devStateType = 0u; /*豸״̬*/ + + /*·豸 */ + /*·*/ + UINT8 const overlapSum = GetRouteOverlapSum(routeId); + UINT16 const overlapId = GetRouteOverlapLockedId(routeId); + + UINT8 lineIdentity = CI_TRADITION_RAILWAY; + + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ*/ + + /* ߼ */ + + /*·*/ + if (overlapSum > 0u) + { + /*з·*/ + /*·Id>0 Ρ·IDڵǰ·*/ + devId = GetOverlapFirstPhySecId(overlapId); + devState = GetPhySecLockState(devId); + if ((overlapId > 0u) && (routeId == GetPhySecPLockBelongRouteId(devId))) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*зΡС*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OpenBlockOvlpAllSecOccuClrCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if(CI_TRADITION_RAILWAY == lineIdentity) + { + /*ελȷ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchPosCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + } + else + { + /* zt ɾش 2022-02-15 */ + } + + /* еδ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchFLockStateCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelProtSwiFLockStaCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ιλȷ*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelatedProtSwitchPosCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ιա򡾵ҷա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelatedProtSwitchLockCheck(overlapId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + if (CI_SUCCESS == reResult) + { + /*·״̬*/ + devId = 0u; + devState = 0u; + checkResult = OverlapInvSecAndConSwiCheckup(overlapId, &devId, &devState); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /*β*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + /*鱣β״̬*/ + devId = 0u; + devState = 0u; + checkResult = OverlapLateralDfnCheck(overlapId, &devId, &devState); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + + /*鱣Ч*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = SignalOverlapValidCheck(routeId, &devId, &devState); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + /* ·ΡδԾա*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecJumpLockStateCheck(overlapId,&devId,&devState); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + /*зΡδ*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + checkResult = OverlapAllSecFLockValidErrCheck(overlapId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /*з״̬*/ + if ((CI_SUCCESS == reResult) || (CI_ROUTE_RECOVER_ERR == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapFloodGateStateCheck(overlapId,&devId,&devStateType,&devState); + if (CI_ERROR == checkResult) + { + reResult = checkResult; + } + } + + } + else + { + /*޷·*/ + reResult = CI_SUCCESS; + } + + + /* ؽ */ + return reResult; +} + +/* +* ŵ· +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenDTrainRouteSectionErrCheck(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_OPEN_D_SEC_ERR_CHECK_CLD; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /* ߼ */ + /* ·ռ״̬С ֹͣмβ */ + checkResult = CheckDTrainRoutePhySecOccupy(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + +/*ʹĺRouteIntruSecVainSPKSErrCheck*/ +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·δ */ + if (CI_SUCCESS == reResult) + { + checkResult = RouteSecFLockErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + } + + /* ؽ */ + return reResult; +} + +/* +* ʽ·ź +* ˵ +* const UINT16 routeId, · +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenBlocRouteSectionErrCheck(const UINT16 routeId) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 chDsnFuncSwitch = 0U; /* ֱռùܿ */ + UINT8 chXianSuFuncSwitch = 0U; /*ģʽźſǷʱٿ*/ + + chDsnFuncSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH); + chXianSuFuncSwitch = GetCiFunctionSwitchConfig(FUNC_XIANSU_SWITCH); + + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + if (FUNC_SWITCH_ON != chDsnFuncSwitch) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + checkResult = RouteAllSecColOccuClearCheck(routeId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + checkResult = RouteFaultOccuCheck(routeId, &devId, &devState); + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ʹĺRouteIntruSecVainSPKSErrCheck*/ +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ·δ */ + if (CI_SUCCESS == reResult) + { + checkResult = RouteSecFLockErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + /*޴*/ + } + } + + /* ·δʱ */ + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == chXianSuFuncSwitch) + {/*ģʽźſǷʱٿش*/ + checkResult = RouteAllLgcSecXianSuCheck(routeId, &devId, &devState); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + /*޴*/ + } + } + else + { + /* ܿعر, */ + } + } + + /* ؽ */ + return reResult; +} + +/* +* Cbtc·źű +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 KeepCbtcRouteSectionErrCheck(const UINT16 routeId) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 startSignalId = 0u; + UINT8 functionId = EFUNC_KEEPROUTESECTIONERRCHECK; + UINT8 rcWorkMode = 0U; /*rcģʽ*/ + UINT8 signalCrossState = 0u; + UINT8 preLogDevState = 0u; /*֮ǰ߼ռ״̬*/ + UINT8 LogSecCurCtOrUtOcc = 0U; /*߼εǰռ״̬*/ + UINT8 cLocalCiType = 0U; /**/ + + rcWorkMode = GetLocalRcWorkMode(); + + /* ߼ */ + reResult = CI_SUCCESS; + cLocalCiType = GetLocalCiType(); + if (CI_TYPE_CLD != cLocalCiType) + { + /*dzΣCBTC߼*/ + if (RC_WORK_MODE_TIOC == rcWorkMode) + { + /*CBTC·ڷһ߼*/ + reResult = RouteCbtcFirstLgcSecCheck(routeId, &devId, &devState); + if (CI_SUCCESS == reResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else if (RC_WORK_MODE_CI == rcWorkMode) + {/*CI*/ + + /* ·ʼźŻδѹ ǣ·ⷽΡСڷһ߼Ρռá*/ + startSignalId = GetRouteStartSignalId(routeId); + devId = GetRouteInFirstLogSecId(routeId); + devState = GetLogSecCurOccupyState(devId); + signalCrossState = GetSignalCrossState(startSignalId); + LogSecCurCtOrUtOcc = GetLogSecCurCtOrUtOccupyState(devId); + preLogDevState = GetLogSecPreCtOrUtOccupyState(devId); + if ((SIGNAL_CROSS_STATE_NO == signalCrossState) + && (!((SECTION_OCCUPY_NO == devState) && (LOGICSECTION_OCCUPY_CT == preLogDevState))) + ) + { + /*޿ѹʱǣڷһ߼εǰС֮ǰCTռá˵Ѿһ߼ΣֻҪδһ߼Σȿѹ*/ + + if (LOGICSECTION_OCCUPY_UT != LogSecCurCtOrUtOcc) + { + /*ֻеΪCTռѹͿʱֹUT쳣ռѹ ͨ */ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; /*UTռѹ쳣*/ + } + } + else + { + reResult = CheckEngineerVehicleNear(routeId);/*Ƿǹ̳ӽĿѹԼгʵѹ*/ + } + } + else + { + reResult = CI_ERROR;/*ģʽ󷵻ʧ*/ + } + } + else + { + /*Σ·׷٣·ڷο*/ + reResult = CLDKeepOpenSecCheck(routeId, functionId, ESEND_LEVEL_ZERO); + } + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (CI_SUCCESS ==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } +/*ʹĺRouteIntruSecVainSPKSErrCheck*/ +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + +#endif + + /* ·δ */ + if (CI_SUCCESS == reResult) + { + checkResult = RouteSecFLockErrCheck(routeId); + + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /* ؽ */ + return reResult; +} + +/* +* Cbtc·źſ +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OpenCbtcRouteSectionErrCheck(const UINT16 routeId) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 startSignalId = 0u; + UINT8 functionId = EFUNC_OPENROUTESECTIONERRCHECK; + UINT8 rcWorkMode = 0U; + UINT8 cLocalCiType = 0U; /**/ + + rcWorkMode = GetLocalRcWorkMode(); + + /* ߼ */ + cLocalCiType = GetLocalCiType(); + if (CI_TYPE_CLD != cLocalCiType) + { + /*dzΣCBTC߼*/ + if (RC_WORK_MODE_TIOC == rcWorkMode) + { + /* ·ʼźŻδѹڷһ߼ΡС*/ + /*CBTC·ڷһ߼*/ + + reResult = RouteCbtcFirstLgcSecCheck(routeId, &devId, &devState); + if (CI_SUCCESS == reResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else if (RC_WORK_MODE_CI == rcWorkMode) + {/*CI*/ + + /* ·ʼźŻδѹڷһ߼ΡС*/ + startSignalId = GetRouteStartSignalId(routeId); + devId = GetRouteInFirstLogSecId(routeId); + devState = GetLogSecCurOccupyState(devId); + if ((GetSignalCrossState(startSignalId) == SIGNAL_CROSS_STATE_NO) && + (devState == SECTION_OCCUPY_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + reResult = CheckEngineerVehicleNear(routeId);/*Ƿǹ̳ӽĿѹ*/ + } + } + else + { + reResult = CI_ERROR;/*ģʽ󷵻ʧ*/ + } + } + else + { + /*Σ·׷٣·ڷο*/ + reResult = CLDKeepOpenSecCheck(routeId, functionId, ESEND_LEVEL_ZERO); + } + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + +/*ʹĺRouteIntruSecVainSPKSErrCheck*/ +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + +#if 0 + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·δ */ + if (checkResult == CI_SUCCESS) + { + checkResult = RouteSecFLockErrCheck(routeId); + if ((CI_ERROR == checkResult) || (CI_ROUTE_RECOVER_ERR == checkResult)) + { + reResult = checkResult; + } + else + { + ; + } + } + else + { + ; + } + + /* ؽ */ + return reResult; +} + +/* +* ָг·źŻ +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +*/ +static UINT8 RecoverLTrainRouteSignalCheck(const UINT16 routeId) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /*·źŻδ*/ + checkResult = RouteSignalFLockCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·ĵж*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /* ؽ */ + return reResult; +} + +/* ָʽ·źŻ */ +/* +* ʽ·źŻ +* ˵ +* const UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +*/ +static UINT8 RecoverBlocRouteSignalCheck(const UINT16 routeId) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + checkResult = RouteSignalFLockCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·ĵж*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /* ؽ */ + return reResult; +} + +/* ָ·SPKS */ +/* +* ·Ч +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS ޲ + CI_ROUTE_RECOVER_ERR:SPKSµޣǵSPKSָؿź +*/ +static UINT8 RouteIntruSecVainSPKSErrCheck(const UINT16 routeId) +{ + /* */ + UINT8 const checkSum = GetRouteIntrudePhySectionSum(routeId); + RouteIntrudePhySectionStruct* const dataIdBuf = GetRouteIntrudePhySectionData(routeId); + /* ֲʼ */ + UINT16 i = 0U, j = 0U; /* ѭ */ + UINT16 devId = 0U; + UINT8 devState = 0U; + UINT8 devFLockState = 0U; + UINT8 intruSwitchSum = 0U; + RouteConditionSwitchStruct* intruSwitchConStru = NULL; + UINT16 intruSwitchId = 0U; + UINT8 intruSwitchPos = 0U; + UINT8 devLockState = 0U; + UINT8 devJumpLockState = 0U; + UINT8 intruSwitchPosValid = CI_ERROR; + UINT8 reVal = CI_ERROR; + UINT8 fLockType = PHY_SEC_FLOCK_TYPE_NONE;/*ηͱ*/ + UINT8 checkFlockFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_CHECKFLOCK_FLAG); + UINT8 cFuncSwitchSpks = 0U; /*SPKSԶźؿǷ·𿪹*/ + UINT8 cRouteLevel = 0U; + UINT8 chPhySecLogLockState = 0U;/*߼״̬*/ + + /* ״̬ */ + if (NULL == dataIdBuf) + { + /*ָΪ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + reVal = CI_SUCCESS;/*Ƚֵóɹ޳޸ĺֵΪCI_ERRORCI_ROUTE_RECOVER_ERR*/ + cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS); + cRouteLevel = GetRouteLevel(routeId); + + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i].SectionId; + devState = GetPhySecCurMergeState(devId);/*ȡռ״̬*/ + devFLockState = GetPhySecFLockState(devId);/*ȡη״̬*/ + fLockType = GetPhySecFLockType(devId);/*ȡη*/ + devLockState = GetPhySecLockState(devId); + devJumpLockState = GetPhySecJumpLockState(devId); + chPhySecLogLockState = PhySecLogLockStateCheck(devId); + + + + /* Ƿռû*/ + if ((SECTION_OCCUPY_YES == devState) + || ((PHYSICAL_SECTION_FLOCK_YES == devFLockState) && (FUNC_SWITCH_ON != checkFlockFlag)) + || (PHYSICAL_SECTION_LOCK_NO != devLockState) + || (PHYSICAL_SECTION_JUMP_LOCK_YES == devJumpLockState) + || (LOG_SECTION_LOGLOCK_NO != chPhySecLogLockState)) + { + /*ռû*/ + intruSwitchSum = dataIdBuf[i].SwitchSum; + if (intruSwitchSum > 0u) + { + /*޵λü*/ + intruSwitchPosValid = CI_ERROR; + for (j = 0u; j < intruSwitchSum; j++) + { + intruSwitchConStru = &dataIdBuf[i].ConditionSwitchStru[j]; + intruSwitchId = intruSwitchConStru->SwitchId; + intruSwitchPos = GetSwitchCurPosition(intruSwitchId); + + if ((intruSwitchPos == intruSwitchConStru->SwitchPosition) || + (SWITCH_POSITION_SIKAI == intruSwitchPos) || (SWITCH_POSITION_MOVE == intruSwitchPos) + || (SWITCH_POSITION_JICHA == intruSwitchPos)) + { + intruSwitchPosValid = CI_ERROR; + } + else + { + /*δ*/ + intruSwitchPosValid = CI_SUCCESS; + break; + } + } + + if (CI_ERROR == intruSwitchPosValid) + { + /*в*/ + if ((PHYSICAL_SECTION_JUMP_LOCK_YES != devJumpLockState) && (PHYSICAL_SECTION_LOCK_NO == devLockState) && (SECTION_OCCUPY_YES != devState) + && (PHYSICAL_SECTION_FLOCK_YES == devFLockState) && (PHY_SEC_FLOCK_TYPE_SPKS == fLockType) && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState) + && ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel)))) + {/*δռҷSPKSµµķ(SPKSԶؿش򿪻رյ·ΪCBTC)SPKSָԶؿ*/ + reVal = CI_ROUTE_RECOVER_ERR; + } + else + {/*SPKS޳µ޳ijؿ*/ + reVal = CI_ERROR; + } + } + } + else + { + if ((PHYSICAL_SECTION_JUMP_LOCK_YES != devJumpLockState) && (PHYSICAL_SECTION_LOCK_NO == devLockState) && (SECTION_OCCUPY_YES != devState) + && (PHYSICAL_SECTION_FLOCK_YES == devFLockState) && (PHY_SEC_FLOCK_TYPE_SPKS == fLockType) && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState) + && ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel)))) + {/*δռҷSPKSµµķ(SPKSԶؿش򿪻رյ·ΪCBTC)SPKSָԶؿ*/ + reVal = CI_ROUTE_RECOVER_ERR; + } + else + {/*SPKS޳µ޳ijؿ*/ + reVal = CI_ERROR; + } + } + if (CI_ERROR == reVal) + {/*SPKS޳µ޳ijؿֱ˳жǷ + reVal = CI_ROUTE_RECOVER_ERR;ʱжǷ*/ + break; + } + } + + } + } + + /**/ + return reVal; +} + +/* +* ָ·ղ +* ˵ UINT16 const routeId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* RELAY_STATE_WAITE +*/ +static UINT8 RouteRelayZhaoChaErrCheck(UINT16 const routeId) +{ +/* ֲʼ */ + UINT16 relayId = 0U; + UINT8 relayState = 0U; + UINT8 zcPhySecSum = 0U; /*ղĿ*/ + UINT16* pZcPhySecIdBuf = NULL; /*ղID*/ + UINT8 ii = 0U; + UINT16 thisRealyId = 0U; + UINT8 thisRelayState = 0U; + UINT8 routeState = 0U; + UINT8 retVal = CI_ERROR; /*ֵ*/ + UINT16 pDevId = 0U; + UINT8 pDevState = 0U; + UINT8 chRouteLevel = 0U; + UINT8 chErrTemp = 0U; + + /* Զղ */ + zcPhySecSum = GetRouteThatZhaoChaPhySecSum(routeId); /*ȡղĿ*/ + pZcPhySecIdBuf = GetRouteThatZhaoChaPhySecIdBuf(routeId); /*ȡղID*/ + /*·ලȷ*/ + chRouteLevel = GetRouteLevel(routeId); + + if (NULL == pZcPhySecIdBuf) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + + for (ii = 0u; ii < zcPhySecSum; ii++) + { + retVal = RoutePhySecZhaoChaErrCheck(routeId,pZcPhySecIdBuf[ii]); + if (CI_ERROR == retVal) + { + break; + } + else if(CI_ROUTE_RECOVER_ERR == retVal) /*YF00083-1013,һֹΣһǰ飬һδں鸲ǵretValֵ*/ + { + chErrTemp++; /*һSPKSͼһ*/ + } + else + { + ; /**/ + } + + if (0U < chErrTemp) + { + retVal = CI_ROUTE_RECOVER_ERR; /*ֹһSPKS͸ֵֵΪSPKS*/ + } + } + } + + if ((CI_SUCCESS == retVal) || (CI_ROUTE_RECOVER_ERR == retVal)) + {/*ղμͨ,鱾ղ̵*/ + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + thisRealyId = GetRouteThisZhaoChaRelayId(routeId); /*ģʽղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + thisRealyId = GetRouteCbtcThisZhaoChaRelayId(routeId);/*CBTCģʽղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + + thisRelayState = GetRelayCollState(thisRealyId); /*ȡָID̵״̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + if (thisRealyId > 0u) + {/*ڱղ̵*/ + if ((ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState)) + { + /*·״̬쳣Ԥգӽ쳣ӽţԤȿţ + жϱղ״̬*/ + if(RELAY_STATE_UP == thisRelayState) + { + retVal = CI_ERROR; + } + } + else if (ROUTE_STATE_FIRST_LOCK == routeState) + { + if(RELAY_STATE_UP == thisRelayState) + { + /*ȴصȴ־*/ + retVal = RELAY_STATE_WAITE; + } + } + else + { + /*·״̬Ϊֵʱ*/ + } + } + + } + + if ((CI_SUCCESS == retVal) || (CI_ROUTE_RECOVER_ERR == retVal)) + {/*ղ̵ͨԶղ̵*/ + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + relayId = GetRouteThatZhaoChaRelayId(routeId); /*ģʽԶղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + relayId = GetRouteCbtcThatZhaoChaRelayId(routeId);/*CBTCģʽԶղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + + if(0u != relayId) + {/*ڶԶղ̵*/ + + relayState = GetRelayCollState(relayId); + + /* ղ*/ + if (RELAY_STATE_UP == relayState) + { + /*ͨ*/ + } + else + { + retVal = CI_ERROR; + } + } + } + + return retVal; + +} + +/* +* ָ·ղ +* ˵ UINT16 const routeId ·κ +* UINT16 const phySecId κ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RoutePhySecZhaoChaErrCheck(UINT16 const routeId ,UINT16 const phySecId) +{ + UINT8 secFlockState = 0u; /*η״̬*/ + UINT8 secLockState = 0u; /*״̬*/ + UINT8 secLockedDirection = 0u; /*շ*/ + UINT8 routeDirection = 0u; /*·*/ + UINT8 retVal = CI_ERROR; /*ֵ*/ + UINT8 fLockType = PHY_SEC_FLOCK_TYPE_NONE; /*ηͱ*/ + UINT8 phyBelongCi = 0u; /**/ + UINT8 commState = 0u; /*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 localCi = GetSystemParaLocalCiId(); /**/ + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + UINT8 cFuncSwitchSpks = 0U; /*SPKSźԶؿأ0x55·0xaa*/ + UINT8 cRouteLevel = 0U; + + if ((0U == routeId ) || (0U == phySecId)) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + + phyBelongCi = GetPhySecBelongCiId(phySecId);/*ȡ*/ + + routeDirection = GetRouteDirection(routeId); /*ȡ·*/ + + commState = GetLocalCiAndOtherCiTransSta(phyBelongCi);/*ͨͨ״̬*/ + + if ((localCi!=phyBelongCi) && (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*źŻ뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣԲźŻ״̬*/ + retVal = CI_SUCCESS; + } + else + { + secFlockState = GetPhySecFLockState(phySecId); /*ȡη״̬*/ + if(PHYSICAL_SECTION_FLOCK_NO == secFlockState) + {/*η״̬:δ*/ + + secLockState = GetPhySecLockState(phySecId); /*ȡ״̬*/ + + if(PHYSICAL_SECTION_LOCK_NO == secLockState) + { + /*״̬:δ ղμͨ*/ + } + else if((PHYSICAL_SECTION_LOCK_PROTECT == secLockState) || (PHYSICAL_SECTION_LOCK_NORMAL == secLockState) + || (PHYSICAL_SECTION_LOCK_EXCEPT == secLockState) || (PHYSICAL_SECTION_LOCK_DELAY == secLockState) + || (PHYSICAL_SECTION_LOCK_FAULTDELAY == secLockState)) + {/*״̬: 쳣 ʱ ʱ·ʱʱղָʾͻȻƵ*/ + secLockedDirection = GetPhySecLockDirection(phySecId); /*ȡշ*/ + if(routeDirection == secLockedDirection) + { + /*շͽ·һ£ͨ*/ + } + else + { + /*շͽ·һ£ʧ*/ + retVal = CI_ERROR; + } + } + else + { /*״̬:Ƿ״̬ ʧ*/ + retVal = CI_ERROR; + } + } + else if (PHYSICAL_SECTION_FLOCK_YES == secFlockState) + { + fLockType = GetPhySecFLockType(phySecId);/*η*/ + cFuncSwitchSpks = GetCiFunctionSwitchConfig(FUNC_REPEATE_OPEN_CHECK_SPKS); + cRouteLevel = GetRouteLevel(routeId); + if ((PHY_SEC_FLOCK_TYPE_SPKS == fLockType) && ((FUNC_SWITCH_ON == cFuncSwitchSpks) || ((FUNC_SWITCH_OFF == cFuncSwitchSpks) && (ROUTE_LEVEL_CBTC == cRouteLevel)))) + { + retVal = CI_ROUTE_RECOVER_ERR; /* ״̬SPKSµķSPKSԶؿش򿪻رյ·ΪCBTCԻָؿ*/ + } + else + { + retVal = CI_ERROR; + } + } + else + {/*η״̬: ʧ*/ + retVal = CI_ERROR; + } + } + } + + return retVal; +} diff --git a/TSCP/src/APP/ciapp/LogicManage/RouteRecoverManage.h b/TSCP/src/APP/ciapp/LogicManage/RouteRecoverManage.h new file mode 100644 index 0000000..794f332 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicManage/RouteRecoverManage.h @@ -0,0 +1,179 @@ +/******************************************************** +* +* RouteRecoverManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2017-01-04 +* ߣ +* ʵPSDSPKS۳ָؿźŵĹܡģҪɿźԼźűֽ׶ε飬е߼dzơ +* +* ʹע⣺ +* ޸ļ¼ +* 2017-01-04 ½ +* +********************************************************/ +#ifndef _ROUTE_RECOVER_MANAGE_H +#define _ROUTE_RECOVER_MANAGE_H + +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" + +#define OPEN_CHECK_STEP_OPEN 0x55U +#define OPEN_CHECK_STEP_RECOVER 0xaaU + +/* +* CBTC·߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenCbtcLTrainRouteErrProcess(const UINT16 routeId, const UINT8 checkStep); + +/* +* ŵʽ·߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenBlocLTrainRouteErrProcess(const UINT16 routeId); + +/* +* CBTC۷·߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹCI_ROUTE_RECOVER_ERR +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenCbtcReturnRouteErrProcess(const UINT16 routeId, const UINT8 checkStep); + +/* +* ŵʽ۷·ź +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenBlocReturnRouteErrProcess(const UINT16 routeId); + +/* +* CBTCгźű +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepCbtcLTrainRouteErrProcess(const UINT16 routeId); + +/* +* ʽźű +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepBlocLTrainRouteErrProcess(const UINT16 routeId); + +/* +* CBTC۷·źű +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepCbtcReturnRouteErrProcess(const UINT16 routeId); + +/* +* ʽ۷·źű +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepBlocReturnRouteErrProcess(const UINT16 routeId); + +/* +* г·ź߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenLTrainRouteErrP(const UINT16 routeId, const UINT8 checkStep); + +/* +* ŵ·ź߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 OpenDTrainRouteErrP(const UINT16 routeId, const UINT8 checkStep); + +/* +* г·ź߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepLTrainRouteErrP(const UINT16 routeId); + +/* +* ֵ·ź߼ +* ˵ +UINT16 const routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +UINT8 KeepDTrainRouteErrP(const UINT16 routeId); + +/* +* SPKSPSD۳ָ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 RecoverOpenRouteCheck(const UINT16 routeId); + +/* +* SPKSPSD۳ָ飬 +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 RecoverOpenRouteCheckCLD(const UINT16 routeId); + +/* +* ָ·ղ +* ˵ UINT16 const routeId ·κ +* UINT16 const phySecId κ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RoutePhySecZhaoChaErrCheck(UINT16 const routeId, UINT16 const phySecId); +#endif diff --git a/TSCP/src/APP/ciapp/LogicManage/TradInterlockLogicManage.c b/TSCP/src/APP/ciapp/LogicManage/TradInterlockLogicManage.c new file mode 100644 index 0000000..54a4d7f --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicManage/TradInterlockLogicManage.c @@ -0,0 +1,7345 @@ +/******************************************************** +* +* TradInterlockLogicManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-10 +* ߣ +* ߼ +* ޸ļ¼ +* +********************************************************/ + +#include "TradInterlockLogicManage.h" +#include "RouteRecoverManage.h" + + +void ClosSigByGrgdoorCloseCmd(UINT16 grgdoorId); + +/* +* ߼ +* ˵ void +* ֵ +*/ +void TradInterlockLogicMainProc(void) +{ + /*Ӧ̹ܴ*/ + JKJRelayLogicProcess(); + + /*·߼*/ + LongRouteLogicProcess(); + + /*·߼*/ + RouteLogicProcess(); + + /*ǽ·߼*/ + NonRouteLogicProcess(); + + /* ߼ */ + GargeDoorLogicProcess(); + + /*߼*/ + UnlockSwitchLogicManage(); +} + +/* +* Ӧ̹ܴ +* ˵ void +* ֵ +*/ +void JKJRelayLogicProcess(void) +{ + UINT16 wJkjRelayId = 0u; + UINT8 JkjRelayState = CI_ERROR; + UINT32 JkjRelayCycNum = 0u; + UINT32 JkjValidCycNum = 0u; + UINT32 curCycNum = 0u; + UINT8 checkRes = CI_TIME_OUT; + UINT8 tmpRet =CI_ERROR; + + wJkjRelayId = GetJkjRelayId(); + JkjRelayState = GetRelayCollState(wJkjRelayId); /*JKJӦ̵̼ɼ״̬*/ + JkjRelayCycNum = GetRelayStateUpdateCycNum(wJkjRelayId); /*JKJӦ̵̼״̬*/ + JkjValidCycNum = GetJkjRelayValidCycNum(); /*JKJӦ״̬Ч*/ + + + + if ((wJkjRelayId > 0u) && (RELAY_STATE_DOWN == JkjRelayState)) + { + curCycNum = Get2oo2CurCycleNum(); + if (0u == JkjRelayCycNum) + {/*δʱʼ*/ + tmpRet = SetRelayStateUpdateCycNum(wJkjRelayId,curCycNum); + if (CI_ERROR == tmpRet) + { + /**/ + } + } + checkRes = SystemOverTimeCheck(JkjRelayCycNum,JKJ_REYLAY_VALID_CYCLE_NUM); + if (CI_TIME_OUT == checkRes) + { /*ӦЧ*/ + SetCiJkjFlag(JKJ_REYLAY_VALID); /*JKJӦЧ־ΪЧ*/ + if (0u == JkjValidCycNum) /*֮ǰûӦЧʼ*/ + { + SetJkjRelayValidCycNum(curCycNum); /*JKJӦЧ*/ + } + } + } + else if ((wJkjRelayId > 0u) && (RELAY_STATE_UP == JkjRelayState)) + { + tmpRet = SetRelayStateUpdateCycNum(wJkjRelayId, 0u); /*JKJ̵Чʼں*/ + if (CI_ERROR == tmpRet) + { + /**/ + } + /*ӦЧ*/ + SetCiJkjFlag(JKJ_REYLAY_INVALID); /*JKJӦ̵̼Ч־ΪЧ*/ + + SetJkjRelayValidCycNum(0u); /*JKJӦЧ*/ + } + else + { + /*ӦЧ*/ + SetCiJkjFlag(JKJ_REYLAY_INVALID); /*JKJӦ̵̼Ч־ΪЧ*/ + SetJkjRelayValidCycNum(0u); /*JKJӦ̵̼Ч*/ + } +} + +/* +* ǽ·߼ +* ˵ void +* ֵ +*/ +void NonRouteLogicProcess(void) +{ + UINT8 nonRouteState = 0u; /*ǽ·״̬*/ + + UINT8 i = 0u; + + for (;iNonRouteId == 0u) + { + continue; + } + + nonRouteState = pNonRoute->NonRouteState; /*ȡǽ·״̬*/ + + if (NONROUTE_STATE_IDLE == nonRouteState) + { /*ǽ·*/ + ; + } + else if (NONROUTE_STATE_XUANPAI == nonRouteState) + { /*ǽ·ѡ*/ + + NonRouteXuanPaiDeal(pNonRoute->NonRouteId); /*ǽ·ѡŴ*/ + } + else if (NONROUTE_STATE_LOCK == nonRouteState) + { /*ǽ·*/ + + NonRouteLockDeal(pNonRoute->NonRouteId); /*ǽ·մ*/ + } + else if (NONROUTE_STATE_LOCKERR == nonRouteState) + { /*ǽ·*/ + + } + else if (NONROUTE_STATE_OPEN == nonRouteState) + { /*ǽ·*/ + + NonRouteOpenDeal(pNonRoute->NonRouteId); /*ǽ·Ŵ*/ + } + else if (NONROUTE_STATE_DELAY_UNLOCK == nonRouteState) + { /*ǽ·ʱ׶*/ + + NonRouteDelayUnlockDeal(pNonRoute->NonRouteId); /*ǽ·ʱ߼*/ + } + else if (NONROUTE_STATE_FAULTDELAY_UNLOCK == nonRouteState) + { /*ʱ*/ + + NonRouteFaultDelayUnlockDeal(pNonRoute->NonRouteId); /*ǽ·ʱ߼*/ + } + else + { + /*·ݴ*/ + } + + + /*ȡǽ·*/ + if ((NONROUTE_CANCEL_FLAG_YES ==pNonRoute->CancelFlag) + && (NONROUTE_CANCEL_FLAG_NO ==pNonRoute->HaveCancelFlag)) + { + NonRouteCancelDeal(pNonRoute->NonRouteId); /*ǽ·ȡ*/ + } + } +} + + +/* +* ǽ·ѡŹ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ void +*/ +void NonRouteXuanPaiDeal(UINT8 nonRouteId) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + if (CI_SUCCESS == LockNonRouteP(nonRouteId)) + { /*ճɹ*/ + + if (CI_SUCCESS == CheckNonRouteSwitchPosRight(nonRouteId,0u,0u)) + { /*·λȷ*/ + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_LOCK); /*÷ǽ·Ϊ*/ + } + else + { /*δλ*/ + + /*ǽ·*/ + if (CI_ERROR == NonRouteLockDrvSwitchDeal(nonRouteId)) + { + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_IDLE); /*÷ǽ·Ϊ*/ + } + + } + } + else + { /*·ʧ*/ + + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_IDLE); /*÷ǽ·Ϊ*/ + } +} + + +/* +* ǽ·չ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ void +*/ +void NonRouteLockDeal(UINT8 nonRouteId) +{ + if (CI_SUCCESS == CheckNonRouteSignalAllOpen(nonRouteId)) + { /*źŶ*/ + + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_OPEN); /*÷ǽ·*/ + + NonRouteOpenDeal(nonRouteId); /*ǽ·źſŴ*/ + } + else + { /*źŹر*/ + + if (CI_SUCCESS == OpenNonRouteP(nonRouteId)) + { /*ųɹ*/ + + DriveNonRouteSignalOpen(nonRouteId); /*ǽ·źſ*/ + } + else + { /*ʧ*/ + + DriveNonRouteSignalClose(nonRouteId); /*ǽ·źŹر*/ + + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_LOCKERR); /*÷ǽ·쳣*/ + + } + } +} + + +/* +* ǽ·Ź +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ void +*/ +void NonRouteOpenDeal(UINT8 nonRouteId) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + if (pNonRoute !=NULL) + { + + if (CI_SUCCESS == CheckNonRouteSignalAllOpen(nonRouteId)) + { /*źŶ*/ + + if (CI_SUCCESS == KeepOpenNonRouteP(nonRouteId)) + { /*ֿųɹ*/ + + DriveNonRouteSignalOpen(nonRouteId); /*ǽ·źſ*/ + } + else + { /*ʧ*/ + + DriveNonRouteSignalClose(nonRouteId); /*ǽ·źŹر*/ + + SetNonRouteStateDeal(pNonRoute->NonRouteId,NONROUTE_STATE_LOCKERR); /*÷ǽ·쳣*/ + } + } + else + { /*źŹر*/ + + DriveNonRouteSignalClose(nonRouteId); /*ǽ·źŹر*/ + + SetNonRouteStateDeal(pNonRoute->NonRouteId,NONROUTE_STATE_LOCKERR); /*÷ǽ·쳣*/ + } + } +} + + +/* +* ǽ·ʱ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ void +*/ +void NonRouteDelayUnlockDeal(UINT8 nonRouteId) +{ + UINT32 delayStartCycNum = 0u; /*ʱʼں*/ + UINT32 delayTotalCycSum = 0u; /*ʱ*/ + + + /*ǽ·źŹر*/ + DriveNonRouteSignalClose(nonRouteId); + + delayStartCycNum = GetNonRouteDelayUnlockStartCyc(nonRouteId); /*ȡǽ·ʱʼ*/ + delayTotalCycSum = GetSystemParaNonRDelayUnlockCnt(); /*ȡǽ·ʱ*/ + + if ((0u == Get2oo2CurCycleNum()) || (delayTotalCycSum == 0u) || (delayStartCycNum == 0u)) + { /*ʱʱЧ*/ + + return; + } + + if (CI_SUCCESS == CancelNonRouteP(nonRouteId)) + { /*ȡɹ*/ + + if(CI_TIME_OUT == SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum)) + { /*ʱѵ*/ + + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_IDLE); /*÷ǽ·Ϊ*/ + } + else + { + /*ʱδδ*/ + } + } + else + { /*ȡʧ*/ + + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_LOCKERR); /*÷ǽ·쳣*/ + } +} + + +/* +* ǽ·ʱ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ void +*/ +void NonRouteFaultDelayUnlockDeal(UINT8 nonRouteId) +{ + UINT32 delayStartCycNum = 0u; /*ʱʼں*/ + UINT32 delayTotalCycSum = 0u; /*ʱ*/ + + + /*ǽ·źŹر*/ + DriveNonRouteSignalClose(nonRouteId); + + delayStartCycNum = GetNonRouteDelayUnlockStartCyc(nonRouteId); /*ȡǽ·ʱʼ*/ + delayTotalCycSum = GetSystemParaNonRDelayUnlockCnt(); /*ȡǽ·ʱ*/ + + if ((0u == Get2oo2CurCycleNum()) || (delayTotalCycSum == 0u) || (delayStartCycNum == 0u)) + { /*ʱʱЧ*/ + + return; + } + + if (CI_SUCCESS == FaultCancelNonRouteP(nonRouteId)) + { /*ȡɹ*/ + + if(CI_TIME_OUT == SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum)) + { /*ʱѵ*/ + + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_IDLE); /*÷ǽ·Ϊ*/ + } + else + { + /*ʱδδ*/ + } + } + else + { /*ȡʧ*/ + + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_LOCKERR); /*÷ǽ·쳣*/ + } +} + + +/* +* ·߼ +* ˵ void +* ֵ +*/ +void LongRouteLogicProcess(void) +{ + UINT16 longRouteCurSum = 0u; /*·Ŀ*/ + UINT8 longRouteState = 0u; /*·״̬*/ + UINT16 longRouteId = 0u; /*·ID*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 longRouteSubRouteSum = 0u; + UINT16* longRouteSubRouteIdBuf = NULL; + UINT8 virCIid = 0u; + UINT16 recordErrorNum = 0u; + + longRouteCurSum = GetLongRouteCurSum(); /*ȡ·*/ + + if (GetStartLockFlag() != CI_START_LOCK_NO) + { /*δϵ*/ + + return; + } + + /*·*/ + for (ii = 0u; ii <= longRouteCurSum; ii++) + { + longRouteId = 0u; /*·ID*/ + longRouteState = 0u; /*·״̬*/ + + longRouteId = GetLongRouteId(ii); /*ȡ·ID*/ + longRouteState = GetLongRouteState(longRouteId); /*ȡ·״̬*/ + + /*cgh-ϲCID-2349-5*/ + longRouteSubRouteSum = GetLongRouteSubRouteSum(longRouteId); + longRouteSubRouteIdBuf = GetLongRouteSubRouteIdBuf(longRouteId); + if ((0u < longRouteSubRouteSum) && (NULL != longRouteSubRouteIdBuf)) + { + virCIid = GetRouteBelongVirCiId(longRouteSubRouteIdBuf[0]); + } + recordErrorNum = GetErrorDataCurSum(); + /*#####·״̬#####*/ + if (ROUTE_LONG_STATE_IDLE == longRouteState) + { /*·*/ +#if 0 + RouteIdleManage(routeId); +#endif + } + else if (ROUTE_LONG_STATE_XUANPAI == longRouteState) + {/*·ѡ*/ + + LongRouteXuanPaiDeal(longRouteId); /*ѡŴ*/ + } + else if (ROUTE_LONG_STATE_LOCK == longRouteState) + {/*·*/ + + LongRouteLockDeal(longRouteId); /*մ*/ + } + else + { + /*״̬쳣*/ + /*xxxxx 崻*/ + } + /*cgh-ϲCID-2349-5*/ + SetErrorDataBelongVirCiId(recordErrorNum, virCIid);/*вErrorCodeֵ*/ + } +} + + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LongRouteXuanPaiDeal(const UINT16 longRouteId) +{ + UINT8 subRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + UINT8 NeedForDrvRoutAssoSwit = SWITCH_NEED_DRIV_FALSE;/*ǷҪ*/ + UINT8 cSGBJDelayOpenFlag = 0U; /*ⱨʱű־*/ + + subRouteSum = GetLongRouteSubRouteSum(longRouteId); /*ӽ·*/ + pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(longRouteId); /*ӽ·*/ + + if (1U>=subRouteSum) + { + return; + } + else + { + ; + } + + if (CI_SUCCESS == LockLongDTrainRouteP(longRouteId)) + { /*ճɹ*/ + + for (ii = 0u; ii < subRouteSum; ii++) + { + NeedForDrvRoutAssoSwit = CheckRoutAssoSwitNeedDriv(pSubRouteIdBuf[ii]);/*ǷҪ*/ + + if((CI_SUCCESS == CheckRouteSwitchPosRight(pSubRouteIdBuf[ii])) && (SWITCH_NEED_DRIV_FALSE == NeedForDrvRoutAssoSwit)) + { /*·λȷ*/ + } + else + { /*δλ*/ + + if (CI_ERROR == RouteLockDriveSwitch(pSubRouteIdBuf[ii], NeedForDrvRoutAssoSwit)) + { + /*ʧ*/ + + SetRoutAssoSwitSingOperStat(pSubRouteIdBuf[ii], SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetRouteStateDeal(pSubRouteIdBuf[ii], ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); /**/ + + SetLongRouteStateDeal(longRouteId, ROUTE_LONG_STATE_IDLE); /*-->ó·*/ + } + else + { + ; + } + + return; + } + + } + + for (ii = 0u; ii < subRouteSum; ii++) + { + if ((subRouteSum - 1U) != ii) + { + SetRelZuHeRouteSGBJDelayFlag(pSubRouteIdBuf[ii], ROUTE_SGBJ_DELAY_OPEN_INVALID); /*Ͻ·ʼ˵ӽ·ùϽ·ⱨʱ־Ч*/ + } + else + { + cSGBJDelayOpenFlag = GetRouteSGBJDelayFlag(pSubRouteIdBuf[ii]); + if (ROUTE_SGBJ_DELAY_OPEN_VALID == cSGBJDelayOpenFlag) + { + SetRelZuHeRouteSGBJDelayFlag(pSubRouteIdBuf[ii], ROUTE_SGBJ_DELAY_OPEN_VALID); /*Ͻ·ʼ˵ӽ·ⱨʱ־ЧʾϽ·ΪⷽùϽ·ⱨʱ־Ч*/ + } + else + { + SetRelZuHeRouteSGBJDelayFlag(pSubRouteIdBuf[ii], ROUTE_SGBJ_DELAY_OPEN_INVALID); /*Ͻ·ʼ˵ӽ·ⱨʱ־ЧʾϽ·ΪⷽùϽ·ⱨʱ־Ч*/ + } + } + + SetRoutAssoSwitSingOperStat(pSubRouteIdBuf[ii], SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetRouteStateDeal(pSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCK); /*-->ý·*/ + + SetRouteStateDeal(pSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCKERR); /*-->ý·쳣*/ + + SetRouteBelongLongRouteId(pSubRouteIdBuf[ii],longRouteId); /*ý··Id*/ + + SetRouteGroupRouteCmdFlag(pSubRouteIdBuf[ii], ROUTE_GROUPROUTE_CMD_YES);/*ý·Ͻ·־*/ + } + + SetLongRouteStateDeal(longRouteId, ROUTE_LONG_STATE_LOCK); /*-->ó·*/ + } + else + { /*·ʧ*/ + + SetLongRouteStateDeal(longRouteId, ROUTE_LONG_STATE_IDLE); /*-->ó·*/ + } +} + + +/* +* ·չ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LongRouteLockDeal(const UINT16 longRouteId) +{ + UINT8 subRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + + subRouteSum = GetLongRouteSubRouteSum(longRouteId); /*ӽ·*/ + pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(longRouteId); /*ӽ·*/ + + + if (1U >= subRouteSum ) + { + return; + } + else + { + ; + } + + for (ii = 0u; ii < subRouteSum; ii++) + { + if ((GetRouteState(pSubRouteIdBuf[ii]) == ROUTE_STATE_FIRST_LOCKERR) && + (GetRouteBelongLongRouteId(pSubRouteIdBuf[ii]) != longRouteId)) + { /*ӽ·״̬Ϊ쳣*/ + + SetLongRouteStateDeal(longRouteId, ROUTE_LONG_STATE_IDLE); /*-->ó·*/ + return; + } + else + { + ; + } + } + + for (ii = 0u; ii < subRouteSum; ii++) + { + if ((ROUTE_STATE_YUXIAN_OPEN == GetRouteState(pSubRouteIdBuf[ii])) || + (ROUTE_STATE_NEAR_OPEN == GetRouteState(pSubRouteIdBuf[ii]))) + { /*ӽ·״̬ΪԤȿ||ӽ*/ + + continue; + } + else if (ROUTE_STATE_FIRST_LOCK == GetRouteState(pSubRouteIdBuf[ii])) + { /*·*/ + + break; + } + else + { + if ((GetRouteState(pSubRouteIdBuf[ii]) != ROUTE_STATE_FIRST_LOCKERR) || + (GetRouteBelongLongRouteId(pSubRouteIdBuf[ii]) != longRouteId)) + { /*ӽ·״̬Ϊ쳣||Ϊ·*/ + + SetLongRouteStateDeal(longRouteId, ROUTE_LONG_STATE_IDLE); /*-->ó·*/ + } + else + { + SetRouteStateDeal(pSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCK); /*-->ý·*/ + } + + break; + } + } +} + + +/* +* ·߼ +* ˵ void +* ֵ +*/ +void RouteLogicProcess(void) +{ + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT8 localCiId = 0u; /*ID*/ + UINT16 routeId = 0u; /*·ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 zongQuXiaoFlag = 0u; /*·ȡ־*/ + UINT8 zongRenJieFlag = 0u; /*·˽־*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 virCIid = 0u; + UINT16 recordErrorNum = 0u; + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if (GetStartLockFlag() != CI_START_LOCK_NO) + { /*δϵ*/ + + return; + } + + + /*źſŹ*/ + YLockSignalOpenManage(); + + /*;۷*/ + DTrainReturnUnlockP(); + + /*·״̬*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = 0u; /*·ID*/ + belongCiId = 0u; /*·ID*/ + routeState = 0u; /*·״̬*/ + zongQuXiaoFlag = 0u; /*·ȡ־*/ + zongRenJieFlag = 0u; /*·˽־*/ + routeId = GetRouteId(ii); /*ȡ·ID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + virCIid = GetRouteBelongVirCiId(routeId); + recordErrorNum = GetErrorDataCurSum(); + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + /*************DZOverlap߼***************/ + /*վ䱣߼*/ + LockOverlapLogicManage(routeId); + + /**/ + UnlockOverlapLogicManage(routeId); + + /*****************·߼**********************/ + continue; + } + + /*ȡ·ֶ̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + zongQuXiaoFlag = GetRouteZongQuXiaoFlag(routeId); /*ȡ·ȡ־*/ + zongRenJieFlag = GetRouteZongRenJieFlag(routeId); /*ȡ·˽־*/ + + + /*#####·״̬#####*/ + if (ROUTE_STATE_IDLE == routeState) + { /*·*/ +#if 0 + RouteIdleManage(routeId); +#endif + } + else if (ROUTE_STATE_FIRST_XUANPAI == routeState) + {/*·Ԥѡ*/ + } + else if (ROUTE_STATE_XUANPAI == routeState) + { /*·ѡ*/ + + CommonRouteXuanPaiDeal(routeId); /*ͨ·ѡŴ*/ + } + else if (ROUTE_STATE_LEAD_XUANPAI == routeState) + { /*·ѡ*/ + + LeadRouteXuanPaiDeal(routeId); /*·ѡŴ*/ + } + else if (ROUTE_STATE_FIRST_LOCK == routeState) + { /*·*/ + + RouteFirstLockDeal(routeId); /*·*/ + } + else if (ROUTE_STATE_FIRST_LOCKERR == routeState) + { /*·쳣*/ + + RouteFirstLockErrDeal(routeId); /*·쳣*/ + } + else if (ROUTE_STATE_YUXIAN_LOCK == routeState) + { /*Ԥ*/ + + RouteYuXianLockDeal(routeId); /*·Ԥմ*/ + } + else if (ROUTE_STATE_YUXIAN_OPEN == routeState) + { /*Ԥȿ*/ + + RouteYuXianOpenDeal(routeId); /*·Ԥմ*/ + } + else if (ROUTE_STATE_NEAR_LOCK == routeState) + { /*ӽ*/ + + RouteNearLockDeal(routeId); /*·ӽմ*/ + } + else if (ROUTE_STATE_NEAR_LOCKERR == routeState) + { /*ӽ쳣*/ + + RouteNearLockErrDeal(routeId); /*·ӽ쳣*/ + } + else if (ROUTE_STATE_NEAR_OPEN == routeState) + { /*ӽ*/ + + RouteNearOpenDeal(routeId); /*·ӽŴ*/ + } + else if (ROUTE_STATE_DELAY_UNLOCK == routeState) + { /*ʱ*/ + + RouteDelayUnlockDeal(routeId); /*·ʱ*/ + } + else if (ROUTE_STATE_AUTO_UNLOCK == routeState) + { /*Զ*/ + + RouteSecAutoUnlockDeal(routeId); /*·Զ*/ + } + else if (ROUTE_STATE_AUTO_UNLOCKERR == routeState) + { /*Զ쳣*/ + + RouteSecAutoUnlockErrDeal(routeId); /*·Զ쳣*/ + } + else if (ROUTE_STATE_LEAD_LOCK == routeState) + { /**/ + + RouteLeadLockDeal(routeId); /*·մ*/ + } + else if (ROUTE_STATE_LEAD_OPEN == routeState) + { /**/ + + RouteLeadOpenDeal(routeId); /*·Ŵ*/ + } + else if (ROUTE_STATE_LEAD_LOCKERR == routeState) + { + RouteLeadLockErrDeal(routeId); /*·쳣*/ + } + else + { + /*״̬쳣*/ + /*xxxxx 崻*/ + } + + /*ȡ·״̬*/ + routeState = GetRouteState(routeId); + + if ((routeState != ROUTE_STATE_IDLE) && + (routeState != ROUTE_STATE_FIRST_XUANPAI) && + (routeState != ROUTE_STATE_XUANPAI) && + (routeState != ROUTE_STATE_LEAD_FIRST_XUANPAI) && + (routeState != ROUTE_STATE_LEAD_XUANPAI) && + (routeState != ROUTE_STATE_AUTO_UNLOCK) && + (routeState != ROUTE_STATE_AUTO_UNLOCKERR)) + { + /*·պгʻΪֹرźŴ*/ + (void)RouteOpenNeedCloseSignal(routeId); + } + + /*ղ״̬*/ + UpdateZhaoChaDeal(routeId, routeState); + + TryClearRouteTrainEnterFlag(routeId); + /*#####·ȡ#####*/ + if (ROUTE_ZONGQUXIAO_SET_YES == zongQuXiaoFlag) + { /*Ѱȡ*/ + + RouteZongQuXiaoDeal(routeId); + } + else if(ROUTE_ZONGRENJIE_SET_YES == zongRenJieFlag) + { /*Ѱ˽*/ + + RouteZongRenJieDeal(routeId); + } + else + {/**/ + } + /*************Overlap߼***************/ + /*վ䱣߼*/ + LockOverlapLogicManage(routeId); + + /**/ + UnlockOverlapLogicManage(routeId); + /*****************·߼********************/ + + /*۳SPKSPSDźŹرؿ*/ + RouteRecoverOpenProc(routeId); + + /*·ͬ߼*/ + RouteDCTYLogicM(routeId); + + /*ݽ·״̬ر־*/ + ClearSomeFlagDependRouteState(routeId); + /*cgh-ϲCID-2349-5*/ + SetErrorDataBelongVirCiId(recordErrorNum, virCIid); + } +} + + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void CommonRouteXuanPaiDeal(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 NeedForDrvRoutAssoSwit = SWITCH_NEED_DRIV_FALSE; /*ǷҪ*/ + UINT8 usingCheck = 0u; + UINT8 xuanPaiOvertime = 0u;/*ѡųʱ*/ + UINT8 switchCheak = 0u; + UINT8 switchDriveOvertime = 0u; + UINT8 switchDrive= 0u; + UINT8 checkVainResult = 0u;/*·߼*/ + UINT16 deviceId = 0u; + UINT8 deviceState = 0u; + UINT8 functionId = EFUNC_RouteLockVainCheak;/*麯*/ + routeType = GetRouteType(routeId); /*ȡ·*/ + usingCheck = RouteFirstXuanProc(routeId); + + if (CI_ERROR == usingCheck) + { + /*ʧ*/ + + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + /*ý·*/ + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); + } + else if (CI_SUCCESS == usingCheck) + { + /*óɹ*/ + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + returnValue = LockLTrainRouteP(routeId); + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + + returnValue = LockDTrainRouteP(routeId); + } + else + { /*·ʹ*/ + + return; + } + if(CI_SUCCESS == returnValue) + { + /*ǷҪ*/ + NeedForDrvRoutAssoSwit = CheckRoutAssoSwitNeedDriv(routeId); + switchCheak = CheckRouteSwitchPosRight(routeId); + if ((CI_SUCCESS == switchCheak) && (SWITCH_NEED_DRIV_FALSE == NeedForDrvRoutAssoSwit)) + { /*·λȷ豻*/ + checkVainResult = RouteIntruSecVainCheck(routeId,&deviceId,&deviceState); + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + if(CI_SUCCESS == checkVainResult) + { + /*߼ɹ*/ + SetRouteStateDeal(routeId, ROUTE_STATE_FIRST_LOCK); /*-->ý·*/ + } + else + { + /*·߼ʧ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /**/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,deviceId,ETYPE_PS_INTRU_OCU_STATE,deviceState,ESEND_LEVEL_ATS); + } + } + else + { /*δλߴ豻*/ + switchDriveOvertime = ChekRoutSwitDrivOvtmStat(routeId); + if (CI_SUCCESS == switchDriveOvertime) + {/*·ڷǷʱ*/ + switchDrive = RouteLockDriveSwitch(routeId, NeedForDrvRoutAssoSwit); + if (CI_ERROR == switchDrive) + { /*δʱ*/ + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /**/ + } + else + { + /**/ + } + } + else + {/*·ڷʱý·*/ + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*ٹʷ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /**/ + } + } + } + else + { /*·ʧ*/ + + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*ٹʷ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /**/ + } + } + /*ȴ*/ + else if(RETURN_FIRSTXUANPAI_ERR_WAIT == usingCheck) + { + xuanPaiOvertime = RouteFirstXuanOverTime(routeId); + if (OVERTIME_YES == xuanPaiOvertime) + {/*ѡųʱ*/ + /*ý·δ*/ + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); + + /*ý·*/ + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); + /*ӽ·ѡʱӡ*/ + SetErrorData(EFUNC_CommonRouteXuanPaiDeal,CI_DEVICE_TYPE_ROUTE,routeId, + ETYPE_ROUTE_FIRST_XUANPAI_OVERTIME,ROUTE_STATE_FIRST_XUANPAI,ESEND_LEVEL_ZERO); + } + else + { + /**/ + } + } + else + { + /*޲*/ + } + +} + + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LeadRouteXuanPaiDeal(const UINT16 routeId) +{ + UINT8 NeedForDrvRoutAssoSwit = SWITCH_NEED_DRIV_FALSE;/*ǷҪ*/ + + if (CI_SUCCESS == LockLeadTrainRouteP(routeId)) + { /*ճɹ*/ + + /*·ǷҪ*/ + NeedForDrvRoutAssoSwit = CheckRoutAssoSwitNeedDriv(routeId); + + if ((CI_SUCCESS == CheckRouteSwitchPosRight(routeId)) && (SWITCH_NEED_DRIV_FALSE == NeedForDrvRoutAssoSwit)) + { /*·λȷ*/ + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_LOCK); /*-->*/ + } + else + { /*δλ*/ + if (CI_SUCCESS == ChekRoutSwitDrivOvtmStat(routeId)) + {/*·ڷǷʱ*/ + if (RouteLockDriveSwitch(routeId, NeedForDrvRoutAssoSwit) == CI_ERROR) + { /*δʱ*/ + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /**/ + } + + } + else + {/*·ڷʱý·*/ + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*ٹʷ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /**/ + } + + } + } + else + { /*·ʧ*/ + SetRoutAssoSwitSingOperStat(routeId, SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /**/ + } +} + + +/* +* · +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstLockDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 openCloseState = 0u; /*źŻŹر״̬*/ + + UINT8 returnValue = 0u; /*Ƿִ*/ + + /* źʱ״̬*/ + UINT8 const routeTimeState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId), + GetSystemParaRouteOpenSigCyc()); + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + openCloseState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId)); /*ȡ·ʼźŻŹر״̬*/ + + /*г·*/ + if (ROUTE_OVERLAP_SET_NO == GetRouteOverlapLockFlag(routeId)) + { + /*·δ*/ + if (CI_TIME_IN != routeTimeState) + { + /*źſųʱ*/ + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCKERR); /*-->ó쳣*/ + returnValue = CI_ERROR; + } + else + { + /*δʱȴ*/ + returnValue = CI_ERROR; + } + } + else + { + /*ûб*/ + + /*ûб*/ + + /*ռü*/ + returnValue = BlocOverlapOccClearProc(routeId); + if (CI_ERROR == returnValue) + { + /*ռ*/ + if (CI_TIME_IN != routeTimeState) + {/*ռóʱ*/ + SetErrorData(EFUNC_LOCK_BLOC_T_ROUTE,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_OVERLAP_UNLOCK,ROUTE_OVERLAP_SET_NO,ESEND_LEVEL_ATS); + debug_infor_printf((const)"\nRoute %d ovlerlap OccTimeOut.\n",routeId); + SetRouteStateManage(routeId, ROUTE_STATE_FIRST_LOCKERR); /*-->ó쳣*/ + } + + } + } + + if (CI_SUCCESS == returnValue) + { + if (SIGNAL_OPEN == openCloseState) + { /*źſ*/ + + if (CI_SUCCESS == RouteHaveTrainNear(routeId)) + { + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_OPEN); /*ýӽ*/ + + RouteNearOpenDeal(routeId); /*·ӽŴ*/ + } + else + { + SetRouteStateDeal(routeId, ROUTE_STATE_YUXIAN_OPEN); /*Ԥȿ*/ + + RouteYuXianOpenDeal(routeId); /*·ԤȿŴ*/ + } + } + else + { /*źŹر*/ + + /*Ž·źŴ*/ + if (OpenCommRouteSigProc(routeId) == CI_SUCCESS) + { + return; + } + else + { + /*쳣*/ + SetRouteStateDeal(routeId, ROUTE_STATE_FIRST_LOCKERR); + } + } + } +} + + +/* +* ·쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstLockErrDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 openCloseState = 0u; /*źŻŹر״̬*/ + UINT8 needOpenNotTrueRepeatFlag = ROUTE_NEEDOPEN_REOPEN_NO;/*迪Ųʱؿ־*/ + + UINT8 dctyReOpenFlag = ROUTE_DCTY_REOPEN_NO;/*ͬؿ־*/ + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + openCloseState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId)); /*ȡ·ʼźŻŹر״̬*/ + + if (SIGNAL_OPEN == openCloseState) + { /*źſ*/ + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { + /*źؿ*/ + + SetRouteStateDeal(routeId,ROUTE_STATE_YUXIAN_OPEN); /*ý·״̬Ԥȿš*/ + + RouteYuXianOpenDeal(routeId); /*·ԤȿŹ*/ + } + else + { + needOpenNotTrueRepeatFlag = GetRouteNeedOpenReopenFlag(routeId); + /*ȡͬؿ־*/ + dctyReOpenFlag = GetRouteDCTYNotSatisfySignalReOpenFlag(routeId); + if ((ROUTE_NEEDOPEN_REOPEN_YES == needOpenNotTrueRepeatFlag ) + || (ROUTE_DCTY_REOPEN == dctyReOpenFlag)) + { +#if 0 + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0); +#endif + SetRouteStateDeal(routeId,ROUTE_STATE_YUXIAN_OPEN); /*ý·״̬Ԥȿš*/ + + RouteYuXianOpenDeal(routeId); /*·ԤȿŹ*/ + } + else + { + /*źŻ쳣*/ + /*xxxxx崻*/ + + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + CI_DEVICE_TYPE_SIGNAL, + startSignalId, + ETYPE_SYSTEM_SIGNAL_OPEN, + openCloseState,ESEND_LEVEL_ZERO); + } + + + + } + } + else + { + + /*źŹر*/ + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { + /*ؿźźŴ*/ + (void)OpenCommRouteSigProc(routeId); + } + else + { + /* ֽ·쳣״̬*/ + needOpenNotTrueRepeatFlag = GetRouteNeedOpenReopenFlag(routeId); + /*ȡͬؿ־*/ + dctyReOpenFlag = GetRouteDCTYNotSatisfySignalReOpenFlag(routeId); + if ((ROUTE_NEEDOPEN_REOPEN_YES == needOpenNotTrueRepeatFlag) || + (ROUTE_DCTY_REOPEN == dctyReOpenFlag) ) + {/*迪㣬迪ؿ־Ч/ͬؿ־Чʱ*/ + (void)OpenCommRouteSigProc(routeId); + } + else + { +#if 0 + (void)DriveSignalClose(startSignalId); +#endif + } + } + } +} + + +/* +* ·Ԥչ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteYuXianLockDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT8 startSigPreDrvColor = 0u; /*ʼźŻɫ*/ + + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + startSignalCurColor = GetSignalCurColor(startSignalId); + startSigPreDrvColor = GetSignalPreDriveColor(startSignalId); + + + if (SIGNAL_OPEN == GetSignalOpenCloseState(startSignalCurColor)) + { /*źſ*/ + + if (SIGNAL_CLOSE == GetSignalOpenCloseState(startSigPreDrvColor)) + { /*֮ǰر*/ + + return; + } + + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { /*źؿЧ*/ + + if (CI_SUCCESS == RouteHaveTrainNear(routeId)) + { /*·гӽ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ýӽ*/ + + RouteNearOpenDeal(routeId); /*·ӽŴ*/ + } + else + { + SetRouteStateDeal(routeId, ROUTE_STATE_YUXIAN_OPEN); /*-->Ԥȿ*/ + + RouteYuXianOpenDeal(routeId); /*·ԤȿŴ*/ + } + } + else + { + /*źŻ쳣*/ + /*xxxxx崻*/ + } + } + else + { + /*źŹر*/ + + if (CI_SUCCESS == RouteHaveTrainNear(routeId)) + { /*гӽ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + + RouteNearLockErrDeal(routeId); /*·ӽ쳣*/ + } + else + { /*޳ӽ*/ + + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { /*źؿЧ*/ + + (void)OpenCommRouteSigProc(routeId); /*Ž·źŴ*/ + } + else + { + /*ؿԶź*/ + } + } + } +} + + +/* +* ·ԤȿŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteYuXianOpenDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 needOpenNotTrueRepeatFlag = ROUTE_NEEDOPEN_REOPEN_NO; + UINT8 dctyReOpenFlag =ROUTE_DCTY_REOPEN_NO; + UINT8 curColor = 0u; + UINT8 sigState = 0u; + UINT8 funcId = EFUNC_RouteYuXianOpenDeal;/*ID*/ + UINT8 checkResult = 0u; + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + curColor = GetSignalCurColor(startSignalId); + + sigState = GetSignalOpenCloseState(curColor); + + if (SIGNAL_OPEN == sigState) + { /*źſ*/ + needOpenNotTrueRepeatFlag = GetRouteNeedOpenReopenFlag(routeId); + if (ROUTE_NEEDOPEN_REOPEN_YES == needOpenNotTrueRepeatFlag ) + { + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + } + else + { + ; + } + dctyReOpenFlag = GetRouteDCTYNotSatisfySignalReOpenFlag(routeId); + if (ROUTE_DCTY_REOPEN == dctyReOpenFlag) + { + SetRouteDCTYNotSatisfySignalReOpenFlag(routeId,ROUTE_DCTY_REOPEN_NO); + SetRouteDCTYNotSatisfyStartCnt(routeId,0u); + } + else + { + ; + } + /*ֿŽ·źŴ*/ + checkResult = KeepCommRouteSigProc(routeId); + if (CI_SUCCESS == checkResult) + { + /*ֳɹ*/ + checkResult = RouteHaveTrainNear(routeId); + if (CI_SUCCESS == checkResult) + { + /*·гӽ*/ + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ӽ*/ + + RouteNearOpenDeal(routeId); /*·ӽŴ*/ + } + else + { + /*Ԥȿ*/ + return; + } + } + else + { + /*ʧ*/ + checkResult = RouteHaveTrainNear(routeId); + if (CI_SUCCESS == checkResult) + { /*гӽ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + else + { /*޳ӽ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_YUXIAN_LOCK); /*-->Ԥ*/ + } + } + } + else + { /*źŹر*/ + checkResult = RouteHaveTrainNear(routeId); + if (CI_SUCCESS == checkResult) + { /*гӽ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + else + { /*޳ӽ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_YUXIAN_LOCK); /*-->Ԥ*/ + } + + /*źŻϹرձ*/ + SetErrorData(funcId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,sigState,ESEND_LEVEL_ATS); + } +} + + +/* +* ·ӽչ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearLockDeal(const UINT16 routeId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT16 nextSecId = 0u; /*һID*/ + UINT8 rtUnlockExceptFlag = 0u;/*·ǷԶ쳣־*/ + UINT8 routeType = 0u;/*·*/ + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + routeType = GetRouteType(routeId);/*ȡ·*/ + + if (0u == sectionSum) + { /*·ݴ*/ + + return; + } + else + { + } + + if ((GetPhySecLockState(pRouteSecStru[0].PhysicalSectionId) != PHYSICAL_SECTION_LOCK_NORMAL) || + (GetPhySecRLockBelongRouteId(pRouteSecStru[0].PhysicalSectionId) != routeId)) + { /*մ*/ + + return; + } + else + { + } + + /**/ + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(pRouteSecStru[0].PhysicalSectionId)) + { /*һռ*/ + + if ((ROUTE_TYPE_DIAOCHE == routeType)&& + (PHYSICAL_SEC_TYPE_NOSWITCH == GetPhySecType(pRouteSecStru[0].PhysicalSectionId)) && + (1u == sectionSum)) + { /*·&&ֻһ&&޲*/ + + SetPhySecLockState(pRouteSecStru[0].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, routeId, GetRouteDirection(routeId)); /*δ*/ + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + else + { + } + + return; + } + else + { + } + + /*һο*/ + if (SECTION_OCCUPY_YES == GetPhySecPreMergeState(pRouteSecStru[0].PhysicalSectionId)) + { /*һ֮ǰռ*/ + + nextSecId = GetRouteNextPhySecId(routeId, pRouteSecStru[0].PhysicalSectionId); /*ȡһ*/ + + if (0xFFFFu != nextSecId) + {/*һδ*/ + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(nextSecId)) + {/*һռ*/ + SetPhySecLockState(pRouteSecStru[0].PhysicalSectionId, PHYSICAL_SECTION_LOCK_DELAY, 0, 0); /*ʱ*/ + SetPhySecAutoUnlockStartCycNum(pRouteSecStru[0].PhysicalSectionId, Get2oo2CurCycleNum()); /*ʱʼ*/ + SetRouteStateDeal(routeId, ROUTE_STATE_AUTO_UNLOCK); /*-->Զ*/ + + rtUnlockExceptFlag = 0u;/*ý·쳣־Ч*/ + } + else + {/*һδռ*/ + rtUnlockExceptFlag = 1u;/*Ҫ쳣*/ + + } + } + else + {/*һβ*/ + rtUnlockExceptFlag = 1u;/*Ҫ쳣*/ + } + } + else + { + } + + if ((1u== rtUnlockExceptFlag) && (ROUTE_TYPE_LIECHE == routeType)) + {/*·ڷһֻ̹г·ãȻ;۷ ޸20170911ByWuRenju*/ + SetPhySecLockState(pRouteSecStru[0].PhysicalSectionId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, GetRouteDirection(routeId)); + /*-->Զ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + else if ((1u== rtUnlockExceptFlag) && (ROUTE_TYPE_DIAOCHE == routeType)) + {/*ýӽ쳣޸20170911ByWuRenju*/ + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); + } + else + { + /*ʲô*/ + } +} + +/* +* ·ӽ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearLockErrDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT8 startSigPreDrvColor = 0u; /*ʼźŻɫ*/ + UINT16 sigInfirPhySecId = 0u;/*źŻڷһ*/ + + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + startSignalCurColor = GetSignalCurColor(startSignalId); + startSigPreDrvColor = GetSignalPreDriveColor(startSignalId); + sigInfirPhySecId = GetSignalInFirstPhySecId(startSignalId, routeId); + + if (SIGNAL_OPEN == GetSignalOpenCloseState(startSignalCurColor)) + { /*źſ*/ + + if (SIGNAL_CLOSE == GetSignalOpenCloseState(startSigPreDrvColor)) + { /*֮ǰر*/ + + return; + } + + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { /*źؿЧ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_OPEN); /*-->ýӽ*/ + + RouteNearOpenDeal(routeId); /*·ӽŴ*/ + } + else + { + /*źŻ쳣*/ + /*xxxxx崻*/ + } + } + else + { /*źŹر*/ + /*г·źŻѹڷһοУõһιգֵطź쳣رգźŻڷһο*/ + if ((SIGNAL_CROSS_STATE_YES == GetSignalCrossState(startSignalId)) && (SECTION_OCCUPY_NO == GetPhySecCurMergeState(sigInfirPhySecId)) + && (ROUTE_TYPE_LIECHE == GetRouteType(routeId))) + { + /*Ӹֵطź쳣رգźŻڷһο*/ + SetCiSendCmdBackInfoData(CI_BACK_SIG_CLOSE_EXCEPT,CI_DEVICE_TYPE_SIGNAL,startSignalId,0u,0u); + /*ڷһι*/ + SetPhySecLockState(sigInfirPhySecId, PHYSICAL_SECTION_LOCK_EXCEPT, routeId, GetRouteDirection(routeId)); + /*-->Զ쳣*/ + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + else + { + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { /*źؿЧ*/ + + (void)OpenCommRouteSigProc(routeId); /*Ž·źŴ*/ + } + else + { + /*ؿԶź*/ + } + } + } +} + + +/* +* ·ӽŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearOpenDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT16 errorCodeCurSum = 0u; /*Ŀ*/ + ErrorDataStruct* errorCodeStu = NULL; /**/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 curColor = 0u; + UINT8 sigState = 0u; + UINT8 funcId = EFUNC_RouteNearOpenDeal;/*ID*/ + UINT8 checkResult = 0u; + /*ʼźⷽͬʱռѹΪгʻ룻ע⣺ʻ־ֻ˽жϣгʻжϴڲ*/ + checkResult = RouteInOutSecOccupy(routeId); + if (CI_SUCCESS == checkResult) + { + SetRouteTrainEnterFlag(routeId, ROUTE_TRAIN_ENTER_FLAG_YES); + } + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + curColor = GetSignalCurColor(startSignalId); + + sigState = GetSignalOpenCloseState(curColor); + + if (SIGNAL_OPEN == sigState) + { /*źſ*/ + + /*ֿŽ·źŴ*/ + checkResult = KeepCommRouteSigProc(routeId); + if (CI_SUCCESS == checkResult) + { /*ֳɹ*/ + + return; + } + else + { /*ʧ*/ + checkResult = CheckTrainEnterRoute(routeId); + if (CI_SUCCESS == checkResult) + { /*гʻ*/ + + errorCodeCurSum = GetErrorDataCurSum(); /*ȡ*/ + /**/ + for (ii = 0u; ii < errorCodeCurSum; ii++) + { + errorCodeStu = GetErrorData(ii); /*ȡ*/ + + if (NULL != errorCodeStu) + { + + if((EFUNC_CLD_KEEP_L_TRAIN_ROUTE == errorCodeStu->FunctionId)|| (EFUNC_CLD_KEEP_D_TRAIN_ROUTE == errorCodeStu->FunctionId)) + {/*г·͵·źű*/ + if (((CI_DEVICE_TYPE_PHYSEC == errorCodeStu->DeviceType) || (CI_DEVICE_TYPE_LOGICSEC == errorCodeStu->DeviceType))&& + (ETYPE_PS_MERGY_OCU_STATE == errorCodeStu->DeviceStateType)) + { /*ʻ룬ɾ*/ + DeleteErrorData(ii); + } + + } + + } + } + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCK); /*-->ýӽ*/ + } + else + { + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + } + } + else + { /*źŹر*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + + /*źŻϹرձ*/ + SetErrorData(funcId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,sigState,ESEND_LEVEL_ATS); + } +} + + +/* +* ·ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteDelayUnlockDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT32 delayStartCycNum = 0u; /*ʱʼں*/ + UINT32 delayTotalCycSum = 0u; /*ʱ*/ + UINT8 routeLevel = 0u; /*·ල*/ + + UINT8 zrjDelayType;/*·˽ʱ*/ + UINT8 zrjExe = CI_ERROR;/*˽Ƿִ*/ + UINT8 routePreState = 0u;/*·֮״̬*/ + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + routeLevel = GetRouteLevel(routeId); + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + if (SIGNAL_OPEN == GetSignalOpenCloseState(GetSignalCurColor(startSignalId))) + { /*źſ*/ + + return; + } + + delayStartCycNum = GetRouteDelayUnlockStartCycNum(routeId); /*ȡ·ʱʼ*/ + + if ((GetRouteType(routeId) == ROUTE_TYPE_LIECHE) || (GetRouteType(routeId) == ROUTE_TYPE_RETURN)) + { + delayTotalCycSum = GetSystemParaBlocRouteDelayCyc();/*ȡг·ʱ*/ + } + else if (GetRouteType(routeId) == ROUTE_TYPE_DIAOCHE) + { + delayTotalCycSum = GetSystemParaFaultUnlockCyc(); /*ȡ·ʱ*/ + } + else + { + /**/ + } + + if ((0u == Get2oo2CurCycleNum()) || (delayTotalCycSum == 0u) || (delayStartCycNum == 0u)) + { /*ʱʱЧ*/ + + return; + } + + zrjDelayType = GetRouteZongRenJieDelayType(routeId);/*ý·˽ʱ*/ + + if (ROUTE_ZRJ_DELAY_TYPE_IDLE == zrjDelayType) + { + if (CI_SUCCESS == CommRouteDelayUnlockProc(routeId)) + { /*ȡɹ*/ + + if ((CI_TIME_OUT == SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum)) || + (ROUTE_STOPENSURE_YES == GetRouteStopensureFlag(routeId))) + { /*ʱյ֤ͣ*/ + + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + else + { + /*ʱδδ*/ + } + } + else + { /*ȡʧ*/ + routePreState = GetRoutePreState(routeId); + if ((ROUTE_STATE_LEAD_LOCKERR == routePreState) || (ROUTE_STATE_LEAD_LOCK == routePreState)) + { + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_LOCKERR); /*-->쳣*/ + } + else + { + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + } + + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + } + } + else if ((ROUTE_ZRJ_DELAY_TYPE_ALL_EXP == zrjDelayType) || (ROUTE_ZRJ_DELAY_TYPE_EXP_TO_OCCUPY == zrjDelayType)) + { + zrjExe = CheckRouteZongRenJieFeasibility(routeId); + + if (CI_SUCCESS == zrjExe) + { + if ((CI_TIME_OUT == SystemOverTimeCheck(delayStartCycNum, delayTotalCycSum)) || + (ROUTE_STOPENSURE_YES == GetRouteStopensureFlag(routeId))) + { /*ʱյ֤ͣ*/ + if (ROUTE_ZRJ_DELAY_TYPE_ALL_EXP == zrjDelayType) + { + /*·ó쳣*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_EXCEPT); + + /*·߼ζ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_EXCEPT); + } + else + { + /*·ڵһռѹ֮ǰΪ쳣*/ + SetRoutePhySecExpLockToOccupy(routeId); + } + SetRouteStateDeal(routeId, ROUTE_STATE_AUTO_UNLOCKERR); /*-->ý·Զ쳣*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + } + else + { + /*ʱδδ*/ + } + } + else + { + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + } + } + else + { + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*-->ýӽ쳣*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_INVALID); + } +} + + +/* +* ·Զ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteSecAutoUnlockDeal(const UINT16 routeId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT16 nextSecId = 0u; /*һID*/ + UINT16 waitUnlockSecId = 0u; /*ȴID*/ + UINT8 unlockSecIndex = 0xFFu; /**/ + UINT8 ii= 0u; + UINT16 preSec = 0u;/*һID*/ + UINT16 returnSigId = 0u;/*źŻID*/ + UINT8 rtUnlockExceptFlag = 0u;/*·ǷԶ쳣־*/ + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + + if (0u == sectionSum) + { + return; + } + else + { + } + /*·ʱ*/ + RouteSecDelayUnlockProc(routeId); + + for(ii = 0u; ii < sectionSum; ii++) + { + if ((GetPhySecLockState(pRouteSecStru[ii].PhysicalSectionId) == PHYSICAL_SECTION_LOCK_NORMAL) && + (GetPhySecRLockBelongRouteId(pRouteSecStru[ii].PhysicalSectionId) == routeId)) + { /*·һ*/ + + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(pRouteSecStru[ii].PhysicalSectionId)) + { /*һռ*/ + + return; + } + else + { /*ο*/ + + unlockSecIndex = ii; + break; + } + } + else + { + } + } + + if (0xFFu == unlockSecIndex) + { /*ûҵ*/ + + return; + } + else + { + } + + /*ȴID*/ + waitUnlockSecId = pRouteSecStru[unlockSecIndex].PhysicalSectionId; + + /*εǰ*/ + if (SECTION_OCCUPY_YES == GetPhySecPreMergeState(waitUnlockSecId)) + { /*֮ǰռ*/ + + nextSecId = GetRouteNextPhySecId(routeId, waitUnlockSecId); /*ȡһ*/ + + if (0xFFFFu != nextSecId) + {/*һδ*/ + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(nextSecId)) + {/*һռ*/ + /*ɹ*/ + SetPhySecLockState(waitUnlockSecId, PHYSICAL_SECTION_LOCK_DELAY, 0, 0); /*ʱ*/ + SetPhySecAutoUnlockStartCycNum(waitUnlockSecId, Get2oo2CurCycleNum()); /*ʱʼ*/ + + /*·ʱ*/ + RouteSecDelayUnlockProc(routeId); + } + else + {/*һο*/ + /*ǰ;۷߼;۷߼򲻻ߵﲻ;۷ֱ̹*/ + rtUnlockExceptFlag = 1;/*ý·쳣־Ч*/ + } + } + else + {/*һβ*/ + /*;۷źŻ;۷źŻֱó̹ԭ;۷źŻ£;۷߼ѲյĽ·ʣȫ·״̬ɿУߵ֮Իߵ֤;۷߼ֲ飬ֱó̹*/ + returnSigId = GetRouteMidwayReturnSignalId(routeId); + + if ((0u != returnSigId)&&(GetStartSignalCIRouteSum(returnSigId)>0U)) + {/*;۷źŻ*/ + rtUnlockExceptFlag = 1u;/*ý·쳣־Ч*/ + } + else + { + /*;۷źŻǽ·һΣһռδգҲԽӸ߼ҪӦ෿ߣBͣߵC*/ + if (sectionSum >= 2u) + {/*·*/ + if (unlockSecIndex == (sectionSum - 1u)) + { + preSec = pRouteSecStru[unlockSecIndex - 1U].PhysicalSectionId; + + if ((SECTION_OCCUPY_YES == GetPhySecCurMergeState(preSec)) && (PHYSICAL_SECTION_LOCK_NO == GetPhySecLockState(preSec))) + { + /*ɹ*/ + SetPhySecLockState(waitUnlockSecId, PHYSICAL_SECTION_LOCK_DELAY, 0u, 0u); /*ʱ*/ + SetPhySecAutoUnlockStartCycNum(waitUnlockSecId, Get2oo2CurCycleNum()); /*ʱʼ*/ + RouteSecDelayUnlockProc(routeId);/*·ʱ*/ + } + else + { + rtUnlockExceptFlag = 1u;/*ý·쳣־Ч*/ + } + } + else + { + rtUnlockExceptFlag = 1u;/*ý·쳣־Ч*/ + } + } + else + { + /*С2ߵԶڣ˴봦ȫ*/ + rtUnlockExceptFlag = 1u;/*ý·쳣־Ч*/ + } + } + } + } + else + { + } + + if (1u == rtUnlockExceptFlag) + {/*·쳣־Ч*/ + /*쳣*/ + SetPhySecLockState(waitUnlockSecId, PHYSICAL_SECTION_LOCK_EXCEPT, 0u, 0u); + + /*-->Զ쳣*/ + SetRouteStateDeal(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + + /*·ʱ*/ + RouteSecDelayUnlockProc(routeId); + } + else + { + } +} + + +/* +* ·Զ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteSecAutoUnlockErrDeal(const UINT16 routeId) +{ + /*·ʱ*/ + RouteSecDelayUnlockProc(routeId); + /*쳣δ*/ + RouteExpLockContinue(routeId); +} + + +/* +* ·չ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadLockDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 returnValue = 0u; + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + if (SIGNAL_OPEN == GetSignalOpenCloseState(GetSignalCurColor(startSignalId))) + { /*źſ*/ + + if (GetPhySecCurMergeState(GetSignalInFirstPhySecId(startSignalId, routeId)) == SECTION_OCCUPY_YES) + {/*ڷι*/ + + SetRouteLeadFaultOpenStartCyc(routeId, Get2oo2CurCycleNum()); /*ʱʱ*/ + } + + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_OPEN); /**/ + + RouteLeadOpenDeal(routeId); /*·Ŵ*/ + } + else + { /*źŹر*/ + + returnValue = OpenLeadRouteP(routeId); + + /*·źŴ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + DriveSignalOpen(startSignalId, routeId); /*·źſ*/ + } + else if (RETURN_OPEN_ERR_SIGOPEN == returnValue) + { /*رźδر*/ + (void)DriveSignalClose(startSignalId); /*źŹر*/ + } + else if (RELAY_STATE_WAITE == returnValue) + { + /*ȴ*/ + } + else + { /*ʧ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_LOCKERR); /*-->쳣*/ + } + } +} + + +/* +* ·Ź +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadOpenDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 returnValue = 0u; /*ֵ*/ + + + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + /*ʼźⷽͬʱռѹΪгʻ룻ע⣺ʻ־ֻ˽жϣгʻжϴڲ*/ + if (CI_SUCCESS == RouteInOutSecOccupy(routeId)) + { + SetRouteTrainEnterFlag(routeId, ROUTE_TRAIN_ENTER_FLAG_YES); + } + + if (SIGNAL_OPEN == GetSignalOpenCloseState(GetSignalCurColor(startSignalId))) + { /*źſ*/ + + /*ֿ·źŴ*/ + returnValue = KeepLeadRouteP(routeId); + + if (CI_SUCCESS == returnValue) + { /*ֳɹ*/ + if (GetPhySecCurMergeState(GetSignalInFirstPhySecId(startSignalId, routeId)) == SECTION_OCCUPY_NO) + {/*ڷһδռ*/ + + SetRouteLeadFaultOpenStartCyc(routeId,0u); /*ʱʱ*/ + } + + DriveSignalOpen(startSignalId, routeId); /*·źſ*/ + } + else + { /*ʧ*/ + + (void)DriveSignalClose(startSignalId); /*·źŹر*/ + + SetRouteLeadFaultOpenStartCyc(routeId, 0u); /*ʱʱ*/ + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_LOCKERR); /*-->쳣*/ + } + } + else + { /*źŹر*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_LOCKERR); /*-->쳣*/ + } +} + + +/* +* ·쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadLockErrDeal(const UINT16 routeId) +{ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 returnValue = 0u; + /*ȡ·ֶ̬*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + + openCloseState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId)); + + if (SIGNAL_OPEN == openCloseState) + { /*źſ*/ + + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { /*źؿЧ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_OPEN); /*-->*/ + + RouteLeadOpenDeal(routeId); /*·Ŵ*/ + } + else + { + /*ź쳣*/ + /*xxxxx崻*/ + } + } + else + { /*źŹر*/ + + + if (ROUTE_REPEATOPEN_SET_YES == GetRouteRepeatOpenFlag(routeId)) + { + returnValue = OpenLeadRouteP(routeId); + /*ݿźŷֵ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + DriveSignalOpen(startSignalId, routeId); /*źſ*/ + } + else if (RETURN_OPEN_ERR_SIGOPEN == returnValue) + { /*رźδر*/ + (void)DriveSignalClose(startSignalId); /*źŹر*/ + } + else if (RELAY_STATE_WAITE == returnValue) + { + /*ȴ*/ + } + else + { /*ʧ*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteOpenSigStartCycNum(routeId,0u); /*źſʱ*/ + } + } + else + { + /*ؿź*/ + } + } +} + + +/* +* Ž·źŴ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS +* CI_ERROR +*/ +UINT8 OpenCommRouteSigProc(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT16 startSignalId = 0u; + + UINT8 errType = CI_ERROR;/*ʧʱĴ*/ + UINT8 recoverState = ROUTE_RECOVER_STA_STAY;/*ǰָؿ״̬*/ + UINT8 routeState = 0u;/*·״̬*/ + UINT32 curCycle = 0u;/*ǰ*/ + UINT8 needOpenNotTrueRepeatFlag = ROUTE_NEEDOPEN_REOPEN_NO;/*迪δ㣬ؿ־*/ + UINT32 needOpenRepeatStartCount = 0u;/*迪δ㣬ؿʼ*/ + UINT32 sysparaRepeatCount = 0u;/*ϵͳؿά*/ + UINT8 routeTimeState = CI_TIME_NO; + + UINT8 dctyReOpenFlag = ROUTE_DCTY_REOPEN_NO;/*ͬؿ־*/ + UINT32 dctyStartCount = 0u;/*ͬʼ*/ + + routeType = GetRouteType(routeId); /*ȡ·*/ + startSignalId = GetRouteStartSignalId(routeId); + routeState = GetRouteState(routeId); + curCycle = Get2oo2CurCycleNum(); + + dctyReOpenFlag = GetRouteDCTYNotSatisfySignalReOpenFlag(routeId);/*ȡͬؿ־*/ + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + returnValue = OpenLTrainRouteP(routeId); /*г·*/ + errType = OpenLTrainRouteErrP(routeId, OPEN_CHECK_STEP_OPEN);/*ʧԭ*/ + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + + returnValue = OpenDTrainRouteP(routeId); /*ŵ·*/ + errType = OpenDTrainRouteErrP(routeId, OPEN_CHECK_STEP_OPEN); /*ʧԭ*/ + } + else + { /*·ʹ*/ + + returnValue = CI_ERROR; + } + + if ((ROUTE_TYPE_LIECHE == routeType) || (ROUTE_TYPE_DIAOCHE == routeType)) + { + /*ݿźŷֵ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + DriveSignalOpen(startSignalId, routeId); /*źſ*/ + + /*㿪Ҳ·ָ״̬һν·״̬ת*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_INIT); + + + + + returnValue = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_SIGOPEN == returnValue) + { /*رźδر*/ + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + + if (ROUTE_DCTY_REOPEN == dctyReOpenFlag) + { + SetErrorData(EFUNC_CLD_OpenCommRouteSigProc, + CI_DEVICE_TYPE_ROUTE,routeId, + ETYPE_DCTY_REOPEN_TIMING_BREAK,dctyReOpenFlag,ESEND_LEVEL_ATS); + SetRouteDCTYNotSatisfySignalReOpenFlag(routeId,ROUTE_DCTY_REOPEN_NO); + SetRouteDCTYNotSatisfyStartCnt(routeId,0u); + } + + + returnValue = CI_SUCCESS; + } + else if (RETURN_OPEN_ERR_NEEDOPEN == returnValue/*迪*/) + { + (void)DriveSignalClose(startSignalId); + + if (ROUTE_STATE_FIRST_LOCK == routeState/**/) + { + /*ؿ־δŲؿʼʱ*/ + /*жг·迪źŻΪźŻҹر*/ + if (ROUTE_TYPE_LIECHE == routeType) + { + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_YES); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,curCycle); + } + else + { + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + } + } + else if(ROUTE_STATE_FIRST_LOCKERR == routeState/*쳣*/) + { + /*ȡؿ־*/ + /*鳬ʱ*/ + needOpenNotTrueRepeatFlag = GetRouteNeedOpenReopenFlag(routeId); + needOpenRepeatStartCount = GetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId); + sysparaRepeatCount = GetSystemParaRouteOpenSigCyc();/*迪ŵȴʱý·źſʱ*/ + if ((ROUTE_NEEDOPEN_REOPEN_YES == needOpenNotTrueRepeatFlag) && (needOpenRepeatStartCount>0u)) + { + /*鳬ʱʱ־*/ + /* źʱ״̬*/ + routeTimeState = SystemOverTimeCheck(needOpenRepeatStartCount,sysparaRepeatCount); + if (CI_TIME_OUT == routeTimeState)/*ʱ*/ + { + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + } + else if (CI_TIME_NO == routeTimeState)/*δʱ*/ + { + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + } + else if(CI_TIME_IN == routeTimeState)/*ʱ*/ + { + /*ؿ*/ + } + else + { + /*Ƿ*/ + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + } + + /*Ϊڿ迪ŲʱԶؿУԣźԶؿ־ظ*/ + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + SetRouteOpenSigStartCycNum(routeId,0u); /*źſʱ*/ + + } + + } + else + { + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + } + if (ROUTE_DCTY_REOPEN == dctyReOpenFlag) + { + SetErrorData(EFUNC_CLD_OpenCommRouteSigProc, + CI_DEVICE_TYPE_ROUTE,routeId, + ETYPE_DCTY_REOPEN_TIMING_BREAK,dctyReOpenFlag,ESEND_LEVEL_ATS); + SetRouteDCTYNotSatisfySignalReOpenFlag(routeId,ROUTE_DCTY_REOPEN_NO); + SetRouteDCTYNotSatisfyStartCnt(routeId,0u); + } + + returnValue = CI_ERROR; + } + else if ((ROUTE_TYPE_DIAOCHE == routeType)&&(RETURN_DCTY_NOT_SATISIFY == returnValue)/*ͬⲻ*/) + { + (void)DriveSignalClose(startSignalId);/*źŹر*/ + if (ROUTE_STATE_FIRST_LOCK == routeState/**/) + { + SetRouteDCTYNotSatisfySignalReOpenFlag(routeId,ROUTE_DCTY_REOPEN); + SetRouteDCTYNotSatisfyStartCnt(routeId,curCycle); + } + else if(ROUTE_STATE_FIRST_LOCKERR == routeState/*쳣*/) + { + sysparaRepeatCount = 0u; + /*鳬ʱ*/ + dctyStartCount = GetRouteDCTYNotSatisfyStartCnt(routeId);/*ȡͬⲻʼ*/ + sysparaRepeatCount = GetSysParaDCTYWaitSigOpenCnt();/*ȡϵͳͬȴźؿʱʱ*/ + if ((ROUTE_DCTY_REOPEN == dctyReOpenFlag) && (dctyStartCount>0u)) + { + /*鳬ʱʱ־*/ + /* źʱ״̬*/ + routeTimeState = SystemOverTimeCheck(dctyStartCount,sysparaRepeatCount); + if (CI_TIME_OUT == routeTimeState)/*ʱ*/ + { + SetErrorData(EFUNC_CLD_OpenCommRouteSigProc, + CI_DEVICE_TYPE_ROUTE,routeId, + ETYPE_DCTY_REOPEN_TIMEOUT,dctyReOpenFlag,ESEND_LEVEL_ATS); + + SetRouteDCTYNotSatisfySignalReOpenFlag(routeId,ROUTE_DCTY_REOPEN_NO); + SetRouteDCTYNotSatisfyStartCnt(routeId,0u); + } + else if (CI_TIME_NO == routeTimeState)/*δʱ*/ + { + SetRouteDCTYNotSatisfySignalReOpenFlag(routeId,ROUTE_DCTY_REOPEN_NO); + SetRouteDCTYNotSatisfyStartCnt(routeId,0u); + } + else if(CI_TIME_IN == routeTimeState)/*ʱ*/ + { + /*ؿ*/ + } + else + { + /*Ƿ*/ + SetRouteDCTYNotSatisfySignalReOpenFlag(routeId,ROUTE_DCTY_REOPEN_NO); + SetRouteDCTYNotSatisfyStartCnt(routeId,0u); + } + + + + } + } + else + { + /**/ + } + /*Ϊڿ迪ŲʱԶؿУԣźԶؿ־ظ*/ + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + SetRouteOpenSigStartCycNum(routeId,0u); /*źſʱ*/ + + returnValue = CI_ERROR; + } + else if (RELAY_STATE_WAITE == returnValue) + { + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + + returnValue = CI_SUCCESS; /*ȴ*/ + } + else + { /*ʧ*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteOpenSigStartCycNum(routeId,0u); /*źſʱ*/ + + /*忪δؿ־δŲؿʼʱ*/ + SetRouteNeedOpenReopenFlag(routeId,ROUTE_NEEDOPEN_REOPEN_NO); + SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(routeId,0u); + + if (ROUTE_DCTY_REOPEN == dctyReOpenFlag) + { + SetErrorData(EFUNC_CLD_OpenCommRouteSigProc, + CI_DEVICE_TYPE_ROUTE,routeId, + ETYPE_DCTY_REOPEN_TIMING_BREAK,dctyReOpenFlag,ESEND_LEVEL_ATS); + SetRouteDCTYNotSatisfySignalReOpenFlag(routeId,ROUTE_DCTY_REOPEN_NO); + SetRouteDCTYNotSatisfyStartCnt(routeId,0u); + + } + + if (CI_ROUTE_RECOVER_ERR == errType) + { + recoverState = GetRouteRecoverOpenFlag(routeId); + + if ((ROUTE_RECOVER_STA_INIT == recoverState) || (ROUTE_RECOVER_STA_WAIT == recoverState)) + { + /*·֮ǰڿɻָ״ֿ̬ɻָ״̬ȴָ*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_WAIT); + } + else + { + /*·֮ǰѾڲɻָ״ֲ̬ɻָ״ֹ̬ؿʹ·߱˻ָؿ*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY); + } + } + else + { + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY);/*һ㣬·䲻߱Զؿ*/ + } + + returnValue = CI_ERROR; + } + } + + return returnValue; +} + + +/* +* ֿŽ·źŴ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 KeepCommRouteSigProc(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT16 outPhySecId = 0u; /*źŻⷽһID*/ + UINT16 inPhySecId = 0u; /*źŻڷһID*/ + UINT8 returnValue = 0u; /*ֵ*/ + + UINT8 errType = CI_ERROR;/*ʧʱĴ*/ + + routeType = GetRouteType(routeId); /*ȡ·*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + inPhySecId = GetSignalInFirstPhySecId(startSignalId, routeId); /*źŻڷһID*/ + outPhySecId = GetSignalOutFirstPhySecId(startSignalId); /*źŻⷽһID*/ + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + returnValue = KeepLTrainRouteP(routeId); /*г·ź*/ + errType = KeepLTrainRouteErrP(routeId);/*ʧԭ*/ + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + + returnValue = KeepDTrainRouteP(routeId); /*ֵ·ź*/ + errType = KeepDTrainRouteErrP(routeId);/*ʧԭ*/ + + /*жгʻ:ڷһεǰռ && ֮ǰУ && ʼźŻⷽһεǰռ*/ + if ((SECTION_OCCUPY_YES == GetPhySecCurMergeState(inPhySecId)) && (SECTION_OCCUPY_NO == GetPhySecPreMergeState(inPhySecId))) + { + if ((0U == outPhySecId) || (SECTION_OCCUPY_YES == GetPhySecCurMergeState(outPhySecId))) + { + SetTrainEnterRouteFlag(routeId, TRAIN_ENTER_ROUTE_FLAG_YES); + } + } + } + else + { /*·ʹ*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + return CI_ERROR; + } + + /*ݿźŷֵ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + DriveSignalOpen(startSignalId, routeId); /*źſ*/ + + return CI_SUCCESS; + } + else + { /*ʧ*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + + SetRouteStopFlagManage(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + + if (CI_ROUTE_RECOVER_ERR == errType) + { + /*·Ϊָؿص޷ֿţý·߱ȴָ*/ + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_WAIT); + } + else + { + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY); + } + + return CI_ERROR; + } +} + + +/* +* ·ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 CommRouteDelayUnlockProc(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 returnValue = 0u; /*ֵ*/ + + + routeType = GetRouteType(routeId); /*ȡ·*/ + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + returnValue = RouteCancelLogicProcess(routeId); /*г·ʱ*/ + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + + returnValue = CancelDTrainRouteP(routeId); /*·ʱ*/ + } + else + { /*·ʹ*/ + + return CI_ERROR; + } + + + /*ݿźŷֵ*/ + if (CI_SUCCESS == returnValue) + { /*ɹ*/ + + return CI_SUCCESS; + } + else + { /*ʧ*/ + + return CI_ERROR; + } +} + + + +/* +* ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteSecDelayUnlockProc(const UINT16 routeId) +{ + UINT16 delayUnlockSecId = 0u; /*ʱID*/ + UINT16 nextPhySecId = 0u; /*һID*/ + UINT8 secUnlockTime = 0u; /*νʱ*/ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT8 ii= 0u; + UINT32 delayTotalCycSum = 0u; /*ʱ*/ + UINT16 routeLastSwiPhySecId = 0u; /*·Զ˵ID*/ + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + routeLastSwiPhySecId = GetRouteLastSwichPhySecId(routeId);/*ȡ·Զ˵*/ + + + if (0u == sectionSum) + { + return; + } + else + { + } + + /*#####ʽʱ#####*/ + for(ii = 0u; ii < sectionSum; ii++) + { + if (PHYSICAL_SECTION_LOCK_FAULTDELAY ==GetPhySecLockState(pRouteSecStru[ii].PhysicalSectionId)) + { /*·һʽʱ*/ + /*жĽ·*/ + /*ǰһ汾δджϣᵼ⣺αո·A·AδԶͨʽ⽫쳣αɿУռõΣʱAԴԶ쳣*/ + /*֮αո·BȻ·BҲҪʽ⣬ڽ·Aڽ·BǰԱڽ·Bʽʱ߼A*/ + if(GetPhySecRLockBelongRouteId(pRouteSecStru[ii].PhysicalSectionId) == routeId) + { + delayUnlockSecId = pRouteSecStru[ii].PhysicalSectionId; + break; + } + else + { + } + } + else + { + } + } + + /*ͬ·ʽʱͬ*/ + if ((ROUTE_TYPE_LIECHE==GetRouteType(routeId)) || (ROUTE_TYPE_RETURN ==GetRouteType(routeId))) + { + delayTotalCycSum = GetSystemParaBlocRouteDelayCyc();/*ȡг·ʱ*/ + } + else if (ROUTE_TYPE_DIAOCHE==GetRouteType(routeId)) + { + delayTotalCycSum = GetSystemParaFaultUnlockCyc(); /*ȡ·ʱ*/ + } + else + { + /**/ + } + + if (delayUnlockSecId > 0u) + { + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(delayUnlockSecId)) + { /*ռ*/ + + /**/ + SetPhySecLockState(delayUnlockSecId, PHYSICAL_SECTION_LOCK_NORMAL, routeId, GetRouteDirection(routeId)); /**/ + + /*ý·ӽ쳣*/ + SetRouteStateDeal(routeId, ROUTE_STATE_NEAR_LOCKERR); /*ý·ӽ쳣*/ + + /*ʱʼ*/ + (void)SetPhySecFaultUnlockStartCycNum(delayUnlockSecId, 0u); + } + else + { /*ο*/ + + secUnlockTime = SystemOverTimeCheck(GetPhySecFaultUnlockStartCycNum(delayUnlockSecId),delayTotalCycSum); + + if (CI_TIME_OUT == secUnlockTime) + { /*ʱѵ*/ + + SetPhySecLockState(delayUnlockSecId, PHYSICAL_SECTION_LOCK_NO, routeId, GetRouteDirection(routeId)); /*δ*/ + + if (routeLastSwiPhySecId == delayUnlockSecId) + { + /*·*/ + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_CANCEL);/*ȡ·ķ*/ + } + else + { + ; + } + + PhySecFaultRelatedUnLockDeal(delayUnlockSecId, routeId); /*״̬*/ + + if (CI_SUCCESS == CheckRoutePhySecHaveUnLock(routeId)) + { /*·ȫ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + else + { + ; + } + } + else + { + ; + } + } + + return; + } + + /*#####Զʱ#####*/ + delayUnlockSecId = 0u; + for(ii = 0u; ii < sectionSum; ii++) + { + if ((GetPhySecLockState(pRouteSecStru[ii].PhysicalSectionId) == PHYSICAL_SECTION_LOCK_DELAY) && + (GetPhySecRLockBelongRouteId(pRouteSecStru[ii].PhysicalSectionId) == routeId)) + { /*·һʱ*/ + + delayUnlockSecId = pRouteSecStru[ii].PhysicalSectionId; + break; + } + else + { + } + } + + if (0u == delayUnlockSecId) + { /*δҵ*/ + + return; + } + else + { + } + + + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(delayUnlockSecId)) + { /*ռ*/ + + /*ʱʼ*/ + SetPhySecAutoUnlockStartCycNum(delayUnlockSecId, Get2oo2CurCycleNum()); + + return; + } + else + { /*ο*/ + + secUnlockTime = SystemOverTimeCheck(GetPhySecAutoUnlockStartCycNum(delayUnlockSecId), + GetSystemParaSecDelayUnlockCyc()); + + if (CI_TIME_OUT == secUnlockTime) + { /*ʱѵ*/ + + /*δ*/ + SetPhySecLockState(delayUnlockSecId, PHYSICAL_SECTION_LOCK_NO, routeId, GetRouteDirection(routeId)); + + if (routeLastSwiPhySecId == delayUnlockSecId) + { + /*·*/ + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_CANCEL);/*ȡ·ķ*/ + } + else + { + ; + } + + /*һ޲*/ + if ((ROUTE_TYPE_DIAOCHE == GetRouteType(routeId)) && + (sectionSum >= 2u) && + (delayUnlockSecId == pRouteSecStru[sectionSum-2U].PhysicalSectionId) && + (PHYSICAL_SEC_TYPE_NOSWITCH == GetPhySecType(pRouteSecStru[sectionSum-1U].PhysicalSectionId))) + { /*· && 2 && ·ڶ && һ޲*/ + + SetPhySecLockState(pRouteSecStru[sectionSum-1U].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, routeId, GetRouteDirection(routeId)); /*δ*/ + } + else + { + ; + } + + + if (CI_SUCCESS == CheckRoutePhySecHaveUnLock(routeId)) + { /*·ȫ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + else + { + nextPhySecId = GetRouteNextPhySecId(routeId, delayUnlockSecId); /*ȡһID*/ + + if (PHYSICAL_SECTION_LOCK_DELAY == GetPhySecLockState(nextPhySecId)) + { /*һʱ*/ + + /*һμʱ*/ + SetPhySecAutoUnlockStartCycNum(nextPhySecId, Get2oo2CurCycleNum()); + } + else + { + return; + } + } + } + else + { + return; + } + } +} + + +/* +* ϵ߼ +* ˵ void +* ֵ +*/ +void StartupUnlockM(void) +{ + UINT16 phySecId = 0u; /*ID*/ + UINT16 phySecSum = 0u; /**/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT16 ii = 0u; /*α*/ + + + if (GetStartLockFlag() != CI_START_LOCK_YES) + { + return; + } + + phySecSum = GetPhySecCurSum(); /*ȡ*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + for (ii = 0u; ii < phySecSum; ii++) + {/**/ + + belongCiId = 0u; /*·ID*/ + + phySecId = GetPhySecId(ii); /*ȡID*/ + belongCiId = GetPhySecBelongCiId(phySecId); + + if ((0u == phySecId) || (phySecId >= PHYSICAL_SECTION_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (localCiId == 0u)) + { + continue; + } + + + if (PHYSICAL_SECTION_LOCK_START == GetPhySecLockState(phySecId)) + { /*ϵ*/ + + SetPhySecLockState(phySecId, PHYSICAL_SECTION_LOCK_NO, 0u, 0u);/*״̬Ϊδ*/ + } + } + + SetStartLockFlag(CI_START_LOCK_NO); /*ϵɹ*/ +} + + +/* +* ͨ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetCommonRouteLogicM(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + routeType = GetRouteType(routeId); /* ȡ·*/ + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + if (CI_SUCCESS == SetLTrainRouteP(routeId)) + { /*ͨ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_XUANPAI); /*ý·״̬Ϊѡ*/ + + CommonRouteXuanPaiDeal(routeId); /*ͨ·ѡŴ*/ + } + else + { + /**/ + } + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + + /*ý·ֹͣ־*/ + SetRouteStopFlagManage(routeId, GetStopCheckFlag()); + + if (CI_SUCCESS == SetDTrainRouteP(routeId)) + { /*ͨ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_XUANPAI); /*ý·״̬Ϊѡ*/ + + CommonRouteXuanPaiDeal(routeId); /*ͨ·ѡŴ*/ + } + else + { + SetRouteStopFlagManage(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + } + } + else + { + /*޲*/ + } +} + + +/* +* Ͻ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetZuHeRouteLogicM(const UINT16 routeId) +{ + UINT8 subRouteSum = 0U; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0U; + UINT8 routeType = 0U; + UINT8 reVal = CI_ERROR; + UINT16 longRouteLastRouteId = 0U; + UINT8 stopCheckFlag = 0U; + UINT8 phySecUseFlag = 0U; + + subRouteSum = GetLongRouteSubRouteSum(routeId); /*ӽ·*/ + pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(routeId); /*ӽ·*/ + + + if (1u >= subRouteSum ) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + /*ӽ·ñ־*/ + if (CI_SUCCESS == reVal) + { + /*ӽ·*/ + for (ii = 0u; ii < subRouteSum; ii++) + { + phySecUseFlag = RoutePhySectionUseLogicProcess(pSubRouteIdBuf[ii]); + if (CI_SUCCESS == phySecUseFlag) + { + /*ͨ*/ + } + else + { + reVal = CI_ERROR; + + break; + } + } + } + else + { + /*ʧ*/ + } + + + if(CI_SUCCESS == reVal) + { + routeType = GetRouteType(pSubRouteIdBuf[0]); + longRouteLastRouteId = GetLongRouteLastRouteId(routeId);/*ȡϽ·һӽ·ID*/ + stopCheckFlag = GetStopCheckFlag();/*ȡֹͣɵ־*/ + /*ϵ·һӽ·ֹͣ־*/ + if(ROUTE_TYPE_DIAOCHE == routeType) + { + SetRouteStopFlagManage(longRouteLastRouteId, stopCheckFlag); + } + + reVal = SetLongDTrainRouteP(routeId); + if (CI_SUCCESS == reVal) + { /*ͨ*/ + + for (ii = 0u; ii < subRouteSum; ii++) + { + SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_YES); /*ý·*/ + } + + SetLongRouteStateDeal(routeId, ROUTE_LONG_STATE_XUANPAI); /*ó·״̬Ϊѡ*/ + } + else + { + if(ROUTE_TYPE_DIAOCHE == routeType) + { + /*ֻе·żֹͣ־*/ + SetRouteStopFlagManage(longRouteLastRouteId, ROUTE_STOPCHECK_SET_NO); /*һ·ֹͣ־*/ + } + } + } + +} + +/* +* ȡϵ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void CancelZuHeRouteLogicM(const UINT16 routeId) +{ + UINT8 subRouteSum = 0U; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0U; + UINT8 chRouteType = 0U; + UINT8 chRouteState = 0U; + + subRouteSum = GetLongRouteSubRouteSum(routeId); /*ӽ·*/ + pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(routeId); /*ӽ·*/ + if ((1U >= subRouteSum) || (NULL == pSubRouteIdBuf)) + { + ; /*ô󣬲*/ + } + else + { + for (ii = 0U; ii < subRouteSum; ii++) + { + /*ӽ·Ϊ·*/ + chRouteType = GetRouteType(pSubRouteIdBuf[ii]); /*ȡ·*/ + chRouteState = GetRouteState(pSubRouteIdBuf[ii]);/*ȡ·״̬*/ + if (ROUTE_TYPE_DIAOCHE == chRouteType) + { + if ((ROUTE_STATE_IDLE == chRouteState) || (ROUTE_STATE_AUTO_UNLOCK == chRouteState) || (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState)) + { + SetCiSendCmdBackInfoData(CI_BACK_ROUTE_LOCK_NOTALL, CI_DEVICE_TYPE_ROUTE, pSubRouteIdBuf[ii], 0U, 0U); + } + else + { + ZongQuXiaoRouteM(pSubRouteIdBuf[ii]);/*ӽ·ȡ*/ + } + } + } + } + +} + +/* +* ȡг·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void CancelZuHeLieCheRouteLogicM(const UINT16 routeId) +{ + UINT8 subRouteSum = 0U; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0U; + UINT8 chRouteType = 0U; + UINT8 chRouteState = 0U; + + subRouteSum = GetLongRouteSubRouteSum(routeId); /*ӽ·*/ + pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(routeId); /*ӽ·*/ + if ((subRouteSum <= 1U) || (NULL == pSubRouteIdBuf)) + { + ; /*ô󣬲*/ + } + else + { + for (ii = 0U; ii < subRouteSum; ii++) + { + /*ӽ·Ϊг·*/ + chRouteType = GetRouteType(pSubRouteIdBuf[ii]); /*ȡ·*/ + chRouteState = GetRouteState(pSubRouteIdBuf[ii]);/*ȡ·״̬*/ + if (ROUTE_TYPE_LIECHE == chRouteType) + { + if ((ROUTE_STATE_IDLE == chRouteState) || (ROUTE_STATE_AUTO_UNLOCK == chRouteState) || (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState)) + { + SetCiSendCmdBackInfoData(CI_BACK_ROUTE_LOCK_NOTALL, CI_DEVICE_TYPE_ROUTE, pSubRouteIdBuf[ii], 0U, 0U); + } + else + { + ZongQuXiaoRouteM(pSubRouteIdBuf[ii]);/*ӽ·ȡ*/ + } + } + } + } + +} + +/* +* ·߼ +* ˵ const UINT16 signalId, źŻID +* ֵ +*/ +void SetLeadRouteM(const UINT16 signalId) +{ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 routeId = 0u; + UINT8 sigExtinctState = 0U; + UINT8 maintLightState = 0U; + UINT8 routeLevel = 0U; + + routeId = GetStartSignalRouteId(signalId); /*ȡźŻID*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + sigExtinctState = GetSignalLightExtinctState(signalId); + maintLightState = GetSignalMaintainState(signalId); + routeLevel = GetRouteLevel(routeId); + + + if ((0u != routeId) && (routeId < ROUTE_SUM_MAX)) + {/*cgh-ϲCID-3037-8*/ + if (((SIGNAL_LIGHT_EXTICT_STATE_NO == sigExtinctState) && (MAINTAIN_STATE_YES == maintLightState)) + || (SIGNAL_LIGHT_EXTICT_STATE_ALL_YES == sigExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_YES == sigExtinctState)) + { + if (ROUTE_STATE_IDLE == routeState) + { /*·*/ + + if (CI_SUCCESS == SetLeadRouteP(routeId)) + {/*ͨ*/ + + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_XUANPAI); /*ý·״̬Ϊѡ*/ + + } + else + { + /**/ + + /*ԭ·״̬*/ + + } + } + else if ((routeState == ROUTE_STATE_FIRST_LOCKERR) || + (routeState == ROUTE_STATE_YUXIAN_LOCK) || + (routeState == ROUTE_STATE_NEAR_LOCK) || + (routeState == ROUTE_STATE_NEAR_LOCKERR)) + { + /*ת·*/ + + /*·쳣 + Ԥա + ӽ + ӽ쳣*/ + if (CI_SUCCESS == LockLeadTrainRouteP(routeId)) + { + /*ճɹ*/ + SetRouteStateDeal(routeId, ROUTE_STATE_LEAD_LOCK); /*ý·*/ + + } + else + { + /*ʧ*/ + + /*ԭ·״̬*/ + + } + } + else + { + SetErrorData(EFUNC_CLD_OPEN_LEAD_ROUTE, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, routeState, ESEND_LEVEL_ATS); + } + } + else + { + SetErrorData(EFUNC_CLD_OPEN_LEAD_ROUTE, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEVEL, routeLevel, ESEND_LEVEL_ATS); + } + } +} + + +/* +* ȡ·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void ZongQuXiaoRouteM(const UINT16 routeId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + if (ROUTE_ZONGQUXIAO_SET_NO == GetRouteZongQuXiaoFlag(routeId)) + { /*·δȡ*/ + + SetRouteZongQuXiaoFlag(routeId, ROUTE_ZONGQUXIAO_SET_YES); /*ý·ȡ־*/ + /* Ż룺жPSDSPKS۳µźŹرգؿ־λȴؿʱյʽʱؿ־ */ + if(GetRouteRecoverOpenFlag(routeId) == ROUTE_RECOVER_STA_WAIT) + { + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY);/*ֹ߼ؿ*/ + } + } +} + + +/* +* ˽·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void ZongRenJieRouteM(const UINT16 routeId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 cRouteZongRenJieFlag = 0u; + UINT8 cRouteRecoverOpenFlag = 0u; + + if ((0u == routeId) || (ROUTE_SUM_MAX <= routeId)) + { + ;/* ޴ */ + } + else + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + ;/* ޴ */ + } + else + { + cRouteZongRenJieFlag = GetRouteZongRenJieFlag(routeId); + if (ROUTE_ZONGRENJIE_SET_NO == cRouteZongRenJieFlag) + { /*·δ˽*/ + + (void)SetRouteZongRenJieFlag(routeId, ROUTE_ZONGRENJIE_SET_YES); /*ý·˽־*/ + /* Ż룺жPSDSPKS۳µźŹرգؿ־λȴؿʱյʽʱؿ־ */ + cRouteRecoverOpenFlag = GetRouteRecoverOpenFlag(routeId); + if (ROUTE_RECOVER_STA_WAIT == cRouteRecoverOpenFlag) + { + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*·źؿ־*/ + + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_STAY);/*ֹ߼ؿ*/ + } + else + { + ;/* ޴ */ + } + } + else + { + ;/* ޴ */ + } + } + } +} + + +/* +* ؿź߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void RepeatOpenSignalM(const UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT16 routeId = 0u; /*·ID*/ + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 ii = 0u; /*ѭ*/ + UINT8 cSGBJDelayOpenFlag = 0U; /*ⱨʱű־*/ + UINT8 cRelZuHeSGBJDelayOpenFlag = 0U; /*Ͻ·ⱨʱű־*/ + UINT32 dwCurDelayOpenStartCycNum = 0U; /*·ⱨʱʼ*/ + UINT32 dwCurCycNum = 0U; + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + + /*·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = 0u; /*·ID*/ + belongCiId = 0u; /*·ID*/ + routeState = 0u; /*·״̬*/ + + + routeId = GetRouteId(ii); /*ȡ·ID*/ + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + continue; + } + + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + continue; + } + + if (signalId != GetRouteStartSignalId(routeId)) + { /*Ϊ·ʼźŻID*/ + + continue; + } + + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + if ((routeState != ROUTE_STATE_FIRST_LOCKERR) && + (routeState != ROUTE_STATE_YUXIAN_LOCK) && + (routeState != ROUTE_STATE_NEAR_LOCKERR)) + { /*·״̬Ϊ: 쳣&&Ԥ&&ӽ쳣*/ + if (ROUTE_STATE_DELAY_UNLOCK == routeState) + {/*˽ʱڼ䣬źؿЧ¼ϲֵغATSͷ*/ + SetErrorData(EFUNC_CANCLE_ROUTE,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_CANCEL,CI_ERROR,ESEND_LEVEL_ATS); + } + continue; + } + + if ((ROUTE_ZONGQUXIAO_SET_YES == GetRouteZongQuXiaoFlag(routeId)) || + (ROUTE_ZONGRENJIE_SET_YES == GetRouteZongRenJieFlag(routeId))) + { /*ȡ˽*/ + SetErrorData(EFUNC_CANCLE_ROUTE,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_CANCEL,CI_ERROR,ESEND_LEVEL_ATS);/*ȡ˽ʱźؿЧ¼ϲֵغATSͷ*/ + return; + } + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_YES); /*ý·źؿ־*/ + SetRouteStopFlagManage(routeId, GetStopCheckFlag()); /*ý·ֹͣ־*/ + + dwCurCycNum = Get2oo2CurCycleNum(); + cSGBJDelayOpenFlag = GetRouteSGBJDelayFlag(routeId); + cRelZuHeSGBJDelayOpenFlag = GetRelZuHeRouteSGBJDelayFlag(routeId); + dwCurDelayOpenStartCycNum = GetRouteDelayOpenStartCyc(routeId); + + if ((0U == dwCurDelayOpenStartCycNum) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cSGBJDelayOpenFlag) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cRelZuHeSGBJDelayOpenFlag)) + { + SetRouteDelayOpenStartCyc(routeId, dwCurCycNum); + SetRouteOpenSigStartCycNum(routeId, 0U); /*ⱨʱ·źſʱ䣬ⱨʱ½·źſʱ䳬*/ + } + else if ((ROUTE_SGBJ_DELAY_OPEN_VALID != cSGBJDelayOpenFlag) || (ROUTE_SGBJ_DELAY_OPEN_VALID != cRelZuHeSGBJDelayOpenFlag)) + { + SetRouteOpenSigStartCycNum(routeId, dwCurCycNum); /*·ⱨʱţźſʼʱ*/ + } + else + { + /*ʱʼڣ*/ + } + + return; + } +} + + +/* +* õ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void SetSwitchFengSuoM(const UINT16 switchId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 const switchType = GetSwitchType(switchId); + UINT16 switch2ndId = 0U; + UINT8 chNonRouteCheck = CI_ERROR; + UINT8 chKeepwork = CI_SUCCESS; + UINT8 funRet = CI_ERROR; + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + chKeepwork = CI_ERROR; + } + + if (CI_SUCCESS == chKeepwork) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + chKeepwork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepwork) + { + chNonRouteCheck = CheckSwitchBelongNonRoute(switchId); + if (CI_SUCCESS == chNonRouteCheck) + { /*Ѱǽ·*/ + + chKeepwork = CI_ERROR; + } + + if (switchType == SWITCH_TYPE_DOUBLE) + { + /*˫*/ + /*2ڷǽ·*/ + switch2ndId = GetDSwitchOtherId(switchId); + chNonRouteCheck = CheckSwitchBelongNonRoute(switch2ndId); + if (CI_SUCCESS == chNonRouteCheck) + { + /*һѰǽ·*/ + chKeepwork = CI_ERROR; + } + } + } + + + if (CI_SUCCESS == chKeepwork) + { + /*õ߼*/ + funRet = SetSwitchFLockLogicProcess(switchId); + if (CI_SUCCESS == funRet) + { /*ͨ*/ + + SetSwitchFengSuoStateDeal(switchId, SWITCH_LOCK_FENGSUO_YES); /*õ*/ + } + else + { /*ʧ*/ + } + } +} + + +/* +* õ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void SetSwitchDanSuoM(const UINT16 switchId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 const switchType = GetSwitchType(switchId); + UINT16 switch2ndId = 0U; + UINT8 chNonRouteCheck = CI_ERROR; + UINT8 chKeepwork = CI_SUCCESS; + UINT8 funRet = CI_ERROR; + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + chKeepwork = CI_ERROR; + } + + if (CI_SUCCESS == chKeepwork) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + chKeepwork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepwork) + { + + chNonRouteCheck = CheckSwitchBelongNonRoute(switchId); + if (CI_SUCCESS == chNonRouteCheck) + { /*Ѱǽ·*/ + + chKeepwork = CI_ERROR; + } + + if (switchType == SWITCH_TYPE_DOUBLE) + { + /*˫*/ + /*2ڷǽ·*/ + switch2ndId = GetDSwitchOtherId(switchId); + chNonRouteCheck = CheckSwitchBelongNonRoute(switch2ndId); + if (CI_SUCCESS == chNonRouteCheck) + { + /*һѰǽ·*/ + chKeepwork = CI_ERROR; + } + } + } + + if (CI_SUCCESS == chKeepwork) + { + /*õ߼*/ + funRet = SetSwitchDLockLogicProcess(switchId); + if (CI_SUCCESS == funRet) + { /*ͨ*/ + + SetSwitchDanSuoStateDeal(switchId, SWITCH_LOCK_DANSUO_SET); /*õ*/ + } + else + { /*ʧ*/ + } + } +} + + +/* +* źŷ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ +*/ +void SetSignalFengSuoM(const UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + if (CI_SUCCESS == CheckSignalBelongNonRoute(signalId)) + { /*źŻѰǽ·*/ + + return; + } + + if (SIGNAL_FENGSUO_NO == GetSignalFLockState(signalId)) + { /*źŻδ*/ + + SetSignalFLockState(signalId, SIGNAL_FENGSUO_YES); /*źŻ*/ + } + else + { + } +} + + +/* +* ȡ߼ +* ˵ UINT16 switchId, ID +* ֵ +*/ +void CancelSwitchFengSuoM(const UINT16 switchId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 const switchType = GetSwitchType(switchId); + UINT16 switch2ndId = 0U; + UINT8 chNonRouteCheck = CI_ERROR; + UINT8 chKeepwork = CI_SUCCESS; + UINT8 funRet = CI_ERROR; + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + chKeepwork = CI_ERROR; + } + if (CI_SUCCESS == chKeepwork) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + chKeepwork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepwork) + { + chNonRouteCheck = CheckSwitchBelongNonRoute(switchId); + if (CI_SUCCESS == chNonRouteCheck) + { /*Ѱǽ·*/ + + chKeepwork = CI_ERROR; + } + + if (switchType == SWITCH_TYPE_DOUBLE) + { + /*˫*/ + /*2ڷǽ·*/ + switch2ndId = GetDSwitchOtherId(switchId); + chNonRouteCheck = CheckSwitchBelongNonRoute(switch2ndId); + if (CI_SUCCESS == chNonRouteCheck) + { + /*һѰǽ·*/ + chKeepwork = CI_ERROR; + } + } + } + + if (CI_SUCCESS == chKeepwork) + { + /*ȡ߼*/ + funRet = CancelSwitchFLockLogicProcess(switchId); + if (CI_SUCCESS == funRet) + { /*ͨ*/ + + SetSwitchFengSuoStateDeal(switchId, SWITCH_LOCK_FENGSUO_NO); /*ȡ*/ + } + else + { /*ȡʧ*/ + } + } +} + + +/* +* ȡ߼ +* ˵ UINT16 switchId, ID +* ֵ +*/ +void CancelSwitchDanSuoM(const UINT16 switchId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 const switchType = GetSwitchType(switchId); + UINT16 switch2ndId = 0U; + UINT8 chNonRouteCheck = CI_ERROR; + UINT8 chKeepwork = CI_SUCCESS; + UINT8 funRet = CI_ERROR; + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + chKeepwork = CI_ERROR; + } + + if (CI_SUCCESS == chKeepwork) + { + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + chKeepwork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepwork) + { + chNonRouteCheck = CheckSwitchBelongNonRoute(switchId); + if (CI_SUCCESS == chNonRouteCheck) + { /*Ѱǽ·*/ + + chKeepwork = CI_ERROR; + } + + if (switchType == SWITCH_TYPE_DOUBLE) + { + /*˫*/ + /*2ڷǽ·*/ + switch2ndId = GetDSwitchOtherId(switchId); + chNonRouteCheck = CheckSwitchBelongNonRoute(switch2ndId); + if (CI_SUCCESS == chNonRouteCheck) + { + /*һѰǽ·*/ + chKeepwork = CI_ERROR; + } + } + } + + if (CI_SUCCESS == chKeepwork) + { + /*ȡ߼*/ + funRet = CancelSwitchDLockLogicProcess(switchId); + if (CI_SUCCESS == funRet) + { /*ͨ*/ + + SetSwitchDanSuoStateDeal(switchId, SWITCH_LOCK_DANSUO_CANCEL); /*ȡ*/ + } + else + { /*ȡʧ*/ + } + } +} + + +/* +* ȡźŷ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ +*/ +void CancelSignalFengSuoM(const UINT16 signalId) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + + + if ((0u == signalId) || (signalId >= SIGNAL_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSignalBelongCiId(signalId); /*ȡźŻID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + if (CI_SUCCESS == CheckSignalBelongNonRoute(signalId)) + { /*źŻѰǽ·*/ + + return; + } + + if (SIGNAL_FENGSUO_YES == GetSignalFLockState(signalId)) + { /*źŻ*/ + + SetSignalFLockState(signalId, SIGNAL_FENGSUO_NO); /*źŻδ*/ + } + else + { + } +} + + +/* +* õλ߼ +* ˵ UINT16 switchId, ID +* const UINT8 switchSetPos, λ +* ֵ +*/ +void SetSwitchPositionM(const UINT16 switchId, const UINT8 switchSetPos) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*·ID*/ + UINT8 check_Result = CI_SUCCESS; + UINT8 lineType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡͨ·*/ + UINT8 chTemp = CI_ERROR; + + if ((0u == switchId) || (switchId >= SWITCH_SUM_MAX)) + { + return; + } + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + belongCiId = GetSwitchBelongCiId(switchId); /*ȡID*/ + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + return; + } + + if (CI_TRADITION_RAILWAY == lineType) + {/*ǹ·*/ + if ((switchSetPos != SWITCH_POSITION_DINGWEI) && (switchSetPos != SWITCH_POSITION_FANWEI)) + {/*λЧ*/ + check_Result = CI_ERROR; + } + else + {/*λЧ*/ + check_Result = CI_SUCCESS; + } + } /* zt ɾش 2022-02-15 */ + else + {/*Ч·*/ + check_Result = CI_ERROR; + } + +/*˶δע͵SetSwitchPositionLogicProcess()ҲмǰλǷѾǵλ*/ +#if 0 + if (switchSetPos == GetSwitchCurPosition(switchId)) + {/*λڵλ*/ + return; + } +#endif + + if (CI_SUCCESS == check_Result) + {/*λЧ*/ + /*ٵ*/ + if (CI_SUCCESS == SetSwitchPositionLogicProcess(switchId, switchSetPos, 0u, &chTemp)) + { /*ͨ*/ + + (void)SetSwitchDanCaoPosition(switchId, switchSetPos); /*õλñ־*/ + } + else + { /*ʧ*/ + } + } +} + +/* +* ǽ·߼ +* ˵ +* ֵ +*/ +void SetNonRouteM(UINT8 nonRouteId) +{ + /*ǽ·*/ + UINT8 interfaceType = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE);/*ȡԳ복νӿڷʽ*/ + + if (CI_SUCCESS == SetNonRouteP(nonRouteId)) + { /*ͨ*/ + + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_XUANPAI); /*÷ǽ·Ϊѡ*/ + if (SCX_CLD_INTERFACE_RELAY == interfaceType) + {/*̵ӿ*/ + /* SQJ */ + if (GetRelayCollState(GetNonRouteAppTryRelayIdById(nonRouteId)) == RELAY_STATE_UP) + { /*ûԳ*/ + + (void)SetNonRouteRunModeById(nonRouteId,NONROUTE_RUN_MODE_TRAIN); /*÷ǽ·ΪԳģʽ*/ + } + else + { /*Գ*/ + + (void)SetNonRouteRunModeById(nonRouteId,NONROUTE_RUN_MODE_APPLY); /*÷ǽ·Ϊźģʽ*/ + } + } + else if((SCX_CLD_INTERFACE_COMM == interfaceType)||(SCX_CLD_SERIAL_PORT_COMM == interfaceType)) + {/*ͨŽӿ*/ + if (COMM_TRAIN_TEST_DEV_STATE_INVALID == GetCommTrainTestCLDSQJStatus()) + {/*Գ*/ + (void)SetNonRouteRunModeById(nonRouteId,NONROUTE_RUN_MODE_TRAIN); /*÷ǽ·ΪԳģʽ*/ + } + else + {/*Գ*/ + (void)SetNonRouteRunModeById(nonRouteId,NONROUTE_RUN_MODE_APPLY); /*÷ǽ·Ϊźģʽ*/ + } + } + else + { + /*޲*/ + } + } + else + { /*ʧ*/ + } +} + + +/* +* ȡǽ·߼ +* ˵ +* ֵ +*/ +void CancelNonRouteM(UINT8 nonRouteId) +{ + /*ʼ*/ + UINT8 ciFunctionSwitchConfig = 0u; + UINT8 routeCancelFlag = 0u; + UINT8 routeHaveCancelFlag = 0u; + UINT8 routeRunMode = 0u; + UINT8 trainRelayState = 0u; + UINT16 tryTrainRelayId = 0u; + UINT8 nonRouteState = 0u; + UINT8 CLDSQJStatus = 0u; + UINT8 retvalue = CI_ERROR; + + /*ȡ״̬*/ + routeCancelFlag = GetNonRouteCancelFlagById(nonRouteId); + routeHaveCancelFlag = GetNonRouteHaveCancelFlagById(nonRouteId); + + + if (NONROUTE_CANCEL_FLAG_YES == routeCancelFlag) + { /*ȡ־Ч*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause the NONROUTE_CALCEL_FLAG is YES.",nonRouteId); + retvalue = CI_ERROR; + } + else + { + retvalue = CI_SUCCESS; + } + + if(CI_SUCCESS == retvalue) + { + if (NONROUTE_CANCEL_FLAG_YES == routeHaveCancelFlag) + { /*ȡ־Ч*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause the NONROUTE_HAVE_CALCEL_FLAG is YES.",nonRouteId); + retvalue = CI_ERROR; + } + else + { + } + } + else + { + } + + if(CI_SUCCESS == retvalue) + { + /*ȡģʽͨŷʽ*/ + routeRunMode = GetNonRouteRunModeById(nonRouteId); + ciFunctionSwitchConfig = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE); + tryTrainRelayId = GetNonRouteAppTryRelayIdById(nonRouteId); + trainRelayState = GetRelayCollState(tryTrainRelayId); + CLDSQJStatus = GetCommTrainTestCLDSQJStatus(); + + /*źģʽҼ̵ģʽ£̵£ͨģʽ豸Ч*/ + if (((NONROUTE_RUN_MODE_APPLY == routeRunMode) && + ((RELAY_STATE_DOWN == trainRelayState) && (SCX_CLD_INTERFACE_RELAY == ciFunctionSwitchConfig))) + || ((COMM_TRAIN_TEST_DEV_STATE_VALID == CLDSQJStatus) && ((SCX_CLD_INTERFACE_COMM == ciFunctionSwitchConfig) + || (SCX_CLD_SERIAL_PORT_COMM == ciFunctionSwitchConfig)))) + { /*źģʽδԳ*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause the mode is APPLY,and ApplyTryTrain is not finished.",nonRouteId); + retvalue = CI_ERROR; + } + else + { + } + } + else + { + } + if(CI_SUCCESS == retvalue) + { + nonRouteState = GetNonRouteStateById(nonRouteId); + if ((NONROUTE_STATE_XUANPAI != nonRouteState) && + (NONROUTE_STATE_LOCK != nonRouteState) && + (NONROUTE_STATE_LOCKERR != nonRouteState) && + (NONROUTE_STATE_OPEN != nonRouteState)) + { /*ǽ·״̬Ϊѡ||||||*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause the nonRoute state is %d.",nonRouteId,GetNonRouteStateById(nonRouteId)); + retvalue = CI_ERROR; + } + else + { + } + } + else + { + } + if(CI_SUCCESS == retvalue) + { + (void)SetNonRouteCancelFlagById(nonRouteId,NONROUTE_CANCEL_FLAG_YES); /*÷ǽ·ȡ־*/ + } + else + { + } +} + + +/* +* ȡǽ·߼ +* ˵ +* ֵ +*/ +void FaultCancelNonRouteM(UINT8 nonRouteId) +{ + /*ʼ*/ + UINT8 ciFunctionSwitchConfig = 0u; + UINT8 routeCancelFlag = 0u; + UINT8 routeHaveCancelFlag = 0u; + UINT8 routeRunMode = 0u; + UINT8 trainRelayState = 0u; + UINT16 tryTrainRelayId = 0u; + UINT8 faultCancelState = 0u; + UINT8 CLDSQJStatus = 0u; + UINT8 nonRouteState = 0u; + UINT8 signalAllClose = 0u; + UINT8 retvalue = CI_ERROR; + + /*ȡȡ־״̬*/ + routeCancelFlag = GetNonRouteCancelFlagById(nonRouteId); + routeHaveCancelFlag = GetNonRouteHaveCancelFlagById(nonRouteId); + + if (NONROUTE_CANCEL_FLAG_YES == routeCancelFlag) + { /*ȡ־Ч*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause the NONROUTE_CALCEL_FLAG is YES.",nonRouteId); + retvalue = CI_ERROR; + } + else + { + retvalue = CI_SUCCESS; + } + if(CI_SUCCESS == retvalue) + { + if (NONROUTE_CANCEL_FLAG_NO == routeHaveCancelFlag) + { /*ȡ־Ч*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause the NONROUTE_HAVE_CALCEL_FLAG is YES.",nonRouteId); + retvalue = CI_ERROR; + } + } + if(CI_SUCCESS == retvalue) + { + /*ȡģʽͨŷʽ*/ + routeRunMode = GetNonRouteRunModeById(nonRouteId); + ciFunctionSwitchConfig = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE); + tryTrainRelayId = GetNonRouteAppTryRelayIdById(nonRouteId); + trainRelayState = GetRelayCollState(tryTrainRelayId); + CLDSQJStatus = GetCommTrainTestCLDSQJStatus(); + + /*źģʽҼ̵ģʽ£̵£ͨģʽ豸Ч*/ + if (((NONROUTE_RUN_MODE_APPLY == routeRunMode) && + ((RELAY_STATE_DOWN == trainRelayState) && (SCX_CLD_INTERFACE_RELAY == ciFunctionSwitchConfig))) + || ((COMM_TRAIN_TEST_DEV_STATE_VALID == CLDSQJStatus) && ((SCX_CLD_INTERFACE_COMM == ciFunctionSwitchConfig) + || (SCX_CLD_SERIAL_PORT_COMM == ciFunctionSwitchConfig)))) + { + /*źģʽδԳ*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause the mode is APPLY,and ApplyTryTrain is not finished.",nonRouteId); + retvalue = CI_ERROR; + } + } + if(CI_SUCCESS == retvalue) + { + nonRouteState = GetNonRouteStateById(nonRouteId); + if (NONROUTE_STATE_LOCKERR != nonRouteState) + { /*ǽ·״̬*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause nonRoute STATE is %d, not NONROUTE_STATE_LOCKERR.",nonRouteId,GetNonRouteStateById(nonRouteId)); + retvalue = CI_ERROR; + } + } + if(CI_SUCCESS == retvalue) + { + signalAllClose = CheckNonRouteSignalAllClose(nonRouteId); + if (CI_ERROR == signalAllClose) + { /*ǽ·źſ*/ + debug_infor_printf((const)"CancelNonRouteM %d failed, cause CheckNonRouteSignalAllClose failed.",nonRouteId); + retvalue = CI_ERROR; + } + } + + if(CI_SUCCESS == retvalue) + { + faultCancelState = FaultCancelNonRouteP(nonRouteId); + /*ȡǽ·*/ + if (CI_SUCCESS == faultCancelState) + { + (void)SetNonRouteStateById(nonRouteId,NONROUTE_STATE_FAULTDELAY_UNLOCK); /*÷ǽ·Ϊʱ*/ + } + } + +} + + +/* +* ֹͣ +* ˵ void +* ֵ +*/ +void SetStopCheckM(void) +{ + SetStopCheckFlag(); /*ֹͣ*/ +} + + +/* +* ȡֹͣ +* ˵ void +* ֵ +*/ +void CancelStopCheckM(void) +{ + CancelStopCheckFlag(); /*ȡֹͣ*/ +} + + +/* +* ·ȡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongQuXiaoDeal(const UINT16 routeId) +{ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 routeType = 0u; /*·*/ + + + /*ȡ·ֶ̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + startSignalId = GetRouteStartSignalId(routeId); + + /*###ź*/ + if (GetSignalOpenCloseState(GetSignalCurColor(startSignalId)) == SIGNAL_OPEN) + { /*źδر*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ + return; + } + else + { /*źѹر*/ + + SetRouteZongQuXiaoFlag(routeId, ROUTE_ZONGQUXIAO_SET_NO); /*ȡ·ȡ־*/ + } + + + /*###ȡ·*/ + if (ROUTE_STATE_IDLE == routeState) + { /*·*/ + + CancelLongRouteXuanPai(routeId); /*ȡ·ѡ*/ + } + else if (ROUTE_STATE_XUANPAI == routeState) + { /*·ѡ*/ + + CancelRouteXuanPai(routeId); /*ȡ·ѡ*/ + } + else if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState)) + { /*·||·쳣||·Ԥ*/ + + routeType = GetRouteType(routeId); /*ȡ·*/ + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + if (CI_SUCCESS == RouteCancelLogicProcess(routeId)) + { /*ȡг·ɹ*/ + + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + else + { /*ȡʧ*/ + } + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + + if (CI_SUCCESS == CancelDTrainRouteP(routeId)) + { /*ȡ·ɹ*/ + + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + else + { /*ȡʧ*/ + } + } + else + { /*·ʹ*/ + } + } + else if ((ROUTE_STATE_NEAR_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState)) + { + /*ӽ*/ + SetCiSendCmdBackInfoData(CI_BACK_ROUTE_NEAR_LOCK_YES,CI_DEVICE_TYPE_ROUTE,routeId,0,0); + } + else if ((ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState) || + (ROUTE_STATE_LEAD_XUANPAI == routeState)) + { + /*·ȡϢ*/ + } + else + { + /*δ*/ + SetCiSendCmdBackInfoData(CI_BACK_ROUTE_LOCK_NOTALL,CI_DEVICE_TYPE_ROUTE,routeId,0,0); + } +} + + +/* +* ·˽⴦ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongRenJieDeal(const UINT16 routeId) +{ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 routeType = 0u; /*·*/ + + UINT8 checkResult = 0u;/*Ƿгռ*/ + UINT16 firstOccuSecId = 0u;/*·ڷһռõID*/ + UINT8 devState = 0u; + UINT8 trainEnterSta = 0u;/*·гʻ־*/ + /*UINT8 zrjCloseSigFlag;*//*˽⵼¹źű־*/ + UINT8 zrjExe = CI_ERROR;/*˽ִܷ*/ + UINT8 checkResultSecAndQXZC = 0u; /*RouteExceptLastSecOccuClrCheck˺ļ*/ + + /*ȡ·ֶ̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + startSignalId = GetRouteStartSignalId(routeId); + + if (GetSignalOpenCloseState(GetSignalCurColor(startSignalId)) == SIGNAL_OPEN) + { /*źδر*/ + + (void)DriveSignalClose(startSignalId); /*źŹر*/ +#if 0 + SetRouteZongRenJieCloseFlag(routeId, ROUTE_ZRJ_CLOSE_FLAG_YES);/*·źŹر˽⵼*/ +#endif + return; + } + else + { /*źѹر*/ + + (void)SetRouteZongRenJieFlag(routeId, ROUTE_ZONGRENJIE_SET_NO); /*ȡ·˽־*/ +#if 0 + zrjCloseSigFlag = GetRouteZongRenJieCloseFlag(routeId);/*ȡ·˽źű־*/ + SetRouteZongRenJieCloseFlag(routeId, ROUTE_ZRJ_CLOSE_FLAG_NO);/**/ +#endif + } + + trainEnterSta = GetRouteTrainEnterFlag(routeId); + routeType = GetRouteType(routeId); /*ȡ·*/ + + if (ROUTE_TYPE_DIAOCHE==routeType) + { + checkResult = CheckDTrainRoutePhySecOccupy(routeId, EFUNC_ROUTE_ZRJ_DEAL, ESEND_LEVEL_ZERO); + } + else if (ROUTE_TYPE_LIECHE == routeType) + { + checkResult = RouteAllSecOccuClearCheck(routeId, &firstOccuSecId, &devState); + } + else + { + /*ʲô*/ + } + + /*˽·*/ + if (ROUTE_STATE_IDLE == routeState) + { /*·*/ + + CancelLongRouteXuanPai(routeId); /*ȡ·ѡ*/ + } + else if (ROUTE_STATE_XUANPAI == routeState) + { /*·ѡ*/ + + CancelRouteXuanPai(routeId); /*ȡ·ѡ*/ + } + else if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState)) + { /*·||·쳣||·Ԥ*/ + + zrjExe = CheckRouteZongRenJieFeasibility(routeId); + if (CI_SUCCESS == zrjExe) + { + if (CI_SUCCESS == checkResult) + {/*ռ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + else + { + if (ROUTE_TRAIN_ENTER_FLAG_NO == trainEnterSta) + {/*޳ʻ룬ȫ̹*/ + /*·α̹*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_EXCEPT); + + /*·߼ζ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_EXCEPT); + } + else + {/*̹*/ + SetRoutePhySecExpLockToOccupy(routeId); + } + + SetRouteStateDeal(routeId, ROUTE_STATE_AUTO_UNLOCKERR); + } + } + else + { + /*·ȡ*/ + } + } + else if ((ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState)) + { /*·||·쳣*/ + /*˽·ԭ޸20180809 + ·ڷлһռʱ + һռʻ룬ʱ*/ + checkResultSecAndQXZC = RouteExceptLastSecOccuClrCheck(routeId); + if (CI_SUCCESS == checkResultSecAndQXZC) + { /*οлһռ*/ + + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + else if ((ROUTE_TRAIN_ENTER_FLAG_NO == trainEnterSta) && (CI_ERROR_QXZC != checkResultSecAndQXZC)) + { /*гδʻҷһΣʱ*/ + SetRouteStateManage(routeId, ROUTE_STATE_DELAY_UNLOCK); /*ý·ʱ*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_IDLE); /*ʱν*/ + } + else + { + /**/ + } + } + else if (ROUTE_STATE_NEAR_LOCKERR == routeState) + { + zrjExe = CheckRouteZongRenJieFeasibility(routeId); + + /*˽ִ*/ + if (CI_SUCCESS==zrjExe) + { + SetRouteStateDeal(routeId, ROUTE_STATE_DELAY_UNLOCK); /*ý·״̬Ϊʱ*/ + + if (CI_SUCCESS == checkResult) + { + /*޳ռãʱȫ*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_IDLE); + } + else + { + if (ROUTE_TRAIN_ENTER_FLAG_NO == trainEnterSta) + { + /*гʻʱȫ̹*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_ALL_EXP); + } + else + { + /*̹*/ + SetRouteZongRenJieDelayType(routeId, ROUTE_ZRJ_DELAY_TYPE_EXP_TO_OCCUPY); + } + } + } + } + else + { + /*·˽*/ + /*·״̬*/ + /* ¼ */ + SetErrorData(EFUNC_ROUTE_ZRJ_DEAL, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, routeState, ESEND_LEVEL_ATS); + } +} + + +/* +* ǽ·ȡ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ void +*/ +void NonRouteCancelDeal(UINT8 nonRouteId) +{ + UINT8 nonRouteState = 0u; /*·״̬*/ + + if (CI_ERROR == CheckNonRouteSignalAllClose(nonRouteId)) + { /*ǽ·źſ*/ + + DriveNonRouteSignalClose(nonRouteId); /*ǽ·źŹر*/ + return; + } + + (void)SetNonRouteHaveCancelFlagById(nonRouteId,NONROUTE_CANCEL_FLAG_YES);/*÷ǽ·ȡ־*/ + (void)SetNonRouteCancelFlagById(nonRouteId,NONROUTE_CANCEL_FLAG_NO); /*ǽ·ȡ־*/ + + nonRouteState = GetNonRouteStateById(nonRouteId); /*ȡǽ·״̬*/ + + if (NONROUTE_STATE_XUANPAI == nonRouteState) + { /*ѡ*/ + + CancelNonRouteXuanPai(nonRouteId); /*ȡǽ·ѡ*/ + } + else if (NONROUTE_STATE_LOCK == nonRouteState) + { /**/ + + if (CI_SUCCESS == CancelNonRouteP(nonRouteId)) + { + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_DELAY_UNLOCK); /*÷ǽ·Ϊʱ*/ + } + else + { + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_LOCKERR); /*÷ǽ·*/ + } + } + else if (NONROUTE_STATE_LOCKERR == nonRouteState) + { /**/ + + if (CI_SUCCESS == CancelNonRouteP( nonRouteId)) + { + SetNonRouteStateDeal(nonRouteId,NONROUTE_STATE_DELAY_UNLOCK); /*÷ǽ·Ϊʱ*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + + +/* +* ղ̵ +* ˵ + const UINT16 routeId, UINT8 routeState +* ֵ + CI_ERROR + CI_SUCCESS +*/ +void UpdateZhaoChaDeal(const UINT16 routeId, const UINT8 routeState) +{ + UINT16 wSelfRealyId = 0U; /*ģʽղID*/ + UINT16 wOtherRealyId = 0U; /*ģʽղID*/ + UINT8 relauDrvState = 0U; + UINT8 chRouteLevel = GetRouteLevel(routeId); + UINT8 chOverTimeCheck = 0U; + UINT32 dwTimeOutCycCount = 0U; + + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + wSelfRealyId = GetRouteThisZhaoChaRelayId(routeId); /*ģʽղ̵ID*/ + wOtherRealyId = GetRouteCbtcThisZhaoChaRelayId(routeId); /*CBTCģʽղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + wSelfRealyId = GetRouteCbtcThisZhaoChaRelayId(routeId); /*CBTCģʽղ̵ID*/ + wOtherRealyId = GetRouteThisZhaoChaRelayId(routeId); /*ģʽղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + + dwTimeOutCycCount = GetSystemParaSignalCloseCyc(); + + if ((routeState == ROUTE_STATE_IDLE) || + (routeState == ROUTE_STATE_FIRST_XUANPAI) || + (routeState == ROUTE_STATE_XUANPAI) || + (routeState == ROUTE_STATE_LEAD_FIRST_XUANPAI) || + (routeState == ROUTE_STATE_LEAD_XUANPAI)) + { + /*· ģʽղ鶼*/ + if (0U < wSelfRealyId) + { + relauDrvState = GetRelayDriveState(wSelfRealyId); + if (RELAY_DRIVE_STATE_NULL == relauDrvState) + { + (void)SetRelayDriveState(wSelfRealyId, RELAY_STATE_UP); + } + } + if (0U < wOtherRealyId) + { + relauDrvState = GetRelayDriveState(wOtherRealyId); + if (RELAY_DRIVE_STATE_NULL == relauDrvState) + { + (void)SetRelayDriveState(wOtherRealyId, RELAY_STATE_UP); + } + } + } + else + { + /*· ģʽղ£һģʽղ*/ + if (0U < wOtherRealyId) + { + relauDrvState = GetRelayDriveState(wOtherRealyId); + if (RELAY_DRIVE_STATE_NULL == relauDrvState) + { + (void)SetRelayDriveState(wOtherRealyId, RELAY_STATE_UP); + } + } + if (0U < wSelfRealyId) + { + (void)SetRelayDriveState(wSelfRealyId, RELAY_STATE_DOWN); + relauDrvState = GetRelayCollState(wSelfRealyId); + if (RELAY_STATE_DOWN != relauDrvState) + { /*ղ̵δ*/ + chOverTimeCheck = CheckRelayDriveOutTime(wSelfRealyId, dwTimeOutCycCount); + if (CI_ERROR == chOverTimeCheck) + {/*ղ鳬ʱʱ*/ + + /*xxxxx崻*/ + SetPlatOverFlag(); /*ƽ̨崻*/ + SetErrorData(EFUNC_PLAT_OVER, CI_DEVICE_TYPE_RELAY, wSelfRealyId, ETYPE_ZHAOCHA_ROUTE_OVERTIME, RELAY_STATE_UP, ESEND_LEVEL_ZERO);/*¼崻*/ + } + } + } + } +} + + + +/* +* ǽ· +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 NonRouteLockDrvSwitchDeal(const UINT8 nonRouteId) +{ + UINT16 switchId = 0u; /*ID*/ + UINT8 switchPos = 0u; /*λ*/ + UINT8 switchSum = 0u; /**/ + NonRouteSwitchStruct* pNonRouteSwitchStru = NULL; /**/ + UINT8 protectSwitchSum = 0u; /**/ + NonRouteProtectSwitchStruct* pNonRouteProtectSwitchStru = NULL; /**/ + UINT8 switchDancaoPosition = 0u; + UINT8 ii = 0u; + + switchSum = GetNonRouteSwitchSumById(nonRouteId); /*ǽ·*/ + pNonRouteSwitchStru = GetNonRouteSwitchStructBufById(nonRouteId); /*ǽ·*/ + protectSwitchSum = GetNonRouteRelatedProtSwitSum(nonRouteId); /*ǽ·*/ + pNonRouteProtectSwitchStru = GetNonRouteRelatedProtSwitStru(nonRouteId); /*ǽ·*/ + + if ((0u == switchSum) || (NULL == pNonRouteSwitchStru)) + { + return CI_ERROR; + } + + /* ǽ·෴λȡ· */ + for (ii = 0u; ii < switchSum; ii++) + { + switchId = pNonRouteSwitchStru[ii].SwitchId; + switchPos = pNonRouteSwitchStru[ii].SwitchPos; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + + if ((switchDancaoPosition == SWITCH_POSITION_INVALID) + || (switchDancaoPosition == switchPos)) + { + /*Ч λ붯λһ*/ + continue; + } + else + { + /*ٵ෴λȡ·*/ + return CI_ERROR; + } + } + + /* ǽ·෴λȡ· */ + for (ii = 0u; ii < protectSwitchSum; ii++) + { + switchId = pNonRouteProtectSwitchStru[ii].ProtectSwitchId; + switchPos = pNonRouteProtectSwitchStru[ii].ProtectPosition; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + + if ((switchDancaoPosition == SWITCH_POSITION_INVALID) + || (switchDancaoPosition == switchPos)) + { + /*Ч λ붯λһ*/ + continue; + } + else + { + /*ٵ෴λȡ·*/ + return CI_ERROR; + } + } + + /**/ + for (ii = 0u; ii < switchSum; ii++) + { + switchId = pNonRouteSwitchStru[ii].SwitchId; + switchPos = pNonRouteSwitchStru[ii].SwitchPos; + + (void)SwitchDriveProcess(switchId, switchPos); /**/ + } + + for (ii = 0u; ii < protectSwitchSum; ii++) + { + switchId = pNonRouteProtectSwitchStru[ii].ProtectSwitchId; + switchPos = pNonRouteProtectSwitchStru[ii].ProtectPosition; + + (void)SwitchDriveProcess(switchId, switchPos); /**/ + } + + return CI_SUCCESS; +} + + +/* +* ιϽ쳣մ +* ˵ UINT16 phySecId ID +* ֵ1 +* 0: +*/ +void PhySecFaultRelatedUnLockDeal(const UINT16 phySecId, const UINT16 belongRouteId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *RouteSecStru = NULL; /**/ + UINT8 ii= 0u; + + + sectionSum = GetRoutePhysicalSectionSum(belongRouteId); /*ý·Ŀ*/ + RouteSecStru = GetRouteSectionData(belongRouteId); /*·*/ + + if (0u == sectionSum) + { + return; + } + + for (ii = 0u; ii < sectionSum; ii++) + { + if ((PHYSICAL_SECTION_LOCK_NORMAL == GetPhySecLockState(RouteSecStru[ii].PhysicalSectionId)) && + (belongRouteId == GetPhySecRLockBelongRouteId(RouteSecStru[ii].PhysicalSectionId))) + { /*Ϊ·*/ + + SetPhySecLockState(RouteSecStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_EXCEPT, 0, 0); /*쳣*/ + } + else + { + } + } +} + +#if 0 +void PhySecFaultRelatedUnLockDeal(const UINT16 phySecId, const UINT16 belongRouteId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *RouteSecStru = NULL; /**/ + UINT8 phySecOccupyIndex = 0xFF; /*ռ±*/ + UINT8 ii= 0u; + + + sectionSum = GetRoutePhysicalSectionSum(belongRouteId); /*ý·Ŀ*/ + RouteSecStru = GetRouteSectionData(belongRouteId); /*·*/ + + if ((0u == sectionSum) || (NULL == RouteSecStru)) + { + return; + } + else + { + } + + for (ii = 0u; ii < sectionSum; ii++) + { + if (phySecId == RouteSecStru[ii].PhysicalSectionId) + { /*ҵ*/ + + phySecOccupyIndex = ii; + break; + } + else + { + } + } + + if (0xFFu == phySecOccupyIndex) + { + return; + } + else + { + } + + /*ѽ*/ + for (ii = 0u; ii < phySecOccupyIndex; ii++) + { + if ((PHYSICAL_SECTION_LOCK_NORMAL == GetPhySecLockState(RouteSecStru[phySecOccupyIndex-1-ii].PhysicalSectionId)) && + (belongRouteId == GetPhySecRLockBelongRouteId(RouteSecStru[phySecOccupyIndex-1-ii].PhysicalSectionId))) + { /*Ϊ·*/ + + if (PHYSICAL_SEC_TYPE_NOSWITCH == GetPhySecType(RouteSecStru[phySecOccupyIndex-1-ii].PhysicalSectionId)) + { /*޲*/ + + SetPhySecLockState(RouteSecStru[phySecOccupyIndex-1-ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, belongRouteId, GetRouteDirection(belongRouteId)); /*δ*/ + } + else + { /*в*/ + + SetPhySecLockState(RouteSecStru[phySecOccupyIndex-1-ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_EXCEPT, 0, 0); /*쳣*/ + break; + } + } + else + { + break; + } + } + + /*ѽҲ*/ + for (ii = phySecOccupyIndex+1u; ii < sectionSum; ii++) + { + if ((PHYSICAL_SECTION_LOCK_NORMAL == GetPhySecLockState(RouteSecStru[ii].PhysicalSectionId)) && + (belongRouteId == GetPhySecRLockBelongRouteId(RouteSecStru[ii].PhysicalSectionId))) + { /**/ + + if (PHYSICAL_SEC_TYPE_NOSWITCH == GetPhySecType(RouteSecStru[ii].PhysicalSectionId)) + { /*޲*/ + + SetPhySecLockState(RouteSecStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_NO, belongRouteId, GetRouteDirection(belongRouteId)); /*δ*/ + } + else + { /*в*/ + + SetPhySecLockState(RouteSecStru[ii].PhysicalSectionId, PHYSICAL_SECTION_LOCK_EXCEPT, 0u, 0u); /*쳣*/ + break; + } + } + else + { + break; + } + } +} +#endif + + + +/* +* ý·״̬ +* ˵ UINT16 routeId · +* ֵvoid +*/ +void SetRouteStateDeal(const UINT16 routeId, const UINT8 routeState) +{ + UINT8 cSGBJDelayOpenFlag = 0U; /*ⱨʱű־*/ + UINT8 cRelZuHeSGBJDelayOpenFlag = 0U; /*Ͻ·ⱨʱű־*/ + UINT32 dwCurDelayOpenStartCycNum = 0U; /*·ⱨʱʼ*/ + UINT32 dwCurCycNum = 0U; + + dwCurCycNum = Get2oo2CurCycleNum(); + + if (ROUTE_STATE_IDLE == routeState) + { /*·*/ + + SetRouteStopFlagManage(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + + if (GetRouteBelongLongRouteId(routeId) > 0u) + { + SetLongRouteStateDeal(GetRouteBelongLongRouteId(routeId), ROUTE_LONG_STATE_IDLE); /*-->ó·*/ + } + else + { + } + + SetRouteBelongLongRouteId(routeId, 0u); /*·*/ + + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_INIT);/*Ҳ·ָ״̬һν·״̬ת*/ + + SetTrainEnterRouteFlag(routeId,TRAIN_ENTER_ROUTE_FLAG_NO);/*·кгʻ·־*/ + + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_CANCEL); /*ȡ·ķ*/ + + /*ùϽ·ⱨʱ־Ч*/ + SetRelZuHeRouteSGBJDelayFlag(routeId, ROUTE_SGBJ_DELAY_OPEN_VALID); + + /*ý·ⱨ־Ч*/ + SetRouteDriveSGBJFlag(routeId, ROUTE_DRIVE_SGBJ_INVALID); + + /*ý·δⱨ*/ + SetRouteHasDrivedSGBJFlag(routeId, ROUTE_HAS_DRIVED_SGBJ_INVALID); + } + else if (ROUTE_STATE_XUANPAI == routeState) + { /*·ѡ*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_YES); /*ý·*/ +#if 0 + SetRouteStopFlagManage(routeId,ROUTE_STOPCHECK_SET_YES);/*ý·ֹͣ־*/ +#endif + } + else if (ROUTE_STATE_FIRST_LOCK ==routeState) + { /*·*/ + + SetRouteBelongLongRouteId(routeId, 0u); /*·*/ + + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NORMAL); /*ý·*/ + + /*ý·߼: */ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NORMAL); + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /*ý·δ*/ + + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_SET); /*ý·Ϊ*/ + + /*·صλ*/ + ClearRouteSwitchDrivePos(routeId); + + /*·صλ*/ + ClearRouteSwitchDanCaoPos(routeId); + + SetRouteRecoverState(routeId, ROUTE_RECOVER_STA_INIT);/*ζգ׼ź*/ + + /*ⱨʱʼʱ*/ + cSGBJDelayOpenFlag = GetRouteSGBJDelayFlag(routeId); + cRelZuHeSGBJDelayOpenFlag = GetRelZuHeRouteSGBJDelayFlag(routeId); + dwCurDelayOpenStartCycNum = GetRouteDelayOpenStartCyc(routeId); + + if ((0U == dwCurDelayOpenStartCycNum) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cSGBJDelayOpenFlag) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cRelZuHeSGBJDelayOpenFlag)) + { + SetRouteDelayOpenStartCyc(routeId, dwCurCycNum); + SetRouteOpenSigStartCycNum(routeId, 0U); /*ⱨʱ·źſʱ䣬ⱨʱ½·źſʱ䳬*/ + } + else if ((ROUTE_SGBJ_DELAY_OPEN_VALID != cSGBJDelayOpenFlag) || (ROUTE_SGBJ_DELAY_OPEN_VALID != cRelZuHeSGBJDelayOpenFlag)) + { + SetRouteOpenSigStartCycNum(routeId, dwCurCycNum); /*źſʱ*/ + } + else + { + /*ʱʼڣ*/ + } + } + else if (ROUTE_STATE_YUXIAN_OPEN ==routeState) + { /*·Ԥȿ*/ + + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*ȡ·źؿ־*/ + + (void)CleanRoutePhySecPreOccupyState(routeId); /*·֮ǰռ״̬*/ + (void)SetRouteStopKeepCheckFlag(routeId, GetRouteStopCheckFlag(routeId)); /*ý·ֹͣ鱣ֱ־*/ + (void)SetRouteStopCheckFlag(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + SetTrainEnterRouteFlag(routeId,TRAIN_ENTER_ROUTE_FLAG_NO);/*·кгʻ·־*/ + } + else if (ROUTE_STATE_NEAR_OPEN ==routeState) + { /*·ӽ*/ + + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*ȡ·źؿ־*/ + + (void)CleanRoutePhySecPreOccupyState(routeId); /*·֮ǰռ״̬*/ + if ( ROUTE_STOPCHECK_SET_YES == GetRouteStopCheckFlag(routeId)) + { + (void)SetRouteStopKeepCheckFlag(routeId, GetRouteStopCheckFlag(routeId)); /*ý·ֹͣ鱣ֱ־*/ + (void)SetRouteStopCheckFlag(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + } + else + { + } + + SetTrainEnterRouteFlag(routeId,TRAIN_ENTER_ROUTE_FLAG_NO);/*·źгʻ·־*/ + + } + else if (ROUTE_STATE_LEAD_XUANPAI == routeState) + {/*·ѡ*/ + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_YES); /*ý·*/ + } + else if (ROUTE_STATE_LEAD_LOCK ==routeState) + { /*·*/ + + SetRouteBelongLongRouteId(routeId, 0u); /*·*/ + + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NORMAL); /*ý·*/ + + /*ý·߼: */ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NORMAL); + + SetRoutePhySectionOccupyState(routeId, PHYSICAL_SECTION_USING_NO); /*ý·δ*/ + + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_SET); /*ý·Ϊ*/ + + SetRouteOpenSigStartCycNum(routeId, Get2oo2CurCycleNum()); /*źſʱ*/ + + /*ⱨʱʼʱ*/ + cSGBJDelayOpenFlag = GetRouteSGBJDelayFlag(routeId); + dwCurDelayOpenStartCycNum = GetRouteDelayOpenStartCyc(routeId); + if ((0U == dwCurDelayOpenStartCycNum) && (ROUTE_SGBJ_DELAY_OPEN_VALID == cSGBJDelayOpenFlag)) + { + SetRouteDelayOpenStartCyc(routeId, dwCurCycNum); + SetRouteOpenSigStartCycNum(routeId, 0U); /*ⱨʱ·źſʱ䣬ⱨʱ½·źſʱ䳬*/ + } + else + { + /*ʱʱʼڣ*/ + } + + /*·صλ*/ + ClearRouteSwitchDrivePos(routeId); + + /*·صλ*/ + ClearRouteSwitchDanCaoPos(routeId); + } + else if (ROUTE_STATE_LEAD_LOCKERR ==routeState) + { /*·쳣*/ + + SetRouteLeadFaultOpenStartCyc(routeId, 0u); /*ʱʱ*/ + } + else if (ROUTE_STATE_LEAD_OPEN ==routeState) + { /*·*/ + + SetRouteOpenSigStartCycNum(routeId, 0u); /*źſʱ*/ + + SetRouteRepeatOpenFlag(routeId, ROUTE_REPEATOPEN_SET_NO); /*ȡ·źؿ־*/ + + (void)CleanRoutePhySecPreOccupyState(routeId); /*·֮ǰռ״̬*/ + (void)SetRouteStopKeepCheckFlag(routeId, GetRouteStopCheckFlag(routeId)); /*ý·ֹͣ鱣ֱ־*/ + (void)SetRouteStopCheckFlag(routeId, ROUTE_STOPCHECK_SET_NO); /*·ֹͣ־*/ + } + else if (ROUTE_STATE_DELAY_UNLOCK == routeState) + { /*·ʱ*/ + + } + else + {/**/ + } + + (void)SetRouteState(routeId, routeState); /*ý·״̬*/ +} + + +/* +* ó·״̬ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +void SetLongRouteStateDeal(const UINT16 longRouteId, const UINT8 longRouteState) +{ + UINT8 subRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + + subRouteSum = GetLongRouteSubRouteSum(longRouteId); /*ӽ·*/ + pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(longRouteId); /*ӽ·*/ + + if (subRouteSum <= 1u) + { + return; + } + + + if (ROUTE_LONG_STATE_IDLE == longRouteState) + { /**/ + + for (ii = 0u; ii < subRouteSum; ii++) + { + SetRouteBelongLongRouteId(pSubRouteIdBuf[ii], 0u); /*ӽ·*/ + + SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); /*ӽ·*/ + } + } + else if (ROUTE_LONG_STATE_XUANPAI == longRouteState) + { /*ѡ*/ + + } + else if (ROUTE_LONG_STATE_LOCK ==longRouteState) + { /**/ + + for (ii = 0u; ii < subRouteSum; ii++) + { + SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); /*ӽ·*/ + } + } + else + { + return; + } + + /*ó״̬*/ + (void)SetLongRouteState(longRouteId, longRouteState); +} + + +/* +* ÷ǽ·״̬ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +void SetNonRouteStateDeal(UINT8 nonRouteId,const UINT8 nonRouteState) +{ + UINT8 execRes = CI_ERROR; + if (NONROUTE_STATE_IDLE == nonRouteState) + { /*ǽ·*/ + + execRes = SetNonRouteCancelFlagById(nonRouteId,NONROUTE_CANCEL_FLAG_NO); /*ǽ·ȡ־*/ + + execRes &= SetNonRouteHaveCancelFlagById(nonRouteId,NONROUTE_CANCEL_FLAG_NO);/*÷ǽ·ȡ־*/ + + SetNonRouteSigOpenStartCycById(nonRouteId,0u); /*ǽ·źſʱ*/ + + SetNonRoutePhySecUsingState(nonRouteId,PHYSICAL_SECTION_USING_NO); /*÷ǽ·δ*/ + + SetNonRoutePhySecLockState(nonRouteId,PHYSICAL_SECTION_LOCK_NO); /*÷ǽ·δ*/ + + SetNonRouteLogSecLockState(nonRouteId, LOG_SECTION_LOCK_NO); /*÷ǽ·߼δ*/ + + execRes &= SetNonRouteRelatedProtSwLockSta(nonRouteId,SWITCH_LOCK_PROTECT_CANCEL);/*ȡǽ·*/ + if (CI_ERROR == execRes) + { + /*ʱ*/ + } + } + else if (NONROUTE_STATE_XUANPAI == nonRouteState) + { /*ǽ·ѡ*/ + + SetNonRoutePhySecUsingState(nonRouteId,PHYSICAL_SECTION_USING_YES); /*÷ǽ·*/ + } + else if (NONROUTE_STATE_LOCK ==nonRouteState) + { /*ǽ·*/ + + SetNonRoutePhySecUsingState(nonRouteId,PHYSICAL_SECTION_USING_NO); /*÷ǽ·δ*/ + + SetNonRoutePhySecLockState(nonRouteId,PHYSICAL_SECTION_LOCK_NORMAL); /*÷ǽ·*/ + + SetNonRouteLogSecLockState(nonRouteId, LOG_SECTION_LOCK_NORMAL); /*÷ǽ·߼*/ + + execRes = SetNonRouteRelatedProtSwLockSta(nonRouteId,SWITCH_LOCK_PROTECT_SET);/*÷ǽ·*/ + + execRes &= SetNonRouteStateById(nonRouteId,NONROUTE_STATE_LOCK); /*÷ǽ·Ϊ*/ + + SetNonRouteSigOpenStartCycById(nonRouteId,Get2oo2CurCycleNum()); /*÷ǽ·źſʱ*/ + + /*ǽ·λ*/ + execRes &= ClearNonRouteSwitchDrivePos(nonRouteId); + + /*ǽ·λ*/ + execRes &= ClearNonRouteSwitchDanCaoPos(nonRouteId); + + if (CI_ERROR == execRes) + { + /*ʱ*/ + } + } + else if (NONROUTE_STATE_LOCKERR ==nonRouteState) + { /*ǽ·쳣*/ + + } + else if (NONROUTE_STATE_OPEN ==nonRouteState) + { /*ǽ·*/ + + SetNonRouteSigOpenStartCycById(nonRouteId,0u); /*ǽ·źſʱ*/ + } + else if (NONROUTE_STATE_DELAY_UNLOCK ==nonRouteState) + { /*ǽ·ʱ*/ + + } + else if (NONROUTE_STATE_FAULTDELAY_UNLOCK ==nonRouteState) + { /*ǽ·ʱ*/ + + } + else + { + return; + } + + /*÷ǽ·״̬*/ + (void)SetNonRouteStateById(nonRouteId,nonRouteState); +} + +/* +* ÷ǽ·״̬ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +void SetNonRoutePhySecUsingState(UINT8 nonRouteId,const UINT8 usingState) +{ + UINT8 sectionSum = 0u; /**/ + NonRoutePhySectionStruct *pPhySecStruBuf = NULL; /**/ + UINT8 ii= 0u; + + UINT8 nonRouteProSwitchSum = 0u; /*ǽ·*/ + NonRouteProtectSwitchStruct* pNonRouteProSwitchData = NULL; /*ǽ·*/ + UINT16 switchId = 0u;/*ID*/ + UINT16 phyId = 0u; /*ID*/ + UINT8 reVal = CI_ERROR; + + sectionSum = GetNonRoutePhySectionSumById(nonRouteId); /*÷ǽ·Ŀ*/ + pPhySecStruBuf = GetNonRoutePhySecStruBufById(nonRouteId); /*ȡǽ·*/ + + nonRouteProSwitchSum = GetNonRouteRelatedProtSwitSum(nonRouteId);/*ȡǽ·*/ + pNonRouteProSwitchData = GetNonRouteRelatedProtSwitStru(nonRouteId);/*ȡǽ·*/ + + if ((0u == sectionSum) || (NULL == pPhySecStruBuf)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + if ((PHYSICAL_SECTION_USING_YES!=usingState) && + (PHYSICAL_SECTION_USING_NO!=usingState)) + { + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + { + for(ii = 0u; ii < sectionSum; ii++) + { + SetPhySecUseState(pPhySecStruBuf[ii].PhySectionId, usingState, 0u); /*÷ǽ·*/ + } + + for (ii=0u;iiNonRouteId); /*ǽ·*/ + pNonRouteSwitchStru = GetNonRouteSwitchStructBufById(pNonRoute->NonRouteId); /*ǽ·*/ + + if ((0u == switchSum) || (NULL == pNonRouteSwitchStru)) + { + return CI_ERROR; + } + + if (GetNonRouteStateById(pNonRoute->NonRouteId) == NONROUTE_STATE_IDLE) + { /*ǽ·*/ + + return CI_ERROR; + } + + for (ii = 0u; ii < switchSum; ii++) + { + if (switchId == pNonRouteSwitchStru[ii].SwitchId) + { /*ڷǽ·*/ + + return CI_SUCCESS; + } + } + } + return CI_ERROR; +} + + +/* +* ǽ·źŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: Ѱǽ· +* 1: Ѱǽ· +*/ +UINT8 CheckSignalBelongNonRoute(const UINT16 signalId) +{ + UINT8 sigSum = 0u; /*źŻ*/ + UINT16 *pSigIdBuf = NULL;/*ź*/ + UINT8 ii = 0u; + + NonRouteConfigDataStruct *pNonRoute = GetNonRouteConfigDataBySignalId(signalId); + if (pNonRoute !=NULL) + { + + sigSum = GetNonRouteSignalSumById(pNonRoute->NonRouteId); /*ȡǽ·źŻĿ*/ + pSigIdBuf = GetNonRouteSignalIdBufById(pNonRoute->NonRouteId); /*ȡǽ·źŻID*/ + + if ((0u == sigSum) || (NULL == pSigIdBuf)) + { + return CI_ERROR; + } + + if (GetNonRouteStateById(pNonRoute->NonRouteId) == NONROUTE_STATE_IDLE) + { /*ǽ·*/ + + return CI_ERROR; + } + + for (ii = 0u; ii < sigSum; ii++) + { + if (signalId == pSigIdBuf[ii]) + { /*ڷǽ·*/ + + return CI_SUCCESS; + } + } + } + + return CI_ERROR; +} + +/* +* ǽ·μ +* ˵ const UINT16 phySecId ID +* ֵ 0: Ѱǽ· +* 1: Ѱǽ· +*/ +UINT8 CheckPhySecBelongNonRoute(const UINT16 phySecId) +{ + UINT8 phySecSum = 0U; /**/ + NonRoutePhySectionStruct* pNonRoutePhySecStru = NULL; /**/ + UINT8 ii = 0U; + UINT8 retVal = CI_ERROR; + UINT8 nonRouteFlag = CI_ERROR; + UINT8 nonRouteState = 0U;/*ǽ·״̬*/ + + NonRouteConfigDataStruct* pNonRoute = GetNonRouteConfigDataByPhySecId(phySecId); + + + if (pNonRoute != NULL) + { + retVal = CI_SUCCESS; + nonRouteState = GetNonRouteStateById(pNonRoute->NonRouteId); + phySecSum = GetNonRoutePhySectionSumById(pNonRoute->NonRouteId); /*ǽ·*/ + pNonRoutePhySecStru = GetNonRoutePhySecStruBufById(pNonRoute->NonRouteId); /*ǽ·*/ + + if ((0U == phySecSum) || (NULL == pNonRoutePhySecStru)) + { + retVal = CI_ERROR; + } + else + { + /*ͨ*/ + } + + if (NONROUTE_STATE_IDLE == nonRouteState) + { /*ǽ·*/ + + retVal = CI_ERROR; + } + else + { + /*ͨ*/ + } + + if (CI_SUCCESS == retVal) + { + for (ii = 0U; ii < phySecSum; ii++) + { + if (phySecId == pNonRoutePhySecStru[ii].PhySectionId) + { /*ڷǽ·*/ + + nonRouteFlag = CI_SUCCESS; + break; + } + else + { + /**/ + } + } + } + else + { + /*ʧ*/ + } + + } + if (CI_SUCCESS == nonRouteFlag) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + + +/* +* ǽ·źŻر +* ˵ +* ֵ 0:ʧ +* 1:ɹ +*/ +void DriveNonRouteSignalClose(UINT8 nonRouteId) +{ + UINT8 sigSum = 0u; /*źŻ*/ + UINT16 *pSigIdBuf = NULL;/*ź*/ + UINT8 ii = 0u; + + + sigSum = GetNonRouteSignalSumById(nonRouteId); /*ȡǽ·źŻĿ*/ + pSigIdBuf = GetNonRouteSignalIdBufById(nonRouteId); /*ȡǽ·źŻID*/ + + if ((0u == sigSum) || (NULL == pSigIdBuf)) + { + return; + } + + for (ii = 0u; ii < sigSum; ii++) + { + /*źź*/ + SetSignalCurDriveColor(pSigIdBuf[ii], SIGNAL_DRIVECOLOUR_RED); + } +} + + +/* +* ǽ·źŻ +* ˵ +* ֵ 0:ʧ +* 1:ɹ +*/ +void DriveNonRouteSignalOpen(UINT8 nonRouteId) +{ + UINT8 sigSum = 0u; /*źŻ*/ + UINT16 *pSigIdBuf = NULL;/*ź*/ + UINT8 ii = 0u; + + + sigSum = GetNonRouteSignalSumById(nonRouteId); /*ȡǽ·źŻĿ*/ + pSigIdBuf = GetNonRouteSignalIdBufById(nonRouteId); /*ȡǽ·źŻID*/ + + if ((0u == sigSum) || (NULL == pSigIdBuf)) + { + return; + } + + for (ii = 0u; ii < sigSum; ii++) + { + /*źŰ׵*/ + SetSignalCurDriveColor(pSigIdBuf[ii], SIGNAL_DRIVECOLOUR_WHITE); + } +} + + +/* +* ǽ·źŻȫرռ +* ˵ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 CheckNonRouteSignalAllClose(UINT8 nonRouteId) +{ + UINT8 sigSum = 0u; /*źŻ*/ + UINT16 *pSigIdBuf = NULL;/*ź*/ + UINT8 ii = 0u; + + + sigSum = GetNonRouteSignalSumById(nonRouteId); /*ȡǽ·źŻĿ*/ + pSigIdBuf = GetNonRouteSignalIdBufById(nonRouteId); /*ȡǽ·źŻID*/ + + if ((0u == sigSum) || (NULL == pSigIdBuf)) + { + return CI_ERROR; + } + + for (ii = 0u; ii < sigSum; ii++) + { + if (SIGNAL_OPEN == GetSignalOpenCloseState(GetSignalCurColor(pSigIdBuf[ii]))) + { /*źſ*/ + + return CI_ERROR; + } + } + + return CI_SUCCESS; +} + + +/* +* ǽ·źŻȫż +* ˵ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 CheckNonRouteSignalAllOpen(UINT8 nonRouteId) +{ + UINT8 sigSum = 0u; /*źŻ*/ + UINT16 *pSigIdBuf = NULL;/*ź*/ + UINT8 ii = 0u; + + + sigSum = GetNonRouteSignalSumById(nonRouteId); /*ȡǽ·źŻĿ*/ + pSigIdBuf = GetNonRouteSignalIdBufById(nonRouteId); /*ȡǽ·źŻID*/ + + if ((0u == sigSum) || (NULL == pSigIdBuf)) + { + return CI_ERROR; + } + + for (ii = 0u; ii < sigSum; ii++) + { + if (SIGNAL_CLOSE == GetSignalOpenCloseState(GetSignalCurColor(pSigIdBuf[ii]))) + { /*źŹر*/ + + return CI_ERROR; + } + } + + return CI_SUCCESS; +} + + + + +/* +* ·֮ǰռ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +#if 0 +void CleanRoutePreOccupyState(const UINT16 routeId) +{ + UINT8 nearSecSum = 0u; /*ӽ*/ + UINT8 routeSecSum = 0u; /*·*/ + RouteNearPhySectionStruct *pRouteNearSecData = NULL; /*ӽ*/ + RoutePhysicalSectionStruct *pRouteSecData = NULL; /*·*/ + UINT8 ii = 0u; + + nearSecSum = GetRouteBlocNearSecConditionSum(routeId); /*ȡ·ӽĿ*/ + pRouteNearSecData = GetRouteBlocNearPhySectionStru(routeId); /*ȡ·ӽ*/ + + if ((nearSecSum > 0u) && (pRouteNearSecData != NULL)) + { + if ((pRouteNearSecData[0].NearPhySecSum > 0u) && (pRouteNearSecData[0].NearPhySecIdBuf != NULL)) + { + CleanPhySecPreMergeState(pRouteNearSecData[0].NearPhySecIdBuf[pRouteNearSecData[0].NearPhySecSum-1]);/*֮ǰ״̬ҲΪ*/ + } + } + + routeSecSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·Ŀ*/ + pRouteSecData = GetRouteSectionData(routeId); /*ȡ·*/ + + if ((routeSecSum > 0u) && (pRouteSecData != NULL)) + { + for (ii = 0u; ii < routeSecSum; ii++) + { + CleanPhySecPreMergeState(pRouteSecData[ii].PhysicalSectionId); /*֮ǰ״̬Ϊ*/ + } + } +} +#endif + + + +/* +* ·δʱ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckRoutePhySecUnfaultDelay(const UINT16 routeId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *RouteSecStru = NULL; /**/ + UINT8 ii= 0u; + + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + RouteSecStru = GetRouteSectionData(routeId); /*·*/ + + if (0u == sectionSum) + { + return CI_ERROR; + } + else + { + } + + for(ii = 0u; ii < sectionSum; ii++) + { + if (PHYSICAL_SECTION_LOCK_FAULTDELAY == GetPhySecLockState(RouteSecStru[ii].PhysicalSectionId)) + { /*ʱ*/ + + return CI_ERROR; + } + else + { + } + } + + return CI_SUCCESS; +} + + +/* +* ·гʻ +* ˵ const UINT16 routeId, ·ID +* ֵ SUCCESSɹ +* ERROR ʧ +*/ +UINT8 CheckTrainEnterRoute(const UINT16 routeId) +{ + UINT8 routeType = 0u; /*·*/ + UINT16 startSigId = 0u; /*·ʼźŻID*/ + UINT16 outPhySecId = 0u; /*źŻⷽһID*/ + UINT16 inPhySecId = 0u; /*źŻڷһID*/ + UINT16 nextPhySecId = 0u; /*źŻڷһһID*/ + UINT8 signalType = 0u; /*źŻƵ·*/ + UINT8 signalCrossCloseType = 0u; /*źŻѹص*/ + + startSigId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + signalType = GetSignalType(startSigId); /*ȡźŻ߼*/ + signalCrossCloseType = GetSignalCrossCloseAttr(startSigId); /*ȡźŻѹص*/ + if (0u == startSigId) + { /*ʼźŻݴ*/ + + return CI_ERROR; + } + + inPhySecId = GetSignalInFirstPhySecId(startSigId, routeId); /*źŻڷһID*/ + outPhySecId = GetSignalOutFirstPhySecId(startSigId); /*źŻⷽһID*/ + + if (0u == inPhySecId) + { /*ڷݴ*/ + + return CI_ERROR; + } + + routeType = GetRouteType(routeId); /*·*/ + + if (ROUTE_TYPE_LIECHE == routeType) + { /*г·*/ + + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(inPhySecId)) + { /*ڷռ*/ + + if (outPhySecId == 0u) + { + return CI_SUCCESS; /*гʻ*/ + } + else + { + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(outPhySecId)) + { /*ⷽռ*/ + + return CI_SUCCESS; /*гʻ*/ + } + } + } + } + else if (ROUTE_TYPE_DIAOCHE == routeType) + { /*·*/ + /*źţȫԽźŻʱźŻⷽгźŻⷽδ·Ƿг³гڷһʱ*/ + if ((SECTION_OCCUPY_NO == GetPhySecCurMergeState(inPhySecId)) && + (SECTION_OCCUPY_YES == GetPhySecPreMergeState(inPhySecId))) + { /*ڷһο*/ + + if ((outPhySecId == 0u) || ((SECTION_OCCUPY_YES == GetPhySecCurMergeState(outPhySecId)) && + (PHYSICAL_SEC_TYPE_NOSWITCH == GetPhySecType(outPhySecId)))) + { /*ⷽΪ0||ⷽεǰռ&&޲*/ + + nextPhySecId = GetRouteNextPhySecId(routeId, inPhySecId); /*ȡڷһεһID*/ + + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(nextPhySecId)) + { + return CI_SUCCESS; /*гʻ*/ + } + } + } + else if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(inPhySecId)) + { /*ڷһռ*/ + if (0u == outPhySecId) + { + return CI_SUCCESS; /*гʻ*/ + } + else if(((SIGNAL_TYPE_JINKUCHUKU == signalType) || (SIGNAL_TYPE_TWO_JINKU_RGY == signalType) || (SIGNAL_TYPE_THREE_JINKU_YINDAO == signalType)) + && (SIGNAL_CROSS_ClOSE_YES == signalCrossCloseType) && (SECTION_OCCUPY_YES == GetPhySecCurMergeState(outPhySecId))) + {/*ε·źŻڷһռеѹصʱΪгʻ*/ + return CI_SUCCESS; /*гʻ*/ + } + else + { + if ((SECTION_OCCUPY_NO == GetPhySecCurMergeState(outPhySecId)) && + (SECTION_OCCUPY_YES == GetPhySecPreMergeState(outPhySecId))) + { /*ⷽεǰ&&֮ǰռ*/ + + return CI_SUCCESS; /*гʻ*/ + } + } + + } + else + { /*ڷ֮ǰǰ*/ + + return CI_ERROR; + } + } + else + { /*·ʹ*/ + + return CI_ERROR; + } + + return CI_ERROR; +} + + +/* +* ý·ֹͣ־ +* ˵ const UINT16 routeId, ·ID +* UINT8 setState, ״̬ +* ֵ +*/ +void SetRouteStopFlagManage(const UINT16 routeId, UINT8 setState) +{ + UINT8 ii = 0u; + UINT8 phySecSum = 0u; /**/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT8 ljkTag = 0U; /*ָεм־*/ + UINT8 pyhSecCurState = 0U; /*ָεĵǰɼ״̬*/ + phySecSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(routeId); /*ȡ·*/ + + if ((0u == routeId) || (ROUTE_SUM_MAX <= routeId)) + { + ; /**/ + } + else if (ROUTE_STOPCHECK_SET_YES == setState) + { + /*ý·ֹͣ־ */ + (void)SetRouteStopCheckFlag(routeId, ROUTE_STOPCHECK_SET_YES); + /*Ľ·ΣֹͣЧ*/ + for(ii = 0u; ii < phySecSum; ii ++) + { + /*·м*/ + ljkTag = GetPhySecLjkFlag(pPhySecDataStru[ii].PhysicalSectionId); + if (PHYSICAL_SECTION_LJK_YES == ljkTag) + { + /*мĽ·ֹͣɵ־*/ + /*ֹͣ־*/ + CancelStopCheckFlag(); + pyhSecCurState = GetPhySecCurOccupyState(pPhySecDataStru[ii].PhysicalSectionId); + if(SECTION_OCCUPY_YES == pyhSecCurState) + { + SetPhySectionStopCheckFlag(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_STOPCHECK_SET_YES); + + } + } + } + + } + else if (setState == ROUTE_STOPCHECK_SET_NO) + { + /*·ֹͣ־ */ + (void)SetRouteStopCheckFlag(routeId, ROUTE_STOPCHECK_SET_NO); + (void)SetRouteStopKeepCheckFlag(routeId, ROUTE_STOPCHECK_SET_NO); + + for(ii = 0u; ii < phySecSum; ii ++) + { + /*·м*/ + ljkTag = GetPhySecLjkFlag(pPhySecDataStru[ii].PhysicalSectionId); + if (PHYSICAL_SECTION_LJK_YES == ljkTag) + { + SetPhySectionStopCheckFlag(pPhySecDataStru[ii].PhysicalSectionId, PHYSICAL_STOPCHECK_SET_NO); + + } + + } + } + else + { + /*޲*/ + } + +} + + +/* +* õ״̬ +* ˵ UINT16 switchId +* ֵ1 +* 0: +*/ +void SetSwitchFengSuoStateDeal(const UINT16 switchId, const UINT8 flockState) +{ + if ((flockState != SWITCH_LOCK_FENGSUO_YES) && + (flockState != SWITCH_LOCK_FENGSUO_NO)) + { + return; + } + + SetSwitchFLockState(switchId, flockState); /*õ״̬*/ + + if (SWITCH_TYPE_DOUBLE == GetSwitchType(switchId)) + { /*˫*/ + + SetSwitchFLockState(GetDSwitchOtherId(switchId), flockState); /*õ״̬*/ + } +} + + +/* +* õ״̬ +* ˵ UINT16 switchId +* ֵ1 +* 0: +*/ +void SetSwitchDanSuoStateDeal(const UINT16 switchId, const UINT8 lockCommand) +{ + if ((lockCommand != SWITCH_LOCK_DANSUO_SET) && (lockCommand != SWITCH_LOCK_DANSUO_CANCEL)) + { + return; + } + + SetSwitchLockStatus(SWITCH_PLOCKTYPE_DANSUO,0u,switchId, lockCommand); /*õ״̬*/ + + if (SWITCH_TYPE_DOUBLE == GetSwitchType(switchId)) + { /*˫*/ + + SetSwitchLockStatus(SWITCH_PLOCKTYPE_DANSUO,0u,GetDSwitchOtherId(switchId), lockCommand); /*õ״̬*/ + } +} + + +/* +* ιϽʱ +* ˵ UINT16 phySecId ID +* ֵ1 +* 0: +*/ +UINT8 CheckPhySecFaultTrainUnEnterR(const UINT16 belongRouteId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *RouteSecStru = NULL; /**/ + UINT8 phySecOccupyIndex = 0xFFu; /*ռ±*/ + UINT8 ii= 0u; + + + sectionSum = GetRoutePhysicalSectionSum(belongRouteId); /*ý·Ŀ*/ + RouteSecStru = GetRouteSectionData(belongRouteId); /*·*/ + + if (0u == sectionSum) + { + return CI_ERROR; + } + else + { + } + + for (ii = 0u; ii < sectionSum; ii++) + { + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(RouteSecStru[ii].PhysicalSectionId)) + { /*ռ*/ + + phySecOccupyIndex = ii; + break; + } + else + { + } + } + + /*δռ*/ + if (0xFFu == phySecOccupyIndex) + { + return CI_SUCCESS; + } + else + { + } + + + if (0u= ROUTE_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + continue; + } + + /*;۷·մ*/ + DTrainReturnUnlockRouteAllLockP(routeId); + } + + /*;۷*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + routeId = 0u; /*·ID*/ + routeId = GetRouteId(ii); /*ȡ·ID*/ + belongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((0u == routeId) || (routeId >= ROUTE_SUM_MAX)) + { + continue; + } + + if ((belongCiId != localCiId) || (0u == localCiId)) + { + continue; + } + + /*;۷·մ*/ + DTrainRtnUnlockRoutePartLockP(routeId); + } +} + + +/* +* ȡ۷źŻID +* ˵ UINT16 routeId, ·ID +* ֵ ۷źŻID +*/ +UINT16 GetReturnId(const UINT16 routeId) +{ + UINT8 routeState = 0u; /*·״̬*/ + UINT16 returnSigId = 0u; /*۷źŻID*/ + UINT16 starSigRouteSum = 0u; /*ͬźŻΪʼ˵Ľ·Ŀ*/ + UINT16* starSigRouteBuf = NULL; /*ͬźŻΪʼ˵Ľ·ID*/ + UINT8 preRouteState = 0u; /* ֮ǰ·״̬ */ + UINT16 ii = 0u; + UINT8 toGo = CI_SUCCESS; + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + preRouteState = GetRoutePreState(routeId);/*ȡ·ǰһ״̬*/ + + if ((routeState != ROUTE_STATE_NEAR_LOCK) && + (routeState != ROUTE_STATE_NEAR_LOCKERR)) + { + toGo = CI_ERROR; + } + + if ((CI_ERROR == RouteAllLockSecNoOccupyCheck(routeId)) && (CI_SUCCESS == toGo)) + { /*·βǶ*/ + + toGo = CI_ERROR; + } + + if (CI_SUCCESS == toGo) + { + if (ROUTE_STATE_NEAR_LOCK == routeState) + { + returnSigId = GetRouteBingZhiSignalId(routeId); /*ȡźŻID*/ + if (0u != returnSigId) + { + starSigRouteSum = GetStartSignalRouteSum(returnSigId); + starSigRouteBuf = GetStartSignalRouteBuf(returnSigId); + + if ((starSigRouteSum != 0u) &&(NULL != starSigRouteBuf)) + { + /*ȡĽ·ID*/ + for (ii = 0u; ii < starSigRouteSum; ii++) + { + /*BΪ·8鳵ռѹ·ʱʱBG2·ҪԲֵźŻΪʼ˵Ľ·״̬*/ + if ((ROUTE_STATE_IDLE == GetRouteState(starSigRouteBuf[ii])) &&(CI_SUCCESS == CheckRoutePhysicalType(starSigRouteBuf[ii])) && + (SIGNAL_VIRTUAL_YES == GetSignalVirtualAttr(returnSigId))) + { + /*ԲźŻΪʼ˵Ľ·Ϊҽ·ξΪмΣҲźŻΪźŻ, + 㷨Ŀǰֻڿ;۷*/ + } + else + { + break; + } + } + if (ii == starSigRouteSum) + { /*۷źŻΪʼ˵Ľ·Ϊ*/ + + returnSigId = GetRouteChaZhiSignalId(routeId); /*ȡźŻID*/ + } + } + } + + + } + else + { + /*ǰ״̬ǽӽ쳣*/ + + /* Dzгʻ·ͬʱ֮ǰ״̬Ϊӽгѹ룬źŹرգ + * Ϊͬһг;۷ + */ + if((ROUTE_STATE_NEAR_LOCK == preRouteState) && (TRAIN_ENTER_ROUTE_FLAG_YES == GetTrainEnterRouteFlag(routeId))) + { + returnSigId = GetRouteChaZhiSignalId(routeId); /*ȡźŻID*/ + } + else + { + returnSigId = 0u; + } + } + } + return returnSigId; +} + + +/* +* ۷·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void DTrainReturnUnlockRouteAllLockP(const UINT16 routeId) +{ + UINT8 routeState = 0U; /*·״̬*/ + UINT16 returnSigId = 0U; /*۷źŻID*/ + UINT16 innerSecId = 0U; /*źŻڷID*/ + UINT16 lockBelongRouteId = 0U; /*·ID*/ + UINT8 routeType = 0U; + UINT16 starSigRouteSum = 0U; /*ͬźŻΪʼ˵Ľ·Ŀ*/ + UINT16* starSigRouteBuf = NULL; /*ͬźŻΪʼ˵Ľ·ID*/ + UINT16 ii = 0U; + UINT16 tmp = 0U; + UINT16 endSigId = 0U; + UINT16 endRouteSum =0U; + UINT16* endRouteBuf = NULL; + UINT16 wLockRouteStartSigId = 0U;/*·ʼźŻID*/ + UINT8 chKeepFlag = CI_ERROR;/*ִб־*/ + UINT8 chLockBelRouteState = 0U; /*··״̬*/ + UINT8 chLockBelRouteType = 0U;/*··*/ + UINT8 chTrainEnterRouteFlag = 0U;/*гʻ·־*/ + UINT8 chRouteInOutSecOccupy = 0U;/*·ⷽͬʱռѹ־*/ + + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + routeType = GetRouteType(routeId); + + if ((ROUTE_STATE_NEAR_LOCK != routeState) && + (ROUTE_STATE_NEAR_LOCKERR != routeState)) + { + chKeepFlag = CI_ERROR; + } + else + { + chKeepFlag = CI_SUCCESS; + } + + if(CI_SUCCESS == chKeepFlag) + { + chKeepFlag = RouteAllLockSecNoOccupyCheck(routeId); + if (CI_SUCCESS == chKeepFlag) + { + /*·ζ*/ + returnSigId = GetReturnId(routeId); + if (0U != returnSigId) + { + /*۷źŻЧ*/ + endSigId = GetRouteEndSignalId(routeId); + endRouteSum = GetStartSignalRouteSum(endSigId); + endRouteBuf = GetStartSignalRouteBuf(endSigId); + for (ii = 0U; ii < endRouteSum; ii++) + { + DTrainRtnUnlockRemoteRAllLockP(endRouteBuf[ii]); + } + innerSecId = GetSignalInFirstPhySecId(returnSigId, routeId); /*ȡźŻڷһID*/ + lockBelongRouteId = GetPhySecRLockBelongRouteId(innerSecId); /*·ID*/ + chLockBelRouteType = GetRouteType(lockBelongRouteId); + chLockBelRouteState = GetRouteState(lockBelongRouteId); + if (0U != lockBelongRouteId) + { + /*·Ч*/ + wLockRouteStartSigId = GetRouteStartSignalId(lockBelongRouteId);/*ȡ·ʼźŻID*/ + chTrainEnterRouteFlag = CheckTrainEnterRoute(lockBelongRouteId);/*ȡгʻ·־*/ + chRouteInOutSecOccupy = RouteInOutSecOccupy(lockBelongRouteId);/*·ⷽͬʱռñ־*/ + + if ((ROUTE_STATE_NEAR_OPEN == chLockBelRouteState) && (ROUTE_TYPE_DIAOCHE == chLockBelRouteType) && + (returnSigId == wLockRouteStartSigId) && + ((CI_SUCCESS == chTrainEnterRouteFlag) || + ((CI_SUCCESS == chRouteInOutSecOccupy) && (ROUTE_TYPE_LIECHE == routeType)))) + { + /*۳·ǵ·&&״̬ǽӽ&&۳·ʼźŻDZ·۷źŻ &&гʻ ·Ϊг·۳·ʱⷽͬʱռѹ*/ + + /*ɹ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + if ((ROUTE_TYPE_LIECHE == chLockBelRouteType) && (ROUTE_STATE_NEAR_LOCK == chLockBelRouteState) + && (returnSigId == wLockRouteStartSigId)) + { + /*۳·г· ·״̬ǽӽ ۳·ʼźŻDZ·۷źŻ*/ + + /*ɹ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + } + } + } + } +} + +/* +* ۷Զ˽·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void DTrainRtnUnlockRemoteRAllLockP(const UINT16 routeId) +{ + UINT8 routeState = 0U; /*·״̬*/ + UINT16 returnSigId = 0U; /*۷źŻID*/ + UINT16 innerSecId = 0U; /*źŻڷID*/ + UINT16 lockBelongRouteId = 0U; /*·ID*/ + UINT8 routeType = 0U; + UINT16 starSigRouteSum = 0U; /*ͬźŻΪʼ˵Ľ·Ŀ*/ + UINT16* starSigRouteBuf = NULL; /*ͬźŻΪʼ˵Ľ·ID*/ + UINT16 ii = 0U; + UINT16 tmp = 0U; + UINT16 endSigId = 0U; + UINT16 endRouteSum =0U; + UINT16* endRouteBuf = NULL; + UINT8 retVal = CI_ERROR;/*ִб־*/ + UINT16 wLockRouteStartSigId = 0U;/*·ʼźŻID*/ + UINT8 chLockBelRouteState = 0U; /*··״̬*/ + UINT8 chLockBelRouteType = 0U;/*··*/ + UINT8 chTrainEnterRouteFlag = 0U;/*гʻ·־*/ + UINT8 chRouteInOutSecOccupy = 0U;/*·ⷽͬʱռѹ־*/ + + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + routeType = GetRouteType(routeId); + + if ((routeState != ROUTE_STATE_NEAR_LOCK) && + (routeState != ROUTE_STATE_NEAR_LOCKERR)) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + + if (CI_SUCCESS == retVal) + { + /*·ζ*/ + retVal = RouteAllLockSecNoOccupyCheck(routeId); + } + + if (CI_SUCCESS == retVal) + { + returnSigId = GetReturnId(routeId); + + if (0u == returnSigId) + { /*۷źŻЧ*/ + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + innerSecId = GetSignalInFirstPhySecId(returnSigId, routeId); /*ȡźŻڷһID*/ + lockBelongRouteId = GetPhySecRLockBelongRouteId(innerSecId); /*·ID*/ + if (0u == lockBelongRouteId) + { /*·Ч*/ + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + chLockBelRouteType = GetRouteType(lockBelongRouteId); + chLockBelRouteState = GetRouteState(lockBelongRouteId); + wLockRouteStartSigId = GetRouteStartSignalId(lockBelongRouteId);/*ȡ·ʼźŻID*/ + chTrainEnterRouteFlag = CheckTrainEnterRoute(lockBelongRouteId);/*ȡгʻ·־*/ + chRouteInOutSecOccupy = RouteInOutSecOccupy(lockBelongRouteId);/*·ⷽͬʱռñ־*/ + + if ((ROUTE_STATE_NEAR_OPEN == chLockBelRouteState) && (ROUTE_TYPE_DIAOCHE == chLockBelRouteType) && + (returnSigId == wLockRouteStartSigId) && + ((CI_SUCCESS == chTrainEnterRouteFlag) || + ((CI_SUCCESS == chRouteInOutSecOccupy) && (ROUTE_TYPE_LIECHE== routeType)))) + { + /*۳·ǵ·&&״̬ǽӽ&&۳·ʼźŻDZ·۷źŻ &&гʻ ·Ϊг·۳·ʱⷽͬʱռѹ*/ + /*ɹ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + if ((ROUTE_TYPE_LIECHE== chLockBelRouteType) && (ROUTE_STATE_NEAR_LOCK == chLockBelRouteState) + && (returnSigId == wLockRouteStartSigId)) + { + /*۳·г· ·״̬ǽӽ ۳·ʼźŻDZ·۷źŻ*/ + /*ɹ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + } +} + + +/* +* ۷·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void DTrainRtnUnlockRoutePartLockP(const UINT16 routeId) +{ + UINT8 routeState = 0U; /*·״̬*/ + UINT16 returnSigId = 0U; /*۷źŻID*/ + UINT16 innerSecId = 0U; /*źŻڷID*/ + UINT16 lockBelongRouteId = 0U; /*·ID*/ + UINT8 routeType = 0U; + UINT8 chKeepFlag = CI_ERROR;/*ִб־*/ + UINT8 chLockBelRouteState = 0U; /*··״̬*/ + UINT8 chTrainEnterRouteFlag = 0U;/*гʻ·־*/ + UINT16 wLockRouteStartSigId = 0U;/*·ʼźŻID*/ + UINT16 wOutSecId = 0U; /*۷źŻⷽ*/ + UINT8 chOutSecType = 0U; + UINT8 chSecOccupyState = 0U; /*۳·ⷽռѹ״̬*/ + UINT8 chSecLockState = 0U;/*ⷽ״̬*/ + + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + if (routeState != ROUTE_STATE_AUTO_UNLOCK) + { + chKeepFlag = CI_ERROR; + } + else + { + chKeepFlag = CI_SUCCESS; + } + + if (CI_SUCCESS == chKeepFlag) + { + chKeepFlag = RouteAllLockSecNoOccupyCheck(routeId); + } + + if (CI_SUCCESS == chKeepFlag) + { + returnSigId = GetRouteMidwayReturnSignalId(routeId); /*ȡ;۷źŻID*/ + if (0u == returnSigId) + { /*۷źŻЧ*/ + chKeepFlag = CI_ERROR; + ZHGDTrainRtnUnlockRouteProc(routeId); /*ת;۷źŻ*/ + + } + } + + if (CI_SUCCESS == chKeepFlag) + { + innerSecId = GetSignalInFirstPhySecId(returnSigId, routeId); /*ȡźŻڷһID*/ + lockBelongRouteId = GetPhySecRLockBelongRouteId(innerSecId); /*·ID*/ + if (0u == lockBelongRouteId) + { /*·Ч*/ + chKeepFlag = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepFlag) + { + routeType = GetRouteType(lockBelongRouteId); + chLockBelRouteState = GetRouteState(lockBelongRouteId); + chTrainEnterRouteFlag = CheckTrainEnterRoute(lockBelongRouteId);/*ȡгʻ·־*/ + wLockRouteStartSigId = GetRouteStartSignalId(lockBelongRouteId);/*ȡ·ʼźŻID*/ + + if ((ROUTE_TYPE_DIAOCHE == routeType) && (ROUTE_STATE_NEAR_OPEN == chLockBelRouteState) && + (CI_SUCCESS == chTrainEnterRouteFlag) && (returnSigId == wLockRouteStartSigId)) + { + /*۳·ǵ··״̬ǽӽгʻ۳·ʼźŻDZ·۷źŻ*/ + /*ɹ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + + if ((ROUTE_TYPE_LIECHE == routeType) && (ROUTE_STATE_NEAR_LOCK == chLockBelRouteState) + && (returnSigId == wLockRouteStartSigId)) + { + /*۳·г··״̬ǽӽ۳·ʼźŻDZ·۷źŻ*/ + + /*ɹ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + } +} + + +/* +* ȡ·źŻID +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT16 GetRouteBingZhiSignalId(const UINT16 routeId) +{ + UINT16 startSigId = 0u; /*ʼźŻID*/ + UINT16 signalSum = 0u; /*źŻ*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT16 ii = 0u; + + startSigId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + signalSum = GetSignalCurSum(); /*ȡźŻ*/ + + for (ii = 0u; ii < signalSum; ii++) + { + signalId = GetSignalId(ii); /*ȡźŻID*/ + + if ((GetSignalInFirstPhySecId(startSigId, routeId) == GetSignalOutFirstPhySecId(signalId)) && + (GetSignalOutFirstPhySecId(startSigId) == GetSignalInFirstPhySecId(signalId, routeId))) + { + return signalId; + } + } + + return 0u; +} + + +/* +* ȡ·źŻID +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT16 GetRouteChaZhiSignalId(const UINT16 routeId) +{ + UINT16 startSigId = 0u; /*ʼźŻID*/ + UINT16 signalSum = 0u; /*źŻ*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT16 routeSecSum = 0u; /*·*/ + RoutePhysicalSectionStruct *pRoutePhySecStru = NULL; /*·*/ + UINT16 returnOutSecId = 0u; /*۷źŻⷽID*/ + UINT16 returnInSecId = 0u; /*۷źŻڷID*/ + UINT16 lockBelongRouteId = 0u; /*·ID*/ + UINT16 outSecId = 0u; /*ⷽID*/ + UINT16 ii = 0u; + UINT16 tmpSigId = 0u; + + + startSigId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + signalSum = GetSignalCurSum(); /*ȡźŻ*/ + + if (PHYSICAL_SEC_TYPE_NOSWITCH == GetPhySecType(GetSignalOutFirstPhySecId(startSigId))) + { /*޲*/ + + for (ii = 0u; ii < signalSum; ii++) + { + signalId = GetSignalId(ii); /*ȡźŻID*/ + + if ((GetSignalOutFirstPhySecId(startSigId) == GetSignalOutFirstPhySecId(signalId)) && + (startSigId != signalId)) + { + return signalId; + } + } + } + else + { /*в*/ + + outSecId = GetSignalOutFirstPhySecId(startSigId); /*·ʼźŻⷽID*/ + lockBelongRouteId = GetPhySecRLockBelongRouteId(outSecId); /*·ID*/ + + routeSecSum = GetRoutePhysicalSectionSum(lockBelongRouteId); /*ȡ·*/ + pRoutePhySecStru = GetRouteSectionData(lockBelongRouteId); /*ȡ·*/ + + if ((0u == routeSecSum) || (NULL == pRoutePhySecStru)) + { + return 0u; + } + if (routeSecSum == 1u) + { + /*if ((PHYSICAL_SECTION_LOCK_NORMAL == GetPhySecLockState(pRoutePhySecStru[0].PhysicalSectionId)) && + (lockBelongRouteId == GetPhySecRLockBelongRouteId(pRoutePhySecStru[0].PhysicalSectionId)))*/ + { + returnOutSecId = pRoutePhySecStru[0].PhysicalSectionId;/*۷źŻⷽID*/ + + tmpSigId = GetRouteStartSignalId(lockBelongRouteId);/*۷źŻڷID*/ + + returnInSecId = GetSignalOutFirstPhySecId(tmpSigId); + } + } + else if (routeSecSum > 1u) + { + for (ii = 0u; ii < routeSecSum; ii++) + { + + if ((PHYSICAL_SECTION_LOCK_NORMAL == GetPhySecLockState(pRoutePhySecStru[ii].PhysicalSectionId)) && + (lockBelongRouteId == GetPhySecRLockBelongRouteId(pRoutePhySecStru[ii].PhysicalSectionId))) + { /*·һյ*/ + + returnOutSecId = pRoutePhySecStru[ii].PhysicalSectionId; /*۷źŻⷽID*/ + + if (ii > 0u) + { + returnInSecId = pRoutePhySecStru[ii-1U].PhysicalSectionId; /*۷źŻڷID*/ + } + + break; + } + } + } + else + { + /*޲*/ + } + if ((0u == returnOutSecId) || (0u == returnInSecId)) + { + return 0u; + } + + for (ii = 0u; ii < signalSum; ii++) + { + signalId = GetSignalId(ii); /*ȡźŻID*/ + + if ((returnOutSecId == GetSignalOutFirstPhySecId(signalId)) && + (returnInSecId == GetSignalInFirstPhySecId(signalId, routeId))) + { + return signalId; + } + } + } + + return 0u; +} + + +/* +* ȡ·;۷źŻID +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT16 GetRouteMidwayReturnSignalId(const UINT16 routeId) +{ + UINT16 signalSum = 0u; /*źŻ*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT16 routeSecSum = 0u; /*·*/ + RoutePhysicalSectionStruct *pRoutePhySecStru = NULL; /*·*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT16 returnOutSecId = 0u; /*۷źŻⷽID*/ + UINT16 returnInSecId = 0u; /*۷źŻڷID*/ + + signalSum = GetSignalCurSum(); /*ȡźŻ*/ + routeSecSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·*/ + pRoutePhySecStru = GetRouteSectionData(routeId); /*ȡ·*/ + + if (0u == routeSecSum) + { + return 0u; + } + else + { + } + + for (ii = 0u; ii < routeSecSum; ii++) + { + + if ((PHYSICAL_SECTION_LOCK_NORMAL == GetPhySecLockState(pRoutePhySecStru[ii].PhysicalSectionId)) && + (routeId == GetPhySecRLockBelongRouteId(pRoutePhySecStru[ii].PhysicalSectionId))) + { /*·һյ*/ + + for (jj = 0u; jj < signalSum; jj++) + { + signalId = GetSignalId(jj); /*ȡźŻID*/ + returnOutSecId = pRoutePhySecStru[ii].PhysicalSectionId;/*۷źŻⷽ*/ + if (ii > 0u) + { + returnInSecId = pRoutePhySecStru[ii-1U].PhysicalSectionId;/*۷źŻڷ*/ + if ((returnOutSecId == GetSignalOutFirstPhySecId(signalId)) + && (returnInSecId == GetSignalInFirstPhySecId(signalId, routeId))) + { + return signalId; + } + else + { + } + } + else + { + } + } + + break; + } + else + { + } + } + + return 0u; +} + + +/* +* ·ȫм +* ˵ UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllLockSecNoOccupyCheck(UINT16 const routeId) +{ + UINT8 const checkSum = GetRoutePhysicalSectionSum(routeId); + RoutePhysicalSectionStruct* const dataIdBuf = GetRouteSectionData(routeId); + + UINT16 i = 0u; /* ѭ */ + + if (0u == checkSum) + { + return CI_ERROR; + } + else + { + } + + for (i = 0u; i < checkSum; i++) + { + if (routeId == GetPhySecRLockBelongRouteId(dataIdBuf[i].PhysicalSectionId)) + { /*ڱ·յ*/ + + if (SECTION_OCCUPY_YES == GetPhySecCurMergeState(dataIdBuf[i].PhysicalSectionId)) + { + return CI_ERROR; + } + else + { + } + } + else + { + } + } + + return CI_SUCCESS; +} + + +/* +* ſ߼ +* ˵ const UINT16 garageDoorId, ID +* ֵ void +*/ +void SetGarageDoorOpenLogicM(const UINT16 garageDoorId) +{/*ſ*/ + + (void)SetGrgdoorCmdProcessState(garageDoorId,GARAGE_DOOR_CMD_OPEN); +} + +/* +* Ź߼ +* ˵ const UINT16 garageDoorId, ID +* ֵ void +*/ +void SetGarageDoorCloseLogicM(const UINT16 garageDoorId) +{/*Ź*/ + + (void)SetGrgdoorCmdProcessState(garageDoorId,GARAGE_DOOR_CMD_CLOSE); +} + + + + +/* +* ߼ +* ˵ +* ֵ +*/ +void GargeDoorLogicProcess(void) +{ + UINT16 grgDoorSum = GetGaragedoorSum(); + UINT8 ii = 0u; + UINT8 cmd = 0u; + UINT8 ret = 0u; + UINT16 grgdoorId = 0u; + UINT8 doorDrvState = 0u; /*ŵǰ״̬*/ + UINT8 doorCurMode = 0u; /*ŵǰģʽ*/ + UINT32 waiteZCResbackStartTime = 0u; /*ȴ ZCʼʱ*/ + UINT32 waiteIVOCResbackStartTime = 0u; /*ȴ IVOCʼʱ*/ + UINT32 curCycCount = Get2oo2CurCycleNum(); /*ȡǰں*/ + UINT8 closeFlagZC = GARAGE_DOOR_ALLOW_CLOSE_NO; + UINT8 closeFlagIVOC = GARAGE_DOOR_ALLOW_CLOSE_NO; + UINT8 RcWorkMode = 0U; /*ģʽ*/ + UINT8 checkFlag = 0U; /*RCģʽŹżжϱ־*/ + UINT32 waitResponseCount = 0U; /*ŵȴʱʱ*/ + UINT16 applyCloseTrainId = UINT16_MAX; + + waitResponseCount = GetWaitZCResponseCount(); + RcWorkMode = GetLocalRcWorkMode(); /*RCģʽȡ*/ + + + for(ii = 0u; ii < grgDoorSum; ii++) + { + grgdoorId = GetGaragedoorId(ii); + cmd = GetGrgdoorCmdProcessState(grgdoorId); + + if(GARAGE_DOOR_CMD_OPEN == cmd) + { + /* ʱҪ */ + ret = DriveGarageDoorOpenCheck(grgdoorId); + if(CI_SUCCESS == ret) + { + (void)SetDrvGaragedoorState(grgdoorId,GARAGE_DOOR_DRV_OPEN); + (void)SetGaragedoorOpenStartCycNum(grgdoorId, Get2oo2CurCycleNum()); /*¼ʼ*/ + } + (void)SetGrgdoorCmdProcessState(grgdoorId,GARAGE_DOOR_CMD_NULL); + } + else if(GARAGE_DOOR_CMD_CLOSE == cmd) /* */ + { + ret = DriveGarageDoorCloseCheck(grgdoorId); /*Ź*/ + + /* źŻر */ + ClosSigByGrgdoorCloseCmd(grgdoorId); + + /* ʱҪ */ + if(CI_SUCCESS == ret) + { + (void)SetDrvGaragedoorState(grgdoorId,GARAGE_DOOR_DRV_CLOSE); + (void)SetGaragedoorCloseStartCycNum(grgdoorId, Get2oo2CurCycleNum()); /*¼ʼ*/ + (void)SetGrgdoorCmdProcessState(grgdoorId,GARAGE_DOOR_CMD_NULL); /*ź*/ + } + else if(CI_ERROR == ret) + { + /*ֱ*/ + (void)SetGrgdoorCmdProcessState(grgdoorId,GARAGE_DOOR_CMD_NULL); /**/ + } + else if(RETURN_GRGDOOR_CLSCHK_WAITALLOW == ret) + {/*ռ*/ + + /*TIOCģʽ£жǷܹر*/ + if (RC_WORK_MODE_TIOC == RcWorkMode) + { + closeFlagIVOC = GetGaragedoorAllowCloseFlagIVOC(grgdoorId); /*ȡIVOC־*/ + waiteIVOCResbackStartTime = GetWaiteIVOCResponseStartCycNum(grgdoorId); /*ȡָIDŵȴIVOCʼʱ*/ + + /*TIOCģʽ´ռʱŹ*/ + checkFlag = GarageDoorCloseCheckinRCMode(grgdoorId, ESEND_LEVEL_ZERO); + applyCloseTrainId = GetGaragedoorNearestTrainId(grgdoorId); + + if (CI_SUCCESS == checkFlag) + { + + if ((curCycCount - waiteIVOCResbackStartTime) > waitResponseCount) + { + /*ʱ*/ + (void)SetGrgdoorCmdProcessState(grgdoorId, GARAGE_DOOR_CMD_NULL); + SetWaiteIVOCResponseStartCycNum(grgdoorId, 0u); /*ȴIVOCʱ*/ + SetGaragedoorNearestTrainId(grgdoorId, NAME_FAILUREAREA); /*ӽгID*/ + SetErrorData(EFUNC_CLD_CLOSE_GARAGEDOOR, CI_DEVICE_TYPE_GARAGEDOOR, grgdoorId, ETYPE_GARDOOR_NOT_RECV_IVOC_GMXK, 0, ESEND_LEVEL_ZERO); + SetGaragedoorAllowCloseFlagIVOC(grgdoorId, GARAGE_DOOR_ALLOW_CLOSE_NO);/*IVOC־*/ + } + else + { + /* δʱ */ + + /* A޳ռѹгߣIVOC */ + if (0U == applyCloseTrainId) + { + /*Źر*/ + (void)SetDrvGaragedoorState(grgdoorId, GARAGE_DOOR_DRV_CLOSE); + SetGaragedoorCloseStartCycNum(grgdoorId, Get2oo2CurCycleNum()); /*¼ʼ*/ + (void)SetGrgdoorCmdProcessState(grgdoorId, GARAGE_DOOR_CMD_NULL); + SetWaiteIVOCResponseStartCycNum(grgdoorId, 0u); /*ȴIVOCʱ*/ + SetGaragedoorNearestTrainId(grgdoorId, NAME_FAILUREAREA); /*ӽгID*/ + SetGaragedoorAllowCloseFlagIVOC(grgdoorId, GARAGE_DOOR_ALLOW_CLOSE_NO);/*IVOC־*/ + } + + else if (GARAGE_DOOR_ALLOW_CLOSE_YES == closeFlagIVOC) + { + /*ͨŹر*/ + (void)SetDrvGaragedoorState(grgdoorId, GARAGE_DOOR_DRV_CLOSE); + SetGaragedoorCloseStartCycNum(grgdoorId, Get2oo2CurCycleNum()); /*¼ʼ*/ + (void)SetGrgdoorCmdProcessState(grgdoorId, GARAGE_DOOR_CMD_NULL); + SetWaiteIVOCResponseStartCycNum(grgdoorId, 0u); /*ȴIVOCʱ*/ + SetGaragedoorNearestTrainId(grgdoorId, NAME_FAILUREAREA); /*ӽгID*/ + SetGaragedoorAllowCloseFlagIVOC(grgdoorId, GARAGE_DOOR_ALLOW_CLOSE_NO);/*IVOC־*/ + + } + else + { + /*δʱδյIVOCڵȴ״̬ڼǷ,*/ + } + } + } + else + { + /*ͨʧ*/ + (void)SetGrgdoorCmdProcessState(grgdoorId, GARAGE_DOOR_CMD_NULL); /**/ + SetWaiteIVOCResponseStartCycNum(grgdoorId, 0u); /*ȴIVOCʱ*/ + SetGaragedoorNearestTrainId(grgdoorId, NAME_FAILUREAREA); /*ӽгID*/ + SetGaragedoorAllowCloseFlagIVOC(grgdoorId, GARAGE_DOOR_ALLOW_CLOSE_NO);/*IVOC־*/ + + } + } + /*CIģʽ£ȴZCرϢ*/ + else if (RC_WORK_MODE_CI == RcWorkMode) + { + closeFlagZC = GetGaragedoorAllowCloseFlag(grgdoorId); /*ȡZC־*/ + waiteZCResbackStartTime = GetWaiteZCResponseStartCycNum(grgdoorId); /*ȡָIDŵȴZCʼʱ*/ + /* ڵȴ״̬ڼǷ, */ + if ((curCycCount - waiteZCResbackStartTime) > waitResponseCount) + { + /*ʱ*/ + (void)SetGrgdoorCmdProcessState(grgdoorId, GARAGE_DOOR_CMD_NULL); + SetWaiteZCResponseStartCycNum(grgdoorId, 0u); /*ȴZCʱ*/ + SetErrorData(EFUNC_CLD_CLOSE_GARAGEDOOR, CI_DEVICE_TYPE_GARAGEDOOR, grgdoorId, ETYPE_GARDOOR_NOT_RECV_ZC_GMXK, 0, ESEND_LEVEL_ATS); + } + else + { + /*δʱδյZCȴδʱյ*/ + if (GARAGE_DOOR_ALLOW_CLOSE_YES == closeFlagZC) + { + (void)SetDrvGaragedoorState(grgdoorId, GARAGE_DOOR_DRV_CLOSE); + SetGaragedoorCloseStartCycNum(grgdoorId, Get2oo2CurCycleNum()); /*¼ʼ*/ + (void)SetGrgdoorCmdProcessState(grgdoorId, GARAGE_DOOR_CMD_NULL); + SetWaiteZCResponseStartCycNum(grgdoorId, 0u); /*ȴZCʱ*/ + } + else + { + /*δʱδյZCڵȴ״̬ڼǷ,*/ + } + } + } + + else + { + ; /**/ + } + + + } + else + { + /*޲*/ + } + + /* ʱж */ + } + else + { + /**/ + } + + /* ǰΪģʽ ſģʽתΪʱֹͣ */ + doorCurMode = GetGaragedoorModeState(grgdoorId); + doorDrvState = GetDrvGaragedoorState(grgdoorId); + if (GARAGE_DOOR_STATE_MODE_LOCAL == doorCurMode) + { + if ((GARAGE_DOOR_DRV_OPEN == doorDrvState) || (GARAGE_DOOR_DRV_CLOSE == doorDrvState)) + { + (void)SetDrvGaragedoorState(grgdoorId, GARAGE_DOOR_DRV_NULL); + } + } + } +} + +#if 0 +/* +* ŹʱرзźŻ +* ˵ const UINT16 garageDoorId, ID +* ֵ +*/ +void ClosSigByGrgdoorCloseCmd(UINT16 grgdoorId) +{ + UINT16 sigNum = 0u; + UINT16 sigIdx = 0u; + UINT16 sigId = 0u; + UINT16 i = 0u; + + sigNum = GetGardoorProtectSigSum(grgdoorId); + for (i = 0u; i < sigNum;i++) + { + /*ŷźŻ飬źŻر*/ + + sigIdx = GetGardoorProtectSigIdByIndex(grgdoorId,i); + sigId = GetSignalConfigBufIndex(sigIdx); + if (GetSignalBelongCiId(sigId) == GetSystemParaLocalCiId()) + { + /*οԳźŴ*/ + SetSignalCurDriveColor(sigId, SIGNAL_DRIVECOLOUR_RED); + } + } +} +#endif + +/* +* Źʱرз·ʼźŻ +* ˵ const UINT16 garageDoorId, ID +* ֵ +*/ +void ClosSigByGrgdoorCloseCmd(UINT16 grgdoorId) +{ + UINT16 routeNum = 0u; + UINT16* routeIdBuf = NULL; + UINT16 routeId = 0u; + UINT16 i = 0u; + UINT8 routeState = 0u; + + routeNum = GetGardoorRouteSum(grgdoorId); + routeIdBuf = GetGardoorRouteIdBuf(grgdoorId); + if (routeNum > 0u) + { + for (i = 0u; i < routeNum;i++) + { + /*ŷ·ʼźŻźŻر*/ + + routeId = routeIdBuf[i]; + routeState = GetRouteState(routeId); + if ((ROUTE_STATE_YUXIAN_OPEN == routeState) || (ROUTE_STATE_NEAR_OPEN == routeState)) + { + /*·ʼźŻر*/ + SetSignalCurDriveColor(GetRouteStartSignalId(routeId), SIGNAL_DRIVECOLOUR_RED); + } + else + { + } + } + } + else + { + } + +} + +/* +* ǰΪ·һΣΪ޲ +* ˵ const UINT16 phySectionId, ID +* const UINT16 lockBelongRouteId ·ID +* ֵ: CI_SUCCESS ɹ +* CI_ERROR ʧ +*/ +UINT8 CLDPhySectionFaultUnlockDeal(const UINT16 phySectionId,const UINT16 lockBelongRouteId) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *RouteSecStru = NULL; /**/ + UINT8 phySecIndex = 0u; /*ռ±*/ + UINT16 rtNextPhySecId = 0u; + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 retVal = CI_SUCCESS; + UINT8 chLockRouteDirection = 0U;/*·*/ + UINT8 lockState = 0U; + UINT8 phySecType = 0U; + UINT8 unLockFlag = 0U; + + if ((0u == phySectionId) || (PHYSICAL_SECTION_SUM_MAX<=phySectionId ) || (0u == lockBelongRouteId) || (ROUTE_SUM_MAX<=lockBelongRouteId )) + { /*IDЧ··IDЧ*/ + retVal = CI_ERROR; + } + else + { + } + + if (CI_SUCCESS == retVal) + { + sectionSum = GetRoutePhysicalSectionSum(lockBelongRouteId); /*ý·Ŀ*/ + RouteSecStru = GetRouteSectionData(lockBelongRouteId); /*·*/ + chLockRouteDirection = GetRouteDirection(lockBelongRouteId); + if ((0u == sectionSum) || (1u == sectionSum) ) + {/*·ĿΪ1ʱִд˲*/ + retVal = CI_ERROR; + } + else + { + } + } + else + { + } + + if (CI_SUCCESS == retVal) + { + for (ii = 0u;ii < sectionSum;ii++) + { + if (phySectionId == RouteSecStru[ii].PhysicalSectionId) + {/*ҵ*/ + phySecIndex = ii; + break; + } + } + if (phySecIndex < (sectionSum-1U)) + {/*ǰβǽ·ڵһ*/ + for (jj = phySecIndex+1U;jj < sectionSum;jj++) + {/*·ʣ*/ + rtNextPhySecId = RouteSecStru[jj].PhysicalSectionId; + lockState = GetPhySecLockState(rtNextPhySecId); + phySecType = GetPhySecType(rtNextPhySecId); + + + if ((PHYSICAL_SECTION_LOCK_NORMAL == lockState) || (PHYSICAL_SECTION_LOCK_EXCEPT == lockState)) + {/*εǰΪ || 쳣*/ + if ((PHYSICAL_SEC_TYPE_NOSWITCH == phySecType) && (jj == (sectionSum - 1U))) + {/*·һΪ޲βǽ·һ*/ + SetPhySecLockState(rtNextPhySecId, PHYSICAL_SECTION_LOCK_NO, lockBelongRouteId, chLockRouteDirection); /*δ*/ + /*ͬʱڱ·յ߼δ*/ + SetPhyIncludeLogLockState(rtNextPhySecId, LOG_SECTION_LOCK_NO, lockBelongRouteId); + unLockFlag = CheckRoutePhySecHaveUnLock(lockBelongRouteId); + if (CI_SUCCESS == unLockFlag) + {/*ҵ·ȫδգ·״̬Ϊ*/ + SetRouteStateDeal(lockBelongRouteId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + else + { + } + } + else + {/*в βǽ·һ*/ + SetPhySecLockState(rtNextPhySecId, PHYSICAL_SECTION_LOCK_EXCEPT, lockBelongRouteId, chLockRouteDirection); /*쳣*/ + SetPhyIncludeLogLockState(rtNextPhySecId, LOG_SECTION_LOCK_EXCEPT, lockBelongRouteId); + + break; + } + } + else + { + } + } + } + else + { + } + } + else + { + } + + return retVal; +} + +/* +* ȡϴ߼ +* ˵ void +* ֵ void +*/ +void CancelWashWorkLogicM(void) +{/*ȡϴ*/ + UINT16 washMachineId = 0u; + washMachineId = GetWashMachineId(0u); +#if 0 + SetCancelWashMachineFlag(washMachineId,CANCEL_WASH_FLAG_SET_YES); +#endif + if (washMachineId >0u) + {/*յֵȡϴֱӰϴͬⰴť״߼̬Ϊ̧*/ + (void)SetWashmachineXTALogicState(washMachineId,XTA_STATE_RAISE_UP); + } +} + +/* +* ·ͬ߼ +* ˵ void +* ֵ void +*/ +void RouteDCTYLogicM(UINT16 routeId) +{ + UINT8 routeType = 0u; + UINT8 routeState = 0u; + UINT16 routeDCQJId = 0u; + routeType = GetRouteType(routeId);/*·*/ + routeState = GetRouteState(routeId);/*·״̬*/ + routeDCQJId = GetRouteDCQJId(routeId); + if ((routeDCQJId >0u) && (ROUTE_TYPE_DIAOCHE == routeType)) + {/*̵IDڣǵ·*/ + if((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState)|| + (ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState) || + (ROUTE_STATE_DELAY_UNLOCK == routeState) || + (ROUTE_STATE_NEAR_LOCK == routeState)) + {/*·:··쳣ԤաԤȿšӽšӽ쳣ӽ + ա쳣šʱ*/ + (void)SetRouteDCQState(routeId,ROUTE_DCQ_REQUEST);/*ý·״̬Ϊ*/ + } + else + {/*ý·״̬Ϊǵ*/ + (void)SetRouteDCQState(routeId,ROUTE_DCQ_NOT_REQUEST); + } + } +} + +/* +* ÷ǽ·߼״̬ +* ˵ const UINT16 nonRouteId, ǽ·ID +* const UINT8 lockState, ״̬ +* ֵ void +* cgh-20230529-޸YF0083-823 +*/ +void SetNonRouteLogSecLockState(const UINT8 nonRouteId, const UINT8 lockState) +{ + UINT8 chSectionSum = 0u; /*ǽ·*/ + NonRoutePhySectionStruct* pPhySecStruBuf = NULL; /*ǽ·Ӧ*/ + UINT8 chLogicSecSum = 0u; /*ΰ߼*/ + UINT16* pLogicSecIdBuf = NULL;/*ΰ߼Id*/ + UINT8 chKeepFlag = CI_ERROR; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 chNonRouteLogSecCheck = CI_ERROR;/*Ӧ߼ǷΪǽ·ڷμ*/ + + chSectionSum = GetNonRoutePhySectionSumById(nonRouteId); /*÷ǽ·Ŀ*/ + pPhySecStruBuf = GetNonRoutePhySecStruBufById(nonRouteId); /*ȡǽ·*/ + + + if ((0u == chSectionSum) || (NULL == pPhySecStruBuf)) + { + chKeepFlag = CI_ERROR; + } + else + { + chKeepFlag = CI_SUCCESS; + } + + if (CI_SUCCESS == chKeepFlag) + { + if ((lockState != LOG_SECTION_LOCK_NO) && + (lockState != LOG_SECTION_LOCK_NORMAL)) + {/*ǽ·ֻδպ*/ + chKeepFlag = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepFlag) + { + for (ii = 0u; ii < chSectionSum; ii++) + {/*ȡζӦ߼*/ + chLogicSecSum = GetPhySecIncLogSecSum(pPhySecStruBuf[ii].PhySectionId); + pLogicSecIdBuf = GetPhySecIncLogSecIdBuf(pPhySecStruBuf[ii].PhySectionId); + for (jj = 0U; jj < chLogicSecSum; jj++) + { + chNonRouteLogSecCheck = NonRouteLogSecCheck(nonRouteId, pLogicSecIdBuf[jj]); + if (CI_SUCCESS == chNonRouteLogSecCheck) + {/*߼Ϊǽ·ڷ߼ΣöӦ߼״̬*/ + SetLogSecLockState(pLogicSecIdBuf[jj], lockState, 0U, 0U); + } + } + } + } +} + +/* +* ǽ·Ƿ߼ +* ˵ const UINT16 chNonRouteId, ǽ·ID +* const UINT16 wLogSecId ߼ID +* ֵ CI_ERROR +* CI_SUCCESS +* cgh-20230529-޸YF0083-823 +*/ +UINT8 NonRouteLogSecCheck(const UINT8 chNonRouteId, const UINT16 wLogSecId) +{ + UINT8 reval = CI_ERROR; + UINT8 chNonRouteSwitchSum = 0U;/*ǽ·Ŀ*/ + NonRouteSwitchStruct* pNonRouteSwitchStr = NULL;/*ǽ·*/ + UINT8 chLogSecSwitchSum = 0U;/*߼ΰĿ*/ + LogsecSwitchStruct* pLgcSecSwitchStru = NULL;/*߼ΰ*/ + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 chCheckPassFlag = 0U;/*߼εǽ·ƥ־*/ + + chNonRouteSwitchSum = GetNonRouteSwitchSumById(chNonRouteId); + pNonRouteSwitchStr = GetNonRouteSwitchStructBufById(chNonRouteId); + chLogSecSwitchSum = GetLogicSecSwitchSum(wLogSecId); + pLgcSecSwitchStru = GetLogicSecSwitchIdStru(wLogSecId); + + if((NULL == pNonRouteSwitchStr) || (NULL == pLgcSecSwitchStru)) + { + reval = CI_ERROR; + } + else + { + for (ii = 0U; ii < chLogSecSwitchSum; ii++) + {/*߼ΰĵIDλǷǽ·ĵһ*/ + for (jj = 0U; jj < chNonRouteSwitchSum; jj++) + { + if ((pNonRouteSwitchStr[jj].SwitchId == pLgcSecSwitchStru[ii].SwitchId) && (pNonRouteSwitchStr[jj].SwitchPos == pLgcSecSwitchStru[ii].SwitchPosition)) + { + chCheckPassFlag++; + } + } + } + if (chLogSecSwitchSum == chCheckPassFlag) + {/*߼ΰеĵڷǽ·ƥ䵽ɹ*/ + reval = CI_SUCCESS; + } + } + return reval; +} + +/* +* ת۷·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +* fan0824 +*/ +void ZHGDTrainRtnUnlockRouteProc(const UINT16 routeId) +{ + UINT8 routeState = 0U; /*·״̬*/ + UINT16 returnSigId = 0U; /*۷źŻID*/ + UINT16 innerSecId = 0U; /*źŻڷID*/ + UINT16 lockBelongRouteId = 0U; /*·ID*/ + UINT8 routeType = 0U; + UINT8 chKeepFlag = CI_ERROR;/*ִб־*/ + UINT8 chLockBelRouteState = 0U; /*··״̬*/ + UINT16 wLockRouteStartSigId = 0U;/*·ʼźŻID*/ + UINT16 wOutSecId = 0U; /*۷źŻⷽ*/ + UINT8 chOutSecType = 0U; + UINT8 chSecOccupyState = 0U; /*۳·ⷽռѹ״̬*/ + UINT8 chSecLockState = 0U;/*ⷽ״̬*/ + + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + if (routeState != ROUTE_STATE_AUTO_UNLOCK) + { + chKeepFlag = CI_ERROR; + } + else + { + chKeepFlag = CI_SUCCESS; + } + + if (CI_SUCCESS == chKeepFlag) + { + chKeepFlag = RouteAllLockSecNoOccupyCheck(routeId); + } + + if (CI_SUCCESS == chKeepFlag) + { + returnSigId = GetRouteTransRoutZFSigID(routeId); + if (0u == returnSigId) + { + chKeepFlag = CI_ERROR; + } + else + { + /*fan޸ת۷ȫ峡ת۷źŻ*/ + wOutSecId = GetSignalOutFirstPhySecId(returnSigId);/*ȡźŻⷽID תǰһ*/ + innerSecId = GetSignalInFirstPhySecId(returnSigId, routeId); + chSecLockState = GetPhySecLockState(wOutSecId); + chSecOccupyState = GetPhySecCurMergeState(wOutSecId); + chOutSecType = GetPhySecType(wOutSecId); + + if ((PHYSICAL_SEC_TYPE_NOSWITCH == chOutSecType) && (SECTION_OCCUPY_YES == chSecOccupyState) && (PHYSICAL_SECTION_LOCK_NO == chSecLockState)) + { + /*תǰһռѹ޲δգ򲻽*/ + chKeepFlag = CI_SUCCESS; + } + else + { + chKeepFlag = CI_ERROR;/**/ + } + } + } + + if (CI_SUCCESS == chKeepFlag) + { + innerSecId = GetSignalInFirstPhySecId(returnSigId, routeId); /*ȡźŻڷһID*/ + lockBelongRouteId = GetPhySecRLockBelongRouteId(innerSecId); /*·ID*/ + if (0u == lockBelongRouteId) + { /*·Ч*/ + chKeepFlag = CI_ERROR; + } + else + { + ; /**/ + } + } + + if (CI_SUCCESS == chKeepFlag) + { + routeType = GetRouteType(lockBelongRouteId); + chLockBelRouteState = GetRouteState(lockBelongRouteId); + wLockRouteStartSigId = GetRouteStartSignalId(lockBelongRouteId);/*ȡ·ʼźŻID*/ + chSecOccupyState = GetPhySecCurMergeState(innerSecId); /*Ѿ۳ⷽռѹ˴ڷռѹ*/ + if ((ROUTE_TYPE_DIAOCHE == routeType) && (ROUTE_STATE_NEAR_OPEN == chLockBelRouteState) && + (SECTION_OCCUPY_YES == chSecOccupyState) && (returnSigId == wLockRouteStartSigId)) + { + /*۳·ǵ··״̬ǽӽгʻ۳·ʼźŻDZ·۷źŻ*/ + /*ɹ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + + else if ((ROUTE_TYPE_LIECHE == routeType) && (ROUTE_STATE_NEAR_LOCK == chLockBelRouteState) + && (returnSigId == wLockRouteStartSigId)) + { + /*۳·г··״̬ǽӽ۳·ʼźŻDZ·۷źŻ*/ + + /*ɹ*/ + SetRoutePhySectionLockState(routeId, PHYSICAL_SECTION_LOCK_NO); /*ý·δ*/ + /*ý·߼: δ*/ + SetRouteLogSectionLockState(routeId, LOG_SECTION_LOCK_NO); + SetRouteStateDeal(routeId, ROUTE_STATE_IDLE); /*ý·״̬Ϊ*/ + } + else + { + ; /**/ + } + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/LogicManage/TradInterlockLogicManage.h b/TSCP/src/APP/ciapp/LogicManage/TradInterlockLogicManage.h new file mode 100644 index 0000000..ab9fa9b --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicManage/TradInterlockLogicManage.h @@ -0,0 +1,861 @@ +/******************************************************** +* +* InterlockLogicManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-10 +* ߣ +* ߼ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _TRAD_INTERLOCK_LOGIC_MANAGE_H_ +#define _TRAD_INTERLOCK_LOGIC_MANAGE_H_ + + + +#include "../System/SystemParameterManage.h" +#include "../System/CiSystemDefine.h" +#include "../Switch/SwitchDefine.h" +#include "../Switch/SwitchDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Signal/SignalDefine.h" +#include "../Signal/SignalDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Section/SectionDefine.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Route/RouteDefine.h" +#include "../Route/RouteDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../ERROR/ErrorDataManage.h" +#include "../ERROR/ErrorDefine.h" +#include "../DataManage/DeviceDataManage.h" +#include "../ParsePack/CiInterfaceDefine.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../LogicProcess/InterlockLogicCheck.h" +#include "../LogicManage/InterlockCommonManage.h" + +#include "../LogRecord/LogRecord.h" + +#ifdef SCADE_MODE +#include "../LogicManage/General/LogicManageScadeInterface.h" +#else +#include "../LogicProcess/InterlockLogicProcess.h" +#include "../LogicProcess/TradInterlockLogicProcess.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +* ߼ +* ˵ void +* ֵ +*/ +void TradInterlockLogicMainProc(void); + +/* +* ǽ·߼ +* ˵ void +* ֵ +*/ +void NonRouteLogicProcess(void); + +/* +* ǽ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void NonRouteXuanPaiDeal(UINT8 nonRouteId); + +/* +* ǽ·չ +* ˵ +* ֵ void +*/ +void NonRouteLockDeal(UINT8 nonRouteId); + +/* +* ǽ·Ź +* ˵ +* ֵ void +*/ +void NonRouteOpenDeal(UINT8 nonRouteId); + +/* +* ǽ·ʱ +* ˵ +* ֵ void +*/ +void NonRouteDelayUnlockDeal(UINT8 nonRouteId); + +/* +* ǽ·ʱ +* ˵ +* ֵ void +*/ +void NonRouteFaultDelayUnlockDeal(UINT8 nonRouteId); + +/* +* ·߼ +* ˵ void +* ֵ +*/ +void LongRouteLogicProcess(void); + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LongRouteXuanPaiDeal(const UINT16 longRouteId); + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LongRouteLockDeal(const UINT16 longRouteId); + +/* +* ·߼ +* ˵ void +* ֵ +*/ +void RouteLogicProcess(void); + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void CommonRouteXuanPaiDeal(const UINT16 routeId); + +/* +* ·ѡŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LeadRouteXuanPaiDeal(const UINT16 routeId); + +/* +* · +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstLockDeal(const UINT16 routeId); + +/* +* ·쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteFirstLockErrDeal(const UINT16 routeId); + +/* +* ·Ԥչ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteYuXianLockDeal(const UINT16 routeId); + +/* +* ·ԤȿŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteYuXianOpenDeal(const UINT16 routeId); + +/* +* ·ӽչ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearLockDeal(const UINT16 routeId); + +/* +* ·ӽ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearLockErrDeal(const UINT16 routeId); + +/* +* ·ӽŹ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteNearOpenDeal(const UINT16 routeId); + +/* +* ·ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteDelayUnlockDeal(const UINT16 routeId); + +/* +* ·Զ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteSecAutoUnlockDeal(const UINT16 routeId); + +/* +* ·Զ쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteSecAutoUnlockErrDeal(const UINT16 routeId); + +/* +* ·չ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadLockDeal(const UINT16 routeId); + +/* +* ·Ź +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadOpenDeal(const UINT16 routeId); + +/* +* ·쳣 +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLeadLockErrDeal(const UINT16 routeId); + +/* +* Ӧ̹ܴ +* ˵ void +* ֵ +*/ +void JKJRelayLogicProcess(void); + +/* +* Ž·źŴ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS +* CI_ERROR +*/ +UINT8 OpenCommRouteSigProc(const UINT16 routeId); + +/* +* ֿŽ·źŴ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 KeepCommRouteSigProc(const UINT16 routeId); + +/* +* ·ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +UINT8 CommRouteDelayUnlockProc(const UINT16 routeId); + +/* +* ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteSecDelayUnlockProc(const UINT16 routeId); + +/* +* ϵ߼ +* ˵ void +* ֵ +*/ +void StartupUnlockM(void); + +/* +* ͨ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetCommonRouteLogicM(const UINT16 routeId); + +/* +* Ͻ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void SetZuHeRouteLogicM(const UINT16 routeId); + +/* +* ȡϵ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void CancelZuHeRouteLogicM(const UINT16 routeId); + +/* +* ȡг·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void CancelZuHeLieCheRouteLogicM(const UINT16 routeId); + +/* +* ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +void SetLeadRouteM(const UINT16 signalId); + +/* +* ȡ·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void ZongQuXiaoRouteM(const UINT16 routeId); + +/* +* ˽·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void ZongRenJieRouteM(const UINT16 routeId); + +/* +* ؿź߼ +* ˵ const UINT16 signalId, źŻID +* ֵ void +*/ +void RepeatOpenSignalM(const UINT16 signalId); + +/* +* õ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void SetSwitchFengSuoM(const UINT16 switchId); + +/* +* õ߼ +* ˵ const UINT16 switchId, ID +* ֵ void +*/ +void SetSwitchDanSuoM(const UINT16 switchId); + +/* +* źŷ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ +*/ +void SetSignalFengSuoM(const UINT16 signalId); + +/* +* ȡ߼ +* ˵ UINT16 switchId, ID +* ֵ +*/ +void CancelSwitchFengSuoM(const UINT16 switchId); + +/* +* ȡ߼ +* ˵ UINT16 switchId, ID +* ֵ +*/ +void CancelSwitchDanSuoM(const UINT16 switchId); + +/* +* ȡźŷ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ +*/ +void CancelSignalFengSuoM(const UINT16 signalId); + +/* +* õλ߼ +* ˵ UINT16 switchId, ID +* const UINT8 switchSetPos, λ +* ֵ +*/ +void SetSwitchPositionM(const UINT16 switchId, const UINT8 switchSetPos); + +/* +* ǽ·߼ +* ˵ +UINT8 nonRouteId - ǽ·ID +* ֵ +*/ +void SetNonRouteM(UINT8 nonRouteId); + + +/* +* ȡǽ·߼ +* ˵ +UINT8 nonRouteId - ǽ·ID +* ֵ +*/ +void CancelNonRouteM(UINT8 nonRouteId); + +/* +* ȡǽ·߼ +* ˵ +UINT8 nonRouteId - ǽ·ID +* ֵ +*/ +void FaultCancelNonRouteM(UINT8 nonRouteId); + +/* +* ֹͣ +* ˵ void +* ֵ +*/ +void SetStopCheckM(void); + +/* +* ȡֹͣ +* ˵ void +* ֵ +*/ +void CancelStopCheckM(void); + +/* +* ·ȡ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongQuXiaoDeal(const UINT16 routeId); + +/* +* ·˽⴦ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteZongRenJieDeal(const UINT16 routeId); + +/* +* ǽ·ȡ +* ˵ +UINT8 nonRouteId - ǽ·ID +* ֵ void +*/ +void NonRouteCancelDeal(UINT8 nonRouteId); + +/* +* ղ̵ +* ˵ + const UINT16 routeId, UINT8 routeState +* ֵ + CI_ERROR + CI_SUCCESS +*/ +void UpdateZhaoChaDeal(const UINT16 routeId, const UINT8 routeState); + + +/* +* ǽ· +* ˵ const UINT16 routeId, ǽ·ID +* ֵ UINT8 +*/ +UINT8 NonRouteLockDrvSwitchDeal(const UINT8 nonRouteId); + +/* +* ιϽ쳣մ +* ˵ UINT16 phySecId ID +* ֵ1 +* 0: +*/ +void PhySecFaultRelatedUnLockDeal(const UINT16 phySecId, const UINT16 belongRouteId); + +/* +* ý·״̬ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +void SetRouteStateDeal(const UINT16 routeId, const UINT8 routeState); + +/* +* ó·״̬ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +void SetLongRouteStateDeal(const UINT16 longRouteId, const UINT8 longRouteState); + +/* +* ÷ǽ·״̬ +* ˵ UINT16 routeId ǽ· UINT8 nonRouteStateǽ·״̬ +* ֵ1 +* 0: +*/ +void SetNonRouteStateDeal(UINT8 nonRouteId,const UINT8 nonRouteState); + +/* +* ÷ǽ·״̬ +* ˵ UINT16 routeId ǽ· const UINT8 usingState ״̬ +* ֵ1 +* 0: +*/ +void SetNonRoutePhySecUsingState(UINT8 nonRouteId,const UINT8 usingState); + +/* +* ÷ǽ·״̬ +* ˵ UINT16 routeId ǽ· const UINT8 lockState ״̬ +* ֵ1 +* 0: +*/ +void SetNonRoutePhySecLockState(const UINT8 nonRouteId, const UINT8 lockState); + +/* +* ÷ǽ·״̬ +* ˵ const UINT16 nonRouteId, ·ID +* const UINT8 lockCommand, ״̬ +* ֵ 0 ʧ +* 1 ɹ +*/ +UINT8 SetNonRouteRelatedProtSwLockSta(const UINT16 nonRouteId, const UINT8 lockCommand); + +/* +* ս·ѡ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +void CancelLongRouteXuanPai(const UINT16 routeId); + +/* +* ս·ѡ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +void CancelRouteXuanPai(const UINT16 routeId); + +/* +* ȡǽ·ѡŴ +* ˵ +* ֵ +*/ +void CancelNonRouteXuanPai(UINT8 nonRouteId); + +/* +* ǽ· +* ˵ const UINT16 switchId, ID +* ֵ 0: Ѱǽ· +* 1: Ѱǽ· +*/ +UINT8 CheckSwitchBelongNonRoute(const UINT16 switchId); + +/* +* ǽ·źŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: Ѱǽ· +* 1: Ѱǽ· +*/ +UINT8 CheckSignalBelongNonRoute(const UINT16 signalId); + +/* +* ǽ·μ +* ˵ const UINT16 switchId, ID +* ֵ 0: Ѱǽ· +* 1: Ѱǽ· +*/ +UINT8 CheckPhySecBelongNonRoute(const UINT16 phySecId); + +/* +* ǽ·źŻر +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ 0:ʧ +* 1:ɹ +*/ +void DriveNonRouteSignalClose(UINT8 nonRouteId); + +/* +* ǽ·źŻ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ 0:ʧ +* 1:ɹ +*/ +void DriveNonRouteSignalOpen(UINT8 nonRouteId); + +/* +* ǽ·źŻȫرռ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 CheckNonRouteSignalAllClose(UINT8 nonRouteId); + +/* +* ǽ·źŻȫż +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 CheckNonRouteSignalAllOpen(UINT8 nonRouteId); + + +/* +* ·֮ǰռ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +*/ +#if 0 +void CleanRoutePreOccupyState(const UINT16 routeId); +#endif + + +/* +* ·δʱ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckRoutePhySecUnfaultDelay(const UINT16 routeId); + +/* +* ·гʻ +* ˵ const UINT16 routeId, ·ID +* ֵ SUCCESSɹ +* ERROR ʧ +*/ +UINT8 CheckTrainEnterRoute(const UINT16 routeId); + +/* +* ý·ֹͣ־ +* ˵ const UINT16 routeId, ·ID +* UINT8 setState, ״̬ +* ֵ +*/ +void SetRouteStopFlagManage(const UINT16 routeId, UINT8 setState); + +/* +* õ״̬ +* ˵ UINT16 switchId +* ֵ1 +* 0: +*/ +void SetSwitchFengSuoStateDeal(const UINT16 switchId, const UINT8 flockState); + +/* +* õ״̬ +* ˵ UINT16 switchId +* ֵ1 +* 0: +*/ +void SetSwitchDanSuoStateDeal(const UINT16 switchId, const UINT8 lockCommand); + +/* +* ιϽʱ +* ˵ UINT16 phySecId ID +* ֵ1 +* 0: +*/ +UINT8 CheckPhySecFaultTrainUnEnterR(const UINT16 belongRouteId); + +/* +* ιϽʱ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SWITCH_FLOCK +*/ +UINT8 SectionFaultUnlockUndelayP(const UINT16 phySectionId); + +/* +* ιϽʱ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SWITCH_FLOCK +*/ +UINT8 SectionFaultUnlockDelayP(const UINT16 phySectionId); + +/* +* ۷߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void DTrainReturnUnlockP(void); + +/* +* ۷·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void DTrainReturnUnlockRouteAllLockP(const UINT16 routeId); + + +/* +* ۷·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void DTrainRtnUnlockRoutePartLockP(const UINT16 routeId); + + +/* +* ȡ·źŻID +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT16 GetRouteBingZhiSignalId(const UINT16 routeId); + +/* +* ȡ·źŻID +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT16 GetRouteChaZhiSignalId(const UINT16 routeId); + +/* +* ȡ·;۷źŻID +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT16 GetRouteMidwayReturnSignalId(const UINT16 routeId); + +/* +* ·ȫм +* ˵ UINT16 routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllLockSecNoOccupyCheck(UINT16 const routeId); + + +/* +* ſ߼ +* ˵ const UINT16 garageDoorId, ID +* ֵ void +*/ +void SetGarageDoorOpenLogicM(const UINT16 garageDoorId); + +/* +* Ź߼ +* ˵ const UINT16 garageDoorId, ID +* ֵ void +*/ +void SetGarageDoorCloseLogicM(const UINT16 garageDoorId); + +/* +* ιϽ߼⴦ǰΪ·һΣΪ޲ +* ˵ const UINT16 phySectionId, ID +* const UINT16 lockBelongRouteId ·ID +* ֵ: CI_SUCCESS ɹ +* CI_ERROR ʧ +*/ +UINT8 CLDPhySectionFaultUnlockDeal(const UINT16 phySectionId,const UINT16 lockBelongRouteId); + +/* +* ȡ۷źŻID +* ˵ UINT16 routeId, ·ID +* ֵ ۷źŻID +*/ +UINT16 GetReturnId(const UINT16 routeId); + +/* +* ۷Զ˽·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +void DTrainRtnUnlockRemoteRAllLockP(const UINT16 routeId); + +/* +* ȡϴ߼ +* ˵ void +* ֵ void +*/ +void CancelWashWorkLogicM(void); + +/* +* ·ͬ߼ +* ˵ void +* ֵ void +*/ +void RouteDCTYLogicM(UINT16 routeId); + +/* +* ·ͬ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* RETURN_OPEN_ERR_SIGOPEN +*/ +UINT8 DRouteDCTYCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* Σֿг· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepOpenLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ÷ǽ·߼״̬ +* ˵ const UINT16 nonRouteId, ǽ·ID +* const UINT8 lockState, ״̬ +* ֵ void +* cgh-20230529-޸YF0083-823 +*/ +void SetNonRouteLogSecLockState(const UINT8 nonRouteId, const UINT8 lockState); + +/* +* ǽ·Ƿ߼ +* ˵ const UINT16 chNonRouteId, ǽ·ID +* const UINT16 wLogSecId ߼ID +* ֵ CI_ERROR +* CI_SUCCESS +* cgh-20230529-޸YF0083-823 +*/ +UINT8 NonRouteLogSecCheck(const UINT8 chNonRouteId, const UINT16 wLogSecId); +/* +* ת۷·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +* fan0824 +*/ +void ZHGDTrainRtnUnlockRouteProc(const UINT16 routeId); +/* +* ߼ +* ˵ +* ֵ +*/ +void GargeDoorLogicProcess(void); + +/* +* · +* ˵ UINT16 routeId, ·ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20250224 +*/ +UINT8 SetLeadRouteCheck(const UINT16 routeId); + +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20250224 +*/ +UINT8 LeadRouteSetSectionCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicCheck.c b/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicCheck.c new file mode 100644 index 0000000..3e92915 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicCheck.c @@ -0,0 +1,25890 @@ +/******************************************************** +* +* InterlockLogicCheck.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-10 +* ߣ +* ߼ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + +#include "InterlockLogicCheck.h" +#include "../System/CiSystemDefine.h" +#include "../ERROR/ErrorDefine.h" +#include "RouteConfigDataManage.h" +#include "InterlockLogicManage.h" +#include "AxisSort.h" +#include "AxisSort_api.h" +#include "EnvelopeManageAPI.h" +#include "LogicalRouteLogicCheck.h" +#include "../Garagedoor/GaragedoorDataManage.h" +#include "../EnvelopeManage/ELMDataPrepare.h" + +/* +* źŻ: ·ŵź״ָ̬ܸźŻ״̬ +* źŻʾΪźţ·źŲܸ +* źŻΪźŻ·źŻֻΪźš +* гźŻ-г(0xbb),гźŻ-гź()(0x55) +* ˵ UINT16 const routeId ·ID +* UINT16 const relationSignalId źŻID +* UINT8 const devStatus 豸״̬ +* ֵ 0 ʧ +* >0 豸״̬ +*/ +static UINT8 CheckRelationSignalOnSameOpen(UINT16 const routeId, UINT16 const relationSignalId, UINT8 const devStatus); + +/* +* +* ˵ UINT16 routeId ·ID +* ֵ +CI_ERROR:ʧ +CI_SUCCESS:ɹ +CI_ROUTE_RECOVER_ERR:ʧܣǵʱؿź +*/ +static UINT8 OtherCiValidErrCheck(UINT16 const routeId); +/* +* ·źŻ״̬ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteSignalFLockCheck(UINT16 const routeId, UINT16 *pDevId,UINT8 *pDevState) +{ + UINT8 routeInitFsState = 0u; + /* źŻ */ + UINT8 const checkSum = GetRouteFengSuoSignalSum(routeId); + UINT16* const dataIdBuf = GetRouteFengSuoSignalIdBuf(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + UINT8 sigBelongCi = 0u;/*źŻ*/ + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportState = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 localCi = GetSystemParaLocalCiId();/**/ + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + routeInitFsState = GetRouteInitFSStatus(routeId); + + if (ROUTE_INIT_NOT_FS == routeInitFsState) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + *pDevState = SIGNAL_FENGSUO_YES; + } + + if (CI_SUCCESS == reVal) + { + /* ״̬ */ + if(NULL != dataIdBuf) + { + if(0u != checkSum) + { + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i]; + devState = GetSignalFLockState(devId); + + sigBelongCi = GetSignalBelongCiId(devId);/*ȡźŻ*/ + commState = GetLocalCiAndOtherCiTransSta(sigBelongCi);/*ͨͨ״̬*/ + + if ((localCi !=sigBelongCi) && (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag) && + (FUNC_SWITCH_ON == funcSwitchSupportState)) + { + + /*źŻ뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣԲźŻ״̬*/ + reVal = CI_SUCCESS; + } + else + { + if (SIGNAL_FENGSUO_NO == devState) + { + /* ͨ*/ + reVal = CI_SUCCESS; + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + break; + } + } + } + } + else + { + /*޿ɷźŻ*/ + /*޿ɷźŻ򲻼,жźŻ״̬ͨ*/ + reVal = CI_SUCCESS; + } + } + else + { + /*ݴ*/ + reVal = CI_ERROR; + } + } + + + + /*ȫͨ*/ + return reVal; +} + + +/* +* ·жЧ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ж +* CI_SUCCESS ж +*/ +UINT8 RouteSignalEnemyVainCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState) +{ +/* жԽ· */ + UINT8 const checkSum = GetRouteEnemySignalSum(routeId); + RouteEnemySignalStruct* const dataIdBuf = GetRouteEnemySignalData(routeId); + +/* ֲʼ */ + UINT16 i = 0u,j = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 enemySwitchSum = 0u; + RouteConditionSwitchStruct* enemySwitchConStru = NULL; + UINT16 enemySwitchId = 0u; + UINT8 enemySwitchPos = 0u; + + UINT8 enemySwitchPosValid = CI_ERROR; + UINT8 reVal = CI_ERROR; + UINT8 localCiID = GetSystemParaLocalCiId(); + UINT8 sigBelongCiId = 0u; + UINT8 commNeiborCiState = 0u; + UINT8 signalCurColor = 0u; + UINT8 routeInitEnemyState = 0u;/*·ʼж*/ + + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + routeInitEnemyState = GetRouteInitEnemyStatus(routeId);/*ȡ·ʼж*/ + + /*ָ*/ + if (NULL == dataIdBuf) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + if(ROUTE_INIT_NOT_ENEMY == routeInitEnemyState) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + if (CI_SUCCESS == reVal) + { + /*ʼ*/ + for (i = 0u; iSwitchId; + enemySwitchPos = GetSwitchCurPosition(enemySwitchId); + + if (enemySwitchPos == enemySwitchConStru->SwitchPosition) + { + enemySwitchPosValid = CI_ERROR; + } + else + { + /*δж*/ + enemySwitchPosValid = CI_SUCCESS; + break; + } + } + + if (CI_ERROR == enemySwitchPosValid) + { + /*вж*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + else + {/*вж*/ + reVal = CI_SUCCESS; + } + } + else + { + /*޲ж*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + } + else + {/*жźδ*/ + sigBelongCiId = GetSignalBelongCiId(devId);/*ȡжźID*/ + + if (localCiID != sigBelongCiId) + {/*ڱźŻ*/ + /*CIͨ״̬*/ + (void)UpdateCiTransmitState(localCiID, CI_SYSTEM_TYPE_CI, sigBelongCiId); + commNeiborCiState = GetCiTransmitState(CI_SYSTEM_TYPE_CI,sigBelongCiId); + + if (TRANSMIT_STATE_GOOD != commNeiborCiState) + {/*ͨжϣΪж*/ + if ((CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*ǰ·̵ּ֧ӿڣҼ̵ӿȷϣҪźŻĵж*/ + } + else + { + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + + } + else + {/*ͨδжźδţж*/ + reVal = CI_SUCCESS; + } + } + else + {/*жźڱδжԲ*/ + reVal = CI_SUCCESS; + } + } + if (CI_ERROR == reVal) + { + break; + } + } + } + /* δ⵽ж */ + return reVal; +} + + +/* +* ·жЧ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ж +* CI_SUCCESS ж +*/ +UINT8 ReverseRouteSigEnemyVainCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState) +{ +/* жԽ· */ + UINT8 const checkSum = GetRouteEnemySignalSum(routeId); /*ȡжźŻ*/ + RouteEnemySignalStruct* const dataIdBuf = GetRouteEnemySignalData(routeId); /*ȡжźŻṹ*/ + +/* ֲʼ */ + UINT16 i = 0u,j = 0u,k = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + + UINT8 enemySwitchSum = 0u; /*жԵĿ*/ + RouteConditionSwitchStruct* enemySwitchConStru = NULL; /*ṹ*/ + UINT16 enemySwitchId = 0u; /*жԵID*/ + UINT8 enemySwitchPos = 0u; /*ԶԵλ*/ + UINT8 chRevrsRouteHasAutoSigRouteSum = 0u; /*·ԶźŽ·Ŀ*/ + UINT16 * reverseRouteAutoSigRouteBuf = NULL; /*·ԶźŽ·Id*/ + UINT16 startSignalId = 0u; /*·ʼźŻ*/ + UINT8 enemySwitchPosValid = CI_ERROR; /*жԵλ*/ + + UINT8 retVal = CI_ERROR; /*ֵ*/ + UINT8 localCiID = GetSystemParaLocalCiId(); + UINT8 sigBelongCiId = 0u; + UINT8 commNeiborCiState = 0u; + + UINT8 routeInitEnemyState = 0u;/*·ʼж*/ + + chRevrsRouteHasAutoSigRouteSum = GetReverseRouteIncludeRouteSum(routeId);/*ȡ·ԶźŽ·Ŀ*/ + reverseRouteAutoSigRouteBuf = GetReverseRouteIncludeRouteBuf(routeId);/*ȡ·ԶźŽ·ID*/ + + routeInitEnemyState = GetRouteInitEnemyStatus(routeId);/*ȡ·ʼж*/ + +/* ж״̬ */ + if (NULL == dataIdBuf) + { + /*޼:سɹ*/ + retVal = CI_ERROR; + } + else + { + retVal =CI_SUCCESS; + } + + if (CI_SUCCESS == retVal) + { + if(ROUTE_INIT_ENEMY == routeInitEnemyState) + { + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + for (i = 0u; i 0u) + { + /*жԵλü*/ + enemySwitchPosValid = CI_ERROR; + for (j = 0u; jSwitchId; + enemySwitchPos = GetSwitchCurPosition(enemySwitchId); + + if (enemySwitchPos == enemySwitchConStru->SwitchPosition) + { + enemySwitchPosValid = CI_ERROR; + } + else + { + /*δж*/ + enemySwitchPosValid = CI_SUCCESS; + break; + + } + } + + if (enemySwitchPosValid == CI_ERROR) + { + /*жԵȫжԣжų*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + else + { + /*жԵȫжԣж*/ + retVal = CI_SUCCESS; + } + } + else + { + /*޲жȫжԣжų*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + } + else + { + /*жźδ*/ + sigBelongCiId = GetSignalBelongCiId(devId);/*ȡжźID*/ + + if (localCiID != sigBelongCiId) + {/*ڱźŻ*/ + /*CIͨ״̬*/ + (void)UpdateCiTransmitState(localCiID, CI_SYSTEM_TYPE_CI, sigBelongCiId); + commNeiborCiState = GetCiTransmitState(CI_SYSTEM_TYPE_CI,sigBelongCiId); + + if (TRANSMIT_STATE_GOOD != commNeiborCiState) + {/*ͨжϣΪж*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + else + {/*ͨδжźδţж*/ + retVal = CI_SUCCESS; + } + } + else + {/*жźڱδжԲ*/ + retVal = CI_SUCCESS; + } + + } + } + if (CI_ERROR == retVal) + { + break; + } + + } + } + + return retVal; +} + + +/* +* ·ղ +* ˵ UINT16 const checkRouteId ·κ +* UINT16 const zcPhySecId ղκ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RoutePhySecZhaoChaCheck(UINT16 const checkRouteId ,UINT16 const zcPhySecId,UINT16 *pDevId,UINT8 *pDevState ) +{ + UINT8 secFlockState = 0u; /*η״̬*/ + UINT8 secLockState = 0u; /*״̬*/ + UINT8 secLockedDirection = 0u; /*շ*/ + UINT8 routeDirection = 0u; /*·*/ + UINT8 retVal = CI_ERROR; /*ֵ*/ + + UINT8 phyBelongCi = 0u;/**/ + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 localCi = GetSystemParaLocalCiId();/**/ + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + UINT16 zcPhyLockBelongRouteId = 0u; + UINT8 haveDirChangeInLockRoute = 0u;/*·ڷ仯*/ + UINT8 lockRouteZcPhyOppose = 0u; + UINT8 haveDirChangeInCheckRoute = 0u; + UINT8 checkRouteZcPhyOppose = 0u; + UINT8 haveDirChangeAfterLockRoute = 0u; + UINT16 phyPLockBelongRouteId = 0u; + + phyBelongCi = GetPhySecBelongCiId(zcPhySecId);/*ȡ*/ + + routeDirection = GetRouteDirection(checkRouteId); /*ȡ·*/ + + if ((NULL == pDevId ) || (NULL == pDevState)) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + + commState = GetLocalCiAndOtherCiTransSta(phyBelongCi);/*ͨͨ״̬*/ + + if ((localCi !=phyBelongCi) && (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*źŻ뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣԲźŻ״̬*/ + retVal = CI_SUCCESS; + } + else + { + secFlockState = GetPhySecFLockState(zcPhySecId); /*ȡη״̬*/ + if(PHYSICAL_SECTION_FLOCK_NO == secFlockState) + {/*η״̬:δ*/ + + secLockState = GetPhySecLockState(zcPhySecId); /*ȡ״̬*/ + + if(PHYSICAL_SECTION_LOCK_NO == secLockState) + { + /*״̬:δ ղμͨ*/ + } + else if((PHYSICAL_SECTION_LOCK_PROTECT == secLockState) || (PHYSICAL_SECTION_LOCK_NORMAL == secLockState) + || (PHYSICAL_SECTION_LOCK_EXCEPT == secLockState) || (PHYSICAL_SECTION_LOCK_DELAY == secLockState) + || (PHYSICAL_SECTION_LOCK_FAULTDELAY == secLockState)) + {/*״̬: 쳣 ʱ ʱ·ʱʱղָʾͻȻƵ*/ + + zcPhyLockBelongRouteId = GetPhySecRLockBelongRouteId(zcPhySecId);/*ȡղ·ID*/ + haveDirChangeInLockRoute = GetRouteHaveDirChangePointIn(zcPhyLockBelongRouteId); /*ս·ڷ仯*/ + lockRouteZcPhyOppose = GetRoutePhySecShouldLockOppose(zcPhyLockBelongRouteId,zcPhySecId);/*ǷӦȡ*/ + + + /*·仯ȡ*/ + haveDirChangeInCheckRoute = GetRouteHaveDirChangePointIn(checkRouteId); + checkRouteZcPhyOppose = GetRoutePhySecShouldLockOppose(checkRouteId,zcPhySecId);/*ǷӦȡ*/ + + /**/ + if(PHYSICAL_SECTION_LOCK_PROTECT == secLockState) + { + /*·*/ + phyPLockBelongRouteId = GetPhySecPLockBelongRouteId(zcPhySecId); + /*·ڷ仯*/ + haveDirChangeAfterLockRoute = GetRouteHaveDirChangePointAfter(phyPLockBelongRouteId); + } + + secLockedDirection = GetPhySecLockDirection(zcPhySecId); /*ȡշ*/ + debug_infor_printf((const)"\n RoutePhySecZhaoChaCheck Route%d -ZCPhyRouteDirChange:%d--haveDirChangeInCheckRoute:%d .-ZcPhyOppose%d_checkRouteZcPhyOppose:%d \n", checkRouteId, haveDirChangeInLockRoute, haveDirChangeInCheckRoute, lockRouteZcPhyOppose, checkRouteZcPhyOppose); + /*·:աձ·*/ + if(((PHYSICAL_SECTION_LOCK_PROTECT != secLockState) && (zcPhyLockBelongRouteId != checkRouteId)) + || ((PHYSICAL_SECTION_LOCK_PROTECT == secLockState) && (phyPLockBelongRouteId != checkRouteId))) + { + /*1.·ڷ仯ӦȡҼ·޷仯㣻2ս·޷仯㣬ڷս·ղӦȡΣȡ + 3գ·ڷ仯㣬ȡ*/ + if (((ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInLockRoute) && (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == lockRouteZcPhyOppose) && (ROUTE_HAVE_DIR_CHANGE_POINT != haveDirChangeInCheckRoute)) + || ((ROUTE_HAVE_DIR_CHANGE_POINT != haveDirChangeInLockRoute) && (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInCheckRoute) && (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == checkRouteZcPhyOppose)) + || ((PHYSICAL_SECTION_LOCK_PROTECT == secLockState) && (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeAfterLockRoute))) + { + + if(CI_SYSTEM_DIRECTION_UP == secLockedDirection) + { + secLockedDirection = CI_SYSTEM_DIRECTION_DOWN; + } + else if(CI_SYSTEM_DIRECTION_DOWN == secLockedDirection) + { + secLockedDirection = CI_SYSTEM_DIRECTION_UP; + } + else + { + /**/ + } + } + else + { + } + if(routeDirection == secLockedDirection) + { + /*շͽ·һ£ͨ*/ + } + else + { + /*շͽ·һ£ʧ*/ + retVal = CI_ERROR; + *pDevId = zcPhySecId; + *pDevState = secLockState; + } + } + else + { + /**/ + } + } + else + { /*״̬:Ƿ״̬ ʧ*/ + retVal = CI_ERROR; + *pDevId = zcPhySecId; + *pDevState = secLockState; + } + } + else + {/*η״̬: ʧ*/ + retVal = CI_ERROR; + *pDevId = zcPhySecId; + *pDevState = secFlockState; + } + } + + } + + + return retVal; +} + +/* +* ·ղ +* ˵ UINT16 const routeId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* RELAY_STATE_WAITE ·ղ̵--ȴ +* RES_CHECK_STATE_WAITE Դ鱾ղ̵--ȴ +*/ +UINT8 RouteRelayZhaoChaCheck(UINT16 const routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT16 relayId = 0u; + UINT8 relayState = 0u; + UINT8 zcPhySecSum = 0u; /*ղĿ*/ + UINT16* pZcPhySecIdBuf = NULL; /*ղID*/ + UINT8 ii = 0u; + UINT16 thisRealyId = 0u; + UINT8 thisRelayState = 0u; + UINT8 routeState = 0u; + UINT8 retVal = CI_ERROR; /*ֵ*/ + UINT16 pDevId = 0u; + UINT8 pDevState = 0u; + UINT8 funcSwitchSupportRelayInterface = 0u; + UINT8 confirmRelayInterfaceFlag = 0u; + UINT16 endSignalId = 0u; + UINT8 commState = 0u;/*ͨ״̬*/ + UINT8 endSignalBelongCi = 0u; + UINT8 localCi = 0u; + UINT8 chRouteLevel = 0U; + + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + /* Զղ */ + zcPhySecSum = GetRouteThatZhaoChaPhySecSum(routeId); /*ȡղĿ*/ + pZcPhySecIdBuf = GetRouteThatZhaoChaPhySecIdBuf(routeId); /*ȡղID*/ + + endSignalId = GetRouteEndSignalId(routeId);/*·նźŻ*/ + endSignalBelongCi = GetSignalBelongCiId(endSignalId); + + funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + + if(endSignalBelongCi != localCi) + { + /*ȡͨ״̬*/ + commState = GetLocalCiAndOtherCiTransSta(endSignalBelongCi); + } + + /*̵ӿȷ*/ + if((localCi != endSignalBelongCi) && (TRANSMIT_STATE_BAD == commState) + && (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag) + && (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*ȡ̵ӿڱղID*/ + thisRealyId = GetRouteRelayBenDuanZcIdOnRelay(routeId); + /*ȡ̵ӿڶԶղID*/ + relayId = GetRouteRelayDuiDuanZcIdOnRelay(routeId); + } + else + { + /*·ලȷ*/ + chRouteLevel = GetRouteLevel(routeId); + + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + thisRealyId = GetRouteThisZhaoChaRelayId(routeId); /*ģʽղ̵ID*/ + relayId = GetRouteThatZhaoChaRelayId(routeId); /*ģʽԶղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + thisRealyId = GetRouteCbtcThisZhaoChaRelayId(routeId);/*CBTCģʽղ̵ID*/ + relayId = GetRouteCbtcThatZhaoChaRelayId(routeId); /*CBTCģʽԶղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + + } + + if (NULL == pZcPhySecIdBuf) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + + for (ii = 0u; ii < zcPhySecSum; ii++) + { + retVal = RoutePhySecZhaoChaCheck(routeId,pZcPhySecIdBuf[ii],&pDevId,&pDevState); + if(CI_ERROR == retVal) + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,pDevId,ETYPE_PS_ZHAOCHA_CHECK,pDevState,sendLevel); + break; + } + + } + } + + if(CI_SUCCESS == retVal) + {/*ղμͨ,鱾ղ̵*/ + + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + if (thisRealyId > 0u) + {/*ڱղ̵*/ + thisRelayState = GetRelayCollState(thisRealyId); /*ȡָID̵״̬*/ + if ((ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState)) + { + /*·״̬쳣Ԥգӽ쳣 + жϱղ״̬*/ + if (RELAY_STATE_UP == thisRelayState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, thisRealyId, ETYPE_THIS_ZHAOCHA, RELAY_STATE_UP, sendLevel); + retVal = CI_ERROR; + } + } + else if ((ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState)) + { + /*Żʱ + 1·״̬ΪӽţԤȿ,·תΪģʽʱõıղ̵δ*/ + retVal = KeepSignalRelayZhaoChaCheck(routeId); + if (CI_ERROR == retVal) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, thisRealyId, ETYPE_THIS_ZHAOCHA, RELAY_STATE_UP, sendLevel); + + } + } + else if (ROUTE_STATE_HALF_UNLOCK == routeState) + { + /*Żʱ + ֽ·гԴʱղ̵δ*/ + retVal = KeepSignalRelayZhaoChaCheck(routeId); + if (CI_ERROR == retVal) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, thisRealyId, ETYPE_THIS_ZHAOCHA, RELAY_STATE_UP, sendLevel); + + } + } + else if (ROUTE_STATE_FIRST_LOCK == routeState) + { + if(RELAY_STATE_UP == thisRelayState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, thisRealyId, ETYPE_THIS_ZHAOCHA, RELAY_STATE_UP, ESEND_LEVEL_ZERO); + /*ȴصȴ־*/ + retVal = RELAY_STATE_WAITE; + } + + } + /* ԶԶ쳣ʱҲղ*/ + else if ((ROUTE_STATE_DELAY_UNLOCK == routeState) + || (ROUTE_STATE_AUTO_UNLOCK == routeState) + || (ROUTE_STATE_AUTO_UNLOCKERR == routeState) + || (ROUTE_STATE_HALF_UNLOCKDELAY == routeState)) + { + if (RELAY_STATE_UP == thisRelayState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, thisRealyId, ETYPE_THIS_ZHAOCHA, RELAY_STATE_UP, sendLevel); + retVal = CI_ERROR; + } + + } + else + { + /*·״̬Ϊֵʱ*/ + } + } + + } + + + if((CI_SUCCESS == retVal) || (RELAY_STATE_WAITE == retVal) || (RES_CHECK_STATE_WAITE == retVal)) + {/*ղ̵ͨ/ȴԶղ̵*/ + if(0u != relayId) + {/*ڶԶղ̵*/ + + relayState = GetRelayCollState(relayId); + + /* ղ*/ + if (RELAY_STATE_UP == relayState) + { + /*ͨ*/ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_RELAY,relayId,ETYPE_THAT_ZHAOCHA,relayState,sendLevel); + + retVal = CI_ERROR; + } + } + } + + return retVal; + +} + + +/* +* ·ȫм +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllSecOccuClearCheck(UINT16 const routeId, UINT16 *pDevId,UINT8 *pDevState ) +{ +/* ·*/ + UINT8 const checkSum = GetRoutePhysicalSectionSum(routeId); + RoutePhysicalSectionStruct* const dataIdBuf = GetRouteSectionData(routeId); + +/* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + +/* ռü */ + if (0u == checkSum) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (i = 0u; i 0u) && (SECTION_OCCUPY_YES == devCurMergeState)) + {/*ǽ·գں״̬ռõ*/ + prePhySecSum = GetRoutePhysicalSectionSum(preLockedRouteID);/*ȡ·*/ + pPrePhysecData = GetRouteSectionData(preLockedRouteID);/*ȡ·*/ + if ((prePhySecSum > 0u) && (NULL != pPrePhysecData)) + {/**/ + flagCheck = CI_SUCCESS; + if (prePhySecSum > 1u) + {/*1ΣԳһ֮Σδռ*/ + for (jj=0u;jj<(prePhySecSum - 1u);jj++) + { + tmpRLockedRouteID = GetPhySecRLockBelongRouteId(pPrePhysecData[jj].PhysicalSectionId); + if ((0u == tmpRLockedRouteID) || (preLockedRouteID != tmpRLockedRouteID)) + {/*δ·:··IDΪ0*/ + flagCheck = CI_SUCCESS; + } + else + { + flagCheck = CI_ERROR; + break; + } + } + } + else + { + /*1ΣֻҪռռͨ͹*/ + } + + if (CI_SUCCESS == flagCheck) + { + if (pPrePhysecData[prePhySecSum - 1u].PhysicalSectionId == devId) + {/*֮ǰյĽ·һ*/ + + } + else + { + flagCheck = CI_ERROR; + } + } + + + if (CI_ERROR == flagCheck) + { + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + + } + else + { + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + debug_infor_printf((const)"Route %d ConfigData error.\n",preLockedRouteID); + } + } + else + { + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + debug_infor_printf((const)"Section %d's routeID %d Data error,Occupy %d.\n",devId,preLockedRouteID,devCurMergeState); + } + } + else + { + /*״̬Ч״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + } + else + { + /*״̬Ч״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + debug_infor_printf((const)"Section %d state %d: FaultLock or ? \n",devId,devState); + } + + if (CI_ERROR == reVal) + { + break; + } + } + } + + /*ȫͨ*/ + return reVal; +} + +/* +* ·ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 ReverseRouteSecLockValidCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState) +{ +/* ·*/ + UINT8 const checkSum = GetRoutePhysicalSectionSum(routeId);/*ȡ·Ŀ*/ + RoutePhysicalSectionStruct* const dataIdBuf = GetRouteSectionData(routeId);/*ȡ·νṹ*/ + +/* ֲʼ */ + UINT8 i = 0; + UINT8 j = 0U; + UINT16 devId = 0U; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + UINT8 secLockDirection = 0U; /*շ*/ + UINT8 chRevrsRouteHasAutoSigRouteSum = 0U; /*·ԶźŽ·Ŀ*/ + UINT16 * reverseRouteAutoSigRouteBuf = NULL; /*·ԶźŽ·Id*/ + UINT16 secLockBlongRouteId = 0U; /*·Id*/ + UINT16 secPLockBlongRouteId = 0U; /*η·Id*/ + UINT8 retVal = CI_ERROR; /*ֵ*/ + UINT8 const routeDirDirection = GetRouteDirection(routeId); /*·*/ + UINT8 cIndex = 0U; + UINT8 cPhySecIncLogSecNum = 0U; /*ΰ߼Ŀ*/ + UINT16* pPhySecIncLogSecId = NULL; /*ΰ߼ID*/ + UINT8 cRouteState = ROUTE_STATE_IDLE; + UINT8 cRouteType = 0U; /*·*/ + + chRevrsRouteHasAutoSigRouteSum = GetReverseRouteIncludeRouteSum(routeId);/*ȡ·ԶźŽ·Ŀ*/ + reverseRouteAutoSigRouteBuf = GetReverseRouteIncludeRouteBuf(routeId);/*ȡ·ԶźŽ·ID*/ + + if ((0U != checkSum) && (NULL != dataIdBuf) && (NULL != pDevId) && (NULL != pDevState)) + { + retVal = CI_SUCCESS; + for (i = 0U; i < checkSum; i++) + { + cPhySecIncLogSecNum = GetPhySecIncLogSecSum(dataIdBuf[i].PhysicalSectionId); + pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(dataIdBuf[i].PhysicalSectionId); + + if ((0U != cPhySecIncLogSecNum) && (NULL != pPhySecIncLogSecId)) + { + /*ΰ߼״̬ǷϷ*/ + for (cIndex = 0U; cIndex < cPhySecIncLogSecNum; cIndex++) + { + devId = pPhySecIncLogSecId[cIndex];/*ȡ߼ID*/ + devState = GetLogSecLockState(devId);/*ȡ߼״̬*/ + secLockDirection = GetLogSecLockDir(devId);/*߼շ*/ + + if (LOG_SECTION_LOCK_NO == devState) + { + /*δգͨ*/ + } + else if (LOG_SECTION_LOCK_PROTECT == devState) + { + if (secLockDirection == routeDirDirection) + { + /*շһ£ͨ*/ + } + else + { + /*շһ*/ + if (0U == chRevrsRouteHasAutoSigRouteSum) + { + /*·вԶźŽ·(ɵôβDZԶźŽ·)鲻ͨ*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + else + { + secPLockBlongRouteId = GetLogSecPLockRouteId(devId); /*߼η·*/ + for (j = 0U; j < chRevrsRouteHasAutoSigRouteSum; j++) + { + /*ÿԶźŽ·鷴·ǷԶźŽ·*/ + if (secPLockBlongRouteId == reverseRouteAutoSigRouteBuf[j]) + { + break; /*ΪԶźŽ·գֹͣ*/ + } + } + + if (j == chRevrsRouteHasAutoSigRouteSum) + { + /*βΪκԶźŽ·գ鲻ͨ*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + } + } + } + else if (LOG_SECTION_LOCK_NORMAL == devState) + { + secLockBlongRouteId = GetLogSecLockBelongRoute(devId); /*߼·ID*/ + cRouteState = GetRouteState(secLockBlongRouteId); + cRouteType = GetRouteType(routeId); /*ȡ·*/ + + if ((ROUTE_STATE_HALF_UNLOCK == cRouteState) && (ROUTE_TYPE_LIECHE == cRouteType) && (secLockDirection == routeDirDirection)) + { + /*߼·ǰΪֽ·ȴ״̬Ϊг·շ뱾·ͬͨ*/ + } + else + { + if (0U == chRevrsRouteHasAutoSigRouteSum) + { + /*·вԶźŽ·(ɵôβΪԶźŽ·)鲻ͨ*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + else + { + /*·аԶźŽ·*/ + for (j = 0U; j < chRevrsRouteHasAutoSigRouteSum; j++) + { + /*ÿԶźŽ·*/ + if (secLockBlongRouteId == reverseRouteAutoSigRouteBuf[j]) + { + break; /*ΪԶźŽ·գֹͣ*/ + } + } + if (j == chRevrsRouteHasAutoSigRouteSum) + { + /*βΪκԶźŽ·գ鲻ͨ*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + } + } + } + else + { + /*״̬Чʧ*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + + if (CI_ERROR == retVal) + { + break; + } + } + } + else + { + retVal = CI_ERROR; /*ȡΰ߼ʧܣ0ʧ*/ + } + + if (CI_ERROR == retVal) + { + break; + } + } + } + else + { + retVal = CI_ERROR; /*ȡ·ݴ/ηǷ0ʧ*/ + } + + return retVal; +} + +/* +* ·߼ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ +*/ +UINT8 ReverseRouteLogSecLockValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ·߼*/ + UINT16 const checkSum = GetRouteLogSectionSum(routeId); + UINT16* const dataIdBuf = GetRouteLogSectionIdBuf(routeId);/* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 j = 0u; /* ѭ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 secLockDirection = 0u; /*ηշ*/ + UINT8 chRevrsRouteHasAutoSigRouteSum = 0u; /*·ԶźŽ·Ŀ*/ + UINT16 * reverseRouteAutoSigRouteBuf = NULL; /*·ԶźŽ·Id*/ + UINT16 secLockBlongRouteId = 0u; /*·Id*/ + UINT16 secPLockBlongRouteId = 0u; /*η·Id*/ + UINT8 retVal = CI_SUCCESS; /*ֵ*/ + UINT8 cRouteState = ROUTE_STATE_IDLE; /*·״̬*/ + UINT8 routeDirDirection = 0U; /*·*/ + UINT8 cRouteType = 0U; /*·*/ + + routeDirDirection = GetRouteDirection(routeId); + chRevrsRouteHasAutoSigRouteSum = GetReverseRouteIncludeRouteSum(routeId);/*ȡ·ԶźŽ·Ŀ*/ + reverseRouteAutoSigRouteBuf = GetReverseRouteIncludeRouteBuf(routeId);/*ȡ·ԶźŽ·ID*/ + + if ((0u == checkSum) || (NULL == dataIdBuf)) + { + /*ݴ*/ + retVal = CI_ERROR; + } + else + { + /*к*/ + for (i = 0u; i 0u) + { + /*޵λü*/ + intruSwitchPosValid = CI_ERROR; + for (j = 0u; j < intruSwitchSum; j++) + { + intruSwitchConStru = &dataIdBuf[i].ConditionSwitchStru[j]; + intruSwitchId = intruSwitchConStru->SwitchId; + intruSwitchPos = GetSwitchCurPosition(intruSwitchId); + + if ((intruSwitchPos == intruSwitchConStru->SwitchPosition) + || (SWITCH_POSITION_SIKAI == intruSwitchPos) + || (SWITCH_POSITION_MOVE == intruSwitchPos) + || (SWITCH_POSITION_JICHA == intruSwitchPos) + || (SWITCH_POSITION_INVALID == intruSwitchPos)) + { + /* ռʱȥж */ + if ((PHYSICAL_SECTION_FLOCK_NO == devFLockState) + && (PHYSICAL_SECTION_JUMP_LOCK_NO == devJumpLockState) + && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState)) + { + if ((chPhySecLockDir == dataIdBuf[i].chCondSwitLockDir) + && ((CI_SYSTEM_DIRECTION_UP == dataIdBuf[i].chCondSwitLockDir) + || (CI_SYSTEM_DIRECTION_DOWN == dataIdBuf[i].chCondSwitLockDir))) + { + if (LOGICSECTION_OCCUPY_CT == chPhySecCtOrUt) + { + intruSwitchPosValid = CI_SUCCESS; /*ɹ*/ + } + else + { + intruSwitchPosValid = IntruSecVainCheck(devId); + } + } + else + { + intruSwitchPosValid = CI_ERROR; + } + } + else + { + intruSwitchPosValid = CI_ERROR; + } + } + else + { + /*δ*/ + intruSwitchPosValid = CI_SUCCESS; + break; + } + } + + if (CI_ERROR == intruSwitchPosValid) + { + /*в*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + } + else + { + /*޲*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + if (CI_ERROR == reVal) + { + break; + } + } + else if ((SECTION_OCCUPY_NO == devState) + && ((PHYSICAL_SECTION_FLOCK_NO == devFLockState) || (FUNC_SWITCH_ON == checkFlockFlag)) + && (PHYSICAL_SECTION_LOCK_NO == devLockState) + && (PHYSICAL_SECTION_JUMP_LOCK_NO == devJumpLockState) + && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState)) + {/*δռ(δ򲻼)δδԾ*/ + /*μͨ*/ + } + else + {/*״̬쳣*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + break; + } + + } + } + + /* δ⵽ */ + return reVal; +} + + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteSwitchYLockCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState ) +{ +/* · */ + UINT8 const checkSum = GetRouteSwitchSum(routeId); + RouteSwitchStruct* const dataIdBuf = GetRouteSwitchData(routeId); + +/* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + +/* ״̬ */ + if (NULL == dataIdBuf) + { + /*ָΪ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + /*ʼ*/ + for (i = 0u; i routeId) && (NULL != pDevId) && (NULL != pDevState)) + { + reVal = CI_SUCCESS; + /*ȡ·Ϣ*/ + routeProSwitchSum = GetRouteHalfProSwData(routeId, szRouteProSwitchData);/*ȡ·*/ + if (0U != routeProSwitchSum) + { + for (i = 0u; i < routeProSwitchSum; i++) + { + proSwitchId = szRouteProSwitchData[i].ProtectSwitchId;/*id*/ + proSwitchRoutePos = szRouteProSwitchData[i].ProtectPosition;/*·Ҫķλ*/ + switchCurPosition = GetSwitchCurPosition(proSwitchId); + proSwitchSecId = GetSwitchPhySectionId(proSwitchId);/*ȡid*/ + devState = GetPhySecUseState(proSwitchSecId); /*ȡ״̬*/ + + /* 鱾 */ + if (PHYSICAL_SECTION_USING_NO == devState) + { + /* ͨ*/ + reVal = CI_SUCCESS; + } + else + { + phySecUseRouteId = GetPhySecUseRouteId(proSwitchSecId); + phySecProtectUseRouteId = GetPhySecProtectUseRouteId(proSwitchSecId); + if ((0u < phySecUseRouteId) || (0u < phySecProtectUseRouteId)) + { + reVal = CI_SUCCESS;/*ִе˴˴뱣ֵ֤һ0*/ + } + else + { + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + /*鵱ǰλûλǷ뱾·Ҫķλͬ*/ + if (proSwitchRoutePos == switchCurPosition) + { + reVal = CI_SUCCESS; + } + else + { + /*õλǷ·Ҫλͬ*/ + SwitchDrvPos = GetSwitchPreExpDrvPosition(proSwitchId); + if ((SWITCH_POSITION_DINGWEI == proSwitchRoutePos) && (SWITCH_DRIVE_POS_DINGWEI == SwitchDrvPos)) + { + reVal = CI_SUCCESS; + } + else if ((SWITCH_POSITION_FANWEI == proSwitchRoutePos) && (SWITCH_DRIVE_POS_FANWEI == SwitchDrvPos)) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + } + + /*ʧܣ˳*/ + if (CI_SUCCESS != reVal) + { + /*״̬һ·ع״̬*/ + *pDevId = proSwitchSecId; + *pDevState = devState; + break; + } + } + + } + } + else + { + reVal = CI_SUCCESS; /*޷سɹ*/ + } + + } + else + { + /*ʧ*/ + reVal = CI_ERROR; + } + return reVal; +} + + + +/*****************************************************************************************/ + +/* +* ·ҪǷмζ +* ˵ UINT16 routeId · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CheckDTrainRoutePhySecOccupy(const UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT8 ii= 0u; + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reVal = CI_SUCCESS; + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + + + if (sectionSum == 0u) + { + reVal = CI_ERROR; + } + else + { + for(ii = 0u; ii < sectionSum; ii++) + { + if (((ROUTE_STOPCHECK_SET_YES == GetRouteStopCheckFlag(routeId)) && + (PHYSICAL_SECTION_LJK_YES == GetPhySecLjkFlag(pRouteSecStru[ii].PhysicalSectionId)) && + (PHYSICAL_STOPCHECK_SET_YES == GetPhySectionStopCheckFlag(pRouteSecStru[ii].PhysicalSectionId))) + ||(ROUTE_PHYSICALSECTION_CHECK_NO == pRouteSecStru[ii].CheckProperty)) + { /*ֹͣЧΪмֹͣЧ,*/ + + } + else + { + devId = pRouteSecStru[ii].PhysicalSectionId; + devState = GetPhySecCurMergeState(devId); + if (SECTION_OCCUPY_YES == devState) + { /*ռ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + + reVal = CI_ERROR; + break; + } + else + { + } + } + } + } + + return reVal; +} + + +/* +* ·źűռ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckDTrainKeepSigPhySecOccupy(const UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + UINT8 reVal = CI_ERROR; + UINT8 sectionSum = 0u; /**/ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT16 outPhySecId = 0u; /*źŻⷽһID*/ + UINT16 inPhySecId = 0u; /*źŻڷһID*/ + UINT8 ii = 0u; + UINT8 tempIndex = 0u; + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 signalType = 0u; /*źŻƵ·*/ + UINT8 signalCrossCloseType = 0u; /*źŻѹص*/ + UINT8 stopCheckflag = 0u; + UINT8 RouteStopKeepCheckFlag = 0u;/*ֹͣɵ־*/ + UINT8 PhySecLjkFlag = 0u;/*мα־*/ + UINT8 PhySectionStopCheckFlag =0u;/*ֹͣ־*/ + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + startSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻID*/ + signalCrossCloseType = GetSignalCrossCloseAttr(startSignalId); /*ȡźŻѹص*/ + if ((sectionSum == 0u) || (pRouteSecStru == NULL)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + if(CI_SUCCESS == reVal) + { + inPhySecId = pRouteSecStru[0].PhysicalSectionId; /*źŻڷһID*/ + outPhySecId = GetSignalOutFirstPhySecId(startSignalId); /*źŻⷽһID*/ + devState = GetPhySecCurMergeState(inPhySecId); + if (SECTION_OCCUPY_NO == devState) + { /*ڷһο*/ + + devId = inPhySecId; + devState = GetPhySecPreMergeState(inPhySecId); + if (SECTION_OCCUPY_YES == devState) + { /*ڷ֮ǰռ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + + reVal = CI_ERROR; + } + if(CI_SUCCESS == reVal) + { + stopCheckflag = 0u; + for(ii = 1u; ii < sectionSum; ii++) + { + RouteStopKeepCheckFlag = GetRouteStopKeepCheckFlag(routeId); + PhySecLjkFlag = GetPhySecLjkFlag(pRouteSecStru[ii].PhysicalSectionId); + PhySectionStopCheckFlag = GetPhySectionStopCheckFlag(pRouteSecStru[ii].PhysicalSectionId); + if ((ROUTE_STOPCHECK_SET_YES == RouteStopKeepCheckFlag) && + (PHYSICAL_SECTION_LJK_YES == PhySecLjkFlag) && + (PHYSICAL_STOPCHECK_SET_YES == PhySectionStopCheckFlag)) + { /*ֹͣЧΪмֹͣЧ*/ + + stopCheckflag = 1u; + } + + if (ROUTE_PHYSICALSECTION_CHECK_NO == pRouteSecStru[ii].CheckProperty) + { /**/ + stopCheckflag = 1u; + } + if(1u != stopCheckflag) + { + devId = pRouteSecStru[ii].PhysicalSectionId; + devState = GetPhySecCurMergeState(devId); + if (SECTION_OCCUPY_YES == devState) + { /*ռ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + reVal = CI_ERROR; + break; + } + } + stopCheckflag = 0u; + } + } + } + else + { /*ڷһռ*/ + if (0u == outPhySecId) + {/*ⷽβ*/ + devState = SECTION_OCCUPY_YES;/*ĬΪռ*/ + } + else + { + devId = outPhySecId; + devState = GetPhySecCurMergeState(outPhySecId); + } + if (SECTION_OCCUPY_YES == devState) + { /*ⷽռ*/ + + signalType = GetSignalType(startSignalId); /*ȡźŻ߼*/ + if (((SIGNAL_TYPE_JINKUCHUKU == signalType) || (SIGNAL_TYPE_TWO_JINKU_RGY == signalType) || (SIGNAL_TYPE_THREE_JINKU_YINDAO == signalType)) + && (SIGNAL_CROSS_ClOSE_YES == signalCrossCloseType)) + { + /*źŻгʻ뼴ص*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + reVal = CI_ERROR; + } + else + { + /*¼һռƫ*/ + tempIndex = 0u; + stopCheckflag = 0u; + for(ii = 1u; ii < sectionSum; ii++) + { + RouteStopKeepCheckFlag = GetRouteStopKeepCheckFlag(routeId); + PhySecLjkFlag = GetPhySecLjkFlag(pRouteSecStru[ii].PhysicalSectionId); + PhySectionStopCheckFlag = GetPhySectionStopCheckFlag(pRouteSecStru[ii].PhysicalSectionId); + if ((ROUTE_STOPCHECK_SET_YES == RouteStopKeepCheckFlag) && + (PHYSICAL_SECTION_LJK_YES == PhySecLjkFlag) && + (PHYSICAL_STOPCHECK_SET_YES == PhySectionStopCheckFlag)) + { /*ֹͣЧΪмֹͣЧ*/ + + stopCheckflag = 1u; + } + + if (ROUTE_PHYSICALSECTION_CHECK_NO == pRouteSecStru[ii].CheckProperty) + { /**/ + + stopCheckflag = 1u; + } + if(1u != stopCheckflag) + { + devId = pRouteSecStru[ii].PhysicalSectionId; + devState = GetPhySecCurMergeState(devId); + if (SECTION_OCCUPY_YES == devState) + { /*ռ*/ + if ((ii - tempIndex) == 1u) + { + /*ռ*/ + tempIndex = ii; + } + else + { + /*ռ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + reVal = CI_ERROR; + break; + } + } + else + { + /*ο*/ + } + } + stopCheckflag = 0u; + } + if(CI_SUCCESS == reVal) + { + reVal = RouteOutfirstPhySecSwiPosCheck(routeId);/*·ⷽһελü飬λλòͬ򷵻ش*/ + if(CI_SUCCESS == reVal) + { + /*ʲôҲ*/ + } + else + { + if (0u == outPhySecId) + {/*ⷽβ*/ + devState = SECTION_OCCUPY_YES;/*ĬΪռ*/ + } + else + { + devState = GetPhySecCurMergeState(outPhySecId); + } + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,outPhySecId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + } + } + } + } + else + { /*ⷽο*/ + if ( SECTION_OCCUPY_YES == GetPhySecPreMergeState(outPhySecId)) + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,inPhySecId,ETYPE_PS_MERGY_OCU_STATE,SECTION_OCCUPY_YES,sendLevel); + reVal = CI_ERROR; + } + if(CI_SUCCESS == reVal) + { + stopCheckflag = 0u; + for(ii = 0u; ii < sectionSum; ii++) + { + RouteStopKeepCheckFlag = GetRouteStopKeepCheckFlag(routeId); + PhySecLjkFlag = GetPhySecLjkFlag(pRouteSecStru[ii].PhysicalSectionId); + PhySectionStopCheckFlag = GetPhySectionStopCheckFlag(pRouteSecStru[ii].PhysicalSectionId); + if ((ROUTE_STOPCHECK_SET_YES == RouteStopKeepCheckFlag) && + (PHYSICAL_SECTION_LJK_YES == PhySecLjkFlag) && + (PHYSICAL_STOPCHECK_SET_YES == PhySectionStopCheckFlag)) + { /*ֹͣЧΪмֹͣЧ*/ + stopCheckflag = 1u; + } + + if (ROUTE_PHYSICALSECTION_CHECK_NO == pRouteSecStru[ii].CheckProperty) + { /**/ + stopCheckflag = 1u; + } + if(1u != stopCheckflag) + { + devId = pRouteSecStru[ii].PhysicalSectionId; + devState = GetPhySecCurMergeState(devId); + if (SECTION_OCCUPY_YES == devState) + { /*ռ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + reVal = CI_ERROR; + break; + } + } + stopCheckflag=0u; + } + } + } + } + } + else + { + /*ʲôҲ*/ + } + return reVal; +} + + +/* +* ǽ·λúͶЧԼ +* ˵ +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 NonRouteSwitchPosMovValCheck(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel) +{ + /* · */ + UINT8 const checkSum = GetNonRouteSwitchSumById(nonRouteId); + NonRouteSwitchStruct* const dataIdBuf = GetNonRouteSwitchStructBufById(nonRouteId); + +/* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 switchPos = 0u; + + UINT8 switchMoveState = 0u; + UINT8 reVal = CI_SUCCESS; + UINT8 checkResult = 0u; + +/**/ + if ((0u == checkSum) || (NULL == dataIdBuf)) + { + /*޼*/ + reVal = CI_SUCCESS; + } + else + { + /*ʼ*/ + /* ·еλȷ ҲΪ λòȷɶ*/ + for (i = 0u; i 0u) + { + /*޵λü*/ + intruSwitchPosValid = CI_ERROR; + for (j = 0u; jSwitchId; + intruSwitchPos = GetSwitchCurPosition(intruSwitchId); + + if ((intruSwitchPos == intruSwitchConStru->SwitchPos) + || (SWITCH_POSITION_SIKAI == intruSwitchPos) + || (SWITCH_POSITION_MOVE == intruSwitchPos) + || (SWITCH_POSITION_JICHA == intruSwitchPos) + || (SWITCH_POSITION_INVALID == intruSwitchPos)) + { + intruSwitchPosValid = CI_ERROR; + } + else + { + /*δ*/ + intruSwitchPosValid = CI_SUCCESS; + break; + } + + } + + if (intruSwitchPosValid == CI_ERROR) + { + /*в*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + reVal = CI_ERROR; + } + else + { + /*δ*/ + + } + } + else + { + /*޲*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + reVal = CI_ERROR; + } + } + else if ((SECTION_OCCUPY_NO == devState) + && ((PHYSICAL_SECTION_FLOCK_NO == devFLockState) || (FUNC_SWITCH_ON == checkFlockFlag)) + && (PHYSICAL_SECTION_LOCK_NO == devLockState) + && (PHYSICAL_SECTION_JUMP_LOCK_NO == devJumpLockState)) + {/*δռ(δ򲻼)δδԾ*/ + /*μͨ*/ + } + else + {/*״̬쳣*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + reVal = CI_ERROR; + } + if (CI_ERROR == reVal) + { + break; + } + } + } + + /* δ⵽ */ + return reVal; +} + +/* +* Զ۷·ǷеִԶ·Ѱ +* ˵ +* UINT16 autoReturnIdԶ·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR ִ +* CI_SUCCESS ִ +*/ +UINT8 AutoReturnIsOpposedCheck(UINT16 autoReturnId, UINT8 functionID) +{ + UINT8 autoReturnOpposedRouteSum = 0u; /*Զͨ·ִĽ·Ŀ*/ + UINT16 *autoReturnOpposedRouteBuf = NULL; + + UINT8 autoReturnOpposedReturnSum = 0u; /*Զ۷·ִĽ·Ŀ*/ + UINT16 *autoReturnOpposedReturnBuf = NULL; + + UINT8 autoReturnOpposedAllReturnSum = 0u; /*ȫԶ۷·ִĽ·Ŀ*/ + UINT16 *autoReturnOpposedAllReturnBuf = NULL; + UINT8 opposedRouteIdSum = 0u; /*·ִ·Ŀ*/ + UINT16 *opposedRouteIdbuf = NULL; /*·ִ·ID*/ + + UINT8 includeRouteSum = 0u; /*Զ۷·Ľ·Ŀ*/ + UINT16 *includeRouteBuf = NULL; + UINT8 setAutoTriggerValidFlag = 0u; /*ԶǷЧ־*/ + UINT8 i = 0u; + UINT8 j = 0u; + UINT8 k = 0u; + UINT8 p = 0u; + UINT8 q = 0u; + UINT8 h = 0u; + UINT8 chOpposeSecCheckRtn = CI_ERROR; + UINT8 routeState = 0u; /*·״̬*/ + UINT8 returnValue = CI_ERROR; + + if ((autoReturnId < 1u) || (autoReturnId >= AUTO_RETURN_SUM_MAX)) + { + returnValue = CI_ERROR; + } + else + { + returnValue = CI_SUCCESS; + + } + + if(CI_SUCCESS == returnValue) + { + autoReturnOpposedReturnSum = GetAutoReturnOpposedReturnIdSum(autoReturnId); + autoReturnOpposedReturnBuf = GetAutoReturnOpposedReturnIdBuf(autoReturnId); + autoReturnOpposedRouteSum = GetAutoReturnOpposedRouteIdSum(autoReturnId); + autoReturnOpposedRouteBuf = GetAutoReturnOpposedRouteIdBuf(autoReturnId); + autoReturnOpposedAllReturnSum = GetAutoRtnOppAllReturnIdSum(autoReturnId); + autoReturnOpposedAllReturnBuf = GetAutoRtnOppAllReturnIdBuf(autoReturnId); + /*۷·ִԶͨ·ǷѰ*/ + for (i = 0u; i= AUTO_ROUTE_SUM_MAX) ) + { + flag = 1u; + } + else + { + flag = 0u; + autoRouteOpposedReturnSum = GetAutoRouteOpposedReturnIdSum(autoRouteId); + autoRouteOpposedReturnBuf = GetAutoRouteOpposedReturnIdBuf(autoRouteId); + autoRouteOpposedRouteSum = GetAutoRouteOpposedRouteIdSum(autoRouteId); + autoRouteOpposedRouteBuf = GetAutoRouteOpposedRouteIdBuf(autoRouteId); + autoRouteOpposedAllReturnSum = GetAutoRouteOpposedAllRtnIdSum(autoRouteId); + autoRouteOpposedAllReturnBuf = GetAutoRouteOpposedAllRtnIdBuf(autoRouteId); + + /*Զ·ִԶ۷·ǷѰ*/ + for (i = 0u; i= ALL_AUTO_RETURN_SUM_MAX)) + { + returnValue = CI_ERROR; + } + if(CI_SUCCESS == returnValue) + { + allAutoReturnOpposedReturnSum = GetAllAutoRtnOppReturnIdSum(allAutoReturnId); + allAutoReturnOpposedReturnBuf = GetAllAutoRtnOppReturnIdBuf(allAutoReturnId); + allAutoRtnOpposedRouteSum = GetAllAutoRtnOppRouteIdSum(allAutoReturnId); + allAutoRtnOpposedRouteBuf = GetAllAutoRtnOppRouteIdBuf(allAutoReturnId); + allAutoReturnOpposedAllReturnSum = GetAllAutoRtnOppAllReturnIdSum(allAutoReturnId); + allAutoReturnOpposedAllReturnBuf = GetAllAutoRtnOppAllRtnIdBuf(allAutoReturnId); + /*ȫԶ۷·ִԶͨ·ǷѰ*/ + for (i = 0u; i< allAutoRtnOpposedRouteSum; i++) + { + if (AUTO_ROUTE_SET_YES == GetAutoRouteSetFlag(allAutoRtnOpposedRouteBuf[i])) + { + returnValue = CI_ERROR; + /*ATS*/ + SetErrorData(chFunctionId, CI_DEVICE_TYPE_AUTOROUTE, allAutoRtnOpposedRouteBuf[i], ETYPE_ALL_AUTO_RETURN_FLAG, ALL_AUTO_RETURN_DICHU_AUTOR, ESEND_LEVEL_ATS); + + break; + } + } + if(CI_SUCCESS == returnValue) + { + /*ȫԶ۷·ִԶ۷·ǷѰ*/ + for (h = 0u; hDevType; +#if 0 + if (CI_DEVICE_TYPE_AXISSEC == tmpOtherCiDevInfo->DevType) + { + devId = GetAxisSecRelativePhySecId(devId); + } +#endif + /*ߵתΪ*/ + if(CI_DEVICE_TYPE_CONNECT_SWITCH == tmpOtherCiDevInfo->DevType) + { + devType = CI_DEVICE_TYPE_SWITCH; + } + devStateType = GetOtherCiCheckDevStateType(devType); + SetErrorData(functionId,devType,devId,devStateType,devState,sendLevel); + ret = CI_ERROR; + + } + else if(CI_ROUTE_RECOVER_ERR == otherCheckState) + { + /* յVOBC*/ + ret = CI_ERROR; + + } + else + { + /*Ϊɹʱ*/ + } + if (CI_ERROR == ret) + { + break; + } + } + } + + return ret; +} + +/* +* 豸״̬ +* ˵ UINT16 routeId ·ID +* RouteOhterCheckStruct *pOtherDevInfo +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OtherCiDevStatusCheck(UINT16 const routeId,const RouteOtherCheckStruct *pOtherDevInfo, + UINT16 *pDevId,UINT8 *pDevState) +{ + UINT16 devId = pOtherDevInfo->DevId; + UINT16 chkDevStatus = pOtherDevInfo->DevStatus; + UINT16 devType = pOtherDevInfo->DevType; + UINT8 devState = 0u; + UINT8 ret = CI_ERROR; + UINT8 routeLeadProperty = 0u; /*·*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 retVal = CI_ERROR; + UINT8 AxisSecLinXianFlag = 0U; + UINT16 leaveLogicSecId = 0U; /*·һȥ߼*/ + UINT8 routeOverlapSum = 0U; /*·*/ + UINT8 logSwichSum = 0U; /*߼ΰĵ*/ + UINT8 logBelogAxisNum = 0u; + UINT16* logBelogAxisBuff = NULL; + + + devState = GetOtherCiDevStatus(devType,devId,chkDevStatus); + + if (CI_DEVICE_TYPE_SIGNAL != devType) + { /* źŻ״̬ */ + /* ״̬㣬򷵻ʧ */ + if (chkDevStatus != devState) + { + routeLeadProperty = GetRouteLeadProperty(routeId);/*ȡ·*/ + routeState = GetRouteState(routeId);/*ȡ·״̬*/ + + if (((ROUTE_LEAD_PROPERTY_YES == routeLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == routeLeadProperty)) + && ((ROUTE_STATE_LEAD_LOCK == routeState) || (ROUTE_STATE_LEAD_LOCKERR == routeState) + || (ROUTE_STATE_LEAD_OPEN == routeState))) + { /*·ֻ·żεռ״̬,ߵ*/ + if ((CI_DEVICE_TYPE_AXISSEC == devType) || (CI_DEVICE_TYPE_CONNECT_SWITCH == devType) + || (CI_DEVICE_TYPE_SWITCH == devType) || (CI_DEVICE_TYPE_FLOODGATE == devType)) + { + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + } + } + else + { + if (CI_DEVICE_TYPE_AXISSEC == devType) /*վֱ죬Ҫᵥж*/ + { + AxisSecLinXianFlag = GetAxisSecLinXianFlag(devId); + + if (AXIS_SEC_LINXIAN_NO == AxisSecLinXianFlag) + { + /*ȡ·ⷽһȥ߼*/ + leaveLogicSecId = GetRouteLeaveLogicSecId(routeId); + /*·ⷽȥ*/ + if (0U != leaveLogicSecId) + { + /*߼ΰĵ*/ + logSwichSum = GetLogicSecSwitchSum(leaveLogicSecId); + routeOverlapSum = GetRouteOverlapSum(routeId); + /*߼ιļ*/ + logBelogAxisNum = GetLgcSecRelativeAxleSecSum(leaveLogicSecId); + logBelogAxisBuff = GetLgcSecRltvAxleSecIdBuf(leaveLogicSecId); + + /*ǰ·ޱΣȥ߼β*/ + if ((0U == logSwichSum) && (0U == routeOverlapSum) && (1U == logBelogAxisNum)) + { + /*õļΪ·ȥΣɼ·ȥABLг*/ + if (logBelogAxisBuff[0] == devId) + { + ret = TrainLeaveLogSecABLTrainCheck(leaveLogicSecId); + } + else + { + ret = CI_ERROR; + } + + } + else + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; /*·ȥΣټǷVBLӽֱӷʧ*/ + } + } + else + { + ret = CI_ERROR; /*DZ·ټǷVBLӽֱӷʧ*/ + } + } + else + { + if (OTHER_CI_PSD_STATUS_OCCUPY_OPEN == devState) + { + /* յVOBC ֻ¼*/ + ret = CI_ROUTE_RECOVER_ERR; + } + else + { + /* 쳣 */ + ret = CI_ERROR; + } + } + } + } + else + { + ret = CI_SUCCESS; + } + } + else + { + /* źŻ״̬ */ + if ((OTHER_CI_SIGNAL_STATUS_SAME == chkDevStatus)||(OTHER_CI_SIGNAL_STATUS_OPEN == chkDevStatus)) + { + retVal = CheckRelationSignalOnSameOpen(routeId, devId, (UINT8)chkDevStatus); + if (CI_SUCCESS == retVal) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + else + { + /*쳣ֵźŻֻÿ0x550xbb*/ + ret = CI_ERROR; + } + } + if (CI_ERROR == ret) + { + *pDevId = devId; + *pDevState = devState; + } + + return ret; + +} + +/* +* źŻ: ·ŵź״ָ̬ܸźŻ״̬ +* źŻʾΪźţ·źŲܸ +* źŻΪźŻ·źŻֻΪźš +* гźŻ-г(0xbb),гźŻ-гź()(0x55) +* ˵ UINT16 const routeId ·ID +* UINT16 const relationSignalId źŻID +* UINT8 const devStatus 豸״̬ +* ֵ 0 ʧ +* >0 豸״̬ +*/ +static UINT8 CheckRelationSignalOnSameOpen(UINT16 const routeId,UINT16 const relationSignalId,UINT8 const devStatus) +{ + UINT8 routeState = 0u,routeLeadProperty = 0u; + UINT8 ret = CI_SUCCESS; + UINT8 routeType = 0u; /*·*/ + UINT8 relationSignalOpenColor = GetSignalCurColor(relationSignalId); + + routeState = GetRouteState(routeId); + routeLeadProperty = GetRouteLeadProperty(routeId);/*ȡ·*/ + routeType = GetRouteType(routeId); /*ȡ·*/ + + if ((routeState != 0u) && (relationSignalOpenColor != 0u)) + { + /* źſţ鱾·ҪŵźǷȵǰĿŵļҪ */ + if (SIGNAL_OPEN == GetSignalOpenCloseState(relationSignalOpenColor)) + { + switch (relationSignalOpenColor) + { + case SIGNAL_SHOWCOLOUR_REDYELLOW: + /* Ƶ,źſűź */ + + if (((ROUTE_LEAD_PROPERTY_YES == routeLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == routeLeadProperty)) + && ((ROUTE_STATE_LEAD_LOCK == routeState) + || (ROUTE_STATE_LEAD_LOCKERR == routeState) + || (ROUTE_STATE_LEAD_OPEN == routeState))) + {/* ·Ϊҽ·״̬Ϊ<><쳣><> ,·, */ + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + break; + case SIGNAL_SHOWCOLOUR_WHITE: + if (ROUTE_TYPE_DIAOCHE == routeType) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + break; + case SIGNAL_SHOWCOLOUR_YELLOW: + if (OTHER_CI_SIGNAL_STATUS_OPEN == devStatus) + { + /* Էгźţɰ·г·ܰ·(0x55)*/ + if (ROUTE_TYPE_DIAOCHE == routeType) + { + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + } + } + else + { + if (ROUTE_TYPE_LIECHE == routeType) + { + if (((ROUTE_LEAD_PROPERTY_YES == routeLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == routeLeadProperty)) + && ((ROUTE_STATE_LEAD_LOCK == routeState) + || (ROUTE_STATE_LEAD_LOCKERR == routeState) + || (ROUTE_STATE_LEAD_OPEN == routeState))) + {/* ·Ϊҽ·״̬Ϊ<><쳣><> ,·, */ + ret = CI_ERROR; + } + else + {/*Էгźţֻܰгźţҷ(0xbb)*/ + ret = CI_SUCCESS; + } + } + else + { + ret = CI_ERROR; /*Էгźţ*/ + } + } + break; + default: + ret = CI_ERROR; /*ɫãʧ*/ + break; + } + } + else + { + ret = CI_ERROR; + } + } + else + { + /* ·״̬ȡʧ źŻ״̬ȡʧܣֱӷؼʧ */ + ret = CI_ERROR; + } + + return ret; +} + +/* +* ſ +* ˵ const UINT16 garageDoorId, ID +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +*/ +UINT8 DriveGarageDoorOpenCheck(const UINT16 garageDoorId) +{ + UINT8 retVal = CI_ERROR; + UINT8 jkjRelayValidFlag = GetCiJkjFlag(); + /*JKJӦ̵̼Ч־*/ + UINT8 modeFlag = GetGaragedoorModeState(garageDoorId); + UINT8 faultFlag = GetGaragedoorFaultState(garageDoorId); + UINT8 doorState = GetGaragedoorState(garageDoorId); + UINT8 pangluState = GetGaragedoorPangLuState(garageDoorId); + UINT16 jkjRelayId = GetJkjRelayId(); + /**/ + UINT8 const functionId = EFUNC_CLD_CLOSE_GARAGEDOOR; + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + + + if ((GARAGE_DOOR_SUM_MAX > garageDoorId) && (0U < garageDoorId)) + { + retVal = CI_SUCCESS; + /* ¼ */ + if ((jkjRelayId > 0u) && (JKJ_REYLAY_VALID == jkjRelayValidFlag)) + {/*Ӧ̵̼Ч״̬*/ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, jkjRelayId, ETYPE_JKJ_WORK, RELAY_STATE_DOWN, sendLevel); + retVal = CI_ERROR; + } + else if (GARAGE_DOOR_STATE_MODE_LOCAL == modeFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_GARAGEDOOR, garageDoorId, ETYPE_GARAGEDOOR_STATE_MODE_LOCAL, modeFlag, sendLevel); + retVal = CI_ERROR; + } + else if (GARAGE_DOOR_FAULT_TRUE == faultFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_GARAGEDOOR, garageDoorId, ETYPE_GARAGEDOOR_FAULT, faultFlag, sendLevel); + retVal = CI_ERROR; + } + else if (GARAGE_DOOR_PANGLU_TRUE == pangluState) + { + retVal = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_GARAGEDOOR, garageDoorId, ETYPE_GARAGEDOOR_PANGLU, pangluState, ESEND_LEVEL_ZERO); + } + else if (GARAGE_DOOR_STATE_OPEN == doorState) + { + /*Ϊ״̬յʱƶŹϺͿģʽ֮ + Ƿֹͬʱֲϴ*/ + retVal = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_GARAGEDOOR, garageDoorId, ETYPE_GARAGEDOOR_DRIVE_INVALID, doorState, ESEND_LEVEL_ZERO); + } + else + { + retVal = CI_SUCCESS; + } + } + else + { + /*ʧ*/ + } + + return retVal; +} + + +/* Ź +* ˵ const UINT16 garageDoorId, ID +* ֵ CI_ERRORʧ +* RETURN_GRGDOOR_CLSCHK_WAITALLOW ȴ +* CI_SUCCESSͨ +*/ +UINT8 DriveGarageDoorCloseCheck(const UINT16 garageDoorId) +{ + UINT8 retVal = CI_ERROR; + UINT8 jkjRelayValidFlag = GetCiJkjFlag(); + /*JKJӦ̵̼Ч־*/ + UINT8 modeFlag = GetGaragedoorModeState(garageDoorId); + UINT8 faultFlag = GetGaragedoorFaultState(garageDoorId); + UINT8 pangluState = GetGaragedoorPangLuState(garageDoorId); + UINT16 wSpksSum = GetGarageSpksSum(garageDoorId); /*SPKS*/ + UINT16 spksId = 0u; /*SPKS ID*/ + UINT16 ii = 0u; + UINT8 spksState = 0u; /*spks״̬*/ + UINT16 phySum = GetGardoorphySecSum(garageDoorId); + UINT16 phyId = 0u; + UINT8 phyState = SECTION_OCCUPY_YES; + UINT8 phyFLockState = PHYSICAL_SECTION_FLOCK_YES; + UINT8 phyLockState = PHYSICAL_SECTION_LOCK_NORMAL;/*״̬*/ + UINT16 jkjRelayId = GetJkjRelayId(); + UINT16 jj = 0u; + UINT32 responseZCStartCyc = 0U;/*ȴZCʼ*/ + UINT32 responseIVOCStartCyc = 0U;/*ȴIVOCʼ*/ + + /**/ + UINT8 const functionId = EFUNC_CLD_CLOSE_GARAGEDOOR; + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + UINT8 rcWorkMode = 0U; /*ģʽ*/ + + + UINT8 doorState = GetGaragedoorState(garageDoorId); + + rcWorkMode = GetLocalRcWorkMode(); /*RCģʽȡ*/ + + if ((GARAGE_DOOR_SUM_MAX > garageDoorId) && (0U < garageDoorId)) + { + retVal = CI_SUCCESS; + /* ¼ */ + if ((jkjRelayId > 0u) && (JKJ_REYLAY_VALID == jkjRelayValidFlag)) + {/*Ӧ̵̼Ч״̬*/ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, jkjRelayId, ETYPE_JKJ_WORK, RELAY_STATE_DOWN, sendLevel); + retVal = CI_ERROR; + } + else if (GARAGE_DOOR_STATE_MODE_LOCAL == modeFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_GARAGEDOOR, garageDoorId, ETYPE_GARAGEDOOR_STATE_MODE_LOCAL, modeFlag, sendLevel); + retVal = CI_ERROR; + } + else if (GARAGE_DOOR_FAULT_TRUE == faultFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_GARAGEDOOR, garageDoorId, ETYPE_GARAGEDOOR_FAULT, faultFlag, sendLevel); + retVal = CI_ERROR; + } + else if (GARAGE_DOOR_PANGLU_TRUE == pangluState) + { + retVal = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_GARAGEDOOR, garageDoorId, ETYPE_GARAGEDOOR_PANGLU, pangluState, ESEND_LEVEL_ZERO); + } + else if (GARAGE_DOOR_STATE_CLOSE == doorState) + { + /*Ϊ״̬յʱƶŹϺͿģʽ֮ + Ƿֹͬʱֲϴ*/ + retVal = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_GARAGEDOOR, garageDoorId, ETYPE_GARAGEDOOR_DRIVE_INVALID, doorState, ESEND_LEVEL_ZERO); + } + else + { + /*SPKSЧصȫΪУͨ*/ + for (ii = 0u; ii < wSpksSum; ii++) + { + spksId = GetGarageSpksIdBuff(garageDoorId, ii); + spksState = GetSpksState(spksId); + if ((SPKS_STATUS_NO == spksState) || (GetSpksCutState(spksId) == SPKS_CUT_YES)) /*δ ·*/ + { + retVal = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SPKS, spksId, ETYPE_SPKS_STATE_UP, spksState, sendLevel); + retVal = CI_ERROR; + break; /*һSPKSЧ򷵻*/ + } + } + if (CI_SUCCESS == retVal) + { + if (phySum == 0u) + { + retVal = CI_ERROR; + } + else if (phySum > 0u) + { + for (jj = 0u; jj < phySum; jj++) + { + phyId = GetGardoorphySecBuf(garageDoorId, jj); + phyState = GetPhySecCurAndMergeState(phyId); + phyFLockState = GetPhySecFLockState(phyId); + phyLockState=GetPhySecLockState(phyId); + if ((SECTION_OCCUPY_NO == phyState) && (PHYSICAL_SECTION_FLOCK_NO == phyFLockState) && (PHYSICAL_SECTION_LOCK_NO == phyLockState)) + { + retVal = CI_SUCCESS; + } + else if (PHYSICAL_SECTION_FLOCK_YES == phyFLockState) + {/* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, phyId, ETYPE_PS_FLOCK_STATE, phyFLockState, sendLevel); + retVal = CI_ERROR; + break; /*һη򷵻*/ + } + else + { + retVal = RETURN_GRGDOOR_CLSCHK_WAITALLOW; /*һռûzc*/ + break; + + } + } + } + else + { + /*<0ڣ账*/ + } + } + responseZCStartCyc = GetWaiteZCResponseStartCycNum(garageDoorId); + responseIVOCStartCyc = GetWaiteIVOCResponseStartCycNum(garageDoorId); + + if ((RETURN_GRGDOOR_CLSCHK_WAITALLOW == retVal) && (0u == responseZCStartCyc) && (RC_WORK_MODE_CI == rcWorkMode)) + { + SetWaiteZCResponseStartCycNum(garageDoorId, Get2oo2CurCycleNum()); /*õȴZCʼں*/ + } + if ((RETURN_GRGDOOR_CLSCHK_WAITALLOW == retVal) && (0u == responseIVOCStartCyc) && (RC_WORK_MODE_TIOC == rcWorkMode)) + { + SetWaiteIVOCResponseStartCycNum(garageDoorId, Get2oo2CurCycleNum()); /*õȴIVOCʼں*/ + } + + } + } + return retVal; +} + +/* RCģʽ´ռʱŹ +* ˵ const UINT16 garageDoorId, ID +* const UINT8 sendLevel ǷATSͶӦ +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +* BY LC +*/ +UINT8 GarageDoorCloseCheckinRCMode(const UINT16 garageDoorId, const UINT8 sendLevel) +{ + UINT8 retVal = CI_ERROR; + + /**/ + UINT8 const functionId = EFUNC_CLD_CHECK_GARAGEDOOR_CLOSE; + + if ((GARAGE_DOOR_SUM_MAX > garageDoorId) && (0U < garageDoorId)) + { + /*ڼ*/ + retVal = CheckAdjacentACOfGarageDoor(garageDoorId, functionId, sendLevel); + + /*A*/ + if (CI_SUCCESS == retVal) + { + retVal = CheckAkuPhysecOfGarageDoor(garageDoorId, functionId, sendLevel); + } + + /*Aӽг*/ + if (CI_SUCCESS == retVal) + { + retVal = CheckNearestTrainOfGarageDoor(garageDoorId, functionId, sendLevel); + } + } + else + { + /*ʧ*/ + } + return retVal; +} + + +/* Źڼ +* ˵ const UINT16 garageDoorId, ID +* const UINT8 functionId ú +* const UINT8 sendLevel 뷢ͼ +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +* BY LC +*/ +UINT8 CheckAdjacentACOfGarageDoor(const UINT16 garageDoorId, const UINT8 functionId, const UINT8 sendLevel) +{ + UINT8 retVal = CI_ERROR; + UINT16 adjacentACID[GARAGE_DOOR_ADJACENT_AXIS] = { 0U }; /*ڼID*/ + UINT8 adjacentACNum = 0U; /*ڼ*/ + UINT16 occuAdjacentACID[GARAGE_DOOR_ADJACENT_AXIS] = { 0U }; /*ռõڼID*/ + UINT8 occuAdjacentACNum = 0U; /*ռõڼ*/ + UINT8 tempAcStatus = 0U; + UINT8 i = 0U; + UINT8 j = 0U; + UINT8 attribute = 0U; + + UINT16 devId = 0U; + UINT8 devState = 0U; + + /*ѯŵڼᡪŶӦAΰἰⷽһ*/ + adjacentACNum = GetGarageDoorAdjacentAC(garageDoorId, adjacentACID); + if ((0U != adjacentACNum) && (GARAGE_DOOR_ADJACENT_AXIS > adjacentACNum)) + {/*ڼѯɹ*/ + + retVal = CI_SUCCESS; + /*ڼᣬɸѡռõڼ*/ + for (i = 0U; i < adjacentACNum; i++) + { + tempAcStatus = elm_PrepareACStatus(adjacentACID[i]); + if (ELM_AC_OCC == tempAcStatus) + { + occuAdjacentACID[occuAdjacentACNum] = adjacentACID[i]; + occuAdjacentACNum += 1U; + } + else + { + /*˼δռã*/ + } + } + attribute = GetGarageDoorAttribute(garageDoorId); + + + if (GARAGE_DOOR_ATTRIBUTE_LJK == attribute) + { + if (0U == occuAdjacentACNum) + { + /*ڼ᲻ռãֱӷؼͨ*/ + } + else + { + for ( j = 0U; j < occuAdjacentACNum; j++) + { + /*鱻ռѹǷΪA߹ A߹ΪVBTCռ*/ + retVal &= CheckGarageDoorSleepAC(garageDoorId, occuAdjacentACID[j]); + retVal &= CheckGarageDoorAKuIsCTOccu(garageDoorId); + + if (CI_ERROR == retVal) + { + devId = elm_PrepareACRelPhyId(occuAdjacentACID[j]); + devState = GetPhySecCurMergeState(devId); + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + break; + } + } + + } + } + else if (GARAGE_DOOR_ATTRIBUTE_XCK == attribute) + { + if (0U == occuAdjacentACNum) + { + /*ڼ᲻ռãؼͨ*/ + } + else + { + /*ϴڼռãʧ*/ + retVal = CI_ERROR; + + devId = elm_PrepareACRelPhyId(occuAdjacentACID[0]); + devState = GetPhySecCurMergeState(devId); + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + } + else + { + /*Ч*/ + retVal = CI_ERROR; + } + } + else + { + /*ڼʧ*/ + } + return retVal; +} + +/* ӽг +* ˵ const UINT16 garageDoorId, ID +* const UINT8 functionId ú +* const UINT8 sendLevel 뷢ͼ +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +* BY LC +*/ +UINT8 CheckNearestTrainOfGarageDoor(const UINT16 garageDoorId, const UINT8 functionId, const UINT8 sendLevel) +{ + UINT8 aKuPhyOccuStatus = 0U; + UINT8 retVal = CI_ERROR; + UINT16 trainId = 0U; /*ӽгID*/ + UINT8 chSleepState = TRAIN_SLEEP_NO; /*г״̬*/ + str_Zone strTrainZone = { 0u }; + struct_PathPoint gdPoint = { 0U }; + UINT8 containFlag = CI_ERROR; + UINT16 devId = 0U; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + + aKuPhyOccuStatus = GetGarageDoorAKuIsOccu(garageDoorId); + + if (CI_SUCCESS == aKuPhyOccuStatus) + {/*ռãͨ*/ + + SetGaragedoorNearestTrainId(garageDoorId, 0U); + retVal = CI_SUCCESS; + + } + else + { + /*ѯA복ͨų*/ + trainId = FindNearestTrainInAKuPhy(garageDoorId); + retVal = CI_SUCCESS; + + if ((UINT16_MAX != trainId) && (0U != trainId) && (NAME_FAILUREAREA != trainId)) + { + SetGaragedoorNearestTrainId(garageDoorId, trainId); + + /*гΪ߳*/ + chSleepState = GetTrainSleepState(trainId); + if (TRAIN_SLEEP_YES == chSleepState) + { + /*߳ͨͿ*/ + SetGaragedoorNearestTrainId(garageDoorId, 0U); + } + else + {/*гδ*/ + + /*гӽһ޿*/ + retVal = CheckNearestTrainScreen(garageDoorId, trainId, functionId, sendLevel); + + + if (CI_SUCCESS == retVal) + { + /*гδѹ*/ + retVal = CheckNearestTrainKuaya(garageDoorId, trainId, functionId, sendLevel); + } + + /*ӽг޿Ұδѹţͨ*/ + + } + + } + else + { + /*سʧ*/ + retVal = CI_ERROR; + devId = GetGarageDoorAKuPhySec(garageDoorId); + devState = GetPhySecCurMergeState(devId); + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + } + return retVal; + +} + +/* +* ˵ const UINT16 garageDoorId, ID +* const UINT8 functionId ú +* const UINT8 sendLevel 뷢ͼ +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +* BY LC +*/ +UINT8 CheckAkuPhysecOfGarageDoor(const UINT16 garageDoorId, const UINT8 functionId, const UINT8 sendLevel) +{ + UINT8 retVal = CI_ERROR; + + UINT16 devId = 0U; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + + UINT16 phySecAId = 0U; /*ŶӦAID*/ + UINT8 attribute = 0U;/**/ + UINT8 occuState = 0U;/*Aռ״̬*/ + UINT8 lockState = 0U;/*A״̬*/ + /*ȡŶӦA*/ + phySecAId = GetGarageDoorAKuPhySec(garageDoorId); + + /*ȡ*/ + attribute = GetGarageDoorAttribute(garageDoorId); + + /*Aռ״̬*/ + occuState = GetPhySecCurMergeState(phySecAId); + /*A״̬*/ + lockState = GetPhySecLockState(phySecAId); + /*м*/ + if (GARAGE_DOOR_ATTRIBUTE_LJK == attribute) + { + if (PHYSICAL_SECTION_LOCK_NO == lockState) + { + /*Aδ ռ*/ + if (SECTION_OCCUPY_NO == occuState) + { + /*ͨ*/ + retVal = CI_SUCCESS; + } + else + { + /*鲻ͨAռ*/ + devId = phySecAId; + devState = occuState; + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + } + else if (PHYSICAL_SECTION_LOCK_NORMAL == lockState) + { + /*A ռ*/ + if (SECTION_OCCUPY_YES == occuState) + { + /*ͨ*/ + retVal = CI_SUCCESS; + } + else + { + /*鲻ͨA*/ + devId = phySecAId; + devState = lockState; + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + } + } + else + { + /*鲻ͨA״̬*/ + devId = phySecAId; + devState = lockState; + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + } + + } + else if (GARAGE_DOOR_ATTRIBUTE_XCK == attribute) + { + retVal = CheckGDAdjacentACLockState(garageDoorId, &devId, &devState); + /*ڼδ*/ + if (CI_SUCCESS == retVal) + { + /*ͨ*/ + } + else + { + /*鲻ͨ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + } + } + else + { + /*Դ󣬷ʧ*/ + } + + return retVal; +} + + + + +/* L14_ʽ·źűź */ +/* +* ʽ·źűź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepBlocRouteOtherSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /* ·豸 */ + /*·迪źŻ*/ + UINT8 const needOpenSigSum = GetRouteOpenNeedOpenSigSum(routeId); + UINT16* const pNeedOpenBuf = GetRouteOpenNeedOpenSigIdBuf(routeId); + /*·زͬʱźŻ*/ + UINT8 const oneOpenSigSum = GetRouteOnlyOneOpenSigSum(routeId); + UINT16* const pOneOpenBuf = GetRouteOnlyOneOpenSigIdBuf(routeId); + /*·رźŻ*/ + UINT8 const needCloseSigSum = GetRouteOpenNeedCloseSigSum(routeId); + UINT16* const pNeedCloseBuf = GetRouteOpenNeedCloseSigIdBuf(routeId); + + /*·źŻ۷·*/ + UINT8 const zheFanRouteSum = GetRtnEndSigAsStartSigRouteSum(routeId); + UINT16 * const zheFanRouteIdBuf = GetReturnEndSigAsStartSigRoute(routeId); + + + /* ߼ */ + + /*·迪źŻѿ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedOpenBuf,needOpenSigSum,SIGNAL_OPEN,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_NEED_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·زͬʱźŻδ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pOneOpenBuf,oneOpenSigSum,SIGNAL_CLOSE,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ONE_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·رźŻѹر */ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedCloseBuf,needCloseSigSum,SIGNAL_CLOSE,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_NEED_CLOSE_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ʼźŻΪնźŻ۷·ǷѾɹ*/ + devId = 0u; + devState = 0u; + checkResult = RtnEndSigAsStartSigRouteCheck(zheFanRouteIdBuf,zheFanRouteSum,&devId,&devState); + if(CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_SIG_RETURN_OPENED_STATE,devState,sendLevel); + reResult = CI_ERROR; + } + } + + /* ؽ */ + return reResult; +} +#if 0 +/* +* ʽ·źűź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepCbtcRouteOtherSignalCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /* ·豸 */ + /*·迪źŻ*/ + UINT8 const needOpenSigSum = GetRouteCbtcNeedOpenSigSum(routeId); + UINT16* const pNeedOpenBuf = GetRouteCbtcNeedOpenSigIdBuf(routeId); + /*·زͬʱźŻ*/ + UINT8 const oneOpenSigSum = GetRouteOnlyOneOpenSigSum(routeId); + UINT16* const pOneOpenBuf = GetRouteOnlyOneOpenSigIdBuf(routeId); + /*·رźŻ*/ + UINT8 const needCloseSigSum = GetRouteOpenNeedCloseSigSum(routeId); + UINT16* const pNeedCloseBuf = GetRouteOpenNeedCloseSigIdBuf(routeId); + + /*·źŻ۷·*/ + UINT8 const zheFanRouteSum = GetRtnEndSigAsStartSigRouteSum(routeId); + UINT16 * const zheFanRouteIdBuf = GetReturnEndSigAsStartSigRoute(routeId); + + + /* ߼ */ + + /*·迪źŻѿ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedOpenBuf, needOpenSigSum, SIGNAL_OPEN, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_NEED_OPEN_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·زͬʱźŻδ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pOneOpenBuf, oneOpenSigSum, SIGNAL_CLOSE, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_ONE_OPEN_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·رźŻѹر */ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedCloseBuf, needCloseSigSum, SIGNAL_CLOSE, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_NEED_CLOSE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ʼźŻΪնźŻ۷·ǷѾɹ*/ + devId = 0u; + devState = 0u; + checkResult = ReturnEndSigAsRouteStartSigRouteStateCheck(zheFanRouteIdBuf, zheFanRouteSum, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_SIG_RETURN_OPENED_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + } + + /* ؽ */ + return reResult; +} +#endif +/* L12_ʽ·źſź */ +/* +* ʽ·źſź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* RETURN_OPEN_ERR_SIGOPEN +*/ +UINT8 OpenBlocRouteOtherSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 cRouteLeadProperty = 0U; /**/ + UINT32 dwStartCycNum = 0U; /*źſʼ*/ + UINT32 dwOpenMaxCount = 0U; /*źſų*/ + +/* ·豸 */ + /* źʱ״̬*/ + UINT8 routeTimeState = CI_TIME_OUT; + /*·迪źŻ*/ + UINT8 const needOpenSigSum = GetRouteOpenNeedOpenSigSum(routeId); + UINT16* const pNeedOpenBuf = GetRouteOpenNeedOpenSigIdBuf(routeId); + /*·زͬʱźŻ*/ + UINT8 const oneOpenSigSum = GetRouteOnlyOneOpenSigSum(routeId); + UINT16* const pOneOpenBuf = GetRouteOnlyOneOpenSigIdBuf(routeId); + /*·رźŻ*/ + UINT8 const needCloseSigSum = GetRouteOpenNeedCloseSigSum(routeId); + UINT16* const pNeedCloseBuf = GetRouteOpenNeedCloseSigIdBuf(routeId); + + /*·źŻ۷·*/ + UINT8 const zheFanRouteSum = GetRtnEndSigAsStartSigRouteSum(routeId); + UINT16* const zheFanRouteIdBuf = GetReturnEndSigAsStartSigRoute(routeId); + + UINT8 signalVirtualAttr = SIGNAL_VIRTUAL_NO;/*źŻ*/ + UINT8 repeatOpenFlag = ROUTE_REPEATOPEN_SET_NO;/*ؿ־*/ + + /* ߼ */ + cRouteLeadProperty = GetRouteLeadProperty(routeId); + routeState = GetRouteState(routeId);/*ȡ·״̬*/ + if (((ROUTE_LEAD_PROPERTY_YES == cRouteLeadProperty) || (ROUTE_LEAD_PROPERTY_CBTC_YES == cRouteLeadProperty)) && (ROUTE_STATE_LEAD_LOCK == routeState)) + { + dwOpenMaxCount = GetSystemParaSignalOpenCyc(); /*·źſųʱ*/ + } + else + { + dwOpenMaxCount = GetSystemParaRouteOpenSigCyc();/*·źſųʱ*/ + } + + dwStartCycNum = GetRouteOpenSigStatrtCycNum(routeId); + routeTimeState = SystemOverTimeCheck(dwStartCycNum, dwOpenMaxCount); + + /*·źųʱ*/ + if (CI_TIME_OUT != routeTimeState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + devId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_OPEN_OVERTIME,routeTimeState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·迪źŻѿ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedOpenBuf,needOpenSigSum,SIGNAL_OPEN,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + + repeatOpenFlag = GetRouteRepeatOpenFlag(routeId); + + if ((ROUTE_STATE_FIRST_LOCKERR == routeState) && (ROUTE_REPEATOPEN_SET_YES == repeatOpenFlag)) + { + /*쳣ؿźʱͱ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_NEED_OPEN_STATE, devState, sendLevel); + } + else if (ROUTE_STATE_FIRST_LOCKERR != routeState) + {/*cgh-ϲCID-2539-3*/ + /*·Ԥաաӽ쳣ӽʱm by yt 202283*/ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_NEED_OPEN_STATE, devState, sendLevel); + } + else + { + ; /*б*/ + } + + if (devId>0u) + { + signalVirtualAttr = GetSignalVirtualAttr(devId); + if (SIGNAL_VIRTUAL_YES == signalVirtualAttr) + { + reResult = RETURN_OPEN_ERR_NEEDOPEN; + } + else + { + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + } + } + + if (CI_SUCCESS == reResult) + { + /*·زͬʱźŻδ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pOneOpenBuf,oneOpenSigSum,SIGNAL_CLOSE,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ONE_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·رźŻѹر + ʧܷ RETURN_OPEN_ERR_SIGOPEN*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedCloseBuf,needCloseSigSum,SIGNAL_CLOSE,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + + reResult = RETURN_OPEN_ERR_SIGOPEN; + } + } + + if (CI_SUCCESS == reResult) + { + /*ʼźŻΪնźŻ۷·ǷѾɹ*/ + devId = 0u; + devState = 0u; + checkResult = RtnEndSigAsStartSigRouteCheck(zheFanRouteIdBuf,zheFanRouteSum,&devId,&devState); + if(CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_SIG_RETURN_OPENED_STATE,devState,sendLevel); + reResult = CI_ERROR; + } + } + + /* ؽ */ + return reResult; +} + +/* +* CBTC·źſź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* RETURN_OPEN_ERR_SIGOPEN +*/ +UINT8 OpenCbtcRouteOtherSignalCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 routeState = 0u; /*·״̬*/ + + /* ·豸 */ + /* źʱ״̬*/ + UINT8 const routeTimeState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId), + GetSystemParaRouteOpenSigCyc()); + /*·迪źŻ*/ + UINT8 const needOpenSigSum = GetRouteCbtcNeedOpenSigSum(routeId); + UINT16* const pNeedOpenBuf = GetRouteCbtcNeedOpenSigIdBuf(routeId); + /*·زͬʱźŻ*/ + UINT8 const oneOpenSigSum = GetRouteOnlyOneOpenSigSum(routeId); + UINT16* const pOneOpenBuf = GetRouteOnlyOneOpenSigIdBuf(routeId); + /*·رźŻ*/ + UINT8 const needCloseSigSum = GetRouteOpenNeedCloseSigSum(routeId); + UINT16* const pNeedCloseBuf = GetRouteOpenNeedCloseSigIdBuf(routeId); + + /*·źŻ۷·*/ + UINT8 const zheFanRouteSum = GetRtnEndSigAsStartSigRouteSum(routeId); + UINT16* const zheFanRouteIdBuf = GetReturnEndSigAsStartSigRoute(routeId); + + UINT8 signalVirtualAttr = SIGNAL_VIRTUAL_NO;/*źŻ*/ + UINT8 repeatOpenFlag = ROUTE_REPEATOPEN_SET_NO;/*ؿ־*/ + UINT8 needOpenNotTrueRepeatFlag = ROUTE_NEEDOPEN_REOPEN_NO;/*迪Ųؿ־*/ + + routeState = GetRouteState(routeId);/*ȡ·״̬*/ + /* ߼ */ + + /*·źųʱ*/ + if (CI_TIME_OUT != routeTimeState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + devId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_OPEN_OVERTIME, routeTimeState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·迪źŻѿ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedOpenBuf, needOpenSigSum, SIGNAL_OPEN, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + + repeatOpenFlag = GetRouteRepeatOpenFlag(routeId); + if ((ROUTE_STATE_FIRST_LOCKERR == routeState) && (ROUTE_REPEATOPEN_SET_YES == repeatOpenFlag)) + { + /*쳣ؿźʱͱ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_NEED_OPEN_STATE, devState, sendLevel); + } + else if (ROUTE_STATE_FIRST_LOCKERR != routeState) + {/*cgh-ϲCID-2539-3*/ + /*·Ԥաաӽ쳣ӽʱ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_NEED_OPEN_STATE, devState, sendLevel); + } + else + { + ; /*б*/ + } + + if (devId>0u) + { + signalVirtualAttr = GetSignalVirtualAttr(devId); + if (SIGNAL_VIRTUAL_YES == signalVirtualAttr) + { + reResult = RETURN_OPEN_ERR_NEEDOPEN; + } + else + { + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + /* ʧܷ */ + + + } + } + + if (CI_SUCCESS == reResult) + { + /*·زͬʱźŻδ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pOneOpenBuf, oneOpenSigSum, SIGNAL_CLOSE, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_ONE_OPEN_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·رźŻѹر + ʧܷ RETURN_OPEN_ERR_SIGOPEN*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedCloseBuf, needCloseSigSum, SIGNAL_CLOSE, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + + reResult = RETURN_OPEN_ERR_SIGOPEN; + } + } + + if (CI_SUCCESS == reResult) + { + /*ʼźŻΪնźŻ۷·ǷѾɹ*/ + devId = 0u; + devState = 0u; + checkResult = RtnEndSigAsStartSigRouteCheck(zheFanRouteIdBuf, zheFanRouteSum, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_SIG_RETURN_OPENED_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + } + + /* ؽ */ + return reResult; +} +/* +* ·Ծ״̬ +* ˵ UINT16 const routeId, · +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ ʧܷCI_ERROR +* ɹCI_SUCCESS +*/ +UINT8 RouteAllSecJumpLockStateCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState) +{ + /* ֲʼ */ + UINT8 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + + /*·*/ + /* ·*/ + UINT8 const routeSectionSum = GetRoutePhysicalSectionSum(routeId); + RoutePhysicalSectionStruct* const pRouteSectionDataBuf = GetRouteSectionData(routeId); + UINT8 reVal = CI_ERROR; + + /* Ծ״̬ */ + if (0u == routeSectionSum) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (i = 0u; i 0u) && (otherCiId != routeBelongCi)) + { + commState = GetLocalCiAndOtherCiTransSta(otherCiId);/*ͨͨ״̬*/ + if ((TRANSMIT_STATE_BAD == commState) && + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + {/*·ڱIJҪ*/ + if (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag) + { + /*ͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣҪ̵ӿȡղ̵״̬*/ + reResult = CI_SUCCESS; + + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleRelayZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + if (RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, cancleRelayZhaoChaRelayId, ETYPE_CANCLE_ZHAOCHA, relayState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + {/*ûȷϣ׼ʽ⣬ʧ*/ + reResult = CI_ERROR; + debug_infor_printf((const)"PhySectionFaultUnlockLogicProcess error,not Confirm.\n"); + } + + } + + } + } + else + {/*·ڱҪ*/ + + } + + } + + + } + return reResult; +} + +/* +* ·˽ĿԡֻҪ·һοֱӽ̹Ϊ˽Сע·˽ⲻɵøú +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +CI_SUCCESS:˽ִ +CI_ERROR:˽ⲻִ +*/ +UINT8 CheckRouteZongRenJieFeasibility(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_ROUTE_ZRJ; + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 cancleZhaoChaRelayId = 0u; /*ȡղ̵ID*/ + UINT8 relayState = 0u; /*̵ɼ״̬*/ + UINT8 trainEnterFlag = 0u; /*·гʻ־*/ + UINT16 inPhySecId = 0u; /*źŻڷһID*/ + UINT16 wInLogSecId = 0u; /* ·ڷһ߼ */ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT8 sectionSum = 0u;/*·*/ /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + UINT16 secIdx = 0u;/*·ڰα*/ + UINT8 chRouteLevel = 0U; + + /**/ + /* ·״̬ա*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + trainEnterFlag = GetRouteTrainEnterFlag(routeId);/*ȡ·гʻ־*/ + + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + + if (ROUTE_TRAIN_ENTER_FLAG_NO==trainEnterFlag) + {/*гûʻ*/ + /*·ڴڿе Ż޸ʱ䣺20170301ա޸ԭ򣺱·ռѹʱ̹*/ + if ((NULL==pRouteSecStru ) || (0u == sectionSum)) + { + reResult = CI_ERROR; + } + else + { + for (secIdx = 0u;secIdx < sectionSum;secIdx++) + {/*·ΣǷڿ*/ + inPhySecId = pRouteSecStru[secIdx].PhysicalSectionId; + devState = GetPhySecCurMergeState(inPhySecId); + + if (SECTION_OCCUPY_NO == devState) + { + break; + } + else + { + } + } + + if (secIdx < sectionSum) + {/*·ڴڿе*/ + reResult = CI_SUCCESS; + } + else + {/*·ȫռ*/ + reResult = CI_ERROR; + } + } + } + else + { + if ((NULL==pRouteSecStru ) || (0u == sectionSum)) + { + reResult = CI_ERROR; + } + else + { +#if 0 + inPhySecId = pRouteSecStru[0].PhysicalSectionId;/*·ڷһ*/ + devState = GetPhySecCurMergeState(inPhySecId); + + if (SECTION_OCCUPY_NO == devState) + {/**/ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + reResult = CI_ERROR; + } +#endif + /* ·ڷһ߼ο */ + wInLogSecId = GetRouteInFirstLogSecId(routeId); + devState = GetLogSecCurCtOrUtOccupyState(wInLogSecId); + + if (SECTION_OCCUPY_NO == devState) + { + /* */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, wInLogSecId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + } + } + + } + else + { + } + + if (CI_SUCCESS == reResult) + { + chRouteLevel = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(routeId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if ((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + devId = cancleZhaoChaRelayId; + devState = relayState; + if (RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, devId, ETYPE_CANCLE_ZHAOCHA, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + else + { + } + } + else + { + } + + return reResult; +} + +/* +* ·˽ĿԡֻҪ·һοֱӽ̹Ϊ˽Сע·˽ⲻɵøú +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +CI_SUCCESS:˽ִ +CI_ERROR:˽ⲻִ +*/ +UINT8 CheckDiaoCheRouteZRJFeasibility(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_DIAOCHE_ROUTE_ZRJ; + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 cancleZhaoChaRelayId = 0u; /*ȡղ̵ID*/ + UINT8 relayState = 0u; /*̵ɼ״̬*/ + UINT8 trainEnterFlag = 0u; /*·гʻ־*/ + UINT16 inPhySecId = 0u; /*źŻڷһID*/ + RoutePhysicalSectionStruct *pRouteSecStru = NULL; /**/ + UINT8 sectionSum;/*·*/ + UINT8 sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + UINT8 chRouteLevel = 0U; + + /* ·״̬ա*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + + if (CI_SUCCESS == reResult) + { + trainEnterFlag = GetRouteTrainEnterFlag(routeId);/*ȡ·гʻ־*/ + + if (ROUTE_TRAIN_ENTER_FLAG_NO == trainEnterFlag) + {/*гûʻ*/ + reResult = CI_SUCCESS; + } + else + { + sectionSum = GetRoutePhysicalSectionSum(routeId); /*ý·Ŀ*/ + pRouteSecStru = GetRouteSectionData(routeId); /*·*/ + + if ((NULL == pRouteSecStru) || (0u == sectionSum)) + { + reResult = CI_ERROR; + } + else + { + inPhySecId = pRouteSecStru[0].PhysicalSectionId; + + if (((ROUTE_STOPCHECK_SET_YES == GetRouteStopCheckFlag(routeId)) && + (PHYSICAL_SECTION_LJK_YES == GetPhySecLjkFlag(inPhySecId)) && + (PHYSICAL_STOPCHECK_SET_YES == GetPhySectionStopCheckFlag(inPhySecId))) + || (ROUTE_PHYSICALSECTION_CHECK_NO == pRouteSecStru[0].CheckProperty)) + { /*ֹͣЧΪмֹͣЧ,*/ + reResult = CI_SUCCESS; + } + else + { + devState = GetPhySecCurMergeState(inPhySecId); + + if (SECTION_OCCUPY_NO == devState) + { + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + } + } + } + } + else + { + } + + if (CI_SUCCESS == reResult) + { + chRouteLevel = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(routeId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if ((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + devId = cancleZhaoChaRelayId; + devState = relayState; + if (RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, devId, ETYPE_CANCLE_ZHAOCHA, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + } + else + { + } + + return reResult; +} + +/* +ձ +UINT16 const overlapId ID +UINT8 PLockDirect շ + +CI_SUCCESS ɹ +CI_ERROR ʧ + +*/ +UINT8 LockLocalOvlpCheckHlht(const UINT16 overlapId, UINT8 PLockDirect) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_HLHT_LOC_OVLP; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /* Ρδ*/ + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecFLockValidCheck(overlapId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + + + /* ΡС*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecOccuClearCheck(overlapId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + + /* ۷·*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllReturnRouteCheckup(overlapId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_USE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + + /* μ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapInvSecAndConSwiCheckup(overlapId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + + /* β*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapLateralDfnCheck(overlapId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* εĵжޱμ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapInvOppOverlapCheckup(overlapId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_OVERLAP, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + /* еδ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchYLockCheck(overlapId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + /* еδ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchFLockStateCheck(overlapId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + /* δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelProtSwiFLockStaCheck(overlapId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + /* δա + ͬա + ͬա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecLockDirectCheck(overlapId, PLockDirect, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + /*·еλȷλòȷɶ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchMoveValidCheck(overlapId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + /*ελü + RETURN_LOCK_ERR_SWITPOS ελòȷ + CI_SUCCESS еλȷ + */ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchPosCheck(overlapId, &devId, &devState); + if (CI_ERROR == checkResult) + { + /* λòȷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + } + else + { + /* λȷ ͨ */ + reResult = CI_SUCCESS; + } + } + else + { + } + /* ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecJumpLockStateCheck(overlapId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_JUMP_LOCK, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + + + return reResult; +} + +/* C11_ս·overlap߼ */ +/* +* ս·overlap߼,·ԼCIDZڻͨ +* ˵ const UINT16 routeId, const UINT16 overlapId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_OVER_LAP +*/ +UINT8 LockOthCiOvlpCheckHlht(const UINT16 routeId, const UINT16 overlapId) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_HLHT_REM_OVLP;/*Ҫ¶庯*/ + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + UINT8 cAlarmType = FLAG_UNSET; + + /* */ + + /*·һΡС*/ + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecCurMergeState(devId); + if (devState == SECTION_OCCUPY_NO) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·һΡաڵǰ·*/ + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecLockState(devId); + if ((GetPhySecLockState(devId) == PHYSICAL_SECTION_LOCK_NORMAL) && + (GetPhySecRLockBelongRouteId(devId) == routeId)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* Ρδ*/ + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecFLockValidCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ΡС*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecOccuClearCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* Ρδá*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecUsingClearCheck(overlapId, &devId, &devState, &cAlarmType); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (RETURN_WAIT_SWITCH_USING == checkResult) + { + reResult = RETURN_WAIT_SWITCH_USING; /*ͨ·ݲַ֧*/ + } + else + { + /* ¼ */ + if (FLAG_SET == cAlarmType) + { + /**/ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_USE_STATE, devState, sendLevel); + } + else + { + /*α*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_USE_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* δա + ͬա + ͬա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecLockValidCheck(overlapId, routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ߼Ρδ߼ա߷ͬ߼ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapLogSecLogicLockCheck(overlapId, routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* μ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapInvSecAndConSwiCheckup(overlapId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* β*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapLateralDfnCheck(overlapId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* εĵжޱμ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapInvOppOverlapCheckup(overlapId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_OVERLAP, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* еδ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchYLockCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* еδ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchFLockStateCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* еδ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelProtSwiFLockStaCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecJumpLockStateCheck(overlapId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + return reResult; +} + +/* + +UINT16 overlapId ID + +CI_SUCCESS ɹ +CI_ERROR ʧ + +*/ +UINT8 UnlockLocalOvlpCheckHlht(UINT16 overlapId) +{ + /**/ + UINT8 const functionId = EFUNC_UNLOCK_OVER_LAP; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /*·*/ + /*ϲ㺯ѼoverlapIdΪ0ʴ˴else֧߲˴޸*/ + + /*·з*/ + if (overlapId > 0u ) + { + /*з·*/ + reResult = CI_SUCCESS; + } + else + { + /*޷·*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE, overlapId, ETYPE_ROUTE_OVERLAP_UNLOCK, CI_ERROR, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /* ΡС*/ + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecOccuClearCheck(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + return reResult; +} + +/* +: ·նźŻЧԼ +: UINT16 const routeId ·ID +: UINT16 *pDevId 豸Id +UINT8 *pDevState 豸״̬ +ֵ: CI_SUCCESS +CI_ERROR +*/ +UINT8 SignalOverlapValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + UINT8 reResult = CI_ERROR; + + /*·״̬*/ + UINT16 tempDevId = 0u;/*·նźŻ*/ + UINT8 tempDevState = SIGNAL_PRO_SEC_INVALID;/*źŻЧ*/ + + if (routeId>0u) + { + /*鱣Ч*/ + tempDevId = GetRouteEndSignalId(routeId); + + if (tempDevId > 0u) + { + tempDevState = GetSignalProSecValid(tempDevId); + + if (SIGNAL_PRO_SEC_VALID == tempDevState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + + *pDevId = tempDevId; + *pDevState = tempDevState; + + return reResult; +} + +/* +* ·նźŻΪCBTC +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CheckRouteEndSignalNotCbtc(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 bCiSwitchShowGreenYellow = FUNC_SWITCH_OFF;/*̻ƿ*/ + UINT16 routeEndSignalId = 0u; /*·նźŻID*/ + UINT8 endSignalLightExtinctState = 0u;/*źŻϢ*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT32 curCycle = 0u; /*ǰں*/ + UINT32 keepSignalTolerateCyc = 0u; /*źűֿ״̬*/ + + UINT8 sigBelongCi = 0u;/*źŻ*/ + UINT8 commState = 0u;/*ͨ״̬*/ + /*Ƿ̵ּ֧ӿ*/ + UINT8 funcSwitchSupportRelayInterface = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + UINT8 localCi = GetSystemParaLocalCiId();/**/ + UINT8 confirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag();/*̵ӿȷ״̬*/ + UINT8 sigalMaintainState = 0U;/*źŻά޵״̬*/ + UINT8 belongVirCI = 0u; + UINT8 allSignalBrightFlag = 0u; /*ȫվ*/ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + bCiSwitchShowGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow); + if (FUNC_SWITCH_ON == bCiSwitchShowGreenYellow)/*ʾ̻Ƶƿء򿪡*/ + { + routeEndSignalId = GetRouteEndSignalId(routeId); + + sigBelongCi = GetSignalBelongCiId(routeEndSignalId);/*ȡźŻ*/ + commState = GetLocalCiAndOtherCiTransSta(sigBelongCi);/*ͨͨ״̬*/ + + if ((localCi !=sigBelongCi) && (TRANSMIT_STATE_BAD == commState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == confirmRelayInterfaceFlag)&& + (FUNC_SWITCH_ON == funcSwitchSupportRelayInterface)) + { + /*źŻ뱾ͬұͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣԲźŻ״̬*/ + reResult = CI_SUCCESS; + } + else + { + endSignalLightExtinctState = GetSignalLightExtinctState(routeEndSignalId);/*ȡնźŻǿƵ״̬*/ + /* ҷά޵*/ + sigalMaintainState = GetSignalMaintainState(routeEndSignalId);/*źŻά޵״̬*/ + + if (FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCI = GetSignalBelongVirCiId(routeEndSignalId); + allSignalBrightFlag = GetVirCIAllSignalBrightState(belongVirCI);/*ȫվƱ־*/ + } + else + { + allSignalBrightFlag = GetAllSignalBrightFlag(); /*ȫվƱ־*/ + } + if ((SIGNAL_LIGHT_EXTICT_STATE_NO == endSignalLightExtinctState )&&(MAINTAIN_STATE_NO == sigalMaintainState)) + { + routeState = GetRouteState(routeId); + if((ROUTE_STATE_YUXIAN_OPEN == routeState)||(ROUTE_STATE_NEAR_OPEN == routeState)) + { + curCycle = Get2oo2CurCycleNum();/*ǰں*/ + reResult = (UINT8)GetRouteKeepSigTolerateCyc(routeId,&keepSignalTolerateCyc);/*ȡźűֿ״̬*/ + if(CI_SUCCESS == reResult) + { + if(0u == keepSignalTolerateCyc) + { + reResult = SetRouteKeepSigTolerateCyc(routeId,curCycle);/*ÿź*/ + if(CI_SUCCESS == reResult) + { + /* ʲôҲ*/ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,routeEndSignalId,ETYPE_SIG_LIGHT_EXTINCT,SIGNAL_LIGHT_EXTICT_STATE_NO,sendLevel); + reResult = CI_ERROR; + } + } + else + { + if(ROUTE_SIGNAL_TOLERATE_OPEN_COUNT >= (curCycle - keepSignalTolerateCyc)) + { + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,routeEndSignalId,ETYPE_SIG_LIGHT_EXTINCT,SIGNAL_LIGHT_EXTICT_STATE_NO,sendLevel); + reResult = CI_ERROR; + } + } + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,routeEndSignalId,ETYPE_SIG_LIGHT_EXTINCT,SIGNAL_LIGHT_EXTICT_STATE_NO,sendLevel); + reResult = CI_ERROR; + } + + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,routeEndSignalId,ETYPE_SIG_LIGHT_EXTINCT,SIGNAL_LIGHT_EXTICT_STATE_NO,sendLevel); + reResult = CI_ERROR; + } + + } + else if ((SIGNAL_LIGHT_EXTICT_STATE_YES == endSignalLightExtinctState )||(MAINTAIN_STATE_YES == sigalMaintainState))/**/ + { + reResult = SetRouteKeepSigTolerateCyc(routeId,0);/*ź̿ſʼΪ0*/ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,routeEndSignalId,ETYPE_SIG_LIGHT_EXTINCT,SIGNAL_LIGHT_EXTICT_STATE_NO,sendLevel); + reResult = CI_ERROR; + } + } + } + else + { + reResult = CI_SUCCESS; + } + return reResult; +} + +/* +* ·նźŻ˿ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CheckRouteEndSignalDS(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 bCiSwitchCheckEndSignalDs = FUNC_SWITCH_OFF;/*鿪*/ + UINT16 routeEndSignalId = 0u; /*·նźŻID*/ + UINT8 endSignalCurColor = 0u;/*նźŻǰɫ*/ + UINT8 routeLevel = 0u; /*·*/ + UINT8 routeType = 0u; /*г*/ + UINT8 routeState = 0u; /*·״̬*/ + + bCiSwitchCheckEndSignalDs = GetCiFunctionSwitchConfig(FUNC_SWITCH_CHECK_END_SIGNAL_DS); + routeLevel = GetRouteLevel(routeId);/*·*/ + routeType = GetRouteType(routeId);/*·*/ + routeState = GetRouteState(routeId);/*ȡ·״̬*/ + + if (FUNC_SWITCH_ON == bCiSwitchCheckEndSignalDs) + {/*ش򿪽м*/ + routeEndSignalId = GetRouteEndSignalId(routeId); + + endSignalCurColor = GetSignalCurColor(routeEndSignalId);/*ȡնźŻǰɫ״̬*/ + + if ((ROUTE_LEVEL_BLOC == routeLevel) && (ROUTE_TYPE_DIAOCHE != routeType) + && (ROUTE_STATE_LEAD_LOCK != routeState) && (ROUTE_STATE_LEAD_OPEN != routeState) + && (ROUTE_STATE_LEAD_LOCKERR != routeState)) + {/*ֻ󱸡ǵг۷0աšҷ쳣µļ*/ + if (SIGNAL_SHOWCOLOUR_REDBREAK == endSignalCurColor )/*Ǻ*/ + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,routeEndSignalId,ETYPE_SIG_ENDSIGNAL_DS,SIGNAL_SHOWCOLOUR_REDBREAK,sendLevel); + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + } + else + {/*ش򿪣Ǻģʽߵ·سɹ*/ + reResult = CI_SUCCESS; + } + + } + else + {/*عرգسɹ*/ + reResult = CI_SUCCESS; + } + return reResult; +} + +/* +* ʽ·ź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + + /* ·豸 */ + /* ʼźŻId */ + UINT16 const startSignalId = GetRouteStartSignalId(routeId); + + /* ߼ */ + + devState = GetSignalCurColor(startSignalId); /*ȡźŻǰɫ*/ + if (SIGNAL_SHOWCOLOUR_REDBREAK != devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + + /*·źŻδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·ĵж*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ENEMY_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + reResult = CheckRouteEndSignalNotCbtc(routeId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + {/*նźŻ˿*/ + reResult = CheckRouteEndSignalDS(routeId,functionId,sendLevel); + } + + /* ؽ */ + return reResult; +} + +/* +* Ž· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLTrainRouteSwitchCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + + + /* ߼ */ + + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchFLockCheck(routeId,&devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteReltProtSwitchFLockCheck(routeId,&devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + + if(CI_SUCCESS == reResult) + { + /*·еλȷ*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSwitchPosCheck(routeId,&devId, &devState); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_POSTION_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + {/*·ŷ*/ + /*·λȷ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchPosCheck(routeId,&devId, &devState); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_POSTION_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·ա򡾵ҷա*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchLockCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_LOCK_STATUS,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + + /* ؽ */ + return reResult; +} + +/* ʽ۷·źűź */ +/* +* ʽ۷·źűź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepBlocReturnSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 endSigId = 0u; /*ȡ;۷źŻID*/ + UINT8 endSigState = SIGNAL_OPEN; /*նźŻ״̬ */ + + + /* ·豸 */ + /* ʼźŻId */ + UINT16 const startSignalId = GetRouteStartSignalId(routeId); + UINT8 flag = 0u; + UINT8 FSignalFlag = 0u; + + /* ߼ */ + + /* ·ʼźŻɫΪš*/ + devState = GetSignalOpenCloseState(GetSignalPreDriveColor(startSignalId)); + if (devState == SIGNAL_OPEN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + flag = 1u; + } + if (1u == flag) + { + } + else + { + FSignalFlag = GetCiFunctionSwitchConfig(CLOSE_OPENED_SIG_LOCK_SIGNAL); + if (FUNC_SWITCH_OFF == FSignalFlag) /*δ򲻼źŻ״̬*/ + { + reResult = CI_SUCCESS; + } + else if(FUNC_SWITCH_ON == FSignalFlag) + { + devId = 0u; + devState = 0u; + checkResult = RouteSignalFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + flag = 1u; + } + } + else + { + /**/ + } + /*·źŻδ*/ + + if (1u == flag) + { + } + else + { + /* ·նźŻδ*/ + endSigId = GetRouteEndSignalId(routeId); /*ȡ;۷źŻID*/ + endSigState = GetSignalOpenCloseState(GetSignalCurColor(endSigId)); + if (endSigState == SIGNAL_CLOSE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,endSigId,ETYPE_SIG_RETURN_DS_STATE,endSigState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + flag = 1u; + } + if (1u == flag) + { + } + else + { + /*·ĵж*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ENEMY_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + } + + if (CI_SUCCESS == reResult) + {/*նźŻ˿*/ + reResult = CheckRouteEndSignalDS(routeId,functionId,sendLevel); + } + + /* ؽ */ + return reResult; +} + +/* L01_ʽ·źŻ */ +/* +* ʽ·źŻ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetBlocRouteSignalCheck( UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 signalCurColor = 0u; + + /* ·豸 */ + /* ʼźŻId */ + UINT16 const startSignalId = GetRouteStartSignalId(routeId); + + /* ߼ */ + + /* ·ʼźŻδ*/ + signalCurColor = GetSignalCurColor(startSignalId); + devState = GetSignalOpenCloseState(signalCurColor); + if (devState == SIGNAL_CLOSE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·źŻδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·ĵж*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ENEMY_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /* ؽ */ + return reResult; +} + +/* L11_ʽ·źվ̨ */ +/* +* ʽ·źվ̨ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenRoutePlatformCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + + + UINT8 devState = 0u; /*豸״̬*/ + + UINT16 routeStartSignalId = GetRouteStartSignalId(routeId); + + /* ߼ */ +#if 0 /* վ̨PSDESBȣм */ + /*ӷ·*/ + /*վ̨رհťδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteEsbVainCheck(routeId, &devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PLATFORM,devId,ETYPE_ESB_VALID,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + return reResult; + } + + /*վ̨ȫŹرջ*/ + devId = 0u; + devState = 0u; + checkResult = RoutePsdCloseCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PLATFORM,devId,ETYPE_PSD_CLOSE_NO,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + return reResult; + } + +#endif + /*վ̨δʵʩ۳ҵ*/ + devState = GetSignalDetainFlag(routeStartSignalId); + if (SIGNAL_DETAIN_NO==devState ) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,routeStartSignalId,ETYPE_PLAT_DETAIN,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + + /* ؽ */ + return reResult; +} + +/* +* ·ȫվ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LeadzLockCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 includeVirFlag = 0U; + UINT8 belongVirCI = 0u; + UINT8 yLockState = 0u; /*״̬*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 routeStartSignalId = GetRouteStartSignalId(routeId); /*ȡ·ʼźŻ*/ + /*ID*/ + includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + /*ȡ·*/ + devState = GetRouteLeadProperty(routeId); + + /*ȡȫվı־*/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + belongVirCI = GetRouteBelongVirCiId(routeId); /*ȡ·ID*/ + yLockState = GetVirCIAllSwitchYLockState(belongVirCI); + } + else + { + yLockState = GetAllSwitchYLockFlag(); + } + + if (ROUTE_LEAD_PROPERTY_YES == devState) + { + reResult = CI_SUCCESS; /*CBTCĽ·dzɶĵط*/ + } + else /*·ֻֻ0xaa0xbb*/ + { + /*CBTCߵĽ·Ҫɶ*/ + if (CI_ALL_SWITCH_YLOCK_NO != yLockState) + { + /*ATSYF0083-1318*/ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, routeStartSignalId, ETYPE_SIG_LEAD_ALL_LOCK, CI_ERROR, sendLevel); + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + } + return reResult; +} + +/* +* г·źŻ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLTrainRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + + /* ·豸 */ + /* ʼźŻId */ + UINT16 const startSignalId = GetRouteStartSignalId(routeId); + + /* ߼ */ + + /* ·ʼźŻɫΪơ*/ + devState = GetSignalCurColor(startSignalId); + if ((SIGNAL_SHOWCOLOUR_RED == devState)||(SIGNAL_DRIVECOLOUR_REDCLOSE == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + if(CI_SUCCESS == reResult) + { + /*·źŻδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if(CI_SUCCESS == reResult) + { + /*·ĵж*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ENEMY_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + {/*նźŻ˿*/ + reResult = CheckRouteEndSignalDS(routeId,functionId,sendLevel); + } + + /* ؽ */ + return reResult; +} + +/* L09_ʽ·źŵ */ +/* +* ʽ·źŵ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocRouteSwitchCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 lineIdentity = CI_TRADITION_RAILWAY; + + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ*/ + + /* ·豸 */ + + + /* ߼ */ + + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchFLockCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteReltProtSwitchFLockCheck(routeId,&devId, &devState); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + if(CI_TRADITION_RAILWAY == lineIdentity) + { + /*·еλȷ*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSwitchPosCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_POSTION_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ *//* zt ɾش 2022-02-15 */ + reResult = CI_ERROR; + } + } + + if(CI_SUCCESS == reResult) + { + if(CI_TRADITION_RAILWAY == lineIdentity) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ *//* zt ɾش 2022-02-15 */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + {/*·ŷ*/ + if(CI_TRADITION_RAILWAY == lineIdentity) + { + /*·λȷ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchPosCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_POSTION_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·ա򡾵ҷա*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchLockCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_LOCK_STATUS,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ *//* zt ɾش 2022-02-15 */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + checkResult = RouteAllLtrlDfncSwitchCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ؽ */ + return reResult; +} + + +/* L10_ʽ·źű */ +/* +* ʽ·źű +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocRouteOverlapCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devStateType = 0u; /*豸״̬*/ + UINT8 devState = 0u; /*豸״̬*/ + + /* ·豸 */ + /*·*/ + UINT8 const overlapSum = GetRouteOverlapSum(routeId); + UINT16 const overlapId = GetRouteOverlapLockedId(routeId); + + UINT8 lineIdentity = CI_TRADITION_RAILWAY; + + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ*/ + + /* ߼ */ + + /*·*/ + if (overlapSum>0u) + { + /*з·*/ + /*·Id>0 Ρ·IDڵǰ·*/ + devId = GetOverlapFirstPhySecId(overlapId); + devState = GetPhySecLockState(devId); + if ((overlapId > 0u) && (routeId == GetPhySecPLockBelongRouteId(devId))) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_OVERLAP_UNLOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + /*зΡδ*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecFLockValidCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* cgh-ϲCID-2539-1cgh-ϲCID-2539-1 */ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*зΡС*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OpenBlockOvlpAllSecOccuClrCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_ROUTE_OVERLAP_OCCUPY,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + if(CI_TRADITION_RAILWAY == lineIdentity) + { + /*ελȷ*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchPosCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_POSTION_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + } + else + { + /* zt ɾش 2022-02-15 */ + /*·*/ + } + +#if 0 /*·ɲƣʱ·Ӧԭ״̬*/ + + /* еδ*/ + if(CI_SUCCESS == checkResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchYLockCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_YLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* еδ*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchFLockStateCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* δ*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelProtSwiFLockStaCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ιλȷ*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelatedProtSwitchPosCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_POSTION_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ιա򡾵ҷա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelatedProtSwitchLockCheck(overlapId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_LOCK_STATUS,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = SignalOverlapValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_PRO_SEC_VALID, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*鱣״̬*/ + devId = 0u; + devState = 0u; + checkResult = OverlapInvSecAndConSwiCheckup(overlapId, &devId, &devState); + + if(CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + } + + /*·β*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapLateralDfnCheck(overlapId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + } + + /* ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecJumpLockStateCheck(overlapId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + + /*з״̬*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapFloodGateStateCheck(overlapId,&devId,&devStateType,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_FLOODGATE,devId,devStateType,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + else + { + /*޷·*/ + reResult = CI_SUCCESS; + } + + /* ؽ */ + return reResult; +} + + +/* zt ɾش 2022-02-15 */ + +/*һεЧǷڳ +* ˵ +* const UINT16 switchId, ID +* const UINT8 swtCurPos, λ +*ֵ CI_ERROR ڳɶ +* CI_SUCCESS ûгɶ +*/ +UINT8 checkSwtLastValDrvPosStayorNot(const UINT16 switchId,const UINT8 swtCurPos) +{ + UINT8 retVal = CI_ERROR;/*ֵ*/ + UINT8 lastValidDrvSta = 0u;/*һεЧ״̬*/ + UINT32 lastValidDrvCycNum = 0u;/*һεЧ״̬ʼ*/ + + lastValidDrvSta = GetSwitchLastValidDrvPos(switchId); + lastValidDrvCycNum = GetSwitchLastValDrvPosStartCyc(switchId); + + if (SWITCH_POSITION_DINGWEI == swtCurPos) + {/*λ*/ + if (SWITCH_DRIVE_POS_FANWEI == lastValidDrvSta) + {/*һЧΪλ*/ + if ((Get2oo2CurCycleNum() - lastValidDrvCycNum) <= SWITCH_LAST_DRV_STAY_MAX_NUM ) + {/**/ + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + } + else if((SWITCH_DRIVE_POS_DINGWEI == lastValidDrvSta) + ||(SWITCH_DRIVE_POS_INVALID ==lastValidDrvSta)) + { + /*Ϊλû*/ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else if (SWITCH_POSITION_FANWEI == swtCurPos) + {/*λ*/ + if (SWITCH_DRIVE_POS_DINGWEI == lastValidDrvSta) + {/*һЧΪλ*/ + if ((Get2oo2CurCycleNum() - lastValidDrvCycNum) <= SWITCH_LAST_DRV_STAY_MAX_NUM ) + {/**/ + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + } + else if ((SWITCH_DRIVE_POS_FANWEI == lastValidDrvSta) + || (SWITCH_DRIVE_POS_INVALID == lastValidDrvSta)) + { + /*Ϊλû*/ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + + return retVal;/*ֵ*/ +} + + +/* +* ձμʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 + CI_SUCCESS:޵ʱ + CI_ERROR:еʱ +*/ +UINT8 ChekSwitDrivOvtm(const UINT16 overlapId) +{ + UINT8 retVal = CI_SUCCESS; + + /* overlap */ + UINT8 const routeSwitchSum = GetOverlapSwitchSum(overlapId); + OverlapConditionSwitchStruct* const switchDataBuf = GetOverlapCondSwitchStruct(overlapId); + UINT8 const protectSwitchSum = GetOverlapRelatedProtSwitSum(overlapId); + OverlapProtectSwitchStruct* const protectSwitchDataBuf = GetOverlapRelatedProtSwitStru(overlapId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 SwitchId = 0u; + UINT8 SwitchPos = SWITCH_POSITION_INVALID; + UINT8 SwitchDrivOvtmDrvPos = SWITCH_DRIVE_POS_INVALID; + UINT8 cLocalCiId = 0U; + UINT8 cSwitchBelongCiId = 0U; + + cLocalCiId = GetSystemParaLocalCiId(); + + if ((0u == routeSwitchSum) || (NULL == switchDataBuf)) + { + /*޼*/ + retVal = CI_SUCCESS; + } + else + { + /*ʼ*/ + for (i = 0u; i 0u) + { + phyOccupyState = GetPhySecCurMergeState(phyId); + + if (SECTION_OCCUPY_YES == phyOccupyState) + {/*ռã鷽*/ + if ((FLOOD_GATE_ACCESS_DIR == phyDir) || (FLOOD_GATE_AWAY_DIR == phyDir)) + { + phyRlockBelongRouteId = GetPhySecRLockBelongRouteId(phyId); + if (0U < phyRlockBelongRouteId) + { + lockDir = GetPhySecLockDirection(phyId); + haveDirChangeInRoute = GetRouteHaveDirChangePointIn(phyRlockBelongRouteId); + shouldOppose = GetRoutePhySecShouldLockOppose(phyRlockBelongRouteId, phyId);/*ǷӦȡ*/ + if (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute) + {/*·з仯*/ + if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == shouldOppose) + {/*Ӧȡ*/ + if (CI_SYSTEM_DIRECTION_UP == lockDir) + { + lockDir = CI_SYSTEM_DIRECTION_DOWN;/*֮ǰյģȡ*/ + } + else if (CI_SYSTEM_DIRECTION_DOWN == lockDir) + { + lockDir = CI_SYSTEM_DIRECTION_UP;/*շȡ*/ + } + else + { + /*ִе*/ + } + } + else + {/*Ӧȡ*/ + /*֮ǰɶɶ*/ + } + } + lockDir = ConvertDirectionToLogic(lockDir); /*ӪתΪ߼*/ + + if (phyDir != lockDir) + { + /*ǽӽ򣬷طǽӽ*/ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; /*гӽؽӽ*/ + } + } + else + { + reResult = CI_ERROR; /*δ·գδգUTռѹؽӽ*/ + } + } + else + { + /*÷ΪĬʱΪӽ*/ + reResult = CI_ERROR; + } + + if (CI_ERROR == reResult) + { + *pDevId = phyId; + *pDevState = phyOccupyState; + break; + } + } + else + { + /*οУǽӽ*/ + reResult = CI_SUCCESS; + } + } + + } + } + return reResult; +} + + +/* +* ŷռü +* ˵ +* UINT16 floodGateId, Id +* UINT16 *pDevId, 豸idָ룬ȡid +* UINT8 *pDevState, 豸id״ָ̬룬ȡ״̬ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 FloodGateProtPhysecOccuCheck(UINT16 floodGateId,UINT16 *pDevId,UINT8 *pDevState) +{ + UINT8 reResult =CI_ERROR; + + UINT16 phySecSum = 0u; + UINT16 *pPhySecIdBuf = NULL;/*ʱŹidָ*/ + UINT16 phyId = 0u; + UINT8 phyOccupyState = 0u;/*ʱռ״̬*/ + + UINT16 ii=0u; + + phySecSum = GetFloodGateProtectPhySecNum(floodGateId); + pPhySecIdBuf = GetFloodGateProtectPhyIDBuf(floodGateId); + + if ((NULL == pPhySecIdBuf) ||(NULL == pDevId) || (NULL == pDevState)) + { + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + if (CI_SUCCESS == reResult) + { + for (ii=0u;ii 0u) + { + phyOccupyState = GetPhySecCurMergeState(phyId); + + if (SECTION_OCCUPY_YES == phyOccupyState) + {/*ռãʧܣѭ*/ + reResult = CI_ERROR; + *pDevId = phyId; + *pDevState = phyOccupyState; + break; + } + + } + + } + } + return reResult; +} + + + +/* +* ι״̬ +* ˵ UINT16 const overlapId, ID +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevStateType,豸״̬ͣأ +* UINT8 *pDevState, 豸״̬أ +* ֵ ʧܷCI_ERROR +* ɹCI_SUCCESS +*/ +UINT8 OverlapFloodGateStateCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevStateType,UINT8 *pDevState) +{ + /* ֲʼ */ + UINT8 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT16 floodGateId = 0u;/*ʱid*/ + UINT8 floodState = 0u;/*ʱ״̬*/ + UINT8 reVal = CI_ERROR; + /* overlap */ + UINT8 const floodSum = (UINT8)GetOverlapFloodGateSum(overlapId); + UINT16* const pFloodIdBuf = GetOverlapFloodGateBuf(overlapId); + + + /* ָ */ + if ((NULL == pFloodIdBuf) || (NULL == pDevId) || (NULL == pDevStateType) || (NULL == pDevState) ) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + /*ʼ*/ + for (i = 0u; i 0u) + { + if (pOverlapFloodIdBuf != NULL) + { + for (pp=0u;pp 0u) + { + reVal = FloodGateStateCheck(floodGateId,functionId,sendLevel); + if (CI_ERROR == reVal) + { + flagBreak = 1u; + break; + } + } + } + if (1u == flagBreak) + { + break; + } + } + + if (CI_SUCCESS == reVal) + { + flagBreak = 0u; + pRouteOverlapIdBuf = GetRouteOverlapIdBuf(routeId); + routeOverlapSum = GetRouteOverlapSum(routeId); + for(kk =0u;kk 0u) + { + if (pOverlapFloodIdBuf != NULL) + { + for (pp=0u;pp 0u) + { + /*״̬Ϊ״̬*/ + reVal = FloodGateStateCheck(floodGateId,functionId,sendLevel); + if (CI_ERROR == reVal) + { + flagBreak = 1u; + break; + } + + } + + } + if (1u == flagBreak) + { + break; + } + } + + if (CI_SUCCESS == reVal) + { + flagBreak = 0u; + pRouteOverlapIdBuf = GetRouteOverlapIdBuf(routeId); + routeOverlapSum = GetRouteOverlapSum(routeId); + for(kk =0u;kk 0u) + { + if (pOverlapFloodIdBuf != NULL) + { + for (pp=0u;pp ROUTE_SUM_MAX) || (belongCiId != localCiId)) + { + /*IDЧDZ*/ + } + else + { + autoTriggerType = GetAutoTriggerType(routeId); /*ȡ·Զ·*/ + if (ROUTE_TYPE_AUTO_TRIGGER == autoTriggerType) + { + BlocRouteFloodGateCheck + reVal = ChekRouteFlockState(routeId, functionId); + if (CI_ERROR == reVal) + { + break; /*Ľ·һзԶ*/ + } + } + } + + } + return reVal; +#endif + + UINT8 functionId = ETYPE_AUTO_TRAGGER_FLAG; + UINT8 reVal = CI_ERROR; + UINT8 sendLevel = ESEND_LEVEL_ATS; + UINT16 ii = 0U; + UINT16 kk = 0U; + UINT16 pp = 0U; + UINT16 devId = 0U; + UINT8 autoTriggerType = 0U; /*Զ·*/ + + UINT16 floodSum = 0u; + UINT16* pFloodIdBuf = NULL;/*ʱ·idָ*/ + + UINT16* pRouteOverlapIdBuf = NULL;/*·idָ*/ + UINT16 routeOverlapSum = 0u;/*·*/ + UINT16* pOverlapFloodIdBuf = NULL;/*ιidָ*/ + UINT16 overlapFloodSum = 0u;/*ι*/ + + UINT16 jj = 0u;/*ʱ*/ + UINT8 flagBreak = 0u;/*жѭ־*/ + + UINT16 floodGateId = 0U;/*ʱid*/ + + + + autoTriggerType = GetAutoTriggerType(routeId); /*ȡ·Զ·*/ + if (ROUTE_TYPE_AUTO_TRIGGER == autoTriggerType) + { + floodSum = GetRouteFloodGateSum(routeId); + pFloodIdBuf = GetRouteFloodGateBuf(routeId); + + if (NULL == pFloodIdBuf) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + flagBreak = 0u; + for (jj = 0u; jj < floodSum; jj++) + { + devId = pFloodIdBuf[jj]; + + floodGateId = GetFloodGateBufIndex(devId);/*idϷж*/ + + reVal = FloodGateStateCheck(floodGateId, functionId, sendLevel);/*״̬*/ + + if (CI_ERROR == reVal) + { + flagBreak = 1u; + break; + } + } + } + } + + if (CI_SUCCESS == reVal) + { + flagBreak = 0u; + pRouteOverlapIdBuf = GetRouteOverlapIdBuf(routeId);/*ȡ·buf*/ + routeOverlapSum = GetRouteOverlapSum(routeId);/*ȡ·*/ + for (kk = 0u; kk < routeOverlapSum; kk++) + { + if (pRouteOverlapIdBuf != NULL) + { + pOverlapFloodIdBuf = GetOverlapFloodGateBuf(pRouteOverlapIdBuf[kk]);/*ȡιbuf*/ + overlapFloodSum = GetOverlapFloodGateSum(pRouteOverlapIdBuf[kk]);/*ȡι*/ + if (overlapFloodSum > 0u) + { + if (pOverlapFloodIdBuf != NULL) + { + for (pp = 0u; pp < overlapFloodSum; pp++) + { + floodGateId = pOverlapFloodIdBuf[pp]; + reVal = FloodGateStateCheck(floodGateId, functionId, sendLevel);/*״̬*/ + if (CI_ERROR == reVal) + { + + flagBreak = 1u;/*жѭ־1*/ + break; + } + } + if (1u == flagBreak) + { + break; + } + } + + } + + } + + } + } + return reVal; + +} + + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteReltProtSwitchFLockCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState) +{ + /* · */ + UINT8 const checkSum = GetRouteRelatedProtectSwitchSum(routeId); + RouteProtectSwitchStruct* const pDataIdBuf = GetRouteRelatedProtSwitchData(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + + /* ״̬ */ + if (NULL == pDataIdBuf) + { + /*޼*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + /*ʼ*/ + for (i = 0u; i 0u) && ( ROUTE_TYPE_DIAOCHE == routeType)) + { + /*·*/ + reVal = CI_ERROR; + SetErrorData(funcId,CI_DEVICE_TYPE_ROUTE,routeRlockId,ETYPE_JUMP_LOCK_DIAOCE_ROUTE_LOCK,ROUTE_TYPE_DIAOCHE,sendLevel); + } + else + { + reVal = CI_SUCCESS; + } + + /*ܷ*/ + if ((routePlockId > 0u) && (CI_SUCCESS == reVal)) + { + routeLevel = GetRouteLevel(routePlockId); /*ȡ·ල*/ + pLockRouteState = GetRouteState(routePlockId); /*ȡ·״̬*/ + /*CBTC*/ + if(ROUTE_LEVEL_CBTC == routeLevel) + { + reVal = CI_SUCCESS; /*سɹ*/ + } + else + { + routeHaveNear = RouteHaveTrainNear(routePlockId); + /*·гӽҽ·״̬ΪӽŻԤȿ*/ + if ((CI_SUCCESS == routeHaveNear) && + ((ROUTE_STATE_YUXIAN_OPEN == pLockRouteState)||(ROUTE_STATE_NEAR_OPEN == pLockRouteState))) + { + reVal = CI_ERROR; + SetErrorData(funcId,CI_DEVICE_TYPE_ROUTE,routePlockId,ETYPE_ROUTE_STATE,pLockRouteState,sendLevel); + } + } + } + + /*ܱӽҽ·ӽŻԤȿ*/ + if ((CI_SUCCESS == reVal)&&(routeRlockId > 0u)) + { + routeLevel = GetRouteLevel(routeRlockId); /*ȡ·ල*/ + /*ʽ·*/ + if(ROUTE_LEVEL_BLOC == routeLevel) + { + routeHaveNear = RouteHaveTrainNear(routeRlockId); + /*·гӽҽ·״̬ΪӽŻԤȿ*/ + if ((CI_SUCCESS == routeHaveNear) && + ((ROUTE_STATE_YUXIAN_OPEN == routeState)||(ROUTE_STATE_NEAR_OPEN == routeState))) + { + reVal = CI_ERROR; + SetErrorData(funcId,CI_DEVICE_TYPE_ROUTE,routeRlockId,ETYPE_ROUTE_STATE,routeState,sendLevel); + } + } + else + { + /*سɹ*/ + reVal = CI_SUCCESS; + } + } + + if ((CI_SUCCESS == reVal) &&(PHYSICAL_SECTION_FLOCK_YES == phySecFLockState)) + { + /*δڷ״̬*/ + SetErrorData(funcId,CI_DEVICE_TYPE_PHYSEC,physicalSecId,ETYPE_PS_FLOCK_STATE,phySecFLockState,sendLevel); + reVal = CI_ERROR; + } + + if ((CI_SUCCESS == reVal)&&( CI_ERROR == PhysicalIntruSecVainCheck(physicalSecId))) + { + /*α*/ + SetErrorData(funcId,CI_DEVICE_TYPE_PHYSEC,physicalSecId,ETYPE_PS_INSTRU,0,sendLevel); + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + if (physicalSecId > 0u) + { + floodGateSum = GetPhySecLocatedFloodSum(physicalSecId); /*Ϊ0˵ûзţ飬ɷسɹ*/ + if (0U < floodGateSum) + { + floodGateIdBuf = GetPhySecLocatedFloodId(physicalSecId); + if (NULL != floodGateIdBuf) + { + for (jj = 0U; jj < floodGateSum; jj++) + { + /*зţ״̬*/ + floodState = GetFloodGateCurLogicCloseState(floodGateIdBuf[jj]); + if (FLOOD_GATE_OPEN != floodState) + { + reVal = CI_ERROR; + break; + } + else + { + reVal = CI_SUCCESS; + } + } + } + else + { + reVal = CI_ERROR; /*ȡʧܣʧ*/ + } + } + } + } + return reVal; +} + + + +/* +* Ծյ +* ˵ const UINT16 axisSecId, ID +* ֵ UINT8 + CI_SUCCESS:ͨ + CI_ERROR:ʧ +*/ +UINT8 JumpLockSwitchCheck(const UINT16 axisSecId,UINT8 funcId,UINT8 sendLevel) +{ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reVal = CI_ERROR; + + /*еδ*/ + devId = 0u; + devState = 0u; + reVal = AxisSecSwitchYZLockCheck(axisSecId,&devId, &devState); + if (CI_ERROR == reVal) + { + /* ¼ */ + SetErrorData(funcId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_YLOCK_STATE,devState,sendLevel); + } + + + /*еδ*/ + if (CI_SUCCESS == reVal) + { + devId = 0u; + devState = 0u; + reVal = AxisSecSwitchFLockCheck(axisSecId,&devId, &devState); + if (CI_ERROR == reVal) + { + /* ¼ */ + SetErrorData(funcId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + } + } + + /*еλȷһһ»λòȷɶ*/ + if (CI_SUCCESS == reVal) + { + devId = 0u; + devState = 0u; + reVal = AxisSecSwitchPosMoveValCheck(axisSecId,&devId, &devState,funcId, sendLevel); + if (CI_ERROR == reVal) + { + /* ¼ */ + SetErrorData(funcId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + } + } + + + /*еλȷ ȷRETURN_LOCK_ERR_SWITPOS ȷCI_SUCCESS*/ + if (CI_SUCCESS == reVal) + { + devId = 0u; + devState = 0u; + reVal = AxisSecAllSwitchPosCheck(axisSecId,&devId, &devState); + if (CI_ERROR == reVal) + { + reVal = RETURN_LOCK_ERR_SWITPOS; + } + } + + return reVal; +} + +/* +* ε״̬ +* ˵ UINT16 const axisSecId, α +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 AxisSecSwitchYZLockCheck(UINT16 const axisSecId,UINT16 *pDevId,UINT8 *pDevState) +{ + /* ε */ + UINT8 const checkSum = GetAxisSwitchSum(axisSecId); + AxisSwitchStruct* const dataIdBuf = GetAxisSwitchIdStru(axisSecId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + + /* ״̬ */ + if (NULL == dataIdBuf) + { + /*ָΪ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + /*ʼ*/ + for (i = 0u; i= secConditionSum)&&(NULL != pRouteNearPSSecStru)) + { + for(i=0u;i= nearPhySecSum) + { + if(0u == flag) + { + for(j=0u;j= axisSecSum)&&(CI_SUCCESS==reVal)) + { + for(i=0u;i= axisSwitchSum) + { + for(j=0u;jSwitchSum;/*ӽΰ*/ + if(CI_SUCCESS == reVal) + { + if(ROUTE_CONDITION_SWITCH_SUM_MAX >= switchSum) + { + for(k=0u;kConditionSwitchStru[k].SwitchId) + { + devState = GetSwitchCurPosition(devId);/*ȡλ*/ + if(devState != pRouteNearPSSecStru->ConditionSwitchStru[k].SwitchPosition) + { + reVal = CI_ERROR; + break; + } + else + { + /*ʲôҲ*/ + } + } + else + { + /*ʲôҲ*/ + } + } + } + else + { + reVal = CI_ERROR;/*Խ磬شֵ*/ + } + } + else + { + /*ʲôҲ*/ + } + } + } + else + { + reVal = CI_ERROR;/*Խ磬شֵ*/ + } + } + else + { + /*ʲôҲ*/ + } + } + } + else + { + reVal = CI_ERROR;/*Խ磬شֵ*/ + } + return reVal; +} + +/* +* г·ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 TradLTrainRouteSecLockValCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState) +{ +/* ·*/ + UINT8 checkSum = 0u; + RoutePhysicalSectionStruct* pDataIdBuf = NULL; + +/* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 secProtectDirection = 0u; + UINT8 phyArbState = 0u; + UINT8 routeDirDirection = 0u; + UINT8 routeStopState = 0u; + UINT8 phyLJKValue = 0u; + UINT8 phyStoCheckFlag = 0u; + UINT8 reVal = CI_ERROR; + + /*ֵ*/ + pDataIdBuf = GetRouteSectionData(routeId); + checkSum = GetRoutePhysicalSectionSum(routeId); + routeDirDirection = GetRouteDirection(routeId); + +/* ռ */ + if ((0u == checkSum) || (NULL == pDataIdBuf)) + { + /*ݴ*/ + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (i = 0u; i i); i++) + { + cSwitchUsingState = GetSwitchUsingState(pincludeSwitchBuff[i].SwitchId); /*ȡ״̬*/ + switchUsingOverlapId = GetSwitchBelongOverlapId(pincludeSwitchBuff[i].SwitchId); + + /*ü*/ + if (((SWITCH_USING_YES == cSwitchUsingState) && (switchUsingOverlapId == overlapId)) + || ((SWITCH_USING_NO == cSwitchUsingState) && (0U == switchUsingOverlapId))) + { + /*δû򱻸ñãͨ*/ + } + else + { + /*òڱΣʧ*/ + *pDevId = pincludeSwitchBuff[i].SwitchId; + returnValue = CI_ERROR; + break; + } + } + } + + /*ηü*/ + if(CI_SUCCESS == returnValue) + { + cLocalCiId = GetSystemParaLocalCiId(); + for(i = 0u; (i < protectSwitchSum)&&(OVERLAP_PROTECTSWI_SUM_MAX >i); i++) + { + cSwitchUsingState = GetSwitchUsingState(protectSwitchBuff[i].ProtectSwitchId); /*ȡ״̬*/ + switchUsingOverlapId = GetSwitchBelongOverlapId(protectSwitchBuff[i].ProtectSwitchId); + + cSwitchBelongCiId = GetSwitchBelongCiId(protectSwitchBuff[i].ProtectSwitchId); /*ȡ*/ + if (cLocalCiId == cSwitchBelongCiId) + { + /*鱾״̬*/ + if (((SWITCH_USING_YES == cSwitchUsingState) && (switchUsingOverlapId == overlapId)) + || ((SWITCH_USING_NO == cSwitchUsingState) && (0U == switchUsingOverlapId))) + { + /*δû򱻸ñãͨ*/ + } + else + { + /*òڱΣʧ*/ + returnValue = CI_ERROR; + } + } + else + { + /*DZ״̬*/ + dwXuanPaiStartCycNum = GetOverlapXuanPaiStartCycNum(overlapId); /*ȡѡʼں*/ + + if ((SWITCH_USING_YES == cSwitchUsingState) && (overlapId == switchUsingOverlapId)) + { + /*ѱñãͨ*/ + } + else if (((SWITCH_USING_APPLY == cSwitchUsingState) && (overlapId == switchUsingOverlapId)) + || ((SWITCH_USING_NO == cSwitchUsingState) && (0U == dwXuanPaiStartCycNum))) + { + returnValue = RETURN_WAIT_SWITCH_USING; /*ûδʼãصȴ*/ + } + else + { + /*òڱΣʧ*/ + returnValue = CI_ERROR; + } + } + + if (CI_ERROR == returnValue) + { + *pDevId = protectSwitchBuff[i].ProtectSwitchId; + break; + } + } + } + + return returnValue; +} + + +/* +* Overlapг +* ˵ UINT16 const overlapId +* UINT16 *pTrainId, гţأ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapLogicSectionTrainCheck(UINT16 const overlapId, UINT16 *pTrainId) +{ + UINT16 wTrainId = 0u; + UINT8 cOverlapLogicSectionSum = 0u; + UINT16* pOverlapLogicSectionIdBuf = NULL; + UINT8 cLogicSectionTrainSum = 0u; + LogicTrainResStruct* pLogicSectionTrainRes = NULL; + + UINT8 i = 0u; + UINT8 reVal = CI_ERROR; + + cOverlapLogicSectionSum = GetOverlapLogicSectionSum(overlapId); + pOverlapLogicSectionIdBuf = GetOverlapLogicSectionBuf(overlapId); + + if ((NULL != pTrainId) && (0u != cOverlapLogicSectionSum)) + { + reVal = CI_SUCCESS; + } + else + { + } + + if (CI_SUCCESS == reVal) + { + for (i = 0u; i < cOverlapLogicSectionSum; i++) + { + cLogicSectionTrainSum = GetLogSecTrainInfoSum(pOverlapLogicSectionIdBuf[i]); + pLogicSectionTrainRes = GetLogSecTrainInfo(pOverlapLogicSectionIdBuf[i]); + + if(NULL == pLogicSectionTrainRes) + { + reVal = CI_ERROR; + } + else if (0u == cLogicSectionTrainSum) + { + /* ޳ */ + } + else if(1u == cLogicSectionTrainSum) + { + /* һռѹ */ + if ((0u == wTrainId) || (wTrainId == pLogicSectionTrainRes[0u].wTrainId)) + { + /* һαȽϻгIDͬ */ + wTrainId = pLogicSectionTrainRes[0u].wTrainId; + } + else + { + /* гIDͬ */ + reVal = CI_ERROR; + } + } + else + { + /* ռѹ */ + reVal = CI_ERROR; + } + + if (CI_ERROR == reVal) + { + wTrainId = 0u; + break; + } + else + { + } + } + *pTrainId = wTrainId; + } + else + { + } + + return reVal; +} + +/* +* ߼η״̬ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecFLockCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ֲʼ */ + UINT16 wLgcRelativePhyId = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chPhyFLockState = PHYSICAL_SECTION_FLOCK_YES; + UINT8 chPhyFLockReason = 0U; + if ((NULL != pDevId)&&(NULL!= pDevState)) + { + wLgcRelativePhyId = GetLgcSecRelativePhySecId(wLgcId); + chPhyFLockState = GetPhySecFLockState(wLgcRelativePhyId); + if (PHYSICAL_SECTION_FLOCK_NO == chPhyFLockState) + { + /* ͨ*/ + chRetVal = CI_SUCCESS; + } + else + { + chPhyFLockReason = GetPhySecFLockType(wLgcRelativePhyId); + if (PHY_SEC_FLOCK_TYPE_SPKS == chPhyFLockReason) + { + /* SPKSʱӰԴ*/ + chRetVal = CI_SUCCESS; + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = wLgcRelativePhyId; + *pDevState = chPhyFLockState; + chRetVal = CI_ERROR; + } + } + + + } + else + { + chRetVal = CI_ERROR; + } + + + + return chRetVal; +} + +/* +* ߼λü +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +* ʹ߼ιм +*/ +UINT8 LogicSecRelativeSwitchPosCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ֲʼ */ + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT16 chDevId = 0U; + UINT8 chDevState = 0U; + UINT16 wLgcRelativeAxleSecId = 0U; + UINT8 chCheckSum = 0U; + LogsecSwitchStruct *pstlogicSecSwitchBuf = NULL; + + chCheckSum = GetLogicSecSwitchSum(wLgcId); + pstlogicSecSwitchBuf = GetLogicSecSwitchIdStru(wLgcId); + if ((NULL != pDevId) + && (NULL != pDevState) + &&(NULL !=pstlogicSecSwitchBuf) + &&(LOGSEC_INCLUDE_SWITCH_SUM_MAX>chCheckSum)) + { + chRetVal = CI_SUCCESS; + for (ii = 0U; ii < chCheckSum; ii++) + { + chDevId = pstlogicSecSwitchBuf[ii].SwitchId; + chDevState = GetSwitchCurPosition(chDevId); + if (pstlogicSecSwitchBuf[ii].SwitchPosition == chDevState) + { + /* λһ£*/ + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = chDevId; + *pDevState = chDevState; + chRetVal = CI_ERROR; + } + } + + + + } + else + { + chRetVal = CI_ERROR; + } + + + + return chRetVal; +} + +/* +* ߼δ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecRelSwitchFLockCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState, UINT8* pYLockAlarmFlag) +{ + /* ֲʼ */ + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT16 chDevId = 0U; + UINT8 chDevState = 0U; + UINT8 chCheckSum = 0U; + LogsecSwitchStruct *pstLogicSecSwitchBuf = NULL; + + chCheckSum = GetLogicSecSwitchSum(wLgcId); + pstLogicSecSwitchBuf = GetLogicSecSwitchIdStru(wLgcId); + if ((NULL != pDevId) && (NULL != pDevState) && (NULL != pYLockAlarmFlag) && (NULL != pstLogicSecSwitchBuf) + && (LOGSEC_INCLUDE_SWITCH_SUM_MAX>chCheckSum)) + { + chRetVal = CI_SUCCESS; + for (ii = 0U; ii < chCheckSum; ii++) + { + chDevId = pstLogicSecSwitchBuf[ii].SwitchId; + chDevState =GetSwitchFLockState(chDevId); + if (SWITCH_LOCK_FENGSUO_NO == chDevState) + { + /*δ*/ + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = chDevId; + *pDevState = chDevState; + *pYLockAlarmFlag = FLAG_UNSET; + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + chDevState = GetSwitchYLockState(chDevId); + if (SWITCH_LOCK_YINZONG_NO == chDevState) + { + + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = chDevId; + *pDevState = chDevState; + *pYLockAlarmFlag = FLAG_SET; + chRetVal = CI_ERROR; + } + } + else + { + /*ʧ*/ + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + ; /*ִ*/ + } + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ߼δ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecRltvPrtctSwFLockCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState, UINT8* pYLockAlarmFlag) +{ + /* ֲʼ */ + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT16 chDevId = 0U; + UINT8 chDevState = 0U; + UINT8 chCheckSum = 0U; + UINT16 wProtectSwSum = 0U; + UINT16* pProtectSwIdBuf = NULL; + LogsecSwitchStruct *pstLogicSecSwitchBuf = NULL; + + chCheckSum = GetLogicSecSwitchSum(wLgcId); + pstLogicSecSwitchBuf = GetLogicSecSwitchIdStru(wLgcId); + if ((NULL != pDevId) && (NULL != pDevState) && (NULL != pYLockAlarmFlag) && (NULL != pstLogicSecSwitchBuf) + && (LOGSEC_INCLUDE_SWITCH_SUM_MAX>chCheckSum)) + { + chRetVal = CI_SUCCESS; + for (ii = 0U; ii < chCheckSum; ii++) + { + wProtectSwSum = GetSwitchProtectSwitchNum(pstLogicSecSwitchBuf[ii].SwitchId); + pProtectSwIdBuf = GetSwitchProtectSwitchIdBuf(pstLogicSecSwitchBuf[ii].SwitchId); + + if ((NULL != pProtectSwIdBuf) + && (SWITCH_PROTECT_SWITCH_MAX_NUM > wProtectSwSum)) + { + for (jj = 0U; jj < wProtectSwSum; jj++) + { + chDevId = pProtectSwIdBuf[jj]; + chDevState = GetSwitchFLockState(chDevId); + if (SWITCH_LOCK_FENGSUO_NO == chDevState) + { + /*δ*/ + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = chDevId; + *pDevState = chDevState; + *pYLockAlarmFlag = FLAG_UNSET; + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + chDevState = GetSwitchYLockState(chDevId); + if (SWITCH_LOCK_YINZONG_NO == chDevState) + { + + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = chDevId; + *pDevState = chDevState; + *pYLockAlarmFlag = FLAG_SET; + chRetVal = CI_ERROR; + } + } + else + { + /*ʧ*/ + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + ; /*ִ*/ + } + } + } + + if (CI_ERROR == chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + + + + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ߼λü +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +* ޸ģʹ߼ηλ qw.liu +*/ +UINT8 LogicSecRltvPrtctSwPosCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ֲʼ */ + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT16 chDevId = 0U; + UINT8 chDevState = 0U; + UINT8 chCheckSum = 0U; + UINT8 chProSwState = 0U; + LogsecSwitchStruct *pstLogicSecSwitchBuf = NULL; + + chCheckSum = GetLgcRelateProSwSum(wLgcId);/*ȡָID߼ιĿ*/ + pstLogicSecSwitchBuf = GetLgcRelateProSwStru(wLgcId); + if ((NULL != pDevId) + && (NULL != pDevState) + && (NULL != pstLogicSecSwitchBuf) + && (LOGSEC_RELATE_PRO_SW_SUM_MAX>chCheckSum)) + { + chRetVal = CI_SUCCESS; + /*߼ι*/ + for (ii = 0U; ii < chCheckSum; ii++) + { + + chDevId = pstLogicSecSwitchBuf[ii].SwitchId; + chDevState = GetSwitchCurPosition(chDevId);/*ȡǰλ*/ + chProSwState = pstLogicSecSwitchBuf[ii].SwitchPosition; + /*λһ*/ + if ((chProSwState == chDevState) + && ((SWITCH_POSITION_DINGWEI == chProSwState) + || (SWITCH_POSITION_FANWEI == chProSwState))) + { + /*λüͨ*/ + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = chDevId; + *pDevState = chDevState; + chRetVal = CI_ERROR; + break; + } + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ߼״̬(ջ) +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecRltvPrtctSwLockCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ֲʼ */ + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT8 kk = 0U; + UINT16 chDevId = 0U; + UINT8 chDevState = 0U; + UINT16 wLgcRelativeAxleSecId = 0U; + + UINT8 chProtectSwitchSum = 0U; + LogsecSwitchStruct *chProtectSwitchIdBuf = NULL; + + chProtectSwitchSum = GetLgcRelateProSwSum(wLgcId);/*ȡָID߼ιĿ*/ + chProtectSwitchIdBuf = GetLgcRelateProSwStru(wLgcId); + + if ((NULL != pDevId) + && (NULL != pDevState) + && (NULL != chProtectSwitchIdBuf) + && (LOGSEC_INCLUDE_SWITCH_SUM_MAX > chProtectSwitchSum)) + { + chRetVal = CI_SUCCESS; + for (ii = 0U; ii < chProtectSwitchSum; ii++) + { + chDevId = chProtectSwitchIdBuf[jj].SwitchId; + chDevState = GetSwitchLockStatus(chDevId); + + if ((SWITCH_LOCK_STATUS_PROTECT == chDevState) || (SWITCH_LOCK_STATUS_DAP == chDevState)) + { + /*ѡա򡾵ҷա*/ + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = chDevId; + *pDevState = chDevState; + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ߼Ч +* ˵ +* UINT16 const physicalId, ID +* ֵ CI_ERROR +* CI_SUCCESS ޲ +* +*/ +UINT8 LogicIntruSecVainCheck(UINT16 const wLogicSecId, UINT16* pDevId, UINT8* pDevState) +{ + + /* ֲʼ */ + UINT16 i = 0u, j = 0u; /* ѭ */ + UINT16 intruSwitchSum = 0u; + UINT16 intruSwitchId = 0u; + UINT16 intruSwitchPos = 0u; + UINT8 intruSwitchLockDir = 0U; + UINT16 wDevId = 0u; + UINT8 chDevState = 0u; + UINT8 chDevFengSuoState = 0u; + UINT8 intruSwitchPosValid = CI_ERROR; + UINT8 reVal = CI_ERROR; + UINT8 chSwitchCurPos = 0U; + UINT8 chPhysecLockDir = 0U; + UINT8 chPhySecCtOrUt = 0U; + UINT8 cPhyLockState = 0U; + UINT8 cPhyJumpLockState = 0U; + /*ʱǷ */ + UINT8 checkFlockFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_CHECKFLOCK_FLAG); + /* */ + UINT8 const chLgcIntruSum = GetSecIntrudeLgcSectionSum(wLogicSecId); + UINT16* const pLgcSecIntruIdBuf = GetSecIntrudeLgcSectionData(wLogicSecId); + UINT8* const pLgcSecIntruDirBuf = GetSecIntrudeLgcSecDirData(wLogicSecId); + UINT8 chPhySecLogLockState = 0U;/*߼״̬*/ + + /* ״̬ */ + if ((NULL == pLgcSecIntruIdBuf) + || (NULL == pLgcSecIntruDirBuf) + || (NULL == pDevId) + || (NULL == pDevState)) + { + /*޼*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (i = 0u; i < chLgcIntruSum; i++) + { + wDevId = GetInvaSectId(pLgcSecIntruIdBuf[i]); + chDevState = GetPhySecCurMergeState(wDevId); + chDevFengSuoState = GetPhySecFLockState(wDevId); + chPhySecCtOrUt = GetPhySecUtOrCtOccuState(wDevId); + chPhysecLockDir = GetPhySecLockDirection(wDevId); + intruSwitchLockDir = pLgcSecIntruDirBuf[i]; + cPhyLockState = GetPhySecLockState(wDevId); + cPhyJumpLockState = GetPhySecJumpLockState(wDevId); + chPhySecLogLockState = PhySecLogLockStateCheck(wDevId); + + /* Ƿռû*/ + if ((SECTION_OCCUPY_NO != chDevState) + || ((PHYSICAL_SECTION_FLOCK_NO != chDevFengSuoState) && (FUNC_SWITCH_ON != checkFlockFlag)) + || (PHYSICAL_SECTION_LOCK_NO != cPhyLockState) + || (PHYSICAL_SECTION_JUMP_LOCK_NO != cPhyJumpLockState) + || (LOG_SECTION_LOGLOCK_NO != chPhySecLogLockState)) + { + /*ռû*/ + intruSwitchSum = GetInvaSectsCondSwitSum(pLgcSecIntruIdBuf[i]); + if (intruSwitchSum > 0u) + { + /*޵λü*/ + intruSwitchPosValid = CI_ERROR; + for (j = 0u; j < intruSwitchSum; j++) + { + intruSwitchId = GetInvaSectsCondSwitId(pLgcSecIntruIdBuf[i], (INT16)j); + intruSwitchPos = GetInvaSectsCondSwitStat(pLgcSecIntruIdBuf[i], (INT16)j); + + chSwitchCurPos = GetSwitchCurPosition(intruSwitchId); + if ((intruSwitchPos == chSwitchCurPos) + || (SWITCH_POSITION_SIKAI == chSwitchCurPos) + || (SWITCH_POSITION_MOVE == chSwitchCurPos) + || (SWITCH_POSITION_JICHA == chSwitchCurPos) + || (SWITCH_POSITION_INVALID == chSwitchCurPos)) + { + /* ռѹжռѹ */ + if ((PHYSICAL_SECTION_FLOCK_NO == chDevFengSuoState) + && (PHYSICAL_SECTION_JUMP_LOCK_NO == cPhyJumpLockState) + && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState)) + { + if ((chPhysecLockDir == intruSwitchLockDir) + && ((CI_SYSTEM_DIRECTION_UP == intruSwitchLockDir) + || (CI_SYSTEM_DIRECTION_DOWN == intruSwitchLockDir))) + { + if (LOGICSECTION_OCCUPY_CT == chPhySecCtOrUt) + { + intruSwitchPosValid = CI_SUCCESS; /*ɹ*/ + } + else + { + intruSwitchPosValid = IntruSecVainCheck(wDevId); + } + + } + else + { + intruSwitchPosValid = CI_ERROR; + } + } + else + { + intruSwitchPosValid = CI_ERROR; + } + } + else + { + /*δ*/ + intruSwitchPosValid = CI_SUCCESS; + break; + } + } + + if (intruSwitchPosValid == CI_ERROR) + { + /*в*/ + reVal = CI_ERROR; + *pDevId = wDevId; + *pDevState = chDevState; + } + } + else + { + /*޲*/ + reVal = CI_ERROR; + *pDevId = wDevId; + *pDevState = chDevState; + } + if (CI_ERROR == reVal) + { + *pDevId = wDevId; + *pDevState = chDevState; + break; + } + } + /* δռδ*/ + else if ((SECTION_OCCUPY_NO == chDevState) + && ((PHYSICAL_SECTION_FLOCK_NO == chDevFengSuoState) || (FUNC_SWITCH_ON == checkFlockFlag)) + && (PHYSICAL_SECTION_LOCK_NO == cPhyLockState) + && (PHYSICAL_SECTION_JUMP_LOCK_NO == cPhyJumpLockState) + && (LOG_SECTION_LOGLOCK_NO == chPhySecLogLockState)) + {/*δռ(δ򲻼)δδԾδ߼*/ + /*μͨ*/ + } + else + { + /*ռ״̬쳣ȫ*/ + reVal = CI_ERROR; + *pDevId = wDevId; + *pDevState = chDevState; + break; + } + } + } + + /* δ⵽ */ + return reVal; +} + +/* +* ·һ߼εһ߼ռ +* ˵UINT16 const wLogicSecId, ߼ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +* +*/ +UINT8 LogicNextLogSecLockCheck(UINT16 const wLogicSecId, UINT16* pDevId, UINT8* pDevState) +{ + /* ֲʼ */ + UINT8 i = 0U; + UINT8 reVal = CI_ERROR; + UINT16 wRouteLastLogSecId = 0U; /*߼·һ߼ID*/ + UINT16 wNextLogSecId = 0U; /*һ߼ID*/ + UINT16 wThisLogSecLockBelongRouteId = 0U; /*߼·ID*/ + UINT8 cRouteMainorSub = 0U; /*ӽ·*/ + UINT16 wRouteEndSignalId = 0U; /*·նźŻ*/ + UINT8 cSignalIsVir = 0U; /*źŻ*/ + UINT8 cThisRouteLockDir = 0U; /*߼·շ*/ + UINT8 cThisLogSecLockDir = 0U; /*߼շ*/ + UINT8 cNextLogSecLockstate = 0U; /*һ߼״̬*/ + UINT8 cNextLogSecLockDir = 0U; /*һ߼շ*/ + UINT8 cSysLogDir = 0U; /*ϵͳ߼*/ + UINT8 cRelatedLogSecSum = 0U; /*һ߼*/ + UINT16* pRelatedLogSecId = NULL; /*һ߼ID*/ + + wThisLogSecLockBelongRouteId = GetLogSecLockBelongRoute(wLogicSecId); + wRouteLastLogSecId = GetRouteInLastLogSecId(wThisLogSecLockBelongRouteId); + + if (0U == wRouteLastLogSecId)/*·һ߼IDЧ*/ + { + reVal = CI_ERROR; + *pDevId = wNextLogSecId; + *pDevState = cNextLogSecLockDir; + } + else if (wRouteLastLogSecId == wLogicSecId) /*ǰ߼Ϊ·һ߼βŴ*/ + { + cRouteMainorSub = GetRouteMainorSubPropert(wThisLogSecLockBelongRouteId); + + if (ROUTE_SUB_PROPERTY == cRouteMainorSub) /*ֶν·ж*/ + { + wRouteEndSignalId = GetRouteEndSignalId(wThisLogSecLockBelongRouteId); + cSignalIsVir = GetSignalVirtualAttr(wRouteEndSignalId); + + if (SIGNAL_VIRTUAL_NO != cSignalIsVir) /*źŻж*/ + { + cThisRouteLockDir = GetRouteDirection(wThisLogSecLockBelongRouteId); + cSysLogDir = GetLinkLogicDirUpAndDown(); + + /*߼ȷ߼һ߼/ID*/ + if (cThisRouteLockDir == cSysLogDir) + { + cRelatedLogSecSum = GetLogBeginLogSecSum(wLogicSecId); + pRelatedLogSecId = GetLogBeginLogSecData(wLogicSecId); + } + else + { + cRelatedLogSecSum = GetLogEndLogSecSum(wLogicSecId); + pRelatedLogSecId = GetLogEndLogSecData(wLogicSecId); + } + + for (i = 0U; i < cRelatedLogSecSum; i++) + { + wNextLogSecId = pRelatedLogSecId[i]; + cNextLogSecLockstate = GetLogSecLockState(wNextLogSecId); + + if ((LOG_SECTION_LOCK_NORMAL == cNextLogSecLockstate) || (LOG_SECTION_LOCK_PROTECT == cNextLogSecLockstate)) /*ȱYF0083-9162023-07-03*/ + { + cThisLogSecLockDir = GetLogSecLockDir(wLogicSecId); + cNextLogSecLockDir = GetLogSecLockDir(wNextLogSecId); + + if (((CI_SYSTEM_DIRECTION_DOWN == cThisLogSecLockDir) && (CI_SYSTEM_DIRECTION_DOWN == cNextLogSecLockDir)) + || ((CI_SYSTEM_DIRECTION_UP == cThisLogSecLockDir) && (CI_SYSTEM_DIRECTION_UP == cNextLogSecLockDir))) + { + reVal = CI_SUCCESS; /*߼һ߼շͬسɹ*/ + } + else + { + + *pDevId = wNextLogSecId; + *pDevState = cNextLogSecLockDir; + reVal = CI_ERROR; + break; + } + } + else + { + *pDevId = wNextLogSecId; + *pDevState = cNextLogSecLockDir; + reVal = CI_ERROR; + } + } + } + else + { + reVal = CI_SUCCESS; /*ʵźŻسɹ*/ + } + } + else + { + reVal = CI_SUCCESS; /*·ͨ·سɹ*/ + } + } + else + { + reVal = CI_SUCCESS; /*ǽ·һ߼Σسɹ*/ + } + + return reVal; +} + +/* +* ߼·һ߼εһ߼ռ +* ˵UINT16 const wLogicSecId, ߼ID +* UINT16 const wLogRouteId, +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +* +*/ +UINT8 LogRouteNextLogSecLockCheck(UINT16 const wLogicSecId, UINT16 const wLogRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT8 reVal = CI_ERROR; + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 wRouteLastLogSecId = 0U; + UINT16 wNextLogSecId = 0U; /*һ߼ID*/ + UINT8 cNextLogSecLockDir = 0U; /*һ߼շ*/ + UINT8 cThisRouteLockDir = 0U; /*߼߼·շ*/ + UINT8 cSysLogDir = 0U; /*ϵͳ߼*/ + UINT8 cRelatedLogSecSum = 0U; /*һ߼*/ + UINT16* pRelatedLogSecId = NULL; /*һ߼ID*/ + UINT8 i = 0U; + UINT8 cNextLogSecLockstate = 0U; /*һ߼״̬*/ + UINT8 cThisLogSecLockDir = 0U; /*߼շ*/ + UINT8 cLogRouteNextLogSecLockstate = 0U; /*һ߼߼״̬*/ + + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + logSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + wRouteLastLogSecId = LogSecIdBuff[logSecSum - 1U]; /*ȡ߼·һ߼*/ + + if (0U == wRouteLastLogSecId)/*·һ߼IDЧ*/ + { + reVal = CI_ERROR; + *pDevId = wNextLogSecId; + *pDevState = cNextLogSecLockDir; + } + else if (wRouteLastLogSecId == wLogicSecId) + { + cThisRouteLockDir = GetLogicalRouteDir(wLogRouteId); + cSysLogDir = GetLinkLogicDirUpAndDown(); + + /*߼ȷ߼һ߼/ID*/ + if (cThisRouteLockDir == cSysLogDir) + { + cRelatedLogSecSum = GetLogBeginLogSecSum(wLogicSecId); + pRelatedLogSecId = GetLogBeginLogSecData(wLogicSecId); + } + else + { + cRelatedLogSecSum = GetLogEndLogSecSum(wLogicSecId); + pRelatedLogSecId = GetLogEndLogSecData(wLogicSecId); + } + + for (i = 0U; i < cRelatedLogSecSum; i++) + { + wNextLogSecId = pRelatedLogSecId[i]; + cNextLogSecLockstate = GetLogSecLockState(wNextLogSecId); + cLogRouteNextLogSecLockstate = GetLogSecLogLockState(wNextLogSecId); /*ȡ߼߼·״̬*/ + cThisLogSecLockDir = GetLogSecLogLockDir(wLogicSecId); /*߼·߼շ*/ + + if ((LOG_SECTION_LOCK_NORMAL == cNextLogSecLockstate) || (LOG_SECTION_LOCK_PROTECT == cNextLogSecLockstate)) /*ȱYF0083-9162023-07-03*/ + { + cNextLogSecLockDir = GetLogSecLockDir(wNextLogSecId); + + if (((CI_SYSTEM_DIRECTION_DOWN == cThisLogSecLockDir) && (CI_SYSTEM_DIRECTION_DOWN == cNextLogSecLockDir)) + || ((CI_SYSTEM_DIRECTION_UP == cThisLogSecLockDir) && (CI_SYSTEM_DIRECTION_UP == cNextLogSecLockDir))) + { + reVal = CI_SUCCESS; /*߼һ߼շͬسɹ*/ + } + else + { + + *pDevId = wNextLogSecId; + *pDevState = cNextLogSecLockDir; + reVal = CI_ERROR; + break; + } + } + else if(LOG_SECTION_LOCK_NO== cNextLogSecLockstate) + { + reVal = CI_SUCCESS; /*һ߼οУԸԴسɹ*/ + } + else + { + *pDevId = wNextLogSecId; + *pDevState = cNextLogSecLockDir; + reVal = CI_ERROR; + break; + } + + if (CI_SUCCESS == reVal) + { + if (LOG_SECTION_LOGLOCK_NORMAL == cLogRouteNextLogSecLockstate) + { + cNextLogSecLockDir = GetLogSecLogLockDir(wNextLogSecId); /*һ߼շ*/ + + if (((CI_SYSTEM_DIRECTION_DOWN == cThisLogSecLockDir) && (CI_SYSTEM_DIRECTION_DOWN == cNextLogSecLockDir)) + || ((CI_SYSTEM_DIRECTION_UP == cThisLogSecLockDir) && (CI_SYSTEM_DIRECTION_UP == cNextLogSecLockDir))) + { + reVal = CI_SUCCESS; /*߼һ߼շͬسɹ*/ + } + else + { + + *pDevId = wNextLogSecId; + *pDevState = cNextLogSecLockDir; + reVal = CI_ERROR; + break; + } + } + else if (LOG_SECTION_LOGLOCK_NO == cLogRouteNextLogSecLockstate) + { + reVal = CI_SUCCESS; /*һ߼οУԸԴسɹ*/ + } + else + { + *pDevId = wNextLogSecId; + *pDevState = cNextLogSecLockDir; + reVal = CI_ERROR; + break; + } + } + } + } + else + { + reVal = CI_SUCCESS; /*ǽ·һ߼Σسɹ*/ + } + + return reVal; +} + +/* +* ߼Ծ״̬ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-02 +*/ +UINT8 LogicSecJumpLockCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ֲʼ */ + UINT16 wLgcRelativePhyId = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chPhyJumpLockState = PHYSICAL_SECTION_JUMP_LOCK_YES; + + if ((NULL != pDevId) && (NULL != pDevState)) + { + wLgcRelativePhyId = GetLgcSecRelativePhySecId(wLgcId); + chPhyJumpLockState = GetPhySecJumpLockState(wLgcRelativePhyId); + if (PHYSICAL_SECTION_JUMP_LOCK_NO == chPhyJumpLockState) + { + /* ͨ*/ + chRetVal = CI_SUCCESS; + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = wLgcRelativePhyId; + *pDevState = chPhyJumpLockState; + chRetVal = CI_ERROR; + } + + + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ߼ԴԼ +* ˵ +* UINT16 wLogicSecId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogicSecResSwitchCheck(UINT16 wLogicSecId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 FSwitchFlag = 0u; + UINT8 cYLockAlarmFlag = FLAG_UNSET; /*־*/ + + /* ߼ */ + + FSwitchFlag = GetCiFunctionSwitchConfig(CLOSE_OPENED_SIG_LOCK_SWITCH); + if (FUNC_SWITCH_OFF == FSwitchFlag) /*δ򲻼״̬*/ + { + reResult = CI_SUCCESS; + } + else if (FUNC_SWITCH_ON == FSwitchFlag) + { + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult =LogicSecRelSwitchFLockCheck(wLogicSecId, &devId, &devState, &cYLockAlarmFlag); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·δ*/ + devId = 0u; + devState = 0u; + cYLockAlarmFlag = FLAG_UNSET; + checkResult =LogicSecRltvPrtctSwFLockCheck (wLogicSecId, &devId, &devState, &cYLockAlarmFlag); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + } + else + { + reResult = CI_ERROR; + } + + + if (CI_SUCCESS == reResult) + { + + /*·еλȷ*/ + devId = 0u; + devState = 0u; + checkResult =LogicSecRelativeSwitchPosCheck (wLogicSecId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + else + { + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·λȷ*/ + devId = 0u; + devState = 0u; + checkResult = LogicSecRltvPrtctSwPosCheck(wLogicSecId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·ա򡾵ҷա*/ + devId = 0u; + devState = 0u; + checkResult =LogicSecRltvPrtctSwLockCheck(wLogicSecId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_LOCK_STATUS, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*߼β*/ + devId = 0u; + devState = 0u; + checkResult = LogicSecSwitchLtrlDfncCheck(wLogicSecId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + if (CI_SUCCESS == reResult) + { + /*߼ߵ*/ + devId = 0u; + devState = 0u; + checkResult = LogicContactLineDevCheck(wLogicSecId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + + +/* +* ߼Դ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogicSecResSectionCheck(UINT16 wLogicSecId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 cLocalWorkMode = RC_WORK_MODE_CI; /*ģʽ*/ + UINT16 wLogSecRelPhySecId = 0U; /*߼ι*/ + + devId = 0u; + devState = 0u; + + /* ߼μ */ +#if 0 + /* ߼δ */ + checkResult = LogicSecFLockCheck(wLogicSecId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } +#endif + + /*߼ */ + devId = 0u; + devState = 0u; + cLocalWorkMode = GetLocalRcWorkMode(); + if (RC_WORK_MODE_TIOC == cLocalWorkMode) + { + checkResult = LogicIntruSecVainCheck(wLogicSecId, &devId, &devState); /*RCģʽ߼Ƿ*/ + } + else + { + wLogSecRelPhySecId = GetLgcSecRelativePhySecId(wLogicSecId); + checkResult = PhysicalIntruSecVainCheck(wLogSecRelPhySecId); /*CIģʽ߼ιǷ*/ + } + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + + /*·һ߼εһ߼ռ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogicNextLogSecLockCheck(wLogicSecId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*߼CBTCԼ*/ + if (CI_SUCCESS == reResult) + { + devId = wLogicSecId; + devState = 0U; + checkResult = CheckLogSecCbtcProperty(wLogicSecId, &devState); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_CBTC_PROPERTY, devState, sendLevel); + reResult = CI_ERROR; + } + } + +#if 0 + /* ߼ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogicSecJumpLockCheck(wLogicSecId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_JUMP_LOCK, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ؽ */ + return reResult; +} + +/* +* ߼·߼Դ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT16 wLogicSecId, ߼ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteLogicSecResSectionCheck(UINT16 wLogicSecId, UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + + devId = 0u; + devState = 0u; + + + /* ߼μ */ +#if 0 + /* ߼δ */ + checkResult = LogicSecFLockCheck(wLogicSecId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } +#endif + + + /*߼ */ + + devId = 0u; + devState = 0u; + checkResult = LogicIntruSecVainCheck(wLogicSecId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·һ߼εһ߼ռ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteNextLogSecLockCheck(wLogicSecId, wLogRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ؽ */ + return reResult; +} +/* +* ߼ԴԼ +* ˵ UINT16 const wLogicSecId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOGIC_RES_APP_CHECK +*/ +UINT8 LogicSecResApplicabilityCheck(UINT16 const wLogicSecId) +{ + /**/ + UINT8 const functionId = EFUNC_LOGIC_RES_APP_CHECK; + + /* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 routeId = 0U; + UINT8 devState = 0u; /*豸״̬*/ + UINT8 sendLevel = 0u; /*Ϸͼ*/ + + /* ߼· */ + routeId = GetLogSecLockBelongRoute(wLogicSecId); + /*ݶATS*/ + sendLevel = ESEND_LEVEL_ZERO; + + /* ߼ */ + reResult = CheckRouteStateNotYinDaoLock(routeId); + if (CI_SUCCESS == reResult) + { + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if ((ROUTE_TYPE_LIECHE == devState) + ||(ROUTE_TYPE_RETURN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (RES_CHECK_STATE_WAITE == checkResult) + { + checkResult = TrainRelateLogSecCheck(wLogicSecId, routeId); + if (CI_SUCCESS == checkResult) + { + /* г߼αղ̵ڼͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult =LogicSecResSectionCheck (wLogicSecId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = LogicSecResSwitchCheck(wLogicSecId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = FloodGateCheck(wLogicSecId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + return reResult; +} + +/* +* ߼·߼ԴԼ +* ˵ UINT16 const wLogicSecId ߼ID +* UINT16 const wLogRouteId ߼·ID +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOGROUTE_LOGIC_RES_APP_CHECK +*/ +UINT8 LogRouteLogSecResAppCheck(UINT16 const wLogicSecId,UINT16 const wLogRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_LOGROUTE_LOGIC_RES_APP_CHECK; + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 sendLevel = 0u; /*Ϸͼ*/ + + /*ݶATS*/ + sendLevel = ESEND_LEVEL_ZERO; + + /* */ + + checkResult = LogRouteLogicSecResSectionCheck(wLogicSecId, wLogRouteId,functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = LogicSecResSwitchCheck(wLogicSecId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = FloodGateCheck(wLogicSecId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + return reResult; +} + +/* +* ߼β +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* +*/ +UINT8 LogicSecSwitchLtrlDfncCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ֲʼ */ + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT16 chDevId = 0U; + UINT8 chDevState = 0U; + UINT16 wSwitchRltvPhySecId = 0U; + UINT8 chCheckSum = 0U; + UINT16 wLtrlDfncSwSum = 0U; + LogsecSwitchStruct* pProtectSwIdBuf = NULL; + UINT8 chPhySecUtOrCtOccState = 0U; + UINT8 chPhySecLockDir = 0U; + UINT8 chSwitchCurPos = 0U; + UINT8 *pSwitchLtrlDfncLockDir = NULL; + UINT16 wLgcLockBelongRutId = 0U; + UINT16 wRutIncProSwFlag = CI_ERROR; + UINT8 chPhySecMerOccState = 0U; + LogsecSwitchStruct *pstLtrlDfncSwitch = NULL; + UINT8 cLogSecLockFlag = CI_ERROR; /*߼ձ־*/ + + wLtrlDfncSwSum = GetLgcSecLtrlDfncSwSum(wLgcId); + pstLtrlDfncSwitch =GetLgcSecLtrlDfncSwStru (wLgcId); + pSwitchLtrlDfncLockDir = GetLgcSecLtrlDfncLockDir(wLgcId); + if ((NULL != pDevId) + && (NULL != pDevState) + && (NULL != pstLtrlDfncSwitch) + &&(NULL!= pSwitchLtrlDfncLockDir) + && (LOGSEC_LTRL_DFNC_SUM_MAX>wLtrlDfncSwSum)) + { + chRetVal = CI_SUCCESS; + for (ii = 0U; ii < wLtrlDfncSwSum; ii++) + { + /*ȡ*/ + wSwitchRltvPhySecId =GetSwitchPhySectionId(pstLtrlDfncSwitch[ii].SwitchId); + /*ȡǰλ*/ + chSwitchCurPos = GetSwitchCurPosition(pstLtrlDfncSwitch[ii].SwitchId); + /*ȡշ*/ + chPhySecLockDir = GetPhySecLockDirection(wSwitchRltvPhySecId); + cLogSecLockFlag = CheckPSecIncLSecLogicLockState(wSwitchRltvPhySecId, pDevId, pDevState); + if (CI_ERROR != wSwitchRltvPhySecId) + { + /*Ϸ*/ + chPhySecMerOccState = GetPhySecCurMergeState(wSwitchRltvPhySecId); + chPhySecUtOrCtOccState = GetPhySecUtOrCtOccuState(wSwitchRltvPhySecId); + if (SECTION_OCCUPY_NO != chPhySecMerOccState) + { + /*ں״̬Ϊռ*/ + if ((pstLtrlDfncSwitch[ii].SwitchPosition == chSwitchCurPos) + &&((SWITCH_POSITION_DINGWEI==pstLtrlDfncSwitch[ii].SwitchPosition) + ||(SWITCH_POSITION_FANWEI == pstLtrlDfncSwitch[ii].SwitchPosition))) + { + ; /*λã*/ + } + else + { + if (LOGICSECTION_OCCUPY_CT == chPhySecUtOrCtOccState) + { + /*CTռѹշǷ*/ + if ((pSwitchLtrlDfncLockDir[ii] != chPhySecLockDir) + && ((CI_SYSTEM_DIRECTION_UP == chPhySecLockDir) || (CI_SYSTEM_DIRECTION_DOWN == chPhySecLockDir)) + && ((CI_SYSTEM_DIRECTION_UP == pSwitchLtrlDfncLockDir[ii]) || (CI_SYSTEM_DIRECTION_DOWN == pSwitchLtrlDfncLockDir[ii])) + && (CI_SUCCESS == cLogSecLockFlag)) + { + ; /*շΪӽ߼߼*/ + } + else + { + chRetVal = CI_ERROR; /*շǽӽ߼·գʧ*/ + } + } + else + { + chRetVal = CI_ERROR; /*CTռѹʧ*/ + } + } + } + } + else + { + /* */ + chRetVal = CI_ERROR; + } + if (CI_ERROR == chRetVal) + { + *pDevId = wSwitchRltvPhySecId; + *pDevState = chPhySecUtOrCtOccState; + break; + } + else + { + /*ִ*/ + } + } + + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} +/* +* ο߼ +* ˵ UINT16 const overlapId ID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +*/ +UINT8 OverlapUsableCheck(UINT16 const wOverlapId) +{ + UINT8 const functionId = EFUNC_OVERLAP_RES_APP_CHECK; + UINT8 sendLevel = ESEND_LEVEL_ZERO; + UINT8 cErrStep = 0U; + UINT8 cRetVal = CI_ERROR; /*ֵ*/ + UINT8 overlapPhySecSum = 0u;/*ΰĿ*/ + UINT16 *overlapContainPhySecIdBuf = NULL;/*ΰ*/ + UINT8 ii = 0u; + UINT16 overlapbelongRtId = 0u;/*α·*/ + UINT16 rtOverlapLockedId = 0u;/*·ʵյı*/ + UINT8 checkResult = CI_ERROR;/**/ + UINT16 tempDevId = 0u;/*豸IDʱCheckҪijڲ*/ + UINT8 tempDevSta = 0u;/*豸״̬ʱCheckҪijڲ*/ + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + UINT8 jj = 0u; + + overlapPhySecSum = GetOverlapPhySecSum(wOverlapId); + overlapContainPhySecIdBuf = GetOverlapPhySecIdBuf(wOverlapId); + for (ii = 0u; ii < overlapPhySecSum; ii++) + {/*ΰΣҷ·ID*/ + overlapbelongRtId = GetPhySecPLockBelongRouteId(overlapContainPhySecIdBuf[ii]); + if (0u != overlapbelongRtId) + {/*ҳɹ*/ + cRetVal = CI_SUCCESS; + break; + } + } + if (CI_SUCCESS == cRetVal) + { + overlapSum = GetRouteOverlapSum(overlapbelongRtId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(overlapbelongRtId); /*ȡOverlap ID BUF*/ + } + + if ((NULL != overlapIdBuf) + &&(0UoverlapSum)) + { + for (jj = 0u; jj < overlapSum; jj++) + { /*·ıյıһ£ͱλ򲻷 + ֹ·ͬһαϢʵûյĽ·ıҲͱλ20190109*/ + rtOverlapLockedId = GetRouteOverlapLockedId(overlapbelongRtId);/*ȡ·ʵյıID*/ + + if ((overlapIdBuf[jj] == rtOverlapLockedId) && (wOverlapId == overlapIdBuf[jj])) + { + /*νλЧԼ*/ + checkResult = OverlapValidMaskCheck(rtOverlapLockedId); + + if (CI_SUCCESS == checkResult) + { + cRetVal = CI_SUCCESS; + } + else + { + cErrStep = 1U; + cRetVal = CI_ERROR; + } + + /*źŻЧ*/ + if (CI_SUCCESS == cRetVal) + { + checkResult = SignalOverlapValidCheck(overlapbelongRtId, &tempDevId, &tempDevSta); + + if (CI_SUCCESS == checkResult) + { + cRetVal = CI_SUCCESS; + } + else + { + cErrStep = 2U; + cRetVal = CI_ERROR; + } + } + else + { + cRetVal = CI_ERROR; + } + + /*鱣εCBTC*/ + if (CI_SUCCESS == cRetVal) + { + checkResult = CheckOverlapCbtcProperty(wOverlapId); + if (CI_SUCCESS == checkResult) + { + cRetVal = CI_SUCCESS; /**/ + } + else + { + cErrStep = 3U; + cRetVal = CI_ERROR; /*߼βCBTCԣֹͣʧ*/ + } + } + else + { + cRetVal = CI_ERROR; + } + + /*鱣βǷ*/ + if (CI_SUCCESS == cRetVal) + { + checkResult = OverlapLateralDfnCheck(wOverlapId, &tempDevId, &tempDevSta); + + if (CI_SUCCESS == checkResult) + { + cRetVal = CI_SUCCESS; + } + else + { + cErrStep = 4U; + cRetVal = CI_ERROR; + } + } + else + { + cRetVal = CI_ERROR; + } + + if (CI_SUCCESS != cRetVal) + { + SetErrorData(functionId, CI_DEVICE_TYPE_OVERLAP, wOverlapId, ETYPE_OVERLAP_RES_CHECK_FAIL, cErrStep, sendLevel); /*¼ʧԭ*/ + } + + break; + } + else + { + cRetVal = CI_ERROR; + } + } + } + else + { + cRetVal = CI_ERROR; + } + + return cRetVal; +} + +/* +* ·VBTCµһ߼μ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +*/ +UINT8 RouteCbtcFirstLgcSecCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 chRetVal = CI_ERROR; + UINT8 chFunRet = CI_ERROR; + /* ·豸 */ + /*źŻ*/ + UINT16 startSignalId = 0u; + UINT16 wOutFirstSecId = 0U; + UINT8 chOutFirstOccState = 0U; + UINT16 wInFirstSecId = 0U; + UINT16 wTrainId = 0U; + UINT8 chTrainEnterState = 0U; + UINT8 chTrainInfoSum = 0U; + UINT8 chReadyEnterRouteTrainSum = 0U; + UINT16 wszReadyEtRouteTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + UINT8 chLogSecOccupyState = 0U;/*߼ռ״̬*/ + + + if ((NULL != pDevId) && (NULL != pDevState)) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + /* ߼ */ + + + /* ·ʼźŻδѹ ǣ·ⷽΡСڷһ߼Ρռá*/ + if (CI_SUCCESS == chRetVal) + { + + /* ͨ CBTC·ڵһ߼жгԴʱź*/ + chFunRet = GetRouteInOutFstLgcTrainInfo(routeId, &chReadyEnterRouteTrainSum, wszReadyEtRouteTrainId); + startSignalId = GetRouteStartSignalId(routeId); + wOutFirstSecId = GetSignalOutFirstPhySecId(startSignalId); + chOutFirstOccState = GetPhySecCurMergeState(wOutFirstSecId); + wInFirstSecId = GetRouteInFirstLogSecId(routeId); + devState = GetLogSecCurOccupyState(wInFirstSecId); /*ںռѹ״̬*/ + chLogSecOccupyState = GetLogSecCurCtOrUtOccupyState(wInFirstSecId); /*ռѹ״̬ںϺжCTUTռѹ*/ + + if (CI_SUCCESS == chFunRet) + { + if (1U < chReadyEnterRouteTrainSum) + { + chRetVal = CI_SUCCESS; + } + else if (1U == chReadyEnterRouteTrainSum) + { + chTrainEnterState = dsuTrainMinHeadCrossSignal(wszReadyEtRouteTrainId[0], routeId); + if ((TRAIN_ENTER_ROUTE_FULL == chTrainEnterState) || (TRAIN_ENTER_ROUTE_TAIL == chTrainEnterState)) + { + /*гȫʻ·/̳ٳͷʻ·βڽ·ص by cgh 20250102*/ + chRetVal = CI_ERROR; + } + else if (TRAIN_ENTER_ROUTE_HEAD == chTrainEnterState) + { + /*гʻ·δѹźŻص */ + chRetVal = CI_SUCCESS; + } + else if (TRAIN_ENTER_ROUTE_CROSS == chTrainEnterState) + { + /*гѹźŻжϵһ߼ռѹ״̬*/ + + if (SECTION_OCCUPY_NO == devState) + {/*һ߼ں״̬δռѹصƣȴռѹ */ + chRetVal = CI_SUCCESS; + } + else + {/*һ߼ں״̬ռѹ ص*/ + chRetVal = CI_ERROR; + } + + } + else if((TRAIN_ENTER_ROUTE_NO == chTrainEnterState) + || (CI_ERROR == chTrainEnterState)) + { + /*гδߣгδѹص*/ + chRetVal = CI_SUCCESS; + } + else + { + + chRetVal = CI_ERROR; + } + } + else + { + if ((!((SECTION_OCCUPY_YES != chOutFirstOccState) && (SECTION_OCCUPY_NO!=devState)))) + { + /*гȫʻ·*/ + if (LOGICSECTION_OCCUPY_UT == chLogSecOccupyState) + { + /*CBTC·жڷһ߼зͨųռѹʱص by cgh 20231101*/ + chRetVal = CI_ERROR; + } + else + { + /* ͨ */ + ; + } + } + else + { + chRetVal = CI_ERROR; + } + } + + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + } + else + { + *pDevId = wInFirstSecId; + *pDevState = devState; + } + } + + /* δ⵽ */ + return chRetVal; +} + + + +/* +* ۷·VBTCµһ߼μ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +*/ +UINT8 RouteCbtcReturnFirstLgcSecCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* */ + UINT16 wLgcSecId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 chRetVal = CI_ERROR; + UINT8 chFunRet = CI_ERROR; + /* ·豸 */ + /*źŻ*/ + UINT16 startSignalId = 0u; + UINT16 wOutFirstSecId = 0U; + UINT8 chOutFirstOccState = 0U; + UINT16 wInFirstSecId = 0U; + UINT16 wTrainId = 0U; + UINT8 chTrainEnterState = 0U; + UINT8 chTrainInfoSum = 0U; + UINT8 chReadyEnterRouteTrainSum = 0U; + UINT16 wszReadyEtRouteTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + UINT16 wCrossTrainId = 0u; + UINT8 chGroupRelate = 0u; + + if ((NULL != pDevId) && (NULL != pDevState)) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + /* ߼ */ + + + /* ·ʼźŻδѹ ǣ·ⷽΡСڷһ߼Ρռá*/ + if (CI_SUCCESS == chRetVal) + { + startSignalId = GetRouteStartSignalId(routeId); + wOutFirstSecId = GetSignalOutFirstPhySecId(startSignalId); + chOutFirstOccState = GetPhySecCurMergeState(wOutFirstSecId); + wInFirstSecId = GetRouteInFirstLogSecId(routeId); + devState = GetLogSecCurOccupyState(wInFirstSecId); + /* ͨ CBTC·ڵһ߼жгԴʱDZ۷ź*/ + chFunRet = GetRouteInOutFstLgcTrainInfo(routeId, &chReadyEnterRouteTrainSum, wszReadyEtRouteTrainId); + if (CI_SUCCESS == chFunRet) + { + if (2U < chReadyEnterRouteTrainSum) + { + /*۷Դ2 ,ʧ*/ + chRetVal = CI_ERROR; + + } + else if (1U == chReadyEnterRouteTrainSum) + { + wCrossTrainId = wszReadyEtRouteTrainId[0]; + chRetVal = CI_SUCCESS; + } + else if (2U == chReadyEnterRouteTrainSum) + { + /*۷󳵲Źź*/ + chRetVal = isTwoGroupRunTrain(wszReadyEtRouteTrainId[0], wszReadyEtRouteTrainId[1]); + if (CI_SUCCESS == chRetVal) + { + chGroupRelate = GetGroupTrainRelation(wszReadyEtRouteTrainId[0]); + if (VOBC_CI_GROUP_TAIL == chGroupRelate) + { + wCrossTrainId = wszReadyEtRouteTrainId[0]; + } + else + { + wCrossTrainId = wszReadyEtRouteTrainId[1]; + } + } + else + { + /*DZ۷ź*/ + chRetVal = CI_ERROR; + } + } + else + { + if ((!((SECTION_OCCUPY_YES != chOutFirstOccState) && (SECTION_OCCUPY_NO != devState)))) + { + /* ͨ */ + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + + /*ѹ֮ź*/ + if ((CI_SUCCESS == chRetVal)&&(0u != wCrossTrainId)) + { + chTrainEnterState = dsuTrainMinHeadCrossSignal(wCrossTrainId, routeId); + if ((TRAIN_ENTER_ROUTE_FULL == chTrainEnterState) + || (TRAIN_ENTER_ROUTE_TAIL == chTrainEnterState)) + { + /*۷·гȫʻ·ͷʻ·ص by cgh 20231215*/ + chRetVal = CI_ERROR; + } + else if (TRAIN_ENTER_ROUTE_HEAD == chTrainEnterState) + { + /*гʻ·δѹźŻص */ + chRetVal = CI_SUCCESS; + } + else if (TRAIN_ENTER_ROUTE_CROSS == chTrainEnterState) + { + /*гѹźŻжϵһ߼ռѹ״̬*/ + + if (SECTION_OCCUPY_NO == devState) + {/*һ߼ں״̬δռѹصƣȴռѹ */ + chRetVal = CI_SUCCESS; + } + else + {/*һ߼ں״̬ռѹ ص*/ + chRetVal = CI_ERROR; + } + } + else if ((TRAIN_ENTER_ROUTE_NO == chTrainEnterState) || (CI_ERROR == chTrainEnterState)) + { + /*гδߣгδѹ*/ + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + } + else + { + *pDevId = wInFirstSecId; + *pDevState = devState; + } + + } + else + { + ; /*ִʧ*/ + } + + + /* δ⵽ */ + return chRetVal; +} + +/* +* ·ȫɼм +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllSecColOccuClearCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ·*/ + UINT8 const checkSum = GetRoutePhysicalSectionSum(routeId); + RoutePhysicalSectionStruct* const dataIdBuf = GetRouteSectionData(routeId); + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + + if ((NULL == pDevId) || (NULL == pDevState)) + { + /*δ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + {/* ռü */ + if (0u == checkSum) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i].PhysicalSectionId; + devState =GetPhySecCurOccupyState(devId); + + if (SECTION_OCCUPY_NO == devState) + { + /* ͨ*/ + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + break; + } + } + } + + } + else + { + } + /*ȫͨ*/ + return reVal; +} + +/* +* ·ȫɼм +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteFaultOccuCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ·*/ + UINT8 const checkSum = GetRoutePhysicalSectionSum(routeId); + RoutePhysicalSectionStruct* const dataIdBuf = GetRouteSectionData(routeId); + UINT16 wOutFirstPhySecId = 0U; + UINT8 chTrainNum = 0U; + UINT16 szTrianId[TRAIN_SUM_MAX] = { 0U }; + UINT16 wTrainId = 0U; + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + UINT8 chFuncRet = CI_ERROR; + UINT8 chAllClearFlag = CI_ERROR; + + if ((NULL == pDevId) || (NULL == pDevState)) + { + /*δ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + {/* ռü */ + if (0u == checkSum) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i].PhysicalSectionId; + devState = IsPhyFree(devId); + chTrainNum = ToaGetPhyUtNum(devId); + chFuncRet = ToaGetPhyUtId(devId,szTrianId); + if (CI_SUCCESS == devState) + { + chAllClearFlag = CI_SUCCESS;/* ͨ*/ + } + else + { + if (CI_SUCCESS == chFuncRet) + { + /*ֻһϳ*/ + if (1U == chTrainNum) + { + + if (0U == wTrainId) + { + /*ǰ¼ϳIDΪ0*/ + wTrainId = szTrianId[0]; + } + else if((szTrianId[0]== wTrainId)&&(255U!=wTrainId)) + { + /*·ڷһϳ*/ + } + else + { + + reVal = CI_ERROR; + } + } + else + { + + reVal = CI_ERROR; + } + } + else + {/*״̬һ·ع״̬*/ + + reVal = CI_ERROR; + } + + } + + if ((CI_SUCCESS == chAllClearFlag)&&(0U!=chTrainNum)) + { + reVal = CI_ERROR; + } + + if (CI_ERROR == reVal) + { + *pDevId = devId; + *pDevState = devState; + break; + } + } + } + } + + if (CI_SUCCESS == reVal) + { + if (1U == chTrainNum) + { + devId = GetSignalOutFirstPhySecId(GetRouteStartSignalId(routeId)); + devState = IsPhyFree(devId); + chTrainNum = ToaGetPhyUtNum(devId); + chFuncRet = ToaGetPhyUtId(devId, szTrianId); + if ((TRAIN_SUM_MAX > chTrainNum) + && (CI_SUCCESS == chFuncRet) + && (CI_ERROR == devState)) + { + for (i = 0u; i < chTrainNum; i++) + { + if ((szTrianId[i] == wTrainId)) + { + break; + } + } + + if (i == chTrainNum) + { + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + } + else + { + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + } + else + { + /*޹ϳ ȫ*/ + } + } + /*ȫͨ*/ + return reVal; +} + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllLgcSecXianSuCheck(UINT16 const routeId,UINT16 *pDevId, UINT8 *pDevState) +{ + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT8 j = 0U; + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 secDirction = 0u; + UINT8 chRouteXianSuCfmState = 0U; + /*·*/ + /* ·*/ + UINT16 const routeSectionSum = GetRouteLogSectionSum(routeId); + UINT16* const pRouteSectionDataBuf = GetRouteLogSectionIdBuf(routeId); + UINT16 const overlapId = GetRouteOverlapLockedId(routeId); + UINT8 const routeOvlapSectionSum =GetOverlapLogicSectionSum (overlapId); + UINT16* const pRouteOvlapSectionDataBuf =GetOverlapLogicSectionBuf (overlapId); + UINT8 wRouteRelSwitchNum = 0U; /*·ĵ*/ + RouteSwitchStruct* pRouteRelSwitchStr = NULL; /*·ĵṹ*/ + UINT16 wRouteRelSwitchId = 0U; /*·ĵID*/ + UINT8 wOvlpRelSwitchNum = 0U; /*ιĵ*/ + OverlapConditionSwitchStruct* pOvlpRelSwitchStr = NULL; /*ιĵṹ*/ + UINT16 wOvlpRelSwitchId = 0U; /*ιĵID*/ + UINT8 reVal = CI_ERROR; + + /* ݼ */ + if ((MAX_ROUTE_IN_LT_NUM <= routeSectionSum) + || (NULL == pRouteSectionDataBuf) + ||(OVLP_LOGICSECTION_SUM_MAX <= routeOvlapSectionSum) + || ((0U!=routeOvlapSectionSum) + &&(NULL==pRouteOvlapSectionDataBuf))) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + chRouteXianSuCfmState =GetRouteXiansuConfirmStt (routeId); + if (ROUTE_XIANSU_CONFIRM_YES == chRouteXianSuCfmState) + { + reVal = CI_SUCCESS; + } + else + { + for (i = 0u; i < routeSectionSum; i++) + { + devId = pRouteSectionDataBuf[i]; + devState = GetLogSecLinShiXianSuSetState(devId); + /*ʼ*/ + /* 鱾 */ + if ((LOGSEC_LSXS_SET_STATE_NO == devState) + || (LOGSEC_LSXS_SET_STATE_INVALID == devState)) + { + reVal = CI_SUCCESS; + + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + + if (CI_ERROR == reVal) + { + break; + } + } + + /*·ڵ߼ʱ״̬*/ + wRouteRelSwitchNum = GetRouteSwitchSum(routeId); + pRouteRelSwitchStr = GetRouteSwitchData(routeId); + if ((CI_SUCCESS == reVal) && (0U != wRouteRelSwitchNum) && (ROUTE_SWITCH_SUM_MAX > wRouteRelSwitchNum) && (NULL != pRouteRelSwitchStr)) + { + for (j = 0U; j < wRouteRelSwitchNum; j++) + { + devId = 0U; + devState = 0U; + wRouteRelSwitchId = pRouteRelSwitchStr[j].SwitchId; + reVal = SwitchRelLogSecLSXSStateCheck(wRouteRelSwitchId, &devId, &devState); + + if (CI_ERROR == reVal) + { + /*߼ʱ٣ʧ*/ + *pDevId = devId; + *pDevState = devState; + break; + } + else + { + /**/ + } + } + } + else + { + /**/ + } + + if (CI_SUCCESS == reVal) + { + for (i = 0u; i < routeOvlapSectionSum; i++) + { + devId = pRouteOvlapSectionDataBuf[i]; + devState = GetLogSecLinShiXianSuSetState(devId); + /*ʼ*/ + /* 鱾 */ + if ((LOGSEC_LSXS_SET_STATE_NO == devState) + || (LOGSEC_LSXS_SET_STATE_INVALID == devState)) + { + reVal = CI_SUCCESS; + + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + + if (CI_ERROR == reVal) + { + break; + } + } + } + + /*ڵ߼ʱ״̬*/ + wOvlpRelSwitchNum = GetOverlapSwitchSum(overlapId); + pOvlpRelSwitchStr = GetOverlapCondSwitchStruct(overlapId); + if ((CI_SUCCESS == reVal) && (0U != wOvlpRelSwitchNum) && (OVERLAP_CONDISWIT_SUM_MAX > wOvlpRelSwitchNum) && (NULL != pOvlpRelSwitchStr)) + { + for (j = 0U; j < wOvlpRelSwitchNum; j++) + { + devId = 0U; + devState = 0U; + wOvlpRelSwitchId = pOvlpRelSwitchStr[j].SwitchId; + reVal = SwitchRelLogSecLSXSStateCheck(wOvlpRelSwitchId, &devId, &devState); + + if (CI_ERROR == reVal) + { + /*߼ʱ٣ʧ*/ + *pDevId = devId; + *pDevState = devState; + break; + } + else + { + /**/ + } + } + } + else + { + /**/ + } + } + } + + return reVal; + +} + +/* +* Overlapοм +* ˵ UINT16 const overlapId +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlockOvlpAllSecOccuClrCheck(UINT16 const overlapId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* overlap */ + UINT8 const checkSum = GetOverlapPhySecSum(overlapId); + UINT16* const dataIdBuf = GetOverlapPhySecIdBuf(overlapId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_SUCCESS; + UINT8 chSwitch = 0u; + UINT16 wRouteId = 0u; + UINT16 wFirstPhyId = 0u; + UINT8 chPTrainNum = 0u; + UINT16 szPTrainId[MAX_AC_IN_TRAIN]; + UINT8 chFTrainNum = 0u; + UINT16 szFTrainId[MAX_AC_IN_TRAIN]; + UINT8 chOccState = SECTION_OCCUPY_YES; + + chSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH); + + /* ռü */ + /**/ + if (0u == checkSum) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i]; + devState = GetPhySecCurMergeState(devId); + if (SECTION_OCCUPY_NO==devState) + { + /* ͨ*/ + + } + else + { + if (FUNC_SWITCH_ON == chSwitch) + { + chOccState = GetPhySecCurOccupyState(devId); + wRouteId = GetPhySecPLockBelongRouteId(devId); + wFirstPhyId = GetRouteFirstPhySectionId(wRouteId); + chFTrainNum = ToaGetPhyTrain(wFirstPhyId, szFTrainId); + chPTrainNum = ToaGetPhyTrain(devId, szPTrainId); + if ((1u == chFTrainNum) && (1u == chPTrainNum) && (szPTrainId[0] == szFTrainId[0]) && (SECTION_OCCUPY_NO == chOccState)) + { + ; + } + else + { + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + break; + } + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + break; + } + } + } + } + + /*ȫͨ*/ + return reVal; + +} + +/* +* źſʱ·οм +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +*/ +UINT8 KeepCbtcReturnRouteSecOccCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 checkResult = CI_ERROR; + UINT8 reResult = CI_ERROR; + UINT16 wRouteFirstPhySecId = 0u; /*·һ*/ + UINT8 chTrainEnterState = CI_ERROR; /*гʻ·״̬*/ + UINT8 axisSecSum = 0u; + UINT16* pAxisSecIdBuf = NULL; + UINT8 logSectionSum = 0u; + UINT16* logIdBuf = NULL; + UINT8 cLogSecLinkSum = 0u; /*߼ΰLink*/ + UINT16* cLogSecLinkBuf = NULL; + UINT8 logCurOccupyState = 0u; /*߼ռ״̬*/ + UINT8 cRouteDir = 0U; /*·*/ + UINT8 cLinkLogicDir = 0U; /*߼*/ + UINT16 wLogId = 0u; + UINT8 i = 0u; + UINT8 j = 0u; + UINT8 index = 0u; + TRAIN_SEQUANCE_s tmpTrainInfo = { 0u }; + UINT8 chTrainNum = 0U; + UINT16 wRouteTrainId = 0U; + UINT8 SetLogicErrorFlag = 0U; + UINT8 ChangeDirFlag = 0U; /*ķ־*/ + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + wRouteFirstPhySecId = GetRouteFirstPhySectionId(routeId); + chTrainEnterState = GetTrainEnteringRouteState(routeId); + if ((devId == wRouteFirstPhySecId) && (CI_SUCCESS == chTrainEnterState)) + { + checkResult = RouteCbtcReturnFirstLgcSecCheck(routeId, &devId, &devState); + /*CBTC۷·гʻʱѹϢδ,ʱź*/ + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + SetLogicErrorFlag = 1U; + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + +#if 0 + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, wRouteFirstPhySecId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); +#endif + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /*DZǰռѹ򲻹ź*/ + axisSecSum = GetPAxisSectionSum(devId); + pAxisSecIdBuf = GetPAxisSectionIdBuf(devId); + + if ((NULL != pAxisSecIdBuf) + &&(PHYSICAL_INCLUDE_AXIS_SUM_MAX>axisSecSum)) + { + for (i = 0u; i < axisSecSum; i++) + { + logSectionSum = GetAxisSecLogSectionSum(pAxisSecIdBuf[i]); + logIdBuf = GetAxisSecLogSectionIdBuf(pAxisSecIdBuf[i]); + if ((NULL != logIdBuf) + &&(AXIS_INCLUDE_LOG_SUM_MAX>logSectionSum)) + { + for (j = 0u; j < logSectionSum; j++) + { + wLogId = logIdBuf[j]; + logCurOccupyState = GetLogSecCurCtOrUtOccupyState(wLogId); + if (LOGICSECTION_OCCUPY_CT == logCurOccupyState) + { + checkResult = IsLogicHaveNoSupicTrain(wLogId); + if (CI_SUCCESS == checkResult) + { + /*CTռѹҲس*/ + break; + } + else + { + /* */ + } + } + else + { + /* */ + } + + } + + if (j != logSectionSum) + { + break; + } + else + { + /* */ + } + } + else + { + /* ݳ*/ + } + } + + if (i != axisSecSum) + { + cRouteDir = GetRouteDirection(routeId); + cLinkLogicDir = ConvertDirectionToLogic(cRouteDir); /*תӪΪ߼*/ + ChangeDirFlag = GetLogSecLockDirOpposedFlag(wLogId); + if (CI_SUCCESS == ChangeDirFlag) /*Ҫȡ*/ + { + cLinkLogicDir = ConvertTrainDir(cLinkLogicDir); + } + else + { + ; /*ȡ*/ + } + cLogSecLinkSum = GetSecIntrudeLinkSum(wLogId); + cLogSecLinkBuf = GetSecIntrudeLinkIdBuf(wLogId); + if ((NULL != cLogSecLinkBuf)&& + (LOGSEC_INCLUDE_LINK_SUM_MAX > cLogSecLinkSum)) + {/*߼ռѹĵһ*/ + for (index = 0u; index < cLogSecLinkSum; index++) + { + if (DIR_SAME == cLinkLogicDir) + { + chTrainNum = as_GetLinkTrainNum(cLogSecLinkBuf[index]); + tmpTrainInfo = as_GetLinkFirstTrain(cLogSecLinkBuf[index]); + } + else + { + chTrainNum = as_GetLinkTrainNum(cLogSecLinkBuf[index]); + tmpTrainInfo = as_GetLinkLastTrain(cLogSecLinkBuf[index]); + } + + if (0u != chTrainNum) + { + wRouteTrainId = tmpTrainInfo.u16TrainID; + break; + } + } + + /*߼CTռѹǷΪǰ*/ + checkResult = isGroupHeadTrain(wRouteTrainId); + + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS;/*ǰռѹź*/ + } + else + { + reResult = CI_ERROR;/*DZǰռѹ*/ + } + } + else + { + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR;/*CTռѹǰɸɵCTռѹ*/ + } + } + else + { + reResult = CI_ERROR;/*ݳ*/ + } + + + + } + + } + + if (CI_SUCCESS == reResult) + { + /* ź*/ + } + else + { + if (0U == SetLogicErrorFlag) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + else + { + /*¼߼ι󣬲ټ¼ι*/ + } + /* ʧܷ */ + reResult = CI_ERROR; + } + return reResult; +} + +/* +* CBTC·гʻ(CBTCʹ) +* ˵ +* UINT16 const routeId, · +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ һг׼ʻ·½·ź +*/ +UINT8 RouteCbtcTiranEnterCheck(UINT16 const routeId) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 chFunRet = CI_ERROR; + UINT8 chRouteType = 0U; + UINT8 chTrainEnterState = 0U; + UINT8 chReadyEnterRouteTrainSum = 0U; + UINT16 wszReadyEtRouteTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + UINT16 wCrossTrainId = 0u; + UINT8 chGroupRelate = 0u; + UINT16 wInFirstSecId = 0U;/*·ڷһ*/ + UINT8 chLogSecCurOccupySta = 0U;/*߼ںռ״̬*/ + UINT16 wStartSignalId = 0U;/*ʼźŻID*/ + UINT16 wOutFirstPhySecId = 0U;/*ⷽһID*/ + UINT8 chOutFirstPhyOccState = 0U;/*ⷽһںռ״̬*/ + + /* ͨ CBTC·ڵһ߼жгԴʱDZ۷ź*/ + chFunRet = GetRouteInOutFstLgcTrainInfo(routeId, &chReadyEnterRouteTrainSum, wszReadyEtRouteTrainId); + if (CI_SUCCESS == chFunRet) + { + if (2U < chReadyEnterRouteTrainSum) + { + /*۷Դ2 ,ʧ*/ + chRetVal = CI_ERROR; + } + else if (1U == chReadyEnterRouteTrainSum) + { + wCrossTrainId = wszReadyEtRouteTrainId[0]; + chRetVal = CI_SUCCESS; + } + else if (2U == chReadyEnterRouteTrainSum) + { + chRouteType = GetRouteType(routeId); + /*۷󳵲Źź*/ + chRetVal = isTwoGroupRunTrain(wszReadyEtRouteTrainId[0], wszReadyEtRouteTrainId[1]); + if ((CI_SUCCESS == chRetVal) + &&(ROUTE_TYPE_RETURN == chRouteType)) + { + chGroupRelate = GetGroupTrainRelation(wszReadyEtRouteTrainId[0]); + if (VOBC_CI_GROUP_TAIL == chGroupRelate) + { + wCrossTrainId = wszReadyEtRouteTrainId[0]; + } + else + { + wCrossTrainId = wszReadyEtRouteTrainId[1]; + } + } + else + { + /*DZ۷ź*/ + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + /*ѹ֮ź*/ + if ((CI_SUCCESS == chRetVal) && (0u != wCrossTrainId)) + { + wInFirstSecId = GetRouteInFirstLogSecId(routeId); + chLogSecCurOccupySta = GetLogSecCurOccupyState(wInFirstSecId); + chTrainEnterState = dsuTrainMinHeadCrossSignal(wCrossTrainId, routeId); + + wStartSignalId = GetRouteStartSignalId(routeId); + wOutFirstPhySecId = GetSignalOutFirstPhySecId(wStartSignalId); + chOutFirstPhyOccState = GetPhySecCurMergeState(wOutFirstPhySecId); + + /*гѹźŻ*/ + if (TRAIN_ENTER_ROUTE_CROSS == chTrainEnterState) + { + if (SECTION_OCCUPY_NO == chOutFirstPhyOccState) + { + /*̳ٿѹⷽһѾУʱ쳣ص*/ + chRetVal = CI_ERROR; + } + else + { + if (SECTION_OCCUPY_NO != chLogSecCurOccupySta) + { + ; /*гѹźŻҵһ߼ռѹӽ by cgh 20231129*/ + } + else + { + /*гѹźŻҵһ߼οУӽ쳣 by cgh 20231129*/ + chRetVal = CI_ERROR; + } + } + } + else if ((TRAIN_ENTER_ROUTE_FULL == chTrainEnterState) || (TRAIN_ENTER_ROUTE_TAIL == chTrainEnterState)) + { + if (SECTION_OCCUPY_NO != chLogSecCurOccupySta) + { + ; /*̳гȫڽ·߳βʻһ߼ռѹӽ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + ; /* DO NOTHING*/ + } + else + { + chRetVal = CI_ERROR; + } + + /* δ⵽ */ + return chRetVal; +} + +/* +* ·ȫ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllLtrlDfncSwitchCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ·*/ + UINT16 const checkSum = GetRouteLogSectionSum(routeId); + UINT16* const dataIdBuf =GetRouteLogSectionIdBuf (routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + + /* ռü */ + if (0u == checkSum) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (i = 0u; i0:ռ״̬CTռorUTռor +*/ +UINT8 CheckRouteIdOutFirstLogSecState(const UINT16 routeId,UINT16 *logicSecId) +{ + UINT16 bufIndex = 0; /*±*/ + + UINT8 retVal = CI_ERROR; + UINT8 signalDirection = 0u; + UINT16 signalOutFirstPhySecId = 0u; + UINT16 * pAxisSectionIdBuf =NULL; + UINT8 axisSectionSum = 0u; + UINT8 i=0u; + UINT8 PhySecType = 0u; + UINT16* pLogSectionIdBuf =NULL; + UINT8 logSectionSum = 0u; + UINT8 startSigisEndSigRouteSum = 0u; + UINT16 *pStartSigisEndSigRouteIdBuf = NULL; + UINT16 routeStartSignalId = 0u; + UINT16 routeInLastLogSecId = 0u; + + if((0u < routeId)&&(NULL != logicSecId)) + { + *logicSecId = 0u; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + if(CI_SUCCESS == retVal) + { + startSigisEndSigRouteSum = GetRouteStartSigisEndRouteSum(routeId); + pStartSigisEndSigRouteIdBuf = GetRouteStartSigisEndRouteBuf(routeId); + if(NULL == pStartSigisEndSigRouteIdBuf) + { + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + if(0U == startSigisEndSigRouteSum) + {/*źŻ߼*/ + routeStartSignalId = GetRouteStartSignalId(routeId); + signalDirection = GetSignalDirection(routeStartSignalId); + signalOutFirstPhySecId = GetSignalOutFirstPhySecId(routeStartSignalId); + + if(0u < signalOutFirstPhySecId) + { + pAxisSectionIdBuf= GetPAxisSectionIdBuf(signalOutFirstPhySecId); + axisSectionSum = GetPAxisSectionSum(signalOutFirstPhySecId); + } + else + { + retVal = CI_ERROR; + } + + if(CI_SUCCESS == retVal) + { + if((NULL ==pAxisSectionIdBuf)||(0u == axisSectionSum)) + { + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + retVal = CI_ERROR; + PhySecType = GetPhySecType(signalOutFirstPhySecId); + if(PHYSICAL_SEC_TYPE_NOSWITCH ==PhySecType) + { + pLogSectionIdBuf = GetAxisSecLogSectionIdBuf(pAxisSectionIdBuf[0]); + logSectionSum = GetAxisSecLogSectionSum(pAxisSectionIdBuf[0]); + if((NULL != pLogSectionIdBuf)&&(0u < logSectionSum)) + { + if(LINK_DIRECTION == signalDirection) + { + retVal = GetLogSecCurCtOrUtOccupyState(pLogSectionIdBuf[0]); + *logicSecId = pLogSectionIdBuf[0];/*߼ID*/ + } + else if(NOT_LINK_DIRECTION == signalDirection) + { + retVal = GetLogSecCurCtOrUtOccupyState(pLogSectionIdBuf[logSectionSum-1U]); + *logicSecId =pLogSectionIdBuf[logSectionSum-1U];/*߼ID*/ + } + else + { + retVal = CI_ERROR;/*ش*/ + } + } + } + else + { + retVal = CI_ERROR;/*ش*/ + } + } + } + else + {/*Խ·߼*/ + for(i=0u;i bufIndex) + { + PhySecFlockType = GetPhySecFLockType(phySectionId); + if (PHY_SEC_FLOCK_TYPE_CMD == PhySecFlockType) + { + /*ATS򱨾Ӧ*/ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, phySectionId, ETYPE_PS_FLOCK_STATE, devState, sendLevel); + } + else if (PHY_SEC_FLOCK_TYPE_SPKS == PhySecFlockType) + {/*spksɵķ򱨾spks*/ + checkResult = CheckPhysecFlockReasonSpksId(phySectionId, &spksId, &spksState);/*ȡηǸspksµµ*/ + if (CI_SUCCESS == checkResult) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SPKS, spksId, ETYPE_SPKS_STATE_UP, spksState, sendLevel); + } + } + else if (PHY_SEC_FLOCK_TYPE_SPKSCMD == PhySecFlockType) + { + /*spks÷򱨾һαspksһαη + 豸״̬ãôʱ*/ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, phySectionId, ETYPE_PS_FLOCK_SPKSCMD_STATE, devState, sendLevel); + } + else + { + /**/ + } + } +} +/* +* CBTC·źűź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepCBTCRouteOtherSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0U; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + UINT8 needOpenSigSum = 0U; + UINT16* pNeedOpenBuf = NULL; + UINT8 oneOpenSigSum = 0U; + UINT16* pOneOpenBuf = NULL; + UINT8 needCloseSigSum = 0U; + UINT16* pNeedCloseBuf = NULL; + UINT8 zheFanRouteSum = 0U; + UINT16 * zheFanRouteIdBuf = NULL; + + /* ·豸 */ + /*·迪źŻ*/ + needOpenSigSum = GetRouteCbtcNeedOpenSigSum(routeId); + pNeedOpenBuf = GetRouteCbtcNeedOpenSigIdBuf(routeId); + /*·زͬʱźŻ*/ + oneOpenSigSum = GetRouteOnlyOneOpenSigSum(routeId); + pOneOpenBuf = GetRouteOnlyOneOpenSigIdBuf(routeId); + /*·رźŻ*/ + needCloseSigSum = GetRouteOpenNeedCloseSigSum(routeId); + pNeedCloseBuf = GetRouteOpenNeedCloseSigIdBuf(routeId); + + /*·źŻ۷·*/ + zheFanRouteSum = GetRtnEndSigAsStartSigRouteSum(routeId); + zheFanRouteIdBuf = GetReturnEndSigAsStartSigRoute(routeId); + + + /* ߼ */ + + /*·迪źŻѿ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedOpenBuf,needOpenSigSum,SIGNAL_OPEN,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_NEED_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·زͬʱźŻδ*/ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pOneOpenBuf,oneOpenSigSum,SIGNAL_CLOSE,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ONE_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·رźŻѹر */ + devId = 0u; + devState = 0u; + checkResult = SignalBufOpenCloseStateCheck(pNeedCloseBuf,needCloseSigSum,SIGNAL_CLOSE,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_NEED_CLOSE_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ʼźŻΪնźŻ۷·ǷѾɹ*/ + devId = 0u; + devState = 0u; + checkResult = RtnEndSigAsStartSigRouteCheck(zheFanRouteIdBuf,zheFanRouteSum,&devId,&devState); + if(CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_SIG_RETURN_OPENED_STATE,devState,sendLevel); + reResult = CI_ERROR; + } + } + + /* ؽ */ + return reResult; +} + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LeadRouteSecLockStateCheck(UINT16 const routeId, UINT8 checkState, UINT16* pDevId, UINT8* pDevState) +{ + /* ֲʼ */ + UINT16 i = 0U; /* ѭ */ + UINT16 devId = 0U; + UINT8 devState = 0U; + UINT8 secDirction = 0U; + + /*·*/ + /* ·*/ + UINT8 routeSectionSum = 0U; + RoutePhysicalSectionStruct* pRouteSectionDataBuf = NULL; + UINT8 routeDirction = 0U; + UINT8 reVal = CI_ERROR; + + + routeDirction = GetRouteDirection(routeId); + routeSectionSum = GetRoutePhysicalSectionSum(routeId); + pRouteSectionDataBuf = GetRouteSectionData(routeId); + /* ռü */ + if ((0u == routeSectionSum) || (NULL == pRouteSectionDataBuf)) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (i = 0U; i < routeSectionSum; i++) + { + devId = pRouteSectionDataBuf[i].PhysicalSectionId; + devState = GetPhySecLockState(devId); + secDirction = GetPhySecLockDirection(devId); + + /* 鱾 */ + if ((devState == checkState) || (PHYSICAL_SECTION_LOCK_NO == devState)) + { + if ((PHYSICAL_SECTION_LOCK_NO == checkState) || (PHYSICAL_SECTION_LOCK_START == checkState)) + { + /*δա롾ϵա鷽*/ + /* ͨ*/ + + } + else + { + if (PHYSICAL_SECTION_LOCK_NO == devState) + { + /* ͨ*/ + } + else + { + /*շ·һ*/ + if (secDirction == routeDirction) + { + /* ͨ*/ + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + } + + } + + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + } + if (CI_ERROR == reVal) + { + break; + } + } + } + + /*ȫͨ*/ + return reVal; +} +/* +* Զ۷Ƿͨ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESSԶ۷ͨ + CI_ERROR:Զ۷ʧ + 2022.08.03 add by pfq ۷гռʱжϵִ·Ϊ۷·ҽ·һռԶ۷ +*/ +UINT8 JudgeSetAutoTriggerFlagIsValid(const UINT16 routeId) +{ + UINT8 retVal = CI_ERROR; + UINT16 routeInPhySecId = 0u; /*·ڷID */ + UINT8 PhySecOccupyState = 0u; /*ռ״̬*/ + UINT8 PhySecLockState = 0u; /*״̬*/ + UINT8 phySectionSum = 0u; /*·*/ + UINT8 routeState = 0u; /*·״̬*/ + RoutePhysicalSectionStruct* pRoutePhysicalSectionBuf = NULL; + UINT16 bufIndex = 0; /*±*/ + UINT16 ii = 0u; /*ѭ±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex >= ROUTE_SUM_MAX) + { + retVal = CI_ERROR; + } + else + { + routeState = GetRouteState(routeId); + if (ROUTE_STATE_AUTO_UNLOCK == routeState) /*ִ·ԶʱԽ·ڷνм*/ + { + phySectionSum = GetRoutePhysicalSectionSum(bufIndex); /*ȡ·ڷ*/ + /*ȡ·ڷID*/ + pRoutePhysicalSectionBuf = GetRouteSectionData(bufIndex); + if ((0u < phySectionSum) && (NULL != pRoutePhysicalSectionBuf)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + for (ii = 0u; ii < phySectionSum; ii++) + { + routeInPhySecId = pRoutePhysicalSectionBuf[ii].PhysicalSectionId; + PhySecOccupyState = GetPhySecCurOccupyState(routeInPhySecId); /*ȡεǰռ״̬*/ + PhySecLockState = GetPhySecLockState(routeInPhySecId); /*ȡεǰ״̬*/ + if (ii < (phySectionSum - 1U)) + { + if ((PHYSICAL_SECTION_LOCK_NO == PhySecLockState) && (SECTION_OCCUPY_NO == PhySecOccupyState)) + { + /*ԶĽ·ڷһζδҿ*/ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; /*һ˳*/ + break; + } + } + else + { + if ((PHYSICAL_SECTION_LOCK_NORMAL == PhySecLockState) && (SECTION_OCCUPY_YES == PhySecOccupyState)) + { + /*·гͣվ̨ʱ۷·Զ*/ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + } + } + + return retVal; +} + + +/* +* ·߼ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221007 ·ǰ +*/ +UINT8 LeadRouteLogSecLockValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ·߼*/ + UINT16 const checkSum = GetRouteLogSectionSum(routeId); + UINT16* const dataIdBuf = GetRouteLogSectionIdBuf(routeId); + + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 secLockDirection = 0u; + UINT8 ciType = 0u; + UINT8 cLocalCiId = 0U; + UINT8 const routeDirDirection = GetRouteDirection(routeId); + UINT8 reVal = CI_ERROR; + UINT8 phyArbState = 0u; + UINT16 phySecId = 0u; /* ID */ + + cLocalCiId = GetSystemParaLocalCiId(); + ciType = GetCiType(cLocalCiId); + + /*·߼״̬*/ + if ((0u == checkSum) || (NULL == dataIdBuf || (NULL == pDevId) || (NULL == pDevState))) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (i = 0u; ichCheckSum)) + { + chRetVal = CI_SUCCESS; + for (ii = 0U; ii < chCheckSum; ii++) + { + devId = pstlogicSecSwitchBuf[ii].SwitchId; + devState = GetSwitchCurPosition(devId); + if (SWITCH_POSITION_INVALID == devState) + { + /*λЧ*/ + *pDevId = devId; + *pDevState = devState; + chRetVal = CI_ERROR; + } + else if ((SWITCH_POSITION_DINGWEI == devState) || (SWITCH_POSITION_FANWEI == devState)|| (SWITCH_POSITION_MOVE == devState)) + { + if (pstlogicSecSwitchBuf[ii].SwitchPosition == devState) + { + /* λһ£*/ + } + else + {/*λòһ*/ + if (ROUTE_HALF_SWITCH_MOVE_VALID == routeHalfSwitchMoveStt) + { + /* λòȷ Ұ*/ + switchMoveState = GetSwitchMoveValidState(devId, SWITCH_OPER_NO_DANCAO, sendLevel); + if (switchMoveState == CI_SUCCESS) + { + /*ɶ*/ + } + else + { + /*λòȷ ɶ*/ + *pDevId = devId; + *pDevState = devState; + chRetVal = CI_ERROR; + } + } + else + { + /*λòȷ ɶ*/ + *pDevId = devId; + *pDevState = devState; + chRetVal = CI_ERROR; + } + } + } + else if (SWITCH_POSITION_SIKAI == devState) + { + /*Ŀ*/ + *pDevId = devId; + *pDevState = devState; + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + chRetVal = CI_ERROR; + } + else if (SWITCH_POSITION_JICHA == devState) + { + /**/ + *pDevId = devId; + *pDevState = devState; + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + chRetVal = CI_ERROR; + } + else + { + /*λ״̬Ч */ + *pDevId = devId; + *pDevState = devState; + chRetVal = CI_ERROR; + } + if (CI_ERROR == chRetVal) + { + break; + } + else + { + } + } + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + +/* +* ·ղֵλǷɶ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfSwitchMoveValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ·*/ + UINT8 const checkSum = GetHalfRouteLockLgcSecSum(routeId); + UINT16* const pDataIdBuf = GetHalfRouteLockLgcSecIdBuf(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 ret = CI_ERROR; + UINT8 routeHalfSwitchMoveStt = 0U; + /* ռü */ + if (0U == checkSum) + { + /*ݴ*/ + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + + routeHalfSwitchMoveStt = GetHalfRouteSwitchMoveValid(routeId); + /*ʼ*/ + for (i = 0u; ichCheckSum)) + { + chRetVal = CI_SUCCESS; + for (ii = 0U; ii < chCheckSum; ii++) + { + devId = pstlogicSecSwitchBuf[ii].SwitchId; + devState = GetSwitchCurPosition(devId); + if (SWITCH_POSITION_INVALID == devState) + { + /*λЧ*/ + *pDevId = devId; + *pDevState = devState; + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + chRetVal = CI_ERROR; + } + else + { + if (pstlogicSecSwitchBuf[ii].SwitchPosition == devState) + { + /* λһ£*/ + } + else if (SWITCH_POSITION_SIKAI == devState) + { + /*Ŀ*/ + *pDevId = devId; + *pDevState = devState; + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + chRetVal = CI_ERROR; + } + else if (SWITCH_POSITION_JICHA == devState) + { + /**/ + *pDevId = devId; + *pDevState = devState; + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + chRetVal = CI_ERROR; + } + else + { + if (ROUTE_HALF_SWITCH_MOVE_VALID == routeHalfSwitchMoveStt) + { + + switchMoveState = GetSwitchMoveValidState(devId, SWITCH_OPER_NO_DANCAO, sendLevel); + + if (switchMoveState == CI_SUCCESS) + { + /*ɶ*/ + } + else + { + /*λòȷ ɶ*/ + *pDevId = devId; + *pDevState = devState; + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + chRetVal = CI_ERROR; + } + } + else + { + /*λòȷ ɶ*/ + *pDevId = devId; + *pDevState = devState; + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + chRetVal = CI_ERROR; + } + } + } + if (CI_ERROR == chRetVal) + { + break; + } + else + { + } + } + + + + } + else + { + chRetVal = CI_ERROR; + } + + + + return chRetVal; +} + +/* +* ·ղַ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfProSwitchMoveValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState) +{ + /* ·*/ + UINT8 const checkSum = GetHalfRouteLockLgcSecSum(routeId); + UINT16* const pDataIdBuf = GetHalfRouteLockLgcSecIdBuf(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 ret = CI_ERROR; + UINT8 routeHalfSwitchMoveStt = 0U; + /* ռü */ + if (0U == checkSum) + { + /*ݴ*/ + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + + routeHalfSwitchMoveStt = GetHalfRouteSwitchMoveValid(routeId); + /*ʼ*/ + for (i = 0u; i curRouteID) + { + curRoutestate = GetRouteState(curRouteID); + /*·ӽ·Ѱ*/ + if (ROUTE_STATE_IDLE != curRoutestate) + { + retVal = CI_ERROR; + } + else + { + /*ѭ*/ + } + } + else + { + /*ӽ·IDЧ*/ + retVal = CI_ERROR; + } + + if (CI_ERROR == retVal) + {/*ѭ*/ + break; + } + else + { + /*ѭ*/ + } + + } + } + return retVal; +} + + +/* +* ӽ· +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR ͨ +* CI_SUCCESS ͨ +*/ +UINT8 SubRouteCheck(UINT16 const routeId) +{ + + UINT16 curRouteID = 0U; + UINT8 curRoutestate = 0U; + UINT16 curPhysicId = 0U; + UINT8 curPhysicState = 0U; + + UINT8 i = 0U; + UINT8 j = 0U; + UINT16 devId = 0U; + UINT8 devState = 0U; + UINT8 retVal = CI_ERROR; + UINT16 routeLockedId = 0; /*Ľ·ID*/ + UINT16* mainRouteIDBuff = NULL; /*ӽ··ID*/ + UINT8 mainRouteSum = 0U; /*ӽ··*/ + UINT16 logicSum = 0U; + UINT16* logicIdBuf = NULL; + + mainRouteIDBuff = GetMainRouteBuff(routeId); + mainRouteSum = GetMainRouteSum(routeId); + logicSum = GetRouteLogSectionSum(routeId); /*·߼*/ + logicIdBuf = GetRouteLogSectionIdBuf(routeId); /*·߼*/ + + if ((NULL == mainRouteIDBuff) || (0U == mainRouteSum) + || (NULL == logicIdBuf) || (0U == logicSum)) + { + /*·Ч,CI_ERROR*/ + } + else + { + retVal = CI_SUCCESS; + /*߼ռ*/ + for (i = 0U; i < logicSum; i++) + { + devId = logicIdBuf[i]; + devState = GetLogSecLockState(devId); + + if (LOG_SECTION_LOCK_NO != devState) + {/*߼*/ + routeLockedId = GetLogSecLockBelongRoute(devId);/*ȡָ߼·*/ + /*ý·ӽ·*/ + for (j = 0U; j < mainRouteSum; j++) + { + if (routeLockedId == mainRouteIDBuff[j]) + {/*ӽ··Ϊ· 鲻ͨ*/ + retVal = CI_ERROR; + break; + } + else + { + /*ѭ*/ + } + } + } + else + { + /*δ ѭ*/ + } + + if (CI_ERROR == retVal) + { + /*㣬ѭCI_ERROR*/ + break; + } + else + { + /*ѭ*/ + } + } + } + return retVal; +} + +/* +* ··Ƿеʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +CI_SUCCESS:·޵ʱ +CI_ERROR:·еʱ +*/ +UINT8 ChekRouteHalfSwDrvOvTime(const UINT16 routeId) +{ + UINT8 retVal = CI_ERROR; + + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct *pLgcSecSwitchData = NULL; + UINT8 ii = 0u; /*ѭ*/ + UINT8 jj = 0U; + RouteSwitchStruct* pRouteSwitchStru = NULL; /**/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + + UINT16 i = 0u; /* ѭ */ + UINT16 SwitchId = 0u; + UINT8 SwitchPos = SWITCH_POSITION_INVALID; + UINT8 SwitchDrivOvtmDrvPos = SWITCH_DRIVE_POS_INVALID; + + /*ȡ·߼Ϣ*/ + logSectionSum = GetHalfRouteLockLgcSecSum(routeId); + pLogIdBuff = GetHalfRouteLockLgcSecIdBuf(routeId); + routeProtectSwitchSum = GetRouteHalfProSwData(routeId, routeProtectSwitchStru); /*ȡ*/ + /* ֲʼ */ + + if ((0u == logSectionSum) || (NULL == pLogIdBuff)) + { + /*߼Σ󳡾*/ + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if ((NULL != pLgcSecSwitchData) + && (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)) + { + /*ʼ·ڵ*/ + for (i = 0u; i < lgcSecSwitchSum; i++) + { + SwitchId = pLgcSecSwitchData[i].SwitchId; + SwitchPos = pLgcSecSwitchData[i].SwitchPosition; + SwitchDrivOvtmDrvPos = GetSwitchDrivOvtmDrvPosition(SwitchId); + + if (SWITCH_POSITION_DINGWEI == SwitchPos) + { + /*λȷ*/ + if (SWITCH_DRIVE_POS_DINGWEI == SwitchDrivOvtmDrvPos) + { + retVal = CI_ERROR; + } + + } + else if (SWITCH_POSITION_FANWEI == SwitchPos) + { + /*λȷ*/ + if (SWITCH_DRIVE_POS_FANWEI == SwitchDrivOvtmDrvPos) + { + retVal = CI_ERROR; + } + + } + else + { + /*ô*/ + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + /*ڳʱ*/ + break; + } + } + } + } + } + + if (CI_SUCCESS == retVal) + { + if ((0u == routeProtectSwitchSum)) + { + /*޼*/ + retVal = CI_SUCCESS; + } + else + { + /*ʼ·*/ + for (i = 0u; i= cEndSignalSum) && (NULL != szRouteSum) && (NULL != szRouteId) && (NULL != szMatchedRouteId)) + { + retVal = CI_SUCCESS; + + for (i = 0U; i < cEndSignalSum; i++) + { + cLieCheIndex = 0U; + cReturnIndex = 0U; + cTargRouteFlag = FLAG_UNSET; /*ÿѭһΣһα־*/ + + for (j = 0U; j < szRouteSum[i]; j++) + { + cRouteType = GetRouteType(szRouteId[i][j]); + if (0U == i) + { + /*һ߼Ϊؽ·ͨ·ҳ·еķ·г·*/ + cMainRouteProperty = GetRouteMainorSubPropert(szRouteId[i][j]); + if (ROUTE_TYPE_LIECHE == cRouteType) + { + if (ROUTE_MAIN_PROPERTY != cMainRouteProperty) + { + cLieCheIndex = j; + cTargRouteFlag = FLAG_SET; /*ҵг·ҷ·ȷΪƥĽ·ñ־Чֹͣ*/ + } + else + { + cLieCheIndex = j; + } + } + else + { + if (ROUTE_MAIN_PROPERTY != cMainRouteProperty) + { + cReturnIndex = j; + } + else + { + /**/ + } + } + } + else + { + /*߼ͨг·ҳĿ·*/ + if (ROUTE_TYPE_LIECHE == cRouteType) + { + cLieCheIndex = j; + cTargRouteFlag = FLAG_SET; /*ҵг·ȷΪƥĽ·ñ־Чֹͣ*/ + } + else + { + /**/ + } + } + + if (FLAG_SET == cTargRouteFlag) + { + break; /*ҵĿ·ֹͣ*/ + } + else + { + /**/ + } + } + + if (0U != cLieCheIndex) + { + szMatchedRouteId[i] = szRouteId[i][cLieCheIndex]; /*г·г·*/ + } + else + { + szMatchedRouteId[i] = szRouteId[i][cReturnIndex]; /*г·ʹ۷·*/ + } + } + } + else + { + /*μʧܣ0ʧ*/ + } + + return retVal; +} + +/* +* ߼س +* const UINT16 wTrainId гID +* const UINT8 cLogSecSum е߼ +* const UINT16 pLogSecIdBuff[] ߼ +* +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +UINT8 LogSecSeqIncUTCheck(const UINT16 wTrainId, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[]) +{ + /*ֲʼ*/ + UINT8 retVal = CI_ERROR; + UINT8 i = 0U; + UINT8 j = 0U; + UINT8 k = 0U; + UINT8 cTrainCommState = 0U; /*гͨ״̬*/ + EnvelopeStruct* pTrainEnvelopeData = NULL; /*г*/ + UINT8 cLogSecOccState = 0U; /*߼ռ״̬*/ + UINT8 cLogSecIncLinkNum = 0U; /*߼ΰlink*/ + UINT16* pLogSecIncLinkIdBuff = NULL; /*߼ΰlinkID*/ + UINT8 cLinkIncTrainSum = 0U; /*linkϵг*/ + TRAIN_SEQUANCE_s linkInctrainList[SIZE_MAX_TRAINOFAC] = { 0u }; /*linkϵг*/ + + /*μ飨ݲгID*/ + if ((0U == cLogSecSum) || (NULL == pLogSecIdBuff)) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + + if (CI_SUCCESS == retVal) + { + if ((0U != wTrainId) && (UINT16_MAX != wTrainId)) /*гIDϷж*/ + { + cTrainCommState = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_GOOD == cTrainCommState) /*ͨųǰɸ*/ + { + if (CI_SUCCESS == retVal) + { + /*߼Ƿس*/ + for (i = 0U; i < cLogSecSum; i++) + { + cLogSecOccState = GetLogSecCurCtOrUtOccupyState(pLogSecIdBuff[i]); + if (LOGICSECTION_OCCUPY_NO != cLogSecOccState) + { + /*гռʱж߼Ƿس*/ + cLogSecIncLinkNum = GetSecIntrudeLinkSum(pLogSecIdBuff[i]); + pLogSecIncLinkIdBuff = GetSecIntrudeLinkIdBuf(pLogSecIdBuff[i]); + for (j = 0U; j < cLogSecIncLinkNum; j++) + { + cLinkIncTrainSum = as_GetLinkTrainList(pLogSecIncLinkIdBuff[j], linkInctrainList, SIZE_MAX_LINETRAIN); + for (k = 0U; k < cLinkIncTrainSum; k++) + { + if ((NAME_FAILUREAREA != linkInctrainList[k].u16TrainID) && (TYPE_CT == linkInctrainList[k].u8TrainType)) + { + retVal = CI_SUCCESS; /*ͨų*/ + } + else + { + retVal = CI_ERROR; /*ڷͨųֹͣ顣ʧ*/ + break; + } + } + + if (CI_SUCCESS != retVal) + { + break; /*߼һlinkسֹͣ飬ʧ*/ + } + else + { + /**/ + } + } + } + else + { + retVal = CI_SUCCESS; /*޳ռãͨ*/ + } + + if (CI_SUCCESS != retVal) + { + break; /*һ߼δسֹͣ飬ʧ*/ + } + else + { + /**/ + } + } + } + { + /*ͨųǰ˿ɣֱӷʧ*/ + } + } + else + { + /*ͨųֱӷسɹ*/ + } + } + else + { + /*Чֱӷسɹ*/ + } + } + else + { + /*Уʧ*/ + } + + return retVal; +} + +/* +* ·ڱڷ +* const UINT16 routeId, ·ID +* +* ֵ CI_ERROR ·ڱڷڱ +* CI_SUCCESS ·ڱڷûڱ +* cgh:ɶ27ν·󣬽·ڱȫ +*/ +UINT8 RouteAllPhyBelongCiCheck(const UINT16 routeId) +{ + UINT8 reval = CI_ERROR; + UINT8 chLocalCiId = 0U;/**/ + UINT8 chPhySecSum = 0u; /**/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT8 chPhyBelongCiId = 0U;/**/ + UINT8 ii = 0U; + UINT8 chRouteProSwitchSum = 0U; /*Ŀ*/ + RouteProtectSwitchStruct* pRouteProtectSwitchStru = NULL; /**/ + UINT16 wProSwRelPhySecId = 0U;/*ID*/ + + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + chPhySecSum = GetRoutePhysicalSectionSum(routeId); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(routeId); /*ȡ·*/ + + if ((0u == chLocalCiId) || (NULL == pPhySecDataStru)) + { + reval = CI_ERROR; + } + else + { + reval = CI_SUCCESS; /*ִͨ*/ + } + + if (CI_SUCCESS == reval) + { + for (ii = 0U; ii < chPhySecSum; ii++) + { + chPhyBelongCiId = GetPhySecBelongCiId(pPhySecDataStru[ii].PhysicalSectionId); + if (chLocalCiId == chPhyBelongCiId) + { + /*·һڱCI_ERROR*/ + reval = CI_ERROR; + break; + } + else + { + ; /**/ + } + } + } + else + { + ; + } + + if (CI_SUCCESS == reval) + { + chRouteProSwitchSum = GetRouteRelatedProtectSwitchSum(routeId); + pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(routeId); + + for (ii= 0u; ii < chRouteProSwitchSum; ii++) + { + wProSwRelPhySecId = GetSwitchPhySectionId(pRouteProtectSwitchStru[ii].ProtectSwitchId); + chPhyBelongCiId = GetPhySecBelongCiId(wProSwRelPhySecId); + if (chLocalCiId == chPhyBelongCiId) + { + /*·һڱCI_ERROR*/ + reval = CI_ERROR; + break; + } + else + { + ; /**/ + } + } + } + else + { + + } + + return reval; +} +/* +* жϽ·Ƿ +* const UINT16 routeId, ·ID +* +* ֵ CI_ERROR · +* CI_SUCCESS · +*/ +UINT8 RouteAllLockCheck(const UINT16 routeId) +{ + UINT8 reval = CI_ERROR; + UINT8 routeState = 0U;/*·״̬*/ + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + + + if((ROUTE_STATE_FIRST_LOCK== routeState)|| + (ROUTE_STATE_FIRST_LOCKERR== routeState)|| + (ROUTE_STATE_YUXIAN_LOCK == routeState)|| + (ROUTE_STATE_YUXIAN_OPEN == routeState)|| + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState)|| + (ROUTE_STATE_NEAR_LOCK == routeState) + ) + { + /*·:··쳣ԤաԤȿšӽšӽ쳣ӽ*/ + reval = CI_SUCCESS; + } + else + { + /*·*/ + } + return reval; +} + +/* +* ߼ǷƥĽ· +* const UINT8 cLogSecSeqDir ߼з +* const UINT8 cLogSecSum ߼ +* const UINT16 pLogSecIdBuff[] ߼ +* UINT16* pMatchedRouteId ƥĽ·ID +* ֵ 0: ƥɹ +* 1: ƥʧ +*/ +UINT8 MatchedRouteCheck(const UINT8 cLogSecSeqDir, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[], UINT16* pMatchedRouteId) +{ + UINT8 cLastIndex = 0U; + UINT8 i = 0U; + UINT8 cRelatedSigSum = 0U; /*߼ιźŻ*/ + UINT16* pRelatedSigId = NULL; /*߼ιźŻID*/ + UINT8 cSignalProDir = 0U; + UINT16 wSigProLinkId = 0U; /*źŻlink*/ + UINT8 cQueryLogDir = 0U; /*ѯ߼*/ + UINT16 wEndSignalId = 0U; /*նźŻID*/ + UINT16 wMatchedRouteId = 0U; + UINT8 retVal = CI_ERROR; + UINT16* pLogSecIncLinkId = NULL; /*߼ΰlink*/ + LOD_STRU strCurPoint = { 0U }; + LOD_STRU strNxtPoint = { 0U }; + UINT8 cDirChangeNum = 0U; /*仯*/ + + if (((CI_SYSTEM_DIRECTION_DOWN != cLogSecSeqDir) && (CI_SYSTEM_DIRECTION_UP != cLogSecSeqDir)) + || (0U == cLogSecSum) || (NULL == pLogSecIdBuff)) + { + retVal = CI_ERROR; /*ʧ*/ + } + else + { + cLastIndex = cLogSecSum - 1U; + cRelatedSigSum = GetLogRelateEndSigSum(pLogSecIdBuff[cLastIndex]); /*ȡһ߼ιնźŻ/ID*/ + pRelatedSigId = GetLogRelateEndSigData(pLogSecIdBuff[cLastIndex]); + pLogSecIncLinkId = GetSecIntrudeLinkIdBuf(pLogSecIdBuff[0]); /*ȡ׸߼ΰlink*/ + + /*ѡ߼ιնźŻзRC͵зͬźŻ߼*/ + if ((0U != cRelatedSigSum) && (NULL != pRelatedSigId) && (NULL != pLogSecIncLinkId)) + { + cQueryLogDir = ConvertDirectionToLogic(cLogSecSeqDir); /*ӪתΪ߼*/ + + for (i = 0U; i < cRelatedSigSum; i++) + { + cSignalProDir = GetSignalDirection(pRelatedSigId[i]); + wSigProLinkId = GetSignalProtectLink(pRelatedSigId[i]); + strCurPoint.Lnk = pLogSecIncLinkId[0]; + strCurPoint.Off = 0U; + strNxtPoint.Lnk = wSigProLinkId; + strNxtPoint.Off = 0U; + cDirChangeNum = GetDirChangeNumBtwPoints(&strCurPoint, &strNxtPoint); /*ѯǰlinkźŻlinkķ仯*/ + cSignalProDir = TransDirByChangeNum(cSignalProDir, cDirChangeNum); + + if (cSignalProDir == cQueryLogDir) + { + wEndSignalId = pRelatedSigId[i]; /*һ߼δͬնźŻźŻID*/ + break; + } + else + { + /*ͬնźŻһ߼Σ*/ + } + } + + /*߼ƥ·*/ + if (0U != wEndSignalId) + { + wMatchedRouteId = SearchMatchedRoute(wEndSignalId, cLogSecSum, pLogSecIdBuff); + + if (0U != wMatchedRouteId) + { + *pMatchedRouteId = wMatchedRouteId; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; /*δҵնźŻ*/ + } + } + else + { + retVal = CI_ERROR; + } + } + + return retVal; +} + +/* +* Ѱ߼ƥĽ· +* UINT16 wEndSignalId նźŻID +* const UINT8 cLogSecSum ߼ +* const UINT16 pLogSecIdBuff[] ߼ +* +* ֵ 0: δҵƥĽ· +* >0: ƥĽ·ID +*/ +UINT16 SearchMatchedRoute(UINT16 wEndSignalId, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[]) +{ + UINT8 i = 0U; + UINT8 j = 0U; + UINT16 k = 0U; + UINT8 tempIndex = 0U; + UINT8 cRelatedRouteSum = 0U; /*߼ι·*/ + UINT16* pRelatedRouteId = NULL; /*߼ι·ID*/ + UINT16 wRouteEndSignalId = 0U; /*·նźŻ*/ + UINT16 cRouteIncLogSecSum = 0U; /*·߼*/ + UINT16* pRouteIncLogSecIdBuff = NULL; /*·߼ID*/ + UINT8 cMatchedLogSum = 0U; /*б·߼жǷ񱻽·ȫ*/ + UINT8 wPossibleRouteSum = 0U ; /*ɸɹĽ·*/ + UINT16 wPossibleRouteIdBuff[ROUTE_SUBROUTE_SUM_MAX] = { 0U }; /*ɸɹĽ·ID飨նźŻͬȫ߼У*/ + UINT16 wMatchedRouteId = 0U; /*ƥĽ·ID*/ + UINT8 cLocalCiId = 0U; + UINT8 cRouteBelongCiId = 0U; + + cLocalCiId = GetSystemParaLocalCiId(); + + + if ((0U == wEndSignalId) || (0U == cLogSecSum) || (NULL == pLogSecIdBuff)) + { + /*μʧ*/ + } + else + { + tempIndex = cLogSecSum - 1U; /*ȡǰ߼еһ߼*/ + + /*ȡһ߼ι·Ϣ*/ + cRelatedRouteSum = GetLogRelateRouteSum(pLogSecIdBuff[tempIndex]); + pRelatedRouteId = GetLogRelateRouteData(pLogSecIdBuff[tempIndex]); + + for (i = 0U; i < cRelatedRouteSum; i++) + { + wRouteEndSignalId = GetRouteEndSignalId(pRelatedRouteId[i]); + cRouteBelongCiId = GetRouteBelongCiId(pRelatedRouteId[i]); + + if ((cRouteBelongCiId == cLocalCiId) && (wRouteEndSignalId == wEndSignalId)) /*·ڱҽ·նźŻ߼նźŻͬ*/ + { + /*ȡ·߼Ϣ*/ + cRouteIncLogSecSum = GetRouteLogSectionSum(pRelatedRouteId[i]); + pRouteIncLogSecIdBuff = GetRouteLogSectionIdBuf(pRelatedRouteId[i]); + cMatchedLogSum = 0U; + + /*жϽ·Ƿȫ߼*/ + for (j = 0U; j < cLogSecSum; j++) + { + for (k = 0U; k < cRouteIncLogSecSum; k++) + { + if (pLogSecIdBuff[j] == pRouteIncLogSecIdBuff[k]) + { + cMatchedLogSum++; + break; + } + else + { + /*·һ߼ƥ*/ + } + } + } + + /*洢ȫ߼еĽ·Ϣ*/ + if (cMatchedLogSum == cLogSecSum) + { + wPossibleRouteIdBuff[wPossibleRouteSum] = pRelatedRouteId[i]; + wPossibleRouteSum++; + } + else + { + ; + } + } + else + { + /*նźŻͬ*/ + } + } + + if (0U == wPossibleRouteSum) + { + /*δƥ䵽·*/ + } + else + { + /*ҳ·Եг·*/ + wMatchedRouteId = SearchNonMainRoute(wPossibleRouteSum, wPossibleRouteIdBuff); + } + } + return wMatchedRouteId; +} + +/* +* Ѱҽ·еķ· +* UINT8 cRouteSum · +* UINT16 wRouteIdBuff[] ·ID +* +* ֵ UINT16 wNonMainRouteId ·ID +*/ +UINT16 SearchNonMainRoute(UINT8 cRouteSum, UINT16 wRouteIdBuff[]) +{ + UINT16 wNonMainRouteId = 0U; + UINT8 i = 0U; + UINT8 tempLiecheIndex = 0U; /*г·*/ + UINT8 tempReturnIndex = 0U; /*۷·*/ + UINT8 cMainRouteProperty = 0U; /*/ӽ·*/ + UINT8 cRouteType = 0u; /*·*/ + + if ((0U == cRouteSum) || (NULL == wRouteIdBuff)) + { + /*μʧ*/ + } + else + { + for (i = 0U; i < cRouteSum; i++) + { + cRouteType = GetRouteType(wRouteIdBuff[i]); + + if (ROUTE_TYPE_LIECHE == cRouteType) + { + cMainRouteProperty = GetRouteMainorSubPropert(wRouteIdBuff[i]); + if (ROUTE_MAIN_PROPERTY != cMainRouteProperty) + { + tempLiecheIndex = i; /*ҵг·ҷ·ȷΪƥĽ·ֹͣ*/ + break; + } + else + { + tempLiecheIndex = i; /*µǰг·*/ + } + } + else + { + cMainRouteProperty = GetRouteMainorSubPropert(wRouteIdBuff[i]); + if (ROUTE_MAIN_PROPERTY != cMainRouteProperty) + { + tempReturnIndex = i; /*ҵ۷·ҷ·ȷΪƥĽ·ֹͣ*/ + } + else + { + /**/ + } + } + } + + if (0U != tempLiecheIndex) + { + /*г·г·Ϊ*/ + wNonMainRouteId = wRouteIdBuff[tempLiecheIndex]; + } + else + { + /*г·۷·۷·Ҳڣ򷵻ؽ·еĵһ·*/ + wNonMainRouteId = wRouteIdBuff[tempReturnIndex]; + } + } + + return wNonMainRouteId; +} + +/* +* ߼εʱ״̬ +* UINT16 switchId Id +* UINT16* pLogSecId ʱٵ߼ID +* UINT8 *pLogState, ߼ʱ״̬ +* ֵ CI_SUCCESS: ߼βʱ +* CI_ERROR: ߼δʱ +* modify 20230927 ӽ·ڵ߼ʱ״̬ +*/ +UINT8 SwitchRelLogSecLSXSStateCheck(UINT16 switchId, UINT16* pLogSecId, UINT8* pLogState) +{ + UINT16 i = 0U; + UINT16 wLogSecSum = 0U; + UINT8 cLogSecLockState = 0U; + UINT16* pLogSecIDBuf = NULL; + UINT8 retValue = CI_ERROR; + + if ((0U != switchId) && (SWITCH_SUM_MAX > switchId) && (NULL != pLogSecId) && (NULL != pLogState)) + { + /*ȡ߼Ϣ*/ + wLogSecSum = GetSwitchLogSecSum(switchId); + pLogSecIDBuf = GetSwitchLogSecBuf(switchId); + + if ((0U != wLogSecSum) && (NULL != pLogSecIDBuf)) + { + /*߼ʱ״̬*/ + for (i = 0U; i < wLogSecSum; i++) + { + cLogSecLockState = GetLogSecLinShiXianSuSetState(pLogSecIDBuf[i]); + if ((LOGSEC_LSXS_SET_STATE_NO == cLogSecLockState) + || (LOGSEC_LSXS_SET_STATE_INVALID == cLogSecLockState)) + { + retValue = CI_SUCCESS; + } + else + { + *pLogSecId = pLogSecIDBuf[i]; + *pLogState = cLogSecLockState; + retValue = CI_ERROR; + break; + } + } + } + else + { + /*ʧ*/ + } + } + else + { + /*ηǷʧ*/ + } + + return retValue; +} + +/* +* źűֿʱ·ղ +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* RES_CHECK_STATE_WAITE ȴ +* by cgh 20230930 +*/ +UINT8 KeepSignalRelayZhaoChaCheck(UINT16 const routeId) +{ + UINT8 chRetVal = CI_ERROR; /*ֵ*/ + UINT8 chRouteLevel = 0U; /*·ල*/ + UINT32 chRouteLevelChangeCyc = 0U; /*·ල仯ں*/ + UINT16 wSelfRealyId = 0U;/*ǰ𱾶ղ̵ID*/ + UINT8 chRelayCollState = 0U;/*̵ɼ״̬*/ + UINT8 checkRelayRes = 0U;/*̵ʱ*/ + UINT8 chRouteState = 0U;/*·״̬*/ + UINT32 dwRouteLockStartCyc = 0U;/*·ʼ*/ + + chRouteLevel = GetRouteLevel(routeId); + + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + wSelfRealyId = GetRouteThisZhaoChaRelayId(routeId); /*ģʽղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + wSelfRealyId = GetRouteCbtcThisZhaoChaRelayId(routeId); /*CBTCģʽղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0*/ + } + if (0U < wSelfRealyId) + { + chRelayCollState = GetRelayCollState(wSelfRealyId); /*ȡָID̵״̬*/ + /*߾Чʱֱж*/ + if (RELAY_STATE_UP == chRelayCollState) + { + chRouteState = GetRouteState(routeId); + + if ((ROUTE_STATE_NEAR_OPEN == chRouteState) || + (ROUTE_STATE_YUXIAN_OPEN == chRouteState)) + { + chRouteLevelChangeCyc = GetRouteLevelChangeCyc(routeId); + /*·ǰලͬл*/ + checkRelayRes = SystemOverTimeCheck(chRouteLevelChangeCyc, RELAY_DRIVE_MAX_NUM); + if (CI_TIME_IN == checkRelayRes) + { + /*ڷģʽתղ̵״̬δ£ʱسɹ*/ + /*ղ̵״̬10ڣʱڷسɹ*/ + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else if (ROUTE_STATE_HALF_UNLOCK == chRouteState) + { + dwRouteLockStartCyc = GetRouteLockStartCycNum(routeId); + checkRelayRes = SystemOverTimeCheck(dwRouteLockStartCyc, RELAY_DRIVE_MAX_NUM); + if (CI_TIME_IN == checkRelayRes) + { + /*ղ̵״̬10ڣʱڷسɹ*/ + chRetVal = RES_CHECK_STATE_WAITE; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == chRelayCollState) + { + chRetVal = CI_SUCCESS; + } + else + { + /*ɼ״̬Ƿ*/ + chRetVal = CI_ERROR; + } + } + else + { + /*𱾶ղ̵Чͨ*/ + chRetVal = CI_SUCCESS; + } + return chRetVal; +} + +/* +* ζӦ߼Ƿ· +* ˵ const UINT16 phySectionId ID +* ֵ ߼· +* cgh-20231002 +*/ +UINT16 CheckLogSecLockBelongRoute(const UINT16 phySectionId) +{ + UINT8 chPhyIncLogSum = 0U; /*߼Ŀ*/ + UINT16* pPhyIncLogId = NULL; /*ΰ߼ID*/ + UINT8 ii = 0U; /*ΰ߼ѭ*/ + UINT16 wLogLockBelongRouteId = 0U; /*߼·ID*/ + UINT16 chReval = 0U; + + chPhyIncLogSum = GetPhySecIncLogSecSum(phySectionId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(phySectionId); + + if (NULL != pPhyIncLogId) + { + for (ii = 0U; ii < chPhyIncLogSum; ii++) + { + wLogLockBelongRouteId = GetLogSecLockBelongRoute(pPhyIncLogId[ii]); + if ((0U < wLogLockBelongRouteId) && (ROUTE_SUM_MAX > wLogLockBelongRouteId)) + { + chReval = wLogLockBelongRouteId; + break; + } + else + { + /**/ + } + } + } + return chReval; +} + +/* +* ߼ιϽ +* ˵ UINT16 const wLogSecId ߼ID +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_UNLOCK_FAULT_LOGSEC +* by cgh 20231004 +*/ +UINT8 LogSecFaultUnlockLogicProcess(UINT16 const wLogSecId) +{ + UINT8 chResult = CI_ERROR; + UINT8 const chFunctionId = EFUNC_UNLOCK_FAULT_LOGSEC;/**/ + UINT8 chLogSecLockState = 0U;/*߼״̬*/ + UINT8 chCheckResult = 0U;/*߼*/ + UINT8 chSendLevel = ESEND_LEVEL_ATS;/*͵ȼ-ATS*/ + UINT8 chTransmitState = 0U;/*ͨ״̬*/ + UINT8 chLogSecBelongCiId = 0U;/*߼*/ + UINT8 chFuncSwitch = 0U; /*Ƿ̵ּ֧ӿ*/ + UINT8 chLocalCi = 0U;/*ID*/ + UINT8 chConfirmRelayInterfaceFlag = 0U;/*̵ӿȷ״̬*/ + UINT16 wLogSecLockBelongRouteId = 0U;/*߼·ID*/ + UINT8 chRouteBelongCi = 0U;/*·*/ + UINT16 wLogSecBelongPhySecId = 0U;/*߼ID*/ + UINT8 chRouteLevel = 0U;/*߼··ල*/ + UINT16 wCancleZhaoChaRelayId = 0U;/*ȡղ̵ID*/ + UINT8 chRelayCollState = 0U;/*̵ɼ״̬*/ + UINT8 chOtherCiId = 0U;/*ID*/ + UINT8 chExecRes = 0U;/*ִ߼*/ + UINT8 chCommState = 0U;/*ͨͨ״̬*/ + + chFuncSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI); + chLocalCi = GetSystemParaLocalCiId(); + chConfirmRelayInterfaceFlag = GetCiCiRelayInterfConfirmFlag(); + chLogSecBelongCiId = GetLogSecBelongCiId(wLogSecId); + wLogSecLockBelongRouteId = GetLogSecLockBelongRoute(wLogSecId); + chRouteBelongCi = GetRouteBelongCiId(wLogSecLockBelongRouteId);/*ȡ·*/ + chTransmitState = GetLocalCiAndOtherCiTransSta(chLogSecBelongCiId); + + /**/ + /*״̬*/ + chCheckResult = GetLogSecLockState(wLogSecId); + if (LOG_SECTION_LOCK_EXCEPT == chCheckResult) + { + chResult = CI_SUCCESS; + } + else + { + SetErrorData(chFunctionId, CI_DEVICE_TYPE_LOGICSEC, wLogSecId, ETYPE_LOGSEC_LOCK_STATE, chCheckResult, chSendLevel); + chResult = CI_ERROR; + } + + /*ο*/ + if (CI_SUCCESS == chResult) + { + wLogSecBelongPhySecId = GetLgcSecRelativePhySecId(wLogSecId); + /*·ΪΪҼ̵ӿ£ռ*/ + if ((chLocalCi == chRouteBelongCi) && (chLocalCi != chLogSecBelongCiId) && + (TRANSMIT_STATE_BAD == chTransmitState) && (CICI_RELAY_INTERFACE_CONFIRM_YES == chConfirmRelayInterfaceFlag) + && (FUNC_SWITCH_ON == chFuncSwitch)) + { + chResult = CI_SUCCESS; + } + else + { + chCheckResult = GetPhySecCurMergeState(wLogSecBelongPhySecId); + if (SECTION_OCCUPY_NO == chCheckResult) + { + /* ͨ */ + chResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(chFunctionId, CI_DEVICE_TYPE_PHYSEC, wLogSecBelongPhySecId, ETYPE_PS_MERGY_OCU_STATE, chCheckResult, chSendLevel); + /* ʧܷ */ + chResult = CI_ERROR; + } + } + + } + + /*ȡղ̵Ϊ*/ + if (CI_SUCCESS == chResult) + { + chRouteLevel = GetRouteLevel(wLogSecLockBelongRouteId); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + wCancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(wLogSecLockBelongRouteId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + wCancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(wLogSecLockBelongRouteId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + + if ((0U != wCancleZhaoChaRelayId) && (0xFFFFU != wCancleZhaoChaRelayId)) + { + if ((chLocalCi == chLogSecBelongCiId) && (chLocalCi != chRouteBelongCi) && + (TRANSMIT_STATE_BAD == chTransmitState) && + (CICI_RELAY_INTERFACE_CONFIRM_YES == chConfirmRelayInterfaceFlag) && + (FUNC_SWITCH_ON == chFuncSwitch)) + { + /*Ϊ·뱾ͬұ·ͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣԲȡղ̵״̬*/ + chResult = CI_SUCCESS; + } + else + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + chRelayCollState = GetRelayCollState(wCancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + if (RELAY_STATE_UP == chRelayCollState) + { + /* ͨ */ + chResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(chFunctionId, CI_DEVICE_TYPE_RELAY, wCancleZhaoChaRelayId, ETYPE_CANCLE_ZHAOCHA, chRelayCollState, chSendLevel); + /* ʧܷ */ + chResult = CI_ERROR; + } + } + } + } + + /*̵ӿȡղ̵Ϊ*/ + if (CI_SUCCESS == chResult) + { + /*̵ȡղ*/ + wCancleZhaoChaRelayId = GetRouteCancleZCRelayId(wLogSecLockBelongRouteId); + chExecRes = RouteHavePhySecBelongOtherCi(wLogSecLockBelongRouteId, &chOtherCiId); + + if ((0U != wCancleZhaoChaRelayId) && (0xFFFFU != wCancleZhaoChaRelayId)) + { + if (chRouteBelongCi == chLocalCi) + {/*·ڱ*/ + if ((CI_SUCCESS == chExecRes) && (0U < chOtherCiId) && (chOtherCiId != chRouteBelongCi)) + { + chCommState = GetLocalCiAndOtherCiTransSta(chOtherCiId);/*ͨͨ״̬*/ + if ((TRANSMIT_STATE_BAD == chCommState) && + (FUNC_SWITCH_ON == chFuncSwitch)) + {/*·ڱIJҪ*/ + if (CICI_RELAY_INTERFACE_CONFIRM_YES == chConfirmRelayInterfaceFlag) + { + /*ͨжϣӪԱ·ȷϼ̵ӿ + ̵ּ֧ӿڣҪ̵ӿȡղ̵״̬*/ + chResult = CI_SUCCESS; + + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + chRelayCollState = GetRelayCollState(wCancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + if (RELAY_STATE_UP == chRelayCollState) + { + /* ͨ */ + chResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(chFunctionId, CI_DEVICE_TYPE_RELAY, wCancleZhaoChaRelayId, ETYPE_CANCLE_ZHAOCHA, chRelayCollState, chSendLevel); + /* ʧܷ */ + chResult = CI_ERROR; + } + } + else + {/*ûȷϣ׼ʽ⣬ʧ*/ + chResult = CI_ERROR; + debug_infor_printf((const)"LogSectionFaultUnlockLogicProcess error,not Confirm.\n"); + } + } + } + } + else + {/*·ڱҪ*/ + + } + } + } + return chResult; +} + +/* +* ʽս· +* ˵ const UINT16 wPhySectionId ID +* const UINT8 chVirCIid ID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +* cgh-20231011 +*/ +UINT8 PhySecFaultUnlockRouteCheck(const UINT16 wPhySectionId, const UINT8 chVirCIid) +{ + UINT8 chReval = CI_ERROR; + UINT16 wPhySecLockBelRouteId = 0U; /*·ID*/ + UINT16 wLogLockBelongRouteId = 0U; /*߼·ID*/ + UINT8 chLogLockBelLogRouteCheck = 0U; /*߼߼·*/ + + if ((0U == wPhySectionId) || (PHYSICAL_SECTION_SUM_MAX < wPhySectionId)) + { + /*IDЧ*/ + chReval = CI_ERROR; + } + else + { + wPhySecLockBelRouteId = GetPhySecRLockBelongRouteId(wPhySectionId); /*ȡν··ID*/ + chLogLockBelLogRouteCheck = CheckLogSecLockExistLogRoute(wPhySectionId); + + if (ROUTE_SUM_MAX < wPhySecLockBelRouteId) + { + /*·IDЧ*/ + chReval = CI_ERROR; + SetCiSendCmdBackInfoData(CI_BACK_PSEC_LOCK_NO, CI_DEVICE_TYPE_PHYSEC, wPhySectionId, 0U, 0U); + } + else if (0U == wPhySecLockBelRouteId) + { + /*·Ϊ01λ۷гȫ·ͷţʱ߼·2ֻ߼·*/ + /*ִειϽ߼ִ߼ιϽ*/ + chReval = CI_ERROR; + wLogLockBelongRouteId = CheckLogSecLockBelongRoute(wPhySectionId); + if (((0U == wLogLockBelongRouteId) || (ROUTE_SUM_MAX < wLogLockBelongRouteId)) && (CI_ERROR == chLogLockBelLogRouteCheck)) + { + SetCiSendCmdBackInfoData(CI_BACK_PSEC_LOCK_NO, CI_DEVICE_TYPE_PHYSEC, wPhySectionId, 0U, 0U); + } + else + { + LogicSecFaultUnlockLogicManage(wPhySectionId, chVirCIid); + } + + } + else + { + /*δ·ܴ߼·ͨ·Ӱ*/ + if (CI_SUCCESS == chLogLockBelLogRouteCheck) + { + chReval = CheckPhyAllLogSecExceptLockSta(wPhySectionId); + } + else + { + /*ֻδ·ִУִʽͲ·ʽ߼*/ + chReval = CI_SUCCESS; + } + if (CI_ERROR == chReval) + { + SetErrorData(EFUNC_PHYSEC_FAULT_BELONG_ROUTE, CI_DEVICE_TYPE_PHYSEC, wPhySectionId, + ETYPE_PS_LJJL_PHYJL_ALL_NAMAL, chReval, ESEND_LEVEL_ZERO); + + /*鲻ͨرͨ·źż߼·Чź*/ + SecFaultUnlockDrvRelSigClose(wPhySectionId); + } + } + } + return chReval; +} + +/* +* ζӦ߼Ƿ߼· +* ˵ const UINT16 wPhySectionId ID +* ֵ CI_ERROR +* CI_SUCCESS +* cgh-20231011 +*/ +UINT8 CheckLogSecLockExistLogRoute(const UINT16 wPhySectionId) +{ + UINT8 chPhyIncLogSum = 0U; /*߼Ŀ*/ + UINT16* pPhyIncLogId = NULL; /*ΰ߼ID*/ + UINT8 ii = 0U; /*ΰ߼ѭ*/ + UINT8 wLogLockBelLogRouteSum = 0U; /*߼߼·Ŀ*/ + UINT8 chReval = CI_ERROR; + + chPhyIncLogSum = GetPhySecIncLogSecSum(wPhySectionId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(wPhySectionId); + + if (NULL != pPhyIncLogId) + { + for (ii = 0U; ii < chPhyIncLogSum; ii++) + { + wLogLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(pPhyIncLogId[ii]); + if (0U < wLogLockBelLogRouteSum) + { + chReval = CI_SUCCESS; + break; + } + else + { + /**/ + } + } + } + return chReval; +} + +/* +* ζӦ߼쳣߼״̬ +* ˵ const UINT16 wPhySectionId ID +* ֵ CI_ERROR ȫΪ +* CI_SUCCESS һΪջ߼· +* cgh-20231011 +*/ +UINT8 CheckPhyAllLogSecExceptLockSta(const UINT16 wPhySectionId) +{ + UINT8 chPhyIncLogSum = 0U; /*߼Ŀ*/ + UINT16* pPhyIncLogId = NULL; /*ΰ߼ID*/ + UINT8 ii = 0U; /*ΰ߼ѭ*/ + UINT8 wLogLockBelLogRouteSum = 0U; /*߼߼·Ŀ*/ + UINT8 chLogSecLogLockState = 0U;/*߼߼״̬*/ + UINT8 chLogSecLockState = 0U;/*߼״̬*/ + UINT8 chReval = CI_ERROR; + + if ((0u == wPhySectionId) || (PHYSICAL_SECTION_SUM_MAX < wPhySectionId)) + { + /*IDЧ*/ + chReval = CI_ERROR; + } + else + { + chPhyIncLogSum = GetPhySecIncLogSecSum(wPhySectionId); + pPhyIncLogId = GetPhySecIncLogSecIdBuf(wPhySectionId); + + if ((NULL != pPhyIncLogId) && ((0U < chPhyIncLogSum) && (PHYSICAL_INCLUDE_LOG_SUM_MAX > chPhyIncLogSum))) + { + for (ii = 0U; ii < chPhyIncLogSum; ii++) + { + wLogLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(pPhyIncLogId[ii]); + chLogSecLockState = GetLogSecLockState(pPhyIncLogId[ii]); + + if (0U != wLogLockBelLogRouteSum) + { + chReval = CI_ERROR; + chLogSecLogLockState = GetLogSecLogLockState(pPhyIncLogId[ii]); + + if ((LOG_SECTION_LOGLOCK_NORMAL == chLogSecLogLockState) && (LOG_SECTION_LOCK_NORMAL == chLogSecLockState)) + { + break; + } + else if ((LOG_SECTION_LOGLOCK_EXCEPT == chLogSecLogLockState) && (LOG_SECTION_LOCK_NORMAL == chLogSecLockState)) + { + /*̬·쳣գͨ·δ쳣գóڣ쳣򲻿ʽ⣬崻*/ + SetPlatOverFlag(); /*ƽ̨崻*/ + SetErrorData(EFUNC_PLAT_OVER, CI_DEVICE_TYPE_LOGICSEC, pPhyIncLogId[ii], ETYPE_PS_LJJL_NAMAL_BUT_LOGEXCEPT, LOG_SECTION_LOCK_NORMAL, ESEND_LEVEL_ZERO);/*¼崻*/ + break; + } + else + { + ;/*ʽ*/ + } + } + else + { + ;/*ǰ߼߼ս·*/ + } + } + + if (chPhyIncLogSum == ii) + { + chReval = CI_SUCCESS; + } + else + { + chReval = CI_ERROR; + } + } + else + { + ; /**/ + } + } + return chReval; +} + +/* +* ֵ߼Ƿ +* ˵ const UINT8 cSeqNum +* const UINT8 pSeqIncLogSecNum[] а߼ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* Created By LQ 2023/10/12 +*/ +UINT8 SeqNumAndIncLogSecNumCheck(const UINT8 cSeqNum, const UINT8 pSeqIncLogSecNum[]) +{ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0U; + + if ((ROUTE_SUBROUTE_SUM_MAX > cSeqNum) && (NULL != pSeqIncLogSecNum)) + { + if (0U != cSeqNum) + { + for (ii == 0U; ii < cSeqNum; ii++) + { + if ((MAX_ROUTE_IN_LT_NUM > pSeqIncLogSecNum[ii])) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; /*Խ磬ʧ*/ + break; + } + } + } + else + { + retVal = CI_SUCCESS; /*Ϊ0سɹ*/ + } + } + else + { + /*ʧ*/ + } + + return retVal; +} + +/* +* Уָ̬·ӽ·ǷΪؽ· +* ˵ const UINT8 cIndex ӽ· +* const UINT16 pRouteId[] ӽ·ID +* const UINT16 pCTOccLogSecNum CT߼ +* const UINT16 pCTOccLogSecId[] CT߼ID +* const UINT8 cLogicRouteFlag һǷΪ߼·ı־ +* ֵ CI_ERROR ǰؽ· +* CI_SUCCESS ؽ· +* Created By LQ 2023/10/12 +*/ +UINT8 HalfRouteTypeCheck(const UINT8 cIndex, const UINT16 pRouteId[], const UINT16 pCTOccLogSecNum, const UINT16 pCTOccLogSecId[], const UINT8 cLogicRouteFlag) +{ + UINT8 retVal = CI_ERROR; + UINT16 i = 0U; + UINT16 j = 0U; + UINT16 cRouteIncLogSecSum = 0U; /*·߼*/ + UINT16* pRouteIncLogSecIdBuff = NULL; /*·߼ID*/ + UINT8 cCTOccFlag = FLAG_UNSET; /*гռѹ־ʼΪ޳ռѹ*/ + + if ((ROUTE_SUBROUTE_SUM_MAX > cIndex) && (NULL != pRouteId) && (SIZE_MAX_SECTION_BT_TRAIN > pCTOccLogSecNum) && (NULL != pCTOccLogSecId) + && ((FLAG_SET == cLogicRouteFlag) || (FLAG_UNSET == cLogicRouteFlag))) + { + /*жϽ·Ƿгռѹ*/ + if (0U != pCTOccLogSecNum) + { + cRouteIncLogSecSum = GetRouteLogSectionSum(pRouteId[cIndex]); + pRouteIncLogSecIdBuff = GetRouteLogSectionIdBuf(pRouteId[cIndex]); + for (i = 0U; i < cRouteIncLogSecSum; i++) + { + for (j = 0U; j < pCTOccLogSecNum; j++) + { + if (pRouteIncLogSecIdBuff[i] == pCTOccLogSecId[j]) + { + cCTOccFlag = FLAG_SET; /*гռѹϱ־*/ + break; + } + else + { + cCTOccFlag = FLAG_UNSET; + } + } + + if (FLAG_SET == cCTOccFlag) + { + break; /*гռѹֹͣ*/ + } + else + { + /**/ + } + } + } + else + { + cCTOccFlag = FLAG_UNSET; + } + + if (0U != cIndex) + { + if (FLAG_UNSET == cCTOccFlag) + { + retVal = CI_ERROR; /*޳ռѹƥĽ·ӦΪӽ·*/ + } + else + { + retVal = CI_SUCCESS; /*гռѹƥĽ·ӦΪӽ·*/ + } + + } + else + { + if ((FLAG_SET == cLogicRouteFlag) && (FLAG_UNSET == cCTOccFlag)) + { + retVal = CI_ERROR; /*һΪ߼·޳ռѹʱƥ·ӦΪӽ·*/ + } + else + { + retVal = CI_SUCCESS; /*һз߼·гռѹʱƥ·ӦΪӽ·*/ + } + } + } + else + { + /*ηǷ*/ + } + + return retVal; +} + +/* +* ΰ߼߼״̬ЧԼ +* ˵ const UINT16 overlapId ID +* const UINT16 routeId η·ID +* UINT16 *pDevId 豸Idأ +* UINT8 *pDevState 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* Created By LQ 2023/10/14 +*/ +UINT8 OverlapLogSecLogicLockCheck(const UINT16 overlapId, const UINT16 routeId, UINT16* pDevId, UINT8* pDevState) +{ + UINT8 reVal = CI_ERROR; + UINT8 i = 0U; + UINT8 j = 0U; + UINT16 wLogSecId = 0U; + UINT8 wLogSecLogicLockState = 0U; /*߼߼״̬*/ + UINT8 cLogSecLogicLockDir = 0U; /*߼߼շ*/ + UINT8 cLogicLockBelongRouteNum = 0U; /*߼߼·*/ + UINT8 cChangeInRoute = 0U; /*·еķ仯־*/ + UINT8 cChangeAfterRoute = 0U; /*·뱣μķ仯־*/ + UINT8 cRouteDir = 0U; /*·*/ + UINT8 cOverlapIncPhySecNum = 0U; /*ΰ*/ + UINT16* pOverlapIncPhySecId = NULL; /*ΰID*/ + UINT8 wPhySecIncLogSecNum = 0U; /*ΰ߼*/ + UINT16* pPhySecIncLogSecID = NULL; /*ΰ߼ID*/ + + if ((0U < overlapId) && (OVERLAP_SUM_MAX > overlapId) && (0U < routeId) && (ROUTE_SUM_MAX > routeId) && (NULL != pDevId) && (NULL != pDevState)) + { + cOverlapIncPhySecNum = GetOverlapPhySecSum(overlapId); + pOverlapIncPhySecId = GetOverlapPhySecIdBuf(overlapId); + + if ((0U != cOverlapIncPhySecNum) && (NULL != pOverlapIncPhySecId)) + { + /*ȡ·Ƿз仯*/ + cRouteDir = GetRouteDirection(routeId); + cChangeInRoute = GetRouteHaveDirChangePointIn(routeId); + cChangeAfterRoute = GetRouteHaveDirChangePointAfter(routeId); + + /*У鱣߼Ρδ߼ա·ͬġ߼ա*/ + for (i = 0U; i < cOverlapIncPhySecNum; i++) + { + wPhySecIncLogSecNum = GetPhySecIncLogSecSum(pOverlapIncPhySecId[i]); + pPhySecIncLogSecID = GetPhySecIncLogSecIdBuf(pOverlapIncPhySecId[i]); + + if ((0U != wPhySecIncLogSecNum) && (NULL != pPhySecIncLogSecID)) + { + for (j = 0U; j < wPhySecIncLogSecNum; j++) + { + wLogSecId = pPhySecIncLogSecID[j]; + wLogSecLogicLockState = GetLogSecLogLockState(wLogSecId); + cLogicLockBelongRouteNum = GetLogSecLockBelLogRouteSum(wLogSecId); + + if ((LOG_SECTION_LOGLOCK_NO == wLogSecLogicLockState) && (0U == cLogicLockBelongRouteNum)) + { + reVal = CI_SUCCESS; /*δ߼߼·Ϊ0سɹ*/ + } + else if (LOG_SECTION_LOGLOCK_NORMAL == wLogSecLogicLockState) + { + /*߼ʱ·޷仯շ·ͬ򣨽·з仯շ·ͬسɹ*/ + cLogSecLogicLockDir = GetLogSecLogLockDir(wLogSecId); + if (((((ROUTE_HAVE_DIR_CHANGE_POINT != cChangeInRoute) && (ROUTE_HAVE_DIR_CHANGE_POINT != cChangeAfterRoute)) && (cRouteDir == cLogSecLogicLockDir)) + || (((ROUTE_HAVE_DIR_CHANGE_POINT == cChangeInRoute) || (ROUTE_HAVE_DIR_CHANGE_POINT == cChangeAfterRoute)) && (cRouteDir != cLogSecLogicLockDir))) + && (CI_ERROR != cRouteDir) && (CI_ERROR != cLogSecLogicLockDir)) + + { + reVal = CI_SUCCESS; + } + else + { + *pDevId = wLogSecId; + *pDevState = wLogSecLogicLockState; + reVal = CI_ERROR; /*״̬Ƿ,ʧ*/ + } + } + else + { + *pDevId = wLogSecId; + *pDevState = wLogSecLogicLockState; + reVal = CI_ERROR; /*״̬Ƿ,ʧ*/ + } + + if (CI_ERROR == reVal) + { + break; /*߼μδֹͨͣ飬ʧ*/ + } + else + { + /**/ + } + } + } + else + { + /*ȡΰ߼ʧܣʧ*/ + } + + if (CI_ERROR == reVal) + { + break; /*߼μδֹͨͣ飬ʧ*/ + } + } + } + else + { + /*ȡΰʧܣʧ*/ + } + } + + return reVal; +} + +/* +* ·߼߼״̬ +* ˵ const UINT16 routeId ·ID +* UINT16 *pDevId 豸Idأ +* UINT8 *pDevState 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* Created By LQ 2023/10/14 +*/ +UINT8 RouteIncLogSecLogicLockCheck(const UINT16 routeId, UINT16* pDevId, UINT8* pDevState) +{ + UINT8 reVal = CI_ERROR; + UINT16 i = 0U; + UINT16 wLogSecId = 0U; + UINT16 cRouteIncLogSecNum = 0U; /*·߼*/ + UINT16* pRouteIncLogSecId = NULL; /*·߼ID*/ + UINT8 cLogicLockState = 0U; /*߼߼״̬*/ + UINT8 cLogicLockBelongRouteNum = 0U; /*߼߼·*/ + + if ((0U < routeId) && (ROUTE_SUM_MAX > routeId) && (NULL != pDevId) && (NULL != pDevState)) + { + cRouteIncLogSecNum = GetRouteLogSectionSum(routeId); + pRouteIncLogSecId = GetRouteLogSectionIdBuf(routeId); + + if ((0U != cRouteIncLogSecNum) && (NULL != pRouteIncLogSecId)) + { + for (i = 0U; i < cRouteIncLogSecNum; i++) + { + wLogSecId = pRouteIncLogSecId[i]; + cLogicLockState = GetLogSecLogLockState(wLogSecId); /*ȡ߼߼״̬*/ + cLogicLockBelongRouteNum = GetLogSecLockBelLogRouteSum(wLogSecId); /*ȡ߼߼·*/ + + /*߼δ߼߼·Ϊ0سɹ򷵻ʧ*/ + if ((LOG_SECTION_LOGLOCK_NO == cLogicLockState) && (0U == cLogicLockBelongRouteNum)) + { + reVal = CI_SUCCESS; + } + else + { + *pDevId = wLogSecId; + *pDevState = cLogicLockState; + reVal = CI_ERROR; /*߼δ߼գֹͣʧ*/ + } + + if (CI_ERROR == reVal) + { + break; /*߼μδֹͨͣ飬ʧ*/ + } + else + { + /**/ + } + } + } + else + { + /*ȡ·ʧܣʧ*/ + } + } + else + { + /*ηǷʧ*/ + } + + return reVal; +} + + +/* +* ȡ߼гϢ +* ˵ UINT16 wLogSectionId +* ֵ г +* By LC 20231116 +*/ +UINT8 GetLogSecTrainId(const UINT16 wLogSectionId, UINT16 * trainIdbuff) +{ + UINT8 cLogSecLinkSum = 0u; /*߼ΰLink*/ + UINT16* cLogSecLinkBuf = NULL; + UINT8 i = 0U; + UINT8 j = 0U; + UINT8 k = 0U; + TRAIN_SEQUANCE_s strTmp[SIZE_MAX_TRAINOFAC] = { 0u }; /*linkϵг*/ + UINT8 tmpTrainNum = 0U; + UINT8 trainCount = 0U; + + + cLogSecLinkSum = GetSecIntrudeLinkSum(wLogSectionId); + cLogSecLinkBuf = GetSecIntrudeLinkIdBuf(wLogSectionId); + if ((NULL != cLogSecLinkBuf) && (LOGSEC_INCLUDE_LINK_SUM_MAX > cLogSecLinkSum)) + {/*ȡ߼г*/ + for (i = 0u; i < cLogSecLinkSum; i++) + { + tmpTrainNum = as_GetLinkTrainNum(cLogSecLinkBuf[i]); + + /*ȡLinkгϢ*/ + tmpTrainNum = as_GetLinkTrainList(cLogSecLinkBuf[i], strTmp, SIZE_MAX_TRAINOFAC); + if (0u != tmpTrainNum) + { + for (j = 0U; j < tmpTrainNum; j++) + { + trainIdbuff[trainCount] = strTmp[j].u16TrainID; + trainCount++; + } + } + } + } + return trainCount; +} +/* +* ߼ι豸 +* ˵ UINT16 const wLgcId, ߼ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* +*/ +UINT8 LogicContactLineDevCheck(UINT16 const wLgcId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 wLgcSecContactLineCheckSum = 0U; + LogsecContacSwitchStruct *pLgcSecContactSwitchCheck = NULL; + UINT16 *pLogContactAxisCheckData = NULL; + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + wLgcSecContactLineCheckSum = GetLgcSecContactLineCheckSum(wLgcId); + pLgcSecContactSwitchCheck = GetLgcSecContactSwitchCheckStru(wLgcId); + pLogContactAxisCheckData = GetLogContactAxisCheckData(wLgcId); + + if ((NULL != pLgcSecContactSwitchCheck) && (NULL != pLogContactAxisCheckData)) + { + if (0U == wLgcSecContactLineCheckSum) + { + chRetVal = CI_SUCCESS; /*豸سɹ*/ + } + else + { + chRetVal = CI_SUCCESS; + for (ii = 0U; ii < wLgcSecContactLineCheckSum; ii++) + { + /*ߵǷ*/ + if (0U != pLgcSecContactSwitchCheck[ii].ContactSwitchId) + { + chRetVal = CheckLogContactSwitchState(pLgcSecContactSwitchCheck[ii].ContactSwitchId, pLgcSecContactSwitchCheck[ii].ContactSwitchCheckState, &devId, &devState); + } + + /*ߵռѹǷ*/ + if (CI_SUCCESS == chRetVal) + { + if (0U != pLogContactAxisCheckData[ii]) + { + chRetVal = CheckLogContactOccState(pLogContactAxisCheckData[ii], &devId, &devState); + } + + if (CI_ERROR == chRetVal) + { + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + } + + if (CI_ERROR == chRetVal) + { + break; /*ֲ㼴*/ + } + } + } + } + else + { + ; /*߼βϷʧ*/ + } + + return chRetVal; +} + +/* +* ߼ιߵ(ͬߵ) +* ˵ UINT16 const wSwitchId, ID +* UINT8 const wState ״̬ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* +*/ +UINT8 CheckLogContactSwitchState(UINT16 const wSwitchId,UINT8 const wState, UINT16 *pDevId, UINT8 *pDevState) +{ + UINT8 switchDsState = 0u; + UINT8 switchBypassState = 0u; + UINT8 switchPosState = 0u; + UINT8 chRetVal = CI_ERROR; + + if ((OTHER_CI_CONNECT_SWITCH_YES == wState) || (OTHER_CI_CONNECT_SWITCH_NODSUO_YES == wState) || (OTHER_CI_CONNECT_SWITCH_NO == wState)) + { + switchDsState = GetConnetSwitchDsState(wSwitchId); + switchBypassState = GetConnetSwitchByPassState(wSwitchId); + switchPosState = GetSwitchCurPosition(wSwitchId); + if (OTHER_CI_CONNECT_SWITCH_YES == wState) + { + /*·*/ + if (SWITCH_BYPASS_YES == switchBypassState) + { + chRetVal = CI_SUCCESS; + } + else + { + /*Ҷλ״̬*/ + if ((CONNECT_SWITCH_DANSUO_YES == switchDsState) && (SWITCH_POSITION_DINGWEI == switchPosState)) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + } + else if (OTHER_CI_CONNECT_SWITCH_NODSUO_YES == wState) + { + /*·*/ + if (SWITCH_BYPASS_YES == switchBypassState) + { + chRetVal = CI_SUCCESS; + } + else + { + /*λ״̬*/ + if (SWITCH_POSITION_DINGWEI == switchPosState) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + } + else + { + /**/ + } + } + + if (CI_ERROR == chRetVal) + { + /* ¼ */ + *pDevId = wSwitchId; + *pDevState = switchPosState; + } + + return chRetVal; +} + +/* +* ߼ιռѹ(ͬռѹ) +* ˵ UINT16 const wAxisId, ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* +*/ +UINT8 CheckLogContactOccState(UINT16 const wAxisId, UINT16 *pDevId, UINT8 *pDevState) +{ + UINT16 wPhySecId = 0U; + UINT8 wPhySecOccState = 0u; + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0u; + UINT8 axisSwitchSum = 0u; + AxisSwitchStruct* axisSwitchStru = NULL; + UINT8 switchBypassState = 0u; + UINT8 switchCurPosition = 0u; + UINT8 switchContactFlag = CI_SUCCESS; + UINT8 devIsThisLine = 0u; /*豸Ƿ񱾽·*/ + + wPhySecId = GetAxisSecRelativePhySecId(wAxisId); + wPhySecOccState = GetPhySecCurMergeState(wPhySecId); + + /*صռ״̬*/ + if (SECTION_OCCUPY_YES == wPhySecOccState) + { + axisSwitchSum = GetAxisSwitchSum(wAxisId); + axisSwitchStru = GetAxisSwitchIdStru(wAxisId); + if ((0u != axisSwitchSum) && (NULL != axisSwitchStru)) + { + for (ii = 0u; ii < axisSwitchSum; ii++) + { + devIsThisLine = GetSwitchIsThisLineState(axisSwitchStru[ii].SwitchId); + if (DEV_IS_THIS_LINE_NO == devIsThisLine) + { + switchBypassState = GetConnetSwitchByPassState(axisSwitchStru[ii].SwitchId); + if (SWITCH_BYPASS_YES == switchBypassState) + { + switchContactFlag = CI_ERROR; /*Էռѹ·*/ + } + else + { + switchContactFlag = CI_SUCCESS; /*Էռѹδ·Ҫ*/ + } + } + else + { + switchContactFlag = CI_SUCCESS; /*豸Ϊ豸,Ҫռѹ*/ + } + + if (CI_SUCCESS == switchContactFlag) + { + break; /*DZ·ߵδȫ·ģҪеǷ*/ + } + } + + for (ii = 0u; ii < axisSwitchSum; ii++) + { + if (CI_SUCCESS == switchContactFlag) + { + switchCurPosition = GetSwitchCurPosition(axisSwitchStru[ii].SwitchId); + if ((axisSwitchStru[ii].SwitchPosition == switchCurPosition) || + (SWITCH_POSITION_SIKAI == switchCurPosition) || (SWITCH_POSITION_MOVE == switchCurPosition) + || (SWITCH_POSITION_JICHA == switchCurPosition)) + {/*жϵǰĵλǰλǷͬ,ĵΪĿƶ*/ + chRetVal = CI_ERROR; + } + else + { + chRetVal = CI_SUCCESS; + break; + } + } + else + { + chRetVal = CI_SUCCESS; + break; + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else if (SECTION_OCCUPY_NO == wPhySecOccState) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_ERROR == chRetVal) + { + /* ¼ */ + *pDevId = wPhySecId; + *pDevState = wPhySecOccState; + } + return chRetVal; +} + +/* +* ÷Źг +* ˵ UINT16 floodGateId ID +* ֵ CI_ERROR +* CI_SUCCESS CT +*/ +UINT8 SetFloodGateAcCloseApplyProc(UINT16 floodGateId) +{ + UINT16 axisSum = 0u; + UINT16 *pAxisIdBuf = NULL; + UINT8 reResult = CI_ERROR; + UINT16 axisId = 0u; /*ID*/ + UINT16 phyId = 0U; /*ID*/ + UINT8 phyOccupyState = 0u;/*ʱռ״̬*/ + UINT16 ii = 0u; + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 mm = 0U; + UINT16 bufIndex = 0u; /*±*/ + UINT8 cAxisLinkSum = 0U; + UINT16 *pAxisLinkIdBuf = NULL; + UINT16 wAxisLinkId = 0U; + UINT8 linkIndex = 0U; + UINT8 chTrainSum = 0U; + TRAIN_SEQUANCE_s TrainList[FLOOD_GATE_APPLY_TRAIN_SUM_MAX] = { 0u }; + UINT8 chTrainIndex = 0U; + + UINT8 chTempTrainSum = 0U; /*ʱ洢*/ + UINT16 TempTrainIdBuf[FLOOD_GATE_APPLY_TRAIN_SUM_MAX] = { 0U }; + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + axisSum = GetFloodGateAccessAxisNum(floodGateId); + pAxisIdBuf = GetFloodGateAccessAxisIDBuf(floodGateId); + + if (NULL == pAxisIdBuf) + { + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + if (CI_SUCCESS == reResult) + { + SetFloodGateCloseApplyIvocSum(floodGateId, 0U); /*ȳ壬ֹѴڹ룬*/ + SetFloodGateCloseApplyIvocId(floodGateId, TempTrainIdBuf); + ClearFloodGateAllowClosFlagIVOC(floodGateId); /*һǰ֮ǰѾظг*/ + for (ii = 0u; ii < axisSum; ii++) + { + axisId = pAxisIdBuf[ii]; + phyId = GetAxisSecRelativePhySecId(axisId); /*ȡΣȡںռѹ*/ + if ((0U < axisId) && (0U < phyId)) + { + phyOccupyState = GetPhySecCurMergeState(phyId); + if (SECTION_OCCUPY_YES == phyOccupyState) + { + /*ȡΰİ磬ڷCT磬˵зͨųܣѭ*/ + cAxisLinkSum = GetAxisLinkSum(axisId); + pAxisLinkIdBuf = GetAxisLinkIdBuf(axisId); + if (NULL == pAxisLinkIdBuf) + { + reResult = CI_ERROR; + } + else + { + for (linkIndex = 0U; linkIndex < cAxisLinkSum; linkIndex++) + { + wAxisLinkId = pAxisLinkIdBuf[linkIndex]; + chTrainSum = as_GetLinkTrainList(wAxisLinkId, TrainList, FLOOD_GATE_APPLY_TRAIN_SUM_MAX); + if (0u != chTrainSum) + { + for (chTrainIndex = 0u; chTrainIndex < chTrainSum; chTrainIndex++) + { + if (TYPE_CT == TrainList[chTrainIndex].u8TrainType) + { + for (kk = 0U; kk < chTempTrainSum; kk++) + { + if (TempTrainIdBuf[kk] == TrainList[chTrainIndex].u16TrainID) + { + break; /*Ѿӹгӣȥ*/ + } + else + { + + } + } + if (kk == chTempTrainSum) + { + TempTrainIdBuf[chTempTrainSum] = TrainList[chTrainIndex].u16TrainID; /*гIDʱ洢ռ*/ + chTempTrainSum++; + } + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + break; /*سѭ*/ + } + } + } + + if (CI_ERROR == reResult) + { + break; /*linkسѭٲһlink*/ + } + } + } + if (CI_ERROR == reResult) + { + break; /*ּܣѭػܣٲһ*/ + } + } + else + { + reResult = CI_SUCCESS; + } + } + } + + if (CI_SUCCESS == reResult) + { + SetFloodGateCloseApplyIvocSum(floodGateId, chTempTrainSum); /*нӽļᶼѯسʱҪг͵ID*/ + SetFloodGateCloseApplyIvocId(floodGateId, TempTrainIdBuf); + } + } + + return reResult; +} + + +/* +* ȡŹгظ +* ˵ UINT16 floodGateId ID +* ֵ CI_ERROR ͬ +* CI_SUCCESS ͬ +*/ +UINT8 GetFloodGateAccessCloseAskIVOC(UINT16 floodGateId) +{ + UINT8 reResult = CI_ERROR; + UINT8 wTrainSum = 0U; + UINT16 *pTrainIdBuf = NULL; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT16 chTrainID = 0U; + UINT8 FloodGateCloseFromIvocSum = 0U; + FloodGateTrainAnsStruct *pFloodGatteAnsFromIvoc = NULL; + UINT8 wTrainAnsFlag = 0U; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetFloodGateBufIndex(floodGateId); /*ȡ±*/ + wTrainSum = GetFloodGateCloseApplyIvocSum(floodGateId); + pTrainIdBuf = GetFloodGateCloseApplyIvocId(floodGateId); + pFloodGatteAnsFromIvoc = GetFloodGateCloseFromIvocStru(floodGateId); + FloodGateCloseFromIvocSum = GetFloodGateCloseAnsIvocSum(floodGateId); + + if ((0U < FloodGateCloseFromIvocSum) && (0U < wTrainSum) && (NULL != pTrainIdBuf) && (NULL != pFloodGatteAnsFromIvoc)) + { + for (ii = 0U; ii < wTrainSum; ii++) + { + chTrainID = pTrainIdBuf[ii]; + + for (jj = 0U; jj < FloodGateCloseFromIvocSum; jj++) + { + if (chTrainID == pFloodGatteAnsFromIvoc[jj].wTrainId) + { + wTrainAnsFlag = pFloodGatteAnsFromIvoc[jj].wFloodGateCloseIvocFlag; + if (FLOOD_GATE_ALLOWCLOSE_IVOC == wTrainAnsFlag) + { + reResult = CI_SUCCESS; + break; + } + else + { + reResult = CI_ERROR; /*һгδظ򲻿ͬ*/ + } + } + else + { + reResult = CI_ERROR; /*δ鵽лظг֮ǰһ£ʧ*/ + } + } + + if (CI_ERROR == reResult) + { + break; /*ٲһг*/ + } + } + } + + return reResult; +} + +/* +* ߼ڷ +* ˵ +* UINT16 wLogicSecId, ߼α +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 FloodGateCheck(UINT16 wLogicSecId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; + UINT16 wPhySecId = 0U; /*ID*/ + UINT16 jj = 0U; + UINT16 floodGateSum = 0U; /**/ + UINT16* floodGateIdBuf = NULL;/*ʱ*/ + UINT16 wFloodGateId = 0U; /*ID*/ + UINT8 floodState = 0u;/*״̬*/ + UINT8 FSwitchFlagOpenLock = 0U; + UINT8 FSwitchFlagCloseReq = 0U; + + FSwitchFlagOpenLock = GetCiFunctionSwitchConfig(FUNC_FLOODGATE_NO_OPEN_LOCK_CHECK); + FSwitchFlagCloseReq = GetCiFunctionSwitchConfig(FUNC_FLOODGATE_NO_CLOSE_REQ_CHECK); + wPhySecId = GetLgcSecRelativePhySecId(wLogicSecId); /*ȡ߼ID*/ + if (0U < wPhySecId) + { + floodGateSum = GetPhySecLocatedFloodSum(wPhySecId); /*Ϊ0˵ûзţ飬ɷسɹ*/ + if (0U < floodGateSum) + { + floodGateIdBuf = GetPhySecLocatedFloodId(wPhySecId); + if (NULL != floodGateIdBuf) + { + for (jj = 0U; jj < floodGateSum; jj++) + { + wFloodGateId = floodGateIdBuf[jj]; + /*1ſ״̬Ϊ*/ + if (FUNC_SWITCH_ON == FSwitchFlagOpenLock) + { + reResult = CI_SUCCESS; + } + else + { + floodState = GetFloodGateCurOpenLockState(wFloodGateId); + if (FLOOD_GATE_OPENLOCK == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, ETYPE_FLOODGATE_OPENLOCKSTATE, floodState, sendLevel); + } + } + + /*2Ź״̬Ϊδ*/ + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == FSwitchFlagCloseReq) + { + ; /**/ + } + else + { + floodState = GetFloodGateCurCloseRequestSta(wFloodGateId); + if (FLOOD_GATE_NOT_CLOSEREQ == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, ETYPE_FLOODGATE_CLOSEREQSTATE, floodState, sendLevel); + } + } + } + + /*3ŵǰͬ״̬Ϊͬ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurAgreeCloseSta(wFloodGateId); + if (FLOOD_GATE_NOT_AGREE_CLOSE == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, ETYPE_FLOODGATE_AGREECLOSESTATE, floodState, sendLevel); + } + } + + if (CI_SUCCESS != reResult) + { + break; /*һŲERROR*/ + } + } + } + else + { + reResult = CI_ERROR; /*ȡʧܣʧ*/ + } + } + else + { + reResult = CI_SUCCESS;/*߼ιβIDسɹ*/ + } + } + return reResult; +} + +/* +* ߼μ·CBTC +* ˵ const UINT16 wLogSecId ߼ID +* UINT8* pDevState 豸״̬ +* ֵ CI_ERROR 0 CBTC +* CI_SUCCESS 1 CBTC +* Created By LQ 2023.12.08 +*/ +UINT8 CheckLogSecCbtcProperty(const UINT16 wLogSecId, UINT8* pDevState) +{ + UINT8 retVal = CI_ERROR; + UINT8 cLogSecCbtcProperty = LOGSEC_CBTC_PROPERTY_NO; /*߼CBTC*/ + UINT16 wLogSecRLockRouteId = 0U; /*߼ν··ID*/ + UINT16 wLogSecPLockRouteId = 0U; /*߼η·ID*/ + UINT8 cRouteCbtcProperty = ROUTE_CBTC_PROPERTY_NO; /*··CBTC*/ + + if ((0U != wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId) && (NULL != pDevState)) + { + retVal = CI_SUCCESS; + wLogSecRLockRouteId = GetLogSecLockBelongRoute(wLogSecId); + wLogSecPLockRouteId = GetLogSecPLockRouteId(wLogSecId); + + if ((0U < wLogSecRLockRouteId) && (ROUTE_SUM_MAX > wLogSecRLockRouteId)) + { + cLogSecCbtcProperty = GetLogSecCbtcProperty(wLogSecId); + if (LOGSEC_CBTC_PROPERTY_YES == cLogSecCbtcProperty) + { + /*߼ν··CBTC*/ + cRouteCbtcProperty = GetRouteCbtcProperty(wLogSecRLockRouteId); + if (ROUTE_CBTC_PROPERTY_YES == cRouteCbtcProperty) + { + /*·CBTCԣسɹ*/ + } + else + { + retVal = CI_ERROR; /*߼ν··CBTCԣʧ*/ + } + } + else + { + retVal = CI_ERROR; /*߼βCBTCԣʧ*/ + } + } + else if ((0U < wLogSecPLockRouteId) && (ROUTE_SUM_MAX > wLogSecPLockRouteId)) + { + /*߼η·CBTC*/ + cRouteCbtcProperty = GetRouteCbtcProperty(wLogSecPLockRouteId); + if (ROUTE_CBTC_PROPERTY_YES == cRouteCbtcProperty) + { + /*·CBTCԣسɹ*/ + } + else + { + retVal = CI_ERROR; /*߼η·CBTCԣʧ*/ + } + } + else + { + retVal = CI_ERROR; + } + + *pDevState = cLogSecCbtcProperty; + } + else + { + /*ηǷʧ*/ + } + + return retVal; +} + +/* +* ߼·߼εCBTC +* ˵ const UINT8 wLogSecNum ߼·߼ +* const UINT16 pLogSecId[MAX_ROUTE_IN_LT_NUM] ߼·߼ID +* ֵ CI_ERROR 0 CBTC +* CI_SUCCESS 1 CBTC +* Created By LQ 2023.12.08 +*/ +UINT8 CheckLogicRouteCbtcProperty(const UINT8 wLogSecNum, const UINT16 pLogSecId[MAX_ROUTE_IN_LT_NUM]) +{ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 cLogSecCbtcProperty = LOGSEC_CBTC_PROPERTY_NO; /*߼CBTC*/ + UINT16 wLogSecRLockRouteId = 0U; /*߼ν··ID*/ + UINT16 wLogSecPLockRouteId = 0U; /*߼η·ID*/ + UINT8 cRouteCbtcProperty = ROUTE_CBTC_PROPERTY_NO; /*··CBTC*/ + + if ((0U != wLogSecNum) && (MAX_ROUTE_IN_LT_NUM > wLogSecNum) && (NULL != pLogSecId)) + { + retVal = CI_SUCCESS; + + for (ii = 0U; ii < wLogSecNum; ii++) + { + /*߼εCBTC*/ + cLogSecCbtcProperty = GetLogSecCbtcProperty(pLogSecId[ii]); + if (LOGSEC_CBTC_PROPERTY_YES == cLogSecCbtcProperty) + { + /**/ + } + else + { + retVal = CI_ERROR; /*߼ηCBTCԣֹͣʧ*/ + break; + } + } + } + else + { + /*ηǷʧ*/ + } + + return retVal; +} + +/* +* ·;۷ · +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCLE_ROUTE +* BY LC +*/ +UINT8 CheckRouteZhefanJiesuo(UINT16 const routeId) +{ + /**/ + UINT8 const functionId = EFUNC_ROUTE_ZHONGTUZHEFAN_UNLOCK; + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 routepreState = 0u; /*·״̬*/ + UINT16 cancleZhaoChaRelayId = 0u; /*ȡղ̵ID*/ + UINT8 relayState = 0u; /*̵ɼ״̬*/ + + UINT8 sendLevel = ESEND_LEVEL_ATS; /*ATS*//*Ϸͼ*/ + UINT8 chRouteLevel = 0U; + UINT8 cRouteType = 0U; /*·*/ + UINT8 routeState = 0U; /*·״̬*/ + UINT16 startSignalId = 0U; /*·ʼźŻID*/ + UINT8 cSignalColor = 0U; /*·ʼźŻǰɫ*/ + UINT8 cSignalOpenState = 0U; /*·ʼźŻ״̬*/ + + /**/ + + /*·ʼźŻر*/ + startSignalId = GetRouteStartSignalId(routeId); + cSignalColor = GetSignalCurColor(startSignalId); + cSignalOpenState = GetSignalOpenCloseState(cSignalColor); + if (SIGNAL_CLOSE == cSignalOpenState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + devId = startSignalId; + devState = cSignalOpenState; + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_SIG_START_OPEN_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + + /*·״̬Ϊӽ쳣*/ + if (CI_SUCCESS == reResult) + { + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + if (ROUTE_STATE_NEAR_LOCKERR == routeState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + devId = routeId; + devState = routeState; + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·ռѹ(ǵ)*/ + if (CI_SUCCESS == reResult) + { + cRouteType = GetRouteType(routeId); /*ȡ·*/ + if (ROUTE_TYPE_DIAOCHE != cRouteType) + { + /* ·ռ״̬С*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + devId = routeId; + devState = cRouteType; + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel); + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + chRouteLevel = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(routeId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if ((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + devId = cancleZhaoChaRelayId; + devState = relayState; + if (RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_RELAY, devId, ETYPE_CANCLE_ZHAOCHA, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + else + { + } + } + else + { + } + + return reResult; +} + + +/* +* ιΰķDZڵ߼ռ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +* BY LC +*/ +UINT8 CheckOverlapPhysecOtherLock(UINT16 const overlapId, UINT16* pDevId, UINT8* pDevState) +{ + UINT16 dataIdBuf[OVLP_LOGICSECTION_SUM_MAX] = { 0U }; /*DZڵ߼*/ + UINT8 checkSum = 0U; /*DZڵ߼*/ + UINT8 i = 0U; + UINT8 reVal = CI_ERROR; + UINT8 lockState = 0U; /*߼α·״̬*/ + UINT8 logLockState = 0U; /*߼α߼·״̬*/ + UINT8 logLockBelongRouteNum = 0U; + + + if ((0U < overlapId) && (OVERLAP_SUM_MAX > overlapId) + && (NULL != pDevId) && (NULL != pDevState)) + { + /*ȡιΰķDZڵ߼*/ + reVal = GetOverlapPhysecOtherLogSec(overlapId, &dataIdBuf,&checkSum); + if (CI_SUCCESS == reVal) + { + if (0u == checkSum) + { + /*޼,سɹ*/ + } + else + { + /*DZڵ߼*/ + for (i = 0U; i < checkSum; i++) + { + lockState = GetLogSecLockState(dataIdBuf[i]); + logLockState = GetLogSecLogLockState(dataIdBuf[i]); + logLockBelongRouteNum = GetLogSecLockBelLogRouteSum(dataIdBuf[i]); /*ȡ߼߼߼·*/ + + if ((LOG_SECTION_LOCK_NO == lockState) && (LOG_SECTION_LOGLOCK_NO == logLockState) && (0U == logLockBelongRouteNum)) + { + /* δδ߼߼·Ϊ0سɹ */ + } + else + { + /*״̬*/ + *pDevId = dataIdBuf[i]; + if (LOG_SECTION_LOCK_NO == lockState) + { + *pDevState = logLockState; + } + else + { + *pDevState = lockState; + } + + reVal = CI_ERROR; + break; + } + } + } + } + else + { + /*ȡ߼ʧ*/ + } + } + else + { + /*μ鲻ͨ*/ + } + return reVal; +} + +/* +* β +* ˵UINT16 const overlapId, OverlapID +* UINT16* pDevId 豸Idأ +* UINT8* pDevState 豸״̬أ +* ֵ 0 ʧ +* 1 ɹ +* Created By LQ 2024.01.05 +*/ +UINT8 OverlapLateralDfnCheck(UINT16 const overlapId, UINT16* pDevId, UINT8* pDevState) +{ + UINT8 retVal = CI_ERROR; + UINT8 i = 0U; + UINT16 wLogSecId = 0U; + UINT8 cOvlpIncLogSecNum = 0U; /*ΰ߼*/ + UINT16* pOvlpIncLogSecId = NULL; /*ΰ߼ID*/ + + if ((0U != overlapId) && (OVERLAP_SUM_MAX > overlapId) && (NULL != pDevId) && (NULL != pDevState)) + { + cOvlpIncLogSecNum = GetOverlapLogicSectionSum(overlapId); + pOvlpIncLogSecId = GetOverlapLogicSectionBuf(overlapId); + + if ((0U != cOvlpIncLogSecNum) && (NULL != pOvlpIncLogSecId)) + { + /*鱣߼εIJǷ*/ + for (i = 0U; i < cOvlpIncLogSecNum; i++) + { + wLogSecId = pOvlpIncLogSecId[i]; + retVal = LogicSecSwitchLtrlDfncCheck(wLogSecId, pDevId, pDevState); + + if (CI_SUCCESS == retVal) + { + /*ͨ*/ + } + else + { + retVal = CI_ERROR; + break; + } + } + } + else + { + /*ȡΰ߼Ϣʧܣʧ*/ + } + } + else + { + /*ηǷʧ*/ + } + + return retVal; +} + +/* +* 鱣εCBTC +* ˵ const UINT16 wOverlapId ID +* ֵ CI_ERROR 0 CBTC +* CI_SUCCESS 1 CBTC +* Created By LQ 2024.02.20 +*/ +UINT8 CheckOverlapCbtcProperty(const UINT16 wOverlapId) +{ + UINT8 retVal = CI_ERROR; + UINT8 ii; + UINT8 cOverlapIncLogSecNum = 0U; /*ΰ߼*/ + UINT16* pOverlapIncLogSecId = NULL; /*ΰ߼ID*/ + UINT16 wLogSecPLockRouteId = 0U; /*߼η·ID*/ + UINT8 cRouteCbtcProperty = ROUTE_CBTC_PROPERTY_NO; /*·CBTC*/ + + if ((0U < wOverlapId) && (OVERLAP_SUM_MAX > wOverlapId)) + { + retVal = CI_SUCCESS; + cOverlapIncLogSecNum = GetOverlapLogicSectionSum(wOverlapId); + pOverlapIncLogSecId = GetOverlapLogicSectionBuf(wOverlapId); + + if ((0U < cOverlapIncLogSecNum) && (OVLP_LOGICSECTION_SUM_MAX > cOverlapIncLogSecNum) && (NULL != pOverlapIncLogSecId)) + { + /*鱣ΰ߼η·CBTC*/ + for (ii = 0U; ii < cOverlapIncLogSecNum; ii++) + { + wLogSecPLockRouteId = GetLogSecPLockRouteId(pOverlapIncLogSecId[ii]); /*ȡ߼η·ID*/ + if ((0U < wLogSecPLockRouteId) && (ROUTE_SUM_MAX > wLogSecPLockRouteId)) + { + cRouteCbtcProperty = GetRouteCbtcProperty(wLogSecPLockRouteId); + if (ROUTE_CBTC_PROPERTY_YES == cRouteCbtcProperty) + { + /*·CBTCԣ1ɹ*/ + } + else + { + retVal = CI_ERROR; /*߼η·CBTCԣ0ʧ*/ + } + } + else + { + retVal = CI_ERROR; /*δգ0ʧ*/ + } + + if (CI_SUCCESS != retVal) + { + retVal = CI_ERROR; + break; + } + else + { + /**/ + } + } + } + else + { + retVal = CI_ERROR; /*ȡΰ߼ʧܣ0ʧ*/ + } + } + else + { + /*ηǷ0ʧ*/ + } + + return retVal; +} + +#if 0 +/* +* ·Ƿͬ +* ˵ const UINT16 wSrcRouteId Դ·ID +* const UINT16 wSrcRouteId Ŀ·ID +* +* ֵ CI_ERROR ûص +* CI_SUCCESS ص +* BY CGH 20240320 +*/ +UINT8 CheckRoutePhySecSame(const UINT16 wSrcRouteId, const UINT16 wDstRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 chSrcRoutePhySecSum = 0U;/*Դ·Ŀ*/ + RoutePhysicalSectionStruct* pSrcPhySecData = NULL;/*Դ·Ϣ*/ + UINT8 chDstRoutePhySecSum = 0U;/*Ŀ·Ŀ*/ + RoutePhysicalSectionStruct* pDstPhySecData = NULL;/*Ŀ·Ϣ*/ + UINT8 checkFlag = 0U; + + if ((0U < wSrcRouteId) && (ROUTE_SUM_MAX > wSrcRouteId) && (0U < wDstRouteId) && (ROUTE_SUM_MAX > wDstRouteId)) + { + chSrcRoutePhySecSum = GetRoutePhysicalSectionSum(wSrcRouteId); + pSrcPhySecData = GetRouteSectionData(wSrcRouteId); + + if (NULL != pSrcPhySecData) + { + for (ii = 0U; ii < chSrcRoutePhySecSum; ii++) + { + chDstRoutePhySecSum = GetRoutePhysicalSectionSum(wDstRouteId); + pDstPhySecData = GetRouteSectionData(wDstRouteId); + for (jj = 0U; jj < chDstRoutePhySecSum; jj++) + { + if (pSrcPhySecData[ii].PhysicalSectionId == pDstPhySecData[jj].PhysicalSectionId) + { + chRetVal = CI_SUCCESS; + checkFlag = 1U; + } + else + { + ; /**/ + } + if (1U == checkFlag) + { + break; + } + else + { + ; /**/ + } + } + if (1U == checkFlag) + { + break; + } + else + { + ; /**/ + } + } + } + else + { + ; + } + + } + else + { + ; /*У鲻Ϸ*/ + } + + return chRetVal; +} +#endif + +/* +* ߼ǷΪг߼μ +* ˵ wLogSecId ߼ID +* const UINT16 wRouteId ·ID +* ֵ CI_ERROR Ϊг߼ +* CI_SUCCESS Ϊг߼ +* BY CGH 20240325 +*/ +UINT8 TrainRelateLogSecCheck(const UINT16 wLogSecId, const UINT16 wRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 szItsRouteAppTrainId = 0U;/*ATS벿·гID*/ + UINT8 chTrainDir = 0U; /*гз*/ + struct_PathPoint start = { 0U }; /*г߼*/ + struct_PathPoint end = { 0U }; /*г߼յ*/ + UINT16 wTrainOccLogSum = 0U; /*г߼*/ + UINT16 wTrainOccLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*гռѹ߼ID*/ + UINT16 jj = 0U; + + if ((0U < wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId) && (0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + szItsRouteAppTrainId = GetHalfRouteResReqTrainId(wRouteId); + + if (0U != szItsRouteAppTrainId) + { + chRetVal = CI_SUCCESS; + chTrainDir = GetTrainDir(szItsRouteAppTrainId); + + if (DIR_SAME == chTrainDir) + { + /* г߼ */ + end.wLinkId = GetTrainMaxHeadLink(szItsRouteAppTrainId); + end.dwOffset = GetTrainMaxHeadOffset(szItsRouteAppTrainId); + start.wLinkId = GetTrainMinTailLink(szItsRouteAppTrainId); + start.dwOffset = GetTrainMinTailOffset(szItsRouteAppTrainId); + } + else if (DIR_CONVERT == chTrainDir) + { + /* г߼ */ + start.wLinkId = GetTrainMaxHeadLink(szItsRouteAppTrainId); + start.dwOffset = GetTrainMaxHeadOffset(szItsRouteAppTrainId); + end.wLinkId = GetTrainMinTailLink(szItsRouteAppTrainId); + end.dwOffset = GetTrainMinTailOffset(szItsRouteAppTrainId); + } + else + { + chRetVal = CI_ERROR;/*쳣0ʧ*/ + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = GetLogSecBtwTwoPoints(start, end, &wTrainOccLogSum, wTrainOccLogID); + if (CI_SUCCESS == chRetVal) + { + if ((0U < wTrainOccLogSum) && (SIZE_MAX_SECTION_BT_TRAIN > wTrainOccLogSum)) + { + for (jj = 0U; jj < wTrainOccLogSum; jj++) + { + chRetVal = CI_ERROR; + if (wLogSecId == wTrainOccLogID[jj]) + { + /*ǰ߼ijһĽ߼μسɹ*/ + chRetVal = CI_SUCCESS; + break; + } + } + } + else + { + chRetVal = CI_ERROR; /*г߼Ƿʧ*/ + } + } + else + { + ; /*󣬷ʧ*/ + } + } + else + { + ; + } + } + else + { + ; /*ֻвֽ·ȴʱŻᵽ˺ʱгIDΪ0Ϸ*/ + } + + } + else + { + ; /*У鲻Ϸ*/ + } + + return chRetVal; +} + + +/* +* ·һȥ߼μ +* ˵ wLogSecId һȥ߼ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +* BY LC 20240710 +*/ +UINT8 RouteLeaveLogSecCheck(const UINT16 wLogSecId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16* wAxisIdBuff = NULL; + UINT8 const functionId = EFUNC_FIRSTLEAVE_LOGSEC_CHECK; + UINT8 leaveLogOccuState = 0U; + UINT8 acEnvelopeCount = 0u; /*ϰ*/ + EnvelopeStruct envelopeInfo[SECTION_REL_ENVELOPE_SUM_MAX] = { 0u };/*ϰϢ*/ + UINT8 i = 0U; + UINT8 ifCrossFlag = 0U; + str_Zone strZoneLogic = { 0u }; /*߼οռλ*/ + str_Zone strZoneEnvolop = { 0u }; /*ռλ*/ + + LOD_STRU strPointA = { 0u }; + LOD_STRU strPointB = { 0u }; + UINT32 dwLen = 0U; + UINT16 linkNum = 0U; + UINT8 crossCount = 0U; /*ڽİ*/ + EnvelopeStruct wCrossEnvolopInfo[SECTION_REL_ENVELOPE_SUM_MAX] = {0U}; /*ڽİ*/ + UINT16 tmpTrainId = 0U;/*егID*/ + UINT16* pLogSecIncLinkBuff = NULL; /*߼ΰlink ID*/ + UINT16 linkMaxHead = 0U; + UINT16 linkMinTail = 0U; + UINT32 offsetMaxHead = 0U; + UINT32 offsetMinTail = 0U; + UINT8 checkFlag = CI_ERROR; + + leaveLogOccuState = GetLogSecCurCtOrUtOccupyState(wLogSecId); + + /*߼*/ + wAxisIdBuff = GetLgcSecRltvAxleSecIdBuf(wLogSecId); + if (NULL != wAxisIdBuff) + { + /*ҸüεİϢ*/ + acEnvelopeCount = elm_GetEnvelopeInAC(wAxisIdBuff[0], envelopeInfo); + } + else + { + acEnvelopeCount = SECTION_REL_ENVELOPE_SUM_MAX; + } + /*ȡ߼εĿռλ*/ + strZoneLogic.pLinkSeq.cLinkCnt = GetSecIntrudeLinkSum(wLogSecId); + pLogSecIncLinkBuff = GetSecIntrudeLinkIdBuf(wLogSecId); + if (NULL != pLogSecIncLinkBuff) + { + for (i = 0U; i < strZoneLogic.pLinkSeq.cLinkCnt; i++) + { + strZoneLogic.pLinkSeq.szLinkId[i] = pLogSecIncLinkBuff[i]; + } + } + strZoneLogic.pStart.wLinkId = GetLgcSecOrgnLink(wLogSecId); + strZoneLogic.pStart.dwOffset = GetLgcSecOrgnOffset(wLogSecId); + strZoneLogic.pEnd.wLinkId = GetLgcSecTmnlLink(wLogSecId); + strZoneLogic.pEnd.dwOffset = GetLgcSecTmnlOffset(wLogSecId); + + + /*ȥ߼ο*/ + if (LOGICSECTION_OCCUPY_NO == leaveLogOccuState) + { + chRetVal = CI_SUCCESS; + } + /*ȥ߼οUTռѹ*/ + else if (LOGICSECTION_OCCUPY_UT == leaveLogOccuState) + { + checkFlag = CI_SUCCESS; + if (SECTION_REL_ENVELOPE_SUM_MAX != acEnvelopeCount) + { + /*еİ*/ + for (i = 0U; i < acEnvelopeCount; i++) + { + strZoneEnvolop.pStart.wLinkId = envelopeInfo[i].startPos.Lnk; + strZoneEnvolop.pStart.dwOffset = envelopeInfo[i].startPos.Off; + strZoneEnvolop.pEnd.wLinkId = envelopeInfo[i].endPos.Lnk; + strZoneEnvolop.pEnd.dwOffset = envelopeInfo[i].endPos.Off; + + strPointA.Lnk = strZoneEnvolop.pStart.wLinkId; + strPointA.Off = strZoneEnvolop.pStart.dwOffset; + strPointB.Lnk = strZoneEnvolop.pEnd.wLinkId; + strPointB.Off = strZoneEnvolop.pEnd.dwOffset; + dwLen = dsuLenByPoint(&strPointA, &strPointB, &linkNum, strZoneEnvolop.pLinkSeq.szLinkId, &strZoneEnvolop.Dir); + strZoneEnvolop.pLinkSeq.cLinkCnt = (UINT8)linkNum; + + if (UINT32_MAX != dwLen) + { + + ifCrossFlag = CheckZoneIsCrossing(&strZoneLogic, &strZoneEnvolop); + if (CI_ERROR == ifCrossFlag) + { + /*߼δڽ*/ + wCrossEnvolopInfo[crossCount] = envelopeInfo[i]; + crossCount++; + } + } + else + { + /*λüʧܣر־ERROR*/ + checkFlag = CI_ERROR; + } + + if ((1U < crossCount) || (CI_ERROR == checkFlag)) + { + /*ڽİ1ʧܣ*/ + break; + } + else + { + /**/ + } + } + + /*߼δڽİ1*/ + if ((1U != crossCount) || (CI_ERROR == checkFlag)) + { + /*ڽİ1ѯʧܣʧ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"CheckFirstLeaveLog ERROR: envelope on This LogicSec Number Is %d\n", crossCount); + + } + else + { + /*ΪUCTҲڿ */ + if ((TYPE_UCT_ENVELOPE != wCrossEnvolopInfo[0].envelopeType) || (LINE_MAX_TRAIN == wCrossEnvolopInfo[0].headTrainID) || (LINE_MAX_TRAIN == wCrossEnvolopInfo[0].tailTrainID)) + { + /*粻ΪUCT磬ΪUCTڿ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"CheckFirstLeaveLog ERROR: envelope %d on This LogicSec is Not Right\n", wCrossEnvolopInfo[0].id); + } + else + { + /*гλ߼ûн*/ + chRetVal = TrainBackPosCrossLogCheck(wCrossEnvolopInfo[0].id, wLogSecId, functionId); + } + } + + } + else + { + /*ʧ*/ + chRetVal = CI_ERROR; + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, wLogSecId, ETYPE_LOGSEC_OCC_STATE, leaveLogOccuState, ESEND_LEVEL_ZERO); + } + + } + /*ȥ߼CTռѹ*/ + else + { + chRetVal = CI_ERROR; + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, wLogSecId, ETYPE_LOGSEC_OCC_STATE, leaveLogOccuState, ESEND_LEVEL_ZERO); + } + return chRetVal; +} + +/* +* ѯгλǷ߼ཻ +* ˵ wLogSecId һȥ߼ID +* envolopId ID +* ֵ CI_ERROR ཻ +* CI_SUCCESS δཻ +*/ +UINT8 TrainBackPosCrossLogCheck(const UINT16 envolopId, const UINT16 logsecId ,const UINT8 functionId) +{ + UINT8 i = 0U; + str_Zone strZoneTrainBack = { 0U }; + UINT8 chRetVal = CI_ERROR; + UINT32 dwLen = 0U; + UINT16 linkNum = 0U; + LOD_STRU strPointA = { 0u }; + LOD_STRU strPointB = { 0u }; + UINT8 ifCrossFlag = CI_ERROR; + const EnvelopeStruct* pTempInfo = NULL; /*Ϣ*/ + UINT16 trainId = 0U; + str_Zone strZoneLogic = { 0u }; /*߼οռλ*/ + UINT16* pLogSecIncLinkBuff = NULL; /*߼ΰlink ID*/ + + if ((0U != envolopId) && (LINE_MAX_TRAIN != envolopId) && (0U != logsecId) && (LOGIC_SECTION_SUM_MAX > logsecId)) + { + /*ѯ߼λϢ*/ + /*ȡ߼εĿռλ*/ + strZoneLogic.pLinkSeq.cLinkCnt = GetSecIntrudeLinkSum(logsecId); + pLogSecIncLinkBuff = GetSecIntrudeLinkIdBuf(logsecId); + if (NULL != pLogSecIncLinkBuff) + { + for (i = 0U; i < strZoneLogic.pLinkSeq.cLinkCnt; i++) + { + strZoneLogic.pLinkSeq.szLinkId[i] = pLogSecIncLinkBuff[i]; + } + } + strZoneLogic.pStart.wLinkId = GetLgcSecOrgnLink(logsecId); + strZoneLogic.pStart.dwOffset = GetLgcSecOrgnOffset(logsecId); + strZoneLogic.pEnd.wLinkId = GetLgcSecTmnlLink(logsecId); + strZoneLogic.pEnd.dwOffset = GetLgcSecTmnlOffset(logsecId); + + pTempInfo = elm_GetEnvelopeInfoByID(envolopId); + /*г*/ + for (i = 0U; i < pTempInfo->trianCnt; i++) + { + trainId = pTempInfo->trainID[i]; + + /*ѯгλϢ*/ + strZoneTrainBack.pEnd.wLinkId = GetAblTrainMaxHeadLink(trainId); + strZoneTrainBack.pEnd.dwOffset = GetAblTrainMaxHeadOffset(trainId); + strZoneTrainBack.pStart.wLinkId = GetAblTrainMinTailLink(trainId); + strZoneTrainBack.pStart.dwOffset = GetAblTrainMinTailOffset(trainId); + strPointA.Lnk = strZoneTrainBack.pStart.wLinkId; + strPointA.Off = strZoneTrainBack.pStart.dwOffset; + strPointB.Lnk = strZoneTrainBack.pEnd.wLinkId; + strPointB.Off = strZoneTrainBack.pEnd.dwOffset; + + dwLen = dsuLenByPoint(&strPointA, &strPointB, &linkNum, strZoneTrainBack.pLinkSeq.szLinkId, &strZoneTrainBack.Dir); + + if (UINT32_MAX != dwLen) + { + strZoneTrainBack.pLinkSeq.cLinkCnt = (UINT8)linkNum; + + /*жϸгλ߼εĹϵ*/ + chRetVal = CheckZoneIsCrossing(&strZoneLogic, &strZoneTrainBack); + if (CI_SUCCESS != chRetVal) + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"CheckFirstLeaveLog ERROR: Train %d Is Overlap With FirstLeaveLogSec\n", trainId); + } + + } + else + { + /*ѯλʧ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"CheckFirstLeaveLog ERROR: Train %d Do Not Have BackUp Position\n", trainId); + } + if (CI_ERROR == chRetVal) + { + break; + } + } + if (CI_SUCCESS != chRetVal) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, logsecId, ETYPE_LOGSEC_OCC_STATE, CI_BACK_PSEC_OCU_YES, ESEND_LEVEL_ZERO); + } + } + return chRetVal; +} + +/* +* ·ȥεABLг +* ˵ leaveLogicSecId һȥ߼ID +* routeId · +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +*/ +UINT8 TrainLeaveLogSecABLTrainCheck(const UINT16 leaveLogicSecId) +{ + UINT8 ret = CI_ERROR; + UINT8 leaveLogCheckFlag = LOGSEC_LEAVE_LOGSEC_REPLY_NO;/*͵Ľ·ȥεABLг־*/ + UINT8 leaveLogBelongCI = 0U; + UINT8 chLocalCiId = 0U; + + chLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + leaveLogBelongCI = GetLogSecBelongCiId(leaveLogicSecId); + /*һ߼ڱ*/ + if (chLocalCiId == leaveLogBelongCI) + { + /*·ⷽһȥ߼Ƿźſ*/ + ret = RouteLeaveLogSecCheck(leaveLogicSecId); + } + /*͵һȥ߼μ*/ + else + { + leaveLogCheckFlag = GetRouteLeaveLogFlag(leaveLogicSecId); + /*յŷ*/ + if (LOGSEC_LEAVE_LOGSEC_REPLY_YES == leaveLogCheckFlag) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + return ret; +} + +/* +* ߼ABL· +* ˵ const UINT16 wLogSecId ߼ID +* const UINT16 wTrainId гID +* ֵ CI_ERROR 0 ABL· +* CI_SUCCESS 1 ABL· +* Created By CGH 20240726 +*/ +UINT8 CheckLogSecAblReverseProperty(const UINT16 wLogSecId, const UINT16 wTrainId) +{ + UINT8 retVal = CI_ERROR; + UINT8 chTrainLevel = 0U;/*гȼ*/ + UINT16 wLogSecRLockRouteId = 0U; /*߼ν··ID*/ + UINT8 chLogSecReverseProperty = 0U;/*·*/ + + if ((0U < wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId) && (0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + chTrainLevel = GetTrainLevel(wTrainId); + if (TRAIN_LEVEL_ABL == chTrainLevel) + { + wLogSecRLockRouteId = GetLogSecLockBelongRoute(wLogSecId); + + if ((0U < wLogSecRLockRouteId) && (ROUTE_SUM_MAX > wLogSecRLockRouteId)) + { + chLogSecReverseProperty = GetRouteReverseProperty(wLogSecRLockRouteId); + if (ROUTE_REVERSE_PROPERTY_YES == chLogSecReverseProperty) + { + /*߼·߱*/ + retVal = CI_ERROR; + } + else + { + /*߼βз*/ + retVal = CI_SUCCESS; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_SUCCESS; /*гȼΪABLм*/ + } + } + else + { + /*ηǷʧ*/ + } + + return retVal; +} + + +/* +* αúǷ㱻һ·û򱣻 +* ˵ UINT16 switchId, ID +* UINT8 switchState, λ +* ֵ CI_SUCCESSüͨ +* CI_ERROR:üʧ +* 2023.07.24 add by mpt +*/ +UINT8 CheckPhyUseSecCanOtherUse(UINT16 switchId, UINT8 switchState) +{ + UINT8 retVal = CI_ERROR; + RouteSwitchStruct *pRouteInnerSwitchIdBuf = NULL; /*·ڷID */ + UINT8 routeExpectSwitchState = 0U; /*·ĵλ*/ + UINT8 routeSwitchSum = 0U; /*·ڰĵ*/ + UINT16 ii = 0U; /*ѭ±*/ + UINT16 phyUseBelongRouteId = 0U; /*·ID*/ + UINT8 routeState = 0U; /*·״̬*/ + UINT16 switchBelongPhySecId = 0U; /*ID*/ + UINT16 phyProtUseBelongRouteId = 0U; /*ID*/ + UINT8 routeProtSwitchSum = 0U; /*·ڰĵ*/ + RouteProtectSwitchStruct* pRouteProtectSwitchStr = NULL; /*·*/ + + switchBelongPhySecId = GetSwitchPhySectionId(switchId); /*ȡID*/ + + phyUseBelongRouteId = GetPhySecUseRouteId(switchBelongPhySecId); /*·ID*/ + phyProtUseBelongRouteId = GetPhySecProtectUseRouteId(switchBelongPhySecId); /*·ID*/ + + if (0U < phyUseBelongRouteId) + { + retVal = CI_ERROR; + routeSwitchSum = GetRouteSwitchSum(phyUseBelongRouteId); /*·ĵ*/ + pRouteInnerSwitchIdBuf = GetRouteSwitchData(phyUseBelongRouteId);/*·ڷĵID*/ + if (NULL != pRouteInnerSwitchIdBuf) + { + for (ii = 0U; ii < routeSwitchSum; ii++) + { + if (switchId == pRouteInnerSwitchIdBuf[ii].SwitchId) + { + if (switchState == pRouteInnerSwitchIdBuf[ii].SwitchPosition) + { + retVal = CI_SUCCESS;/*ĵλһͨ*/ + } + else + { + retVal = CI_ERROR; + } + break; + } + } + if (ii == routeSwitchSum) + {/*·Ľ·ͨ*/ + retVal = CI_SUCCESS; + } + } + } + else + { + retVal = CI_SUCCESS; + } + + + if (CI_SUCCESS == retVal) + { + if (0U < phyProtUseBelongRouteId) + { + retVal = CI_ERROR; + routeProtSwitchSum = GetRouteRelatedProtectSwitchSum(phyProtUseBelongRouteId); /*·ĵ*/ + pRouteProtectSwitchStr = GetRouteRelatedProtSwitchData(phyProtUseBelongRouteId);/*·ڷĵID*/ + if (NULL != pRouteProtectSwitchStr) + { + for (ii = 0U; ii < routeProtSwitchSum; ii++) + { + if (switchId == pRouteProtectSwitchStr[ii].ProtectSwitchId) + { + if (switchState == pRouteProtectSwitchStr[ii].ProtectPosition) + { + retVal = CI_SUCCESS;/*ĵλһͨ*/ + } + else + { + retVal = CI_ERROR; + } + break; + } + } + if (ii == routeProtSwitchSum) + { + /*·ķмͨ*/ + retVal = CI_SUCCESS; + } + } + } + else + { + retVal = CI_SUCCESS; + } + } + + if (CI_SUCCESS == retVal) + { + if ((0U == phyUseBelongRouteId) && (0U == phyProtUseBelongRouteId)) + { + retVal = CI_ERROR;/*ãǽ·úͽ·öΪ0˵οǷǽ·Ծãʧ*/ + } + } + + return retVal; +} + +/* +* ͨųǰ˿ɼ +* const UINT16 wTrainId гID +* const UINT8 cLogSecSeqDir ATS·߼з +* const UINT16 wLogSecId ߼ID +* +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20240819 +*/ +UINT8 CtTrainHeadSuspCheck(const UINT16 wTrainId, const UINT8 cLogSecSeqDir,const UINT16 wLogSecId) +{ + /*ֲʼ*/ + UINT8 retVal = CI_ERROR; + UINT8 cTrainDir = 0U; /*гз*/ + UINT8 cSysLogDir = 0U; /*ϵͳ߼*/ + UINT8 cTrainCommState = 0U; /*гͨ״̬*/ + EnvelopeStruct* pTrainEnvelopeData = NULL; /*г*/ + LOD_STRU strCurPoint = { 0U }; + LOD_STRU strNxtPoint = { 0U }; + UINT8 cDirChangeNum = 0U; /*г߼μķ仯*/ + UINT16 wTrainMinTailLink = 0U;/*гСLINK*/ + UINT16 wLogSecOrgnLink = 0U;/*߼LINK*/ + UINT8 cVirHeadScreStat = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гǰɸ־*/ + UINT8 cVirTailScreStat = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гɸ־*/ + + /*μ*/ + cSysLogDir = GetLinkLogicDirUpAndDown(); + if (((CI_SYSTEM_DIRECTION_DOWN == cLogSecSeqDir) || (CI_SYSTEM_DIRECTION_UP == cLogSecSeqDir)) && ((0x55 == cSysLogDir) || (0xaa == cSysLogDir))) + { + if ((0U != wTrainId) && (UINT16_MAX != wTrainId)) /*гIDϷж*/ + { + cTrainCommState = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_GOOD == cTrainCommState) /*ͨųǰɸ*/ + { + cTrainDir = GetTrainDir(wTrainId); + /*г߼תΪӪ*/ + if (cTrainDir == DIR_CONVERT) + { + cTrainDir = cSysLogDir; + } + else if (cTrainDir == DIR_SAME) + { + cTrainDir = ~cSysLogDir; + } + else + { + /*޲*/ + } + + wTrainMinTailLink = GetTrainMinTailLink(wTrainId); + wLogSecOrgnLink = GetLgcSecOrgnLink(wLogSecId); + strCurPoint.Lnk = wTrainMinTailLink; + strCurPoint.Off = 0U; + strNxtPoint.Lnk = wLogSecOrgnLink; + strNxtPoint.Off = 0U; + cDirChangeNum = GetDirChangeNumBtwPoints(&strCurPoint, &strNxtPoint); /*ѯг׸߼μķ仯*/ + cTrainDir = TransDirByChangeNum(cTrainDir, cDirChangeNum); + + pTrainEnvelopeData = elm_GetEnvelopeInfoByTrainID((wTrainId & 0xFFU)); /*ȡгڰ*/ + if (NULL != pTrainEnvelopeData) + { + if (((CI_SYSTEM_DIRECTION_UP == cLogSecSeqDir) && (CI_SYSTEM_DIRECTION_UP == cTrainDir)) + || ((CI_SYSTEM_DIRECTION_DOWN == cLogSecSeqDir) && (CI_SYSTEM_DIRECTION_DOWN == cTrainDir))) + { + /*гз߼зͬͨųǰǷ*/ + cVirHeadScreStat = GetTrainVirHeadScreenPassFlag(wTrainId); + if ((0U != pTrainEnvelopeData->headTrainID) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != cVirHeadScreStat)) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + } + else if (((CI_SYSTEM_DIRECTION_DOWN == cLogSecSeqDir) && (CI_SYSTEM_DIRECTION_UP == cTrainDir)) + || ((CI_SYSTEM_DIRECTION_UP == cLogSecSeqDir) && (CI_SYSTEM_DIRECTION_DOWN == cTrainDir))) + { + /*гз߼з෴ͨųǷ*/ + cVirTailScreStat = GetTrainVirTailScreenPassFlag(wTrainId); + if ((0U != pTrainEnvelopeData->tailTrainID) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != cVirTailScreStat)) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + } + else + { + retVal = CI_ERROR; /*󣬷ʧ*/ + } + } + else + { + /*ڿȡг磬ֱð*/ + retVal = CI_SUCCESS; + } + } + else + { + /*ͨųֱð*/ + retVal = CI_SUCCESS; + } + } + else + { + /*Чʧ*/ + } + } + else + { + retVal = CI_ERROR; /*μʧܣʧ*/ + } + + return retVal; +} + +/* +* βֽ·߼кгλü +* const UINT8 cLogSecSum ߼ +* const UINT16* pLogSecIdBuff ߼ +* const UINT16 wTrainId +* +* ֵ CI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.09.05 +*/ +UINT8 LogSecSeqAndTrainPosCheckCLD(const UINT8 cLogSecSum, const UINT16* pLogSecIdBuff, const UINT16 wTrainId) +{ + /*ֲʼ*/ + UINT8 cRetVal = CI_ERROR; + UINT16 wTrainIndex = 0U; + UINT8 cLogSecLockState = LOG_SECTION_LOCK_NORMAL; /*߼״̬*/ + UINT8 cLogSecLogLockState = LOG_SECTION_LOGLOCK_NORMAL; /*߼߼״̬*/ + UINT8 cLogSecIncLinkNum = 0U; /*߼ΰlink*/ + UINT16* pLogSecIncLinkId = NULL; /*߼ΰlink ID*/ + UINT16 wLogSecRelPhySecId = 0U; /*߼ι*/ + UINT8 cPhySecType = PHYSICAL_SEC_TYPE_SWITCH; /*ͣǷ*/ + UINT8 cSleepWakeAttr = CI_ERROR; /*߻ѹ*/ + UINT8 cTrainCommState = TRAIN_COMM_STATE_UNKNOWN; /*гͨ״̬*/ + UINT16 wTrainMaxHeadLink = 0U; + UINT16 wTrainMinHeadLink = 0U; + UINT16 wTrainMaxTailLink = 0U; + UINT16 wTrainMinTailLink = 0U; + + /*μ*/ + wTrainIndex = GetTrainBufIndex(wTrainId); + if ((1U == cLogSecSum) && (NULL != pLogSecIdBuff) && (TRAIN_SUM_MAX > wTrainIndex)) + { + /****** ֽ·߼Ψһ߼Ƿδ ******/ + cLogSecLockState = GetLogSecLockState(pLogSecIdBuff[0]); + cLogSecLogLockState = GetLogSecLogLockState(pLogSecIdBuff[0]); + + if ((LOG_SECTION_LOCK_NO == cLogSecLockState) && (LOG_SECTION_LOGLOCK_NO == cLogSecLogLockState)) + { + /****** ֽ·߼Ψһδգ߼ǷΪ߻ѹҷDz ******/ + cLogSecIncLinkNum = GetSecIntrudeLinkSum(pLogSecIdBuff[0]); /*ȡ߼ΰlink*/ + pLogSecIncLinkId = GetSecIntrudeLinkIdBuf(pLogSecIdBuff[0]); + + if ((1U == cLogSecIncLinkNum) && (NULL != pLogSecIncLinkId)) + { + cSleepWakeAttr = IsLinkSwTrack(pLogSecIncLinkId[0]); /*ȡlink߻ѹ*/ + wLogSecRelPhySecId = GetLgcSecRelativePhySecId(pLogSecIdBuff[0]); /*ȡ߼ι*/ + cPhySecType = GetPhySecType(wLogSecRelPhySecId); /*ȡ*/ + + if ((CI_SUCCESS == cSleepWakeAttr) && (PHYSICAL_SEC_TYPE_NOSWITCH == cPhySecType)) + { + /****** ֽ·߼ΨһδΪ߻ѹҷDzгǷȫλڴ߻ѹ ******/ + cTrainCommState = GetTrainTransitmitStat(wTrainId); + + if (TRAIN_COMM_STATE_GOOD == cTrainCommState) /*ͨųǰɸ*/ + { + wTrainMaxHeadLink = GetTrainMaxHeadLink(wTrainId); /*ȡгλ*/ + wTrainMinHeadLink = GetTrainMinHeadLink(wTrainId); + wTrainMaxTailLink = GetTrainMaxTailLink(wTrainId); + wTrainMinTailLink = GetTrainMinTailLink(wTrainId); + + if ((pLogSecIncLinkId[0] == wTrainMaxHeadLink) && (wTrainMaxHeadLink == wTrainMinHeadLink) + && (wTrainMinHeadLink == wTrainMaxTailLink) && (wTrainMaxTailLink == wTrainMinTailLink)) + { + cRetVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"LogSecSeqAndTrainPosCheckCLD: Train Check Error: Train[%d] Position Is Error\n", wTrainId); /*гδȫ߻ѹ죬ʧ*/ + } + } + else + { + debug_infor_printf((const)"LogSecSeqAndTrainPosCheckCLD: Train Check Error: Train[%d] CommState Is Error\n", wTrainId); /*гͨ쳣ʧ*/ + } + } + else + { + debug_infor_printf((const)"LogSecSeqAndTrainPosCheckCLD: LogSec Check Error: LogSec[%d] Attr Is Error\n", pLogSecIdBuff[0]); /*ֽ·߼η߻ѹ/Σʧ*/ + } + } + else + { + /*ȡ߼ΰlinkʧܣʧ*/ + } + } + else + { + debug_infor_printf((const)"LogSecSeqAndTrainPosCheckCLD: LogSec Check Error: LogSec[%d] State Is Error\n", pLogSecIdBuff[0]); /*߼գʧ*/ + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* βֽ·߼·ƥ +* const UINT8 cLogSecSeqDir ߼зӪ +* const UINT16 wLogSecId ߼ID +* UINT16* pMatchedRouteId ߼ƥĽ·ID +* ֵ CI_ERROR 0 ƥʧ +* CI_SUCCESS 1 ƥɹ +* Created By LQ 2024.09.05 +*/ +UINT8 LogSecSeqAndRouteMatchCheckCLD(const UINT8 cLogSecSeqDir, const UINT16 wLogSecId, UINT16* pMatchedRouteId) +{ + /*ֲʼ*/ + UINT8 cRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT16 wLogSecIndex = 0U; + UINT8 cRelatedEndSigSum = 0U; /*߼ιնźŻ*/ + UINT16* pRelatedEndSigId = NULL; /*߼ιնźŻID*/ + UINT16* pLogSecIncLinkId = NULL; /*߼ΰlinkID*/ + UINT8 cQueryLogicDir = DIR_INVALID; /*ѯ߼*/ + UINT8 cSignalProDir = DIR_INVALID; /*źŻ߼*/ + UINT16 wSigProLinkId = 0U; /*źŻlink*/ + LOD_STRU strCurPoint = { 0U }; + LOD_STRU strNxtPoint = { 0U }; + UINT8 cDirChangeNum = 0U; + UINT16 wEndSignalId = 0U; + UINT8 cRelatedRouteSum = 0U; /*߼ι·*/ + UINT16* pRelatedRouteId = NULL; /*߼ι·ID*/ + UINT16 wRouteEndSignalId = 0U; /*·նźŻ*/ + UINT8 cPossibleRouteSum = { 0U }; /*ɸɹĽ·*/ + UINT16 szPossibleRouteIdBuff[MAX_ROUTE_IN_LT_NUM] = { 0U }; /*ɸɹĽ·ID*/ + + /*μ*/ + wLogSecIndex = GetlogSectionBufIndex(wLogSecId); + if (((CI_SYSTEM_DIRECTION_DOWN == cLogSecSeqDir) || (CI_SYSTEM_DIRECTION_UP == cLogSecSeqDir)) && (LOGIC_SECTION_SUM_MAX > wLogSecIndex) && (NULL != pMatchedRouteId)) + { + /****** 1.ȷ߼ιⷽźŻ ******/ + cRelatedEndSigSum = GetLogRelateEndSigSum(wLogSecId); + pRelatedEndSigId = GetLogRelateEndSigData(wLogSecId); + pLogSecIncLinkId = GetSecIntrudeLinkIdBuf(wLogSecId); + + /*ѡ߼ιźŻзATS·зͬźŻ*/ + if ((0U != cRelatedEndSigSum) && (NULL != pRelatedEndSigId) && (NULL != pLogSecIncLinkId)) + { + cQueryLogicDir = ConvertDirectionToLogic(cLogSecSeqDir); /*ӪתΪ߼*/ + + for (ii = 0U; ii < cRelatedEndSigSum; ii++) + { + cSignalProDir = GetSignalDirection(pRelatedEndSigId[ii]); + wSigProLinkId = GetSignalProtectLink(pRelatedEndSigId[ii]); + strCurPoint.Lnk = pLogSecIncLinkId[0U]; + strCurPoint.Off = 0U; + strNxtPoint.Lnk = wSigProLinkId; + strNxtPoint.Off = 0U; + cDirChangeNum = GetDirChangeNumBtwPoints(&strCurPoint, &strNxtPoint); /*ѯǰlinkźŻlinkķ仯*/ + cSignalProDir = TransDirByChangeNum(cSignalProDir, cDirChangeNum); + + if (cSignalProDir == cQueryLogicDir) + { + wEndSignalId = pRelatedEndSigId[ii]; + break; + } + else + { + /*ͬնźŻ*/ + } + } + } + else + { + /*ȡ߼ιնźŻʧܣ*/ + } + + /****** 2.ɸ߼οƥĽ· ******/ + cRelatedRouteSum = GetLogRelateRouteSum(wLogSecId); + pRelatedRouteId = GetLogRelateRouteData(wLogSecId); + + if ((0U != cRelatedRouteSum) && (NULL != pRelatedRouteId)) + { + for (ii = 0U; ii < cRelatedRouteSum; ii++) + { + wRouteEndSignalId = GetRouteEndSignalId(pRelatedRouteId[ii]); + + /*·նźŻ߼նźŻͬӽ·Ϊܵƥ·*/ + if (wRouteEndSignalId == wEndSignalId) + { + if (MAX_ROUTE_IN_LT_NUM > cPossibleRouteSum) + { + szPossibleRouteIdBuff[cPossibleRouteSum] = pRelatedRouteId[ii]; + cPossibleRouteSum++; + } + else + { + break; /*ﵽޣټ*/ + } + } + else + { + /*նźŻͬ*/ + } + } + + if (0U != cPossibleRouteSum) + { + cRetVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"LogSecSeqAndRouteMatchCheckCLD: No End Signal Matched Route\n"); /*δƥ䵽·ʧ*/ + } + } + else + { + /*ȡ߼ιĽ·ʧܣ*/ + } + + /****** 3.ȷ߼ƥĽ· ******/ + if (CI_SUCCESS == cRetVal) + { + cRetVal = MatchLieCheRouteCLD(cPossibleRouteSum, szPossibleRouteIdBuff, pMatchedRouteId); /*ƥ·г·*/ + } + else + { + cRetVal = CI_ERROR; /*ʧ*/ + } + } + else + { + /*μʧܣ*/ + } + + return cRetVal; +} + +/* +* βֽ·ƥг· +* const UINT8 cRouteSum · +* const UINT16 szRouteId[MAX_ROUTE_IN_LT_NUM] ·ID +* UINT16* pMatchedRouteId ߼ƥĽ·ID +* ֵ CI_ERROR 0 ƥʧ +* CI_SUCCESS 1 ƥɹ +* Created By LQ 2024.09.05 +*/ +UINT8 MatchLieCheRouteCLD(const UINT8 cRouteSum, const UINT16 szRouteId[MAX_ROUTE_IN_LT_NUM], UINT16* pMatchedRouteId) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 cRouteType = 0U; /*·*/ + UINT8 cLieCheIndex = UINT8_MAX; /*Ŀг·*/ + UINT8 cReturnIndex = UINT8_MAX; /*Ŀ۷·*/ + UINT16 wMatchedRouteId = 0U; + UINT8 cRouteRukuProperty = ROUTE_AUTOSIG_PROPERTY_NO; /*·*/ + + /*μ*/ + if ((MAX_ROUTE_IN_LT_NUM >= cRouteSum) && (NULL != szRouteId) && (NULL != pMatchedRouteId)) + { + for (ii = 0U; ii < cRouteSum; ii++) + { + /*ͨ·ҳ·ег·*/ + cRouteType = GetConfigRouteType(szRouteId[ii]); + if (ROUTE_TYPE_LIECHE == cRouteType) + { + cLieCheIndex = ii; + break; /*ҵг·ȷΪƥĽ·ñ־Чֹͣ*/ + } + else if (ROUTE_TYPE_RETURN == cRouteType) + { + cReturnIndex = ii; /*۷·*/ + } + else + { + /*·*/ + } + } + + if (UINT8_MAX != cLieCheIndex) + { + wMatchedRouteId = szRouteId[cLieCheIndex]; /*г·г·*/ + } + else if(UINT8_MAX != cReturnIndex) + { + wMatchedRouteId = szRouteId[cReturnIndex]; /*г·ʹ÷۷·*/ + } + else + { + debug_infor_printf((const)"MatchLieCheRouteCLD: No Train Route And Return Route\n"); /*ֻе·ʧ*/ + } + + /*жƥ䵽Ľ·ǷΪ·*/ + cRouteRukuProperty = GetRouteRukuProperty(wMatchedRouteId); + if (ROUTE_RUKU_PROPERTY_YES == cRouteRukuProperty) + { + *pMatchedRouteId = wMatchedRouteId; /*·سɹ*/ + cRetVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"MatchLieCheRouteCLD: Route Id[%d] Is Not Ruku Route\n", wMatchedRouteId); /*·ATS͵߼зⷽ򣬷ʧ*/ + } + } + else + { + /*μʧܣ0ʧ*/ + } + + return cRetVal; +} + +/* +* ͨгǰ˿ɼ +* const UINT16 wTrainId гID +* +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.09.05 +*/ +UINT8 CtTrainSuspCheck(const UINT16 wTrainId) +{ + /*ֲʼ*/ + UINT8 cRetVal = CI_ERROR; + UINT16 wTrainIndex = 0U; + EnvelopeStruct* pTrainEnvelopeData = NULL; /*г*/ + UINT8 cVirHeadScreStat = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гǰɸ־*/ + UINT8 cVirTailScreStat = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гɸ־*/ + + /*μ*/ + wTrainIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wTrainIndex) + { + pTrainEnvelopeData = elm_GetEnvelopeInfoByTrainID((wTrainId & 0xFFU)); /*ȡгڰ*/ + if (NULL != pTrainEnvelopeData) + { + /*мͨųǰ+Ƿ*/ + cVirHeadScreStat = GetTrainVirHeadScreenPassFlag(wTrainId); + cVirTailScreStat = GetTrainVirTailScreenPassFlag(wTrainId); + + if (((0U == pTrainEnvelopeData->headTrainID) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == cVirHeadScreStat)) + && ((0U == pTrainEnvelopeData->tailTrainID) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == cVirTailScreStat))) + { + cRetVal = CI_SUCCESS; + } + else + { + /*гǰ˻˿ԣʧ*/ + } + } + else + { + /*ȡгʧܣʧ*/ + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* жϽ·Ƿյı +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERROR ûյı +* CI_SUCCESS յı +* BY CGH 20240920 +*/ +UINT8 CheakRouteHaveLockOverlap(const UINT16 routeId) +{ + UINT8 ii = 0U; + UINT16 wOverlapBelongRouteId = 0U;/*·*/ + UINT16 wRouteOrgnLink = 0U;/*·LINK*/ + UINT8 chReResult = CI_ERROR; + UINT16 wRouteInFirstLogSecId = 0U;/*·ڷһ߼ID*/ + UINT16 wOverlapFirstLogSecId = 0U;/*εһ߼ID*/ + UINT8 chOverlapFirstSecLockDir = 0U;/*εһշ*/ + UINT16 wLogSecOrgnLink = 0U;/*߼LINK*/ + UINT8 chRouteLockDir = 0U; + UINT8 chOverlapSum = GetRouteOverlapSum(routeId); + UINT16* pOverlapIdBuf = GetRouteOverlapIdBuf(routeId); + LOD_STRU pLODAStru = { 0U }; + LOD_STRU pLODBStru = { 0U }; + UINT8 chDirChangeNum = 0U;/*仯Ŀ*/ + UINT16 wOverlapId = 0U;/*·ձID*/ + UINT16 wRouteAtsExpLkOverlapId = GetRouteAtsExpLkOverlapId(routeId); + + if ((0U < chOverlapSum) && (NULL != pOverlapIdBuf) && (0U == wRouteAtsExpLkOverlapId)) + { + for (ii = 0U; ii < chOverlapSum; ii++) + { + /*ڱ·Ϊ0 ˵*/ + wOverlapBelongRouteId = GetOverlapBelongRouteId(pOverlapIdBuf[ii]); + + if (0U != wOverlapBelongRouteId) + { + chRouteLockDir = GetRouteDirection(routeId); + wRouteInFirstLogSecId = GetRouteInFirstLogSecId(routeId); + wRouteOrgnLink = GetLgcSecOrgnLink(wRouteInFirstLogSecId); + pLODAStru.Lnk = wRouteOrgnLink; + pLODAStru.Off = 0U; + pLODAStru.Dir = EMAP_SAME_DIR;/*ʹãֵ*/ + + wOverlapFirstLogSecId = GetOverlapFirstLogSecId(pOverlapIdBuf[ii]); + chOverlapFirstSecLockDir = GetLogSecLockDir(wOverlapFirstLogSecId); + wLogSecOrgnLink = GetLgcSecOrgnLink(wOverlapFirstLogSecId); + pLODBStru.Lnk = wLogSecOrgnLink; + pLODBStru.Off = 0U; + pLODBStru.Dir = EMAP_SAME_DIR;/*ʹãֵ*/ + + chDirChangeNum = GetDirChangeNumBtwPoints(&pLODAStru, &pLODBStru); + + if (UINT8_MAX != chDirChangeNum) + { + if (0U == (chDirChangeNum % 2U)) + { + if (chOverlapFirstSecLockDir == chRouteLockDir) + { + /*·շͱշһʱ*/ + wOverlapId = pOverlapIdBuf[ii]; + chReResult = CI_SUCCESS; + } + else + { + chReResult = CI_ERROR; + } + } + else + { + if (chOverlapFirstSecLockDir == (UINT8)(~chRouteLockDir)) + { + /*·շͱշ෴ʱ*/ + wOverlapId = pOverlapIdBuf[ii]; + chReResult = CI_SUCCESS; + } + else + { + chReResult = CI_ERROR; + } + } + } + else + { + chReResult = CI_ERROR; + } + break; + } + else + { + chReResult = CI_ERROR; + } + } + } + else + { + chReResult = CI_ERROR; + } + + + if ((CI_SUCCESS == chReResult) && (0U != wOverlapId)) + { + if (wOverlapBelongRouteId != routeId) + { + chReResult = CI_SUCCESS; + } + else + { + /*ʲôҲ*/ + } + } + else + { + chReResult = CI_ERROR; + } + + return chReResult; +} + +/* +* жϴԶ·δִ· +* ˵ const UINT16 checkRouteId ·, const UINT16 opposeRouteId ִ· +* ֵ CI_ERROR ǿеִ·գ鲻ͨ +* CI_SUCCESS ͨ +* BY fan 20241111 +*/ +UINT8 AutoRouteOpposeSectionCheck(const UINT16 checkRouteId, const UINT16 opposeRouteId) +{ + UINT8 returnValue = CI_ERROR; + UINT8 i = 0U; /*ѭ*/ + UINT16 wPhySecId = 0U; + UINT8 curLockState = 0U; + UINT8 checkSum = 0U; + RoutePhysicalSectionStruct* pDataIdBuf =NULL; + UINT16 wLockBelongRouteId = 0U;/*·ID*/ + UINT8 routeState = 0U; + + if ((1u <= checkRouteId) && (ROUTE_SUM_MAX > checkRouteId) + && (1u <= opposeRouteId) && (ROUTE_SUM_MAX > opposeRouteId)) + { + routeState = GetRouteState(opposeRouteId); + if (ROUTE_STATE_IDLE != routeState) + { + checkSum = GetRoutePhysicalSectionSum(checkRouteId); + pDataIdBuf = GetRouteSectionData(checkRouteId); + if((0U != checkSum) && (NULL != pDataIdBuf)) + { + for (i = 0u; i < checkSum; i++) + { + wPhySecId = pDataIdBuf[i].PhysicalSectionId; + curLockState = GetPhySecLockState(wPhySecId); /*ȡεǰ״̬*/ + if (PHYSICAL_SECTION_LOCK_NO != curLockState) + { /*||ʱ*/ + + wLockBelongRouteId = GetPhySecRLockBelongRouteId(wPhySecId); + if (wLockBelongRouteId == opposeRouteId) + { + /*ִ· ʧ*/ + break; + } + else + { + ; /**/ + } + } + else + { + ; /*δ ͨ*/ + } + } + if (i == checkSum) + { + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + } + else + { + /*ݼʧ*/ + returnValue = CI_ERROR; + } + } + else + { + returnValue = CI_SUCCESS; /*ִ·δ*/ + } + } + else + { + /*μʧ*/ + returnValue = CI_ERROR; + } + return returnValue; +} + +/* +* λúͶЧ +* ˵ const UINT16 wSwitchId, ID +* ֵ +* BY CGH 20241203 +*/ +UINT8 CheckSwitchPosAndMoveValid(const UINT16 wSwitchId,const UINT8 chSwitchPos, UINT8 sendLevel) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 chDevState = 0U;/*豸״̬*/ + UINT8 chResult = CI_ERROR;/**/ + UINT8 chFuncSwitch = 0U; /*ܿ*/ + UINT8 chLocalCiId = 0U; /*ID*/ + UINT8 chCiType = 0U; /*Ŀ*/ + + chFuncSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + chLocalCiId = GetSystemParaLocalCiId(); + chCiType = GetCiType(chLocalCiId); + + if ((0U < wSwitchId) && (SWITCH_SUM_MAX > wSwitchId)) + { + chRetVal = CI_SUCCESS; + chDevState = GetSwitchCurPosition(wSwitchId); + if (chSwitchPos == chDevState) + { + /* λȷ */ + /*һβЧ򷵻ʧ*/ + chResult = checkSwtLastValDrvPosStayorNot(wSwitchId, chSwitchPos); + if (CI_SUCCESS == chResult) + { + ; /*ͨ*/ + } + else + { + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, wSwitchId, ETYPE_SWT_POSTION_STATE, chDevState, sendLevel); + chRetVal = CI_ERROR; + } + } + else if (SWITCH_POSITION_SIKAI == chDevState) + { + /*Ŀ*/ + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, wSwitchId, ETYPE_SWT_POSTION_STATE, chDevState, sendLevel); + chRetVal = CI_ERROR; + } + else if (SWITCH_POSITION_JICHA == chDevState) + { + /**/ + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, wSwitchId, ETYPE_SWT_POSTION_STATE, chDevState, sendLevel); + chRetVal = CI_ERROR; + } + else + { + /* λòȷ */ + if (CI_TYPE_CLD == chCiType) + { + chDevState = GetSwitchMoveValidState(wSwitchId, SWITCH_OPER_NO_DANCAO, sendLevel); + } + else + { + if (FUNC_SWITCH_ON == chFuncSwitch) + { + /*·ǰ*/ + chDevState = GetSwitchMoveEarlyValidState(wSwitchId, SWITCH_OPER_NO_DANCAO, sendLevel); + } + else + { + chDevState = GetSwitchMoveValidState(wSwitchId, SWITCH_OPER_NO_DANCAO, sendLevel); + } + } + + if (CI_SUCCESS == chDevState) + { + ; /*ɶ*/ + } + else + { + /*λòȷ ɶ*/ + /* ¼ */ + SetErrorData(EFUNC_CHECK_SWITCHPOS_MOVEVALID, CI_DEVICE_TYPE_SWITCH, wSwitchId, ETYPE_SWT_POSTION_STATE, chDevState, sendLevel); + chRetVal = CI_ERROR; + } + } + } + else + { + ; + } + return chRetVal; +} + +/* +* ·λЧԼ +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20241204 +*/ +UINT8 RouteOtherCiSwPosValidCheck(UINT16 const routeId) +{ + UINT8 const checkRouteSwSum = GetRouteSwitchSum(routeId); + RouteSwitchStruct* pRouteSwIdBuf = GetRouteSwitchData(routeId); + UINT8 const checkRouteProSwSum = GetRouteRelatedProtectSwitchSum(routeId); + RouteProtectSwitchStruct* pRouteProSwIdBuf = GetRouteRelatedProtSwitchData(routeId); + UINT8 ii = 0U; /* ѭ */ + UINT8 reVal = CI_ERROR; + UINT8 chRouteSwitchBelCiCheck = 0U;/*·Ƿȫڽ·*/ + UINT8 chRouteApplySwitchCheckFlag = 0U;/*·־*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chSwitchBelCiId = 0U;/*ID*/ + + if ((NULL == pRouteSwIdBuf) || (NULL == pRouteProSwIdBuf)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + chLocalCiId = GetSystemParaLocalCiId(); + /*ʼ*/ + for (ii = 0U; ii < checkRouteSwSum; ii++) + { + chSwitchBelCiId = GetSwitchBelongCiId(pRouteSwIdBuf[ii].SwitchId); + if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId)) + { + reVal = CheckSwitchPosAndMoveValid(pRouteSwIdBuf[ii].SwitchId, pRouteSwIdBuf[ii].SwitchPosition, ESEND_LEVEL_ATS); + if (CI_ERROR == reVal) + { + break; + } + else + { + ; + } + } + else + { + /*ҵȫ鱾ĵ*/ + ; + } + } + + if (CI_SUCCESS == reVal) + { + for (ii = 0U; ii < checkRouteProSwSum; ii++) + { + chSwitchBelCiId = GetSwitchBelongCiId(pRouteProSwIdBuf[ii].ProtectSwitchId); + if ((chLocalCiId == chSwitchBelCiId) && (0U != chLocalCiId)) + { + reVal = CheckSwitchPosAndMoveValid(pRouteProSwIdBuf[ii].ProtectSwitchId, pRouteProSwIdBuf[ii].ProtectPosition, ESEND_LEVEL_ATS); + if (CI_ERROR == reVal) + { + break; + } + else + { + ; + } + } + else + { + /*ҵȫ鱾ĵ*/ + ; + } + } + } + else + { + ; + } + } + + return reVal; +} + +/* +* ιķЧԼ +* ˵const UINT16 wOverlapId ID +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.12.09 +*/ +UINT8 OtherCiOvlpRelProSwMovValCheck(const UINT16 wOverlapId) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cOverlapIncProSwNum = 0U; /*ȡι*/ + OverlapProtectSwitchStruct* pOverlapIncProSwData = NULL; + UINT8 cLocalCiId = 0U; + UINT16 ii = 0U; + UINT16 wProSwId = 0U; /*ID*/ + UINT8 cSwitchBelongCiId = 0U; /**/ + UINT8 cProSwCurPos = 0U; /*ǰλ*/ + UINT8 cProSwExpPos = 0U; /*λ*/ + UINT8 cCheckResult = CI_ERROR; + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*Ϸͼ𣬲*/ + + cOverlapIncProSwNum = GetOverlapRelatedProtSwitSum(wOverlapId); /*ȡι*/ + pOverlapIncProSwData = GetOverlapRelatedProtSwitStru(wOverlapId); + + if (0U == cOverlapIncProSwNum) + { + cRetVal = CI_SUCCESS; /*޷سɹ*/ + } + else if (NULL != pOverlapIncProSwData) + { + cRetVal = CI_SUCCESS; + cLocalCiId = GetSystemParaLocalCiId(); + + for (ii = 0U; ii < cOverlapIncProSwNum; ii++) + { + wProSwId = pOverlapIncProSwData[ii].ProtectSwitchId; + cSwitchBelongCiId = GetSwitchBelongCiId(wProSwId); /*ȡ*/ + + if ((cLocalCiId == cSwitchBelongCiId) && (0U != cSwitchBelongCiId)) + { + /*ɶ*/ + cProSwCurPos = GetSwitchCurPosition(wProSwId); + cProSwExpPos = pOverlapIncProSwData[ii].ProtectPosition; + if (cProSwCurPos == cProSwExpPos) + { + cCheckResult = checkSwtLastValDrvPosStayorNot(wProSwId, cProSwExpPos); /*ǷЧķ*/ + if (CI_SUCCESS == cCheckResult) + { + /*Чķسɹ*/ + } + else + { + cRetVal = CI_ERROR; + } + } + else if (SWITCH_POSITION_SIKAI == cProSwCurPos) + { + cRetVal = CI_ERROR; /*Ŀʧ*/ + } + else if (SWITCH_POSITION_JICHA == cProSwCurPos) + { + cRetVal = CI_ERROR; /*ʧ*/ + } + else + { + cCheckResult = GetSwitchMoveValidState(wProSwId, SWITCH_OPER_NO_DANCAO, sendLevel); /*λòȷǷɶ*/ + if (CI_SUCCESS == cCheckResult) + { + /*ɶسɹ*/ + } + else + { + cRetVal = CI_ERROR; /*λòȷҵɶʧ*/ + } + } + } + else + { + /*DZ*/ + } + + if (CI_ERROR == cRetVal) + { + break; + } + else + { + /**/ + } + } + } + else + { + cRetVal = CI_ERROR; /*ηΪգʧ*/ + } + + return cRetVal; +} + +/* +* ηü +* ˵const UINT16 wOverlapId ID +* UINT16* pDevId 豸IDأ +* UINT8* pDevState 豸״̬أ +* UINT8* pAlarmType ͣأ +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* RETURN_WAIT_SWITCH_USING 0x30 ȴ +* Created By LQ 2024.12.10 +*/ +UINT8 OverlapProSwUsingCheck(const UINT16 wOverlapId, UINT16* pDevId, UINT8* pDevState, UINT8* pAlarmType) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cOverlapProSwitchNum = 0U; /*η*/ + OverlapProtectSwitchStruct* pOverlapProSwitchData = NULL; /*η*/ + UINT8 cLocalCiId = 0U; + UINT16 ii = 0U; + UINT16 wProSwitchId = 0U; /*ID*/ + UINT8 cSwitchBelongCiId = 0U; /**/ + UINT16 wProSwitchPhySecId = 0U; /*ID*/ + UINT8 cDevState = 0U; + UINT16 wPhySecUseRouteId = 0U; /*·ID*/ + UINT16 wPhySecProUseRouteId = 0U; /*η·ID*/ + UINT8 cProSwitchProtectExpPos = 0U; /*Ҫĵλ*/ + UINT8 cCheckResult = CI_ERROR; + UINT16 wUsingBelongOverlapId = 0U; /**/ + UINT32 dwXuanPaiStartCycNum = 0U; /*ηѡʼ*/ + UINT8 cAlarmType = FLAG_UNSET; /*ͣ0xAA-α0x55-*/ + + cOverlapProSwitchNum = GetOverlapRelatedProtSwitSum(wOverlapId);/*ȡη*/ + pOverlapProSwitchData = GetOverlapRelatedProtSwitStru(wOverlapId);/*ȡη*/ + cLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL != pOverlapProSwitchData) && (NULL != pDevId) && (NULL != pDevState) && (NULL != pAlarmType)) + { + cRetVal = CI_SUCCESS; + + for (ii = 0U; ii < cOverlapProSwitchNum; ii++) + { + wProSwitchId = pOverlapProSwitchData[ii].ProtectSwitchId; /*ID*/ + cSwitchBelongCiId = GetSwitchBelongCiId(wProSwitchId); /*ȡ*/ + if (cLocalCiId == cSwitchBelongCiId) + { + /*״̬*/ + wProSwitchPhySecId = GetSwitchPhySectionId(wProSwitchId); /*ȡID*/ + cDevState = GetPhySecUseState(wProSwitchPhySecId); /*ȡ״̬*/ + + if (PHYSICAL_SECTION_USING_NO == cDevState) + { + /*ͨ*/ + } + else + { + wPhySecUseRouteId = GetPhySecUseRouteId(wProSwitchPhySecId); /*ȡ·ID*/ + wPhySecProUseRouteId = GetPhySecProtectUseRouteId(wProSwitchPhySecId); /*ȡ·ID*/ + if ((0U < wPhySecUseRouteId) || (0U < wPhySecProUseRouteId)) + { + cProSwitchProtectExpPos = pOverlapProSwitchData[ii].ProtectPosition; /*Ҫλ*/ + cCheckResult = CheckPhyUseSecCanOtherUse(wProSwitchId, cProSwitchProtectExpPos); + if (CI_ERROR == cCheckResult) + { + cRetVal = CI_ERROR; /*0x30ȴתΪ1ɹ*/ + } + else + { + /**/ + } + } + else + { + cRetVal = CI_ERROR; + } + } + } + else + { + /*DZ״̬*/ + cDevState = GetSwitchUsingState(wProSwitchId); /*ȡ״̬*/ + wUsingBelongOverlapId = GetSwitchBelongOverlapId(wProSwitchId); /*ȡID*/ + dwXuanPaiStartCycNum = GetOverlapXuanPaiStartCycNum(wOverlapId); /*ȡѡʼں*/ + + if ((SWITCH_USING_YES == cDevState) && (wOverlapId == wUsingBelongOverlapId)) + { + /*ѱñãͨ*/ + } + else if (((SWITCH_USING_APPLY == cDevState) && (wOverlapId == wUsingBelongOverlapId)) + || ((SWITCH_USING_NO == cDevState) && (0U == dwXuanPaiStartCycNum))) + { + cRetVal = RETURN_WAIT_SWITCH_USING; /*ûδʼãصȴ*/ + } + else + { + wProSwitchPhySecId = wProSwitchId; /*ΣټжϿܵȦӶȳޣ*/ + cAlarmType = FLAG_SET; /*ͱ*/ + cRetVal = CI_ERROR; + } + } + + if (CI_ERROR == cRetVal) + { + *pDevId = wProSwitchPhySecId; + *pDevState = cDevState; + *pAlarmType = cAlarmType; + break; /*ʧܣֹͣʧ*/ + } + else + { + /**/ + } + } + } + else + { + cRetVal = CI_ERROR; /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* ·еλȷ +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* BY CGH 20250224 +*/ +UINT8 RouteRelAllSwitchPosCheck(UINT16 const routeId) +{ + /* · */ + UINT8 chRouteSwSum = GetRouteSwitchSum(routeId); + RouteSwitchStruct* szRouteSwDataBuf = GetRouteSwitchData(routeId); + /* · */ + UINT8 chRouteProSwSum = GetRouteRelatedProtectSwitchSum(routeId); + RouteProtectSwitchStruct* szRouteProSwDataBuf = GetRouteRelatedProtSwitchData(routeId); + /* ֲʼ */ + UINT8 ii = 0U; /* ѭ */ + UINT8 reVal = CI_ERROR; + UINT8 chSwState = 0U;/*״̬*/ + + if ((NULL != szRouteSwDataBuf) && (NULL != szRouteProSwDataBuf)) + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (ii = 0u; ii < chRouteSwSum; ii++) + { + chSwState = GetSwitchCurPosition(szRouteSwDataBuf[ii].SwitchId); + if (chSwState == szRouteSwDataBuf[ii].SwitchPosition) + { + /*λȷ*/ + ; + } + else + { + /*λòȷ*/ + reVal = CI_ERROR; + break; + } + } + + if (CI_SUCCESS == reVal) + { + for (ii = 0u; ii < chRouteProSwSum; ii++) + { + chSwState = GetSwitchCurPosition(szRouteProSwDataBuf[ii].ProtectSwitchId); + if (chSwState == szRouteProSwDataBuf[ii].ProtectPosition) + { + /*λȷ*/ + ; + } + else + { + /*λòȷ*/ + reVal = CI_ERROR; + break; + } + } + } + else + { + ; /*ʧ*/ + } + } + else + { + ; /*ʧ*/ + } + + /*ȫͨ*/ + return reVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicCheck.h b/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicCheck.h new file mode 100644 index 0000000..636ec6a --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicCheck.h @@ -0,0 +1,2723 @@ +/******************************************************** +* +* InterlockLogicCheck.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-10 +* ߣ +* ߼ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _INTERLOCK_LOGIC_CHECK_H_ +#define _INTERLOCK_LOGIC_CHECK_H_ + +#include "../ERROR/ErrorDataManage.h" +#include "../ERROR/ErrorDefine.h" +#include "../Route/RouteDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../System/SystemParameterManage.h" +#include "../System/CiSystemDefine.h" +#include "../Overlap/OverlapDataManage.h" +#include "../Overlap/OverlapConfigDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../psd/PSDDataManage.h" +#include "../Section/LogicSectionDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../NonRoute/NonRouteConfigDataManage.h" +#include "../AutoReturn/AutoReturnDataManage.h" +#include "../AutoRoute/AutoRouteDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../AllAutoReturn/AllAutoReturnDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" +#include "../WashMachine/WashMachineDataManage.h" +#include "../InvadeSection/InvadeSectionConfigDataManage.h" +#include "../Train/TrainOnAcManage.h" +#include "../DataManage/DeviceConfigDataManage.h" + +/* +* ·źŻ״̬ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteSignalFLockCheck(UINT16 const routeId, UINT16 *pDevId,UINT8 *pDevState); + + + +/* +* ·жЧ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ж +* CI_SUCCESS ж +*/ +UINT8 RouteSignalEnemyVainCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ·жЧ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ж +* CI_SUCCESS ж +*/ +UINT8 ReverseRouteSigEnemyVainCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ·նźŻΪCBTC +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CheckRouteEndSignalNotCbtc(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·ղ +* ˵ UINT16 const routeId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* RELAY_STATE_WAITE ·ղ̵--ȴ +* RES_CHECK_STATE_WAITE Դ鱾ղ̵--ȴ +*/ +UINT8 RouteRelayZhaoChaCheck(UINT16 const routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* ·ղ +* ˵ UINT16 const checkRouteId ·κ +* UINT16 const zcPhySecId ղκ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RoutePhySecZhaoChaCheck(UINT16 const checkRouteId ,UINT16 const zcPhySecId,UINT16 *pDevId,UINT8 *pDevState ); + + +/* +* ·ȫм +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllSecOccuClearCheck(UINT16 const routeId, UINT16 *pDevId,UINT8 *pDevState); + + + +/* +* ·߼κͽ·߼ȫм +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221007 ·ǰ +*/ +UINT8 RouteAllLogSecOccuClearCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ʽ·߼ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221007 ·ǰ +*/ +UINT8 BlockRouteLogSecLockValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ʽ·ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 BlockRouteSecLockValidCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ·ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 DTrainRouteSecLockValidCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ·ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 ReverseRouteSecLockValidCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ·߼ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ +*/ +UINT8 ReverseRouteLogSecLockValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + + + +/* +* ·Ч +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS ޲ +*/ +UINT8 RouteIntruSecVainCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + + + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteSwitchYLockCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + + + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteSwitchFLockCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + + + +/* +* ·λúͶЧԼ +* ˵ UINT16 const routeId, · +* UINT8 sendLevel ȼ +* ֵ CI_ERROR +* CI_SUCCESS +* edit cgh 20241204 +*/ +UINT8 RouteSwitchPosAndMoveValidCheck(UINT16 const routeId, UINT8 sendLevel); + +/* zt ɾش 2022-02-15 */ + + +/* +* CBTC·ЧԼ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteCbtcSecLockValidCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* CBTC·߼ЧԼ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221005 ·ǰ⶯ +*/ +UINT8 RouteCbtcLogSecLockValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·գ·εķǽ·ҷǵ߼ЧԼ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ⶯ +*/ +UINT8 RouteOutLogSecLockValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·еλȷ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllSwitchPosCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* zt ɾش 2022-02-15 */ + +/* +* ·λȷ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteRelatedProSwitchPosCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ·ռ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteRelatedProSwitchLockCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* · +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteRelatedProSwitchYLockCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState ); + +/* +* ·λúͶЧԼ +* ˵ UINT16 const routeId, · +* UINT8 sendLevel ͵ȼ +* ֵ CI_ERROR +* CI_SUCCESS +* edit cgh 20241203 +*/ +UINT8 RouteRelProSwiPosAndMovValCheck(UINT16 const routeId, UINT8 sendLevel); + +/* +* շ +* ˵ const UINT16 overlapId ID + UINT8 plockDirect շ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapAllSecLockDirectCheck(const UINT16 overlapId, UINT8 plockDirect, UINT16 *pDevId,UINT8 *pDevState); + +/* +* Overlapοм +* ˵ UINT16 const overlapId +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapAllSecOccuClearCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* Overlapü +* ˵ UINT16 const overlapId +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pAlarmType ͣأ +* ֵ CI_ERROR 0 ȫδ +* CI_SUCCESS 1 ȫδ +* RETURN_WAIT_SWITCH_USING 0x30 ȴ +*/ +UINT8 OverlapAllSecUsingClearCheck(UINT16 const overlapId, UINT16* pDevId, UINT8* pDevState, UINT8* pAlarmType); + + +/* +* ״̬ЧԼ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapAllSecLockValidCheck(UINT16 const overlapId,UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + + +/* +* overlap״̬ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapSwitchYLockCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + + +/* +* overlap״̬ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OvlpRelatedProSwitchYLockCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + + +/* +* ε״̬ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapSwitchFLockStateCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + + +/* +* εЧԼ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapSwitchMoveValidCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ιЧԼ +* ˵UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8 *pAlarmType, ͣأ +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* RETURN_WAIT_SWITCH_CHECK 0x31 ȴ +*/ +UINT8 OvlpRelatedProtSwiMovValCheck(UINT16 const overlapId, UINT16* pDevId, UINT8* pDevState, UINT8* pAlarmType); + +/* zt ɾش 2022-02-15 */ + +/* +* ελȷ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapSwitchPosCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ιλü +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OvlpRelatedProtSwitchPosCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ιռ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OvlpRelatedProtSwitchLockCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* zt ɾش 2022-02-15 */ + +/* +* ۷· +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapAllReturnRouteCheckup(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* +: μ +: UINT16 const overlapId ID +: UINT16 *pDevId 豸Id + UINT8 *pDevState 豸״̬ +ֵ: CI_SUCCESS + CI_ERROR +*/ +UINT8 OverlapInvSecAndConSwiCheckup(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + + +/* +: ι޵жԱμ +: UINT16 const overlapId ID +: UINT16 *pDevId 豸Id + UINT8 *pDevState 豸״̬ +ֵ: CI_SUCCESS + CI_ERROR +*/ +UINT8 OverlapInvOppOverlapCheckup(UINT16 const overlapId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllSecLockStateCheck(UINT16 const routeId,UINT8 checkState,UINT16 *pDevId,UINT8 *pDevState); + + + +/* +* վ̨رհťЧ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteEsbVainCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + + + +/* +* s20_վ̨Źرռ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RoutePsdCloseCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + + + +/* +* źŻID鿪״̬ +* ˵ UINT8 *dataIdBuf, +* UINT8 checkSum, 鳤 +* UINT8 checkState, 鳤 +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SignalBufOpenCloseStateCheck(UINT16 *dataIdBuf,UINT8 checkSum,UINT8 checkState, + UINT16 *pDevId,UINT8 *pDevState); + + +/* +* ·δ״̬ +* ˵ RoutePhysicalSectionStruct *dataIdBuf, +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllSecUseVainCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ֽ·δ״̬ +* ˵ UINT16 const routeId +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 HalfRouteAllSecUseVainCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + +/* +*ܣ鲿ֽ·ε +*˵const UINT16 routeId ·ID +*ֵ0ʧ +* 1ɹ +*/ +UINT8 CheckProSwUseStateInHalfRoute(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + + + +/*****************************************************************************************/ + +/* +* ·ҪǷмζ +* ˵ UINT16 routeId · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CheckDTrainRoutePhySecOccupy(const UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·źűռ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckDTrainKeepSigPhySecOccupy(const UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·λúͶЧԼ +* ˵ +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 NonRouteSwitchPosMovValCheck(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·λúͶЧԼ +* ˵ +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 NonRouteRelProSwiPosMovValCheck(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·ȷ +* ˵ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 CheckRouteSwitchPosRight(const UINT16 routeId); + + +/* +: ·ǷҪ +: const UINT16 routeId ·ID; +: +ֵ: 0x55:Ҫ,0xAA:豻 +*/ +UINT8 CheckRoutAssoSwitNeedDriv(const UINT16 routeId); + + +/* +* ǽ·źŻδ˿ +* ˵ +* ֵ 0 źŻ˿ +* 1: ǽ·źŻδ˿ +*/ +UINT8 CheckNonRouteSignalNoBreak(UINT8 nonRouteId,UINT8 functionId, UINT8 sendLevel); + +/* +* ǽ·ǷźŻ +* ˵ const UINT16 routeId, ·ID +* ֵ 0 źŻ +* 1: ·źŻδ +*/ +UINT8 CheckNonRouteSignalFengSuo(UINT8 nonRouteId,UINT8 functionId, UINT8 sendLevel); + +/* +* ǽ·źŻ֮ǰ +* ˵ +* ֵ 0 źŻ +* 1: ·źŻδ +*/ +UINT8 CheckNonRouteSignalPreDrvOpen(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·еĵжźǷ +* ˵ UINT16 routeId · +* ֵ1жԳ +* 0: жԲ +*/ +UINT8 CheckNonRouteEnemySignal(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ· +* ˵ +* ֵ1 +* 0: +*/ +UINT8 CheckNonRoutePhySecUsing(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·еǷζδ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckNonRoutePhySectionUnLock(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·Ƿе +* ˵ +* ֵ 0 е +* 1: ·еδ +*/ +UINT8 CheckNonRouteSwitchFengSuo(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·Ƿ +* ˵ +* ֵ 0 зδ +* 1: зѷ +*/ +UINT8 CheckNonRouteRelProSwiLockSta(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·Ƿе +* ˵ const UINT16 routeId, ·ID +* ֵ 0 е +* 1: ·еδ +*/ +UINT8 CheckNonRouteSwitchYinSuo(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·Ƿ +* ˵ const UINT16 routeId, ·ID +* UINT8 functionId,Id +* UINT8 sendLevel,ͼ +* ֵ 0 е +* 1: ·еδ +*/ +UINT8 CheckNonRouteRelProSwiYinSuo(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·ռ״̬ +* ˵ +* ֵ1 +* 0: +*/ +UINT8 CheckNonRoutePhySectionOccupy(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·еǷζ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckNonRoutePhySectionLock(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ǽ·ȷ +* ˵ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 CheckNonRouteSwitchPosRight(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ʽ·гʻ +* ˵ UINT16 routeId · +* ֵ1 +* 0: +*/ +UINT8 CheckPhySecFaultTrainCrossRoute(const UINT16 routeId); + +/* +* ǽ·Ч +* ˵ +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS ޲ +*/ +UINT8 NonRouteIntruSecVainCheck(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* Զ۷·ǷеִԶ·Ѱ +* ˵ +* UINT16 autoReturnIdԶ·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR ִ +* CI_SUCCESS ִ +*/ +UINT8 AutoReturnIsOpposedCheck(UINT16 autoReturnId, UINT8 functionID); + +/* +* Զͨ·ǷеִԶ·Ѱ +* ˵ +* UINT16 autoReturnIdԶ·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR ִ +* CI_SUCCESS ִ +*/ +UINT8 AutoRouteIsOpposedCheck(UINT16 autoRouteId, UINT8 functionID); + +/* +* ָ·ʼźŻΪնźŻ۷·Ѱ +* ˵ +* UINT16 *dataIdBuf, +* UINT8 checkSum, 鳤 +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR δͨ +* CI_SUCCESS ͨ +*/ +UINT8 RtnEndSigAsStartSigRouteCheck(UINT16 *pDataIdBuf,UINT8 checkSum,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ·һȫм +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ״̬鲻ͨ +* CI_ERROR_QXZC ȡղ +* CI_SUCCESS +*/ +UINT8 RouteExceptLastSecOccuClrCheck(UINT16 const routeId); + +/* +* ȫԶ۷·ǷеִԶ·Ѱ +* ˵ +* UINT16 allAutoReturnId + +* ֵ CI_ERROR ִ +* CI_SUCCESS ִ +*/ +UINT8 AllAutoReturnIsOpposedCheck(UINT16 allAutoReturnId, UINT8 chFunctionId); + + +/* +* ·η +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteSecFLockCheck(UINT16 const routeId, UINT16 *pDevId,UINT8 *pDevState ); + + +/* +* η״̬ЧԼ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapAllSecFLockValidCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* +* ˵ UINT16 routeId ·ID +* UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS routeId, functionId, sendLevel +*/ +UINT8 OtherCiValidCheck(UINT16 const routeId,UINT8 const functionId,UINT8 const sendLevel); + +/* +* ſ +* ˵ const UINT16 garageDoorId, ID +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +*/ +UINT8 DriveGarageDoorOpenCheck(const UINT16 garageDoorId); + +/* Ź +* ˵ const UINT16 garageDoorId, ID +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +*/ +UINT8 DriveGarageDoorCloseCheck(const UINT16 garageDoorId); + +/* RCģʽ´ռʱŹ +* ˵ const UINT16 garageDoorId, ID +* const UINT8 sendLevel ǷATSͶӦ +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +*/ +UINT8 GarageDoorCloseCheckinRCMode(const UINT16 garageDoorId, const UINT8 sendLevel); + +/* Źڼ +* ˵ const UINT16 garageDoorId, ID +* const UINT8 functionId ú +* const UINT8 sendLevel 뷢ͼ +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +*/ +UINT8 CheckAdjacentACOfGarageDoor(const UINT16 garageDoorId, const UINT8 functionId, const UINT8 sendLevel); + + +/* ӽг +* ˵ const UINT16 garageDoorId, ID +* const UINT8 functionId ú +* const UINT8 sendLevel 뷢ͼ +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +*/ +UINT8 CheckNearestTrainOfGarageDoor(const UINT16 garageDoorId, const UINT8 functionId, const UINT8 sendLevel); + + +/* A +* ˵ const UINT16 garageDoorId, ID +* const UINT8 functionId ú +* const UINT8 sendLevel 뷢ͼ +* ֵ CI_ERRORʧ +* CI_SUCCESSͨ +*/ +UINT8 CheckAkuPhysecOfGarageDoor(const UINT16 garageDoorId, const UINT8 functionId, const UINT8 sendLevel); + + + +/* L12_ʽ·źſź */ +/* +* ʽ·źſź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* OpenBlocRouteOtherSignalCheck +*/ +UINT8 OpenBlocRouteOtherSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L14_ʽ·źűź */ +/* +* ʽ·źűź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepBlocRouteOtherSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·Ծ״̬ +* ˵ UINT16 const routeId, · +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ ʧܷCI_ERROR +* ɹCI_SUCCESS +*/ +UINT8 RouteAllSecJumpLockStateCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ·źűֵ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepRouteSwitchCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); +/* +* г·źŻ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLTrainRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + + +/* L07_ʽ·յ */ +/* +* ʽ·յ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LockBlocRouteSwitchCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* յʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ⶯ +*/ +UINT8 LockBlocRouteSectionCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* CBTCг· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ⶯ +*/ +UINT8 LockCBTCRouteSectionCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* ·Ƿеʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 + CI_SUCCESS:·޵ʱ + CI_ERROR:·еʱ +*/ +UINT8 ChekRoutSwitDrivOvtmStat(const UINT16 routeId); + +/* +* ιϽ +* ˵ UINT16 const phySectionId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_UNLOCK_FAULT_SECTION +*/ +UINT8 PhySecFaultUnlockLogicProcess(const UINT16 phySectionId); + +/* +* ·˽ĿԡֻҪ·һοֱӽ̹Ϊ˽С +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +CI_SUCCESS:˽ִ +CI_ERROR:˽ⲻִ +*/ +UINT8 CheckRouteZongRenJieFeasibility(const UINT16 routeId); + +/* +* ·˽ĿԡֻҪ·һοֱӽ̹Ϊ˽Сע·˽ⲻɵøú +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 +CI_SUCCESS:˽ִ +CI_ERROR:˽ⲻִ +*/ +UINT8 CheckDiaoCheRouteZRJFeasibility(const UINT16 routeId); + +/* +ձ +UINT16 const overlapId ID +UINT8 PLockDirect շ + +CI_SUCCESS ɹ +CI_ERROR ʧ + +*/ +UINT8 LockLocalOvlpCheckHlht(const UINT16 overlapId, UINT8 PLockDirect); + +/* + +UINT16 overlapId ID + +CI_SUCCESS ɹ +CI_ERROR ʧ + +*/ +UINT8 UnlockLocalOvlpCheckHlht(UINT16 overlapId); + +/* +* ս·overlap߼,·ԼCIDZڻͨ +* ˵ const UINT16 routeId, const UINT16 overlapId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_OVER_LAP +*/ +UINT8 LockOthCiOvlpCheckHlht(const UINT16 routeId, const UINT16 overlapId); + +/* +* 豸״̬ +* ˵ UINT16 routeId ·ID +* RouteOhterCheckStruct *pOtherDevInfo +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OtherCiDevStatusCheck(UINT16 const routeId, const RouteOtherCheckStruct *pOtherDevInfo,UINT16 *pDevId, UINT8 *pDevState); + +/* +: ·նźŻЧԼ +: UINT16 const routeId ·ID +: UINT16 *pDevId 豸Id +UINT8 *pDevState 豸״̬ +ֵ: CI_SUCCESS +CI_ERROR +*/ +UINT8 SignalOverlapValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ʽ·ź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* Ž· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLTrainRouteSwitchCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* ʽ۷·źűź */ +/* +* ʽ۷·źűź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepBlocReturnSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L01_ʽ·źŻ */ +/* +* ʽ·źŻ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetBlocRouteSignalCheck( UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L11_ʽ·źվ̨ */ +/* +* ʽ·źվ̨ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenRoutePlatformCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·ȫվ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LeadzLockCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* г·źŻ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLTrainRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L09_ʽ·źŵ */ +/* +* ʽ·źŵ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocRouteSwitchCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L10_ʽ·źű */ +/* +* ʽ·źű +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocRouteOverlapCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* zt ɾش 2022-02-15 */ + +/*һεЧǷڳ +* ˵ +* const UINT16 switchId, ID +* const UINT8 swtCurPos, λ +*ֵ CI_ERROR ڳɶ +* CI_SUCCESS ûгɶ +*/ +UINT8 checkSwtLastValDrvPosStayorNot(const UINT16 switchId,const UINT8 swtCurPos); + + + /* +* ձμʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 + CI_SUCCESS:޵ʱ + CI_ERROR:еʱ +*/ +UINT8 ChekSwitDrivOvtm(const UINT16 overlapId); + +/* +* Զͨ·ڷźŻεķ +* ˵ const UINT16 autoRouteId, Զͨ·ID +* ֵ UINT8 + CI_SUCCESS:޷ + CI_ERROR:з +*/ +UINT8 ChekAutoRouteFlockState(const UINT16 autoRouteId); + +/* +* Զ۷·ڷźŻεķ +* ˵ const UINT16 autoReturnId, Զͨ·ID +* ֵ UINT8 + CI_SUCCESS:޷ + CI_ERROR:з +*/ +UINT8 ChekAutoReturnFlockState(const UINT16 autoReturnId); + +/* +* ȫԶ۷·ڷźŻεķ +* ˵ const UINT16 allAutoReturnId,ȫԶ۷·ID +* ֵ UINT8 + CI_SUCCESS:޷ + CI_ERROR:з +*/ +UINT8 ChekAllAutoReturnFlockState(const UINT16 allAutoReturnId); +/* +* Զ·ڷźŻεķ +* ˵ +* ֵ UINT8 + CI_SUCCESS:޷ + CI_ERROR:з +*cgh-ϲCID-3037-4 +*/ +UINT8 ChekAutoTriggerRouteFlockState(UINT16 routeId); +/* +* ·ڷźŻεķ +* ˵ const UINT16 autoRouteId, ·ID +* const UINT8 functionId, ID +* ֵ UINT8 + CI_SUCCESS:޷ + CI_ERROR:з +*/ +UINT8 ChekRouteFlockState(const UINT16 routeId, const UINT8 functionId); +/* +* Ծ״̬ +* ˵ UINT16 const overlapId, ID +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ ʧܷCI_ERROR +* ɹCI_SUCCESS +*/ +UINT8 OverlapAllSecJumpLockStateCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* Źռü +* ˵ +* UINT16 floodGateId, Id +* UINT16 *pDevId, 豸idָ룬ȡid +* UINT8 *pDevState, 豸id״ָ̬룬ȡ״̬ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 FloodGateAccessPhysecAcCheck(UINT16 floodGateId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ŷռü +* ˵ +* UINT16 floodGateId, Id +* UINT16 *pDevId, 豸idָ룬ȡid +* UINT8 *pDevState, 豸id״ָ̬룬ȡ״̬ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 FloodGateProtPhysecOccuCheck(UINT16 floodGateId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ι״̬ +* ˵ UINT16 const overlapId, ID +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevStateType,豸״̬ͣأ +* UINT8 *pDevState, 豸״̬أ +* ֵ ʧܷCI_ERROR +* ɹCI_SUCCESS +*/ +UINT8 OverlapFloodGateStateCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevStateType,UINT8 *pDevState); + +/* +* Զͨ·ڷ״̬ +* ˵ const UINT16 autoRouteId, Զͨ·ID +* ֵ UINT8 + CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 AutoRouteFloodStateCheck(const UINT16 autoRouteId); + +/* +* Զ۷·ڷ״̬ +* ˵ const UINT16 autoReturnId, Զ۷·ID +* ֵ UINT8 + CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 AutoReturnFloodStateCheck(const UINT16 autoReturnId); + +/* +* ȫԶ۷·ڷ״̬ +* ˵ const UINT16 allAutoReturnId, ȫԶ۷·ID +* ֵ UINT8 + CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 AllAutoReturnFloodStateCheck(const UINT16 allAutoReturnId); + + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteReltProtSwitchFLockCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + + +/* +* ι״̬ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OvlpRelProtSwiFLockStaCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + + +/* +* ǽ·Ƿе +* ˵ +* ֵ 0 е +* 1: ·еδ +*/ +UINT8 CheckNonRouteRelProSwiFengSuo(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·η״̬ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteRelProtSwitchSecFLockCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + + +/* +* ιη״̬ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OvlpRelProSwiSecFLockStaCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ǽ·Ƿη +* ˵ +* ֵ 0 α +* 1: ɹûб +*/ +UINT8 CheckNonRouteRelProSwitSecFLock(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* Զ·ڷŵ״̬ +* ˵ +* ֵ UINT8 + CI_SUCCESS:޷ + CI_ERROR:з +*/ +UINT8 ChekAutoTrigRouteFloodGateState(UINT16 routeId); + + +/* +* ǽ·Ƿα +* ˵ +* ֵ 0 е +* 1: ·еδ +*/ +UINT8 CheckNonRoutePhysecFengSuo(UINT8 nonRouteId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·նźŻ˿ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CheckRouteEndSignalDS(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ״̬ +* ˵ +* UINT16 floodGateId, ű +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* RETURN_OPEN_ERR_SIGOPEN +*/ +UINT8 FloodGateStateCheck(UINT16 floodGateId,UINT8 functionId,UINT8 sendLevel); + +/* +* ԾǷеʱ +* ˵ const UINT16 routeId, ·ID +* ֵ UINT8 + CI_SUCCESS:޵ʱ + CI_ERROR:еʱ +*/ +UINT8 ChekJumpLockSwitDrivOvtmStat(const UINT16 axisSecId); + +/* +* Ծμ +* ˵ const UINT16 axisSecId, ID +* ֵ UINT8 + CI_SUCCESS:ͨ + CI_ERROR:ʧ +*/ +UINT8 JumpLockSecStateCheck(const UINT16 axisSectionId,UINT8 funcId,UINT8 sendLevel); + + + +/* +* Ծյ +* ˵ const UINT16 axisSecId, ID +* ֵ UINT8 + CI_SUCCESS:ͨ + CI_ERROR:ʧ +*/ +UINT8 JumpLockSwitchCheck(const UINT16 axisSecId,UINT8 funcId,UINT8 sendLevel); + + +/* +* ε״̬ +* ˵ UINT16 const axisSecId, α +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 AxisSecSwitchYZLockCheck(UINT16 const axisSecId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ε״̬ +* ˵ UINT16 const axisSecId, α +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 AxisSecSwitchFLockCheck(UINT16 const axisSecId,UINT16 *pDevId,UINT8 *pDevState); + +/* +* ελúͶЧԼ +* ˵ UINT16 const axisSecId, α +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 AxisSecSwitchPosMoveValCheck(UINT16 const axisSecId,UINT16 *pDevId,UINT8 *pDevState,UINT8 funcId,UINT8 sendLevel); + +/* +* еλȷ +* ˵ UINT16 const axisSecId, α +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 AxisSecAllSwitchPosCheck(UINT16 const axisSecId,UINT16 *pDevId,UINT8 *pDevState); +/* +* ָ·źŻⷽһελü +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteOutfirstPhySecSwiPosCheck(UINT16 const routeId); +/* +* ָӽǰλü +* ˵ RouteNearPhySectionStruct* pRouteNearPSSecStru, ·ӽνṹ +* UINT16 outPhySecId źŻⷽһID +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 BlocNearConditionSwitchPosCheck(RouteNearPhySectionStruct* pRouteNearPSSecStru,UINT16 outPhySecId); + +/* +* г·ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 TradLTrainRouteSecLockValCheck(UINT16 const routeId,UINT16 *pDevId,UINT8 *pDevState); + +/* +*ܣԶϽ·Զ·Ƿ +*˵const UINT16 autoRouteId Զ·ID +*ֵ +*/ +UINT8 GroupInAutoRouteConditionCheck(UINT16 autoRouteId); + +/* +*ܣڵǷü +*˵const UINT16 overlapIdID +*ֵCI_ERROR:صδ +* CI_SUCCESSص +*/ +UINT8 OvlpIncludeAndProtSwitchCheck(const UINT16 overlapId); +/* +*ܣδڷʱǷ԰ +*˵const UINT16 devId ID +* const UINT16 routeId ѾûҪøεĽ· +*ֵ0ʧ +* 1ɹ +*/ +UINT8 CheckPhysecUseState(const UINT16 devId,const UINT16 routeId); +/* +*ܣδʱǷ԰ +*˵const UINT16 devId ID +* const UINT16 overlapId ID +*ֵ0ʧ +* 1ɹ +*/ +UINT8 CheckOverlapPhysecUseState(const UINT16 devId,const UINT16 overlapId); +/* +*ܣü +* const UINT16 overlapId ID +* UINT16 *pDevId 豸ID +*ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ͨ +* RETURN_WAIT_SWITCH_USING 0x30 ȴ +*/ +UINT8 CheckOverlapSwitchUseState(const UINT16 overlapId, UINT16* pDevId); + +/* +* Overlapг +* ˵ UINT16 const overlapId +* UINT16 *pTrainId, гţأ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapLogicSectionTrainCheck(UINT16 const overlapId, UINT16 *pTrainId); + +/* +* ο߼ +* ˵ UINT16 const routeId, UINT16 const overlapId +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +*/ +UINT8 OverlapUsableCheck(UINT16 const wOverlapId); + +/* +* ߼ԴԼ +* ˵ UINT16 const wLogicSecId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOGIC_RES_APP_CHECK +*/ +UINT8 LogicSecResApplicabilityCheck(UINT16 const wLogicSecId); + +/* +* ߼·߼ԴԼ +* ˵ UINT16 const wLogicSecId ߼ID +* UINT16 const wLogRouteId ߼·ID +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOGROUTE_LOGIC_RES_APP_CHECK +*/ +UINT8 LogRouteLogSecResAppCheck(UINT16 const wLogicSecId, UINT16 const wLogRouteId); + +/* +* ߼Դ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogicSecResSectionCheck(UINT16 wLogicSecId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼·߼Դ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT16 wLogicSecId, ߼ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteLogicSecResSectionCheck(UINT16 wLogicSecId, UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼ԴԼ +* ˵ +* UINT16 wLogicSecId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogicSecResSwitchCheck(UINT16 wLogicSecId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼Ծ״̬ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-02 +*/ +UINT8 LogicSecJumpLockCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼Ч +* ˵ +* UINT16 const physicalId, ID +* ֵ CI_ERROR +* CI_SUCCESS ޲ +* +*/ +UINT8 LogicIntruSecVainCheck(UINT16 const wLogicSecId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·һ߼εһ߼ռ +* ˵UINT16 const wLogicSecId, ߼ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ͨ +* CI_SUCCESS ʧ +* +*/ +UINT8 LogicNextLogSecLockCheck(UINT16 const wLogicSecId, UINT16* pDevId, UINT8* pDevState); +/* +* ߼·һ߼εһ߼ռ +* ˵UINT16 const wLogicSecId, ߼ID +* UINT16 const wLogRouteId, +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +* +*/ +UINT8 LogRouteNextLogSecLockCheck(UINT16 const wLogicSecId, UINT16 const wLogRouteId, UINT16* pDevId, UINT8* pDevState); + +/* +* ߼״̬(ջ) +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecRltvPrtctSwLockCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼λü +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecRltvPrtctSwPosCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼δ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecRltvPrtctSwFLockCheck(UINT16 const wLgcId, UINT16* pDevId, UINT8* pDevState, UINT8* pYLockAlarmFlag); + +/* +* ߼δ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecRelSwitchFLockCheck(UINT16 const wLgcId, UINT16* pDevId, UINT8* pDevState, UINT8* pYLockAlarmFlag); + +/* +* ߼η״̬ +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +*/ +UINT8 LogicSecFLockCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼λü +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +* ʹ߼ιм +*/ +UINT8 LogicSecRelativeSwitchPosCheck(UINT16 const wLgcId, UINT16* pDevId, UINT8* pDevState); + +/* +* ·VBTCµһ߼μ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +*/ +UINT8 RouteCbtcFirstLgcSecCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ۷·VBTCµһ߼μ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +*/ +UINT8 RouteCbtcReturnFirstLgcSecCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·ȫɼм +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllSecColOccuClearCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·ȫɼм +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteFaultOccuCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllLgcSecXianSuCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* Overlapοм +* ˵ UINT16 const overlapId +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlockOvlpAllSecOccuClrCheck(UINT16 const overlapId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* źſʱ·οм +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +*/ +UINT8 KeepCbtcReturnRouteSecOccCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* CBTC·гʻ(CBTCʹ) +* ˵ +* UINT16 const routeId, · +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ һг׼ʻ·½·ź +*/ +UINT8 RouteCbtcTiranEnterCheck(UINT16 const routeId); + +/* +* ·գ·εķǽ·ҷǵ߼δռѹ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ⶯ +*/ +UINT8 RouteOutLogSecOccClearCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* CBTC·ڵһ߼δ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221005 Ż·飬·ʱһλù߼δ +*/ +UINT8 RouteSwOtherLogLockValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* г· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ⶯ +*/ +UINT8 LockLeadRouteSectionCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼β +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* +*/ +UINT8 LogicSecSwitchLtrlDfncCheck(UINT16 const wLgcId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·ȫ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteAllLtrlDfncSwitchCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·ȫ豸 +* ˵ UINT16 routeId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteContactLineDevSwitchCheck(UINT16 const routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* ʽ·źſź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* RETURN_OPEN_ERR_SIGOPEN +*/ +UINT8 OpenCbtcRouteOtherSignalCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); +#if 0 +/* +* ʽ·źűź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepCbtcRouteOtherSignalCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); +#endif +/* +* atsձռü +* ˵ UINT16 const overlapId +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 AtsLockOverlapSecOccupyCheck(UINT16 const overlapId,UINT16 *pDevId,UINT8 *pDevState); +/* +* ָ·ⷽ߼״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0ȡʧ + >0:ռ״̬ռor +*/ +UINT8 CheckRouteIdOutFirstLogSecState(const UINT16 routeId,UINT16 *logicSecId); +#if 0 +/* +* @func ߼δڱʱ· +* @param UINT16 wLgcSecId, ߼ID + +* @return CI_ERROR +* CI_SUCCESS +*/ +UINT8 OverlapLgcResMainRtCheck(UINT16 wLgcSecId); +#endif +/* +* Ƿгѹ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS:δѹ + CI_ERROR:ѹ +*cgh-ϲCID-2341-5 +*/ +UINT8 CheckEngineerVehicleNear(const UINT16 routeId); +/* +* ηerrorcode +* ˵ const UINT16 phySectionId, ID +* const UINT8 functionId ID +* const UINT8 sendLevel ͼ +* const UINT8 devState 豸״̬ +* ֵ +* add by pfq 2022.04.21 +*/ +void AccToPhySecFlockTypeSetErrcode(const UINT16 phySectionId, const UINT8 functionId, const UINT8 sendLevel, const UINT8 devState); +/* +* CBTC·źűź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepCBTCRouteOtherSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·״̬ +* ˵ UINT16 const routeId, · +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LeadRouteSecLockStateCheck(UINT16 const routeId, UINT8 checkState, UINT16* pDevId, UINT8* pDevState); +/* +* Զ۷Ƿͨ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESSԶ۷ͨ + CI_ERROR:Զ۷ʧ + 2022.08.03 add by pfq ۷гռʱжϵִ·Ϊ۷·ҽ·һռԶ۷ +*/ +UINT8 JudgeSetAutoTriggerFlagIsValid(const UINT16 routeId); + +/* +* ·߼ЧԼ +* ˵ +* UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221007 ·ǰ +*/ +UINT8 LeadRouteLogSecLockValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ζӦж +* ˵ +* UINT16 const wInvaSectId, ID +* ֵ CI_ERROR +* CI_SUCCESS ޲ +* cgh-20230422 +*/ +UINT8 IntruSecVainCheck(UINT16 const wInvaSectId); + + +/* +* ·ղ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfSecLockCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·ղη +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfSecFLockCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·ղ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfIntruSecCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼λü +* ˵ UINT16 const routeId, ·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +* ʹ߼ιм +*/ +UINT8 LogicSwitchMoveValidCheck(UINT16 const wLgcId, UINT8 routeHalfSwitchMoveStt, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel); + +/* +* ·ղ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfSwitchMoveValidCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼ηλüɶԼ +* ˵ UINT16 const wLgcId, ߼ID +* UINT8 const routeHalfSwitchMoveStt ؽ·Ƿɶ־ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* qw.liu 2022-03-01 +* ʹ߼ιм +*/ +UINT8 LogicProSwitchMoveValidCheck(UINT16 const wLgcId, UINT8 const routeHalfSwitchMoveStt, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel); + +/* +* ·ղַ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfProSwitchMoveValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·ղֵ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfSwitchFLockCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState, UINT8* pYLockAlarmFlag); + +/* +* ·ղֵλü +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfSwitchPosCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ·ڲԾ״̬ +* ˵ UINT16 const routeId, · +* UINT8 checkState, ȶֵ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ ʧܷCI_ERROR +* ɹCI_SUCCESS +*/ +UINT8 RouteHalfSecJumpLockStateCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + + + +/* +* ֶν· +* ˵ UINT16 const routeId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteFenDuanConditionCheck(UINT16 const routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* · +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR ͨ +* CI_SUCCESS ͨ +*/ +UINT8 MainRouteCheck(UINT16 const routeId); + +/* +* ӽ· +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR ͨ +* CI_SUCCESS ͨ +*/ +UINT8 SubRouteCheck(UINT16 const routeId); +/* +* ·ղַλ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfProSwitchPosCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼Ƿ +* const UINT8 cLogSecSeqDir ߼з +* const UINT8 cLogSecSum ߼ +* const UINT16 pLogSecIdBuff[] ߼ +* UINT8 pQueryDir[] ÿ߼ζӦIJѯ +* ֵ CI_ERROR ߼в +* CI_SUCCESS ߼ +*/ +UINT8 LogSecSeqIsContinuousCheck(const UINT8 cLogSecSeqDir, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[], UINT8 pQueryDir[]); + +/* +* ߼·ƥ +* const UINT8 cEndSignalSum ߼йնźŻ +* const UINT16 wEndSignalIdBuff[] ߼йնźŻID +* const UINT8 cSplitLogSecSumBuff[] ֺ߼а߼ +* const UINT16 pSplitLogSecIdBuff[][MAX_ROUTE_IN_LT_NUM] ֺ߼а߼ID +* UINT16 pMatchedRouteIdBuff[] ߼ƥĽ·ID +* UINT8* pLogicRouteFlag ߼·ڱ־ +* ֵ CI_ERROR ƥʧ +* CI_SUCCESS ƥɹ +*/ +UINT8 LogSecSeqAndRouteMatchCheck(const UINT8 cEndSignalSum, const UINT16 pEndSignalIdBuff[], const UINT8 pSplitLogSecSumBuff[], const UINT16 pSplitLogSecIdBuff[][MAX_ROUTE_IN_LT_NUM], UINT16 pMatchedRouteIdBuff[], UINT8* pLogicRouteFlag); + +/* +* ƥ·г· +* const UINT8 cEndSignalSum ߼йնźŻ +* const UINT8 szRouteSum[ROUTE_SUBROUTE_SUM_MAX] ÿ߼ƥ䵽ĿܵĽ· +* const UINT16 szRouteId[ROUTE_SUBROUTE_SUM_MAX][MAX_ROUTE_IN_LT_NUM] ÿ߼ƥ䵽ĿܵĽ·ID +* UINT16 szMatchedRouteId[ROUTE_SUBROUTE_SUM_MAX] ߼ƥĽ·ID +* ֵ CI_ERROR ƥʧ +* CI_SUCCESS ƥɹ +* Created By LQ 2024.05.07 +*/ +UINT8 MatchNonMainAndLieCheRoute(const UINT8 cEndSignalSum, const UINT8 szRouteSum[ROUTE_SUBROUTE_SUM_MAX], const UINT16 szRouteId[ROUTE_SUBROUTE_SUM_MAX][MAX_ROUTE_IN_LT_NUM], UINT16 szMatchedRouteId[ROUTE_SUBROUTE_SUM_MAX]); + +/* +* ߼س +* const UINT16 wTrainId гID +* const UINT8 cLogSecSum е߼ +* const UINT16 pLogSecIdBuff[] ߼ +* +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +UINT8 LogSecSeqIncUTCheck(const UINT16 wTrainId, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[]); + +/* +* ·ղַ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfProSwitchFLockCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState, UINT8* pYLockAlarmFlag); + +/* +* ·ȫ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfLtrlDfncSwitchCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ֽ·ȫ豸 +* ˵ UINT16 routeId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 RouteHalfContactLineDevCheck(UINT16 const routeId, UINT8 functionId, UINT8 sendLevel); + +/* +* ·ڱڷ +* const UINT16 routeId, ·ID +* +* ֵ CI_ERROR ·ڱڷڱ +* CI_SUCCESS ·ڱڷûڱ +* cgh:ɶ27ν·ڳΣȫ +*/ +UINT8 RouteAllPhyBelongCiCheck(const UINT16 routeId); + + +/* +* жϽ·Ƿ +* const UINT16 routeId, ·ID +* +* ֵ CI_ERROR · +* CI_SUCCESS · +*/ +UINT8 RouteAllLockCheck(const UINT16 routeId); + +/* +* ߼ǷƥĽ· +* const UINT8 cLogSecSeqDir ߼з +* const UINT8 cLogSecSum ߼ +* const UINT16 pLogSecIdBuff[] ߼ +* UINT16* pMatchedRouteId ƥĽ·ID +* ֵ 0: ƥɹ +* 1: ƥʧ +*/ +UINT8 MatchedRouteCheck(const UINT8 cLogSecSeqDir, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[], UINT16* pMatchedRouteId); + +/* +* Ѱ߼ƥĽ· +* UINT16 wEndSignalId նźŻID +* const UINT8 cLogSecSum ߼ +* const UINT16 pLogSecIdBuff[] ߼ +* +* ֵ 0: δҵƥĽ· +* >0: ƥĽ·ID +*/ +UINT16 SearchMatchedRoute(UINT16 wEndSignalId, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[]); + +/* +* Ѱҽ·еķ· +* UINT8 cRouteSum · +* UINT16 wRouteIdBuff[] ·ID +* +* ֵ UINT16 wNonMainRouteId ·ID +*/ +UINT16 SearchNonMainRoute(UINT8 cRouteSum, UINT16 wRouteIdBuff[]); + +/* +* ߼εʱ״̬ +* UINT16 switchId Id +* UINT16* pLogSecId ʱٵ߼ID +* UINT8 *pLogState, ߼ʱ״̬ +* ֵ CI_SUCCESS: ߼βʱ +* CI_ERROR: ߼δʱ +* modify 20230927 ӽ·ڵ߼ʱ״̬ +*/ +UINT8 SwitchRelLogSecLSXSStateCheck(UINT16 switchId, UINT16* pLogSecId, UINT8* pLogState); + +/* +* źűֿʱ·ղ +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* RES_CHECK_STATE_WAITE ȴ +* by cgh 20230930 +*/ +UINT8 KeepSignalRelayZhaoChaCheck(UINT16 const routeId); + +/* +* ζӦ߼Ƿ· +* ˵ const UINT16 phySectionId ID +* ֵ ߼· +* cgh-20231002 +*/ +UINT16 CheckLogSecLockBelongRoute(const UINT16 phySectionId); + +/* +* ߼ιϽ +* ˵ UINT16 const wLogSecId ߼ID +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_UNLOCK_FAULT_LOGSEC +* by cgh 20231004 +*/ +UINT8 LogSecFaultUnlockLogicProcess(UINT16 const wLogSecId); + +/* +* ʽս· +* ˵ const UINT16 wPhySectionId ID +* const UINT8 chVirCIid ID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +* cgh-20231011 +*/ +UINT8 PhySecFaultUnlockRouteCheck(const UINT16 wPhySectionId, const UINT8 chVirCIid); + +/* +* ζӦ߼Ƿ߼· +* ˵ const UINT16 wPhySectionId ID +* ֵ CI_ERROR +* CI_SUCCESS +* cgh-20231011 +*/ +UINT8 CheckLogSecLockExistLogRoute(const UINT16 wPhySectionId); + +/* +* ζӦ߼쳣߼״̬ +* ˵ const UINT16 wPhySectionId ID +* ֵ CI_ERROR ȫΪ +* CI_SUCCESS һΪջ߼· +* cgh-20231011 +*/ +UINT8 CheckPhyAllLogSecExceptLockSta(const UINT16 wPhySectionId); + +/* +* ֵ߼Ƿ +* ˵ const UINT8 cSeqNum +* const UINT8 pSeqIncLogSecNum[] а߼ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* Created By LQ 2023/10/12 +*/ +UINT8 SeqNumAndIncLogSecNumCheck(const UINT8 cSeqNum, const UINT8 pSeqIncLogSecNum[]); + +/* +* Уָ̬·ӽ·ǷΪؽ· +* ˵ const UINT8 cIndex ӽ· +* const UINT16 pRouteId[] ӽ·ID +* const UINT16 pCTOccLogSecNum CT߼ +* const UINT16 pCTOccLogSecId[] CT߼ID +* const UINT8 cLogicRouteFlag һǷΪ߼·ı־ +* ֵ CI_ERROR ǰؽ· +* CI_SUCCESS ؽ· +* Created By LQ 2023/10/12 +*/ +UINT8 HalfRouteTypeCheck(const UINT8 cIndex, const UINT16 pRouteId[], const UINT16 pCTOccLogSecNum, const UINT16 pCTOccLogSecId[], const UINT8 cLogicRouteFlag); + +/* +* ΰ߼߼״̬ЧԼ +* ˵ const UINT16 overlapId ID +* const UINT16 routeId η·ID +* UINT16 *pDevId 豸Idأ +* UINT8 *pDevState 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* Created By LQ 2023/10/14 +*/ +UINT8 OverlapLogSecLogicLockCheck(const UINT16 overlapId, const UINT16 routeId, UINT16* pDevId, UINT8* pDevState); + +/* +* ·߼߼״̬ +* ˵ const UINT16 routeId ·ID +* UINT16 *pDevId 豸Idأ +* UINT8 *pDevState 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* Created By LQ 2023/10/14 +*/ +UINT8 RouteIncLogSecLogicLockCheck(const UINT16 routeId, UINT16* pDevId, UINT8* pDevState); + +/* +* ȡ߼гϢ +* ˵ UINT16 wLogSectionId +* ֵ г +* By LC 20231116 +*/ +UINT8 GetLogSecTrainId(const UINT16 wLogSectionId, UINT16 * trainIdbuff); +/* +* ߼ι豸 +* ˵ UINT16 const wLgcId, ߼ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* +*/ +UINT8 LogicContactLineDevCheck(UINT16 const wLgcId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼ιߵ +* ˵ UINT16 const wSwitchId, ID +* UINT8 const wState ״̬ +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* +*/ +UINT8 CheckLogContactSwitchState(UINT16 const wSwitchId, UINT8 const wState, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼ιռѹ +* ˵ UINT16 const wAxisId, ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* +*/ +UINT8 CheckLogContactOccState(UINT16 const wAxisId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ÷Źг +* ˵ UINT16 floodGateId ID +* ֵ CI_ERROR +* CI_SUCCESS CT +*/ +UINT8 SetFloodGateAcCloseApplyProc(UINT16 floodGateId); + +/* +* ȡŹгظ +* ˵ UINT16 floodGateId ID +* ֵ CI_ERROR ͬ +* CI_SUCCESS ͬ +*/ +UINT8 GetFloodGateAccessCloseAskIVOC(UINT16 floodGateId); + +/* +* ߼ڷ +* ˵ +* UINT16 wLogicSecId, ߼α +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 FloodGateCheck(UINT16 wLogicSecId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼μ·CBTC +* ˵ const UINT16 wLogSecId ߼ID +* UINT8* pDevState 豸״̬ +* ֵ CI_ERROR 0 CBTC +* CI_SUCCESS 1 CBTC +* Created By LQ 2023.12.08 +*/ +UINT8 CheckLogSecCbtcProperty(const UINT16 wLogSecId, UINT8* pDevState); + +/* +* ߼·߼εCBTC +* ˵ const UINT8 wLogSecNum ߼·߼ +* const UINT16 pLogSecId[MAX_ROUTE_IN_LT_NUM] ߼·߼ID +* ֵ CI_ERROR 0 CBTC +* CI_SUCCESS 1 CBTC +* Created By LQ 2023.12.08 +*/ +UINT8 CheckLogicRouteCbtcProperty(const UINT8 wLogSecNum, const UINT16 pLogSecId[MAX_ROUTE_IN_LT_NUM]); + + +/* +* ·;۷ · +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCLE_ROUTE +* BY LC +*/ +UINT8 CheckRouteZhefanJiesuo(UINT16 const routeId); + + +/* +* ιΰķDZڵ߼ռ +* ˵ UINT16 const overlapId, OverlapID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +* BY LC +*/ +UINT8 CheckOverlapPhysecOtherLock(UINT16 const overlapId, UINT16* pDevId, UINT8* pDevState); + +/* +* β +* ˵UINT16 const overlapId, OverlapID +* UINT16* pDevId 豸Idأ +* UINT8* pDevState 豸״̬أ +* ֵ 0 ʧ +* 1 ɹ +* Created By LQ 2024.01.05 +*/ +UINT8 OverlapLateralDfnCheck(UINT16 const overlapId, UINT16* pDevId, UINT8* pDevState); + +/* +* 鱣εCBTC +* ˵ const UINT16 wOverlapId ID +* ֵ CI_ERROR 0 CBTC +* CI_SUCCESS 1 CBTC +* Created By LQ 2024.02.20 +*/ +UINT8 CheckOverlapCbtcProperty(const UINT16 wOverlapId); + +#if 0 +/* +* ·Ƿͬ +* ˵ const UINT16 wSrcRouteId Դ·ID +* const UINT16 wSrcRouteId Ŀ·ID +* +* ֵ CI_ERROR ûص +* CI_SUCCESS ص +* BY CGH 20240320 +*/ +UINT8 CheckRoutePhySecSame(const UINT16 wSrcRouteId, const UINT16 wDstRouteId); +#endif + +/* +* ߼ǷΪг߼μ +* ˵ wLogSecId ߼ID +* const UINT16 wRouteId ·ID +* ֵ CI_ERROR Ϊг߼ +* CI_SUCCESS Ϊг߼ +* BY CGH 20240325 +*/ +UINT8 TrainRelateLogSecCheck(const UINT16 wLogSecId, const UINT16 wRouteId); + +/* +* ·һȥ߼μ +* ˵ wLogSecId һȥ߼ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +* BY LC 20240710 +*/ +UINT8 RouteLeaveLogSecCheck(const UINT16 wLogSecId); + + +/* +* ѯгλǷ߼ཻ +* ˵ wLogSecId һȥ߼ID +* envolopId ID +* ֵ CI_ERROR ཻ +* CI_SUCCESS δཻ +*/ +UINT8 TrainBackPosCrossLogCheck(const UINT16 envolopId, const UINT16 logsecId, const UINT8 functionId); + + +/* +* ·ȥεABLг +* ˵ leaveLogicSecId һȥ߼ID +* routeId · +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +*/ +UINT8 TrainLeaveLogSecABLTrainCheck(const UINT16 leaveLogicSecId); + +/* +* ߼ABL· +* ˵ const UINT16 wLogSecId ߼ID +* const UINT16 wTrainId гID +* ֵ CI_ERROR 0 ABL· +* CI_SUCCESS 1 ABL· +* Created By CGH 20240726 +*/ +UINT8 CheckLogSecAblReverseProperty(const UINT16 wLogSecId, const UINT16 wTrainId); + +/* +* αúǷ㱻һ·û򱣻 +* ˵ UINT16 switchId, ID +* UINT8 switchState, λ +* ֵ CI_SUCCESSüͨ +* CI_ERROR:üʧ +* 2023.07.24 add by mpt +*/ +UINT8 CheckPhyUseSecCanOtherUse(UINT16 switchId, UINT8 switchState); + +/* +* ͨųǰ˿ɼ +* const UINT16 wTrainId гID +* const UINT8 cLogSecSeqDir ATS·߼з +* const UINT16 wLogSecId ߼ID +* +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20240819 +*/ +UINT8 CtTrainHeadSuspCheck(const UINT16 wTrainId, const UINT8 cLogSecSeqDir, const UINT16 wLogSecId); + +/* +* βֽ·߼кгλü +* const UINT8 cLogSecSum ߼ +* const UINT16* pLogSecIdBuff ߼ +* const UINT16 wTrainId +* +* ֵ CI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.09.05 +*/ +UINT8 LogSecSeqAndTrainPosCheckCLD(const UINT8 cLogSecSum, const UINT16* pLogSecIdBuff, const UINT16 wTrainId); + +/* +* βֽ·߼·ƥ +* const UINT8 cLogSecSeqDir ߼зӪ +* const UINT16 wLogSecId ߼ID +* UINT16* pMatchedRouteId ߼ƥĽ·ID +* ֵ CI_ERROR 0 ƥʧ +* CI_SUCCESS 1 ƥɹ +* Created By LQ 2024.09.05 +*/ +UINT8 LogSecSeqAndRouteMatchCheckCLD(const UINT8 cLogSecSeqDir, const UINT16 wLogSecId, UINT16* pMatchedRouteId); + +/* +* βֽ·ƥг· +* const UINT8 cRouteSum · +* const UINT16 szRouteId[MAX_ROUTE_IN_LT_NUM] ·ID +* UINT16* pMatchedRouteId ߼ƥĽ·ID +* ֵ CI_ERROR 0 ƥʧ +* CI_SUCCESS 1 ƥɹ +* Created By LQ 2024.09.05 +*/ +UINT8 MatchLieCheRouteCLD(const UINT8 cRouteSum, const UINT16 szRouteId[MAX_ROUTE_IN_LT_NUM], UINT16* pMatchedRouteId); + +/* +* ͨгǰ˿ɼ +* const UINT16 wTrainId гID +* +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.09.05 +*/ +UINT8 CtTrainSuspCheck(const UINT16 wTrainId); + +/* +* жϽ·Ƿյı +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERROR ûյı +* CI_SUCCESS յı +* BY CGH 20240920 +*/ +UINT8 CheakRouteHaveLockOverlap(const UINT16 routeId); +/* +* жϴԶ·δִ· +* ˵ const UINT16 checkRouteId ·, const UINT16 opposeRouteId ִ· +* ֵ CI_ERROR ǿеִ·գ鲻ͨ +* CI_SUCCESS ͨ +* BY fan 20241111 +*/ +UINT8 AutoRouteOpposeSectionCheck(const UINT16 checkRouteId, const UINT16 opposeRouteId); + +/* +* λúͶЧ +* ˵ const UINT16 wSwitchId, ID +* ֵ +* BY CGH 20241203 +*/ +UINT8 CheckSwitchPosAndMoveValid(const UINT16 wSwitchId, const UINT8 chSwitchPos, UINT8 sendLevel); + +/* +* ·λЧԼ +* ˵ UINT16 const routeId, · +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20241204 +*/ +UINT8 RouteOtherCiSwPosValidCheck(UINT16 const routeId); + +/* +* ιķЧԼ +* ˵const UINT16 wOverlapId ID +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.12.09 +*/ +UINT8 OtherCiOvlpRelProSwMovValCheck(const UINT16 wOverlapId); + +/* +* ηü +* ˵const UINT16 wOverlapId ID +* UINT16* pDevId 豸IDأ +* UINT8* pDevState 豸״̬أ +* UINT8* pAlarmType ͣأ +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* RETURN_WAIT_SWITCH_USING 0x30 ȴ +* Created By LQ 2024.12.10 +*/ +UINT8 OverlapProSwUsingCheck(const UINT16 wOverlapId, UINT16* pDevId, UINT8* pDevState, UINT8* pAlarmType); + +/* +* ·еλȷ +* ˵ UINT16 const routeId, ·ţ +* ֵ CI_ERROR +* CI_SUCCESS +* BY CGH 20250224 +*/ +UINT8 RouteRelAllSwitchPosCheck(UINT16 const routeId); + +#endif + diff --git a/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicProcess.c b/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicProcess.c new file mode 100644 index 0000000..269c600 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicProcess.c @@ -0,0 +1,12646 @@ +/******************************************************** +* +* InterlockLogicProcess.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-10 +* ߣ +* ߼ +* ޸ļ¼ +* +********************************************************/ + +#include "InterlockLogicProcess.h" +#include "AxisSort_api.h" +#include "DynamicRouteDataManage.h" +#include "LogicalRouteLogicCheck.h" + + + +/* C02_ʽг· */ +/* +* ʽг· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_BLOC_T_ROUTE +*/ +UINT8 SetBlocLTrainRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_SET_BLOC_T_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + UINT8 triggerFlag = 0u; + + triggerFlag = GetRouteAutoTriggerFlag(routeId); /*ȡ·Զ־*/ + if ((AutoSignalOrRouteValid(routeId) == CI_SUCCESS) || + (AUTO_TRIGGER_SET_YES == triggerFlag)) + { + /*Զ·Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + +/* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_BLOC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡг·*/ + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_LIECHE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·С ·Ԥѡ*/ + devState = GetRouteState(routeId); + if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + +/* C03_CBTCг· */ +/* +* CBTCг· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_CBTC_T_ROUTE +*/ +UINT8 SetCbtcLTrainRouteLogicProcess(UINT16 const routeId) +{ + /**/ + UINT8 const functionId = EFUNC_SET_CBTC_T_ROUTE; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + + /**/ + UINT8 triggerFlag = 0u; + /*Ϸͼ*/ + UINT8 sendLevel = 0u; + + triggerFlag = GetRouteAutoTriggerFlag(routeId); /*ȡ·Զ־*/ + if ((AutoSignalOrRouteValid(routeId) == CI_SUCCESS) || + (AUTO_TRIGGER_SET_YES == triggerFlag)) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + /* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_CBTC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEVEL, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡг·*/ + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_LIECHE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·СԶ ·ԤѡԶ쳣ARBҹ޸ģ*/ + devState = GetRouteState(routeId); + if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_AUTO_UNLOCK == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState) + || (ROUTE_STATE_AUTO_UNLOCKERR == devState) || (ROUTE_STATE_HALF_UNLOCK == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetCbtcRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + + if (CI_SUCCESS == reResult) + { + /*ֶν·*/ + checkResult = RouteFenDuanConditionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + +/* RR1_зԵг· */ +/* +* зԵг· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_REVERSE_T_ROUTE +*/ +UINT8 SetRevrLTrainRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_SET_REVERSE_T_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + UINT8 isAutoSigRoute = CI_ERROR; + + isAutoSigRoute = AutoSignalOrRouteValid(routeId); + if (CI_SUCCESS == isAutoSigRoute) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + +/* ߼ */ + + /* ·ǡг·*/ + if(CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_LIECHE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + + /* ·״̬Ϊ·С ·Ԥѡ*/ + if(CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState) || (ROUTE_STATE_HALF_UNLOCK == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + /* źŻ */ + if(CI_SUCCESS == reResult) + { + checkResult = SetReverseRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղȷ*/ + if(CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } +#if 0 + /*·ԶźŽ·״̬*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = SetRevrRouteAutoSigStaCheck(routeId,functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* */ + if(CI_SUCCESS == reResult) + { + checkResult = SetReverseRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* */ + if(CI_SUCCESS == reResult) + { + checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + + + + + +/* C04_ʽ۷· */ +/* +* ʽ۷· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_BLOC_R_ROUTE +*/ +UINT8 SetBlocReturnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_SET_BLOC_R_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 autoSignalOrRouteValid = 0u; + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + autoSignalOrRouteValid = AutoSignalOrRouteValid(routeId); + if (CI_SUCCESS == autoSignalOrRouteValid) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if ((ROUTE_LEVEL_BLOC==devState )) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡ۷·*/ + devState = GetRouteType(routeId); + if (ROUTE_TYPE_RETURN==devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·С ·Ԥѡ*/ + devState = GetRouteState(routeId); + if ((ROUTE_STATE_IDLE==devState) || (ROUTE_STATE_FIRST_XUANPAI==devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_RETURN_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS==checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + +/* C05_CBTC۷· */ +/* +* CBTC۷· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_CBTC_R_ROUTE +*/ +UINT8 SetCbtcReturnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_SET_CBTC_R_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_CBTC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡ۷·*/ + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·С ·Ԥѡ*/ + devState = GetRouteState(routeId); + if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_RETURN_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*ֶν·*/ + checkResult = RouteFenDuanConditionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + +/* RR2_зԵ۷· */ +/* +* зԵ۷· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_REVERSE_R_ROUTE +*/ +UINT8 SetReverseRtnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_SET_REVERSE_R_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ǡ۷·*/ + if(CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ·״̬Ϊ·С ·Ԥѡ*/ + if(CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* źŻ */ + if(CI_SUCCESS == reResult) + { + checkResult = SetReverseRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /*ղȷ*/ + if(CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#if 0 + /*·ԶźŽ·״̬*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = SetRevrRouteAutoSigStaCheck(routeId,functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* */ + if(CI_SUCCESS == reResult) + { + checkResult = SetReverseRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if(CI_SUCCESS == reResult) + { + checkResult = SetBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* سɹ */ + return reResult; +} + + + + +/* C06_· */ +/* +* · +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_LEAD_ROUTE +*/ +UINT8 LockLeadRouteLogicProcess(UINT16 const routeId) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_LEAD_ROUTE; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + + + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + + /* ߼ */ + + /* ·ǡ*/ + devState = GetRouteLeadProperty(routeId); + if ((ROUTE_LEAD_PROPERTY_YES == devState) || (ROUTE_LEAD_PROPERTY_CBTC_YES == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_LEAD_PROPERTY, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ + ѡš + ·쳣 + Ԥա + ӽ + ӽ쳣 + */ + devState = GetRouteState(routeId); + if ((devState == ROUTE_STATE_LEAD_XUANPAI) || + (devState == ROUTE_STATE_FIRST_LOCKERR) || + (devState == ROUTE_STATE_YUXIAN_LOCK) || + (devState == ROUTE_STATE_NEAR_LOCK) || + (devState == ROUTE_STATE_NEAR_LOCKERR)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetLeadRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + + /*·εķǽ·ҷǵ߼ЧԼ*/ + checkResult = LockLeadRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + + + } + /* سɹ */ + return reResult; +} + + + +/* C07_յʽг· */ +/* +* յʽг· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_BLOC_T_ROUTE +*/ +UINT8 LockBlocLTrainRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_LOCK_BLOC_T_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*Ϸͼ*/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(routeId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_BLOC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + if (CI_SUCCESS == reResult) + { + /* ·ǡг·*/ + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_LIECHE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·ѡš*/ + devState = GetRouteState(routeId); + if (ROUTE_STATE_XUANPAI == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + if (CI_SUCCESS == reResult) + { + /**/ + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼μ*/ + checkResult = LockBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + +/* C08_CBTCг· */ +/* +* CBTCг· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_CBTC_T_ROUTE +*/ +UINT8 LockCbtcLTrainRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_LOCK_CBTC_T_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*Ϸͼ*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 routeStateFlag = ROUTE_STATE_FLAG_NO; /*·״̬תƱ־*/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(routeId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + routeStateFlag = GetRouteStateFlag(routeId); /* ȡ·״̬תƱ־*/ + + +/* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(routeId); + if (ROUTE_LEVEL_CBTC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡг·*/ + devState = GetRouteType(routeId); + if (ROUTE_TYPE_LIECHE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·ѡš*/ + devState = GetRouteState(routeId); + if (ROUTE_STATE_XUANPAI == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if ((ROUTE_STATE_AUTO_UNLOCK == devState) || (ROUTE_STATE_AUTO_UNLOCKERR == devState) || (ROUTE_STATE_HALF_UNLOCK == devState)) + { + if (ROUTE_STATE_FLAG_YES == routeStateFlag) + { + /*·״̬תռʱ·״̬ȻΪԶԶ쳣ARBҹ޸ģ*/ + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetCbtcRouteSectionCheck(routeId, functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + if ((ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) || (ROUTE_TYPE_AIRSHAFT == GetAirShaftRouteType(routeId))) + { /*·εռ״̬֮ǰڲռ״̬źų·ڷһ߼ΣźŻؿ*/ + /*羮·׷ٰ·*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼ЧԼ*/ + checkResult = LockCBTCRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*ֶν·*/ + checkResult = RouteFenDuanConditionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* سɹ */ + return reResult; +} + +/* C09_յʽ۷· */ +/* +* յʽ۷· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_BLOC_R_ROUTE +*/ +UINT8 LockBlocReturnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_LOCK_BLOC_R_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*Ϸͼ*/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(routeId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_BLOC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡ۷·*/ + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·ѡš*/ + devState = GetRouteState(routeId); + if (ROUTE_STATE_XUANPAI == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼μ*/ + checkResult = LockBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + +/* C10_CBTC۷· */ +/* +* CBTC۷· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_CBTC_R_ROUTE +*/ +UINT8 LockCbtcReturnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_LOCK_CBTC_R_ROUTE; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*Ϸͼ*/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(routeId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_CBTC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡ۷·*/ + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·ѡš*/ + devState = GetRouteState(routeId); + if (ROUTE_STATE_XUANPAI == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼μ*/ + checkResult = LockBlocRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*ֶν·*/ + checkResult = RouteFenDuanConditionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + +/* C11_ս·overlap߼ */ +/* +* ս·overlap߼ +* ˵ UINT16 const routeId, UINT16 const overlapId +* ֵ CI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* RETURN_LOCK_ERR_SWITPOS 0x22 λô +* RETURN_WAIT_SWITCH_USING 0x30 ȴ +* RETURN_WAIT_SWITCH_CHECK 0x31 ȴ +* ϱ룺 EFUNC_LOCK_OVER_LAP +*/ +UINT8 LockRouteOverlapLogicProcess(UINT16 const routeId, UINT16 const overlapId,UINT8 lockType) +{ +/**/ + UINT8 const functionId = EFUNC_LOCK_OVER_LAP; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devStateType = 0u; /*豸״̬*/ + UINT8 devState = 0u; /*豸״̬*/ + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + UINT8 lineIdentity = CI_TRADITION_RAILWAY; + UINT8 secStopFlag = 0u;/*ͣ״̬*/ + UINT8 laborLockCmdFlag = 0u; + UINT16 belongRouteId = 0u; + UINT8 chOverlapFromRouteFlag = 0U;/*δ·ID*/ + UINT16 wRouteLeavePhySecId = 0U;/*·ȥID*/ + UINT8 chLeavePhyCurOcuState = 0U;/*ȥռ״̬*/ + UINT8 cAlarmType = FLAG_UNSET; + + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ*/ + + + /* */ + + if(ATS_LOCK_OVERLAP == lockType) + { + chOverlapFromRouteFlag = GetOverlapFromSetRouteCmdFlag(overlapId); + if (OVERLAP_ROUTE_FLAG_YES == chOverlapFromRouteFlag) + { + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecCurMergeState(devId); + if (devState == SECTION_OCCUPY_NO) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + wRouteLeavePhySecId = GetRouteLeavePhySecId(routeId); + chLeavePhyCurOcuState = GetPhySecCurMergeState(wRouteLeavePhySecId); + if (SECTION_OCCUPY_NO == chLeavePhyCurOcuState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, wRouteLeavePhySecId, ETYPE_PS_MERGY_OCU_STATE, chLeavePhyCurOcuState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + /* ͨ */ + reResult = CI_SUCCESS; + } + } + } + else + { + /*Ǵ·IDATSβټ·һռ״̬*/ + reResult = CI_SUCCESS; + } + } + else + { + /*·һΡС*/ + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecCurMergeState(devId); + if (devState == SECTION_OCCUPY_NO) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { +#if 0 + /*鱣ε״̬*/ + overlapSwitchUsing = OvlpIncludeAndProtSwitchCheck(overlapId); + + /*ε*/ + if(CI_SUCCESS == overlapSwitchUsing) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } +#endif + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + + /*ͣ״̬*/ + if (CI_SUCCESS == reResult) + { + devId = GetRouteLastPhySectionId(routeId); + secStopFlag = GetPhySecStopSteadyFlag(devId); + if(PHYSICAL_SECTION_STOPSTEADY_NO == secStopFlag) + {/*δյͣϢ*/ + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_STOPSTEADY_STATE,secStopFlag,sendLevel);/*ֻ¼*/ + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + + /*·һΡաڵǰ·*/ + if (CI_SUCCESS == reResult) + { + + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecLockState(devId); + belongRouteId = GetPhySecRLockBelongRouteId(devId); + if ((PHYSICAL_SECTION_LOCK_NORMAL == devState) && + (belongRouteId == routeId)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /* Ρδ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecFLockValidCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ΡС*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + + if(ATS_LOCK_OVERLAP ==lockType) + { + reResult = AtsLockOverlapSecOccupyCheck(overlapId,&devId,&devState); + if (CI_SUCCESS != reResult) + { /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + } + } + else if(CI_LOCK_OVERLAP ==lockType) + { + reResult = OverlapAllSecOccuClearCheck(overlapId,&devId,&devState); + if (CI_SUCCESS != reResult) + { + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + } + } + else + { + reResult = CI_ERROR; + } + } + + /* μηΡδá*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecUsingClearCheck(overlapId, &devId, &devState, &cAlarmType); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (RETURN_WAIT_SWITCH_USING == checkResult) + { + reResult = RETURN_WAIT_SWITCH_USING; + } + else + { + /* ¼ */ + if (FLAG_SET == cAlarmType) + { + /**/ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_USE_STATE, SWITCH_USING_YES, sendLevel); + } + else + { + /*α*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_USE_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ڵͷδûڱ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = CheckOverlapSwitchUseState(overlapId, &devId); + if (CI_SUCCESS == checkResult) + { + /* ͨ飬ֵǰ״̬ */ + } + else if (RETURN_WAIT_SWITCH_USING == checkResult) + { + reResult = RETURN_WAIT_SWITCH_USING; + } + else + { + /* ¼ */ + /*ô룺*/ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_USE_STATE,SWITCH_USING_YES,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* Ρδա + ͬա + ͬա*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecLockValidCheck(overlapId,routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ߼Ρδ߼ա߷ͬ߼ա*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapLogSecLogicLockCheck(overlapId, routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ۷·*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllReturnRouteCheckup(overlapId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_USE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* μ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapInvSecAndConSwiCheckup(overlapId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*β*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapLateralDfnCheck(overlapId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + reResult = CI_ERROR; /* ʧ */ + } + } + + /* ΡδԾա*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecJumpLockStateCheck(overlapId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ιΰķDZڵ߼δ·߼·*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = CheckOverlapPhysecOtherLock(overlapId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + + + /* εĵжޱμ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapInvOppOverlapCheckup(overlapId, &devId, &devState); + + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_OVERLAP, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*з״̬*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapFloodGateStateCheck(overlapId,&devId,&devStateType,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_FLOODGATE,devId,devStateType,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* еδ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchYLockCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_YLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* еδ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OverlapSwitchFLockStateCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* δ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelProtSwiFLockStaCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*еλȷλòȷɶ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + if (CI_TRADITION_RAILWAY == lineIdentity) + {/*ͳ·*/ + checkResult = OverlapSwitchMoveValidCheck(overlapId,&devId,&devState); + }/* zt ɾش 2022-02-15 */ + else + {/*·ʹ*/ + checkResult = CI_ERROR; + } + + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_POSTION_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /*·ͼ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + {/* zt ɾش 2022-02-15 */ + if (CI_TRADITION_RAILWAY == lineIdentity) + {/*ͳ·*/ + /* ͨ飬ֵǰ״̬ */ + } + else + {/*·ʹ*/ + reResult = CI_ERROR; + } + } + + /*ελü + * RETURN_LOCK_ERR_SWITPOS ελòȷ + * CI_SUCCESS еλȷ + */ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult)) + { + devId = 0u; + devState = 0u; + if(CI_TRADITION_RAILWAY == lineIdentity) + {/*ͳ·*/ + checkResult = OverlapSwitchPosCheck(overlapId,&devId,&devState); + }/* zt ɾش 2022-02-15 */ + else + {/*·ʹ*/ + checkResult = CI_ERROR; + } + + if (checkResult == CI_ERROR) + { + /* λòȷ */ + if (RETURN_WAIT_SWITCH_USING == reResult) + { + /*ȴ*/ + } + else + { + reResult = RETURN_LOCK_ERR_SWITPOS; /*صλô*/ + } + } + else + { + /* λȷ ͨ飬ֵǰ״̬ */ + } + } + + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult) || (RETURN_LOCK_ERR_SWITPOS == reResult)) + {/*ڵλȷλòȷɶżιؼ*/ + /*ιδ*/ + devId = 0u; + devState = 0u; + checkResult = OvlpRelatedProSwitchYLockCheck(overlapId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ飬ֵǰ״̬ */ + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_YLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ιλȷλòȷɶ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult) || (RETURN_LOCK_ERR_SWITPOS == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelatedProtSwiMovValCheck(overlapId, &devId, &devState, &cAlarmType); + + if (CI_SUCCESS == checkResult) + { + /* ͨ飬ֵǰ״̬ */ + } + else if (RETURN_WAIT_SWITCH_CHECK == checkResult) + { + if (RETURN_WAIT_SWITCH_USING == reResult) + { + /*ȴȣȼȴ>ȴ>λô*/ + } + else + { + reResult = RETURN_WAIT_SWITCH_CHECK; /*ɶԼδȷϣصȴ*/ + } + } + else + { + /* ¼ */ + if (FLAG_SET == cAlarmType) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_MOVE_CHECK_RESULT, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ιλȷ*/ + if ((CI_SUCCESS == reResult) || (RETURN_WAIT_SWITCH_USING == reResult) || (RETURN_WAIT_SWITCH_CHECK == reResult) || (RETURN_LOCK_ERR_SWITPOS == reResult)) + { + devId = 0u; + devState = 0u; + checkResult = OvlpRelatedProtSwitchPosCheck(overlapId,&devId,&devState); + + if (checkResult == CI_ERROR) + { + if ((RETURN_WAIT_SWITCH_USING == reResult) || (RETURN_WAIT_SWITCH_CHECK == reResult)) + { + /*άֵǰֵȼȴ>ȴ>λô*/ + } + else + { + /* λòȷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + } + } + else + { + /* λȷ ͨ飬ֵǰ״̬ */ + } + } + } + + if(CI_ERROR == reResult) + { + laborLockCmdFlag = GetOverlaplaborLockCmdFlag(overlapId); + if((LOCK_OVERLAP_CMD_YES == laborLockCmdFlag)&&(ATS_LOCK_OVERLAP ==lockType)) + {/*˹ձ*/ + SetOverlaplaborLockCmdFlag(overlapId,LOCK_OVERLAP_CMD_NO); + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_OVERLAP,overlapId,ETYPE_OVERLAP_LABORUNLOCK_FAIL,0u,ESEND_LEVEL_ATS); + + SetRouteAtsExpLkOverlapId(routeId,0u); /*˹գһЧձID*/ + } + } + + return reResult; +} + +/* C12_ŵʽг·ź */ +/* +* ŵʽг·ź +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* RETURN_OPEN_ERR_SIGOPEN +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_BLOC_T_SIGNAL +*/ +UINT8 OpenBlocLTrainRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_OPEN_BLOC_T_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + +/* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_BLOC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_LIECHE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + · + ·쳣 + Ԥա + ӽ쳣 + ӽ + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((devState == ROUTE_STATE_FIRST_LOCK)|| + (devState == ROUTE_STATE_FIRST_LOCKERR)|| + (devState == ROUTE_STATE_YUXIAN_LOCK)|| + (devState == ROUTE_STATE_NEAR_LOCKERR) || + (devState == ROUTE_STATE_NEAR_LOCK)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((zxqFlag == ROUTE_ZONGQUXIAO_SET_NO)&& + (zrjFlag == ROUTE_ZONGRENJIE_SET_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSectionCheck(routeId, functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* վ̨ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* */ + return reResult; +} + + +/* C13_ʽг·źű */ +/* +* ʽг·źű +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_BLOC_T_SIGNAL +*/ +UINT8 KeepBlocLTrainRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_KEEP_BLOC_T_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + +/* ԶźԼ */ + UINT8 autoValueCheck = 0u; + + autoValueCheck = AutoSignalOrRouteValid(routeId); + if (CI_SUCCESS == autoValueCheck) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_LIECHE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + Ԥȿš + ӽš + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_YUXIAN_OPEN == devState)|| + (ROUTE_STATE_NEAR_OPEN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag)&& + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSectionCheck(routeId, functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* վ̨ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /*·նźŻCBTC*/ + if (CI_SUCCESS == reResult) + { + reResult = CheckRouteEndSignalNotCbtc(routeId,functionId,sendLevel); + + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + return reResult; +} + + +/* C14_CBTCг·ź */ +/* +* CBTCг·ź +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_CBTC_T_SIGNAL +*/ +UINT8 OpenCbtcLTrainRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_OPEN_CBTC_T_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + UINT16 devId = 0u; /*豸ID*/ +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪCBTC*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_CBTC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_LIECHE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + · + ·쳣 + Ԥա + ӽ쳣 + ӽ + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((devState == ROUTE_STATE_FIRST_LOCK)|| + (devState == ROUTE_STATE_FIRST_LOCKERR)|| + (devState == ROUTE_STATE_YUXIAN_LOCK)|| + (devState == ROUTE_STATE_NEAR_LOCKERR)|| + (devState == ROUTE_STATE_NEAR_LOCK)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((zxqFlag == ROUTE_ZONGQUXIAO_SET_NO)&& + (zrjFlag == ROUTE_ZONGRENJIE_SET_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenCbtcRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* վ̨ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenCbtcRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + if (CI_SUCCESS == reResult) + { + if ((ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(routeId)) || (ROUTE_TYPE_AIRSHAFT == GetAirShaftRouteType(routeId))) + { /*·εռ״̬֮ǰڲռ״̬źų·ڷһΣźŻؿ*/ + /*羮·׷ٰʿӶԽ·ڷεռ״̬*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*߷羮·*/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + } + else + { + /*ȲǷ·ҲǷ羮·*/ + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + } + } + + + + return reResult; +} + + + +/* C15_CBTCг·źű */ +/* +* CBTCг·źű +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_CBTC_T_SIGNAL +* ޸bug YF0083-72 +*/ +UINT8 KeepCbtcLTrainRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_KEEP_CBTC_T_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + UINT16 devId = 0u; /*豸ID*/ + UINT8 autoValueCheck = 0u; /* ԶźԼ */ + UINT16 firstPhySecId = 0u; /* ·ڷһID */ + UINT8 trainEnterRouteState = CI_ERROR; /* гʻ·״̬ */ + UINT16 startSigId = 0u; /* ʼźŻID */ + UINT8 signalCrossState = CI_ERROR; /* ѹźŻ״̬ */ + UINT8 routeRevProperty = 0u; /* · */ + UINT8 airShaftRouteType = 0u; /* 羮· */ + + autoValueCheck = AutoSignalOrRouteValid(routeId); + if (CI_SUCCESS == autoValueCheck) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(routeId); + if (ROUTE_LEVEL_CBTC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·г·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (ROUTE_TYPE_LIECHE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /* ·״̬Ϊ + Ԥȿš + ӽš + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((ROUTE_STATE_YUXIAN_OPEN == devState)|| + (ROUTE_STATE_NEAR_OPEN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == zxqFlag)&& + (ROUTE_ZONGRENJIE_SET_NO == zrjFlag)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepCbtcRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ӷ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepCBTCRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + routeRevProperty = GetRouteReverseProperty(routeId); + airShaftRouteType = GetAirShaftRouteType(routeId); + if ((ROUTE_REVERSE_PROPERTY_YES == routeRevProperty) || (ROUTE_TYPE_AIRSHAFT == airShaftRouteType)) + { /*·羮·Խ·ڷεռѹ״̬м*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + firstPhySecId = GetRouteFirstPhySectionId(routeId); + trainEnterRouteState = GetTrainEnteringRouteState(routeId); + startSigId = GetRouteStartSignalId(routeId); + signalCrossState = GetSignalCrossState(startSigId); + if((devId == firstPhySecId) + && ((CI_SUCCESS == trainEnterRouteState) && (SIGNAL_CROSS_STATE_NO == signalCrossState))) + { + /*CBTC·гʻʱѹϢδ,ʱź*/ + reResult = CI_SUCCESS; + } + else + { + if(devId == firstPhySecId) + { + reResult = CheckEngineerVehicleNear(routeId);/*Ƿǹ̳ӽĿѹ*/ + } + else + { + reResult = CI_ERROR; + } + if(CI_SUCCESS != reResult) + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + } + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + } + else + { + /*ȲǷҲǷ羮*/ + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + } + + } + + + + return reResult; +} + + +/* C16_ŵʽ۷·ź */ +/* +* ŵʽ۷·ź +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* RETURN_OPEN_ERR_SIGOPEN +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_BLOC_R_SIGNAL +*/ +UINT8 OpenBlocReturnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_OPEN_BLOC_R_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + UINT16 endSigId = 0u; /*ȡ;۷źŻID*/ + UINT8 endSigState = SIGNAL_OPEN; + + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_BLOC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ǡ۷·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + · + ·쳣 + Ԥա + ӽ쳣 + ӽ + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((devState == ROUTE_STATE_FIRST_LOCK)|| + (devState == ROUTE_STATE_FIRST_LOCKERR)|| + (devState == ROUTE_STATE_YUXIAN_LOCK)|| + (devState == ROUTE_STATE_NEAR_LOCKERR)|| + (devState == ROUTE_STATE_NEAR_LOCK)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((zxqFlag == ROUTE_ZONGQUXIAO_SET_NO)&& + (zrjFlag == ROUTE_ZONGRENJIE_SET_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + {/*ȴղͼɹ*/ + reResult = checkResult; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSectionCheck(routeId, functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* վ̨ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + + + /* ·նźŻ״̬Ϊδ*/ + if (CI_SUCCESS == reResult) + { + endSigId = GetRouteEndSignalId(routeId); /*ȡ;۷źŻID*/ + endSigState = GetSignalOpenCloseState(GetSignalCurColor(endSigId)); + if (endSigState == SIGNAL_CLOSE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + return reResult; +} + + +/* C17_ʽ۷·źű */ +/* +* ʽ۷·źű +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_BLOC_R_SIGNAL +*/ +UINT8 KeepBlocReturnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_KEEP_BLOC_R_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪʽ*/ + + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_BLOC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + + /* ·ǡ۷·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + Ԥȿš + ӽš + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((devState == ROUTE_STATE_YUXIAN_OPEN)|| + (devState == ROUTE_STATE_NEAR_OPEN)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((zxqFlag == ROUTE_ZONGQUXIAO_SET_NO)&& + (zrjFlag == ROUTE_ZONGRENJIE_SET_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepBlocReturnSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSectionCheck(routeId, functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ӷ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /*·նźŻCBTC*/ + if (CI_SUCCESS == reResult) + { + reResult = CheckRouteEndSignalNotCbtc(routeId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + +/* C18_CBTC۷·ź */ +/* +* CBTC۷·ź +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* RETURN_OPEN_ERR_SIGOPEN +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_CBTC_R_SIGNAL +*/ +UINT8 OpenCbtcReturnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_OPEN_CBTC_R_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + +/* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + /*Ϸͼ*/ + UINT8 sendLevel = 0u; + + + UINT16 devId = 0u; /*豸ID*/ + + + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪCBTC*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_CBTC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ǡ۷·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + · + ·쳣 + Ԥա + ӽ쳣 + ӽ + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((devState == ROUTE_STATE_FIRST_LOCK)|| + (devState == ROUTE_STATE_FIRST_LOCKERR)|| + (devState == ROUTE_STATE_YUXIAN_LOCK)|| + (devState == ROUTE_STATE_NEAR_LOCKERR)|| + (devState == ROUTE_STATE_NEAR_LOCK)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((zxqFlag == ROUTE_ZONGQUXIAO_SET_NO)&& + (zrjFlag == ROUTE_ZONGRENJIE_SET_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenCbtcRouteSectionCheck(routeId, functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ӷ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + return reResult; +} + + +/* C19_CBTC۷·źű */ +/* +* CBTC۷·źű +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_CBTC_R_SIGNAL +*/ +UINT8 KeepCbtcReturnRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_KEEP_CBTC_R_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ +/* ·豸 */ + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + + UINT16 devId = 0u; /*豸ID*/ + UINT16 routeFirstPhyId = 0u; + UINT8 rcWorkMode = GetLocalRcWorkMode(); + + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(routeId); + if ((devState == ROUTE_LEVEL_CBTC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEVEL,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ǡ۷·*/ + if (CI_SUCCESS == reResult) + { + devState = GetRouteType(routeId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_TYPE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬Ϊ + Ԥȿš + ӽš + */ + if (CI_SUCCESS == reResult) + { + devState = GetRouteState(routeId); + if ((devState == ROUTE_STATE_YUXIAN_OPEN)|| + (devState == ROUTE_STATE_NEAR_OPEN)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·δáȡδá˽⡿*/ + if (CI_SUCCESS == reResult) + { + if ((zxqFlag == ROUTE_ZONGQUXIAO_SET_NO)&& + (zrjFlag == ROUTE_ZONGRENJIE_SET_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* źŻ */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղȷ*/ + if (CI_SUCCESS == reResult) + { + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepCbtcRouteSectionCheck(routeId, functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* · */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ӷ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ź */ + if (CI_SUCCESS == reResult) + { + checkResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + if (RC_WORK_MODE_TIOC == rcWorkMode) + {/*TIOC*/ + checkResult = KeepCbtcReturnRouteSecOccCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + else if (RC_WORK_MODE_CI == rcWorkMode) + {/*CI*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + routeFirstPhyId = GetRouteFirstPhySectionId(routeId); + + if ((devId == routeFirstPhyId) && ((GetTrainEnteringRouteState(routeId) == CI_SUCCESS) && + (GetSignalCrossState(GetRouteStartSignalId(routeId)) == SIGNAL_CROSS_STATE_NO))) + { + /*CBTC۷·гʻʱѹϢδ,ʱź*/ + reResult = CI_SUCCESS; + } + else + { + if (devId == routeFirstPhyId) + { + reResult = CheckEngineerVehicleNear(routeId);/*Ƿǹ̳ӽĿѹ*/ + } + else + { + reResult = CI_ERROR; + } + if (CI_SUCCESS != reResult) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + } + } + else + { + reResult = CI_ERROR;/*ģʽ󷵻ʧ*/ + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + return reResult; +} + + +/* C20_·߼ */ +/* +* ·߼ +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_LEAD_SIGNAL +*/ +UINT8 OpenLeadRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_OPEN_LEAD_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + +/*Ϸͼ*/ + UINT8 sendLevel = 0u; + UINT8 cDetainCloseLeadFlag = 0u; + + UINT8 devState = 0u; /*豸״̬*/ + +/* ·豸 */ + + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + + + /* ȡ۳Ƿرźű־ */ + cDetainCloseLeadFlag = GetCiFunctionSwitchConfig(FUNC_KOUCHE_CLOSE_YINDAO_FLAG); + + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* ߼ */ + + /* ·Ϊ*/ + devState = GetRouteLeadProperty(routeId); + if ((ROUTE_LEAD_PROPERTY_YES == devState)||(ROUTE_LEAD_PROPERTY_CBTC_YES == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEAD_PROPERTY,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊա*/ + devState = GetRouteState(routeId); + if (devState == ROUTE_STATE_LEAD_LOCK) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·δáȡδá˽⡿*/ + if ((zxqFlag == ROUTE_ZONGQUXIAO_SET_NO)&& + (zrjFlag == ROUTE_ZONGRENJIE_SET_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = OpenBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = OpenLeadRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = OpenBlocRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ź */ + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /*cgh-ϲCID-2341-3 ܿ-źż۳*/ + if (FUNC_SWITCH_ON == cDetainCloseLeadFlag) + { + /* վ̨۳ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /*ܿ-Ƿִ¹*/ + if (CI_SUCCESS == reResult) + { + checkResult = LeadzLockCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + return reResult; +} + + +/* C21_ֿ·߼ */ +/* +* ֿ·߼ +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_LEAD_SIGNAL +*/ +UINT8 KeepLeadRouteLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_KEEP_LEAD_SIGNAL; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + + /*Ϸͼ*/ + UINT8 sendLevel = 0u; + UINT8 cDetainCloseLeadFlag = 0u; + +/* ·豸 */ + /* ʼźŻId */ + UINT16 const startSignalId = GetRouteStartSignalId(routeId); + /* ȡ־ */ + UINT8 const zxqFlag = GetRouteZongQuXiaoFlag(routeId); + UINT8 const zrjFlag = GetRouteZongRenJieFlag(routeId); + /* ӷ */ + + + + /*źſʱ״̬*/ + UINT8 const leadSinalOpenState = SystemOverTimeCheck(GetRouteLeadFaultOpenStartCyc(routeId), + GetSystemParaLeadFaultOpenCyc()); + + /*·ʼźŻڷһ*/ + UINT16 const routeInFirstSecId = GetSignalInFirstPhySecId(startSignalId, routeId); + UINT8 const inSecCurOccupyState = GetPhySecCurMergeState(routeInFirstSecId); + /*·ʼźŻⷽһ*/ + UINT16 const routeOutFirstSecId = GetSignalOutFirstPhySecId(startSignalId); + UINT8 const outSecPreOccupyState = GetPhySecPreMergeState(routeOutFirstSecId); + UINT8 const outSecCurOccupyState = GetPhySecCurMergeState(routeOutFirstSecId); + + /* ȡ۳Ƿرźű־ */ + cDetainCloseLeadFlag = GetCiFunctionSwitchConfig(FUNC_KOUCHE_CLOSE_YINDAO_FLAG); + + if (AutoSignalOrRouteValid(routeId) == CI_SUCCESS) + { + /*Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + +/* ߼ */ + + /* ·Ϊ*/ + devState = GetRouteLeadProperty(routeId); + if ((ROUTE_LEAD_PROPERTY_YES == devState)||(ROUTE_LEAD_PROPERTY_CBTC_YES == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_LEAD_PROPERTY,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊš*/ + devState = GetRouteState(routeId); + if (devState == ROUTE_STATE_LEAD_OPEN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·δáȡδá˽⡿*/ + if ((zxqFlag == ROUTE_ZONGQUXIAO_SET_NO)&& + (zrjFlag == ROUTE_ZONGRENJIE_SET_NO)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = KeepLTrainRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = OpenLeadRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = KeepRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ź */ + checkResult = KeepBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + if (CI_SUCCESS == reResult) + { + if (leadSinalOpenState == CI_TIME_NO) + { + /*1.δʱ*/ + if (inSecCurOccupyState != SECTION_OCCUPY_NO) + { + /*źŻڷΡǰռá򡾹ϡźر*/ + reResult = CI_ERROR; + } + else + { + /*1.3 ڷΡǰС*/ + reResult = CI_SUCCESS; + } + } + else if (leadSinalOpenState == CI_TIME_IN) + { + /*2.ʱ*/ + + if(0u < routeOutFirstSecId) + { + /*2.1 ڷΡǰռáⷽΡǰСҡ֮ǰռáгȫʻ룩*/ + if ((inSecCurOccupyState != SECTION_OCCUPY_NO) && + (outSecCurOccupyState != SECTION_OCCUPY_YES) && (outSecPreOccupyState != SECTION_OCCUPY_NO)) + { + reResult = CI_ERROR; + /*رźŻ*/ + + } + else + { + /*ʱδ*/ + reResult = CI_SUCCESS; + } + } + else + { + /*ʱδ*/ + reResult = CI_SUCCESS; + } + } + else + { + /* 3.ʱ*/ + /*3.1źſʱ䳬ʱ*/ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /*cgh-ϲCID-2341-3 ܿ-źż۳*/ + if (FUNC_SWITCH_ON == cDetainCloseLeadFlag) + { + /* վ̨۳ */ + if (CI_SUCCESS == reResult) + { + checkResult = OpenRoutePlatformCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /*ܿ-Ƿִ¹*/ + if (CI_SUCCESS == reResult) + { + checkResult = LeadzLockCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + + +/* C22_·һԶ */ +/* +* ·һԶ +* ˵ UINT16 const routeId· +* UINT16* phySectionIdID +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_UNLOCK_1ST_SECTION +*/ +UINT8 RouteFirstSecAutoUnlockProcess(UINT16 const routeId, UINT16* phySectionId) +{ +/**/ + UINT8 const functionId = EFUNC_UNLOCK_1ST_SECTION; +/* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT16 cancleZhaoChaRelayId = 0u; /*ȡղ̵ID*/ + UINT8 relayState = 0u; /*̵ɼ״̬*/ +/* · */ + /*һڵǰ·ġա*/ + UINT16 nlockSectionId = 0U; + /*·*/ + UINT8 routeType = 0U; + /*һ*/ + UINT16 nextSecId = 0U; + /*Ч۷źŻ*/ + UINT16 validReturnSigId = 0U; + /*۷*/ + UINT16 returnSecId = 0U; + /*۳*/ + UINT16 backSecId = 0U; + /*۳·״̬*/ + UINT8 backRouteState = 0U; + /*۷·ʱ*/ + UINT32 returnRouteLockTime = 0U; + /*۳·ʱ*/ + UINT32 backRouteLockTime = 0U; + /*ںռ״̬*/ + UINT8 mergeState = 0U; + /*֮ǰںռ״̬*/ + UINT8 mergePreState = 0U; + /*һںռ״̬*/ + UINT8 nextMergeState = 0U; + /*·*/ + UINT16 belongRouteID = 0U; + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + UINT8 chRouteLevel = 0U; + + /*һڵǰ·ġա*/ + nlockSectionId = GetRouteFirstNormalLockSection(routeId); + /*·*/ + routeType = GetRouteType(routeId); + /*һ*/ + nextSecId = GetRouteNextPhySecId(routeId, nlockSectionId); + /*Ч۷źŻ*/ + validReturnSigId = GetValidReturnSinalId(routeId, nlockSectionId); + /*۷*/ + returnSecId = GetSignalOutFirstPhySecId(validReturnSigId); + /*۳*/ + backSecId = GetSignalInFirstLockedPhySecId(validReturnSigId); + /*·*/ + belongRouteID = GetPhySecRLockBelongRouteId(backSecId); + /*۳·״̬*/ + backRouteState = GetRouteState(belongRouteID); + /*۷·ʱ*/ + returnRouteLockTime = GetRouteLockStartCycNum(routeId); + /*۳·ʱ*/ + backRouteLockTime = GetRouteLockStartCycNum(belongRouteID); + chRouteLevel = GetRouteLevel(routeId); + + if(CI_SUCCESS == reResult) + { + /*ҵڵǰ·ĵһա*/ + if (nlockSectionId > 0u) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + /*ID = 0*/ + *phySectionId = 0u; + + } + } +#if 0 + if(CI_SUCCESS == reResult) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); + if((0u != cancleZhaoChaRelayId) && (0xFFFF != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + if(RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_RELAY,cancleZhaoChaRelayId,ETYPE_CANCLE_ZHAOCHA,relayState,sendLevel); + /* ʧܷȡղʧ */ + reResult = CI_CANCLE_ZHAOCHA_FAIL; + /*ID = 0*/ + *phySectionId = nlockSectionId; + + } + + } + + } +#endif + + if(CI_SUCCESS == reResult) + { + /*·Ϊ۷·ҽΪ۷*/ + if ((routeType == ROUTE_TYPE_RETURN) + && (nlockSectionId == returnSecId)) + { + /*۷*/ + /*۷ΡС֮ǰռá*/ + mergeState = GetPhySecCurMergeState(returnSecId); + mergePreState = GetPhySecPreMergeState(returnSecId); + if ((SECTION_OCCUPY_NO== mergeState) && (SECTION_OCCUPY_YES== mergePreState)) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + *phySectionId = nlockSectionId; + } + /*·ڷһռñʱẈ̂ȡղ̵()״̬*/ + if(CI_SUCCESS == reResult) + { + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(routeId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + if(RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_RELAY,cancleZhaoChaRelayId,ETYPE_CANCLE_ZHAOCHA,relayState,sendLevel); + /* ʧܷȡղʧ */ + reResult = CI_CANCLE_ZHAOCHA_FAIL; + /*ID = 0*/ + *phySectionId = nlockSectionId; + + } + } + } + if(CI_SUCCESS == reResult) + { + /*۳·һΡռá*/ + mergeState = GetPhySecCurMergeState(backSecId); + if (SECTION_OCCUPY_YES== mergeState) + { + /*۷*/ + reResult = CI_SUCCESS; + } + else + { + /*۷쳣*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,backSecId,ETYPE_PS_RUNLOCK_ERROR, mergeState, sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + + } + } + if(CI_SUCCESS == reResult) + { + /*۷·ʱ۳· ۳·״̬ΪӽԶ*/ + if ((returnRouteLockTime < backRouteLockTime) + &&(( ROUTE_STATE_NEAR_LOCK == backRouteState) + ||(ROUTE_STATE_AUTO_UNLOCK == backRouteState))) + { + reResult = CI_SUCCESS; + *phySectionId = nlockSectionId; + } + else + { + /*۷쳣*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE, belongRouteID,ETYPE_PS_RUNLOCK_ERROR, backRouteState,sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + } + } + else + { + /**/ + /*ǰ֮ǰǰС֮ǰռá*/ + mergeState = GetPhySecCurMergeState(nlockSectionId); + mergePreState = GetPhySecPreMergeState(nlockSectionId); + if ((SECTION_OCCUPY_NO == mergeState) && + (SECTION_OCCUPY_YES == mergePreState)) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + *phySectionId = nlockSectionId; + } + /*·ڷһռñʱẈ̂ȡղ̵()״̬*/ + if(CI_SUCCESS == reResult) + { + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(routeId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + if(RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_RELAY,cancleZhaoChaRelayId,ETYPE_CANCLE_ZHAOCHA,relayState,sendLevel); + /* ʧܷȡղʧ */ + reResult = CI_CANCLE_ZHAOCHA_FAIL; + /*ID = 0*/ + *phySectionId = nlockSectionId; + + } + + } + } + if(CI_SUCCESS == reResult) + { + /* һΡռá*/ + nextMergeState = GetPhySecCurMergeState(nextSecId); + if (SECTION_OCCUPY_YES == nextMergeState) + { + /**/ + reResult = CI_SUCCESS; + *phySectionId = nlockSectionId; + } + else + { + if (0U < validReturnSigId)/*ͨ·ת۷·*/ + { + /*۳·һռ*/ + mergeState = GetPhySecCurMergeState(backSecId); + if (SECTION_OCCUPY_YES == mergeState) + { + /*۷*/ + reResult = CI_SUCCESS; + } + else + { + /*۷쳣*/ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, backSecId, ETYPE_PS_RUNLOCK_ERROR, mergeState , sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + + if (CI_SUCCESS == reResult) + { + /*۷·ʱ۳· ۳·״̬Ϊӽ*/ + if ((backRouteLockTime > returnRouteLockTime) && (ROUTE_STATE_NEAR_LOCK== backRouteState)) + { + reResult = CI_SUCCESS; + *phySectionId = nlockSectionId; + } + else + { + /*۷쳣*/ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, belongRouteID, ETYPE_PS_RUNLOCK_ERROR, backRouteState, sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + } + } + else + {/*ͨ·쳣*/ + /*һΡСɳ*/ + /* 쳣 */ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, nextSecId, ETYPE_PS_AUNLOCK_ERROR,nextMergeState, sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + } + } + } + } + return reResult; +} + + +/* C23_·Զ */ +/* +* ·Զ +* ˵ UINT16 const routeId· +* UINT16* phySectionIdID +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_UNLOCK_OTHERS_SECTION +*/ +UINT8 RouteOtherSecAutoUnlockProcess(UINT16 const routeId, UINT16* phySectionId) +{ +/**/ + UINT8 const functionId = EFUNC_UNLOCK_OTHERS_SECTION; + +/* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ +/* · */ + /*һڵǰ·ġա*/ + UINT16 const nlockSectionId = GetRouteFirstNormalLockSection(routeId); + /*·*/ + UINT8 const routeType = GetRouteType(routeId); + /*һ*/ + UINT16 const nextSecId = GetRouteNextPhySecId(routeId,nlockSectionId); + /*Ч۷źŻ*/ + UINT16 const validReturnSigId = GetValidReturnSinalId(routeId,nlockSectionId); + /*۷*/ + UINT16 const returnSecId = GetSignalOutFirstPhySecId(validReturnSigId); + /*۳*/ + UINT16 const backSecId = GetSignalInFirstLockedPhySecId(validReturnSigId); + /*·*/ + UINT16 const wPhySecRLockId = GetPhySecRLockBelongRouteId(backSecId); + /*۳·״̬*/ + UINT8 const backRouteState = GetRouteState(wPhySecRLockId); + /*۷·ʱ*/ + UINT32 const returnRouteLockTime = GetRouteLockStartCycNum(routeId); + /*۳·ʱ*/ + UINT32 const backRouteLockTime = GetRouteLockStartCycNum(wPhySecRLockId); +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + UINT8 chPhySecCurMergeState = 0U;/*εǰں״̬*/ + UINT8 chPhySecPreMergeState = 0U;/*֮ǰں״̬*/ + +/**/ + + if(CI_SUCCESS == reResult) + { + /*ҵڵǰ·ĵһա*/ + if (nlockSectionId > 0u) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + /*ID = 0*/ + *phySectionId = 0u; + + } + } + if(CI_SUCCESS == reResult) + { + /*·Ϊ۷·ҽΪ۷*/ + if ((routeType == ROUTE_TYPE_RETURN) + && (nlockSectionId == returnSecId)) + { + /*۷*/ + /*۷ΡС֮ǰռá*/ + chPhySecCurMergeState = GetPhySecCurMergeState(returnSecId); + chPhySecPreMergeState = GetPhySecPreMergeState(returnSecId); + + if ((SECTION_OCCUPY_NO == chPhySecCurMergeState) && + (SECTION_OCCUPY_YES == chPhySecPreMergeState)) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + *phySectionId = nlockSectionId; + } + + if(CI_SUCCESS == reResult) + { + /*۳·һΡռá*/ + chPhySecCurMergeState = GetPhySecCurMergeState(backSecId); + + if (SECTION_OCCUPY_YES == chPhySecCurMergeState) + { + /*۷*/ + reResult = CI_SUCCESS; + } + else + { + /*۷쳣*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,backSecId,ETYPE_PS_RUNLOCK_ERROR,chPhySecCurMergeState,sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + } + if(CI_SUCCESS == reResult) + { + /*۷·ʱ۳· ۳·״̬Ϊӽ*/ + if ((returnRouteLockTime < backRouteLockTime) + && ((ROUTE_STATE_NEAR_LOCK == backRouteState) + || (ROUTE_STATE_AUTO_UNLOCK == backRouteState))) + { + reResult = CI_SUCCESS; + *phySectionId = nlockSectionId; + } + else + { + /*۷쳣*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE, wPhySecRLockId,ETYPE_PS_RUNLOCK_ERROR, backRouteState,sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + } + } + else + { + /**/ + /*ǰ֮ǰǰС֮ǰռá*/ + chPhySecCurMergeState = GetPhySecCurMergeState(nlockSectionId); + chPhySecPreMergeState = GetPhySecPreMergeState(nlockSectionId); + + if ((SECTION_OCCUPY_NO == chPhySecCurMergeState) && + (SECTION_OCCUPY_YES == chPhySecPreMergeState)) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + *phySectionId = nlockSectionId; + + } + if(CI_SUCCESS == reResult) + { + /* һΡռá*/ + chPhySecCurMergeState = GetPhySecCurMergeState(nextSecId); + if (SECTION_OCCUPY_YES == chPhySecCurMergeState) + { + /**/ + reResult = CI_SUCCESS; + *phySectionId = nlockSectionId; + } + else + { + if (validReturnSigId > 0u)/*ͨ·ת۷·*/ + { + /*۳·һռ*/ + chPhySecCurMergeState = GetPhySecCurMergeState(backSecId); + + if (SECTION_OCCUPY_YES == chPhySecCurMergeState) + { + /*۷*/ + reResult = CI_SUCCESS; + } + else + { + /*۷쳣*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,backSecId,ETYPE_PS_RUNLOCK_ERROR, chPhySecCurMergeState,sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + if(CI_SUCCESS == reResult) + { + /*۷·ʱ۳· ۳·״̬Ϊӽ*/ + if ((((INT32)(backRouteLockTime- returnRouteLockTime)) > 0 ) + &&(backRouteState == ROUTE_STATE_NEAR_LOCK)) + { + reResult = CI_SUCCESS; + *phySectionId = nlockSectionId; + } + else + { + /*۷쳣*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE, wPhySecRLockId,ETYPE_PS_RUNLOCK_ERROR, backRouteState,sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + } + } + else + {/*ͨ·쳣*/ + /*һΡСɳ*/ + /* 쳣 */ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,nextSecId,ETYPE_PS_AUNLOCK_ERROR, chPhySecCurMergeState,sendLevel); + /* ʧܷ */ + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *phySectionId = nlockSectionId; + } + } + } + } + } + return reResult; +} + + +/* C24_ʱ*/ +/* +* ʱ +* ˵ UINT16 const routeId· +* UINT16* phySectionIdID +* ֵ CI_ERROR +* RETURN_DELAYUNLOCK_ERR_TIMECOUNT +* CI_SUCCESS +* ϱ룺 EFUNC_DLOCK_SECTION +*/ +UINT8 PhySectionDelayUnlockProcess(UINT16 const routeId, UINT16* phySectionId) +{ +/**/ + /*UINT8 const functionId = EFUNC_DLOCK_SECTION;*/ + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + + UINT32 cycNum = 0u; + UINT32 cycNumSysPara = 0u;/*ϵͳʱ*/ + + UINT8 routeTimeState = CI_TIME_OUT; + + /* · */ + /*һڵǰ·ġʱա*/ + UINT16 const dlockSectionId = GetRouteFirstDelayLockSection(routeId); + /*ռ״̬*/ + UINT8 const secOccypyState = GetPhySecCurMergeState(dlockSectionId); + + cycNum = GetPhySecAutoUnlockStartCycNum(dlockSectionId); + cycNumSysPara = GetSystemParaSecDelayUnlockCyc(); + /* ʱʱ״̬*/ + routeTimeState = SystemOverTimeCheck(cycNum, cycNumSysPara); + + +/**/ + + /*·һΡʱաڵǰ·*/ + if (dlockSectionId > 0u) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + /*ID = 0*/ + *phySectionId = 0u; + + } + + if (CI_SUCCESS == reResult) + { + /*ռ״̬ = С*/ + if (secOccypyState == SECTION_OCCUPY_NO) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + /* ʱ */ + *phySectionId = dlockSectionId; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ʱʱ*/ + if (routeTimeState == CI_TIME_NO) + { + /*ʱδ*/ + /* ʧܷ */ + reResult = CI_ERROR; + /* ʱ */ + *phySectionId = dlockSectionId; + + } + else if (routeTimeState == CI_TIME_IN) + { + /*ʱδ*/ + /* ʧܷ */ + reResult = RETURN_DELAYUNLOCK_ERR_TIMECOUNT; + /* ʱ */ + *phySectionId = dlockSectionId; + + } + else + { + /* ʱ䵽ʱ */ + reResult = CI_SUCCESS; + /* */ + *phySectionId = dlockSectionId; + + } + } + + return reResult; +} + +/* C25_·overlap߼ */ +/* +* ·overlap߼ +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* CI_UNLOCK_OVERLAP_REQURE ZC +* ϱ룺 EFUNC_UNLOCK_OVER_LAP +*/ +UINT8 UnlockRouteOverlapLogicProcess(UINT16 const routeId, UINT16* overlapId,UINT16* pTrainId) +{ +/**/ + UINT8 const functionId = EFUNC_UNLOCK_OVER_LAP; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 secStopTimeState = CI_TIME_NO; /*ʱǷʱ*/ + /*CTUTռ״̬Ϊ(UT)ռ״̬*/ + UINT8 utOrCtOccFlag = LOGICSECTION_OCCUPY_UT; + UINT8 functionSwitchFlag = 0u; + + /*·һ*/ + UINT16 const routeLastSecId = GetRouteLastPhySectionId(routeId); + UINT16 const secStopFlag = GetPhySecStopSteadyFlag(routeLastSecId); + + /*·*/ + UINT8 const overlapSum = GetRouteOverlapSum(routeId); + UINT16 const overlapLockedId = GetRouteOverlapLockedId(routeId); + + UINT8 tmpRouteBelongCiId = 0u; + UINT8 localCiId = 0u; + UINT8 overlapBelongCiId = 0u; + UINT16 overlapUnLockCount = 0u;/*ν*/ + + UINT32 relyonStartCycNum = 0u;/*ʱ*/ +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + UINT8 cIvocUnlockOverlapFlag = 0U; /*гͬα־*/ + UINT8 cRcWorkMode = 0U; + UINT8 phySecSum = 0U; + UINT8 chABLFlag = 0U; /*ABLռñ־*/ + + localCiId = GetSystemParaLocalCiId(); + + SetOverlapCanLaborUnlockFlag(overlapLockedId,CANNOT_LABOR_UNLOCK_OVERLAP);/*ÿò˹*/ + /*·*/ + /*·з*/ + if ((overlapSum > 0u) && (overlapLockedId >0u) && (NULL != pTrainId)) + { + /*з·*/ + reResult = CI_SUCCESS; + } + else + { + /*޷·*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_OVERLAP_UNLOCK,CI_ERROR,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + *overlapId = overlapLockedId; + + } + + if (CI_SUCCESS == reResult) + { + /* ΡС*/ + devId = 0u; + devState = 0u; + checkResult = OverlapAllSecOccuClearCheck(overlapLockedId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + *overlapId = overlapLockedId; + + } + } + +#if 0 + if (CI_SUCCESS == reResult) + { + /* ڵ߼Դֻһгȡ޳ռ */ + checkResult = OverlapLogicSectionTrainCheck(overlapLockedId, &wTmpTrainId); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + *pTrainId = wTmpTrainId; + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + *overlapId = overlapLockedId; + + } + } +#endif + + if (CI_SUCCESS == reResult) + { + /*·״̬Сҽ·һΡδա*/ + devId = GetRouteLastPhySectionId(routeId); + devState = GetPhySecLockState(devId); + + tmpRouteBelongCiId = GetRouteBelongCiId(routeId); + overlapBelongCiId = (UINT8)GetOverlapBelongCiId(overlapLockedId); + + if (PHYSICAL_SECTION_LOCK_NO==devState) + { + /*һδԽ*/ + /* ֱӽ */ + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + } + else + { + if (GetRouteDirection(routeId) == GetPhySecLockDirection(devId)) + {/*˵·շ·ķͬ*/ + if (GetPhySecCurMergeState(devId) == SECTION_OCCUPY_YES) + { + utOrCtOccFlag = GetPhySecPreOccState(devId); /*ȡCTUTռ״̬*/ + functionSwitchFlag = GetCiFunctionSwitchConfig(UNLOCK_OVERLAP_SWITCH_CONF); + /*ͣȽεʱʱ飺ͨųռü45sʱͨųռü180sʱ*/ + if (LOGICSECTION_OCCUPY_UT == utOrCtOccFlag) + {/*ǰΪͨųռãABL45sʱABL180S RC16.0*/ + chABLFlag = GetPhySecABLTrainFlag(devId); + if ((tmpRouteBelongCiId == localCiId) && (overlapBelongCiId == localCiId))/*·ڱұڱ*/ + {/*ʱνΪϵͳ*/ + if (PHYSICAL_SECTION_ABLOCCUPY_YES != chABLFlag) + { + overlapUnLockCount = (UINT16)GetSystemParaProtSecUnlockCyc(); + } + else + { + /*ABLCTʱ*/ + overlapUnLockCount = (UINT16)GetSystemParaCtProtSecUnlockCyc(); + } + } + else if ((tmpRouteBelongCiId != localCiId) && (overlapBelongCiId == localCiId))/*·ڱұڱ*/ + { + if (PHYSICAL_SECTION_ABLOCCUPY_YES != chABLFlag) + { + overlapUnLockCount = GetOtherCIRouteOvlpUTUnlockCnt(routeId); + } + else + { + /*ABLCTʱ*/ + overlapUnLockCount = GetOtherCIRouteOverlapCTUnlockCount(routeId); + } + + } + else + { + /*·ڱβڱһѾأݲ*/ + + } + + relyonStartCycNum = CalculaOverlapUnlockStartCycNum(overlapLockedId, devId);/*ʼʱ*/ + + + secStopTimeState = SystemOverTimeCheck(relyonStartCycNum, overlapUnLockCount); + if (((PHYSICAL_SECTION_STOPSTEADY_YES == secStopFlag) && (CI_TIME_IN == secStopTimeState)) || (CI_TIME_OUT == secStopTimeState)) + {/*δʱյͣϢǵʱʱ*/ + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + } + else + { + /*δʱδյͣϢܽ*/ + reResult = CI_ERROR; + *overlapId = overlapLockedId; + } + if (CI_SUCCESS != reResult) + {/*ִе˴˵˹־*/ + + SetOverlapCanLaborUnlockFlag(overlapLockedId, CAN_LABOR_UNLOCK_OVERLAP);/*ÿ˹*/ + + checkResult = CheckOverlapLaborUnlock(overlapLockedId, (UINT32)overlapUnLockCount, relyonStartCycNum); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + /*reResultʲôҲ*/ + } + } + } + else if (LOGICSECTION_OCCUPY_CT == utOrCtOccFlag) + {/*ǰΪͨųռã180sʱ*/ + + if ((tmpRouteBelongCiId == localCiId) && (overlapBelongCiId == localCiId))/*·ڱұڱ*/ + {/*ʱνΪϵͳ*/ + overlapUnLockCount = (UINT16)GetSystemParaCtProtSecUnlockCyc(); + } + else if ((tmpRouteBelongCiId != localCiId) && (overlapBelongCiId == localCiId))/*·ڱұڱ*/ + { + overlapUnLockCount = GetOtherCIRouteOverlapCTUnlockCount(routeId); + } + else + { + /*·ڱβڱһѾأݲ*/ + + /*·ڱβڱһѾأݲ*/ + } + + /*ͨųҪ鳵ZC͵ͣϢͣ򲻽*/ + relyonStartCycNum = CalculaOverlapUnlockStartCycNum(overlapLockedId, devId);/*ʼʱ*/ + secStopTimeState = SystemOverTimeCheck(relyonStartCycNum, overlapUnLockCount); + if (FUNC_SWITCH_ON == functionSwitchFlag) + { + if (PHYSICAL_SECTION_STOPSTEADY_YES == secStopFlag) + {/*CTΣյͣϢ*/ + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + + } + else + { + /*δʱδյͣϢܽ*/ + if (CI_TIME_OUT == secStopTimeState) + { + /*ʱʱZC/IVOC뱣ν*/ + cRcWorkMode = GetLocalRcWorkMode(); + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + reResult = GetNearstVBTCTrainToOverlap(routeId, pTrainId); /*Ѱӽεг*/ + if (CI_SUCCESS == reResult) + { + cIvocUnlockOverlapFlag = GetOverlapIvocAllowUnlockFlag(overlapLockedId); /*ȡгͬα־*/ + if (IVOC_ALLOW_UNLOCK_OVERLAP_YES == cIvocUnlockOverlapFlag) + { + reResult = CI_SUCCESS; /*ͬسɹ*/ + } + else + { + reResult = CI_UNLOCK_OVERLAP_REQURE; /*ͬ*/ + } + } + else + { + reResult = CI_ERROR; + } + } + else + { + reResult = CI_UNLOCK_OVERLAP_REQURE; /*ZC*/ + } + + *overlapId = overlapLockedId; + } + else + { + reResult = CI_ERROR; + *overlapId = overlapLockedId; + } + + } + + } + else if (FUNC_SWITCH_OFF == functionSwitchFlag) + { + if (((PHYSICAL_SECTION_STOPSTEADY_YES == secStopFlag) && (CI_TIME_IN == secStopTimeState)) || (CI_TIME_OUT == secStopTimeState)) + {/*δʱյͣϢǵʱʱ*/ + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + } + else + { + /*δʱδյͣϢܽ*/ + reResult = CI_ERROR; + *overlapId = overlapLockedId; + } + } + else + { /*ô*/ + reResult = CI_ERROR; + *overlapId = overlapLockedId; + } + if (CI_SUCCESS != reResult) + {/*ִе˴˵˹־*/ + + SetOverlapCanLaborUnlockFlag(overlapLockedId, CAN_LABOR_UNLOCK_OVERLAP);/*ÿ˹*/ + + checkResult = CheckOverlapLaborUnlock(overlapLockedId, (UINT32)overlapUnLockCount, relyonStartCycNum); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + /*reResultʲôҲ*/ + } + *overlapId = overlapLockedId; + } + + } + else + { + /*г͹*/ + reResult = CI_ERROR; + *overlapId = overlapLockedId; + } + + } + else + { + phySecSum = GetRoutePhysicalSectionSum(routeId); + /*·ֻһΣҸαǰһ· Խ*/ + if ((PHYSICAL_SECTION_LOCK_PROTECT == devState)&&(1U== phySecSum)) + { + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + } + else + { + /*һν·յδռãԽ*/ + /*ڴ˴˹ձ־ӡ¼*/ + SetOverlapAtsOrlaborLockCmdFlag(overlapLockedId, LOCK_OVERLAP_CMD_NO);/*˹ձ־ʹ´ռʱռʼʱΪԶʱοʱ*/ + SetlaborUnlockStartCycNum(overlapLockedId, 0u);/*˹ʼڣ֤ZCLEUͱν*/ + reResult = CI_ERROR; + *overlapId = overlapLockedId; + } + } + } + else + { + /*һѾգοԽ*/ + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + } + } +#if 0 + if ((routeState == ROUTE_STATE_IDLE) && (devState == PHYSICAL_SECTION_LOCK_NO)) + { + /* ֱӽ */ + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + + } + else + { + /*յһͣ*/ + if (((secStopFlag == PHYSICAL_SECTION_STOPSTEADY_YES)&&(secStopTimeState == CI_TIME_IN)) + || (PHYSICAL_SECTION_LOCK_NO == secLockState)) + {/*δʱյͣȣ*/ + + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + } + else if (secStopTimeState == CI_TIME_OUT) + {/*Ƿյͣȣʱ*/ + + reResult = CI_SUCCESS; + *overlapId = overlapLockedId; + + } + else + {/**/ + + reResult = CI_ERROR; + *overlapId = overlapLockedId; + + } + } +#endif + } + + return reResult; +} + + +/* C26_·ȡ */ +/* +* ·ȡ +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCLE_ROUTE +*/ +UINT8 RouteCancelLogicProcess(UINT16 const routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CANCLE_ROUTE; +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 routepreState = 0u; /*·״̬*/ + UINT16 cancleZhaoChaRelayId = 0u; /*ȡղ̵ID*/ + UINT8 relayState = 0u; /*̵ɼ״̬*/ +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + UINT8 chRouteLevel = 0U; + UINT8 cRouteType = 0U; /*·*/ + +/**/ + /* ·״̬ա*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if(CI_SUCCESS == reResult) + { + cRouteType = GetRouteType(routeId); /*ȡ·*/ + if (ROUTE_TYPE_DIAOCHE == cRouteType) + { + /*·гмͲռѹζ*/ + checkResult = CheckDTrainRoutePhySecOccupy(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /*ͨ*/ + reResult = CI_SUCCESS; + } + else + { + /*ʧܷ*/ + reResult = CI_ERROR; + } + } + else + { + routepreState = GetRoutePreState(routeId);/*ȡڽ·״̬*/ + if ((ROUTE_STATE_LEAD_LOCK != routepreState) && + (ROUTE_STATE_LEAD_LOCKERR != routepreState)) /*·ż·*/ + { /* ·ռ״̬С*/ + + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + } + } + else + { + } + + if(CI_SUCCESS == reResult) + { + chRouteLevel = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(routeId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + devId = cancleZhaoChaRelayId; + devState = relayState; + if(RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_RELAY,devId,ETYPE_CANCLE_ZHAOCHA,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + else + { + } + } + else + { + } + + return reResult; +} + + +/* C27_ü */ +/* +* ü +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CHECK_SECTION_USE +*/ +UINT8 RoutePhySectionUseLogicProcess(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CHECK_SECTION_USE; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /**/ + UINT8 triggerFlag = 0u; + UINT8 sendLevel = 0u; /*ATS*/ + + triggerFlag = GetRouteAutoTriggerFlag(routeId); /*ȡ·Զ־*/ + if ((AutoSignalOrRouteValid(routeId) == CI_SUCCESS) || + (AUTO_TRIGGER_SET_YES == triggerFlag)) + { + /*Զ·/Զ·ATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/**/ + + /* ·ȫ = δá*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecUseVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_USE_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + return reResult; +} + +/* C29_*/ +/* +* +* ˵ +* UINT16 const switchId, UINT8 const switchSetPos +* UINT8 chSwitchTestFlag CI_SUCCESS/λʱָλñ־CI_ERROR ǵ/λߵ/λʱָλñ־ +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SWITCH_POS +* cgh-ϲCID-3037-6 +*/ +UINT8 SetSwitchPositionLogicProcess(UINT16 const switchId, UINT8 const switchSetPos, const UINT8 chCmdType, UINT8* chSwitchTestFlag) +{ + /**/ + UINT8 const functionId = EFUNC_SET_SWITCH_POS; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 lineType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡͨ·*/ + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + + /**/ + (*chSwitchTestFlag) = CI_ERROR; + /*λòָλ*/ + checkResult = GetSwitchCurPosition(switchId); + if (checkResult != switchSetPos) + { + /*ڵλ*/ + reResult = CI_SUCCESS; + } + else + { + /*ָλ*/ + if ((ATS_CMD_SWITCH_DINGWEI_TEST_TWO == chCmdType) || (ATS_CMD_SWITCH_FANWEI_TEST_TWO == chCmdType)) + { + *chSwitchTestFlag = CI_SUCCESS; /*ִе/λʱб*/ + + + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_POSTION_STATE, checkResult, sendLevel); + + } + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*״̬Ϊδա*/ + /*״̬ =С*/ + /*״̬ =δ*/ + /*״̬ =δ*/ + if (CI_TRADITION_RAILWAY == lineType) + {/*ǹ·*/ + checkResult = GetSwitchMoveValidState(switchId, SWITCH_OPER_DANCAO, sendLevel); + } /* zt ɾش 2022-02-15 */ + else + {/*ڵ·*/ + checkResult = CI_ERROR; + } + + if (checkResult == CI_SUCCESS) + { + /*ɵ*/ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; + } + + if (CI_SUCCESS == reResult) + { + /*ЧԼͨ*/ + reResult = GetSwitchUsingValidState(switchId, functionId, sendLevel); + } + else + { + ; + } + + return reResult; +} + + +/* C30_õ*/ +/* +* õ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SWITCH_DLOCK +*/ +UINT8 SetSwitchDLockLogicProcess(UINT16 const switchId) +{ +/**/ + UINT8 const functionId = EFUNC_SET_SWITCH_DLOCK; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + +/*豸*/ + /**/ + UINT8 const switchType = GetSwitchType(switchId); + /*1*/ + UINT8 const switch1stLockStatus = GetSwitchLockStatus(switchId); + UINT8 const switch1stYLockState = GetSwitchYLockState(switchId); + UINT8 const switch1stFLockState = GetSwitchFLockState(switchId); + + /*2*/ + UINT16 const switch2ndId = GetDSwitchOtherId(switchId); + UINT8 const switch2ndLockStatus = GetSwitchLockStatus(switch2ndId); + UINT8 const switch2ndYLockState = GetSwitchYLockState(switch2ndId); + UINT8 const switch2ndFLockState = GetSwitchFLockState(switch2ndId); + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + UINT8 CiFunctionFLock = 0u; /*ȡʱ־*/ + CiFunctionFLock = GetCiFunctionSwitchConfig(FUNC_CHECK_FLOCK_BEFORE_DANSUO); + +/**/ + + /*1״̬ =δա򡾷ա*/ + checkResult = switch1stLockStatus; + if ((SWITCH_LOCK_STATUS_NO == checkResult) || (SWITCH_LOCK_STATUS_PROTECT == checkResult)) + { + /*δա򡾷ա*/ + reResult = CI_SUCCESS; + } + else + { + if ((SWITCH_LOCK_STATUS_DANSUO == checkResult) || (SWITCH_LOCK_STATUS_DAP == checkResult)) + { + /*򡾵ҷա*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_LOCK_STATUS,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*1״̬ =δ*/ + checkResult = switch1stYLockState; + if (checkResult == SWITCH_LOCK_YINZONG_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_YLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_OFF == CiFunctionFLock) + {/*cgh-ϲCID-2349-2*/ + /**/ + reResult = CI_SUCCESS; + } + else + { + /*1״̬=δ*/ + checkResult = switch1stFLockState; + if (checkResult == SWITCH_LOCK_FENGSUO_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_FLOCK_STATE, checkResult, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + } + + if (CI_SUCCESS == reResult) + { + if (switchType == SWITCH_TYPE_DOUBLE) + { + /*˫*/ + /*2״̬ =δա򡾷ա*/ + checkResult = switch2ndLockStatus; + if ((SWITCH_LOCK_STATUS_NO == checkResult) || (SWITCH_LOCK_STATUS_PROTECT == checkResult)) + { + /*δա򡾷ա*/ + reResult = CI_SUCCESS; + } + else + { + if ((SWITCH_LOCK_STATUS_DANSUO == checkResult) || (SWITCH_LOCK_STATUS_DAP == checkResult)) + { + /*򡾵ҷա*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_LOCK_STATUS,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + if (CI_SUCCESS == reResult) + { + /*2״̬ =δ*/ + checkResult = switch2ndYLockState; + if (checkResult == SWITCH_LOCK_YINZONG_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_YLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + {/*cgh-ϲCID-2349-2*/ + if (FUNC_SWITCH_OFF == CiFunctionFLock) + { + reResult = CI_SUCCESS; + } + else + { + /*2״̬=δ*/ + checkResult = switch2ndFLockState; + if (checkResult == SWITCH_LOCK_FENGSUO_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, switchId, ETYPE_SWT_FLOCK_STATE, checkResult, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + } + + } + else + { + /*ɵ*/ + } + } + + return reResult; +} + +/* C31_ȡ*/ +/* +* ȡ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCEL_SWITCH_DLOCK +*/ +UINT8 CancelSwitchDLockLogicProcess(UINT16 const switchId) +{ +/**/ + UINT8 const functionId = EFUNC_CANCEL_SWITCH_DLOCK; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + +/*豸*/ + /**/ + UINT8 const switchType = GetSwitchType(switchId); + /*1*/ + UINT8 const switch1stLockStatus = GetSwitchLockStatus(switchId); + + /*2*/ + UINT16 const switch2ndId = GetDSwitchOtherId(switchId); + UINT8 const switch2ndLockStatus = GetSwitchLockStatus(switch2ndId); + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + + +/**/ + + /*1״̬ =򡾵ҷա*/ + checkResult = switch1stLockStatus; + if ((SWITCH_LOCK_STATUS_DANSUO == checkResult) || (SWITCH_LOCK_STATUS_DAP == checkResult)) + { + /*򡾵ҷա*/ + reResult = CI_SUCCESS; + } + else + { + /*δա򡾷ա*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_LOCK_STATUS,SWITCH_LOCK_STATUS_DANSUO_NO,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + if (switchType == SWITCH_TYPE_DOUBLE) + { + /*˫*/ + /*2״̬ =򡾵ҷա*/ + checkResult = switch2ndLockStatus; + if ((SWITCH_LOCK_STATUS_DANSUO == checkResult) || (SWITCH_LOCK_STATUS_DAP == checkResult)) + { + /*˫򡾵ҷա*/ + reResult = CI_SUCCESS; + } + else + { + /*δա򡾷ա*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_LOCK_STATUS,SWITCH_LOCK_STATUS_DANSUO_NO,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + /*ɵ*/ + } + } + + return reResult; +} + + +/* C32_õ*/ +/* +* õ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SWITCH_FLOCK +*/ +UINT8 SetSwitchFLockLogicProcess(UINT16 const switchId) +{ +/**/ + UINT8 const functionId = EFUNC_SET_SWITCH_FLOCK; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 lineIdentity = CI_TRADITION_RAILWAY; /*·*/ + UINT16 phySecId = 0u; /*ID*/ + UINT8 devState = 0u; /*豸״̬*/ +/*豸*/ + /**/ + UINT8 const switchType = GetSwitchType(switchId); + /*1*/ + UINT8 const switch1stLockStatus = GetSwitchLockStatus(switchId); + UINT8 const switch1stYLockState = GetSwitchYLockState(switchId); + UINT8 const switch1stFLockState = GetSwitchFLockState(switchId); + UINT16 const switch1stSecId = GetSwitchPhySectionId(switchId); + UINT8 const switch1stSecLockState = GetPhySecLockState(switch1stSecId); + UINT8 const chSw1PhySecLogLockState = PhySecLogLockStateCheck(switch1stSecId);/*߼·״̬*/ + + /*2*/ + UINT16 const switch2ndId = GetDSwitchOtherId(switchId); + UINT8 const switch2ndLockStatus = GetSwitchLockStatus(switch2ndId); + UINT8 const switch2ndYLockState = GetSwitchYLockState(switch2ndId); + UINT8 const switch2ndFLockState = GetSwitchFLockState(switch2ndId); + UINT16 const switch2ndSecId = GetSwitchPhySectionId(switch2ndId); + UINT8 const switch2ndSecLockState = GetPhySecLockState(switch2ndSecId); + UINT8 const chSw2PhySecLogLockState = PhySecLogLockStateCheck(switch2ndSecId);/*˫߼·״̬*/ + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + + UINT8 CiFunctionDLock = 0u; /*ȡʱ־*/ + UINT8 CiFunctionLock = 0u; /*ȡʱձ־*/ + + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF); /*ȡ·*/ +/**/ + + CiFunctionDLock = GetCiFunctionSwitchConfig(CHECK_SWITCH_DANLOCK_FLOCKING_SWITCH_CONF); + CiFunctionLock = GetCiFunctionSwitchConfig(CHECK_SWITCH_LOCKING_BEFORE_LOCKING_SWITCH_CONF); + + if(FUNC_SWITCH_ON == CiFunctionDLock) + { + /*1״̬ =δա*/ + checkResult = switch1stLockStatus; + if (checkResult == SWITCH_LOCK_STATUS_NO) + { + /*δա*/ + reResult = CI_SUCCESS; + } + else + { + /*ա*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_LOCK_STATUS,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else if(FUNC_SWITCH_OFF == CiFunctionDLock) + { + reResult = CI_SUCCESS; + } + else + { + /*ܿô ߼*/ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*1״̬ =δ*/ + checkResult = switch1stYLockState; + if (checkResult == SWITCH_LOCK_YINZONG_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_YLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*1״̬=δ*/ + checkResult = switch1stFLockState; + if (checkResult == SWITCH_LOCK_FENGSUO_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_FLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + + if(FUNC_SWITCH_ON == CiFunctionLock) + { + if (CI_TRADITION_RAILWAY == lineIdentity) + {/*ͳ·*/ + /*1״̬Ϊδա*/ + checkResult = switch1stSecLockState; + if (checkResult == PHYSICAL_SECTION_LOCK_NO) + { + /*δա*/ + reResult = CI_SUCCESS; + + if (LOG_SECTION_LOGLOCK_NO == chSw1PhySecLogLockState) + { + /*δ߼·ա*/ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch1stSecId, ETYPE_PS_LOCK_STATE, chSw1PhySecLogLockState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /*ա*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch1stSecId,ETYPE_PS_LOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + }/* zt ɾش 2022-02-15 */ + else + {/*·ʹ*/ + reResult = CI_ERROR; + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,phySecId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + } + + } + else if(FUNC_SWITCH_OFF == CiFunctionLock) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + if (switchType == SWITCH_TYPE_DOUBLE) + { + /*˫*/ + /*2״̬ =δա*/ + if(FUNC_SWITCH_ON == CiFunctionDLock) + { + checkResult = switch2ndLockStatus; + if (checkResult == SWITCH_LOCK_STATUS_NO) + { + /*δա*/ + reResult = CI_SUCCESS; + } + else + { + /*ա*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_LOCK_STATUS,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else if(FUNC_SWITCH_OFF == CiFunctionDLock) + { + reResult = CI_SUCCESS; + } + else + { + /*ܿô ߼*/ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*2״̬ =δ*/ + checkResult = switch2ndYLockState; + if (checkResult == SWITCH_LOCK_YINZONG_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_YLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*2״̬=δ*/ + checkResult = switch2ndFLockState; + if (checkResult == SWITCH_LOCK_FENGSUO_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_FLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + if(FUNC_SWITCH_ON == CiFunctionLock) + { + if (CI_TRADITION_RAILWAY == lineIdentity) + {/*ͳ·*/ + /*2״̬Ϊδա*/ + checkResult = switch2ndSecLockState; + if (checkResult == PHYSICAL_SECTION_LOCK_NO) + { + /*δա*/ + reResult = CI_SUCCESS; + if (LOG_SECTION_LOGLOCK_NO == chSw2PhySecLogLockState) + { + /*δ߼·ա*/ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, switch2ndSecId, ETYPE_PS_LOCK_STATE, chSw2PhySecLogLockState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /*ա*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,switch2ndSecId,ETYPE_PS_LOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + }/* zt ɾش 2022-02-15 */ + else + {/*·ʹ*/ + reResult = CI_ERROR; + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,phySecId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + } + } + else if(FUNC_SWITCH_OFF == CiFunctionLock) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + } + else + { + /*ɷ*/ + } + } + + return reResult; +} + + +/* C33_ȡ*/ +/* +* ȡ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCEL_SWITCH_FLOCK +* +*/ +UINT8 CancelSwitchFLockLogicProcess(UINT16 const switchId) +{ +/**/ + UINT8 const functionId = EFUNC_CANCEL_SWITCH_FLOCK; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + +/*豸*/ + /**/ + UINT8 const switchType = GetSwitchType(switchId); + /*1*/ + UINT8 const switch1stFLockState = GetSwitchFLockState(switchId); + + /*2*/ + UINT16 const switch2ndId = GetDSwitchOtherId(switchId); + UINT8 const switch2ndFLockState = GetSwitchFLockState(switch2ndId); + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + + +/**/ + + /*1״̬ =*/ + checkResult = switch1stFLockState; + if (checkResult == SWITCH_LOCK_FENGSUO_YES) + { + /**/ + reResult = CI_SUCCESS; + } + else + { + /*δ*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_FLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + if (switchType == SWITCH_TYPE_DOUBLE) + { + /*˫*/ + /*2״̬ =*/ + checkResult = switch2ndFLockState; + if (checkResult == SWITCH_LOCK_FENGSUO_YES) + { + /*˫ɽ*/ + reResult = CI_SUCCESS; + } + else + { + /*δ*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_FLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + /*ɽ*/ + } + } + + return reResult; +} + +/* C34_źŻ*/ +/* +* źŻ +* ˵ UINT16 const signalId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SIGNAL_FLOCK +* +*/ +UINT8 SetSignalFLockLogicProcess(UINT16 const signalId) +{ +/**/ + UINT8 const functionId = EFUNC_SET_SIGNAL_FLOCK; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + +/*豸*/ + UINT8 const signalFLockState = GetSignalFLockState(signalId); + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + +/**/ + + /*źŻ״̬ =δ*/ + checkResult = signalFLockState; + if (checkResult == SIGNAL_FENGSUO_NO) + { + /*δ*/ + reResult = CI_SUCCESS; + } + else + { + /**/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,signalId,ETYPE_SIG_FLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + return reResult; +} + + +/* C35_ȡźŻ*/ +/* +* ȡźŻ +* ˵ UINT16 const signalId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCEL_SIGNAL_FLOCK +* +*/ +UINT8 CancelSignalFLockLogicProcess(UINT16 const signalId) +{ +/**/ + UINT8 const functionId = EFUNC_CANCEL_SIGNAL_FLOCK; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + +/*豸*/ + UINT8 const signalFLockState = GetSignalFLockState(signalId); + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS;/*ATS*/ + +/**/ + + /*źŻ״̬ =*/ + checkResult = signalFLockState; + if (checkResult == SIGNAL_FENGSUO_YES) + { + /**/ + reResult = CI_SUCCESS; + } + else + { + /*δ*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,signalId,ETYPE_SIG_FLOCK_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + return reResult; +} + +/* C36_ǿ*/ +/* +* ǿ +* ˵ UINT16 const switchId, UINT8 const switchSetPos +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_FORCE_SET_SWITCH_POS +*/ +UINT8 ForceSetSwitchPosLogicProcess(UINT16 const switchId, UINT8 const switchSetPos) +{ +/**/ + UINT8 const functionId = EFUNC_FORCE_SET_SWITCH_POS; + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 lineType = CI_TRADITION_RAILWAY; +/*豸*/ + /*Ϸͼ*/ + UINT8 sendLevel = 0u; + sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + + + lineType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡͨ·*/ + +/**/ + + /*λòָλ*/ + checkResult = GetSwitchCurPosition(switchId); + if (checkResult != switchSetPos) + { + /*ڵλ*/ + reResult = CI_SUCCESS; + } + else + { + /*ָλ*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,switchId,ETYPE_SWT_POSTION_STATE,checkResult,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + + + + if (CI_SUCCESS == reResult) + { + /*״̬Ϊδա*/ + /*״̬ =ռá*/ + /*״̬ =δ*/ + /*״̬ =δ*/ + + if(CI_TRADITION_RAILWAY == lineType) + { + checkResult = GetSwitchForceMoveValidState(switchId,sendLevel); + }/* zt ɾش 2022-02-15 */ + else + { + /* ʧܷ */ + checkResult = CI_ERROR; + } + + + + if(checkResult == CI_SUCCESS) + { + /*ɵ*/ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + ; + } + + if (CI_SUCCESS == reResult) + { + /*ЧԼͨ*/ + reResult = GetSwitchUsingValidState(switchId, functionId, sendLevel); + } + else + { + ; + } + + return reResult; +} + +/* R_R_S_C1·źŻ */ +/* +* ·źŻ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetReverseRouteSignalCheck( UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + +/* ·豸 */ + /* ʼźŻId */ + UINT16 const startSignalId = GetRouteStartSignalId(routeId); + + /* ߼ */ + + /* ·ʼźŻδ*/ + + devState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId)); + if (SIGNAL_CLOSE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + /*·źŻδ*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteSignalFLockCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + /*·ĵж*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = ReverseRouteSigEnemyVainCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ENEMY_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + } + /* ؽ */ + return reResult; +} + + + + +/* L02_ʽ· */ +/* +* ʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetBlocRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 funcSwitch = 0u; /*ܿ*/ + + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /* ·ռ״̬С*/ + devId = 0u; + devState = 0u; + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221007 ·ǰ⶯*/ + checkResult = RouteAllLogSecOccuClearCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + /* ·״̬δաͬġա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221007 ·ǰ⶯*/ + checkResult = BlockRouteLogSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + checkResult = BlockRouteSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /* ·߼Ρδ߼ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIncLogSecLogicLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ڵһλ߼δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + + +/* R_L_L_01· */ +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetReverseRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 funcSwitch = 0u; /*ܿ*/ + + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + + +/* ߼ */ + + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221008 ·ǰ⶯*/ + checkResult = RouteAllLogSecOccuClearCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /* ·״̬δաͬġա*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221008 ·ǰ⶯*/ + checkResult = ReverseRouteLogSecLockValCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + checkResult = ReverseRouteSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /* ·߼Ρδ߼ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIncLogSecLogicLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + +#if 0 + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ڵһλ߼δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ؽ */ + return reResult; +} + +/* R_L_L_02·ԶźŽ·״̬ */ +/* +* ·ԶźŽ·״̬ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetRevrRouteAutoSigStaCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 reverseRouteAutoSigRouteSum = 0u; /*·ԶźŽ·Ŀ*/ + UINT16 * reverseRouteAutoSigRouteBuf = NULL; /*·ԶźŽ·Id*/ + + UINT8 i = 0u; + + +/* ߼ */ + + /*·ڰԶźŽ·״̬Ϊ:ӽšӽ쳣*/ + devId = 0u; + devState = 0u; + reverseRouteAutoSigRouteSum = GetReverseRouteIncludeRouteSum(routeId);/*ȡ·ԶźŽ·Ŀ*/ + reverseRouteAutoSigRouteBuf = GetReverseRouteIncludeRouteBuf(routeId);/*ȡ·ԶźŽ·ID*/ + + for(i = 0u;i < reverseRouteAutoSigRouteSum;i++) + { + devId = reverseRouteAutoSigRouteBuf[i];/*ȡԶźŽ·ID*/ + devState = GetRouteState(devId);/*ȡԶźŽ·״̬*/ + if((ROUTE_STATE_NEAR_OPEN == devState) || (ROUTE_STATE_NEAR_LOCKERR == devState)) + {/*ԶźŽ·״̬Ϊ(ӽ) || (ӽ쳣)ʧ*/ + + reResult = CI_ERROR; + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_STATE,devState,sendLevel); + break; + } + } + + /* ؽ */ + return reResult; +} + + + + + + +/* L03_ʽ· */ +/* +* ʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetBlocRouteSwitchCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 chConnetCheckFunc = 0U; + + chConnetCheckFunc = GetCiFunctionSwitchConfig(FUNC_SETROUTE_CONNECT_CHECK); /*ȡǷҪĿ*/ + + /* ߼ */ + + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchYLockCheck(routeId,&devId, &devState); + if (CI_SUCCESS == checkResult ) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_YLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchFLockCheck(routeId,&devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteReltProtSwitchFLockCheck(routeId,&devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SWITCH,devId,ETYPE_SWT_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + checkResult = RouteAllLtrlDfncSwitchCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == chConnetCheckFunc) + { + ; /*ش򿪣*/ + } + else + { + /*·豸*/ + checkResult = RouteContactLineDevSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + if (CI_SUCCESS == reResult) + { + /*·еλȷλòȷɶ*/ + devId = 0u; + devState = 0u; + + checkResult = RouteSwitchPosAndMoveValidCheck(routeId,sendLevel); + + if ((CI_SUCCESS == checkResult) || (RETURN_LOCK_ERR_WAIT_SWCHECK == checkResult)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /*do nothing*/ + } + + + if(CI_SUCCESS == reResult) + {/*·*/ + /*·δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchYLockCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·λȷλòȷɶ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelProSwiPosAndMovValCheck(routeId,sendLevel); + if ((CI_SUCCESS == checkResult) || (RETURN_LOCK_ERR_WAIT_SWCHECK == checkResult)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ؽ */ + return reResult; +} + +/* L04_Cbtc· */ +/* +* Cbtc· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetCbtcRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 funcSwitch = 0u; /*ܿ*/ + UINT8 CiFunctionJLock = 0u; /*ǷԾձ־*/ + UINT8 cRcWorkMode = 0u; + + /* RCģʽ */ + cRcWorkMode = GetLocalRcWorkMode(); + + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + + +/* ·豸 */ + + + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + +#if 1 + /* ·ڵһ߼ռ״̬С*/ + if (CI_SUCCESS == reResult) + { + if (RC_WORK_MODE_CI == cRcWorkMode) + { + devId = GetRouteInFirstLogSecId(routeId); + devState = GetLogSecCurOccupyState(devId); + if (devState == SECTION_OCCUPY_NO) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else if(RC_WORK_MODE_TIOC == cRcWorkMode) + { + ;/* */ + } + else + { + reResult = CI_ERROR; + } + } +#endif + /* ·״̬δա + ͬġա + (ͬġա ͬġʱաս·Ϊг·ARBҷһ) + */ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221005 ·ǰ⶯*/ + checkResult = RouteCbtcLogSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + checkResult = RouteCbtcSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /* ·߼Ρδ߼ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIncLogSecLogicLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + {/*cgh-ϲCID-2349-1*/ + devId = 0u; + devState = 0u; + CiFunctionJLock = GetCiFunctionSwitchConfig(FUNC_CBTC_CHECK_JUMPLOCK_FLAG); + if (FUNC_SWITCH_OFF == CiFunctionJLock) + { + reResult = CI_SUCCESS; + } + else + { + checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_JUMP_LOCK, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /* ·ڵһλ߼δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* L05_· */ +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetLeadRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 checkSecFlockFlag = 0u; /*Ƿη*/ + UINT8 funcSwitch = 0u; /*ܿ*/ + + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG); + + +/* ߼ */ + if(NON_CHECK_SECFLOCK == checkSecFlockFlag) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { /* ·δ */ + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ȫ״̬δա + ȫΪͬġա + ȫΪͬġա||δա20220804޸Ľ·ηգοУ·*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221007 ·ǰ⶯*/ + checkResult = LeadRouteLogSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NO, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_NORMAL, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + devId = 0u; + devState = 0u; + checkResult = LeadRouteSecLockStateCheck(routeId, PHYSICAL_SECTION_LOCK_PROTECT, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + } + } + + /* ·߼Ρδ߼ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIncLogSecLogicLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·*/ +#if 0 + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ڵһλ߼δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* ʽ۷·ź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocReturnRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 endSigId = 0u; /*ȡ;۷źŻID*/ + UINT8 endSigState = 0u; /*նźŻ״̬ */ + + +/* ·豸 */ + /* ʼźŻId */ + UINT16 const startSignalId = GetRouteStartSignalId(routeId); + UINT8 flag = 0u; + /* ߼ */ + + /* ·ʼźŻɫΪơ*/ + devState = GetSignalCurColor(startSignalId); + if (devState == SIGNAL_SHOWCOLOUR_RED) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + flag = 1u; + } + if (1u == flag) + { + } + else + { + /*·źŻδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + flag = 1u; + } + if (1u == flag) + { + } + else + { + /* ·նźŻδ*/ + endSigId = GetRouteEndSignalId(routeId); /*ȡ;۷źŻID*/ + endSigState = GetSignalOpenCloseState(GetSignalCurColor(endSigId)); + if (endSigState == SIGNAL_CLOSE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,endSigId,ETYPE_SIG_RETURN_DS_STATE,endSigState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + flag = 1u; + } + if (1u == flag) + { + } + else + { + /*·ĵж*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ENEMY_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + } + /* ؽ */ + return reResult; +} + +/* L08_ʽ·ź */ +/* +* ʽ·ź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + UINT8 ciType = 0u; + UINT8 cPhySecCurMergeState = 0U; /*ںռѹ״̬*/ + + UINT8 routeState = 0u; + UINT8 chDsnFuncSwitch = 0U; /* ֱռùܿ */ + UINT8 chXianSuFuncSwitch = 0U; /*ģʽźſǷʱٿ*/ + + chDsnFuncSwitch = GetCiFunctionSwitchConfig(FUNC_TOA_SWITCH); + chXianSuFuncSwitch = GetCiFunctionSwitchConfig(FUNC_XIANSU_SWITCH); + + ciType = GetCiType(LocalCiId); + + /* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + startSignalId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &cPhySecCurMergeState); + routeState = GetRouteState(routeId); + if ((CI_TYPE_CLD == ciType) && ((ROUTE_STATE_YUXIAN_OPEN == routeState) ||(ROUTE_STATE_NEAR_OPEN == routeState))) + {/*ν·ԤȿŻӽ*/ + reResult = CLDKeepOpenSecCheck(routeId,functionId,sendLevel); + } + else + { + if ((SIGNAL_CROSS_STATE_NO == GetSignalCrossState(startSignalId)) && (CI_SUCCESS == checkResult)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + if (FUNC_SWITCH_ON != chDsnFuncSwitch) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, cPhySecCurMergeState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + checkResult = RouteAllSecColOccuClearCheck(routeId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + checkResult = RouteFaultOccuCheck(routeId, &devId, &devState); + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, cPhySecCurMergeState, sendLevel); /*޸ȱYF8803-1019,RouteFaultOccuCheckм鲻devState״̬Ϊ0ռ״̬*/ + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + } + } + /* ·״̬ա*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬*/ + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == chXianSuFuncSwitch) + {/*ģʽźſǷʱٿش*/ + + devId = 0u; + devState = 0u; + checkResult = RouteAllLgcSecXianSuCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_XIANSU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ܿعر, */ + } + + } + /* ؽ */ + return reResult; +} + + +/* +* εʽ·ź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CLDKeepOpenSecCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + + UINT16 routeInFirstLogSecId = 0u;/*·ڷһ߼Id*/ + UINT8 routeInFirstLogSecState = 0u;/*·ڷһ߼ռ״̬*/ + + UINT16 routeOutLastLogSecId = 0u;/*·ⷽһ߼Id*/ + UINT8 routeOutLastLogSecState = 0u;/*·ⷽһ߼ռ״̬*/ + + + UINT8 crossState = 0u;/*ѹ״̬*/ + UINT16 ii = 0u;/**/ + UINT16 phyId = 0u;/*ID*/ + UINT16 phyOccupyFlag = 0u;/*ռñ־*/ + UINT8 hasUtFlag = 0u;/*UTռ*/ + UINT8 hasCtFlag = 0u;/*CTռ*/ + + UINT8 sigConfigCross = 0u;/*Ƿ˿ѹλ*/ + + UINT32 curCycle = 0u;/*ǰں*/ + + RoutePhysicalSectionStruct* pRoutePhySecData = NULL;/*·*/ + UINT16 routePhyNum = 0u; + UINT8 chFunRet = CI_ERROR; + UINT8 chTrainEnterState = 0U; + UINT8 chReadyEnterRouteTrainSum = 0U; + UINT16 wszReadyEtRouteTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + UINT8 rcWorkMode = GetLocalRcWorkMode(); + + pRoutePhySecData = GetRouteSectionData(routeId); + routePhyNum = GetRoutePhysicalSectionSum(routeId); + curCycle = Get2oo2CurCycleNum(); + devId = 0u; + devState = 0u; + startSignalId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + + sigConfigCross = (UINT8)GetSigConfZcCiSignalCrossMask(startSignalId);/*ǷźŻѹλ*/ + + routeInFirstLogSecId = GetRouteInFirstLogSecId(routeId);/*ȡ·ڷһ߼Id*/ + routeInFirstLogSecState = GetLogSecCurCtOrUtOccupyState(routeInFirstLogSecId);/*ȡ·ڷһ߼ռ״̬*/ + + routeOutLastLogSecId = GetSignalOutFirstLogSec(startSignalId); + routeOutLastLogSecState = GetLogSecCurCtOrUtOccupyState(routeOutLastLogSecId);/*ȡ·ⷽһ߼ռ״̬*/ + crossState = GetSignalCrossState(startSignalId); + + if (SIGNAL_CROSS_STATE_NO == crossState) + { + /*δѹ*/ + checkResult = RouteAllSecOccuClearCheck(routeId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /*ȫ,ͨ飬ź*/ + reResult = CI_SUCCESS; + } + else + { + /*·ΣUTռãźűʧ*/ + /*·ΣCTҵһ߼κⷽһһ߼CTռãźűֳɹʧ*/ + hasUtFlag = 0u; + hasCtFlag = 0u; + for (ii = 0u; ii < routePhyNum; ii++) + { + phyId = pRoutePhySecData[ii].PhysicalSectionId; + phyOccupyFlag = GetPhySecPreOccState(phyId); + if (LOGICSECTION_OCCUPY_UT == phyOccupyFlag) + { + hasUtFlag = 1u; + } + else if (LOGICSECTION_OCCUPY_CT == phyOccupyFlag) + { + hasCtFlag = 1u; + } + else + { + /*ûCT UTռ*/ + } + } + + debug_infor_printf((const)"\r\ncurCycle:%d, RouteId:%d, hasUtFlag:%d, hasCtFlag:%d,startSignalId:%d, sigConfigCross:%d \r\n", curCycle, routeId, hasUtFlag, hasCtFlag, startSignalId, sigConfigCross); + + debug_infor_printf((const)"\r\ncurCycle:%d, RouteId:%d, routeInFirstLogSecId:%d, routeInFirstLogSecState:%d,routeOutLastLogSecId:%d, routeOutLastLogSecState:%d \r\n", + curCycle, routeId, routeInFirstLogSecId, routeInFirstLogSecState, + routeOutLastLogSecId, routeOutLastLogSecState); + + if (1u == hasUtFlag) + { + /*źűʧ*/ + reResult = CI_ERROR; + SetErrorData(functionId, + CI_DEVICE_TYPE_PHYSEC, devId, + ETYPE_PS_MERGY_OCU_STATE, devState, + sendLevel); + } + else if ((0u == hasUtFlag) && (1u == hasCtFlag)) + { + if (RC_WORK_MODE_TIOC == rcWorkMode) + { + /*RCģʽ£ҪгλжϿѹ*/ + chFunRet = GetRouteInOutFstLgcTrainInfo(routeId, &chReadyEnterRouteTrainSum, wszReadyEtRouteTrainId); + if (CI_SUCCESS == chFunRet) + { + chTrainEnterState = dsuTrainMinHeadCrossSignal(wszReadyEtRouteTrainId[0], routeId); + if (TRAIN_ENTER_ROUTE_FULL == chTrainEnterState) + { + /*гȫʻ·ص by cgh 20231128*/ + reResult = CI_ERROR; + } + else if (TRAIN_ENTER_ROUTE_HEAD == chTrainEnterState) + { + /*гʻ·δѹص */ + reResult = CI_SUCCESS; + } + else if (TRAIN_ENTER_ROUTE_CROSS == chTrainEnterState) + { + /*гѹźŻжϵһ߼ռѹ״̬*/ + + if (LOGICSECTION_OCCUPY_NO == routeInFirstLogSecState) + {/*һ߼ں״̬δռѹصƣȴռѹ */ + reResult = CI_SUCCESS; + } + else + {/*һ߼ں״̬ռѹ ص*/ + reResult = CI_ERROR; + } + } + else if ((TRAIN_ENTER_ROUTE_NO == chTrainEnterState) + || (CI_ERROR == chTrainEnterState) + || (TRAIN_ENTER_ROUTE_TAIL == chTrainEnterState)) + { + /*гʻгδߣгδѹ*/ + reResult = CI_SUCCESS; + } + else + { + + reResult = CI_ERROR; + } + + if ((LOGICSECTION_OCCUPY_CT == routeInFirstLogSecState) && + (LOGICSECTION_OCCUPY_CT == routeOutLastLogSecState)) + { + /*ֵǰ״̬*/ + } + else + { + reResult = CI_ERROR; /*ʧܣVBTC1ڽ·ⷽһVBTC2ǰ·ڷһ߼ʱ·δź*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); /*޸ȱYF0083-2282ռñID*/ + } + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + } + /*CTռãһ߼CTռãⷽһһ߼CTռã˿ѹλ򱣳ֳɹʧ*/ + else + { + if (SIGNAL_CONFIG_CROSS_MASK_YES == sigConfigCross) + {/*˿ѹλȿѹŹص*/ + if ((LOGICSECTION_OCCUPY_CT == routeInFirstLogSecState) && + (LOGICSECTION_OCCUPY_CT == routeOutLastLogSecState)) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + } + else + {/*ûÿѹλ*/ + /*·CTռþ͹ص*/ + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + } + } + } + else + { + /*ûռãźűֳɹ*/ + reResult = CI_SUCCESS; + } + } + } + else + { + /*ѹźűʧ*/ + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, startSignalId, ETYPE_SIG_CROSS, crossState, sendLevel); + } + + return reResult; +} + +/* L15_Cbtc·źſ */ +/* +* Cbtc·źſ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenCbtcRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 CiFunctionJLock = 0u; /*ǷԾձ־*/ + UINT8 rcWorkMode = GetLocalRcWorkMode(); + UINT8 cLocalCiType = 0U; /**/ + +/* ·豸 */ + /*źŻ*/ + UINT16 startSignalId = 0u; + UINT8 signalCrossState = 0u; + + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*CBTC·ڷһ߼飬ν·ڷο*/ + if (CI_SUCCESS == reResult) + { + cLocalCiType = GetLocalCiType(); + if (CI_TYPE_CLD != cLocalCiType) + { + /*dzΣCBTC߼*/ + if (RC_WORK_MODE_TIOC == rcWorkMode) + {/*TIOC*/ + + /*CBTC·ڷһ߼*/ + reResult = RouteCbtcFirstLgcSecCheck(routeId, &devId, &devState); + if (CI_SUCCESS == reResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else if (RC_WORK_MODE_CI == rcWorkMode) + {/*CI*/ + + /* ·ʼźŻδѹڷһ߼ΡС*/ + startSignalId = GetRouteStartSignalId(routeId); + devId = GetRouteInFirstLogSecId(routeId); + devState = GetLogSecCurOccupyState(devId); + signalCrossState = GetSignalCrossState(startSignalId); + if (SIGNAL_CROSS_STATE_NO == signalCrossState) + { + if (devState == SECTION_OCCUPY_NO) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + /* ʧ */ + reResult = CI_ERROR; + } + + } + else + { + reResult = CheckEngineerVehicleNear(routeId);/*Ƿǹ̳ӽĿѹ*/ + if (CI_SUCCESS == reResult) + { + /**/ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + /* ʧ */ + reResult = CI_ERROR; + } + } + } + else + { + reResult = CI_ERROR;/*ģʽ󷵻ʧ*/ + } + } + else + { + /*Σ·׷٣·ڷο*/ + reResult = CLDKeepOpenSecCheck(routeId, functionId, sendLevel); + } + } + /* ·״̬ա*/ + if(CI_SUCCESS == reResult) + { + + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#if 1 + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + CiFunctionJLock = GetCiFunctionSwitchConfig(FUNC_CBTC_CHECK_JUMPLOCK_FLAG); + if (FUNC_SWITCH_OFF == CiFunctionJLock) + { + reResult = CI_SUCCESS; + } + else + { + checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_JUMP_LOCK, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + else + { + ; /**/ + } + +#endif + /* ؽ */ + return reResult; +} + +/* L16_·źſ */ +/* +* ·źſ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLeadRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 checkSecFlockFlag = 0u; /*Ƿη*/ + checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG); +/* ·豸 */ + + if(NON_CHECK_SECFLOCK == checkSecFlockFlag) + { + /* ߼ */ + reResult = CI_SUCCESS; + } + else + { + /* ·δ */ + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /*·*/ +#if 0 + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ؽ */ + return reResult; +} + +/* L17_Cbtc·źű */ +/* +* Cbtc·źű +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +* mod by qw.liu ޸ CBTC±źŵһ߼μ +*/ +UINT8 KeepCbtcRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 CiFunctionJLock = 0u; /*ǷԾձ־*/ + UINT8 rcWorkMode = GetLocalRcWorkMode(); + +/* ·豸 */ + /*źŻ*/ + UINT16 startSignalId = 0u; + UINT8 signalCrossState = 0u; + UINT8 preLogDevState = 0u; /*֮ǰ߼ռ״̬*/ + UINT8 LogSecCurCtOrUtOcc = 0U; + UINT16 outPhySecId = 0U; /*·ⷽһ*/ + UINT8 outPhySecState = 0U; + UINT8 cLocalCiType = 0U; /**/ + +/* ߼ */ + + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*CBTC·ڷһ߼*/ + if(CI_SUCCESS == reResult) + { + cLocalCiType = GetLocalCiType(); + if (CI_TYPE_CLD != cLocalCiType) + { + /*dzΣCBTC߼*/ + if (RC_WORK_MODE_TIOC == rcWorkMode) + {/*TIOC*/ + + /*CBTC·ڷһ߼*/ + reResult = RouteCbtcFirstLgcSecCheck(routeId, &devId, &devState); + if (CI_SUCCESS == reResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else if (RC_WORK_MODE_CI == rcWorkMode) + {/*CI*/ + + /* ·ʼźŻδѹ ǣ·ⷽΡСڷһ߼Ρռá*/ + startSignalId = GetRouteStartSignalId(routeId); + devId = GetRouteInFirstLogSecId(routeId); + devState = GetLogSecCurOccupyState(devId); + LogSecCurCtOrUtOcc = GetLogSecCurCtOrUtOccupyState(devId); + preLogDevState = GetLogSecPreCtOrUtOccupyState(devId); + signalCrossState = GetSignalCrossState(startSignalId); + if (SIGNAL_CROSS_STATE_NO == signalCrossState) + { + if (!((SECTION_OCCUPY_NO == devState) && (LOGICSECTION_OCCUPY_CT == preLogDevState))) + { /*ǣڷһ߼εǰС֮ǰռCT˵Ѿһ߼ΣֻҪδһ߼Σȿѹ*/ + if (LOGICSECTION_OCCUPY_UT != LogSecCurCtOrUtOcc) + { + /*ֻеΪCTռѹͿʱֹUT쳣ռѹ ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, LogSecCurCtOrUtOcc, sendLevel); + reResult = CI_ERROR; /*UTռѹ쳣*/ + } + + } + else + { + outPhySecId = GetSignalOutFirstPhySecId(startSignalId); /*źŻⷽһID*/ + outPhySecState = GetPhySecCurMergeState(outPhySecId); + /*·ⷽһδռ״̬رź(CTг׷٣ǰʻʱֶδ·룬ɵһ쳣壬źŻرյij)*/ + if (SECTION_OCCUPY_YES == outPhySecState) + { + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + } + } + else + { + reResult = CheckEngineerVehicleNear(routeId);/*Ƿǹ̳ӽĿѹԼгʵѹ*/ + if (CI_SUCCESS == reResult) + { + /**/ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + /* ʧ */ + reResult = CI_ERROR; + } + } + } + else + { + reResult = CI_ERROR;/*ģʽ󷵻ʧ*/ + } + } + else + { + /*Σ·׷٣·ڷο*/ + reResult = CLDKeepOpenSecCheck(routeId, functionId, sendLevel); + } + } + + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#if 1 + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + CiFunctionJLock = GetCiFunctionSwitchConfig(FUNC_CBTC_CHECK_JUMPLOCK_FLAG); + if (FUNC_SWITCH_OFF == CiFunctionJLock) + { + reResult = CI_SUCCESS; + } + else + { + checkResult = RouteAllSecJumpLockStateCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_JUMP_LOCK, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + else + { + ; /**/ + } + +#endif + + /* ؽ */ + return reResult; +} + + +/* L04_ʽ· */ +/* +* ģʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 BlocRouteFloodGateCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + + UINT16 devId = 0u; /*豸ID*/ + + UINT16 floodSum = 0u; + UINT16 *pFloodIdBuf = NULL;/*ʱ·idָ*/ + + + UINT16 ii=0u; + + UINT16 floodGateId = 0u;/*ʱid*/ + UINT8 floodState = 0u;/*״̬*/ + + /*0.ȡ·*/ + floodSum = GetRouteFloodGateSum(routeId); + pFloodIdBuf = GetRouteFloodGateBuf(routeId); + + if (NULL == pFloodIdBuf) + { + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + if (CI_SUCCESS == reResult) + { + for (ii =0u;ii 0u) + { + + /*1ſ״̬Ϊ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurOpenLockState(floodGateId); + if (FLOOD_GATE_OPENLOCK == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId,CI_DEVICE_TYPE_FLOODGATE,floodGateId,ETYPE_FLOODGATE_OPENLOCKSTATE,floodState,sendLevel); + break; + } + } + + + + /*2Ź״̬Ϊδ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurCloseRequestSta(floodGateId); + if (FLOOD_GATE_NOT_CLOSEREQ == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId,CI_DEVICE_TYPE_FLOODGATE,floodGateId,ETYPE_FLOODGATE_CLOSEREQSTATE,floodState,sendLevel); + break; + } + } + + /*3ŵǰͬ״̬Ϊͬ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurAgreeCloseSta(floodGateId); + if (FLOOD_GATE_NOT_AGREE_CLOSE == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId,CI_DEVICE_TYPE_FLOODGATE,floodGateId,ETYPE_FLOODGATE_AGREECLOSESTATE,floodState,sendLevel); + break; + } + } + } + else + { + reResult = CI_ERROR; + break; + } + + + } + } + + return reResult; +} + + + + +/* L04_CBTC· */ +/* +* ģʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CBTCRouteFloodGateCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + + UINT16 devId = 0u; /*豸ID*/ + + UINT16 floodSum = 0u; + UINT16 *pFloodIdBuf = NULL;/*ʱ·idָ*/ + + + UINT16 ii=0u; + + UINT16 floodGateId = 0u;/*ʱid*/ + UINT8 floodState = 0u;/*״̬*/ + + /*0.ȡ·*/ + floodSum = GetRouteFloodGateSum(routeId); + pFloodIdBuf = GetRouteFloodGateBuf(routeId); + + if (NULL == pFloodIdBuf) + { + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + if (CI_SUCCESS == reResult) + { + for (ii =0u;ii 0u) + { + + /*1ſ״̬Ϊ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurOpenLockState(floodGateId); + if (FLOOD_GATE_OPENLOCK == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId,CI_DEVICE_TYPE_FLOODGATE,floodGateId,ETYPE_FLOODGATE_OPENLOCKSTATE,floodState,sendLevel); + break; + } + } + + + + /*2Ź״̬Ϊδ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurCloseRequestSta(floodGateId); + if (FLOOD_GATE_NOT_CLOSEREQ == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId,CI_DEVICE_TYPE_FLOODGATE,floodGateId,ETYPE_FLOODGATE_CLOSEREQSTATE,floodState,sendLevel); + break; + } + } + + /*3ŵǰͬ״̬Ϊͬ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurAgreeCloseSta(floodGateId); + if (FLOOD_GATE_NOT_AGREE_CLOSE == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId,CI_DEVICE_TYPE_FLOODGATE,floodGateId,ETYPE_FLOODGATE_AGREECLOSESTATE,floodState,sendLevel); + break; + } + } + + } + else + { + reResult = CI_ERROR; + break; + } + + } + } + + return reResult; +} + + +/* +* ȡԶź +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +void CancleAutoSigCmdProcc(const UINT16 routeId) +{ + /*ʼ*/ + UINT8 autoSigCmdFlag = 0u; + UINT8 cancleRouteState = 0u; + + autoSigCmdFlag = GetCancleAutoSigCmdFlag(routeId); + /*ȡԶźЧ*/ + if(AUTO_ROUTE_CANCLE_CMD_YES == autoSigCmdFlag) + { + /*ȡ*/ + cancleRouteState = AutoSigRouteQuXiaoProc(routeId); + if(RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT == cancleRouteState) + { + /*ȡȴ״̬*/ + SetAutoSigCancleState(routeId,AUTO_ROUTE_CANCLE_WAIT); + } + else if(CI_SUCCESS == cancleRouteState) + { + /*ȡɹ״̬*/ + SetAutoSigCancleState(routeId,AUTO_ROUTE_CANCLE_SUCCESS); + /*Ч*/ + SetCancleAutoSigCmdFlag(routeId,AUTO_ROUTE_CANCLE_CMD_NO); + } + else + { + /*ȡʧ״̬*/ + SetAutoSigCancleState(routeId,AUTO_ROUTE_CANCLE_FAIL); + /*Ч*/ + SetCancleAutoSigCmdFlag(routeId,AUTO_ROUTE_CANCLE_CMD_NO); + } + } + else + { + /*ȡЧ״̬*/ + SetAutoSigCancleState(routeId,AUTO_ROUTE_CANCLE_NO); + } +} + + + +/* +* γ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 BlocOverlapOccClearProc(const UINT16 routeId) +{ + + UINT8 rtVal = CI_ERROR; + UINT8 checkResult = CI_ERROR; + UINT16 devId = 0u; + UINT8 devState = 0u; + + /* ·豸 */ + /*·*/ + UINT8 const overlapSum = GetRouteOverlapSum(routeId); + UINT16 const overlapId = GetRouteOverlapLockedId(routeId); + + if (overlapSum > 0u) + { + if (overlapId > 0U) + {/**/ + devId = 0u; + devState = 0u; + checkResult = OpenBlockOvlpAllSecOccuClrCheck(overlapId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /*գûռãͨ */ + rtVal = CI_SUCCESS; + } + else + { + /*ռãرռ*/ + rtVal = CI_ERROR; + } + } + } + else + {/*ûб,سɹ*/ + rtVal = CI_SUCCESS; + } + + return rtVal; +} + +/* +* ·һ߼ν +* ˵ const UINT16 routeId, ·ID +* +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* CI_CANCLE_ZHAOCHA_FAIL ղʧ +* RETURN_AUTOLOCK_ERR_EXCEPT ʧ +*/ +UINT8 RouteLogSecAutoUnlockProcess(UINT16 const routeId, UINT16* logSectionId) +{ + /*ʼ*/ + UINT8 const functionId = EFUNC_ROUTE_FIRST_LOG_UNLOCK; + UINT16 nlockLogId = 0u; + UINT16 nextLogId = 0u; /*һ߼*/ + UINT16 cancleZhaoChaRelayId = 0u; /*ȡղ̵ID*/ + UINT8 relayState = 0u; /*̵ɼ״̬*/ + UINT8 logCurOccupyState = 0u; + UINT8 logPreOccupyState = 0u; + UINT16 routeLeavePhyId = 0u; + UINT8 leavePhyCurOccState = 0u; + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + UINT8 chRouteLevel = 0U; + + /*һڵǰ·߼*/ + nlockLogId = GetRouteFirstNormalLockLogId(routeId); + + /*ҵ·һ߼*/ + if(0u < nlockLogId) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + *logSectionId = 0u; + } + /*ռ*/ + if(CI_SUCCESS == reResult) + { + /*ȡռϢ*/ + logCurOccupyState = GetLogSecCurCtOrUtOccupyState(nlockLogId); + logPreOccupyState = GetLogSecPreCtOrUtOccupyState(nlockLogId); + /*ǰεǰ֮ǰCTռ*/ + if((LOGICSECTION_OCCUPY_NO == logCurOccupyState) && (LOGICSECTION_OCCUPY_CT == logPreOccupyState)) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + *logSectionId = nlockLogId; + } + /*·ڷһռñʱẈ̂ȡղ̵()״̬*/ + if(CI_SUCCESS == reResult) + { + chRouteLevel = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(routeId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + if(RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_RELAY,cancleZhaoChaRelayId,ETYPE_CANCLE_ZHAOCHA,relayState,sendLevel); + /* ʧܷȡղʧ */ + reResult = CI_CANCLE_ZHAOCHA_FAIL; + *logSectionId = nlockLogId; + } + + } + } + /*һ߼ռ״̬*/ + if(CI_SUCCESS == reResult) + { + /*ȡһ߼*/ + nextLogId = GetRouteNextLogSecId(routeId,nlockLogId); + if(0u != nextLogId) + { + /*ʹȣ˵ǽ·һ߼*/ + if(nlockLogId == nextLogId) + { + /*ȡ·ȥ*/ + routeLeavePhyId = GetRouteLeavePhySecId(routeId); + leavePhyCurOccState = GetPhySecCurMergeState(routeLeavePhyId); + /*ȥռ*/ + if(SECTION_OCCUPY_YES == leavePhyCurOccState) + { + /*سɹ*/ + reResult = CI_SUCCESS; + *logSectionId = nlockLogId; + } + /*ɳ*/ + else + { + /* ʧܷδʼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,routeLeavePhyId,ETYPE_PS_AUNLOCK_ERROR,leavePhyCurOccState,sendLevel); + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *logSectionId = nlockLogId; + } + } + /*ǽ·һ߼*/ + else + { + logCurOccupyState = GetLogSecCurOccupyState(nextLogId); + /*һ߼ռ*/ + if(SECTION_OCCUPY_YES == logCurOccupyState) + { + /*سɹ*/ + reResult = CI_SUCCESS; + *logSectionId = nlockLogId; + } + else + { + /* ʧܷδʼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_LOGICSEC,nextLogId,ETYPE_PS_AUNLOCK_ERROR,logCurOccupyState,sendLevel); + reResult = RETURN_AUTOLOCK_ERR_EXCEPT; + *logSectionId = nlockLogId; + } + } + } + } + } + return(reResult); +} + + +/* +* ·߼ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LogSecDelayUnlockProc(const UINT16 routeId) +{ + /*ʼ*/ + UINT16 logSectionId = 0u; /*߼ID*/ + UINT16 nextLogId = 0u; /*һ߼ID*/ + UINT8 logLockState = 0u; /*߼״̬*/ + UINT8 returnValue = 0u; /*ֵ*/ + UINT8 logUlockState = 0u; /*߼ν״̬*/ + UINT8 routeFlag = 0u; + UINT32 cycNum = 0u; + UINT8 checkValue = 0u; + UINT16 logBelongPhyId = 0u; + UINT16 logRoute = 0u; + UINT8 routeDir = 0u; + UINT16 routeLastSwiPhySecId = 0u; + + /*Ϣȡ*/ + routeDir = GetRouteDirection(routeId); + cycNum = Get2oo2CurCycleNum(); + /*߼ʱ*/ + returnValue = LogSecDelayUnlockProcess(routeId, &logSectionId); + /*ûʱ߼*/ + if(0u == logSectionId) + { + /**/ + } + else + { + /*߼ʱɹ*/ + if(CI_SUCCESS == returnValue) + { + /*߼δ*/ + SetLogSecLockState(logSectionId,LOG_SECTION_LOCK_NO,routeId,routeDir); + /*ȡ߼*/ + logBelongPhyId = GetLgcSecRelativePhySecId(logSectionId); + checkValue = CheckPhyInLogUlock(logBelongPhyId,routeId,&logRoute); + /*ڱ·յ߼ȫ*/ + if(CI_SUCCESS == checkValue) + { + routeLastSwiPhySecId = GetRouteLastSwichPhySecId(routeId); + /**/ + if(routeLastSwiPhySecId == logBelongPhyId) + { + /*·յ*/ + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_CANCEL); + } + /*߼ȫҲ߼·*/ + if(0u == logRoute) + { + /*ν*/ + SetPhySecLockState(logBelongPhyId, PHYSICAL_SECTION_LOCK_NO, routeId, routeDir); + } + } + /*·߼ȫ*/ + logUlockState = CheckRouteLogSecHaveUnLock(routeId); + if(CI_SUCCESS == logUlockState) + { + /*·ȫ*/ + routeFlag = GetRouteStateFlag(routeId); + if (ROUTE_STATE_FLAG_YES == routeFlag) + {/*CBTC׷ٰ·־Ч򲻸ı·״̬Զʱ·ȫ*/ + } + else + {/*CBTC׷ٰ·־Чý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + } + else + { + /*ȡһ߼״̬*/ + nextLogId = GetRouteNextLogSecId(routeId,logSectionId); + logLockState = GetLogSecLockState(nextLogId); + /*һ,ʱ״̬*/ + if((0u < nextLogId) && (logSectionId != nextLogId) + && (LOG_SECTION_LOCK_DELAY == logLockState)) + { + /*һ߼ʱʱ*/ + SetLogUnlockStartCycNum(nextLogId,cycNum); + } + else + { + /**/ + } + } + } + /*ʱδ*/ + else if(RETURN_DELAYUNLOCK_ERR_TIMECOUNT == returnValue) + { + /**/ + } + /*ʧ*/ + else + { + /*ʱʼ*/ + SetLogUnlockStartCycNum(logSectionId,cycNum); + } + } +} + + +/* +* ʱ +* ˵ UINT16 const routeId· +* UINT16* phySectionIdID +* ֵ CI_ERROR +* RETURN_DELAYUNLOCK_ERR_TIMECOUNT +* CI_SUCCESS +*/ +UINT8 LogSecDelayUnlockProcess(UINT16 const routeId, UINT16* logSectionId) +{ + /*ʼ*/ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT32 cycNum = 0u; + UINT32 cycNumSysPara = 0u;/*ϵͳʱ*/ + UINT8 routeTimeState = 0u; + UINT16 dlockLogId = 0u; + UINT8 logOccState = 0u; /*߼ռ״̬*/ + + + /*һʱʱ*/ + dlockLogId = GetRouteFirstDelayLockLogId(routeId); + logOccState = GetLogSecCurOccupyState(dlockLogId); + /*ȡ*/ + cycNum = GetLogUnlockStartCycNum(dlockLogId); + cycNumSysPara = GetSystemParaSecDelayUnlockCyc(); + /* ʱʱ״̬*/ + routeTimeState = SystemOverTimeCheck(cycNum, cycNumSysPara); + + /*·һΡʱաڵǰ·*/ + if (dlockLogId > 0U) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + /*ID = 0*/ + *logSectionId = 0; + + } + if(CI_SUCCESS == reResult) + { + /*ο*/ + if(SECTION_OCCUPY_NO == logOccState) + { + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + /* ʱ */ + *logSectionId = dlockLogId; + + } + } + if(CI_SUCCESS == reResult) + { + /*δʱ*/ + if (CI_TIME_NO == routeTimeState) + { + /* ʧܷ */ + reResult = CI_ERROR; + /* ʱ */ + *logSectionId = dlockLogId; + } + /*ʱ*/ + else if(CI_TIME_IN == routeTimeState) + { + /*ʱδ*/ + /* ʧܷ */ + reResult = RETURN_DELAYUNLOCK_ERR_TIMECOUNT; + /* ʱ */ + *logSectionId = dlockLogId; + } + /*ʱ*/ + else + { + /* ʱ䵽ʱ */ + reResult = CI_SUCCESS; + *logSectionId = dlockLogId; + } + } + return(reResult); +} + +/* +* ·߼Դг +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLgcSecResUnlockProcess(const UINT16 wRouteId) +{ + /*ʼ*/ + UINT8 chLgcCurOccupyState = 0u; + UINT16 ii = 0U; + UINT16 wBelongRouteId = 0U; + UINT16 wPreBelongRouteId = 0U; + UINT16 wRouteFirstLgcSecId = 0U; + UINT16 wUnlockLgcSecId = 0U; /*ǰ߼id*/ + UINT16 wPreUnlockLgcSecId = 0U; /*·߼һ߼*/ + UINT8 chLgcLockState = 0U; + UINT8 chPreLgcLockState = 0U; + UINT8 chLgcResTrainSum = 0U; + UINT8 chLogSecReleaseFlag = 0U; + UINT8 chKeepWork = CI_ERROR; + UINT16 wRelayZhaoCId = 0U; + UINT8 chRelayState = 0U; + UINT16 routeLogNum = 0u; + UINT16 wTrainId = 0U; + UINT8 chLogicTrainRetrunStt = 0U; + UINT16* routeLogIdBuf = NULL; + UINT8 cRouteState = 0U; + UINT8 chRouteLevel = 0U; + UINT8 chTrainLevel = 0U; + UINT8 chThreePointCheck = CI_ERROR; + UINT8 chLocalCi = 0U; + UINT8 chLogSecBelongCi = 0U; + + + /*ȡ·߼*/ + routeLogNum = GetRouteLogSectionSum(wRouteId); + routeLogIdBuf = GetRouteLogSectionIdBuf(wRouteId); + + + if ((0u < routeLogNum) + && (MAX_ROUTE_IN_LT_NUM > routeLogNum)) + { + chRouteLevel = GetRouteLevel(wRouteId); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + wRelayZhaoCId = GetRouteCancleZhaoChaRelayId(wRouteId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + wRelayZhaoCId = GetRouteCbtcCancelZhaochaRelay(wRouteId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if ((0u != wRelayZhaoCId) && (0xFFFFU != wRelayZhaoCId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + chRelayState = GetRelayCollState(wRelayZhaoCId);/*ȡȡ̵ɼ״̬*/ + if (RELAY_STATE_UP == chRelayState) + { + /* ͨ */ + chKeepWork = CI_SUCCESS; + } + else + { + + chKeepWork = CI_ERROR; + } + + } + else + { + /* ͨ */ + chKeepWork = CI_SUCCESS; + } + + /*ղ̵ͨʼ*/ + if (CI_SUCCESS == chKeepWork) + { + for (ii = 0u; ii < routeLogNum; ii++) + { + chKeepWork = CI_ERROR; + wPreUnlockLgcSecId = wUnlockLgcSecId; + wUnlockLgcSecId = routeLogIdBuf[ii]; + if (0U == wPreUnlockLgcSecId) + { + chKeepWork = CI_SUCCESS; + } + else + { + chPreLgcLockState = GetLogSecLockState(wPreUnlockLgcSecId); + wPreBelongRouteId = GetLogSecLockBelongRoute(wPreUnlockLgcSecId); + if (wPreBelongRouteId == wRouteId) + { + if ((LOG_SECTION_LOCK_NO == chPreLgcLockState) + || (LOG_SECTION_LOCK_PROTECT == chPreLgcLockState)) + { + chKeepWork = CI_SUCCESS; + } + else + { + chKeepWork = CI_ERROR; + } + } + else + { + /* һղԼ*/ + chKeepWork = CI_SUCCESS; + } + + + } + if (CI_SUCCESS == chKeepWork) + { + + wBelongRouteId = GetLogSecLockBelongRoute(wUnlockLgcSecId); + /*·ڱ·*/ + if (wBelongRouteId == wRouteId) + { + chLgcCurOccupyState = GetLogSecCurCtOrUtOccupyState(wUnlockLgcSecId); + if (LOGICSECTION_OCCUPY_NO == chLgcCurOccupyState) + { + chLgcLockState = GetLogSecLockState(wUnlockLgcSecId); + chLogSecReleaseFlag = GetLogSecReleaseFlag(wUnlockLgcSecId); + chLgcResTrainSum = GetLogSecTrainInfoSum(wUnlockLgcSecId); + + wTrainId = GetLogSecTrainIdByIndex(wUnlockLgcSecId, 0); + chLogicTrainRetrunStt = GetLogSecTrainReturnState(wUnlockLgcSecId, wTrainId); + } + else + { + chKeepWork = CI_ERROR; + } + + } + else + { + chKeepWork = CI_ERROR; + } + } + else + { + } +#if 0 + if (CI_SUCCESS == chKeepWork) + { + if (LOGIC_SECTION_TRAIN_RETURN_NO != chLogicTrainRetrunStt) + { + chKeepWork = CI_ERROR; + } + else + { + } + } + else + { + } +#endif + if (CI_SUCCESS == chKeepWork) + { + chLocalCi = GetSystemParaLocalCiId(); + chLogSecBelongCi = GetLogSecBelongCiId(wUnlockLgcSecId); + if (chLocalCi != chLogSecBelongCi) + { + /*ͷڿ*/ + chTrainLevel = GetLogSecReleaseTrainLevel(wUnlockLgcSecId, wTrainId); + } + else + { + /*ڱ ҪVBTCͷŽ*/ + chTrainLevel = GetTrainLevel(wTrainId); + } + if (TRAIN_LEVEL_VBTC == chTrainLevel) + { + chThreePointCheck = RouteLgcSecResUnlockNextSecCheck(wRouteId, wUnlockLgcSecId); + } + else + { + chThreePointCheck = CI_ERROR; + } + + /**/ + if (LOG_SECTION_LOCK_NORMAL == chLgcLockState) + { + cRouteState = GetRouteState(wRouteId); + /*߼гԴΪ1ұVBTC VBTCͷ*/ + if ((1U == chLgcResTrainSum) && (LOGIC_SECTION_TRAIN_UNLOCK_YES == chLogSecReleaseFlag) + && ((CI_SUCCESS == chThreePointCheck) || (ROUTE_STATE_HALF_UNLOCK == cRouteState))) + { + /*·״̬Ϊֽ·ȴʱг𣬽гλ۷Կ׻˻ᵼгVBTCʱͷԴԭ·߼޷*/ + LgcSecUnlockProc(wRouteId, wUnlockLgcSecId); + cRouteState = GetRouteState(wRouteId); /*߼ν¸½·״̬*/ + wRouteFirstLgcSecId = GetRouteInFirstLogSecId(wRouteId); + if ((wRouteFirstLgcSecId == wUnlockLgcSecId) && (ROUTE_STATE_NEAR_LOCK == cRouteState)) /*ȱYF0083-9222023-07-14*/ + { + SetRouteStateManage(wRouteId, ROUTE_STATE_AUTO_UNLOCK); + } + else + { + } + debug_infor_printf((const)"LogSecRes Unlock LgcId: %d TrainId:%d Cyc\n" + , wUnlockLgcSecId + , wTrainId + , Get2oo2CurCycleNum()); + } + else + { + } + } + + /*ʱ յ*/ + else if (LOG_SECTION_LOCK_DELAY == chLgcLockState) + { + /*߼гԴΪ1ұVBTC VBTCͷ*/ + if ((1U == chLgcResTrainSum) && (LOGIC_SECTION_TRAIN_UNLOCK_YES == chLogSecReleaseFlag) && (CI_SUCCESS == chThreePointCheck)) + { + LgcSecUnlockProc(wRouteId, wUnlockLgcSecId); + } + else + { + } + } + else + { + /*޲*/ + } + } + else + { + } + } + } + else + { + } + } + else + { + } +} + +/* +* ·߼ν +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LgcSecUnlockProc(const UINT16 routeId, const UINT16 logSectionId) +{ + /*ʼ*/ + UINT16 nextLogId = 0u; /*һ߼ID*/ + UINT8 logLockState = 0u; /*߼״̬*/ + UINT8 logUlockState = 0u; /*߼ν״̬*/ + UINT8 routeFlag = 0u; + UINT8 checkValue = 0u; + UINT16 logBelongPhyId = 0u; + UINT16 logRoute = 0u; + UINT8 routeDir = 0u; + UINT16 routeLastSwiPhySecId = 0u; + UINT32 cycNum = 0U; + + cycNum = Get2oo2CurCycleNum(); + + /*Ϣȡ*/ + routeDir = GetRouteDirection(routeId); + + /*߼δ*/ + SetLogSecLockState(logSectionId, LOG_SECTION_LOCK_NO, routeId, routeDir); + /*ȡ߼*/ + logBelongPhyId = GetLgcSecRelativePhySecId(logSectionId); + checkValue = CheckPhyInLogUlock(logBelongPhyId, routeId, &logRoute); + /*ڱ·յ߼ȫ*/ + if (CI_SUCCESS == checkValue) + { + routeLastSwiPhySecId = GetRouteLastSwichPhySecId(routeId); + /**/ + if (routeLastSwiPhySecId == logBelongPhyId) + { + /*·յ*/ + SetRouteRelProSwitchLockSta(routeId, SWITCH_LOCK_PROTECT_CANCEL); + } + /*ν*/ + SetPhySecLockState(logBelongPhyId, PHYSICAL_SECTION_LOCK_NO, routeId, routeDir); + } + /*·߼ȫ*/ + logUlockState = CheckRouteLogSecHaveUnLock(routeId); + if (CI_SUCCESS == logUlockState) + { + /*·ȫ*/ + routeFlag = GetRouteStateFlag(routeId); + if (ROUTE_STATE_FLAG_YES == routeFlag) + {/*CBTC׷ٰ·־Ч򲻸ı·״̬Զʱ·ȫ*/ + } + else + {/*CBTC׷ٰ·־Чý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*-->ý·*/ + } + } + else + { + /*ȡһ߼״̬*/ + nextLogId = GetRouteNextLogSecId(routeId, logSectionId); + logLockState = GetLogSecLockState(nextLogId); + /*һ,ʱ״̬*/ + if ((0u < nextLogId) && (logSectionId != nextLogId) + && (LOG_SECTION_LOCK_DELAY == logLockState)) + { + /*һ߼ʱʱ*/ + SetLogUnlockStartCycNum(nextLogId, cycNum); + } + else + { + /**/ + } + } +} + + +/* +* ·߼ԴгͷŴ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLgcSecResReleaseProcess(const UINT16 wRouteId) +{ + /*ʼ*/ + UINT16 ii = 0U; + UINT16 wTrainId = 0U; + UINT8 jj = 0U; + UINT16 wBelongRouteId = 0U; + UINT16 wUnlockLgcSecId = 0U; + UINT16 wPreUnlockLgcSecId = 0U; /*·߼һ߼*/ + UINT8 chLgcResTrainSum = 0U; + UINT8 chLogSecReleaseFlag = 0U; + UINT8 chKeepWork = CI_ERROR; + UINT16 routeLogNum = 0u; + UINT16 wLgcBufIndex = 0U; + UINT8 chNeedKeepSum = 0U; + UINT16* routeLogIdBuf = NULL; + LogicTrainResStruct * pstTrainResInfo = NULL; + LogicSectionDataStruct *pstLgcSecInfo = NULL; + /*ȡ·߼*/ + routeLogNum = GetRouteLogSectionSum(wRouteId); + routeLogIdBuf = GetRouteLogSectionIdBuf(wRouteId); + pstLgcSecInfo = GetLogicSecData(); + + if ((0u < routeLogNum) + && (MAX_ROUTE_IN_LT_NUM > routeLogNum) + &&(NULL!= pstLgcSecInfo)) + { + for (ii = 0u; ii < routeLogNum; ii++) + { + chKeepWork = CI_ERROR; + wPreUnlockLgcSecId = wUnlockLgcSecId; + wUnlockLgcSecId = routeLogIdBuf[ii]; + wBelongRouteId = GetLogSecLockBelongRoute(wUnlockLgcSecId); + wLgcBufIndex = GetlogSectionBufIndex(wUnlockLgcSecId); + + if (LOGIC_SECTION_SUM_MAX > wLgcBufIndex) + { + chKeepWork = CI_SUCCESS; + } + else + { + chKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == chKeepWork) + { + /*·ڱ·*/ + if (wBelongRouteId == wRouteId) + { + chLgcResTrainSum = GetLogSecTrainInfoSum(wUnlockLgcSecId); + if (LOGIC_SECTION_RES_SUM_MAX > chLgcResTrainSum) + { + ; /*ִ*/ + } + else + { + chKeepWork = CI_ERROR; + } + } + else + { + chKeepWork = CI_ERROR; + } + } + else + { + } + + + if (CI_SUCCESS == chKeepWork) + { + chNeedKeepSum = 0U; + for (jj = 0U; jj < chLgcResTrainSum; jj++) + { + wTrainId = GetLogSecTrainIdByIndex(wUnlockLgcSecId, jj); + + /*Ƿյг*/ + chLogSecReleaseFlag = GetLogSecTrainRelease(wUnlockLgcSecId, wTrainId); + + /*һǷѽ*/ + pstTrainResInfo = GetLogSecTrainInfoById(wPreUnlockLgcSecId, wTrainId); + if (((LOGIC_SECTION_TRAIN_UNLOCK_YES == chLogSecReleaseFlag)||(0U==wTrainId)) + && (NULL == pstTrainResInfo)) + { + /*ɾгӦ߼Դ*/ + (void)ComMemSet((void *)&pstLgcSecInfo[wLgcBufIndex].szTrainResData[jj], (UINT16)sizeof(LogicTrainResStruct), 0U); + debug_infor_printf((const)"LogSecRes Release LgcId: %d TrainId:%d Cyc\n" + , wUnlockLgcSecId + , wTrainId + , Get2oo2CurCycleNum()); + } + else + { + pstLgcSecInfo[wLgcBufIndex].szTrainResData[chNeedKeepSum++] = pstLgcSecInfo[wLgcBufIndex].szTrainResData[jj]; + } + + } + pstLgcSecInfo[wLgcBufIndex].chTrainInfoSum = chNeedKeepSum; + if (0U == chNeedKeepSum) + { + SetLogSecResShareFlag(wUnlockLgcSecId,LOGIC_SECTION_RES_SHARE_YES); + } + } + else + { + } + } + } +} +/* +* 鱣˹Ƿִ +* ˵ const UINT16 overlapId, ID +* const UINT32 dwOverlapUnlockCount Զ +* const UINT32 dwOverlapUnlockStartCyc Զʼ +* ֵ CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 CheckOverlapLaborUnlock(const UINT16 overlapId, const UINT32 dwOverlapUnlockCount, const UINT32 dwOverlapUnlockStartCyc) +{ + UINT8 rtVal = CI_ERROR; + UINT8 OverlapLaborUnlockSetState = 0u; + UINT32 laborUnlockOverlapTimeCount = 0u; + UINT32 laborUnlockStartCycNum =0u; + UINT8 laborUnlockStopTimeState =0u; + UINT8 cTimeCheckFlag = CI_TIME_NO; + + if ((0U < overlapId) && (OVERLAP_SUM_MAX > overlapId)) + { + OverlapLaborUnlockSetState = GetOverlapLaborUnlockSetState(overlapId); + if (LABOR_UNLOCK_OVERLAP_YES == OverlapLaborUnlockSetState) + { + /*յ˹ʱ*/ + laborUnlockOverlapTimeCount = GetlabarUnlockOverlapTimeCount();/*˹ʱʱ*/ + laborUnlockStartCycNum = GetlaborUnlockStartCycNum(overlapId); + laborUnlockStopTimeState = SystemOverTimeCheck(laborUnlockStartCycNum, laborUnlockOverlapTimeCount); + if (CI_TIME_OUT == laborUnlockStopTimeState) + { + rtVal = CI_SUCCESS; + } + else + { + /*޸ȱYF0083-1554ʱ*/ + cTimeCheckFlag = SystemOverTimeCheck(dwOverlapUnlockStartCyc, dwOverlapUnlockCount); + + if (CI_TIME_OUT == cTimeCheckFlag) + { + rtVal = CI_SUCCESS; /*Զʱ䳬ʱ1ɹ*/ + } + else + { + rtVal = CI_ERROR; + } + } + } + else + { + rtVal = CI_ERROR; + } + } + else + { + /*ηǷ0ʧ*/ + } + + return rtVal; +} +/* +* 㱣νʱʼ +* ˵ const UINT16 overlapId, ID +* const UINT16 phySecId ·ID +* ֵ ʱ +*/ +UINT32 CalculaOverlapUnlockStartCycNum(const UINT16 overlapId,const UINT16 phySecId) +{ + + UINT32 rtVal = 0u; + UINT8 atsOrlaborLockCmdFlag = 0u; + UINT32 OverlaplockSucessStartCycNum = 0u; + UINT32 phyOccuStartCycNum = 0u; + + + + atsOrlaborLockCmdFlag = GetOverlapAtsOrlaborLockCmdFlag(overlapId); + OverlaplockSucessStartCycNum = GetOverlaplockSucessStartCycNum(overlapId); + phyOccuStartCycNum = GetSecUtOrCtOccuStartCycNum(phySecId); + if(LOCK_OVERLAP_CMD_YES == atsOrlaborLockCmdFlag)/*վ̨ռõ£˹ջATSձ*/ + { + if((0u OverlaplockSucessStartCycNum)/*֮ǰյıΣռõĽ·һ*/ + { + rtVal = phyOccuStartCycNum;/*ռʼ*/ + } + else + { /*֮ǰռõĽ·һΣձ*/ + rtVal = OverlaplockSucessStartCycNum;/*ʼʼ*/ + } + } + else + { + rtVal = phyOccuStartCycNum;/*ռʼΪʼ*/ + } + } + else + { + rtVal = phyOccuStartCycNum; + } + + (void)SetOverlapUnlockStartCycNum(overlapId,rtVal);/*˱δʹãڴáñʼںţ*/ + + return rtVal; +} + +/* C81_·г· */ +/* +* ·г· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_HALF_ROUTE_LOGIC +*/ +UINT8 SetHalfTrainRouteLogicProcess(UINT16 const routeId) +{ + /**/ + UINT8 const functionId = EFUNC_SET_HALF_ROUTE_LOGIC; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS; + + /* ·ǡг·۷·*/ + devState = GetRouteType(routeId); + if ((ROUTE_TYPE_LIECHE == devState) + || (ROUTE_TYPE_RETURN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊ·С򡾽·ս*/ + devState = GetRouteState(routeId); + if ((ROUTE_STATE_IDLE == devState) + || (ROUTE_STATE_HALF_UNLOCK == devState) + || (ROUTE_STATE_AUTO_UNLOCK == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetHalfRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetRouteHalfSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*ֶν·*/ + checkResult = RouteFenDuanConditionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* سɹ */ + return reResult; +} + +/* L04_·· */ +/* +* ·· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetHalfRouteSectionCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 CiFunctionJLock = 0u; /*ǷԾձ־*/ + + + + /* ·豸 */ + + /* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteHalfSecFLockCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·״̬δա + ͬġա + (ͬġա ͬġʱաս·Ϊг·ARBҷһ) + */ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + + checkResult = RouteHalfSecLockCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + {/*cgh-ϲCID-2349-1*/ + devId = 0u; + devState = 0u; + CiFunctionJLock = GetCiFunctionSwitchConfig(FUNC_CBTC_CHECK_JUMPLOCK_FLAG); + if (FUNC_SWITCH_OFF == CiFunctionJLock) + { + reResult = CI_SUCCESS; + } + else + { + checkResult = RouteHalfSecJumpLockStateCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_JUMP_LOCK, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /* ؽ */ + return reResult; +} + +/* ·ֵ */ +/* +* ʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetRouteHalfSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 cYLockAlarmFlag = FLAG_UNSET; /*־*/ + UINT8 chConnetCheckFunc = 0U; + + chConnetCheckFunc = GetCiFunctionSwitchConfig(FUNC_SETROUTE_CONNECT_CHECK); /*ȡǷҪĿ*/ + + /*·еδ δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteHalfSwitchFLockCheck(routeId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·δ*/ + devId = 0u; + devState = 0u; + cYLockAlarmFlag = FLAG_UNSET; + checkResult = RouteHalfProSwitchFLockCheck(routeId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteHalfLtrlDfncSwitchCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == chConnetCheckFunc) + { + ; /*ش򿪣*/ + } + else + { + /*ֽ·豸*/ + checkResult = RouteHalfContactLineDevCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + if (CI_SUCCESS == reResult) + { + + /*·еλȷλòȷɶ*/ + devId = 0u; + devState = 0u; + + checkResult = RouteHalfSwitchMoveValidCheck(routeId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·λȷλòȷɶ*/ + devId = 0u; + devState = 0u; + checkResult = RouteHalfProSwitchMoveValCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ؽ */ + return reResult; +} + +/* C82_ս·· */ +/* +* CBTCг· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_CBTC_T_ROUTE +*/ +UINT8 LockRouteHalfLogicProcess(UINT16 const routeId) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_HALF_ROUTE_LOGIC; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 devState = 0u; /*豸״̬*/ + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + UINT16 devId = 0u; /*豸ID*/ + + + /* ߼ */ + + + + /* ·ǡг·۷·*/ + devState = GetRouteType(routeId); + if ((ROUTE_TYPE_LIECHE == devState) + ||(ROUTE_TYPE_RETURN == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_TYPE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬Ϊֽ·ѡšֽ·ԶС*/ + devState = GetRouteState(routeId); + if ((ROUTE_STATE_HALF_XUANPAI == devState) + || (ROUTE_STATE_HALF_UNLOCK == devState) + ||(ROUTE_STATE_IDLE == devState) + || (ROUTE_STATE_AUTO_UNLOCK == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetHalfRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ֶν·*/ + checkResult = RouteFenDuanConditionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockRouteHalfSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult =RouteHalfIntruSecCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټޣʧֱܺӷ͸ATS*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + + /* سɹ */ + return reResult; +} + +/* ·ղֵ */ +/* +* ·յ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LockRouteHalfSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT32 dwXuanPaiStartCycNum = 0U;/*·ѡʼ*/ + UINT32 dwRouteXuanPaiCount = 0U;/*·ѡų*/ + UINT8 chRouteTimeState = 0U; + UINT8 cYLockAlarmFlag = FLAG_UNSET; /*־*/ + UINT8 chConnetCheckFunc = 0U; + + chConnetCheckFunc = GetCiFunctionSwitchConfig(FUNC_SETROUTE_CONNECT_CHECK); /*ȡǷҪĿ*/ + + dwXuanPaiStartCycNum = GetRouteXuanPaiStartCycNum(routeId); + dwRouteXuanPaiCount = GetSystemParaRouteXuanPaiCyc(); + chRouteTimeState = SystemOverTimeCheck(dwXuanPaiStartCycNum, dwRouteXuanPaiCount); + /*·еδ δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteHalfSwitchFLockCheck(routeId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·δ*/ + devId = 0u; + devState = 0u; + cYLockAlarmFlag = FLAG_UNSET; + checkResult = RouteHalfProSwitchFLockCheck(routeId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + if (CI_SUCCESS == reResult) + { + /*·ʱ䳬ʱ*/ + /*жΪCI_TIME_INʱͨ·תʱ˴ʱ(ΪѡʱΪ0)*/ + if (CI_TIME_OUT == chRouteTimeState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_XUANPAI_OVERTIME, chRouteTimeState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + else + { + /* ͨ */ + reResult = CI_SUCCESS; + } + } + /*·*/ + if (CI_SUCCESS == reResult) + { + checkResult = RouteHalfLtrlDfncSwitchCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == chConnetCheckFunc) + { + ; /*ش򿪣*/ + } + else + { + /*ֽ·豸*/ + checkResult = RouteHalfContactLineDevCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + if (CI_SUCCESS == reResult) + { + + /*·еλȷλòȷɶ*/ + devId = 0u; + devState = 0u; + + checkResult = RouteHalfSwitchMoveValidCheck(routeId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·λȷλòȷɶ*/ + devId = 0u; + devState = 0u; + checkResult = RouteHalfProSwitchMoveValCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + reResult = CI_ERROR; + } + + + if (CI_SUCCESS == reResult) + { + + /* + ·еλȷ + ȷRETURN_LOCK_ERR_SWITPOS + ȷCI_SUCCESS + */ + devId = 0u; + devState = 0u; + checkResult = RouteHalfSwitchPosCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + + } + } + if (CI_SUCCESS == reResult) + { + + /* + ·зλȷ + ȷRETURN_LOCK_ERR_SWITPOS + ȷCI_SUCCESS + */ + devId = 0u; + devState = 0u; + checkResult = RouteHalfProSwitchPosCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + + } + } + /* ؽ */ + return reResult; +} + +/* +* ȡӽ·εVBTCг +* UINT16 const routeId ·ID +* UINT16* pTrainId ӽεгID +* ֵ CI_SUCCESS ȡɹ +* CI_ERROR ȡʧ +*/ +UINT8 GetNearstVBTCTrainToOverlap(UINT16 const routeId, UINT16* pTrainId) +{ + UINT16 wTempTrainId = 0U; + UINT16 wEndSignalId = 0U; /*·նźŻID*/ + UINT8 cTrainLevel = 0U; + UINT8 retVal = CI_ERROR; + + if ((0U != routeId) && (ROUTE_SUM_MAX > routeId) && (NULL != pTrainId)) + { + wEndSignalId = GetRouteEndSignalId(routeId); /*ȡ·նźŻ*/ + wTempTrainId = GetSignalLightUpTrainId(wEndSignalId); /*ȡնźŻĵгID*/ + cTrainLevel = GetTrainLevel(wTempTrainId); + + if (TRAIN_LEVEL_VBTC == cTrainLevel) + { + *pTrainId = wTempTrainId; + retVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + } + else + { + /*ʧ*/ + } + + return retVal; +} + +/* +* ֽ·ü +* ˵ const UINT16 routeId ֽ· +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CHECK_HALFROUTE_USEING +*/ +UINT8 HalfRoutePhySecUseLogicProcess(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_CHECK_HALFROUTE_USEING; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 sendLevel = 0u; /*ATS*/ + + + sendLevel = ESEND_LEVEL_ATS; + + + /**/ + + /* ֽ·ȫ = δá*/ + devId = 0u; + devState = 0u; + checkResult = HalfRouteAllSecUseVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_USE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + return reResult; +} + +/* +* εķ봦 +* ˵const UINT16 wSwitchId ID +* const UINT16 wOverlapId ID +* ֵ +* Created By LQ 2024.12.04 +*/ +void OtherCiOlpProSwUseApplyPro(const UINT16 wSwitchId, const UINT16 wOverlapId) +{ + UINT16 wSwitchIndex = 0U; + UINT16 wOverlapIndex = 0U; + UINT8 cLocalCiId = 0U; /*ID*/ + UINT8 cOverlapBelongCiId = 0U; /*ID*/ + UINT8 cSwitchBelongCiId = 0U; /*ID*/ + UINT16 wProSwitchPhySecId = 0U; /*ID*/ + UINT8 cPhySecUsingState = 0U; /*״̬*/ + UINT16 wPhySecUsingRouteId = 0U; /*ν··ID*/ + UINT16 wPhySecProUsingRouteId = 0U; /*η·ID*/ + UINT16 wUsingBelongOverlapId = 0U; /*ID*/ + UINT8 cCheckFlag = CI_ERROR; + UINT8 cProSwitchPos = 0U; /*λ*/ + UINT8 cSwitchUsingState = 0U; /*״̬*/ + + wSwitchIndex = GetSwitchConfigBufIndex(wSwitchId); + wOverlapIndex = GetOverlapConfigBufIndex(wOverlapId); + + if ((SWITCH_SUM_MAX > wSwitchIndex) && (OVERLAP_SUM_MAX > wOverlapIndex)) + { + cLocalCiId = GetSystemParaLocalCiId(); + cSwitchBelongCiId = GetSwitchBelongCiId(wSwitchId); + cOverlapBelongCiId = GetOverlapBelongCiId(wOverlapId); + if ((0U != cLocalCiId) && (cLocalCiId == cSwitchBelongCiId) && (0U != cOverlapBelongCiId) && (cLocalCiId != cOverlapBelongCiId)) + { + cCheckFlag = CI_SUCCESS; + + /****** 1.Ƿ񱻽· ******/ + wProSwitchPhySecId = GetSwitchPhySectionId(wSwitchId); /*ȡID*/ + cPhySecUsingState = GetPhySecUseState(wProSwitchPhySecId); /*ȡ״̬*/ + + if (PHYSICAL_SECTION_USING_NO == cPhySecUsingState) + { + /*ͨ*/ + } + else + { + cProSwitchPos = GetOverlapProSwitchPos(wOverlapId, wSwitchId); /*ȡķλ*/ + wPhySecUsingRouteId = GetPhySecUseRouteId(wProSwitchPhySecId); /*ȡõĽ·*/ + wPhySecProUsingRouteId = GetPhySecProtectUseRouteId(wProSwitchPhySecId); /*ȡηõĽ·*/ + + if ((CI_ERROR != cProSwitchPos) && ((0U < wPhySecUsingRouteId) || (0U < wPhySecProUsingRouteId))) + { + cCheckFlag = CheckPhyUseSecCanOtherUse(wSwitchId, cProSwitchPos); /*·õλǷһ*/ + } + else + { + cCheckFlag = CI_ERROR; + } + } + + /****** 2.Ƿ ******/ + if (CI_SUCCESS == cCheckFlag) + { + cSwitchUsingState = GetSwitchUsingState(wSwitchId); /*ȡ״̬*/ + wUsingBelongOverlapId = GetSwitchBelongOverlapId(wSwitchId); /*ȡıID*/ + if (((SWITCH_USING_NO == cSwitchUsingState) && (0U == wUsingBelongOverlapId)) + || ((SWITCH_USING_YES == cSwitchUsingState) && (wUsingBelongOverlapId == wOverlapId))) + { + /*ͨ*/ + } + else + { + cCheckFlag = CI_ERROR; /*ãʧ*/ + } + } + else + { + /*üʧܣ*/ + } + + if (CI_SUCCESS == cCheckFlag) + { + SetSwitchUsingState(wSwitchId, SWITCH_USING_YES, wOverlapId); /*÷ıñ*/ + } + else + { + AddCiSendToCiCmdInfo(CI_CMD_OLP_PROSWT_USE_FAILURE, wSwitchId, wOverlapId, cOverlapBelongCiId); /*ʧܣʧܷ*/ + } + } + else + { + /*DZ򱾿Σ*/ + } + } + else + { + /*/IDǷ*/ + } +} + +/* +* εķȡ +* ˵const UINT16 wSwitchId ID +* const UINT16 wOverlapId ID +* ֵ +* Created By LQ 2024.12.04 +*/ +void OtherCiOlpProSwUseCancelPro(const UINT16 wSwitchId, const UINT16 wOverlapId) +{ + UINT16 wSwitchIndex = 0U; + UINT16 wOverlapIndex = 0U; + UINT8 cLocalCiId = 0U; /*ID*/ + UINT8 cOverlapBelongCiId = 0U; /*ID*/ + UINT8 ii = 0U; + UINT8 cSwitchBelongCiId = 0U; /*ID*/ + UINT16 wUsingBelongOverlapId = 0U; /*ID*/ + UINT8 cSwitchUsingState = 0U; /*״̬*/ + + wSwitchIndex = GetSwitchConfigBufIndex(wSwitchId); + wOverlapIndex = GetOverlapConfigBufIndex(wOverlapId); + + if ((SWITCH_SUM_MAX > wSwitchIndex) && (OVERLAP_SUM_MAX > wOverlapIndex)) + { + cLocalCiId = GetSystemParaLocalCiId(); + cSwitchBelongCiId = GetSwitchBelongCiId(wSwitchId); + cOverlapBelongCiId = GetOverlapBelongCiId(wOverlapId); + if ((0U != cLocalCiId) && (cLocalCiId == cSwitchBelongCiId) && (0U != cOverlapBelongCiId) && (cLocalCiId != cOverlapBelongCiId)) + { + cSwitchUsingState = GetSwitchUsingState(wSwitchId); /*ȡ״̬*/ + wUsingBelongOverlapId = GetSwitchBelongOverlapId(wSwitchId); /*ȡıID*/ + if ((SWITCH_USING_YES == cSwitchUsingState) && (wUsingBelongOverlapId == wOverlapId)) + { + SetSwitchUsingState(wSwitchId, SWITCH_USING_NO, wOverlapId); /*˱ã*/ + } + else + { + AddCiSendToCiCmdInfo(CI_CMD_OLP_PROSWT_USE_FAILURE, wSwitchId, wOverlapId, cOverlapBelongCiId); /*ȡʧܣʧܷ*/ + } + } + else + { + /*DZ򱾿Σ*/ + } + } + else + { + /*IDǷ*/ + } +} +/* +* гͷŽ߼ +* ˵const UINT16 wRouteId ·id +* const UINT16 wUnlockLgcSecId ID +* ֵ +* Created By fan 2025.03.10 +*/ +UINT8 RouteLgcSecResUnlockNextSecCheck(const UINT16 wRouteId, const UINT16 wUnlockLgcSecId) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 chRouteType = 0U; /*·*/ + UINT8 chRouteState = 0U; /*·״̬*/ + UINT16 wLogBelongPhy = 0U; /**/ + UINT16 wValidReturnSigId = 0U; /*۷źŻ*/ + UINT16 wReturnSecId = 0U; /*۷id*/ + UINT16 wNextLogId = 0U; /*һ߼id*/ + UINT8 chNextLogSecOccupy = 0U; /*һ߼ռ״̬*/ + UINT16 wNextPhyId = 0U; /*һid*/ + UINT8 chNextPhyState = 0U; /*һ״̬*/ + + wLogBelongPhy = GetLgcSecRelativePhySecId(wUnlockLgcSecId);/*ȡӦ*/ + chRouteType = GetRouteType(wRouteId); + chRouteState = GetRouteState(wRouteId); /*·״̬*/ + + if ((0U != chRouteState) && (0U != wLogBelongPhy)) + { + wNextLogId = GetRouteNextLogSecId(wRouteId, wUnlockLgcSecId); + + /*ȡ·Ϣ*/ + wValidReturnSigId = GetValidReturnSinalId(wRouteId, wLogBelongPhy); + wReturnSecId = GetSignalOutFirstPhySecId(wValidReturnSigId); + + if (ROUTE_STATE_HALF_UNLOCK == chRouteState) + { + /*λ۷ ȴ·յͷż߼*/ + chRetVal = CI_SUCCESS; + } + else + { + if ((ROUTE_TYPE_RETURN == chRouteType) && (wLogBelongPhy == wReturnSecId)) + { + chRetVal = RouteLgcSecResReturnSecCheck(wValidReturnSigId, wRouteId); + } + else if ((ROUTE_TYPE_RETURN != chRouteType) && (0U < wValidReturnSigId) && (wLogBelongPhy == wReturnSecId)) + { + /*һռ ۳·״̬ȷ*/ + wNextPhyId = GetRouteNextPhySecId(wRouteId, wLogBelongPhy); + chNextPhyState = GetPhySecCurMergeState(wNextPhyId); + if (SECTION_OCCUPY_YES == chNextPhyState) + { + chRetVal = CI_SUCCESS; + } + else + { + /*ͨת۷ ۳*/ + chRetVal = RouteLgcSecResReturnSecCheck(wValidReturnSigId, wRouteId); + } + } + else + { + wNextLogId = GetRouteNextLogSecId(wRouteId, wUnlockLgcSecId); + if (0u != wNextLogId) + { + /*ʹȣ˵ǽ·һ߼*/ + if (wNextLogId == wUnlockLgcSecId) + { + /*ȡ·ȥ*/ + wNextPhyId = GetRouteLeavePhySecId(wRouteId); + chNextPhyState = GetPhySecCurMergeState(wNextPhyId); + if (SECTION_OCCUPY_YES == chNextPhyState) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*һռ״̬*/ + chNextLogSecOccupy = GetLogSecCurOccupyState(wNextLogId); + if (SECTION_OCCUPY_YES == chNextLogSecOccupy) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + } + } + else + { + /*·IDIDǷ*/ + chRetVal = CI_ERROR; + } + + return chRetVal; +} + + +/* +* гͷŽ۷ +* ˵const UINT16 wValidReturnSigId ۷źŻ +* const UINT16 wRouteId ·ID +* ֵ +* Created By fan 2025.03.10 +*/ +UINT8 RouteLgcSecResReturnSecCheck(UINT16 wValidReturnSigId, const UINT16 wRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wPhySecRLockId = 0U; /*·*/ + UINT8 chBackRouteState = 0U;/*۳·״̬*/ + UINT32 dwUnlockRouteStartCyc = 0U; /*·ʱ*/ + UINT32 dwBackRouteLockTime = 0U; /*۳·ʱ*/ + UINT16 wNextPhyId = 0U; /*һid*/ + UINT8 chNextPhyState = 0U; /*һ״̬*/ + UINT8 chErrorLog = 0U; + if ((0U != wValidReturnSigId)&&(0U != wRouteId)) + { + /*۷źŻڷ*/ + wNextPhyId = GetSignalInFirstLockedPhySecId(wValidReturnSigId); /*ȡźŻڷ*/ + chNextPhyState = GetPhySecCurMergeState(wNextPhyId); + wPhySecRLockId = GetPhySecRLockBelongRouteId(wNextPhyId); /*·*/ + chBackRouteState = GetRouteState(wPhySecRLockId);/*۳·״̬*/ + dwUnlockRouteStartCyc = GetRouteLockStartCycNum(wRouteId); + dwBackRouteLockTime = GetRouteLockStartCycNum(wPhySecRLockId); + + chErrorLog++; + /*۳·״̬*/ + if (SECTION_OCCUPY_YES == chNextPhyState) + { + chErrorLog++; + /*۷·ʱ۳· ۳·״̬Ϊӽ*/ + if ((((INT32)(dwUnlockRouteStartCyc - dwBackRouteLockTime)) > 0U) + && (ROUTE_STATE_NEAR_LOCK == chBackRouteState)) + { + chRetVal = CI_SUCCESS; + } + else + { + /*۷쳣*/ + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + if (CI_ERROR == chRetVal) + { + debug_infor_printf((const)"Return_Sec RouteLgcSecResReturnSecCheck Fail %d Step\n", chErrorLog); + } + return chRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicProcess.h b/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicProcess.h new file mode 100644 index 0000000..13d5dda --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicProcess/InterlockLogicProcess.h @@ -0,0 +1,830 @@ +/******************************************************** +* +* InterlockLogicProcess.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-10 +* ߣ +* ߼ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _INTERLOCK_LOGIC_PROCESS_H_ +#define _INTERLOCK_LOGIC_PROCESS_H_ + +#define CI_CANCLE_ZHAOCHA_FAIL (0x02U) + +#include "InterlockLogicCheck.h" +#include "../ERROR/ErrorDataManage.h" +#include "../ERROR/ErrorDefine.h" +#include "../LogicManage/InterlockLogicManage.h" +#include "../Route/RouteDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../System/SystemParameterManage.h" +#include "../System/CiSystemDefine.h" +#include "../Overlap/OverlapDataManage.h" +#include "../Overlap/OverlapConfigDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../psd/PSDDataManage.h" +#include "../Section/LogicSectionDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" +#include "../LogicManage/InterlockCommonManage.h" +#include "../DataManage/DeviceConfigDataManage.h" +#ifdef __cplusplus +extern "C" { +#endif + + +/* C02_ʽг· */ +/* +* ʽг· +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFC_SET_BLOC_T_ROUTE +*/ +UINT8 SetBlocLTrainRouteLogicProcess(const UINT16 routeId); + + +/* C03_CBTCг· */ +/* +* CBTCг· +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_CBTC_T_ROUTE +*/ +UINT8 SetCbtcLTrainRouteLogicProcess(const UINT16 routeId); + + +/* RR1_зԵг· */ +/* +* зԵг· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_REVERSE_T_ROUTE +*/ +UINT8 SetRevrLTrainRouteLogicProcess(UINT16 const routeId); + + +/* C04_ʽ۷· */ +/* +* ʽ۷· +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_BLOC_T_ROUTE +*/ +UINT8 SetBlocReturnRouteLogicProcess(const UINT16 routeId); + + +/* C05_CBTC۷· */ +/* +* CBTC۷· +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_CBTC_R_ROUTE +*/ +UINT8 SetCbtcReturnRouteLogicProcess(const UINT16 routeId); + +/* RR2_зԵ۷· */ +/* +* зԵ۷· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_REVERSE_R_ROUTE +*/ +UINT8 SetReverseRtnRouteLogicProcess(UINT16 const routeId); + + + +/* C06_· */ +/* +* · +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_LEAD_ROUTE +*/ +UINT8 LockLeadRouteLogicProcess(const UINT16 routeId); + + +/* C07_յʽг· */ +/* +* յʽг· +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_BLOC_T_ROUTE +*/ +UINT8 LockBlocLTrainRouteLogicProcess(const UINT16 routeId); + + +/* C08_CBTCг· */ +/* +* CBTCг· +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_CBTC_T_ROUTE +*/ +UINT8 LockCbtcLTrainRouteLogicProcess(const UINT16 routeId); + + +/* C09_յʽ۷· */ +/* +* յʽ۷· +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_BLOC_R_ROUTE +*/ +UINT8 LockBlocReturnRouteLogicProcess(const UINT16 routeId); + + +/* C10_CBTC۷· */ +/* +* CBTC۷· +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_CBTC_R_ROUTE +*/ +UINT8 LockCbtcReturnRouteLogicProcess(const UINT16 routeId); + + +/* C11_ս·overlap߼ */ +/* +* ս·overlap߼ +* ˵ UINT16 const routeId, UINT16 const overlapId +* ֵ CI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* RETURN_LOCK_ERR_SWITPOS 0x22 λô +* RETURN_WAIT_SWITCH_USING 0x30 ȴ +* RETURN_WAIT_SWITCH_CHECK 0x31 ȴ +* ϱ룺 EFUNC_LOCK_OVER_LAP +*/ +UINT8 LockRouteOverlapLogicProcess(UINT16 const routeId, UINT16 const overlapId,UINT8 lockType); + + +/* C12_ŵʽг·ź */ +/* +* ŵʽг·ź +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* RETURN_OPEN_ERR_SIGOPEN +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_BLOC_T_SIGNAL +*/ +UINT8 OpenBlocLTrainRouteLogicProcess(const UINT16 routeId); + + +/* C13_ʽг·źű */ +/* +* ʽг·źű +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_BLOC_T_SIGNAL +*/ +UINT8 KeepBlocLTrainRouteLogicProcess(const UINT16 routeId); + +/* C14_CBTCг·ź */ +/* +* CBTCг·ź +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_CBTC_T_SIGNAL +*/ +UINT8 OpenCbtcLTrainRouteLogicProcess(const UINT16 routeId); + +/* C15_CBTCг·źű */ +/* +* CBTCг·źű +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_CBTC_T_SIGNAL +*/ +UINT8 KeepCbtcLTrainRouteLogicProcess(const UINT16 routeId); + +/* C16_ŵʽ۷·ź */ +/* +* ŵʽ۷·ź +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* RETURN_OPEN_ERR_SIGOPEN +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_BLOC_R_SIGNAL +*/ +UINT8 OpenBlocReturnRouteLogicProcess(const UINT16 routeId); + +/* C17_ʽ۷·źű */ +/* +* ʽ۷·źű +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_BLOC_R_SIGNAL +*/ +UINT8 KeepBlocReturnRouteLogicProcess(const UINT16 routeId); + +/* C18_CBTC۷·ź */ +/* +* CBTC۷·ź +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* RETURN_OPEN_ERR_SIGOPEN +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_CBTC_R_SIGNAL +*/ +UINT8 OpenCbtcReturnRouteLogicProcess(const UINT16 routeId); + +/* C19_CBTC۷·źű */ +/* +* CBTC۷·źű +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_CBTC_R_SIGNAL +*/ +UINT8 KeepCbtcReturnRouteLogicProcess(const UINT16 routeId); + +/* C20_·߼ */ +/* +* ·߼ +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_OPEN_LEAD_SIGNAL +*/ +UINT8 OpenLeadRouteLogicProcess(const UINT16 routeId); + + +/* C21_ֿ·߼ */ +/* +* ֿ·߼ +* ˵ UINT16 const routeId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_KEEP_LEAD_SIGNAL +*/ +UINT8 KeepLeadRouteLogicProcess(const UINT16 routeId); + + +/* C22_·һԶ */ +/* +* ·һԶ +* ˵ UINT16 const routeId· +* UINT16* phySectionIdID +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_UNLOCK_1ST_SECTION +*/ +UINT8 RouteFirstSecAutoUnlockProcess(const UINT16 routeId, UINT16* phySectionId); + +/* C23_·Զ */ +/* +* ·Զ +* ˵ UINT16 const routeId· +* UINT16* phySectionIdID +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_UNLOCK_OTHERS_SECTION +*/ +UINT8 RouteOtherSecAutoUnlockProcess(const UINT16 routeId, UINT16* phySectionId); + +/* C24_ʱ*/ +/* +* ʱ +* ˵ UINT16 const routeId· +* UINT16* phySectionIdID +* ֵ CI_ERROR +* RETURN_DELAYUNLOCK_ERR_TIMECOUNT +* CI_SUCCESS +* ϱ룺 EFUNC_DLOCK_SECTION +*/ +UINT8 PhySectionDelayUnlockProcess(const UINT16 routeId, UINT16* phySectionId); + + +/* C25_·overlap߼ */ +/* +* ·overlap߼ +* ˵ const UINT16 routeId +* ֵ CI_ERROR +* CI_SUCCESS +* CI_UNLOCK_OVERLAP_REQURE ZC +* ϱ룺 EFUNC_UNLOCK_OVER_LAP +*/ +UINT8 UnlockRouteOverlapLogicProcess(const UINT16 routeId, UINT16* overlapId, UINT16* pTrainId); + +/* C26_·ȡ */ +/* +* ·ȡ +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCLE_ROUTE +*/ +UINT8 RouteCancelLogicProcess(const UINT16 routeId); + +/* C27_ü */ +/* +* ü +* ˵ const UINT16 routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CHECK_SECTION_USE +*/ +UINT8 RoutePhySectionUseLogicProcess(const UINT16 routeId); + +/* C28_ιϽ */ + + +/* C29_*/ +/* +* +* ˵ +* UINT16 const switchId, UINT8 const switchSetPos +* UINT8 chSwitchTestFlag CI_SUCCESS/λʱָλñ־CI_ERROR ǵ/λߵ/λʱָλñ־ +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SWITCH_POS +* cgh-ϲCID-3037-6 +*/ +UINT8 SetSwitchPositionLogicProcess(UINT16 const switchId, UINT8 const switchSetPos, const UINT8 chCmdType, UINT8* chSwitchTestFlag); + +/* C30_õ*/ +/* +* õ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SWITCH_DLOCK +*/ +UINT8 SetSwitchDLockLogicProcess(const UINT16 switchId); + +/* C31_ȡ*/ +/* +* ȡ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCEL_SWITCH_DLOCK +*/ +UINT8 CancelSwitchDLockLogicProcess(const UINT16 switchId); + +/* C32_õ*/ +/* +* õ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCEL_SWITCH_FLOCK +*/ +UINT8 SetSwitchFLockLogicProcess(const UINT16 switchId); + +/* C33_ȡ*/ +/* +* ȡ +* ˵ UINT16 const switchId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCEL_SWITCH_FLOCK +* +*/ +UINT8 CancelSwitchFLockLogicProcess(const UINT16 switchId); + +/* C34_źŻ*/ +/* +* źŻ +* ˵ UINT16 const signalId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_SIGNAL_FLOCK +* +*/ +UINT8 SetSignalFLockLogicProcess(const UINT16 signalId); + +/* C35_źŻ*/ +/* +* ȡźŻ +* ˵ UINT16 const signalId +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CANCEL_SIGNAL_FLOCK +* +*/ +UINT8 CancelSignalFLockLogicProcess(const UINT16 signalId); + + +/* C36_*/ +/* +* ǿ +* ˵ UINT16 const switchId, UINT8 const switchSetPos +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_FORCE_SET_SWITCH_POS +*/ +UINT8 ForceSetSwitchPosLogicProcess(UINT16 const switchId, UINT8 const switchSetPos); + +/* R_R_S_C1·źŻ */ +/* +* ·źŻ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetReverseRouteSignalCheck( UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + + + +/* L02_ʽ· */ +/* +* ʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetBlocRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + + +/* R_L_L_01· */ +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetReverseRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + + + +/* R_L_L_02·ԶźŽ·״̬ */ +/* +* ·ԶźŽ·״̬ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetRevrRouteAutoSigStaCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L04_ʽ· */ +/* +* ģʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 BlocRouteFloodGateCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L03_ʽ· */ +/* +* ʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetBlocRouteSwitchCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L04_Cbtc· */ +/* +* Cbtc· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetCbtcRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + + +/* L05_· */ +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetLeadRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L08_ʽ·ź */ +/* +* ʽ·ź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L15_Cbtc·źſ */ +/* +* Cbtc·źſ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenCbtcRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L16_·źſ */ +/* +* ·źſ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLeadRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* L17_Cbtc·źű */ +/* +* Cbtc·źű +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepCbtcRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ʽ۷·ź +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenBlocReturnRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + + + +/* L04_CBTC· */ +/* +* ģʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 CBTCRouteFloodGateCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ȡԶź +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +void CancleAutoSigCmdProcc(const UINT16 routeId); + +/* +* ռʱ +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 BlocOverlapOccClearProc(const UINT16 routeId); +/*************************************************************************************************/ + +/* +* ·һ߼ν +* ˵ const UINT16 routeId, ·ID +* +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* CI_CANCLE_ZHAOCHA_FAIL ղʧ +* RETURN_AUTOLOCK_ERR_EXCEPT ʧ +*/ +UINT8 RouteLogSecAutoUnlockProcess(UINT16 const routeId, UINT16* logSectionId); + + + +/* +* ·߼ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LogSecDelayUnlockProc(const UINT16 routeId); + +/* +* ʱ +* ˵ UINT16 const routeId· +* UINT16* phySectionIdID +* ֵ CI_ERROR +* RETURN_DELAYUNLOCK_ERR_TIMECOUNT +* CI_SUCCESS +*/ +UINT8 LogSecDelayUnlockProcess(UINT16 const routeId, UINT16* logSectionId); + +UINT8 CLDKeepOpenSecCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel); + +/* +* ·߼Դг +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLgcSecResUnlockProcess(const UINT16 wRouteId); + +/* +* ·߼ν +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void LgcSecUnlockProc(const UINT16 routeId, const UINT16 logSectionId); + +/* +* ·߼ԴгͷŴ +* ˵ const UINT16 routeId, ·ID +* ֵ void +*/ +void RouteLgcSecResReleaseProcess(const UINT16 wRouteId); +/* +* 鱣˹Ƿִ +* ˵ const UINT16 overlapId, ID +* const UINT32 dwOverlapUnlockCount Զ +* const UINT32 dwOverlapUnlockStartCyc Զʼ +* ֵ CI_SUCCESS:ɹ + CI_ERROR:ʧ +*/ +UINT8 CheckOverlapLaborUnlock(const UINT16 overlapId, const UINT32 dwOverlapUnlockCount, const UINT32 dwOverlapUnlockStartCyc); +/* +* 㱣νʱʼ +* ˵ const UINT16 overlapId, ID +* const UINT16 phySecId ·ID +* ֵ ʱ +*/ +UINT32 CalculaOverlapUnlockStartCycNum(const UINT16 overlapId,const UINT16 phySecId); + +/* C81_·г· */ +/* +* ·г· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_SET_HALF_ROUTE_LOGIC +*/ +UINT8 SetHalfTrainRouteLogicProcess(UINT16 const routeId); + +/* L04_·· */ +/* +* ·· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetHalfRouteSectionCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/* ·ֵ */ +/* +* ʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetRouteHalfSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/* ·ղֵ */ +/* +* ·յ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LockRouteHalfSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/* C82_ս·· */ +/* +* CBTCг· +* ˵ UINT16 const routeId · +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_LOCK_CBTC_T_ROUTE +*/ +UINT8 LockRouteHalfLogicProcess(UINT16 const routeId); + +/* +* ȡӽ·εVBTCг +* UINT16 const routeId ·ID +* UINT16* pTrainId ӽεгID +* ֵ CI_SUCCESS ȡɹ +* CI_ERROR ȡʧ +*/ +UINT8 GetNearstVBTCTrainToOverlap(UINT16 const routeId, UINT16* pTrainId); + +/* +* ֽ·ü +* ˵ const UINT16 routeId ֽ· +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CHECK_HALFROUTE_USEING +*/ +UINT8 HalfRoutePhySecUseLogicProcess(const UINT16 routeId); + +/* +* εķ봦 +* ˵const UINT16 wSwitchId ID +* const UINT16 wOverlapId ID +* ֵ +* Created By LQ 2024.12.04 +*/ +void OtherCiOlpProSwUseApplyPro(const UINT16 wSwitchId, const UINT16 wOverlapId); + +/* +* εķȡ +* ˵const UINT16 wSwitchId ID +* const UINT16 wOverlapId ID +* ֵ +* Created By LQ 2024.12.04 +*/ +void OtherCiOlpProSwUseCancelPro(const UINT16 wSwitchId, const UINT16 wOverlapId); + +/* +* гͷŽ߼ʱ +* ˵const UINT16 wRouteId ·id +* const UINT16 wUnlockLgcSecId ID +* ֵ +* Created By fan 2025.03.10 +*/ +UINT8 RouteLgcSecResUnlockNextSecCheck(const UINT16 wRouteId, const UINT16 wUnlockLgcSecId); + +/* +* гͷŽ۷ +* ˵const UINT16 wValidReturnSigId ۷źŻ +* const UINT16 wRouteId ·ID +* ֵ +* Created By fan 2025.03.10 +*/ +UINT8 RouteLgcSecResReturnSecCheck(UINT16 wValidReturnSigId, const UINT16 wRouteId); + +#if 0 +/* +* ߼αտ߼ +* ˵ UINT16 const overlapId ID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +*/ +UINT8 LgcOverlapUsableProcess(UINT16 const wLgcSecId); +#endif +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/LogicProcess/LogicalRouteLogicCheck.c b/TSCP/src/APP/ciapp/LogicProcess/LogicalRouteLogicCheck.c new file mode 100644 index 0000000..ce910e8 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicProcess/LogicalRouteLogicCheck.c @@ -0,0 +1,3968 @@ +#include "LogicalRouteDataManage.h" +#include "PhysicalSectionDataManage.h" +#include "InterlockCommonManage.h" +#include "LogicalRouteLogicCheck.h" +#include "InterlockLogicCheck.h" + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* @return CI_SUCCESSͨ CI_ERROR鲻ͨ +* @note +*/ +UINT8 SetLogRouteCheckProcess(UINT16 const logRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_SetLogRouteCheckProcess; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS; + + /* ·״̬Ϊ·ѡ*/ + devState = GetLogicalRouteState(logRouteId); + if (ROUTE_LOGICAL_STATE_FIRST_XUANPAI == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, logRouteId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + /*ղȷ(Ԥ)*/ + + + /* ߼ */ + if (CI_SUCCESS == reResult) + { + checkResult = LogRouteSectionCheck(logRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + ; /**/ + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteFloodGateCheck(logRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = SetLogRouteSwitchCheck(logRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + ; /**/ + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = LogRouteSwitchRelaySecCheck(logRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + + /* سɹ */ + return reResult; +} +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* @return 1ͨ 0鲻ͨ +* @note +*/ +UINT8 LockLogRouteCheckProcess(UINT16 const logRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_LockLogRouteCheckProcess; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + + + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ATS; + + /* ·״̬Ϊ·ѡš*/ + devState = GetLogicalRouteState(logRouteId); + if (ROUTE_LOGICAL_STATE_XUANPAI == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, logRouteId, ETYPE_ROUTE_STATE, devState, ESEND_LEVEL_ZERO); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + + /* ղȷ(Ԥ) */ + + + /* ߼· */ + if (CI_SUCCESS == reResult) + { + checkResult = LogRouteSectionCheck(logRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + ; /**/ + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = KeepLogRouteFloodGateCheck(logRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = LogRouteSwitchRelaySecCheck(logRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = LockLogRouteSwitchCheck(logRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + else + { + ; /**/ + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = LogRouteIntruSecCheck(logRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + ; /**/ + } + + /* سɹ */ + return reResult; +} + + +/** +* @brief ߼·η +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRoutePhySecFengSuoCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 ii = 0U; + UINT16 devId = 0U; /*ID*/ + UINT8 devState = 0U; + UINT8 retval = CI_ERROR; + + LogSecIdBuff = GetLogicalRouteInLogSecId(logRouteId); + logSecSum = GetLogicalRouteInLogSecSum(logRouteId); + if ((NULL != LogSecIdBuff) && (0U != logSecSum) && (NULL!= pDevId) && (NULL != pDevState)) + { + retval = CI_SUCCESS; + for (ii = 0U; ii < logSecSum; ii++) + { + devId = GetLgcSecRelativePhySecId(LogSecIdBuff[ii]); + devState = GetPhySecFLockState(devId); + + /* ״̬δ״̬Ϊʧ */ + if (PHYSICAL_SECTION_FLOCK_NO != devState ) + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + retval = CI_ERROR; + break; + } + else + { + /**/ + } + } + } + else + { + /*ʧ*/ + } + return retval; +} + + +/** +* @brief ߼·߼ռ +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteSectionLockCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 ii = 0U; + UINT16 devId = 0U; /*߼ID*/ + UINT8 devState = 0U; /*߼״̬*/ + + UINT8 retVal = CI_ERROR; + UINT8 funcRet = CI_ERROR; + UINT8 routeDirection = 0U; + UINT8 secLockDirection = 0U; + UINT16 protectLockedId = 0U; + + LogSecIdBuff = GetLogicalRouteInLogSecId(logRouteId); + logSecSum = GetLogicalRouteInLogSecSum(logRouteId); + + if ((NULL != LogSecIdBuff) && (0U != logSecSum) && (NULL != pDevId) && (NULL != pDevState)) + { + retVal = CI_SUCCESS; + /*ʼ*/ + routeDirection = GetLogicalRouteDir(logRouteId); + for (ii = 0u; ii < logSecSum; ii++) + { + devId = LogSecIdBuff[ii]; + devState = GetLogSecLockState(devId); /*߼·״̬*/ + + if (LOG_SECTION_LOCK_NO == devState) + { + /* δ */ + + } + else if (LOG_SECTION_LOCK_PROTECT == devState) + { + /**/ + secLockDirection = GetLogSecLockDir(devId); + if (secLockDirection == routeDirection) + { + /*һ*/ + + } + else + { + /*һ*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + + } + else if ((LOG_SECTION_LOCK_NORMAL == devState) || (LOG_SECTION_LOCK_DELAY == devState)) + { + /* Ρա ʱա */ + secLockDirection = GetLogSecLockDir(devId); + protectLockedId = GetLogSecPLockRouteId(devId); + /*ȡָID߼·гԴ߼*/ + funcRet = CheckLgcSecHaveTrainLocRoute(logRouteId, devId); + + /*һ*/ + if ((CI_SUCCESS == funcRet) && (0U == protectLockedId)) + { + /*гδͷʼ, ¼ʱгǰС߼*/ + } + else + {/*鲻ͨ*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + } + else + { + /*״̬*/ /*쳣޷*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + } + if (CI_ERROR == retVal) + { + break; + } + else + { + /*ѭ*/ + } + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ߼α߼· +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteLockBylogRouteCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT16* LogSecIdBuff = NULL; + UINT8 logRouteNum = 0U; /*߼ϴڵ߼·*/ + UINT16 logSecSum = 0U; + UINT16 ii = 0U; + UINT16 devId = 0U; /*߼ID*/ + UINT8 devState = 0U; /*߼α߼·״̬*/ + UINT8 logSecLockDir = 0U; /*߼α߼·շ,ֻͬһ*/ + UINT8 logRoutDirection = 0U; /*߼·*/ + UINT8 retVal = CI_ERROR; + UINT8 funcRet = CI_ERROR; + UINT16 protectLockedId = 0U; + + + LogSecIdBuff = GetLogicalRouteInLogSecId(logRouteId); + logSecSum = GetLogicalRouteInLogSecSum(logRouteId); + logRoutDirection = GetLogicalRouteDir(logRouteId); + if ((NULL != LogSecIdBuff) && (0U != logSecSum)) + { + retVal = CI_SUCCESS; + /*ʼ*/ + for ( ii = 0; ii < logSecSum; ii++) + { + devId = LogSecIdBuff[ii]; + devState = GetLogSecLogLockState(devId); + logRouteNum = GetLogSecLockBelLogRouteSum(devId); + logSecLockDir = GetLogSecLogLockDir(devId); + funcRet = CheckLgcSecHaveTrainLocRoute(logRouteId, devId); + protectLockedId = GetLogSecPLockRouteId(devId); + + /*߼쳣*/ + if (LOG_SECTION_LOGLOCK_EXCEPT == devState) + { + retVal = CI_ERROR; + } + else if (LOG_SECTION_LOGLOCK_NORMAL == devState) + { + if ((logRoutDirection == logSecLockDir) && ((CI_SYSTEM_DIRECTION_UP == logRoutDirection) || (CI_SYSTEM_DIRECTION_DOWN == logRoutDirection))) + { + /*߼α߼·,շ뱾·һ ͨ*/ + } + else if (((CI_SYSTEM_DIRECTION_UP == logRoutDirection) && (CI_SYSTEM_DIRECTION_DOWN == logSecLockDir)) + || ((CI_SYSTEM_DIRECTION_DOWN == logRoutDirection) && (CI_SYSTEM_DIRECTION_UP == logSecLockDir))) + { + /*һ*/ + if ((CI_SUCCESS == funcRet) && (0U == protectLockedId)) + { + ; /*µ߼·յ߼ΣҴûգ԰߼·*/ + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; /*򲻺Ϸ0ʧ*/ + } + } + else if (LOG_SECTION_LOGLOCK_NO == devState) + { + /*߼δ߼·գͨ*/ + } + else + { + /*Ƿֵ鲻ͨ*/ + retVal = CI_ERROR; + } + + if (CI_ERROR == retVal) + { + /*鲻ͨ*/ + *pDevId = devId; + *pDevState = devState; + break; + } + + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ߼Ƿ· +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteYDLockCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 ii = 0U; + UINT16 wlogSecId = 0u; + UINT16 devId = 0U; /*߼·ID*/ + UINT8 devState = 0U; /*·״̬*/ + UINT8 retVal = CI_ERROR; + + LogSecIdBuff = GetLogicalRouteInLogSecId(logRouteId); + logSecSum = GetLogicalRouteInLogSecSum(logRouteId); + + if ((NULL != LogSecIdBuff) && (0U != logSecSum) && (NULL != pDevId) && (NULL != pDevState)) + { + retVal = CI_SUCCESS; + /*ʼ*/ + for (ii = 0; ii < logSecSum; ii++) + { + wlogSecId = LogSecIdBuff[ii]; + /*ȡ߼ι·ID*/ + devId = GetLogSecLockBelongRoute(wlogSecId); + /*·*/ + if (0U != devId) + { + devState = GetRouteState(devId); + if ((ROUTE_STATE_LEAD_LOCK == devState) + || (ROUTE_STATE_LEAD_LOCKERR == devState) + || (ROUTE_STATE_LEAD_OPEN == devState)) + { + /*·*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + break; + } + else + { + /**/ + } + } + else + { + /**/ + } + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ߼Ծռ +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LogRouteJumpLockCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 ii = 0U; + UINT16 wlogSecId = 0u; + UINT16 devId = 0U; /*߼ιID*/ + UINT8 devState = 0U; /*Ծ״̬*/ + UINT8 retVal = CI_ERROR; + LogSecIdBuff = GetLogicalRouteInLogSecId(logRouteId); + logSecSum = GetLogicalRouteInLogSecSum(logRouteId); + + if ((NULL != LogSecIdBuff) && (0U != logSecSum) && (NULL != pDevId) && (NULL != pDevState)) + { + retVal = CI_SUCCESS; + /*ʼ*/ + for (ii = 0; ii < logSecSum; ii++) + { + wlogSecId = LogSecIdBuff[ii]; + devId = GetLgcSecRelativePhySecId(LogSecIdBuff[ii]); + devState = GetPhySecJumpLockState(devId); + + /* 鱾 */ + if (PHYSICAL_SECTION_JUMP_LOCK_NO != devState) + { + /*״̬δԾշع״̬*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + break; + } + else + { + ; /*ִ*/ + } + } + } + + /*ȫͨ*/ + return retVal; +} +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LogRouteSectionCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel) +{ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 reResult = CI_ERROR; /*ֵ*/ + + /*߼·δ*/ + devId = 0u; + devState = 0u; + checkResult = LogRoutePhySecFengSuoCheck(logRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·״̬δա + ͬġա + Ϊгδ + */ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + + checkResult = LogRouteSectionLockCheck(logRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*߼δ߼·գշһ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + + checkResult = LogRouteLockBylogRouteCheck(logRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /*߼δ·*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + + checkResult = LogRouteYDLockCheck(logRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*߼δԾ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + + checkResult = LogRouteJumpLockCheck(logRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_JUMP_LOCK, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + return reResult; +} + + + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 SetLogRouteSwitchCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 cYLockAlarmFlag = FLAG_UNSET; /*־*/ + UINT8 chConnetCheckFunc = 0U; + + chConnetCheckFunc = GetCiFunctionSwitchConfig(FUNC_SETROUTE_CONNECT_CHECK); /*ȡǷҪĿ*/ + + /*߼·еδ δ*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteSwitchFLockCheck(logRouteId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + cYLockAlarmFlag = FLAG_UNSET; + checkResult = LogRouteProSwitchFLockCheck(logRouteId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteCeFangSwitchCheck(logRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == chConnetCheckFunc) + { + ; /*ش򿪣*/ + } + else + { + /*߼·豸*/ + checkResult = LogRouteContactLineDevSwitCheck(logRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /*·еλȷλòȷɶ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteSwitchMoveValidCheck(logRouteId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + /*·λȷλòȷɶ*/ + if (CI_SUCCESS == reResult) + { + + devId = 0u; + devState = 0u; + checkResult = LogRouteProSwitchMoveValidCheck(logRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ؽ */ + return reResult; +} + + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LockLogRouteSwitchCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 cYLockAlarmFlag = FLAG_UNSET; /*־*/ + UINT32 dwXuanPaiStartCycNum = 0U;/*߼·ѡʼ*/ + UINT32 dwRouteXuanPaiCount = 0U;/*·ѡų*/ + UINT8 chRouteTimeState = 0U; /*жѡǷʱ*/ + + UINT8 chConnetCheckFunc = 0U; + + chConnetCheckFunc = GetCiFunctionSwitchConfig(FUNC_SETROUTE_CONNECT_CHECK); /*ȡǷҪĿ*/ + + dwXuanPaiStartCycNum = GetLogRouteXuanPaiStartCycNum(logRouteId); + dwRouteXuanPaiCount = GetSystemParaRouteXuanPaiCyc(); + chRouteTimeState = SystemOverTimeCheck(dwXuanPaiStartCycNum, dwRouteXuanPaiCount); + + /*߼·еδ δ*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteSwitchFLockCheck(logRouteId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + cYLockAlarmFlag = FLAG_UNSET; + checkResult = LogRouteProSwitchFLockCheck(logRouteId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == reResult) + { + /*·ʱ䳬ʱ*/ + /*жΪCI_TIME_INʱͨ·תʱ˴ʱ(ΪѡʱΪ0)*/ + if (CI_TIME_OUT == chRouteTimeState) + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, logRouteId, ETYPE_ROUTE_XUANPAI_OVERTIME, chRouteTimeState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + else + { + /* ͨ */ + reResult = CI_SUCCESS; + } + } + else + { + ; /**/ + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteCeFangSwitchCheck(logRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == chConnetCheckFunc) + { + ; /*ش򿪣*/ + } + else + { + /*߼·豸*/ + checkResult = LogRouteContactLineDevSwitCheck(logRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + /*·еλȷλòȷɶ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteSwitchMoveValidCheck(logRouteId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + /*·λȷλòȷɶ*/ + if (CI_SUCCESS == reResult) + { + + devId = 0u; + devState = 0u; + checkResult = LogRouteProSwitchMoveValidCheck(logRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + else + { + ; /**/ + } + + /*λǷȷ*/ + if (CI_SUCCESS == reResult) + { + /* ·еλȷ ȷCI_SUCCESS ȷתRETURN_LOCK_ERR_SWITPOS*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteSwitchPosCheck(logRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, ESEND_LEVEL_ZERO); + /* ʧܷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + + } + } + else + { + ; /**/ + } + + /*λǷȷ*/ + if (CI_SUCCESS == reResult) + { + /* ·зλȷ ȷCI_SUCCESS ȷתRETURN_LOCK_ERR_SWITPOS*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteProSwitchPosCheck(logRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, ESEND_LEVEL_ZERO); + /* ʧܷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + + } + } + else + { + ; /**/ + } + + /* ؽ */ + return reResult; +} + +/** +* @brief ߼· +* @param UINT16 routeId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* @noteCI_ERROR CI_SUCCESS +*/ +UINT8 LogRouteSwitchFLockCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState, UINT8* pYLockAlarmFlag) +{ + /* ·*/ + UINT16 const checkSum = GetLogicalRouteInLogSecSum(routeId); + UINT16* const pDataIdBuf = GetLogicalRouteInLogSecId(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 ret = CI_ERROR; + + if (0U == checkSum) + { + /*ݴ*/ + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = pDataIdBuf[i]; + + ret = LogicSecRelSwitchFLockCheck(devId, pDevId, pDevState, pYLockAlarmFlag); + + /* ʧ */ + if (CI_SUCCESS != ret) + { + /*״̬һ·ع״̬*/ + + ret = CI_ERROR; + break; + } + else + { + /* ִ*/ + } + + } + } + + /*ȫͨ*/ + return ret; +} + +/* +* ߼· +* ˵ UINT16 routeId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteProSwitchFLockCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState, UINT8* pYLockAlarmFlag) +{ + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 ret = CI_ERROR; + /* ·*/ + UINT16 checkSum = 0U; + UINT16* pDataIdBuf = NULL; + checkSum = GetLogicalRouteInLogSecSum(routeId); + pDataIdBuf= GetLogicalRouteInLogSecId(routeId); + + if (0U == checkSum) + { + /*ݴ*/ + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = pDataIdBuf[i]; + + ret = LogicSecRltvPrtctSwFLockCheck(devId, pDevId, pDevState, pYLockAlarmFlag); + + /* ʧ */ + if (CI_SUCCESS != ret) + { + /*״̬һ·ع״̬*/ + ret = CI_ERROR; + break; + } + else + { + /* ִ*/ + } + + } + } + + /*ȫͨ*/ + return ret; +} + +/* +* ߼· +* ˵ UINT16 routeId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteCeFangSwitchCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState) +{ + /* ·*/ + UINT16 const checkSum = GetLogicalRouteInLogSecSum(routeId); + UINT16* const dataIdBuf = GetLogicalRouteInLogSecId(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 reVal = CI_ERROR; + + if ((0u == checkSum) || (NULL == pDevId) || (NULL == pDevState)) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i]; + reVal = LogicSecSwitchLtrlDfncCheck(devId, pDevId, pDevState); + if (CI_SUCCESS == reVal) + { + /* ͨ*/ + } + else + { + /*״̬һ·ع״̬*/ + reVal = CI_ERROR; + break; + } + } + } + /*ȫͨ*/ + return reVal; +} + +/* +* ߼·ȫ豸 +* ˵ UINT16 logRouteId, ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteContactLineDevSwitCheck(UINT16 const logRouteId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reVal = CI_ERROR; + UINT16 LogSectionSum = 0U; + UINT16 ii = 0U; + UINT16 *pLogicSecId = NULL; + + /*߼ߵ*/ + LogSectionSum = GetLogicalRouteInLogSecSum(logRouteId); /*ȡ߼·߼*/ + pLogicSecId = GetLogicalRouteInLogSecId(logRouteId); + if (0u == LogSectionSum) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (ii = 0U; ii < LogSectionSum; ii++) + { + reVal = LogicContactLineDevCheck(pLogicSecId[ii], functionId, sendLevel); + if (reVal == CI_SUCCESS) + { + ; /*ͨ*/ + } + else + { + reVal = CI_ERROR; + break; + } + } + } + return reVal; +} + +/* +* ߼· +* ˵ UINT16 routeId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteProtectLockSwitchCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState) +{ + /* ·*/ + UINT16 const checkSum = GetLogicalRouteInLogSecSum(routeId); + UINT16* const dataIdBuf = GetLogicalRouteInLogSecId(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 reVal = CI_ERROR; + + if ((0u == checkSum) || (NULL == pDevId) || (NULL == pDevState)) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i]; + reVal = LogicSecRltvPrtctSwLockCheck(devId, pDevId, pDevState); + if (CI_SUCCESS == reVal) + { + /* ͨ*/ + } + else + { + /*״̬һ·ع״̬*/ + reVal = CI_ERROR; + break; + } + } + } + /*ȫͨ*/ + return reVal; +} + +/* +* ߼·λǷɶ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteSwitchMoveValidCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState) +{ + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 ret = CI_ERROR; + UINT8 logRouteSwitchMoveFlag = 0U; + + /* ·*/ + UINT16 const checkSum = GetLogicalRouteInLogSecSum(routeId); + UINT16* const pDataIdBuf = GetLogicalRouteInLogSecId(routeId); + + + if (0U == checkSum) + { + /*ݴ*/ + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + + logRouteSwitchMoveFlag = GetLogicalRouteSwitchMoveFlag(routeId); + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = pDataIdBuf[i]; + + ret = LogicSwitchMoveValidCheck(devId, logRouteSwitchMoveFlag, pDevId, pDevState, (UINT8)1U); + + /* ʧ */ + if (CI_SUCCESS != ret) + { + ret = CI_ERROR; + break; + } + else + { + /* ִ*/ + } + + } + } + + /*ȫͨ*/ + return ret; +} + +/* +* ߼·λǷɶ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteProSwitchMoveValidCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState) +{ + /* ·*/ + UINT16 const checkSum = GetLogicalRouteInLogSecSum(routeId); + UINT16* const pDataIdBuf = GetLogicalRouteInLogSecId(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 ret = CI_ERROR; + UINT8 logRouteSwitchMoveFlag = 0U; + + if (0U == checkSum) + { + /*ݴ*/ + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + + logRouteSwitchMoveFlag = GetLogicalRouteSwitchMoveFlag(routeId); + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = pDataIdBuf[i]; + + ret = LogicProSwitchMoveValidCheck(devId, logRouteSwitchMoveFlag, pDevId, pDevState, (UINT8)1U); + + /* ʧ */ + if (CI_SUCCESS != ret) + { + /*״̬һ·ع״̬*/ + ret = CI_ERROR; + break; + } + else + { + /* ִ*/ + } + + } + } + + /*ȫͨ*/ + return ret; +} + + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LogRouteSwitchRelaySecCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /*߼·ڵһ߼δ*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteSwOtherLogLockCheck(logRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*߼·ڵεķǽ·ҷǵ߼δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteOutLogSecLockCheck(logRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + /* ؽ */ + return reResult; +} + + + +/* +* ߼·ڵһ߼ռ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteSwOtherLogLockCheck(UINT16 const logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT16 checkOtherSum = 0U; /*߼*/ + UINT16* dataOtherIdBuf = NULL; + UINT16 i = 0U; /* ѭ */ + UINT16 devId = 0U; + UINT8 devState = 0U; + UINT8 cLogicLockState = 0U; + UINT8 reVal = CI_ERROR; + UINT8 cLogicLockBelongRouteNum = 0U; + + checkOtherSum = GetLogRInSwitOtherPosLogSecSum(logRouteId); + dataOtherIdBuf = GetLogRInSwitOtherPosLogSecID(logRouteId); + + /*·ڵķǽ·߼״̬*/ + if ((NULL == dataOtherIdBuf) || (NULL == pDevId) || (NULL == pDevState)) + { + /*ݴָΪ*/ + reVal = CI_ERROR; + } + else if (checkOtherSum == 0u) + { + /*·سɹ*/ + reVal = CI_SUCCESS; + } + else + { + /*ʼ*/ + reVal = CI_SUCCESS; + /* ·ڵķǽ·߼״̬δա */ + for (i = 0u; i < checkOtherSum; i++) + { + devId = dataOtherIdBuf[i]; + devState = GetLogSecLockState(devId); + cLogicLockState = GetLogSecLogLockState(devId); /*ȡ߼߼״̬*/ + cLogicLockBelongRouteNum = GetLogSecLockBelLogRouteSum(devId); /*ȡ߼߼·*/ + + if ((LOG_SECTION_LOCK_NO == devState) && (LOG_SECTION_LOGLOCK_NO == cLogicLockState) && (0U == cLogicLockBelongRouteNum)) + { + /* δδ߼߼·Ϊ0سɹ */ + } + else + { + /*״̬*/ + *pDevId = devId; + if (LOG_SECTION_LOCK_NO == devState) + { + *pDevState = cLogicLockState; + } + else + { + *pDevState = devState; + } + reVal = CI_ERROR; + } + if (CI_ERROR == reVal) + { + break; + } + else + { + ; /**/ + } + } + } + + return reVal; + +} + +/** +* @brief ߼·ڵεķǽ·ҷǵ߼ռ +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteOutLogSecLockCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + /* ·ڷǽ·ҷǵ߼*/ + UINT16 checkSum = 0u; /*߼*/ + UINT16* dataIdBuf = NULL; + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + UINT8 cLogicLockState = 0u; + UINT8 cLogicLockBelongRouteNum = 0u; + + checkSum = GetLogicalRouteOutLogSecSum(logRouteId); + dataIdBuf = GetLogicalRouteOutLogSecID(logRouteId); + + + /*߼Ρδա*/ + if ((NULL == dataIdBuf) || (NULL == pDevId) || (NULL == pDevState)) + { + /*ݴָΪ*/ + reVal = CI_ERROR; + } + else if (0u == checkSum) + { + /*δ߼Σسɹ*/ + reVal = CI_SUCCESS; + } + else + { + reVal = CI_SUCCESS; + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i]; + devState = GetLogSecLockState(devId); + cLogicLockState = GetLogSecLogLockState(devId); /*ȡ߼߼״̬*/ + cLogicLockBelongRouteNum = GetLogSecLockBelLogRouteSum(devId); /*ȡ߼߼·*/ + + if ((LOG_SECTION_LOCK_NO == devState) && (LOG_SECTION_LOGLOCK_NO == cLogicLockState) && (0U == cLogicLockBelongRouteNum)) + { + /* δδ߼߼·Ϊ0سɹ */ + } + else + { + /*״̬*/ + *pDevId = devId; + if (LOG_SECTION_LOCK_NO == devState) + { + *pDevState = cLogicLockState; + } + else + { + *pDevState = devState; + } + reVal = CI_ERROR; + break; + } + } + } + + /*ȫͨ*/ + return reVal; + +} + + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @return CI_ERROR ͨ +* CI_SUCCESS ͨ +* @noteby LC +*/ +UINT8 LogRouteIntruSecCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; /*߼ID*/ + UINT8 devState = 0u; /**/ + UINT8 reResult = CI_ERROR; + UINT8 checkResult = CI_ERROR; + /*·߼*/ + UINT16 const checkSum = GetLogicalRouteInLogSecSum(logRouteId); + UINT16* const pDataIdBuf = GetLogicalRouteInLogSecId(logRouteId); + + /* ռü */ + if (0U == checkSum) + { + /*ݴ*/ + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = pDataIdBuf[i]; + /*߼*/ + checkResult = LogicIntruSecVainCheck(devId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + break; + } + + } + } + + /*ȫͨ*/ + return reResult; +} + + +/** +* @brief ߼·Ƿɹ +* @param wLogRouteId ߼·ID +* UINT8 functionId,ú +* UINT8 sendLevel,뷢ͼ +* @return CI_ERROR ͨ +* CI_SUCCESS ͨ +* @noteby LC +*/ +UINT8 LogRouteUseStateCheck(UINT16 logRouteId) +{ + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 wPhySecId = 0u; /*߼ιID*/ + + UINT8 reResult = CI_ERROR; + + UINT16 wUsingRouteId = 0U;/*ڱõ߼·ID*/ + UINT8 wUsingState = 0U; /*״̬*/ + + + /*·߼*/ + UINT16 const logSecSum = GetLogicalRouteInLogSecSum(logRouteId); + UINT16* const pDataIdBuf = GetLogicalRouteInLogSecId(logRouteId); + + if (0U == logSecSum) + { + /*ݴ*/ + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + /*߼Σʼ*/ + for (i = 0u; i < logSecSum; i++) + { + wPhySecId = GetLgcSecRelativePhySecId(pDataIdBuf[i]); + wUsingRouteId = GetPhySecUseLogRouteId(wPhySecId); + wUsingState = GetPhySecUseState(wPhySecId); + + /*߼״̬ãõ߼·Ϊ߼·*/ + if ((logRouteId == wUsingRouteId)&&(PHYSICAL_SECTION_USING_YES==wUsingState)) + { + /*ͨ*/ + } + else + { + reResult = CI_ERROR; + break; + } + + } + + if (CI_ERROR == reResult) + {/*߼·δ*/ + SetLogRouteSectionUsingState(logRouteId, PHYSICAL_SECTION_USING_NO); + } + } + + /*ȫͨ*/ + return reResult; +} + +/* +* ߼·λ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteSwitchPosCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState) +{ + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; /*߼ID*/ + UINT8 ret = CI_ERROR; + + /* ·߼*/ + UINT16 const checkSum = GetLogicalRouteInLogSecSum(routeId); + UINT16* const pDataIdBuf = GetLogicalRouteInLogSecId(routeId); + + if ((0U == checkSum) || (NULL == pDevId) || (NULL == pDevState)) + { + /*ݴָΪ*/ + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = pDataIdBuf[i]; + + ret = LogicSecRelativeSwitchPosCheck(devId, pDevId, pDevState); + + /* ʧ */ + if (CI_SUCCESS != ret) + { + /*״̬һ·ع״̬*/ + ret = CI_ERROR; + break; + } + else + { + /* ִ*/ + } + + } + } + + /*ȫͨ*/ + return ret; + +} + +/* +* ߼·λ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteProSwitchPosCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState) +{ + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 ret = CI_ERROR; + + /* ·*/ + UINT16 const checkSum = GetLogicalRouteInLogSecSum(routeId); + UINT16* const pDataIdBuf = GetLogicalRouteInLogSecId(routeId); + + if ((0U== checkSum) || (NULL == pDevId) || (NULL == pDevState)) + { + /*ݴָΪ*/ + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = pDataIdBuf[i]; + + ret = LogicSecRltvPrtctSwPosCheck(devId, pDevId, pDevState); + + /* ʧ */ + if (CI_SUCCESS != ret) + { + /*״̬һ·ع״̬*/ + ret = CI_ERROR; + break; + } + else + { + /* ִ*/ + } + + } + } + + /*ȫͨ*/ + return ret; +} + +/* ߼·źű */ +/* +* ߼·źű +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLogRouteSectionCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0U; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + + /* ߼·δ */ + checkResult = LogRoutePhySecFengSuoCheck(wLogRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*߼·״̬߼ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0U; + devState = 0U; + + checkResult = LogNormalLockBylogRouteCheck(wLogRouteId, LOG_SECTION_LOGLOCK_NORMAL, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + /* ߼·״̬ǡ쳣ա + ̬·һ߼δ· + */ + if (CI_SUCCESS == reResult) + { + devId = 0U; + devState = 0U; + + checkResult = LogRouteSectionExceptLockCheck(wLogRouteId, &devId, &devState); + if (CI_SUCCESS== checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0U; + devState = 0U; + checkResult = LogRouteIntruSecCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS== checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + + } + } + else + { + ; /**/ + } + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0U; + devState = 0U; + checkResult = LogRouteJumpLockCheck(wLogRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_JUMP_LOCK, devState, sendLevel); + reResult = CI_ERROR; + } + } + + /*߼·ڷһ߼*/ + if (CI_SUCCESS == reResult) + { + devId = 0U; + devState = 0U; + /*CBTC·ڷһ߼*/ + checkResult = LogRouteFirstLgcSecCheck(wLogRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else if (LOG_ROUTE_TRAIN_CROSS == checkResult) + { + /*гѹͨ*/ + reResult = LOG_ROUTE_TRAIN_CROSS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_OCC_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + return reResult; +} + + +/** +* @brief ߼α߼·״̬ +* @param UINT16 wLogRouteId ߼·ID +* UINT8 checkState Ҫ߼״̬ +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogNormalLockBylogRouteCheck(UINT16 wLogRouteId, UINT8 checkState,UINT16* pDevId, UINT8* pDevState) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT8 logRoutDirection = 0U; /*߼·*/ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 devId = 0U; /*߼ID*/ + UINT8 devState = 0U; /*߼α߼·״̬*/ + UINT8 logSecLockDir = 0U; /*߼α߼·շ,ֻͬһ*/ + + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + logSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + logRoutDirection = GetLogicalRouteDir(wLogRouteId); + + if ((NULL != LogSecIdBuff) && (0U != logSecSum)) + { + retVal = CI_SUCCESS; + + /*ʼ*/ + for (ii = 0; ii < logSecSum; ii++) + { + devId = LogSecIdBuff[ii]; + devState = GetLogSecLogLockState(devId); + + if (devState == checkState) + { + if (LOG_SECTION_LOGLOCK_NO == checkState) + { + /*δա鷽*/ + /* ͨ*/ + } + else + { + logSecLockDir = GetLogSecLogLockDir(devId); + if (logRoutDirection == logSecLockDir) + { + /*߼δ߼·ջշһ*/ + + } + else + { + /*鲻ͨ*/ + retVal = CI_ERROR; + } + } + } + else + { + /*״̬һ·ع״̬ʧ*/ + retVal = CI_ERROR; + } + if (CI_ERROR == retVal) + { + /*鲻ͨ*/ + *pDevId = devId; + *pDevState = devState; + break; + } + } + } + return retVal; +} + +/** +* @brief ߼·߼쳣Լһ߼δ·ռ +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteSectionExceptLockCheck(UINT16 wLogRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 devId = 0U; /*߼ID*/ + UINT8 devState = 0U; /*߼״̬*/ + + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + logSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + + if ((NULL != LogSecIdBuff) && (0U != logSecSum) && (NULL != pDevId) && (NULL!= pDevState)) + { + retVal = CI_SUCCESS; + /*ʼ*/ + devId = LogSecIdBuff[0]; /*̬һ߼Σܱ·*/ + devState = GetLogSecLockState(devId); /*߼·״̬*/ + if (LOG_SECTION_LOCK_NO != devState) + { + if (LOG_SECTION_LOCK_PROTECT == devState) + { + ; /*տԿźţسɹ*/ + } + else + { + retVal = CI_ERROR; + } + } + else + { + ; /**/ + } + if (CI_SUCCESS == retVal) + { + for (ii = 0u; ii < logSecSum; ii++) + { + devId = LogSecIdBuff[ii]; + devState = GetLogSecLockState(devId); /*߼·״̬Ϊ쳣*/ + + if (LOG_SECTION_LOCK_EXCEPT == devState) + { + retVal = CI_ERROR; + break; + } + else + { + ; /**/ + } + + if (CI_SUCCESS == retVal) + { + devState = GetLogSecLogLockState(devId); /*߼߼ι*/ + if (LOG_SECTION_LOGLOCK_EXCEPT == devState) + { + retVal = CI_ERROR; + break; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + } + else + { + ; /**/ + } + + if (CI_ERROR == retVal) + { + *pDevId = devId; + *pDevState = devState; /*¼״̬豸ID*/ + } + else + { + ; /**/ + } + } + return retVal; +} +/* +* ߼·һ߼μ +* ˵ +* UINT16 const wLogRouteId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +*/ +UINT8 LogRouteFirstLgcSecCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState) +{ + UINT16 wLogRouteApplyResTrainId = 0U; + UINT8 chTrainEnterState = 0U; + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT16* LogSecIdBuff = NULL; + UINT8 devState = 0u; /*һ߼ںռѹ״̬*/ + + /*гǷѹ*/ + wLogRouteApplyResTrainId = GetLogicalRouteApplyResTrainId(wLogRouteId); + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + devState = GetLogSecCurOccupyState(LogSecIdBuff[0U]); + chTrainEnterState = dsuLogRouteTrainCrossSignal(wLogRouteApplyResTrainId, wLogRouteId); + + if ((NULL != pDevId) && (NULL != pDevState)) + { + if (TRAIN_ENTER_ROUTE_FULL == chTrainEnterState) + { + /*гȫʻ߼··ص by cgh 20231128*/ + reResult = LOG_ROUTE_TRAIN_CROSS; + } + else if (TRAIN_ENTER_ROUTE_HEAD == chTrainEnterState) + { + /*гʻ߼·δѹص*/ + reResult = CI_SUCCESS; + } + else if (TRAIN_ENTER_ROUTE_CROSS == chTrainEnterState) + { + /*гѹźŻжϵһ߼ռѹ״̬*/ + + if (SECTION_OCCUPY_NO == devState) + {/*һ߼ں״̬δռѹصƣȴռѹ */ + reResult = CI_SUCCESS; + } + else + {/*һ߼ں״̬ռѹ ص*/ + reResult = LOG_ROUTE_TRAIN_CROSS; + } + } + else if ((TRAIN_ENTER_ROUTE_NO == chTrainEnterState) + || (CI_ERROR == chTrainEnterState) + || (TRAIN_ENTER_ROUTE_TAIL == chTrainEnterState)) + { + /*гʻгδߣгδѹص*/ + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + + if (CI_ERROR == reResult) + { + *pDevId = LogSecIdBuff[0U]; + *pDevState = devState; + } + } + return reResult; +} + +/** +* @brief ߼·ڲ߼Ƿȫ +* @param wLogRouteId ߼·ID +* @return CI_ERROR ͨ +* CI_SUCCESS ͨ +* : fan 2023-10-11 +*/ +UINT8 LogRouteLogSecReleaseCheck(UINT16 logRouteId) +{ + /* ֲʼ */ + UINT16 ii = 0u; /* ѭ */ + UINT16 devId = 0u; /*߼ID*/ + UINT8 reResult = CI_SUCCESS; + UINT8 checkResult = CI_ERROR; + /*·߼*/ + UINT16 routeLogNum = GetLogicalRouteInLogSecSum(logRouteId); + UINT16* routeLogSecId = GetLogicalRouteInLogSecId(logRouteId);/*߼ID*/ + for (ii = 0u; ii < routeLogNum; ii++) + { + devId = routeLogSecId[ii];/*ȡǰ߼ID*/ + + /*ij߼ζԸ߼·Ľ*/ + checkResult = CheckLogRouteIdBelLogSec(devId, logRouteId); + if (0U == checkResult) + /*δջ߲߼·*/ + { + reResult = CI_SUCCESS; + } + else + { + /*ʧ*/ + reResult = CI_ERROR; + break; + } + } + + /*ȫͨ*/ + return reResult; +} +/* ߼·źűźŻ */ +/* +* ߼·źűźŻ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLogRouteSignalCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + UINT8 devColor = 0U; /*źŻɫ*/ + UINT16 wLogRouteSignalId = 0U; + UINT8 FSwitchFlag = 0u; + + wLogRouteSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + + /* ߼ */ + + /* ߼·ʼźŻɫΪš*/ + devColor = GetSignalPreDriveColor(wLogRouteSignalId); + devState = GetSignalOpenCloseState(devColor); + if (SIGNAL_OPEN == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, wLogRouteSignalId, ETYPE_SIG_START_OPEN_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + + if (CI_SUCCESS == reResult) + { + FSwitchFlag = GetCiFunctionSwitchConfig(CLOSE_OPENED_SIG_LOCK_SIGNAL); + if (FUNC_SWITCH_OFF == FSwitchFlag) + { + reResult = CI_SUCCESS; /*δ򲻼źŻ״̬*/ + } + else if (FUNC_SWITCH_ON == FSwitchFlag) + { + + /*߼·źŻδ*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteSignalFLockCheck(wLogRouteId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, wLogRouteSignalId, ETYPE_SIG_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + /**/ + } + } + return reResult; +} + +/* ߼·źſźŻ */ +/* +* ߼·źſźŻ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLogRouteSignalCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + UINT16 wLogRouteSignalId = 0U; + UINT8 FSwitchFlag = 0u; + UINT8 signalCurColor = 0u; + + wLogRouteSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + + /* ߼ */ + + /* ·ʼźŻδ*/ + signalCurColor = GetSignalCurColor(wLogRouteSignalId); + devState = GetSignalOpenCloseState(signalCurColor); + if (SIGNAL_CLOSE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, wLogRouteSignalId, ETYPE_SIG_START_OPEN_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + FSwitchFlag = GetCiFunctionSwitchConfig(CLOSE_OPENED_SIG_LOCK_SIGNAL); + if (FUNC_SWITCH_OFF == FSwitchFlag) + { + reResult = CI_SUCCESS; /*δ򲻼źŻ״̬*/ + } + else if (FUNC_SWITCH_ON == FSwitchFlag) + { + + /*߼·źŻδ*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteSignalFLockCheck(wLogRouteId, &devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, wLogRouteSignalId, ETYPE_SIG_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + /**/ + } + } + return reResult; +} + +/* +* ߼·źŻ״̬ +* ˵ UINT16 const wLogRouteId, ߼·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteSignalFLockCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT8 signalEndSum = 0U; + UINT8 signalBeginSum = 0U; + UINT16* signalEndIdBuff = NULL; + UINT16* signalBeginIdBuff = NULL; + UINT8 retVal = CI_ERROR; + UINT16 wLogSecId = 0U; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 devId = 0U; /*źŻID*/ + UINT8 devState = 0U; /*źŻ״̬*/ + + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + logSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + + if ((NULL != LogSecIdBuff) && (0U != logSecSum)&& (NULL != pDevId) && (NULL != pDevState)) + { + retVal = CI_SUCCESS; + + /*ʼ*/ + for (ii = 0U; ii < logSecSum; ii++) + { + wLogSecId = LogSecIdBuff[ii]; + signalBeginSum = GetLogRelateBeginSigSum(wLogSecId); + signalBeginIdBuff = GetLogRelateBeginSigData(wLogSecId); + signalEndSum = GetLogRelateEndSigSum(wLogSecId); + signalEndIdBuff = GetLogRelateEndSigData(wLogSecId); + + if ((0U != signalBeginSum) && (NULL != signalBeginIdBuff)) + { + for (jj = 0U; jj < signalBeginSum; jj++) + { + devId = signalBeginIdBuff[jj]; + devState = GetSignalFLockState(devId); + if (SIGNAL_FENGSUO_NO == devState) + { + /* ͨ*/ + retVal = CI_SUCCESS; + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + break; + } + + } + } + + if (CI_SUCCESS == retVal) + { + if ((0U != signalEndSum) && (NULL != signalEndIdBuff)) + { + devId = 0U; + devState = 0U; + for (jj = 0U; jj < signalEndSum; jj++) + { + devId = signalEndIdBuff[jj]; + devState = GetSignalFLockState(devId); + if (SIGNAL_FENGSUO_NO == devState) + { + /* ͨ*/ + retVal = CI_SUCCESS; + } + else + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + retVal = CI_ERROR; + break; + } + + } + } + } + if (CI_ERROR == retVal) + { + break; + } + } + } + return retVal; +} + +/* ߼·źűֵ */ +/* +* ߼·źűֵ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLogRouteSwitchCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0U; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + UINT8 cYLockAlarmFlag = FLAG_UNSET; /*־*/ + + /*߼·еδ δ*/ + checkResult = LogRouteSwitchFLockCheck(wLogRouteId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + cYLockAlarmFlag = FLAG_UNSET; + checkResult = LogRouteProSwitchFLockCheck(wLogRouteId, &devId, &devState, &cYLockAlarmFlag); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + if (FLAG_SET == cYLockAlarmFlag) + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + } + else + { + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + } + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*λǷȷ*/ + if (CI_SUCCESS == reResult) + { + /* ·еλȷ ȷCI_SUCCESS ȷתRETURN_LOCK_ERR_SWITPOS*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteSwitchPosCheck(wLogRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + + } + } + else + { + ; /**/ + } + + /*λǷȷ*/ + if (CI_SUCCESS == reResult) + { + /* ·зλȷ ȷCI_SUCCESS ȷתRETURN_LOCK_ERR_SWITPOS*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteProSwitchPosCheck(wLogRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_POSTION_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + + } + } + else + { + ; /**/ + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteCeFangSwitchCheck(wLogRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == reResult) + { + /*߼·豸*/ + checkResult = LogRouteContactLineDevSwitCheck(wLogRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteProtectLockSwitchCheck(wLogRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + ; /**/ + } + + return reResult; +} + +/* +* ߼Ϊ߼·յĵһμ +* ˵ const UINT16 wLogSectionId, ߼ID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +* by cgh 20231013 +*/ +UINT8 LogSecLogRouteFirstLockCheck(const UINT16 wLogSectionId) +{ + UINT8 chReVal = CI_ERROR; + UINT8 chLogSecLockBelLogRouteSum = 0U;/*߼߼·Ŀ*/ + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT8 ii = 0U; + UINT16 wLogSecBelLogRouteId = 0U;/*߼߼·ID*/ + UINT16 wFirstNormalLockLogId = 0U; /*߼·һյ߼ID*/ + + if ((0U < wLogSectionId) && (LOGIC_SECTION_SUM_MAX > wLogSectionId)) + { + chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSectionId); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSectionId); + + if (NULL != szLogSecLockBelLogRouteData) + { + if (1U == chLogSecLockBelLogRouteSum) + { + chReVal = CI_SUCCESS; + } + else if ((1U < chLogSecLockBelLogRouteSum) && (LOGSEC_RELATE_ROUTE_SUM_MAX > chLogSecLockBelLogRouteSum)) + { + chReVal = CI_SUCCESS; + for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++) + { + wLogSecBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId; + wFirstNormalLockLogId = GetLogRouteFirNormalLockLogId(wLogSecBelLogRouteId); + if ((wLogSectionId != wFirstNormalLockLogId) && (0U != wFirstNormalLockLogId)) + { + /*ǰ߼α߼·գǶ߼·һյ߼Σʽ*/ + chReVal = CI_ERROR; + break; + } + } + } + else + { + ; /*Ĭϼ鲻ͨ*/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + return chReVal; +} + +/* ߼·źűվ̨ */ +/* +* ߼·źűվ̨ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLogRoutePlatformCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0U; /*豸ID*/ + UINT8 devState = 0U; /*豸״̬*/ + + /* ߼ */ + + /* վ̨PSDESBȣм */ + /*ӷ·*/ + /*վ̨رհťδ*/ + checkResult = LogRouteEsbVainCheck(wLogRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ESB, devId, ETYPE_ESB_VALID, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*վ̨ȫŹرջ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRoutePsdCloseCheck(wLogRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PSD, devId, ETYPE_PSD_CLOSE_NO, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /*վ̨δʵʩ۳ҵ*/ + + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = LogRouteDetainCheck(wLogRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SIGNAL, devId, ETYPE_PLAT_DETAIN, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + return reResult; +} + +/* +* ߼·վ̨رհťЧ +* ˵ UINT16 const wLogRouteId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteEsbVainCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState) +{ + /*ESB*/ + UINT8 checkSum = 0U; + UINT16 *dataIdBuf = NULL; + UINT8 reVal = CI_ERROR; + UINT16 wLogRouteSignalId = 0U; + UINT8 i = 0U; /* ѭ */ + UINT16 devId = 0U; + UINT8 devState = 0U; + UINT8 devCutState = 0U; + + wLogRouteSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + checkSum = GetSignalRelatedEsbSum(wLogRouteSignalId); + dataIdBuf = GetSignalRelatedEsbBuf(wLogRouteSignalId); + + if ((NULL == pDevId) || (NULL == pDevState) || (NULL == dataIdBuf)) + { + /*ָʧ*/ + reVal = CI_ERROR; + } + else if (0u == checkSum) + { + /*ESBť޼*/ + reVal = CI_SUCCESS; + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i]; + devState = GetEsbState(devId); + devCutState = GetEsbCutState(devId); + if ((devState == ESB_STATE_VALID_NO) || (ESB_CUT_YES == devCutState)) + { + /* Ч*/ + + } + else + { + /*Ч*/ + *pDevId = (UINT16)devId; + *pDevState = devState; + reVal = CI_ERROR; + break; + } + } + } + + return reVal; +} + +/* +* ߼·վ̨Źرռ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRoutePsdCloseCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState) +{ + /*PSD*/ + UINT8 checkSum = 0U; + UINT16 *dataIdBuf = NULL; + UINT16 i = 0U; /* ѭ */ + UINT16 devId = 0U; + UINT8 devState = 0U; + UINT8 reVal = CI_ERROR; + UINT16 wLogRouteSignalId = 0U; + UINT8 psdMutualLockState = 0u; + + wLogRouteSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + checkSum = GetSignalRelatedPsdSum(wLogRouteSignalId); + dataIdBuf = GetSignalRelatedPsdBuf(wLogRouteSignalId); + + if ((NULL == pDevId) || (NULL == pDevState) || (NULL == dataIdBuf)) + { + /*ָΪշʧ*/ + reVal = CI_ERROR; + } + /* վ̨״̬ */ + else if (0u == checkSum) + { + /*PSD飬޼*/ + reVal = CI_SUCCESS; + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i]; + devState = GetPsdState(devId); + psdMutualLockState = GetPsdMutualLockRemoveState(devId); + if ((PSD_STATE_CLOSE == devState) || (PSD_MUTUALLOCK_REMOVE_YES == psdMutualLockState) + || (PSD_ATS_MUTUALLOCK_REMOVE_YES == psdMutualLockState) || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == psdMutualLockState)) + { + /* վ̨ȫŹرջ */ + + } + else + { + /* */ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + break; + } + } + } + + return reVal; +} + +/* +* ߼·վ̨δ۳ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteDetainCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState) +{ + UINT16 devId = 0U; + UINT8 devState = 0U; + UINT8 reVal = CI_ERROR; + + devId = GetLogicalRouteRelateBeginSigId(wLogRouteId); /*ȡ߼·źŻ*/ + devState = GetSignalDetainFlag(devId); + + if ((NULL == pDevId) || (NULL == pDevState)) + { + reVal = CI_ERROR; + } + else if (SIGNAL_DETAIN_NO == devState) + { + /* ͨ */ + reVal = CI_SUCCESS; + } + else + { + /* ¼ */ + *pDevId = devId; + *pDevState = devState; + /* ʧܷ */ + reVal = CI_ERROR; + + } + return reVal; +} + + +/* +* Ƿ߼·ռ +* ˵ UINT16 const wPhySectionId, ID +* ֵ 0 ݷǷУʧ +* >0 ߼·״̬ +* by cgh 20231014 +*/ +UINT8 PhySecLogLockStateCheck(UINT16 const wPhySectionId) +{ + UINT8 chReval = CI_ERROR; + UINT16 wPhyIncLogSecSum = 0U;/*ΰ߼Ŀ*/ + UINT16* szPhyIncLogSecIdBuf = NULL;/*ΰ߼ID*/ + UINT16 ii = 0U; + UINT8 chLogSecLogLockState = 0U;/*߼߼״̬*/ + + if ((0U < wPhySectionId) && (PHYSICAL_SECTION_SUM_MAX > wPhySectionId)) + { + wPhyIncLogSecSum = GetPhySecIncLogSecSum(wPhySectionId); + szPhyIncLogSecIdBuf = GetPhySecIncLogSecIdBuf(wPhySectionId); + + if (NULL != szPhyIncLogSecIdBuf) + { + for (ii = 0U; ii < wPhyIncLogSecSum; ii++) + { + chLogSecLogLockState = GetLogSecLogLockState(szPhyIncLogSecIdBuf[ii]); + if (LOG_SECTION_LOGLOCK_NO != chLogSecLogLockState) + { + /*һ߼״̬Ϊ߼δգ*/ + break; + } + } + + if (wPhyIncLogSecSum == ii) + { + /*е߼ξΪδգͨ*/ + chReval = LOG_SECTION_LOGLOCK_NO; + } + else + { + /*߼߼״̬Ϊδգ״̬*/ + chReval = chLogSecLogLockState; + } + } + else + { + chReval = CI_ERROR; /*ĬϷؼʧ*/ + } + + } + else + { + chReval = CI_ERROR; /*ĬϷؼʧ*/ + } + return chReval; +} + +/* +* Ƿ߼·ռ +* ˵ UINT16 const wPhySectionId, ID +* ֵ 0 ݷǷУʧ +* >0 ߼·״̬ +* by cgh 20231014 +*/ +UINT8 AixsSecLogLockStateCheck(UINT16 const wAxisSectionId) +{ + UINT8 chReval = CI_ERROR; + UINT16 axisRelativeLogSecNum = 0U;/*ΰ߼Ŀ*/ + UINT16* axisRelativeLogSecIdBuf = NULL;/*ΰ߼ID*/ + UINT16 ii = 0U; + UINT8 chLogSecLogLockState = 0U;/*߼߼״̬*/ + + if ((0U < wAxisSectionId) && (AXIS_SECTION_SUM_MAX > wAxisSectionId)) + { + + /** ȡι߼ID*/ + axisRelativeLogSecNum = GetAxisSecLogSectionSum(wAxisSectionId); + axisRelativeLogSecIdBuf = GetAxisSecLogSectionIdBuf(wAxisSectionId); + + if (NULL != axisRelativeLogSecIdBuf) + { + for (ii = 0U; ii < axisRelativeLogSecNum; ii++) + { + chLogSecLogLockState = GetLogSecLogLockState(axisRelativeLogSecIdBuf[ii]); + if (LOG_SECTION_LOGLOCK_NO != chLogSecLogLockState) + { + /*һ߼״̬Ϊ߼δգ*/ + break; + } + } + + if (axisRelativeLogSecNum == ii) + { + /*е߼ξΪδգͨ*/ + chReval = LOG_SECTION_LOGLOCK_NO; + } + else + { + /*߼߼״̬Ϊδգ״̬*/ + chReval = chLogSecLogLockState; + } + } + else + { + chReval = CI_ERROR; /*ĬϷؼʧ*/ + } + + } + else + { + chReval = CI_ERROR; /*ĬϷؼʧ*/ + } + return chReval; +} + +/* +* ߼·ڵһ߼δռ +* ˵ UINT16 const logRouteId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221005 Ż·飬·ʱһλù߼δ +*/ +UINT8 LogRouteSwOtherLogLockValCheck(UINT16 const logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + /* ·*/ + UINT16 const checkOtherSum = GetRouteSwitOtherLogSecSum(logRouteId); + UINT16* const dataOtherIdBuf = GetRouteSwitOtherPosLogSecIdBuf(logRouteId); + + /* ֲʼ */ + UINT16 j = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + UINT8 cLogicLockState = 0U; /*߼߼״̬*/ + UINT8 cLogicLockBelongRouteNum = 0U; /*߼߼·*/ + + /*·ڵķǽ·߼״̬*/ + if (NULL == dataOtherIdBuf) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else if (checkOtherSum == 0u) + { + /*·سɹ*/ + reVal = CI_SUCCESS; + } + else + { + /*ʼ*/ + reVal = CI_SUCCESS; + /* ·ڵķǽ·߼״̬δա */ + for (j = 0u; j < checkOtherSum; j++) + { + devId = dataOtherIdBuf[j]; + devState = GetLogSecLockState(devId); + cLogicLockState = GetLogSecLogLockState(devId); /*ȡ߼߼״̬*/ + cLogicLockBelongRouteNum = GetLogSecLockBelLogRouteSum(devId); /*ȡ߼߼·*/ + + if ((LOG_SECTION_LOCK_NO == devState) && (LOG_SECTION_LOGLOCK_NO == cLogicLockState) && (0U == cLogicLockBelongRouteNum)) + { + /* δδ߼߼·Ϊ0سɹ */ + } + else + { + /*״̬*/ + *pDevId = devId; + if (LOG_SECTION_LOCK_NO == devState) + { + *pDevState = cLogicLockState; + } + else + { + *pDevState = devState; + } + reVal = CI_ERROR; + } + if (CI_ERROR == reVal) + { + break; + } + else + { + ; /**/ + } + } + } + + return reVal; +} + + +/* +* ߼·εķǽ·ҷǵ߼ЧԼ +* ˵ UINT16 const logRouteId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ⶯ +*/ +UINT8 LogRouteOutLogSecOccClearCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState) +{ + /* ·εķǽ·ҷǵ߼*/ + UINT16 const checkSum = GetRouteOutLogSecSum(routeId); + UINT16* const dataIdBuf = GetRouteOutLogSecSumIdBuf(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 reVal = CI_ERROR; + + + /**/ + /*߼Ρδա*/ + if (NULL == dataIdBuf) + { + /*ݴ*/ + reVal = CI_ERROR; + } + else if (checkSum == 0u) + { + /*δ߼Σسɹ*/ + reVal = CI_SUCCESS; + } + else + { + reVal = CI_SUCCESS; + for (i = 0u; i < checkSum; i++) + { + devId = dataIdBuf[i]; + devState = GetLogSecCurOccupyState(devId); + + if (SECTION_OCCUPY_NO == devState) + { + /* δռѹ */ + + } + else + { + /*״̬*/ + *pDevId = devId; + *pDevState = devState; + reVal = CI_ERROR; + break; + } + } + } + + /*ȫͨ*/ + return reVal; +} + +/* +* ߼·һյ߼εһ߼״̬ +* ˵ const UINT16 wLogRouteId ߼·ID +* const UINT16 wLogSecId ߼ID +* ֵ CI_ERROR һ߼״̬鲻ͨ +* CI_SUCCESS һ߼״̬ͨ +* by cgh 20231016 +*/ +UINT8 CheckLogRouteLogSecLastSecLock(const UINT16 wLogRouteId, const UINT16 wLogSecId) +{ + UINT8 ii = 0U; + UINT8 chReval = CI_ERROR; + UINT8 chLogSecLastSecSum = 0U;/*߼һ߼Ŀ*/ + UINT16* wLogSecLastSecIdBuf = NULL;/*߼һ߼ID*/ + UINT8 chLastLogSecLockState = 0U;/*һ߼״̬*/ + UINT8 chLastLogSecLogLockState = 0U;/*һ߼߼״̬*/ + UINT8 chLogRouteDir = 0U;/*߼·Ӫ*/ + UINT8 chLogRouteLogicDir = 0U;/*߼·߼*/ + UINT8 chLogSecLogLockDir = 0U;/*߼߼״̬*/ + UINT8 chLastLogSecLockDir = 0U;/*һ߼շ*/ + UINT8 chLastLogSecLogLockDir = 0U;/*һ߼߼շ*/ + UINT8 chCheckFlag = 0U;/*־*/ + + chLogRouteDir = GetLogicalRouteDir(wLogRouteId); + chLogRouteLogicDir = ConvertDirectionToLogic(chLogRouteDir); + chLogSecLogLockDir = GetLogSecLogLockDir(wLogSecId); + + if (DIR_SAME == chLogRouteLogicDir) + { + chLogSecLastSecSum = GetLogBeginLogSecSum(wLogSecId); + wLogSecLastSecIdBuf = GetLogBeginLogSecData(wLogSecId); + } + else if(DIR_CONVERT == chLogRouteLogicDir) + { + chLogSecLastSecSum = GetLogEndLogSecSum(wLogSecId); + wLogSecLastSecIdBuf = GetLogEndLogSecData(wLogSecId); + } + else + { + ;/*ش*/ + } + + if (NULL != wLogSecLastSecIdBuf) + { + if (0U != chLogSecLastSecSum) + { + for (ii = 0U; ii < chLogSecLastSecSum; ii++) + { + chLastLogSecLockState = GetLogSecLockState(wLogSecLastSecIdBuf[ii]); + chLastLogSecLogLockState = GetLogSecLogLockState(wLogSecLastSecIdBuf[ii]); + chLastLogSecLockDir = GetLogSecLockDir(wLogSecLastSecIdBuf[ii]); + chLastLogSecLogLockDir = GetLogSecLogLockDir(wLogSecLastSecIdBuf[ii]); + + if ((LOG_SECTION_LOCK_NO == chLastLogSecLockState) && (LOG_SECTION_LOGLOCK_NO == chLastLogSecLogLockState)) + { + ; /*߼״̬߼״̬Ϊδգ*/ + } + else + { + if (LOG_SECTION_LOCK_NO == chLastLogSecLockState) + { + if (chLastLogSecLogLockDir != chLogSecLogLockDir) + { + ;/*߼δյ߼״̬Ϊδգʱͬͨ*/ + } + else + { + chCheckFlag = 1U; + } + } + else if (LOG_SECTION_LOGLOCK_NO == chLastLogSecLogLockState) + { + if (chLastLogSecLockDir != chLogSecLogLockDir) + { + ;/*߼βΪδյ߼״̬Ϊδ߼գʱͬͨ*/ + } + else + { + chCheckFlag = 1U; + } + } + else + { + /*״̬Ϊ*/ + if ((chLastLogSecLockDir != chLogSecLogLockDir) && (chLastLogSecLogLockDir != chLogSecLogLockDir)) + { + ;/*ͨ*/ + } + else + { + chCheckFlag = 1U; + } + } + + if (1U == chCheckFlag) + { + SetErrorData(EFUNC_LOGSEC_LAST_SECLOCK, CI_DEVICE_TYPE_LOGICSEC, wLogSecLastSecIdBuf[ii], + ETYPE_LOGSEC_LOCK_STATE, chCheckFlag, ESEND_LEVEL_ZERO); + break; /**/ + } + else + { + ; /**/ + } + + } + } + if (chLogSecLastSecSum == ii) + { + /*ξΪδգسɹ*/ + chReval = CI_SUCCESS; + } + } + else + { + /*ĿΪ0·ͷسɹ*/ + chReval = CI_SUCCESS; + } + } + else + { + ; /**/ + } + + return chReval; +} + +/* +* ȡָID߼·Դ߼ +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: ߼·Ԥ +* CI_ERROR: ߼·Ԥ +*/ +UINT8 CheckLgcSecInLogRoute(const UINT16 wLogRouteId, const UINT16 lgcSecId) +{ + UINT8 reVal = CI_ERROR; + UINT16 wLogRouteLogSecSum = 0U; /*г߼*/ + UINT16* wLogRouteLogSecIdBuf = NULL; + UINT8 ii = 0U; + + wLogRouteLogSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + wLogRouteLogSecIdBuf = GetLogicalRouteInLogSecId(wLogRouteId); + + for (ii = 0U; ii < wLogRouteLogSecSum; ii++) + { + if (lgcSecId == wLogRouteLogSecIdBuf[ii]) + { + reVal = CI_SUCCESS; + break; + } + } + + if (ii == wLogRouteLogSecSum) + { + reVal = CI_ERROR; + } + return reVal; +} + +/* +* ȡָID߼·Դ +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT16 phySecId +* ֵ CI_SUCCESS: ߼·Ԥ +* CI_ERROR: ߼·Ԥ +*/ +UINT8 CheckPhySecInLogRoute(const UINT16 wLogRouteId, const UINT16 phySecId) +{ + UINT8 reVal = CI_ERROR; + UINT16 pRoutePhySecIdBuf[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; /*·µID*/ + UINT8 routePhySecSum = 0U; /*·Ŀ*/ + UINT8 ii = 0U; + + /*ȡ߼·Ϣ*/ + routePhySecSum = GetLogicRouteIncPhySec(wLogRouteId, &pRoutePhySecIdBuf); + for (ii = 0U; ii < routePhySecSum; ii++) + { + if (phySecId == pRoutePhySecIdBuf[ii]) + { + reVal = CI_SUCCESS; + break; + } + } + + if (ii == routePhySecSum) + { + reVal = CI_ERROR; + } + return reVal; +} + +/* +* @brief ǷΪͬһгظͬһ߼· +* @param const UINT16 wLogSecSum ߼·߼Ŀ +* @param const UINT16* pLogSecIdbuf ߼·߼ID +* @param const UINT16 wTrainId ߼·гID +* @return 1 ɹ +* 0 ʧ +* @noteCreated by LQ 2023.11.01 +*/ +UINT8 RepeatSetLogicRouteCheck(const UINT16 wLogSecSum, const UINT16* pLogSecIdbuf, const UINT16 wTrainId) +{ + UINT8 retVal = CI_ERROR; + UINT8 cKeepWorkFlag = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 wLogicRouteID = 0U; /*߼·ID*/ + UINT8 cLogicRouteState = 0U; /*߼·״̬*/ + UINT16 wLogicRouteIncLogSecNum = 0U; /*߼·߼*/ + UINT16* pLogicRouteIncLogSecId = NULL; /*߼·߼ID*/ + UINT16 wLogicRouteResTrainId = 0U; /*߼·ԴгID*/ + + if ((0U != wLogSecSum) && (NULL != pLogSecIdbuf)) + { + for (ii = 0U; ii < ROUTE_LOGICAL_SUM_MAX; ii++) + { + wLogicRouteID = GetLogicalRouteId(ii); + cLogicRouteState = GetLogicalRouteState(wLogicRouteID); + + if (ROUTE_LOGICAL_STATE_IDLE != cLogicRouteState) + { + wLogicRouteIncLogSecNum = GetLogicalRouteInLogSecSum(wLogicRouteID); /*ȡ߼·߼*/ + pLogicRouteIncLogSecId = GetLogicalRouteInLogSecId(wLogicRouteID); + wLogicRouteResTrainId = GetLogicalRouteApplyResTrainId(wLogicRouteID); /*ȡ߼·Դг*/ + + if ((wLogicRouteIncLogSecNum == wLogSecSum) && (NULL != pLogicRouteIncLogSecId) && (wLogicRouteResTrainId == wTrainId)) + { + for (jj = 0U; jj < wLogicRouteIncLogSecNum; jj++) + { + if (pLogicRouteIncLogSecId[jj] == pLogSecIdbuf[jj]) + { + cKeepWorkFlag = CI_ERROR; /**/ + } + else + { + cKeepWorkFlag = CI_SUCCESS; /*ڵ߼βظֹͣ*/ + break; + } + } + } + else + { + cKeepWorkFlag = CI_SUCCESS; /*߼ȻԴгȣΪظ߼·*/ + } + } + else + { + retVal = CI_SUCCESS; /*ҵһе߼·ǰǿе߼·δظֹͣسɹ*/ + } + + if ((CI_ERROR == cKeepWorkFlag) || (CI_SUCCESS == retVal)) + { + break; /*ظ߼·ҵһе߼·ִֹͣн*/ + } + else + { + /**/ + } + } + } + else + { + retVal = CI_ERROR; /*ηǷʧ*/ + } + + return retVal; +} + +/* +* @brief ߼·ǷҪʼźŻ +* @param const UINT16 wFstLogSecId ߼·ĵһ߼ID +* @param const UINT8 cLogicRouteDir ߼·߼ +* @param const UINT16 wTrainId ߼·гID +* @return 0 ʼźŻ +* >0 ӵʼźŻID +* @noteCreated by LQ 2023.11.01 +*/ +UINT16 LogicRouteAddStartSignalCheck(const UINT16 wFstLogSecId, const UINT8 cLogicRouteDir, const UINT16 wTrainId) +{ + UINT16 wStartSignalId = 0U; /*߼·ʼźŻID*/ + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 wBufIndex = 0U; + struct_PathPoint start = { 0U }; /*г߼*/ + struct_PathPoint end = { 0U }; /*г߼յ*/ + UINT16 wCTOccLogSum = 0U; /*ͨг߼*/ + UINT16 wCTOccLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*ͨгռѹ߼ID*/ + UINT8 cRelatedStartSigNum = 0U; /*߼ιʼźŻ*/ + UINT16* pRelatedStartSigId = NULL; /*߼ιʼźŻID*/ + UINT16* pLogSecIncLinkId = NULL; /*߼ΰlink ID*/ + UINT8 cSignalProDir = 0U; /*źŻ*/ + UINT16 wSigProLinkId = 0U; /*źŻlink*/ + LOD_STRU strCurPoint = { 0U }; + LOD_STRU strNxtPoint = { 0U }; + UINT8 cDirChangeNum = 0U; /*仯*/ + UINT8 cKeepWork = CI_ERROR; + UINT8 cCommStateWithTrain = CI_ERROR; /*복ͨ״̬*/ + + wBufIndex = GetTrainBufIndex(wTrainId); + + if ((0U != wFstLogSecId) && (LOGIC_SECTION_SUM_MAX != wFstLogSecId) + && ((DIR_CONVERT == cLogicRouteDir) || (DIR_SAME == cLogicRouteDir)) + && (TRAIN_SUM_MAX > wBufIndex)) + { + cCommStateWithTrain = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_GOOD == cCommStateWithTrain) + { + end.wLinkId = GetTrainMaxHeadLink(wTrainId); + end.dwOffset = GetTrainMaxHeadOffset(wTrainId); + start.wLinkId = GetTrainMinTailLink(wTrainId); + start.dwOffset = GetTrainMinTailOffset(wTrainId); + cKeepWork = GetLogSecBtwTwoPoints(start, end, &wCTOccLogSum, wCTOccLogID); /*ȡͨų߼Ϣ˴ÿǷ*/ + } + else + { + cKeepWork = CI_SUCCESS; + } + + if (CI_SUCCESS == cKeepWork) + { + /*жгǷռѹ߼·ڷһ*/ + for (ii = 0U; ii < wCTOccLogSum; ii++) + { + if (wCTOccLogID[ii] == wFstLogSecId) + { + cKeepWork = CI_ERROR; /*гռѹ߼·ڷһΣֹͣ*/ + break; + } + else + { + /**/ + } + } + + if (CI_SUCCESS == cKeepWork) + { + /*гδռѹ߼·ڷһΣж߼ǷͬʼźŻ*/ + cRelatedStartSigNum = GetLogRelateBeginSigSum(wFstLogSecId); + pRelatedStartSigId = GetLogRelateBeginSigData(wFstLogSecId); + pLogSecIncLinkId = GetSecIntrudeLinkIdBuf(wFstLogSecId); + + if ((0U != cRelatedStartSigNum) && (NULL != pRelatedStartSigId) && (NULL != pLogSecIncLinkId)) + { + for (jj = 0U; jj < cRelatedStartSigNum; jj++) + { + cSignalProDir = GetSignalDirection(pRelatedStartSigId[jj]); + wSigProLinkId = GetSignalProtectLink(pRelatedStartSigId[jj]); + strCurPoint.Lnk = pLogSecIncLinkId[0U]; + strCurPoint.Off = 0U; + strNxtPoint.Lnk = wSigProLinkId; + strNxtPoint.Off = 0U; + cDirChangeNum = GetDirChangeNumBtwPoints(&strCurPoint, &strNxtPoint); /*ѯǰlinkźŻlinkķ仯*/ + cSignalProDir = TransDirByChangeNum(cSignalProDir, cDirChangeNum); + if (cSignalProDir == cLogicRouteDir) + { + wStartSignalId = pRelatedStartSigId[jj]; /*ҵͬʼźŻشźŻIDֹͣ*/ + break; + } + else + { + /**/ + } + } + } + else + { + /*ȡ߼ʼźŻlinkʧܣ0*/ + } + } + else + { + /*гռѹ߼·ڷһΣ0*/ + } + } + else + { + /*гμʧܣ0*/ + } + } + else + { + /*ηǷ0*/ + } + + return wStartSignalId; +} + +/* +* @brief ߼ǷǵҾͣ +* @param const UINT16 wLogSecId ߼ID +* @return 0 λ򲻾ͣ +* 1 ǵҾͣ +* @noteCreated by LQ 2023.11.03 +*/ +UINT8 LogSecIsSwitchAndStopAreaCheck(const UINT16 wLogSecId) +{ + UINT8 retVal = CI_ERROR; + UINT16 wStopAreaId = 0U; /*ͣID*/ + UINT8 cLogSecIncLinkNum = 0; /*߼ΰlink*/ + UINT16* pLogSecIncLinkId = NULL; /*߼ΰlink ID*/ + UINT16 wLogSecRelPhySecId = 0U; /*߼ιID*/ + UINT8 cPhySecType = 0U; /**/ + + if ((0U != wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId)) + { + cLogSecIncLinkNum = GetSecIntrudeLinkSum(wLogSecId); /*ȡ߼ΰlink*/ + pLogSecIncLinkId = GetSecIntrudeLinkIdBuf(wLogSecId); + wLogSecRelPhySecId = GetLgcSecRelativePhySecId(wLogSecId); /*ȡ߼ι*/ + cPhySecType = GetPhySecType(wLogSecRelPhySecId); /*ȡ*/ + + /*ж߼ǷǵҾͣ*/ + if ((1U == cLogSecIncLinkNum) && (NULL != pLogSecIncLinkId) && (PHYSICAL_SEC_TYPE_NOSWITCH == cPhySecType)) + { + wStopAreaId = GetLinkStopAreaId(pLogSecIncLinkId[0U]); /*ȡlinkͣID*/ + if (0U != wStopAreaId) + { + retVal = CI_SUCCESS; /*ͣ򣬷سɹ*/ + } + else + { + retVal = CI_ERROR; /*ͣ򣬷ʧ*/ + } + } + else + { + retVal = CI_ERROR; /*㣬ʧ*/ + } + } + else + { + retVal = CI_ERROR; /*ηǷʧ*/ + } + + return retVal; +} + +/* ߼·źűַ */ +/* +* ߼·źűַ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLogRouteFloodGateCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel) +{ + UINT8 reResult = CI_ERROR; + UINT16 wPhySecId = 0U; /*ID*/ + UINT16 LogSectionSum = 0U; + UINT16 ii = 0U; + UINT16 *pLogicSecId = NULL; + UINT16 jj = 0U; + UINT16 floodGateSum = 0U; /**/ + UINT16* floodGateIdBuf = NULL;/*ʱ*/ + UINT16 wFloodGateId = 0U; /*ڷID*/ + UINT8 floodState = 0u;/*״̬*/ + + LogSectionSum = GetLogicalRouteInLogSecSum(wLogRouteId); /*ȡ߼·߼*/ + pLogicSecId = GetLogicalRouteInLogSecId(wLogRouteId); + + if (( 0U < LogSectionSum) && (NULL != pLogicSecId)) + { + for (ii = 0U; ii < LogSectionSum; ii++) + { + wPhySecId = GetLgcSecRelativePhySecId(pLogicSecId[ii]); /*ȡ߼ID*/ + if (0U < wPhySecId) + { + floodGateSum = GetPhySecLocatedFloodSum(wPhySecId); /*Ϊ0˵ûзţ飬ɷسɹ*/ + if (0U < floodGateSum) + { + floodGateIdBuf = GetPhySecLocatedFloodId(wPhySecId); + if (NULL != floodGateIdBuf) + { + for (jj = 0U; jj < floodGateSum; jj++) + { + wFloodGateId = floodGateIdBuf[jj]; + + /*1ſ״̬Ϊ*/ + floodState = GetFloodGateCurOpenLockState(wFloodGateId); + if (FLOOD_GATE_OPENLOCK == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, ETYPE_FLOODGATE_OPENLOCKSTATE, floodState, sendLevel); + } + + /*2Ź״̬Ϊδ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurCloseRequestSta(wFloodGateId); + if (FLOOD_GATE_NOT_CLOSEREQ == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, ETYPE_FLOODGATE_CLOSEREQSTATE, floodState, sendLevel); + } + } + + /*3ŵǰͬ״̬Ϊͬ*/ + if (CI_SUCCESS == reResult) + { + floodState = GetFloodGateCurAgreeCloseSta(wFloodGateId); + if (FLOOD_GATE_NOT_AGREE_CLOSE == floodState) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + SetErrorData(functionId, CI_DEVICE_TYPE_FLOODGATE, wFloodGateId, ETYPE_FLOODGATE_AGREECLOSESTATE, floodState, sendLevel); + } + } + + if (CI_SUCCESS != reResult) + { + break; /*һŲERROR*/ + } + } + } + else + { + reResult = CI_ERROR; /*ȡʧܣʧ*/ + } + } + else + { + reResult = CI_SUCCESS;/*߼ιβIDسɹ*/ + } + if (CI_ERROR == reResult) + { + break; /*ż鲻ͨѭ*/ + } + } + } + } + + return reResult; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/LogicProcess/LogicalRouteLogicCheck.h b/TSCP/src/APP/ciapp/LogicProcess/LogicalRouteLogicCheck.h new file mode 100644 index 0000000..19b0727 --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicProcess/LogicalRouteLogicCheck.h @@ -0,0 +1,526 @@ +/******************************************************** +* +* LogicalRouteLogicCheck.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2023-10-10 +* ߣ +* ߼·麯ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* by lc 20231011 +* +********************************************************/ + +#ifndef _LOGICAL_ROUTE_LOGIC_CHECK_H_ +#define _LOGICAL_ROUTE_LOGIC_CHECK_H_ + + +#include "CommonTypes.h" +#include "RouteDefine.h" +#include "SectionDefine.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* @return 1ͨ 0鲻ͨ +* @note +*/ +UINT8 SetLogRouteCheckProcess(UINT16 const logRouteId); + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* @return 1ͨ 0鲻ͨ +* @note +*/ +UINT8 LockLogRouteCheckProcess(UINT16 const logRouteId); + + +/** +* @brief ߼·η +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LogRoutePhySecFengSuoCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState); + +/** +* @brief ߼·߼ռ +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteSectionLockCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState); + +/** +* @brief ߼α߼· +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteLockBylogRouteCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState); +/** +* @brief ߼Ƿ· +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteYDLockCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState); +/** +* @brief ߼·μ +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LogRouteSectionCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel); + +/** +* @brief ߼·Ծռ +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LogRouteJumpLockCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState); + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 SetLogRouteSwitchCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel); + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LockLogRouteSwitchCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel); + +/** +* @brief ߼· +* @param UINT16 routeId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* @noteCI_ERROR CI_SUCCESS +*/ +UINT8 LogRouteSwitchFLockCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState, UINT8* pYLockAlarmFlag); + +/* +* ߼· +* ˵ UINT16 routeId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* UINT8* pYLockAlarmFlag ־أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteProSwitchFLockCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState, UINT8* pYLockAlarmFlag); + +/* +* ߼· +* ˵ UINT16 routeId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteCeFangSwitchCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + +/* +* ߼·ȫ豸 +* ˵ UINT16 logRouteId, ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteContactLineDevSwitCheck(UINT16 const logRouteId, UINT8 functionId, UINT8 sendLevel); + + +/* +* ߼· +* ˵ UINT16 routeId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteProtectLockSwitchCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + +/* +* ߼·λǷɶ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteSwitchMoveValidCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + +/* +* ߼·λǷɶ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteProSwitchMoveValidCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @note +*/ +UINT8 LogRouteSwitchRelaySecCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼·ڵһ߼ռ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteSwOtherLogLockCheck(UINT16 const logRouteId, UINT16* pDevId, UINT8* pDevState); + +/** +* @brief ߼·ڵεķǽ·ҷǵ߼ռ +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteOutLogSecLockCheck(UINT16 logRouteId, UINT16* pDevId, UINT8* pDevState); + +/** +* @brief ߼· +* @param wLogRouteId ߼·ID +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* @return CI_ERROR ͨ +* CI_SUCCESS ͨ +* @noteby LC +*/ +UINT8 LogRouteIntruSecCheck(UINT16 logRouteId, UINT8 functionId, UINT8 sendLevel); + +/** +* @brief ߼·Ƿɹ +* @param wLogRouteId ߼·ID +* UINT8 functionId,ú +* UINT8 sendLevel,뷢ͼ +* @return CI_ERROR ͨ +* CI_SUCCESS ͨ +* @noteby LC +*/ +UINT8 LogRouteUseStateCheck(UINT16 logRouteId); + +/* +* ߼·λ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteSwitchPosCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + +/* +* ߼·λ +* ˵ UINT16 routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteProSwitchPosCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + +/* ߼·źű */ +/* +* ߼·źű +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLogRouteSectionCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel); + +/** +* @brief ߼α߼·״̬ +* @param UINT16 wLogRouteId ߼·ID +* UINT8 checkState Ҫ߼״̬ +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogNormalLockBylogRouteCheck(UINT16 wLogRouteId, UINT8 checkState, UINT16* pDevId, UINT8* pDevState); + +/** +* @brief ߼·߼쳣Լһ߼δ·ռ +* @param wLogRouteId ߼·ID +* UINT8 pDevId,豸ID +* UINT8 pDevState,豸״̬ +* @note +*/ +UINT8 LogRouteSectionExceptLockCheck(UINT16 wLogRouteId, UINT16* pDevId, UINT8* pDevState); + +/* +* ߼·һ߼μ +* ˵ +* UINT16 const wLogRouteId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ͨ +*/ +UINT8 LogRouteFirstLgcSecCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState); + + +/** +* @brief ߼·ڲ߼Ƿȫ +* @param wLogRouteId ߼·ID +* @return CI_ERROR ͨ +* CI_SUCCESS ͨ +* : fan 2023-10-11 +*/ +UINT8 LogRouteLogSecReleaseCheck(UINT16 logRouteId); + +/* ߼·źűźŻ */ +/* +* ߼·źűźŻ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLogRouteSignalCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel); + + +/* ߼·źſźŻ */ +/* +* ߼·źſźŻ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLogRouteSignalCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼·źŻ״̬ +* ˵ UINT16 const wLogRouteId, ߼·ID +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteSignalFLockCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState); + +/* ߼·źűֵ */ +/* +* ߼·źűֵ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLogRouteSwitchCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼Ϊ߼·յĵһμ +* ˵ const UINT16 wLogSectionId, ߼ID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +* by cgh 20231013 +*/ +UINT8 LogSecLogRouteFirstLockCheck(const UINT16 wLogSectionId); + +/* ߼·źűվ̨ */ +/* +* ߼·źűվ̨ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLogRoutePlatformCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel); + +/* +* ߼·վ̨رհťЧ +* ˵ UINT16 const wLogRouteId, ߼· +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteEsbVainCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼·վ̨Źرռ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRoutePsdCloseCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* ߼·վ̨δ۳ +* ˵ UINT16 const routeId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteDetainCheck(UINT16 const wLogRouteId, UINT16 *pDevId, UINT8 *pDevState); + +/* +* Ƿ߼·ռ +* ˵ UINT16 const wPhySectionId, ID +* ֵ 0 ݷǷУʧ +* >0 ߼·״̬ +* by cgh 20231014 +*/ +UINT8 PhySecLogLockStateCheck(UINT16 const wPhySectionId); + +/* +* Ƿ߼·ռ +* ˵ UINT16 const wPhySectionId, ID +* ֵ 0 ݷǷУʧ +* >0 ߼·״̬ +* by cgh 20231014 +*/ +UINT8 AixsSecLogLockStateCheck(UINT16 const wAxisSectionId); + +/* +* ߼·ڵһ߼δռ +* ˵ UINT16 const logRouteId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221005 Ż·飬·ʱһλù߼δ +*/ +UINT8 LogRouteSwOtherLogLockValCheck(UINT16 const logRouteId, UINT16* pDevId, UINT8* pDevState); + +/* +* ߼·εķǽ·ҷǵ߼ЧԼ +* ˵ UINT16 const logRouteId, · +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +* add 20221008 ·ǰ⶯ +*/ +UINT8 LogRouteOutLogSecOccClearCheck(UINT16 const routeId, UINT16* pDevId, UINT8* pDevState); + +/* +* ߼·һյ߼εһ߼״̬ +* ˵ const UINT16 wLogRouteId ߼·ID +* const UINT16 wLogSecId ߼ID +* ֵ CI_ERROR һ߼״̬鲻ͨ +* CI_SUCCESS һ߼״̬ͨ +* by cgh 20231016 +*/ +UINT8 CheckLogRouteLogSecLastSecLock(const UINT16 wLogRouteId, const UINT16 wLogSecId); + +/* +* ȡָID߼·Դ߼ +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: ߼·Ԥ +* CI_ERROR: ߼·Ԥ +*/ +UINT8 CheckLgcSecInLogRoute(const UINT16 wLogRouteId, const UINT16 lgcSecId); + + +/* +* ȡָID߼·гԴ +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT16 phySecId +* ֵ CI_SUCCESS: ߼·Ԥ +* CI_ERROR: ߼·Ԥ +*/ +UINT8 CheckPhySecInLogRoute(const UINT16 wLogRouteId, const UINT16 phySecId); + +/* +* @brief ǷΪͬһгظͬһ߼· +* @param const UINT16 wLogSecSum ߼·߼Ŀ +* @param const UINT16* pLogSecIdbuf ߼·߼ID +* @param const UINT16 wTrainId ߼·гID +* @return 1 ɹ +* 0 ʧ +* @noteCreated by LQ 2023.11.01 +*/ +UINT8 RepeatSetLogicRouteCheck(const UINT16 wLogSecSum, const UINT16* pLogSecIdbuf, const UINT16 wTrainId); + +/* +* @brief ߼·ǷҪʼźŻ +* @param const UINT16 wFstLogSecId ߼·ĵһ߼ID +* @param const UINT8 cLogicRouteDir ߼·߼ +* @param const UINT16 wTrainId ߼·гID +* @return 0 ʼźŻ +* >0 ӵʼźŻID +* @noteCreated by LQ 2023.11.01 +*/ +UINT16 LogicRouteAddStartSignalCheck(const UINT16 wFstLogSecId, const UINT8 cLogicRouteDir, const UINT16 wTrainId); + +/* +* @brief ߼ǷǵҾͣ +* @param const UINT16 wLogSecId ߼ID +* @return 0 λ򲻾ͣ +* 1 ǵҾͣ +* @noteCreated by LQ 2023.11.03 +*/ +UINT8 LogSecIsSwitchAndStopAreaCheck(const UINT16 wLogSecId); + +/* ߼·źűַ */ +/* +* ߼·źűַ +* ˵ +* UINT16 wLogRouteId, ߼· +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepLogRouteFloodGateCheck(UINT16 wLogRouteId, UINT8 functionId, UINT8 sendLevel); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/LogicProcess/TradInterlockLogicProcess.c b/TSCP/src/APP/ciapp/LogicProcess/TradInterlockLogicProcess.c new file mode 100644 index 0000000..da8bfff --- /dev/null +++ b/TSCP/src/APP/ciapp/LogicProcess/TradInterlockLogicProcess.c @@ -0,0 +1,4401 @@ +/******************************************************** +* +* TradInterlockLogicProcess.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2011-05-06 +* ߣ +* ߼ +* ޸ļ¼ 2015.5.20 ɾ·ű ·鳵ŵϢ Ҷ +* +********************************************************/ + + +#include "TradInterlockLogicProcess.h" + +/* C81 ϱ: EFUNC_CLD_SET_L_TRAIN_ROUTE */ +/* +* ѡг·߼ +* ˵ UINT16 routeId, ·ID +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetLTrainRouteP(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_CLD_SET_L_TRAIN_ROUTE; + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ +/* ֲʼ */ + UINT8 devState = 0U; /*豸״̬*/ + UINT8 reResult = CI_ERROR; /*ֵ*/ + +/* */ + + devState = GetRouteState(routeId); + /*·״̬лѡԶ쳣ARBҹգ*/ + if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState) || (ROUTE_STATE_AUTO_UNLOCKERR == devState)) + { + /* سɹ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ź*/ + /*if ((CI_SUCCESS == reResult) && (CI_ERROR == SetLTrainRouteSignalCheck(routeId,functionId,sendLevel)))*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == SetBlocRouteSignalCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ղ*/ + if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == SetLTrainRouteSectionCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == SetLTrainRouteSwitchCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + return reResult; +} + +/* C82 ϱ: EFUNC_CLD_SET_D_TRAIN_ROUTE */ +/* +* ѡŵ·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ +*/ +UINT8 SetDTrainRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_SET_D_TRAIN_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + + UINT8 reVal = 0u; + +/* */ + devId = routeId; + devState = GetRouteState(routeId); + if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_FIRST_XUANPAI == devState)) + { /*·״̬лѡ*/ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ź*/ + if (CI_SUCCESS == reResult) + { + /* ʧܷ */ +#if 0 + reResult = SetLTrainRouteSignalCheck(routeId,functionId,sendLevel); +#endif + reResult = SetBlocRouteSignalCheck(routeId,functionId,sendLevel); + } + + /*ղ*/ + if (CI_SUCCESS == reResult) + { + reVal = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if(CI_SUCCESS != reVal) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + /* ʧܷ */ + reVal = SetDTrainRouteSectionCheck(routeId,functionId,sendLevel); + if(CI_ERROR == reVal) + { + reResult = CI_ERROR; + } + + } + + /**/ + if (CI_SUCCESS == reResult) + { + /* ʧܷ */ + reVal = SetLTrainRouteSwitchCheck(routeId,functionId,sendLevel); + if(CI_ERROR == reVal) + { + reResult = CI_ERROR; + } + } + + return reResult; +} + +/* C83 ϱ: EFUNC_CLD_SET_LEAD_ROUTE */ +/* +* ѡ·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 SetLeadRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_SET_LEAD_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + +/* */ + devId = routeId; + devState = GetRouteState(routeId); + if (devState != ROUTE_STATE_IDLE) + { /*·״̬*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,routeId,ETYPE_ROUTE_STATE,devState,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ź*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == /*SetLTrainRouteSignalCheck*/SetBlocRouteSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ղ*/ + if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == SetLeadRouteSectionC(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == SetLTrainRouteSwitchCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /**/ + reResult = BlocRouteFloodGateCheck(routeId,functionId,sendLevel); + + } + + return reResult; +} + +/* C84 ϱ: EFUNC_CLD_SET_D_LONG_ROUTE */ +/* +* ѡų·߼ +* ˵ UINT16 longRouteId, ·ID +* ֵ +*/ +UINT8 SetLongDTrainRouteP(const UINT16 longRouteId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_SET_D_LONG_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 subRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + UINT8 routeType = 0u; +/* */ + subRouteSum = GetLongRouteSubRouteSum(longRouteId); /*ӽ·*/ + pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(longRouteId); /*ӽ·*/ + + devId = longRouteId; + devState = GetLongRouteState(longRouteId); + if (devState != ROUTE_LONG_STATE_IDLE) + { /*·*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_STATE,devState,sendLevel); + reResult = CI_ERROR; + } + if (CI_SUCCESS == reResult) + { + for (ii = 0u; ii < subRouteSum; ii++) + { + if (ii == 0u) + { + routeType = GetRouteType(pSubRouteIdBuf[ii]); + if(ROUTE_TYPE_DIAOCHE == routeType) /*ϵ·*/ + { + /*һ·յ·*/ + if (CI_ERROR == SetDTrainRouteP(pSubRouteIdBuf[ii])) + { /*·ѡżʧ*/ + + reResult = CI_ERROR; + } + } + else /*г·*/ + { + /*г·*/ + if (CI_ERROR == SetLTrainRouteP(pSubRouteIdBuf[ii])) + { /*·ѡżʧ*/ + + reResult = CI_ERROR; + } + } + + } + else + { + /*·г·*/ + if (CI_ERROR == SetLTrainRouteP(pSubRouteIdBuf[ii])) + { /*·ѡżʧ*/ + + reResult = CI_ERROR; + } + } + if (CI_ERROR == reResult) + { + break; + } + } + } + + return reResult; +} + + +/* C85 ϱ: EFUNC_CLD_LOCK_L_TRAIN_ROUTE */ +/* +* г·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 LockLTrainRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_LOCK_L_TRAIN_ROUTE; + +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + UINT32 routeXuanPaiStartCycNum = 0u; + UINT32 dwSystemParaRouteXuanPaiCyc = 0u; + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT8 reVal = 0u; + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(routeId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* */ + devId = routeId; + routeXuanPaiStartCycNum = GetRouteXuanPaiStartCycNum(routeId); + dwSystemParaRouteXuanPaiCyc = GetSystemParaRouteXuanPaiCyc(); + devState = SystemOverTimeCheck(routeXuanPaiStartCycNum,dwSystemParaRouteXuanPaiCyc); + if(CI_TIME_OUT == devState) + { /*ѡųʱ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_XUANPAI_OVERTIME,devState,sendLevel); + + reResult = CI_ERROR; + } + + /*ź*/ + if (CI_SUCCESS == reResult) + { + reVal = /*SetLTrainRouteSignalCheck*/SetBlocRouteSignalCheck(routeId,functionId,sendLevel); + if(CI_ERROR ==reVal) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + + /*ղ*/ + if (CI_SUCCESS == reResult) + { + reVal = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if(CI_SUCCESS != reVal) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + + /**/ + if (CI_SUCCESS == reResult) + { + reVal = LockLTrainRouteSectionCheck(routeId,functionId,sendLevel); + if(CI_ERROR == reVal) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + reVal = SetLTrainRouteSwitchCheck(routeId,functionId,sendLevel); + if(CI_SUCCESS == reVal) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = reVal; + } + } + if (CI_SUCCESS == reResult) + { + /**/ + devId = 0u; + devState = 0u; + reVal = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (CI_SUCCESS == reVal) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + return reResult; +} + +/* C86 ϱ: EFUNC_CLD_LOCK_D_TRAIN_ROUTE */ +/* +* յ·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 LockDTrainRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_LOCK_D_TRAIN_ROUTE; +/*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; /*ֵ*/ + UINT32 routeXuanPaiStartCycNum = 0u; + UINT32 dwSystemParaRouteXuanPaiCyc = 0u; + UINT8 checkResult = CI_ERROR; /**/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(routeId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + +/* */ + devId = routeId; + routeXuanPaiStartCycNum = GetRouteXuanPaiStartCycNum(routeId); + dwSystemParaRouteXuanPaiCyc = GetSystemParaRouteXuanPaiCyc(); + devState = SystemOverTimeCheck(routeXuanPaiStartCycNum, dwSystemParaRouteXuanPaiCyc); + + if(CI_TIME_OUT == devState) + { /*ѡųʱ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_XUANPAI_OVERTIME,devState,sendLevel); + + reResult = CI_ERROR; + } + + + /*ź*/ + if (CI_SUCCESS == reResult) + { + checkResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ղ*/ + if (CI_SUCCESS == reResult) + { + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + checkResult = LockDTrainRouteSectionCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetLTrainRouteSwitchCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + if (CI_SUCCESS == reResult) + { + /**/ + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټ*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + return reResult; +} + +/* C87 ϱ: EFUNC_CLD_LOCK_LEAD_ROUTE */ +/* +* ·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 LockLeadTrainRouteP(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_CLD_LOCK_LEAD_ROUTE; + /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; + UINT8 cAutoStateFlag = CI_ERROR; + UINT8 chCheckResult = CI_ERROR; + UINT32 dwXuanPaiStartCycNum = 0U;/*·ѡʼ*/ + UINT32 dwParaRouteXuanPaiCyc = 0U;/*·ѡų*/ + + cAutoStateFlag = AutoSignalOrRouteValid(routeId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + /* */ + devId = routeId; + dwXuanPaiStartCycNum = GetRouteXuanPaiStartCycNum(routeId); + dwParaRouteXuanPaiCyc = GetSystemParaRouteXuanPaiCyc(); + + devState = SystemOverTimeCheck(dwXuanPaiStartCycNum, dwParaRouteXuanPaiCyc); + if (CI_TIME_OUT == devState) + { /*ѡųʱ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_XUANPAI_OVERTIME, devState, sendLevel); + + reResult = CI_ERROR; + } + + /*ź*/ + chCheckResult = SetBlocRouteSignalCheck(routeId, functionId, sendLevel); + if ((CI_SUCCESS == reResult) && (CI_ERROR == chCheckResult)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ղ*/ + chCheckResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if ((CI_SUCCESS == reResult) && (CI_SUCCESS != chCheckResult)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + chCheckResult = LockLeadRouteSectionC(routeId, functionId, sendLevel); + if ((CI_SUCCESS == reResult) && (CI_ERROR == chCheckResult)) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼ЧԼ*/ + reResult = LockLeadRouteSectionCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == reResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /**/ + + if (CI_SUCCESS == reResult) + { + chCheckResult = SetLTrainRouteSwitchCheck(routeId, functionId, sendLevel); + if (CI_ERROR == chCheckResult) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + reResult = chCheckResult; + } + } + return reResult; +} + +/* C88 ϱ: EFUNC_CLD_LEAD_TRAIN_ROUTE */ +/* +* ճ·߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 LockLongDTrainRouteP(const UINT16 longRouteId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_SET_D_LONG_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 subRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + UINT8 reResult = CI_SUCCESS; + UINT8 routeType = 0u; /*·*/ +/* */ + subRouteSum = GetLongRouteSubRouteSum(longRouteId); /*ӽ·*/ + pSubRouteIdBuf = GetLongRouteSubRouteIdBuf(longRouteId); /*ӽ·*/ + + devId = longRouteId; + devState = GetLongRouteState(longRouteId); + if (devState != ROUTE_LONG_STATE_XUANPAI) + { /*·Ϊѡ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_STATE,devState,sendLevel); + reResult = CI_ERROR; + } + if (CI_SUCCESS == reResult) + { + devState = SystemOverTimeCheck(GetLongRouteXuanPaiStartCycNum(longRouteId),GetSystemParaZuheRXuanPaiCnt()); + if(CI_TIME_OUT == devState) + { /*ѡųʱ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_ROUTE,devId,ETYPE_ROUTE_XUANPAI_OVERTIME,devState,sendLevel); + + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + + for (ii = 0u; ii < subRouteSum; ii++) + { + + if (ii == 0u) + { + routeType = GetRouteType(pSubRouteIdBuf[ii]); /*жϸϽ·Ϊгϵ*/ + if (ROUTE_TYPE_LIECHE == routeType) + { + /*г·*/ + if (CI_ERROR == LockLTrainRouteP(pSubRouteIdBuf[ii])) + { /*·ѡżʧ*/ + + reResult = CI_ERROR; + } + } + else + { + /*һ·յ·*/ + if (CI_ERROR == LockDTrainRouteP(pSubRouteIdBuf[ii])) + { /*·ѡżʧ*/ + + reResult = CI_ERROR; + } + } + + } + else + { + /*·г·*/ + if (CI_ERROR == LockLTrainRouteP(pSubRouteIdBuf[ii])) + { /*·ѡżʧ*/ + + reResult = CI_ERROR; + } + } + if (CI_ERROR == reResult) + { + break; + } + } + } + + return reResult; +} + + +/* C89 ϱ: EFUNC_CLD_OPEN_L_TRAIN_ROUTE */ +/* +* г·ź߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 OpenLTrainRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_OPEN_L_TRAIN_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 checkResult = CI_ERROR; + UINT8 reResult = CI_ERROR; + +/* */ +/*ȡ˽*/ + + + if ((ROUTE_ZONGQUXIAO_SET_YES == GetRouteZongQuXiaoFlag(routeId)) || + (ROUTE_ZONGRENJIE_SET_YES == GetRouteZongRenJieFlag(routeId))) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + } + + + if(CI_SUCCESS == reResult) + { + devId = routeId; + devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId),GetSystemParaRouteOpenSigCyc()); + if(CI_TIME_OUT == devState) + { /*ųʱ*/ + devId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_OPEN_OVERTIME,devState,ESEND_LEVEL_ATS); + + reResult = CI_ERROR; + } + else + { + } + } + else + { + } + + /*ź*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenLTrainRouteSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + } + + /*ղ*/ +#if 0 + if ((reResult == CI_SUCCESS) &&(CI_ERROR == RouteRelayZhaoChaCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } +#endif + if (CI_SUCCESS == reResult) + { + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + {/*ȴղͼɹ*/ + reResult = checkResult; + } + } + else + { + } + + /**/ + if ((CI_SUCCESS == reResult) &&(CI_ERROR == OpenLTrainRouteSectionCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + } + /**/ + if ((CI_SUCCESS == reResult) &&(CI_ERROR == OpenLTrainRouteSwitchCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + else + { + } + /* · */ + if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + /*źŻ*/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + else + { + } + /* */ + if (CI_SUCCESS == reResult) + { + checkResult = OtherCiValidCheck(routeId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + return reResult; +} + +/* C90 ϱ: EFUNC_CLD_OPEN_D_TRAIN_ROUTE */ +/* +* ŵ·ź߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 OpenDTrainRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_OPEN_D_TRAIN_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; + UINT8 checkResult = CI_ERROR; /*·ղ20150616*/ + +/* */ + /*ȡ˽*/ + if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) || + (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES)) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + + if(CI_SUCCESS == reResult) + { + devId = routeId; + devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId),GetSystemParaRouteOpenSigCyc()); + if(CI_TIME_OUT == devState) + { /*ųʱ*/ + devId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_OPEN_OVERTIME,devState,ESEND_LEVEL_ATS); + + reResult = CI_ERROR; + } + } + + /*ź*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenLTrainRouteSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ղ*/ +#if 0 + if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } +#endif + if (CI_SUCCESS == reResult) + { + checkResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*ȴղͼɹ*/ + reResult = checkResult; + } + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenDTrainRouteSectionCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenLTrainRouteSwitchCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* */ + if (CI_SUCCESS == reResult) + { + if (CI_SUCCESS == OtherCiValidCheck(routeId,functionId,sendLevel)) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /*źŻ*/ + if (CI_SUCCESS == reResult) + { + checkResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + + if (CI_SUCCESS == reResult) + {/*ֻǰ㣬żͬ*/ + /*reResultΪCI_SUCCESSRETURN_DCTY_NOT_SATISIFY*/ + reResult = DRouteDCTYCheck(routeId, functionId, sendLevel); + } + return reResult; +} + +/* C91 ϱ: EFUNC_CLD_OPEN_LEAD_ROUTE */ +/* +* ·ź߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 OpenLeadRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_OPEN_LEAD_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; + +/* */ + /*ȡ˽*/ + if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) || + (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES)) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + if(reResult == CI_SUCCESS) + { + devId = routeId; + devState = SystemOverTimeCheck(GetRouteOpenSigStatrtCycNum(routeId),GetSystemParaRouteOpenSigCyc()); + if(CI_TIME_OUT == devState) + { /*ųʱ*/ + devId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_OPEN_OVERTIME,devState,ESEND_LEVEL_ATS); + + reResult = CI_ERROR; + } + } + + /*ź*/ + if ((reResult == CI_SUCCESS) &&(CI_ERROR == OpenLTrainRouteSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ղ*/ + if (reResult == CI_SUCCESS) + { + /* ʧܷ */ + reResult = RouteRelayZhaoChaCheck(routeId, functionId, sendLevel); + } + + /**/ + if ((reResult == CI_SUCCESS) &&(CI_ERROR == OpenLeadRouteSectionC(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((reResult == CI_SUCCESS) && (CI_ERROR == OpenLTrainRouteSwitchCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + /*źŻ*/ + if (CI_SUCCESS == reResult) + { + reResult = OpenBlocRouteOtherSignalCheck(routeId, functionId, sendLevel); + + } + /* */ + if (CI_SUCCESS == reResult) + { + reResult = OtherCiValidCheck(routeId,functionId,sendLevel); + + } + return reResult; +} + + +/* C92 ϱ: EFUNC_CLD_KEEP_L_TRAIN_ROUTE */ +/* +* ֿг·ź߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 KeepLTrainRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_KEEP_L_TRAIN_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; + +/* */ + /*ȡ˽*/ + if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) || + (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES)) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·״̬Ԥȿš򡾽ӽš*/ + if(CI_SUCCESS == reResult) + { + devId = routeId; + devState = GetRouteState(devId); + if ((devState != ROUTE_STATE_YUXIAN_OPEN) && + (devState != ROUTE_STATE_NEAR_OPEN)) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ź*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepLTrainRouteSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ղ*/ + if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepOpenLTrainRouteSectionCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepRouteSwitchCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* */ + if (CI_SUCCESS == reResult) + { + if (CI_SUCCESS == OtherCiValidCheck(routeId,functionId,sendLevel)) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /*źŻ*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepBlocRouteOtherSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + /* · */ + + if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenBlocRouteOverlapCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + return reResult; +} + +/* C93 ϱ: EFUNC_CLD_KEEP_D_TRAIN_ROUTE */ +/* +* ֿŵ·ź߼ +* ˵ UINT16 routeId, ·ID +* ֵ +*/ +UINT8 KeepDTrainRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_KEEP_D_TRAIN_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + +/* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; + +/* */ + /*ȡ˽*/ + if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) || + (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES)) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·״̬Ԥȿš򡾽ӽš*/ + if(CI_SUCCESS == reResult) + { + devId = routeId; + devState = GetRouteState(devId); + if ((devState != ROUTE_STATE_YUXIAN_OPEN) && + (devState != ROUTE_STATE_NEAR_OPEN)) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ź*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepLTrainRouteSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ղ*/ + if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) &&(CI_ERROR == KeepDTrainRouteSectionCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepRouteSwitchCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* */ + if (CI_SUCCESS == reResult) + { + if (CI_SUCCESS == OtherCiValidCheck(routeId,functionId,sendLevel)) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /*źŻ*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepBlocRouteOtherSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + {/*ֻǰ㣬żͬ*/ + /*reResultΪCI_SUCCESSRETURN_DCTY_NOT_SATISIFY*/ + reResult = DRouteDCTYCheck(routeId, functionId, sendLevel); + } + + return reResult; +} + +/* C94 ϱ: EFUNC_CLD_KEEP_LEAD_ROUTE */ +/* +* ·߼ +* ˵ UINT16 routeId, ·ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +UINT8 KeepLeadRouteP(const UINT16 routeId) +{ + /**/ + UINT8 const functionId = EFUNC_CLD_KEEP_LEAD_ROUTE; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + + /* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; + + /* */ + /*ȡ˽*/ + if ((GetRouteZongQuXiaoFlag(routeId) == ROUTE_ZONGQUXIAO_SET_YES) || + (GetRouteZongRenJieFlag(routeId) == ROUTE_ZONGRENJIE_SET_YES)) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*·״̬š*/ + if(CI_SUCCESS == reResult) + { + devId = routeId; + devState = GetRouteState(devId); + if (devState != ROUTE_STATE_LEAD_OPEN) + { + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, routeId, ETYPE_ROUTE_STATE, devState,sendLevel); + + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*ź*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepLTrainRouteSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /*ղ*/ + if ((CI_SUCCESS == reResult) && (CI_SUCCESS != RouteRelayZhaoChaCheck(routeId, functionId, sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == OpenLeadRouteSectionC(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + /**/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepRouteSwitchCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + /*·źռ*/ + if(CI_SUCCESS == reResult) + { + reResult = KeepLeadSecOccCheck(routeId); + } + /*źŻ*/ + if ((CI_SUCCESS == reResult) && (CI_ERROR == KeepBlocRouteOtherSignalCheck(routeId,functionId,sendLevel))) + { + /* ʧܷ */ + reResult = CI_ERROR; + } + /* */ + if (CI_SUCCESS == reResult) + { + reResult = OtherCiValidCheck(routeId,functionId,sendLevel); + + } + return reResult; +} + + +/* C95 ϱ: EFUNC_CLD_SET_NONROUTE */ +/* +* ѡŷǽ·߼ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ 0 ʧ +* 1 ɹ +*/ +UINT8 SetNonRouteP(UINT8 nonRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_CLD_SET_NONROUTE; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + + /* ֲʼ */ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_ERROR; + + /* */ + devState = GetNonRouteStateById(nonRouteId); + if (devState != NONROUTE_STATE_IDLE) + { /*ǽ·״̬*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_NONROUTE, nonRouteId, ETYPE_ROUTE_STATE, devState,sendLevel); + + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + if (CI_SUCCESS == reResult) + { /*źŻ˿*/ + + reResult = CheckNonRouteSignalNoBreak(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*źŻ*/ + + reResult = CheckNonRouteSignalFengSuo(nonRouteId,functionId,sendLevel); + } + + if(CI_SUCCESS == reResult) + { /*жźų*/ + + reResult = CheckNonRouteEnemySignal(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRoutePhySecUsing(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·ռÿд*/ + + reResult = CheckNonRoutePhySectionOccupy(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRoutePhySectionUnLock(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteSwitchYinSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + {/*ǽ·Ρδ*/ + reResult = CheckNonRoutePhysecFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteSwitchFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteRelProSwiFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·λȷ򡾲ȷɶ*/ + + reResult = NonRouteSwitchPosMovValCheck(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteRelProSwiYinSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·λòȷҲɶ*/ + + reResult = NonRouteRelProSwiPosMovValCheck(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + {/**/ + reResult = NonRouteIntruSecVainCheck(nonRouteId,functionId,sendLevel); + } + + + + return reResult; +} + +/* C96 ϱ: EFUNC_CLD_LOCK_NONROUTE */ +/* +* շǽ·߼ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ +*/ +UINT8 LockNonRouteP(UINT8 nonRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_CLD_LOCK_NONROUTE; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + + /* ֲʼ */ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_SUCCESS; + + /* */ + devState = GetNonRouteStateById(nonRouteId); + if (devState != NONROUTE_STATE_XUANPAI) + { /*ǽ·״̬ѡ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_NONROUTE, nonRouteId, ETYPE_ROUTE_STATE, devState,sendLevel); + + reResult = CI_ERROR; + } + if (CI_SUCCESS == reResult) + { + devState = SystemOverTimeCheck(GetNonRouteXuanPaiStartCycById(nonRouteId),GetSystemParaNonRouteXuanPaiCnt()); + if(CI_TIME_OUT == devState) + { /*ѡųʱ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_NONROUTE,nonRouteId,ETYPE_ROUTE_XUANPAI_OVERTIME,devState,sendLevel); + + reResult = CI_ERROR; + } + } + + + if (CI_SUCCESS == reResult) + { /*źŻ˿*/ + + reResult = CheckNonRouteSignalNoBreak(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*źŻ*/ + + reResult = CheckNonRouteSignalFengSuo(nonRouteId,functionId,sendLevel); + } + + if(CI_SUCCESS == reResult) + { /*жźų*/ + + reResult = CheckNonRouteEnemySignal(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·ռÿд*/ + + reResult = CheckNonRoutePhySectionOccupy(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRoutePhySectionUnLock(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteSwitchYinSuo(nonRouteId,functionId,sendLevel); + } + + + if (CI_SUCCESS == reResult) + {/*ǽ·Ρδ*/ + reResult = CheckNonRoutePhysecFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteSwitchFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteRelProSwiFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·λòȷҲɶ*/ + + reResult = NonRouteSwitchPosMovValCheck(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteRelProSwiYinSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·λòȷҲɶ*/ + + reResult = NonRouteRelProSwiPosMovValCheck(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + {/**/ + reResult = NonRouteIntruSecVainCheck(nonRouteId,functionId,sendLevel); + } + + + + return reResult; +} + +/* C97 ϱ: EFUNC_CLD_OPEN_NONROUTE */ +/* +* ŷǽ·߼ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ 0 ʧ +* 1 سɹ +*/ +UINT8 OpenNonRouteP(UINT8 nonRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_CLD_OPEN_NONROUTE; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + + /* ֲʼ */ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResult = CI_ERROR; + + /* */ + + devState = GetNonRouteCancelFlagById(nonRouteId); + if (NONROUTE_CANCEL_FLAG_YES == devState) + { /*ȡ־Ч*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_NONROUTE, nonRouteId, ETYPE_ROUTE_CANCEL, devState,sendLevel); + + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + if (CI_SUCCESS == reResult) + { + devState = SystemOverTimeCheck(GetNonRouteSigOpenStartCycById(nonRouteId),GetSystemParaRouteOpenSigCyc()); + if(CI_TIME_OUT == devState) + { /*ųʱ*/ + + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_NONROUTE,nonRouteId,ETYPE_SIG_OPEN_OVERTIME,devState,ESEND_LEVEL_ATS); + + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { /*źŻ˿*/ + + reResult = CheckNonRouteSignalNoBreak(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*źŻ*/ + + reResult = CheckNonRouteSignalFengSuo(nonRouteId,functionId,sendLevel); + } + + if(CI_SUCCESS == reResult) + { /*жźų*/ + + reResult = CheckNonRouteEnemySignal(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·ռÿд*/ + + reResult = CheckNonRoutePhySectionOccupy(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·δ*/ + + reResult = CheckNonRoutePhySectionLock(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + {/*ǽ·Ρδ*/ + reResult = CheckNonRoutePhysecFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteSwitchFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteRelProSwiFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·λ*/ + + reResult = CheckNonRouteSwitchPosRight(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + { /*ǽ·*/ + + reResult = CheckNonRouteRelProSwiLockSta(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == reResult) + {/**/ + reResult = NonRouteIntruSecVainCheck(nonRouteId,functionId,sendLevel); + } + + + return reResult; +} + +/* C98 ϱ: EFUNC_CLD_KEEP_NONROUTE */ +/* +* ֿŷǽ·߼ +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ 0 ʧ +* 1 ɹ +*/ +UINT8 KeepOpenNonRouteP(UINT8 nonRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_CLD_KEEP_NONROUTE; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + /* ֲʼ */ + UINT8 flagCancelNonRoute = 0u;/*ȡ־*/ + UINT8 chkResult = CI_ERROR;/**/ + + /* */ + flagCancelNonRoute = GetNonRouteCancelFlagById(nonRouteId); + if (NONROUTE_CANCEL_FLAG_YES == flagCancelNonRoute) + { /*ȡ־Ч*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_NONROUTE, nonRouteId, ETYPE_ROUTE_CANCEL, CI_ERROR,sendLevel); + + chkResult = CI_ERROR; + } + else + {/*ȡ־Чͨ*/ + chkResult = CI_SUCCESS; + } + + + if (CI_SUCCESS == chkResult) + { /*źŻ֮ǰر*/ + + chkResult = CheckNonRouteSignalPreDrvOpen(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == chkResult) + { /*źŻ*/ + + chkResult = CheckNonRouteSignalFengSuo(nonRouteId,functionId,sendLevel); + } + + if(CI_SUCCESS == chkResult) + { /*жźų*/ + + chkResult = CheckNonRouteEnemySignal(nonRouteId,functionId,sendLevel); + } + + + if (CI_SUCCESS == chkResult) + { /*ǽ·δ*/ + + chkResult = CheckNonRoutePhySectionLock(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == chkResult) + {/*ǽ·Ρδ*/ + chkResult = CheckNonRoutePhysecFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == chkResult) + { /*ǽ·*/ + + chkResult = CheckNonRouteSwitchFengSuo(nonRouteId,functionId,sendLevel); + } + + if (CI_SUCCESS == chkResult) + { /*ǽ·*/ + + chkResult = CheckNonRouteRelProSwiFengSuo(nonRouteId,functionId,sendLevel); + } + + + if (CI_SUCCESS == chkResult) + { /*ǽ·λ*/ + + chkResult = CheckNonRouteSwitchPosRight(nonRouteId,functionId,sendLevel); + } + + + if (CI_SUCCESS == chkResult) + { /*ǽ·*/ + + chkResult = CheckNonRouteRelProSwiLockSta(nonRouteId,functionId,sendLevel); + } + + + if (CI_SUCCESS == chkResult) + {/**/ + chkResult = NonRouteIntruSecVainCheck(nonRouteId,functionId,sendLevel); + } + + + return chkResult; +} + + +/* C100 ϱ: EFUNC_CLD_CANCEL_NONROUTE */ +/* +* ȡǽ· +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ +*/ +UINT8 CancelNonRouteP(UINT8 nonRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_CLD_CANCEL_NONROUTE; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + UINT8 reVal = CI_ERROR; + + /* */ + /*ǽ·ռÿ*/ + reVal = CheckNonRoutePhySectionOccupy(nonRouteId,functionId,sendLevel); + + if(CI_SUCCESS == reVal) + { /*ǽ·ռ*/ + reVal = CheckNonRoutePhySectionLock(nonRouteId,functionId,sendLevel); + } + + return reVal; +} + +/* C101 ϱ: EFUNC_CLD_FAULT_CANCEL_NONROUTE */ +/* +* ȡǽ· +* ˵ UINT8 nonRouteIdǽ·ID +* ֵ +*/ +UINT8 FaultCancelNonRouteP(UINT8 nonRouteId) +{ +/**/ +UINT8 const functionId = EFUNC_CLD_FAULT_CANCEL_NONROUTE; + +/*Ϸͼ*/ +UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + +/* */ + + if (CI_ERROR == CheckNonRoutePhySectionLock(nonRouteId,functionId,sendLevel)) + { /*ǽ·ȷ*/ + + return CI_ERROR; + } + + return CI_SUCCESS; +} + + +/* C102 ϱ: EFUNC_CLD_CANCEL_D_TRAIN_ROUTE */ +/* +* ȡ·߼ +* ˵ UINT16 routeId, ·ID +* ֵ CI_ERROR +* CI_SUCCESS +*ϱ룺EFUNC_CLD_CANCEL_D_TRAIN_ROUTE +*/ +UINT8 CancelDTrainRouteP(const UINT16 routeId) +{ +/**/ + UINT8 const functionId = EFUNC_CLD_CANCEL_D_TRAIN_ROUTE; + +/*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 cancleZhaoChaRelayId = 0u; /*ȡղ̵ID*/ + UINT8 relayState = 0u; /*̵ɼ״̬*/ + UINT8 chRouteLevel = 0U; + + +/* */ +/*·*/ + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + + if (CI_SUCCESS == reResult) + {/*·гмζ*/ + checkResult = CheckDTrainRoutePhySecOccupy(routeId,functionId,sendLevel); + if (CI_SUCCESS == checkResult) + { + /*ͨ*/ + reResult = CI_SUCCESS; + } + else + { + /*ʧܷ*/ + reResult = CI_ERROR; + } + } + else + { + } + if (CI_SUCCESS == reResult) + {/*ȡղ̵״̬Ƿ*/ + chRouteLevel = GetRouteLevel(routeId); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCancleZhaoChaRelayId(routeId); /*ģʽȡղ̵ID*/ + } + else if (ROUTE_LEVEL_CBTC == chRouteLevel) + { + cancleZhaoChaRelayId = GetRouteCbtcCancelZhaochaRelay(routeId);/*CBTCģʽȡղ̵ID*/ + } + else + { + ; /*Ƿලģʽ̵IDΪ0治ᴦ*/ + } + if((0u != cancleZhaoChaRelayId) && (0xFFFFu != cancleZhaoChaRelayId)) + { + /*ȡ̵Чȡ̵ɼ״̬Ϊ*/ + relayState = GetRelayCollState(cancleZhaoChaRelayId);/*ȡȡ̵ɼ״̬*/ + devId = cancleZhaoChaRelayId; + devState = relayState; + if(RELAY_STATE_UP == relayState) + { + /* ͨ */ + reResult = CI_SUCCESS; + + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_RELAY,devId,ETYPE_CANCLE_ZHAOCHA,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + + } + else + { + } + + } + else + { + } + return reResult; +} + + + + + + +/*************************************************************************************************/ + + +/* +* г·źŻ +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetLTrainRouteSignalCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + +/* ·豸 */ + /* ʼźŻId */ + UINT16 const startSignalId = GetRouteStartSignalId(routeId); + + /* ߼ */ + + /* ·ʼźŻδ*/ + devState = GetSignalOpenCloseState(GetSignalCurColor(startSignalId)); + if (devState == SIGNAL_CLOSE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,startSignalId,ETYPE_SIG_START_OPEN_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + return reResult; + } + + /*·źŻδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_FLOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + return reResult; + } + + /*·ĵж*/ + devId = 0u; + devState = 0u; + checkResult = RouteSignalEnemyVainCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_SIGNAL,devId,ETYPE_SIG_ENEMY_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + return reResult; + } + + /* ؽ */ + return reResult; +} + + +/* +* г· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬δա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = TradLTrainRouteSecLockValCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* ʽ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetLTrainRouteSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 reResultP = CI_ERROR; /*λþֲ鷵ֵ*/ + UINT8 chConnetCheckFunc = 0U; + + chConnetCheckFunc = GetCiFunctionSwitchConfig(FUNC_SETROUTE_CONNECT_CHECK); /*ȡǷҪĿ*/ + + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchYLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchFLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + else + { + ; /*ִ*/ + } + + if (CI_SUCCESS == reResult) + { + /*·δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteReltProtSwitchFLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + checkResult = RouteAllLtrlDfncSwitchCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + if (FUNC_SWITCH_ON == chConnetCheckFunc) + { + ; /*ش򿪣*/ + } + else + { + /*·豸*/ + checkResult = RouteContactLineDevSwitchCheck(routeId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + if (CI_SUCCESS == reResult) + { + /*·еλȷλòȷɶ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchPosAndMoveValidCheck(routeId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + } + } + else + { + ; /*ִ*/ + } + + if (CI_SUCCESS == reResult) + { + /*·еλȷ + ȷRETURN_LOCK_ERR_SWITPOS + ȷCI_SUCCESS */ + devId = 0u; + devState = 0u; + checkResult = RouteAllSwitchPosCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + + } + } + else + { + /*ǽ·ڵȴ״̬,ȲǷȫλãȴ*/ + } + + if ((CI_SUCCESS == reResult) || (RETURN_LOCK_ERR_SWITPOS == reResult)) + { + /*·δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchYLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResultP = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResultP = CI_ERROR; + } + + if (CI_SUCCESS == reResultP) + { + /*·λȷλòȷɶ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelProSwiPosAndMovValCheck(routeId,sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ܼ鵽Ƿɶ˵ȫڱڿѷ״̬ */ + /* ͨ */ + reResultP = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResultP = checkResult; + } + } + else + { + reResultP = CI_ERROR; + } + + if (CI_SUCCESS == reResultP) + { + /*·λȷ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchPosCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResultP = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResultP = RETURN_LOCK_ERR_SWITPOS; + } + } + else + { + reResultP = CI_ERROR; + } + + if (CI_ERROR == reResultP) + {/*ļΪܵļΪ*/ + reResult = CI_ERROR; + } + else if (CI_SUCCESS == reResultP) + { + /*ļΪɹܵļֲ*/ + } + else if (RETURN_LOCK_ERR_WAIT_SWCHECK == reResultP) + { + /*ļȴ飬ܵļȴ*/ + reResult = RETURN_LOCK_ERR_WAIT_SWCHECK; + } + else if (RETURN_LOCK_ERR_SWITPOS == reResultP) + {/*ļΪλôܵļΪλô*/ + reResult = RETURN_LOCK_ERR_SWITPOS; + } + else + {/*ڵܵĽΪ*/ + reResult = CI_ERROR; + } + } + else if (RETURN_LOCK_ERR_WAIT_SWCHECK == reResult) + { + /*·ڵȴ״̬,Ȳ״̬ȴ*/ + ; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + /* ؽ */ + return reResult; +} + +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetDTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ռ״̬С ֹͣмβ */ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = CheckDTrainRoutePhySecOccupy(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬δա*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = DTrainRouteSecLockValidCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#if 0 + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetLeadRouteSectionC(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 checkSecFlockFlag = 0u; /*Ƿη*/ + UINT8 funcSwitch = 0u; /*ܿ*/ + + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG); + /* ߼ */ + if(NON_CHECK_SECFLOCK == checkSecFlockFlag) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ·δ */ + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬δá*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecUseVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_USE_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ·״̬δա*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221008 ·ǰ⶯*/ + checkResult = BlockRouteLogSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + checkResult = BlockRouteSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + /*·*/ + + /* ·߼Ρδ߼ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIncLogSecLogicLockCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + +#if 0 + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ڵһλ߼δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* г· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LockLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ռ״̬С*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ·״̬δա*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = TradLTrainRouteSecLockValCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* յ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LockDTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ռ״̬С ֹͣмβ */ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = CheckDTrainRoutePhySecOccupy(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬δա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = DTrainRouteSecLockValidCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState, ESEND_LEVEL_ATS); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } +#endif + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LockLeadRouteSectionC(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 checkSecFlockFlag = 0u; /*Ƿη*/ + UINT8 funcSwitch = 0u; /*ܿ*/ + + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG); + /* ߼ */ + if(NON_CHECK_SECFLOCK == checkSecFlockFlag) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ·δ */ + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬δա*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + if (FUNC_SWITCH_ON == funcSwitch) + { + /*modify 20221010 ·ǰ⶯*/ + checkResult = BlockRouteLogSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + checkResult = BlockRouteSecLockValidCheck(routeId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + /*·*/ +#if 0 + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ڵһλ߼δ*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteSwOtherLogLockValidCheck(routeId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_LOGICSEC, devId, ETYPE_LOGSEC_LOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* г· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ʼźŻδѹҽ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + startSignalId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + if ((SIGNAL_CROSS_STATE_NO == GetSignalCrossState(startSignalId)) && (CI_SUCCESS == checkResult)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_MERGY_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* ŵ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenDTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + /* ·ռ״̬С ֹͣмβ */ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = CheckDTrainRoutePhySecOccupy(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + +/* +* · +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 OpenLeadRouteSectionC(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 checkSecFlockFlag = 0u; /*Ƿη*/ + checkSecFlockFlag = GetCiFunctionSwitchConfig(FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG); + +/* ߼ */ + if(NON_CHECK_SECFLOCK == checkSecFlockFlag) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { /* ·δ */ + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬ա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /*·*/ +#if 0 + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } +#endif + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + + + +/* +* ·źռ +* ˵ +* UINT16 RouteId, · +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +UINT8 KeepLeadSecOccCheck(UINT16 routeId) +{ + /*ʼźŻ*/ + UINT16 startSignalId = GetRouteStartSignalId(routeId); + + /*źſʱ״̬*/ + UINT8 const leadSinalOpenState = SystemOverTimeCheck(GetRouteLeadFaultOpenStartCyc(routeId), + GetSystemParaLeadFaultOpenCyc()); + + /*·ʼźŻڷһ*/ + UINT16 const routeInFirstSecId = GetSignalInFirstPhySecId(startSignalId, routeId); + UINT8 const inSecCurOccupyState = GetPhySecCurMergeState(routeInFirstSecId); + /*·ʼźŻⷽһ*/ + UINT16 const routeOutFirstSecId = GetSignalOutFirstPhySecId(startSignalId); + UINT8 const outSecPreOccupyState = GetPhySecPreMergeState(routeOutFirstSecId); + UINT8 const outSecCurOccupyState = GetPhySecCurMergeState(routeOutFirstSecId); + UINT8 reResult = CI_ERROR; /*ֵ*/ + + if (leadSinalOpenState == CI_TIME_NO) + { + /*1.δʱ*/ + if (inSecCurOccupyState != SECTION_OCCUPY_NO) + { + /*źŻڷΡǰռá򡾹ϡźر*/ + reResult = CI_ERROR; + + } + else + { + /*1.3 ڷΡǰС*/ + reResult = CI_SUCCESS; + } + } + else if (leadSinalOpenState == CI_TIME_IN) + { + /*2.ʱ*/ + if(0u < routeOutFirstSecId) + { + /*2.1 ڷΡǰռáⷽΡǰСҡ֮ǰռáгȫʻ룩*/ + if ((inSecCurOccupyState != SECTION_OCCUPY_NO) && + (outSecCurOccupyState != SECTION_OCCUPY_YES) && (outSecPreOccupyState != SECTION_OCCUPY_NO)) + { + + /*رźŻ*/ + reResult = CI_ERROR; + } + else + { + /*ʱδ*/ + reResult = CI_SUCCESS; + } + } + else + { + /*ʱδ*/ + reResult = CI_SUCCESS; + } + } + else + { + /* 3.ʱ*/ + /*3.1źſʱ䳬ʱ*/ + reResult = CI_ERROR; + } + return reResult; +} + + +/* +* ŵ· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepDTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ +/* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + +/* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + + /* ·ռ״̬С ֹͣмβ */ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = CheckDTrainKeepSigPhySecOccupy(routeId,functionId,sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·״̬ա*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecLockStateCheck(routeId,PHYSICAL_SECTION_LOCK_NORMAL,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_LOCK_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /**/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(routeId,&devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_INTRU_OCU_STATE,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /* ·ΡδԾա*/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteAllSecJumpLockStateCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId,CI_DEVICE_TYPE_PHYSEC,devId,ETYPE_PS_JUMP_LOCK,devState,sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + /* ؽ */ + return reResult; +} + + +/* +* Σֿг· +* ˵ +* UINT16 RouteId, · +* UINT8 functionId, ú +* UINT8 sendLevel, 뷢ͼ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 KeepOpenLTrainRouteSectionCheck(UINT16 routeId,UINT8 functionId,UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 startSignalId = 0u; /*·ʼźŻID*/ + + UINT16 outPhySecId = 0u;/*źŻⷽ*/ + UINT16 inPhySecId = 0u;/*źŻڷһ*/ + + UINT16 routeInFirstLogSecId = 0u;/*·ڷһ߼Id*/ + UINT8 routeInFirstLogSecState = 0u;/*·ڷһ߼ռ״̬*/ + + UINT16 routeOutLastLogSecId = 0u;/*·ⷽһ߼Id*/ + UINT8 routeOutLastLogSecState = 0u;/*·ⷽһ߼ռ״̬*/ + + UINT16 outRouteId = 0u;/*źŻⷽ·ID*/ + + UINT8 crossState = 0u;/*ѹ״̬*/ + + RoutePhysicalSectionStruct* pRoutePhySecData = NULL;/*·*/ + UINT16 routePhyNum = 0u; + + + UINT16 ii = 0u;/**/ + UINT16 phyId = 0u;/*ID*/ + UINT16 phyOccupyFlag = 0u;/*ռñ־*/ + UINT8 hasUtFlag = 0u;/*UTռ*/ + UINT8 hasCtFlag = 0u;/*CTռ*/ + + UINT8 sigConfigCross = 0u;/*Ƿ˿ѹλ*/ + + UINT32 curCycle = 0u;/*ǰں*/ + UINT8 rcWorkMode = 0U;/*RCģʽ*/ + rcWorkMode = GetLocalRcWorkMode(); + + pRoutePhySecData = GetRouteSectionData(routeId); + routePhyNum = GetRoutePhysicalSectionSum(routeId); + + curCycle = Get2oo2CurCycleNum(); + + if ((NULL == pRoutePhySecData)|| (0u == routePhyNum)) + {/*·ûΣ߽·Ϊ*/ + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + /* ߼ */ + /* ·δ */ + devId = 0u; + devState = 0u; + if (CI_SUCCESS == reResult) + { + checkResult = RouteSecFLockCheck(routeId,&devId,&devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /*cgh-ϲCID-2539-1ηerrorcode*/ + AccToPhySecFlockTypeSetErrcode(devId, functionId, sendLevel, devState); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + + /* ·ʼźŻδѹҽ·ռ״̬С*/ + if(CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + + startSignalId = GetRouteStartSignalId(routeId);/*ȡ·ʼźŻID*/ + + inPhySecId = GetSignalInFirstPhySecId(startSignalId,routeId);/*ȡźŻڷһ*/ + + sigConfigCross = GetSigConfZcCiSignalCrossMask(startSignalId);/*ǷźŻѹλ*/ + + routeInFirstLogSecId = GetRouteInFirstLogSecId(routeId);/*ȡ·ڷһ߼Id*/ + routeInFirstLogSecState = GetLogSecCurCtOrUtOccupyState(routeInFirstLogSecId);/*ȡ·ڷһ߼ռ״̬*/ + + + crossState = GetSignalCrossState(startSignalId); + + if (SIGNAL_CROSS_STATE_NO == crossState) + { + /*δѹ*/ + checkResult = RouteAllSecOccuClearCheck(routeId,&devId, &devState); + + if (CI_SUCCESS == checkResult) + { + /*ȫ,ͨ飬ź*/ + reResult = CI_SUCCESS; + } + else + { + routeOutLastLogSecState = CheckRouteIdOutFirstLogSecState(routeId,&routeOutLastLogSecId); + /*·ΣUTռãźűʧ*/ + /*·ΣCTҵһ߼κⷽһһ߼CTռãźűֳɹʧ*/ + hasUtFlag = 0u; + hasCtFlag = 0u; + for (ii = 0u;ii0: λID +*/ +UINT16 GetMaskId(const UINT8 SendsystemType, const UINT8 RecvsystemType, const UINT16 Index) +{ + UINT16 returnValue = 0u;/*ֵ*/ + + if (SendsystemType == CI_SYSTEM_TYPE_CI) + { + switch (RecvsystemType) + { + case CI_SYSTEM_TYPE_ATS: + case CI_SYSTEM_TYPE_XIANDI: + returnValue = CiToAtsMaskConfigDataStru[Index].MaskId; + break; + + case CI_SYSTEM_TYPE_ZC: + returnValue = CiToZcMaskConfigDataStru[Index].MaskId; + break; + + case CI_SYSTEM_TYPE_LEU: + returnValue = CiToLeuMaskConfigDataStru[Index].MaskId; + break; + + default: + returnValue = 0u; + break; + } + } + else if (SendsystemType == CI_SYSTEM_TYPE_ZC) + { + if (CI_SYSTEM_TYPE_CI == RecvsystemType) + { + returnValue = ZcToCiMaskConfigDataStru[Index].MaskId; + } + else + { + returnValue = 0u; + } + } + else + { + returnValue = 0u; + } + + return returnValue; +} + +/* +* ȡָCIָϵͳλ +* ˵ const UINT8 systemType, ϵͳ +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT16 GetSendMaskSum(const UINT8 systemType) +{ + UINT16 returnValue = 0u; + switch (systemType) + { + case CI_SYSTEM_TYPE_ATS: + case CI_SYSTEM_TYPE_XIANDI: + returnValue = CiToAtsMaskCurSum; + break; + + case CI_SYSTEM_TYPE_ZC: + returnValue = CiToZcMaskCurSum; + break; + + case CI_SYSTEM_TYPE_LEU: + returnValue = CiToLeuMaskCurSum; + break; + + default: + returnValue = 0u; + break; + } + + return returnValue; +} + + +/* +* ȡָCIָϵͳλ +* ˵ const UINT8 sourceSystemType, Դϵͳ +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT16 GetReceiveMaskSum(const UINT8 sourceSystemType) +{ + UINT16 returnValue = 0u; + switch (sourceSystemType) + { + case CI_SYSTEM_TYPE_ZC: + returnValue = ZcToCiMaskCurSum; + break; + + case CI_SYSTEM_TYPE_LEU: + returnValue = LeuToCiStruSum; + break; + + default: + returnValue = 0u; + break; + } + + return returnValue; +} + + +/* +* ȡָCIָϵͳλ豸 +* ˵ const UINT8 destSystemType, Ŀϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: 豸 +*/ +UINT8 GetSendMaskDeviceType(const UINT8 destSystemType, const UINT16 Index) +{ + UINT8 returnValue = 0u; + + switch (destSystemType) + { + case CI_SYSTEM_TYPE_ATS: + case CI_SYSTEM_TYPE_XIANDI: + returnValue = CiToAtsMaskConfigDataStru[Index].DeviceType; + break; + + case CI_SYSTEM_TYPE_ZC: + returnValue = CiToZcMaskConfigDataStru[Index].DeviceType; + break; + + case CI_SYSTEM_TYPE_LEU: + returnValue = CiToLeuMaskConfigDataStru[Index].DeviceType; + break; + + default: + returnValue = 0u; + break; + } + + return returnValue; +} + + +/* +* ȡָCIָϵͳλ豸ID +* ˵ const UINT8 destSystemType, Ŀϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: 豸ID +*/ +UINT16 GetSendMaskDeviceId(const UINT8 destSystemType, const UINT16 Index) +{ + UINT16 returnValue = 0u;/*ֵ*/ + + switch (destSystemType) + { + case CI_SYSTEM_TYPE_ATS: + case CI_SYSTEM_TYPE_XIANDI: + returnValue = CiToAtsMaskConfigDataStru[Index].DeviceId; + break; + + case CI_SYSTEM_TYPE_ZC: + returnValue = CiToZcMaskConfigDataStru[Index].DeviceId; + break; + + case CI_SYSTEM_TYPE_LEU: + returnValue = CiToLeuMaskConfigDataStru[Index].DeviceId; + break; + + default: + returnValue = 0u; + break; + } + + return returnValue; +} + + +/* +* ȡָCIָϵͳλ +* ˵ const UINT8 destSystemType, Ŀϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetSendMaskType(const UINT8 destSystemType, const UINT16 Index) +{ + UINT8 returnValue = 0u; + + switch (destSystemType) + { + case CI_SYSTEM_TYPE_ATS: + case CI_SYSTEM_TYPE_XIANDI: + returnValue = CiToAtsMaskConfigDataStru[Index].MaskType; + break; + + case CI_SYSTEM_TYPE_ZC: + returnValue = CiToZcMaskConfigDataStru[Index].MaskType; + break; + + case CI_SYSTEM_TYPE_LEU: + returnValue = CiToLeuMaskConfigDataStru[Index].MaskType; + break; + + default: + returnValue = 0u; + break; + } + + return returnValue; +} + + +/* +* ȡϵͳCIλ豸 +* ˵ const UINT8 sourceSystemType, Դϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: 豸 +*/ +UINT8 GetReceiveMaskDeviceType(const UINT8 sourceSystemType,const UINT16 Index) +{ + UINT8 returnValue = 0u;/*ֵ*/ + + if (CI_SYSTEM_TYPE_ZC == sourceSystemType) + { + returnValue = ZcToCiMaskConfigDataStru[Index].DeviceType; + } + else + { + returnValue = 0u; + } + + return returnValue; +} + + +/* +* ȡϵͳCIλ豸ID +* ˵ const UINT8 sourceSystemType, Դϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: 豸ID +*/ +UINT16 GetReceiveMaskDeviceId(const UINT8 sourceSystemType,const UINT16 Index) +{ + UINT16 returnValue = 0u;/*ֵ*/ + + + if (CI_SYSTEM_TYPE_ZC == sourceSystemType) + { + returnValue = ZcToCiMaskConfigDataStru[Index].DeviceId; + } + else + { + returnValue = 0u; + } + + return returnValue; +} + + +/* +* ȡϵͳCIλ +* ˵ const UINT8 sourceSystemType, Դϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetReceiveMaskType(const UINT8 sourceSystemType,const UINT16 Index) +{ + UINT8 returnValue = 0u;/*ֵ*/ + + + if (CI_SYSTEM_TYPE_ZC == sourceSystemType) + { + returnValue = ZcToCiMaskConfigDataStru[Index].MaskType; + } + else + { + returnValue = 0u; + } + + return returnValue; +} + +/* +* ȡָλID± +* ˵ const UINT8 SendsystemType, ͷϵͳ +* const UINT8 RecvsystemType, ܷϵͳ +* const UINT16 maskId, λID +* ֵ 0: ȡʧ +* >0: ± +*/ +UINT16 GetMaskIndex(const UINT8 SendsystemType, const UINT8 RecvsystemType, const UINT16 maskId) +{ + UINT16 returnValue = 0u;/*ֵ*/ + UINT16 ii = 0u; + + + + if (SendsystemType == CI_SYSTEM_TYPE_CI) + { + switch (RecvsystemType) + { + case CI_SYSTEM_TYPE_ATS: + case CI_SYSTEM_TYPE_XIANDI: + for (ii = 1u; ii <= CiToAtsMaskCurSum; ii++) + { + if (CiToAtsMaskConfigDataStru[ii].MaskId == maskId) + { + returnValue = ii; + break; + } + } + break; + + case CI_SYSTEM_TYPE_ZC: + for (ii = 1u; ii <= CiToZcMaskCurSum; ii++) + { + if (CiToZcMaskConfigDataStru[ii].MaskId == maskId) + { + returnValue = ii; + break; + } + } + break; + + case CI_SYSTEM_TYPE_LEU: + for (ii = 1u; ii <= CiToLeuMaskCurSum; ii++) + { + if (CiToLeuMaskConfigDataStru[ii].MaskId == maskId) + { + returnValue = ii; + break; + } + } + break; + + default: + returnValue = 0u; + break; + } + } + else if (SendsystemType == CI_SYSTEM_TYPE_ZC) + { + if (CI_SYSTEM_TYPE_CI == RecvsystemType) + { + for (ii = 1u; ii <= ZcToCiMaskCurSum; ii++) + { + if (ZcToCiMaskConfigDataStru[ii].MaskId == maskId) + { + returnValue = ii; + break; + } + } + } + else + { + returnValue = 0u; + } + } + else + { + returnValue = 0u; + } + + return returnValue; +} diff --git a/TSCP/src/APP/ciapp/Mask/MaskConfigDataManage.h b/TSCP/src/APP/ciapp/Mask/MaskConfigDataManage.h new file mode 100644 index 0000000..2596123 --- /dev/null +++ b/TSCP/src/APP/ciapp/Mask/MaskConfigDataManage.h @@ -0,0 +1,158 @@ +/******************************************************** +* +* MaskConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-05-03 +* ߣ +* λݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _MASK_CONFIG_DATA_MANAGE_H_ +#define _MASK_CONFIG_DATA_MANAGE_H_ + + +#include "CommonTypes.h" +#include "MaskDefine.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*λݽṹ*/ +typedef struct S_MaskConfigDataStruct +{ + UINT16 MaskId; /*λID (ֶ)*/ + UINT8 DeviceType; /*豸 (ֶ)*/ + UINT16 DeviceId; /*豸ID (ֶ)*/ + UINT8 MaskType; /*λ (ֶ)*/ +} MaskConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern MaskConfigDataStruct CiToAtsMaskConfigDataStru[CI_TO_ATS_MASK_SUM_MAX]; /*CIվATSλ*/ +extern UINT16 CiToAtsMaskCurSum ; /*CIվATSλǰ*/ + +extern MaskConfigDataStruct CiToZcMaskConfigDataStru[CI_TO_ZC_MASK_SUM_MAX]; /*CIվZCλ*/ +extern UINT16 CiToZcMaskCurSum ; /*CIվZCλǰ*/ + +extern MaskConfigDataStruct CiToCiMaskConfigDataStru[CI_SUM_MAX][CI_TO_CI_MASK_SUM_MAX]; /*CIվCIλ*/ +extern UINT16 CiToCiMaskCurSum[CI_SUM_MAX] ; /*CIվCIλǰ*/ + +extern MaskConfigDataStruct ZcToCiMaskConfigDataStru[ZC_TO_CI_MASK_SUM_MAX]; /*ZCվCIλ*/ +extern UINT16 ZcToCiMaskCurSum ; /*CIվZCλǰ*/ + +extern MaskConfigDataStruct CiToLeuMaskConfigDataStru[CI_TO_LEU_MASK_SUM_MAX]; /*CILEUλ*/ +extern UINT16 CiToLeuMaskCurSum ; /*CIվLeuλǰ*/ + +extern MaskConfigDataStruct CiToVobcMaskConfigDataStru[CI_SUM_MAX][ZC_TO_CI_MASK_SUM_MAX]; /*CIVOBCλ*/ +extern UINT16 CiToVobcMaskCurSum[CI_SUM_MAX] ; /*CIվVOBCλǰ*/ + +extern MaskConfigDataStruct VobcToCiMaskConfigDataStru[CI_SUM_MAX][ZC_TO_CI_MASK_SUM_MAX]; /*VOBCCIλ*/ +extern UINT16 VobcToCiMaskCurSum[CI_SUM_MAX] ; /*VOBCCIλǰ*/ + +extern UINT16 LeuToCiStruSum ; /*LeuݿĿ*/ + + +/* +* ȡָϵͳλָ±λID +* ˵ const UINT8 SendsystemType, ͷϵͳ +* const UINT8 RecvsystemType, ܷϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: λID +*/ +UINT16 GetMaskId(const UINT8 SendsystemType, const UINT8 RecvsystemType, const UINT16 Index); + +/* +* ȡָCIָϵͳλ +* ˵ const UINT8 systemType, ϵͳ +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT16 GetSendMaskSum(const UINT8 systemType); + +/* +* ȡָCIָϵͳλ +* ˵ const UINT8 sourceSystemType, Դϵͳ +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT16 GetReceiveMaskSum(const UINT8 sourceSystemType); + +/* +* ȡָCIָϵͳλ豸 +* ˵ const UINT8 destSystemType, Ŀϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: 豸 +*/ +UINT8 GetSendMaskDeviceType(const UINT8 destSystemType, const UINT16 Index); + +/* +* ȡָCIָϵͳλ豸ID +* ˵ const UINT8 destSystemType, Ŀϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: 豸ID +*/ +UINT16 GetSendMaskDeviceId(const UINT8 destSystemType, const UINT16 Index); + +/* +* ȡָCIָϵͳλ +* ˵ const UINT8 destSystemType, Ŀϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetSendMaskType(const UINT8 destSystemType, const UINT16 Index); + +/* +* ȡϵͳCIλ豸 +* ˵ const UINT8 sourceSystemType, Դϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: 豸 +*/ +UINT8 GetReceiveMaskDeviceType(const UINT8 sourceSystemType,const UINT16 Index); + +/* +* ȡϵͳCIλ豸ID +* ˵ const UINT8 sourceSystemType, Դϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: 豸ID +*/ +UINT16 GetReceiveMaskDeviceId(const UINT8 sourceSystemType,const UINT16 Index); + +/* +* ȡϵͳCIλ +* ˵ const UINT8 sourceSystemType, Դϵͳ +* const UINT16 Index, ± +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetReceiveMaskType(const UINT8 sourceSystemType,const UINT16 Index); + +/* +* ȡָλID± +* ˵ const UINT8 SendsystemType, ͷϵͳ +* const UINT8 RecvsystemType, ܷϵͳ +* const UINT16 maskId, λID +* ֵ 0: ȡʧ +* >0: ± +*/ +UINT16 GetMaskIndex(const UINT8 SendsystemType, const UINT8 RecvsystemType, const UINT16 maskId); + + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Mask/MaskDefine.h b/TSCP/src/APP/ciapp/Mask/MaskDefine.h new file mode 100644 index 0000000..71ebeb1 --- /dev/null +++ b/TSCP/src/APP/ciapp/Mask/MaskDefine.h @@ -0,0 +1,225 @@ +/******************************************************** +* +* MaskConfigDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-01 +* ߣ +* λöͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _MASK_CONFIG_DEFINE_H_ +#define _MASK_CONFIG_DEFINE_H_ + + +/*ϵͳͷļ*/ +#include "../System/SystemConfigDefine.h" +#include "../System/CiSystemDefine.h" + + +/*λֵ*/ +#define CI_TO_ATS_MASK_SUM_MAX ((UINT16)10000) /*CIATSλֵ*/ +#define CI_TO_ZC_MASK_SUM_MAX ((UINT16)4000) /*CIZCλֵ*/ +#define ZC_TO_CI_MASK_SUM_MAX ((UINT16)4000) /*ZCCIλֵ*/ +#define CI_TO_CI_MASK_SUM_MAX ((UINT16)1000) /*CICIλֵ*/ +#define CI_TO_LEU_MASK_SUM_MAX ((UINT16)144) /*CILEUλֵ*/ + + +#define LEU_TO_CI_DATA_SUM_MAX ((UINT16)20) /*LEUCiݸֵ*/ +#define LEU_TO_CI_DATA_LENGTH ((UINT16)24) /*LEUCIÿݵij*/ + + +/*λ*/ +#define MASK_TYPE_SWITCH_DINGWEI ((UINT8)0x01) /*λλ*/ +#define MASK_TYPE_SWITCH_FANWEI ((UINT8)0x02) /*λλ*/ +#define MASK_TYPE_SWITCH_MOVING ((UINT8)0x03) /*ƶλ*/ +#define MASK_TYPE_SWITCH_SIKAI ((UINT8)0x04) /*Ŀλ*/ +#define MASK_TYPE_SWITCH_DYNAMIC_JICHA ((UINT8)0x05) /*̬λ*/ +#define MASK_TYPE_SWITCH_DANSUO ((UINT8)0x06) /*λ*/ +#define MASK_TYPE_SWITCH_FENGSUO ((UINT8)0x07) /*λ*/ +#define MASK_TYPE_SWITCH_YINDAOSUO ((UINT8)0x08) /*λ*/ +#define MASK_TYPE_SWITCH_DINGWEI_LOGIC ((UINT8)0x0A) /*λλ߼жã*/ +#define MASK_TYPE_SWITCH_FANWEI_LOGIC ((UINT8)0x0B) /*λλ߼жã*/ + +#define MASK_TYPE_SWITCH_LOCKSTATE ((UINT8)0x09) /*״̬λ*/ +#define MASK_TYPE_SWITCH_PROTECTLOCK ((UINT8)0x0C) /*λ*/ +#define MASK_TYPE_SWITCH_BYPASS ((UINT8)0x0D) /*·λ*/ +#define MASK_TYPE_SWITCH_OPEN_CAP ((UINT8)0x0E) /*ڰ忨״̬*/ +#define MASK_TYPE_SWITCH_SUDDEN_JICHA ((UINT8)0x0F) /*̬λ*/ + +/*_λ*/ +/* zt ɾش 2022-02-15 */ + +/*źŻλ*/ +#define MASK_TYPE_SIGNAL_RED ((UINT8)0x10) /*źŻλ*/ +#define MASK_TYPE_SIGNAL_GREEN ((UINT8)0x11) /*źŻ̵λ*/ +#define MASK_TYPE_SIGNAL_YELLOW ((UINT8)0x12) /*źŻƵλ*/ +#define MASK_TYPE_SIGNAL_REDYELLOW ((UINT8)0x13) /*źŻƵλ*/ +#define MASK_TYPE_SIGNAL_WHITE ((UINT8)0x14) /*źŻ׵λ*/ +#define MASK_TYPE_SIGNAL_REDCLOSE ((UINT8)0x15) /*źŻλ*/ +#define MASK_TYPE_SIGNAL_GREENCLOSE ((UINT8)0x16) /*źŻλ*/ +#define MASK_TYPE_SIGNAL_YELLOWCLOSE ((UINT8)0x17) /*źŻλ*/ +#define MASK_TYPE_SIGNAL_REDBREAK ((UINT8)0x18) /*źŻλ*/ +#define MASK_TYPE_SIGNAL_GREENBREAK ((UINT8)0x19) /*źŻ̶λ*/ +#define MASK_TYPE_SIGNAL_YELLOWBREAK ((UINT8)0x1a) /*źŻƶλ*/ +#define MASK_TYPE_SIGNAL_WHITEBREAK ((UINT8)0x1b) /*źŻ׶λ*/ +#define MASK_TYPE_SIGNAL_BREAK ((UINT8)0x1c) /*źŻ˿λ*/ +#define MASK_TYPE_SIGNAL_FENGSUO ((UINT8)0x1d) /*źŻλ*/ + +#define MASK_TYPE_SIGNAL_OPENSTATE ((UINT8)0x1e) /*źŻ״̬λ*/ +#define MASK_ZC_CI_TYPE_SIGNAL_OCCUPYED ((UINT8)0x1f) /*ZC-CIͨųѹͨźŻ״̬λ*/ +#define MASK_TYPE_SIGNAL_LIGHTSTATE ((UINT8)0x20) /*źŻ״̬λ*/ +#define MASK_CI_ZC_SIGNAL_OCCUPYED_REC ((UINT8)0x24) /*CI-ZCѹźŻ״̬ȷλ*/ + +#define MASK_TYPE_SIGNAL_CENTER_DETAIN ((UINT8)0x21) /*Ŀ۳λ˹*/ +#define MASK_TYPE_SIGNAL_LOCAL_DETAIN ((UINT8)0x22) /*峵վ۳λ*/ +#define MASK_TYPE_SIGNAL_RELAY_DETAIN ((UINT8)0x5d) /*Ӳ߿۳λ*/ +#define MASK_TYPE_SIGNAL_LINSHIXIANSU_SET ((UINT8)0x23) /*ʱλ*/ + +#define MASK_TYPE_SIGNAL_DOUBLE_GREEN ((UINT8)0x54) /*źŻ˫λ*/ +#define MASK_TYPE_SIGNAL_DOUBLE_YELLOW ((UINT8)0x55) /*źŻ˫λ*/ +#define MASK_TYPE_SIGNAL_GREEN_YELLOW ((UINT8)0x56) /*źŻ̻λ*/ +#define MASK_TYPE_SIGNAL_MAINTAINSTATE ((UINT8)0x57) /*źŻά޵״̬*/ + +#define MASK_TYPE_SIGNAL_CLOSE_ABNORMAL ((UINT8)0x58) /* źŻ쳣رλ *//* add 2022.02.28 */ +#define MASK_TYPE_SIGNAL_OC_BOARD_FAULT ((UINT8)0x5a) /*źŻOC忨ϱ״̬,ϴ޸ֵ*/ +#define MASK_TYPE_SIGNAL_CANCEL_DET_ERR ((UINT8)0x5b) /*źŻȡ۳ť״̬λ*/ +#define MASK_TYPE_SIGNAL_DET_ERR ((UINT8)0x5c) /*źŻ۳ť״̬λ*/ +#define MASK_TYPE_SIGNAL_AUTO_DERAIN ((UINT8)0x5e) /*źŻԶ۳λ*/ + +#define MASK_ZC_CI_SIG_ENGINEERV_NEAR ((UINT8)0x97) /*źŻ̳ӽλ*/ +#define MASK_CI_ZC_SIG_ENGINCROSS_STE ((UINT8)0x98) /*źŻ̳صλ*/ + +/*λ*/ +#define MASK_TYPE_PHYSECTION_OCCUPY ((UINT8)0x25) /*ռλ*/ +#define MASK_TYPE_PHYSECTION_STARTLOCK ((UINT8)0x26) /*ϵλ*/ +#define MASK_TYPE_PHYSECTION_ROUTELOCK ((UINT8)0x27) /*ν·λ*/ +#define MASK_TYPE_PHYSECTION_PROTECTLOCK ((UINT8)0x28) /*ηλ*/ +#define MASK_TYPE_PHYSECTION_FAULTLOCK ((UINT8)0x29) /*ιλ*/ +#define MASK_TYPE_PHYSECTION_FLOCK ((UINT8)0x2a) /*η״̬λ*/ +#define MASK_TYPE_PHYSECTION_JUMPLOCK ((UINT8)0x2c) /*Ծ״̬λ*/ +#define MASK_TYPE_PHYSECTION_PRERESET ((UINT8)0x3c) /*Ԥȸλ״̬λ*/ +#define MASK_TYPE_PHYSECTION_JUMPLOCK_APPLY ((UINT8)0x2d) /*ԾλZC->CI*/ +#define MASK_TYPE_PHYSECTION_JUMPLOCK_CANCEL ((UINT8)0x2e) /*ԾȡλZC->CI*/ +#define MASK_TYPE_PHYSECTION_JUMPLOCK_ZC ((UINT8)0x2f) /*Ծ״̬λ(CI-ZC)*/ +#define MASK_TYPE_PHYSECTION_UT_OCC ((UINT8)0xa0) /*ιռλ*/ +#define MASK_TYPE_PHYSEC_FLOCK_SPKS ((UINT8)0xa1) /*η״̬λ(SPKS) --¼ 20230417lc*/ +#define MASK_TYPE_PHYSECTION_ROUTELOCK_SHOW ((UINT8)0x2b) /*ν·ʾλ(ֵ/ATSʹ)*/ +#define MASK_TYPE_AXISSECTION_ARB ((UINT8)0x35) /*ARB״̬λ*/ +#define MASK_TYPE_PHYSECTION_HEAD_XTD ((UINT8)0x31) /*з״̬λ*/ +#define MASK_TYPE_PHYSECTION_HEAD_STD ((UINT8)0x32) /*з״̬λ*/ +#define MASK_TYPE_LIECHE_STOPSTATE ((UINT8)0x3a) /*гͣϢ״̬λ*/ + + +/*߼λ*/ +#define MASK_TYPE_LOGICSECTION_UTOCCUPY ((UINT8)0x33) /*߼ηͨųռλ*/ +#define MASK_TYPE_LOGICSECTION_CTOCCUPY ((UINT8)0x34) /*߼ͨųռλ*/ +#define MASK_TYPE_LOGICSECTION_TXOCCUPY ((UINT8)0x53) /*߼ͨŵRMռλADD by yt 2022518 TSCIϲ 20221208-lc*/ +#define MASK_TYPE_LOGICSECTION_LINSHIXIANSU_SET ((UINT8)0x36) /*߼ʱλ*/ +#define MASK_TYPE_LOGICSECTION_LOCK ((UINT8)0x37) /* CI-ZC߼λ */ +#define MASK_TYPE_LOGICSECTION_DIR_UP ((UINT8)0x38) /* CI-ZCзλ */ +#define MASK_TYPE_LOGICSECTION_DIR_DOWN ((UINT8)0x39) /* CI-ZCзλ */ +#define MASK_TYPE_LOGICSECTION_ROUTELOCK ((UINT8)0x97) /*߼ν·λ*/ +#define MASK_TYPE_LOGICSECTION_FAULTLOCK ((UINT8)0x98) /*߼ιλ*/ +#define MASK_TYPE_UPWARD_DIRECTION ((UINT8)0x93) /*߼λ*/ +#define MASK_TYPE_DOWNWARD_DIRECTION ((UINT8)0x94) /*߼λ*/ +#define MASK_TYPE_LOGICSECTION_PROTECTLOCK ((UINT8)0x99) /*߼ηλ*/ +#define MASK_TYPE_LOGICSECTION_JUMPLOCK ((UINT8)0x9A) /*߼Ծλ*/ +#define MASK_TYPE_LOGICSECTION_ARB ((UINT8)0x9B) /*߼ARB״̬λ*/ +#define MASK_TYPE_LOGICSECTION_SPKS_FLOCK ((UINT8)0x9C) /*߼SPKS״̬λ*/ + + + +/*λ*/ +#define MASK_TYPE_OVERLAP_LOCKSTATE ((UINT8)0x30) /*屣״̬λ*/ +#define MASK_TYPE_OVERLAP_UNLOCK_APPLY ((UINT8)0x3b) /*CI->ZCνλ*/ + + +/*·λ*/ +#define MASK_TYPE_ROUTE_IDLE ((UINT8)0x40) /*·λ*/ +#define MASK_TYPE_ROUTE_XUANPAI ((UINT8)0x41) /*·ѡλ*/ +#define MASK_TYPE_ROUTE_ALLLOCK ((UINT8)0x42) /*·λCI-ATS*/ +#define MASK_TYPE_ROUTE_PARTLOCK ((UINT8)0x43) /*·λ*/ +#define MASK_TYPE_ROUTE_DELAYUNLOCK ((UINT8)0x44) /*·ʱλ*/ + +#define MASK_TYPE_ROUTE_LOCKSTATE ((UINT8)0x45) /*·δλ*/ +#define MASK_TYPE_ROUTE_OPENSTATE ((UINT8)0x49) /*·״̬λ(CI-LEU)*/ +#define MASK_TYPE_ROUTE_EXISTENCE ((UINT8)0x4A) /*·״̬λ(CI-ATS)*/ +#define MASK_TYPE_ROUTE_NEARLOCK ((UINT8)0x4B) /*·ӽ״̬λ(CI-ATS)*/ +#define MASK_TYPE_ROUTE_STOPE_APPLY ((UINT8)0x4C) /*֤ͣ־λ CI->ZC */ +#define MASK_TYPE_ROUTE_STOPENABLEE_STATUS ((UINT8)0x4D) /*֤ͣ־λ ZC -> CI */ +#define MASK_TYPE_ROUTE_SIGNAL_STATE ((UINT8)0x4E) /* CI-LEUλ(źźƻƻ01)*/ +#define MASK_TYPE_ROUTE_YINDAOLOCK ((UINT8)0x4F) /*·״̬λ(CI-ATS)*/ +#define MASK_TYPE_ROUTE_DC_QINGQIU ((UINT8)0x51) /*·״̬λ(CI-ATS)*/ +#define MASK_TYPE_ROUTE_DC_AGREE ((UINT8)0x52) /*·ͬ״̬λ(CI-ATS)*/ +#define MASK_TYPE_ROUTE_AUTO_TRIGGER ((UINT8)0x53) /*·Զλ(CI-ATS)*/ + + +/*վ̨λ*/ +#define MASK_TYPE_PLAT_AUTORETURNSIG_FLASH ((UINT8)0x46) /*վ̨۷״̬λ*/ +#define MASK_TYPE_PLAT_AUTORETURNSIG_STEADY ((UINT8)0x47) /*վ̨۷ȵ״̬λ*/ +#define MASK_TYPE_PLAT_AUTORETURNSIG_BUTTONSTAT ((UINT8)0x48) /*վ̨۷ť״̬λ*/ + +/*վ̨رհťλ*/ +#define MASK_TYPE_ESP_STATE ((UINT8)0x50) /*վ̨ر״̬λ*/ +#define MASK_TYPE_ESS_STEADY_STATE ((UINT8)0x9a) /*ESSȵ״̬λ*/ +#define MASK_TYPE_ESP_FLASH_STATE ((UINT8)0x9b) /*ESSƵ״̬λ*/ +#define MASK_TYPE_CANCEL_ESP_FAULT ((UINT8)0x9c) /*ȡرհťλ*/ +#define MASK_TYPE_ESP_FAULT ((UINT8)0x9d) /*رհťλ*/ + +/*վ̨ȫλ*/ +#define MASK_TYPE_PSD_STATE ((UINT8)0x60) /*վ̨ȫ״̬λ-ZC,LEU*/ +#define MASK_TYPE_MUTUALLOCK_STATE ((UINT8)0x61) /*վ̨ȫŻλ*/ +#define MASK_TYPE_REMORA_STATE ((UINT8)0x69) /*վ̨ȫϰϢλ*/ +#define MASK_TYPE_PSD_PCB ((UINT8)0x85) /*վ̨ȫPCBť״̬λ*/ +#define MASK_TYPE_PSD_POB ((UINT8)0x86) /*վ̨ȫPOBť״̬λ*/ +#define MASK_TYPE_PSD_PSB ((UINT8)0x87) /*վ̨ȫPSBť״̬λ*/ +#define MASK_TYPE_PSD_PCB_INVALID ((UINT8)0x88) /*վ̨ȫPCBťʧЧ״̬λ*/ +#define MASK_TYPE_PSD_POB_INVALID ((UINT8)0x89) /*վ̨ȫPOBťʧЧ״̬λ*/ +#define MASK_TYPE_PSD_PSB_INVALID ((UINT8)0x90) /*վ̨ȫPSBťʧЧ״̬λ*/ +#define MASK_TYPE_PSD_JXTC_PANGLU ((UINT8)0x91) /*վ̨ȫż϶̽·״̬*/ +#define MASK_TYPE_PSD_PCBPSBDPB_PANGLU_STATE ((UINT8)0x92) /*PCB/POB/DPB·״̬λ*/ +#define MASK_TYPE_PSD_STATE_ATS ((UINT8)0x99) /*վ̨ȫ״̬λ-ATS*/ +#define MASK_TYPE_PSD_PDB_FLASH_STATE ((UINT8)0xA0) /*ȷPDBťָʾ״̬λ*/ +#define MASK_TYPE_PSD_VIDEO_QK_LU ((UINT8)0xA1) /*ͰťƵͱʾƣ)״̬λ*/ +#define MASK_TYPE_PSD_VIDEO_QK_HONG ((UINT8)0xA2) /*ͰťƵͱʾƣ)״̬λ*/ + +/*λ*/ +#define MASK_TYPE_GARAGEDOOR_OPEN_STATE ((UINT8)0x62) /*峵ſ״̬λCI->ATS*/ +#define MASK_TYPE_GARAGEDOOR_CLOSE_STATE ((UINT8)0x63) /*峵Ź״̬λCI->ATS*/ +#define MASK_TYPE_GARAGEDOOR_MODE_STATE ((UINT8)0x64) /*峵ģʽ״̬λCI->ATS*/ +#define MASK_TYPE_GARAGEDOOR_APPLYCLOSE_STATE ((UINT8)0x65) /*峵رλCI->ZC*/ +#define MASK_TYPE_GARAGEDOOR_ALLOWCLOSE_STATE ((UINT8)0x66) /*峵رλZC->CI*/ +#define MASK_TYPE_GARAGEDOOR_STATE ((UINT8)0x67) /*峵״̬λCI->ZC*/ +#define MASK_TYPE_GARAGEDOOR_FAULT_STATE ((UINT8)0x68) /*峵Ź״̬λCI->ATS*/ +#define MASK_TYPE_GARAGEDOOR_PANGLU_STATE ((UINT8)0x69) /*峵·״̬λCI->ATS*/ + +/*·λ*/ +#define MASK_TYPE_AUTORETURN_STATE ((UINT8)0x70) /*Զ۷״̬λ*/ +#define MASK_TYPE_AUTOROUTE_STATE ((UINT8)0x71) /*Զͨ״̬λ*/ +#define MASK_TYPE_ALLAUTORETURN_STATE ((UINT8)0x72) /*ȫԶ۷״̬λ*/ + +/*SPKSλ*/ +#define MASK_TYPE_SPKS_OPENSTATE ((UINT8)0x73) /*SPKS״̬λ*/ +#define MASK_TYPE_SPKS_ISOLATE_BUTTON_STATE ((UINT8)0x83) /*SPKS·ť״̬λ*/ +#define MASK_TYPE_SPKS_OPENSTATE_ZC ((UINT8)0x84) /*SPKS״̬λ:spks+·ں״̬CI-ZC*/ + +/*λ*/ +#define MASK_TYPE_FD_OPENLOCK_TO_ATS ((UINT8)0x75) /*ſλ CI-ATS*/ +#define MASK_TYPE_FD_OPENLOCK_TO_ZC ((UINT8)0x78) /*ſλ CI-ZC*/ +#define MASK_TYPE_FLOODGATE_CLOSEAPLAY_STATE ((UINT8)0x76) /*Źλ CI-ZC/CI-ATS*/ +#define MASK_TYPE_FLOODGATE_AGREECLOSE_TOATS ((UINT8)0x77) /*ͬλ CI-ATS*/ +#define MASK_TYPE_FLOODGATE_SQGM_TOZC ((UINT8)0x95) /*CI-ZCرλ*/ +#define MASK_TYPE_FLOODGATE_YXGM_FROMZC ((UINT8)0x96) /*CI-ZCرλ*/ + +/*ϴλ*/ +#define MASK_TYPE_WASHMACHINE_READYSTATE ((UINT8)0x74) /*ϴ״̬λ*/ +#define MASK_TYPE_WASHMACHINE_WORKMODE ((UINT8)0x9E) /*ϴģʽλ*/ + +/*λ*/ + + +#endif diff --git a/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnConfigDataManage.c b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnConfigDataManage.c new file mode 100644 index 0000000..45057ff --- /dev/null +++ b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnConfigDataManage.c @@ -0,0 +1,268 @@ +/******************************************************** +* +* NonAutoReturnConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ۷ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "NonAutoReturnConfigDataManage.h" + +NonAutoReturnConfigDataStruct NonReturnConfigDataStru[NON_AUTO_RETURN_SUM_MAX]; /*Զ۷ýṹ*/ +UINT16 LocalCiNonReturnIdBuf[NON_AUTO_RETURN_SUM_MAX] = {0u}; /*屾Զ۷ťӳ*/ +INT16 gNonReturnCurSum = 0; /*Զ۷ǰ*/ + +/* +* ȡָID۷± +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ۷±ID +*/ +UINT16 GetNonReturnBufIndex(const UINT16 nonReturnId) +{ + UINT16 returnValue = NON_AUTO_RETURN_SUM_MAX; + + if ((nonReturnId >= 1u) && (nonReturnId < NON_AUTO_RETURN_SUM_MAX)) + { + returnValue = nonReturnId; + } + else + { + returnValue = NON_AUTO_RETURN_SUM_MAX; + } + return returnValue; +} + +/* +* ȡָ±۷Id +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ۷±ID +*/ +UINT16 GetNonReturnId(const UINT16 bufIndex) +{ + UINT16 nonReturnId = CI_ERROR; + + UINT16 curSum = GetNonAutoReturnCurSum(); + + if (bufIndex < curSum) + { + nonReturnId = LocalCiNonReturnIdBuf[bufIndex]; + } + else + { + ; /* 0*/ + } + + return nonReturnId; +} +/* +* ȡԶ۷ťǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Զ۷·ǰ +*/ +UINT16 GetNonAutoReturnCurSum(void) +{ + UINT16 nonReturnCurSum = 0u; + if (gNonReturnCurSum >= (INT16)NON_AUTO_RETURN_SUM_MAX) + { + nonReturnCurSum = NON_AUTO_RETURN_SUM_MAX; + } + else if (gNonReturnCurSum < 0) + { + nonReturnCurSum = 0u; + } + else + { + nonReturnCurSum = (UINT16)gNonReturnCurSum; + } + return nonReturnCurSum; +} + +/* +* ȡָ±ӦԶ۷ťID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetNonAutoBelongCiId(const UINT16 nonReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetNonReturnBufIndex(nonReturnId); /*ȡԶ۷±*/ + + if (bufIndex < NON_AUTO_RETURN_SUM_MAX) + { + returnValue = NonReturnConfigDataStru[bufIndex].BelongCiId; + } + else + { + returnValue = CI_ERROR; + } + return returnValue; +} + +/* +* ȡָ±ӦԶ۷ťID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetNonAutoBelongVirCiId(const UINT16 nonReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetNonReturnBufIndex(nonReturnId); /*ȡԶ۷±*/ + + if (bufIndex < NON_AUTO_RETURN_SUM_MAX) + { + returnValue = NonReturnConfigDataStru[bufIndex].BelongVirCiId; + } + else + { + returnValue = CI_ERROR; + } + return returnValue; +} +/* +* ȡָ±ӦԶ۷ťIDʵΪָʾID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: Զ۷ťID +*/ +UINT16 GetNonRtnRlyId(const UINT16 nonReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 returnValue = CI_ERROR; + + bufIndex = GetNonReturnBufIndex(nonReturnId); /*ȡԶ۷±*/ + + if (bufIndex < NON_AUTO_RETURN_SUM_MAX) + { + returnValue = NonReturnConfigDataStru[bufIndex].NonAutoRtnRlyId; + } + return returnValue; +} + +/* +* ȡָIDԶ۷ťָʾƼ̵ID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: Զ۷ťָʾƼ̵ID +*/ +UINT16 GetNonRtnLghtRlyId(const UINT16 nonReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 returnValue = CI_ERROR; + + bufIndex = GetNonReturnBufIndex(nonReturnId); /*ȡԶ۷±*/ + + if (bufIndex < NON_AUTO_RETURN_SUM_MAX) + { + returnValue = NonReturnConfigDataStru[bufIndex].NonAutoRtnLghtRlyId; + } + return returnValue; +} + +/* +* ۷ +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 NonReturnConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 autoReturnConfigDataSum = 0u; /*۷·豸*/ + UINT8 returnValue = CI_ERROR; + UINT8 localCiId = 0u; + localCiId = GetSystemParaLocalCiId(); + + /*۷·Id*/ + autoReturnConfigDataSum = GetNonAutoReturnCurSum(); + if (autoReturnConfigDataSum >= NON_AUTO_RETURN_SUM_MAX) + {/**/ + + returnValue = CI_ERROR; + } + else + { + returnValue = CI_SUCCESS; + for (ii = 0u; ii < NON_AUTO_RETURN_SUM_MAX; ii++) + { + if (jj == autoReturnConfigDataSum) + {/*Ч*/ + + break; + } + + if (NonReturnConfigDataStru[ii].BelongCiId == localCiId) + {/*òΪЧ*/ + + LocalCiNonReturnIdBuf[jj] = NonReturnConfigDataStru[ii].NonAutoReturnId; + jj++; + } + } + } + return returnValue; +} + +/* +* ȡָID۷ָʾID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ۷ָʾID +* by cgh 20241031 +*/ +UINT16 GetNonRtnRelLightId(const UINT16 nonReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 returnValue = CI_ERROR; + + bufIndex = GetNonReturnBufIndex(nonReturnId); /*ȡԶ۷±*/ + + if (bufIndex < NON_AUTO_RETURN_SUM_MAX) + { + returnValue = NonReturnConfigDataStru[bufIndex].NonAutoReturnRelLightId; + } + else + { + ; + } + return returnValue; +} + +/* +* ȡָID۷ťID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ۷ťID +* by cgh 20241031 +*/ +UINT16 GetNonRtnRelButtonId(const UINT16 nonReturnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 returnValue = CI_ERROR; + + bufIndex = GetNonReturnBufIndex(nonReturnId); /*ȡԶ۷±*/ + + if (bufIndex < NON_AUTO_RETURN_SUM_MAX) + { + returnValue = NonReturnConfigDataStru[bufIndex].NonAutoReturnRelButtonId; + } + else + { + ; + } + return returnValue; +} + + + diff --git a/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnConfigDataManage.h b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnConfigDataManage.h new file mode 100644 index 0000000..9fc3cff --- /dev/null +++ b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnConfigDataManage.h @@ -0,0 +1,135 @@ +/******************************************************** +* +* NonAutoReturnConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* Զ۷ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _NON_AUTORETURN_CONFIG_DATA_MANAGE_H_ +#define _NON_AUTORETURN_CONFIG_DATA_MANAGE_H_ + + +#include "NonAutoReturnDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../Route/RouteDefine.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + + +/*ԶԶ۷ݽṹ*/ +typedef struct S_NonAutoReturnConfigDataStruct +{ + UINT16 NonAutoReturnId; /*Զ۷ťID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 BelongVirCiId; /*ID*/ + UINT16 NonAutoRtnRlyId; /*Զ谴ť̵ID (ֶ)*/ + UINT16 NonAutoRtnLghtRlyId; /*Զ谴ťָʾƼ̵ID (ֶ)*/ + UINT16 NonAutoReturnRelLightId; /*۷ID*/ + UINT16 NonAutoReturnRelButtonId; /*۷ťID*/ +} NonAutoReturnConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern NonAutoReturnConfigDataStruct NonReturnConfigDataStru[NON_AUTO_RETURN_SUM_MAX]; /*Զ۷ýṹ*/ +extern UINT16 LocalCiNonReturnIdBuf[NON_AUTO_RETURN_SUM_MAX]; /*屾Զ۷ťӳ*/ +extern INT16 gNonReturnCurSum; /*Զ۷ǰ*/ + +/* +* ȡָID۷± +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ۷±ID +*/ +UINT16 GetNonReturnBufIndex(const UINT16 nonReturnId); + +/* +* ȡָ±۷Id +* ˵ const UINT16 floodGateId, ID +* ֵ 0u: ȡʧ +* >0u: ۷±ID +*/ +UINT16 GetNonReturnId(const UINT16 bufIndex); +/* +* ȡԶ۷ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Զ۷·ǰ +*/ +UINT16 GetNonAutoReturnCurSum(void); + +/* +* ȡָ±ӦԶ۷ťID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetNonAutoBelongCiId(const UINT16 nonReturnId); + +/* +* ȡָ±ӦԶ۷ťID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetNonAutoBelongVirCiId(const UINT16 nonReturnId); + +/* +* ȡָ±ӦԶ۷ťIDʵΪָʾID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: Զ۷ťID +*/ +UINT16 GetNonRtnRlyId(const UINT16 nonReturnId); + +/* +* ȡָIDԶ۷ťָʾƼ̵ID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: Զ۷ťָʾƼ̵ID +*/ +UINT16 GetNonRtnLghtRlyId(const UINT16 nonReturnId); + +/* +* ۷ +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 NonReturnConfigDataManage(void); + +/* +* ȡָID۷ָʾID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ۷ָʾID +* by cgh 20241031 +*/ +UINT16 GetNonRtnRelLightId(const UINT16 nonReturnId); + +/* +* ȡָID۷ťID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: ۷ťID +* by cgh 20241031 +*/ +UINT16 GetNonRtnRelButtonId(const UINT16 nonReturnId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDataManage.c b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDataManage.c new file mode 100644 index 0000000..960b224 --- /dev/null +++ b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDataManage.c @@ -0,0 +1,363 @@ +/******************************************************** +* +* NonAutoReturnConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ۷ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "NonAutoReturnConfigDataManage.h" +#include "NonAutoReturnDataManage.h" +#include "DeviceDataManage.h" + + + +NonAutoReturnDataStruct NonReturnDataStru[NON_AUTO_RETURN_SUM_MAX]; /*Զ۷̬ṹ*/ + +/* +* ȡ۷ݽṹָ +* ˵ +* ֵ + NonAutoReturnDataStruct * +*/ +NonAutoReturnDataStruct* GetNonReturnData(void) +{ + return NonReturnDataStru; +} + +/* +* ȡָIDԶ۷ťгID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: Զ۷ťָʾƼ̵ID +*/ +UINT16 GetNonRtnCmdSetTrainId(const UINT16 nonReturnId) +{ + UINT16 trainId = CI_ERROR; + UINT16 bufIndex = 0U; + bufIndex = GetNonReturnBufIndex(nonReturnId); + if (bufIndex < NON_AUTO_RETURN_SUM_MAX) + { + trainId = NonReturnDataStru[bufIndex].cmdSetTrainId; + } + else + { + ; /* 0*/ + } + + return trainId; +} + +/* +* ָIDԶ۷ťгID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ +* +*/ +void SetNonRtnCmdSetTrainId(const UINT16 nonReturnId,const UINT16 trainId) +{ + UINT16 bufIndex = 0U; + bufIndex = GetNonReturnBufIndex(nonReturnId); + if (bufIndex < NON_AUTO_RETURN_SUM_MAX) + { + + NonReturnDataStru[bufIndex].cmdSetTrainId = trainId; + } + else + { + ; /*DO NOTHING*/ + } +} + +/* +* ȡ۷Ƶ״̬ +* ˵ UINT16 devId ۷豸ID +* ֵ ۷״̬ +* 0x55 ״̬Ч +* 0xAA ״̬Ч +* by cgh 20240904 +*/ +UINT8 GetAutoRtnIndictFlashState(UINT16 devId) +{ + UINT16 wBufIndex = 0U; + UINT8 retValue = VOBCTOCIAUTORTN_INDICT_MASK_INVALID; + + wBufIndex = GetNonReturnBufIndex(devId); + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + retValue = NonReturnDataStru[wBufIndex].VobcToCIAutoRtnIndicFlashState; + } + else + { + ; + } + + return retValue; +} + +/* +* ȡ۷Ƶȵ״̬ +* ˵ UINT16 devId ۷豸ID +* ֵ ۷ȵ״̬ +* 0x55 ȵ״̬Ч +* 0xAA ȵ״̬Ч +* by cgh 20240904 +*/ +UINT8 GetAutoRtnIndictSteadyState(UINT16 devId) +{ + UINT16 wBufIndex = 0U; + UINT8 retValue = VOBCTOCIAUTORTN_INDICT_MASK_INVALID; + + wBufIndex = GetNonReturnBufIndex(devId); + + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + retValue = NonReturnDataStru[wBufIndex].VobcToCIAutoRtnIndicSteadyState; + } + else + { + ; + } + + return retValue; +} + +/* +* ۷Ƶ״̬ +* ˵ UINT16 devId ۷豸ID +* UINT8 state۷״̬ +* VOBCTOCIAUTORTN_INDICT_MASK_VALID 0x55 Ч״̬ +* VOBCTOCIAUTORTN_INDICT_MASK_INVALID 0xAA Ч״̬ +* ֵ void +* by cgh 20240904 +*/ +void SetAutoRtnIndictFlashState(UINT16 devId, UINT8 state) +{ + UINT16 wBufIndex = 0U; + wBufIndex = GetNonReturnBufIndex(devId); + + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + if ((VOBCTOCIAUTORTN_INDICT_MASK_VALID == state) || (VOBCTOCIAUTORTN_INDICT_MASK_INVALID == state)) + { + NonReturnDataStru[wBufIndex].VobcToCIAutoRtnIndicFlashState = state; + } + else + { + ; + } + } + else + { + ; /*DO NOTHING*/ + } +} + +/* +* ۷Ƶȵ״̬ +* ˵ UINT16 devId ۷豸ID +* UINT8 state ۷ȵ״̬ +* VOBCTOCIAUTORTN_INDICT_MASK_VALID 0x55 Ч״̬ +* VOBCTOCIAUTORTN_INDICT_MASK_INVALID 0xAA Ч״̬ +* ֵ void +* by cgh 20240904 +*/ +void SetAutoRtnIndictSteadyState(UINT16 devId, UINT8 state) +{ + UINT16 wBufIndex = 0U; + wBufIndex = GetNonReturnBufIndex(devId); + + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + if ((VOBCTOCIAUTORTN_INDICT_MASK_VALID == state) || (VOBCTOCIAUTORTN_INDICT_MASK_INVALID == state)) + { + NonReturnDataStru[wBufIndex].VobcToCIAutoRtnIndicSteadyState = state; + } + else + { + ; + } + } + else + { + ; /*DO NOTHING*/ + } +} + +/* +* ȡ۷ť̵ +* ˵ UINT16 devId ۷豸ID +* ֵ ۷ť̵ID +* by cgh 20240904 +*/ +UINT16 GetNonRtnAdhesionRealyId(UINT16 devId) +{ + UINT16 wBufIndex = 0U; + UINT16 retValue = 0U; + + wBufIndex = GetNonReturnBufIndex(devId); + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + retValue = NonReturnDataStru[wBufIndex].RtnRelayAdhesionState.AdhesionRealyId; + } + else + { + ; + } + + return retValue; +} + +/* +* ȡ۷ť̵ճ״̬ +* ˵ UINT16 devId ۷豸ID +* ֵ 0: ȡʧ +* >0:۷ť̵ճ״̬ +* by cgh 20240904 +*/ +UINT8 GetNonRtnAdhesionState(UINT16 devId) +{ + UINT16 wBufIndex = 0U; + UINT8 retValue = 0U; + + wBufIndex = GetNonReturnBufIndex(devId); + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + retValue = NonReturnDataStru[wBufIndex].RtnRelayAdhesionState.AdhesionState; + } + else + { + ; + } + + return retValue; +} + +/* +* ۷ť̵ճ״̬ +* ˵ UINT16 devId ۷豸ID +* UINT8 state ۷ť̵ճ״̬ +* ֵ void +* by cgh 20240904 +*/ +void SetNonRtnAdhesionState(UINT16 devId, UINT8 state) +{ + UINT16 wBufIndex = 0U; + wBufIndex = GetNonReturnBufIndex(devId); + + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + if ((RTN_RELAY_ADHESION_NO == state) || (RTN_RELAY_ADHESION_YES == state)) + { + NonReturnDataStru[wBufIndex].RtnRelayAdhesionState.AdhesionState = state; + } + else + { + ; /**/ + } + } + else + { + ; /*DO NOTHING*/ + } +} + +/* +* ȡ۷ť̵̵ +* ˵ UINT16 devId ۷豸ID +* ֵ ۷ť̵̵ +* by cgh 20240904 +*/ +UINT32 GetNonRtnRelayUpCycNum(UINT16 devId) +{ + UINT16 wBufIndex = 0U; + UINT32 retValue = 0U; + + wBufIndex = GetNonReturnBufIndex(devId); + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + retValue = NonReturnDataStru[wBufIndex].RtnRelayAdhesionState.RelayUpCycNum; + } + else + { + ; + } + + return retValue; +} + +/* +* ۷ť̵̵ +* ˵ UINT16 devId ۷豸ID +* UINT32 state ۷ť̵̵ +* ֵ void +* by cgh 20240904 +*/ +void SetNonRtnRelayUpCycNum(UINT16 devId, UINT32 state) +{ + UINT16 wBufIndex = 0U; + wBufIndex = GetNonReturnBufIndex(devId); + + if (NON_AUTO_RETURN_SUM_MAX > wBufIndex) + { + NonReturnDataStru[wBufIndex].RtnRelayAdhesionState.RelayUpCycNum = state; + } + else + { + ; /*DO NOTHING*/ + } +} + +/* +* ۷ťǷճ +* ˵ UINT8 devId ӵͼ۷ťID +* ֵ RTN_RELAY_ADHESION_NO +* RTN_RELAY_ADHESION_YES +* by cgh 20241031 +*/ +UINT8 CheckNonReturnExistAdhesion(UINT8 devId) +{ + UINT8 chRetVal = RTN_RELAY_ADHESION_NO; + UINT16 NonAutoReturnCurSum = 0U;/*۷ťǰ*/ + UINT16 ii = 0U; + UINT16 wNonAutoRtnId = 0U;/*۷ID*/ + UINT16 wCurNonAutoRtnButonId = 0U;/*۷ťID*/ + UINT8 chNonRtnAdhesionState = 0U;/*۷ճ״̬*/ + + if ((0U < devId) && (NON_AUTO_RETURN_SUM_MAX > devId)) + { + NonAutoReturnCurSum = GetNonAutoReturnCurSum(); + for (ii = 0U; ii < NonAutoReturnCurSum; ii++) + { + wNonAutoRtnId = GetNonReturnId(ii); + wCurNonAutoRtnButonId = GetNonRtnRelButtonId(wNonAutoRtnId); + if (devId == wCurNonAutoRtnButonId) + { + chNonRtnAdhesionState = GetNonRtnAdhesionState(wNonAutoRtnId); + if (RTN_RELAY_ADHESION_YES == chNonRtnAdhesionState) + { + chRetVal = RTN_RELAY_ADHESION_YES; + /*ҵһ۷ճ˳ѭ*/ + break; + } + else + { + ; + } + } + else + { + ; /**/ + } + } + } + else + { + /*μʧܣʧ*/ + } + + return chRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDataManage.h b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDataManage.h new file mode 100644 index 0000000..1b73ce9 --- /dev/null +++ b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDataManage.h @@ -0,0 +1,169 @@ +/******************************************************** +* +* NonAutoReturnConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* Զ۷ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _NON_AUTORETURN_DATA_MANAGE_H_ +#define _NON_AUTORETURN_DATA_MANAGE_H_ + + +#include "NonAutoReturnDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*۷̵ճ״̬ṹ*/ +typedef struct S_RtnRelayAdhesionStruct +{ + UINT16 AdhesionRealyId; /*ճ̵ID*/ + UINT8 AdhesionState; /*̵ճ״̬*/ + UINT32 RelayUpCycNum; /*̵*/ +} RtnRelayAdhesionStruct; + +/*ԶԶ۷ݽṹ*/ +typedef struct S_NonAutoReturnDataStruct +{ + UINT16 cmdSetTrainId; /*гID (ֶ̬)*/ + UINT8 IndicatorDevID; /*ָʾ豸ID*/ + UINT8 VobcToCIAutoRtnIndicFlashState; /*ظ۷ָʾ״̬*/ + UINT8 VobcToCIAutoRtnIndicSteadyState; /*ظ۷ָʾȵ״̬*/ + RtnRelayAdhesionStruct RtnRelayAdhesionState; /*۷̵ճ״̬*/ +} NonAutoReturnDataStruct; + +extern NonAutoReturnDataStruct NonReturnDataStru[NON_AUTO_RETURN_SUM_MAX]; /*Զ۷̬ṹ*/ + +/* +* ȡָIDԶ۷ťгID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ 0: ȡʧ +* >0: Զ۷ťָʾƼ̵ID +*/ +UINT16 GetNonRtnCmdSetTrainId(const UINT16 nonReturnId); + +/* +* ȡ۷ݽṹָ +* ˵ +* ֵ +NonAutoReturnDataStruct * +*/ +NonAutoReturnDataStruct* GetNonReturnData(void); + +/* +* ָIDԶ۷ťгID +* ˵ const UINT16 autoReturnId, Զ۷ID +* ֵ +* +*/ +void SetNonRtnCmdSetTrainId(const UINT16 nonReturnId, const UINT16 trainId); + +/* +* ȡ۷Ƶ״̬ +* ˵ UINT16 devId ۷豸ID +* ֵ ۷״̬ +* 0x55 ״̬Ч +* 0xAA ״̬Ч +* by cgh 20240904 +*/ +UINT8 GetAutoRtnIndictFlashState(UINT16 devId); + +/* +* ȡ۷Ƶȵ״̬ +* ˵ UINT16 devId ۷豸ID +* ֵ ۷ȵ״̬ +* 0x55 ȵ״̬Ч +* 0xAA ȵ״̬Ч +* by cgh 20240904 +*/ +UINT8 GetAutoRtnIndictSteadyState(UINT16 devId); + +/* +* ۷Ƶ״̬ +* ˵ UINT16 devId ۷豸ID +* UINT8 state۷״̬ +* VOBCTOCIAUTORTN_INDICT_MASK_VALID 0x55 Ч״̬ +* VOBCTOCIAUTORTN_INDICT_MASK_INVALID 0xAA Ч״̬ +* ֵ void +* by cgh 20240904 +*/ +void SetAutoRtnIndictFlashState(UINT16 devId, UINT8 state); + +/* +* ۷Ƶȵ״̬ +* ˵ UINT16 devId ۷豸ID +* UINT8 state ۷ȵ״̬ +* VOBCTOCIAUTORTN_INDICT_MASK_VALID 0x55 Ч״̬ +* VOBCTOCIAUTORTN_INDICT_MASK_INVALID 0xAA Ч״̬ +* ֵ void +* by cgh 20240904 +*/ +void SetAutoRtnIndictSteadyState(UINT16 devId, UINT8 state); + +/* +* ȡ۷ť̵ +* ˵ UINT16 devId ۷豸ID +* ֵ ۷ť̵ID +* by cgh 20240904 +*/ +UINT16 GetNonRtnAdhesionRealyId(UINT16 devId); + +/* +* ȡ۷ť̵ճ״̬ +* ˵ UINT16 devId ۷豸ID +* ֵ 0: ȡʧ +* >0:۷ť̵ճ״̬ +* by cgh 20240904 +*/ +UINT8 GetNonRtnAdhesionState(UINT16 devId); + +/* +* ۷ť̵ճ״̬ +* ˵ UINT16 devId ۷豸ID +* UINT8 state ۷ť̵ճ״̬ +* ֵ void +* by cgh 20240904 +*/ +void SetNonRtnAdhesionState(UINT16 devId, UINT8 state); + +/* +* ȡ۷ť̵̵ +* ˵ UINT16 devId ۷豸ID +* ֵ ۷ť̵̵ +* by cgh 20240904 +*/ +UINT32 GetNonRtnRelayUpCycNum(UINT16 devId); + +/* +* ۷ť̵̵ +* ˵ UINT16 devId ۷豸ID +* UINT32 state ۷ť̵̵ +* ֵ void +* by cgh 20240904 +*/ +void SetNonRtnRelayUpCycNum(UINT16 devId, UINT32 state); + +/* +* ۷ťǷճ +* ˵ UINT8 devId ӵͼ۷ťID +* ֵ RTN_RELAY_ADHESION_NO +* RTN_RELAY_ADHESION_YES +* by cgh 20241031 +*/ +UINT8 CheckNonReturnExistAdhesion(UINT8 devId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDefine.h b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDefine.h new file mode 100644 index 0000000..2ee1147 --- /dev/null +++ b/TSCP/src/APP/ciapp/NonAutoReturn/NonAutoReturnDefine.h @@ -0,0 +1,24 @@ +/******************************************************** +* +* NonAutoReturnDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* ۷ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _NON_AUTORETURN_CONFIG_H_ +#define _NON_AUTORETURN_CONFIG_H_ + +/*۷ֵ*/ +#define NON_AUTO_RETURN_SUM_MAX ((UINT8)100) /*Զ۷ֵ*/ + + +#define RTN_RELAY_ADHESION_YES 0xaaU /*۷̵ճ*/ +#define RTN_RELAY_ADHESION_NO 0x55U /*۷̵ճ*/ + +#endif diff --git a/TSCP/src/APP/ciapp/NonRoute/NonRouteConfigDataManage.c b/TSCP/src/APP/ciapp/NonRoute/NonRouteConfigDataManage.c new file mode 100644 index 0000000..bfa3736 --- /dev/null +++ b/TSCP/src/APP/ciapp/NonRoute/NonRouteConfigDataManage.c @@ -0,0 +1,546 @@ +/******************************************************** +* +* NonRouteConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-17 +* ߣ +* ǽ·ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "NonRouteConfigDataManage.h" +#include "../System/CiSystemDefine.h" +#include "../Signal/SignalConfigDataManage.h" + +NonRouteConfigDataStruct NonRouteConfigDataStruArr[NONROUTE_ID_NUM_MAX]; /*ǽ·ݽṹ*/ + +UINT16 NonRouteCurSum = 0u; /*ǽ·ǰ*/ + + +/* +* ȡǽ· +* ˵ void +* ֵ ǽ· +*/ +UINT16 GetNonRouteCurSum(void) +{ + UINT16 retVal = 0u; + if (NonRouteCurSum >= NONROUTE_ID_NUM_MAX) + { + retVal = 0u; + } + else + { + retVal = NonRouteCurSum; + } + return retVal; +} +/* +* ȡǽ· +* ˵ void +* ֵ ǽ· +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataPtr(void) +{ + return NonRouteConfigDataStruArr; +} + +/* +* ݷǽ·idȡǽ·ṹָ +* ˵ ǽ·id +* ֵ ǽ·ṹָ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataPtrById(UINT8 nonRouteId) +{ + NonRouteConfigDataStruct* pNonRoutePtr = NULL; + + UINT8 i = 0u; + for (i=0u;i< NONROUTE_ID_NUM_MAX;i++) + { + pNonRoutePtr = NonRouteConfigDataStruArr + i; + if (pNonRoutePtr!=NULL) + { + if (pNonRoutePtr->NonRouteId == nonRouteId) + { + break; + } + } + } + return pNonRoutePtr; +} + +/* +* ȡǽ·źŻĿ +* ˵ ǽ·id +* ֵ ǽ·źĿ +*/ +UINT8 GetNonRouteSignalSumById(UINT8 nonRouteId) +{ + UINT8 sigNum = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + sigNum = pNonRouteConfig->SignalSum; + } + return sigNum; +} + + +/* +* ȡǽ·źŻ +* ˵ ǽ·id +* ֵ ǽ·źŻ +*/ +UINT16* GetNonRouteSignalIdBufById(UINT8 nonRouteId) +{ + UINT16 *pSigArr = NULL; + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + pSigArr = pNonRouteConfig->SignalIdBuf; + } + return pSigArr; +} + + +/* +* ȡǽ·Ŀ +* ˵ ǽ·id +* ֵ ǽ·Ŀ +*/ +UINT8 GetNonRoutePhySectionSumById(UINT8 nonRouteId) +{ + UINT8 secNum = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + secNum = pNonRouteConfig->PhySectionSum; + } + return secNum; +} + + +/* +* ȡǽ· +* ˵ ǽ·id +* ֵ ǽ· +*/ +NonRoutePhySectionStruct* GetNonRoutePhySecStruBufById(UINT8 nonRouteId) +{ + NonRoutePhySectionStruct* phyArr = NULL; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + phyArr = pNonRouteConfig->NonRoutePhySecStru; + } + + return phyArr; +} + + +/* +* ȡǽ·Ŀ +* ˵ ǽ·id +* ֵ ǽ·Ŀ +*/ +UINT8 GetNonRouteSwitchSumById(UINT8 nonRouteId) +{ + UINT8 swNum = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (NULL != pNonRouteConfig) + { + swNum = pNonRouteConfig->SwitchSum; + } + else + { + ; /*0*/ + } + + return swNum; +} + +/* +* ȡǽ·Ŀ +* ˵ ǽ·id +* ֵ ǽ·Ŀ +*/ +UINT8 GetNonRouteRelatedProtSwitSum(UINT8 nonRouteId) +{ + UINT8 swNum = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + swNum = pNonRouteConfig->ProtectSwitchSum; + } + + return swNum; +} + + +/* +* ȡǽ·ṹ +* ˵ ǽ·id +* ֵ ǽ·ṹ +*/ +NonRouteSwitchStruct* GetNonRouteSwitchStructBufById(UINT8 nonRouteId) +{ + NonRouteSwitchStruct* swArr = NULL; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + swArr = pNonRouteConfig->NonRouteSwitStru; + } + + return swArr; +} + +/* +* ȡǽ·ṹ +* ˵ ǽ·id +* ֵ ǽ·ṹ +*/ +NonRouteProtectSwitchStruct* GetNonRouteRelatedProtSwitStru(UINT8 nonRouteId) +{ + NonRouteProtectSwitchStruct* swArr = NULL; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + swArr = pNonRouteConfig->NonRouteProtectSwitchStru; + } + return swArr; +} + + +/* +* ȡǽ·жźĿ +* ˵ ǽ·id +* ֵ ǽ·жźĿ +*/ +UINT8 GetNonRouteEnemySignalSumById(UINT8 nonRouteId) +{ + UINT8 enemySigNum = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + enemySigNum = pNonRouteConfig->EnemySignalSum; + } + + return enemySigNum; +} + + +/* +* ȡǽ·жźŽṹ +* ˵ ǽ·id +* ֵ ǽ·жźŽṹ +*/ +NonRouteEnemySignalStruct* GetNonRouteEnemySigStruBufById(UINT8 nonRouteId) +{ + NonRouteEnemySignalStruct* pEnemySig = NULL; + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + pEnemySig = pNonRouteConfig->EnemySignalStru; + } + + return pEnemySig; +} + +/* +* ȡǽ·Ŀ +* ˵ ǽ·id +* ֵ ǽ·Ŀ +*/ +UINT8 GetNonRouteIntrudePhySecSumById(UINT8 nonRouteId) +{ + UINT8 intruPhyNum = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + intruPhyNum = pNonRouteConfig->IntruPhySecSum; + } + + return intruPhyNum; +} + +/* +* ȡǽ·νṹ +* ˵ ǽ·id +* ֵ ǽ·νṹ +*/ +NonRouteIntrudePhySectionStruct* GetNonRouteIntrudePhySecBufById(UINT8 nonRouteId) +{ + NonRouteIntrudePhySectionStruct* pIntruPhyArr = NULL; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + pIntruPhyArr = pNonRouteConfig->IntruPhySecStru; + } + + return pIntruPhyArr; +} + +/* +* ȡǽ·Գ̵ID +* ˵ ǽ·id +* ֵ Գ̵ID +*/ +UINT16 GetNonRouteAppTryRelayIdById(UINT8 nonRouteId) +{ + UINT16 applyTryTrainId = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + applyTryTrainId = pNonRouteConfig->ApplyTryTrainRelayId; + } + + return applyTryTrainId; +} + + +/* +* ȡǽ·ͬԳ̵ID +* ˵ ǽ·id +* ֵ ͬԳ̵ID +*/ +UINT16 GetNonRouteAgreeTryRelayIdById(UINT8 nonRouteId) +{ + UINT16 agreeTryTrainRelayId = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + agreeTryTrainRelayId = pNonRouteConfig->AgreeTryTrainRelayId; + } + + return agreeTryTrainRelayId; +} + + +/* +* ȡԳԳ̵ID +* ˵ ǽ·id +* ֵ Գ̵ID +*/ +UINT16 GetSCXDrvApplyTryRelayIdById(UINT8 nonRouteId) +{ + UINT16 drvApplyTryTrainRelayId = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + drvApplyTryTrainRelayId = pNonRouteConfig->DrvApplyTryTrainRelayId; + } + + return drvApplyTryTrainRelayId; +} + +/* +* ȡԳ߲ɼͬԳ̵ID +* ˵ ǽ·id +* ֵ ɼͬԳ̵ID +*/ +UINT16 GetSCXColAgreeTryRelayIdById(UINT8 nonRouteId) +{ + UINT16 collAgreeTryTrainRelayId = 0u; + + NonRouteConfigDataStruct *pNonRouteConfig = GetNonRouteConfigDataPtrById(nonRouteId); + if (pNonRouteConfig !=NULL) + { + collAgreeTryTrainRelayId = pNonRouteConfig->ColAgreeTryTrainRelayId; + } + + return collAgreeTryTrainRelayId; +} + +/* +* ݵidҶӦķǽ· +* ˵swId-id +* ֵǽ·ṹָ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataBySwitchId(UINT16 swId) +{ + NonRouteConfigDataStruct *pNonRoute = NULL; + + UINT8 i=0; + UINT8 j=0; + UINT8 breakFlag = 0U; + for (;iSwitchSum) && (j < NONROUTE_SWITCH_SUM_MAX);j++) + { + if (pNonRoute->NonRouteSwitStru[j].SwitchId == swId) + { + breakFlag = 1U; + break; + } + } + } + if (1U == breakFlag) + { + break; + } + } + + + return pNonRoute; +} + +/* +* źŻidȡǽ·ṹָ +* ˵ źŻ +* ֵ ǽ·ṹָ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataBySignalId(UINT16 sigId) +{ + NonRouteConfigDataStruct *pNonRoute = NULL; + + UINT8 i=0; + UINT8 j=0; + UINT8 breakflag = 0U; + for (;iSignalSum) && (j < NONROUTE_SIGNAL_SUM_MAX);j++) + { + if (pNonRoute->SignalIdBuf[j] == sigId) + { + breakflag = 1U; + break; + } + } + } + if (1U == breakflag) + { + break; + } + } + + + return pNonRoute; +} + +/* +* idҶӦķǽ· +* ˵phyId-id +* ֵǽ·ṹָ룺ҳɹ +* NULLʧ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataByPhySecId(UINT16 phyId) +{ + NonRouteConfigDataStruct* pNonRoute = NULL; + NonRouteConfigDataStruct* retNonRoute = NULL; + UINT16 i = 0; + UINT16 j = 0; + UINT8 breakFlag = 0U; + /*зǽ·*/ + for (i = 0; i < NONROUTE_ID_NUM_MAX; i++) + { + pNonRoute = NonRouteConfigDataStruArr + i; + if (pNonRoute != NULL) + { + /*Ӧ*/ + for (j = 0; (j < pNonRoute->PhySectionSum) && (j < NONROUTE_PHYSEC_SUM_MAX); j++) + { + if (pNonRoute->NonRoutePhySecStru[j].PhySectionId == phyId) + { + breakFlag = 1U; + break; + } + else + { + /**/ + } + } + } + if (1U == breakFlag) + { + /*ҳɹ*/ + retNonRoute = pNonRoute; + break; + } + else + { + /**/ + } + } + + return retNonRoute; +} + +/* +* ȡǽ· +* ˵ ǽ·id +* ֵ +*/ +UINT8 GetnonRouteIdbelongVirCIid(UINT8 nonRouteId) +{ + UINT8 i= 0u; + UINT8 signalSum = 0u; + UINT16 signalId = 0u; + UINT8 reVal = 0u; + for(i=0u;i < NONROUTE_ID_NUM_MAX;i++) + { + if(nonRouteId == NonRouteConfigDataStruArr[i].NonRouteId) + { + signalSum = NonRouteConfigDataStruArr[i].SignalSum; + if(0u < signalSum) + { + signalId = NonRouteConfigDataStruArr[i].SignalIdBuf[0]; + reVal = GetSignalBelongVirCiId(signalId); + } + break; + } + } + + return reVal; +} + + +/* +* ȡǽ·ID +* ˵ ǽ·id +* ֵ ID +*/ +UINT8 GetnonRouteIdbelongCIid(UINT8 nonRouteId) +{ + UINT8 i = 0u; + UINT8 signalSum = 0u; + UINT16 signalId = 0u; + UINT8 reVal = 0u; + for (i = 0u; i < NONROUTE_ID_NUM_MAX; i++) + { + if (nonRouteId == NonRouteConfigDataStruArr[i].NonRouteId) + { + signalSum = NonRouteConfigDataStruArr[i].SignalSum; + if (0u < signalSum) + { + signalId = NonRouteConfigDataStruArr[i].SignalIdBuf[0]; + reVal = GetSignalBelongCiId(signalId); + } + break; + } + } + + return reVal; +} + + + diff --git a/TSCP/src/APP/ciapp/NonRoute/NonRouteConfigDataManage.h b/TSCP/src/APP/ciapp/NonRoute/NonRouteConfigDataManage.h new file mode 100644 index 0000000..5c784a3 --- /dev/null +++ b/TSCP/src/APP/ciapp/NonRoute/NonRouteConfigDataManage.h @@ -0,0 +1,275 @@ +/******************************************************** +* +* NonRouteConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-17 +* ߣ +* ǽ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _NON_ROUTE_CONFIG_DATA_MANAGE_H_ +#define _NON_ROUTE_CONFIG_DATA_MANAGE_H_ + +#include "CommonTypes.h" +#include "NonRouteDefine.h" + + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*·ݽṹ*/ +typedef struct S_NonRoute_PhysicalSection +{ + UINT16 PhySectionId; /*ID (ֶ)*/ + UINT8 CheckState; /* (ֶ)*/ +} NonRoutePhySectionStruct; + +/*ǽ·ṹ*/ +typedef struct S_NonRoute_Switch_Struct +{ + UINT16 SwitchId; /*ID (ֶ)*/ + UINT8 SwitchPos; /*λ (ֶ)*/ +} NonRouteSwitchStruct; + +/*ǽ·ṹ*/ +typedef struct S_NonRoute_Protect_Switch_Struct +{ + UINT16 ProtectSwitchId; /*ID (ֶ)*/ + UINT8 ProtectPosition; /*λ (ֶ)*/ +} NonRouteProtectSwitchStruct; + +/*жźŽṹ*/ +typedef struct S_NonRoute_Enemy_Signal_Struct +{ + UINT16 EnemySigId; /*жźID (ֶ)*/ + UINT8 SwitchSum; /*صĿ (ֶ)*/ + NonRouteSwitchStruct EnemySwitchStru[NONROUTE_CONDITION_SWITCH_SUM_MAX]; /*·ṹ (ֶ)*/ +} NonRouteEnemySignalStruct; + +/*ǽ·νṹ*/ +typedef struct S_NonRoute_Intrude_PhySection +{ + UINT16 SectionId; /*ID (ֶ)*/ + UINT8 SwitchSum; /*Ŀ (ֶ)*/ + NonRouteSwitchStruct ConditionSwitchStru[NONROUTE_CONDITION_SWITCH_SUM_MAX]; /*ṹ(ֶ)*/ +} NonRouteIntrudePhySectionStruct; + +/*ǽ·ݽṹ*/ +typedef struct S_NonRouteConfigDataStruct +{ + UINT8 NonRouteId; + UINT8 SignalSum; /*ǽ·źŻĿ (ֶ)*/ + UINT16 SignalIdBuf[NONROUTE_SIGNAL_SUM_MAX]; /*ǽ·źŻ (ֶ)*/ + UINT8 PhySectionSum; /*ǽ·Ŀ (ֶ)*/ + NonRoutePhySectionStruct NonRoutePhySecStru[NONROUTE_PHYSEC_SUM_MAX]; /*ǽ·νṹ (ֶ)*/ + UINT8 SwitchSum; /*ǽ·Ŀ (ֶ)*/ + NonRouteSwitchStruct NonRouteSwitStru[NONROUTE_SWITCH_SUM_MAX]; /*ǽ·ṹ (ֶ)*/ + UINT8 ProtectSwitchSum; /*ǽ·Ŀ (ֶ)*/ + NonRouteProtectSwitchStruct NonRouteProtectSwitchStru[NONROUTE_PROTECTSWI_SUM_MAX]; /*ǽ·ṹ (ֶ)*/ + UINT8 EnemySignalSum; /*жźĿ (ֶ)*/ + NonRouteEnemySignalStruct EnemySignalStru[NONROUTE_ENEMY_SIGNAL_SUM_MAX]; /*ǽ·жźŽṹ (ֶ)*/ + UINT8 IntruPhySecSum; /*Ŀ (ֶ)*/ + NonRouteIntrudePhySectionStruct IntruPhySecStru[NONROUTE_ENEMY_SIGNAL_SUM_MAX]; /*ǽ·νṹ (ֶ)*/ + UINT16 ApplyTryTrainRelayId; /*Գ̵ID (ֶ)*/ + UINT16 AgreeTryTrainRelayId; /*ͬԳ̵ID (ֶ)*/ + UINT16 DrvApplyTryTrainRelayId; /* ԳԳ̵ID */ + UINT16 ColAgreeTryTrainRelayId; /* Գ߲ɼͬԳ̵ID */ +} NonRouteConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern NonRouteConfigDataStruct NonRouteConfigDataStruArr[NONROUTE_ID_NUM_MAX]; /*ǽ·ݽṹ*/ + +extern UINT16 NonRouteCurSum; /*ǽ·ǰ*/ + +/**************************************************Ϊ******************************************************/ +/**************************************************Ϊ******************************************************/ +/**************************************************Ϊ******************************************************/ +/**************************************************Ϊ******************************************************/ +/**************************************************Ϊ******************************************************/ +/**************************************************Ϊ******************************************************/ + + +/* +* ȡǽ· +* ˵ void +* ֵ ǽ· +*/ +UINT16 GetNonRouteCurSum(void); + + +/* +* ȡǽ·Ԫָ +* ˵ void +* ֵ ·ṹָ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataPtr(void); + +/* +* ݷǽ·idȡǽ·ṹָ +* ˵ ǽ·id +* ֵ ǽ·ṹָ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataPtrById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·ӦźŻ +* ˵ ǽ·id +* ֵ źŻ +*/ +UINT8 GetNonRouteSignalSumById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·ӦźŻidָ +* ˵ ǽ·id +* ֵ źŻidָ +*/ +UINT16* GetNonRouteSignalIdBufById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·Ӧ +* ˵ ǽ·id +* ֵ +*/ +UINT8 GetNonRoutePhySectionSumById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·Ӧidָ +* ˵ ǽ·id +* ֵ Ԫָ +*/ +NonRoutePhySectionStruct* GetNonRoutePhySecStruBufById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·Ӧĵ +* ˵ ǽ·id +* ֵ +*/ +UINT8 GetNonRouteSwitchSumById(UINT8 nonRouteId); + +/* +* ȡǽ·Ŀ +* ˵ ǽ·id +* ֵ ǽ·Ŀ +*/ +UINT8 GetNonRouteRelatedProtSwitSum(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·ӦĵṹԪָ +* ˵ ǽ·id +* ֵ ṹԪָ +*/ +NonRouteSwitchStruct* GetNonRouteSwitchStructBufById(UINT8 nonRouteId); + +/* +* ȡǽ·ṹ +* ˵ ǽ·id +* ֵ ǽ·ṹ +*/ +NonRouteProtectSwitchStruct* GetNonRouteRelatedProtSwitStru(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·ӦĵжźŻ +* ˵ ǽ·id +* ֵ жźŻ +*/ +UINT8 GetNonRouteEnemySignalSumById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·ӦĵжźŻṹԪָ +* ˵ void +* ֵ жźŻṹԪָ +*/ +NonRouteEnemySignalStruct* GetNonRouteEnemySigStruBufById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·Ӧ +* ˵ ǽ·id +* ֵ +*/ +UINT8 GetNonRouteIntrudePhySecSumById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·ӦνṹԪָ +* ˵ ǽ·id +* ֵ νṹԪָ +*/ +NonRouteIntrudePhySectionStruct* GetNonRouteIntrudePhySecBufById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·ӦԳ̵id +* ˵ ǽ·id +* ֵ Գ̵id +*/ +UINT16 GetNonRouteAppTryRelayIdById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡǽ·ӦͬԳԳ̵id +* ˵ ǽ·id +* ֵ ͬԳ̵id +*/ +UINT16 GetNonRouteAgreeTryRelayIdById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡԳԳ̵ID +* ˵ ǽ·id +* ֵ ԳԳ̵ID +*/ +UINT16 GetSCXDrvApplyTryRelayIdById(UINT8 nonRouteId); + +/* +* ݷǽ·idȡԳͬԳ̵ID +* ˵ ǽ·id +* ֵ Գ߲ɼͬԳ̵ID +*/ +UINT16 GetSCXColAgreeTryRelayIdById(UINT8 nonRouteId); + +/* +* ݵidȡǽ·ṹָ +* ˵ id +* ֵ ǽ·ṹָ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataBySwitchId(UINT16 swId); + +/* +* źŻidȡǽ·ṹָ +* ˵ źŻ +* ֵ ǽ·ṹָ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataBySignalId(UINT16 sigId); + +/* +* idҶӦķǽ· +* ˵phyId-id +* ֵǽ·ṹָ룺ҳɹ +* NULLʧ +*/ +NonRouteConfigDataStruct* GetNonRouteConfigDataByPhySecId(UINT16 phyId); + +/* +* ȡǽ· +* ˵ ǽ·id +* ֵ +*/ +UINT8 GetnonRouteIdbelongVirCIid(UINT8 nonRouteId); + + +/* +* ȡǽ·ID +* ˵ ǽ·id +* ֵ +*/ +UINT8 GetnonRouteIdbelongCIid(UINT8 nonRouteId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/NonRoute/NonRouteDataManage.c b/TSCP/src/APP/ciapp/NonRoute/NonRouteDataManage.c new file mode 100644 index 0000000..8131b43 --- /dev/null +++ b/TSCP/src/APP/ciapp/NonRoute/NonRouteDataManage.c @@ -0,0 +1,388 @@ +/******************************************************** +* +* NonRouteDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-17 +* ߣ +* ǽ·ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "NonRouteDataManage.h" + + + +NonRouteDataStruct NonRouteDataStruArr[NONROUTE_ID_NUM_MAX];/*ǽ·ݽṹ*/ + +/* +* ȡǽ·Ԫָ +* ˵ void +* ֵ ǽ·Ԫָ +*/ +NonRouteDataStruct* GetNonRouteDataPtr(void) +{ + return NonRouteDataStruArr; +} + +/* +* ȡӦidķǽ·ṹָ +* ˵ void +* ֵ ǽ·ṹָ +*/ +NonRouteDataStruct* GetNonRouteDataById(UINT8 nonRouteId) +{ + NonRouteDataStruct *pRetNonRoute = NULL; + UINT8 i=0; + for (;iNonRouteState; + } + else + { + + } + return nonRouteState; +} + +/* +* ÷ǽ·״̬ +* 1˵const UINT8 nonRouteIdǽ·id +* 2˵ const UINT8 nonRouteState, ǽ·״̬ +* ֵ 1:óɹ +* 0:ʧ +*/ +UINT8 SetNonRouteStateById(const UINT8 nonRouteId,const UINT8 nonRouteStateToSet) +{ + UINT8 reVal = CI_ERROR; + + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + + if( NULL != pNonRoute) + { + reVal = CI_SUCCESS; + if (NONROUTE_STATE_IDLE == nonRouteStateToSet) + { /*ǽ·*/ + pNonRoute->XuanPaiStartCycleNum = 0u; /*ǽ·ѡʼ*/ + pNonRoute->DelayUnlockStartCycleNum = 0u; /*ǽ·ѡʼ*/ + } + else if(NONROUTE_STATE_XUANPAI == nonRouteStateToSet) + { /*ǽ·ѡ*/ + pNonRoute->XuanPaiStartCycleNum = Get2oo2CurCycleNum(); + } + else if(NONROUTE_STATE_LOCK == nonRouteStateToSet) + { /*ǽ·*/ + + } + else if (NONROUTE_STATE_LOCKERR ==nonRouteStateToSet) + { /*ǽ·쳣*/ + pNonRoute->DelayUnlockStartCycleNum = 0u; + } + else if (NONROUTE_STATE_OPEN ==nonRouteStateToSet) + { /*ǽ·*/ + + } + else if(NONROUTE_STATE_DELAY_UNLOCK == nonRouteStateToSet) + { /*ǽ·ʱ*/ + pNonRoute->DelayUnlockStartCycleNum = Get2oo2CurCycleNum(); + } + else if (NONROUTE_STATE_FAULTDELAY_UNLOCK ==nonRouteStateToSet) + { /*ǽ·ʱ*/ + pNonRoute->DelayUnlockStartCycleNum = Get2oo2CurCycleNum(); + } + else + { + reVal = CI_ERROR; + } + pNonRoute->NonRouteState = nonRouteStateToSet; + } + else + { + reVal = CI_ERROR; + } + + return reVal; +} + + +/* +* ȡǽ·ѡſʼʱ +* ˵ void +* ֵ ѡſʼʱ +*/ +UINT32 GetNonRouteXuanPaiStartCycById(UINT8 nonRouteId) +{ + UINT32 dwTime = 0u; + + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + + if(pNonRoute !=NULL) + { + dwTime = pNonRoute->XuanPaiStartCycleNum ; + } + else + { + + } + return dwTime; +} + + + +/* +* ÷ǽ·źſʼ +* ˵ const UINT32 sigOpenStartCycleNum, źſʼ +* ֵ void +*/ +void SetNonRouteSigOpenStartCycById(const UINT8 nonRouteId, const UINT32 sigOpenStartCycleNum) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + if(pNonRoute !=NULL) + { + pNonRoute->SigOpenStartCycleNum = sigOpenStartCycleNum; + } + else + { + + } +} + + +/* +* ȡǽ·ǰʱʱ +* ˵ void +* ֵ ǽ·ǰʱʱ +*/ +UINT32 GetNonRouteDelayUnlockStartCyc(const UINT8 nonRouteId) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + UINT32 unlockCycle = 0u; + if(pNonRoute !=NULL) + { + unlockCycle = pNonRoute->DelayUnlockStartCycleNum; + } + else + { + + } + return unlockCycle; +} + + +/* +* ÷ǽ·ǰʱʱ +* ˵ const UINT16 curDelayTime: ǰʱʱ +* ֵ void +*/ +void SetNonRouteDelayUnlockStartCyc(const UINT8 nonRouteId,const UINT32 delayTimeStartCycleNum) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + + if(pNonRoute !=NULL) + { + pNonRoute->DelayUnlockStartCycleNum = delayTimeStartCycleNum; + } + else + { + + } +} + + +/* +* ȡǽ·ȡ־ +* ˵ void +* ֵ ǽ·ȡ־ +*/ +UINT8 GetNonRouteCancelFlagById(const UINT8 nonRouteId) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + UINT8 flag = 0u; + if(pNonRoute !=NULL) + { + flag = pNonRoute->CancelFlag; + } + else + { + + } + return flag; +} + + +/* +* ÷ǽ·ȡ־ +* ˵ const UINT8 cancelFlag, ȡ־ +* ֵ 0: ȡʧ +* 1: ȡɹ +*/ +UINT8 SetNonRouteCancelFlagById(const UINT8 nonRouteId,const UINT8 cancelFlag) +{ + UINT8 reVal = CI_ERROR; + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + + if(pNonRoute !=NULL) + { + if ((NONROUTE_CANCEL_FLAG_NO == cancelFlag) || + (NONROUTE_CANCEL_FLAG_YES == cancelFlag)) + { + pNonRoute->CancelFlag = cancelFlag; + + reVal = CI_SUCCESS; + } + } + else + { + reVal = CI_ERROR; + } + + + + return reVal; +} + +/* +* ȡǽ·ȡ־ +* ˵ void +* ֵ ǽ·ȡ־ +*/ +UINT8 GetNonRouteHaveCancelFlagById(const UINT8 nonRouteId) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + UINT8 retCancelFlag = 0u; + if(pNonRoute !=NULL) + { + retCancelFlag = pNonRoute->HaveCancelFlag; + } + else + { + + } + return retCancelFlag; +} + + +/* +* ÷ǽ·ȡ־ +* ˵ const UINT8 cancelFlag, ȡ־ +* ֵ 0: ȡʧ +* 1: ȡɹ +*/ +UINT8 SetNonRouteHaveCancelFlagById(const UINT8 nonRouteId,const UINT8 haveCancelFlag) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + UINT8 ret = CI_SUCCESS; + if(pNonRoute !=NULL) + { + if ((NONROUTE_CANCEL_FLAG_NO == haveCancelFlag) || + (NONROUTE_CANCEL_FLAG_YES == haveCancelFlag)) + { + pNonRoute->HaveCancelFlag = haveCancelFlag; + + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + else + { + + } + return ret; +} + + +/* +* ȡǽ·Գģʽ +* ˵ void +* ֵ +*/ +UINT8 GetNonRouteRunModeById(const UINT8 nonRouteId) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + UINT8 runMode = 0u; + if(pNonRoute !=NULL) + { + runMode = pNonRoute->RunMode; + } + else + { + + } + return runMode; +} + + +/* +* ÷ǽ·Գģʽ +* ˵ const UINT8 cancelFlag, ȡ־ +* ֵ 0: ȡʧ +* 1: ȡɹ +*/ +UINT8 SetNonRouteRunModeById(const UINT8 nonRouteId,const UINT8 runFlag) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + UINT8 ret = 0u; + if(pNonRoute !=NULL) + { + if ((NONROUTE_RUN_MODE_TRAIN == runFlag) || + (NONROUTE_RUN_MODE_APPLY == runFlag)) + { + pNonRoute->RunMode = runFlag; + + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + else + { + + } + return ret; +} + +/* +* ȡӦidķǽ·źŻʼ +* ˵ nonRouteId - ǽ·id +* ֵ ʼ +*/ +UINT32 GetNonRouteSigOpenStartCycById(const UINT8 nonRouteId) +{ + NonRouteDataStruct *pNonRoute = GetNonRouteDataById(nonRouteId); + UINT32 startCycle = 0u; + if (pNonRoute!=NULL) + { + startCycle = pNonRoute->SigOpenStartCycleNum; + } + return startCycle; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/NonRoute/NonRouteDataManage.h b/TSCP/src/APP/ciapp/NonRoute/NonRouteDataManage.h new file mode 100644 index 0000000..196a5d4 --- /dev/null +++ b/TSCP/src/APP/ciapp/NonRoute/NonRouteDataManage.h @@ -0,0 +1,172 @@ +/******************************************************** +* +* NonRouteDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2011-05-03 +* ߣ +* ǽ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _NONROUTE_DATA_MANAGE_H_ +#define _NONROUTE_DATA_MANAGE_H_ + +#include "CommonTypes.h" +#include "NonRouteDefine.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../System/CiSystemDefine.h" + + + + +#ifdef __cplusplus +extern "C" { +#endif + +/*ǽ·ݽṹ*/ +typedef struct S_NonRouteDataStruct +{ + UINT8 NonRouteId; /*ǽ·Id*/ + UINT8 NonRouteState; /*ǽ·״̬ 0x11:ǽ· 0x22:ǽ·ѡ 0x44:ǽ· (ֶ̬)*/ + UINT8 CancelFlag; /*ȡ־ 0x55:δȡ 0xaa:ȡ*/ + UINT8 HaveCancelFlag; /*ȡ־ 0x55:ûȡ 0xaa:ȡ*/ + UINT32 XuanPaiStartCycleNum; /*ѡʼ (ֶ̬)*/ + UINT32 SigOpenStartCycleNum; /*źſʼ (ֶ̬)*/ + UINT32 DelayUnlockStartCycleNum; /*ǰǽ·ʱ (ֶ̬)*/ + UINT8 RunMode; /*ģʽ־*/ +} NonRouteDataStruct; + +extern NonRouteDataStruct NonRouteDataStruArr[NONROUTE_ID_NUM_MAX];/*ǽ·ݽṹ*/ + /* + * ȡǽ·Ԫָ + * ˵ void + * ֵ ǽ·Ԫָ + */ + NonRouteDataStruct* GetNonRouteDataPtr(void); + + /* + * ȡӦidķǽ·ṹָ + * ˵ void + * ֵ ǽ·ṹָ + */ + NonRouteDataStruct* GetNonRouteDataById(UINT8 nonRouteId); + + /* + * ȡָǽ·IDķǽ·״̬ + * ˵ nonRouteDiaocheID:ǽ·ID + * ֵ NONROUTE_STATE_IDLE : ǽ· + * NONROUTE_STATE_XUANPAI : ǽ·ѡ + * IDNONROUTE_STATE_LOCK : ǽ· + NONROUTE_STATE_DELAY_UNLOCK: ǽ·ʱ + * 0 : Ч + */ + UINT8 GetNonRouteStateById(const UINT8 nonRouteDiaocheID); + + /* + * ÷ǽ·״̬ + * 1˵const UINT8 nonRouteIdǽ·id + * 2˵ const UINT8 nonRouteState, ǽ·״̬ + * ֵ 1:óɹ + * 0:ʧ + */ + UINT8 SetNonRouteStateById(const UINT8 nonRouteId,const UINT8 nonRouteStateToSet); + + + /* + * ȡǽ·ѡſʼʱ + * ˵ void + * ֵ ѡſʼʱ + */ + UINT32 GetNonRouteXuanPaiStartCycById(UINT8 nonRouteId); + + + /* + * ÷ǽ·źſʼ + * ˵ const UINT32 sigOpenStartCycleNum, źſʼ + * ֵ void + */ + void SetNonRouteSigOpenStartCycById(const UINT8 nonRouteId, const UINT32 sigOpenStartCycleNum); + + + /* + * ȡǽ·ǰʱʱ + * ˵ void + * ֵ ǽ·ǰʱʱ + */ + UINT32 GetNonRouteDelayUnlockStartCyc(const UINT8 nonRouteId); + + + /* + * ÷ǽ·ǰʱʱ + * ˵ const UINT16 curDelayTime: ǰʱʱ + * ֵ void + */ + void SetNonRouteDelayUnlockStartCyc(const UINT8 nonRouteId,const UINT32 delayTimeStartCycleNum); + + + /* + * ȡǽ·ȡ־ + * ˵ void + * ֵ ǽ·ȡ־ + */ + UINT8 GetNonRouteCancelFlagById(const UINT8 nonRouteId); + + + /* + * ÷ǽ·ȡ־ + * ˵ const UINT8 cancelFlag, ȡ־ + * ֵ 0: ȡʧ + * 1: ȡɹ + */ + UINT8 SetNonRouteCancelFlagById(const UINT8 nonRouteId,const UINT8 cancelFlag); + + + /* + * ȡǽ·ȡ־ + * ˵ void + * ֵ ǽ·ȡ־ + */ + UINT8 GetNonRouteHaveCancelFlagById(const UINT8 nonRouteId); + + + /* + * ÷ǽ·ȡ־ + * ˵ const UINT8 cancelFlag, ȡ־ + * ֵ 0: ȡʧ + * 1: ȡɹ + */ + UINT8 SetNonRouteHaveCancelFlagById(const UINT8 nonRouteId,const UINT8 haveCancelFlag); + + + /* + * ȡǽ·Գģʽ + * ˵ void + * ֵ + */ + UINT8 GetNonRouteRunModeById(const UINT8 nonRouteId); + + + /* + * ÷ǽ·Գģʽ + * ˵ const UINT8 cancelFlag, ȡ־ + * ֵ 0: ȡʧ + * 1: ȡɹ + */ + UINT8 SetNonRouteRunModeById(const UINT8 nonRouteId,const UINT8 runFlag); + + + /* + * ȡӦidķǽ·źŻʼ + * ˵ nonRouteId - ǽ·id + * ֵ ʼ + */ + UINT32 GetNonRouteSigOpenStartCycById(const UINT8 nonRouteId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/NonRoute/NonRouteDefine.h b/TSCP/src/APP/ciapp/NonRoute/NonRouteDefine.h new file mode 100644 index 0000000..3c8e623 --- /dev/null +++ b/TSCP/src/APP/ciapp/NonRoute/NonRouteDefine.h @@ -0,0 +1,56 @@ +/******************************************************** +* +* NonRouteConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-11-17 +* ߣ +* ǽ·ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _NON_ROUTE_CONFIG_H_ +#define _NON_ROUTE_CONFIG_H_ + + + +/**/ +#define NONROUTE_SIGNAL_SUM_MAX ((UINT8)8) /*ǽ·źŻֵ*/ +#define NONROUTE_PHYSEC_SUM_MAX ((UINT8)16) /*ǽ·ֵ*/ +#define NONROUTE_SWITCH_SUM_MAX ((UINT8)16) /*ǽ·ֵ*/ +#define NONROUTE_PROTECTSWI_SUM_MAX ((UINT8)8) /*ǽ·ֵ*/ +#define NONROUTE_ENEMY_SIGNAL_SUM_MAX ((UINT8)8) /*ǽ·жźŻֵ*/ +#define NONROUTE_CONDITION_SWITCH_SUM_MAX ((UINT8)16) /*ǽ·ֵ*/ + +#define NONROUTE_ID_NUM_MAX ((UINT8)3) /*ǽ·idֵ*/ + + +/*ǽ·״̬*/ +#define NONROUTE_STATE_INVALID ((UINT8)0x0) /*ǽ·״̬Ч*/ +#define NONROUTE_STATE_IDLE ((UINT8)0x01) /*ǽ·*/ +#define NONROUTE_STATE_XUANPAI ((UINT8)0x02) /*ǽ·ѡ*/ +#define NONROUTE_STATE_LOCK ((UINT8)0x04) /*ǽ·*/ +#define NONROUTE_STATE_LOCKERR ((UINT8)0x08) /*ǽ·*/ +#define NONROUTE_STATE_OPEN ((UINT8)0x10) /*ǽ·*/ +#define NONROUTE_STATE_DELAY_UNLOCK ((UINT8)0x20) /*ǽ·ʱ*/ +#define NONROUTE_STATE_FAULTDELAY_UNLOCK ((UINT8)0x30) /*ǽ·ʱ*/ + + + +/*ǽ·μ־*/ +#define NONROUTE_SECTION_OCCUPY_CHECK_NO ((UINT8)0x55) /*ǽ·μδռ*/ +#define NONROUTE_SECTION_OCCUPY_CHECK_YES ((UINT8)0xaa) /*ǽ·μռ*/ + +/*ǽ·ȡ־*/ +#define NONROUTE_CANCEL_FLAG_NO ((UINT8)0x55) /*ǽ·δȡ*/ +#define NONROUTE_CANCEL_FLAG_YES ((UINT8)0xaa) /*ǽ·ȡ*/ + +/*ǽ·Գģʽ*/ +#define NONROUTE_RUN_MODE_TRAIN ((UINT8)0xaa) /*Գģʽ*/ +#define NONROUTE_RUN_MODE_APPLY ((UINT8)0x55) /*źģʽ*/ + + + +#endif diff --git a/TSCP/src/APP/ciapp/Overlap/OverlapConfigDataManage.c b/TSCP/src/APP/ciapp/Overlap/OverlapConfigDataManage.c new file mode 100644 index 0000000..4a5e981 --- /dev/null +++ b/TSCP/src/APP/ciapp/Overlap/OverlapConfigDataManage.c @@ -0,0 +1,875 @@ +/******************************************************** +* +* OverlapConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "OverlapConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" + + + +OverlapConfigDataStruct OverlapConfigDataStru[OVERLAP_SUM_MAX]; /*OVERLAPýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiOverlapIdBuf[OVERLAP_SUM_MAX] = {0u}; /*屾IDӳ*/ +INT16 OverlapCurSum = 0; /*OVERLAPǰ*/ + + +/* +* ȡεǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: εǰ +*/ +UINT16 GetOverlapCurSum(void) +{ + UINT16 reVal = 0u; + if (OverlapCurSum >= (INT16)OVERLAP_SUM_MAX) + { + reVal = OVERLAP_SUM_MAX; + } + else if (OverlapCurSum < 0) + { + reVal = 0u; + } + else + { + reVal = (UINT16)OverlapCurSum; + } + return reVal; +} + +/* +* ȡָ±ӦıID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetOverlapId(const UINT16 bufIndex) +{ + UINT16 reVal = CI_ERROR; + + if (bufIndex < GetOverlapCurSum()) + { + reVal = LocalCiOverlapIdBuf[bufIndex]; + } + return reVal; +} + +/* +* ȡID +* ˵ UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetOverlapBelongCiId(UINT16 overlapId) +{ + UINT8 reVal = CI_ERROR; + + UINT16 bufIndex = GetOverlapConfigBufIndex(overlapId); + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].BelongCiId; + } + return reVal; +} + +/* +* ȡָID +* ˵ const UINT16 overlapId, ID +* ֵ OVERLAP_SUM_MAX: ȡʧ +* overlapId)) + { + reVal = overlapId; + } + else + { + ; + } + + return reVal; +} + + +/* +* ȡָID +* ˵ +* ֵ OverlapConfigDataStruct * +*/ +OverlapConfigDataStruct *GetOverlapConfigData(void) +{ + return OverlapConfigDataStru; +} + +/* +* ȡָIDĿ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetOverlapPhySecSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].PhySecSum; + } + return reVal; +} + + +/* +* ȡָIDID +* ˵ const UINT16 overlapId, ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +UINT16* GetOverlapPhySecIdBuf(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* reVal = NULL; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].PhySecIdBuf; + } + return reVal; +} + + +/* +* ȡָIDĿ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetOverlapSwitchSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].SwitchSum; + } + return reVal; +} + +/* +* ȡָIDιĿ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetOverlapRelatedProtSwitSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].ProtectSwitchSum; + } + return reVal; +} + + +/* +* ȡָIDṹ +* ˵ const UINT16 overlapId, ID +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +OverlapConditionSwitchStruct* GetOverlapCondSwitchStruct(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + OverlapConditionSwitchStruct* reVal = NULL; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].ConditionSwitchStru; + } + return reVal; +} + +/* +* ȡָIDιṹ +* ˵ const UINT16 overlapId, ID +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +OverlapProtectSwitchStruct* GetOverlapRelatedProtSwitStru(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + OverlapProtectSwitchStruct* reVal = NULL; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].ProtectSwitchStru; + } + return reVal; +} + + +/* +* ȡָIDԶźŷĿ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ԶźŷĿ +*/ +UINT8 GetOverlapTriPhySecSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].TriPhySecSum; + } + return reVal; +} + + +/* +* ȡָIDԶźŷ +* ˵ const UINT16 overlapId, ID +* ֵ NULL: ȡʧ +* !NULL: Զźŷָ +*/ +UINT16* GetOverlapTriPhySecIdBuf(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* reVal = NULL; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].TriPhySecIdBuf; + } + return reVal; +} + +/* +* ȡָIDεһID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetOverlapFirstPhySecId(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].PhySecIdBuf[0]; + } + return reVal; +} + +/* +* ı +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 OverlapConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 overlapConfigDataSum = 0u; /*豸*/ + UINT8 reVal = CI_SUCCESS; + + /*汣ID*/ + overlapConfigDataSum = GetOverlapCurSum(); + if (overlapConfigDataSum >= OVERLAP_SUM_MAX) + {/**/ + + reVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < OVERLAP_SUM_MAX; ii++) + { + if (jj == overlapConfigDataSum) + {/*Ч*/ + + break; + } + + if (OverlapConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + + LocalCiOverlapIdBuf[jj] = OverlapConfigDataStru[ii].OverlapId; + jj++; + } + + } + } + return reVal; +} + +/* +* ȡָID۷·Ŀ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ۷·Ŀ +*/ +UINT8 GetOvlpRetRoutAndTrkPhySecSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].RetRoutAndTrkPhySecSum; + } + + return reVal; +} + +/* +* ȡָID۷Ŀ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ۷Ŀ +*/ +UINT8 GetOverlapRetTrkPhySecSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].RetRoutAndTrkPhySecSum; + } + + return reVal; +} + +/* +* ȡָID۷·ID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ۷·ID +*/ +UINT16 GetOverlapReturnRouteId(const UINT16 overlapId, const UINT16 index) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if(index < OverlapConfigDataStru[bufIndex].RetRoutAndTrkPhySecSum) + { + reVal = OverlapConfigDataStru[bufIndex].ReturnRouteIdBuf[index]; + } + + } + + return reVal; +} + +/* +* ȡָID۷ID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ۷ID +*/ +UINT16 GetOverlapRetTrkPhySecId(const UINT16 overlapId, const UINT16 index) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if(index < OverlapConfigDataStru[bufIndex].RetRoutAndTrkPhySecSum) + { + reVal = OverlapConfigDataStru[bufIndex].RetTrkPhySecIdBuf[index]; + } + + } + + return reVal; +} + +/* +: ָιμ +: const UINT16 overlapId ID +: +ֵ: [1, 65535]μ + 0 λȡʧ +*/ +UINT16 GetOverlapInvSecAndConSwiSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + retVal = OverlapConfigDataStru[bufIndex].InvSecAndConSwiSum; + } + + return retVal; +} + + +/* +: ָιμID +: const UINT16 overlapId ID + const UINT16 index μ +: +ֵ: [1, 65535]μID + 0 λȡʧ +*/ +UINT16 GetOverlapInvSecAndConSwiId(const UINT16 overlapId, const UINT16 index) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if(index < OverlapConfigDataStru[bufIndex].InvSecAndConSwiSum) + { + retVal = OverlapConfigDataStru[bufIndex].InvSecAndConSwiIdBuf[index]; + } + } + + return retVal; +} + +/* +: ָι޵жԱ +: const UINT16 overlapId ID +: +ֵ: [1, 65535]޵жԱ + 0 ޵жԱλȡʧ +*/ +UINT16 GetOverlapInvOppOverlapSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + retVal = OverlapConfigDataStru[bufIndex].InvOppOverlapSum; + } + + return retVal; +} + +/* +: ָι޵жԱID +: const UINT16 overlapId ID + const UINT16 index ޵жԱ +: +ֵ: [1, 65535]޵жԱID + 0 ޵жԱλȡʧ +*/ +UINT16 GetOverlapInvOppOverlapId(const UINT16 overlapId, const UINT16 index) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if(index < OverlapConfigDataStru[bufIndex].InvOppOverlapSum) + { + retVal = OverlapConfigDataStru[bufIndex].InvOppOverlapIdBuff[index]; + } + } + + return retVal; +} + +/* +: ָιķ +: const UINT16 overlapId ID +: +ֵ: [1, 65535] + 0 ޷Żȡʧ +*/ +UINT16 GetOverlapFloodGateSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + retVal = OverlapConfigDataStru[bufIndex].FloodGateIdSum; + } + + return retVal; +} + +/* +: ָιķID +: const UINT16 overlapId ID +: +ֵ: idָ +*/ +UINT16* GetOverlapFloodGateBuf(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *pFloodIdBuf = NULL;/*idָ*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + pFloodIdBuf = OverlapConfigDataStru[bufIndex].FloodGateIdBuff; + } + + return pFloodIdBuf; +} + +/* +* +* ˵ overlapSum · +* overlapIdBuff ͸ıID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendOverlapIdDataManage(UINT16 overlapSum,const UINT16 *overlapIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if ((OverlapCurSum + (INT16)overlapSum) >= (INT16)OVERLAP_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = (UINT16)OverlapCurSum; + OverlapCurSum += (INT16)overlapSum; + for(ii = 0u;ii< overlapSum;ii++) + { + LocalCiOverlapIdBuf[index+ii] = overlapIdBuff[ii];/*׷ӵLocalCiOverlapIdBuf*/ + } + } + + return retVal; +} + +/* +* ȡID +* ˵ UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetOverlapBelongVirCiId(UINT16 overlapId) +{ + UINT8 reVal = CI_ERROR; + + UINT16 bufIndex = GetOverlapConfigBufIndex(overlapId); + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].BelongVirCiId; + } + return reVal; +} + + +/* +*: ָΰ߼ +*: const UINT16 overlapId ID +*: +*ֵ: [0, 255]߼ +*/ +UINT8 GetOverlapLogicSectionSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if (OVLP_LOGICSECTION_SUM_MAX > OverlapConfigDataStru[bufIndex].cLogicSectionSum) + { + retVal = OverlapConfigDataStru[bufIndex].cLogicSectionSum; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +: ָΰ߼ID +: const UINT16 overlapId ID +: +ֵ: ߼idָ +*/ +UINT16* GetOverlapLogicSectionBuf(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *pLogicSectionIdBuf = NULL; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (OVERLAP_SUM_MAX > bufIndex) + { + pLogicSectionIdBuf = OverlapConfigDataStru[bufIndex].szLogicSectionIdBuf; + } + else + { + ; + } + + return pLogicSectionIdBuf; +} +/* +: ָĽ·ID +: const UINT16 overlapId ID +: +ֵ: [1, 65535]Ľ·ID +0 ȡʧ +޸ģcgh-ϲCID-2341-8 +*/ +UINT16 GetOverlapRouteIdSum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 retVal = 0; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + retVal = OverlapConfigDataStru[bufIndex].OverlapRouteSum; + } + + return retVal; +} + +/* +: ָĽ·ID +: const UINT16 overlapId ID +: +ֵ: ·idָ +޸ģcgh-ϲCID-2341-8 +*/ +UINT16* GetOverlapRouteIdBuf(const UINT16 overlapId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16* pRouteIdBuf = NULL;/*·idָ*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + pRouteIdBuf = OverlapConfigDataStru[bufIndex].OverlapRouteIdBuf; + } + + return pRouteIdBuf; +} + +/* +*: ָΰԶ˼ +*: const UINT16 overlapId ID +*: +*ֵ: 0 ѯʧ +* >0 ID +*/ +UINT16 GetOverlapFarLogicSecID(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + retVal = OverlapConfigDataStru[bufIndex].AxisSecFarId; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡָIDεһ߼ID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ߼ID +* by cgh 20240923 +*/ +UINT16 GetOverlapFirstLogSecId(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapConfigDataStru[bufIndex].szLogicSectionIdBuf[0]; + } + return reVal; +} + +/* +* жǷڷڱ +* ˵const UINT16 wOverlapId ID +* ֵ0 ڷı +* >0 ID +* Created By LQ 2024.12.03 +*/ +UINT8 CheckOtherCiOlpHaveLocalCiPSw(const UINT16 wOverlapId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + UINT8 cLocalCiId = 0U; /*ID*/ + UINT8 cOverlapBelongCiId = 0U; /*ID*/ + UINT8 cOverlapProSwtNum = 0U; /*ηĿ*/ + OverlapProtectSwitchStruct* pOverlapProSwtData = NULL; /*η*/ + UINT8 ii = 0U; + UINT8 cSwitchBelongCiId = 0U; /*ID*/ + + wBufIndex = GetOverlapConfigBufIndex(wOverlapId); + + if (OVERLAP_SUM_MAX > wBufIndex) + { + cLocalCiId = GetSystemParaLocalCiId(); + cOverlapBelongCiId = GetOverlapBelongCiId(wOverlapId); + if ((0U != cLocalCiId) && (0U != cOverlapBelongCiId) && (cLocalCiId != cOverlapBelongCiId)) + { + /****** ηDZ鱣Ƿڷڱ ******/ + cOverlapProSwtNum = GetOverlapRelatedProtSwitSum(wOverlapId); + pOverlapProSwtData = GetOverlapRelatedProtSwitStru(wOverlapId); + if (NULL != pOverlapProSwtData) + { + for (ii = 0U; ii < cOverlapProSwtNum; ii++) + { + cSwitchBelongCiId = GetSwitchBelongCiId(pOverlapProSwtData[ii].ProtectSwitchId); + if (cLocalCiId == cSwitchBelongCiId) + { + cRetVal = cOverlapBelongCiId; + break; + } + else + { + ; /**/ + } + } + } + else + { + /*ȡʧܣ0*/ + } + } + else + { + /*Σ*/ + } + } + else + { + /*μʧܣ0*/ + } + + return cRetVal; + +} + +/* +* ȡָķλ +* ˵const UINT16 wOverlapId ID +* const UINT16 wProSwitchId ID +* ֵ0 ʧ +* λ +* Created By LQ 2024.12.05 +*/ +UINT8 GetOverlapProSwitchPos(const UINT16 wOverlapId, const UINT16 wProSwitchId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wOverlapIndex = 0U; /*±*/ + UINT16 wSwitchIndex = 0U; /*±*/ + UINT8 ii = 0U; + + wOverlapIndex = GetOverlapConfigBufIndex(wOverlapId); /*ȡ±*/ + wSwitchIndex = GetSwitchConfigBufIndex(wProSwitchId); + + if ((OVERLAP_SUM_MAX > wOverlapIndex) && (SWITCH_SUM_MAX > wSwitchIndex)) + { + for (ii = 0U; ii < OverlapConfigDataStru[wOverlapIndex].ProtectSwitchSum; ii++) + { + if (wProSwitchId == OverlapConfigDataStru[wOverlapIndex].ProtectSwitchStru[ii].ProtectSwitchId) + { + cRetVal = OverlapConfigDataStru[wOverlapIndex].ProtectSwitchStru[ii].ProtectPosition; + break; + } + else + { + /**/ + } + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Overlap/OverlapConfigDataManage.h b/TSCP/src/APP/ciapp/Overlap/OverlapConfigDataManage.h new file mode 100644 index 0000000..ff1eace --- /dev/null +++ b/TSCP/src/APP/ciapp/Overlap/OverlapConfigDataManage.h @@ -0,0 +1,380 @@ +/******************************************************** +* +* OverlapConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _OVERLAP_CONFIG_DATA_MANAGE_H_ +#define _OVERLAP_CONFIG_DATA_MANAGE_H_ + + +#include "OverlapDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ṹ*/ +typedef struct S_Overlap_Condition_Switch +{ + UINT16 SwitchId; /*ID (ֶ)*/ + UINT8 SwitchPosition; /*λ(μλö) (ֶ)*/ +} OverlapConditionSwitchStruct; + +/*ηṹ*/ +typedef struct S_Overlap_Protect_Switch +{ + UINT16 ProtectSwitchId; /*ID (ֶ)*/ + UINT8 ProtectPosition; /*λ(ֶ)*/ +} OverlapProtectSwitchStruct; + + +/*ݽṹ*/ +typedef struct S_OverlapConfigDataStruct +{ + UINT16 OverlapId; /*ID (ֶ)*/ + UINT8 BelongCiId; /*ID (ֶ)*/ + UINT8 BelongVirCiId; /*ID (ֶ)*/ + UINT8 PhySecSum; /*Ŀ (ֶ)*/ + UINT16 PhySecIdBuf[OVERLAP_PHYSEC_SUM_MAX]; /*ID (ֶ)*/ + UINT8 SwitchSum; /*Ŀ (ֶ)*/ + OverlapConditionSwitchStruct ConditionSwitchStru[OVERLAP_CONDISWIT_SUM_MAX]; /*ṹ(ֶ)*/ + UINT8 ProtectSwitchSum; /*Ŀ (ֶ)*/ + OverlapProtectSwitchStruct ProtectSwitchStru[OVERLAP_PROTECTSWI_SUM_MAX]; /*ṹ (ֶ)*/ + UINT8 TriPhySecSum; /*ԶźoverlapĿ (ֶ)*/ + UINT16 TriPhySecIdBuf[OVERLAP_TRIGPHYSEC_SUM_MAX]; /*ԶźoverlapID (ֶ)*/ + UINT8 RetRoutAndTrkPhySecSum; /*ΰ۷·۷*/ + UINT16 ReturnRouteIdBuf[OVLP_RETROUTSEC_N_RETTRKPHYSEC_SUM_MAX]; /*۷·ID*/ + UINT16 RetTrkPhySecIdBuf[OVLP_RETROUTSEC_N_RETTRKPHYSEC_SUM_MAX]; /*۷ID*/ + UINT8 InvSecAndConSwiSum; /*ΰμ*/ + UINT16 InvSecAndConSwiIdBuf[OVLP_INVASECT_N_CONDSWIT_SUM_MAX]; /*μ*/ + UINT16 InvOppOverlapIdBuff[OVLP_INVA_OPP_OVLP_SUM_MAX]; /*޵жԱ*/ + UINT8 InvOppOverlapSum; /*޵жԱ*/ + UINT16 FloodGateIdBuff[OVLP_FLOODGATE_SUM_MAX]; /*(ֶ)*/ + UINT8 FloodGateIdSum; /*(ֶ)*/ + + /* 2022-2-28 */ + UINT8 cLogicSectionSum; /* ΰ߼ */ + UINT16 szLogicSectionIdBuf[OVLP_LOGICSECTION_SUM_MAX]; /* ΰ߼ID,δշ˳ */ + UINT16 OverlapRouteSum; /*ν·*/ + UINT16 OverlapRouteIdBuf[OVERLAP_ROUTE_SUM_MAX]; /*ν·*/ + UINT16 AxisSecFarId; /*Զ˼ID*/ + +} OverlapConfigDataStruct; + +extern OverlapConfigDataStruct OverlapConfigDataStru[OVERLAP_SUM_MAX]; /*OVERLAPýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiOverlapIdBuf[OVERLAP_SUM_MAX]; /*屾IDӳ*/ +extern INT16 OverlapCurSum; /*OVERLAPǰ*/ +/* +* ȡεǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: εǰ +*/ +UINT16 GetOverlapCurSum(void); + +/* +* ȡָ±ӦıID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetOverlapId(const UINT16 bufIndex); + +/* +* ȡID +* ˵ UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetOverlapBelongCiId(UINT16 overlapId); + +/* +* ȡָID +* ˵ +* ֵ OverlapConfigDataStruct * +*/ +OverlapConfigDataStruct *GetOverlapConfigData(void); + +/* +* ȡָID +* ˵ const UINT16 overlapId, ID +* ֵ OVERLAP_SUM_MAX: ȡʧ +* 0: Ŀ +*/ +UINT8 GetOverlapPhySecSum(const UINT16 overlapId); + +/* +* ȡָIDID +* ˵ const UINT16 overlapId, ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +UINT16* GetOverlapPhySecIdBuf(const UINT16 overlapId); + +/* +* ȡָIDĿ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetOverlapSwitchSum(const UINT16 overlapId); + +/* +* ȡָIDιĿ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetOverlapRelatedProtSwitSum(const UINT16 overlapId); + +/* +* ȡָIDṹ +* ˵ const UINT16 overlapId, ID +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +OverlapConditionSwitchStruct* GetOverlapCondSwitchStruct(const UINT16 overlapId); + +/* +* ȡָIDιṹ +* ˵ const UINT16 overlapId, ID +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +OverlapProtectSwitchStruct* GetOverlapRelatedProtSwitStru(const UINT16 overlapId); + +/* +* ȡָIDԶźoverlapĿ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ԶźoverlapĿ +*/ +UINT8 GetOverlapTriPhySecSum(const UINT16 overlapId); + +/* +* ȡָIDԶźoverlap +* ˵ const UINT16 overlapId, ID +* ֵ NULL: ȡʧ +* !NULL: Զźoverlapָ +*/ +UINT16* GetOverlapTriPhySecIdBuf(const UINT16 overlapId); + +/* +* ȡָIDεһID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetOverlapFirstPhySecId(const UINT16 overlapId); + +/* +* ı +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 OverlapConfigDataManage(void); + +/* +* ȡָID۷·Ŀ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ۷·Ŀ +*/ +UINT8 GetOvlpRetRoutAndTrkPhySecSum(const UINT16 overlapId); + +/* +* ȡָID۷Ŀ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ۷Ŀ +*/ +UINT8 GetOverlapRetTrkPhySecSum(const UINT16 overlapId); + +/* +* ȡָID۷·ID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ۷·ID +*/ +UINT16 GetOverlapReturnRouteId(const UINT16 overlapId, const UINT16 index); + +/* +* ȡָID۷ID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ۷ID +*/ +UINT16 GetOverlapRetTrkPhySecId(const UINT16 overlapId, const UINT16 index); + +/* +: ָιμ +: +: +ֵ: [1, 65535]μ + 0 λȡʧ +*/ +UINT16 GetOverlapInvSecAndConSwiSum(const UINT16 overlapId); + +/* +: ָιμID +: +: +ֵ: [1, 65535]μID + 0 λȡʧ +*/ +UINT16 GetOverlapInvSecAndConSwiId(const UINT16 overlapId, const UINT16 index); + + +/* +: ָι޵жԱ +: const UINT16 overlapId ID +: +ֵ: [1, 65535]޵жԱ + 0 ޵жԱλȡʧ +*/ +UINT16 GetOverlapInvOppOverlapSum(const UINT16 overlapId); + +/* +: ָι޵жԱID +: const UINT16 overlapId ID + const UINT16 index ޵жԱ +: +ֵ: [1, 65535]޵жԱID + 0 ޵жԱλȡʧ +*/ +UINT16 GetOverlapInvOppOverlapId(const UINT16 overlapId, const UINT16 index); + +/* +: ָιķ +: const UINT16 overlapId ID +: +ֵ: [1, 65535] + 0 ޷Żȡʧ +*/ +UINT16 GetOverlapFloodGateSum(const UINT16 overlapId); + +/* +: ָιķID +: const UINT16 overlapId ID +: +ֵ: idָ +*/ +UINT16* GetOverlapFloodGateBuf(const UINT16 overlapId); + +/* +* +* ˵ overlapSum · +* overlapIdBuff ͸ıID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendOverlapIdDataManage(UINT16 overlapSum,const UINT16 *overlapIdBuff); + +/* +* ȡID +* ˵ UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetOverlapBelongVirCiId(UINT16 overlapId); + +/* +*: ָΰ߼ +*: const UINT16 overlapId ID +*: +*ֵ: [0, 255]߼ +*/ +UINT8 GetOverlapLogicSectionSum(const UINT16 overlapId); + +/* +: ָΰ߼ID +: const UINT16 overlapId ID +: +ֵ: ߼idָ +*/ +UINT16* GetOverlapLogicSectionBuf(const UINT16 overlapId); +/* +: ָĽ·ID +: const UINT16 overlapId ID +: +ֵ: [1, 65535]Ľ·ID +0 ȡʧ +޸ģcgh-ϲCID-2341-8 +*/ +UINT16 GetOverlapRouteIdSum(const UINT16 overlapId); + +/* +: ָĽ·ID +: const UINT16 overlapId ID +: +ֵ: ·idָ +޸ģcgh-ϲCID-2341-8 +*/ +UINT16* GetOverlapRouteIdBuf(const UINT16 overlapId); + + +/* +*: ָΰԶ˼ +*: const UINT16 overlapId ID +*: +*ֵ: 0 ѯʧ +* >0 ID +*/ +UINT16 GetOverlapFarLogicSecID(const UINT16 overlapId); + +/* +* ȡָIDεһ߼ID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ߼ID +* by cgh 20240923 +*/ +UINT16 GetOverlapFirstLogSecId(const UINT16 overlapId); + +/* +* жǷڷڱ +* ˵const UINT16 wOverlapId ID +* ֵ0 ڷı +* >0 ID +* Created By LQ 2024.12.03 +*/ +UINT8 CheckOtherCiOlpHaveLocalCiPSw(const UINT16 wOverlapId); + +/* +* ȡָķλ +* ˵const UINT16 wOverlapId ID +* const UINT16 wProSwitchId ID +* ֵ0 ʧ +* λ +* Created By LQ 2024.12.05 +*/ +UINT8 GetOverlapProSwitchPos(const UINT16 wOverlapId, const UINT16 wProSwitchId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Overlap/OverlapDataManage.c b/TSCP/src/APP/ciapp/Overlap/OverlapDataManage.c new file mode 100644 index 0000000..f636446 --- /dev/null +++ b/TSCP/src/APP/ciapp/Overlap/OverlapDataManage.c @@ -0,0 +1,978 @@ +/******************************************************** +* +* OverlapDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "OverlapDataManage.h" +#include "../Section/LogicSectionDataManage.h" + + + +OverlapDataStruct OverlapDataStru[OVERLAP_SUM_MAX]; /*OVERLAPݽṹ*/ + + + +/* +* ȡָID +* ˵ +* ֵ + OverlapDataStruct * +*/ +OverlapDataStruct *GetOverlapData(void) +{ + return OverlapDataStru; +} + +/* +* ȡָID·ID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetOverlapBelongRouteId(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].BelongRouteId; + } + return reVal; +} + + +/* +* ָIDʼں +* ˵ const UINT16 overlapId, ID +* const UINT16 belongRouteId, · +* ֵ +* +*/ +void SetOverlapBelongRouteId(const UINT16 overlapId, const UINT16 belongRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + OverlapDataStru[bufIndex].BelongRouteId = belongRouteId; /*·*/ + } +} + +/* +* ñι״̬ +* ˵ const UINT16 overlapId, ID +* const UINT8 lockCommand, ״̬ +* ֵ void +*/ +void SetOverlapRelateProtSwLockSta(const UINT16 overlapId, const UINT8 lockCommand) +{ + UINT8 ii = 0u; /**/ + UINT8 retVal = CI_SUCCESS; /*ֵ*/ + UINT16 protectSwitchId = 0u; /*ID*/ + UINT8 overlapProtectSwitchSum = 0u; /*Ŀ*/ + OverlapProtectSwitchStruct* overlapProtectSwitchStru = NULL; /**/ + + overlapProtectSwitchSum = GetOverlapRelatedProtSwitSum(overlapId); /*ȡĿ*/ + overlapProtectSwitchStru = GetOverlapRelatedProtSwitStru(overlapId); /*ȡ*/ + + if (0u == overlapProtectSwitchSum) + { + retVal = CI_ERROR; + } + else + { + } + + if((SWITCH_LOCK_PROTECT_SET != lockCommand) && (SWITCH_LOCK_PROTECT_CANCEL != lockCommand)) + { + retVal = CI_ERROR; + } + else + { + } + + if (CI_SUCCESS == retVal) + { + for (ii= 0u; ii < overlapProtectSwitchSum; ii++) + { + protectSwitchId = overlapProtectSwitchStru[ii].ProtectSwitchId; + SetSwitchLockStatus(SWITCH_PLOCKTYPE_OVERLAP,overlapId,protectSwitchId, lockCommand); /*õ״̬*/ + /*RC 13.0.0 ޣ˫һ*/ +#if 0 + if (SWITCH_TYPE_DOUBLE == GetSwitchType(protectSwitchId)) + { /*˫*/ + SetSwitchLockStatus(SWITCH_PLOCKTYPE_OVERLAP,overlapId,GetDSwitchOtherId(protectSwitchId), lockCommand); /*õ ״̬*/ + } + else + { + } +#endif + } + } + else + { + retVal = CI_ERROR; + } +} + +/* +* ȡָIDʼں +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetOverlapUnlockStartCycNum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].UnlockStartCycNum; + } + return reVal; +} + + +/* +* ָIDʼں +* ˵ const UINT16 overlapId, ID +* const UINT32 unlockStartCycNum, ʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetOverlapUnlockStartCycNum(const UINT16 overlapId, const UINT32 unlockStartCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + OverlapDataStru[bufIndex].UnlockStartCycNum = unlockStartCycNum; /*ýʼں*/ + + reVal = CI_SUCCESS; + } + return reVal; +} + +/* +* ȡָIDѡſʼں +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetOverlapXuanPaiStartCycNum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].XuanPaiStartCycNum; + } + return reVal; +} + + +/* +* ָIDѡſʼں +* ˵ const UINT16 overlapId, ID +* const UINT32 unlockStartCycNum, ѡʼں +* ֵ +* +*/ +void SetOverlapXuanPaiStartCycNum(const UINT16 overlapId, const UINT32 xuanpaiStartCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if ((0U == xuanpaiStartCycNum) || (0U == OverlapDataStru[bufIndex].XuanPaiStartCycNum)) + { + OverlapDataStru[bufIndex].XuanPaiStartCycNum = xuanpaiStartCycNum; /*ѡʼں*/ + } + else + { + /*ѡʼڣ*/ + } + } + else + { + /*IDǷ*/ + } +} + +/* +* ȡָIDZCα־ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT8 GetOverlapUnlockApplyFlag(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].OverlapUnlockApplyFlag; + } + return reVal; +} + + +/* +* ָIDZCα־ +* ˵ const UINT16 overlapId, ID +* const UINT8 overlapUnlockApplyFlag +* ֵ +* +*/ +void SetOverlapUnlockApplyFlag(const UINT16 overlapId, const UINT8 overlapUnlockApplyFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + OverlapDataStru[bufIndex].OverlapUnlockApplyFlag = overlapUnlockApplyFlag; /*ZCα־*/ + } +} + +/* +* ȡָIDгID +* ˵const UINT16 overlapId, ID +* ֵ 0 ȡʧ +* гID0x14 +*/ +UINT16 GetOverlapUnlockApplyTrainId(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].wOverlapUnlockApplyTrainId; + } + return reVal; +} + + +/* +* ָIDгID +* ˵ const UINT16 overlapId, ID +* const UINT16 wTrainIdгID0x14 +* ֵ +* +*/ +void SetOverlapUnlockApplyTrainId(const UINT16 overlapId, const UINT16 wTrainId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + OverlapDataStru[bufIndex].wOverlapUnlockApplyTrainId = wTrainId; + } +} + +/* +* ñε߼гԴ +* ˵ const UINT16 wOverlapId, ID const UINT16 wTrnId гID +* +* ֵ VOID +*/ +void SetOverlapTrainLockApply(const UINT16 wOverlapId, const UINT16 wTrnId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* pLogicSectionId = NULL; + UINT8 cLogicSectionSum = 0u; + UINT8 i = 0u; + + bufIndex = GetOverlapConfigBufIndex(wOverlapId); /*ȡ±*/ + + if (OVERLAP_SUM_MAX > bufIndex) + { + cLogicSectionSum = GetOverlapLogicSectionSum(wOverlapId); + pLogicSectionId = GetOverlapLogicSectionBuf(wOverlapId); + + if ((0u != cLogicSectionSum) && (0u != wTrnId)) + { + for (i = 0u; i < cLogicSectionSum; i++) + { + AddLogSecTrainRes(pLogicSectionId[i],wTrnId); + } + } + else + { + } + } + else + { + } +} +/* +* ñο˹־ +* ˵ const UINT16 overlapId, ID +* const UINT8 CanLaborUnlockFlag ܷ˹־ +*/ +void SetOverlapCanLaborUnlockFlag(const UINT16 overlapId,const UINT8 CanLaborUnlockFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if((CAN_LABOR_UNLOCK_OVERLAP == CanLaborUnlockFlag)||(CANNOT_LABOR_UNLOCK_OVERLAP == CanLaborUnlockFlag)) + { + OverlapDataStru[bufIndex].OverlapCanLaborUnlockFlag = CanLaborUnlockFlag; /*ܷ˹־*/ + } + } +} + +/* +* ȡο˹־ +* ˵ const UINT16 overlapId, ID +* const UINT8 CanLaborUnlockFlag ܷ˹־ +* ֵ 0: ȡʧ +* 0<: ȡɹ +*/ +UINT8 GetOverlapCanLaborUnlockFlag(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].OverlapCanLaborUnlockFlag; /*ܷ˹־*/ + } + return reVal; +} + +/* +* ñ˹״̬ +* ˵ const UINT16 overlapId, ID +* const UINT8 LaborUnlockSetState ˹״̬ +*/ +void SetOverlapLaborUnlockSetState(const UINT16 overlapId,const UINT8 LaborUnlockSetState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if((LABOR_UNLOCK_OVERLAP_YES == LaborUnlockSetState)||(LABOR_UNLOCK_OVERLAP_NO == LaborUnlockSetState)) + { + OverlapDataStru[bufIndex].OverlapLaborUnlockSetState = LaborUnlockSetState; /*˹״̬*/ + } + } +} + +/* +* ȡ˹״̬ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* 0<: ȡɹ +*/ +UINT8 GetOverlapLaborUnlockSetState(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].OverlapLaborUnlockSetState; /*˹״̬*/ + } + return reVal; +} + +/* +* ñ˹ʼں +* ˵ const UINT16 overlapId, ID +* const UINT32 laborUnlockStartCycNum ˹ʼں +*/ +void SetlaborUnlockStartCycNum(const UINT16 overlapId,const UINT32 laborUnlockStartCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + OverlapDataStru[bufIndex].laborUnlockStartCycNum = laborUnlockStartCycNum; /*˹ʼں*/ + } +} + +/* +* ȡ˹ʼں +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* 0<: ȡɹ +*/ +UINT32 GetlaborUnlockStartCycNum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].laborUnlockStartCycNum; /*˹ʼں*/ + } + return reVal; +} + + +/* +* ñATS˹ʶ +* ˵ const UINT16 overlapId, ID +* const UINT8 atsOrlaborLockCmdFlag ATS˹ʶ +*/ +void SetOverlapAtsOrlaborLockCmdFlag(const UINT16 overlapId,const UINT8 atsOrlaborLockCmdFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if((LOCK_OVERLAP_CMD_YES == atsOrlaborLockCmdFlag)||(LOCK_OVERLAP_CMD_NO == atsOrlaborLockCmdFlag)) + { + OverlapDataStru[bufIndex].atsOrlaborLockFlag = atsOrlaborLockCmdFlag; /*ʶ*/ + } + + } +} + +/* +* ñATS˹ʶ +* ˵ const UINT16 overlapId, ID +* ֵ:0:ʧ +* 0<:ATS˹ʶ +*/ +UINT8 GetOverlapAtsOrlaborLockCmdFlag(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].atsOrlaborLockFlag; /*ʶ*/ + } + + return reVal; +} + +/* +* ñճɹʼ +* ˵ const UINT16 overlapId, ID +* const UINT32 lockSucessStartCycNum ճɹʼ +*/ +void SetOverlaplockSucessStartCycNum(const UINT16 overlapId,const UINT32 lockSucessStartCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + OverlapDataStru[bufIndex].lockStartCycNum = lockSucessStartCycNum; /**/ + } +} + +/* +* ȡճɹʼ +* ˵ const UINT16 overlapId, ID +* const UINT32 lockSucessStartCycNum ճɹʼ +*/ +UINT32 GetOverlaplockSucessStartCycNum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].lockStartCycNum; /**/ + } + return reVal; +} + +/* +* ñεʱʱ +* ˵ const UINT16 overlapId, ID +* const UINT16 overlapUnlockTime εʱʱ +*/ +void SetOverlapUnlockTime(const UINT16 overlapId,const UINT16 overlapUnlockTime) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + OverlapDataStru[bufIndex].overlapUnlockTime = overlapUnlockTime; /*ʱ*/ + } +} + +/* +* ñεʱʱ +* ˵ const UINT16 overlapId, ID +* ֵʱʱ +*/ +UINT16 GetOverlapUnlockTime(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].overlapUnlockTime; /*ʱ*/ + } + return reVal; +} +/* +* ñ˹ʶ +* ˵ const UINT16 overlapId, ID +* const UINT8 laborLockCmdFlag ˹ʶ +*/ +void SetOverlaplaborLockCmdFlag(const UINT16 overlapId,const UINT8 laborLockCmdFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if((LOCK_OVERLAP_CMD_YES == laborLockCmdFlag)||(LOCK_OVERLAP_CMD_NO == laborLockCmdFlag)) + { + OverlapDataStru[bufIndex].laborLockOverlapCmd = laborLockCmdFlag; /*ʶ*/ + } + + } +} + +/* +* ñ˹ʶ +* ˵ const UINT16 overlapId, ID +* ֵ:0:ʧ +* 0<:˹ʶ +*/ +UINT8 GetOverlaplaborLockCmdFlag(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].laborLockOverlapCmd; /*ʶ*/ + } + + return reVal; +} + +/* +* ʼں +* ˵const UINT16 overlapId ID +* const UINT32 reqIvocUnlockStartCycNum ʼں +* ֵ +*/ +void SetReqIvocUnlockStartCycNum(const UINT16 overlapId, const UINT32 reqIvocUnlockStartCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + OverlapDataStru[bufIndex].dwReqIvocUnLockStartCycNum = reqIvocUnlockStartCycNum; /*˹ʼں*/ + } +} + +/* +* ȡʼں +* ˵ const UINT16 overlapId ID +* ֵ 0: ȡʧ +* 0<: ȡɹ +*/ +UINT32 GetReqIvocUnlockStartCycNum(const UINT16 overlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = 0u; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].dwReqIvocUnLockStartCycNum; /*˹ʼں*/ + } + return reVal; +} + +/* +* ָIDг־ +* ˵const UINT16 overlapId ID +* const UINT8 overlapIvocUnlockFlag г־ +* ֵ +*/ +void SetOverlapIvocAllowUnlockFlag(const UINT16 overlapId, const UINT8 overlapIvocUnlockFlag) +{ + UINT8 retVal = CI_ERROR; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if ((bufIndex < OVERLAP_SUM_MAX) && ((IVOC_ALLOW_UNLOCK_OVERLAP_YES == overlapIvocUnlockFlag) || (IVOC_ALLOW_UNLOCK_OVERLAP_NO == overlapIvocUnlockFlag))) + { + OverlapDataStru[bufIndex].cIvocAllowUnlockFlag = overlapIvocUnlockFlag; + } + else + { + /**/ + } +} + +/* +* ȡָIDг־ +* ˵const UINT16 overlapId ID +* ֵ 0xAA: ͬ +* 0x55: ͬ +* 0: ȡʧ +*/ +UINT8 GetOverlapIvocAllowUnlockFlag(const UINT16 overlapId) +{ + UINT8 reVal = CI_ERROR; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].cIvocAllowUnlockFlag; + } + else + { + /*ʧ*/ + } + + return reVal; +} + +/* +* ȡָIDιΰķDZڵ߼ +* ˵const UINT16 overlapId ID +* UINT16* logsecIdbuf ߼ID +* ֵ CI_SUCCESS ҳɹ +* CI_ERROR ʧ +* BY LC +*/ +UINT8 GetOverlapPhysecOtherLogSec(const UINT16 overlapId, OUT UINT16 * logsecIdbuf,OUT UINT8 * logSecSum) +{ + UINT8 phySecSum = 0u; /**/ + UINT16* pPhySecIdBuf = NULL; /*νṹָ*/ + UINT8 cLogicSectionSum = 0u; /*߼*/ + UINT16* pLogicSectionIdBuf = NULL; /*߼ID*/ + UINT8 cPhySecIncLogSecSum = 0U; /*ΰ߼*/ + UINT16* pPhySecIncLogSecId = NULL; /*ΰ߼ID*/ + + UINT8 i = 0u; /**/ + UINT8 j = 0u; /**/ + UINT8 k = 0u; /**/ + UINT8 szHitOverlapLgcSec[LOGIC_SECTION_SUM_MAX] = { 0U }; + UINT8 retVal = CI_ERROR; + UINT8 count = 0U; + + phySecSum = GetOverlapPhySecSum(overlapId); /*ȡoverlap*/ + pPhySecIdBuf = GetOverlapPhySecIdBuf(overlapId); /*ȡoverlapID*/ + + + if ((0U < overlapId) && (OVERLAP_SUM_MAX > overlapId) + && (NULL != logsecIdbuf) && (NULL != logSecSum)) + { + retVal = CI_SUCCESS; + + cLogicSectionSum = GetOverlapLogicSectionSum(overlapId); /*ȡoverlap߼*/ + pLogicSectionIdBuf = GetOverlapLogicSectionBuf(overlapId); /*ȡoverlap߼ID*/ + + for (i = 0U; i < cLogicSectionSum; i++) + { + if ((LOGIC_SECTION_SUM_MAX > pLogicSectionIdBuf[i]) && (0U != pLogicSectionIdBuf[i])) + { + szHitOverlapLgcSec[pLogicSectionIdBuf[i]] = 1U; + } + else + { + retVal = CI_ERROR; + break; + } + } + + for (j = 0U; j < phySecSum; j++) + { + /*ȡι߼Ϣ*/ + cPhySecIncLogSecSum = GetPhySecIncLogSecSum(pPhySecIdBuf[j]); + pPhySecIncLogSecId = GetPhySecIncLogSecIdBuf(pPhySecIdBuf[j]); + if ((NULL == pPhySecIncLogSecId) || (0U == cPhySecIncLogSecSum)) + { + retVal = CI_ERROR; + break; + } + else + { + for (k = 0U; k < cPhySecIncLogSecSum; k++) + { + /*߼βڱ*/ + if (0U == szHitOverlapLgcSec[pPhySecIncLogSecId[k]]) + { + logsecIdbuf[count] = pPhySecIncLogSecId[k]; + count++; + } + } + } + } + *logSecSum = count; + } + else + { + retVal = CI_ERROR; + } + + + return retVal; +} + +/* +* ñɽ·־ +* ˵ const UINT16 overlapId, ID +* const UINT8 setFlag ʶ +*/ +void SetOverlapFromSetRouteCmdFlag(const UINT16 overlapId, const UINT8 setFlag) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if ((OVERLAP_ROUTE_FLAG_YES == setFlag) || (OVERLAP_ROUTE_FLAG_NO == setFlag)) + { + OverlapDataStru[bufIndex].OverlapFromSetRouteCmdFlag = setFlag; /*ʶ*/ + } + + } +} + +/* +* ȡɽ·־ +* ˵ const UINT16 overlapId, ID +* ֵ:0:ʧ +* 0<:־ +*/ +UINT8 GetOverlapFromSetRouteCmdFlag(const UINT16 overlapId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 reVal = 0U; + + bufIndex = GetOverlapConfigBufIndex(overlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + reVal = OverlapDataStru[bufIndex].OverlapFromSetRouteCmdFlag; + } + + return reVal; +} + +/* +* 屣˹ATS־ +* ˵ const UINT16 routeId, ·ID +* const UINT16 overlapId, ID +* ֵ: +* by cgh 20240920 +*/ +void CleanOverlapAtsOrlaborLockFlag(const UINT16 routeId, const UINT16 overlapId) +{ + UINT16 overlapRouteSum = 0U; /*ν·*/ + UINT16* pOverlapRouteBuf = NULL; /*ν·*/ + UINT16 atsExpLockOverlapId = 0U; /*ATSյıID*/ + UINT16 routeLastPhyId = 0U; /*·һID*/ + UINT8 routeLastPhyState = 0U; /*·һںռ״̬*/ + UINT16 ii = 0U; /*α*/ + + overlapRouteSum = GetOverlapRouteIdSum(overlapId); /*ȡν·*/ + pOverlapRouteBuf = GetOverlapRouteIdBuf(overlapId); /*ȡν·*/ + + for (ii = 0U; ii < overlapRouteSum; ii++) + { + atsExpLockOverlapId = GetRouteAtsExpLkOverlapId(pOverlapRouteBuf[ii]); + routeLastPhyId = GetRouteLastPhySectionId(pOverlapRouteBuf[ii]); + routeLastPhyState = GetPhySecCurMergeState(routeLastPhyId); + if ((pOverlapRouteBuf[ii] != routeId) && (overlapId == atsExpLockOverlapId) && (SECTION_OCCUPY_YES == routeLastPhyState)) + { + /*ǰһ·һռñνʱ쵽ʱһ·ʱATS˹־ + ᵼºĽ·ıθռʱȥ*/ + break; + } + } + if (ii == overlapRouteSum) + { + SetOverlapAtsOrlaborLockCmdFlag(overlapId, LOCK_OVERLAP_CMD_NO); + } +} + +/* +* ñη־ +* ˵const UINT16 wOverlapId ID +* const UINT8 cCheckResultFlag ־ +* ֵ +* Created By LQ 2024.12.03 +*/ +void SetOverlapProSwtCheckResultFlag(const UINT16 wOverlapId, const UINT8 cCheckResultFlag) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(wOverlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if ((PROSWITCH_CHECK_RESULT_DEFAULT == cCheckResultFlag) || (PROSWITCH_CHECK_RESULT_VALID == cCheckResultFlag) || (PROSWITCH_CHECK_RESULT_INVALID == cCheckResultFlag)) + { + if ((PROSWITCH_CHECK_RESULT_VALID == cCheckResultFlag) && (PROSWITCH_CHECK_RESULT_INVALID == OverlapDataStru[bufIndex].cProSwitchCheckResultFlag)) + { + /*־ֱɳɹתʧ*/ + } + else + { + OverlapDataStru[bufIndex].cProSwitchCheckResultFlag = cCheckResultFlag; + } + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡη־ +* ˵const UINT16 wOverlapId ID +* ֵ0xFF Ĭֵ +* 0x55 ʧ +* 0xAA ɹ +* Created By LQ 2024.12.03 +*/ +UINT8 GetOverlapProSwtCheckResultFlag(const UINT16 wOverlapId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 cRetVal = PROSWITCH_CHECK_RESULT_INVALID; + + bufIndex = GetOverlapConfigBufIndex(wOverlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + cRetVal = OverlapDataStru[bufIndex].cProSwitchCheckResultFlag; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + +/* +* ñη鿪ʼ־ +* ˵const UINT16 wOverlapId ID +* const UINT8 cCheckStartFlag 鿪ʼ־ +* ֵ +* Created By LQ 2024.12.03 +*/ +void SetOverlapProSwtCheckStartFlag(const UINT16 wOverlapId, const UINT8 cCheckStartFlag) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetOverlapConfigBufIndex(wOverlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + if ((PROSWITCH_CHECK_START_VALID == cCheckStartFlag) || (PROSWITCH_CHECK_START_INVALID == cCheckStartFlag)) + { + OverlapDataStru[bufIndex].cProSwitchCheckStartFlag = cCheckStartFlag; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡη鿪ʼ־ +* ˵const UINT16 wOverlapId ID +* ֵ0x55 鿪ʼ +* 0xAA ֹͣ +* Created By LQ 2024.12.03 +*/ +UINT8 GetOverlapProSwtCheckStartFlag(const UINT16 wOverlapId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 cRetVal = PROSWITCH_CHECK_START_INVALID; + + bufIndex = GetOverlapConfigBufIndex(wOverlapId); /*ȡ±*/ + + if (bufIndex < OVERLAP_SUM_MAX) + { + cRetVal = OverlapDataStru[bufIndex].cProSwitchCheckStartFlag; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Overlap/OverlapDataManage.h b/TSCP/src/APP/ciapp/Overlap/OverlapDataManage.h new file mode 100644 index 0000000..047fc02 --- /dev/null +++ b/TSCP/src/APP/ciapp/Overlap/OverlapDataManage.h @@ -0,0 +1,367 @@ +/******************************************************** +* +* OverlapDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _OVERLAP_DATA_MANAGE_H_ +#define _OVERLAP_DATA_MANAGE_H_ + + +#include "OverlapConfigDataManage.h" +#include "CommonTypes.h" +#include "../Switch/SwitchDefine.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*ݽṹ*/ +typedef struct S_OverlapDataStruct +{ + UINT16 OverlapId; /*ID (ʼֶ)*/ + UINT16 BelongRouteId; /*·ID (ֶ̬)*/ + UINT32 UnlockStartCycNum; /*νʼں (ֶ̬)*/ + UINT32 XuanPaiStartCycNum; /*ѡſʼں(ֶ̬)*/ + UINT8 OverlapUnlockApplyFlag; /*ZCν־20181105*/ + UINT16 wOverlapUnlockApplyTrainId;/* 뱣νгID0x14*/ + UINT32 dwReqIvocUnLockStartCycNum; /*ʼں*/ + UINT8 cIvocAllowUnlockFlag; /*гα־0xAAͬ0x55ͬ*/ + UINT8 OverlapCanLaborUnlockFlag;/*ο˹־*/ + UINT8 OverlapLaborUnlockSetState;/*˹״̬*/ + UINT32 laborUnlockStartCycNum;/*˹ʼں*/ + UINT8 atsOrlaborLockFlag;/*ATS˹´־ڼ㵹ʱʼʱ*/ + UINT32 lockStartCycNum;/*ճɹʼں*/ + UINT16 overlapUnlockTime;/*νʱ*/ + UINT8 laborLockOverlapCmd;/*˹ձ˹һЧ*/ + UINT8 OverlapFromSetRouteCmdFlag;/*ɽ·ʱı־*/ + UINT8 cProSwitchCheckResultFlag; /*־0xFFĬֵ0x55ʧܣ0xAAɹ*/ + UINT8 cProSwitchCheckStartFlag; /*鿪ʼ־0x55鿪ʼ0xAAֹͣ*/ +} OverlapDataStruct; + +/*******************************ȫֱ*******************************/ +extern OverlapDataStruct OverlapDataStru[OVERLAP_SUM_MAX]; /*OVERLAPݽṹ*/ +/* +* ȡָID +* ˵ +* ֵ + OverlapDataStruct * +*/ +OverlapDataStruct *GetOverlapData(void); + +/* +* ȡָID·ID +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetOverlapBelongRouteId(const UINT16 overlapId); + +/* +* ָIDʼں +* ˵ const UINT16 overlapId, ID +* const UINT16 belongRouteId, · +* ֵ +* +*/ +void SetOverlapBelongRouteId(const UINT16 overlapId, const UINT16 belongRouteId); + +/* +* ñι״̬ +* ˵ const UINT16 overlapId, ID +* const UINT8 lockCommand, ״̬ +* ֵ void +*/ +void SetOverlapRelateProtSwLockSta(const UINT16 overlapId, const UINT8 lockCommand); + +/* +* ȡָIDʼں +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetOverlapUnlockStartCycNum(const UINT16 overlapId); + +/* +* ָIDʼں +* ˵ const UINT16 overlapId, ID +* const UINT32 unlockStartCycNum, ʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetOverlapUnlockStartCycNum(const UINT16 overlapId, const UINT32 unlockStartCycNum); + +/* +* ȡָIDѡſʼں +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetOverlapXuanPaiStartCycNum(const UINT16 overlapId); + +/* +* ָIDѡſʼں +* ˵ const UINT16 overlapId, ID +* const UINT32 unlockStartCycNum, ѡʼں +* ֵ +* +*/ +void SetOverlapXuanPaiStartCycNum(const UINT16 overlapId, const UINT32 xuanpaiStartCycNum); +/* +* ȡָIDZCα־ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT8 GetOverlapUnlockApplyFlag(const UINT16 overlapId); +/* +* ָIDZCα־ +* ˵ const UINT16 overlapId, ID +* const UINT8 overlapUnlockApplyFlag +* ֵ +* +*/ +void SetOverlapUnlockApplyFlag(const UINT16 overlapId, const UINT8 overlapUnlockApplyFlag); + +/* +* ȡָIDгID +* ˵const UINT16 overlapId, ID +* ֵ 0 ȡʧ +* гID0x14 +*/ +UINT16 GetOverlapUnlockApplyTrainId(const UINT16 overlapId); + + +/* +* ָIDгID +* ˵ const UINT16 overlapId, ID +* const UINT16 wTrainIdгID0x14 +* ֵ +* +*/ +void SetOverlapUnlockApplyTrainId(const UINT16 overlapId, const UINT16 wTrainId); + + +/* +* ñε߼гԴ +* ˵ const UINT16 wOverlapId, ID const UINT16 wTrnId гID +* +* ֵ VOID +*/ +void SetOverlapTrainLockApply(const UINT16 wOverlapId, const UINT16 wTrnId); + +/* +* ñο˹־ +* ˵ const UINT16 overlapId, ID +* const UINT8 CanLaborUnlockFlag ܷ˹־ +*/ +void SetOverlapCanLaborUnlockFlag(const UINT16 overlapId,const UINT8 CanLaborUnlockFlag); +/* +* ȡο˹־ +* ˵ const UINT16 overlapId, ID +* const UINT8 CanLaborUnlockFlag ܷ˹־ +* ֵ 0: ȡʧ +* 0<: ȡɹ +*/ +UINT8 GetOverlapCanLaborUnlockFlag(const UINT16 overlapId); +/* +* ñ˹״̬ +* ˵ const UINT16 overlapId, ID +* const UINT8 LaborUnlockSetState ˹״̬ +*/ +void SetOverlapLaborUnlockSetState(const UINT16 overlapId,const UINT8 LaborUnlockSetState); + +/* +* ȡ˹״̬ +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* 0<: ȡɹ +*/ +UINT8 GetOverlapLaborUnlockSetState(const UINT16 overlapId); + +/* +* ñ˹ʼں +* ˵ const UINT16 overlapId, ID +* const UINT32 laborUnlockStartCycNum ˹ʼں +*/ +void SetlaborUnlockStartCycNum(const UINT16 overlapId,const UINT32 laborUnlockStartCycNum); +/* +* ȡ˹ʼں +* ˵ const UINT16 overlapId, ID +* ֵ 0: ȡʧ +* 0<: ȡɹ +*/ +UINT32 GetlaborUnlockStartCycNum(const UINT16 overlapId); + + +/* +* ñATS˹ʶ +* ˵ const UINT16 overlapId, ID +* const UINT8 atsOrlaborLockCmdFlag ATS˹ʶ +*/ +void SetOverlapAtsOrlaborLockCmdFlag(const UINT16 overlapId,const UINT8 atsOrlaborLockCmdFlag); +/* +* ñATS˹ʶ +* ˵ const UINT16 overlapId, ID +* ֵ:0:ʧ +* 0<:ATS˹ʶ +*/ +UINT8 GetOverlapAtsOrlaborLockCmdFlag(const UINT16 overlapId); +/* +* ñճɹʼ +* ˵ const UINT16 overlapId, ID +* const UINT32 lockSucessStartCycNum ճɹʼ +*/ +void SetOverlaplockSucessStartCycNum(const UINT16 overlapId,const UINT32 lockSucessStartCycNum); +/* +* ȡճɹʼ +* ˵ const UINT16 overlapId, ID +* const UINT32 lockSucessStartCycNum ճɹʼ +*/ +UINT32 GetOverlaplockSucessStartCycNum(const UINT16 overlapId); + +/* +* ñεʱʱ +* ˵ const UINT16 overlapId, ID +* const UINT16 overlapUnlockTime εʱʱ +*/ +void SetOverlapUnlockTime(const UINT16 overlapId,const UINT16 overlapUnlockTime); +/* +* ñεʱʱ +* ˵ const UINT16 overlapId, ID +* ֵʱʱ +*/ +UINT16 GetOverlapUnlockTime(const UINT16 overlapId); +/* +* ñ˹ʶ +* ˵ const UINT16 overlapId, ID +* const UINT8 laborLockCmdFlag ˹ʶ +*/ +void SetOverlaplaborLockCmdFlag(const UINT16 overlapId,const UINT8 laborLockCmdFlag); +/* +* ñ˹ʶ +* ˵ const UINT16 overlapId, ID +* ֵ:0:ʧ +* 0<:˹ʶ +*/ +UINT8 GetOverlaplaborLockCmdFlag(const UINT16 overlapId); + +/* +* ʼں +* ˵const UINT16 overlapId ID +* const UINT32 reqIvocUnlockStartCycNum ʼں +* ֵ +*/ +void SetReqIvocUnlockStartCycNum(const UINT16 overlapId, const UINT32 reqIvocUnlockStartCycNum); + +/* +* ȡʼں +* ˵ const UINT16 overlapId ID +* ֵ 0: ȡʧ +* 0<: ȡɹ +*/ +UINT32 GetReqIvocUnlockStartCycNum(const UINT16 overlapId); + +/* +* ָIDг־ +* ˵const UINT16 overlapId ID +* const UINT8 overlapIvocUnlockFlag г־ +* ֵ +*/ +void SetOverlapIvocAllowUnlockFlag(const UINT16 overlapId, const UINT8 overlapIvocUnlockFlag); + +/* +* ȡָIDг־ +* ˵const UINT16 overlapId ID +* ֵ 0xAA: ͬ +* 0x55: ͬ +* 0: ȡʧ +*/ +UINT8 GetOverlapIvocAllowUnlockFlag(const UINT16 overlapId); + +/* +* ȡָIDιΰķDZڵ߼ +* ˵const UINT16 overlapId ID +* UINT16* logsecIdbuf ߼ID +* ֵ ߼Ŀ +* BY LC +*/ +UINT8 GetOverlapPhysecOtherLogSec(const UINT16 overlapId, OUT UINT16* logsecIdbuf, OUT UINT8* logSecSum); + +/* +* ñɽ·־ +* ˵ const UINT16 overlapId, ID +* const UINT8 setFlag ʶ +*/ +void SetOverlapFromSetRouteCmdFlag(const UINT16 overlapId, const UINT8 setFlag); + +/* +* ȡɽ·־ +* ˵ const UINT16 overlapId, ID +* ֵ:0:ʧ +* 0<:־ +*/ +UINT8 GetOverlapFromSetRouteCmdFlag(const UINT16 overlapId); + +/* +* 屣˹ATS־ +* ˵ const UINT16 routeId, ·ID +* const UINT16 overlapId, ID +* ֵ: +* by cgh 20240920 +*/ +void CleanOverlapAtsOrlaborLockFlag(const UINT16 routeId, const UINT16 overlapId); + +/* +* ñη־ +* ˵const UINT16 wOverlapId ID +* const UINT8 cCheckResultFlag ־ +* ֵ +* Created By LQ 2024.12.03 +*/ +void SetOverlapProSwtCheckResultFlag(const UINT16 wOverlapId, const UINT8 cCheckResultFlag); + +/* +* ȡη־ +* ˵const UINT16 wOverlapId ID +* ֵ0xFF Ĭֵ +* 0x55 ʧ +* 0xAA ɹ +* Created By LQ 2024.12.03 +*/ +UINT8 GetOverlapProSwtCheckResultFlag(const UINT16 wOverlapId); + +/* +* ñη鿪ʼ־ +* ˵const UINT16 wOverlapId ID +* const UINT8 cCheckStartFlag 鿪ʼ־ +* ֵ +* Created By LQ 2024.12.03 +*/ +void SetOverlapProSwtCheckStartFlag(const UINT16 wOverlapId, const UINT8 cCheckStarttFlag); + +/* +* ȡη鿪ʼ־ +* ˵const UINT16 wOverlapId ID +* ֵ0x55 鿪ʼ +* 0xAA ֹͣ +* Created By LQ 2024.12.03 +*/ +UINT8 GetOverlapProSwtCheckStartFlag(const UINT16 wOverlapId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Overlap/OverlapDefine.h b/TSCP/src/APP/ciapp/Overlap/OverlapDefine.h new file mode 100644 index 0000000..3c87018 --- /dev/null +++ b/TSCP/src/APP/ciapp/Overlap/OverlapDefine.h @@ -0,0 +1,78 @@ +/******************************************************** +* +* OverlapConfigDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _OVERLAP_CONFIG_DEFINE_H_ +#define _OVERLAP_CONFIG_DEFINE_H_ + + + +/*OVERLAPֵ*/ +#define OVERLAP_SUM_MAX ((UINT16)1460) /*overlapֵ*/ + + +/*OVERLAPԪ*/ +#define OVERLAP_PHYSEC_SUM_MAX ((UINT16)4) /*屣ΰֵ*/ +#define OVERLAP_CONDISWIT_SUM_MAX ((UINT16)16) /*屣ΰֵ*/ +#define OVERLAP_PROTECTSWI_SUM_MAX ((UINT16)8) /*屣ιֵ*/ +#define OVERLAP_TRIGPHYSEC_SUM_MAX ((UINT16)16) /*Զźoverlapֵ*/ + +#define OVLP_RETROUTSEC_N_RETTRKPHYSEC_SUM_MAX ((UINT16)5) /*屣ΰ۷·۷ֵ*/ +#define OVLP_INVASECT_N_CONDSWIT_SUM_MAX ((UINT16)8) /*屣ΰμֵ*/ +#define OVLP_INVA_OPP_OVLP_SUM_MAX ((UINT16)4) /*屣޵жԱֵ*/ +#define OVLP_FLOODGATE_SUM_MAX ((UINT16)2) /*屣طֵ*/ + +#define OVLP_LOGICSECTION_SUM_MAX ((UINT16)200) /*屣ΰ߼ֵ*/ + +/*ZCα־*/ +#define UNLOCK_OVERLAP_APPLY_YES ((UINT8)0xaa) /*ZC뱣ν*/ +#define UNLOCK_OVERLAP_APPLY_NO ((UINT8)0x55) /*ZC뱣ν*/ + +/* ο״̬ */ +#define OVERLAP_USABLE ((UINT8)0x55U) /*Դ*/ +#define OVERLAP_UNUSABLE ((UINT8)0xAAU) /*Դ*/ + +#define OVERLAP_ROUTE_SUM_MAX ((UINT16)10) /**/ +/*ν*/ +#define ATS_LOCK_OVERLAP ((UINT8)0x01)/*ATS*/ +#define CI_LOCK_OVERLAP ((UINT8)0x02)/*CI*/ +#define LABOR_LOCK_OVERLAP ((UINT8)0x03)/*˹*/ + +/*ܷ˹־*/ +#define CAN_LABOR_UNLOCK_OVERLAP ((UINT8)0xAA)/*δڿ˹״̬*/ +#define CANNOT_LABOR_UNLOCK_OVERLAP ((UINT8)0x55)/*εǰ˹״̬*/ + +/*˹α־*/ +#define LABOR_UNLOCK_OVERLAP_YES ((UINT8)0xAA)/*˹*/ +#define LABOR_UNLOCK_OVERLAP_NO ((UINT8)0x55)/*˹δ*/ + +/*վ̨ռõATSλ˹α־*/ +#define LOCK_OVERLAP_CMD_YES ((UINT8)0xAA)/*ձ*/ +#define LOCK_OVERLAP_CMD_NO ((UINT8)0x55)/*ձδ*/ + +/*гα־*/ +#define IVOC_ALLOW_UNLOCK_OVERLAP_YES ((UINT8)0xAA) /*IVOCͬ*/ +#define IVOC_ALLOW_UNLOCK_OVERLAP_NO ((UINT8)0x55) /*IVOCͬ*/ + +/*ο־*/ +#define PROSWITCH_CHECK_RESULT_DEFAULT ((UINT8)0xFF) /*Ĭֵ*/ +#define PROSWITCH_CHECK_RESULT_INVALID ((UINT8)0x55) /*ʧ*/ +#define PROSWITCH_CHECK_RESULT_VALID ((UINT8)0xAA) /*ɹ*/ + +/*ο鿪ʼ־*/ +#define PROSWITCH_CHECK_START_VALID ((UINT8)0x55) /*ʼ*/ +#define PROSWITCH_CHECK_START_INVALID ((UINT8)0xAA) /*ֹͣ*/ + +#define OVERLAP_USING_OVERTIME_CYC_NUM 10U /*óʱ*/ + +#endif + diff --git a/TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.c b/TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.c new file mode 100644 index 0000000..341f806 --- /dev/null +++ b/TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.c @@ -0,0 +1,57 @@ +/******************************************************** +* +* PSCConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* վ̨ſݹ +* ޸ļ¼ +* +********************************************************/ + +#include "PSCConfigDataManage.h" + + +PscConfigDataStruct PscConfigDataStru[PSC_SUM_MAX]; /*վ̨ſýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ + +INT16 PscCurSum = 0; /*PSCǰ*/ + + +/* +* ȡվ̨ſ +* ˵ +* ֵ + PscConfigDataStruct * +*/ +PscConfigDataStruct *GetPscConfigData(void) +{ + return PscConfigDataStru; +} + + + +/* +* ȡPSCǰ +* ˵ void +* ֵ 0u: ȡʧ +* >0u: ŵǰ +*/ +UINT16 GetPscCurSum(void) +{ + UINT16 retVal = 0u; + + if (PscCurSum >= (INT16)PSC_SUM_MAX) + { + retVal = PSC_SUM_MAX; + } + else if (PscCurSum < 0) + { + retVal = 0u; + } + else + { + retVal = (UINT16)PscCurSum; + } + return retVal; +} + diff --git a/TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.h b/TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.h new file mode 100644 index 0000000..4cf9bd3 --- /dev/null +++ b/TSCP/src/APP/ciapp/PSC/PSCConfigDataManage.h @@ -0,0 +1,60 @@ +/******************************************************** +* +* PSCConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* վ̨ſݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PSC_CONFIG_DATA_MANAGE_H_ +#define _PSC_CONFIG_DATA_MANAGE_H_ + + +#include "PSCDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*PSCݽṹ*/ +typedef struct S_PscConfigDataStruct +{ + UINT16 PscId; /*PSCID (ֶ)*/ /*ID*/ + UINT16 psdSum; /* psd */ + UINT16 psdIdBuff[PSC_INCLUDE_PSD_MAX_SUM]; /* psdID */ +} PscConfigDataStruct; + +extern PscConfigDataStruct PscConfigDataStru[PSC_SUM_MAX]; /*վ̨ſýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern INT16 PscCurSum; /*PSCǰ*/ + +/* +* ȡվ̨ſ +* ˵ +* ֵ + PscConfigDataStruct * +*/ +PscConfigDataStruct *GetPscConfigData(void); + +/* +* ȡPSCǰ +* ˵ void +* ֵ 0u: ȡʧ +* >0u: PSCǰ +*/ +UINT16 GetPscCurSum(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/PSC/PSCDefine.h b/TSCP/src/APP/ciapp/PSC/PSCDefine.h new file mode 100644 index 0000000..27392f1 --- /dev/null +++ b/TSCP/src/APP/ciapp/PSC/PSCDefine.h @@ -0,0 +1,23 @@ +/******************************************************** +* +* PSCConfigDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* վ̨ſͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PSC_DEFINE_H_ +#define _PSC_DEFINE_H_ + + + +/*վ̨ſֵ*/ +#define PSC_SUM_MAX ((UINT16)90) /*վ̨ſֵ*/ + +#define PSC_INCLUDE_PSD_MAX_SUM ((UINT16)8) /*һPSCŸ*/ +#endif diff --git a/TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.c b/TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.c new file mode 100644 index 0000000..06913d6 --- /dev/null +++ b/TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.c @@ -0,0 +1,1044 @@ +/******************************************************** +* +* PSDConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "PSDConfigDataManage.h" + + + + +PsdConfigDataStruct PsdConfigDataStru[PSD_SUM_MAX]; /*ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiPsdIdBuf[PSD_SUM_MAX] = {0u}; /*屾վ̨IDӳ*/ +INT16 PsdCurSum = 0; /*ŵǰ*/ +UINT16 totalPsdNum = 0u;/*͸Psd*/ + + + +/* +* ȡŵǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ŵǰ +*/ +UINT16 GetPsdSum(void) +{ + UINT16 retVal = 0u; + if (PsdCurSum >= (INT16)PSD_SUM_MAX) + { + retVal = PSD_SUM_MAX; + } + else if (PsdCurSum < 0) + { + retVal = 0u; + } + else + { + retVal = (UINT16)PsdCurSum; + } + return retVal; +} + +/* +* ȡָ±ӦID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: D +*/ +UINT16 GetPsdId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + if (bufIndex < GetTotalPsdCurNum()) + { + retVal = LocalCiPsdIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID +* ˵ const UINT16 doorId, ID +* ֵ SWITCH_SUM_MAX: ȡʧ +* doorId)) + { + retVal = doorId; + } + else + { + ; + } + + return retVal; +} + +/* +* ȡָIDվ̨ID +* ˵ const UINT16 doorId, վ̨ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPsdBelongCiId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].BelongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDվ̨վID +* ˵ const UINT16 doorId, վ̨ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPsdBelongStationId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].BelongStationId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDվ̨վ̨ID +* ˵ const UINT16 doorId, վ̨ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetPsdBelongPlatformId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].BelongPlatformId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDŻ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPsdMutualLockRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].MutualLockRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDŻ̵ID 2 +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPsdMutualLockRelayId2(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].wMutualLockRelayId2; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetPsdCloseDriveRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].CloseDriveRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDıż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetFourGroupPsdOpenDrvRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].OpenFourEditGroupDriveRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetSixGroupPsdOpenDrvRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].OpenSixEditGroupDriveRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ȡָIDŰ˱ż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ˱鿪ż̵ID +*/ +UINT16 GetEightGroupPsdOpenDrvRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].OpenEightEditGroupDriveRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDŵİť̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetDoorButtonRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].wRelayDoorButtonId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDŹID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: PSDID +*/ +UINT16 GetPsdRelatedPhySecId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].PsdRelationPhySecId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID״̵̬ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̵̬ID +*/ +UINT16 GetPsdStateRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].DoorStateRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDŹijվ·Ŀ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ijվ·Ŀ +*/ +UINT8 GetPsdRalatedOutStationRouteSum(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].RelatedOutStationRouteSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDŹijվ·ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ijվ·ID +*/ +UINT16 * GetPsdRelOutStationRouteIdBuf(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].RelatedOutStationRouteIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* PSD +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 PsdConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 psdConfigDataSum = 0u; /*PSD豸*/ + UINT8 retVal = CI_SUCCESS; + + /*PsdId*/ + psdConfigDataSum = GetPsdSum(); + totalPsdNum = psdConfigDataSum; + if (psdConfigDataSum >= PSD_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < PSD_SUM_MAX; ii++) + { + if (jj == psdConfigDataSum) + {/*Ч*/ + + break; + } + + if (PsdConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + + LocalCiPsdIdBuf[jj] = PsdConfigDataStru[ii].PsdId; + jj++; + } + + + } + } + + + return retVal; +} + +/* +* Psd +* ˵ psdSum PSD +* psdIdBuff ͸PsdID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendPsdIdDataManage(UINT16 psdSum,const UINT16 *psdIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if ((totalPsdNum + psdSum) >= PSD_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = totalPsdNum; + totalPsdNum += psdSum; + for(ii = 0u;ii< psdSum;ii++) + { + LocalCiPsdIdBuf[index+ii] = psdIdBuff[ii];/*׷ӵLocalCiEsbIdBuf*/ + } + } + + return retVal; +} + +/* +* ȡ͸ԼPsdǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Psdǰ +*/ +UINT16 GetTotalPsdCurNum(void) +{ + UINT16 retVal = 0u; + if (totalPsdNum >= PSD_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = totalPsdNum; + } + return retVal; +} + +/* +* ȡͬPSD ID +* ˵ const UINT16 doorId, վ̨ID +* ֵ 0: ȡʧ +* >0: ͬPSD ID +*/ +UINT16 GetPsdGroupPsdId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].GroupPsdId; + } + else + { + retVal = 0u; + } + return retVal; +} + +/* +* ȡָIDŵ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ŵ +*/ +UINT8 GetPsdVirtualAttribute(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].VirtualAttribute; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDٴοż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ٴοż̵ID +*/ +UINT16 GetPsdReOpenRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].doorReopenRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDŷȷϼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ȷϼ̵ID +*/ +UINT16 GetPsdDeparConfmRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].departureConfirmRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID̵̽ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ̵̽ID +*/ +UINT16 GetPsdDetStartRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].detectStartRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDֹͣ϶̵̽ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ̵ֹͣ̽ID +*/ +UINT16 GetPsdDetStopRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].detectStopRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϰ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ϰ̵ID +*/ +UINT16 GetPsdObtacleRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].obstacleRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDż϶̽⻥̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ϶̽⻥̵ID +*/ +UINT16 GetPsdGapDetMuLockelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].gapDetMuLockRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDųŹ״̵̬ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Ź״̵̬ID +*/ +UINT16 GetPsdDoorStateRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].closeStateRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDſ״̬ɼ̵ID 2 +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Ź״̵̬ID +*/ +UINT16 GetPsdStateRelayId2(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].wDoorStateRelayId2; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPsdbelongVirCIid(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].BelongVirCIid; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDͰťȷȵƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +* cgh-ϲCID-3037-7 +*/ +UINT16 GetQKASteadyLightRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].ClearPasseSteadyLightRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDͰťȷƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +* cgh-ϲCID-3037-7 +*/ +UINT16 GetQKAFlashLightRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].ClearPasseFlashLightRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDͰťȷϰť̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +* cgh-ϲCID-3037-7 +*/ +UINT16 GetQKButtonRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].ClearPassengerButtonRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDȷPCBť̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ȷPCBť̵ID +* by cgh-20230529 +*/ +UINT16 GetCleFarePCBButRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].wCleFarePCBButtonRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDȷPDBťָʾƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ȷPDBťָʾƼ̵ID +* by cgh-20230529 +*/ +UINT16 GetCleFarePDBFlaLigRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].wCleFarePDBFlaLigRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDٴοŰťָʾƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ٴοŰťָʾƼ̵ID +*/ +UINT16 GetPsdPobBsdRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].wPobIndicatorRelayId; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡָIDٴιŰťָʾƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ٴιŰťָʾƼ̵ID +*/ +UINT16 GetPsdPcbRelayId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdConfigDataStru[bufIndex].wPcbIndicatorRelayId; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡָIDͰťƵָʾ1̵̣ID +* ˵ const UINT16 wDoorId, ID +* ֵ 0: ȡʧ +* >0: ͰťƵָʾ1̵̣ID +* by cgh 20231214 +*/ +UINT16 GetPsdVideoQkLight1RelayId(const UINT16 wDoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(wDoorId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdConfigDataStru[bufIndex].wVideoQkLight1RelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDͰťƵָʾ2죩̵ID +* ˵ const UINT16 wDoorId, ID +* ֵ 0: ȡʧ +* >0: ͰťƵָʾ2죩̵ID +* by cgh 20231214 +*/ +UINT16 GetPsdVideoQkLight2RelayId(const UINT16 wDoorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(wDoorId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdConfigDataStru[bufIndex].wVideoQkLight2RelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* PSDǷڴ䷶Χ +* ˵ const UINT16 wCheckPsdId, PSDID +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20240621 +*/ +UINT8 CheckPsdBelSendRange(const UINT16 wCheckPsdId) +{ + UINT8 retVal = CI_ERROR; + UINT16 wPsdSum = 0U;/*PSDĿ*/ + UINT16 ii = 0U; + UINT16 wPsdId = 0U;/*PSD ID*/ + + if ((0U < wCheckPsdId) && (PSD_SUM_MAX > wCheckPsdId)) + { + /*ʼ*/ + retVal = CI_SUCCESS; + wPsdSum = GetTotalPsdCurNum(); + for (ii = 0U; ii < wPsdSum; ii++) + { + wPsdId = GetPsdId(ii);/*ȡļиµPSD ID*/ + if (wCheckPsdId == wPsdId) + { + retVal = CI_ERROR; + break; + } + else + { + ; /*do nothing*/ + } + } + } + else + { + ; /**/ + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.h b/TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.h new file mode 100644 index 0000000..aca7c84 --- /dev/null +++ b/TSCP/src/APP/ciapp/PSD/PSDConfigDataManage.h @@ -0,0 +1,418 @@ +/******************************************************** +* +* PSDConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PSD_CONFIG_DATA_MANAGE_H_ +#define _PSD_CONFIG_DATA_MANAGE_H_ + + +#include "PSDDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ݽṹ*/ +typedef struct S_PsdConfigDataStruct +{ + UINT16 PsdId; /*ID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 BelongVirCIid; /*ID*/ + UINT8 BelongStationId; /*վID*/ + UINT16 BelongPlatformId; /*߼վ̨ID*/ + UINT8 RelatedOutStationRouteSum; /*Źijվ·Ŀ*/ + UINT16 RelatedOutStationRouteIdBuf[RALATED_OUT_STATION_ROUTE_SUM_MAX]; /*Źijվ·ID*/ + UINT16 MutualLockRelayId; /*̵ID (ֶ)*/ + UINT16 wMutualLockRelayId2; /*̵ID2(ֶ) ˹*/ + UINT16 CloseDriveRelayId; /*ż̵ID (ֶ)*/ + UINT16 OpenFourEditGroupDriveRelayId; /*ıŵ̵(ֶ)*/ + UINT16 OpenSixEditGroupDriveRelayId; /*ŵ̵(ֶ)*/ + UINT16 OpenEightEditGroupDriveRelayId; /*򿪰˱ŵ̵(ֶ)*/ + UINT16 DoorStateRelayId; /*ſɼ̵ID (ֶ)*/ + UINT16 wDoorStateRelayId2; /*ſɼ̵ID2(ֶ) ˹*/ + UINT16 wRelayDoorButtonId; /*ٹŰť̵*/ + UINT16 doorReopenRelayId; /*վ̨ٴοż̵*/ + UINT16 departureConfirmRelayId; /*ȷϼ̵*/ + UINT16 detectStartRelayId; /*̵̽*/ + UINT16 detectStopRelayId; /*̵ֹͣ̽*/ + UINT16 obstacleRelayId; /*ϰ̵*/ + UINT16 gapDetMuLockRelayId; /*϶̽⻥̵*/ + UINT16 closeStateRelayId; /*Ź״̵̬*/ + UINT16 PsdRelationPhySecId; /*ŹID*/ + UINT16 GroupPsdId; /*ͬPSD ID,ܴ˫ŵվ̨*/ + UINT8 VirtualAttribute; /*Ƿ*/ + UINT16 ClearPasseSteadyLightRelayId; /*ȵƼ̵ID*/ + UINT16 ClearPasseFlashLightRelayId; /*Ƽ̵ID*/ + UINT16 ClearPassengerButtonRelayId; /*ȷϰť̵ID*/ + UINT16 wCleFarePCBButtonRelayId; /*ȷPCBť̵*/ + UINT16 wCleFarePDBFlaLigRelayId; /*ȷPDBťָʾƼ̵*/ + UINT16 wPobIndicatorRelayId; /*ٿŰťָʾƼ̵*/ + UINT16 wPcbIndicatorRelayId; /*ٹŰťָʾƼ̵*/ + UINT16 wVideoQkLight1RelayId; /*ͰťƵָʾ1̵̣*/ + UINT16 wVideoQkLight2RelayId; /*ͰťƵָʾ2죩̵*/ +} PsdConfigDataStruct; + + + +/*******************************ȫֱ*******************************/ +extern PsdConfigDataStruct PsdConfigDataStru[PSD_SUM_MAX]; /*ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiPsdIdBuf[PSD_SUM_MAX]; /*屾վ̨IDӳ*/ +extern INT16 PsdCurSum; /*ŵǰ*/ +extern UINT16 totalPsdNum;/*͸Psd*/ +/* +* ȡŵǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ŵǰ +*/ +UINT16 GetPsdSum(void); + +/* +* ȡָ±ӦID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: D +*/ +UINT16 GetPsdId(const UINT16 bufIndex); + +/* +* ȡָID +* ˵ const UINT16 doorId, ID +* ֵ SWITCH_SUM_MAX: ȡʧ +* 0: ID +*/ +UINT8 GetPsdBelongCiId(const UINT16 doorId); + +/* +* ȡָIDվ̨վID +* ˵ const UINT16 doorId, վ̨ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPsdBelongStationId(const UINT16 doorId); + +/* +* ȡָIDվ̨վ̨ID +* ˵ const UINT16 doorId, վ̨ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetPsdBelongPlatformId(const UINT16 doorId); + +/* +* ȡָIDŻ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPsdMutualLockRelayId(const UINT16 doorId); + +/* +* ȡָIDŻ̵ID 2 +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPsdMutualLockRelayId2(const UINT16 doorId); +/* +* ȡָIDż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetPsdCloseDriveRelayId(const UINT16 doorId); + + + +/* +* ȡָIDıż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetFourGroupPsdOpenDrvRelayId(const UINT16 doorId); + + +/* +* ȡָIDż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetSixGroupPsdOpenDrvRelayId(const UINT16 doorId); + +/* +* ȡָIDŰ˱ż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ˱鿪ż̵ID +*/ +UINT16 GetEightGroupPsdOpenDrvRelayId(const UINT16 doorId); + + +/* +* ȡָIDŵİť̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +*/ +UINT16 GetDoorButtonRelayId(const UINT16 doorId); + +/* +* ȡָIDŹID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: PSDID +*/ +UINT16 GetPsdRelatedPhySecId(const UINT16 doorId); + +/* +* ȡָID״̵̬ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̵̬ID +*/ +UINT16 GetPsdStateRelayId(const UINT16 doorId); + +/* +* ȡָIDŹijվ·Ŀ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ijվ·Ŀ +*/ +UINT8 GetPsdRalatedOutStationRouteSum(const UINT16 doorId); + +/* +* ȡָIDŹijվ·ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ijվ·ID +*/ +UINT16 * GetPsdRelOutStationRouteIdBuf(const UINT16 doorId); + +/* +* PSD +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 PsdConfigDataManage(void); + +/* +* Psd +* ˵ psdSum PSD +* psdIdBuff ͸PsdID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendPsdIdDataManage(UINT16 psdSum,const UINT16 *psdIdBuff); + +/* +* ȡ͸ԼPsdǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Psdǰ +*/ +UINT16 GetTotalPsdCurNum(void); + +/* +* ȡͬPSD ID +* ˵ const UINT16 doorId, վ̨ID +* ֵ 0: ȡʧ +* >0: ͬPSD ID +*/ +UINT16 GetPsdGroupPsdId(const UINT16 doorId); + +/* +* ȡָIDŵ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ŵ +*/ +UINT8 GetPsdVirtualAttribute(const UINT16 doorId); + +/* +* ȡָIDٴοż̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ٴοż̵ID +*/ +UINT16 GetPsdReOpenRelayId(const UINT16 doorId); + +/* +* ȡָIDŷȷϼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ȷϼ̵ID +*/ +UINT16 GetPsdDeparConfmRelayId(const UINT16 doorId); + +/* +* ȡָID̵̽ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ̵̽ID +*/ +UINT16 GetPsdDetStartRelayId(const UINT16 doorId); + +/* +* ȡָIDֹͣ϶̵̽ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ̵ֹͣ̽ID +*/ +UINT16 GetPsdDetStopRelayId(const UINT16 doorId); + +/* +* ȡָIDϰ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ϰ̵ID +*/ +UINT16 GetPsdObtacleRelayId(const UINT16 doorId); + +/* +* ȡָIDż϶̽⻥̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ϶̽⻥̵ID +*/ +UINT16 GetPsdGapDetMuLockelayId(const UINT16 doorId); + +/* +* ȡָIDųŹ״̵̬ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Ź״̵̬ID +*/ +UINT16 GetPsdDoorStateRelayId(const UINT16 doorId); +/* +* ȡָIDID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPsdbelongVirCIid(const UINT16 doorId); + +/* +* ȡָIDſ״̬ɼ̵ID 2 +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Ź״̵̬ID +*/ +UINT16 GetPsdStateRelayId2(const UINT16 doorId); +/* +* ȡָIDͰťȷȵƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +* cgh-ϲCID-3037-7 +*/ +UINT16 GetQKASteadyLightRelayId(const UINT16 doorId); + +/* +* ȡָIDͰťȷƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +* cgh-ϲCID-3037-7 +*/ +UINT16 GetQKAFlashLightRelayId(const UINT16 doorId); + +/* +* ȡָIDͰťȷϰť̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ż̵ID +* cgh-ϲCID-3037-7 +*/ +UINT16 GetQKButtonRelayId(const UINT16 doorId); + +/* +* ȡָIDȷPCBť̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ȷPCBť̵ID +* by cgh-20230529 +*/ +UINT16 GetCleFarePCBButRelayId(const UINT16 doorId); + +/* +* ȡָIDȷPDBťָʾƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ȷPDBťָʾƼ̵ID +* by cgh-20230529 +*/ +UINT16 GetCleFarePDBFlaLigRelayId(const UINT16 doorId); + +/* +* ȡָIDٴοŰťָʾƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ٴοŰťָʾƼ̵ID +*/ +UINT16 GetPsdPobBsdRelayId(const UINT16 doorId); + +/* +* ȡָIDٴιŰťָʾƼ̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ٴιŰťָʾƼ̵ID +*/ +UINT16 GetPsdPcbRelayId(const UINT16 doorId); + +/* +* ȡָIDͰťƵָʾ1̵̣ID +* ˵ const UINT16 wDoorId, ID +* ֵ 0: ȡʧ +* >0: ͰťƵָʾ1̵̣ID +* by cgh 20231214 +*/ +UINT16 GetPsdVideoQkLight1RelayId(const UINT16 wDoorId); + +/* +* ȡָIDͰťƵָʾ2죩̵ID +* ˵ const UINT16 wDoorId, ID +* ֵ 0: ȡʧ +* >0: ͰťƵָʾ2죩̵ID +* by cgh 20231214 +*/ +UINT16 GetPsdVideoQkLight2RelayId(const UINT16 wDoorId); + +/* +* PSDǷڴ䷶Χ +* ˵ const UINT16 wCheckPsdId, PSDID +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20240621 +*/ +UINT8 CheckPsdBelSendRange(const UINT16 wCheckPsdId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/PSD/PSDDataManage.c b/TSCP/src/APP/ciapp/PSD/PSDDataManage.c new file mode 100644 index 0000000..b15470a --- /dev/null +++ b/TSCP/src/APP/ciapp/PSD/PSDDataManage.c @@ -0,0 +1,2512 @@ +/******************************************************** +* +* PSDConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "PSDDataManage.h" +#include "../ParsePack/ParsePackDefine.h" + +PsdDataStruct PsdDataStru[PSD_SUM_MAX]; /*ݽṹ*/ + +/* +* ȡָID +* ˵ +* ֵ PsdDataStruct * +*/ +PsdDataStruct *GetPsdData(void) +{ + return PsdDataStru; +} + +/* +* ȡָIDŻ״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPsdMutualLockRemoveState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].MutualLockRemoveState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDŻ״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 mutualLockState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdMutualLockRemoveState(const UINT16 doorId, const UINT8 mutualLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_MUTUALLOCK_REMOVE_NO == mutualLockState) || (PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + { + PsdDataStru[bufIndex].MutualLockRemoveState = mutualLockState; /*Ż״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPsdState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PsdState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 doorState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdState(const UINT16 doorId, const UINT8 doorState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_STATE_CLOSE == doorState) || (PSD_STATE_OPEN == doorState)) + { + PsdDataStru[bufIndex].PsdState = doorState; /*״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDŰť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Űť״̬ +*/ +UINT8 GetPsdButtonState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].DoorButtonState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDŰť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, Űť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdButtonState(const UINT16 doorId, const UINT8 buttonState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_BUTTON_STATE_DOWN == buttonState) || (PSD_BUTTON_STATE_UP == buttonState)) + { + PsdDataStru[bufIndex].DoorButtonState = buttonState; /*վ̨ť״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ȡָID״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPsdDriveState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PsdDriveState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 doorDriveState, ״̬ +* ֵ +* +*/ +void SetPsdDriveState(const UINT16 doorId, const UINT8 doorDriveState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_DRIVE_STATE_CLOSE == doorDriveState) || (PSD_DRIVE_STATE_OPEN == doorDriveState) || (PSD_DRIVE_STATE_INVALID == doorDriveState)) + { + PsdDataStru[bufIndex].PsdDriveState = doorDriveState; /*״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +#if 0 +/* +* ȡָID״̬תƱ־ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬תƱ־ +*/ +UINT8 GetPsdStateTransferFlag(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PsdStateTransferFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} +#endif + +#if 0 +/* +* ָID״̬תƱ־ +* ˵ const UINT16 doorId, ID +* const UINT8 PsdStateTransferFlag, ״̬תƱ־ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdStateTransferFlag(const UINT16 doorId, const UINT8 PsdStateTransferFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_INITIAL_STATE == PsdStateTransferFlag) || + (PSD_OPEN_CMD == PsdStateTransferFlag) || + (PSD_OPEN_STATE == PsdStateTransferFlag) || + (PSD_CLOSE_CMD == PsdStateTransferFlag) || + (PSD_CLOSE_STATE== PsdStateTransferFlag) + ) + { + PsdDataStru[bufIndex].PsdStateTransferFlag = PsdStateTransferFlag; /*״̬תƱ־*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} +#endif + +#if 0 +/* +* ȡָIDŶӦİɹĽ·Ŀ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ſŵźŹرյĽ·Ŀ +*/ +UINT8 GetBuildedOutStationRouteSum(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].BuildedOutStationRouteSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ָIDŶӦİɹĽ·Ŀ +* ˵ const UINT16 doorId, ID +* const UINT8 routeSum, ӦİɹĽ·Ŀ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetBuildedOutStationRouteSum(const UINT16 doorId,const UINT8 routeSum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].BuildedOutStationRouteSum = routeSum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; + + +} +#endif + +#if 0 +/* +* ȡָIDŶӦİɹĽ·Id +* ˵ const UINT16 doorId, ID +* ֵ NULL: ȡʧ +* !NULL: ӦİɹĽ·Id +*/ +UINT16 * GetBuildedOutStationRouteIdBuf(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].BuildedOutStationRouteIdBuf; + } + else + { + retVal = NULL; + } + return retVal; + +} + + +/* +* ȡվ·źŹرǷָIDŴ֮ǰı־ +* ˵ const UINT16 doorId, ID +* ֵ NULL: ȡʧ +* !NULL: վ·źŹرǷָIDŴ֮ǰı־ +*/ +UINT8 * GetPsdOpenBeforeOutStationRouteIsBuildedFlagBuf(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 * retVal = NULL; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PsdOpenBeforeOutStationRouteIsBuildedFlagBuf; + } + else + { + retVal = NULL; + } + return retVal; + +} +#endif +/* +* PSDVOBC +* ˵ const UINT16 doorId,ID +* const UINT16 vobcId,ŵVOBC ID + const UINT8 operCmd,VOBCĿ +* ֵ +* +*/ +void SetPsdVobcCmd(const UINT16 doorId, const UINT16 vobcId,const UINT8 operCmd) +{ + UINT16 bufIndex = 0u; /*±*/ + + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if (PsdDataStru[bufIndex].SrcVobcId == vobcId) + { + PsdDataStru[bufIndex].PsdCmd=operCmd; + } + else + { + /*һVOBCʼţ֮ǰVOBCŲĽиλ*/ + PsdDataStru[bufIndex].SrcVobcId = vobcId; + PsdDataStru[bufIndex].PsdCmd=operCmd; + /*PsdDataStru[bufIndex].ClosedRouteId = 0;*/ + /*PsdDataStru[bufIndex].LastDriState=PSD_DRIVE_STATE_INVALID;*/ + } + PsdDataStru[bufIndex].CmdSetCycle = Get2oo2CurCycleNum(); + } + else + { + /**/ + } +} + +#if 0 +/* +* PSD򿪶ʼźŹرյĽ·ID +* ˵ const UINT16 doorId,ID +* const UINT16 routeId,PSD򿪶ʼźŹرյĽ·ID +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdClosedRouteId(const UINT16 doorId,const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].ClosedRouteId = routeId; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +#endif + +/* +* öӦPSD״̬ΪĬ̬ +* ˵ const UINT16 psdId,PSD ID +* ֵ +* +*/ +void ResetPsdData(const UINT16 psdId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + /*PsdDataStru[bufIndex].SrcVobcId = 0;*/ + PsdDataStru[bufIndex].PsdCmd=PSD_DEFAULT_CONTROL_CMD; + /*վ̨޳ʱPSD򿪡رպͲѯʼ*/ + /*PsdDataStru[bufIndex].CmdSetCycle = 0;*/ + + PsdDataStru[bufIndex].PsdDriveState=PSD_DRIVE_STATE_INVALID; + PsdDataStru[bufIndex].PsdPreDriveState=PSD_DRIVE_STATE_INVALID; + } + else + { + /**/ + } +} +#if 0 +/* +* ȡPSD򿪶ʼźŹرյĽ·ID +* ˵ const UINT16 doorId,ID +* ֵ PSD򿪶ʼźŹرյĽ·ID +*/ +UINT16 GetPsdClosedRouteId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 routeId=0u; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + routeId=PsdDataStru[bufIndex].ClosedRouteId; + } + else + { + routeId=0u; + } + return routeId; +} +#endif + +/* +* PSDVOBC +* ˵ const UINT16 doorId,ID +* ֵ PSDVOBC +*/ +UINT8 GetPsdVobcCmd(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ctrlCmd; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + ctrlCmd=PsdDataStru[bufIndex].PsdCmd; + } + else + { + ctrlCmd=PSD_DEFAULT_CONTROL_CMD; + } + return ctrlCmd; +} +/* +* õǰƸPSDVOBCID +* ˵ const UINT16 doorId,ID +* ֵ ƸPSDVOBCID;ûпƸPSDVOBC,0 +*/ +UINT16 GetPsdVobcId(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 vobcId = 0u; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + vobcId=PsdDataStru[bufIndex].SrcVobcId; + } + else + { + vobcId=0u; + } + return vobcId; +} + +#if 0 +/* +* PSDһε״̬ +* ˵ const UINT16 doorId,ID + const UINT8 driSta,PSD״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdLastDriState(const UINT16 doorId,const UINT8 driSta) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal= CI_ERROR; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_DRIVE_STATE_CLOSE == driSta) || (PSD_DRIVE_STATE_OPEN == driSta) || (PSD_DRIVE_STATE_INVALID == driSta)) + { + PsdDataStru[bufIndex].LastDriState=driSta; + retVal=CI_SUCCESS; + } + else + { + retVal=CI_ERROR; + } + } + else + { + retVal=CI_ERROR; + } + return retVal; +} +/* +* øPSDһε״̬ +* ˵ const UINT16 doorId,ID +* ֵ PSDһε״̬ +*/ +UINT8 GetPsdLastDriState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 driSta=PSD_DRIVE_STATE_INVALID; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + driSta=PsdDataStru[bufIndex].LastDriState; + } + else + { + driSta=PSD_DRIVE_STATE_INVALID; + } + return driSta; +} +#endif + +/* +* øPSDĿ +* ˵ const UINT16 doorId,ID +* ֵ PSDĿ +*/ +UINT32 GetPsdCmdSetCycle(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 setCycle=0u; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + setCycle=PsdDataStru[bufIndex].CmdSetCycle; + } + else + { + setCycle=0u; + } + return setCycle; +} +/* +* ȡPSDϰ״̬ +* ˵ const UINT16 doorId,ID + +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetPsdRemoraState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PsdRemoraState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* PSDϰ״̬ +* ˵ const UINT16 doorId,ID + const UINT8 driSta,PSDϰ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdRemoraState(const UINT16 doorId, const UINT8 remoraState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_REMORA_YES == remoraState) || (PSD_REMORA_NO == remoraState) ) + { + PsdDataStru[bufIndex].PsdRemoraState = remoraState; /*״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡPSDļ϶̽⻥״̬ +* ˵ const UINT16 doorId,ID + +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetJXTCMutualLockState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].JXTCMutualLockState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* PSDϰ״̬ +* ˵ const UINT16 doorId,ID + const UINT8 mutualLockState,ü϶̽⻥״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetJXTCMutualLockState(const UINT16 doorId, const UINT8 mutualLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((JXTC_MUTUALLOCK_REMOVE_YES == mutualLockState) || (JXTC_MUTUALLOCK_REMOVE_NO == mutualLockState) ) + { + PsdDataStru[bufIndex].JXTCMutualLockState = mutualLockState; /*϶̽⻥״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָPSD̽ں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ +* +*/ +void SetStartDetectionCycNum(const UINT16 doorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].StartDetectionCycNum = startCycNum; + } + else + { + /**/ + } +} +/* +* ȡ̽ʼں +* ˵ const UINT16 doorId, ·ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetStartDetectionCycNum(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].StartDetectionCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ÿʼ̽״̬ +* ˵ const UINT16 doorId, ID +* const UINT32 detectionState, ״̬ +* ֵ +* +*/ +void SetStartDetectionState(const UINT16 doorId, const UINT32 detectionState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((JXTC_START_DETECTION_NO == detectionState) || (JXTC_START_DETECTION_YES == detectionState) ) + { + PsdDataStru[bufIndex].StartDetectionState = (UINT8)(detectionState); + } + else + { + /**/ + } + + } + else + { + /**/ + } +} +/* +* ȡʼ̽״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT8 GetStartDetectionState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].StartDetectionState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ֹͣ̽״̬ +* ˵ const UINT16 doorId, ID +* const UINT32 detectionState, ֹͣ̽״̬ +* ֵ +* +*/ +void SetStopDetectionState(const UINT16 doorId, const UINT32 detectionState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((JXTC_STOP_DETECTION_NO == detectionState) || (JXTC_STOP_DETECTION_YES == detectionState) ) + { + PsdDataStru[bufIndex].StopDetectionState = (UINT8)(detectionState); + } + else + { + /**/ + } + + } + else + { + /**/ + } +} +/* +* ȡֹͣ̽״̬ +* ˵ const UINT16 routeId, ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT8 GetStopDetectionState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].StopDetectionState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +#if 0 +/* +* VOBCPSDҪؿĽ· +* ˵ const UINT16 doorId,ID +* const UINT16 routeId,·ID +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdToBeOpenedRoute(const UINT16 doorId, const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].ToBeOpenedRouteId = routeId; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡVOBCPSDҪؿĽ· +* ˵ const UINT16 doorId,ID +* ֵ 0: ûVOBCPSDҪؿĽ·Dzʧ +* >0: VOBCPSDҪؿĽ· +*/ +UINT16 GetPsdToBeOpenedRoute(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].ToBeOpenedRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +#endif + +/* +* ȡָIDſŰť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ſŰť״̬ +*/ +UINT8 GetPsdOpenButtonState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].doorOpenButtonState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDſŰť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, ſŰť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdOpenButtonState(const UINT16 doorId, const UINT8 buttonState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_OPEN_BUTTON_STATE_VALID == buttonState) || (PSD_OPEN_BUTTON_STATE_INVALID == buttonState)) + { + PsdDataStru[bufIndex].doorOpenButtonState = buttonState; /*վ̨ť״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ȡָIDŷť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ŷť״̬ +*/ +UINT8 GetPsdDepartButtonState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].doorDepartButtonState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDŷť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, ŷť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdDepartButtonState(const UINT16 doorId, const UINT8 buttonState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PLATFORM_DEPAR_BUTTON_STATE_VALID == buttonState) || (PLATFORM_DEPAR_BUTTON_STATE_INVALID == buttonState)) + { + PsdDataStru[bufIndex].doorDepartButtonState = buttonState; /*վ̨ť״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ָIDPCBʼں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetPCBPressCycNum(const UINT16 doorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].PCBPressCycNum = startCycNum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDPCBʼں +* ˵ const UINT16 doorIdID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetPCBPressCycNum(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PCBPressCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDPOBʼں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetPOBPressCycNum(const UINT16 doorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].POBPressCycNum = startCycNum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDPOBʼں +* ˵ const UINT16 doorIdID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetPOBPressCycNum(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].POBPressCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDPSBʼں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetPSBPressCycNum(const UINT16 doorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].PSBPressCycNum = startCycNum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDPSBʼں +* ˵ const UINT16 doorIdID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetPSBPressCycNum(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PSBPressCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDŰť·״̬ +* ˵ const UINT16 doorId, ID +* UINT8 setFlag õİť·״̬ +* ֵ PSD_BUTTON_PANGLU_STATE_VALID 0x55 Ч +* PSD_BUTTON_PANGLU_STATE_INVALID 0xaa Ч +*/ +UINT8 SetPsdButtonPangluState(const UINT16 doorId, const UINT8 setFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_BUTTON_PANGLU_STATE_VALID == setFlag) || (PSD_BUTTON_PANGLU_STATE_INVALID == setFlag)) + { + PsdDataStru[bufIndex].PsdButtonPangluState = setFlag; /*ðť·״̬*/ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDŰť·״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: վ̨ȫŰť·״̬ +*/ +UINT8 GetPsdButtonPangluState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*վ̨ȫŰť·״̬*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PsdButtonPangluState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDűϢ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡϢʧ +* >0: Ϣ +*/ +UINT16 GetPsdEditGroupInfoFromPsdData(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].psdEditGroupInfo; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* VOBC2CI״̬Ϣ +* ˵ const UINT16 doorId, ID +* const UINT32 doorState, ״̬ +* ֵ +* +*/ +void SetVOBCDoorState(const UINT16 doorId, const UINT32 doorState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((PSD_DOOR_CLOSEDANDLOCKED_VALID == doorState) || (PSD_DOOR_CLOSEDANDLOCKED_INVALID == doorState)) + { + PsdDataStru[bufIndex].VOBCDoorState = (UINT8)(doorState); + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡVOBC2CI״̬Ϣ +* ˵ const UINT16 doorId, ID +* ֵ UINT8,״̬Ϣ +* 0: ȡ״̬Ϣʧ +* >0: ȡ״̬Ϣɹ +*/ +UINT8 GetVOBCDoorState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].VOBCDoorState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDPsc +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT32 GetPsdCmdCyclePsc(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].CmdSetCyclePsc; + } + else + { + retVal = 0u; + } + return retVal; +} + + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 doorState, +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdCmdCyclePsc(const UINT16 doorId, const UINT32 doorCycle) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].CmdSetCyclePsc = doorCycle; /**/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDȷPSC־ +* ˵ const UINT16 doorId, ID +* const UINT8 setFlag, ·״̬ +* ֵ +* +*/ + +void SetPsdPscConfirmFlag(const UINT16 doorId,const UINT8 setFlag) +{ + /*ʼ*/ + UINT16 bufIndex = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + if(bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].PscPlConfirmFlag = setFlag; + } + else + { + /**/ + } +} + +/* +* ȡָIDȷPSC·־ +* ˵ const UINT16 doorId, ID +* +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetPsdPscPlFlag(const UINT16 doorId) +{ + /*ʼ*/ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if(bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].PscPlConfirmFlag; + } + else + { + /**/ + } + return(retVal); +} + +/* +* PSCͬʱһͨʱPSC· +* ˵ UINT8 psdId psd ID +* UINT16 pscId psc豸ID +* UINT8 setFlag,ñ־ +* ֵ +*/ +void SetNearCiPscPlFlag(const UINT16 psdId,const UINT16 pscId,const UINT8 setFlag) +{ + /*ʼ*/ + UINT8 i = 0u; + UINT8 transmitState = 0u; + UINT8 localCiId = 0u; + UINT8 psdCiId = 0u; + UINT8 pscPlFlag = 0u; + UINT16 savePscId = 0u; + UINT8 lowBytePscId = 0u; + UINT8 funcId = EFUNC_SETNEARCIPSCPLFLAG; + UINT8 sendLevel = ESEND_LEVEL_ATS; + + /*ֵ*/ + savePscId = pscId; + lowBytePscId =(UINT8)(savePscId & 0x00FFu); + localCiId = GetSystemParaLocalCiId();/*ȡCI ID*/ + psdCiId = GetPsdBelongCiId(psdId); + + + /*PSCCIͨ״̬*/ + (void)UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_PSC, lowBytePscId); + transmitState = GetCiTransmitState(CI_SYSTEM_TYPE_PSC, lowBytePscId); + /*PSC·*/ + if(CI_PSC_PL_CONFIRM_YES == setFlag) + { + /*ͨ쳣*/ + if(TRANSMIT_STATE_GOOD != transmitState) + { + /**/ + if(psdCiId == localCiId) + { + /*PSCӦPSD·*/ + SetPsdPscConfirmFlag(psdId, setFlag); + } + } + else + { + /**/ + SetErrorData(funcId,CI_SYSTEM_TYPE_PSC,pscId,ETYPE_COMM_WITH_PSC,transmitState,sendLevel); + } + } + else + { + /*ȡPSD·־*/ + pscPlFlag = GetPsdPscPlFlag(psdId); + if(psdCiId == localCiId) + { + if(CI_PSC_PL_CONFIRM_YES == pscPlFlag) + { + SetPsdPscConfirmFlag(psdId, CI_PSC_PL_CONFIRM_NO); + } + else + { + /**/ + SetErrorData(funcId,CI_SYSTEM_TYPE_PSC,pscId,ETYPE_PSC_CONFIRM_PL_STATE,CI_PSC_PL_CONFIRM_NO,sendLevel); + } + } + } +} + +/* +* ü϶̵̽ +* ˵ UINT16 psdId ID +* UINT32 cycNum +* ֵ +* +*/ +void SetJXTCStartUpCycNum(UINT16 psdId, UINT32 cycNum) +{ + /*ʼ*/ + + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].JXTCStartCycNum = cycNum; /**/ + } + else + { + /**/ + } +} + + +/* +* ȡ϶̵̽ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0ʼ +* +*/ +UINT32 GetJXTCStartUpCycNum(UINT16 psdId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].JXTCStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ü϶̵ֹ̽ͣ +* ˵ UINT16 psdId ID +* UINT32 cycNum +* ֵ +* +*/ +void SetJXTCStopUpCycNum(UINT16 psdId, UINT32 cycNum) +{ + /*ʼ*/ + + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].JXTCStopCycNum = cycNum; /**/ + } + else + { + /**/ + } +} + +/* +* ȡ϶̵ֹ̽ͣ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0ʼ +* +*/ +UINT32 GetJXTCStopUpCycNum(UINT16 psdId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].JXTCStopCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ϶̽ת״̬ +* ˵ UINT16 psdId ID +* +* ֵ +* +*/ +void SetJXTCStartState(UINT16 psdId, UINT8 jxtcState) +{ + /*ʼ*/ + + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].JXTCStartState = jxtcState; /*״̬*/ + } + else + { + /**/ + } + +} + +/* +* ȡ϶̽״̬ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0϶̽ +* +*/ +UINT8 GetJXTCStartState(UINT16 psdId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].JXTCStartState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ֹͣ϶̽ת״̬ +* ˵ UINT16 psdId ID +* +* ֵ +* +*/ +void SetJXTCStopState(UINT16 psdId, UINT8 jxtcState) +{ + /*ʼ*/ + + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].JXTCStopState = jxtcState; /*״̬*/ + } + else + { + /**/ + } + +} + +/* +* ȡֹͣ϶̽״̬ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0϶̽ +* +*/ +UINT8 GetJXTCStopState(UINT16 psdId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].JXTCStopState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ü϶̽־ +* ˵ UINT16 psdId ID +* UINT8 jxtcDriveFlag ϶̽־ +* ֵ +* +*/ +void SetJXTCDriveStartFlag(UINT16 psdId, UINT8 jxtcDriveFlag) +{ + /*ʼ*/ + + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].JXTCStartFlag = jxtcDriveFlag; /*״̬*/ + } + else + { + /**/ + } + +} + +/* +* ȡ϶̽־ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0϶̽־ +* +*/ +UINT8 GetJXTCDriveStartFlag(UINT16 psdId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].JXTCStartFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ü϶ֹ̽ͣ־ +* ˵ UINT16 psdId ID +* UINT8 jxtcDriveFlag ϶ֹ̽ͣ־ +* ֵ +* +*/ +void SetJXTCDriveStopFlag(UINT16 psdId, UINT8 jxtcDriveFlag) +{ + /*ʼ*/ + + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].JXTCStopFlag = jxtcDriveFlag; /*״̬*/ + } + else + { + /**/ + } + +} + +/* +* ȡ϶ֹ̽ͣ־ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0϶ֹ̽ͣ־ +* +*/ +UINT8 GetJXTCDriveStopFlag(UINT16 psdId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].JXTCStopFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPsdPreDriveState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].PsdPreDriveState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 doorDriveState, ״̬ +* ֵ void +*/ +void SetPsdPreDriveState(const UINT16 doorId, const UINT8 doorDriveState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + if ((PSD_DRIVE_STATE_CLOSE == doorDriveState) || (PSD_DRIVE_STATE_OPEN == doorDriveState) || (PSD_DRIVE_STATE_INVALID == doorDriveState)) + { + PsdDataStru[bufIndex].PsdPreDriveState = doorDriveState; /*״̬*/ + } + + } + +} +/* +* ſʼ +* ˵ UINT16 psdId ID +* UINT32 cycNum +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void SetPsdDriveOpenStartCycNum(UINT16 psdId, UINT32 cycNum) +{ + /*ʼ*/ + + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].psdDriveOpenStartNum = cycNum; /**/ + } + else + { + /**/ + } +} + +/* +* ȡpsdſʼ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0ʼ +*cgh-ϲCID-2349-4 +*/ +UINT32 GetPsdDriveOpenStartCycNum(UINT16 psdId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].psdDriveOpenStartNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* رտʼ +* ˵ UINT16 psdId ID +* UINT32 cycNum +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void SetPsdDriveCloseStartCycNum(UINT16 psdId, UINT32 cycNum) +{ + /*ʼ*/ + + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].psdDriveCloseStartNum = cycNum; /**/ + } + else + { + /**/ + } +} + +/* +* ȡpsdرտʼ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0ʼ +* cgh-ϲCID-2349-4 +* +*/ +UINT32 GetPsdDriveCloseStartCycNum(UINT16 psdId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].psdDriveCloseStartNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡͱ־ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +* cgh-ϲCID-2349-4\cgh-ϲCID-3037-1 +*/ +UINT8 GetClearPassenagerFlag(const UINT16 doorId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].clearPassengerFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ͱ־ +* ˵ UINT16 psdId ID +* UINT8 clearPassenagerFlag ͱ־ +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void SetClearPassenagerFlag(const UINT16 psdId, UINT8 clearPassenagerFlag) +{ + /*ʼ*/ + + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].clearPassengerFlag = clearPassenagerFlag; /**/ + } + else + { + /**/ + } +} + +/* +* ȡͰťǷȵƱ־ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +* cgh-ϲCID-2349-4\cgh-ϲCID-3037-1 +*/ +UINT8 GetSteadyLightFlag(const UINT16 doorId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].steadyLightFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ͰťȵƱ־ +* ˵ UINT16 psdId ID +* UINT8 clearPassenagerFlag ͱ־ +* ֵ +* cgh-ϲCID-2349-4\cgh-ϲCID-3037-1 +* +*/ +void SetSteadyLightFlag(const UINT16 psdId, UINT8 steadyLightFlag) +{ + /*ʼ*/ + + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetPsdConfigBufIndex(psdId); /*ȡ±*/ + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].steadyLightFlag = steadyLightFlag; /**/ + } + else + { + /**/ + } +} + +/* +* ָIDȷPCBʼں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +* ӣby cgh 20230526 +*/ +UINT8 SetCleFarePCBPressCycNum(const UINT16 doorId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + PsdDataStru[bufIndex].dwCleFarePCBPressCycNum = startCycNum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDȷPCBʼں +* ˵ const UINT16 doorIdID +* ֵ 0: ȡʧ +* >0: ʼں +*ӣ by cgh 20230526 +*/ +UINT32 GetCleFarePCBPressCycNum(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].dwCleFarePCBPressCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDȷPCBť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Űť״̬ +* * ӣby cgh 20230526 +*/ +UINT8 GetCleFarePCBButtonState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].chCleFarePCBButtonState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDȷPCBť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, Űť״̬ +* ֵ 0: ʧ +* 1: óɹ +* * ӣby cgh 20230526 +*/ +UINT8 SetCleFarePCBButtonState(const UINT16 doorId, const UINT8 buttonState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((QK_PSD_BUTTON_STATE_DOWN == buttonState) || (QK_PSD_BUTTON_STATE_UP == buttonState)) + { + PsdDataStru[bufIndex].chCleFarePCBButtonState = buttonState; /*ȷPCBť״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDȷPCBť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Űť״̬ +* * ӣby cgh 20230526 +*/ +UINT8 GetCleFarePCBButKeepState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].chCleFarePCBButKeepState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDȷPCBť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, Űť״̬ +* ֵ 0: ʧ +* 1: óɹ +* * ӣby cgh 20230526 +*/ +UINT8 SetCleFarePCBButKeepState(const UINT16 doorId, const UINT8 buttonState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((QK_PSD_BUTTON_STATE_UP == buttonState) || (QK_PSD_BUTTON_STATE_DOWN == buttonState)) + { + PsdDataStru[bufIndex].chCleFarePCBButKeepState = buttonState; /*ȷPCBť״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDȷPDBťָʾƱ־ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, ȷPDBťָʾƱ־ +* ֵ 0: ʧ +* 1: óɹ +* * ӣby cgh 20230529 +*/ +UINT8 SetCleFarePDBFlaLigFlag(const UINT16 doorId, const UINT8 buttonState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal =CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + if ((QK_BUTTON_FLASH_LIGHT_NO == buttonState) || (QK_BUTTON_FLASH_LIGHT_YES == buttonState)) + { + PsdDataStru[bufIndex].chCleFarePDBFlaLigFlag = buttonState; /*ȷPCBť״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDȷPDBťָʾƱ־ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ȷPDBťָʾƱ־ +* * ӣby cgh 20230529 +*/ +UINT8 GetCleFarePDBFlaLigFlag(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal =CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (bufIndex < PSD_SUM_MAX) + { + retVal = PsdDataStru[bufIndex].chCleFarePDBFlaLigFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ñOCȷPCBť״̬ +* ˵ const UINT16 wOcId OC ID + const UINT8 buttonState, Űť״̬ +* ֵ +* * ӣby cgh 20230605 +*/ +void SetAllCleFarePCBButKeepSta(const UINT16 wOcId,const UINT8 buttonState) +{ + UINT16 ii = 0U; /*α*/ + UINT16 wPsdSum = 0U; /*psd*/ + UINT16 wPsdId = 0U; /*ID*/ + UINT16 wCleFarePCBButtonRelayId = 0U;/*ŶӦȷPCBť̵*/ + UINT16 wPsdCleFarePCBDelayCiId = 0U; /*ŶӦȷPCBť̵ID*/ + UINT16 wPsdBufIndex = 0U;/*ָID*/ + + wPsdSum = GetPsdSum(); + for (ii = 0u; ii < wPsdSum; ii++) + { + wPsdId = GetPsdId(ii); + if ((0u < wPsdId) && (PSD_SUM_MAX > wPsdId)) + { + wCleFarePCBButtonRelayId = GetCleFarePCBButRelayId(wPsdId); + wPsdBufIndex = GetPsdConfigBufIndex(wPsdId); + if (PSD_SUM_MAX > wPsdBufIndex) + { + if ((0U == wCleFarePCBButtonRelayId) || (UINT16_MAX == wCleFarePCBButtonRelayId)) + { + ; /*̵IDЧҪ״̬*/ + } + else + { + wPsdCleFarePCBDelayCiId = GetRelayBelongOCId(wCleFarePCBButtonRelayId); + if (wOcId == wPsdCleFarePCBDelayCiId) + { + if ((QK_PSD_BUTTON_STATE_UP == buttonState) || (QK_PSD_BUTTON_STATE_DOWN == buttonState)) + { + PsdDataStru[wPsdBufIndex].chCleFarePCBButKeepState = buttonState; /*ȷPCBť״̬*/ + } + else + { + ; /*Ƿ״̬*/ + } + } + else + { + ; /*ڱOC*/ + } + } + } + else + { + ; /*IDЧ*/ + } + } + else + { + ; /*IDЧ*/ + } + } +} + +/* +* ָIDƵ״̬ +* ˵ const UINT16 wPsdId, ID +* const UINT8 chSetState, Ƶ״̬ +* ֵ +* ӣby cgh 20231214 +*/ +void SetPsdVideoQkDriveState(const UINT16 wPsdId, const UINT8 chSetState) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetPsdConfigBufIndex(wPsdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + if ((VIDEO_QK_DRIVE_STATE_NO == chSetState) || (VIDEO_QK_DRIVE_STATE_HAVE == chSetState) || + (VIDEO_QK_DRIVE_STATE_TESTING == chSetState) || (VIDEO_QK_DRIVE_STATE_INVALID == chSetState)) + { + PsdDataStru[bufIndex].chVideoQkDriveState = chSetState; /*Ƶ״̬*/ + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ȡָIDƵ״̬ +* ˵ const UINT16 wPsdId, ID +* ֵ 0: ȡʧ +* >0: Ƶ״̬ +* * ӣby cgh 20231214 +*/ +UINT8 GePsdVideoQkDriveState(const UINT16 wPsdId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(wPsdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].chVideoQkDriveState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDƵ͹VOBC ID +* ˵ const UINT16 wPsdId, ID +* const UINT16 wVobcId, Ƶ͹VOBC ID +* ֵ +* ӣby cgh 20231214 +*/ +void SetPsdVideoQkRelateVobcId(const UINT16 wPsdId, const UINT16 wVobcId) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetPsdConfigBufIndex(wPsdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + PsdDataStru[bufIndex].wVideoQkRelateVobcId = wVobcId; /*Ƶ͹VOBC ID*/ + } + else + { + ; /**/ + } +} + +/* +* ȡָIDƵ͹VOBC ID +* ˵ const UINT16 wPsdId, ID +* ֵ 0: ȡʧ +* >0: Ƶ״̬ +* * ӣby cgh 20231214 +*/ +UINT16 GePsdVideoQkRelateVobcId(const UINT16 wPsdId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPsdConfigBufIndex(wPsdId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + retVal = PsdDataStru[bufIndex].wVideoQkRelateVobcId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/PSD/PSDDataManage.h b/TSCP/src/APP/ciapp/PSD/PSDDataManage.h new file mode 100644 index 0000000..8012e33 --- /dev/null +++ b/TSCP/src/APP/ciapp/PSD/PSDDataManage.h @@ -0,0 +1,879 @@ +/******************************************************** +* +* PSDDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PSD_DATA_MANAGE_H_ +#define _PSD_DATA_MANAGE_H_ + + +#include "PSDDefine.h" +#include "PSDConfigDataManage.h" +#include "../ERROR/ErrorDataManage.h" +#include "../ERROR/ErrorDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../Relay/RelayConfigDataManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*ݽṹ*/ +typedef struct S_PsdDataStruct +{ + UINT16 PsdId; /*ID (ʼֶ)*/ + UINT16 psdEditGroupInfo; /*űϢ(ֶ̬)*/ + UINT8 MutualLockRemoveState; /*״̬ (ֶ̬)*/ + UINT8 PsdState; /*״̬ (ֶ̬)*/ + UINT8 DoorButtonState; /*ٹŰť״̬(ֶ̬)*/ + UINT8 doorOpenButtonState; /*վ̨Űť״̬(ֶ̬)*/ + UINT8 doorDepartButtonState; /*վ̨ť״̬(ֶ̬)*/ + UINT8 PsdButtonPangluState; /*վ̨Űť·״̬*/ + UINT8 PsdDriveState; /*״̬ (ֶ̬)*/ + +#if 0 + UINT8 PsdStateTransferFlag; /*״̬תƱ־ֶ̬)*/ + UINT8 BuildedOutStationRouteSum; /*ijվ·Ŀֶ̬Σ*/ + UINT16 BuildedOutStationRouteIdBuf[RALATED_OUT_STATION_ROUTE_SUM_MAX]; /*ijվ·ID飨ֶ̬)*/ + UINT8 PsdOpenBeforeOutStationRouteIsBuildedFlagBuf[RALATED_OUT_STATION_ROUTE_SUM_MAX];/*ijվ·źŹرǷŴ֮ǰı־ :Ӧ־λ 0xAA 0x55*/ +#endif + + UINT16 SrcVobcId;/*ŵĵǰVOBC ID*/ + UINT8 PsdCmd;/*ŵ*/ + /*UINT16 ClosedRouteId;*//*VOBCPSDرźŵĽ·*/ + /*UINT8 LastDriState;*//*ʷ״̬*/ + UINT32 CmdSetCycle;/**/ + UINT32 CmdSetCyclePsc;/**/ + UINT8 PsdRemoraState; /*ϰ״̬*/ + UINT8 JXTCMutualLockState; /*϶̽⻥״̬*/ + UINT32 StartDetectionCycNum; /*̽*/ + UINT8 StartDetectionState; /*̽״̬*/ + UINT8 StopDetectionState; /*ֹͣ̽״̬*/ + UINT8 VOBCDoorState; /*VOBC״̬*/ + UINT32 PCBPressCycNum; /*PCBʼ*/ + UINT32 POBPressCycNum; /*POBʼ*/ + UINT32 PSBPressCycNum; /*PSBʼ*/ + UINT8 PscPlConfirmFlag; /*ATSȷ·־*/ + /*UINT16 ToBeOpenedRouteId;*//*ҪؿĽ·*/ + UINT8 JXTCStartState; /*ӿڼ϶̽״̬*/ + UINT32 JXTCStartCycNum; /*ӿڼ϶̽ʼ*/ + UINT8 JXTCStopState; /*ӿڼ϶ֹ̽ͣ״̬*/ + UINT32 JXTCStopCycNum; /*ӿڼ϶ֹ̽ͣʼ*/ + UINT8 JXTCStartFlag; /*־*/ + UINT8 JXTCStopFlag; /*ֹͣ־*/ + UINT8 PsdPreDriveState; /*״̬ (ֶ̬)*/ + UINT32 psdDriveOpenStartNum; /*PSDʼ*/ + UINT32 psdDriveCloseStartNum; /*PSDʼ*/ + UINT8 clearPassengerFlag; /*ATSǷͱ־*/ + UINT8 steadyLightFlag; /*ͰťָʾȵƱ־*/ + UINT32 dwCleFarePCBPressCycNum; /*ȷŰťʼ*//*by cgh 20230526*/ + UINT8 chCleFarePCBButtonState; /*ȷŰť״̬(ֶ̬)*//*by cgh 20230526*/ + UINT8 chCleFarePCBButKeepState; /*ȷŰť״̬(ֶ̬)*//*by cgh 20230529*/ + UINT8 chCleFarePDBFlaLigFlag; /*ȷPDBťָʾƱ־*//*by cgh 20230529*/ + UINT8 chVideoQkDriveState; /*Ƶ״̬ by cgh 20231214*/ + UINT16 wVideoQkRelateVobcId; /*ƵͶӦгID by cgh 20231214*/ +} PsdDataStruct; + +extern PsdDataStruct PsdDataStru[PSD_SUM_MAX]; /*ݽṹ*/ + +/* +* PSDVOBC +* ˵ const UINT16 doorId,ID +* const UINT16 vobcId,ŵVOBC ID + const UINT8 operCmd,VOBCĿ +* ֵ +* +*/ +void SetPsdVobcCmd(const UINT16 doorId, const UINT16 vobcId,const UINT8 operCmd); +/* +* PSDVOBC +* ˵ const UINT16 doorId,ID +* ֵ PSDVOBC +*/ +UINT8 GetPsdVobcCmd(const UINT16 doorId); +/* +* õǰƸPSDVOBCID +* ˵ const UINT16 doorId,ID +* ֵ ƸPSDVOBCID;ûпƸPSDVOBC,0 +*/ +UINT16 GetPsdVobcId(const UINT16 doorId); +/* +* PSDһε״̬ +* ˵ const UINT16 doorId,ID + const UINT8 driSta,PSD״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +#if 0 +UINT8 SetPsdLastDriState(const UINT16 doorId,const UINT8 driSta); +/* +* øPSDһε״̬ +* ˵ const UINT16 doorId,ID +* ֵ PSDһε״̬ +*/ +UINT8 GetPsdLastDriState(const UINT16 doorId); + +/* +* PSD򿪶ʼźŹرյĽ·ID +* ˵ const UINT16 doorId,ID +* const UINT16 routeId,PSD򿪶ʼźŹرյĽ·ID +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdClosedRouteId(const UINT16 doorId,const UINT16 routeId); +/* +* ȡPSD򿪶ʼźŹرյĽ·ID +* ˵ const UINT16 doorId,ID +* ֵ PSD򿪶ʼźŹرյĽ·ID +*/ +UINT16 GetPsdClosedRouteId(const UINT16 doorId); +#endif + +/* +* øPSDĿ +* ˵ const UINT16 doorId,ID +* ֵ PSDĿ +*/ +UINT32 GetPsdCmdSetCycle(const UINT16 doorId); +/* +* öӦPSD״̬ΪĬ̬ +* ˵ const UINT16 psdId,PSD ID +* ֵ +* +*/ +void ResetPsdData(const UINT16 psdId); + +/* +* ȡָID +* ˵ +* ֵ PsdDataStruct * +*/ +PsdDataStruct *GetPsdData(void); + +/* +* ȡָIDŻ״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPsdMutualLockRemoveState(const UINT16 doorId); + +/* +* ָIDŻ״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 mutualLockState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdMutualLockRemoveState(const UINT16 doorId, const UINT8 mutualLockState); + +/* +* ȡָID״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPsdState(const UINT16 doorId); + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 doorState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdState(const UINT16 doorId, const UINT8 doorState); + +/* +* ȡָIDŰť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Űť״̬ +*/ +UINT8 GetPsdButtonState(const UINT16 doorId); + +/* +* ָIDŰť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, Űť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdButtonState(const UINT16 doorId, const UINT8 buttonState); + + +/* +* ȡָID״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPsdDriveState(const UINT16 doorId); + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 doorDriveState, ״̬ +* ֵ +* +*/ +void SetPsdDriveState(const UINT16 doorId, const UINT8 doorDriveState); +#if 0 +/* +* ȡָID״̬תƱ־ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬תƱ־ +*/ +UINT8 GetPsdStateTransferFlag(const UINT16 doorId); + +/* +* ָID״̬תƱ־ +* ˵ const UINT16 doorId, ID +* const UINT8 PsdStateTransferFlag, ״̬תƱ־ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdStateTransferFlag(const UINT16 doorId, const UINT8 PsdStateTransferFlag); + + +/* +* ȡָIDŶӦİɹĽ·Ŀ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ſŵźŹرյĽ·Ŀ +*/ +UINT8 GetBuildedOutStationRouteSum(const UINT16 doorId); + +/* +* ָIDŶӦİɹĽ·Ŀ +* ˵ const UINT16 doorId, ID +* const UINT8 routeSum, ӦİɹĽ·Ŀ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetBuildedOutStationRouteSum(const UINT16 doorId,const UINT8 routeSum); + +/* +* ȡָIDŶӦİɹĽ·Id +* ˵ const UINT16 doorId, ID +* ֵ NULL: ȡʧ +* !NULL: ӦİɹĽ·Id +*/ +UINT16 * GetBuildedOutStationRouteIdBuf(const UINT16 doorId); + +/* +* ȡվ·źŹرǷָIDŴ֮ǰı־ +* ˵ const UINT16 doorId, ID +* ֵ NULL: ȡʧ +* !NULL: վ·źŹرǷָIDŴ֮ǰı־ +*/ +UINT8 * GetPsdOpenBeforeOutStationRouteIsBuildedFlagBuf(const UINT16 doorId); + +/* +* VOBCPSDҪؿĽ· +* ˵ const UINT16 doorId,ID +* const UINT16 routeId,·ID +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdToBeOpenedRoute(const UINT16 doorId, const UINT16 routeId); + +/* +* ȡVOBCPSDҪؿĽ· +* ˵ const UINT16 doorId,ID +* ֵ 0: ûVOBCPSDҪؿĽ·Dzʧ +* >0: VOBCPSDҪؿĽ· +*/ +UINT16 GetPsdToBeOpenedRoute(const UINT16 doorId); +#endif +/* +* ȡPSDϰ״̬ +* ˵ const UINT16 doorId,ID + +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetPsdRemoraState(const UINT16 doorId); + +/* +* PSDϰ״̬ +* ˵ const UINT16 doorId,ID + const UINT8 driSta,PSDϰ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdRemoraState(const UINT16 doorId, const UINT8 remoraState); +/* +* ȡPSDļ϶̽⻥״̬ +* ˵ const UINT16 doorId,ID + +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetJXTCMutualLockState(const UINT16 doorId); +/* +* PSDϰ״̬ +* ˵ const UINT16 doorId,ID + const UINT8 mutualLockState,ü϶̽⻥״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetJXTCMutualLockState(const UINT16 doorId, const UINT8 mutualLockState); +/* +* ָPSD̽ں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ +* +*/ +void SetStartDetectionCycNum(const UINT16 doorId, const UINT32 startCycNum); +/* +* ȡָID·źſʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetStartDetectionCycNum(const UINT16 doorId); +/* +* ÿʼ̽״̬ +* ˵ const UINT16 doorId, ID +* const UINT32 detectionState, ״̬ +* ֵ +* +*/ +void SetStartDetectionState(const UINT16 doorId, const UINT32 detectionState); +/* +* ȡʼ̽״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT8 GetStartDetectionState(const UINT16 doorId); + +/* +* ֹͣ̽״̬ +* ˵ const UINT16 doorId, ID +* const UINT32 detectionState, ֹͣ̽״̬ +* ֵ +* +*/ +void SetStopDetectionState(const UINT16 doorId, const UINT32 detectionState); + +/* +* ȡֹͣ̽״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT8 GetStopDetectionState(const UINT16 doorId); + +/* +* ȡָIDſŰť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ſŰť״̬ +*/ +UINT8 GetPsdOpenButtonState(const UINT16 doorId); + +/* +* ָIDſŰť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, ſŰť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdOpenButtonState(const UINT16 doorId, const UINT8 buttonState); + +/* +* ȡָIDŷť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ŷť״̬ +*/ +UINT8 GetPsdDepartButtonState(const UINT16 doorId); + +/* +* ָIDŷť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, ŷť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdDepartButtonState(const UINT16 doorId, const UINT8 buttonState); + +/* +* ָIDPCBʼں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetPCBPressCycNum(const UINT16 doorId, const UINT32 startCycNum); +/* +* ȡָIDPCBʼں +* ˵ const UINT16 doorIdID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetPCBPressCycNum(const UINT16 doorId); + +/* +* ָIDPOBʼں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetPOBPressCycNum(const UINT16 doorId, const UINT32 startCycNum); +/* +* ȡָIDPOBʼں +* ˵ const UINT16 doorIdID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetPOBPressCycNum(const UINT16 doorId); + +/* +* ָIDPSBʼں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetPSBPressCycNum(const UINT16 doorId, const UINT32 startCycNum); +/* +* ȡָIDPSBʼں +* ˵ const UINT16 doorIdID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetPSBPressCycNum(const UINT16 doorId); +/* +* ָIDŰť·״̬ +* ˵ const UINT16 doorId, ID +* UINT8 setFlag õİť·״̬ +* ֵ PSD_BUTTON_PANGLU_STATE_VALID 0x55 Ч +* PSD_BUTTON_PANGLU_STATE_INVALID 0xaa Ч +*/ +UINT8 SetPsdButtonPangluState(const UINT16 doorId, const UINT8 setFlag); +/* +* ȡָIDŰť·״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: վ̨ȫŰť·״̬ +*/ +UINT8 GetPsdButtonPangluState(const UINT16 doorId); + +/* +* ȡָIDż϶̽⻥̵ID +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ϶̽⻥̵ID +*/ +UINT16 GetPsdEditGroupInfoFromPsdData(const UINT16 doorId); + +/* +* VOBC2CI״̬Ϣ +* ˵ const UINT16 doorId, ID +* const UINT32 doorState, ״̬ +* ֵ +* +*/ +void SetVOBCDoorState(const UINT16 doorId, const UINT32 doorState); + +/* +* ȡVOBC2CI״̬Ϣ +* ˵ const UINT16 doorId, ID +* ֵ UINT8,״̬Ϣ +* 0: ȡ״̬Ϣʧ +* >0: ȡ״̬Ϣɹ +*/ +UINT8 GetVOBCDoorState(const UINT16 doorId); + +/* +* ȡָIDPsc +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT32 GetPsdCmdCyclePsc(const UINT16 doorId); + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 doorState, +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPsdCmdCyclePsc(const UINT16 doorId, const UINT32 doorCycle); + +/* +* ָIDȷPSC־ +* ˵ const UINT16 doorId, ID +* const UINT8 setFlag, ·״̬ +* ֵ +* +*/ + +void SetPsdPscConfirmFlag(const UINT16 doorId,const UINT8 setFlag); + +/* +* ȡָIDȷPSC·־ +* ˵ const UINT16 doorId, ID +* +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetPsdPscPlFlag(const UINT16 doorId); + +/* +* PSCͬʱһͨʱPSC· +* ˵ UINT8 psdId psd ID +* UINT16 pscId psc豸ID +* UINT8 setFlag,ñ־ +* ֵ +*/ +void SetNearCiPscPlFlag(const UINT16 psdId,const UINT16 pscId,const UINT8 setFlag); + +/* +* ü϶̵̽ +* ˵ UINT16 psdId ID +* UINT32 cycNum +* ֵ +* +*/ +void SetJXTCStartUpCycNum(UINT16 psdId, UINT32 cycNum); + +/* +* ȡ϶̵̽ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0ʼ +* +*/ +UINT32 GetJXTCStartUpCycNum(UINT16 psdId); + +/* +* ϶̽ת״̬ +* ˵ UINT16 psdId ID +* +* ֵ +* +*/ +void SetJXTCStartState(UINT16 psdId, UINT8 jxtcState); + +/* +* ȡ϶̽״̬ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0϶̽ +* +*/ +UINT8 GetJXTCStartState(UINT16 psdId); + +/* +* ü϶̵ֹ̽ͣ +* ˵ UINT16 psdId ID +* UINT32 cycNum +* ֵ +* +*/ +void SetJXTCStopUpCycNum(UINT16 psdId, UINT32 cycNum); + +/* +* ȡ϶̵ֹ̽ͣ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0ʼ +* +*/ +UINT32 GetJXTCStopUpCycNum(UINT16 psdId); + +/* +* ֹͣ϶̽ת״̬ +* ˵ UINT16 psdId ID +* +* ֵ +* +*/ +void SetJXTCStopState(UINT16 psdId, UINT8 jxtcState); + +/* +* ȡֹͣ϶̽״̬ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0϶̽ +* +*/ +UINT8 GetJXTCStopState(UINT16 psdId); + +/* +* ü϶̽־ +* ˵ UINT16 psdId ID +* UINT8 jxtcDriveFlag ϶̽־ +* ֵ +* +*/ +void SetJXTCDriveStartFlag(UINT16 psdId, UINT8 jxtcDriveFlag); + +/* +* ȡ϶̽־ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0϶̽־ +* +*/ +UINT8 GetJXTCDriveStartFlag(UINT16 psdId); + +/* +* ü϶ֹ̽ͣ־ +* ˵ UINT16 psdId ID +* UINT8 jxtcDriveFlag ϶ֹ̽ͣ־ +* ֵ +* +*/ +void SetJXTCDriveStopFlag(UINT16 psdId, UINT8 jxtcDriveFlag); + +/* +* ȡ϶ֹ̽ͣ־ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0϶ֹ̽ͣ־ +* +*/ +UINT8 GetJXTCDriveStopFlag(UINT16 psdId); + +/* +* ȡָID״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPsdPreDriveState(const UINT16 doorId); + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 doorDriveState, ״̬ +* ֵ void +*/ +void SetPsdPreDriveState(const UINT16 doorId, const UINT8 doorDriveState); + +/* +* ſʼ +* ˵ UINT16 psdId ID +* UINT32 cycNum +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void SetPsdDriveOpenStartCycNum(UINT16 psdId, UINT32 cycNum); + +/* +* ȡpsdſʼ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0ʼ +*cgh-ϲCID-2349-4 +*/ +UINT32 GetPsdDriveOpenStartCycNum(UINT16 psdId); + +/* +* رտʼ +* ˵ UINT16 psdId ID +* UINT32 cycNum +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void SetPsdDriveCloseStartCycNum(UINT16 psdId, UINT32 cycNum); + +/* +* ȡpsdرտʼ +* ˵ UINT16 psdId ID +* +* ֵ 0ش +* 0ʼ +* cgh-ϲCID-2349-4 +* +*/ +UINT32 GetPsdDriveCloseStartCycNum(UINT16 psdId); + +/* +* ȡͱ־ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +* cgh-ϲCID-2349-4 +*/ +UINT8 GetClearPassenagerFlag(const UINT16 doorId); + +/* +* ͱ־ +* ˵ UINT16 psdId ID +* UINT8 clearPassenagerFlag ͱ־ +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void SetClearPassenagerFlag(const UINT16 psdId, UINT8 clearPassenagerFlag); + +/* +* ȡͰťǷȵƱ־ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +* cgh-ϲCID-2349-4 +*/ +UINT8 GetSteadyLightFlag(const UINT16 doorId); + +/* +* ͰťȵƱ־ +* ˵ UINT16 psdId ID +* UINT8 clearPassenagerFlag ͱ־ +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void SetSteadyLightFlag(const UINT16 psdId, UINT8 steadyLightFlag); + +/* +* ָIDȷPCBʼں +* ˵ const UINT16 doorId, ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +* ӣby cgh 20230526 +*/ +UINT8 SetCleFarePCBPressCycNum(const UINT16 doorId, const UINT32 startCycNum); +/* +* ȡָIDȷPCBʼں +* ˵ const UINT16 doorIdID +* ֵ 0: ȡʧ +* >0: ʼں +*ӣ by cgh 20230526 +*/ +UINT32 GetCleFarePCBPressCycNum(const UINT16 doorId); +/* +* ȡָIDȷPCBť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Űť״̬ +* * ӣby cgh 20230526 +*/ +UINT8 GetCleFarePCBButtonState(const UINT16 doorId); + +/* +* ָIDȷPCBť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, Űť״̬ +* ֵ 0: ʧ +* 1: óɹ +* * ӣby cgh 20230526 +*/ +UINT8 SetCleFarePCBButtonState(const UINT16 doorId, const UINT8 buttonState); + +/* +* ȡָIDȷPCBť״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: Űť״̬ +* * ӣby cgh 20230526 +*/ +UINT8 GetCleFarePCBButKeepState(const UINT16 doorId); +/* +* ָIDȷPCBť״̬ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, Űť״̬ +* ֵ 0: ʧ +* 1: óɹ +* * ӣby cgh 20230526 +*/ +UINT8 SetCleFarePCBButKeepState(const UINT16 doorId, const UINT8 buttonState); + +/* +* ָIDȷPDBťָʾƱ־ +* ˵ const UINT16 doorId, ID +* const UINT8 buttonState, ȷPDBťָʾƱ־ +* ֵ 0: ʧ +* 1: óɹ +* * ӣby cgh 20230529 +*/ +UINT8 SetCleFarePDBFlaLigFlag(const UINT16 doorId, const UINT8 buttonState); + +/* +* ȡָIDȷPDBťָʾƱ־ +* ˵ const UINT16 doorId, ID +* ֵ 0: ȡʧ +* >0: ȷPDBťָʾƱ־ +* * ӣby cgh 20230529 +*/ +UINT8 GetCleFarePDBFlaLigFlag(const UINT16 doorId); + +/* +* ñȷPCBť״̬ +* ˵ const UINT16 wOcId OC ID + const UINT8 buttonState, Űť״̬ +* ֵ +* * ӣby cgh 20230605 +*/ +void SetAllCleFarePCBButKeepSta(const UINT16 wOcId, const UINT8 buttonState); + +/* +* ָIDƵ״̬ +* ˵ const UINT16 wPsdId, ID +* const UINT8 chSetState, Ƶ״̬ +* ֵ +* ӣby cgh 20231214 +*/ +void SetPsdVideoQkDriveState(const UINT16 wPsdId, const UINT8 chSetState); + +/* +* ȡָIDƵ״̬ +* ˵ const UINT16 wPsdId, ID +* ֵ 0: ȡʧ +* >0: Ƶ״̬ +* * ӣby cgh 20231214 +*/ +UINT8 GePsdVideoQkDriveState(const UINT16 wPsdId); + +/* +* ָIDƵ͹VOBC ID +* ˵ const UINT16 wPsdId, ID +* const UINT16 wVobcId, Ƶ͹VOBC ID +* ֵ +* ӣby cgh 20231214 +*/ +void SetPsdVideoQkRelateVobcId(const UINT16 wPsdId, const UINT16 wVobcId); + +/* +* ȡָIDƵ͹VOBC ID +* ˵ const UINT16 wPsdId, ID +* ֵ 0: ȡʧ +* >0: Ƶ״̬ +* * ӣby cgh 20231214 +*/ +UINT16 GePsdVideoQkRelateVobcId(const UINT16 wPsdId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/PSD/PSDDefine.h b/TSCP/src/APP/ciapp/PSD/PSDDefine.h new file mode 100644 index 0000000..6ba3aaa --- /dev/null +++ b/TSCP/src/APP/ciapp/PSD/PSDDefine.h @@ -0,0 +1,175 @@ +/******************************************************** +* +* PSDConfigDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PSD_DEFINE_H_ +#define _PSD_DEFINE_H_ + + + +/*ֵ*/ +#define PSD_SUM_MAX ((UINT16)90U) /*ֵ*/ + +/*Źijվ·Ŀֵ*/ +#define RALATED_OUT_STATION_ROUTE_SUM_MAX ((UINT16)10U) /*Źijվ·Ŀֵ*/ + +/*Ż״̬*/ +#define PSD_MUTUALLOCK_REMOVE_NO ((UINT8)0x55U) /*δ*/ +#define PSD_MUTUALLOCK_REMOVE_YES ((UINT8)0xaaU) /**/ +#define PSD_MUTUALLOCK_REMOVE_DEFAULT ((UINT8)0xffU) /*Ĭֵ*/ +#define PSD_ATS_MUTUALLOCK_REMOVE_YES ((UINT8)0x01U) /*PSC ATSȷϻ*/ +#define PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES ((UINT8)0x02U) /*PSC ATSͼ̵ͬʱȷϻ*/ + +/*Żť״̬*/ +#define PSD_MUTUALLOCK_STATE_DOWN ((UINT8)0x55U) /*ť*/ +#define PSD_MUTUALLOCK_STATE_UP ((UINT8)0xaaU) /*ťδ*/ +#define PSD_MUTUALLOCK_STATE_DEFAULT ((UINT8)0xFFU) /*ťĬֵ*/ + +/*״̬*/ +#define PSD_STATE_CLOSE ((UINT8)0x55U) /**/ +#define PSD_STATE_OPEN ((UINT8)0xaaU) /**/ +#define PSD_STATE_CLOSE_VIETNAM ((UINT8)0xaaU) /*,Խ߽ӿĵ״̬෿߲һ*/ +#define PSD_STATE_OPEN_VIETNAM ((UINT8)0x55U) /**/ +#define PSD_STATE_INVALID_HLHT ((UINT8)0xFFU) /*Ч*/ + +/*վ̨ť״̬*/ +#define PSD_BUTTON_STATE_DOWN ((UINT8)0x55U) /**/ +#define PSD_BUTTON_STATE_UP ((UINT8)0xaaU) /*δ*/ + +/*״̬*/ +#define PSD_DRIVE_STATE_CLOSE ((UINT8)0x11U) /**/ +#define PSD_DRIVE_STATE_OPEN ((UINT8)0x22U) /**/ +#define PSD_DRIVE_STATE_INVALID ((UINT8)0xffU) /*Ч*/ + +/*״̬ת漰״̬*/ +#define PSD_INITIAL_STATE ((UINT8)0x00U) /*ʼ״̬*/ +#define PSD_OPEN_CMD ((UINT8)0x01U) /*յ״̬*/ +#define PSD_OPEN_STATE ((UINT8)0x02U) /*ųɹ״̬*/ +#define PSD_CLOSE_CMD ((UINT8)0x03U) /*յ״̬*/ +#define PSD_CLOSE_STATE ((UINT8)0x04U) /*ųɹر״̬*/ + + +/*ĬϢ*/ +#define PSD_INVALID_ID ((UINT16)0xFFFFU) /*ЧID*/ +#define PSD_DEFAULT_CONTROL_CMD ((UINT8)0x00U) /*ĬϿ*/ +#define PSD_DEFAULT_FAULT_ISOLATION ((UINT32)0xFFFFFFFFU) /*ĬϹϸϢ*/ +#define PSD_DEFAULT_ALL_OPEN_STATE ((UINT32)0xFFFFFFFFU) /*Ĭȫ״̬*/ +#define PSD_INVALID_CMD ((UINT8)0xFFU) /*Ч*/ +#define PSD_FAULT_ISOLATION_SCX ((UINT8)0x81U) /*ԳùϸϢ18Ÿ*/ +#define PSD_OPEN_STATE_SCX ((UINT32)0xFFFFFF7EU) /*Գ߹ϸʱŴ״̬18⣬ȫ*/ + + +/*෿FAOϢ*/ +#define PSD_FOUR_EDIT_GROUP_FAO_YF ((UINT8)0x01U) /*ı*/ +#define PSD_SIX_EDIT_GROUP_FAO_YF ((UINT8)0x02U) /**/ + +/*űϢ*/ +#define PSD_FOUR_EDIT_GROUP ((UINT8)0x04U) /*ı*/ +#define PSD_SIX_EDIT_GROUP ((UINT8)0x06U) /**/ +#define PSD_EIGHT_EDIT_GROUP ((UINT8)0x08U) /*˱*/ + +/*ijվ·źŹرǷŴ֮ǰı־*/ +#define PSD_OPEN_BEFORE_SIG_CLOSE_YES ((UINT8)0xaaU) /*Ŵ֮ǰźŹر*/ +#define PSD_OPEN_BEFORE_SIG_CLOSE_NO ((UINT8)0x55U) /*Ŵ֮źŹر*/ + +#define PSD_HAVE_TRAIN_DOOR_YES ((UINT8)0x55U) /*гϢ*/ +#define PSD_HAVE_TRAIN_DOOR_NO ((UINT8)0xaaU) /*޳Ϣ*/ + +#define PSD_VIRTUAL_ATTR_YES ((UINT8)0x55U) /**/ +#define PSD_VIRTUAL_ATTR_NO ((UINT8)0xaaU) /**/ + +/*ϰϢ*/ +#define PSD_REMORA_YES ((UINT8)0xAAU) /*ϰ*/ +#define PSD_REMORA_NO ((UINT8)0x55U) /*Ѽϰ*/ + +/*϶̽⻥״̬*/ +#define JXTC_MUTUALLOCK_REMOVE_NO ((UINT8)0x55U) /*δ*/ +#define JXTC_MUTUALLOCK_REMOVE_YES ((UINT8)0xaaU) /**/ + +/*϶̽״̬*/ +#define JXTC_START_DETECTION_NO ((UINT8)0x55U) /*δ̽*/ +#define JXTC_START_DETECTION_YES ((UINT8)0xaaU) /*̽*/ + +#define JXTC_STOP_DETECTION_NO ((UINT8)0x55U) /*δֹͣ̽*/ +#define JXTC_STOP_DETECTION_YES ((UINT8)0xaaU) /*ֹͣ̽*/ + +/*վ̨Űť״̬*/ +#define PSD_OPEN_BUTTON_STATE_VALID ((UINT8)0x55U) /*Ч*/ +#define PSD_OPEN_BUTTON_STATE_INVALID ((UINT8)0xaaU) /*Ч*/ + +/*վ̨ť״̬*/ +#define PLATFORM_DEPAR_BUTTON_STATE_VALID ((UINT8)0x55U) /*Ч*/ +#define PLATFORM_DEPAR_BUTTON_STATE_INVALID ((UINT8)0xaaU) /*Ч*/ +#define PLATFORM_DEPAR_BUTTON_NO ((UINT8)0xccU) /*վ̨ť*/ + +/*վ̨ť·״̬*/ +#define PSD_BUTTON_PANGLU_STATE_VALID ((UINT8)0x55U) /*Ч*/ +#define PSD_BUTTON_PANGLU_STATE_INVALID ((UINT8)0xaaU) /*Ч*/ + +/*VOBC2CIŹر*/ +#define PSD_DOOR_CLOSEDANDLOCKED_VALID ((UINT8)0x55U) /*VOBC2CIŹرЧ*/ +#define PSD_DOOR_CLOSEDANDLOCKED_INVALID ((UINT8)0xAAU) /*VOBC2CIŹرЧ*/ + +/*վ̨ťĬ״̬*/ +#define PSD_RELATED_BUTTON_STATE_DEFAULT ((UINT8)0xFFU) + +/*״̬·ʽ*/ +#define PSD_STATE_FROM_VOBC ((UINT8)0x55U) +#define PSD_STATE_FROM_PSC ((UINT8)0xaaU) + +/*PSCΧPSD·״̬ȷ*/ +#define CI_PSC_PL_CONFIRM_NO ((UINT8)0x55U) /*PSC·״̬δȷ*/ +#define CI_PSC_PL_CONFIRM_YES ((UINT8)0xaaU) /*PSC·״̬ȷ*/ + +#define JXTC_NO_DRIVE_STATE ((UINT8)0x01U) /*϶̽ⲽ1ʼ̵ֹͣ*/ +#define JXTC_DRIVE_UP_KEEP_STATE ((UINT8)0x02U) /*϶̽ⲽ2̵ֹͣ𱣳֣ʱ״̬*/ +#define JXTC_DRIVE_DOWN_STATE ((UINT8)0x03U) /*϶̽ⲽ3ɼ̵ֹͣ״̬*/ + +#define JXTC_DRIVE_START_STOP_YES ((UINT8)0x01U) /*ֹͣһ*/ +#define JXTC_DRIVE_START_STOP_NO ((UINT8)0x00U) /*ֹͣ*/ + +/*CIMű*/ +#define PSD_OPEN_OUT_TIME ((UINT8)0x55U)/*δ*/ +#define PSD_CLOSE_OUT_TIME ((UINT8)0xaaU)/*δ*/ + +#define PSD_OPEN_DRVANDCOLL_DIFF ((UINT8)0x55U)/*ɼһ*/ +#define PSD_CLOSE_DRVANDCOLL_DIFF ((UINT8)0xaaU)/*ɼһ*/ + +/*վ̨*/ +#define ATS_TO_CI_PLATFORM_QK_NO ((UINT8)0x55U) /*ATSδվ̨*/ +#define ATS_TO_CI_PLATFORM_QK_YES ((UINT8)0xaaU) /*ATSվ̨*/ + +#define QK_BUTTON_STEADY_LIGHT_NO ((UINT8)0x55U) /*ͰťδȵƱ־*/ +#define QK_BUTTON_STEADY_LIGHT_YES ((UINT8)0xaaU) /*ͰťȵƱ־*/ + +/*ȷPCBť״̬*/ +#define QK_PSD_BUTTON_STATE_DOWN ((UINT8)0x55U) /**/ +#define QK_PSD_BUTTON_STATE_UP ((UINT8)0xaaU) /*δ*/ + +/*ȷPDBťָʾ״̬*/ +#define QK_BUTTON_FLASH_LIGHT_NO ((UINT8)0x55U) /*ȷPDBťָʾƲƱ־*/ +#define QK_BUTTON_FLASH_LIGHT_YES ((UINT8)0xaaU) /*ȷPDBťָʾƱ־*/ + +/*Ƶ*/ +#define VIDEO_QK_STATE_TESTING ((UINT8)0x55U) /*Ƶ״̬*/ +#define VIDEO_QK_STATE_DEFAULT ((UINT8)0xffU) /*Ƶ״̬Ĭ*/ + +#define VIDEO_QK_RESULT_TESTNO ((UINT8)0x55U) /*ƵͽѼ*/ +#define VIDEO_QK_RESULT_TESTHAVE ((UINT8)0xaaU) /*ƵͽѼ*/ +#define VIDEO_QK_RESULT_TESTDEFAULT ((UINT8)0xffU) /*ƵͽĬ*/ + +#define VIDEO_QK_DRIVE_STATE_NO ((UINT8)0x55U) /*Ƶ״̬*/ +#define VIDEO_QK_DRIVE_STATE_HAVE ((UINT8)0xaaU) /*Ƶ״̬*/ +#define VIDEO_QK_DRIVE_STATE_TESTING ((UINT8)0xccU) /*Ƶ״̬*/ +#define VIDEO_QK_DRIVE_STATE_INVALID ((UINT8)0xffU) /*Ƶ״̬Ч*/ + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/CiInterfaceDefine.h b/TSCP/src/APP/ciapp/ParsePack/CiInterfaceDefine.h new file mode 100644 index 0000000..fe2683b --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/CiInterfaceDefine.h @@ -0,0 +1,451 @@ +/******************************************************** +* +* CiInterfaceDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* ATSCIӿڶ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ATS_CI_INTERFACE_DEFINE_H_ +#define _ATS_CI_INTERFACE_DEFINE_H_ + +/*һǰ·*/ +#define ATS_ROUTE_SET_PROCESS_MAX ((UINT8)3) + +/*ATS궨*/ +#define ATS_CMD_STARTFLOCK_UNLOCK_ONE ((UINT8)0x01) /*ȫվһ*/ +#define ATS_CMD_STARTFLOCK_UNLOCK_TWO ((UINT8)0x02) /*ȫվ*/ +#define ATS_CMD_ALL_SIG_BRIGHT_SET_ONE ((UINT8)0x03) /*ȫվһ*/ +#define ATS_CMD_ALL_SIG_BRIGHT_SET_TWO ((UINT8)0x04) /*ȫվƶ*/ +#define ATS_CMD_ALLSIGBRIGHT_CANCEL_ONE ((UINT8)0x05) /*ȡȫվһ*/ +#define ATS_CMD_ALLSIGBRIGHT_CANCEL_TWO ((UINT8)0x06) /*ȡȫվƶ*/ +#define ATS_CMD_SWITCH_ZONGSUO_SET_ONE ((UINT8)0x07) /*һ*/ +#define ATS_CMD_SWITCH_ZONGSUO_SET_TWO ((UINT8)0x08) /**/ +#define ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE ((UINT8)0x09) /*ȡһ*/ +#define ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO ((UINT8)0x0a) /*ȡ*/ +#define ATS_CMD_PHYSEC_RESET_ONE ((UINT8)0x0b) /*Ḵλһ*/ +#define ATS_CMD_PHYSEC_RESET_TWO ((UINT8)0x0c) /*Ḵλ*/ +#define ATS_CMD_SWIT_QIANG_DINGWEI_ONE ((UINT8)0x0d) /*ǿⶨλһ*/ +#define ATS_CMD_SWIT_QIANG_DINGWEI_TWO ((UINT8)0x0e) /*ǿⶨλ*/ +#define ATS_CMD_SWIT_QIANG_FANWEI_ONE ((UINT8)0x2c) /*ǿⷴλһ*/ +#define ATS_CMD_SWIT_QIANG_FANWEI_TWO ((UINT8)0x2d) /*ǿⷴλ*/ +#define ATS_CMD_BUTTON_YULIU ((UINT8)0x0f) /*Ԥ*/ +#define ATS_CMD_BUTTON_STARTUP_UNLOCK ((UINT8)0x10) /*ϵ*/ +#define ATS_CMD_BUTTON_SET_STOPCHECK ((UINT8)0x11) /*ֹͣ*/ +#define ATS_CMD_BUTTON_CANCEL_STOPCHECK ((UINT8)0x12) /*ȡֹͣ*/ +#define ATS_CMD_BUTTON_NONROUTE_SET ((UINT8)0x13) /*ǽ·*/ +#define ATS_CMD_BUTTON_NONROUTE_CANCEL ((UINT8)0x14) /*ǽ·ȡ*/ +#define ATS_CMD_BUTTON_NONROUTE_FAULT ((UINT8)0x15) /*ǽ·ϸԭ*/ +#define ATS_CMD_ROUTE_PUTONG_SET ((UINT8)0x16) /*ͨ·*/ +#define ATS_CMD_ROUTE_YINDAO_SET ((UINT8)0x17) /*·*/ +#define ATS_CMD_ROUTE_ZONGQUXIAO ((UINT8)0x18) /*ȡ*/ +#define ATS_CMD_ROUTE_ZONGRENJIE ((UINT8)0x19) /*˽*/ +#define ATS_CMD_SECTION_FAULT_UNLOCK ((UINT8)0x1a) /*ιϽ*/ +#define ATS_CMD_SIGNAL_REPEAT_OPEN ((UINT8)0x1b) /*ؿź*/ +#define ATS_CMD_SIGNAL_YINDAO_OPEN ((UINT8)0x1c) /*ź*/ +#define ATS_CMD_SIGNAL_FENGSUO_SET ((UINT8)0x1d) /*źŷ*/ +#define ATS_CMD_SIGNAL_FENGSUO_CANCEL ((UINT8)0x1e) /*źŽ*/ +#define ATS_CMD_SWITCH_FENGSUO_SET ((UINT8)0x1f) /**/ +#define ATS_CMD_SWITCH_FENGSUO_CANCEL ((UINT8)0x20) /**/ +#define ATS_CMD_SWITCH_DINGWEI_SET ((UINT8)0x21) /*ܶλ*/ +#define ATS_CMD_SWITCH_FANWEI_SET ((UINT8)0x22) /*ܷλ*/ +#define ATS_CMD_SWITCH_DANSUO_SET ((UINT8)0x23) /**/ +#define ATS_CMD_SWITCH_DANSUO_CANCEL ((UINT8)0x24) /**/ +#define ATS_CMD_AUTO_ROUTE_SET ((UINT8)0x25) /*Զ·*/ +#define ATS_CMD_AUTO_ROUTE_CANCEL ((UINT8)0x26) /*ȡԶ·*/ +#define ATS_CMD_AUTO_RETURN_SET ((UINT8)0x27) /*Զ۷*/ +#define ATS_CMD_AUTO_RETURN_CANCEL ((UINT8)0x28) /*ȡԶ۷*/ +#define ATS_CMD_KOUCHE_SET_XIANDI ((UINT8)0x29) /*վֵؿ۳*/ +#define ATS_CMD_KOUCHE_CANCEL_XIANDI ((UINT8)0x2a) /*վֵؿ۳ȡ*/ +#define ATS_CMD_RETURN_TO_LIECHE ((UINT8)0x2b) /*۷תͨ(źؿ)*/ +#define ATS_CMD_ROUTE_CHANGDIAO_SET ((UINT8)0x2e) /*·*/ +#define ATS_CMD_ROUTE_CHANGDIAO_CANCEL ((UINT8)0x9f) /*ȡ·*/ +#define ATS_CMD_ALL_AUTO_RETURN_SET ((UINT8)0x2f) /*ȫԶ۷*/ +#define ATS_CMD_ALL_AUTO_RETURN_CANCEL ((UINT8)0x30) /*ȡȫԶ۷*/ +#define ATS_CMD_APPLY_TRY_TRAIN ((UINT8)0x31) /* Գť */ +#define ATS_CMD_CANCEL_TRY_TRAIN ((UINT8)0x32) /* ȡԳť */ +#define ATS_CMD_LINSHIXIANSU_CLEAR ((UINT8)0x33) /* ʱ*/ +#define ATS_CMD_CI_MODE_CHANGE ((UINT8)0x34) /* վģʽл */ +#define ATS_CMD_KOUCHE_SET_ATS ((UINT8)0x39) /*ATS˹۳*/ +#define ATS_CMD_KOUCHE_SET_ATS_AUTO ((UINT8)0xa7) /*ATSԶ۳*/ +#define ATS_CMD_KOUCHE_CANCEL_ATS ((UINT8)0x3a) /*ATSĿ۳ȡ*/ +#define ATS_CMD_GARAGE_DOOR_OPEN ((UINT8)0x40) /* ſ */ +#define ATS_CMD_GARAGE_DOOR_CLOSE ((UINT8)0x41) /* Ź */ +#define ATS_CMD_ROUTE_ZUHELIECHE_SET ((UINT8)0x42) /*г·*/ +#define ATS_CMD_ROUTE_ZUHELIECHE_CANCEL ((UINT8)0xA0) /*ȡг·*/ + + + +#define SCX_ATS_CMD_PSD_OPEN ((UINT8)0x44) /**/ +#define SCX_ATS_CMD_PSD_CLOSE ((UINT8)0x45) /*ر*/ +#define SCX_ATS_CMD_PSD_REMOVE ((UINT8)0x46) /*г*/ +#define SCX_ATS_CMD_PSD_REMOVE_CANCEL ((UINT8)0x47) /*ȡг*/ +#define SCX_ATS_CMD_PSD_ISOLATE ((UINT8)0x48) /*Ÿ*/ +#define SCX_ATS_CMD_PSD_ISOLATE_CANCEL ((UINT8)0x49) /*ȡŸ*/ +#define SCX_ATS_CMD_ESB_PRESS ((UINT8)0x4a) /*ýر*/ +#define SCX_ATS_CMD_ESB_CANCEL ((UINT8)0x4b) /*ȡر*/ +#define SCX_ATS_CMD_AUTO_RETURN_SET ((UINT8)0x4c) /*۷*/ +#define SCX_ATS_CMD_AUTO_RETURN_CANCEL ((UINT8)0x4d) /*ȡ۷*/ +#define SCX_ATS_CMD_SPKS_PRESS ((UINT8)0x4e) /*SPKSش*/ +#define SCX_ATS_CMD_SPKS_CANCEL ((UINT8)0x4f) /*SPKSȡ*/ +#define SCX_ATS_CMD_PCB_BUTTON_PRESS ((UINT8)0x50) /*PCBť*/ +#define SCX_ATS_CMD_PCB_BUTTON_CANCEL ((UINT8)0x51) /*ȡPCBť*/ +/* zt ɾش 2022-02-15 */ +#define ATS_CMD_AUTO_TRIGGER_SET ((UINT8)0x53) /*Զ· */ +#define ATS_CMD_CANCLE_AUTO_TRIGGER_SET ((UINT8)0x54) /*ȡԶ· */ +#define ATS_CMD_SET_UP_OVERLAP ((UINT8)0x55) /* */ +#define ATS_CMD_SET_PSD_BUTTON_PANGLU ((UINT8)0x56) /* վ̨ȫŰť· */ +#define ATS_CMD_CANCEL_PSD_BUTTON_PANGLU ((UINT8)0x58) /* رվ̨ȫŰť· */ +#define ATS_CMD_ONEKEY_OPEN_ALL_GARAGE_DOORS ((UINT8)0x59) /*һп*/ +#define ATS_CMD_ONEKEY_CLOSE_ALL_GARAGE_DOORS ((UINT8)0x5A) /*һп*/ +#define ATS_CMD_SECTION_FENGSUO_SET ((UINT8)0x60) /*η*/ +#define ATS_CMD_SECTION_FENGSUO_CANCEL ((UINT8)0x61) /*ν*/ +#define ATS_CMD_PHYSEC_PRE_RESET_ONE ((UINT8)0x62) /*Ԥλһ*/ +#define ATS_CMD_PHYSEC_PRE_RESET_TWO ((UINT8)0x63) /*Ԥλ*/ +#define ATS_CMD_CANCEL_XICHE ((UINT8)0x64) /*ֵȡϴ*/ +#define ATS_CMD_PHYSEC_GENERAL_RESET_SET ((UINT8)0x65) /*ܸλ*/ +#define ATS_CMD_PHYSEC_GENERAL_RESET_CANCEL ((UINT8)0x66) /*ȡܸλ*/ +#define ATS_CMD_CICI_NET_TO_RELAY_ONE ((UINT8)0x68) /*ӿת̵ӿһ*/ +#define ATS_CMD_CICI_NET_TO_RELAY_TWO ((UINT8)0x69) /*ӿת̵ӿڶ*/ +#define ATS_CMD_PSC_PL_ONE ((UINT8)0x70) /*PSC·һ*/ +#define ATS_CMD_PSC_PL_TWO ((UINT8)0x71) /*PSC·*/ +#define ATS_CMD_QUXIAO_PSC_PL_ONE ((UINT8)0x72) /*ȡPSC·һ*/ +#define ATS_CMD_QUXIAO_PSC_PL_TWO ((UINT8)0x73) /*ȡPSC·*/ +#define ATS_CMD_ROUTE_GROUP_AUTO_SET ((UINT8)0x74) /*Զ·*/ +#define ATS_CMD_ROUTE_GROUP_AUTO_CANCLE ((UINT8)0x75) /*ȡԶ·*/ + +#define ATS_CMD_SIGNALMAINTAINSTATE_ONE ((UINT8)0x76) /*źŻά޵һ*/ +#define ATS_CMD_SIGNALMAINTAINSTATE_TWO ((UINT8)0x77) /*źŻά޵ƶ*/ +#define ATS_CMD_CANCEL_SIG_MAINTAIN_ONE ((UINT8)0x78) /*ȡźŻά޵һ*/ +#define ATS_CMD_CANCEL_SIG_MAINTAIN_TWO ((UINT8)0x79) /*ȡźŻά޵ƶ*/ +#define ATS_CMD_CANCEL_SW_ALARM_ONE ((UINT8)0x7a) /*ȡת޻һ*/ +#define ATS_CMD_CANCEL_SW_ALARM_TWO ((UINT8)0x7b) /*ȡת޻*/ +#define ATS_CMD_RECOVER_SW_ALARM_ONE ((UINT8)0x7c) /*ָת޻һ*/ +#define ATS_CMD_RECOVER_SW_ALARM_TWO ((UINT8)0x7d) /*ָת޻*/ + +#define LABOR_CMD_CANCEL_OVERLAP_ONE ((UINT8)0x7e) /* ˹ȡһ */ +#define LABOR_CMD_CANCEL_OVERLAP_TWO ((UINT8)0x7f) /* ˹ȡζ */ +#define LABOR_CMD_SET_UP_OVERLAP ((UINT8)0x80) /* ˹,ϴʱij80 */ + +#define ATS_CMD_ROUTE_APPLY ((UINT8)0x92) /*·*/ +#define ATS_CMD_ROUTE_APPLY_CANCLE ((UINT8)0x93) /*ȡ·*/ +#define ATS_CMD_ROUTE_PART_APPLY ((UINT8)0x94) /*벿·*/ +#define ATS_CMD_ROUTE_PART_APPLY_CANCEL ((UINT8)0x95) /*ȡ벿·*/ +#define ATS_CMD_AUTO_RETURN_SET_ONE ((UINT8)0x96) /*Զ۷һЧ*/ +#define ATS_CMD_AUTO_RETURN_CMD_CANCEL ((UINT8)0x97) /*ȡԶ۷*/ +#define ATS_CMD_SET_PHYSEC_ERR ((UINT8)0x98) /*ιռ*/ +#define ATS_CMD_CANCEL_PHYSEC_FIRST ((UINT8)0x99) /*ιռȡһ*/ +#define ATS_CMD_CANCEL_PHYSEC_SECOND ((UINT8)0x9a) /*ιռȡ*/ +#define ATS_CMD_TOA_RESET_FIRST ((UINT8)0x9b) /*վռѹλ*/ +#define ATS_CMD_TOA_RESET_SECOND ((UINT8)0x9c) /*վռѹλ*/ +#define ATS_CMD_OPEN_XIANSU_SIGNAL_FIRST ((UINT8)0x9d) /*źһ*/ +#define ATS_CMD_OPEN_XIANSU_SIGNAL_SECOND ((UINT8)0x9e) /*źŶ*/ +#define ATS_CMD_OPEN_XIANSU_SIGNAL_SPECIAL ((UINT8)0xa6) /*ź⿪*/ + + + +#define ATS_CMD_GET_CTRL_POWER ((UINT8)0x81) /* ȡȨ*/ +#define ATS_CMD_RELEASE_CTRL_POWER ((UINT8)0x82) /* ͷȨ*/ + +#define ATS_CMD_ROUTE_AUTO_TRIGGER_SET (UINT8)0x83 /*·Զ· */ +#define ATS_CMD_ROUTE_CANCLE_AUTO_TRIGGER (UINT8)0x84 /*·ȡԶ· */ +#define ATS_CMD_SWITCH_DINGWEI_TEST_ONE ((UINT8)0x85) /* λһ*/ +#define ATS_CMD_SWITCH_DINGWEI_TEST_TWO ((UINT8)0x86) /* λԶ*/ +#define ATS_CMD_SWITCH_FANWEI_TEST_ONE ((UINT8)0x87) /* λһ*/ +#define ATS_CMD_SWITCH_FANWEI_TEST_TWO ((UINT8)0x88) /*λԶ*/ + +#define SCX_ATS_CMD_ESS_GO_POSITION (UINT8)0x89 /*ESSȥλ*/ +#define SCX_ATS_CMD_ESS_STOP_POSITION (UINT8)0x90 /*ESSͣλ*/ +#define ATS_CMD_STATION_QK_SET (UINT8)0x91 /*վ̨ͱ־ */ + +/****궨****/ +#define CI_CMD_PHYSEC_USING_APPLY ((UINT16)0x0001) /**/ +#define CI_CMD_PHYSEC_USING_REPLAY_FAILURE ((UINT16)0x0002) /*ʧӦ*/ +#define CI_CMD_PHYSEC_USING_CANCEL ((UINT16)0x0003) /*ȡ*/ +#define CI_CMD_PHYSEC_LOCK_APPLY ((UINT16)0x0004) /**/ +#define CI_CMD_PHYSEC_LOCK_CANCEL ((UINT16)0x0005) /*ȡ*/ +#define CI_CMD_SWITCH_DRIVE ((UINT16)0x0006) /**/ +#define CI_CMD_SIGNAL_SPEC_OPEN_APPLY ((UINT16)0x0007) /*źؿ*/ +#define CI_CMD_TRAIN_TEST_APPLY ((UINT16)0x0009) /*Գ룬Գ->*/ +#define CI_CMD_TRAIN_TEST_ALLOW_STATUS ((UINT16)0x000A) /*Գ״̬->Գ*/ +#define CI_CMD_KOUCHE ((UINT16)0x000B) /*۳*/ +#define CI_CMD_KOUCHE_DETAIN ((UINT16)0x000C) /*۳ӲźŻڱźŻ۳̵ڱ*/ +#define CI_CMD_SET_PSC_PL ((UINT16)0x000D) /*PSC·*/ +#define CI_CMD_QX_PSC_PL ((UINT16)0x000E) /*ȡPSC·*/ +#define CI_CMD_SECTION_FAULT_UNLOCK ((UINT8)0x0F) /* ιϽ*/ +#define CI_CMD_AUTO_SIG_ROUTE_CANCLE ((UINT8)0x11) /*ԶźŽ·ȡ*/ +#define CI_CMD_SET_AUTO_SIG_ROUTE_VALID ((UINT8)0x12) /*ԶźԶЧ*/ +#define CI_CMD_PSD_VOBC_CMD_TO_CI ((UINT8)0x13) /*PSDvobc*/ +#define CI_CMD_ROUTE_OVERLAP_LOGSEC_LOCK ((UINT8)0x14) /*·*/ +#define CI_CMD_ROUTE_OVERLAP_LOCK_REPLAY ((UINT8)0x15) /*·ظ*/ +#define CI_CMD_ROUTE_LOGIC_LOCK_CANCEL ((UINT8)0x16) /*߼ν*/ +#define CI_CMD_LOGSEC_LOCK ((UINT8)0x17) /*߼*/ +#define CI_CMD_LOGSEC_LOCK_REPLAY ((UINT8)0x18) /*߼ظ*/ +#define CI_CMD_RT_OVRLP_RES_SHR ((UINT8)0x19) /*·߼ù*/ +#define CI_CMD_RT_OVRLP_SHR_REPLY ((UINT8)0x20) /*·߼ùظ*/ + +#define CI_CMD_LOCK_OVERLAP_CMD (UINT8)0x21 /*ձ*/ /*TIOC붨ظΪ21,22*/ +#define CI_CMD_UNLOCK_OVERLAP_CMD (UINT8)0x22 /*˹*/ +#define CI_CMD_DR_ROUTE_STATE (UINT8)0x23 /*䶯̬·ý·״̬*/ +#define CI_CMD_DR_SWITCH_PLOCK_CANCEL (UINT8)0x24 /*䶯̬·ȡ״̬*/ +#define LOCK_OVERLAP_HAVE_ROUTE_CMD (UINT8)0x25 /*ձδ·ID*/ + +#define CI_CMD_PHYSEC_PLOCK_ROUTE_CMD (UINT8)0x26U /*η·*/ +#define CI_CMD_LOGSEC_PLOCK_ROUTE_CMD (UINT8)0x27U /*߼η·*/ +#define CI_CMD_ROUTE_LOCKED_OVERLAP (UINT8)0x28U /*ý·չı*/ +#define CI_CMD_ROUTE_NOTVBTC_LOGIC_LOCK_CANCEL ((UINT8)0x29) /*߼ν*/ +#define CI_CMD_OLP_PROSWT_USE_APPLY ((UINT8)0x2A) /**/ +#define CI_CMD_OLP_PROSWT_USE_CANCEL ((UINT8)0x2B) /*ȡ*/ +#define CI_CMD_OLP_PROSWT_USE_FAILURE ((UINT8)0x2C) /*ʧܷ*/ +#define CI_CMD_ROUTE_NEAR_STATE_SEARCH ((UINT8)0x30) /*·ӽ״̬ѯ*/ +#define CI_CMD_ROUTE_NEAR_STATE_REPLAY ((UINT8)0x31) /*·ӽ״̬ظ*/ +#define CI_CMD_ROUTE_SEC_LOCK_APPLY ((UINT8)0x32) /*·*/ +#define CI_CMD_PROSW_SEC_USING_APPLY ((UINT16)0x0033) /**/ +#define CI_CMD_PROSW_SEC_USING_FAIL ((UINT16)0x0034) /*ʧ*/ +#define CI_CMD_PROSW_SEC_USING_CANCEL ((UINT16)0x0035) /*ȡ*/ + +/****VOBC궨****/ +#define VOBCTOCI_COMMAND_TYPE_PSDCHECK ((UINT8)0x00) /*ѯPSD*/ +#define VOBCTOCI_COMMAND_TYPE_PSDOPEN ((UINT8)0x55) /*PSD*/ +#define VOBCTOCI_COMMAND_TYPE_PSDCLOSE ((UINT8)0xAA) /*رPSD*/ +#define VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT ((UINT8)0xFF) /*ѯPSD(»߲ѯ)*/ + +/****ATSϢ궨****/ +/*Ϣ*/ +#define BACK_INFO_ALARM ((UINT8)0x11) /*Ϣ*/ +#define BACK_INFO_OPERATE ((UINT8)0x22) /*Ϣ*/ +#define BACK_INFO_COUNT_DOWN ((UINT8)0x44) /*ʱϢ*/ +#define BACK_INFO_LINK_STATE ((UINT8)0x88) /*״̬Ϣ*/ + + +/*ϷϢ*/ +/*·Ϸ*/ +#define CI_BACK_ROUTE_LEAD_ERROR ((UINT8)0x01) /*·Ϊ*/ +#define CI_BACK_ROUTE_CANCEL ((UINT8)0x02) /*·ȡ*/ +#define CI_BACK_ROUTE_OVERLAP_LOCK_NO ((UINT8)0x03) /*·δ*/ +#define CI_BACK_ROUTE_OVERLAP_OCCUPY ((UINT8)0x04) /*·ռ*/ + +#define CI_BACK_ROUTE_NEAR_LOCK_YES ((UINT8)0x05) /*·ӽ??*/ +#define CI_BACK_ROUTE_LOCK_NOTALL ((UINT8)0x06) /*·??*/ + +#define CI_BACK_ROUTE_LEVEL_CBTC ((UINT8)0x08) /*·ලΪʽ?δʹ?*/ +#define CI_BACK_ROUTE_LEVEL_BLOC ((UINT8)0x00) /*·ලΪCBTC?δʹ?*/ +#define CI_BACK_ROUTE_TYPE_ERROR ((UINT8)0x00) /*·쳣?δʹ?*/ +#define CI_BACK_ROUTE_STATE_ERROR ((UINT8)0x59) /*·*/ +#define CI_BACK_RETURN_ROUTE_STATE_ERROR ((UINT8)0x5A) /*۷·׷ٰ*/ +#define CI_BACK_ROUTE_XUANPAI_OVERTIME ((UINT8)0x07) /*·ѡųʱ*/ + +#define CI_BACK_ROUTE_UNLOCK_FAIL ((UINT8)0x1b) /*·*/ + +#define CI_BACK_GROUP_AUTO_ROUTE_SET_ERR ((UINT8)0x7e) /*Զ·Զʧ*/ + +#define CI_BACK_AUTO_TRIGGER_SET_ERR (UINT8)0x85 /*·Զ־ʧ*/ + +/*źŻϷ*/ +#define CI_BACK_SIG_START_OPEN ((UINT8)0x11) /*·ʼźŻ*/ +#define CI_BACK_SIG_START_CLOSE ((UINT8)0x15) /*·ʼźŻر*/ +#define CI_BACK_SIG_FLOCK_YES ((UINT8)0x12) /*źŻ*/ +#define CI_BACK_SIG_FLOCK_NO ((UINT8)0x13) /*źŻδ*/ +#define CI_BACK_SIG_ENEMY_OPEN ((UINT8)0x14) /*·жźŻ*/ +#define CI_BACK_SIG_NEED_CLOSE ((UINT8)0x00) /*·رźδر*/ +#define CI_BACK_SIG_NEED_OPEN ((UINT8)0x16) /*·迪źδ*/ +#define CI_BACK_SIG_ONE_OPEN ((UINT8)0x17) /*·ͬʱźſ*/ +#define CI_BACK_SIG_OPEN_OT ((UINT8)0x5C) /*źŻųʱ*/ +#define CI_BACK_SIG_CLOSE_OT ((UINT8)0x5C) /*źŻرճʱ*/ + +#define CI_BACK_SIG_ERROR_CLOSE ((UINT8)0x18) /*źŻϹر*/ +#define CI_BACK_AS_RETR_ENDSIG_RT_SET ((UINT8)0x19) /*ԸźŻΪնźŻ۷·Ѿ*/ +#define CI_BACK_SIG_CLOSE_EXCEPT ((UINT8)0x1a) /*źŻ쳣رգźŻڷһο*/ +#define CI_BACK_SIG_YDROUTE_SEARCH_ERR ((UINT8)0x7f) /*ѱźŻΪʼ˵·ʧ*/ + +#define CI_BACK_SIG_LEAD_OPEN_FAIL ((UINT8)0x9F) /*·źſ㣺ȫ*/ + +/*ιϷ*/ +#define CI_BACK_PSEC_OCU_YES ((UINT8)0x21) /*ռ*/ +#define CI_BACK_PSEC_OCU_NO ((UINT8)0x22) /*ο*/ +#define CI_BACK_PSEC_LOCK_YES ((UINT8)0x23) /**/ +#define CI_BACK_PSEC_LOCK_NO ((UINT8)0x24) /*δ*/ +#define CI_BACK_PSEC_INTRU ((UINT8)0x25) /*ռ*/ +#define CI_BACK_PSEC_RUNLOCK_ERROR ((UINT8)0x00) /*۷쳣*/ +#define CI_BACK_PSEC_AUNLOCK_ERROR ((UINT8)0x00) /*Զ쳣*/ +#define CI_BACK_PSEC_USE ((UINT8)0x26) /**/ +#define CI_BACK_PSEC_FLOCK ((UINT8)0x2A) /*ѷ*/ +#define CI_BACK_PSEC_UNFLOCK ((UINT8)0x60) /*δ*/ +#define CI_BACK_PSEC_QGJ_UNLOCK ((UINT8)0x27) /*δЧ*/ +#define CI_BACK_PSEC_QGJ_YINMIAN ((UINT8)0x28) /*ӭЧ*/ +#define CI_BACK_PSEC_QGJ_LOCKERROR ((UINT8)0xA2) /*ιϽ-δ˳*/ +#define CI_BACK_PSEC_JUMP_LOCK_YES ((UINT8)0x2B) /*Ծ*/ +#define CI_BACK_PSEC_RESET_ZFW_ERROR ((UINT8)0x56) /*μܸλ*/ +#define CI_BACK_PSEC_RESET_OP_INVALID_CT_ERROR ((UINT8)0x57) /*CTռüḴλЧ*/ +#define CI_BACK_PSEC_RESET_IN_CT ((UINT8)0x58) /*ḴλCTռ*/ +#define UNLOCK_OVELAP_CANNOT (UINT8)0x80 /**/ +#define LOCK_OVELAP_OUT_CANNOT (UINT8)0x81 /**/ + +/*Ϸ*/ +#define CI_BACK_SWT_YLOCK_YES ((UINT8)0x31) /**/ +#define CI_BACK_SWT_YLOCK_NO ((UINT8)0x00) /*δ*/ +#define CI_BACK_SWT_FLOCK_YES ((UINT8)0x33) /**/ +#define CI_BACK_SWT_FLOCK_NO ((UINT8)0x34) /*δ*/ +#define CI_BACK_SWT_DLOCK_YES ((UINT8)0x35) /**/ +#define CI_BACK_SWT_DLOCK_NO ((UINT8)0x36) /*δ*/ +#define CI_BACK_SWT_PLOCK_YES ((UINT8)0x38) /**/ +#define CI_BACK_SWT_PLOCK_NO ((UINT8)0x73) /*δ*/ +#define CI_BACK_SWT_POS_ERROR ((UINT8)0x37) /*λô*/ +#define CI_BACK_SWT_MOVE_VALID ((UINT8)0x00) /*ɶ*/ +#define CI_BACK_SWT_MOVE_OT ((UINT8)0x39) /*ʱ*/ +#define CI_BACK_SWT_BYPASS_CANCEL_NO ((UINT8)0x93) /*ߵ·δʱȡ*/ +/* zt ɾش 2022-02-15 */ +#define CI_BACK_SWT_USING ((UINT8)0x3f) /**/ +#define CI_BACK_SWT_MOVE_ERR ((UINT8)0x84) /*ᶯʧ*/ + +/*̵Ϸ*/ +#define CI_BACK_REL_ZHAOCHA_UP ((UINT8)0x41) /*ղ̵*/ +#define CI_BACK_CANCEL_ZHAOCHA ((UINT8)0x40) /* ղ̵ */ +#define CI_BACK_PHYSEC_ZHAOCHA ((UINT8)0x50) /* ղ */ +#define CI_BACK_JKJ_VALID ((UINT8)0x5F) /* Ӧ̵̼Ч */ + +/*վ̨Ϸ*/ +#define CI_BACK_PLA_ESB_ESBVALID ((UINT8)0x42) /*ťЧ*/ +#define CI_BACK_PLA_PSD_OPEN ((UINT8)0x43) /*δر*/ +#define CI_BACK_PLA_PSD_MUTULLOCK ((UINT8)0x00) /*Ż*/ +#define CI_BACK_PLA_DETAIN ((UINT8)0x44) /*վ̨۳*/ +#define CI_BACK_PSD_CLOSE_OUT_TIME ((UINT8)0x82) /*Źرճʱ*/ +#define CI_BACK_PSD_OPEN_OUT_TIME ((UINT8)0x83) /*Ŵ򿪳ʱ*/ + + +/* */ +#define CI_BACK_WASH_MACHINE_UNVALID ((UINT8)0x45) /* ϴδ */ +#define CI_BACK_OTHER_GARAGEDOOR_OPEN_NO ((UINT8)0x46) /* δ */ +#define CI_BACK_OTHER_SIGNAL_OPEN_CHECK ((UINT8)0x47) /* źſʧ */ +#define CI_BACK_OTHER_SIGNAL_CHECK ((UINT8)0x48) /* źŻʧ */ +#define CI_BACK_OTHER_SWITCH_POSITION_ERROR ((UINT8)0x49) /* ָλ */ +#define CI_BACK_GARAGEDOOR_STATE_MODE_LOCAL ((UINT8)0x4A) /* ſģʽΪ */ +#define CI_BACK_SPKS_STATE_UP ((UINT8)0x4B) /* SPKSť */ +#define CI_BACK_GARAGEDOOR_BAD ((UINT8)0x4E) /*Ź*/ +#define CI_BACK_GARAGEDOOR_TIMEOUT ((UINT8)0x5B) /*Ŷʱ*/ +#define CI_BACK_WASH_LINE_ALLOW_NOT ((UINT8)0x72) /*ϴδͬϴ*/ +#define CI_BACK_OTHER_ROUTE_NOT_OPEN ((UINT8)0x9D) /*·迪Ž·δ*/ +#define CI_BACK_WASH_PASS_ALLOW_NOT ((UINT8)0x9E) /*ϴ/δͬͨ*/ + +/* ȡιгռ÷ */ +#define CI_BACK_SPE_TRAIN_DIR_ERR ((UINT8)0x86) /*ιϳռãѴڵĹϳһ*/ +#define CI_BACK_SPE_LOOK_DIR_ERR ((UINT8)0x87) /*ιϳռãշһ*/ +#define CI_BACK_SPE_OTHER_CT ((UINT8)0x88) /*ιϳռãͨų*/ +#define CI_BACK_SPE_DISCONTINUITY ((UINT8)0x89) /*ιϳռã˹ϵ*/ +#define CI_BACK_CPE_TRAIN_ID_ERR ((UINT8)0x8a) /*ιϳռãڸóгID*/ +#define CI_BACK_CPE_PHYSEC_ID_ERR ((UINT8)0x8b) /*ιϳռãID*/ + + +#define CI_BACK_LGC_SEC_XIANSU_SET ((UINT8)0x8c) /*߼ʱٹرź*/ + + +/*Ϣ*/ + +/*Ϸ*/ +#define CI_BACK_FLOOD_GATE_CLOSE ((UINT8)0x76) /*㣺Źر*/ +#define CI_BACK_FLOOD_GATE_REQ_CLOSE ((UINT8)0xA0) /*㣺ر*/ +#define CI_BACK_FLOOD_ALLOW_CLOSE ((UINT8)0xA1) /*㣺ͬر*/ + +#define CI_BACK_COMM_CI_GOOD ((UINT8)0x7a) /*̵ӿʧܣͨŶ*/ + +#define CI_BACK_CIPSC_GOOD ((UINT8)0x7b) /*CIPSCִͨATSվ̨Żȷ*/ + +#define CI_BACK_PSC_NO_CONFIRM ((UINT8)0x7c) /*PSCδATSȷִȡ*/ + +#define CI_BACK_LEU_CHANNEL_SWITCH_FAULT ((UINT8)0x4c) /* LEU-CIͨͨлϱ */ +#define CI_BACK_LEU_ALL_STATE__FAULT ((UINT8)0x4d) /* LEU-CIͨ״̬ϱ */ + +#define CI_BACK_GARDOOR_NOT_RECV_ZC_GMXK ((UINT8)0x4f) /* ŹرδյZCظر */ + +/*ʱ*/ +#define CI_BACK_COUNT_LEAD ((UINT8)0x51) /*źŹϵʱ*/ +#define CI_BACK_COUNT_ZONGRENJIE ((UINT8)0x52) /*˽⵹ʱֽ*/ +#define CI_BACK_COUNT_SECFAULT ((UINT8)0x53) /*ʽ⵹ʱ*/ +#define CI_BACK_COUNT_CANCEL_NONROUTE ((UINT8)0x54) /*ȡǽ·*/ +#define CI_BACK_COUNT_OVERLAP_UNLOCK ((UINT8)0x55) /*νʱֽ*/ +#define CI_BACK_COUNT_OVERLAP_UNLOCK_HIGH ((UINT8)0x5d) /*νʱֽ*/ +#define CI_BACK_COUNT_ZONGRENJIE_HIGH ((UINT8)0x5e) /*˽⵹ʱֽ*/ +#define CI_BACK_COUNT_ZFWJ_VALID ((UINT8)0x75) /*ܸλ̵Чʱ*/ +#define CI_BACK_COUNT_FLOODGATE_CLOSE ((UINT8)0x90) /*Źرյʱֽ*/ +#define CI_BACK_COUNT_FLOODGATE_CLOSE_HIGH ((UINT8)0x91) /*Źرյʱֽ*/ + +#define CI_BACK_TRAIN_DOOR_STATE ((UINT8)0x61) /*гͨ״̬*/ + +#define CI_BACK_TRAIN_TEST_OFF ((UINT8)0x62) /*δԳģʽЧ*/ +#define CI_BACK_DCTY_REOPEN_TIMEOUT ((UINT8)0x63) /*·XXȴͬⳬʱ*/ +#define CI_BACK_FLOOD_GATE_YGJ_CROSS_LINE ((UINT8)0x64) /*YGJ*/ + +#define CI_BACK_ROUTE_END_SIGNAL_REDBREAK ((UINT8)0x77) /*·նźŻ˿*/ + +#define CI_BACK_DCTY_NOT_SATISFY ((UINT8)0x78) /*ͬ*/ +#define CI_BACK_DCTY_REOPEN_TIMING_BREAK ((UINT8)0x79) /*㣬ͬؿʱж*/ + +/**/ +#define CI_BACK_FIRSTORDER_OUTTIME ((UINT8)0x7d) /*һյʱ*/ +#define CI_BACK_ORDER_REPEAT ((UINT8)0x70) /*յϢ*/ + +/*Ч*/ +#define CI_BACK_INVALID_CMD ((UINT8)0x71) /*յЧ*/ + +/*OC忨ϵ*/ +#define CI_BACK_OC_BOARD_SWAPSYS (UINT8)0x86 /*OC忨ϵ*/ + +/*ϵͳϷ*/ +#define CI_BACK_SYSTEM_SIGNAL_OPEN ((UINT8)0x00) /* δźŻ */ +#define CI_BACK_SYSTEM_EXCEPT ((UINT8)0x00) /* ϵͳ״̬쳣 */ +#define CI_BACK_STARTLOCKE_ERROR ((UINT8)0x00) /* ϵʧ */ +#define CI_BACK_REL_UPDATA_ERROR ((UINT8)0x00) /* ̵ʧ */ +#define CI_BACK_SIG_UPDATA_ERROR ((UINT8)0x00) /* źŻʧ */ +#define CI_BACK_SEC_UPDATA_ERROR ((UINT8)0x00) /* θʧ */ +#define CI_BACK_SWT_UPDATA_ERROR ((UINT8)0x00) /* ʧ */ + + + + +#define CI_BACK_DATA_INFO_TYPE_ERR ((UINT8)0xf1) /* CIϵͳݽӿϢʹ */ +#define CI_BACK_DATA_SEND_FLAG_ERR ((UINT8)0xf2) /* CIϵͳݷͷʶϢ */ +#define CI_BACK_DATA_RECV_FLAG_ERR ((UINT8)0xf3) /* CIϵͳݽշ־Ϣ */ +#define CI_BACK_DATA_MSG_BDS_SN_ERR ((UINT8)0xf4) /* CIϵͳݱԷյһϢʱкŴ */ +#define CI_BACK_DATA_MSG_SN_ERR ((UINT8)0xf5) /* CIϵͳݶԷϢкżյһϢʱкŴ */ +#define CI_BACK_DATA_PROTOCOL_VER_ERR ((UINT8)0xf6) /* CIϵͳЭ汾Ŵ */ +#define CI_BACK_DATA_APP_LEN_ERR ((UINT8)0xf7) /* CIϵͳӦòݳЧ */ +#define CI_BACK_DATA_COM_PERIOD ((UINT8)0xf8) /* CIϵͳͨڴ */ +#define CI_BACK_DATA_VER_CHECK_FAIL ((UINT8)0xfe) /* CIϵͳݰ汾Уʧ */ +/*Ӧ*/ +#define RESPONSE_FIRST ((UINT8)0xAA) /*һȷӦ*/ +#define RESPONSE_SECOND ((UINT8)0xBB) /*ȷӦ*/ +/*ȷϽ*/ +#define AFFIRM_SUCCESS ((UINT8)0x55) /*ȷϳɹ*/ +#define AFFIRM_FAIL ((UINT8)0xAA) /*ȷʧ*/ + +#define CI_BACK_COUNT_HALF_SECUNLO ((UINT8)0x8D) /*ؽ·ʽ⵹ʱֽ*/ +#define CI_BACK_COUNT_HALF_SECUNLO_HIGH ((UINT8)0x8E) /*ؽ·ʽ⵹ʱֽ*/ + +#define CI_BACK_COMMON_ROUTE_SET ((UINT8)0x8F) /*·Ѱ*/ + +/*ԶԽ·Ϸ*/ +#define CI_BACK_AUTO_ROUTE_DICHU_ROUTE_SET ((UINT8)0x94) /*ִԶͨ·Ѱ*/ +#define CI_BACK_AUTO_RETURN_DICHU_ROUTE_SET ((UINT8)0x97) /*ִԶ۷··Ѱ*/ +#define CI_BACK_ALLAUTO_RETURN_DICHU_ROUTE_SET ((UINT8)0x9A) /*ִȫԶ۷··Ѱ*/ + +#define CI_BACK_AUTO_ROUTE_HAVE_BLOCK ((UINT8)0x95) /*Զͨ·Զ·ڷ*/ +#define CI_BACK_AUTO_ROUTE_FLOOD_STATE_ERR ((UINT8)0x96) /*Զͨ·ڷŲ*/ + + +#define CI_BACK_AUTO_RETURN_HAVE_BLOCK ((UINT8)0x98) /*Զ۷·ڷ*/ +#define CI_BACK_AUTO_RETURN_FLOOD_STATE_ERR ((UINT8)0x99) /*Զ۷·ڷŲ*/ + + +#define CI_BACK_ALLAUTO_RETURN_HAVE_BLOCK ((UINT8)0x9B) /*ȫԶ۷·ڷ*/ +#define CI_BACK_ALLAUTO_RETURN_FLOOD_STATE_ERR ((UINT8)0x9C) /*ȫԶ۷·ڷŲ*/ + + + +#endif + + diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackAtsData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackAtsData.c new file mode 100644 index 0000000..5e63b4d --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackAtsData.c @@ -0,0 +1,2673 @@ +/******************************************************** +* +* ParseAtsData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* ATSݽ +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackAtsData.h" +#include "../DataManage/DeviceConfigDataManage.h" +#include "ParsePackPSCData.h" +#include "ParsePackOcData.h" +#include "dsuRssp2Func.h" +#include "dquCIInterFace.h" +#include "../IO/OutputDataProcess.h" +#include "EnvelopeManageAPI.h" +#include "../DataManage/PlatDataManage.h" + +/*ʹ*/ +CommandDataStruct CiRevCmdDataStru[ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX] = {0u}; /*CIṹ*/ +UINT16 CiRevCmdStruCurSum = 0u; /*CIṹ鳤*/ +/*ʹ*/ +CommandDataStruct ATSorXDToCiCmdRtnToTRDataStru[ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX] = {0u}; /*ATSֵصCIźؿṹ*/ +UINT16 ATSorXDToCiCmdReturnToTRCurSum = 0u; /*ATSֵصCIźؿṹ鳤*/ + +/*ʹ*/ +CommandDataStruct CiSendCmdDataStru[CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX] = {0u}; /*CIṹ*/ +UINT16 CiSendCmdStruCurSum = 0u; /*CIṹ鳤*/ +/*ݴ淴*/ +CommandDataStruct CiSendBackDataTempStru[CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX] = {0u}; /*CIʱ*/ +UINT16 CiSendBackDataTempStruSum = 0u; /*CIṹʱ鳤*/ + +/*һβԴϵͳ*/ +UINT8 LastCmdSourceSysType = 0u; + +/*״βȷϵID*/ +UINT32 FirstCmdId; /*״βȷϵID*/ + +PSCToCiDataStruct* pscCiSendToAtsDataStru = NULL; + +/* +* CiAts߼Ϣ +* ˵ const UINT8* pDataBuf, ݻ +* const UINT16 *wDataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToAtsLgcSgmtInfo(UINT8* pDataBuf, UINT16* wDataLength); + + +/* +* תCiATSOCbyte˫ϵԴ״̬Ϣ +* ˵ +* UINT8 PowerState, Դ״̬ +* +* +* ֵ תĵԴ״̬ +*/ +static UINT8 TransCiToAtsPowerState(UINT8 PowerState); + +/* +* תCiATSOCbyte״̬Ϣ +* ˵ +* UINT8 fanState, ״̬ +* +* +* ֵ תķ״̬ +*/ +static UINT8 TransCiToAtsFanState(UINT8 fanState); + +/* +* תCiATSOCbyte豸״̬Ϣ +* ˵ +* UINT8 ocDevFaultState, OC豸״̬ +* +* +* ֵ ת豸״̬ +*/ +static UINT8 TransCiToAtsOcDevFaultState(UINT8 ocDevFaultState); + +/* +* תCiATSPSC ״̬ʾ״̬Ϣ +* ˵ +* UINT8 ciToXianDiData, CIֵϢ +* UINT8 MoveNum λ +* UINT8 PscState psc״̬ʾ״̬ +* +* +* ֵ ת +*/ +static UINT8 TransCiToAtsPSCWorkState(UINT8 ciToXianDiData, UINT8 MoveNum, UINT8 PscState); + +/* +* תCiATSPSC ״̬ʾϢ +* ˵ +* UINT8 ciToXianDiData, CIֵϢ +* UINT8 MoveNum λ +* UINT8 PscState psc״̬ʾ״̬ +* UINT8 BitValY ifҪƵĺֵ +* UINT8 BitValN ifҪƵĺֵ +* +* +* ֵ ת +*/ +static UINT8 TransCiToAtsPSCState(UINT8 ciToXianDiData, UINT8 MoveNum, UINT8 PscState, UINT8 BitValY, UINT8 BitValN); + +/* +* תCiATSPSC ״̬Ϣ +* ˵ +* UINT8 ciToXianDiData, CIֵϢ +* UINT8 MoveNum λ +* UINT8 PscStatetype psC״̬Ӧ +* UINT8 PscState pscӦ״̬ +* UINT8 BitValY ifҪƵĺֵ +* UINT8 BitValN ifҪƵĺֵ +* +* +* ֵ ת +*/ +static UINT8 TransCiToAtsPSCtypeState(UINT8 ciToXianDiData, UINT8 MoveNum, UINT8 PscStatetype, UINT8 PscState, UINT8 BitValY, UINT8 BitValN); + + +/* +* ֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +* ޸bug YF0083-210 +*/ +UINT8 ParseAtsOrXianDiToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength) +{ + UINT8 sourceId = 0u; /*ԴID*/ + UINT8 sourceType = 0u; /*Դϵͳ*/ + UINT8 targetId = 0u; /*ĿID*/ + UINT8 targetType = 0u; /*Ŀϵͳ*/ + UINT32 systemTimeH = 0u; /*ϵͳʱ4ֽ*/ + UINT32 systemTimeL = 0u; /*ϵͳʱ4ֽ*/ + UINT16 commandTotalLen = 0u; /*ܳ*/ + UINT16 commandTotalSum = 0u; /**/ + UINT8 commandLenth = 0u; /**/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT16 dwIndex = 0u; + UINT32 dataCheckInfo = 0u; /*ݰ汾УϢ*/ + UINT32 interfacePrtclVer = 0u; /*ӿЭ汾ʱԤ*/ + UINT32 emapCrcInfo = 0u; + UINT8 localCiId = 0u; + UINT8 ciEmapCheck = 0u; + UINT8 systemtype = 0u; + UINT8 chRetVal = CI_ERROR; + UINT8 chKeepWork = CI_ERROR; + UINT16 preAtsRouteSteCmdNum = 0u; /*ATS·*/ + UINT16 wCmdStartByteNum = 0u;/*У*/ + UINT16 wParseCmdLength = 0u; + UINT8 chLogicSecIndex = 0u; + UINT32 dwHlhtTrainId = 0u;/*ͨг*/ + UINT16 wTrainId = 0;/*гID ֽֽͣڱ*/ + UINT16 logId = 0;/*vobcʱʹö˱ 1-TC1 2-TC2 0-2IPβ೵*/ + UINT8 chCmdType = 0u; + UINT32 dwCmdParam = 0u; + UINT32 dwCmdId = 0u; + UINT16 wTerminalId = 0u; + UINT8 chVirCi = 0u; + UINT8 chLogSecNum = 0u; + UINT8 chToaCmdNum = 0u; + UINT32 dwCmdParam_DevID = 0u; + UINT16 dwCmdParam_Type = 0u; + UINT8 dwCmdParam_Param = 0u; + UINT16 oVerlap_RouteId = 0U; + + if ((NULL!= dataBuf) && (0u < dataLength)) + { + sourceType = dataBuf[ii++]; /*ȡݰԴ豸*/ + sourceId = dataBuf[ii++]; /*ȡݰԴ豸ID*/ + targetType= dataBuf[ii++]; /*ȡݰĿ豸*/ + targetId = dataBuf[ii++]; /*ȡݰĿ豸ID*/ + dataCheckInfo = LongFromChar(&dataBuf[ii]); /*ȡݰ汾УϢ4ֽ*/ + ii += 4u; + /*УϢȽ*/ + ciEmapCheck = GetCiEmapCheckVer(targetId,&emapCrcInfo,sourceType); + if (CI_SUCCESS == ciEmapCheck) + { + chRetVal = CI_SUCCESS; + chKeepWork = CI_SUCCESS; + + if (dataCheckInfo != emapCrcInfo) + { +#if 0 + /*ATSֵطݰ汾УʧϢ*/ + if ((CI_SYSTEM_TYPE_XIANDI == sourceType) || ((CI_SYSTEM_TYPE_ATS == sourceType))) + { + SetCiSendCmdBackInfoData(CI_BACK_DATA_VER_CHECK_FAIL, sourceType, sourceId, 0, 0); + } +#endif + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + if (CI_ERROR != chRetVal) + { + interfacePrtclVer = LongFromChar(&dataBuf[ii]); /*ȡӿЭ汾Ϣ4ֽ*/ + ii += 4u; + systemTimeH = LongFromChar(&dataBuf[ii]); /*ȡϵͳʱ4ֽ*/ + ii += 4u; + systemTimeL = LongFromChar(&dataBuf[ii]); /*ȡϵͳʱ4ֽ*/ + ii += 4u; + commandTotalLen = ShortFromChar(&dataBuf[ii]); /*ȡݰܳ*/ + ii += 2u; + + localCiId = GetSystemParaLocalCiId(); + systemtype = Get2oo2SheBeiType(); + if ((targetType != systemtype) || (targetId != localCiId) + || ((CI_SYSTEM_TYPE_XIANDI != sourceType) && (CI_SYSTEM_TYPE_ATS != sourceType))) + {/*ݲϷ*/ + + chKeepWork = CI_ERROR; + } + + if (0u == commandTotalLen) + {/**/ + + chKeepWork = CI_ERROR; + } + + if (CI_ERROR != chKeepWork) + { + commandTotalSum = ShortFromChar(&dataBuf[ii]); /*ȡݰ֡*/ + ii += 2u; + if ((0u == commandTotalSum) || (ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX < commandTotalSum)) + {/*Ϊ0*/ + + chRetVal = CI_ERROR; + } + else + { + /** ܳȵЧ*/ + chRetVal = CheckATSorXiandTotalDataLenVal(&dataBuf[ii], commandTotalSum, commandTotalLen); + + } + + if (CI_ERROR != chRetVal) + { + /*ȻȡһǴ洢·*/ + preAtsRouteSteCmdNum = GetCiRevCmdStruCurSum(); + /**/ + for (jj = preAtsRouteSteCmdNum; jj < (commandTotalSum + preAtsRouteSteCmdNum); jj++) + { + /*ȫ*/ + if (ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX > jj) + { + commandLenth = dataBuf[ii++];/*ȡ*/ + wCmdStartByteNum = ii; /*Ȳȱ*/ + chCmdType = dataBuf[ii++]; /*ȡ*/ + dwCmdId = LongFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 4u; + dwCmdParam = LongFromChar(&dataBuf[ii]);/*ȡ*/ + ii += 4u; + wTerminalId = ShortFromChar(&dataBuf[ii]);/*ȡնID*/ + ii += 2u; + + oVerlap_RouteId = ShortFromChar(&dataBuf[ii]);/*ȡι·ID*/ + ii += 2U; + + /*Ԥ*/ + ii += 2U; + chVirCi = dataBuf[ii++];/*ID*/ + /*Ԥ*/ + ii++; + + /*¼*/ + dwHlhtTrainId = LongFromChar(&dataBuf[ii]); + ii += 4u; + (void)dquHlhtId2VobcName(dwHlhtTrainId, &wTrainId, &logId);/*4ֽڻͨת2ֽ*/ + + chLogSecNum = dataBuf[ii++];/*߼*/ + /*š豸IDз*/ + dwCmdParam_DevID = dwCmdParam & 0xffff0000u; + dwCmdParam_Type = (UINT16)(dwCmdParam & 0x0000ff00u); + dwCmdParam_Param = (UINT8)(dwCmdParam & 0x000000ffu); /*ӷYF0083-227ȱ޸*/ + if ((0xffffffffu == dwCmdId) || (0xffff0000u == dwCmdParam_DevID)|| + (0x0000ff00u == dwCmdParam_Type)||(0x000000ffu == dwCmdParam_Param)) + { + chRetVal = CI_ERROR; + } + else + { + if ((ATS_CMD_SET_PHYSEC_ERR == chCmdType) + || (ATS_CMD_CANCEL_PHYSEC_FIRST == chCmdType) + || (ATS_CMD_CANCEL_PHYSEC_SECOND == chCmdType) + || (ATS_CMD_TOA_RESET_FIRST == chCmdType) + || (ATS_CMD_TOA_RESET_SECOND == chCmdType)) + { + chToaCmdNum++; + chRetVal = ToaAddCmd(chCmdType, wTrainId, dwCmdId, wTerminalId, chVirCi, dwCmdParam); + if ((CI_SUCCESS == chRetVal) && (0u != chLogSecNum)) + { + chRetVal = CI_ERROR; + } + else + { + ; + } + } + else + { + CiRevCmdDataStru[jj].CommandType = chCmdType; /*ȡ*/ + CiRevCmdDataStru[jj].CommandId = dwCmdId; /*ȡ*/ + CiRevCmdDataStru[jj].CommandParam = dwCmdParam;/*ȡ*/ + CiRevCmdDataStru[jj].termial_id = wTerminalId;/*ȡնID*/ + CiRevCmdDataStru[jj].VirCIid = chVirCi;/*ID*/ + CiRevCmdDataStru[jj].wTrainIdParam = wTrainId; /* гID*/ + CiRevCmdDataStru[jj].OverLapRouteID = oVerlap_RouteId; /* ι·ID*/ + + CiRevCmdDataStru[jj].chLogicSecSum = chLogSecNum;/*߼*/ + if (MAX_ROUTE_IN_LT_NUM > CiRevCmdDataStru[jj].chLogicSecSum) + { + for (chLogicSecIndex = 0u; chLogicSecIndex < CiRevCmdDataStru[jj].chLogicSecSum; chLogicSecIndex++) + { + CiRevCmdDataStru[jj].wLogicSecData[chLogicSecIndex] = ShortFromChar(&dataBuf[ii]);/*߼ID*/ + ii += 2u; + } + } + else + { + /*Խ*/ + chRetVal = CI_ERROR; + } + } + } + if (CI_SUCCESS == chRetVal) + { + /*У*/ + wParseCmdLength = (UINT16)(ii - wCmdStartByteNum); + if (commandLenth != wParseCmdLength) + {/*ȳ*/ + chRetVal = CI_ERROR; + + } + else + { + chRetVal = CI_SUCCESS; + } + } + else + { + ; + } + + if (CI_ERROR == chRetVal) + {/*ݴ󣬶*/ + /*Ȿ*/ + ToaClearCmd(); + commandTotalSum = 0u; + for (dwIndex = preAtsRouteSteCmdNum; dwIndex <= jj; dwIndex++) + { + (void)CommonMemSet(&CiRevCmdDataStru[dwIndex], (UINT32)sizeof(CommandDataStruct), 0u, (UINT32)sizeof(CommandDataStruct)); + } + break; + } + else + { + /*޲*/ + } + + } + } + + /**/ + if (CI_SUCCESS == chRetVal) + { + CiRevCmdStruCurSum = commandTotalSum - chToaCmdNum + preAtsRouteSteCmdNum;/**/ + } + else + { + CiRevCmdStruCurSum = preAtsRouteSteCmdNum;/*ֻ¼ڴ洢*/ + } + + + if (dataLength < ii) + { + CiRevCmdStruCurSum = 0u; + chRetVal = CI_ERROR; + } + else + { + /*޲*/ + } + + LastCmdSourceSysType = sourceType;/*һβԴϵͳ*/ + } + + } + + } + + } + else + { + /*Ч*/ + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ATSֵ +* ˵ QueueStruct* ciToAtsDataQueue, Ͷеַ +* const UINT8 deviceId, ĿϵͳID +* const UINT8 targetDevType, Ŀϵͳ +* const UINT8 frame,֡ +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 PackCiToAtsOrXianDiData(const UINT8 deviceId, const UINT8 targetDevType, const UINT8 frame) +{ + UINT8 localCi = 0u; /*ID*/ + UINT8 ciToXianDiDataBuffer[CI_TO_ATS_DATA_LEN_MAX] = { 0u }; /*CIֵ֡*/ + UINT16 SendMaskSum = 0u; /*λֽ*/ + UINT16 indicatorId = 0u; /*ʾƱID*/ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT8 kk = 0u; /*α*/ + UINT16 m = 0u; + UINT8 n = 0u; + UINT8 mm = 0U; /*ִеα*/ + UINT16 curIndex = 0u; /*α*/ + UINT8 pscId = 0u; + + UINT8 transmitState = 0u; + UINT8 pscConfirmFlag = 0u; + + UINT32 emapCrcInfo = 0u; /*ݰ汾УCRCϢ*/ + UINT32 interfacePrtclVer = 0u; /*ӿЭ汾ʱԤ*/ + UINT16 deviceSum = 0u; /*豸*/ + UINT8* pDeviceIdBuf = NULL; /*豸ID*/ + + UINT16 ocDeviceSum = 0u;/*OC豸*/ + UINT8* pOcDeviceIdBuf = NULL; /*OC豸ID*/ + UINT16 ocId = 0u; + UINT8 powerAState = 0u;/*AϵԴ״̬0x55-˫·տ0xaa-·տ쳣0xFF-˫·տ쳣*/ + UINT8 powerBState = 0u;/*BϵԴ״̬0x55-˫·տ0xaa-·տ쳣0xFF-˫·տ쳣*/ + UINT8 ocDevFaultState = 0u;/*OC豸״̬0x55-忨0xFF-忨*/ + UINT8 fanState = 0u; + UINT8 ciAndOcCommState = 0u;/*ciOCͨ״̬*/ + UINT32 curCycleNum = 0u;/*ǰ*/ + UINT8 psdSum = 0u; + UINT8 psdMutualLockState = 0u; + UINT8 psdCiId = 0u; + UINT8 emapCheckState = 0u; + PSCToCiDataStruct* pscToCiDataStru = GetPscToCiDataStru(); + UINT8 virtualCiNum = 0u; + UINT8 virtualCIid = 0u; + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 indicatorState = 0u; + UINT16 indicatorNum = 0u; + UINT8 i = 0u; + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + UINT8 cTiocMode = REVERSE_MODE_SHADOW; + UINT8 cTiocCutReason = 0u; + UINT8 cTiocCutState = REVERSE_CUT_STATE_DEFAULT; + UINT32 dwTrainId = 0u; + UINT8 cLogId = 0u; + UINT8 cFunRetVal = CI_ERROR; + UINT8 ocstionPowerIndic = 0U; + + UINT8 indicatorDevId = 0U; + UINT16 szEnvelopeIdBuf[ENVELOPE_SUM_MAX] = { 0u }; + UINT16 wEnvelopeSum = 0u; + UINT16 wcomTrainSumIndex = 0u; /*ͨų*/ + UINT16 comTrainSum = 0U; /*ͨųʼΪ0*/ + UINT16 wEnvelopeIndex = 0u; /**/ + InfEnvelopeStruct strEnvelope = { 0u }; /*Ϣؽṹ*/ + UINT16 wEnvelopeId = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT32 dwHLHTTrainID = 0u; /*гͨID*/ + UINT8 chHeadScreStat = 0u; /*гǰɸ־*/ + UINT8 chTailScreStat = 0u; /*гɸ־*/ + UINT8 chVirHeadScreStat = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гǰɸ־*/ + UINT8 chVirTailScreStat = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гɸ־*/ + UINT16 wTrainId = 0u; /*гID*/ + UINT8 chRetVal = CI_ERROR; + UINT8 indicatorType = 0u; /*豸*/ + + UINT8 wPbNum = 0u; /*ִе*/ + UINT8 hlhtIdFlag = 0U; /*ͨIDǷЧ*/ + OcToATSPlusBox szSendATSPlusBox[MAX_OC_PLUS_BOX_NUM] = { 0U }; /*ATSִеṹϢ*/ + UINT16 wDjqySwitchNum = 0U; /*ǣ*/ + OcToATSSwitchZzjData szSendAtsSwitchZzjData[SWITCH_SUM_MAX] = { 0U }; /*ATSĵӦת޻Ϣ*/ + UINT16 wDjqySwitchIndex = 0U;/*ǣ*/ + UINT8 chSwitchZzjStateIndex = 0U;/*ǣӦת޻״̬*/ + + UINT8 powerANodeState = 0U;/*AϵԴ״̬*/ + UINT8 powerBNodeState = 0U;/*BϵԴ״̬*/ + UINT8 ModeAState = 0U;/*AϵԴģ״̬*/ + UINT8 ModeBState = 0U;/*BϵԴģ״̬*/ + + + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + pscCiSendToAtsDataStru = GetPscToCiDataStru(); /*ȡPsc-CIĽṹ*/ + + curCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + + if (CI_ATS_STATION_FRAME == frame) + { + /*ʼӦ֡*/ + ciToXianDiDataBuffer[ii++] = CI_ATS_STATION_FRAME; /*վ״̬֡*/ + ciToXianDiDataBuffer[ii++] = Get2oo2SheBeiType();/*Ͷ豸ID豸*/ + ciToXianDiDataBuffer[ii++] = localCi; + + ciToXianDiDataBuffer[ii++] = targetDevType; /*ն豸ID豸*/ + ciToXianDiDataBuffer[ii++] = deviceId; + + emapCheckState = GetCiEmapCheckVer(localCi, &emapCrcInfo, targetDevType); + if (CI_SUCCESS == emapCheckState) + { + LongToChar(emapCrcInfo, &ciToXianDiDataBuffer[ii]); /*ݰ汾УCRCϢ*/ + ii += 4u; + } + else + { + ii += 4u; + } + LongToChar(interfacePrtclVer, &ciToXianDiDataBuffer[ii]); /*ӿЭ汾Ϣ*/ + ii += 4u; + + ShortToChar((UINT16)255, &ciToXianDiDataBuffer[ii]); + ii += 4u; /*ʱǰĸֽΪĬϷ*/ + + LongToChar(curCycleNum, &ciToXianDiDataBuffer[ii]); + ii += 4u; /*ʱĸֽΪCIں*/ + + + /*ʼӦ*/ + + if (0u == GetSendMaskSum(targetDevType) % 8u) + { + SendMaskSum = (UINT16)(GetSendMaskSum(targetDevType) / 8u); + } + else + { + SendMaskSum = (UINT16)(GetSendMaskSum(targetDevType) / 8u + 1u); + } + + curIndex = ii; + + ShortToChar(SendMaskSum, &ciToXianDiDataBuffer[ii]); /*վϢܳ*/ + ii += 2u; + + /*λϢ*/ + (void)MaskPack(targetDevType, &ciToXianDiDataBuffer[ii]); + ii = (UINT16)(ii + SendMaskSum); + + /*ͨгϢ*/ + chRetVal = CI_SUCCESS; + wEnvelopeSum = elm_GetAllEnvelope(szEnvelopeIdBuf); /*ȡеİϢ*/ + wcomTrainSumIndex = ii; + ii += 2U; + if (ENVELOPE_SUM_MAX > wEnvelopeSum) + { + for (wEnvelopeIndex = 0U; wEnvelopeIndex < wEnvelopeSum; wEnvelopeIndex++) + { + wEnvelopeId = szEnvelopeIdBuf[wEnvelopeIndex]; /*ȡID*/ + chFunRtn = elm_ConvertEnvelopeInfo(wEnvelopeId, &strEnvelope); + if (CI_SUCCESS == chFunRtn) + {/*Ϣȡɹ*/ + /*ͨų*/ + if (TYPE_CT_ENVELOPE == strEnvelope.envelopeType) + { + comTrainSum++; + wTrainId = 0x1400u + (strEnvelope.trainID[0] & 0x00FFu); + hlhtIdFlag = dquDevName2HlhtId(wTrainId, 0u, &dwHLHTTrainID); /*ֽгIDתΪ4ֽڻͨID*/ + if (hlhtIdFlag == CI_SUCCESS) + {/*ͨIDѯɹ*/ + LongToChar(dwHLHTTrainID, &ciToXianDiDataBuffer[ii]); /* гID */ + ii += 4u; + } + else + { /*ʧ*/ + chRetVal = CI_ERROR; + } + + /*ǰɸ*/ + chHeadScreStat = strEnvelope.suspicHead; + chVirHeadScreStat = GetTrainVirHeadScreenPassFlag(wTrainId); + if ((CI_IVOC_HEAD_SCREEN_PASS == chHeadScreStat) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chVirHeadScreStat)) + { + /*ǰɸ״̬Ч*/ + ciToXianDiDataBuffer[ii] = CI_IVOC_HEAD_SCREEN_PASS; + ii += 1U; + } + else if ((CI_IVOC_HEAD_SCREEN_UNKNOW == chHeadScreStat) && (TRAIN_VIR_SCREEN_PASS_FLAG_INVALID == chVirHeadScreStat)) + { + /*ǰɸ״̬Ч*/ + ciToXianDiDataBuffer[ii] = CI_IVOC_HEAD_SCREEN_UNKNOW; + ii += 1U; + } + else + { + chRetVal = CI_ERROR; + } + + /*ɸ*/ + chTailScreStat = strEnvelope.suspicTail; + chVirTailScreStat = GetTrainVirTailScreenPassFlag(wTrainId); + if ((CI_IVOC_TAIL_SCREEN_PASS == chTailScreStat) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chVirTailScreStat)) + { + /*ɸ״̬Ч*/ + ciToXianDiDataBuffer[ii] = CI_IVOC_TAIL_SCREEN_PASS; + ii += 1U; + } + else if ((CI_IVOC_TAIL_SCREEN_UNKNOW == chTailScreStat) && (TRAIN_VIR_SCREEN_PASS_FLAG_INVALID == chVirTailScreStat)) + { + /*ɸ״̬Ч*/ + ciToXianDiDataBuffer[ii] = CI_IVOC_TAIL_SCREEN_UNKNOW; + ii += 1U; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /* ִ*/ + } + } + else + { + /*ID*/ + chRetVal = CI_ERROR; + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /*гϢִ*/ + } + ShortToChar(comTrainSum, &ciToXianDiDataBuffer[wcomTrainSumIndex]); + + /*ָʾ״̬*/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + virtualCiNum = GetVirtualCINum(); + ciToXianDiDataBuffer[ii++] = virtualCiNum;/**/ + for (kk = 0u; kk < virtualCiNum; kk++) + { + virtualCIid = GetVirtualCIid(kk); + ciToXianDiDataBuffer[ii++] = virtualCIid;/*ID*/ + /*ʾƱϢ*/ + indicatorNum = (UINT8)GetVirCIIndicatorConfigDataNum(virtualCIid); + ShortToChar(indicatorNum, &ciToXianDiDataBuffer[ii]);/*ʾƱ*/ + ii += 2u; + for (i = 0u; i < indicatorNum; i++) + { + indicatorId = GetVirCIlocalCiIndicatorId(virtualCIid, i); /*ʾƱƷ*/ + indicatorType = GetVirCIIndicatorType(virtualCIid, (UINT8)indicatorId); /*ȡ豸*/ /*ԭֱõڸΪIDҪתΪͼ*/ + indicatorState = GetVirCIIndicatorState(virtualCIid, (UINT8)indicatorId); /*ʾƱ״̬*/ + indicatorDevId = GetVirCIIndicatorDevId(virtualCIid, (UINT8)indicatorId); /*ʾƱID*/ + ciToXianDiDataBuffer[ii++] = indicatorType; + ciToXianDiDataBuffer[ii++] = indicatorDevId; + ciToXianDiDataBuffer[ii++] = indicatorState; + } + } + } + else + { + /*ʾƱϢ*/ + ciToXianDiDataBuffer[ii++] = 1u;/*ӿ*/ + ciToXianDiDataBuffer[ii++] = localCi; + indicatorNum = GetIndicatorCurSum(); + ShortToChar(indicatorNum, &ciToXianDiDataBuffer[ii]);/*ʾƱ*/ + ii += 2u; + for (jj = 0u; jj < indicatorNum; jj++) + { + indicatorId = GetIndicatorId(jj); + indicatorType = GetIndicatorType(indicatorId); /*ȡ豸*/ /*ԭֱõڸΪIDҪתΪͼ*/ + ciToXianDiDataBuffer[ii++] = indicatorType; /*ʾƱƷ*/ + indicatorDevId = GetIndicatorDevId(indicatorId); + ciToXianDiDataBuffer[ii++] = indicatorDevId;/*豸ID*/ + ciToXianDiDataBuffer[ii++] = GetIndicatorState(indicatorId);/*ʾƱ״̬*/ + } + } + + UpdataCiSendCmdBack_OrderBack();/**/ + if (1u > CiSendCmdStruCurSum) + { /*ȴ*/ + + ShortToChar(0, &ciToXianDiDataBuffer[ii]); /*֡ܳ*/ + ii += 2u; + } + else + { + curIndex = ii;/*֡ܳ*/ + ii += 2u; + + ShortToChar(CiSendCmdStruCurSum, &ciToXianDiDataBuffer[ii]); /*֡*/ + ii += 2u; + + for (jj = 0u; jj < CiSendCmdStruCurSum; jj++) + { + ciToXianDiDataBuffer[ii++] = 22u; /**/ + ciToXianDiDataBuffer[ii++] = CiSendCmdDataStru[jj].CommandType; /**/ + LongToChar(CiSendCmdDataStru[jj].CommandId, &ciToXianDiDataBuffer[ii]); /**/ + ii += 4u; + LongToChar(CiSendCmdDataStru[jj].CommandParam, &ciToXianDiDataBuffer[ii]); /**/ + ii += 4u; + ShortToChar(CiSendCmdDataStru[jj].termial_id, &ciToXianDiDataBuffer[ii]); /**/ + ii += 2u; + ciToXianDiDataBuffer[ii++] = CiSendCmdDataStru[jj].order_type; /**/ + ciToXianDiDataBuffer[ii++] = CiSendCmdDataStru[jj].response_type; /*Ӧ*/ + ciToXianDiDataBuffer[ii++] = CiSendCmdDataStru[jj].affirm_result; /*ȷϽ*/ + ciToXianDiDataBuffer[ii++] = CiSendCmdDataStru[jj].firstCmd_time; /*һεʱ*/ + ciToXianDiDataBuffer[ii++] = CiSendCmdDataStru[jj].VirCIid; /*ID*/ + ciToXianDiDataBuffer[ii++] = CiSendCmdDataStru[jj].OCid; /*OC ID*/ + + if (0u != CiSendCmdDataStru[jj].wTrainIdParam) + { + cLogId = (UINT8)(CiSendCmdDataStru[jj].wTrainIdParam & 0xFFu); + cFunRetVal = dquDevName2HlhtId(CiSendCmdDataStru[jj].wTrainIdParam, cLogId, &dwTrainId); + if (CI_ERROR == cFunRetVal) + { + cLogId = 0u; + dwTrainId = 0u; + } + else + { + ; + } + } + else + { + cLogId = 0u; + dwTrainId = 0u; + } + LongToChar(dwTrainId, &ciToXianDiDataBuffer[ii]); + ii += 4u; + + ciToXianDiDataBuffer[ii++] = 0u;/*߼*/ + } + + ShortToChar((UINT16)(ii - curIndex - 2U), &ciToXianDiDataBuffer[curIndex]); /*֡ܳ*/ + +#if 0 + /**/ + ClearCiSendCmdData(); +#endif + } + + /* ߼εϢ*/ + (void)PackCiToAtsLgcSgmtInfo(ciToXianDiDataBuffer, &ii); + + /* ģʽϢ */ + cTiocMode = GetTiocSystemMode(); + if (REVERSE_MODE_MAIN == cTiocMode) + { + /* ģʽ */ + ciToXianDiDataBuffer[ii] = 0x55; + } + else + { + /* Ӱģʽ */ + ciToXianDiDataBuffer[ii] = 0xAA; + } + ii++; + + ciToXianDiDataBuffer[ii] = GetTiocSystemCutState(); + ii++; + + /* ɵԭ */ + cTiocCutReason = GetTiocCanntCutReason(); + ciToXianDiDataBuffer[ii] = cTiocCutReason; + ii++; + + ii += 40u; + } + else + { + } + + /*豸״̬֡*/ + if (CI_ATS_DEVICE_STATE_FRAME == frame) + { + /*豸֡*/ + ciToXianDiDataBuffer[ii++] = CI_ATS_DEVICE_STATE_FRAME; /*豸״̬֡*/ + ciToXianDiDataBuffer[ii++] = Get2oo2SheBeiType();/*Ͷ豸ID豸*/ + ciToXianDiDataBuffer[ii++] = localCi; + + ciToXianDiDataBuffer[ii++] = targetDevType; /*ն豸ID豸*/ + ciToXianDiDataBuffer[ii++] = deviceId; + + emapCheckState = GetCiEmapCheckVer(localCi, &emapCrcInfo, targetDevType); + if (CI_SUCCESS == emapCheckState) + { + LongToChar(emapCrcInfo, &ciToXianDiDataBuffer[ii]); /*ݰ汾УCRCϢ*/ + ii += 4u; + } + else + { + ii += 4u; + } + LongToChar(interfacePrtclVer, &ciToXianDiDataBuffer[ii]); /*ӿЭ汾Ϣ*/ + ii += 4u; + + ShortToChar((UINT16)255, &ciToXianDiDataBuffer[ii]); + ii += 4u; /*ʱǰĸֽΪĬϷ*/ + + LongToChar(curCycleNum, &ciToXianDiDataBuffer[ii]); + ii += 4u; /*ʱĸֽΪCIں*/ + + + deviceSum = (UINT16)GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PSC); /*ȡͨPSC豸*/ + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PSC); /*ȡͨPSC豸ID*/ + if (1u > deviceSum) + { /*PSC*/ + + ShortToChar(0u, &ciToXianDiDataBuffer[ii]); /*PSCܳ*/ + ii += 2u; + } + else + { + ShortToChar(deviceSum, &ciToXianDiDataBuffer[ii]); /*PSC*/ + ii += 2u; + + if (NULL != pDeviceIdBuf) + { /*ͨ豸ȷ*/ + for (jj = 0u; jj < deviceSum; jj++) + { + pscId = pDeviceIdBuf[jj]; /*ȡPSCID*/ + if (0u != pscId) + { + ciToXianDiDataBuffer[ii++] = 0u; /*PSCID*/ + ciToXianDiDataBuffer[ii++] = pscId; + + /*PSC Aϵ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCWorkState(ciToXianDiDataBuffer[ii], 6u, + pscCiSendToAtsDataStru[pscId].devType_PSC_A_WORK_STATE); + + /*PSC Bϵ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCWorkState(ciToXianDiDataBuffer[ii], 4u, + pscCiSendToAtsDataStru[pscId].devType_PSC_B_WORK_STATE); + + /*PSC ͨŰ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 2u, + pscCiSendToAtsDataStru[pscId].devType_PSC_SINGLE_COMM_STATE, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*PSC FSIO״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 0u, + pscCiSendToAtsDataStru[pscId].devType_PSC_FSIO_FAULT_STATE, BIT_VAL_00000011B, BIT_VAL_00000000B); + + ii++; + + /*PSC Դ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 6u, + pscCiSendToAtsDataStru[pscId].devType_PSC_DRIVE_POWER_STATE, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*PSC ƵԴ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 4u, + pscCiSendToAtsDataStru[pscId].devType_PSC_CONTROL_POWER_STATE, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*PSCӿģ1״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 2u, + pscCiSendToAtsDataStru[pscId].devType_PSC_Q_IM_1_STATE, BIT_VAL_00000001B, BIT_VAL_00000000B); + + /*PSCӿģ2״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 0u, + pscCiSendToAtsDataStru[pscId].devType_PSC_Q_IM_2_STATE, BIT_VAL_00000001B, BIT_VAL_00000000B); + + ii++; + /*PSC пŹ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 6u, + pscCiSendToAtsDataStru[pscId].devType_PSC_OPEN_FAULT_STATE_UP, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*PSC йŹ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 4u, + pscCiSendToAtsDataStru[pscId].devType_PSC_CLOSE_FAULT_STATE_UP, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*PSC пŹ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 2u, + pscCiSendToAtsDataStru[pscId].devType_PSC_OPEN_FAULT_STATE_DOWN, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*PSC йŹ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCState(ciToXianDiDataBuffer[ii], 0u, + pscCiSendToAtsDataStru[pscId].devType_PSC_CLOSE_FAULT_STATE_DOWN, BIT_VAL_00000011B, BIT_VAL_00000000B); + + ii++; + + transmitState = GetCiTransmitState(CI_SYSTEM_TYPE_PSC, pscId);/*ȡCIPSCͨ״̬*/ + pscConfirmFlag = GetPscConfirmFlag(pscId); /*ȡPSC·״̬*/ + /*·״̬*/ + + /*·״̬ת*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCtypeState(ciToXianDiDataBuffer[ii], 2u, pscConfirmFlag, + CI_PSC_PL_CONFIRM_YES, BIT_VAL_00000000B, BIT_VAL_00000001B); + + /*CIPSCͨ״̬ת*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPSCtypeState(ciToXianDiDataBuffer[ii], 0u, transmitState, + TRANSMIT_STATE_GOOD, BIT_VAL_00000001B, BIT_VAL_00000000B); + + ii++; + } + else + { + } + } + } + else + { + } + } + + ocDeviceSum = (UINT16)GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC); /*ȡͨOC豸*/ + pOcDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); /*ȡͨOC豸ID*/ + + ShortToChar(ocDeviceSum, &ciToXianDiDataBuffer[ii]); /*OCܳ*/ + ii += 2u; + + if (NULL != pOcDeviceIdBuf) + { + for (jj = 0u; jj < ocDeviceSum; jj++)/*ͨŵoc*/ + { + ocId = pOcDeviceIdBuf[jj]; /*ȡOC ID*/ + + powerAState = DUAL_WAY_AIR_SWITCH_ABNORMAL;/**/ + powerBState = DUAL_WAY_AIR_SWITCH_ABNORMAL;/**/ + ocDevFaultState = OC_CARD_ABNORMAL;/**/ + fanState = DUAL_WAY_AIR_SWITCH_ABNORMAL;/*ȹ*/ + wPbNum = 0U; /*OCǰֹͬһһOC*/ + + if (0U != ocId) + { + ShortToChar(ocId, &ciToXianDiDataBuffer[ii]); /*OCID*/ + ii += 2u; + + for (kk = 0u; kk < m_OcToCiOrginDataNum; kk++) + { + if (NULL != m_OcToCiOrginDataArr) + { + if (m_OcToCiOrginDataArr[kk].OcId == ocId)/*ͨţҵ͸ֵ*/ + { + powerAState = m_OcToCiOrginDataArr[kk].PowerAState; + powerBState = m_OcToCiOrginDataArr[kk].PowerBState; + ocDevFaultState = m_OcToCiOrginDataArr[kk].OCDevFaultState; + fanState = m_OcToCiOrginDataArr[kk].FanState; + + /*OCbyteִеӿת*/ + wPbNum = TransCiToAtsOCPlusBoxInfo(szSendATSPlusBox, &kk); + + /*by cgh 20230918 ǣת޻Ŀת*/ + wDjqySwitchNum = TransCiToAtsSwitchZzjInfo(szSendAtsSwitchZzjData, &kk); + } + else + { + + } + } + else + { + } + } + /*תAϵԴ״̬*/ + powerAState = TransCiToAtsPowerState(powerAState); + + /*תBϵԴ״̬*/ + powerBState = TransCiToAtsPowerState(powerBState); + + /*ת״̬*/ + fanState = TransCiToAtsFanState(fanState); + + /*תOC豸״̬*/ + ocDevFaultState = TransCiToAtsOcDevFaultState(ocDevFaultState); + + ciAndOcCommState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_OC, (UINT8)jj); + + ciToXianDiDataBuffer[ii++] = powerAState; + ciToXianDiDataBuffer[ii++] = powerBState; + ciToXianDiDataBuffer[ii++] = ciAndOcCommState;/*OCͨ״̬*/ + ciToXianDiDataBuffer[ii++] = ocDevFaultState; + ciToXianDiDataBuffer[ii++] = fanState; + + ciToXianDiDataBuffer[ii++] = wPbNum; /*ִе,ЧֻΪ0Ҳֻ*/ + if (MAX_OC_PLUS_BOX_NUM >= wPbNum) + { + for (mm = 0u; mm < wPbNum; mm++) + { + ciToXianDiDataBuffer[ii++] = szSendATSPlusBox[mm].chPbId; /*ִе*/ + ciToXianDiDataBuffer[ii++] = szSendATSPlusBox[mm].SendAtsAsState; /*鱨*/ + } + } + else + { + ; /*do nothing*/ + } + + ShortToChar(wDjqySwitchNum, &ciToXianDiDataBuffer[ii]); /*˫ǣĿ*/ + ii += 2U; + if (SWITCH_SUM_MAX > wDjqySwitchNum) + { + for (wDjqySwitchIndex = 0U; wDjqySwitchIndex < wDjqySwitchNum; wDjqySwitchIndex++) + { + ShortToChar(szSendAtsSwitchZzjData[wDjqySwitchIndex].wSwitchId, &ciToXianDiDataBuffer[ii]); /*˫ǣID*/ + ii += 2U; + ciToXianDiDataBuffer[ii++] = szSendAtsSwitchZzjData[wDjqySwitchIndex].chSwIncludeZzjSum; /*Ӧת޻Ŀ*/ + for (chSwitchZzjStateIndex = 0U; chSwitchZzjStateIndex < szSendAtsSwitchZzjData[wDjqySwitchIndex].chSwIncludeZzjSum; chSwitchZzjStateIndex++) + { + ciToXianDiDataBuffer[ii++] = szSendAtsSwitchZzjData[wDjqySwitchIndex].szSwitchIncldeZzjState[chSwitchZzjStateIndex]; + } + } + } + else + { + ; /*do nothing*/ + } + } + else + { + } + } + } + else + { + } + + /*PSC豸ŷPSDϢATS*/ + if (NULL == pDeviceIdBuf) + { + ciToXianDiDataBuffer[ii++] = 0u; + } + else + { + /*PSD0*/ + ciToXianDiDataBuffer[ii++] = 0u; + + for (m = 0u; m < deviceSum; m++) + { + for (n = 0u; n < pscToCiDataStru[pDeviceIdBuf[m]].psdSum; n++) + { + /*ȡPSD*/ + psdCiId = GetPsdBelongCiId(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdId); + if (localCi == psdCiId) + { + psdSum++; + /*psd ID*/ + ShortToChar(0u, &ciToXianDiDataBuffer[ii]); + ii += 2u; + ShortToChar(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdId, &ciToXianDiDataBuffer[ii]); + ii += 2u; + /*ȡϢ*/ + psdMutualLockState = GetPsdMutualLockRemoveState(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdId); + /*ATSȷ·*/ + if ((PSD_ATS_MUTUALLOCK_REMOVE_YES == psdMutualLockState) || + (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == psdMutualLockState)) + { + /*ϸϢ()*/ + pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdFaultQStataOne = 0u; + pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdFaultQStataTwo = 0u; + /*ſϢ*/ + pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdDoorsStateOne = 0u; + pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdDoorsStateTwo = 0u; + } + else + { + /**/ + } + /*ϸϢ()*/ + LongToChar(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdFaultQStataOne, &ciToXianDiDataBuffer[ii]); + ii += 4u; + LongToChar(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdFaultQStataTwo, &ciToXianDiDataBuffer[ii]); + ii += 4u; + /*űϢ*/ + LongToChar(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdDoorIStateOne, &ciToXianDiDataBuffer[ii]); + ii += 4u; + LongToChar(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdDoorIStateTwo, &ciToXianDiDataBuffer[ii]); + ii += 4u; + /*ÿſϢ*/ + LongToChar(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdDoorsStateOne, &ciToXianDiDataBuffer[ii]); + ii += 4u; + LongToChar(pscToCiDataStru[pDeviceIdBuf[m]].psdDataStr[n].psdDoorsStateTwo, &ciToXianDiDataBuffer[ii]); + ii += 4u; + } + else + { + /**/ + } + } + } + /*дPSD*/ + ciToXianDiDataBuffer[ii - (psdSum * 28U) - 1U] = psdSum; + } + + + /*RCOCI豸״̬ Դ/Դģ״̬2ֽ*/ + powerANodeState = CheckRCIAPowerFaultState(); + powerBNodeState = CheckRCIBPowerFaultState(); + ModeAState = CheckRCIAPowerModeFaultState(); + ModeBState = CheckRCIBPowerModeFaultState(); + + /*AϵԴ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPowerModeState(ciToXianDiDataBuffer[ii], 6u, powerANodeState, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*BϵԴ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPowerModeState(ciToXianDiDataBuffer[ii], 4u, powerBNodeState, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*AϵԴģ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPowerModeState(ciToXianDiDataBuffer[ii], 2u, ModeAState, BIT_VAL_00000011B, BIT_VAL_00000000B); + + /*BϵԴģ״̬ʾ*/ + ciToXianDiDataBuffer[ii] = TransCiToAtsPowerModeState(ciToXianDiDataBuffer[ii], 0u, ModeBState, BIT_VAL_00000011B, BIT_VAL_00000000B); + debug_infor_printf((const)"\nPOWER BYTE IS %d", ciToXianDiDataBuffer[ii]); + ii++; + + + /*Ԥһֽ*/ + ii++; + + /**/ + /*ȡ*/ + virtualCiNum = GetVirtualCINum(); + ciToXianDiDataBuffer[ii++] = virtualCiNum; + if (0u < virtualCiNum) + { + for (m = 0u; m < virtualCiNum; m++) + { + ciToXianDiDataBuffer[ii++] = ctrlpowerFlag[m].virCiId; + ciToXianDiDataBuffer[ii++] = ctrlpowerFlag[m].ctrlPowerState; + ciToXianDiDataBuffer[ii++] = ctrlpowerFlag[m].ctrlDeviceType; + ShortToChar(ctrlpowerFlag[m].ctrlDeviceId, &ciToXianDiDataBuffer[ii]); + ii += 2u; + } + } + else + { + /**/ + } + + /*Ԥ40ֽ*/ + ii += 40u; + } + else + { + } + + /*ݰܳ */ + /*ciToXianDiDataBuffer[0] = (UINT8) (((ii - 2) >> 8u) & 0xffu); + ciToXianDiDataBuffer[1] = (UINT8) ((ii - 2) & 0xffu);*/ + + if (ii > CI_TO_ATS_DATA_LEN_MAX) + { + return CI_ERROR; + } + else + { + } + +#ifdef APPCI_MAINTAIN_DEBUG +#ifdef PLATFORM_2OO2 + /*͸ά޻*/ + (void)DarkInfoPack(CIM_INFO_RCI_TO_ATS_DATA, ciToXianDiDataBuffer, ii); +#endif + +#endif/*APPCI_MAINTAIN_DEBUG*/ + + + /*if (QueueWrite(ii, ciToXianDiDataBuffer, ciToXianDiDataQueue))*/ + dstDevId = ((UINT16)((UINT16)targetDevType << 8u) | ((UINT16)deviceId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &ciToXianDiDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + if (targetDevType == CI_SYSTEM_TYPE_XIANDI) + {/*͸ֵ*/ + debug_infor_printf((const)"\nXIANDI_SEND:%d", ii); + debug_out_array(0xAA, ciToXianDiDataBuffer, ii); + } + else + {/*͸ATS*/ + debug_infor_printf((const)"\nATS_SEND:%d", ii); + debug_out_array(0xAA, ciToXianDiDataBuffer, ii); + } +#endif/*ƽ̨ӡ*/ + +#endif + return CI_SUCCESS; + } + else + { + /*дʧ*/ + return CI_ERROR; + } +} + +/* +* ȡCIյIJṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: CIղṹ鳤 +*/ +UINT16 GetCiRevCmdStruCurSum(void) +{ + return CiRevCmdStruCurSum; +} + + +/* +* ȡCIյIJṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIղṹָ +*/ +CommandDataStruct* GetCiRevCmdDataStruct(void) +{ + if (CiRevCmdStruCurSum == 0u) + { + return NULL; + } + else + { + return CiRevCmdDataStru; + } +} + + +/* +* CI +* ˵ const UINT32 CommandId, ID +* const UINT8 CommandType, +* const UINT16 DeviceId, 豸ID +* const UINT8 commandParam, +* const UINT32 commandId, ID +* ֵ void +*/ +void SetCiSendCmdBackInfoData(const UINT8 CommandType, const UINT8 deviceType, const UINT16 deviceId, const UINT8 commandParam, const UINT32 commandId) +{ + UINT32 deviceInfo = 0u; /*豸Ϣ*/ + UINT16 tempDeviceId = 0U; + UINT8 swapSysBoardBelongOC = 0U; + + /*ΪOC忨ϵʱdeviceIdݽIJǸֽOC ID+ֽڰ忨ID + ATSʱҪ豸IDʵֵΪ忨IDҪォdeviceIdתOC IDͰ忨ID*/ + if (CI_BACK_OC_BOARD_SWAPSYS == CommandType) + { + swapSysBoardBelongOC = (UINT8)(deviceId >> 8U); /*ȡֽڵOC ID*/ + tempDeviceId = (deviceId & (UINT16)0xFF); /*ȡֽڵİ忨ID*/ + } + else + { + /*ʹݵdeviceIdΪʵʵ豸ID˲ҪתOC IDΪ*/ + swapSysBoardBelongOC = 0U; + tempDeviceId = deviceId; + } + + if (CiSendCmdStruCurSum < CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX) + { + deviceInfo = (((deviceInfo | (UINT32)tempDeviceId) << 16U) | ((deviceInfo | (UINT32)deviceType) << 8U) | (UINT32)commandParam); + + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandType = CommandType; + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandId = commandId; + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandParam = deviceInfo; + CiSendCmdDataStru[CiSendCmdStruCurSum].termial_id = 0U; + CiSendCmdDataStru[CiSendCmdStruCurSum].affirm_result = 0U; + CiSendCmdDataStru[CiSendCmdStruCurSum].firstCmd_time = 0U; + CiSendCmdDataStru[CiSendCmdStruCurSum].order_type = 0U; + CiSendCmdDataStru[CiSendCmdStruCurSum].response_type = 0U; + CiSendCmdDataStru[CiSendCmdStruCurSum].setCurNum = 0U; + CiSendCmdDataStru[CiSendCmdStruCurSum].VirCIid = 0U; + /*ΪOC忨ϵϵ忨OC ID*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].OCid = swapSysBoardBelongOC; + + CiSendCmdStruCurSum++; + } + else + { + debug_infor_printf((const)"Error:SetCiSendCmdBackInfoData,%d exceed max %d\n",CiSendCmdStruCurSum,CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX); + } + +} + +/* +* CIݴгID +* ˵ const UINT32 CommandId, ID +* const UINT8 CommandType, +* const UINT16 DeviceId, 豸ID +* const UINT8 commandParam, +* const UINT32 commandId, ID +* const UINT16 TrainId,гID +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetCiSendCmdBackInfoWithTrainId(const UINT8 CommandType, const UINT8 deviceType, const UINT16 deviceId, const UINT8 commandParam, const UINT32 commandId,const UINT16 trainId) +{ + UINT32 deviceInfo = 0u; /*豸Ϣ*/ + + if (CiSendCmdStruCurSum < CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX) + { + deviceInfo = (((deviceInfo | (UINT32)deviceId) << 16u) | ((deviceInfo | (UINT32)deviceType) << 8u) | (UINT32)commandParam); + + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandType = CommandType; + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandId = commandId; + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandParam = deviceInfo; + CiSendCmdDataStru[CiSendCmdStruCurSum].termial_id = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].affirm_result = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].firstCmd_time = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].order_type = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].response_type = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].setCurNum = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].VirCIid = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].wTrainIdParam = trainId; + CiSendCmdDataStru[CiSendCmdStruCurSum].OCid = 0U; + CiSendCmdStruCurSum++; + } + else + { + debug_infor_printf((const)"Error:SetCiSendCmdBackInfoData,%d exceed max %d\n", CiSendCmdStruCurSum, CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX); + } + +} + +/* +* һζķ +* ˵ const UINT32 CommandId, ID +* const UINT8 CommandType, +* const UINT16 DeviceId, 豸ID +* const UINT8 commandParam, +* const UINT32 commandId, ID +* ֵ +*/ +void SetCiSendCmdBackData_OrderBack( const UINT32 commandId,const UINT16 deviceId, const UINT8 deviceType,const UINT16 termial_id, const UINT8 order_type, const UINT8 response_type,const UINT8 affirm_result,const UINT8 virCIid) +{ + UINT32 curCycleNum = 0u; + UINT32 appCycTime = 0u;/**/ + UINT8 ii = 0u; + UINT16 cmdDeviceId = 0u; + UINT8 cmdDevType = 0u; + UINT32 deviceInfo = 0u; /*豸Ϣ*/ + UINT32 firstOrderTimeCount = 0u; + curCycleNum =Get2oo2CurCycleNum(); + appCycTime = GetSystemParaAppCycleTime();/*ȡں*/ + firstOrderTimeCount = GetFirstOrderTimeCount(); + /*ҪͶʱݴһ*/ + for (ii = 0u; ii < CiSendBackDataTempStruSum; ii ++) + { + if(RESPONSE_SECOND == response_type) + { + cmdDeviceId = (UINT16)(CiSendBackDataTempStru[ii].CommandParam>>16u); + cmdDevType = (UINT8)(CiSendBackDataTempStru[ii].CommandParam >> 8u); + if((termial_id == CiSendBackDataTempStru[ii].termial_id) &&(commandId == CiSendBackDataTempStru[ii].CommandId) + &&(deviceType == cmdDevType)&&(deviceId == cmdDeviceId)&&(virCIid == CiSendBackDataTempStru[ii].VirCIid)) + { + (void)CommonMemSet(&CiSendBackDataTempStru[ii], (UINT32)sizeof(CommandDataStruct),0u, (UINT32)sizeof(CommandDataStruct)); + } + } + } + + if (CiSendCmdStruCurSum < CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX) + { + deviceInfo = (((deviceInfo | (UINT32)deviceId) << 16u) | ((deviceInfo | (UINT32)deviceType) << 8u) | (UINT32)0u); + + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandType = CI_BACK_ORDER_REPEAT;/*0x70*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandId = commandId;/*ID */ + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandParam = deviceInfo;/*豸ID+豸+(ʱֵ)*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].termial_id = termial_id; /*նID*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].order_type = order_type;/**/ + CiSendCmdDataStru[CiSendCmdStruCurSum].response_type = response_type;/*ظ*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].affirm_result = affirm_result; /*ȷϽ*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].setCurNum = 0u; /*һ*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].firstCmd_time = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].VirCIid = virCIid; + CiSendCmdDataStru[CiSendCmdStruCurSum].OCid = 0U; + if((RESPONSE_FIRST == CiSendCmdDataStru[CiSendCmdStruCurSum].response_type)&&(AFFIRM_SUCCESS==CiSendCmdDataStru[CiSendCmdStruCurSum].affirm_result)) + {/*һ*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].setCurNum = curCycleNum; /*һ*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].firstCmd_time = (UINT8)((firstOrderTimeCount*appCycTime)/1000U); + /*ݴ1*/ + if (CiSendBackDataTempStruSum < CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX) + { + (void)CommonMemCpy(&CiSendBackDataTempStru[CiSendBackDataTempStruSum], (UINT32)sizeof(CommandDataStruct),&CiSendCmdDataStru[CiSendCmdStruCurSum], (UINT32)sizeof(CommandDataStruct)); + CiSendBackDataTempStruSum++; + } + else + { + debug_infor_printf((const)"Error:CiSendBackDataTempStru,%d exceed max %d\n",CiSendBackDataTempStruSum,CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX); + } + } + CiSendCmdStruCurSum++; + } + else + { + debug_infor_printf((const)"Error:SetCiSendCmdBackData_OrderBack,%d exceed max %d\n",CiSendCmdStruCurSum,CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX); + } + +} +/* +* һʱ +* ˵ +* ֵ +*/ +void UpdataCiSendCmdBack_OrderBack(void) +{/*֮ǰ*/ + UINT16 ii = 0u; + UINT8 timeData = 0u; + UINT32 curCycleNum = 0u; + UINT32 appCycTime = 0u;/**/ + UINT32 firstOrderTimeCount = 0u; + UINT16 deviceID = 0u; + UINT8 deviceType = 0u; + UINT8 virCIid = 0u; + curCycleNum =Get2oo2CurCycleNum(); + appCycTime = GetSystemParaAppCycleTime();/*ȡں*/ + firstOrderTimeCount = GetFirstOrderTimeCount(); + for (ii = 0u; ii < CiSendBackDataTempStruSum; ii ++) + { + /*һʱ*/ + if(0u != CiSendBackDataTempStru[ii].setCurNum) + { + if(curCycleNum >= (firstOrderTimeCount + CiSendBackDataTempStru[ii].setCurNum)) + {/*ʱʱ䵽*/ + /*һʱ*/ + deviceID = (UINT16)(CiSendBackDataTempStru[ii].CommandParam>>16u); + deviceType = (UINT8)(CiSendBackDataTempStru[ii].CommandParam>>8u); + virCIid = CiSendBackDataTempStru[ii].VirCIid; + SetCiSendCmdBack_FstOrdOutTime(CiSendBackDataTempStru[ii].CommandId,deviceID,deviceType,CiSendBackDataTempStru[ii].order_type,CiSendBackDataTempStru[ii].termial_id,virCIid); + /**/ + (void)CommonMemSet(&CiSendBackDataTempStru[ii], (UINT32)sizeof(CommandDataStruct), 0U , (UINT32)sizeof(CommandDataStruct)); + } + else + { + timeData = (UINT8)(((firstOrderTimeCount + CiSendBackDataTempStru[ii].setCurNum - curCycleNum)* appCycTime)/1000U); + CiSendBackDataTempStru[ii].firstCmd_time = timeData; /*һʱ*/ + } + } + + } +} +/* +* һʱ +* ˵ +* ֵ +*/ +void SetCiSendCmdBack_FstOrdOutTime(const UINT32 commandId,const UINT16 deviceId, const UINT8 deviceType,const UINT8 order_type,const UINT16 termial_id,UINT8 virCIid) +{ + UINT32 deviceInfo = 0u; /*豸Ϣ*/ + if (CiSendCmdStruCurSum < CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX) + { + deviceInfo = (((deviceInfo | (UINT32)deviceId) << 16u) | ((deviceInfo | (UINT32)deviceType) << 8u) | (UINT32)0u); + + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandType = CI_BACK_FIRSTORDER_OUTTIME;/*0x7d*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandId = commandId;/*ID */ + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandParam = deviceInfo;/*豸ID+豸+(ʱֵ)*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].termial_id = termial_id; /*նID*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].order_type = order_type;/**/ + CiSendCmdDataStru[CiSendCmdStruCurSum].response_type = 0u;/*ظ*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].affirm_result = 0u; /*ȷϽ*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].setCurNum = 0u; /*һ*/ + CiSendCmdDataStru[CiSendCmdStruCurSum].firstCmd_time = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].VirCIid =virCIid; + CiSendCmdDataStru[CiSendCmdStruCurSum].OCid = 0U; + CiSendCmdStruCurSum++; + } + else + { + debug_infor_printf((const)"Error:SetCiSendCmdBack_FstOrdOutTime,%d exceed max %d\n",CiSendCmdStruCurSum,CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX); + } + +} +/* +* CIݴIJҪ +* ˵ void +* ֵ +*/ +void ClearCiSendBackDataTempStruData(void) +{ + UINT16 ii = 0u; + UINT16 ciSendCmdStruTempNum = 0u; /*CIṹ鳤*/ + UINT16 jj = 0u; + for (ii = 0u; ii < CiSendBackDataTempStruSum; ii ++) + { + if(ii < CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX) + { + /*ȫ0ݱ棬ȫƳ*/ + if(0u !=CiSendBackDataTempStru[ii].response_type) + { + (void)CommonMemCpy(&CiSendBackDataTempStru[ciSendCmdStruTempNum], (UINT32)sizeof(CommandDataStruct), &CiSendBackDataTempStru[ii], (UINT32)sizeof(CommandDataStruct)); + ciSendCmdStruTempNum++; + } + } + } + /**/ + for (jj = ciSendCmdStruTempNum; jj < CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX; jj ++) + { + (void)CommonMemSet(&CiSendBackDataTempStru[jj], (UINT32)sizeof(CommandDataStruct), 0 , (UINT32)sizeof(CommandDataStruct)); + } + CiSendBackDataTempStruSum = ciSendCmdStruTempNum; +} +/* +* CIݶ +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +void ClearCiRevCmdData(void) +{ + UINT16 ii = 0u; + + for (ii = 0u; ii < CiRevCmdStruCurSum; ii ++) + { + (void)CommonMemSet(&CiRevCmdDataStru[ii], (UINT32)sizeof(CommandDataStruct), 0u , (UINT32)sizeof(CommandDataStruct)); + } + + CiRevCmdStruCurSum = 0u; +} + + +/* +* CIݶ +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +void ClearCiSendCmdData(void) +{ + UINT16 ii = 0u; + + for (ii = 0u; ii < CiSendCmdStruCurSum; ii ++) + { + (void)CommonMemSet(&CiSendCmdDataStru[ii], (UINT32)sizeof(CommandDataStruct), 0u , (UINT32)sizeof(CommandDataStruct)); + } + + CiSendCmdStruCurSum = 0u; + ClearCiSendBackDataTempStruData(); +} +/* +* ЧԼ +* ˵ 豸ID,豸ͣնID,ն +* ֵ CI_ERROR : ʧ +* CI_SUCCESS: ɹ +*/ +UINT8 CheckSecondOrderValid(const UINT32 commandId,const UINT16 deviceId, const UINT8 deviceType,const UINT16 termial_id, const UINT8 order_type,const UINT8 virCiID) +{ + UINT16 ii = 0u; + UINT16 ciSendCmdStruNum = 0u; /*CIṹ鳤*/ + UINT8 reVal = CI_ERROR; + UINT8 firstOrder = 0u; + UINT16 cmdDeviceId =0u; + UINT8 cmdDevType =0u; + firstOrder = FindFirstOrder(order_type); + for (ii = 0u; ii < CiSendBackDataTempStruSum; ii ++) + { + cmdDeviceId = (UINT16)(CiSendBackDataTempStru[ii].CommandParam>>16u); + cmdDevType = (UINT8)(CiSendBackDataTempStru[ii].CommandParam >> 8u); + if((deviceId == cmdDeviceId)&&(deviceType == cmdDevType)&&(commandId == CiSendBackDataTempStru[ii].CommandId) + &&(termial_id == CiSendBackDataTempStru[ii].termial_id)&&(firstOrder == CiSendBackDataTempStru[ii].order_type) + &&(0u !=firstOrder)&&(virCiID == CiSendBackDataTempStru[ii].VirCIid)) + { + reVal = CI_SUCCESS; + break; + } + } + return reVal; +} + +/* +* ȡ״βȷϵID +* ˵ void +* ֵ ״βȷϵID +*/ +UINT32 GetFirstCmdId(void) +{ + return FirstCmdId; +} + +/* +* ״βȷϵID +* ˵ const UINT32 cmdId, ID +* ֵ void +*/ +void SetFirstCmdId(const UINT32 cmdId) +{ + FirstCmdId = cmdId; +} + +/* +* ȡCIյATSֵźؿṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: CIATSֵźؿṹ鳤 +*/ +UINT16 GetATSToCiCmdRtnToTRCurSum(void) +{ + return ATSorXDToCiCmdReturnToTRCurSum; +} + + +/* +* ȡCIյATSֵźؿṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIATSֵźؿṹָ +*/ +CommandDataStruct* GetATSorXDToCiCmdRtnToTRData(void) +{ + CommandDataStruct* pTemp = NULL; + if (0u == ATSorXDToCiCmdReturnToTRCurSum) + { + pTemp = NULL; + } + else + { + pTemp = ATSorXDToCiCmdRtnToTRDataStru; + } + + return pTemp; +} + + +/* +* źؿṹУɾָλõ +* ˵ const UINT16 idx:źؿṹλ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 RemoveReturnToTRCmdAt(const UINT16 idx) +{ + UINT8 retVal = CI_ERROR; + UINT16 afIdx = 0u; + if(idx >= ATSorXDToCiCmdReturnToTRCurSum) + { + retVal = CI_ERROR; + } + else + { + for(afIdx = idx+1U;afIdx < ATSorXDToCiCmdReturnToTRCurSum;afIdx++) + { + CopyReturnToTRCmd(&(ATSorXDToCiCmdRtnToTRDataStru[afIdx]),&(ATSorXDToCiCmdRtnToTRDataStru[afIdx-1U])); + } + + /*һ*/ + ATSorXDToCiCmdReturnToTRCurSum--; + retVal = CI_SUCCESS; + } + + return retVal; +} +/* +* ͸CIźؿϢṹ +* ˵ const CommandDataStruct* src:Ƶźؿṹָ + CommandDataStruct* dst:Ŀźؿṹָ +* ֵ +*/ +void CopyReturnToTRCmd(const CommandDataStruct* src,CommandDataStruct* dst) +{ + if ((NULL != src) && (NULL != dst)) + { + (void)CommonMemCpy(dst, (UINT32)sizeof(CommandDataStruct), src , (UINT32)sizeof(CommandDataStruct)); + } + +} + +/* +* ȡȷPSC־ +* ˵ UINT8 pscId, PSCϵͳID +* +* ֵ 0: δû +* >0: û +*/ +UINT8 GetPscConfirmFlag(UINT8 pscId) +{ + /*ʼ*/ + UINT8 i = 0u; + UINT8 pscPsdFlag = 0u; + UINT8 retVal = 0u; + UINT8 localCiId = 0u; + UINT8 psdCiId = 0u; + PSCToCiDataStruct* pscToCiDataStru = GetPscToCiDataStru();/*᷵NULL*/ + + localCiId = GetSystemParaLocalCiId();/*ȡCI ID*/ + + /**/ + if (PSC_TO_CI_SUM_MAX > pscId) + { + for(i = 0u; i < pscToCiDataStru[pscId].psdSum; i++) + { + + psdCiId = GetPsdBelongCiId(pscToCiDataStru[pscId].psdDataStr[i].psdId); + /**/ + if(psdCiId == localCiId) + { + /*ȡPSCӦPSDĻȷϱ־*/ + pscPsdFlag = GetPsdPscPlFlag(pscToCiDataStru[pscId].psdDataStr[i].psdId); + if(CI_PSC_PL_CONFIRM_YES == pscPsdFlag) + { + retVal = CI_PSC_PL_CONFIRM_YES; + break; + } + else + { + /**/ + } + } + } + } + return(retVal); +} +/* +* psdʱ +* ˵ +* +* ֵ +* cgh-ϲCID-3037-2 +*/ +void PsdDriveOutTimeToAts(void) +{ + UINT16 wPsdSum = 0u; + UINT16 i = 0u; + UINT16 wpsdId = 0u; + UINT8 chPsdBelongCiId = 0u; + UINT8 chlocalCiId = 0u; + UINT8 chPsdDriveOutTimeState = 0u; + + chlocalCiId = GetSystemParaLocalCiId(); + /*ȡpsd*/ + wPsdSum = GetTotalPsdCurNum(); + for (i = 0u; i < wPsdSum; i++) + { + wpsdId = GetPsdId(i); + chPsdBelongCiId = GetPsdBelongCiId(wpsdId); + if (chlocalCiId == chPsdBelongCiId) + { + /*δӦϢ*/ + chPsdDriveOutTimeState = CheckPsdDriveOutTimeState(wpsdId); + + if (PSD_OPEN_OUT_TIME == chPsdDriveOutTimeState) + { + SetCiSendCmdBackInfoData(CI_BACK_PSD_OPEN_OUT_TIME, CI_DEVICE_TYPE_PSD, wpsdId, 0u, 0u); + + } + else if (PSD_CLOSE_OUT_TIME == chPsdDriveOutTimeState) + { + SetCiSendCmdBackInfoData(CI_BACK_PSD_CLOSE_OUT_TIME, CI_DEVICE_TYPE_PSD, wpsdId, 0u, 0u); + + } + else + { + ; /*dzʱ״̬б*/ + } + + + } + else + { + ; /*DZϽPSDд*/ + } + + } +} +/* +* ȡӦһ +* ˵ +* +* ֵ һ +*/ +UINT8 FindFirstOrder(UINT8 SecondOrder) +{ + UINT8 i = 0u; + UINT8 reVal = 0u; + switch(SecondOrder) + { + case ATS_CMD_STARTFLOCK_UNLOCK_TWO: + reVal = ATS_CMD_STARTFLOCK_UNLOCK_ONE; /*ȫվһ*/ + break; + case ATS_CMD_ALL_SIG_BRIGHT_SET_TWO: + reVal =ATS_CMD_ALL_SIG_BRIGHT_SET_ONE;/*ȫվһ*/ + break; + case ATS_CMD_ALLSIGBRIGHT_CANCEL_TWO: + reVal =ATS_CMD_ALLSIGBRIGHT_CANCEL_ONE;/*ȡȫվһ*/ + break; + case ATS_CMD_SWITCH_ZONGSUO_SET_TWO: + reVal =ATS_CMD_SWITCH_ZONGSUO_SET_ONE;/*һ*/ + break; + case ATS_CMD_SWIT_ZONGSUO_CANCEL_TWO: + reVal =ATS_CMD_SWIT_ZONGSUO_CANCEL_ONE;/*ȡһ*/ + break; + case ATS_CMD_PHYSEC_RESET_TWO: + reVal = ATS_CMD_PHYSEC_RESET_ONE;/*Ḵλһ*/ + break; + case ATS_CMD_SWIT_QIANG_DINGWEI_TWO: + reVal = ATS_CMD_SWIT_QIANG_DINGWEI_ONE; /*ǿⶨλһ*/ + break; + case ATS_CMD_SWIT_QIANG_FANWEI_TWO: + reVal = ATS_CMD_SWIT_QIANG_FANWEI_ONE; /*ǿⷴλһ*/ + break; + case ATS_CMD_PHYSEC_PRE_RESET_TWO: + reVal = ATS_CMD_PHYSEC_PRE_RESET_ONE; /*Ԥλһ*/ + break; + case ATS_CMD_CICI_NET_TO_RELAY_TWO: + reVal = ATS_CMD_CICI_NET_TO_RELAY_ONE; /*ӿת̵ӿһ*/ + break; + case ATS_CMD_PSC_PL_TWO: + reVal = ATS_CMD_PSC_PL_ONE;/*PSC·һ*/ + break; + case ATS_CMD_QUXIAO_PSC_PL_TWO: + reVal = ATS_CMD_QUXIAO_PSC_PL_ONE;/*ȡPSC·һ*/ + break; + case ATS_CMD_SIGNALMAINTAINSTATE_TWO: + reVal = ATS_CMD_SIGNALMAINTAINSTATE_ONE;/*źŻά޵һ*/ + break; + case ATS_CMD_CANCEL_SIG_MAINTAIN_TWO: + reVal = ATS_CMD_CANCEL_SIG_MAINTAIN_ONE;/*ȡźŻά޵һ*/ + break; + case ATS_CMD_CANCEL_SW_ALARM_TWO: + reVal = ATS_CMD_CANCEL_SW_ALARM_ONE; /*ȡת޻һ*/ + break; + case ATS_CMD_RECOVER_SW_ALARM_TWO: + reVal = ATS_CMD_RECOVER_SW_ALARM_ONE; /*ָת޻һ*/ + break; + case LABOR_CMD_CANCEL_OVERLAP_TWO: + reVal = LABOR_CMD_CANCEL_OVERLAP_ONE; /*˹һ*/ + break; + case ATS_CMD_CANCEL_PHYSEC_SECOND: + reVal = ATS_CMD_CANCEL_PHYSEC_FIRST;/* һ */ + break; + case ATS_CMD_TOA_RESET_SECOND: + reVal = ATS_CMD_TOA_RESET_FIRST;/*ռѹλһ*/ + break; + case ATS_CMD_OPEN_XIANSU_SIGNAL_SECOND: + reVal = ATS_CMD_OPEN_XIANSU_SIGNAL_FIRST;/*źһ*/ + break; + case ATS_CMD_SWITCH_DINGWEI_TEST_TWO: + reVal = ATS_CMD_SWITCH_DINGWEI_TEST_ONE; /*λһ*/ + break; + case ATS_CMD_SWITCH_FANWEI_TEST_TWO: + reVal = ATS_CMD_SWITCH_FANWEI_TEST_ONE; /*λһ*/ + break; + default: + reVal = 0u; + break; + } + return reVal; +} +/* +* ֵػATSķID߱ID +* ˵ void +* ֵ +*/ +void AddCiSendBackDataCIid(void) +{ + UINT16 ii = 0u; + UINT16 cmdDeviceId = 0u; + UINT8 cmdDevType = 0u; + UINT8 belongVirCIid = 0u; + UINT8 backType = 0u; + UINT8 virCINum = 0u; + UINT8 boardBelongOcId = 0U; + UINT16 phySecPlockBelongRouteId = 0U; /*η·ID*/ + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); /*ȡǷ֧ܿ*/ + + for (ii = 0u; ii < CiSendCmdStruCurSum; ii ++) + { + belongVirCIid = 0u; + cmdDeviceId = (UINT16)(CiSendCmdDataStru[ii].CommandParam >> 16u); + cmdDevType = (UINT8)(CiSendCmdDataStru[ii].CommandParam >> 8u); + backType = CiSendCmdDataStru[ii].CommandType; + if (FUNC_SWITCH_ON == includeVirFlag) + { + if ((CI_BACK_ORDER_REPEAT != backType) && (CI_BACK_FIRSTORDER_OUTTIME != backType) + && (CI_BACK_COUNT_OVERLAP_UNLOCK != backType) && (CI_BACK_COUNT_OVERLAP_UNLOCK_HIGH != backType)) + /*0x700x7dͲ,ַVirCIidǰѾֵڴ˴ٸֵ0x55,0x5d˷ֵ֧Ᵽʱڱֵϲʾʱ*/ + { + switch (cmdDevType) + { + case CI_DEVICE_TYPE_SWITCH: + belongVirCIid = GetSwitchBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_SIGNAL: + belongVirCIid = GetSignalBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_PHYSEC: + belongVirCIid = GetPhySecBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_LOGICSEC: + belongVirCIid = GetLogSecBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_ROUTE: + belongVirCIid = GetRouteBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_OVERLAP: + belongVirCIid = GetOverlapBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_AXISSEC: + belongVirCIid = GetAxisSectionBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_PSD: + belongVirCIid = GetPsdbelongVirCIid(cmdDeviceId); + break; + case CI_DEVICE_TYPE_RELAY: + belongVirCIid = GetRelayBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_SPKS: + belongVirCIid = GetSpksBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_GARAGEDOOR: + belongVirCIid = GetGaragedoorBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_WASHMACHINE: + belongVirCIid = GetWashMachineBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_FLOODGATE: + belongVirCIid = GetFloodGateBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_GROUP_AUTO_ROUTE: + belongVirCIid = GetGroupAutoRouteBelongVirCIid(cmdDeviceId);/*Զ·*/ + break; + /*רԳ*/ + case CI_DEVICE_TYPE_CMD: + virCINum = GetVirtualCINum(); + if (1u <= virCINum) + { + belongVirCIid = GetVirtualCIid(0u);/*ԳһһֱȡȡĵһID*/ + } + break; + case CI_DEVICE_TYPE_ESB: + belongVirCIid = GetEsbBelongVirCiId(cmdDeviceId); + break; + case CI_DEVICE_TYPE_NONROUTE: + belongVirCIid = GetnonRouteIdbelongVirCIid((UINT8)cmdDeviceId);/*ǽ·ɷǽ·źŻ*/ + break; + case CI_DEVICE_TYPE_WASH_LINE:/*ϴ*/ + belongVirCIid = GetWashMachineBelongVirCiId(cmdDeviceId);/*XTJӦϴ*/ + break; + case CI_DEVICE_TYPE_OC_BOARD: + boardBelongOcId = CiSendCmdDataStru[ii].OCid; + belongVirCIid = GetOCBelongVirCIid(boardBelongOcId); /*ȡϵ忨ID*/ + break; + case CI_DEVICE_TYPE_WASH_ALLOW_PASS:/*ϴͨ*/ + belongVirCIid = GetWashMachineBelongVirCiId(cmdDeviceId);/*ϴ*/ + break; + default: + belongVirCIid = 0u; + break; + } + } + else if ((CI_BACK_COUNT_OVERLAP_UNLOCK == backType) || (CI_BACK_COUNT_OVERLAP_UNLOCK_HIGH == backType)) + { + if (CI_DEVICE_TYPE_PHYSEC == cmdDevType) + { + phySecPlockBelongRouteId = GetPhySecPLockBelongRouteId(cmdDeviceId); /*ȡη·ID*/ + belongVirCIid = GetRouteBelongVirCiId(phySecPlockBelongRouteId); /*ȡ·ID*/ + } + } + else + { + ; /**/ + } + } + else + { + /*߱ATSID*/ + belongVirCIid = GetSystemParaLocalCiId(); + } + + if (0U == CiSendCmdDataStru[ii].VirCIid) + { + CiSendCmdDataStru[ii].VirCIid = belongVirCIid; + } + } +} + +/* +* CiAts߼Ϣ +* ˵ const UINT8* pDataBuf, ݻ +* const UINT16 *wDataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToAtsLgcSgmtInfo(UINT8* pDataBuf, UINT16* wDataLength) +{ + UINT16 wLogicSecSum = 0u; /*߼*/ + UINT16 wLogicSecIndex = 0U; + UINT16 wLogicSecId = 0U; /*߼ID*/ + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + UINT16 deviceSum = 0u; + UINT8 chLogicTrainSum = 0U; /*߼εг*/ + LogicTrainResStruct * pstLogicResTrainInfo = NULL; /*߼εгϢָ*/ + UINT16 wTrainId = 0U;/*߼εгID*/ + UINT8 chTrainIndex = 0U; + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 belongCiId = 0u; + UINT8 localCiId = 0u; + UINT32 dwHlhtTrainId = 0u;/*ͨгID*/ + UINT8 chLogUseState = 0u; + UINT8 chLogLockState = 0u; + UINT8 chLogRouteLogLockState = 0U; + UINT8 chUseState = 0u; + UINT8 chLockState = 0u; + UINT8 chUseLockState = 0u; + + /*η*/ + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + chRetVal = CI_SUCCESS; + } + + if (CI_SUCCESS == chRetVal) + { + ii = *wDataLength; + localCiId = GetSystemParaLocalCiId();/*ID*/ + wLogicSecSum = GetTotalLogSecCurNum(); + if (LOGIC_SECTION_SUM_MAX > wLogicSecSum) + { + + /*߼*/ + /*д߼*/ + ShortToChar(wLogicSecSum, &pDataBuf[ii]); + ii += 2u; + for (wLogicSecIndex = 0u; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++) + { + /*߼ID*/ + wLogicSecId = GetLogicSecId(wLogicSecIndex); + + /*ֻͱ߼Ϣ*/ + if ((0U < wLogicSecId) && (LOGIC_SECTION_SUM_MAX> wLogicSecId)) + { + /*߼εг*/ + chLogicTrainSum = GetLogSecTrainInfoSum(wLogicSecId); + pstLogicResTrainInfo = GetLogSecTrainInfo(wLogicSecId); + + /*߼ID*/ + ShortToChar(wLogicSecId, &pDataBuf[ii]); + ii += 2u; + + pDataBuf[ii++] = chLogicTrainSum; + if((0U < chLogicTrainSum)) + { + if((LOGIC_SECTION_RES_SUM_MAX >chLogicTrainSum) + && (NULL != pstLogicResTrainInfo)) + { + + for (chTrainIndex = 0u; chTrainIndex < chLogicTrainSum; chTrainIndex++) + { + /*߼աʱ쳣ա߼ա߼쳣ʱATS߼ԴϢ*/ + chLogLockState = GetLogSecLockState(wLogicSecId); + chLogRouteLogLockState = GetLogSecLogLockState(wLogicSecId); + if ((LOG_SECTION_LOCK_NORMAL == chLogLockState) || (LOG_SECTION_LOCK_DELAY == chLogLockState) || (LOG_SECTION_LOCK_EXCEPT == chLogLockState) + || (LOG_SECTION_LOGLOCK_NORMAL == chLogRouteLogLockState) || (LOG_SECTION_LOGLOCK_EXCEPT == chLogRouteLogLockState)) + { + /*鳵-2ֽڲת4ֽڻͨ(ĬϷһ)*/ + (void)dquDevName2HlhtId(pstLogicResTrainInfo[chTrainIndex].wTrainId, 1u, &dwHlhtTrainId); + LongToChar(dwHlhtTrainId, &pDataBuf[ii]); + ii += 4u; + if (LOGIC_SECTION_RES_USABLE == pstLogicResTrainInfo[chTrainIndex].chLogicResUsable) + { + chUseLockState = 0x55u;/*ҿ*/ + } + else + { + chUseLockState = 0x5Au;/*ղ*/ + } + pDataBuf[ii++] = chUseLockState; + } + else + { + } + + } + } + else + { + chRetVal = CI_ERROR; + } + + } + else + { + ; /*û ִ*/ + } + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + } + + } + + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + } + } + else + { + } + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ATS/ֵصܳЧ +* ˵ const UINT8* pdataBuf, ݻ +* const UINT16 comSum, ֡ +* const UINT16 comTotalLen, ܳ +* ֵ CI_ERROR Ч +* CI_SUCCESS Ч +*/ +UINT8 CheckATSorXiandTotalDataLenVal(const UINT8* pdataBuf, const UINT16 comSum, const UINT16 comTotalLen) +{ + UINT8 retValue = CI_ERROR; + UINT16 i = 0u; + UINT8 oneCmdDataLen = 0u; + UINT16 jj = 0u; + + /** μ*/ + if ((NULL != pdataBuf) && (0u != comSum) && (ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX >= comSum) && (0u != comTotalLen)) + { + /** ֡ܳ*/ + for (jj = 0u; jj < comSum; jj++) + { + /** ȡݳ*/ + oneCmdDataLen = pdataBuf[i]; + i = i + 1u + ((UINT16)oneCmdDataLen); /** ݳȲȱҪϱ1ֽ*/ + } + + /** ܳ,֡2ֽ*/ + i += 2u; + + /** ܳη͵ֶܳ*/ + if (comTotalLen == i) + { + /** ܳЧسɹ*/ + retValue = CI_SUCCESS; + } + else + { + /** ܳЧʧ*/ + retValue = CI_ERROR; + } + } + else + { + /** βϷʧ*/ + retValue = CI_ERROR; + } + + return retValue; +} +/* +* Ϣת +* ˵ const UINT32 CommandId, ID +* const UINT8 CommandType, +* const UINT16 DeviceId, 豸ID +* const UINT8 virCIid, ID +* ֵ 0: ʧ +* 1: óɹ +* cgh-ϲCID-2349-5 +*/ +void errorCodeDataTransCmdBack(const UINT8 CommandType, const UINT8 deviceType, const UINT16 deviceId, const UINT8 virCIid) +{ + UINT32 deviceInfo = 0u; /*豸Ϣ*/ + + if (CiSendCmdStruCurSum < CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX) + { + deviceInfo = (((deviceInfo | (UINT32)deviceId) << 16) | ((deviceInfo | (UINT32)deviceType) << 8) | (UINT32)0); + + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandType = CommandType; + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandId = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].CommandParam = deviceInfo; + CiSendCmdDataStru[CiSendCmdStruCurSum].termial_id = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].affirm_result = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].firstCmd_time = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].order_type = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].response_type = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].setCurNum = 0u; + CiSendCmdDataStru[CiSendCmdStruCurSum].VirCIid = virCIid; + CiSendCmdStruCurSum++; + } + else + { + debug_infor_printf((const)"Error:errorCodeDataTransCmdBack,%d exceed max %d\n", CiSendCmdStruCurSum, CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX); + } + +} + +/* +* תCiATSOCbyteִе״̬Ϣ +* ˵ +* UINT8 *dataLength, ݵַ +* +* OcToATSPlusBox *ciSendATSPlusBox, ״̬ +* ֵ ִе +*/ +UINT8 TransCiToAtsOCPlusBoxInfo(OcToATSPlusBox *ciSendATSPlusBox, UINT8 *wDataLength) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 kk = 0U; + UINT8 mm = 0U; + UINT8 wPbNum = 0u; /*ִе*/ + UINT8 wPbType = 0u; /*ִе*/ + UINT8 wAsState = 0u; /*ִе䱨*/ + + if ((NULL == ciSendATSPlusBox) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + kk = *wDataLength; + chRetVal = CI_SUCCESS; + + wPbNum = m_OcToCiOrginDataArr[kk].chPbNum; /*ȡִе*/ + + if (MAX_OC_PLUS_BOX_NUM >= wPbNum) + { + for (mm = 0U; mm < wPbNum; mm++) + { + ciSendATSPlusBox[mm].chPbId = m_OcToCiOrginDataArr[kk].szPlusBox[mm].chPbId; /*ȡӦŲ*/ + wPbType = m_OcToCiOrginDataArr[kk].szPlusBox[mm].chPbType; + wAsState = m_OcToCiOrginDataArr[kk].szPlusBox[mm].chAsState; + switch (wPbType) + { + case TYPE_SIGNAL: /*ΪźŻ*/ + if (HIGH_NORMAL == (wAsState & 0xf0U)) /*ֻλִе˿Ƿ*/ + { + ciSendATSPlusBox[mm].SendAtsAsState = FUSE_NORMAL; + } + else + { + ciSendATSPlusBox[mm].SendAtsAsState = SIGNAL_FUSE_ALARM; + } + break; + case TYPE_POINT_SWITCH: /*Ϊת޻*/ + if (HIGH_NORMAL == (wAsState & 0xf0U)) /*λִе˿Ƿ*/ + { + if (LOW_NORMAL == (wAsState & 0x0fU)) /*λʾ˿Ƿ*/ + { + ciSendATSPlusBox[mm].SendAtsAsState = FUSE_NORMAL; + } + else + { + ciSendATSPlusBox[mm].SendAtsAsState = POINT_SWITCH_EXPRESSED_FUSE_ALARM; + } + } + else + { + if (LOW_NORMAL == (wAsState & 0x0fU)) /*λʾ˿Ƿ*/ + { + ciSendATSPlusBox[mm].SendAtsAsState = POINT_SWITCH_EXECUTIVE_FUSE_ALARM; + } + else + { + ciSendATSPlusBox[mm].SendAtsAsState = POINT_SWITCH_FUSE_ALARM; + } + } + break; + default: + /*ɴ֧*/ + break; + } + } + } + else + { + ; /*OCȡִеݴ*/ + } + } + return wPbNum; +} +/* +* תCiATSOCbyte˫ϵԴ״̬Ϣ +* ˵ +* UINT8 PowerState, Դ״̬ +* +* +* ֵ תĵԴ״̬ +*/ +static UINT8 TransCiToAtsPowerState(UINT8 PowerState) +{ + UINT8 Power_state = DUAL_WAY_AIR_SWITCH_ABNORMAL_ATS; + + if (DUAL_WAY_AIR_SWITCH_NORMAL == PowerState) + { + Power_state = DUAL_WAY_AIR_SWITCH_NORMAL_ATS; + } + else if (SINGLE_WAY_AIR_SWITCH_ABNORMAL == PowerState) + { + Power_state = SINGLE_WAY_AIR_SWITCH_ABNORMAL_ATS; + } + else + { + Power_state = DUAL_WAY_AIR_SWITCH_ABNORMAL_ATS; + } + + return Power_state; +} + +/* +* תCiATSOCbyte״̬Ϣ +* ˵ +* UINT8 fanState, ״̬ +* +* +* ֵ תķ״̬ +*/ +static UINT8 TransCiToAtsFanState(UINT8 fanState) +{ + UINT8 Fan_state = AirFan_ABNORMAL_ATS; + + if (AirFan_NORMAL == fanState) + { + Fan_state = AirFan_NORMAL_ATS; + } + else if (AirFan_Fault == fanState) + { + Fan_state = AirFan_Fault_ATS; + } + else + { + Fan_state = AirFan_ABNORMAL_ATS; + } + + return Fan_state; +} + +/* +* תCiATSOCbyte״̬Ϣ +* ˵ +* UINT8 ocDevFaultState, OC豸״̬ +* +* +* ֵ ת豸״̬ +*/ +static UINT8 TransCiToAtsOcDevFaultState(UINT8 ocDevFaultState) +{ + UINT8 ocDevFault_state = OC_CARD_ABNORMAL_ATS; + + if (OC_CARD_NORMAL == ocDevFaultState) + { + ocDevFault_state = OC_CARD_NORMAL_ATS; + } + else + { + ocDevFault_state = OC_CARD_ABNORMAL_ATS; + } + + return ocDevFault_state; +} + +/* +* תCiATSPSC ״̬ʾ״̬Ϣ +* ˵ +* UINT8 ciToXianDiData, CIֵϢ +* UINT8 MoveNum λ +* UINT8 PscState psc״̬ʾ״̬ +* +* +* ֵ ת +*/ +static UINT8 TransCiToAtsPSCWorkState(UINT8 ciToXianDiData, UINT8 MoveNum, UINT8 PscState) +{ + UINT8 TransCiSendData = 0u; + + if (ALARM_MAIN_WORK_STATE == PscState) + {/*PSC ״̬ʾ*/ + TransCiSendData = ciToXianDiData | ((UINT8)(BIT_VAL_00000001B << MoveNum)); + } + else if (ALARM_BACKUP_WORK_STATE == PscState) + { + TransCiSendData = ciToXianDiData | ((UINT8)(BIT_VAL_00000010B << MoveNum)); + } + else + { + TransCiSendData = ciToXianDiData | ((UINT8)(BIT_VAL_00000000B << MoveNum)); + } + + return TransCiSendData; +} + +/* +* תCiATSPSC ״̬ʾϢ +* ˵ +* UINT8 ciToXianDiData, CIֵϢ +* UINT8 MoveNum λ +* UINT8 PscState psc״̬ʾ״̬ +* UINT8 BitValY ifҪƵĺֵ +* UINT8 BitValN ifҪƵĺֵ +* +* +* ֵ ת +*/ +static UINT8 TransCiToAtsPSCState(UINT8 ciToXianDiData, UINT8 MoveNum, UINT8 PscState, UINT8 BitValY,UINT8 BitValN) +{ + UINT8 TransCiSendData = 0u; + + if (ALARM_STATE_NO == PscState) + {/*PSC ״̬ʾ*/ + TransCiSendData = ciToXianDiData | ((UINT8)(BitValY << MoveNum)); + } + else + { + TransCiSendData = ciToXianDiData | ((UINT8)(BitValN << MoveNum)); + } + + return TransCiSendData; +} + +/* +* תCiATSPSC ״̬Ϣ +* ˵ +* UINT8 ciToXianDiData, CIֵϢ +* UINT8 MoveNum λ +* UINT8 PscStatetype psC״̬Ӧ +* UINT8 PscState pscӦ״̬ +* UINT8 BitValY ifҪƵĺֵ +* UINT8 BitValN ifҪƵĺֵ +* +* +* ֵ ת +*/ +static UINT8 TransCiToAtsPSCtypeState(UINT8 ciToXianDiData, UINT8 MoveNum, UINT8 PscStatetype, UINT8 PscState, UINT8 BitValY, UINT8 BitValN) +{ + UINT8 TransCiSendData = 0u; + + if (PscState == PscStatetype) + { + TransCiSendData = ciToXianDiData | ((UINT8)(BitValY << MoveNum)); + } + else + { + TransCiSendData = ciToXianDiData | ((UINT8)(BitValN << MoveNum)); + } + + return TransCiSendData; +} +#if 0 +/* +* OCidOCվԴָʾ״̬ +* ˵ void +* ֵ +* cgh-ϲCID-3037-3\cgh-ϲCID-3037-5 +*/ +UINT8 packOcStationPowerIndic(UINT8 ocid) +{ + UINT16 devCurSum = GetOCStationIndicCurSum(); /*ȡOCվʾƵǰ*/ + UINT16 i = 0u; + UINT8 belongOcid = 0u; + UINT8 indicId = 0u; + UINT8 indicType = 0u; + UINT8 reval = 0u; + UINT8 indicState = 0u; + for (i = 0u; i < devCurSum; i++) + { + belongOcid = GetOCStationIndicOcIdByIndex(i); + if (ocid == belongOcid) + { + indicId = GetOCStationIndicIdByIndex(i); + indicType = GetOCStationIndicType(ocid, indicId); + indicState = GetOCStationIndicState(ocid, indicId); + if (INDICATOR_SHOW_YES == indicState) + { + indicState = CLOASE_STATE; + } + else + { + indicState = BREAK_STATE; + } + + switch (indicType) + { + case INDIC_POWER_I_1: + reval = reval | indicState; + break; + case INDIC_POWER_I_2: + reval = reval | (indicState << 2); + break; + case INDIC_POWER_II_1: + reval = reval | (indicState << 4); + break; + case INDIC_POWER_II_2: + reval = reval | (indicState << 6); + break; + default: + break; + } + } + } + return reval; +} +#endif + +/* +* תCiATSжǣת޻Ŀ״̬Ϣ +* ˵ +* UINT8 *wDataLength, ݵַ +* +* OcToATSSwitchZzjData *ciSendAtsSwitchZzjData, ״̬ +* ֵ ǣ +* by cgh 20230918 ɶߵת޻ʾ +*/ +UINT16 TransCiToAtsSwitchZzjInfo(OcToATSSwitchZzjData* ciSendAtsSwitchZzjData, UINT8* wDataLength) +{ + UINT16 wSwitchNum = 0U; /*ǣ*/ + UINT8 kk = 0U;/*OC ID*/ + UINT16 ii = 0U;/*豸*/ + UINT8 jj = 0U;/*Ӧת޻*/ + UINT8 mm = 0U;/*״̬ĿʱжǷ쳣ѭ*/ + UINT8 chSwitchDriveFlag = 0U;/*־*/ + + if ((NULL != ciSendAtsSwitchZzjData) + && (NULL != wDataLength)) + { + kk = *wDataLength; + for (ii = 0U; ii < m_OcToCiOrginDataArr[kk].OcDeviceNum; ii++) + { + if (OC_DEVICE_TYPE_SWITCH == m_OcToCiOrginDataArr[kk].OcDevices[ii].DeviceType) + { + /*豸ǵŴж߼*/ + if (1U < m_OcToCiOrginDataArr[kk].OcDevices[ii].chSwitchIncldeZzjNum) + { + /*Ӧת޻Ŀ1˵Ƕǣ,״̬*/ + ciSendAtsSwitchZzjData[wSwitchNum].wSwitchId = m_OcToCiOrginDataArr[kk].OcDevices[ii].DeviceId; + ciSendAtsSwitchZzjData[wSwitchNum].chSwIncludeZzjSum = m_OcToCiOrginDataArr[kk].OcDevices[ii].chSwitchIncldeZzjNum; + if ((OC_SWITCH_POSITION_DINGWEI == m_OcToCiOrginDataArr[kk].OcDevices[ii].DeviceState) + || (OC_SWITCH_POSITION_FANWEI == m_OcToCiOrginDataArr[kk].OcDevices[ii].DeviceState) + || (OC_SWITCH_POSITION_MOVE == m_OcToCiOrginDataArr[kk].OcDevices[ii].DeviceState)) + { + /*1OCCIĵǰ״̬Ϊλλʱ˵Ӧת޻״̬ҲǶλ߷λʱ޹ + 2OCCIĵǰ״̬ΪƶУʱת޻״̬ΪĿʱжΪϣʱ޹*/ + for (jj = 0U; jj < m_OcToCiOrginDataArr[kk].OcDevices[ii].chSwitchIncldeZzjNum; jj++) + { + ciSendAtsSwitchZzjData[wSwitchNum].szSwitchIncldeZzjState[jj] = OC_TO_ATS_SWITCH_ZZJ_NORMAL; + } + + } + else if(OC_SWITCH_POSITION_UNKNOW == m_OcToCiOrginDataArr[kk].OcDevices[ii].DeviceState) + { + /*OCCIĵǰ״̬Ϊδ֪öӦת޻״̬Ϊ,δ֪״̬ᵥһת޻*/ + for (jj = 0U; jj < m_OcToCiOrginDataArr[kk].OcDevices[ii].chSwitchIncldeZzjNum; jj++) + { + ciSendAtsSwitchZzjData[wSwitchNum].szSwitchIncldeZzjState[jj] = OC_TO_ATS_SWITCH_ZZJ_ALARM; + } + } + else + { + /*OCCIĵǰ״̬ΪĿ*/ + for (jj = 0U; jj < m_OcToCiOrginDataArr[kk].OcDevices[ii].chSwitchIncldeZzjNum; jj++) + { + if ((OC_SWITCH_POSITION_FANWEI == m_OcToCiOrginDataArr[kk].OcDevices[ii].szSwitchIncldeZzjState[jj]) + || ((OC_SWITCH_POSITION_DINGWEI == m_OcToCiOrginDataArr[kk].OcDevices[ii].szSwitchIncldeZzjState[jj]))) + { +#if 0 + /*һת޻״ֹ̬һת޻״̬Ϊ ͬʱת޻·ƵλֻɼأɼλڣҪжΪϣδ֪쳣ȫͨŰӦ߼δ֪״̬ᵥһת޻֣*/ + for (mm = 0U; mm < m_OcToCiOrginDataArr[kk].OcDevices[ii].chSwitchIncldeZzjNum; mm++) + { + if (((UINT8)(~m_OcToCiOrginDataArr[kk].OcDevices[ii].szSwitchIncldeZzjState[jj]) == m_OcToCiOrginDataArr[kk].OcDevices[ii].szSwitchIncldeZzjState[mm]) + || (OC_SWITCH_POSITION_UNKNOW == m_OcToCiOrginDataArr[kk].OcDevices[ii].szSwitchIncldeZzjState[mm])) + { + break; + } + } + if (m_OcToCiOrginDataArr[kk].OcDevices[ii].chSwitchIncldeZzjNum == mm) + { + /*ûת޻뱾ת޻״̬෴,ת޻״̬Ϊ*/ + ciSendAtsSwitchZzjData[wSwitchNum].szSwitchIncldeZzjState[jj] = OC_TO_ATS_SWITCH_ZZJ_NORMAL; + } + else + { + /*ת޻뱾ת޻״̬෴,ת޻״̬Ϊ*/ + ciSendAtsSwitchZzjData[wSwitchNum].szSwitchIncldeZzjState[jj] = OC_TO_ATS_SWITCH_ZZJ_ALARM; + } +#endif + /*18.0ǣ޸ λΪ*/ + ciSendAtsSwitchZzjData[wSwitchNum].szSwitchIncldeZzjState[jj] = OC_TO_ATS_SWITCH_ZZJ_NORMAL; + } + else + { + chSwitchDriveFlag = GetSwitchDrivedFlag(m_OcToCiOrginDataArr[kk].OcDevices[ii].DeviceId); + if (SWITCH_DRIVED_FLAG_YES == chSwitchDriveFlag) + { + /*ȡת޻״̬Ϊ*/ + ciSendAtsSwitchZzjData[wSwitchNum].szSwitchIncldeZzjState[jj] = OC_TO_ATS_SWITCH_ZZJ_NORMAL; + } + else + { + /*ûĿת޻״̬Ϊ*/ + ciSendAtsSwitchZzjData[wSwitchNum].szSwitchIncldeZzjState[jj] = OC_TO_ATS_SWITCH_ZZJ_ALARM; + } + + } + } + } + wSwitchNum++; + } + else + { + ; /*Ӧת޻ĿΪ0.Ƕǣ*/ + } + + } + else + { + ; /*źŻ޴˽ӿڣ*/ + } + } + } + return wSwitchNum; +} + + +/* +* תCiATSԴ/Դģ״̬ʾϢ +* ˵ +* UINT8 ciToXianDiData, CIֵϢ +* UINT8 MoveNum λ +* UINT8 powerState Դ/Դģ״̬ +* UINT8 BitValY ifҪƵĺֵ +* UINT8 BitValN ifҪƵĺֵ +* +* +* ֵ ת +*/ +static UINT8 TransCiToAtsPowerModeState(UINT8 ciToXianDiData, UINT8 MoveNum, UINT8 powerState, UINT8 BitValY, UINT8 BitValN) +{ + UINT8 TransCiSendData = 0u; + + if (CI_SUCCESS == powerState) + {/*Դ/Դģ ״̬ʾ*/ + TransCiSendData = ciToXianDiData | ((UINT8)(BitValY << MoveNum)); + } + else + { + TransCiSendData = ciToXianDiData | ((UINT8)(BitValN << MoveNum)); + } + + return TransCiSendData; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackAtsData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackAtsData.h new file mode 100644 index 0000000..f610676 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackAtsData.h @@ -0,0 +1,373 @@ +/******************************************************** +* +* ParseAtsData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* ATSݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_ATS_DATA_H_ +#define _PARSE_ATS_DATA_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "ParsePackCiData.h" +#include "ParsePackLeuData.h" +#include "ParsePackOcData.h" +#if 0 +#include "ParsePackZcData.h" +#endif +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../System/CiSystemDefine.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../Indicator/IndicatorDataManage.h" +#include "CbtcVersion.h" +#include "../DataManage/PlatDataManage.h" + +#define DUAL_WAY_AIR_SWITCH_NORMAL ((UINT8)0x55) /*˫·տ*/ +#define DUAL_WAY_AIR_SWITCH_ABNORMAL ((UINT8)0xFF) /*˫·տ쳣*/ +#define SINGLE_WAY_AIR_SWITCH_ABNORMAL ((UINT8)0xAA) /*·տ쳣*/ +#define DUAL_WAY_AIR_SWITCH_NORMAL_ATS ((UINT8)0x01) /*˫·տ*/ +#define DUAL_WAY_AIR_SWITCH_ABNORMAL_ATS ((UINT8)0x03) /*˫·տ쳣*/ +#define SINGLE_WAY_AIR_SWITCH_ABNORMAL_ATS ((UINT8)0x02) /*·տ쳣*/ + +#define AirFan_NORMAL ((UINT8)0x55) /**/ +#define AirFan_ABNORMAL ((UINT8)0xFF) /*ȹ*/ +#define AirFan_Fault ((UINT8)0xAA) /*쳣*/ +#define AirFan_NORMAL_ATS ((UINT8)0x01) /**/ +#define AirFan_ABNORMAL_ATS ((UINT8)0x03) /*ȹ*/ +#define AirFan_Fault_ATS ((UINT8)0x02) /*쳣*/ + +#define OC_CARD_NORMAL ((UINT8)0x55) /*OC忨*/ +#define OC_CARD_ABNORMAL ((UINT8)0xFF) /*OC忨*/ +#define OC_CARD_NORMAL_ATS ((UINT8)0x55) /*ATSӿ:OC忨*/ +#define OC_CARD_ABNORMAL_ATS ((UINT8)0xAA) /*ATSӿ:OC忨*/ + +#define TYPE_POINT_SWITCH ((UINT8)0xAA) /*Ϊת޻*/ +#define TYPE_SIGNAL ((UINT8)0x55) /*ΪźŻ*/ + +#define FUSE_NORMAL ((UINT8)0x55) /*ת޻źŻޱ*/ +#define SIGNAL_FUSE_ALARM ((UINT8)0xAA) /*źŻִе˿*/ +#define POINT_SWITCH_FUSE_ALARM ((UINT8)0xCC) /*ת޻ִе˿ͱʾ˿*/ +#define POINT_SWITCH_EXECUTIVE_FUSE_ALARM ((UINT8)0x5A) /*ת޻ִе˿,ʾ*/ +#define POINT_SWITCH_EXPRESSED_FUSE_ALARM ((UINT8)0xA5) /*ת޻ʾ˿,ִ*/ + +#define HIGH_NORMAL ((UINT8)0x50) /*λ0x5ִе˿*/ +#define HIGH_ALARM ((UINT8)0xA0) /*λ0xAִе˿*/ +#define LOW_NORMAL ((UINT8)0x05) /*λ0x5ʾ˿*/ +#define LOW_ALARM ((UINT8)0x0A) /*λ0xAʾ˿*/ + +#define OC_TO_ATS_SWITCH_ZZJ_NORMAL ((UINT8)0x55) /*OCATSĶǣӦ״̬-*/ +#define OC_TO_ATS_SWITCH_ZZJ_ALARM ((UINT8)0xAA) /*OCATSĶǣӦ״̬-*/ + +/*ִеϢ*/ +typedef struct s_PlusBoxDataSendATS +{ + UINT8 chPbId; /*ִе*/ + UINT8 SendAtsAsState; /**/ +}OcToATSPlusBox; + +/*֡ṹ*/ +typedef struct S_CommandDataStruct +{ + UINT8 CommandType; /**/ + UINT32 CommandId; /*ID*/ + UINT32 CommandParam; /**/ + UINT16 termial_id; /*նID*/ + UINT8 order_type; /**/ + UINT8 response_type; /*ظ*/ + UINT8 affirm_result; /*ȷϽ*/ + UINT8 firstCmd_time; /*һʱ*/ + UINT32 setCurNum; /*һں*/ + UINT8 VirCIid;/*ID*/ + /*¼*/ + UINT16 wTrainIdParam; /*гID 20220301*/ + UINT8 chLogicSecSum; /*߼ 20220301*/ + UINT16 wLogicSecData[MAX_ROUTE_IN_LT_NUM];/*߼ 20220301*/ + UINT8 OCid;/*OC ID*/ + UINT16 OverLapRouteID; /*ι·ID 20240319*/ + +} CommandDataStruct; + +/*ǣӦת޻Ϣ*/ +typedef struct s_SwitchZzjDataSendATS +{ + UINT16 wSwitchId; /*ID*/ + UINT8 chSwIncludeZzjSum; /*Ӧת޻Ŀ*/ + UINT8 szSwitchIncldeZzjState[MAX_OC_SWITCH_INCLUDE_ZZJ_NUM]; /*ATSĵӦת޻״̬*/ +}OcToATSSwitchZzjData; + +#ifdef __cplusplus +extern "C" { +#endif + +/*******************************ȫֱ*******************************/ +extern CommandDataStruct CiRevCmdDataStru[ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX]; /*CIṹ*/ +extern UINT16 CiRevCmdStruCurSum; +extern CommandDataStruct ATSorXDToCiCmdRtnToTRDataStru[ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX]; +extern UINT16 ATSorXDToCiCmdReturnToTRCurSum; +extern CommandDataStruct CiSendCmdDataStru[CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX]; +extern UINT16 CiSendCmdStruCurSum; +extern CommandDataStruct CiSendBackDataTempStru[CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX]; +extern UINT16 CiSendBackDataTempStruSum; +extern UINT8 LastCmdSourceSysType; +extern UINT32 FirstCmdId; /*״βȷϵID*/ + +/* +* ֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseAtsOrXianDiToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength); + +/* +* ATSֵ +* ˵ +* const UINT8 deviceId, ĿϵͳID +* const UINT8 targetDevType, Ŀϵͳ +* const UINT8 frame,֡ +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 PackCiToAtsOrXianDiData( const UINT8 deviceId, const UINT8 targetDevType,const UINT8 frame); + +/* +* ȡCIյIJṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: CIղṹ鳤 +*/ +UINT16 GetCiRevCmdStruCurSum(void); + +/* +* ȡCIյIJṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIղṹָ +*/ +CommandDataStruct* GetCiRevCmdDataStruct(void); + +/* +* CI +* ˵ const UINT32 CommandId, ID +* const UINT8 CommandType, +* const UINT16 DeviceId, 豸ID +* const UINT8 commandParam, +* const UINT32 commandId, ID +* ֵ void +*/ +void SetCiSendCmdBackInfoData(const UINT8 CommandType, const UINT8 deviceType, const UINT16 deviceId, const UINT8 commandParam, const UINT32 commandId); + +/* +* CIݴгID +* ˵ const UINT32 CommandId, ID +* const UINT8 CommandType, +* const UINT16 DeviceId, 豸ID +* const UINT8 commandParam, +* const UINT32 commandId, ID +* const UINT16 TrainId,гID +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetCiSendCmdBackInfoWithTrainId(const UINT8 CommandType, const UINT8 deviceType, const UINT16 deviceId, const UINT8 commandParam, const UINT32 commandId, const UINT16 trainId); + +/* +* һζŻ +* ˵ const UINT32 CommandId, ID +* const UINT8 CommandType, +* const UINT16 DeviceId, 豸ID +* const UINT8 commandParam, +* const UINT32 commandId, ID +* ֵ +*/ +void SetCiSendCmdBackData_OrderBack( const UINT32 commandId,const UINT16 deviceId, const UINT8 deviceType,const UINT16 termial_id, const UINT8 order_type, const UINT8 response_type,const UINT8 affirm_result,const UINT8 virCIid); +/* +* һʱ +* ˵ +* ֵ +*/ +void UpdataCiSendCmdBack_OrderBack(void); +/* +* CIݶ +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +void ClearCiRevCmdData(void); + +/* +* CIݶ +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +void ClearCiSendCmdData(void); + +/* +* ȡ״βȷϵID +* ˵ void +* ֵ ״βȷϵID +*/ +UINT32 GetFirstCmdId(void); + +/* +* ״βȷϵID +* ˵ const UINT32 cmdId, ID +* ֵ void +*/ +void SetFirstCmdId(const UINT32 cmdId); + +/* +* ȡCIյATSֵźؿṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: CIATSֵźؿṹ鳤 +*/ +UINT16 GetATSToCiCmdRtnToTRCurSum(void); + +/* +* ȡCIյATSֵźؿṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: CIATSֵźؿṹָ +*/ +CommandDataStruct* GetATSorXDToCiCmdRtnToTRData(void); + +/* +* źؿṹУɾָλõ +* ˵ const UINT16 idx:źؿṹλ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 RemoveReturnToTRCmdAt(const UINT16 idx); + +/* +* źؿϢṹ +* ˵ const CommandDataStruct* src:Ƶźؿṹָ + CommandDataStruct* dst:Ŀźؿṹָ +* ֵ +*/ +void CopyReturnToTRCmd(const CommandDataStruct* src,CommandDataStruct* dst); + +/* +* ȡȷPSC־ +* ˵ UINT8 pscId, PSCϵͳID +* +* ֵ 0: δû +* >0: û +*/ +UINT8 GetPscConfirmFlag(UINT8 pscId); +/* +* psdʱ +* ˵ +* +* ֵ +* cgh-ϲCID-3037-2 +*/ +void PsdDriveOutTimeToAts(void); +/* +* ȡӦһ +* ˵ +* +* ֵ һ +*/ +UINT8 FindFirstOrder(UINT8 SecondOrder); +/* +* ЧԼ +* ˵ 豸ID,豸ͣնID,ն +* ֵ CI_ERROR : ʧ +* CI_SUCCESS: ɹ +*/ +UINT8 CheckSecondOrderValid(const UINT32 commandId,const UINT16 deviceId, const UINT8 deviceType,const UINT16 termial_id, const UINT8 order_type,const UINT8 virCiID); +/* +* CIݴIJҪ +* ˵ void +* ֵ +*/ +void ClearCiSendBackDataTempStruData(void); +/* +* һʱ +* ˵ +* ֵ +*/ +void SetCiSendCmdBack_FstOrdOutTime(const UINT32 commandId,const UINT16 deviceId, const UINT8 deviceType,const UINT8 order_type,const UINT16 termial_id,UINT8 virCIid); +/* +* ֵػATSķID߱ID +* ˵ void +* ֵ +*/ +void AddCiSendBackDataCIid(void); + +/* +* ATS/ֵصܳЧ +* ˵ const UINT8* pdataBuf, ݻ +* const UINT16 comSum, ֡ +* const UINT16 comTotalLen, ܳ +* ֵ CI_ERROR Ч +* CI_SUCCESS Ч +*/ +UINT8 CheckATSorXiandTotalDataLenVal(const UINT8* pdataBuf, const UINT16 comSum, const UINT16 comTotalLen); + +/* +* Ϣת +* ˵ const UINT32 CommandId, ID +* const UINT8 CommandType, +* const UINT16 DeviceId, 豸ID +* const UINT8 virCIid, ID +* ֵ 0: ʧ +* 1: óɹ +* cgh-ϲCID-2349-5 +*/ +void errorCodeDataTransCmdBack(const UINT8 CommandType, const UINT8 deviceType, const UINT16 deviceId, const UINT8 virCIid); + +/* +* תCiATSOCbyteִе״̬Ϣ +* ˵ +* UINT8 *dataLength, ݵַ +* +* OcToATSPlusBox *ciSendATSPlusBox, ״̬ +* +* ֵ ִе +*/ +UINT8 TransCiToAtsOCPlusBoxInfo(OcToATSPlusBox *ciSendATSPlusBox, UINT8 *wDataLength); + +/* +* תCiATSжǣת޻Ŀ״̬Ϣ +* ˵ +* UINT8 *wDataLength, ݵַ +* +* OcToATSSwitchZzjData *ciSendAtsSwitchZzjData, ״̬ +* ֵ ǣ +*/ +UINT16 TransCiToAtsSwitchZzjInfo(OcToATSSwitchZzjData* ciSendAtsSwitchZzjData, UINT8* wDataLength); + +/* +* תCiATSԴ/Դģ״̬ʾϢ +* ˵ +* UINT8 ciToXianDiData, CIֵϢ +* UINT8 MoveNum λ +* UINT8 powerState Դ/Դģ״̬ +* UINT8 BitValY ifҪƵĺֵ +* UINT8 BitValN ifҪƵĺֵ +* +* +* ֵ ת +*/ +static UINT8 TransCiToAtsPowerModeState(UINT8 ciToXianDiData, UINT8 MoveNum, UINT8 powerState, UINT8 BitValY, UINT8 BitValN); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackAxleData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackAxleData.c new file mode 100644 index 0000000..61adf37 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackAxleData.c @@ -0,0 +1,956 @@ +/******************************************************** +* +* ParsePackIoData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* IOݽ +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackAxleData.h" +#include "dquCIInit.h" +#include "HLHTCommonDataPacketHead.h" +#include "HLHTHeadContexManage.h" +#include "dsuRsspFunc.h" +#include "protclStruct.h" +#include "../QueryFiles/dquCIInterFace.h" + +#define PHY_SEC_RESET_CMD (0x0DU) /*ֱӸλ*/ +#define PHY_SEC_PRE_RESET_CMD (0x0EU) /*Ԥλ*/ +#define GAL_INTERFACE ((UINT16)0x060A) /*GALӿϢ*/ +#define GAL_PRTCL_VER ((UINT8)0x01) /*GALЭ汾*/ +#define GAL_DATA_VER ((UINT32)0x01000000) /*GALݰ汾УϢ*/ +#define AXISDATASTR_IDX ((UINT8)0xFF) /*axisDataStrЧλ*/ + +AxisToCiDataStruct axisToCiDataStru[AXIS_TO_CI_SUM_MAX] = {0u}; /*AxisCI֡ṹ*/ +static DSU_RSSP_INFO_STRU_WL dsuRsspInfo = { 0 }; /*RSSPIѯϢ*/ + +static UINT8 GalHeadCheck(const UINT32 localEtcsId, const UINT32 remoteEtcsId, const UINT16 devInterfaceType, const UINT8 prtrlVer, const UINT32 dataVer, HLHTGALInfoStruct* pMICommonPackage, UINT32* pErrorCode); +static UINT8 GetRsspiAddr(const UINT16 locTypeId, const UINT16 oppTypeId, UINT16* locRsspiAddr, UINT16* oppRsspiAddr); +static UINT8 GetPhySecIdxInAxisDataStr(const UINT8 axleId, const UINT16 phySecId, UINT8* axisDataStrIdx); + +extern ProtclConfigInfoStru gCbtcData; /*ͨЭṹ*/ +/* +* ͨŲɼ +* ˵ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +#if 0 + + +UINT8 ParseAxisToCiData() +{ + QueueStruct* AxisToCiDataQueue = Get2oo2AxisToCiDataQueue(); + + if (AxisToCiDataQueue != NULL) + { + UINT32 dataQueueTotalLen = 0u; /*ܳ*/ + UINT8 dataLenBuf[2]; /*ݳ*/ + UINT8 tempDataBuf[5000]; /*ʱ*/ + UINT16 appDataLen = 0u; /*һ֡ݳ*/ + UINT8 tempBuf[2]; /*ʱ*/ + UINT8 axisId = 1u; /*ʵ*/ /*Axis*/ + + /*ȡܳ*/ + dataQueueTotalLen = QueueStatus(AxisToCiDataQueue); + + while (dataQueueTotalLen > 0u) + { + QueueScan(2, dataLenBuf, AxisToCiDataQueue); + + appDataLen = (UINT16) (ShortFromChar(dataLenBuf) + 2u); /*ȡ֡ݳ*/ + + if ((dataQueueTotalLen >= appDataLen) && (appDataLen > 2u)) + { + /*ǰ2ֽ*/ + QueueRead(2, tempBuf, AxisToCiDataQueue); + + /*Ӷжһ֡*/ + QueueRead(appDataLen-2, tempDataBuf, AxisToCiDataQueue); + +#ifdef LOGPRINT + + debug_infor_printf((const)"\nAXIS_RECV:%d", appDataLen - 2); + debug_out_array(0xAA, tempDataBuf, appDataLen - 2); + +#endif + /*AXISCI֡*/ + if (CI_ERROR == ParseAxisToCiDataFrame(tempDataBuf, (UINT16)(appDataLen-2), axisId)) + { + ClearAxisData();/*Axis*/ + } + } + else + { + break; + } + + /*ȡܳ*/ + dataQueueTotalLen = QueueStatus(AxisToCiDataQueue); + + } + + if (dataQueueTotalLen > 0u) + { + QueueClear(AxisToCiDataQueue); /**/ + + return CI_ERROR; + } + else + { + return CI_SUCCESS; + } + + } + else + { + return CI_ERROR; + } +} +#endif + +/* +* ʼᵽCIݽṹaxisToCiDataStru +* ˵ +* ֵ CI_ERROR: ʼʧ +* CI_SUCCESS: ʼɹ +*/ +UINT8 InitAxleToCiDataStru(void) +{ + UINT8 rtn = CI_ERROR; /*ֵ*/ + UINT8 deviceSum = 0u; /*豸*/ + UINT8* deviceIdBuf = NULL; /*豸ID*/ + UINT8 i = 0u; /*ѭ*/ + UINT8 j = 0u; /*ѭ*/ + UINT8 ciId = 0u; /*CI ID*/ + UINT8 axleId = 0u; /*ID*/ + UINT16 axleName = 0u; /*豸ƣ+ID*/ + UINT16 ciName = 0u; /*豸ƣ+ID*/ + UINT32 axieEtcsId = 0u; /*ụͨID*/ + UINT32 ciEtcsId = 0u; /*CIͨID*/ + UINT16 phySecCurSum = 0u; /*Ŀ*/ + UINT16 phySecId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*ID*/ + UINT8 belongAxleSysId = 0u; /*ID*/ + UINT16 axlePhySecSum = 0u; /*ϵͳĿ*/ + UINT8 pyhIsThisLine = 0u; + UINT8 cPrtclVerBtwCiAndAxle = 0U; /*ͼЭУ汾*/ + + ciId = GetSystemParaLocalCiId(); + ciName = (CI_SYSTEM_TYPE_CI) * 256U + ciId; + rtn = DsuRsspInitWl((const)DataPath,0,NULL,ciName, 0, &dsuRsspInfo); + if (CI_SUCCESS == rtn) + { + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); /*ȡͨAxis豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); /*ȡͨAxis豸ID*/ + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + { + phySecCurSum = GetPhySecCurSum(); + for (i = 0u; i < deviceSum; i++) /*ͨŵļϵͳ*/ + { + axleId = deviceIdBuf[i]; + axleName = (CI_SYSTEM_TYPE_AXIS) * 256u + axleId; + cPrtclVerBtwCiAndAxle = GetCiAndAxisPrtclCheckVer(); /*ȡЭУ汾*/ + + if (20U <= cPrtclVerBtwCiAndAxle) + { + rtn = dquDevName2HlhtId(axleName, 0U, &axieEtcsId); /*ȡụͨID*/ + rtn &= dquDevName2HlhtId(ciName, 0U, &ciEtcsId); /*ȡCIͨID*/ + } + else + { + /*ʹ豸IDΪͨID*/ + rtn = GetRsspiAddr(axleName, ciName, &axieEtcsId, &ciEtcsId); + } + + if (CI_SUCCESS == rtn) /*GAL㻥ͨIDȡɹ*/ + { + if(axleId>=AXIS_TO_CI_SUM_MAX) + { + break;/*룬ֹԽ*/ + } + axisToCiDataStru[axleId].deviceType = CI_SYSTEM_TYPE_AXIS; + axisToCiDataStru[axleId].axisSystemId = deviceIdBuf[i]; + axisToCiDataStru[axleId].axisEtcsId = axieEtcsId; + axisToCiDataStru[axleId].ciEtcsId = ciEtcsId; + + (void)memset(axisToCiDataStru[axleId].PhySecIdx, (INT)AXISDATASTR_IDX, PHYSICAL_SECTION_SUM_MAX); /*Ĭ±ΪЧλ*/ + for (j = 0u; j < phySecCurSum; j++) /**/ + { + phySecId = GetPhySecId(j); + belongCiId = GetPhySecBelongCiId(phySecId); + belongAxleSysId = GetPhySecBelongAxisSysId(phySecId); + pyhIsThisLine = GetPhyIsThisLineState(phySecId); /*Ƿ·*/ + if ((0U < phySecId) && (phySecId < PHYSICAL_SECTION_SUM_MAX) && (belongCiId == ciId) + && (belongAxleSysId == axleId) && (DEV_IS_THIS_LINE_YES == pyhIsThisLine)) + { + axlePhySecSum = axisToCiDataStru[axleId].SectionSum; + + if (CI_INCLUDE_AXIS_MAX_SUM > axlePhySecSum) + { + axisToCiDataStru[axleId].axisDataStr[axlePhySecSum].PhySecId = phySecId; + axisToCiDataStru[axleId].axisDataStr[axlePhySecSum].gdRelayState = RELAY_STATE_DOWN; + axisToCiDataStru[axleId].axisDataStr[axlePhySecSum].faultInfo = 0u; + axisToCiDataStru[axleId].axisDataStr[axlePhySecSum].showAndReplyInfo = 0u; + axisToCiDataStru[axleId].axisDataStr[axlePhySecSum].PreResetRst = RELAY_STATE_DOWN; + axisToCiDataStru[axleId].axisDataStr[axlePhySecSum].State = RELAY_STATE_DOWN; + + axisToCiDataStru[axleId].PhySecIdx[phySecId] = (UINT8)(axlePhySecSum); + + axisToCiDataStru[axleId].SectionSum++; + } + else /**/ + { + rtn = CI_ERROR; + break; + } + } + } + } + } + } + else + { + rtn = CI_SUCCESS; + } + } + if (CI_ERROR == rtn) + { + debug_infor_printf((const)"InitAxleToCiDataStru fail.\r\n"); + } + + return rtn; +} + +/* +* ͨŲɼ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseAxisToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId) +{ + UINT8 retVal = CI_ERROR; + UINT8 deviceSum = 0u; /*豸*/ + UINT8* deviceIdBuf = NULL; /*豸ID*/ + UINT16 ii = 0u; /*ѭ*/ + UINT16 jj = 0u; /*ѭ*/ + UINT8 findFlag = 0u; /*ҵ־*/ + UINT8 localCiId = 0u; /*CI ID*/ + UINT32 curCycleNo = 0u; /*ǰں*/ + UINT8 acFty = 0u; /*ϵͳ*/ + HLHTGALInfoStruct hlhtGalHead = { 0u }; /*ͨGALͷ*/ + UINT8 headRet = HLHT_HEAD_ERROR;/*ͨ*/ + UINT32 errCode = 0u; /*GALͷ*/ + INT32 remainValidiy = 0; /*ʣʱǷЧ*/ + UINT8 axisDataStrIdx = AXISDATASTR_IDX; /*axisDataStrλ*/ + UINT8 phySecNum = 0u; /**/ + UINT16 curPhySecId = 0u; /*ǰID*/ + UINT8 galPrtclVer = 0u; /*Э汾*/ + UINT32 galAxisDataVer = 0u; /*ϵͳݰ汾*/ + UINT32 ciAndAxisTimeOutCout = 0u; /*ͨж*/ + UINT32 ciCurappCycleTime = 0u; /*ǰ*/ + UINT16 axisDevName = 0u; /*ƣ+ID*/ + + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); /*ȡͨAxis豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); /*ȡͨAxis豸ID*/ + axisDevName = (CI_SYSTEM_TYPE_AXIS) * 256U + systemId; + localCiId = GetSystemParaLocalCiId(); + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + { + for (ii = 0u; ii < deviceSum; ii++) /*ͨŵļϵͳ*/ + { + if (deviceIdBuf[ii] == systemId) /*ҵ*/ + { + for (jj = 0u; jj < axisToCiDataStru[systemId].SectionSum; jj++) /*ȫ״̬*/ + { + axisToCiDataStru[systemId].axisDataStr[jj].gdRelayState = RELAY_STATE_DOWN; + axisToCiDataStru[systemId].axisDataStr[jj].faultInfo = 0u; + axisToCiDataStru[systemId].axisDataStr[jj].showAndReplyInfo = 0u; + axisToCiDataStru[systemId].axisDataStr[jj].PreResetRst = RELAY_STATE_DOWN; + axisToCiDataStru[systemId].axisDataStr[jj].State = RELAY_STATE_DOWN; + } + + findFlag = 1u;/*ҵ־*/ + } + } + } + + if (1u == findFlag) + { + retVal = CI_SUCCESS; + curCycleNo = Get2oo2CurCycleNum(); + + ii = 0u; /*±*/ + + /*ͨϢͷ*/ + hlhtGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.sourceId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.destId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.comPeriod = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.prtclVer = dataBuf[ii++]; + hlhtGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]); + ii += 2u; + galPrtclVer = GetCiAndAxisPrtclCheckVer(); /*ȡϵͳЭ汾*/ + galAxisDataVer = GetCiTranAxisDataCheckVer(localCiId, axisDevName); /*ȡϵͳݰ汾*/ + headRet = GalHeadCheck(axisToCiDataStru[systemId].axisEtcsId, axisToCiDataStru[systemId].ciEtcsId, GAL_INTERFACE, galPrtclVer, galAxisDataVer, &hlhtGalHead, &errCode); + debug_infor_printf((const)"\nAXLE %d GAL Check Result:%d errCode:%d", systemId, headRet, errCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + if (HLHT_HEAD_SUCCESS == headRet) + { + ciAndAxisTimeOutCout = GetCiAndAxleTransBadEnsureTime(); + ciCurappCycleTime = GetSystemParaAppCycleTime(); + /*ϢʱЧ*/ + remainValidiy = HLHTCommonMsgRemainingValidity(ciAndAxisTimeOutCout, curCycleNo, ciCurappCycleTime, hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN, hlhtGalHead.comPeriod); + + if (remainValidiy > 0) /*Ч*/ + { + acFty = GetCiFunctionSwitchConfig(FUNC_SWITCH_AC_FACTORY); + if (AXIS_TYPE_YONGLIE == acFty) + { + if(systemId < AXIS_TO_CI_SUM_MAX) + { + if (axisToCiDataStru[systemId].deviceType != dataBuf[ii++]) /*豸ж*/ + { + retVal = CI_ERROR; + } + if (axisToCiDataStru[systemId].axisSystemId != dataBuf[ii++])/*ԴţĬ01*/ + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + if (CI_SUCCESS == retVal) + { + phySecNum = dataBuf[ii++]; /*ȡ*/ + for (jj = 0u; jj < phySecNum; jj++) + { + curPhySecId = ShortFromCharLE(&dataBuf[ii]); /*ȡID*/ + retVal = GetPhySecIdxInAxisDataStr(systemId, curPhySecId, &axisDataStrIdx); + ii += 2u; + if (CI_SUCCESS == retVal) + { + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].gdRelayState = dataBuf[ii++]; /*̵״̬*/ + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].showAndReplyInfo = dataBuf[ii++]; /*ʾϢͷϢ*/ + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].faultInfo = dataBuf[ii++]; /*Ϣ*/ + } + else /*ƫ3ֽ*/ + { + ii += 3u; + } + /*Ԥ*/ + ii += 1u; + } + + retVal = CI_SUCCESS; + } + + } + else if (AXIS_TYPE_KEANDA == acFty) + { + if (0x0BU == dataBuf[ii++]) + { + phySecNum = dataBuf[ii++]; /*ȡ*/ + if(AXIS_TO_CI_SECTION_SUM_MAX > phySecNum) + { + for (jj = 0u; jj < phySecNum; jj++) + { + curPhySecId = ShortFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 2u; + retVal = GetPhySecIdxInAxisDataStr(systemId, curPhySecId, &axisDataStrIdx); + if (CI_SUCCESS == retVal) + { + if (0x03u == ((dataBuf[ii] >> 3u) & 0x03u)) /*Ԥλɹ*/ + { + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].PreResetRst = RELAY_STATE_UP; + } + else if (0x02u == ((dataBuf[ii] >> 3u) & 0x03u)) /*δȷյԤλ*/ + { + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].PreResetRst = RELAY_STATE_DOWN; + } + else /**/ + { + retVal = CI_ERROR; /*Ԥλ״̬Ƿʧ*/ + } + + if (0x01u == ((dataBuf[ii] >> 2u) & 0x01u)) /**/ + { + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].State = RELAY_STATE_DOWN; + } + else /*Ĭ״̬*/ + { + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].State = RELAY_STATE_UP; + } + + if (0x02u == (dataBuf[ii] & 0x03u)) /**/ + { + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].gdRelayState = RELAY_STATE_UP; + } + else /*ռ*/ + { + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].gdRelayState = RELAY_STATE_DOWN; + } + } + ii += 1u; + + if (CI_SUCCESS != retVal) + { + retVal = CI_ERROR; + break; /*ʧܣֹͣʧ*/ + } + else + { + /**/ + } + } + } + else /*һϵͳ͵ֵ*/ + { + /*ΰȫദ*/ + for (jj = 0u; jj < phySecNum; jj++) + { + curPhySecId = ShortFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 2u; + retVal = GetPhySecIdxInAxisDataStr(systemId, curPhySecId, &axisDataStrIdx); + if (CI_SUCCESS == retVal) + { + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].PreResetRst = RELAY_STATE_DOWN; + + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].State = RELAY_STATE_UP; + + axisToCiDataStru[systemId].axisDataStr[axisDataStrIdx].gdRelayState = RELAY_STATE_DOWN; + } + ii += 1u; + + } + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else /*Ч*/ + { + retVal = CI_ERROR; + debug_infor_printf((const)"\naxleSys gal check err.axleSysId=%d,remainValidiy=%d,curCycle=%d,RSN=%d,TSN=%d,LTSN=%d", systemId, remainValidiy, curCycleNo, hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN); + } + + if (CI_SUCCESS == retVal) + { + /*ݾУ飬Ҫ洢ͨñ*/ + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_AXIS, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_AXIS, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_AXIS, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_AXIS, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_AXIS, systemId, curCycleNo); + } + } + else if (HLHT_HEAD_INIT == headRet) + { + if (curCycleNo > 0u) + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_AXIS, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_AXIS, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_AXIS, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_AXIS, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_AXIS, systemId, curCycleNo); + } + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + localCiId = GetSystemParaLocalCiId(); + /*ͨ*/ + if (CI_SUCCESS == SetCiTransmitRecvDataCycNum(localCiId, CI_SYSTEM_TYPE_AXIS, systemId, curCycleNo)) + {/*ڳɹ*/ + + /*axisͨ״̬жaxisǷͨж*/ + if (CI_ERROR == UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_AXIS, systemId)) + { + /*ͨ״̬ʧ*/ + } + else + { + /*ͨ״̬ɹ*/ + } + } + } + else + { + /*ռ*/ + for (jj = 0u; jj < axisToCiDataStru[systemId].SectionSum; jj++) /*ȫ״̬*/ + { + axisToCiDataStru[systemId].axisDataStr[jj].gdRelayState = RELAY_STATE_DOWN; + axisToCiDataStru[systemId].axisDataStr[jj].faultInfo = 0u; + axisToCiDataStru[systemId].axisDataStr[jj].showAndReplyInfo = 0u; + axisToCiDataStru[systemId].axisDataStr[jj].PreResetRst = RELAY_STATE_DOWN; + axisToCiDataStru[systemId].axisDataStr[jj].State = RELAY_STATE_DOWN; + } + + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡɼݽṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ɼṹָ +*/ +AxisToCiDataStruct* GetCollAxisDataStruct(void) +{ + return axisToCiDataStru; +} + +/* +* Axis +* ˵ void +* ֵ void +*/ +void ClearAxisData(void) +{ + UINT16 ii = 0u; + UINT16 kk = 0u; + + for (kk=0u;kk axisSysId) + { + retVal = CI_SUCCESS; + } + if (CI_SUCCESS == retVal) + { +#if 0 +#ifdef PLATFORM_2OO2 + /*ͨЭ֡ͷ*/ + ii += 2u; + CiToAxisDataBuffer[ii++] = CI_SYSTEM_TYPE_AXIS;/*ն豸*/ + CiToAxisDataBuffer[ii++] = axisSysId; /*ն豸ID*/ + CiToAxisDataBuffer[ii++] = 0u; /*Ԥ2BYTE*/ + CiToAxisDataBuffer[ii++] = 0u; +#endif +#endif + localCiId = GetSystemParaLocalCiId(); + galPrtclVer = GetCiAndAxisPrtclCheckVer(); + galAxisDataVer = GetCiTranAxisDataCheckVer(localCiId, axisDevName); + ShortToChar(GAL_INTERFACE, &CiToAxisDataBuffer[ii]);/*ӿϢ*/ + ii += 2u; + LongToChar(axisToCiDataStru[axisSysId].ciEtcsId, &CiToAxisDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(axisToCiDataStru[axisSysId].axisEtcsId, &CiToAxisDataBuffer[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(galAxisDataVer, &CiToAxisDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &CiToAxisDataBuffer[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &CiToAxisDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_AXIS, axisSysId), &CiToAxisDataBuffer[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_AXIS, axisSysId), &CiToAxisDataBuffer[ii]);/*յһϢʱк*/ + ii += 4u; + CiToAxisDataBuffer[ii++] = galPrtclVer; /*CI_VOBCӿЭ汾*/ + ii += 2u;/*ͨñͷеӦò㱨ܳ*/ + + acFty = GetCiFunctionSwitchConfig(FUNC_SWITCH_AC_FACTORY); + if (AXIS_TYPE_YONGLIE == acFty) + { + /*ʼӦ֡*/ + CiToAxisDataBuffer[ii++] = Get2oo2SheBeiType();/*Ͷ豸*/ + CiToAxisDataBuffer[ii++] = axisSysId; /**/ + phyCount = axisToCiDataStru[axisSysId].SectionSum; + CiToAxisDataBuffer[ii++] = (UINT8)(phyCount); /**/ + for (jj = 0u; jj < phyCount; jj++) + { + phySecId = axisToCiDataStru[axisSysId].axisDataStr[jj].PhySecId; + + ShortToCharLE(phySecId, &CiToAxisDataBuffer[ii]); + ii += 2u; + + fwCycle = GetPhySecResetStartCycNum(phySecId); + if (0u < fwCycle) + { + relaySta = RELAY_STATE_UP; + if (1U == (axisToCiDataStru[axisSysId].axisDataStr[jj].showAndReplyInfo & 0x01U)) + { + relaySta = RELAY_STATE_DOWN; + } + else + { + } + } + else + { + relaySta = RELAY_STATE_DOWN; + } + CiToAxisDataBuffer[ii++] = relaySta;/*1*/ + CiToAxisDataBuffer[ii++] = 0u;/*2*/ + ii++;/*Ԥ*/ + CiToAxisDataBuffer[ii++] = relaySta;/*1Ό*/ + } + } + else if (AXIS_TYPE_KEANDA == acFty) + { + cmdIdx = ii; /*¼±λ*/ + ii += 1u; + phySumIndex = ii; + phyCount = axisToCiDataStru[axisSysId].SectionSum; + CiToAxisDataBuffer[ii] = (UINT8)(phyCount); + ii += 1u; + for (jj = 0u; jj < phyCount; jj++) + { + phySecId = axisToCiDataStru[axisSysId].axisDataStr[jj].PhySecId; /*ID*/ + ShortToChar(phySecId, &CiToAxisDataBuffer[ii]); /*ID*/ + ii += 2u; + + fwCycle = GetPhySecResetStartCycNum(phySecId); + if (0u < fwCycle) + { + relaySta = RELAY_STATE_UP; + } + else + { + relaySta = RELAY_STATE_DOWN; + } + resetType = GetPhySecSectionResetType(phySecId); + if ((PHYSICAL_SECTION_PRE_RESET_NO == resetType) && (RELAY_STATE_UP == relaySta)) /*ֱӸλ*/ + { + if (PHY_SEC_PRE_RESET_CMD == CiToAxisDataBuffer[cmdIdx]) /*Ԥλ*/ + { + isDiffCmd = 1u; + } + else + { + } + CiToAxisDataBuffer[cmdIdx] = PHY_SEC_RESET_CMD; /*,ֱӸλ*/ + CiToAxisDataBuffer[ii++] = 0x01u; /*·λ*/ + } + else if ((PHYSICAL_SECTION_PRE_RESET_YES == resetType) && (RELAY_STATE_UP == relaySta)) /*Ԥλ*/ + { + if (PHY_SEC_RESET_CMD == CiToAxisDataBuffer[cmdIdx]) /*ֱӸλ*/ + { + isDiffCmd = 1u; + } + else + { + } + CiToAxisDataBuffer[cmdIdx] = PHY_SEC_PRE_RESET_CMD; /*,Ԥλ*/ + CiToAxisDataBuffer[ii++] = 0x01u; /*·Ԥλ*/ + } + else /*Ĭ0x00ָ*/ + { + CiToAxisDataBuffer[ii++] = 0x00u; + } + + } + if (0u == CiToAxisDataBuffer[cmdIdx]) /*ֱӸλԤλ,ĬԤλ,0x00ָ*/ + { + CiToAxisDataBuffer[cmdIdx] = PHY_SEC_PRE_RESET_CMD; + } + else + { + } + + if (1u == isDiffCmd) /*ΪĬԤλ,0x00ָ*/ + { + CiToAxisDataBuffer[cmdIdx] = PHY_SEC_PRE_RESET_CMD; + for (jj = 1u; jj <= phyCount; jj++) + { + CiToAxisDataBuffer[phySumIndex + (2U + 1U) * jj] = 0x00u; + } + } + else + { + } + } + else + { + retVal = CI_ERROR; + } + + /*ͨñͷӦò㱨ܳ*/ + CiToAxisDataBuffer[29] = (UINT8)(((ii - 31U) >> 8u) & 0xffu); + CiToAxisDataBuffer[30] = (UINT8)((ii - 31U) & 0xffu); +#if 0 + /*ݰܳ */ + CiToAxisDataBuffer[0] = (UINT8)(((ii - 2u) >> 8u) & 0xffu); + CiToAxisDataBuffer[1] = (UINT8)((ii - 2u) & 0xffu); + + /*ü̵״̬ע͵CIOCļ̵ᱻ*/ + ClearRelayDriveState(); +#endif + if (CI_TO_AXIS_DATA_LEN_MAX < ii ) + { + retVal = CI_ERROR; + } + else + { + } + + if (CI_SUCCESS == retVal)/*֮ǰIJdzɹ*/ + { + dstDevId = (((UINT16)(CI_SYSTEM_TYPE_AXIS << 8u)) | ((UINT16)axisSysId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 1U, &CiToAxisDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nAXIS_SEND:%d", ii); + debug_out_array(0xAA, CiToAxisDataBuffer, ii); +#endif/*ƽ̨ӡ*/ +#endif + retVal = CI_SUCCESS; + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + } + } + else + { + } + } + else + { + /*AXIS*/ + ClearAxisData(); + retVal = CI_ERROR; + } + return retVal; +} + +/* +* GALͷ +* ˵ const UINT32 localEtcsId, ͨID +* const UINT32 remoteEtcsId, ԷͨID +* const UINT16 devInterfaceType, ӿϢ +* const UINT8 prtrlVer,Э汾 +* const UINT32 dataVer,ݰ汾УϢ +* HLHTGALInfoStruct* pMICommonPackage, GALͷ +* UINT32* pErrorCode, +* ֵ HLHT_HEAD_ERROR: ͨͷ +* HLHT_HEAD_INIT:ͷǻͨʼͨ֡ +* HLHT_HEAD_SUCCESS:ͨͷȷ +*/ +static UINT8 GalHeadCheck(const UINT32 localEtcsId, const UINT32 remoteEtcsId, const UINT16 devInterfaceType, const UINT8 prtrlVer, const UINT32 dataVer, HLHTGALInfoStruct* pMICommonPackage, UINT32* pErrorCode) +{ + UINT8 retVal = CI_ERROR; /*ֵ*/ + + /*ÿζ*/ + *pErrorCode = 0u; + + /*жϸϢǷںϷΧ,ֻҪдӦ*/ + if (pMICommonPackage->devInterInfoType != devInterfaceType) + { + *pErrorCode |= GAL_COMPARE_INFO_TYPE_ERR; + } + + /*ͷУ*/ + if (pMICommonPackage->sourceId != localEtcsId) + { + *pErrorCode |= GAL_COMPARE_SEND_FLAG_ERR; + } + + /*շУ*/ + if (pMICommonPackage->destId != remoteEtcsId) + { + *pErrorCode |= GAL_COMPARE_RECV_FLAG_ERR; + } + + /*ݰ汾У*/ + if (dataVer != pMICommonPackage->emapVerCrc) + { + *pErrorCode |= GAL_COMPARE_EMAP_VER_COMP_ERR; + } + + /* кźϷԼ, (2^31-1u)*/ + if ((1u > pMICommonPackage->crntOwnMsgSN) || (0x7FFFFFFFU < pMICommonPackage->crntOwnMsgSN) + || (1u > pMICommonPackage->recvOppMsgSN) || (0x7FFFFFFFU < pMICommonPackage->recvOppMsgSN) + || (1u > pMICommonPackage->preOwnMsgSN) || (0x7FFFFFFFU < pMICommonPackage->preOwnMsgSN)) + { + *pErrorCode |= GAL_COMPARE_MSG_BDS_SN_ERR; + } + + /* Э汾 */ + if (prtrlVer != pMICommonPackage->prtclVer) + { + *pErrorCode |= GAL_COMPARE_PROTOCOL_VER_ERR; + } + + /* Ӧݳ */ + if (0u >= pMICommonPackage->totalDataLen) + { + *pErrorCode |= GAL_COMPARE_APP_LEN_ERR; + } + /*ͨϢͨ*/ + if (0u == pMICommonPackage->comPeriod) + { + *pErrorCode |= GAL_COMPARE_COM_PERIOD; + } + + /*ӿϢûз,ȷ;򷵻ش*/ + if (0u == *pErrorCode) + { + /*ӿȫȷ,ȷ*/ + retVal = HLHT_HEAD_SUCCESS; + } + else if (GAL_COMPARE_MSG_BDS_SN_ERR == *pErrorCode) + { + if ((0u < pMICommonPackage->crntOwnMsgSN) && (UINT32_MAX == pMICommonPackage->recvOppMsgSN) && (UINT32_MAX == pMICommonPackage->preOwnMsgSN)) + {/*˵Էûյ֡ǰ֡dzʼ֡*/ + retVal = HLHT_HEAD_INIT; + } + else + { + retVal = HLHT_HEAD_ERROR; + } + } + else + { + retVal = HLHT_HEAD_ERROR; + } + + return retVal; +} + +/* +* ȡRSSPIַ +* ˵ const UINT16 locTypeId, ID +* const UINT16 oppTypeId, ԷID +* UINT16* locRsspiAddr, RSSPIַ +* UINT16* oppRsspiAddr, ԷRSSPIַ +* ֵ CI_ERROR: ȡʧ +* CI_SUCCESS: ȡɹ +*/ +static UINT8 GetRsspiAddr(const UINT16 locTypeId, const UINT16 oppTypeId, UINT16* locRsspiAddr, UINT16* oppRsspiAddr) +{ + + UINT8 rtn = CI_ERROR; /*ֵ*/ + UINT16 i = 0; /*ѭ*/ + UINT32 locHlhtId = 0; /*ͨID*/ + UINT32 oppHlhtId = 0; /*ԷͨID*/ + + locHlhtId = DquTypeIdToHlhtId(locTypeId, 0, &dsuRsspInfo); + oppHlhtId = DquTypeIdToHlhtId(oppTypeId, 0, &dsuRsspInfo); + + for (i = 0; i < dsuRsspInfo.RsspInfoStruLen; i++) /*RSSPIϢ*/ + { + if ((dsuRsspInfo.pRsspLnkInfoStru[i].EmitterName == locHlhtId) && (dsuRsspInfo.pRsspLnkInfoStru[i].ReceptorName == oppHlhtId)) /*ҵ*/ + { + *locRsspiAddr = dsuRsspInfo.pRsspLnkInfoStru[i].RsspAddr; + *oppRsspiAddr = dsuRsspInfo.pRsspLnkInfoStru[i].SseAddr; + rtn = CI_SUCCESS; + break; + } + } + + return rtn; +} + +/* +* ȡAxisDataStrID± +* ˵ const UINT8 axleId, ϵͳID +* const UINT16 phySecId, ID +* UINT8* axisDataStrIdx, AxisDataStrID± +* ֵ CI_ERROR: ȡʧ +* CI_SUCCESS: ȡɹ +*/ +static UINT8 GetPhySecIdxInAxisDataStr(const UINT8 axleId, const UINT16 phySecId, UINT8* axisDataStrIdx) +{ + UINT8 rtn = CI_ERROR; /*ֵ*/ + + if ((0u < phySecId) && (PHYSICAL_SECTION_SUM_MAX > phySecId)) + { + *axisDataStrIdx = axisToCiDataStru[axleId].PhySecIdx[phySecId]; + if (AXISDATASTR_IDX != (*axisDataStrIdx)) + { + rtn = CI_SUCCESS; + } + } + + return rtn; +} + + + + diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackAxleData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackAxleData.h new file mode 100644 index 0000000..84f4624 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackAxleData.h @@ -0,0 +1,134 @@ +/******************************************************** +* +* ParsePackIoData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* IOݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_AXLE_DATA_H_ +#define _PARSE_PACK_AXLE_DATA_H_ + + +#include "ParsePackDefine.h" +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "Convert.h" +#include "../Route/RouteConfigDataManage.h" +#include "../Route/RouteDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Relay/RelayDefine.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../psd/PSDConfigDataManage.h" +#include "../psd/PSDDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" + +#ifdef LOGPRINT +#include "../LogRecord/LogRecord.h" +#endif + + + +/*ͨŵϢ*/ +typedef struct S_AxisDataStruct +{ + UINT16 PhySecId; /*ID*/ + UINT8 gdRelayState; /*ɵ̵״̬£0x550xaa*/ + UINT8 showAndReplyInfo; /*bit0bit1㷴bit2bit3Ԥbit4bit7ʾϢֶ̬Σ*/ + UINT8 faultInfo; /*Ϣbit0ιϡbit1忨ϡbit2ϵ硢bit3ͨŹϡbit4ϡbit5ͷϡbit6Ԥbit7ϵ(ֶ̬)*/ + + UINT8 PreResetRst; /*Ԥλ*/ + UINT8 State; /*״̬*/ + +} AxisCollDataStruct; + +typedef struct S_AxisToCiDataStruct +{ + UINT16 axisSystemId; + UINT32 axisEtcsId; /*ụͨID*/ + UINT32 ciEtcsId; /*CIͨID*/ + UINT8 deviceType; /*豸:ֶ̬*/ + UINT8 SectionSum; /*: ֶ̬*/ + UINT8 PhySecIdx[PHYSICAL_SECTION_SUM_MAX]; /*ڼϢṹλ*/ + AxisCollDataStruct axisDataStr[CI_INCLUDE_AXIS_MAX_SUM]; /*Ϣṹ*/ +}AxisToCiDataStruct; + + +extern AxisToCiDataStruct axisToCiDataStru[AXIS_TO_CI_SUM_MAX]; /*AxisCI֡ṹ*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/* +* ͨŲɼ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseAxisToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId); + +/* +* ȡɼݽṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ɼṹָ +*/ +AxisToCiDataStruct* GetCollAxisDataStruct(void); + +#if 0 +/* +* ͨŲɼ +* ˵ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseAxisToCiData(); +#endif + +/* +* Axis +* ˵ void +* ֵ void +*/ +void ClearAxisData(void); + +/* +* Axis +* ˵ UINT8 axisSysId,ID +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToAxisData( UINT8 axisSysId); + +/* +* ʼᵽCIݽṹaxisToCiDataStru +* ˵ +* ֵ CI_ERROR: ʼʧ +* CI_SUCCESS: ʼɹ +*/ +UINT8 InitAxleToCiDataStru(void); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackCiData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackCiData.c new file mode 100644 index 0000000..310dc67 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackCiData.c @@ -0,0 +1,16084 @@ +/******************************************************** +* +* ParsePackCiData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* CIݽ +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackCiData.h" +#include "../DataManage/DeviceConfigDataManage.h" +#include "../HLHTMsgHead/HLHTCommonDataPacketHead.h" +#include "../HLHTMsgHead/HLHTHeadContexManage.h" +#include "../QueryFiles/dquCIInterFace.h" +#include "../CutoffPoint/CutoffPointDataManage.h" +#include "ELMDataPrepare.h" + +#define CI_CI_DEFAULT_DEV_SUM_BUF_LEN 39U /*CI䲻Ҫ豸״̬ʱֻʱӦ豸ռĻλҪд0ÿ豸2ֽڣѩ1ֽڣ39ֽ*/ + +/*ʹ*/ +ToCiCommandDataStruct RecvCiCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX] = {0u}; /*CIṹ*/ +UINT16 RecvCiCmdDataStruCurSum = 0u; /*CIṹ鳤*/ + +/*ʹ*/ +ToCiCommandDataStruct SendCiCmdDataStru[SENDCI_CMD_DATA_STRU_SUM_MAX] = {0u}; /*CI͵ṹ*/ +UINT16 SendCiCmdDataStruCurSum = 0u; /*CI͵ṹ鳤*/ + +UINT16 PhySecIdBufOfOtherCi[PHYSICAL_SECTION_SUM_MAX] = {0u}; /*״̬ȨID*/ +UINT8 PhySecIdBufSumhOfOtherCi = 0u; /*״̬ȨIDĿ*/ + +#define CI_INTER_SUM_MAX ((CI_SUM_MAX)+ (CI_SUM_MAX)) +CiTransmitStruct ciTransmitStruct[CI_INTER_SUM_MAX] = { 0u }; +UINT16 ciTransNum; + +TiocTransmitCtStruct g_szTiocCt[TRANSMIT_OBJECT_DEVICE_SUM_MAX] = { 0u }; +UINT8 g_transmitTiocNum = 0u; + +ToCiDrCmdDataStruct RecvCiDrCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX] = { 0U }; /*CI̬·ṹ*/ +UINT8 RecvCiDrCmdSum = 0U; /*CI̬·*/ + +ToCiDrCmdDataStruct SendCiDrCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX] = { 0U }; /*CI͵̬·ṹ*/ +UINT8 SendCiDrCmdSum = 0U; /*CI͵̬·*/ + +ToCiAreaSnowStruct szRecvCiAreaSnow[CI_COM_CI_MAX_NUM] = { 0U }; /*ѩվ̨Ϣ*/ + +ToCiAreaSnowStruct szSendCiAreaSnow[CI_COM_CI_MAX_NUM] = { 0U }; /*͸ѩվ̨Ϣ*/ + +#define CI_TO_CI_INTERFACE (0x0606) + +#define INTERFACE_INFO_TYPE_LEN (2U) /*ӿֽڳ*/ + +#define SOURCE_ID_LEN (4U) /*ԴIDֽڳ*/ + +#define DESTIN_ID_LEN (4U) /*ĿIDֽڳ*/ + +#define EMAP_VISION_CHECK_SUM_LEN (4U) /*ӵͼУϢֽڳ*/ + +#define SOURCE_MESSAGE_SN_LEN (4U) /*Ϣֽڳ*/ + +#define COMM_PERIOD_LEN (2U) /*ֽͨڳ*/ + +#define DESTIN_MESSAGE_SN_LEN (4U) /*ԷϢֽڳ*/ + +#define PREV_SOURCE_MESSAGE_SN_LEN (4U) /*յһϢʱԷϢֽڳ*/ + +#define PROTOCOL_VERSION_LEN (1U) /*Э汾ֽڳ*/ + +#define APP_LAYER_PACKET_LEN_LEN (2U) /*Ӧò㱨ֽܳڳ*/ + +void PackCiToCiDataFrameUseCfg(UINT8 dstCiId,UINT8* dataFrame, UINT16* dataLength); + +/** +* @brief ɢϢ +* @param UINT8 dstCiId ĿTIOC +* @param UINT8* dataFrame ݻ +* @return +*/ +static UINT16 PackCiToCiDataFrameEa(UINT8 dstCiId, UINT8* dataFrame); + +/*ͨ*/ + +static UINT8 SetIntconPhySecRLockState(UINT16 phySecId, UINT8 routeLockState); + +/* +: +ȡһ +: +const UINT8 *pInputData ָ +: +UINT16 *pPacketType +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParsePacketType(const UINT8* pInputData, UINT16* pPacketType, UINT16* pItemLen); + +/* +: +Ӧñݰ +: +UINT8 *pInputData ָ룬UINT16 packetType Ӧñ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPacketType(UINT8* pInputData, UINT16 packetType, UINT16* pItemLen); + +/* +: +ȡһij +: +const UINT8 *pInputData ָ +: +UINT16 *pPacketLen ij +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParsePacketLength(const UINT8* pInputData, UINT16* pPacketLen, UINT16* pItemLen); + +/* +: +*pInputDataУȡűݳȵַĵַ +: +UINT8 *pInputData ָ +: +UINT8 **ppLenItemAddr űݳȵַĵַ +UINT16 *pItemLen Ӧ͵ıݳȣɡ͡Ľ֡ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPacketLenPha1(UINT8* pInputData, UINT8** ppLenItemAddr, UINT16* pItemLen); + +/* +: +*pInputDataб汨ijȵĵַϣӦ͵ıݵij +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen Ӧ͵ıݳȣɡ͡Ľ֡ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPacketLenPha2(UINT8* pInputData, UINT16 itemLen); + +/* +: +ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseSwitchPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +: +ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +const UINT8 dstCiId:ĿID +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackSwitchPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); + +/* +: +״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParsePhySecPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +: +ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPhySecPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); + +/* +: +߼״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseLogSecPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +: +߼ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackLogSecPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); + +/* +: +źŻ״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseSignalPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +: +źŻݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackSignalPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); + +/* +: +վ̨״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParsePsdPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +: +վ̨ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPsdPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); + +/* +: +رհť״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseEmbtnPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +: +رհťݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackEmbtnPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); + +/* +: +ղ״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseZhaoChaPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +: +ղ̵ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackZhaoChaPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); +/* +: +״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseFloodGatePacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +: +״̬ݰ +: +UINT8 *pInputData ָ +const UINT8 dstCiId ĿID +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackFloodGatePacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); + + +/* +: +ϵ״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseStartLockPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + + +/* +: +ϵ״̬ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackStartLockPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); + +/* +* ͨCIӿʱݰ +* ˵UINT8 *pInputBuf ָ +* UINT16 *pItemLen еij +* const UINT8 srcCiId ԴID +* ֵ1 ɹ +* 0 ʧ +* edit cgh 20250116 +*/ +static UINT8 ParseTSRPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId); + +/* +* ͨCIӿʱݰ +* ˵UINT8 *pInputBuf ָ +* UINT16 *pItemLen еij +* const UINT8 dstCiId ĿID +* ֵ1 ɹ +* 0 ʧ +* edit cgh 20250116 +*/ +static UINT8 PackTSRPacket(UINT8* pInputBuf, UINT16* pItemLen, const UINT8 dstCiId); +/* +: +Զݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseCityDefPacket(const UINT8* pInputData, UINT16* pItemLen); + +/* +: +Զݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackCityDefPacket(UINT8* pInputData, UINT16* pItemLen); + +/* +: +Զݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseManufacDefPacket(const UINT8* pInputData, UINT16* pItemLen); + +/* +: +Զݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackManufacDefPacket(UINT8* pInputData, UINT16* pItemLen); + +/* +: +컥ͨӦ +: +const UINT8 dstCiId ĿID +: +UINT8 *pInputData ݻָ +UINT16 *pOverallLen Ӧָܳ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackCiPacketCont(UINT8* pInputData, UINT16* pOverallLen, const UINT8 dstCiId); + +/* +: + +: +const UINT8 *pInputData ָ +const UINT16 overallLen Ӧñܳ +: + +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseCiPacketCont(const UINT8* pInputData, const UINT16 overallLen, const UINT8 srcId); + +/* +: +ͨӦñ֡ +: +UINT8 dstCiId ĿID +: +UINT8* dataFrame ָ֡ +UINT16* dataLength ֡ȱָ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackHLHTCiToCiDataFrameUseCfg(UINT8 dstCiId, UINT8* dataFrame, UINT16* dataLength); + +/*ͨ*/ +UINT16 packetOderQueue[16] = +{ SWITCH_STATUS_PACKET, + PHYSIC_SEC_STATUS_PACKET, + LOGIC_SEC_STATUS_PACKET, + SIGNAL_STATUS_PACKET, + PSD_STATUS_PACKET, + EMERGEBTN_STATUS_PACKET, + ZHAOCHA_STATUS_PACKET, + FLOOD_GATE_STATUS_PACKET, + START_LOCK_STATUS_PACKET, + LINSHI_XIANSU_STATUS_PACKET, + CITY_DEF_STATUS_PACKET, + MANUFAC_DEF_STATUS_PACKET, + 0xFFFFu, + 0xFFFFu, + 0xFFFFu, + 0xFFFFu}; + +IntconPhySecDataStrut IntconPhySecData[PHYSICAL_SECTION_SUM_MAX]; /*ݽṹ*/ + +/* +* CI +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 ParseCiToCiData(void) +{ + QueueStruct* ci0ToCiDataQueue = Get2oo2CiRecvCiDataQueue(); + UINT32 dataQueueTotalLen = 0u; /*ܳ*/ + UINT8 dataLenBuf[2]; /*ݳ*/ + UINT8 tempBuf[7]; /*ʱ*/ + UINT8 tempDataBuf[5000]; /*ʱ*/ + UINT16 appDataLen = 0u; /*һ֡ݳ*/ + + if (ci0ToCiDataQueue != NULL) + { + /*ȡܳ*/ + dataQueueTotalLen = QueueStatus(ci0ToCiDataQueue); + + while (dataQueueTotalLen > 0u) + { + (void)QueueScan(2, dataLenBuf, ci0ToCiDataQueue); + + appDataLen = (UINT16) (ShortFromChar(dataLenBuf) + 2u); /*ȡ֡ݳ*/ + + if ((dataQueueTotalLen >= appDataLen) && (appDataLen >= 6u)) + { + /*ǰ6ֽ*/ + (void)QueueRead(6, tempBuf, ci0ToCiDataQueue); + + /*Ӷжһ֡*/ + (void) QueueRead(appDataLen-6U, tempDataBuf, ci0ToCiDataQueue); + + /*CICI֡*/ + (void)ParseCiToCiDataFrame(tempDataBuf, (UINT16)(appDataLen-6U)); + + } + else + { + break; + } + + /*ȡܳ*/ + dataQueueTotalLen = QueueStatus(ci0ToCiDataQueue); + } + + if (dataQueueTotalLen > 0u) + { + (void)QueueClear(ci0ToCiDataQueue); /**/ + + return 0u; + } + else + { + return 1u; + } + } + else + { + return 0u; + } +} + +/* +* УCICI֡ݳȺϷ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 totalLength, ܳ +* UINT8 * errNo,ַ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 CheckCi2CiDataLenValid(const UINT8* dataBuf, const UINT16 totalLength,UINT8 * errNo) +{ + /*У飺ܳ=2B(ԴID) + 4B(Դں)+ 2B(ĿID) + 2B(汾) +4B(CICI汾УϢ) + 2B(վstaLen) + + * 2Bm+ m * (12B) + + * 2Bn+ n * (14B) + + * 2B (߼p) + p * (4B) + + * 2B (źŻa) + a * (8B) + + * 2B (b) + b * (4B) + + * 2B (ESBc) + c * (3B) + + * 2B (·d) + d * (8B) + + * 2B (״̬e) + e * (10B) + + * 2B (spksf) + f * (4B) + + * 2B (̵g) + g * (3B) + + * 2Bh+ h * (6B) + * 2B (Զͨ·i) + i*(3B) + * վ = m*(7B) + n*(14B) + p*(4B) + a*(8B) + b*(2B) + c*(3B) + d*(8B) + e*(10B) + f*(4B) + g*(3B) + * ܳ = 2B + 4B +2B + 1B + 2Bվ + վ + 2Bh+ h * (6B) + * + * У飺 + * վ = 8 + * = 10 + * = 10 + 2 + m*(7) + * ߼ = 10 + 2 + m*(7) + 2 + n*(14) + * źŻ = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + * = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(8) + * ESB = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(8) + 2 + b*(2) + * · = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(8) + 2 + b*(2) + 2 + c*(3) + * ״̬ = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(8) + 2 + b*(2) + 2 + c*(3) + 2 + d*(8) + * spks = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(8) + 2 + b*(2) + 2 + c*(3) + 2 + d*(8) + 2 + e*(10) + * ̵ = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(8) + 2 + b*(2) + 2 + c*(3) + 2 + d*(8) + 2 + e*(10) + 2 + f*(4) + * = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(8) + 2 + b*(2) + 2 + c*(3) + 2 + d*(8) + 2 + e*(10) + 2 + f*(4) + 2 + g*(3) + * Զͨ· = 10 + 2 + m*(7) + 2 + n*(14) + 2 + p*(4) + 2 + a*(8) + 2 + b*(2) + 2 + c*(3) + 2 + d*(8) + 2 + e*(10) + 2 + f*(4) + 2 + g*(3)+2+h*(6) + + * Уվ + * Уܳ + * + */ + UINT8 reVal = CI_ERROR; + UINT16 switchNum = 0u, switchNumIndex = 0u; + UINT16 phySecNum = 0u, phySecNumIndex = 0u; + UINT16 logSecNum = 0u, logSecNumIndex = 0u; + UINT16 signalNum = 0u, signalNumIndex = 0u; + UINT16 psdNum = 0u, psdNumIndex = 0u; + UINT16 esbNum = 0u, esbNumIndex = 0u; + UINT16 routeNum = 0u,routeNumIndex = 0u; + UINT16 physecLockStateNum = 0u, physecLockStateNumIndex = 0u; + UINT16 spksNum = 0u, spksNumIndex = 0u; + UINT16 virtualRelayNum = 0u, virtualRelayNumIndex = 0u; + UINT16 floodGateNum = 0u, floodGateNumIndex = 0u; + UINT16 overlapNum = 0u,overlapNumIndex = 0u; + UINT16 cmdNum = 0u, cmdNumIndex = 0u; + UINT16 stationLen = 0u, stationLenIndex = 0u; + UINT16 tmpStationLen = 0u; + UINT16 tmpTotalLen = 0u; + UINT16 logsecLockStateNumIndex = 0u; + UINT16 logsecLockStateNum = 0u; + UINT16 wCfpInfoNum = 0u; + UINT16 wCfpInfoIndex = 0u; + UINT8 chTrainNum = 0U; + UINT16 trainNumIndex = 0U; + UINT16 trainNum = 0U; + UINT16 ii = 0U; + UINT16 wCfpInfoLen = 0u; + UINT16 wCfpIndex = 0u; + UINT8 chEnvelopeNum = 0u; + UINT8 chEnvelopeIndex = 0u; + UINT8 chLgcStateTrainNum = 0u; + UINT8 chTrainIndex = 0u; + UINT16 wEaLen = 0u; + UINT8 chEaNum = 0u; + UINT8 chEaIndex = 0u; + UINT16 wEaInfoIndex = 0u; + UINT8 chEaLgcNum = 0u; + UINT16 autoRouteNum = 0u; + UINT16 autoRouteNumIndex = 0u; + UINT16 wDrCmdNum = 0U; /*̬·*/ + UINT8 cDrLogSecNum = 0U; + UINT8 cDrTrainLocLogSecNum = 0U; + UINT16 wDrCmdIndex = 0U; + UINT16 wDrCmdLenIndex = 0u; + UINT16 wAreaSnowIndex = 0U; + UINT8 cAreaSnowNum = 0U; + UINT16 wLeaveLogIndex = 0U; + UINT16 cLeaveLogNum = 0U; + UINT16 wNeedCheckSwStaRouteIndex = 0U; + UINT16 wNeedCheckSwStaRouteSum = 0U; + UINT16 wNeedCheckProSwStaOlpIndex = 0U; + UINT16 wNeedCheckProSwStaOlpNum = 0U; /*Ҫ״̬ı*/ + UINT16 wProSwitchNum = 0U; + UINT16 wProSwitchIndex = 0U; + UINT8 cPLockRouteNum = 0U; + UINT8 cPLockOverlapNum = 0U; + UINT16 wProSwInfoLen = 0U; + + /*ָ*/ + if (NULL == errNo) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + /*Уվ*/ + if (totalLength < CICI_BEGIN_TO_STATION_LEN) + { + reVal = CI_ERROR; + *errNo = 1U; + } + else + { + stationLenIndex = CICI_BEGIN_TO_STATION_LEN - 2U; + stationLen = ShortFromChar(&dataBuf[stationLenIndex]); + reVal = CI_SUCCESS; + } + } + + if (CI_SUCCESS == reVal) + { + /*У*/ + if (totalLength < CICI_BEGIN_TO_STATION_LEN + 2U) + { + reVal = CI_ERROR; + *errNo = 2U; + } + else + { + switchNumIndex = CICI_BEGIN_TO_STATION_LEN; + switchNum = ShortFromChar(&dataBuf[switchNumIndex]); + reVal = CI_SUCCESS; + } + } + + + /*Уγ*/ + if (CI_SUCCESS == reVal) + { + phySecNumIndex = CICI_BEGIN_TO_STATION_LEN + 2U + switchNum * CICI_ONE_SWITCH_LEN; + if (totalLength < phySecNumIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 3U; + } + else + { + phySecNum = ShortFromChar(&dataBuf[phySecNumIndex]); + reVal = CI_SUCCESS; + } + + } + + /*У߼*/ + if (CI_SUCCESS == reVal) + { + logSecNumIndex = phySecNumIndex + 2U + phySecNum * CICI_ONE_PHYSEC_LEN; + if (totalLength < logSecNumIndex +2U) + { + reVal = CI_ERROR; + *errNo = 4U; + } + else + { + logSecNum = ShortFromChar(&dataBuf[logSecNumIndex]); + reVal = CI_SUCCESS; + } + } + if (CI_SUCCESS == reVal) + { + if (0u == logSecNum) + { + trainNumIndex = logSecNumIndex + 1u; + } + else + { + for (ii = 0U; ii < logSecNum; ii++) + { + /*ǰг± = ߼ʼ±+2ʼ±곤ȣ+֮ǰ߼ݳ+֮ǰгݳ+֮ǰгռλ*/ + trainNumIndex = logSecNumIndex + 2U + (ii + 1U)*CICI_ONE_LOGSEC_LEN + chLgcStateTrainNum * 3U + ii * 1U; + chLgcStateTrainNum += dataBuf[trainNumIndex]; + } + } + } + /*УźŻ*/ + if (CI_SUCCESS == reVal) + { + signalNumIndex = trainNumIndex + 1u + dataBuf[trainNumIndex] * 3u; ; + + if (totalLength < signalNumIndex +2U) + { + reVal = CI_ERROR; + *errNo = 5U; + } + else + { + signalNum = ShortFromChar(&dataBuf[signalNumIndex]); + reVal = CI_SUCCESS; + } + } + + + /*У*/ + if (CI_SUCCESS == reVal) + { + psdNumIndex = signalNumIndex + 2U + signalNum * CICI_ONE_SIGNAL_LEN ; + + if (totalLength < psdNumIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 6U; + } + else + { + psdNum = ShortFromChar(&dataBuf[psdNumIndex]); + reVal = CI_SUCCESS; + } + } + + + /*УESB*/ + if (CI_SUCCESS == reVal) + { + esbNumIndex = psdNumIndex + 2U + psdNum * CICI_ONE_PSD_LEN; + if (totalLength < esbNumIndex +2U) + { + reVal = CI_ERROR; + *errNo = 7U; + } + else + { + esbNum = ShortFromChar(&dataBuf[esbNumIndex]); + reVal = CI_SUCCESS; + } + } + + /*У·*/ + if (CI_SUCCESS == reVal) + { + routeNumIndex = esbNumIndex + 2U + esbNum * CICI_ONE_ESB_LEN; + if (totalLength < routeNumIndex +2U) + { + reVal = CI_ERROR; + *errNo = 8U; + } + else + { + routeNum = ShortFromChar(&dataBuf[routeNumIndex]); + reVal = CI_SUCCESS; + } + } + + /*У״̬*/ + if (CI_SUCCESS == reVal) + { + physecLockStateNumIndex = routeNumIndex + 2U + routeNum * CICI_ONE_ROUTE_LEN; + if (totalLength < physecLockStateNumIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 9U; + } + else + { + physecLockStateNum = ShortFromChar(&dataBuf[physecLockStateNumIndex]); + reVal = CI_SUCCESS; + } + } + + /*Уspks*/ + if (CI_SUCCESS == reVal) + { + spksNumIndex = physecLockStateNumIndex + 2U + physecLockStateNum * CICI_ONE_PHYSEC_LOCKSTATE_LEN; + if (totalLength < spksNumIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 10U; + } + else + { + spksNum = ShortFromChar(&dataBuf[spksNumIndex]); + reVal = CI_SUCCESS; + } + } + + /*У̵*/ + if (CI_SUCCESS == reVal) + { + virtualRelayNumIndex = spksNumIndex + 2U + spksNum * CICI_ONE_SPKS_LEN; + if (totalLength < virtualRelayNumIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 11U; + } + else + { + virtualRelayNum = ShortFromChar(&dataBuf[virtualRelayNumIndex]); + reVal = CI_SUCCESS; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + floodGateNumIndex = virtualRelayNumIndex + 2u + (virtualRelayNum * CICI_ONE_VIRTUAL_RELAY_LEN); + if (totalLength < (floodGateNumIndex + 2u)) + { + reVal = CI_ERROR; + *errNo = 12U; + } + else + { + floodGateNum = ShortFromChar(&dataBuf[floodGateNumIndex]); + reVal = CI_SUCCESS; + } + } + + /*У鱣*/ + if (CI_SUCCESS == reVal) + { + overlapNumIndex = floodGateNumIndex + 2u + floodGateNum * CICI_ONE_FLOODGATE_LEN; + if (totalLength < overlapNumIndex +2u) + { + reVal = CI_ERROR; + *errNo = 13U; + } + else + { + overlapNum = ShortFromChar(&dataBuf[overlapNumIndex]); + reVal = CI_SUCCESS; + } + } + /*cgh-ϲCID-2539-7УԶͨ·*/ + if (CI_SUCCESS == reVal) + { + autoRouteNumIndex = overlapNumIndex + 2u + overlapNum * CICI_ONE_OVERLAP_LEN; + if (totalLength < autoRouteNumIndex + 2u) + { + reVal = CI_ERROR; + *errNo = 14U; + } + else + { + autoRouteNum = ShortFromChar(&dataBuf[autoRouteNumIndex]); + reVal = CI_SUCCESS; + } + } + /*У߼*/ + if(CI_SUCCESS == reVal) + { + logsecLockStateNumIndex = autoRouteNumIndex + 2u + autoRouteNum*CICI_ONE_AUTOROUTE_LEN; + if(totalLength < logsecLockStateNumIndex + 2u) + { + reVal = CI_ERROR; + *errNo = 15U; + } + else + { + logsecLockStateNum = ShortFromChar(&dataBuf[logsecLockStateNumIndex]); + reVal = CI_SUCCESS; + } + } + + if (CI_SUCCESS == reVal) + { + trainNum = 0U; + trainNumIndex = 0u; + for (ii = 0U; ii < logsecLockStateNum; ii++) + { + trainNumIndex = logsecLockStateNumIndex + 2U + (ii + 1U)*CICI_ONE_LOGSEC_LOCKSTATE_LEN + trainNum * 2U + ii * 1U; + trainNum += dataBuf[trainNumIndex]; + } + if (totalLength < trainNumIndex + 2u) + { + reVal = CI_ERROR; + *errNo = 16U; + } + else + { + reVal = CI_SUCCESS; + } + } + + /*Уֽ*/ + if (CI_SUCCESS == reVal) + { + if (0u == trainNumIndex) + { + wCfpInfoIndex = logsecLockStateNumIndex + 2U; + } + else + { + wCfpInfoIndex = trainNumIndex + 1u + dataBuf[trainNumIndex] * 2u; + } + + if (totalLength < wCfpInfoIndex + 2u) + { + reVal = CI_ERROR; + *errNo = 17U; + } + else + { + wCfpInfoNum = ShortFromChar(&dataBuf[wCfpInfoIndex]); + wCfpInfoIndex += 2u; + for (wCfpIndex = 0u; wCfpIndex < wCfpInfoNum; wCfpIndex++) + { + wCfpInfoIndex += CICI_ONE_CUT_OFFPOINT_LEN; + wCfpInfoLen += CICI_ONE_CUT_OFFPOINT_LEN; + + chEnvelopeNum = dataBuf[wCfpInfoIndex++]; + wCfpInfoLen++; + for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++) + { + wCfpInfoIndex += 19u; + wCfpInfoLen += 19u; + + chTrainNum = dataBuf[wCfpInfoIndex++]; + wCfpInfoLen++; + for (chTrainIndex = 0u; chTrainIndex < chTrainNum; chTrainIndex++) + { + wCfpInfoIndex += 3u; /*г*/ + wCfpInfoLen += 3u; + } + } + + chEnvelopeNum = dataBuf[wCfpInfoIndex++]; + wCfpInfoLen++; + for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++) + { + wCfpInfoIndex += 35u; + wCfpInfoLen += 35u; + } + + /*ֽԶRMϢ*/ + wCfpInfoIndex += 7U; + wCfpInfoLen += 7U; + + /*ֽRCźŻID*/ + wCfpInfoIndex += 2U; + wCfpInfoLen += 2U; + + /*ֽźŻƱ־*/ + wCfpInfoIndex++; + wCfpInfoLen++; + } + reVal = CI_SUCCESS; + } + } + + /*Уѩ*/ + if (CI_SUCCESS == reVal) + { + wAreaSnowIndex = wCfpInfoIndex; + if (totalLength < wAreaSnowIndex + 1U) + { + reVal = CI_ERROR; + *errNo = 18U; + } + else + { + cAreaSnowNum = dataBuf[wAreaSnowIndex]; + wAreaSnowIndex++; /*ѩ*/ + wAreaSnowIndex += cAreaSnowNum * 4U; /*ѩվ̨ͨID*/ + } + } + + /*Уȥ߼γ*/ + if (CI_SUCCESS == reVal) + { + wLeaveLogIndex = wAreaSnowIndex; + if (totalLength < wLeaveLogIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 23U; + } + else + { + cLeaveLogNum = ShortFromChar(&dataBuf[wLeaveLogIndex]);/*ȥ*/ + wLeaveLogIndex += 2U;/*ȥ*/ + + wLeaveLogIndex += cLeaveLogNum * 3U; /*ȥID*/ + } + } + + /*УҪ״̬·ݳ*/ + if (CI_SUCCESS == reVal) + { + wNeedCheckSwStaRouteIndex = wLeaveLogIndex; + if (totalLength < wNeedCheckSwStaRouteIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 24U; + } + else + { + wNeedCheckSwStaRouteSum = ShortFromChar(&dataBuf[wNeedCheckSwStaRouteIndex]);/*ȥ*/ + wNeedCheckSwStaRouteIndex += 2U;/*ȥ*/ + + wNeedCheckSwStaRouteIndex += wNeedCheckSwStaRouteSum * 3U; /*ȥID*/ + } + } + + /*УҪ״̬ıݳ*/ + if (CI_SUCCESS == reVal) + { + wNeedCheckProSwStaOlpIndex = wNeedCheckSwStaRouteIndex; + if (totalLength < wNeedCheckProSwStaOlpIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 25U; + } + else + { + wNeedCheckProSwStaOlpNum = ShortFromChar(&dataBuf[wNeedCheckProSwStaOlpIndex]); /**/ + wNeedCheckProSwStaOlpIndex += 2U; + + wNeedCheckProSwStaOlpIndex += wNeedCheckProSwStaOlpNum * 3U; + } + } + + /*У鱻·/ηյķݳ*/ + if (CI_SUCCESS == reVal) + { + wProSwitchIndex = wNeedCheckProSwStaOlpIndex; + if (totalLength < wProSwitchIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 26U; + } + else + { + wProSwitchNum = ShortFromChar(&dataBuf[wProSwitchIndex]); /**/ + wProSwitchIndex += 2U; + for (ii = 0U; ii < wProSwitchNum; ii++) + { + wProSwitchIndex += 2U; /*ID*/ + wProSwInfoLen += 2U; + + cPLockRouteNum = dataBuf[wProSwitchIndex]; + wProSwitchIndex++; /*ս·*/ + wProSwInfoLen++; + wProSwitchIndex += cPLockRouteNum * 2U; /*ս·ID*/ + wProSwInfoLen += cPLockRouteNum * 2U; + + cPLockOverlapNum = dataBuf[wProSwitchIndex]; + wProSwitchIndex++; /*ձ*/ + wProSwInfoLen++; + wProSwitchIndex += cPLockOverlapNum * 2U; /*ձID*/ + wProSwInfoLen += cPLockOverlapNum * 2U; + } + } + } + + /*Уվ*/ + if (CI_SUCCESS == reVal) + { + tmpStationLen = 2u + (switchNum*CICI_ONE_SWITCH_LEN) + 2u + (phySecNum* CICI_ONE_PHYSEC_LEN) + 2u +(logSecNum*CICI_ONE_LOGSEC_LEN) + + logSecNum + (chLgcStateTrainNum * 3U)+ + 2u + (signalNum * CICI_ONE_SIGNAL_LEN) + 2u + (psdNum * CICI_ONE_PSD_LEN) + 2u + (esbNum*CICI_ONE_ESB_LEN) + + 2u + (routeNum * CICI_ONE_ROUTE_LEN) + 2u + (physecLockStateNum * CICI_ONE_PHYSEC_LOCKSTATE_LEN) + + 2u + (spksNum * CICI_ONE_SPKS_LEN) + 2u + (virtualRelayNum * CICI_ONE_VIRTUAL_RELAY_LEN) + + 2u + (floodGateNum * CICI_ONE_FLOODGATE_LEN)+ 2u + (overlapNum * CICI_ONE_OVERLAP_LEN) + 2u + (autoRouteNum * CICI_ONE_AUTOROUTE_LEN)+ + 2u + (logsecLockStateNum * CICI_ONE_LOGSEC_LOCKSTATE_LEN) + logsecLockStateNum + (trainNum * 2U) + 2u + (wCfpInfoLen)+1U + cAreaSnowNum * 4U + + 2U + cLeaveLogNum * 3U + 2U + wNeedCheckSwStaRouteSum * 3U + 2U + wNeedCheckProSwStaOlpNum * 3U + 2U + wProSwInfoLen; + if (stationLen == tmpStationLen) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + *errNo = 19U; + } + } + + /* ȡɢݳ */ + if (CI_SUCCESS == reVal) + { + wEaInfoIndex = wProSwitchIndex; + chEaNum = dataBuf[wEaInfoIndex]; /* ȡڿɢ */ + wEaLen++; + wEaInfoIndex++; + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + { + wEaInfoIndex += 2u; /* ɢгID */ + wEaLen += 2u; + chEaLgcNum = dataBuf[wEaInfoIndex]; /* ɢ߼ */ + wEaInfoIndex++; + wEaLen++; + wEaInfoIndex += (UINT16)(chEaLgcNum * sizeof(UINT16)); /* ɢ߼ID */ + wEaLen += (UINT16)(chEaLgcNum * sizeof(UINT16)); + wEaInfoIndex += 6u; /* ״̬ߡ */ + wEaLen += 6u; + wEaInfoIndex += 4u; /* ں*/ + wEaLen += 4u; + } + + chEaNum = dataBuf[wEaInfoIndex]; /* ȡڿɢϢ */ + wEaLen++; + wEaInfoIndex++; + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + { + wEaInfoIndex += 3u; /* ɢгID״̬ */ + wEaLen += 3u; + wEaInfoIndex += 4u; /* ں*/ + wEaLen += 4u; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + cmdNumIndex = CICI_BEGIN_TO_STATION_LEN + stationLen + wEaLen; + if (totalLength < cmdNumIndex + 2U) + { + reVal = CI_ERROR; + *errNo = 20U; + } + else + { + cmdNum = ShortFromChar(&dataBuf[cmdNumIndex]); + reVal = CI_SUCCESS; + } + } + + /*У鶯̬·*/ + if (CI_SUCCESS == reVal) + { + wDrCmdLenIndex = cmdNumIndex + 2U + cmdNum * CICI_ONE_CMD_LEN; + if (totalLength < (wDrCmdLenIndex + 2U)) + { + reVal = CI_ERROR; + *errNo = 21U; + } + else + { + wDrCmdNum = ShortFromChar(&dataBuf[wDrCmdLenIndex]); + wDrCmdLenIndex += 2U; /**/ + for (wDrCmdIndex = 0U; wDrCmdIndex < wDrCmdNum; wDrCmdIndex++) + { + wDrCmdLenIndex++; /**/ + wDrCmdLenIndex++; /**/ + cDrLogSecNum = dataBuf[wDrCmdLenIndex]; /*߼*/ + wDrCmdLenIndex++; + wDrCmdLenIndex += (UINT16)(cDrLogSecNum * sizeof(UINT16)); /*߼ID*/ + wDrCmdLenIndex += 2U; /*гID*/ + cDrTrainLocLogSecNum = dataBuf[wDrCmdLenIndex]; /*г߼*/ + wDrCmdLenIndex++; + wDrCmdLenIndex += (UINT16)(cDrTrainLocLogSecNum * sizeof(UINT16)); /*г߼ID*/ + wDrCmdLenIndex++; /*ɶ־*/ + wDrCmdLenIndex += 2U; /*ʼźŻID*/ + } + reVal = CI_SUCCESS; + } + } + + /*Уܳ*/ + if (CI_SUCCESS == reVal) + { + if (totalLength == wDrCmdLenIndex + 40U) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + *errNo = 22U; + } + } + + return reVal; +} + + +/* +* CI֡ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +* @note ڲŻ 20220419 wqm +1淶dsuCheckSameLocֵҪн +2ӷֵж +*/ +UINT8 ParseCiToCiDataFrame(UINT8* dataBuf, UINT16 dataLength) +{ + UINT16 sourceId = 0u; /*ԴID*/ + UINT16 targetId = 0u; /*ĿID*/ + UINT16 MaskTotalLen = 0u; /*λܳ*/ + UINT16 deviceSum = 0u; /*豸*/ + UINT16 deviceId = 0u; /*豸ID*/ + UINT16 pLockBlongRouteId = 0u; /*·ID*/ + UINT16 rLockBlongRouteId = 0u; /*··ID*/ + UINT8 deviceInfo = 0u; /*豸Ϣ*/ + UINT16 commandTotalLen = 0u; /*ܳ*/ + UINT16 commandID = 0u; /*֡*/ + UINT16 commandParam1 = 0u; /*֡1*/ + UINT16 commandParam2 = 0u; /*֡2*/ + UINT16 ii = 0u;/*α*/ + UINT16 jj = 0u;/*α*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 floodBelongCiId = 0u;/*ID*/ + UINT8 devSum = 0u; /*豸*/ + UINT8* deviceIdBuf = NULL; /*豸ID*/ + UINT8 deviceFlag = 0u; + UINT8 yy = 0u; + UINT8 kk = 0u; + UINT8 execRet = CI_ERROR; + UINT8 reVal = CI_ERROR; + + UINT16 routePhySecSum = 0u; + RoutePhysicalSectionStruct* routePSSecStru = NULL; + UINT16 preSecId = 0u; + RouteNearPhySectionStruct* routeNearPSSecStru = NULL; + UINT16 routeId = 0u; + /*CTUTռ״̬Ϊ(UT)ռ״̬*/ + UINT8 curUtOrCtOccFlag = LOGICSECTION_OCCUPY_UT; /*ǰCTUTռñ־*/ + UINT8 utOrCtOccFlag = LOGICSECTION_OCCUPY_UT; + + UINT16 bufIndex = 0u; /*±*/ + UINT32 sourceCurCycleNo = 0u;/*ǰϢԴں*/ + + UINT16 utOverlapUnlockCount = 0u;/*UTνʱ*/ + UINT16 ctOverlapUnlockCount = 0u;/*CTνʱ*/ + + UINT16 overlapBelongRouteId = 0u;/*·ID (ֶ̬)*/ + UINT8 overlapUnlockApplyFlag = 0u; /*ZCν־*/ + UINT32 unlockStartCycNum = 0u;/*νʼں (ֶ̬)*/ + UINT32 xuanPaiStartCycNum = 0u;/*ѡſʼں(ֶ̬)*/ + UINT8 autoRouteSetFlag = 0u; /*Զ·ñ־δ(/)*/ + + UINT16 ciciVer = 0u;/*ci-ciӿڰ汾*/ + + UINT8 ciTransmitRecvDataCycResult = 0u; + UINT8 belongCiId =0u; + UINT16 belongRouteId = 0u; + UINT8 cRouteCiId = 0u; + UINT8 phySecPreOccupyState = 0u; + UINT8 phySecCurOccupyState = 0u; + UINT8 phySecCurMergeState = 0u; + UINT8 phySecPreMergeState = 0u; + UINT8 phySecLockState = 0u; + UINT8 chCurPhySecUseState = 0u; + UINT8 phySecArbState = 0u; + UINT8 logLockState = 0u; + UINT8 localLogLockState = 0u; + UINT16 lockBelongRoute = 0u; + UINT16 pLockBelongRoute = 0u; + UINT8 lockDir = 0u; + UINT8 chLogSecTrainInfoSum = 0u; + UINT8 chLogicTrainIndex = 0u; + PhysicalSectionDataStruct* tmpPhysicalSectionDataStru = GetPhySecData(); + SignalDataStruct * tmpSignalDataStru = GetSignalData(); + SwitchDataStruct * tmpSwitchDataStru = GetSwitchData(); + LogicSectionDataStruct * tmpLogicSectionDataStru = GetLogicSecData(); + PsdDataStruct * tmpPsdDataStru = GetPsdData(); + SpksDataStruct * tmpSpksDataStru = GetSpksData(); + EsbDataStruct * tmpEsbDataStru = GetEsbData(); + RelayDataStruct * tmpRelayDataStru = GetRelayData(); + UINT16 szTrainId[LOGIC_SECTION_RES_SUM_MAX] = {0u}; + UINT8 cFlashTrainInfoFlag = 0u;/* ǷˢгϢ */ + UINT16 dwTmpIndex = 0u; + CfpTrainInfoStru tmpTrainInfo = { 0u }; + CfpEnvelopeStruct tmpEnvelopeInfo = { 0u }; + UINT8 chEnvelopeNum = 0u; + UINT8 chEnvelopeIndex = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chAcIndex = 0u; + UINT16 wTiocId = 0u; + UINT16 wLinkTioc = 0u; + UINT8 chLgcResShrFlag = 0U; + UINT8 chCtNum = 0u; + UINT8 chCtIndex = 0u; + UINT16 wLinkId = 0u; + UINT32 dwOffset = 0u; + UINT16 wTrainId = 0u; + UINT8 chLevel = 0u; + UINT32 dwTrainDelay = 0u; + UINT16 wSpeed = 0u; + UINT8 chSpeedDir = 0u; + UINT8 chTiocIndex = 0u; + UINT8 chTrainDir = 0u; + UINT8 chEaNum = 0u; + UINT8 chEaIndex = 0u; + UINT8 chLgcIndex = 0u; + EaDataStru strEaTmp = { 0u }; + UINT16 overlapUnlockTime = 0u; + UINT32 dwDataVerFromOtherCi = 0U; + UINT32 dwDataVerFromEmap = 0U; + UINT16 wCiDevName = 0U;/*ڽܴ豸͵ID*/ + UINT8 chLgcSecResTrainSum = 0U; + UINT16 wPhyErrlockTime = 0U;/*ʽ⵹ʱ*/ + UINT8 cTempTrainNum = 0U; + UINT8 cLogSecLogicLockState = LOG_SECTION_LOCK_NO; /*߼߼״̬*/ + UINT8 cLogSecLogicLockDir = CI_SYSTEM_DIRECTION_NONE; /*߼߼շ*/ + UINT8 cCiRecvAreaSnowNum = 0U; /*͵ѩ*/ + UINT32 dwPlatFormHlhtId = 0U; /*͵ѩվ̨ͨID*/ + UINT8 cCmdRecvFlag = 0U; + ToCiCommandDataStruct strTempCiRecvCmd = { 0U }; + ToCiDrCmdDataStruct strTempCiRecvDrCmd = { 0U }; + UINT32 dwCurCycNum = 0U; + UINT8 cRrmSrcRcId = 0U;/* RRMԴRC ID */ + UINT16 wRrmTrainId = 0U;/* RRMгID */ + UINT16 wRrmTrainNextStaId = 0U;/* RRMгһվ̨ID */ + UINT8 chRrmSrcApplyState = 0U;/* ԶRMʱԴTIOC״̬ */ + UINT8 chRrmDstAllowState = 0U;/* ԶRMʱĿTIOC״̬ */ + UINT8 switchIsThisLineFlag = 0U; /*ǷΪ·*/ + UINT32 dwEaBuildCyc = 0U; /*͵гɢں*/ + UINT16 cCiRecvLeavelogNum = 0U; /*͵ȥ߼*/ + UINT16 leaveLogSecId = 0U; /*͵ȥ߼ID*/ + UINT8 leaveCheckFlag = LOGSEC_LEAVE_LOGSEC_REPLY_NO; /*͵ȥ߼μ־*/ + UINT16 wCfpRelAdjaRcSignalId = 0U; /*ֽRCźŻ*/ + UINT8 cCfpSignalLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_YES; /*ֽźŻƱ־*/ + UINT32 dwSecUtOrCtOccuCyc = 0U; + UINT8 chCurAblFlag = 0U; /*ǰABL־*/ + UINT8 chPreAblFlag = 0U; /*֮ǰABL־*/ + UINT8 cPhySecInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO; + UINT16 wUsingBelongOverlapId = 0U; /*ID*/ + UINT8 cSwitchCurUsingState = 0U; /*ǰ״̬*/ + UINT8 cSwitchTempUsingState = 0U; /*״̬*/ + UINT8 cOverlapBelongCiId = 0U; + UINT8 cProSwtCheckStartFlag = 0U; /*η鿪ʼ־*/ + UINT8 cProSwtCheckResultFlag = 0U; /*η־*/ + UINT8 cPLockRouteNum = 0U; /*·*/ + UINT16 szPLockRouteId[SWITCH_MAX_PROTECT_LOCKED_NUM] = { 0U }; + UINT8 cPLockOverlapNum = 0U; /**/ + UINT16 szPLockOverlapId[SWITCH_MAX_PROTECT_LOCKED_NUM] = { 0U }; + UINT8 chRouteState = 0U;/*·״̬*/ + UINT8 chRouteStateFlag = 0U;/*·׷ٰ־*/ + UINT8 chPhySecBelCiId = 0U;/*ID*/ + UINT8 chRecvPhySecUseState = 0U; /*յ״̬*/ + UINT16 wPhySecUseRouteId = 0U;/*·ID*/ + UINT16 wProSwSecUseRouteId = 0U;/*·ID*/ + UINT8 cPhySecOccState = 0U; + UINT8 cLogLockBelLogRouteSum = 0U; + + localCiId = GetSystemParaLocalCiId(); + dwCurCycNum = Get2oo2CurCycleNum(); + + if ((dataBuf != NULL) && (dataLength > 0u)) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + + + if (CI_SUCCESS == reVal) + { + sourceId = ShortFromChar(&dataBuf[ii]); /*ȡݰԴ豸ID*/ + ii += 2u; + sourceCurCycleNo = LongFromChar(&dataBuf[ii]); /*ȡݰԴں*/ + ii +=4u; + targetId = ShortFromChar(&dataBuf[ii]); /*ȡݰĿ豸ID*/ + ii += 2u; + + ciciVer = ShortFromChar(&dataBuf[ii]);/*汾ţ2ֽ*/ + ii += 2u; + + if ((UINT16)CICI_VERSION == ciciVer) + { + reVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"CICI_VERSION ERROR,local:%d other:%d\n",CICI_VERSION,ciciVer); + reVal = CI_ERROR; + } + if (CI_SUCCESS == reVal) + { + dwDataVerFromOtherCi = LongFromChar(&dataBuf[ii]); /*УϢ*/ + ii += 4U; + wCiDevName = (CI_SYSTEM_TYPE_CI) * 256U + sourceId; + dwDataVerFromEmap = GetCiTranCiDataCheckVer(localCiId, wCiDevName); /*ȡϵͳݰ汾*/ + if (dwDataVerFromOtherCi != dwDataVerFromEmap) + { + reVal = CI_ERROR; + SetCiSendCmdBackInfoData(CI_BACK_DATA_VER_CHECK_FAIL, CI_SYSTEM_TYPE_CI, sourceId, 0U, 0U); + } + } + + + if (CI_SUCCESS == reVal) + { + MaskTotalLen = ShortFromChar(&dataBuf[ii]); /*ȡվϢܳ*/ + ii += 2u; + + if (localCiId != targetId) + { + /*ĿDZ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + } + + } + + if (CI_SUCCESS == reVal) + { + /*жԴ豸ǷָCI*/ + devSum = GetCiTransmitSpecifySysDevSum(Get2oo2SheBeiType()); /*ȡͨ豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(Get2oo2SheBeiType()); /*ȡͨ豸ID*/ + + if ((0u < devSum) && (NULL != deviceIdBuf)) + { + for (yy = 0u; yy < devSum; yy++) + { + if (deviceIdBuf[yy] == sourceId) + { + deviceFlag = 1u; + break; + } + } + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + if (0u == deviceFlag) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + } + + } + if (CI_SUCCESS == reVal) + { + /**/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 2u; + belongCiId = GetSwitchBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_SWITCH_LEN - 2u;/*ڱĵ״̬Ϣ*/ + } + else + { + bufIndex = GetSwitchConfigBufIndex(deviceId); + tmpSwitchDataStru[bufIndex].SwitchId = deviceId; + + /*״̬*/ + SetSwitchYLockState(deviceId, dataBuf[ii++]); + /*״̬*/ + SetOtherCiSwitchLockStatus(deviceId, dataBuf[ii++]); + /*״̬*/ + SetSwitchFLockState(deviceId, dataBuf[ii++]); + /*ǰλ*/ + SetSwitchCurPosition(deviceId, dataBuf[ii++]); + /*ǰλ*/ + SetSingleSwitchCurPosition(deviceId, dataBuf[ii++]); + + switchIsThisLineFlag = GetSwitchIsThisLineState(deviceId); + if (DEV_IS_THIS_LINE_NO == switchIsThisLineFlag) + { + SetConnetSwitchDsState(deviceId, dataBuf[ii++]); /*ߵ״̬*/ + SetConnetSwitchByPassState(deviceId, dataBuf[ii++]); /*ߵ·״̬,ǽ·ʱδе·״̬Ӱźſ*/ + } + else + { + ii += 2U; /*ߵֽ*/ + } + + /*õ״̬*/ + SetSwitchJichaState(deviceId, dataBuf[ii++]); + + /*õıID*/ + wUsingBelongOverlapId = ShortFromChar(&dataBuf[ii]); /**/ + ii += 2U; + cSwitchTempUsingState = dataBuf[ii]; /*״̬*/ + ii++; + + /*ݵǰ״̬µ״̬*/ + cSwitchCurUsingState = GetSwitchUsingState(deviceId); + cOverlapBelongCiId = GetOverlapBelongCiId(wUsingBelongOverlapId); + if (cOverlapBelongCiId == localCiId) + { + /*ñΪ*/ + if ((SWITCH_USING_YES == cSwitchTempUsingState) && (SWITCH_USING_APPLY == cSwitchCurUsingState)) + { + /*ԷãұǰΪã״̬*/ + SetSwitchUsingState(deviceId, SWITCH_USING_YES, wUsingBelongOverlapId); /*õñ*/ + } + else if ((SWITCH_USING_YES == cSwitchTempUsingState) && (SWITCH_USING_NO == cSwitchCurUsingState)) + { + AddCiSendToCiCmdInfo(CI_CMD_OLP_PROSWT_USE_CANCEL, deviceId, wUsingBelongOverlapId, belongCiId); /*ȡ*/ + /*ο󣬳ʼδãᷢãʱͨ*/ + } + else + { + /**/ + } + } + else + { + /*ñηDZIDΪ0*/ + if (SWITCH_USING_NO == cSwitchTempUsingState) + { + if (SWITCH_USING_APPLY == cSwitchCurUsingState) + { + /*άֵǰ״̬οտʼãͨ첽ᷢδãʱοҪά״̬*/ + } + else + { + SetSwitchUsingState(deviceId, SWITCH_USING_NO, wUsingBelongOverlapId); /**/ + } + } + else + { + if (0U < wUsingBelongOverlapId) + { + SetSwitchUsingState(deviceId, cSwitchTempUsingState, wUsingBelongOverlapId); /*״̬*/ + } + else + { + /**/ + } + } + } + } + } + } + + if (CI_SUCCESS == reVal) + { + /**/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 2U; + chPhySecBelCiId = GetPhySecBelongCiId(deviceId); + if (chPhySecBelCiId == localCiId) + { + ii += CICI_ONE_PHYSEC_LEN - 2U;/*ڱ״̬Ϣ*/ + } + else + { + bufIndex = GetPhySecConfigBufIndex(deviceId); /*ȡ±*/ + + tmpPhysicalSectionDataStru[bufIndex].PhysicalSectionId = deviceId; /*εǰں״̬*/ + + cPhySecOccState = dataBuf[ii]; + ii++; + SetPhySecCurOccupyState(deviceId, cPhySecOccState); /*βɼռ״̬*/ + + /*ںϺ״̬*/ + SetPhySecCurMergeState(deviceId, dataBuf[ii++]); + + /*ȡεǰCTUTռ״̬*/ + curUtOrCtOccFlag = dataBuf[ii++]; + + /*ͣϢ*/ + SetPhySecStopSteadyFlag(deviceId, dataBuf[ii++]); + + chRecvPhySecUseState = dataBuf[ii++]; + wPhySecUseRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + wProSwSecUseRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + /*״̬*/ + belongCiId = GetRouteBelongCiId(wPhySecUseRouteId); + chCurPhySecUseState = GetPhySecUseState(deviceId); + if (belongCiId == localCiId) + { + /*ý·ڱ*/ + if ((PHYSICAL_SECTION_USING_YES == chRecvPhySecUseState) && (PHYSICAL_SECTION_USING_APPLY == chCurPhySecUseState)) + { /*ԷҵǰòŸ*/ + + SetPhySecUseState(deviceId, chRecvPhySecUseState, wPhySecUseRouteId); + } + else if ((PHYSICAL_SECTION_USING_YES == chRecvPhySecUseState) && (PHYSICAL_SECTION_USING_NO == chCurPhySecUseState)) + { /*Էұδ*/ + /*ȡ*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_CANCEL, deviceId, wPhySecUseRouteId, chPhySecBelCiId); + /*2024.12.06ڲŻ·󣬳ʼδãοᷢãʱͨ*/ + } + else + { + /**/ + } + } + else + { + /*ý·ڱƻ߽·IDΪ0*/ + if (PHYSICAL_SECTION_USING_NO == chRecvPhySecUseState) + { + /*δ*/ + if (PHYSICAL_SECTION_USING_APPLY == chCurPhySecUseState) + { + ; + } + else + { + SetPhySecUseState(deviceId, chRecvPhySecUseState, wPhySecUseRouteId); + } + } + else + { + /**/ + if (0U < wPhySecUseRouteId) + { + SetPhySecUseState(deviceId, chRecvPhySecUseState, wPhySecUseRouteId); + } + else + { + ; + } + } + } + + /*״̬*/ + belongCiId = GetRouteBelongCiId(wProSwSecUseRouteId); + chCurPhySecUseState = GetPhySecUseState(deviceId); + if (belongCiId == localCiId) + { + /*ý·ڱ*/ + if ((PHYSICAL_SECTION_USING_YES == chRecvPhySecUseState) && (PHYSICAL_SECTION_USING_APPLY == chCurPhySecUseState)) + { /*ԷҵǰòŸ*/ + + SetPhySecProtectUseState(deviceId, chRecvPhySecUseState, wProSwSecUseRouteId); + } + else if ((PHYSICAL_SECTION_USING_YES == chRecvPhySecUseState) && (PHYSICAL_SECTION_USING_NO == chCurPhySecUseState)) + { /*Էұδ*/ + /*ȡ*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_CANCEL, deviceId, wProSwSecUseRouteId, chPhySecBelCiId); + } + else + { + ; /**/ + } + } + else + { + /*ý·ڱƻ߽·IDΪ0*/ + if (PHYSICAL_SECTION_USING_NO == chRecvPhySecUseState) + { + /*δ*/ + if (PHYSICAL_SECTION_USING_APPLY == chCurPhySecUseState) + { + ; + } + else + { + SetPhySecProtectUseState(deviceId, chRecvPhySecUseState, wProSwSecUseRouteId); + } + } + else + { + /**/ + if (0U < wProSwSecUseRouteId) + { + SetPhySecProtectUseState(deviceId, chRecvPhySecUseState, wProSwSecUseRouteId); + } + else + { + ; + } + } + } + + + /*η״̬*/ + (void)SetPhySecFLockState(deviceId, dataBuf[ii++]); + /*Arb״̬*/ + phySecArbState = dataBuf[ii++]; + SetPhySecArbState(deviceId,phySecArbState); + /*Arb״̬ùarb*/ + SetPhyContainAxisSecArbState(deviceId,phySecArbState); + /*ռ״̬*/ + SetPhySecCurAndMergeState(deviceId,dataBuf[ii++]); + /*Ծ״̬*/ + SetPhySecJumpLockState(deviceId,dataBuf[ii++]); + /*η*/ + SetPhySecFLockType(deviceId, dataBuf[ii++]); + /*Ԥλ״̬*/ + SetPhySecPreResetState(deviceId, dataBuf[ii++]); + /*by cgh 20230706 ʾʽ⵹ʱ*/ + wPhyErrlockTime = ShortFromChar(&dataBuf[ii]); + ii += 2U; + SetPhyErrUnlockTime(deviceId, wPhyErrlockTime); + /*ƶ״̬*/ + SetPhySecAreaUrgentState(deviceId, dataBuf[ii++]); + + /*16.0£ABLռñ־*/ + chCurAblFlag = dataBuf[ii++]; + SetPhySecABLTrainFlag(deviceId, chCurAblFlag); + /*ռ״̬͵ʱ仯*/ + phySecCurMergeState = GetPhySecCurMergeState(deviceId); + if (SECTION_OCCUPY_YES == phySecCurMergeState) + { + utOrCtOccFlag = GetPhySecPreOccState(deviceId); /*ȡ֮ǰCTUTռ״̬*/ + dwSecUtOrCtOccuCyc = GetSecUtOrCtOccuStartCycNum(deviceId); + /*ʱУγռ״̬仯ҽѿʼʱ*/ + if ((utOrCtOccFlag != curUtOrCtOccFlag) && (0u != dwSecUtOrCtOccuCyc)) + { + /*UTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(deviceId, dwCurCycNum); + } + else if (LOGICSECTION_OCCUPY_UT == curUtOrCtOccFlag) + { + /*UTռѹ ABL UTCTռÿʼʱ*/ + chPreAblFlag = GetPhySecPreABLTrainFlag(deviceId); + if (chCurAblFlag != chPreAblFlag) + { + SetSecUtOrCtOccuStartCycNum(deviceId, dwCurCycNum); + } + } + else + { + /*ιУ·һγռδ仯ʱ*/ + } + + /*ռ״̬Ϊ֮ǰռ״̬*/ + SetPhySecPreOccState(deviceId, curUtOrCtOccFlag); + } + if (SECTION_OCCUPY_NO == phySecCurMergeState) + { + /*ȡUTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(deviceId, 0u); + SetPhySecPreOccState(deviceId, LOGICSECTION_OCCUPY_NO); + } + + /*λռñ־*/ + SetPhySecUTTrainFlag(deviceId, dataBuf[ii++]); + + cPhySecInHumidRailFlag = dataBuf[ii++]; + SetPhySecInHumidRailFlag(deviceId, cPhySecInHumidRailFlag); /*ڿεʪ־*/ + } + } + } + if (CI_SUCCESS == reVal) + { + /*߼*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡ߼*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡ߼ID*/ + ii += 2u; + + belongCiId = GetLogSecBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += 5U; /*ڱ߼״̬Ϣ*/ + chLgcSecResTrainSum = dataBuf[ii++]; /*ȡ߼Դг*/ + ii += chLgcSecResTrainSum * 3U; /*߼εԴгϢ*/ + } + else + { + + bufIndex = GetlogSectionBufIndex(deviceId); + tmpLogicSectionDataStru[bufIndex].LogicSectionId = deviceId; + /*߼ռ״̬*/ + SetLogSecPreOccupyState(deviceId, GetLogSecCurCtOrUtOccupyState(deviceId));/*߼֮ǰռ״̬*/ + SetLogSecCurOccupyState(deviceId, dataBuf[ii++]); + SetLogSecXSSttOtherTioc(deviceId, dataBuf[ii++]); + /** ߼Ծ״̬ */ + SetLogSecJumpLockState(deviceId, dataBuf[ii++]); + /* ߼ARB״̬ */ + SetLgcArbState(deviceId, dataBuf[ii++]); + /* ߼SPKS״̬ */ + SetLogSecSpksFLockState(deviceId, dataBuf[ii++]); + /*߼ηԴ״̬*/ + SetLogSecProResUseState(deviceId, dataBuf[ii++]); + /*߼ABLԴñ־*/ + SetLogSecAblUseFlag(deviceId, dataBuf[ii++]); + /*ʱٶֵ*/ + SetLogSecXiansuSpeed(deviceId, dataBuf[ii++]); + + chLgcSecResTrainSum = dataBuf[ii++]; + for (kk = 0U; kk < chLgcSecResTrainSum; kk++) + { + wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + SetLogSecTrainUseState(deviceId,wTrainId,dataBuf[ii++]); + } + } + + } + } + + if (CI_SUCCESS == reVal) + { + /*źŻ*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡźŻ*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡźŻID*/ + ii += 2u; + belongCiId = GetSignalBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_SIGNAL_LEN -2u;/*ڱźŻ״̬Ϣ*/ + } + else + { + bufIndex = GetSignalConfigBufIndex(deviceId); + tmpSignalDataStru[bufIndex].SignalId = deviceId; + + /*źŻ״̬*/ + SetSignalFLockState(deviceId, dataBuf[ii++]); + /*źŻ״̬*/ + (void)SetNearCISigLightExtinctState(deviceId, dataBuf[ii++]); + /*źŻǰʾɫ*/ + (void)SetNearCISignalCurColor(deviceId, dataBuf[ii++]); + /*źŻʱ*/ + SetSignalLinShiXianSuSetFlag(deviceId, dataBuf[ii++]); + /*źŻ۳*/ + SetSignalDetainState(deviceId, dataBuf[ii++]); + /*źŻӲ߿۳״̬*/ + SetSignalRelayDetainFlag(deviceId, dataBuf[ii++]); + /*źŻά޵״̬*/ + SetSignalMaintainState(deviceId, dataBuf[ii++]); + } + } + } + + if (CI_SUCCESS == reVal) + { + /**/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 2u; + belongCiId = GetPsdBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_PSD_LEN -2u;/*ڱPSD״̬Ϣ*/ + } + else + { + bufIndex = GetPsdConfigBufIndex(deviceId); + tmpPsdDataStru[bufIndex].PsdId = deviceId; + + (void)SetPsdState(deviceId, dataBuf[ii++]); /*ſ״̬״̬*/ + (void)SetPsdMutualLockRemoveState(deviceId,dataBuf[ii++]); /*Ż״̬״̬*/ + } + } + } + + if (CI_SUCCESS == reVal) + { + /*ͣť*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡͣ*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡͣID*/ + ii += 2u; + belongCiId = GetEsbBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_ESB_LEN -2u;/*ڱESB״̬Ϣ*/ + } + else + { + bufIndex = GetEsbConfigBufIndex(deviceId); + tmpEsbDataStru[bufIndex].EsbId = deviceId; + + /*ͣť״̬*/ + (void)SetEsbState(deviceId, dataBuf[ii++]); + + /*ͣ·ť״̬*/ + SetEsbCutState(deviceId, dataBuf[ii++]); + } + } + } + + if (CI_SUCCESS == reVal) + { + /*·*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡ·*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡ·ID*/ + ii += 2u; + belongCiId = GetRouteBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_ROUTE_LEN -2u;/*ڱĽ·״̬Ϣ*/ + } + else + { + /*·״̬*/ + (void)SetRouteState(deviceId, dataBuf[ii++]); + + /*·ල*/ + SetRouteLevel(deviceId, dataBuf[ii++]); + + /* 2B:UTνʱ*/ + utOverlapUnlockCount = ShortFromChar(&dataBuf[ii]); + ii+=2u; + + if (0u < utOverlapUnlockCount) + { + SetOtherCIRouteOvlpUTUnlockCnt(deviceId,utOverlapUnlockCount); + } + + /* 2B:CTνʱ*/ + ctOverlapUnlockCount = ShortFromChar(&dataBuf[ii]); + ii+=2u; + + if (0u < ctOverlapUnlockCount) + { + SetOtherCIRouteOverlapCTUnlockCount(deviceId,ctOverlapUnlockCount); + } + + /*Զźȡ״̬*/ + SetAutoSigCancleState(deviceId,dataBuf[ii++]); + SetRouteOverlapNeedCIlockFlag(deviceId, dataBuf[ii++]); + + SetRouteStateFlag(deviceId, dataBuf[ii++]);/*·׷ٰ־*/ + + SetRouteAutoTriggerFlag(deviceId, dataBuf[ii++]);/*·Զ־*/ + } + } + } + + if (CI_SUCCESS == reVal) + { + /*״̬*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 2u; + /*״̬*/ + deviceInfo = dataBuf[ii++]; + + /*η·ID*/ + pLockBlongRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + /*·ID*/ + rLockBlongRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + /*״̬*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if (belongCiId != localCiId) + {/*DZ*/ + + if (PHYSICAL_SECTION_LOCK_PROTECT == deviceInfo) + {/*ֻз*/ + + /*·գΪPHYSICAL_SECTION_LOCK_NOPhysicalSectionDataStru[bufIndex].RLockBelongRouteId*/ + (void)SetPhySecLockStateOtherCI(deviceId, PHYSICAL_SECTION_LOCK_NO, 0u, 0u); + + /*·Ϊ*/ + belongCiId = GetRouteBelongCiId(pLockBlongRouteId); + if (belongCiId == localCiId) + { + /*ý·*/ + SetRouteOverlapLockedId(pLockBlongRouteId,ShortFromChar(&dataBuf[ii])); + } + } + else if (PHYSICAL_SECTION_LOCK_NO == deviceInfo) + { /*δ*/ + + belongRouteId = GetPhySecPLockBelongRouteId(deviceId); + belongCiId = GetRouteBelongCiId(belongRouteId); + if ((0u < belongRouteId) &&(belongCiId == localCiId)) + { + /*·ձId*/ + SetRouteOverlapLockedId(GetPhySecPLockBelongRouteId(deviceId), 0); + /*α־*/ + SetOverlapUnlockApplyFlag(ShortFromChar(&dataBuf[ii]),UNLOCK_OVERLAP_APPLY_NO); + } + } + else + { + + if(pLockBlongRouteId > 0u) + {/*ͬʱڷպͨ*/ + belongCiId = GetRouteBelongCiId(pLockBlongRouteId); + if(belongCiId == localCiId) + {/*η·ڱ*/ + SetRouteOverlapLockedId(pLockBlongRouteId,ShortFromChar(&dataBuf[ii])); + } + + /*η*/ + (void)SetPhySecLockStateOtherCI(deviceId,PHYSICAL_SECTION_LOCK_PROTECT,pLockBlongRouteId,dataBuf[ii+3U]); + } + else + { + belongRouteId = GetPhySecPLockBelongRouteId(deviceId); + if (0u < belongRouteId) + { + belongCiId = GetRouteBelongCiId(belongRouteId); + if(belongCiId == localCiId) + { + /*·ձId*/ + SetRouteOverlapLockedId(GetPhySecPLockBelongRouteId(deviceId), 0); + /*α־*/ + SetOverlapUnlockApplyFlag(ShortFromChar(&dataBuf[ii]),UNLOCK_OVERLAP_APPLY_NO); + } + + (void) ClearPhySecPLock(deviceId); + } + + } + } + + ii += 2u;/*ID*/ + if(PHYSICAL_SECTION_LOCK_PROTECT == deviceInfo) + { + (void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, pLockBlongRouteId, dataBuf[ii++]);/*״̬dataBuf[ii++]Ϊշ*/ + } + else + { + (void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, rLockBlongRouteId, dataBuf[ii++]);/*״̬dataBuf[ii++]Ϊշ*/ + } + + /* αռüʱ */ + phySecPreOccupyState = GetPhySecPreOccupyState(deviceId); + phySecCurOccupyState = GetPhySecCurOccupyState(deviceId); + phySecPreMergeState = GetPhySecPreMergeState(deviceId); + phySecCurMergeState = GetPhySecCurMergeState(deviceId); + if ((SECTION_OCCUPY_NO == phySecPreOccupyState) && (SECTION_OCCUPY_YES == phySecCurOccupyState)) + { + /*бռ*/ + + /*εһͬʱռʱռÿʼʱ*/ + routeId = GetPhySecRLockBelongRouteId(deviceId); + if (routeId > 0u) + {/*ν·*/ + + routePhySecSum = GetRoutePhysicalSectionSum(routeId); + routePSSecStru = GetRouteSectionData(routeId); + preSecId = 0u; + for (kk = 0u; kk < routePhySecSum; kk++) + { + if (routePSSecStru[kk].PhysicalSectionId == deviceId) + {/*ҵ·еĸ*/ + + if (kk > 0u) + {/*ǵһ*/ + + preSecId = routePSSecStru[kk - 1U].PhysicalSectionId; + } + else + { + routeNearPSSecStru = GetRouteBlocNearPhySectionStru(routeId); + if (routeNearPSSecStru != NULL) + { + preSecId = routeNearPSSecStru[0].NearPhySecIdBuf[0]; + } + else + { + preSecId = 0u; + } + + } + phySecCurMergeState = GetPhySecCurMergeState(preSecId); + if ((0u != preSecId) &&(SECTION_OCCUPY_YES == phySecCurMergeState)) + {/*һͬʱռ*/ + + /*ռÿʼʱ*/ + SetSecCurOccupyStartCycNum(deviceId, Get2oo2CurCycleNum()); + + /*UTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(deviceId, Get2oo2CurCycleNum()); + } + + break; + } + } + + } + else + { + /* ûս·Ϊг˳ռ, */ + SetSecCurOccupyStartCycNum(deviceId, 0u); + /*ȡUTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(deviceId, 0u); + } + } + else if ((SECTION_OCCUPY_YES == phySecPreMergeState) && (SECTION_OCCUPY_NO == phySecCurMergeState)) + { + /*ռñ*/ + + /*ȡռÿʼʱ*/ + SetSecCurOccupyStartCycNum(deviceId, 0u); + /*ȡUTCTռÿʼʱ*/ + SetSecUtOrCtOccuStartCycNum(deviceId, 0u); + } + else + { + /*ʱ*/ + } + + continue; + } + else + { + ii += 2u;/*ID*/ + SetPhySecOtherCiPLockRouteId(deviceId, pLockBlongRouteId); /*ñ߼CI͵ķ·ID*/ + } + + /*״̬״̬Ϣ*/ + switch (deviceInfo) + { + case PHYSICAL_SECTION_LOCK_START: + /*ǰϵ*/ + + /**/ + + break; + case PHYSICAL_SECTION_LOCK_NO: + /*ǰδ*/ + phySecLockState = GetPhySecLockState(deviceId); + if (PHYSICAL_SECTION_LOCK_NO != phySecLockState) + { + (void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, rLockBlongRouteId, dataBuf[ii]);/*״̬dataBuf[ii++]Ϊշ*/ + } + + break; + + default: + /*״̬*/ + if(PHYSICAL_SECTION_LOCK_PROTECT == deviceInfo) + { + (void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, pLockBlongRouteId, dataBuf[ii]);/*״̬dataBuf[ii++]Ϊշ*/ + } + else + { + (void)SetPhySecLockStateOtherCI(deviceId, deviceInfo, rLockBlongRouteId, dataBuf[ii]);/*״̬dataBuf[ii++]Ϊշ*/ + } + break; + + } + ii++; + + } + } + + + if (CI_SUCCESS == reVal) + { + /* SPKS */ + deviceSum = ShortFromChar(&dataBuf[ii]);/*SPKS*/ + ii += 2u; + for (jj = 0u;jj < deviceSum;jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + belongCiId = GetSpksBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_SPKS_LEN -2u;/*ڱSPKS״̬Ϣ*/ + } + else + { + bufIndex = GetSpksConfigBufIndex(deviceId); + tmpSpksDataStru[bufIndex].spksId = deviceId; + + deviceInfo = dataBuf[ii++]; + (void)SetSpksState(deviceId, deviceInfo); + + deviceInfo = dataBuf[ii++]; + SetSpksCutState(deviceId, deviceInfo); + } + } + } + + if (CI_SUCCESS == reVal) + { + /* ̵ */ + deviceSum = ShortFromChar(&dataBuf[ii]);/*̵*/ + ii += 2u; + for (jj = 0u;jj < deviceSum;jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + belongCiId = GetRelayBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_VIRTUAL_RELAY_LEN - 2u;/*ڱ̵״̬Ϣ*/ + } + else + { + bufIndex = GetRelayConfigBufIndex(deviceId); + tmpRelayDataStru[bufIndex].RelayId = deviceId; + + deviceInfo = dataBuf[ii++]; + SetRelayCollState(deviceId, deviceInfo);/*̵ɼ״̬*/ + } + } + } + + if (CI_SUCCESS == reVal) + { + /* */ + deviceSum = ShortFromChar(&dataBuf[ii]);/**/ + ii += 2u; + for (jj = 0u;jj < deviceSum;jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + floodBelongCiId = GetFloodGateBelongCiId(deviceId); + if (floodBelongCiId == localCiId) + { + ii += CICI_ONE_FLOODGATE_LEN - 2u;/*ڱķŵ״̬Ϣ*/ + } + else + { + bufIndex = GetFloodGateBufIndex(deviceId); + execRet = SetFloodGateCurOpenLockState(bufIndex,dataBuf[ii++]);/**/ + if (CI_ERROR == execRet) + { + debug_infor_printf((const)"SetFloodGateCurOpenLockState %d error.",bufIndex); + } + execRet = SetFloodGateCurCloseRequestSta(bufIndex,dataBuf[ii++]);/**/ + if (CI_ERROR == execRet) + { + debug_infor_printf((const)"SetFloodGateCurCloseRequestState %d error.",bufIndex); + } + execRet = SetFloodGateCurZCAgrCloseAck(bufIndex,dataBuf[ii++]);/*zcͬر*/ + if (CI_ERROR == execRet) + { + debug_infor_printf((const)"SetFloodGateCurAgreeCloseAckFromZC %d error.",bufIndex); + } + execRet = SetFloodGateCurAgreeCloseSta(bufIndex,dataBuf[ii++]);/*ǰɼͬر*/ + if (CI_ERROR == execRet) + { + debug_infor_printf((const)"SetFloodGateCurAgreeCloseCollState %d error.",bufIndex); + } + execRet = SetFloodGateCurAgreeCloseOutSta(bufIndex,dataBuf[ii++]);/*ͬر*/ + if (CI_ERROR == execRet) + { + debug_infor_printf((const)"SetFloodGateCurAgreeCloseOutState %d error.",bufIndex); + } + } + } + } + + if (CI_SUCCESS == reVal) + { + /**/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 2u; + belongCiId = GetOverlapBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_OVERLAP_LEN -2u;/*ڱı״̬Ϣ*/ + } + else + { + /*·ID*/ + overlapBelongRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + SetOverlapBelongRouteId(deviceId,overlapBelongRouteId); + + /* 4B:ָIDʼں*/ + unlockStartCycNum = LongFromChar(&dataBuf[ii]); + ii += 4u; + + if (unlockStartCycNum > 0u) + { + (void)SetOverlapUnlockStartCycNum(deviceId,unlockStartCycNum); + } + + /* 4B:ָIDѡſʼں*/ + xuanPaiStartCycNum = LongFromChar(&dataBuf[ii]); + ii += 4u; + + if (xuanPaiStartCycNum > 0u) + { + SetOverlapXuanPaiStartCycNum(deviceId,xuanPaiStartCycNum); + } + + /*ָIDZCα־*/ + overlapUnlockApplyFlag = dataBuf[ii++]; + if (overlapUnlockApplyFlag > 0u) + { + SetOverlapUnlockApplyFlag(deviceId,overlapUnlockApplyFlag); + } + /*νʱ*/ + overlapUnlockTime = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + SetOverlapUnlockTime(deviceId,overlapUnlockTime); + + /*η鿪ʼ־*/ + cProSwtCheckStartFlag = dataBuf[ii]; + ii++; + SetOverlapProSwtCheckStartFlag(deviceId, cProSwtCheckStartFlag); + + if (PROSWITCH_CHECK_START_VALID != cProSwtCheckStartFlag) + { + SetOverlapProSwtCheckResultFlag(deviceId, PROSWITCH_CHECK_RESULT_DEFAULT); /*ս־ΪĬֵ*/ + } + else + { + /*ڽӿи·־*/ + } + } + } + } + + if (CI_SUCCESS == reVal) + { + /*cgh-ϲCID-2539-7Զͨ·*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡԶͨ·*/ + ii += 2u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡԶͨ·ID*/ + ii += 2u; + belongCiId = GetAutoRouteBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_AUTOROUTE_LEN - 2u;/*ڱԶͨ·Ϣ*/ + } + else + { + autoRouteSetFlag = dataBuf[ii++]; + /*Զͨ·״̬*/ + SetAutoRouteSetFlag(deviceId, autoRouteSetFlag); + } + } + } + + if (CI_SUCCESS == reVal) + { + /*߼״̬*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ȡ߼*/ + ii += 2U; + for (jj = 0; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ȡ߼ID*/ + ii += 2U; + /*״̬*/ + logLockState = dataBuf[ii++]; + /*·*/ + lockBelongRoute = ShortFromChar(&dataBuf[ii]); + ii += 2U; + /*·*/ + pLockBelongRoute = ShortFromChar(&dataBuf[ii]); + ii += 2U; + /*շ*/ + lockDir = dataBuf[ii++]; + /*߼߼״̬*/ + cLogSecLogicLockState = dataBuf[ii++]; + /*߼߼շ*/ + cLogSecLogicLockDir = dataBuf[ii++]; + /*߼߼߼·*/ + cLogLockBelLogRouteSum = dataBuf[ii++]; + chLgcResShrFlag = dataBuf[ii++]; + /* ȡ߼TIOC */ + belongCiId = GetLogSecBelongCiId(deviceId); + belongRouteId = GetLogSecLockBelongRoute(deviceId); + cRouteCiId = GetRouteBelongCiId(belongRouteId); + cFlashTrainInfoFlag = 0u; + + if ((belongCiId != localCiId) || ((cRouteCiId != localCiId)&&(0U != cRouteCiId))) + {/*DZ߼λս·DZTIOC*/ + + /* ״̬жǷͬг */ + if ((LOG_SECTION_LOCK_NORMAL == logLockState) || (LOG_SECTION_LOCK_DELAY == logLockState) || (LOG_SECTION_LOCK_PROTECT == logLockState) + || (LOG_SECTION_LOGLOCK_NORMAL == cLogSecLogicLockState)) + { + /* Էջʱջ߼ո */ + cFlashTrainInfoFlag = 1u; + } + } + + /*״̬*/ + + if (belongCiId != localCiId) + {/*DZ߼*/ + + switch (logLockState) + { + case LOG_SECTION_LOCK_PROTECT: + /*ֻз*/ + SetLogSecLockStateOtherCI(deviceId, logLockState, pLockBelongRoute, lockDir);/*߼״̬*/ + break; + case LOG_SECTION_LOCK_NO: + /*δ*/ + SetLogSecLockStateOtherCI(deviceId, logLockState, lockBelongRoute, lockDir);/*߼״̬*/ + /*YF0083-1235,޸ȱݣԷ״̬Ϊδʱյε״̬Ľ·ID*/ + ClearLogicSecPLock(deviceId); + break; + default: + + if (pLockBelongRoute > 0u) + { + /*η*/ + SetLogSecLockStateOtherCI(deviceId, LOG_SECTION_LOCK_PROTECT, pLockBelongRoute, lockDir); + } + else + { + /*޸ȱݣԷ·ID0ʱҪս·ID,ʱԷʱջ*/ + ClearLogicSecPLock(deviceId); + } + SetLogSecLockStateOtherCI(deviceId, logLockState, lockBelongRoute, lockDir);/*߼״̬*/ + break; + } + + SetLogSecLogLockStateOtherCi(deviceId, cLogSecLogicLockState, cLogSecLogicLockDir, cLogLockBelLogRouteSum); /*·DZ߼ε߼״̬ڸʾ*/ + } + else + { + /*߼״̬߼̬Ϣ߼ε߼״̬ɱٽ߼״̬*/ + switch (logLockState) + { + case LOG_SECTION_LOCK_START: + /*ǰϵ*/ + /**/ + break; + case LOG_SECTION_LOCK_NO: + /*ǰδ*/ + localLogLockState = GetLogSecLockState(deviceId); + if (LOG_SECTION_LOCK_NO != localLogLockState) + { + SetLogSecLockStateOtherCI(deviceId, logLockState, lockBelongRoute, lockDir);/*߼״̬*/ + } + + break; + case LOG_SECTION_LOCK_PROTECT: + /* */ + SetLogSecLockStateOtherCI(deviceId, logLockState, pLockBelongRoute, lockDir); + break; + default: + /*״̬*/ + SetLogSecLockStateOtherCI(deviceId, logLockState, lockBelongRoute, lockDir);/*߼״̬*/ + break; + + } + + SetLogSecOtherCiPLockRouteId(deviceId, pLockBelongRoute); /*ñ߼CI͵ķ·ID*/ + } + + /* ԴϢ */ + chLogSecTrainInfoSum = dataBuf[ii++];/*߼г*/ + + /*߼гϢ*/ + for (chLogicTrainIndex = 0u; chLogicTrainIndex < chLogSecTrainInfoSum; chLogicTrainIndex++) + { + + szTrainId[chLogicTrainIndex] = ShortFromChar(&dataBuf[ii]);/*гID*/ + ii += 2u; + } + + + if (1u == cFlashTrainInfoFlag) + { + /* ͬгϢs */ + SetLogSecResShareFlag(deviceId, chLgcResShrFlag); + AddLogSecOtherTIOCTrainRes(deviceId, chLogSecTrainInfoSum, szTrainId); + } + } + } + + if (CI_SUCCESS == reVal) + { + /*ֽϢ*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*ֽ*/ + ii += 2u; + chTiocIndex = GetTiocTransmitIndex((UINT8)sourceId); + g_szTiocCt[chTiocIndex].chCtNum = 0u; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ֽID*/ + ii += 2u; + dwTmpIndex = GetCfpBufIndex(deviceId); + + + if (CUTOFF_POINT_SUM_MAX <= dwTmpIndex) + { + ii += 7U; /*ڱֽгϢ*/ + chEnvelopeNum = dataBuf[ii++]; /*ֽ*/ + for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++) + { + /*ֽϢ*/ + ii += 19U; + cTempTrainNum = dataBuf[ii++]; /*г*/ + ii += cTempTrainNum * 2U; /*гID*/ + } + + chCtNum = dataBuf[ii++]; /*ֽг*/ + ii += cTempTrainNum * 35U; /*ֽгϢ*/ + ii += 7U; /*ԶRRMϢ*/ + ii += 2; /*źŻID*/ + } + else + { + /*гID*/ + tmpTrainInfo.wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + /*еȼ*/ + tmpTrainInfo.chTrainLevel =dataBuf[ii]; + ii++; + if ((0u == tmpTrainInfo.chTrainLevel) || (TRAIN_LEVEL_BACKUP_UNKNOWN == tmpTrainInfo.chTrainLevel) || (TRAIN_LEVEL_UR == tmpTrainInfo.chTrainLevel) + || (TRAIN_LEVEL_ABL == tmpTrainInfo.chTrainLevel) || (TRAIN_LEVEL_VBTC == tmpTrainInfo.chTrainLevel) || (TRAIN_LEVEL_ITC == tmpTrainInfo.chTrainLevel)) + { + ;/*0޳URABLVBTCITC 0xffϷ*/ + } + else + { + reVal = CI_ERROR; + } + + /*ֽ*/ + tmpTrainInfo.dwDis = LongFromChar(&dataBuf[ii]); + ii += 4u; + + /* дֽг */ + SetCfpOtherOcTrainInfo(deviceId,tmpTrainInfo); + + /* ֽյOCİ */ + chEnvelopeNum = dataBuf[ii++]; + if (CUTOFF_POINT_SUM_MAX >= chEnvelopeNum) + { + SetCfpOtherOcENum(deviceId, chEnvelopeNum); + } + else + { + reVal = CI_ERROR; + } + + for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++) + { + tmpEnvelopeInfo.envelopeType = dataBuf[ii++]; /* */ + if ((TYPE_UKT_ENVELOPE == tmpEnvelopeInfo.envelopeType) + || (TYPE_UCT_ENVELOPE == tmpEnvelopeInfo.envelopeType) + || (TYPE_CT_ENVELOPE == tmpEnvelopeInfo.envelopeType)) + { + ;/*1:ͨų 2ʧͨų 3س*/ + } + else + { + reVal = CI_ERROR; + } + + tmpEnvelopeInfo.headTrainID = ShortFromChar(&dataBuf[ii]);/* ǰID */ + ii += 2u; + + tmpEnvelopeInfo.tailTrainID = ShortFromChar(&dataBuf[ii]);/* ID */ + ii += 2u; + + tmpEnvelopeInfo.startPos.Dir = dataBuf[ii++];/* 㷽 */ + + tmpEnvelopeInfo.startPos.Lnk = ShortFromChar(&dataBuf[ii]);/* link */ + ii += 2u; + + tmpEnvelopeInfo.startPos.Off = LongFromChar(&dataBuf[ii]);/* offset */ + ii += 4u; + + tmpEnvelopeInfo.endPos.Dir = dataBuf[ii++];/* յ㷽 */ + + tmpEnvelopeInfo.endPos.Lnk = ShortFromChar(&dataBuf[ii]);/* յlink */ + ii += 2u; + + tmpEnvelopeInfo.endPos.Off = LongFromChar(&dataBuf[ii]);/* յoffset */ + ii += 4u; + + wLinkTioc = GetLinkManageTiocById(tmpEnvelopeInfo.startPos.Lnk); + if (wLinkTioc == localCiId) + { + (void)dsuCheckSameLoc(tmpEnvelopeInfo.startPos.Lnk, tmpEnvelopeInfo.startPos.Off, &tmpEnvelopeInfo.startPos.Lnk, &tmpEnvelopeInfo.startPos.Off); + } + + wLinkTioc = GetLinkManageTiocById(tmpEnvelopeInfo.endPos.Lnk); + if (wLinkTioc == localCiId) + { + (void)dsuCheckSameLoc(tmpEnvelopeInfo.endPos.Lnk, tmpEnvelopeInfo.endPos.Off, &tmpEnvelopeInfo.endPos.Lnk, &tmpEnvelopeInfo.endPos.Off); + } + + /*ȡֽOCİ*/ + reVal = CutCfpOtherOcEData(deviceId,&tmpEnvelopeInfo); + + tmpEnvelopeInfo.ACCnt = elm_PrepareACBtwPoints(tmpEnvelopeInfo.startPos, tmpEnvelopeInfo.endPos, tmpEnvelopeInfo.ACID); + /* ڲŻ 20220419 wqm elm_PrepareACBtwPoints0߷гаʱ˴Ӧ÷ΪCI_ERROR*/ + if ((SECTION_IN_ENVELOPE_SUM_MAX == tmpEnvelopeInfo.ACCnt) || (0u == tmpEnvelopeInfo.ACCnt)) + { + reVal = CI_ERROR; + } + else + { + for (chAcIndex = 0u; chAcIndex < tmpEnvelopeInfo.ACCnt; chAcIndex++) + { + wTiocId = GetAxisBelongTioc(tmpEnvelopeInfo.ACID[chAcIndex]); + if ((localCiId == wTiocId) || (0u == wTiocId)) + { + reVal = CI_ERROR; + break; + } + else + { + ; + } + } + } + + + tmpEnvelopeInfo.trianCnt = dataBuf[ii++];/* г */ + + for (chTrainIndex = 0u; chTrainIndex < tmpEnvelopeInfo.trianCnt; chTrainIndex++) + { + tmpEnvelopeInfo.trainID[chTrainIndex] = ShortFromChar(&dataBuf[ii]);/* гID */ + ii += 2u; + + tmpEnvelopeInfo.ACTPort[chTrainIndex] = dataBuf[ii++]; /* гˡUCTֽRRM */ + } + + if (CI_SUCCESS == reVal) + { + /* дֽյİ */ + SetCfpOtherOcEData(deviceId, chEnvelopeIndex, tmpEnvelopeInfo); + } + else + { + ; + } + } + + chCtNum = dataBuf[ii++]; + for (chCtIndex = 0u; chCtIndex < chCtNum; chCtIndex++) + { + wTrainId = ShortFromChar(&dataBuf[ii]); /* гID */ + ii += 2u; + + g_szTiocCt[chTiocIndex].szCtId[g_szTiocCt[chTiocIndex].chCtNum++] = wTrainId; + + SetTrainMsgFromTiocId(wTrainId, (UINT8)sourceId); + + (void)SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_GOOD); + + chLevel = dataBuf[ii++]; + (void)SetTrainLevel(wTrainId, chLevel); /* гм */ + + dwTrainDelay = LongFromChar(&dataBuf[ii]); /* TIOCгͨʱ */ + ii += 4u; + (void)SetTrainMsgDelayTime(wTrainId, dwTrainDelay); + + wSpeed = ShortFromChar(&dataBuf[ii]); + ii += 2u; + (void)SetTrainSpeed(wTrainId, wSpeed); /* гٶ */ + + chSpeedDir = dataBuf[ii++]; + (void)SetTrainSpeedDir(wTrainId, chSpeedDir); /* ٶȷ */ + + chTrainDir = dataBuf[ii++]; + (void)SetTrainDir(wTrainId, chTrainDir); /* гз */ + + wLinkId = ShortFromChar(&dataBuf[ii]); /* гȫǰlink */ + ii += 2u; + (void)SetTrainMaxHeadLink(wTrainId, wLinkId); + + dwOffset = LongFromChar(&dataBuf[ii]); /* гȫǰOffset */ + ii += 4u; + (void)SetTrainMaxHeadOffset(wTrainId, dwOffset); + + wLinkId = ShortFromChar(&dataBuf[ii]); /* гСȫǰlink */ + ii += 2u; + (void)SetTrainMinHeadLink(wTrainId, wLinkId); + + dwOffset = LongFromChar(&dataBuf[ii]); /* гСȫǰOffset */ + ii += 4u; + (void)SetTrainMinHeadOffset(wTrainId, dwOffset); + + wLinkId = ShortFromChar(&dataBuf[ii]); /* гȫlink */ + ii += 2u; + (void)SetTrainMaxTailLink(wTrainId, wLinkId); + + dwOffset = LongFromChar(&dataBuf[ii]); /* гȫOffset */ + ii += 4u; + (void)SetTrainMaxTailOffset(wTrainId, dwOffset); + + wLinkId = ShortFromChar(&dataBuf[ii]); /* гСȫlink */ + ii += 2u; + (void)SetTrainMinTailLink(wTrainId, wLinkId); + + dwOffset = LongFromChar(&dataBuf[ii]); /* гСȫOffset */ + ii += 4u; + (void)SetTrainMinTailOffset(wTrainId, dwOffset); + + /*гȫˡСȫǰˡȫǰ˵з*/ + reVal = SetTrainOtherPointDir(wTrainId, chTrainDir); + + } + + /*ֽԶRMϢ*/ + cRrmSrcRcId = dataBuf[ii++]; /*ԴRC ID*/ + wRrmTrainId = ShortFromChar(&dataBuf[ii]); /* RRMгID */ + ii += 2U; + wRrmTrainNextStaId = ShortFromChar(&dataBuf[ii]); /* RRMгһվ̨ID */ + ii += 2U; + chRrmSrcApplyState = dataBuf[ii++]; /* ԶRMʱԴTIOC״̬ */ + chRrmDstAllowState = dataBuf[ii++]; /* ԶRMʱĿTIOC״̬ */ + + SetCfpRrmSrcRcId(deviceId, cRrmSrcRcId); + SetCfpRrmTrainId(deviceId, wRrmTrainId); + SetCfpRrmTrainNextStaId(deviceId, wRrmTrainNextStaId); + if (cRrmSrcRcId != localCiId) + { + SetCfpRrmSrcApplyState(deviceId, chRrmSrcApplyState); + } + else + { + /*ΪԴRC*/ + } + + SetCfpRrmDstAllowState(deviceId, chRrmDstAllowState); + + wCfpRelAdjaRcSignalId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + cCfpSignalLightUpFlag = dataBuf[ii]; /*ֽźŻƱ־*/ + ii++; + + belongCiId = GetSignalBelongCiId(wCfpRelAdjaRcSignalId); + + if ((0U != belongCiId) && (belongCiId == localCiId)) + { + SetSleepTrainLightUpSignalFlag(wCfpRelAdjaRcSignalId, cCfpSignalLightUpFlag); /*Էֽ߳źŻ־Ч*/ + } + else + { + /*DZźŻ*/ + } + } + } + } + + /*ѩ*/ + if (CI_SUCCESS == reVal) + { + cCiRecvAreaSnowNum = dataBuf[ii]; + ii++; + if (CI_TO_CI_AREA_SNOW_SUM_MAX >= cCiRecvAreaSnowNum) + { + ClearCiRecvAreaSnowInfo((UINT8)sourceId); /*͸ѩϢ*/ + for (kk = 0U; kk < cCiRecvAreaSnowNum; kk++) + { + dwPlatFormHlhtId = LongFromChar(&dataBuf[ii]); /*վ̨ͨID*/ + ii += 4U; + + AddCiRecvAreaSnowInfo((UINT8)sourceId, localCiId, dwPlatFormHlhtId); /*洢DZѩվ̨ID*/ + } + } + else + { + reVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*ȥ*/ + if (CI_SUCCESS == reVal) + { + cCiRecvLeavelogNum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (CI_TO_CI_LEAVE_LOGSEC_ROUTE_NUM >= cCiRecvLeavelogNum) + { + for (kk = 0U; kk < cCiRecvLeavelogNum; kk++) + { + leaveLogSecId = ShortFromChar(&dataBuf[ii]); /*ȥ߼ID*/ + ii += 2U; + leaveCheckFlag = dataBuf[ii++]; + SetRouteLeaveLogSecFlag(leaveLogSecId, leaveCheckFlag); + } + } + else + { + reVal = CI_ERROR; + } + } + else + { + /**/ + } + + if (CI_SUCCESS == reVal) + { + /* Ҫ״̬Ľ· */ + deviceSum = ShortFromChar(&dataBuf[ii]);/*Ҫ״̬Ľ·*/ + ii += 2U; + for (jj = 0u; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); + belongCiId = GetRouteBelongCiId(deviceId); + if (belongCiId == localCiId) + { + ii += 2U; + chRouteState = GetRouteState(deviceId); + chRouteStateFlag = GetRouteStateFlag(deviceId); + + if ((ROUTE_STATE_XUANPAI == chRouteState) + || (((ROUTE_STATE_AUTO_UNLOCK == chRouteState) || (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState)) && (ROUTE_STATE_FLAG_YES == chRouteStateFlag)) + || (ROUTE_STATE_LEAD_XUANPAI == chRouteState)) + { + /*ͨ첽ֻн··״̬Ÿڿ״̬ãֹĬϣ첽˳ɹʧܽĬ޸*/ + SetRouteApplySwitchCheckFlag(deviceId, dataBuf[ii++]); + } + else + { + ii++; + } + + } + else + { + ii += 3U;/*ڱĽ·*/ + } + } + } + + if (CI_SUCCESS == reVal) + { + /*Ҫ״̬ı*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /*Ҫ״̬ı*/ + ii += 2U; + for (jj = 0U; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + belongCiId = GetOverlapBelongCiId(deviceId); + if (belongCiId == localCiId) + { + cProSwtCheckResultFlag = dataBuf[ii]; + ii++; + cProSwtCheckStartFlag = GetOverlapProSwtCheckStartFlag(deviceId); /*ȡ鿪ʼ־*/ + if (PROSWITCH_CHECK_START_VALID == cProSwtCheckStartFlag) + { + SetOverlapProSwtCheckResultFlag(deviceId, cProSwtCheckResultFlag); + } + else + { + /*βУ·־ + Ѿճɹ/ʧܣ־Ϊ0xFFͨ첽ᷢ0xAA/0x55ʱοҪάֱ־Ϊ0xFF*/ + } + } + else + { + ii++; /*ڱıΣ*/ + } + } + } + else + { + /**/ + } + + if (CI_SUCCESS == reVal) + { + /*·/ηյıķϢ*/ + deviceSum = ShortFromChar(&dataBuf[ii]); /**/ + ii += 2U; + for (jj = 0U; jj < deviceSum; jj++) + { + deviceId = ShortFromChar(&dataBuf[ii]); /*ID*/ + ii += 2U; + + cPLockRouteNum = dataBuf[ii]; /*յĽ·*/ + ii++; + + for (kk = 0U; kk < cPLockRouteNum; kk++) + { + szPLockRouteId[kk] = ShortFromChar(&dataBuf[ii]); /*յĽ·ID*/ + ii += 2U; + } + + cPLockOverlapNum = dataBuf[ii]; /*յĽ·*/ + ii++; + + for (kk = 0U; kk < cPLockOverlapNum; kk++) + { + szPLockOverlapId[kk] = ShortFromChar(&dataBuf[ii]); /*յĽ·ID*/ + ii += 2U; + } + + belongCiId = GetSwitchBelongCiId(deviceId); + if (belongCiId == localCiId) + { + for (kk = 0U; kk < cPLockRouteNum; kk++) + { + SetSwitchLockStatus(SWITCH_PLOCKTYPE_ROUTE, szPLockRouteId[kk], deviceId, SWITCH_LOCK_PROTECT_SET); /*ý·*/ + } + + for (kk = 0U; kk < cPLockOverlapNum; kk++) + { + SetSwitchLockStatus(SWITCH_PLOCKTYPE_OVERLAP, szPLockOverlapId[kk], deviceId, SWITCH_LOCK_PROTECT_SET); /*ñη*/ + } + } + else + { + /*ڱ*/ + } + } + } + else + { + /**/ + } + + /*ɢ*/ + if (CI_SUCCESS == reVal) + { + chTiocIndex = GetTiocTransmitIndex((UINT8)sourceId); + g_szTiocCt[chTiocIndex].chEaTrainNum = 0u; + chEaNum = dataBuf[ii]; + ii++; + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + {/* ȡɢгID */ + strEaTmp.wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + /* ߼ */ + strEaTmp.strLgcInfo.chObjNum = dataBuf[ii]; + ii++; + for (chLgcIndex = 0u; chLgcIndex < strEaTmp.strLgcInfo.chObjNum; chLgcIndex++) + {/* ߼ID */ + strEaTmp.strLgcInfo.szObjId[chLgcIndex] = ShortFromChar(&dataBuf[ii]); + ii += 2u; + } + + /* ʶ */ + strEaTmp.chBuildedFlag = dataBuf[ii]; + ii++; + + /* ɢг */ + strEaTmp.dwMidLine = LongFromChar(&dataBuf[ii]); + ii += 4u; + + /* */ + strEaTmp.chPaType = dataBuf[ii]; + ii++; + + /* ɢں */ + strEaTmp.dwEaBuildCycNum = LongFromChar(&dataBuf[ii]); + ii += 4u; + + /* ¼ڿķ */ + g_szTiocCt[chTiocIndex].szEaTrainId[g_szTiocCt[chTiocIndex].chEaTrainNum] = strEaTmp.wTrainId; + g_szTiocCt[chTiocIndex].szPaType[g_szTiocCt[chTiocIndex].chEaTrainNum] = strEaTmp.chPaType; + g_szTiocCt[chTiocIndex].dwEaBuildCyc[g_szTiocCt[chTiocIndex].chEaTrainNum++] = strEaTmp.dwEaBuildCycNum; + + strEaTmp.chSrcTiocId = (UINT8)(sourceId & 0x00ffu); + strEaTmp.chDstTiocId = localCiId; + + EaNeighborUpdata(&strEaTmp); + } + + chEaNum = dataBuf[ii]; + ii++; + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + {/* ɢгID */ + strEaTmp.wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + /* ڿ״̬ */ + strEaTmp.chDstAllowed = dataBuf[ii]; + ii++; + + /* ں */ + dwEaBuildCyc = LongFromChar(&dataBuf[ii]); + ii += 4u; + strEaTmp.chSrcTiocId = localCiId; + strEaTmp.chDstTiocId = (UINT8)(sourceId & 0x00ffu); + + EaSetNeighborAllowFlag(strEaTmp.wTrainId, strEaTmp.chSrcTiocId, strEaTmp.chDstTiocId, strEaTmp.chDstAllowed,dwEaBuildCyc); + } + } + else + { + ; + } + + if (CI_SUCCESS == reVal) + { + /*Ϣ*/ + commandTotalLen = ShortFromChar(&dataBuf[ii]); /*ȡݰ*/ + ii += 2u; + + if (commandTotalLen <= RECVCI_CMD_DATA_STRU_SUM_MAX) + { + for (jj = 0u; jj < commandTotalLen; jj++) + { + commandID = ShortFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 2u; + commandParam1 = ShortFromChar(&dataBuf[ii]);/*ȡ1*/ + ii += 2u; + commandParam2 = ShortFromChar(&dataBuf[ii]);/*ȡ2*/ + ii += 2u; + + strTempCiRecvCmd.SourceCiId = (UINT8)sourceId; + strTempCiRecvCmd.TargetCiId = (UINT8)targetId; + strTempCiRecvCmd.CommandID = commandID; + strTempCiRecvCmd.Param1 = commandParam1; + strTempCiRecvCmd.Param2 = commandParam2; + strTempCiRecvCmd.CycleNo = dwCurCycNum; + + cCmdRecvFlag = CheckCiRecvCmdIsRepeat(&strTempCiRecvCmd); + if (CI_SUCCESS == cCmdRecvFlag) + { + RecvCiCmdDataStru[RecvCiCmdDataStruCurSum] = strTempCiRecvCmd; + RecvCiCmdDataStruCurSum++; + } + else + { + /*ظ洢*/ + } + } + } + else + { + /*Խ*/ + reVal = CI_ERROR; + } + + } + + if (CI_SUCCESS == reVal) + { + /*CI̬·Ϣ*/ + commandTotalLen = ShortFromChar(&dataBuf[ii]); /*ȡݰ*/ + ii += 2u; + + if (commandTotalLen <= RECVCI_CMD_DATA_STRU_SUM_MAX) + { + for (jj = 0u; jj < commandTotalLen; jj++) + { + strTempCiRecvDrCmd.cSourceCiId = (UINT8)sourceId; + strTempCiRecvDrCmd.cTargetCiId = (UINT8)targetId; + strTempCiRecvDrCmd.cCmdType = dataBuf[ii]; /*̬·*/ + ii++; + + strTempCiRecvDrCmd.cLogSecSeqDir = dataBuf[ii]; /*̬·߼з*/ + ii++; + + strTempCiRecvDrCmd.cLogSecSum = dataBuf[ii]; /*̬·߼*/ + ii++; + + for (kk = 0U; kk < strTempCiRecvDrCmd.cLogSecSum; kk++) + { + strTempCiRecvDrCmd.wLogSecIdBuff[kk] = ShortFromChar(&dataBuf[ii]); /*̬·߼ID*/ + ii += 2U; + } + + strTempCiRecvDrCmd.wTrainId = ShortFromChar(&dataBuf[ii]); /*̬·гID*/ + ii += 2U; + + strTempCiRecvDrCmd.cTrainLocLogSecSum = dataBuf[ii]; /*̬·г߼*/ + ii++; + + for (kk = 0U; kk < strTempCiRecvDrCmd.cTrainLocLogSecSum; kk++) + { + strTempCiRecvDrCmd.wTrainLocLogSecIdBuff[kk] = ShortFromChar(&dataBuf[ii]); /*̬·г߼ID*/ + ii += 2U; + } + + strTempCiRecvDrCmd.cSwitchMoveFlag = dataBuf[ii]; /*ؽ·ɶ־*/ + ii++; + + strTempCiRecvDrCmd.wRelStartSignalId = ShortFromChar(&dataBuf[ii]); /*׸߼ιʼźŻID*/ + ii += 2U; + strTempCiRecvDrCmd.CycleNo = dwCurCycNum; + + cCmdRecvFlag = CheckCiRecvDrCmdIsRepeat(&strTempCiRecvDrCmd); + if (CI_SUCCESS == cCmdRecvFlag) + { + RecvCiDrCmdDataStru[RecvCiDrCmdSum] = strTempCiRecvDrCmd; + RecvCiDrCmdSum++; + } + else + { + /*ظ洢*/ + } + } + } + else + { + /*Խ*/ + reVal = CI_ERROR; + } + } + else + { + /**/ + } + + if (CI_SUCCESS == reVal) + { /*CI뱾CIͨ*/ + /*ͨ*/ + ciTransmitRecvDataCycResult = SetCiTransmitRecvDataCycNum(localCiId, Get2oo2SheBeiType(), (UINT8)sourceId, Get2oo2CurCycleNum()); + if (CI_ERROR == ciTransmitRecvDataCycResult) + { + /*ʧ*/ + reVal = CI_ERROR; + } + else + { + + } + } + + return reVal; +} + +/* +* CI +* ˵ UINT8 targetDeviceId, Ŀ豸ID +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 PackCiToCiData(UINT8 targetDeviceId) +{ + UINT8 localCi = GetSystemParaLocalCiId(); /*ȡID*/ + UINT16 cmdSum = 0u;/**/ + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + UINT8 localCiType = 0u; + UINT16 scState; + UINT32 curCycleNo = Get2oo2CurCycleNum();/*ȡǰں*/ + UINT8 ciFunctionSwitchConfig = 0u; + UINT8 ciToCiDataBuffer[CI_TO_CI_DATA_LEN_MAX] = {0u};/*CICI֡*/ + UINT16 infoSumIndex = 0u; /*Ϣܳαλ*/ + UINT16 infoSum = 0u; /*Ϣܳ*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 kk = 0U; + UINT16 curIndex = 0u; + UINT16 deviceId = 0u; /*豸ID*/ + const CiTransmitStruct* pCiTramsStru = GetDstCiTransInfo(targetDeviceId); + UINT16 otherCiPhySecIdSum = 0u; + UINT16 wOtherCiSwitchIdSum = 0U; + UINT8 chRtn = CI_ERROR; + UINT16 OcDevName = 0U; + UINT32 emapCheckVer = 0U; + UINT16 wDevType = 0U; + UINT8 cDevBelongCiId = 0U; + UINT16 wUsingBelongOverlapId = 0U; /*ID*/ + UINT8 cSwitchUsingState = 0U; /*״̬*/ + UINT8 chPhySecUseState = 0U; /*״̬*/ + UINT16 wPhySecUseRouteId = 0U;/*·ID*/ + UINT16 wProSwSecUseRouteId = 0U;/*·ID*/ + UINT8 chPhyUseRouteBelCiId = 0U;/*ý·ID*/ + UINT8 chProPhyUseRouteBelCiId = 0U;/*ý·ID*/ + + OcDevName = (CI_SYSTEM_TYPE_CI) * 256U + targetDeviceId; + emapCheckVer = GetCiTranCiDataCheckVer(localCi, OcDevName); + + /*Ӧ֡ʼ*/ + ShortToChar((UINT16)localCi, &ciToCiDataBuffer[ii]); /*CI ID*/ + ii += 2u; + LongToChar(curCycleNo, &ciToCiDataBuffer[ii]); /*鵱ǰں*/ + ii +=4u; + ShortToChar((UINT16)targetDeviceId, &ciToCiDataBuffer[ii]); /*ĿCI ID*/ + ii += 2u; + + ShortToChar((UINT16)CICI_VERSION, &ciToCiDataBuffer[ii]);/*ci-ciӿڰ汾ţÿ޸ĽӿҪ汾*/ + ii+=2u; + + LongToChar(emapCheckVer, &ciToCiDataBuffer[ii]); /*CI-CIУ*/ + ii += 4U; + + /***֡Ϣ***/ + infoSumIndex = ii; + ii += 2u;/*Ϣܳ*/ + + PackCiToCiDataFrameUseCfg(targetDeviceId,&ciToCiDataBuffer[ii],&infoSum); + + ShortToChar(infoSum, &ciToCiDataBuffer[infoSumIndex]);/*ܳ*/ + ii = ii + infoSum; + + /* ڿ֮以ɢ */ + infoSum = PackCiToCiDataFrameEa(targetDeviceId, &ciToCiDataBuffer[ii]); + if (0u == infoSum) + { + ; + } + else + { + chRtn = CI_SUCCESS; + } + ii += infoSum; + + /*DZ*/ + if(NULL != pCiTramsStru ) + { + otherCiPhySecIdSum = pCiTramsStru->phySecIdBufSumhOfOtherCi; + wOtherCiSwitchIdSum = pCiTramsStru->wSwitchSumOfOtherCi; + } + else + { + otherCiPhySecIdSum = 0u; + } + for (jj = 0u; jj < otherCiPhySecIdSum; jj++) + { + deviceId = pCiTramsStru->wPhySecIdBufOfOtherCi[jj];/*ȡID*/ + cDevBelongCiId = GetPhySecBelongCiId(deviceId); + + if (targetDeviceId == cDevBelongCiId) + {/*DZ*/ + chPhySecUseState = GetPhySecUseState(deviceId); + wPhySecUseRouteId = GetPhySecUseRouteId(deviceId); + wProSwSecUseRouteId = GetPhySecProtectUseRouteId(deviceId); + chPhyUseRouteBelCiId = GetRouteBelongCiId(wPhySecUseRouteId); + chProPhyUseRouteBelCiId = GetRouteBelongCiId(wProSwSecUseRouteId); + + if (PHYSICAL_SECTION_USING_APPLY == chPhySecUseState) + { + /*·*/ + if ((0U < wPhySecUseRouteId) && (localCi == chPhyUseRouteBelCiId)) + { + /**/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_APPLY, deviceId, wPhySecUseRouteId, cDevBelongCiId); + } + else + { + ; + } + + /*·*/ + if ((0U < wProSwSecUseRouteId) && (localCi == chProPhyUseRouteBelCiId)) + { + /**/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_APPLY, deviceId, wProSwSecUseRouteId, cDevBelongCiId); + } + else + { + ; + } + } + else if (PHYSICAL_SECTION_USING_CANCEL == GetPhySecUseState(deviceId)) + { + /*·ȡ*/ + if ((0U < wPhySecUseRouteId) && (localCi == chPhyUseRouteBelCiId)) + { + /**/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PHYSEC_USING_CANCEL, deviceId, wPhySecUseRouteId, cDevBelongCiId); + } + else + { + ; + } + + /*·*/ + if ((0U < wProSwSecUseRouteId) && (localCi == chProPhyUseRouteBelCiId)) + { + /**/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_PROSW_SEC_USING_CANCEL, deviceId, wProSwSecUseRouteId, cDevBelongCiId); + } + else + { + ; + } + } + else + { + ; /**/ + } + } + else + { + ; /*β*/ + } + + } + + /*/ȡ*/ + for (jj = 0U; jj < wOtherCiSwitchIdSum; jj++) + { + deviceId = pCiTramsStru->szSwitchIdBufOfOtherCi[jj]; + cDevBelongCiId = GetSwitchBelongCiId(deviceId); + if (targetDeviceId == cDevBelongCiId) + { + wUsingBelongOverlapId = GetSwitchBelongOverlapId(deviceId); /*ȡID*/ + cSwitchUsingState = GetSwitchUsingState(deviceId); /*ȡ״̬*/ + if (SWITCH_USING_APPLY == cSwitchUsingState) + { + AddCiSendToCiCmdInfo(CI_CMD_OLP_PROSWT_USE_APPLY, deviceId, wUsingBelongOverlapId, cDevBelongCiId); /**/ + } + else if (SWITCH_USING_CANCEL == cSwitchUsingState) + { + AddCiSendToCiCmdInfo(CI_CMD_OLP_PROSWT_USE_CANCEL, deviceId, wUsingBelongOverlapId, cDevBelongCiId); /*ȡ*/ + } + else + { + /**/ + } + } + else + { + /**/ + } + } + + /*ΪλԳߣݳκԳߵĽӿڷʽ໥Գ豸״̬*/ + ciFunctionSwitchConfig = GetCiFunctionSwitchConfig(SCX_CLD_INTERFACE_TYPE); + if ((SCX_CLD_INTERFACE_COMM == ciFunctionSwitchConfig)||(SCX_CLD_SERIAL_PORT_COMM == ciFunctionSwitchConfig)) + {/*Գ복νӿΪͨŽӿ*/ + localCiType = GetLocalCiType();/*ȡ豸*/ + + if(CI_TYPE_CLD==localCiType) + {/*Ϊ*/ + if(CI_TYPE_SCX==GetCiType(targetDeviceId))/*ĿΪԳ*/ + { + scState = GetCommTrainTestCLDTYSJStatus();/*ȡTYSJ״̬*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_TRAIN_TEST_ALLOW_STATUS, (UINT16)COMM_TRAIN_TEST_TYSJ_CLD, scState, targetDeviceId);/*Գ߷Գ豸״̬*/ + } + else + { + } + } + + else if (CI_TYPE_SCX==localCiType) + {/*ΪԳ*/ + if (CI_TYPE_CLD==GetCiType(targetDeviceId))/*ĿΪ*/ + { + scState = GetCommTrainTestSCXSQAJStatus();/*ȡԳSQAJ״̬*/ + AddCiSendToCiCmdInfo((UINT8)CI_CMD_TRAIN_TEST_APPLY, (UINT16)COMM_TRAIN_TEST_SQAJ_SCX, (UINT16)(scState*256U+CI_TYPE_SCX), targetDeviceId);/*ηԳ豸״̬*/ + } + else + { + } + } + else + { + /*ʲô*/ + } + } + else + { + } + + if (1u> SendCiCmdDataStruCurSum) + { /**/ + + ShortToChar(cmdSum, &ciToCiDataBuffer[ii]); /*֡*/ + ii += 2u; + } + else + { + curIndex = ii;/**/ + ii += 2u; + + for (jj = 0u; jj < SendCiCmdDataStruCurSum; jj++) + { + if ((SendCiCmdDataStru[jj].SourceCiId == localCi) && (SendCiCmdDataStru[jj].TargetCiId == targetDeviceId)) + { + ShortToChar(SendCiCmdDataStru[jj].CommandID, &ciToCiDataBuffer[ii]); /**/ + ii += 2u; + ShortToChar(SendCiCmdDataStru[jj].Param1, &ciToCiDataBuffer[ii]); /*1*/ + ii += 2u; + ShortToChar(SendCiCmdDataStru[jj].Param2, &ciToCiDataBuffer[ii]); /*2*/ + ii += 2u; + cmdSum++; + } + else + { + } + + } + ShortToChar(cmdSum, &ciToCiDataBuffer[curIndex]); /**/ + } + + /*䶯̬·*/ + cmdSum = 0U; + if (1u > SendCiDrCmdSum) + { /**/ + + ShortToChar(cmdSum, &ciToCiDataBuffer[ii]); /**/ + ii += 2u; + } + else + { + curIndex = ii;/**/ + ii += 2u; + + for (jj = 0u; jj < SendCiDrCmdSum; jj++) + { + if ((SendCiDrCmdDataStru[jj].cSourceCiId == localCi) && (SendCiDrCmdDataStru[jj].cTargetCiId == targetDeviceId)) + { + ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cCmdType; /*鶯̬·*/ + ii += 1u; + + ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cLogSecSeqDir; /*߼з*/ + ii += 1u; + + ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cLogSecSum; /*߼*/ + ii += 1u; + + for (kk = 0U; kk < SendCiDrCmdDataStru[jj].cLogSecSum; kk++) + { + ShortToChar(SendCiDrCmdDataStru[jj].wLogSecIdBuff[kk], &ciToCiDataBuffer[ii]); /*߼ID*/ + ii += 2u; + } + + ShortToChar(SendCiDrCmdDataStru[jj].wTrainId, &ciToCiDataBuffer[ii]); /*гID*/ + ii += 2u; + + ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cTrainLocLogSecSum; /*г߼*/ + ii += 1u; + + for (kk = 0U; kk < SendCiDrCmdDataStru[jj].cTrainLocLogSecSum; kk++) + { + ShortToChar(SendCiDrCmdDataStru[jj].wTrainLocLogSecIdBuff[kk], &ciToCiDataBuffer[ii]); /*г߼ID*/ + ii += 2u; + } + + ciToCiDataBuffer[ii] = SendCiDrCmdDataStru[jj].cSwitchMoveFlag; /*ؽ·ɶ־*/ + ii += 1u; + + ShortToChar(SendCiDrCmdDataStru[jj].wRelStartSignalId, &ciToCiDataBuffer[ii]); /*׸߼ιʼźŻID*/ + ii += 2u; + + cmdSum++; + } + else + { + } + } + ShortToChar(cmdSum, &ciToCiDataBuffer[curIndex]); /*鶯̬·*/ + } + + /*Ԥ40ֽ*/ + ii += 40u; + + /*CIݺͷ͸RCѩ*/ + ClearPackCICmdData(targetDeviceId); + ClearPackCiDrCmdData(targetDeviceId); + + if (CI_SUCCESS == chRtn) + { + wDevType = (UINT16)Get2oo2SheBeiType(); + dstDevId = ((UINT16)(wDevType << 8u) | ((UINT16)targetDeviceId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &ciToCiDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nCI_SEND:%d", ii); + debug_out_array(0xAA, ciToCiDataBuffer, ii); +#endif/*ƽ̨ӡ*/ + +#endif + chRtn = CI_SUCCESS; + } + else + { + /*дʧ*/ + chRtn = CI_ERROR; + } + } + else + { + ; + } + return chRtn; +} + + + +/* +* ȡ״̬ȨID +* ˵ void +* ֵ 0: ȡʧ +* >0: ״̬ID +*/ +UINT8 GetPhySecIdBufSumhOfOtherCi(void) +{ + return PhySecIdBufSumhOfOtherCi; +} + +/* +* ȡ״̬ȨID +* ˵ const UINT16 bufIndex, ID± +* ֵ 0: ȡʧ +* >0: ״̬ID +*/ +UINT16 GetPhySecIdBufOfOtherCi(const UINT16 bufIndex) +{ + if (bufIndex >= PhySecIdBufSumhOfOtherCi) + { + return 0u; + } + + return PhySecIdBufOfOtherCi[bufIndex]; +} + + +/* +* CI +* ˵ targetDeviceId ĿID +* ֵ void +* WGY -2022.3.10-޸ȱ +*/ +void ClearPackCICmdData(UINT8 targetDeviceId) +{ + UINT16 ii = 0u; + UINT32 cycleNum = 0u; + + UINT16 chNeedKeepSum = 0U; + UINT16 chStruCurSum = 0U; + + cycleNum = Get2oo2CurCycleNum();/*ȡƽ̨ں*/ + chStruCurSum = SendCiCmdDataStruCurSum; + + for (ii = 0U; ii < chStruCurSum; ii++) + { + + if(SENDCI_CMD_DATA_STRU_SUM_MAX > ii) + { + if ((cycleNum >= (SendCiCmdDataStru[ii].CycleNo+1U)) && (SendCiCmdDataStru[ii].TargetCiId == targetDeviceId)) + { + /*ɾ,*/ + } + else + {/*ɾ*/ + SendCiCmdDataStru[chNeedKeepSum++] = SendCiCmdDataStru[ii]; + } + } + } + /*ȫ*/ + for (ii = chNeedKeepSum; ii < chStruCurSum; ii++) + { + SendCiCmdDataStru[ii].SourceCiId = 0U; + SendCiCmdDataStru[ii].TargetCiId = 0U; + SendCiCmdDataStru[ii].CommandID = 0U; + SendCiCmdDataStru[ii].Param1 = 0U; + SendCiCmdDataStru[ii].Param2 = 0U; + SendCiCmdDataStru[ii].CycleNo = 0U; + } + SendCiCmdDataStruCurSum = chNeedKeepSum; +} + +/* +* ȡCICIṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: ṹ鳤 +*/ +UINT16 GetCiRecvCiCmdStruCurSum(void) +{ + return RecvCiCmdDataStruCurSum; +} + +/* +* ȡCICIṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +ToCiCommandDataStruct *GetCiRecvCiCmdDataStruct(void) +{ + return RecvCiCmdDataStru; +} + +/* +* CI͵Ϣ +* ˵ UINT8 cmdID, ID +* UINT16 cmdParam1, 1 +* UINT16 cmdParam2, 2 +* UINT8 toCiId, ͵ID +* ֵ 0: ʧ +* 1: ӳɹ +*/ +void AddCiSendToCiCmdInfo(UINT8 cmdID, UINT16 cmdParam1, UINT16 cmdParam2, UINT8 toCiId) +{ + UINT32 cycleNo = 0u; + UINT8 localCi = GetSystemParaLocalCiId();/*ID*/ + cycleNo = Get2oo2CurCycleNum(); + if(SENDCI_CMD_DATA_STRU_SUM_MAX > SendCiCmdDataStruCurSum) + { + /*Ϣ*/ + SendCiCmdDataStru[SendCiCmdDataStruCurSum].SourceCiId = localCi; + SendCiCmdDataStru[SendCiCmdDataStruCurSum].TargetCiId = toCiId; + SendCiCmdDataStru[SendCiCmdDataStruCurSum].CommandID = cmdID; + SendCiCmdDataStru[SendCiCmdDataStruCurSum].Param1 = cmdParam1; + SendCiCmdDataStru[SendCiCmdDataStruCurSum].Param2 = cmdParam2; + SendCiCmdDataStru[SendCiCmdDataStruCurSum].CycleNo = cycleNo; + SendCiCmdDataStruCurSum++; + } + else + { + debug_infor_printf((const)"Error:AddCiSendToCiCmdInfo,%d exceed max %d\n",SendCiCmdDataStruCurSum,SENDCI_CMD_DATA_STRU_SUM_MAX); + } + +} + +/* +* ȡĿӦĽṹ +* ˵ UINT8 dstId ID +* ֵ NULLʧ NULL 豸ݽṹָ +*/ +CiTransmitStruct* GetDstCiTransInfo(UINT8 dstId) +{ + UINT8 ii = 0u; + CiTransmitStruct *pTmpCiTransInfo = NULL; + + for (ii = 0u; ii < ciTransNum; ii++) + { + if (dstId == ciTransmitStruct[ii].destCiId) + { + /* ҵӦ */ + pTmpCiTransInfo = &ciTransmitStruct[ii]; + break; + } + } + + return pTmpCiTransInfo; +} + +/* +* ȡָCI->CIĽӿ +* ˵ srcId CIݵID +* ֵ NULLʧ NULL 豸 +*/ +CiTransmitStruct* GetSrcCiTransInfo(UINT8 srcId) +{ + UINT8 ii = 0u; + CiTransmitStruct *pTmpCiTransInfo = NULL; + + for (ii = 0u; ii < ciTransNum; ii++) + { + if (srcId == ciTransmitStruct[ii].srcCiId) + { + /* ҵӦ */ + pTmpCiTransInfo = &ciTransmitStruct[ii]; + break; + } + } + + return pTmpCiTransInfo; +} + +/* +* CI֡,ӦPackCiToCiDataFrameһ +* ˵ +* UINT8* dataFrame, Buf +* UINT16* dataLength, ܳȵĵַ +* ֵ +*/ +void PackCiToCiDataFrameUseCfg(UINT8 dstCiId,UINT8* dataFrame, UINT16* dataLength) +{ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 m = 0U; + UINT16 n = 0u; + UINT8 chLogSecIndex = 0u; + UINT16 deviceSum = 0u; /*豸*/ + UINT16 deviceId = 0u; /*豸ID*/ + UINT8 localCi = 0u; /*ID*/ + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + CiTransmitStruct *pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + UINT8 deviceState = 0u;/*豸״̬*/ + UINT16 phySecRLockBelongRouteId = 0u;/*·ID*/ + UINT8 dataIsNeedPack = CI_FALSE;/*Ƿ־*/ + UINT8 phySecLockDir = 0u;/*շ*/ + UINT16 phySecLockDirFlg = 0u;/*շǷȡ־*/ + UINT16 utOverlapUnlockCount = 0u;/*UTν*/ + UINT16 ctOverlapUnlockCount = 0u;/*CTν*/ + UINT16 overlapBelongRouteId = 0u;/*·ID (ֶ̬)*/ + UINT8 overlapUnlockApplyFlag = 0u; /*ZCν־*/ + UINT32 unlockStartCycNum = 0u;/*νʼں (ֶ̬)*/ + UINT32 xuanPaiStartCycNum = 0u;/*ѡſʼں(ֶ̬)*/ + UINT8 floodOpenL = 0u;/*ſ״̬*/ + UINT8 floodCloseR = 0u;/*Źر״̬*/ + UINT8 floodAgreeCloseFromZC = 0u;/*zcͬر״̬*/ + UINT8 floodAgreeCloseOut = 0u;/*ͬر״̬*/ + UINT8 floodAgreeCloseIn = 0u;/*Żزͬر״̬*/ + UINT8 routeBelongCi = 0u; + UINT8 belongCiId = 0u; + UINT8 startLockFlag = 0u; + UINT16 secPLockBelongRouteId = 0u; + UINT16 logSectionSum = 0u; + UINT16* logIdBuf = NULL; + UINT16 logLockBelongRouteId = 0u; + UINT16 logPLockBelongRouteId = 0u; + UINT8 logLockState = 0u; + UINT8 logLockDir = 0u; + UINT8 chLogSecTrainInfoSum = 0U; + UINT16 wTrainId = 0U; + CfpTrainInfoStru tmpTrainInfo = { 0u }; + UINT8 chEnvelopeNum = 0u; + CfpEnvelopeStruct * pEnvelopeInfo = NULL; + UINT8 chEnvelopeIndex = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chLgcResShrFlag = 0U; + UINT8 chCtNum = 0u; + UINT8 chCtIndex = 0u; + CfpCtTrainStruct * pCtInfo = NULL; + UINT16 overlapUnlockTime = 0u; + UINT8 autoRouteSetFlag = 0u; + UINT8 chLogicTrainSum = 0U; /*߼εг*/ + UINT16 dwPhyErrlockTime = 0U;/*ʽ⵹ʱ*/ + LogicTrainResStruct * pstLogicResTrainInfo = NULL; /*߼εгϢָ*/ + UINT8 cLogSecLogicLockState = LOG_SECTION_LOCK_NO; /*߼߼״̬*/ + UINT8 cLogSecLogicLockDir = CI_SYSTEM_DIRECTION_NONE; /*߼߼շ*/ + UINT8 cCiSendAreaSnowNum = 0U; /*RC͸RCѩ*/ + UINT16 cCiSendAreaSnowIndex = 0U; + ToCiAreaSnowStruct* pCiSendAreaSnow = NULL; + UINT8 cRrmSrcRcId = 0U;/* RRMԴRC ID */ + UINT16 wRrmTrainId = 0U;/* RRMгID */ + UINT16 wRrmTrainNextStaId = 0U;/* RRMгһվ̨ID */ + UINT8 chRrmSrcApplyState = 0U;/* ԶRMʱԴTIOC״̬ */ + UINT8 chRrmDstAllowState = 0U;/* ԶRMʱĿTIOC״̬ */ + UINT8 switchIsThisLineFlag = 0U; /*ǷΪ·*/ + UINT8 chSwitchJichaState = 0U; + UINT8 leaveCheckFlag = LOGSEC_LEAVE_LOGSEC_REPLY_NO; + UINT16 wCfpRelAdjaRcSignalId = 0U; /*ֽRCźŻID*/ + UINT8 cCfpSignalLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_YES; /*ֽźŻƱ־*/ + UINT8 cPhySecInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO; + UINT8 chRouteApplySwitchCheckFlag = 0U;/*·״̬־*/ + UINT16 wUsingBelongOverlapId = 0U; /*ID*/ + UINT8 cSwitchUsingState = 0U; /*״̬*/ + UINT8 cProSwtCheckStartFlag = 0U; /*ο鿪ʼ־*/ + UINT8 cProSwtCheckResultFlag = 0U; /*ο־*/ + SwitchDataStruct* pSwitchDataStru = NULL; /*ṹ*/ + UINT16 wPhySecUseRouteId = 0U;/*·ID*/ + UINT16 wProSwSecUseRouteId = 0U;/*·ID*/ + UINT16 wSwPLockRouteIndex = 0U; + UINT8 cSwPLockRouteNum = 0U; + UINT16 wSwPLockOverlapIndex = 0U; + UINT8 cSwPLockOverlapNum = 0U; + UINT8 cLogLockBelLogRouteSum = 0U; + + localCi = GetSystemParaLocalCiId(); + startLockFlag = GetStartLockFlag(); + if((NULL != pTmpCiTransInfo) && (CI_START_LOCK_NO==startLockFlag)) + {/*ݴѾϵŸ豸Ϣ*/ + /*Ϣ*/ + deviceSum = 0u;/**/ + deviceSumIndex = ii;/*αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->switchNum; jj++) + { + deviceId = pTmpCiTransInfo->switchIdBuf[jj];/*ȡID*/ + belongCiId = GetSwitchBelongCiId(deviceId); + if ((localCi == belongCiId) || (dstCiId != belongCiId)) + {/*ڱڶԷ13ABߵ⣩*/ + + ShortToChar(deviceId, &dataFrame[ii]);/*ID*/ + ii += 2u; + dataFrame[ii++] = GetSwitchYLockState(deviceId);/*״̬*/ + dataFrame[ii++] = GetSwitchLockStatus(deviceId);/*״̬*/ + dataFrame[ii++] = GetSwitchFLockState(deviceId);/*״̬*/ + dataFrame[ii++] = GetSwitchCurPosition(deviceId);/*ǰλ*/ + dataFrame[ii++] = GetSingleSwitchCurPosition(deviceId);/*ǰλ*/ + switchIsThisLineFlag = GetSwitchIsThisLineState(deviceId); + if (DEV_IS_THIS_LINE_NO == switchIsThisLineFlag) + { + dataFrame[ii++] = GetConnetSwitchDsState(deviceId); /*ߵ״̬*/ + dataFrame[ii++] = GetConnetSwitchByPassState(deviceId); /*ߵ·״̬,ǽ·ʱδе·״̬Ӱźſ*/ + } + else + { + dataFrame[ii++] = 0U; /*ߵҪֽڣ0*/ + dataFrame[ii++] = 0U; + } + /*̬̬״̬*/ + chSwitchJichaState = GetSwitchPrompylyAlarmInfo(deviceId); + if ((SWITCH_POSITION_DYNAMIC_JICHA == chSwitchJichaState) || (SWITCH_POSITION_SUDDEN_JICHA == chSwitchJichaState)) + { + dataFrame[ii++] = chSwitchJichaState; + } + else + { + dataFrame[ii++] = 0U; /*ǼӦ״̬0*/ + } + + wUsingBelongOverlapId = GetSwitchBelongOverlapId(deviceId); + ShortToChar(wUsingBelongOverlapId, &dataFrame[ii]); /*õıID*/ + ii += 2U; + cSwitchUsingState = GetSwitchUsingState(deviceId); + dataFrame[ii] = cSwitchUsingState; /*״̬*/ + ii++; + + /* zt ɾش 2022-02-15 */ + deviceSum++; + } + else + { + /*ԷϢ*/ + + } + } + /*д*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*Ϣ*/ + deviceSum = 0u;/**/ + deviceSumIndex = ii;/*αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->phySecNum; jj++) + { + deviceId = pTmpCiTransInfo->phySecIdBuf[jj];/*ȡID*/ + belongCiId = GetPhySecBelongCiId(deviceId); + if (localCi == belongCiId) + {/*δڱ*/ + + ShortToChar(deviceId, &dataFrame[ii]); /*ID*/ + ii += 2u; + dataFrame[ii] = GetPhySecCurOccupyState(deviceId); /*βɼռ״̬ڶԷ¼ռʼڣжARBռʱ䡪2025.01.08*/ + ii++; + dataFrame[ii++] = GetPhySecCurMergeState(deviceId); /*ںϺռ״̬*/ + dataFrame[ii++] = GetPhySecPreOccState(deviceId); /*εǰCTUTռ״̬*/ + dataFrame[ii++] = GetPhySecStopSteadyFlag(deviceId); /*ͣϢ*/ + dataFrame[ii++] = GetPhySecUseState(deviceId); /*״̬*/ + wPhySecUseRouteId = GetPhySecUseRouteId(deviceId); + ShortToChar(wPhySecUseRouteId, &dataFrame[ii]); /*·ID*/ + ii += 2U; + wProSwSecUseRouteId = GetPhySecProtectUseRouteId(deviceId); + ShortToChar(wProSwSecUseRouteId, &dataFrame[ii]); /*·ID*/ + ii += 2u; + + dataFrame[ii++] = GetPhySecFLockState(deviceId); /*η״̬*/ + dataFrame[ii++] = GetPhySecArbState(deviceId); /*Arb״̬*/ + dataFrame[ii++] = GetPhySecCurAndMergeState(deviceId); /*ռ״̬*/ + dataFrame[ii++] = GetPhySecJumpLockState(deviceId); /*Ծ״̬*/ + dataFrame[ii++] = GetPhySecFLockType(deviceId); /*η*/ + dataFrame[ii++] = GetPhySecPreResetState(deviceId); /*Ԥλ״̬*/ + dwPhyErrlockTime = GetPhyErrUnlockTime(deviceId); + ShortToChar(dwPhyErrlockTime, &dataFrame[ii]); /*by cgh 20230706 ʾʽ⵹ʱ*/ + ii += 2u; + dataFrame[ii++] = GetPhySecAreaUrgentState(deviceId); /*ƶ״̬*/ + /*RC16.0.0*/ + dataFrame[ii++] = GetPhySecABLTrainFlag(deviceId); /*ABLռ״̬*/ + dataFrame[ii++] = GetPhySecUTTrainFlag(deviceId); /*򻵳ռñ־*/ + cPhySecInHumidRailFlag = GetPhySecInHumidRailFlag(deviceId); + dataFrame[ii++] = cPhySecInHumidRailFlag; /*ʪ־*/ + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + /*д*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*߼Ϣ*/ + deviceSum = 0u;/*߼*/ + deviceSumIndex = ii;/*߼αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->logicSecNum; jj++) + { + deviceId = pTmpCiTransInfo->logicSecIdBuf[jj];/*ȡ߼ID*/ + belongCiId = GetLogSecBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + + ShortToChar(deviceId, &dataFrame[ii]);/*߼ID*/ + ii += 2u; + dataFrame[ii++] = GetLogSecCurCtOrUtOccupyState(deviceId);/*߼ռ״̬*/ + dataFrame[ii++] = GetLogSecLinShiXianSuSetState(deviceId); /* ʱ */ + dataFrame[ii++] = GetLogSecJumpLockState(deviceId); /*߼Ծ״̬*/ + dataFrame[ii++] = GetLgcArbState(deviceId); /*߼ARB״̬*/ + dataFrame[ii++] = GetLogSecSpksFLockState(deviceId); /*߼SPKS״̬*/ + dataFrame[ii++] = GetLogSecProResUseState(deviceId); /*߼αԴ״̬*/ + dataFrame[ii++] = GetLogSecAblUseFlag(deviceId); /*߼ABLӽԴñ־*/ + dataFrame[ii++] = GetLogSecXiansuSpeed(deviceId); /*߼ʱȡֵ*/ + + chLogicTrainSum = GetLogSecTrainInfoSum(deviceId); + dataFrame[ii++] = chLogicTrainSum; + if ((0U < chLogicTrainSum)) + { + pstLogicResTrainInfo = GetLogSecTrainInfo(deviceId); + if ((LOGIC_SECTION_RES_SUM_MAX >chLogicTrainSum) + && (NULL != pstLogicResTrainInfo)) + { + + for (chTrainIndex = 0u; chTrainIndex < chLogicTrainSum; chTrainIndex++) + { + /*ãδϢ 1ֽ*/ + /*鳵-2ֽ*/ + ShortToChar(pstLogicResTrainInfo[chTrainIndex].wTrainId, &dataFrame[ii]); + ii += 2u; + dataFrame[ii++] = pstLogicResTrainInfo[chTrainIndex].chLogicResUsable; + } + } + else + { + ; /*ִ*/ + } + + } + else + { + ; /*û ִ*/ + } + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + /*д߼*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*źŻϢ*/ + deviceSum = 0u;/*źŻ*/ + deviceSumIndex = ii;/*źŻαλ*/ + ii += 2u; + for (jj = 0u; (jj < pTmpCiTransInfo->signalNum)&&(jjsignalIdBuf[jj];/*ȡID*/ + belongCiId = GetSignalBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + + ShortToChar(deviceId, &dataFrame[ii]);/*źŻID*/ + ii += 2u; + dataFrame[ii++] = GetSignalFLockState(deviceId);/*źŻ״̬*/ + dataFrame[ii++] = GetSignalLightExtinctState(deviceId);/*źŻ״̬״̬*/ + dataFrame[ii++] = GetSignalCurColor(deviceId);/*źŻǰʾɫ״̬*/ + dataFrame[ii++] = GetSignalLinShiXianSuSetFlag(deviceId);/*źŻʱ״̬*/ + dataFrame[ii++] = GetSignalSoftDetainFlag(deviceId);/*źŻ۳״̬*/ + dataFrame[ii++] = GetSignalRelayDetainFlag(deviceId);/*źŻӲ߿۳״̬*/ + dataFrame[ii++] = GetSignalMaintainState(deviceId);/*źŻά޵״̬*/ + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + /*дźŻ*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*Ϣ*/ + deviceSum = 0u;/**/ + deviceSumIndex = ii;/*αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->psdNum; jj++) + { + deviceId = pTmpCiTransInfo->psdIdBuf[jj];/*ȡID*/ + belongCiId = GetPsdBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + + ShortToChar(deviceId, &dataFrame[ii]);/*ID*/ + ii += 2u; + dataFrame[ii++] = GetPsdState(deviceId);/*״̬*/ + dataFrame[ii++] = GetPsdMutualLockRemoveState(deviceId);/*Ż״̬*/ + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + /*д*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*ͣťϢ*/ + deviceSum = 0u;/*ͣť*/ + deviceSumIndex = ii;/*ͣťαλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->esbNum; jj++) + { + deviceId = pTmpCiTransInfo->esbIdBuf[jj];/*ȡͣťID*/ + belongCiId = GetEsbBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + + ShortToChar(deviceId, &dataFrame[ii]);/*ͣťID*/ + ii += 2u; + dataFrame[ii++] = GetEsbState(deviceId);/*ͣť״̬*/ + + dataFrame[ii++] = GetEsbCutState(deviceId);/*ͣ·ť״̬*/ + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + /*дͣť*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*·Ϣ*/ + deviceSum = 0u;/*·*/ + deviceSumIndex = ii;/*·αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->routeNum; jj++) + { + deviceId = pTmpCiTransInfo->routeIdBuf[jj];/*ȡ·ID*/ + belongCiId = GetRouteBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + + ShortToChar(deviceId, &dataFrame[ii]);/*·ID 2B*/ + ii += 2u; + dataFrame[ii++] = GetRouteState(deviceId);/*·״̬ 1B*/ + dataFrame[ii++] = GetRouteLevel(deviceId);/*·ල 1B*/ + + /* 2B:UTνʱ*/ + utOverlapUnlockCount = (UINT16)GetSystemParaProtSecUnlockCyc(); + ShortToChar(utOverlapUnlockCount,&dataFrame[ii]); + ii+=2u; + + /* 2B:CTνʱ*/ + ctOverlapUnlockCount = (UINT16)GetSystemParaCtProtSecUnlockCyc(); + ShortToChar(ctOverlapUnlockCount,&dataFrame[ii]); + ii+=2u; + + /*ԶźŽ·ȡ״̬*/ + dataFrame[ii++] = GetAutoSigCancleState(deviceId); + + /*·Ҫձ־*/ + dataFrame[ii++] = GetRouteOverlapNeedCIlockFlag(deviceId); + + /*·׷ٰ־*/ + dataFrame[ii++] = GetRouteStateFlag(deviceId); + + /*·Զ־*/ + dataFrame[ii++] = GetRouteAutoTriggerFlag(deviceId); + + + deviceSum++; + + } + else + { + /*DZϢ*/ + } + } + /*д·*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + +#if 0 + if (GetStartLockFlag() == CI_START_LOCK_YES) + {/*ϵ״̬*/ + deviceSum = 0u;/*״̬*/ + deviceSumIndex = ii;/*״̬αλ*/ + ii += 2u; + /*д*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + } + else + {/*ϵ״̬*/ + } +#endif + /*״̬Ϣ*/ + deviceSum = 0u;/*״̬*/ + deviceSumIndex = ii;/*״̬αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->phySecIdBufSumhOfOtherCi; jj++) + { + dataIsNeedPack = CI_FALSE; + + deviceId = pTmpCiTransInfo->wPhySecIdBufOfOtherCi[jj];/*ȡID,CIеԼ·IJڱ*/ + + phySecLockDirFlg = pTmpCiTransInfo->phySecIdLockDirFlag[jj];/*ȡշǷȡ־ǰphySecNumӿ*/ + + deviceState = GetPhySecLockState(deviceId);/*ȡ״̬*/ + + if((PHYSICAL_SECTION_LOCK_NORMAL == deviceState) || (PHYSICAL_SECTION_LOCK_DELAY == deviceState)) + {/*ջʱ*/ + phySecRLockBelongRouteId = GetPhySecRLockBelongRouteId(deviceId); + routeBelongCi = GetRouteBelongCiId(phySecRLockBelongRouteId); + if(localCi != routeBelongCi) + {/*ս·ڱ*/ + dataIsNeedPack = CI_FALSE; + /*߼·ڱҲĿ人·2ڵ3ֵ + ӵĵ2εĽ·״̬*/ + if (dstCiId != routeBelongCi) + { + /*ҲĿ*/ + dataIsNeedPack = CI_TRUE; + } + else + {/*Ŀֹܷ*/ + dataIsNeedPack = CI_FALSE; + } + } + else + { + dataIsNeedPack = CI_TRUE; + } + } + else + {/*״̬*/ + dataIsNeedPack = CI_TRUE; + } + + if(CI_TRUE == dataIsNeedPack) + { + ShortToChar(deviceId, &dataFrame[ii]);/*ID*/ + ii += 2u; + dataFrame[ii++] = GetPhySecLockState(deviceId);/*״̬*/ + + ShortToChar(GetPhySecPLockBelongRouteId(deviceId), &dataFrame[ii]);/*η·ID*/ + ii += 2u; + ShortToChar(GetPhySecRLockBelongRouteId(deviceId), &dataFrame[ii]);/*ν··ID*/ + ii += 2u; + ShortToChar(GetRouteOverlapLockedId(GetPhySecPLockBelongRouteId(deviceId)), &dataFrame[ii]);/*ηOverLapID*/ + ii += 2u; + + phySecLockDir = GetPhySecLockDirection(deviceId);/*ȡշ*/ + if (PHYSEC_LOCKDIRECTION_OPPST_YES == phySecLockDirFlg) + {/*շҪȡ*/ + if (CI_SYSTEM_DIRECTION_DOWN == phySecLockDir) + {/*շ*/ + phySecLockDir = CI_SYSTEM_DIRECTION_UP; + } + else if (CI_SYSTEM_DIRECTION_UP == phySecLockDir) + {/*շ*/ + phySecLockDir = CI_SYSTEM_DIRECTION_DOWN; + } + else + {/**/ + } + } + + dataFrame[ii++] = phySecLockDir;/*շ*/ + deviceSum++; + } + } + /*д*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + deviceSum = 0u;/*SPKS*/ + deviceSumIndex = ii;/*SPKSαλ*/ + ii += 2u; + for (jj = 0u;jj < pTmpCiTransInfo->spksNum;jj++) + { + deviceId = pTmpCiTransInfo->spksIdBuff[jj]; + belongCiId = GetSpksBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + ShortToChar(deviceId,&dataFrame[ii]); + ii += 2u; + dataFrame[ii++] = GetSpksState(deviceId); + dataFrame[ii++] = GetSpksCutState(deviceId); + deviceSum++; + } + } + ShortToChar(deviceSum,&dataFrame[deviceSumIndex]); + + deviceSum = 0u;/*̵*/ + deviceSumIndex = ii;/*̵αλ*/ + ii += 2u; + for (jj = 0u;jj < pTmpCiTransInfo->zcjNum;jj++) + { + deviceId = pTmpCiTransInfo->zcjIdBuf[jj]; + belongCiId = GetRelayBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + ShortToChar(deviceId,&dataFrame[ii]); + ii += 2u; + dataFrame[ii++] = GetRelayCollState(deviceId); + deviceSum++; + } + } + ShortToChar(deviceSum,&dataFrame[deviceSumIndex]); + + + /*Ϣ*/ + deviceSum = 0u;/*ͷ*/ + deviceSumIndex = ii;/*ͷαλ*/ + ii += 2u; + for (jj = 0u;jj < pTmpCiTransInfo->floodGateNum;jj++) + { + deviceId = pTmpCiTransInfo->floodGateIdBuf[jj]; + belongCiId = GetFloodGateBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + ShortToChar(deviceId,&dataFrame[ii]); + ii += 2u; + floodOpenL = GetFloodGateCurOpenLockState(deviceId);/*ſ*/ + floodCloseR = GetFloodGateCurCloseRequestSta(deviceId);/*Ź*/ + + floodAgreeCloseFromZC = GetFloodGateCurZCAgrCloseAck(deviceId);/*յzcͬر*/ + floodAgreeCloseIn = GetFloodGateCurAgreeCloseSta(deviceId);/*Ųɼͬر*/ + floodAgreeCloseOut = GetFloodGateCurAgreeCloseOutSta(deviceId);/*ͬر*/ + + dataFrame[ii++] = floodOpenL;/*ſ*/ + dataFrame[ii++] = floodCloseR;/*Ź*/ + dataFrame[ii++] = floodAgreeCloseFromZC;/*յzcͬر*/ + dataFrame[ii++] = floodAgreeCloseIn;/*Ųɼͬر*/ + dataFrame[ii++] = floodAgreeCloseOut;/*ͬر*/ + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + ShortToChar(deviceSum,&dataFrame[deviceSumIndex]); + + /*鱣Ϣ*/ + deviceSum = 0u;/**/ + deviceSumIndex = ii;/*αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->overlapNum; jj++) + { + deviceId = pTmpCiTransInfo->overlapIdBuf[jj];/*ȡID*/ + belongCiId = GetOverlapBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + + ShortToChar(deviceId, &dataFrame[ii]);/*ID 2B*/ + ii += 2u; + + /*2B:·ID (ֶ̬)*/ + overlapBelongRouteId = GetOverlapBelongRouteId(deviceId); + ShortToChar(overlapBelongRouteId,&dataFrame[ii]); + ii += 2u; + + /* 4B:ָIDʼں*/ + unlockStartCycNum = GetOverlapUnlockStartCycNum(deviceId); + LongToChar(unlockStartCycNum,&dataFrame[ii]); + ii += 4u; + + /* 4B:ָIDѡſʼں*/ + xuanPaiStartCycNum = GetOverlapXuanPaiStartCycNum(deviceId); + LongToChar(xuanPaiStartCycNum,&dataFrame[ii]); + ii += 4u; + + /* 1B ȡָIDZCα־*/ + overlapUnlockApplyFlag = GetOverlapUnlockApplyFlag(deviceId); + dataFrame[ii++] = overlapUnlockApplyFlag; + + /* 2B ȡָIDνʱ*/ + overlapUnlockTime = GetOverlapUnlockTime(deviceId); + ShortToChar(overlapUnlockTime, &dataFrame[ii]);/*νʱ 2B*/ + ii += 2U; + + cProSwtCheckStartFlag = GetOverlapProSwtCheckStartFlag(deviceId); + dataFrame[ii] = cProSwtCheckStartFlag; /*鱣η鿪ʼ־*/ + ii++; + + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + /*д*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*cgh-ϲCID-2539-7Զͨ·Ϣ*/ + deviceSum = 0u; + deviceSumIndex = ii; + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->autoRouteNum; jj++) + { + deviceId = pTmpCiTransInfo->autoRouteIdBuf[jj]; + belongCiId = GetAutoRouteBelongCiId(deviceId); + if (localCi == belongCiId) + { + ShortToChar(deviceId, &dataFrame[ii]); + ii += 2u; + /*ȡԶͨ·־*/ + autoRouteSetFlag = GetAutoRouteSetFlag(deviceId); + dataFrame[ii++] = autoRouteSetFlag; + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + /*дԶͨ·*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*߼״̬Ϣ*/ + deviceSum = 0u;/*״̬߼*/ + deviceSumIndex = ii;/*״̬߼αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->phySecIdBufSumhOfOtherCi; jj++) + { + deviceId = pTmpCiTransInfo->wPhySecIdBufOfOtherCi[jj]; + + /*ȡ߼Ϣ*/ + logSectionSum = GetPhySecIncLogSecSum(deviceId); + logIdBuf = GetPhySecIncLogSecIdBuf(deviceId); + /*߼Ϣȷ*/ + if ((0u < logSectionSum) && (NULL != logIdBuf)) + { + for (n = 0u; n < logSectionSum; n++) + { + dataIsNeedPack = CI_FALSE; + /*ȡ״̬շ*/ + logLockState = GetLogSecLockState(logIdBuf[n]); + logLockDir = GetLogSecLockDir(logIdBuf[n]); + chLgcResShrFlag = GetLogSecResShareFlag(logIdBuf[n]); + /*·Ϣ*/ + logLockBelongRouteId = GetLogSecLockBelongRoute(logIdBuf[n]); + /* յĽ·Ϣ */ + logPLockBelongRouteId = GetLogSecPLockRouteId(logIdBuf[n]); + cLogSecLogicLockState = GetLogSecLogLockState(logIdBuf[n]); /*߼߼״̬*/ + cLogSecLogicLockDir = GetLogSecLogLockDir(logIdBuf[n]); /*߼߼շ*/ + + /*գʱ״̬*/ + if ((LOG_SECTION_LOCK_NORMAL == logLockState) || (LOG_SECTION_LOCK_DELAY == logLockState)) + { + dataIsNeedPack = CI_FALSE; + routeBelongCi = GetRouteBelongCiId(logLockBelongRouteId); + /*·ڱҲĿ*/ + if ((localCi == routeBelongCi) || ((localCi != routeBelongCi) && (dstCiId != routeBelongCi))) + { + dataIsNeedPack = CI_TRUE; + } + else + { + dataIsNeedPack = CI_FALSE; + /**/ + } + } + else + { + dataIsNeedPack = CI_TRUE; + } + + if (CI_TRUE == dataIsNeedPack) + { + ShortToChar(logIdBuf[n], &dataFrame[ii]);/*߼ID*/ + ii += 2U; + dataFrame[ii++] = logLockState; /*߼״̬*/ + ShortToChar(logLockBelongRouteId, &dataFrame[ii]); /*߼·ID*/ + ii += 2U;/*շ*/ + + ShortToChar(logPLockBelongRouteId, &dataFrame[ii]); /*߼αID*/ + ii += 2U;/*շ*/ + dataFrame[ii++] = logLockDir; + + dataFrame[ii++] = cLogSecLogicLockState; /*߼߼״̬*/ + dataFrame[ii++] = cLogSecLogicLockDir; /*߼߼շ*/ + cLogLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(logIdBuf[n]); + dataFrame[ii++] = cLogLockBelLogRouteSum; /*߼߼߼·*/ + + dataFrame[ii++] = chLgcResShrFlag; + /* ߼Դг */ + chLogSecTrainInfoSum = GetLogSecTrainInfoSum(logIdBuf[n]); /*߼г*/ + dataFrame[ii++] = chLogSecTrainInfoSum; + + for (chLogSecIndex = 0u; chLogSecIndex < chLogSecTrainInfoSum; chLogSecIndex++) + { + wTrainId = GetLogSecTrainIdByIndex(logIdBuf[n], chLogSecIndex); + ShortToChar(wTrainId, &dataFrame[ii]);/*гID*/ + ii += 2u; + } + + deviceSum++; + } + } + } + } + /*д߼*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + /*дϢܳ*/ + *dataLength = ii; + + /* ߽гϢ */ + deviceSum = 0u;/*ͱ߽*/ + deviceSumIndex = ii;/*ͱ߽αλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->wCutoffPointNum; jj++) + { + /* ߽ID */ + deviceId = pTmpCiTransInfo->wCutoffPointBuf[jj]; + tmpTrainInfo = GetCfpLocalOcTrainInfo(deviceId); + chEnvelopeNum = GetCfpLocalOcENum(deviceId); + pEnvelopeInfo = GetCfpLocalOcEData(deviceId); + chCtNum = GetCfpLocalOcCtNum(deviceId); + pCtInfo = GetCfpLocalOcCtData(deviceId); + + dataIsNeedPack = CI_FALSE; + + if ((UINT16_MAX != tmpTrainInfo.wTrainId) && (UINT8_MAX != chEnvelopeNum) && (NULL != pEnvelopeInfo) + && (UINT8_MAX != chCtNum) && (NULL != pCtInfo)) + { + dataIsNeedPack = CI_TRUE; + } + + if (CI_TRUE == dataIsNeedPack) + { + ShortToChar(deviceId, &dataFrame[ii]);/*ֽID*/ + ii += 2u; + + ShortToChar(tmpTrainInfo.wTrainId, &dataFrame[ii]);/*гID*/ + ii += 2u; + + dataFrame[ii] = tmpTrainInfo.chTrainLevel; /* гȼ */ + ii++; + + LongToChar(tmpTrainInfo.dwDis, &dataFrame[ii]);/*гID*/ + ii += 4u; + + dataFrame[ii++] = chEnvelopeNum;/* ֽ㷢͸OCİ */ + + for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++) + { + dataFrame[ii++] = pEnvelopeInfo[chEnvelopeIndex].envelopeType; /* */ + + ShortToChar(pEnvelopeInfo[chEnvelopeIndex].headTrainID, &dataFrame[ii]); /* ǰID */ + ii += 2u; + + ShortToChar(pEnvelopeInfo[chEnvelopeIndex].tailTrainID, &dataFrame[ii]); /* ID */ + ii += 2u; + + dataFrame[ii++] = pEnvelopeInfo[chEnvelopeIndex].startPos.Dir; /* 㷽 */ + + ShortToChar(pEnvelopeInfo[chEnvelopeIndex].startPos.Lnk, &dataFrame[ii]);/* link */ + ii += 2u; + + LongToChar(pEnvelopeInfo[chEnvelopeIndex].startPos.Off, &dataFrame[ii]);/* offset */ + ii += 4u; + + dataFrame[ii++] = pEnvelopeInfo[chEnvelopeIndex].endPos.Dir;/* յ㷽 */ + + ShortToChar(pEnvelopeInfo[chEnvelopeIndex].endPos.Lnk, &dataFrame[ii]);/* յlink */ + ii += 2u; + + LongToChar(pEnvelopeInfo[chEnvelopeIndex].endPos.Off, &dataFrame[ii]);/* յoffset */ + ii += 4u; + + dataFrame[ii++] = (pEnvelopeInfo[chEnvelopeIndex].trianCnt); /* г */ + + for (chTrainIndex = 0u; chTrainIndex < pEnvelopeInfo[chEnvelopeIndex].trianCnt; chTrainIndex++) + { + ShortToChar(pEnvelopeInfo[chEnvelopeIndex].trainID[chTrainIndex], &dataFrame[ii]); /* гID */ + ii += 2u; + + dataFrame[ii++] = pEnvelopeInfo[chEnvelopeIndex].ACTPort[chTrainIndex]; /* ֽгˡUCTRMMжϼ */ + } + } + + dataFrame[ii++] = chCtNum;/* ֽ㷢͸TIOCͨų */ + for (chCtIndex = 0u; chCtIndex < chCtNum; chCtIndex++) + { + ShortToChar(pCtInfo[chCtIndex].wTrainId, &dataFrame[ii]);/* ͨгID */ + ii += 2u; + + dataFrame[ii++] = pCtInfo[chCtIndex].chLevel;/* гм */ + + LongToChar(pCtInfo[chCtIndex].dwDelay, &dataFrame[ii]);/* TIOCгͨʱ */ + ii += 4u; + + ShortToChar(pCtInfo[chCtIndex].wSpeed, &dataFrame[ii]);/* гٶ */ + ii += 2u; + + dataFrame[ii++] = pCtInfo[chCtIndex].chSpeedDir;/* гٶȷ */ + + dataFrame[ii++] = pCtInfo[chCtIndex].chTrainDir;/* гз */ + + ShortToChar(pCtInfo[chCtIndex].wMaxHeadLink, &dataFrame[ii]);/* ͨгȫǰlink */ + ii += 2u; + + LongToChar(pCtInfo[chCtIndex].dwMaxHeadOff, &dataFrame[ii]);/* ͨгȫǰƫ */ + ii += 4u; + + ShortToChar(pCtInfo[chCtIndex].wMinHeadLink, &dataFrame[ii]);/* ͨгСȫǰlink */ + ii += 2u; + + LongToChar(pCtInfo[chCtIndex].dwMinHeadOff, &dataFrame[ii]);/* ͨгСȫǰƫ */ + ii += 4u; + + ShortToChar(pCtInfo[chCtIndex].wMaxTailLink, &dataFrame[ii]);/* ͨгȫlink */ + ii += 2u; + + LongToChar(pCtInfo[chCtIndex].dwMaxTailOff, &dataFrame[ii]);/* ͨгȫƫ */ + ii += 4u; + + ShortToChar(pCtInfo[chCtIndex].wMinTailLink, &dataFrame[ii]);/* ͨгСȫlink */ + ii += 2u; + + LongToChar(pCtInfo[chCtIndex].dwMinTailOff, &dataFrame[ii]);/* ͨгСȫƫ */ + ii += 4u; + } + + /*ֽԶRMϢ*/ + cRrmSrcRcId = GetCfpRrmSrcRcId(deviceId); /*RRMԴRC ID*/ + wRrmTrainId = GetCfpRrmTrainId(deviceId); /* RRMгID */ + wRrmTrainNextStaId = GetCfpRrmTrainNextStaId(deviceId); /* RRMгһվ̨ID */ + chRrmSrcApplyState = GetCfpRrmSrcApplyState(deviceId); /* ԶRMʱԴTIOC״̬ */ + chRrmDstAllowState = GetCfpRrmDstAllowState(deviceId); /* ԶRMʱĿTIOC״̬ */ + + dataFrame[ii] = cRrmSrcRcId; + ii++; + ShortToChar(wRrmTrainId, &dataFrame[ii]); + ii += 2U; + ShortToChar(wRrmTrainNextStaId, &dataFrame[ii]); + ii += 2U; + if (cRrmSrcRcId == localCi) + { + dataFrame[ii] = chRrmSrcApplyState; + } + else + { + dataFrame[ii] = TRAIN_RRM_LOCALCI_NOT_APPLY; /*ԴRCĬδ*/ + } + ii++; + dataFrame[ii] = chRrmDstAllowState; + ii++; + + wCfpRelAdjaRcSignalId = GetCfpRelAdjacentRcSignalId(deviceId); + ShortToChar(wCfpRelAdjaRcSignalId, &dataFrame[ii]); /*ֽRCźŻ*/ + ii += 2U; + + cCfpSignalLightUpFlag = GetCfpSignalLightUpFlag(deviceId); + dataFrame[ii] = cCfpSignalLightUpFlag; + ii++; + + deviceSum++; + } + + SetCfpSignalLightUpFlag(deviceId, SIGNAL_SLEEP_TRAIN_LIGHTUP_NO); /*ɺӦƱ־*/ + } + + /*ֽ*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*ѩϢ*/ + cCiSendAreaSnowIndex = ii; /*ѩ*/ + ii++; + pCiSendAreaSnow = GetCiSendAreaSnowInfo(dstCiId); + if (NULL != pCiSendAreaSnow) + { + for (m = 0U; m < pCiSendAreaSnow->cPlatFormNum; m++) + { + LongToChar(pCiSendAreaSnow->dwPlatFormId[m], &dataFrame[ii]); /*վ̨ͨID*/ + ii += 4U; + cCiSendAreaSnowNum++; + } + } + else + { + cCiSendAreaSnowNum = 0U; /*δ鵽ĿѩϢѩΪ0*/ + } + dataFrame[cCiSendAreaSnowIndex] = cCiSendAreaSnowNum; /*ѩ*/ + + /*·һȥ߼ABLгϢ*/ + deviceSum = 0u;/*ȥ߼*/ + deviceSumIndex = ii;/*ȥαλ*/ + ii += 2u; + for (jj = 0u; jj < pTmpCiTransInfo->routeleaveLogSumOfOtherCi; jj++) + { + deviceId = pTmpCiTransInfo->wrouteleaveLogIdBufOfOtherCi[jj];/*ȡ߼ID*/ + belongCiId = GetLogSecBelongCiId(deviceId); + if (localCi == belongCiId) + {/*ڱ*/ + + ShortToChar(deviceId, &dataFrame[ii]);/*߼ID 2B*/ + ii += 2u; + leaveCheckFlag= RouteLeaveLogSecCheck(deviceId); /*Ƿͨȥμ־ 1B*/ + if (CI_SUCCESS == leaveCheckFlag) + { + dataFrame[ii++] = LOGSEC_LEAVE_LOGSEC_REPLY_YES; + } + else + { + dataFrame[ii++] = LOGSEC_LEAVE_LOGSEC_REPLY_NO; + } + deviceSum++; + } + else + { + /*DZϢ*/ + } + } + /*дȥ߼*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*·Ҫ״̬Ľ·Ϣ*/ + deviceSum = 0U;/*·Ҫ״̬Ľ·Ŀ*/ + deviceSumIndex = ii;/*·Ҫ״̬Ľ·Ŀαλ*/ + ii += 2U; + for (jj = 0u; jj < pTmpCiTransInfo->wNeedCheckSwitchStateRouteSum; jj++) + { + chRouteApplySwitchCheckFlag = GetRouteApplySwitchCheckFlag(pTmpCiTransInfo->szNeedCheckSwStateRouteBuf[jj]); + if ((ROUTE_APPLY_SWITCH_CHECK_NO == chRouteApplySwitchCheckFlag) || (ROUTE_APPLY_SWITCH_CHECK_YES == chRouteApplySwitchCheckFlag)) + { + ;/*·־dzɹʧҪ·*/ + ShortToChar(pTmpCiTransInfo->szNeedCheckSwStateRouteBuf[jj], &dataFrame[ii]);/*·ID 2B*/ + ii += 2U; + dataFrame[ii++] = chRouteApplySwitchCheckFlag; + deviceSum++; + } + else + { + ; /*״̬ΪĬϲڿ*/ + } + } + /*дȥ·Ҫ״̬Ľ·Ŀ*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*εķ*/ + deviceSum = 0U; + deviceSumIndex = ii; + ii += 2U; + for (jj = 0U; jj < pTmpCiTransInfo->wNeedCheckProSwtStateOlpNum; jj++) + { + deviceId = pTmpCiTransInfo->szNeedCheckProSwtStateOlpIdBuf[jj]; + cProSwtCheckResultFlag = GetOverlapProSwtCheckResultFlag(deviceId); + if ((PROSWITCH_CHECK_RESULT_VALID == cProSwtCheckResultFlag) || (PROSWITCH_CHECK_RESULT_INVALID == cProSwtCheckResultFlag)) + { + ShortToChar(deviceId, &dataFrame[ii]); /*ID*/ + ii += 2U; + + dataFrame[ii++] = cProSwtCheckResultFlag; /**/ + deviceSum++; + } + else + { + /*״̬ΪĬϲڿ*/ + } + } + /*дҪı*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*鱻·/ηյķϢ*/ + deviceSum = 0U; + deviceSumIndex = ii; + ii += 2U; + pSwitchDataStru = GetSwitchData(); + if (NULL != pSwitchDataStru) + { + for (jj = 0U; jj < pTmpCiTransInfo->wSwitchSumOfOtherCi; jj++) + { + cSwPLockRouteNum = 0U; /*0*/ + cSwPLockOverlapNum = 0U; + deviceId = pTmpCiTransInfo->szSwitchIdBufOfOtherCi[jj];/*ȡID*/ + belongCiId = GetSwitchBelongCiId(deviceId); + if (dstCiId == belongCiId) + { + if ((0U < pSwitchDataStru[deviceId].PLockedRouteNum) || (0U < pSwitchDataStru[deviceId].PLockedOverlapNum)) + { + ShortToChar(deviceId, &dataFrame[ii]); /*ID*/ + ii += 2U; + + wSwPLockRouteIndex = ii; /*·*/ + ii++; + for (m = 0U; m < SWITCH_MAX_PROTECT_LOCKED_NUM; m++) + { + if (0U != pSwitchDataStru[deviceId].PLockedRouteIdArr[m]) + { + ShortToChar(pSwitchDataStru[deviceId].PLockedRouteIdArr[m], &dataFrame[ii]); /*յĽ·ID*/ + ii += 2U; + cSwPLockRouteNum++; + } + else + { + /*·IDΪ0*/ + } + } + dataFrame[wSwPLockRouteIndex] = cSwPLockRouteNum; /*յĽ·*/ + + wSwPLockOverlapIndex = ii; /*յı*/ + ii++; + for (m = 0U; m < SWITCH_MAX_PROTECT_LOCKED_NUM; m++) + { + if (0U != pSwitchDataStru[deviceId].PLockedOverlapIdArr[m]) + { + ShortToChar(pSwitchDataStru[deviceId].PLockedOverlapIdArr[m], &dataFrame[ii]); /*յıID*/ + ii += 2U; + cSwPLockOverlapNum++; + } + else + { + /*IDΪ0*/ + } + } + dataFrame[wSwPLockOverlapIndex] = cSwPLockOverlapNum; /*յı*/ + + deviceSum++; /*ķ+1*/ + } + else + { + /*ڷգ*/ + } + } + else + { + /**/ + } + } + } + else + { + /**/ + } + /*д/·յ*/ + ShortToChar(deviceSum, &dataFrame[deviceSumIndex]); + + /*дϢܳ*/ + *dataLength = ii; + } + else + { + /*豸Ŀ0*/ + for (ii=0u;iisrcCiId == belongCiId) + { + pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi = 0u; + /* õΣҲҪͱ */ + for (jj = 0u; jj < pTmpCiTransmitStru->phySecNum; jj++) + { + /* ·ڵΣڱҪպ״̬ */ + phyBelongCIid = GetPhySecBelongCiId(pTmpCiTransmitStru->phySecIdBuf[jj]); + wPhySecIdCheck = CheckPhyBufOfOtherCiExist(pTmpCiTransmitStru->destCiId, pTmpCiTransmitStru->phySecIdBuf[jj]); + + if ((phyBelongCIid == belongCiId) && (CI_SUCCESS == wPhySecIdCheck)) + { + if (PHYSICAL_SECTION_SUM_MAX > pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi) + { + pTmpCiTransmitStru->wPhySecIdBufOfOtherCi[pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi] = pTmpCiTransmitStru->phySecIdBuf[jj]; + pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi++; + } + else + { + reVal = CI_ERROR; + } + } + else + { + ; /**/ + } + } + /* Ҫ͵ȫ뷢ϵ */ + for (jj = 0u; jj < pTmpCiTransmitStru->routeNum; jj++) + { + routePhySecSum = GetRoutePhysicalSectionSum(pTmpCiTransmitStru->routeIdBuf[jj]);/*·Ŀ*/ + routePhySecData = GetRouteSectionData(pTmpCiTransmitStru->routeIdBuf[jj]); /*·*/ + + for (kk = 0u; kk < routePhySecSum; kk++) + { + /* ·ڵΣڱҪպ״̬ */ + phyBelongCIid = GetPhySecBelongCiId(routePhySecData[kk].PhysicalSectionId); + wPhySecIdCheck = CheckPhyBufOfOtherCiExist(pTmpCiTransmitStru->destCiId, routePhySecData[kk].PhysicalSectionId); + + if ((phyBelongCIid != belongCiId) && (phyBelongCIid == pTmpCiTransmitStru->destCiId) && (CI_SUCCESS == wPhySecIdCheck)) + { + /*βڱĿ*/ + if (PHYSICAL_SECTION_SUM_MAX > pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi) + { + pTmpCiTransmitStru->wPhySecIdBufOfOtherCi[pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi] = routePhySecData[kk].PhysicalSectionId; + pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi++; + } + else + { + reVal = CI_ERROR; + } + } + else + { + ; /**/ + } + } + + chRouteProSwitchSum = GetRouteRelatedProtectSwitchSum(pTmpCiTransmitStru->routeIdBuf[jj]); + pRouteProtectSwitchStru = GetRouteRelatedProtSwitchData(pTmpCiTransmitStru->routeIdBuf[jj]); + + for (kk = 0u; kk < chRouteProSwitchSum; kk++) + { + wProSwRelPhySecId = GetSwitchPhySectionId(pRouteProtectSwitchStru[kk].ProtectSwitchId); + phyBelongCIid = GetPhySecBelongCiId(wProSwRelPhySecId); + wPhySecIdCheck = CheckPhyBufOfOtherCiExist(pTmpCiTransmitStru->destCiId, wProSwRelPhySecId); + + if ((phyBelongCIid != belongCiId) && (phyBelongCIid == pTmpCiTransmitStru->destCiId) && (CI_SUCCESS == wPhySecIdCheck)) + { + /*βڱĿ*/ + if (PHYSICAL_SECTION_SUM_MAX > pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi) + { + pTmpCiTransmitStru->wPhySecIdBufOfOtherCi[pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi] = wProSwRelPhySecId; + pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi++; + } + else + { + reVal = CI_ERROR; + } + } + else + { + ; /**/ + } + } + + } + } + else + { + ; /*ʼ*/ + } + } + + return reVal; +} + +/* +* 鱾״̬ȨIDǷ +* ˵ const UINT8 chDetCiId ĿID +* const UINT16 wPhySecId ID +* ֵ CI_SUCCESS δ +* CI_ERROR +* edit cgh 20240107 +*/ +UINT8 CheckPhyBufOfOtherCiExist(const UINT8 chDetCiId,const UINT16 wPhySecId) +{ + UINT16 ii = 0U; /* α */ + UINT16 jj = 0U; + UINT8 belongCiId = 0U; /*ID*/ + CiTransmitStruct* pTmpCiTransmitStru = NULL; + UINT8 reVal = CI_ERROR; + + for (ii = 0U; ii < ciTransNum; ii++) + { + reVal = CI_SUCCESS; + pTmpCiTransmitStru = &ciTransmitStruct[ii]; + belongCiId = GetSystemParaLocalCiId(); + + if ((pTmpCiTransmitStru->srcCiId == belongCiId) && (pTmpCiTransmitStru->destCiId == chDetCiId)) + { + /*ֻҵһ*/ + for (jj = 0U; jj < pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi; jj++) + { + if (wPhySecId == pTmpCiTransmitStru->wPhySecIdBufOfOtherCi[jj]) + { + break; + } + else + { + ; + } + } + + if (jj == pTmpCiTransmitStru->phySecIdBufSumhOfOtherCi) + { + ; + } + else + { + /*ظ*/ + reVal = CI_ERROR; + } + } + else + { + ; + } + + if (CI_ERROR == reVal) + { + break; + } + else + { + ; + } + } + + return reVal; +} + + +/* +* CIյ +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +void ClearCiRevCiCmdData(void) +{ + UINT16 ii = 0U; + UINT32 dwCycleNum = 0U; + UINT16 cStruCurSum = 0U; + UINT16 cNeedKeepSum = 0U; + + dwCycleNum = Get2oo2CurCycleNum(); + cStruCurSum = RecvCiCmdDataStruCurSum; + + for (ii = 0U; ii < cStruCurSum; ii++) + { + if (((dwCycleNum >= (RecvCiCmdDataStru[ii].CycleNo + 1U)) && (CI_CMD_AUTO_SIG_ROUTE_CANCLE != RecvCiCmdDataStru[ii].CommandID)) + || ((dwCycleNum >= (RecvCiCmdDataStru[ii].CycleNo + 2U)) && (CI_CMD_AUTO_SIG_ROUTE_CANCLE == RecvCiCmdDataStru[ii].CommandID))) + { + /*洢ﵽ2ڣɾ,*/ + } + else + { + RecvCiCmdDataStru[cNeedKeepSum] = RecvCiCmdDataStru[ii]; /*ɾ*/ + cNeedKeepSum++; + } + } + + /*ȫ*/ + for (ii = cNeedKeepSum; ii < cStruCurSum; ii++) + { + RecvCiCmdDataStru[ii].SourceCiId = 0U; + RecvCiCmdDataStru[ii].TargetCiId = 0U; + RecvCiCmdDataStru[ii].CommandID = 0U; + RecvCiCmdDataStru[ii].Param1 = 0U; + RecvCiCmdDataStru[ii].Param2 = 0U; + RecvCiCmdDataStru[ii].CycleNo = 0U; + } + + RecvCiCmdDataStruCurSum = cNeedKeepSum; +} + +/* +* ͨӿڵCICI +* ˵ +UINT8* dataBuf,ֽ֡ +const UINT16 dataLength,ֽ֡Чݵij +const UINT8 systemId,ͷ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseCiToCiDataFrameHLHT(UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId) +{ + UINT8 retVal = CI_SUCCESS; + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + UINT32 errCode = 0u; + HLHTGALInfoStruct hlhtGalHead = { 0u }; + INT32 vobcInfoRemainValidiy = 0; + UINT8 headRet = HLHT_HEAD_ERROR;/*ͨ*/ + UINT16 srcCiName, localCiName;/*ԭCIĿֽID*/ + UINT32 curntCycleNo = 0u;/*ǰں*/ + UINT32 ii = 0u; + UINT8 startLockState = 0u; + UINT8 chTransmitRecvDataCycResult = 0U;/*ͨ״̬½*/ + UINT8 ch2oo2SheBeiType = 0U;/*豸*/ + + srcCiName = (CI_SYSTEM_TYPE_CI) * 256U + systemId; + localCiName = (CI_SYSTEM_TYPE_CI) * 256U + localCiId; + + /*ͨϢͷ*/ + hlhtGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.sourceId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.destId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.comPeriod = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.prtclVer = dataBuf[ii++]; + hlhtGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + curntCycleNo = Get2oo2CurCycleNum(); + + /*ͨñͷ*/ + headRet = HLHTCiCommonPacketHeadCheck(srcCiName, localCiName, HLHT_CI_INTER_TYPE, HLHT_CI_INTER_VER, &hlhtGalHead, &errCode, 0, CI_SYSTEM_TYPE_CI); + debug_infor_printf((const)"\nCI %d GAL Check Result:%d errCode:%d", systemId, headRet, errCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + if (HLHT_HEAD_SUCCESS == headRet) + { + /*ϢʱЧ*/ + vobcInfoRemainValidiy = HLHTCommonMsgRemainingValidity(GetCiAndVobcTransBadEnsureTime(), curntCycleNo, GetSystemParaAppCycleTime(), hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN, hlhtGalHead.comPeriod); + + if (vobcInfoRemainValidiy > 0) + { + startLockState = GetStartLockFlag(); + + if(startLockState == CI_START_LOCK_NO) + { + /*ִо*/ + retVal = ParseCiPacketCont(dataBuf + ii, hlhtGalHead.totalDataLen, systemId); + } + else + { + retVal = CI_SUCCESS; + } + + if (CI_SUCCESS == retVal) + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_CI, systemId, curntCycleNo); + + if (CI_SUCCESS == retVal) + { /*CI뱾CIͨ*/ + /*ͨ*/ + chTransmitRecvDataCycResult = SetCiTransmitRecvDataCycNum(localCiId, Get2oo2SheBeiType(), systemId, curntCycleNo); + if (CI_ERROR == chTransmitRecvDataCycResult) + { + /*ʧ*/ + retVal = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } + } + } + else + { + retVal = CI_ERROR; + } + } + else if (HLHT_HEAD_INIT == headRet) + { + if (curntCycleNo > 0u)/*жŴ0Ϊ0Ч*/ + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_CI, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_CI, systemId, curntCycleNo); + } + + retVal = CI_ERROR; + } + else + { + /*ATSֵطCI-CIݽӿϢʹ*/ + if (GAL_COMPARE_INFO_TYPE_ERR == (errCode & GAL_COMPARE_INFO_TYPE_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_INFO_TYPE_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطCI-CIݷͷʶϢ*/ + else if (GAL_COMPARE_SEND_FLAG_ERR == (errCode & GAL_COMPARE_SEND_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_SEND_FLAG_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطCI-CIݽշ־Ϣ*/ + else if (GAL_COMPARE_RECV_FLAG_ERR == (errCode & GAL_COMPARE_RECV_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_RECV_FLAG_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطCI-CIݰ汾УʧϢ*/ + else if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_VER_CHECK_FAIL,ESEND_LEVEL_ATS); + } + /*ATSֵطCI-CIݱԷյһϢʱкŴ*/ + else if (GAL_COMPARE_MSG_BDS_SN_ERR == (errCode & GAL_COMPARE_MSG_BDS_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_MSG_BDS_SN_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطCI-CIݶԷϢкżյһϢʱкŴ*/ + else if (GAL_COMPARE_MSG_SN_ERR == (errCode & GAL_COMPARE_MSG_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_MSG_SN_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطCI-CIЭ汾Ŵ*/ + else if (GAL_COMPARE_PROTOCOL_VER_ERR == (errCode & GAL_COMPARE_PROTOCOL_VER_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_PROTOCOL_VER_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطCI-CIӦòݳЧ*/ + else if (GAL_COMPARE_APP_LEN_ERR == (errCode & GAL_COMPARE_APP_LEN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_APP_LEN_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطCI-CIͨڴ */ + else if (GAL_COMPARE_COM_PERIOD == (errCode & GAL_COMPARE_COM_PERIOD)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_BACK_DATA_COM_PERIOD,ESEND_LEVEL_ATS); + } + else + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_CI2CI_DATA,CI_SYSTEM_TYPE_CI,systemId,ETYPE_COMM_WITH_CI,CI_ERROR,ESEND_LEVEL_ATS); + } + retVal = CI_ERROR; + } + + return retVal; +} +/*ͨ*/ + +static UINT8 SetIntconPhySecRLockState(UINT16 phySecId, UINT8 routeLockState) +{ + UINT16 bufIndex = 0u; + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + IntconPhySecData[bufIndex].RLockState = routeLockState; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +: +ȡһ +: +const UINT8 *pInputData ָ +: +UINT16 *pPacketType +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParsePacketType(const UINT8* pInputData, UINT16* pPacketType, UINT16* pItemLen) +{ + UINT8 cRetVal = CI_ERROR; + + if ((NULL != pInputData) && (NULL != pPacketType) && (NULL != pItemLen)) + { + *pPacketType = ShortFromChar(pInputData); + *pItemLen = PACKET_TYPE_LEN; + + cRetVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + +/* +: +Ӧñݰ +: +UINT8 *pInputData ָ룬UINT16 packetType Ӧñ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPacketType(UINT8 *pInputData, UINT16 packetType, UINT16 *pItemLen) +{ + UINT8 cRetVal = CI_ERROR; + + if ((NULL != pInputData) && (NULL != pItemLen)) + { + ShortToChar(packetType, pInputData); + *pItemLen = PACKET_TYPE_LEN; + + cRetVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + +/* +: +ȡһij +: +const UINT8 *pInputData ָ +: +UINT16 *pPacketLen ij +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParsePacketLength(const UINT8 *pInputData, UINT16 *pPacketLen, UINT16 *pItemLen) +{ + UINT8 cRetVal = CI_ERROR; + + if ((NULL != pInputData) && (NULL != pPacketLen) && (NULL != pItemLen)) + { + *pPacketLen = ShortFromChar(pInputData); + *pItemLen = PACKET_LENGTH_LEN; + + cRetVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + +/* +: +*pInputDataУȡűݳȵַĵַ +: +UINT8 *pInputData ָ +: +UINT8 **ppLenItemAddr űݳȵַĵַ +UINT16 *pItemLen Ӧ͵ıݳȣɡ͡Ľ֡ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPacketLenPha1(UINT8 *pInputData, UINT8 **ppLenItemAddr, UINT16 *pItemLen) +{ + UINT8 cRetVal = CI_ERROR; + + if ((NULL != pInputData) && (NULL != ppLenItemAddr) && (NULL != pItemLen)) + { + *pItemLen = PACKET_LENGTH_LEN; + *ppLenItemAddr = pInputData; + + cRetVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + +/* +: +*pInputDataб汨ijȵĵַϣӦ͵ıݵij +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen Ӧ͵ıݳȣɡ͡Ľ֡ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPacketLenPha2(UINT8 *pInputData, UINT16 itemLen) +{ + UINT8 cRetVal = CI_ERROR; + + if (NULL != pInputData) + { + ShortToChar(itemLen, pInputData); + cRetVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + +/* +: +ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseSwitchPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId) +{ + const CiTransmitStruct* pCiRecptStru = NULL; + UINT8 deviceSum = 0u; /**/ + UINT8 dataBuf = 0u; /*״̬*/ + UINT8 curPosition = 0u; /*λ*/ + UINT8 yLockState = 0u; /*״̬*/ + UINT8 dLockState = 0u; /*״̬*/ + UINT8 fLockState = 0u; /*״̬*/ + + UINT8 localCiId = 0u; + UINT8 belongCiId = 0u; + + UINT16 switchId = 0xFFFFu; /*id*/ + UINT8 swiInd = 0u; + UINT16 parsedLen = 0u; /*ָƫ*/ + UINT8 retValue = CI_ERROR; + UINT16 bufInd = 0u; + SwitchDataStruct * pSwitchDataStru = NULL; + + localCiId = GetSystemParaLocalCiId(); + pCiRecptStru = GetSrcCiTransInfo(srcCiId); /*ȡԴӦĽṹ*/ + + deviceSum = *(pInputData + parsedLen); + parsedLen += 1u; + if (NULL == pCiRecptStru) + { + retValue = CI_ERROR; /*ȡʧ*/ + } + else if (deviceSum == pCiRecptStru->switchNum) + { + pSwitchDataStru = GetSwitchData(); + + for (swiInd = 0u; swiInd < pCiRecptStru->switchNum; swiInd++) + { + dataBuf = *(pInputData + parsedLen); /*״̬Ϣȡ*/ + parsedLen += 1u; + + switchId = pCiRecptStru->switchIdBuf[swiInd]; /*ȡID*/ + + bufInd = GetSwitchConfigBufIndex(switchId); + + (pSwitchDataStru + bufInd)->SwitchId = switchId; + + belongCiId = GetSwitchBelongCiId(switchId); + + if (localCiId != belongCiId) + { + curPosition = (dataBuf & BIT_MASK_00000011B); + yLockState = ((dataBuf >> 2u) & BIT_MASK_00000011B); + dLockState = ((dataBuf >> 4u) & BIT_MASK_00000011B); + fLockState = ((dataBuf >> 6u) & BIT_MASK_00000011B); + + switch (curPosition) + { + case BIT_VAL_00000001B: + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_DINGWEI); + SetSwitchCurPosition(switchId, SWITCH_POSITION_DINGWEI);/*ǶԷģֻΪSingleλһ*/ + break; + case BIT_VAL_00000010B: + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_FANWEI); + SetSwitchCurPosition(switchId, SWITCH_POSITION_FANWEI); + break; + case BIT_VAL_00000000B: + SetSingleSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + SetSwitchCurPosition(switchId, SWITCH_POSITION_SIKAI); + break; + default: + /*ɴ֧*/ + break; + } + switch (yLockState) + { + case BIT_VAL_00000001B: + SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_NO); /*δ*/ + break; + case BIT_VAL_00000010B: + SetSwitchYLockState(switchId, SWITCH_LOCK_YINZONG_YES); /*״̬*/ + break; + default: + /*ɴ֧*/ + break; + } + switch (dLockState) + { + case BIT_VAL_00000001B: + SetOtherCiSwitchLockStatus(switchId, SWITCH_LOCK_STATUS_NO); /*δ״̬*/ + break; + case BIT_VAL_00000010B: + SetOtherCiSwitchLockStatus(switchId, SWITCH_LOCK_STATUS_DANSUO); /*״̬*/ + break; + default: + /*ɴ֧*/ + break; + } + switch (fLockState) + { + case BIT_VAL_00000001B: + SetSwitchFLockState(switchId, SWITCH_LOCK_FENGSUO_NO); /*δ״̬*/ + break; + case BIT_VAL_00000010B: + SetSwitchFLockState(switchId, SWITCH_LOCK_FENGSUO_YES); /*״̬*/ + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + ; + } + } + retValue = CI_SUCCESS; + } + else + { + retValue = CI_ERROR; + } + + *pItemLen = parsedLen; + return retValue; +} + +/* +: +ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +const UINT8 dstCiId:ĿID +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackSwitchPacket(UINT8 *pInputBuf, UINT16 *pItemLen,const UINT8 dstCiId) +{ + UINT8 deviceSum = 0u; /*豸*/ + + UINT8 localCi = 0u; /*ID*/ + UINT16 switchId = 0u; /*id*/ + UINT8 curPosition = 0u; /*λ*/ + UINT8 yLockState = 0u; /*״̬*/ + UINT8 dLockState = 0u; /*״̬*/ + UINT8 fLockState = 0u; /*״̬*/ + + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + UINT16 packedLen = 0u; + UINT16 i = 0u; + UINT8 retValue = CI_ERROR; + CiTransmitStruct *pTmpCiTransInfo = NULL; + + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + + if (NULL != pTmpCiTransInfo) + { + *(pInputBuf + packedLen) = (UINT8)pTmpCiTransInfo->switchNum; + + packedLen += 1u; + + for (i = 0u; i < pTmpCiTransInfo->switchNum; i++) + { + switchId = pTmpCiTransInfo->switchIdBuf[i]; /*ȡID*/ + + if (localCi == GetSwitchBelongCiId(switchId)) + {/*ڱ*/ + curPosition = GetSingleSwitchCurPosition(switchId); /*ǰλ*/ + + yLockState = GetSwitchYLockState(switchId); /*״̬*/ + + dLockState = GetSwitchLockStatus(switchId); /*״̬*/ + + fLockState = GetSwitchFLockState(switchId); /*״̬*/ + + switch (curPosition) + { + case SWITCH_POSITION_DINGWEI: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | BIT_VAL_00000001B; /*λ*/ + break; + case SWITCH_POSITION_FANWEI: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | BIT_VAL_00000010B; /*λ*/ + break; + case SWITCH_POSITION_SIKAI: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | BIT_VAL_00000000B; /*Ŀ*/ + break; + default: + /*ɴ֧*/ + break; + } + + switch (yLockState) + { + case SWITCH_LOCK_YINZONG_NO: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 2u));/*δ״̬*/ + break; + case SWITCH_LOCK_YINZONG_YES: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 2u));/*״̬*/ + break; + default: + /*ɴ֧*/ + break; + } + + switch (dLockState) + { + case SWITCH_LOCK_STATUS_NO: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 4u));/*δ״̬*/ + break; + case SWITCH_LOCK_STATUS_DANSUO: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 4u));/*״̬*/ + break; + default: + /*ɴ֧*/ + break; + } + + switch (fLockState) + { + case SWITCH_LOCK_FENGSUO_NO: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 6u));/*״̬*/ + break; + case SWITCH_LOCK_FENGSUO_YES: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 6u));/*״̬*/ + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + /*DZϢ*/ + } + + packedLen += 1u; + deviceSum += 1u; + + } + + pInputBuf[deviceSumIndex] = deviceSum; /**/ + *pItemLen = packedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParsePhySecPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId) +{ + UINT8 deviceSum = 0u; /**/ + UINT16 phySectionId = 0u; /*ID*/ + UINT8 dataBuf1 = 0u; + UINT8 dataBuf2 = 0u; + UINT8 curCollState = 0u; /*ռ*/ + UINT8 routeLockState = 0u; /*·״̬*/ + UINT8 protectLockState = 0u; /*״̬*/ + UINT8 exceptLockState = 0u; /*״̬*/ + UINT8 arbState = 0u; /*ARB״̬*/ + UINT8 fLockState = 0u; /* ״̬*/ + UINT8 lockDirection = 0u; /*շ*/ + UINT8 directionState = 0u; + + UINT8 localCiId = 0u; + UINT8 belongCiId = 0u; + + UINT8 phySecInd = 0u; + UINT16 parsedLen = 0u; + UINT8 retValue = CI_ERROR; + UINT16 bufInd = 0u; + + UINT16 *proRouteIdS = NULL; + UINT8 proRouteIdSum = 0u; + UINT8 i = 0u;/*·ID*/ + UINT16 tempRouteId = 0u; + UINT8 routeState = 0u; + + PhysicalSectionDataStruct * pPhySecDataStru = NULL; + + const CiTransmitStruct* pCiRecptStru = NULL; + + localCiId = GetSystemParaLocalCiId(); + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + + deviceSum = *(pInputData + parsedLen); + parsedLen += 1u; + + if(NULL == pCiRecptStru) + { + *pItemLen = 0u; + retValue = CI_ERROR; /*ݻȡʧ*/ + } + else if (deviceSum == pCiRecptStru->phySecNum) + { + pPhySecDataStru = GetPhySecData(); + + for (phySecInd = 0u; phySecInd < pCiRecptStru->phySecNum; phySecInd++) + { + dataBuf1 = *(pInputData + parsedLen); /*byte1Ϣȡ*/ + dataBuf2 = *(pInputData + parsedLen + 1u); /*byte2Ϣȡ*/ + + parsedLen += 2u; + + phySectionId = pCiRecptStru->phySecIdBuf[phySecInd]; /*ȡID*/ + + bufInd = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + (pPhySecDataStru + bufInd)->PhysicalSectionId = phySectionId; /*εǰں״̬*/ + + belongCiId = GetPhySecBelongCiId(phySectionId); + + if (localCiId != belongCiId) + { + curCollState = (dataBuf1 & BIT_MASK_00000011B); /*ռ״̬*/ + routeLockState = ((dataBuf1 >> 2u) & BIT_MASK_00000011B); /* ·״̬*/ + protectLockState = ((dataBuf1 >> 4u) & BIT_MASK_00000011B); /* ״̬*/ + exceptLockState = ((dataBuf1 >> 6u) & BIT_MASK_00000011B); /* ״̬*/ + arbState = (dataBuf2 & BIT_MASK_00000011B); /*ARB״̬*/ + fLockState = ((dataBuf2 >> 2u) & BIT_MASK_00000011B); /* ״̬*/ + lockDirection = ((dataBuf2 >> 4u) & BIT_MASK_00000011B); /* շ*/ + + switch (curCollState) + { + case BIT_VAL_00000000B: + SetPhySecCurOccupyState(phySectionId, SECTION_OCCUPY_YES); + SetPhySecCurMergeState(phySectionId, SECTION_OCCUPY_YES); + break; + case BIT_VAL_00000010B: + SetPhySecCurOccupyState(phySectionId, SECTION_OCCUPY_NO); + SetPhySecCurMergeState(phySectionId, SECTION_OCCUPY_NO); + break; + default: + /*ɴ֧*/ + break; + } + + /*α״̬*/ + switch (protectLockState) + { + case BIT_VAL_00000001B: + protectLockState = PHYSICAL_SECTION_LOCK_NO; + break; + case BIT_VAL_00000010B: + protectLockState = PHYSICAL_SECTION_LOCK_PROTECT; + break; + default: + break; + } + + /*ν·״̬*/ + switch (routeLockState) + { + case BIT_VAL_00000001B: + routeLockState = PHYSICAL_SECTION_LOCK_NO; + break; + case BIT_VAL_00000010B: + routeLockState = PHYSICAL_SECTION_LOCK_NORMAL; + break; + default: + break; + } + + /* ARB״̬*/ + switch (arbState) + { + case BIT_VAL_00000001B: + SetPhySecArbState(phySectionId, AXIS_SECTION_ARB_YES); + SetPhyContainAxisSecArbState(phySectionId, AXIS_SECTION_ARB_YES); + break; + case BIT_VAL_00000010B: + SetPhySecArbState(phySectionId, AXIS_SECTION_ARB_NO); + SetPhyContainAxisSecArbState(phySectionId, AXIS_SECTION_ARB_NO); + break; + default: + /*ɴ֧*/ + break; + } + + /* ״̬*/ + switch (fLockState) + { + case BIT_VAL_00000001B: + (void)SetPhySecFLockState(phySectionId, PHYSICAL_SECTION_FLOCK_YES); + break; + case BIT_VAL_00000010B: + (void)SetPhySecFLockState(phySectionId, PHYSICAL_SECTION_FLOCK_NO); + break; + default: + /*ɴ֧*/ + break; + } + + /*շ*/ + switch (lockDirection) + { + case BIT_VAL_00000001B: + directionState = CI_SYSTEM_DIRECTION_UP; + break; + case BIT_VAL_00000010B: + directionState = CI_SYSTEM_DIRECTION_DOWN; + break; + case BIT_VAL_00000000B: + directionState = CI_SYSTEM_DIRECTION_NONE; + break; + default: + /*ɴ֧*/ + break; + } + + /*ι*/ + switch (exceptLockState) + { + case BIT_VAL_00000001B: + exceptLockState = PHYSICAL_SECTION_LOCK_NO; + break; + case BIT_VAL_00000010B: + exceptLockState = PHYSICAL_SECTION_LOCK_EXCEPT; + break; + default: + break; + } + + /*ε״̬ε״̬*/ + /*Ϊδ*/ + SetPhySecLockStateHlht(phySectionId, PHYSICAL_SECTION_LOCK_NO); + SetPhySecLockDirHlht(phySectionId, directionState); + + if (PHYSICAL_SECTION_LOCK_PROTECT == protectLockState) + { + SetPhySecLockStateHlht(phySectionId, PHYSICAL_SECTION_LOCK_PROTECT); + + /*жǷΪCIĽ·յ*/ + proRouteIdS = GetPhySecProLockRouteIdBuf(phySectionId); + proRouteIdSum = GetPhySecProLockRouteSum(phySectionId); + + for (i = 0u;i < proRouteIdSum;i++) + { + tempRouteId = proRouteIdS[i]; + + if (GetRouteBelongCiId(tempRouteId) == localCiId) + { + routeState = GetRouteState(tempRouteId); + if ((ROUTE_STATE_IDLE != routeState) && (GetRouteDirection(tempRouteId) == directionState)) + { + SetPhySecPLockRouteIdHlht(phySectionId, tempRouteId); + break; + } + } + } + + if (proRouteIdSum == i) + {/*˵αĽ·DZ*/ + SetPhySecPLockRouteIdHlht(phySectionId, UINT16_MAX); + } + } + else + { + SetPhySecPLockRouteIdHlht(phySectionId, 0u); + } + + /*ȼڷ*/ + if ((PHYSICAL_SECTION_LOCK_NORMAL == routeLockState)) + { + SetPhySecLockStateHlht(phySectionId, PHYSICAL_SECTION_LOCK_NORMAL); + SetPhySecRLockRouteIdHlht(phySectionId, UINT16_MAX); + } + else + { + SetPhySecRLockRouteIdHlht(phySectionId, 0u); + } + + /*쳣յȼ*/ + if (PHYSICAL_SECTION_LOCK_EXCEPT==exceptLockState) + { + SetPhySecLockStateHlht(phySectionId, PHYSICAL_SECTION_LOCK_EXCEPT); + } + } + else + { + ; + } + } + + *pItemLen = parsedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPhySecPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId) +{ + UINT8 deviceSum = 0u; /*豸*/ + + UINT8 localCi = 0u; /*ID*/ + UINT16 phySectionId = 0xFFFFu; /*id*/ + UINT8 curCollState = 0u; /*ռ*/ + UINT8 PhySecLockState = 0u; /*״̬*/ + UINT8 arbState = 0u; /*ARB״̬*/ + UINT8 fLockState = 0u; /* ״̬*/ + UINT8 lockDirection = 0u; /*շ*/ + UINT16 i = 0u; + UINT16 packedLen = 0u; + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + UINT8 retValue = CI_ERROR; + CiTransmitStruct *pTmpCiTransInfo = NULL; + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + packedLen++; + + if (NULL != pTmpCiTransInfo) + { + for (i = 0u; i < pTmpCiTransInfo->phySecNum; i++) + { + phySectionId = pTmpCiTransInfo->phySecIdBuf[i]; /*ȡID*/ + + if (localCi == GetPhySecBelongCiId(phySectionId)) + {/*δڱ*/ + curCollState = GetPhySecCurMergeState(phySectionId); /*ռ״̬*/ + PhySecLockState = GetPhySecLockState(phySectionId); /*״̬*/ + arbState = GetPhySecArbState(phySectionId); /*ARB״̬*/ + fLockState = GetPhySecFLockState(phySectionId); /*η״̬*/ + lockDirection = GetPhySecLockDirection(phySectionId); /*շ*/ + + /*ռ״̬*/ + switch (curCollState) + { + case SECTION_OCCUPY_YES: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | (BIT_VAL_00000000B); + break; + case SECTION_OCCUPY_NO: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | (BIT_VAL_00000010B); + break; + default: + /*ɴ֧*/ + break; + } + + /*״̬*/ + if (PhySecLockState == PHYSICAL_SECTION_LOCK_EXCEPT) + {/*ι*/ + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 6u)); + } + else + { + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 6u)); /*δ*/ + switch (PhySecLockState) + { + case PHYSICAL_SECTION_LOCK_PROTECT: /*ֻб*/ + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 4u)); + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 2u)); + break; + case PHYSICAL_SECTION_LOCK_NO: /*δ*/ + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 4u)); + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 2u)); + break; + case PHYSICAL_SECTION_LOCK_NORMAL: + if (0U != GetPhySecPLockBelongRouteId(phySectionId)) + {/*ͬʱڽ·պͱ*/ + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 4u)); + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 2u)); + } + else + {/**/ + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 4u)); + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 2u)); + } + break; + default: + /*ɴ֧*/ + break; + } + } + + + /*ARB״̬*/ + switch (arbState) + { + case AXIS_SECTION_ARB_YES: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | (BIT_VAL_00000001B); + break; + case AXIS_SECTION_ARB_NO: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | (BIT_VAL_00000010B); + break; + default: + /*ɴ֧*/ + break; + } + + /*η״̬*/ + switch (fLockState) + { + case PHYSICAL_SECTION_FLOCK_YES: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000001B << 2u)); + break; + case PHYSICAL_SECTION_FLOCK_NO: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000010B << 2u)); + break; + default: + /*ɴ֧*/ + break; + } + + /*շ*/ + switch (lockDirection) + { + case CI_SYSTEM_DIRECTION_UP: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000001B << 4u)); + break; + case CI_SYSTEM_DIRECTION_DOWN: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000010B << 4u)); + break; + case CI_SYSTEM_DIRECTION_NONE: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000000B << 4u)); + break; + default: + break; + } + } + else + { + /*DZϢ*/ + } + + packedLen += 2u; + + deviceSum += 1u; + } + + pInputBuf[deviceSumIndex] = deviceSum; + *pItemLen = packedLen; + + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +߼״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseLogSecPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId) +{ + + UINT8 deviceSum = 0u; /*߼*/ + UINT16 logSecId = 0u; /*߼ID*/ + + UINT8 retValue = CI_ERROR; + UINT8 logSecInd = 0u; /*α*/ + UINT8 dataBuf1 = 0u; + UINT8 dataBuf2 = 0u; + UINT8 localCiId = 0u; + UINT8 belongCiId = 0u; + + UINT8 lockDirection = 0u; /*շ*/ + UINT8 protectionLockState = 0u; /*״̬*/ + UINT8 sectionRouteLockState = 0u; /*ν·״̬*/ + UINT8 sectionOccupyState = 0u; /*ռ״̬*/ + UINT8 sectionFlockState = 0u; /*η״̬*/ + UINT8 faultLockState = 0u; /*״̬*/ + UINT16 bufInd = 0u; + LogicSectionDataStruct * pLogSecDataStru = NULL; + const CiTransmitStruct* pCiRecptStru = NULL; + UINT16 parsedLen = 0u; + UINT16 wLogSecBelPhySecId = 0U;/*߼ιID*/ + UINT16* proRouteIdS = NULL; + UINT8 proRouteIdSum = 0u; + UINT8 ii = 0u;/*·ID*/ + UINT16 tempRouteId = 0u; + UINT8 chRouteState = 0U;/*·״̬*/ + UINT8 chRouteBelCiId = 0U;/*·ID*/ + UINT8 chRouteDir = 0U;/*·*/ + + localCiId = GetSystemParaLocalCiId(); + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + + deviceSum = *(pInputData + parsedLen); + parsedLen += 1u; + + if(NULL == pCiRecptStru) + { + *pItemLen = 0u; + retValue = CI_ERROR; /*ݻȡʧ*/ + } + else if (deviceSum == pCiRecptStru->logicSecNum) + { + pLogSecDataStru = GetLogicSecData(); + + for (logSecInd = 0u; logSecInd < pCiRecptStru->logicSecNum; logSecInd++) + { + dataBuf1 = *(pInputData + parsedLen); /*߼״̬Ϣȡ*/ + + dataBuf2 = *(pInputData + parsedLen + 1u); + + parsedLen += 2u; + + logSecId = pCiRecptStru->logicSecIdBuf[logSecInd]; /*ȡ߼ID*/ + + bufInd = GetlogSectionBufIndex(logSecId); + + (pLogSecDataStru + bufInd)->LogicSectionId = logSecId; + + belongCiId = GetLogSecBelongCiId(logSecId); + + if (localCiId != belongCiId) + { + sectionOccupyState = (dataBuf1 & BIT_MASK_00000011B); /*ռ״̬*/ + sectionRouteLockState = ((dataBuf1 >> 2u) & BIT_MASK_00000011B); /*ν·״̬*/ + protectionLockState = ((dataBuf1 >> 4u)& BIT_MASK_00000011B); /*α״̬*/ + lockDirection = ((dataBuf1 >> 6u) & BIT_MASK_00000011B); /*շ*/ + + sectionFlockState = (dataBuf2 & BIT_MASK_00000011B); /*η״̬Ԥ״̬*/ + faultLockState = ((dataBuf2 >> 2u) & BIT_MASK_00000011B); /*ι״̬ */ + + switch (sectionOccupyState) + { + case BIT_VAL_00000000B: + SetLogSecPreOccupyState(logSecId, GetLogSecCurCtOrUtOccupyState(logSecId));/*߼֮ǰռ״̬*/ + SetLogSecCurOccupyState(logSecId, LOGICSECTION_OCCUPY_UT);/*CBTCռ*/ + break; + case BIT_VAL_00000001B: + SetLogSecPreOccupyState(logSecId, GetLogSecCurCtOrUtOccupyState(logSecId));/*߼֮ǰռ״̬*/ + SetLogSecCurOccupyState(logSecId, LOGICSECTION_OCCUPY_CT);/*CBTCռ*/ + break; + case BIT_VAL_00000010B: + SetLogSecPreOccupyState(logSecId, GetLogSecCurCtOrUtOccupyState(logSecId));/*߼֮ǰռ״̬*/ + SetLogSecCurOccupyState(logSecId, LOGICSECTION_OCCUPY_NO);/**/ + break; + default: + /*ɴ֧*/ + break; + } + + SetLogSecLinShiXianSuState(logSecId, LOGSEC_LSXS_SET_STATE_NO); + + /*ν·״̬*/ + switch (sectionRouteLockState) + { + case BIT_VAL_00000001B: + sectionRouteLockState = LOG_SECTION_LOCK_NO; + break; + case BIT_VAL_00000010B: + sectionRouteLockState = LOG_SECTION_LOCK_NORMAL; + break; + default: + break; + } + + /*α״̬*/ + switch (protectionLockState) + { + case BIT_VAL_00000001B: + protectionLockState = LOG_SECTION_LOCK_NO; + break; + case BIT_VAL_00000010B: + protectionLockState = LOG_SECTION_LOCK_PROTECT; + break; + default: + break; + } + + + /*շ*/ + switch (lockDirection) + { + case BIT_VAL_00000001B: + lockDirection = CI_SYSTEM_DIRECTION_UP; + break; + case BIT_VAL_00000010B: + lockDirection = CI_SYSTEM_DIRECTION_DOWN; + break; + case BIT_VAL_00000000B: + lockDirection = CI_SYSTEM_DIRECTION_NONE; + break; + default: + break; + } + + + /*ι״̬*/ + switch (faultLockState) + { + case BIT_VAL_00000001B: + faultLockState = LOG_SECTION_LOCK_NO; + break; + case BIT_VAL_00000010B: + faultLockState = LOG_SECTION_LOCK_EXCEPT; + break; + default: + break; + } + + /*߼ε״̬״̬*/ + /*Ϊδ*/ + SetLogSecLockStateHlht(logSecId, LOG_SECTION_LOCK_NO); + SetLogSecLockDirHlht(logSecId, lockDirection); + + if (LOG_SECTION_LOCK_PROTECT == protectionLockState) + { + SetLogSecLockStateHlht(logSecId, LOG_SECTION_LOCK_PROTECT); + + wLogSecBelPhySecId = GetLgcSecRelativePhySecId(logSecId); + + /*жǷΪCIĽ·յ*/ + proRouteIdS = GetPhySecProLockRouteIdBuf(wLogSecBelPhySecId); + proRouteIdSum = GetPhySecProLockRouteSum(wLogSecBelPhySecId); + + for (ii = 0u; ii < proRouteIdSum; ii++) + { + tempRouteId = proRouteIdS[ii]; + chRouteBelCiId = GetRouteBelongCiId(tempRouteId); + + if (localCiId == chRouteBelCiId) + { + chRouteState = GetRouteState(tempRouteId); + chRouteDir = GetRouteDirection(tempRouteId); + + if ((ROUTE_STATE_IDLE != chRouteState) && (chRouteDir == lockDirection)) + { + SetLogSecPLockRouteIdHlht(logSecId, tempRouteId); + break; + } + } + } + + if (proRouteIdSum == ii) + {/*˵αĽ·DZ*/ + SetLogSecPLockRouteIdHlht(logSecId, UINT16_MAX); + } + } + else + { + SetLogSecPLockRouteIdHlht(logSecId, 0U); + } + + /*ȼڷ*/ + if ((LOG_SECTION_LOCK_NORMAL == sectionRouteLockState)) + { + SetLogSecLockStateHlht(logSecId, LOG_SECTION_LOCK_NORMAL); + SetLogSecRLockRouteIdHlht(logSecId, UINT16_MAX); + } + else + { + SetLogSecRLockRouteIdHlht(logSecId, 0u); + } + + /*쳣յȼ*/ + if (LOG_SECTION_LOCK_EXCEPT == faultLockState) + { + SetLogSecLockStateHlht(logSecId, LOG_SECTION_LOCK_EXCEPT); + } + + } + else + { + ; + } + } + + *pItemLen = parsedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +߼ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackLogSecPacket(UINT8 *pInputBuf, UINT16 *pItemLen,const UINT8 dstCiId) +{ + UINT8 deviceSum = 0u; /*豸*/ + + UINT8 localCi = 0u; /*ID*/ + UINT16 logSectionId = 0u; /*߼id*/ + UINT16 phySecId = 0u; + UINT8 lockDirection = 0u; /*շ*/ + UINT8 protectLockState = 0u; /*״̬*/ + UINT8 routeLockState = 0u; /*·״̬*/ + UINT8 occupyState = 0u; /*ռ*/ + UINT8 exceptLockState = 0u; /*״̬*/ + UINT8 fLockState = 0u; /* ״̬*/ + UINT8 phySecLockState = 0u; + + UINT16 logSecIx = 0u; + UINT16 packedLen = 0u; + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + UINT8 retValue = CI_ERROR; + CiTransmitStruct *pTmpCiTransInfo = NULL; + UINT16 plockRouteId = 0u; + UINT16 rlockRouteId = 0u; + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + packedLen++; + + if (NULL != pTmpCiTransInfo) + { + for (logSecIx = 0u; logSecIx < pTmpCiTransInfo->logicSecNum; logSecIx++) + { + logSectionId = pTmpCiTransInfo->logicSecIdBuf[logSecIx]; /*ȡ߼ID*/ + + if (localCi == GetLogSecBelongCiId(logSectionId)) + {/*߼δڱ*/ + + phySecId = GetLgcSecRelativePhySecId(logSectionId); + + phySecLockState = GetLogSecLockState(logSectionId); + + lockDirection = GetLogSecLockDir(logSectionId); + + plockRouteId = GetLogSecPLockRouteId(logSectionId); + + if(0u == plockRouteId) + { + protectLockState = LOG_SECTION_LOCK_NO; + } + else + { + protectLockState = LOG_SECTION_LOCK_PROTECT; + } + + rlockRouteId = GetLogSecLockBelongRoute(logSectionId); + + if(0u == rlockRouteId) + { + routeLockState = LOG_SECTION_LOCK_NO; + } + else + { + routeLockState = LOG_SECTION_LOCK_NORMAL; + } + + occupyState = GetLogSecCurCtOrUtOccupyState(logSectionId); + + if(LOG_SECTION_LOCK_EXCEPT != phySecLockState) + { + exceptLockState = LOG_SECTION_LOCK_NO; + } + else + { + exceptLockState = LOG_SECTION_LOCK_EXCEPT; + } + + fLockState = GetPhySecFLockState(phySecId); + + /*ռ״̬*/ + switch (occupyState) + { + case LOGICSECTION_OCCUPY_UT: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000000B << 0u)); + break; + case LOGICSECTION_OCCUPY_CT: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 0u)); + break; + case LOGICSECTION_OCCUPY_NO: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 0u)); + break; + default: + break; + } + + switch (routeLockState) + { + case LOG_SECTION_LOCK_NO: /*߼δ*/ + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 2u)); + break; + case LOG_SECTION_LOCK_NORMAL: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 2u)); + break; + default: + break; + } + + switch (protectLockState) + { + case LOG_SECTION_LOCK_NO: /*߼δ*/ + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 4u)); + break; + case LOG_SECTION_LOCK_PROTECT: /*߼α*/ + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 4u)); + break; + default: + break; + } + + /*շ*/ + switch (lockDirection) + { + case CI_SYSTEM_DIRECTION_UP: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000001B << 6u)); + break; + case CI_SYSTEM_DIRECTION_DOWN: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000010B << 6u)); + break; + case CI_SYSTEM_DIRECTION_NONE: + *(pInputBuf + packedLen) = *(pInputBuf + packedLen) | ((UINT8)(BIT_VAL_00000000B << 6u)); + break; + default: + break; + } + + /*η״̬*/ + switch (fLockState) + { + case PHYSICAL_SECTION_FLOCK_YES: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000001B << 0u)); + break; + case PHYSICAL_SECTION_FLOCK_NO: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000010B << 0u)); + break; + default: + break; + } + + /*ι״̬*/ + switch (exceptLockState) + { + case LOG_SECTION_LOCK_NO: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000001B << 2u)); + break; + case LOG_SECTION_LOCK_EXCEPT: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000010B << 2u)); + break; + default: + break; + } + } + else + { + /*DZϢ*/ + } + + packedLen += 2u; + + deviceSum += 1u; + } + pInputBuf[deviceSumIndex] = deviceSum; + *pItemLen = packedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +źŻ״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseSignalPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId) +{ + UINT8 deviceSum = 0u; /*źŻ*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT8 dataByte1 = 0u; + UINT8 dataByte2 = 0u; + UINT8 dataByte3 = 0u; + UINT8 sigPLockCmd = 0u; + UINT8 showColor = 0u; /*źŻʾ״̬*/ + UINT8 sigColor = 0u; /*źŻʾ״̬*/ + UINT8 fLockState = 0u; /*źŻ״̬*/ + UINT8 overlapValid = 0u; /*Ч*/ + UINT8 nearLock = 0u; + UINT8 sigExtStat = 0u; /*źŻ״̬*/ + + UINT8 localCiId = 0u; + UINT8 belongCiId = 0u; + + UINT8 sigInd = 0u; + UINT16 parsedLen = 0u; + UINT8 retValue = CI_ERROR; + UINT16 bufInd = 0u; + const CiTransmitStruct* pCiRecptStru = NULL; + SignalDataStruct * pSignalDataStru = NULL; + + UINT16 sigOutSec = 0u;/*źŻⷽ*/ + UINT16 sigOutSecCi = 0u;/*źŻⷽCI*/ + + localCiId = GetSystemParaLocalCiId(); + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + + deviceSum = *(pInputData + parsedLen); + parsedLen += 1u; + if(NULL == pCiRecptStru) + { + *pItemLen = 0u; + retValue = CI_ERROR; /*ݻȡʧ*/ + } + else if (deviceSum == pCiRecptStru->signalNum) + { + pSignalDataStru = GetSignalData(); + + for (sigInd = 0u; sigInd < pCiRecptStru->signalNum; sigInd++) + { + dataByte1 = *(pInputData + parsedLen); /*źŻʾ״̬*/ + + dataByte2 = *(pInputData + parsedLen + 1); + + dataByte3 = *(pInputData + parsedLen + 2); + + parsedLen += 3u; + + signalId = pCiRecptStru->signalIdBuf[sigInd]; + + bufInd = GetSignalConfigBufIndex(signalId); + + pSignalDataStru[bufInd].SignalId = signalId; + + sigColor = dataByte1; + sigExtStat = ((dataByte2 >> 0u) & BIT_MASK_00000011B); /*źŻ״̬*/ + fLockState = ((dataByte2 >> 2u) & BIT_MASK_00000011B); /*źŻ״̬*/ + nearLock = ((dataByte2 >> 4u) & BIT_MASK_00000011B); /*ӽ*/ + sigPLockCmd = ((dataByte2 >> 6u) & BIT_MASK_00000011B); /*źŻ*/ + overlapValid = ((dataByte3 >> 0u) & BIT_MASK_00000011B); /*Ч*/ + + belongCiId = GetSignalBelongCiId(signalId); + + if (localCiId != belongCiId) + { + switch(sigColor) + {/*ɫʾж*/ + case BIT_VAL_00000000B:/*˿*/ + sigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + break; + case BIT_VAL_00010001B:/**/ + sigColor = SIGNAL_SHOWCOLOUR_RED; + break; + case BIT_VAL_00010010B:/*Ƶ*/ + sigColor = SIGNAL_SHOWCOLOUR_YELLOW; + break; + case BIT_VAL_00010100B:/*̵*/ + sigColor = SIGNAL_SHOWCOLOUR_GREEN; + break; + case BIT_VAL_00011000B:/*Ƶ*/ + sigColor = SIGNAL_SHOWCOLOUR_REDYELLOW; + break; + default: + sigColor = SIGNAL_SHOWCOLOUR_REDBREAK; + break; + } + + switch(sigExtStat) + { + case BIT_VAL_00000001B: + sigExtStat = SIGNAL_LIGHT_EXTICT_STATE_NO; /*źŻ*/ + break; + case BIT_VAL_00000010B: + sigExtStat = SIGNAL_LIGHT_EXTICT_STATE_YES; /*źŻ*/ + break; + default: + /*ɴ֧*/ + break; + } + + if(SIGNAL_SHOWCOLOUR_RED == sigColor) + { + if(SIGNAL_LIGHT_EXTICT_STATE_NO == sigExtStat) + { + showColor = SIGNAL_SHOWCOLOUR_RED; + } + else + { + showColor = SIGNAL_SHOWCOLOUR_REDCLOSE; + } + } + else if(SIGNAL_SHOWCOLOUR_YELLOW == sigColor) + { + if(SIGNAL_LIGHT_EXTICT_STATE_NO == sigExtStat) + { + showColor = SIGNAL_SHOWCOLOUR_YELLOW; + } + else + { + showColor = SIGNAL_SHOWCOLOUR_YELLOWCLOSE; + } + } + else if(SIGNAL_SHOWCOLOUR_GREEN == sigColor) + { + if(SIGNAL_LIGHT_EXTICT_STATE_NO == sigExtStat) + { + showColor = SIGNAL_SHOWCOLOUR_GREEN; + } + else + { + showColor = SIGNAL_SHOWCOLOUR_GREENCLOSE; + } + } + else if(SIGNAL_SHOWCOLOUR_REDYELLOW == sigColor) + { + showColor = SIGNAL_SHOWCOLOUR_REDYELLOW; + } + else if(SIGNAL_SHOWCOLOUR_REDBREAK == sigColor) + { + showColor = SIGNAL_SHOWCOLOUR_REDBREAK; + } + else + { + showColor = SIGNAL_SHOWCOLOUR_REDBREAK; + } + + + (void)SetSignalCurColor(signalId, showColor); + + switch(fLockState) + { + case BIT_VAL_00000001B: + SetSignalFLockState(signalId, SIGNAL_FENGSUO_YES); /*źŻ*/ + break; + case BIT_VAL_00000010B: + SetSignalFLockState(signalId, SIGNAL_FENGSUO_NO); /*źŻδ*/ + break; + default: + /*ɴ֧*/ + break; + } + + switch(sigPLockCmd) + { + case BIT_VAL_00000001B: + break; + case BIT_VAL_00000010B: + break; + default: + /*ɴ֧*/ + break; + } + + sigOutSec = GetSignalOutFirstPhySecId(signalId); + sigOutSecCi = GetPhySecBelongCiId(sigOutSec); + + if (sigOutSecCi == localCiId) + {/*˵źŻǿվźŻҪźŻЧ*/ + switch (overlapValid) + { + case BIT_VAL_00000001B: + SetSignalProSecValid(signalId, SIGNAL_PRO_SEC_VALID); + break; + case BIT_VAL_00000010B: + SetSignalProSecValid(signalId, SIGNAL_PRO_SEC_INVALID); + break; + default: + SetSignalProSecValid(signalId, SIGNAL_PRO_SEC_INVALID);/*ֵΪЧȫ*/ + break; + } + } + } + else + { + switch (sigPLockCmd) + { + case BIT_VAL_00000001B: + SetSignalPLockCommand(signalId, SIGNAL_PLOCK_CMD_CREATE); + break; + case BIT_VAL_00000010B: + SetSignalPLockCommand(signalId, SIGNAL_PLOCK_CMD_CANCEL); + break; + case BIT_VAL_00000000B: + SetSignalPLockCommand(signalId, SIGNAL_PLOCK_CMD_NONE); + break; + default: + break; + } + } + } + *pItemLen = parsedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +źŻݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackSignalPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId) +{ + UINT8 deviceSum = 0u; /*豸*/ + + UINT8 localCi = 0u; /*ID*/ + UINT16 signalId = 0u; /*źŻID*/ + UINT8 curColor = 0u; /*źŻʾ״̬*/ + UINT8 lightExtinctState = 0u; /*źŻ״̬*/ + UINT8 fLockState = 0u; /*źŻ״̬*/ + + UINT16 sigInd = 0u; + UINT16 packedLen = 0u; + UINT8 retValue = CI_ERROR; + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + UINT8 signalPLockCmd = 0u; + CiTransmitStruct *pTmpCiTransInfo = NULL; + UINT16 *sigProSecIdBuf = NULL;/*źŻı*/ + UINT8 sigProSecSum = 0u;/*źŻı*/ + UINT8 tempMaskValue = BIT_VAL_00000010B;/*λֵʱ*/ + UINT16 ii = 0u;/*ѭ*/ + UINT16 tempProSecId = 0u;/*IDʱ*/ + UINT8 checkResult = CI_ERROR;/*ʱ*/ + UINT16 sigOutSec = 0u;/*źŻⷽ*/ + UINT16 sigOutSecCi = 0u;/*źŻⷽCI*/ + UINT8 sigDsBreakFlag = 0u; /*źŻ˿־*/ + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + packedLen++; + + if (NULL != pTmpCiTransInfo) + { + for (sigInd = 0u; sigInd < pTmpCiTransInfo->signalNum; sigInd++) + { + signalId = pTmpCiTransInfo->signalIdBuf[sigInd]; /*ȡźŻID*/ + + signalPLockCmd = GetSignalPLockCommand(signalId); + + curColor = GetSignalCurColor(signalId); /*źŻǰʾɫ״̬*/ + + lightExtinctState = GetSignalLightExtinctState(signalId); /*źŻ״̬״̬*/ + + fLockState = GetSignalFLockState(signalId); /*źŻ״̬*/ + + if (localCi == GetSignalBelongCiId(signalId)) + { + sigDsBreakFlag = GetSignalDsBreakFlag(signalId); + + if(SIGNAL_DS_BREAK_NO == sigDsBreakFlag) + { + switch (curColor) + { + case SIGNAL_SHOWCOLOUR_REDBREAK: + case SIGNAL_SHOWCOLOUR_GREENBREAK: + case SIGNAL_SHOWCOLOUR_YELLOWBREAK: + case SIGNAL_SHOWCOLOUR_WHITEBREAK: + *(pInputBuf + packedLen) = BIT_VAL_00000000B; + break; + case SIGNAL_SHOWCOLOUR_RED: + case SIGNAL_SHOWCOLOUR_REDCLOSE: + *(pInputBuf + packedLen) = BIT_VAL_00010001B; + break; + case SIGNAL_SHOWCOLOUR_YELLOW: + case SIGNAL_SHOWCOLOUR_YELLOWCLOSE: + *(pInputBuf + packedLen) = BIT_VAL_00010010B; + break; + case SIGNAL_SHOWCOLOUR_GREEN: + case SIGNAL_SHOWCOLOUR_GREENCLOSE: + *(pInputBuf + packedLen) = BIT_VAL_00010100B; + break; + case SIGNAL_SHOWCOLOUR_REDYELLOW: + *(pInputBuf + packedLen) = BIT_VAL_00011000B; + break; + default: + *(pInputBuf + packedLen) = BIT_VAL_11111111B; + break; + } + } + else + { + *(pInputBuf + packedLen) = BIT_VAL_00000000B; + } + + switch (curColor) + { + case SIGNAL_SHOWCOLOUR_RED: + case SIGNAL_SHOWCOLOUR_YELLOW: + case SIGNAL_SHOWCOLOUR_GREEN: + case SIGNAL_SHOWCOLOUR_REDYELLOW: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000001B << 0u)); + break; + case SIGNAL_SHOWCOLOUR_REDCLOSE: + case SIGNAL_SHOWCOLOUR_YELLOWCLOSE: + case SIGNAL_SHOWCOLOUR_GREENCLOSE: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000010B << 0u)); + break; + case SIGNAL_SHOWCOLOUR_INVALID: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000000B << 0u)); + break; + default: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000011B << 0u)); + break; + } + + switch (fLockState) + { + case SIGNAL_FENGSUO_YES: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000001B << 2u)); + break; + case SIGNAL_FENGSUO_NO: + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000010B << 2u)); + break; + default: + break; + } + + /*źŻ,Ч*/ + *(pInputBuf + packedLen + 1) = *(pInputBuf + packedLen + 1) | ((UINT8)(BIT_VAL_00000000B << 6u)); + + /*Ч*/ + sigOutSec = GetSignalOutFirstPhySecId(signalId); + sigOutSecCi = GetPhySecBelongCiId(sigOutSec); + + sigProSecIdBuf = GetSignalProSecIdBuf(signalId); + sigProSecSum = GetSignalProSecIdSum(signalId); + + if ((sigOutSecCi == dstCiId)&&(sigProSecSum > 0u) && (sigProSecIdBuf != NULL)) + { + for (ii = 0u;ii < sigProSecSum;ii++) + { + tempProSecId = sigProSecIdBuf[ii]; + + checkResult = OverlapValidMaskCheck(tempProSecId); + if (CI_SUCCESS == checkResult) + { + break; + } + } + + if (CI_SUCCESS == checkResult) + {/*˵ղͨı*/ + tempMaskValue = BIT_VAL_00000001B; + } + else + { + tempMaskValue = BIT_VAL_00000010B; + } + } + else + { + tempMaskValue = BIT_VAL_00000010B; + } + + *(pInputBuf + packedLen + 2u) = *(pInputBuf + packedLen + 2u) | (tempMaskValue << 0u); + } + else + { + switch (signalPLockCmd) + { + case SIGNAL_PLOCK_CMD_CREATE: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000001B << 6u)); + break; + case SIGNAL_PLOCK_CMD_CANCEL: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000010B << 6u)); + break; + case SIGNAL_PLOCK_CMD_NONE: + *(pInputBuf + packedLen + 1u) = *(pInputBuf + packedLen + 1u) | ((UINT8)(BIT_VAL_00000000B << 6u)); + break; + default: + break; + } + + /*DZϢ*/ + } + + packedLen += 3u; + + deviceSum++; + } + + pInputBuf[deviceSumIndex] = deviceSum; + + *pItemLen = packedLen; + + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +վ̨״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParsePsdPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId) +{ + UINT8 deviceSum = 0u; /*վ̨*/ + UINT16 psdId = 0u; /*վ̨ID*/ + UINT8 doorState = 0u; /*վ̨״̬*/ + UINT8 mutualLockState = 0u; /*·״̬*/ + UINT8 psdByte = 0u; /*վֽ̨*/ + + UINT8 localCiId = 0u; /*ID*/ + UINT8 belongCiId = 0u; /*վ̨ID*/ + UINT16 inxRem = 0u; /*ֵ*/ + + UINT16 psdInx = 0u; /*վֵ̨*/ + UINT16 parsedLen = 0u; /*ѽֽ*/ + UINT16 offset = 0u; /*ֽλƫ*/ + UINT8 retValue = CI_ERROR; /*ֵ*/ + const CiTransmitStruct* pCiRecptStru = NULL; /*CI-CIͨŹϵṹָ*/ + UINT16 bufInx = 0u; /*վ̨Ŷ̬ݽṹ*/ + PsdDataStruct * pPsdDataStru = NULL; /*վ̨Ŷ̬ݽṹָ*/ + + localCiId = GetSystemParaLocalCiId(); + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + + deviceSum = *(pInputData + parsedLen); + parsedLen += 1u; + + if (NULL == pCiRecptStru) + { + *pItemLen = 0u; + retValue = CI_ERROR; /*ݻȡʧ*/ + } + else if (deviceSum == pCiRecptStru->psdNum) + { + pPsdDataStru = GetPsdData(); + + for (psdInx = 0u; psdInx < pCiRecptStru->psdNum; psdInx++) + { + inxRem = psdInx % PSD_NUM_PER_BYTE; + + if (0u == inxRem) + { + psdByte = *(pInputData + parsedLen); + + parsedLen += 1u; + } + else + { + /*κδ*/ + ; + } + + psdId = pCiRecptStru->psdIdBuf[psdInx]; + + bufInx = GetPsdConfigBufIndex(psdId); + + (pPsdDataStru + bufInx)->PsdId = psdId; + + belongCiId = GetPsdBelongCiId(psdId); + + if (localCiId != belongCiId) + { + offset = inxRem * BIT_NUM_PER_PSD; + + /*վ̨ſ״̬*/ + doorState = ((psdByte >> offset) & BIT_MASK_00000011B);/*offsetȡֵСڵ4*/ + switch (doorState) + { + case BIT_VAL_00000001B: + (void)SetPsdState(psdId, PSD_STATE_OPEN); + break; + case BIT_VAL_00000010B: + (void)SetPsdState(psdId, PSD_STATE_CLOSE); + break; + default: + /*ɴ֧*/ + break; + } + + /*վ̨·־(״̬)*/ + mutualLockState = ((psdByte >> (offset + 2U)) & BIT_MASK_00000011B);/*offsetȡֵСڵ4*/ + + switch (mutualLockState) + { + case BIT_VAL_00000001B: + (void)SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_NO); + break; + case BIT_VAL_00000010B: + (void)SetPsdMutualLockRemoveState(psdId, PSD_MUTUALLOCK_REMOVE_YES); + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + ; + } + } + + *pItemLen = parsedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +վ̨ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackPsdPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId) +{ + UINT8 localCi = 0u; + UINT8 deviceSum = 0u; /*豸*/ + + UINT16 psdId = 0u; /*վ̨ID*/ + UINT8 doorState = 0u; /*վ̨״̬*/ + UINT8 mutualLockState = 0u; /*·״̬*/ + + UINT16 packedLen = 0u; + UINT16 psdInx = 0u; + UINT16 offset = 0u; + UINT8 retValue = CI_ERROR; + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + UINT16 inxRem = 0u; + UINT8 * pPsdByte = NULL; + CiTransmitStruct *pTmpCiTransInfo = NULL; + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + packedLen += 1u; + + if (NULL != pTmpCiTransInfo) + { + for (psdInx = 0u; psdInx < pTmpCiTransInfo->psdNum; psdInx++) + { + inxRem = psdInx % PSD_NUM_PER_BYTE; + + if (0u == inxRem) + { + pPsdByte = pInputBuf + packedLen; + + packedLen += 1u; + } + else + { + /*κδ*/ + ; + } + + psdId = pTmpCiTransInfo->psdIdBuf[psdInx]; /*ȡվ̨ID*/ + + if (localCi == GetPsdBelongCiId(psdId)) + {/*ڱ*/ + offset = inxRem * BIT_NUM_PER_PSD; + + doorState = GetPsdState(psdId); + + switch (doorState) + { + case PSD_STATE_OPEN: + *pPsdByte = *pPsdByte | ((UINT8)(BIT_VAL_00000001B << offset));/*offsetȡֵСڵ4*/ + break; + case PSD_STATE_CLOSE: + *pPsdByte = *pPsdByte | ((UINT8)(BIT_VAL_00000010B << offset)); + break; + default: + break; + } + + /*ȡ·״̬*/ + mutualLockState = GetPsdMutualLockRemoveState(psdId); + + switch (mutualLockState) + { + case PSD_MUTUALLOCK_REMOVE_NO: + *pPsdByte = *pPsdByte | ((UINT8)(BIT_VAL_00000001B << (offset + 2u)));/*offsetȡֵСڵ4*/ + break; + case PSD_MUTUALLOCK_REMOVE_YES: + case PSD_ATS_MUTUALLOCK_REMOVE_YES: + case PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES: + *pPsdByte = *pPsdByte | ((UINT8)(BIT_VAL_00000010B << (offset + 2u))); + break; + default: + break; + } + + } + else + { + /*DZϢ*/ + } + + deviceSum += 1u; + } + + pInputBuf[deviceSumIndex] = deviceSum; + *pItemLen = packedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +رհť״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseEmbtnPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId) +{ + UINT8 deviceSum = 0u; /*رհť*/ + UINT16 esbId = 0u; /*رհťID*/ + UINT8 esbByte = 0u; + UINT8 esbState = 0u; /*رհť״̬*/ + + UINT8 localCiId = 0u; + UINT8 belongCiId = 0u; + + UINT8 esbInx = 0u; + UINT8 retValue = CI_ERROR; + const CiTransmitStruct* pCiRecptStru = NULL; + UINT16 offset = 0u; + UINT16 parsedLen = 0u; + UINT16 inxRem = 0u; + + UINT16 bufInx = 0u; + EsbDataStruct * pEsbDataStru = NULL; + + localCiId = GetSystemParaLocalCiId(); + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + + deviceSum = *(pInputData + parsedLen); + parsedLen += 1u; + + if (NULL == pCiRecptStru) + { + *pItemLen = 0u; + retValue = CI_ERROR; /*ݻȡʧ*/ + } + else if (deviceSum == pCiRecptStru->esbNum) + { + pEsbDataStru = GetEsbData(); + + for (esbInx = 0u; esbInx < deviceSum; esbInx++) + { + inxRem = esbInx % ESB_NUM_PER_BYTE; + + if (0u == inxRem) + { + esbByte = *(pInputData + parsedLen); + + parsedLen += 1u; + } + else + { + /*κδ*/ + ; + } + + esbId = pCiRecptStru->esbIdBuf[esbInx]; + + bufInx = GetEsbConfigBufIndex(esbId); + + (pEsbDataStru + bufInx)->EsbId = esbId; + + belongCiId = GetEsbBelongCiId(esbId); + + if (localCiId != belongCiId) + { + offset = inxRem * BIT_NUM_PER_ESB; + /*offsetȡֵСڵ4*/ + esbState = ((esbByte >> offset) & BIT_MASK_00000011B); /*رհť״̬*/ + + switch (esbState) + { + case BIT_VAL_00000001B: + (void)SetEsbState(esbId, ESB_STATE_VALID_YES); + break; + case BIT_VAL_00000010B: + (void)SetEsbState(esbId, ESB_STATE_VALID_NO); + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + ; + } + } + + *pItemLen = parsedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +رհťݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackEmbtnPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId) +{ + UINT8 localCi = 0u; + UINT8 deviceSum = 0u; /*豸*/ + + UINT16 esbId = 0u; /*رհťID*/ + UINT8 esbState = 0u; /*رհť״̬*/ + + UINT16 offset = 0u; + UINT16 packedLen = 0u; + UINT16 esbInx = 0u; + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + UINT8 retValue = CI_ERROR; + CiTransmitStruct *pTmpCiTransInfo = NULL; + UINT16 inxRem = 0u; + UINT8 * pEsbByte = NULL; + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + packedLen += 1u; + + if (NULL != pTmpCiTransInfo ) + { + + for (esbInx = 0u; esbInx < pTmpCiTransInfo->esbNum; esbInx++) + { + inxRem = esbInx % ESB_NUM_PER_BYTE; + + if (0u == inxRem) + { + pEsbByte = pInputBuf + packedLen; + + packedLen += 1u; + } + else + { + /*κδ*/ + ; + } + + esbId = pTmpCiTransInfo->esbIdBuf[esbInx]; /*ȡͣťID*/ + + if (localCi == GetEsbBelongCiId(esbId)) + { + offset = inxRem * BIT_NUM_PER_ESB; + + esbState = GetEsbState(esbId); /*رհť״̬*/ + + switch (esbState) + { + case ESB_STATE_VALID_YES: + *pEsbByte = *pEsbByte | ((UINT8)(BIT_VAL_00000001B << offset));/*offsetȡֵСڵ4*/ + break; + case ESB_STATE_VALID_NO: + *pEsbByte = *pEsbByte | ((UINT8)(BIT_VAL_00000010B << offset)); + break; + default: + /*ɴ֧*/ + break; + + } + } + else + { + /*DZϢ*/ + } + + deviceSum++; + } + + pInputBuf[deviceSumIndex] = deviceSum; + *pItemLen = packedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + +/* +: +ղ״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseZhaoChaPacket(const UINT8 *pInputData, UINT16 *pItemLen, const UINT8 srcCiId) +{ + UINT8 devSum = 0u; /*ղ̵*/ + UINT16 zcjIdt = 0u; /*ղ̵ID*/ + UINT8 zcjByte = 0u; + UINT8 zcjSta = 0u; /*ղ̵ɼ״̬*/ + + UINT8 localCiId = 0u; + UINT8 belongCiId = 0u; + + UINT8 zcjInx = 0u; + UINT8 retVal = CI_ERROR; + const CiTransmitStruct* pCiRecptStru = NULL; + UINT16 offset = 0u; + UINT16 parsedLen = 0u; + UINT16 inxRem = 0u; + + UINT16 bufInx = 0u; + + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + + devSum = *(pInputData + parsedLen); + parsedLen += 1u; + + if (NULL == pCiRecptStru) + { + *pItemLen = 0u; + retVal = CI_ERROR; /*ݻȡʧ*/ + } + else if (devSum == pCiRecptStru->zcjNum) + { + localCiId = GetSystemParaLocalCiId(); + + for (zcjInx = 0u; zcjInx < devSum; zcjInx++) + { + inxRem = zcjInx % ZCJ_NUM_PER_BYTE; + + if (0u == inxRem) + { + zcjByte = *(pInputData + parsedLen); + + parsedLen += 1u; + } + else + { + /*κδ*/ + ; + } + + zcjIdt = pCiRecptStru->zcjIdBuf[zcjInx]; + + belongCiId = GetRelayBelongCiId(zcjIdt); + + if (localCiId != belongCiId) + { + offset = inxRem * BIT_NUM_PER_ZCJ; + + /*offsetȡֵСڵ4*/ + zcjSta = ((zcjByte >> offset) & BIT_MASK_00000011B);/*ղ̵ɼ״̬*/ + + bufInx = GetRelayConfigBufIndex(zcjIdt); /*ȡ̵±*/ + + RelayDataStru[bufInx].RelayId = zcjIdt; + + switch (zcjSta) + { + case BIT_VAL_00000001B: + RelayDataStru[bufInx].RelayCollState = RELAY_STATE_DOWN; + break; + case BIT_VAL_00000010B: + RelayDataStru[bufInx].RelayCollState = RELAY_STATE_UP; + break; + default: + RelayDataStru[bufInx].RelayCollState = RELAY_STATE_DOWN; + break; + } + } + else + { + ; + } + } + + *pItemLen = parsedLen; + retVal = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retVal = CI_ERROR; + } + + return retVal; +} + +/* +: +ղ̵ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackZhaoChaPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId) +{ + UINT8 localCi = 0u; + UINT8 devSum = 0u; /*豸*/ + + UINT16 zcjIdt = 0u; /*ղ̵ID*/ + UINT8 zcjSta = 0u; /*ղ̵ɼ״̬*/ + + UINT16 offset = 0u; + UINT16 packedLen = 0u; + UINT16 zcjInx = 0u; + UINT16 devSumInx = 0u; /*豸αλ*/ + UINT8 retVal = CI_ERROR; + CiTransmitStruct *pTmpCiTransInfo = NULL; + UINT16 inxRem = 0u; + UINT8 * pZcjByte = NULL; + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + packedLen += 1u; + + if (NULL != pTmpCiTransInfo) + { + for (zcjInx = 0u; zcjInx < pTmpCiTransInfo->zcjNum; zcjInx++) + { + inxRem = zcjInx % ZCJ_NUM_PER_BYTE; + + if(0u == inxRem) + { + pZcjByte = pInputBuf + packedLen; + + packedLen += 1u; + } + else + { + /*κδ*/ + ; + } + + zcjIdt = pTmpCiTransInfo->zcjIdBuf[zcjInx]; /*ȡղ̵ID*/ + + if (localCi == GetRelayBelongCiId(zcjIdt)) + { + offset = inxRem * BIT_NUM_PER_ZCJ; + + zcjSta = GetRelayCollState(zcjIdt); /*ղ̵ɼ״̬*/ + + switch (zcjSta) + { + case RELAY_STATE_DOWN: + *pZcjByte = *pZcjByte | ((UINT8)(BIT_VAL_00000001B << offset));/*offsetȡֵСڵ4*/ + break; + case RELAY_STATE_UP: + *pZcjByte = *pZcjByte | ((UINT8)(BIT_VAL_00000010B << offset)); + break; + default: + break; + } + } + else + { + /*DZϢ*/ + } + + devSum++; + } + + pInputBuf[devSumInx] = devSum; + *pItemLen = packedLen; + retVal = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retVal = CI_ERROR; + } + + return retVal; +} + + +/* +: +״̬ݰ +: +const UINT8 *pInputData ָ +const UINT8 srcCiId ԴID +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseFloodGatePacket(const UINT8 *pInputData, UINT16 *pItemLen, const UINT8 srcCiId) +{ + const CiTransmitStruct* pCiRecptStru = NULL; + FloodGateDataStruct* pstrFloodGateData = NULL; + UINT8 cDevSum = 0U; /**/ + UINT16 wParsedLen = 0U; + UINT8 cLocalCiId = 0U; + UINT8 cFloodGateIndex = 0U; + UINT16 wFloodGateId = 0U; /*ID*/ + UINT8 cFloodGateBelongCiId = 0U; + UINT16 wFloodGateIdIndex = 0U; + UINT8 cFloodGateByte = 0U; + UINT8 cFloodGateState = 0U; /*ſ/״̬*/ + UINT8 cFloodGateReqState = 0U; /*Ź״̬*/ + UINT8 cFloodGateAllowState = 0U; /*״̬*/ + UINT8 cRetVal = CI_ERROR; + + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + pstrFloodGateData = GetFloodGateData(); + cDevSum = *(pInputData + wParsedLen); + wParsedLen++; + + if ((NULL == pCiRecptStru) || (NULL == pstrFloodGateData)) + { + *pItemLen = 0U; + cRetVal = CI_ERROR; /*ݻȡʧ*/ + } + else if (cDevSum == ((UINT8)pCiRecptStru->floodGateNum)) + { + cLocalCiId = GetSystemParaLocalCiId(); + + for (cFloodGateIndex = 0U; cFloodGateIndex < cDevSum; cFloodGateIndex++) + { + cFloodGateByte = *(pInputData + wParsedLen); /*ǰ״̬*/ + wParsedLen++; + + wFloodGateId = pCiRecptStru->floodGateIdBuf[cFloodGateIndex]; + cFloodGateBelongCiId = GetFloodGateBelongCiId(wFloodGateId); + if (cLocalCiId != cFloodGateBelongCiId) + { + wFloodGateIdIndex = GetFloodGateBufIndex(wFloodGateId); + pstrFloodGateData[wFloodGateIdIndex].FloodGateId = wFloodGateId; + + cFloodGateState = (cFloodGateByte & BIT_MASK_00000011B); /*ſ/״̬*/ + switch (cFloodGateState) + { + case BIT_VAL_00000010B: + SetFloodGateCurOpenLockState(wFloodGateId, FLOOD_GATE_OPENLOCK); /*ÿ*/ + break; + case BIT_VAL_00000001B: + SetFloodGateCurOpenLockState(wFloodGateId, FLOOD_GATE_NOT_OPENLOCK); /*ù*/ + break; + default: + break; + } + + cFloodGateReqState = ((cFloodGateByte >> 2U) & BIT_MASK_00000011B); /*Ź״̬*/ + switch (cFloodGateReqState) + { + case BIT_VAL_00000001B: + SetFloodGateCurCloseRequestSta(wFloodGateId, FLOOD_GATE_CLOSEREQ); /*й*/ + break; + case BIT_VAL_00000010B: + SetFloodGateCurCloseRequestSta(wFloodGateId, FLOOD_GATE_NOT_CLOSEREQ); /*޹*/ + break; + default: + break; + } + + cFloodGateAllowState = ((cFloodGateByte >> 4U) & BIT_MASK_00000011B); /*״̬*/ + switch (cFloodGateAllowState) + { + case BIT_VAL_00000001B: + SetFloodGateCurAgreeCloseSta(wFloodGateId, FLOOD_GATE_AGREE_CLOSE); /**/ + break; + case BIT_VAL_00000010B: + SetFloodGateCurAgreeCloseSta(wFloodGateId, FLOOD_GATE_NOT_AGREE_CLOSE); /*ò*/ + break; + default: + break; + } + } + else + { + ;/*豸*/ + } + } + + *pItemLen = wParsedLen; + cRetVal = CI_SUCCESS; + } + else + { + *pItemLen = 0U; + cRetVal = CI_ERROR; + } + + return cRetVal; +} + +/* +: +״̬ݰ +: +UINT8 *pInputData ָ +const UINT8 dstCiId ĿID +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackFloodGatePacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId) +{ + CiTransmitStruct* pTmpCiTransInfo = NULL; + UINT8 cLocalCiId = 0U; + UINT16 wPackedLen = 0U; + UINT16 wFdGateIndex = 0U; + UINT8* pFloodGateByte = NULL; + UINT16 wFloodGateId = 0U; /*ID*/ + UINT8 cFloodGateBelongCiId = 0U; + UINT8 cFloodGateState = 0U; /*ſ/״̬*/ + UINT8 cFloodGateReqState = 0U; /*Ź״̬*/ + UINT8 cFloodGateAllowState = 0U; /*״̬*/ + UINT8 cRetVal = CI_ERROR; + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + + if (NULL != pTmpCiTransInfo) + { + cLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + pInputBuf[wPackedLen] = (UINT8)pTmpCiTransInfo->floodGateNum; /**/ + wPackedLen++; + + for (wFdGateIndex = 0U; wFdGateIndex < pTmpCiTransInfo->floodGateNum; wFdGateIndex++) + { + pFloodGateByte = pInputBuf + wPackedLen; + + wFloodGateId = pTmpCiTransInfo->floodGateIdBuf[wFdGateIndex]; /*ȡղ̵ID*/ + cFloodGateBelongCiId = GetFloodGateBelongCiId(wFloodGateId); + + if (cLocalCiId == cFloodGateBelongCiId) + { + cFloodGateState = GetFloodGateCurOpenLockState(wFloodGateId); + switch (cFloodGateState) + { + case FLOOD_GATE_OPENLOCK: + *pFloodGateByte = *pFloodGateByte | BIT_VAL_00000010B; /*ſ*/ + break; + case FLOOD_GATE_NOT_OPENLOCK: + *pFloodGateByte = *pFloodGateByte | BIT_VAL_00000001B; /*Źر*/ + break; + default: + break; + } + + cFloodGateReqState = GetFloodGateCurCloseRequestSta(wFloodGateId); + switch (cFloodGateReqState) + { + case FLOOD_GATE_CLOSEREQ: + *pFloodGateByte = *pFloodGateByte | (BIT_VAL_00000001B << 2U); /*й*/ + break; + case FLOOD_GATE_NOT_CLOSEREQ: + *pFloodGateByte = *pFloodGateByte | (BIT_VAL_00000010B << 2U); /*޹*/ + break; + default: + break; + } + + cFloodGateAllowState = GetFloodGateCurAgreeCloseSta(wFloodGateId); + switch (cFloodGateAllowState) + { + case FLOOD_GATE_AGREE_CLOSE: + *pFloodGateByte = *pFloodGateByte | (BIT_VAL_00000001B << 4U); /**/ + break; + case FLOOD_GATE_NOT_AGREE_CLOSE: + *pFloodGateByte = *pFloodGateByte | (BIT_VAL_00000010B << 4U); /*Ų*/ + break; + default: + break; + } + } + else + { + /*DZϢ*/ + } + + wPackedLen++; + } + + *pItemLen = wPackedLen; + cRetVal = CI_SUCCESS; + } + else + { + *pItemLen = 0U; + cRetVal = CI_ERROR; + } + + return cRetVal; +} + + +/* +: +ϵ״̬ݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseStartLockPacket(const UINT8* pInputData, UINT16* pItemLen, const UINT8 srcCiId) +{ + UINT8 deviceSum = 0u; /*ϵ*/ + UINT8 retValue = CI_ERROR; + UINT16 phySecId = 0u; /*ID*/ + UINT16 ii = 0u; /*α*/ + UINT16 bufIndex = 0u; /*±*/ + UINT8 StartLockState = 0u; /*ϵ״̬*/ + UINT8 localCiId = 0u; + UINT16 wLogSecId = 0u; /*߼ID*/ + UINT8 cSecBelongCiId = 0U; + const CiTransmitStruct* pCiRecptStru = NULL; + UINT16 parsedLen = 0u; + LogicSectionDataStruct* pstrLogSecData = NULL; + PhysicalSectionDataStruct* tmpPhysicalSectionDataStru = GetPhySecData(); + localCiId = GetSystemParaLocalCiId(); + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + pstrLogSecData = GetLogicSecData(); + + deviceSum = *(pInputData + parsedLen); + parsedLen += 1u; + + if ((NULL == pCiRecptStru) || (NULL == tmpPhysicalSectionDataStru) || (NULL == pstrLogSecData)) + { + *pItemLen = 0u; + retValue = CI_ERROR; /*ݻȡʧ*/ + } + else if (1u == deviceSum) + { + StartLockState = *(pInputData + parsedLen); /*ϵ״̬*/ + parsedLen += 1u; + + for (ii = 0u;ii < pCiRecptStru->phySecNum;ii++) + { + phySecId = pCiRecptStru->phySecIdBuf[ii]; + cSecBelongCiId = GetPhySecBelongCiId(phySecId); + if (cSecBelongCiId == srcCiId) + { + bufIndex = GetPhySecConfigBufIndex(phySecId); + tmpPhysicalSectionDataStru[bufIndex].PhysicalSectionId = phySecId; + + switch (StartLockState) + { + case HLHT_STARTLOCK_SET_NO: + SetPhySecStartLockStateHlht(phySecId, PHYSICAL_SECTION_LOCK_NO); + break; + case HLHT_STARTLOCK_SET_YES: + SetPhySecStartLockStateHlht(phySecId, PHYSICAL_SECTION_LOCK_START); + SetPhySecLockDirHlht(phySecId, CI_SYSTEM_DIRECTION_NONE); + SetPhySecRLockRouteIdHlht(phySecId, 0u); + SetPhySecPLockRouteIdHlht(phySecId, 0u); + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + /*DZΣ*/ + } + } + + for (ii = 0u; ii < pCiRecptStru->logicSecNum; ii++) + { + wLogSecId = pCiRecptStru->logicSecIdBuf[ii]; + cSecBelongCiId = GetLogSecBelongCiId(wLogSecId); + if (cSecBelongCiId == srcCiId) + { + bufIndex = GetlogSectionBufIndex(wLogSecId); + pstrLogSecData[bufIndex].LogicSectionId = wLogSecId; + + switch (StartLockState) + { + case HLHT_STARTLOCK_SET_NO: + SetLogSecStartLockStateHlht(wLogSecId, LOG_SECTION_LOCK_NO); + break; + case HLHT_STARTLOCK_SET_YES: + SetLogSecStartLockStateHlht(wLogSecId, LOG_SECTION_LOCK_START); + SetLogSecLockDirHlht(wLogSecId, CI_SYSTEM_DIRECTION_NONE); + SetLogSecPLockRouteIdHlht(wLogSecId, 0U); + SetLogSecRLockRouteIdHlht(wLogSecId, 0U); + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + /*DZΣ*/ + } + } + + *pItemLen = parsedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0u; + retValue = CI_ERROR; + } + + return retValue; +} + + +/* +: +ϵ״̬ݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackStartLockPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId) +{ + UINT8 StartLockState = 0u; /*ϵ״̬*/ + UINT16 ii = 0u; + UINT16 deviceSumIndex = 0u; /*豸αλ*/ + UINT8 retValue = CI_ERROR; + + ii++; + + StartLockState = GetStartLockFlag(); /*״̬*/ + + switch (StartLockState) + { + case CI_START_LOCK_YES: + pInputBuf[ii] = HLHT_STARTLOCK_SET_YES; + break; + case CI_START_LOCK_NO: + pInputBuf[ii] = HLHT_STARTLOCK_SET_NO; + break; + default: + /*ɴ֧*/ + break; + } + + ii++; + + pInputBuf[deviceSumIndex] = 1u;/*ϵΪ1*/ + *pItemLen = ii; + retValue = CI_SUCCESS; + + return retValue; +} + +/* +* ͨCIӿʱݰ +* ˵UINT8 *pInputBuf ָ +* UINT16 *pItemLen еij +* const UINT8 srcCiId ԴID +* ֵ1 ɹ +* 0 ʧ +* edit cgh 20250116 +*/ +static UINT8 ParseTSRPacket(const UINT8 *pInputData, UINT16 *pItemLen,const UINT8 srcCiId) +{ + UINT8 retValue = CI_ERROR; + UINT8 chLocalCiId = 0U;/*ID*/ + const CiTransmitStruct* pCiRecptStru = NULL; /*Դַ*/ + UINT8 chDeviceSum = 0U;/*豸Ŀ*/ + UINT16 wParsedLen = 0U;/*ݳ*/ + UINT16 wLogSecIndex = 0U;/*߼*/ + UINT16 wLogSecId = 0U;/*߼ID*/ + UINT8 chLogSecBelCiId = 0U;/*߼ID*/ + UINT8 chLinShiXianSuState = 0U;/*ʱ״̬*/ + UINT8 chTsrByte = 0U;/*ʱֽ*/ + UINT16 wInxRem = 0U;/*ʱ߼ֽƫƱ־*/ + UINT16 wOffset = 0U;/*ʱ߼ֽƫ*/ + + pCiRecptStru = GetSrcCiTransInfo(srcCiId); + + if ((NULL != pInputData) && (NULL != pItemLen) && (NULL != pCiRecptStru)) + { + chLocalCiId = GetSystemParaLocalCiId(); + chDeviceSum = *pInputData; + wParsedLen += 1U; + + if (chDeviceSum == (UINT8)pCiRecptStru->logicSecNum) + { + for (wLogSecIndex = 0U; wLogSecIndex < pCiRecptStru->logicSecNum; wLogSecIndex++) + { + wInxRem = wLogSecIndex % TSR_NUM_PER_BYTE; + + if (0U == wInxRem) + { + /*˵Ҫֽ*/ + chTsrByte = *(pInputData + wParsedLen); + + wParsedLen += 1U; + } + else + { + /*κδҪƫ*/ + ; + } + + wLogSecId = pCiRecptStru->logicSecIdBuf[wLogSecIndex]; + chLogSecBelCiId = GetLogSecBelongCiId(wLogSecId); + + if (chLocalCiId != chLogSecBelCiId) + { + wOffset = wInxRem * BIT_NUM_PER_TSR; + + chLinShiXianSuState = ((chTsrByte >> wOffset) & BIT_MASK_00000011B); + + switch (chLinShiXianSuState) + { + case BIT_VAL_00000011B: + SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_INVALID); + break; + case BIT_VAL_00000001B: + SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_YES); + break; + case BIT_VAL_00000010B: + SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_NO); + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + ; /*Σ*/ + } + } + + *pItemLen = wParsedLen; + retValue = CI_SUCCESS; + } + else + { + *pItemLen = 0U; /*ʧ*/ + } + } + else + { + ; + } + + return retValue; +} + +/* +* ͨCIӿʱݰ +* ˵UINT8 *pInputBuf ָ +* UINT16 *pItemLen еij +* const UINT8 dstCiId ĿID +* ֵ1 ɹ +* 0 ʧ +* edit cgh 20250116 +*/ +static UINT8 PackTSRPacket(UINT8 *pInputBuf, UINT16 *pItemLen, const UINT8 dstCiId) +{ + UINT8 retValue = CI_ERROR; + CiTransmitStruct* pTmpCiTransInfo = NULL; + UINT16 wLogSecIndex = 0U;/*߼*/ + UINT8 chLocalCi = 0U; /*ID*/ + UINT16 wPackedLen = 0U;/**/ + UINT16 wLogSecId = 0U;/*߼ID*/ + UINT8 chLogSecBelCiId = 0U;/*߼ID*/ + UINT8 chLinShiXianSuState = 0U;/*ʱ״̬*/ + UINT8* pTsrByte = NULL;/*ʱٴ洢ַ*/ + UINT16 wInxRem = 0U;/*ʱ߼ֽƫƱ־*/ + UINT16 wOffset = 0U;/*ʱ߼ֽƫ*/ + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + + if ((NULL != pInputBuf) && (NULL != pItemLen) && (NULL != pTmpCiTransInfo)) + { + chLocalCi = GetSystemParaLocalCiId(); + wPackedLen += 1U; + + for (wLogSecIndex = 0U; wLogSecIndex < pTmpCiTransInfo->logicSecNum; wLogSecIndex++) + { + wInxRem = wLogSecIndex % TSR_NUM_PER_BYTE; + + if (0U == wInxRem) + { + /*˵Ҫֽ*/ + pTsrByte = pInputBuf + wPackedLen; + + wPackedLen += 1U; + } + else + { + /*κδҪƫ*/ + ; + } + + wLogSecId = pTmpCiTransInfo->logicSecIdBuf[wLogSecIndex]; + chLogSecBelCiId = GetLogSecBelongCiId(wLogSecId); + if (chLocalCi == chLogSecBelCiId) + { + wOffset = wInxRem * BIT_NUM_PER_TSR; + + chLinShiXianSuState = GetLogSecLinShiXianSuSetState(wLogSecId); + + switch (chLinShiXianSuState) + { + case LOGSEC_LSXS_SET_STATE_INVALID: + *pTsrByte = *pTsrByte | ((UINT8)(BIT_VAL_00000011B << wOffset)); + break; + case LOGSEC_LSXS_SET_STATE_YES: + *pTsrByte = *pTsrByte | ((UINT8)(BIT_VAL_00000001B << wOffset)); + break; + case LOGSEC_LSXS_SET_STATE_NO: + *pTsrByte = *pTsrByte | ((UINT8)(BIT_VAL_00000010B << wOffset)); + break; + default: + /*ɴ֧*/ + break; + } + } + else + { + ; /*DZ*/ + } + } + + pInputBuf[0] = pTmpCiTransInfo->logicSecNum; + *pItemLen = wPackedLen; + retValue = CI_SUCCESS; + } + else + { + ; + } + return retValue; +} +/* +: +Զݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 ParseCityDefPacket(const UINT8 *pInputData, UINT16 *pItemLen) +{ + + return CI_SUCCESS; +} + +/* +: +Զݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ + +static UINT8 PackCityDefPacket(UINT8 *pInputData, UINT16 *pItemLen) +{ + + return CI_SUCCESS; +} + +/* +: +Զݰ +: +const UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseManufacDefPacket(const UINT8 *pInputData, UINT16 *pItemLen) +{ + return CI_SUCCESS; +} + +/* +: +Զݰ +: +UINT8 *pInputData ָ +: +UINT16 *pItemLen еij +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackManufacDefPacket(UINT8 *pInputData, UINT16 *pItemLen) +{ + return CI_SUCCESS; +} + +/* +: +컥ͨӦ +: +const UINT8 dstCiId ĿID +: +UINT8 *pInputData ݻָ +UINT16 *pOverallLen Ӧָܳ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackCiPacketCont(UINT8 *pInputData, UINT16 *pOverallLen, const UINT8 dstCiId) +{ + UINT16 packetOrder = 0u; + UINT16 packetType = 0xFFFFu; /*Ӧñ*/ + + UINT16 packedLen = 0u; /*Ӧñָƫ*/ + UINT16 itemLen = 0u; /*Ϣ*/ + UINT8 *pLenItemAddr = NULL; /*ָ Ӧñijbufferַ*/ + + UINT8 dataIsAvail = CI_FALSE; + UINT8 retVal = CI_ERROR; + + CiTransmitStruct *pTmpCiTransInfo = NULL; + + pTmpCiTransInfo = GetDstCiTransInfo(dstCiId); + + if ((NULL == pTmpCiTransInfo) || (NULL == pInputData) || (NULL == pOverallLen)) + { + retVal = CI_ERROR; + *pOverallLen = 0u; + } + else + { + retVal = CI_SUCCESS; + while (1) + { + packetType = packetOderQueue[packetOrder]; /**/ + + packetOrder++; + + if ((0xFFFFU != packetType) && (CI_SUCCESS == retVal)) + { + /*ݰ*/ + } + else + { + break; + } + + switch (packetType) + { + case SWITCH_STATUS_PACKET: + if (0u != pTmpCiTransInfo->switchNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case PHYSIC_SEC_STATUS_PACKET: + if (0u != pTmpCiTransInfo->phySecNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case LOGIC_SEC_STATUS_PACKET: + if (0u != pTmpCiTransInfo->logicSecNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case SIGNAL_STATUS_PACKET: + if (0u != pTmpCiTransInfo->signalNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case PSD_STATUS_PACKET: + if (0u != pTmpCiTransInfo->psdNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case EMERGEBTN_STATUS_PACKET: + if (0u != pTmpCiTransInfo->esbNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case ZHAOCHA_STATUS_PACKET: + if (0u != pTmpCiTransInfo->zcjNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case FLOOD_GATE_STATUS_PACKET: + if (0u != pTmpCiTransInfo->floodGateNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case START_LOCK_STATUS_PACKET: + dataIsAvail = CI_TRUE; + break; + case LINSHI_XIANSU_STATUS_PACKET: + if (0u != pTmpCiTransInfo->logicSecNum) + { + dataIsAvail = CI_TRUE; + } + else + { + dataIsAvail = CI_FALSE; + } + break; + case CITY_DEF_STATUS_PACKET: + dataIsAvail = CI_FALSE; + break; + case MANUFAC_DEF_STATUS_PACKET: + dataIsAvail = CI_FALSE; + break; + default: + dataIsAvail = CI_FALSE; + break; + } + + if (CI_TRUE == dataIsAvail) + { + retVal &= PackPacketLenPha1(pInputData + packedLen, &pLenItemAddr, &itemLen); /*ȡűݳȵַĵַ*/ + packedLen += itemLen; + + retVal &= PackPacketType(pInputData + packedLen, packetType, &itemLen); /*Ӧñ*/ + packedLen += itemLen; + + packedLen += PACKET_EMPTY_LEN; /*ֽڵԤλ*/ + + if (CI_SUCCESS == retVal) + { + switch (packetType) + { + case SWITCH_STATUS_PACKET: + retVal &= PackSwitchPacket(pInputData + packedLen, &itemLen, dstCiId); /**/ + packedLen += itemLen; + break; + case PHYSIC_SEC_STATUS_PACKET: + retVal &= PackPhySecPacket(pInputData + packedLen, &itemLen, dstCiId); /*α*/ + packedLen += itemLen; + break; + case LOGIC_SEC_STATUS_PACKET: + retVal &= PackLogSecPacket(pInputData + packedLen, &itemLen, dstCiId); /*߼α*/ + packedLen += itemLen; + break; + case SIGNAL_STATUS_PACKET: + retVal &= PackSignalPacket(pInputData + packedLen, &itemLen, dstCiId); /*źŻ*/ + packedLen += itemLen; + break; + case PSD_STATUS_PACKET: + retVal &= PackPsdPacket(pInputData + packedLen, &itemLen, dstCiId); /*PSD*/ + packedLen += itemLen; + break; + case EMERGEBTN_STATUS_PACKET: + retVal &= PackEmbtnPacket(pInputData + packedLen, &itemLen, dstCiId); /*ͣť*/ + packedLen += itemLen; + break; + case ZHAOCHA_STATUS_PACKET: + retVal &= PackZhaoChaPacket(pInputData + packedLen, &itemLen, dstCiId); /*ղ̵*/ + packedLen += itemLen; + break; + case FLOOD_GATE_STATUS_PACKET: + retVal &= PackFloodGatePacket(pInputData + packedLen, &itemLen, dstCiId); + packedLen += itemLen; + break; + case START_LOCK_STATUS_PACKET: + retVal &= PackStartLockPacket(pInputData + packedLen, &itemLen, dstCiId); /*ϵձ*/ + packedLen += itemLen; + break; + case LINSHI_XIANSU_STATUS_PACKET: + retVal &= PackTSRPacket(pInputData + packedLen, &itemLen, dstCiId); /*ϵձ*/ + packedLen += itemLen; + break; + case CITY_DEF_STATUS_PACKET: + break; + case MANUFAC_DEF_STATUS_PACKET: + break; + default: + /*ɴ֧*/ + break; + } + + retVal &= PackPacketLenPha2(pLenItemAddr, itemLen + PACKET_TYPE_LEN + PACKET_EMPTY_LEN); /*뱨ݵij*/ + + if (CI_SUCCESS == retVal) + { + /**/ + } + else + { + retVal = CI_ERROR; /*ʧܣʧ*/ + debug_infor_printf((const)"\nHlht Ci Id[%d] Pack Packet[0x%04x] Error", dstCiId, packetType); + } + } + else + { + retVal = CI_ERROR; /*ʧܣʧ*/ + debug_infor_printf((const)"\nHlht Ci Id[%d] Pack Len Or Type Error", dstCiId); + } + } + else + { + packedLen += 0u; + } + } + *pOverallLen = packedLen; /*ȡܳ*/ + } + + return retVal; +} + +/* +: + +: +const UINT8 *pInputData ָ +const UINT16 overallLen Ӧñܳ +: + +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 ParseCiPacketCont(const UINT8 *pInputData, const UINT16 overallLen,const UINT8 srcId) +{ + UINT16 packetType = 0xFFFFu; /*Ӧñ*/ + UINT16 packetLen = 0u; /*Ӧñij*/ + UINT16 parsedLen = 0u; /*Ӧñָƫ*/ + UINT16 packetIdle = 0u; /*Ԥ*/ + UINT16 itemLen = 0u; /*Ϣ*/ + UINT8 cRetVal = CI_ERROR; + + if (NULL != pInputData) + { + cRetVal = CI_SUCCESS; + while (1) + { + if ((parsedLen < overallLen) && (CI_SUCCESS == cRetVal)) + { + /*ݰ*/ + } + else + { + break; + } + + cRetVal &= ParsePacketLength(pInputData + parsedLen, &packetLen, &itemLen); /*ȡһij*/ + parsedLen += itemLen; + + cRetVal &= ParsePacketType(pInputData + parsedLen, &packetType, &itemLen); /*ȡһ*/ + parsedLen += itemLen; + + packetIdle = ShortFromChar(pInputData + parsedLen); /*ȡԤλ*/ + parsedLen += PACKET_EMPTY_LEN; + + if (CI_SUCCESS == cRetVal) + { + switch (packetType) + { + case SWITCH_STATUS_PACKET: + cRetVal &= ParseSwitchPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case PHYSIC_SEC_STATUS_PACKET: + cRetVal &= ParsePhySecPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case LOGIC_SEC_STATUS_PACKET: + cRetVal &= ParseLogSecPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case SIGNAL_STATUS_PACKET: + cRetVal &= ParseSignalPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case PSD_STATUS_PACKET: + cRetVal &= ParsePsdPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case EMERGEBTN_STATUS_PACKET: + cRetVal &= ParseEmbtnPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case ZHAOCHA_STATUS_PACKET: + cRetVal &= ParseZhaoChaPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case FLOOD_GATE_STATUS_PACKET: + cRetVal &= ParseFloodGatePacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case START_LOCK_STATUS_PACKET: + cRetVal &= ParseStartLockPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case LINSHI_XIANSU_STATUS_PACKET: + cRetVal &= ParseTSRPacket(pInputData + parsedLen, &itemLen, srcId); + parsedLen += itemLen; + break; + case CITY_DEF_STATUS_PACKET: + cRetVal &= ParseCityDefPacket(pInputData + parsedLen, &itemLen); + parsedLen += itemLen; + break; + case MANUFAC_DEF_STATUS_PACKET: + cRetVal &= ParseManufacDefPacket(pInputData + parsedLen, &itemLen); + parsedLen += itemLen; + break; + default: + /*ɴ֧*/ + break; + } + + if (CI_SUCCESS == cRetVal) + { + /**/ + } + else + { + cRetVal = CI_ERROR; /*ʧ*/ + debug_infor_printf((const)"\nHlht Ci Id[%d] Parse Packet[0x%04x] Error", srcId, packetType); + } + } + else + { + cRetVal = CI_ERROR; /*ʧ*/ + debug_infor_printf((const)"\nHlht Ci Id[%d] Parse Len Or Type Error"); + } + } + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + +/* +: +ͨͷڶ +: + +: +UINT8 * pInputData ݻָ +UINT16 appDataLen Ӧݳ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +UINT8 PackHlhtPacketHeadPha2(UINT8 * pInputData, UINT16 appDataLen) +{ + UINT8 cRetVal = CI_ERROR; + + if (NULL != pInputData) + { + /*дӦݳ*/ + ShortToChar(appDataLen, pInputData); + cRetVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + + +/* +: +ͨͷһ +: +UINT8 dstCiId ĿID +: +UINT8 * pInputData ݻָ +UINT16 * pHeadDataLen ͷȱָ +UINT8 * * ppLenItemAddr ͷдӦóȵĵַָ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +UINT8 PackHlhtPacketHeadPha1(UINT8 dstCiId, UINT8 * pInputData, UINT16 * pHeadDataLen, UINT8 * * ppLenItemAddr) +{ + UINT16 interfaceInfoType = CI_TO_CI_INTERFACE; /*ӿ*/ + UINT32 srcCiEtcsId = 0u; /*ID*/ + UINT32 dstCiEtcsId = 0u; /*ĿID*/ + UINT32 emapVerChkSum = 0u; /*ӵͼУϢ*/ + UINT32 sourceMessageSn = 0u; /*Ϣ*/ + UINT16 commPeriod = 0u; /*ͨ*/ + UINT32 destinMessageSn = 0u; /*ԷϢ*/ + UINT32 prevSourceMessageSn = 0u; /*յһϢʱԷϢ*/ + UINT8 protocolVersion = HLHT_CI_INTER_VER; /*Э汾*/ + UINT8 locCiId = 0u; + UINT16 ii = 0u; /*α*/ + UINT8 headSaved = GetHLHTHeadCtxExistance(CI_SYSTEM_TYPE_CI, dstCiId); + UINT16 wCiDevName = 0U; + UINT8 cRetVal = CI_ERROR; + + if ((NULL != pInputData) && (NULL != pHeadDataLen) && (NULL != ppLenItemAddr)) + { + locCiId = GetSystemParaLocalCiId(); /*ID*/ + + ShortToChar(interfaceInfoType, &pInputData[ii]); /*дӿϢ*/ + ii += INTERFACE_INFO_TYPE_LEN; + + (void)dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_CI << 8u) + locCiId, 0u, &srcCiEtcsId); + LongToChar(srcCiEtcsId, &pInputData[ii]); /*д뷢ͷETCS ID*/ + ii += SOURCE_ID_LEN; + + (void)dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_CI << 8u) + dstCiId, 0u, &dstCiEtcsId); + LongToChar(dstCiEtcsId, &pInputData[ii]); /*дշETCS ID*/ + ii += DESTIN_ID_LEN; + + wCiDevName = (CI_SYSTEM_TYPE_CI) * 256U + dstCiId; + emapVerChkSum = GetCiTranCiDataCheckVer(locCiId, wCiDevName); + + LongToChar(emapVerChkSum, &pInputData[ii]); /*дӵͼУϢ*/ + ii += EMAP_VISION_CHECK_SUM_LEN; + + sourceMessageSn = Get2oo2CurCycleNum(); + LongToChar(sourceMessageSn, &pInputData[ii]); /*дԷϢ*/ + ii += SOURCE_MESSAGE_SN_LEN; + + commPeriod = (UINT16)GetSystemParaAppCycleTime(); + ShortToChar(commPeriod, &pInputData[ii]); /*дͨ*/ + ii += COMM_PERIOD_LEN; + + if (CI_SUCCESS == headSaved) + { + destinMessageSn = GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_CI, dstCiId); + prevSourceMessageSn = GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_CI, dstCiId); + } + else + { + destinMessageSn = UINT32_MAX; + prevSourceMessageSn = UINT32_MAX; + } + + LongToChar(destinMessageSn, &pInputData[ii]); /*дԷϢ*/ + ii += DESTIN_MESSAGE_SN_LEN; + + LongToChar(prevSourceMessageSn, &pInputData[ii]); /*дյһϢʱԷϢ*/ + ii += PREV_SOURCE_MESSAGE_SN_LEN; + + pInputData[ii] = protocolVersion; /*дЭ汾*/ + ii += PROTOCOL_VERSION_LEN; + + /*Ӧñijλָ*/ + *ppLenItemAddr = (pInputData + ii); + + ii += PACKET_LENGTH_LEN; + + *pHeadDataLen = ii; /*ȡͷij*/ + + cRetVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + + return cRetVal; +} + + + +/* +: +ͨӦñ֡ +: +UINT8 dstCiId ĿID +: +UINT8* dataFrame ָ֡ +UINT16* dataLength ֡ȱָ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +static UINT8 PackHLHTCiToCiDataFrameUseCfg(UINT8 dstCiId, UINT8* dataFrame, UINT16* dataLength) +{ + UINT16 appDataLen = 0u; /*Ӧòݳ*/ + UINT16 headDataLen = 0u; /*ͨñͷݳ*/ + UINT8 reVaule = CI_ERROR; + UINT8 * pLenItemAddr = NULL; + + if ((dataFrame != NULL) && (NULL != dataLength)) + { + /*黥ͨͷһ*/ + reVaule = PackHlhtPacketHeadPha1(dstCiId, dataFrame, &headDataLen, &pLenItemAddr); /*뱨ͷ Ӧò㱨ܳ*/ + + reVaule &= PackCiPacketCont(dataFrame + headDataLen, &appDataLen, dstCiId); /*Ӧñ*/ + + /*黥ͨͷڶ*/ + reVaule &= PackHlhtPacketHeadPha2(pLenItemAddr, appDataLen); + + *dataLength = headDataLen + appDataLen; /*ݱܳ*/ + } + else + { + reVaule = CI_ERROR; + } + + return reVaule; +} + +/* +: +ͨ +: +UINT8 targetDeviceId ĿID +: +QueueStruct* ciToCiDataQueue ݶָ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +UINT8 PackHLHTCiToCiData(UINT8 targetDeviceId) +{ + UINT8 retVal = CI_ERROR; + UINT8 localCiId = 0u; + UINT32 etcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT8 ciToCiDataBuffer[CI_TO_CI_DATA_LEN_MAX] = { 0u };/*CICI֡*/ + UINT16 frameDataLen = 0u; /*Ϣܳ*/ + UINT16 ii = 0u; + UINT8 locCiEtcsIdChkRetVal = CI_ERROR; + UINT8 tarCiEtcsIdChkRetVal = CI_ERROR; + UINT8 locCiEmapChkRetVal = CI_ERROR; + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + UINT16 wDevType = 0u; + + localCiId = GetSystemParaLocalCiId(); /*ID*/ + locCiEtcsIdChkRetVal = dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_CI << 8u) + localCiId,0u,&etcsId); + tarCiEtcsIdChkRetVal = dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_CI << 8u) + targetDeviceId,0u,&etcsId); + locCiEmapChkRetVal = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_CI); + /*ȻȡʱϢȡɹбҪ*/ + if( (CI_SUCCESS == locCiEtcsIdChkRetVal) + && + (CI_SUCCESS == tarCiEtcsIdChkRetVal) + && + (CI_SUCCESS == locCiEmapChkRetVal)) + { + /*ͨӦñ֡*/ + retVal = PackHLHTCiToCiDataFrameUseCfg(targetDeviceId, &ciToCiDataBuffer[ii], &frameDataLen); + ii = ii + frameDataLen; + + if (CI_SUCCESS == retVal) + { + wDevType = (UINT16)Get2oo2SheBeiType(); + dstDevId = ((UINT16)(wDevType << 8u) | ((UINT16)targetDeviceId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &ciToCiDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nCI_SEND:%d", ii); + debug_out_array(0xAA, ciToCiDataBuffer, ii); +#endif/*ƽ̨ӡ*/ + + +#endif + retVal = CI_SUCCESS; + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; /*ʧ*/ + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/** +* @brief ʼTIOCӿͨų¼ +* @param +* @return +* @note +*/ +void TiocTransCtInit(void) +{ + UINT8 * pTiocIdBuf = NULL; + UINT8 chTiocNum = 0u; + UINT8 chIndex = 0u; + + chTiocNum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI); + pTiocIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI); + + if ((TRANSMIT_OBJECT_DEVICE_SUM_MAX > chTiocNum) && (NULL != pTiocIdBuf)) + { + g_transmitTiocNum = chTiocNum; + for (chIndex = 0u; chIndex < chTiocNum; chIndex++) + { + g_szTiocCt[chIndex].chTiocId = pTiocIdBuf[chIndex]; + } + } + else + { + ; + } +} + +/** +* @brief ȡָTIOCͨų洢 +* @param +* @return +* @note +*/ +UINT8 GetTiocTransmitIndex(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + for (chIndex = 0u; chIndex < g_transmitTiocNum; chIndex++) + { + if (chTiocId == g_szTiocCt[chIndex].chTiocId) + { + break; + } + else + { + ; + } + } + return chIndex; +} + +/** +* @brief ȡָTIOCͨų +* @param +* @return +* @note +*/ +UINT8 GetTiocTransmitCtNum(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + UINT8 chRtn = 0u; + chIndex = GetTiocTransmitIndex(chTiocId); + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex) + { + chRtn = g_szTiocCt[chIndex].chCtNum; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡָTIOCͨųID +* @param +* @return IDַ +* @note +*/ +UINT16 * GetTiocTransmitCtIds(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + UINT16 * chRtn = NULL; + chIndex = GetTiocTransmitIndex(chTiocId); + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex) + { + chRtn = g_szTiocCt[chIndex].szCtId; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ɢϢ +* @param UINT8 dstCiId ĿTIOC +* @param UINT8* dataFrame ݻ +* @return ȣʧ0 +*/ +static UINT16 PackCiToCiDataFrameEa(UINT8 dstCiId, UINT8* dataFrame) +{ + UINT16 wRtn = 0u; + UINT16 wEaNumIndex = 0u; + UINT8 chEaSendNum = 0u; + UINT8 chEaNum = 0u; + UINT8 chEaIndex = 0u; + UINT16 wEaTrainId = 0u; + UINT8 chEaLgcNum = 0u; + UINT16 * pEaLgcId = NULL; + UINT32 dwMidLine = 0u; + UINT8 chEaBuidFlag = 0u; + UINT8 chDstTioc = 0u; + UINT8 chSrcTioc = 0u; + UINT8 chDstAllowed = 0u; + UINT8 chLgcIndex = 0u; + UINT8 chPackFlag = CI_ERROR; + UINT8 chLocalId = GetSystemParaLocalCiId(); + UINT8 chPaType = 0u; + UINT32 dwEaBuildCyc = 0u; + + /* Ԥɢλ */ + wRtn++; + + chEaNum = GetEaNum(); + /*chEaNumɢֵʱ*/ + if (EA_MAX_NUM < chEaNum) + { + chPackFlag = CI_ERROR; + } + else + { + chPackFlag = CI_SUCCESS; + } + + if (CI_SUCCESS == chPackFlag) + { + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + { + /* ɢгID */ + wEaTrainId = GetEvacuatingTrainIdByIndex(chEaIndex); + if ((0u == wEaTrainId) || (UINT16_MAX == wEaTrainId)) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + /* ߼ */ + chEaLgcNum = EaGetLgcNum(chEaIndex); + if ((0u < chEaLgcNum) && (EA_SECTION_MAX_NUM >= chEaLgcNum)) + { + ; + } + else + { + chPackFlag = CI_ERROR; + } + + /* ߼ */ + pEaLgcId = EaGetLgcId(chEaIndex); + if (NULL == pEaLgcId) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + /* ɢг */ + dwMidLine = EaGetMidLine(chEaIndex); + if (UINT32_MAX == dwMidLine) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + /* ־ */ + chEaBuidFlag = GetEaBuildedFlag(chEaIndex); + if ((EA_IS_BUILDED != chEaBuidFlag) && (EA_IS_NOT_BUILDED != chEaBuidFlag)) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + /* */ + chPaType = GetPaTypeByIndex(chEaIndex); + if ((PA_TYPE_DA != chPaType) && (PA_TYPE_EA != chPaType)) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + /* ں */ + dwEaBuildCyc = EaGetBuildCycNum(chEaIndex); + if (0U == dwEaBuildCyc) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + chDstTioc = GetEaDstTiocByIndex(chEaIndex); + chSrcTioc = GetEaSrcTiocByIndex(chEaIndex); + if (CI_SUCCESS == chPackFlag) + { + if ((chSrcTioc == chLocalId) && (chDstTioc == dstCiId)) + {/* ΪնΪĿ */ + chEaSendNum++; + ShortToChar(wEaTrainId, &dataFrame[wRtn]); + wRtn += 2u; + dataFrame[wRtn] = chEaLgcNum; + wRtn++; + for (chLgcIndex = 0u; chLgcIndex < chEaLgcNum; chLgcIndex++) + { + /* ߼ID */ + if ((0u != pEaLgcId[chLgcIndex]) && (UINT16_MAX != pEaLgcId[chLgcIndex])) + { + ShortToChar(pEaLgcId[chLgcIndex], &dataFrame[wRtn]); + wRtn += 2u; + } + else + { + chPackFlag = CI_ERROR; + break; + } + } + + dataFrame[wRtn] = chEaBuidFlag; + wRtn++; + + LongToChar(dwMidLine, &dataFrame[wRtn]); + wRtn += 4u; + + dataFrame[wRtn] = chPaType; + wRtn++; + + LongToChar(dwEaBuildCyc, &dataFrame[wRtn]); + wRtn += 4u; + } + else + { + ; + } + } + else + { + ; + } + + if (CI_ERROR == chPackFlag) + { + break; + } + else + { + ; + } + } + /* ¼Ea */ + dataFrame[wEaNumIndex] = chEaSendNum; + } + + wEaNumIndex = wRtn; + wRtn++; + chEaSendNum = 0u; + if (CI_SUCCESS == chPackFlag) + { + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + { + /* ɢгID */ + wEaTrainId = GetEvacuatingTrainIdByIndex(chEaIndex); + if ((0u == wEaTrainId) || (UINT16_MAX == wEaTrainId)) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + /* */ + chPaType = GetPaTypeByIndex(chEaIndex); + if ((PA_TYPE_DA != chPaType) && (PA_TYPE_EA != chPaType)) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + /*ں*/ + dwEaBuildCyc = EaGetBuildCycNum(chEaIndex); + if (dwEaBuildCyc == 0U) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + chDstTioc = GetEaDstTiocByIndex(chEaIndex); + chSrcTioc = GetEaSrcTiocByIndex(chEaIndex); + /* ǰͬ״̬ */ + chDstAllowed = GetEaDstAllowedByIndex(chEaIndex); + if ((EA_DST_ALLOWED_YES != chDstAllowed) && (EA_DST_ALLOWED_NO != chDstAllowed)) + { + chPackFlag = CI_ERROR; + } + else + { + ; + } + + if (CI_SUCCESS == chPackFlag) + { + if ((chDstTioc == chLocalId) && (chSrcTioc == dstCiId) && (PA_TYPE_EA == chPaType)) + {/* նΪĿΪ */ + chEaSendNum++; + ShortToChar(wEaTrainId, &dataFrame[wRtn]); + wRtn += 2u; + dataFrame[wRtn] = chDstAllowed; + wRtn++; + LongToChar(dwEaBuildCyc, &dataFrame[wRtn]); + wRtn += 4u; + } + else + { + ; + } + } + else + { + ; + } + } + } + else + { + ; + } + /* ¼Ea */ + dataFrame[wEaNumIndex] = chEaSendNum; + + if (CI_ERROR == chPackFlag) + {/* ʧܣ0 */ + wRtn = 0u; + } + else + { + ; + } + + return wRtn; +} + +/** +* @brief ȡָTIOCɢ +* @param +* @return +* @note +*/ +UINT8 GetTiocTransmitEaNum(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + UINT8 chRtn = 0u; + chIndex = GetTiocTransmitIndex(chTiocId); + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex) + { + chRtn = g_szTiocCt[chIndex].chEaTrainNum; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡָTIOCɢID +* @param +* @return IDַ +* @note +*/ +UINT16 * GetTiocTransmitEaIds(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + UINT16 * pRtn = NULL; + chIndex = GetTiocTransmitIndex(chTiocId); + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex) + { + pRtn = g_szTiocCt[chIndex].szEaTrainId; + } + else + { + ; + } + return pRtn; +} + +/** +* @brief ȡָTIOC +* @param +* @return ͵ַ +* @note +*/ +UINT8 * GetTiocTransmitPaTypes(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + UINT8 * pRtn = NULL; + chIndex = GetTiocTransmitIndex(chTiocId); + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex) + { + pRtn = g_szTiocCt[chIndex].szPaType; + } + else + { + ; + } + return pRtn; +} + +/** +* @brief ȡָTIOCɢʱ +* @param +* @return ͵ַ +* @note +*/ +UINT32 * GetTiocTransmitPaBuildCyc(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + UINT32 * pRtn = NULL; + chIndex = GetTiocTransmitIndex(chTiocId); + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex) + { + pRtn = g_szTiocCt[chIndex].dwEaBuildCyc; + } + else + { + ; + } + return pRtn; +} + +/* +* CI̬· +* ˵ targetDeviceId ĿID +* ֵ void +* +*/ +void ClearPackCiDrCmdData(UINT8 targetDeviceId) +{ + UINT8 ii = 0u; + UINT32 cycleNum = 0u; + UINT8 chNeedKeepSum = 0U; + UINT8 chStruCurSum = 0U; + + cycleNum = Get2oo2CurCycleNum();/*ȡƽ̨ں*/ + chStruCurSum = SendCiDrCmdSum; + + for (ii = 0U; ii < chStruCurSum; ii++) + { + + if (SENDCI_CMD_DATA_STRU_SUM_MAX > ii) + { + if ((cycleNum >= (SendCiDrCmdDataStru[ii].CycleNo + 1U)) && (SendCiDrCmdDataStru[ii].cTargetCiId == targetDeviceId)) + { + /*ɾ,*/ + } + else + {/*ɾ*/ + SendCiDrCmdDataStru[chNeedKeepSum++] = SendCiDrCmdDataStru[ii]; + } + } + } + /*ȫ*/ + for (ii = chNeedKeepSum; ii < chStruCurSum; ii++) + { + SendCiDrCmdDataStru[ii].cSourceCiId = 0U; + SendCiDrCmdDataStru[ii].cTargetCiId = 0U; + SendCiDrCmdDataStru[ii].cCmdType = 0U; + SendCiDrCmdDataStru[ii].cLogSecSeqDir = 0U; + SendCiDrCmdDataStru[ii].cLogSecSum = 0U; + (void)CommonMemSet(SendCiDrCmdDataStru[ii].wLogSecIdBuff, (UINT32)(MAX_ROUTE_IN_LT_NUM * sizeof(UINT16)), 0U, (UINT32)(MAX_ROUTE_IN_LT_NUM * sizeof(UINT16))); + SendCiDrCmdDataStru[ii].wTrainId = 0U; + SendCiDrCmdDataStru[ii].cTrainLocLogSecSum = 0U; + (void)CommonMemSet(SendCiDrCmdDataStru[ii].wTrainLocLogSecIdBuff, (UINT32)(SIZE_MAX_SECTION_BT_TRAIN * sizeof(UINT16)), 0U, (UINT32)(SIZE_MAX_SECTION_BT_TRAIN * sizeof(UINT16))); + SendCiDrCmdDataStru[ii].cSwitchMoveFlag = 0U; + SendCiDrCmdDataStru[ii].CycleNo = 0U; + SendCiDrCmdDataStru[ii].wRelStartSignalId = 0U; + } + SendCiDrCmdSum = chNeedKeepSum; +} + +/* +* CI͵̬·߼Ϣ +* ˵ UINT8 cmdType +* UINT8 logSecSqeDir ߼з +* UINT8 logSecSum ߼ +* UINT16 logSecIdBuff[] ߼ID +* UINT8 toCiId ͵ID +*/ +void AddCiSendToCiDrCmdLogSecInfo(UINT8 cmdType, UINT8 logSecSqeDir, UINT8 logSecSum, UINT16 logSecIdBuff[], UINT8 toCiId) +{ + UINT32 cycleNo = 0u; + UINT8 localCi = 0U; /*ID*/ + UINT8 i = 0U; + + cycleNo = Get2oo2CurCycleNum(); + localCi = GetSystemParaLocalCiId(); + + if (((CICI_DR_CMD_HALF == cmdType) || (CICI_DR_CMD_FULL == cmdType) || (CICI_DR_CMD_LOGIC == cmdType)) + && (0U != logSecSum) && (MAX_ROUTE_IN_LT_NUM > logSecSum) && (NULL != logSecIdBuff) + &&((CI_SYSTEM_DIRECTION_DOWN == logSecSqeDir) || (CI_SYSTEM_DIRECTION_UP == logSecSqeDir)) + && (0U != toCiId)) + { + if (SENDCI_CMD_DATA_STRU_SUM_MAX > SendCiDrCmdSum) + { + /*Ϣ*/ + SendCiDrCmdDataStru[SendCiDrCmdSum].cSourceCiId = localCi; + SendCiDrCmdDataStru[SendCiDrCmdSum].cTargetCiId = toCiId; + SendCiDrCmdDataStru[SendCiDrCmdSum].CycleNo = cycleNo; + SendCiDrCmdDataStru[SendCiDrCmdSum].cCmdType = cmdType; + SendCiDrCmdDataStru[SendCiDrCmdSum].cLogSecSeqDir = logSecSqeDir; + SendCiDrCmdDataStru[SendCiDrCmdSum].cLogSecSum = logSecSum; + for (i = 0u; i < logSecSum; i++) + { + SendCiDrCmdDataStru[SendCiDrCmdSum].wLogSecIdBuff[i] = logSecIdBuff[i]; + } + SendCiDrCmdSum++; + } + else + { + debug_infor_printf((const)"Error in AddCiSendToCiDrCmdLogSecInfo: SendCiDrCmdSum exceed max %d!\n", SENDCI_CMD_DATA_STRU_SUM_MAX); + } + } + else + { + debug_infor_printf((const)"Error in AddCiSendToCiDrCmdLogSecInfo: CmdType is %d, LogSecSum is %d, LogSecSqeDir is %d, TargetCiId is %d!\n", cmdType, logSecSum, logSecSqeDir, toCiId); + } +} + +/* +* CI͵̬·İؽ·Ϣ +* ˵ UINT16 trainId гID +* UINT8 trainLocLogSecSum г߼ +* UINT16 trainLocLogSecIdBuff[] г߼ID +* UINT8 switchMoveFlag ؽ·ɶ־ +* UINT16 startSignalId ׸߼ιʼźŻID +*/ +void AddCiSendToCiDrCmdHalfInfo(UINT16 trainId, UINT8 trainLocLogSecSum, UINT16 trainLocLogSecIdBuff[], UINT8 switchMoveFlag, UINT16 startSignalId) +{ + UINT8 i = 0U; + + if ((SIZE_MAX_SECTION_BT_TRAIN > trainLocLogSecSum) && (NULL != trainLocLogSecIdBuff) + && ((ROUTE_HALF_SWITCH_MOVE_VALID == switchMoveFlag) || (ROUTE_HALF_SWITCH_MOVE_INVALID == switchMoveFlag)) + && (SIGNAL_SUM_MAX > startSignalId)) + { + if (SENDCI_CMD_DATA_STRU_SUM_MAX > SendCiDrCmdSum) + { + /*Ϣ*/ + SendCiDrCmdDataStru[SendCiDrCmdSum].wTrainId = trainId; + SendCiDrCmdDataStru[SendCiDrCmdSum].cSwitchMoveFlag = switchMoveFlag; + SendCiDrCmdDataStru[SendCiDrCmdSum].cTrainLocLogSecSum = trainLocLogSecSum; + for (i = 0u; i < trainLocLogSecSum; i++) + { + SendCiDrCmdDataStru[SendCiDrCmdSum].wTrainLocLogSecIdBuff[i] = trainLocLogSecIdBuff[i]; + } + SendCiDrCmdDataStru[SendCiDrCmdSum].wRelStartSignalId = startSignalId; + } + else + { + debug_infor_printf((const)"Error in AddCiSendToCiDrCmdHalfInfo: SendCiDrCmdSum exceed max %d!\n", SENDCI_CMD_DATA_STRU_SUM_MAX); + } + } + else + { + debug_infor_printf((const)"Error in AddCiSendToCiDrCmdHalfInfo: TrainLocLogSecSum is %d, SwitchMoveFlag is %d!\n", trainLocLogSecSum, switchMoveFlag); + } +} + +/* +* ȡCICI̬·ṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetCiRecvCiDrCmdStruCurSum(void) +{ + return RecvCiDrCmdSum; +} + +/* +* ȡCICI̬·ṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +ToCiDrCmdDataStruct* GetCiRecvCiDrCmdDataStruct(void) +{ + return RecvCiDrCmdDataStru; +} + +/* +* CIյ̬· +* ˵ +* ֵ +*/ +void ClearCiRevCiDrCmdData(void) +{ + UINT8 ii = 0U; + UINT32 dwCycleNum = 0U; + UINT8 cStruCurSum = 0U; + UINT8 cNeedKeepSum = 0U; + + dwCycleNum = Get2oo2CurCycleNum(); + cStruCurSum = RecvCiDrCmdSum; + + for (ii = 0U; ii < cStruCurSum; ii++) + { + if (dwCycleNum >= (RecvCiDrCmdDataStru[ii].CycleNo + 1U)) + { + /*洢ﵽ2ڣɾ,*/ + } + else + { + RecvCiDrCmdDataStru[cNeedKeepSum] = RecvCiDrCmdDataStru[ii]; /*ɾ*/ + cNeedKeepSum++; + } + } + + /*ȫ*/ + for (ii = cNeedKeepSum; ii < cStruCurSum; ii++) + { + RecvCiDrCmdDataStru[ii].cSourceCiId = 0U; + RecvCiDrCmdDataStru[ii].cTargetCiId = 0U; + RecvCiDrCmdDataStru[ii].cCmdType = 0U; + RecvCiDrCmdDataStru[ii].cLogSecSeqDir = 0U; + RecvCiDrCmdDataStru[ii].cLogSecSum = 0U; + (void)CommonMemSet(RecvCiDrCmdDataStru[ii].wLogSecIdBuff, (UINT32)(MAX_ROUTE_IN_LT_NUM * sizeof(UINT16)), 0U, (UINT32)(MAX_ROUTE_IN_LT_NUM * sizeof(UINT16))); + RecvCiDrCmdDataStru[ii].wTrainId = 0U; + RecvCiDrCmdDataStru[ii].cTrainLocLogSecSum = 0U; + (void)CommonMemSet(RecvCiDrCmdDataStru[ii].wTrainLocLogSecIdBuff, (UINT32)(SIZE_MAX_SECTION_BT_TRAIN * sizeof(UINT16)), 0U, (UINT32)(SIZE_MAX_SECTION_BT_TRAIN * sizeof(UINT16))); + RecvCiDrCmdDataStru[ii].cSwitchMoveFlag = 0U; + RecvCiDrCmdDataStru[ii].CycleNo = 0U; + RecvCiDrCmdDataStru[ii].wRelStartSignalId = 0U; + } + + RecvCiDrCmdSum = cNeedKeepSum; +} + +/* +* УCI䵥֡ +* ˵ UINT8* dataBuf Ϣ +* UINT16 dataLength ݳ +* UINT8 *errNo Уʧܹ +* ֵ CI_ERROR:Уʧ +* CI_SUCCESS:Уɹ +*/ +UINT8 ParseCiToCiDataCheck(UINT8* dataBuf, UINT16 dataLength,UINT8 *errNo) +{ + UINT8 reVal = CI_ERROR; + UINT8 errorNo_length = 0U; + UINT8 errorNO_Type = 0U; + UINT16 ii = 0U; /**/ + + /*η*/ + if ((dataBuf != NULL) && (dataLength > 0U)) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + + /*汾ţIDУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiIDAndVer(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 1U; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCi2CiDataLenValid(dataBuf, dataLength, &errorNo_length); + if (CI_ERROR == reVal) + { + debug_infor_printf((const)"CheckCi2CiDataLenValid error:%d\n", errorNo_length); + *errNo = 2U; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiSwitchData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 3U; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiPhySecData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 4U; + } + } + + /*߼У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiLogSecData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 5U; + } + } + + /*źŻУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiSignalData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 6U; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiPsdData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 7U; + } + } + + /*ͣťУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiEsbData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 8U; + } + } + + /*·У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiRouteData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 9U; + } + } + + /*ͬ״̬У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiCommonPhyLockData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 10U; + } + } + + /*SPKSУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiSpksData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 11U; + } + } + + /*̵У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiVirRelayData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 12U; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiFloodGateData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 13U; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiOverlapData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 14U; + } + } + + /*Զͨ·У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiAutoRouteData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 15U; + } + } + + /*߼״̬У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiLogicLockData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 16U; + } + } + + /*ֽУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiCfpData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 17U; + } + } + + /*ѩУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiAreaSnowData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 18U; + } + } + + /*·ȥ߼У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiLeaveLogSecData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 23U; + } + } + + /*Ҫ״̬Ľ·У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiNeedCheckSwRouteData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 24U; + } + } + + /*Ҫ״̬ıУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiNeedCheckSwOlpData(dataBuf, &ii); + if (CI_SUCCESS == reVal) + { + /**/ + } + else + { + *errNo = 25U; + } + } + else + { + /**/ + } + + /*·/ηյķУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiProSwPLockData(dataBuf, &ii); + if (CI_SUCCESS == reVal) + { + /**/ + } + else + { + *errNo = 26U; + } + } + else + { + /**/ + } + + /*ɢУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiEaData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 19U; + } + } + + /*У*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiCommandData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 20U; + } + } + /*̬·ϢУ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckCiToCiDrCmdData(dataBuf, &ii); + if (CI_ERROR == reVal) + { + *errNo = 21U; + } + } + + return reVal; +} + + +/* +* УCI汾ϢID +* ˵ const UINT8* dataBuf Ϣ +* UINT8* Index (Σ) +* ֵ CI_ERROR:Уʧ +* CI_SUCCESS:Уɹ +*/ +UINT8 CheckCiIDAndVer(const UINT8* dataBuf, UINT8* Index) +{ + UINT8 reVal = CI_ERROR; + UINT8 ii = 0u; + UINT16 sourceId = 0u; /*ԴID*/ + UINT16 targetId = 0u; /*ĿID*/ + UINT32 sourceCurCycleNo = 0u;/*ǰϢԴں*/ + UINT16 ciciVer = 0u;/*ci-ciӿڰ汾*/ + UINT32 dwDataVerFromOtherCi = 0U; + UINT16 wCiDevName = 0U;/*ڽܴ豸͵ID*/ + UINT32 dwDataVerFromEmap = 0U; + UINT8 localCiId = 0u; /*ID*/ + UINT16 MaskTotalLen = 0u; /*λܳ*/ + UINT8 devSum = 0u; /*豸*/ + UINT8* deviceIdBuf = NULL; /*豸ID*/ + UINT8 deviceFlag = 0u; + UINT8 yy = 0u; + localCiId = GetSystemParaLocalCiId(); + + if ((dataBuf != NULL) && (Index != NULL)) + { + ii = *Index; + + sourceId = ShortFromChar(&dataBuf[ii]); /*ȡݰԴ豸ID*/ + ii += 2u; + sourceCurCycleNo = LongFromChar(&dataBuf[ii]); /*ȡݰԴں*/ + ii += 4u; + targetId = ShortFromChar(&dataBuf[ii]); /*ȡݰĿ豸ID*/ + ii += 2u; + + ciciVer = ShortFromChar(&dataBuf[ii]);/*汾ţ2ֽ*/ + ii += 2u; + + if ((UINT16)CICI_VERSION == ciciVer) + { + reVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"CICI_VERSION ERROR,local:%d other:%d\n", CICI_VERSION, ciciVer); + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + dwDataVerFromOtherCi = LongFromChar(&dataBuf[ii]); /*УϢ*/ + ii += 4U; + wCiDevName = (CI_SYSTEM_TYPE_CI) * 256U + sourceId; + dwDataVerFromEmap = GetCiTranCiDataCheckVer(localCiId, wCiDevName); /*ȡϵͳݰ汾*/ + if (dwDataVerFromOtherCi != dwDataVerFromEmap) + { + reVal = CI_ERROR; + SetCiSendCmdBackInfoData(CI_BACK_DATA_VER_CHECK_FAIL, CI_SYSTEM_TYPE_CI, sourceId, 0U, 0U); + } + } + + if (CI_SUCCESS == reVal) + { + MaskTotalLen = ShortFromChar(&dataBuf[ii]); /*ȡվϢܳ*/ + ii += 2u; + + if (localCiId != targetId) + { + /*ĿDZ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + } + + if (CI_SUCCESS == reVal) + { + /*жԴ豸ǷָCI*/ + devSum = GetCiTransmitSpecifySysDevSum(Get2oo2SheBeiType()); /*ȡͨ豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(Get2oo2SheBeiType()); /*ȡͨ豸ID*/ + + if ((0u < devSum) && (NULL != deviceIdBuf)) + { + for (yy = 0u; yy < devSum; yy++) + { + if (deviceIdBuf[yy] == sourceId) + { + deviceFlag = 1u; + break; + } + } + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + if (0u == deviceFlag) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + } + } + + *Index = ii; /*ضӦ*/ + } + else + { + ; /**/ + } + + return reVal; +} + +/* +* УCI͵Ĵĵ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiSwitchData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 cSwitchSum = 0U; /**/ + UINT16 wSwitchId = 0U; /*ID*/ + UINT8 cSwitchYDLockState = 0U; /*״̬*/ + UINT8 cSwitchLockState = 0U; /*״̬*/ + UINT8 cSwitchFLockState = 0U; /*״̬*/ + UINT8 cSwitchCurPos = 0U; /*ǰλ*/ + UINT8 cSingleSwitchCurPos = 0U; /*ǰλ*/ + UINT8 cSwitchBelongCiId = 0U; + UINT8 cLocalCiId = 0U; + UINT8 switchIsThisLineFlag = 0U; /*ǷΪ·*/ + UINT8 ConnetSwitchDsState = 0U; /*ߵ״̬*/ + UINT8 ConnetSwitchByPassState = 0U; /*ߵ·״̬*/ + UINT8 chSwitchJichaState = 0U;/*״̬*/ + UINT16 wUsingBelongOverlapId = 0U; /*ID*/ + UINT8 cSwitchUsingState = 0U; /*״̬*/ + + cLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + cSwitchSum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (SWITCH_SUM_MAX > cSwitchSum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < cSwitchSum; jj++) + { + /*УID*/ + wSwitchId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if ((0U < wSwitchId) && (SWITCH_SUM_MAX > wSwitchId)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchId Is 0 Or Exceed Max %d\n", wSwitchId, SWITCH_SUM_MAX); + retVal = CI_ERROR; + } + + cSwitchBelongCiId = GetSwitchBelongCiId(wSwitchId); + if (cSwitchBelongCiId == cLocalCiId) + { + ii += CICI_ONE_SWITCH_LEN - 2U; /*ڱĵ״̬ϢУ*/ + } + else + { + /*У״̬*/ + if (CI_SUCCESS == retVal) + { + cSwitchYDLockState = dataBuf[ii]; + ii++; + if ((SWITCH_LOCK_YINZONG_NO == cSwitchYDLockState) || (SWITCH_LOCK_YINZONG_YES == cSwitchYDLockState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchYDLockState Is %d\n", wSwitchId, cSwitchYDLockState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*У״̬*/ + if (CI_SUCCESS == retVal) + { + cSwitchLockState = dataBuf[ii]; + ii++; + if ((SWITCH_LOCK_STATUS_NO == cSwitchLockState) || (SWITCH_LOCK_STATUS_DANSUO == cSwitchLockState) + || (SWITCH_LOCK_STATUS_PROTECT == cSwitchLockState) || (SWITCH_LOCK_STATUS_DAP == cSwitchLockState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchLockState Is %d\n", wSwitchId, cSwitchLockState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*У״̬*/ + if (CI_SUCCESS == retVal) + { + cSwitchFLockState = dataBuf[ii]; + ii++; + if ((SWITCH_LOCK_FENGSUO_NO == cSwitchFLockState) || (SWITCH_LOCK_FENGSUO_YES == cSwitchFLockState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchFLockState Is %d\n", wSwitchId, cSwitchFLockState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уǰλ*/ + if (CI_SUCCESS == retVal) + { + cSwitchCurPos = dataBuf[ii]; + ii++; + if ((SWITCH_POSITION_DINGWEI == cSwitchCurPos) || (SWITCH_POSITION_FANWEI == cSwitchCurPos) || (SWITCH_POSITION_SIKAI == cSwitchCurPos) + || (SWITCH_POSITION_MOVE == cSwitchCurPos) || (SWITCH_POSITION_JICHA == cSwitchCurPos)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchCurPos Is %d\n", wSwitchId, cSwitchCurPos); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*У鵥ǰλ*/ + if (CI_SUCCESS == retVal) + { + cSingleSwitchCurPos = dataBuf[ii]; + ii++; + if ((SWITCH_POSITION_DINGWEI == cSingleSwitchCurPos) || (SWITCH_POSITION_FANWEI == cSingleSwitchCurPos) || (SWITCH_POSITION_SIKAI == cSingleSwitchCurPos) + || (SWITCH_POSITION_MOVE == cSingleSwitchCurPos) || (SWITCH_POSITION_JICHA == cSingleSwitchCurPos)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SingleSwitchCurPos Is %d\n", wSwitchId, cSingleSwitchCurPos); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уߵ״̬*/ + if (CI_SUCCESS == retVal) + { + switchIsThisLineFlag = GetSwitchIsThisLineState(wSwitchId); + if (DEV_IS_THIS_LINE_NO == switchIsThisLineFlag) + { + ConnetSwitchDsState = dataBuf[ii]; + ii++; + if ((CONNECT_SWITCH_DANSUO_YES == ConnetSwitchDsState) || (CONNECT_SWITCH_DANSUO_NO == ConnetSwitchDsState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: ConnetSwitchDsState Is %d\n", wSwitchId, ConnetSwitchDsState); + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + ConnetSwitchByPassState = dataBuf[ii]; + ii++; + + if ((SWITCH_BYPASS_NO == ConnetSwitchByPassState) || (SWITCH_BYPASS_YES == ConnetSwitchByPassState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: ConnetSwitchByPassState Is %d\n", wSwitchId, ConnetSwitchByPassState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + } + else + { + ii += 2U; /*ߵĵ˶ֽ*/ + } + } + else + { + /*Уʧ*/ + } + + /*У鵥״̬*/ + if (CI_SUCCESS == retVal) + { + chSwitchJichaState = dataBuf[ii]; + ii++; + if ((SWITCH_POSITION_DYNAMIC_JICHA == chSwitchJichaState) || (SWITCH_POSITION_SUDDEN_JICHA == chSwitchJichaState) || (0U == chSwitchJichaState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: chSwitchJichaState Is %d\n", wSwitchId, chSwitchJichaState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*У*/ + if (CI_SUCCESS == retVal) + { + wUsingBelongOverlapId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (OVERLAP_SUM_MAX > wUsingBelongOverlapId) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: UsingBelongOverlapId Is %d\n", wSwitchId, wUsingBelongOverlapId); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*У״̬*/ + if (CI_SUCCESS == retVal) + { + cSwitchUsingState = dataBuf[ii]; + ii++; + if ((SWITCH_USING_NO == cSwitchUsingState) || (SWITCH_USING_YES == cSwitchUsingState) + || (SWITCH_USING_APPLY == cSwitchUsingState) || (SWITCH_USING_CANCEL == cSwitchUsingState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSwitchData SwitchId[%d] Is Error: SwitchUsingState Is %d\n", wSwitchId, cSwitchUsingState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /*У*/ + } + } + } + else + { + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiSwitchData Is Error: SwitchSum %d Exceed Max %d\n", cSwitchSum, SWITCH_SUM_MAX); + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵Ĵ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiPhySecData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 wPhySecSum = 0U;/*Ŀ*/ + UINT16 wPhySecId = 0U;/*Id*/ + UINT8 chPhySecBelongCiId = 0U;/**/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chPhySecOccupyState = 0U;/*ռ״̬*/ + UINT8 chPhySecUtOrCtState = 0U;/*UTCTռ״̬*/ + UINT8 chPhySecStopSteadyFlag = 0U;/*ͣϢ*/ + UINT8 chPhySecUsingState = 0U;/*״̬*/ + UINT16 wPhySecUseBelongRouteId = 0U;/*·ID*/ + UINT8 chPhySecFLockState = 0U;/*η״̬*/ + UINT8 chPhySecArbState = 0U;/*Arb״̬*/ + UINT8 chPhySecCurAndMergeState = 0U;/*ռ״̬*/ + UINT8 chPhySecJumpLockState = 0U;/*Ծ״̬*/ + UINT8 chPhySecFLockType = 0U;/*η*/ + UINT8 chPhySecPreResetState = 0U;/*Ԥλ״̬*/ + UINT16 wPhySecErrUnlockTime = 0U;/*ʽ⵹ʱ*/ + UINT8 chPhySecAreaUrgentState = 0U;/*ƶ״̬*/ + UINT8 chPhyAblTrainFlag = 0U; /*ABLռñ־*/ + UINT8 chPhyUtOccupyFlag = 0U; /*λռñ־*/ + UINT8 cPhySecInHumidRailFlag = PHYSEC_IN_HUMID_RAIL_NO; + UINT16 wProSwSecUseBelRouteId = 0U;/*·ID*/ + + chLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + wPhySecSum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (PHYSICAL_SECTION_SUM_MAX > wPhySecSum) + { + for (jj = 0U; jj < wPhySecSum; jj++) + { + /*ID*/ + wPhySecId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId)) + { + chPhySecBelongCiId = GetPhySecBelongCiId(wPhySecId); + if (chLocalCiId == chPhySecBelongCiId) + { + ii += CICI_ONE_PHYSEC_LEN - 2U;/*ڱ״̬Ϣ*/ + } + else + { + /*βɼռ״̬*/ + chPhySecOccupyState = dataBuf[ii]; + ii++; + if ((SECTION_OCCUPY_NO == chPhySecOccupyState) || (SECTION_OCCUPY_YES == chPhySecOccupyState)) + { + /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecCurOccupyState Is %d\n", wPhySecId, chPhySecOccupyState); + } + + if (CI_SUCCESS == retVal) + { + /*ںϺռ״̬*/ + chPhySecOccupyState = dataBuf[ii++]; + if ((SECTION_OCCUPY_NO == chPhySecOccupyState) || (SECTION_OCCUPY_YES == chPhySecOccupyState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecMerOccupyState Is %d\n", wPhySecId, chPhySecOccupyState); + } + } + else + { + /**/ + } + + if (CI_SUCCESS == retVal) + { + /*εǰCTUTռ״̬*/ + chPhySecUtOrCtState = dataBuf[ii++]; + if ((LOGICSECTION_OCCUPY_UT == chPhySecUtOrCtState) || (LOGICSECTION_OCCUPY_CT == chPhySecUtOrCtState) + || (LOGICSECTION_OCCUPY_NO == chPhySecUtOrCtState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecOccupyState Is %d\n", wPhySecId, chPhySecOccupyState); + } + } + if (CI_SUCCESS == retVal) + { + /*ͣϢ*/ + chPhySecStopSteadyFlag = dataBuf[ii++]; + if ((PHYSICAL_SECTION_STOPSTEADY_NO == chPhySecStopSteadyFlag) || (PHYSICAL_SECTION_STOPSTEADY_YES == chPhySecStopSteadyFlag)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecStopSteadyFlag Is %d\n", wPhySecId, chPhySecStopSteadyFlag); + } + } + if (CI_SUCCESS == retVal) + { + /*״̬*/ + chPhySecUsingState = dataBuf[ii++]; + if ((PHYSICAL_SECTION_USING_NO == chPhySecUsingState) || (PHYSICAL_SECTION_USING_YES == chPhySecUsingState) + || (PHYSICAL_SECTION_USING_APPLY == chPhySecUsingState) || (PHYSICAL_SECTION_USING_CANCEL == chPhySecUsingState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecUsingState Is %d\n", wPhySecId, chPhySecUsingState); + } + } + if (CI_SUCCESS == retVal) + { + /*·ID*/ + wPhySecUseBelongRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (ROUTE_SUM_MAX > wPhySecUseBelongRouteId) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: wPhySecUseBelongRouteId Is %d\n", wPhySecId, wPhySecUseBelongRouteId); + } + } + if (CI_SUCCESS == retVal) + { + /*·ID*/ + wProSwSecUseBelRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (ROUTE_SUM_MAX > wProSwSecUseBelRouteId) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: wProSwSecUseBelRouteId Is %d\n", wPhySecId, wProSwSecUseBelRouteId); + } + } + if (CI_SUCCESS == retVal) + { + /*η״̬*/ + chPhySecFLockState = dataBuf[ii++]; + if ((PHYSICAL_SECTION_FLOCK_NO == chPhySecFLockState) || (PHYSICAL_SECTION_FLOCK_YES == chPhySecFLockState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecFLockState Is %d\n", wPhySecId, chPhySecFLockState); + } + } + if (CI_SUCCESS == retVal) + { + /*Arb״̬*/ + chPhySecArbState = dataBuf[ii++]; + if ((AXIS_SECTION_ARB_NO == chPhySecArbState) || (AXIS_SECTION_ARB_YES == chPhySecArbState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecArbState Is %d\n", wPhySecId, chPhySecArbState); + } + } + if (CI_SUCCESS == retVal) + { + /*ռ״̬*/ + chPhySecCurAndMergeState = dataBuf[ii++]; + if ((SECTION_OCCUPY_NO == chPhySecCurAndMergeState) || (SECTION_OCCUPY_YES == chPhySecCurAndMergeState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecCurAndMergeState Is %d\n", wPhySecId, chPhySecCurAndMergeState); + } + } + if (CI_SUCCESS == retVal) + { + /*Ծ״̬*/ + chPhySecJumpLockState = dataBuf[ii++]; + if ((PHYSICAL_SECTION_JUMP_LOCK_YES == chPhySecJumpLockState) || (PHYSICAL_SECTION_JUMP_LOCK_NO == chPhySecJumpLockState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecJumpLockState Is %d\n", wPhySecId, chPhySecJumpLockState); + } + } + if (CI_SUCCESS == retVal) + { + /*η*/ + chPhySecFLockType = dataBuf[ii++]; + if ((PHY_SEC_FLOCK_TYPE_NONE == chPhySecFLockType) || (PHY_SEC_FLOCK_TYPE_SPKSCMD == chPhySecFLockType) + || (PHY_SEC_FLOCK_TYPE_SPKS == chPhySecFLockType) || (PHY_SEC_FLOCK_TYPE_CMD == chPhySecFLockType)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecFLockType Is %d\n", wPhySecId, chPhySecFLockType); + } + } + if (CI_SUCCESS == retVal) + { + /*Ԥλ״̬*/ + chPhySecPreResetState = dataBuf[ii++]; + if ((PHYSICAL_SECTION_PRE_RESET_YES == chPhySecPreResetState) || (PHYSICAL_SECTION_PRE_RESET_NO == chPhySecPreResetState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecPreResetState Is %d\n", wPhySecId, chPhySecPreResetState); + } + } + if (CI_SUCCESS == retVal) + { + wPhySecErrUnlockTime = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (UINT16_MAX > wPhySecErrUnlockTime) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: wPhySecErrUnlockTime Is %d\n", wPhySecId, wPhySecErrUnlockTime); + } + } + + if (CI_SUCCESS == retVal) + { + /*ƶ״̬*/ + chPhySecAreaUrgentState = dataBuf[ii++]; + if ((PHYSEC_AREA_URGENT_NO == chPhySecAreaUrgentState) || (PHYSEC_AREA_URGENT_YES == chPhySecAreaUrgentState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhySecAreaUrgentState Is %d\n", wPhySecId, chPhySecAreaUrgentState); + } + } + + if (CI_SUCCESS == retVal) + { + /*ABLռ״̬*/ + chPhyAblTrainFlag = dataBuf[ii++]; + if ((PHYSICAL_SECTION_ABLOCCUPY_NO == chPhyAblTrainFlag) || (PHYSICAL_SECTION_ABLOCCUPY_YES == chPhyAblTrainFlag) || (PHYSICAL_SECTION_ABLOCCUPY_DEFAULT == chPhyAblTrainFlag)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhyAblTrainFlag Is %d\n", wPhySecId, chPhyAblTrainFlag); + } + } + + if (CI_SUCCESS == retVal) + { + /*λռռ״̬*/ + chPhyUtOccupyFlag = dataBuf[ii++]; + if ((PHYSICAL_AXIS_UT_YES == chPhyUtOccupyFlag) || (PHYSICAL_AXIS_UT_NO == chPhyUtOccupyFlag)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: chPhyUtOccupyFlag Is %d\n", wPhySecId, chPhyUtOccupyFlag); + } + } + + if (CI_SUCCESS == retVal) + { + /*ʪ־*/ + cPhySecInHumidRailFlag = dataBuf[ii++]; + if ((PHYSEC_IN_HUMID_RAIL_YES == cPhySecInHumidRailFlag) || (PHYSEC_IN_HUMID_RAIL_NO == cPhySecInHumidRailFlag)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData wPhySecId %d Is Error: cPhySecInHumidRailFlag Is %d\n", wPhySecId, cPhySecInHumidRailFlag); + } + } + else + { + /**/ + } + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiPhySecData Is Error: wPhySecId Is %d\n", wPhySecId); + } + if (CI_ERROR == retVal) + { + break; + } + } + + } + else + { + retVal = CI_ERROR; + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiPhySecData Is Error: wPhySecSum Is %d\n", wPhySecSum); + } + *index = ii; + } + else + { + retVal = CI_ERROR; /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵Ĵ߼ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiLogSecData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 kk = 0U; + UINT16 wLogSecSum = 0U;/*߼Ŀ*/ + UINT16 wLogSecId = 0U;/*߼Id*/ + UINT8 chLogSecBelongCiId = 0U;/*߼*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chLogSecCurOccupyState = 0U;/*߼ռ״̬*/ + UINT8 chLogSecLSXSState = 0U;/*߼ʱ״̬*/ + UINT8 chLogSecJumpLockState = 0U;/** ߼Ծ״̬ */ + UINT8 chLogSecArbState = 0U;/* ߼ARB״̬ */ + UINT8 chLogSecResTrainSum = 0U;/*߼Դг*/ + UINT16 wLogSecResTrainId = 0U;/*߼ԴгID*/ + UINT8 chLogSecTrainUseState = 0U;/*߼Դ״̬*/ + UINT8 chLogSecSpksFLockState = 0U;/*߼SPKS״̬*/ + UINT8 chLogSecProResUseState = 0U;/*߼αԴ״̬*/ + UINT8 chLogSecAblUseFlag = 0U; + UINT8 chLogSecXinsuSpeed = 0U; + + chLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + wLogSecSum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (LOGIC_SECTION_SUM_MAX > wLogSecSum) + { + for (jj = 0U; jj < wLogSecSum; jj++) + { + /*߼ID*/ + wLogSecId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if ((0U < wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId)) + { + chLogSecBelongCiId = GetLogSecBelongCiId(wLogSecId); + if (chLocalCiId == chLogSecBelongCiId) + { + ii += CICI_ONE_LOGSEC_LEN - 2U;/*ڱ߼״̬Ϣ*/ + ii = ii + 1U + (dataBuf[ii] * 3U);/* ߼ԴĿ1B + Ŀ*3B */ + } + else + { + /*߼ռ״̬*/ + chLogSecCurOccupyState = dataBuf[ii++]; + if ((LOGICSECTION_OCCUPY_UT == chLogSecCurOccupyState) || (LOGICSECTION_OCCUPY_CT == chLogSecCurOccupyState) + || (LOGICSECTION_OCCUPY_NO == chLogSecCurOccupyState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecCurOccupyState Is %d\n", wLogSecId, chLogSecCurOccupyState); + } + if (CI_SUCCESS == retVal) + { + /*߼ʱ״̬*/ + chLogSecLSXSState = dataBuf[ii++]; + if ((LOGSEC_LSXS_SET_STATE_NO == chLogSecLSXSState) || (LOGSEC_LSXS_SET_STATE_YES == chLogSecLSXSState) + || (LOGSEC_LSXS_SET_STATE_INVALID == chLogSecLSXSState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecLSXSState Is %d\n", wLogSecId, chLogSecLSXSState); + } + } + if (CI_SUCCESS == retVal) + { + /* ߼Ծ״̬ */ + chLogSecJumpLockState = dataBuf[ii++]; + if ((LOGIC_SECTION_JUMP_LOCK_NO == chLogSecJumpLockState) || (LOGIC_SECTION_JUMP_LOCK_YES == chLogSecJumpLockState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecJumpLockState Is %d\n", wLogSecId, chLogSecJumpLockState); + } + } + if (CI_SUCCESS == retVal) + { + /* ߼ARB״̬ */ + chLogSecArbState = dataBuf[ii++]; + if ((LGC_SECTION_ARB_NO == chLogSecArbState) || (LGC_SECTION_ARB_YES == chLogSecArbState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecArbState Is %d\n", wLogSecId, chLogSecArbState); + } + } + if (CI_SUCCESS == retVal) + { + /* ߼SPKS״̬ */ + chLogSecSpksFLockState = dataBuf[ii++]; + if ((LOGIC_SECTION_SPKS_FLOCK_NO == chLogSecSpksFLockState) || (LOGIC_SECTION_SPKS_FLOCK_YES == chLogSecSpksFLockState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecSpksFLockState Is %d\n", wLogSecId, chLogSecSpksFLockState); + } + } + if (CI_SUCCESS == retVal) + { + /* ߼αԴ״̬ */ + chLogSecProResUseState = dataBuf[ii++]; + if ((LOGIC_SECTION_PRO_RES_UNUSABLE == chLogSecProResUseState) || (LOGIC_SECTION_PRO_RES_USABLE == chLogSecProResUseState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecProResUseState Is %d\n", wLogSecId, chLogSecProResUseState); + } + } + + if (CI_SUCCESS == retVal) + { + /* ߼ABLӽԴñ־ */ + chLogSecAblUseFlag = dataBuf[ii++]; + if ((LOGIC_ABLNEAR_USE_FLAG_YES == chLogSecAblUseFlag) || (LOGIC_ABLNEAR_USE_FLAG_NO == chLogSecAblUseFlag)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecAblUseFlag Is %d\n", wLogSecId, chLogSecAblUseFlag); + } + } + + if (CI_SUCCESS == retVal) + { + /* ߼ʱٶֵ */ + chLogSecXinsuSpeed = dataBuf[ii++]; + if (UINT8_MAX > chLogSecXinsuSpeed) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecXinsuSpeed Is %d\n", wLogSecId, chLogSecXinsuSpeed); + } + } + + if (CI_SUCCESS == retVal) + { + /* ߼Դг */ + chLogSecResTrainSum = dataBuf[ii++]; + if (LOGIC_SECTION_RES_SUM_MAX >= chLogSecResTrainSum) + { + for (kk = 0U; kk < chLogSecResTrainSum; kk++) + { + if (CI_SUCCESS == retVal) + { + /*߼ԴгID*/ + wLogSecResTrainId = ShortFromChar(&dataBuf[ii]);/*߼ԴгID*/ + ii += 2U; + if (((0U < wLogSecResTrainId) && (254U >= wLogSecResTrainId)) + || ((0X1401U <= wLogSecResTrainId) && (0X14FEU >= wLogSecResTrainId))) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: wLogSecResTrainId Is %d\n", wLogSecId, wLogSecResTrainId); + } + } + if (CI_SUCCESS == retVal) + { + /*߼Դ״̬*/ + chLogSecTrainUseState = dataBuf[ii++];/*߼Դ״̬*/ + if ((LOGIC_SECTION_RES_USABLE == chLogSecTrainUseState) || (LOGIC_SECTION_RES_UNUSABLE == chLogSecTrainUseState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecTrainUseState Is %d\n", wLogSecId, chLogSecTrainUseState); + } + } + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData wLogSecId %d Is Error: chLogSecResTrainSum Is %d\n", wLogSecId, chLogSecResTrainSum); + } + } + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiLogSecData Is Error: wLogSecId Is %d\n", wLogSecId); + } + if (CI_ERROR == retVal) + { + break; + } + } + + } + else + { + retVal = CI_ERROR; + /*߼ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiLogSecData Is Error: wLogSecSum Is %d\n", wLogSecSum); + } + *index = ii; + } + else + { + retVal = CI_ERROR; /*Уʧܣʧ*/ + } + + + return retVal; +} + +/* +* УCI͵ĴźŻ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiSignalData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 wSignalSum = 0U;/*źŻĿ*/ + UINT16 wSignalId = 0U;/*źŻId*/ + UINT8 chSignalBelongCiId = 0U;/*źŻ*/ + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chSignalFLockState = 0U;/*źŻ״̬*/ + UINT8 chSignalLigExtinctState = 0U;/*źŻ״̬״̬*/ + UINT8 chSignalCurColor = 0U;/*źŻǰʾɫ״̬*/ + UINT8 chSignalLSXSSetFlag = 0U;/*źŻʱ״̬*/ + UINT8 chSignalDetainFlag = 0U;/*źŻ۳״̬*/ + UINT8 chSignalRelayDetainFlag = 0U;/*źŻӲ߿۳״̬*/ + UINT8 chSignalMaintainState = 0U;/*źŻά޵״̬*/ + UINT8 chSignalVBLNearFlag = 0U; /*źŻVBLгӽ־*/ + UINT8 chCheckSigCurColorResult = CI_ERROR;/*źŻǰʾɫϷԼ*/ + + chLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + wSignalSum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (SIGNAL_SUM_MAX > wSignalSum) + { + for (jj = 0U; jj < wSignalSum; jj++) + { + /*źŻID*/ + wSignalId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if ((0U < wSignalId) && (SIGNAL_SUM_MAX > wSignalId)) + { + chSignalBelongCiId = GetSignalBelongCiId(wSignalId); + if (chLocalCiId == chSignalBelongCiId) + { + ii += CICI_ONE_SIGNAL_LEN - 2U;/*ڱźŻ״̬Ϣ*/ + } + else + { + /*źŻ״̬*/ + chSignalFLockState = dataBuf[ii++]; + if ((SIGNAL_FENGSUO_NO == chSignalFLockState) || (SIGNAL_FENGSUO_YES == chSignalFLockState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalFLockState Is %d\n", wSignalId, chSignalFLockState); + } + if (CI_SUCCESS == retVal) + { + /*źŻ״̬״̬*/ + chSignalLigExtinctState = dataBuf[ii++]; + if ((SIGNAL_LIGHT_EXTICT_STATE_NO == chSignalLigExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_YES == chSignalLigExtinctState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalLigExtinctState Is %d\n", wSignalId, chSignalLigExtinctState); + } + } + if (CI_SUCCESS == retVal) + { + /*źŻǰʾɫ״̬*/ + chSignalCurColor = dataBuf[ii++]; + chCheckSigCurColorResult = CheckSignalCurColor(chSignalCurColor); + if (CI_SUCCESS == chCheckSigCurColorResult) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalCurColor Is %d\n", wSignalId, chSignalCurColor); + } + } + if (CI_SUCCESS == retVal) + { + /*źŻʱ״̬*/ + chSignalLSXSSetFlag = dataBuf[ii++]; + if ((SIGNAL_LINSHIXIANSUSET_STATE_NO == chSignalLSXSSetFlag) || (SIGNAL_LINSHIXIANSUSET_STATE_YES == chSignalLSXSSetFlag) + || (SIGNAL_LINSHIXIANSUSET_STATE_INVALID == chSignalLSXSSetFlag)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalLSXSSetFlag Is %d\n", wSignalId, chSignalLSXSSetFlag); + } + } + if (CI_SUCCESS == retVal) + { + /*źŻ۳״̬*/ + chSignalDetainFlag = dataBuf[ii++]; + if ((SIGNAL_DETAIN_YES == chSignalDetainFlag) || (SIGNAL_DETAIN_XIANDI_ATSAUTO == chSignalDetainFlag) || (SIGNAL_DETAIN_NO == chSignalDetainFlag) + || (SIGNAL_DETAIN_XIANDI == chSignalDetainFlag) || (SIGNAL_DETAIN_ATS == chSignalDetainFlag) || (SIGNAL_DETAIN_ATS_AUTO == chSignalDetainFlag) + || (SIGNAL_RELAY_DETAIN_YES == chSignalDetainFlag)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalDetainFlag Is %d\n", wSignalId, chSignalDetainFlag); + } + } + if (CI_SUCCESS == retVal) + { + /*źŻӲ߿۳״̬*/ + chSignalRelayDetainFlag = dataBuf[ii++]; + if ((SIGNAL_RELAY_DETAIN_NO == chSignalRelayDetainFlag) || (SIGNAL_RELAY_DETAIN_YES == chSignalRelayDetainFlag)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalRelayDetainFlag Is %d\n", wSignalId, chSignalRelayDetainFlag); + } + } + if (CI_SUCCESS == retVal) + { + /*źŻά޵״̬*/ + chSignalMaintainState = dataBuf[ii++]; + if ((MAINTAIN_STATE_YES == chSignalMaintainState) || (MAINTAIN_STATE_NO == chSignalMaintainState)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiSignalData wSignalId %d Is Error: chSignalMaintainState Is %d\n", wSignalId, chSignalMaintainState); + } + } + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiSignalData Is Error: wSignalId Is %d\n", wSignalId); + } + if (CI_ERROR == retVal) + { + break; + } + } + + } + else + { + retVal = CI_ERROR; + /*źŻޣʧ*/ + debug_infor_printf((const)"CheckCiToCiSignalData Is Error: wSignalSum Is %d\n", wSignalSum); + } + *index = ii; + } + else + { + retVal = CI_ERROR; /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵Ĵ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiCommandData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 wCommandSum = 0U;/**/ + UINT16 wCommandId = 0U;/**/ + UINT16 wCommandParam1 = 0U;/*1*/ + UINT16 wCommandParam2 = 0U;/*2*/ + UINT8 chNeiborCiType = 0U;/**/ + UINT8 chDevState = 0U;/*豸״̬*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + wCommandSum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (RECVCI_CMD_DATA_STRU_SUM_MAX >= wCommandSum) + { + for (jj = 0U; jj < wCommandSum; jj++) + { + if (CI_SUCCESS == retVal) + { + /**/ + wCommandId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + /*1*/ + wCommandParam1 = ShortFromChar(&dataBuf[ii]); + ii += 2U; + /*2*/ + wCommandParam2 = ShortFromChar(&dataBuf[ii]); + ii += 2U; + switch (wCommandId) + { + case CI_CMD_PHYSEC_USING_APPLY:/**/ + { + if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_PHYSEC_USING_REPLAY_FAILURE:/*ʧӦ*/ + { + if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (ROUTE_SUM_MAX > wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_PHYSEC_USING_CANCEL:/*ȡ*/ + { + if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_PROSW_SEC_USING_APPLY:/**/ + { + if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_PROSW_SEC_USING_FAIL:/*ʧӦ*/ + { + if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (ROUTE_SUM_MAX > wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_PROSW_SEC_USING_CANCEL:/*ȡ*/ + { + if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_SWITCH_DRIVE:/**/ + { + if ((0U < wCommandParam1) && (SWITCH_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if((SWITCH_POSITION_DINGWEI == wCommandParam2) || (SWITCH_POSITION_FANWEI == wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_SIGNAL_SPEC_OPEN_APPLY:/*źؿ*/ + { + if ((0U < wCommandParam1) && (SIGNAL_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (0U == wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_KOUCHE:/*۳*/ + { + if ((0U < wCommandParam1) && (SIGNAL_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((SIGNAL_DETAIN_ATS == wCommandParam2)|| (SIGNAL_DETAIN_ATS_AUTO == wCommandParam2) || (SIGNAL_DETAIN_XIANDI == wCommandParam2) + || (SIGNAL_DETAIN_ATS_NO == wCommandParam2) || (SIGNAL_DETAIN_XIANDI_NO == wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_KOUCHE_DETAIN:/*Ӳ߿۳*/ + { + if ((0U < wCommandParam1) && (SIGNAL_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((SIGNAL_DETAIN_CI_RELAY_YES == wCommandParam2) || (SIGNAL_DETAIN_CI_RELAY_NO == wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_TRAIN_TEST_APPLY:/*ԳԳ*/ + { + if (COMM_TRAIN_TEST_SQAJ_SCX == wCommandParam1) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + chNeiborCiType = (UINT8)((wCommandParam2 & ((UINT16)0x00FF)));/**/ + chDevState = (UINT8)((wCommandParam2 >> 8));/*豸״̬*/ + if ((CI_TYPE_SCX == chNeiborCiType) && ((COMM_TRAIN_TEST_DEV_STATE_VALID == chDevState) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == chDevState))) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_TRAIN_TEST_ALLOW_STATUS:/*Գ͵Գ״̬*/ + { + if (COMM_TRAIN_TEST_TYSJ_CLD == wCommandParam1) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((COMM_TRAIN_TEST_DEV_STATE_VALID == wCommandParam2) || (COMM_TRAIN_TEST_DEV_STATE_INVALID == wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_SET_PSC_PL:/*PSC·*/ + { + if ((0U < wCommandParam1) && (PSD_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0U < wCommandParam2) && (PSC_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_QX_PSC_PL:/*ȡPSC·*/ + { + if ((0U < wCommandParam1) && (PSD_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0U < wCommandParam2) && (PSC_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_SECTION_FAULT_UNLOCK:/*ιϽ*/ + { + if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (0U == wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_AUTO_SIG_ROUTE_CANCLE:/*Զźȡ*/ + { + if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (0U == wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_SET_AUTO_SIG_ROUTE_VALID:/*ԶźŽ·Զ*/ + { + if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (0U == wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_PSD_VOBC_CMD_TO_CI:/*psdvobc*/ + { + if ((0U < wCommandParam1) && (PSD_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((VOBCTOCI_COMMAND_TYPE_PSDCHECK == wCommandParam2) || (VOBCTOCI_COMMAND_TYPE_PSDOPEN == wCommandParam2) + || (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == wCommandParam2) || (VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT == wCommandParam2) + || (PSD_DEFAULT_CONTROL_CMD == wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_LOCK_OVERLAP_CMD:/*͵İ*/ + { + if ((0U < wCommandParam1) && (OVERLAP_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((ATS_LOCK_OVERLAP == wCommandParam2) || (LABOR_LOCK_OVERLAP == wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case LOCK_OVERLAP_HAVE_ROUTE_CMD:/*͵İ·ID*/ + { + if ((0U < wCommandParam1) && (OVERLAP_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0U < wCommandParam2) && (ROUTE_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_UNLOCK_OVERLAP_CMD:/*͵Ľ*/ + { + if ((0U < wCommandParam1) && (OVERLAP_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (0U == wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_LOGSEC_LOCK:/*·߼*/ + { + if ((0U < wCommandParam1) && (LOGIC_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (((0U < wCommandParam2) && (255U > wCommandParam2)) + || ((0X1400U < wCommandParam2) && (0X14FFU > wCommandParam2))) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_ROUTE_LOGIC_LOCK_CANCEL:/*߼ν*/ + { + if ((0U < wCommandParam1) && (LOGIC_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0X1400U < wCommandParam2) && (0X14FFU > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_ROUTE_NOTVBTC_LOGIC_LOCK_CANCEL:/*߼ηVBTCͷ*/ + { + if ((0U < wCommandParam1) && (LOGIC_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((0X1400U < wCommandParam2) && (0X14FFU > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_DR_ROUTE_STATE:/*䶯̬·ý·״̬*/ + { + if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((ROUTE_STATE_IDLE == wCommandParam2) || (ROUTE_STATE_HALF_UNLOCK == wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_DR_SWITCH_PLOCK_CANCEL:/*䶯̬·ȡ״̬*/ + { + if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (SWITCH_LOCK_PROTECT_CANCEL == wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_PHYSEC_PLOCK_ROUTE_CMD: /*η·*/ + { + if ((0U < wCommandParam1) && (PHYSICAL_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (ROUTE_SUM_MAX > wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_LOGSEC_PLOCK_ROUTE_CMD: /*߼η·*/ + { + if ((0U < wCommandParam1) && (LOGIC_SECTION_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (ROUTE_SUM_MAX > wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_ROUTE_LOCKED_OVERLAP: /*ý·չı*/ + { + if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (OVERLAP_SUM_MAX > wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_ROUTE_NEAR_STATE_SEARCH: /*·ӽ״̬ѯ*/ + { + if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + } + break; + case CI_CMD_ROUTE_NEAR_STATE_REPLAY: /*·ӽ״̬ظ*/ + { + if ((0U < wCommandParam1) && (ROUTE_SUM_MAX > wCommandParam1)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if ((ROUTE_NEAR_SEC_HAVE_UT == wCommandParam2) || (ROUTE_NEAR_SEC_NOT_HAVE_UT == wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_ROUTE_SEC_LOCK_APPLY: /*·*/ + { + if (ROUTE_SUM_MAX > wCommandParam1) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + if (CI_SUCCESS == retVal) + { + if (ROUTE_SUM_MAX > wCommandParam2) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam2 Is %d\n", wCommandId, wCommandParam2); + } + } + } + break; + case CI_CMD_OLP_PROSWT_USE_APPLY: /*η*/ + { + if ((0U < wCommandParam1) && (SWITCH_SUM_MAX > wCommandParam1)) + { + if ((0U < wCommandParam2) && (OVERLAP_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam2); + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + } + break; + case CI_CMD_OLP_PROSWT_USE_CANCEL: /*ηȡ*/ + { + if ((0U < wCommandParam1) && (SWITCH_SUM_MAX > wCommandParam1)) + { + if ((0U < wCommandParam2) && (OVERLAP_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam2); + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + } + break; + case CI_CMD_OLP_PROSWT_USE_FAILURE: /*ηʧܷ*/ + { + if ((0U < wCommandParam1) && (SWITCH_SUM_MAX > wCommandParam1)) + { + if ((0U < wCommandParam2) && (OVERLAP_SUM_MAX > wCommandParam2)) + { + retVal = CI_SUCCESS; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam2); + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData wCommandId %d Is Error: wCommandParam1 Is %d\n", wCommandId, wCommandParam1); + } + } + break; + default: + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCommandData Is Error: wCommandId Is %d\n", wCommandId); + } + break; + } + } + } + } + else + { + retVal = CI_ERROR; + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiCommandData Is Error: wCommandSum Is %d\n", wCommandSum); + } + *index = ii; + } + else + { + retVal = CI_ERROR; /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵Ĵķ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiFloodGateData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + + UINT16 floodGateSum = 0U; /**/ + UINT16 chFloodGateId = 0U; /*ID*/ + UINT8 chFloodBelongCiId = 0U; /*ID*/ + UINT8 chFGOpenLockState = 0u; /*ſ״̬*/ + UINT8 chFGCloseRequestState = 0u; /*Ź״̬*/ + UINT8 chFGAgreeClosefromZC = 0u; /*ZCظĹ*/ + UINT8 chFGAgreeCloseCollState = 0u; /*ǰͬŲɼ״̬*/ + UINT8 chFGAgreeCloseOutState = 0u; /*ǰͬ״̬*/ + + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + floodGateSum = ShortFromChar(&dataBuf[ii]);/**/ + ii += 2u; + if (FLOOD_GATE_SUM_MAX > floodGateSum) + { + /**/ + for (jj = 0U; jj < floodGateSum; jj++) + { + /*УID*/ + chFloodGateId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U != chFloodGateId)&& (FLOOD_GATE_SUM_MAX > chFloodGateId)) + { + /*ڱķŵ״̬ϢУ*/ + chFloodBelongCiId = GetFloodGateBelongCiId(chFloodGateId); + if (chFloodBelongCiId == localCiId) + { + ii += CICI_ONE_FLOODGATE_LEN - 2u; + } + } + else + { + debug_infor_printf((const)"CheckCiToCiFloodGateData Is Error: FloodGateId Is %d\n", chFloodGateId); + retVal = CI_ERROR; + } + /*У鿪״̬*/ + if (CI_SUCCESS == retVal) + { + chFGOpenLockState = dataBuf[ii]; + ii++; + if ((FLOOD_GATE_OPENLOCK == chFGOpenLockState) || (FLOOD_GATE_NOT_OPENLOCK == chFGOpenLockState)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateOpenLockState Is %d\n", chFloodGateId, chFGOpenLockState); + retVal = CI_ERROR; + } + } + /*У״̬*/ + if (CI_SUCCESS == retVal) + { + chFGCloseRequestState = dataBuf[ii]; + ii++; + if ((FLOOD_GATE_CLOSEREQ == chFGCloseRequestState) || (FLOOD_GATE_NOT_CLOSEREQ == chFGCloseRequestState)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateCloseRequestState Is %d\n", chFloodGateId, chFGCloseRequestState); + retVal = CI_ERROR; + } + } + /*УZCظ*/ + if (CI_SUCCESS == retVal) + { + chFGAgreeClosefromZC = dataBuf[ii]; + ii++; + if ((FLOOD_GATE_ALLOWCLOSE_ZC == chFGAgreeClosefromZC) || (FLOOD_GATE_NOT_ALLOWCLOSE_ZC == chFGAgreeClosefromZC)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateAgreeCloseAckFromZC Is %d\n", chFloodGateId, chFGAgreeClosefromZC); + retVal = CI_ERROR; + } + } + /*У鵱ǰͬŲɼ״̬*/ + if (CI_SUCCESS == retVal) + { + chFGAgreeCloseCollState = dataBuf[ii]; + ii++; + if ((FLOOD_GATE_AGREE_CLOSE == chFGAgreeCloseCollState) || (FLOOD_GATE_NOT_AGREE_CLOSE == chFGAgreeCloseCollState)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateAgreeCloseCollState Is %d\n", chFloodGateId, chFGAgreeCloseCollState); + retVal = CI_ERROR; + } + } + /*Уͬ״̬*/ + if (CI_SUCCESS == retVal) + { + chFGAgreeCloseOutState = dataBuf[ii]; + ii++; + if ((FLOOD_GATE_AGREE_CLOSE == chFGAgreeCloseOutState) || (FLOOD_GATE_NOT_AGREE_CLOSE == chFGAgreeCloseOutState)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiFloodGateData wFloodGateId %d Is Error: FloodGateAgreeCloseOutState Is %d\n", chFloodGateId, chFGAgreeCloseOutState); + retVal = CI_ERROR; + } + } + + if (CI_ERROR == retVal) + { + /*Уʧ*/ + break; + } + else + { + /*Уɹ*/ + } + } + } + else + { + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiFloodGateData Is Error: floodGateSum Is %d\n", floodGateSum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* УCI͵Ĵı +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiOverlapData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + + UINT16 overlapSum = 0U; /**/ + UINT16 chOverlapId = 0U; /*ID*/ + UINT8 chOverlapBelongCiId = 0U; /*ID*/ + UINT16 chOverlapBelongRouteId = 0U; /*·ID*/ + UINT32 chOverlapUnlockCycNum = 0u; /*ʼں*/ + UINT32 chOverlapXuanpaiCycNum = 0u; /*ѡſʼں*/ + UINT8 chOverlapUnlockApplyFlag = 0u; /*ZCα־*/ + UINT16 chOverlapUnlockTime = 0u; /*νʱ*/ + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT8 cProSwtCheckStartFlag = 0U; /*η鿪ʼ־*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + overlapSum = ShortFromChar(&dataBuf[ii]);/**/ + ii += 2u; + if (OVERLAP_SUM_MAX > overlapSum) + { + for (jj = 0U; jj < overlapSum; jj++) + { + /*У鱣ID*/ + chOverlapId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U != chOverlapId) && (OVERLAP_SUM_MAX > chOverlapId)) + { + /*ڱıεϢУ*/ + chOverlapBelongCiId = GetOverlapBelongCiId(chOverlapId); + if (chOverlapBelongCiId == localCiId) + { + ii += CICI_ONE_OVERLAP_LEN - 2u; + } + } + else + { + debug_infor_printf((const)"CheckCiToCiOverlapData Is Error: OverlapId Is %d\n", chOverlapId); + retVal = CI_ERROR; + } + /*У鱣·ID*/ + if (CI_SUCCESS == retVal) + { + chOverlapBelongRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if (ROUTE_SUM_MAX > chOverlapBelongRouteId) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapBelongRouteId Is %d\n", chOverlapId, chOverlapBelongRouteId); + retVal = CI_ERROR; + } + } + /*У鱣ʼں*/ + if (CI_SUCCESS == retVal) + { + chOverlapUnlockCycNum = LongFromChar(&dataBuf[ii]); + ii += 4u; + if (UINT32_MAX > chOverlapUnlockCycNum) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapUnlockCycNum Is %d\n", chOverlapId, chOverlapUnlockCycNum); + retVal = CI_ERROR; + } + } + /*У鱣ѡſʼں*/ + if (CI_SUCCESS == retVal) + { + chOverlapXuanpaiCycNum = LongFromChar(&dataBuf[ii]); + ii += 4u; + if (UINT32_MAX > chOverlapXuanpaiCycNum) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapXuanpaiCycNum Is %d\n", chOverlapId, chOverlapXuanpaiCycNum); + retVal = CI_ERROR; + } + } + /*УZCα־*/ + if (CI_SUCCESS == retVal) + { + chOverlapUnlockApplyFlag = dataBuf[ii]; + ii++; + if ((UNLOCK_OVERLAP_APPLY_YES == chOverlapUnlockApplyFlag) || (UNLOCK_OVERLAP_APPLY_NO == chOverlapUnlockApplyFlag)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapUnlockApplyFlag Is %d\n", chOverlapId, chOverlapUnlockApplyFlag); + retVal = CI_ERROR; + } + } + /*У鱣νʱ*/ + if (CI_SUCCESS == retVal) + { + chOverlapUnlockTime = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if (UINT16_MAX > chOverlapUnlockTime) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: OverlapUnlockTime Is %d\n", chOverlapId, chOverlapUnlockTime); + retVal = CI_ERROR; + } + } + /*У鱣ηʼ־*/ + if (CI_SUCCESS == retVal) + { + cProSwtCheckStartFlag = dataBuf[ii]; + ii++; + if ((PROSWITCH_CHECK_START_VALID == cProSwtCheckStartFlag) || (PROSWITCH_CHECK_START_INVALID == cProSwtCheckStartFlag)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiOverlapData OverlapId %d Is Error: ProSwtCheckStartFlag Is %d\n", chOverlapId, cProSwtCheckStartFlag); + retVal = CI_ERROR; + } + } + if (CI_ERROR == retVal) + { + /*Уʧ*/ + break; + } + else + { + /*Уɹ*/ + } + } + } + else + { + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiOverlapData Is Error: overlapSum Is %d\n", overlapSum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + retVal = CI_ERROR; + } + + return retVal; +} + + +/* +* УCI͵ĴԶͨ· +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiAutoRouteData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + + UINT16 autoRouteSum = 0U; /*Զͨ·*/ + UINT16 chAutoRouteId = 0U; /*Զͨ·ID*/ + UINT8 chAutoRouteBelongCiId = 0u; /*Զͨ·ID*/ + UINT8 chAutoRouteSetFlag = 0U; /*Զͨ·־*/ + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + autoRouteSum = ShortFromChar(&dataBuf[ii]);/*Զͨ·*/ + ii += 2u; + if (AUTO_ROUTE_SUM_MAX > autoRouteSum) + { + for (jj = 0U; jj < autoRouteSum; jj++) + { + /*УԶͨ·ID*/ + chAutoRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U != chAutoRouteId) && (AUTO_ROUTE_SUM_MAX > chAutoRouteId)) + { + /*ڱԶͨ·ϢУ*/ + chAutoRouteBelongCiId = GetAutoRouteBelongCiId(chAutoRouteId); + if (chAutoRouteBelongCiId == localCiId) + { + ii += CICI_ONE_AUTOROUTE_LEN - 2u; + } + } + else + { + debug_infor_printf((const)"CheckCiToCiAutoRouteData Is Error: AutoRouteId Is %d\n", chAutoRouteId); + retVal = CI_ERROR; + } + /*УԶͨ·־*/ + if (CI_SUCCESS == retVal) + { + chAutoRouteSetFlag = dataBuf[ii]; + ii++; + if ((AUTO_ROUTE_SET_YES == chAutoRouteSetFlag) || (AUTO_ROUTE_SET_NO == chAutoRouteSetFlag)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiAutoRouteData AutoRouteId %d Is Error: AutoRouteSetFlag Is %d\n", chAutoRouteId, chAutoRouteSetFlag); + retVal = CI_ERROR; + } + } + if (CI_ERROR == retVal) + { + /*Уʧ*/ + break; + } + else + { + /*Уɹ*/ + } + } + } + else + { + /*Զͨ·ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiAutoRouteData Is Error: autoRouteSum Is %d\n", autoRouteSum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* УCI͵ı߼ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiLogicLockData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 kk = 0u; + + UINT16 lgcSum = 0U; /*߼*/ + UINT16 chLgcId = 0U; /*߼ID*/ + UINT8 chLgcLockState = 0u; /*߼״̬*/ + UINT16 chLgcLockBelongRoute = 0u; /*߼·ID*/ + UINT16 chLgcPLockBelongRoute = 0u; /*߼α·ID*/ + UINT8 chLgcLockDir = 0U; /*շ*/ + UINT8 chLgcResShrFlag = 0u; /*Դ־*/ + UINT8 chLgcSecTrainSum = 0u; /*߼εг*/ + UINT16 szLgcSecTrainId = 0u; /*߼εгID*/ + UINT8 cLogLockLogRouteSum = 0u; /*߼߼߼·*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + lgcSum = ShortFromChar(&dataBuf[ii]);/*߼*/ + ii += 2u; + if (LOGIC_SECTION_SUM_MAX > lgcSum) + { + for (jj = 0U; jj < lgcSum; jj++) + { + /*У߼ID*/ + chLgcId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U != chLgcId) && (LOGIC_SECTION_SUM_MAX > chLgcId)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData Is Error: LgcId Is %d\n", chLgcId); + retVal = CI_ERROR; + } + /*У߼״̬*/ + if (CI_SUCCESS == retVal) + { + chLgcLockState = dataBuf[ii]; + ii++; + if ((LOG_SECTION_LOCK_NO == chLgcLockState) || (LOG_SECTION_LOCK_NORMAL == chLgcLockState) + || (LOG_SECTION_LOCK_DELAY == chLgcLockState) || (LOG_SECTION_LOCK_EXCEPT == chLgcLockState) + || (LOG_SECTION_LOCK_PROTECT == chLgcLockState)||(LOG_SECTION_LOCK_START == chLgcLockState)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLockState Is %d\n", chLgcId, chLgcLockState); + retVal = CI_ERROR; + } + } + /*У߼·*/ + if (CI_SUCCESS == retVal) + { + chLgcLockBelongRoute = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if (ROUTE_SUM_MAX > chLgcLockBelongRoute) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLockBelongRouteID Is %d\n", chLgcId, chLgcLockBelongRoute); + retVal = CI_ERROR; + } + } + /*У߼α·*/ + if (CI_SUCCESS == retVal) + { + chLgcPLockBelongRoute = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if (ROUTE_SUM_MAX > chLgcPLockBelongRoute) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcPLockBelongRouteID Is %d\n", chLgcId, chLgcPLockBelongRoute); + retVal = CI_ERROR; + } + } + /*У߼շ*/ + if (CI_SUCCESS == retVal) + { + chLgcLockDir = dataBuf[ii]; + ii++; + if ((CI_SYSTEM_DIRECTION_DOWN == chLgcLockDir) || (CI_SYSTEM_DIRECTION_UP == chLgcLockDir) || (0u == chLgcLockDir)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLockDir Is %d\n", chLgcId, chLgcLockDir); + retVal = CI_ERROR; + } + } + /*У߼߼״̬*/ + if (CI_SUCCESS == retVal) + { + chLgcLockState = dataBuf[ii]; + ii++; + if ((LOG_SECTION_LOGLOCK_NO == chLgcLockState) || (LOG_SECTION_LOGLOCK_NORMAL == chLgcLockState) || (LOG_SECTION_LOGLOCK_EXCEPT == chLgcLockState)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLogicLockState Is %d\n", chLgcId, chLgcLockState); + retVal = CI_ERROR; + } + } + /*У߼߼շ*/ + if (CI_SUCCESS == retVal) + { + chLgcLockDir = dataBuf[ii]; + ii++; + if ((CI_SYSTEM_DIRECTION_DOWN == chLgcLockDir) || (CI_SYSTEM_DIRECTION_UP == chLgcLockDir) || (0u == chLgcLockDir)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcLogicLockDir Is %d\n", chLgcId, chLgcLockDir); + retVal = CI_ERROR; + } + } + /*У߼߼߼·*/ + if (CI_SUCCESS == retVal) + { + cLogLockLogRouteSum = dataBuf[ii]; + ii++; + if (LOGSEC_RELATE_ROUTE_SUM_MAX >= cLogLockLogRouteSum) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LogLockLogRouteSum Is %d\n", chLgcId, cLogLockLogRouteSum); + retVal = CI_ERROR; + } + } + + /*У߼ιԴ־*/ + if (CI_SUCCESS == retVal) + { + chLgcResShrFlag = dataBuf[ii]; + ii++; + if ((LOGIC_SECTION_RES_SHARE_NO == chLgcResShrFlag) || (LOGIC_SECTION_RES_SHARE_YES == chLgcResShrFlag)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcResShrFlag Is %d\n", chLgcId, chLgcResShrFlag); + retVal = CI_ERROR; + } + } + /*У߼εг*/ + if (CI_SUCCESS == retVal) + { + chLgcSecTrainSum = dataBuf[ii];/*߼εг*/ + ii++; + if (LOGIC_SECTION_RES_SUM_MAX > chLgcSecTrainSum) + { + /*У߼εгID*/ + for (kk = 0u; kk < chLgcSecTrainSum; kk++) + { + szLgcSecTrainId = ShortFromChar(&dataBuf[ii]);/*߼εгID*/ + ii += 2u; + if (TRAIN_SUM_MAX >= szLgcSecTrainId) + { + /*0255 Уͨ*/ + } + else if ((TRAIN_ID_MIN < szLgcSecTrainId) && (TRAIN_ID_MAX >= szLgcSecTrainId)) + { + /*0x14010x14ffУͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcSecTrainId Is %d\n", chLgcId, szLgcSecTrainId); + retVal = CI_ERROR; + break; + } + } + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData LgcId %d Is Error: LgcSecTrainSum Is %d\n", chLgcId, chLgcSecTrainSum); + retVal = CI_ERROR; + } + } + if (CI_ERROR == retVal) + { + /*Уʧ*/ + break; + } + else + { + /*Уɹ*/ + } + } + } + else + { + /*߼ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiLogicLockData Is Error: lgcSum Is %d\n", lgcSum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* У鶯̬·Ϣ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiDrCmdData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 kk = 0u; + UINT16 drCmdSum = 0U; /*̬·*/ + UINT8 chDrRouteType = 0u; /*̬·*/ + UINT8 chDrRouteDir = 0u; /*̬·߼з*/ + UINT8 chDrRouteLgcSum = 0u; /*̬·߼*/ + UINT16 szDrRouteLgcId = 0U; /*̬·߼ID*/ + UINT16 chDrRouteTrainId = 0U; /*̬·гID*/ + UINT8 chDrRouteTrainLgcSum = 0U;/*̬·г߼*/ + UINT16 szDrRouteTrainLgcID = 0U;/*̬·г߼ID*/ + UINT8 chSwitchMoveFlag = 0u; /*ؽ·ɶ־*/ + UINT16 wRelSignalId = 0U; /*׸߼ιʼźŻID*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + drCmdSum = ShortFromChar(&dataBuf[ii]);/*̬·*/ + ii += 2u; + if (RECVCI_CMD_DATA_STRU_SUM_MAX > drCmdSum) + { + for (jj = 0U; jj < drCmdSum; jj++) + { + /*У鶯̬·*/ + chDrRouteType = dataBuf[ii]; + ii++; + if ((CICI_DR_CMD_HALF == chDrRouteType) || (CICI_DR_CMD_FULL == chDrRouteType) || (CICI_DR_CMD_LOGIC == chDrRouteType)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteType Is %d\n", jj, chDrRouteType); + retVal = CI_ERROR; + } + /*У鶯̬·߼з*/ + if (CI_SUCCESS == retVal) + { + chDrRouteDir = dataBuf[ii]; + ii++; + if ((CI_SYSTEM_DIRECTION_UP == chDrRouteDir) || (CI_SYSTEM_DIRECTION_DOWN == chDrRouteDir)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteDir Is %d\n", jj, chDrRouteDir); + retVal = CI_ERROR; + } + } + /*У鶯̬·߼*/ + if (CI_SUCCESS == retVal) + { + chDrRouteLgcSum = dataBuf[ii]; + ii++; + if ( MAX_ROUTE_IN_LT_NUM > chDrRouteLgcSum) + { + /*У鶯̬·߼ID*/ + for (kk = 0U; kk < chDrRouteLgcSum; kk++) + { + szDrRouteLgcId = ShortFromChar(&dataBuf[ii]); /*̬·߼ID*/ + ii += 2U; + if ((0u != szDrRouteLgcId) && (UINT16_MAX > szDrRouteLgcId)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteLgcId Is %d\n", jj, szDrRouteLgcId); + retVal = CI_ERROR; + break; + } + } + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteLgcSum Is %d\n", jj, chDrRouteLgcSum); + retVal = CI_ERROR; + } + } + /*У鶯̬·гID*/ + if (CI_SUCCESS == retVal) + { + chDrRouteTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (UINT16_MAX > chDrRouteTrainId) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteTrainId Is %d\n", jj, chDrRouteTrainId); + retVal = CI_ERROR; + } + } + /*У鶯̬·г߼,·*/ + if (CI_SUCCESS == retVal) + { + chDrRouteTrainLgcSum = dataBuf[ii]; + ii++; + if (SIZE_MAX_SECTION_BT_TRAIN > chDrRouteTrainLgcSum) + { + /*У鶯̬·г߼ID*/ + for (kk = 0U; kk < chDrRouteTrainLgcSum; kk++) + { + szDrRouteTrainLgcID = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if ((0u != szDrRouteTrainLgcID) && (LOGIC_SECTION_SUM_MAX > szDrRouteTrainLgcID)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteTrainLgcID Is %d\n", jj, szDrRouteTrainLgcID); + retVal = CI_ERROR; + break; + } + } + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: DrRouteTrainLgcSum Is %d\n", jj, chDrRouteTrainLgcSum); + retVal = CI_ERROR; + } + } + /*Уؽ·ɶ־*/ + if (CI_SUCCESS == retVal) + { + chSwitchMoveFlag = dataBuf[ii]; + ii++; + if ((ROUTE_HALF_SWITCH_MOVE_VALID == chSwitchMoveFlag) || (ROUTE_HALF_SWITCH_MOVE_INVALID == chSwitchMoveFlag)) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: SwitchMoveFlag Is %d\n", jj, chSwitchMoveFlag); + retVal = CI_ERROR; + } + } + + /*У׸߼ιʼźŻID*/ + if (CI_SUCCESS == retVal) + { + wRelSignalId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (SIGNAL_SUM_MAX > wRelSignalId) + { + /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiLogicLockData DrRouteIndex %d Is Error: RelStartSignalId Is %d\n", jj, wRelSignalId); + retVal = CI_ERROR; + } + } + + if (CI_ERROR == retVal) + { + /*Уʧ*/ + break; + } + else + { + /*Уɹ*/ + } + } + } + else + { + /*̬·ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiDrCmdData Is Error: drCmdSum Is %d\n", drCmdSum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* УCI͵ĴĹ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiCommonPhyLockData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 cPhySecSum = 0U; /**/ + UINT16 wPhySecId = 0U; /*ID*/ + UINT8 cPhySecLockState = 0U; /*״̬*/ + UINT16 wPLockBelongRouteId = 0U; /*η·ID*/ + UINT16 wRLockBelongRouteId = 0U; /*ν··ID*/ + UINT16 wOverlapId = 0U; /*ID*/ + UINT8 cPhySecLockDir = 0U; /*շ*/ + UINT8 cPhySecBelongCiId = 0U; + UINT8 cLocalCiId = 0U; + + cLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + cPhySecSum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (PHYSICAL_SECTION_SUM_MAX > cPhySecSum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < cPhySecSum; jj++) + { + /*УID*/ + wPhySecId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if ((0U < wPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wPhySecId)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: PhySecId Is 0 Or Exceed Max %d\n", wPhySecId, PHYSICAL_SECTION_SUM_MAX); + retVal = CI_ERROR; + } + + /*Уε״̬*/ + if (CI_SUCCESS == retVal) + { + cPhySecLockState = dataBuf[ii]; + ii++; + if ((PHYSICAL_SECTION_LOCK_NO == cPhySecLockState) || (PHYSICAL_SECTION_LOCK_NORMAL == cPhySecLockState) + || (PHYSICAL_SECTION_LOCK_EXCEPT == cPhySecLockState) || (PHYSICAL_SECTION_LOCK_PROTECT == cPhySecLockState) || (PHYSICAL_SECTION_LOCK_DELAY == cPhySecLockState) + || (PHYSICAL_SECTION_LOCK_FAULTDELAY == cPhySecLockState) || (PHYSICAL_SECTION_LOCK_START == cPhySecLockState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: PhySecLockState Is %d\n", wPhySecId, cPhySecLockState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уη·ID*/ + if (CI_SUCCESS == retVal) + { + wPLockBelongRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (ROUTE_SUM_MAX > wPLockBelongRouteId) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: PLockBelongRouteId Is %d\n", wPhySecId, wPLockBelongRouteId); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уν··ID*/ + if (CI_SUCCESS == retVal) + { + wRLockBelongRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (ROUTE_SUM_MAX > wRLockBelongRouteId) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: RLockBelongRouteId Is %d\n", wPhySecId, wRLockBelongRouteId); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + cPhySecBelongCiId = GetPhySecBelongCiId(wPhySecId); + if (cPhySecBelongCiId == cLocalCiId) + { + ii += 2U; /*ΣУ*/ + } + else + { + /*УηնӦıID*/ + if (CI_SUCCESS == retVal) + { + wOverlapId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (OVERLAP_SUM_MAX > wOverlapId) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: OverlapId Is %d\n", wPhySecId, wOverlapId); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + } + + /*Уεշ*/ + if (CI_SUCCESS == retVal) + { + cPhySecLockDir = dataBuf[ii]; + ii++; + if ((0U == cPhySecLockDir)||(CI_SYSTEM_DIRECTION_UP == cPhySecLockDir) || (CI_SYSTEM_DIRECTION_DOWN == cPhySecLockDir)|| (CI_SYSTEM_DIRECTION_NONE == cPhySecLockDir)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCommonPhyLockData PhySecId[%d] Is Error: PhySecLockDir Is %d\n", wPhySecId, cPhySecLockDir); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /*У*/ + } + } + + } + else + { + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiCommonPhyLockData Is Error: PhySecSum %d Exceed Max %d\n", cPhySecSum, PHYSICAL_SECTION_SUM_MAX); + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵ĴSPKS +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiSpksData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 cSpksSum = 0U; /*SPKS*/ + UINT16 wSpksId = 0U; /*SPKS ID*/ + UINT8 cSpksState = 0U; /*SPKS״̬*/ + UINT8 cSpksCutState = 0U; /*SPKS·״̬*/ + UINT8 cSpksBelongCiId = 0U; + UINT8 cLocalCiId = 0U; + + cLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + cSpksSum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (SPKS_SUM_MAX > cSpksSum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < cSpksSum; jj++) + { + /*УSPKS ID*/ + wSpksId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if ((0U < wSpksId) && (SPKS_SUM_MAX > wSpksId)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSpksData SpksId[%d] Is Error: SpksId Is 0 Or Exceed Max %d\n", wSpksId, SPKS_SUM_MAX); + retVal = CI_ERROR; + } + + cSpksBelongCiId = GetSpksBelongCiId(wSpksId); + if (cSpksBelongCiId == cLocalCiId) + { + ii += CICI_ONE_SPKS_LEN - 2U; /*ڱSPKS״̬ϢУ*/ + } + else + { + /*УSPKS״̬*/ + if (CI_SUCCESS == retVal) + { + cSpksState = dataBuf[ii]; + ii++; + if ((SPKS_STATUS_NO == cSpksState) || (SPKS_STATUS_YES == cSpksState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSpksData SpksId[%d] Is Error: SpksState Is %d\n", wSpksId, cSpksState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УSPKS·״̬*/ + if (CI_SUCCESS == retVal) + { + cSpksCutState = dataBuf[ii]; + ii++; + if ((SPKS_CUT_NO == cSpksCutState) || (SPKS_CUT_YES == cSpksCutState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiSpksData SpksId[%d] Is Error: SpksCutState Is %d\n", wSpksId, cSpksCutState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /*У*/ + } + } + + } + else + { + /*SPKSޣʧ*/ + debug_infor_printf((const)"CheckCiToCiSpksData Is Error: SpksSum %d Exceed Max %d\n", cSpksSum, SPKS_SUM_MAX); + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵Ĵ̵ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiVirRelayData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 cVirRelaySum = 0U; /*̵*/ + UINT16 wVirRelayId = 0U; /*̵ID*/ + UINT8 cVirRelayCollState = 0U; /*̵ɼ״̬*/ + UINT8 cVirRelayBelongCiId = 0U; + UINT8 cLocalCiId = 0U; + + cLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + cVirRelaySum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (RELAY_SUM_MAX > cVirRelaySum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < cVirRelaySum; jj++) + { + /*У̵ID*/ + wVirRelayId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if ((0U < wVirRelayId) && (RELAY_SUM_MAX > wVirRelayId)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiVirRelayData VirRelayId[%d] Is Error: VirRelayId Is 0 Or Exceed Max %d\n", wVirRelayId, RELAY_SUM_MAX); + retVal = CI_ERROR; + } + + cVirRelayBelongCiId = GetRelayBelongCiId(wVirRelayId); + if (cVirRelayBelongCiId == cLocalCiId) + { + ii += CICI_ONE_VIRTUAL_RELAY_LEN - 2U; /*ڱ̵״̬ϢУ*/ + } + else + { + /*У̵ɼ״̬*/ + if (CI_SUCCESS == retVal) + { + cVirRelayCollState = dataBuf[ii]; + ii++; + if ((RELAY_DRIVE_STATE_DOWN == cVirRelayCollState) || (RELAY_DRIVE_STATE_UP == cVirRelayCollState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiVirRelayData VirRelayId[%d] Is Error: VirRelayCollState Is %d\n", wVirRelayId, cVirRelayCollState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /*У*/ + } + } + + } + else + { + /*̵ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiVirRelayData Is Error: VirRelaySum %d Exceed Max %d\n", cVirRelaySum, RELAY_SUM_MAX); + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵Ĵɢ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiEaData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 cEaSum = 0U; /*ɢ*/ + EaDataStru strEaTmp = { 0u }; /*ɢṹ*/ + UINT16 wTrainIdIndex = 0U; + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + + /*Уڿɢ*/ + cEaSum = dataBuf[ii]; + ii++; + if (EA_MAX_NUM >= cEaSum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < cEaSum; jj++) + { + /*УڿɢгID*/ + strEaTmp.wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + wTrainIdIndex = GetTrainBufIndex(strEaTmp.wTrainId); + if (TRAIN_SUM_MAX > wTrainIdIndex) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaTrainId Is %d\n", jj, strEaTmp.wTrainId); + retVal = CI_ERROR; + } + + /*Уڿɢ߼Ϣ*/ + if (CI_SUCCESS == retVal) + { + strEaTmp.strLgcInfo.chObjNum = dataBuf[ii]; + ii++; + if (EA_SECTION_MAX_NUM >= strEaTmp.strLgcInfo.chObjNum) + { + for (kk = 0U; kk < strEaTmp.strLgcInfo.chObjNum; kk++) + { + /*Уڿɢ߼ID*/ + strEaTmp.strLgcInfo.szObjId[kk] = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U < strEaTmp.strLgcInfo.szObjId[kk]) && (LOGIC_SECTION_SUM_MAX > strEaTmp.strLgcInfo.szObjId[kk])) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaLogSecId %d Is 0 Or Exceed Max %d\n", jj, strEaTmp.strLgcInfo.szObjId[kk], LOGIC_SECTION_SUM_MAX); + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /*У*/ + } + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaLogSecSum %d Exceed Max %d\n", jj, strEaTmp.strLgcInfo.chObjNum, EA_SECTION_MAX_NUM); + } + } + else + { + /*Уʧ*/ + } + + /*УڿɢĽʶ*/ + if (CI_SUCCESS == retVal) + { + strEaTmp.chBuildedFlag = dataBuf[ii]; + ii++; + if ((EA_IS_BUILDED == strEaTmp.chBuildedFlag) || (EA_IS_NOT_BUILDED == strEaTmp.chBuildedFlag)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaBuildedFlag Is %d\n", jj, strEaTmp.chBuildedFlag); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уڿɢг*/ + if (CI_SUCCESS == retVal) + { + strEaTmp.dwMidLine = LongFromChar(&dataBuf[ii]); + ii += 4U; + if (UINT32_MAX > strEaTmp.dwMidLine) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaMidLine Is %d\n", jj, strEaTmp.dwMidLine); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уڿɢ*/ + if (CI_SUCCESS == retVal) + { + strEaTmp.chPaType = dataBuf[ii]; + ii++; + if ((PA_TYPE_EA == strEaTmp.chPaType) || (PA_TYPE_DA == strEaTmp.chPaType)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: EaType Is %d\n", jj, strEaTmp.chPaType); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уڿɢں*/ + if (CI_SUCCESS == retVal) + { + strEaTmp.dwEaBuildCycNum = LongFromChar(&dataBuf[ii]); + ii += 4U; + if ((PA_TYPE_EA == strEaTmp.chPaType) && (0U == strEaTmp.dwEaBuildCycNum)) + { + debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: dwEaBuildCycNum Is %d\n", jj, strEaTmp.dwEaBuildCycNum); + retVal = CI_ERROR; + } + else + { + ; /*У*/ + } + } + else + { + /*Уʧ*/ + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /*У*/ + } + } + } + else + { + /*ڿɢޣʧ*/ + debug_infor_printf((const)"CheckCiToCiEaData Is Error: BuildEaSum %d Exceed Max %d\n", cEaSum, EA_MAX_NUM); + } + + if (CI_SUCCESS == retVal) + { + /*Уڿɢ*/ + cEaSum = dataBuf[ii]; + ii++; + if (EA_MAX_NUM >= cEaSum) + { + for (jj = 0U; jj < cEaSum; jj++) + { + /*УڿɢгID*/ + strEaTmp.wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + wTrainIdIndex = GetTrainBufIndex(strEaTmp.wTrainId); + if (TRAIN_SUM_MAX > wTrainIdIndex) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEaData BackEaIndex[%d] Is Error: EaTrainId Is %d\n", jj, strEaTmp.wTrainId); + retVal = CI_ERROR; + } + + /*Уڿɢ*/ + if (CI_SUCCESS == retVal) + { + strEaTmp.chDstAllowed = dataBuf[ii]; + ii++; + if ((EA_DST_ALLOWED_NO == strEaTmp.chDstAllowed) || (EA_DST_ALLOWED_YES == strEaTmp.chDstAllowed)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEaData BackEaIndex[%d] Is Error: EaDstAllowed Is %d\n", jj, strEaTmp.chDstAllowed); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уڿɢں*/ + if (CI_SUCCESS == retVal) + { + strEaTmp.dwEaBuildCycNum = LongFromChar(&dataBuf[ii]); + ii += 4U; + if (0U == strEaTmp.dwEaBuildCycNum) + { + debug_infor_printf((const)"CheckCiToCiEaData BuildEaIndex[%d] Is Error: dwEaBuildCycNum Is %d\n", jj, strEaTmp.dwEaBuildCycNum); + retVal = CI_ERROR; + } + else + { + ; /*У*/ + } + } + else + { + /*Уʧ*/ + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /*У*/ + } + } + + } + else + { + /*ڿɢޣʧ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiEaData Is Error: BackEaSum %d Exceed Max %d\n", cEaSum, EA_MAX_NUM); + } + } + else + { + /*Уʧ*/ + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵Ĵķֽͨų +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiCfpCTData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT8 cCTSum = 0U; /*ͨų*/ + UINT16 wTrainId = 0U; /*гID*/ + UINT8 cTrainLevel = 0U; /*гм*/ + UINT32 dwTrainDelay = 0U; /*гͨʱ*/ + UINT16 wTrainSpeed = 0U; /*гٶ*/ + UINT8 cSpeedDir = 0U; /*ٶȷ*/ + UINT8 cTrainDir = 0U; /*г*/ + UINT16 wTrainIdIndex = 0U; + + LOD_STRU wMaxhead = { 0u }; + LOD_STRU wMinhead = { 0u }; + LOD_STRU wMaxtail = { 0u }; + LOD_STRU wMintail = { 0u }; + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + cCTSum = dataBuf[ii]; + ii++; + if (TRAIN_SUM_MAX > cCTSum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < cCTSum; jj++) + { + /*УͨųID*/ + wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + wTrainIdIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wTrainIdIndex) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainId Is 0 Or Exceed Max %d\n", wTrainId, TRAIN_SUM_MAX); + retVal = CI_ERROR; + } + + /*Уͨų*/ + if (CI_SUCCESS == retVal) + { + cTrainLevel = dataBuf[ii]; + ii++; + if ((TRAIN_LEVEL_UR == cTrainLevel)|| (TRAIN_LEVEL_ABL == cTrainLevel) || (TRAIN_LEVEL_VBTC == cTrainLevel)||(TRAIN_LEVEL_ITC == cTrainLevel)) + { + /*У ˴0 0xff*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainLevel Is %d\n", wTrainId, cTrainLevel); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Угͨʱ*/ + if (CI_SUCCESS == retVal) + { + dwTrainDelay = LongFromChar(&dataBuf[ii]); + ii += 4U; + if (UINT32_MAX > dwTrainDelay) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainDelay Is %d\n", wTrainId, dwTrainDelay); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Угٶ*/ + if (CI_SUCCESS == retVal) + { + wTrainSpeed = ShortFromChar(&dataBuf[ii]); + ii += 2U; + if (UINT16_MAX > wTrainSpeed) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainSpeed Is %d\n", wTrainId, wTrainSpeed); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Угٶȷ*/ + if (CI_SUCCESS == retVal) + { + cSpeedDir = dataBuf[ii]; + ii++; + if ((TRAIN_SPEED_DIR_BACKWARD == cSpeedDir) || (TRAIN_SPEED_DIR_FORWARD == cSpeedDir)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: SpeedDir Is %d\n", wTrainId, cSpeedDir); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*Уг*/ + if (CI_SUCCESS == retVal) + { + cTrainDir = dataBuf[ii]; + ii++; + if ((DIR_SAME == cTrainDir) || (DIR_CONVERT == cTrainDir)) + { + /*У*/ + + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainDir Is %d\n", wTrainId, cTrainDir); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УгǰLink ID*/ + if (CI_SUCCESS == retVal) + { + wMaxhead.Lnk = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U < wMaxhead.Lnk) && (UINT16_MAX > wMaxhead.Lnk)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MaxHeadLinkId Is %d\n", wTrainId, wMaxhead.Lnk); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УгǰLinkƫ*/ + if (CI_SUCCESS == retVal) + { + wMaxhead.Off = LongFromChar(&dataBuf[ii]); + ii += 4u; + if (UINT32_MAX > wMaxhead.Off) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MaxHeadLinkOffset Is %d\n", wTrainId, wMaxhead.Off); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УгСǰLink ID*/ + if (CI_SUCCESS == retVal) + { + wMinhead.Lnk = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U < wMinhead.Lnk) && (UINT16_MAX > wMinhead.Lnk)) + { + /*У*/ + } + else + { + debug_infor_printf((const)" TrainId[%d] Is Error: MinHeadLinkId Is %d\n", wTrainId, wMinhead.Lnk); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УгСǰLinkƫ*/ + if (CI_SUCCESS == retVal) + { + wMinhead.Off = LongFromChar(&dataBuf[ii]); + ii += 4u; + if (UINT32_MAX > wMinhead.Off) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MinHeadLinkOffset Is %d\n", wTrainId, wMinhead.Off); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УгLink ID*/ + if (CI_SUCCESS == retVal) + { + wMaxtail.Lnk = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U < wMaxtail.Lnk) && (UINT16_MAX > wMaxtail.Lnk)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MaxTailLinkId Is %d\n", wTrainId, wMaxtail.Lnk); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УгLinkƫ*/ + if (CI_SUCCESS == retVal) + { + wMaxtail.Off = LongFromChar(&dataBuf[ii]); + ii += 4u; + if (UINT32_MAX > wMaxtail.Off) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error:MaxTailLinkOffset Is %d\n", wTrainId, wMaxtail.Off); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УгСLink ID*/ + if (CI_SUCCESS == retVal) + { + wMintail.Lnk = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U < wMintail.Lnk) && (UINT16_MAX > wMintail.Lnk)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: MinTailLinkId Is %d\n", wTrainId, wMintail.Lnk); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + /*УгСLinkƫ*/ + if (CI_SUCCESS == retVal) + { + wMintail.Off = LongFromChar(&dataBuf[ii]); + ii += 4u; + if (UINT32_MAX > wMintail.Off) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error:MinTailLinkOffset Is %d\n", wTrainId, wMintail.Off); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + /*УгСܷó㷽*/ + if (CI_SUCCESS == retVal) + { + retVal = CheckTrainDirToOtherPointDir(wMaxhead, wMinhead, wMaxtail, wMintail, cTrainDir); + if (CI_SUCCESS != retVal) + { + debug_infor_printf((const)"CheckCiToCiCfpCTData TrainId[%d] Is Error: TrainDir %d is Fail To Calculate\n", wTrainId, cTrainDir); + retVal = CI_ERROR; + } + + } + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /*У*/ + } + } + } + else + { + /*ͨųޣʧ*/ + debug_infor_printf((const)"CheckCiToCiCfpCTData Is Error: CTSum %d Exceed Max %d\n", cCTSum, TRAIN_SUM_MAX); + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + + return retVal; +} + +/* +* УCI͵PSD +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiPsdData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 belongCiId = 0u; + UINT8 localCiId = 0u; /*ID*/ + + UINT16 psdSum = 0u; /*Psd*/ + UINT16 psdId = 0u; /*Psd豸ID*/ + UINT8 doorState = 0u; /*״̬*/ + UINT8 mutualLockState = 0u; /*Ż״̬*/ + localCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + + /**/ + psdSum = ShortFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 2u; + + if (PSD_SUM_MAX > psdSum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < psdSum; jj++) + { + psdId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0u < psdId) && (PSD_SUM_MAX > psdId)) + { + belongCiId = GetPsdBelongCiId(psdId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_PSD_LEN - 2u;/*ڱPSD״̬Ϣ*/ + } + else + { + /*״̬*/ + doorState = dataBuf[ii]; + ii++; + if ((PSD_STATE_CLOSE == doorState) || (PSD_STATE_OPEN == doorState)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiPsdData PsdId %d Is Error: doorState Is %d\n", psdId, doorState); + retVal = CI_ERROR; + } + + /*״̬*/ + if (CI_SUCCESS == retVal) + { + mutualLockState = dataBuf[ii]; + ii++; + if ((PSD_MUTUALLOCK_REMOVE_NO == mutualLockState) || (PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiPsdData PsdId %d Is Error: mutualLockState Is %d\n", psdId, mutualLockState); + retVal = CI_ERROR; + } + } + } + } + else + { + debug_infor_printf((const)"CheckCiToCiPsdData Is Error: PsdId Is %d\n", psdId); + retVal = CI_ERROR; + } + + if (CI_ERROR == retVal) + { + break; + } + else + { + /*ѯһPsd*/ + } + } + } + else + { + /*PSDޣʧ*/ + debug_infor_printf((const)"CheckCiToCiPsdData Is Error: PsdSum Is %d\n", psdSum); + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵ESB +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiEsbData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 belongCiId = 0u; + UINT8 localCiId = 0u; /*ID*/ + + UINT16 esbSum = 0u; /*esb*/ + UINT16 esbId = 0u; /*esb豸ID*/ + UINT8 esdState = 0u; /*ͣť״̬*/ + UINT8 esbCutState = 0u; /*ͣť·״̬*/ + localCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + + /*ͣť*/ + esbSum = ShortFromChar(&dataBuf[ii]); /*ȡͣť*/ + ii += 2u; + + if (ESB_SUM_MAX > esbSum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < esbSum; jj++) + { + esbId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0u < esbId) && (ESB_SUM_MAX > esbId)) + { + belongCiId = GetEsbBelongCiId(esbId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_ESB_LEN - 2u;/*ڱESD״̬Ϣ*/ + } + else + { + /*ͣť״̬*/ + esdState = dataBuf[ii]; + ii++; + if ((ESB_STATE_VALID_NO == esdState) || (ESB_STATE_VALID_YES == esdState)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEsbData esbId %d Is Error: esdState Is %d\n", esbId, esdState); + retVal = CI_ERROR; + } + + + /*ͣť·״̬*/ + if (CI_SUCCESS == retVal) + { + esbCutState = dataBuf[ii]; + ii++; + if ((ESB_CUT_NO == esbCutState) || (ESB_CUT_YES == esbCutState)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiEsbData esbId %d Is Error: esbCutState Is %d\n", esbId, esbCutState); + retVal = CI_ERROR; + } + } + } + } + else + { + debug_infor_printf((const)"CheckCiToCiEsbData Is Error: esbId Is %d\n", esbId); + retVal = CI_ERROR; + } + + if (CI_ERROR == retVal) + { + break; + } + else + { + /*ѯһEsb*/ + } + } + } + else + { + /*ESBޣʧ*/ + debug_infor_printf((const)"CheckCiToCiEsbData Is Error: esbSum Is %d\n", esbSum); + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + + +/* +* УCI͵Ľ· +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiRouteData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 belongCiId = 0u; + UINT8 localCiId = 0u; /*ID*/ + + UINT16 routeSum = 0u; /*·*/ + UINT16 routeId = 0u; /*·豸ID*/ + UINT8 routeState = 0u; /*·״̬*/ + UINT8 routeLevel = 0u; /*·ල*/ + UINT16 utOverlapUnlockCount = 0u;/*UTνʱ*/ + UINT16 ctOverlapUnlockCount = 0u;/*CTνʱ*/ + UINT8 cancleState = 0u; /*·ȡ״̬*/ + UINT8 overLapflag = 0u; /*ñҪձ־*/ + UINT8 routeStateFlag = 0U; /*·׷ٰ־*/ + UINT8 routeZDCFFlag = 0U; /*·Զ־*/ + + localCiId = GetSystemParaLocalCiId(); + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + + /*·*/ + routeSum = ShortFromChar(&dataBuf[ii]); /*ȡ·*/ + ii += 2u; + + if (ROUTE_SUM_MAX > routeSum) + { + retVal = CI_SUCCESS; + for (jj = 0U; jj < routeSum; jj++) + { + routeId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0u < routeId) && (ROUTE_SUM_MAX > routeId)) + { + belongCiId = GetRouteBelongCiId(routeId); + if (belongCiId == localCiId) + { + ii += CICI_ONE_ROUTE_LEN - 2u;/*ڱĽ·״̬Ϣ*/ + } + else + { + /*·״̬*/ + routeState = dataBuf[ii]; + ii++; + retVal = RouteStateValidCheck(routeState); + if (CI_SUCCESS == retVal) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: routeState Is %d\n", routeId, routeState); + } + + /*·ල*/ + if (CI_SUCCESS == retVal) + { + routeLevel = dataBuf[ii]; + ii++; + if ((ROUTE_LEVEL_CBTC == routeLevel) || (ROUTE_LEVEL_BLOC == routeLevel)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: routeLevel Is %d\n", routeId, routeLevel); + retVal = CI_ERROR; + } + } + + /*·ȡ״̬*/ + if (CI_SUCCESS == retVal) + { + utOverlapUnlockCount = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + ctOverlapUnlockCount = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + cancleState = dataBuf[ii]; + ii++; + if ((AUTO_ROUTE_CANCLE_NO == cancleState) || (AUTO_ROUTE_CANCLE_WAIT == cancleState) + || (AUTO_ROUTE_CANCLE_FAIL == cancleState) || (AUTO_ROUTE_CANCLE_SUCCESS == cancleState)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: cancleState Is %d\n", routeId, cancleState); + retVal = CI_ERROR; + } + } + + /*·ձ־*/ + if (CI_SUCCESS == retVal) + { + overLapflag = dataBuf[ii]; + ii++; + if ((OVERLAPCILOCK_YES == overLapflag) || (OVERLAPCILOCK_NO == overLapflag)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: overLapflag Is %d\n", routeId, overLapflag); + retVal = CI_ERROR; + } + } + + /*·׷ٰ־*/ + if (CI_SUCCESS == retVal) + { + routeStateFlag = dataBuf[ii]; + ii++; + if ((ROUTE_STATE_FLAG_YES == routeStateFlag) || (ROUTE_STATE_FLAG_NO == routeStateFlag)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: Zhuizongbanliflag Is %d\n", routeId, routeStateFlag); + retVal = CI_ERROR; + } + } + + /*·Զ־*/ + if (CI_SUCCESS == retVal) + { + routeZDCFFlag = dataBuf[ii]; + ii++; + if ((AUTO_TRIGGER_SET_YES == routeZDCFFlag) || (AUTO_TRIGGER_SET_NO == routeZDCFFlag)) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiRouteData routeId %d Is Error: AutoTriggerflag Is %d\n", routeId, routeZDCFFlag); + retVal = CI_ERROR; + } + } + + } + } + else + { + debug_infor_printf((const)"CheckCiToCiRouteData Is Error: routeId Is %d\n", routeId); + retVal = CI_ERROR; + } + + if (CI_ERROR == retVal) + { + break; + } + else + { + /*ѯһ·*/ + } + } + } + else + { + /*·ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiRouteData Is Error: routeSum Is %d\n", routeSum); + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵ķֽ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiCfpData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 dwTmpIndex = 0u; + UINT16 cfpSum = 0u; /*ֽ*/ + UINT16 cfpId = 0u; /*ֽ豸ID*/ + UINT16 wCfpRelAdjaRcSignalId = 0U; /*ֽRCźŻID*/ + UINT8 cSignalBelongCiId = 0U; + UINT8 cLocalCiId = 0U; + UINT8 cCfpSignalLightUpFlag = 0U; + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + retVal = CI_SUCCESS; + + /*ֽ*/ + cfpSum = ShortFromChar(&dataBuf[ii]); /*ȡֽ*/ + ii += 2u; + + if (CUTOFF_POINT_SUM_MAX >= cfpSum) + { + for (jj = 0U; jj < cfpSum; jj++) + { + cfpId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + dwTmpIndex = GetCfpBufIndex(cfpId); + if (CUTOFF_POINT_SUM_MAX <= dwTmpIndex) + { + retVal = CI_ERROR;/*ֽIDΧ*/ + } + else + { + /*У*/ + retVal = CiToCiEnvelopeCheck(dataBuf, &ii); + + if (CI_SUCCESS == retVal) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpData CiToCiEnvelopeCheck cfpId %d Is Error\n", cfpId); + } + + /*CTгУ*/ + if (CI_SUCCESS == retVal) + { + retVal = CheckCiToCiCfpCTData(dataBuf, &ii); + if (CI_SUCCESS == retVal) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpData CheckCiToCiCfpCTData cfpId %d Is Error\n", cfpId); + } + } + + /*ֽԶRMϢ*/ + if (CI_SUCCESS == retVal) + { + retVal = CheckCiToCiCfpRrmData(dataBuf, &ii); + if (CI_SUCCESS == retVal) + { + ; /*Уͨ*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpData CheckCiToCiCfpRrmData cfpId %d Is Error\n", cfpId); + } + } + + /*ֽRCźŻIDУ*/ + if (CI_SUCCESS == retVal) + { + wCfpRelAdjaRcSignalId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + cLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + cSignalBelongCiId = GetSignalBelongCiId(wCfpRelAdjaRcSignalId); + + if ((0U == wCfpRelAdjaRcSignalId) || ((1U <= wCfpRelAdjaRcSignalId) && (SIGNAL_SUM_MAX > wCfpRelAdjaRcSignalId) && (cSignalBelongCiId == cLocalCiId))) + { + retVal = CI_SUCCESS; /*Уͨ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCfpData CheckCiToCiCfpLightUpSignalId cfpId %d Is Error\n", cfpId); + } + } + else + { + /**/ + } + + /*ֽźŻƱ־У*/ + if (CI_SUCCESS == retVal) + { + cCfpSignalLightUpFlag = dataBuf[ii]; + ii++; + + if ((SIGNAL_SLEEP_TRAIN_LIGHTUP_YES == cCfpSignalLightUpFlag) || (SIGNAL_SLEEP_TRAIN_LIGHTUP_NO == cCfpSignalLightUpFlag)) + { + retVal = CI_SUCCESS; /*Уͨ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CheckCiToCiCfpData CheckCiToCiCfpSignalLightUpFlag cfpId %d Is Error\n", cfpId); + } + } + else + { + /**/ + } + } + + if (CI_ERROR == retVal) + { + break; + } + else + { + ;/*ѯһֽ*/ + } + } + } + else + { + /*·ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiCfpData Is Error: cfpSum Is %d\n", cfpSum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* УCI͵ķֽа +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CiToCiEnvelopeCheck(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 wTrainId = 0U; /*гID*/ + UINT8 chTrainLevel = 0U; /*гȼ*/ + UINT32 dwDis = 0U; /*ֽ*/ + UINT8 chEnvelopeNum = 0U; /*ֽյOCİ*/ + UINT8 chEnvelopeIndex = 0U; + UINT8 envelopeType = 0U; /* */ + UINT16 headTrainID = 0U; /*ǰгID*/ + UINT16 tailTrainID = 0U; /*гID*/ + UINT8 startPosDir = 0U; /*㷽*/ + UINT16 startPosLnk = 0U; /*LINK*/ + UINT32 startPosOff = 0U; /*ƫ*/ + UINT8 endPosDir = 0U; /*յ㷽*/ + UINT16 endPosLnk = 0U; /*յLINK*/ + UINT32 endPosOff = 0U; /*յƫ*/ + UINT8 trianCnt = 0U; /*г*/ + UINT8 chTrainIndex = 0u; + UINT16 envlopetrainID = 0U; + UINT16 ii = 0U; + UINT8 cActivePort = 0U; /*г*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + ii = *index; + /*гID*/ + wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((TRAIN_ID_MIN <= wTrainId) && (TRAIN_ID_MAX >= wTrainId)) + { + retVal = CI_SUCCESS; + } + else if (TRAIN_SUM_MAX >= wTrainId) + { + retVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"CiToCiEnvelopeCheck Is Error: wTrainId Is %d\n", wTrainId); + } + + /*еȼ*/ + if (CI_SUCCESS == retVal) + { + chTrainLevel = dataBuf[ii]; + ii++; + + if ((0u == chTrainLevel) ||(TRAIN_LEVEL_UR == chTrainLevel) + || (TRAIN_LEVEL_ABL == chTrainLevel) || (TRAIN_LEVEL_VBTC == chTrainLevel) || (TRAIN_LEVEL_ITC == chTrainLevel)) + { + ;/*0޳URABLVBTCϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck Is Error: chTrainLevel Is %d\n", chTrainLevel); + } + } + + /*ֽ*/ + if (CI_SUCCESS == retVal) + { + dwDis = LongFromChar(&dataBuf[ii]); + ii += 4u; + + if (UINT32_MAX > dwDis) + { + ; /*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck Is Error: dwDis Is %d\n", dwDis); + } + } + + /*OCİУ*/ + if (CI_SUCCESS == retVal) + { + chEnvelopeNum = dataBuf[ii]; + ii++; + + if (SECTION_REL_ENVELOPE_SUM_MAX >= chEnvelopeNum) + { + for (chEnvelopeIndex = 0u; chEnvelopeIndex < chEnvelopeNum; chEnvelopeIndex++) + { + envelopeType = dataBuf[ii++]; /* */ + if ((TYPE_UKT_ENVELOPE == envelopeType) + || (TYPE_UCT_ENVELOPE == envelopeType) + || (TYPE_CT_ENVELOPE == envelopeType)) + { + ;/*1:ͨų 2ʧͨų 3س*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: envelopeType Is %d\n", chEnvelopeIndex, envelopeType); + } + + + if (CI_SUCCESS == retVal) + { + headTrainID = ShortFromChar(&dataBuf[ii]);/* ǰID */ + ii += 2u; + if (TRAIN_SUM_MAX >= headTrainID) + { + ;/*ǰ/гIDȡֵΧ0-255 ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: headTrainID Is %d\n", chEnvelopeIndex, headTrainID); + } + } + + if (CI_SUCCESS == retVal) + { + tailTrainID = ShortFromChar(&dataBuf[ii]);/* ID */ + ii += 2u; + if (TRAIN_SUM_MAX >= tailTrainID) + { + ;/*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: tailTrainID Is %d\n", chEnvelopeIndex, tailTrainID); + } + } + + if (CI_SUCCESS == retVal) + { + startPosDir = dataBuf[ii++];/* 㷽 */ + if ((EMAP_SAME_DIR == startPosDir) || (EMAP_CONVER_DIR == startPosDir)) + { + ;/*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: startPosDir Is %d\n", chEnvelopeIndex, startPosDir); + } + } + + if (CI_SUCCESS == retVal) + { + startPosLnk = ShortFromChar(&dataBuf[ii]);/* link */ + ii += 2u; + if ((0u < startPosLnk) && (UINT16_MAX > startPosLnk)) + { + ;/*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: startPosLnk Is %d\n", chEnvelopeIndex, startPosLnk); + } + } + + if (CI_SUCCESS == retVal) + { + startPosOff = LongFromChar(&dataBuf[ii]);/* offset */ + ii += 4u; + if (UINT32_MAX > startPosOff) + { + ;/*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: startPosOff Is %d\n", chEnvelopeIndex, startPosOff); + } + } + + if (CI_SUCCESS == retVal) + { + endPosDir = dataBuf[ii++];/* յ㷽 */ + if ((EMAP_SAME_DIR == endPosDir) || (EMAP_CONVER_DIR == endPosDir)) + { + ;/*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: endPosDir Is %d\n", chEnvelopeIndex, endPosDir); + } + } + + if (CI_SUCCESS == retVal) + { + endPosLnk = ShortFromChar(&dataBuf[ii]);/* յlink */ + ii += 2u; + if ((0u < endPosLnk) && (UINT16_MAX > endPosLnk)) + { + ;/*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: endPosLnk Is %d\n", chEnvelopeIndex, endPosLnk); + } + } + + if (CI_SUCCESS == retVal) + { + endPosOff = LongFromChar(&dataBuf[ii]);/* յoffset */ + ii += 4u; + if (UINT32_MAX > endPosOff) + { + ;/*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: endPosOff Is %d\n", chEnvelopeIndex, endPosOff); + } + } + + if (CI_SUCCESS == retVal) + { + trianCnt = dataBuf[ii++];/* г */ + if ((TRAIN_IN_ENVELOPE_SUM_MAX >= trianCnt) && (0U < trianCnt)) + { + for (chTrainIndex = 0u; chTrainIndex < trianCnt; chTrainIndex++) + { + envlopetrainID = ShortFromChar(&dataBuf[ii]);/* гID */ + ii += 2u; + + cActivePort = dataBuf[ii++]; /*г*/ + + if ((TRAIN_SUM_MAX >= envlopetrainID) + && ((TRAIN_ACTIVE_NONE == cActivePort) || (TRAIN_ACTIVE_ONE == cActivePort) + || (TRAIN_ACTIVE_TWO == cActivePort) || (TRAIN_ACTIVE_ALL == cActivePort))) + { + ;/*ݺϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: envlopetrainID Is %d, ActivePort Is %d\n", chEnvelopeIndex, envlopetrainID, cActivePort); + break; + } + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck chEnvelopeIndex %d Is Error: endPosOff Is %d\n", chEnvelopeIndex, endPosOff); + } + } + } + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"CiToCiEnvelopeCheck Is Error: chEnvelopeNum Is %d\n", chEnvelopeNum); + } + } + + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* ͸ѩϢ +* ˵ UINT8 cSrcCiId ͷCI +* UINT8 cDstCiId շCI +* UINT32 dwAreaSnowId ѩվ̨ID +* ֵ +* Created By LQ 2023.11.16 +*/ +void AddCiRecvAreaSnowInfo(UINT8 cSrcCiId, UINT8 cDstCiId, UINT32 dwAreaSnowId) +{ + UINT16 ii = 0U; + UINT8 cKeepWork = CI_ERROR; + + if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId) && (0U != cDstCiId) && (CI_SUM_MAX > cDstCiId) && (0U != dwAreaSnowId)) + { + for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++) + { + /*ѰĿCI*/ + if ((cSrcCiId == szRecvCiAreaSnow[ii].cSourceCiId) && (cDstCiId == szRecvCiAreaSnow[ii].cTargetCiId)) + { + cKeepWork = CI_SUCCESS; + } + else if ((0U == szRecvCiAreaSnow[ii].cSourceCiId) && (0U == szRecvCiAreaSnow[ii].cTargetCiId)) + { + cKeepWork = CI_SUCCESS; + } + else + { + /*ĿCI*/ + } + + if (CI_SUCCESS == cKeepWork) + { + + break; + } + else + { + /**/ + } + } + + if (CI_SUCCESS == cKeepWork) + { + if (CI_TO_CI_AREA_SNOW_SUM_MAX > szRecvCiAreaSnow[ii].cPlatFormNum) + { + /*ѩϢ*/ + szRecvCiAreaSnow[ii].cSourceCiId = cSrcCiId; + szRecvCiAreaSnow[ii].cTargetCiId = cDstCiId; + szRecvCiAreaSnow[ii].dwPlatFormId[szRecvCiAreaSnow[ii].cPlatFormNum] = dwAreaSnowId; + szRecvCiAreaSnow[ii].cPlatFormNum++; + } + else + { + debug_infor_printf((const)"Error in AddCiRecvAreaSnowInfo: PlatFormNum Exceed Max %d!\n", CI_TO_CI_AREA_SNOW_SUM_MAX); + } + } + else + { + debug_infor_printf((const)"Error in AddCiRecvAreaSnowInfo: No TargetCi!\n"); + } + } + else + { + debug_infor_printf((const)"Error in AddCiRecvAreaSnowInfo: Input Data Is Illegal!\n"); + } +} + +/* +* ӱ͸ָIDѩϢ +* ˵ UINT8 cSrcCiId ͷCI +* UINT8 cDstCiId շCI +* UINT32 dwAreaSnowId ѩվ̨ID +* ֵ +*/ +void AddCiSendAreaSnowInfo(UINT8 cSrcCiId, UINT8 cDstCiId, UINT32 dwAreaSnowId) +{ + UINT16 ii = 0U; + UINT8 cKeepWork = CI_ERROR; + UINT8 jj = 0U; + + if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId) && (0U != cDstCiId) && (CI_SUM_MAX > cDstCiId) && (0U != dwAreaSnowId)) + { + for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++) + { + /*ѰĿCI*/ + if ((cSrcCiId == szSendCiAreaSnow[ii].cSourceCiId) && (cDstCiId == szSendCiAreaSnow[ii].cTargetCiId)) + { + cKeepWork = CI_SUCCESS; + } + else if ((0U == szSendCiAreaSnow[ii].cSourceCiId) && (0U == szSendCiAreaSnow[ii].cTargetCiId)) + { + cKeepWork = CI_SUCCESS; + } + else + { + /*ĿCI*/ + } + + if(CI_SUCCESS == cKeepWork) + { + + break; + } + else + { + /**/ + } + } + + if (CI_SUCCESS == cKeepWork) + { + if (CI_TO_CI_AREA_SNOW_SUM_MAX > szSendCiAreaSnow[ii].cPlatFormNum) + { + /*by cgh ȥ*/ + for (jj = 0U; jj < szSendCiAreaSnow[ii].cPlatFormNum; jj++) + { + if (szSendCiAreaSnow[ii].dwPlatFormId[jj] == dwAreaSnowId) + { + break; + } + else + { + ; /**/ + } + } + + if (szSendCiAreaSnow[ii].cPlatFormNum == jj) + { + /*ѩϢ*/ + szSendCiAreaSnow[ii].cSourceCiId = cSrcCiId; + szSendCiAreaSnow[ii].cTargetCiId = cDstCiId; + szSendCiAreaSnow[ii].dwPlatFormId[szSendCiAreaSnow[ii].cPlatFormNum] = dwAreaSnowId; + szSendCiAreaSnow[ii].cPlatFormNum++; + } + else + { + ; /*ظ*/ + } + } + else + { + debug_infor_printf((const)"Error in AddCiSendToCiAreaSnowInfo: PlatFormNum Exceed Max %d!\n", CI_TO_CI_AREA_SNOW_SUM_MAX); + } + } + else + { + debug_infor_printf((const)"Error in AddCiSendToCiAreaSnowInfo: No TargetCi!\n"); + } + } + else + { + debug_infor_printf((const)"Error in AddCiSendToCiAreaSnowInfo: Input Data Is Illegal!\n"); + } +} + +/* +* ȡ͸ѩϢ +* ˵ +* ֵ ͵ѩϢ +* Created By LQ 2023.11.16 +*/ +ToCiAreaSnowStruct* GetCiRecvAreaSnowInfo(void) +{ + return szRecvCiAreaSnow; +} + +/* +* ȡ͸ָIDѩϢ +* ˵ const UINT8 cTargetCiId Ŀ +* ֵ ͵ѩϢ +* Created By LQ 2023.11.16 +*/ +ToCiAreaSnowStruct* GetCiSendAreaSnowInfo(const UINT8 cTargetCiId) +{ + ToCiAreaSnowStruct* retVal = NULL; + UINT16 ii = 0U; + + if ((0U != cTargetCiId) && (CI_SUM_MAX > cTargetCiId)) + { + for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++) + { + if (szSendCiAreaSnow[ii].cTargetCiId == cTargetCiId) + { + retVal = &szSendCiAreaSnow[ii]; + } + else + { + /**/ + } + } + } + else + { + /*ηǷNULL*/ + } + + return retVal; +} + +/* +* ͸ѩϢ +* ˵ const UINT8 cSrcCiId ͷCI +* ֵ +* Created By LQ 2023.11.16 +*/ +void ClearCiRecvAreaSnowInfo(const UINT8 cSrcCiId) +{ + UINT16 ii = 0U; + + if ((0U != cSrcCiId) && (CI_SUM_MAX > cSrcCiId)) + { + for (ii = 0U; ii < CI_COM_CI_MAX_NUM; ii++) + { + if (szRecvCiAreaSnow[ii].cSourceCiId == cSrcCiId) + { + (void)CommonMemSet(&szRecvCiAreaSnow[ii], (UINT32)sizeof(ToCiAreaSnowStruct), 0U, (UINT32)sizeof(ToCiAreaSnowStruct)); + break; + } + else + { + /**/ + } + } + } + else + { + /*ηǷ*/ + } +} + +/* +* ͸ѩϢ +* ˵ +* ֵ +* Created By LQ 2023.11.16 +*/ +void ClearCiSendAreaSnowInfo(void) +{ + (void)CommonMemSet(szSendCiAreaSnow, (UINT32)(CI_COM_CI_MAX_NUM * sizeof(ToCiAreaSnowStruct)), 0U, (UINT32)(CI_COM_CI_MAX_NUM * sizeof(ToCiAreaSnowStruct))); +} + +/* +* УCI͵Ĵѩ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +* Created By LQ 2023.11.16 +*/ +UINT8 CheckCiToCiAreaSnowData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT8 cAreaSnowNum = 0U; /**/ + UINT32 dwPlatFormId = 0U; /*ѩվ̨ID*/ + UINT8 cPlatFormBelongCiId = 0U; /*վ̨*/ + UINT8 localCiId = 0U; /*ID*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + localCiId = GetSystemParaLocalCiId(); + + cAreaSnowNum = dataBuf[ii]; /*ѩվ̨*/ + ii++; + if (CI_TO_CI_AREA_SNOW_SUM_MAX >= cAreaSnowNum) + { + for (jj = 0U; jj < cAreaSnowNum; jj++) + { + /*Уѩվ̨ID*/ + dwPlatFormId = LongFromChar(&dataBuf[ii]); + ii += 4U; + + if ((0U != dwPlatFormId) && (UINT32_MAX > dwPlatFormId)) + { + cPlatFormBelongCiId = GetAreaSnowPlatFormBelongCiId((UINT16)dwPlatFormId); /*ȡѩվ̨*/ + + if ((localCiId != cPlatFormBelongCiId) && (0U != cPlatFormBelongCiId) && (0U != localCiId)) + { + /*Уͨ*/ + } + else + { + /*վ̨Ϊʧ*/ + debug_infor_printf((const)"CheckCiToCiAreaSnowData Is Error: PlatFormBelongCiId Is %d\n", cPlatFormBelongCiId); + retVal = CI_ERROR; + } + } + else + { + debug_infor_printf((const)"CheckCiToCiAreaSnowData Is Error: dwPlatFormId Is %d\n", dwPlatFormId); + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /**/ + } + } + } + else + { + /*ѩվ̨ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiAreaSnowData Is Error: AreaSnowNum Is %d\n", cAreaSnowNum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* УCI͵Ƿظ +* ˵const ToCiCommandDataStruct* pCiRecvCmdStr յCI +* ֵ 0 ظ +* 1 ظ +* Created By LQ 2023.11.22 +*/ +UINT8 CheckCiRecvCmdIsRepeat(const ToCiCommandDataStruct* pCiRecvCmdStr) +{ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0U; + + if (NULL != pCiRecvCmdStr) + { + retVal = CI_SUCCESS; + if (CI_CMD_PHYSEC_USING_APPLY != pCiRecvCmdStr->CommandID) + { + for (ii = 0U; ii < RecvCiCmdDataStruCurSum; ii++) + { + /*ǰ洢ڿҳظ*/ + if ((RecvCiCmdDataStru[ii].SourceCiId == pCiRecvCmdStr->SourceCiId) && (RecvCiCmdDataStru[ii].TargetCiId == pCiRecvCmdStr->TargetCiId) + && (RecvCiCmdDataStru[ii].CommandID == pCiRecvCmdStr->CommandID) && (RecvCiCmdDataStru[ii].Param1 == pCiRecvCmdStr->Param1) && (RecvCiCmdDataStru[ii].Param2 == pCiRecvCmdStr->Param2)) + { + retVal = CI_ERROR; /*ҵظֹͣ0*/ + break; + } + else + { + /*δظ*/ + } + } + } + else + { + /**/ + } + } + else + { + /*ηǷ0*/ + } + + return retVal; +} + +/* +* УCI͵Ķ̬·Ƿظ +* ˵const ToCiDrCmdDataStruct* pCiRecvDrCmdStr յCI̬· +* ֵ 0 ظ +* 1 ظ +* Created By LQ 2023.11.22 +*/ +UINT8 CheckCiRecvDrCmdIsRepeat(const ToCiDrCmdDataStruct* pCiRecvDrCmdStr) +{ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 jj = 0U; + + if (NULL != pCiRecvDrCmdStr) + { + retVal = CI_SUCCESS; + for (ii = 0U; ii < RecvCiDrCmdSum; ii++) + { + /*ǰ洢ڿ̬·ҳظĶ̬·*/ + if ((RecvCiDrCmdDataStru[ii].cSourceCiId == pCiRecvDrCmdStr->cSourceCiId) && (RecvCiDrCmdDataStru[ii].cTargetCiId == pCiRecvDrCmdStr->cTargetCiId) + && (RecvCiDrCmdDataStru[ii].cCmdType == pCiRecvDrCmdStr->cCmdType) && (RecvCiDrCmdDataStru[ii].cLogSecSeqDir == pCiRecvDrCmdStr->cLogSecSeqDir) + && (RecvCiDrCmdDataStru[ii].cLogSecSum == pCiRecvDrCmdStr->cLogSecSum) && (RecvCiDrCmdDataStru[ii].wTrainId == pCiRecvDrCmdStr->wTrainId)) + { + for (jj = 0U; jj < RecvCiDrCmdDataStru[ii].cLogSecSum; jj++) + { + if (RecvCiDrCmdDataStru[ii].wLogSecIdBuff[jj] != pCiRecvDrCmdStr->wLogSecIdBuff[jj]) + { + break; /*߼IDֹͬͣ*/ + } + else + { + /*߼IDͬ*/ + } + } + + if (jj == RecvCiDrCmdDataStru[ii].cLogSecSum) + { + retVal = CI_ERROR; /*߼IDͬظֹͣ0*/ + break; + } + else + { + /*߼IDͬδظ*/ + } + } + else + { + /*δظ*/ + } + + } + } + else + { + /*ηǷ0*/ + } + + return retVal; +} + +/* +* УCI͵ĴķֽԶRM +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +* by cgh 20240221 +*/ +UINT8 CheckCiToCiCfpRrmData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 cRrmSrcRcId = 0U;/* RRMԴRC ID */ + UINT16 wRrmTrainId = 0U;/* RRMгID */ + UINT16 wRrmTrainNextStaId = 0U;/* RRMгһվ̨ID */ + UINT8 chRrmSrcApplyState = 0U;/* ԶRMʱԴTIOC״̬ */ + UINT8 chRrmDstAllowState = 0U;/* ԶRMʱĿTIOC״̬ */ + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + + /*ֽԶRMϢ*/ + cRrmSrcRcId = dataBuf[ii++]; + if (CI_SUM_MAX > cRrmSrcRcId) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpRrmData cRrmSrcRcId %d Is Error\n", cRrmSrcRcId); + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + wRrmTrainId = ShortFromChar(&dataBuf[ii]); /* RRMгID */ + ii += 2U; + if (TRAIN_SUM_MAX > wRrmTrainId) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpRrmData wRrmTrainId[%d] Is Error: TrainId Is Exceed Max %d\n", wRrmTrainId, TRAIN_SUM_MAX); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + if (CI_SUCCESS == retVal) + { + wRrmTrainNextStaId = ShortFromChar(&dataBuf[ii]); /* RRMгһվ̨ID */ + ii += 2U; + if (UINT16_MAX != wRrmTrainNextStaId) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpRrmData wRrmTrainNextStaId %d Is Error: wRrmTrainNextStaId Is Exceed Max %d\n", wRrmTrainNextStaId, UINT16_MAX); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + if (CI_SUCCESS == retVal) + { + + chRrmSrcApplyState = dataBuf[ii++]; /* ԶRMʱԴTIOC״̬ */ + if ((TRAIN_RRM_LOCALCI_NOT_APPLY == chRrmSrcApplyState) || (TRAIN_RRM_LOCALCI_APPLY == chRrmSrcApplyState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpRrmData chRrmSrcApplyState %d Is Error\n", chRrmSrcApplyState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + + if (CI_SUCCESS == retVal) + { + + chRrmDstAllowState = dataBuf[ii++]; /* ԶRMʱĿTIOC״̬ */ + if ((TRAIN_RRM_OTHERCI_ALLOW == chRrmDstAllowState) || (TRAIN_RRM_OTHERCI_NOT_ALLOW == chRrmDstAllowState)) + { + /*У*/ + } + else + { + debug_infor_printf((const)"CheckCiToCiCfpRrmData chRrmDstAllowState %d Is Error\n", chRrmDstAllowState); + retVal = CI_ERROR; + } + } + else + { + /*Уʧ*/ + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + } + + return retVal; +} + +/* +* ʼ跢͵ȥ߼ID,ͨ +* ˵ void +* ֵ سɹ +*/ +UINT8 InitLeaveLogIdBufOfOtherCiByConf(void) +{ + UINT16 ii = 0u; /* α */ + UINT16 jj = 0u; + UINT8 kk = 0u; + UINT8 belongCiId = 0u; /*ID*/ + + CiTransmitStruct* pTmpCiTransmitStru = NULL; + UINT8 reVal = CI_ERROR; + UINT16 routeSum = 0U; + + UINT8 leaveLogBelongCI = 0U; /*һȥID*/ + UINT8 routeBelongCi = 0U; /*·ID*/ + UINT16 leaveLogicSecId = 0U; + UINT16 tmpRouteId = 0U; + + UINT8 checkSumCBTC = 0U; + UINT8 checkSumBloc = 0U; + RouteOtherCheckStruct* dataOtherCiDevBufCBTC = NULL; + RouteOtherCheckStruct* dataOtherCiDevBufBloc = NULL; + UINT8 checkFlag = CI_ERROR; + UINT8 logBelogAxisNum = 0u; + UINT16* logBelogAxisBuff = NULL; + UINT16 phySecId = 0U; + UINT8 phySwitchSum = 0U; + + routeSum = GetRouteCurSum(); /*ȡ·*/ + belongCiId = GetSystemParaLocalCiId(); + reVal = CI_SUCCESS; + /* ״̬ */ + for (ii = 0u; ii < ciTransNum; ii++) + { + pTmpCiTransmitStru = &ciTransmitStruct[ii]; + + if (pTmpCiTransmitStru->srcCiId == belongCiId) + { + pTmpCiTransmitStru->routeleaveLogSumOfOtherCi = 0u; + + /* н· */ + for (jj = 0u; jj < routeSum; jj++) + { + + checkFlag = CI_ERROR; + tmpRouteId = GetRouteId(jj); /*ȡ·ID*/ + routeBelongCi = GetRouteBelongCiId(tmpRouteId);/*·ID*/ + /*ȡ·ⷽһȥ߼*/ + leaveLogicSecId = GetRouteLeaveLogicSecId(tmpRouteId); + leaveLogBelongCI = GetLogSecBelongCiId(leaveLogicSecId); + + /*߼ιļ*/ + logBelogAxisNum = GetLgcSecRelativeAxleSecSum(leaveLogicSecId); + logBelogAxisBuff = GetLgcSecRltvAxleSecIdBuf(leaveLogicSecId); + + /*ȥ߼ι*/ + phySecId= GetLgcSecRelativePhySecId(leaveLogicSecId); + phySwitchSum = GetPhyIncludeSwitchSum(phySecId); /*ΰĵ*/ + + /*·ΪĿȥΪ޲*/ + if ((pTmpCiTransmitStru->destCiId == routeBelongCi)&&(0U == phySwitchSum)&&(1U== logBelogAxisNum)) + { + /*CBTC*/ + checkSumBloc = GetRouteBlocOtherCiSum(tmpRouteId); + dataOtherCiDevBufBloc = GetRouteBlocOtherCiBuf(tmpRouteId); + /*ʽ*/ + checkSumCBTC = GetRouteCbtcOtherCiSum(tmpRouteId); + dataOtherCiDevBufCBTC = GetRouteCbtcOtherCiBuf(tmpRouteId); + + /*·ȥ*/ + if ((NULL != dataOtherCiDevBufBloc) && (NULL != dataOtherCiDevBufCBTC)) + { + for (kk = 0; kk < checkSumBloc; kk++) + { + if ((CI_DEVICE_TYPE_AXISSEC == dataOtherCiDevBufBloc[kk].DevType)&&(dataOtherCiDevBufBloc[kk].DevId== logBelogAxisBuff[0])) + { + checkFlag = CI_SUCCESS; + break; + } + } + + for (kk = 0; kk < checkSumCBTC; kk++) + { + if ((CI_DEVICE_TYPE_AXISSEC == dataOtherCiDevBufCBTC[kk].DevType)&&(dataOtherCiDevBufCBTC[kk].DevId == logBelogAxisBuff[0])) + { + checkFlag = CI_SUCCESS; + break; + } + } + } + else + { + reVal = CI_ERROR; + } + } + if (CI_SUCCESS == checkFlag) + { + + /*ҽ·Ŀȥ߼ڱ*/ + if (leaveLogBelongCI == belongCiId) + { + if (CI_TO_CI_LEAVE_LOGSEC_ROUTE_NUM > pTmpCiTransmitStru->routeleaveLogSumOfOtherCi) + { + /*ȥ*/ + for ( kk = 0; kk < pTmpCiTransmitStru->routeleaveLogSumOfOtherCi; kk++) + { + if (leaveLogicSecId == pTmpCiTransmitStru->wrouteleaveLogIdBufOfOtherCi[kk]) + { + /*߼Ѵ*/ + break; + } + } + if(kk== pTmpCiTransmitStru->routeleaveLogSumOfOtherCi) + { + pTmpCiTransmitStru->wrouteleaveLogIdBufOfOtherCi[pTmpCiTransmitStru->routeleaveLogSumOfOtherCi] = leaveLogicSecId; + pTmpCiTransmitStru->routeleaveLogSumOfOtherCi++; + } + } + else + { + /*ʧ*/ + reVal = CI_ERROR; + break; + } + + } + else + { + ; + } + } + } + } + if (CI_ERROR == reVal) + { + break; + } + + } + + return reVal; +} + +/* +* УCI͵ȥ߼ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +* Created By LQ 2023.11.16 +*/ +UINT8 CheckCiToCiLeaveLogSecData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 leaveLogNum = 0U; /*ȥ*/ + UINT32 dwLogSecId = 0U; /*߼ID*/ + UINT8 checkFlag = 0U; /*־*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + + leaveLogNum =ShortFromChar(&dataBuf[ii]); /*ȥ*/ + ii += 2U; + + if (CI_TO_CI_LEAVE_LOGSEC_ROUTE_NUM >= leaveLogNum) + { + for (jj = 0U; jj < leaveLogNum; jj++) + { + /*У߼ID*/ + dwLogSecId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + checkFlag=dataBuf[ii]; + ii++; + + if ((0U != dwLogSecId) && (LOGIC_SECTION_SUM_MAX > dwLogSecId)) + { + if ((LOGSEC_LEAVE_LOGSEC_REPLY_YES == checkFlag) || (LOGSEC_LEAVE_LOGSEC_REPLY_NO == checkFlag)) + { + ; + } + else + { + /*ʧ*/ + debug_infor_printf((const)"CheckCiToCiLeaveLogSecData Is Error: checkFlag Is %d\n", checkFlag); + retVal = CI_ERROR; + } + } + else + { + debug_infor_printf((const)"CheckCiToCiLeaveLogSecData Is Error: dwLogSecId Is %d\n", dwLogSecId); + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + /**/ + } + } + } + else + { + /*ȥޣʧ*/ + debug_infor_printf((const)"CheckCiToCiLeaveLogSecData Is Error: leaveLogNum Is %d\n", leaveLogNum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ʼ跢͵Ҫ״̬Ľ· +* ˵ void +* ֵ CI_SUCCESS ʼɹ +* CI_ERROR ʼʧ +* by cgh 20241202 +*/ +UINT8 InitNeedCheckSwitchStaRoute(void) +{ + UINT8 chReVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 wRouteCurSum = 0U;/*·ǰ*/ + UINT16 jj = 0U; + UINT8 chLocalCiId = 0U;/*ID*/ + CiTransmitStruct* pTmpCiTransmitStru = NULL; + UINT16 wRouteId = 0U;/*·ID*/ + UINT8 chRouteExistLocalCiSwFlag = 0U;/*·ڱ*/ + CiTransmitStruct* pDestCiTransmitStru = NULL;/*Ŀ*/ + + wRouteCurSum = GetRouteCurSum(); + chLocalCiId = GetSystemParaLocalCiId(); + + if (0U == ciTransNum) + { + /*ԳݴҪʼɹ*/ + chReVal = CI_SUCCESS; + } + else + { + for (ii = 0u; ii < ciTransNum; ii++) + { + pTmpCiTransmitStru = &ciTransmitStruct[ii]; + if (NULL != pTmpCiTransmitStru) + { + chReVal = CI_SUCCESS; + if (chLocalCiId == pTmpCiTransmitStru->destCiId) + { + /*Ľ·Ȼ·Ҫøݽ·*/ + pDestCiTransmitStru = GetDstCiTransInfo(pTmpCiTransmitStru->srcCiId); + if (NULL != pDestCiTransmitStru) + { + pDestCiTransmitStru->wNeedCheckSwitchStateRouteSum = 0U; + for (jj = 0U; jj < wRouteCurSum; jj++) + { + wRouteId = GetRouteId(jj); + chRouteExistLocalCiSwFlag = GetOthCiRouteExistLocalCiSw(wRouteId); + if (pTmpCiTransmitStru->srcCiId == chRouteExistLocalCiSwFlag) + { + /*ȡҪݣ*/ + if (ROUTE_SUM_MAX > pDestCiTransmitStru->wNeedCheckSwitchStateRouteSum) + { + pDestCiTransmitStru->szNeedCheckSwStateRouteBuf[pDestCiTransmitStru->wNeedCheckSwitchStateRouteSum] = wRouteId; + pDestCiTransmitStru->wNeedCheckSwitchStateRouteSum++; + } + else + { + chReVal = CI_ERROR; + break; + } + } + else + { + ; /**/ + } + } + } + } + else + { + ; /*ҽշԼ*/ + } + } + else + { + ; + } + + if (CI_ERROR == chReVal) + { + break; + } + else + { + ; /*ʼ*/ + } + } + } + + return chReVal; +} + +/* +* УCI͵Ҫ״̬Ľ· +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +* by cgh 20241202 +*/ +UINT8 CheckCiToCiNeedCheckSwRouteData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 wNeedCheckRouteSum = 0U; /*Ҫ·Ŀ*/ + UINT32 wNeedCheckRouteId = 0U; /*Ҫ·ID*/ + UINT8 chRouteApplySwitchCheckFlag = 0U;/*·־*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + retVal = CI_SUCCESS; + ii = *index; + + wNeedCheckRouteSum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + if (ROUTE_SUM_MAX > wNeedCheckRouteSum) + { + for (jj = 0U; jj < wNeedCheckRouteSum; jj++) + { + wNeedCheckRouteId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + if ((0U < wNeedCheckRouteId) && (ROUTE_SUM_MAX > wNeedCheckRouteId)) + { + chRouteApplySwitchCheckFlag = dataBuf[ii]; + ii++; + if ((ROUTE_APPLY_SWITCH_CHECK_NO == chRouteApplySwitchCheckFlag) || (ROUTE_APPLY_SWITCH_CHECK_YES == chRouteApplySwitchCheckFlag)) + { + ; + } + else + { + /*ʧ*/ + debug_infor_printf((const)"CheckCiToCiLeaveLogSecData Is Error: chRouteApplySwitchCheckFlag Is %d\n", chRouteApplySwitchCheckFlag); + retVal = CI_ERROR; + } + } + else + { + debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: wNeedCheckRouteId Is %d\n", wNeedCheckRouteId); + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + break; + } + else + { + ; /**/ + } + } + } + else + { + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiNeedCheckSwRouteData Is Error: wNeedCheckRouteSum Is %d\n", wNeedCheckRouteSum); + retVal = CI_ERROR; + } + *index = ii; + } + else + { + /*Уʧܣʧ*/ + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ʼҪɱ״̬ı +* ˵void +* ֵ1 ɹ +* 0 ʧ +* Created By LQ 2024.12.03 +*/ +UINT8 InitNeedCheckProSwtStaOverlap(void) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 wOverlapCurSum = 0U; /*εǰ*/ + UINT8 cLocalCiId = 0U; /*ID*/ + CiTransmitStruct* pTmpCiTransmitStru = NULL; /*ǰ*/ + CiTransmitStruct* pDestCiTransmitStru = NULL; /*Ŀ*/ + UINT16 wOverlapId = 0U; /*ID*/ + UINT8 cCheckFlag = 0U; + + wOverlapCurSum = GetOverlapCurSum(); + cLocalCiId = GetSystemParaLocalCiId(); + cRetVal = CI_SUCCESS; + + for (ii = 0U; ii < ciTransNum; ii++) + { + pTmpCiTransmitStru = &ciTransmitStruct[ii]; + if (NULL != pTmpCiTransmitStru) + { + if (cLocalCiId == pTmpCiTransmitStru->destCiId) + { + /*ҪñαȻҪڽӿнд*/ + pDestCiTransmitStru = GetDstCiTransInfo(pTmpCiTransmitStru->srcCiId); + if (NULL != pDestCiTransmitStru) + { + pDestCiTransmitStru->wNeedCheckProSwtStateOlpNum = 0U; /*ʼ0*/ + for (jj = 0U; jj < wOverlapCurSum; jj++) + { + wOverlapId = GetOverlapId(jj); + cCheckFlag = CheckOtherCiOlpHaveLocalCiPSw(wOverlapId); /*Ƿзڱ*/ + if (pTmpCiTransmitStru->srcCiId == (UINT16)cCheckFlag) + { + if (OVERLAP_SUM_MAX > pDestCiTransmitStru->wNeedCheckProSwtStateOlpNum) + { + /*ڱεķڱ¼˱*/ + pDestCiTransmitStru->szNeedCheckProSwtStateOlpIdBuf[pDestCiTransmitStru->wNeedCheckProSwtStateOlpNum] = wOverlapId; + pDestCiTransmitStru->wNeedCheckProSwtStateOlpNum++; + } + else + { + cRetVal = CI_ERROR; + break; + } + } + else + { + /*ӣ*/ + } + } + } + else + { + /*Էݣ˵Էݽã*/ + } + } + else + { + /*ҽշԼ*/ + } + } + else + { + cRetVal = CI_ERROR; /*ݻȡ󣬷ʧ*/ + } + + if (CI_ERROR == cRetVal) + { + break; /*ʼʧ*/ + } + else + { + /**/ + } + } + + return cRetVal; +} + +/* +* УCI͵Ҫ״̬ı +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ0 Уʧ +* 1 Уɹ +* Created By LQ 2024.12.03 +*/ +UINT8 CheckCiToCiNeedCheckSwOlpData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 wNeedCheckOverlapNum = 0U; /*Ŀ*/ + UINT16 wNeedCheckOverlapId = 0U; /*ID*/ + UINT8 cProSwCheckResultFlag = 0U; /*־*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + cRetVal = CI_SUCCESS; + ii = *index; + + wNeedCheckOverlapNum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + if (OVERLAP_SUM_MAX > wNeedCheckOverlapNum) + { + for (jj = 0U; jj < wNeedCheckOverlapNum; jj++) + { + wNeedCheckOverlapId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + if ((0U < wNeedCheckOverlapId) && (OVERLAP_SUM_MAX > wNeedCheckOverlapId)) + { + cProSwCheckResultFlag = dataBuf[ii]; + ii++; + if ((PROSWITCH_CHECK_RESULT_INVALID == cProSwCheckResultFlag) || (PROSWITCH_CHECK_RESULT_VALID == cProSwCheckResultFlag)) + { + /**/ + } + else + { + /*Ƿʧ*/ + debug_infor_printf((const)"CheckCiToCiNeedCheckSwOlpData Is Error: ProSwCheckResultFlag Is %d\n", cProSwCheckResultFlag); + cRetVal = CI_ERROR; + } + } + else + { + /*IDǷʧ*/ + debug_infor_printf((const)"CheckCiToCiNeedCheckSwOlpData Is Error: NeedCheckOverlapId Is %d\n", wNeedCheckOverlapId); + cRetVal = CI_ERROR; + } + + if (CI_SUCCESS != cRetVal) + { + break; + } + else + { + ; /**/ + } + } + } + else + { + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiNeedCheckSwOlpData Is Error: NeedCheckOverlapNum Is %d\n", wNeedCheckOverlapNum); + cRetVal = CI_ERROR; + } + + *index = ii; /**/ + } + else + { + cRetVal = CI_ERROR; /*Уʧܣʧ*/ + } + + return cRetVal; +} + +/* +* УCI͵ķ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ0 Уʧ +* 1 Уɹ +* Created By LQ 2024.12.04 +*/ +UINT8 CheckCiToCiProSwPLockData(const UINT8* dataBuf, UINT16* index) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 kk = 0U; + UINT16 wProSwNum = 0U; /*Ŀ*/ + UINT16 wProSwId = 0U; /*ID*/ + UINT8 cPLockRouteNum = 0U; /*յĽ·*/ + UINT16 wPLockRouteId = 0U; /*յĽ·ID*/ + UINT8 cPLockOverlapNum = 0U; /*յı*/ + UINT16 wPLockOverlapId = 0U; /*յıID*/ + + if ((NULL != dataBuf) && (NULL != index)) + { + cRetVal = CI_SUCCESS; + ii = *index; + + wProSwNum = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + if (SWITCH_SUM_MAX > wProSwNum) + { + for (jj = 0U; jj < wProSwNum; jj++) + { + wProSwId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + if ((0U < wProSwId) && (SWITCH_SUM_MAX > wProSwId)) + { + cPLockRouteNum = dataBuf[ii]; /*ս·*/ + ii++; + if (SWITCH_MAX_PROTECT_LOCKED_NUM >= cPLockRouteNum) + { + for (kk = 0U; kk < cPLockRouteNum; kk++) + { + wPLockRouteId = ShortFromChar(&dataBuf[ii]); /*ս·ID*/ + ii += 2U; + + if ((0 < wPLockRouteId) && (ROUTE_SUM_MAX > wPLockRouteId)) + { + + } + else + { + /*ս·IDǷʧ*/ + debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: PLockRouteId Is %d\n", wPLockRouteId); + cRetVal = CI_ERROR; + break; + } + } + } + else + { + /*ս·ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: PLockRouteNum Is %d\n", cPLockRouteNum); + cRetVal = CI_ERROR; + } + + if (CI_SUCCESS == cRetVal) + { + cPLockOverlapNum = dataBuf[ii]; /*ձ*/ + ii++; + if (SWITCH_MAX_PROTECT_LOCKED_NUM >= cPLockOverlapNum) + { + for (kk = 0U; kk < cPLockOverlapNum; kk++) + { + wPLockOverlapId = ShortFromChar(&dataBuf[ii]); /*ձID*/ + ii += 2U; + + if ((0 < wPLockOverlapId) && (OVERLAP_SUM_MAX > wPLockOverlapId)) + { + + } + else + { + /*ձIDǷʧ*/ + debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: PLockOverlapId Is %d\n", wPLockOverlapId); + cRetVal = CI_ERROR; + break; + } + } + } + else + { + /*ձޣʧ*/ + debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: PLockOverlapNum Is %d\n", cPLockOverlapNum); + cRetVal = CI_ERROR; + } + } + else + { + /*УʧܣУ*/ + } + } + else + { + /*IDǷʧ*/ + debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: ProSwitchId Is %d\n", wProSwId); + cRetVal = CI_ERROR; + } + + if (CI_SUCCESS != cRetVal) + { + break; + } + else + { + ; /**/ + } + } + } + else + { + /*ޣʧ*/ + debug_infor_printf((const)"CheckCiToCiProSwPLockData Is Error: ProSwitchNum Is %d\n", wProSwNum); + cRetVal = CI_ERROR; + } + + *index = ii; /**/ + } + else + { + cRetVal = CI_ERROR; /*Уʧܣʧ*/ + } + + return cRetVal; +} + +/* +* ʼҪõķ +* ˵void +* ֵ1 ɹ +* 0 ʧ +* edit cgh 20241224 +*/ +UINT8 InitNeedOlapUsingOtherCiProSw(void) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cLocalCiId = 0U; /*ID*/ + UINT16 wOverlapCurSum = 0U; /*εǰ*/ + UINT16 ii = 0U; + CiTransmitStruct* pTmpCiTransmitStru = NULL; /*ǰ*/ + UINT16 jj = 0U; + UINT16 wOverlapId = 0U; /*ID*/ + UINT8 cOverlapBelongCiId = 0U; + UINT8 cOverlapRelProSwNum = 0U; /*ιķ*/ + OverlapProtectSwitchStruct* pOverlapRelProSwStru = NULL; /*ιķϢ*/ + UINT8 cSwitchBelongCiId = 0U; + UINT8 kk = 0U; + UINT16 mm = 0U; + UINT16 wRouteCurSum = 0U;/*·ǰ*/ + UINT16 wRouteId = 0U;/*·ID*/ + UINT8 chRouteBelCiId = 0U;/*·ID*/ + UINT8 chRouteProSwitchSum = 0U;/*·Ŀ*/ + RouteProtectSwitchStruct* szRouteProSwitchData = NULL;/*·*/ + + cLocalCiId = GetSystemParaLocalCiId(); + wOverlapCurSum = GetOverlapCurSum(); + cRetVal = CI_SUCCESS; + wRouteCurSum = GetRouteCurSum(); + + for (ii = 0U; ii < ciTransNum; ii++) + { + pTmpCiTransmitStru = &ciTransmitStruct[ii]; + if (NULL != pTmpCiTransmitStru) + { + if ((cLocalCiId == pTmpCiTransmitStru->srcCiId) && (0U != pTmpCiTransmitStru->srcCiId)) + { + pTmpCiTransmitStru->wSwitchSumOfOtherCi = 0U; /*ʼ0*/ + for (jj = 0U; jj < wOverlapCurSum; jj++) + { + wOverlapId = GetOverlapId(jj); + cOverlapBelongCiId = GetOverlapBelongCiId(wOverlapId); /*ȡ*/ + if (cLocalCiId == cOverlapBelongCiId) + { + cOverlapRelProSwNum = GetOverlapRelatedProtSwitSum(wOverlapId); /*ȡιķϢ*/ + pOverlapRelProSwStru = GetOverlapRelatedProtSwitStru(wOverlapId); + + if (NULL != pOverlapRelProSwStru) + { + for (kk = 0U; kk < cOverlapRelProSwNum; kk++) + { + cSwitchBelongCiId = GetSwitchBelongCiId(pOverlapRelProSwStru[kk].ProtectSwitchId); + if ((0U != cSwitchBelongCiId) && (pTmpCiTransmitStru->destCiId == cSwitchBelongCiId)) + { + /*ڶԷȥؼӸõ*/ + for (mm = 0U; mm < pTmpCiTransmitStru->wSwitchSumOfOtherCi; mm++) + { + /*ȥؼ*/ + if (pOverlapRelProSwStru[kk].ProtectSwitchId == pTmpCiTransmitStru->szSwitchIdBufOfOtherCi[mm]) + { + break; + } + else + { + /*Ƿ*/ + } + } + + if (mm == pTmpCiTransmitStru->wSwitchSumOfOtherCi) + { + /*δӸõ*/ + if (SWITCH_SUM_MAX > pTmpCiTransmitStru->wSwitchSumOfOtherCi) + { + pTmpCiTransmitStru->szSwitchIdBufOfOtherCi[pTmpCiTransmitStru->wSwitchSumOfOtherCi] = pOverlapRelProSwStru[kk].ProtectSwitchId; /*ӱõķDZID*/ + pTmpCiTransmitStru->wSwitchSumOfOtherCi++; + } + else + { + cRetVal = CI_ERROR; /*ޣʧ*/ + break; + } + } + else + { + /*õӻѴޣ*/ + } + } + else + { + /*ڱ*/ + } + } + } + else + { + cRetVal = CI_ERROR; /*ݻȡ󣬷ʧ*/ + break; + } + } + else + { + /*DZΣ*/ + } + } + + /*ڿ·еڱ*/ + if (CI_SUCCESS == cRetVal) + { + for (jj = 0U; jj < wRouteCurSum; jj++) + { + wRouteId = GetRouteId(jj); + chRouteBelCiId = GetRouteBelongCiId(wRouteId); /*ȡ·*/ + + if (cLocalCiId == chRouteBelCiId) + { + chRouteProSwitchSum = GetRouteRelatedProtectSwitchSum(wRouteId); + szRouteProSwitchData = GetRouteRelatedProtSwitchData(wRouteId); + + if (NULL != szRouteProSwitchData) + { + for (kk = 0U; kk < chRouteProSwitchSum; kk++) + { + cSwitchBelongCiId = GetSwitchBelongCiId(szRouteProSwitchData[kk].ProtectSwitchId); + if ((0U != cSwitchBelongCiId) && (pTmpCiTransmitStru->destCiId == cSwitchBelongCiId)) + { + /*ڶԷȥؼӸõ*/ + for (mm = 0U; mm < pTmpCiTransmitStru->wSwitchSumOfOtherCi; mm++) + { + /*ȥؼ*/ + if (szRouteProSwitchData[kk].ProtectSwitchId == pTmpCiTransmitStru->szSwitchIdBufOfOtherCi[mm]) + { + break; + } + else + { + /*Ƿ*/ + } + } + + if (mm == pTmpCiTransmitStru->wSwitchSumOfOtherCi) + { + /*δӸõ*/ + if (SWITCH_SUM_MAX > pTmpCiTransmitStru->wSwitchSumOfOtherCi) + { + pTmpCiTransmitStru->szSwitchIdBufOfOtherCi[pTmpCiTransmitStru->wSwitchSumOfOtherCi] = szRouteProSwitchData[kk].ProtectSwitchId; /*ӱõķDZID*/ + pTmpCiTransmitStru->wSwitchSumOfOtherCi++; + } + else + { + cRetVal = CI_ERROR; /*ޣʧ*/ + break; + } + } + else + { + /*õӻѴޣ*/ + } + } + else + { + /*ڱ*/ + } + } + } + else + { + cRetVal = CI_ERROR; /*ݻȡ󣬷ʧ*/ + break; + } + } + else + { + /*DZ·*/ + } + } + } + else + { + ; /*ʧ*/ + } + } + else + { + /*ʼ*/ + } + } + else + { + cRetVal = CI_ERROR; /*ݻȡ󣬷ʧ*/ + } + + if (CI_ERROR == cRetVal) + { + break; /*ʼʧ*/ + } + else + { + /**/ + } + } + + return cRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackCiData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackCiData.h new file mode 100644 index 0000000..c19955d --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackCiData.h @@ -0,0 +1,916 @@ +/******************************************************** +* +* ParsePackCiData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* CIݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_CI_DATA_H_ +#define _PARSE_PACK_CI_DATA_H_ + + +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "ParsePackAtsData.h" +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../ParsePack/CiInterfaceDefine.h" +#include "../FloodGate/FloodGateDefine.h" +#include "../CutoffPoint/CutoffPointConfigDataManage.h" +#include "SectionStateProcess_define.h" +#include "../SPKS/SpksDefine.h" +#include "../Relay/RelayDataManage.h" + +#define HLHT_CI_INTER_TYPE ((UINT16)0x0606)/*ͨCI-CIӿ*/ +#define HLHT_CI_INTER_VER ((UINT8)0x01)/*ͨCI-CIЭ汾*/ + +#define SWITCH_STATUS_PACKET ((UINT16)0x0201) /*״̬Ϣ*/ + +#define PHYSIC_SEC_STATUS_PACKET ((UINT16)0x0202) /*״̬Ϣ*/ + +#define LOGIC_SEC_STATUS_PACKET ((UINT16)0x0203) /*߼״̬Ϣ*/ + +#define SIGNAL_STATUS_PACKET ((UINT16)0x0204) /*źŻ״̬Ϣ*/ + +#define PSD_STATUS_PACKET ((UINT16)0x0205) /*վ̨״̬Ϣ*/ + +#define EMERGEBTN_STATUS_PACKET ((UINT16)0x0206) /*رհť״̬Ϣ*/ + +#define ZHAOCHA_STATUS_PACKET ((UINT16)0x0207) /*ղ״̬Ϣ*/ + +#define FLOOD_GATE_STATUS_PACKET ((UINT16)0x0208) /*״̬Ϣ*/ + +#define START_LOCK_STATUS_PACKET ((UINT16)0x0209) /*ϵ״̬Ϣ*/ + +#define LINSHI_XIANSU_STATUS_PACKET ((UINT16)0x020a) /*ʱϢ*/ + +#define CITY_DEF_STATUS_PACKET ((UINT16)0x020b) /*ԶϢ*/ + +#define MANUFAC_DEF_STATUS_PACKET ((UINT16)0x020c) /*ԶϢ*/ + +#define PSD_NUM_PER_BYTE ((UINT8)2) /*PSDֽڳ*/ +#define BIT_NUM_PER_PSD ((UINT8)(8U / PSD_NUM_PER_BYTE)) /*PSDֽڳ*/ +#define ESB_NUM_PER_BYTE ((UINT8)4) /*ͣťֽڳ*/ +#define BIT_NUM_PER_ESB ((UINT8)(8 / ESB_NUM_PER_BYTE)) /*ֽͣڳ*/ + +#define ZCJ_NUM_PER_BYTE ((UINT8)4) /*ͣťֽڳ*/ +#define BIT_NUM_PER_ZCJ ((UINT8)(8U / ZCJ_NUM_PER_BYTE)) /*ֽͣڳ*/ + +#define TSR_NUM_PER_BYTE ((UINT8)4) /*TSRťֽڳ*/ +#define BIT_NUM_PER_TSR ((UINT8)(8U / TSR_NUM_PER_BYTE)) /*TSRֽڳ*/ + + +#define PACKET_LENGTH_LEN ((UINT8)2) /*ܳ*/ +#define PACKET_TYPE_LEN ((UINT8)2) /*ͳ*/ +#define PACKET_EMPTY_LEN ((UINT8)2) /*Ԥֽڳ*/ + +#define BIT_MASK_00000011B ((UINT8)0X03) + +#define BIT_VAL_00000000B ((UINT8)0X00) +#define BIT_VAL_00000001B ((UINT8)0X01) +#define BIT_VAL_00000010B ((UINT8)0X02) +#define BIT_VAL_00000011B ((UINT8)0X03) +#define BIT_VAL_00010001B ((UINT8)0x11) +#define BIT_VAL_00010010B ((UINT8)0x12) +#define BIT_VAL_00010100B ((UINT8)0x14) +#define BIT_VAL_00011000B ((UINT8)0x18) +#define BIT_VAL_11111111B ((UINT8)0xFF) + +/*ϵñ־*/ +#define HLHT_STARTLOCK_SET_NO ((UINT8)0xaa) /*δ*/ +#define HLHT_STARTLOCK_SET_YES ((UINT8)0x55) /**/ + +/*͵շǷȡ־*/ +#define PHYSEC_LOCKDIRECTION_OPPST_NO ((UINT8)0x55) /*ȡ*/ +#define PHYSEC_LOCKDIRECTION_OPPST_YES ((UINT8)0xAA) /*ȡ*/ +#define PHYSEC_LOCKDIRECTION_OPPST_DEFAULT ((UINT8)0xFF) /*Ĭֵ*/ + +#define CICI_VERSION ((UINT16)23) /*ciciӿڰ汾ţÿ޸ĽӿҪ汾šLast Modified On 2025.03.10*/ +#define CICI_BEGIN_TO_STATION_LEN ((UINT16)16) /*ӿʼվֹ cgh4ֽCI-CIУϢ*/ +#define CICI_ONE_SWITCH_LEN ((UINT16)13) /*һݳ*/ +#define CICI_ONE_PHYSEC_LEN ((UINT16)23U)/*һݳ*/ +#define CICI_ONE_LOGSEC_LEN ((UINT16)10)/*һ߼ݳ*/ +#define CICI_ONE_SIGNAL_LEN ((UINT16)9)/*һźŻݳ*/ +#define CICI_ONE_PSD_LEN ((UINT16)4)/*һݳ*/ +#define CICI_ONE_ESB_LEN ((UINT16)4)/*һESBݳ*/ +#define CICI_ONE_ROUTE_LEN ((UINT16)12)/*һ·ݳ*/ +#define CICI_ONE_PHYSEC_LOCKSTATE_LEN ((UINT16)10)/*һ״̬ݳ*/ +#define CICI_ONE_SPKS_LEN ((UINT16)4) /*һSPKSݳ*/ +#define CICI_ONE_VIRTUAL_RELAY_LEN ((UINT16)3) /*һSPKSݳ*/ +#define CICI_ONE_FLOODGATE_LEN ((UINT16)7) /*һݳ*/ +#define CICI_ONE_OVERLAP_LEN ((UINT16)16)/*һݳ*/ +#define CICI_ONE_LOGSEC_LOCKSTATE_LEN ((UINT16)12)/*һ߼״̬ݳ*/ +#define CICI_ONE_CUT_OFFPOINT_LEN ((UINT16)9)/*һֽݳ*/ +#define CICI_ONE_CMD_LEN ((UINT16)6) /*һ*/ +#define CICI_ONE_DR_CMD_LEN ((UINT16)16) /*һ̬·*/ +#define CICI_ONE_AUTOROUTE_LEN (UINT16)(3) /*һԶͨ·*/ + +/*䶯̬·*/ +#define CICI_DR_CMD_HALF ((UINT8)0x55) /*ӽ·*/ +#define CICI_DR_CMD_FULL ((UINT8)0xaa) /*ӽ·*/ +#define CICI_DR_CMD_LOGIC ((UINT8)0xbb) /*߼ӽ·*/ + +/*ݽṹ*/ +typedef struct S_IntconPhySecDataStruct +{ + UINT8 RLockState; /*ν·״̬ (ֶ̬)*/ + UINT8 PLockState; /*α״̬ (ֶ̬)*/ + UINT8 LockDirect; +}IntconPhySecDataStrut; + +#ifdef __cplusplus +extern "C" { +#endif + + /*֡ṹ*/ + typedef struct S_ToCiCommandDataStruct + { + UINT8 SourceCiId; /*ͷID*/ + UINT8 TargetCiId; /*շID*/ + UINT16 CommandID; /*ID*/ + UINT32 CycleNo; /**/ + UINT16 Param1; /*1*/ + UINT16 Param2; /*2*/ + } ToCiCommandDataStruct; + + /*վվϢṹ*/ + typedef struct S_BordCiToXianDiDataStruct + { + UINT8 CiId; /*ID*/ + UINT16 MaskDataLen; /*վϢ*/ + UINT8 MaskData[CI_TO_ATS_DATA_LEN_MAX]; /*λ*/ + + }BordCiToXianDiDataStruct; + + /* ͨ豸 */ + typedef struct S_CI_TRANSMIT_STRU + { + UINT16 srcCiId;/*ͷCI*/ + + UINT16 destCiId; /* ĿID */ + UINT16 signalNum; /* źŻ */ + UINT16 signalIdBuf[SIGNAL_SUM_MAX]; + UINT16 phySecNum; /* */ + UINT16 phySecIdBuf[PHYSICAL_SECTION_SUM_MAX]; + UINT16 phySecIdLockDirFlag[PHYSICAL_SECTION_SUM_MAX];/*շǷȡ־*/ + UINT16 logicSecNum; /* ߼ */ + UINT16 logicSecIdBuf[LOGIC_SECTION_SUM_MAX]; + UINT16 switchNum; /* */ + UINT16 switchIdBuf[SWITCH_SUM_MAX]; + UINT16 psdNum; /* */ + UINT16 psdIdBuf[PSD_SUM_MAX]; + UINT16 esbNum; /* ͣť */ + UINT16 esbIdBuf[ESB_SUM_MAX]; + UINT16 routeNum; + UINT16 routeIdBuf[ROUTE_SUM_MAX]; /* ·Ϣ */ + UINT16 overlapNum; + UINT16 overlapIdBuf[OVERLAP_SUM_MAX]; /* Ϣ */ + UINT16 phySecIdBufSumhOfOtherCi; /* */ + UINT16 wPhySecIdBufOfOtherCi[PHYSICAL_SECTION_SUM_MAX]; + UINT16 spksNum; /* Ҫ͵SPKS */ + UINT16 spksIdBuff[SPKS_SUM_MAX]; /* SPKSť */ + UINT16 zcjNum; /* Ҫ͵ZCJ */ + UINT16 zcjIdBuf[ZCJ_SUM_MAX]; /* ZCJ IdBuf */ + UINT16 floodGateNum; /*跢ͷ*/ + UINT16 floodGateIdBuf[FLOOD_GATE_SUM_MAX];/*跢͵ķ*/ + UINT16 autoRouteNum; /* Ҫ͵Զͨ· */ + UINT16 autoRouteIdBuf[AUTO_ROUTE_SUM_MAX]; /* Զͨ· */ + /*ֽ*/ + UINT16 wCutoffPointNum; /*跢ͷֽ*/ + UINT16 wCutoffPointBuf[CUTOFF_POINT_SUM_MAX]; /*跢ͷֽIDbuff*/ + UINT16 routeleaveLogSumOfOtherCi; /* 跢ȥμ߼ */ + UINT16 wrouteleaveLogIdBufOfOtherCi[CI_TO_CI_LEAVE_LOGSEC_ROUTE_NUM];/* 跢ȥμ߼IDbuff */ + UINT16 wNeedCheckSwitchStateRouteSum; /*Ҫ״̬Ľ·Ŀ*/ + UINT16 szNeedCheckSwStateRouteBuf[ROUTE_SUM_MAX]; /*Ҫ״̬Ľ·ID*/ + UINT16 wNeedCheckProSwtStateOlpNum; /*Ҫ״̬ı*/ + UINT16 szNeedCheckProSwtStateOlpIdBuf[OVERLAP_SUM_MAX]; /*Ҫ״̬ıID*/ + UINT16 wSwitchSumOfOtherCi; /*漰õ*/ + UINT16 szSwitchIdBufOfOtherCi[SWITCH_SUM_MAX]; /*漰õ*/ + } CiTransmitStruct; + + /* TIOCͨų */ + typedef struct + { + UINT8 chTiocId; /* TIOC */ + UINT8 chCtNum; /* ͨų */ + UINT16 szCtId[TRAIN_SUM_MAX]; /* гID */ + UINT8 chEaTrainNum; /* ɢ */ + UINT16 szEaTrainId[EA_MAX_NUM]; /* ɢгID */ + UINT8 szPaType[EA_MAX_NUM]; /* ɢ */ + UINT32 dwEaBuildCyc[EA_MAX_NUM]; /* ɢʱ */ + }TiocTransmitCtStruct; + + /*䲿·ṹ*/ + typedef struct S_ToCiDrCmdDataStruct + { + UINT8 cSourceCiId; /*ͷID*/ + UINT8 cTargetCiId; /*շID*/ + UINT8 cCmdType; /**/ + UINT8 cLogSecSeqDir; /*߼з*/ + UINT8 cLogSecSum; /*ֽ·߼*/ + UINT16 wLogSecIdBuff[MAX_ROUTE_IN_LT_NUM]; /*ֽ·߼*/ + UINT16 wTrainId; /*гID*/ + UINT8 cTrainLocLogSecSum; /*г߼*/ + UINT16 wTrainLocLogSecIdBuff[SIZE_MAX_SECTION_BT_TRAIN]; /*г߼*/ + UINT8 cSwitchMoveFlag; /*ؽ·ɶ־*/ + UINT32 CycleNo; /**/ + UINT16 wRelStartSignalId; /*׸߼ιʼźŻID*/ + }ToCiDrCmdDataStruct; + + /*RCѩվ̨Ϣ*/ + typedef struct S_ToCiAreaSnowStruct + { + UINT8 cSourceCiId; /*ͷID*/ + UINT8 cTargetCiId; /*շID*/ + UINT8 cPlatFormNum; /*ѩվ̨*/ + UINT32 dwPlatFormId[CI_TO_CI_AREA_SNOW_SUM_MAX]; /*ѩվ̨ͨID*/ + } ToCiAreaSnowStruct; + + /*******************************ȫֱ*******************************/ + extern ToCiCommandDataStruct RecvCiCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX]; + extern UINT16 RecvCiCmdDataStruCurSum; + extern ToCiCommandDataStruct SendCiCmdDataStru[SENDCI_CMD_DATA_STRU_SUM_MAX]; + extern UINT16 SendCiCmdDataStruCurSum; + extern UINT16 PhySecIdBufOfOtherCi[PHYSICAL_SECTION_SUM_MAX]; + extern UINT8 PhySecIdBufSumhOfOtherCi; + extern UINT16 ciTransNum; + extern TiocTransmitCtStruct g_szTiocCt[TRANSMIT_OBJECT_DEVICE_SUM_MAX]; + extern UINT8 g_transmitTiocNum; + extern ToCiDrCmdDataStruct RecvCiDrCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX]; + extern UINT8 RecvCiDrCmdSum; + extern ToCiDrCmdDataStruct SendCiDrCmdDataStru[RECVCI_CMD_DATA_STRU_SUM_MAX]; + extern UINT8 SendCiDrCmdSum; + extern ToCiAreaSnowStruct szRecvCiAreaSnow[CI_COM_CI_MAX_NUM]; + extern ToCiAreaSnowStruct szSendCiAreaSnow[CI_COM_CI_MAX_NUM]; + +/* +* CI +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 ParseCiToCiData(void); + +/* +* CI֡ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseCiToCiDataFrame(UINT8* dataBuf, UINT16 dataLength); + +/* +* УCI䵥֡ +* ˵ UINT8* dataBuf Ϣ +* UINT16 dataLength ݳ +* UINT8 *errNo Уʧܹ +* ֵ CI_ERROR:Уʧ +* CI_SUCCESS:Уɹ +*/ +UINT8 ParseCiToCiDataCheck(UINT8* dataBuf, UINT16 dataLength, UINT8 *errNo); + +/* +* CI +* ˵ UINT8 targetDeviceId, Ŀ豸ID +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 PackCiToCiData(UINT8 targetDeviceId); + + + +/* +* ȡ״̬ȨID +* ˵ void +* ֵ 0: ȡʧ +* >0: ״̬ID +*/ +UINT8 GetPhySecIdBufSumhOfOtherCi(void); + +/* +* ȡ״̬ȨID +* ˵ const UINT16 bufIndex, ID± +* ֵ 0: ȡʧ +* >0: ״̬ID +*/ +UINT16 GetPhySecIdBufOfOtherCi(const UINT16 bufIndex); + + +/* +* CI +* ˵ targetDeviceId ĿID +* ֵ void +*/ +void ClearPackCICmdData(UINT8 targetDeviceId); + +/* +* ȡCICIṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: ṹ鳤 +*/ +UINT16 GetCiRecvCiCmdStruCurSum(void); + +/* +* ȡCICIṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +ToCiCommandDataStruct *GetCiRecvCiCmdDataStruct(void); + +/* +* CI͵Ϣ +* ˵ UINT8 cmdID, ID +* UINT16 cmdParam1, 1 +* UINT16 cmdParam2, 2 +* UINT8 toCiId, ͵ID +* ֵ 0: ʧ +* 1: ӳɹ +*/ +void AddCiSendToCiCmdInfo(UINT8 cmdID, UINT16 cmdParam1, UINT16 cmdParam2, UINT8 toCiId); + +/* +* ʼ״̬ȨID,ͨ +* ˵ void +* ֵ سɹ +*/ +UINT8 InitPhySecIdBufOfOtherCiByConf(void); + +/* +* 鱾״̬ȨIDǷ +* ˵ const UINT8 chDetCiId ĿID +* const UINT16 wPhySecId ID +* ֵ CI_SUCCESS δ +* CI_ERROR +* edit cgh 20240107 +*/ +UINT8 CheckPhyBufOfOtherCiExist(const UINT8 chDetCiId, const UINT16 wPhySecId); + +/* +* CIյ +* ˵ void +* ֵ void +*/ +void ClearCiRevCiCmdData(void); + +/* +* ͨӿڵCICI +* ˵ +UINT8* dataBuf,ֽ֡ +const UINT16 dataLength,ֽ֡Чݵij +const UINT8 systemId,ͷ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseCiToCiDataFrameHLHT(UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId); + +/* +* ȡָCI->CIĽӿ +* ˵ srcId CIݵID +* ֵ NULLʧ NULL 豸 +*/ +CiTransmitStruct* GetSrcCiTransInfo(UINT8 srcId); +/* +* ȡCI->ָCIĽӿ +* ˵ dstId ĿCI +* ֵ NULLʧ NULL 豸 +*/ +CiTransmitStruct* GetDstCiTransInfo(UINT8 dstId); + +/* +: +ͨ +: +UINT8 targetDeviceId ĿID +: +QueueStruct* ciToCiDataQueue ݶָ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +UINT8 PackHLHTCiToCiData(UINT8 targetDeviceId); + +/* +* УCICI֡ݳȺϷ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 totalLength, ܳ +* UINT8 * errNo,ַ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 CheckCi2CiDataLenValid(const UINT8* dataBuf, const UINT16 totalLength,UINT8 * errNo); + +/** +* @brief ʼTIOCӿͨų¼ +* @param +* @return +* @note +*/ +void TiocTransCtInit(void); + +/** +* @brief ȡָTIOCͨų洢 +* @param +* @return +* @note +*/ +UINT8 GetTiocTransmitIndex(UINT8 chTiocId); + +/** +* @brief ȡָTIOCͨų +* @param +* @return +* @note +*/ +UINT8 GetTiocTransmitCtNum(UINT8 chTiocId); + +/** +* @brief ȡָTIOCͨųID +* @param +* @return IDַ +* @note +*/ +UINT16 * GetTiocTransmitCtIds(UINT8 chTiocId); + +/** +* @brief ȡָTIOCɢ +* @param +* @return +* @note +*/ +UINT8 GetTiocTransmitEaNum(UINT8 chTiocId); + +/** +* @brief ȡָTIOCɢID +* @param +* @return IDַ +* @note +*/ +UINT16 * GetTiocTransmitEaIds(UINT8 chTiocId); + +/** +* @brief ȡָTIOC +* @param +* @return ͵ַ +* @note +*/ +UINT8 * GetTiocTransmitPaTypes(UINT8 chTiocId); + +/** +* @brief ȡָTIOCɢʱ +* @param +* @return ͵ַ +* @note +*/ +UINT32 * GetTiocTransmitPaBuildCyc(UINT8 chTiocId); + +/* +* CI̬· +* ˵ targetDeviceId ĿID +* ֵ void +* +*/ +void ClearPackCiDrCmdData(UINT8 targetDeviceId); + +/* +* CI͵̬·߼Ϣ +* ˵ UINT8 cmdType +* UINT8 logSecSqeDir ߼з +* UINT8 logSecSum ߼ +* UINT16 logSecIdBuff[] ߼ID +* UINT8 toCiId ͵ID +*/ +void AddCiSendToCiDrCmdLogSecInfo(UINT8 cmdType, UINT8 logSecSqeDir, UINT8 logSecSum, UINT16 logSecIdBuff[], UINT8 toCiId); + +/* +* CI͵̬·İؽ·Ϣ +* ˵ UINT16 trainId гID +* UINT8 trainLocLogSecSum г߼ +* UINT16 trainLocLogSecIdBuff[] г߼ID +* UINT8 switchMoveFlag ؽ·ɶ־ +* UINT16 startSignalId ׸߼ιʼźŻID +*/ +void AddCiSendToCiDrCmdHalfInfo(UINT16 trainId, UINT8 trainLocLogSecSum, UINT16 trainLocLogSecIdBuff[], UINT8 switchMoveFlag, UINT16 startSignalId); + +/* +* ȡCICI̬·ṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetCiRecvCiDrCmdStruCurSum(void); + +/* +* ȡCICI̬·ṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +ToCiDrCmdDataStruct* GetCiRecvCiDrCmdDataStruct(void); + +/* +* CIյ̬· +* ˵ +* ֵ +*/ +void ClearCiRevCiDrCmdData(void); + +/* +* УCI汾ϢID +* ˵ const UINT8* dataBuf Ϣ +* UINT8* Index (Σ) +* ֵ CI_ERROR:Уʧ +* CI_SUCCESS:Уɹ +*/ +UINT8 CheckCiIDAndVer(const UINT8* dataBuf, UINT8* Index); + +/* +* УCI͵Ĵĵ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiSwitchData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵Ĵ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiPhySecData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵Ĵ߼ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiLogSecData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵ĴźŻ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiSignalData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵Ĵ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiCommandData(const UINT8* dataBuf, UINT16* index); + + +/* +* УCI͵Ĵķ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiFloodGateData(const UINT8* dataBuf, UINT16* index); + + +/* +* УCI͵Ĵı +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiOverlapData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵ĴԶͨ· +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiAutoRouteData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵ı߼ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiLogicLockData(const UINT8* dataBuf, UINT16* index); + +/* +* У鶯̬·Ϣ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiDrCmdData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵ĴĹ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiCommonPhyLockData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵ĴSPKS +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiSpksData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵Ĵ̵ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiVirRelayData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵Ĵɢ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiEaData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵Ĵķֽͨų +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiCfpCTData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵PSD +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiPsdData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵ESB +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiEsbData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵Ľ· +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiRouteData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵ķֽ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CheckCiToCiCfpData(const UINT8* dataBuf, UINT16* index); + + +/* +* УCI͵ķֽа +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +*/ +UINT8 CiToCiEnvelopeCheck(const UINT8* dataBuf, UINT16* index); + +/* +* ͸ѩϢ +* ˵ UINT8 cSrcCiId ͷCI +* UINT8 cDstCiId շCI +* UINT32 dwAreaSnowId ѩվ̨ID +* ֵ +* Created By LQ 2023.11.16 +*/ +void AddCiRecvAreaSnowInfo(UINT8 cSrcCiId, UINT8 cDstCiId, UINT32 dwAreaSnowId); + +/* +* ӱ͸ָIDѩϢ +* ˵ UINT8 cSrcCiId ͷCI +* UINT8 cDstCiId շCI +* UINT32 dwAreaSnowId ѩվ̨ID +* ֵ +* Created By LQ 2023.11.16 +*/ +void AddCiSendAreaSnowInfo(UINT8 cSrcCiId, UINT8 cDstCiId, UINT32 dwAreaSnowId); + +/* +* ȡ͸ѩϢ +* ˵ +* ֵ ͵ѩϢ +* Created By LQ 2023.11.16 +*/ +ToCiAreaSnowStruct* GetCiRecvAreaSnowInfo(void); + +/* +* ȡ͸ָIDѩϢ +* ˵ const UINT8 cTargetCiId Ŀ +* ֵ ͵ѩϢ +* Created By LQ 2023.11.16 +*/ +ToCiAreaSnowStruct* GetCiSendAreaSnowInfo(const UINT8 cTargetCiId); + +/* +* ͸ѩϢ +* ˵ const UINT8 cSrcCiId ͷCI +* ֵ +* Created By LQ 2023.11.16 +*/ +void ClearCiRecvAreaSnowInfo(const UINT8 cSrcCiId); + +/* +* ͸ѩϢ +* ˵ +* ֵ +* Created By LQ 2023.11.16 +*/ +void ClearCiSendAreaSnowInfo(void); + +/* +* УCI͵Ĵѩ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +* Created By LQ 2023.11.16 +*/ +UINT8 CheckCiToCiAreaSnowData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵Ƿظ +* ˵const ToCiCommandDataStruct* pCiRecvCmdStr յCI +* ֵ 0 ظ +* 1 ظ +* Created By LQ 2023.11.22 +*/ +UINT8 CheckCiRecvCmdIsRepeat(const ToCiCommandDataStruct* pCiRecvCmdStr); + +/* +* УCI͵Ķ̬·Ƿظ +* ˵const ToCiDrCmdDataStruct* pCiRecvDrCmdStr յCI̬· +* ֵ 0 ظ +* 1 ظ +* Created By LQ 2023.11.22 +*/ +UINT8 CheckCiRecvDrCmdIsRepeat(const ToCiDrCmdDataStruct* pCiRecvDrCmdStr); + +/* +* УCI͵ĴķֽԶRM +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +* by cgh 20240221 +*/ +UINT8 CheckCiToCiCfpRrmData(const UINT8* dataBuf, UINT16* index); + + +/* +* ʼ跢͵ȥ߼ID,ͨ +* ˵ void +* ֵ سɹ +*/ +UINT8 InitLeaveLogIdBufOfOtherCiByConf(void); + +/* +* УCI͵ȥ߼ +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +* Created By LQ 2023.11.16 +*/ +UINT8 CheckCiToCiLeaveLogSecData(const UINT8* dataBuf, UINT16* index); + +/* +* ʼ跢͵Ҫ״̬Ľ· +* ˵ void +* ֵ CI_SUCCESS ʼɹ +* CI_ERROR ʼʧ +* by cgh 20241202 +*/ +UINT8 InitNeedCheckSwitchStaRoute(void); + +/* +* УCI͵Ҫ״̬Ľ· +* ˵const UINT8* dataBuf ݣ +* UINT16* index +* ֵ 0 Уʧ +* 1 Уɹ +* by cgh 20241202 +*/ +UINT8 CheckCiToCiNeedCheckSwRouteData(const UINT8* dataBuf, UINT16* index); + +/* +* ʼҪɱ״̬ı +* ˵void +* ֵ1 ɹ +* 0 ʧ +* Created By LQ 2024.12.03 +*/ +UINT8 InitNeedCheckProSwtStaOverlap(void); + +/* +* УCI͵Ҫ״̬ı +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ0 Уʧ +* 1 Уɹ +* Created By LQ 2024.12.03 +*/ +UINT8 CheckCiToCiNeedCheckSwOlpData(const UINT8* dataBuf, UINT16* index); + +/* +* УCI͵ķ +* ˵const UINT8* dataBuf +* UINT16* index +* ֵ0 Уʧ +* 1 Уɹ +* Created By LQ 2024.12.04 +*/ +UINT8 CheckCiToCiProSwPLockData(const UINT8* dataBuf, UINT16* index); + +/* +: +ͨͷڶ +: + +: +UINT8 * pInputData ݻָ +UINT16 appDataLen Ӧݳ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +UINT8 PackHlhtPacketHeadPha2(UINT8 * pInputData, UINT16 appDataLen); + +/* +: +ͨͷһ +: +UINT8 dstCiId ĿID +: +UINT8 * pInputData ݻָ +UINT16 * pHeadDataLen ͷȱָ +UINT8 * * ppLenItemAddr ͷдӦóȵĵַָ +ֵ: +CI_SUCCESS,ɹ;CI_ERROR,ʧ. +*/ +UINT8 PackHlhtPacketHeadPha1(UINT8 dstCiId, UINT8 * pInputData, UINT16 * pHeadDataLen, UINT8 * * ppLenItemAddr); + +/* +* ʼҪõķ +* ˵void +* ֵ1 ɹ +* 0 ʧ +* Created By LQ 2024.12.17 +*/ +UINT8 InitNeedOlapUsingOtherCiProSw(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackCommon.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackCommon.c new file mode 100644 index 0000000..7d9949c --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackCommon.c @@ -0,0 +1,4776 @@ +/******************************************************** +* +* ParsePackCommon.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-05-11 +* ߣ +* ͨú +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackCommon.h" +#include "../LogicProcess/InterlockLogicCheck.h" +#include "TrainOnAcManage.h" +#include "SignalDataManage.h" +#include "SignalConfigDataManage.h" +#include "SwitchDataManage.h" +#include "SwitchConfigDataManage.h" +#include "PhysicalSectionConfigDataManage.h" +#include "ESBConfigDataManage.h" +#include "PSDConfigDataManage.h" +#include "../Deployment/DeploymentExtern.h" +#include "MSCP_APP_API.h" +#include "ParsePackAtsData.h" +#include "ParsePackOcData.h" +#include "../DataManage/PlatDataManage.h" +#include "dquCIInterFace.h" +#include "NonAutoReturnDataManage.h" + +#include "2oo2InterfaceDataManage.h" + +PlatHeartDataStruct RecvHeartDataStru = { 0U }; /*ƽ̨֡ݽṹ*/ +PlatGPIODataStruct RecvPlatDataStruGPIO = { 0U };/*ƽ̨0x2D֡ݽṹ GPIOɼ״̬*/ + +/* +* źŻλ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*1zt 2022.02.28 źŻ쳣رλ +*/ +UINT8 SignalMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_SUCCESS;/*Ĭλɹ*/ + UINT16 ii = 0u; + UINT16 statrSigRtSum = 0u; + UINT16* startSigRouteBuf = NULL; + UINT16 tmpRtId = 0u; + UINT8 tmpRtState = 0u; + UINT8 sigDetainFlag = 0u;/*źŻ۳־*/ + UINT8 curColor = 0u;/*źŻǰʾɫ*/ + UINT8 getState = 0u; + UINT8 chZqxFlag = 0U; + UINT8 chZrjFlag = 0U; + UINT8 sigEnginVehicCrossCloseSte = 0u; + UINT8 signalBoardState = 0u; + UINT8 cancelDetainBtnErrFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; /*ȡ۳ťϱ־*/ + UINT8 detainBtnErrFlag = SIGNAL_ZFS_BTN_ERR_FLAG_NO; /*۳ťϱ־*/ + UINT8 SignalCrossState = 0U; + UINT8 SigVobcCrossInPhyOccSta = 0U; + + switch (MaskType) + { + case MASK_TYPE_SIGNAL_RED:/*λ*/ + if ((SIGNAL_SHOWCOLOUR_RED == GetSignalCurColor(DeviceId)) + + || (SIGNAL_SHOWCOLOUR_REDCLOSE == GetSignalCurColor(DeviceId))) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_SIGNAL_YELLOW:/*Ƶλ*/ + { + if ((SIGNAL_SHOWCOLOUR_YELLOW == GetSignalCurColor(DeviceId)) + || (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == GetSignalCurColor(DeviceId))) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + + } + break; + case MASK_TYPE_SIGNAL_GREEN:/*̵λ*/ + + if ((SIGNAL_SHOWCOLOUR_GREEN == GetSignalCurColor(DeviceId)) + || (SIGNAL_SHOWCOLOUR_GREENCLOSE == GetSignalCurColor(DeviceId))) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + + break; + case MASK_TYPE_SIGNAL_REDYELLOW:/*Ƶλ*/ + if ((SIGNAL_SHOWCOLOUR_REDYELLOW == GetSignalCurColor(DeviceId)) || (SIGNAL_SHOWCOLOUR_RED_WHITE == GetSignalCurColor(DeviceId))) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SIGNAL_DOUBLE_GREEN:/*˫λ*/ + { + if ((SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == GetSignalCurColor(DeviceId))) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + } + break; + case MASK_TYPE_SIGNAL_DOUBLE_YELLOW:/*˫λ*/ + { + if ((SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == GetSignalCurColor(DeviceId))) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + } + break; + case MASK_TYPE_SIGNAL_GREEN_YELLOW:/*̻λʾ̻ƻ*/ + { + curColor = GetSignalCurColor(DeviceId); + if ((SIGNAL_SHOWCOLOUR_GREENYELLOW == curColor) || + (SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == curColor)) + {/*̻ƻ̻̻λ1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + } + break; +#if 0 + case MASK_TYPE_SIGNAL_BLUE: + { + if (1 == sigColorWuhanBlue) + { + SetMaskValue(MaskId,dataBuf); + } + else + { + + } + } + break; +#endif + case MASK_TYPE_SIGNAL_WHITE:/*׵λ*/ + if (SIGNAL_SHOWCOLOUR_WHITE == GetSignalCurColor(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SIGNAL_FENGSUO:/*λ*/ + if (SIGNAL_FENGSUO_NO == GetSignalFLockState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_SIGNAL_CLOSE_ABNORMAL:/*쳣رλ*/ + /*ԸźŻΪʼźŻĽ·һ·״̬Ϊӽ쳣Ԥա쳣1*/ + statrSigRtSum = GetStartSignalRouteSum(DeviceId);/*ȡԸźŻΪʼźŻĽ·Ŀ*/ + startSigRouteBuf = GetStartSignalRouteBuf(DeviceId);/*ȡԸźŻΪʼźŻĽ·*/ + if (0u != statrSigRtSum) + { + for (ii = 0u; ii < statrSigRtSum; ii++) + { + tmpRtId = startSigRouteBuf[ii]; + tmpRtState = GetRouteState(tmpRtId);/*ȡ·״̬*/ + if ((ROUTE_STATE_NEAR_LOCKERR == tmpRtState) + || (ROUTE_STATE_YUXIAN_LOCK == tmpRtState) + || (ROUTE_STATE_FIRST_LOCKERR == tmpRtState) + || (ROUTE_STATE_LEAD_LOCKERR == tmpRtState) + || (ROUTE_STATE_AUTO_UNLOCKERR == tmpRtState) + || (ROUTE_STATE_DELAY_UNLOCK == tmpRtState)) + {/*·״̬Ϊӽ쳣Ԥա쳣*/ + curColor = GetSignalCurColor(DeviceId); + getState = GetSignalOpenCloseState(curColor); + chZqxFlag = GetRouteZongQuXiaoFlag(tmpRtId); + chZrjFlag = GetRouteZongRenJieFlag(tmpRtId); + if ((SIGNAL_OPEN != getState) + && (ROUTE_ZONGQUXIAO_SET_NO == chZqxFlag) + && (ROUTE_ZONGRENJIE_SET_NO == chZrjFlag)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + ; + } + break; + } + } + } + break; + case MASK_TYPE_SIGNAL_OPENSTATE:/*CI-ZCλ״̬λݽӿ˵飬·0 */ +#if 0 + if ((SIGNAL_OPEN == GetSignalOpenCloseState(GetSignalCurColor(DeviceId))) + && (SIGNAL_SHOWCOLOUR_REDYELLOW != GetSignalCurColor(DeviceId))) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } +#endif + /*ԸźŻΪʼźŻĽ·һ·״̬ΪԤȿŻӽ1*/ + statrSigRtSum = GetStartSignalRouteSum(DeviceId);/*ȡԸźŻΪʼźŻĽ·Ŀ*/ + startSigRouteBuf = GetStartSignalRouteBuf(DeviceId);/*ȡԸźŻΪʼźŻĽ·*/ + if (0u != statrSigRtSum) + { + for (ii = 0u; ii < statrSigRtSum; ii++) + {/*źŻΪʼźŻĿŵĽ·ID*/ + tmpRtId = startSigRouteBuf[ii]; + tmpRtState = GetRouteState(tmpRtId);/*ȡ·״̬*/ + if ((ROUTE_STATE_YUXIAN_OPEN == tmpRtState) || (ROUTE_STATE_NEAR_OPEN == tmpRtState)) + {/*ҵŵĽ·Ϳλ*/ + SetMaskValue(MaskId, dataBuf); + break; + } + } + } + break; + case MASK_ZC_CI_TYPE_SIGNAL_OCCUPYED:/*ͨųѹͨźŻ״̬λ*/ + if (SIGNAL_CROSS_STATE_YES == GetSignalCrossState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_CI_ZC_SIGNAL_OCCUPYED_REC:/*CI-ZCѹźŻ״̬ȷλ*/ + SignalCrossState = GetSignalCrossState(DeviceId); + SigVobcCrossInPhyOccSta = GetSigVobcCrossInPhyOccSta(DeviceId); + if ((SIGNAL_CROSS_STATE_YES == SignalCrossState) && (SECTION_OCCUPY_YES == SigVobcCrossInPhyOccSta)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_SIGNAL_LIGHTSTATE:/*źŻ״̬λ*/ + if ((SIGNAL_SHOWCOLOUR_REDCLOSE == GetSignalCurColor(DeviceId)) + || (SIGNAL_SHOWCOLOUR_GREENCLOSE == GetSignalCurColor(DeviceId)) + || (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == GetSignalCurColor(DeviceId)) + || (SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == GetSignalCurColor(DeviceId)) + ) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SIGNAL_BREAK:/*źŻ˿λ*/ + if (SIGNAL_SHOWCOLOUR_REDBREAK == GetSignalCurColor(DeviceId)) + { + + } + else + { + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_SIGNAL_CENTER_DETAIN:/*˹۳λ*/ + sigDetainFlag = GetSignalATSDetainFlag(DeviceId);/*ȡźŻ۳־*/ + if ((SIGNAL_ATS_DETAIN_NO == sigDetainFlag)|| (SIGNAL_ATS_DETAIN_AUTO_YES == sigDetainFlag)) + { + /*δĿ۳,1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*Ŀ۳,0*/ + } + break; + case MASK_TYPE_SIGNAL_AUTO_DERAIN:/*Զ۳λ*/ + sigDetainFlag = GetSignalATSDetainFlag(DeviceId);/*ȡźŻ۳־*/ + if ((SIGNAL_ATS_DETAIN_NO == sigDetainFlag)|| (SIGNAL_ATS_DETAIN_YES == sigDetainFlag)) + { + /*δԶ۳,1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*Զ۳,0*/ + } + break; + case MASK_TYPE_SIGNAL_LOCAL_DETAIN:/*վ۳λ*/ + sigDetainFlag = GetSignalLocalDetainFlag(DeviceId);/*ȡźŻ۳־*/ + if (SIGNAL_XIANDI_DETAIN_NO == sigDetainFlag) + { + /*δվ۳,1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*վ۳,0*/ + } + break; + case MASK_TYPE_SIGNAL_RELAY_DETAIN:/*Ӳ߿۳λ*/ + sigDetainFlag = GetSignalRelayDetainFlag(DeviceId);/*ȡźŻӲ߿۳־*/ + if (SIGNAL_RELAY_DETAIN_NO == sigDetainFlag) + { + /*δӲ߿۳,1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*Ӳ߿۳,0*/ + } + break; + case MASK_TYPE_SIGNAL_LINSHIXIANSU_SET:/*źŻʱλ*/ + if (SIGNAL_LINSHIXIANSUSET_STATE_YES == GetSignalLinShiXianSuSetFlag(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_SIGNAL_MAINTAINSTATE:/*CI-ATSźŻά޵״̬λ*/ + getState = GetSignalMaintainState(DeviceId); + if (MAINTAIN_STATE_YES == getState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_CI_ZC_SIG_ENGINCROSS_STE:/*CI-ZC ̳ѹصλ*/ + sigEnginVehicCrossCloseSte = GetSigEnginVehicCrossCloseSte(DeviceId); + if (ENGIN_VEHIC_CROSSCLOSE_STE_YES == sigEnginVehicCrossCloseSte) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*0*/ + } + break; + case MASK_ZC_CI_SIG_ENGINEERV_NEAR:/*ZC-CI ̳ӽλ*/ + break; + case MASK_TYPE_SIGNAL_OC_BOARD_FAULT: /*CI-ATS OCźŻ忨ϱλ-WGY*/ + signalBoardState = GetSignalBoardState(DeviceId); + if (OC_SIGNAL_BOARD_FAULT_YES == signalBoardState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*0*/ + } + break; + case MASK_TYPE_SIGNAL_CANCEL_DET_ERR: + cancelDetainBtnErrFlag = GetSignalCancelDetainBtnErrFlag(DeviceId); + if (SIGNAL_ZFS_BTN_ERR_FLAG_YES == cancelDetainBtnErrFlag) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*λֵ0*/ + } + break; + case MASK_TYPE_SIGNAL_DET_ERR: + detainBtnErrFlag = GetSignalDetainBtnErrFlag(DeviceId); + if (SIGNAL_ZFS_BTN_ERR_FLAG_YES == detainBtnErrFlag) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*λֵ0*/ + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 SwitchMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + UINT8 switchLockStatus = 0U; + UINT8 switchCurPosition = 0U; + UINT8 switchLockState = 0U; + UINT8 switchConnectDsState = 0U; + UINT8 switchByPassState = 0U; + UINT16 i = 0U; + UINT8 k = 0U; + UINT8 flagFind = 0U; + UINT16 indexFind = 0U; + UINT8 devBelongThisLine = 0U; + UINT8 switchBoardNum = 0U; + UINT8 switchStateCheck = CI_ERROR; + + switchLockStatus = GetSwitchLockStatus(DeviceId); + + switch (MaskType) + { + case MASK_TYPE_SWITCH_DINGWEI: + /*λλ*/ + switchCurPosition = GetSingleSwitchCurPosition(DeviceId); + if (SWITCH_POSITION_DINGWEI == switchCurPosition) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SWITCH_FANWEI: + /*λλ*/ + switchCurPosition = GetSingleSwitchCurPosition(DeviceId); + if (SWITCH_POSITION_FANWEI == switchCurPosition) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SWITCH_DINGWEI_LOGIC: + /*λ߼λ*/ + switchCurPosition = GetSwitchCurPosition(DeviceId); + if (SWITCH_POSITION_DINGWEI == switchCurPosition) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SWITCH_FANWEI_LOGIC: + /*λ߼λ*/ + switchCurPosition = GetSwitchCurPosition(DeviceId); + if (SWITCH_POSITION_FANWEI == switchCurPosition) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SWITCH_MOVING: + /*ƶλ*/ + switchCurPosition = GetSingleSwitchCurPosition(DeviceId); + if (SWITCH_POSITION_MOVE == switchCurPosition) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SWITCH_SIKAI: + /*Ŀλ*/ + switchCurPosition = GetSingleSwitchCurPosition(DeviceId); + if (SWITCH_POSITION_SIKAI == switchCurPosition) + { + + } + else + { + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_SWITCH_DYNAMIC_JICHA: + /*̬λ*/ + switchCurPosition = GetSwitchJichaState(DeviceId); + + if (SWITCH_POSITION_DYNAMIC_JICHA == switchCurPosition) + { + ; /*ЧֵΪ0*/ + } + else + { + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_SWITCH_DANSUO: + /*λ*/ + devBelongThisLine = GetSwitchIsThisLineState(DeviceId); + if (DEV_IS_THIS_LINE_YES == devBelongThisLine) + { + switchConnectDsState = GetConnetSwitchDsState(DeviceId); + if ((SWITCH_LOCK_STATUS_NO == switchLockStatus) || (SWITCH_LOCK_STATUS_PROTECT == switchLockStatus)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + } + else + { + switchConnectDsState = GetConnetSwitchDsState(DeviceId); + if (((SWITCH_LOCK_STATUS_NO == switchLockStatus) || (SWITCH_LOCK_STATUS_PROTECT == switchLockStatus)) + && (CONNECT_SWITCH_DANSUO_NO == switchConnectDsState)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + } + + break; + case MASK_TYPE_SWITCH_FENGSUO: + /*λ*/ + switchLockState = GetSwitchFLockState(DeviceId); + if (SWITCH_LOCK_FENGSUO_NO == switchLockState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_SWITCH_YINDAOSUO: + /*λ*/ + switchLockState = GetSwitchYLockState(DeviceId); + if (SWITCH_LOCK_YINZONG_NO == switchLockState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_SWITCH_PROTECTLOCK: + /*λ*/ + if ((SWITCH_LOCK_STATUS_NO == switchLockStatus) || (SWITCH_LOCK_STATUS_DANSUO == switchLockStatus)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_SWITCH_LOCKSTATE: + /*״̬λ*/ + switchLockState = GetSwitchRouteLockState(DeviceId); + if (CI_SUCCESS == switchLockState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SWITCH_BYPASS: + switchByPassState = GetConnetSwitchByPassState(DeviceId); + if (SWITCH_BYPASS_YES == switchByPassState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_SWITCH_OPEN_CAP: + for (i = 0u; i < m_SwitchNum; i++) + { + if (m_Switches[i].DeviceId == DeviceId) + { + flagFind = 1u; + indexFind = i; + break; + } + } + if (1u == flagFind) + { + /*忨״̬һϵǿ״̬*/ + switchBoardNum = m_Switches[indexFind].BoardNum; + for (k = 0u; k < switchBoardNum; k++) + { + if (OC_SWITCH_OPEN_CAP_STATE == (m_Switches[indexFind].BoardState[k] & OC_SWITCH_OPEN_CAP_STATE)) + { + SetMaskValue(MaskId, dataBuf); + break; + } + else + { + ; /**/ + } + } + } + break; + case MASK_TYPE_SWITCH_SUDDEN_JICHA: + /*̬λ*/ + switchCurPosition = GetSwitchJichaState(DeviceId); + + if (SWITCH_POSITION_SUDDEN_JICHA == switchCurPosition) + { + ; /*ЧֵΪ0*/ + } + else + { + SetMaskValue(MaskId, dataBuf); + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 PhySectionMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + UINT8 localCiType = GetLocalCiType(); /**/ + UINT8 lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY); /*·*/ + UINT16 phyId = 0u; + UINT8 swSum = 0u; + UINT8 switchCurPosition = 0u; + AxisSwitchStruct* axisSwitchStru = NULL; + UINT8 swPosRight = 1u;/*0 1ȷ*/ + UINT8 iIndex = 0u; + UINT8 physecPreResetSta = PHYSICAL_SECTION_PRE_RESET_NO; /*Ԥλ״̬ʱ*/ + UINT8 jumpState = 0u;/*Ծ״̬*/ + UINT8 funcSwitchJumpLockDriveSwitch = 0u;/*ܿأԾǷ*/ + UINT8 lockDir = 0u;/*շ*/ + UINT8 lockState = 0u;/*״̬*/ + UINT16 routeLockBelongRouteID = 0u;/*··ID*/ + UINT16 protectLockBelongRouteID = 0u;/*·ID*/ + UINT16 phySecId = 0u;/*ID*/ + UINT8 haveDirChangeInRoute = 0u; + UINT8 shouldOppose = 0u;/*ǷӦȡ*/ + UINT8 phySecState = 0u; + UINT8 phySecLockType = 0u; + UINT8 phySecLockState = 0u; + UINT8 phyIntruSecVainCheck = 0u; + UINT8 routeAutoSigProperty = 0u; + UINT16 phySecPLockBelongRouteId = 0u; + UINT8 phySecStopSteadyFlag = 0u; + UINT8 chPhyFree = CI_ERROR; + UINT8 gdDLline = 0u; /*·Ƿù·*/ + funcSwitchJumpLockDriveSwitch = GetCiFunctionSwitchConfig(FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH); + /*жǷù·*/ + gdDLline = GetCiFunctionSwitchConfig(FUNC_CLD_GD_DIANLU_LINE); + + switch (MaskType) + { + case MASK_TYPE_PHYSECTION_OCCUPY: + /*ռλ*/ + phySecState = GetPhySecCurOccupyState(DeviceId); + if (SECTION_OCCUPY_NO == phySecState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_PHYSECTION_STARTLOCK: + /*ϵ״̬*/ + phySecState = GetPhySecLockState(DeviceId); + if (PHYSICAL_SECTION_LOCK_START == phySecState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_PHYSECTION_ROUTELOCK: + /*ν·״̬*/ + phySecLockState = GetPhySecLockState(DeviceId); + localCiType = GetLocalCiType(); + phyIntruSecVainCheck = PhysicalIntruSecVainCheck(DeviceId); + if (((PHYSICAL_SECTION_LOCK_NORMAL == phySecLockState) || + (PHYSICAL_SECTION_LOCK_DELAY == phySecLockState) || + (PHYSICAL_SECTION_LOCK_FAULTDELAY == phySecLockState) || + ((PHYSICAL_SECTION_LOCK_EXCEPT == phySecLockState) && (CI_TYPE_CLD == localCiType))) + && (CI_SUCCESS == phyIntruSecVainCheck)) + {/*ջʱʽʱ,쳣Ҳ״̬,ζӦZCδգ20190308*/ + + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_PHYSECTION_ROUTELOCK_SHOW: + /*ν·ʾ״̬(ATS/ֵʹ)*/ + phySecLockState = GetPhySecLockState(DeviceId); + if ((PHYSICAL_SECTION_LOCK_NORMAL == phySecLockState) || + (PHYSICAL_SECTION_LOCK_DELAY == phySecLockState) || + (PHYSICAL_SECTION_LOCK_FAULTDELAY == phySecLockState)) + {/*ջʱʽʱ*/ + routeAutoSigProperty = GetRouteAutoSigProperty(GetPhySecRLockBelongRouteId(DeviceId)); + if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty) + { + + } + else + { + SetMaskValue(MaskId, dataBuf); + } + + } + else + { + + } + break; + case MASK_TYPE_PHYSECTION_PROTECTLOCK: + /*η·״̬*/ + /*ԾգCI->ATS/ֵزͱ*/ + phySecLockState = GetPhySecJumpLockState(DeviceId); + if (PHYSICAL_SECTION_JUMP_LOCK_YES != phySecLockState) + { + phySecPLockBelongRouteId = GetPhySecPLockBelongRouteId(DeviceId); + if (0u != phySecPLockBelongRouteId) + { + routeAutoSigProperty = GetRouteAutoSigProperty(GetPhySecPLockBelongRouteId(DeviceId)); + if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty) + {/*Զźŵıβλ*/ + } + else + { + SetMaskValue(MaskId, dataBuf);/*20190904޸߼жǷ·գֻҪзվͷλ*/ + } + } + } + else + { + + } + break; + case MASK_TYPE_PHYSECTION_FAULTLOCK: + /*ι״̬*/ + phySecState = GetPhySecLockState(DeviceId); + if (PHYSICAL_SECTION_LOCK_EXCEPT == phySecState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_PHYSECTION_HEAD_XTD: + /*״̬*/ + phySecId = DeviceId; + lockDir = GetPhySecLockDirection(phySecId); + lockState = GetPhySecLockState(phySecId); + routeLockBelongRouteID = GetPhySecRLockBelongRouteId(phySecId);/*ȡ··ID*/ + protectLockBelongRouteID = GetPhySecPLockBelongRouteId(phySecId);/*ȡ·ID*/ + + if (CI_SYSTEM_DIRECTION_NONE != lockDir) + {/*շЧ*/ + if (0U < routeLockBelongRouteID) + { + /*н·*//*ǷӦȡ*/ + haveDirChangeInRoute = GetRouteHaveDirChangePointIn(routeLockBelongRouteID); + shouldOppose = GetRoutePhySecShouldLockOppose(routeLockBelongRouteID, phySecId); + + if (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute) + { + /*·з仯*/ + if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == shouldOppose) + { + /*Ӧȡ*/ + if (CI_SYSTEM_DIRECTION_UP == lockDir) + { + lockDir = CI_SYSTEM_DIRECTION_DOWN;/*֮ǰյģȡ*/ + } + else if (CI_SYSTEM_DIRECTION_DOWN == lockDir) + { + lockDir = CI_SYSTEM_DIRECTION_UP;/*շȡ*/ + } + else + { + ; /*ִе*/ + } + } + else + { + ; /*Ӧȡ,֮ǰɶɶ*/ + } + } + } + else if ((0U == routeLockBelongRouteID) && (0U < protectLockBelongRouteID)) + { + ; /*ûн·գз,״̬ñշʱǹΪʵշﲻת*/ + } + else + { + ; /*ûн·գҲûзգת*/ + } + } + if ((CI_SYSTEM_DIRECTION_DOWN == lockDir) || + ((PHYSICAL_SECTION_LOCK_EXCEPT == lockState) && + (((LINE_FAO == lineIdentity) || (LINE_HLHT == lineIdentity) || (LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity)|| (LINE_FAOHLHT_ONESELFSECOND == lineIdentity)) + && ((CI_TYPE_CLD == localCiType) && (FUNC_SWITCH_ON == gdDLline))))) + { + /*շΪлFAO·ijʹù·ʱ쳣շ״̬Ч*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_PHYSECTION_HEAD_STD: + /*״̬*/ + phySecId = DeviceId; + lockDir = GetPhySecLockDirection(phySecId); + lockState = GetPhySecLockState(phySecId); + + routeLockBelongRouteID = GetPhySecRLockBelongRouteId(phySecId);/*ȡ··ID*/ + protectLockBelongRouteID = GetPhySecPLockBelongRouteId(phySecId);/*ȡ·ID*/ + + if (CI_SYSTEM_DIRECTION_NONE != lockDir) + {/*շЧ*/ + if (0U < routeLockBelongRouteID)/*н·*/ + { + haveDirChangeInRoute = GetRouteHaveDirChangePointIn(routeLockBelongRouteID); + shouldOppose = GetRoutePhySecShouldLockOppose(routeLockBelongRouteID, phySecId);/*ǷӦȡ*/ + if (ROUTE_HAVE_DIR_CHANGE_POINT == haveDirChangeInRoute) + { + /*·з仯*/ + if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == shouldOppose) + { + /*Ӧȡ*/ + if (CI_SYSTEM_DIRECTION_UP == lockDir) + { + lockDir = CI_SYSTEM_DIRECTION_DOWN;/*֮ǰյģȡ*/ + } + else if (CI_SYSTEM_DIRECTION_DOWN == lockDir) + { + lockDir = CI_SYSTEM_DIRECTION_UP;/*շȡ*/ + } + else + { + ; /*ִе*/ + } + } + else + { + ; /*Ӧȡ,֮ǰɶɶ*/ + } + } + } + else if ((0U == routeLockBelongRouteID) && (0u < protectLockBelongRouteID)) + { + ; /*ûн·գз,״̬ñշʱǹΪʵշﲻת*/ + } + else + { + ; /*ûн·գҲû÷գ*/ + } + } + localCiType = GetLocalCiType(); + if ((CI_SYSTEM_DIRECTION_UP == lockDir) || + ((PHYSICAL_SECTION_LOCK_EXCEPT == lockState) && + (((LINE_FAO == lineIdentity) || (LINE_HLHT == lineIdentity) || (LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity)) + && ((CI_TYPE_CLD == localCiType) && (FUNC_SWITCH_ON == gdDLline))))) + { + /*շΪлFAO·ijʹù·ʱ쳣շ״̬Ч*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_AXISSECTION_ARB: + /*ARB״̬λ*/ + phySecState = GetPhySecArbState(DeviceId); + if (AXIS_SECTION_ARB_YES == phySecState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_LIECHE_STOPSTATE: + /*гͣϢ״̬λ*/ + phySecStopSteadyFlag = GetPhySecStopSteadyFlag(DeviceId); + if (PHYSICAL_SECTION_STOPSTEADY_YES == phySecStopSteadyFlag) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_PHYSECTION_FLOCK: + /*״̬λ(ATS) 0 δԼSPKS1*/ + phySecState = GetPhySecFLockState(DeviceId); + if (PHYSICAL_SECTION_FLOCK_NO != phySecState) + { + phySecLockType = GetPhySecFLockType(DeviceId); + if (PHY_SEC_FLOCK_TYPE_SPKS != phySecLockType) + { + /*SPKS 0*/ + } + else + { + /*SPKSķ 1*/ + SetMaskValue(MaskId, dataBuf); + } + } + else + { + /*δ 1*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_PHYSEC_FLOCK_SPKS: + /*״̬λ(SPKS 0 δԼATS1*/ + phySecState = GetPhySecFLockState(DeviceId); + if (PHYSICAL_SECTION_FLOCK_NO != phySecState) + { + phySecLockType = GetPhySecFLockType(DeviceId); + if (PHY_SEC_FLOCK_TYPE_CMD != phySecLockType) + { + /*ATS 0*/ + } + else + { + /*ֻATSķ 1*/ + SetMaskValue(MaskId, dataBuf); + } + } + else + { + /*δ 1*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_PHYSECTION_JUMPLOCK: + /*Ծ״̬λ*/ + jumpState = GetPhySecJumpLockState(DeviceId); + if (PHYSICAL_SECTION_JUMP_LOCK_YES == jumpState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + + break; + case MASK_TYPE_PHYSECTION_JUMPLOCK_ZC: + /*Ծ״̬λ--ZC;ֻZCλȷļԾ*/ + swSum = GetAxisSwitchSum(DeviceId); + axisSwitchStru = GetAxisSwitchIdStru(DeviceId); + if ((0U != swSum) && (NULL != axisSwitchStru)) + { + for (iIndex = 0U; iIndex < swSum; iIndex++) + { + switchCurPosition = GetSwitchCurPosition(axisSwitchStru[iIndex].SwitchId); + if (axisSwitchStru[iIndex].SwitchPosition == switchCurPosition) + { + ; /*λȷ*/ + } + else + { + swPosRight = 0U;/*λô*/ + } + } + } + if (1U == swPosRight) + { + phyId = GetAxisSecRelativePhySecId(DeviceId);/*idתid*/ + jumpState = GetPhySecJumpLockStateToZC(phyId); + + if (PHYSICAL_SECTION_JUMP_LOCK_YES == jumpState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*0*/ + } + } + break; + + case MASK_TYPE_PHYSECTION_PRERESET: + /*Ԥλ״̬λ*/ + physecPreResetSta = GetPhySecPreResetState(DeviceId); + if (PHYSICAL_SECTION_PRE_RESET_YES == physecPreResetSta) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + + case MASK_TYPE_PHYSECTION_UT_OCC: + /* ιռλ */ + chPhyFree = IsPhyFree(DeviceId); + if (CI_SUCCESS == chPhyFree) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + ; + } + break; + + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + +/* +* ߼λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 LogicSectionMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + UINT8 logLockState = 0U; + UINT8 routeAutoSigProperty = 0U; + UINT16 logLockBelongRoute = 0U;/*߼·*/ + UINT16 logProtectLockRoute = 0U;/*߼η·*/ + UINT8 chJumpLockState = 0U;/*߼״̬*/ + UINT8 cLogArbState = 0U; /* ߼ARB״̬ */ + UINT8 chLogSecLockDirOpposedFlag = CI_ERROR;/*߼շǷȡ־*/ + UINT8 cLogSpksFlockState = 0U; /* ߼SPKS״̬ */ + UINT8 cLogSecLogicLockState = LOG_SECTION_LOCK_NO; /*߼߼״̬*/ + UINT8 cLogSecLockDir = CI_SYSTEM_DIRECTION_NONE; /*߼շ*/ + UINT8 chLogSecBelLogRouteSum = 0U;/*߼߼·Ŀ*/ + + switch (MaskType) + { + case MASK_TYPE_LOGICSECTION_UTOCCUPY: + /*߼ηͨųռλ*/ + if ((LOGICSECTION_OCCUPY_CT == GetLogSecCurCtOrUtOccupyState(DeviceId)) + || (LOGICSECTION_OCCUPY_NO == GetLogSecCurCtOrUtOccupyState(DeviceId))) + { + /*ͨųռû޳ռ λ1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_LOGICSECTION_CTOCCUPY: + /*߼ͨųռλ*/ + if ((LOGICSECTION_OCCUPY_UT == GetLogSecCurCtOrUtOccupyState(DeviceId)) + || (LOGICSECTION_OCCUPY_NO == GetLogSecCurCtOrUtOccupyState(DeviceId))) + { + /*ͨųռû޳ռ λ1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_LOGICSECTION_LINSHIXIANSU_SET: + /*߼ʱλ*/ + if (LOGSEC_LSXS_SET_STATE_YES == GetLogSecLinShiXianSuSetState(DeviceId)) + { + /*߼ʱ٣λ1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + /*߼ν·λ*/ + case MASK_TYPE_LOGICSECTION_ROUTELOCK: + logLockState = GetLogSecLockState(DeviceId); + cLogSecLogicLockState = GetLogSecLogLockState(DeviceId); + /*߼ջʱջ߼*/ + if ((LOG_SECTION_LOCK_NORMAL == logLockState) || (LOG_SECTION_LOCK_DELAY == logLockState) || (LOG_SECTION_LOGLOCK_NORMAL == cLogSecLogicLockState)) + { + logLockBelongRoute = GetLogSecLockBelongRoute(DeviceId); + routeAutoSigProperty = GetRouteAutoSigProperty(logLockBelongRoute); + /*Զź*/ + if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty) + { + /**/ + } + else + { + /*λΪ1*/ + SetMaskValue(MaskId, dataBuf); + } + } + break; + case MASK_TYPE_LOGICSECTION_FAULTLOCK: + logLockState = GetLogSecLockState(DeviceId); + cLogSecLogicLockState = GetLogSecLogLockState(DeviceId); + /*߼ιջ߼*/ + if ((LOG_SECTION_LOCK_EXCEPT == logLockState) || (LOG_SECTION_LOGLOCK_EXCEPT == cLogSecLogicLockState)) + { + /*λΪ1*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_LOGICSECTION_PROTECTLOCK: + /**/ + + /*߼ޡԾա*/ + chJumpLockState = GetLogSecJumpLockState(DeviceId); + if (LOGIC_SECTION_JUMP_LOCK_YES != chJumpLockState) + { + /*·ԶźŽ·ͷ*/ + logProtectLockRoute = GetLogSecPLockRouteId(DeviceId); + if (0u != logProtectLockRoute) + { + routeAutoSigProperty = GetRouteAutoSigProperty(logProtectLockRoute); + if (ROUTE_AUTOSIG_PROPERTY_YES == routeAutoSigProperty) + { + /*Զźŵıβλ*/ + } + else + { + /*λΪ1*/ + SetMaskValue(MaskId, dataBuf); + } + } + else + { + /*޷գ*/ + } + } + else + { + /*Ծգ*/ + } + break; + case MASK_TYPE_LOGICSECTION_JUMPLOCK: + /*Ծ*/ + chJumpLockState = GetLogSecJumpLockState(DeviceId);/*߼Ծ״̬*/ + if (LOGIC_SECTION_JUMP_LOCK_YES == chJumpLockState) + { + /*λΪ1*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_UPWARD_DIRECTION: + chLogSecLockDirOpposedFlag = GetLogSecLockDirOpposedFlag(DeviceId); + chLogSecBelLogRouteSum = GetLogSecLockBelLogRouteSum(DeviceId); + + if (0U == chLogSecBelLogRouteSum) + { + cLogSecLockDir = GetLogSecLockDir(DeviceId); + } + else + { + /*߼߼·Ŀ0߼շȡ߼·*/ + cLogSecLockDir = GetLogSecLogLockDir(DeviceId); + } + /*շ*/ + if (((CI_SYSTEM_DIRECTION_UP == cLogSecLockDir) && (CI_ERROR == chLogSecLockDirOpposedFlag)) + || ((CI_SYSTEM_DIRECTION_DOWN == cLogSecLockDir) && (CI_SUCCESS == chLogSecLockDirOpposedFlag))) + { + /*߼շΪշҪȡ ߼շΪշҪȡ*/ + /*λΪ1*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_DOWNWARD_DIRECTION: + chLogSecLockDirOpposedFlag = GetLogSecLockDirOpposedFlag(DeviceId); + chLogSecBelLogRouteSum = GetLogSecLockBelLogRouteSum(DeviceId); + + if (0U == chLogSecBelLogRouteSum) + { + cLogSecLockDir = GetLogSecLockDir(DeviceId); + } + else + { + /*߼߼·Ŀ0߼շȡ߼·*/ + cLogSecLockDir = GetLogSecLogLockDir(DeviceId); + } + /*շ*/ + if (((CI_SYSTEM_DIRECTION_DOWN == cLogSecLockDir) && (CI_ERROR == chLogSecLockDirOpposedFlag)) + || ((CI_SYSTEM_DIRECTION_UP == cLogSecLockDir) && (CI_SUCCESS == chLogSecLockDirOpposedFlag))) + { + /*߼շΪշҪȡ ߼շΪշҪȡ*/ + /*λΪ1*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_LOGICSECTION_ARB: + /* ߼ARB״̬ */ + cLogArbState = GetLgcArbState(DeviceId); + /*ARB*/ + if (LGC_SECTION_ARB_YES == cLogArbState) + { + /*λΪ1*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_LOGICSECTION_SPKS_FLOCK: + /* ߼SPKS״̬ */ + cLogSpksFlockState = GetLogSecSpksFLockState(DeviceId); + /*SPKS*/ + if (LOGIC_SECTION_SPKS_FLOCK_YES == cLogSpksFlockState) + { + ; /*0*/ + } + else + { + /*λΪ1*/ + SetMaskValue(MaskId, dataBuf); + } + + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 OverlapMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_ERROR; /*ֵ*/ + UINT8 overlapPhySecSum = 0u;/*ΰĿ*/ + UINT16* overlapContainPhySecIdBuf = NULL;/*ΰ*/ + UINT8 ii = 0u; + UINT16 overlapbelongRtId = 0u;/*α·*/ + UINT16 rtOverlapLockedId = 0u;/*·ʵյı*/ + + UINT8 checkResult = CI_ERROR;/**/ + UINT16 tempDevId = 0u;/*豸IDʱCheckҪijڲ*/ + UINT8 tempDevSta = 0u;/*豸״̬ʱCheckҪijڲ*/ + + UINT8 lineIdentity = CI_TRADITION_RAILWAY; + UINT8 overlapSum = 0u; + UINT16* overlapIdBuf = NULL; + UINT8 jj = 0u; + UINT8 flag = 0u; + overlapPhySecSum = GetOverlapPhySecSum(DeviceId); + overlapContainPhySecIdBuf = GetOverlapPhySecIdBuf(DeviceId); + for (ii = 0u; ii < overlapPhySecSum; ii++) + {/*ΰΣҷ·ID*/ + overlapbelongRtId = GetPhySecPLockBelongRouteId(overlapContainPhySecIdBuf[ii]); + if (0u != overlapbelongRtId) + {/*ҳɹ*/ + returnValue = CI_SUCCESS; + break; + } + } + if (CI_SUCCESS == returnValue) + { + overlapSum = GetRouteOverlapSum(overlapbelongRtId); /*ȡOverlap*/ + overlapIdBuf = GetRouteOverlapIdBuf(overlapbelongRtId); /*ȡOverlap ID BUF*/ + + for (jj = 0u; jj < overlapSum; jj++) + { /*·ıյıһ£ͱλ򲻷 + ֹ·ͬһαϢʵûյĽ·ıҲͱλ20190109*/ + rtOverlapLockedId = GetRouteOverlapLockedId(overlapbelongRtId);/*ȡ·ʵյıID*/ + if (overlapIdBuf[jj] == rtOverlapLockedId) + { + flag = 1u; /*յıΪ·ڷ*/ + } + if ((1u == flag) && (DeviceId == overlapIdBuf[jj])) + { + /*λбеλλλһ£ֻŴλ + ˴жϷֹյλʵʴλһµ*/ + if (MASK_TYPE_OVERLAP_LOCKSTATE == MaskType) /*״̬*/ + { + /*νλЧԼ*/ + checkResult = OverlapValidMaskCheck(rtOverlapLockedId); + + if (CI_SUCCESS == checkResult) + { + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + + /*źŻЧ*/ + if (CI_SUCCESS == returnValue) + { + checkResult = SignalOverlapValidCheck(overlapbelongRtId, &tempDevId, &tempDevSta); + + if (CI_SUCCESS == checkResult) + { + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + } + + if (CI_SUCCESS == returnValue) + { + /*ȡ·ʶ*/ + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF); + + if (CI_TRADITION_RAILWAY == lineIdentity) + { + /*ͳ˫·*/ + returnValue = CI_SUCCESS; + } + else + { + /* ʧܷ *//* zt ɾش 2022-02-15 */ + returnValue = CI_ERROR; + } + } + else + { + returnValue = CI_ERROR; + } + + if (CI_SUCCESS == returnValue) + { + SetMaskValue(MaskId, dataBuf); + + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + + } + else if (MASK_TYPE_OVERLAP_UNLOCK_APPLY == MaskType) + { /*־ЧZCλ,ȡյıε״̬*/ + if (UNLOCK_OVERLAP_APPLY_YES == GetOverlapUnlockApplyFlag(rtOverlapLockedId)) + { + SetMaskValue(MaskId, dataBuf); + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + + } + else + { + returnValue = CI_ERROR; + } + } + else + { + returnValue = CI_ERROR; + } + } + } + else + { + returnValue = CI_ERROR; + } + + + return returnValue; +} + + +/* +* ·λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 RouteMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_SUCCESS; /*ֵĬϳɹ*/ + UINT8 routeState = GetRouteState(DeviceId); /*ȡ·״̬*/ + UINT8 routeLevel = GetRouteLevel(DeviceId); + UINT16 lastPhyLockId = GetRouteLastPhySectionId(DeviceId); /*ȡָID·һID*/ + UINT8 lastPhyLockState = GetPhySecLockState(lastPhyLockId); /*ȡһ״̬*/ + UINT8 firstLogicOccuState = GetLogSecCurOccupyState(GetRouteInFirstLogSecId(DeviceId)); + UINT8 dcQState = GetRouteDCQState(DeviceId);/*·״̬*/ + UINT8 dcTState = GetRouteDCTYState(DeviceId);/*·ͬ״̬*/ + UINT8 RouteCiId = 0u; /*·*/ + UINT8 CiTypeOfRoute = 0u; /*ǰ·*/ + UINT8 ciTrainTestState = 0u; /*Գ״̬*/ + UINT8 routeAutoTriggerFlag = GetRouteAutoTriggerFlag(DeviceId); /*ȡ·Զ־*/ + switch (MaskType) + { + case MASK_TYPE_ROUTE_IDLE:/*·λ*/ + if (ROUTE_STATE_IDLE == routeState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_ROUTE_XUANPAI:/*·ѡλ*/ + if (ROUTE_STATE_XUANPAI == routeState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_ROUTE_ALLLOCK:/*CI-ATSλ·λ*/ + if (ROUTE_AUTOSIG_PROPERTY_YES == GetRouteAutoSigProperty(DeviceId)) + { + if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState) || + (ROUTE_STATE_DELAY_UNLOCK == routeState) || + (ROUTE_STATE_NEAR_LOCK == routeState)) + {/*Զ·ж··쳣ԤաԤȿšӽšӽ쳣ӽ + ա쳣šʱ*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + } + else + { + if ((ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState) || + (ROUTE_STATE_DELAY_UNLOCK == routeState) || + ((ROUTE_STATE_NEAR_LOCK == routeState) && (SECTION_OCCUPY_YES == firstLogicOccuState))) + {/*ͨ·ж··쳣ԤաԤȿšӽšӽ쳣ӽҵһռ + »·ڷһΪ󳤼ᣬг׷ٽʱͣڽ·ָⷽΪһ߼οкATSͷգ + ա쳣šʱ*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + } + break; + case MASK_TYPE_ROUTE_PARTLOCK:/*·λ*/ + break; + case MASK_TYPE_ROUTE_DELAYUNLOCK:/*ʱλ*/ + if ((ROUTE_STATE_DELAY_UNLOCK == routeState) || + (ROUTE_STATE_AUTO_UNLOCK == routeState) || + (ROUTE_STATE_AUTO_UNLOCKERR == routeState)) + {/*ʱԶԶ쳣*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_ROUTE_LOCKSTATE:/*CI-ZCλ·״̬λ:ݽӿ˵·ڰ״̬·0,·״̬ΪԤѡѡһΪ״̬Է1CBTCģʽ·׷ٰڼ䲻ZC·״̬*/ + /*ȡ·CI*/ + RouteCiId = GetRouteBelongCiId(DeviceId); + /*ȡ*/ + CiTypeOfRoute = GetCiType(RouteCiId); + if ((0u != RouteCiId) && (0u != CiTypeOfRoute)) + { + if ((ROUTE_STATE_IDLE != routeState) + && (ROUTE_STATE_FIRST_XUANPAI != routeState) + && (ROUTE_STATE_XUANPAI != routeState) + && (ROUTE_STATE_LEAD_FIRST_XUANPAI != routeState) + && (ROUTE_STATE_LEAD_XUANPAI != routeState) + && (ROUTE_STATE_LEAD_LOCK != routeState) + && (ROUTE_STATE_LEAD_LOCKERR != routeState) + && (ROUTE_STATE_LEAD_OPEN != routeState) + || (((ROUTE_STATE_FIRST_XUANPAI == routeState) || (ROUTE_STATE_XUANPAI == routeState)) + && ((PHYSICAL_SECTION_LOCK_NORMAL == lastPhyLockState) || + (PHYSICAL_SECTION_LOCK_DELAY == lastPhyLockState) || + (PHYSICAL_SECTION_LOCK_FAULTDELAY == lastPhyLockState))) + ) + { + ciTrainTestState = GetCiTrainTestStatus(); + if ((CI_TYPE_SCX == CiTypeOfRoute) && (CI_TRAIN_TEST_ON != ciTrainTestState)) + { + ; + } + else + { + SetMaskValue(MaskId, dataBuf); + } + } + else + { + ; + } + } + else + { + ; + } + break; + case MASK_TYPE_ROUTE_OPENSTATE:/*·״̬λ*/ + if ((ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState)) + {/*·Ԥȿšӽ*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_ROUTE_EXISTENCE:/*·״̬λ*/ + if (ROUTE_STATE_IDLE == routeState) + {/*·У*/ + } + else + {/*״̬*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_ROUTE_NEARLOCK:/*·ӽ״̬λ*/ + if ((ROUTE_STATE_NEAR_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState)) + {/*·ӽաӽ쳣ӽ*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_ROUTE_YINDAOLOCK: + if ((ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState)) + {/*·ա쳣ʱλ1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + + case MASK_TYPE_ROUTE_DC_QINGQIU:/*λ*/ + { + if (ROUTE_DCQ_REQUEST == dcQState) + {/*е1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*޵0*/ + } + } + break; + + case MASK_TYPE_ROUTE_DC_AGREE:/*ͬλ*/ + { + if (ROUTE_DCT_AGREE == dcTState) + {/*еͬ⣬1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*޵ͬ⣬0*/ + } + } + break; + + case MASK_TYPE_AUTOROUTE_STATE:/*Զͨ·״̬λ*/ + if (AUTO_ROUTE_SET_YES == GetAutoRouteSetFlag(DeviceId)) + {/*Զͨ·־*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_AUTORETURN_STATE:/*Զ۷·״̬λ*/ + if (AUTO_RETURN_SET_YES == GetAutoReturnSetFlag(DeviceId)) + {/*Զ۷·־*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_ALLAUTORETURN_STATE:/*ȫԶ۷·״̬λ*/ + if (ALL_AUTO_RETURN_SET_YES == GetAllAutoReturnSetFlag(DeviceId)) + {/*ȫԶ۷·־*/ + SetMaskValue(MaskId, dataBuf); + } + + break; + case MASK_TYPE_ROUTE_STOPE_APPLY: /*˽ⲢZCδ֤ͣҳδѹʼźŻڷ²Ҫ֤ͣ*/ + if (ROUTE_STATE_DELAY_UNLOCK == routeState) + { + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_ROUTE_SIGNAL_STATE: /* ·Ϣ: źƻƣ״̬ 0 1 */ + if ((ROUTE_LEVEL_BLOC == routeLevel) && + ((ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState))) + {/* ʽ´źſ״̬ */ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + case MASK_TYPE_ROUTE_AUTO_TRIGGER: /* CI-ATSλ·Զ־ */ + if (AUTO_TRIGGER_SET_YES == routeAutoTriggerFlag) + {/* Զ·Զ־ */ + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + + + +/* +* վ̨λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 PlatMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT16 ii = 0u; + UINT8 relaySum = 0u; + UINT16* relayIdBuf; + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + UINT8 mutualLockState = 0u; + UINT8 psdState = 0u; + + UINT8 includeVirFlag = GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 RelayCollState = 0u; + UINT8 localCi = GetSystemParaLocalCiId(); + UINT8 virtualZDZFBelongCiId = 0U; + UINT8 virtualZDZFDevType = 0U; + UINT8 virtualZDZFButtonState = 0U; + UINT8 psdSendAtsStateFlag = 0u; + UINT8 EssSteadyState = 0u; + UINT8 EssFlashState = 0u; + UINT8 chPslPcbState = 0U;/*PSLſPCBť״̬*/ + UINT8 chCleFarePcbState = 0U; /*ȷPCBť״̬*/ + UINT32 dwPsdButPreTimeCount = 0U;/*վ̨ťʧЧʱ*/ + UINT32 dwPslPcbPreCyc = 0U;/*PSLſPCBť*/ + UINT32 dwCleFarePcbPreCyc = 0U;/*ȷPCBť*/ + UINT8 chPslPcbTimeCheck = 0U;/*PSLſPCBťʱ*/ + UINT8 chCleFarePcbTimeCheck = 0U;/*ȷPCBťʱ*/ + UINT8 cancelEsbErrFlag = ESB_ERROR_FLAG_NO; /*ȡرհťϱ־*/ + UINT8 esbErrFlag = ESB_ERROR_FLAG_NO; /*رհťϱ־*/ + UINT8 chCleFarePDBFlaLigFlag = 0U;/*ȷPDBť״̬*/ + UINT8 chPsdVideoQkDriveState = 0U;/*ȷƵ״̬*/ + UINT8 chRtnIndicatorDevId = 0U;/*۷豸ID*/ + UINT8 chNonRrnAdhesionState = 0U;/*۷ťճ״̬*/ + + chRtnIndicatorDevId = GetIndicatorRelNonReturnId(DeviceId); + virtualZDZFBelongCiId = GetVirtualZDZFBelongCiId(); + virtualZDZFDevType = GetVirtualZDZFDevType(); + virtualZDZFButtonState = GetVirtualZDZFButtonState(); + + switch (MaskType) + { + case MASK_TYPE_PLAT_AUTORETURNSIG_BUTTONSTAT:/*վ̨۷ť״̬λ*/ + if (FUNC_SWITCH_ON == includeVirFlag) + { + DealAutoReturnButtonMask_Vir(DeviceId, MaskId, dataBuf);/*DeviceIdΪָʾƱID*/ + } + else + {/*δDeviceIdΪָʾID*/ + for (ii = 0u; ii < GetIndicatorCurSum(); ii++) + { + if ((DeviceId == GetIndicatorId(ii)) + && (INDICATOR_TYPE_EXPRESS_RETURN == GetIndicatorType(DeviceId))) + {/*豸IDӦָʾΪ۷*/ + + if ((virtualZDZFBelongCiId == localCi) && (CI_DEVICE_TYPE_AUTORETURN == virtualZDZFDevType)) + {/*۷ťΪ豸*/ + if (VIRTUAL_ZDZFAJ_BUTTON_YES == virtualZDZFButtonState) + {/*豸۷ť*/ + SetMaskValue(MaskId, dataBuf); + } + } + else + {/*۷ťʵ*/ + relaySum = GetIndicatorRelaySum(DeviceId); + relayIdBuf = GetIndicatorRelayIdBuf(DeviceId); + if ((3u != relaySum) || (NULL == relayIdBuf)) + {/*̵ݴ۷ťΪ豸*/ + returnValue = CI_ERROR; + break; + } + else + { + RelayCollState = GetRelayCollState(relayIdBuf[2]); + chNonRrnAdhesionState = GetNonRtnAdhesionState(chRtnIndicatorDevId); + + if ((RELAY_STATE_UP == RelayCollState) && (RTN_RELAY_ADHESION_NO == chNonRrnAdhesionState)) + {/*۷ť̵*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + } + } + } + + } + } + } + + break; + + case MASK_TYPE_ESP_STATE:/*վ̨رհťλ*/ + if ((ESB_STATE_VALID_NO == GetEsbState(DeviceId)) || (ESB_CUT_YES == GetEsbCutState(DeviceId))) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_ESS_STEADY_STATE:/*ESSȵ״̬λ*/ + EssSteadyState = GetEsbRelateEssSteadyState(DeviceId); + if (ESB_STATE_LIGHT_STATE_Y == EssSteadyState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + ; /*ȵ״̬Ϊδ״̬ߴ״̬λ*/ + } + break; + case MASK_TYPE_ESP_FLASH_STATE:/*ESSƵ״̬λ*/ + EssFlashState = GetEsbRelateEssFlashState(DeviceId); + if (ESB_STATE_LIGHT_STATE_Y == EssFlashState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + ; /*״̬Ϊδ״̬ߴ״̬λ*/ + } + break; + case MASK_TYPE_CANCEL_ESP_FAULT: + cancelEsbErrFlag = GetCancelEsbErrFlag(DeviceId); + if (ESB_ERROR_FLAG_YES == cancelEsbErrFlag) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*λֵ0*/ + } + break; + case MASK_TYPE_ESP_FAULT: + esbErrFlag = GetEsbErrFlag(DeviceId); + if (ESB_ERROR_FLAG_YES == esbErrFlag) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*λֵ0*/ + } + break; + case MASK_TYPE_PSD_STATE_ATS:/*վ̨״̬λ;ATS*/ + /*ȡŻ״̬״̬*/ + mutualLockState = GetPsdMutualLockRemoveState(DeviceId); + psdState = GetPsdState(DeviceId); + psdSendAtsStateFlag = GetCiFunctionSwitchConfig(FUNC_PSD_SEND_ATS_STATE_FLAG); + if (FUNC_SWITCH_ON == psdSendAtsStateFlag) + { + if (PSD_STATE_CLOSE == psdState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + } + else + { + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_STATE_CLOSE == psdState)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + } + break; + + case MASK_TYPE_PSD_STATE:/*վ̨״̬λ-ZC,LEU*/ + /*ȡŻ״̬״̬*/ + mutualLockState = GetPsdMutualLockRemoveState(DeviceId); + psdState = GetPsdState(DeviceId); + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_STATE_CLOSE == psdState)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_MUTUALLOCK_STATE:/*վ̨Ż״̬λ*/ + mutualLockState = GetPsdMutualLockRemoveState(DeviceId); + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + + } + break; + + case MASK_TYPE_REMORA_STATE:/*ϰϢλCIյVOBCʼ̽ʼ̵̽ʱTimeCIŸֵغATS϶̽״̬*/ + if (JXTC_MUTUALLOCK_REMOVE_YES == GetJXTCMutualLockState(DeviceId)) + {/*϶̽⻥*/ + /*ͼ϶̽ϰ*/ + } + else + {/*϶̽δ*/ + if (CI_TIME_OUT == SystemOverTimeCheck(GetStartDetectionCycNum(DeviceId), GetGapDetectCount())) + { + if (PSD_REMORA_YES == GetPsdRemoraState(DeviceId)) + {/*1ʾ϶̽ϰ*/ + SetMaskValue(MaskId, dataBuf); + } + else + {/*0ʾ϶̽ϰ*/ + } + } + else + {/*δʼʱʱδֵغATSϰ*/ + } + } + break; + case MASK_TYPE_PSD_JXTC_PANGLU: + { + if (JXTC_MUTUALLOCK_REMOVE_YES == GetJXTCMutualLockState(DeviceId)) + {/*϶̽⻥*/ + /*ͼ϶̽·״̬Ϊ·*/ + SetMaskValue(MaskId, dataBuf); + } + else + {/*϶̽δ*/ + + } + break; + } + case MASK_TYPE_PSD_PCBPSBDPB_PANGLU_STATE:/*PCB/POB/DPB·״̬λ*/ + { + if (PSD_BUTTON_PANGLU_STATE_VALID == GetPsdButtonPangluState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + + break; + } + case MASK_TYPE_PSD_PCB:/*վ̨PCBť״̬λ*/ + chPslPcbState = GetPsdButtonState(DeviceId); + chCleFarePcbState = GetCleFarePCBButtonState(DeviceId); + if ((PSD_BUTTON_STATE_DOWN == chPslPcbState) || (QK_PSD_BUTTON_STATE_DOWN == chCleFarePcbState)) + {/*cgh޸ijɶPSLſPCBȷPCBһ*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_PSD_POB:/*վ̨POBť״̬λ*/ + if (PSD_OPEN_BUTTON_STATE_VALID == GetPsdOpenButtonState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_PSD_PSB:/*վ̨PSBť״̬λ*/ + if (PLATFORM_DEPAR_BUTTON_STATE_VALID == GetPsdDepartButtonState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_PSD_PCB_INVALID:/*վ̨PCBťʧЧ״̬λ-cgh޸ijɶ󣺰PSLſPCBťʧЧȷPCBťʧЧ*/ + dwPsdButPreTimeCount =GetPsdButtonPressCount(); + dwPslPcbPreCyc = GetPCBPressCycNum(DeviceId); + dwCleFarePcbPreCyc = GetCleFarePCBPressCycNum(DeviceId); + chPslPcbTimeCheck = SystemOverTimeCheck(dwPslPcbPreCyc, dwPsdButPreTimeCount); + chCleFarePcbTimeCheck = SystemOverTimeCheck(dwCleFarePcbPreCyc, dwPsdButPreTimeCount); + if ((CI_TIME_OUT == chPslPcbTimeCheck) || (CI_TIME_OUT == chCleFarePcbTimeCheck)) + {/*PSLſPCBȷPCBֻҪһʱҪǷͰťЧλ*/ + if ((0u == dwPslPcbPreCyc) && (0u == dwCleFarePcbPreCyc)) + { + /*δʱ*/ + } + else + {/*2һPCBťʱЧ*/ + SetMaskValue(MaskId, dataBuf); + } + } + else + { + ; /*λЧ*/ + } + break; + case MASK_TYPE_PSD_POB_INVALID:/*վ̨POBťʧЧ״̬λ*/ + if (CI_TIME_OUT == SystemOverTimeCheck(GetPOBPressCycNum(DeviceId), GetPsdButtonPressCount())) + { + if (0u == GetPOBPressCycNum(DeviceId)) + { + /*δʱ*/ + } + else + { + SetMaskValue(MaskId, dataBuf); + } + } + else + { + } + break; + case MASK_TYPE_PSD_PSB_INVALID:/*վ̨PSBťʧЧ״̬λ*/ + if (CI_TIME_OUT == SystemOverTimeCheck(GetPSBPressCycNum(DeviceId), GetPsdButtonPressCount())) + { + if (0u == GetPSBPressCycNum(DeviceId)) + { + /*δʱ*/ + + } + else + { + SetMaskValue(MaskId, dataBuf); + } + } + else + { + } + break; + case MASK_TYPE_PSD_PDB_FLASH_STATE:/*ȷPDBťָʾ״̬λ*/ + chCleFarePDBFlaLigFlag = GetCleFarePDBFlaLigFlag(DeviceId); + if (QK_BUTTON_FLASH_LIGHT_YES == chCleFarePDBFlaLigFlag) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + ; /*ָIDȷPDBťָʾƱ־ЧλЧ*/ + } + break; + case MASK_TYPE_PSD_VIDEO_QK_LU:/*ͰťƵͱʾƣ)״̬λ*/ + chPsdVideoQkDriveState = GePsdVideoQkDriveState(DeviceId); + if ((VIDEO_QK_DRIVE_STATE_NO == chPsdVideoQkDriveState) || (VIDEO_QK_DRIVE_STATE_TESTING == chPsdVideoQkDriveState)) + { + /*Ƶ״̬Ϊ˻߼У̵λЧ*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*Ƶ״̬Ϊ˻Ч̵λЧ*/ + } + break; + case MASK_TYPE_PSD_VIDEO_QK_HONG:/*ͰťƵͱʾƣ)״̬λ*/ + chPsdVideoQkDriveState = GePsdVideoQkDriveState(DeviceId); + if ((VIDEO_QK_DRIVE_STATE_HAVE == chPsdVideoQkDriveState) || (VIDEO_QK_DRIVE_STATE_TESTING == chPsdVideoQkDriveState)) + { + /*Ƶ״̬Ϊ˻߼УλЧ*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*Ƶ״̬Ϊ˻ЧλЧ*/ + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + +/* +* SPKSλ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 SPKSMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + + switch (MaskType) + { + case MASK_TYPE_SPKS_OPENSTATE:/*SPKS״̬λ*/ + if (SPKS_STATUS_YES == GetSpksState(DeviceId)) + { + /*SPKS򿪣0*/ + } + else + { + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_SPKS_ISOLATE_BUTTON_STATE:/*SPKS·״̬λ*/ + if (SPKS_CUT_YES == GetSpksCutState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_SPKS_OPENSTATE_ZC: /*SPKS״̬λ:spks+·ں״̬CI-ZC*/ + if ((SPKS_STATUS_YES == GetSpksState(DeviceId)) && (SPKS_CUT_NO == GetSpksCutState(DeviceId))) + { + ; /* Mask Set zero*/ + } + else + { + SetMaskValue(MaskId, dataBuf); + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + + +/* +* ϴλ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 WashManchineMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + UINT8 chWashMachineReadyState = 0U;/*ϴ״̬*/ + UINT8 chWashModeState = 0U;/*ϴģʽ*/ + + switch (MaskType) + { + case MASK_TYPE_WASHMACHINE_READYSTATE:/*ϴ״̬λ*/ + chWashMachineReadyState = GetWashMachineReadyState(DeviceId); + if (WASHMACHINE_COL_READY_YES == chWashMachineReadyState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_WASHMACHINE_WORKMODE: + /*ϴģʽλ*/ + chWashModeState = GetWashModeState(DeviceId); + if (XTA_MODE_STATE_UP == chWashModeState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 GaragedoorMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + + switch (MaskType) + { + case MASK_TYPE_GARAGEDOOR_STATE:/*峵״̬λ(CI->ZC)*/ + if (GARAGE_DOOR_STATE_OPEN == GetGaragedoorState(DeviceId)) + {/*״̬1*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + + case MASK_TYPE_GARAGEDOOR_APPLYCLOSE_STATE:/*峵رλ(CI->ZC)*/ + if ((GARAGE_DOOR_CMD_CLOSE == GetGrgdoorCmdProcessState(DeviceId)) && + (GetWaiteZCResponseStartCycNum(DeviceId) > 0U)) + {/*ZCرճţ1*/ + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_GARAGEDOOR_OPEN_STATE:/*峵ſ״̬λ(CI->ATS)*/ + if (GARAGE_DOOR_STATE_OPEN == GetGaragedoorState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_GARAGEDOOR_CLOSE_STATE:/*峵Ź״̬λ(CI->ATS)*/ + if (GARAGE_DOOR_STATE_CLOSE == GetGaragedoorState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + break; + case MASK_TYPE_GARAGEDOOR_MODE_STATE:/*峵ģʽ״̬λ(CI->ATS)*/ + if (GARAGE_DOOR_STATE_MODE_REMOTE == GetGaragedoorModeState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*Ϊģʽ0*/ + } + break; + case MASK_TYPE_GARAGEDOOR_FAULT_STATE:/*峵Ź״̬λ(CI->ATS)*/ + if (GARAGE_DOOR_FAULT_TRUE == GetGaragedoorFaultState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + case MASK_TYPE_GARAGEDOOR_PANGLU_STATE:/*峵·״̬λ(CI->ATS)*/ + if (GARAGE_DOOR_PANGLU_TRUE == GetGaragedoorPangLuState(DeviceId)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 FloodGateMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf) +{ + UINT8 returnValue = CI_ERROR;/*ֵĬʧ*/ + UINT8 floodState = 0u; /*ʱ״̬*/ + UINT16 floodId = DeviceId; + UINT16 phySecId = 0u; + UINT8 physecState = 0u; + UINT8 checkRes = 0u;/**/ + UINT32 wFloodGateDelayCloseStartCyc = 0U; /*Žӽռѹӳٹʼʱ*/ + switch (MaskType) + { + case MASK_TYPE_FLOODGATE_CLOSEAPLAY_STATE:/*Źλ ATS/ZC*/ + { + floodState = GetFloodGateCurCloseRequestSta(floodId); + if (FLOOD_GATE_CLOSEREQ == floodState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*޹*/ + } + returnValue = CI_SUCCESS; + } + break; + case MASK_TYPE_FD_OPENLOCK_TO_ATS:/*ſλ ATS*/ + { + floodState = GetFloodGateCurOpenLockState(floodId); + if (FLOOD_GATE_OPENLOCK == floodState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*δ*/ + } + returnValue = CI_SUCCESS; + } + break; + case MASK_TYPE_FD_OPENLOCK_TO_ZC:/*ſλ ZC*/ + { + floodState = GetFloodGateCurOpenLockState(floodId); + if (FLOOD_GATE_OPENLOCK == floodState) + {/*޹пʱͿ*/ + SetMaskValue(MaskId, dataBuf); + } + else + { + /*޿*/ + } + + returnValue = CI_SUCCESS; + } + break; + case MASK_TYPE_FLOODGATE_AGREECLOSE_TOATS:/*ͬر״̬ to ATS*/ + { + floodState = GetFloodGateCurAgreeCloseSta(floodId); + if (FLOOD_GATE_AGREE_CLOSE == floodState) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*ͬر*/ + } + returnValue = CI_SUCCESS; + } + break; + case MASK_TYPE_FLOODGATE_SQGM_TOZC:/*رλ to ZC*/ + { + /*1. ɼر*/ + floodState = GetFloodGateCurCloseRequestSta(floodId); + + /*2. ŷο*/ + checkRes = FloodGateProtPhysecOccuCheck(floodId, &phySecId, &physecState); + wFloodGateDelayCloseStartCyc = GetFloodGateDelayCloseStartCnt(floodId); /*ʼʱZCλ*/ + + if ((FLOOD_GATE_CLOSEREQ == floodState) && (CI_SUCCESS == checkRes) && (0U < wFloodGateDelayCloseStartCyc)) + { + SetMaskValue(MaskId, dataBuf); + } + else + { + /*ر*/ + } + returnValue = CI_SUCCESS; + } + break; + default: + returnValue = CI_ERROR; + break; + } + + return returnValue; +} +/* +* λ +* ˵ const UINT8 localCiId, վID +* const UINT8 destSystemType, Ŀϵͳ +* const UINT8* dataBuf, λbuf +* ֵ 0: ʧ +* 1: ɳɹ +*/ +UINT8 MaskPack(const UINT8 destSystemType, UINT8* dataBuf) +{ + UINT16 MaskSum; /*λ*/ + UINT16 ii = 0u; /*α*/ + UINT16 DeviceId; /*豸ID*/ + UINT8 DeviceType; /*豸*/ + UINT8 MaskType; /*λ*/ + UINT16 MaskId = 0u; /*λID*/ + UINT8 returnValue = CI_SUCCESS;/*ʼֵΪ1*/ + + MaskSum = GetSendMaskSum(destSystemType); + if (0u == MaskSum) + { + return CI_ERROR; + } + + for (ii = 1u; ii <= MaskSum; ii++) + { + MaskId = GetMaskId(Get2oo2SheBeiType(), destSystemType, ii); + if (MaskId != 0u) + { + MaskType = GetSendMaskType(destSystemType, ii); + DeviceId = GetSendMaskDeviceId(destSystemType, ii); + DeviceType = GetSendMaskDeviceType(destSystemType, ii); + } + else + { + continue; + } + + switch (DeviceType) + { + case CI_DEVICE_TYPE_SWITCH:/*λ*/ + if (CI_ERROR == SwitchMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_SIGNAL:/*źŻλ*/ + if (CI_ERROR == SignalMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_PHYSEC:/*λ*/ + if (CI_ERROR == PhySectionMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_LOGICSEC:/*߼λ*/ + if (CI_ERROR == LogicSectionMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_OVERLAP:/*λ*/ + if (CI_ERROR == OverlapMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_ROUTE:/*·λ*/ + case CI_DEVICE_TYPE_AUTOROUTE:/*Զͨ·λ*/ + case CI_DEVICE_TYPE_AUTORETURN:/*Զ۷·λ*/ + case CI_DEVICE_TYPE_ALLAUTORETURN:/*ȫԶ۷·λ*/ + if (CI_ERROR == RouteMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + /*վ̨λ*/ + case CI_DEVICE_TYPE_PSD: + case CI_DEVICE_TYPE_ESB: + case CI_DEVICE_TYPE_PLATFORM: + if (CI_ERROR == PlatMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_SPKS:/*SPKSλ*/ + if (CI_ERROR == SPKSMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_WASHMACHINE:/*ϴλ*/ + if (CI_ERROR == WashManchineMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_GARAGEDOOR:/*λ*/ + if (CI_ERROR == GaragedoorMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + case CI_DEVICE_TYPE_FLOODGATE:/*λ*/ + if (CI_ERROR == FloodGateMaskManage(MaskType, DeviceId, MaskId, dataBuf)) + { + returnValue = CI_ERROR; + } + break; + + default: + returnValue = CI_ERROR; + break; + } + } + return returnValue; +} + + + +/* +* λ +* ˵ const UINT16 maskId, λID +* UINT8* dataBuf, λbuf +* ֵ +* +*/ +void SetMaskValue(const UINT16 maskId, UINT8* dataBuf) +{ + UINT16 divNum = 0u; /**/ + UINT16 remNum = 0u; /**/ + + if ((maskId > 0u) && (dataBuf != NULL)) + { + divNum = (UINT16)(maskId / 8u); + remNum = (UINT16)(maskId % 8u); + + if (0u == remNum) + { + dataBuf[divNum - 1U] = (UINT8)(dataBuf[divNum - 1U] | 0x01u); + } + else + { + dataBuf[divNum] = (UINT8)(dataBuf[divNum] | (0x80u >> (remNum - 1u)));/*remNum0-7ȡֵ*/ + } + } + else + { + /**/ + } +} + + +/* +* λ +* ˵ const UINT8* SourceDataBuf, Դݻ +* const UINT16 SourceDataLength, Դܳ +* UINT16 MaskSum, λ ʵʵλСSourceDataLength*8 +* UINT8* TargetDataBuf, Ŀݻ +* ֵ 0: ʧ +* >0: ɹ +*/ +UINT8 GetMaskValue(UINT8* TargetDataBuf, const UINT16 MaskSum, const UINT8* SourceDataBuf, const UINT16 SourceDataLength) +{ + UINT16 curSor = 0u; /*Ŀݻ±*/ + UINT8 res = 0u; /**/ + UINT16 ii = 0u; /*Դݻ±*/ + UINT16 jj; /*λ±*/ + UINT8 returnValue = 0u; /*ĬϽʧ*/ + + for (ii = 0u; ii < SourceDataLength; ii++) + { + for (jj = 0u; jj < 8u; jj++) + { + + {/*λδ*/ + + res = (UINT8)((SourceDataBuf[ii] >> (7u - jj)) % 2u);/*2*/ + if (res == 0u) + { + TargetDataBuf[curSor++] = 0u; + } + else + { + TargetDataBuf[curSor++] = 1u; + } + } + + if (MaskSum == curSor) + {/*λ*/ + + returnValue = 1u; + break; + } + + + } + if (1u == returnValue) + { + break; + } + } + + + return returnValue; +} + +/* +* 㱣Чλ +* ˵ const UINT16 ovlpId, ID +* ֵ +CI_SUCCESS: Ч +* CI_ERROR: Ч +*/ +UINT8 OverlapValidMaskCheck(const UINT16 rtOverlapLockedId) +{ + UINT8 returnValue = CI_ERROR; /*ֵ*/ + UINT8 overlapPhySecSum = 0u;/*ΰĿ*/ + UINT16* overlapContainPhySecIdBuf = NULL;/*ΰ*/ + UINT8 ovpLockState = 0u;/*״̬*/ + UINT8 ii = 0u; + + /* overlap */ + UINT8 checkSum = 0u; + OverlapConditionSwitchStruct* condSwiDataIdBuf = NULL; + /* overlap */ + UINT8 protectSwitchSum = 0u; + UINT8 lockStatus = 0u; + UINT8 ylockStatus = 0u;/*ʱ״̬*/ + UINT8 fengsuoStateus = 0u;/*ʱ״̬*/ + UINT8 switchPos = 0u;/*ʱλ*/ + OverlapProtectSwitchStruct* protSwiDataIdBuf = NULL; + + /**/ + UINT16 devId = 0u; + UINT8 devStateType = 0u; /*豸״̬*/ + UINT8 devState = 0u; + UINT32 laborUnlockStartCycNum = 0u; + UINT8 functionId = EFUNC_OVERLAP_VALIDMASK_CHECK; + + if (0u != rtOverlapLockedId) + { + overlapPhySecSum = GetOverlapPhySecSum(rtOverlapLockedId); + overlapContainPhySecIdBuf = GetOverlapPhySecIdBuf(rtOverlapLockedId); + for (ii = 0u; ii < overlapPhySecSum; ii++) + {/*ΰǷԾ*/ + /*Ծջη״̬ʱCI->ZC,CI->ATSͱ*/ + + if ((PHYSICAL_SECTION_FLOCK_NO != GetPhySecFLockState(overlapContainPhySecIdBuf[ii]))) +#if 0 + || (PHYSICAL_SECTION_JUMP_LOCK_YES == GetPhySecJumpLockState(overlapContainPhySecIdBuf[ii])) + + /*߼һ£ռѹ*/ + || (SECTION_OCCUPY_YES == GetPhySecCurMergeState(overlapContainPhySecIdBuf[ii]))) +#endif + { + returnValue = CI_ERROR; + break; + } + } + + if (ii == overlapPhySecSum) + { + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + + if (CI_SUCCESS == returnValue) + { /* overlap */ + checkSum = GetOverlapSwitchSum(rtOverlapLockedId); + condSwiDataIdBuf = GetOverlapCondSwitchStruct(rtOverlapLockedId); + for (ii = 0u; ii < checkSum; ii++) + { + if ((SWITCH_LOCK_YINZONG_NO == GetSwitchYLockState(condSwiDataIdBuf[ii].SwitchId)) && + (SWITCH_LOCK_FENGSUO_NO == GetSwitchFLockState(condSwiDataIdBuf[ii].SwitchId)) && + (condSwiDataIdBuf[ii].SwitchPosition == GetSwitchCurPosition(condSwiDataIdBuf[ii].SwitchId))) + { + /* ĵΪδҵλȷŷλ*/ + + } + else + { + + returnValue = CI_ERROR; + break; + } + } + } + + if (CI_SUCCESS == returnValue) + { /*ι*/ + protectSwitchSum = GetOverlapRelatedProtSwitSum(rtOverlapLockedId); + protSwiDataIdBuf = GetOverlapRelatedProtSwitStru(rtOverlapLockedId); + for (ii = 0u; ii < protectSwitchSum; ii++) + { + lockStatus = GetSwitchLockStatus(protSwiDataIdBuf[ii].ProtectSwitchId); + ylockStatus = GetSwitchYLockState(protSwiDataIdBuf[ii].ProtectSwitchId); + switchPos = GetSwitchCurPosition(protSwiDataIdBuf[ii].ProtectSwitchId); + fengsuoStateus = GetSwitchFLockState(protSwiDataIdBuf[ii].ProtectSwitchId); + + if ((SWITCH_LOCK_YINZONG_NO == ylockStatus) + && ((SWITCH_LOCK_STATUS_PROTECT == lockStatus) || (SWITCH_LOCK_STATUS_DAP == lockStatus)) + && (protSwiDataIdBuf[ii].ProtectPosition == switchPos) + && (SWITCH_LOCK_FENGSUO_NO == fengsuoStateus)) + { + /* ιҷҵλȷδŷλ*/ + } + else + { + returnValue = CI_ERROR; + break; + } + } + } + + if (CI_SUCCESS == returnValue) + { + ovpLockState = GetOverlapLockState(rtOverlapLockedId); + if (CI_SUCCESS == ovpLockState) + { + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + } + + if (CI_SUCCESS == returnValue) + { + if (CI_SUCCESS == OverlapInvSecAndConSwiCheckup(rtOverlapLockedId, NULL, NULL)) + { + returnValue = CI_SUCCESS; + } + else + { + returnValue = CI_ERROR; + } + } + + /*鱣ι״̬*/ + if (CI_SUCCESS == returnValue) + { + returnValue = OverlapFloodGateStateCheck(rtOverlapLockedId, &devId, &devStateType, &devState); + if (CI_ERROR == returnValue) + { + SetErrorData(functionId, CI_DEVICE_TYPE_FLOODGATE, devId, devStateType, devState, ESEND_LEVEL_ZERO); + } + } + /*˹ǷڵʱУʱзZC,LEUδ*/ + if (CI_SUCCESS == returnValue) + { + laborUnlockStartCycNum = GetlaborUnlockStartCycNum(rtOverlapLockedId); + if (0u < laborUnlockStartCycNum) + { + returnValue = CI_ERROR; + } + } + } + else + { + returnValue = CI_ERROR; + } + + return returnValue; +} + + +/* +* CIMͨ״̬Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimCommData(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT8 j = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u }; + UINT8 deviceSum = 0u; /*ͨ豸*/ + UINT8* pDeviceIdBuf = NULL; /*豸ID*/ + UINT8 transmitState = 0u; /*ͨ״̬*/ + UINT8 transmitDevSum = 0U; + UINT16 transmitDevIndex = 0U; + + + ciToCimDataBuffer[i++] = GetLocalRcWorkMode(); + ciToCimDataBuffer[i++] =GetSystemParaLocalCiId (); + + transmitDevIndex = i; + i++; + /*ZCͨ״̬*/ + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC); + if (NULL != pDeviceIdBuf) + { + /*ֻӦһZC*/ + transmitDevSum++; + transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_ZC, 0U); + ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_ZC; + ciToCimDataBuffer[i++] = pDeviceIdBuf[0]; + ciToCimDataBuffer[i++] = 0U; + if (TRANSMIT_2OO2_STATE_GOOD == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD; + } + else if (TRANSMIT_2OO2_STATE_LINK == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK; + } + else + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD; + } + } + + /*TMCͨ״̬*/ + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_TMC); + if (NULL != pDeviceIdBuf) + { + /*ֻӦһTMC*/ + transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_TMC, 0U); + + transmitDevSum++; + ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_TMC; + ciToCimDataBuffer[i++] = pDeviceIdBuf[0]; + ciToCimDataBuffer[i++] = 0U; + if (TRANSMIT_2OO2_STATE_GOOD == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD; + } + else if (TRANSMIT_2OO2_STATE_LINK == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK; + } + else + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD; + } + } + /*OCͨ״̬*/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC); + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); + + if ((NULL != pDeviceIdBuf) && (0u != deviceSum)) + { + for (j = 0u; j < deviceSum; j++) + { + transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_OC, j); + + transmitDevSum++; + ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_OC; + ciToCimDataBuffer[i++] = pDeviceIdBuf[j]; + /*ͨ*/ + ciToCimDataBuffer[i++] = 0U; + if (TRANSMIT_2OO2_STATE_GOOD == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD; + } + else if (TRANSMIT_2OO2_STATE_LINK == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK; + } + else + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD; + } + + } + + } + + /*PSCͨ״̬*/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PSC); + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PSC); + + if ((NULL != pDeviceIdBuf) && (0u != deviceSum)) + { + for (j = 0u; j < deviceSum; j++) + { + transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_PSC, j); + + transmitDevSum++; + ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_PSC; + /*ID*/ + ciToCimDataBuffer[i++] = pDeviceIdBuf[j]; + /*ͨ*/ + ciToCimDataBuffer[i++] = 0U; + if (TRANSMIT_2OO2_STATE_GOOD == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD; + } + else if (TRANSMIT_2OO2_STATE_LINK == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK; + } + else + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD; + } + } + + } + + /*ϵͳͨ״̬*/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); + + if ((NULL != pDeviceIdBuf) && (0u != deviceSum)) + { + for (j = 0u; j < deviceSum; j++) + { + transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_AXIS, j); + /*ID*/ + + transmitDevSum++; + ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_AXIS; + ciToCimDataBuffer[i++] = pDeviceIdBuf[j]; + /*ͨ*/ + ciToCimDataBuffer[i++] = 0U; + if (TRANSMIT_2OO2_STATE_GOOD == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD; + } + else if (TRANSMIT_2OO2_STATE_LINK == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK; + } + else + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD; + } + } + + } + + + /*CIϵͳͨ״̬*/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_CI); + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_CI); + + if ((NULL != pDeviceIdBuf) && (0u != deviceSum)) + { + for (j = 0u; j < deviceSum; j++) + { + transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_CI, j); + /*ID*/ + + transmitDevSum++; + ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_CI; + ciToCimDataBuffer[i++] = pDeviceIdBuf[j]; + + ciToCimDataBuffer[i++] = 0U; + /*ͨ*/ + if (TRANSMIT_2OO2_STATE_GOOD == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD; + } + else if (TRANSMIT_2OO2_STATE_LINK == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK; + } + else + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD; + } + } + + } + /*ֵϵͳͨ״̬*/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_XIANDI); + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_XIANDI); + + if ((NULL != pDeviceIdBuf) && (0u != deviceSum)) + { + for (j = 0u; j < deviceSum; j++) + { + transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_XIANDI, j); + /*ID*/ + + transmitDevSum++; + ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_XIANDI; + ciToCimDataBuffer[i++] = pDeviceIdBuf[j]; + + ciToCimDataBuffer[i++] = 0U; + /*ͨ*/ + if (TRANSMIT_2OO2_STATE_GOOD == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD; + } + else if (TRANSMIT_2OO2_STATE_LINK == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK; + } + else + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD; + } + } + + } + + /*ATSϵͳͨ״̬*/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_ATS); + pDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ATS); + + if ((NULL != pDeviceIdBuf) && (0u != deviceSum)) + { + for (j = 0u; j < deviceSum; j++) + { + transmitState = Get2oo2CiAndOtherSysCommState(CI_SYSTEM_TYPE_ATS, j); + /*ID*/ + + transmitDevSum++; + ciToCimDataBuffer[i++] = CI_SYSTEM_TYPE_ATS; + ciToCimDataBuffer[i++] = pDeviceIdBuf[j]; + + ciToCimDataBuffer[i++] = 0U; + /*ͨ*/ + if (TRANSMIT_2OO2_STATE_GOOD == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_GOOD; + } + else if (TRANSMIT_2OO2_STATE_LINK == transmitState) + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_LINK; + } + else + { + ciToCimDataBuffer[i++] = CI_AND_OTHER_TRANSMIT_BAD; + } + } + + } + + ciToCimDataBuffer[transmitDevIndex] =transmitDevSum; + /*CIM*/ + (void)DarkInfoPack(CIM_INFO_COMM_STATE, ciToCimDataBuffer, i); + +} + +/* +* CIMźŻ˿״̬Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimSignalDsData(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u }; + UINT8 redDsFlag = 0u; /*ƶ˿*/ + UINT8 greenDsFlag = 0u; /*̵ƶ˿*/ + UINT8 yellowDsFlag = 0u; /*Ƶƶ˿*/ + UINT8 whiteDsFlag = 0u; /*׵ƶ˿*/ + UINT8 redYellowDsFlag = 0u; /*Ƶƶ˿*/ + UINT8 redWhiteDsFlag = 0u; /*׵ƶ˿*/ + UINT8 greenYellowDsFlag = 0u; /*̻Ƶƶ˿*/ + UINT8 doubleGreenDsFlag = 0u; /*˫̵ƶ˿*/ + UINT8 doubleYellowDsFlag = 0u; /*˫Ƶƶ˿*/ + UINT8 signalDsSum = 0u; /*˿źŻ*/ + UINT16 signalSum = 0u; /*źŻ*/ + UINT16 deviceId = 0u; + UINT8 signalNoLine = 0u; + UINT8 signalDsStateSum = 0u; /*źŻ˿״̬*/ + UINT16 dsIndex = 0u; + UINT16 sumIndex = 0u; + UINT32 curCycleNum = 0u;/*ǰ*/ + + /*ȡźŻ*/ + signalSum = GetSignalCurSum(); + curCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + + + /*CI*/ + LongToChar(curCycleNum, &ciToCimDataBuffer[i]); + i += 4u; + + sumIndex = i; /*¼ǰλ*/ + /*0*/ + ciToCimDataBuffer[i++] = 0u; + for (j = 0u; j < signalSum; j++) + { + deviceId = GetSignalId(j); + /*ͬźŻ*/ + signalDsStateSum = 0u; + /*źŻڱ*/ + signalNoLine = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, deviceId); + if (CI_TRUE == signalNoLine) + { + /*ȡ˿˿״̬*/ + redDsFlag = GetSignalDsBreakFlag(deviceId); + greenDsFlag = GetSignalGreenDsBreakFlag(deviceId); + yellowDsFlag = GetSignalYellowDsBreakFlag(deviceId); + whiteDsFlag = GetSignalWhiteDsBreakFlag(deviceId); + redYellowDsFlag = GetSignalRedYellowDsBreakFlag(deviceId); + redWhiteDsFlag = GetSignalRedWhiteDsBreakFlag(deviceId); + greenYellowDsFlag = GetSignalGreenYellowDsBreakFlag(deviceId); + doubleGreenDsFlag = GetSignalDoubleGreenDsBreakFlag(deviceId); + doubleYellowDsFlag = GetSigDoubleYellowDsBreakFlag(deviceId); + + /*źŻ˿״̬*/ + if ((SIGNAL_DS_BREAK_YES == redDsFlag) || (SIGNAL_DS_BREAK_YES == greenDsFlag) + || (SIGNAL_DS_BREAK_YES == yellowDsFlag) || (SIGNAL_DS_BREAK_YES == whiteDsFlag) + || (SIGNAL_DS_BREAK_YES == redYellowDsFlag) || (SIGNAL_DS_BREAK_YES == redWhiteDsFlag) + || (SIGNAL_DS_BREAK_YES == greenYellowDsFlag) || (SIGNAL_DS_BREAK_YES == doubleGreenDsFlag) + || (SIGNAL_DS_BREAK_YES == doubleYellowDsFlag)) + { + signalDsSum++; /*źŻ˿Լ1*/ + ShortToChar(deviceId, &ciToCimDataBuffer[i]); /*źŻID*/ + i += 2u; + dsIndex = i;/*¼λ*/ + /*˿״̬0*/ + ciToCimDataBuffer[i++] = 0u; + + /**/ + if (SIGNAL_DS_BREAK_YES == redDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_RED_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*̶*/ + if (SIGNAL_DS_BREAK_YES == greenDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_GREEN_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*ƶ*/ + if (SIGNAL_DS_BREAK_YES == yellowDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_YELLOW_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*׶*/ + if (SIGNAL_DS_BREAK_YES == whiteDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_WHITE_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*ƶ*/ + if (SIGNAL_DS_BREAK_YES == redYellowDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_RED_YELLOW_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*׶*/ + if (SIGNAL_DS_BREAK_YES == redWhiteDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_RED_WHITE_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*̻ƶ*/ + if (SIGNAL_DS_BREAK_YES == greenYellowDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_GREEN_YELLOW_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*˫̶*/ + if (SIGNAL_DS_BREAK_YES == doubleGreenDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_DOUBLE_GREEN_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*˫ƶ*/ + if (SIGNAL_DS_BREAK_YES == doubleYellowDsFlag) + { + ciToCimDataBuffer[i++] = SIGNAL_DOUBLE_YELLOW_DS_STATE; + signalDsStateSum++; /*˿״̬1*/ + } + /*źŻ˿״̬*/ + ciToCimDataBuffer[dsIndex] = signalDsStateSum; + } + + + } + } + /*˿źŻ*/ + ciToCimDataBuffer[sumIndex] = signalDsSum; + /*ά*/ + (void)DarkInfoPack(CIM_INFO_SIGNAL_DS_STATE, ciToCimDataBuffer, i); + +} +/* +* µ۷ťλ +* ˵ void +* ֵ +* +*/ +void DealAutoReturnButtonMask_Vir(UINT16 DeviceId, UINT16 MaskId, UINT8* pdataBuf) +{ + UINT16 ii = 0u; + UINT16 localCIBaojingdengNum = GetLocalCIBaojingdengNum(); + UINT16 localCIBaojingdengWId = 0u;/*ʾƼ̵ID*/ + UINT8 indicatorID = 0u;/*ʾƼ̵ID*/ + UINT8 localCIBaojingdengType = 0u; + UINT8 belongVirCI = 0u; + UINT8 relaySum = 0u; + UINT16* pRelayIdBuf = NULL; + UINT8 RelayCollState = 0u; + UINT8 localCi = GetSystemParaLocalCiId(); + UINT8 virtualZDZFBelongCiId = 0U; + UINT8 virtualZDZFDevType = 0U; + UINT8 virtualZDZFButtonState = 0U; + UINT8 chRtnIndicatorDevId = 0U;/*۷豸ID*/ + UINT8 chNonRrnAdhesionState = 0U;/*۷ťճ״̬*/ + + chRtnIndicatorDevId = GetIndicatorRelNonReturnId(DeviceId); + virtualZDZFBelongCiId = GetVirtualZDZFBelongCiId(); + virtualZDZFDevType = GetVirtualZDZFDevType(); + virtualZDZFButtonState = GetVirtualZDZFButtonState(); + + for (ii = 0u; ii < localCIBaojingdengNum; ii++) + { + localCIBaojingdengWId = GetLocalCIBaojingdengWId(ii); + localCIBaojingdengType = GetLocalCIIndicatorIDOrType(ii); + + if ((DeviceId == localCIBaojingdengWId) && (INDICATOR_TYPE_EXPRESS_RETURN == localCIBaojingdengType)) + {/*豸IDӦָʾΪ۷*/ + indicatorID = GetLocalCIIndicatorIDOrType(ii); + belongVirCI = (UINT8)GetLocalCIBaojingdengBelongVir(ii); + + if ((virtualZDZFBelongCiId == localCi) && (CI_DEVICE_TYPE_AUTORETURN == virtualZDZFDevType)) + {/*Ŀǰһʵֻ֧һ۷ťΪ豸*/ + if (VIRTUAL_ZDZFAJ_BUTTON_YES == virtualZDZFButtonState) + {/*豸۷ť*/ + SetMaskValue(MaskId, pdataBuf); + } + } + else + {/*۷ťʵ*/ + relaySum = GetVirCIIndicConfDataRelaySum(belongVirCI, indicatorID); + pRelayIdBuf = GetVirCIIndicConfDataRelayBuf(belongVirCI, indicatorID); + if ((3u != relaySum) || (NULL == pRelayIdBuf)) + {/*̵ݴ۷ťΪ豸*/ + break; + } + else + { + RelayCollState = GetRelayCollState(pRelayIdBuf[2]); + chNonRrnAdhesionState = GetNonRtnAdhesionState(chRtnIndicatorDevId); + if ((RELAY_STATE_UP == RelayCollState) && (RTN_RELAY_ADHESION_NO == chNonRrnAdhesionState)) + {/*۷ť̵*/ + SetMaskValue(MaskId, pdataBuf); + } + else + { + } + } + } + + } + } +} + +/* +* CIM̵Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimRelayHunXianData(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u }; + UINT32 curCycleNum = 0u;/*ǰ*/ + UINT16 relaySum = 0u; + UINT16 relayId = 0u; + UINT8 belongCi = 0u; + UINT8 localCiId = 0u; + UINT8 hunXianState = 0u; + UINT16 hunXianRelaySum = 0u; + UINT16 sumIndex = 0u; + + relaySum = GetRelayCurSum(); + curCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + sumIndex = i; /*¼ǰλ*/ + /*ֽ*/ + i += 2u; + + for (j = 0u; j < relaySum; j++) + { + relayId = GetRelayId(j); + /*ȡ̵Ϣ*/ + belongCi = GetRelayBelongCiId(relayId); + if (localCiId == belongCi) + { + hunXianState = GetRelayHunXianState(relayId); + if (RELAY_HUNXIAN_STATE_YES == hunXianState) + { + hunXianRelaySum++; + ShortToChar(relayId, &ciToCimDataBuffer[i]); /*̵ID*/ + i += 2u; + } + else + { + /**/ + } + } + } + /*д*/ + + ShortToChar(hunXianRelaySum, &ciToCimDataBuffer[sumIndex]); + i += 2u; + + /*ά*/ + (void)DarkInfoPack(CIM_INFOR_RELAY_HUNXIAN_STATE, ciToCimDataBuffer, i); +} +/* +* CIMű֡ +* ˵ void +* ֵ +* cgh-ϲCID-2349-4 +*/ +void PackCiToCimPsdAlarmData(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 psdNum = 0u; + UINT16 psdId = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u }; + UINT16 sumIndex = 0u; + UINT8 psdDriveOutTimeState = 0u; + UINT8 psdDriAndCollDiff = 0u; + UINT16 diffNum = 0u; + UINT8 psdBelongCiId = 0u; + UINT8 localCIid = GetSystemParaLocalCiId(); + + /*ȡĿ*/ + psdNum = GetTotalPsdCurNum(); + + sumIndex = i; /*¼ǰλ*/ + /*0*/ + i += 2U;/*Ԥ*/ + for (j = 0u; j < psdNum; j++) + { + psdId = GetPsdId(j); + psdBelongCiId = GetPsdBelongCiId(psdId); + + if (localCIid == psdBelongCiId) + { + /*δӦϢ*/ + psdDriveOutTimeState = CheckPsdDriveOutTimeState(psdId); + /*ɼһϢ*/ + psdDriAndCollDiff = CheckPsdDriAndCollDiff(psdId); + + if ((UINT8_MAX != psdDriveOutTimeState) || (UINT8_MAX != psdDriAndCollDiff)) + {/**/ + diffNum++; + + ShortToChar(psdId, &ciToCimDataBuffer[i]); /*psd id*/ + i += 2U; + ciToCimDataBuffer[i++] = psdDriveOutTimeState;/*ʱϢ*/ + ciToCimDataBuffer[i++] = psdDriAndCollDiff; + + ciToCimDataBuffer[i++] = 0xffU;/*ָͻԤ*/ + } + + } + } + /*PSDĿ*/ + ShortToChar(diffNum, &ciToCimDataBuffer[sumIndex]); + /*ά*/ + (void)DarkInfoPack(CIM_INFO_PSD_ALARM, ciToCimDataBuffer, i); + +} + +/* +* CIM̵ɼһ±Ϣ +* ˵ void +* ֵ +* cgh-ϲCID-2349-4 +*/ +void PackCiToCimRelayDriAndCollDiff(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u }; + UINT16 relaySum = 0u; /*̵*/ + UINT16 relayId = 0u; + UINT32 curCycleNum = 0u;/*ǰ*/ + UINT8 foreNodeAColl = 0u; + UINT8 backNodeAColl = 0u; + UINT8 foreNodeBColl = 0u; + UINT8 backNodeBColl = 0u; + UINT8 reValA = 0u; + UINT8 reValB = 0u; + UINT16 diffNum = 0u; + UINT8 relayDrvAddrA = 0u; + UINT8 relayDrvAddrB = 0u; + UINT8 relayDrvPosA = 0u; + UINT8 relayDrvPosB = 0u; + UINT8 relayBelongCiId = 0u; + UINT8 localCiId = GetSystemParaLocalCiId(); + UINT16 sumIndex = 0u; + UINT8 collectMode = 0u; + UINT8 drvAddrA = 0u; + UINT8 drvPosA = 0u; + UINT8 drvAddrB = 0u; + UINT8 drvPosB = 0u; + + /*ȡ̵*/ + relaySum = GetRelayCurSum(); + curCycleNum = Get2oo2CurCycleNum();/*ȡǰں*/ + + sumIndex = i; /*¼ǰλ*/ + + i = i + 2U;/*Ԥ*/ + for (j = 0u; j < relaySum; j++) + { + relayId = GetRelayId(j); + relayBelongCiId = GetRelayBelongCiId(relayId); + if (localCiId == relayBelongCiId) + { + /*ȡ̵ַϢ*/ + drvAddrA = GetRelayDrvAddrA(relayId); + drvPosA = GetRelayDrvPosA(relayId); + drvAddrB = GetRelayDrvAddrB(relayId); + drvPosB = GetRelayDrvPosB(relayId); + /*ȡɼʽ*/ + collectMode = GetRelayCollectMode(relayId); + + if ((drvAddrA > 0u) && (drvPosA > 0u) && (drvAddrB > 0u) && (drvPosB > 0u) + && (collectMode > 0u)) + { + /*AϵǷɼһ*/ + foreNodeAColl = GetForeNodeACollState(relayId); + backNodeAColl = GetBackNodeACollState(relayId); + reValA = CheckRelayDriAndCollDiffSeat(relayId, foreNodeAColl, backNodeAColl); + /*BϵǷɼһ*/ + foreNodeBColl = GetForeNodeBCollState(relayId); + backNodeBColl = GetBackNodeBCollState(relayId); + reValB = CheckRelayDriAndCollDiffSeat(relayId, foreNodeBColl, backNodeBColl); + + if ((CI_ERROR == reValA) || (CI_ERROR == reValB))/**ABϵɼһ*/ + { + diffNum++;/*¼ɼ̵һĿ*/ + relayDrvAddrA = UINT8_MAX;/*Ĭֵ*/ + relayDrvPosA = UINT8_MAX; + + relayDrvAddrB = UINT8_MAX; + relayDrvPosB = UINT8_MAX; + + if (CI_ERROR == reValA) + { + relayDrvAddrA = GetRelayDrvAddrA(relayId); + relayDrvPosA = GetRelayDrvPosA(relayId); + } + if (CI_ERROR == reValB) + { + relayDrvAddrB = GetRelayDrvAddrB(relayId); + relayDrvPosB = GetRelayDrvPosB(relayId); + } + + ShortToChar(relayId, &ciToCimDataBuffer[i]);/*̵ID*/ + i = i + 2U; + ciToCimDataBuffer[i++] = relayDrvAddrA;/*Aϵ忨ַ*/ + ciToCimDataBuffer[i++] = relayDrvPosA;/*Aϵڵλ*/ + ciToCimDataBuffer[i++] = relayDrvAddrB;/*Bϵ忨ַ*/ + ciToCimDataBuffer[i++] = relayDrvPosB;/*Bϵڵλ*/ + + } + } + + + } + + } + /*ɼһ¼̵*/ + ShortToChar(diffNum, &ciToCimDataBuffer[sumIndex]); + /*ά*/ + (void)DarkInfoPack(CIM_INFO_RELAY_DRVANDCOLLDEF, ciToCimDataBuffer, i); + +} + +/* +* CIMźŻʱϢ +* ˵ void +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void PackCiToCimSigDriOutTimeData(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0 }; + UINT16 signalSum = 0u; /*źŻ*/ + UINT16 deviceId = 0u; + UINT8 signalNoLine = 0u; + UINT16 sumIndex = 0u; + UINT8 curDrvColor = 0u; + UINT32 sigDriCloseStarNum = 0u; + UINT32 SigDriOpenStartNum = 0u; + UINT32 SysParaSigCloseCount = 0u; + UINT32 SysParaSigOpenCount = 0u; + UINT8 checkOut = 0u; + UINT8 signalDriOutTimeSum = 0u; + UINT8 signalCurColor = 0u; + UINT8 signalOpenCloseState = 0u; + UINT32 SigDifColorOpenStartNum = 0u; + UINT32 actionMaxCount = 0u; + UINT8 CiPattern = 0u; + UINT8 chDsnLinSwitch = 0U; + UINT8 signalPreDrvColor = 0U; + chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + CiPattern = GetLocalCiPattern(); + /*ȡźŻ*/ + signalSum = GetSignalCurSum(); + + sumIndex = i; /*¼ǰλ*/ + /*0*/ + ciToCimDataBuffer[i++] = 0u; + for (j = 0U; j < signalSum; j++) + { + deviceId = GetSignalId(j); + /*źŻڱ*/ + signalNoLine = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_SIGNAL, deviceId); + if (CI_TRUE == signalNoLine) + { + /*ȡźŻɫ*/ + curDrvColor = GetSignalCurDriveColor(deviceId); /*ȡźŻǰɫ*/ + + if ((SIGNAL_DRIVECOLOUR_NULL == curDrvColor) || (0u == curDrvColor)) + {/*źŻЧ*/ + } + else + { + if ((SIGNAL_DRIVECOLOUR_RED == curDrvColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == curDrvColor)) + {/*źŻر*/ + sigDriCloseStarNum = GetSignalDriveCloseStartCycNum(deviceId); + SysParaSigCloseCount = GetSystemParaSignalCloseCyc(); + checkOut = SystemOverTimeCheck(sigDriCloseStarNum, SysParaSigCloseCount); + if (CI_TIME_OUT == checkOut) + { + signalDriOutTimeSum++; /*źŻʱ*/ + ShortToChar(deviceId, &ciToCimDataBuffer[i]); /*źŻID*/ + i += 2U; + /*дʱɫ*/ + ciToCimDataBuffer[i++] = curDrvColor; + } + } + else + {/**/ + signalCurColor = GetSignalCurColor(deviceId); + signalOpenCloseState = GetSignalOpenCloseState(signalCurColor); + if (SIGNAL_CLOSE == signalOpenCloseState) + {/*źŻǰ״̬رգɹرųʱ*/ + SigDriOpenStartNum = GetSignalDriveOpenStartCycNum(deviceId); + SysParaSigOpenCount = GetSystemParaSignalOpenCyc(); + if (0u < SysParaSigOpenCount) + {/*鵽ųʱ󣬻رաǰһڽʱ*/ + SysParaSigOpenCount = SysParaSigOpenCount - 1U; + } + checkOut = SystemOverTimeCheck(SigDriOpenStartNum, SysParaSigOpenCount); + if (CI_TIME_OUT == checkOut) + { + signalDriOutTimeSum++; /*źŻʱ*/ + ShortToChar(deviceId, &ciToCimDataBuffer[i]); /*źŻID*/ + i += 2U; + /*дʱɫ*/ + ciToCimDataBuffer[i++] = curDrvColor; + } + } + else + {/*źŻǰ״̬ţɵǰĿɫһֿɫʱ*/ + SigDifColorOpenStartNum = GetSignalDiffColorOpenStartCyc(deviceId); + signalPreDrvColor = GetSignalPreDriveColor(deviceId);/*ȡźŻ֮ǰɫ*/ + if ((CI_PATTERN_FULL_ELECTRONIC == CiPattern) && (FUNC_SWITCH_OFF == chDsnLinSwitch)&& (SIGNAL_DRIVECOLOUR_GREENYELLOW == signalPreDrvColor)) + { + /*ȫǵʿ ̻ Ժ̵ʹ̻Ƶ޸*/ + actionMaxCount = GetSystemParaSignalOpenCyc() - 2u;/*2ΪʾͬĶӦѾرˣҪǰ*/ + } + else if (2u <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + actionMaxCount = SIGNAL_RELAY_ACTION_TIMEMAX - 2u;/*2Ϊʾͬĵ10ѾرˣҪڵ9ǰ*/ + } + else + { + actionMaxCount = SIGNAL_RELAY_ACTION_TIMEMAX; + } + checkOut = SystemOverTimeCheck(SigDifColorOpenStartNum, actionMaxCount); + if (CI_TIME_OUT == checkOut) + { + signalDriOutTimeSum++; /*źŻʱ*/ + ShortToChar(deviceId, &ciToCimDataBuffer[i]); /*źŻID*/ + i += 2U; + /*дʱɫ*/ + ciToCimDataBuffer[i++] = curDrvColor; + } + } + + + } + + } + } + } + /*źŻ*/ + ciToCimDataBuffer[sumIndex] = signalDriOutTimeSum; + debug_infor_printf((const)"\nCIM_Signal_DriveOutTime \n"); + /*ά*/ + (void)DarkInfoPack(CIM_INFO_SIGNAL_DRIVOUT, ciToCimDataBuffer, i); + +} + + +/* +* Ͱ汾Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimVerData(void) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u }; + UINT16* pTiocFsVersion = NULL; /*FS汾buff*/ + + /*FS汾*/ + pTiocFsVersion = GetTiocFsVersion(); + ciToCimDataBuffer[i++] = (UINT8)pTiocFsVersion[0]; + ciToCimDataBuffer[i++] = (UINT8)pTiocFsVersion[1]; + ciToCimDataBuffer[i++] = (UINT8)(pTiocFsVersion[2] >> 4U); + ciToCimDataBuffer[i++] = (UINT8)((pTiocFsVersion[2] << 4U) + pTiocFsVersion[3]); + /*汾*/ + ciToCimDataBuffer[i++] = VER_SOFT_PRODUCT; + ciToCimDataBuffer[i++] = VER_SOFT_MODUAL_APP >> 2U; + ciToCimDataBuffer[i++] = (VER_SOFT_MODUAL_APP << 6U) + (VER_SOFT_MIANVERSION & (UINT8)0x3F); + ciToCimDataBuffer[i++] = VER_SOFT_SUBVERSION; + /*鼯ɰ汾*/ + ciToCimDataBuffer[i++] = VER_INTE_PROJECT; + ciToCimDataBuffer[i++] = VER_INTE_PRODUCT; + ciToCimDataBuffer[i++] = (UINT8)((UINT8)VER_INTE_EXE << 1U) + ((UINT8)VER_INTE_TIME >> 7U); + ciToCimDataBuffer[i++] = VER_INTE_TIME; + /*CIM*/ + (void)DarkInfoPack(CIM_INFO_VER_INFO, ciToCimDataBuffer, i); + +} + + +/* +* 豸״̬Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimDeviceData(void) +{ + /*ʼ*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u }; + UINT16 deviceNum = 0U; + UINT16 deviceId = 0U; + SwitchDataStruct* pSwitchData = NULL; + SignalDataStruct* pSignalData = NULL; + PsdDataStruct* pPsdData = NULL; + EsbDataStruct* pEsbData = NULL; + SpksDataStruct* pSpksData = NULL; + PhysicalSectionDataStruct* pPhysicalData = NULL; + WashMachineDataStruct* pWashMachineData = NULL; + GaragedoorDataStruct* pGrageDoorData = NULL; + FloodGateDataStruct* pFloodGateData = NULL; + UINT8 cRcWorkMode = GetLocalRcWorkMode(); + UINT8 chSwitchJichaState = 0U; + + /*͵*/ + pSwitchData = GetSwitchData(); + deviceNum = GetSwitchCurSum(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*ID*/ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++)/*͸ĵĿ*/ + { + + + /*Ƚ*/ + deviceId = GetSwitchId(jj); + + /**************ӡϢ****************/ + + ShortToChar(pSwitchData[deviceId].SwitchId, &ciToCimDataBuffer[ii]);/*ID*/ + ii += 2u; + + + chSwitchJichaState = GetSwitchJichaState(deviceId); + if (SWITCH_POSITION_DYNAMIC_JICHA == chSwitchJichaState) + { + ciToCimDataBuffer[ii++] = 0x20U;/*̬*/ + } + else if (SWITCH_POSITION_SUDDEN_JICHA == chSwitchJichaState) + { + /*ش*/ + ciToCimDataBuffer[ii++] = 0x40U;/*̬*/ + } + else + { + ciToCimDataBuffer[ii++] = pSwitchData[deviceId].SingleSwitchCurPosition;/*ǰλ*/ + } + + + ciToCimDataBuffer[ii++] = pSwitchData[deviceId].SwitchDrivePos;/*λ*/ + ciToCimDataBuffer[ii++] = pSwitchData[deviceId].SwitchDanCaoPostition;/*λ*/ + + ciToCimDataBuffer[ii++] = pSwitchData[deviceId].SwitchByPassState; /*·״̬*/ + ciToCimDataBuffer[ii++] = pSwitchData[deviceId].ConnetSwitchDsState; /*ߵ״̬*/ + } + + /*źŻ*/ + + deviceNum = GetSignalCurSum(); + pSignalData = GetSignalData(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++)/*͸źŻĿ*/ + { + deviceId = GetSignalId(jj); + /**************ӡϢ****************/ + + ShortToChar(pSignalData[deviceId].SignalId, &ciToCimDataBuffer[ii]);/*źŻID*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pSignalData[deviceId].CurColor;/*ǰʾɫ*/ + ciToCimDataBuffer[ii++] = pSignalData[deviceId].CurDriveColor;/*ǰɫ*/ + ciToCimDataBuffer[ii++] = pSignalData[deviceId].CancelDetainBtnErrFlag;/*ȡ۳ťϱ־*/ + ciToCimDataBuffer[ii++] = pSignalData[deviceId].DetainBtnErrFlag;/*۳ťϱ־*/ + ciToCimDataBuffer[ii++] = pSignalData[deviceId].RealyDetainFlag;/*Ӳ߿۳־*/ + ciToCimDataBuffer[ii++] = pSignalData[deviceId].DsBreakFlag;/*˿˿־״̬*/ + } + + /*************************************PSD״̬********************************************/ + /*״̬*/ + deviceNum = GetPsdSum(); + pPsdData = GetPsdData(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++)/*͸PsdĿ*/ + { + + + /*Ƚ*/ + deviceId = GetPsdId(jj); + + /**************ӡϢ****************/ + + ShortToChar(pPsdData[deviceId].PsdId, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pPsdData[deviceId].PsdState;/*״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].MutualLockRemoveState;/*Ż״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].DoorButtonState;/*Űť״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].doorOpenButtonState;/*վ̨Űť״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].doorDepartButtonState;/*վ̨ť״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].PsdRemoraState;/*ϰ״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].JXTCMutualLockState;/*϶̽⻥״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].StartDetectionState;/*̽״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].StopDetectionState; /*ֹͣ̽״̬*/ + ShortToChar(pPsdData[deviceId].SrcVobcId, &ciToCimDataBuffer[ii]);/*ŵĵǰVOBC ID*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pPsdData[deviceId].PsdCmd;/*ŵ*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].PsdDriveState;/*״̬*/ + + ciToCimDataBuffer[ii++] = pPsdData[deviceId].clearPassengerFlag;/*ATSǷͱ־*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].steadyLightFlag; /*ȵƱ־*/ + + + ciToCimDataBuffer[ii++] = pPsdData[deviceId].chCleFarePCBButtonState;/*ȷŰť״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].chCleFarePCBButKeepState;/*ȷŰť״̬*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].chCleFarePDBFlaLigFlag;/*ȷPDBťָʾƱ־*/ + ciToCimDataBuffer[ii++] = pPsdData[deviceId].chVideoQkDriveState; /*Ƶ״̬*/ + ShortToChar(pPsdData[deviceId].wVideoQkRelateVobcId, &ciToCimDataBuffer[ii]);/*ƵͶӦгID*/ + ii += 2u; + + } + + /*״̬*/ + deviceNum = GetEsbSum(); + pEsbData = GetEsbData(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++)/*͸PsdĿ*/ + { + + + /*Ƚ*/ + deviceId = GetEsbId(jj); + + /**************ӡϢ****************/ + + ShortToChar(pEsbData[deviceId].EsbId, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pEsbData[deviceId].EsbState; /*Esb״̬*/ + ciToCimDataBuffer[ii++] = pEsbData[deviceId].CutStatus; /*esb·״̬*/ + ciToCimDataBuffer[ii++] = pEsbData[deviceId].EssSteadyState; /*Esbȵ״̬*/ + ciToCimDataBuffer[ii++] = pEsbData[deviceId].EssFlashState; /*Esb״̬*/ + + + } + + /*״̬*/ + deviceNum = GetSpksSum(); + pSpksData = GetSpksData(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++)/*͸PsdĿ*/ + { + + + /*Ƚ*/ + deviceId = GetSpksIdByIndex(jj); + + /**************ӡϢ****************/ + + ShortToChar(pSpksData[deviceId].spksId, &ciToCimDataBuffer[ii]);/*SPks ID*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pSpksData[deviceId].status; /*Esb״̬*/ + ciToCimDataBuffer[ii++] = pSpksData[deviceId].cutStatus; /*esb·״̬*/ + + + } + + /*״̬*/ + deviceNum = GetPhySecCurSum(); + pPhysicalData = GetPhySecData(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/* */ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++)/*͸PsdĿ*/ + { + /*Ƚ*/ + deviceId = GetPhySecId(jj); + + /**************ӡϢ****************/ + + ShortToChar(pPhysicalData[deviceId].PhysicalSectionId, &ciToCimDataBuffer[ii]);/* ID*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pPhysicalData[deviceId].CurOccupyState; /*ɼռѹ״̬*/ + ciToCimDataBuffer[ii++] = pPhysicalData[deviceId].cAreaUrgentBrakeState; /*ƶ״̬*/ + + ciToCimDataBuffer[ii++] = GetPhySecRelLogSecExistArb(pPhysicalData[deviceId].PhysicalSectionId);/*ARB״̬*/ + + } + + /*************************************ӡϴ********************************************/ + /*ӡϴ*/ + pWashMachineData = GetWashMachineData(); + deviceNum = GetWashMachineSum(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++) + { + + + /*Ƚ*/ + deviceId = GetWashMachineId(jj); + + /**************ӡϢ****************/ + + ShortToChar(pWashMachineData[deviceId].WashMachineId, &ciToCimDataBuffer[ii]);/*ϴID*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashMachineReadyState;/*ϴ״̬*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashMachineRequestVerifyState;/*ϴȷ״̬*/ + + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TrainEmergencyStopState;/*гͣ״̬*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].HeadWashAllowState;/*ͷϴ״̬*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TailWashAllowState;/*βϴ״̬*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TrainOutWashTrainPortAllowState;/*ϴ״̬*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashTrainRequestDrvState;/*ϴ״̬*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TrainHeadStopSteadyDrvState;/*ͷͣ״̬*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].TrainTailStopSteadyDrvState;/*βͣ״̬*/ + ii += 2u; + + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].PauseTrainWashRequestDrvState;/*ͣϴ״̬(ֶ̬:)*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].PaseWashMachineRequesDrvtState;/*ͨϴ״̬(ֶ̬:)*/ + + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashMachineWorkModeDrvtState;/*ϴģʽ״̬(ֶ̬:)*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].WashModeState;/*ϴģʽ(ֶ̬:ɼ)*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].chSetWashWorkModeBack;/*ϴģʽ*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].chDownWashAllowState;/*ģʽϴͬ״̬(ֶ̬:ɼ)*/ + ciToCimDataBuffer[ii++] = pWashMachineData[deviceId].chDownWashAllowPassState;/*ģʽϴͬͨ״̬(ֶ̬:ɼ)*/ + + } + + + /*************************************ӡ********************************************/ + /*ӡ*/ + deviceNum = GetGaragedoorSum(); + pGrageDoorData = GetGaragedoorData(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++) + { + + deviceId = GetGaragedoorId(jj); + + /**************ӡϢ****************/ + + ShortToChar(pGrageDoorData[deviceId].GaragedoorId, &ciToCimDataBuffer[ii]);/*ID (ʼֶ)*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorState; /*״̬ (ֶ̬)*/ + ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorAllowCloseFlag; /*ű־ ZC*/ + ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GDAllowCloseFlagIVOC; /*ű־ IVOC*/ + ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorModeState; /*ģʽ״̬*/ + ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorFaultState; /*Ź״̬*/ + ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].GaragedoorPangLuState; /*·״̬*/; + ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].drvDoorState; /* ״̬*/ + ciToCimDataBuffer[ii++] = pGrageDoorData[deviceId].cmdProcessState; /* ״̬ */ + LongToChar(pGrageDoorData[deviceId].waiteZCResponseStartCycNum, &ciToCimDataBuffer[ii]);/* ȴZCʼʱ */ + ii += 4u; + LongToChar(pGrageDoorData[deviceId].waiteIVOCResponseStartCycNum, &ciToCimDataBuffer[ii]);/* ȴIVOCʼʱ */ + ii += 4u; + LongToChar(pGrageDoorData[deviceId].GaragedoorOpenStartCycNum, &ciToCimDataBuffer[ii]);/* Ŵ򿪿ʼ */ + ii += 4u; + LongToChar(pGrageDoorData[deviceId].GaragedoorCloseStartCycNum, &ciToCimDataBuffer[ii]);/* Źرտʼ */ + ii += 4u; + } + + + /*ӡ*/ + deviceNum = GetFloodGateCurSum(); + pFloodGateData = GetFloodGateData(); + ShortToChar(deviceNum, &ciToCimDataBuffer[ii]);/*PSD ID*/ + ii += 2u; + for (jj = 0u; jj < deviceNum; jj++) + { + + /*Ƚ*/ + deviceId = GetFloodGateId(jj); + + /**************ӡϢ****************/ + + ShortToChar(pFloodGateData[deviceId].FloodGateId, &ciToCimDataBuffer[ii]);/*ID (ʼֶ)*/ + ii += 2u; + ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurOpenLockStateFromFYM; /*ǰ״̬ (ֶ̬)*/ + ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurCloseRequestStateFromFYM; /*ǰ״̬*/ + if ((FLOOD_GATE_CLOSEREQ == pFloodGateData[deviceId].CurCloseRequestStateFromFYM) && (0U < pFloodGateData[deviceId].CurFloodGateDelayCloseStartCyc) && (RC_WORK_MODE_CI == cRcWorkMode)) + { + ciToCimDataBuffer[ii++] = 0x55; /*CIZCͷŹ*/ + } + else + { + ciToCimDataBuffer[ii++] = 0xaa; /*δ*/ + } + ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurAgreeCloseAckFromZC; /*ǰzcظ״̬*/ + ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurAgreeCloseStateIn; /*ǰͬŲɼ״̬*/; + ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].CurAgreeCloseStateOut; /* ǰͬ״ֶ̬̬Σ*/ + LongToChar(pFloodGateData[deviceId].CurFloodGateDelayCloseStartCyc, &ciToCimDataBuffer[ii]);/* Žӽռѹʱſʼʱ */ + ii += 4u; + ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].FloodGateCloseApplyIvocSum; /*Źг*/ + ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].FloodGateCloseAnsIvocSum; /*Źгظ*/ + ciToCimDataBuffer[ii++] = pFloodGateData[deviceId].FloodGateAccessUTFlag; /*ŽӽǷзͨų־*/ + + + } + /*CIM*/ + (void)DarkInfoPack(CIM_INFO_DEVICE_STATE, ciToCimDataBuffer, ii); + +} + + + +/* +* AIM +* ˵AIMϢ֡ +* ֵ +*/ +void AIMOutput(void) +{ + UINT16 wQueueIndex = 0U; /*±*/ + UINT16 wQueueCountTemp = 0U; /*֡*/ + UINT8 g_szAIMOut[CI_TO_AIM_DATA_LEN_MAX] = {0u}; /*AIM֡*/ + + /*ʼAIM*/ + (void)memset(&g_szAIMOut[0], 0xff, CI_TO_AIM_DATA_LEN_MAX); + + wQueueCountTemp = Deploy_PackToAIMInfo(&g_szAIMOut[0], CI_TO_AIM_DATA_LEN_MAX); + + if (0U != wQueueCountTemp) + { + wQueueIndex += wQueueCountTemp; + /******************дȫͨЭ飨SFPϢ***************************/ + /*ProtocolInfoSendЭͣдӦ*/ + ProtocolInfoSend((UINT8)((DEVICE_TYPE_AIM >> 8U) & 0x00ffU), (UINT8)(DEVICE_TYPE_AIM & 0x00ffU), g_szAIMOut, wQueueIndex); + + } + else + { + /**/ + } +} + +/* +* AIM +* ˵ + * @param[in] UINT8 chDevType Ŀ豸 + * @param[in] UINT8 chDevID Ŀ豸ID + * @param[in] UINT8 g_szOutBuffer[] ʵ׵ַ + * @param[in] UINT16 wLength ʵݳ +* ֵ +* +*/ +void ProtocolInfoSend(UINT8 chDevType, UINT8 chDevID, UINT8 g_szOutBuffer[], UINT16 wLength) +{ + /*- ʼ */ + UINT16 logicId = 0u; + UINT16 DataTypeAndId = (UINT16)((UINT16)chDevType << 8U) + (UINT16)chDevID; + UINT8* pLocalPointer = NULL; /*תĵľֲָ*/ + UINT8 g_TempOutBuffer[CI_TO_AIM_DATA_LEN_MAX] = { 0U }; /*ʱ*/ + + + /** VOBC ߼IDΪĬֵ */ + logicId = 0U; + + /*- ʼֲbuff*/ + (void)memset(&g_TempOutBuffer[0u], 0, sizeof(UINT8) * CI_TO_AIM_DATA_LEN_MAX); + + /*- SFPЭ*/ + pLocalPointer = &g_TempOutBuffer[0u]; + ShortToChar((UINT16)(wLength + 4u), pLocalPointer); + + /*ȫͨЭ飨SFPԤֽдΪֵ*/ + /*- дĿ豸ͼID */ + g_TempOutBuffer[2] = chDevType; + g_TempOutBuffer[3] = chDevID; + + /*д豸߼ͺ ݴ úֵʾ*/ + /** д豸߼ID */ + ShortToChar(logicId, &g_TempOutBuffer[4]); + + /** ʵ*/ + (void)memcpy(&g_TempOutBuffer[6], &g_szOutBuffer[0u], (UINT32)wLength); + + /** QNX */ +#if (kPLATFORM==kVXWORKS) + if ((UINT8)((DEVICE_TYPE_AIM >> 8U) & 0x00ff) == chDevType) + { + (void)InnetSafeSend(DataTypeAndId, logicId, g_szOutBuffer, wLength); + debug_infor_printf((const)"\nAIM_SEND:%d", wLength); + debug_out_array(0xAA, g_szOutBuffer, wLength); + } + else + { + (void)OutnetSafeSend(DataTypeAndId, logicId, g_szOutBuffer, wLength); + } +#if 0 + /*- ӡ*/ + ZC_QNX_Printf(chFlag, chDevType, chDevID, wLength + 6u, g_TempOutBuffer); +#endif + +#endif +} + +/* +* ִеԪϢ +* ˵ void +* ֵ +* +*/ +void PackCiToCimUnitAlarmData(void) +{ + /*ʼ*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0u }; + UINT8 wPbNum = 0u; /*ִе*/ + UINT8 kk = 0u; /*α*/ + UINT8 mm = 0U; + UINT16 nn = 0U; + UINT16 ocId = 0u; + UINT16 ocDeviceSum = 0u;/*OC豸*/ + UINT8* pOcDeviceIdBuf = NULL; /*OC豸ID*/ + OcToATSPlusBox szSendAIMPlusBox[MAX_OC_PLUS_BOX_NUM] = { 0U }; /*ATSִеṹϢ,άִеԪϢ͸ATSһATSĽṹ*/ + OcToATSSwitchZzjData szSendAIMSwitchZzjData[SWITCH_SUM_MAX] = { 0U }; /*͸AIMĶǣ*/ + UINT16 wSwitchNum = 0U; /*ǣ*/ + + ocDeviceSum = (UINT16)GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC); /*ȡͨOC豸*/ + pOcDeviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); /*ȡͨOC豸ID*/ + + ShortToChar(ocDeviceSum, &ciToCimDataBuffer[ii]); /*OCܳ*/ + ii += 2u; + + if (NULL != pOcDeviceIdBuf) + { + for (jj = 0u; jj < ocDeviceSum; jj++)/*ͨŵoc*/ + { + ocId = pOcDeviceIdBuf[jj]; /*ȡOC ID*/ + + wPbNum = 0U; /*OCǰֹͬһһOC*/ + + if (0U != ocId) + { + ShortToChar(ocId, &ciToCimDataBuffer[ii]); /*OCID*/ + ii += 2u; + + for (kk = 0u; kk < m_OcToCiOrginDataNum; kk++) + { + if (NULL != m_OcToCiOrginDataArr) + { + if (m_OcToCiOrginDataArr[kk].OcId == ocId)/*ͨţҵ͸ֵ*/ + { + wPbNum = TransCiToAtsOCPlusBoxInfo(szSendAIMPlusBox, &kk); /*OCbyteִеӿת,AIMϢATSϢһôת*/ + wSwitchNum = TransCiToAtsSwitchZzjInfo(szSendAIMSwitchZzjData, &kk); /*ȡ͸AIMĶǣ*/ + } + else + { + + } + } + else + { + } + } + + ciToCimDataBuffer[ii++] = wPbNum; /*ִе,ЧֻΪ0Ҳֻ*/ + if (MAX_OC_PLUS_BOX_NUM >= wPbNum) + { + for (mm = 0u; mm < wPbNum; mm++) + { + ciToCimDataBuffer[ii++] = szSendAIMPlusBox[mm].chPbId; /*ִе*/ + ciToCimDataBuffer[ii++] = szSendAIMPlusBox[mm].SendAtsAsState; /*鱨*/ + } + } + + if (SWITCH_SUM_MAX > wSwitchNum) + { + ShortToChar(wSwitchNum, &ciToCimDataBuffer[ii]); /*ǣ*/ + ii += 2U; + + for (nn = 0U; nn < wSwitchNum; nn++) + { + ShortToChar(szSendAIMSwitchZzjData[nn].wSwitchId, &ciToCimDataBuffer[ii]); /*˫ǣID*/ + ii += 2U; + + if (MAX_OC_SWITCH_INCLUDE_ZZJ_NUM >= szSendAIMSwitchZzjData[nn].chSwIncludeZzjSum) + { + ciToCimDataBuffer[ii++] = szSendAIMSwitchZzjData[nn].chSwIncludeZzjSum; /*ǣת޻*/ + for (mm = 0U; mm < szSendAIMSwitchZzjData[nn].chSwIncludeZzjSum; mm++) + { + ciToCimDataBuffer[ii++] = szSendAIMSwitchZzjData[nn].szSwitchIncldeZzjState[mm]; /*ǣת޻״̬*/ + } + } + else + { + ciToCimDataBuffer[ii++] = 0U; /*ޣǣת޻Ϊ0*/ + } + } + } + else + { + ShortToChar(0U, &ciToCimDataBuffer[ii]); /*ޣǣΪ0*/ + ii += 2U; + } + } + else + { + } + } + } + else + { + } + /*CIM*/ + (void)DarkInfoPack(CIM_INFO_UNIT_ALARM, ciToCimDataBuffer, ii); + +} + + + +/* +* ƽ̨ͨ֡ +* ˵UINT8* datdaBuffݻ +* UINT32 dataLength ֡ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* BY LC +*/ +UINT8 ParasePlantCCUHeartFrame(UINT8* dataBuf) +{ + UINT8 retVal = CI_ERROR; + UINT32 ii = 0U; + UINT32 crcCheck = 0U; + + UINT8 boardCCId = 0U;/*ͨذID */ + UINT16 dataLengthRcv = 0U; /*֡*/ + UINT32 cycCount = 0U; + UINT16 volA = 0U; + UINT16 volB = 0U; + UINT16 curA = 0U; + UINT16 curB = 0U; + UINT16 volCoup = 0U; + UINT16 curCoup = 0U; + UINT32 tempera = 0U; + UINT8 flagEEPROM = 0U; + UINT32 crcRecv = 0U; + + /*յƽ̨֡*/ + if (dataBuf != NULL) + { + retVal = CI_SUCCESS; + + /*ݳ*/ + dataLengthRcv = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + /*忨ID*/ + boardCCId = dataBuf[ii]; + ii += 1u; + /*ں*/ + cycCount= LongFromChar(&dataBuf[ii]); + ii += 4u; + /*24VAԴѹ*/ + volA= ShortFromChar(&dataBuf[ii]); + ii += 2u; + /*24VBԴѹ*/ + volB = ShortFromChar(&dataBuf[ii]); + ii += 2u; + /*24VAԴ*/ + curA = ShortFromChar(&dataBuf[ii]); + ii += 2u; + /*24VBԴ*/ + curB = ShortFromChar(&dataBuf[ii]); + ii += 2u; + /*24VԴϵѹ*/ + volCoup = ShortFromChar(&dataBuf[ii]); + ii += 2u; + /*24VԴϵ*/ + curCoup = ShortFromChar(&dataBuf[ii]); + ii += 2u; + /*¶*/ + tempera = LongFromChar(&dataBuf[ii]); + ii += 4u; + /*EEPROM洢*/ + flagEEPROM = dataBuf[ii]; + ii += 1u; + /*CRCУ*/ + crcRecv = LongFromChar(&dataBuf[ii]); /*ȡCRC*/ + ii += 4u; + + /*У*/ + if (dataLengthRcv == ii - 2U) + { + + /*CRCУ,2CRC4*/ + crcCheck = Tioc_PlatCommonCrc32(&dataBuf[2], 22U); + + + if (crcCheck == crcRecv) + { + /*Уͨ*/ + } + else + { + /*CRCУʧ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:CRC Check Error, RecvCRC:%d, CalCRC:%d", boardCCId, crcRecv, crcCheck); + } + + } + else + { + /*Уʧ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:Length Check Error, RecvLength:%d, RealLength:%d", boardCCId, dataLengthRcv, ii - 2U); + } + + + if (CI_SUCCESS == retVal) + { + /*CCUA ͨغ*/ + if (0x09U == boardCCId) + { + RecvHeartDataStru.voltageA_CCA = volA; + RecvHeartDataStru.voltageB_CCA = volB; + RecvHeartDataStru.currentA_CCA = curA; + RecvHeartDataStru.currentB_CCA = curB; + RecvHeartDataStru.voltageCoup_CCA = volCoup; + RecvHeartDataStru.currentCoup_CCA = curCoup; + RecvHeartDataStru.temperature_CCA = tempera; + RecvHeartDataStru.check_EEPROM_CCA = flagEEPROM; + + /*¼ͨ*/ + RecvHeartDataStru.commStartCycle_CCA = Get2oo2CurCycleNum(); + } + /*CCUB ͨ*/ + else if (0x0CU == boardCCId) + { + RecvHeartDataStru.voltageA_CCB = volA; + RecvHeartDataStru.voltageB_CCB = volB; + RecvHeartDataStru.currentA_CCB = curA; + RecvHeartDataStru.currentB_CCB = curB; + RecvHeartDataStru.voltageCoup_CCB = volCoup; + RecvHeartDataStru.currentCoup_CCB = curCoup; + RecvHeartDataStru.temperature_CCB = tempera; + RecvHeartDataStru.check_EEPROM_CCB = flagEEPROM; + + /*¼ͨ*/ + RecvHeartDataStru.commStartCycle_CCB = Get2oo2CurCycleNum(); + } + else + { + /*忨IDУ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:BoradId Check Error", boardCCId); + } + } + else + { + /*ʧܣݲ*/ + } + + } + else + { + /*ʧ*/ + } + + return retVal; +} + +/* +* ƽ̨չ֡ +* ˵UINT8* datdaBuffݻ +* UINT32 dataLength ֡ +* ֵ void +* BY LC +*/ +UINT8 ParasePlantSEBHeartFrame(UINT8* dataBuf) +{ + UINT8 retVal = CI_ERROR; + UINT32 ii = 0U; + UINT32 crcCheck = 0U; + + UINT8 boardSEBId = 0U;/*չID */ + UINT16 dataLengthRcv = 0U; /*֡*/ + UINT32 crcRecv = 0U; /*CRCУ*/ + UINT32 rcvCyc = 0U; /*ں*/ + /*յƽ̨֡*/ + if (dataBuf != NULL) + { + retVal = CI_SUCCESS; + + /*ݳ*/ + dataLengthRcv = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + + /*忨ID*/ + boardSEBId = dataBuf[ii]; + ii += 1u; + + /*ں*/ + rcvCyc = LongFromChar(&dataBuf[ii]); + ii += 4U; + + /* 3ֽ*/ + ii += 5U; + + + /*CRCУ*/ + crcRecv = LongFromChar(&dataBuf[ii]); /*ȡCRC*/ + ii += 4u; + + /*У*/ /*ܳ16ֽ*/ + if (dataLengthRcv == ii - 2U) + { + + /*CRCУ,2CRC4*/ + crcCheck = Tioc_PlatCommonCrc32(&dataBuf[2], 10U); + + + if (crcCheck == crcRecv) + { + /*Уͨ*/ + + } + else + { + /*CRCУʧ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:CRC Check Error, RecvCRC:%d, CalCRC:%d", boardSEBId, crcRecv, crcCheck); + } + + } + else + { + /*Уʧ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:Length Check Error, RecvLength:%d, RealLength:%d", boardSEBId, dataLengthRcv, ii - 2U); + } + + if (CI_SUCCESS == retVal) + { + /*SEB1*/ + if (BOARD_TYPE_SEBA == boardSEBId) + { + /*¼ͨ*/ + RecvHeartDataStru.commStartCycle_SEBA = Get2oo2CurCycleNum(); + } + /*SEB2*/ + else if (BOARD_TYPE_SEBB == boardSEBId) + { + + /*¼ͨ*/ + RecvHeartDataStru.commStartCycle_SEBB = Get2oo2CurCycleNum(); + } + else + { + /*忨IDУ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nBoard ID:%d HeartFrameParese:BoradId Check Error", boardSEBId); + } + } + else + { + /*ʧܣݲ*/ + } + + } + else + { + /*ʧ*/ + } + + + return retVal; +} + +/* +* ƽ̨֡Ĵ +* ˵ +* ֵ +* BY LC +*/ +UINT8 PlatHeartFrameProcess(void) +{ + UINT8 retVal = CI_ERROR; + UINT8 heartData_CC1[HEART_FRAME_MAX_LENGTH] = { 0u }; /*CC1֡*/ + UINT8 heartData_CC2[HEART_FRAME_MAX_LENGTH] = { 0u }; /*CC2֡*/ + UINT8 heartData_SEB1[HEART_FRAME_MAX_LENGTH] = { 0u }; /*SEB1֡*/ + UINT8 heartData_SEB2[HEART_FRAME_MAX_LENGTH] = { 0u }; /*SEB2֡*/ + UINT8 platFlag = CI_ERROR; /*/б־*/ + + UINT8 commFlag_CC1 = CI_ERROR;/*CC1ͨ־*/ + UINT8 commFlag_CC2 = CI_ERROR;/*CC2ͨ־*/ + UINT8 commFlag_SEB1 = CI_ERROR;/*SEB1ͨ־*/ + UINT8 commFlag_SEB2 = CI_ERROR;/*SEB2ͨ־*/ + + UINT32 commCyc_CC1 = 0U; + UINT32 commCyc_CC2 = 0U; + UINT32 commCyc_SEB1 = 0U; + UINT32 commCyc_SEB2 = 0U; + + UINT32 curCycNum = 0U; + +#if (kPLATFORM == kVXWORKS) + platFlag = CI_SUCCESS; +#endif + + /*ģʽ ƽ̨֡*/ + if (CI_SUCCESS == platFlag) + { + retVal = CI_SUCCESS; + curCycNum = Get2oo2CurCycleNum(); + + /*ȡƽ̨͵֡*/ + InnetHeartFrameRecv(&heartData_CC1, &heartData_CC2, &heartData_SEB1, &heartData_SEB2, &commFlag_CC1, &commFlag_CC2, &commFlag_SEB1, &commFlag_SEB2); + + debug_infor_printf((const)"\ncommFlag_CC1 %d", commFlag_CC1); + debug_infor_printf((const)"\ncommFlag_CC2 %d", commFlag_CC2); + debug_infor_printf((const)"\ncommFlag_SEB1 %d", commFlag_SEB1); + debug_infor_printf((const)"\ncommFlag_SEB2 %d", commFlag_SEB2); + + /*CC1֡*/ + if (CI_SUCCESS == commFlag_CC1) + { + commFlag_CC1 = ParasePlantCCUHeartFrame(&heartData_CC1); + debug_infor_printf((const)"\nCC1_RECV HeartFrame:"); + debug_out_array(0xAA, heartData_CC1, HEART_FRAME_REAL_LENGTH); + } + else + { + retVal = CI_ERROR; + } + /*CC2֡*/ + if (CI_SUCCESS == commFlag_CC2) + { + commFlag_CC2 = ParasePlantCCUHeartFrame(&heartData_CC2); + debug_infor_printf((const)"\nCC2_RECV HeartFrame:"); + debug_out_array(0xAA, heartData_CC2, HEART_FRAME_REAL_LENGTH); + } + else + { + retVal = CI_ERROR; + } + /*SEB1֡*/ + if (CI_SUCCESS == commFlag_SEB1) + { + commFlag_SEB1 = ParasePlantSEBHeartFrame(&heartData_SEB1); + debug_infor_printf((const)"\nSEB1_RECV HeartFrame:"); + debug_out_array(0xAA, heartData_SEB1, HEART_FRAME_REAL_LENGTH); + } + else + { + retVal = CI_ERROR; + } + /*SEB2֡*/ + if (CI_SUCCESS == commFlag_SEB2) + { + commFlag_SEB2 = ParasePlantSEBHeartFrame(&heartData_SEB2); + debug_infor_printf((const)"\nSEB2_RECV HeartFrame:"); + debug_out_array(0xAA, heartData_SEB2, HEART_FRAME_REAL_LENGTH); + } + else + { + retVal = CI_ERROR; + } + + + + + /*жCC1ͨ״̬*/ + commCyc_CC1 = GetRCIandCCBoardCommCyCNum(BOARD_TYPE_CCUA); + if ((CCU_CommBadEnsureTime_CycleCount < (curCycNum - commCyc_CC1)) + && (CI_ERROR == commFlag_CC1)) + { + SetRCIandCCBoardCommStatus(BOARD_TYPE_CCUA, CCU_COMMSTATUS_BAD); + ClearnCCUHeartData(BOARD_TYPE_CCUA); + debug_infor_printf((const)"\nCC1 And RCI CommState is Bad"); + } + else + { + SetRCIandCCBoardCommStatus(BOARD_TYPE_CCUA, CCU_COMMSTATUS_GOOD); + debug_infor_printf((const)"\nCC1 And RCI CommState is Good"); + + + } + + /*жCC2ͨ״̬*/ + commCyc_CC2 = GetRCIandCCBoardCommCyCNum(BOARD_TYPE_CCUB); + if ((CCU_CommBadEnsureTime_CycleCount < (curCycNum - commCyc_CC2)) + && (CI_ERROR == commFlag_CC2)) + { + SetRCIandCCBoardCommStatus(BOARD_TYPE_CCUB, CCU_COMMSTATUS_BAD); + ClearnCCUHeartData(BOARD_TYPE_CCUB); + debug_infor_printf((const)"\nCC2 And RCI CommState is Bad "); + } + else + { + SetRCIandCCBoardCommStatus(BOARD_TYPE_CCUB, CCU_COMMSTATUS_GOOD); + debug_infor_printf((const)"\nCC2 And RCI CommState is Good "); + + } + + /*жSEB1ͨ״̬*/ + commCyc_SEB1 = GetRCIandCCBoardCommCyCNum(BOARD_TYPE_SEBA); + if ((CCU_CommBadEnsureTime_CycleCount < (curCycNum - commCyc_SEB1)) + && (CI_ERROR == commFlag_SEB1)) + { + SetRCIandCCBoardCommStatus(BOARD_TYPE_SEBA, CCU_COMMSTATUS_BAD); + ClearnCCUHeartData(BOARD_TYPE_SEBA); + debug_infor_printf((const)"\nSEB1 And RCI CommState is Bad"); + } + else + { + SetRCIandCCBoardCommStatus(BOARD_TYPE_SEBA, CCU_COMMSTATUS_GOOD); + debug_infor_printf((const)"\nSEB1 And RCI CommState is Good"); + + + } + /*жSEB2ͨ״̬*/ + commCyc_SEB2 = GetRCIandCCBoardCommCyCNum(BOARD_TYPE_SEBB); + if ((CCU_CommBadEnsureTime_CycleCount < (curCycNum - commCyc_SEB2)) + && (CI_ERROR == commFlag_SEB2)) + { + SetRCIandCCBoardCommStatus(BOARD_TYPE_SEBB, CCU_COMMSTATUS_BAD); + ClearnCCUHeartData(BOARD_TYPE_SEBB); + debug_infor_printf((const)"\nSEB2 And RCI CommState is Bad"); + } + else + { + SetRCIandCCBoardCommStatus(BOARD_TYPE_SEBB, CCU_COMMSTATUS_GOOD); + debug_infor_printf((const)"\nSEB2 And RCI CommState is Good"); + } + } + else + { + /*ģʽֵ֡Ϊֵ,*/ + SetCCUHeartDataNormal(); + retVal = CI_SUCCESS; + } + return retVal; +} + +/* +* ƽ̨IOݴǰԤ +* ˵ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* BY LC +*/ +void PlatChannelIODataProcess(void) +{ + + UINT8 platFlag = CI_ERROR; /*/б־*/ + UINT8 retVal = CI_ERROR; + UINT8 ioDataBuff[IO_DATA_DATA_LENGTH] = { 0U }; + +#if (kPLATFORM == kVXWORKS) + platFlag = CI_SUCCESS; +#endif + + /*ģʽ ȡIO״̬*/ + if (CI_SUCCESS == platFlag) + { + retVal = InnetChannelIODataRecv(&ioDataBuff); + + /*δɹյIO*/ + if (CI_ERROR == retVal) + { + /*IOɼ״̬Ϊ*/ + (void)CommonMemSet(&ioDataBuff, IO_DATA_DATA_LENGTH, 0U, IO_DATA_LENGTH); + } + else + { + /*IO״̬*/ + ParasePlantIOData(&ioDataBuff); + } + + } + else + { + /*ģʽGPIOΪֵ,*/ + SetCCUPlatGPIODataNormal(); + } + +} + +/* +* ƽ̨IO״̬ +* ˵UINT8* datdaBuffIOݻ +* ֵ +* BY LC +*/ +void ParasePlantIOData(UINT8* dataBuf) +{ + UINT8 powerANode_PUA = 0U; /*Aϵɼ AϵԴĿտ״̬*/ + UINT8 powerBNode_PUA = 0U; /*Aϵɼ BϵԴĿտ״̬*/ + UINT8 ModepowerAState_PUA = 0U; /*AϵԴΪCPUA24VDCԴģ״̬*/ + UINT8 ModepowerBState_PUA = 0U; /*BϵԴΪCPUA24VDCԴģ״̬*/ + + UINT8 powerANode_PUB = 0U; /*Bϵɼ AϵԴĿտ״̬*/ + UINT8 powerBNode_PUB = 0U; /*Bϵɼ BϵԴĿտ״̬*/ + UINT8 ModepowerAState_PUB = 0U; /*AϵԴΪCPUB24VDCԴģ״̬*/ + UINT8 ModepowerBState_PUB = 0U; /*BϵԴΪCPUB24VDCԴģ״̬*/ + + if (NULL != dataBuf) + { + powerANode_PUA = dataBuf[0] & dataBuf[4]; + ModepowerAState_PUA = dataBuf[1] & dataBuf[5]; + powerBNode_PUA = dataBuf[2] & dataBuf[6]; + ModepowerBState_PUA = dataBuf[3] & dataBuf[7]; + + powerANode_PUB = dataBuf[8] & dataBuf[12]; + ModepowerAState_PUB = dataBuf[9] & dataBuf[13]; + powerBNode_PUB = dataBuf[10] & dataBuf[14]; + ModepowerBState_PUB = dataBuf[11] & dataBuf[15]; + + /*AϵԴĿտ״̬ 00 01*/ + if (0x01U == (powerANode_PUA & powerANode_PUB)) + { + RecvPlatDataStruGPIO.powerANodeState = NODE_STATUS_CLOSE; + } + else + { + RecvPlatDataStruGPIO.powerANodeState = NODE_STATUS_BREAK; + } + /*BϵԴĿտ״̬ 00 01*/ + if (0x01U == (powerBNode_PUA & powerBNode_PUB)) + { + RecvPlatDataStruGPIO.powerBNodeState = NODE_STATUS_CLOSE; + } + else + { + RecvPlatDataStruGPIO.powerBNodeState = NODE_STATUS_BREAK; + } + /*AϵԴΪCPUA24VDCԴģ״̬ 00 01*/ + if (0x01U == ModepowerAState_PUA) + { + RecvPlatDataStruGPIO.ModepowerAState_PUA = POWER_STATUS_NORMAL; + } + else + { + RecvPlatDataStruGPIO.ModepowerAState_PUA = POWER_STATUS_ABNORMAL; + } + /*BϵԴΪCPUA24VDCԴģ״̬ 00 01*/ + if (0x01U == ModepowerBState_PUA) + { + RecvPlatDataStruGPIO.ModepowerBState_PUA = POWER_STATUS_NORMAL; + } + else + { + RecvPlatDataStruGPIO.ModepowerBState_PUA = POWER_STATUS_ABNORMAL; + } + /*AϵԴΪCPUB24VDCԴģ״̬ 00 01*/ + if (0x01U == ModepowerAState_PUB) + { + RecvPlatDataStruGPIO.ModepowerAState_PUB = POWER_STATUS_NORMAL; + } + else + { + RecvPlatDataStruGPIO.ModepowerAState_PUB = POWER_STATUS_ABNORMAL; + } + /*BϵԴΪCPUB24VDCԴģ״̬ 00 01*/ + if (0x01U == ModepowerBState_PUB) + { + RecvPlatDataStruGPIO.ModepowerBState_PUB = POWER_STATUS_NORMAL; + } + else + { + RecvPlatDataStruGPIO.ModepowerBState_PUB = POWER_STATUS_ABNORMAL; + } + + + } + else + { + /**/ + } + +} + +/* +* CIMɳ״̬Ϣ +* ˵ void +* ֵ +* BY fan 20241021 +*/ +void PackCiToCimFlyProtectData(void) +{ + /*ʼ*/ + UINT16 ii = 0u; + UINT8 jj = 0U; + UINT8 chIndex = 0U; + UINT8 chFlyTrainNum = 0U; /*г*/ + UINT8 ciToCimDataBuffer[CI_TO_CIM_DATA_LEN_MAX] = { 0U }; + UINT16 wTrainId = 0U; + UINT32 dwTrainId = 0U; /*ͨг*/ + TrainFlyProtectStru * pFlyData = NULL; + UINT8 TrainFlyAxis = 0U; /*ɳ*/ + chFlyTrainNum = GetFlyProtectNum(); + if (SHUT_DOWN_TRAIN_NUMMAX < chFlyTrainNum) + { + chFlyTrainNum = SHUT_DOWN_TRAIN_NUMMAX; + } + ciToCimDataBuffer[ii++] = chFlyTrainNum; + for (chIndex = 0U; chIndex < chFlyTrainNum; chIndex++) + { + pFlyData = GetFlyProtectData(chIndex); + wTrainId = pFlyData->wTrainId; + TrainFlyAxis = pFlyData->flyProtectSecCnt; + (void)dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U) + wTrainId, 0U, &dwTrainId); /*ֽгIDתΪ4ֽڻͨID*/ + LongToChar(dwTrainId, &ciToCimDataBuffer[ii]); /* гID */ + ii += 4u; + + if (TRAIN_FLYALARM_SECNUM_MAX < TrainFlyAxis) + { + TrainFlyAxis = TRAIN_FLYALARM_SECNUM_MAX; + } + ciToCimDataBuffer[ii++] = TrainFlyAxis; /* */ + for (jj = 0U; jj < TrainFlyAxis; jj++) + { + ShortToChar(pFlyData->flyProtectSec[jj], &ciToCimDataBuffer[ii]); + ii += 2u; + } + } + + /*ά*/ + (void)DarkInfoPack(CIM_INFO_FLYPROTECT_ALARM, ciToCimDataBuffer, ii); + +} + diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackCommon.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackCommon.h new file mode 100644 index 0000000..db381a3 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackCommon.h @@ -0,0 +1,387 @@ +/******************************************************** +* +* ParsePackCommon.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-05-11 +* ߣ +* ͨúͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_COMMON_H_ +#define _PARSE_PACK_COMMON_H_ + + +#include "CommonTypes.h" +#include "ParsePackDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../Section/AxisSectionDataManage.h" +#include "../Section/LogicSectionDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../Section/SectionDefine.h" +#include "../Route/RouteDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../psd/PSDDataManage.h" +#include "../Overlap/OverlapDataManage.h" +#include "../System/SystemParameterManage.h" +#include "../Transmit/TransmitStateDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../Indicator/IndicatorDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../AutoReturn/AutoReturnDataManage.h" +#include "../AutoRoute/AutoRouteDataManage.h" +#include "../AllAutoReturn/AllAutoReturnDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" +#include "../VirtualDevice/VirtualDevDataManage.h" +#include "../ParsePack/ParsePackOcData.h" +#include "../DataManage/PlatDataManage.h" +#include "../IO/DeviceRelayDataProcess.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define HEART_FRAME_MAX_SUM ((UINT16)20U) /*һڴƽ̨ȡ֡*/ +#define HEART_FRAME_MAX_LENGTH ((UINT16)100U) /*һֽ֡*/ +#define HEART_FRAME_REAL_LENGTH ((UINT16)28U) /*һ֡ʵֽ*/ +#define IO_DATA_LENGTH ((UINT32)50U) /*һIO״ֽ̬֡*/ +#define IO_DATA_DATA_LENGTH ((UINT32)16U) /*һIO״̬֡ʵݵֽ*/ + + + extern PlatHeartDataStruct RecvHeartDataStru; + extern PlatGPIODataStruct RecvPlatDataStruGPIO; + +/* +* źŻλ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 SignalMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 SwitchMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 PhySectionMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* ߼λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 LogicSectionMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 OverlapMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* ·λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 RouteMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* վ̨λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 PlatMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* SPKSλ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 SPKSMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + + +/* +* ϴλ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 WashManchineMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 GaragedoorMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* λ +* ˵ const UINT8 localCiId, վID +* const UINT8 destSystemType, Ŀϵͳ +* UINT8* dataBuf, λbuf +* ֵ 0: ʧ +* 1: ɳɹ +*/ +UINT8 MaskPack(const UINT8 destSystemType, UINT8* dataBuf); + +/* +* λ +* ˵ const UINT8* SourceDataBuf, Դݻ +* const UINT16 SourceDataLength, Դܳ +* UINT16 MaskSum, λ ʵʵλСSourceDataLength*8 +* UINT8* TargetDataBuf, Ŀݻ +* ֵ 0: ʧ +* >0: ɹ +*/ +UINT8 GetMaskValue(UINT8* TargetDataBuf, const UINT16 MaskSum, const UINT8* SourceDataBuf, const UINT16 SourceDataLength); + +/* +* λ +* ˵ const UINT16 maskId, λID +* UINT8* dataBuf, λbuf +* ֵ 0: ʧ +* 1: ɳɹ +*/ +void SetMaskValue(const UINT16 maskId,UINT8* dataBuf); + +/* +* 㱣Чλ +* ˵ const UINT16 rtOverlapLockedId, ID +* ֵ + CI_SUCCESS: Ч +* CI_ERROR: Ч +*/ +UINT8 OverlapValidMaskCheck(const UINT16 rtOverlapLockedId); + +/* +* λ +* ˵ UINT8 MaskType, λ +* UINT16 DeviceId, 豸ID +* UINT16 MaskId, λID +* UINT8* dataBuf, ݻ +* ֵ 0: λʧ +* 1: λɹ +*/ +UINT8 FloodGateMaskManage(UINT8 MaskType, UINT16 DeviceId, UINT16 MaskId, UINT8* dataBuf); + +/* +* CIMͨ״̬Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimCommData(void); + +/* +* CIMźŻ˿״̬Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimSignalDsData(void); + +/* +* µ۷ťλ +* ˵ void +* ֵ +* +*/ +void DealAutoReturnButtonMask_Vir(UINT16 DeviceId, UINT16 MaskId, UINT8* pdataBuf); + +/* +* CIM̵Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimRelayHunXianData(void); + +/* +* CIMű֡ +* ˵ void +* ֵ +* cgh-ϲCID-2349-4 +*/ +void PackCiToCimPsdAlarmData(void); + +/* +* CIM̵ɼһ±Ϣ +* ˵ void +* ֵ +* cgh-ϲCID-2349-4 +*/ +void PackCiToCimRelayDriAndCollDiff(void); + +/* +* CIMźŻʱϢ +* ˵ void +* ֵ +* cgh-ϲCID-2349-4 +* +*/ +void PackCiToCimSigDriOutTimeData(void); + +/* +* Ͱ汾Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimVerData(void); + + +/* +* 豸״̬Ϣ +* ˵ void +* ֵ +* +*/ +void PackCiToCimDeviceData(void); + + +/* +* AIM +* ˵AIMϢ֡ +* ֵ +*/ +void AIMOutput(void); + +/* +* AIM +* ˵ + * @param[in] UINT8 chDevType Ŀ豸 + * @param[in] UINT8 chDevID Ŀ豸ID + * @param[in] UINT8 g_szOutBuffer[] ʵ׵ַ + * @param[in] UINT16 wLength ʵݳ +* ֵ +* +*/ +void ProtocolInfoSend(UINT8 chDevType, UINT8 chDevID, UINT8 g_szOutBuffer[], UINT16 wLength); + +/* +* ִеԪϢ +* ˵ void +* ֵ +* +*/ +void PackCiToCimUnitAlarmData(void); + +/* +* ƽ̨ͨ֡ +* ˵UINT8* datdaBuffݻ +* UINT32 dataLength ֡ +* ֵ void +* BY LC +*/ +UINT8 ParasePlantCCUHeartFrame(UINT8* dataBuf); + + +/* +* ƽ̨չ֡ +* ˵UINT8* datdaBuffݻ +* UINT32 dataLength ֡ +* ֵ void +* BY LC +*/ +UINT8 ParasePlantSEBHeartFrame(UINT8* dataBuf); + + +/* +* ƽ̨֡Ĵ +* ˵ +* ֵ +* BY LC +*/ +UINT8 PlatHeartFrameProcess(void); + + +/* +* ƽ̨ͨݴ +* ˵ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* BY LC +*/ +void PlatChannelIODataProcess(void); + +/* +* ƽ̨IO״̬ +* ˵UINT8* datdaBuffIOݻ +* ֵ +* BY LC +*/ +void ParasePlantIOData(UINT8* dataBuf); + +/* +* CIMɳ״̬Ϣ +* ˵ void +* ֵ +* BY fan 20241021 +*/ +void PackCiToCimFlyProtectData(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackDefine.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackDefine.h new file mode 100644 index 0000000..645a2b0 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackDefine.h @@ -0,0 +1,124 @@ +/******************************************************** +* +* ParsePackDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_DEFINE_H_ +#define _PARSE_PACK_DEFINE_H_ + + + + +/*CIIO*/ +#define IOTOCI_DATA_STRU_SUM_MAX ((UINT16)120) /*IOCIݽṹֵ*/ +#define IOTOCI_COLL_BYTE_SUM_MAX ((UINT16)4) /*IOCIһ֡ɼֵֽ*/ +#define CITOIO_DATA_STRU_SUM_MAX ((UINT16)120) /*CIIOݽṹֵ*/ +#define CITOIO_DRV_BYTE_SUM_MAX ((UINT16)2) /*CIIOһֵֽ֡*/ +#define DRV_BOARD_POSITION_MAX ((UINT16)16) /*λֵ*/ +#define COL_BOARD_POSITION_MAX ((UINT16)32) /*ɼλֵ*/ + + +#define IO_BYTE_MAX ((UINT16)4) /*CIIOһֵֽ֡*/ + + +/*CIATS*/ +#define ATSORXIANDI_TO_CI_CMD_DATA_STRU_SUM_MAX ((UINT16)100) /*ATSֵصCIݽṹֵ*/ +#define CI_TO_ATSORXIANDI_CMD_DATA_STRU_SUM_MAX ((UINT16)200) /*CIATSֵݽṹֵ*/ +#define CI_TO_ATS_DATA_LEN_MAX ((UINT16)5000) /*CIATS󳤶*/ +#define CI_TO_XIANDI_DATA_LEN_MAX ((UINT16)5000) /*CIֵ󳤶*/ + +/*CI CI*/ +#define RECVCI_CMD_DATA_STRU_SUM_MAX ((UINT16)100) /*CIݽṹֵ*/ +#define SENDCI_CMD_DATA_STRU_SUM_MAX ((UINT16)100) /*CI͵ݽṹֵ*/ +#define CI_TO_CI_DATA_LEN_MAX ((UINT16)5000) /*CIֵ*/ +#define CI_TO_CI_AREA_SNOW_SUM_MAX ((UINT8)4) /*RC䷢͵ѩֵ*/ +#define CI_TO_CI_LEAVE_LOGSEC_ROUTE_NUM ((UINT16)100) /*RC䷢͵ȥ߼μֵ*/ + +/*CI ZC*/ +#define CI_TO_ZC_DATA_LEN_MAX ((UINT16)3000) /*ZCֵ*/ +#define ZC_TO_CI_TRAIN_MAX ((UINT16)50) /*ZC͸гĿ*/ +#define TRAIN_OCCUPY_SECTION_MAX ((UINT16)20) /*гռ߼Ŀֵ*/ +#define ZC_TO_CI_EB_MAX ((UINT16)254) /*ZCCIƶֵ*/ + +/*TIOC TMC*/ +#define TIOC_TO_TMC_DATA_LEN_MAX ((UINT16)3000) /*ZCֵ*/ + +/*CI LEU*/ +#define LEU_TO_CI_SUM_MAX ((UINT16)9) /*ͨŵLEUֵ*/ +#define LEU_TO_CI_DATA_LEN_MAX ((UINT16)500) /*LEUCIֵ*/ +#define CI_TO_LEU_DATA_LEN_MAX ((UINT16)36) /*LEUݶֵ*/ + +/*CI VOBC*/ +#define VOBC_TO_CI_SUM_MAX ((UINT16)100U) /*ͨŵVOBCֵ*/ +#define VOBC_BACKUP_TO_CI_SUM_MAX ((UINT16)256) /*úģʽͨŵVOBCֵȡID*/ +#define VOBC_TO_CI_TRAIN_PSD_MAX ((UINT16)8) /*гĿ*/ +#define VOBC_BACKUP_TO_CI_TRAIN_PSD_MAX ((UINT8)2) /*ģʽվ̨PSDĿǰֵȡ2*/ +#define VOBC_TO_CI_DATA_LEN_MAX ((UINT16)5000) /*VOBCֵ*/ +#define VOBC_2X_DATA_LEN ((UINT16)44U) /*VOBCͬݳ*/ + +/*CI ITE*/ +#define ITE_TO_CI_SUM_MAX (UINT16)(VOBC_TO_CI_SUM_MAX*2U) /*ͨŵITEֵ*/ +#define ITE_2X_DATA_LEN ((UINT16)8U) /*ITEͬݳ*/ + +/*CIPLATFORM*/ +#define PLATFORM_TO_CI_SUM_MAX ((UINT16)60) /*ͨŵPLATFORMϵͳֵ*/ +#define PLATFORM_TO_CI_DATA_LEN_MAX ((UINT16)1000) +#define PLATFORM_INCLUDE_PSD_MAX_SUM ((UINT16)8) /*һվŸ*/ + +/*CIPSC*/ +#define PSC_TO_CI_SUM_MAX ((UINT16)60) /*ͨŵPSCϵͳֵ*/ +#define PSC_TO_CI_DATA_LEN_MAX ((UINT16)1200) + +/*CI OC*/ +#define OC_TO_CI_DATA_LEN_MAX ((UINT16)1000) /*OCCIֵ*/ + +/*CI AXIS*/ +#define CI_INCLUDE_AXIS_MAX_SUM ((UINT16)250) /*ÿվθRSSP-1ЭҪ*/ +#define AXIS_TO_CI_SECTION_SUM_MAX ((UINT16)200) /*һϵͳ͵ֵ*/ +#define AXIS_TO_CI_SUM_MAX ((UINT16)30) /*ͨŵļϵͳֵ7CI7ϵͳݶ*/ +#define CI_TO_AXIS_DATA_LEN_MAX ((UINT16)3000) /*AXISֵ*/ + +/*CI CIM*/ +#define CI_TO_CIM_DATA_LEN_MAX ((UINT16)5000) /*CICIMֵ*/ +#define CI_TO_AIM_DATA_LEN_MAX ((UINT16)5000) /*CIAIMֵ*/ +#define CIM_INFO_RCI_TO_ATS_DATA ((UINT16)0x2001) /*CIM ATS״̬Ϣ*/ +#define CIM_INFO_ATS_TO_RCI_DATA ((UINT16)0x2002) /*CIM ATS״̬Ϣ*/ +#define CIM_INFO_VER_INFO ((UINT16)0x2003) /*CIM汾Ϣ*/ +#define CIM_INFO_COMM_STATE ((UINT16)0x2004) /*CIM豸ͨ״̬Ϣ*/ +#define CIM_INFO_SIGNAL_DS_STATE ((UINT16)0x2005) /*CIMźŻ˿״̬Ϣ*/ +#define CIM_INFO_RELAY_DRVANDCOLLDEF ((UINT16)0x2006) /*CIM̵زɲһ±*/ +#define CIM_INFO_PSD_ALARM ((UINT16)0x2007) /*CIMű֡*/ +#define CIM_INFO_DEVICE_STATE ((UINT16)0x2008) /*CIM豸״̬Ϣ*/ +#define CIM_INFO_MAINTENANCE ((UINT16)0x2009) /*CIMάϢ*/ +#define CIM_INFO_LEU_STATE ((UINT16)0x200A) /*CIMLEU״̬*/ +#define CIM_INFOR_RELAY_HUNXIAN_STATE ((UINT16)0x200F) /*CIM̵״̬Ϣ*/ +#define CIM_INFO_SIGNAL_DRIVOUT ((UINT16)0x2010) /*CIMźŻʱϢ*/ +#define CIM_INFO_UNIT_ALARM ((UINT16)0x2011) /*CIMִеԪ*/ +#define CIM_INFO_FLYPROTECT_ALARM ((UINT16)0x2012) /*CIMɳ崻*/ + +#define CI_AND_OTHER_TRANSMIT_GOOD ((UINT8)0x55) /*CIϵͳ˫ͨ*/ +#define CI_AND_OTHER_TRANSMIT_LINK ((UINT8)0x5A) /*CIϵͳͨ*/ +#define CI_AND_OTHER_TRANSMIT_BAD ((UINT8)0xaa) /*CIϵͳ˫ͨ쳣*/ +#define SIGNAL_RED_DS_STATE ((UINT8)0x01) /*źŻ״̬*/ +#define SIGNAL_GREEN_DS_STATE ((UINT8)0x02) /*źŻ̶״̬*/ +#define SIGNAL_YELLOW_DS_STATE ((UINT8)0x03) /*źŻƶ״̬*/ +#define SIGNAL_WHITE_DS_STATE ((UINT8)0x04) /*źŻ׶״̬*/ +#define SIGNAL_RED_YELLOW_DS_STATE ((UINT8)0x05) /*źŻƶ״̬*/ +#define SIGNAL_RED_WHITE_DS_STATE ((UINT8)0x06) /*źŻ׶״̬*/ +#define SIGNAL_GREEN_YELLOW_DS_STATE ((UINT8)0x07) /*źŻ̻ƶ״̬*/ +#define SIGNAL_DOUBLE_GREEN_DS_STATE ((UINT8)0x08) /*źŻ˫̶״̬*/ +#define SIGNAL_DOUBLE_YELLOW_DS_STATE ((UINT8)0x09) /*źŻ˫ƶ״̬*/ + + + +#endif + + diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackGateWayData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackGateWayData.c new file mode 100644 index 0000000..5379e6d --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackGateWayData.c @@ -0,0 +1,2084 @@ +#include "ParsePackGateWayData.h" +#include "DeviceConfigDataManage.h" +#include "TrainDataManage.h" +#include "2oo2InterfaceDataManage.h" +#include "dquCIInterFace.h" +#include "WLBrakeDataManage.h" +#include "RRMManageAPI.h" + +AtsScreenMsgFstStru g_strAtsMsgFst = { 0u }; /*Զɸѡ״Ϣ*/ +AtsMsgCfmStru g_strAtsCfmFst = { 0u }; /*Զɸѡ״ȷ*/ +AtsScreenMsgSndStru g_strAtsMsgSnd = { 0u }; /*ԶɸѡϢ*/ +AtsMsgCfmStru g_strAtsCfmSnd = { 0u }; /*Զɸѡȷ*/ + +AtsEaMsgStru g_strAtsEaMsgFst = { 0u }; /*ȡɢ״Ϣ*/ +AtsMsgCfmStru g_strAtsEaCfmFst = { 0u }; /*ȡɢ״ȷ*/ +AtsEaMsgStru g_strAtsEaMsgSnd = { 0u }; /*ȡɢٴϢ*/ +AtsMsgCfmStru g_strAtsEaCfmSnd = { 0u }; /*ȡɢٴȷ*/ + +AtsWlbMsgStru g_strAtsWlbMsgFst = { 0u }; /*/ȡȫгƶ״Ϣ*/ +AtsMsgCfmStru g_strAtsWlbCfmFst = { 0u }; /*/ȡȫгƶ״ȷ*/ +AtsWlbMsgStru g_strAtsWlbMsgSnd = { 0u }; /*ȡȫгƶٴϢ*/ +AtsMsgCfmStru g_strAtsWlbCfmSnd = { 0u }; /*ȡȫгƶٴȷ*/ + +AtsDaMsgStru g_strAtsDaMsgFst = { 0u }; /*ȡѹ״Ϣ*/ +AtsMsgCfmStru g_strAtsDaCfmFst = { 0u }; /*ȡѹ״ȷ*/ +AtsDaMsgStru g_strAtsDaMsgSnd = { 0u }; /*ȡѹٴϢ*/ +AtsMsgCfmStru g_strAtsDaCfmSnd = { 0u }; /*ȡѹٴȷ*/ + +/** +* @brief ֡ +* @param const UINT8* dataBuf, ݻ +* @param const UINT16 dataLength, ݳ +* @return CI_SUCCESS:ɹCI_ERROR:ʧ +*/ +UINT8 ParseGateWayToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chMsgNum = 0u; + UINT32 dwDataVer = 0u; + UINT32 dwPrtclMsg = 0u; + UINT8 chMsgId = 0u; + UINT16 ii = 0u; + UINT32 dwDataVerLocal = 0u; + UINT8 chMsgIndex = 0u; + UINT8 chLocalId = 0u; + UINT8 chTrainIndex = 0u; + UINT16 wMsgLen = 0U; + UINT16 wMsgLenCount = 0U; + + if ((NULL != dataBuf) && (0u < dataLength)) + { + chLocalId = GetSystemParaLocalCiId(); + + /* Ϣ */ + chMsgNum = dataBuf[ii++]; + /* ݰ汾 */ + dwDataVer = LongFromChar(&dataBuf[ii]); + ii += 4u; + /* ЭϢ */ + dwPrtclMsg = LongFromChar(&dataBuf[ii]); + ii += 4u; + chRtn = GetCiEmapCheckVer(chLocalId, &dwDataVerLocal, CI_SYSTEM_TYPE_ATS); + if (CI_SUCCESS == chRtn) + { + if(dwDataVer == dwDataVerLocal) + { + ; /* ݰ汾Уͨ */ + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*ȡʧ*/ + } + + if (CI_SUCCESS == chRtn) + { + if (GATE_WAY_PRTCL_VER == dwPrtclMsg) + { + ; /* Э汾Уͨ */ + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == chRtn) + { + for (chMsgIndex = 0u; chMsgIndex < chMsgNum; chMsgIndex++) + { + chMsgId = dataBuf[ii++]; + wMsgLen = ShortFromChar(&dataBuf[ii]); + ii += 2U; + wMsgLenCount = ii; + ii++; + switch (chMsgId) + { + case MSG_TYPE_REQUEST_FIRST:/* Զɸѡ״Ϣ */ + { + g_strAtsMsgFst.dwCycle = Get2oo2CurCycleNum(); + g_strAtsMsgFst.chAtsId = dataBuf[ii++]; + if (0U < g_strAtsMsgFst.chAtsId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsMsgFst.chStation = dataBuf[ii++]; + g_strAtsMsgFst.chIndex = dataBuf[ii++]; + if (0U < g_strAtsMsgFst.chIndex) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsMsgFst.chTiocId = dataBuf[ii++]; + if (g_strAtsMsgFst.chTiocId == chLocalId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsMsgFst.dwTime = LongFromChar(&dataBuf[ii]); + ii += 4u; + + g_strAtsMsgFst.chTrainNum = dataBuf[ii++]; + if ((0U < g_strAtsMsgFst.chTrainNum) && (ATS_GATEWAY_CI_TRAIN_MAX > g_strAtsMsgFst.chTrainNum)) + { + for (chTrainIndex = 0u; chTrainIndex < g_strAtsMsgFst.chTrainNum; chTrainIndex++) + { + g_strAtsMsgFst.strTrainInfo[chTrainIndex].dwTrainId = LongFromChar(&dataBuf[ii]); + ii += 4u; + if ((0U == g_strAtsMsgFst.strTrainInfo[chTrainIndex].dwTrainId) + || (UINT32_MAX == g_strAtsMsgFst.strTrainInfo[chTrainIndex].dwTrainId)) + { + chRtn = CI_ERROR; + } + g_strAtsMsgFst.strTrainInfo[chTrainIndex].wLgcId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U == g_strAtsMsgFst.strTrainInfo[chTrainIndex].dwTrainId) + || (UINT32_MAX == g_strAtsMsgFst.strTrainInfo[chTrainIndex].dwTrainId)) + { + chRtn = CI_ERROR; + } + else + { + ; /*DO NOTHING*/ + } + + if ((0U == g_strAtsMsgFst.strTrainInfo[chTrainIndex].wLgcId) + || (UINT16_MAX == g_strAtsMsgFst.strTrainInfo[chTrainIndex].wLgcId)) + { + chRtn = CI_ERROR; + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + ; /**/ + } + else + { + break; + } + } + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsMsgFst.chFlag = FLAG_SET; + } + else + { + ; /*DO NOTHING*/ + } + break; + } + case MSG_TYPE_REQUEST_SECOND:/* ԶɸѡϢ */ + { + g_strAtsMsgSnd.dwCycle = Get2oo2CurCycleNum(); + g_strAtsMsgSnd.chAtsId = dataBuf[ii++]; + if (0U < g_strAtsMsgSnd.chAtsId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS==chRtn) + { + g_strAtsMsgSnd.chStation = dataBuf[ii++]; + g_strAtsMsgSnd.chIndex = dataBuf[ii++]; + if (0U < g_strAtsMsgSnd.chIndex) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS==chRtn) + { + g_strAtsMsgSnd.chTiocId = dataBuf[ii++]; + if (g_strAtsMsgSnd.chTiocId == chLocalId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsMsgSnd.dwTime = LongFromChar(&dataBuf[ii]); + ii += 4u; + g_strAtsMsgSnd.chTrainNum = dataBuf[ii++]; + if ((0U < g_strAtsMsgSnd.chTrainNum) && (ATS_GATEWAY_CI_TRAIN_MAX > g_strAtsMsgSnd.chTrainNum)) + { + for (chTrainIndex = 0u; chTrainIndex < g_strAtsMsgSnd.chTrainNum; chTrainIndex++) + { + g_strAtsMsgSnd.strTrainInfo[chTrainIndex].dwTrainId = LongFromChar(&dataBuf[ii]); + ii += 4u; + g_strAtsMsgSnd.strTrainInfo[chTrainIndex].wLgcId = ShortFromChar(&dataBuf[ii]); + ii += 2u; + if ((0U == g_strAtsMsgSnd.strTrainInfo[chTrainIndex].dwTrainId) + || (UINT32_MAX == g_strAtsMsgSnd.strTrainInfo[chTrainIndex].dwTrainId)) + { + chRtn = CI_ERROR; + } + else + { + ; /*DO NOTHING*/ + } + + if ((0U == g_strAtsMsgSnd.strTrainInfo[chTrainIndex].wLgcId) + || (UINT16_MAX == g_strAtsMsgSnd.strTrainInfo[chTrainIndex].wLgcId)) + { + chRtn = CI_ERROR; + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + ; /**/ + } + else + { + break; + } + } + } + else + { + chRtn = CI_ERROR;/**/ + } + g_strAtsMsgSnd.dwCrc32 = LongFromChar(&dataBuf[ii]); + ii += 4u; + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsMsgSnd.chFlag = FLAG_SET; + } + else + { + ; /*DO NOTHING*/ + } + break; + } + case MSG_TYPE_EA_CANCLE_FIRST:/* ɢȡ״Ϣ */ + { + g_strAtsEaMsgFst.dwCycle = Get2oo2CurCycleNum(); /* յȡɢϢں */ + g_strAtsEaMsgFst.chAtsId = dataBuf[ii++]; /* ATS */ + if (0U < g_strAtsEaMsgFst.chAtsId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgFst.chStation = dataBuf[ii++]; /* վ */ + g_strAtsEaMsgFst.chIndex = dataBuf[ii++]; /* վ */ + if (0U < g_strAtsEaMsgFst.chIndex) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgFst.chTiocId = dataBuf[ii++]; /* TIOC */ + if (g_strAtsEaMsgFst.chTiocId == chLocalId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgFst.dwEaTrainId = LongFromChar(&dataBuf[ii]); /* ɢгͨ */ + ii += 4u; + if ((0u < g_strAtsEaMsgFst.dwEaTrainId) && (UINT32_MAX > g_strAtsEaMsgFst.dwEaTrainId)) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgFst.dwTime = LongFromChar(&dataBuf[ii]); /* ·Ϣʱ */ + ii += 4u; + + g_strAtsEaMsgFst.chType = dataBuf[ii];/* */ + ii++; + + if (ATS_EA_CMD_TYPE_CANCEL == g_strAtsEaMsgFst.chType) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgFst.chLine = dataBuf[ii];/* */ + ii++; + if ((EA_AREA_ALL == g_strAtsEaMsgFst.chLine) || (EA_AREA_UP == g_strAtsEaMsgFst.chLine) || (EA_AREA_DOWN == g_strAtsEaMsgFst.chLine)) + { + g_strAtsEaMsgFst.chFlag = FLAG_SET; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; + } + + break; + } + case MSG_TYPE_EA_CANCLE_SECOND:/* ɢȡϢ */ + { + g_strAtsEaMsgSnd.dwCycle = Get2oo2CurCycleNum(); /* յϢں */ + g_strAtsEaMsgSnd.chAtsId = dataBuf[ii++]; /* ATS */ + if (0U < g_strAtsEaMsgSnd.chAtsId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgSnd.chStation = dataBuf[ii++]; /* վ */ + g_strAtsEaMsgSnd.chIndex = dataBuf[ii++]; /* վ */ + if (0U < g_strAtsEaMsgSnd.chIndex) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgSnd.chTiocId = dataBuf[ii++]; /* TIOC */ + if (g_strAtsEaMsgSnd.chTiocId == chLocalId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgSnd.dwEaTrainId = LongFromChar(&dataBuf[ii]); /* ɢгͨ */ + ii += 4u; + if ((0u < g_strAtsEaMsgSnd.dwEaTrainId) && (UINT32_MAX > g_strAtsEaMsgSnd.dwEaTrainId)) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgSnd.dwTime = LongFromChar(&dataBuf[ii]); /* ·ʱ */ + ii += 4u; + + g_strAtsEaMsgSnd.chType = dataBuf[ii];/* */ + ii++; + + if (ATS_EA_CMD_TYPE_CANCEL == g_strAtsEaMsgSnd.chType) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgSnd.chLine = dataBuf[ii]; /* Ҫȡ */ + ii++; + if ((EA_AREA_ALL == g_strAtsEaMsgSnd.chLine) || (EA_AREA_UP == g_strAtsEaMsgSnd.chLine) || (EA_AREA_DOWN == g_strAtsEaMsgSnd.chLine)) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsEaMsgSnd.dwCrc32 = LongFromChar(&dataBuf[ii]); /* CRCֵ */ + ii += 4u; + + g_strAtsEaMsgSnd.chFlag = FLAG_SET; + } + else + { + ; + } + + break; + } + case MSG_TYPE_WLB_SET_FIRST: /* ȫгƶһ */ + { + g_strAtsWlbMsgFst.dwCycle = Get2oo2CurCycleNum(); /* յȫгƶں */ + g_strAtsWlbMsgFst.chAtsId = dataBuf[ii++]; /* ATS */ + if (0U < g_strAtsWlbMsgFst.chAtsId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgFst.chStation = dataBuf[ii++]; /* վ */ + g_strAtsWlbMsgFst.chIndex = dataBuf[ii++]; /* վ */ + if (0U < g_strAtsWlbMsgFst.chIndex) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgFst.chTiocId = dataBuf[ii++]; /* TIOC */ + if (g_strAtsWlbMsgFst.chTiocId == chLocalId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgFst.chBrakeType = dataBuf[ii++]; /* ƶͣƶƶ */ + if ((WLB_TYPE_RC == g_strAtsWlbMsgFst.chBrakeType) || (WLB_TYPE_PHYSEC == g_strAtsWlbMsgFst.chBrakeType)) + { + ; /* ƶͺϷ */ + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /* DO NOTHING */ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgFst.chBrakeCount = dataBuf[ii++]; /* */ + if (1u == g_strAtsWlbMsgFst.chBrakeCount) + { + ; /* Ϸ,Ϊ1 */ + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /* DO NOTHING */ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgFst.wBrakeIndex = ShortFromChar(&dataBuf[ii]); /* ID */ + ii += 2u; + + chRtn = WlbUrgentIdCheck(g_strAtsWlbMsgFst.chBrakeType, g_strAtsWlbMsgFst.wBrakeIndex); /*УIDǷϷ*/ + } + else + { + ; /* DO NOTHING */ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgFst.dwTime = LongFromChar(&dataBuf[ii]); /* ·Ϣʱ */ + ii += 4u; + + g_strAtsWlbMsgFst.chType = dataBuf[ii];/* */ + ii++; + + if ((MSG_TYPE_WLB_SET == g_strAtsWlbMsgFst.chType) || (MSG_TYPE_WLB_CANCEL == g_strAtsWlbMsgFst.chType)) + { + g_strAtsWlbMsgFst.chFlag = FLAG_SET; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; + } + + break; + } + case MSG_TYPE_WLB_SET_SECOND: /* ȫгƶ */ + { + g_strAtsWlbMsgSnd.dwCycle = Get2oo2CurCycleNum(); /* յϢں */ + g_strAtsWlbMsgSnd.chAtsId = dataBuf[ii++]; /* ATS */ + if (0U < g_strAtsWlbMsgSnd.chAtsId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgSnd.chStation = dataBuf[ii++]; /* վ */ + g_strAtsWlbMsgSnd.chIndex = dataBuf[ii++]; /* վ */ + if (0U < g_strAtsWlbMsgSnd.chIndex) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgSnd.chTiocId = dataBuf[ii++]; /* TIOC */ + if (g_strAtsWlbMsgSnd.chTiocId == chLocalId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgSnd.chBrakeType = dataBuf[ii++]; /* ƶ */ + if ((WLB_TYPE_RC == g_strAtsWlbMsgSnd.chBrakeType) || (WLB_TYPE_PHYSEC == g_strAtsWlbMsgSnd.chBrakeType)) + { + ; /* ƶͺϷ */ + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /* DO NOTHING */ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgSnd.chBrakeCount = dataBuf[ii++]; /* */ + if (1u == g_strAtsWlbMsgSnd.chBrakeCount) + { + ; /* Ϸ,Ϊ1 */ + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /* DO NOTHING */ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgSnd.wBrakeIndex = ShortFromChar(&dataBuf[ii]); /* ID */ + ii += 2u; + + chRtn = WlbUrgentIdCheck(g_strAtsWlbMsgSnd.chBrakeType, g_strAtsWlbMsgSnd.wBrakeIndex); /*УIDǷϷ*/ + } + else + { + ; /* DO NOTHING */ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgSnd.dwTime = LongFromChar(&dataBuf[ii]); /* ·ʱ */ + ii += 4u; + + g_strAtsWlbMsgSnd.chType = dataBuf[ii];/* */ + ii++; + + if (MSG_TYPE_WLB_CANCEL == g_strAtsWlbMsgSnd.chType) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsWlbMsgSnd.dwCrc32 = LongFromChar(&dataBuf[ii]); /* CRCֵ */ + ii += 4u; + + g_strAtsWlbMsgSnd.chFlag = FLAG_SET; + } + else + { + ; + } + + break; + } + case MSG_TYPE_DA_CANCLE_FIRST:/* ѹȡ״Ϣ */ + { + g_strAtsDaMsgFst.dwCycle = Get2oo2CurCycleNum(); /* յȡѹϢں */ + g_strAtsDaMsgFst.chAtsId = dataBuf[ii++]; /* ATS */ + if (0U < g_strAtsDaMsgFst.chAtsId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgFst.chStation = dataBuf[ii++]; /* վ */ + g_strAtsDaMsgFst.chIndex = dataBuf[ii++]; /* վ */ + if (0U < g_strAtsDaMsgFst.chIndex) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgFst.chTiocId = dataBuf[ii++]; /* TIOC */ + if (g_strAtsDaMsgFst.chTiocId == chLocalId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgFst.dwDaTrainId = LongFromChar(&dataBuf[ii]); /* ѹгͨ */ + ii += 4u; + if ((0u < g_strAtsDaMsgFst.dwDaTrainId) && (UINT32_MAX > g_strAtsDaMsgFst.dwDaTrainId)) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgFst.dwTime = LongFromChar(&dataBuf[ii]); /* ·Ϣʱ */ + ii += 4u; + + g_strAtsDaMsgFst.chType = dataBuf[ii];/* */ + ii++; + + if (ATS_DA_CMD_TYPE_CANCEL == g_strAtsDaMsgFst.chType) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgFst.chLine = dataBuf[ii];/* */ + ii++; + if ((DA_AREA_ALL == g_strAtsDaMsgFst.chLine) || (DA_AREA_UP == g_strAtsDaMsgFst.chLine) || (DA_AREA_DOWN == g_strAtsDaMsgFst.chLine)) + { + g_strAtsDaMsgFst.chFlag = FLAG_SET; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; + } + + break; + } + case MSG_TYPE_DA_CANCLE_SECOND:/* ѹȡϢ */ + { + g_strAtsDaMsgSnd.dwCycle = Get2oo2CurCycleNum(); /* յϢں */ + g_strAtsDaMsgSnd.chAtsId = dataBuf[ii++]; /* ATS */ + if (0U < g_strAtsDaMsgSnd.chAtsId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgSnd.chStation = dataBuf[ii++]; /* վ */ + g_strAtsDaMsgSnd.chIndex = dataBuf[ii++]; /* վ */ + if (0U < g_strAtsDaMsgSnd.chIndex) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgSnd.chTiocId = dataBuf[ii++]; /* TIOC */ + if (g_strAtsDaMsgSnd.chTiocId == chLocalId) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgSnd.dwDaTrainId = LongFromChar(&dataBuf[ii]); /* ɢгͨ */ + ii += 4u; + if ((0u < g_strAtsDaMsgSnd.dwDaTrainId) && (UINT32_MAX > g_strAtsDaMsgSnd.dwDaTrainId)) + { + ; + } + else + { + chRtn = CI_ERROR; + } + + } + else + { + ; /*DO NOTHING*/ + } + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgSnd.dwTime = LongFromChar(&dataBuf[ii]); /* ·ʱ */ + ii += 4u; + + g_strAtsDaMsgSnd.chType = dataBuf[ii];/* */ + ii++; + + if (ATS_DA_CMD_TYPE_CANCEL == g_strAtsDaMsgSnd.chType) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /*DO NOTHING*/ + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgSnd.chLine = dataBuf[ii]; /* Ҫȡ */ + ii++; + if ((DA_AREA_ALL == g_strAtsDaMsgSnd.chLine) || (DA_AREA_UP == g_strAtsDaMsgSnd.chLine) || (DA_AREA_DOWN == g_strAtsDaMsgSnd.chLine)) + { + ; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + g_strAtsDaMsgSnd.dwCrc32 = LongFromChar(&dataBuf[ii]); /* CRCֵ */ + ii += 4u; + + g_strAtsDaMsgSnd.chFlag = FLAG_SET; + } + else + { + ; + } + + break; + } + default: + { + chRtn = CI_ERROR; + break; + } + } + if (wMsgLen != (ii - wMsgLenCount)) + { + chRtn = CI_ERROR;/**/ + } + else + { + /*ѭ*/ + } + if (CI_ERROR == chRtn) + { + break; + } + else + { + ; + } + } + } + else + { + ; + } + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + ; /**/ + } + else + { + ClearAtsMsgFirst(); + ClearAtsMsgSecond(); + ClearAtsEaMsgFirst(); + ClearAtsEaMsgSecond(); + ClearAtsWlbMsgFirst(); + ClearAtsWlbMsgSecond(); + ClearAtsDaMsgFirst(); + ClearAtsDaMsgSecond(); + } + return chRtn; +} + +/** +* @brief ȡԶɸѡATS״Ϣ +* @param +* @return ԶɸѡATS״Ϣ +*/ +AtsScreenMsgFstStru * GetAtsMsgFst(void) +{ + return &g_strAtsMsgFst; +} + +/** +* @brief ȡԶɸѡATSϢ +* @param +* @return ԶɸѡATSϢ +*/ +AtsScreenMsgSndStru * GetAtsMsgSnd(void) +{ + return &g_strAtsMsgSnd; +} + +/** +* @brief ȡԶɸѡ״ȷϢ +* @param +* @return Զɸѡ״ȷϢ +*/ +AtsMsgCfmStru * GetAtsCfmFst(void) +{ + return &g_strAtsCfmFst; +} + +/** +* @brief ȡԶɸѡȷϢ +* @param +* @return ԶɸѡȷϢ +*/ +AtsMsgCfmStru * GetAtsCfmSnd(void) +{ + return &g_strAtsCfmSnd; +} + +/** +* @brief 1ATSɸѡϢ +* @param void +* @return void +*/ +void ClearAtsMsgFirst(void) +{ + (void)CommonMemSet((void*)&g_strAtsMsgFst, (UINT32)sizeof(g_strAtsMsgFst), (UINT8)0U, (UINT32)sizeof(g_strAtsMsgFst)); +} + +/** +* @brief 2ATSɸѡϢ +* @param void +* @return void +*/ +void ClearAtsMsgSecond(void) +{ + (void)CommonMemSet((void*)&g_strAtsMsgSnd, (UINT32)sizeof(g_strAtsMsgSnd), (UINT8)0U, (UINT32)sizeof(g_strAtsMsgSnd)); +} + +/** +* @brief ȡATSȡɢ״Ϣ +* @param +* @return ATSȡɢ״Ϣ +*/ +AtsEaMsgStru * GetAtsEaMsgFst(void) +{ + return &g_strAtsEaMsgFst; +} + +/** +* @brief ȡATSȡɢϢ +* @param +* @return ATSȡɢϢ +*/ +AtsEaMsgStru * GetAtsEaMsgSnd(void) +{ + return &g_strAtsEaMsgSnd; +} + +/** +* @brief ȡATSȡɢ״ȷ +* @param +* @return ATSȡɢ״ȷ +*/ +AtsMsgCfmStru * GetAtsEaCfmFst(void) +{ + return &g_strAtsEaCfmFst; +} + +/** +* @brief ȡATSȡɢȷ +* @param +* @return ATSȡɢȷ +*/ +AtsMsgCfmStru * GetAtsEaCfmSnd(void) +{ + return &g_strAtsEaCfmSnd; +} + +/** +* @brief 1ATSɢϢ +* @param void +* @return void +*/ +void ClearAtsEaMsgFirst(void) +{ + (void)CommonMemSet((void*)&g_strAtsEaMsgFst, (UINT32)sizeof(g_strAtsEaMsgFst), (UINT8)0U, (UINT32)sizeof(g_strAtsEaMsgFst)); +} + +/** +* @brief 2ATSɢϢ +* @param void +* @return void +*/ +void ClearAtsEaMsgSecond(void) +{ + (void)CommonMemSet((void*)&g_strAtsEaMsgSnd, (UINT32)sizeof(g_strAtsEaMsgSnd), (UINT8)0U, (UINT32)sizeof(g_strAtsEaMsgSnd)); +} + +/** +* @brief ȡATS/ȡȫгƶ״Ϣ +* @param +* @return ATS/ȡɢ״Ϣ +*/ +AtsWlbMsgStru * GetAtsWlbMsgFst(void) +{ + return &g_strAtsWlbMsgFst; +} + +/** +* @brief ȡATSȡȫгƶϢ +* @param +* @return ATSȡȫгƶϢ +*/ +AtsWlbMsgStru * GetAtsWlbMsgSnd(void) +{ + return &g_strAtsWlbMsgSnd; +} + +/** +* @brief ȡATS/ȡȫгƶ״ȷ +* @param +* @return ATS/ȡȫгƶ״ȷ +*/ +AtsMsgCfmStru * GetAtsWlbCfmFst(void) +{ + return &g_strAtsWlbCfmFst; +} + +/** +* @brief ȡATSȡȫгƶȷ +* @param +* @return ATSȡȫгƶȷ +*/ +AtsMsgCfmStru * GetAtsWlbCfmSnd(void) +{ + return &g_strAtsWlbCfmSnd; +} + +/** +* @brief 1ATS/ȡȫгƶϢ +* @param void +* @return void +*/ +void ClearAtsWlbMsgFirst(void) +{ + (void)CommonMemSet((void*)&g_strAtsWlbMsgFst, (UINT32)sizeof(g_strAtsWlbMsgFst), (UINT8)0U, (UINT32)sizeof(g_strAtsWlbMsgFst)); +} + +/** +* @brief 2ATSȡȫгƶϢ +* @param void +* @return void +*/ +void ClearAtsWlbMsgSecond(void) +{ + (void)CommonMemSet((void*)&g_strAtsWlbMsgSnd, (UINT32)sizeof(g_strAtsWlbMsgSnd), (UINT8)0U, (UINT32)sizeof(g_strAtsWlbMsgSnd)); +} + +/** +* @brief ȡATSȡѹ״Ϣ +* @param +* @return ATSȡѹ״Ϣ +*/ +AtsDaMsgStru * GetAtsDaMsgFst(void) +{ + return &g_strAtsDaMsgFst; +} + +/** +* @brief ȡATSȡѹϢ +* @param +* @return ATSȡѹϢ +*/ +AtsDaMsgStru * GetAtsDaMsgSnd(void) +{ + return &g_strAtsDaMsgSnd; +} + +/** +* @brief ȡATSȡѹ״ȷ +* @param +* @return ATSȡѹ״ȷ +*/ +AtsMsgCfmStru * GetAtsDaCfmFst(void) +{ + return &g_strAtsDaCfmFst; +} + +/** +* @brief ȡATSȡѹȷ +* @param +* @return ATSȡѹȷ +*/ +AtsMsgCfmStru * GetAtsDaCfmSnd(void) +{ + return &g_strAtsDaCfmSnd; +} + +/** +* @brief 1ATSȡѹϢ +* @param void +* @return void +*/ +void ClearAtsDaMsgFirst(void) +{ + (void)CommonMemSet((void*)&g_strAtsDaMsgFst, (UINT32)sizeof(g_strAtsDaMsgFst), (UINT8)0U, (UINT32)sizeof(g_strAtsDaMsgFst)); +} + +/** +* @brief 2ATSȡѹϢ +* @param void +* @return void +*/ +void ClearAtsDaMsgSecond(void) +{ + (void)CommonMemSet((void*)&g_strAtsDaMsgSnd, (UINT32)sizeof(g_strAtsDaMsgSnd), (UINT8)0U, (UINT32)sizeof(g_strAtsDaMsgSnd)); +} + +/** +* @brief TIOC +* @param +* @return CI_ERRORʧܣCI_SUCCESSɹ +*/ +UINT8 PackTiocToGateWayData(const UINT8 deviceId, const UINT8 targetDevType) +{ + UINT8 szToGateWayDataBuf[CI_TO_ATS_DATA_LEN_MAX] = { 0u }; + UINT16 ii = 0u; + UINT16 jj = 0U; + UINT16 wMsgNumIndex = 0u; + UINT8 chRtn = CI_ERROR; + UINT32 dwDataVer = 0u; + UINT8 chLocalId = GetSystemParaLocalCiId(); + UINT16 wMsgLenIndex = 0u; + UINT8 chMsgNum = 0u; + UINT8 chAtsScreenNum = 0u; + UINT16 wTrainId = 0u; + UINT16 wLgcId = 0u; + UINT8 chScreenType = 0u; + UINT8 chTrainIndex = 0u; + UINT32 dwTrainId = 0u; + UINT16 wMsgLen = 0u; + UINT16 wDstDevId = 0u; + UINT16 wTrainLgcId = 0u; + UINT8 chEaNum = 0u; + UINT16 wEaTrainid = 0u; + UINT32 dwEaTrainHlhtId = 0u; + UINT8 chEaLgcNum = 0u; + UINT16 * pEaLgcId = NULL; + UINT8 chEaIndex = 0u; + UINT8 chEaLgcIndex = 0u; + UINT8 chEaBuidFlag = 0u; + UINT8 chEaSendNum = 0u; + UINT16 wEaNumIndex = 0u; + UINT8 chEaSrcId = 0u; + UINT8 chPaType = 0u; + UINT8 chEaConfigId = 0u; + ATSTrainInfoStru strTrainInfo = {0u}; /** 㱨гϢ*/ + UINT8 chWlbState = WLB_SET; + UINT16 wWlbSum = 0u; + UINT16 wWlbSumIndex = 0; /*ƶλ*/ + UINT16 wRcId = 0u; + UINT16 wPhyCurSum = 0U; /*εǰ*/ + UINT16 wPhySecId = 0U; /*ID*/ + UINT8 cPhySecAreaUrgentState = PHYSEC_AREA_URGENT_YES; /*ƶ״̬*/ + UINT8 chEaAreaLineType = 0U; + UINT8 chTrainPosMonitorState = 0u;/*гλüල־*/ + UINT8 chTrainNvramFlag = 0u;/*гNVRAM־*/ + UINT32 dwFlyProtectOverCyc= GetFlyProtectOverCyc(); /*ɳ*/ + UINT8 FlyProtectTrainNum; + UINT8 TrainFlyAxis = 0U; /*ɳ*/ + UINT8 chIndex = 0U; + TrainFlyProtectStru * pFlyData = NULL; + + wRcId = (UINT16)chLocalId; /* RCţ */ + + /* Ϣλ */ + ii++; + + chRtn = GetCiEmapCheckVer(chLocalId, &dwDataVer, targetDevType); + if (CI_SUCCESS == chRtn) + {/* ݰ汾 */ + LongToChar(dwDataVer, &szToGateWayDataBuf[ii]); + ii += 4u; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + {/* Э汾 */ + LongToChar(GATE_WAY_PRTCL_VER, &szToGateWayDataBuf[ii]); + ii += 4u; + } + else + { + ; + } + if (0U == dwFlyProtectOverCyc) + { + if (CI_SUCCESS == chRtn) + {/* TIOC㱨ATSԶɸѡгϢ */ + szToGateWayDataBuf[ii++] = MSG_TYPE_REPORT; /* 㱨ԶɸѡгϢ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_REPORT; + ShortToChar(GATE_WAY_APP_PRTCL_VER, &szToGateWayDataBuf[ii]); /* ӦЭ汾 */ + ii += 2u; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + chAtsScreenNum = GetAtsScreenNum(); + szToGateWayDataBuf[ii++] = chAtsScreenNum; /* Զɸѡг */ + for (chTrainIndex = 0u; chTrainIndex < chAtsScreenNum; chTrainIndex++) + { + wTrainId = GetAtsScreenTrainIdByIndex(chTrainIndex); + chRtn = dquDevName2HlhtId(wTrainId, wTrainLgcId, &dwTrainId); + chScreenType = GetAtsScreenTypeByIndex(chTrainIndex); + wLgcId = GetAtsScreenLgcIdByIndex(chTrainIndex); + chTrainPosMonitorState = GetTrainPosMonitorState(wTrainId); + chTrainNvramFlag = GetTrainNvramPosFlag(wTrainId); + + LongToChar(dwTrainId, &szToGateWayDataBuf[ii]); /* гID */ + ii += 4u; + + if (TRAIN_SCREEN_TYPE_LU == chScreenType) + { + if ((TRAIN_POS_MONITOR_VALID == chTrainPosMonitorState) || (TRAIN_NVRAM_POS_FLAG_NO == chTrainNvramFlag)) + { + szToGateWayDataBuf[ii++] = TRAIN_SCREEN_TYPE_LU; /* Զɸѡ */ + } + else + { + szToGateWayDataBuf[ii++] = TRAIN_SCREEN_TYPE_POSTION_LOST; /* ලλЧɸѡ */ + } + + } + else + { + szToGateWayDataBuf[ii++] = chScreenType; + } + + ShortToChar(wLgcId, &szToGateWayDataBuf[ii]); /* г߼ */ + ii += 2u; + } + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + if (FLAG_SET == g_strAtsCfmFst.chFlag) + { + szToGateWayDataBuf[ii++] = MSG_TYPE_CONFIRM_FIRST; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_CONFIRM_FIRST; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = g_strAtsCfmFst.chStation; /* վ */ + szToGateWayDataBuf[ii++] = g_strAtsCfmFst.chIndex; /* վ */ + LongToChar(g_strAtsCfmFst.dwTime, &szToGateWayDataBuf[ii]); /* ʱ */ + ii += 4u; + szToGateWayDataBuf[ii++] = g_strAtsCfmFst.chOpStatus; /* ȷϽ */ + LongToChar(g_strAtsCfmFst.dwCrc32, &szToGateWayDataBuf[ii]); /* CRC */ + ii += 4u; + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + g_strAtsCfmFst.chFlag = FLAG_UNSET; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + if (FLAG_SET == g_strAtsCfmSnd.chFlag) + { + szToGateWayDataBuf[ii++] = MSG_TYPE_CONFIRM_SECOND; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_CONFIRM_SECOND; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = g_strAtsCfmSnd.chStation; /* վ */ + szToGateWayDataBuf[ii++] = g_strAtsCfmSnd.chIndex; /* վ */ + LongToChar(g_strAtsCfmSnd.dwTime, &szToGateWayDataBuf[ii]); /* ʱ */ + ii += 4u; + szToGateWayDataBuf[ii++] = g_strAtsCfmSnd.chOpStatus; /* ȷϽ */ + LongToChar(g_strAtsCfmSnd.dwCrc32, &szToGateWayDataBuf[ii]); /* CRC */ + ii += 4u; + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + g_strAtsCfmSnd.chFlag = FLAG_UNSET; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + /* TIOC㱨ATSɢϢ */ + szToGateWayDataBuf[ii++] = MSG_TYPE_EA_REPORT; /* ɢ㱨Ϣ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_EA_REPORT; + ShortToChar(GATE_WAY_APP_PRTCL_VER, &szToGateWayDataBuf[ii]); /* ӦЭ汾 */ + ii += 2u; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + + chEaNum = GetEaNum(); + if (EA_MAX_NUM < chEaNum) + { + chRtn = CI_ERROR; + } + else + { + chEaSendNum = 0u; + wEaNumIndex = ii; /* ¼㱨洢± */ + ii++; + + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + { + wEaTrainid = GetEvacuatingTrainIdByIndex(chEaIndex); + chRtn = dquDevName2HlhtId(wEaTrainid, wTrainLgcId, &dwEaTrainHlhtId); + chEaLgcNum = EaGetLgcNum(chEaIndex); + pEaLgcId = EaGetLgcId(chEaIndex); + chEaBuidFlag = GetEaBuildedFlag(chEaIndex); + chEaSrcId = GetEaSrcTiocByIndex(chEaIndex); + chPaType = GetPaTypeByIndex(chEaIndex); + chEaConfigId = GetEaConfigID(chEaIndex); + chEaAreaLineType = GetEaAreaLineType(chEaIndex); + if ((NULL == pEaLgcId) || (CI_ERROR == chRtn) || (EA_SECTION_MAX_NUM < chEaLgcNum) + || ((PA_TYPE_DA != chPaType) && (PA_TYPE_EA != chPaType))) + { + chRtn = CI_ERROR; + break; + } + else + { + if ((chEaSrcId == chLocalId) && (PA_TYPE_EA == chPaType)) + { + chEaSendNum++; + LongToChar(dwEaTrainHlhtId, &szToGateWayDataBuf[ii]); /* ɢгͨID */ + ii += 4u; + + szToGateWayDataBuf[ii++] = chEaConfigId; /* ID*/ + + szToGateWayDataBuf[ii++] = chEaBuidFlag; /* ־ */ + + szToGateWayDataBuf[ii++] = chEaAreaLineType; /* */ + + szToGateWayDataBuf[ii++] = chEaLgcNum; /* ߼ */ + for (chEaLgcIndex = 0u; chEaLgcIndex < chEaLgcNum; chEaLgcIndex++) + { + ShortToChar(pEaLgcId[chEaLgcIndex], &szToGateWayDataBuf[ii]); + ii += 2u; + } + } + else + { + ; /* ǽ㱨ATS */ + } + } + } + + szToGateWayDataBuf[wEaNumIndex] = chEaSendNum; /* 㱨 */ + + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + if (FLAG_SET == g_strAtsEaCfmFst.chFlag) + { + szToGateWayDataBuf[ii++] = MSG_TYPE_EA_CONFIRM_FIRST; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_EA_CONFIRM_FIRST; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = g_strAtsEaCfmFst.chStation; /* վ */ + szToGateWayDataBuf[ii++] = g_strAtsEaCfmFst.chIndex; /* վ */ + LongToChar(g_strAtsEaCfmFst.dwTime, &szToGateWayDataBuf[ii]); /* ʱ */ + ii += 4u; + szToGateWayDataBuf[ii++] = g_strAtsEaCfmFst.chOpStatus; /* ȷϽ */ + LongToChar(g_strAtsEaCfmFst.dwCrc32, &szToGateWayDataBuf[ii]); /* CRC */ + ii += 4u; + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + g_strAtsEaCfmFst.chFlag = FLAG_UNSET; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + if (FLAG_SET == g_strAtsEaCfmSnd.chFlag) + { + szToGateWayDataBuf[ii++] = MSG_TYPE_EA_CONFIRM_SECOND; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_EA_CONFIRM_SECOND; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = g_strAtsEaCfmSnd.chStation; /* վ */ + szToGateWayDataBuf[ii++] = g_strAtsEaCfmSnd.chIndex; /* վ */ + LongToChar(g_strAtsEaCfmSnd.dwTime, &szToGateWayDataBuf[ii]); /* ʱ */ + ii += 4u; + szToGateWayDataBuf[ii++] = g_strAtsEaCfmSnd.chOpStatus; /* ȷϽ */ + LongToChar(g_strAtsEaCfmSnd.dwCrc32, &szToGateWayDataBuf[ii]); /* CRC */ + ii += 4u; + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + g_strAtsEaCfmSnd.chFlag = FLAG_UNSET; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + /* TIOC㱨ATSȫгƶϢ */ + szToGateWayDataBuf[ii++] = MSG_TYPE_WLB_REPORT; /* ȫгƶ㱨Ϣ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_WLB_REPORT; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + + wWlbSum = 0U; + wWlbSumIndex = ii; + ii += 2U; + + /*ȫ߽ƶϢ*/ + chWlbState = WlbGetState(); + if (WLB_UNSET != chWlbState) + { + wWlbSum++; + szToGateWayDataBuf[ii++] = WLB_TYPE_RC; /* ƶ */ + ShortToChar(wRcId, &szToGateWayDataBuf[ii]); /* RC */ + ii += 2u; + } + else + { + /* δã */ + } + + /*ƶϢ*/ + wPhyCurSum = GetPhySecCurSum(); + for (jj = 0U; jj < wPhyCurSum; jj++) + { + wPhySecId = GetPhySecId(jj); + cPhySecAreaUrgentState = GetPhySecAreaUrgentState(wPhySecId); + if (PHYSEC_AREA_URGENT_NO != cPhySecAreaUrgentState) + { + wWlbSum++; + szToGateWayDataBuf[ii++] = WLB_TYPE_PHYSEC; /* ƶ */ + ShortToChar(wPhySecId, &szToGateWayDataBuf[ii]); /* α */ + ii += 2U; + } + else + { + /**/ + } + } + + ShortToChar(wWlbSum, &szToGateWayDataBuf[wWlbSumIndex]); /* ƶ */ + + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + if (FLAG_SET == g_strAtsWlbCfmFst.chFlag) + { + szToGateWayDataBuf[ii++] = MSG_TYPE_WLB_CONFIRM_FIRST; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_WLB_CONFIRM_FIRST; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = g_strAtsWlbCfmFst.chStation; /* վ */ + szToGateWayDataBuf[ii++] = g_strAtsWlbCfmFst.chIndex; /* վ */ + + LongToChar(g_strAtsWlbCfmFst.dwTime, &szToGateWayDataBuf[ii]); /* ʱ */ + ii += 4u; + szToGateWayDataBuf[ii++] = g_strAtsWlbCfmFst.chOpStatus; /* ȷϽ */ + LongToChar(g_strAtsWlbCfmFst.dwCrc32, &szToGateWayDataBuf[ii]); /* CRC */ + ii += 4u; + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + g_strAtsWlbCfmFst.chFlag = FLAG_UNSET; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + if (FLAG_SET == g_strAtsWlbCfmSnd.chFlag) + { + szToGateWayDataBuf[ii++] = MSG_TYPE_WLB_CONFIRM_SECOND; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_WLB_CONFIRM_SECOND; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = g_strAtsWlbCfmSnd.chStation; /* վ */ + szToGateWayDataBuf[ii++] = g_strAtsWlbCfmSnd.chIndex; /* վ */ + + LongToChar(g_strAtsWlbCfmSnd.dwTime, &szToGateWayDataBuf[ii]); /* ʱ */ + ii += 4u; + szToGateWayDataBuf[ii++] = g_strAtsWlbCfmSnd.chOpStatus; /* ȷϽ */ + LongToChar(g_strAtsWlbCfmSnd.dwCrc32, &szToGateWayDataBuf[ii]); /* CRC */ + ii += 4u; + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + g_strAtsWlbCfmSnd.chFlag = FLAG_UNSET; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + /* TIOC㱨ATSѹϢ */ + szToGateWayDataBuf[ii++] = MSG_TYPE_DA_REPORT; /* ѹ㱨Ϣ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_DA_REPORT; + ShortToChar(GATE_WAY_APP_PRTCL_VER, &szToGateWayDataBuf[ii]); /* ӦЭ汾 */ + ii += 2u; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + + chEaNum = GetEaNum(); + if (EA_MAX_NUM < chEaNum) + { + chRtn = CI_ERROR; + } + else + { + chEaSendNum = 0u; + wEaNumIndex = ii; /* ¼㱨洢± */ + ii++; + + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + { + wEaTrainid = GetEvacuatingTrainIdByIndex(chEaIndex); + chRtn = dquDevName2HlhtId(wEaTrainid, wTrainLgcId, &dwEaTrainHlhtId); + chEaLgcNum = EaGetLgcNum(chEaIndex); + pEaLgcId = EaGetLgcId(chEaIndex); + chEaBuidFlag = GetEaBuildedFlag(chEaIndex); + chEaSrcId = GetEaSrcTiocByIndex(chEaIndex); + chPaType = GetPaTypeByIndex(chEaIndex); + chEaAreaLineType = GetEaAreaLineType(chEaIndex); + + if ((NULL == pEaLgcId) || (CI_ERROR == chRtn) || (EA_SECTION_MAX_NUM < chEaLgcNum) + || ((PA_TYPE_DA != chPaType) && (PA_TYPE_EA != chPaType))) + { + chRtn = CI_ERROR; + break; + } + else + { + if ((chEaSrcId == chLocalId) && (PA_TYPE_DA == chPaType)) + { + chEaSendNum++; + LongToChar(dwEaTrainHlhtId, &szToGateWayDataBuf[ii]); /* ɢгͨID */ + ii += 4u; + + szToGateWayDataBuf[ii++] = chEaAreaLineType; /* */ + + szToGateWayDataBuf[ii++] = chEaLgcNum; /* ߼ */ + for (chEaLgcIndex = 0u; chEaLgcIndex < chEaLgcNum; chEaLgcIndex++) + { + ShortToChar(pEaLgcId[chEaLgcIndex], &szToGateWayDataBuf[ii]); + ii += 2u; + } + } + else + { + ; /* ǽ㱨ATS */ + } + } + } + + szToGateWayDataBuf[wEaNumIndex] = chEaSendNum; /* 㱨 */ + + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + if (FLAG_SET == g_strAtsDaCfmFst.chFlag) + { + szToGateWayDataBuf[ii++] = MSG_TYPE_DA_CONFIRM_FIRST; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_DA_CONFIRM_FIRST; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = g_strAtsDaCfmFst.chStation; /* վ */ + szToGateWayDataBuf[ii++] = g_strAtsDaCfmFst.chIndex; /* վ */ + LongToChar(g_strAtsDaCfmFst.dwTime, &szToGateWayDataBuf[ii]); /* ʱ */ + ii += 4u; + szToGateWayDataBuf[ii++] = g_strAtsDaCfmFst.chOpStatus; /* ȷϽ */ + LongToChar(g_strAtsDaCfmFst.dwCrc32, &szToGateWayDataBuf[ii]); /* CRC */ + ii += 4u; + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + g_strAtsDaCfmFst.chFlag = FLAG_UNSET; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + if (FLAG_SET == g_strAtsDaCfmSnd.chFlag) + { + szToGateWayDataBuf[ii++] = MSG_TYPE_DA_CONFIRM_SECOND; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_DA_CONFIRM_SECOND; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = g_strAtsDaCfmSnd.chStation; /* վ */ + szToGateWayDataBuf[ii++] = g_strAtsDaCfmSnd.chIndex; /* վ */ + LongToChar(g_strAtsDaCfmSnd.dwTime, &szToGateWayDataBuf[ii]); /* ʱ */ + ii += 4u; + szToGateWayDataBuf[ii++] = g_strAtsDaCfmSnd.chOpStatus; /* ȷϽ */ + LongToChar(g_strAtsDaCfmSnd.dwCrc32, &szToGateWayDataBuf[ii]); /* CRC */ + ii += 4u; + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + g_strAtsDaCfmSnd.chFlag = FLAG_UNSET; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + /* TIOC㱨ATSгϢ */ + rrm_GetInfToATSUCTInfo(&strTrainInfo); + szToGateWayDataBuf[ii++] = MSG_TYPE_TRIAN_INFO_REPORT; /* 㱨ԶɸѡгϢ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_TRIAN_INFO_REPORT; + ShortToChar(GATE_WAY_APP_PRTCL_VER, &szToGateWayDataBuf[ii]); /* ӦЭ汾 */ + ii += 2u; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + szToGateWayDataBuf[ii++] = strTrainInfo.trainCnt; /* г */ + for (chTrainIndex = 0u; chTrainIndex < strTrainInfo.trainCnt; chTrainIndex++) + { + (void)dquDevName2HlhtId(strTrainInfo.TrainID[chTrainIndex], wTrainLgcId, &dwTrainId); + LongToChar(dwTrainId, &szToGateWayDataBuf[ii]); /* гͨID */ + ii += 4u; + + ShortToChar(strTrainInfo.TailSecID[chTrainIndex], &szToGateWayDataBuf[ii]); /* гβ߼ */ + ii += 2u; + } + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + chMsgNum++; /* Ϣ */ + } + else + { + ; + } + } + else + { + /*ɳ崻Ϣ*/ + szToGateWayDataBuf[ii++] = MSG_TYPE_TRAIN_FLY_INFO; /* ֡ */ + wMsgLenIndex = ii; /* ¼֡ȴ± */ + ii += 2u; + szToGateWayDataBuf[ii++] = MSG_TYPE_TRAIN_FLY_INFO; + + ShortToChar(GATE_WAY_APP_PRTCL_VER, &szToGateWayDataBuf[ii]); /* ӦЭ汾 */ + ii += 2u; + szToGateWayDataBuf[ii++] = chLocalId; /* TIOC */ + + FlyProtectTrainNum = GetFlyProtectNum(); + if (SHUT_DOWN_TRAIN_NUMMAX < FlyProtectTrainNum) + { + chRtn = CI_ERROR; + } + else + { + szToGateWayDataBuf[ii++] = FlyProtectTrainNum; /*ɳг*/ + for (chIndex = 0U; chIndex < FlyProtectTrainNum; chIndex++) + { + pFlyData = GetFlyProtectData(chIndex); + wTrainId = pFlyData->wTrainId; + TrainFlyAxis = pFlyData->flyProtectSecCnt; + chRtn = dquDevName2HlhtId((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U) + wTrainId, 0U, &dwTrainId); /*ֽгIDתΪ4ֽڻͨID*/ + if (chRtn == CI_SUCCESS) + {/*ͨIDѯɹ*/ + LongToChar(dwTrainId, &szToGateWayDataBuf[ii]); /* гID */ + ii += 4u; + /** ȡͨųӦİid */ + + if (TRAIN_FLYALARM_SECNUM_MAX < TrainFlyAxis) + { + chRtn = CI_ERROR; + } + else + { + szToGateWayDataBuf[ii++] = TrainFlyAxis; /* */ + /* ȡ id*/ + for (jj = 0U; jj < TrainFlyAxis; jj++) + { + wPhySecId = pFlyData->flyProtectSec[jj]; + ShortToChar(wPhySecId, &szToGateWayDataBuf[ii]); + ii += 2u; + } + } + + } + else + { /*ʧ*/ + chRtn = CI_ERROR; + } + } + wMsgLen = (ii - wMsgLenIndex - 2u); + ShortToChar(wMsgLen, &szToGateWayDataBuf[wMsgLenIndex]); /* ֡ */ + } + + if (CI_SUCCESS == chRtn) + { + debug_infor_printf((const)"\n GATEWAY_FLY_SHUT_DOWN \n"); + chMsgNum = 1U; + } + } + if (CI_SUCCESS == chRtn) + { + /* ɹϢ */ + szToGateWayDataBuf[wMsgNumIndex] = chMsgNum; + wDstDevId = (UINT16)(((UINT16)targetDevType << 8U) | (UINT16)deviceId); + chRtn = OutnetSafeSend(wDstDevId, 0u, &szToGateWayDataBuf[0], ii); + if (CI_SUCCESS == chRtn) + { + debug_infor_printf((const)"\nGATEWAY_SEND:%d", ii); + debug_out_array(0xAA, szToGateWayDataBuf, ii); + } + else + { + ; + } + } + else + { + ; + } + + return chRtn; +} + +/** +* @brief ȫ߽ƶIDУ +* @param const UINT8 cDeviceType 豸 +* @param const UINT16 wDeviceId 豸ID +* @return 1 ɹ0 ʧ +* @note Created By LQ 2023.11.09 +*/ +UINT8 WlbUrgentIdCheck(const UINT8 cDeviceType, const UINT16 wDeviceId) +{ + UINT8 retVal = CI_ERROR; + UINT8 cLocalCiId = 0U; /*ID*/ + UINT8 cPhySecBelongCiId = 0U; /**/ + + cLocalCiId = GetSystemParaLocalCiId(); + + if (((WLB_TYPE_RC == cDeviceType) && (0U != wDeviceId) && (CI_SUM_MAX > wDeviceId)) + || ((WLB_TYPE_PHYSEC == cDeviceType) && (0U != wDeviceId) && (PHYSICAL_SECTION_SUM_MAX > wDeviceId))) + { + switch (cDeviceType) + { + case WLB_TYPE_RC: + if ((cLocalCiId == (UINT8)wDeviceId) && (0U != cLocalCiId)) + { + retVal = CI_SUCCESS; + } + else + { + /*DZʧ*/ + } + break; + case WLB_TYPE_PHYSEC: + cPhySecBelongCiId = GetPhySecBelongCiId(wDeviceId); + if ((cLocalCiId == cPhySecBelongCiId) && (0U != cLocalCiId)) + { + retVal = CI_SUCCESS; + } + else + { + /*DZʧ*/ + } + break; + default: + /*ʧ*/ + break; + } + } + else + { + /*ηǷʧ*/ + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackGateWayData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackGateWayData.h new file mode 100644 index 0000000..4825614 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackGateWayData.h @@ -0,0 +1,411 @@ +#ifndef _PARSE_PACK_GW_DATA_H_ +#define _PARSE_PACK_GW_DATA_H_ +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" + +#define MSG_TYPE_WLB_REPORT ((UINT8)111u) /*㱨ȫгƶϢ*/ +#define MSG_TYPE_WLB_SET_FIRST ((UINT8)112u) /*ȫгƶһ*/ +#define MSG_TYPE_WLB_CONFIRM_FIRST ((UINT8)113u) /*ȫгƶ״ȷ*/ +#define MSG_TYPE_WLB_SET_SECOND ((UINT8)114u) /*ȫгƶö*/ +#define MSG_TYPE_WLB_CONFIRM_SECOND ((UINT8)115u) /*ȫгƶȷ*/ +#define MSG_TYPE_DA_REPORT ((UINT8)116u) /*ѹ㱨Ϣ*/ +#define MSG_TYPE_DA_CANCLE_FIRST ((UINT8)117u) /*ѹȡ״Ϣ*/ +#define MSG_TYPE_DA_CONFIRM_FIRST ((UINT8)118u) /*ѹ״ȷϢ*/ +#define MSG_TYPE_DA_CANCLE_SECOND ((UINT8)119u) /*ѹȡٴϢ*/ +#define MSG_TYPE_DA_CONFIRM_SECOND ((UINT8)120u) /*ѹٴȷϢ*/ +#define MSG_TYPE_REPORT ((UINT8)121u) /*㱨ԶɸѡгϢ*/ +#define MSG_TYPE_REQUEST_FIRST ((UINT8)122u) /*״Ϣ*/ +#define MSG_TYPE_CONFIRM_FIRST ((UINT8)123u) /*״ȷ*/ +#define MSG_TYPE_REQUEST_SECOND ((UINT8)124u) /*ٴϢ*/ +#define MSG_TYPE_CONFIRM_SECOND ((UINT8)125u) /*ٴȷ*/ +#define MSG_TYPE_EA_REPORT ((UINT8)126u) /*ɢ㱨Ϣ*/ +#define MSG_TYPE_EA_CANCLE_FIRST ((UINT8)127u) /*ɢȡ״Ϣ*/ +#define MSG_TYPE_EA_CONFIRM_FIRST ((UINT8)128u) /*ɢ״ȷϢ*/ +#define MSG_TYPE_EA_CANCLE_SECOND ((UINT8)129u) /*ɢȡٴϢ*/ +#define MSG_TYPE_EA_CONFIRM_SECOND ((UINT8)130u) /*ɢٴȷϢ*/ +#define MSG_TYPE_TRIAN_INFO_REPORT ((UINT8)131u) /*TIOCATSгϢ*/ +#define MSG_TYPE_TRAIN_FLY_INFO ((UINT8)132u) /*TIOCATSͷɳ崻Ϣ*/ + +#define CONFIRM_UNKNOWN ((UINT8)0u) /*δ֪*/ +#define CONFIRM_FIRST_SUCCESS ((UINT8)1u) /*״ȷϳɹ*/ +#define CONFIRM_FIRST_REPEAT ((UINT8)2u) /*ظȷ*/ +#define CONFIRM_FIRST_TRAINID ((UINT8)3u) /*ˢг*/ +#define CONFIRM_FIRST_LGCID ((UINT8)4u) /*ȷ߼*/ +#define CONFIRM_SECOND_SUCCESS ((UINT8)1u) /*ȷϳɹ*/ +#define CONFIRM_SECOND_CRC ((UINT8)2u) /*CRCУʧ*/ +#define CONFIRM_SECOND_TRAINID ((UINT8)3u) /*ˢг*/ +#define CONFIRM_SECOND_LGCID ((UINT8)4u) /*ȷ߼*/ +#define CONFIRM_SECOND_FIRST ((UINT8)5u) /*״ɸѡȷʧ*/ +#define CONFIRM_SECOND_DIFF ((UINT8)6u) /*Ϣһβһ*/ + +#define CONFIRM_FIRST_NOT_EA ((UINT8)7u) /*гδɢ*/ +#define CONFIRM_FIRST_EING ((UINT8)9u) /*гɢ*/ + +#define CONFIRM_EA_SECOND_CRC ((UINT8)3u) /*CRCʧ*/ +#define CONFIRM_EA_SECOND_FIRST ((UINT8)4u) /*δִһ*/ +#define CONFIRM_SECOND_NOT_EA ((UINT8)5u) /*гδɢ*/ +#define CONFIRM_SECOND_EA_TRAINID ((UINT8)8u) /*״гŲһ*/ +#define CONFIRM_SECOND_TIOC ((UINT8)10u) /*ڿͨж*/ +#define CONFIRM_EALINE_DIFFERENT ((UINT8)11U) /*ȡѽԲһ*/ + +#define MSG_TYPE_WLB_SET ((UINT8)0xaau) /*ȫгƶ*/ +#define MSG_TYPE_WLB_CANCEL ((UINT8)0x55u) /*ȫгƶȡ*/ + +#define WLB_TYPE_RC ((UINT8)2u) /*ȫгƶ*/ +#define WLB_TYPE_PHYSEC ((UINT8)3u) /*νƶ*/ + +#define CONFIRM_WLB_FST_UNKNOWN ((UINT8)0u) /*״λظδ֪*/ +#define CONFIRM_WLB_FST_SUCCESS ((UINT8)1u) /*״λظɹ*/ +#define CONFIRM_WLB_FST_REPEAT ((UINT8)2u) /*״λظظ*/ +#define CONFIRM_WLB_FST_UNSET ((UINT8)5u) /*״λظδ*/ + +#define CONFIRM_WLB_SND_UNKNOWN ((UINT8)0u) /*λظδ֪*/ +#define CONFIRM_WLB_SND_SUCCESS ((UINT8)1u) /*λظɹ*/ +#define CONFIRM_WLB_SND_CRC ((UINT8)3u) /*λظCRCʧ*/ +#define CONFIRM_WLB_SND_FIRST ((UINT8)4u) /*λظδִ״ȷ*/ + +#define CONFIRM_DA_FST_UNKNOWN ((UINT8)0u) /*ȡѹ״λظδ֪*/ +#define CONFIRM_DA_FST_SUCCESS ((UINT8)1u) /*ȡѹ״λظɹ*/ +#define CONFIRM_DA_FST_UNSET ((UINT8)7u) /*ȡѹ״λظδ*/ +#define CONFIRM_DA_FST_DERAIL ((UINT8)9u) /*ȡѹ״λظǰгѹ״̬*/ + +#define CONFIRM_DA_SND_UNKNOWN ((UINT8)0u) /*ȡѹٴλظδ֪*/ +#define CONFIRM_DA_SND_SUCCESS ((UINT8)1u) /*ȡѹٴλظɹ*/ +#define CONFIRM_DA_SND_CRC ((UINT8)3u) /*ȡѹٴλظCRCʧ*/ +#define CONFIRM_DA_SND_FIRST ((UINT8)4u) /*ȡѹٴλظδִ״*/ +#define CONFIRM_DA_SND_DIFF ((UINT8)8u) /*ȡѹٴλظгIDһβһ*/ +#define CONFIRM_DA_SND_DERAIL ((UINT8)9u) /*ȡѹٴλظгǰѹ״̬*/ + +#define DA_AREA_UP ((UINT8)0x55u) /* */ +#define DA_AREA_DOWN ((UINT8)0xaau) /* */ +#define DA_AREA_ALL ((UINT8)0xffu) /* к */ + +#define ATS_DA_CMD_TYPE_CANCEL ((UINT8)0x55u) /* ATSȡѹ */ + +#define CONFIRM_TIMEOUT_CC ((UINT16)400u) /*״ϢȴϢʱʱ*/ + +#define GATE_WAY_PRTCL_VER ((UINT32)101u) /*Э汾*/ +#define GATE_WAY_APP_PRTCL_VER ((UINT16)3001u) /*ӦЭ汾*/ + +#define ATS_GATEWAY_CI_TRAIN_MAX ((UINT8)0xFEU) /*ATS TO CI гֵ*/ + +#define ATS_EA_CMD_TYPE_CANCEL ((UINT8)0x55u) /* ATSȡɢ */ + +#define EA_AREA_UP ((UINT8)0x55u) /* */ +#define EA_AREA_DOWN ((UINT8)0xaau) /* */ +#define EA_AREA_ALL ((UINT8)0xffu) /* к */ +/* ԶɸѡгϢṹ */ +typedef struct +{ + UINT32 dwTrainId; /*г*/ + UINT16 wLgcId; /*߼ID*/ +}AtsScreenTrainInfoStru; + +/* ATSԶɸѡ״Ϣṹ */ +typedef struct +{ + UINT8 chFlag; /*״Ϣ״̬*/ + UINT32 dwCycle; /*״Ϣں*/ + UINT8 chAtsId; /*ATS*/ + UINT8 chStation; /*վ*/ + UINT8 chIndex; /*վ*/ + UINT8 chTiocId; /*TIOC*/ + UINT32 dwTime; /*ʱ*/ + UINT8 chTrainNum; /*г*/ + AtsScreenTrainInfoStru strTrainInfo[TRAIN_SUM_MAX]; /*гϢ*/ +}AtsScreenMsgFstStru; + +/* ATSԶɸѡȷϽṹ */ +typedef struct +{ + UINT8 chFlag; /*ϢЧ*/ + UINT8 chTiocId; /*TIOC*/ + UINT8 chStation; /*վ*/ + UINT8 chIndex; /*վ*/ + UINT32 dwTime; /*ʱ*/ + UINT8 chOpStatus; /**/ + UINT32 dwCrc32; /*CRC*/ +}AtsMsgCfmStru; + +/* ATSԶɸѡϢṹ */ +typedef struct +{ + UINT8 chFlag; /*״Ϣ״̬*/ + UINT32 dwCycle; /*״Ϣں*/ + UINT8 chAtsId; /*ATS*/ + UINT8 chStation; /*վ*/ + UINT8 chIndex; /*վ*/ + UINT8 chTiocId; /*TIOC*/ + UINT32 dwTime; /*ʱ*/ + UINT8 chTrainNum; /*г*/ + AtsScreenTrainInfoStru strTrainInfo[TRAIN_SUM_MAX]; /*гϢ*/ + UINT32 dwCrc32; /*CRCֵ*/ +}AtsScreenMsgSndStru; + +/* ATSȡɢϢṹ */ +typedef struct +{ + UINT8 chFlag; /*Ϣ״̬*/ + UINT32 dwCycle; /*Ϣں*/ + UINT8 chAtsId; /*ATS*/ + UINT8 chStation; /*վ*/ + UINT8 chIndex; /*վ*/ + UINT8 chTiocId; /*TIOC*/ + UINT32 dwEaTrainId; /*гͨ*/ + UINT32 dwTime; /*ʱ*/ + UINT8 chType; /*/ȡ*/ + UINT8 chLine; /*·*/ + UINT32 dwCrc32; /*CRCֵ*/ +}AtsEaMsgStru; + +/* ATS/ȡȫгƶϢṹ */ +typedef struct +{ + UINT8 chFlag; /*Ϣ״̬*/ + UINT32 dwCycle; /*Ϣں*/ + UINT8 chAtsId; /*ATS*/ + UINT8 chStation; /*վ*/ + UINT8 chIndex; /*վ*/ + UINT8 chTiocId; /*TIOC*/ + UINT32 dwTime; /*ʱ*/ + UINT8 chType; /*/ȡ*/ + UINT32 dwCrc32; /*CRCֵ*/ + UINT8 chBrakeType; /*ƶ*/ + UINT8 chBrakeCount; /**/ + UINT16 wBrakeIndex; /*ƶID*/ +}AtsWlbMsgStru; + +/* ATSȡѹϢṹ */ +typedef struct +{ + UINT8 chFlag; /*Ϣ״̬*/ + UINT32 dwCycle; /*Ϣں*/ + UINT8 chAtsId; /*ATS*/ + UINT8 chStation; /*վ*/ + UINT8 chIndex; /*վ*/ + UINT8 chTiocId; /*TIOC*/ + UINT32 dwDaTrainId; /*гͨ*/ + UINT32 dwTime; /*ʱ*/ + UINT8 chType; /*/ȡ*/ + UINT8 chLine; /*·*/ + UINT32 dwCrc32; /*CRCֵ*/ +}AtsDaMsgStru; + +/*******************************ȫֱ*******************************/ +extern AtsScreenMsgFstStru g_strAtsMsgFst; +extern AtsMsgCfmStru g_strAtsCfmFst; +extern AtsScreenMsgSndStru g_strAtsMsgSnd; +extern AtsMsgCfmStru g_strAtsCfmSnd; + +extern AtsEaMsgStru g_strAtsEaMsgFst; +extern AtsMsgCfmStru g_strAtsEaCfmFst; +extern AtsEaMsgStru g_strAtsEaMsgSnd; +extern AtsMsgCfmStru g_strAtsEaCfmSnd; + +extern AtsWlbMsgStru g_strAtsWlbMsgFst; +extern AtsMsgCfmStru g_strAtsWlbCfmFst; +extern AtsWlbMsgStru g_strAtsWlbMsgSnd; +extern AtsMsgCfmStru g_strAtsWlbCfmSnd; + +extern AtsDaMsgStru g_strAtsDaMsgFst; +extern AtsMsgCfmStru g_strAtsDaCfmFst; +extern AtsDaMsgStru g_strAtsDaMsgSnd; +extern AtsMsgCfmStru g_strAtsDaCfmSnd; + + +/** +* @brief ȡԶɸѡATS״Ϣ +* @param +* @return ԶɸѡATS״Ϣ +*/ +extern AtsScreenMsgFstStru * GetAtsMsgFst(void); + +/** +* @brief ȡԶɸѡATSϢ +* @param +* @return ԶɸѡATSϢ +*/ +extern AtsScreenMsgSndStru * GetAtsMsgSnd(void); + +/** +* @brief ȡԶɸѡ״ȷϢ +* @param +* @return Զɸѡ״ȷϢ +*/ +extern AtsMsgCfmStru * GetAtsCfmFst(void); + +/** +* @brief ȡԶɸѡȷϢ +* @param +* @return ԶɸѡȷϢ +*/ +extern AtsMsgCfmStru * GetAtsCfmSnd(void); + +/** +* @brief ȡԶɸѡȷϢ +* @param +* @return ԶɸѡȷϢ +*/ +extern UINT8 PackTiocToGateWayData(const UINT8 deviceId, const UINT8 targetDevType); + + +/** +* @brief ֡ +* @param const UINT8* dataBuf, ݻ +* @param const UINT16 dataLength, ݳ +* @return CI_SUCCESS:ɹCI_ERROR:ʧ +*/ +extern UINT8 ParseGateWayToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength); + +/** +* @brief 1ATSɸѡϢ +* @param void +* @return void +*/ +void ClearAtsMsgFirst(void); + +/** +* @brief 2ATSɸѡϢ +* @param void +* @return void +*/ +void ClearAtsMsgSecond(void); + +/** +* @brief ȡATSȡɢ״Ϣ +* @param +* @return ATSȡɢ״Ϣ +*/ +AtsEaMsgStru * GetAtsEaMsgFst(void); + +/** +* @brief ȡATSȡɢϢ +* @param +* @return ATSȡɢϢ +*/ +AtsEaMsgStru * GetAtsEaMsgSnd(void); + +/** +* @brief ȡATSȡɢ״ȷ +* @param +* @return ATSȡɢ״ȷ +*/ +AtsMsgCfmStru * GetAtsEaCfmFst(void); + +/** +* @brief ȡATSȡɢȷ +* @param +* @return ATSȡɢȷ +*/ +AtsMsgCfmStru * GetAtsEaCfmSnd(void); + +/** +* @brief 1ATSɢϢ +* @param void +* @return void +*/ +void ClearAtsEaMsgFirst(void); + +/** +* @brief 2ATSɢϢ +* @param void +* @return void +*/ +void ClearAtsEaMsgSecond(void); + +/** +* @brief ȡATS/ȡȫгƶ״Ϣ +* @param +* @return ATS/ȡɢ״Ϣ +*/ +AtsWlbMsgStru * GetAtsWlbMsgFst(void); + +/** +* @brief ȡATSȡȫгƶϢ +* @param +* @return ATSȡȫгƶϢ +*/ +AtsWlbMsgStru * GetAtsWlbMsgSnd(void); + +/** +* @brief ȡATS/ȡȫгƶ״ȷ +* @param +* @return ATS/ȡȫгƶ״ȷ +*/ +AtsMsgCfmStru * GetAtsWlbCfmFst(void); + +/** +* @brief ȡATSȡȫгƶȷ +* @param +* @return ATSȡȫгƶȷ +*/ +AtsMsgCfmStru * GetAtsWlbCfmSnd(void); + +/** +* @brief 1ATS/ȡȫгƶϢ +* @param void +* @return void +*/ +void ClearAtsWlbMsgFirst(void); + +/** +* @brief 2ATSȡȫгƶϢ +* @param void +* @return void +*/ +void ClearAtsWlbMsgSecond(void); + +/** +* @brief ȡATSȡѹ״Ϣ +* @param +* @return ATSȡѹ״Ϣ +*/ +AtsDaMsgStru * GetAtsDaMsgFst(void); + +/** +* @brief ȡATSȡѹϢ +* @param +* @return ATSȡѹϢ +*/ +AtsDaMsgStru * GetAtsDaMsgSnd(void); + +/** +* @brief ȡATSȡѹ״ȷ +* @param +* @return ATSȡѹ״ȷ +*/ +AtsMsgCfmStru * GetAtsDaCfmFst(void); + +/** +* @brief ȡATSȡѹȷ +* @param +* @return ATSȡѹȷ +*/ +AtsMsgCfmStru * GetAtsDaCfmSnd(void); + +/** +* @brief 1ATSȡѹϢ +* @param void +* @return void +*/ +void ClearAtsDaMsgFirst(void); + +/** +* @brief 2ATSȡѹϢ +* @param void +* @return void +*/ +void ClearAtsDaMsgSecond(void); + +/** +* @brief ȫ߽ƶIDУ +* @param const UINT8 cDeviceType 豸 +* @param const UINT16 wDeviceId 豸ID +* @return 1 ɹ + 0 ʧ +*/ +UINT8 WlbUrgentIdCheck(const UINT8 cDeviceType, const UINT16 wDeviceId); + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackITEData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackITEData.c new file mode 100644 index 0000000..de46f75 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackITEData.c @@ -0,0 +1,489 @@ +/******************************************************** +* +* ParsePackITEData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2024-06-05 +* ߣ +* ITEݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + +#include "ParsePackITEData.h" + + +IteToCiDataStruct IteToCiDataStru[ITE_TO_CI_SUM_MAX] = { 0U }; /*ͨŵITEϢ*/ +UINT8 IteToCiSum = 0U; /*ͨŵITEĿ*/ + + +/* +* ȡCIͨŵITEͨŽṹ +* ˵void +* ֵNULL ȡʧ +* NULL CIͨŵITEͨŽṹ +* Created By LQ 2024.06.06 +*/ +IteToCiDataStruct* GetIteToCiDataStru(void) +{ + IteToCiDataStruct* pRetVal = NULL; + + if (0U != IteToCiSum) + { + pRetVal = IteToCiDataStru; + } + else + { + pRetVal = NULL; /*CIͨŵITENULL*/ + } + + return pRetVal; +} + +/* +* ȡCIͨŵITEͨŽṹ +* ˵ +* ֵCIͨŵITEͨŽṹ +* Created By LQ 2024.06.06 +*/ +UINT8 GetIteToCiSum(void) +{ + return IteToCiSum; +} + +/* +* ITE +* ˵const UINT8* dataBuf ݻ +* const UINT16 dataLength ݳ +* const UINT8 systemId Դ豸ID +* const UINT16 logId ITEͨID1˻2˱ʶ +* ֵ CI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.06.05 +*/ +UINT8 ParseIteToCiData(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, const UINT16 logId) +{ + UINT8 ii = 0U; + UINT8 retVal = CI_ERROR; + UINT8 cGalHeadSavedFlag = CI_ERROR; + + if (IteToCiSum < ITE_TO_CI_SUM_MAX) + { + (void)CommonMemSet(&(IteToCiDataStru[IteToCiSum]), (UINT32)sizeof(IteToCiDataStruct), 0U, (UINT32)sizeof(IteToCiDataStruct)); /*ڴ棬ֹ*/ + + retVal = ParseIteToCiDataFrame(dataBuf, dataLength, systemId, &(IteToCiDataStru[IteToCiSum]), &cGalHeadSavedFlag, logId); + + if (CI_SUCCESS == retVal) + { + IteToCiSum++; + /*ͨŵITEITEͨŽṹǷѴڵǰITE*/ + for (ii = 0u; ii < (IteToCiSum - 1U); ii++) + { + if ((IteToCiDataStru[ii].wIteId == IteToCiDataStru[IteToCiSum - 1U].wIteId) && (IteToCiDataStru[ii].wIteLogId == IteToCiDataStru[IteToCiSum - 1U].wIteLogId)) + { + /*ĿITEѴͨŽṹУݿ֮ǰ洢ĵַ*/ + (void)CommonMemCpy(&(IteToCiDataStru[ii]), (UINT32)sizeof(IteToCiDataStruct), &(IteToCiDataStru[IteToCiSum - 1U]), (UINT32)sizeof(IteToCiDataStruct)); + IteToCiSum--; + break; + } + else + { + /**/ + } + } + } + else + { + (void)CommonMemSet(&(IteToCiDataStru[IteToCiSum]), (UINT32)sizeof(IteToCiDataStruct), 0U, (UINT32)sizeof(IteToCiDataStruct)); /*ɾһ*/ + + /*ͨͷѾˣִͨͷ򣬳Ҳͨͷ*/ + if (CI_ERROR == cGalHeadSavedFlag) + { + ClearIteHlhtHeadCtx(systemId, logId); + } + else + { + /**/ + } + + retVal = CI_ERROR; /*0ʧ*/ + } + } + else + { + /*ͨޣ0ʧ*/ + } + + return retVal; +} + + +/* +* ITE֡ +* ˵const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStru vobcTociݽṹָ +* UINT8* saveGalHead,ͨñͷǷ,1:0: +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ CI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.06.05 +*/ +UINT8 ParseIteToCiDataFrame(const UINT8* pDataBuf, const UINT16 dataLength, const UINT8 systemId, IteToCiDataStruct* pstIteToCiDataStru, UINT8* pSaveGalHead, const UINT16 logId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wIteName = 0U; /*ITE豸ƣ+ID*/ + UINT8 cLocalCiId = 0U; /*ID*/ + UINT16 wCiName = 0U; /*豸ƣ+ID*/ + HLHTGALInfoStruct strHlhtGalHead = { 0U }; /*ͨͷ*/ + UINT16 ii = 0U; /**/ + UINT32 dwCurCycNum = 0U; /*ǰں*/ + UINT8 cHeadGalCheckRet = HLHT_HEAD_ERROR; /*ͨͷ*/ + UINT32 dwErrorCode = 0U; + INT32 dwIteInfoRemainValidiy = 0; /*ϢʱЧ*/ + UINT32 dwTransBadCycCount = 0U; /*жͨж*/ + UINT32 dwAppCycle = 0U; /*Ӧ*/ + UINT16 wApplyDataLenth = 0U; /*Ӧݳ*/ + UINT16 wAppInfoType = 0U; /*ӦϢ*/ + UINT8 cTrainDir = 0U; /*гз*/ + + if ((NULL != pDataBuf) && (NULL != pstIteToCiDataStru) && (NULL != pSaveGalHead) && (ITE_TO_CI_DATA_LEN_MAX >= dataLength) && (0U != systemId) && (0U != logId)) + { + chRetVal = CI_SUCCESS; + + wIteName = (CI_SYSTEM_TYPE_ITE) * 256U + systemId; + cLocalCiId = GetSystemParaLocalCiId(); + wCiName = (CI_SYSTEM_TYPE_CI) * 256U + cLocalCiId; + + /*ͨϢͷ*/ + strHlhtGalHead.devInterInfoType = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + strHlhtGalHead.sourceId = LongFromChar(&pDataBuf[ii]); + ii += 4U; + strHlhtGalHead.destId = LongFromChar(&pDataBuf[ii]); + ii += 4U; + strHlhtGalHead.emapVerCrc = LongFromChar(&pDataBuf[ii]); + ii += 4U; + strHlhtGalHead.crntOwnMsgSN = LongFromChar(&pDataBuf[ii]); + ii += 4U; + strHlhtGalHead.comPeriod = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + strHlhtGalHead.recvOppMsgSN = LongFromChar(&pDataBuf[ii]); + + ii += 4U; + strHlhtGalHead.preOwnMsgSN = LongFromChar(&pDataBuf[ii]); + ii += 4U; + strHlhtGalHead.prtclVer = pDataBuf[ii++]; + strHlhtGalHead.totalDataLen = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + + pstIteToCiDataStru->wIteLogId = logId; /*洢ITE߼ID1˻2*/ + dwCurCycNum = Get2oo2CurCycleNum(); + cHeadGalCheckRet = HLHTRecvCommonPacketHeadCheck(wIteName, wCiName, ITE_CI_INTERFACE_INFOTYPE, CI_ITE_PRTCL_VER, &strHlhtGalHead, &dwErrorCode, logId, CI_SYSTEM_TYPE_ITE); + + debug_infor_printf((const)"\nITE %d GAL Check Result:%d errCode:%d", systemId, cHeadGalCheckRet, dwErrorCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + if (HLHT_HEAD_SUCCESS == cHeadGalCheckRet) + { + /*ϢʱЧ*/ + dwTransBadCycCount = GetCiAndVobcTransBadEnsureTime(); + dwAppCycle = GetSystemParaAppCycleTime(); + dwIteInfoRemainValidiy = HLHTCommonMsgRemainingValidity(dwTransBadCycCount, dwCurCycNum, dwAppCycle, strHlhtGalHead.recvOppMsgSN, strHlhtGalHead.crntOwnMsgSN, strHlhtGalHead.preOwnMsgSN, strHlhtGalHead.comPeriod); + + if (dwIteInfoRemainValidiy > 0) + { + pstIteToCiDataStru->dwComStartCycCount = dwCurCycNum; /*¼ͨʼ*/ + + /*Ӧ*/ + wApplyDataLenth = ShortFromChar(&pDataBuf[ii]); /*Ӧòݳ*/ + ii += 2U; + + wAppInfoType = ShortFromChar(&pDataBuf[ii]); /*ӦϢ*/ + ii += 2U; + + pstIteToCiDataStru->wIteId = systemId; + + ii += 2U; /*Ԥֽ*/ + + if (ITE_CI_INFO_TYPE_POSITION == wAppInfoType) + { + pstIteToCiDataStru->wTrainHeadLinkId = ShortFromChar(&pDataBuf[ii]); /*ͷlink ID*/ + ii += 2U; + + pstIteToCiDataStru->dwTrainHeadLinkOffset = LongFromChar(&pDataBuf[ii]); /*ͷlinkƫ*/ + ii += 4U; + + pstIteToCiDataStru->wTrainTailLinkId = ShortFromChar(&pDataBuf[ii]); /*βlink ID*/ + ii += 2U; + + pstIteToCiDataStru->dwTrainTailLinkOffset = LongFromChar(&pDataBuf[ii]); /*βlinkƫ*/ + ii += 4U; + + cTrainDir = pDataBuf[ii]; /*г*/ + ii++; + + pstIteToCiDataStru->cTrainDir = cTrainDir; + + pstIteToCiDataStru->wForWardOffset = ShortFromChar(&pDataBuf[ii]); /*λǰ*/ + ii += 2U; + + pstIteToCiDataStru->wBackOffset = ShortFromChar(&pDataBuf[ii]); /*λ*/ + ii += 2U; + } + else + { + chRetVal = CI_ERROR; /*ӦϢͷǷ0ʧ*/ + } + + if (CI_SUCCESS == chRetVal) + { + /*Уݳ γȣڲ㳤ȱټ¼ȵֽ */ + if ((strHlhtGalHead.totalDataLen != ii - 31U) || (wApplyDataLenth != ii - 33U)) + { + /* 31ΪӦ֡ͷ */ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\nstrHlhtGalHead.totalDataLen :%d ii %d wApplyDataLenth %d", strHlhtGalHead.totalDataLen, ii, wApplyDataLenth); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + } + else + { + /**/ + } + } + else + { + chRetVal = CI_ERROR; /*0ʧ*/ + } + + if (CI_SUCCESS == chRetVal) + { + SetIteHLHTHeadCtx(systemId, logId, &strHlhtGalHead); /*ݾУ飬洢ͨñͷ*/ + *pSaveGalHead = CI_SUCCESS; + } + else + { + /**/ + } + } + else + { + chRetVal = CI_ERROR; /*ʱ0ʧ*/ + } + } + else if (HLHT_HEAD_INIT == cHeadGalCheckRet) + { + if (dwCurCycNum > 0U) + { + SetIteHLHTHeadCtx(systemId, logId, &strHlhtGalHead); /*洢ͨñͷ*/ + *pSaveGalHead = CI_SUCCESS; + } + else + { + /**/ + } + + chRetVal = CI_ERROR; /*0ʧ*/ + } + else + { + chRetVal = CI_ERROR; /*0ʧ*/ + } + } + else + { + chRetVal = CI_ERROR; /*ηǷ0ʧ*/ + } + + return chRetVal; +} + +/* +* CIITE +* ˵void +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.06.06 +*/ +UINT8 PackCiToIteData(void) +{ + UINT8 retVal = CI_SUCCESS; + UINT8 ii = 0U; + UINT8 cInitIteNum = 0U; + UINT8 szInitIteIdBuf[ITE_TO_CI_SUM_MAX] = { 0U }; /*ʼͨ״̬ITEID*/ + UINT8 szInitIteLogIdBuf[ITE_TO_CI_SUM_MAX] = { 0U }; /*ʼͨ״̬ITE߼ID*/ + UINT8 cPackHeartFlag = CI_ERROR; + + /*ͨŵITE*/ + debug_infor_printf((const)"\nPackCiToIteData IteToCiSum = %d\n", IteToCiSum); /*ӡCIͨŵITEĿ*/ + for (ii = 0U; (ii < IteToCiSum) && (ii < ITE_TO_CI_SUM_MAX); ii++) + { + debug_infor_printf((const)"\nITE ID[%d]-ITE LogID[%d]", IteToCiDataStru[ii].wIteId, IteToCiDataStru[ii].wIteLogId); + retVal &= PackCiToIteDataFrame((UINT8)IteToCiDataStru[ii].wIteId, IteToCiDataStru[ii].wIteLogId); + } + + /*ʼͨŵITE*/ + cPackHeartFlag = GetIteHlhtInitHeadDevs(&cInitIteNum, szInitIteIdBuf, szInitIteLogIdBuf); + if (CI_SUCCESS == cPackHeartFlag) + { + for (ii = 0U; ii < cInitIteNum; ii++) + { + debug_infor_printf((const)"\nPackCiToIteData HeartFrame To ITE[%d]", szInitIteIdBuf[ii]); /*ӡCIʼͨŵITE*/ + retVal &= PackCiToIteDataFrame(szInitIteIdBuf[ii], szInitIteLogIdBuf[ii]); + } + } + else + { + /**/ + } + + return retVal; +} + +/* +* CIITE֡ +* ˵const UINT8 iteId ĿITE ID +* const UINT16 iteLogId ĿITE߼ID1˻2ˣ +* ֵ0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToIteDataFrame(const UINT8 iteId, const UINT16 iteLogId) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cFuncRet = CI_ERROR; + UINT8 cLocalCiId = 0U; /*ID*/ + UINT32 dwCiEtcsId = 0U; /*ͨID*/ + UINT32 dwIteEtcsId = 0U; /*ITEͨID*/ + UINT32 dwEmapCheckVer = 0U; /*ӵͼУ汾*/ + HLHTHeadContextStru* pstrHlhtHeadCtx = NULL; /*ITEͨͷ*/ + UINT32 dwCurCycNum = 0U; + UINT32 dwAppCycTime = 0U; /*Ӧ*/ + UINT16 ii = 0U; + UINT8 szCiToIteDataBuf[ITE_TO_CI_DATA_LEN_MAX] = { 0U }; /*CIITE*/ + UINT16 wGalLenIndex = 0U; + UINT16 wAppLenIndex = 0U; + UINT16 wGalLen = 0U; /*ͨñͷеӦò㱨ij*/ + UINT16 wAppLen = 0U; /*Ӧò㱨ij*/ + UINT16 wDstDevId = 0U; /*ITEţ0x19*/ + UINT8 cOutnetSafeSendRtn = 0U; /*ͽ*/ + + if ((0U < iteId) && (ITE_SUM_MAX > iteId) && (0U < iteLogId) && (VOBC_INC_ITE_SUM_MAX >= iteLogId)) + { + /*ȻȡʱϢȡɹż*/ + cLocalCiId = GetSystemParaLocalCiId(); + cFuncRet = dquDevName2HlhtId(((UINT16)CI_SYSTEM_TYPE_CI * 256U + cLocalCiId), 0U, &dwCiEtcsId); + cFuncRet &= dquDevName2HlhtId(((UINT16)CI_SYSTEM_TYPE_ITE * 256U) + iteId, iteLogId, &dwIteEtcsId); + cFuncRet &= GetCiEmapCheckVer(cLocalCiId, &dwEmapCheckVer, CI_SYSTEM_TYPE_ITE); + pstrHlhtHeadCtx = GetIteHLHTHeadCtx(iteId, iteLogId); /*ȡָITEͨͷ*/ + + if ((CI_SUCCESS == cFuncRet) && (NULL != pstrHlhtHeadCtx)) + { + cRetVal = CI_SUCCESS; + + /*ʼ*/ + ShortToChar(ITE_CI_INTERFACE_INFOTYPE, &szCiToIteDataBuf[ii]); /*ӿϢ*/ + ii += 2U; + + LongToChar(dwCiEtcsId, &szCiToIteDataBuf[ii]); /*ͷʶϢ*/ + ii += 4U; + + LongToChar(dwIteEtcsId, &szCiToIteDataBuf[ii]); /*շʶϢ*/ + ii += 4U; + + LongToChar(dwEmapCheckVer, &szCiToIteDataBuf[ii]); /*ӵͼ汾УϢ*/ + ii += 4U; + + dwCurCycNum = Get2oo2CurCycleNum(); + LongToChar(dwCurCycNum, &szCiToIteDataBuf[ii]); /*Ϣк*/ + ii += 4U; + + dwAppCycTime = GetSystemParaAppCycleTime(); + ShortToChar((UINT16)dwAppCycTime, &szCiToIteDataBuf[ii]); /*豸ͨѶ*/ + ii += 2U; + + LongToChar(pstrHlhtHeadCtx->sourceCrntOwnMsgSN, &szCiToIteDataBuf[ii]); /*ԷϢкţյԷһϢеĶԷϢк*/ + ii += 4U; + + LongToChar(pstrHlhtHeadCtx->ciPreRecvOwnSn, &szCiToIteDataBuf[ii]); /*յһϢʱк*/ + ii += 4U; + + szCiToIteDataBuf[ii] = CI_ITE_PRTCL_VER; /*CI_ITEӿЭ汾*/ + ii++; + + wGalLenIndex = ii; /*ͨñͷеӦò㱨ܳ*/ + ii += 2U; + + /*ΪӦò*/ + wAppLenIndex = ii; /*Ӧò㱨ij*/ + ii += 2U; + + ShortToChar(CI_ITE_INFO_TYPE_HEART, &szCiToIteDataBuf[ii]); /*ֽͣ*/ + ii += 2U; + + ii += 2U; /*Ԥֽ*/ + + /*ͨñͷӦò㱨ܳ*/ + wGalLen = ii - (wGalLenIndex + 2U); + ShortToChar(wGalLen, &szCiToIteDataBuf[wGalLenIndex]); + + /*Ӧòݵıij */ + wAppLen = ii - (wAppLenIndex + 2U); + ShortToChar(wAppLen, &szCiToIteDataBuf[wAppLenIndex]); + + wDstDevId = (UINT16)(CI_SYSTEM_TYPE_ITE << 8U) | ((UINT16)iteId); + cOutnetSafeSendRtn = OutnetSafeSend(wDstDevId, iteLogId, &szCiToIteDataBuf[0U], ii); + if (1U == cOutnetSafeSendRtn) + { + /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nITE_SEND:%d", ii); + debug_out_array(0xAA, szCiToIteDataBuf, ii); +#endif/*ƽ̨ӡ*/ +#endif + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; /*дʧ*/ + } + } + else + { + cRetVal = CI_ERROR; /*ȡʧܣ0ʧ*/ + } + } + else + { + cRetVal = CI_ERROR; /*ηǷ0ʧ*/ + } + + return cRetVal; +} + +/* +* ITE͸CIϢṹУɾָλü֮ +* ˵const UINT8 index ITE͸CIϢṹλ +* ֵ +* Created By LQ 2024.06.05 +*/ +void RemoveIteToCiMsgAt(const UINT8 index) +{ + UINT8 ii = 0U; + + if (index < IteToCiSum) + { + for (ii = index; ii < IteToCiSum; ii++) + { + (void)CommonMemSet(&(IteToCiDataStru[ii]), (UINT32)sizeof(IteToCiDataStruct), 0U, (UINT32)sizeof(IteToCiDataStruct)); + } + + IteToCiSum = index; + } + else + { + /*ޣ*/ + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackITEData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackITEData.h new file mode 100644 index 0000000..0bfaad6 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackITEData.h @@ -0,0 +1,129 @@ +/******************************************************** +* +* ParsePackITEData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2024-06-05 +* ߣ +* ITEݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_ITE_DATA_H_ +#define _PARSE_PACK_ITE_DATA_H_ + + +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "../HLHTMsgHead/HLHTCommonDataPacketHead.h" +#include "../HLHTMsgHead/HLHTHeadContexManage.h" +#include "../QueryFiles/dquCIInterFace.h" + + +#define ITE_TO_CI_DATA_LEN_MAX ((UINT16)1000U) /*ITECIֵ*/ +#define ITE_CI_INTERFACE_INFOTYPE ((UINT16)0x010AU) /*ITE->CIӿ*/ + +#define ITE_CI_INFO_TYPE_POSITION ((UINT16)0x0201U) /*ITE->CIλϢ֡*/ +#define CI_ITE_INFO_TYPE_HEART ((UINT16)0x0202U) /*CI->ITE֡*/ +#define CI_ITE_PRTCL_VER CI_IVOC_PRTCL_VER /*CI_ITEЭ汾*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*ͨŵITEϢ*/ +typedef struct S_IteToCiDataStruct +{ + UINT16 wIteId; /*ITE ID0x19ʶ*/ + UINT16 wIteLogId; /*ITE߼ID*/ + UINT16 wTrainHeadLinkId; /*гͷlink ID*/ + UINT32 dwTrainHeadLinkOffset; /*гͷlinkƫ*/ + UINT16 wTrainTailLinkId; /*гβlink ID*/ + UINT32 dwTrainTailLinkOffset; /*гβlinkƫ*/ + UINT8 cTrainDir; /*гз0x55߼0xAA߼*/ + UINT16 wForWardOffset; /*λǰcm*/ + UINT16 wBackOffset; /*λcm*/ + UINT32 dwComStartCycCount; /*ITEͨʼ*/ +} IteToCiDataStruct; + + +extern IteToCiDataStruct IteToCiDataStru[ITE_TO_CI_SUM_MAX]; +extern UINT8 IteToCiSum; +/* +* ȡCIͨŵITEͨŽṹ +* ˵void +* ֵNULL ȡʧ +* NULL CIͨŵITEͨŽṹ +* Created By LQ 2024.06.06 +*/ +IteToCiDataStruct* GetIteToCiDataStru(void); + +/* +* ȡCIͨŵITEͨŽṹ +* ˵ +* ֵCIͨŵITEͨŽṹ +* Created By LQ 2024.06.06 +*/ +UINT8 GetIteToCiSum(void); + +/* +* ITE +* ˵const UINT8* dataBuf ݻ +* const UINT16 dataLength ݳ +* const UINT8 systemId Դ豸ID +* const UINT16 logId ITEͨID1˻2˱ʶ +* ֵ CI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.06.05 +*/ +UINT8 ParseIteToCiData(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, const UINT16 logId); + +/* +* ITE֡ +* ˵const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStru vobcTociݽṹָ +* UINT8* saveGalHead,ͨñͷǷ,1:0: +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ CI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.06.05 +*/ +UINT8 ParseIteToCiDataFrame(const UINT8* pDataBuf, const UINT16 dataLength, const UINT8 systemId, IteToCiDataStruct* pstIteToCiDataStru, UINT8* pSaveGalHead, const UINT16 logId); + +/* +* CIITE +* ˵void +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.06.06 +*/ +UINT8 PackCiToIteData(void); + +/* +* CIITE֡ +* ˵const UINT8 iteId ĿITE ID +* const UINT16 iteLogId ĿITE߼ID1˻2ˣ +* ֵ0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToIteDataFrame(const UINT8 iteId, const UINT16 iteLogId); + +/* +* ITE͸CIϢṹУɾָλü֮ +* ˵const UINT8 index ITE͸CIϢṹλ +* ֵ +* Created By LQ 2024.06.05 +*/ +void RemoveIteToCiMsgAt(const UINT8 index); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackIoData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackIoData.c new file mode 100644 index 0000000..763b95a --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackIoData.c @@ -0,0 +1,328 @@ +/******************************************************** +* +* ParsePackIoData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* IOݽ +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackIoData.h" + + + +/**/ +IoDataStruct CollBoardDataStru[BOARD_SUM_MAX]; /*IOCI֡ṹ*/ +UINT8 CollBroadStruCurSum = 0u; /*IOCIݽṹ嵱ǰ*/ + +UINT32 preRawLen = 0; /*͸ݳ*/ +UINT8 preTempDataBuf[BOARD_SUM_MAX * (BOARD_COLL_DATA_LEN + 1U)] = { 0U }; /*ʱ*/ + +/* +* IO +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseIoToCiData(void ) +{ /*ܳ*/ + UINT8 tempDataBuf[BOARD_SUM_MAX *(BOARD_COLL_DATA_LEN + 1U)] = {0u}; /*ʱ*/ + /*BOARD_SUM_MAX:һվɼĿֵ + BOARD_COLL_DATA_LEN:һɼɼݳ + 1:忨ַ + */ + + UINT32 rawLen = 0U; /*͸ݳ*/ + + rawLen = InnetRawIoRecv(tempDataBuf, (UINT32)sizeof(tempDataBuf)); + if (rawLen > 0U) + { + (void)memcpy(preTempDataBuf, tempDataBuf, rawLen); + preRawLen = rawLen; + } + else + { + (void)memcpy(tempDataBuf, preTempDataBuf, preRawLen); + rawLen = preRawLen; + } + + /*IOCI֡*/ + (void)ParseIoToCiDataFrame(tempDataBuf, (UINT16)rawLen); + + return CI_SUCCESS; + + +} + + +/* +* IOCI֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseIoToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength) +{ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 kk = 0u; + UINT8 currentValue = 0u; + BoardDataStruct* pColBoardStru = NULL; /*ɼݽṹ*/ + UINT16 colBoardSum = 0u; /*ɼݽṹ*/ + UINT8 boardIndex = 0u; /*ɼ*/ +#ifdef LOGPRINT + UINT8 colPData[BOARD_SUM_MAX * (BOARD_COLL_DATA_LEN + 1U)] = {0u}; /*ӡIJɼ*/ +#endif + + colBoardSum = GetColRelayStructSum();/*ɼ*/ + pColBoardStru = GetColRelayStruct();/*ɼ*/ + if ((dataBuf != NULL) && (dataLength > 0u)) + { + /*IOɼݰ*/ + for (ii = 0u; (ii < colBoardSum * (BOARD_COLL_DATA_LEN + 1u)) && (ii < dataLength); ii += (BOARD_COLL_DATA_LEN + 1u)) + { + CollBoardDataStru[boardIndex].BoardAddress = dataBuf[ii]; + + for (jj = 0u; jj < BOARD_COLL_DATA_LEN; jj++) + { + currentValue = dataBuf[ii + jj + 1u]; + + for (kk = 0u; kk < 8u; kk++) + { + if (((currentValue >> kk) & 0x01u) == 0x01u) + { + CollBoardDataStru[boardIndex].PosValueBuf[jj * 8U + kk] = RELAY_STATE_UP; + + } + else + { + + CollBoardDataStru[boardIndex].PosValueBuf[jj * 8U + kk] = RELAY_STATE_DOWN; + + } + + } + } + + boardIndex++; + } + + CollBroadStruCurSum = boardIndex; + + +#ifdef LOGPRINT + + for (ii = 0u; (ii < colBoardSum * (BOARD_COLL_DATA_LEN + 1u)) && (ii < dataLength); ii++) + { + colPData[ii] = dataBuf[ii]; + } + + /*ӡɼ*/ + if (CI_SUCCESS == RecordCollectDataLog(colPData)) + { + /*ӡɼݴ*/ + } + +#endif + + return CI_SUCCESS; + } + else + { + /*Ч*/ + return CI_ERROR; + } +} + + +/* +* IO +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 PackCiToIoData(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + QueueStruct* ciToIoDataQueue = Get2oo2CiToIoDataQueue(); + BoardDataStruct* pDrvBoardStru = NULL; /*ݽṹ*/ + UINT16 drvBoardSum = 0u; /*ݽṹ*/ + UINT8 relayDrvState = 0u; /*̵״̬*/ + UINT8 drvDataBuf[BOARD_DRV_DATA_LEN + 1U] = {0u}; /**/ + UINT16 drvData = 0u; /**/ + UINT16 relayId = 0u; /*̵ID*/ +#ifdef LOGPRINT + UINT8 drvPData[CITOIO_DATA_STRU_SUM_MAX * (BOARD_DRV_DATA_LEN + 1U)] = {0u}; /*ӡ*/ + UINT16 drvPDataLen = 0u; /*ӡݳ*/ +#endif + if (NULL != ciToIoDataQueue) + { + drvBoardSum = GetDrvRelayStructSum(); /*ȡṹ*/ + pDrvBoardStru = GetDrvRelayStruct(); /*ȡṹ ᷵NULL*/ + + debug_infor_printf((const)"Runing: PackCiToIoData, drvBoardSum = %d", drvBoardSum); + + for (ii = 0u; ii < drvBoardSum; ii++) + { + drvData = 0u;/*Ϣ*/ + + drvDataBuf[0] = pDrvBoardStru[ii].BoardAddress; + + for (jj = 0u; jj < DRV_BOARD_POSITION_MAX; jj++) + { + relayId = pDrvBoardStru[ii].RelayIdBuf[jj]; + + if ((0u != relayId) && (relayId < RELAY_SUM_MAX)) + { + relayDrvState = GetRelayDriveState(relayId); /*ȡ̵״̬*/ + + if (RELAY_STATE_DOWN == relayDrvState) + { /*̵*/ + + } + else if (RELAY_STATE_UP == relayDrvState) + { /*̵*/ + + drvData = drvData | (0x0001u << jj); + } + else + { /*̵Ч*/ + + /*̵*/ + } + } + } + + ShortToCharLE(drvData, &drvDataBuf[1]); /*UINT16ͨС˷ʽ*/ +#if 0 + if (0u == QueueWrite(BOARD_DRV_DATA_LEN + 1, drvDataBuf, ciToIoDataQueue)) + { /*дʧ*/ + + QueueClear(ciToIoDataQueue); /**/ + + debug_infor_printf((const)"Error: PackCiToIoData, QueueWrite = 0"); + + return CI_ERROR; + } +#endif +#ifdef LOGPRINT + for (jj = 0u; jj < BOARD_DRV_DATA_LEN + 1u; jj++) + { + drvPData[drvPDataLen++] = drvDataBuf[jj]; + } +#endif + + } + + (void)InnetRawIoSend(drvPData, drvPDataLen); + pDrvBoardStru = NULL;/*ָ*/ + + /*ü̵״̬*/ + ClearRelayDriveState(); + +#ifdef LOGPRINT + /*ӡ*/ + if (drvPData == NULL) + { + + } + else + { + if (CI_SUCCESS == RecordDriverDataLog(drvPData)) + { + /*ӡݴ*/ + } + } + +#endif + return CI_SUCCESS; + } + else + { + debug_infor_printf((const)"Error: PackCiToIoData, ciToIoDataQueue = NULL"); + return CI_ERROR; + } +} + + +/* +* ȡɼṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: ɼṹ鳤 +*/ +UINT8 GetCollBroadStruCurSum(void) +{ + return CollBroadStruCurSum; +} + + +/* +* ȡɼṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ɼṹָ +*/ +IoDataStruct* GetCollBoardDataStruct(void) +{ + if (CollBroadStruCurSum == 0u) + { + return NULL; + } + else + { + return CollBoardDataStru; + } +} + +/* +* IOCI֡ +* ˵ void +* ֵ void +*/ +void ResetIoToCiData(void) +{ + UINT16 ii = 0u; + UINT16 jj = 0u; + + BoardDataStruct* colBoard = GetColRelayStruct();/*ȡɼ*/ + + for (ii = 0u; ii < GetColRelayStructSum(); ii++) + { + CollBoardDataStru[ii].BoardAddress = colBoard[ii].BoardAddress; + + for (jj = 0u; jj < COL_BOARD_POSITION_MAX; jj++) + { + CollBoardDataStru[ii].PosValueBuf[jj] = RELAY_STATE_DOWN; + } + } + + CollBroadStruCurSum = (UINT8)GetColRelayStructSum();/*ɼɼһ*/ +} + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackIoData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackIoData.h new file mode 100644 index 0000000..6ce933e --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackIoData.h @@ -0,0 +1,122 @@ +/******************************************************** +* +* ParsePackIoData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* IOݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_IO_DATA_H_ +#define _PARSE_PACK_IO_DATA_H_ + + +#include "ParsePackDefine.h" +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "Convert.h" +#include "../Route/RouteConfigDataManage.h" +#include "../Route/RouteDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Relay/RelayDefine.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../psd/PSDConfigDataManage.h" +#include "../psd/PSDDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" + +#ifdef LOGPRINT +#include "../LogRecord/LogRecord.h" +#endif + + + + + + +/*IOݽṹ*/ +typedef struct S_IoDataStruct +{ + UINT8 BoardAddress; /*ӵַ*/ + UINT8 PosValueBuf[BOARD_POS_MAX]; /*Ӹλ*/ +} IoDataStruct; + + +/**/ +extern IoDataStruct CollBoardDataStru[BOARD_SUM_MAX]; /*IOCI֡ṹ*/ +extern UINT8 CollBroadStruCurSum; + +extern UINT32 preRawLen; +extern UINT8 preTempDataBuf[BOARD_SUM_MAX * (BOARD_COLL_DATA_LEN + 1U)]; + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +* IO +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseIoToCiData(void); + +/* +* IOCI֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseIoToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength); + +/* +* IO +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 PackCiToIoData(void); + +/* +* ȡɼṹ鳤 +* ˵ void +* ֵ 0: ȡʧ +* >0: ɼṹ鳤 +*/ +UINT8 GetCollBroadStruCurSum(void); + +/* +* ȡɼṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ɼṹָ +*/ +IoDataStruct* GetCollBoardDataStruct(void); + +/* +* IOCI֡ +* ˵ void +* ֵ void +*/ +void ResetIoToCiData(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackLeuData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackLeuData.c new file mode 100644 index 0000000..9410eb8 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackLeuData.c @@ -0,0 +1,318 @@ +/******************************************************** +* +* ParsePackLeuData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* Leuݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + + +#include "ParsePackLeuData.h" + + + +UINT8 LeuData[LEU_TO_CI_DATA_LEN_MAX] = {0u}; /*Leu*/ +UINT16 LeuDataSum; /*Leuݳ*/ +UINT8 leuToCiSum = 0u;/*ͨŵLEUĿ*/ +UINT8 leuFaultFlag = 1u;/*LEUϱ־1޹ϣ0*/ +LeuToCiDataStruct LeuToCiDataStru[LEU_TO_CI_SUM_MAX] = {0u}; + +/* +* LEU +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ void +*/ +void SaveLeuToCiData(const UINT8* dataBuf, const UINT16 dataLength) +{ + UINT16 ii = 0u; + + if ((dataLength > 0u) && (dataBuf != NULL) && (dataLength + LeuDataSum < LEU_TO_CI_DATA_LEN_MAX)) + {/*Ч&&δ*/ + + for (ii = 0u; ii < dataLength; ii++) + { + LeuData[LeuDataSum] = dataBuf[ii]; + LeuDataSum = LeuDataSum + 1u; + } + } + else + { + /*LEUݴ */ + LeuDataSum = 0u; + } +} + +/* +* LEU֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseLeuToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLenth, const UINT8 systemId) +{ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0u; /**/ + UINT8 jj = 0u; + UINT8 kk = 0U; + UINT8 leuIndex = 0U; + UINT8 leuNum = 0U; + UINT8 localCiId = 0u; /*CI ID*/ + UINT32 curCycleNo = 0u; /*ǰں*/ + + leuNum = Get2oo2CiAndOtherSysCommNum(CI_SYSTEM_TYPE_LEU); /*CIͨLEU*/ + localCiId = GetSystemParaLocalCiId(); + curCycleNo = Get2oo2CurCycleNum(); + + if (NULL == dataBuf) + { + ; + } + else + { + if (leuNum < leuToCiSum) + { + debug_infor_printf((const)"LeuToCiSumError,leuNum= %d ,leuToCiSum=%d/n", leuNum, leuToCiSum); + } + else + { + ii++; /*ֽ*/ + retVal = CI_SUCCESS; + for (kk = 0U; kk < leuToCiSum; kk++) + { + if (LeuToCiDataStru[kk].idInfo[2] == dataBuf[ii]) + { + leuIndex = kk; + break; + } + else + { + ;/*δҵǷѾLEU*/ + } + } + + if (kk == leuToCiSum) + { + leuIndex = leuToCiSum; + leuToCiSum++; /*LEU*/ + } + else + { + ;/*LEUǼеLEU״̬*/ + } + LeuToCiDataStru[leuIndex].idInfo[2] = dataBuf[ii];/*LEU IDȡֽڵÿCIĵڼLEUΪID */ + + ii += 3U; /*LEU IDʾ3ֽеĵֽCI+·*/ + LeuToCiDataStru[leuIndex].allState = dataBuf[ii++];/*LEU״̬*/ + + LeuToCiDataStru[leuIndex].leuType = dataBuf[ii++];/*LEU*/ + LeuToCiDataStru[leuIndex].toQianjiComState = dataBuf[ii++];/*ǰͨ״̬*/ + ii++; /*弶״̬*/ + for (jj = 0u; jj < 4u; jj++) + {/*LEU1234״̬4ֽ*/ + LeuToCiDataStru[leuIndex].outState[jj] = dataBuf[ii++]; + } + for (jj = 0u; jj < 12u; jj++) + {/*λϢ12ֽ*/ + LeuToCiDataStru[leuIndex].maskInfo[jj] = dataBuf[ii++]; + } + + if (ii > dataLenth) + { + retVal = CI_ERROR; + } + else + { + + } + } + + if (CI_SUCCESS == retVal) + { + (void)SetCiTransmitRecvDataCycNum(localCiId, CI_SYSTEM_TYPE_LEU, systemId, curCycleNo); /*յLEUϢںţͨں*/ + LeuToCiDataStru[leuIndex].errorToAtsFlag = LEU_TO_ATS_ERRORFLAG_YES; /*յLEUݣϱATS*/ + } + } + return retVal; +} + +/* +* LEU +* ˵ UINT8 deviceId, Ŀ豸ID +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToLeuData(UINT8 deviceId) +{ + UINT8 localCi = GetSystemParaLocalCiId(); /*ID*/ + UINT8 CiToLeuDataBuffer[CI_TO_LEU_DATA_LEN_MAX+5U] = {0u};/*CILEU֡ CI_TO_LEU_DATA_LEN_MAXΪӦݶҪ*/ + UINT16 SendMaskSum = 0u; + UINT16 ii = 0u; + UINT16 row = 0u; + UINT16 kk = 0u; + UINT16 index = 0u; /*ֽ*/ + UINT16 maskid = 0u; /*ʾλID*/ + UINT8 currentValue = 0u; /*ǰλ*/ + UINT16 divNum = 0u; /**/ + UINT16 remNum = 0u; /**/ + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + + /*ȡҪ͵λֽ*/ + if (GetSendMaskSum(CI_SYSTEM_TYPE_LEU) % 8u == 0u) + { + SendMaskSum = (UINT16) (GetSendMaskSum(CI_SYSTEM_TYPE_LEU) / 8u); + } + else + { + SendMaskSum = (UINT16) (GetSendMaskSum(CI_SYSTEM_TYPE_LEU) / 8u + 1u); + } + + if ((SendMaskSum == 0u) || (SendMaskSum > CI_TO_LEU_DATA_LEN_MAX/2u)) + {/*Ӧݻݳ򷵻*/ + return CI_ERROR; + } + + /*λϢ*/ + (void)MaskPack(CI_SYSTEM_TYPE_LEU,&CiToLeuDataBuffer[ii]); + ii = (UINT16) (ii + SendMaskSum); + + /*븴ʾλ*/ + for (row = (UINT16) (ii - SendMaskSum); row < ii; row++) + { + currentValue = CiToLeuDataBuffer[row]; + for (kk = 0u; kk < 8u; kk++) + { + maskid = index * 8u + GetSendMaskSum(CI_SYSTEM_TYPE_LEU) + kk + 1u;/*ʾλID*/ + if ((maskid > GetSendMaskSum(CI_SYSTEM_TYPE_LEU)) && (maskid <= GetSendMaskSum(CI_SYSTEM_TYPE_LEU) * 2u)) + { + /*ɾ 5ƫ*/ + divNum = (UINT16) ((maskid / 8u)); + remNum = (UINT16) (maskid % 8u); + + if (((currentValue >> (7u - kk)) & 0x01u) == 0x01u) + { + /*1*/ + if (0u == remNum) + { + CiToLeuDataBuffer[divNum - 1U] = (UINT8)(CiToLeuDataBuffer[divNum - 1U] | 0x01u);/*divNumֻ0-7ȡֵ*/ + } + else + { + CiToLeuDataBuffer[divNum] = (UINT8)(CiToLeuDataBuffer[divNum] | (0x80u >> (remNum - 1U))); + } + + } + else + { + } + } + else + { + continue; + } + } + index++; + } + + ii = CI_TO_LEU_DATA_LEN_MAX; + + dstDevId = ((UINT16)(CI_SYSTEM_TYPE_LEU << 8) | ((UINT16)deviceId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &CiToLeuDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nLEU_SEND:%d", ii); + debug_out_array(0xAA, CiToLeuDataBuffer, ii); +#endif/*ƽ̨ӡ*/ +#endif + return CI_SUCCESS; + } + else + { + return CI_ERROR; + } + + +} + +/* +* LEU +* ˵ void +* ֵ void +*/ +void ClearLeuToCiData(void) +{ + UINT16 ii = 0u; + + for (ii = 0u; ii < LeuDataSum; ii++) + { + LeuData[ii] = 0u; + } + LeuDataSum = 0u; +} + +/* +* ȡLEUݳ +* ˵ void +* ֵ ݳ +*/ +UINT16 GetLeuDataLen(void) +{ + return LeuDataSum; +} + +/* +* ȡLEU +* ˵ void +* ֵ +*/ +UINT8* GetLeuData(void) +{ + return LeuData; +} + +/* +* ȡCIͨŵLEUĿ +* ˵ void +* ֵ CIͨŵLEUĿ +*/ +UINT16 GetLeuToCiSum(void) +{ + return leuToCiSum; +} + +/* +* ȡLEUCIͨݽṹ +* ˵ void +* ֵ LEUCIͨݽṹָ +*/ +LeuToCiDataStruct* GetLeuToCiDataStru(void) +{ + return LeuToCiDataStru; +} + +/* +* ͨŵLEUı־ +* ˵ void +* ֵ +*/ +void ClearAllErrorFlag(void) +{ + UINT16 leuSum = GetLeuToCiSum();/*CIͨŵLEUĿ*/ + UINT16 ii = 0U; + + for (ii = 0U; ii < leuSum; ii++) + { + LeuToCiDataStru[ii].errorToAtsFlag = LEU_TO_ATS_ERRORFLAG_NO; + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackLeuData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackLeuData.h new file mode 100644 index 0000000..ef9124b --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackLeuData.h @@ -0,0 +1,127 @@ +/******************************************************** +* +* ParsePackLeuData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* Leuݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_LEU_DATA_H_ +#define _PARSE_PACK_LEU_DATA_H_ + + +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../DataManage/DeviceDataManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/*ͨŵLEUϢ*/ +typedef struct S_LeuToCiDataStruct +{ + UINT8 reservedByte;/*ֽ*/ + UINT8 idInfo[3U];/*IDʾϢidInfo[0]δ֪idInfo[1]LEU豸ͣidInfo[2]LEU ID*/ + UINT8 allState;/*״̬*/ + UINT8 leuType;/*LEUͣ02͸䣬03͸*/ + UINT8 toQianjiComState;/*ǰͨ״̬*/ + UINT8 boardState;/*弶״̬*/ + UINT8 outState[4U];/*״̬1-4*/ + UINT8 maskInfo[12U];/*λϢ12ֽ*/ + UINT8 errorToAtsFlag; /*ATS͹ϱı־*/ +} LeuToCiDataStruct; + +/*******************************ȫֱ*******************************/ +extern UINT8 LeuData[LEU_TO_CI_DATA_LEN_MAX]; +extern UINT16 LeuDataSum; +extern UINT8 leuToCiSum; +extern UINT8 leuFaultFlag; +extern LeuToCiDataStruct LeuToCiDataStru[LEU_TO_CI_SUM_MAX]; + + +/* +* LEU +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ void +*/ +void SaveLeuToCiData(const UINT8* dataBuf, const UINT16 dataLength); + +/* +* LEU +* ˵ UINT8 deviceId, Ŀ豸ID +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToLeuData(UINT8 deviceId); + +/* +* LEU +* ˵ void +* ֵ void +*/ +void ClearLeuToCiData(void); + +/* +* ȡLEUݳ +* ˵ void +* ֵ ݳ +*/ +UINT16 GetLeuDataLen(void); + +/* +* ȡLEU +* ˵ void +* ֵ +*/ +UINT8* GetLeuData(void); + + +/* +* LEU֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseLeuToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLenth, const UINT8 systemId); + +/* +* ȡCIͨŵLEUĿ +* ˵ void +* ֵ CIͨŵLEUĿ +*/ +UINT16 GetLeuToCiSum(void); + +/* +* ȡLEUCIͨݽṹ +* ˵ void +* ֵ LEUCIͨݽṹָ +*/ +LeuToCiDataStruct* GetLeuToCiDataStru(void); + +/* +* ͨŵLEUı־ +* ˵ void +* ֵ +*/ +void ClearAllErrorFlag(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackManage.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackManage.c new file mode 100644 index 0000000..828e6b0 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackManage.c @@ -0,0 +1,1164 @@ +/******************************************************** +* +* ParsePackManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-09-12 +* ߣ +* ͨݽ +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackManage.h" +#include "../DataManage/DeviceConfigDataManage.h" +#include "ParsePackOcData.h" +#include "ParsePackAxleData.h" +#include "FsfbProtcl.h" +#include "ParsePackTmcData.h" +#include "ParsePackGateWayData.h" +#include "../Deployment/DeploymentExtern.h" +#include "ParsePackCommon.h" +#define TMP_BUF_LEN 10000 + + + + +/* +* +* ˵ void +* ֵ void +*/ +void ParseInputData(void) +{ + UINT8 LocalCiPattern = 0u; + UINT8 ParseIoToCiData_ret = 0u; + UINT8 ParseOtherResult = CI_ERROR; + UINT8 ParseInnetResult = CI_ERROR; + UINT8 ParsePlatResult = CI_ERROR; + LocalCiPattern = GetLocalCiPattern(); + + if (CI_PATTERN_TRADITIONAL == LocalCiPattern) + {/*ͳģʽŽIO*/ + /*IO*/ + ParseIoToCiData_ret = ParseIoToCiData(); + if (0u == ParseIoToCiData_ret) + {/*ʧ*/ + + /*Ϊȫֵ*/ + } + else + { + /*޲*/ + } + } + else if (CI_PATTERN_FULL_ELECTRONIC == LocalCiPattern)/*ʱãЭOC*/ + { + + + } + else + { + /*޲*/ + } + + /*SFP*/ + ParseOtherResult = ParseOtherSysToCiData(); + if (0u == ParseOtherResult) + {/*ʧ*/ + + /*ڲѾΪȫֵ*/ + } + else + { + /*ɹ*/ + } + /**/ + ParseInnetResult = ParseINNETToCiData(); + if (0u == ParseInnetResult) + {/*ʧ*/ + + /*ڲѾΪȫֵ*/ + } + else + { + /*ɹ*/ + } + /*ƽ̨豸*/ + ParsePlatResult=ParasePlatToRCIData(); + if (0u == ParsePlatResult) + {/*ʧ*/ + + /*ڲѾΪȫֵ*/ + } + else + { + /*ɹ*/ + } +} + +/* +* oc id +* ˵ +* UINT16 ocId +* ֵ void +*/ +void InsertOcId(UINT16 ocId) +{ + UINT16 i = 0U; + UINT8 flagFind = 0u; + for (i = 0U; i < OC_SUM_MAX; i++) + { + if (LocalOcIds[i] == ocId) + { + flagFind = 1u; + break; + } + } + if (0u == flagFind) + { + for (i = 0U; i < OC_SUM_MAX; i++) + { + if (0u == LocalOcIds[i]) + { + LocalOcIds[i] = ocId; + break; + } + } + } +} + +/* +* +* ˵ void +* ֵ void +*/ +void PackOutputData(void) +{ + QueueStruct* dataSendQueue = NULL; /*ȡ*/ + UINT8 deviceSum = 0u; /*豸*/ + UINT8* deviceIdBuf = NULL; /*豸ID*/ + UINT32 flyTag = GetFlyProtectOverCyc(); + UINT8 ciPatten = GetLocalCiPattern(); + + /*ͳ δ崻*/ + if ((0U == flyTag) && (CI_PATTERN_TRADITIONAL == ciPatten)) + { + /*IO*/ + (void)PackCiToIoData(); + } + else + { + + } + + /*SFP*/ + if (CI_ERROR == PackCiToOtherSysData()) + { + /*ʧ*/ + } + +#ifdef LOGPRINT + + /*¼豸״̬*/ + (void)RecordDeviceDataLog(CI_SUCCESS); + +#endif +} + + + +/* +* ϵͳ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseOtherSysToCiData(void) +{ + QueueStruct* otherSysToCiDataQueue = NULL; /*ͨЭ*/ + UINT32 dataQueueTotalLen = 0u; /*ܳ*/ + UINT8 dataLenBuf[2] = { 0u }; /*ݳ*/ + UINT16 appDataLen = 0u; /*һ֡ݳ*/ + UINT8 tempBuf[7] = { 0u }; /*ʱ*/ + + UINT8 tempDataBuf[10000] = { 0u }; /*ʱ*/ + UINT8 sameLineCi = SAME_LINE_ERR;/*ǷͷCIͽշCIǷͬһ·CI*/ + UINT16 logId = 0u;/*߼ID4IP VOBC޸,ֻڽͨVOBCʱЧ*/ + UINT8 oc2ciParseResult = CI_ERROR;/*occi*/ + UINT8 checkResult = 0u; + UINT8 startLockFlag = 0u; + + UINT8 ocId = 0u; + UINT8 chLocalCiId = 0u; + UINT8 appRecvRtn = 0u; + UINT16 srcDevTypeId = 0u; + UINT16 srcDevLogicId = 0u; + UINT8 data[TMP_BUF_LEN] = { 0u }; + + UINT32 dataLen = 0u; + UINT8 devType = 0u; + UINT8 devId = 0u; + UINT8 ocInCiId = 0u; + UINT8 locCiId = 0u; + UINT32 curSysCount = 0u; /*ǰϵͳ*/ + UINT8 srcDevTypeIdBuff[2] = { 0 }; /*Դ豸ID*/ + UINT8 srcLogicIdBuff[2] = { 0 }; /*Դ߼ID*/ + UINT8 isBreak = 0u; /*˳*/ + UINT16 wTiocRcvAtsGtwyDevTypeId = 0U; + UINT8 errorNO_Type = 0u; /*CIӿУݹ*/ + + curSysCount = MSCP_GetSysCount(); + wTiocRcvAtsGtwyDevTypeId = GetTiocTrnsmtGtwyDevTypeId(); + + while (1) + { /*ȡвΪ*/ + /*ȡܳ*/ + appRecvRtn = OutnetSafeRecv(&srcDevTypeId, &srcDevLogicId, data, &dataLen, (UINT32)sizeof(data)); + if ((1U == appRecvRtn) && (0U < dataLen)) //ճɹ + { + devType = (UINT8)((srcDevTypeId >> 8u) & 0xFFu);/*ȡ豸*/ + devId = (UINT8)(srcDevTypeId & 0xFFu); + switch (devType) /*豸ʹ*/ + { +#if USE_PROTOCOL_RSSP + + + case CI_SYSTEM_TYPE_OC: + { +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nOC_RECV:%d OcId:%d", dataLen, devId); + debug_out_array(0xAA, data, (UINT16)dataLen); + debug_out_array(0x11, data, (UINT16)dataLen); +#endif/*ƽ̨ӡ*/ +#endif/*־ӡ*/ + ocId = (UINT8)GetCiIdByOcId(devId); + chLocalCiId = GetSystemParaLocalCiId(); + if (ocId == chLocalCiId)/*oc idci idΪid*/ + { + oc2ciParseResult = ParseOcToCiDataFrame(data, (UINT16)dataLen, devId); + if (CI_ERROR == oc2ciParseResult) + { + /*OCݴѾ10ڣͨжϣȫ*/ + } + else if (CI_CHECK_LEN_ERROR == oc2ciParseResult) + { + /*УѴOCԭʼ豸״̬ȫ*/ + /* Уʧܴ + * 1. ڣOCԭʼݻ豸״̬״̬DI忨״̬DO忨״̬ðȫ̬ + * 2. ΪCIOCͨڲ£CI OCͨжҲͨжϣ豸״̬ȫ + */ + ResetOcOriginalState(devId); + ConvertOcOriginDataToPtData();/*ѽOC忨תΪOCλ*/ + ConvertOcOriginDataToOcSigSwDev();/*ѽOC豸תΪOC źŻ OC 豸ݺOC*/ + debug_infor_printf((const)"OC Id %d len check ERROR.", devId); + } + else if (CI_SUCCESS == oc2ciParseResult) + {/*ɹתOC忨*/ + ConvertOcOriginDataToPtData();/*ѽOC忨תΪOCλ*/ + ConvertOcOriginDataToOcSigSwDev();/*ѽOC豸תΪOC źŻ OC 豸ݺOC*/ + debug_infor_printf((const)"\nconvert succeed\n"); + } + else + { + /*ֵʲôҲ*/ + } + } + else + { + } + + break; + } +#endif + case CI_SYSTEM_TYPE_ATS: + /*ATS*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + +#endif/*ƽ̨ӡ*/ + +#endif + if (wTiocRcvAtsGtwyDevTypeId != srcDevTypeId) + { + + debug_infor_printf((const)"\nATS_RECV:%d", dataLen); + checkResult = ParseAtsOrXianDiToCiDataFrame(data, (UINT16)dataLen); + (void)DarkInfoPack(CIM_INFO_ATS_TO_RCI_DATA, data, (UINT16)dataLen); + } + else + { + + debug_infor_printf((const)"\nGATEWAY_RECV:%d", dataLen); + checkResult = ParseGateWayToCiDataFrame(data, (UINT16)dataLen); + } + debug_out_array(0xAA, data, (UINT16)dataLen); + if (CI_ERROR == checkResult) + {/*ʧ*/ + + debug_infor_printf((const)"parse ats id %d error.", devId); + } + else + { + } + break; + case CI_SYSTEM_TYPE_XIANDI: + /*ֵ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nXIANDI_RECV:%d", dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + debug_out_array(0x11, data, (UINT16)dataLen); +#endif/*ƽ̨ӡ*/ + +#endif + checkResult = ParseAtsOrXianDiToCiDataFrame(data, (UINT16)dataLen); + + (void)DarkInfoPack(CIM_INFO_ATS_TO_RCI_DATA, data, (UINT16)dataLen); + if (CI_ERROR == checkResult) + { + debug_infor_printf((const)"parse xiandi id %d error.", devId); + } + else + { + } + break; + case CI_SYSTEM_TYPE_CI: + /*CI*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nCI_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); +#endif/*ƽ̨ӡ*/ + +#endif + /*жǷͬһ·ͬ·ʹûͨӿڣͬһ·ʹԼӿ*/ + sameLineCi = IsSameLineCI(devId, GetSystemParaLocalCiId()); + if (SAME_LINE_YES == sameLineCi) /*ͬ*/ + { + startLockFlag = GetStartLockFlag(); + if (CI_START_LOCK_NO == startLockFlag) + { + checkResult = ParseCiToCiDataCheck(data, (UINT16)dataLen, &errorNO_Type); /*CIݴУ*/ + if (CI_SUCCESS != checkResult) + { + debug_infor_printf((const)"check parse ci step %d error", errorNO_Type); + } + else + { + checkResult = ParseCiToCiDataFrame(data, (UINT16)dataLen); + if (CI_SUCCESS != checkResult) /**/ + { + debug_infor_printf((const)"parse ci id %d error", devId); + } + else + { + + } + } + } + else + { + } + } + else if (SAME_LINE_NO == sameLineCi) /*ͬ*/ + { + checkResult = ParseCiToCiDataFrameHLHT(data, (UINT16)dataLen, devId); + if (CI_ERROR == checkResult) /**/ + { + debug_infor_printf((const)"parse hlht ci id %d error", devId); + } + else + { + } + } + else + { + debug_infor_printf((const)"ci id %d sameLineCi:%d error", devId, sameLineCi); + } + + break; + + case CI_SYSTEM_TYPE_ZC: + debug_infor_printf((const)"\nZC_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + + checkResult = ParseZcToCiDataFrame(data, (UINT16)dataLen, devId); + if (CI_ERROR == checkResult) /**/ + { + ClearZcData();/*ZC*/ + debug_infor_printf((const)"parse zc id %d error", devId); + } + else + { + } + + break; + + case CI_SYSTEM_TYPE_TMC:/* TMC */ + debug_infor_printf((const)"\nTMC_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + + checkResult = ParseTmcToTiocDataFrame(data, (UINT16)dataLen, devId); + if (CI_ERROR == checkResult) /**/ + { + debug_infor_printf((const)"parse tmc id %d error", devId); + } + else + { + } + + break; + case CI_SYSTEM_TYPE_VOBC: /*VOBC*/ + debug_infor_printf((const)"\nVOBC_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + + checkResult = ParseVobcToCiDataFrame(data, (UINT16)dataLen, devId, srcDevLogicId); + if (CI_ERROR == checkResult) /**/ + { + debug_infor_printf((const)"parse vobc id %d,logic id %d error", devId, srcDevLogicId); + } + else + { + } + + break; + case CI_SYSTEM_TYPE_VOBC_BACKUP: /*VOBCͨ*/ + debug_infor_printf((const)"\nVOBC_BACKUP_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + + checkResult = ParseVobcBackUpToCiDataFrame(data, (UINT16)dataLen, devId, srcDevLogicId); + if (CI_ERROR == checkResult) /**/ + { + debug_infor_printf((const)"parse vobc_backup id %d,logic id %d error", devId, srcDevLogicId); + } + else + { + } + + break; + case CI_SYSTEM_TYPE_ITE: + debug_infor_printf((const)"\nITE_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + + checkResult = ParseIteToCiData(data, (UINT16)dataLen, devId, srcDevLogicId); /*ITE*/ + if (CI_ERROR == checkResult) + { + debug_infor_printf((const)"parse ite id %d,logic id %d error", devId, srcDevLogicId); /*󣬼¼־*/ + } + else + { + /**/ + } + break; + case CI_SYSTEM_TYPE_PLATFORM: /*PSD*/ + debug_infor_printf((const)"\nPSD_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + + checkResult = ParsePlatformToCiDataFrame(data, (UINT16)dataLen, devId); + if (CI_ERROR == checkResult) /**/ + { + debug_infor_printf((const)"parse psd id %d error", devId); + } + else + { + } + + break; + case CI_SYSTEM_TYPE_AXIS: /**/ + debug_infor_printf((const)"\nAXIS_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + + checkResult = ParseAxisToCiDataFrame(data, (UINT16)dataLen, devId); + if (CI_ERROR == checkResult) /**/ + { + debug_infor_printf((const)"parse axis id %d error", devId); + } + else + { + } + + break; + case CI_SYSTEM_TYPE_PSC: /*PSC*/ + debug_infor_printf((const)"\nPSC_RECV:%d", (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); + + checkResult = ParsePscToCiDataFrame(data, (UINT16)dataLen, devId); + if (CI_ERROR == checkResult) /**/ + { + debug_infor_printf((const)"parse psc id %d error", devId); + } + else + { + } + + break; + case CI_SYSTEM_TYPE_LEU: + /*LEU*/ + SaveLeuToCiData(data, (UINT16)dataLen); + +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nLEU%d_RECV:%d", devId, (UINT16)dataLen); + debug_out_array(0xAA, data, (UINT16)dataLen); +#endif/*ƽ̨ӡ*/ +#endif + checkResult = ParseLeuToCiDataFrame(data + 6, (UINT16)dataLen, devId); + if (CI_ERROR == checkResult) + { + debug_infor_printf((const)"parse leu id %d error", devId); + } + else + { + } + + break; + default: /*Ƿ*/ + break; + } + + } + else + { + break; + } + } + + return CI_SUCCESS; +} + + +/* +* +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseINNETToCiData(void) +{ + UINT8 funcRet = 0u; + UINT16 srcDevTypeId = 0u; + UINT16 srcDevLogicId = 0u; + UINT8 data[TMP_BUF_LEN] = { 0u }; + UINT32 dataLen = 0u; + UINT8 devType = 0u; + UINT8 devId = 0u; + UINT8 parseResult = CI_ERROR; /*Ƿɹ*/ + while (1) + { + /*ȡвΪ*/ + funcRet = InnetSafeRecv(&srcDevTypeId, &srcDevLogicId, data, &dataLen, (UINT32)sizeof(data)); + if ((1U == funcRet) && (0U < dataLen) && (0u != srcDevTypeId)) //ճɹ + { + devType = (UINT8)((srcDevTypeId >> 8u) & 0xFFu);/*豸*/ + devId = (UINT8)(srcDevTypeId & 0xFFu);/*豸ID*/ + + /*豸ʹ*/ + switch (devType) + { +#if USE_PROTOCOL_RSSP + + + case DEVTYPE_AIM: + { +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nAIM_RECV:%d OcId:%d", dataLen, devId); + debug_out_array(0xAA, data, (UINT16)dataLen); +#endif/*ƽ̨ӡ*/ +#endif/*־ӡ*/ + + parseResult = Deploy_ParseAIMInputInfo(data, (UINT16)dataLen, devType, devId); + if (CI_SUCCESS == parseResult) + { + /*ɹ*/ + } + else + { + debug_infor_printf((const)"4.3 AID %04x Input Error!\n", srcDevTypeId); + } + break; + } +#endif + + default: /*Ƿ*/ + break; + } + } + else + { + break; + } + } + + return CI_SUCCESS; +} + + + + +/* +* 鷢͵ϵͳ +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 PackCiToOtherSysData(void) +{ + UINT8 deviceSum = 0u; /*豸*/ + UINT8* deviceIdBuf = NULL; /*豸ID*/ + UINT8 ii = 0u; + UINT8 comCycNumForCiToOtherSys = 0u; + UINT8 reVal = 0u; + UINT8 IsSameLine = 0u; + + UINT32 fsfbDataLen = 0u; /*fsfbݳ*/ + UINT32 fsfbDataIdx = 0u; /*fsfbݵǰλ*/ + UINT16 fsfbFramLen = 0u; /*fsfb֡*/ + UINT16 dstTypeId = 0u; /*ĿID*/ + UINT32 curSysCount = 0u; /*ǰϵͳ*/ + UINT32 fsfbOutQueLen = 0u; /*fsfbг*/ + UINT8 fsfbOutQueData[2048] = { 0 }; /*fsfb*/ + UINT32 fsfbOutQueIdx = 0u; /*fsfbλ*/ + UINT16 fsfbOutQueFramLen = 0u; /*fsfb֡*/ + UINT8 fsfbBtmHead[5] = { 0 }; /*fsfb btm֡ͷ*/ + + UINT8 chTiocRcvAtsGtwyDevTypeId = 0U; + unsigned long long cost[20] = { 0U }; + UINT32 dwFlyProtectOverCyc = GetFlyProtectOverCyc(); + + chTiocRcvAtsGtwyDevTypeId = (UINT8)GetTiocTrnsmtGtwyDevTypeId(); + curSysCount = MSCP_GetSysCount(); + + cost[0] = MSCP_GetTick(); + + if(0U == dwFlyProtectOverCyc) + { + /*****ֵ*****/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_XIANDI); /*ȡֵͨ豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_XIANDI); /*ȡֵͨ豸ID*/ + + if ((0u < deviceSum) && (NULL != deviceIdBuf)) + { /*ͨ豸ȷ*/ + + /*ͨǷͨҪ,ͨΪ0ʱԽͨ*/ + comCycNumForCiToOtherSys = GetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_XIANDI); + if (0u == comCycNumForCiToOtherSys) + { + for (ii = 0u; ii < deviceSum; ii++) + { + /*ֵվ֡*/ + reVal = PackCiToAtsOrXianDiData(deviceIdBuf[ii], CI_SYSTEM_TYPE_XIANDI, CI_ATS_STATION_FRAME); + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; + } + } + + SetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_XIANDI, COM_CYCNUM_CI_TO_XIANDI);/*ֵͨ*/ + } + else + { + for (ii = 0u; ii < deviceSum; ii++) + { + /*ֵ豸֡*/ + reVal = PackCiToAtsOrXianDiData(deviceIdBuf[ii], CI_SYSTEM_TYPE_XIANDI, CI_ATS_DEVICE_STATE_FRAME); + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; + } + } + SetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_XIANDI, (UINT8)(comCycNumForCiToOtherSys - 1U));/*ֵͨż¼ֵ1*/ + } + + } + + /*****ATS*****/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_ATS); /*ȡͨATS豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ATS); /*ȡͨATS豸ID*/ + + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + { /*ͨ豸ȷ*/ + + /*ͨǷͨҪ,ͨΪ0ʱԽͨ*/ + comCycNumForCiToOtherSys = GetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_ATS); + for (ii = 0u; ii < deviceSum; ii++) + { + if (chTiocRcvAtsGtwyDevTypeId != deviceIdBuf[ii]) + { + if (0u == comCycNumForCiToOtherSys) + { + + /*ATSվ֡*/ + reVal = PackCiToAtsOrXianDiData(deviceIdBuf[ii], CI_SYSTEM_TYPE_ATS, CI_ATS_STATION_FRAME); + + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; /*DO NOTHING*/ + } + SetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_ATS, COM_CYCNUM_CI_TO_ATS);/*ֵͨ*/ + } + else + { + /*ATS豸֡*/ + reVal = PackCiToAtsOrXianDiData(deviceIdBuf[ii], CI_SYSTEM_TYPE_ATS, CI_ATS_DEVICE_STATE_FRAME); + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; /*DO NOTHING*/ + } + SetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_ATS, (UINT8)(comCycNumForCiToOtherSys - 1U));/*ֵͨż¼ֵ1*/ + } + } + else + { + ; /*do nothing*/ + } + } + if (0u == comCycNumForCiToOtherSys) + { + ClearCiSendCmdData();/*ɺCIֵ/ATS*/ + } + else + { + /* DO NOTHING*/ + } + } + else if (deviceSum == 0u) + { + comCycNumForCiToOtherSys = GetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_ATS); + if (0U == comCycNumForCiToOtherSys) + { + + SetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_ATS, COM_CYCNUM_CI_TO_ATS);/*ֵͨ*/ + + ClearCiSendCmdData();/*ɺCIֵ/ATS*/ + } + else + { + SetComCycNumForCiToOtherSys(CI_SYSTEM_TYPE_ATS, (UINT8)(comCycNumForCiToOtherSys - 1U));/*ֵͨż¼ֵ1*/ + } + } + else + { + /*ʲô*/ + } + } + + /*******ATS*********/ + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_ATS); /*ȡͨATS豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ATS); /*ȡͨATS豸ID*/ + + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + { /*ͨ豸ȷ*/ + for (ii = 0u; ii < deviceSum; ii++) + { + if (chTiocRcvAtsGtwyDevTypeId == deviceIdBuf[ii]) + { + /*ATSվ֡*/ + reVal = PackTiocToGateWayData(deviceIdBuf[ii], CI_SYSTEM_TYPE_ATS); + + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; /*DO NOTHING*/ + } + } + else + { + ; /*do nothing*/ + } + } + + } + else + { + /*ʲô*/ + } + + cost[1] = MSCP_GetTick(); + if(0U == dwFlyProtectOverCyc) + { + /*****ZC*****/ + deviceSum = 0u; + deviceIdBuf = NULL; + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_ZC); /*ȡͨZC豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC); /*ȡͨZC豸ID*/ + + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + { /*ͨ豸ȷ*/ + + for (ii = 0u; ii < deviceSum; ii++) + { + /*ZC*/ + reVal = PackCiToZcData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; + } + } + } + else + { + ; /*do nothing*/ + } + + + /*****TMC*****/ + deviceSum = 0u; + deviceIdBuf = NULL; + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_TMC); /*ȡͨTMC豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_TMC); /*ȡͨTMC豸ID*/ + + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + { /*ͨ豸ȷ*/ + + for (ii = 0u; ii < deviceSum; ii++) + { + /*TMC*/ + reVal = PackTiocToTmcData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; + } + } + } + else + { + ; /*do nothing*/ + } + + /*****CI*****/ + deviceSum = 0u; + deviceIdBuf = NULL; + deviceSum = GetCiTransmitSpecifySysDevSum(Get2oo2SheBeiType()); /*ȡͨCI豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(Get2oo2SheBeiType()); /*ȡͨCI豸ID*/ + + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + { /*ͨ豸ȷ*/ + + for (ii = 0u; ii < deviceSum; ii++) + { + + IsSameLine = IsSameLineCI(GetSystemParaLocalCiId(), deviceIdBuf[ii]); + + if (SAME_LINE_YES == IsSameLine) + { + /*CI*/ + reVal = PackCiToCiData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; + } + } + else if (SAME_LINE_NO == IsSameLine) + { + /*CI*/ + reVal = PackHLHTCiToCiData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + } + else + { + ; + } + } + else + { + /*޲*/ + } + } + } + + + /*****LEU*****/ + deviceSum = 0u; + deviceIdBuf = NULL; + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_LEU); /*ȡͨCI豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_LEU); /*ȡͨCI豸ID*/ + + if ((deviceSum > 0u) && (deviceIdBuf != NULL)) + { /*ͨ豸ȷ*/ + + for (ii = 0u; ii < deviceSum; ii++) + { + /*LEU*/ + reVal = PackCiToLeuData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + debug_infor_printf((const)"\nLEU_PACK_ERROR:%d"); + } + } + + } + else + { + ; /*do nothing*/ + } + cost[2] = MSCP_GetTick(); + /*****VOBC*****/ + + /*VOBC*/ + reVal = PackCiToVobcData(); + if (CI_ERROR == reVal) + { + /**/ + + } + cost[3] = MSCP_GetTick(); + /*VOBCͨ*/ + (void)PackCiToVobcBackUpData(); + if (CI_ERROR == reVal) + { + /**/ + + } + + /*ITE*/ + reVal = PackCiToIteData(); + if (CI_ERROR == reVal) + { + /**/ + + } + + /*****PSD******/ + deviceSum = 0u; + deviceIdBuf = NULL; + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PLATFORM); /*ȡͨPSD豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PLATFORM); /*ȡͨPSD豸ID*/ + + if ((0u < deviceSum) && (NULL != deviceIdBuf)) + { /*ͨ豸ȷ*/ + + for (ii = 0u; ii < deviceSum; ii++) + { + /*PSD*/ + reVal = PackCiToPlatformData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + + } + else + { + ; /*do nothing*/ + } + } + } + else + { + ; /*do nothing*/ + } + + /*****Axis*****/ + + deviceSum = 0u; + deviceIdBuf = NULL; + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_AXIS); /*ȡͨAxis豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_AXIS); /*ȡͨAxis豸ID*/ + + if ((0u < deviceSum) && (NULL != deviceIdBuf)) + { /*ͨ豸ȷ*/ + + for (ii = 0u; ii < deviceSum; ii++) + { + /*Axis*/ + reVal = PackCiToAxisData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + } + } + } + else + { + ; /*do nothing*/ + } + } +#ifdef APPCI_MAINTAIN_DEBUG +#ifdef PLATFORM_2OO2 + /*cgh-ϲCID-2349-1*/ + /*͸ά豸ͨ״̬*/ + debug_infor_printf((const)"\nCIM_SEND_COMM\n"); + PackCiToCimCommData(); + /*͸άźŻ˿״̬*/ + debug_infor_printf((const)"\nCIM_SEND_DS\n"); + PackCiToCimSignalDsData(); + /*ά̵ɼһ±*/ + debug_infor_printf((const)"\nCIM_Relay_DriAndCollDiff\n"); + PackCiToCimRelayDriAndCollDiff(); + /*άű*/ + debug_infor_printf((const)"\nCIM_PSD_alarm\n"); + PackCiToCimPsdAlarmData(); + /*άʱ*/ + PackCiToCimSigDriOutTimeData(); + /*ά汾Ϣ*/ + PackCiToCimVerData(); + /*ά豸״̬Ϣ*/ + PackCiToCimDeviceData(); + /*άɳ*/ + PackCiToCimFlyProtectData(); + /*͸AIM˳ӪϢ*/ + AIMOutput(); + /*͸άִеԪϢ*/ + PackCiToCimUnitAlarmData(); + +#endif +#endif + +#if USE_PROTOCOL_RSSP/*OC*/ + /*OC*/ + cost[4] = MSCP_GetTick(); + if (0U == dwFlyProtectOverCyc) + { + deviceSum = 0u; + deviceIdBuf = NULL; + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_OC); /*ȡͨOC豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC); /*ȡͨOC豸ID*/ + + if ((0u < deviceSum) && (NULL != deviceIdBuf)) + { /*ͨ豸ȷ*/ + + for (ii = 0u; ii < deviceSum; ii++) + { + /*OC*/ + reVal = PackCiToOcData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + + } + } + + } + } +#endif + + if (0U == dwFlyProtectOverCyc) + { + /*****PSC******/ + + deviceSum = 0u; + deviceIdBuf = NULL; + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_PSC); /*ȡͨPSC豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_PSC); /*ȡͨPSC豸ID*/ + + if ((0u < deviceSum) && (NULL != deviceIdBuf)) + { /*ͨ豸ȷ*/ + + for (ii = 0u; ii < deviceSum; ii++) + { + /*PSC*/ + reVal = PackCiToPscData(deviceIdBuf[ii]); + if (CI_ERROR == reVal) + { + /**/ + + } + else + { + ; /*do nothing*/ + } + } + } + else + { + ; /*do nothing*/ + } + } + cost[5] = MSCP_GetTick(); +#ifdef APPCI_MAINTAIN_DEBUG +#ifdef PLATFORM_2OO2 + /*תLEUݸά޻*/ +#if 0 + tempDataBuf = GetLeuData(); + debug_out_array(0x10, GetLeuData(), GetLeuDataLen()); +#endif +#endif +#endif + +#ifdef APPCI_MAINTAIN_DEBUG +#ifdef PLATFORM_2OO2 +#if 0 + debug_infor_printf((const)"\nCIM_SEND_COMM\n"); + /*͸ά޻豸ͨ״̬*/ + PackCiToCimCommData(); +#endif + debug_infor_printf((const)"\nCIM_SEND_DS\n"); + /*͸ά޻źŻ˿״̬*/ + PackCiToCimSignalDsData(); + /*͸ά޻̵״̬*/ + debug_infor_printf((const)"\nCIM_SEND_HUNXIAN\n"); + PackCiToCimRelayHunXianData(); +#endif +#endif + + /*LEU*/ + ClearLeuToCiData(); + + /*cgh-ϲCID-2588-3*/ + /*IOIJɼ̵*/ + ResetRelayABCollState(); + /*ü̵״̬*/ + ClearRelayDriveState(); + cost[6] = MSCP_GetTick(); + debug_infor_printf((const)"\n Pack Ats :%dms Pack CI :%dms Pack Vobc:%dms Pack Axle:%dms Pack Oc:%dms Pack Maintain:%dms \n", (cost[1] - cost[0]) / 1000, (cost[2] - cost[1]) / 1000, (cost[3] - cost[2]) / 1000, (cost[4] - cost[3]) / 1000, (cost[5] - cost[4]) / 1000, (cost[6] - cost[5]) / 1000); + + return CI_SUCCESS; +} + +/* +* +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParasePlatToRCIData(void) +{ + UINT8 retVal = CI_ERROR; + + /*֡*/ + retVal = PlatHeartFrameProcess(); + + /*ƽ̨ͨIO*/ + PlatChannelIODataProcess(); + + + + return retVal; +} + + diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackManage.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackManage.h new file mode 100644 index 0000000..9983822 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackManage.h @@ -0,0 +1,105 @@ +/******************************************************** +* +* ParsePackManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-09-12 +* ߣ +* ͨݽ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_MANAGE_H_ +#define _PARSE_PACK_MANAGE_H_ + + + +#include "CommonTypes.h" +#include "Convert.h" +#include "./ParsePackAtsData.h" +#include "./ParsePackCiData.h" +#include "./ParsePackZcData.h" +#include "./ParsePackIoData.h" +#include "./ParsePackPSCData.h" +#include "./ParsePackLeuData.h" +#include "./ParsePackVobcData.h" +#include "./ParsePackPlatformData.h" +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../Transmit/TransmitStateDataManage.h" +#include "CbtcVersion.h" +#include "../System/SystemConfigDefine.h" +#include "MSCP_APP_API.h" +#include "../QueryFiles/dquCIInit.h" +#include "./ParsePackITEData.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +* +* ˵ void +* ֵ void +*/ +void ParseInputData(void); + +/* +* +* ˵ void +* ֵ void +*/ +void PackOutputData(void); + + +/* +* ϵͳ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseOtherSysToCiData(void); + +/* +* 鷢͵ϵͳ +* ˵ void +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 PackCiToOtherSysData(void); + +/* +* +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParseINNETToCiData(void); + +/* +* oc id +* ˵ +* UINT16 ocId +* ֵ void +*/ +void InsertOcId(UINT16 ocId); + + +/* +* +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 ParasePlatToRCIData(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackOcData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackOcData.c new file mode 100644 index 0000000..cc2ff0d --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackOcData.c @@ -0,0 +1,2356 @@ +/******************************************************** +* +* ParsePackIoData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* IOݽ +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackIoData.h" +#include "ParsePackOcData.h" +#include "./ParsePackManage.h" +#include "../HLHTMsgHead/HLHTCommonDataPacketHead.h" +#include "../HLHTMsgHead/HLHTHeadContexManage.h" + +#include "dfsDataRead.h" +#include "dquCIInit.h" + + + + +OcToCiOriginDataStruct m_OcToCiOrginDataArr[OC_SUM_MAX]; /*OCCI֡ṹ,ԭʼݡ*/ +UINT8 m_OcToCiOrginDataNum = 0u; /*OcCiݵǰ*/ + + +OcCollBoardDataStruct m_OcConvertedPtDataArr[OC_SUM_MAX];/*CIյOCɼݡתĵλݣ|¡*/ + +OcFaultStateStruct m_OcFaultState[OC_SUM_MAX];/*CIյOC״̬*/ + +OcDeviceStruct m_Signals[CI_SIGNAL_MAX];/*OCźŻ豸*/ +UINT16 m_SignalNum = 0u; + +OcDeviceStruct m_Switches[CI_SWITCH_MAX];/*OCе豸*/ +UINT16 m_SwitchNum = 0u; + +OcGdDevice m_Gds[CI_GD_MAX];/*豸*/ +UINT16 m_GdNum = 0u; + + +UINT16 LocalOcIds[OC_SUM_MAX]; + +UINT8 xingshiTestStart = 0u; +UINT32 xingshiTestStartCycle = 0u; +UINT8 xingshiTestStop = 0u; +UINT32 xingshiTestStopCycle = 0u; + + +UINT8 ocsBoardsIsScatter[OC_SUM_MAX][BOARD_SUM_MAX][1] = { 0u }; /*OCĸ忨Ƿɢ忨*/ + +UINT8 InitOcsBoardsIsScatter(void); + +/* +* ѵλתΪ +* ˵ +* +* UINT8 drvColorλ +* ֵ 0:תʧ +* 1: +*/ +UINT16 ConvertSwitchDrvPosToSwDrvCmd(UINT8 drvPos) +{ + UINT16 retDrvCmd = 0u; + switch(drvPos) + { + case SWITCH_DRIVE_POS_DINGWEI: + retDrvCmd = OC_SWITCH_DRIVE_POS_DINGWEI; + break; + case SWITCH_DRIVE_POS_FANWEI: + retDrvCmd = OC_SWITCH_DRIVE_POS_FANWEI; + break; + case SWITCH_DRIVE_POS_INVALID: + retDrvCmd = OC_SWITCH_DRIVE_POS_KEEP; + break; + default: + retDrvCmd = OC_SWITCH_DRIVE_POS_KEEP; + break; + } + return retDrvCmd; +} + +/* +* źŻɫתΪźŻ +* ˵ +* +* UINT8 drvColorźŻɫ +* ֵ 0:źŻתʧ +* 1:źŻ +*/ +UINT16 ConvertSigDrvColorToSigDrvCmd(const UINT16 signalId, const UINT8 drvColor) +{ + UINT16 retDrvCmd = 0u; + UINT8 ocHasBlue = 0u; + UINT8 funSwitchGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*ʾ̻ƹܿǷ*/ + UINT8 ciType = GetLocalCiType(); + switch (drvColor) + { + case SIGNAL_DRIVECOLOUR_RED:/**/ + /*źŻ ֻڳúת*/ + ocHasBlue = OcSignalHasBlue(signalId); + if ((1u == ocHasBlue) &&(CI_TYPE_CLD == ciType)) + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_BLUE; + } + else /*,*/ + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_RED; + } + break; + case SIGNAL_DRIVECOLOUR_YELLOW:/**/ + retDrvCmd = OC_SIGNAL_DRIVECOLOR_YELLOW; + break; + case SIGNAL_DRIVECOLOUR_REDYELLOW:/**/ + retDrvCmd = OC_SIGNAL_DRIVECOLOR_REDYELLOW; + break; + case SIGNAL_DRIVECOLOUR_GREEN:/**/ + retDrvCmd = OC_SIGNAL_DRIVECOLOR_GREEN; + break; + case SIGNAL_DRIVECOLOUR_YELLOWCLOSE:/**/ + if (FUNC_SWITCH_ON == funSwitchGreenYellow) + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_BLUE; + } + else + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_CLOSE; + } + break; + case SIGNAL_DRIVECOLOUR_REDCLOSE:/**/ + retDrvCmd = OC_SIGNAL_DRIVECOLOR_CLOSE; + break; + case SIGNAL_DRIVECOLOUR_GREENCLOSE:/**/ + if (FUNC_SWITCH_ON == funSwitchGreenYellow) + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_BLUE; + } + else + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_CLOSE; + } + break; + case SIGNAL_DRIVECOLOUR_WHITE:/**/ + retDrvCmd = OC_SIGNAL_DRIVECOLOR_WHITE; + break; + case SIGNAL_DRIVECOLOUR_RED_WHITE:/**/ + retDrvCmd = OC_SIGNAL_DRIVECOLOR_REDWHITE; + break; + case SIGNAL_DRIVECOLOUR_GREENYELLOW:/*̻*/ + if (FUNC_SWITCH_ON == funSwitchGreenYellow) + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_GREENYELLOW; + } + else + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_RED; /*Ч*/ + } + break; + case SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE:/*̻*/ + if (FUNC_SWITCH_ON == funSwitchGreenYellow) + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_BLUE; + } + else + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_RED; /*Ч*/ + } + break; + case SIGNAL_DRIVECOLOUR_DOUBLE_GREEN:/*˫*/ + if (FUNC_SWITCH_ON == funSwitchGreenYellow) + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_DOUBLEGREEN; + } + else + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_RED; /*Ч*/ + } + break; + case SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW:/*˫*/ + if (FUNC_SWITCH_ON == funSwitchGreenYellow) + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_DOUBLEYELLOW; + } + else + { + retDrvCmd = OC_SIGNAL_DRIVECOLOR_RED; /*Ч*/ + } + break; + case SIGNAL_DRIVECOLOUR_NULL:/*Ч*/ + retDrvCmd = OC_SIGNAL_DRIVECOLOR_RED; + break; + default: + retDrvCmd = OC_SIGNAL_DRIVECOLOR_RED; + break; + } + return retDrvCmd; +} + + + +/* +* OC +* ˵ UINT8 deviceId, 豸ID +* UINT8 deviceId, OCID +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToOcData( UINT8 deviceId) +{ + UINT8 Ci2OcDataBuffer[OC_TO_CI_DATA_LEN_MAX] = {0u};/*CIVOBC֡*/ + UINT8 siBoardNum = 0u; /*SI忨*/ + UINT8 ciSiToOc[OC_TO_CI_DATA_LEN_MAX] = { 0u };/*CISIOC֡*/ + UINT32 ciSiToOcIdx = 0u; /*CISIOC֡±*/ + UINT8 sorBoardNum = 0U;/*SOR忨*/ + UINT8 ciSorToOc[OC_TO_CI_DATA_LEN_MAX] = { 0U };/*CISOROC֡*/ + UINT32 ciSorToOcIdx = 0U; /*CISOROC֡±*/ + UINT32 pBoardNumStartIndex = 0u;/*Ŀ±*/ + UINT8 boardNum = 0u;/*忨Ŀ*/ + UINT16 i = 0u; + UINT32 ii = 0u; + UINT16 mm = 0u; + UINT8 kk = 0u; + UINT16 nn = 0u; + UINT16 relayId = 0u; + UINT8 relayDrvState = 0u; + UINT32 ciEtcsId = 0u; + UINT32 ocEtcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT8 retVal= CI_ERROR; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT32 curCycleNum = Get2oo2CurCycleNum(); /*Ӧں*/ + UINT32 appCycleTime = GetSystemParaAppCycleTime(); /*Ӧ*/ + UINT8 drvClor = 0u;/*źŻɫ*/ + UINT8 drvPos = 0u;/*λ*/ + UINT16 drvCmd = 0u;/**/ + UINT16 tmpInd = 0u;/*ʱ*/ + OcToCiOriginDataStruct *pOcData = NULL; /*OCCIݽṹ*/ + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + UINT16 OcDevName = 0U; /*OCƣ+ID*/ + UINT8 chSwitch = GetCiFunctionSwitchConfig(FUNC_OC_100_OR_200); + UINT8 chLocalOcType = GetLocalOcPattern(); /*OC*/ +#if 0 + QueueClear(CiToOcDataQueue); /**/ +#endif + if (0u != deviceId) + { + retVal = CI_SUCCESS; + } + else + { + } + + if (CI_SUCCESS == retVal) + { + for (i = 0u; i < m_OcToCiOrginDataNum; i++) + { + if (m_OcToCiOrginDataArr[i].OcId == deviceId) + { + break; + } + else + { + } + } + pOcData = &m_OcToCiOrginDataArr[i]; + OcDevName = (CI_SYSTEM_TYPE_OC) * 256U + deviceId; + emapCheckVer = GetCiTranOcDataCheckVer(localCiId, OcDevName); + ciEtcsId = localCiId; + ocEtcsId = deviceId; + ShortToChar(CI_OC_INTERFACE, &Ci2OcDataBuffer[ii]);/*ӿͣCI-OCӿ0206*/ + ii += 2u; + LongToChar(ciEtcsId, &Ci2OcDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(ocEtcsId, &Ci2OcDataBuffer[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(emapCheckVer, &Ci2OcDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &Ci2OcDataBuffer[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &Ci2OcDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_OC, (UINT8)pOcData->OcId), &Ci2OcDataBuffer[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_OC, (UINT8)pOcData->OcId), &Ci2OcDataBuffer[ii]);/*յһϢʱк*/ + ii += 4u; + Ci2OcDataBuffer[ii++] = (UINT8)CI_OC_PRTCL_VER;/*CI_OCӿЭ汾*/ + ii += 2u;/*ͨñͷеӦò㱨ܳ*/ + /****************Ӧñ*************/ + + ii += 2u;/*Ӧñij*/ + ShortToChar(CI_OC_CONTROL_INFO, &Ci2OcDataBuffer[ii]); + ii += 2u; + ii += 2u;/*Ԥ2ֽ*/ + + ShortToChar(pOcData->OcDeviceNum, &Ci2OcDataBuffer[ii]);/*豸*/ + ii += 2u; + for (kk = 0u; kk < pOcData->OcDeviceNum; kk++)/*豸*/ + { + if( MAX_OC_DEVICE_NUM == kk) + { + retVal = CI_ERROR; + break; + } + else + { + } + switch (pOcData->OcDevices[kk].DeviceType) + { + case CI_DEVICE_TYPE_SWITCH:/*豸*/ + { + Ci2OcDataBuffer[ii++] = CI_DEVICE_TYPE_SWITCH; + ShortToChar(pOcData->OcDevices[kk].DeviceId, &Ci2OcDataBuffer[ii]); + ii += 2u; + drvPos = GetSwitchDrivePostion(pOcData->OcDevices[kk].DeviceId); + drvCmd = ConvertSwitchDrvPosToSwDrvCmd(drvPos); + ShortToChar(drvCmd, &Ci2OcDataBuffer[ii]); + ii += 2u; + break; + } + case CI_DEVICE_TYPE_SIGNAL:/*źŻ豸*/ + { + Ci2OcDataBuffer[ii++] = CI_DEVICE_TYPE_SIGNAL; + ShortToChar(pOcData->OcDevices[kk].DeviceId, &Ci2OcDataBuffer[ii]); + ii += 2u; + drvClor = GetSignalCurDriveColor(pOcData->OcDevices[kk].DeviceId);/*ȡźŻǰɫ*/ + drvCmd = ConvertSigDrvColorToSigDrvCmd(pOcData->OcDevices[kk].DeviceId, drvClor); + ShortToChar(drvCmd, &Ci2OcDataBuffer[ii]); + ii += 2u; + break; + } + default: + { + ii += 5u; + break; + } + } + }/*Ϊoc豸*/ + + pBoardNumStartIndex = ii;/*ֵ*/ + ii += 2u;/*ֵ*/ + + /*ʼ忨*/ + for (kk = 0u; kk < GetDrvRelayStructSum(); kk++) + { + BoardDataStruct* pDrvBoard = GetDrvRelayStruct(); + if (pDrvBoard[kk].OcId == pOcData->OcId) + { + /*ɢ忨*/ + if (1u == ocsBoardsIsScatter[pOcData->OcId][pDrvBoard[kk].BoardAddress][0]) + { + ciSiToOc[ciSiToOcIdx++] = 0u; + ciSiToOc[ciSiToOcIdx++] = pDrvBoard[kk].BoardAddress; + tmpInd = (UINT16)(ciSiToOcIdx); + for (nn = 0u; nn < 24u / 2u; nn++) + {/*ȰеSI忨̵״̬ó*/ + ciSiToOc[tmpInd] = (UINT8)(OC_RELAY_DOWN << 4u) + OC_RELAY_DOWN; + tmpInd++; + } + /*̵ 8B*/ + for (nn = 0u; nn < 24u / 2u; nn++) + { + relayId = pDrvBoard[kk].RelayIdBuf[nn * 2U]; + + if ((0u != relayId) && (relayId < RELAY_SUM_MAX)) + { + relayDrvState = GetRelayDriveState(relayId);/*䵽ֽ*/ + + if (RELAY_STATE_DOWN == relayDrvState) + { /*̵*/ + ciSiToOc[ciSiToOcIdx] = (ciSiToOc[ciSiToOcIdx] & 0xf0u) | OC_RELAY_DOWN; + } + else if (RELAY_STATE_UP == relayDrvState) + { /*̵*/ + + /*drvData = drvData | (0x0001 << jj);*/ + ciSiToOc[ciSiToOcIdx] = (ciSiToOc[ciSiToOcIdx] & 0xf0u) | OC_RELAY_UP; + } + else + { /*̵Ч*/ + + /*̵*/ + ciSiToOc[ciSiToOcIdx] = (ciSiToOc[ciSiToOcIdx] & 0xf0u) | OC_RELAY_DOWN; + } + + } + else + { + } + + relayId = pDrvBoard[kk].RelayIdBuf[nn * 2U + 1U]; + + if ((0u != relayId) && (relayId < RELAY_SUM_MAX)) + { + relayDrvState = GetRelayDriveState(relayId);/*䵽ֽ*/ + + if (RELAY_STATE_DOWN == relayDrvState) + { /*̵*/ + ciSiToOc[ciSiToOcIdx] = (ciSiToOc[ciSiToOcIdx] & 0x0fu) | (UINT8)(OC_RELAY_DOWN << 4u); + } + else if (RELAY_STATE_UP == relayDrvState) + { /*̵*/ + + /*drvData = drvData | (0x0001 << jj);*/ + ciSiToOc[ciSiToOcIdx] = (ciSiToOc[ciSiToOcIdx] & 0x0fu) | (UINT8)(OC_RELAY_UP << 4u); + } + else + { /*̵Ч*/ + + /*̵*/ + ciSiToOc[ciSiToOcIdx] = (ciSiToOc[ciSiToOcIdx] & 0x0fu) | (UINT8)(OC_RELAY_DOWN << 4u); + } + + } + else + { + } + ciSiToOcIdx++; + } + + siBoardNum++; + + } + /*ȫ̵忨 SOR*/ + else if (2u == ocsBoardsIsScatter[pOcData->OcId][pDrvBoard[kk].BoardAddress][0]) + { + ciSorToOc[ciSorToOcIdx++] = pDrvBoard[kk].BoardAddress; + tmpInd = ciSorToOcIdx; + for (nn = 0U; nn < 8u / 2u; nn++) + {/*ȰеSOR忨̵״̬ó*/ + ciSorToOc[tmpInd] = (OC_RELAY_DOWN << 4) + OC_RELAY_DOWN; + tmpInd++; + } + + /*̵ 8B*/ + for (nn = 0U; nn < 8u / 2u; nn++) + { + relayId = pDrvBoard[kk].RelayIdBuf[nn * 2u]; + + if ((0U != relayId) && (relayId < RELAY_SUM_MAX)) + { + relayDrvState = GetRelayDriveState(relayId);/*䵽ֽ*/ + + if (RELAY_STATE_DOWN == relayDrvState) + { /*̵*/ + ciSorToOc[ciSorToOcIdx] = (ciSorToOc[ciSorToOcIdx] & 0xf0U) | OC_RELAY_DOWN; + } + else if (RELAY_STATE_UP == relayDrvState) + { /*̵*/ + + /*drvData = drvData | (0x0001 << jj);*/ + ciSorToOc[ciSorToOcIdx] = (ciSorToOc[ciSorToOcIdx] & 0xf0U) | OC_RELAY_UP; + } + else + { /*̵Ч*/ + + /*̵*/ + ciSorToOc[ciSorToOcIdx] = (ciSorToOc[ciSorToOcIdx] & 0xf0U) | OC_RELAY_DOWN; + } + + } + + relayId = pDrvBoard[kk].RelayIdBuf[nn * 2U + 1U]; + + if ((0U != relayId) && (relayId < RELAY_SUM_MAX)) + { + relayDrvState = GetRelayDriveState(relayId);/*䵽ֽ*/ + + if (RELAY_STATE_DOWN == relayDrvState) + { /*̵*/ + ciSorToOc[ciSorToOcIdx] = (ciSorToOc[ciSorToOcIdx] & 0x0fU) | (UINT8)(OC_RELAY_DOWN << 4U); + } + else if (RELAY_STATE_UP == relayDrvState) + { /*̵*/ + + /*drvData = drvData | (0x0001 << jj);*/ + ciSorToOc[ciSorToOcIdx] = (ciSorToOc[ciSorToOcIdx] & 0x0fU) | (UINT8)(OC_RELAY_UP << 4U); + } + else + { /*̵Ч*/ + + /*̵*/ + ciSorToOc[ciSorToOcIdx] = (ciSorToOc[ciSorToOcIdx] & 0x0fU) | (UINT8)(OC_RELAY_DOWN << 4U); + } + + } + ciSorToOcIdx++; + } + + sorBoardNum++; + } + else + { + /*忨ַ 2B*/ + Ci2OcDataBuffer[ii++] = 0u; + Ci2OcDataBuffer[ii++] = pDrvBoard[kk].BoardAddress; + tmpInd = (UINT16)(ii); + for (nn = 0u; nn < DRV_BOARD_POSITION_MAX / 2u; nn++) + {/*ȰеDO忨̵״̬ó*/ + Ci2OcDataBuffer[tmpInd] = (UINT8)(OC_RELAY_DOWN << 4u) + OC_RELAY_DOWN; + tmpInd++; + } + /*̵ 8B*/ + for (nn = 0u; nn < DRV_BOARD_POSITION_MAX / 2u; nn++) + { + relayId = pDrvBoard[kk].RelayIdBuf[nn * 2u]; + + if ((0u != relayId) && (relayId < RELAY_SUM_MAX)) + { + relayDrvState = GetRelayDriveState(relayId);/*䵽ֽ*/ + + if (RELAY_STATE_DOWN == relayDrvState) + { /*̵*/ + Ci2OcDataBuffer[ii] = (Ci2OcDataBuffer[ii] & 0xf0u) | OC_RELAY_DOWN; + } + else if (RELAY_STATE_UP == relayDrvState) + { /*̵*/ + + /*drvData = drvData | (0x0001 << jj);*/ + Ci2OcDataBuffer[ii] = (Ci2OcDataBuffer[ii] & 0xf0u) | OC_RELAY_UP; + } + else + { /*̵Ч*/ + + /*̵*/ + Ci2OcDataBuffer[ii] = (Ci2OcDataBuffer[ii] & 0xf0u) | OC_RELAY_DOWN; + } + + } + else + { + } + + relayId = pDrvBoard[kk].RelayIdBuf[nn * 2u + 1u]; + + if ((0u != relayId) && (relayId < RELAY_SUM_MAX)) + { + relayDrvState = GetRelayDriveState(relayId);/*䵽ֽ*/ + + if (RELAY_STATE_DOWN == relayDrvState) + { /*̵*/ + Ci2OcDataBuffer[ii] = (Ci2OcDataBuffer[ii] & 0x0fu) | (UINT8)(OC_RELAY_DOWN << 4u); + } + else if (RELAY_STATE_UP == relayDrvState) + { /*̵*/ + + /*drvData = drvData | (0x0001 << jj);*/ + Ci2OcDataBuffer[ii] = (Ci2OcDataBuffer[ii] & 0x0fu) | (UINT8)(OC_RELAY_UP << 4u); + } + else + { /*̵Ч*/ + + /*̵*/ + Ci2OcDataBuffer[ii] = (Ci2OcDataBuffer[ii] & 0x0fu) | (UINT8)(OC_RELAY_DOWN << 4u); + } + + } + else + { + } + ii++; + } + + boardNum++; + + } + + } + else + { + } + } + Ci2OcDataBuffer[pBoardNumStartIndex] = (UINT8)((boardNum >> 8u) & 0xffu); + Ci2OcDataBuffer[pBoardNumStartIndex + 1U] = (UINT8)(boardNum & 0xffu); + + ShortToChar(siBoardNum, &Ci2OcDataBuffer[ii]); + ii += 2u; + (void)CommonMemCpy(&Ci2OcDataBuffer[ii], OC_TO_CI_DATA_LEN_MAX-ii, ciSiToOc, ciSiToOcIdx); + ii += ciSiToOcIdx; + + if ((FUNC_SWITCH_ON == chSwitch)&&(OC_DATA_TYPE_NEW == chLocalOcType)) + { + /*OC200 ݽṹ25ϲ֧SOR*/ + Ci2OcDataBuffer[ii] = sorBoardNum; + ii += 1U; + (void)CommonMemCpy(&Ci2OcDataBuffer[ii], OC_TO_CI_DATA_LEN_MAX - ii, ciSorToOc, ciSorToOcIdx); + ii += ciSorToOcIdx; + } + +#if 0 /*ʽʵ飬ԺҪٴ*/ + if (curCycleNum == xingshiTestStartCycle && 1 == xingshiTestStart) + { + Ci2OcDataBuffer[ii++] = 0xaa; + Ci2OcDataBuffer[ii++] = 0xbb; + } + else if (curCycleNum == xingshiTestStopCycle && 1 == xingshiTestStop) + { + Ci2OcDataBuffer[ii++] = 0xcc; + Ci2OcDataBuffer[ii++] = 0xdd; + } + else + { + Ci2OcDataBuffer[ii++] = 0xff; + Ci2OcDataBuffer[ii++] = 0xff; + } +#endif + /*OC100OCݽṹ24 ӿڱԤ20ֽ*/ + if ((FUNC_SWITCH_OFF == chSwitch) || (OC_DATA_TYPE_OLD == chLocalOcType)) + { + Ci2OcDataBuffer[ii++] = 0xffu; + Ci2OcDataBuffer[ii++] = 0xffu; + for (mm = 2u; mm < 20u; mm++)/*Ԥ*/ + { + Ci2OcDataBuffer[ii++] = 0xffu; + } + } + else + { + ; /*OC200 OC3.0ɾԤ20ֽ*/ + } + + Ci2OcDataBuffer[31] = (UINT8)(((ii - 33U) >> 8u) & 0xffu); + Ci2OcDataBuffer[32] = (UINT8)((ii - 33U) & 0xffu);/*䳤*/ + + Ci2OcDataBuffer[29] = (UINT8)(((ii - 31U) >> 8u) & 0xffu); + Ci2OcDataBuffer[30] = (UINT8)((ii - 31U) & 0xffu); + + dstDevId = ((UINT16)(CI_SYSTEM_TYPE_OC << 8u) | ((UINT16)deviceId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &Ci2OcDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nOC_SEND:%d", ii); + debug_out_array(0xAA, Ci2OcDataBuffer, (UINT16)ii); +#endif/*ƽ̨ӡ*/ +#endif + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + } + + + } + else + { + } + + + + return retVal; +} + + +/* +* УOcCIĵ֡ݳȺϷ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 CheckOc2CiDataLenValid(const UINT8* dataBuf, const UINT16 totalLength) +{ + /*OC100У飺ܳ=32(GALͷ) + 1(Э汾)+ 2(GALܳ) + 2(Ӧܳ) +2(Ϣ0x8802) +2(Ԥ) + + * 2豸m+ 8*m + + * 2n+ 8*n + + * 2 (DI忨p) + 20*p + + * 2 (DO忨q) + 2*q + * 2 (ɢ忨r) + 14*r + + * 2 (ɢ忨s) + 2*s + * 豸 = 32+1+2+2+2+2 + * = 32+1+2+2+2+2+ 2+8m + * DI忨 = 32+1+2+2+2+ 2+8m+2+8n + * DO忨 = 32+1+2+2+2+ 2+8m+2+8n+2+20*p + * ɢ忨 = 32+1+2+2+2+ 2+8m+2+8n+2+20*p+2*q + * ɢ忨 = 32+1+2+2+2+ 2+8m+2+8n+2+2*r+2*q+14*r + *OC200 3.0У飺޸豸Ϣ + * 1m+ (3+1ת޻z+z+1忨b+2b*m+ + * 1źŻx+7*x+ + * ΡDI/DO/SI/DO忨δ޸ + * 1 (SOR忨h) + 7h + + */ + + UINT8 retVal = CI_ERROR; + UINT16 devNumber = 0u;/*豸*/ + UINT8 switchNum = 0u;/*豸*/ + UINT8 switchBoardNum = 0U; /*忨*/ + UINT8 signalNum = 0u;/*źŻ豸*/ + UINT16 gdBoardNumber = 0u;/**/ + UINT16 diBoardNumber = 0u;/*DI忨*/ + UINT16 doBoardNumber = 0u;/*DO忨*/ + UINT16 siBoardNumber = 0u;/*SI忨*/ + UINT16 soBoardNumber = 0u;/*SO忨*/ + UINT8 sorBoardNumber = 0u;/*SOR忨*/ + UINT16 SwapBoardNumber = 0U;/*ϵ忨*/ + UINT8 chPbNumber = 0u; /*ִе*/ + + UINT16 upToGDNumber = 0u; + UINT16 upToDIBoardNumber = 0u; + UINT16 upToDOBoardNumber = 0u; + UINT16 upToSIBoardNumber = 0u; + UINT16 upToSOBoardNumber = 0u; + UINT16 upToSORBoardNumber = 0u; + UINT16 upToPbNumer = 0u;/*ִеݸ*/ + UINT16 upToSwapSysBoardNumber = 0U; + UINT16 tmpTotalLen = 0u;/*ʱܳ*/ + UINT8 chSwitch = 0u; + UINT8 ii = 0U;/*豸ѭ*/ + UINT16 wDevInfoIndex = LEN_OC_UP_TO_DEV_NO-1U;/*ת޻ oc200ʹ*/ + UINT16 wZzjStateNumber = 0U;/*ת޻״̬ռֽ*/ + UINT8 chLocalOcType = GetLocalOcPattern(); /*ȡOC汾Ϣ*/ + UINT16 wSwitchIncludeZzjIndex = LEN_OC_UP_TO_DEV_NO;/*ת޻*/ + UINT16 wOffSet = 0U; + if(NULL != dataBuf) + { + retVal = CI_SUCCESS; + chSwitch = GetCiFunctionSwitchConfig(FUNC_OC_100_OR_200); + if (totalLength < LEN_OC_UP_TO_DEV_NO) + {/*УOCݴӿʼ豸ֹ豸*/ + retVal = CI_CHECK_LEN_ERROR; + } + else + { + ; /**/ + } + } + + if (FUNC_SWITCH_ON == chSwitch) + { + /*OC-200 ҽOCӿУ*/ + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷݽֹ*/ + + if (OC_DATA_TYPE_NEW == chLocalOcType) + { + /*ݳ*/ + switchNum = dataBuf[LEN_OC_UP_TO_DEV_NO - 2U]; + for (ii = 0U; ii < switchNum; ii++) + { + wDevInfoIndex += 3U; + wZzjStateNumber = wZzjStateNumber + (UINT16)(dataBuf[wDevInfoIndex] * 1U); + wDevInfoIndex += 1U + (UINT16)dataBuf[wDevInfoIndex] * 1U; + switchBoardNum += (UINT8)dataBuf[wDevInfoIndex]; + wDevInfoIndex += 1U + (UINT16)dataBuf[wDevInfoIndex] * 2U; + } + /*źŻ*/ + signalNum = dataBuf[wDevInfoIndex]; + //wDevInfoIndex += 1U; + upToGDNumber = (UINT16)LEN_OC_UP_TO_GD_NO_200(wZzjStateNumber, (UINT16)switchNum, (UINT16)switchBoardNum, (UINT16)signalNum); + wDevInfoIndex = upToGDNumber; + } + else + { + /*OCݽṹ24ӦOC*/ + devNumber = ShortFromChar(&dataBuf[LEN_OC_UP_TO_DEV_NO - 2U]); + for (ii = 0U; ii < devNumber; ii++) + { + wSwitchIncludeZzjIndex += 4U; + wZzjStateNumber = wZzjStateNumber + (dataBuf[wSwitchIncludeZzjIndex] * 1U); + wSwitchIncludeZzjIndex += 1U + dataBuf[wSwitchIncludeZzjIndex] * 1U + 4U; + } + upToGDNumber = LEN_OC_UP_TO_GD_NO_200_2(devNumber, wZzjStateNumber); + wDevInfoIndex = upToGDNumber; + } + if (totalLength < upToGDNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹ*/ + gdBoardNumber = ShortFromChar(&dataBuf[upToGDNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷDIݽֹDI*/ + upToDIBoardNumber = LEN_OC_UP_TO_DIBOARD_NO_200(wDevInfoIndex, gdBoardNumber); + + if (totalLength < upToDIBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*УɹDI忨*/ + diBoardNumber = ShortFromChar(&dataBuf[upToDIBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷDOݽֹDO*/ + upToDOBoardNumber = LEN_OC_UP_TO_DOBOARD_NO_200(wDevInfoIndex, gdBoardNumber, diBoardNumber); + if (totalLength < upToDOBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹdo忨*/ + doBoardNumber = ShortFromChar(&dataBuf[upToDOBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷSIݽֹSI*/ + upToSIBoardNumber = LEN_OC_UP_TO_SIBOARD_NO_200(wDevInfoIndex, gdBoardNumber, diBoardNumber, doBoardNumber); + if (totalLength < upToSIBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹsi忨*/ + siBoardNumber = ShortFromChar(&dataBuf[upToSIBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷSOݽֹSO*/ + upToSOBoardNumber = LEN_OC_UP_TO_SOBOARD_NO_200(wDevInfoIndex, gdBoardNumber, diBoardNumber, doBoardNumber, siBoardNumber); + if (totalLength < upToSOBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹso忨*/ + soBoardNumber = ShortFromChar(&dataBuf[upToSOBoardNumber - 2U]); + } + } + if (OC_DATA_TYPE_NEW == chLocalOcType) + { + wOffSet = 0U; + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷSORݽֹSOR*/ + upToSORBoardNumber = LEN_OC_UP_TO_SORBOARD_NO_200(wDevInfoIndex, gdBoardNumber, diBoardNumber, doBoardNumber, siBoardNumber, soBoardNumber); + if (totalLength < upToSORBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹsor忨*/ + sorBoardNumber = dataBuf[upToSORBoardNumber - 1U]; + } + } + } + else + { + /*֧SOR*/ + wOffSet = 1U; + sorBoardNumber = 0U; + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷִеݽִֹе*/ + upToPbNumer = LEN_OC_UP_TO_PLUSBOX_NO_200(wDevInfoIndex, gdBoardNumber, diBoardNumber, doBoardNumber, siBoardNumber, soBoardNumber, (UINT16)sorBoardNumber); + if (totalLength < upToPbNumer) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹִе*/ + chPbNumber = dataBuf[upToPbNumer - 1U- wOffSet]; + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷϵ忨ݽֹϵ忨*/ + upToSwapSysBoardNumber = LEN_OC_UP_TO_SWAPSYSBOARD_NO_200(wDevInfoIndex, gdBoardNumber, diBoardNumber, doBoardNumber, siBoardNumber, soBoardNumber, (UINT16)sorBoardNumber, chPbNumber); + upToSwapSysBoardNumber -= wOffSet; + if (totalLength < upToSwapSysBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹϵ忨*/ + SwapBoardNumber = ShortFromChar(&dataBuf[upToSwapSysBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*Уݳ*/ + tmpTotalLen = LEN_OC_UP_TO_END_200(wDevInfoIndex, gdBoardNumber, diBoardNumber, doBoardNumber, siBoardNumber, soBoardNumber, (UINT16)sorBoardNumber, chPbNumber, SwapBoardNumber); + tmpTotalLen -= wOffSet; + if (totalLength == tmpTotalLen) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_CHECK_LEN_ERROR; + } + } + } + else if (FUNC_SWITCH_OFF == chSwitch) + { + /*OC-100ӿ*/ + devNumber = ShortFromChar(&dataBuf[LEN_OC_UP_TO_DEV_NO - 2U]); + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷݽֹ*/ + upToGDNumber = LEN_OC_UP_TO_GD_NO(devNumber); + + if (totalLength < upToGDNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹ*/ + gdBoardNumber = ShortFromChar(&dataBuf[upToGDNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷDIݽֹDI*/ + upToDIBoardNumber = LEN_OC_UP_TO_DIBOARD_NO(devNumber, gdBoardNumber); + + if (totalLength < upToDIBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*УɹDI忨*/ + diBoardNumber = ShortFromChar(&dataBuf[upToDIBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷDOݽֹDO*/ + upToDOBoardNumber = LEN_OC_UP_TO_DOBOARD_NO(devNumber, gdBoardNumber, diBoardNumber); + if (totalLength < upToDOBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹdo忨*/ + doBoardNumber = ShortFromChar(&dataBuf[upToDOBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷSIݽֹSI*/ + upToSIBoardNumber = LEN_OC_UP_TO_SIBOARD_NO(devNumber, gdBoardNumber, diBoardNumber, doBoardNumber); + if (totalLength < upToSIBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹdo忨*/ + siBoardNumber = ShortFromChar(&dataBuf[upToSIBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷSOݽֹSO*/ + upToSOBoardNumber = LEN_OC_UP_TO_SOBOARD_NO(devNumber, gdBoardNumber, diBoardNumber, doBoardNumber, siBoardNumber); + if (totalLength < upToSOBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹdo忨*/ + soBoardNumber = ShortFromChar(&dataBuf[upToSOBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*УOCݴӿͷϵ忨ݽֹϵ忨*/ + upToSwapSysBoardNumber = LEN_OC100_UP_TO_SWAPSYSBOARD_NO(devNumber, gdBoardNumber, diBoardNumber, doBoardNumber, siBoardNumber, soBoardNumber); + if (totalLength < upToSwapSysBoardNumber) + { + retVal = CI_CHECK_LEN_ERROR; + } + else + { + /*Уɹϵ忨*/ + SwapBoardNumber = ShortFromChar(&dataBuf[upToSwapSysBoardNumber - 2U]); + } + } + + if (CI_SUCCESS == retVal) + {/*Уݳ*/ + tmpTotalLen = LEN_OC100_UP_TO_END(devNumber, gdBoardNumber, diBoardNumber, doBoardNumber, siBoardNumber, soBoardNumber, SwapBoardNumber); + if (totalLength == tmpTotalLen) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_CHECK_LEN_ERROR; + } + } + } + else + { + retVal = CI_CHECK_LEN_ERROR; + } + return retVal; +} + +/* +* ocԭʼ״̬ +* ˵ const UINT8 ocId, ocId +* ֵ void +* +*/ +void ResetOcOriginalState(const UINT8 ocId) +{ + UINT16 ii=0u; + UINT16 jj=0u; + UINT16 toFindIndex = 0u;/*ҵ*/ + UINT8 findFlag = 0u;/*ұ־0δҵ 1ҵ*/ + for (ii=0u;ii ii) + { + if (m_OcToCiOrginDataArr[ii].OcId == ocId) + { + toFindIndex = ii; + findFlag = 1u; + break; + } + } + } + if (1u == findFlag) + {/*ҵ*/ + for (ii=0u;iiDeviceType) + { + case OC_DEVICE_TYPE_SWITCH: + { + pDev->DeviceState = OC_SWITCH_POSITION_SIKAI;/*õλΪĿ*/ + for (jj = 0U; jj < pDev->chSwitchIncldeZzjNum; jj++) + { + pDev->szSwitchIncldeZzjState[jj] = OC_SWITCH_POSITION_SIKAI;/*ת޻״̬ΪĿ*/ + } + } + break; + case OC_DEVICE_TYPE_SIGNAL: + { + pDev->DeviceState = OC_SIGNAL_SHOWCOLOR_RED_BREAK; /*źŻʾɫΪ*/ + } + break; + default: + /* 3/CCɼ忨/DD忨*/ + break; + } + } + + for (ii=0u;iiGdState1 = OC_GD_STATE_OCCUPY; + pGdDev->GdState2 = OC_GD_STATE_OCCUPY; + pGdDev->GdMergeState = OC_GD_STATE_OCCUPY;/*A/Bϵ״̬Ϊռ*/ + } + + for (ii=0u;iiBoardCollData[jj] = 0xaau;/*DI忨̵ȫ*/ + } + } + + for (ii = 0u; iiBoardCollData[jj] = 0xaau;/*SOR忨̵ȫ*/ + } + } + } +} + +/* +* OcCIĵ֡ݵ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseOcToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength,const UINT8 systemId) +{ + UINT8 retVal = CI_ERROR; + UINT8 localCiId = 0u; /*ID*/ + + UINT16 ii = 0u; /**/ + UINT8 j = 0u; + UINT8 k = 0U; + UINT8 tmpDeviceType = 0u; /*豸 1B*/ + UINT8 tmpSwitchNum = 0U;/**/ + UINT8 tmpSignalNum = 0U;/**/ + UINT16 tmpDeviceId = 0u; /*豸Id 2B*/ + UINT8 tmpDeviceState = 0u; /*豸״̬ 1B*/ + UINT8 tmpSwitchBoardNum = 0U; /*忨*/ + UINT8 switchBoardCheck = CI_ERROR; /*״̬*/ + UINT8 tmpBoardAddr1 = 0u;/*1ϵ忨ַ 1B*/ + UINT8 tmpBoardState1 = 0u; /*1ϵ忨״̬ 2B*/ + + UINT8 tmpBoardAddr2 = 0u; /*忨ַ*/ + UINT8 tmpBoardState2 = 0u; /*忨״̬ 0x0000 󷢴*/ + UINT8 tmpBoardCollData[18] = {0u}; /*ɼ*/ + + UINT16 ocName = 0u; /*ciͨŵoc Name 0x46*/ + UINT8 headRet = HLHT_HEAD_ERROR; + + UINT8* sourceId = NULL; /*ԴID*/ + UINT32 curntCycleNo = 0u; /*ǰں*/ + HLHTGALInfoStruct hlhtGalHead= {0u}; + INT32 ocInfoRemainValidity = 0; + + UINT16 appInfoType = 0u; /*ӦϢ*/ + OcToCiOriginDataStruct * pTmpOcToCiData = NULL; + UINT8 toUpdateOcIndex = 0u; + UINT8 findFlag = 0u; + UINT16 tmpGdId = 0u;/*ʱʱId*/ + UINT16 curBoardNum = 0u; /*ǰ*/ + UINT16 curBoardSwapSysNum = 0U;/*ϵ忨*/ + UINT32 galOcDataVer = 0U; + UINT8 chPbIndex = 0u; + UINT8 chSwitch = 0u; + UINT8 chZzjStateIndex = 0u;/*Ӧת޻״̬*/ + UINT8 chOcType = GetLocalOcPattern(); /*ȡOCݽṹ*/ + + for (j=0u;j 0u)) + {/*УOCciЧ*/ + retVal = CheckOc2CiDataLenValid(dataBuf,dataLength); + } + else + { + retVal = CI_ERROR; + } + + + if (CI_SUCCESS == retVal) + { + /* ȡOCͺţ0xaa:2000x55:100 */ + chSwitch = GetCiFunctionSwitchConfig(FUNC_OC_100_OR_200); + sourceId = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_OC);/*ȡ뱾ͨŵOCID*/ + + ii+=4u;/*4ֽڣԺoc*/ + /*ͨϢͷ*/ + hlhtGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.sourceId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.destId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.comPeriod = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.prtclVer = dataBuf[ii++]; + hlhtGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + curntCycleNo = Get2oo2CurCycleNum(); + + ocName = (CI_SYSTEM_TYPE_OC) * 256U + systemId; + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + galOcDataVer = GetCiTranOcDataCheckVer(localCiId, ocName); /*ȡOCϵͳݰ汾*/ + if (hlhtGalHead.emapVerCrc == galOcDataVer) + { + headRet = HLHT_HEAD_SUCCESS; + } + else + { + headRet = HLHT_HEAD_ERROR; + } +#if 0 + headRet = HLHTRecvCommonPacketHeadCheck(ocName, ciName, CI_OC_INTERFACE_INFOTYPE, CI_OC_PRTCL_VER, &hlhtGalHead, &errCode, 0, CI_SYSTEM_TYPE_OC); +#endif + if (HLHT_HEAD_SUCCESS == headRet) + { +#if 0 + ocInfoRemainValidity = HLHTCommonMsgRemainingValidity(GetCiAndOcTransmitBadEnsureCnt(),curntCycleNo, + GetSystemParaAppCycleTime(),hlhtGalHead.recvOppMsgSN,hlhtGalHead.crntOwnMsgSN,hlhtGalHead.preOwnMsgSN,hlhtGalHead.comPeriod); +#endif + ocInfoRemainValidity = 1; + if (ocInfoRemainValidity > 0) + { + /*Ӧ*/ + ii+=2u;/*Ӧò㳤ȣ2B*/ + + appInfoType = ShortFromChar(&dataBuf[ii]);/*ӦϢͣ2B*/ + ii += 2u; + + ii+=2u; /*Ԥ2B*/ + + pTmpOcToCiData->OcId = systemId; /*oc idֵ*/ + + pTmpOcToCiData->ComStartCycle = Get2oo2CurCycleNum();/*յOCʱͨſʼ*/ + + debug_infor_printf((const)"\nId:%d OC_COM:%d\n",pTmpOcToCiData->OcId,pTmpOcToCiData->ComStartCycle); + + if (OC_CI_STATE_INFO == appInfoType)/*OCCI״̬Ϣ 0x8802*/ + { + /*by cgh 20230831 ת޻״̬ӿ*/ + /*fan 20241120 4ǣ OC3.0 ӿ ֧OCݽṹнݽṹ*/ + if ((FUNC_SWITCH_ON == chSwitch)&&(OC_DATA_TYPE_NEW == chOcType)) + { + /*************豸[]***********/ + tmpDeviceType = CI_DEVICE_TYPE_SWITCH; + tmpSwitchNum = dataBuf[ii++];/**/ + for (j = 0u;jOcDevices[j].chSwitchIncldeZzjNum = dataBuf[ii++]; + if (MAX_OC_SWITCH_INCLUDE_ZZJ_NUM >= pTmpOcToCiData->OcDevices[j].chSwitchIncldeZzjNum) + { + for (chZzjStateIndex = 0U; chZzjStateIndex < pTmpOcToCiData->OcDevices[j].chSwitchIncldeZzjNum; chZzjStateIndex++) + { + /*ת޻״̬*/ + pTmpOcToCiData->OcDevices[j].szSwitchIncldeZzjState[chZzjStateIndex] = dataBuf[ii++]; + } + } + else + { + retVal = CI_ERROR; + pTmpOcToCiData->OcDevices[j].chSwitchIncldeZzjNum = 0U; + pTmpOcToCiData->OcDevices[j].szSwitchIncldeZzjState[0U] = OC_SWITCH_POSITION_SIKAI; + } + + if (CI_SUCCESS == retVal) + { + tmpSwitchBoardNum = dataBuf[ii++];/*忨*/ + + if ((j < MAX_OC_DEVICE_NUM) && (tmpSwitchBoardNum <= MAX_OC_SWITCH_INCLUDE_BOARD_NUM)) + { + pTmpOcToCiData->OcDevices[j].OcId = systemId;/*ÿ豸oc id*/ + /*忨ַ״ֵ̬*/ + pTmpOcToCiData->OcDevices[j].BoardNum = tmpSwitchBoardNum; /*忨*/ + switchBoardCheck = CI_ERROR; + for (k = 0U; k < tmpSwitchBoardNum; k++) + { + pTmpOcToCiData->OcDevices[j].BoardAddr[k] = dataBuf[ii++];/*忨ַ 1B*/ + pTmpOcToCiData->OcDevices[j].BoardState[k] = dataBuf[ii++];/*忨״̬ 1B*/ + if (0U == pTmpOcToCiData->OcDevices[j].BoardState[k]) + { + switchBoardCheck = CI_SUCCESS; /*忨*/ + } + } + pTmpOcToCiData->OcDevices[j].DeviceType = tmpDeviceType; /*豸 1B*/ + pTmpOcToCiData->OcDevices[j].DeviceId = tmpDeviceId; /*豸Id 2B*/ + pTmpOcToCiData->OcDevices[j].DeviceState = tmpDeviceState; /*豸״̬ 1B*/ + + if (CI_SUCCESS == switchBoardCheck) /*0Ϊ 忨*/ + { + pTmpOcToCiData->OcDevices[j].DeviceState = tmpDeviceState; /*豸״̬ 1B*/ + } + else + { + /*ats*/ + + } + } + else + { + /*豸źŻԾϢ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"devId'index %d exceed macro %d boardNum%d, max:%d \n", tmpDeviceId, MAX_OC_DEVICE_NUM, tmpSwitchBoardNum, MAX_OC_SWITCH_INCLUDE_BOARD_NUM); + } + } + } + + + /*************豸[źŻ]***********/ + if (CI_SUCCESS == retVal) + { + tmpDeviceType = CI_DEVICE_TYPE_SIGNAL; + tmpSignalNum = dataBuf[ii++];/*źŻ*/ + + pTmpOcToCiData->OcDeviceNum = tmpSignalNum + tmpSwitchNum; + for (j = tmpSwitchNum; j < pTmpOcToCiData->OcDeviceNum; j++) /*豸*/ + { + tmpDeviceId = ShortFromChar(&dataBuf[ii]); /*豸Id 2B*/ + ii += 2u; + tmpDeviceState = dataBuf[ii++]; /*豸״̬ 1B*/ + + tmpBoardAddr1 = dataBuf[ii++];/*忨ַ 1B*/ + tmpBoardState1 = dataBuf[ii++]; /*忨״̬ 1B*/ + + tmpBoardAddr2 = dataBuf[ii++];/*忨ַ 1B*/ + tmpBoardState2 = dataBuf[ii++]; /*忨״̬ 1B*/ + if (j < MAX_OC_DEVICE_NUM) + { + pTmpOcToCiData->OcDevices[j].OcId = systemId;/*ÿ豸oc id*/ + /*忨ַ״ֵ̬*/ + pTmpOcToCiData->OcDevices[j].BoardNum = 2U; /*忨*/ + pTmpOcToCiData->OcDevices[j].chSwitchIncldeZzjNum = 0U; + pTmpOcToCiData->OcDevices[j].BoardAddr[0] = tmpBoardAddr1;/*忨ַ 1B*/ + pTmpOcToCiData->OcDevices[j].BoardState[0] = tmpBoardState1; /*忨״̬ 1B*/ + pTmpOcToCiData->OcDevices[j].BoardAddr[1] = tmpBoardAddr2;/*忨ַ 1B*/ + pTmpOcToCiData->OcDevices[j].BoardState[1] = tmpBoardState2; /*忨״̬ 1B*/ + pTmpOcToCiData->OcDevices[j].chSwitchIncldeZzjNum = 0U; + pTmpOcToCiData->OcDevices[j].DeviceType = tmpDeviceType; /*豸 1B*/ + pTmpOcToCiData->OcDevices[j].DeviceId = tmpDeviceId; /*豸Id 2B*/ + pTmpOcToCiData->OcDevices[j].DeviceState = tmpDeviceState; /*豸״̬ 1B*/ + + if ((0u == tmpBoardState1) || (0u == tmpBoardState2)) /*0Ϊ 쳣*/ + { + pTmpOcToCiData->OcDevices[j].DeviceState = tmpDeviceState; /*豸״̬ 1B*/ + } + else + { + /*ats*/ + + } + } + else + { + /*豸źŻԾϢ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"devId'index %d exceed macro %d.\n", tmpDeviceId, MAX_OC_DEVICE_NUM); + } + } + } + + } + /*OC-100 ԼOCݽṹ24ӦOC 4ǣ 豸ֵ&źŻϲ ̶豸忨2*/ + else + { + /*OC100 Լ OCݽṹ24*/ + /*************豸[źŻ]***********/ + pTmpOcToCiData->OcDeviceNum = ShortFromChar(&dataBuf[ii]);/*豸*/ + ii += 2u; + for (j = 0u; jOcDeviceNum; j++) /*豸*/ + { + tmpDeviceType = dataBuf[ii++]; /*豸 1B*/ + tmpDeviceId = ShortFromChar(&dataBuf[ii]); /*豸Id 2B*/ + ii += 2u; + tmpDeviceState = dataBuf[ii++]; /*豸״̬ 1B*/ + + if (FUNC_SWITCH_ON == chSwitch) + { + /*Ӧת޻Ŀ豸ΪźŻʱ,˸Ϊ0*/ + pTmpOcToCiData->OcDevices[j].chSwitchIncldeZzjNum = dataBuf[ii++]; + for (chZzjStateIndex = 0U; chZzjStateIndex < pTmpOcToCiData->OcDevices[j].chSwitchIncldeZzjNum; chZzjStateIndex++) + { + /*ת޻״̬*/ + pTmpOcToCiData->OcDevices[j].szSwitchIncldeZzjState[chZzjStateIndex] = dataBuf[ii++]; + } + } + else + { + /* 100޴˽ӿ */ + } + tmpBoardAddr1 = dataBuf[ii++];/*忨ַ 1B*/ + tmpBoardState1 = dataBuf[ii++]; /*忨״̬ 1B*/ + + tmpBoardAddr2 = dataBuf[ii++];/*忨ַ 1B*/ + tmpBoardState2 = dataBuf[ii++]; /*忨״̬ 1B*/ + if (j< MAX_OC_DEVICE_NUM) + { + pTmpOcToCiData->OcDevices[j].OcId = systemId;/*ÿ豸oc id*/ + /*忨ַ״ֵ̬*/ + pTmpOcToCiData->OcDevices[j].BoardNum = 2U; /*忨̶2*/ + pTmpOcToCiData->OcDevices[j].BoardAddr[0] = tmpBoardAddr1;/*忨ַ 1B*/ + pTmpOcToCiData->OcDevices[j].BoardState[0] = tmpBoardState1; /*忨״̬ 1B*/ + pTmpOcToCiData->OcDevices[j].BoardAddr[1] = tmpBoardAddr2;/*忨ַ 1B*/ + pTmpOcToCiData->OcDevices[j].BoardState[1] = tmpBoardState2; /*忨״̬ 1B*/ + + pTmpOcToCiData->OcDevices[j].DeviceType = tmpDeviceType; /*豸 1B*/ + pTmpOcToCiData->OcDevices[j].DeviceId = tmpDeviceId; /*豸Id 2B*/ + pTmpOcToCiData->OcDevices[j].DeviceState = tmpDeviceState; /*豸״̬ 1B*/ + + if ((0u == tmpBoardState1) || (0u == tmpBoardState2)) /*0Ϊ 쳣*/ + { + pTmpOcToCiData->OcDevices[j].DeviceState = tmpDeviceState; /*豸״̬ 1B*/ + } + else + { + /*ats*/ + + } + } + else + { + /*豸źŻԾϢ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"devId'index %d exceed macro %d.\n", tmpDeviceId, MAX_OC_DEVICE_NUM); + } + } + } + + + /************************/ + if (CI_SUCCESS == retVal) + { + pTmpOcToCiData->OcGdNum = ShortFromChar(&dataBuf[ii]);/**/ + ii += 2u; + if (Max_OC_GD_NUM >= pTmpOcToCiData->OcGdNum) + { + for (j = 0u; j < pTmpOcToCiData->OcGdNum; j++)/**/ + { + pTmpOcToCiData->OcId = systemId;/*OCŸֵ*/ + + tmpGdId = ShortFromChar(&dataBuf[ii]);/*id*/ + + pTmpOcToCiData->OcGdDevices[j].OcId = systemId; + pTmpOcToCiData->OcGdDevices[j].GdDeviceId = ShortFromChar(&dataBuf[ii]);/*id*/ + ii += 2u; + pTmpOcToCiData->OcGdDevices[j].BoardAddr1 = dataBuf[ii++]; + pTmpOcToCiData->OcGdDevices[j].BoardState1 = dataBuf[ii++]; + pTmpOcToCiData->OcGdDevices[j].GdState1 = dataBuf[ii++]; + + pTmpOcToCiData->OcGdDevices[j].BoardAddr2 = dataBuf[ii++]; + pTmpOcToCiData->OcGdDevices[j].BoardState2 = dataBuf[ii++]; + pTmpOcToCiData->OcGdDevices[j].GdState2 = dataBuf[ii++]; + } + } + else + { + retVal = CI_ERROR; + /*峬ԾϢ*/ + debug_infor_printf((const)"devId'index %d exceed macro %d.\n", pTmpOcToCiData->OcGdNum, Max_OC_GD_NUM); + } + } + /*************DI忨***********/ + if (CI_SUCCESS == retVal) + { + pTmpOcToCiData->OcDIBoardDataNum = ShortFromChar(&dataBuf[ii]);/*忨*/ + ii += 2u; + if (MAX_OC_DI_BOARD_NUM >= pTmpOcToCiData->OcDIBoardDataNum) + { + for (j = 0u; j < pTmpOcToCiData->OcDIBoardDataNum; j++) /*忨*/ + { + tmpBoardAddr2 = dataBuf[ii++]; /*忨ַ*/ + tmpBoardState2 = dataBuf[ii++]; /*忨״̬*/ + + (void)memcpy(tmpBoardCollData, &dataBuf[ii], 18); /*忨ɼ*/ /*ij18ֽˣҪ޸*/ + ii += 18u; + + pTmpOcToCiData->OcDIBoardDatas[j].BoardAddr = tmpBoardAddr2; + pTmpOcToCiData->OcDIBoardDatas[j].BoardState = tmpBoardState2; + if (tmpBoardState2 == 0u) /*忨*/ + { + (void)memcpy(pTmpOcToCiData->OcDIBoardDatas[j].BoardCollData, tmpBoardCollData, 18); + + } + else /*忨*/ + { + (void)memset(pTmpOcToCiData->OcDIBoardDatas[j].BoardCollData, 0xaa, 18); + /*ats*/ + } + } + } + else + { + /*DI忨ԾϢ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"OcDIBoardDatas'index %d exceed macro %d.\n", pTmpOcToCiData->OcDIBoardDataNum, MAX_OC_DI_BOARD_NUM); + } + } + + /************DO忨**********/ + if (CI_SUCCESS == retVal) + { + pTmpOcToCiData->OcDOBoardNum = ShortFromChar(&dataBuf[ii]);/*DO忨*/ + ii += 2u; + if (MAX_OC_DO_BOARD_NUM >=pTmpOcToCiData->OcDOBoardNum) + { + for (j = 0u; j < pTmpOcToCiData->OcDOBoardNum; j++) + { + pTmpOcToCiData->OcDOBoardDatas[j].DoBoardAddr = dataBuf[ii++]; + pTmpOcToCiData->OcDOBoardDatas[j].DoBoardState = dataBuf[ii++]; + } + } + else + { + retVal = CI_ERROR; + /*DO忨ԾϢ*/ + debug_infor_printf((const)"OcDOBoardDatas'index %d exceed macro %d.\n", pTmpOcToCiData->OcDOBoardNum, MAX_OC_DO_BOARD_NUM); + } + } + + /*************SI忨***********/ + if (CI_SUCCESS == retVal) + { + curBoardNum = pTmpOcToCiData->OcDIBoardDataNum; + pTmpOcToCiData->OcDIBoardDataNum += ShortFromChar(&dataBuf[ii]);/*SI忨*/ + ii += 2u; + if (MAX_OC_DI_BOARD_NUM >= pTmpOcToCiData->OcDIBoardDataNum) + { + for (j = (UINT8)(curBoardNum); j < pTmpOcToCiData->OcDIBoardDataNum; j++) /*忨*/ + { + tmpBoardAddr2 = dataBuf[ii++]; /*忨ַ*/ + tmpBoardState2 = dataBuf[ii++]; /*忨״̬*/ + + (void)memcpy(tmpBoardCollData, &dataBuf[ii], 12); /*忨ɼ*/ /*ij12ֽˣҪ޸*/ + ii += 12u; + + pTmpOcToCiData->OcDIBoardDatas[j].BoardAddr = tmpBoardAddr2; + pTmpOcToCiData->OcDIBoardDatas[j].BoardState = tmpBoardState2; + if (tmpBoardState2 == 0u) /*忨*/ + { + (void)memcpy(pTmpOcToCiData->OcDIBoardDatas[j].BoardCollData, tmpBoardCollData, 12); + } + else /*忨*/ + { + (void)memset(pTmpOcToCiData->OcDIBoardDatas[j].BoardCollData, 0xaa, 12); + /*ats*/ + } + } + } + else + { + /*SI忨ԾϢ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"OcSIBoardDatas'index %d exceed macro %d\n.", pTmpOcToCiData->OcDIBoardDataNum, MAX_OC_DI_BOARD_NUM); + } + } + /************SO忨**********/ + curBoardNum = pTmpOcToCiData->OcDOBoardNum; + pTmpOcToCiData->OcDOBoardNum += ShortFromChar(&dataBuf[ii]);/*DO忨*/ + ii += 2u; + if (MAX_OC_DO_BOARD_NUM >=pTmpOcToCiData->OcDOBoardNum) + { + for (j = (UINT8)(curBoardNum); j < pTmpOcToCiData->OcDOBoardNum; j++) + { + pTmpOcToCiData->OcDOBoardDatas[j].DoBoardAddr = dataBuf[ii++]; + pTmpOcToCiData->OcDOBoardDatas[j].DoBoardState = dataBuf[ii++]; + } + } + else + { + retVal = CI_ERROR; + /*SO忨ԾϢ*/ + debug_infor_printf((const)"OcSOBoardDatas'index %d exceed macro %d.\n", pTmpOcToCiData->OcDOBoardNum, MAX_OC_DO_BOARD_NUM); + } + + /*************SOR忨 OC-200ҽOC***********/ + if ((CI_SUCCESS == retVal) && (FUNC_SWITCH_ON == chSwitch)&& (OC_DATA_TYPE_NEW == chOcType)) + { + pTmpOcToCiData->OcSORBoardNum = dataBuf[ii++];/*Sor忨*/ + if (MAX_OC_SOR_BOARD_NUM >= pTmpOcToCiData->OcSORBoardNum) + { + for (j = 0U; j < pTmpOcToCiData->OcSORBoardNum; j++) /*忨*/ + { + tmpBoardAddr2 = dataBuf[ii++]; /*忨ַ*/ + tmpBoardState2 = dataBuf[ii++]; /*忨״̬*/ + + (void)memcpy(tmpBoardCollData, &dataBuf[ii], 5); /*̵ز*/ + ii += 5u; + + pTmpOcToCiData->OcSORBoardDatas[j].BoardAddr = tmpBoardAddr2; + pTmpOcToCiData->OcSORBoardDatas[j].BoardState = tmpBoardState2; + if (tmpBoardState2 == 0u) /*忨*/ + { + (void)memcpy(pTmpOcToCiData->OcSORBoardDatas[j].BoardCollData, tmpBoardCollData, 5U); + } + else /*忨*/ + { + (void)memset(pTmpOcToCiData->OcSORBoardDatas[j].BoardCollData, 0xaaU, 5U); + /*ats*/ + } + } + } + else + { + /*Sor忨ԾϢ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"OcSorBoardDatas'index %d exceed macro %d.\n", pTmpOcToCiData->OcSORBoardNum, MAX_OC_SOR_BOARD_NUM); + } + } + + /*************OCԴ״ִ̬е***********/ + if (CI_SUCCESS == retVal) + { + pTmpOcToCiData->PowerAState = dataBuf[ii++]; + pTmpOcToCiData->PowerBState = dataBuf[ii++]; + pTmpOcToCiData->OCDevFaultState = dataBuf[ii++]; + pTmpOcToCiData->FanState = dataBuf[ii++]; + + if (FUNC_SWITCH_ON == chSwitch) + { + /* ִеϢ */ + pTmpOcToCiData->chPbNum = dataBuf[ii++]; + if (pTmpOcToCiData->chPbNum <= MAX_OC_PLUS_BOX_NUM) + { + for (chPbIndex = 0u; chPbIndex < pTmpOcToCiData->chPbNum; chPbIndex++) + { + /* ִеID */ + pTmpOcToCiData->szPlusBox[chPbIndex].chPbId = dataBuf[ii++]; + /* */ + pTmpOcToCiData->szPlusBox[chPbIndex].chPbType = dataBuf[ii++]; + /* տ״̬ */ + pTmpOcToCiData->szPlusBox[chPbIndex].chAsState = dataBuf[ii++]; + } + } + else + { + /*ִеԾϢ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"OcPbNumDatas'index %d exceed macro %d.\n", pTmpOcToCiData->chPbNum, MAX_OC_PLUS_BOX_NUM); + } + } + else + { + /* 100ִе */ + } + } + /*************ϵ忨***********/ + if (CI_SUCCESS == retVal) + { +#if 1 + pTmpOcToCiData->OCBoardSwapSysNum = ShortFromChar(&dataBuf[ii]); /*OCϵ忨*/ + ii += 2U; + curBoardSwapSysNum = pTmpOcToCiData->OCBoardSwapSysNum; + if (MAX_OC_DEVICE_NUM >= curBoardSwapSysNum) + { + for (j = 0U; j < curBoardSwapSysNum; j++) + { + pTmpOcToCiData->SwapSysBoardId[j] = dataBuf[ii++];/*OCϵ忨ID*/ + } + } + else + { + /*ϵԾϢ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"OcSwapSysBoardNum'index %d exceed macro %d.\n", curBoardSwapSysNum, MAX_OC_DEVICE_NUM); + } + } +#endif +#if 0 + (void)memcpy(pTmpOcToCiData->OcSystemState,&dataBuf[ii],16);/*OCϵͳ״̬*/ + ii+=16; +#endif + } + else + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + if (ii > dataLength) + { + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + /*ݾУ飬Ҫ洢ͨñ*/ + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_OC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_OC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_OC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_OC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_OC, systemId, curntCycleNo); + + if(findFlag ==0u) /*ҪµocûҵΪµoc,Ҫoc*/ + { + m_OcToCiOrginDataNum++; + } + } + + } + + + } + else if (HLHT_HEAD_INIT == headRet) + { + if (curntCycleNo > 0u) + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_OC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_OC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_OC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_OC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_OC, systemId, curntCycleNo); + } + } + else + { + /*ATSֵطCI-OCݰ汾УʧϢ*/ + SetCiSendCmdBackInfoData(CI_BACK_DATA_VER_CHECK_FAIL, CI_SYSTEM_TYPE_OC, systemId, 0U, 0U); + retVal = CI_ERROR; + } + } + + + if (CI_SUCCESS == retVal) + { + if (SetCiTransmitRecvDataCycNum(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_OC, systemId, Get2oo2CurCycleNum()) == CI_ERROR) + {/*ʧ*/ + + } + else + {/*ڳɹ*/ + + /*OCͨ״̬жOCǷͨж*/ + if (UpdateCiTransmitState(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_OC, systemId) == CI_ERROR) + { + /*ͨ״̬ʧ*/ + } + else + { + /*ͨ״̬ɹ*/ + } + } + + } + else if ((CI_ERROR == retVal)|| (CI_CHECK_LEN_ERROR == retVal) /*|| (0 == galHeadSaved)*/) + { + /*ͨñͷ*/ + ClearHlhtHeadCtx(CI_SYSTEM_TYPE_OC, systemId); + } + else + { + /**/ + } + + + + return retVal; +} + + + +/* +* ʼOC豸 +* ˵ void +* ֵ void +*/ +void InitOcDevices(void) +{ + InitOcSignals(); + + InitOcSwitchs(); + + InitOcGds(); + + (void)InitOcsBoardsIsScatter(); +} + +/* +* ͨźŻidȡ +* ˵ void +* ֵ void +*/ +INT16 GetIndexBySignalId(UINT16 sigId) +{ + INT16 retIndex = -1; + + UINT16 i =0u; + + for (i=0u;iDeviceType == OC_DEVICE_TYPE_SIGNAL) + {/*źŻ*/ + ind = GetIndexBySignalId(pOcDevice->DeviceId); + if ((ind >=0) && (OC_DEVICE_TYPE_SIGNAL == pOcDevice->DeviceType)) + { + if ((m_Signals[ind].OcId == pOcDevice->OcId) && + (m_Signals[ind].DeviceId == pOcDevice->DeviceId)) + { + m_Signals[ind].DeviceState = pOcDevice->DeviceState; + m_Signals[ind].DeviceType = pOcDevice->DeviceType; + m_Signals[ind].BoardNum = pOcDevice->BoardNum; + m_Signals[ind].BoardAddr[0] = pOcDevice->BoardAddr[0]; + m_Signals[ind].BoardState[0] = pOcDevice->BoardState[0]; + m_Signals[ind].BoardAddr[1] = pOcDevice->BoardAddr[1]; + m_Signals[ind].BoardState[1] = pOcDevice->BoardState[1]; + } + else + { + } + } + else + { + } + + + } + else if (pOcDevice->DeviceType == OC_DEVICE_TYPE_SWITCH) + {/**/ + ind = GetIndexBySwitchId(pOcDevice->DeviceId); + if ((ind >=0) && (OC_DEVICE_TYPE_SWITCH == pOcDevice->DeviceType)) + { + if ((m_Switches[ind].OcId == pOcDevice->OcId) && + (m_Switches[ind].DeviceId == pOcDevice->DeviceId)) + { + m_Switches[ind].DeviceState = pOcDevice->DeviceState; + m_Switches[ind].DeviceType = pOcDevice->DeviceType; + m_Switches[ind].BoardNum = pOcDevice->BoardNum; + for (k = 0U; k < m_Switches[ind].BoardNum; k++) + { + m_Switches[ind].BoardAddr[k] = pOcDevice->BoardAddr[k]; + m_Switches[ind].BoardState[k] = pOcDevice->BoardState[k]; + } + } + else + { + } + + } + else + { + } + + } + else + {/*յ豸ͷǷȷźŻַǵ*/ + flagRecvInvalidData = 1u; + + } + } + else + { + } + } + + for (j=0U;jGdDeviceId); + if (ind >=0 ) + { + if ((m_Gds[ind].OcId == pGdDevice->OcId) && + (m_Gds[ind].GdDeviceId == pGdDevice->GdDeviceId)) + { + m_Gds[ind].BoardAddr1 = pGdDevice->BoardAddr1; + m_Gds[ind].BoardAddr2 = pGdDevice->BoardAddr2; + m_Gds[ind].BoardState1 = pGdDevice->BoardState1; + m_Gds[ind].BoardState2 = pGdDevice->BoardState2; + m_Gds[ind].GdState1 = pGdDevice->GdState1; + m_Gds[ind].GdState2 = pGdDevice->GdState2; + } + else + { + } + } + else + { + } + + } + + if (1u == flagRecvInvalidData) + {/*յǷ豸*/ + m_OcToCiOrginDataArr[i].RecvErrorDevTypeCycle++; + } + else if (0u == flagRecvInvalidData) + {/*յ֡Ѵ*/ + m_OcToCiOrginDataArr[i].RecvErrorDevTypeCycle = 0; + } + else + { + /*޲*/ + } + } + else + { + } + } +} + + +/* +* ѽOC忨תΪOCλ +* ˵ void +* ֵ void +*/ +void ConvertOcOriginDataToPtData(void) +{ + UINT8 i=0U; + UINT16 j= 0U; + INT16 k=0; + UINT8 boardNum = 0u; + UINT8 byteRealy = 0u; + UINT8 lowByte = 0u; + UINT8 highByte = 0u; + UINT8 boardAddr =0u; + UINT8 cBoardState = RELAY_BOARD_FAULT_YES; + UINT8 chLocalCiId = GetSystemParaLocalCiId(); + + for (i=0U;iOcId) == chLocalCiId) + { + if (Get2oo2CurCycleNum() - pOcOriginData->ComStartCycle <= GetCiAndOcTransmitBadEnsureCnt())/*CIOCͨδʱ*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].OcBoardNum = 0u; + /*һOCDI忨*/ + for (j=0U;jOcDIBoardDataNum;j++) + { + boardAddr = pOcOriginData->OcDIBoardDatas[j].BoardAddr;/*忨ַ*/ + cBoardState = pOcOriginData->OcDIBoardDatas[j].BoardState; /*忨״̬*/ + boardNum = (UINT8)m_OcConvertedPtDataArr[pOcOriginData->OcId].OcBoardNum;/*忨*/ + + + m_OcConvertedPtDataArr[pOcOriginData->OcId].OcId = pOcOriginData->OcId; + InsertOcId(pOcOriginData->OcId);/*oc id*/ + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].BoardAddress = boardAddr;/*忨ֵַ*/ + + if (0U == cBoardState) + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].BoardState = RELAY_BOARD_FAULT_NO; /*忨״̬*/ + } + else + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].BoardState = RELAY_BOARD_FAULT_YES; /*忨״̬*/ + } + + for (k=0;k<18;k++)/*һ忨18ֽڣ1~40λ1~36λЧ*/ + { + byteRealy = pOcOriginData->OcDIBoardDatas[j].BoardCollData[k]; + + lowByte = byteRealy & 0x0fu;/*ֽڵ4λ*/ + highByte = (byteRealy>>4)&0x0fu;/*ֽڸ4λ*/ + + if (OC_RELAY_UP == (lowByte ) )/*5:*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k*2] = RELAY_STATE_UP; + } + else if (OC_RELAY_DOWN == (lowByte ) )/*0xa:*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k*2] = RELAY_STATE_DOWN; + } + else + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k*2] = RELAY_STATE_DOWN; + } + + if (OC_RELAY_UP == (highByte ) )/*5:*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k*2+1] = RELAY_STATE_UP; + } + else if (OC_RELAY_DOWN == (highByte ) )/*0xa:*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k*2+1] = RELAY_STATE_DOWN; + } + else + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k*2+1] = RELAY_STATE_DOWN; + } +#if 0 + for (ii=0;ii<8;ii++) + { + if (((byteRealy>>ii) & 0x1) == 0x1) + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k*8+ii] = RELAY_STATE_UP; + } + else + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k*8+ii] = RELAY_STATE_DOWN; + } + } +#endif + } + m_OcConvertedPtDataArr[pOcOriginData->OcId].OcBoardNum++; + + } + + /*SOR忨*/ + for (j = 0U; j < pOcOriginData->OcSORBoardNum; j++) + { + boardAddr = pOcOriginData->OcSORBoardDatas[j].BoardAddr;/*忨ַ*/ + cBoardState = pOcOriginData->OcSORBoardDatas[j].BoardState; /*忨״̬*/ + boardNum = (UINT8)m_OcConvertedPtDataArr[pOcOriginData->OcId].OcBoardNum;/*а忨*/ + + m_OcConvertedPtDataArr[pOcOriginData->OcId].OcId = pOcOriginData->OcId; + InsertOcId(pOcOriginData->OcId);/*oc id*/ + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].BoardAddress = boardAddr;/*忨ֵַ*/ + + if (0U == cBoardState) + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].BoardState = RELAY_BOARD_FAULT_NO; /*忨״̬*/ + } + else + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].BoardState = RELAY_BOARD_FAULT_YES; /*忨״̬*/ + } + + for (k = 0; k<5; k++)/*SOR忨ز5ֽڣ10·ɼ*/ + { + byteRealy = pOcOriginData->OcSORBoardDatas[j].BoardCollData[k]; + + lowByte = byteRealy & 0x0fu;/*ֽڵ4λ*/ + highByte = (byteRealy >> 4) & 0x0fu;/*ֽڸ4λ*/ + + if (OC_RELAY_UP == (lowByte))/*5:*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k * 2] = RELAY_STATE_UP; + } + else if (OC_RELAY_DOWN == (lowByte))/*0xa:*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k * 2] = RELAY_STATE_DOWN; + } + else + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k * 2] = RELAY_STATE_DOWN; + } + + if (OC_RELAY_UP == (highByte))/*5:*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k * 2 + 1] = RELAY_STATE_UP; + } + else if (OC_RELAY_DOWN == (highByte))/*0xa:*/ + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k * 2 + 1] = RELAY_STATE_DOWN; + } + else + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k * 2 + 1] = RELAY_STATE_DOWN; + } +#if 0 + for (ii = 0; ii<8; ii++) + { + if (((byteRealy >> ii) & 0x1) == 0x1) + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k * 8 + ii] = RELAY_STATE_UP; + } + else + { + m_OcConvertedPtDataArr[pOcOriginData->OcId].BoardDatas[boardNum].PosValueBuf[k * 8 + ii] = RELAY_STATE_DOWN; + } + } +#endif + } + m_OcConvertedPtDataArr[pOcOriginData->OcId].OcBoardNum++; + } + } + } + else + { + /*ocIdڱ*/ + } + } +} + +UINT8 InitOcsBoardsIsScatter(void) +{ + UINT8 rtn = 0u; /*ֵ*/ + UINT8 *pData = NULL; /**/ + UINT32 dataLen = 0u; /*ݳ*/ + UINT8 readRtn = 0u; /**/ + UINT32 rowNum = 0u; /**/ + UINT32 i = 0u; /*ѭ*/ + UINT32 offset = 0u; /*ƫ*/ + UINT16 boardId = 0u; /*忨ID*/ + UINT16 ocId = 0u; /*OC ID*/ + UINT8 boardType = 0u; /*忨*/ + + readRtn = dquGetConfigData((const)DataPath, OC_DATA_TYPE, OC_IN_OUT_TYPE_ID, &pData, &dataLen); + if (1u == readRtn) /*ȡɹ*/ + { + if (0u < dataLen) /**/ + { + rowNum = dataLen / OC_IN_OUT_TYPE_LEN; /*ݵĸ*/ + if ((BOARD_SUM_MAX*OC_SUM_MAX) >= rowNum) + { + for (i = 0u; i < rowNum; i++) + { + boardId = ShortFromChar(&pData[offset]); /*忨ID*/ + offset += 2u; + ocId = ShortFromChar(&pData[offset]); /*OC ID*/ + offset += 2u; + boardType = pData[offset]; /*忨*/ + offset += 1u; + + if ((BOARD_SUM_MAX > boardId) && (OC_SUM_MAX > ocId) && (0x3cU == boardType)) + { + ocsBoardsIsScatter[ocId][boardId][0] = 1u;/*ɢ̵*/ + } + else if ((BOARD_SUM_MAX > boardId) && (OC_SUM_MAX > ocId) && (0xc8U == boardType)) + { + ocsBoardsIsScatter[ocId][boardId][0] = 2u; /*ȫ̵*/ + } + else if ((BOARD_SUM_MAX > boardId) && (OC_SUM_MAX > ocId)) + { + ocsBoardsIsScatter[ocId][boardId][0] = 0u; + } + else + { + rtn = 0U; + } + } + if (offset == dataLen) /*ȷ*/ + { + rtn = 1u; + } + } + } + } + + return rtn; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackOcData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackOcData.h new file mode 100644 index 0000000..b2fbffc --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackOcData.h @@ -0,0 +1,407 @@ +/******************************************************** +* +* ParsePackIoData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* IOݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_OC_DATA_H_ +#define _PARSE_PACK_OC_DATA_H_ + +#define USE_PROTOCOL_RSSP 1 + +#include "ParsePackDefine.h" +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "Convert.h" + +#include "../Route/RouteConfigDataManage.h" +#include "../Route/RouteDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Relay/RelayDefine.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../Signal/SignalDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Switch/SwitchDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "../psd/PSDConfigDataManage.h" +#include "../psd/PSDDataManage.h" +#include "../esb/ESBDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../Garagedoor/GaragedoorDataManage.h" + + +#define CI_OC_INTERFACE_INFOTYPE ((UINT16)0x0206) /*CI_OCӿϢ*/ + +#define CI_OC_PRTCL_VER ((UINT16)0x01) /*CI_OCЭ汾*/ + +#ifdef LOGPRINT +#include "../LogRecord/LogRecord.h" +#endif + +#define MAX_OC_DEVICE_NUM ((UINT16)150) /*һOCֶ֧ٸ豸*/ +#define MAX_OC_DI_BOARD_NUM ((UINT16)20) /*һOC֧DI忨*/ +#define MAX_OC_DO_BOARD_NUM ((UINT16)20) /*һOC֧DO忨*/ +#define MAX_OC_SOR_BOARD_NUM ((UINT16)20) /*һOC֧SOR忨*/ +#define MAX_OC_PLUS_BOX_NUM ((UINT16)3) /*һOCִ֧е*/ +#define MAX_OC_SWITCH_INCLUDE_ZZJ_NUM ((UINT16)4) /*һ֧ת޻*/ +#define MAX_OC_SWITCH_INCLUDE_BOARD_NUM ((UINT8)4) /*һ֧忨*/ + +#define Max_OC_GD_NUM ((UINT16)100) /*һoc֧ٸ*/ + +#define OC_CI_STATE_INFO ((UINT16)0x8802) /*OCCI״̬Ϣ*/ + +#define CI_OC_CONTROL_INFO ((UINT16)0x8801) /*CIOC*/ + +#define CI_OC_INTERFACE ((UINT16)0x0206) /*OC*/ + +#define OC_RELAY_UP ((UINT8)0x05) /*OC̵*/ +#define OC_RELAY_DOWN ((UINT8)0x0a) /*OC̵*/ + +#define OC_BOARD_STATE_NORMAL ((UINT8)0) /*oc忨״̬*/ + +typedef struct s_OcDevState +{ + UINT16 OcId;/*oc id*/ + UINT8 DeviceType; /*豸 1/2źŻ/3/CCɼ忨/DD忨*/ + UINT16 DeviceId; /*豸Id*/ + UINT8 DeviceState; /*豸״̬*/ + UINT8 chSwitchIncldeZzjNum; /*Ӧת޻Ŀ豸ΪźŻʱ,˸Ϊ0*/ + UINT8 szSwitchIncldeZzjState[MAX_OC_SWITCH_INCLUDE_ZZJ_NUM];/*ת޻״̬*/ + UINT8 BoardNum; /*忨*/ + UINT8 BoardAddr[MAX_OC_SWITCH_INCLUDE_BOARD_NUM]; /*忨ַ*/ + UINT8 BoardState[MAX_OC_SWITCH_INCLUDE_BOARD_NUM]; /*忨״̬ 0x0000 󷢴*/ +}OcDeviceStruct; + +typedef struct s_OcBoardData +{ + UINT8 BoardAddr; /*忨ַ*/ + UINT8 BoardState; /*忨״̬ 0x00 󷢴*/ + UINT8 BoardCollData[18]; /*ɼ*/ +}OcDIBoard; + +typedef struct s_OcGd +{ + UINT16 OcId; /*OC*/ + UINT16 GdDeviceId;/*Id*/ + UINT8 BoardAddr1; /*1ϵ忨ַ*/ + UINT8 BoardState1; /*1ϵ忨״̬ 0x0000 󷢴*/ + UINT8 GdState1;/*1ϵ忨ɼ״̬0x55壻0xAAռã0x5A*/ + + UINT8 BoardAddr2; /*1ϵ忨ַ*/ + UINT8 BoardState2; /*1ϵ忨״̬ 0x0000 󷢴*/ + UINT8 GdState2;/* 2ϵ忨ɼ״̬0x55壻0xAAռã0x5A*/ + + UINT8 GdMergeState;/*ں״̬*/ +}OcGdDevice; + +typedef struct s_OcDoBoard +{ + UINT8 DoBoardAddr; + UINT8 DoBoardState; +}OcDoBoard; + +typedef struct s_PlusBox +{ + UINT8 chPbId; /**/ + UINT8 chPbType; /* 0x55:źŻ䣬0xaa:ת޻*/ + UINT8 chAsState; /*տ״̬ λʾ1տ״̬λʾ2տ״̬0x50xaϣźŻ䣬ֻһտλЧת޻ߡλЧ*/ +}OcPlusBox; + +typedef struct S_OcToCiDataStruct +{ + UINT16 OcId; /*OC*/ + + UINT16 OcDeviceNum; /*һoc豸*/ + OcDeviceStruct OcDevices[MAX_OC_DEVICE_NUM]; /*һoc豸*/ + + UINT16 OcGdNum;/*һocйε*/ + OcGdDevice OcGdDevices[Max_OC_GD_NUM];/*һocй豸*/ + + UINT16 OcDIBoardDataNum; /*һocвɼ忨*/ + OcDIBoard OcDIBoardDatas[MAX_OC_DI_BOARD_NUM]; /*һocвɼ忨*/ + + UINT16 OcDOBoardNum;/*һOCвɼ忨*/ + OcDoBoard OcDOBoardDatas[MAX_OC_DO_BOARD_NUM]; /*OC忨*/ + + UINT16 OcSORBoardNum;/*һOC̵忨*/ + OcDIBoard OcSORBoardDatas[MAX_OC_SOR_BOARD_NUM]; /*OCİȫ忨*/ + + UINT8 PowerAState;/*AϵԴ״̬0x55-˫·տ0xaa-·տ쳣0xFF-˫·տ쳣*/ + UINT8 PowerBState;/*BϵԴ״̬0x55-˫·տ0xaa-·տ쳣0xFF-˫·տ쳣*/ + UINT8 OCDevFaultState;/*OC豸״̬0x55-忨0xFF-忨*/ + UINT8 FanState;/*״̬ 0x55-״̬0xaa-״̬쳣0xFF-״̬*/ + + UINT8 chPbNum;/*ִе*/ + OcPlusBox szPlusBox[MAX_OC_PLUS_BOX_NUM];/*ִеϢ*/ + + UINT16 OCBoardSwapSysNum;/*OCϵ忨*/ + UINT8 SwapSysBoardId[MAX_OC_DEVICE_NUM];/*OCϵ忨ID*/ + + UINT32 ComStartCycle; /*ͨſʼڣʹøжOCCIж*/ + + UINT16 RecvErrorDevTypeCycle; /*յ豸*/ +}OcToCiOriginDataStruct; + + +/*****************OC************************/ +typedef struct S_OcBoardDataStruct1 +{ + UINT8 BoardAddress; /*ӵַ*/ + UINT8 BoardState; /*忨״̬0x550xaa*/ + UINT8 PosValueBuf[OC_COLL_BOARD_POS_NUM]; /*Ӹλ*/ +}CollBoardData; + +typedef struct S_OcCollBoardDataStruct +{ + UINT16 OcId; + CollBoardData BoardDatas[Oc_Max_Board_Num]; + UINT16 OcBoardNum;/**/ +} OcCollBoardDataStruct;/*һOCIJɼ*/ + +typedef struct S_OcDevFaultStruct +{ + UINT16 OcId; + UINT8 PowerAState;/*AϵԴ״̬0x55-˫·տ0xaa-·տ쳣0xFF-˫·տ쳣*/ + UINT8 PowerBState;/*BϵԴ״̬0x55-˫·տ0xaa-·տ쳣0xFF-˫·տ쳣*/ + UINT8 OCDevFaultState;/*OC豸״̬0x55-忨0xFF-忨*/ + UINT8 FanState;/*״̬ 0x55-״̬0xaa-״̬쳣0xFF-״̬*/ +}OcFaultStateStruct;/*һOCĹ״̬ṹ*/ + +extern UINT16 LocalOcIds[OC_SUM_MAX];/*OC ID*/ + +extern OcToCiOriginDataStruct m_OcToCiOrginDataArr[OC_SUM_MAX]; /*OCCI֡ṹ,ԭʼݡ*/ +extern UINT8 m_OcToCiOrginDataNum; /*OcCiݵǰ*/ + + +extern OcCollBoardDataStruct m_OcConvertedPtDataArr[OC_SUM_MAX];/*CIյOCɼݡתĵλݡ*/ + +extern OcDeviceStruct m_Signals[CI_SIGNAL_MAX];/*OCźŻ豸*/ +extern UINT16 m_SignalNum; + +extern OcDeviceStruct m_Switches[CI_SWITCH_MAX];/*OCе豸*/ +extern UINT16 m_SwitchNum; + +extern OcGdDevice m_Gds[CI_GD_MAX];/*豸*/ +extern UINT16 m_GdNum; + +extern UINT8 xingshiTestStart; +extern UINT32 xingshiTestStartCycle; +extern UINT8 xingshiTestStop; +extern UINT32 xingshiTestStopCycle; + + +extern UINT8 ocsBoardsIsScatter[OC_SUM_MAX][BOARD_SUM_MAX][1]; + +extern OcFaultStateStruct m_OcFaultState[OC_SUM_MAX];/*CIյOC״̬*/ + + +#define OC_DEVICE_TYPE_SWITCH 1U /*oc豸 - */ +#define OC_DEVICE_TYPE_SIGNAL 2U /*oc豸 - źŻ*/ +/*****************OC************************/ + +/*OCӿڴͷ豸ֹ*/ +#define LEN_OC_UP_TO_DEV_NO 43U + +/*OC-100ӿʹ*/ +/*OCӿʼֹdevNo:豸*/ +#define LEN_OC_UP_TO_GD_NO(devNo) (LEN_OC_UP_TO_DEV_NO+(devNo)*8U+2U) + +/*OCӿʼDIֹdevNo:豸gdBoardNo*/ +#define LEN_OC_UP_TO_DIBOARD_NO(devNo,gdBoardNo) LEN_OC_UP_TO_GD_NO(devNo) +((gdBoardNo)*8U)+2U + +/*OCӿʼDOֹdevNo:豸gdBoardNo*/ +#define LEN_OC_UP_TO_DOBOARD_NO(devNo,gdBoardNo,diBoardNo) LEN_OC_UP_TO_DIBOARD_NO((devNo),(gdBoardNo))+20U*(diBoardNo)+2U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo*/ +#define LEN_OC_UP_TO_SIBOARD_NO(devNo,gdBoardNo,diBoardNo,doBoardNo) LEN_OC_UP_TO_DOBOARD_NO((devNo),(gdBoardNo),(diBoardNo))+2U*(doBoardNo)+2U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo siBoardNo:si*/ +#define LEN_OC_UP_TO_SOBOARD_NO(devNo,gdBoardNo,diBoardNo,doBoardNo,siBoardNo) LEN_OC_UP_TO_SIBOARD_NO((devNo),(gdBoardNo),(diBoardNo),(doBoardNo))+14U*(siBoardNo)+2U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo siBoardNo:si soBoardNo:so*/ +#define LEN_OC100_UP_TO_SWAPSYSBOARD_NO(devNo,gdBoardNo,diBoardNo,doBoardNo,siBoardNo,soBoardNo) LEN_OC_UP_TO_SOBOARD_NO((devNo),(gdBoardNo),(diBoardNo),(doBoardNo),(siBoardNo))+2U*(soBoardNo)+6U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo siBoardNo:si soBoardNo:so swapSysBoardNo:ϵ忨*/ +#define LEN_OC100_UP_TO_END(devNo,gdBoardNo,diBoardNo,doBoardNo,siBoardNo,soBoardNo,swapSysBoardNo) LEN_OC100_UP_TO_SWAPSYSBOARD_NO((devNo),(gdBoardNo),(diBoardNo),(doBoardNo),(siBoardNo),(soBoardNo))+(swapSysBoardNo) + + +/*OC-200ӿʹ*/ +/*OCӿʼֹdevNo:豸*/ +#define LEN_OC_UP_TO_GD_NO_200(zzjStateNo,switchNo,switchBoardNo,sianalNo) (LEN_OC_UP_TO_DEV_NO+2U +(switchNo)*5U+ switchBoardNo*2U+(zzjStateNo)*1U)+sianalNo*7U +/*OC2.1.6 OCӿʼֹdevNo:豸*/ +#define LEN_OC_UP_TO_GD_NO_200_2(devNo,zzjStateNo) (LEN_OC_UP_TO_DEV_NO+(devNo)* 9U+2U + (zzjStateNo)*1U) + +/*OCӿʼDIֹdevNo:豸gdBoardNo*/ +#define LEN_OC_UP_TO_DIBOARD_NO_200(startIndex,gdBoardNo) startIndex +((gdBoardNo)*8U)+2U + +/*OCӿʼDOֹdevNo:豸gdBoardNo*/ +#define LEN_OC_UP_TO_DOBOARD_NO_200(startIndex,gdBoardNo,diBoardNo) startIndex+((gdBoardNo)*8U)+2U+20U*(diBoardNo)+2U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo*/ +#define LEN_OC_UP_TO_SIBOARD_NO_200(startIndex,gdBoardNo,diBoardNo,doBoardNo) LEN_OC_UP_TO_DOBOARD_NO_200((startIndex),(gdBoardNo),(diBoardNo))+2U*(doBoardNo)+2U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo siBoardNo:si*/ +#define LEN_OC_UP_TO_SOBOARD_NO_200(startIndex,gdBoardNo,diBoardNo,doBoardNo,siBoardNo) LEN_OC_UP_TO_SIBOARD_NO_200((startIndex),(gdBoardNo),(diBoardNo),(doBoardNo))+14U*(siBoardNo)+2U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo siBoardNo:si soBoardNo:so*/ +#define LEN_OC_UP_TO_SORBOARD_NO_200(startIndex,gdBoardNo,diBoardNo,doBoardNo,siBoardNo,soBoardNo) LEN_OC_UP_TO_SOBOARD_NO_200((startIndex),(gdBoardNo),(diBoardNo),(doBoardNo),(siBoardNo))+soBoardNo*2U+1U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo siBoardNo:si soBoardNo:so sorBoardNo:sor*/ +#define LEN_OC_UP_TO_PLUSBOX_NO_200(startIndex,gdBoardNo,diBoardNo,doBoardNo,siBoardNo,soBoardNo,sorBoardNo) LEN_OC_UP_TO_SORBOARD_NO_200((startIndex),(gdBoardNo),(diBoardNo),(doBoardNo),(siBoardNo),(soBoardNo))+7U*(sorBoardNo)+5U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo siBoardNo:si soBoardNo:so sorBoardNo:sor pbNo:ִе*/ +#define LEN_OC_UP_TO_SWAPSYSBOARD_NO_200(startIndex,gdBoardNo,diBoardNo,doBoardNo,siBoardNo,soBoardNo, sorBoardNo,pbNo) LEN_OC_UP_TO_PLUSBOX_NO_200((startIndex),(gdBoardNo),(diBoardNo),(doBoardNo),(siBoardNo),(soBoardNo),(sorBoardNo))+3U*(pbNo)+2U + +/*OCӿʼdevNo:豸gdBoardNo, diBoardNodi doBoardNodo siBoardNo:si soBoardNo:so sorBoardNo:sor pbNo:ִе swapSysBoardNo:ϵ忨*/ +#define LEN_OC_UP_TO_END_200(startIndex,gdBoardNo,diBoardNo,doBoardNo,siBoardNo,soBoardNo,sorBoardNo,pbNo,swapSysBoardNo) LEN_OC_UP_TO_SWAPSYSBOARD_NO_200((startIndex),(gdBoardNo),(diBoardNo),(doBoardNo),(siBoardNo),(soBoardNo),(sorBoardNo),(pbNo))+(swapSysBoardNo) + + + +#ifdef __cplusplus +extern "C" { +#endif + + + + +/* +* IOCI֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseOcToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength,const UINT8 systemId); + +/* +* OC +* ˵ +* UINT8 deviceId, OCID +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToOcData( UINT8 deviceId); + +/* +* ѵλתΪ +* ˵ +* +* UINT8 drvColorλ +* ֵ 0:תʧ +* 1: +*/ +UINT16 ConvertSwitchDrvPosToSwDrvCmd(UINT8 drvPos); + +/* +* źŻɫתΪźŻ +* ˵ +* +* UINT8 drvColorźŻɫ +* ֵ 0:źŻתʧ +* 1:źŻ +*/ +UINT16 ConvertSigDrvColorToSigDrvCmd(const UINT16 signalId, const UINT8 drvColor); + + +/* +* ѽOC豸תΪOC źŻ OC 豸 +* ˵ void +* ֵ void +*/ +void ConvertOcOriginDataToOcSigSwDev(void); + +/* +* ѽOC忨תΪOCλ +* ˵ void +* ֵ void +*/ +void ConvertOcOriginDataToPtData(void); + +/* +* ʼOC豸 +* ˵ void +* ֵ void +*/ +void InitOcDevices(void); + +/* +* ʼOCźŻ +* ˵ void +* ֵ void +*/ +void InitOcSignals(void); + +/* +* ʼOC +* ˵ void +* ֵ void +*/ +void InitOcSwitchs(void); + +/* +* ʼOC +* ˵ void +* ֵ void +*/ +void InitOcGds(void); + +/* +* ͨźŻidȡ +* ˵ +* IdźŻ +* ֵ +* Int16:źŻId +*/ +INT16 GetIndexBySignalId(UINT16 sigId); + +/* +* ͨidȡ +* ˵ +* Id +* ֵ +* Int16:Id +*/ +INT16 GetIndexBySwitchId(UINT16 swId); + +/* +* ͨidȡ +* ˵ +* Id +* ֵ +* Int16:Id +*/ +INT16 GetIndexByGdId(UINT16 gdId); + + +/* +* УOcCIĵ֡ݳȺϷ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 CheckOc2CiDataLenValid(const UINT8* dataBuf, const UINT16 totalLength); + +/* +* oc״̬ +* ˵ const UINT8 ocId, ocId +* ֵ void +* +*/ +void ResetOcOriginalState(const UINT8 ocId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackPSCData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackPSCData.c new file mode 100644 index 0000000..f1bfb50 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackPSCData.c @@ -0,0 +1,453 @@ +/******************************************************** +* +* ParsePackPSCData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-25 +* ߣ +* PSDݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + + +#include "ParsePackPSCData.h" +#include "CommonMemory.h" +#include "../QueryFiles/dquCIInterFace.h" +#include "../PSC/PSCConfigDataManage.h" + +/*վӳ + stationId == 1,ӳ䵽pscToCiDataStru[1] +*/ +PSCToCiDataStruct PscToCiDataStru[PSC_TO_CI_SUM_MAX] = {0u}; + +/*PlatformToCiDataStructṹеλ:PsdӳΪУPsdվӳΪһУPsdToCiDataStructλӳΪ2 + 1platformToCiDataStruеλΪ:վΪPsdPlatformIndex[1][0] ,ŵĽṹλΪPsdPlatformIndex[1][1] +*/ +UINT8 PscIndex[PSD_SUM_MAX][2] = {0u}; + + +/* +* վ̨ſݽṹʼ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 InitialPscToCiData(void) +{ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT16 psdId = 0u; + UINT8 pscId = 0u; + UINT8 deviceSum =0u;/*ͨ豸*/ + UINT8* deviceIdBuf = NULL;/*ͨ豸ID*/ + UINT8 psdSum = (UINT8)PSC_INCLUDE_PSD_MAX_SUM; + UINT8 retVal = CI_SUCCESS; + PscConfigDataStruct *pPSC = NULL; + deviceSum = (UINT8)GetPscCurSum(); /*ȡͨPSC豸*/ + pPSC = GetPscConfigData();/*᷵NULL*/ + if (0u < deviceSum) + {/*Чж*/ + for (ii = 0u; ii < deviceSum; ii++) + {/*뱾CIͨŵվ̨ϵͳ*/ + pscId = (UINT8)(pPSC[ii].PscId); + + if(PSC_TO_CI_SUM_MAX <= pscId) + {/*PSCϵͳIDϷ*/ + retVal = CI_ERROR; + break; + } + for (jj = 0u; jj < pPSC[ii].psdSum; jj++) + {/*뱾CIͨŵվ̨ϵͳ*/ + /*ʼPscToCiDataStru*/ + PscToCiDataStru[pscId].pscId = pscId; + psdId = pPSC[ii].psdIdBuff[jj]; + PscToCiDataStru[pscId].psdDataStr[jj].psdId = psdId; + PscToCiDataStru[pscId].psdDataStr[jj].psdState = PSD_STATE_INVALID_HLHT; + PscToCiDataStru[pscId].psdDataStr[jj].psdMLockState = PSD_MUTUALLOCK_REMOVE_DEFAULT; + PscToCiDataStru[pscId].psdDataStr[jj].psdFaultQStataOne = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[jj].psdFaultQStataTwo = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[jj].psdDoorsStateOne = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[jj].psdDoorsStateTwo = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[jj].psdDoorIStateOne = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[jj].psdDoorIStateTwo = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[jj].psdAtsMlockState = PSD_MUTUALLOCK_REMOVE_NO; + + PscToCiDataStru[pscId].psdSum = (UINT8)(pPSC[ii].psdSum); + /*ʼPsdPlatformIndex*/ + PscIndex[psdId][0] = pscId; + PscIndex[psdId][1] = (UINT8)jj; + + } + } + } + + return retVal; +} + +/* +* PSC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParsePscToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId) +{ + UINT8 retVal = CI_SUCCESS; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT16 appInfoType = 0u; /*ӦϢ*/ + UINT32 psdId = 0u; /*PSD */ + UINT16 psdIndexId = 0u; /*PSD ID*/ + UINT8 psdSum = 0u; + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT8 rowIndex = 0u; + UINT8 colIndex = 0u; + UINT8 fucRetun = 0u; + UINT32 curCycleNum = 0u; + UINT8 setCycNum = 0u; + UINT8 updateCycNum = 0u; + + curCycleNum = Get2oo2CurCycleNum(); /*ȡǰں*/ + + if (CI_PSC_INTERFACE_INFOTYPE != ShortFromChar(&dataBuf[ii])) + {/*վ̨ſ͵*/ + retVal = CI_ERROR; + } + ii += 2u; + ii += 2u;/*Ӧñij2ֽ*/ + if(CI_SUCCESS == retVal) + { + /*ͨ*/ + setCycNum = SetCiTransmitRecvDataCycNum(localCiId, CI_SYSTEM_TYPE_PSC, systemId, curCycleNum); + if (CI_ERROR == setCycNum) + {/*ʧ*/ + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + updateCycNum = UpdateCiTransmitState(localCiId, CI_SYSTEM_TYPE_PSC, systemId); + if(CI_ERROR == updateCycNum) + { + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + if (systemId < PSC_TO_CI_SUM_MAX) + { + /*Ӧ*/ + appInfoType = ShortFromChar(&dataBuf[ii]);/*CIPSCͨŵӦòϢ*/ + ii += 2u; + PscToCiDataStru[systemId].appInfoType = appInfoType; + PscToCiDataStru[systemId].pscId = systemId; + + ii += 2u;/*Ԥֽ*/ + + if (PSC_CI_INFO_TYPE_PSD_STATE == appInfoType) + { + PscToCiDataStru[systemId].devType_PSC_A_WORK_STATE = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC Aϵ״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_B_WORK_STATE = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC Bϵ״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_SINGLE_COMM_STATE = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC ͨŰ״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_FSIO_FAULT_STATE = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC FSIO״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_DRIVE_POWER_STATE = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC Դ״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_CONTROL_POWER_STATE = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC ƵԴ״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_Q_IM_1_STATE = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC ӿģ1״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_Q_IM_2_STATE = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC ӿģ2״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_OPEN_FAULT_STATE_UP = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC пŹ״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_CLOSE_FAULT_STATE_UP = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC йŹ״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_OPEN_FAULT_STATE_DOWN = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC пŹ״̬ʾ*/ + PscToCiDataStru[systemId].devType_PSC_CLOSE_FAULT_STATE_DOWN = dataBuf[ii]; /*ȡ*/ + ii += 1u; /*PSC йŹ״̬ʾ*/ + + psdSum = dataBuf[ii]; + PscToCiDataStru[systemId].psdSum = psdSum; /*ȡ*/ + ii += 1u; + + for(jj = 0u;jj < psdSum;jj++) + { + psdId = LongFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 4u; + + fucRetun = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdId, &psdIndexId); + + if (fucRetun > 0u) + { + rowIndex = PscIndex[psdIndexId][0];/*ȡӳ:վ̨ϵͳID*/ + colIndex = PscIndex[psdIndexId][1];/*ȡӳ:վ̨ϵͳṹУ*/ + + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdId = psdIndexId; + + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdState = dataBuf[ii++];/*PSD״̬*/ + + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdMLockState = dataBuf[ii++];/*״̬*/ + /*ϸ״̬1*/ + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdFaultQStataOne = LongFromChar(&dataBuf[ii]); + ii += 4u; + /*ϸ״̬2*/ + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdFaultQStataTwo = LongFromChar(&dataBuf[ii]); + ii += 4u; + /*ÿ״̬1*/ + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdDoorsStateOne = LongFromChar(&dataBuf[ii]); + ii += 4u; + /*ÿ״̬2*/ + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdDoorsStateTwo = LongFromChar(&dataBuf[ii]); + ii += 4u; + /*ÿű״̬1*/ + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdDoorIStateOne = LongFromChar(&dataBuf[ii]); + ii += 4u; + /*ÿű״̬2*/ + PscToCiDataStru[rowIndex].psdDataStr[colIndex].psdDoorIStateTwo = LongFromChar(&dataBuf[ii]); + ii += 4u; + + } + /*վ̨ŽӦֽ*/ + else + { + ii += 26u; + } + } + } + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + + return retVal; +} + +/* +* PSC +* ˵ UINT8 deviceId, Ŀ豸ID +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToPscData(UINT8 deviceId) +{ + UINT8 localCi = GetSystemParaLocalCiId(); /*ID*/ + UINT8 CiToPscDataBuffer[PSC_TO_CI_DATA_LEN_MAX] = {0u}; /*CIPSC֡*/ + UINT16 devCurSum = 0u; /*豸*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devType = 0u; /*豸*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 indicatorState = 0u; + UINT8 retVal = 0u; + UINT16 temDatalen = 0u; + UINT16 temDataLenIndex = 0u; + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + + + /*ͨЭ֡ͷ*/ + ii += 2u; + CiToPscDataBuffer[ii++] = CI_SYSTEM_TYPE_PSC; /*Ŀ߼*/ + CiToPscDataBuffer[ii++] = deviceId; /*Ŀ߼ID*/ + CiToPscDataBuffer[ii++] = 0u; /*Ԥ2Byte*/ + CiToPscDataBuffer[ii++] = 0u; + /*ʼӦ֡*/ + ShortToChar(CI_PSC_INTERFACE_INFOTYPE,&CiToPscDataBuffer[ii]); /*ӿϢ*/ + ii += 2u; + temDataLenIndex = ii; /*¼ܳλ*/ + ii += 2u; + + /*ΪӦò*/ + ShortToChar(CI_PSC_INFO_TYPE_PSD_STATE, &CiToPscDataBuffer[ii]); + ii += 2u; + /*Ԥֽ*/ + ii += 2u; + + devCurSum = GetIndicatorCurSum(); /*ȡָʾǰ*/ + + for (jj = 0u; jj < devCurSum; jj++) + { + devId = GetIndicatorId(jj); /*ȡָʾID*/ + devType = GetIndicatorType(devId); /*ȡ豸*/ + + /*###ָʾơ###*/ + if (INDICATOR_TYPE_POWER_SCREEN == devType) + { + indicatorState = GetIndicatorState(devId); /*ʾƱ״̬*/ + if ((INDICATOR_SHOW_YES != indicatorState) && (INDICATOR_SHOW_NO != indicatorState)) + { + CiToPscDataBuffer[ii++] = ALARM_STATE_DEFAULT; /*õԴĬֵ*/ + } + else + { + if (INDICATOR_SHOW_YES != indicatorState) + { /*̵ʾЧ*/ + CiToPscDataBuffer[ii++] = ALARM_STATE_NO; /*õԴЧ*/ + } + else + { + CiToPscDataBuffer[ii++] = ALARM_STATE_YES; /*õԴЧ*/ + } + } + + indicatorState = 0u;/*Դ״̬*/ + } + else if (INDICATOR_TYPE_EXPRESS_MAINP == devType) + {/*Դָʾ*/ + indicatorState = GetIndicatorState(devId); /*ʾƱ״̬*/ + if ((INDICATOR_SHOW_YES != indicatorState) && (INDICATOR_SHOW_NO != indicatorState)) + { + CiToPscDataBuffer[ii++] = ALARM_STATE_DEFAULT; /*õԴĬֵ*/ + } + else + { + if (INDICATOR_SHOW_YES != indicatorState) + {/*̵ʾЧ*/ + CiToPscDataBuffer[ii++] = ALARM_STATE_NO; /*õԴЧ*/ + } + else + { + CiToPscDataBuffer[ii++] = ALARM_STATE_YES; /*õԴЧ*/ + } + } + indicatorState = 0u;/*Դ״̬*/ + } + else if (INDICATOR_TYPE_EXPRESS_BACKP == devType) + {/*Դָʾ*/ + indicatorState = GetIndicatorState(devId); /*ʾƱ״̬*/ + if ((INDICATOR_SHOW_YES != indicatorState) && (INDICATOR_SHOW_NO != indicatorState)) + { + CiToPscDataBuffer[ii++] = ALARM_STATE_DEFAULT; /*õԴĬֵ*/ + } + else + { + if (INDICATOR_SHOW_YES != indicatorState) + {/*̵ʾЧ*/ + CiToPscDataBuffer[ii++] = ALARM_STATE_NO; /*õԴЧ*/ + } + else + { + CiToPscDataBuffer[ii++] = ALARM_STATE_YES; /*õԴЧ*/ + } + } + indicatorState = 0u;/*Դ״̬*/ + } + else + {/*ָʾ*/ + + } + } + /*ȥͨ֡ͷԼܳ2ֽ*/ + temDatalen = ii - 2U - temDataLenIndex; + + /*дӦò㱨ܳ*/ + ShortToChar(temDatalen,&CiToPscDataBuffer[temDataLenIndex]); + + dstDevId = ((UINT16)(CI_SYSTEM_TYPE_PSC << 8u) | ((UINT16)deviceId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &CiToPscDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nPSC_SEND:%d", ii); + debug_out_array(0xAA, CiToPscDataBuffer, ii); +#endif/*ƽ̨ӡ*/ +#endif + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + + return retVal; +} + +/* +* ȡPsc-CIĽṹ +* ˵ void +* ֵ Psc-CIṹָ +*/ +PSCToCiDataStruct* GetPscToCiDataStru(void) +{ + return PscToCiDataStru; +} + +/* +* ΪָPSD->CIĽṹȱʡֵ(ȫֵ) +* ˵ platformId:PSDϵͳID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 SetPscToCiDefaultDataStru(UINT8 pscId) +{ + UINT8 retVal = 0u; + UINT8 ii; + UINT8 psdVirArr = 0u; + + if(PSC_TO_CI_SUM_MAX <= pscId) + { + retVal = CI_ERROR; + } + else + { + PscToCiDataStru[pscId].devType_PSC_A_WORK_STATE = ALARM_STATE_DEFAULT; + /*PSC Aϵ״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_B_WORK_STATE = ALARM_STATE_DEFAULT; + /*PSC Bϵ״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_SINGLE_COMM_STATE = ALARM_STATE_YES; + /*PSC ͨŰ״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_FSIO_FAULT_STATE = ALARM_STATE_YES; + /*PSC FSIO״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_DRIVE_POWER_STATE = ALARM_STATE_YES; + /*PSC Դ״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_CONTROL_POWER_STATE = ALARM_STATE_YES; + /*PSC ƵԴ״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_Q_IM_1_STATE = ALARM_STATE_YES; + /*PSC ӿģ1״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_Q_IM_2_STATE = ALARM_STATE_YES; + /*PSC ӿģ2״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_OPEN_FAULT_STATE_UP = ALARM_STATE_YES; + /*PSC пŹ״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_CLOSE_FAULT_STATE_UP = ALARM_STATE_YES; + /*PSC йŹ״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_OPEN_FAULT_STATE_DOWN = ALARM_STATE_YES; + /*PSC пŹ״̬ʾ*/ + PscToCiDataStru[pscId].devType_PSC_CLOSE_FAULT_STATE_DOWN = ALARM_STATE_YES; + + for(ii = 0u;ii < PscToCiDataStru[pscId].psdSum;ii++) + { + psdVirArr = GetPsdVirtualAttribute(PscToCiDataStru[pscId].psdDataStr[ii].psdId); + if (PSD_VIRTUAL_ATTR_YES != psdVirArr) + {/*Ų*/ + PscToCiDataStru[pscId].psdDataStr[ii].psdState = PSD_STATE_INVALID_HLHT; + PscToCiDataStru[pscId].psdDataStr[ii].psdMLockState = PSD_MUTUALLOCK_REMOVE_DEFAULT; + /*ÿPSCͨжʱдĬֵ*/ + PscToCiDataStru[pscId].psdDataStr[ii].psdFaultQStataOne = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[ii].psdFaultQStataTwo = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[ii].psdDoorsStateOne = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[ii].psdDoorsStateTwo = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[ii].psdDoorIStateOne = 0xffffffffu; + PscToCiDataStru[pscId].psdDataStr[ii].psdDoorIStateTwo = 0xffffffffu; + } + } + retVal = CI_SUCCESS; + } + return retVal; +} diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackPSCData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackPSCData.h new file mode 100644 index 0000000..ae0eaf0 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackPSCData.h @@ -0,0 +1,137 @@ +/******************************************************** +* +* ParsePackPSCData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-25 +* ߣ +* PSDݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_PSC_DATA_H_ +#define _PARSE_PACK_PSC_DATA_H_ + + +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "CiInterfaceDefine.h" +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../PSD/PSDConfigDataManage.h" +#include "../PSC/PSCConfigDataManage.h" +#ifdef __cplusplus +extern "C" { +#endif + + +#define CI_PSC_INTERFACE_INFOTYPE ((UINT16)0x0401) /*CI_PSCӿϢ*/ +#define CI_PSC_INFO_TYPE_PSD_STATE ((UINT16)0x0402) /*CI=>PSC״̬Ϣ*/ +#define PSC_CI_INFO_TYPE_PSD_STATE ((UINT16)0x0403) /*PSC=>CI״̬Ϣ*/ + + +/*Ϣʾ״̬*/ +#define ALARM_STATE_NO ((UINT8)0x55) /**/ +#define ALARM_STATE_YES ((UINT8)0xAA) /**/ +#define ALARM_STATE_DEFAULT ((UINT8)0xFF) /*Ĭֵ*/ + +/*˫ϵϢʾ״̬*/ +#define ALARM_MAIN_WORK_STATE ((UINT8)0x55) /*״̬*/ +#define ALARM_BACKUP_WORK_STATE ((UINT8)0xAA) /*״̬*/ +#define ALARM_DEFAULT_WORK_STATE ((UINT8)0xFF) /*״̬*/ + +/*ͨŵPsdϢ*/ +typedef struct S_PsdToPscDataStruct +{ + UINT16 psdId; /*Psd ID*/ + UINT8 psdState; /*Psd״̬ţ0x55ţ0xaa*/ + UINT8 psdMLockState; /*Ϣδ 0x55; 0xaa*/ + UINT32 psdFaultQStataOne; /*ϸϢǰĸֽ*/ + UINT32 psdFaultQStataTwo; /*ϸϢĸֽ*/ + UINT32 psdDoorsStateOne; /*ÿŵĿ״̬ǰĸֽ*/ + UINT32 psdDoorsStateTwo; /*ÿŵĿ״̬ĸֽ*/ + UINT32 psdDoorIStateOne; /*ÿŵıϢǰĸֽ*/ + UINT32 psdDoorIStateTwo; /*ÿŵıϢĸֽ*/ + UINT8 psdAtsMlockState; /*ATSȷϻ״̬δ 0x55; 0xaa*/ +} PsdToPscDataStruct; + + +typedef struct S_PSCToCiDataStruct +{ + UINT8 pscId; + UINT16 appInfoType; /*ӦϢ*//*վ:ֶ*/ + UINT8 psdSum; + UINT8 devType_PSC_A_WORK_STATE; /*PSC Aϵ״̬ʾ*/ + UINT8 devType_PSC_B_WORK_STATE; /*PSC Bϵ״̬ʾ*/ + UINT8 devType_PSC_SINGLE_COMM_STATE; /*PSC ͨŰ״̬ʾ*/ + UINT8 devType_PSC_FSIO_FAULT_STATE; /*PSC FSIO״̬ʾ*/ + UINT8 devType_PSC_DRIVE_POWER_STATE; /*PSC Դ״̬ʾ*/ + UINT8 devType_PSC_CONTROL_POWER_STATE; /*PSC ƵԴ״̬ʾ*/ + UINT8 devType_PSC_Q_IM_1_STATE; /*PSC ӿģ1״̬ʾ*/ + UINT8 devType_PSC_Q_IM_2_STATE; /*PSC ӿģ2״̬ʾ*/ + UINT8 devType_PSC_OPEN_FAULT_STATE_UP; /*PSC пŹ״̬ʾ*/ + UINT8 devType_PSC_CLOSE_FAULT_STATE_UP; /*PSC йŹ״̬ʾ*/ + UINT8 devType_PSC_OPEN_FAULT_STATE_DOWN; /*PSC пŹ״̬ʾ*/ + UINT8 devType_PSC_CLOSE_FAULT_STATE_DOWN; /*PSC йŹ״̬ʾ*/ + /*: ֶ*/ + PsdToPscDataStruct psdDataStr[PSC_INCLUDE_PSD_MAX_SUM]; /*Ϣṹ*/ +} PSCToCiDataStruct; + +/*******************************ȫֱ*******************************/ +extern PSCToCiDataStruct PscToCiDataStru[PSC_TO_CI_SUM_MAX]; +extern UINT8 PscIndex[PSD_SUM_MAX][2]; + +/* +* վ̨ݽṹʼ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 InitialPscToCiData(void); + + +/* +* PSD֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParsePscToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId); + + +/* +* PSD +* ˵ QueueStruct* CiToPscDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToPscData(UINT8 deviceId); + + +/* +* ȡPlatform-CIĽṹ +* ˵ void +* ֵ Platform-CIṹָ +*/ +PSCToCiDataStruct* GetPscToCiDataStru(void); + +/* +* ΪָPSD->CIĽṹȱʡֵ(ȫֵ) +* ˵ platformId:PSDϵͳID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 SetPscToCiDefaultDataStru(UINT8 pscId); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackPlatformData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackPlatformData.c new file mode 100644 index 0000000..99aca40 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackPlatformData.c @@ -0,0 +1,425 @@ +/******************************************************** +* +* ParsePackPlatformData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-25 +* ߣ +* PSDݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + + +#include "ParsePackPlatformData.h" + + +/*վӳ + stationId == 1,ӳ䵽platformToCiDataStru[1] +*/ +PlatformToCiDataStruct platformToCiDataStru[PLATFORM_TO_CI_SUM_MAX] = {0u}; + +/*PlatformToCiDataStructṹеλ:PsdӳΪУPsdվӳΪһУPsdToCiDataStructλӳΪ2 + 1platformToCiDataStruеλΪ:վΪPsdPlatformIndex[1][0] ,ŵĽṹλΪPsdPlatformIndex[1][1] +*/ +UINT8 PsdPlatformIndex[PSD_SUM_MAX][2] = {0u}; + + + + + +/* +* վ̨ݽṹʼ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 InitialPlatformData(void) +{ + UINT16 ii = 0U; + UINT16 psdId = 0U; + UINT8 belongStationId = 0U; + UINT8 psdSum = 0U; + UINT8 retVal = CI_SUCCESS; + UINT8 lineIdentity = 0U; + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡVOBC-CIӿڱʶ*/ + for(ii = 0U; ii < GetTotalPsdCurNum();ii++) + { + psdId = GetPsdId(ii); + belongStationId = GetPsdBelongStationId(psdId); /*ȡվID*/ + if(PLATFORM_TO_CI_SUM_MAX <= belongStationId) + {/*Ŀǰһվһվ̨ϵͳվID <==> վ̨ϵͳID*/ + /*ΪûжӦվ̨ϵͳسɹ*/ + retVal = CI_SUCCESS; + break; + } + + psdSum = platformToCiDataStru[belongStationId].psdSum; + + if(psdSum < PLATFORM_INCLUDE_PSD_MAX_SUM) + {/*ֹԽ*/ + /*ʼplatformToCiDataStru*/ + platformToCiDataStru[belongStationId].stationId = belongStationId; + platformToCiDataStru[belongStationId].psdDataStr[psdSum].PsdId = psdId; + if (LINE_FAO == lineIdentity) + { /*෿Ĭ4*/ + platformToCiDataStru[belongStationId].psdDataStr[psdSum].doorEditGroupInfo = PSD_FOUR_EDIT_GROUP_FAO_YF; + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity)) + { /*»ĬΪ0*/ + platformToCiDataStru[belongStationId].psdDataStr[psdSum].doorEditGroupInfo = 0U; + } + else + {/*·*/ + } + + platformToCiDataStru[belongStationId].psdDataStr[psdSum].faultIsolationRequestInfo = 0U;/*20161027гCIͨʱCIгδPSD*/ + platformToCiDataStru[belongStationId].psdDataStr[psdSum].faultIsolationReplyInfo = PSD_DEFAULT_FAULT_ISOLATION; + platformToCiDataStru[belongStationId].psdDataStr[psdSum].doorHaveOrNot = PSD_HAVE_TRAIN_DOOR_NO; + platformToCiDataStru[belongStationId].psdDataStr[psdSum].psdState = 0xFFFFFFFFU; + platformToCiDataStru[belongStationId].psdDataStr[psdSum].psdOpenCloseState[0] = 0U;/*ÿ״̬Ϊ򿪣ʼֵ*/ + platformToCiDataStru[belongStationId].psdDataStr[psdSum].psdOpenCloseState[1] = 0U;/*ÿ״̬Ϊ򿪣ʼֵ*/ + + /*ʼPsdPlatformIndex*/ + PsdPlatformIndex[psdId][0] = belongStationId; + PsdPlatformIndex[psdId][1] = psdSum; + + platformToCiDataStru[belongStationId].psdSum++; + + + } + + + + } + return retVal; + +} + + +/* +* PSD֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParsePlatformToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId) +{ + UINT8 retVal = CI_SUCCESS; + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + UINT16 psdId = 0u; /*PSD */ + UINT16 psdSum = 0u; + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 rowIndex = 0u; + UINT8 colIndex = 0u; + UINT8 lineIdentity = 0u; + + if (dataBuf[ii++] != CI_SYSTEM_TYPE_PLATFORM) + {/*վ̨ϵͳ͵*/ + + retVal = CI_ERROR; + } + + /*վ̨ϵͳID*/ + ii++; + + if(CI_SUCCESS == retVal) + { + if (dataBuf[ii++] != Get2oo2SheBeiType()) + {/*Ƿ͵豸*/ + + retVal = CI_ERROR; + } + } + if(CI_SUCCESS == retVal) + { + if (dataBuf[ii++] != localCiId) + {/*Ƿ͵*/ + + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + /*ͨ*/ + if (SetCiTransmitRecvDataCycNum(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_PLATFORM, systemId, Get2oo2CurCycleNum()) == CI_ERROR) + {/*ʧ*/ + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + if(UpdateCiTransmitState(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_PLATFORM, systemId) == CI_ERROR) + { + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡVOBC-CIӿڱʶ*/ + + psdSum = ShortFromChar(&dataBuf[ii]); /*ȡ*/ + ii += 2u; + + for(jj = 0u;jj < psdSum;jj++) + { + psdId = ShortFromChar(&dataBuf[ii]); /*ȡID*/ + ii += 2u; + + rowIndex = PsdPlatformIndex[psdId][0];/*ȡӳ:վ̨ϵͳID*/ + colIndex = PsdPlatformIndex[psdId][1];/*ȡӳ:վ̨ϵͳṹУ*/ + + platformToCiDataStru[rowIndex].psdDataStr[colIndex].PsdId = psdId; + + if (LINE_FAO == lineIdentity) + {/*FAO·*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo = LongFromChar(&dataBuf[ii]);/*ȫŹ״̬*/ + ii += 4u; + + platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState = LongFromChar(&dataBuf[ii]);/*ȫ״̬*/ + ii += 4u; + } + else + {/*·ͣ*/ + } + } + + retVal = CI_SUCCESS; + } + + + + return retVal; +} + +/* +* PSD +* ˵ QueueStruct* CiToPlatformDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToPlatformData(UINT8 deviceId) +{ + UINT8 localCi = GetSystemParaLocalCiId(); /*ID*/ + UINT8 CiToPsdDataBuffer[PLATFORM_TO_CI_DATA_LEN_MAX] = {0u}; /*CIPSD֡*/ + UINT16 psdId = 0u; /*ID*/ + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT8 psdSum = 0u; + UINT8 retVal = 0u; + UINT8 lineIdentity = 0u; + UINT32 faultIsolutionInfo = 0u; + UINT32 vobc2PsdFaultIsolation[2] = {0u,0u}; + + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡVOBC-CIӿڱʶ*/ + + /*ʼӦ֡*/ + CiToPsdDataBuffer[ii++] = Get2oo2SheBeiType(); + CiToPsdDataBuffer[ii++] = localCi; + CiToPsdDataBuffer[ii++] = CI_SYSTEM_TYPE_PLATFORM; + CiToPsdDataBuffer[ii++] = deviceId; + + + + psdSum = platformToCiDataStru[deviceId].psdSum; + CiToPsdDataBuffer[ii++] = psdSum; /**/ + + for(jj = 0u;jj < psdSum ;jj++) + { /*վ̨ϵͳ*/ + psdId =platformToCiDataStru[deviceId].psdDataStr[jj].PsdId; /*ID*/ + ShortToChar(psdId,&CiToPsdDataBuffer[ii]); + ii += 2u; + + CiToPsdDataBuffer[ii++] = platformToCiDataStru[deviceId].psdDataStr[jj].doorHaveOrNot; /*Ϣ*/ + /*platformToCiDataStru[deviceId].psdDataStr[jj].doorHaveOrNot = PSD_HAVE_TRAIN_DOOR_NO;*/ /*޸ǰɺΪ޳Ϣ޸ĺVOBCͨжϺ޳Ϣ*/ + + if (LINE_FAO == lineIdentity) + {/*FAO·*/ + faultIsolutionInfo = platformToCiDataStru[deviceId].psdDataStr[jj].faultIsolationRequestInfo; + LongToChar(faultIsolutionInfo,&CiToPsdDataBuffer[ii]); /*ϸϢ*/ + ii += 4u; + } + else + { + /*do nothing*/ + } + + + /*ղVOBCݣCIжVOBCͨжǰPSDʹVOBCյĹϸϢĬֵ*/ +#if 0 + /*20161027󣺵CIVOBCͨжʱҲгδPSD*/ + platformToCiDataStru[deviceId].psdDataStr[jj].faultIsolationRequestInfo = 0;/*ɺPSDĬδϸ״̬*/ +#endif + + CiToPsdDataBuffer[ii++] = platformToCiDataStru[deviceId].psdDataStr[jj].doorEditGroupInfo; /*űϢ*/ + + } + + dstDevId = ((UINT16)(CI_SYSTEM_TYPE_PLATFORM << 8u) | ((UINT16)deviceId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &CiToPsdDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nPSD_SEND:%d", ii); + debug_out_array(0xAA, CiToPsdDataBuffer, ii); +#endif/*ƽ̨ӡ*/ + +#endif + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + + return retVal; +} + +/* +* ȡPlatform-CIĽṹ +* ˵ void +* ֵ Platform-CIṹָ +*/ +PlatformToCiDataStruct * GetPlatformToCiDataStru(void) +{ + return platformToCiDataStru; +} + +/* +* ΪָPSD->CIĽṹȱʡֵ(ȫֵ) +* ˵ platformId:PSDϵͳID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 SetPlatformToCiDefaultDataStru(UINT8 platformId) +{ + UINT8 retVal = 0u; + UINT8 ii; + if(PLATFORM_TO_CI_SUM_MAX <= platformId) + { + retVal = CI_ERROR; + } + else + { + for(ii = 0u;ii < platformToCiDataStru[platformId].psdSum;ii++) + { + if (PSD_VIRTUAL_ATTR_YES != GetPsdVirtualAttribute(platformToCiDataStru[platformId].psdDataStr[ii].PsdId)) + {/*Ų*/ + platformToCiDataStru[platformId].psdDataStr[ii].faultIsolationReplyInfo = PSD_DEFAULT_FAULT_ISOLATION; + platformToCiDataStru[platformId].psdDataStr[ii].psdState = 0xFFFFFFFFU; + } + } + retVal = CI_SUCCESS; + } + return retVal; +} + +/* +* ָIDŹϸ״̬ +* ˵ const UINT16 doorId, ID +* const UINT32 isolateState, Źϸ״̬ +* ֵ +* +*/ +void SetPsdIsolateState(const UINT16 doorId, const UINT32 isolateState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 belongStationId = 0u;/*PSDվID*/ + UINT8 ii = 0u; + UINT8 jj = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + belongStationId = GetPsdBelongStationId(doorId);/*ȡPSDվID*/ + for (ii = 0u; ii < PLATFORM_TO_CI_SUM_MAX;ii++) + {/*վ̨ϵͳ*/ + if (belongStationId == platformToCiDataStru[ii].stationId) + { + for (jj = 0u;jj < platformToCiDataStru[ii].psdSum;jj++) + {/*վ̨ϵͳPSD*/ + if (doorId == platformToCiDataStru[ii].psdDataStr[jj].PsdId) + {/*վ̨ϵͳҵPSDùϸϢ*/ + platformToCiDataStru[ii].psdDataStr[jj].faultIsolationReplyInfo = isolateState; + break;/*ҵ˳*/ + } + else + { + } + } + break;/*ҵ˳*/ + } + else + { + ; + } + } + } + else + { + /**/ + } +} + +/* +* ȡָIDŹϸ״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: δϸ +* >0: ϸ +*/ +UINT32 GetPsdIsolateState(const UINT16 doorId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 psdIsolateState = 0u;/*ϸ״̬*/ + UINT8 belongStationId = 0u;/*PSDվID*/ + UINT8 ii = 0u; + UINT8 jj = 0u; + + bufIndex = GetPsdConfigBufIndex(doorId); /*ȡ±*/ + + if (PSD_SUM_MAX > bufIndex) + { + belongStationId = GetPsdBelongStationId(doorId);/*ȡPSDվID*/ + for (ii = 0u; ii < PLATFORM_TO_CI_SUM_MAX;ii++) + {/*վ̨ϵͳ*/ + if (belongStationId == platformToCiDataStru[ii].stationId) + { + for (jj = 0u;jj < platformToCiDataStru[ii].psdSum;jj++) + {/*վ̨ϵͳPSD*/ + if (doorId == platformToCiDataStru[ii].psdDataStr[jj].PsdId) + {/*վ̨ϵͳҵPSDȡϸϢ*/ + psdIsolateState = platformToCiDataStru[ii].psdDataStr[jj].faultIsolationReplyInfo; + break;/*ҵ˳*/ + } + else + { + } + } + break;/*ҵ˳*/ + } + else + { + } + } + } + else + { + psdIsolateState = 0u; + } + return psdIsolateState; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackPlatformData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackPlatformData.h new file mode 100644 index 0000000..d0f356e --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackPlatformData.h @@ -0,0 +1,124 @@ +/******************************************************** +* +* ParsePackPlatformData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-25 +* ߣ +* PSDݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_PLATFORM_DATA_H_ +#define _PARSE_PACK_PLATFORM_DATA_H_ + + +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "CiInterfaceDefine.h" +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../PSD/PSDConfigDataManage.h" +#ifdef __cplusplus +extern "C" { +#endif + + + +/*ͨŵPsdϢ*/ +typedef struct S_PsdToCiDataStruct +{ + UINT16 PsdId; /*Psd ID*/ + UINT8 doorHaveOrNot; /*ϢгϢ0x55޳Ϣ0xaa*/ + UINT8 doorEditGroupInfo; /*гϢ:VOBC(ֶ̬)*/ + UINT32 faultIsolationRequestInfo; /*ϸ:VOBC(ֶ̬)*/ + UINT32 faultIsolationReplyInfo; /*ϸظ:PSDϵͳ(ֶ̬)ȫŹ״̬*/ + UINT32 psdState; /*bit0bit23ʾ124ŵĴ״̬bitΪ0ʾر״̬Ϊ1ʾ״̬(ǹر)bit0-bit7Ϊ1ֽڣʾ1-8Ŵ״̬*/ + UINT32 vobcToPsdfaultIsolationRequest[2]; /*ϸ:VOBC(ֶ̬)8ֽ*/ + UINT32 psdToVobcfaultIsolationReply[2]; /*ϸ״̬ظ:PSDϵͳ(ֶ̬)ȫŹ״̬8ֽڣ1ʾ޹ϣ0ʾϣδbitĬд0*/ + UINT32 psdOpenCloseState[2]; /*bit0bit31ʾ132ŵĴ״̬bitΪ1ʾر״̬Ϊ0ʾ״̬(ǹر)bit0-bit7Ϊ1ֽڣʾ1-8Ŵ״̬δbitĬд0*/ +} PsdToCiDataStruct; + + +typedef struct S_PlatformToCiDataStruct +{ + UINT8 stationId; /*վ:ֶ*/ + UINT8 psdSum; /*: ֶ*/ + PsdToCiDataStruct psdDataStr[PLATFORM_INCLUDE_PSD_MAX_SUM]; /*Ϣṹ*/ +}PlatformToCiDataStruct; + + + +/* +* վ̨ݽṹʼ +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 InitialPlatformData(void); + + + +/* +* PSD֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParsePlatformToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId); + + +/* +* PSD +* ˵ QueueStruct* CiToPlatformDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToPlatformData(UINT8 deviceId); + + +/* +* ȡPlatform-CIĽṹ +* ˵ void +* ֵ Platform-CIṹָ +*/ +PlatformToCiDataStruct * GetPlatformToCiDataStru(void); + +/* +* ΪָPSD->CIĽṹȱʡֵ(ȫֵ) +* ˵ platformId:PSDϵͳID +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 SetPlatformToCiDefaultDataStru(UINT8 platformId); + +/* +* ָID״̬ +* ˵ const UINT16 doorId, ID +* const UINT32 isolateState, Źϸ״̬ +* ֵ +* +*/ +void SetPsdIsolateState(const UINT16 doorId, const UINT32 isolateState); + +/* +* ȡָIDŹϸ״̬ +* ˵ const UINT16 doorId, ID +* ֵ 0: δϸ +* >0: ϸ +*/ +UINT32 GetPsdIsolateState(const UINT16 doorId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackTmcData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackTmcData.c new file mode 100644 index 0000000..5e54dc7 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackTmcData.c @@ -0,0 +1,1616 @@ +/******************************************************** +* +* ParsePackTmcData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2022-06-15 +* ߣ +* TMC +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackTmcData.h" +#include "../QueryFiles/dquCIInterFace.h" +#include "../HLHTMsgHead/HLHTHeadContexManage.h" +#include "../HLHTMsgHead/HLHTCommonDataPacketHead.h" +#include "SystemParameterManage.h" + +/* 뻺 */ +static TmcToTiocDataStruct g_TmcToTiocDataStru = { 0u }; + + + +/* +* ʱϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID ʱ Ԥ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseTsrData(UINT8* dataBuf, UINT16 dataLen); + +/* +* TMCʱ +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ 0:ʧ +* :ݳ +*/ +static UINT16 PackToTmcTsrData(UINT8* TiocToTmcDataBuffer); + +/* +* TMCʱѩģʽ +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ 0:ʧ +* :ݳ +*/ +static UINT16 PackToTmcSnowData(UINT8* TiocToTmcDataBuffer); + +/* +* TMCȫɸ +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ 0:ʧ +* :ݳ +*/ +static UINT16 PackToTmcWLScreenData(UINT8* TiocToTmcDataBuffer); + +/* +* ȫѩģʽϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID ʱ Ԥ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseSnowData(UINT8* dataBuf, UINT16 dataLen); + +/* +* ȫɸϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID ʱ Ԥ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseWLSData(UINT8* dataBuf, UINT16 dataLen); + +/* +* ITEȫгϢ +* ˵const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵCI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.07.12 +*/ +static UINT8 ParseIteLineCutData(UINT8* dataBuf, UINT16 dataLen); + +/* +* ITEȫгϢ +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ0 ʧ +* ݳ +* Created By LQ 2024.07.12 +*/ +static UINT16 PackToTmcIteLineCutData(UINT8* TiocToTmcDataBuffer); + +/* +* ȫͨųϢ +* ˵const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵCI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.07.12 +*/ +static UINT8 ParseLineCTData(UINT8* dataBuf, UINT16 dataLen); + +/* +* TMCȫͨų +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ0 ʧ +* ݳ +* Created By LQ 2024.07.14 +*/ +static UINT16 PackToTmcLineCTData(UINT8* TiocToTmcDataBuffer); + +/* +* Tmc֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID ʱ Ԥ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseTmcToTiocDataFrame(UINT8* dataBuf, UINT16 dataLength, UINT8 systemId) +{ + UINT8* sourceId = NULL; /*ԴID*/ + UINT16 ii = 0u; + UINT8 retVal = CI_ERROR; + UINT8 galHeadSaved = 0u; /*ͨͷǷѱ־1棻0δ*/ + UINT32 curntCycleNo = 0u; /*ǰں*/ + UINT32 errCode = 0u; + UINT16 wTmcName = 0u; /*ZC豸ƣ+ID*/ + UINT16 wTiocName = 0u; /*豸ƣ+ID*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 headRet = HLHT_HEAD_ERROR;/*ͨ*/ + INT32 InfoRemainValidity = 0; + UINT8 cTiocTmcPrtclVersion = TIOC_TMC_PRTCL_VER; /* ӿЭ汾 */ + UINT8 cFunRetVal = CI_ERROR; + UINT16 wMsgLen = 0u; + UINT16 wMsgCheckLen = 0u; /* ڽУݳ */ + UINT16 wMsgType = 0u; + UINT16 wTmpDataLen = 0u; + UINT32 TiocAndTmcTransmitBadEnsureTime = 0u; /*TIOCTMCͨжȷʱ*/ + UINT32 SystemParaAppCycleTime = 0u; /*Ӧ*/ + UINT8 cTiocId = 0u; + HLHTGALInfoStruct hlhtGalHead = { 0u }; + UINT32 dwParseStep = 0U; + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + wTmcName = (CI_SYSTEM_TYPE_TMC)*256U + systemId; + wTiocName = (CI_SYSTEM_TYPE_CI)*256U + localCiId; + curntCycleNo = Get2oo2CurCycleNum(); + + /* ս */ + ClearTmcToTiocData(); + + if ((NULL != dataBuf) && (dataLength > 0u)) + { + /*ͨϢͷ*/ + hlhtGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.sourceId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.destId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.comPeriod = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.prtclVer = dataBuf[ii++]; + hlhtGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + headRet = HLHTRecvCommonPacketHeadCheck(wTmcName, wTiocName, TIOC_TMC_INTERFACE_INFOTYPE, TIOC_TMC_PRTCL_VER, &hlhtGalHead, &errCode, 0u, CI_SYSTEM_TYPE_TMC); + + + debug_infor_printf((const)"\nTMC_RECV GAL Check Result:%d,errCode:%d", headRet,errCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + if (HLHT_HEAD_SUCCESS==headRet) + {/*GALϢͷУͨ*/ + /*ϢʱЧ*/ + TiocAndTmcTransmitBadEnsureTime = GetTiocAndTmcTransBadEnsureTime(); + SystemParaAppCycleTime = GetSystemParaAppCycleTime(); + InfoRemainValidity = HLHTCommonMsgRemainingValidity(TiocAndTmcTransmitBadEnsureTime, curntCycleNo, SystemParaAppCycleTime, hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN, hlhtGalHead.comPeriod); + + if (0 < InfoRemainValidity ) + {/*Ч*/ + + if (0u == hlhtGalHead.totalDataLen) + { + /* GALͷϢ */ + retVal = CI_ERROR; + } + else if (2u > hlhtGalHead.totalDataLen) + { + /* ݳȴ,ʧ */ + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + while (wTmpDataLen < hlhtGalHead.totalDataLen) + { + /* һӦݳ */ + wMsgLen = ShortFromChar(&dataBuf[ii]); + ii += 2u; + wTmpDataLen += 2U; + wTmpDataLen += wMsgLen; + + if (0u == wMsgLen) + { + ; /* ޴һ */ + } + else if(5u > wMsgLen) + { + /* Ȳ */ + retVal = CI_ERROR; + } + else + { + /* ȡ */ + wMsgType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + /* Ԥ */ + ii += 2u; + + wMsgCheckLen = wMsgLen - 4u; + switch (wMsgType) + { + case TMC_TO_TIOC_TSR_MSG: + /* TMCʱϢ */ + retVal = ParseTsrData(&dataBuf[ii], wMsgCheckLen); + dwParseStep |= 0x10000U; + debug_infor_printf((const)"\n ParseTsrData:%d", retVal); + break; + case TMC_TO_TIOC_SNOW_MSG: + /*ȫѩģʽϢ*/ + retVal = ParseSnowData(&dataBuf[ii], wMsgCheckLen); + dwParseStep |= 0x01000U; + debug_infor_printf((const)"\n ParseSnowData:%d", retVal); + break; + case TMC_TO_TIOC_WLS_MSG: + /* ɸϢ */ + retVal = ParseWLSData(&dataBuf[ii], wMsgCheckLen); + dwParseStep |= 0x00100U; + debug_infor_printf((const)"\n ParseWLSData:%d", retVal); + break; + case TMC_TO_TIOC_ITELINECUT_MSG: + /* ITEȫгϢ */ + retVal = ParseIteLineCutData(&dataBuf[ii], wMsgCheckLen); + dwParseStep |= 0x00010U; + debug_infor_printf((const)"\n ParseIteLineCutData:%d", retVal); + break; + case TMC_TO_TIOC_LINECT_MSG: + /* ȫͨųϢ */ + retVal = ParseLineCTData(&dataBuf[ii], wMsgCheckLen); + dwParseStep |= 0x00001U; + debug_infor_printf((const)"\n ParseLineCTData:%d", retVal); + break; + default: + retVal = CI_ERROR; + break; + } + + if (CI_SUCCESS == retVal) + { + /* ɹݰ */ + ii += wMsgCheckLen; + } + else + { + ; /*do nothing*/ + } + } + + if (CI_ERROR == retVal) + { + break; + } + else + { + ; /*do nothing*/ + } + } + + /*УTMC͵֡Ƿÿһ֡λü1*/ + if ((CI_SUCCESS == retVal) && (0x11111U != dwParseStep)) + { + debug_infor_printf((const)"\nParseTmcToTiocDataFrame Error: ParseStep Is 0x%05x\n", dwParseStep); + retVal = CI_ERROR; /*ȱij֡ʧ*/ + } + else + { + /**/ + } + } + + if (CI_SUCCESS == retVal) + { + /*ݾУ飬Ҫ洢ͨñ*/ + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_TMC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_TMC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_TMC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_TMC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_TMC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_TMC, systemId, 0u); + + galHeadSaved = 1; + } + else + { + ; /*do nothing*/ + } + } + else + { + + debug_infor_printf((const)"\n InfoRemainValidity:%d", InfoRemainValidity); /*Ч do nothing*/ + } + } + else if (HLHT_HEAD_INIT ==headRet) + { + if (curntCycleNo > 0u)/*жŴ0Ϊ0Ч*/ + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_TMC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_TMC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_TMC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_TMC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_TMC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_TMC, systemId, 0u); + + galHeadSaved = 1; + } + else + { + ; /*do nothing*/ + } + + retVal = CI_ERROR; + } + else + { + + /*ATSֵطTMC-CIݰ汾УʧϢ*/ + if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_TMC2CI_DATA, CI_SYSTEM_TYPE_TMC, 0U, ETYPE_COMM_WITH_TMC, CI_BACK_DATA_VER_CHECK_FAIL, ESEND_LEVEL_ATS); + } + else + { + ; /*¼*/ + } + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + + if ((CI_ERROR == retVal) || (0u == galHeadSaved)) + { + /*ͨñͷ*/ + ClearHlhtHeadCtx(CI_SYSTEM_TYPE_TMC, systemId); + } + else + { + ; /*do nothing*/ + } + + /* ͨϢͷУͨͨ */ + if (1u == galHeadSaved) + { + cTiocId = GetSystemParaLocalCiId(); /*ȡID*/ + sourceId = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_TMC);/*ȡ뱾TIOCͨŵTMCIDĿǰһֻһTMCͨ*/ + if (NULL == sourceId) + { + cFunRetVal = CI_ERROR; + } + else + { + cFunRetVal = SetCiTransmitRecvDataCycNum(cTiocId, CI_SYSTEM_TYPE_TMC, sourceId[0], Get2oo2CurCycleNum()); + } + + if (CI_ERROR == cFunRetVal) + {/*ʧ*/ + + } + else + {/*ڳɹ*/ + cFunRetVal = UpdateCiTransmitState(cTiocId, CI_SYSTEM_TYPE_TMC, sourceId[0]); + + /*TMCͨ״̬жTMCǷͨж*/ + if (CI_ERROR == cFunRetVal) + { + /*ͨ״̬ʧ,޴*/ + } + else + { + /*ͨ״̬ɹ*/ + } + } + } + else + { + ; /*do nothing*/ + } + + if (CI_ERROR == retVal) + { + /* յӦϢ */ + ClearTmcToTiocData(); + } + else + { + ; /*do nothing*/ + } + + return retVal; +} + +/* +* ʱϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID ʱ Ԥ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseTsrData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cFunRetVal = 0u; /* ؽ */ + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT8 kk = 0u; + TsrDataStruct* pTmpTsrInfo = NULL; + UINT8 cTiocId = 0u; + UINT8 cDevTiocId = 0u; + UINT16 tsrMaxCmdSum = 0u; + UINT16 tsrMaxSecSum = 0u; + + if (NULL == dataBuf) + { + cRetVal = CI_ERROR; + } + else + { + tsrMaxCmdSum = GetTsrMaxCmdSum(); + tsrMaxSecSum = GetTsrMaxSecSum(); + cRetVal = CI_SUCCESS; + } + + /* ʱЧ־λ */ + if (CI_SUCCESS == cRetVal) + { + g_TmcToTiocDataStru.tsrInputInfoStru.cTsrValidFlag = dataBuf[ii]; + ii++; + if ((0x55U == g_TmcToTiocDataStru.tsrInputInfoStru.cTsrValidFlag) || (0xAAU == g_TmcToTiocDataStru.tsrInputInfoStru.cTsrValidFlag)) + { + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; + } + } + else + { + ; /*Уʧ do nothing*/ + } + + /* ȫʱϢ */ + if (CI_SUCCESS == cRetVal) + { + g_TmcToTiocDataStru.tsrInputInfoStru.cAllLineTsrState = dataBuf[ii]; + ii++; + + g_TmcToTiocDataStru.tsrInputInfoStru.cAllLineTsrSpeed = dataBuf[ii]; + ii++; + + if (((0x55U == g_TmcToTiocDataStru.tsrInputInfoStru.cAllLineTsrState) && (0u == g_TmcToTiocDataStru.tsrInputInfoStru.cAllLineTsrSpeed)) + ||((0xAAU == g_TmcToTiocDataStru.tsrInputInfoStru.cAllLineTsrState) && (0u < g_TmcToTiocDataStru.tsrInputInfoStru.cAllLineTsrSpeed))) + { + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; + } + } + else + { + ; /*do nothing*/ + } + + /* ʱ */ + if (CI_SUCCESS == cRetVal) + { + g_TmcToTiocDataStru.tsrInputInfoStru.cTsrSum = dataBuf[ii]; + ii++; + if ((TSR_MAX_SUM < g_TmcToTiocDataStru.tsrInputInfoStru.cTsrSum) || (tsrMaxCmdSum < g_TmcToTiocDataStru.tsrInputInfoStru.cTsrSum)) + { + cRetVal = CI_ERROR; + } + else + { + ; /* do nothing */ + } + //ʱϢЧ־ΪЧʱΪ0 + if ((0U != g_TmcToTiocDataStru.tsrInputInfoStru.cTsrSum) && (0xAAU == g_TmcToTiocDataStru.tsrInputInfoStru.cTsrValidFlag)) + { + cRetVal = CI_ERROR; + } + else + { + ; /* do nothing */ + } + } + else + { + ; /* do nothing */ + } + + /* ʱ */ + if (CI_SUCCESS == cRetVal) + { + cTiocId = GetSystemParaLocalCiId(); /*ȡID*/ + + for (jj = 0u; jj < g_TmcToTiocDataStru.tsrInputInfoStru.cTsrSum;jj++) + { + /* ֵ */ + g_TmcToTiocDataStru.tsrInputInfoStru.szTsrInfo[jj].cSpeed = dataBuf[ii]; + ii++; + if ((0u == g_TmcToTiocDataStru.tsrInputInfoStru.szTsrInfo[jj].cSpeed) + || (UINT8_MAX == g_TmcToTiocDataStru.tsrInputInfoStru.szTsrInfo[jj].cSpeed)) + { + cRetVal = CI_ERROR; + } + else + { + ; /* do nothing */ + } + + /* */ + if (CI_SUCCESS == cRetVal) + { + g_TmcToTiocDataStru.tsrInputInfoStru.szTsrInfo[jj].cLogSecSum = dataBuf[ii]; + ii++; + if ((TSR_SEC_MAX_SUM < g_TmcToTiocDataStru.tsrInputInfoStru.szTsrInfo[jj].cLogSecSum) + ||(0u == g_TmcToTiocDataStru.tsrInputInfoStru.szTsrInfo[jj].cLogSecSum) + ||(tsrMaxSecSum < g_TmcToTiocDataStru.tsrInputInfoStru.szTsrInfo[jj].cLogSecSum)) + { + cRetVal = CI_ERROR; + } + else + { + ; /* do nothing */ + } + } + else + { + ; /* do nothing */ + } + + /* ID */ + if (CI_SUCCESS == cRetVal) + { + pTmpTsrInfo = &g_TmcToTiocDataStru.tsrInputInfoStru.szTsrInfo[jj]; + for (kk = 0u; kk < pTmpTsrInfo->cLogSecSum;kk++) + { + pTmpTsrInfo->szLogSecId[kk] = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + if ((0u == pTmpTsrInfo->szLogSecId[kk]) || (UINT16_MAX == pTmpTsrInfo->szLogSecId[kk])) + { + cRetVal = CI_ERROR; + } + else + { + cDevTiocId = GetLogSecBelongCiId(pTmpTsrInfo->szLogSecId[kk]); + + if ((0u != cTiocId) && (cDevTiocId == cTiocId)) + { + ; /* DZTIOC߼ */ + } + else + { + cRetVal = CI_ERROR; + } + } + + if (CI_ERROR == cRetVal) + { + break; + } + else + { + ; /* do nothing */ + } + } + + } + else + { + ; /* do nothing */ + } + + if (CI_ERROR == cRetVal) + { + break; + } + else + { + ; /* do nothing */ + } + } + } + else + { + ; /* do nothing */ + } + + if (dataLen != ii) + { + cRetVal = CI_ERROR; + } + else + { + ; /* do nothing */ + } + + return cRetVal; +} + +/* +* ȫѩģʽϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID ʱ Ԥ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseSnowData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0u; + UINT8 jj = 0U; + UINT32 dwPlatFormId = 0U; /*վ̨ͨID*/ + UINT8 cPlatFormNum = 0U; /*վ̨*/ + UINT8 cTmepNum = 0U; + UINT8 cPlatFormBelongCiId = 0U; /*վ̨LinkCI*/ + UINT8 cLocalCiId = 0U; + + if (NULL == dataBuf) + { + cRetVal = CI_ERROR; + } + else + { + cRetVal = CI_SUCCESS; + } + + /*ȫѩģʽЧ־λ */ + if (CI_SUCCESS == cRetVal) + { + g_TmcToTiocDataStru.cSnowValidFlag = dataBuf[ii]; + ii++; + if ((CI_ALL_SNOW_VALID == g_TmcToTiocDataStru.cSnowValidFlag) || (CI_ALL_SNOW_UNVALID == g_TmcToTiocDataStru.cSnowValidFlag)) + { + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; + } + } + + /*ѩվ̨Ϣ*/ + if (CI_SUCCESS == cRetVal) + { + cPlatFormNum = dataBuf[ii]; /*ѩվ̨*/ + ii++; + + if (ALL_AREA_SNOW_SUM_MAX >= cPlatFormNum) + { + cLocalCiId = GetSystemParaLocalCiId(); + for (jj = 0U; jj < cPlatFormNum; jj++) + { + dwPlatFormId = LongFromChar(&dataBuf[ii]); /*ѩվ̨ID*/ + ii += 4U; + + cPlatFormBelongCiId = GetAreaSnowPlatFormBelongCiId((UINT16)dwPlatFormId); /*ȡѩվ̨*/ + if (0U < dwPlatFormId) + { + if ((cLocalCiId == cPlatFormBelongCiId) && (0U != cLocalCiId)) + { + if (LOCAL_AREA_SNOW_SUM_MAX > cTmepNum) + { + g_TmcToTiocDataStru.szAreaSnowPlatFormId[cTmepNum] = dwPlatFormId; + cTmepNum++; + } + else + { + cRetVal = CI_ERROR; /*ѩվ̨ޣֹͣʧ*/ + break; + } + } + else + { + /*DZվ̨*/ + } + } + else + { + /*ѩģʽIDǷ*/ + cRetVal = CI_ERROR; + } + } + + g_TmcToTiocDataStru.cAreaSnowPlatFormNum = cTmepNum; + } + else + { + cRetVal = CI_ERROR; /*ѩվ̨ޣʧ*/ + } + } + else + { + /*ʧܣʧ*/ + } + + if (dataLen != ii) + { + cRetVal = CI_ERROR; + } + return cRetVal; +} + +/* +* ȫɸϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID ʱ Ԥ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseWLSData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0u; + UINT8 jj = 0u; + WLScreenReciveStruct g_WLScreenReciveStruc = { 0u }; + + + + if (NULL == dataBuf) + { + cRetVal = CI_ERROR; + } + else + { + cRetVal = CI_SUCCESS; + } + + /* ɸк */ + if (CI_SUCCESS == cRetVal) + { + g_WLScreenReciveStruc.recvSeq = LongFromChar(&dataBuf[ii]); /*ɸк*/ + ii += 4u; + /*ȫɸ־*/ + g_WLScreenReciveStruc.WLScreenVaildFlag = dataBuf[ii]; + ii++; + if ((0x55u == g_WLScreenReciveStruc.WLScreenVaildFlag) || (0xAAu == g_WLScreenReciveStruc.WLScreenVaildFlag)) + { + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; + } + } + + + + /* ߷ΧܿسϢ*/ + if (CI_SUCCESS == cRetVal) + { + g_WLScreenReciveStruc.WLTrainCnt = dataBuf[ii]; + ii++; + for (jj = 0u; jj < g_WLScreenReciveStruc.WLTrainCnt; jj++) + { + g_WLScreenReciveStruc.WLTrainID[jj] = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + if ((0u == g_WLScreenReciveStruc.WLTrainID[jj]) || (UINT8_MAX <= g_WLScreenReciveStruc.WLTrainID[jj])) + { + cRetVal = CI_ERROR; + } + else + { + ; + } + if (CI_ERROR == cRetVal) + { + break; + } + } + } + + if (dataLen != ii) + { + cRetVal = CI_ERROR; + } + + if (CI_SUCCESS == cRetVal) + { + wls_RefreshWLSInfoFromTMC(&g_WLScreenReciveStruc); + } + + return cRetVal; +} + +/* +* TMC +* ˵UINT8 deviceId TMC +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackTiocToTmcData( UINT8 deviceId) +{ + UINT8 localCi = 0u; /*ID*/ + UINT8 TiocToTmcDataBuffer[TIOC_TO_TMC_DATA_LEN_MAX] = {0u};/*CIZC֡*/ + UINT16 ii = 0u; + UINT32 cTiocEtcsId = 0u;/*TIOCͨ*/ + UINT32 cTmcEtcsId = 0u; /*TMCͨ*/ + UINT32 emapCheckVer = 0u; /*УϢ*/ + UINT8 retVal = CI_ERROR; + UINT16 dstDevId = 0; + UINT8 outnetSafeSendRtn = 0u; + UINT32 curCycleNum = 0u; /*Ӧں*/ + UINT32 appCycleTime = 0u; /*Ӧ*/ + UINT16 wAppDataLenIndex = 0u; /* Ӧݳλ */ + UINT16 wAppDataLen = 0u; /* Ӧݳ */ + UINT16 wMagLen = 0u; /* ݳ */ + + UINT32 dwHlhtHSrcSN = 0u; + UINT32 dwHlhtHRcvSN = 0u; + UINT8 cStep = 0u; + UINT8 cStepRetVal = CI_ERROR; + + curCycleNum = Get2oo2CurCycleNum(); + appCycleTime = GetSystemParaAppCycleTime(); + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + + /* ȡGALͷϢ */ + retVal = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCi, 0U, &cTiocEtcsId); + retVal &= dquDevName2HlhtId((CI_SYSTEM_TYPE_TMC * 256U) + deviceId, 0U, &cTmcEtcsId); + retVal &= GetCiEmapCheckVer(localCi, &emapCheckVer, CI_SYSTEM_TYPE_TMC); + dwHlhtHSrcSN = GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_TMC, deviceId); + dwHlhtHRcvSN = GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_TMC, deviceId); + + if (CI_SUCCESS == retVal) + { + /*GALͷ*/ + ShortToChar(TIOC_TMC_INTERFACE_INFOTYPE, &TiocToTmcDataBuffer[ii]);/*ӿϢ*/ + ii += 2u; + LongToChar(cTiocEtcsId, &TiocToTmcDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(cTmcEtcsId, &TiocToTmcDataBuffer[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(emapCheckVer, &TiocToTmcDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &TiocToTmcDataBuffer[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &TiocToTmcDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(dwHlhtHSrcSN, &TiocToTmcDataBuffer[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(dwHlhtHRcvSN, &TiocToTmcDataBuffer[ii]);/*յһϢʱк*/ + ii += 4u; + + TiocToTmcDataBuffer[ii++] = TIOC_TMC_PRTCL_VER;/*CI_TMCӿЭ汾*/ + + /* Ӧݳ */ + wAppDataLenIndex = ii; + ii += 2u; + + cStepRetVal = CI_SUCCESS; + while (CI_ERROR != cStepRetVal) + { + wMagLen = 0u; + switch (cStep) + { + case 0u: + wMagLen = PackToTmcTsrData(&TiocToTmcDataBuffer[ii]); + break; + case 1u: + wMagLen = PackToTmcSnowData(&TiocToTmcDataBuffer[ii]); + break; + case 2u: + wMagLen = PackToTmcWLScreenData(&TiocToTmcDataBuffer[ii]); + break; + case 3u: + wMagLen = PackToTmcIteLineCutData(&TiocToTmcDataBuffer[ii]); + break; + case 4U: + wMagLen = PackToTmcLineCTData(&TiocToTmcDataBuffer[ii]); + break; + default: + cStepRetVal = CI_ERROR; + break; + } + + cStep++; + + if (CI_ERROR == cStepRetVal) + { + /* */ + cStepRetVal = CI_ERROR; + } + else if(0u != wMagLen) + { + /* Ч */ + ii += wMagLen; + } + else + { + /* Ч */ + cStepRetVal = CI_ERROR; + retVal = CI_ERROR; + } + } + + /* ݳ */ + if (CI_SUCCESS == retVal) + { + wAppDataLen = ii - wAppDataLenIndex; + wAppDataLen -= 2u; + /* Ӧݳ */ + ShortToChar(wAppDataLen, &TiocToTmcDataBuffer[wAppDataLenIndex]); + } + + } + + + /* д뷢Ͷ */ + if (CI_SUCCESS == retVal) + { + dstDevId = ((UINT16)(CI_SYSTEM_TYPE_TMC << 8u) | ((UINT16)deviceId)); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, TiocToTmcDataBuffer, ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nTMC_SEND:%d", ii); + debug_out_array(0xAA, TiocToTmcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ + +#endif + retVal = CI_SUCCESS; + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + } + } + + return retVal; +} + +/* +* TMC +*/ +void ClearTmcToTiocData(void) +{ + UINT8 cFunRetVal = 0u; /* ؽ */ + cFunRetVal = CommonMemSet(&g_TmcToTiocDataStru, (UINT32)sizeof(g_TmcToTiocDataStru), 0u , (UINT32)sizeof(g_TmcToTiocDataStru)); + + if (0u == cFunRetVal) + { + ; /* ڴ쳣 */ + } + else + { + ; /* óɹ޴ */ + } +} + +/* +* ȡTMC +* ֵTMC +*/ +TmcToTiocDataStruct* GetTmcToTiocData(void) +{ + return &g_TmcToTiocDataStru; +} + + +/* +* TMCʱ +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ 0:ʧ +* :ݳ +*/ +static UINT16 PackToTmcTsrData(UINT8* TiocToTmcDataBuffer) +{ + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT8 kk = 0u; + UINT16 wMagLen = 0u; + UINT16 wMagLenIndex = 0u; + UINT16 wRetVal = 0u; + UINT8 startLockFlag = 0u; + UINT8 cTsrSum = 0u; /* ʱ */ + UINT8 cTsrSecSum = 0u; /* */ + UINT8 cFunRetVal = CI_ERROR; + UINT8 cAllLineTsrState = CI_ALL_LINE_TSR_UNVALID; + UINT8 cAllLineTsrSpeed = 0u; + TsrDataStruct* pTsrData = NULL; + + cTsrSum = GetTsrSum(); + pTsrData = GetTsrData(); + startLockFlag = GetStartLockFlag(); + cAllLineTsrState = GetAllLineTsrState(); + cAllLineTsrSpeed = GetAllLineTsrSpeed(); + + if ((NULL != TiocToTmcDataBuffer) && (NULL != pTsrData)) + { + cFunRetVal = CI_SUCCESS; + + wMagLenIndex = ii; + ii += 2u; + + ShortToChar(TIOC_TO_TMC_TSR_MSG, &TiocToTmcDataBuffer[ii]);/* */ + ii += 2u; + + /* Ԥ2ֽ */ + ii += 2u; + + /* ʱЧ־λ */ + if (CI_START_LOCK_YES != startLockFlag) + { + /* ϵɹ */ + TiocToTmcDataBuffer[ii++] = 0x55u;/* ʱЧ */ + + /* ȫʱϢ */ + if (CI_ALL_LINE_TSR_VALID == cAllLineTsrState) + { + TiocToTmcDataBuffer[ii++] = 0xAAu; + } + else if (CI_ALL_LINE_TSR_UNVALID == cAllLineTsrState) + { + TiocToTmcDataBuffer[ii++] = 0x55u; + } + else + { + cFunRetVal = CI_ERROR; + } + TiocToTmcDataBuffer[ii++] = cAllLineTsrSpeed; + + /* ͨʱϢ */ + if (TSR_MAX_SUM < cTsrSum) + { + cFunRetVal = CI_ERROR; + } + + if (CI_SUCCESS == cFunRetVal) + { + TiocToTmcDataBuffer[ii++] = cTsrSum;/* */ + + for (jj = 0u; jj < cTsrSum; jj++) + { + TiocToTmcDataBuffer[ii++] = pTsrData[jj].cSpeed;/* ٶ */ + + cTsrSecSum = pTsrData[jj].cLogSecSum; + + if ((0u == cTsrSecSum) || (TSR_SEC_MAX_SUM < cTsrSecSum)) + { + cFunRetVal = CI_ERROR; + } + else + { + TiocToTmcDataBuffer[ii++] = cTsrSecSum;/* */ + + for (kk = 0u; kk < cTsrSecSum; kk++) + { + /* ߼ID */ + if ((0u == pTsrData[jj].szLogSecId[kk]) || (UINT16_MAX == pTsrData[jj].szLogSecId[kk])) + { + cFunRetVal = CI_ERROR; + } + else + { + ShortToChar(pTsrData[jj].szLogSecId[kk], &TiocToTmcDataBuffer[ii]); + ii += 2u; + } + + if (CI_ERROR == cFunRetVal) + { + break; + } + else + { + } + } + } + + if (CI_ERROR == cFunRetVal) + { + break; + } + else + { + } + } + } + } + else + { + TiocToTmcDataBuffer[ii++] = 0xAAu;/* ʱЧ */ + + TiocToTmcDataBuffer[ii++] = 0x55u;/* δȫʱ */ + + TiocToTmcDataBuffer[ii++] = 0u;/* δȫʱ */ + + TiocToTmcDataBuffer[ii++] = 0u;/* 0 */ + } + } + else + { + ; /* ʧ */ + } + + if (CI_SUCCESS == cFunRetVal) + { + /* дݳ */ + wMagLen = ii - wMagLenIndex; + wRetVal = wMagLen; + wMagLen -= 2u; + + ShortToChar(wMagLen, &TiocToTmcDataBuffer[wMagLenIndex]); + } + + return wRetVal; +} + + +/* +* TMCʱѩģʽ +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ 0:ʧ +* :ݳ +*/ +static UINT16 PackToTmcSnowData(UINT8* TiocToTmcDataBuffer) +{ + UINT16 ii = 0u; + UINT8 jj = 0U; + UINT16 wMagLen = 0u; + UINT16 wMagLenIndex = 0u; + UINT16 wRetVal = 0u; + UINT8 snowModelFlag = 0u; /*ȫѩģʽ־*/ + UINT8 cFunRetVal = CI_ERROR; + UINT8 cAreaSnowNum = 0U; /*ѩվ̨*/ + UINT32* pAreaSnowId = NULL; /*ѩվ̨ID*/ + + snowModelFlag = GetAllSnowModel(); + + if (NULL != TiocToTmcDataBuffer) + { + cFunRetVal = CI_SUCCESS; + + wMagLenIndex = ii; + ii += 2u; + + ShortToChar(TIOC_TO_TMC_SNOW_MSG, &TiocToTmcDataBuffer[ii]); /* */ + ii += 2u; + + /* Ԥ2ֽ */ + ii += 2u; + + /*ȫѩģʽЧ־*/ + if (CI_ALL_SNOW_VALID == snowModelFlag) + { + TiocToTmcDataBuffer[ii++] = 0x55u; /* ȫѩģʽЧ */ + } + else + { + TiocToTmcDataBuffer[ii++] = 0xAAu; /* ȫѩģʽЧ */ + } + + /*ѩ״̬Ϣ*/ + cAreaSnowNum = GetLocalAreaSnowNum(); + pAreaSnowId = GetLocalAreaSnowId(); + + if (LOCAL_AREA_SNOW_SUM_MAX >= cAreaSnowNum) + { + TiocToTmcDataBuffer[ii] = cAreaSnowNum; /*ѩվ̨*/ + ii++; + + for (jj = 0U; jj < cAreaSnowNum; jj++) + { + LongToChar(pAreaSnowId[jj], &TiocToTmcDataBuffer[ii]); /*ѩվ̨ID*/ + ii += 4U; + } + } + else + { + cFunRetVal = CI_ERROR; /*ѩޣʧ*/ + } + } + else + { + ; /*ʧ*/ + } + if (CI_SUCCESS == cFunRetVal) + { + /* дݳ */ + wMagLen = ii - wMagLenIndex; + wRetVal = wMagLen; + wMagLen -= 2u; + + ShortToChar(wMagLen, &TiocToTmcDataBuffer[wMagLenIndex]); + } + return wRetVal; +} + +/* +* TMCȫɸ +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ 0:ʧ +* :ݳ +*/ +static UINT16 PackToTmcWLScreenData(UINT8* TiocToTmcDataBuffer) +{ + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT16 wMagLen = 0u; + UINT16 wMagLenIndex = 0u; + UINT16 wRetVal = 0u; + UINT8 cFunRetVal = CI_ERROR; + WLScreenReportStruct tmpWLScreenReportStru = { 0u }; + + if (NULL != TiocToTmcDataBuffer) + { + + cFunRetVal = wls_PrepareWLSInfoToTMC(&tmpWLScreenReportStru); + + if (CI_SUCCESS == cFunRetVal) + { + wMagLenIndex = ii; + ii += 2u; + + ShortToChar(TIOC_TO_TMC_MIANSHAI_MSG, &TiocToTmcDataBuffer[ii]);/* */ + ii += 2u; + + /* Ԥ2ֽ */ + ii += 2u; + + /* ϵɹ */ + LongToChar(tmpWLScreenReportStru.sendSeq, &TiocToTmcDataBuffer[ii]); /*ɸк*/ + ii += 4u; + + TiocToTmcDataBuffer[ii++] = tmpWLScreenReportStru.UTFlag; /*ǷUTǰ˿ɱ־*/ + + TiocToTmcDataBuffer[ii++] = tmpWLScreenReportStru.enterCheckFlag; /*쳣־*/ + + TiocToTmcDataBuffer[ii++] = tmpWLScreenReportStru.controlTrainCnt; /*TIOCΧܿг*/ + /*ܿسID*/ + for (jj = 0u; jj < tmpWLScreenReportStru.controlTrainCnt; jj++) + { + if ((0u == tmpWLScreenReportStru.controlTrainID[jj]) || (UINT8_MAX <= tmpWLScreenReportStru.controlTrainID[jj])) + { + cFunRetVal = CI_ERROR; + break; + } + else + { + ShortToChar(tmpWLScreenReportStru.controlTrainID[jj], &TiocToTmcDataBuffer[ii]); + ii += 2u; + } + } + + if (CI_SUCCESS == cFunRetVal) + { + TiocToTmcDataBuffer[ii++] = tmpWLScreenReportStru.offlineTrainCnt; /*ӱTIOCضλʻߵܿг*/ + /*ܿسID*/ + for (jj = 0u; jj < tmpWLScreenReportStru.offlineTrainCnt; jj++) + { + if ((0u == tmpWLScreenReportStru.offlineTrainID[jj]) || (UINT8_MAX <= tmpWLScreenReportStru.offlineTrainID[jj])) + { + cFunRetVal = CI_ERROR; + break; + } + else + { + ShortToChar(tmpWLScreenReportStru.offlineTrainID[jj], &TiocToTmcDataBuffer[ii]); + ii += 2u; + } + } + } + } + } + else + { + ; /* ʧ */ + } + + if (CI_SUCCESS == cFunRetVal) + { + /* дݳ */ + wMagLen = ii - wMagLenIndex; + wRetVal = wMagLen; + wMagLen -= 2u; + + ShortToChar(wMagLen, &TiocToTmcDataBuffer[wMagLenIndex]); + + } + + return wRetVal; +} + +/* +* ITEȫгϢ +* ˵const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵCI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.07.12 +*/ +static UINT8 ParseIteLineCutData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cIteLineCutState = 0U; /*ITEȫг״̬*/ + UINT16 ii = 0u; + + if (NULL != dataBuf) + { + cIteLineCutState = dataBuf[ii]; + ii++; + + if ((CI_ITE_LINE_CUT_VALID == cIteLineCutState) || (CI_ITE_LINE_CUT_INVALID == cIteLineCutState)) + { + g_TmcToTiocDataStru.cIteLineCutState = cIteLineCutState; /*洢ITEȫг״̬*/ + + if (dataLen == ii) + { + cRetVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"ParseIteLineCutData Error: MsgLen Is Error\n"); + cRetVal = CI_ERROR; /*Ȳһ£ʧ*/ + } + } + else + { + cRetVal = CI_ERROR; /*״̬Ƿʧ*/ + debug_infor_printf((const)"ParseIteLineCutData Error: IteLineCutState[0x%2x] Is Invalid\n", cIteLineCutState); + } + } + else + { + /*ηǷʧ*/ + } + + return cRetVal; +} + +/* +* ITEȫгϢ +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ0 ʧ +* ݳ +* Created By LQ 2024.07.12 +*/ +static UINT16 PackToTmcIteLineCutData(UINT8* TiocToTmcDataBuffer) +{ + UINT16 ii = 0U; + UINT16 wMagLen = 0U; + UINT16 wMagLenIndex = 0U; + UINT16 wRetVal = 0U; + UINT8 cIteLineCutState = 0U; /*ITEȫг״̬*/ + + if (NULL != TiocToTmcDataBuffer) + { + wMagLenIndex = ii; + ii += 2U; + + ShortToChar(TIOC_TO_TMC_ITELINECUT_MSG, &TiocToTmcDataBuffer[ii]); /* */ + ii += 2U; + + /* Ԥ2ֽ */ + ii += 2U; + + /*ITEȫг״̬*/ + cIteLineCutState = GetIteLineCutState(); + if ((CI_ITE_LINE_CUT_VALID == cIteLineCutState) || (CI_ITE_LINE_CUT_INVALID == cIteLineCutState)) + { + TiocToTmcDataBuffer[ii] = cIteLineCutState; + } + else + { + TiocToTmcDataBuffer[ii] = CI_ITE_LINE_CUT_DEFAULT; /* Ĭֵ */ + } + + ii++; + + /* дݳ */ + wMagLen = ii - wMagLenIndex; + wRetVal = wMagLen; + wMagLen -= 2U; + + ShortToChar(wMagLen, &TiocToTmcDataBuffer[wMagLenIndex]); + } + else + { + /*ηǷ0*/ + } + + return wRetVal; +} + +/* +* ȫͨųϢ +* ˵const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵCI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.07.12 +*/ +static UINT8 ParseLineCTData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT8 cLineCtNum = 0U; + UINT16 wTrainId = 0U; + + if (NULL != dataBuf) + { + cRetVal = CI_SUCCESS; + + cLineCtNum = dataBuf[ii]; + ii++; + + if (TRAIN_SUM_MAX > cLineCtNum) + { + g_TmcToTiocDataStru.cLineCtNum = cLineCtNum; + for (jj = 0u; jj < g_TmcToTiocDataStru.cLineCtNum; jj++) + { + wTrainId = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + if ((0u < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + g_TmcToTiocDataStru.szLineCtId[jj] = wTrainId; /**/ + } + else + { + debug_infor_printf((const)"ParseLineCTData Error: Train ID[%d] Is Invalid\n", wTrainId); + cRetVal = CI_ERROR; /*ͨųIDǷֹͣʧ*/ + break; + } + } + if (CI_SUCCESS == cRetVal) + { + if (dataLen == ii) + { + /**/ + } + else + { + debug_infor_printf((const)"ParseLineCTData Error: MsgLen Is Error\n"); + cRetVal = CI_ERROR; /*Ȳһ£ʧ*/ + } + } + else + { + /**/ + } + } + else + { + debug_infor_printf((const)"ParseLineCTData Error: Train Num[%d] Exceed Max[%d]\n", cLineCtNum, TRAIN_SUM_MAX); + cRetVal = CI_ERROR; /*ͨųޣʧ*/ + } + } + else + { + cRetVal = CI_ERROR; /*ηǷʧ*/ + } + + return cRetVal; +} + +/* +* TMCȫͨų +* ˵UINT8* TiocToTmcDataBuffer ݵַ +* ֵ0 ʧ +* ݳ +* Created By LQ 2024.07.14 +*/ +static UINT16 PackToTmcLineCTData(UINT8* TiocToTmcDataBuffer) +{ + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 wMagLen = 0U; + UINT16 wMagLenIndex = 0U; + UINT16 wTrainNumIndex = 0U; + UINT16 wRetVal = 0U; + UINT8 cFunRetVal = CI_ERROR; + UINT8 cCommTrainNum = 0U; /*뱾RCͨŵͨų*/ + TrainInfoStru* pstrTrainInfo = NULL; /*гϢṹ*/ + UINT16 wTrainId = 0U; + UINT8 cCtEnvelopeFlag = CI_ERROR; /*гǷCT־*/ + + if (NULL != TiocToTmcDataBuffer) + { + cFunRetVal = CI_SUCCESS; + wMagLenIndex = ii; + ii += 2U; + + ShortToChar(TIOC_TO_TMC_LINECT_MSG, &TiocToTmcDataBuffer[ii]); /* */ + ii += 2U; + + ii += 2U; /*Ԥ2ֽ*/ + + wTrainNumIndex = ii; /*ͨгλ*/ + ii++; + + pstrTrainInfo = GetTrainInfoData(); + if (NULL == pstrTrainInfo) + { + cCommTrainNum = 0U; /*ͨųṹΪNULLͨų0*/ + } + else + { + for (jj = 0U; jj < TRAIN_SUM_MAX; jj++) + { + if (TRAIN_COMM_STATE_GOOD == pstrTrainInfo[jj].chTransmitStat) + { + wTrainId = pstrTrainInfo[jj].wTrainId & 0x00FFU; + cCtEnvelopeFlag = CheckTrainRelCtEnvelope(wTrainId); /*ͨųǷCT*/ + if (CI_SUCCESS == cCtEnvelopeFlag) + { + if ((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) + { + if (VOBC_TO_CI_SUM_MAX > cCommTrainNum) + { + ShortToChar(wTrainId, &TiocToTmcDataBuffer[ii]); + ii += 2U; + cCommTrainNum++; + } + else + { + debug_infor_printf((const)"PackToTmcLineCTData Error: CommTrainNum[%d] Exceed Max[%d]\n", cCommTrainNum, VOBC_TO_CI_SUM_MAX); + cFunRetVal = CI_ERROR; /*ͨųޣ*/ + } + } + else + { + debug_infor_printf((const)"PackToTmcLineCTData Error: CommTrainID[%d] Is Invalid\n", wTrainId); + cFunRetVal = CI_ERROR; /*ͨųIDǷ*/ + } + + if (CI_ERROR == cFunRetVal) + { + break; + } + else + { + /**/ + } + } + else + { + /*CT磬*/ + } + } + else + { + /*ͨų*/ + } + } + } + + if (CI_SUCCESS == cFunRetVal) + { + /*дݳ*/ + TiocToTmcDataBuffer[wTrainNumIndex] = cCommTrainNum; /*TIOCΧͨг*/ + wMagLen = ii - wMagLenIndex; + wRetVal = wMagLen; + wMagLen -= 2U; + + ShortToChar(wMagLen, &TiocToTmcDataBuffer[wMagLenIndex]); + } + else + { + /*󣬲*/ + } + } + else + { + /*ηǷ*/ + } + + return wRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackTmcData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackTmcData.h new file mode 100644 index 0000000..b6ba84f --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackTmcData.h @@ -0,0 +1,106 @@ +/******************************************************** +* +* ParsePackTmcData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2022-06-15 +* ߣ +* TMCݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_TMC_DATA_H_ +#define _PARSE_PACK_TMC_DATA_H_ + + + +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "SectionDefine.h" +#include "LogicSectionDataManage.h" +#include "WholeLineScreenAPI.h" + +#define TIOC_TMC_PRTCL_VER ((UINT8)0x01u) /*TIOC-TMCЭ汾*/ +#define TIOC_TMC_INTERFACE_INFOTYPE ((UINT16)0x0101u) /*TIOC-TMCӿϢ*/ + +#define TIOC_TO_TMC_TSR_MSG ((UINT16)0x0101u) /*TIOCTMCϢ*/ +#define TMC_TO_TIOC_TSR_MSG ((UINT16)0x0102u) /*TMCTIOCϢ*/ + +#define TIOC_TO_TMC_SNOW_MSG ((UINT16)0x0105u) /*TIOCTMCȫѩģʽϢ*/ +#define TMC_TO_TIOC_SNOW_MSG ((UINT16)0x0106u) /*TMCTIOCȫѩģʽϢ*/ + +#define TIOC_TO_TMC_MIANSHAI_MSG ((UINT16)0x0103u) /*TIOCTMCȫɸϢ*/ +#define TMC_TO_TIOC_WLS_MSG ((UINT16)0x0104u) /*TMCTIOCȫɸϢ*/ + +#define TIOC_TO_TMC_ITELINECUT_MSG ((UINT16)0x0107U) /*TIOCTMC ITEȫгϢ*/ +#define TMC_TO_TIOC_ITELINECUT_MSG ((UINT16)0x0108U) /*TMCTIOC ITEȫгϢ*/ + +#define TIOC_TO_TMC_LINECT_MSG ((UINT16)0x0109U) /*TIOCTMCȫͨųϢ*/ +#define TMC_TO_TIOC_LINECT_MSG ((UINT16)0x010AU) /*TMCTIOCȫͨųϢ*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*ʱ뻺ṹ*/ +typedef struct S_TsrInputInfoStruct +{ + UINT8 cTsrValidFlag; /* ʱЧ־0x55ϢЩ0xAAϢЧ */ + UINT8 cAllLineTsrState; /* ȫʱ״̬ */ + UINT8 cAllLineTsrSpeed; /* ȫʱٶ */ + UINT8 cTsrSum; /* */ + TsrDataStruct szTsrInfo[TSR_MAX_SUM]; /* Ϣ */ +} TsrInputInfoStruct; + + +/*TMC->TIOC*/ +typedef struct S_TmcToTiocDataStruct +{ + TsrInputInfoStruct tsrInputInfoStru;/* ʱϢ */ + UINT8 cSnowValidFlag; /* ȫѩģʽЧ־ */ + UINT8 cAreaSnowPlatFormNum; /*ѩվ̨*/ + UINT32 szAreaSnowPlatFormId[LOCAL_AREA_SNOW_SUM_MAX]; /*ѩվ̨ID*/ + UINT8 cIteLineCutState; /* ITEȫг״̬ */ + UINT8 cLineCtNum; /*ȫͨų*/ + UINT16 szLineCtId[TRAIN_SUM_MAX]; /*ȫͨųID*/ +} TmcToTiocDataStruct; + +/* +* Tmc֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +extern UINT8 ParseTmcToTiocDataFrame(UINT8* dataBuf, UINT16 dataLength, UINT8 systemId); + + +/* +* TMC +* ˵UINT8 deviceId TMC +* ֵ 0:ʧ +* 1:ݳɹ +*/ +extern UINT8 PackTiocToTmcData(UINT8 deviceId); + +/* +* ȡTMC +* ֵTMC +*/ +extern TmcToTiocDataStruct* GetTmcToTiocData(void); + +/* +* TMC +*/ +extern void ClearTmcToTiocData(void); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackVobcData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackVobcData.c new file mode 100644 index 0000000..3b17ad6 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackVobcData.c @@ -0,0 +1,12252 @@ +/******************************************************** +* +* ParsePackVobcData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* Vobcݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + + +#include "ParsePackVobcData.h" +#include "../HLHTMsgHead/HLHTHeadContexManage.h" +#include "../DataManage/DeviceConfigDataManage.h" +#include "../HLHTMsgHead/HLHTCommonDataPacketHead.h" +#include "CommonMemory.h" +#include "../QueryFiles/dquCIInterFace.h" +#include "../Train/TrainDefine.h" +#include "../Train/TrainDataManage.h" +#include "EnvelopeManageAPI.h" +#include "LogicSectionDataManage.h" +#include "NonAutoReturnConfigDataManage.h" +#include "LogicSectionConfigDataManage.h" +#include "WLBrakeDataManage.h" +#include "../AxisSort/AxisSort_api.h" + +/* +* VOBC͸CIϢṹ +* ˵ const VobcToCiDataStruct* srcMsg:ƵVOBC͸CIϢṹָ + VobcToCiDataStruct* dstMsg:ĿVOBC͸CIϢṹָ +* ֵ +*/ +static void CopyVobcToCiMsg(const VobcToCiDataStruct* srcMsg,VobcToCiDataStruct* dstMsg); + +/* +* HLHT VOBC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStru vobcTociݽṹָ +* UINT8* saveGalHead,ͨñͷǷ,1:0: +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseVobcToCiDataFrameHLHT(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru, UINT8* saveGalHead,const UINT16 logId); + +/* +* FAO VOBC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStru vobcTociݽṹָ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseVobcToCiDataFrameFAO(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId,VobcToCiDataStruct* vobcToCiDataStru); + +/* +* 黥ͨVOBC +* ˵ +* VobcToCiDataStruct *vobcToCiDataStru VOBCݽṹָ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToVobcDataHLHT(VobcToCiDataStruct *vobcToCiDataStru); + +/* +* FAOVOBC +* ˵ +* VobcToCiDataStruct *vobcToCiDataStru VOBCݽṹָ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToVobcDataFAO(VobcToCiDataStruct *vobcToCiDataStru); + +/* +* 黥ͨCI->VOBC֡ +* ˵ +* const UINT8 vobcId ĿVOBC ID +* const UINT8 logId ĿVOBC ߼ID1˻2ˣ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToVobcDataHLHTHeart(const UINT8 vobcId, const UINT16 logId); + +/* +* FAO+HLHT VOBC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStru vobcTociݽṹָ +* UINT8* saveGalHead,ͨñͷǷ,1:0: +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseVobcToCiDataFrameFAOHLHT(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru, UINT8* saveGalHead,const UINT16 logId); + +/* +* ֡ +* ˵ const UINT8* pDataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* pstVobcToCiDataStru vobcTociݽṹָ +* UINT8* pSaveGalHead,ͨñͷǷ,1:0: +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseIvocToCiDataFrameCC(const UINT8* pDataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* pstVobcToCiDataStru, UINT8* pSaveGalHead, const UINT16 logId); +/* +* CC IVOCϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* VobcToCiDataStru vobcTociݽṹָ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseIvocToCiCmdCC(const UINT8* pDataBuf,UINT16 * wDataLength, VobcToCiDataStruct* pstVobcToCiDataStru); +/* +* (FAO+HLHT)VOBC +* ˵ VobcToCiDataStruct *vobcToCiDataStru,VOBCciݽṹ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToVobcDataFAOHLHT(VobcToCiDataStruct *vobcToCiDataStru); + +/* +* 鳵Ivoc +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* VobcToCiDataStruct *vobcToCiDataStru VobcϢṹ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToIvocDataCC(VobcToCiDataStruct *pstVobcToCiDataStru); + +/* +* 鳵ͨIvoc +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* VobcBackUpToCiDataStruct *pstVobcBackUpToCiDataStru VobcͨϢṹ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToIvocBackUpDataCC(VobcBackUpToCiDataStruct *pstVobcBackUpToCiDataStru); + +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocSwitchInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocPsdInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvocť״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocEsbInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvoc۷ť״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocARInfo(UINT8* pDataBuf, UINT16 *wDataLength); +/* +* CiIvocSpks״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocSpksInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocGaragedoorInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvoc״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId, гID +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocFloodGateInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocFLockInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvocͨų״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocCommTrainInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvocϳ״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocFaultTrainInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvoc߳״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocSleepTrainInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvocʱ״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocTsrInfo(UINT8* pDataBuf, UINT16 *wDataLength); + +/* +* CiIvoc߼״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocLgcSgmtInfo(UINT8* pDataBuf, UINT16 *wDataLength, UINT16 wVobcId); +/* +* CiIvoc ظ״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocReqAndReplyInfo(UINT8* pDataBuf, UINT16 *wDataLength, UINT16 wTrnId); + +/* +* ϴϢӿУ +* ˵ ΣUINT8 Data ϴϢ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 WashTrainRequestCheck(UINT8 Data); +/* +* ϴͣ1ϢӿУ +* ˵ ΣUINT8 Data ϴͣ1Ϣ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 HeadWashStopSteadyInfoCheck(UINT8 Data); +/* +* ͣϴϢӿУ +* ˵ ΣUINT8 Data ͣϴϢ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 WashPauseRequestCheck(UINT8 Data); +/* +* ϴͣ2ϢӿУ +* ˵ ΣUINT8 Data ϴͣ2Ϣ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 TailWashStopSteadyInfoCheck(UINT8 Data); +/* +* ͨϴϢӿУ +* ˵ ΣUINT8 Data ͨϴϢ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 PassWashMachineRequestCheck(UINT8 Data); + +/* +* CiIvoc ԴԶϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20230802 +*/ +static UINT8 PackCiToIvocReqAlignmentInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrnId); + +/* +* CiIvocϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocUnlockOverlapInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrnId); + +/* +* ϴģʽϢӿУ +* ˵ ΣUINT8 Data ϴģʽϢ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +* by cgh 20231107 +*/ +static UINT8 WashMachineWorkModeCheck(UINT8 Data); + +/* +* CiIvocϴϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* const UINT16 wTrnId VOBC ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20231110 +*/ +static UINT8 PackCiToIvocWashMachineInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrnId); + +/* +* CiIvocѩƶϢ +* ˵ UINT8* pDataBuf ݻ +* UINT16 *pDataLength ݳ() +* UINT16 wTrainId гID0x14 +* ֵ CI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2023.11.10 +*/ +static UINT8 PackCiToIvocSnowAndUrgentInfo(UINT8* pDataBuf, UINT16* pDataLength, UINT16 wTrainId); + +/* +* CiVOBCͨźŻ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20240607 +*/ +static UINT8 PackCiToVobcSigInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CIVOBC״̬ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* VobcToCiDataStruct *pstVobcToCiDataStru VOBCCI +* ֵ 0:ʧ +* 1:ݳɹ +* by cgh 20240704 +*/ +static UINT8 PackCiToVobcBackUpStateData(UINT8* pDataBuf, UINT16* wDataLength, VobcToCiDataStruct* pstVobcToCiDataStru); + +/* +* CiIvocITEȫг״̬ +* ˵const UINT8* dataBuf ݻΣ +* const UINT16 *dataLength ݳȣΣ +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.07.12 +*/ +static UINT8 PackCiToIvocIteLineCutInfo(UINT8* pDataBuf, UINT16* wDataLength); + + +/* +* CiIvocԶδռ߼ + * ˵ UINT8* dataBuf, ݻ + * UINT16 *dataLength, ݳ + * UINT16 wTrainId гID +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LC +*/ +static UINT8 PackCiToIvocFarNoOccuLogInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvocNVRAMλüල״̬ +* ˵const UINT8* dataBuf ݻΣ +* const UINT16 *dataLength ݳȣΣ +* const UINT16 wTrainId гID +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.08.19 +*/ +static UINT8 PackCiToIvocPosMonitorInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrainId); + + +/*ʹ*/ +VobcToCiDataStruct VobcToCiDataStru[VOBC_TO_CI_SUM_MAX] = {0u};/*ͨŵVobcϢ*/ + +VobcBackUpToCiDataStruct VobcBackUpToCiDataStru[VOBC_BACKUP_TO_CI_SUM_MAX] = { 0u };/*ʹúģʽͨŵVobcϢ*/ + +UINT8 VobcToCiSum = 0u;/*ͨŵVobcĿ*/ + + +/*վӳ + stationId == 1,ӳ䵽platformToCiDataStru[1] +*/ +extern PlatformToCiDataStruct platformToCiDataStru[PLATFORM_TO_CI_SUM_MAX]; + +/*PlatformToCiDataStructṹеλ:PsdӳΪУPsdվӳΪһУPsdToCiDataStructλӳΪ2 + 1platformToCiDataStruеλΪ:վΪPsdPlatformIndex[1][0] ,ŵĽṹλΪPsdPlatformIndex[1][1] +*/ +extern UINT8 PsdPlatformIndex[PSD_SUM_MAX][2]; + + +/* +* VOBC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseVobcToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId,const UINT16 logId) +{ + UINT8 ii = 0u; /**/ + UINT8 retVal = CI_SUCCESS; + UINT8 lineIdentity = 0u; /*·ʶ*/ + UINT8 galHeadSaved = 0u; + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡ·ʶ*/ + /*ܴVOBCж*/ + if (VobcToCiSum >= VOBC_TO_CI_SUM_MAX) + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS==retVal) + { + (void)memset(&(VobcToCiDataStru[VobcToCiSum]),0,sizeof(VobcToCiDataStruct));/*ڴ棬ֹ*/ + + if (LINE_HLHT == lineIdentity)/*ͨ·*/ + { + retVal = ParseVobcToCiDataFrameHLHT(dataBuf, dataLength, systemId, &(VobcToCiDataStru[VobcToCiSum]), &galHeadSaved,logId); + } + else if (LINE_FAO == lineIdentity)/*FAO·*/ + { + retVal = ParseVobcToCiDataFrameFAO(dataBuf,dataLength,systemId,&(VobcToCiDataStru[VobcToCiSum])); + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity)||(LINE_FAOHLHT_ONESELFSECOND == lineIdentity))/*FAO+HLHT·*/ + { + retVal = ParseVobcToCiDataFrameFAOHLHT(dataBuf, dataLength, systemId, &(VobcToCiDataStru[VobcToCiSum]), &galHeadSaved,logId); + } + else if (LINE_CC == lineIdentity)/*·*/ + { + retVal = ParseIvocToCiDataFrameCC(dataBuf, dataLength, systemId, &(VobcToCiDataStru[VobcToCiSum]), &galHeadSaved, logId); + } + else + { + retVal = CI_ERROR; + } + + if(CI_SUCCESS == retVal) + { + VobcToCiSum++; + /*ȥ*/ + for (ii = 0u; ii < VobcToCiSum; ii++) + { + /*һ*/ + if (ii == VobcToCiSum - 1u) + { + break; + } + + if (VobcToCiDataStru[ii].VobcId == VobcToCiDataStru[VobcToCiSum - 1U].VobcId) + {/*гӵгһ*/ + CopyVobcToCiMsg(&(VobcToCiDataStru[VobcToCiSum-1U]),&(VobcToCiDataStru[ii])); + VobcToCiSum--; + } + } + } + else + { + if ((LINE_HLHT == lineIdentity) || (LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) + || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) || (LINE_CC == lineIdentity)) + { + + /*ͨͷѾˣִͨͷ򣬳Ҳͨͷ*/ + if (0u == galHeadSaved) + { + ClearHlhtHeadCtx(CI_SYSTEM_TYPE_VOBC, systemId); + } + else + { + ; + } + } + else + { + ; /*޲*/ + } + } + } + + return retVal; +} + +/* +* VOBCͨ֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseVobcBackUpToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, const UINT16 logId) +{ + UINT8 retVal = CI_SUCCESS; + UINT8 VobcID = systemId; /*ʹóIDӦṹIDᳬ255*/ + UINT32 errCode = 0U; + UINT32 curntCycleNo = 0U; /*ǰں*/ + UINT8 ii = 0U; /**/ + UINT8 jj = 0U; + UINT8 headRet = HLHT_HEAD_ERROR;/*ͨ*/ + UINT16 vobcName = 0U; /*VOBC豸ƣ+ID*/ + UINT16 ciName = 0U; /*豸ƣ+ID*/ + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + UINT16 appInfoType = 0U; /*ӦϢ*/ + UINT8 trainDirection = 0U; /*г*/ + UINT8 trainLevel = 0U; /*гм*/ + HLHTGALInfoStruct vobvBackupGalHead = { 0U }; /*뻥ͨͬʽͨñͷ*/ + VobcBackUpToCiDataStruct VobcBackUpTemp; + VobcBackUpToCiDataStruct* vobcBackupToCiCur = &VobcBackUpTemp; + VobcBackUpToCiDataStruct* vobcBackup = &VobcBackUpToCiDataStru[VobcID]; + UINT8 ci_vobcPrtclVersion = 0U; + INT32 vobcInfoRemainValidiy = 0; /*УʱЧ*/ + UINT16 maxHeadLink = 0U; /*ǰlink*/ + UINT32 maxHeadOff = 0U; /*ǰlInkƫ*/ + UINT16 minTailLink = 0U; /*Сlink*/ + UINT32 minTailOff = 0U; /*Сlinkƫ*/ + UINT8 psdSum = 0U; + UINT16 psdId = 0U; /*PSDID*/ + UINT32 psdIdIntConnt = 0U; /*ͨPSDID*/ + UINT8 psdCmdCode = 0U; /*վ̨ſ*/ + UINT8 cmdType = 0U; /*ſϢ0x550xAA*/ + UINT8 funRet = 0U; + UINT8 galSaveTag = 0U; /*ͨͷ־*/ + UINT32 hlhtStationId = 0U; /*ȡͨվ̨ID*/ + UINT32 transmitBadEnsureTime = 0U; /*ͨʧЧʱ*/ + UINT16 TrainSignalId = 0U; + UINT8 errorNum = 0U; + UINT32 dwHlhtNs = 0U; + UINT16 wHeadTrainId = 0U;/*гǰID*/ + UINT16 wTrainRelLgcId = 0U;/*гʹö*/ + UINT8 chNvramPosFlag = 0U;/*NVRAMλñʶ*/ + UINT8 chStopSteayFlag = 0U; /*ͣ׼ͣ״̬*/ + UINT32 dwTrackSecId = 0U; /*ͣ׼Id*/ + + (void)memset(vobcBackupToCiCur, 0, sizeof(VobcBackUpToCiDataStruct));/*ڴ棬ֹ*/ + + /*У*/ + if ((NULL == dataBuf) + || (NULL == vobcBackupToCiCur) + || (NULL == vobcBackup) + || (CI_IVOC_PACKET_LENGTH_MAX< dataLength)) + { + retVal = CI_ERROR; + } + else + { + ; /**/ + } + + if (CI_SUCCESS == retVal) + { + ci_vobcPrtclVersion = GetVersionOfVOBCToCI(); + vobcName = (CI_SYSTEM_TYPE_VOBC)* 256U + systemId; + ciName = (CI_SYSTEM_TYPE_CI)* 256U + localCiId; + /*ͨϢͷ*/ + vobvBackupGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]); + ii += 2U; + vobvBackupGalHead.sourceId = LongFromChar(&dataBuf[ii]); + ii += 4U; + vobvBackupGalHead.destId = LongFromChar(&dataBuf[ii]); + ii += 4U; + vobvBackupGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]); + ii += 4U; + vobvBackupGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4U; + vobvBackupGalHead.comPeriod = ShortFromChar(&dataBuf[ii]); + ii += 2U; + vobvBackupGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4U; + vobvBackupGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4U; + vobvBackupGalHead.prtclVer = dataBuf[ii++]; + vobvBackupGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]); + ii += 2U; + + curntCycleNo = Get2oo2CurCycleNum(); + + + /*ͨϢͷУͨ && ʱЧ żϢ*/ + headRet = HLHTRecvCommonPacketHeadCheck(vobcName, ciName, CI_VOBC_BACKUP_INTERFACE_INFOTYPE, CI_IVOC_BACKUP_PRTCL_VER, &vobvBackupGalHead, &errCode, logId, CI_SYSTEM_TYPE_VOBC); + transmitBadEnsureTime = 2U*GetCiAndVobcTransBadEnsureTime(); + debug_infor_printf((const)"\nVOBC_BACK_UP %d GAL Check Result:%d errCode:%d", systemId, headRet, errCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + if (HLHT_HEAD_SUCCESS == headRet) + { + /*ϢʱЧ*/ + vobcInfoRemainValidiy = HLHTCommonMsgRemainingValidity(transmitBadEnsureTime, curntCycleNo, GetSystemParaAppCycleTime(), vobvBackupGalHead.recvOppMsgSN, vobvBackupGalHead.crntOwnMsgSN, vobvBackupGalHead.preOwnMsgSN, vobvBackupGalHead.comPeriod); + /*Ч*/ + if (0 < vobcInfoRemainValidiy) + { + /*Ӧ*/ + /*½յһϢʱıں*/ + ii += 2U;/*Ӧñij2ֽ*/ + + appInfoType = ShortFromChar(&dataBuf[ii]);/*ӦϢͣ0x0308VOBCͨRC/CI*/ + ii += 2U; + vobcBackupToCiCur->appInfoType = appInfoType; + vobcBackupToCiCur->VobcId = systemId; + vobcBackupToCiCur->vobcLogId = logId;/*洢VOBC߼ID1˻2*/ +#if 0 + vobcToCiDataStru->vobcInfoStartCycNum = Get2oo2CurCycleNum();/*CIյVOBC͵Ϣʼ*/ +#endif + ii += 2U;/*Ԥֽ*/ + + if (VOBC_CI_INFO_TYPE_BACKUP == appInfoType) + {/*ֻеVOBCCIϢſƱʱżϢ*/ + + /*VOBCģʽͨں*/ + vobcBackupToCiCur->ComStartCycle= curntCycleNo; + + /*гпƼЧУ*/ + trainLevel = dataBuf[ii++]; + if ((TRAIN_LEVEL_BACKUP_LIANXU == trainLevel) || (TRAIN_LEVEL_BACKUP_BLOCK == trainLevel) || (TRAIN_LEVEL_BACKUP_CI == trainLevel) + || (TRAIN_LEVEL_BACKUP_ABL == trainLevel) || (TRAIN_LEVEL_BACKUP_UNKNOWN == trainLevel) ) + { + /*01:510=CBTC/VBTC02:ʽ510=ITC03:510=IL/ĿUR */ + vobcBackupToCiCur->chTrainLevel = trainLevel; + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"\nVOBC_BACK_UP %d trainLevel ERROR%d", systemId, trainLevel); + } + + /*гзж*/ + trainDirection = dataBuf[ii++]; + if ((TRAIN_DIR_UP == trainDirection) || (TRAIN_DIR_DOWN == trainDirection) || (TRAIN_DIR_DEF == trainDirection)) + { + vobcBackupToCiCur->trainDirection = trainDirection; + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"\nVOBC_BACK_UP %d trainDirection ERROR%d", systemId, trainDirection); + } + + /*ȡֵУ*/ + if (CI_SUCCESS == retVal) + { +#if 0 + hlhtStationId = LongFromChar(&dataBuf[ii]); + ii += 4U; + vobcBackupToCiCur->wNextStation = 0u; + (void)dquQueryInDevIndex(QFUN_IDMAP_STATION_ID, hlhtStationId, &vobcBackupToCiCur->wNextStation); +#endif + maxHeadLink = ShortFromChar(&dataBuf[ii]); /*гȫǰLink*/ + ii += 2U; + maxHeadOff = LongFromChar(&dataBuf[ii]); /*гȫǰƫ*/ + ii += 4U; + minTailLink = ShortFromChar(&dataBuf[ii]); /*гСȫLink*/ + ii += 2U; + minTailOff = LongFromChar(&dataBuf[ii]); /*гСȫƫ*/ + ii += 4U; + + if ((0u != maxHeadLink) && (UINT16_MAX != maxHeadLink) + && (0u != minTailLink) && (UINT16_MAX != minTailLink) + && (UINT32_MAX != maxHeadOff) && (UINT32_MAX != minTailOff)) + { + vobcBackupToCiCur->wTrainMaxSafeHeadLink = maxHeadLink; + vobcBackupToCiCur->dwTrainMaxSafeHeadOffset = maxHeadOff; + vobcBackupToCiCur->wTrainMinSafeTailLink = minTailLink; + vobcBackupToCiCur->dwTrainMinSafeTailOffset = minTailOff; + } + else + { + retVal = CI_ERROR; /*ֵǷ*/ + debug_infor_printf((const)"\nVOBC_BACK_UP %d Link & Offset ERROR", systemId); + } + } + else + { + ; /**/ + } + /*ȡ*/ + if (CI_SUCCESS == retVal) + { + psdCmdCode = dataBuf[ii++]; /*վ̨룬ÿӦCIҪһվ̨*/; + vobcBackupToCiCur->psdCmdCode = psdCmdCode & 0x1fU; + if ((4U == vobcBackupToCiCur->psdCmdCode) + || (6U == vobcBackupToCiCur->psdCmdCode) + || (8U == vobcBackupToCiCur->psdCmdCode) + || (0U == vobcBackupToCiCur->psdCmdCode)) + {/*гϢȡֵΪ0468*/ + ; /*ȡֵϷ*/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"\nVOBC_BACK_UP %d psdCmdCode ERROR%d", systemId, vobcBackupToCiCur->psdCmdCode); + } + psdSum = dataBuf[ii]; + ii += 1U; + + if ((2U == psdSum) || (1U == psdSum) || (0U == psdSum)) + {/*ӿڶ壺ȡֵΪ012*/ + vobcBackupToCiCur->PsdSum = psdSum; /**/ + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"\nVOBC_BACK_UP %d psdNum ERROR%d", systemId, psdSum); + } + } + else + { + ; /**/ + } + /*ȡУϢ*/ + if (CI_SUCCESS == retVal) + { + for (jj = 0U; jj < psdSum; jj++) + { + psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*ȡͨ4ֽID*/ + ii += 4U; + vobcBackupToCiCur->PsdData[jj].PsdIdInterConn = psdIdIntConnt; + + /*ݻͨ4ֽIDȡID*/ + funRet = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId); + + if (CI_SUCCESS == funRet) + { + vobcBackupToCiCur->PsdData[jj].PsdId = psdId; + + cmdType = dataBuf[ii];/*ȡ*/ + ii += 1U; + if (((VOBCTOCI_COMMAND_TYPE_PSDOPEN == cmdType)&& (0U != vobcBackupToCiCur->psdCmdCode)) + || (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT == cmdType)) + { + /*ʱϢҪΪЧֵ*/ + vobcBackupToCiCur->PsdData[jj].CmdType = cmdType; + + vobcBackupToCiCur->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum(); + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"\nVOBC_BACK_UP %d PSD cmdType : %d, cmdCode : \n", systemId, cmdType, vobcBackupToCiCur->psdCmdCode); + } + } + else + { + ii += 1U; + } + } + } + else + { + ; /**/ + } + + /*ǰźŻID*/ + if (CI_SUCCESS == retVal) + { + dwHlhtNs = LongFromChar(&dataBuf[ii]);/*ظյźŻID*/ + ii += 4U; + if (0x00000000U == dwHlhtNs) + { + /*ĬֵǰIDΪ0*/ + vobcBackupToCiCur->wTrainHeadCurSignalId = 0U; + } + else + { + /*ݻͨ4ֽIDȡźŻID*/ + funRet = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, dwHlhtNs, &TrainSignalId); + if ((CI_SUCCESS == funRet) && (SIGNAL_SUM_MAX > TrainSignalId)) + { + vobcBackupToCiCur->wTrainHeadCurSignalId = TrainSignalId; + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"\nVOBC_BACK_UP %d wTrainHeadCurSignalId : %d\n", systemId, dwHlhtNs); + + } + } + } + else + { + ; /**/ + } + + /*ǰID*/ + if (CI_SUCCESS == retVal) + { + dwHlhtNs = LongFromChar(&dataBuf[ii]); + ii += 4U; + if (0xFFFFFFFFU == dwHlhtNs) + { + /*ĬֵǰIDΪ0*/ + vobcBackupToCiCur->wTrainHeadTrainId = 0x14FFU; + } + else + { + retVal = dquHlhtId2VobcName(dwHlhtNs, &wHeadTrainId, &wTrainRelLgcId); + if (CI_SUCCESS == retVal) + { + vobcBackupToCiCur->wTrainHeadTrainId = wHeadTrainId; + } + else + { + retVal = CI_ERROR; + debug_infor_printf((const)"\nVOBC_BACK_UP %d wTrainHeadTrainId : %d\n", systemId, dwHlhtNs); + } + } + } + else + { + /*󲻼*/ + } + + /*NVRAMλñʶ*/ + if (CI_SUCCESS == retVal) + { + chNvramPosFlag = dataBuf[ii++]; + if ((TRAIN_NVRAM_POS_FLAG_YES == chNvramPosFlag) || (TRAIN_NVRAM_POS_FLAG_NO == chNvramPosFlag)) + { + vobcBackupToCiCur->chNvramPosFlag = chNvramPosFlag; + } + else + { + debug_infor_printf((const)"\nVOBC_BACK_UP %d chNvramPosFlag : %d\n", systemId, chNvramPosFlag); + retVal = CI_ERROR; + } + } + else + { + ; /**/ + } + + /*гͣ״̬*/ + if (CI_SUCCESS == retVal) + { + + chStopSteayFlag = dataBuf[ii]; + ii += 1U; + dwTrackSecId = LongFromChar(&dataBuf[ii]); + ii += 4U; + if ((VOBC_CI_STOP_TW == chStopSteayFlag) || (VOBC_CI_STOP_WTW == chStopSteayFlag)) + { + vobcBackupToCiCur->chStopSteadyState = chStopSteayFlag; + vobcBackupToCiCur->stopSteadyStartCycNum = Get2oo2CurCycleNum(); + vobcBackupToCiCur->trackSecID = dwTrackSecId; + } + else + { + debug_infor_printf((const)"\nVOBC_BACK_UP %d chStopSteayFlag : %d\n", systemId, chStopSteayFlag); + retVal = CI_ERROR; + } + } + + /*Ԥ5ֽ*/ + ii += 5U; + } + else + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + /*Уݳ*/ + if (vobvBackupGalHead.totalDataLen != ii - 31U) + { + /* 31ΪӦ֡ͷ */ + debug_infor_printf((const)"\nVOBC_BACK_UP %d len Error vobvBackupGalHead.totalDataLen:%d Infactlen%d", systemId, vobvBackupGalHead.totalDataLen,ii); + retVal = CI_ERROR; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + + /*ݾУ飬Ҫ洢ͨñ*/ + if (CI_SUCCESS == retVal) + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, logId); + + galSaveTag = 1U; + } + else + { + ; /**/ + } + } + else + { + retVal = CI_ERROR; + } + } + /*һյVOBCϢʱУ鲻ֻͨ¼curntOwnMsgԼǰں*/ + else if (HLHT_HEAD_INIT == headRet) + { + if (0U < curntCycleNo)/*жŴ0*/ + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, vobvBackupGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC_BACKUP, systemId, logId); + + galSaveTag = 1u; + } + else + { + ; /**/ + } + + retVal = CI_ERROR; + } + else + { + /*ATSֵطVOBC-CIݽӿϢʹ*/ + if (GAL_COMPARE_INFO_TYPE_ERR == (errCode & GAL_COMPARE_INFO_TYPE_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_INFO_TYPE_ERR, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + /*ATSֵطVOBC-CIݷͷʶϢ*/ + if (GAL_COMPARE_SEND_FLAG_ERR == (errCode & GAL_COMPARE_SEND_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_SEND_FLAG_ERR, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + + /*ATSֵطVOBC-CIݽշ־Ϣ*/ + if (GAL_COMPARE_RECV_FLAG_ERR == (errCode & GAL_COMPARE_RECV_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_RECV_FLAG_ERR, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + /*ATSֵطVOBC-CIݰ汾УʧϢ*/ + if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_VER_CHECK_FAIL, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + /*ATSֵطVOBC-CIݱԷյһϢʱкŴ*/ + if (GAL_COMPARE_MSG_BDS_SN_ERR == (errCode & GAL_COMPARE_MSG_BDS_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_MSG_BDS_SN_ERR, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + + /*ATSֵطVOBC-CIݶԷϢкżյһϢʱкŴ*/ + if (GAL_COMPARE_MSG_SN_ERR == (errCode & GAL_COMPARE_MSG_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_MSG_SN_ERR, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + /*ATSֵطVOBC-CIЭ汾Ŵ*/ + if (GAL_COMPARE_PROTOCOL_VER_ERR == (errCode & GAL_COMPARE_PROTOCOL_VER_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_PROTOCOL_VER_ERR, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + + /*ATSֵطVOBC-CIӦòݳЧ*/ + if (GAL_COMPARE_APP_LEN_ERR == (errCode & GAL_COMPARE_APP_LEN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_APP_LEN_ERR, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + + /*ATSֵطVOBC-CIͨڴ */ + if (GAL_COMPARE_COM_PERIOD == (errCode & GAL_COMPARE_COM_PERIOD)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_COM_PERIOD, ESEND_LEVEL_ATS); + errorNum++; + } + else + { + ; /*޲*/ + } + + /*쳣*/ + if((0U != errCode)&&(0U == errorNum)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_DEVICE_TYPE_BACKUP_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_ERROR, ESEND_LEVEL_ATS); + } + else + { + ; /*޲*/ + } + retVal = CI_ERROR; + } + } + else + { + ; /**/ + } + + if (CI_SUCCESS == retVal) + { + if ((NULL != vobcBackupToCiCur) && (NULL != vobcBackup)) + { + (void)CommonMemCpy((void *)(vobcBackup), (UINT32)sizeof(VobcBackUpToCiDataStruct), (void *)(vobcBackupToCiCur), (UINT32)sizeof(VobcBackUpToCiDataStruct)); + } + else + { + retVal = CI_ERROR; + } + } + else if(HLHT_HEAD_INIT == headRet) + { + /*Գʼ֡ id*/ + vobcBackup->VobcId = systemId; + } + else + { + ; /*do nothing*/ + } + return retVal; +} + + +/* +* VOBC +* ˵ void +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToVobcData(void) +{ + UINT32 ii = 0u; + UINT8 retVal = CI_SUCCESS; + UINT8 lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY); + UINT8 initVobcIds[UINT8_MAX] = { 0u }; + UINT16 initVobcIdLogIds[UINT8_MAX] = { 0u }; + UINT8 initVobcSum = 0u; + debug_infor_printf((const)"\nPackCiToVobcData VobcToCiSum = %d\n", VobcToCiSum); /*ӡCIͨŵVOBCĿ*/ + for (ii = 0u; (ii < (UINT32)VobcToCiSum) && (ii < VOBC_TO_CI_SUM_MAX); ii++) + { + if (LINE_HLHT == lineIdentity)/*ͨ·*/ + { + retVal = PackCiToVobcDataHLHT(&(VobcToCiDataStru[ii])); + } + else if (LINE_FAO == lineIdentity) + {/*FAO*/ + retVal = PackCiToVobcDataFAO(&(VobcToCiDataStru[ii])); + } + else if (LINE_FAOHLHT == lineIdentity) + {/*FAO+ͨ·*/ + retVal = PackCiToVobcDataFAOHLHT(&(VobcToCiDataStru[ii])); + } + else if (LINE_CC == lineIdentity) + { + /*·*/ + retVal = PackCiToIvocDataCC(&(VobcToCiDataStru[ii])); + } + else if (LINE_FAOHLHT_ONESELF == lineIdentity) + { + retVal = PackCiToVobcDataFAOHLHToneSelf(&(VobcToCiDataStru[ii])); + } + else if (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) + { + retVal = PackCiToVobcDataFAOHLHToneSelfSecond(&(VobcToCiDataStru[ii])); + } + else + { + retVal = CI_ERROR; + } +#if 0 + if (CI_ERROR==chRetVal) + { + break; /*ע͵ֹijʧܣijVOBCղϢCIж*/ + } +#endif + } + + if ((LINE_HLHT == lineIdentity) + || (LINE_FAOHLHT == lineIdentity) + || (LINE_CC == lineIdentity) + || (LINE_FAOHLHT_ONESELF == lineIdentity) + || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity))/*ͨ·FAO+ͨ·*/ + { + /*VOBCͨñͷݣЭ涨VOBC״θCIʱȻУ޷ͨ޷õݣCIҪVOBC*/ + if (CI_SUCCESS == GetHlhtInitHeadDevsByDevType(CI_SYSTEM_TYPE_VOBC, initVobcIds, (UINT8)sizeof(initVobcIds), &initVobcSum, initVobcIdLogIds)) + { + for (ii = 0u; ii < initVobcSum; ii++) + { + retVal &=PackCiToVobcDataHLHTHeart(initVobcIds[ii], initVobcIdLogIds[ii]); + debug_infor_printf((const)"\nPACK HEARTFARME TO VOBC %d", initVobcIds[ii]); /*ӡϢ*/ + } + } + else + { + } + } + else + { + } + + + return retVal; +} + +/* +* VOBCͨ +* ˵ void +* ֵ CI_ERRORʧ CI_SUCCESSɹ +*/ +UINT8 PackCiToVobcBackUpData(void) +{ + UINT32 ii = 0u; + UINT8 retVal = CI_ERROR; + UINT8 VobcBackUpToCiSum = 0U;/*ͨŵĺͨVobcĿ*/ + UINT32 dwCycNum = 0U; + UINT8 chHeadCheck = 0U; + + dwCycNum = Get2oo2CurCycleNum(); + for (ii = 0u; ii < VOBC_BACKUP_TO_CI_SUM_MAX; ii++) + { + if (0U != VobcBackUpToCiDataStru[ii].VobcId) + { + chHeadCheck = BackupHeadCheckValid(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(VobcBackUpToCiDataStru[ii].VobcId)); + + if ((CI_SUCCESS == chHeadCheck) || ((CI_SUCCESS != chHeadCheck) && (dwCycNum == VobcBackUpToCiDataStru[ii].ComStartCycle))) + { + /*ʼ״̬߲֡dzʼ״̬Ҫյ*/ + /*鳵ͨϢ*/ + debug_infor_printf((const)"\nPackCiToVobcData BackUpVobcID: %d\n", VobcBackUpToCiDataStru[ii].VobcId); + retVal = PackCiToIvocBackUpDataCC(&VobcBackUpToCiDataStru[ii]); + VobcBackUpToCiSum++; + } + else + { + ; /**/ + } + } + else + { + ; /*ЧгID */ + } + } + debug_infor_printf((const)"\nPackCiToVobcData VobcBackUpToCiSum = %d\n", VobcBackUpToCiSum); /*ӡCIͨŵVOBCĿ*/ + return retVal; +} +/* +* ȡVOBCCIṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: VOBCCIṹָ +*/ +VobcToCiDataStruct* GetVobcToCiDataStru(void) +{ + VobcToCiDataStruct * retVal = NULL; + if (VobcToCiSum == 0u) + { + retVal = NULL; + } + else + { + retVal = VobcToCiDataStru; + } + return retVal; +} + +/* +* ȡVobc id +* ˵ UINT16 idx:VOBC͸CIϢṹλ +* ֵ 0:ʧ +* ֵ:VobcId +*/ +UINT16 GetVobcIdByIndex(UINT16 index) +{ + UINT16 retVal = 0u; + if (index < VOBC_TO_CI_SUM_MAX) + { + retVal = VobcToCiDataStru[index].VobcId; + } + return retVal; +} + +/* +* ȡVobc Ϣ +* ˵ UINT16 idx:VOBC͸CIϢṹλ +* ֵ 0:ʧ +* ֵ:VobcId +*/ +UINT8 GetVobcEditGroupInfoByIndex(UINT16 index) +{ + UINT8 retVal = 0u; + if (index < VOBC_TO_CI_SUM_MAX) + { + retVal = (UINT8)(VobcToCiDataStru[index].trainEditGroupInfo); + } + return retVal; +} + +/* +* ȡVOBCCIṹ +* ˵ void +* ֵ +*/ +UINT8 GetVobcToCiSum(void) +{ + return VobcToCiSum; +} + +/* +* ȡűϢ +* ˵ const UINT16 psdId :ID +* ֵ 01:ı +* 02: +* 08:˱ +* CI_ERROR: Ϸ +*/ +UINT8 GetPsdEditGroupInfo(const UINT16 psdId) +{ + UINT8 ii = 0u, jj = 0u; + VobcToCiDataStruct * vobcToCiDataStru = NULL; + UINT8 retVal = 0u; + vobcToCiDataStru = GetVobcToCiDataStru(); + + if(NULL != vobcToCiDataStru) + { + for(ii = 0u;ii < GetVobcToCiSum();ii++) + { + for(jj = 0u;jj < vobcToCiDataStru[ii].PsdSum; jj++) + { + if(psdId == vobcToCiDataStru[ii].PsdData[jj].PsdId) + { + break; + } + } + if(jj < vobcToCiDataStru[ii].PsdSum) + { + break; + } + } + if(ii < GetVobcToCiSum()) + { + retVal = (UINT8)(vobcToCiDataStru[ii].trainEditGroupInfo); + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* VOBC͸CIϢṹУɾָλõ +* ˵ const UINT8 idx:VOBC͸CIϢṹλ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 RemoveVobcToCiMsgAt(UINT8 idx) +{ + UINT8 retVal = CI_ERROR; + UINT8 afIdx; + if(idx>=VobcToCiSum) + { + retVal = CI_ERROR; + } + else + { + for(afIdx=idx+1U;afIdxCIźŻID*/ + + +#endif + UINT8 ci_vobcPrtclVersion = 0u; + + ci_vobcPrtclVersion = GetVersionOfVOBCToCI(); + vobcName = (CI_SYSTEM_TYPE_VOBC)*256U + systemId; + ciName = (CI_SYSTEM_TYPE_CI)*256U + localCiId; + + /*ͨϢͷ*/ + hlhtGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.sourceId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.destId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.comPeriod = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.prtclVer = dataBuf[ii++]; + hlhtGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + curntCycleNo = Get2oo2CurCycleNum(); + + vobcToCiDataStru->vobcLogId = logId;/*洢VOBC߼ID1˻2*/ + /*ͨϢͷУͨ && ʱЧżϢ*/ + /*һյVOBCϢʱУ鲻ֻͨ¼curntOwnMsgԼǰں*/ + headRet = HLHTRecvCommonPacketHeadCheck(vobcName, ciName, CI_VOBC_INTERFACE_INFOTYPE, ci_vobcPrtclVersion, &hlhtGalHead, &errCode, logId,CI_SYSTEM_TYPE_VOBC); + + debug_infor_printf((const)"\nVOBC %d GAL Check Result:%d errCode:%d", systemId,headRet,errCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + if (HLHT_HEAD_SUCCESS==headRet) + { + /*ϢʱЧ*/ + vobcInfoRemainValidiy = HLHTCommonMsgRemainingValidity(GetCiAndVobcTransBadEnsureTime(), curntCycleNo, GetSystemParaAppCycleTime(), hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN, hlhtGalHead.comPeriod); + + if (0 < vobcInfoRemainValidiy) + { + /*Ӧ*/ + /*½յһϢʱıں*/ + ii += 2u;/*Ӧñij2ֽ*/ + + appInfoType = ShortFromChar(&dataBuf[ii]);/*ӦϢͣſϢ֡Ϣ*/ + ii += 2u; + vobcToCiDataStru->appInfoType = appInfoType; + vobcToCiDataStru->VobcId = systemId; +#if 0 + vobcToCiDataStru->vobcInfoStartCycNum = Get2oo2CurCycleNum();/*CIյVOBC͵Ϣʼ*/ +#endif + + ii += 2u;/*Ԥֽ*/ + + if (VOBC_CI_INFO_TYPE_PSD_CONTROL == appInfoType) + {/*ֻеVOBCCIϢſƱʱżϢ*/ + vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + /*гзж*/ + trainDirection = dataBuf[ii]; + ii += 1u; + + if ((TRAIN_DIR_UP == trainDirection) || (TRAIN_DIR_DOWN == trainDirection) || (TRAIN_DIR_DEF == trainDirection)) + { + vobcToCiDataStru->trainDirection = trainDirection; + } + else + { + retVal = CI_ERROR; + } + + /*гͣͣ׼Ϣж*/ + if (CI_SUCCESS == retVal) + { + trainStopSteadyState = dataBuf[ii]; + ii += 1u; + + if ((VOBC_CI_STOP_TW == trainStopSteadyState) || (VOBC_CI_STOP_WTW == trainStopSteadyState)) + { + vobcToCiDataStru->trainStopSteadyState = trainStopSteadyState; + vobcToCiDataStru->stopSteadyStartCycNum = Get2oo2CurCycleNum();/*¼յͣȻδͣϢ*/ + } + else + { + retVal = CI_ERROR; + } + } + else + { + } + + trackSectionId = LongFromChar(&dataBuf[ii]);/*ȡID*/ + ii += 4u; + vobcToCiDataStru->trackSecID = trackSectionId; + + if (CI_SUCCESS == retVal) + { + vobcToCiDataStru->VobcId = systemId; /*VOBCID*/ + vobcToCiDataStru->psdCmdCode = dataBuf[ii++]; /*վ̨룬ÿӦCIҪһվ̨*/ + /*վ̨ȡϢĵ5λʾгʵʱ*/ + + /*ΪڹʱVOBCͳĬֵ,Ҫڿʱ泵ֵ*/ + cTempPsdCmdCode = 0x1Fu & vobcToCiDataStru->psdCmdCode; + if (0U != cTempPsdCmdCode) /*ȱYF0083-6822023-07-03*/ + { + vobcToCiDataStru->trainEditGroupInfo = cTempPsdCmdCode; + } + else + { + vobcToCiDataStru->trainEditGroupInfo = vobcToCiDataStru->trainEditGroupInfo; + } + + psdSum = dataBuf[ii]; + ii += 1u; + + if ((2u == psdSum) || (1u == psdSum) || (0u == psdSum)) + {/*ӿڶ壺ȡֵΪ012*/ + vobcToCiDataStru->PsdSum = psdSum; /**/ + } + else + { + retVal = CI_ERROR; + } + } + else + { + } + + if (CI_SUCCESS == retVal) + { + for (jj = 0u; jj < 2u; jj++) + { + psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*ȡͨ4ֽID*/ + ii += 4u; + vobcToCiDataStru->PsdData[jj].PsdIdInterConn = psdIdIntConnt; + + /*ݻͨ4ֽIDȡID*/ + retValue = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId); + + if (CI_SUCCESS == retValue) + { + vobcToCiDataStru->PsdData[jj].PsdId = psdId; + + cmdType = dataBuf[ii];/*ȡ*/ + ii += 1u; + if ((VOBCTOCI_COMMAND_TYPE_PSDOPEN == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCHECK == cmdType)) /*ȱYF0083-6822023-07-03*/ + { + vobcToCiDataStru->PsdData[jj].CmdType = cmdType; + + vobcToCiDataStru->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum(); + } + else + { + retVal = CI_ERROR; + } + } + else + { + ii++; + } + } + + + /*޸20180111޸ԭ򣺻ͨVOBC-CIӿڻˣVOBCCI4ֽźŻIDӦԽ*/ +#if 0 + /*µĽӿڣźŻID1~0xFFFFFFFF,0ΪĬֵVOBCȫǰǰгзͬźŻ*/ + signalId = LongFromChar(&dataBuf[ii]); /*ȡźŻID*/ + ii += 4u; + + vobcToCiDataStru->signalID = signalId; /*źŻID浽ṹ*/ +#endif + } + else + { + } + } + else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == appInfoType) || (VOBC_CI_INFO_TYPE_LOGOUT_ASK == appInfoType)) + {/*֡ע֡*/ + vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + } + else + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + /*Уݳ*/ + if (ii > dataLength) + { + retVal = CI_ERROR; + } + else + { + } + } + else + { + } + + if (CI_SUCCESS == retVal) + { + /*ݾУ飬Ҫ洢ͨñ*/ + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId); + + *saveGalHead = 1u; + } + else + { + } + } + else + { + retVal = CI_ERROR; + } + } + else if (HLHT_HEAD_INIT ==headRet) + { + if (curntCycleNo > 0u)/*жŴ0Ϊ0Ч*/ + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId); + + *saveGalHead = 1u; + } + else + { + } + + retVal = CI_ERROR; + } + else + { + /*ATSֵطVOBC-CIݽӿϢʹ*/ + if (GAL_COMPARE_INFO_TYPE_ERR == (errCode & GAL_COMPARE_INFO_TYPE_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_INFO_TYPE_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݷͷʶϢ*/ + else if (GAL_COMPARE_SEND_FLAG_ERR == (errCode & GAL_COMPARE_SEND_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_SEND_FLAG_ERR,ESEND_LEVEL_ATS); + } + else + { + /*޲*/ + } + /*ATSֵطVOBC-CIݽշ־Ϣ*/ + if (GAL_COMPARE_RECV_FLAG_ERR == (errCode & GAL_COMPARE_RECV_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_RECV_FLAG_ERR,ESEND_LEVEL_ATS); + } + else + { + /*޲*/ + } + /*ATSֵطVOBC-CIݰ汾УʧϢ*/ + if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_VER_CHECK_FAIL,ESEND_LEVEL_ATS); + } + else + { + /*޲*/ + } + /*ATSֵطVOBC-CIݱԷյһϢʱкŴ*/ + if (GAL_COMPARE_MSG_BDS_SN_ERR == (errCode & GAL_COMPARE_MSG_BDS_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_MSG_BDS_SN_ERR,ESEND_LEVEL_ATS); + } + else + { + /*޲*/ + } + /*ATSֵطVOBC-CIݶԷϢкżյһϢʱкŴ*/ + if (GAL_COMPARE_MSG_SN_ERR == (errCode & GAL_COMPARE_MSG_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_MSG_SN_ERR,ESEND_LEVEL_ATS); + } + else + { + /*޲*/ + } + /*ATSֵطVOBC-CIЭ汾Ŵ*/ + if (GAL_COMPARE_PROTOCOL_VER_ERR == (errCode & GAL_COMPARE_PROTOCOL_VER_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_PROTOCOL_VER_ERR,ESEND_LEVEL_ATS); + } + else + { + /*޲*/ + } + /*ATSֵطVOBC-CIӦòݳЧ*/ + if (GAL_COMPARE_APP_LEN_ERR == (errCode & GAL_COMPARE_APP_LEN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_APP_LEN_ERR,ESEND_LEVEL_ATS); + } + else + { + /*޲*/ + } + /*ATSֵطVOBC-CIͨڴ */ + if (GAL_COMPARE_COM_PERIOD == (errCode & GAL_COMPARE_COM_PERIOD)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_BACK_DATA_COM_PERIOD,ESEND_LEVEL_ATS); + } + else + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA,CI_SYSTEM_TYPE_VOBC,systemId,ETYPE_COMM_WITH_VOBC,CI_ERROR,ESEND_LEVEL_ATS); + } + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* FAO VOBC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseVobcToCiDataFrameFAO(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId,VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT8 rowIndex = 0u; /**/ + UINT8 colIndex = 0u; /**/ + UINT8 trainEditGroup = 0u; /*гϢ*/ + UINT8 ii = 0u; /**/ + UINT8 jj = 0u; + UINT8 retVal = CI_SUCCESS; + UINT16 psdId = 0u; /*PSDID*/ + UINT8 psdCmdType = 0u; /*PSDĿ*/ + UINT32 faultInfo = 0u; /*ϸϢ*/ + + if (dataBuf[ii++] != CI_SYSTEM_TYPE_VOBC) + {/*VOBC͵*/ + + retVal = CI_ERROR; + } + if(CI_SUCCESS == retVal) + { + /*VOBCID*/ + ii++; + + if (dataBuf[ii++] != Get2oo2SheBeiType()) + {/*Ƿ͵豸*/ + + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + if (dataBuf[ii++] != localCiId) + {/*Ƿ͵*/ + + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + if (VobcToCiSum >= VOBC_TO_CI_SUM_MAX) + { + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + vobcToCiDataStru->VobcId = systemId; /*VOBCID*/ + vobcToCiDataStru->PsdSum = dataBuf[ii++]; /**/ + + if (2U != vobcToCiDataStru->PsdSum) + {/*ӿڶ壺ȡֵΪ2*/ + vobcToCiDataStru->PsdSum = 0u; + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + for (jj = 0u; jj < vobcToCiDataStru->PsdSum; jj++) + {/*ſϢ*/ + + psdId = ShortFromChar(&dataBuf[ii]);/*ȡID*/ + ii += 2u; + psdCmdType = dataBuf[ii]; /**/ + ii += 1u; + if ((0U == psdId) || (PSD_INVALID_ID == psdId) || (GetPsdBelongCiId(psdId) != GetSystemParaLocalCiId()) || (PSD_INVALID_CMD == psdCmdType) || (PSD_DEFAULT_CONTROL_CMD == psdCmdType)) + {/*IDЧŲڱΪЧ*/ + vobcToCiDataStru->PsdData[jj].PsdId = PSD_INVALID_ID; + vobcToCiDataStru->PsdData[jj].CmdType = PSD_DEFAULT_CONTROL_CMD; + ii += 1u;/*ֶ*/ +#if 0 + vobcToCiDataStru->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum(); /*ʼ:涨ֻҪVOBC->CIݣCIӦ->VOBCظ*/ +#endif + } + else + { + vobcToCiDataStru->PsdData[jj].PsdId = psdId; + vobcToCiDataStru->PsdData[jj].CmdType = psdCmdType; /**/ + vobcToCiDataStru->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum();/*ʼ*/ + } + } + + retVal = ChecktrainEditGroupInfo(dataBuf[ii], OUT (UINT8)vobcToCiDataStru->trainEditGroupInfo); /*гϢ*/ + ii++; + + for (jj = 0u; jj < vobcToCiDataStru->PsdSum; jj++) + {/*ϸϢ*/ + + psdId = vobcToCiDataStru->PsdData[jj].PsdId; + trainEditGroup = (UINT8)(vobcToCiDataStru->trainEditGroupInfo); + + faultInfo = LongFromChar(&dataBuf[ii]); /*ȡϸϢ*/ + ii += 4u; + + + + + if((0u != psdId) && (PSD_INVALID_ID != psdId) &&(GetPsdBelongCiId(psdId) == GetSystemParaLocalCiId())) + {/*IDЧ:ϢCI--->PSDݽṹ*/ + + rowIndex = PsdPlatformIndex[psdId][0];/*ȡӳ*/ + colIndex = PsdPlatformIndex[psdId][1]; + if(0u != rowIndex ) + {/*Ѿ*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].PsdId = psdId; /*ID*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationRequestInfo = faultInfo; /*ϸϢ*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].doorEditGroupInfo = trainEditGroup; /*űϢ*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].doorHaveOrNot = PSD_HAVE_TRAIN_DOOR_YES;/*ΪгϢ*/ + } + vobcToCiDataStru->PsdData[jj].faultIsolationRequest = faultInfo; /*ϸϢ*/ + } + } + + + retVal = CheckwashTrainRequest(dataBuf[ii], OUT vobcToCiDataStru->washTrainRequest); /*ϴϢ*/ + ii++; + retVal = CheckheadWashStopSteady(dataBuf[ii++], OUT vobcToCiDataStru->headWashStopSteadyInfo); /*ͷϴλͣϢ*/ + ii++; + retVal = ChecktailWashStopSteady(dataBuf[ii++], OUT vobcToCiDataStru->tailWashStopSteadyInfo); /*βϴλͣϢ*/ + ii++; + retVal = CheckpassWashMachine(dataBuf[ii++], OUT vobcToCiDataStru->passWashMachineRequest); /*ͨϴϢ*/ + ii++; + + ii += 10u;/*Ԥ10ֽڣδչ20151211*/ + + if (ii > dataLength) + { + retVal = CI_ERROR; + } + } + return retVal; +} + +/* +* VOBC +* ˵ VobcToCiDataStruct *vobcToCiDataStru, vobcCIݽṹ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToVobcDataHLHT(VobcToCiDataStruct *vobcToCiDataStru) +{ + UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = {0u};/*CIVOBC֡*/ + UINT16 psdId = 0u; /*ID*/ + UINT32 psdIdInterConn = 0u; /*ͨ4ֽID*/ + UINT8 startSigColour = 0u; /*Źijվ·ʼźŻ*/ + UINT8 psdState = 0u; /*״̬*/ + UINT16 ii = 0u; + UINT8 kk = 0u; + UINT16 sigId = 0u; /*źŻID*/ + UINT8 rowIndex = 0u; + UINT8 colIndex = 0u; + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 appCycleTime = GetSystemParaAppCycleTime(); + UINT8 retVal = CI_SUCCESS; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT32 ciEtcsId = 0u; + UINT32 vobcEtcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT16 trackIdRelatePhySecId = 0u;/*ιID*/ + UINT8 outStationSignalSum = 0u;/*վźŻĿ*/ + UINT8 sigIdx = 0u;/*źŻ*/ + UINT8 sigDir = 0u;/*źŻӪ*/ + UINT8 outStationSignalAllowOrNotUp = CI_VOBC_SIGNAL_DEFAULT; /*źŻֹ״̬*/ + UINT8 outStationSignalAllowOrNotDown = CI_VOBC_SIGNAL_DEFAULT; /*źŻֹ״̬*/ + UINT8 ci_vobcPrtclVersion = 0u; + UINT8 mutualLockState = 0u; + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + UINT8 chPsdBelongCiId = 0U; + ci_vobcPrtclVersion = GetVersionOfVOBCToCI(); +#if 0 + UINT8 outStationSignalAllowOrNot = CI_VOBC_SIGNAL_DEFAULT; /*źŻֹ״̬*/ + UINT32 signalIdInterConn = 0u; /*ͨ4ֽźŻID*/ +#endif + + /*ȻȡʱϢȡɹбҪ*/ + if ((CI_SUCCESS == dquDevName2HlhtId((CI_SYSTEM_TYPE_CI*256U) + localCiId,0U,&ciEtcsId)) && (CI_SUCCESS == dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC*256U) + (UINT8)(vobcToCiDataStru->VobcId),vobcToCiDataStru->vobcLogId,&vobcEtcsId)) && (CI_SUCCESS == GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC))) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + ii = 0u; + + /*ʼӦ֡*/ + + ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*ӿϢ*/ + ii += 2u; + LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*յһϢʱк*/ + ii += 4u; + CiToVobcDataBuffer[ii++] = ci_vobcPrtclVersion;/*CI_VOBCӿЭ汾*/ + ii += 2u;/*ͨñͷеӦò㱨ܳ*/ + + /*ΪӦò*/ + ii += 2u;/*ij*/ + + ii += 2u;/*Ӧñ*/ + + ii += 2u;/*Ԥֽ*/ + + if ((VOBC_CI_INFO_TYPE_PSD_CONTROL == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*ֻеVOBC͵ϢſϢʱݣϢΪֻ֡ͱ֡ͷ31+6*/ + LongToChar(vobcToCiDataStru->trackSecID,&CiToVobcDataBuffer[ii]);/*ظյĹID,CI-VOBCV2.9ӿĵ޸*/ + ii += 4u; + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->psdCmdCode; /*ظյ״̬*/ + + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum; /**/ + + for (kk = 0u; kk < 2u; kk++) + { + psdId = vobcToCiDataStru->PsdData[kk].PsdId; + psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn; + chPsdBelongCiId = GetPsdBelongCiId(psdId); + if (localCiId != chPsdBelongCiId) + {/*δ鵽ŵϢŲڱ*/ + + + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4U; + + CiToVobcDataBuffer[ii++] = PSD_STATE_INVALID_HLHT; /*״̬*/ + + CiToVobcDataBuffer[ii++] = PSD_INVALID_CMD; /**/ + } + else + {/*ڱ*/ + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4u; + mutualLockState = GetPsdMutualLockRemoveState(psdId); + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + {/*Ż*/ + + psdState = PSD_STATE_CLOSE_VIETNAM;/*ر*/ + } + else + {/*δ*/ + + if (GetPsdState(psdId) == PSD_STATE_CLOSE) + {/*Ź*/ + + psdState = PSD_STATE_CLOSE_VIETNAM;/*ر*/ + } + else + { + psdState = PSD_STATE_OPEN_VIETNAM;/*ǹر*/ + } + } + + CiToVobcDataBuffer[ii++] = psdState; /*״̬*/ + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType; /**/ + } + + }/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/ + + /*޸20180111޸ԭ򣺻ͨVOBC-CIӿڻˣVOBCCI4ֽźŻIDCIҲظźŻIDӦԽ*/ +#if 0 + signalIdInterConn = vobcToCiDataStru->signalID; /*ͨ4ֽźŻID*/ + /*ظյźŻID,CI-VOBCV3.0ӿĵ޸*/ + LongToChar(signalIdInterConn,&CiToVobcDataBuffer[ii]); + ii += 4u; + /*ݻͨ4ֽIDȡźŻID*/ + retVal = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, signalIdInterConn, &sigId); + + if (CI_SUCCESS == retVal) + { + startSigColour = GetSignalShowColor(sigId);/*ȡźŻǰʾɫ*/ + + if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*ȡʼźŻ״̬*/ + {/*źſ*/ + outStationSignalAllowOrNot = CI_VOBC_SIGNAL_YES; + } + else + { + outStationSignalAllowOrNot = CI_VOBC_SIGNAL_NO; + } + } + + /*CIյVOBC͵źŻID״̬*/ + CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNot; /*CI->VOBCźŻ״̬*/ +#endif + + /*ȲҹζӦΣȡԴΪⷽһεźŻĿ֮*/ + trackIdRelatePhySecId = GetTrackToPhySectionId(vobcToCiDataStru->trackSecID); + outStationSignalSum = GetPhySecAsOutFirstPhySecSigSum(trackIdRelatePhySecId);/*ȡԱΪⷽһεźŻĿ*/ + for (sigIdx = 0u;sigIdx < outStationSignalSum;sigIdx++) + { + sigId = GetPhySecAsOutFstPhySecSigId(trackIdRelatePhySecId,sigIdx);/*ȡźŻId*/ + sigDir = GetSignalOperDirection(sigId);/*ȡźŻӪ*/ + startSigColour = GetSignalCurColor(sigId);/*ȡźŻǰʾɫ*/ + + if (CI_SYSTEM_DIRECTION_UP == sigDir) + {/*з*/ + if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*ȡʼźŻ״̬*/ + {/*źſ*/ + outStationSignalAllowOrNotUp = CI_VOBC_SIGNAL_YES; + } + else + { + outStationSignalAllowOrNotUp = CI_VOBC_SIGNAL_NO; + } + } + else if (CI_SYSTEM_DIRECTION_DOWN == sigDir) + {/*з*/ + if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*ȡʼźŻ״̬*/ + {/*źſ*/ + outStationSignalAllowOrNotDown = CI_VOBC_SIGNAL_YES; + } + else + { + outStationSignalAllowOrNotDown = CI_VOBC_SIGNAL_NO; + } + } + else + { + /*޲*/ + } + } + + /*CI->VOBCкгվźŻ״̬*/ + CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNotUp; /*CI_VOBCгվźŻ״̬*/ + CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNotDown; /*CI_VOBCгվźŻ״̬*/ + + ShortToChar(CI_VOBC_INFO_TYPE_PSD_STATE,&CiToVobcDataBuffer[33]);/*ſƱֽͣ*/ + } + else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*֡*/ + ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME,&CiToVobcDataBuffer[33]);/*ֽ֡ͣ*/ + } + else if ((VOBC_CI_INFO_TYPE_LOGOUT_ASK == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*עظ֡*/ + ShortToChar(CI_VOBC_INFO_TYPE_LOGOUT_ACK,&CiToVobcDataBuffer[33]);/*עظֽ֡ͣ*/ + } + else + { + /*Ϣʹʲô*/ + } + + /*ͨñͷӦò㱨ܳ*/ + CiToVobcDataBuffer[29U] = (UINT8) ((UINT8)((ii - 31U) >> 8u) & 0xffu); + CiToVobcDataBuffer[30U] = (UINT8) ((ii - 31U) & 0xffu); + + /*Ӧòݵıij */ + CiToVobcDataBuffer[31U] = (UINT8) (((ii - 33U) >> 8u) & 0xffu); + CiToVobcDataBuffer[32U] = (UINT8) ((ii - 33U) & 0xffu); + + dstDevId = ((UINT16)CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId; + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &CiToVobcDataBuffer[0U], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nVOBC_SEND:%d", ii); + debug_out_array(0xAA, CiToVobcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ +#endif + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + } + } + else + { + } + + return retVal; +} + +/* +* FAOVOBC +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToVobcDataFAO(VobcToCiDataStruct *vobcToCiDataStru) +{ + UINT8 localCi = GetSystemParaLocalCiId(); /*ID*/ + UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = {0u};/*CIVOBC֡*/ + UINT16 psdId = 0u; /*ID*/ + UINT8 psdState = 0u; /*״̬*/ + UINT8 isPack = 0u; /*Ƿͱ־*/ + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT8 kk = 0u; + UINT8 rowIndex = 0u; + UINT8 colIndex = 0u; + UINT32 faultIslutionInfo = 0u; + UINT16 washMachineCurSum = GetWashMachineSum(); /*ȡǰϴ*/ + UINT16 washMachineId = 0u; + UINT32 psdOpenState = 0u; /*ÿһŵĴ״̬*/ + UINT8 CI_PSD_COMM_STATE[VOBC_TO_CI_TRAIN_PSD_MAX] = {0u};/*CIPSDͨ״̬ĬϹϡ20151211*/ + UINT8 psdBelongStationId = 0u; /*PSDվ̨ID*/ + UINT8 psdVirtAttr = 0u; /*psd*/ + UINT8 retVal = CI_SUCCESS; + UINT8 mutualLockState = 0u; + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + + for (jj = 0u;jj < VOBC_TO_CI_TRAIN_PSD_MAX;jj++) + {/*ʼCI͸VOBCCI-PSDͨ״̬ĬϹ0xAA*/ + CI_PSD_COMM_STATE[jj] = CI_PSD_COMM_STATE_BAD; + } + + /*ǰΪһһȫԶϴ*/ + if(1u == washMachineCurSum) + {/*һ̨ȫԶϴ*/ + washMachineId = GetWashMachineId(0u); /*ȡȫԶϴID*/ + } + else + { + } + + + isPack = 0u; + if (Get2oo2CurCycleNum() == vobcToCiDataStru->ComStartCycle) + { + isPack=1u; + } + else + { + /*޲*/ + } + + if (1u == isPack) + {/*跢ʹϢ*/ + ii = 0u; + + + /*ʼӦ֡*/ + CiToVobcDataBuffer[ii++] = Get2oo2SheBeiType(); + CiToVobcDataBuffer[ii++] = localCi; + CiToVobcDataBuffer[ii++] = CI_SYSTEM_TYPE_VOBC; + CiToVobcDataBuffer[ii++] = (UINT8)vobcToCiDataStru->VobcId; + + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum; /**/ + + for (kk = 0u; kk < vobcToCiDataStru->PsdSum; kk++) + { + psdId = vobcToCiDataStru->PsdData[kk].PsdId; + if (PSD_INVALID_ID == psdId) /* ЧֱӷĬϸϢ */ + { + rowIndex = 0u; + colIndex = 0u; + } + else + { + rowIndex = PsdPlatformIndex[psdId][0U]; /*ȡӳ*/ + colIndex = PsdPlatformIndex[psdId][1U]; + } + if(0u == rowIndex) + {/*δ鵽ŵϢŲڱ*/ + ShortToChar(psdId, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 2u; + + psdState = PSD_STATE_OPEN; + CiToVobcDataBuffer[ii++] = psdState; /*״̬*/ + + CiToVobcDataBuffer[ii++] = PSD_DEFAULT_CONTROL_CMD; /**/ + + LongToChar(PSD_DEFAULT_FAULT_ISOLATION,&CiToVobcDataBuffer[ii]); /*ϸϢ*/ + ii += 4u; + + LongToChar(PSD_DEFAULT_ALL_OPEN_STATE,&CiToVobcDataBuffer[ii]); /*ŵ״̬*/ + ii += 4u; + + CiToVobcDataBuffer[ii++] = PSD_BUTTON_STATE_UP; /*վ̨ť״̬*/ + + CI_PSD_COMM_STATE[kk] = CI_PSD_COMM_STATE_BAD; /*CI_PSDͨ״̬*/ + } + else + {/*ڱ*/ + ShortToChar(psdId, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 2u; + + psdVirtAttr = GetPsdVirtualAttribute(psdId);/*ȡPSD*/ + + if (PSD_VIRTUAL_ATTR_YES == psdVirtAttr) + {/*ΪΪCIPSDͨ*/ + CI_PSD_COMM_STATE[kk] = CI_PSD_COMM_STATE_GOOD;/*CI-PSDͨ*/ + } + else + {/*ţжCIPSDͨ״̬*/ + psdBelongStationId = GetPsdBelongStationId(psdId);/*ȡpsdվ̨ID*/ + (void)UpdateCiTransmitState(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_PLATFORM, psdBelongStationId);/*վ̨ͨ״̬*/ + + if (TRANSMIT_STATE_GOOD == GetCiTransmitState(CI_SYSTEM_TYPE_PLATFORM,psdBelongStationId))/*ȡ뵱ǰPSDͨ״̬*/ + { + CI_PSD_COMM_STATE[kk] = CI_PSD_COMM_STATE_GOOD;/*CI-PSDͨ*/ + } + else + { + CI_PSD_COMM_STATE[kk] = CI_PSD_COMM_STATE_BAD;/*CI-PSDͨŹ*/ + } + } + + /*ȡ״̬*/ + mutualLockState = GetPsdMutualLockRemoveState(psdId); + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + {/*Ż*/ + + psdState = PSD_STATE_CLOSE;/*ر*/ + + if (PSD_VIRTUAL_ATTR_YES != psdVirtAttr) + {/**/ + /*20161027󣺻CI-PSDͨжʱCI->VOBCÿ״̬ΪȫرգPSDδ*/ + if (CI_PSD_COMM_STATE_BAD == CI_PSD_COMM_STATE[kk]) + { + if (PSD_FOUR_EDIT_GROUP_FAO_YF == vobcToCiDataStru->trainEditGroupInfo) + {/*4鷢bit0-bit15*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState = 0xFFFF0000u;/*1򿪣0ر*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo = 0xFFFF0000u;/*0޹ϸ룬δ1*/ + } + else if (PSD_SIX_EDIT_GROUP_FAO_YF == vobcToCiDataStru->trainEditGroupInfo) + {/*6鷢bit0-bit23*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState = 0xFF000000u; + platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo = 0xFF000000u; + } + else + {/*Ϣ󣬷ȫŴ򿪺͸*/ + platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState = PSD_DEFAULT_ALL_OPEN_STATE; + platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo = PSD_DEFAULT_FAULT_ISOLATION; + } + + } + else + { + } + } + else + { + } + + } + else + {/*δ*/ + + if (PSD_STATE_CLOSE == GetPsdState(psdId) ) + {/*Ź*/ + + psdState = PSD_STATE_CLOSE;/*ر*/ + } + else + { + psdState = PSD_STATE_OPEN;/*ǹر*/ + } + } + + CiToVobcDataBuffer[ii++] = psdState; /*״̬*/ + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType; /**/ + faultIslutionInfo = platformToCiDataStru[rowIndex].psdDataStr[colIndex].faultIsolationReplyInfo;/*ϸϢ*/ + LongToChar(faultIslutionInfo,&CiToVobcDataBuffer[ii]); + ii += 4u; + + if (PSD_VIRTUAL_ATTR_YES == psdVirtAttr) + {/*ţŵ״̬CIж*/ + if (PSD_STATE_OPEN == psdState) + {/*ſ״̬*/ + if (PSD_FAULT_ISOLATION_SCX == faultIslutionInfo) + {/*ϸ*/ + psdOpenState = PSD_OPEN_STATE_SCX;/*18⣬Ϊ*/ + } + else + {/*δϸ*/ + psdOpenState = PSD_DEFAULT_ALL_OPEN_STATE;/*ȫ״̬*/ + } + + } + else + {/*Ź״̬*/ + /*Ϻͷǹȫ͹ر*/ + psdOpenState = 0;/*ȫ״̬Ϊر*/ + } + } + else + {/*ʵţ״̬PSD->CIͨŽӿڻȡ*/ + psdOpenState = platformToCiDataStru[rowIndex].psdDataStr[colIndex].psdState; + } + LongToChar(psdOpenState,&CiToVobcDataBuffer[ii]); + ii += 4u; + + CiToVobcDataBuffer[ii++] = GetPsdButtonState(psdId); /*վ̨ť״̬*/ + + } + + }/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/ + + if (1U == washMachineCurSum) + {/*ϴ*/ + CiToVobcDataBuffer[ii++] = GetWashMachineRequestVerifySta(washMachineId); /*ϴ*/ + CiToVobcDataBuffer[ii++] = GetHeadWashAllowState(washMachineId); /*ͷϴλϴƶָ*/ + CiToVobcDataBuffer[ii++] = GetTailWashAllowState(washMachineId); /*βϴλϴƶָ*/ + CiToVobcDataBuffer[ii++] = GetTrainEmergencyStopState(washMachineId); /*ϴ״̬*/ + CiToVobcDataBuffer[ii++] = GetTrainOutWashPortAllowSta(washMachineId); /*ϴгͨ*/ + + } + else + {/*ûϴĬֵ*/ + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_REQUEST_INVALID; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_HEADWASH_NO; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_TAILWASH_NO ; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_FALUT_NO ; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_OUT_NO; + } + + for (kk = 0u; kk < vobcToCiDataStru->PsdSum; kk++) + { + CiToVobcDataBuffer[ii++] = CI_PSD_COMM_STATE[kk];/*CI->VOBC CI-PSDͨ״̬*/ + } + + ii += 8u;/*Ԥ8ֽڣĬֵ0x00,δչ*/ + + + dstDevId = (UINT16)(CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId; + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &CiToVobcDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nVOBC_SEND:%d", ii); + debug_out_array(0xAA, CiToVobcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ + +#endif + } + else + { + retVal = CI_ERROR; + } + } + else + { + } + + return retVal; +} + +/* +* 黥ͨCI->VOBC֡ +* ˵ +* const UINT8 vobcId ĿVOBC ID +* const UINT16 logId ĿVOBC ߼ID1˻2ˣ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToVobcDataHLHTHeart(const UINT8 vobcId, const UINT16 logId) +{ + UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = { 0u };/*CIVOBC֡*/ + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 appCycleTime = GetSystemParaAppCycleTime(); + UINT16 ii = 0u; + + UINT8 retVal = CI_ERROR; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT32 ciEtcsId = 0u; + UINT32 vobcEtcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT8 lineIdentity = 0u; + UINT8 ci_vobcPrtclVersion = 0u; + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + UINT8 functionreturn= 0u; + + ci_vobcPrtclVersion = GetVersionOfVOBCToCI(); + functionreturn = dquDevName2HlhtId(((UINT16)CI_SYSTEM_TYPE_CI * 256U + localCiId),0U,&ciEtcsId) ; + functionreturn &= dquDevName2HlhtId(((UINT16)CI_SYSTEM_TYPE_VOBC *256U) + vobcId,logId,&vobcEtcsId); + functionreturn &= GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC); + /*ȻȡʱϢȡɹбҪ*/ + if (CI_SUCCESS == functionreturn) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡVOBC-CIӿڱʶ*/ + + ii = 0u; + + /*ʼӦ֡*/ + if (LINE_CC == lineIdentity) + { + ShortToChar(IVOC_CI_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*ӿϢ*/ + ii += 2u; + } + else + { + ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*ӿϢ*/ + ii += 2u; + } + + + LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, vobcId), &CiToVobcDataBuffer[ii]);/*ԷϢкţյԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, vobcId), &CiToVobcDataBuffer[ii]);/*յһϢʱк*/ + ii += 4u; + if (LINE_HLHT == lineIdentity) + {/*ͨ·*/ + CiToVobcDataBuffer[ii++] = ci_vobcPrtclVersion;/*CI_VOBCӿЭ汾*/ + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity)|| (LINE_FAOHLHT_ONESELFSECOND == lineIdentity)) + {/*ͨ+FAO·*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_PRTCL_VER_FAOHLHT;/*CI_VOBCӿЭ汾*/ + } + else if (LINE_CC == lineIdentity) + {/*ͨ+FAO·*/ + CiToVobcDataBuffer[ii++] = CI_IVOC_PRTCL_VER;/*CI_VOBCӿЭ汾*/ + } + else + {/*·ͣʼֵ0*/ + ii++; + } + + ii += 2u;/*ͨñͷеӦò㱨ܳ*/ + + /*ΪӦò*/ + ii += 2u;/*ij*/ + + ii += 2u;/*Ӧñ*/ + + ii += 2u;/*Ԥֽ*/ + if(LINE_CC == lineIdentity) + {/*ͨ+FAO·*/ + ShortToChar(CI_IVOC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33]);/*ֽ֡ͣ*/ + } + else { + /*֡*/ + ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33]);/*ֽ֡ͣ*/ + } + /*ͨñͷӦò㱨ܳ*/ + CiToVobcDataBuffer[29U] = (UINT8)((UINT8)((ii - 31U) >> 8u) & 0xffu); + CiToVobcDataBuffer[30U] = (UINT8)((ii - 31U) & 0xffu); + + /*Ӧòݵıij */ + CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8u) & 0xffu); + CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffu); + + dstDevId = (UINT16)(CI_SYSTEM_TYPE_VOBC << 8U) | ((UINT16)vobcId); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, logId, &CiToVobcDataBuffer[0U], ii); + if(1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nVOBC_SEND:%d", ii); + debug_out_array(0xAA, CiToVobcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ +#endif + retVal = CI_SUCCESS; + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + } + } + else + { + } + + return retVal; +} + +/* +* FAO+HLHT VOBC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStru vobcTociݽṹָ +* UINT8* saveGalHead,ͨñͷǷ,1:0: +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +static UINT8 ParseVobcToCiDataFrameFAOHLHT(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru, UINT8* saveGalHead,const UINT16 logId) +{ + UINT8 cmdType = 0u; /**/ + UINT8 trainStopSteadyState = 0u; /*гͣ״̬*/ + UINT8 psdSum = 0u; + UINT8 trainDirection = 0u; /*г*/ + UINT16 ii = 0u; /**/ + UINT8 jj = 0u; + UINT8 retVal = CI_SUCCESS; + UINT8 retValue = 0u; + UINT16 psdId = 0u; /*PSDID*/ + UINT16 appInfoType = 0u; /*ӦϢ*/ + UINT32 psdIdIntConnt = 0u; /*ͨPSDID*/ + UINT32 trackSectionId = 0u; /*ID*/ + UINT32 curntCycleNo = 0u; /*ǰں*/ + UINT16 vobcName = 0u; /*VOBC豸ƣ+ID*/ + UINT16 ciName = 0u; /*豸ƣ+ID*/ + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + UINT32 errCode = 0u; + HLHTGALInfoStruct hlhtGalHead = { 0u }; + INT32 vobcInfoRemainValidiy = 0; + UINT8 headRet = HLHT_HEAD_ERROR;/*ͨ*/ + UINT32 signalId = 0u; /*VOBC->CIźŻID*/ + UINT8 gapDetCmdType = 0u; /*϶̽*/ + UINT8 doorState = 0u; /*VOBC-CI״̬*/ + UINT8 cTempPsdCmdCode = 0U; + UINT8 chVideoQkState = 0U;/*Ƶ״̬*/ + UINT8 chVideoQkResult = 0U;/*Ƶͽ*/ + UINT16 wMsgLen = 0U;/*һӦݳ*/ + UINT16 wTmpDataLen = 0U;/*ʱȼ¼*/ + UINT16 wMsgCheckLen = 0u; /* ڽУݳ */ + UINT16 wTempDataLenIndex = 0U;/*ʱݳ*/ + + vobcName = (CI_SYSTEM_TYPE_VOBC)*256U + systemId; + ciName = (CI_SYSTEM_TYPE_CI)*256U + localCiId; + + /*ͨϢͷ*/ + hlhtGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.sourceId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.destId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.comPeriod = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.prtclVer = dataBuf[ii++]; + hlhtGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + curntCycleNo = Get2oo2CurCycleNum(); + + vobcToCiDataStru->vobcLogId = logId;/*洢VOBC߼ID1˻2*/ + /*ͨϢͷУͨ && ʱЧżϢ*/ + /*һյVOBCϢʱУ鲻ֻͨ¼curntOwnMsgԼǰں*/ + headRet = HLHTRecvCommonPacketHeadCheck(vobcName, ciName, CI_VOBC_INTERFACE_INFOTYPE, CI_VOBC_PRTCL_VER_FAOHLHT, &hlhtGalHead, &errCode, logId, CI_SYSTEM_TYPE_VOBC); + + debug_infor_printf((const)"\nVOBC %d GAL Check Result:%d errCode:%d", systemId,headRet,errCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + if (HLHT_HEAD_SUCCESS==headRet) + { + /*ϢʱЧ*/ + vobcInfoRemainValidiy = HLHTCommonMsgRemainingValidity(GetCiAndVobcTransBadEnsureTime(), curntCycleNo, GetSystemParaAppCycleTime(), hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN, hlhtGalHead.comPeriod); + + if (vobcInfoRemainValidiy > 0) + { + if (6U > hlhtGalHead.totalDataLen) + { + retVal = CI_ERROR; + } + else + { + while (wTmpDataLen < hlhtGalHead.totalDataLen) + { + /*пϢÿھͣҪʱѭ*/ + /* һӦݳ */ + wMsgLen = ShortFromChar(&dataBuf[ii]); + ii += 2U; + wTempDataLenIndex = ii + wMsgLen; + + if (4U > wMsgLen) + { + retVal = CI_ERROR; + } + else + { + appInfoType = ShortFromChar(&dataBuf[ii]);/*ӦϢͣſϢ֡Ϣ*/ + ii += 2U; + if (VOBC_CI_INFO_TYPE_BACKUU_CONTROL != appInfoType) + { + vobcToCiDataStru->appInfoType = appInfoType; + } + else + { + ; /**/ + } + vobcToCiDataStru->VobcId = systemId; + + ii += 2u;/*Ԥֽ*/ + + if (VOBC_CI_INFO_TYPE_PSD_CONTROL == appInfoType) + { + wMsgCheckLen = wMsgLen - 4U + 2U + ShortFromChar(&dataBuf[wTempDataLenIndex]); + } + else + { + wMsgCheckLen = wMsgLen - 4U; + } + + wTmpDataLen += 2U;/*ݳ*/ + wTmpDataLen = wTmpDataLen + wMsgCheckLen + 4U;/*ͺԤ4ֽ*/ + + switch (appInfoType) + { + case VOBC_CI_INFO_TYPE_PSD_CONTROL: + case VOBC_CI_INFO_TYPE_FAO_INFO: + case VOBC_CI_INFO_TYPE_HEART_FRAME: + case VOBC_CI_INFO_TYPE_LOGOUT_ASK: + retVal = ParseFAOHLHTOtherTypeData(appInfoType,&dataBuf[ii], wMsgCheckLen,systemId,vobcToCiDataStru); + break; + case VOBC_CI_INFO_TYPE_BACKUU_CONTROL: + retVal = ParseFAOHLHTBackUpControlData(&dataBuf[ii],wMsgCheckLen, vobcToCiDataStru); + break; + default: + retVal = CI_ERROR; + break; + } + + if (CI_SUCCESS == retVal) + { + /* ɹݰ */ + ii += wMsgCheckLen; + } + else + { + debug_infor_printf((const)"\nVOBC %d appInfoType CHECK ERR,appInfoType:%d", vobcToCiDataStru->VobcId, appInfoType); + break; + } + } + } + } + + if (CI_SUCCESS == retVal) + { + /*Уݳ*/ + if (ii > dataLength) + { + debug_infor_printf((const)"\nVOBC %d DATALEN CHECK ERR,dataLen:%d,ii:%d", vobcToCiDataStru->VobcId, dataLength, ii); + + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + /*ݾУ飬Ҫ洢ͨñ*/ + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId); + + *saveGalHead = 1u; + } + } + else + { + retVal = CI_ERROR; + } + } + else if (HLHT_HEAD_INIT ==headRet) + { + if (curntCycleNo > 0u)/*жŴ0Ϊ0Ч*/ + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId); + + *saveGalHead = 1u; + } + + retVal = CI_ERROR; + } + else + { + /*ATSֵطVOBC-CIݽӿϢʹ*/ + if (GAL_COMPARE_INFO_TYPE_ERR == (errCode & GAL_COMPARE_INFO_TYPE_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_INFO_TYPE_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݷͷʶϢ*/ + else if (GAL_COMPARE_SEND_FLAG_ERR == (errCode & GAL_COMPARE_SEND_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_SEND_FLAG_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݽշ־Ϣ*/ + else if (GAL_COMPARE_RECV_FLAG_ERR == (errCode & GAL_COMPARE_RECV_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_RECV_FLAG_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݰ汾УʧϢ*/ + else if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_VER_CHECK_FAIL, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݱԷյһϢʱкŴ*/ + else if (GAL_COMPARE_MSG_BDS_SN_ERR == (errCode & GAL_COMPARE_MSG_BDS_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_MSG_BDS_SN_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݶԷϢкżյһϢʱкŴ*/ + else if (GAL_COMPARE_MSG_SN_ERR == (errCode & GAL_COMPARE_MSG_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_MSG_SN_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIЭ汾Ŵ*/ + else if (GAL_COMPARE_PROTOCOL_VER_ERR == (errCode & GAL_COMPARE_PROTOCOL_VER_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_PROTOCOL_VER_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIӦòݳЧ*/ + else if (GAL_COMPARE_APP_LEN_ERR == (errCode & GAL_COMPARE_APP_LEN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_APP_LEN_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIͨڴ */ + else if (GAL_COMPARE_COM_PERIOD == (errCode & GAL_COMPARE_COM_PERIOD)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_COM_PERIOD, ESEND_LEVEL_ATS); + } + else + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_ERROR, ESEND_LEVEL_ATS); + } + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* (FAO+HLHT)VOBC +* ˵ VobcToCiDataStruct *vobcToCiDataStru,vobcCIݽṹ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToVobcDataFAOHLHT(VobcToCiDataStruct *vobcToCiDataStru) +{ + UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = {0u};/*CIVOBC֡*/ + UINT16 psdId = 0u; /*ID*/ + UINT32 psdIdInterConn = 0u; /*ͨ4ֽID*/ + UINT8 startSigColour = 0u; /*Źijվ·ʼźŻ*/ + UINT8 psdState = 0u; /*״̬*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 kk = 0u; + UINT16 sigId = 0u; /*źŻID*/ + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 appCycleTime = GetSystemParaAppCycleTime(); + UINT8 retVal = CI_SUCCESS; + UINT8 chTempCheckFlag = CI_ERROR; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT32 ciEtcsId = 0u; + UINT32 vobcEtcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT8 outStationSignalAllowOrNot = CI_VOBC_SIGNAL_DEFAULT; /*źŻֹ״̬*/ + UINT32 signalIdInterConn = 0u; /*ͨ4ֽźŻID*/ + UINT16 washMachineCurSum = GetWashMachineSum(); /*ȡǰϴ*/ + UINT16 washMachineId = 0u; + UINT8 psdValidFlag[2] = {0u,0u}; /*0Ч1Ч*/ + UINT8 psdReopenButtState = 0u; /*վ̨ٴοŰť״̬*/ + UINT8 platDepartButtState = 0u; /*վ̨ť״̬*/ + UINT8 psdCloseButtState = 0u; /*״̬*/ + UINT8 gapDetStatus = 0u; /*϶̽״̬*/ + UINT8 gapDetMutualLockRemvSta = 0u; /*϶̽⻥״̬*/ + UINT32 psdStartDetCycNum = 0u; /*PSD϶̽⿪ʼ*/ + UINT8 psdButtonPangluState = 0u; /*վ̨ť·״̬*/ + UINT8 washMachineState = 0u; /*ϴ״̬*/ + UINT8 mutualLockState = 0u; /*״̬*/ + UINT16 psdDepartureButtonRelayId = 0u; /*վ̨ť̵*/ + UINT8 localhlhtId = 0u; + UINT8 vobcHlhtId = 0u; + UINT8 ciEmapCheckVer = 0u; + UINT16 dstDevId = 0; + UINT8 chPsdBelongCiId = 0U; + UINT8 outnetSafeSendRtn = 0u; + UINT16 wTempSendIndex = 0U; + + /*ȻȡʱϢȡɹбҪ*/ + localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI*256U) + localCiId,0U,&ciEtcsId); + vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC*256U) + (UINT8)(vobcToCiDataStru->VobcId),vobcToCiDataStru->vobcLogId,&vobcEtcsId); + ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer,CI_SYSTEM_TYPE_VOBC); + if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + debug_infor_printf((const)"\nPack vobc %d data,retVal = %d\n", vobcToCiDataStru->VobcId,retVal); /*ӡϢ*/ + + if (CI_SUCCESS == retVal) + { + ii = 0u; + + /*ʼӦ֡*/ + + ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*ӿϢ*/ + ii += 2u; + LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*յһϢʱк*/ + ii += 4u; + CiToVobcDataBuffer[ii++] = CI_VOBC_PRTCL_VER_FAOHLHT;/*HLHT+FAO_CI_VOBCӿЭ汾*/ + ii += 2u;/*ͨñͷеӦò㱨ܳ*/ + + if ((VOBC_CI_INFO_TYPE_PSD_CONTROL == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*ֻеVOBC͵ϢſϢʱݣϢΪֻ֡ͱ֡ͷ31+6*/ + + ii += 2u;/*ij*/ + ii += 2u;/*Ӧñ*/ + ii += 2u;/*Ԥֽ*/ + + LongToChar(vobcToCiDataStru->trackSecID, &CiToVobcDataBuffer[ii]);/*ظյĹID*/ + ii += 4u; + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->psdCmdCode; /*ظյ״̬*/ + + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum; /**/ + + for (kk = 0u; kk < 2u; kk++) + { + psdId = vobcToCiDataStru->PsdData[kk].PsdId; + psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn; + chPsdBelongCiId = GetPsdBelongCiId(psdId); + if (localCiId != chPsdBelongCiId) + {/*δ鵽ŵϢŲڱ*/ + psdValidFlag[kk] = 0u; + + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4u; + + CiToVobcDataBuffer[ii++] = PSD_STATE_INVALID_HLHT; /*״̬*/ + + CiToVobcDataBuffer[ii++] = PSD_INVALID_CMD; /**/ + } + else + {/*ڱ*/ + psdValidFlag[kk] = 1u; + /*״̬*/ + mutualLockState = GetPsdMutualLockRemoveState(psdId); + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4u; + + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + {/*Ż*/ + + psdState = PSD_STATE_CLOSE_VIETNAM;/*ر*/ + } + else + {/*δ*/ + + if (GetPsdState(psdId) == PSD_STATE_CLOSE) + {/*Ź*/ + + psdState = PSD_STATE_CLOSE_VIETNAM;/*ر*/ + } + else + { + psdState = PSD_STATE_OPEN_VIETNAM;/*ǹر*/ + } + } + + CiToVobcDataBuffer[ii++] = psdState; /*״̬*/ + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType; /**/ + } + + }/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/ + + signalIdInterConn = vobcToCiDataStru->signalID; /*ͨ4ֽźŻID*/ + + LongToChar(signalIdInterConn, &CiToVobcDataBuffer[ii]);/*ظյźŻID*/ + ii += 4u; + /*ݻͨ4ֽIDȡźŻID*/ + chTempCheckFlag = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, signalIdInterConn, &sigId); + + if (CI_SUCCESS == chTempCheckFlag) + { + startSigColour = GetSignalCurColor(sigId);/*ȡźŻǰʾɫ*/ + + if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*ȡʼźŻ״̬*/ + {/*źſ*/ + outStationSignalAllowOrNot = CI_VOBC_SIGNAL_YES; + } + else + { + outStationSignalAllowOrNot = CI_VOBC_SIGNAL_NO; + } + } + else + { + } + + /*CIյVOBC͵źŻID״̬*/ + CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNot; /*CI->VOBCźŻ״̬*/ + + ShortToChar(CI_VOBC_INFO_TYPE_PSD_STATE, &CiToVobcDataBuffer[33U]);/*ſƱֽͣڣ6+31+2*/ + /*CI2VOBC״̬Ϣ*/ + CiToVobcDataBuffer[31U] = (UINT8)(((ii - 33U) >> 8u) & 0xffu); + CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffu); + + /*ĵͨȫԶźϵͳͨVOBC-CIӿڹ-v1.6-20190109޸ģ2019.02.20*/ + /*CI->VOBCȫԶվ̨״̬ϢӦñͷ*/ + ii += 2u; /*ij*/ + ShortToChar(CI_VOBC_PLAT_CLEAR_PASSENGER_INFO, &CiToVobcDataBuffer[ii]); + ii += 2u; /*ͣȫԶվ̨״̬Ϣ*/ + ii += 2u; /*Ԥ2ֽ*/ + + /*CI2VOBCȫԶվ̨״̬ϢʼCI2VOBC״̬Ϣһͬͣվ̨ذťĬֵ*/ + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum; /**/ + for (kk = 0u; kk < 2u; kk++) + { + psdId = vobcToCiDataStru->PsdData[kk].PsdId; + psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn; + + chPsdBelongCiId = GetPsdBelongCiId(psdId); + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4u; + + if (localCiId != chPsdBelongCiId) + { + + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ťĬֵ*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_DEFAULT; /*϶̽״̬Ĭֵδ/޴˹*/ + } + else + {/*IDЧ*/ + /*ȡȫԶվ̨״̬Ϣ͸VOBC*/ + psdButtonPangluState = GetPsdButtonPangluState(psdId); + if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + } + else + { + psdCloseButtState = GetPsdButtonState(psdId);/*վ̨Űť״̬*/ + if (CI_TIME_OUT == SystemOverTimeCheck(GetPCBPressCycNum(psdId), GetPsdButtonPressCount())) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + else + { + CiToVobcDataBuffer[ii++] = psdCloseButtState; + } + } + if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + } + else + { + + psdReopenButtState = GetPsdOpenButtonState(psdId);/*վ̨Űť״̬*/ + if (CI_TIME_OUT == SystemOverTimeCheck(GetPOBPressCycNum(psdId), GetPsdButtonPressCount())) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + else + { + CiToVobcDataBuffer[ii++] = psdReopenButtState; + } + } + psdDepartureButtonRelayId = GetPsdDeparConfmRelayId(psdId); + /*ŷť״̬*/ + if ((0u != psdDepartureButtonRelayId) && (UINT16_MAX != psdDepartureButtonRelayId)) + {/*վ̨ť̵IDЧ*/ + if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + } + else + { + platDepartButtState = GetPsdDepartButtonState(psdId);/*վ̨ť״̬*/ + if (CI_TIME_OUT == SystemOverTimeCheck(GetPSBPressCycNum(psdId), GetPsdButtonPressCount())) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + else + { + CiToVobcDataBuffer[ii++] = platDepartButtState; + } + } + } + else + {/*վ̨ťVOBCվ̨޷ť״̬*/ + CiToVobcDataBuffer[ii++] = PLATFORM_DEPAR_BUTTON_NO; + } + gapDetStatus = GetPsdRemoraState(psdId); /*ȡ϶̽״̬*/ + gapDetMutualLockRemvSta = GetJXTCMutualLockState(psdId); /*ȡ϶̽⻥״̬*/ + psdStartDetCycNum = GetStartDetectionCycNum(psdId); /*ȡ϶̽ʼ*/ + + if (((PSD_REMORA_NO == gapDetStatus) && (0u != psdStartDetCycNum)) + || (JXTC_MUTUALLOCK_REMOVE_YES == gapDetMutualLockRemvSta)) + {/*ϰ϶̽⻥*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_CLEAR; /*ϰ*/ + } + else if ((PSD_REMORA_YES == gapDetStatus) && (0u != psdStartDetCycNum)) + {/*Ϊϰ*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_UNCLEAR; /*ϰ*/ + } + else + {/*Ĭֵ*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_DEFAULT; /*϶̽״̬Ĭֵδ/޴˹*/ + } + } + } + + /*վ̨״̬ϢӦñij*/ + CiToVobcDataBuffer[60U] = (UINT8)(((ii - 62U) >> 8u) & 0xffu); + CiToVobcDataBuffer[61U] = (UINT8)((ii - 62U) & 0xffu); + } + else if ((VOBC_CI_INFO_TYPE_FAO_INFO == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*ȫԶϴϢ֡*/ + + ii += 2u;/*ij*/ + ii += 2u;/*Ӧñ*/ + ii += 2u;/*Ԥֽ*/ + /*ǰΪһһȫԶϴ*/ + if (1U == washMachineCurSum) + {/*һ̨ȫԶϴ*/ + washMachineId = GetWashMachineId(0u); /*ȡȫԶϴID*/ + washMachineState = GetTrainEmergencyStopState(washMachineId); /*ȡȫԶϴ״̬*/ + } + + /*ȫԶϴϢ*/ + if (1U == washMachineCurSum) + {/*ϴ*/ + CiToVobcDataBuffer[ii++] = GetWashMachineRequestVerifySta(washMachineId); /*1ϴȷϣ0x55ϴ0xaaϴ*/ + CiToVobcDataBuffer[ii++] = GetHeadWashAllowState(washMachineId); /*2ͨ10x55ͨ0xaaֹͨ*/ + CiToVobcDataBuffer[ii++] = GetTailWashAllowState(washMachineId); /*3ͨ20x55ͨ0xaaֹͨ*/ + CiToVobcDataBuffer[ii++] = GetTrainOutWashPortAllowSta(washMachineId); /*4ͨϴ0x55ͨ0xaaֹͨ*/ + CiToVobcDataBuffer[ii++] = washMachineState; /*5ϴϣ0x55޹ϣ0xaa*/ + } + else + {/*ûϴ,Ĭֵ,ϴ״̬ͲɼϢ*/ + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_REQUEST_INVALID; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_HEADWASH_NO; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_TAILWASH_NO; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_OUT_NO_2; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_FALUT_NO; + } + + ShortToChar(CI_VOBC_INFO_TYPE_FAO_INFO, &CiToVobcDataBuffer[33]);/*ȫԶϴֽ֡ͣ*/ + + /*ȫԶϴӦñϢ*/ + CiToVobcDataBuffer[31] = (UINT8)(((ii - 33u) >> 8u) & 0xffu); + CiToVobcDataBuffer[32] = (UINT8)((ii - 33u) & 0xffu); + } + else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*֡*/ + + ii += 2u;/*ij*/ + ii += 2u;/*Ӧñ*/ + ii += 2u;/*Ԥֽ*/ + ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33]);/*ֽ֡ͣ*/ + + /*ӦòϢ*/ + CiToVobcDataBuffer[31] = (UINT8)((UINT8)((ii - 33u) >> 8u) & 0xffu); + CiToVobcDataBuffer[32] = (UINT8)((ii - 33u) & 0xffu); + } + else if ((VOBC_CI_INFO_TYPE_LOGOUT_ASK == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*עظ֡*/ + + ii += 2u;/*ij*/ + ii += 2u;/*Ӧñ*/ + ii += 2u;/*Ԥֽ*/ + + ShortToChar(CI_VOBC_INFO_TYPE_LOGOUT_ACK, &CiToVobcDataBuffer[33]);/*עظֽ֡ͣ*/ + + /*ӦòϢ*/ + CiToVobcDataBuffer[31] = (UINT8)((UINT8)((ii - 33u) >> 8u) & 0xffu); + CiToVobcDataBuffer[32] = (UINT8)((ii - 33u) & 0xffu); + } + else + { + /*Ϣʹʲô*/ + } + + if ((CI_SUCCESS == retVal) && (curCycleNum == vobcToCiDataStru->ComStartCycle) && (0u != vobcToCiDataStru->wTrainMaxSafeHeadLink) && (UINT16_MAX != vobcToCiDataStru->wTrainMaxSafeHeadLink)) + { + /*յ510ͨϢ֡λЧǰVOBC˺Ϣ֡Żظ*/ + wTempSendIndex = ii; + + ii += 2U; /*ij*/ + ShortToChar(CI_VOBC_BACKUP_STATE_INFO, &CiToVobcDataBuffer[ii]); + ii += 2U; /**/ + ii += 2U; /*Ԥ2ֽ*/ + + retVal = PackCiToVobcBackUpStateData(CiToVobcDataBuffer, &ii, vobcToCiDataStru); + + if (CI_SUCCESS == retVal) + { + + /*ӦòϢ*/ + CiToVobcDataBuffer[wTempSendIndex] = (UINT8)((UINT8)((ii - wTempSendIndex - 2U) >> 8U) & 0xffU); + CiToVobcDataBuffer[wTempSendIndex + 1U] = (UINT8)((ii - wTempSendIndex - 2U) & 0xffU); + } + else + { + ; /**/ + } + } + else + { + ; + } + + if (CI_SUCCESS == retVal) + { + /*ͨñͷӦò㱨ܳ*/ + CiToVobcDataBuffer[29U] = (UINT8)((UINT8)((ii - 31U) >> 8u) & 0xffu); + CiToVobcDataBuffer[30U] = (UINT8)((ii - 31U) & 0xffu); + + dstDevId = (UINT16)(CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId; + outnetSafeSendRtn = OutnetSafeSend(dstDevId, (vobcToCiDataStru->vobcLogId), &CiToVobcDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nVOBC_SEND:%d", ii); + debug_out_array(0xAA, CiToVobcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ +#endif + retVal = CI_SUCCESS; + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nWrite VOBC %d dataQueue Error Len = %d\n", vobcToCiDataStru->VobcId, ii); + } + } + else + { + ; + } + } + else + { + ; + } + + if (CI_ERROR == retVal) + { + SetErrorData(EFUNC_PACK_CI2VOBC_DATA,CI_DEVICE_TYPE_COMM_VOBC,vobcToCiDataStru->VobcId,ETYPE_COMM_WITH_VOBC,0,ESEND_LEVEL_ZERO); + } + else + { + } + + return retVal; +} + + +/* +* CC VOBC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStru vobcTociݽṹָ +* UINT8* saveGalHead,ͨñͷǷ,1:0: +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +* ޸bug YF0083-100 +*/ +static UINT8 ParseIvocToCiDataFrameCC(const UINT8* pDataBuf, const UINT16 dataLength, const UINT8 systemId, VobcToCiDataStruct* pstVobcToCiDataStru, UINT8* pSaveGalHead, const UINT16 logId) +{ + UINT8 chTrainDir = 0U; /*г*/ + UINT8 chTrainZeroStt = 0U; /*гٱ־*/ + UINT16 ii = 0U; /**/ + UINT8 jj = 0U; + UINT8 chRetVal = CI_ERROR; + UINT16 appInfoType = 0U; /*ӦϢ*/ + UINT32 dwTrackSecId = 0U; /*ID*/ + UINT32 curntCycleNo = 0U; /*ǰں*/ + UINT16 vobcName = 0U; /*VOBC豸ƣ+ID*/ + UINT16 ciName = 0U; /*豸ƣ+ID*/ + UINT8 localCiId = GetSystemParaLocalCiId();/*ID*/ + UINT32 errCode = 0U; + HLHTGALInfoStruct hlhtGalHead = { 0 }; + INT32 vobcInfoRemainValidiy = 0; + UINT8 headRet = HLHT_HEAD_ERROR;/*ͨ*/ + UINT8 chTrainLevel = 0U; + UINT16 wLinkId = 0U; + UINT32 dwOffset = 0U; + UINT16 wTrainSpeed = 0U; + UINT8 chTrainSpeedDir = 0U; + UINT8 chTrainStopNum = 0U; + UINT16 wTrainStopRtId = 0U; + UINT8 chStopSteayState = 0U; + UINT8 chEaNum = 0U; + UINT8 chLogOutState = 0U; + UINT32 dwCyc = 0u; + UINT8 chGroupState = 0u; + UINT16 wGroupOtherTrainId = 0u; + UINT8 chTrainMode = 0u; + UINT8 chTrainHeadScreenConfirm = 0u; + UINT8 chTrainTailScreenConfirm = 0u; + UINT8 chTrainWakeState = 0u; + UINT8 chTrainReportState = 0u; + UINT8 chEaIndex = 0u; + UINT16 wEaTrainId = 0u; + UINT8 chEaState = 0u; + UINT32 dwEaBuildCyc = 0U; + UINT32 dwHlhtNs = 0u; + UINT8 chResourceCancelNum = 0U; /*Դȡ·*/ + UINT16 wResourceCancelRtID = 0U; /*Դȡ·ID*/ + UINT32 dwResourceCancelCyc = 0U; /*Դȡں*/ + UINT8 cUnlockOverlapNum = 0U; /*гε*/ + UINT16 wUnlockOverlapID = 0U; /*гεID*/ + UINT32 dwUnlockOverlapStartCyc = 0U; /*гεʼں*/ + UINT8 cFloodGateCloseAllowNum = 0U; /*гرյķ*/ + UINT16 wFloodGateID = 0U; /*гرյķID*/ + UINT32 dwFloodGateCloseCyc = 0U; /*Źرں*/ + UINT8 cGarageDoorCloseAllowNum = 0U; /*гرյij*/ + UINT16 wGarageDoorID = 0U; /*гرյijID*/ + UINT32 dwGarageDoorCloseCyc = 0U; /*Źرں*/ + LOD_STRU wMaxhead = { 0u }; + LOD_STRU wMaxtail = { 0u }; + LOD_STRU wMinhead = { 0u }; + LOD_STRU wMintail = { 0u }; + UINT16 wApplyDataLenth = 0U; + UINT8 chVideoQkState = 0U;/*Ƶ״̬*/ + UINT8 chVideoQkResult = 0U;/*Ƶͽ*/ + UINT16 wVideoQkRelatePsdId1 = 0U;/*Ƶ͹ID1*/ + UINT16 wVideoQkRelatePsdId2 = 0U;/*Ƶ͹ID2*/ + UINT16 wHeadAxis = 0U; /*ǰ*/ + UINT16 wTailAxis = 0U; /*󷽼*/ + UINT16 wHeadTrainId = 0U;/*ǰID*/ + UINT16 wTrainRelLgcId = 0U;/*гʹö*/ + UINT16 wHeadSignalId = 0U;/*ǰźŻID*/ + + vobcName = (CI_SYSTEM_TYPE_VOBC) * 256U + systemId; + ciName = (CI_SYSTEM_TYPE_CI) * 256U + localCiId; + + if ((NULL == pDataBuf) + || (NULL == pstVobcToCiDataStru) + || (NULL == pSaveGalHead) + || (CI_IVOC_PACKET_LENGTH_MAX< dataLength)) + { + chRetVal = CI_ERROR; + } + else + { + /*βΪգȽֵΪɹ*/ + chRetVal = CI_SUCCESS; + } + + if (CI_SUCCESS == chRetVal) + { + /*ͨϢͷ*/ + hlhtGalHead.devInterInfoType = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + hlhtGalHead.sourceId = LongFromChar(&pDataBuf[ii]); + ii += 4U; + hlhtGalHead.destId = LongFromChar(&pDataBuf[ii]); + ii += 4U; + hlhtGalHead.emapVerCrc = LongFromChar(&pDataBuf[ii]); + ii += 4U; + hlhtGalHead.crntOwnMsgSN = LongFromChar(&pDataBuf[ii]); + ii += 4U; + hlhtGalHead.comPeriod = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + hlhtGalHead.recvOppMsgSN = LongFromChar(&pDataBuf[ii]); + + ii += 4U; + hlhtGalHead.preOwnMsgSN = LongFromChar(&pDataBuf[ii]); + ii += 4U; + hlhtGalHead.prtclVer = pDataBuf[ii++]; + hlhtGalHead.totalDataLen = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + + curntCycleNo = Get2oo2CurCycleNum(); + + pstVobcToCiDataStru->vobcLogId = logId;/*洢VOBC߼ID1˻2*/ + /*ͨϢͷУͨ && ʱЧżϢ*/ + /*һյVOBCϢʱУ鲻ֻͨ¼curntOwnMsgԼǰں*/ + headRet = HLHTRecvCommonPacketHeadCheck(vobcName, ciName, IVOC_CI_INTERFACE_INFOTYPE, CI_IVOC_PRTCL_VER, &hlhtGalHead, &errCode, logId, CI_SYSTEM_TYPE_VOBC); + + debug_infor_printf((const)"\nVOBC %d GAL Check Result:%d errCode:%d", systemId, headRet, errCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + if (HLHT_HEAD_SUCCESS == headRet) + { + /*ϢʱЧ*/ + vobcInfoRemainValidiy = HLHTCommonMsgRemainingValidity(GetCiAndVobcTransBadEnsureTime(), curntCycleNo, GetSystemParaAppCycleTime(), hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN, hlhtGalHead.comPeriod); + + if (vobcInfoRemainValidiy > 0) + { + /*Ӧ*/ + wApplyDataLenth= ShortFromChar(&pDataBuf[ii]);/*Ӧòݳ*/ + ii += 2U; + + appInfoType = ShortFromChar(&pDataBuf[ii]);/*ӦϢͣſϢ֡Ϣ*/ + ii += 2U; + pstVobcToCiDataStru->appInfoType = appInfoType; + pstVobcToCiDataStru->VobcId = systemId; + + ii += 2U;/*Ԥֽ*/ + + if (IVOC_CI_INFO_TYPE_CONTROL == appInfoType) + {/*ֻеVOBCCIϢſƱʱżϢ*/ + pstVobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + /*геȼж*/ + chTrainLevel = pDataBuf[ii]; + ii += 1U; + + if ((TRAIN_LEVEL_UR == chTrainLevel) || (TRAIN_LEVEL_ABL == chTrainLevel) || (TRAIN_LEVEL_VBTC == chTrainLevel) || (TRAIN_LEVEL_ITC == chTrainLevel)) + { + pstVobcToCiDataStru->chTrainLevel = chTrainLevel; + } + else + { + chRetVal = CI_ERROR; + } + + chTrainMode = pDataBuf[ii]; + ii++; + + /* гģʽ */ + if ((TRAIN_MODE_RM == chTrainMode) + || (TRAIN_MODE_CM == chTrainMode) + || (TRAIN_MODE_AM == chTrainMode) + || (TRAIN_MODE_EUM == chTrainMode) + || (TRAIN_MODE_RD == chTrainMode) + || (TRAIN_MODE_AR == chTrainMode) + || (TRAIN_MODE_FAM == chTrainMode) + || (TRAIN_MODE_CAM == chTrainMode) + || (TRAIN_MODE_RRM == chTrainMode) + || (TRAIN_MODE_VCM == chTrainMode)) + { + pstVobcToCiDataStru->chTrainMode = chTrainMode; + } + else + { + chRetVal = CI_ERROR; + } + + /*гȫǰλ*/ + if (CI_SUCCESS == chRetVal) + { + wMaxhead.Lnk = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + wMaxhead.Off = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if (UINT16_MAX != wLinkId) + { + pstVobcToCiDataStru->wTrainMaxSafeHeadLink = wMaxhead.Lnk; + pstVobcToCiDataStru->dwTrainMaxSafeHeadOffset = wMaxhead.Off; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гСȫλ*/ + if (CI_SUCCESS == chRetVal) + { + wMintail.Lnk = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + wMintail.Off = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if (UINT16_MAX != wLinkId) + { + pstVobcToCiDataStru->wTrainMinSafeTailLink = wMintail.Lnk; + pstVobcToCiDataStru->dwTrainMinSafeTailOffset = wMintail.Off; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + + /*гСȫǰλ*/ + if (CI_SUCCESS == chRetVal) + { + wMinhead.Lnk = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + wMinhead.Off = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if (UINT16_MAX != wLinkId) + { + pstVobcToCiDataStru->wTrainMinSafeHeadLink = wMinhead.Lnk; + pstVobcToCiDataStru->dwTrainMinSafeHeadOffset = wMinhead.Off; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гȫλ*/ + if (CI_SUCCESS == chRetVal) + { + wMaxtail.Lnk = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + wMaxtail.Off = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if (UINT16_MAX != wLinkId) + { + pstVobcToCiDataStru->wTrainMaxSafeTailLink = wMaxtail.Lnk; + pstVobcToCiDataStru->dwTrainMaxSafeTailOffset = wMaxtail.Off; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + /*гз*/ + if (CI_SUCCESS == chRetVal) + { + chTrainDir = pDataBuf[ii]; + ii += 1U; + if ((TRAIN_DIR_UP == chTrainDir) || (TRAIN_DIR_DOWN == chTrainDir)) + { + pstVobcToCiDataStru->trainDirection = chTrainDir; + /*УǷܼǰСǰ㷽*/ + chRetVal = CheckTrainDirToOtherPointDir(wMaxhead, wMinhead, wMaxtail, wMintail, chTrainDir); + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гٶȷ*/ + if (CI_SUCCESS == chRetVal) + { + wTrainSpeed = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + chTrainSpeedDir = pDataBuf[ii]; + ii += 1U; + if (((TRAIN_SPEED_DIR_FORWARD == chTrainSpeedDir) || (TRAIN_SPEED_DIR_BACKWARD == chTrainSpeedDir)) && (UINT16_MAX!= wTrainSpeed)) + { + pstVobcToCiDataStru->chSpeedDir = chTrainSpeedDir; + pstVobcToCiDataStru->wTrainSpeed = wTrainSpeed; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*ٱ־*/ + if (CI_SUCCESS == chRetVal) + { + chTrainZeroStt = pDataBuf[ii]; + ii += 1U; + if ((TRAIN_SPEED_ZERO_YES == chTrainZeroStt) || (TRAIN_SPEED_ZERO_NO == chTrainZeroStt)) + { + pstVobcToCiDataStru->chTrainZeroState = chTrainZeroStt; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*˹ȷǰɸ*/ + if (CI_SUCCESS == chRetVal) + { + chTrainHeadScreenConfirm = pDataBuf[ii]; + ii++; + if ((TRAIN_HEAD_CONFIRM_YES == chTrainHeadScreenConfirm) || (TRAIN_HEAD_CONFIRM_NO == chTrainHeadScreenConfirm)) + { + pstVobcToCiDataStru->chTrainHeadScreenConfirm = chTrainHeadScreenConfirm; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ; + } + + /*˹ȷϺɸ*/ + if (CI_SUCCESS == chRetVal) + { + chTrainTailScreenConfirm = pDataBuf[ii]; + ii++; + if ((TRAIN_TAIL_CONFIRM_YES == chTrainTailScreenConfirm) || (TRAIN_TAIL_CONFIRM_NO == chTrainTailScreenConfirm)) + { + pstVobcToCiDataStru->chTrainTailScreenConfirm = chTrainTailScreenConfirm; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ; + } + + /*ǰɸʶϢ*/ + if (CI_SUCCESS == chRetVal) + { + /*ǰ*/ + wHeadAxis = ShortFromChar(&pDataBuf[ii]); + ii += 2u; + if (0xffffU == wHeadAxis) + { + chRetVal = CI_ERROR; /*Ƿֵ*/ + } + else + { + pstVobcToCiDataStru->wHeadAxisId = wHeadAxis; + } + + /*ǰITEʶ*/ + if (CI_SUCCESS == chRetVal) + { + pstVobcToCiDataStru->wHeadITEResult = pDataBuf[ii]; + ii++; + if ((TRAIN_ITE_RESULT_YES == pstVobcToCiDataStru->wHeadITEResult) + || (TRAIN_ITE_RESULT_NO == pstVobcToCiDataStru->wHeadITEResult)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + + /*󷽼*/ + if (CI_SUCCESS == chRetVal) + { + wTailAxis = ShortFromChar(&pDataBuf[ii]); + ii += 2u; + if (0xffffU == wTailAxis) + { + chRetVal = CI_ERROR; /*Ƿֵ*/ + } + else + { + pstVobcToCiDataStru->wTailAxisId = wTailAxis; + } + } + else + { + /*󲻼*/ + } + + /*ITEʶ*/ + if (CI_SUCCESS == chRetVal) + { + pstVobcToCiDataStru->wTailITEResult = pDataBuf[ii]; + ii++; + if ((TRAIN_ITE_RESULT_YES == pstVobcToCiDataStru->wTailITEResult) + || (TRAIN_ITE_RESULT_NO == pstVobcToCiDataStru->wTailITEResult)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + + if (0U != wHeadAxis) + { + /*ʶЧ*/ + debug_infor_printf((const)"\nVOBC %d ITE Result : Head axis_%d RE :%d __Tail Axis_%d RE: %d\n", + systemId, wHeadAxis, pstVobcToCiDataStru->wHeadITEResult, wTailAxis, pstVobcToCiDataStru->wTailITEResult); + } + } + else + { + /*󲻼*/ + } + + /*г֤ͣ*/ + if (CI_SUCCESS == chRetVal) + { + + chTrainStopNum = pDataBuf[ii]; + ii += 1U; + if (IVOC_CI_STOP_ASS_SUM_MAX > chTrainStopNum) + { + pstVobcToCiDataStru->chTrainStopAssureNum = chTrainStopNum; + for (jj = 0U; jj < chTrainStopNum; jj++) + { + wTrainStopRtId = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + dwCyc = LongFromChar(&pDataBuf[ii]); + ii += 4U; + + if ((UINT16_MAX != wTrainStopRtId) && (0U != wTrainStopRtId)) + { + pstVobcToCiDataStru->szTrainStopRouteId[jj] = wTrainStopRtId; + pstVobcToCiDataStru->szTrainStopRouteCyc[jj] = dwCyc; + } + else + { + chRetVal = CI_ERROR; + } + if (CI_ERROR == chRetVal) + { + break; + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гԴȡ*/ + if (CI_SUCCESS == chRetVal) + { + + chResourceCancelNum = pDataBuf[ii];/*Դȡ·*/ + ii += 1U; + if (IV0C_CI_RESOURCE_CANCEL_SUM_MAX > chResourceCancelNum) + { + pstVobcToCiDataStru->chResourcesCancelNum = chResourceCancelNum; + /*ԴȡĽ·*/ + for (jj = 0U; jj < chResourceCancelNum; jj++) + { + wResourceCancelRtID = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + dwResourceCancelCyc = LongFromChar(&pDataBuf[ii]); + ii += 4U; + /*Դȡ·IDЧ*/ + if ((UINT16_MAX != wResourceCancelRtID) && (0U != wResourceCancelRtID)) + { + pstVobcToCiDataStru->szResourcesCancelRouteId[jj] = wResourceCancelRtID;/*ȡԴȡ·ID*/ + pstVobcToCiDataStru->szResourcesCancelRouteCyc[jj] = dwResourceCancelCyc;/*ȡԴȡں*/ + } + else + { + chRetVal = CI_ERROR; + } + if (CI_ERROR == chRetVal) + { + break; + } + else + { + /*ѭ*/ + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гıϢ*/ + if (CI_SUCCESS == chRetVal) + { + cUnlockOverlapNum = pDataBuf[ii]; /*гε*/ + ii += 1U; + + if (IVOC_CI_UNLOCK_OVERLAP_SUM > cUnlockOverlapNum) + { + pstVobcToCiDataStru->cAllowUnlockOverlapNum = cUnlockOverlapNum; /*гεЧVOBCṹ*/ + + /*гı*/ + for (jj = 0U; jj < cUnlockOverlapNum; jj++) + { + wUnlockOverlapID = ShortFromChar(&pDataBuf[ii]); /*гεID*/ + ii += 2U; + dwUnlockOverlapStartCyc = LongFromChar(&pDataBuf[ii]); /*гεʼں*/ + ii += 4U; + + if ((OVERLAP_SUM_MAX > wUnlockOverlapID) && (0U != wUnlockOverlapID) && (0U != dwUnlockOverlapStartCyc)) + { + /*IDͽʼںЧVOBCṹ*/ + pstVobcToCiDataStru->szAllowUnlockOverlapId[jj] = wUnlockOverlapID; + pstVobcToCiDataStru->szAllowUnlockOverlapStartCyc[jj] = dwUnlockOverlapStartCyc; + } + else + { + chRetVal = CI_ERROR; + break; + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гرյķϢ*/ + if (CI_SUCCESS == chRetVal) + { + cFloodGateCloseAllowNum = pDataBuf[ii]; /*гرյķ*/ + ii += 1U; + + if (IVOC_CI_FLOODGATE_CLOSE_ALLOW_SUM > cFloodGateCloseAllowNum) + { + pstVobcToCiDataStru->cAllowCloseFloodGateNum = cFloodGateCloseAllowNum; /*гرյķЧVOBCṹ*/ + + /*гرյķ*/ + for (jj = 0U; jj < cFloodGateCloseAllowNum; jj++) + { + wFloodGateID = ShortFromChar(&pDataBuf[ii]); /*гرյķID*/ + ii += 2U; + dwFloodGateCloseCyc = LongFromChar(&pDataBuf[ii]); /*Źرں*/ + ii += 4U; + + if ((FLOOD_GATE_SUM_MAX > wFloodGateID) && (0U != wFloodGateID) && (0U != dwFloodGateCloseCyc)) + { + /*гرյķIDͷŹرںЧVOBCṹ*/ + pstVobcToCiDataStru->szAllowCloseFloodGateId[jj] = wFloodGateID; + pstVobcToCiDataStru->szAllowCloseFloodGateCyc[jj] = dwFloodGateCloseCyc; + } + else + { + chRetVal = CI_ERROR; + break; + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гرյijϢ*/ + if (CI_SUCCESS == chRetVal) + { + cGarageDoorCloseAllowNum= pDataBuf[ii];/*гرյij*/ + ii++; + + if (IVOC_CI_GARAGEDOOR_CLOSE_ALLOW_SUM > cGarageDoorCloseAllowNum) + { + pstVobcToCiDataStru->cAllowCloseGarageGateNum = cGarageDoorCloseAllowNum; /*гرյķЧVOBCṹ*/ + + /*гرյķ*/ + for (jj = 0U; jj < cGarageDoorCloseAllowNum; jj++) + { + wGarageDoorID = ShortFromChar(&pDataBuf[ii]); /*гرյijID*/ + ii += 2U; + dwGarageDoorCloseCyc = LongFromChar(&pDataBuf[ii]); /*Źرں*/ + ii += 4U; + + if ((GARAGE_DOOR_SUM_MAX > wGarageDoorID) && (0U != wGarageDoorID) && (0U != dwGarageDoorCloseCyc)) + { + /*гرյijIDͳŹرںЧVOBCṹ*/ + pstVobcToCiDataStru->szAllowCloseGarageGateId[jj] = wGarageDoorID; + pstVobcToCiDataStru->szAllowCloseGarageGateCyc[jj] = dwGarageDoorCloseCyc; + } + else + { + chRetVal = CI_ERROR; + break; + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + + } + /*гͣ״̬*/ + if (CI_SUCCESS == chRetVal) + { + + chStopSteayState = pDataBuf[ii]; + ii += 1U; + dwTrackSecId = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if ((VOBC_CI_STOP_TW == chStopSteayState)||(VOBC_CI_STOP_WTW == chStopSteayState)) + { + pstVobcToCiDataStru->trainStopSteadyState = chStopSteayState; + pstVobcToCiDataStru->stopSteadyStartCycNum = Get2oo2CurCycleNum(); + pstVobcToCiDataStru->trackSecID = dwTrackSecId; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*г״̬*/ + if (CI_SUCCESS == chRetVal) + { + chTrainWakeState = pDataBuf[ii]; + ii++; + if ((TRAIN_WAKE_SUCCESS == chTrainWakeState) + || (TRAIN_WAKE_PROCESS == chTrainWakeState) + || (TRAIN_WAKE_FAILURE == chTrainWakeState) + || (TRAIN_WAKE_DEFAULT == chTrainWakeState)) + { + pstVobcToCiDataStru->chTrainWakeState = chTrainWakeState; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ; + } + + /*г㱨״̬*/ + if (CI_SUCCESS == chRetVal) + { + chTrainReportState = pDataBuf[ii]; + ii++; + + pstVobcToCiDataStru->chTrainReportState = chTrainReportState; + } + else + { + ; + } + /*гɢϢ*/ + if (CI_SUCCESS == chRetVal) + { + chEaNum = pDataBuf[ii]; + ii += 1U; + + if (IVOC_CI_EA_MAX >= chEaNum) + { + pstVobcToCiDataStru->chEaNum = chEaNum; + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + { + wEaTrainId = ShortFromChar(&pDataBuf[ii]); + ii += 2u; + chEaState = pDataBuf[ii]; + ii++; + dwEaBuildCyc =LongFromChar(&pDataBuf[ii]); + ii += 4u; + if ((0x1401u <= wEaTrainId) && (0x14feu >= wEaTrainId) && ((EA_PROTECT_BUILD_Y == chEaState) || (EA_PROTECT_BUILD_N == chEaState))) + { + pstVobcToCiDataStru->stEaInfo[chEaIndex].wDeviceId = wEaTrainId; + pstVobcToCiDataStru->stEaInfo[chEaIndex].chDeviceStatus = chEaState; + pstVobcToCiDataStru->stEaInfo[chEaIndex].dwBuildCyc = dwEaBuildCyc; + } + else + { + chRetVal = CI_ERROR; + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } +#if 0 + /*һID*/ + if (CI_SUCCESS == chRetVal) + { + wGroupOtherTrainId = ShortFromChar(&pDataBuf[ii]); + ii += 2u; + if (((TRAIN_ID_MIN < wGroupOtherTrainId) && (TRAIN_ID_MAX > wGroupOtherTrainId)) + ||(TRAIN_ID_INVAL == wGroupOtherTrainId)) + { + pstVobcToCiDataStru->wGroupOtherTrainId = wGroupOtherTrainId; + } + else + { + /*гID*/ + chRetVal = CI_ERROR; + } + } + else + { + /* */ + } + + /*г״̬*/ + if (CI_SUCCESS == chRetVal) + { + chGroupState = pDataBuf[ii]; + ii++; + if ((VOBC_CI_GROUP_NO == chGroupState)|| + (VOBC_CI_GROUP_SET == chGroupState)|| + (VOBC_CI_GROUP_RUN == chGroupState)|| + (VOBC_CI_GROUP_REVERSE == chGroupState)|| + (VOBC_CI_GROUP_EXIT == chGroupState)) + { + pstVobcToCiDataStru->chGroupRunState = chGroupState; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /* */ + } + + /*ǰ󳵹ϵ*/ + if (CI_SUCCESS == chRetVal) + { + chGroupState = pDataBuf[ii]; + ii++; + if ((VOBC_CI_GROUP_HEAD == chGroupState)|| + (VOBC_CI_GROUP_TAIL == chGroupState)|| + (VOBC_CI_GROUP_INVAL == chGroupState)) + { + pstVobcToCiDataStru->chGroupTrainReat = chGroupState; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /* */ + } +#endif + /*ǰ*/ + if (CI_SUCCESS == chRetVal) + { + pstVobcToCiDataStru->chActive = pDataBuf[ii]; + ii++; + if ((TRAIN_ACTIVE_NONE == pstVobcToCiDataStru->chActive) + || (TRAIN_ACTIVE_ONE == pstVobcToCiDataStru->chActive) + || (TRAIN_ACTIVE_TWO == pstVobcToCiDataStru->chActive) + || (TRAIN_ACTIVE_ALL == pstVobcToCiDataStru->chActive)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ; /**/ + } + + /*ԶRM״̬*/ + if (CI_SUCCESS == chRetVal) + { + pstVobcToCiDataStru->chRrmReq = pDataBuf[ii]; + ii++; + if ((TRAIN_RRM_RQST_YES == pstVobcToCiDataStru->chRrmReq) + || (TRAIN_RRM_RQST_NO == pstVobcToCiDataStru->chRrmReq)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ; /*ʧ*/ + } + + /*RRMģʽһվID*/ + if (CI_SUCCESS == chRetVal) + { + dwHlhtNs = LongFromChar(&pDataBuf[ii]); + ii += 4u; + pstVobcToCiDataStru->wNextStation = 0u; + (void)dquQueryInDevIndex(QFUN_IDMAP_STATION_ID, dwHlhtNs, &pstVobcToCiDataStru->wNextStation); + } + else + { + ; + } + + /*гѹ״̬*/ + if (CI_SUCCESS == chRetVal) + { + pstVobcToCiDataStru->chDerailment = pDataBuf[ii]; + ii++; + if ((TRAIN_DERAIL_YES == pstVobcToCiDataStru->chDerailment) + || (TRAIN_DERAIL_NO == pstVobcToCiDataStru->chDerailment)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ; /*ʧ*/ + } + + + + /*ƵϢ*/ + if (CI_SUCCESS == chRetVal) + { + /*Ƶ״̬*/ + chVideoQkState = pDataBuf[ii]; + ii++; + /*Ƶͽ*/ + chVideoQkResult = pDataBuf[ii]; + ii++; + /*Ƶ͹ID1*/ + wVideoQkRelatePsdId1 = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + /*Ƶ͹ID2*/ + wVideoQkRelatePsdId2 = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + + if (((VIDEO_QK_STATE_TESTING == chVideoQkState) || (VIDEO_QK_STATE_DEFAULT == chVideoQkState)) + && ((VIDEO_QK_RESULT_TESTNO == chVideoQkResult) || (VIDEO_QK_RESULT_TESTHAVE == chVideoQkResult) || (VIDEO_QK_RESULT_TESTDEFAULT == chVideoQkResult)) + && (PSD_SUM_MAX > wVideoQkRelatePsdId1) + && (PSD_SUM_MAX > wVideoQkRelatePsdId2)) + { + pstVobcToCiDataStru->chVideoQkState = chVideoQkState; + pstVobcToCiDataStru->chVideoQkResult = chVideoQkResult; + pstVobcToCiDataStru->wVideoQkRelatePsdId1 = wVideoQkRelatePsdId1; + pstVobcToCiDataStru->wVideoQkRelatePsdId2 = wVideoQkRelatePsdId2; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + + /*гϴϢ*/ + if (CI_SUCCESS == chRetVal) + { + /*ϴ*/ + pstVobcToCiDataStru->washTrainRequest = pDataBuf[ii]; + ii++; + if ((WASHMACHINE_DRVSTATE_REQ_TRUE == pstVobcToCiDataStru->washTrainRequest) + || (WASHMACHINE_DRVSTATE_REQ_FALSE == pstVobcToCiDataStru->washTrainRequest)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + if (CI_SUCCESS == chRetVal) + { + /*ϴͣ1*/ + pstVobcToCiDataStru->headWashStopSteadyInfo = pDataBuf[ii]; + ii++; + if ((WASHMACHINE_HEAD_STEADY_YES == pstVobcToCiDataStru->headWashStopSteadyInfo) + || (WASHMACHINE_HEAD_STEADY_NO == pstVobcToCiDataStru->headWashStopSteadyInfo)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + if (CI_SUCCESS == chRetVal) + { + /*ͣϴ*/ + pstVobcToCiDataStru->washPauseRequest = pDataBuf[ii]; + ii++; + if ((WASHMACHINE_PAUSE_DRVREQ_TRUE == pstVobcToCiDataStru->washPauseRequest) + || (WASHMACHINE_PAUSE_DRVREQ_FALSE == pstVobcToCiDataStru->washPauseRequest)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + if (CI_SUCCESS == chRetVal) + { + /*ϴͣ2*/ + pstVobcToCiDataStru->tailWashStopSteadyInfo = pDataBuf[ii]; + ii++; + if ((WASHMACHINE_TAIL_STEADY_YES == pstVobcToCiDataStru->tailWashStopSteadyInfo) + || (WASHMACHINE_TAIL_STEADY_NO == pstVobcToCiDataStru->tailWashStopSteadyInfo)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + if (CI_SUCCESS == chRetVal) + { + /*ϴͨ*/ + pstVobcToCiDataStru->passWashMachineRequest = pDataBuf[ii]; + ii++; + if ((PASS_WASHMACHINE_REQUEST_VALID == pstVobcToCiDataStru->passWashMachineRequest) + || (PASS_WASHMACHINE_REQUEST_INVALID == pstVobcToCiDataStru->passWashMachineRequest)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + if (CI_SUCCESS == chRetVal) + { + /*ϴģʽ*/ + pstVobcToCiDataStru->chWashMachineWorkMode = pDataBuf[ii]; + ii++; + if ((WASHMACHINE_WORKMODE_ALL_DRV == pstVobcToCiDataStru->chWashMachineWorkMode) + || (WASHMACHINE_WORKMODE_SIDE_DRV == pstVobcToCiDataStru->chWashMachineWorkMode) + || (WASHMACHINE_WORKMODE_DEFAULT_DRV == pstVobcToCiDataStru->chWashMachineWorkMode)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + } + else + { + /*󲻼*/ + } + + if (CI_SUCCESS == chRetVal) + { + /*NVRAMλñʶ*/ + pstVobcToCiDataStru->chNvramPosFlag = pDataBuf[ii]; + ii++; + if ((TRAIN_NVRAM_POS_FLAG_YES == pstVobcToCiDataStru->chNvramPosFlag) + || (TRAIN_NVRAM_POS_FLAG_NO == pstVobcToCiDataStru->chNvramPosFlag)) + { + ; /*ͨ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /*󲻼*/ + } + + if (CI_SUCCESS == chRetVal) + { + dwHlhtNs = LongFromChar(&pDataBuf[ii]); + ii += 4u; + if (0x00000000U == dwHlhtNs) + { + /*ĬֵǰźŻIDΪ0*/ + pstVobcToCiDataStru->wHeadSigId = 0U; + } + else + { + /*ݻͨ4ֽIDȡźŻID*/ + chRetVal = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, dwHlhtNs, &wHeadSignalId); + if ((CI_SUCCESS == chRetVal) && (SIGNAL_SUM_MAX > wHeadSignalId)) + { + pstVobcToCiDataStru->wHeadSigId = wHeadSignalId; + } + else + { + chRetVal = CI_ERROR; + } + } + } + else + { + /*󲻼*/ + } + + /*ǰID*/ + if (CI_SUCCESS == chRetVal) + { + dwHlhtNs = LongFromChar(&pDataBuf[ii]); + ii += 4u; + if (0xFFFFFFFFU == dwHlhtNs) + { + /*ĬֵǰIDΪ0*/ + pstVobcToCiDataStru->wHeadVobcId = 0x14FFU; + } + else + { + chRetVal = dquHlhtId2VobcName(dwHlhtNs, &wHeadTrainId, &wTrainRelLgcId); + if (CI_SUCCESS == chRetVal) + { + pstVobcToCiDataStru->wHeadVobcId = wHeadTrainId; + } + else + { + chRetVal = CI_ERROR; + } + } + } + else + { + /*󲻼*/ + } + + /*гϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = ParseIvocToCiCmdCC(pDataBuf, &ii, pstVobcToCiDataStru); + + } + else + { + /* */ + } + /*Ϣ֡ĩβ4ֽԤλע֡Ԥλ*/ + ii += 4U; + + } + else if (IVOC_CI_INFO_TYPE_LOGOUT_ASK == appInfoType) + {/*IVOC->OCע֡*/ + + pstVobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + chLogOutState = pDataBuf[ii]; + ii += 1U; + if ((IVOC_CI_LOGOUT_NORMAL == chLogOutState) || (IVOC_CI_LOGOUT_SLEEP == chLogOutState)) + { + pstVobcToCiDataStru->chLogOutState = chLogOutState; + } + else + { + chRetVal = CI_ERROR; + } + + /*гȫǰλ*/ + if (CI_SUCCESS == chRetVal) + { + wLinkId = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + dwOffset = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if ((0U != wLinkId) && (UINT16_MAX != wLinkId) && (UINT32_MAX != dwOffset)) + { + pstVobcToCiDataStru->wTrainMaxSafeHeadLink = wLinkId; + pstVobcToCiDataStru->dwTrainMaxSafeHeadOffset = dwOffset; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гСȫλ*/ + if (CI_SUCCESS == chRetVal) + { + wLinkId = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + dwOffset = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if ((0U != wLinkId) && (UINT16_MAX != wLinkId) && (UINT32_MAX != dwOffset)) + { + pstVobcToCiDataStru->wTrainMinSafeTailLink = wLinkId; + pstVobcToCiDataStru->dwTrainMinSafeTailOffset = dwOffset; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гСȫǰλ*/ + if (CI_SUCCESS == chRetVal) + { + wLinkId = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + dwOffset = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if ((0U != wLinkId) && (UINT16_MAX != wLinkId) && (UINT32_MAX != dwOffset)) + { + pstVobcToCiDataStru->wTrainMinSafeHeadLink = wLinkId; + pstVobcToCiDataStru->dwTrainMinSafeHeadOffset = dwOffset; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + + /*гȫλ*/ + if (CI_SUCCESS == chRetVal) + { + wLinkId = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + dwOffset = LongFromChar(&pDataBuf[ii]); + ii += 4U; + if ((0U != wLinkId) && (UINT16_MAX != wLinkId) && (UINT32_MAX != dwOffset)) + { + pstVobcToCiDataStru->wTrainMaxSafeTailLink = wLinkId; + pstVobcToCiDataStru->dwTrainMaxSafeTailOffset = dwOffset; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /**/ + } + } + else if (IVOC_CI_INFO_TYPE_HEART_FRAME == appInfoType) + { + pstVobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + /*Уݳ γȣڲ㳤ȱټ¼ȵֽ */ + if ((hlhtGalHead.totalDataLen != ii - 31U) || (wApplyDataLenth != ii - 33U)) + { + /* 31ΪӦ֡ͷ */ + chRetVal = CI_ERROR; + + } + } + + if (CI_SUCCESS == chRetVal) + { + /*ݾУ飬Ҫ洢ͨñ*/ + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId); + + *pSaveGalHead = 1U; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else if (HLHT_HEAD_INIT == headRet) + { + if (curntCycleNo > 0U)/*жŴ0Ϊ0Ч*/ + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_VOBC, systemId, logId); + + *pSaveGalHead = 1U; + } + + chRetVal = CI_ERROR; + } + else + { + /*ATSֵطVOBC-CIݽӿϢʹ*/ + if (GAL_COMPARE_INFO_TYPE_ERR == (errCode & GAL_COMPARE_INFO_TYPE_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_INFO_TYPE_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݷͷʶϢ*/ + else if (GAL_COMPARE_SEND_FLAG_ERR == (errCode & GAL_COMPARE_SEND_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_SEND_FLAG_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݽշ־Ϣ*/ + else if (GAL_COMPARE_RECV_FLAG_ERR == (errCode & GAL_COMPARE_RECV_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_RECV_FLAG_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݰ汾УʧϢ*/ + else if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_VER_CHECK_FAIL, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݱԷյһϢʱкŴ*/ + else if (GAL_COMPARE_MSG_BDS_SN_ERR == (errCode & GAL_COMPARE_MSG_BDS_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_MSG_BDS_SN_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIݶԷϢкżյһϢʱкŴ*/ + else if (GAL_COMPARE_MSG_SN_ERR == (errCode & GAL_COMPARE_MSG_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_MSG_SN_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIЭ汾Ŵ*/ + else if (GAL_COMPARE_PROTOCOL_VER_ERR == (errCode & GAL_COMPARE_PROTOCOL_VER_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_PROTOCOL_VER_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIӦòݳЧ*/ + else if (GAL_COMPARE_APP_LEN_ERR == (errCode & GAL_COMPARE_APP_LEN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_APP_LEN_ERR, ESEND_LEVEL_ATS); + } + /*ATSֵطVOBC-CIͨڴ */ + else if (GAL_COMPARE_COM_PERIOD == (errCode & GAL_COMPARE_COM_PERIOD)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_BACK_DATA_COM_PERIOD, ESEND_LEVEL_ATS); + } + else + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_VOBC2CI_DATA, CI_SYSTEM_TYPE_VOBC, systemId, ETYPE_COMM_WITH_VOBC, CI_ERROR, ESEND_LEVEL_ATS); + } + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CC IVOCϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* VobcToCiDataStru vobcTociݽṹָ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 ParseIvocToCiCmdCC(const UINT8* pDataBuf,UINT16 *wDataLength, VobcToCiDataStruct* pstVobcToCiDataStru) +{ + UINT16 wCmdNum = 0U; + UINT16 wCmdIndex = 0U; + UINT8 chCmdDevNum = 0U; + UINT8 chCmdDevIdx = 0U; + UINT8 chCmdType = 0U; + UINT16 wCmdDevId = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 cLocalCiId = 0u; + UINT16 wTrainMaxSafeHeadBelongCiId = 0u; + cLocalCiId = GetSystemParaLocalCiId(); + + if ((NULL == pDataBuf) + || (NULL == pstVobcToCiDataStru) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + wTrainMaxSafeHeadBelongCiId = GetLinkManageTiocById(pstVobcToCiDataStru->wTrainMaxSafeHeadLink); + + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wCmdNum = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + + if (IVOC_CI_CMD_MAX > wCmdNum) + { + pstVobcToCiDataStru->wIvocCmdNum = wCmdNum; + for (wCmdIndex = 0U; wCmdIndex < wCmdNum ; wCmdIndex++) + { + chCmdType = pDataBuf[ii]; + ii += 1U; + chCmdDevNum = pDataBuf[ii]; + ii += 1U; + if (IVOC_CI_CMD_DEVICE_MAX > chCmdDevNum) + { + switch (chCmdType) + { + case IVOC_CI_CMD_TYPE_RES_APPLY: + case IVOC_CI_CMD_TYPE_RES_RELEASE: + case IVOC_CI_CMD_TYPE_EA_BUILD: + case IVOC_CI_CMD_TYPE_EA_CANCEL: + case IVOC_CI_CMD_TYPE_DYTEST_REQ: + case IVOC_CI_CMD_TYPE_DYTEST_CANCEL: + case IVOC_CI_CMD_TYPE_JUMP_LOCK_APPLY: + case IVOC_CI_CMD_TYPE_JUMP_LOCK_RELEASE: + case IVOC_CI_CMD_GAP_DETECT_START: + case IVOC_CI_CMD_GAP_DETECT_STOP: + case IVOC_CI_CMD_NON_RETURN_STEADY: + case IVOC_CI_CMD_NON_RETURN_FLASH: + case IVOC_CI_CMD_TYPE_EMD_BUILD: + /*ԴС100*/ + if (((IVOC_CI_CMD_TYPE_EA_BUILD == chCmdType) || (IVOC_CI_CMD_TYPE_EMD_BUILD == chCmdType)) + && ((cLocalCiId != wTrainMaxSafeHeadBelongCiId) || (0u != chCmdDevNum))) + { + chRetVal = CI_ERROR; + } + else + { + ; + } + pstVobcToCiDataStru->stCmdInfo[wCmdIndex].chCmdType = chCmdType; + pstVobcToCiDataStru->stCmdInfo[wCmdIndex].chCmdDevNum = chCmdDevNum; + break; + case IVOC_CI_CMD_TYPE_PSD_OPEN_FOUR: + case IVOC_CI_CMD_TYPE_PSD_CLOSE: + case IVOC_CI_CMD_TYPE_PSD_OPEN_SIX: + case IVOC_CI_CMD_TYPE_PSD_OPEN_EIGHT: + if (2u >= chCmdDevNum) + { + /*С2*/ + pstVobcToCiDataStru->stCmdInfo[wCmdIndex].chCmdType = chCmdType; + pstVobcToCiDataStru->stCmdInfo[wCmdIndex].chCmdDevNum = chCmdDevNum; + } + else + { + chRetVal = CI_ERROR; + } + break; + default: + chRetVal = CI_ERROR; + break; + } + + if (CI_SUCCESS == chRetVal) + { + for (chCmdDevIdx = 0U; chCmdDevIdx < chCmdDevNum; chCmdDevIdx++) + { + wCmdDevId = ShortFromChar(&pDataBuf[ii]); + ii += 2U; + if ((0U < wCmdDevId) && (UINT16_MAX > wCmdDevId)) + { + pstVobcToCiDataStru->stCmdInfo[wCmdIndex].wCmdDevId[chCmdDevIdx] = wCmdDevId; + } + else + { + chRetVal = CI_ERROR; + break; + } + } + } + + } + else + { + /*пƶǷ*/ + chRetVal = CI_ERROR; + } + + if (CI_ERROR == chRetVal) + { + break;/*ƶǷ||ƶIDǷ*/ + } + } + } + else + { + chRetVal = CI_ERROR; + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + + +/* +* 鳵Ivoc +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* VobcToCiDataStruct *pstVobcToCiDataStru VobcϢṹ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToIvocDataCC(VobcToCiDataStruct *pstVobcToCiDataStru) +{ + UINT8 cszCiToIvocDataBuf[VOBC_TO_CI_DATA_LEN_MAX] = { 0u };/*CIVOBC֡*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 kk = 0u; + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 appCycleTime = GetSystemParaAppCycleTime(); + UINT8 chRetVal = CI_ERROR; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT32 ciEtcsId = 0u; + UINT32 vobcEtcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT8 localhlhtId = 0u; + UINT8 vobcHlhtId = 0u; + UINT8 ciEmapCheckVer = 0u; + UINT16 wAppInfoIndex = 0U; + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT8 chSwState = 0u; + /*ȻȡʱϢȡɹбҪ*/ + + if (NULL != pstVobcToCiDataStru) + { + localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCiId, 0U, &ciEtcsId); + vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(pstVobcToCiDataStru->VobcId), pstVobcToCiDataStru->vobcLogId, &vobcEtcsId); + ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC); + } + else + { + ; + } + + if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer)) + { + chRetVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"\nPack vobc %d HLHT_id or EmapCheckVer error ciEmapCheckVer%d \n", pstVobcToCiDataStru->VobcId, ciEmapCheckVer); + chRetVal = CI_ERROR; + } + if (CI_SUCCESS == chRetVal) + { + ii = 0u; +#if 0 + /*ͨЭ֡ͷ*/ + ii += 2u; + cszCiToIvocDataBuf[ii++] = CI_SYSTEM_TYPE_VOBC; /*Ŀ߼*/ + cszCiToIvocDataBuf[ii++] = (UINT8)pstVobcToCiDataStru->VobcId; /*Ŀ߼ID*/ + ShortToChar(pstVobcToCiDataStru->vobcLogId, &cszCiToIvocDataBuf[ii]); /*ͨ4IP VOBC1˻2˱ʶ*/ + ii += 2u; +#endif + /*ʼӦ֡*/ + + ShortToChar(IVOC_CI_INTERFACE_INFOTYPE, &cszCiToIvocDataBuf[ii]);/*ӿϢ*/ + ii += 2u; + LongToChar(ciEtcsId, &cszCiToIvocDataBuf[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(vobcEtcsId, &cszCiToIvocDataBuf[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(emapCheckVer, &cszCiToIvocDataBuf[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &cszCiToIvocDataBuf[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &cszCiToIvocDataBuf[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(pstVobcToCiDataStru->VobcId)), &cszCiToIvocDataBuf[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(pstVobcToCiDataStru->VobcId)), &cszCiToIvocDataBuf[ii]);/*յһϢʱк*/ + ii += 4u; + cszCiToIvocDataBuf[ii++] = CI_VOBC_PRTCL_VER;/*HLHT+FAO_CI_VOBCӿЭ汾*/ + ii += 2u;/*ͨñͷеӦò㱨ܳ*/ + + /*ΪӦò*/ + ii += 2u;/*ij*/ + + wAppInfoIndex = ii; + ii += 2u;/*Ӧñ*/ + + ii += 2u;/*Ԥֽ*/ + + if (IVOC_CI_INFO_TYPE_CONTROL == pstVobcToCiDataStru->appInfoType) + { + ShortToChar(CI_IVOC_INFO_TYPE_STATE, &cszCiToIvocDataBuf[wAppInfoIndex]); + + chRetVal = PackCiToIvocSwitchInfo(cszCiToIvocDataBuf, &ii); + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocPsdInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocSwitchInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocEsbInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocPsdInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocARInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocEsbInfo Error \n", pstVobcToCiDataStru->VobcId); + } + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocSpksInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocARInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocGaragedoorInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocSpksInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocFloodGateInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocGaragedoorInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocFLockInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocFloodGateInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocCommTrainInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocFLockInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocFaultTrainInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocCommTrainInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocSleepTrainInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocFaultTrainInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocTsrInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocSleepTrainInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocLgcSgmtInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocTsrInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocReqAndReplyInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocLgcSgmtInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocReqAlignmentInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocReqAndReplyInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocUnlockOverlapInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocReqAlignmentInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*ѩ״̬ͽƶϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocSnowAndUrgentInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocUnlockOverlapInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*ϴϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocWashMachineInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocSnowAndUrgentInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*ǰźŻϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToVobcSigInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocWashMachineInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocHeadTrainInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToVobcSigInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*ͨIVOCITEȫг״̬*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocIteLineCutInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocHeadTrainInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*ͨIVOCԶδռ߼Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocFarNoOccuLogInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocIteLineCutInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*ͨIVOCгλüල״̬*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocPosMonitorInfo(cszCiToIvocDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocFarNoOccuLogInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + /*ɹ*/ + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC: %d PackCiToIvocPosMonitorInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*Ԥ10ֽ*/ + ii += 10U; + } + else if ((IVOC_CI_INFO_TYPE_LOGOUT_ASK == pstVobcToCiDataStru->appInfoType) && (curCycleNum == pstVobcToCiDataStru->ComStartCycle)) + {/*עظ֡*/ + ShortToChar(CI_IVOC_INFO_TYPE_LOGOUT_ACK, &cszCiToIvocDataBuf[wAppInfoIndex]);/*עظֽ֡ͣ*/ + + if (IVOC_CI_LOGOUT_NORMAL == pstVobcToCiDataStru->chLogOutState) + { + chFunRtn = IsPointManaged(pstVobcToCiDataStru->wTrainMaxSafeHeadLink, pstVobcToCiDataStru->dwTrainMaxSafeHeadOffset); + chFunRtn &= IsPointManaged(pstVobcToCiDataStru->wTrainMinSafeTailLink, pstVobcToCiDataStru->dwTrainMinSafeTailOffset); + chFunRtn &= IsPointManaged(pstVobcToCiDataStru->wTrainMinSafeHeadLink, pstVobcToCiDataStru->dwTrainMinSafeHeadOffset); + chFunRtn &= IsPointManaged(pstVobcToCiDataStru->wTrainMaxSafeTailLink, pstVobcToCiDataStru->dwTrainMaxSafeTailOffset); + if (CI_ERROR == chFunRtn) + { + cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_FAILURE; + } + else + { + cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_SUCCESS; + } + } + else if(IVOC_CI_LOGOUT_SLEEP == pstVobcToCiDataStru->chLogOutState) + { + chSwState = GetTrainSleepState(pstVobcToCiDataStru->VobcId); + if (TRAIN_SLEEP_YES == chSwState) + { + cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_SUCCESS; + } + else + { + cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_FAILURE; + debug_infor_printf((const)"Train:%x Sleep error sw:%d hl:%d hl:%d tl:%d tl:%d\n", pstVobcToCiDataStru->VobcId, \ + chSwState, pstVobcToCiDataStru->wTrainMaxSafeHeadLink, pstVobcToCiDataStru->wTrainMinSafeHeadLink, \ + pstVobcToCiDataStru->wTrainMaxSafeTailLink, pstVobcToCiDataStru->wTrainMinSafeTailLink); + } + } + else + { + cszCiToIvocDataBuf[ii++] = IVOC_LOG_OUT_FAILURE; + } + + /*ӦòϢ*/ + } + else + { + /*Ϣʹʲô*/ + } + + if (CI_SUCCESS == chRetVal) + { + if (CI_IVOC_PACKET_LENGTH_MAX > ii) + { + ; /*ִ*/ + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\nPack vobc %d PackCiToIvoc_PACKETLEN_ Error, len: %d \n", pstVobcToCiDataStru->VobcId, ii); + } + } + + if (CI_SUCCESS == chRetVal) + { + /*Ӧòݵıij */ + cszCiToIvocDataBuf[31U] = (UINT8)((UINT8)((ii - 33u) >> 8u) & 0xffu); + cszCiToIvocDataBuf[32U] = (UINT8)((ii - 33u) & 0xffu); + + /*ͨñͷӦò㱨ܳ*/ + cszCiToIvocDataBuf[29U] = (UINT8)((UINT8)((ii - 31U) >> 8U) & 0xffU); + cszCiToIvocDataBuf[30U] = (UINT8)((ii - 31U) & 0xffU); + + dstDevId = ((UINT16)(CI_SYSTEM_TYPE_VOBC << 8U) | pstVobcToCiDataStru->VobcId); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, (pstVobcToCiDataStru->vobcLogId), &cszCiToIvocDataBuf[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nVOBC_SEND:%d", ii); + debug_out_array(0xAA, cszCiToIvocDataBuf, ii); +#endif/*ƽ̨ӡ*/ +#endif + chRetVal = CI_SUCCESS; + } + else + { + /*дʧ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\nWrite VOBC %d dataQueue Error Len = %d\n", pstVobcToCiDataStru->VobcId, ii); + } + + + if (CI_ERROR == chRetVal) + { + SetErrorData(EFUNC_PACK_CI2VOBC_DATA, CI_DEVICE_TYPE_COMM_VOBC, pstVobcToCiDataStru->VobcId, ETYPE_COMM_WITH_VOBC, 0, ESEND_LEVEL_ZERO); + } + + } + } + + return chRetVal; +} + +/* +* 鳵ͨIvoc +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* VobcBackUpToCiDataStruct *pstVobcBackUpToCiDataStru VobcͨϢṹ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +static UINT8 PackCiToIvocBackUpDataCC(VobcBackUpToCiDataStruct *pstVobcBackUpToCiDataStru) +{ + UINT8 cszCiToIvocDataBuf[VOBC_TO_CI_DATA_LEN_MAX] = { 0u };/*CIVOBC֡*/ + UINT16 ii = 0u; + UINT8 psdIndex = 0U; /*PSD*/ + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 appCycleTime = GetSystemParaAppCycleTime(); + UINT8 chRetVal = CI_ERROR; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT32 ciEtcsId = 0u; + UINT32 vobcEtcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT8 localhlhtId = 0u; + UINT8 vobcHlhtId = 0u; + UINT8 ciEmapCheckVer = 0u; + UINT16 wAppInfoIndex = 0U; + UINT16 dstDevId = 0u; + UINT8 outnetSafeSendRtn = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT8 chSwState = 0u; + /*ȻȡʱϢȡɹбҪ*/ + + if (NULL != pstVobcBackUpToCiDataStru) + { + localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCiId, 0U, &ciEtcsId); + vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(pstVobcBackUpToCiDataStru->VobcId), pstVobcBackUpToCiDataStru->vobcLogId, &vobcEtcsId); + ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC); + } + else + { + ; + } + + if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer)) + { + chRetVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"\nPack vobc %d data check error", pstVobcBackUpToCiDataStru->VobcId); + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + ii = 0u; + /*ʼӦ֡*/ + + ShortToChar(IVOC_CI_BACKUP_INTERFACE_INFOTYPE, &cszCiToIvocDataBuf[ii]);/*ӿϢ*/ + ii += 2u; + LongToChar(ciEtcsId, &cszCiToIvocDataBuf[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(vobcEtcsId, &cszCiToIvocDataBuf[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(emapCheckVer, &cszCiToIvocDataBuf[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &cszCiToIvocDataBuf[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &cszCiToIvocDataBuf[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(pstVobcBackUpToCiDataStru->VobcId)), &cszCiToIvocDataBuf[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC_BACKUP, (UINT8)(pstVobcBackUpToCiDataStru->VobcId)), &cszCiToIvocDataBuf[ii]);/*յһϢʱк*/ + ii += 4u; + cszCiToIvocDataBuf[ii++] = CI_VOBC_BACKUP_PRTCL_VER;/*CI_VOBCͨӿЭ汾*/ + ii += 2u;/*ͨñͷеӦò㱨ܳ*/ + + /*ΪӦò*/ + ii += 2u;/*ij*/ + + wAppInfoIndex = ii; + ii += 2u;/*Ӧñ*/ + + ii += 2u;/*Ԥֽ*/ + + if (IVOC_CI_BACKUPINFO_TYPE_CONTROL == pstVobcBackUpToCiDataStru->appInfoType) + { + ShortToChar(CI_IVOC_BACKUPINFO_TYPE_STATE, &cszCiToIvocDataBuf[wAppInfoIndex]); + + /*鱸ͨ߼Ϣ*/ + chRetVal = PackCiToIvocBackUpLogSecInfo(cszCiToIvocDataBuf, &ii,pstVobcBackUpToCiDataStru->VobcId); + + if (CI_SUCCESS == chRetVal) + { + /*鱸ͨĽ·Ϣ*/ + chRetVal = PackCiToIvocBackUpRouteInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpLogSecInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + /*鱸ͨ۷߼Ϣ*/ + chRetVal = PackCiToIvocBackUpReturnLogInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpRouteInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + /*鱸ͨPSDϢ*/ + chRetVal = PackCiToIvocBackUpPsdInfo(cszCiToIvocDataBuf, &ii,pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpReturnLogInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨѼSPKSϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpSpksInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpPsdInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨESBϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpEsbInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpSpksInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpSwitchInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpEsbInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨı״̬Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpProtectLgcInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpSwitchInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨTSRϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpTsrInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpProtectLgcInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨ״̬ȷϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpReqStateInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpTsrInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨķϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpFloodInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpReqStateInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨźŻ״̬Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToVobcSigInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocBackUpFloodInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨǰλϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocHeadTrainInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToVobcSigInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨITEȫгϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocIteLineCutInfo(cszCiToIvocDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocHeadTrainInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*鱸ͨԶδռ߼Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocFarNoOccuLogInfo(cszCiToIvocDataBuf, &ii, pstVobcBackUpToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocIteLineCutInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + + if (CI_SUCCESS == chRetVal) + { + /*ɹ*/ + } + else + { + /**/ + debug_infor_printf((const)"\n VOBC_BACKUP: %d PackCiToIvocFarNoOccuLogInfo Error \n", pstVobcBackUpToCiDataStru->VobcId); + } + + /*Ԥ10ֽ*/ + ii += 8U; + } + else + { + /*Ϣʹʲô*/ + } + + if (CI_SUCCESS == chRetVal) + { + if (CI_IVOC_PACKET_LENGTH_MAX > ii) + { + ; /*ִ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + + if (CI_SUCCESS == chRetVal) + { + /*Ӧòݵıij */ + cszCiToIvocDataBuf[31U] = (UINT8)((UINT8)((ii - 33u) >> 8u) & 0xffu); + cszCiToIvocDataBuf[32U] = (UINT8)((ii - 33u) & 0xffu); + + /*ͨñͷӦò㱨ܳ*/ + cszCiToIvocDataBuf[29U] = (UINT8)((UINT8)((ii - 31U) >> 8U) & 0xffU); + cszCiToIvocDataBuf[30U] = (UINT8)((ii - 31U) & 0xffU); + + dstDevId = ((UINT16)(CI_SYSTEM_TYPE_VOBC_BACKUP << 8U) | pstVobcBackUpToCiDataStru->VobcId); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, (pstVobcBackUpToCiDataStru->vobcLogId), &cszCiToIvocDataBuf[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nVOBC_BACKUP_SEND:%d", ii); + debug_out_array(0xAA, cszCiToIvocDataBuf, ii); +#endif/*ƽ̨ӡ*/ +#endif + chRetVal = CI_SUCCESS; + } + else + { + /*дʧ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\nWrite VOBC_BACKUP %d dataQueue Error Len = %d\n", pstVobcBackUpToCiDataStru->VobcId, ii); + } + + + if (CI_ERROR == chRetVal) + { + SetErrorData(EFUNC_PACK_CI2VOBC_DATA, CI_DEVICE_TYPE_COMM_VOBC, pstVobcBackUpToCiDataStru->VobcId, ETYPE_COMM_WITH_VOBC, 0, ESEND_LEVEL_ZERO); + } + + } + } + + return chRetVal; +} +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocSwitchInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT8 chSwStat = 0U; + UINT16 wSwId = 0U; + UINT16 wSwIndex = 0U; + UINT16 wSwitchSum = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wSwitchSum = GetSwitchCurSum(); + if (SWITCH_SUM_MAX > wSwitchSum) + { + ShortToChar(wSwitchSum, &pDataBuf[ii]); + ii += 2U; + for (wSwIndex = 0U; wSwIndex < wSwitchSum; wSwIndex++) + { + wSwId = GetSwitchId(wSwIndex); + if ((0U < wSwId) && (UINT16_MAX > wSwId)) + { + ShortToChar(wSwId, &pDataBuf[ii]); + ii += 2U; + chSwStat = GetSwitchCurPosition(wSwId); + switch (chSwStat) + { + case SWITCH_POSITION_DINGWEI: + pDataBuf[ii] = CI_IVOC_SWITCH_POSTION_DING; + break; + case SWITCH_POSITION_FANWEI: + pDataBuf[ii] = CI_IVOC_SWITCH_POSTION_FAN; + break; + case SWITCH_POSITION_JICHA: + case SWITCH_POSITION_MOVE: + case SWITCH_POSITION_SIKAI: + case SWITCH_POSITION_INVALID: + pDataBuf[ii] = CI_IVOC_SWITCH_POSTION_SHIBIAO; + break; + default: + /*״ֹ̬ͣ*/ + chRetVal = CI_ERROR; + break; + + } + /*1*/ + ii++; + } + else + { + /*״ֹ̬ͣ*/ + chRetVal = CI_ERROR; + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /* ֹͣ*/ + chRetVal = CI_ERROR; + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocPsdInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + + UINT8 chPsdTmpStat = 0U; + UINT8 chPsdDoorStat = 0U; + UINT8 chPsdMutualLockStat = 0U; + UINT16 wPsdId = 0U; + UINT16 wPsdIndex = 0U; + UINT16 wPsdSum = 0U; + UINT16 ii = 0U; + UINT16 psdDepartureButtonRelayId = 0U; + UINT8 platDepartButtState = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 psdButtonPangluState = 0U; + UINT8 gapDetStatus=0U; + UINT8 gapDetMutualLockRemvSta=0U; + UINT32 psdStartDetCycNum=0U; + UINT8 chTimeState = 0U; + UINT8 chCleFarePcbState = 0U;/*ȷPCBť״̬*/ + UINT32 dwPsdButPreTimeCount = 0U;/*վ̨ťʧЧʱ*/ + UINT32 dwPslPcbPreCyc = 0U;/*PSLſPCBť*/ + UINT32 dwCleFarePcbPreCyc = 0U;/*ȷPCBť*/ + UINT8 chPslPcbTimeCheck = 0U;/*PSLſPCBťʱ*/ + UINT8 chCleFarePcbTimeCheck = 0U;/*ȷPCBťʱ*/ + UINT32 dwPobPreCyc = 0U; /*POBť*/ + UINT32 dwPobButPreTimeCount = 0U;/*վ̨ťʧЧʱ*/ + UINT8 chPobTimeCheck = 0U; /*POBťʱ*/ + UINT8 psdLockRemoveState = 0U;/*Żť̵״̬*/ + UINT16 psdMutualLockRelayId = 0U; /*ť̵ID*/ + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wPsdSum = GetPsdSum(); + if (PSD_SUM_MAX > wPsdSum) + { + pDataBuf[ii] = (UINT8)wPsdSum; + ii += 1U; + for (wPsdIndex = 0U; wPsdIndex < wPsdSum; wPsdIndex++) + { + wPsdId = GetPsdId(wPsdIndex); + if ((0U < wPsdId) && (UINT16_MAX > wPsdId)) + { + ShortToChar(wPsdId, &pDataBuf[ii]); + ii += 2U; + chPsdDoorStat = GetPsdState(wPsdId); + chPsdMutualLockStat = GetPsdMutualLockRemoveState(wPsdId); + psdButtonPangluState = GetPsdButtonPangluState(wPsdId); + /*Źػѻ͹*/ + if ((PSD_STATE_CLOSE == chPsdDoorStat) || (PSD_MUTUALLOCK_REMOVE_YES== chPsdMutualLockStat)) + { + pDataBuf[ii] = CI_IVOC_PSD_STATE_CLOSE; + } + else if(PSD_STATE_OPEN==chPsdDoorStat) + { + + pDataBuf[ii] = CI_IVOC_PSD_STATE_OPEN; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\nPackCiToIvocPsdInfo PsdDoorState_Error, state: %d \n", chPsdDoorStat); + } + ii++; + + if (CI_SUCCESS == chRetVal) + { + chPsdTmpStat = GetPsdButtonState(wPsdId); + chCleFarePcbState = GetCleFarePCBButtonState(wPsdId); + if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) + { + pDataBuf[ii] = CI_IVOC_PSD_PCB_PL; /*վ̨Űť·ֵ*/ + } + else + { + dwPsdButPreTimeCount = GetPsdButtonPressCount(); + dwPslPcbPreCyc = GetPCBPressCycNum(wPsdId); + dwCleFarePcbPreCyc = GetCleFarePCBPressCycNum(wPsdId); + chPslPcbTimeCheck = SystemOverTimeCheck(dwPslPcbPreCyc, dwPsdButPreTimeCount); + chCleFarePcbTimeCheck = SystemOverTimeCheck(dwCleFarePcbPreCyc, dwPsdButPreTimeCount); + if ((CI_TIME_OUT == chPslPcbTimeCheck) || (CI_TIME_OUT == chCleFarePcbTimeCheck)) + {/*cgh޸ijɶ:PSLſPCBȷPCBֻҪһʱ,վ̨ťĬ״̬*/ + pDataBuf[ii] = CI_IVOC_PSD_PCB_STATE_UP; + } + else + { + if ((PSD_BUTTON_STATE_UP == chPsdTmpStat) && (QK_PSD_BUTTON_STATE_UP == chCleFarePcbState)) + {/*cgh޸ijɶPSLſPCBȷPCBδ,վ̨ťδ״̬*/ + pDataBuf[ii] = CI_IVOC_PSD_PCB_STATE_UP; + } + else if ((PSD_BUTTON_STATE_DOWN == chPsdTmpStat) || (QK_PSD_BUTTON_STATE_DOWN == chCleFarePcbState)) + {/*cgh޸ijɶPSLſPCBȷPCBֻҪһ,վ̨ťͰ״̬*/ + pDataBuf[ii] = CI_IVOC_PSD_PCB_STATE_DOWN; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\nPackCiToIvocPsdInfo PsdButtonState_Error, PSDstate: %d PCB-ButtonState: %d \n", chPsdTmpStat, chCleFarePcbState); + } + } + } + ii++; + } + + if (CI_SUCCESS == chRetVal) + { + chPsdTmpStat =GetPsdOpenButtonState (wPsdId); + if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) + { + pDataBuf[ii] = CI_IVOC_PSD_POB_PL; /*վ̨ŰťĬֵ*/ + } + else + { + dwPobPreCyc = GetPOBPressCycNum(wPsdId); + dwPobButPreTimeCount = GetPsdButtonPressCount(); + chPobTimeCheck = SystemOverTimeCheck(dwPobPreCyc, dwPobButPreTimeCount); + if (CI_TIME_OUT == chPobTimeCheck) + { + /*POBťʱδ״̬*/ + pDataBuf[ii] = CI_IVOC_PSD_POB_STATE_INVALID; + } + else + { + if (PSD_OPEN_BUTTON_STATE_INVALID == chPsdTmpStat) + { + pDataBuf[ii] = CI_IVOC_PSD_POB_STATE_INVALID;/*δ*/ + } + else if (PSD_OPEN_BUTTON_STATE_VALID == chPsdTmpStat) + { + pDataBuf[ii] = CI_IVOC_PSD_POB_STATE_VALID;/**/ + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\nPackCiToIvocPsdInfo PsdOpenButtonState_Error, state: %d \n", chPsdTmpStat); + } + } + } + ii++; + } + + if (CI_SUCCESS == chRetVal) + { + psdDepartureButtonRelayId = GetPsdDeparConfmRelayId(wPsdId); + /*ŷť״̬*/ + if ((0u != psdDepartureButtonRelayId) && (UINT16_MAX != psdDepartureButtonRelayId)) + {/*վ̨ť̵IDЧ*/ + if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) + { + pDataBuf[ii] = CI_IVOC_PSD_PDB_PL; /*վ̨ŰťĬֵ*/ + } + else + { + platDepartButtState = GetPsdDepartButtonState(wPsdId);/*վ̨ť״̬*/ + chTimeState = SystemOverTimeCheck(GetPSBPressCycNum(wPsdId), GetPsdButtonPressCount()); + if (CI_TIME_OUT == chTimeState) + { + pDataBuf[ii] = CI_IVOC_PSD_PDB_STATE_INVALID; + } + else + { + pDataBuf[ii] = platDepartButtState; + } + } + } + else + {/*վ̨ťVOBCվ̨޷ť״̬*/ + pDataBuf[ii] = CI_IVOC_PSD_PDB_NO_BUTTON; + } + ii++; + } + + if (CI_SUCCESS == chRetVal) + { + gapDetStatus = GetPsdRemoraState(wPsdId); /*ȡ϶̽״̬*/ + gapDetMutualLockRemvSta = GetJXTCMutualLockState(wPsdId); /*ȡ϶̽⻥״̬*/ + psdStartDetCycNum = GetStartDetectionCycNum(wPsdId); /*ȡ϶̽ʼ*/ + + if (((PSD_REMORA_NO == gapDetStatus) && (0u != psdStartDetCycNum)) + || (JXTC_MUTUALLOCK_REMOVE_YES == gapDetMutualLockRemvSta)) + {/*ϰ϶̽⻥*/ + pDataBuf[ii++] = CI_IVOC_GAP_DETECT_STATUS_CLEAR; /*ϰ*/ + } + else if ((PSD_REMORA_YES == gapDetStatus) && (0u != psdStartDetCycNum)) + {/*Ϊϰ*/ + pDataBuf[ii++] = CI_IVOC_GAP_DETECT_STATUS_UNCLEAR; /*ϰ*/ + } + else + {/*Ĭֵ*/ + pDataBuf[ii++] = CI_IVOC_GAP_DETECT_STATUS_DEFAULT; /*϶̽״̬Ĭֵδ/޴˹*/ + } + } + + /*Żť״̬*/ + if (CI_SUCCESS == chRetVal) + { + psdMutualLockRelayId = GetPsdMutualLockRelayId(wPsdId); + psdLockRemoveState = GetRelayCollState(psdMutualLockRelayId); + + /*̵𡪡ť*/ + if (RELAY_STATE_UP == psdLockRemoveState) + { + pDataBuf[ii++] = PSD_MUTUALLOCK_STATE_DOWN; + } + /*̵¡ťδ*/ + else if (RELAY_STATE_DOWN == psdLockRemoveState) + { + pDataBuf[ii++] = PSD_MUTUALLOCK_STATE_UP; + } + else + { + /*Ĭֵ*/ + pDataBuf[ii++] = PSD_MUTUALLOCK_STATE_DEFAULT; + } + } + + } + else + { + /*IDֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\nPackCiToIvocPsdInfo PsdID_Error, ID : %d \n", wPsdId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /*ŵǰ ֹͣ*/ + chRetVal = CI_ERROR; + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + + +/* +* CiIvocť״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocEsbInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT8 chEsbStat = 0U; /*¼״̬*/ + UINT16 wEsbId = 0U; /*ID*/ + UINT16 wEsbIndex = 0U; + UINT16 wEsbSum = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chEsbCutState = 0U; + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wEsbSum =GetEsbSum(); + if (ESB_SUM_MAX > wEsbSum) + { + pDataBuf[ii] = (UINT8)wEsbSum; + ii += 1U; + for (wEsbIndex = 0U; wEsbIndex < wEsbSum; wEsbIndex++) + { + wEsbId = GetEsbId(wEsbIndex); + if ((0U < wEsbId) && (UINT16_MAX > wEsbId)) + { + ShortToChar(wEsbId, &pDataBuf[ii]); + ii += 2u; + chEsbStat = GetEsbState(wEsbId); + chEsbCutState = GetEsbCutState(wEsbId); + + if (ESB_CUT_YES == chEsbCutState) + { + pDataBuf[ii++] = CI_IVOC_ESB_STATE_INVALID; + } + else if (ESB_CUT_NO == chEsbCutState) + { + if (ESB_STATE_VALID_NO == chEsbStat) + { + pDataBuf[ii++] = CI_IVOC_ESB_STATE_INVALID; + } + else if (ESB_STATE_VALID_YES == chEsbStat) + { + pDataBuf[ii++] = CI_IVOC_ESB_STATE_VALID; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocEsbInfo EsbState_Error, state: %d \n", chEsbStat); + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocEsbInfo chEsbCutState_Error, state: %d \n", chEsbCutState); + } + } + else + { + /*ͣIDֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocEsbInfo ESDID_Error, ID : %d \n", wEsbId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /*ͣǰ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocEsbInfo EsbSum_Error, sum: %d ; MAX: %d \n", wEsbSum, ESB_SUM_MAX); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvoc۷ť״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocARInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT8 chNonRelayStat = 0U; /*¼״̬*/ + UINT16 nonRetrunId = 0U; /*ID*/ + UINT16 nonReturunIndex = 0U; + UINT16 nonReturnSum = 0U; + UINT16 nonReturnRelayId = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 relaySum = 0u; + UINT16* relayIdBuf; + UINT8 virtualZDZFDevType = 0U; + UINT8 virtualZDZFButtonState = 0U; + UINT8 chNonRtnAdhesionState = 0U;/*۷ťճ״̬*/ + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + nonReturnSum = GetNonAutoReturnCurSum(); + if (NON_AUTO_RETURN_SUM_MAX >nonReturnSum ) + { + pDataBuf[ii] = (UINT8)nonReturnSum; + ii += 1U; + for (nonReturunIndex = 0U; nonReturunIndex < nonReturnSum; nonReturunIndex++) + { + /*ȡID*/ + nonRetrunId =GetNonReturnId (nonReturunIndex); + if ((0U < nonRetrunId) && (UINT16_MAX > nonRetrunId)) + { + /*۷ID*/ + ShortToChar(nonRetrunId, &pDataBuf[ii]); + ii += 2u; + /*ȡ۷ָʾID*/ + nonReturnRelayId = GetNonRtnRlyId(nonRetrunId); + virtualZDZFDevType = GetVirtualZDZFDevType(); + virtualZDZFButtonState = GetVirtualZDZFButtonState(); + + /*۷ťΪ豸*/ + if (CI_DEVICE_TYPE_AUTORETURN == virtualZDZFDevType) + { + if (VIRTUAL_ZDZFAJ_BUTTON_YES == virtualZDZFButtonState) + {/*豸۷ť*/ + pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_VALID; + } + else if (VIRTUAL_ZDZFAJ_BUTTON_NO == virtualZDZFButtonState) + { + pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_INVALID; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocARInfo NonReturn_Virtual_Error, state : %d \n", chNonRelayStat); + } + } + else + { + /*ʵ۷۷*/ + relaySum = GetIndicatorRelaySum(nonReturnRelayId); + relayIdBuf = GetIndicatorRelayIdBuf(nonReturnRelayId); + + /*۷ť̵״̬*/ + chNonRelayStat = GetRelayCollState(relayIdBuf[2]); + if (RELAY_STATE_UP == chNonRelayStat) + { + chNonRtnAdhesionState = GetNonRtnAdhesionState(nonRetrunId); + if (RTN_RELAY_ADHESION_NO == chNonRtnAdhesionState) + { + /*̵ճť*/ + pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_VALID; + } + else + { + /*ճ*/ + pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_INVALID; + } + } + else if (RELAY_STATE_DOWN == chNonRelayStat) + { + pDataBuf[ii] = CI_IVOC_NON_RETURN_STATE_INVALID; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocARInfo NonReturn_RelayState_Error, state : %d \n", chNonRelayStat); + } + + } + /*1*/ + ii++; + } + else + { + /*״ֹ̬ͣ*/ + chRetVal = CI_ERROR; + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /*ǰ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocARInfo nonReturnSum_Error, id : %d \n", nonReturnSum); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} +/* +* CiIvocSpks״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocSpksInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT8 chSpksStat = 0U; /*¼״̬*/ + UINT16 wSpksId = 0U; /*ID*/ + UINT16 wSpksIndex = 0U; + UINT16 wSpksSum = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chSpksCutState = 0U; + UINT8 checkflag = 0U; /*SPKSǷ*/ + UINT16 spksSendIndext = 0U; + UINT16 wSPKSSendSum = 0U; + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wSpksSum = GetTotalSpksCurNum();/*ڵSPKS_SUM_MAX0*/ + spksSendIndext = ii; + wSPKSSendSum = 0U; + + ii += 2U; + for (wSpksIndex = 0U; wSpksIndex < wSpksSum; wSpksIndex++) + { + wSpksId = GetSpksIdByIndex(wSpksIndex); + if ((0U < wSpksId) && (UINT16_MAX > wSpksId)) + { + /*ӼSPKSҪ*/ + checkflag = CheckSpksRelSecBelongCI(wSpksId); + + /**/ + if (CI_SUCCESS == checkflag) + { + /*SPKSϢ*/ + } + /**/ + else if (CI_ERROR == checkflag) + { + ShortToChar(wSpksId, &pDataBuf[ii]); + ii += 2u; + chSpksStat = GetSpksState(wSpksId); + chSpksCutState = GetSpksCutState(wSpksId); + if (((SPKS_STATUS_YES == chSpksStat) || (SPKS_STATUS_NO == chSpksStat)) + && ((SPKS_CUT_NO == chSpksCutState) || (SPKS_CUT_YES == chSpksCutState))) + { + + if ((SPKS_STATUS_YES == chSpksStat) && (SPKS_CUT_NO == chSpksCutState)) + { + /*ڷδ·SPKSЧ*/ + pDataBuf[ii] = CI_IVOC_SPKS_STATE_VALID; + } + else + { + pDataBuf[ii] = CI_IVOC_SPKS_STATE_INVALID; + } + /*1*/ + ii++; + wSPKSSendSum++; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSpksInfo SpksState_Error, SpksState : %d SpksCutState : %d \n", chSpksStat, chSpksCutState); + } + } + else + { + /*󣬷ʧ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSpksInfo SpksRelSecBelongCI_Error \n"); + } + } + else + { + /*spksIDֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSpksInfo Spksid_Error, id : %d \n", wSpksId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + + /*SPKS*/ + ShortToChar(wSPKSSendSum, &pDataBuf[spksSendIndext]); + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocGaragedoorInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT8 chGaragedoorStat = 0U; /*¼״̬*/ + UINT16 wGaragedoorId = 0U; /*ID*/ + UINT16 wGaragedoorIndex = 0U; + UINT16 wGaragedoorSum = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wGaragedoorSum = GetGaragedoorSum(); + if (GARAGE_DOOR_SUM_MAX > wGaragedoorSum) + { + pDataBuf[ii] = (UINT8)wGaragedoorSum; + ii += 1U; + for (wGaragedoorIndex = 0U; wGaragedoorIndex < wGaragedoorSum; wGaragedoorIndex++) + { + wGaragedoorId = GetGaragedoorId(wGaragedoorIndex); + if ((0U < wGaragedoorId) && (UINT16_MAX > wGaragedoorId)) + { + ShortToChar(wGaragedoorId, &pDataBuf[ii]); + ii += 2u; + chGaragedoorStat = GetGaragedoorState(wGaragedoorId); + if (GARAGE_DOOR_STATE_OPEN == chGaragedoorStat) + { + pDataBuf[ii] = CI_IVOC_GARAGEDR_STATE_VALID; + } + else + { + /*ȫ࣬ȫΪţڹŹ*/ + pDataBuf[ii] = CI_IVOC_GARAGEDR_STATE_INVALID; + } + /*1*/ + ii++; + } + else + { + /*IDֹͣ*/ + chRetVal = CI_ERROR; + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /*ŵǰ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocGaragedoorInfo GaragedoorSum_Error, sum : %d MAX: %d \n", wGaragedoorSum, GARAGE_DOOR_SUM_MAX); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvoc״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId, гID +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocFloodGateInfo(UINT8* pDataBuf, UINT16 *wDataLength, UINT16 wTrainId) +{ + UINT16 wFloodGateId = 0U; /*ID*/ + UINT16 wFloodGateIndex = 0U; + UINT16 wFloodGateSum = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chRet = CI_ERROR; + UINT8 floodOpenState = 0U; /*Ϣ*/ + UINT8 floodCloseReq = 0U; /*Ϣ*/ + UINT8 floodCloseReqTempSta = 0U; + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wFloodGateSum = GetTotalFloodGateCurSum(); + if (FLOOD_GATE_SUM_MAX > wFloodGateSum) + { + pDataBuf[ii] = (UINT8)wFloodGateSum; + ii += 1U; + for (wFloodGateIndex = 0U; wFloodGateIndex < wFloodGateSum; wFloodGateIndex++) + { + wFloodGateId = GetFloodGateId(wFloodGateIndex); + if ((0U < wFloodGateId) && (UINT16_MAX > wFloodGateId)) + { + ShortToChar(wFloodGateId, &pDataBuf[ii]); + ii += 2u; + floodOpenState = GetFloodGateCurOpenLockState(wFloodGateId); + if (FLOOD_GATE_OPENLOCK == floodOpenState) + { + pDataBuf[ii] = CI_IVOC_FLOODGATE_OPEN_LOCK; + } + else + { + pDataBuf[ii] = CI_IVOC_FLOODGATE_OPEN_LOCK_NO; + } + /*1*/ + ii++; + + chRet = CheckProtectEnvelope(wFloodGateId, wTrainId); + if (CI_SUCCESS == chRet) + { + /*ص޹*/ + pDataBuf[ii] = CI_IVOC_FLOODGATE_CLOSE_REQ_NO; + } + else + { + /*صʵ״̬*/ + floodCloseReqTempSta = GetFloodGateCurCloseRequestSta(wFloodGateId); + if (FLOOD_GATE_CLOSEREQ == floodCloseReqTempSta) + { + pDataBuf[ii] = CI_IVOC_FLOODGATE_CLOSE_REQ; + } + else if (FLOOD_GATE_NOT_CLOSEREQ == floodCloseReqTempSta) + { + pDataBuf[ii] = CI_IVOC_FLOODGATE_CLOSE_REQ_NO; + } + else + { + chRetVal = CI_ERROR; /*Ź״̬Ƿֹͣ*/ + debug_infor_printf((const)"\n PackCiToIvocFloodGateInfo floodCloseReqState_Error, state : %d \n", floodCloseReqTempSta); + } + } + + /*1*/ + ii++; + } + else + { + /*IDֹͣ*/ + chRetVal = CI_ERROR; + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /*ŵǰ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocFloodGateInfo FloodGateSum_Error, sum : %d MAX: %d \n", wFloodGateSum, FLOOD_GATE_SUM_MAX); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocFLockInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT8 chPhyFlockStat = 0U; /*¼״̬*/ + UINT16 wPhySecId = 0U; /*ID*/ + UINT16 wPhyIndex = 0U; + UINT16 wPhySum = 0U; + UINT16 wPhySendSumIndex = 0U; + UINT16 wPhySendSum = 0U; + UINT8 chStartLockStat = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 cTsrSureFlag = CI_TSR_SURE_NO;/* ȷϱ־ */ + UINT8 cSnowModel = CI_ALL_SNOW_UNVALID;/* ѩģʽ־ */ + UINT8 cAllLineTsrState = CI_ALL_LINE_TSR_UNVALID;/* ȫʱ */ + UINT8 cAllLineTsrSpeed = 0U;/* ѩģʽ־ */ + UINT8 chSecFLockType = 0U;/*η*/ + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + chStartLockStat = GetStartFLockFlag(); + + /*ϵ״̬*/ + if (CI_START_LOCK_NO == chStartLockStat) + { + pDataBuf[ii] = CI_IVOC_ALLLINE_FLOCK_NO; + } + else + { + pDataBuf[ii] = CI_IVOC_ALLLINE_FLOCK; + } + ii++; + + /* ȷϱ־λ */ + cTsrSureFlag = GetTsrSureFlag(); + if (CI_TSR_SURE_YES == cTsrSureFlag) + { + /* ȷ */ + pDataBuf[ii] = cTsrSureFlag; + } + else + { + /* δȷ */ + pDataBuf[ii] = CI_TSR_SURE_NO; + } + ii += 1U; + + /* ѩģʽ */ + cSnowModel = GetAllSnowModel(); + if (CI_ALL_SNOW_VALID == cSnowModel) + { + /* ѩ */ + pDataBuf[ii] = CI_ALL_SNOW_VALID; + } + else + { + /* ѩ */ + pDataBuf[ii] = CI_ALL_SNOW_UNVALID; + } + ii += 1U; + + /* ȫʱϢ */ + cAllLineTsrState = GetAllLineTsrState(); + cAllLineTsrSpeed = GetAllLineTsrSpeed(); + if (CI_ALL_LINE_TSR_VALID == cAllLineTsrState) + { + /* ȫʱ */ + pDataBuf[ii] = CI_ALL_LINE_TSR_VALID; + ii += 1U; + pDataBuf[ii] = cAllLineTsrSpeed; + ii += 1U; + + } + else + { + pDataBuf[ii] = CI_ALL_LINE_TSR_UNVALID; + ii += 1U; + pDataBuf[ii] = 0u; + ii += 1U; + } + + wPhySum = GetPhySecCurSum(); + if (PHYSICAL_SECTION_SUM_MAX > wPhySum) + { + wPhySendSumIndex = ii; + ii += 2U; + for (wPhyIndex = 0U; wPhyIndex < wPhySum; wPhyIndex++) + { + wPhySecId =GetPhySecId (wPhyIndex); + if ((0U < wPhySecId) && (UINT16_MAX > wPhySecId)) + { + chPhyFlockStat =GetPhySecFLockState (wPhySecId); + chSecFLockType = GetPhySecFLockType(wPhySecId); + if ((PHYSICAL_SECTION_FLOCK_NO != chPhyFlockStat) && (PHY_SEC_FLOCK_TYPE_SPKS != chSecFLockType)) + { + /*δ˹ŷ*/ + ShortToChar(wPhySecId,&pDataBuf[ii]); + ii += 2U; + wPhySendSum++; + } + else + { + /*ִ*/ + } + } + else + { + /*IDֹͣ*/ + chRetVal = CI_ERROR; + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + ShortToChar(wPhySendSum, &pDataBuf[wPhySendSumIndex]); + } + else + { + /*εǰ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocFLockInfo PhySum_Error, sum : %d MAX: %d \n", wPhySum, PHYSICAL_SECTION_SUM_MAX); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocͨų״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocCommTrainInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT16 wTmpLinkId = 0U; + UINT32 dwTmpOff = 0U; + UINT16 wOrgnLinkId = 0u; + UINT32 dwOrgnOffset = 0u; + UINT8 chTrainDir = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chHeadScreStat=0u; /*гǰɸ־*/ + UINT8 chTailScreStat=0u; /*гɸ־*/ + UINT16 szEnvelopeIdBuf[ENVELOPE_SUM_MAX] = { 0u }; + UINT16 wEnvelopeSum = 0u; + UINT16 wEnvelopeIndex = 0u; + UINT16 wEnvelopeId = 0u; + UINT16 wEnvelopeSendSum = 0u; + UINT8 chFunRtn = CI_ERROR; + InfEnvelopeStruct strEnvelope = { 0u }; + UINT16 wEnvelopeSendSumIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chLinkLogicDirUpAndDown = 0u; + UINT8 chTrainVirHeadScreenFlag = 0U;/*ǰɸ־*/ + UINT8 chTrainVirTailScreenFlag = 0U;/*ɸ־*/ + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wEnvelopeSum = elm_GetCTEnvelope(szEnvelopeIdBuf); + if (ENVELOPE_SUM_MAX > wEnvelopeSum) + { + wEnvelopeSendSumIndex = ii; + ii += 1U; + for (wEnvelopeIndex = 0U; wEnvelopeIndex < wEnvelopeSum; wEnvelopeIndex++) + { + wEnvelopeId = szEnvelopeIdBuf[wEnvelopeIndex]; + chFunRtn = elm_ConvertEnvelopeInfo(wEnvelopeId, &strEnvelope); + if (CI_SUCCESS == chFunRtn) + { + wTmpLinkId = strEnvelope.endPos.Lnk; + dwTmpOff = strEnvelope.endPos.Off; + + wOrgnLinkId = strEnvelope.startPos.Lnk; + dwOrgnOffset = strEnvelope.startPos.Off; + + wEnvelopeSendSum++; + wTrainId = (0x1400u + (strEnvelope.trainID[0] & 0x00FFu)); + + pDataBuf[ii] = strEnvelope.trainID[0]; + ii += 1U; + + if ((0U != wTmpLinkId) && (UINT16_MAX != wTmpLinkId) && (UINT32_MAX != dwTmpOff)) + { + ShortToChar(wTmpLinkId, &pDataBuf[ii]); + ii += 2U; + LongToChar(dwTmpOff, &pDataBuf[ii]); + ii += 4U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo End_link&Off_Error, linkId : %d Off: %d \n", wTmpLinkId, dwTmpOff); + } + + if ((0U != wOrgnLinkId) && (UINT16_MAX != wOrgnLinkId) && (UINT32_MAX != dwOrgnOffset)) + { + ShortToChar(wOrgnLinkId, &pDataBuf[ii]); + ii += 2U; + LongToChar(dwOrgnOffset, &pDataBuf[ii]); + ii += 4U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo Start_link&Off_Error, linkId : %d Off: %d \n", wOrgnLinkId, dwOrgnOffset); + } + + chTrainDir = strEnvelope.startPos.Dir; + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + if (DIR_SAME == chTrainDir) + { + chTrainDir = ~chLinkLogicDirUpAndDown; + } + else + { + chTrainDir = chLinkLogicDirUpAndDown; + } + + if (TRAIN_DIR_UP == chTrainDir) + { + pDataBuf[ii] |= BIT_VAL_00000001B; /* 01B */ + + } + else if (TRAIN_DIR_DOWN == chTrainDir) + { + pDataBuf[ii] |= BIT_VAL_00000010B; /* 10B */ + + } + else + { + chRetVal = CI_ERROR; + } + /*ǰɸ*/ + chTrainVirHeadScreenFlag = GetTrainVirHeadScreenPassFlag(wTrainId); + if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirHeadScreenFlag) + { + chHeadScreStat = CI_IVOC_HEAD_SCREEN_PASS; + } + else + { + chHeadScreStat = strEnvelope.suspicHead; + } + + if (CI_IVOC_HEAD_SCREEN_PASS == chHeadScreStat) + { + pDataBuf[ii] |= BIT_VAL_00000001B<<2; /*ǰɸѡͨ 01B*/ + } + else if (CI_IVOC_HEAD_SCREEN_UNKNOW == chHeadScreStat) + { + pDataBuf[ii] |= BIT_VAL_00000010B << 2; /*ǰɸѡͨ 10B*/ + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo HeadScreState_Error, state : %d \n", chHeadScreStat); + } + /*ɸ*/ + chTrainVirTailScreenFlag = GetTrainVirTailScreenPassFlag(wTrainId); + if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chTrainVirTailScreenFlag) + { + chTailScreStat = CI_IVOC_TAIL_SCREEN_PASS; + } + else + { + chTailScreStat = strEnvelope.suspicTail; + } + + if (CI_IVOC_TAIL_SCREEN_PASS == chTailScreStat) + { + pDataBuf[ii] |= BIT_VAL_00000001B << 4; /*ɸѡͨ 01B*/ + } + else if (CI_IVOC_TAIL_SCREEN_UNKNOW == chTailScreStat) + { + pDataBuf[ii] |= BIT_VAL_00000010B << 4; /*ɸѡͨ 10B*/ + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo TailScreState_Error, state : %d \n", chTailScreStat); + } + ii += 1U; /*гϢһֽƫ*/ + + + pDataBuf[ii] = GetTrainReportState(wTrainId); /*״̬Ƿֱֵӷ*/ + + ii += 1U; + } + else + { + /*IDֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo EnvelopeId_Error, id : %d \n", wEnvelopeId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + pDataBuf[wEnvelopeSendSumIndex] = (UINT8)wEnvelopeSendSum; + } + else + { + /*·еİϢ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocCommTrainInfo EnvelopeSum_Error, sum : %d MAX: %d \n", wEnvelopeSum, ENVELOPE_SUM_MAX); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocϳ״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocFaultTrainInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT16 wTmpLinkId = 0U; + UINT32 dwTmpOff = 0U; + UINT16 wOrgnLinkId = 0u; + UINT32 dwOrgnOffset = 0u; + UINT8 chTrainDir = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chHeadScreStat = 0u; /*гǰɸ־*/ + UINT8 chTailScreStat = 0u; /*гɸ־*/ + UINT16 szEnvelopeIdBuf[ENVELOPE_SUM_MAX] = { 0u }; + UINT16 wEnvelopeSum = 0u; + UINT16 wEnvelopeIndex = 0u; + UINT16 wEnvelopeId = 0u; + UINT16 wEnvelopeSendSum = 0u; + UINT8 chFunRtn = CI_ERROR; + InfEnvelopeStruct strEnvelope = { 0u }; + UINT16 wEnvelopeSendSumIndex = 0u; + UINT8 chTrainIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chLocalId = 0u; + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + chLocalId = GetSystemParaLocalCiId(); + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wEnvelopeSum = elm_GetFaultEnvelope(szEnvelopeIdBuf); + if (ENVELOPE_SUM_MAX > wEnvelopeSum) + { + wEnvelopeSendSumIndex = ii; + ii += 1U; + for (wEnvelopeIndex = 0U; wEnvelopeIndex < wEnvelopeSum; wEnvelopeIndex++) + { + wEnvelopeId = szEnvelopeIdBuf[wEnvelopeIndex]; + chFunRtn = elm_ConvertEnvelopeInfo(wEnvelopeId, &strEnvelope); + if (CI_SUCCESS == chFunRtn) + { + wTmpLinkId = strEnvelope.endPos.Lnk; + dwTmpOff = strEnvelope.endPos.Off; + + wOrgnLinkId = strEnvelope.startPos.Lnk; + dwOrgnOffset = strEnvelope.startPos.Off; + + for (chTrainIndex = 0u; chTrainIndex < strEnvelope.trianCnt; chTrainIndex++) + { + wEnvelopeSendSum++; + wTrainId = 0x14ffu; + + wTmpLinkId = strEnvelope.endPos.Lnk; + dwTmpOff = strEnvelope.endPos.Off; + + if ((0U != wTmpLinkId) && (UINT16_MAX != wTmpLinkId) && (UINT32_MAX != dwTmpOff)) + { + ShortToChar(wTmpLinkId, &pDataBuf[ii]); + ii += 2U; + LongToChar(dwTmpOff, &pDataBuf[ii]); + ii += 4U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocFaultTrainInfo End_Link&Off_Error, link : %d Off: %d \n", wTmpLinkId, dwTmpOff); + } + + wTmpLinkId = strEnvelope.startPos.Lnk; + dwTmpOff = strEnvelope.startPos.Off; + + if ((0U != wTmpLinkId) && (UINT16_MAX != wTmpLinkId) && (UINT32_MAX != dwTmpOff)) + { + ShortToChar(wTmpLinkId, &pDataBuf[ii]); + ii += 2U; + LongToChar(dwTmpOff, &pDataBuf[ii]); + ii += 4U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocFaultTrainInfo Start_Link&Off_Error, link : %d Off: %d \n", wTmpLinkId, dwTmpOff); + } + } + } + else + { + /*IDֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocFaultTrainInfo EnvelopeId_Error, id : %d \n", wEnvelopeId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + pDataBuf[wEnvelopeSendSumIndex] = (UINT8)wEnvelopeSendSum; + } + else + { + /*·еİϢ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocFaultTrainInfo EnvelopeSum_Error, sum : %d MAX: %d \n", wEnvelopeSum , ENVELOPE_SUM_MAX); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvoc߳״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocSleepTrainInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT16 wTmpLinkId = 0U; + UINT32 dwTmpOff = 0U; + UINT16 wOrgnLinkId = 0u; + UINT32 dwOrgnOffset = 0u; + UINT8 chTrainDir = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chHeadScreStat = 0u; /*гǰɸ־*/ + UINT8 chTailScreStat = 0u; /*гɸ־*/ + UINT16 szEnvelopeIdBuf[ENVELOPE_SUM_MAX] = { 0u }; + UINT16 wEnvelopeSum = 0u; + UINT16 wEnvelopeIndex = 0u; + UINT16 wEnvelopeId = 0u; + UINT16 wEnvelopeSendSum = 0u; + UINT8 chFunRtn = CI_ERROR; + InfEnvelopeStruct strEnvelope = { 0u }; + UINT16 wEnvelopeSendSumIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chLinkLogicDirUpAndDown = 0u; + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wEnvelopeSum = elm_GetSleepEnvelope(szEnvelopeIdBuf); + if (ENVELOPE_SUM_MAX > wEnvelopeSum) + { + wEnvelopeSendSumIndex = ii; + ii += 1U; + for (wEnvelopeIndex = 0U; wEnvelopeIndex < wEnvelopeSum; wEnvelopeIndex++) + { + wEnvelopeId = szEnvelopeIdBuf[wEnvelopeIndex]; + chFunRtn = elm_ConvertEnvelopeInfo(wEnvelopeId, &strEnvelope); + if (CI_SUCCESS == chFunRtn) + { + wTmpLinkId = strEnvelope.endPos.Lnk; + dwTmpOff = strEnvelope.endPos.Off; + + wOrgnLinkId = strEnvelope.startPos.Lnk; + dwOrgnOffset = strEnvelope.startPos.Off; + + wEnvelopeSendSum++; + wTrainId = (0x1400u + (strEnvelope.trainID[0] & 0x00FFu)); + + pDataBuf[ii] = strEnvelope.trainID[0]; + ii += 1U; + + if ((0U != wTmpLinkId) && (UINT16_MAX != wTmpLinkId) && (UINT32_MAX != dwTmpOff)) + { + ShortToChar(wTmpLinkId, &pDataBuf[ii]); + ii += 2U; + LongToChar(dwTmpOff, &pDataBuf[ii]); + ii += 4U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo End_Link&Off_Error, link : %d Off: %d \n", wTmpLinkId, dwTmpOff); + } + + + + if ((0U != wOrgnLinkId) && (UINT16_MAX != wOrgnLinkId) && (UINT32_MAX != dwOrgnOffset)) + { + ShortToChar(wOrgnLinkId, &pDataBuf[ii]); + ii += 2U; + LongToChar(dwOrgnOffset, &pDataBuf[ii]); + ii += 4U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo Start_Link&Off_Error, link : %d Off: %d \n", wTmpLinkId, dwTmpOff); + } + + chTrainDir = GetTrainSafeTailDir(strEnvelope.trainID[0]); + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + if (DIR_SAME == chTrainDir) + { + chTrainDir = ~chLinkLogicDirUpAndDown; + } + else + { + chTrainDir = chLinkLogicDirUpAndDown; + } + + if (TRAIN_DIR_UP == chTrainDir) + { + pDataBuf[ii] |= BIT_VAL_00000001B; /* 01B */ + + } + else if (TRAIN_DIR_DOWN == chTrainDir) + { + pDataBuf[ii] |= BIT_VAL_00000010B; /* 10B */ + + } + else + { + chRetVal = CI_ERROR; + } + /*ǰɸ*/ + chHeadScreStat = strEnvelope.suspicHead; + + if (CI_IVOC_HEAD_SCREEN_PASS == chHeadScreStat) + { + pDataBuf[ii] |= BIT_VAL_00000001B << 2; /*ǰɸѡͨ 01B*/ + } + else if (CI_IVOC_HEAD_SCREEN_UNKNOW == chHeadScreStat) + { + pDataBuf[ii] |= BIT_VAL_00000010B << 2; /*ǰɸѡͨ 10B*/ + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo HeadScreState_Error, state : %d \n", chHeadScreStat); + } + /*ɸ*/ + chTailScreStat = strEnvelope.suspicTail; + if (CI_IVOC_TAIL_SCREEN_PASS == chTailScreStat) + { + pDataBuf[ii] |= BIT_VAL_00000001B << 4; /*ɸѡͨ 01B*/ + } + else if (CI_IVOC_TAIL_SCREEN_UNKNOW == chTailScreStat) + { + pDataBuf[ii] |= BIT_VAL_00000010B << 4; /*ɸѡͨ 10B*/ + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo TailScreStat_Error, state : %d \n", chTailScreStat); + } + ii += 1U; /*гϢƫһֽ*/ + } + else + { + /*IDֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo End_Link&Off_Error, link : %d Off: %d \n", wTmpLinkId, dwTmpOff); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + pDataBuf[wEnvelopeSendSumIndex] = (UINT8)wEnvelopeSendSum; + } + else + { + /*г ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocSleepTrainInfo EnvelopeSum_Error, sum : %d MAX: %d \n", wEnvelopeSum, ENVELOPE_SUM_MAX); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocʱ״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocTsrInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT8 chPhyFlockStat = 0U; /*¼״̬*/ + UINT16 wTsrId = 0U; /*ID*/ + UINT16 wTsrIndex = 0U; + UINT8 cTsrSum = 0U; + UINT16 wTmpLinkId = 0U; + UINT32 dwTmpOff = 0U; + UINT16 wTsrSpeed = 0U; + UINT16 wTsrSecSum = 0U; + UINT8 chTsrCommStat = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 jj = 0u; + UINT8 kk = 0u; + TsrDataStruct* pTsrData = NULL; + + pTsrData = GetTsrData();/*᷵NULL*/ + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + /* ȡ */ + cTsrSum = GetTsrSum(); + if (TSR_MAX_SUM >= cTsrSum) + { + /* ʱ */ + pDataBuf[ii] = cTsrSum; + ii++; + + for (jj = 0u;jj < cTsrSum;jj++) + { + /* ʱٶ */ + pDataBuf[ii] = pTsrData[jj].cSpeed; + ii++; + + /* ߼ */ + if ((0u == pTsrData[jj].cLogSecSum) || (TSR_SEC_MAX_SUM < pTsrData[jj].cLogSecSum)) + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocTsrInfo LogSecSum_Error, sum : %d MAX: %d \n", pTsrData[jj].cLogSecSum, TSR_SEC_MAX_SUM); + } + else + { + pDataBuf[ii] = pTsrData[jj].cLogSecSum; + ii++; + } + + if (CI_SUCCESS == chRetVal) + { + for (kk = 0u; kk < pTsrData[jj].cLogSecSum;kk++) + { + /* ߼ID */ + if ((0u == pTsrData[jj].szLogSecId[kk]) || (UINT16_MAX == pTsrData[jj].szLogSecId[kk])) + { + chRetVal = CI_ERROR; + } + else + { + ShortToChar(pTsrData[jj].szLogSecId[kk], &pDataBuf[ii]); + ii += 2u; + } + + if (CI_ERROR == chRetVal) + { + debug_infor_printf((const)"\n PackCiToIvocTsrInfo LogSecId_Error, ID : %d \n", pTsrData[jj].szLogSecId[kk]); + break; + } + } + } + + if (CI_ERROR == chRetVal) + { + break; + } + } + } + else + { + /*ʱ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocTsrInfo TsrSum_Error, sum : %d MAX: %d \n", cTsrSum , TSR_MAX_SUM); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +#if 0 +/* +* CiIvoc״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocAxisSgmtInfo(UINT8* pDataBuf, UINT16 *wDataLength) +{ + UINT8 chAxisSecHdStat = 0U; /*¼״̬*/ + UINT8 chAxisSecTlStat = 0U; + UINT8 chAxisSecOccStt = 0U; + UINT16 wAxisSecId = 0U; /*ID*/ + UINT16 wAxisSecIndex = 0U; + UINT16 wAxisSecSum = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wAxisSecSum = GetAxisSecCurSum(); + if (AXIS_SECTION_SUM_MAX > wAxisSecSum) + { + ShortToChar(wAxisSecSum, &pDataBuf[ii]); + ii += 2U; + for (wAxisSecIndex = 0U; wAxisSecIndex < wAxisSecSum; wAxisSecIndex++) + { + wAxisSecId = GetAxisSecId(wAxisSecIndex); + if ((0U < wAxisSecId) && (UINT16_MAX > wAxisSecId)) + { + ShortToChar(wAxisSecId, &pDataBuf[ii]); + ii += 2U; + chAxisSecHdStat = GetAxisSecHeadUtCtState(wAxisSecId); + chAxisSecTlStat = GetAxisSecTailUtCtState(wAxisSecId); + if (AXIS_SECTION_UT_STATE == chAxisSecHdStat) + { + chAxisSecOccStt = CI_IVOC_AXIS_HEAD_UT; + } + else if (AXIS_SECTION_CT_STATE == chAxisSecHdStat) + { + + chAxisSecOccStt = CI_IVOC_AXIS_HEAD_CT; + } + else + { + + } + + if (AXIS_SECTION_UT_STATE == chAxisSecTlStat) + { + chAxisSecOccStt |= CI_IVOC_AXIS_TAIL_UT; + } + else if (AXIS_SECTION_CT_STATE == chAxisSecTlStat) + { + chAxisSecOccStt |= CI_IVOC_AXIS_TAIL_CT; + } + else + { + + } + + if( (0U == chAxisSecOccStt)&&(AXIS_SECTION_FREE_STATE == chAxisSecHdStat)&&(AXIS_SECTION_FREE_STATE == chAxisSecTlStat)) + { + chAxisSecOccStt = CI_IVOC_AXIS_HEAD_TAIL_FREE; + } + else if(0U!=chAxisSecOccStt) + { + /*Ѹֵ*/ + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + } + + pDataBuf[ii] = chAxisSecOccStt; + /*1*/ + ii++; + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /*εǰ ֹͣ*/ + chRetVal = CI_ERROR; + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} +#endif + +/* +* CiIvoc߼״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocLgcSgmtInfo(UINT8* pDataBuf, UINT16 *wDataLength,UINT16 wVobcId) +{ + UINT8 chLogicSecLockDir = 0U; /*¼״̬*/ + UINT8 chLogicSendTrnFlag = 0U; /*߼ϢǷIVOC־*/ + UINT8 chLogicTrainRetrunStt = 0U; + UINT8 trainInRoute = 0U; + UINT16 wLogicSecId = 0U; /*ID*/ + UINT16 wLogicSecIndex = 0U; + UINT16 wLogicSecSum = 0U; + UINT16 wLogicSecSendIndex = 0U; + UINT16 wLogicSecSendSum = 0U; + UINT16 wRouteId = 0U; + UINT16 wPLockRouteId = 0U; + UINT16 wRLockRouteId = 0U; + UINT16 wRouteLockOverlapId = 0U; + UINT16 ii = 0U; + UINT16 wTrainSysId = 0U; + LogicTrainResStruct * pstLogicResTrainInfo = NULL; + UINT8 chRetVal = CI_ERROR; + UINT8 logSecJumpLockSta = LOGIC_SECTION_JUMP_LOCK_NO; + UINT16 logSecJumpLockTrnId = 0u; + UINT8 logSecJumpLockPermFlag = LOGIC_JUMPUNLOCK_PERMISSIVE_NO; + UINT8 chLogSecProResUseState = 0U;/*߼ηԴ״̬*/ + UINT16 wLogSecBelongPhyId = 0U;/*߼ID*/ + UINT8 chLockDirOpposedFlag = ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*շǷȡ־*/ + UINT8 cRouteType = 0U; /*·*/ + UINT8 chLogSecBelLogRouteSum = 0U;/*߼߼·Ŀ*/ + UINT16 wLogSecTrainLogRouteSum = 0U;/*߼г߼·Ŀ*/ + UINT16 wLogSecRLockRouteId = 0U;/*߼·*/ + UINT8 chRouteType = 0U;/*·*/ + UINT16 wRouteLastPhy = 0U;/*·һ*/ + UINT8 chSendFlag = 0U; + UINT16 wMinTailPointBelongLogSecId = 0U; + struct_PathPoint strTrainMinTail = { 0u }; + + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + wTrainSysId = ((UINT16)(CI_SYSTEM_TYPE_VOBC * 256U)) + (wVobcId&0x00FFU); + wLogicSecSum = GetLogicSecCurSum(); + strTrainMinTail.wLinkId = GetTrainMinTailLink(wVobcId); + strTrainMinTail.dwOffset = GetTrainMinTailOffset(wVobcId); + wMinTailPointBelongLogSecId = GetPointBelongLogSec(strTrainMinTail); + if (LOGIC_SECTION_SUM_MAX > wLogicSecSum) + { + wLogicSecSendIndex = ii; + wLogicSecSendSum = 0U; + ii += 2U; + for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++) + { + wLogicSecId = GetLogicSecId(wLogicSecIndex); + pstLogicResTrainInfo = NULL; + if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId)) + { + pstLogicResTrainInfo = GetLogSecTrainInfoById(wLogicSecId, wTrainSysId); + + trainInRoute = GetTrainInLgcPRLock(wLogicSecId, wMinTailPointBelongLogSecId); /*гڽ·*/ + + chLogicSendTrnFlag = GetLogSecTrainLockSendFlag(wLogicSecId, wTrainSysId); + wRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId); + cRouteType = GetRouteType(wRLockRouteId); + wLogSecTrainLogRouteSum = GetLogSecBelongLogRouteId(wLogicSecId, wTrainSysId); /*ȡָг߼չ·*/ + chLogSecBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogicSecId); + + if (0U == chLogSecBelLogRouteSum) + { + chLogicSecLockDir = GetLogSecLockDir(wLogicSecId); + } + else + { + /*߼߼·Ŀ0߼շȡ߼·ͨ·߼·ӱȻһµģ*/ + chLogicSecLockDir = GetLogSecLogLockDir(wLogicSecId); + } + + + if (((CI_SUCCESS == chLogicSendTrnFlag) || (CI_SUCCESS == trainInRoute) || (0U < wLogSecTrainLogRouteSum)) + && (ROUTE_TYPE_DIAOCHE != cRouteType)) + { + wLogicSecSendSum += 1U; + ShortToChar(wLogicSecId, &pDataBuf[ii]); + ii += 2U; + if ((CI_SYSTEM_DIRECTION_UP == chLogicSecLockDir) + || (CI_SYSTEM_DIRECTION_DOWN == chLogicSecLockDir)) + { + wLogSecRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId); + wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wLogicSecId); + chLockDirOpposedFlag = GetRoutePhySecShouldLockOppose(wLogSecRLockRouteId, wLogSecBelongPhyId); + + if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == chLockDirOpposedFlag) + { + chLogicSecLockDir = ~chLogicSecLockDir; + } + else + { + ; /*շҪȡ˵߼ҲҪȡ*/ + } + pDataBuf[ii] = chLogicSecLockDir; + ii += 1U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecLockDir_Error, DIR : %d \n", chLogicSecLockDir); + } + +#if 0 + if ((0U < wRLockRouteId) && (0U < wPLockRouteId)) + { + if ((ROUTE_STATE_NEAR_OPEN == chRouteState) + || (ROUTE_STATE_YUXIAN_OPEN == chRouteState)) + { + pDataBuf[ii] = CI_IVOC_LOGSEC_PRLOCK_OPEN; + } + else + { + pDataBuf[ii] = CI_IVOC_LOGSEC_PRLOCK_CLOSE; + } + } + else if (0 < wRLockRouteId) + { + pDataBuf[ii] = CI_IVOC_LOGSEC_RLOCK; + } + else if (0 < wPLockRouteId) + { + pDataBuf[ii] = CI_IVOC_LOGSEC_PLOCK; + } + else + { + chRetVal = CI_ERROR; + } + ii++; +#endif + if (NULL == pstLogicResTrainInfo) + { + + pDataBuf[ii] = LOGIC_SECTION_RES_UNUSABLE; + ii += 1U; + + } + else + { + if ((LOGIC_SECTION_RES_UNUSABLE == pstLogicResTrainInfo->chLogicResUsable) + || (LOGIC_SECTION_RES_USABLE == pstLogicResTrainInfo->chLogicResUsable)) + { + pDataBuf[ii] = pstLogicResTrainInfo->chLogicResUsable; + ii += 1U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicResUsable_Error, state : %d \n", pstLogicResTrainInfo->chLogicResUsable); + } + } + + } + else + { + /*ִУ߼*/ + } + + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecId_Error, ID : %d \n", wLogicSecId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + + ShortToChar(wLogicSecSendSum, &pDataBuf[wLogicSecSendIndex]); + + /*߼*/ + if (CI_SUCCESS == chRetVal) + { + wLogicSecSendIndex = ii; + wLogicSecSendSum = 0U; + ii += 2U; + + for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++) + { + wLogicSecId = GetLogicSecId(wLogicSecIndex); + if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId)) + { + chLogSecProResUseState = GetLogSecProResUseState(wLogicSecId); + wPLockRouteId = GetLogSecPLockRouteId(wLogicSecId); + chLogicSecLockDir = GetLogSecLockDir(wLogicSecId); + if(0U < wPLockRouteId) + { + wLogicSecSendSum++; + ShortToChar(wLogicSecId, &pDataBuf[ii]); + ii += 2U; + if ((CI_SYSTEM_DIRECTION_UP == chLogicSecLockDir) + || (CI_SYSTEM_DIRECTION_DOWN == chLogicSecLockDir)) + { + pDataBuf[ii] = chLogicSecLockDir; + ii += 1U; + } + else + { + chRetVal = CI_ERROR; + } + if ((LOGIC_SECTION_PRO_RES_USABLE == chLogSecProResUseState) + || (LOGIC_SECTION_PRO_RES_UNUSABLE == chLogSecProResUseState)) + { + pDataBuf[ii] = chLogSecProResUseState; + ii += 1U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogSecProResUseState_Error, state : %d \n", chLogSecProResUseState); + } + } + else + { + /*ִУ߼*/ + } + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecId_PRO_Error, ID : %d \n", wLogicSecId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + ShortToChar(wLogicSecSendSum, &pDataBuf[wLogicSecSendIndex]); + } + + /*۷߼*/ + if (CI_SUCCESS == chRetVal) + { + wLogicSecSendIndex = ii; + wLogicSecSendSum = 0U; + ii += 2U; + for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++) + { + wLogicSecId = GetLogicSecId(wLogicSecIndex); + if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId)) + { + chLogicSendTrnFlag = GetLogSecTrainLockSendFlag(wLogicSecId, wTrainSysId); + if (CI_SUCCESS == chLogicSendTrnFlag) + { + wLogSecRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId); + chRouteType = GetConfigRouteType(wLogSecRLockRouteId); + + /*ȡ߼ιΡ·һ*/ + wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wLogicSecId); + wRouteLastPhy = GetRouteLastPhySectionId(wLogSecRLockRouteId); + + if ((ROUTE_TYPE_RETURN == chRouteType) && (wLogSecBelongPhyId == wRouteLastPhy)) + { + chLogicTrainRetrunStt = LOGIC_SECTION_TRAIN_RETURN_YES; + } + else + { + chLogicTrainRetrunStt = LOGIC_SECTION_TRAIN_RETURN_NO; + } + if (LOGIC_SECTION_TRAIN_RETURN_YES == chLogicTrainRetrunStt) + { + /*߼ΪгԴΪ۷*/ + wLogicSecSendSum += 1U; + ShortToChar(wLogicSecId, &pDataBuf[ii]); + ii += 2U; + } + else + { + /*ִУ߼*/ + } + } + else + { + /*ִУ߼*/ + } + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecId_ZF_Error, ID : %d \n", wLogicSecId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + + /*۷߼0-100Ϸ*/ + if (100u < wLogicSecSendSum) + {/*Ϸ*/ + wLogicSecSendSum = 100u; + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo ZFLogicSum_Error, sum : %d MAX: %d \n", wLogicSecSendSum, 100u); + } + else + { + ;/*Ϸ*/ + } + ShortToChar(wLogicSecSendSum, &pDataBuf[wLogicSecSendIndex]); + } + + /** Ծ߼ */ + if (CI_SUCCESS == chRetVal) + { + wLogicSecSendIndex = ii; + wLogicSecSendSum = 0U; + ii += 2U; + for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++) + { + wLogicSecId = GetLogicSecId(wLogicSecIndex); + if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId)) + { + logSecJumpLockTrnId = GetLogSecJumpLockTrainId(wLogicSecId); + if (logSecJumpLockTrnId == wTrainSysId) + { + /** ָгIDԾյ߼ID*/ + wLogicSecSendSum += 1U; + ShortToChar(wLogicSecId, &pDataBuf[ii]); + ii += 2U; + + /** ߼־*/ + logSecJumpLockPermFlag = GetLogSecJumpLockPermFlag(wLogicSecId); + if ((LOGIC_JUMPUNLOCK_PERMISSIVE_YES == logSecJumpLockPermFlag) + || (LOGIC_JUMPUNLOCK_PERMISSIVE_NO == logSecJumpLockPermFlag)) + { + pDataBuf[ii++] = logSecJumpLockPermFlag; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogSecJumpLockPermFlag_Error, flag : %d \n", logSecJumpLockPermFlag); + } + + /** ߼״̬*/ + logSecJumpLockSta = GetLogSecJumpLockState(wLogicSecId); + if (LOGIC_SECTION_JUMP_LOCK_YES == logSecJumpLockSta) + { + pDataBuf[ii++] = CI_IVOC_LOGSEC_JUMPLOCK_YES; + } + else if (LOGIC_SECTION_JUMP_LOCK_NO == logSecJumpLockSta) + { + pDataBuf[ii++] = CI_IVOC_LOGSEC_JUMPLOCK_NO; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogSecJumpLockState_Error, state : %d \n", logSecJumpLockSta); + } + } + else + { + /** ߼ηǸгԴ */ + } + + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo LogicSecId_JUMP_Error, ID : %d \n", wLogicSecId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + + /*Ծ߼0-20Ϸ*/ + if (20u < wLogicSecSendSum) + {/*Ϸ*/ + wLogicSecSendSum = 20u; + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocLgcSgmtInfo JumpLogicSum_Error, sum : %d MAX: %d \n", wLogicSecSendSum, 20u); + } + else + { + ;/*Ϸ*/ + } + ShortToChar(wLogicSecSendSum, &pDataBuf[wLogicSecSendIndex]); + } + } + else + { + /*߼ ֹͣ*/ + chRetVal = CI_ERROR; + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + + + +/* +* CiIvoc ظ״̬Ϣ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocReqAndReplyInfo(UINT8* pDataBuf, UINT16 *wDataLength,UINT16 wTrnId) +{ + UINT8 chPhyFlockStat = 0U; /*¼״̬*/ + UINT16 wRouteId = 0U; /*ID*/ + UINT16 wRouteBelongCiId = 0U; /*ID*/ + UINT16 wCiId = 0U; /*ID*/ + UINT16 wRouteIndex = 0U; + UINT16 wRouteSum = 0U; + UINT16 wTrainId = 0U; + UINT16 wRouteSendSum = 0U; + UINT16 wRouteSendIndex = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT32 dwCyc = 0u; + UINT8 chDynRpl = 0u; + UINT8 chScreenApply = 0u; + UINT8 chEaNum = 0u; + UINT8 chEaIndex = 0u; + UINT16 wEaTrainId = 0u; + UINT8 chEaLgcNum = 0u; + UINT16 * pEaLgcId = NULL; + UINT8 chLgcIndex = 0u; + UINT32 dwMidLine = 0u; + UINT8 chEaBuidFlag = 0u; + UINT8 chPaType = 0u; + UINT32 dwEaBuildCyc = 0u; + UINT8 chRrmState = 0u; + UINT8 chRrmReson = 0u; + UINT16 wNextTioc = 0u; + UINT32 dwHlhtNt = 0u; + + UINT16 wResourceCancelSendIndex = 0U; + UINT16 wResourceCancelSendSum = 0U; + UINT16 wResourceCancelTrainId = 0U; + UINT32 dwResourceCancelCyc = 0u; + + UINT16 gdIndex = 0U; + UINT16 gdCloseSendIndex = 0U; + UINT16 gdApplyCloseTrainId = 0U; + UINT8 gdApplyThisTrainCloseCount = 0U; + UINT16 gdSum = 0U; /*ǰ*/ + UINT16 wGaragedoorId = 0U; + UINT32 wGDApplyIVOCStartCycle = 0U; + + + UINT16 chFloodGateSum = 0U; /**/ + UINT16 chFloodGateIndex = 0U; + UINT16 wFloodGateSendNumIndex = 0U; + UINT16 wFloodGateSendSum = 0U; /*ͷŵ*/ + UINT16 wFloodGateId = 0U; + UINT8 wFloodGateBelongCiId = 0U; + UINT8 wFloodGateCloseApplyIvocSum = 0U; /*Źг*/ + UINT16* wFloodGateCloseApplyIvocIdBuf = NULL; /*Źгid*/ + UINT16 wwFloodGateCloseApplyTrainID = 0U; + UINT8 FloodGateCloseAnsIvocSum = 0U; /*Ѿظг*/ + FloodGateTrainAnsStruct *pFloodGatteAnsFromIvoc = NULL; /*ѾظгϢ*/ + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 sendFlag = CI_ERROR; + UINT32 wFloodGateDelayCloseStartCyc = 0U; /*Žӽгӽʱʼʱ伴Ϊгʱ*/ + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + sendFlag = CI_SUCCESS; + + chDynRpl = GetTrainDynRpl(wTrnId); + /*̬*/ + + pDataBuf[ii] = chDynRpl; + ii += 1U; + + /*ɢ*/ + chEaNum = GetEaNum(); + if (EA_MAX_NUM < chEaNum) + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo EaNum_Error, Num : %d MAX: %d \n", chEaNum, EA_MAX_NUM); + } + else + { + pDataBuf[ii] = chEaNum; + ii += 1U; + for (chEaIndex = 0u; chEaIndex < chEaNum; chEaIndex++) + { + wEaTrainId = GetEvacuatingTrainIdByIndex(chEaIndex); + chEaLgcNum = EaGetLgcNum(chEaIndex); + pEaLgcId = EaGetLgcId(chEaIndex); + dwMidLine = EaGetMidLine(chEaIndex); + chEaBuidFlag = GetEaBuildedFlag(chEaIndex); + chPaType = GetPaTypeByIndex(chEaIndex); + dwEaBuildCyc = EaGetBuildCycNum(chEaIndex); + if (NULL == pEaLgcId) + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo GetLgcId_Error \n"); + break; + } + else + { + ShortToChar(wEaTrainId, &pDataBuf[ii]); + ii += 2u; + pDataBuf[ii] = chEaLgcNum; + ii++; + for (chLgcIndex = 0u; chLgcIndex < chEaLgcNum; chLgcIndex++) + { + ShortToChar(pEaLgcId[chLgcIndex], &pDataBuf[ii]); + ii += 2u; + } + + pDataBuf[ii] = chEaBuidFlag; + ii++; + + LongToChar(dwMidLine, &pDataBuf[ii]); + ii += 4u; + + pDataBuf[ii] = chPaType; + ii++; + + LongToChar(dwEaBuildCyc, &pDataBuf[ii]); + ii += 4u; + } + } + } + /*֤ͣ*/ + pDataBuf[ii] = 0U; + wRouteSendIndex = ii; + ii += 1U; + wRouteSum = GetRouteCurSum(); + wCiId = GetSystemParaLocalCiId(); + for (wRouteIndex = 0U; wRouteIndex < wRouteSum; wRouteIndex++) + { + wRouteId = GetRouteId(wRouteIndex); + wRouteBelongCiId = GetRouteBelongCiId(wRouteId); + + if ((0u != wRouteId) && ( ROUTE_SUM_MAX > wRouteId)) + { + if (wRouteBelongCiId == wCiId) + { + wTrainId = GetRouteStopEnassureTrainId(wRouteId); + dwCyc = GetRouteStopEnassureCyc(wRouteId); + if (wTrnId == wTrainId) + { + wRouteSendSum++; + ShortToChar(wRouteId, &pDataBuf[ii]); + ii += 2U; + + LongToChar(dwCyc, &pDataBuf[ii]); + ii += 4U; + } + else + { + /*ִ*/ + } + + } + else + { + /*ִ*/ + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo RouteId_Stop_Error , route: %d \n", wRouteId); + } + } + + if (CI_IVOC_STOP_ENASSURE_ROUTE_SUM > wRouteSendSum) + { + + pDataBuf[wRouteSendIndex] = (UINT8)wRouteSendSum; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo StopEnassureRouteSum_Error, sum : %d MAX: %d \n", wRouteSendSum, CI_IVOC_STOP_ENASSURE_ROUTE_SUM); + } + + /*Դȡ*/ + pDataBuf[ii] = 0U; + wResourceCancelSendIndex = ii; + ii += 1U; + for (wRouteIndex = 0U; wRouteIndex < wRouteSum; wRouteIndex++) + { + wRouteId = GetRouteId(wRouteIndex); + wRouteBelongCiId = GetRouteBelongCiId(wRouteId); + + if ((0u != wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + if (wRouteBelongCiId == wCiId) + { + wResourceCancelTrainId = GetRouteResourceCancelTrainId(wRouteId); + wResourceCancelTrainId &= 0x00FFu; + dwResourceCancelCyc = GetRouteResourceCancelCyc(wRouteId); + if (wTrnId == wResourceCancelTrainId) + { + wResourceCancelSendSum++; + ShortToChar(wRouteId, &pDataBuf[ii]); + ii += 2U; + + LongToChar(dwResourceCancelCyc, &pDataBuf[ii]); + ii += 4U; + } + else + { + /*ִ*/ + } + + } + else + { + /*ִ*/ + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo RouteId_ResCancel_Error , route: %d \n", wRouteId); + } + } + + if (CI_IVOC_RESOURCE_CANCEL_RTSUM > wResourceCancelSendSum) + { + + pDataBuf[wResourceCancelSendIndex] = (UINT8)wResourceCancelSendSum; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo ResCancelRouteSum_Error, sum : %d MAX: %d \n", wResourceCancelSendSum, CI_IVOC_RESOURCE_CANCEL_RTSUM); + } + + /*Ϣ*/ + pDataBuf[ii] = 0U; + wFloodGateSendNumIndex = ii; + ii += 1U; /**/ + chFloodGateSum = GetFloodGateCurSum(); + for (chFloodGateIndex = 0U; chFloodGateIndex < chFloodGateSum; chFloodGateIndex++) + { + wFloodGateId = GetFloodGateId(chFloodGateIndex); + wFloodGateBelongCiId = GetFloodGateBelongCiId(wFloodGateId); + if ((0u != wFloodGateId) && (FLOOD_GATE_SUM_MAX > wFloodGateId)) + { + if (wFloodGateBelongCiId == wCiId) + { + wFloodGateCloseApplyIvocSum = GetFloodGateCloseApplyIvocSum(wFloodGateId); + wFloodGateCloseApplyIvocIdBuf = GetFloodGateCloseApplyIvocId(wFloodGateId); + wFloodGateDelayCloseStartCyc = GetFloodGateDelayCloseStartCnt(wFloodGateId); + if ((0U != wFloodGateCloseApplyIvocSum) && (NULL != wFloodGateCloseApplyIvocIdBuf) && (0U < wFloodGateDelayCloseStartCyc)) + { + for (jj = 0U; jj < wFloodGateCloseApplyIvocSum; jj++) + { + wwFloodGateCloseApplyTrainID = wFloodGateCloseApplyIvocIdBuf[jj]; + wwFloodGateCloseApplyTrainID &= 0x00FFu; + + if (wTrnId == wwFloodGateCloseApplyTrainID) + { + /*гǷѾظͬţظ*/ + FloodGateCloseAnsIvocSum = GetFloodGateCloseAnsIvocSum(wFloodGateId); + pFloodGatteAnsFromIvoc = GetFloodGateCloseFromIvocStru(wFloodGateId); + for (kk = 0U; kk < FloodGateCloseAnsIvocSum; kk++) + { + if ((wTrnId == pFloodGatteAnsFromIvoc[kk].wTrainId) + && (FLOOD_GATE_ALLOWCLOSE_IVOC == pFloodGatteAnsFromIvoc[kk].wFloodGateCloseIvocFlag)) + { + sendFlag = CI_ERROR; + break; /*гѾظͬţٴ*/ + } + } + + if (CI_SUCCESS == sendFlag) + { + wFloodGateSendSum++; + ShortToChar(wFloodGateId, &pDataBuf[ii]); + ii += 2U; + + LongToChar(wFloodGateDelayCloseStartCyc, &pDataBuf[ii]); + ii += 4U; + } + else + { + ; /*Ѿظг*/ + } + break; + } + else + { + ; /*ڷŽӽڵг*/ + } + } + + } + else + { + ; /*г*/ + } + } + else + { + ; /*DZķŲ*/ + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo FloodGateId_Error , FloodGateId: %d \n", wFloodGateId); + } + } + + if (CI_IVOC_FLOODGATE_APPLY_SUM > wFloodGateSendSum) + { + pDataBuf[wFloodGateSendNumIndex] = (UINT8)wFloodGateSendSum; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo FloodGateSendSum_Error, sum : %d MAX: %d \n", wFloodGateSendSum, CI_IVOC_FLOODGATE_APPLY_SUM); + } + + /*Źر*/ + pDataBuf[ii] = 0U; /*ԤĿ*/ + gdCloseSendIndex = ii; + ii += 1U; + + + gdSum = GetGaragedoorSum(); + for (gdIndex = 0U; gdIndex < gdSum; gdIndex++) + { + wGaragedoorId = GetGaragedoorId(gdIndex); + if ((0U != wGaragedoorId) && (GARAGE_DOOR_SUM_MAX != wGaragedoorId)) + { + wGDApplyIVOCStartCycle = GetWaiteIVOCResponseStartCycNum(wGaragedoorId); + if (0U != wGDApplyIVOCStartCycle) + { + /*еij*/ + gdApplyCloseTrainId = GetGaragedoorNearestTrainId(wGaragedoorId); + if (gdApplyCloseTrainId == wTrnId) + { + gdApplyThisTrainCloseCount++; + + ShortToChar(wGaragedoorId, &pDataBuf[ii]); + ii += 2U; + + LongToChar(wGDApplyIVOCStartCycle, &pDataBuf[ii]); + ii += 4U; + } + + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo GaragedoorId_Error , GaragedoorId: %d \n", wGaragedoorId); + break; + } + } + + + if (GARAGE_DOOR_SUM_MAX > gdApplyThisTrainCloseCount) + { + + pDataBuf[gdCloseSendIndex] = gdApplyThisTrainCloseCount; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo GarageDoorSum_Error, sum : %d MAX: %d \n", gdApplyThisTrainCloseCount, GARAGE_DOOR_SUM_MAX); + } + + + + chScreenApply = GetTrainScreenApply(wTrnId); + if ((TRAIN_HEAD_SCREEN_IVOC == chScreenApply) || (TRAIN_SCREEN_IVOC == chScreenApply)) + {/* ǰɸ */ + pDataBuf[ii++] = CI_IVOC_SCREEN_REQ_YES; + } + else + { + pDataBuf[ii++] = CI_IVOC_SCREEN_REQ_NO; + } + + if ((TRAIN_TAIL_SCREEN_IVOC == chScreenApply) || (TRAIN_SCREEN_IVOC == chScreenApply)) + {/* ɸ */ + pDataBuf[ii++] = CI_IVOC_SCREEN_REQ_YES; + } + else + { + pDataBuf[ii++] = CI_IVOC_SCREEN_REQ_NO; + } + + chRrmState = GetTrainRrmState(wTrnId); + chRrmReson = GetTrainRrmReson(wTrnId); + wNextTioc = GetTrainNextTioc(wTrnId); + (void)dquDevName2HlhtId(wNextTioc, 0u, &dwHlhtNt); + pDataBuf[ii++] = chRrmState; /* ԶRM״̬ */ + pDataBuf[ii++] = chRrmReson; /* ԶRMԭ */ + LongToChar(dwHlhtNt, &pDataBuf[ii]); /* һTIOCͨ */ + ii += 4u; + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} +/* +* (FAO+HLHT)VOBC +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToVobcDataFAOHLHToneSelf(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = { 0 };/*CIVOBC֡*/ + UINT16 psdId = 0; /*ID*/ + UINT32 psdIdInterConn = 0; /*ͨ4ֽID*/ + UINT8 startSigColour = 0; /*Źijվ·ʼźŻ*/ + UINT8 psdState = 0; /*״̬*/ + UINT16 ii = 0; + UINT8 kk = 0; + UINT16 sigId = 0; /*źŻID*/ + UINT8 rowIndex = 0; + UINT8 colIndex = 0; + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 appCycleTime = GetSystemParaAppCycleTime(); + UINT8 retVal = CI_SUCCESS; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT32 ciEtcsId = 0u; + UINT32 vobcEtcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT8 outStationSignalAllowOrNot = CI_VOBC_SIGNAL_DEFAULT; /*źŻֹ״̬*/ + UINT32 signalIdInterConn = 0u; /*ͨ4ֽźŻID*/ + UINT16 washMachineCurSum = GetWashMachineSum(); /*ȡǰϴ*/ + UINT16 washMachineId = 0u; + UINT8 psdValidFlag[2] = { 0,0 }; /*0Ч1Ч*/ + UINT8 psdReopenButtState = 0u; /*վ̨ٴοŰť״̬*/ + UINT8 platDepartButtState = 0u; /*վ̨ť״̬*/ + UINT8 psdCloseButtState = 0u; /*״̬*/ + UINT8 gapDetStatus = 0u; /*϶̽״̬*/ + UINT8 gapDetMutualLockRemvSta = 0u; /*϶̽⻥״̬*/ + UINT32 psdStartDetCycNum = 0u; /*PSD϶̽⿪ʼ*/ + UINT8 psdButtonPangluState = 0u; /*վ̨ť·״̬*/ + UINT8 washMachineState = 0u; /*ϴ״̬*/ + UINT8 mutualLockState = 0u; /*״̬*/ + UINT16 psdDepartureButtonRelayId = 0u; /*վ̨ť̵*/ + UINT8 localhlhtId = 0u; + UINT8 vobcHlhtId = 0u; + UINT8 ciEmapCheckVer = 0u; + UINT16 QKButtonRelayId = 0u; /*Ͱť̵ID*/ + UINT8 QKButtonCollState = 0u; /*Ͱť̵ɼ״̬*/ + UINT8 flag = 0u; /*ͰťºPDB״̬Ĭֵ*/ + UINT8 washModeState = 0xff; + UINT8 chPsdBelongCiId = 0U; + UINT8 chPslPcbState = 0U;/*PSLſPCBť״̬*/ + UINT8 chCleFarePcbState = 0U; /*ȷPCBť״̬*/ + UINT32 dwPsdButPreTimeCount = 0U;/*վ̨ťʧЧʱ*/ + UINT32 dwPslPcbPreCyc = 0U;/*PSLſPCBť*/ + UINT32 dwCleFarePcbPreCyc = 0U;/*ȷPCBť*/ + UINT8 chPslPcbTimeCheck = 0U;/*PSLſPCBťʱ*/ + UINT8 chCleFarePcbTimeCheck = 0U;/*ȷPCBťʱ*/ + UINT8 chWashWorkModeBack = WASH_WORKMODE_BACK_DEFAULT;/*ϴģʽ÷*/ + UINT16 wTempSendIndex = 0U;/*ʱ*/ + UINT8 chTempCheckFlag = CI_ERROR; + + /*ȻȡʱϢȡɹбҪ*/ + localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCiId, 0U, &ciEtcsId); + vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(vobcToCiDataStru->VobcId), vobcToCiDataStru->vobcLogId, &vobcEtcsId); + ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC); + if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + debug_infor_printf((const)"\nPack vobc %d data,retVal = %d\n", vobcToCiDataStru->VobcId, retVal); /*ӡϢ*/ + + if (CI_SUCCESS == retVal) + { + ii = 0U; +#if 0 + /*ͨЭ֡ͷ*/ + ii += 2U; + CiToVobcDataBuffer[ii++] = CI_SYSTEM_TYPE_VOBC; /*Ŀ߼*/ + CiToVobcDataBuffer[ii++] = (UINT8)vobcToCiDataStru->VobcId; /*Ŀ߼ID*/ + ShortToChar(vobcToCiDataStru->vobcLogId, &CiToVobcDataBuffer[ii]); /*ͨ4IP VOBC1˻2˱ʶ*/ + ii += 2U; +#endif + /*ʼӦ֡*/ + + ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*ӿϢ*/ + ii += 2U; + LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4U; + LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*շʶϢ*/ + ii += 4U; + LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4U; + LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*Ϣк*/ + ii += 4U; + ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2U; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4U; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*յһϢʱк*/ + ii += 4U; + CiToVobcDataBuffer[ii++] = CI_VOBC_PRTCL_VER_FAOHLHT;/*HLHT+FAO_CI_VOBCӿЭ汾*/ + ii += 2U;/*ͨñͷеӦò㱨ܳ*/ + + + + if ((VOBC_CI_INFO_TYPE_PSD_CONTROL == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + { + /*ΪӦò*/ + ii += 2U;/*ij*/ + + ii += 2U;/*Ӧñ*/ + + ii += 2U;/*Ԥֽ*/ + /*ֻеVOBC͵ϢſϢʱݣϢΪֻ֡ͱ֡ͷ31+6*/ + LongToChar(vobcToCiDataStru->trackSecID, &CiToVobcDataBuffer[ii]);/*ظյĹID*/ + ii += 4U; + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->psdCmdCode; /*ظյ״̬*/ + + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum; /**/ + + for (kk = 0U; kk < 2U; kk++) + { + psdId = vobcToCiDataStru->PsdData[kk].PsdId; + psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn; + chPsdBelongCiId = GetPsdBelongCiId(psdId); + + if (localCiId != chPsdBelongCiId) + {/*δ鵽ŵϢŲڱ*/ + + + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4U; + + CiToVobcDataBuffer[ii++] = PSD_STATE_INVALID_HLHT; /*״̬*/ + + CiToVobcDataBuffer[ii++] = PSD_INVALID_CMD; /**/ + } + else + {/*ڱ*/ + /*״̬*/ + mutualLockState = GetPsdMutualLockRemoveState(psdId); + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4U; + + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + {/*Ż*/ + + psdState = PSD_STATE_CLOSE_VIETNAM;/*ر*/ + } + else + {/*δ*/ + + if (GetPsdState(psdId) == PSD_STATE_CLOSE) + {/*Ź*/ + + psdState = PSD_STATE_CLOSE_VIETNAM;/*ر*/ + } + else + { + psdState = PSD_STATE_OPEN_VIETNAM;/*ǹر*/ + } + } + + CiToVobcDataBuffer[ii++] = psdState; /*״̬*/ + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType; /**/ + } + + }/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/ + + signalIdInterConn = vobcToCiDataStru->signalID; /*ͨ4ֽźŻID*/ + + LongToChar(signalIdInterConn, &CiToVobcDataBuffer[ii]);/*ظյźŻID*/ + ii += 4U; + /*ݻͨ4ֽIDȡźŻID*/ + chTempCheckFlag = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, signalIdInterConn, &sigId); + + if (CI_SUCCESS == chTempCheckFlag) + { + startSigColour = GetSignalCurColor(sigId);/*ȡźŻǰʾɫ*/ + + if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*ȡʼźŻ״̬*/ + {/*źſ*/ + outStationSignalAllowOrNot = CI_VOBC_SIGNAL_YES; + } + else + { + outStationSignalAllowOrNot = CI_VOBC_SIGNAL_NO; + } + } + + /*CIյVOBC͵źŻID״̬*/ + CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNot; /*CI->VOBCźŻ״̬*/ + + ShortToChar(CI_VOBC_INFO_TYPE_PSD_STATE, &CiToVobcDataBuffer[33U]);/*ſƱֽͣڣ31+2*/ + /*CI2VOBC״̬Ϣ*/ + CiToVobcDataBuffer[31U] = (UINT8)(((ii - 33U) >> 8U) & 0xffU); + CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU); + + /*ĵͨȫԶźϵͳͨVOBC-CIӿڹ-v1.6-20190109޸ģ2019.02.20*/ + /*CI->VOBCȫԶվ̨״̬ϢӦñͷ*/ + ii += 2U; /*ij*/ + ShortToChar(CI_VOBC_PLAT_CLEAR_PASSENGER_INFO, &CiToVobcDataBuffer[ii]); + ii += 2U; /*ͣȫԶվ̨״̬Ϣ*/ + ii += 2U; /*Ԥ2ֽ*/ + + /*CI2VOBCȫԶվ̨״̬ϢʼCI2VOBC״̬Ϣһͬͣվ̨ذťĬֵ*/ + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum; /**/ + for (kk = 0U; kk < 2U; kk++) + { + psdId = vobcToCiDataStru->PsdData[kk].PsdId; + psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn; + chPsdBelongCiId = GetPsdBelongCiId(psdId); + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4U; + + if (localCiId != chPsdBelongCiId) + { + + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ťĬֵ*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_DEFAULT; /*϶̽״̬Ĭֵδ/޴˹*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_REMOVE_OFF; /*Ĭֵ*/ + } + else + {/*IDЧ*/ + /*ȡȫԶվ̨״̬Ϣ͸VOBC*/ + psdButtonPangluState = GetPsdButtonPangluState(psdId); + if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + } + else + { + dwPsdButPreTimeCount = GetPsdButtonPressCount(); + dwPslPcbPreCyc = GetPCBPressCycNum(psdId); + dwCleFarePcbPreCyc = GetCleFarePCBPressCycNum(psdId); + chPslPcbTimeCheck = SystemOverTimeCheck(dwPslPcbPreCyc, dwPsdButPreTimeCount); + chCleFarePcbTimeCheck = SystemOverTimeCheck(dwCleFarePcbPreCyc, dwPsdButPreTimeCount); + if ((CI_TIME_OUT == chPslPcbTimeCheck) || (CI_TIME_OUT == chCleFarePcbTimeCheck)) + {/*cgh޸ijɶ:PSLſPCBȷPCBֻҪһʱ,վ̨ťĬ״̬*/ + psdCloseButtState = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + else + { + chPslPcbState = GetPsdButtonState(psdId); + chCleFarePcbState = GetCleFarePCBButtonState(psdId); + if ((PSD_BUTTON_STATE_DOWN == chPslPcbState) || (QK_PSD_BUTTON_STATE_DOWN == chCleFarePcbState)) + {/*cgh޸ijɶPSLſPCBȷPCBֻҪһ,վ̨ťͰ״̬*/ + psdCloseButtState = PSD_BUTTON_STATE_DOWN; + } + else + {/*cgh޸ijɶPSLſPCBȷPCBδ,վ̨ťδ״̬*/ + psdCloseButtState = PSD_BUTTON_STATE_UP; + } + } + + if ((PSD_RELATED_BUTTON_STATE_DEFAULT == psdCloseButtState) || (PSD_BUTTON_STATE_UP == psdCloseButtState) ) + { + /*PCBť״̬Ϊ»ЧʱͰťȻԷ*/ + QKButtonRelayId = GetQKButtonRelayId(psdId); + if ((0u != QKButtonRelayId) && (UINT16_MAX != QKButtonRelayId)) + { + QKButtonCollState = GetRelayCollState(QKButtonRelayId); + if (RELAY_STATE_UP == QKButtonCollState) + { + psdCloseButtState = PSD_BUTTON_STATE_DOWN; + } + } + } + + CiToVobcDataBuffer[ii++] = psdCloseButtState; + + } + if (PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + } + else + { + + psdReopenButtState = GetPsdOpenButtonState(psdId);/*վ̨Űť״̬*/ + if (CI_TIME_OUT == SystemOverTimeCheck(GetPOBPressCycNum(psdId), GetPsdButtonPressCount())) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + else + { + CiToVobcDataBuffer[ii++] = psdReopenButtState; + } + } + psdDepartureButtonRelayId = GetPsdDeparConfmRelayId(psdId); + QKButtonRelayId = GetQKButtonRelayId(psdId); + if ((0u != QKButtonRelayId) && (UINT16_MAX != QKButtonRelayId)) + { + QKButtonCollState = GetRelayCollState(QKButtonRelayId); + if (RELAY_STATE_UP == QKButtonCollState) + { + flag = 1u; + } + } + /*ŷť״̬*/ + if ((0u != psdDepartureButtonRelayId) && (UINT16_MAX != psdDepartureButtonRelayId)) + {/*վ̨ť̵IDЧ*/ + if ((PSD_BUTTON_PANGLU_STATE_VALID == psdButtonPangluState) || (1u == flag)) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; /*վ̨ŰťĬֵ*/ + } + else + { + platDepartButtState = GetPsdDepartButtonState(psdId);/*վ̨ť״̬*/ + if (CI_TIME_OUT == SystemOverTimeCheck(GetPSBPressCycNum(psdId), GetPsdButtonPressCount())) + { + CiToVobcDataBuffer[ii++] = PSD_RELATED_BUTTON_STATE_DEFAULT; + } + else + { + CiToVobcDataBuffer[ii++] = platDepartButtState; + } + } + } + else + {/*վ̨ťVOBCվ̨޷ť״̬*/ + CiToVobcDataBuffer[ii++] = PLATFORM_DEPAR_BUTTON_NO; + } + gapDetStatus = GetPsdRemoraState(psdId); /*ȡ϶̽״̬*/ + gapDetMutualLockRemvSta = GetJXTCMutualLockState(psdId); /*ȡ϶̽⻥״̬*/ + psdStartDetCycNum = GetStartDetectionCycNum(psdId); /*ȡ϶̽ʼ*/ + + if (((PSD_REMORA_NO == gapDetStatus) && (0U != psdStartDetCycNum)) + || (JXTC_MUTUALLOCK_REMOVE_YES == gapDetMutualLockRemvSta)) + {/*ϰ϶̽⻥*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_CLEAR; /*ϰ*/ + } + else if ((PSD_REMORA_YES == gapDetStatus) && (0U != psdStartDetCycNum)) + {/*Ϊϰ*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_UNCLEAR; /*ϰ*/ + } + else + {/*Ĭֵ*/ + CiToVobcDataBuffer[ii++] = CI_VOBC_GAP_DETECT_STATUS_DEFAULT; /*϶̽״̬Ĭֵδ/޴˹*/ + } + + /*ȡ״̬*/ + mutualLockState = GetPsdMutualLockRemoveState(psdId); + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + {/*Ż*/ + + CiToVobcDataBuffer[ii++] = CI_VOBC_REMOVE_YES; + } + else + { + CiToVobcDataBuffer[ii++] = CI_VOBC_REMOVE_NO; + } + } + } + + /*վ̨״̬ϢӦñij*/ + CiToVobcDataBuffer[60U] = (UINT8)((UINT8)((ii - 62U) >> 8U) & 0xffU); + CiToVobcDataBuffer[61U] = (UINT8)((ii - 62U) & 0xffU); + } + else if ((VOBC_CI_INFO_TYPE_FAO_INFO == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + { + /*ΪӦò*/ + ii += 2U;/*ij*/ + + ii += 2U;/*Ӧñ*/ + + ii += 2U;/*Ԥֽ*/ + /*ȫԶϴϢ֡*/ + /*ǰΪһһȫԶϴ*/ + if (1U == washMachineCurSum) + {/*һ̨ȫԶϴ*/ + washMachineId = GetWashMachineId(0U); /*ȡȫԶϴID*/ + washMachineState = GetTrainEmergencyStopState(washMachineId); /*ȡȫԶϴ״̬*/ + washModeState = GetWashModeState(washMachineId); /*ȡϴģʽ*/ + chWashWorkModeBack = GetWashWorkModeBackState(washMachineId);/*ȡϴϴģʽ÷״̬*/ + } + + /*ȫԶϴϢ*/ + if (1U == washMachineCurSum) + {/*ϴ*/ + CiToVobcDataBuffer[ii++] = GetWashMachineRequestVerifySta(washMachineId); /*1ϴȷϣ0x55ϴ0xaaϴ*/ + CiToVobcDataBuffer[ii++] = GetHeadWashAllowState(washMachineId); /*2ͨ10x55ͨ0xaaֹͨ*/ + CiToVobcDataBuffer[ii++] = GetTailWashAllowState(washMachineId); /*3ͨ20x55ͨ0xaaֹͨ*/ + CiToVobcDataBuffer[ii++] = GetTrainOutWashPortAllowSta(washMachineId); /*4ͨϴ0x55ͨ0xaaֹͨ*/ + CiToVobcDataBuffer[ii++] = washMachineState; /*5ϴϣ0x55޹ϣ0xaa*/ + CiToVobcDataBuffer[ii++] = washModeState; /*ϴģʽ0x01:ͨϴ(ϴ)0x02:ϴȫϴ*/ + CiToVobcDataBuffer[ii++] = chWashWorkModeBack; /*ϴģʽ÷5ȡֵ*/ + } + else + {/*ûϴ,Ĭֵ,ϴ״̬ͲɼϢ*/ + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_REQUEST_INVALID; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_HEADWASH_NO; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_TAILWASH_NO; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_OUT_NO_2; + CiToVobcDataBuffer[ii++] = WASHMACHINE_COL_FALUT_NO_2; + CiToVobcDataBuffer[ii++] = XTA_MODE_STATE_NO; + CiToVobcDataBuffer[ii++] = WASH_WORKMODE_BACK_DEFAULT; + } + + ShortToChar(CI_VOBC_INFO_TYPE_FAO_INFO, &CiToVobcDataBuffer[33]);/*ȫԶϴֽ֡ͣ*/ + + /*ȫԶϴӦñϢ*/ + CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU); + CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU); + } + else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + { + /*ΪӦò*/ + ii += 2U;/*ij*/ + + ii += 2U;/*Ӧñ*/ + + ii += 2U;/*Ԥֽ*/ + /*֡*/ + ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33U]);/*ֽ֡ͣ*/ + + /*ӦòϢ*/ + CiToVobcDataBuffer[31] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU); + CiToVobcDataBuffer[32] = (UINT8)((ii - 33U) & 0xffU); + } + else if ((VOBC_CI_INFO_TYPE_LOGOUT_ASK == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + { + /*ΪӦò*/ + ii += 2U;/*ij*/ + + ii += 2U;/*Ӧñ*/ + + ii += 2U;/*Ԥֽ*/ + /*עظ֡*/ + ShortToChar(CI_VOBC_INFO_TYPE_LOGOUT_ACK, &CiToVobcDataBuffer[33]);/*עظֽ֡ͣ*/ + + /*ӦòϢ*/ + CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU); + CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU); + } + else + { + /*ϢͲڣʲô*/ + } + + if ((CI_SUCCESS == retVal) && (curCycleNum == vobcToCiDataStru->ComStartCycle) && (0u != vobcToCiDataStru->wTrainMaxSafeHeadLink) && (UINT16_MAX != vobcToCiDataStru->wTrainMaxSafeHeadLink)) + { + /*յ510ͨϢ֡λЧǰVOBC˺Ϣ֡Żظ*/ + wTempSendIndex = ii; + + ii += 2U; /*ij*/ + ShortToChar(CI_VOBC_BACKUP_STATE_INFO, &CiToVobcDataBuffer[ii]); + ii += 2U; /**/ + ii += 2U; /*Ԥ2ֽ*/ + retVal = PackCiToVobcBackUpStateData(CiToVobcDataBuffer, &ii, vobcToCiDataStru); + + if (CI_SUCCESS == retVal) + { + /*ӦòϢ*/ + CiToVobcDataBuffer[wTempSendIndex] = (UINT8)((UINT8)((ii - wTempSendIndex - 2U) >> 8U) & 0xffU); + CiToVobcDataBuffer[wTempSendIndex + 1U] = (UINT8)((ii - wTempSendIndex - 2U) & 0xffU); + } + else + { + ; /**/ + } + } + else + { + ; + } + + if (CI_SUCCESS == retVal) + { + /*ͨñͷӦò㱨ܳ*/ + CiToVobcDataBuffer[29U] = (UINT8)((UINT8)((ii - 31U) >> 8U) & 0xffU); + CiToVobcDataBuffer[30U] = (UINT8)((ii - 31U) & 0xffU); +#if 0 + /*ݳ */ + CiToVobcDataBuffer[0] = (UINT8)(((ii - 2) >> 8) & 0xff); + CiToVobcDataBuffer[1] = (UINT8)((ii - 2) & 0xff); +#endif + retVal = OutnetSafeSend(((UINT16)(CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId), (vobcToCiDataStru->vobcLogId), &CiToVobcDataBuffer[0], ii); + if (CI_SUCCESS == retVal) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nVOBC_SEND:%d", ii); + debug_out_array(0xAA, CiToVobcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ +#endif + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nWrite VOBC %d dataQueue Error Len = %d\n", vobcToCiDataStru->VobcId, ii); + } + } + else + { + ; + } + } + + if (CI_ERROR == retVal) + { + SetErrorData(EFUNC_PACK_CI2VOBC_DATA, CI_DEVICE_TYPE_COMM_VOBC, vobcToCiDataStru->VobcId, ETYPE_COMM_WITH_VOBC, 0, ESEND_LEVEL_ZERO); + } + else + { + ; /*ɹ*/ + } + + return retVal; +} + +/* +* (FAO+HLHT)VOBC(ȥԶϴվ̨Ϣ) +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToVobcDataFAOHLHToneSelfSecond(VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 CiToVobcDataBuffer[VOBC_TO_CI_DATA_LEN_MAX] = { 0U };/*CIVOBC֡*/ + UINT16 psdId = 0U; /*ID*/ + UINT32 psdIdInterConn = 0U; /*ͨ4ֽID*/ + UINT8 startSigColour = 0U; /*Źijվ·ʼźŻ*/ + UINT8 psdState = 0U; /*״̬*/ + UINT16 ii = 0U; + UINT8 kk = 0U; + UINT16 sigId = 0U; /*źŻID*/ + UINT8 rowIndex = 0U; + UINT8 colIndex = 0U; + UINT32 curCycleNum = Get2oo2CurCycleNum(); + UINT32 appCycleTime = GetSystemParaAppCycleTime(); + UINT8 retVal = CI_SUCCESS; + UINT8 localCiId = GetSystemParaLocalCiId(); /*ID*/ + UINT32 ciEtcsId = 0u; + UINT32 vobcEtcsId = 0u; + UINT32 emapCheckVer = 0u; + UINT8 outStationSignalAllowOrNot = CI_VOBC_SIGNAL_DEFAULT; /*źŻֹ״̬*/ + UINT32 signalIdInterConn = 0u; /*ͨ4ֽźŻID*/ + UINT8 psdValidFlag[2U] = { 0U,0U }; /*0Ч1Ч*/ + UINT8 mutualLockState = 0u; /*״̬*/ + UINT8 localhlhtId = 0u; + UINT8 vobcHlhtId = 0u; + UINT8 ciEmapCheckVer = 0u; + UINT8 flag = 0u; /*ͰťºPDB״̬Ĭֵ*/ + UINT8 chPsdBelongCiId = 0U; + UINT16 wTempSendIndex = 0U; + UINT8 chTempCheckFlag = CI_ERROR; + + /*ȻȡʱϢȡɹбҪ*/ + localhlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCiId, 0U, &ciEtcsId); + vobcHlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_VOBC * 256U) + (UINT8)(vobcToCiDataStru->VobcId), vobcToCiDataStru->vobcLogId, &vobcEtcsId); + ciEmapCheckVer = GetCiEmapCheckVer(localCiId, &emapCheckVer, CI_SYSTEM_TYPE_VOBC); + if ((CI_SUCCESS == localhlhtId) && (CI_SUCCESS == vobcHlhtId) && (CI_SUCCESS == ciEmapCheckVer)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + debug_infor_printf((const)"\nPack vobc %d data,retVal = %d\n", vobcToCiDataStru->VobcId, retVal); /*ӡϢ*/ + + if (CI_SUCCESS == retVal) + { + ii = 0U; +#if 0 + /*ͨЭ֡ͷ*/ + ii += 2U; + CiToVobcDataBuffer[ii++] = CI_SYSTEM_TYPE_VOBC; /*Ŀ߼*/ + CiToVobcDataBuffer[ii++] = (UINT8)vobcToCiDataStru->VobcId; /*Ŀ߼ID*/ + ShortToChar(vobcToCiDataStru->vobcLogId, &CiToVobcDataBuffer[ii]); /*ͨ4IP VOBC1˻2˱ʶ*/ + ii += 2U; +#endif + /*ʼӦ֡*/ + + ShortToChar(CI_VOBC_INTERFACE_INFOTYPE, &CiToVobcDataBuffer[ii]);/*ӿϢ*/ + ii += 2U; + LongToChar(ciEtcsId, &CiToVobcDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4U; + LongToChar(vobcEtcsId, &CiToVobcDataBuffer[ii]);/*շʶϢ*/ + ii += 4U; + LongToChar(emapCheckVer, &CiToVobcDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4U; + LongToChar(curCycleNum, &CiToVobcDataBuffer[ii]);/*Ϣк*/ + ii += 4U; + ShortToChar((UINT16)appCycleTime, &CiToVobcDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2U; + LongToChar(GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4U; + LongToChar(GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_VOBC, (UINT8)(vobcToCiDataStru->VobcId)), &CiToVobcDataBuffer[ii]);/*յһϢʱк*/ + ii += 4U; + CiToVobcDataBuffer[ii++] = CI_VOBC_PRTCL_VER_FAOHLHT;/*HLHT+FAO_CI_VOBCӿЭ汾*/ + ii += 2U;/*ͨñͷеӦò㱨ܳ*/ + + if ((VOBC_CI_INFO_TYPE_PSD_CONTROL == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*ֻеVOBC͵ϢſϢʱݣϢΪֻ֡ͱ֡ͷ31+6*/ + + ii += 2u;/*ij*/ + ii += 2u;/*Ӧñ*/ + ii += 2u;/*Ԥֽ*/ + + LongToChar(vobcToCiDataStru->trackSecID, &CiToVobcDataBuffer[ii]);/*ظյĹID*/ + ii += 4U; + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->psdCmdCode; /*ظյ״̬*/ + + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdSum; /**/ + + for (kk = 0U; kk < 2U; kk++) + { + psdId = vobcToCiDataStru->PsdData[kk].PsdId; + psdIdInterConn = vobcToCiDataStru->PsdData[kk].PsdIdInterConn; + chPsdBelongCiId = GetPsdBelongCiId(psdId); + + if (localCiId != chPsdBelongCiId) + {/*δ鵽ŵϢŲڱ*/ + + + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4U; + + CiToVobcDataBuffer[ii++] = PSD_STATE_INVALID_HLHT; /*״̬*/ + + CiToVobcDataBuffer[ii++] = PSD_INVALID_CMD; /**/ + } + else + {/*ڱ*/ + /*״̬*/ + mutualLockState = GetPsdMutualLockRemoveState(psdId); + LongToChar(psdIdInterConn, &CiToVobcDataBuffer[ii]); /*ID*/ + ii += 4U; + + if ((PSD_MUTUALLOCK_REMOVE_YES == mutualLockState) || (PSD_ATS_MUTUALLOCK_REMOVE_YES == mutualLockState) + || (PSD_ATS_AND_JD_MUTUALLOCK_REMOVE_YES == mutualLockState)) + {/*Ż*/ + + psdState = PSD_STATE_CLOSE_VIETNAM;/*ر*/ + } + else + {/*δ*/ + + if (GetPsdState(psdId) == PSD_STATE_CLOSE) + {/*Ź*/ + + psdState = PSD_STATE_CLOSE_VIETNAM;/*ر*/ + } + else + { + psdState = PSD_STATE_OPEN_VIETNAM;/*ǹر*/ + } + } + + CiToVobcDataBuffer[ii++] = psdState; /*״̬*/ + CiToVobcDataBuffer[ii++] = vobcToCiDataStru->PsdData[kk].CmdType; /**/ + } + + }/*for (kk = 0; kk < vobcToCiDataStru->PsdSum; kk++)*/ + + signalIdInterConn = vobcToCiDataStru->signalID; /*ͨ4ֽźŻID*/ + + LongToChar(signalIdInterConn, &CiToVobcDataBuffer[ii]);/*ظյźŻID*/ + ii += 4U; + /*ݻͨ4ֽIDȡźŻID*/ + chTempCheckFlag = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, signalIdInterConn, &sigId); + + if (CI_SUCCESS == chTempCheckFlag) + { + startSigColour = GetSignalCurColor(sigId);/*ȡźŻǰʾɫ*/ + + if (SIGNAL_OPEN == GetSignalOpenCloseState(startSigColour))/*ȡʼźŻ״̬*/ + {/*źſ*/ + outStationSignalAllowOrNot = CI_VOBC_SIGNAL_YES; + } + else + { + outStationSignalAllowOrNot = CI_VOBC_SIGNAL_NO; + } + } + + /*CIյVOBC͵źŻID״̬*/ + CiToVobcDataBuffer[ii++] = outStationSignalAllowOrNot; /*CI->VOBCźŻ״̬*/ + + ShortToChar(CI_VOBC_INFO_TYPE_PSD_STATE, &CiToVobcDataBuffer[33U]);/*ſƱֽͣڣ31+2*/ + /*CI2VOBC״̬Ϣ*/ + CiToVobcDataBuffer[31U] = (UINT8)(((ii - 33U) >> 8U) & 0xffU); + CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU); + } + else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*֡*/ + ii += 2u;/*ij*/ + ii += 2u;/*Ӧñ*/ + ii += 2u;/*Ԥֽ*/ + + ShortToChar(CI_VOBC_INFO_TYPE_HEART_FRAME, &CiToVobcDataBuffer[33U]);/*ֽ֡ͣ*/ + + /*ӦòϢ*/ + CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU); + CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU); + } + else if ((VOBC_CI_INFO_TYPE_LOGOUT_ASK == vobcToCiDataStru->appInfoType) && (curCycleNum == vobcToCiDataStru->ComStartCycle)) + {/*עظ֡*/ + + ii += 2u;/*ij*/ + ii += 2u;/*Ӧñ*/ + ii += 2u;/*Ԥֽ*/ + ShortToChar(CI_VOBC_INFO_TYPE_LOGOUT_ACK, &CiToVobcDataBuffer[33U]);/*עظֽ֡ͣ*/ + + /*ӦòϢ*/ + CiToVobcDataBuffer[31U] = (UINT8)((UINT8)((ii - 33U) >> 8U) & 0xffU); + CiToVobcDataBuffer[32U] = (UINT8)((ii - 33U) & 0xffU); + } + else + { + /*ϢЧʲô*/ + } + + if ((CI_SUCCESS == retVal) && (curCycleNum == vobcToCiDataStru->ComStartCycle) && (0u != vobcToCiDataStru->wTrainMaxSafeHeadLink) && (UINT16_MAX != vobcToCiDataStru->wTrainMaxSafeHeadLink)) + { + /*յ510ͨϢ֡λЧǰVOBC˺Ϣ֡Żظ*/ + wTempSendIndex = ii; + ii += 2U; /*ij*/ + ShortToChar(CI_VOBC_BACKUP_STATE_INFO, &CiToVobcDataBuffer[ii]); + ii += 2U; /**/ + ii += 2U; /*Ԥ2ֽ*/ + + retVal = PackCiToVobcBackUpStateData(CiToVobcDataBuffer, &ii, vobcToCiDataStru); + + if (CI_SUCCESS == retVal) + { + /*ӦòϢ*/ + CiToVobcDataBuffer[wTempSendIndex] = (UINT8)((UINT8)((ii - wTempSendIndex - 2U) >> 8U) & 0xffU); + CiToVobcDataBuffer[wTempSendIndex + 1U] = (UINT8)((ii - wTempSendIndex - 2U) & 0xffU); + } + else + { + ; /**/ + } + } + else + { + ; + } + + if (CI_SUCCESS == retVal) + { + /*ͨñͷӦò㱨ܳ*/ + CiToVobcDataBuffer[29U] = (UINT8)((UINT8)((ii - 31U) >> 8U) & 0xffU); + CiToVobcDataBuffer[30U] = (UINT8)((ii - 31U) & 0xffU); +#if 0 + /*ݳ */ + CiToVobcDataBuffer[0] = (UINT8)(((ii - 2) >> 8) & 0xff); + CiToVobcDataBuffer[1] = (UINT8)((ii - 2) & 0xff); +#endif + retVal = OutnetSafeSend(((UINT16)(CI_SYSTEM_TYPE_VOBC << 8u) | vobcToCiDataStru->VobcId), (vobcToCiDataStru->vobcLogId), &CiToVobcDataBuffer[0], ii); + if (CI_SUCCESS == retVal) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nVOBC_SEND:%d", ii); + debug_out_array(0xAA, CiToVobcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ +#endif + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + debug_infor_printf((const)"\nWrite VOBC %d dataQueue Error Len = %d\n", vobcToCiDataStru->VobcId, ii); + } + } + else + { + ; + } + } + + if (CI_ERROR == retVal) + { + SetErrorData(EFUNC_PACK_CI2VOBC_DATA, CI_DEVICE_TYPE_COMM_VOBC, vobcToCiDataStru->VobcId, ETYPE_COMM_WITH_VOBC, 0, ESEND_LEVEL_ZERO); + } + + return retVal; +} +/* +* гϢ +* ˵UINT8 trainEditGroupInfo, гϢ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 ChecktrainEditGroupInfo(UINT8 trainEditGroupInfo, OUT UINT8 EditGroupinfo_out) +{ + UINT8 retval = CI_ERROR; + if ((PSD_SIX_EDIT_GROUP_FAO_YF == trainEditGroupInfo) || (PSD_FOUR_EDIT_GROUP_FAO_YF == trainEditGroupInfo)) + { + EditGroupinfo_out = trainEditGroupInfo; + retval = CI_SUCCESS; + } + else + { + EditGroupinfo_out = 0u; + retval = CI_ERROR; + } + return retval; +} + +/* +* гϴ +* ˵UINT8 trainEditGroupInfo, гϴ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 CheckwashTrainRequest(UINT8 washTrainRequest, OUT UINT8 washTrainRequest_out) +{ + UINT8 retval = CI_ERROR; + if ((WASHMACHINE_DRVSTATE_REQ_FALSE == washTrainRequest) || (WASHMACHINE_DRVSTATE_REQ_TRUE == washTrainRequest)) + { + washTrainRequest_out = washTrainRequest; + retval = CI_SUCCESS; + } + else + { + washTrainRequest_out = 0u; + retval = CI_ERROR; + } + return retval; +} + +/* +* ͷϴλͣϢ +* ˵UINT8 trainEditGroupInfo, ͷϴλͣϢ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 CheckheadWashStopSteady(UINT8 headwashStop, OUT UINT8 headwashStop_out) +{ + UINT8 retval = CI_ERROR; + if ((WASHMACHINE_HEAD_STEADY_YES == headwashStop) || (WASHMACHINE_HEAD_STEADY_NO == headwashStop)) + { + headwashStop_out = headwashStop; + retval = CI_SUCCESS; + } + else + { + headwashStop_out = 0u; + retval = CI_ERROR; + } + return retval; +} + +/* +* βϴλͣϢ +* ˵UINT8 trainEditGroupInfo,βϴλͣϢ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 ChecktailWashStopSteady(UINT8 tailwashStop, OUT UINT8 tailwashStop_out) +{ + UINT8 retval = CI_ERROR; + if ((WASHMACHINE_TAIL_STEADY_YES == tailwashStop) || (WASHMACHINE_TAIL_STEADY_NO == tailwashStop)) + { + tailwashStop_out = tailwashStop; + retval = CI_SUCCESS; + } + else + { + tailwashStop_out = 0u; + retval = CI_ERROR; + } + return retval; +} + +/* +* ͨϴ +* ˵UINT8 trainEditGroupInfo, ͨϴ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 CheckpassWashMachine(UINT8 passWashMachine, OUT UINT8 passWashMachine_out) +{ + UINT8 retval = CI_ERROR; + if ((PASS_WASHMACHINE_DRVREQ_TRUE == passWashMachine) || (PASS_WASHMACHINE_DRVREQ_FALSE == passWashMachine)) + { + passWashMachine_out = passWashMachine; + retval = CI_SUCCESS; + } + else + { + passWashMachine_out = 0u; + retval = CI_ERROR; + } + return retval; +} + +/* +* ϴϢӿУ +* ˵ ΣUINT8 Data ϴϢ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 WashTrainRequestCheck(UINT8 Data) +{ + UINT8 washTrainRequest = 0U; + UINT8 retVal = CI_ERROR; + washTrainRequest = Data; + + if ((WASHMACHINE_DRVSTATE_REQ_TRUE == washTrainRequest) || (WASHMACHINE_DRVSTATE_REQ_FALSE == washTrainRequest)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ϴͣ1ϢӿУ +* ˵ ΣUINT8 Data ϴͣ1Ϣ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 HeadWashStopSteadyInfoCheck(UINT8 Data) +{ + UINT8 headWashStopSteadyInfo = 0U; + UINT8 retVal = CI_ERROR; + headWashStopSteadyInfo = Data; + + if ((WASHMACHINE_HEAD_STEADY_YES == headWashStopSteadyInfo) || (WASHMACHINE_HEAD_STEADY_NO == headWashStopSteadyInfo)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ͣϴϢӿУ +* ˵ ΣUINT8 Data ͣϴϢ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 WashPauseRequestCheck(UINT8 Data) +{ + UINT8 washPauseRequest = 0U; + UINT8 retVal = CI_ERROR; + washPauseRequest = Data; + + if ((WASHMACHINE_PAUSE_DRVREQ_TRUE == washPauseRequest) || (WASHMACHINE_PAUSE_DRVREQ_FALSE == washPauseRequest)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ϴͣ2ϢӿУ +* ˵ ΣUINT8 Data ϴͣ2Ϣ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 TailWashStopSteadyInfoCheck(UINT8 Data) +{ + UINT8 tailWashStopSteadyInfo = 0U; + UINT8 retVal = CI_ERROR; + tailWashStopSteadyInfo = Data; + + if ((WASHMACHINE_TAIL_STEADY_YES == tailWashStopSteadyInfo) || (WASHMACHINE_TAIL_STEADY_NO == tailWashStopSteadyInfo)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ͨϴϢӿУ +* ˵ ΣUINT8 Data ͨϴϢ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +*/ +static UINT8 PassWashMachineRequestCheck(UINT8 Data) +{ + UINT8 passWashMachineRequest = 0U; + UINT8 retVal = CI_ERROR; + passWashMachineRequest = Data; + + if ((PASS_WASHMACHINE_REQUEST_VALID == passWashMachineRequest) || (PASS_WASHMACHINE_REQUEST_INVALID == passWashMachineRequest)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* CiIvoc ԴԶϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20230802 +*/ +static UINT8 PackCiToIvocReqAlignmentInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrnId) +{ + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT8 mm = 0U; + UINT8 chRetVal = CI_ERROR; + UINT16 wLogicSecSum = 0U;/*߼Ŀ*/ + UINT16 wLogicSecIndex = 0U;/*߼*/ + UINT16 wLogicSecId = 0U;/*߼ID*/ + UINT16 wLogicSecSendIndex = 0U;/*ʱ¼*/ + UINT8 wLogicSecSendSum = 0U;/*͵ԴԶĿ*/ + UINT16 wRLockRouteId = 0U;/*߼ν··*/ + UINT16 wPLockRouteId = 0U;/*߼η·*/ + UINT8 chRelateLogSecSum = 0U;/*߼ι߼Ŀ*/ + UINT16* wRelateLogSecId = NULL;/*߼ι߼ID*/ + UINT8 chLogLockDir = 0U;/*߼շ*/ + UINT8 chLogRelateLogLockDir = 0U;/*߼ι߼շ*/ + UINT8 chLinkLogicDirUpAndDown = CI_SYSTEM_DIRECTION_NONE;/*߼еĹϵ*/ + UINT8 chLogSecLogicLockDir = 0U;/*߼շӦ߼*/ + UINT16 wSendLinkId = 0U;/*ԴԶLINK*/ + UINT32 wSendLinkOffset = 0U;/*ԴԶLINKƫ*/ + UINT8 chLogSecHaveResOpp = 0U;/*߼Ƿ߱ԴԶǰ*/ + UINT16 wLogSecBelongPhyId = 0U;/*߼*/ + UINT16 wPhySecRLockRouteId = 0U;/*·*/ + UINT8 chLockDirOpposedFlag = ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*շǷȡ*/ + LOD_STRU pAPoint = { 0U }; /*A·ʼλ*/ + LOD_STRU pBPoint = { 0u }; /*B·ʼλ*/ + UINT8 chDirChangedNum = 0U;/*仯*/ + UINT16 wRouteLogSecSum = 0U;/*·߼*/ + UINT16* pRouteLogSecId = NULL;/*·߼ID*/ + UINT8 chTempBreakFlag = 0U;/*ʱѭ־*/ + UINT8 chTempRemoveFlag = 0U;/*ʱȥӱ־*/ + UINT8 chTempAddFlag = 0U;/*ʱӱ־*/ + struct_PathPoint pSendPoint[20] = { 0U }; + UINT16 wSameLinkId = 0U;/*ͬλLINK*/ + UINT32 wSameLinkOffset = 0U;/*ͬλLINKƫ*/ + UINT16 wOverlapLockedId = 0U;/*·ձID*/ + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + wLogicSecSum = GetLogicSecCurSum(); + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + if (LOGIC_SECTION_SUM_MAX > wLogicSecSum) + { + wLogicSecSendIndex = ii; + wLogicSecSendSum = 0U; + ii += 1U; + for (wLogicSecIndex = 0U; wLogicSecIndex < wLogicSecSum; wLogicSecIndex++) + { + chTempBreakFlag = 0U; + chTempRemoveFlag = 0U; + chTempAddFlag = 0U; + wLogicSecId = GetLogicSecId(wLogicSecIndex); + if ((0U < wLogicSecId) && (UINT16_MAX > wLogicSecId)) + { + chLogSecHaveResOpp = GetLogSecHaveResOpp(wLogicSecId); + if (CI_SUCCESS == chLogSecHaveResOpp) + { + /*߼ξ߱ԴԶǰ߼*/ + wRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId); + wPLockRouteId = GetLogSecPLockRouteId(wLogicSecId); + chLogLockDir = GetLogSecLockDir(wLogicSecId); + + if (0U < wRLockRouteId) + { + wRouteLogSecSum = GetRouteLogSectionSum(wRLockRouteId); + pRouteLogSecId = GetRouteLogSectionIdBuf(wRLockRouteId); + } + else if (0U < wPLockRouteId) + { + wOverlapLockedId = GetRouteOverlapLockedId(wPLockRouteId); + wRouteLogSecSum = GetOverlapLogicSectionSum(wOverlapLockedId); + pRouteLogSecId = GetOverlapLogicSectionBuf(wOverlapLockedId); + } + else + { + ; /*һ*/ + } + + pAPoint.Lnk = GetLgcSecOrgnLink(pRouteLogSecId[0]); + pAPoint.Off = 0U; + + if ((CI_SYSTEM_DIRECTION_UP == chLogLockDir) || (CI_SYSTEM_DIRECTION_DOWN == chLogLockDir)) + { + /*շתΪ߼֮Ĺϵ*/ + if (chLinkLogicDirUpAndDown == chLogLockDir) + { + chLogSecLogicLockDir = EMAP_CONVER_DIR; + } + else + { + chLogSecLogicLockDir = EMAP_SAME_DIR; + } + + wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wLogicSecId); + wPhySecRLockRouteId = GetPhySecRLockBelongRouteId(wLogSecBelongPhyId); + chLockDirOpposedFlag = GetRoutePhySecShouldLockOppose(wPhySecRLockRouteId, wLogSecBelongPhyId); + + if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == chLockDirOpposedFlag) + { + /*·һշҪȡת߼*/ + chLogSecLogicLockDir = ~chLogSecLogicLockDir; + } + + if (EMAP_SAME_DIR == chLogSecLogicLockDir) + { + /*ǰ߼շ߼һ£յ߼շжǷΪԴԶ*/ + chRelateLogSecSum = GetLogEndLogSecSum(wLogicSecId); + wRelateLogSecId = GetLogEndLogSecData(wLogicSecId); + wSendLinkId = GetLgcSecTmnlLink(wLogicSecId); + wSendLinkOffset = GetLgcSecTmnlOffset(wLogicSecId); + } + else if (EMAP_CONVER_DIR == chLogSecLogicLockDir) + { + /*ǰ߼շ߼෴߼շ֮෴ΪԴԶ*/ + chRelateLogSecSum = GetLogBeginLogSecSum(wLogicSecId); + wRelateLogSecId = GetLogBeginLogSecData(wLogicSecId); + wSendLinkId = GetLgcSecOrgnLink(wLogicSecId); + wSendLinkOffset = 0U; + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAndReplyInfo LogSecLogicLockDir_Error, Dir : %d \n", chLogSecLogicLockDir); + } + + (void)dsuCheckSameLoc(wSendLinkId, wSendLinkOffset, &wSameLinkId, &wSameLinkOffset); + for (mm = 0U; mm < wLogicSecSendSum; mm++) + { + /*ȥأǰѷǷѴڶӦλõ㼰ͬλ*/ + if (((pSendPoint[mm].wLinkId == wSendLinkId) && (pSendPoint[mm].dwOffset == wSendLinkOffset)) + || ((pSendPoint[mm].wLinkId == wSameLinkId) && (pSendPoint[mm].dwOffset == wSameLinkOffset))) + { + chTempRemoveFlag = 1U; + break; + } + } + for (jj = 0U; jj < chRelateLogSecSum; jj++) + { + chLogRelateLogLockDir = GetLogSecLockDir(wRelateLogSecId[jj]); + wRLockRouteId = GetLogSecLockBelongRoute(wRelateLogSecId[jj]); + wPLockRouteId = GetLogSecPLockRouteId(wRelateLogSecId[jj]); + if (0U < wRLockRouteId) + { + wRouteLogSecSum = GetRouteLogSectionSum(wRLockRouteId); + pRouteLogSecId = GetRouteLogSectionIdBuf(wRLockRouteId); + if (NULL != pRouteLogSecId) + { + /*漰ûָΪգʱҪһ*/ + pBPoint.Lnk = GetLgcSecOrgnLink(pRouteLogSecId[0]); + pBPoint.Off = 0U; + } + + } + else if (0U < wPLockRouteId) + { + pBPoint.Lnk = GetLgcSecOrgnLink(wRelateLogSecId[jj]); + pBPoint.Off = 0U; + } + else + { + ; /**/ + } + if (NULL != pRouteLogSecId) + { + /*漰ûָΪգʱҪһ*/ + chDirChangedNum = GetDirChangeNumBtwPoints(&pAPoint, &pBPoint); + if ((CI_SYSTEM_DIRECTION_UP == chLogRelateLogLockDir) || (CI_SYSTEM_DIRECTION_DOWN == chLogRelateLogLockDir)) + { + /*ǰ߼շ͹߼շЧ*/ + if (0U == (chDirChangedNum % 2U)) + { + /*2·֮䷽仯ĿΪżշһԴԶ*/ + if (chLogLockDir != chLogRelateLogLockDir) + { + if (0U == chTempRemoveFlag) + { + /**/ + chTempAddFlag = 1U; + chTempBreakFlag = 1U; + } + } + } + else + { + /*2·֮䷽仯ĿΪշһԴԶ*/ + if (chLogLockDir == chLogRelateLogLockDir) + { + if (0U == chTempRemoveFlag) + { + /**/ + chTempAddFlag = 1U; + chTempBreakFlag = 1U; + } + } + } + if (1U == chTempBreakFlag) + { + break; + } + } + else + { + ; /*һ*/ + } + } + } + if (1U == chTempAddFlag) + { + pSendPoint[wLogicSecSendSum].wLinkId = wSendLinkId; + pSendPoint[wLogicSecSendSum].dwOffset = wSendLinkOffset; + wLogicSecSendSum += 1U; + ShortToChar(wSendLinkId, &pDataBuf[ii]); + ii += 2U; + LongToChar(wSendLinkOffset, &pDataBuf[ii]); + ii += 4U; + } + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAlignmentInfo LogLockDir_Error, LockDir : %d \n", chLogLockDir); + } + } + else + { + ; /**/ + } + } + else + { + /*ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAlignmentInfo LogicSecId_Error, ID : %d \n", wLogicSecId); + } + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + pDataBuf[wLogicSecSendIndex] = wLogicSecSendSum; + } + else + { + /*߼ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocReqAlignmentInfo LogicSecSum_Error, sum : %d _MAX: %d \n", wLogicSecSum, LOGIC_SECTION_SUM_MAX); + } + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocUnlockOverlapInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrnId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT16 wSendNumIndex = 0U; + UINT16 wOverlapId = 0U; /*εID*/ + UINT16 wOverlapSum = 0U; /*ڱ*/ + UINT8 cReqUnlockOverlapNum = 0U; /*ε*/ + UINT16 wReqUnlockTrainId = 0U; /*νгID*/ + UINT32 dwReqUnlockStartCycNum = 0U; /*εʼں*/ + UINT8 cOverlapBelongCi = 0U; /*CI*/ + UINT8 cLocalCiId = 0U; + + if ((NULL != pDataBuf) && (NULL != wDataLength) && (0U < wTrnId) && (UINT16_MAX > wTrnId)) + { + chRetVal = CI_SUCCESS; + + cLocalCiId = GetSystemParaLocalCiId(); + wOverlapSum = GetOverlapCurSum(); + ii = *wDataLength; + wSendNumIndex = ii; + ii++; + + for (jj = 0U; jj < wOverlapSum; jj++) + { + wOverlapId = GetOverlapId(jj); + cOverlapBelongCi = GetOverlapBelongCiId(wOverlapId); + + if ((0u != wOverlapId) && (OVERLAP_SUM_MAX > wOverlapId)) + { + if ((0u != cLocalCiId) && (cLocalCiId == cOverlapBelongCi)) + { + wReqUnlockTrainId = GetOverlapUnlockApplyTrainId(wOverlapId); + dwReqUnlockStartCycNum = GetReqIvocUnlockStartCycNum(wOverlapId); + if (wTrnId == wReqUnlockTrainId) + { + cReqUnlockOverlapNum++; + ShortToChar(wOverlapId, &pDataBuf[ii]); /*εID*/ + ii += 2U; + + LongToChar(dwReqUnlockStartCycNum, &pDataBuf[ii]); /*εʼں*/ + ii += 4U; + } + else + { + /*ǽг*/ + } + } + else + { + /*DZΣ*/ + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocUnlockOverlapInfo OverlapId_Error, OverlapId : %d \n", wOverlapId); + break; + } + } + + pDataBuf[wSendNumIndex] = cReqUnlockOverlapNum; /*ε*/ + + if ((CI_SUCCESS == chRetVal) && (CI_IVOC_UNLOCK_OVERLAP_SUM > cReqUnlockOverlapNum)) + { + *wDataLength = ii; /*ɹεδޣسɹ*/ + } + else + { + if (CI_SUCCESS == chRetVal) + { + debug_infor_printf((const)"\n PackCiToIvocUnlockOverlapInfo ReqUnlockOverlapSum_Error, sum : %d _MAX: %d \n", cReqUnlockOverlapNum, CI_IVOC_UNLOCK_OVERLAP_SUM); + } + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ϴģʽϢӿУ +* ˵ ΣUINT8 Data ϴģʽϢ +* ֵ CI_ERROR: ӿУʧ +* CI_SUCESS: ӿУɹ +* by cgh 20231107 +*/ +static UINT8 WashMachineWorkModeCheck(UINT8 Data) +{ + UINT8 chWashMachineWorkMode = 0U; + UINT8 retVal = CI_ERROR; + + chWashMachineWorkMode = Data; + + if ((WASHMACHINE_WORKMODE_ALL_DRV == chWashMachineWorkMode) + || (WASHMACHINE_WORKMODE_SIDE_DRV == chWashMachineWorkMode) + || (WASHMACHINE_WORKMODE_DEFAULT_DRV == chWashMachineWorkMode)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* CiIvocϴϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* const UINT16 wTrnId VOBC ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20231110 +*/ +static UINT8 PackCiToIvocWashMachineInfo(UINT8* pDataBuf, UINT16* wDataLength,const UINT16 wTrnId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 washMachineCurSum = 0U;/*ǰϴ*/ + UINT16 washMachineId = 0U;/*ϴID*/ + + if ((NULL != pDataBuf) && (NULL != wDataLength) && (0U < wTrnId) && (UINT16_MAX > wTrnId)) + { + chRetVal = CI_SUCCESS; + ii = *wDataLength; + /*ȡǰϴ*/ + washMachineCurSum = GetWashMachineSum(); + + if (1U == washMachineCurSum) + { + /*һ̨ȫԶϴ*/ + washMachineId = GetWashMachineId(0U); + } + else + { + if (0U == washMachineCurSum) + { + ; /*ûϴ*/ + } + else + { + chRetVal = CI_ERROR; /*ϴ*/ + debug_infor_printf((const)"\n PackCiToIvocWashMachineInfo washMachineCurSum_Error, sum : %d \n", washMachineCurSum); + } + } + + if(0U != washMachineId) + { + pDataBuf[ii++] = GetWashMachineRequestVerifySta(washMachineId); /*1ϴȷϣ0x55ϴ0xaaϴ*/ + pDataBuf[ii++] = GetHeadWashAllowState(washMachineId); /*2ͨ10x55ͨ0xaaֹͨ*/ + pDataBuf[ii++] = GetTailWashAllowState(washMachineId); /*3ͨ20x55ͨ0xaaֹͨ*/ + pDataBuf[ii++] = GetTrainOutWashPortAllowSta(washMachineId); /*4ͨϴ0x55ͨ0xaaֹͨ*/ + pDataBuf[ii++] = GetTrainEmergencyStopState(washMachineId); /*5ϴϣ0x55޹ϣ0xaa*/ + pDataBuf[ii++] = GetWashModeState(washMachineId); /*ϴģʽ0x01:ͨϴ(ϴ)0x02:ϴȫϴ*/ + pDataBuf[ii++] = GetWashWorkModeBackState(washMachineId); /*ϴģʽ÷5ȡֵ*/ + } + else + { + /*ûϴǵǰгϴ,Ĭֵ*/ + pDataBuf[ii++] = WASHMACHINE_COL_REQUEST_INVALID; + pDataBuf[ii++] = WASHMACHINE_COL_HEADWASH_NO; + pDataBuf[ii++] = WASHMACHINE_COL_TAILWASH_NO; + pDataBuf[ii++] = WASHMACHINE_COL_OUT_NO_2; + pDataBuf[ii++] = WASHMACHINE_COL_FALUT_NO_2; + pDataBuf[ii++] = XTA_MODE_STATE_NO; + pDataBuf[ii++] = WASH_WORKMODE_BACK_DEFAULT; + } + + + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocѩƶϢ +* ˵ UINT8* pDataBuf ݻ +* UINT16 *pDataLength ݳ() +* UINT16 wTrainId гID0x14 +* ֵ CI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2023.11.10 +*/ +static UINT8 PackCiToIvocSnowAndUrgentInfo(UINT8* pDataBuf, UINT16* pDataLength, UINT16 wTrainId) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 kk = 0U; + UINT8 cAreaSnowTotalNum = 0U; /*ѩվ̨*/ + UINT16 wAreaSnowNumIndex = 0U; + UINT32* pAreaSnowId = NULL; /*ѩվ̨ID*/ + ToCiAreaSnowStruct* pRecvCiAreaSnow = NULL; /*͵ѩϢ*/ + UINT8 cWlbState = 0U; /*ȫ߽ƶ״̬*/ + UINT8 cUrgentReason = 0U; /*ԭ*/ + UINT8 cAreaUrgentState = 0U; /*ƶ״̬*/ + EnvelopeStruct* strTrainEnvelope = NULL; /*гϢ*/ + UINT16 wAxisRelPhySecId = 0U; /*ιID*/ + UINT8 cUrgentState = 0U; /*͸IVOCĽ״̬*/ + + if ((NULL != pDataBuf) && (NULL != pDataLength) && (0U != wTrainId) && (LINE_MAX_TRAIN > wTrainId)) + { + retVal = CI_SUCCESS; + ii = *pDataLength; + + /*鱾ѩ״̬Ϣ*/ + wAreaSnowNumIndex = ii; /*ѩվ̨*/ + ii++; + cAreaSnowTotalNum = GetLocalAreaSnowNum(); + pAreaSnowId = GetLocalAreaSnowId(); + + if (LOCAL_AREA_SNOW_SUM_MAX >= cAreaSnowTotalNum) + { + for (jj = 0U; jj < cAreaSnowTotalNum; jj++) + { + LongToChar(pAreaSnowId[jj], &pDataBuf[ii]); /*ѩվ̨ID*/ + ii += 4U; + } + } + else + { + retVal = CI_ERROR; /*ѩޣʧ*/ + debug_infor_printf((const)"\n PackCiToIvocSnowAndUrgentInfo AreaSnowSum_Error, sum : %d _MAX: %d \n", cAreaSnowTotalNum, LOCAL_AREA_SNOW_SUM_MAX); + } + + /*͵ѩ״̬Ϣ*/ + pRecvCiAreaSnow = GetCiRecvAreaSnowInfo(); + for (kk = 0U; kk < CI_COM_CI_MAX_NUM; kk++) + { + if (0U != pRecvCiAreaSnow[kk].cPlatFormNum) + { + for (jj = 0U; jj < pRecvCiAreaSnow[kk].cPlatFormNum; jj++) + { + if (LOCAL_AREA_SNOW_SUM_MAX > cAreaSnowTotalNum) + { + LongToChar(pRecvCiAreaSnow[kk].dwPlatFormId[jj], &pDataBuf[ii]); /*ѩվ̨ID*/ + ii += 4U; + cAreaSnowTotalNum++; + } + else + { + retVal = CI_ERROR; /*ѩޣʧ*/ + } + } + } + else + { + /**/ + } + } + pDataBuf[wAreaSnowNumIndex] = cAreaSnowTotalNum; /*ѩվ̨*/ + + /*ƶ״̬Ϣ*/ + cWlbState = WlbGetState(); /*ȡȫ߽״̬*/ + if (WLB_UNSET != cWlbState) + { + cUrgentReason |= 0x01U; /*ԭȫ߽ƶ*/ + } + else + { + /**/ + } + + strTrainEnvelope = elm_GetEnvelopeInfoByTrainID(wTrainId); + if (NULL != strTrainEnvelope) + { + for (jj = 0U; jj < strTrainEnvelope->ACCnt; jj++) + { + wAxisRelPhySecId = GetAxisSecRelativePhySecId(strTrainEnvelope->ACID[jj]); + cAreaUrgentState = GetPhySecAreaUrgentState(wAxisRelPhySecId); + + if (PHYSEC_AREA_URGENT_NO != cAreaUrgentState) + { + cUrgentReason |= 0x02U; /*ԭƶ*/ + break; + } + else + { + /**/ + } + } + } + else + { + /*Ϊգгδ뱾*/ + } + + if (0U == cUrgentReason) + { + cUrgentState = CI_IVOC_URGENT_NO; /*ԭΪ0Ч*/ + } + else + { + cUrgentState = CI_IVOC_URGENT_YES; /*ԭ0Ч*/ + } + + if (CI_SUCCESS == retVal) + { + pDataBuf[ii] = cUrgentState; /*ƶ״̬*/ + ii++; + pDataBuf[ii] = cUrgentReason; /*ƶԭ*/ + ii++; + *pDataLength = ii; + } + else + { + /*ʧ*/ + } + } + else + { + /*ηǷʧ*/ + } + + return retVal; +} + +/* +* УгǷغ +* ˵ UINT16 wFloodGateId, ID +* UINT16 wTrainId, гID +* ֵ CI_ERROR ʧ,ͷصʵ״̬ +* CI_SUCCESS ɹͷص޹ +*/ +UINT8 CheckProtectEnvelope(UINT16 wFloodGateId, UINT16 wTrainId) +{ + UINT8 retVal = CI_ERROR; + UINT16 axisSum = 0u; + UINT16 *pAxisIdBuf = NULL; + UINT16 ii = 0u; + UINT16 axisId = 0u; /*ID*/ + UINT8 cAxisLinkSum = 0U; + UINT16 *pAxisLinkIdBuf = NULL; + UINT8 linkIndex = 0U; + UINT16 wAxisLinkId = 0U; + UINT8 chTrainSum = 0U; + TRAIN_SEQUANCE_s TrainList[SIZE_MAX_LINETRAIN] = { 0u }; + UINT8 chTrainIndex = 0U; + + axisSum = GetFloodGateProtectAxisNum(wFloodGateId); + pAxisIdBuf = GetFloodGateProtectAxisIDBuf(wFloodGateId); + + if (NULL == pAxisIdBuf) + { + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + } + if (CI_SUCCESS == retVal) + { + for (ii = 0u; ii < axisSum; ii++) + { + axisId = pAxisIdBuf[ii]; + if (0U < axisId) + { + cAxisLinkSum = GetAxisLinkSum(axisId); + pAxisLinkIdBuf = GetAxisLinkIdBuf(axisId); + if (NULL == pAxisLinkIdBuf) + { + retVal = CI_ERROR; + } + else + { + for (linkIndex = 0U; linkIndex < cAxisLinkSum; linkIndex++) + { + wAxisLinkId = pAxisLinkIdBuf[linkIndex]; + chTrainSum = as_GetLinkTrainList(wAxisLinkId, TrainList, SIZE_MAX_LINETRAIN); + if (0u != chTrainSum) + { + for (chTrainIndex = 0u; chTrainIndex < chTrainSum; chTrainIndex++) + { + if (wTrainId == TrainList[chTrainIndex].u16TrainID) + { + /*б磬ͷص*/ + retVal = CI_SUCCESS; + break; + } + else + { + /*а磬DZ磬ްص*/ + retVal = CI_ERROR; + } + } + } + else + { + /*гϢصްص*/ + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + /*б磬ͷص*/ + break; + } + } + } + if (CI_SUCCESS == retVal) + { + /*б磬ͷص*/ + break; + } + } + } + } + + return retVal; +} + +/* +* CiIvocͨ߼Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpLogSecInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 wVobcBackUpSendLogAllNum = 0U; + UINT8 wVobcBackUpSendLogUseNum = 0U; + UINT8 jj = 0U; + UINT16 chIndex = 0U; /*ҪͿ߼ε*/ + ABLTrainRelLogStru* ablVobcBackUpSendLogStr = NULL; + UINT16 wVobcBackUpSendLogId = 0U; + UINT8 LogSecAblUseFlag = 0U; + UINT8 chVobcBackUpSendLogDir = 0U; + UINT16 wLogSecBelongPhyId = 0U; + UINT8 chLockDirOpposedFlag = 0U; + UINT16 wRLockRouteId = 0U; + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + wVobcBackUpSendLogAllNum = GetTrainAblRelLogSecNum(wTrainId); + ablVobcBackUpSendLogStr = GetTrainAblRelLogData(wTrainId); + chIndex = ii; + ii++; + + for (jj = 0U; jj < wVobcBackUpSendLogAllNum; jj++) + { + wVobcBackUpSendLogId = ablVobcBackUpSendLogStr[jj].wAblRelLogSecId; + chVobcBackUpSendLogDir = ablVobcBackUpSendLogStr[jj].chAblRelLogSecDir; + LogSecAblUseFlag = GetLogSecAblUseFlag(wVobcBackUpSendLogId); + + if (LOGIC_ABLNEAR_USE_FLAG_YES == LogSecAblUseFlag) + { + /*ԴԼͨгΪABL߼·Ϊ*/ + wVobcBackUpSendLogUseNum += 1U; + ShortToChar(wVobcBackUpSendLogId, &pDataBuf[ii]); /*߼ID*/ + ii += 2u; + + if ((CI_SYSTEM_DIRECTION_UP == chVobcBackUpSendLogDir) + || (CI_SYSTEM_DIRECTION_DOWN == chVobcBackUpSendLogDir)) + { + /*߼β·*/ + wRLockRouteId = GetLogSecLockBelongRoute(wVobcBackUpSendLogId); + /*β·*/ + wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wVobcBackUpSendLogId); + chLockDirOpposedFlag = GetRoutePhySecShouldLockOppose(wRLockRouteId, wLogSecBelongPhyId); + + if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == chLockDirOpposedFlag) + { + chVobcBackUpSendLogDir = ~chVobcBackUpSendLogDir; + } + else + { + ; /*շҪȡ˵߼ҲҪȡ*/ + } + pDataBuf[ii] = chVobcBackUpSendLogDir; + ii += 1U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpLogSecInfo VobcBackUpSendLogDir_Error, DIR : %d \n", chVobcBackUpSendLogDir); + } + } + else + { + ; /*߼βãг*/ + } + + } + + pDataBuf[chIndex] = wVobcBackUpSendLogUseNum; + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocͨ·Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpRouteInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 chTrainAblAllRouteNum = 0U; + UINT8 VobcBackUpSendRouteNum = 0U; + UINT8 jj = 0U; + UINT16 chIndex = 0U; /*Ҫͽ·*/ + ABLTrainRelAllRouteStru* ablVobcBackUpSendRouteStr = NULL; + UINT16 VobcBackUpSendAblRelRouteId = 0U; + UINT8 VobcBackUpSendAblRelRouteFlag = 0U; + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + chTrainAblAllRouteNum = GetTrainAblAllRouteNum(wTrainId); + ablVobcBackUpSendRouteStr = GetTrainAblRelAllRouteData(wTrainId); + chIndex = ii; + ii++; + + for (jj = 0U; jj < chTrainAblAllRouteNum; jj++) + { + VobcBackUpSendAblRelRouteId = ablVobcBackUpSendRouteStr[jj].wAblRelRouteId; + VobcBackUpSendAblRelRouteFlag = ablVobcBackUpSendRouteStr[jj].chAblRelTrainInFlag; + + if (TRAIN_ABL_ROUTE_FLAG_NO == VobcBackUpSendAblRelRouteFlag) + { + if (CI_VOBC_BACKUP_SEND_ROUTE_SUM > VobcBackUpSendRouteNum) + { + VobcBackUpSendRouteNum += 1U; + ShortToChar(VobcBackUpSendAblRelRouteId, &pDataBuf[ii]); /*·ID*/ + ii += 2u; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpRouteInfo VobcBackUpSendRouteNum Error: %d \n", VobcBackUpSendRouteNum); + break; + } + } + else + { + ; /*гµĽ·*/ + } + + } + } + + if (CI_SUCCESS == chRetVal) + { + pDataBuf[chIndex] = VobcBackUpSendRouteNum; + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocͨ۷߼Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpReturnLogInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 TrainAblRelReturnLogNum = 0U; + UINT8 jj = 0U; + UINT16* TrainAblRelReturnLogIdBuf = NULL; + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + TrainAblRelReturnLogNum = GetTrainAblRelReturnLogNum(wTrainId); + pDataBuf[ii++] = TrainAblRelReturnLogNum; + TrainAblRelReturnLogIdBuf = GetTrainAblRelReturnLogId(wTrainId); + + for (jj = 0U; jj < TrainAblRelReturnLogNum; jj++) + { + ShortToChar(TrainAblRelReturnLogIdBuf[jj], &pDataBuf[ii]); /*۷߼ID*/ + ii += 2u; + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocͨ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpPsdInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 TrainAblRelPsdNum = 0U; + UINT8 jj = 0U; + ABLTrainRelPsdStru* pAblRelPsdData = NULL; + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + TrainAblRelPsdNum = GetTrainAblRelPsdNum(wTrainId); + pDataBuf[ii++] = TrainAblRelPsdNum; + pAblRelPsdData = GetTrainAblRelPsdData(wTrainId); + if (((0U != TrainAblRelPsdNum) && (NULL == pAblRelPsdData)) + ||(TRAIN_ABL_PSD_SUM < TrainAblRelPsdNum)) + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpPsdInfo TrainAblRelPsdNum : %d \n", TrainAblRelPsdNum); + } + else + { + for (jj = 0U; jj < TrainAblRelPsdNum; jj++) + { + ShortToChar(pAblRelPsdData[jj].wAblRelPsdId, &pDataBuf[ii]); /*PSD ID*/ + ii += 2U; + if ((CI_IVOC_PSD_STATE_CLOSE == pAblRelPsdData[jj].chAblRelPsdSta) || (CI_IVOC_PSD_STATE_OPEN == pAblRelPsdData[jj].chAblRelPsdSta)) + { + pDataBuf[ii++] = pAblRelPsdData[jj].chAblRelPsdSta; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpPsdInfo chAblRelPsdSta : %d \n", pAblRelPsdData[jj].chAblRelPsdSta); + } + } + } + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocSpksͨ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpSpksInfo(UINT8* pDataBuf, UINT16* wDataLength) +{ + UINT8 chSpksStat = 0U; /*¼״̬*/ + UINT16 wSpksId = 0U; /*ID*/ + UINT16 wSpksIndex = 0U; + UINT16 wSpksSum = 0U; + UINT8 chSpksCiToVobcSum = 0U; /*CIշ͸VOBCspks*/ + UINT16 wSpksCiToVobcSumDress = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chSpksPangLStat = 0U; /*spks·״̬*/ + UINT8 checkflag = 0U; + + if ((NULL == pDataBuf) + || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wSpksSum = GetTotalSpksCurNum(); /*SPKSڵSPKS_SUM_MAX0*/ + wSpksCiToVobcSumDress = ii; + ii++; + for (wSpksIndex = 0U; wSpksIndex < wSpksSum; wSpksIndex++) + { + wSpksId = GetSpksIdByIndex(wSpksIndex); + if ((0U < wSpksId) && (UINT16_MAX > wSpksId)) + { + /*ӼSPKSҪ*/ + checkflag = CheckSpksRelSecBelongCI(wSpksId); + /**/ + if (CI_SUCCESS == checkflag) + { + ; /*SPKSϢ*/ + } + /**/ + else if (CI_ERROR == checkflag) + { + chSpksStat = GetSpksState(wSpksId); /*SPKS£ҪID*/ + chSpksPangLStat = GetSpksCutState(wSpksId); /*SPKS·״̬*/ + if ((SPKS_STATUS_NO != chSpksStat) && (SPKS_CUT_YES != chSpksPangLStat)) + { + ShortToChar(wSpksId, &pDataBuf[ii]); + ii += 2U; + chSpksCiToVobcSum++; /*SPKS*/ + } + else + { + ; /*δ*/ + } + } + else + { + /*󣬷ʧ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpSpksInfo SpksRelSecBelongCI_Error \n"); + } + } + else + { + debug_infor_printf((const)"\n PackCiToIvocBackUpSpksInfo wSpksId_Error : %d \n", wSpksId); + /*spksIDֹͣ*/ + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + + if (TRAIN_ABL_SPKS_SUM < chSpksCiToVobcSum) + { + /*SPKSޣͨţ*/ + debug_infor_printf((const)"\n PackCiToIvocBackUpSpksInfo chSpksCiToVobcSum_Error : %d \n", chSpksCiToVobcSum); + chRetVal = CI_ERROR; + } + else + { + ; /*ά*/ + } + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + pDataBuf[wSpksCiToVobcSumDress] = chSpksCiToVobcSum; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocͨť״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpEsbInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 TrainAblReEsbNum = 0U; + UINT8 jj = 0U; + ABLTrainRelEsbStru* pAblRelEsbData = NULL; + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + TrainAblReEsbNum = GetTrainAblRelEsbNum(wTrainId); + pDataBuf[ii++] = TrainAblReEsbNum; + pAblRelEsbData = GetTrainAblRelEsbData(wTrainId); + if(((0U != TrainAblReEsbNum)&&(NULL == pAblRelEsbData)) + ||(TRAIN_ABL_ESB_SUM < TrainAblReEsbNum)) + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"PackCiToIvocBackUpEsbInfo_ERROR TrainAblReEsbNum INVALID, %d", TrainAblReEsbNum); + } + else + { + for (jj = 0U; jj < TrainAblReEsbNum; jj++) + { + ShortToChar(pAblRelEsbData[jj].wAblRelEsbId, &pDataBuf[ii]); /*ESB ID*/ + ii += 2u; + if ((CI_IVOC_ESB_STATE_INVALID == pAblRelEsbData[jj].chAblRelEsbSta) || (CI_IVOC_ESB_STATE_VALID == pAblRelEsbData[jj].chAblRelEsbSta)) + { + pDataBuf[ii++] = pAblRelEsbData[jj].chAblRelEsbSta; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"PackCiToIvocBackUpEsbInfo ERROR AblRelEsbSta INVALID, %d", pAblRelEsbData[jj].chAblRelEsbSta); + } + } + } + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocͨ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpSwitchInfo(UINT8* pDataBuf, UINT16* wDataLength) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 chAblRelSwitchNum = 0U; /*ABL*/ + UINT16 wSwitchId = 0U;/*ID*/ + UINT8 chSwitchState = 0U;/*״̬*/ + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + chAblRelSwitchNum = GetTotalSwitchCurNum(); + if (TRAIN_ABL_SWITCH_SUM < chAblRelSwitchNum) + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"PackCiToIvocBackUpSwitchInfo chAblRelSwitchNum INVALID, %d", chAblRelSwitchNum); + } + else + { + pDataBuf[ii++] = (UINT8)chAblRelSwitchNum; + for (jj = 0U; jj < (UINT8)chAblRelSwitchNum; jj++) + { + wSwitchId = GetSwitchId(jj);/*ȡļиµĵID*/ + if (SWITCH_SUM_MAX > wSwitchId) + { + ShortToChar(wSwitchId, &pDataBuf[ii]); /* ID*/ + ii += 2U; + chSwitchState = GetSwitchCurPosition(wSwitchId); + switch (chSwitchState) + { + case SWITCH_POSITION_DINGWEI: + pDataBuf[ii++] = CI_IVOC_SWITCH_POSTION_DING; + break; + case SWITCH_POSITION_FANWEI: + pDataBuf[ii++] = CI_IVOC_SWITCH_POSTION_FAN; + break; + case SWITCH_POSITION_JICHA: + case SWITCH_POSITION_MOVE: + case SWITCH_POSITION_SIKAI: + case SWITCH_POSITION_INVALID: + pDataBuf[ii++] = CI_IVOC_SWITCH_POSTION_SHIBIAO; + break; + default: + /*״ֹ̬ͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"PackCiToIvocBackUpSwitchInfo_ERROR_switchState_INVALID, %d", chSwitchState); + break; + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"PackCiToIvocBackUpSwitchInfo_ERROR_wSwitchId_INVALID, %d", wSwitchId); + } + } + } + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocͨ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpProtectLgcInfo(UINT8* pDataBuf, UINT16* wDataLength,UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 chProSecSum = 0U;/*Ŀ*/ + UINT8 jj = 0U; + ABLTrainRelProSecStru* pAblProSecData = NULL;/*ABLĿ*/ + UINT16 wProSecId = 0U;/*ID*/ + UINT8 chProSecDir = 0U;/*շ*/ + + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + chProSecSum = GetTrainAblRelProSecNum(wTrainId); + pAblProSecData = GetTrainAblRelProSecData(wTrainId); + + if (TRAIN_ABL_PROSEC_SUM >= chProSecSum) + { + pDataBuf[ii++] = chProSecSum; + for (jj = 0U; jj < chProSecSum; jj++) + { + wProSecId = pAblProSecData[jj].wAblRelProSecId; + if ((0U < wProSecId) && (UINT16_MAX > wProSecId)) + { + ShortToChar(wProSecId, &pDataBuf[ii]); + ii += 2U; + chProSecDir = pAblProSecData[jj].chAblRelProSecDir; + if ((CI_SYSTEM_DIRECTION_UP == chProSecDir) || (CI_SYSTEM_DIRECTION_DOWN == chProSecDir)) + { + pDataBuf[ii++] = chProSecDir; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpProtectLgcInfo chProSecDir_error : %d \n", chProSecDir); + } + + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpProtectLgcInfo wProSecId_error : %d \n", wProSecId); + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpProtectLgcInfo chProSecSum more than MAX : %d \n", chProSecSum); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocʱ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpTsrInfo(UINT8* pDataBuf, UINT16* wDataLength,UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 chXianSuPhySecSum = 0U;/*Ŀ*/ + UINT8 jj = 0U; + ABLTrainRelXianSuStru* pAblXiansuPhyData = NULL;/*ABLг*/ + UINT16 wXiansuPhySecId = 0U;/*ID*/ + UINT16 wXiansuPhySecSpeed = 0U;/*ֵ*/ + UINT8 chTempSendAxisSecSum = 0U;/*ʱŷͼĿ*/ + UINT16 wTempSendAxisSecIndex = 0U;/*ʱŷͼĿ*/ + UINT8 kk = 0U; + UINT8 chPhySecRelAxisSecSum = 0U;/*ζӦĿ*/ + UINT16* szPhySecRelAxisId = NULL;/*ιID*/ + UINT8 wTempAxisSum = 0U; /*ʱĿ*/ + UINT16 szAxisIdBuf[AC_MAXCNT_IN_SWITCH] = { 0U };/*ʱID*/ + + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + wTempSendAxisSecIndex = ii; + ii++; + + chXianSuPhySecSum = GetTrainAblRelXianSuNum(wTrainId); + pAblXiansuPhyData = GetTrainAblRelXiansuData(wTrainId); + + if (TRAIN_ABL_XIANSUSEC_SUM >= chXianSuPhySecSum) + { + for (jj = 0U; jj < chXianSuPhySecSum; jj++) + { + wXiansuPhySecId = pAblXiansuPhyData[jj].wAblRelXianSuPhySecId; + if ((0U < wXiansuPhySecId) && (UINT16_MAX > wXiansuPhySecId)) + { + chPhySecRelAxisSecSum = GetPAxisSectionSum(wXiansuPhySecId); + szPhySecRelAxisId = GetPAxisSectionIdBuf(wXiansuPhySecId); + + if ((0U < chPhySecRelAxisSecSum) && (NULL != szPhySecRelAxisId)) + { + wTempAxisSum = GetAllAxisFromAxisSeqSafeSw(szPhySecRelAxisId, (UINT16)chPhySecRelAxisSecSum, &szAxisIdBuf); + + if (0U == wTempAxisSum) + { + /*Ŀмȫ*/ + for (kk = 0U; kk < chPhySecRelAxisSecSum; kk++) + { + if ((0U < szPhySecRelAxisId[kk]) && (UINT16_MAX > szPhySecRelAxisId[kk])) + { + ShortToChar(szPhySecRelAxisId[kk], &pDataBuf[ii]); + ii += 2U; + wXiansuPhySecSpeed = pAblXiansuPhyData[jj].chAblRelXianSuValue; + if (UINT16_MAX > wXiansuPhySecSpeed) + { + chTempSendAxisSecSum++; + ShortToChar(wXiansuPhySecSpeed, &pDataBuf[ii]); + ii += 2U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo wXiansuPhySecSpeed_error : %d \n", wXiansuPhySecSpeed); + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo szPhySecRelAxisId_error : %d \n", szPhySecRelAxisId[kk]); + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + + } + else + { + for (kk = 0U; kk < wTempAxisSum; kk++) + { + if ((0U < szAxisIdBuf[kk]) && (UINT16_MAX > szAxisIdBuf[kk])) + { + ShortToChar(szAxisIdBuf[kk], &pDataBuf[ii]); + ii += 2U; + wXiansuPhySecSpeed = pAblXiansuPhyData[jj].chAblRelXianSuValue; + if (UINT16_MAX > wXiansuPhySecSpeed) + { + chTempSendAxisSecSum++; + ShortToChar(wXiansuPhySecSpeed, &pDataBuf[ii]); + ii += 2U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo wXiansuPhySecSpeed_error : %d \n", wXiansuPhySecSpeed); + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo szPhySecRelAxisId_error : %d \n", szPhySecRelAxisId[kk]); + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo chPhySecRelAxisSecSum_error : %d \n", chPhySecRelAxisSecSum); + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo wXiansuPhySecId_error : %d \n", wXiansuPhySecId); + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpTsrInfo chXianSuPhySecSum more than MAX : %d \n", chXianSuPhySecSum); + } + } + + if ((CI_SUCCESS == chRetVal) && (TRAIN_ABL_XIANSUSEC_SUM >= chTempSendAxisSecSum)) + { + *wDataLength = ii; + pDataBuf[wTempSendAxisSecIndex] = chTempSendAxisSecSum; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvoc״̬ȷϢ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpReqStateInfo(UINT8* pDataBuf, UINT16* wDataLength) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 kk = 0U; + UINT8 chAreaSnowTotalNum = 0U; /*ѩվ̨*/ + UINT16 wAreaSnowNumIndex = 0U; + UINT32* pAreaSnowId = NULL; /*ѩվ̨ID*/ + ToCiAreaSnowStruct* pRecvCiAreaSnow = NULL; /*͵ѩϢ*/ + UINT8 chTsrSureFlag = GetTsrSureFlag();/* ȷϱ־λ */ + UINT8 chAllLineTsrState = 0U;/*ȫʱٱ־*/ + UINT8 chAllLineTsrSpeed = 0U;/*ȫʱֵ*/ + UINT8 chWlbState = 0U; /*ȫ߽ƶ״̬*/ + UINT8 chSnowModel = 0U; /* ѩģʽ */ + + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + /* ȷϱ־λ */ + chTsrSureFlag = GetTsrSureFlag(); + if (CI_TSR_SURE_YES == chTsrSureFlag) + { + /* ȷ */ + pDataBuf[ii] = CI_TSR_SURE_YES; + } + else + { + /* δȷ */ + pDataBuf[ii] = CI_TSR_SURE_NO; + } + ii += 1U; + + /* ȫʱϢ */ + chAllLineTsrState = GetAllLineTsrState(); + chAllLineTsrSpeed = GetAllLineTsrSpeed(); + if (CI_ALL_LINE_TSR_VALID == chAllLineTsrState) + { + /* ȫʱ */ + pDataBuf[ii] = CI_ALL_LINE_TSR_UNVALID; + ii += 1U; + ShortToChar((UINT16)chAllLineTsrSpeed, &pDataBuf[ii]); + ii += 2U; + + } + else + { + pDataBuf[ii] = CI_ALL_LINE_TSR_VALID; + ii += 1U; + ShortToChar(0U, &pDataBuf[ii]); + ii += 2U; + } + + /*ȫ߽ƶ״̬*/ + chWlbState = WlbGetState(); + if (WLB_UNSET == chWlbState) + { + /* δ */ + pDataBuf[ii] = WLB_UNSET; + } + else + { + /* */ + pDataBuf[ii] = WLB_SET; + } + ii += 1U; + + /* ѩģʽ */ + chSnowModel = GetAllSnowModel(); + if (CI_ALL_SNOW_VALID == chSnowModel) + { + /* ѩ */ + pDataBuf[ii] = CI_ALL_SNOW_VALID; + } + else + { + /* ѩ */ + pDataBuf[ii] = CI_ALL_SNOW_UNVALID; + } + ii += 1U; + + + /*鱾ѩ״̬Ϣ*/ + wAreaSnowNumIndex = ii; /*ѩվ̨*/ + ii++; + chAreaSnowTotalNum = GetLocalAreaSnowNum(); + pAreaSnowId = GetLocalAreaSnowId(); + + if (ALL_AREA_SNOW_SUM_MAX >= chAreaSnowTotalNum) + { + for (jj = 0U; jj < chAreaSnowTotalNum; jj++) + { + LongToChar(pAreaSnowId[jj], &pDataBuf[ii]); /*ѩվ̨ID*/ + ii += 4U; + } + } + else + { + chRetVal = CI_ERROR; /*ѩޣʧ*/ + debug_infor_printf((const)"\n PackCiToIvocSnowAndUrgentInfo AreaSnowSum_Error, sum : %d _MAX: %d \n", chAreaSnowTotalNum, LOCAL_AREA_SNOW_SUM_MAX); + } + + /*͵ѩ״̬Ϣ*/ + pRecvCiAreaSnow = GetCiRecvAreaSnowInfo(); + for (kk = 0U; kk < CI_COM_CI_MAX_NUM; kk++) + { + if (0U != pRecvCiAreaSnow[kk].cPlatFormNum) + { + for (jj = 0U; jj < pRecvCiAreaSnow[kk].cPlatFormNum; jj++) + { + if (ALL_AREA_SNOW_SUM_MAX > chAreaSnowTotalNum) + { + LongToChar(pRecvCiAreaSnow[kk].dwPlatFormId[jj], &pDataBuf[ii]); /*ѩվ̨ID*/ + ii += 4U; + chAreaSnowTotalNum++; + } + else + { + debug_infor_printf((const)"\n PackCiToIvocSnowAndUrgentInfo RecvCiAreaSnowSum_Error, sum : %d _MAX: %d \n", pRecvCiAreaSnow, LOCAL_AREA_SNOW_SUM_MAX); + chRetVal = CI_ERROR; /*ѩޣʧ*/ + } + } + } + else + { + /**/ + } + } + pDataBuf[wAreaSnowNumIndex] = chAreaSnowTotalNum; /*ѩվ̨*/ + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvoC״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpFloodInfo(UINT8* pDataBuf, UINT16* wDataLength) +{ + UINT16 wFloodGateId = 0U; /*ID*/ + UINT16 wFloodGateIndex = 0U; + UINT16 wFloodGateSum = 0U; + UINT16 ii = 0U; + UINT8 chRetVal = CI_ERROR; + UINT8 chFloodOpenState = 0U; /*Ϣ*/ + UINT8 chFloodrCloseRequestState = 0U; /**/ + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + chRetVal = CI_SUCCESS; + wFloodGateSum = GetTotalFloodGateCurSum(); + + if (TRAIN_ABL_FLOODGATE_SUM >= wFloodGateSum) + { + pDataBuf[ii++] = (UINT8)wFloodGateSum; + + for (wFloodGateIndex = 0U; wFloodGateIndex < wFloodGateSum; wFloodGateIndex++) + { + wFloodGateId = GetFloodGateId(wFloodGateIndex); + if ((0U < wFloodGateId) && (UINT16_MAX > wFloodGateId)) + { + ShortToChar(wFloodGateId, &pDataBuf[ii]); + ii += 2U; + /*״̬*/ + chFloodOpenState = GetFloodGateCurOpenLockState(wFloodGateId); + chFloodrCloseRequestState = GetFloodGateCurCloseRequestSta(wFloodGateId); + if ((FLOOD_GATE_NOT_OPENLOCK == chFloodOpenState) || (FLOOD_GATE_CLOSEREQ == chFloodrCloseRequestState)) + { + /*Źر״̬й*/ + pDataBuf[ii++] = 0X55U; + } + else if ((FLOOD_GATE_OPENLOCK == chFloodOpenState) && (FLOOD_GATE_NOT_CLOSEREQ == chFloodrCloseRequestState)) + { + pDataBuf[ii++] = 0XAAU; + } + else + { + ; /*Ƿֵ*/ + debug_infor_printf((const)"\n PackCiToIvocBackUpFloodInfo FloodState_Error[chFloodOpenState:%d--chFloodrCloseRequestState:%d] : %d \n", chFloodOpenState,chFloodrCloseRequestState); + /*״ֹ̬ͣ*/ + chRetVal = CI_ERROR; + } + } + else + { + debug_infor_printf((const)"\n PackCiToIvocBackUpFloodInfo wFloodGateId_Error : %d \n", wFloodGateId); + /*IDֹͣ*/ + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS != chRetVal) + { + break; + } + else + { + /*ִ*/ + } + } + } + else + { + /*ŵǰ ֹͣ*/ + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocBackUpFloodInfo FloodGateSum_Error, sum : %d MAX: %d \n", wFloodGateSum, TRAIN_ABL_FLOODGATE_SUM); + } + + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocǰϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* const UINT16 wTrnId VOBC ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20240606 +*/ +static UINT8 PackCiToIvocHeadTrainInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrnId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + HeadTrainLocStru strHeadTrainLocData = { 0U }; + UINT8 chTrainLocReverseRouteFlag = 0U;/*гλ÷·ʶ*/ + + if ((NULL != pDataBuf) && (NULL != wDataLength) && (0U < wTrnId) && (UINT16_MAX > wTrnId)) + { + chRetVal = CI_SUCCESS; + ii = *wDataLength; + + strHeadTrainLocData = GetTrainHeadTrainLocData(wTrnId); + if (0U != strHeadTrainLocData.wHeadVobcId) + { + LongToChar(strHeadTrainLocData.wHeadVobcId,&pDataBuf[ii]); + ii += 4U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocHeadTrainInfo wHeadVobcId %d ERROR \n", strHeadTrainLocData.wHeadVobcId); + } + + if (CI_SUCCESS == chRetVal) + { + pDataBuf[ii++] = strHeadTrainLocData.chHeadTrainLocFlag; + if (HEAD_TRAIN_LOC_ATP == strHeadTrainLocData.chHeadTrainLocFlag) + { + if ((TRAIN_DIR_DEF == strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir) + || (TRAIN_DIR_UP == strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir) + || (TRAIN_DIR_DOWN == strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir)) + { + pDataBuf[ii++] = strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir; + ShortToChar(strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink, &pDataBuf[ii]); + ii += 2U; + LongToChar(strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset, &pDataBuf[ii]); + ii += 4U; + ShortToChar(strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink, &pDataBuf[ii]); + ii += 2U; + LongToChar(strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset, &pDataBuf[ii]); + ii += 4U; + + /*Ԥ4ֽ*/ + ii += 4U; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocHeadTrainInfo chTrainDir %d ERROR \n", strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir); + } + } + else if (HEAD_TRAIN_LOC_ITE == strHeadTrainLocData.chHeadTrainLocFlag) + { + ShortToChar(strHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink, &pDataBuf[ii]); + ii += 2U; + LongToChar(strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset, &pDataBuf[ii]); + ii += 4U; + ShortToChar(strHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink, &pDataBuf[ii]); + ii += 2U; + LongToChar(strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset, &pDataBuf[ii]); + ii += 4U; + + + pDataBuf[ii++] = strHeadTrainLocData.strHeadTrainIteLoc.chTrainDir; + ShortToChar(strHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss, &pDataBuf[ii]); + ii += 2U; + ShortToChar(strHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss, &pDataBuf[ii]); + ii += 2U; + } + else + { + /*ǰɹ˵ǰλϢȡɹλϢ*/ + ; + } + } + else + { + ; /*󲻼*/ + } + + if (CI_SUCCESS == chRetVal) + { + chTrainLocReverseRouteFlag = GetTrainLocReverseRouteFlag(wTrnId); + if ((TRAIN_LOC_REV_ROUTE_FLAG_NONE == chTrainLocReverseRouteFlag) + || (TRAIN_LOC_REV_ROUTE_FLAG_NO == chTrainLocReverseRouteFlag) + || (TRAIN_LOC_REV_ROUTE_FLAG_YES == chTrainLocReverseRouteFlag)) + { + pDataBuf[ii++] = chTrainLocReverseRouteFlag; + } + else + { + chRetVal = CI_ERROR; + debug_infor_printf((const)"\n PackCiToIvocHeadTrainInfo chTrainLocReverseRouteFlag %d ERROR \n", chTrainLocReverseRouteFlag); + } + } + else + { + ; /*󲻼*/ + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* FAOHLHT +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStruct* vobcToCiDataStru VOBCCIṹ +* ֵ 0: ݽʧ +* 1: ݽɹ +* BY CGH 20240606 +*/ +UINT8 ParseFAOHLHTOtherTypeData(const UINT16 appInfoType, UINT8* dataBuf, UINT16 dataLen, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 cmdType = 0u; /**/ + UINT8 trainStopSteadyState = 0u; /*гͣ״̬*/ + UINT8 psdSum = 0u; + UINT8 trainDirection = 0u; /*г*/ + UINT8 ii = 0u; /**/ + UINT8 jj = 0u; + UINT8 retValue = 0u; + UINT16 psdId = 0u; /*PSDID*/ + UINT32 psdIdIntConnt = 0u; /*ͨPSDID*/ + UINT32 trackSectionId = 0u; /*ID*/ + UINT32 signalId = 0u; /*VOBC->CIźŻID*/ + UINT8 gapDetCmdType = 0u; /*϶̽*/ + UINT8 doorState = 0u; /*VOBC-CI״̬*/ + UINT8 cTempPsdCmdCode = 0U; + UINT8 chVideoQkState = 0U;/*Ƶ״̬*/ + UINT8 chVideoQkResult = 0U;/*Ƶͽ*/ + UINT16 wTempAppInfoType = 0U; + + if (NULL == dataBuf) + { + chRetVal = CI_ERROR; + } + else + { + chRetVal = CI_SUCCESS; + + if (VOBC_CI_INFO_TYPE_PSD_CONTROL == appInfoType) + { /*ֻеVOBCCIϢſƱʱżϢ*/ + /*гзж*/ + vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + trainDirection = dataBuf[ii]; + ii += 1u; + + if ((TRAIN_DIR_UP == trainDirection) || (TRAIN_DIR_DOWN == trainDirection) || (TRAIN_DIR_DEF == trainDirection)) + { + vobcToCiDataStru->trainDirection = trainDirection; + } + else + { + chRetVal = CI_ERROR; + } + + /*гͣͣ׼Ϣνж*/ + if (CI_SUCCESS == chRetVal) + { + trainStopSteadyState = dataBuf[ii]; + ii += 1u; + + if ((VOBC_CI_STOP_TW == trainStopSteadyState) || (VOBC_CI_STOP_WTW == trainStopSteadyState)) + { + vobcToCiDataStru->trainStopSteadyState = trainStopSteadyState; + vobcToCiDataStru->stopSteadyStartCycNum = Get2oo2CurCycleNum();/*¼յͣȻδͣϢ*/ + } + else + { + chRetVal = CI_ERROR; + } + } + + trackSectionId = LongFromChar(&dataBuf[ii]);/*ȡID*/ + ii += 4u; + vobcToCiDataStru->trackSecID = trackSectionId; + + if (CI_SUCCESS == chRetVal) + { + vobcToCiDataStru->VobcId = systemId; /*VOBCID*/ + vobcToCiDataStru->psdCmdCode = dataBuf[ii++]; /*վ̨룬ÿӦCIҪһվ̨*/ + /*վ̨ȡϢĵ5λʾгʵʱ*/ + + /*ΪڹʱVOBCͳĬֵ,Ҫڿʱ泵ֵ*/ + cTempPsdCmdCode = 0x1Fu & vobcToCiDataStru->psdCmdCode; + if (0U != cTempPsdCmdCode) /*ȱYF0083-6822023-07-03*/ + { + vobcToCiDataStru->trainEditGroupInfo = cTempPsdCmdCode; + } + else + { + vobcToCiDataStru->trainEditGroupInfo = vobcToCiDataStru->trainEditGroupInfo; + } + + psdSum = dataBuf[ii]; + ii += 1u; + + if ((2u == psdSum) || (1u == psdSum) || (0u == psdSum)) + {/*ӿڶ壺ȡֵΪ012*/ + vobcToCiDataStru->PsdSum = psdSum; /**/ + } + else + { + chRetVal = CI_ERROR; + } + } + + if (CI_SUCCESS == chRetVal) + { + for (jj = 0u; jj < 2u; jj++) + { + psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*ȡͨ4ֽID*/ + ii += 4u; + vobcToCiDataStru->PsdData[jj].PsdIdInterConn = psdIdIntConnt; + + /*ݻͨ4ֽIDȡID*/ + retValue = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId); + + if (CI_SUCCESS == retValue) + { + vobcToCiDataStru->PsdData[jj].PsdId = psdId; + + cmdType = dataBuf[ii];/*ȡ*/ + ii += 1u; + if ((VOBCTOCI_COMMAND_TYPE_PSDOPEN == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCLOSE == cmdType) || (VOBCTOCI_COMMAND_TYPE_PSDCHECK_FAOHLHT == cmdType)) /*ȱYF0083-6822023-07-03*/ + { + vobcToCiDataStru->PsdData[jj].CmdType = cmdType; + vobcToCiDataStru->PsdData[jj].CmdStartCycNum = Get2oo2CurCycleNum(); + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ii++; + } + } + + /*µĽӿڣźŻID1~0xFFFFFFFF,0ΪĬֵVOBCȫǰǰгзͬźŻ*/ + signalId = LongFromChar(&dataBuf[ii]); /*ȡźŻID*/ + ii += 4u; + vobcToCiDataStru->signalID = signalId; /*źŻID浽ṹ*/ + } + + /*VOBC2CIȫԶվ̨Ϣ϶ֹ̽ͣVOBC2CIվ̨ſϢһ*/ + ii += 2u;/*Ӧñij2ֽ*/ + wTempAppInfoType = ShortFromChar(&dataBuf[ii]);/*ӦϢͣſϢ֡Ϣ*/ + ii += 2u; + ii += 2u;/*Ԥֽ*/ + + if (VOBC_CI_INFO_TYPE_FAO_CONTROL == wTempAppInfoType) + {/*ΪȫԶվ̨Ϣ*/ + psdSum = dataBuf[ii]; + ii += 1u; + + if ((2u == psdSum) || (1u == psdSum) || (0u == psdSum)) + {/*ӿڶ壺ȡֵΪ012*/ + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + {/*˴CIĬVOBC͵FAOվ̨ϢPSD ID˳PSDϢPSD ID˳ȫһ¡*/ + for (jj = 0u; jj < 2u; jj++) + { + psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*ȡͨ4ֽID*/ + ii += 4u; + + /*ݻͨ4ֽIDȡID*/ + retValue = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId); + + if (CI_SUCCESS == retValue) + { + gapDetCmdType = dataBuf[ii];/*ȡ*/ + ii += 1u; + + if ((VOBC_CI_GAP_DETECT_CMD_START == gapDetCmdType) || (VOBC_CI_GAP_DETECT_CMD_STOP == gapDetCmdType) + || (VOBC_CI_GAP_DETECT_CMD_DEFAULT == gapDetCmdType)) + {/*жϼ϶̽Ч*/ + vobcToCiDataStru->PsdData[jj].gapDetectCmd = gapDetCmdType; + } + else + { + chRetVal = CI_ERROR; + } + + } + else + { + ii += 1u; /*϶̽*/ + } + } + } + } + else if (VOBC_CI_INFO_TYPE_MANU_DEFINED == wTempAppInfoType) + {/*Զ֡ݸ³״̬Ϣ*/ + + psdSum = dataBuf[ii]; + ii += 1u; + + if ((2u == psdSum) || (1u == psdSum) || (0u == psdSum)) + {/*ӿڶ壺ȡֵΪ012*/ + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + {/*˴CIĬVOBC͵VOBC״̬ϢPSD ID˳PSDϢPSD ID˳ȫһ¡*/ + for (jj = 0u; jj < 2u; jj++) + { + psdIdIntConnt = LongFromChar(&dataBuf[ii]);/*ȡͨ4ֽID*/ + ii += 4u; + vobcToCiDataStru->PsdData[jj].PsdIdInterConn = psdIdIntConnt; + + /*ݻͨ4ֽIDȡID*/ + retValue = dquQueryInDevIndex(QFUN_IDMAP_PSD_ID, psdIdIntConnt, &psdId); + + if (CI_SUCCESS == retValue) + { + vobcToCiDataStru->PsdData[jj].PsdId = psdId; + + doorState = dataBuf[ii];/*ȡVOBC״̬*/ + ii += 1u; + + if ((VOBC_CI_DOOR_CLOSEDANDLOCKED == doorState) || (VOBC_CI_DOOR_NOTCLOSEDANDLOCKED == doorState)) + { /*VOBC״̬Ч*/ + vobcToCiDataStru->PsdData[jj].VOBCDoorState = doorState; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + ii += 1u; /*VOBC״̬*/ + } + } + } + + /*ƵϢ*/ + if (CI_SUCCESS == chRetVal) + { + /*Ƶ״̬*/ + chVideoQkState = dataBuf[ii]; + ii++; + /*Ƶͽ*/ + chVideoQkResult = dataBuf[ii]; + ii++; + + if (((VIDEO_QK_STATE_TESTING == chVideoQkState) || (VIDEO_QK_STATE_DEFAULT == chVideoQkState)) + && ((VIDEO_QK_RESULT_TESTNO == chVideoQkResult) || (VIDEO_QK_RESULT_TESTHAVE == chVideoQkResult) || (VIDEO_QK_RESULT_TESTDEFAULT == chVideoQkResult)) + && (PSD_SUM_MAX > vobcToCiDataStru->PsdData[0].PsdId) && (PSD_SUM_MAX > vobcToCiDataStru->PsdData[1].PsdId)) + { + vobcToCiDataStru->chVideoQkState = chVideoQkState; + vobcToCiDataStru->chVideoQkResult = chVideoQkResult; + vobcToCiDataStru->wVideoQkRelatePsdId1 = vobcToCiDataStru->PsdData[0].PsdId; + vobcToCiDataStru->wVideoQkRelatePsdId2 = vobcToCiDataStru->PsdData[1].PsdId; + } + else + { + chRetVal = CI_ERROR;; + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else if (VOBC_CI_INFO_TYPE_FAO_INFO == appInfoType) + {/*VOBC->CIȫԶϴϢ*/ + vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); /*CI-VOBC ͨſʼ*/ + /*ȫԶϴϢ*/ + + /*ϴϢУ鼰洢*/ + chRetVal = WashTrainRequestCheck(dataBuf[ii]); + + if (CI_SUCCESS == chRetVal) + { + vobcToCiDataStru->washTrainRequest = dataBuf[ii]; + ii += 1U; + /*ϴͣ1ϢУ鼰洢*/ + chRetVal = HeadWashStopSteadyInfoCheck(dataBuf[ii]); + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + vobcToCiDataStru->headWashStopSteadyInfo = dataBuf[ii]; + ii += 1U; + /*ͣϴϢ洢*/ + chRetVal = WashPauseRequestCheck(dataBuf[ii]); + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + vobcToCiDataStru->washPauseRequest = dataBuf[ii]; + ii += 1U; + /*ϴͣ2Ϣ洢*/ + chRetVal = TailWashStopSteadyInfoCheck(dataBuf[ii]); + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + vobcToCiDataStru->tailWashStopSteadyInfo = dataBuf[ii]; + ii += 1U; + /*ͨϴϢ洢*/ + chRetVal = PassWashMachineRequestCheck(dataBuf[ii]); + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + /*ϴģʽϢ洢*/ + vobcToCiDataStru->passWashMachineRequest = dataBuf[ii]; + ii += 1U; + chRetVal = WashMachineWorkModeCheck(dataBuf[ii]); + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + vobcToCiDataStru->chWashMachineWorkMode = dataBuf[ii]; + ii += 1U; + } + else + { + chRetVal = CI_ERROR; + } + } + else if ((VOBC_CI_INFO_TYPE_HEART_FRAME == appInfoType) || (VOBC_CI_INFO_TYPE_LOGOUT_ASK == appInfoType)) + {/*֡ע֡*/ + vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + } + else + { + chRetVal = CI_ERROR; + } + } + + + if (dataLen != ii) + { + debug_infor_printf((const)"\nVOBC %d DATALEN1 CHECK ERR,dataLen:%d,ii:%d", systemId, dataLen, ii); + chRetVal = CI_ERROR; + } + else + { + ; /* do nothing */ + } + return chRetVal; +} + +/* +* FAOHLHTпϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* VobcToCiDataStruct* vobcToCiDataStru VOBCCIṹ +* ֵ 0: ݽʧ +* 1: ݽɹ +* BY CGH 20240606 +*/ +UINT8 ParseFAOHLHTBackUpControlData(UINT8* dataBuf, UINT16 dataLen, VobcToCiDataStruct* vobcToCiDataStru) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 chTrainLevel = 0U;/*гпƼ*/ + UINT8 chTrainDirection = 0U;/*з*/ + UINT16 wMaxHeadLink = 0U; /*гȫǰLink*/ + UINT32 dwMaxHeadOff = 0U; /*гȫǰƫ*/ + UINT16 wMinTailLink = 0U; /*гСȫLink*/ + UINT32 dwMinTailOff = 0U; /*гСȫƫ*/ + UINT32 dwHlhtNs = 0U;/*ͨID*/ + UINT16 wHeadTrainId = 0U;/*ǰID*/ + UINT16 wTrainRelLgcId = 0U; + UINT16 wHeadSignalId = 0U;/*ǰźŻID*/ + UINT8 chNvramPosFlag = 0U; + UINT8 chStopSteayFlag = 0U; /*ͣȱ־*/ + UINT32 dwTrackSecId = 0U; /**/ + + if ((NULL == dataBuf) || (NULL == vobcToCiDataStru)) + { + chRetVal = CI_ERROR; + } + else + { + chRetVal = CI_SUCCESS; + + vobcToCiDataStru->ComStartCycle = Get2oo2CurCycleNum(); + /*гпƼЧУ*/ + chTrainLevel = dataBuf[ii++]; + if ((TRAIN_LEVEL_BACKUP_LIANXU == chTrainLevel) || (TRAIN_LEVEL_BACKUP_BLOCK == chTrainLevel) || (TRAIN_LEVEL_BACKUP_CI == chTrainLevel) + || (TRAIN_LEVEL_BACKUP_ABL == chTrainLevel) || (TRAIN_LEVEL_BACKUP_UNKNOWN == chTrainLevel)) + { + vobcToCiDataStru->chTrainLevel = chTrainLevel; + } + else + { + debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,chTrainLevel:%d", vobcToCiDataStru->VobcId, chTrainLevel); + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + /*гзж*/ + chTrainDirection = dataBuf[ii++]; + if ((TRAIN_DIR_UP == chTrainDirection) || (TRAIN_DIR_DOWN == chTrainDirection) || (TRAIN_DIR_DEF == chTrainDirection)) + { + vobcToCiDataStru->trainDirection = chTrainDirection; + } + else + { + debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,chTrainDirection:%d", vobcToCiDataStru->VobcId, chTrainDirection); + chRetVal = CI_ERROR; + } + } + else + { + ; + } + + /*ȡֵУ*/ + if (CI_SUCCESS == chRetVal) + { + wMaxHeadLink = ShortFromChar(&dataBuf[ii]); /*гȫǰLink*/ + ii += 2U; + dwMaxHeadOff = LongFromChar(&dataBuf[ii]); /*гȫǰƫ*/ + ii += 4U; + wMinTailLink = ShortFromChar(&dataBuf[ii]); /*гСȫLink*/ + ii += 2U; + dwMinTailOff = LongFromChar(&dataBuf[ii]); /*гСȫƫ*/ + ii += 4U; + + if ((0u != wMaxHeadLink) && (UINT16_MAX != wMaxHeadLink) + && (0u != wMinTailLink) && (UINT16_MAX != wMinTailLink) + && (UINT32_MAX != dwMaxHeadOff) && (UINT32_MAX != dwMinTailOff)) + { + vobcToCiDataStru->wTrainMaxSafeHeadLink = wMaxHeadLink; + vobcToCiDataStru->dwTrainMaxSafeHeadOffset = dwMaxHeadOff; + vobcToCiDataStru->wTrainMinSafeTailLink = wMinTailLink; + vobcToCiDataStru->dwTrainMinSafeTailOffset = dwMinTailOff; + } + else + { + debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,wMaxHeadLink:%d,dwMaxHeadOff:%d,wMinTailLink:%d,dwMinTailOff:%d", vobcToCiDataStru->VobcId, wMaxHeadLink, dwMaxHeadOff, wMinTailLink, dwMinTailOff); + chRetVal = CI_ERROR; /*ֵǷ*/ + } + } + else + { + ; /**/ + } + + /*źŻID*/ + if (CI_SUCCESS == chRetVal) + { + dwHlhtNs = LongFromChar(&dataBuf[ii]); + ii += 4U; + if (0x00000000U == dwHlhtNs) + { + /*ĬֵǰźŻIDΪ0*/ + vobcToCiDataStru->wHeadSigId = 0U; + } + else + { + /*ݻͨ4ֽIDȡźŻID*/ + chRetVal = dquQueryInDevIndex(QFUN_IDMAP_SIGNAL_ID, dwHlhtNs, &wHeadSignalId); + if ((CI_SUCCESS == chRetVal) && (SIGNAL_SUM_MAX > wHeadSignalId)) + { + vobcToCiDataStru->wHeadSigId = wHeadSignalId; + } + else + { + chRetVal = CI_ERROR; + + debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,wFaoHlhtBackUpInfoSigId:%d", vobcToCiDataStru->VobcId, dwHlhtNs); + + } + } + } + else + { + + } + + /*ǰID*/ + if (CI_SUCCESS == chRetVal) + { + dwHlhtNs = LongFromChar(&dataBuf[ii]); + ii += 4U; + if (0xFFFFFFFFU == dwHlhtNs) + { + /*ĬֵǰIDΪ0*/ + vobcToCiDataStru->wHeadVobcId = 0x14FFU; + } + else + { + chRetVal = dquHlhtId2VobcName(dwHlhtNs, &wHeadTrainId, &wTrainRelLgcId); + if (CI_SUCCESS == chRetVal) + { + vobcToCiDataStru->wHeadVobcId = wHeadTrainId; + } + else + { + debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,wHeadTrainId dwHlhtNs:%d", vobcToCiDataStru->VobcId, dwHlhtNs); + + chRetVal = CI_ERROR; + } + } + } + else + { + ; /**/ + } + + /*NVRAMλñʶ*/ + if (CI_SUCCESS == chRetVal) + { + chNvramPosFlag = dataBuf[ii++]; + if ((TRAIN_NVRAM_POS_FLAG_YES == chNvramPosFlag) || (TRAIN_NVRAM_POS_FLAG_NO == chNvramPosFlag)) + { + vobcToCiDataStru->chNvramPosFlag = chNvramPosFlag; + } + else + { + debug_infor_printf((const)"\nVOBC %d ParseFAOHLHTBackUpControlData ERR,chNvramPosFlag:%d", vobcToCiDataStru->VobcId, chNvramPosFlag); + chRetVal = CI_ERROR; + } + } + else + { + ; /**/ + } + + /*гͣ״̬*/ + if (CI_SUCCESS == chRetVal) + { + + chStopSteayFlag = dataBuf[ii]; + ii += 1U; + dwTrackSecId = LongFromChar(&dataBuf[ii]); + ii += 4U; + if ((VOBC_CI_STOP_TW == chStopSteayFlag) || (VOBC_CI_STOP_WTW == chStopSteayFlag)) + { + vobcToCiDataStru->trainStopSteadyState = chStopSteayFlag; + vobcToCiDataStru->stopSteadyStartCycNum = Get2oo2CurCycleNum(); + vobcToCiDataStru->trackSecID = dwTrackSecId; + } + else + { + debug_infor_printf((const)"\nVOBC_BACK_UP %d chStopSteayFlag : %d\n", vobcToCiDataStru->VobcId, chStopSteayFlag); + chRetVal = CI_ERROR; + } + } + } + + + if (dataLen != (ii + 5U)) + { + chRetVal = CI_ERROR; + + debug_infor_printf((const)"\nVOBC %d DATALEN2 CHECK ERR,dataLen:%d,ii:%d", vobcToCiDataStru->VobcId, dataLen, ii); + } + else + { + ; /* do nothing */ + } + return chRetVal; +} + +/* +* CiVOBCͨźŻ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20240607 +*/ +static UINT8 PackCiToVobcSigInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT32 dwSigHlhtId = 0U;/*źŻͨID*/ + UINT8 chRouteState = 0U;/*·״̬*/ + UINT16 wStatrSigRtSum = 0U;/*ȡԸźŻΪʼźŻĽ·Ŀ*/ + UINT16* szStartSigRouteBuf = NULL;/*ȡԸźŻΪʼźŻĽ·*/ + UINT8 chSigState = 0U;/*źŻ״̬*/ + UINT16 wSigId = 0U;/*źŻID*/ + UINT8 chRouteLevel = 0U;/*·ල*/ + UINT8 chKeepFlag = CI_ERROR;/*־*/ + UINT8 chRouteReverseProperty = 0U; + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + wSigId = GetTrainHeadSigId(wTrainId); + + if (0U == wSigId) + { + LongToChar(0U, &pDataBuf[ii]); + ii += 4U; + pDataBuf[ii++] = CI_VOBC_SIGNAL_DEFAULT; + } + else + { + chRetVal = dquQueryOutDevId(QFUN_IDMAP_SIGNAL_ID, wSigId, &dwSigHlhtId); + if (CI_SUCCESS == chRetVal) + { + LongToChar(dwSigHlhtId, &pDataBuf[ii]); + ii += 4U; + chSigState = CI_VOBC_SIGNAL_DEFAULT; + /*ԸźŻΪʼźŻĽ·һ·״̬ΪԤȿŻӽ1*/ + wStatrSigRtSum = GetStartSignalRouteSum(wSigId);/*ȡԸźŻΪʼźŻĽ·Ŀ*/ + szStartSigRouteBuf = GetStartSignalRouteBuf(wSigId);/*ȡԸźŻΪʼźŻĽ·*/ + if (0U != wStatrSigRtSum) + { + for (jj = 0U; jj < wStatrSigRtSum; jj++) + {/*źŻΪʼźŻĿŵĽ·ID*/ + chRouteLevel = GetRouteLevel(szStartSigRouteBuf[jj]); + if (ROUTE_LEVEL_BLOC == chRouteLevel) + { + chRouteState = GetRouteState(szStartSigRouteBuf[jj]);/*ȡ·״̬*/ + if ((ROUTE_STATE_YUXIAN_OPEN == chRouteState) || (ROUTE_STATE_NEAR_OPEN == chRouteState)) + { + chRouteReverseProperty = GetRouteReverseProperty(szStartSigRouteBuf[jj]); + if (ROUTE_REVERSE_PROPERTY_YES == chRouteReverseProperty) + { + /*·Ϊ·״̬ΪĬ*/ + chSigState = CI_VOBC_SIGNAL_DEFAULT; + } + else + { + chSigState = CI_VOBC_SIGNAL_YES; + } + chKeepFlag = CI_SUCCESS; + } + else if ((ROUTE_STATE_AUTO_UNLOCK == chRouteState) || (ROUTE_STATE_NEAR_LOCK == chRouteState)) + { + chSigState = CI_VOBC_SIGNAL_NO; + /*ֹźţرգ0XAAӽԶ*/ + chKeepFlag = CI_SUCCESS; + } + else if ((ROUTE_STATE_FIRST_LOCKERR == chRouteState) || (ROUTE_STATE_YUXIAN_LOCK == chRouteState) + || (ROUTE_STATE_NEAR_LOCKERR == chRouteState) || (ROUTE_STATE_DELAY_UNLOCK == chRouteState) + || (ROUTE_STATE_AUTO_UNLOCKERR == chRouteState)) + { + chSigState = CI_VOBC_SIGNAL_ERR; + /*ֹźţ쳣رգ0XCC·״̬Ϊ쳣Ԥաӽ쳣ʱԶ쳣*/ + chKeepFlag = CI_SUCCESS; + } + else if (ROUTE_STATE_IDLE == chRouteState) + { + ; /*мһ*/ + } + else + { + /*Ĭֵ0XFF:ѡѡšѡšա쳣šճѡѡšաֽ·ȴֽ·ʱ*/ + chSigState = CI_VOBC_SIGNAL_DEFAULT; + chKeepFlag = CI_SUCCESS; + } + } + else + { + /*·ලǰս·ʼźŻжϣֻҪһ·ලǺ󱸣˳ңĬ*/ + chKeepFlag = CI_SUCCESS; + chSigState = CI_VOBC_SIGNAL_DEFAULT; + } + + if (CI_SUCCESS == chKeepFlag) + { + break; + } + else + { + ; /**/ + } + } + } + else + { + ; /*ƥ·,״̬ΪĬ*/ + } + pDataBuf[ii++] = chSigState; + } + else + { + debug_infor_printf((const)"\n PackCiToIvocBackUpSigInfo wSigId: %d error\n", wSigId); + } + } + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CIVOBC״̬ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* VobcToCiDataStruct *pstVobcToCiDataStru VOBCCI +* ֵ 0:ʧ +* 1:ݳɹ +* by cgh 20240704 +*/ +static UINT8 PackCiToVobcBackUpStateData(UINT8* pDataBuf, UINT16* wDataLength,VobcToCiDataStruct* pstVobcToCiDataStru) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + + if ((NULL == pDataBuf) || (NULL == wDataLength) || (NULL == pstVobcToCiDataStru)) + { + chRetVal = CI_ERROR; + } + else + { + ii = *wDataLength; + + /*鱸ͨ߼Ϣ*/ + chRetVal = PackCiToIvocBackUpLogSecInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + + if (CI_SUCCESS == chRetVal) + { + /*鱸ͨĽ·Ϣ*/ + chRetVal = PackCiToIvocBackUpRouteInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpLogSecInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + /*鱸ͨ۷߼Ϣ*/ + chRetVal = PackCiToIvocBackUpReturnLogInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpRouteInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + /*鱸ͨPSDϢ*/ + chRetVal = PackCiToIvocBackUpPsdInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpReturnLogInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨѼSPKSϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpSpksInfo(pDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpPsdInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨESBϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpEsbInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpSpksInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpSwitchInfo(pDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpEsbInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨı״̬Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpProtectLgcInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpSwitchInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨTSRϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpTsrInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpProtectLgcInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨ״̬ȷϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpReqStateInfo(pDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpTsrInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨķϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocBackUpFloodInfo(pDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpReqStateInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨźŻ״̬Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToVobcSigInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocBackUpFloodInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨǰλϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocHeadTrainInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToVobcSigInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨITEȫгϢ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocIteLineCutInfo(pDataBuf, &ii); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocHeadTrainInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + /*鱸ͨԶδռ߼Ϣ*/ + if (CI_SUCCESS == chRetVal) + { + chRetVal = PackCiToIvocFarNoOccuLogInfo(pDataBuf, &ii, pstVobcToCiDataStru->VobcId); + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocIteLineCutInfo Error \n", pstVobcToCiDataStru->VobcId); + } + + if (CI_SUCCESS == chRetVal) + { + /*ɹ*/ + } + else + { + /**/ + debug_infor_printf((const)"\n FAOHLHTVOBC_BACKUP: %d PackCiToIvocFarNoOccuLogInfo Error \n", pstVobcToCiDataStru->VobcId); + } + } + + if (CI_SUCCESS == chRetVal) + { + ii += 8U; + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* CiIvocITEȫг״̬ +* ˵const UINT8* dataBuf ݻΣ +* const UINT16 *dataLength ݳȣΣ +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.07.12 +*/ +static UINT8 PackCiToIvocIteLineCutInfo(UINT8* pDataBuf, UINT16* wDataLength) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 cIteLineCutState = CI_ITE_LINE_CUT_INVALID;/* ITEȫг״̬ */ + + if ((NULL != pDataBuf) && (NULL != wDataLength)) + { + ii = *wDataLength; + + /* ITEȫг״̬ */ + cIteLineCutState = GetIteLineCutState(); + if ((CI_ITE_LINE_CUT_VALID == cIteLineCutState) || (CI_ITE_LINE_CUT_INVALID == cIteLineCutState)) + { + pDataBuf[ii] = cIteLineCutState; + } + else + { + pDataBuf[ii] = CI_ITE_LINE_CUT_DEFAULT; /* Ĭֵ */ + } + + ii++; + + *wDataLength = ii; /*ݳ*/ + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + + + +/* +* CiIvocԶδռ߼ + * ˵ UINT8* dataBuf, ݻ + * UINT16 *dataLength, ݳ + * UINT16 wTrainId гID +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LC +*/ +static UINT8 PackCiToIvocFarNoOccuLogInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 farLogSecId = 0U; + + if ((NULL == pDataBuf) || (NULL == wDataLength)) + { + chRetVal = CI_ERROR; + } + else + { + + ii = *wDataLength; + chRetVal = CI_SUCCESS; + + + farLogSecId = GetTrainAblNoOccuFarLogId(wTrainId); + + if (LOGIC_SECTION_SUM_MAX > farLogSecId) + { + ShortToChar(farLogSecId, &pDataBuf[ii]); + ii += 2U; + } + else if (UINT16_MAX == farLogSecId) + { + ShortToChar(UINT16_MAX, &pDataBuf[ii]); + ii += 2U; + } + else + { + ShortToChar(0U, &pDataBuf[ii]); + ii += 2U; + } + } + + if (CI_SUCCESS == chRetVal) + { + *wDataLength = ii; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; + +} + +/* +* CiIvocNVRAMλüල״̬ +* ˵const UINT8* dataBuf ݻΣ +* const UINT16 *dataLength ݳȣΣ +* const UINT16 wTrainId гID +* ֵCI_ERROR 0 ʧ +* CI_SUCCESS 1 ɹ +* Created By LQ 2024.08.19 +*/ +static UINT8 PackCiToIvocPosMonitorInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wTrainIndex = 0U; + UINT16 ii = 0U; + UINT8 cTrainPosMonitorState = TRAIN_POS_MONITOR_INVALID; /* гλüල״̬ */ + + wTrainIndex = GetTrainBufIndex(wTrainId); + if ((NULL != pDataBuf) && (NULL != wDataLength) && (TRAIN_SUM_MAX > wTrainIndex)) + { + ii = *wDataLength; + + /* гλüල״̬ */ + cTrainPosMonitorState = GetTrainPosMonitorState(wTrainId); + if (TRAIN_POS_MONITOR_VALID == cTrainPosMonitorState) + { + pDataBuf[ii] = TRAIN_POS_MONITOR_VALID; /*ලЧ*/ + } + else if (TRAIN_POS_MONITOR_DIFF == cTrainPosMonitorState) + { + pDataBuf[ii] = TRAIN_POS_MONITOR_DIFF; /* ලλòһ */ + } + else + { + pDataBuf[ii] = TRAIN_POS_MONITOR_INVALID; /* ලЧ */ + } + + ii++; + + *wDataLength = ii; /*ݳ*/ + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackVobcData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackVobcData.h new file mode 100644 index 0000000..124cb4e --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackVobcData.h @@ -0,0 +1,690 @@ +/******************************************************** +* +* ParsePackVobcData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* Vobcݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_VOBC_DATA_H_ +#define _PARSE_PACK_VOBC_DATA_H_ + + +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "CiInterfaceDefine.h" +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../DataManage/DeviceDataManage.h" +#include "../ParsePack/ParsePackAtsData.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../Relay/RelayDataManage.h" +#include "../ParsePack/ParsePackPlatformData.h" +#include "../PSD/PSDConfigDataManage.h" +#include "../PSD/PSDDataManage.h" +#include "../WashMachine/WashMachineConfigDataManage.h" +#include "../WashMachine/WashMachineDataManage.h" +#include "../System/SystemParameterManage.h" +#include "../IO/DeviceRelayDataProcess.h" +#include "dquIdmapQuery.h" +#include "../Section/LogicSectionConfigDataManage.h" + + +#define CI_PSD_COMM_STATE_GOOD ((UINT8)0x55) +#define CI_PSD_COMM_STATE_BAD ((UINT8)0xAA) + + + +#define VOBC_CI_STOP_TW ((UINT8)0x55) /*VOBCCIгͣ*/ +#define VOBC_CI_STOP_WTW ((UINT8)0xAA) /*VOBCCIгδͣ*/ + +#define CI_VOBC_SIGNAL_YES ((UINT8)0x55) /*CIVOBCվź*/ +#define CI_VOBC_SIGNAL_NO ((UINT8)0xAA) /*CIVOBCվֹź(ر)*/ +#define CI_VOBC_SIGNAL_ERR ((UINT8)0xCC) /*CIVOBCվֹź(쳣ر)*/ +#define CI_VOBC_SIGNAL_DEFAULT ((UINT8)0xFF) /*CIVOBCվźĬ״̬*/ + +#define CI_VOBC_NO_LOCK ((UINT8)0x00) /*CIͨվֱշĬֵ*/ + +#define CI_VOBC_INTERFACE_INFOTYPE ((UINT16)0x0206) /*ͨCI_VOBCӿϢ*/ +#define CI_VOBC_BACKUP_INTERFACE_INFOTYPE ((UINT16)0x0402) /*ģʽCI_VOBCӿϢ*/ +#define VOBC_CI_INFO_TYPE_PSD_CONTROL ((UINT16)0x0201) /*VOBC_CIſƱ*/ +#define VOBC_CI_INFO_TYPE_BACKUP ((UINT16)0x0308) /*VOBC_CIͨ*/ +#define CI_VOBC_INFO_TYPE_PSD_STATE ((UINT16)0x0202) /*CI_VOBC״̬Ʊ*/ +#define VOBC_CI_INFO_TYPE_HEART_FRAME ((UINT16)0x0203) /*VOBC_CI֡*/ +#define CI_VOBC_INFO_TYPE_HEART_FRAME ((UINT16)0x0204) /*CI_VOBC֡*/ +#define VOBC_CI_INFO_TYPE_CITY_DEFINED ((UINT16)0x0205) /*VOBC_CIԶ֡*/ +#define CI_VOBC_INFO_TYPE_CITY_DEFINED ((UINT16)0x0206) /*CI_VOBCԶ֡*/ +#define VOBC_CI_INFO_TYPE_MANU_DEFINED ((UINT16)0x0207) /*VOBC_CIԶ֡*/ +#define CI_VOBC_INFO_TYPE_MANU_DEFINED ((UINT16)0x0208) /*CI_VOBCԶ֡*/ +#define VOBC_CI_INFO_TYPE_LOGOUT_ASK ((UINT16)0x0209) /*VOBC_CIע֡*/ +#define CI_VOBC_INFO_TYPE_LOGOUT_ACK ((UINT16)0x020a) /*CI_VOBCעظ֡*/ +#define VOBC_CI_INFO_TYPE_FAO_INFO ((UINT16)0x020b) /*VOBC_CIȫԶϴϢ֡*/ +#define CI_VOBC_INFO_TYPE_FAO_INFO ((UINT16)0x020c) /*CI_VOBCȫԶϴϢ֡*/ +#define CI_VOBC_PLAT_CLEAR_PASSENGER_INFO ((UINT16)0x020d) /*CI_VOBCȫԶվ̨״̬Ϣ֡*/ +#define VOBC_CI_INFO_TYPE_FAO_CONTROL ((UINT16)0x020e) /*VOBC_CIȫԶվ̨Ϣ֡ͣ϶̽*/ +#define CI_VOBC_BACKUP_STATE_INFO ((UINT16)0x0211) /*CI=>VOBC״̬Ϣ*/ +#define VOBC_CI_INFO_TYPE_BACKUU_CONTROL ((UINT16)0x0212) /*VOBC=>CIпϢ*/ + +#define VOBC_CI_GAP_DETECT_CMD_START ((UINT8)0x55) /*VOBC2CI϶̽*/ +#define VOBC_CI_GAP_DETECT_CMD_STOP ((UINT8)0xAA) /*VOBC2CIֹͣ϶̽*/ +#define VOBC_CI_GAP_DETECT_CMD_DEFAULT ((UINT8)0xFF) /*VOBC2CIĬϼ϶̽*/ + +#define VOBC_CI_DOOR_CLOSEDANDLOCKED ((UINT8)0x55) /*VOBC2CIŹر*/ +#define VOBC_CI_DOOR_NOTCLOSEDANDLOCKED ((UINT8)0xAA) /*VOBC2CIŷǹرգDefault Value*/ + +#define CI_VOBC_GAP_DETECT_STATUS_CLEAR ((UINT8)0x55) /*CI2VOBC϶̽״̬Ѽϰ*/ +#define CI_VOBC_GAP_DETECT_STATUS_UNCLEAR ((UINT8)0xAA) /*CI2VOBC϶̽״̬Ѽϰ*/ +#define CI_VOBC_GAP_DETECT_STATUS_DEFAULT ((UINT8)0xFF) /*CI2VOBC϶̽״̬δ/޴˹ܣDefault Value*/ + +#define CI_VOBC_PRTCL_VER ((UINT8)0x01) /*CI_VOBCЭ汾*/ +#define CI_VOBC_PRTCL_VER_FAOHLHT ((UINT8)0x65) /*CI_VOBCЭ汾101*/ +#define CI_VOBC_BACKUP_PRTCL_VER ((UINT8)0x66) /*CI_VOBCͨӿЭ汾*/ + +#define CI_VOBC_REMOVE_YES ((UINT8)0x55) /*Ч*/ +#define CI_VOBC_REMOVE_NO ((UINT8)0xAA) /*Ч*/ +#define CI_VOBC_REMOVE_OFF ((UINT8)0xFF) /*Ĭֵ*/ + +#define IVOC_CI_INTERFACE_INFOTYPE ((UINT16)0x0106U) /*IVOC-OCӿ*/ +#define IVOC_CI_BACKUP_INTERFACE_INFOTYPE ((UINT16)0x0402) /*RC/CI-IVOCӿ(ͨ)*/ +#define IVOC_CI_INFO_TYPE_CONTROL ((UINT16)0x0201U) /*IVOC->OCϢڷ*/ +#define CI_IVOC_INFO_TYPE_STATE ((UINT16)0x0202U) /*OC->IVOC״̬Ϣڷ*/ +#define IVOC_CI_BACKUPINFO_TYPE_CONTROL ((UINT16)0x0308U) /*IVOC->OCͨ״̬Ϣڷ*/ +#define CI_IVOC_BACKUPINFO_TYPE_STATE ((UINT16)0x0309U) /*OC->IVOCͨϢڷ*/ +#define IVOC_CI_INFO_TYPE_LOGOUT_ASK ((UINT16)0x0203U) /*IVOC->OCע֡*/ +#define CI_IVOC_INFO_TYPE_LOGOUT_ACK ((UINT16)0x0204U) /*OC->IVOCעظ֡*/ +#define IVOC_CI_INFO_TYPE_HEART_FRAME ((UINT16)0x0205U) /*IVOC->OC֡*/ +#define CI_IVOC_INFO_TYPE_HEART_FRAME ((UINT16)0x0206U) /*OC->IVOC֡*/ + +#define CI_IVOC_PRTCL_VER ((UINT8)0x01U) /*CI_VOBCЭ汾*/ +#define CI_IVOC_BACKUP_PRTCL_VER ((UINT8)0x066) /*CI_VOBCͨЭ汾*/ + +#define IVOC_CI_CMD_MAX ((UINT16)100U) /*IVOC CIֵ*/ +#define IVOC_CI_CMD_DEVICE_MAX ((UINT8)100U) /*IVOC CI豸ֵ*/ +#define IVOC_CI_EA_MAX ((UINT8)20U) /*IVOC CI EAֵ*/ + +#define IVOC_CI_STOP_ASSURE_YES ((UINT8)0x55) /*IVOCCI֤ͣ״̬*/ +#define IVOC_CI_STOP_ASSURE_NO ((UINT8)0xAA) /*IVOCCI֤ͣ״̬δ*/ +#define IVOC_CI_STOP_ASSURE_DEF ((UINT8)0xFF) /*IVOCCI֤ͣ״̬Ĭֵ*/ +#define IVOC_CI_STOP_ASS_SUM_MAX ((UINT8)100U) /*IVOCCIֵ֤ͣ*/ + +#define IV0C_CI_RESOURCE_CANCEL_SUM_MAX ((UINT8)100U) /*IVOCCIȡԴ·ֵ*/ + +#define IVOC_CI_CMD_TYPE_RES_APPLY ((UINT8)0x01) /*IVOCCIԴ*/ +#define IVOC_CI_CMD_TYPE_RES_RELEASE ((UINT8)0x02) /*IVOCCIԴͷ*/ +#define IVOC_CI_CMD_TYPE_PSD_CLOSE ((UINT8)0x03) /*IVOCCIŹر*/ +#define IVOC_CI_CMD_TYPE_PSD_OPEN_FOUR ((UINT8)0x04) /*IVOCCIı鿪*/ +#define IVOC_CI_CMD_TYPE_EA_BUILD ((UINT8)0x05) /*IVOCCIɢ*/ +#define IVOC_CI_CMD_TYPE_EA_CANCEL ((UINT8)0x06) /*IVOCCIɢȡ*/ +#define IVOC_CI_CMD_TYPE_DYTEST_REQ ((UINT8)0x07) /*IVOCCI̬*/ +#define IVOC_CI_CMD_TYPE_DYTEST_CANCEL ((UINT8)0x08) /*IVOCCI̬ȡ*/ +#define IVOC_CI_CMD_TYPE_PSD_OPEN_SIX ((UINT8)0x09) /*IVOCCI鿪*/ +#define IVOC_CI_CMD_TYPE_PSD_OPEN_EIGHT ((UINT8)0x0A) /*IVOCCI˱鿪*/ +#define IVOC_CI_CMD_TYPE_JUMP_LOCK_APPLY ((UINT8)0x0B) /*IVOCTIOCԾ*/ +#define IVOC_CI_CMD_TYPE_JUMP_LOCK_RELEASE ((UINT8)0x0C) /*IVOCTIOCԾͷ*/ +#define IVOC_CI_CMD_GAP_DETECT_START ((UINT8)0x0D) /*IVOC2CI϶̽*/ +#define IVOC_CI_CMD_GAP_DETECT_STOP ((UINT8)0x0E) /*IVOC2CIֹͣ϶̽Default Value*/ +#define IVOC_CI_CMD_NON_RETURN_STEADY ((UINT8)0x0F) /*IVOC2CI۷ȵ*/ +#define IVOC_CI_CMD_NON_RETURN_FLASH ((UINT8)0x10) /*IVOC2CI۷Default Value*/ +#define IVOC_CI_CMD_TYPE_EMD_BUILD ((UINT8)0x11) /*IVOC2CI/Ž*/ + +#define IVOC_CI_LOGOUT_NORMAL ((UINT8)0x00U) /*IVOCIC ע*/ +#define IVOC_CI_LOGOUT_SLEEP ((UINT8)0x01U) /*IVOCIC ע*/ + +#define VOBC_CI_DIR_UP ((UINT8)0x55U) /*IVOCIC */ +#define VOBC_CI_DIR_DOWN ((UINT8)0xAAU) /*IVOCIC */ +#define VOBC_CI_DIR_DEF ((UINT8)0xFFU) /*IVOCIC Ĭ*/ + +#define CI_IVOC_SWITCH_POSTION_DING ((UINT8)0x55U) /*CIIVOCλ״̬*/ +#define CI_IVOC_SWITCH_POSTION_FAN ((UINT8)0xAAU) /*CIIVOCλ״̬*/ +#define CI_IVOC_SWITCH_POSTION_SHIBIAO ((UINT8)0xCCU) /*CIIVOCλʧ*/ + +#define CI_IVOC_PSD_STATE_CLOSE ((UINT8)0xAAU) /*CIIVOCŹر*/ +#define CI_IVOC_PSD_STATE_OPEN ((UINT8)0x55U) /*CIIVOCŴ*/ + +#define CI_IVOC_PSD_PCB_STATE_DOWN ((UINT8)0x55U) /*CIIVOC PCBť*/ +#define CI_IVOC_PSD_PCB_STATE_UP ((UINT8)0xAAU) /*CIIVOC PCBťδ*/ +#define CI_IVOC_PSD_PCB_PL ((UINT8)0xFFU) /*CIIVOC PCBť·*/ + +#define CI_IVOC_PSD_POB_STATE_VALID ((UINT8)0x55U) /*CIIVOC POBť*/ +#define CI_IVOC_PSD_POB_STATE_INVALID ((UINT8)0xAAU) /*CIIVOC POBťδ*/ +#define CI_IVOC_PSD_POB_PL ((UINT8)0xFFU) /*CIIVOC POBť·*/ + +#define CI_IVOC_PSD_PDB_STATE_INVALID ((UINT8)0xAAU) /*CIIVOC PDBťδ*/ +#define CI_IVOC_PSD_PDB_NO_BUTTON ((UINT8)0xCCU) /*CIIVOC PDBťδ*/ +#define CI_IVOC_PSD_PDB_STATE_VALID ((UINT8)0x55U) +#define CI_IVOC_PSD_PDB_PL ((UINT8)0xFFU) /*CIIVOC PDBť·*/ + +#define CI_IVOC_GAP_DETECT_STATUS_CLEAR ((UINT8)0x55) /*CI2VOBC϶̽״̬Ѽϰ*/ +#define CI_IVOC_GAP_DETECT_STATUS_UNCLEAR ((UINT8)0xAA) /*CI2VOBC϶̽״̬Ѽϰ*/ +#define CI_IVOC_GAP_DETECT_STATUS_DEFAULT ((UINT8)0xFF) /*CI2VOBC϶̽״̬δ/޴˹ܣDefault Value*/ + +#define CI_IVOC_ESB_STATE_VALID ((UINT8)0x55U) /*CIIVOC ESBť*/ +#define CI_IVOC_ESB_STATE_INVALID ((UINT8)0xAAU) /*CIIVOC ESBťδ*/ + +#define CI_IVOC_NON_RETURN_STATE_VALID ((UINT8)0x55U) /*CIIVOC ۷ť*/ +#define CI_IVOC_NON_RETURN_STATE_INVALID ((UINT8)0xAAU) /*CIIVOC ۷ťδ*/ + +#define CI_IVOC_SPKS_STATE_VALID ((UINT8)0x55U) /*CIIVOC SPKSť*/ +#define CI_IVOC_SPKS_STATE_INVALID ((UINT8)0xAAU) /*CIIVOC SPKSťδ*/ + +#define CI_IVOC_GARAGEDR_STATE_VALID ((UINT8)0x55U) /*CIIVOC Ŵ*/ +#define CI_IVOC_GARAGEDR_STATE_INVALID ((UINT8)0xAAU) /*CIIVOC Źر*/ + +#define CI_IVOC_ALLLINE_FLOCK ((UINT8)0xCCU) /*CIIVOC ȫ߷*/ +#define CI_IVOC_ALLLINE_FLOCK_NO ((UINT8)0xFFU) /*CIIVOC δȫ߷*/ + +#define CI_IVOC_FLOODGATE_OPEN_LOCK ((UINT8)0xAAU) /*CIIVOC ſ*/ +#define CI_IVOC_FLOODGATE_OPEN_LOCK_NO ((UINT8)0x55U) /*CIIVOC δ*/ + +#define CI_IVOC_FLOODGATE_CLOSE_REQ ((UINT8)0x55U) /*CIIVOC й*/ +#define CI_IVOC_FLOODGATE_CLOSE_REQ_NO ((UINT8)0xAAU) /*CIIVOC ޹*/ + +#define CI_IVOC_DYTEST_REPLY_YES ((UINT8)0x55U) /*CIIVOC ̬ͬ*/ +#define CI_IVOC_DYTEST_REPLY_NO ((UINT8)0xAAU) /*CIIVOC ̬Բͬ*/ + +#define CI_IVOC_LOGSEC_PRLOCK_OPEN ((UINT8)0x55U) /*CIIVOC ߼αμ·գ·*/ +#define CI_IVOC_LOGSEC_PRLOCK_CLOSE ((UINT8)0xAAU) /*CIIVOC ߼αμ·գ·δ*/ +#define CI_IVOC_LOGSEC_RLOCK ((UINT8)0xCCU) /*CIIVOC ߼ν·*/ +#define CI_IVOC_LOGSEC_PLOCK ((UINT8)0x33U) /*CIIVOC ߼ν*/ + +#define CI_IVOC_STOP_ENASSURE_ROUTE_SUM ((UINT16)100U) /*CIIVOC ֤ͣ·ֵ*/ +#define CI_IVOC_RESOURCE_CANCEL_RTSUM ((UINT16)100U) /*CIIVOC Դȡ·ֵ*/ + +#define CI_IVOC_FLOODGATE_APPLY_SUM ((UINT16)50U) /*CIIVOC Źر*/ +#define CI_IVOC_PACKET_LENGTH_MAX ((UINT16)1400U) /*CIIVOC ֵ*/ +#define TRAIN_TOPLATFORM_LOG_SUM ((UINT16)1000U) /*гվ̨߼*/ + +#define CI_IVOC_LOGSEC_JUMPLOCK_YES ((UINT8)0x55U) /*CIIVOC ߼Ծ*/ +#define CI_IVOC_LOGSEC_JUMPLOCK_NO ((UINT8)0xaaU) /*CIIVOC ߼Ծδ*/ + +#define IVOC_LOG_OUT_FAILURE ((UINT8)0xaau) /*IVOCעʧ*/ +#define IVOC_LOG_OUT_SUCCESS ((UINT8)0x55u) /*IVOCעɹ*/ + +#define CI_IVOC_SCREEN_REQ_YES ((UINT8)0x55u) /*ɸѡ*/ +#define CI_IVOC_SCREEN_REQ_NO ((UINT8)0xffu) /*ɸѡ*/ + +#define IVOC_CI_UNLOCK_OVERLAP_SUM ((UINT8)20U) /*IVOCCIֵ*/ +#define CI_IVOC_UNLOCK_OVERLAP_SUM ((UINT8)20U) /*CIIVOCֵ*/ + +#define IVOC_CI_FLOODGATE_CLOSE_ALLOW_SUM ((UINT8)50U) /*IVOCCIŹرֵ*/ +#define IVOC_CI_GARAGEDOOR_CLOSE_ALLOW_SUM ((UINT8)50U) /*IVOCCIŹرֵ*/ + +#define CI_IVOC_URGENT_YES ((UINT8)0x55U) /*CIIVOC ƶ״̬Ч*/ +#define CI_IVOC_URGENT_NO ((UINT8)0xaaU) /*CIIVOC ƶ״̬Ч*/ + +#define CI_VOBC_BACKUP_SEND_ROUTE_SUM ((UINT8)5U) /*CIغͨ·ֵ*/ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef SFP_PROTOCOL + +/*ͨŵVobcϢ*/ +typedef struct S_VobcToCiPsdDataStruct +{ + UINT16 PsdId; /*Psd ID*/ + UINT32 PsdIdInterConn; /*ͨPsd ID*/ + UINT8 CmdType; /**/ + UINT8 gapDetectCmd; /*϶̽*/ + UINT8 VOBCDoorState; /*VOBC״̬*/ + UINT32 CmdStartCycNum; /*ʼ*/ + UINT32 faultIsolationRequest; /*ϸϢ*/ + UINT32 VOBCIsolatePsdRequest[2]; /*VOBCϸPSD»CI-VOBCӿĵ涨8ֽڣAdded on 20180223*/ +} VobcToCiPsdDataStruct; + +/*ģʽͨŵVobcеPSDϢ*/ +typedef struct S_VobcBackUpToCiPsdDataStruct +{ + UINT16 PsdId; /*Psd ID*/ + UINT32 PsdIdInterConn; /*ͨPsd ID*/ + UINT8 CmdType; /**/ + UINT32 CmdStartCycNum; /*ʼ*/ +} VobcBackUpToCiPsdDataStruct; + +typedef struct S_IvocToCiEaStruct +{ + UINT8 chDeviceStatus; /* 豸״̬ */ + UINT16 wDeviceId; /* 豸ID */ + UINT32 dwBuildCyc; /*ɢ*/ +}IvocToCiEaDataStru; + +typedef struct S_IvocToCiCmdStruct +{ + UINT8 chCmdType; /* */ + UINT8 chCmdDevNum; /* 豸 */ + UINT16 wCmdDevId[IVOC_CI_CMD_DEVICE_MAX]; /* 豸ID*/ +}IvocCmdStru; + +/*ͨŵVobcϢ*/ +typedef struct S_VobcToCiDataStruct +{ + UINT16 VobcId; /*Vobc ID*/ + UINT8 psdCmdCode; /*վ̨*/ + UINT16 trainEditGroupInfo; /*гϢ*/ + UINT8 washTrainRequest; /*ϴϢ*/ + UINT8 headWashStopSteadyInfo; /*ͷϴλͣϢϴͣ1*/ + UINT8 tailWashStopSteadyInfo; /*βϴλͣϢϴͣ2*/ + UINT8 passWashMachineRequest; /*ͨϴϢ*/ + UINT8 washPauseRequest; /*ͣϴ*/ + UINT8 chWashMachineWorkMode; /*ϴģʽ*/ + UINT8 PsdSum; /**/ + UINT8 trainDirection; /*гз*/ + UINT8 trainStopSteadyState; /*гͣͣ׼״̬*/ + UINT32 trackSecID; /*ID*/ + UINT32 stopSteadyStartCycNum; /*ͣȿʼ*/ + UINT32 firstHeartFrmSndCycNum; /*һη֡*/ + UINT32 ComStartCycle;/*VOBCͨſʼڣʹøVOBCͨжж*/ + UINT16 appInfoType; /*ӦϢ*/ + UINT16 vobcLogId; /*ͨ4IP VOBC1˻2˱ʶ*/ + VobcToCiPsdDataStruct PsdData[VOBC_TO_CI_TRAIN_PSD_MAX]; /**/ + UINT32 signalID; /*VOBC->CIźŻID*/ + + /*add by qw.liu 2022-02-24 ӳ½ӿֶ*/ + UINT8 chTrainLevel; /*гм:01:VBTC;02:ITC;03:UR;04:ABL*/ + UINT8 chTrainMode; /*гģʽ*/ + UINT16 wTrainMaxSafeHeadLink; /*гȫǰLink*/ + UINT32 dwTrainMaxSafeHeadOffset; /*гȫǰƫ*/ + UINT16 wTrainMinSafeHeadLink; /*гСȫǰlink*/ + UINT32 dwTrainMinSafeHeadOffset; /*гСȫǰƫ*/ + UINT16 wTrainMaxSafeTailLink; /*гȫLink*/ + UINT32 dwTrainMaxSafeTailOffset; /*гȫƫ*/ + UINT16 wTrainMinSafeTailLink; /*гСȫlink*/ + UINT32 dwTrainMinSafeTailOffset; /*гСȫƫ*/ + /*гз trainDirection*/ + UINT16 wTrainSpeed; /*гٶ*/ + UINT8 chSpeedDir; /*гٶȷ*/ + UINT8 chTrainZeroState; /*г״̬*/ + UINT8 chTrainHeadScreenConfirm; /*˹ȷǰɸ״̬*/ + UINT8 chTrainTailScreenConfirm; /*˹ȷϺɸ״̬*/ + UINT8 chTrainStopAssureNum; /*г֤ͣ*/ + UINT16 szTrainStopRouteId[IVOC_CI_STOP_ASS_SUM_MAX]; /*г֤ͣ·ID*/ + UINT32 szTrainStopRouteCyc[IVOC_CI_STOP_ASS_SUM_MAX]; + UINT8 chResourcesCancelNum; /*гԴȡ(·)*/ + UINT16 szResourcesCancelRouteId[IV0C_CI_RESOURCE_CANCEL_SUM_MAX]; /*гȡԴ·ID*/ + UINT32 szResourcesCancelRouteCyc[IV0C_CI_RESOURCE_CANCEL_SUM_MAX]; + UINT8 cAllowUnlockOverlapNum; /*гε*/ + UINT16 szAllowUnlockOverlapId[IVOC_CI_UNLOCK_OVERLAP_SUM]; /*гεID*/ + UINT32 szAllowUnlockOverlapStartCyc[IVOC_CI_UNLOCK_OVERLAP_SUM]; /*гεʼں*/ + UINT8 cAllowCloseFloodGateNum; /*гرյķ*/ + UINT16 szAllowCloseFloodGateId[IVOC_CI_FLOODGATE_CLOSE_ALLOW_SUM]; /*гرյķID*/ + UINT32 szAllowCloseFloodGateCyc[IVOC_CI_FLOODGATE_CLOSE_ALLOW_SUM]; /*Źرں*/ + + UINT8 cAllowCloseGarageGateNum; /*гرյij*/ + UINT16 szAllowCloseGarageGateId[IVOC_CI_FLOODGATE_CLOSE_ALLOW_SUM]; /*гرյijID*/ + UINT32 szAllowCloseGarageGateCyc[IVOC_CI_FLOODGATE_CLOSE_ALLOW_SUM]; /*Źرں*/ + + UINT8 chTrainWakeState; /*г״̬*/ + UINT8 chTrainReportState; /*г㱨ʪ챨Ϣ */ + UINT8 chEaNum; /* ɢ */ + IvocToCiEaDataStru stEaInfo[IVOC_CI_EA_MAX]; /* ɢϢ */ + UINT16 wGroupOtherTrainId; /* һгID*/ + UINT8 chGroupRunState; /* г״̬ 1DZ2齨34۷5*/ + UINT8 chGroupTrainReat; /* ǰ󳵹ϵ 0x55Ϊǰ 0xaa 0x5aDZ*/ + UINT16 wIvocCmdNum; /*IVOC */ + IvocCmdStru stCmdInfo[IVOC_CI_CMD_MAX]; /*IVOC Ϣ*/ + UINT32 dwDelayTime; /*Ϣӳʱ*/ + + UINT8 chLogOutState; /*ע״̬*/ + + UINT8 chActive; /*ǰ*/ + UINT8 chRrmReq; /*ԶRM*/ + UINT16 wNextStation; /*һվ*/ + UINT8 chDerailment; /*ѹ״̬*/ + + UINT8 chVideoQkState; /*Ƶ״̬*/ + UINT8 chVideoQkResult; /*Ƶͽ*/ + UINT16 wVideoQkRelatePsdId1; /*Ƶ͹ID1*/ + UINT16 wVideoQkRelatePsdId2; /*Ƶ͹ID2*/ + + UINT16 wHeadAxisId; /*ǰ*/ + UINT8 wHeadITEResult; /*ǰITEʶ 0x55г 0xaaг*/ + UINT16 wTailAxisId; /*󷽼*/ + UINT8 wTailITEResult; /*ITEʶ 0x55г 0xaaг*/ + UINT8 chNvramPosFlag; /*NVNAMλñʶ 0x55гʹNVRAMλ 0xaaгδʹNVRAMλ*/ + UINT16 wHeadSigId; /*ǰźŻID*/ + UINT16 wHeadVobcId; /*ǰID*/ +} VobcToCiDataStruct; + +/*ʹúģʽͨŵVobcϢ*/ +typedef struct S_VobcBackUpToCiDataStruct +{ + UINT16 VobcId; /*Vobc ID*/ + UINT8 chTrainLevel; /*гм ʽ510/CBTC: 0x01; ITC: 0x02; 510/ILģʽ: 0x03; ABLģʽ :0x04;*/ + UINT8 trainDirection; /*гз*/ + UINT16 appInfoType; /*ӦϢ*/ + UINT16 vobcLogId; /*ͨ4IP VOBC1˻2˱ʶ*/ + UINT32 ComStartCycle; /*VOBCģʽͨڣʹøVOBCͨжж*/ + UINT16 wNextStation; /*ǰվ̨ID*/ + UINT16 wTrainMaxSafeHeadLink; /*гȫǰLink*/ + UINT32 dwTrainMaxSafeHeadOffset; /*гȫǰƫ*/ + UINT16 wTrainMinSafeTailLink; /*гСȫlink*/ + UINT32 dwTrainMinSafeTailOffset; /*гСȫƫ*/ + /*гPSD*/ + UINT8 psdCmdCode; /*վ̨*/ + UINT8 PsdSum; /* ȡֵ012*/ + VobcBackUpToCiPsdDataStruct PsdData[VOBC_BACKUP_TO_CI_TRAIN_PSD_MAX]; /**/ + UINT16 wTrainHeadCurSignalId; /*гǰǰźŻ*/ + UINT16 wTrainHeadTrainId; /*гǰID*/ + UINT8 chNvramPosFlag; /*NVRAMλñʶ*/ + UINT8 chStopSteadyState; /*ͣ׼ͣȱ־*/ + UINT32 stopSteadyStartCycNum; /*ͣ׼ͣȱ־*/ + UINT32 trackSecID; /*ͣ׼ͣȹ*/ +} VobcBackUpToCiDataStruct; + + +#endif + +extern VobcToCiDataStruct VobcToCiDataStru[VOBC_TO_CI_SUM_MAX]; + +extern VobcBackUpToCiDataStruct VobcBackUpToCiDataStru[VOBC_BACKUP_TO_CI_SUM_MAX]; + +extern UINT8 VobcToCiSum; + + +/* +* VOBC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseVobcToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId,const UINT16 logId); + +/* +* VOBCͨ֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* const UINT16 logIdͨ4IP VOBC1˻2˱ʶ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseVobcBackUpToCiDataFrame(const UINT8* dataBuf, const UINT16 dataLength, const UINT8 systemId, const UINT16 logId); + +/* +* VOBC +* ˵ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToVobcData(void); + +/* +* VOBCͨ +* ˵ void +* ֵ CI_ERRORʧ CI_SUCCESSɹ +*/ +UINT8 PackCiToVobcBackUpData(void); + + +/* +* ȡVOBCCIṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: VOBCCIṹָ +*/ +VobcToCiDataStruct* GetVobcToCiDataStru(void); + +/* +* ȡVOBCCIṹ +* ˵ void +* ֵ +*/ +UINT8 GetVobcToCiSum(void); + +/* +* ȡűϢ +* ˵ const UINT16 psdId :ID +* ֵ 01:ı +* 02: +* 08:˱ +* CI_ERROR: Ϸ +*/ +UINT8 GetPsdEditGroupInfo(const UINT16 psdId); +/* +* VOBC͸CIϢṹУɾָλõ +* ˵ const UINT8 idx:VOBC͸CIϢṹλ +* ֵ 0:ʧ +* 1:ɹ +*/ +UINT8 RemoveVobcToCiMsgAt(UINT8 idx); + + +/* +* ȡVobc id +* ˵ UINT16 idx:VOBC͸CIϢṹλ +* ֵ 0:ʧ +* ֵ:VobcId +*/ +UINT16 GetVobcIdByIndex(UINT16 index); + +/* +* ȡVobc Ϣ +* ˵ UINT16 idx:VOBC͸CIϢṹλ +* ֵ 0:ʧ +* ֵ:VobcId +*/ +UINT8 GetVobcEditGroupInfoByIndex(UINT16 index); + +/* +* (FAO+HLHT)VOBC +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToVobcDataFAOHLHToneSelf(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* (FAO+HLHT)VOBC(ȥԶϴվ̨Ϣ) +* ˵ QueueStruct* CiToVobcDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToVobcDataFAOHLHToneSelfSecond(VobcToCiDataStruct* vobcToCiDataStru); + +/* +* гϢ +* ˵UINT8 trainEditGroupInfo, гϢ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 ChecktrainEditGroupInfo(UINT8 trainEditGroupInfo, OUT UINT8 EditGroupinfo_out); + +/* +* гϴ +* ˵UINT8 trainEditGroupInfo, гϢ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 CheckwashTrainRequest(UINT8 washTrainRequest, OUT UINT8 washTrainRequest_out); + +/* +* ͷϴλͣϢ +* ˵UINT8 trainEditGroupInfo, гϢ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 CheckheadWashStopSteady(UINT8 headwashStop, OUT UINT8 headwashStop_out); + +/* +* βϴλͣϢ +* ˵UINT8 trainEditGroupInfo,βϴλͣϢ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 ChecktailWashStopSteady(UINT8 tailwashStop, OUT UINT8 tailwashStop_out); + +/* +* ͨϴ +* ˵UINT8 trainEditGroupInfo, ͨϴ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 CheckpassWashMachine(UINT8 passWashMachine, OUT UINT8 passWashMachine_out); + +/* +* УгǷغ +* ˵ UINT16 wFloodGateId, ID +* UINT16 wTrainId, гID +* ֵ CI_ERROR ʧ,ͷصʵ״̬ +* CI_SUCCESS ɹͷص޹ +*/ +UINT8 CheckProtectEnvelope(UINT16 wFloodGateId, UINT16 wTrainId); + +/* +* CiIvocͨ߼Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpLogSecInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvocͨ·Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpRouteInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvocͨ۷߼Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpReturnLogInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvocͨ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpPsdInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvocSpksͨ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpSpksInfo(UINT8* pDataBuf, UINT16* wDataLength); + +/* +* CiIvocͨť״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpEsbInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvocͨ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpSwitchInfo(UINT8* pDataBuf, UINT16* wDataLength); + +/* +* CiIvocͨ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpProtectLgcInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvocʱ״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* UINT16 wTrainId гID +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpTsrInfo(UINT8* pDataBuf, UINT16* wDataLength, UINT16 wTrainId); + +/* +* CiIvoc״̬ȷϢ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpReqStateInfo(UINT8* pDataBuf, UINT16* wDataLength); + +/* +* CiIvoC״̬Ϣ +* ˵ UINT8* dataBuf, ݻ +* UINT16 *dataLength, ݳ +* ֵ CI_ERROR ʧSpks +* CI_SUCCESS ɹ +*/ +static UINT8 PackCiToIvocBackUpFloodInfo(UINT8* pDataBuf, UINT16* wDataLength); + +/* +* CiIvocǰϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 *dataLength, ݳ +* const UINT16 wTrnId VOBC ID +* ֵ CI_ERROR ʧ +* CI_SUCCESS ɹ +* by cgh 20240606 +*/ +static UINT8 PackCiToIvocHeadTrainInfo(UINT8* pDataBuf, UINT16* wDataLength, const UINT16 wTrnId); + +/* +* FAOHLHT +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* VobcToCiDataStruct* vobcToCiDataStru VOBCCIṹ +* ֵ 0: ݽʧ +* 1: ݽɹ +* BY CGH 20240606 +*/ +UINT8 ParseFAOHLHTOtherTypeData(const UINT16 appInfoType, UINT8* dataBuf, UINT16 dataLen, const UINT8 systemId, VobcToCiDataStruct* vobcToCiDataStru); + +/* +* FAOHLHTпϢ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* VobcToCiDataStruct* vobcToCiDataStru VOBCCIṹ +* ֵ 0: ݽʧ +* 1: ݽɹ +* BY CGH 20240606 +*/ +UINT8 ParseFAOHLHTBackUpControlData(UINT8* dataBuf, UINT16 dataLen, VobcToCiDataStruct* vobcToCiDataStru); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackZcData.c b/TSCP/src/APP/ciapp/ParsePack/ParsePackZcData.c new file mode 100644 index 0000000..bed6509 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackZcData.c @@ -0,0 +1,1370 @@ +/******************************************************** +* +* ParsePackZcData.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* ZCݽ +* ޸ļ¼ +* +********************************************************/ + +#include "ParsePackZcData.h" +#include "ParsePackCommon.h" +#include "../QueryFiles/dquCIInterFace.h" +#include "../HLHTMsgHead/HLHTHeadContexManage.h" +#include "../HLHTMsgHead/HLHTCommonDataPacketHead.h" + + + + +/*ʹ*/ +static ZcToCiDataStruct ZcToCiDataStru={ 0u };/*ZCݽṹ*/ + +/*תATSгλϢ*/ +ComTrainPosDataStruct ComTrainPosDataStru[ZC_TO_CI_TRAIN_MAX];/*гλϢ*/ +UINT16 ComTrainSum = 0u;/*г*/ +UINT8 lineIdentity = 0u; /*·ʶ*/ + + +/* +* ZC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID ʱ Ԥ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseZcToCiDataFrame(UINT8* dataBuf, UINT16 dataLength, UINT8 systemId) +{ + UINT8* sourceId = NULL; /*ԴID*/ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT8 kk = 0u; + UINT8 retVal = CI_SUCCESS; + UINT32 dwStep = 0U; + UINT8 galHeadSaved = 0u; /*ͨͷǷѱ־1棻0δ*/ + + UINT32 curntCycleNo = 0u; /*ǰں*/ + UINT32 errCode = 0u; + UINT16 zcName = 0u; /*ZC豸ƣ+ID*/ + UINT16 ciName = 0u; /*豸ƣ+ID*/ + UINT8 localCiId = 0u; /*ID*/ + UINT8 headRet = HLHT_HEAD_ERROR;/*ͨ*/ + HLHTGALInfoStruct hlhtGalHead = { 0u }; + INT32 zcInfoRemainValidity = 0; + UINT8 ci_zcPrtclVersion = 0u; + UINT16 wTmpDataLen = 0u; /*¼Ѿݳ*/ + UINT16 wMsgLen = 0u; /*ӦϢȼ¼*/ + UINT16 wMsgType = 0u; /*ӦϢ*/ + UINT16 wMsgCheckLen = 0u; /* ڽУݳ */ + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡ·ʶ*/ + + ci_zcPrtclVersion = GetVersionOfZCToCI(); + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + zcName = (CI_SYSTEM_TYPE_ZC)*256U + systemId; + ciName = (CI_SYSTEM_TYPE_CI)*256U + localCiId; + curntCycleNo = Get2oo2CurCycleNum(); + + if ((NULL != dataBuf) && (dataLength > 0u)) + { + sourceId = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*ȡ뱾ͨŵZCIDĿǰһֻһZCͨ*/ + + /*ͨϢͷ*/ + hlhtGalHead.devInterInfoType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.sourceId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.destId = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.emapVerCrc = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.crntOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.comPeriod = ShortFromChar(&dataBuf[ii]); + ii += 2u; + hlhtGalHead.recvOppMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.preOwnMsgSN = LongFromChar(&dataBuf[ii]); + ii += 4u; + hlhtGalHead.prtclVer = dataBuf[ii++]; + hlhtGalHead.totalDataLen = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + /*ͨϢͷУͨ && ʱЧżϢ*/ + /*һյZCϢʱУ鲻ֻͨ¼curntOwnMsgԼǰں*/ + + if (LINE_HLHT == lineIdentity)/*ͨ·*/ + { + headRet = HLHTRecvCommonPacketHeadCheck(zcName, ciName, CI_ZC_INTERFACE_INFOTYPE, ci_zcPrtclVersion, &hlhtGalHead, &errCode, 0u, CI_SYSTEM_TYPE_ZC); + } + else + { + headRet = HLHTRecvCommonPacketHeadCheck(zcName, ciName, CI_ZC_INTERFACE_INFOTYPE, (UINT8)CI_ZC_PRTCL_VER, &hlhtGalHead, &errCode, 0u, CI_SYSTEM_TYPE_ZC); + } + + debug_infor_printf((const)"\nZC_RECV GAL Check Result:%d,errCode:%d", headRet,errCode); /*0x55ȷ0xaa0x33ʼͨ֡*/ + + if (HLHT_HEAD_SUCCESS==headRet) + {/*GALϢͷУͨ*/ + /*ϢʱЧ*/ + zcInfoRemainValidity = HLHTCommonMsgRemainingValidity(GetCiAndZcTransmitBadEnsureTime(), curntCycleNo, GetSystemParaAppCycleTime(), hlhtGalHead.recvOppMsgSN, hlhtGalHead.crntOwnMsgSN, hlhtGalHead.preOwnMsgSN, hlhtGalHead.comPeriod); + + if (zcInfoRemainValidity > 0) + { + if (0u == hlhtGalHead.totalDataLen) + { + /* GALͷϢ */ + retVal = CI_ERROR; + } + else if (2u > hlhtGalHead.totalDataLen) + { + /* ݳȴ,ʧ */ + retVal = CI_ERROR; + } + else + { + /*Ч*/ + retVal = CI_SUCCESS; + { + while (wTmpDataLen < hlhtGalHead.totalDataLen) + { + /* һӦݳ */ + wMsgLen = ShortFromChar(&dataBuf[ii]); + + ii += 2u; + wTmpDataLen += 2U; + wTmpDataLen += wMsgLen; + + if (0u == wMsgLen) + { + ; /* ޴һ */ + } + else if (5u > wMsgLen) + { + /* Ȳ */ + retVal = CI_ERROR; + debug_infor_printf((const)"ParseZcToCiDataFrame_Error wMsgLen\n"); + } + else + { + /* ȡ */ + wMsgType = ShortFromChar(&dataBuf[ii]); + ii += 2u; + + /* Ԥ */ + ii += 2u; + + wMsgCheckLen = wMsgLen - 4u;/*ӦñĽȣɾԤ22ֽ*/ + switch (wMsgType) + { + case ZC_TO_TIOC_MASK_MSG: + /* ZC-CIλϢ */ + retVal = ParseMaskData(&dataBuf[ii], wMsgCheckLen); + dwStep |= 0x10000U; + break; + case ZC_TO_TIOC_TSR_MSG: + /* ʱϢ */ + retVal = ParseZcTsrData(&dataBuf[ii], wMsgCheckLen); + dwStep |= 0x01000U; + break; + case ZC_TO_TIOC_WLB_MSG: + /* ƶϢ */ + retVal = ParseZcEbData(&dataBuf[ii], wMsgCheckLen); + dwStep |= 0x00100U; + break; + case ZC_TO_TIOC_SNOW_MSG: + /*ZC-CIѩģʽϢ*/ + retVal = ParseZcSnowData(&dataBuf[ii], wMsgCheckLen); + dwStep |= 0x00010U; + break; + case ZC_TO_TIOC_ITELINECUT_MSG: + /*ZC-CIITEгϢ*/ + retVal = ParseZcIteLineCutData(&dataBuf[ii], wMsgCheckLen); + dwStep |= 0x00001U; + break; + default: + retVal = CI_ERROR; + break; + } + + if (CI_SUCCESS == retVal) + { + /* ɹݰ */ + ii += wMsgCheckLen; + } + else + { + debug_infor_printf((const)"ParseZcToCiDataFrame_Error Step: 0x%5x\n", dwStep); + ClearZcData(); /*ⲽûͨ*/ + } + } + + if (CI_ERROR == retVal) /*ʧ*/ + { + break; + } + else + { + ; /*do nothing*/ + } + } + + if (CI_SUCCESS == retVal) + { + /*Уݳ*/ + if (ii > dataLength) + { + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + /*ͨ*/ + if (SetCiTransmitRecvDataCycNum(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_ZC, sourceId[0], Get2oo2CurCycleNum()) == CI_ERROR) + {/*ʧ*/ + + } + else + {/*ڳɹ*/ + + /*ZCͨ״̬жZCǷͨж*/ + if (UpdateCiTransmitState(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_ZC, sourceId[0]) == CI_ERROR) + { + /*ͨ״̬ʧ*/ + } + else + { + /*ͨ״̬ɹ*/ + } + } + + /*ݾУ飬Ҫ洢ͨñ*/ + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_ZC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_ZC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_ZC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_ZC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_ZC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_ZC, systemId, 0u); + + galHeadSaved = 1; + } + } + } + } + } + else if (HLHT_HEAD_INIT ==headRet) + { + if (curntCycleNo > 0u)/*жŴ0Ϊ0Ч*/ + { + SetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_ZC, systemId, hlhtGalHead.comPeriod); + SetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_ZC, systemId, hlhtGalHead.crntOwnMsgSN); + SetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_ZC, systemId, hlhtGalHead.recvOppMsgSN); + SetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_ZC, systemId, hlhtGalHead.preOwnMsgSN); + SetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_ZC, systemId, curntCycleNo); + SetHLHTHeadCtxCiRcvLogId(CI_SYSTEM_TYPE_ZC, systemId, 0u); + + galHeadSaved = 1; + } + + retVal = CI_ERROR; + } + else + { +#if 0 + /*ATSֵطCI-ZCݰ汾УʧϢ*/ + if (GAL_COMPARE_EMAP_VER_COMP_ERR == errCode) + { + SetCiSendCmdBackInfoData(CI_BACK_DATA_VER_CHECK_FAIL, CI_SYSTEM_TYPE_ZC, systemId, 0, 0); + } +#endif + retVal = CI_ERROR; + + } + + /*ATSֵطZC-CIݽӿϢʹ*/ + if (GAL_COMPARE_INFO_TYPE_ERR == (errCode & GAL_COMPARE_INFO_TYPE_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_INFO_TYPE_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطZC-CIݷͷʶϢ*/ + else if (GAL_COMPARE_SEND_FLAG_ERR == (errCode & GAL_COMPARE_SEND_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_SEND_FLAG_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطZC-CIݽշ־Ϣ*/ + else if (GAL_COMPARE_RECV_FLAG_ERR == (errCode & GAL_COMPARE_RECV_FLAG_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_RECV_FLAG_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطZC-CIݰ汾УʧϢ*/ + else if (GAL_COMPARE_EMAP_VER_COMP_ERR == (errCode & GAL_COMPARE_EMAP_VER_COMP_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_VER_CHECK_FAIL,ESEND_LEVEL_ATS); + } + /*ATSֵطZC-CIݱԷյһϢʱкŴ*/ + else if (GAL_COMPARE_MSG_BDS_SN_ERR == (errCode & GAL_COMPARE_MSG_BDS_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_MSG_BDS_SN_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطZC-CIݶԷϢкżյһϢʱкŴ*/ + else if (GAL_COMPARE_MSG_SN_ERR == (errCode & GAL_COMPARE_MSG_SN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_MSG_SN_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطZC-CIЭ汾Ŵ*/ + else if (GAL_COMPARE_PROTOCOL_VER_ERR == (errCode & GAL_COMPARE_PROTOCOL_VER_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_PROTOCOL_VER_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطZC-CIӦòݳЧ*/ + else if (GAL_COMPARE_APP_LEN_ERR == (errCode & GAL_COMPARE_APP_LEN_ERR)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_APP_LEN_ERR,ESEND_LEVEL_ATS); + } + /*ATSֵطZC-CIͨڴ */ + else if (GAL_COMPARE_COM_PERIOD == (errCode & GAL_COMPARE_COM_PERIOD)) + {/*¼ͨŹ*/ + SetErrorData(EFUNC_PARSE_ZC2CI_DATA,CI_SYSTEM_TYPE_ZC,systemId,ETYPE_COMM_WITH_ZC,CI_BACK_DATA_COM_PERIOD,ESEND_LEVEL_ATS); + } + else + { + /*޼¼ͨŹ*/ + } +#if 0 + if ((HLHT_HEAD_SUCCESS==headRet) || (HLHT_HEAD_INIT ==headRet)) + { + /*ͨ*/ + if (SetCiTransmitRecvDataCycNum(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_ZC, sourceId[0], Get2oo2CurCycleNum()) == CI_ERROR) + {/*ʧ*/ + + } + else + {/*ڳɹ*/ + + /*ZCͨ״̬жZCǷͨж*/ + if (UpdateCiTransmitState(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_ZC, sourceId[0]) == CI_ERROR) + { + /*ͨ״̬ʧ*/ + } + else + { + /*ͨ״̬ɹ*/ + } + } + } +#endif + } + else + { + retVal = CI_ERROR; + } + + if ((CI_ERROR == retVal) || (0u == galHeadSaved)) + { + /*ͨñͷ*/ + ClearHlhtHeadCtx(CI_SYSTEM_TYPE_ZC, systemId); + } + + return retVal; + +#if 0 + if ((dataBuf != NULL) && (dataLength > 0u)) + { + + sourceId = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*ȡ뱾ͨŵZCIDĿǰһֻһZCͨ*/ + /*ͨ*/ + if (SetCiTransmitRecvDataCycNum(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_ZC, sourceId[0], Get2oo2CurCycleNum()) == CI_ERROR) + {/*ʧ*/ + + } + else + {/*ڳɹ*/ + + /*ZCͨ״̬*/ + if (UpdateCiTransmitState(GetSystemParaLocalCiId(), CI_SYSTEM_TYPE_ZC, sourceId[0]) == CI_ERROR) + { + /*ͨ״̬ʧ*/ + } + else + { + /*ͨ״̬ɹ*/ + } + } + + maskTotalLen = GetReceiveMaskSum(CI_SYSTEM_TYPE_ZC); /*ȡλݰܳ*/ + ZcToCiDataStru.ZcId = sourceId[0]; /*ȡ뱾ͨŵZCIDĿǰһֻһZCͨ*/ + ZcToCiDataStru.ZcMaskValueBufLen = maskTotalLen; + if (maskTotalLen / 8u != 0) + { + maskTotalLen = maskTotalLen / 8u + 1; + } + else + { + maskTotalLen = maskTotalLen / 8u; + } + + /*λϢ*/ + if (0u == ZcToCiDataStru.ZcMaskValueBufLen) + { + return CI_ERROR; + } + + if (GetMaskValue(ZcToCiDataStru.ZcMaskValueBuf, ZcToCiDataStru.ZcMaskValueBufLen, &dataBuf[ii], maskTotalLen) == 0u) + { + return CI_ERROR; + } + + ii = (UINT16) (ii + maskTotalLen); + + /*ͨųռ߼Ϣ*/ + if ((dataLength > ii) && (dataBuf[ii] > 0u)) + { + ComTrainSum = dataBuf[ii++]; + if (ComTrainSum > ZC_TO_CI_TRAIN_MAX) + { + ComTrainSum = 0u; + return CI_ERROR; + } + for (jj = 0u; jj < ComTrainSum; jj++) + { + ComTrainPosDataStru[jj].TrainId = dataBuf[ii++]; + ComTrainPosDataStru[jj].OcuupySectionSum = dataBuf[ii++]; + if (ComTrainPosDataStru[jj].OcuupySectionSum > TRAIN_OCCUPY_SECTION_MAX) + { + ComTrainSum = 0u; + return CI_ERROR; + } + for (kk = 0u; kk < ComTrainPosDataStru[jj].OcuupySectionSum; kk++) + { + ComTrainPosDataStru[jj].OcuupySectionIdBuf[kk] = ShortFromChar(&dataBuf[ii]); + ii += 2u; + } + } + + if (dataLength < ii) + { + ComTrainSum = 0u; + return CI_ERROR; + } + } + else + { + /*CTϢ*/ + } + + return CI_SUCCESS; + } + else + { + /*Ч*/ + + return CI_ERROR; + } +#endif +} + +/* +* ZCCIλ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseMaskData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 retVal = CI_ERROR; + UINT16 maskTotalLen = 0u; /*λݰܳ*/ + UINT8* sourceId = NULL; /*ԴID*/ + UINT8 funcRet = 0u; /*úֵ*/ + UINT16 ii = 0u; + /*У*/ + if(NULL != dataBuf) + { + retVal = CI_SUCCESS; + maskTotalLen = GetReceiveMaskSum(CI_SYSTEM_TYPE_ZC); /*ȡλݰܳ*/ + sourceId = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_ZC);/*ȡ뱾ͨŵZCIDĿǰһֻһZCͨ*/ + ZcToCiDataStru.ZcId = sourceId[0]; /*ȡ뱾ͨŵZCIDĿǰһֻһZCͨ*/ + ZcToCiDataStru.ZcMaskValueBufLen = maskTotalLen; + if (maskTotalLen % 8u != 0u) + { + maskTotalLen = maskTotalLen / 8u + 1U; + } + else + { + maskTotalLen = maskTotalLen / 8u; + } + + /*λϢ*/ + if (0u == ZcToCiDataStru.ZcMaskValueBufLen) + { + retVal = CI_ERROR; + } + + if (dataLen != maskTotalLen) + { + retVal = CI_ERROR; + debug_infor_printf((const)"ParseMaskData maskLen : %d__SystemMaskLen:%d\n", dataLen, maskTotalLen); + } + + if (CI_SUCCESS == retVal) + { + funcRet = GetMaskValue(ZcToCiDataStru.ZcMaskValueBuf, ZcToCiDataStru.ZcMaskValueBufLen, &dataBuf[ii], maskTotalLen); + if (0u == funcRet) + { + retVal = CI_ERROR; + debug_infor_printf((const)"ParseZcToCiMask_MaskParse_Error \n"); + } + } +#if 0 + if (CI_SUCCESS == retVal) + { + ii = (UINT16)(ii + maskTotalLen); + + /*ͨųռ߼Ϣ*/ + if ((dataLength > ii) && (dataBuf[ii] > 0u)) + { + ComTrainSum = dataBuf[ii++]; + if (ComTrainSum > ZC_TO_CI_TRAIN_MAX) + { + ComTrainSum = 0u; + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + for (jj = 0u; jj < ComTrainSum; jj++) + { + ComTrainPosDataStru[jj].TrainId = dataBuf[ii++]; + ComTrainPosDataStru[jj].OcuupySectionSum = dataBuf[ii++]; + if (ComTrainPosDataStru[jj].OcuupySectionSum > TRAIN_OCCUPY_SECTION_MAX) + { + ComTrainSum = 0u; + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + for (kk = 0u; kk < ComTrainPosDataStru[jj].OcuupySectionSum; kk++) + { + ComTrainPosDataStru[jj].OcuupySectionIdBuf[kk] = ShortFromChar(&dataBuf[ii]); + ii += 2u; + } + } + + } + + if (dataLength < ii) + { + ComTrainSum = 0u; + retVal = CI_ERROR; + } + } + + } + else + { + /*CTϢ*/ + } + } +#endif + } + return retVal; +} + +/* +* ZCCIʱ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseZcTsrData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cFunRetVal = 0u; /* ؽ */ + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT8 kk = 0u; + TsrDataStruct* pTmpTsrInfo = NULL; + UINT8 cTiocId = 0u; + UINT8 cSpeed = 0U; + UINT8 cDevTiocId = 0u; + UINT16 wLogSecId = 0U; + UINT8 wFlag = 0U; + UINT8 localTsrSum = 0U; /*ʱ*/ + UINT8 wZcTsrSum = 0U; /*ZC͵ʱ*/ + UINT8 chLogSecSum = 0U; /*ʱڱʱ*/ + UINT8 chTmpLogNum = 0U; /*ZC͵*/ + UINT16 tsrMaxCmdSum = 0u; /*ʱ*/ + UINT16 tsrMaxSecSum = 0u; /*ʱ*/ + + if (NULL == dataBuf) + { + cRetVal = CI_ERROR; + } + else + { + tsrMaxCmdSum = GetTsrMaxCmdSum(); + tsrMaxSecSum = GetTsrMaxSecSum(); + cRetVal = CI_SUCCESS; + } + + /* ʱЧ־λ */ + if (CI_SUCCESS == cRetVal) + { + ZcToCiDataStru.tsrInputInfoStru.cTsrValidFlag = ZC_TSR_VALID; + /*¼ʱЧ*/ + } + + /* ȫʱϢ */ + if (CI_SUCCESS == cRetVal) + { + ZcToCiDataStru.tsrInputInfoStru.cAllLineTsrState = dataBuf[ii]; + ii++; + + ZcToCiDataStru.tsrInputInfoStru.cAllLineTsrSpeed = dataBuf[ii]; + ii++; + + /*0xAA Ϊȫʱ*/ + if (((0x55U == ZcToCiDataStru.tsrInputInfoStru.cAllLineTsrState) && (0u == ZcToCiDataStru.tsrInputInfoStru.cAllLineTsrSpeed)) + || ((0xAAU == ZcToCiDataStru.tsrInputInfoStru.cAllLineTsrState) && (0u < ZcToCiDataStru.tsrInputInfoStru.cAllLineTsrSpeed))) + { + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; /*ٵΪ0δõ*/ + debug_infor_printf((const)"ParseZcToCiTSR_Error AllLineTsrSpeed\n"); + } + } + + /* ʱ */ + if (CI_SUCCESS == cRetVal) + { + wZcTsrSum = dataBuf[ii]; + ii++; + if (TSR_MAX_SUM szLogSecId[chLogSecSum] = wLogSecId; + chLogSecSum++; + wFlag = CI_SUCCESS; + } + } + + if (CI_ERROR == cRetVal) + { + break; + } + } + + if (CI_SUCCESS == wFlag) + { + /*뱾RC*/ + pTmpTsrInfo->cSpeed = cSpeed; + pTmpTsrInfo->cLogSecSum = chLogSecSum; + localTsrSum++; + } + } + + if ((CI_ERROR == cRetVal) ||(tsrMaxCmdSum = cEbSecNum) + { + cLocalCiId = GetSystemParaLocalCiId(); + for (jj = 0U; jj < cEbSecNum; jj++) + { + cPhySecId = ShortFromChar(&dataBuf[ii]); /*ID*/ + ii += 2U; + cSecBelongCiId = GetPhySecBelongCiId(cPhySecId);/*ȡ*/ + if ((0U < cPhySecId) && (cPhySecId= cTmepNum) + { + ZcToCiDataStru.esbInputInfoStruct.cSecEbSum = cTmepNum; /*ƶ*/ + } + else + { + cRetVal = CI_ERROR; /**/ + debug_infor_printf((const)"ParseZcToCiESB_Error cTmepNum\n"); + } + } + else + { + cRetVal = CI_ERROR; /*ޣʧ*/ + } + } + + if (dataLen != ii) + { + cRetVal = CI_ERROR; + } + return cRetVal; +} + +/* +* ZCCIѩ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +* edit cgh 20241030 +*/ +UINT8 ParseZcSnowData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0u; + UINT8 jj = 0U; + UINT16 dwPlatFormId = 0U; /*վ̨ͨID*/ + UINT8 cPlatFormNum = 0U; /*ZCѩվ̨*/ + UINT8 cTmepNum = 0U;/*ѩվ̨*/ + UINT8 cPlatFormBelongCiId = 0U; /*վ̨LinkCI*/ + UINT8 cLocalCiId = 0U; + UINT8 chLocalSnowValidFlag = 0U; /*ѩЧ־*/ + + if (NULL == dataBuf) + { + cRetVal = CI_ERROR; + } + else + { + cRetVal = CI_SUCCESS; + } + + /*ȫѩģʽЧ־λ */ + if (CI_SUCCESS == cRetVal) + { + ZcToCiDataStru.cSnowValidFlag = dataBuf[ii]; + ii++; + /*ZCAAЧ 55Ч*/ + if (0xAAU == ZcToCiDataStru.cSnowValidFlag) + { + ZcToCiDataStru.cSnowValidFlag = CI_ALL_SNOW_VALID; + } + else if (0X55U == ZcToCiDataStru.cSnowValidFlag) + { + ZcToCiDataStru.cSnowValidFlag = CI_ALL_SNOW_UNVALID; + } + else + { + cRetVal = CI_ERROR; + debug_infor_printf((const)"ParseZcToCiSNOW_Error cSnowValidFlag\n"); + } + } + else + { + ; + } + + /*ѩվ̨Ϣ*/ + if (CI_SUCCESS == cRetVal) + { + cPlatFormNum = dataBuf[ii]; /*ѩվ̨*/ + ii++; + + if (ALL_AREA_SNOW_SUM_MAX >= cPlatFormNum) + { + cLocalCiId = GetSystemParaLocalCiId(); + for (jj = 0U; jj < cPlatFormNum; jj++) + { + dwPlatFormId = ShortFromChar(&dataBuf[ii]); /*ѩվ̨ID*/ + ii += 2U; + cPlatFormBelongCiId = GetAreaSnowPlatFormBelongCiId(dwPlatFormId); /*ȡѩվ̨*/ + if (0U != dwPlatFormId) + { + if (cLocalCiId == cPlatFormBelongCiId) + { + /*վ̨ڱ*/ + if (LOCAL_AREA_SNOW_SUM_MAX > cTmepNum) + { + ZcToCiDataStru.szAreaSnowPlatFormId[cTmepNum] = (UINT32)dwPlatFormId; + cTmepNum++; + } + else + { + cRetVal = CI_ERROR; /*ѩվ̨ޣֹͣʧ*/ + debug_infor_printf((const)"ParseZcToCiSNOW_Error cTmepNum\n"); + break; + } + } + else + { + /*DZվ̨*/ + } + } + else + { + cRetVal = CI_ERROR; /*ѩվ̨IdǷʧ*/ + debug_infor_printf((const)"ParseZcToCiSNOW_Error dwPlatFormId\n"); + } + } + + ZcToCiDataStru.cAreaSnowPlatFormNum = cTmepNum; + } + else + { + cRetVal = CI_ERROR; /*ѩվ̨ޣʧ*/ + debug_infor_printf((const)"ParseZcToCiSNOW_Error cPlatFormNum\n"); + } + } + else + { + ; + } + + /*ѩģʽЧ־λ */ + if (CI_SUCCESS == cRetVal) + { + chLocalSnowValidFlag = dataBuf[ii]; + ii++; + /*ZCAAЧ 55Ч*/ + if ((CI_LOCAL_SNOW_UNVALID == chLocalSnowValidFlag) || (CI_LOCAL_SNOW_VALID == chLocalSnowValidFlag)) + { + ZcToCiDataStru.chLocalSnowValidFlag = chLocalSnowValidFlag; + } + else + { + cRetVal = CI_ERROR; + debug_infor_printf((const)"ParseZcToCiSNOW_Error chLocalSnowValidFlag\n"); + } + } + else + { + ; + } + + if (dataLen != ii) + { + cRetVal = CI_ERROR; + } + else + { + ; + } + return cRetVal; +} +/* +* ZC +* ˵ QueueStruct* CiToZcDataQueue, Ͷеַ +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToZcData( UINT8 deviceId) +{ + UINT8 localCi = 0u; /*ID*/ + UINT8 CiToZcDataBuffer[CI_TO_ZC_DATA_LEN_MAX] = {0u};/*CIZC֡*/ + UINT16 SendMaskSum = 0u; + UINT16 ii = 0u; + UINT32 ciEtcsId = 0u; /*CIͨ*/ + UINT32 zcEtcsId = 0u; /*ZCͨ*/ + UINT32 emapCheckVer = 0u; /*УϢ*/ + UINT8 retVal = CI_ERROR; + UINT32 curCycleNum = Get2oo2CurCycleNum(); /*Ӧں*/ + UINT32 appCycleTime = GetSystemParaAppCycleTime(); /*Ӧ*/ + UINT8 ci_zcPrtclVersion = 0u; + UINT16 dstDevId = 0; + UINT8 outnetSafeSendRtn = 0u; + UINT8 CIName2HlhtId = 0U; + UINT8 ZCName2HlhtId = 0U; + UINT8 CiEmapCheckVer = 0U; + UINT32 dwHlhtHSrcSN = 0u; + UINT32 dwHlhtHRcvSN = 0u; + UINT16 totallenIndex = 0U; + + localCi = GetSystemParaLocalCiId(); /*ȡID*/ + ci_zcPrtclVersion = GetVersionOfZCToCI(); + /*ȻȡʱϢȡɹбҪ*/ + CIName2HlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_CI * 256U) + localCi, 0U, &ciEtcsId); + ZCName2HlhtId = dquDevName2HlhtId((CI_SYSTEM_TYPE_ZC * 256U) + deviceId, 0U, &zcEtcsId); + dwHlhtHSrcSN = GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_ZC, deviceId); + dwHlhtHRcvSN = GetHLHTHeadCtxCiRcvSN(CI_SYSTEM_TYPE_ZC, deviceId); + CiEmapCheckVer = GetCiEmapCheckVer(localCi, &emapCheckVer, CI_SYSTEM_TYPE_ZC); + if ((CI_SUCCESS == CIName2HlhtId) && (CI_SUCCESS == ZCName2HlhtId) && (CI_SUCCESS == CiEmapCheckVer)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + + if ((CI_SUCCESS == retVal)) + { + /*ȡҪ͵λֽ*/ + if ((GetSendMaskSum(CI_SYSTEM_TYPE_ZC) % 8u) == 0u) + { + SendMaskSum = (UINT16) (GetSendMaskSum(CI_SYSTEM_TYPE_ZC) / 8u); + } + else + { + SendMaskSum = (UINT16) (GetSendMaskSum(CI_SYSTEM_TYPE_ZC) / 8u + 1u); + } + + if (0u == SendMaskSum) + { + retVal = CI_ERROR; + } + else + { + } + + /*ж豸ƶӦ4ֽڻͨǷȡɹ*/ + if (CI_SUCCESS == retVal) + { + /*ͨЭ֡ͷ*/ + + /*RSSP֡ͷ*/ + + /*ʼӦ֡*/ + /*GALͷ*/ + ShortToChar(CI_ZC_INTERFACE_INFOTYPE, &CiToZcDataBuffer[ii]);/*ӿϢ*/ + ii += 2u; + LongToChar(ciEtcsId, &CiToZcDataBuffer[ii]);/*ͷʶϢ*/ + ii += 4u; + LongToChar(zcEtcsId, &CiToZcDataBuffer[ii]);/*շʶϢ*/ + ii += 4u; + LongToChar(emapCheckVer, &CiToZcDataBuffer[ii]);/*ӵͼ汾УϢ*/ + ii += 4u; + LongToChar(curCycleNum, &CiToZcDataBuffer[ii]);/*Ϣк*/ + ii += 4u; + ShortToChar((UINT16)appCycleTime, &CiToZcDataBuffer[ii]);/*豸ͨѶ*/ + ii += 2u; + LongToChar(dwHlhtHSrcSN, &CiToZcDataBuffer[ii]);/*ԷϢкţrecvOppMsgSN¼յԷһϢеĶԷϢк*/ + ii += 4u; + LongToChar(dwHlhtHRcvSN, &CiToZcDataBuffer[ii]);/*յһϢʱк*/ + ii += 4u; + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡ·ʶ*/ + + if (LINE_HLHT == lineIdentity)/*ͨ·*/ + { + CiToZcDataBuffer[ii++] = ci_zcPrtclVersion; /*CI_ZCӿЭ汾*/ + } + else + { + CiToZcDataBuffer[ii++] = (UINT8)CI_ZC_PRTCL_VER;/*CI_ZCӿЭ汾*/ + } + + totallenIndex = ii; + ii += 2u;/*ͨñͷеӦò㱨ܳ*/ + + ii += 2u;/*ͨñͷеӦò㱨ij(0x202ij)*/ + + ShortToChar(TIOC_TO_ZC_MASK_MSG, &CiToZcDataBuffer[ii]);/*ӿϢ*/ + ii += 2u; + + ii += 2u; /*Ԥ*/ + + /*λϢ*/ + (void)MaskPack(CI_SYSTEM_TYPE_ZC,&CiToZcDataBuffer[ii]); + ii = (UINT16) (ii + SendMaskSum); + + /*ͨñͷӦò㱨ܳ*/ + ShortToChar(ii - totallenIndex - 2U, &CiToZcDataBuffer[totallenIndex]); + + /*ͨӦò㱨ܳ*/ + totallenIndex += 2U; + ShortToChar(ii - totallenIndex - 2U, &CiToZcDataBuffer[totallenIndex]); + + /*ZC*/ + ClearZcData(); + + dstDevId = (UINT16)(CI_SYSTEM_TYPE_ZC << 8) | ((UINT16)deviceId); + outnetSafeSendRtn = OutnetSafeSend(dstDevId, 0u, &CiToZcDataBuffer[0], ii); + if (1u == outnetSafeSendRtn) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nZC_SEND:%d", ii); + debug_out_array(0xAA, CiToZcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ + +#endif + retVal = CI_SUCCESS; + } + else + { + /*дʧ*/ + retVal = CI_ERROR; + } + } + else + { + } + +#if 0 + /*λϢ*/ + MaskPack(CI_SYSTEM_TYPE_ZC,&CiToZcDataBuffer[ii]); + ii = (UINT16) (ii + SendMaskSum); + + /*ݳ */ + CiToZcDataBuffer[0] = (UINT8) (((ii - 2u) >> 8u) & 0xff); + CiToZcDataBuffer[1] = (UINT8) ((ii - 2u) & 0xff); + + /*ZC*/ + ClearZcData(); + + if (QueueWrite(ii, CiToZcDataBuffer, CiToZcDataQueue)) + { /*дгɹ*/ +#ifdef LOGPRINT/*־ӡ*/ +#ifdef PLATFORM_2OO2/*2oo2ƽ̨ӡ*/ + debug_infor_printf((const)"\nZC_SEND:%d", ii); + debug_out_array(0xAA, CiToZcDataBuffer, ii); +#endif/*ƽ̨ӡ*/ + +#endif + return CI_SUCCESS; + } + else + { + /*дʧ*/ + return CI_ERROR; + } +#endif + } + else + { + /*ZC*/ + ClearZcData(); + + retVal = CI_ERROR; + } + + return retVal; +} + + +/* +* ȡZCλֵBuf +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: Bufָ +*/ +UINT8* GetZcMaskValueBuf(void) +{ + UINT8* pZcMaskValueBuf = NULL; /*ZCCIλֵBuf*/ + if (0u == ZcToCiDataStru.ZcMaskValueBufLen) + { + } + else + { + pZcMaskValueBuf = ZcToCiDataStru.ZcMaskValueBuf; + } + return pZcMaskValueBuf; +} + + +/* +* ȡZCλֵBuf +* ˵ void +* ֵ 0: ȡʧ +* >0: Buf +*/ +UINT16 GetZcMaskValueBufLen(void) +{ + return ZcToCiDataStru.ZcMaskValueBufLen; +} + + +/* +* ȡZCλеZCID +* ˵ void +* ֵ 0: ȡʧ +* >0: ZCID +*/ +UINT8 GetZcMaskZcId(void) +{ + return ZcToCiDataStru.ZcId; +} + +/* +* ȡг +* ˵ void +* ֵ г +*/ +UINT16 GetComTrainSum(void) +{ + return ComTrainSum; +} + +/* +* ȡгռϢ +* ˵ void +* ֵ г +*/ +ComTrainPosDataStruct* GetComTrainPosDataStru(void) +{ + return ComTrainPosDataStru; +} + +/* +* ɾ߼εCTռϢ +* ˵ const UINT16 logSecId, ߼ID +* ֵ void +*/ +void DeleteLogSecCTInfo(const UINT16 logSecId) +{ + UINT16 ii = 0u; + UINT8 jj = 0u; + UINT8 kk = 0u; + UINT8 secSum = 0u;/*гռ߼Ŀ*/ + + for (ii = 0u; ii < ComTrainSum; ii++) + { + secSum = ComTrainPosDataStru[ii].OcuupySectionSum; + for (jj = 0u; jj < secSum; jj++) + { + if (ComTrainPosDataStru[ii].OcuupySectionIdBuf[jj] == logSecId) + { + for (kk = jj + 1u; kk < secSum; kk++) + { + ComTrainPosDataStru[ii].OcuupySectionIdBuf[kk - 1U] = ComTrainPosDataStru[ii].OcuupySectionIdBuf[kk]; + } + ComTrainPosDataStru[ii].OcuupySectionSum--; + return; + } + } + } +} + +/* +* ZC +* ˵ void +* ֵ void +*/ +void ClearZcData(void) +{ + (void)CommonMemSet(&ZcToCiDataStru, (UINT32)sizeof(ZcToCiDataStru), 0u, (UINT32)sizeof(ZcToCiDataStru)); +} + + +/* +* ȡZCϢ +* ˵ void +* ֵ ZCϢṹָ +*/ +ZcToCiDataStruct* GetZcToCiDataStru(void) +{ + return & ZcToCiDataStru; +} + +/* +* ZCCIITEȫг״̬ +* ˵INT8* dataBuf ݻ +* UINT16 dataLength ݳ +* ֵCI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.07.12 +*/ +UINT8 ParseZcIteLineCutData(UINT8* dataBuf, UINT16 dataLen) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cIteLineCutState = CI_ITE_LINE_CUT_INVALID; /*ZC͵ITEȫг״̬*/ + UINT16 ii = 0U; + + if (NULL != dataBuf) + { + /*ZC͵ITEȫг״̬*/ + cIteLineCutState = dataBuf[ii]; + ii++; + + if ((CI_ITE_LINE_CUT_INVALID == cIteLineCutState) || (CI_ITE_LINE_CUT_VALID == cIteLineCutState) || (CI_ITE_LINE_CUT_DEFAULT == cIteLineCutState)) + { + ZcToCiDataStru.cIteLineCutState = cIteLineCutState; + + if (dataLen == ii) + { + cRetVal = CI_SUCCESS; + } + else + { + debug_infor_printf((const)"ParseZcIteLineCutData Error: MsgLen Is Error\n"); + cRetVal = CI_ERROR; /*Ȳһ£ʧ*/ + } + } + else + { + debug_infor_printf((const)"ParseZcIteLineCutData Error: IteLineCutState Is Invalid\n"); + cRetVal = CI_ERROR; /*״̬Ƿʧ*/ + } + } + else + { + cRetVal = CI_ERROR; /*ηǷʧ*/ + } + + return cRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ParsePack/ParsePackZcData.h b/TSCP/src/APP/ciapp/ParsePack/ParsePackZcData.h new file mode 100644 index 0000000..6bec290 --- /dev/null +++ b/TSCP/src/APP/ciapp/ParsePack/ParsePackZcData.h @@ -0,0 +1,212 @@ +/******************************************************** +* +* ParsePackZcData.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-28 +* ߣ +* Zcݽͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PARSE_PACK_ZC_DATA_H_ +#define _PARSE_PACK_ZC_DATA_H_ + + + +#include "CommonTypes.h" +#include "Convert.h" +#include "ParsePackDefine.h" +#include "ParsePackCommon.h" +#include "../Mask/MaskDefine.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../ParsePack/ParsePackTmcData.h" + + +#define CI_ZC_INTERFACE_INFOTYPE ((UINT16)0x0106) /*ͨCI_ZCӿϢ*/ +#define CI_ZC_PRTCL_VER ((UINT16)0x65) /*CI_ZCЭ汾ţݡIFAO-3048-ZC-CIӿ˵顷޸*/ +#define ZC_TO_TIOC_MASK_MSG ((UINT16)0x0201u) /*ZCTIOCλϢ*/ +#define TIOC_TO_ZC_MASK_MSG ((UINT16)0x0202u) /*TIOCZCλϢ*/ +#define ZC_TO_TIOC_TSR_MSG ((UINT16)0x0203u) /*ZCTIOCʱϢ*/ +#define ZC_TO_TIOC_WLB_MSG ((UINT16)0x0204u) /*ZCTIOCƶϢ*/ +#define ZC_TO_TIOC_SNOW_MSG ((UINT16)0x0205u) /*ZCTIOCѩģʽϢ*/ +#define ZC_TO_TIOC_ITELINECUT_MSG ((UINT16)0x0206U) /*ZCTIOCITEг״̬Ϣ*/ +#define ZC_TSR_VALID ((UINT8)0x55U) /*ZCʱЧ*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*ZC͵ĽƶϢ*/ +typedef struct S_EbInputInfoStruct +{ + UINT8 cWlbValidFlag; /*ȫ߽Ч־ aaЧ */ + UINT8 cSecEbSum; /*ƶ*/ + UINT16 wEbPhySecId[ZC_TO_CI_EB_MAX]; /*ƶ*/ +} EbInputInfoStruct; + +/*·̬ݽṹ*/ +typedef struct S_ZcToCiDataStruct +{ + UINT8 ZcId; /*Zc ID*/ + UINT16 ZcMaskValueBufLen; /*ZCCIλֵBuf*/ + UINT8 ZcMaskValueBuf[ZC_TO_CI_MASK_SUM_MAX]; /*ZCCIλֵBuf*/ + + TsrInputInfoStruct tsrInputInfoStru;/* ʱϢ */ + EbInputInfoStruct esbInputInfoStruct; /*ƶϢ*/ + UINT8 cSnowValidFlag; /* ȫѩģʽЧ־ */ + UINT8 cAreaSnowPlatFormNum; /*ѩվ̨*/ + UINT32 szAreaSnowPlatFormId[LOCAL_AREA_SNOW_SUM_MAX]; /*ѩվ̨ID*/ + UINT8 chLocalSnowValidFlag; /* ѩģʽЧ־ */ + UINT8 cIteLineCutState; /* ITEȫг״̬ */ +} ZcToCiDataStruct; + +/*ͨųλϢ*/ +typedef struct S_ComTrainPosDataStruct +{ + UINT8 TrainId; /*г ID*/ + UINT8 OcuupySectionSum; /*ռѹ*/ + UINT16 OcuupySectionIdBuf[TRAIN_OCCUPY_SECTION_MAX]; /*ռѹID*/ +} ComTrainPosDataStruct; + + +#ifndef SFP_PROTOCOL + +extern ComTrainPosDataStruct ComTrainPosDataStru[ZC_TO_CI_TRAIN_MAX]; +extern UINT16 ComTrainSum; +extern UINT8 lineIdentity; + + +#endif + +/* +* ZC֡ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* const UINT8 systemId, Դ豸ID +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseZcToCiDataFrame(UINT8* dataBuf, UINT16 dataLength, UINT8 systemId); + +/* +* ZC +* ˵ UINT8 deviceId,豸id +* ֵ 0:ʧ +* 1:ݳɹ +*/ +UINT8 PackCiToZcData( UINT8 deviceId); + +/* +* ȡZCλֵBuf +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: Bufָ +*/ +UINT8* GetZcMaskValueBuf(void); + +/* +* ȡZCλֵBuf +* ˵ void +* ֵ 0: ȡʧ +* >0: Buf +*/ +UINT16 GetZcMaskValueBufLen(void); + +/* +* ȡZCλеZCID +* ˵ void +* ֵ 0: ȡʧ +* >0: ZCID +*/ +UINT8 GetZcMaskZcId(void); + +/* +* ȡг +* ˵ void +* ֵ г +*/ +UINT16 GetComTrainSum(void); + +/* +* ȡгռϢ +* ˵ void +* ֵ г +*/ +ComTrainPosDataStruct* GetComTrainPosDataStru(void); + +/* +* ɾ߼εCTռϢ +* ˵ const UINT16 logSecId, ߼ID +* ֵ void +*/ +void DeleteLogSecCTInfo(const UINT16 logSecId); + +/* +* ZC +* ˵ void +* ֵ void +*/ +void ClearZcData(void); + +/* +* ZCCIλ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseMaskData(UINT8* dataBuf, UINT16 dataLen); + +/* +* ZCCIʱ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseZcTsrData(UINT8* dataBuf, UINT16 dataLen); + +/* +* ZCCIƶ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseZcEbData(UINT8* dataBuf, UINT16 dataLen); + +/* +* ZCCIѩ +* ˵ const UINT8* dataBuf, ݻ +* const UINT16 dataLength, ݳ +* ֵ 0: ݽʧ +* 1: ݽɹ +*/ +UINT8 ParseZcSnowData(UINT8* dataBuf, UINT16 dataLen); + +/* +* ȡZCϢݽṹ +* ˵ void +* ֵ ZCϢṹָ +*/ +ZcToCiDataStruct* GetZcToCiDataStru(void); + +/* +* ZCCIITEȫг״̬ +* ˵INT8* dataBuf ݻ +* UINT16 dataLength ݳ +* ֵCI_ERROR 0 ݽʧ +* CI_SUCCESS 1 ݽɹ +* Created By LQ 2024.07.12 +*/ +UINT8 ParseZcIteLineCutData(UINT8* dataBuf, UINT16 dataLen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/QueryFiles/CiConfigData.h b/TSCP/src/APP/ciapp/QueryFiles/CiConfigData.h new file mode 100644 index 0000000..38f5aad --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/CiConfigData.h @@ -0,0 +1,50 @@ +/************************************************************************ +* +* ļ CiConfigData.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ϵͳݽṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef CI_CONFIG_DATA_H +#define CI_CONFIG_DATA_H + +#include "../AutoReturn/AutoReturnConfigDataManage.h" +#include "../AutoRoute/AutoRouteConfigDataManage.h" +#include "../Indicator/IndicatorConfigDataManage.h" +#include "../esb/ESBConfigDataManage.h" +#include "../psd/PSDConfigDataManage.h" +#include "../Route/LongRouteConfigDataManage.h" +#include "../Route/RouteConfigDataManage.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Signal/SignalConfigDataManage.h" +#include "../Switch/SwitchConfigDataManage.h" +#include "../Section/AxisSectionConfigDataManage.h" +#include "../Section/LogicSectionConfigDataManage.h" +#include "../Section/PhysicalSectionConfigDataManage.h" +#include "../Mask/MaskConfigDataManage.h" +#include "../NonRoute/NonRouteConfigDataManage.h" +#include "../Overlap/OverlapConfigDataManage.h" +#include "../Transmit/TransmitStateDataManage.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../Relay/RelayConfigDataManage.h" +#include "../AllAutoReturn/AllAutoReturnConfigDataManage.h" +#include "../Garagedoor/GaragedoorConfigDataManage.h" +#include "../spks/SpksConfigDataManage.h" +#include "../FloodGate/FloodGateConfigDataManage.h" +#include "../WashMachine/WashMachineConfigDataManage.h" +#include "../ParsePack/ParsePackCiData.h" /* ̫ʣûбȽϺʵĵط,ʱ */ +#include "../InvadeSection/InvadeSectionConfigDataManage.h" +#include "../InvadeSection/InvadeSectionDataManage.h" +#include "../DiffLineDev/DiffLineDevConfigDataManage.h" +#include "../VirtualDevice/VirtualDevDataManage.h" +#include "../DataManage/DeviceConfigDataManage.h" + +#endif + diff --git a/TSCP/src/APP/ciapp/QueryFiles/commonQueryStruDef.c b/TSCP/src/APP/ciapp/QueryFiles/commonQueryStruDef.c new file mode 100644 index 0000000..8bfc365 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/commonQueryStruDef.c @@ -0,0 +1,104 @@ +#include "commonQueryStruDef.h" + +/*ѯҪĽṹ*/ +DSU_EMAP_STRU dsuEmapStru; +/*¼ȡDSUеĸݵ*/ +DSU_DATA_LEN_STRU dsuDataLenStru; +/*¼ȡDSUݿÿֽṹͷָ*/ +DSU_STATIC_HEAD_STRU dsuStaticHeadStru; +/*¼Ŷձиݽṹָ*/ +DSU_IDMAP_STRU dsuIdmapStru; +/*¼̬LINKѯʼָ*/ +DSU_STC_LIMIT_LINKIDX_STRU *gg_ppDsuLimitStcLinkIdx; + +DSU_EMAP_EXTEND_STRU dsuEmapExtendStru; + +UINT16 LINKINDEXNUM; /*ռС*/ +UINT16* dsuLinkIndex; /*linkϢ*/ + +UINT16* dsuPointIndex; /*Ϣ*/ + +UINT16* dsuBaliseIndex; /*ӦϢ*/ + +UINT16 SIGNALINDEXNUM; /*źŻռС*/ +UINT16* dsuSignalIndex; /*źŻϢ*/ + +UINT16* dsuAxleIndex; /*Ϣ*/ + +UINT16* dsuScreenIndex; /*ȫϢ*/ + +UINT16 STATIONINDEXNUM; /*վռС*/ +UINT16* dsuStationIndex; /*վ̨Ϣ*/ + +UINT16* dsuEmergStopIndex; /*ͣťϢ*/ + +UINT16 AXLESGMTINDEXNUM ; /*ռС*/ +UINT16* dsuAxleSgmtIndex; /*Ϣ*/ + +UINT16 LOGICSGMTINDEXNUM; /*ռС*/ +UINT16* dsuLogicSgmtIndex; /*Ϣ*/ + +UINT16* dsuStopPointIndex; /*ͣϢ*/ + +UINT16* dsuTrainLineIndex; /*Ϣ*/ + +UINT16* dsuExitRouteIndex; /*˳CBTCϢ*/ + +UINT16* dsuRunLevelIndex; /*վӪϢ*/ + +UINT16* dsuStaticResSpeedIndex; /*̬ϢϢ*/ + +UINT16 GRADEINDEXNUM; /*¶ռС*/ +UINT16* dsuGradeIndex; /*¶Ϣ*/ + +UINT16* dsuRouteIndex; /*·Ϣ*/ + +UINT16 PROTECT_INDEX_NUM; /*ռС*/ +UINT16* dsuProtectLinkIndex; /*·Ϣ*/ + +UINT16* dsuCBTCAccessLinkIndex; /*CBTC·ӽϢ*/ + +UINT16* dsuBLOCAccessLinkIndex; /*BLOC·ӽϢ*/ + +UINT16* dsuDefaultRoutIndex; /*ĬгϢ*/ + +UINT16* dsuARInIndex; /*۷Ϣ*/ + +UINT16* dsuAROutIndex; /*۷˳Ϣ*/ + +UINT16* dsuATSIndex; /*ATSϢ*/ + +UINT16* dsuCIIndex; /*CIϢ*/ + +UINT16* dsuARIndex; /*ӵĽṹԶ۷Ӧ*/ + +UINT16* dsuZCComZoneIndex; /*ӵZC򣬶Ӧ 2012.1.5*/ + +UINT16* dsuConResSpeedIndex; + +UINT16* dsuConGradeIndex; + +UINT16* dsuZCDividPointIndex; + +UINT16* dsuPhysicalSgmtIndex; /**/ + +UINT16 BLOCTRGAREAINDEXNUM;/*ʽռС*/ +UINT16* dsuBlocTrgAreaIndex; /*ʽ*/ + +UINT16 CBTCTRGAREAINDEXNUM; /*CBTCС*/ +UINT16* dsuCbtcTrgAreaIndex; /*CBTC*/ + +UINT16* dsuPlatFormIndex; /*վ̨*/ + +UINT16 COMEGOINDEXNUM; /*·С*/ +UINT16* dsuComeGoIndex; /*·*/ + +UINT16* dsuFloodGateIndex; /**/ + +UINT16* dsuSpksButtonIndex; /*SPKSť*/ + +UINT16* dsuDepotGateIndex; /**/ + +UINT16* dsuTunnelIndex; /**/ + +CBTC_CFG_DATA_STRU cbtcConfigDataStru;/*ϵͳýṹ*/ \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/QueryFiles/commonQueryStruDef.h b/TSCP/src/APP/ciapp/QueryFiles/commonQueryStruDef.h new file mode 100644 index 0000000..0609b47 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/commonQueryStruDef.h @@ -0,0 +1,110 @@ +#ifndef COMMON_QUERY_STRU_DEF +#define COMMON_QUERY_STRU_DEF + +#include "dsuStruct.h" +#include "dquCbtcConfigData.h" +#include "dsuIdmapStruct.h" + +extern DSU_EMAP_STRU dsuEmapStru; + +extern DSU_DATA_LEN_STRU dsuDataLenStru; /*¼ȡDSUеĸݵ*/ + +extern DSU_STATIC_HEAD_STRU dsuStaticHeadStru; /*¼ȡDSUݿÿֽṹͷָ*/ + +extern DSU_IDMAP_STRU dsuIdmapStru; /*¼Ŷձиݽṹָ*/ + +extern DSU_STC_LIMIT_LINKIDX_STRU *gg_ppDsuLimitStcLinkIdx; /*¼̬LINKѯʼָ*/ + +extern DSU_EMAP_EXTEND_STRU dsuEmapExtendStru; + +extern UINT16 LINKINDEXNUM; /*ռС*/ +extern UINT16* dsuLinkIndex; /*linkϢ*/ + +extern UINT16* dsuPointIndex; /*Ϣ*/ + +extern UINT16* dsuBaliseIndex; /*ӦϢ*/ + +extern UINT16 SIGNALINDEXNUM; /*źŻռС*/ +extern UINT16* dsuSignalIndex; /*źŻϢ*/ + +extern UINT16* dsuAxleIndex; /*Ϣ*/ + +extern UINT16* dsuScreenIndex; /*ȫϢ*/ + +extern UINT16 STATIONINDEXNUM; /*վռС*/ +extern UINT16* dsuStationIndex; /*վ̨Ϣ*/ + +extern UINT16* dsuEmergStopIndex; /*ͣťϢ*/ + +extern UINT16 AXLESGMTINDEXNUM ; /*ռС*/ +extern UINT16* dsuAxleSgmtIndex; /*Ϣ*/ + +extern UINT16 LOGICSGMTINDEXNUM; /*ռС*/ +extern UINT16* dsuLogicSgmtIndex; /*Ϣ*/ + +extern UINT16* dsuStopPointIndex; /*ͣϢ*/ + +extern UINT16* dsuTrainLineIndex; /*Ϣ*/ + +extern UINT16* dsuExitRouteIndex; /*˳CBTCϢ*/ + +extern UINT16* dsuRunLevelIndex; /*վӪϢ*/ + +extern UINT16* dsuStaticResSpeedIndex; /*̬ϢϢ*/ + +extern UINT16 GRADEINDEXNUM; /*¶ռС*/ +extern UINT16* dsuGradeIndex; /*¶Ϣ*/ + +extern UINT16* dsuRouteIndex; /*·Ϣ*/ + +extern UINT16 PROTECT_INDEX_NUM; /*ռС*/ +extern UINT16* dsuProtectLinkIndex; /*·Ϣ*/ + +extern UINT16* dsuCBTCAccessLinkIndex; /*CBTC·ӽϢ*/ + +extern UINT16* dsuBLOCAccessLinkIndex; /*BLOC·ӽϢ*/ + +extern UINT16* dsuDefaultRoutIndex; /*ĬгϢ*/ + +extern UINT16* dsuARInIndex; /*۷Ϣ*/ + +extern UINT16* dsuAROutIndex; /*۷˳Ϣ*/ + +extern UINT16* dsuATSIndex; /*ATSϢ*/ + +extern UINT16* dsuCIIndex; /*CIϢ*/ + +extern UINT16* dsuARIndex; /*ӵĽṹԶ۷Ӧ*/ + +extern UINT16* dsuZCComZoneIndex; /*ӵZC򣬶Ӧ 2012.1.5*/ + +extern UINT16* dsuConResSpeedIndex; + +extern UINT16* dsuConGradeIndex; + +extern UINT16* dsuZCDividPointIndex; + +extern UINT16* dsuPhysicalSgmtIndex; /**/ + +extern UINT16 BLOCTRGAREAINDEXNUM; +extern UINT16* dsuBlocTrgAreaIndex; /*ʽ*/ + +extern UINT16 CBTCTRGAREAINDEXNUM; /*CBTCС*/ +extern UINT16 *dsuCbtcTrgAreaIndex; /*CBTC*/ + +extern UINT16* dsuPlatFormIndex; /*վ̨*/ + +extern UINT16 COMEGOINDEXNUM; /*·С*/ +extern UINT16* dsuComeGoIndex; /*·*/ + +extern UINT16* dsuFloodGateIndex; /**/ + +extern UINT16* dsuSpksButtonIndex; /*SPKSť*/ + +extern UINT16* dsuDepotGateIndex; /**/ + +extern UINT16* dsuTunnelIndex; /**/ + +extern CBTC_CFG_DATA_STRU cbtcConfigDataStru;/*ϵͳýṹ*/ + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIInit.c b/TSCP/src/APP/ciapp/QueryFiles/dquCIInit.c new file mode 100644 index 0000000..cb49b3a --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIInit.c @@ -0,0 +1,12387 @@ +/************************************************************************ +* +* ļ quCIInit.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ϵͳݳʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#include "dquCIInit.h" +#include "CommonMemory.h" +#include "commonQueryStruDef.h" +#include "../System/SystemParameterManage.h" + +#define DJ 0 +#define DJ2 1 +#define LXJ 2 +#define ZXJ 3 +#define YXJ 4 +#define DDJ 5 +#define DXJ 6 + +dquCIConfigDataStr dquCICfgDtStr = {0U}; +UINT8 SpksConfigDataStructInit(CHAR * FSName); +UINT8 MJConfigDataStructInit(CHAR* FSName); +UINT8 ReadSpksConfigDataFromDquData(SpksDataConfigStruct* pSpksDataConfig); +UINT8 ReadMJConfigDataFromDquData(MJDataConfigStruct * pMJDataConfig); +UINT8 CheckInputOtherCiDevInfoValid(const LS_OtherCiDevInfoStruct *pOtherCiDevInfo); +UINT8 GetBelongCiByRelayId(UINT16 relayId ); +UINT8 CiTransmitInfoStructInit(CHAR* FSName); +UINT8 ReadDquCiTransmitInfoToConfig(DquCiTransmitStruct *pDquCiTransmitStr); + + +/* +: ·豸DquCfg·豸 +: DquDiffLineDevStruct *pDquDiffLineDevData ·豸 +: DiffLineDevStruct *pDiffLineDevData DquCfg·豸ָ +ֵ: 0 ʧ + 1 ɹ +*/ +UINT8 ReadDquDiffLineDevDataToConfig(DquDiffLineDevStruct *pDquDiffLineDevData, DiffLineDevStruct *pDiffLineDevData); + +/* +: ֽDquCfgзֽ +: DquCutoffPointStruct *pCutoffPointDevData ֽ豸 +: CfpConfigStru *pstCutoffPointData DquCfg ֽ豸ָ +ֵ: 0 ʧ +1 ɹ +*/ +static UINT8 ReadDquCutoffPointDataToConfig(DquCutoffPointStruct *pCutoffPointDevData, CfpConfigStru *pstCutoffPointData); +/* +* : ϵͳDquCfg +* : CBTC_BOUNDARY_AXLE_CONFIG_STRU* pCbtcBoundaryAxleInfo ϵͳ豸 +* : LinkLineStru *pDstLinkLineData DquCfg 豸ָ +* ֵ : 0 ʧ +* 1 ɹ +* Modified By LQ 2023.11.14 +*/ +UINT8 ReadDquLinkLineDataToConfig(CBTC_BOUNDARY_AXLE_CONFIG_STRU* pCbtcBoundaryAxleInfo, LinkLineStru* pDstLinkLineData); + +void SetSignalDrvEnable(SignalConfigDataStruct* pSgnlCfgDtStr); +UINT8 InvSecNdConSwiConfDataStruInit(CHAR* FSName); +UINT8 GetRelayDrvEnableByRelayId(UINT16 relayId ); +void SetGardoorphySecData(GaragedoorConfigDataStruct* pGaragedoorCfgDtStr, UINT16 physicalId); +UINT8 SetSignalVirtualAttr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr); +UINT8 SetSignalCrossCloseAttr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr); + +/********************************************* +*ܣӵʽʱݣΣʽʱýṹ(߼)ת +*˵pDquOutStationSigStrRef ʽʱݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +static UINT8 sigRelatedAxisSecToLogSecTrans(DquOutStationSigStruct * pDquOutStationSigStrRef); + +/* +* ʼֽбֽ㷽 +* ˵CfpConfigStru *pstCutoffPointData DquCfg ֽ豸ָ루Σ +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.10.16 +*/ +static UINT8 EnsureCfpLocDir(CfpConfigStru* pstCutoffPointData); + +/********************************************* +*ܣʼ۷ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +* by cgh 20241031 +*********************************************/ +static UINT8 NonAutoReturnStructInit(CHAR* FSName); + +/********************************************* +*ܣ۷ݽṹ +*˵pNonReturn ۷ṹָ + pNonReturnCfgDtStr ۷ݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20241031 +*********************************************/ +static UINT8 NonReturnStruFromDquStr(DSU_AR_STRU* pNonReturn, NonAutoReturnConfigDataStruct* pNonReturnCfgDtStr); + +/********************************************* +*ܣʼ̵еĽṹ壬ʼϵͳݡͨݣ +* ʼվźŻ߼/ݡʼ豸̵ݡʼ/߼ݡ +* ʼESBááΡơSPKSݣ +* ʼԶͨ·Զ۷·ȫԶ۷··šϽ··ǽ·ͨŹϵš· +* 豸ȣݡ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayInit(CHAR* FSName) +{ + UINT8 funcRtn = 0u; + UINT8 tmpSpeedLimitType = 0u; /*ʽʱݶȡ*/ + UINT8 localCiPattern = 0u; /*CIģʽ*/ + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 cLocalWorkType = 0U; /*عģʽ*/ + UINT8 chLocalOc = GetLocalOcPattern(); + + (void)memset(&RelayData,0,sizeof(RelayDataStruct_Config)); + (void)memset(&LSData,0,sizeof(LSDataStruct)); + + localCiPattern = GetLocalCiPattern(); /*ȡCIģʽ*/ + cLocalWorkType = GetLocalRcWorkMode(); + (void)dquSetInitCbtcConfigInfoRef(&cbtcConfigDataStru);/*עȫCBTCýṹ*/ + + tmpSpeedLimitType = GetCiFunctionSwitchConfig(BLK_TEMP_SPEED_LIM_CONF); /*ȡʱ*/ + + /*ʼͨŹϵݽṹ*/ + funcRtn = TransmitRelationDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"TransmitRelationDataStructInit fail.\r\n"); + } + if(FUNC_SWITCH_ON == includeVirFlag) + { + /* ȡOC豸ϵ*/ + funcRtn *= ReadVirCIWithOCRelationData(FSName); + + if (0u == funcRtn) + { + debug_infor_printf((const)"ReadVirCIWithOCRelationData fail.\r\n"); + } + } + /*ʼ̵ݽṹ*/ + funcRtn *= RelayConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"RelayConfigDataStructInit fail.\r\n"); + } + + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + /*ʼOC ñ*/ + if (OC_DATA_TYPE_OLD == chLocalOc) + { + funcRtn *= OCSwitchConfigDataStructInit_OLD(FSName); + } + else + { + funcRtn *= OCSwitchConfigDataStructInit(FSName); + } + + /*ʼOC źŻñ*/ + funcRtn *= OCSignalCfgStrConfDataStruInit(FSName); + + /*ʼOC ñ*/ + funcRtn *= OCPhySecConfigDataStructInit(FSName); + + + + if (0u == funcRtn) + { + debug_infor_printf((const)"OCPhySecConfigDataStructInit fail.\r\n"); + } + } + + /*ʼιղ̵*/ + funcRtn *= RelayPhySecFaultLockZCStruInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"RelayPhySecFaultLockZCStruInit fail.\r\n"); + } + + + /*ʼϵͳݽṹ*/ + funcRtn *= SystemParameterStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"SystemParameterStructInit fail.\r\n"); + } + + /* ʼͨ */ + funcRtn *= CiTransmitInfoStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"CiTransmitInfoStructInit fail.\r\n"); + } + + if (0xaau == tmpSpeedLimitType) + { + /* ʼվźŻ߼ */ + funcRtn *= OutStationSigRelLogSecStruInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"OutStationSigRelLogSecStruInit fail.\r\n"); + } + } + else if(0x55u == tmpSpeedLimitType) + { + /* ʼվźŻļ */ + funcRtn *= OutStationSigRelAxisSecStruInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"OutStationSigRelAxisSecStruInit fail.\r\n"); + } + } + else + { + /*do nothing*/ + } + + /*ʼźŻ̵ݽṹ----ṹ*/ + funcRtn *= SignalConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"SignalConfigDataStructInit fail.\r\n"); + } + + /*ʼϴ̵ݽṹ----ṹ*/ + funcRtn *= WashMachineConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"WashMachineConfigDataStructInit fail.\r\n"); + } + + /*ʼ̵[Ӧݽṹ]----ṹ*/ + funcRtn *= SwitchConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"SwitchConfigDataStructInit fail.\r\n"); + } + + /*ʼ߼ݽṹ----ṹ*/ + funcRtn *= LogicSecConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"LogicSecConfigDataStructInit fail.\r\n"); + } + + /*ʼμ̵ݽṹ----ṹ*/ + funcRtn *= PsclSgmtConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"PsclSgmtConfigDataStructInit fail.\r\n"); + } + + /*ʼݽṹ----ṹ*/ + funcRtn *=AxisSectionConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"AxisSectionConfigDataStructInit fail.\r\n"); + } + + /*ʼLINKݽṹ----ṹ*/ + funcRtn *= LinkConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"LinkConfigDataStructInit fail.\r\n"); + } + + /*ʼݽṹ----ṹ*/ + funcRtn *= EaConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"EaConfigDataStructInit fail.\r\n"); + } + + /*ʼݽṹ----ṹ*/ + funcRtn *= AxisConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"AxisConfigDataStructInit fail.\r\n"); + } + + + + /*ʼͣťӿݽṹ----ṹ*/ + funcRtn *=EsbConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"EsbConfigDataStructInit fail.\r\n"); + } + + /*ʼνӿݽṹ----ṹ*/ + funcRtn *=OverlapConfigDataStructInit( FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"OverlapConfigDataStructInit fail.\r\n"); + } + + /*ʼݽṹ*/ + funcRtn *= InvSecNdConSwiConfDataStruInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"InvSecNdConSwiConfDataStruInit fail.\r\n"); + } + + /**/ + funcRtn *=IndicatorConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"IndicatorConfigDataStructInit fail.\r\n"); + } + + /* ۷ */ + funcRtn *= NonAutoReturnStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"NonAutoRrturnStructInit fail.\r\n"); + } + + /* SPKS */ + funcRtn *= SpksConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"SpksConfigDataStructInit fail.\r\n"); + } + + /* Ž */ + funcRtn *= MJConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"MenJinConfigDataStructInit fail.\r\n"); + } + + /**/ + funcRtn *= FloodGateConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"FloodGateConfigDataStructInit fail.\r\n"); + } + + if (RC_WORK_MODE_TIOC == cLocalWorkType) + { + /*ֽ */ + funcRtn *= CutoffPointConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"CutoffPointConfigDataStructInit fail.\r\n"); + } + } + + /* */ + funcRtn *= LinkLineConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"LinkLineConfigDataStructInit fail.\r\n"); + } + + funcRtn *=ReverseCutConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"ReverseCutConfigDataStructInit fail.\r\n"); + } + + if (RC_WORK_MODE_TIOC == cLocalWorkType) + { + funcRtn *= GatewayConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"GatewayConfigDataStructInit fail.\r\n"); + } + } + + /******************************************************************************** + ݼ + *********************************************************************************/ + /*ʼԶ·ݽӿݽṹ----ṹ*/ + funcRtn *=AutoRouteConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"AutoRouteConfigDataStructInit fail.\r\n"); + } + + /*ʼԶ۷·ݽӿݽṹ----ṹ*/ + funcRtn *=AutoReturnConfigDataStructInit( FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"AutoReturnConfigDataStructInit fail.\r\n"); + } + + /*ʼȫԶ۷·ݽӿݽṹ----ṹ*/ + funcRtn *=AllAutoReturnCfgDtStructInit( FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"AllAutoReturnCfgDtStructInit fail.\r\n"); + } + + /*ʼ·ݽӿ-ݽṹ-----ṹ*/ + funcRtn *=ReverseRouteCfgDtStructInit( FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"ReverseRouteCfgDtStructInit fail.\r\n"); + } + + /*ʼݽӿݽṹ----ṹ*/ + funcRtn *=PsdConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"PsdConfigDataStructInit fail.\r\n"); + } + + /*ʼϽ·ݽӿݽṹ----ṹ*/ + funcRtn *=LongRouteConfigDataStructInit( FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"LongRouteConfigDataStructInit fail.\r\n"); + } + + /*ʼ·*/ + funcRtn *=RouteConfigDataStructInit( FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"RouteConfigDataStructInit fail.\r\n"); + } + + /*ʼⱨݽṹ*/ + funcRtn *= SGBJConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"SGBJConfigDataStructInit fail.\r\n"); + } + + /*ʼǽ·ݽṹ----ṹ*/ + funcRtn *=NonRouteConfigDataStructInit( FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"NonRouteConfigDataStructInit fail.\r\n"); + } + + /*:עƶ·ʼ棬ڳųʼõ·е*/ + funcRtn *=GaragedoorConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"GaragedoorConfigDataStructInit fail.\r\n"); + } + + /*·豸ݽṹʼ*/ + funcRtn *= DiffLineDevConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"DiffLineDevConfigDataStructInit fail.\r\n"); + } + + /* ʼ豸 */ + funcRtn *= VirtualDeviceInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"VirtualDeviceInit fail.\r\n"); + } + + /*PSC*/ + funcRtn *= PscConfigDataStructInit(FSName); + if (0u == funcRtn) + { + debug_infor_printf((const)"PscConfigDataStructInit fail.\r\n"); + } + /*ʼԶ·ݽӿݽṹ----ṹ*/ + funcRtn *= GroupAutoRouteCfgDtStructInit(FSName); + + if (0u == funcRtn) + { + debug_infor_printf((const)"GroupAutoRouteCfgDtStructInit fail.\r\n"); + } + return funcRtn; +} + +/********************************************* +*ܣʼ̵ݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayConfigDataStructInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8 funcRtn = 0u; + RelayConfigDataStruct* pRlyDfgDtStr; + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + UINT16 j; + UINT32 excelId = 0u; /*excel id*/ + UINT32 sheetId = 0u; /*sheet id*/ + UINT32 rowLen = 0u; /*г*/ + UINT8 localCiPattern = 0u; /*CIģʽ*/ + + /*Ѿʼˣǵִй*/ + if(RelayData.pRelayCfgDtStr != NULL) + { + rtnValue = 1u; + } + else + { + localCiPattern = GetLocalCiPattern(); + if (CI_PATTERN_TRADITIONAL == localCiPattern) + { + excelId = CI_DATA_TYPE; + sheetId = RELAY_RELAY_CONFIG_ID; + rowLen = LEN_RELAY_RELAY_CONFIG; + } + else + { + excelId = OC_DATA_TYPE; + sheetId = OC_RELAY_RELAY_CONFIG_ID; + rowLen = OC_LEN_RELAY_RELAY_CONFIG; + } + + /*ȡ ̵ */ + funcRtn = dquGetConfigData(FSName, excelId, sheetId,&pDataAddr,&DataSize); + if(funcRtn == 0u) + { + /*ʧ*/ + rtnValue = 0u; + } + else + {/*óɹ*/ + rtnValue = 1u; + } + + if (1u == rtnValue) + { + /*ø*/ + if(DataSize% rowLen != 0u) + { + rtnValue = 0u; + debug_infor_printf((const)"\nCI_RELAY_DATA,RELAY_RELAY,len %d not equal to fs", rowLen); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(excelId <<8)+ sheetId,PRINT_ONCE); + } + } + + if (1u == rtnValue) + { + RelayDataLen.RelayCfgDtStrLen = (UINT16)(DataSize/ rowLen); + + dquCICfgDtStr.RelayCfgDtStrLen = RelayDataLen.RelayCfgDtStrLen; + + RelayData.pRelayCfgDtStr = &dquCICfgDtStr.RelayCfgDtStr[0]; + + /*ڴΪЧ*/ + (void)memset(dquCICfgDtStr.RelayCfgDtStr, 0x00,sizeof(RelayConfigDataStruct) * RELAY_SUM_MAX); + + + /*ݵ ̵ ṹ */ + for(j=0u;j= RELAY_SUM_MAX) + { + rtnValue = 0u; + break; + } + + pRlyDfgDtStr = &dquCICfgDtStr.RelayCfgDtStr[j]; + + /*ݽṹ*/ + (void)RelayConfigDataStruFromChar(pDataAddr,pRlyDfgDtStr,&(dquCICfgDtStr.RelayName[j][0])); + pDataAddr += rowLen; + + pRlyDfgDtStr->VirtualAttribute = RELAY_VIRTUAL_ATTR_NO; + + } + } + + } + + return rtnValue; +} + +/********************************************* +*ܣʼϵͳݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SystemParameterStructInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8 funcRtn = 0u; + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + CBTC_CONFIG_DATA_STRU pCbtcConfigDataStru; + UINT16 ii = 0u;/**/ + + funcRtn = dquCbtcConfigDataInit (FSName); + if(0u == funcRtn) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + pCbtcConfigDataStru = cbtcConfigDataStru.cbtcConfigData; +#if 0 + dquGetCbtcConfigData (&pCbtcConfigDataStru); +#endif + /*ȡ ϵͳ */ + funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_PARAMETER_DATA_ID,&pDataAddr,&DataSize); + if((0u == funcRtn) || (0u == DataSize)) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + /*ø*/ + if(0u != (DataSize % CI_SYSTEM_PARAMETER_DATA_LEN)) + { + rtnValue = 0u; + debug_infor_printf((const)"\nCI_CONFIG_DATA,SYSTEM_PARAMETER,len %d not equal to fs",CI_SYSTEM_PARAMETER_DATA_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_PARAMETER_DATA_ID,PRINT_ONCE); + } + else + { + dquCICfgDtStr.SystemParamStrLen = (UINT16)(DataSize / CI_SYSTEM_PARAMETER_DATA_LEN); + + + for(ii=0u;ii ii ) + { + rtnValue = PZ_SystemParaStruFromCharNew(pDataAddr,dquCICfgDtStr.SystemParaStrNew.ParaStru + ii); + + pDataAddr += CI_SYSTEM_PARAMETER_DATA_LEN;/*ַ14ֽ*/ + + if (0u == rtnValue) + {/*ִнжѭ*/ + break; + } + else + { + } + } + else + { + rtnValue = 0u; + } + } + + if (1u == rtnValue) + { + /*ƶߴٶȣλdfsInitSubSystemCommonConfigData_CCת*/ + dquCICfgDtStr.SystemParaStrNew.MaxLineLimitSpeed = pCbtcConfigDataStru.MaxLineLimitSpeed; + + /*ʱ(km/h)δеλת*/ + dquCICfgDtStr.SystemParaStrNew.MaxTsrSpeed = pCbtcConfigDataStru.MaxTsrSpeed; + + /*NTPУʱʱСʱ*/ + dquCICfgDtStr.SystemParaStrNew.TimeZoneDifference = pCbtcConfigDataStru.TimeZoneDifference; + + /*ͬʻ˫Сȫ(cm))*/ + dquCICfgDtStr.SystemParaStrNew.MABackDistance = pCbtcConfigDataStru.MABackDistance; + + /*һõʱ*/ + dquCICfgDtStr.SystemParaStrNew.MaxTsrNum = pCbtcConfigDataStru.MaxTsrNum; + + /*һʱٱа*/ + dquCICfgDtStr.SystemParaStrNew.MaxSectionOfTsr = pCbtcConfigDataStru.MaxSectionOfTsr; + + /*IVOC-IVOCŹжʱ䣨ms*/ + dquCICfgDtStr.SystemParaStrNew.IvocIvocCommunicationErrorTime = pCbtcConfigDataStru.IvocIvocCommunicationErrorTime; + + /*IVOC-OCͨŹжʱ(ms)*/ + dquCICfgDtStr.SystemParaStrNew.IvocOcCommunicationErrorTime = pCbtcConfigDataStru.IvocOcCommunicationErrorTime; + + /*VOBC-ITSͨŹжʱ(ms)*/ + dquCICfgDtStr.SystemParaStrNew.VobcAtsCommunicationErrorTime = pCbtcConfigDataStru.VobcAtsCommunicationErrorTime; + + /*TMC-ITSͨŹжʱ䣨ms*/ + dquCICfgDtStr.SystemParaStrNew.TmcItsCommunicationErrorTime = pCbtcConfigDataStru.TmcItsCommunicationErrorTime; + + /*ITS-OCͨŹжʱ䣨ms*/ + dquCICfgDtStr.SystemParaStrNew.ItsOcCommunicationErrorTime = pCbtcConfigDataStru.ItsOcCommunicationErrorTime; + + /*OC-TMCͨŹжʱ䣨ms*/ + dquCICfgDtStr.SystemParaStrNew.TmcOcCommunicationErrorTime = pCbtcConfigDataStru.TmcOcCommunicationErrorTime; + + /*OC-PSDͨŹжʱ䣨ms*/ + dquCICfgDtStr.SystemParaStrNew.OcPsdCommunicationErrorTime = pCbtcConfigDataStru.OcPsdCommunicationErrorTime; + + /*IVOC-TSLͨŹжʱ䣨ms*/ + dquCICfgDtStr.SystemParaStrNew.IvocTslCommunicationErrorTime = pCbtcConfigDataStru.IvocTslCommunicationErrorTime; + + /*OC-TSLͨŹжʱ䣨ms*/ + dquCICfgDtStr.SystemParaStrNew.OcTslCommunicationErrorTime = pCbtcConfigDataStru.OcTslCommunicationErrorTime; + + /*㾫ȷͣMA쳤ȣcm*/ + dquCICfgDtStr.SystemParaStrNew.MALengthForATOParking = pCbtcConfigDataStru.MALengthForATOParking; + + /*ϵͳ߼зĹϵ*/ + dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown = pCbtcConfigDataStru.LinkLogicDirUpAndDown; + + /*ʻ˫Сȫ(cm)*/ + dquCICfgDtStr.SystemParaStrNew.OppositeTrackDistance = pCbtcConfigDataStru.OppositeTrackDistance; + + /*վ̨׷ʱг루cm*/ + dquCICfgDtStr.SystemParaStrNew.StationTrackDistance = pCbtcConfigDataStru.StationTrackDistance; + + /*·½ƶ루λm*/ + dquCICfgDtStr.SystemParaStrNew.MaxMALength = pCbtcConfigDataStru.MaxMALength; + + dquCICfgDtStr.SystemParaStrNew.CiAndCiTransmitBadEnsureTime = pCbtcConfigDataStru.CICICommunicationErrorTime; + + dquCICfgDtStr.SystemParaStrNew.dwLineMinTrainLength = pCbtcConfigDataStru.dwLineMinTrainLength; + + dquCICfgDtStr.SystemParaStrNew.chZXDynamicTestSwitch = pCbtcConfigDataStru.chZXDynamicTestSwitch; + + dquCICfgDtStr.SystemParaStrNew.chDynamicTestSwitch = pCbtcConfigDataStru.chDynamicTestSwitch; + + dquCICfgDtStr.SystemParaStrNew.chWLSFunSwitch = pCbtcConfigDataStru.chWLSFunSwitch; + + dquCICfgDtStr.SystemParaStrNew.dwEaFrontDis = pCbtcConfigDataStru.dwEaFrontDis; + + dquCICfgDtStr.SystemParaStrNew.dwEaBehindDis = pCbtcConfigDataStru.dwEaBehindDis; + + dquCICfgDtStr.SystemParaStrNew.CiAndVobcTransmitBadEnsureTime = pCbtcConfigDataStru.CiVobcCommunicationErrorTime; + dquCICfgDtStr.SystemParaStrNew.CiAndZcTransmitBadEnsureTime = pCbtcConfigDataStru.CiZcCommunicationErrorTime; + + dquCICfgDtStr.SystemParaStrNew.CiAndPsdTransmitBadEnsureTime = pCbtcConfigDataStru.CiPsdCommunicationErrorTime; + + dquCICfgDtStr.SystemParaStrNew.dwVersionOfZCToCI = pCbtcConfigDataStru.VersionOfZCToCI; + dquCICfgDtStr.SystemParaStrNew.dwVersionOfVOBCToCI = pCbtcConfigDataStru.VersionOfVOBCToCI; + dquCICfgDtStr.SystemParaStrNew.CiAndPscTransmitBadEnsureTime = pCbtcConfigDataStru.CommFaultTimeOfPSC_CI; + + dquCICfgDtStr.SystemParaStrNew.cAwakeCheckSpksSwitch = pCbtcConfigDataStru.cAwakeCheckSpksSwitch; + dquCICfgDtStr.SystemParaStrNew.dwVobcCiBackUpCommErrorTime = pCbtcConfigDataStru.dwVobcCiackUpCommErrorTime; + dquCICfgDtStr.SystemParaStrNew.VerSionBtwAxisAndCi = pCbtcConfigDataStru.ProtocolVersionOfAxisToCI; + dquCICfgDtStr.SystemParaStrNew.dwHitSoftWallSwitch = pCbtcConfigDataStru.cHitSoftWallSwitch; + dquCICfgDtStr.SystemParaStrNew.dwOverlapLockType = pCbtcConfigDataStru.chOverlapLockType; + dquCICfgDtStr.SystemParaStrNew.dwCDOccuCheckFlag = pCbtcConfigDataStru.chOccuCheckinCD; + dquCICfgDtStr.SystemParaStrNew.chNoCGFollowUtSwitch = pCbtcConfigDataStru.chNoCGFollowUtSwitch; + } + else + { + } + + } + + } + + } + + return rtnValue; +} + + +/********************************************* +*ܣʼźŻ̵ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SignalConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + + callFun = dfsEmapInit (FSName); + callFun *= InitRelay_SignalStru(FSName); + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + {/*ӵͼʼɹִ*/ + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + /*ΪӵͼźŻĸ*/ + dquCICfgDtStr.SgnlCfgDtStrLen = dsuDataLenStru.wSignalLen; + for(i=0u;i= SIGNAL_SUM_MAX) + { + rtnvalue = 0u; + break; + } + rtnvalue = SglCfgDtStruFromDquSignalStr(dsuStaticHeadStru.pSignalStru+i,&dquCICfgDtStr.SgnlCfgDtStr[i]); + if (0u == rtnvalue) + { + break; + } + } + } + + return rtnvalue; +} + +/********************************************* +*ܣʼϴ̵ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 WashMachineConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + + callFun = InitRelay_WashMachineStru(FSName);/*ϴ̵ṹ*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + /*Ϊϴ̵ĸ*/ + dquCICfgDtStr.WashMachineCfgDtStrLen = RelayDataLen.RelayWashMachineStrLen; + for(i=0u;i< dquCICfgDtStr.WashMachineCfgDtStrLen;i++) + { + if (i >= WASHMACHINE_SUM_MAX) + { + rtnvalue = 0u; + break; + } + (void)WashMachineCfgDtStruFromDquStr(RelayData.pRelayWashMachineStr + i,&dquCICfgDtStr.WashMachineCfgStr[i]); + } + } + + return rtnvalue; +} + +/********************************************* +*ܣʼ̵ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SwitchConfigDataStructInit(CHAR * FSName) +{ + UINT8 rtnvalue = 1u; + UINT8 callFun = 0u; + UINT16 i=0u; + UINT8 lineIdentity = CI_TRADITION_RAILWAY; + + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ:0x55:ǹ콻ͨ0xAA:콻ͨ*/ + + callFun = dfsEmapInit (FSName); + + if (CI_TRADITION_RAILWAY == lineIdentity) + { + callFun *= InitRelay_PointStru(FSName); + callFun *= InitLS_ProSwitchHostMapStru(FSName);/*ʼ-Ӧϵ*/ + dquCICfgDtStr.SwchCfgDtStrLen = dsuDataLenStru.wPointLen; + }/* zt ɾش 2022-02-15 */ + else + { + rtnvalue = 0u; + } + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + /*ӵͼʼɹִ*/ + else + { + if (CI_TRADITION_RAILWAY == lineIdentity) + { + for(i=0u;i= SWITCH_SUM_MAX) + { + rtnvalue = 0u; + break; + } + rtnvalue = SwitchCfgDtStruFromDquPointStr(dsuStaticHeadStru.pPointStru+i,&dquCICfgDtStr.SwchCfgDtStr[i]); + + if (1u == rtnvalue) + { + rtnvalue = SwitchCfgDtStruFromLSProHostStr(&dquCICfgDtStr.SwchCfgDtStr[i]); + if (0u == rtnvalue) + { + debug_infor_printf((const)"SwitchCfgDtStruFromLSProHostStr switch %d fail.\r\n", dquCICfgDtStr.SwchCfgDtStr[i].SwitchId); + break; + } + else + { + + } + if (1u == rtnvalue) + { + rtnvalue = SwitchCfgLogTrackInitDquStr(dsuStaticHeadStru.pPointStru+i,&dquCICfgDtStr.SwchCfgDtStr[i]); + if(0u == rtnvalue) + { + debug_infor_printf((const)"SwitchCfgLogTrackInitDquStr switch %d fail.\r\n",dquCICfgDtStr.SwchCfgDtStr[i].SwitchId); + break; + } + } + else + { + debug_infor_printf((const)"SwitchCfgDtStruFromLSProHostStr switch %d fail.\r\n",dquCICfgDtStr.SwchCfgDtStr[i].SwitchId); + break; + } + } + else + { + debug_infor_printf((const)"SwitchCfgDtStruFromDquPointStr switch %d fail.\r\n",dquCICfgDtStr.SwchCfgDtStr[i].SwitchId); + break; + } + } + }/* zt ɾش 2022-02-15 */ + else + { + rtnvalue = 0u; + } + } + + return rtnvalue; +} +/********************************************* +*ܣʼμ̵ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PsclSgmtConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + + callFun = dfsEmapInit (FSName); + callFun *= InitRelay_PhysicalSgmtStru(FSName); + callFun *= InitLS_PhySectionIntrudeStru(FSName); + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + return rtnvalue; + } + else + {/*ӵͼʼɹִ*/ + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.PsclSgmtCfgDtStrLen = dsuDataLenStru.wPhysicalSgmtLen;/**/ + for(i=0u;i= PHYSICAL_SECTION_SUM_MAX) + { + rtnvalue = 0u; + } + else + { + rtnvalue = PhySgmtCfgDtStruFromDquSgmtStr(dsuStaticHeadStru.pPhysicalSgmtStru+i,&dquCICfgDtStr.PsclSgmtCfgDtStr[i],dquCICfgDtStr.SgnlCfgDtStr); + } + if(0u == rtnvalue) + { + break; + } + } + } + + return rtnvalue; +} + +/********************************************* +*ܣʼݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 AxisSectionConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + + callFun = dfsEmapInit (FSName); + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.AxisSctCfgDtStrLen = dsuDataLenStru.wAxleSgmtLen; + for(i=0u;i= AXIS_SECTION_SUM_MAX) + { + rtnvalue = 0u; + break; + } + (void)AxisSecCfgDtStruFromDquSgmtStr(dsuStaticHeadStru.pAxleSgmtStru+i,&dquCICfgDtStr.AxisSctCfgDtStr[i]); + } + } + + return rtnvalue; +} + +/********************************************* +*ܣʼ߼ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LogicSecConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + UINT8 isEachInvFlag = 0U; + + /*жǷá޹ϵ*/ + isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION); + + callFun = dfsEmapInit (FSName); + + + /*߼޹ϵ*/ + callFun *= InitLS_LogicSecIntruStru(FSName); + /*߼λ޹ϵ*/ + callFun *= InitLS_LogSecIntruStru_Each(FSName); + + if (FUNC_SWITCH_OFF == isEachInvFlag) + { + /*μݽṹ*/ + callFun *= InitLS_IntrudePhySectionStruct(FSName); + } + else + { + /*߼λתμݽṹ*/ + callFun *= InitLS_InvEachPhySectionStruct(dsuDataLenStru.wLogicSgmtLen, dsuStaticHeadStru.pLogicSgmtStru); + } + + callFun *= InitLS_LogicLtrlDfncStru(FSName); + callFun *= InitLS_ContactConfigDataStruct(FSName); + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.lgcSctCfgDtStrLen = dsuDataLenStru.wLogicSgmtLen; + for (i = 0u; i < dsuDataLenStru.wLogicSgmtLen; i++) + { + if (i >= LOGIC_SECTION_SUM_MAX) + { + rtnvalue = 0u; + + } + + rtnvalue &= LogicSecCfgDtStruFromDquSgmtStr(dsuStaticHeadStru.pLogicSgmtStru + i, &dquCICfgDtStr.lgcSctCfgDtStr[i]); + + if (0U == rtnvalue) + { + /*ѭسʼʧ*/ + break; + } + } + } + + return rtnvalue; +} + +/********************************************* +*ܣźŻṹźŻ̵ṹ +*˵pSgnlDSUźŻݽṹָ +pSgnlCfgDtStrźŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SglCfgDtStruFromDquSignalStr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr) +{ + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + UINT16 index = 0u; + UINT16 axleSgmtId = 0u; + UINT8 relayFind = 0u; /*ҵ1*/ + DSU_ROUTE_STRU * pCurrentRouteStru = NULL; /*·ṹʱָ*/ + DSU_AXLE_SGMT_STRU * pCurrentAxleStru = NULL; + UINT16 signalOutFirstAxleId = 0u; + UINT16 ocIdBuff = 0u; + UINT16 indexAc = 0U; + UINT8 railwayType = CI_TRADITION_RAILWAY; + + /*ڲ*/ + if((NULL == pSgnl) || (NULL == pSgnlCfgDtStr)) + { + /*ʧ*/ + rtnvalue = 0u; + } + else + { + rtnvalue = CI_SUCCESS; + railwayType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·*/ + + pSgnlCfgDtStr->SignalId = pSgnl->wId; + pSgnlCfgDtStr->BelongCiId = (UINT8)pSgnl->wManagePhysicalCI; + pSgnlCfgDtStr->BelongVirCI = (UINT8)pSgnl->wBelongVirCI; + if (pSgnlCfgDtStr->SignalId < SIGNAL_SUM_MAX) + { + ocIdBuff = dquCICfgDtStr.OCSignalCfgStr[pSgnlCfgDtStr->SignalId].BelongOcId; +#if 0 + if (0u == ocIdBuff) + { + /*źŻIDOCñIDһ£ʧ*/ + rtnvalue = 0u; + return rtnvalue; + } + else + { + pSgnlCfgDtStr->BelongOcId = ocIdBuff; + } +#else + pSgnlCfgDtStr->BelongOcId = ocIdBuff; +#endif + } + pSgnlCfgDtStr->Direction = (UINT8)pSgnl->wProtectDir; + if (pSgnlCfgDtStr->Direction==dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown) + { + pSgnlCfgDtStr->OperDirection = CI_SYSTEM_DIRECTION_DOWN; + } + else + { + pSgnlCfgDtStr->OperDirection = CI_SYSTEM_DIRECTION_UP; + } + pSgnlCfgDtStr->startSigCiRouteSum = 0u; + + /*ʼǰȫΪ0*/ + pSgnlCfgDtStr->FirDsRelayId = 0u; + pSgnlCfgDtStr->SecDsRelayId = 0u; + pSgnlCfgDtStr->LxRelayId = 0u; + pSgnlCfgDtStr->ZxRelayId = 0u; + pSgnlCfgDtStr->YxRelayId = 0u; + pSgnlCfgDtStr->DdRelayId = 0u; + pSgnlCfgDtStr->DxRelayId = 0u; + pSgnlCfgDtStr->YellowRelayId_wh = 0u; + pSgnlCfgDtStr->GreenRelayId_wh = 0u; + pSgnlCfgDtStr->BlueDsRelayId_wh = 0u; + pSgnlCfgDtStr->RepLxRelayId = 0u; + pSgnlCfgDtStr->DetainDriveRelayId = 0u; + pSgnlCfgDtStr->detainRelayId = 0u; + pSgnlCfgDtStr->detainDisplayRelayId = 0u; + pSgnlCfgDtStr->detainCutDisplayRelayId = 0u; + /*źŻڷһID (ֶ)*/ + pSgnlCfgDtStr->InFirstPhySecId = 0u; + + /*źŻⷽһID (ֶ)*/ + pSgnlCfgDtStr->OutFirstPhySecId = 0u; + + if (pSgnl->wId < SIGNAL_SUM_MAX) + { + pSgnlCfgDtStr->detainRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainBtnCollRelayId; + pSgnlCfgDtStr->detainCutRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainCutBtnRelayId; + pSgnlCfgDtStr->detainDisplayRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainBtnIndicatorRelayId; + pSgnlCfgDtStr->detainCutDisplayRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainCutBtnIndicatorRelayId; + /*TSCIϲ -lc 20221208*/ + pSgnlCfgDtStr->detainRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainBtnCollRelayId_2; + pSgnlCfgDtStr->detainCutRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainCutBtnRelayId_2; + pSgnlCfgDtStr->detainDisplayRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainBtnIndicatorRelayId_2; + pSgnlCfgDtStr->detainCutDisplayRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].DetainCutBtnIndicatorRelayId_2; + pSgnlCfgDtStr->cancelDetainBtnCollRelayId = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].CancelDetainBtnCollRelayId; + pSgnlCfgDtStr->cancelDetainBtnCollRelayId_2 = dquCICfgDtStr.OCSignalCfgStr[pSgnl->wId].CancelDetainBtnCollRelayId_2; + } + if ((pSgnl->sDengWeiFengBi | 0xfbu) == 0xfbu) + { + /*Ƶ*/ + pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_YELLOW; + } + else if ((pSgnl->sDengWeiFengBi | 0xfdu) == 0xfdu) + { + /*̵*/ + pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_GREEN; + } + else + { + pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_NO; + } + for(i=0u;iwSignalId == pSgnl->wId) + { +#if 0 + pSgnlCfgDtStr->SignalType = getSignalType((RelayData.pRelaySignalStr+i),pSgnl); +#endif + pSgnlCfgDtStr->FirDsRelayId = (RelayData.pRelaySignalStr+i)->wRelayDengSiId_1; + pSgnlCfgDtStr->SecDsRelayId = (RelayData.pRelaySignalStr+i)->wRelayDengSiId_2; + pSgnlCfgDtStr->LxRelayId = (RelayData.pRelaySignalStr+i)->wRelayTrainSignalId; + pSgnlCfgDtStr->ZxRelayId = (RelayData.pRelaySignalStr+i)->wRelayZhengXianId; + pSgnlCfgDtStr->YxRelayId = (RelayData.pRelaySignalStr+i)->wRelayYinDaoId; + pSgnlCfgDtStr->DdRelayId = (RelayData.pRelaySignalStr+i)->wRelayDianDengId; + pSgnlCfgDtStr->DxRelayId = (RelayData.pRelaySignalStr+i)->wRelayDiaoCheSignalId; + pSgnlCfgDtStr->YellowRelayId_wh = (RelayData.pRelaySignalStr+i)->wRelayYellowId_wh; + pSgnlCfgDtStr->GreenRelayId_wh = (RelayData.pRelaySignalStr+i)->wRelayGreenId_wh; + pSgnlCfgDtStr->BlueDsRelayId_wh = (RelayData.pRelaySignalStr+i)->wRelayBlueDsId_wh; + pSgnlCfgDtStr->RepLxRelayId = (RelayData.pRelaySignalStr+i)->wRepRelayTrainSignalId; + pSgnlCfgDtStr->DetainDriveRelayId = (RelayData.pRelaySignalStr+i)->wRelayDriveDetainId; + pSgnlCfgDtStr->detainRelayId = (RelayData.pRelaySignalStr+i)->wRelayCollDetainId; + pSgnlCfgDtStr->SignalType = (UINT8)((RelayData.pRelaySignalStr+i)->wSignalDrvColType); + pSgnlCfgDtStr->detainRelayId = (RelayData.pRelaySignalStr + i)->DetainBtnCollRelayId; + pSgnlCfgDtStr->detainCutRelayId = (RelayData.pRelaySignalStr + i)->DetainCutBtnRelayId; + pSgnlCfgDtStr->detainDisplayRelayId = (RelayData.pRelaySignalStr + i)->DetainBtnIndicatorRelayId; + pSgnlCfgDtStr->detainCutDisplayRelayId = (RelayData.pRelaySignalStr + i)->DetainCutBtnIndicatorRelayId; + if((pSgnl->sDengWeiFengBi | 0xfbu) == 0xfbu) + { + /*Ƶ*/ + pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_YELLOW; + } + else if((pSgnl->sDengWeiFengBi | 0xfdu) == 0xfdu) + { + /*̵*/ + pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_GREEN; + } + else + { + pSgnlCfgDtStr->SignalFengDengType = SIGNAL_TYPE_FENG_NO; + } + /*ҵӦźŻϢ*/ + relayFind = 1u; + + break; + } + else + { + /*ѭ*/ + } + } + SetSignalDrvEnable(pSgnlCfgDtStr);/*źŻǷ־*/ + rtnvalue &= SetSignalVirtualAttr(pSgnl,pSgnlCfgDtStr);/*ݵӵͼźŻźŻ*/ + rtnvalue &= SetSignalCrossCloseAttr(pSgnl,pSgnlCfgDtStr);/*ݵӵͼźŻźŻѹص*/ + rtnvalue &= SetSignalFenDuanAttr(pSgnl, pSgnlCfgDtStr);/*ݵӵͼźŻźŻֶ*/ + + if (1U == rtnvalue) + { + pSgnlCfgDtStr->wProtectLinkId = pSgnl->wProtectLinkId; + pSgnlCfgDtStr->dwProtectOff = pSgnl->dwProtectLinkOfst; + pSgnlCfgDtStr->chShineSignal = (UINT8)pSgnl->wShineSignal; + if (EMAP_SAME_DIR == pSgnl->wProtectDir) + { + if (0u != pSgnl->dwProtectLinkOfst) + { + pSgnlCfgDtStr->wOutFirstLinkId = pSgnl->wProtectLinkId; + pSgnlCfgDtStr->wInFirstLinkId = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pSgnl->wProtectLinkId]].wTmnlJointMainLkId; + } + else + { + pSgnlCfgDtStr->wOutFirstLinkId = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pSgnl->wProtectLinkId]].wOrgnJointMainLkId; + pSgnlCfgDtStr->wInFirstLinkId = pSgnl->wProtectLinkId; + } + } + else + { + if (0u != pSgnl->dwProtectLinkOfst) + { + pSgnlCfgDtStr->wOutFirstLinkId = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pSgnl->wProtectLinkId]].wTmnlJointMainLkId; + pSgnlCfgDtStr->wInFirstLinkId = pSgnl->wProtectLinkId; + } + else + { + pSgnlCfgDtStr->wOutFirstLinkId = pSgnl->wProtectLinkId; + pSgnlCfgDtStr->wInFirstLinkId = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pSgnl->wProtectLinkId]].wOrgnJointMainLkId; + } + } + + if (0U!=pSgnlCfgDtStr->wOutFirstLinkId) + { + for (indexAc = 0u; indexAc < dsuDataLenStru.wAxleSgmtLen; indexAc++) + { + pCurrentAxleStru = dsuStaticHeadStru.pAxleSgmtStru + indexAc; + if (NULL!=pCurrentAxleStru) + { + + if( (pCurrentAxleStru->wOrgnLkId == pSgnlCfgDtStr->wOutFirstLinkId) + ||(pCurrentAxleStru->wTmnlLkId == pSgnlCfgDtStr->wOutFirstLinkId)) + { + pSgnlCfgDtStr->OutFirstPhySecId = pCurrentAxleStru->wRelatePhysicalSgmtId; + signalOutFirstAxleId = pCurrentAxleStru->wId; + break; + } + } + } + } + + if (0U != pSgnlCfgDtStr->wInFirstLinkId) + { + for (indexAc = 0u; indexAc < dsuDataLenStru.wAxleSgmtLen; indexAc++) + { + pCurrentAxleStru = dsuStaticHeadStru.pAxleSgmtStru + indexAc; + if (NULL != pCurrentAxleStru) + { + + if ((pCurrentAxleStru->wOrgnLkId == pSgnlCfgDtStr->wInFirstLinkId) + || (pCurrentAxleStru->wTmnlLkId == pSgnlCfgDtStr->wInFirstLinkId)) + { + pSgnlCfgDtStr->InFirstPhySecId = pCurrentAxleStru->wRelatePhysicalSgmtId; + break; + } + } + } + } + } + + if (1U == rtnvalue) + { + for (i = 0U; i < dsuDataLenStru.wRouteLen; i++) + { + pCurrentRouteStru = dsuStaticHeadStru.pRouteStru + i; + /*źŻΪն˵Ľ·*/ + if (pSgnl->wId == pCurrentRouteStru->wEndSignalId) + { + index = pCurrentRouteStru->wIncludeAxleSgmtNum; + /*·һ*/ + axleSgmtId = pCurrentRouteStru->wIncludeAxleSgmtId[index - 1U]; + /*źŻⷽһID*/ + if ((axleSgmtId <= AXLESGMTINDEXNUM)) + { + if (0xffffU == dsuAxleSgmtIndex[axleSgmtId]) + { + pSgnlCfgDtStr->OutFirstPhySecId = 0U; + signalOutFirstAxleId = 0U; + } + else + { + /*Ӧ*/ + pSgnlCfgDtStr->OutFirstPhySecId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[axleSgmtId]].wRelatePhysicalSgmtId; + signalOutFirstAxleId = axleSgmtId; + } + } + } + /*źŻΪʼ˵Ľ·*/ + if (pSgnl->wId == pCurrentRouteStru->wStartSignalId) + { + /*źŻڷһID */ + axleSgmtId = pCurrentRouteStru->wIncludeAxleSgmtId[0]; + + if ((axleSgmtId <= AXLESGMTINDEXNUM)) + { + if (0xffffU == dsuAxleSgmtIndex[axleSgmtId]) + { + pSgnlCfgDtStr->InFirstPhySecId = 0U; + } + else + { + /*Ӧ*/ + pSgnlCfgDtStr->InFirstPhySecId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[axleSgmtId]].wRelatePhysicalSgmtId; + } + } + } + } + } + + if (1u == rtnvalue) + { + pSgnlCfgDtStr->signalPsdSum = 0u; + if ((0u != signalOutFirstAxleId) && (signalOutFirstAxleId <= AXLESGMTINDEXNUM)) + { + /*ҵźŻⷽĵһ*/ + if (dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[signalOutFirstAxleId]].wOrgnLkId== dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[signalOutFirstAxleId]].wTmnlLkId) + { + /*˵᲻пվ̨죺ȷźŻPSD*/ + for (i=0u;isignalPsdSumsignalPsdIdBuf[pSgnlCfgDtStr->signalPsdSum++]= dsuStaticHeadStru.pScreenStru[i].wId; + } + else + { + rtnvalue = 0u; + break; + } + } + } + + /*˵᲻пվ̨죺ȷźŻESB*/ + for (i = 0u; i < dsuDataLenStru.wEmergStopLen; i++) + { + if (dsuStaticHeadStru.pEmergStopStru[i].wRelatLkId == dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[signalOutFirstAxleId]].wOrgnLkId) + { + if (pSgnlCfgDtStr->signalEsbSum < SIGNAL_RELATED_ESB_MAX_SUM) + { + pSgnlCfgDtStr->signalEsbIdBuf[pSgnlCfgDtStr->signalEsbSum] = dsuStaticHeadStru.pEmergStopStru[i].wId; + pSgnlCfgDtStr->signalEsbSum++; + } + else + { + rtnvalue = 0u; + break; + } + } + } + } + } + } + +#if 0 + /*ӵͼźŻźŻݱCI-̵źŻ̵źŻ࣬˴Ӧʧ*/ + if (1u == rtnvalue) + { + if(0u == relayFind) + { + rtnvalue = 0u; + } + else + {/*do nothing*/ + } + } +#endif + + + if (1u == rtnvalue) + { + /*źŻ߼μ㣨ڼźŻʽʱ٣*/ + pSgnlCfgDtStr->relatedLogSecSum = 0u; + + for(i = 0u; i < dquOutStationSigStrLen;i++) + { + if((pDquOutStationSigStr + i)->wSignalId == pSgnlCfgDtStr->SignalId) + { + pSgnlCfgDtStr->relatedLogSecSum = (pDquOutStationSigStr + i)->wRalatedLogSecSum; + (void)CommonMemCpy(pSgnlCfgDtStr->ralatedLogSecIdBuf,SIGNAL_RELATED_LOGSEC_MAX_SUM * 2u,(pDquOutStationSigStr + i)->wRalatedLogSecIdBuf,pSgnlCfgDtStr->relatedLogSecSum * 2u); + + } + } + + + /*ȡʼźŻͬĽ·*/ + pSgnlCfgDtStr->startSigRouSum = 0u; + for(i=0u; iwId == pCurrentRouteStru->wStartSignalId) + { + if (pSgnlCfgDtStr->startSigRouSum < SIGNAL_EQUAL_ROUTE_MAX_SUM) + { + pSgnlCfgDtStr->startSigRouBuf[pSgnlCfgDtStr->startSigRouSum] = pCurrentRouteStru->wId; + pSgnlCfgDtStr->startSigRouSum ++; + + if (0u==(pCurrentRouteStru->wRouteType & 0x0200u)) + {/*ZCԶĽ·*/ + pSgnlCfgDtStr->startSigCiRouteSum++; + } + } + else + { + rtnvalue = 0u;/**/ + debug_infor_printf((const)"Error:signal %d startSameSigRouteNum exceed maxNum %d! ",pSgnlCfgDtStr->SignalId,SIGNAL_EQUAL_ROUTE_MAX_SUM); + } + } + } + pSgnlCfgDtStr->ConfigZcCiSignalCrossMask = SIGNAL_CONFIG_CROSS_MASK_NO; + pSgnlCfgDtStr->SignalIsThisLine = DEV_IS_THIS_LINE_YES; /*·*/ + } + } + + return rtnvalue; +} + +/********************************************* +*ܣϴ +*˵relayWashMachineStruct:ϴ̵ṹָ +pWashMachineCfgDtStr:ϴýṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 WashMachineCfgDtStruFromDquStr(Relay_WashMachineStruct * relayWashMachineStruct,WashMachineConfigDataStruct* pWashMachineCfgDtStr) +{ + UINT8 retVal = 0u; + if((NULL == relayWashMachineStruct) || (NULL == pWashMachineCfgDtStr)) + { + retVal = 0u; + } + else + { + pWashMachineCfgDtStr->WashMachineId = relayWashMachineStruct->wId; + pWashMachineCfgDtStr->WashMachineReadyRelayId = relayWashMachineStruct->WashMachineReadyRelayId; + pWashMachineCfgDtStr->BelongCiId = GetBelongCiByRelayId(pWashMachineCfgDtStr->WashMachineReadyRelayId); + pWashMachineCfgDtStr->BelongVirCiId = GetBelongVirCiByRelayId(pWashMachineCfgDtStr->WashMachineReadyRelayId); + pWashMachineCfgDtStr->WashMachineRequestVerifyRelayId = relayWashMachineStruct->WashMachineRequestVerifyRelayId; + pWashMachineCfgDtStr->TrainEmergencyStopRelayId = relayWashMachineStruct->TrainEmergencyStopRelayId; + pWashMachineCfgDtStr->HeadWashAllowRelayId = relayWashMachineStruct->HeadWashAllowRelayId; + pWashMachineCfgDtStr->TailWashAllowRelayId = relayWashMachineStruct->TailWashAllowRelayId; + pWashMachineCfgDtStr->WashTrainRequestRelayId = relayWashMachineStruct->WashTrainRequestRelayId; + pWashMachineCfgDtStr->TrainHeadStopSteadyRelayId = relayWashMachineStruct->TrainHeadStopSteadyRelayId; + pWashMachineCfgDtStr->TrainTailStopSteadyRelayId = relayWashMachineStruct->TrainTailStopSteadyRelayId; + pWashMachineCfgDtStr->TrainPassRequestRelayId = relayWashMachineStruct->TrainPassRequestRelayId; + pWashMachineCfgDtStr->TrainOutWashPortAllowRelayId = relayWashMachineStruct->TrainOutWashPortAllowRelayId; + pWashMachineCfgDtStr->PauseTrainWashRequestRelayId = relayWashMachineStruct->PauseTrainWashRequestRelayId; + pWashMachineCfgDtStr->WashModeBackRelayId = relayWashMachineStruct->WashModeBackRelayId; + + pWashMachineCfgDtStr->WashModeRelayId = relayWashMachineStruct->WashModeRelayId; + pWashMachineCfgDtStr->wDownWashAllowRelayId = relayWashMachineStruct->wDownWashAllowRelayId; + pWashMachineCfgDtStr->wDownWashAllowLightRelayId = relayWashMachineStruct->wDownWashAllowLightRelayId; + pWashMachineCfgDtStr->wDownWashAllowPassRelayId = relayWashMachineStruct->wDownWashAllowPassRelayId; + pWashMachineCfgDtStr->wDownWashRelateRoute1Id = relayWashMachineStruct->wDownWashRelateRoute1Id; + pWashMachineCfgDtStr->wDownWashRelateRoute1CheckType = relayWashMachineStruct->wDownWashRelateRoute1CheckType; + pWashMachineCfgDtStr->wDownWashRelRoute1LightRelayId = relayWashMachineStruct->wDownWashRelRoute1LightRelayId; + pWashMachineCfgDtStr->wDownWashRelateRoute2Id = relayWashMachineStruct->wDownWashRelateRoute2Id; + pWashMachineCfgDtStr->wDownWashRelateRoute2CheckType = relayWashMachineStruct->wDownWashRelateRoute2CheckType; + pWashMachineCfgDtStr->wDownWashRelRoute2LightRelayId = relayWashMachineStruct->wDownWashRelRoute2LightRelayId; + + + retVal = 1u; + } + return retVal; +} + +/********************************************* +*ܣȡźŻ +*˵pRelaySgnl̵źŻṹָ +pSgnlDSUźŻṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 getSignalType(Relay_SignalStruct* pRelaySgnl,DSU_SIGNAL_STRU* pSgnl) +{ + UINT8 MyType = 0u; + UINT16 i; + UINT8 BaseType[] = {0x01u,0x02u,0x04u,0x08u,0x10u,0x20u,0x40u}; + UINT8 RtnType[14] = {0u}; + UINT8 MyRtnType[14] = {SIGNAL_TYPE_THREE_ALL_YINDAO,SIGNAL_TYPE_THREE_ALL_NOYINDAO, + SIGNAL_TYPE_THREE_NOGREEN_YINDAO,SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO, + SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO,SIGNAL_TYPE_TWO_ALL_NOYINDAO, + SIGNAL_TYPE_TWO_NOGREEN_NOYINDAO,SIGNAL_TYPE_DIAOCHE,SIGNAL_TYPE_THREE_NOYELLOW_YINDAO, + SIGNAL_TYPE_JINKUCHUKU,SIGNAL_TYPE_THREE_ALL_YINDAO_NOY,SIGNAL_TYPE_THREE_JINKU_YINDAO,SIGNAL_TYPE_TWO_JINKU_RGY, + SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL}; + + /*ڲ*/ + if((NULL == pRelaySgnl) || (NULL == pSgnl)) + { + /*ʧ*/ + return 0u; + } + + /*źŻ(ʾλ)DJ2DJDDJLXJZXJYXJ*/ + RtnType[0] = BaseType[DJ]|BaseType[DJ2]|BaseType[DDJ]|BaseType[LXJ]|BaseType[ZXJ]|BaseType[YXJ]; + /*źŻ(ʾλ)DJDDJLXJZXJ*/ + RtnType[1] = BaseType[DJ]|BaseType[DDJ]|BaseType[LXJ]|BaseType[ZXJ]; + /*źŻ(ʾ̵ƣ)DJ2DJDDJLXJYXJ*/ + RtnType[2] = BaseType[DJ]|BaseType[DJ2]|BaseType[DDJ]|BaseType[LXJ]|BaseType[YXJ]; + + /*źŻ(ʾ̵ƣ)DJDDJLXJ*/ + RtnType[3] = BaseType[DJ]|BaseType[DDJ]|BaseType[LXJ]; + + /*վźŻ(ʾƵ)DJDDJLXJ*/ + RtnType[4] = BaseType[DJ]|BaseType[DDJ]|BaseType[LXJ]; + + /*վָ赲źŻ(ʾλ)DJDDJLXJ*/ + RtnType[5] = BaseType[DJ]|BaseType[DDJ]|BaseType[LXJ]; + + /*赲źŻ(ʾ̵)DJ*/ + RtnType[6] = BaseType[DJ]; + + /*źŻDXJDJ*/ + RtnType[7] = BaseType[DXJ]|BaseType[DJ]; + + /*źŻ(ʾ)LXJYXJDJ2DJ*/ + RtnType[8] = BaseType[DJ]|BaseType[DJ2]|BaseType[LXJ]|BaseType[YXJ]; + + /*/źŻ(ʾ) DJLXJDXJ*/ + RtnType[9] = BaseType[DJ]|BaseType[DXJ]|BaseType[LXJ]; + + /*źŻ(ʾƣɵƵƣ)*/ + RtnType[10] = BaseType[DJ]|BaseType[DJ2]|BaseType[DDJ]|BaseType[LXJ]|BaseType[YXJ]; + + /*źŻʾ»2019.1.15*/ + RtnType[11] = BaseType[DJ]|BaseType[DJ2]|BaseType[DXJ]|BaseType[LXJ]|BaseType[YXJ]; + + /*/źŻ(ʾ)*/ + RtnType[12] = BaseType[LXJ]|BaseType[YXJ]; + + /*źŻ(ʾ̵ƣ)*/ + RtnType[13] = BaseType[DJ]|BaseType[DJ2]|BaseType[LXJ]|BaseType[YXJ]; + + if(pRelaySgnl->wRelayDengSiId_1 != 0u) + { + MyType |= 0x01u; + } + if(pRelaySgnl->wRelayDengSiId_2 != 0u) + { + MyType |= 0x02u; + } + if(pRelaySgnl->wRelayTrainSignalId != 0u) + { + MyType |= 0x04u; + } + if(pRelaySgnl->wRelayZhengXianId != 0u) + { + MyType |= 0x08u; + } + if(pRelaySgnl->wRelayYinDaoId != 0u) + { + MyType |= 0x10u; + } + if(pRelaySgnl->wRelayDianDengId != 0u) + { + MyType |= 0x20u; + } + if(pRelaySgnl->wRelayDiaoCheSignalId != 0u) + { + MyType |= 0x40u; + } + + for(i=0u;i<14u;i++) + { + if((MyType==RtnType[i])&&(MyType!=RtnType[5])&&(MyType!=RtnType[2])&&(MyType!=RtnType[8])) + { + return MyRtnType[i]; + } + if(MyType==RtnType[5]) + { + /*ʾ*/ + if (pSgnl->dwSignalDengLie >> 7u == 0x00u) + { + return SIGNAL_TYPE_TWO_ALL_NOYINDAO; + } + else/*ʾ*/ + { + /*Ƶ*/ + if((pSgnl->sDengWeiFengBi | 0xfbu) == 0xfbu) + { + return SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO; + } + else + { + return SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO; + } + } + + } + if (MyType==RtnType[2]) + { + /*̵*/ + if((pSgnl->sDengWeiFengBi | 0xfdu) == 0xfdu) + { + return SIGNAL_TYPE_THREE_NOGREEN_YINDAO; + } + else + { + return SIGNAL_TYPE_THREE_ALL_YINDAO_NOY; + } + } + if (MyType == RtnType[8]) + { + /*̵*/ + if ((pSgnl->sDengWeiFengBi | 0xfdu) == 0xfdu) + { + return SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL; + } + else + { + return SIGNAL_TYPE_THREE_NOYELLOW_YINDAO; + } + } + } + return 0u; +} + +/********************************************* +*ܣӵṹ̵ṹ +*˵pPoint̵ṹָ +pSwitchCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SwitchCfgDtStruFromDquPointStr(DSU_POINT_STRU* pPoint,SwitchConfigDataStruct* pSwitchCfgDtStr) +{ + UINT16 i=0u; + UINT16 j=0u; + UINT8 rtnvalue = 0u; + + /*ڲ*/ + if((NULL == pPoint) || (NULL == pSwitchCfgDtStr)) + { + /*ʧ*/ + return 0u; + } + + pSwitchCfgDtStr->SwitchId = pPoint->wId; + pSwitchCfgDtStr->BelongCiId = (UINT8)pPoint->wManagePhysicalCI; + pSwitchCfgDtStr->BelongVirCI = (UINT8)pPoint->wBelongVirCI;/**/ + pSwitchCfgDtStr->dwSwitchKilo = pPoint->dwPointKilo; /* */ + pSwitchCfgDtStr->chKiloType = pPoint->dwPointKiloPlueMinusSign; + if (pSwitchCfgDtStr->SwitchId < SWITCH_SUM_MAX) + { + pSwitchCfgDtStr->BelongOcId = dquCICfgDtStr.OCSwitchCfgStr[pSwitchCfgDtStr->SwitchId].BelongOcId; + } + pSwitchCfgDtStr->DSwitchOtherId = (pPoint->DPointOtherId != 0xffffu)?pPoint->DPointOtherId:0U; + pSwitchCfgDtStr->SwitchPhySecId = 0xffu; + pSwitchCfgDtStr->SwitchIsThisLine = DEV_IS_THIS_LINE_YES; + /*cgh-ϲCID-2341-10*/ + pSwitchCfgDtStr->DsRelayId = 0u; + pSwitchCfgDtStr->DsQRelayId = 0u; + pSwitchCfgDtStr->DsHRelayId = 0u; + pSwitchCfgDtStr->ByPassRelayId = 0u; + for(j=0u;jwId==(RelayData.pRelayPointStr+j)->wPointId) + { + pSwitchCfgDtStr->DbRelayId = (RelayData.pRelayPointStr+j)->wRelayDingBiaoId; + pSwitchCfgDtStr->FbRelayId = (RelayData.pRelayPointStr+j)->wRelayFanBiaoId; + pSwitchCfgDtStr->YcRelayId = (RelayData.pRelayPointStr+j)->wRelayYunCaoId; + pSwitchCfgDtStr->DcRelayId = (RelayData.pRelayPointStr+j)->wRelayDingCaoId; + pSwitchCfgDtStr->FcRelayId = (RelayData.pRelayPointStr+j)->wRelayFanCaoId; + pSwitchCfgDtStr->ZDbRelayId = (RelayData.pRelayPointStr+j)->wRelayZongDingBiaoId; + pSwitchCfgDtStr->ZFbRelayId = (RelayData.pRelayPointStr+j)->wRelayZongFanBiaoId; + pSwitchCfgDtStr->DFHRelayId = (RelayData.pRelayPointStr+j)->wDFHId; + pSwitchCfgDtStr->wShadowDbRelayId = (RelayData.pRelayPointStr + j)->wRelayShadowDingBiaoId; + pSwitchCfgDtStr->wShadowFbRelayId = (RelayData.pRelayPointStr + j)->wRelayShadowFanBiaoId; + if (pSwitchCfgDtStr->SwitchId>0u) + { + if (0u == pSwitchCfgDtStr->DbRelayId) + { + debug_infor_printf((const)"Switch %d DBJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->DbRelayId); + DebugPrintAppError(ERROR_SWITCH_DBJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,pSwitchCfgDtStr->SwitchId,PRINT_ONCE); + } + if (0u == pSwitchCfgDtStr->FbRelayId) + { + debug_infor_printf((const)"Switch %d FBJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->FbRelayId); + DebugPrintAppError(ERROR_SWITCH_FBJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,(UINT32)(pSwitchCfgDtStr->SwitchId),PRINT_ONCE); + } + if (0u == pSwitchCfgDtStr->YcRelayId) + { + debug_infor_printf((const)"Switch %d YCJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->YcRelayId); + DebugPrintAppError(ERROR_SWITCH_YCJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,(UINT32)(pSwitchCfgDtStr->SwitchId),PRINT_ONCE); + } + if (0u == pSwitchCfgDtStr->DcRelayId) + { + debug_infor_printf((const)"Switch %d DCJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->DcRelayId); + DebugPrintAppError(ERROR_SWITCH_DCJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,(UINT32)(pSwitchCfgDtStr->SwitchId),PRINT_ONCE); + } + if (0u == pSwitchCfgDtStr->FcRelayId) + { + debug_infor_printf((const)"Switch %d FCJ %d not config.",pSwitchCfgDtStr->SwitchId,pSwitchCfgDtStr->FcRelayId); + DebugPrintAppError(ERROR_SWITCH_FCJ_NOT_CONFIG,CI_DEVICE_TYPE_SWITCH,(UINT32)(pSwitchCfgDtStr->SwitchId),PRINT_ONCE); + } + } + break; + } + } + + for(i=0u;iwRelatPointNum;j++) + { + if(pSwitchCfgDtStr->SwitchId == (dsuStaticHeadStru.pAxleSgmtStru+i)->wRelatPointId[j]) + { + pSwitchCfgDtStr->SwitchPhySecId = (dsuStaticHeadStru.pAxleSgmtStru+i)->wRelatePhysicalSgmtId; + + /*ҵ̵ֱӷ*/ + rtnvalue = 1u; + return rtnvalue; + } + } + } + rtnvalue = 0u; + return rtnvalue; +} + +/********************************************* +*ܣϵ +*˵ + pSwitchCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*mod by qw.liu 2022-02-28 ӵӦӳϵ +*********************************************/ +UINT8 SwitchCfgDtStruFromLSProHostStr(SwitchConfigDataStruct* pSwitchCfgDtStr) +{ + UINT16 i=0u; + UINT16 j=0u; + UINT8 rtnvalue = 0u; + + if (NULL == pSwitchCfgDtStr) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + if (1u == rtnvalue) + { + pSwitchCfgDtStr->HostSwitchNum = 0u; + for (i=0u;iHostSwitchIdBuf[i] = 0u; + } + + pSwitchCfgDtStr->wProtectSwitchNum = 0u; + for (i = 0u; iwszProtectSwitchIdBuf[i] = 0u; + } + for (i=0u;iSwitchId == LSData.pLSProSwitchHostSwitchMapStru[i].wProSwitchID) + { + for (j=0u;jHostSwitchIdBuf[pSwitchCfgDtStr->HostSwitchNum] = LSData.pLSProSwitchHostSwitchMapStru[i].wHostSwitchIDBuf[j]; + pSwitchCfgDtStr->HostSwitchNum++; + } + } + break; + } + + } + + + for (i = 0u; i < LSDataLen.LS_ProSwitchHostSwitchMapStruLen; i++) + { + /*ҵΪ˵IDݣֵ*/ + for (j = 0u; j < SWITCH_HOST_SWITCH_MAX_NUM; j++) + { + if ((LSData.pLSProSwitchHostSwitchMapStru[i].wHostSwitchIDBuf[j] == pSwitchCfgDtStr->SwitchId)) + { + if ((0U != LSData.pLSProSwitchHostSwitchMapStru[i].wProSwitchID) && + (0xffffU != LSData.pLSProSwitchHostSwitchMapStru[i].wProSwitchID)) + { + pSwitchCfgDtStr->wszProtectSwitchIdBuf[pSwitchCfgDtStr->wProtectSwitchNum] = LSData.pLSProSwitchHostSwitchMapStru[i].wProSwitchID; + pSwitchCfgDtStr->wProtectSwitchNum++; + } + + break; + } + else + { + /*޸õִ*/ + } + } + } + } + + return rtnvalue; +} +/* +*ܣ߼ +*˵pSwitchStr ӵͼṹָ +* pSwitchCfgDtStr ýṹָ +*ֵ0ʧܣ1ɹ +*/ +UINT8 SwitchCfgLogTrackInitDquStr(DSU_POINT_STRU* pSwitchStr,SwitchConfigDataStruct* pSwitchCfgDtStr) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 rtnvalue = CI_ERROR; + DSU_LOGIC_SGMT_STRU* pDsuLogStr = NULL; + UINT8 k = 0u; + UINT8 keepWork = CI_ERROR; + + + /*ǿ*/ + if(NULL != pSwitchCfgDtStr) + { + rtnvalue = CI_SUCCESS; + keepWork = CI_SUCCESS; + /*ʼΪ0*/ + pSwitchCfgDtStr->SwitchLogSecSum = 0u; + for(i = 0u; i < SWITCH_LOG_TRACK_MAX_NUM; i++) + { + pSwitchCfgDtStr->SwitchLogSecIdBuf[i] = 0u; + } + + /*߼Σ߼ιĵγɵ߼εӳ䡣*/ + for (j = 0u; j < dsuDataLenStru.wLogicSgmtLen; j++) + { + pDsuLogStr = dsuStaticHeadStru.pLogicSgmtStru + j; + for (k = 0u; k < pDsuLogStr->chSwitchNum; k++) + { + if (SWITCH_LOG_TRACK_MAX_NUM > pSwitchCfgDtStr->SwitchLogSecSum) + { + if (pDsuLogStr->wSwitchId[k] == pSwitchCfgDtStr->SwitchId) + { + pSwitchCfgDtStr->SwitchLogSecIdBuf[pSwitchCfgDtStr->SwitchLogSecSum++] = pDsuLogStr->wId; + } + else + { + /**/ + } + } + else + { + keepWork = CI_ERROR; + } + } + + if (CI_SUCCESS != keepWork) + { + rtnvalue = CI_ERROR; + break; + } + else + { + + } + + } + } + else + { + rtnvalue = CI_ERROR; + } + return(rtnvalue); +} + +/* zt ɾش 2022-02-15 */ + + +/********************************************* +*ܣνṹμ̵ṹ +*˵pPhysicalSgmtνṹָ +pPsclSgmtCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PhySgmtCfgDtStruFromDquSgmtStr(DSU_PHYSICAL_SGMT_STRU* pPhysicalSgmt, PhysicalSectionConfigDataStruct* pPsclSgmtCfgDtStr, SignalConfigDataStruct* pSgnlCfgDtStr) +{ + UINT16 ii = 0u; + UINT16 j = 0u; + UINT16 axleSgmtManageZC = 0u;/*ֲ*/ + UINT8 rtnvalue = 0u; + UINT16 k = 0u; + UINT8 acFty = GetCiFunctionSwitchConfig(FUNC_SWITCH_AC_FACTORY); + UINT16 wLogIndex = 0U; + UINT8 logsecSum = 0U; + UINT8 isEachInvFlag = 0U; + /*ڲ*/ + if ((NULL != pPhysicalSgmt) && (NULL != pPsclSgmtCfgDtStr) && (NULL != pSgnlCfgDtStr)) + { + pPsclSgmtCfgDtStr->PhysicalSectionId = pPhysicalSgmt->wId; + if (PHYSICAL_SECTION_SUM_MAX > pPsclSgmtCfgDtStr->PhysicalSectionId) + { + pPsclSgmtCfgDtStr->BelongOcId = dquCICfgDtStr.OCPhySecCfgStr[pPsclSgmtCfgDtStr->PhysicalSectionId].BelongOcId; + } + else + { + } + pPsclSgmtCfgDtStr->PhySecType = pPhysicalSgmt->Type; + pPsclSgmtCfgDtStr->LjkSecFlag = pPhysicalSgmt->LjkFlag; + pPsclSgmtCfgDtStr->BelongAxleSysID = pPhysicalSgmt->BelongAxleSysID; + pPsclSgmtCfgDtStr->AxisSectionSum = 0u; + pPsclSgmtCfgDtStr->LocatedFloodGateSum = 0U; /*ڷʼΪ0*/ + for (j = 0U; j < FLOOD_GATE_SUM_MAX; j++) + { + pPsclSgmtCfgDtStr->LocatedFloodGateId[j] = 0U; /*ڷidʼΪ0*/ + } + pPsclSgmtCfgDtStr->PhyIsThisLine = DEV_IS_THIS_LINE_YES; /*ʼ·*/ + /*IDǷZCϽӶӦл*/ + for (j = 0u; j < dsuDataLenStru.wAxleSgmtLen; j++) + { + if (pPhysicalSgmt->wId == (dsuStaticHeadStru.pAxleSgmtStru + j)->wRelatePhysicalSgmtId) + { + pPsclSgmtCfgDtStr->BelongCiId = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru + j)->wManagePhysicalCI; + pPsclSgmtCfgDtStr->BelongVirCI = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru + j)->BelongVirCI; + axleSgmtManageZC = (dsuStaticHeadStru.pAxleSgmtStru + j)->wManageZC;/*ZC*/ + if ((0u != axleSgmtManageZC) && (UINT16_MAX != axleSgmtManageZC)) + {/*ZCЧZCϽ*/ + pPsclSgmtCfgDtStr->managedByZcFlag = PHY_SEC_MANAGED_BY_ZC_YES; + } + else + {/*ZCЧβZCϽ*/ + pPsclSgmtCfgDtStr->managedByZcFlag = PHY_SEC_MANAGED_BY_ZC_NO; + } + break; + } + else + { + } + } + for (j = 0u; j < dsuDataLenStru.wAxleSgmtLen; j++) + { + if (pPhysicalSgmt->wId == (dsuStaticHeadStru.pAxleSgmtStru + j)->wRelatePhysicalSgmtId) + { + pPsclSgmtCfgDtStr->AxisSectionIdBuf[pPsclSgmtCfgDtStr->AxisSectionSum++] = (dsuStaticHeadStru.pAxleSgmtStru + j)->wId; + + } + else + { + } + } + if ((0u < dquCICfgDtStr.OCPhySecCfgStrLen) || ((AXIS_TYPE_YONGLIE == acFty) || (AXIS_TYPE_KEANDA == acFty))) + { + rtnvalue = 1u; + /*ȫӼܸλ*/ + for (j = 0u; j < RelayDataLen.RelayPhysicalSgmtStrLen; j++) + { + if (pPhysicalSgmt->wId == (RelayData.pRelayPhysicalSgmtStr + j)->wPhysicalId) + { + pPsclSgmtCfgDtStr->ZFWRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayAxleZongRetrunId; + pPsclSgmtCfgDtStr->ZFWShowRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRepRelayZongResetShowId; + break; + } + else + { + } + } + } + else + { + for (j = 0u; j < RelayDataLen.RelayPhysicalSgmtStrLen; j++) + { + if (pPhysicalSgmt->wId == (RelayData.pRelayPhysicalSgmtStr + j)->wPhysicalId) + { + pPsclSgmtCfgDtStr->FWRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayAxleRetrunId; + pPsclSgmtCfgDtStr->GdRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayRailwayId; + pPsclSgmtCfgDtStr->wGdRelayId2 = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayRailwayId2; + pPsclSgmtCfgDtStr->ZFWRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayAxleZongRetrunId; + pPsclSgmtCfgDtStr->PreResetRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRelayAxlePreResetId; + pPsclSgmtCfgDtStr->RepGdRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRepRelayTrainId;/*ӹ̵*/ + pPsclSgmtCfgDtStr->ZFWShowRelayId = (RelayData.pRelayPhysicalSgmtStr + j)->wRepRelayZongResetShowId; + if (0u == pPsclSgmtCfgDtStr->GdRelayId) + { + debug_infor_printf((const)"Phy %d GJ %d not config.", pPsclSgmtCfgDtStr->PhysicalSectionId, pPsclSgmtCfgDtStr->GdRelayId); + DebugPrintAppError(ERROR_PHYSEC_GJ_NOT_CONFIG, CI_DEVICE_TYPE_PHYSEC, (UINT32)(pPsclSgmtCfgDtStr->PhysicalSectionId), PRINT_ONCE); + } + else + { + for (k = 0u; k < RelayDataLen.RelayCfgDtStrLen; k++)/* RelayData.pRelayCfgDtStr)*/ + { + if (RelayData.pRelayCfgDtStr[k].RelayId == pPsclSgmtCfgDtStr->GdRelayId) + { + if (RelayData.pRelayCfgDtStr[k].CollMode != RELAY_COLL_MODE_DOUBLE) + { + debug_infor_printf((const)"Phy %d GJ %d not double coll-mode.", pPsclSgmtCfgDtStr->PhysicalSectionId, pPsclSgmtCfgDtStr->GdRelayId); + DebugPrintAppError(ERROR_PHYSEC_GJ_NOT_DOUBLE_COLL, CI_DEVICE_TYPE_PHYSEC, (((UINT32)pPsclSgmtCfgDtStr->PhysicalSectionId << 16u) + pPsclSgmtCfgDtStr->GdRelayId), PRINT_ONCE); + } + else + { + } + break; + } + else + { + } + + } + + } + + /*ҵӦκֱӷ*/ + rtnvalue = 1u; + break; + } + else + { + } + } + } + } + else + { + } + + if (1u == rtnvalue) + { + /* ιվźŻ */ + pPsclSgmtCfgDtStr->relateOutStationSignalNum = 0u; + /* źŻвҶӦźŻⷽһID */ + for (j = 0u; j < dsuDataLenStru.wSignalLen; j++) + { + + if (pPsclSgmtCfgDtStr->PhysicalSectionId == pSgnlCfgDtStr[j].OutFirstPhySecId) + {/* жϵǰźŻⷽһǷڱ */ + pPsclSgmtCfgDtStr->relateOutStationSignalIdBuff[pPsclSgmtCfgDtStr->relateOutStationSignalNum] = pSgnlCfgDtStr[j].SignalId; + pPsclSgmtCfgDtStr->relateOutStationSignalNum++; + } + else + { + } + } + } + else + { + } + if (1u == rtnvalue) + { + pPsclSgmtCfgDtStr->trackSecNum = 0u;/*ʼŶձʱݱŶձйαгʼ*/ + for (j = 0u; j < PHY_SEC_TRACK_SEC_MAX_SUM; j++) + { + pPsclSgmtCfgDtStr->trackSecBuf[j] = 0u; + } + } + else + { + } + + if (1U == rtnvalue) + { + /**߼γʼݣε߼εӳ*/ + pPsclSgmtCfgDtStr->LogSectionSum = 0U; + for (wLogIndex = 0u; wLogIndex < dsuDataLenStru.wLogicSgmtLen; wLogIndex++) + { + if (pPsclSgmtCfgDtStr->PhysicalSectionId == dsuStaticHeadStru.pLogicSgmtStru[wLogIndex].wRelatPhySecId) + { + logsecSum = pPsclSgmtCfgDtStr->LogSectionSum; + pPsclSgmtCfgDtStr->LogSectionIdBuf[logsecSum] = dsuStaticHeadStru.pLogicSgmtStru[wLogIndex].wId; + pPsclSgmtCfgDtStr->LogSectionSum++; + } + else + { + + } + } + } + else + { + + } + + if (1u == rtnvalue) + { /*εμ*/ + isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION); + /*þɰݱȡ*/ + if (FUNC_SWITCH_OFF == isEachInvFlag) + { + /*εμ*/ + pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum = 0u; + for (ii = 0u; ii < LSDataLen.LS_PhySectionIntrudeStruLen; ii++) + { /*εμ*/ + if (LSData.pLSPhyIntruPhySecStru[ii].physicalId == pPsclSgmtCfgDtStr->PhysicalSectionId) + { + for (j = 0u; j < SEC_INVASECT_N_CONDSWIT_SUM_MAX; j++) + { + if (0u != LSData.pLSPhyIntruPhySecStru[ii].phyInvSecAndConSwiId[j]) + { + pPsclSgmtCfgDtStr->SecInvSecAndConSwiId[pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum] = LSData.pLSPhyIntruPhySecStru[ii].phyInvSecAndConSwiId[j]; + pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum++; + } + else + { + ; + } + + } + } + else + { + ; + } + } + } + /*߼λת*/ + else + { + pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum = 0u; + + /*μ*/ + for (j = 0u; j < LSDataLen.LSIntruPhySecStrLen; j++) + { + if ((LSData.pLSIntruPhySecStr[j].belongPhySecId == pPsclSgmtCfgDtStr->PhysicalSectionId) && (0U != LSData.pLSIntruPhySecStr[j].belongPhySecId)) + { + if (SEC_INVASECT_N_CONDSWIT_SUM_MAX > pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum) + { + pPsclSgmtCfgDtStr->SecInvSecAndConSwiId[pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum] = LSData.pLSIntruPhySecStr[j].wId; + pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum++; + } + else + { + /*߼Χʼʧ*/ + rtnvalue = 0U; + debug_infor_printf((const)"[PhySecInv]PhySecID:%d ERROR: SecInvSecAndConSwiSum Is Exceed MAX\n", pPsclSgmtCfgDtStr->PhysicalSectionId); + break; + } + } + else + { + ; + } + } + + } + + /*־дӡ޹ϵ*/ + if ((0U < pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum) && (1U == rtnvalue)) + { + for (ii = 0U; ii < pPsclSgmtCfgDtStr->SecInvSecAndConSwiSum; ii++) + { + debug_infor_printf((const)"[PhySecInv] PhySecID:%d, InvDataID:%d\n", pPsclSgmtCfgDtStr->PhysicalSectionId, pPsclSgmtCfgDtStr->SecInvSecAndConSwiId[ii]); + } + } + else + { + ; + } + } + else + { + ; + } + + return rtnvalue; +} + + +/********************************************* +*ܣݽṹ +*˵pAxleSgmtνṹָ +pAxScCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 AxisSecCfgDtStruFromDquSgmtStr(DSU_AXLE_SGMT_STRU* pAxleSgmt, AxisSectionConfigDataStruct* pAxScCfgDtStr) +{ + UINT16 j = 0u; + UINT8 rtnvalue = 0u; + UINT8 cDir = EMAP_SAME_DIR; + LOD_STRU LODAPointStru = { 0u }; + LOD_STRU LODBPointStru = { 0u }; + UINT16 wlinkNum = 0u; + UINT16 szLinkIdBuf[100u] = { 0u }; + UINT32 dwLen = UINT32_MAX; + + /*ڲ*/ + if ((NULL == pAxleSgmt) || (NULL == pAxScCfgDtStr)) + { + /*ʧ*/ + return 0u; + } + + /*ֱӴӼαлȡ*/ + pAxScCfgDtStr->AxisSectionId = pAxleSgmt->wId; + pAxScCfgDtStr->RelativePhySecId = pAxleSgmt->wRelatePhysicalSgmtId; + pAxScCfgDtStr->LogSectionSum = (UINT8)pAxleSgmt->wIncludeLogicSgmtNum; + pAxScCfgDtStr->AxisSwitchSum = (UINT8)pAxleSgmt->wRelatPointNum; + pAxScCfgDtStr->wOrgnAxisId = pAxleSgmt->wOrgnAxleId; + pAxScCfgDtStr->wTmnlAxisId = pAxleSgmt->wTmnlAxleId; + pAxScCfgDtStr->dwAxisTotalLen = 0U; + + for (j = 0u; j < AXIS_INCLUDE_LOG_SUM_MAX; j++) + { + pAxScCfgDtStr->LogSectionIdBuf[j] = (pAxleSgmt->wLogicSgmtId[j] != 0xffffu ? pAxleSgmt->wLogicSgmtId[j] : 0U); + } + for (j = 0u; j < pAxScCfgDtStr->AxisSwitchSum; j++) + { /*ȡιĵϢ*/ + pAxScCfgDtStr->AxisSwitchIdStru[j].SwitchId = pAxleSgmt->wRelatPointId[j]; + pAxScCfgDtStr->AxisSwitchIdStru[j].SwitchPosition = (UINT8)pAxleSgmt->wRelatPointStatus[j]; + } + + if (pAxleSgmt->wOrgnLkId == pAxleSgmt->wTmnlLkId) + { + pAxScCfgDtStr->chLinkNum = 1u; + pAxScCfgDtStr->szLinkIdBuff[0u] = pAxleSgmt->wOrgnLkId; + pAxScCfgDtStr->dwAxisTotalLen += pAxleSgmt->dwTmnlLinkOfst; + } + else + { + LODAPointStru.Lnk = pAxleSgmt->wOrgnLkId; + LODAPointStru.Off = 0U; + LODAPointStru.Dir = EMAP_SAME_DIR; + LODBPointStru.Lnk = pAxleSgmt->wTmnlLkId; + LODBPointStru.Off = pAxleSgmt->dwTmnlLinkOfst; + LODBPointStru.Dir = EMAP_SAME_DIR; + dwLen = dsuLenByPoint(&LODAPointStru, &LODBPointStru, &wlinkNum, szLinkIdBuf, &cDir); + + if ((UINT32_MAX != dwLen) && (AXIS_INCLUDE_LINK_SUM_MAX >= wlinkNum)) + { + pAxScCfgDtStr->chLinkNum = (UINT8)wlinkNum; + for (j = 0U; j < wlinkNum; j++) + { + pAxScCfgDtStr->szLinkIdBuff[j] = szLinkIdBuf[j]; + } + } + pAxScCfgDtStr->dwAxisTotalLen = dwLen; + } + + + /*ԭΪߵļᣬlinkؽߵģֻҪȡһlinkУԼ*/ + + if (LINK_LINXIAN_YES == dsuStaticHeadStru.pLinkStru[dsuLinkIndex[pAxScCfgDtStr->szLinkIdBuff[0u]]].wLinxian) + { + pAxScCfgDtStr->chAxisLinXian = AXIS_SEC_LINXIAN_YES; + } + else + { + pAxScCfgDtStr->chAxisLinXian = AXIS_SEC_LINXIAN_NO; + } + + rtnvalue = 1u; + return rtnvalue; +} + +/********************************************* +*ܣ߼ݽṹ +*˵pLogicSgmt߼νṹָ +pLgScCfgDtStr߼ݽṹָ +*ֵ0ʧܣ1ɹ +*modify 20220921 TIOC5.0 +*********************************************/ +UINT8 LogicSecCfgDtStruFromDquSgmtStr(DSU_LOGIC_SGMT_STRU* pLogicSgmt,LogicSectionConfigDataStruct* pLgScCfgDtStr) +{ + UINT8 rtnvalue = 0u; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 cDir = EMAP_SAME_DIR; + LOD_STRU LODAPointStru = { 0u }; + LOD_STRU LODBPointStru = { 0u }; + UINT16 wlinkNum = 0u; + UINT16 szLinkIdBuf[100u] = { 0u }; + UINT32 dwLen = UINT32_MAX; + UINT8 kk = 0u; + UINT8 hh = 0u; + UINT8 chLogSecLastLogSecSum = 0U;/*߼*/ + UINT8 chLogSecNextLogSecSum = 0U;/*յ߼*/ + UINT8 chForeachEndFlag = 0U;/*յ߼βɱ־*/ + DSU_LINK_STRU* pLogSecIncLinkStru = NULL; /*߼ΰlinkṹ*/ + UINT8 isEachInvFlag = 0U; + UINT16 wSignalAttribute = 0U; + + + /*ڲ*/ + if ((NULL != pLogicSgmt) && (NULL != pLgScCfgDtStr)) + { + rtnvalue = 1u; + pLgScCfgDtStr->LogicSectionId = pLogicSgmt->wId; + pLgScCfgDtStr->belongCiId = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pLogicSgmt->wAxleSgmtId[0]]].wManagePhysicalCI); + pLgScCfgDtStr->belongVirCI = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pLogicSgmt->wAxleSgmtId[0]]].BelongVirCI); + pLgScCfgDtStr->chRelativeAxleSum = pLogicSgmt->chAxleSgmtSum; + for (kk = 0u; kk < pLogicSgmt->chAxleSgmtSum; kk++) + { + pLgScCfgDtStr->wRelativeAxleSecId[kk] = pLogicSgmt->wAxleSgmtId[kk]; + } + + pLgScCfgDtStr->wRelativePhySecId = pLogicSgmt->wRelatPhySecId; + pLgScCfgDtStr->wOrgnLink = pLogicSgmt->wOrgnLkId; + pLgScCfgDtStr->dwOrgnOffset = pLogicSgmt->dwOrgnLkOfst; + pLgScCfgDtStr->wTmnlLink = pLogicSgmt->wTmnlLkId; + pLgScCfgDtStr->dwTmnlOffset = pLogicSgmt->dwTmnlLkOfst; + pLgScCfgDtStr->chLogsecSwitchSum = pLogicSgmt->chSwitchNum; + for (hh = 0u; hh < pLogicSgmt->chSwitchNum; hh++) + { + pLgScCfgDtStr->LogsecSwitchIdStru[hh].SwitchId = pLogicSgmt->wSwitchId[hh]; + pLgScCfgDtStr->LogsecSwitchIdStru[hh].SwitchPosition = pLogicSgmt->chSwitchPosition[hh]; + } + + + + /* ߼αlink */ + if (pLogicSgmt->wOrgnLkId == pLogicSgmt->wTmnlLkId) + { + pLgScCfgDtStr->chLinkNum = 1u; + pLgScCfgDtStr->szLinkIdBuff[0u] = pLogicSgmt->wOrgnLkId; + } + else + { + LODAPointStru.Lnk = pLogicSgmt->wOrgnLkId; + LODAPointStru.Off = 0u; + LODAPointStru.Dir = EMAP_SAME_DIR; + LODBPointStru.Lnk = pLogicSgmt->wTmnlLkId; + LODBPointStru.Off = 0u; + LODBPointStru.Dir = EMAP_SAME_DIR; + dwLen = dsuLenByPoint(&LODAPointStru, &LODBPointStru, &wlinkNum, szLinkIdBuf, &cDir); + + if ((UINT32_MAX != dwLen) && (AXIS_INCLUDE_LINK_SUM_MAX >= wlinkNum)) + { + pLgScCfgDtStr->chLinkNum = (UINT8)wlinkNum; + + for (ii = 0u; ii < wlinkNum; ii++) + { + pLgScCfgDtStr->szLinkIdBuff[ii] = szLinkIdBuf[ii]; + } + } + } + + pLgScCfgDtStr->cCbtcProperty = LOGSEC_CBTC_PROPERTY_NO; /*ʼ߼βCBTC*/ + /*߼ΰlinkȷ߼εCBTC*/ + for (kk = 0U; kk < pLgScCfgDtStr->chLinkNum; kk++) + { + pLogSecIncLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pLgScCfgDtStr->szLinkIdBuff[kk]]; + if (0x55U != pLogSecIncLinkStru->cCbtcProperty) + { + break; /*linkCBTCԣֹͣ*/ + } + else + { + /*linkCBTCԣ*/ + } + } + + if ((kk == pLgScCfgDtStr->chLinkNum) && (0U != kk)) + { + pLgScCfgDtStr->cCbtcProperty = LOGSEC_CBTC_PROPERTY_YES; /*linkCBTCԣ߼ξCBTC*/ + } + else + { + /*linkCBTCԣ߼βCBTC*/ + } + + pLgScCfgDtStr->chLogLtrlDfncSwitchSum = 0u; + for (ii = 0u; ii < LSDataLen.LSLgcSecLtrlDfncStruLen; ii++) + { /*߼εIJ*/ + if (LSData.pLSLgcLrtlDfncStru[ii].wLogSecId == pLgScCfgDtStr->LogicSectionId) + { + for (jj = 0u; jj < LOGSEC_LTRL_DFNC_SUM_MAX; jj++) + { + if (0u != LSData.pLSLgcLrtlDfncStru[ii].stLrtlDfncSwitch[jj].wPointId) + { + pLgScCfgDtStr->LogLtrlDfncSwitchStru[pLgScCfgDtStr->chLogLtrlDfncSwitchSum].SwitchId = LSData.pLSLgcLrtlDfncStru[ii].stLrtlDfncSwitch[jj].wPointId; + pLgScCfgDtStr->LogLtrlDfncSwitchStru[pLgScCfgDtStr->chLogLtrlDfncSwitchSum].SwitchPosition = (UINT8)LSData.pLSLgcLrtlDfncStru[ii].stLrtlDfncSwitch[jj].wPointSta; + + if (LSData.pLSLgcLrtlDfncStru[ii].szProtectLockDir[jj] == dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown) + { + pLgScCfgDtStr->szLgcDfncLockDir[pLgScCfgDtStr->chLogLtrlDfncSwitchSum] = CI_SYSTEM_DIRECTION_DOWN; + } + else + { + pLgScCfgDtStr->szLgcDfncLockDir[pLgScCfgDtStr->chLogLtrlDfncSwitchSum] = CI_SYSTEM_DIRECTION_UP; + } + pLgScCfgDtStr->chLogLtrlDfncSwitchSum++; + } + + } + + break; + } + } + + /*еݶpLgScCfgDtStr ṹ*/ + pLgScCfgDtStr->chContactLineCheckSum = 0u; + for (ii = 0u; ii < LSDataLen.LSContactStruLen; ii++) + { + /*߼ι豸*/ + if (LSData.pLSContactLineStr[ii].wId == pLgScCfgDtStr->LogicSectionId) + { + for (jj = 0u; jj < PHY_SEC_CONTACT_CHECK_MAX_NUM; jj++) + { + if ((0U != LSData.pLSContactLineStr[ii].wPointId[jj])||(0U != LSData.pLSContactLineStr[ii].wAxisSecId[jj])) + { + if (0U != LSData.pLSContactLineStr[ii].wPointId[jj]) + { + pLgScCfgDtStr->LogContactSwitchCheckStru[pLgScCfgDtStr->chContactLineCheckSum].ContactSwitchId = LSData.pLSContactLineStr[ii].wPointId[jj]; + pLgScCfgDtStr->LogContactSwitchCheckStru[pLgScCfgDtStr->chContactLineCheckSum].ContactSwitchCheckState = LSData.pLSContactLineStr[ii].wPointSta[jj]; + } + + if (0U != LSData.pLSContactLineStr[ii].wAxisSecId[jj]) + { + pLgScCfgDtStr->chContactAxisCheckID[pLgScCfgDtStr->chContactLineCheckSum] = LSData.pLSContactLineStr[ii].wAxisSecId[jj]; + } + pLgScCfgDtStr->chContactLineCheckSum++; + } + } + + break; + } + } + +#if 0 + if ((0 != pLgScCfgDtStr->chLogLtrlDfncSwitchSum) && (0 != pLgScCfgDtStr->chSecInvSecAndConSwiSum)) + { + /*TODO ҵڲĵ޷ֵΪ෴ķ*/ + for (ii = 0U; ii < pLgScCfgDtStr->chSecInvSecAndConSwiSum; ii++) + { + for (jj = 0U; jj < LSDataLen.LSIntruPhySecStrLen; jj++) + { + if (pLgScCfgDtStr->wszSecInvSecAndConSwiId[ii] == LSData.pLSIntruPhySecStr[jj].wId) + { + for (kk = 0U; kk < QXQD_MAX_INCLUDE_POINT_NUM; kk++) + { + if ((0U != LSData.pLSIntruPhySecStr[jj].wPointId[kk]) + && (0xFFFFU != LSData.pLSIntruPhySecStr[jj].wPointId[kk])) + { + for (hh = 0U; hh < pLgScCfgDtStr->chLogLtrlDfncSwitchSum; hh++) + { + if (pLgScCfgDtStr->LogLtrlDfncSwitchStru[hh].SwitchId == LSData.pLSIntruPhySecStr[jj].wPointId[kk]) + { + pLgScCfgDtStr->chSecInvSecLockDir[ii] = ~pLgScCfgDtStr->szLgcDfncLockDir[hh]; + } + else + { + ; + } + } + } + else + { + break; + } + } + + break; + } + else + { + ; /**/ + } + } + } + } + else + { + ; /*ͬʱڣͲó*/ + } +#endif + isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION); + + /*þɰ汾߼*/ + if (FUNC_SWITCH_OFF == isEachInvFlag) + { + /*߼*/ + pLgScCfgDtStr->chSecInvSecAndConSwiSum = 0u; + for (ii = 0u; ii < LSDataLen.LSLgcSecIntruStruLen; ii++) + { /*εμ*/ + if (LSData.pLSLgcIntruSecStru[ii].wLogSecId == pLgScCfgDtStr->LogicSectionId) + { + for (jj = 0u; jj < LOGSEC_INV_N_CONDSWIT_SUM_MAX; jj++) + { + if (0u != LSData.pLSLgcIntruSecStru[ii].wszLogicInvSecAndConSwiId[jj]) + { + pLgScCfgDtStr->wszSecInvSecAndConSwiId[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = LSData.pLSLgcIntruSecStru[ii].wszLogicInvSecAndConSwiId[jj]; + pLgScCfgDtStr->chSecInvSecAndConSwiSum++; + + } + else + { + } + + } + break; + } + else + { + ; + } + } + /*߼εķμлȡ*/ + for (ii = 0U; ii < pLgScCfgDtStr->chSecInvSecAndConSwiSum; ii++) + { + for (jj = 0U; jj < LSDataLen.LSIntruPhySecStrLen; jj++) + { + if (pLgScCfgDtStr->wszSecInvSecAndConSwiId[ii] == LSData.pLSIntruPhySecStr[jj].wId) + { + if (0XFFU == LSData.pLSIntruPhySecStr[jj].wCondSwitLockDir) + { + pLgScCfgDtStr->chSecInvSecLockDir[ii] = CI_SYSTEM_DIRECTION_NONE; + } + else + { + if (dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown == LSData.pLSIntruPhySecStr[jj].wCondSwitLockDir) + { + pLgScCfgDtStr->chSecInvSecLockDir[ii] = CI_SYSTEM_DIRECTION_DOWN; + } + else + { + pLgScCfgDtStr->chSecInvSecLockDir[ii] = CI_SYSTEM_DIRECTION_UP; + } + } + } + } + } + + } + /*°汾߼λ*/ + else + { + /*߼*/ + pLgScCfgDtStr->chSecInvSecAndConSwiSum = 0u; + for (ii = 0u; ii < LSDataLen.LSIntruPhySecStrLen; ii++) + { /*μݱ*/ + + /*ҷ߼ID߼*/ + if ((LSData.pLSIntruPhySecStr[ii].belongLogSecId == pLgScCfgDtStr->LogicSectionId) && (0U != LSData.pLSIntruPhySecStr[ii].belongLogSecId)) + { + if (LOGSEC_INV_N_CONDSWIT_SUM_MAX > pLgScCfgDtStr->chSecInvSecAndConSwiSum) + { + pLgScCfgDtStr->wszSecInvSecAndConSwiId[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = LSData.pLSIntruPhySecStr[ii].wId; + + if (0XFFU == LSData.pLSIntruPhySecStr[ii].wCondSwitLockDir) + { + pLgScCfgDtStr->chSecInvSecLockDir[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = CI_SYSTEM_DIRECTION_NONE; + } + else + { + if (dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown == LSData.pLSIntruPhySecStr[ii].wCondSwitLockDir) + { + pLgScCfgDtStr->chSecInvSecLockDir[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = CI_SYSTEM_DIRECTION_DOWN; + } + else + { + pLgScCfgDtStr->chSecInvSecLockDir[pLgScCfgDtStr->chSecInvSecAndConSwiSum] = CI_SYSTEM_DIRECTION_UP; + } + } + pLgScCfgDtStr->chSecInvSecAndConSwiSum++; + } + else + { + /*޳ֵʧ*/ + rtnvalue = 0u; + debug_infor_printf((const)"[LogSecInv] LogSecID:%d ERROR: SecInvSecAndConSwiSum Is Exceed MAX\n", pLgScCfgDtStr->LogicSectionId); + break; + } + } + else + { + /**/ + } + } + } + + /*־дӡ߼޹ϵ*/ + if ((0U < pLgScCfgDtStr->chSecInvSecAndConSwiSum) && (1U == rtnvalue)) + { + for (ii = 0U; ii < pLgScCfgDtStr->chSecInvSecAndConSwiSum; ii++) + { + debug_infor_printf((const)"[LogSecInv] LogSecID:%d, InvData:%d, Dir:%d\n", pLgScCfgDtStr->LogicSectionId, pLgScCfgDtStr->wszSecInvSecAndConSwiId[ii], pLgScCfgDtStr->chSecInvSecLockDir[ii]); + + } + } + else + { + ; + } + +#if 1 + /*㱾߼ڵ߼Ӧ߼ID*/ + pLgScCfgDtStr->chBeginLogSecSum = 0u; + /*㱾߼յڵ߼Ӧ߼ID*/ + pLgScCfgDtStr->chEndLogSecSum = 0u; + for (ii = 0U; ii < dsuDataLenStru.wLinkLen; ii++) + {/*LINKҵ߼յLINKӦһ*/ + if (pLgScCfgDtStr->wTmnlLink == dsuStaticHeadStru.pLinkStru[ii].wId) + {/*߼յһ£һLINKж߼Σұ߼ΪLINKϵķһ*/ + /*߼յ㲻һ£ұ߼յLINKһLINKαֳ2߼Σ*/ + if (pLgScCfgDtStr->dwTmnlOffset != dsuStaticHeadStru.pLinkStru[ii].dwLength) + { + /*߼յLINKһLINKΪͬһLINKڷ仯*/ + for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++) + {/*߼αҵLINK뱾߼յLINKһ£ƫȱ߼յƫ1Ǹ߼μΪ߼*/ + if (pLgScCfgDtStr->wTmnlLink == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId) + { + if (pLgScCfgDtStr->dwTmnlOffset == (dsuStaticHeadStru.pLogicSgmtStru[jj].dwOrgnLkOfst - 1U)) + { + pLgScCfgDtStr->wEndLogSecId[chLogSecNextLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId; + chLogSecNextLogSecSum++; + } + } + } + } + else + {/*߼յһ£һLINKж߼Σұ߼ΪLINKϵһ*/ + /*߼յ㲻һ£ұ߼ΰLINKɵLINK*/ + if (65535U == dsuStaticHeadStru.pLinkStru[ii].wTmnlJointMainLkId) + {/*յӵlinkţ˵߼κ*/ + pLgScCfgDtStr->chEndLogSecSum = 0U; + } + else + { + + if ((LINK_DIRCHANGE_NONE == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged) + || (LINK_DIRCHANGE_BEGIN == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged)) + { + for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++) + {/*߼ΣLINKƫΪ0*/ + /*ǰ߼նLINK޷仯LINKΪ仯*/ + if (0U == dsuStaticHeadStru.pLogicSgmtStru[jj].dwOrgnLkOfst) + { + if ((dsuStaticHeadStru.pLinkStru[ii].wTmnlJointMainLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId) + || (dsuStaticHeadStru.pLinkStru[ii].wTmnlJointSideLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId)) + {/*߼ζӦLINKյLINKҵ߼LINKһ + ߼ζӦLINKյLINKҵ߼LINKһ*/ + pLgScCfgDtStr->wEndLogSecId[chLogSecNextLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId; + chLogSecNextLogSecSum++; + } + } + } + } + else if (LINK_DIRCHANGE_END == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged) + { + for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++) + {/*߼ΣLINKƫΪ0*/ + /*ǰ߼նLINKյΪ仯*/ + if (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId]].dwLength == dsuStaticHeadStru.pLogicSgmtStru[jj].dwTmnlLkOfst) + { + /*߼յLINKƫӦΪӦLINKij*/ + if ((dsuStaticHeadStru.pLinkStru[ii].wTmnlJointMainLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId) + || (dsuStaticHeadStru.pLinkStru[ii].wTmnlJointSideLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId)) + {/*߼ζӦLINKյLINKҵ߼յLINKһ + ߼ζӦLINKյLINKҵ߼յLINKһ*/ + pLgScCfgDtStr->wEndLogSecId[chLogSecNextLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId; + chLogSecNextLogSecSum++; + } + } + } + } + else + { + rtnvalue = 0U; /*ֵǷ*/ + } + + } + } + if (LOGSEC_NEXT_LOGSEC_SUM_MAX < chLogSecNextLogSecSum) + { + rtnvalue = 0U; + debug_infor_printf((const)"LogicSecCfgDtStruFromDquSgmtStr Error: LogSec Rel End LogSec Num Is Exceed Max\n"); + } + else + { + pLgScCfgDtStr->chEndLogSecSum = chLogSecNextLogSecSum; + chForeachEndFlag++; + } + } + /*LINKҵ߼LINKӦһ*/ + if (pLgScCfgDtStr->wOrgnLink == dsuStaticHeadStru.pLinkStru[ii].wId) + {/*߼ƫΪ0*/ + if (0U != pLgScCfgDtStr->dwOrgnOffset) + { + /*߼LINKһLINKΪͬһLINKڷ仯*/ + for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++) + {/*߼αҵյLINK뱾߼LINKһ£յƫȱ߼ƫС1Ǹ߼μΪ߼*/ + if (pLgScCfgDtStr->wOrgnLink == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId) + { + if (pLgScCfgDtStr->dwOrgnOffset == (dsuStaticHeadStru.pLogicSgmtStru[jj].dwTmnlLkOfst + 1U)) + { + pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId; + chLogSecLastLogSecSum++; + } + } + } + } + else + {/*߼յһ£һLINKж߼Σұ߼ΪLINKϵĵһ*/ + /*߼յ㲻һ£ұ߼ΰLINKɵLINK*/ + if (65535U == dsuStaticHeadStru.pLinkStru[ii].wOrgnJointMainLkId) + {/*յӵlinkţ˵߼κ*/ + pLgScCfgDtStr->chBeginLogSecSum = 0U; + } + else + { + if ((LINK_DIRCHANGE_NONE == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged) + || (LINK_DIRCHANGE_END == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged)) + { + for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++) + {/*߼ΣLINKƫΪ0*/ + if (dsuStaticHeadStru.pLinkStru[ii].wOrgnJointMainLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId) + {/*߼ζӦLINKLINKҵ߼յLINKһ*/ + if (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[dsuStaticHeadStru.pLinkStru[ii].wOrgnJointMainLkId]].dwLength == dsuStaticHeadStru.pLogicSgmtStru[jj].dwTmnlLkOfst) + {/*ҵ߼յLINKƫΪӦLINKij*/ + pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId; + chLogSecLastLogSecSum++; + } + } + if (dsuStaticHeadStru.pLinkStru[ii].wOrgnJointSideLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wTmnlLkId) + {/*߼ζӦLINKLINKҵ߼յLINKһ*/ + if (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[dsuStaticHeadStru.pLinkStru[ii].wOrgnJointSideLkId]].dwLength == dsuStaticHeadStru.pLogicSgmtStru[jj].dwTmnlLkOfst) + {/*ҵ߼յLINKƫΪӦLINKij*/ + pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId; + chLogSecLastLogSecSum++; + } + } + } + } + else if (LINK_DIRCHANGE_BEGIN == dsuStaticHeadStru.pLinkStru[ii].wLogicDirChanged) + { + for (jj = 0U; jj < dsuDataLenStru.wLogicSgmtLen; jj++) + {/*߼ΣLINKƫΪ0*/ + if (dsuStaticHeadStru.pLinkStru[ii].wOrgnJointMainLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId) + {/*߼ζӦLINKLINKҵ߼LINKһ*/ + if (0U == dsuStaticHeadStru.pLogicSgmtStru[jj].dwOrgnLkOfst) + {/*ҵ߼LINKƫΪ0*/ + pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId; + chLogSecLastLogSecSum++; + } + } + if (dsuStaticHeadStru.pLinkStru[ii].wOrgnJointSideLkId == dsuStaticHeadStru.pLogicSgmtStru[jj].wOrgnLkId) + {/*߼ζӦLINKLINKҵ߼LINKһ*/ + if (0U == dsuStaticHeadStru.pLogicSgmtStru[jj].dwOrgnLkOfst) + {/*ҵ߼LINKƫΪ0*/ + pLgScCfgDtStr->wBeginLogSecId[chLogSecLastLogSecSum] = dsuStaticHeadStru.pLogicSgmtStru[jj].wId; + chLogSecLastLogSecSum++; + } + } + } + } + else + { + rtnvalue = 0U; /*ֵǷ*/ + } + } + } + if (LOGSEC_NEXT_LOGSEC_SUM_MAX < chLogSecLastLogSecSum) + { + rtnvalue = 0U; + debug_infor_printf((const)"LogicSecCfgDtStruFromDquSgmtStr Error: LogSec Rel Begin LogSec Num Is Exceed Max\n"); + } + else + { + pLgScCfgDtStr->chBeginLogSecSum = chLogSecLastLogSecSum; + chForeachEndFlag++; + } + } + if ((2U == chForeachEndFlag) || (0U == rtnvalue)) + { + break; + } + } +#endif + /*߼ιźŻ*/ + if ((0U == pLgScCfgDtStr->dwOrgnOffset) || (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength == pLgScCfgDtStr->dwTmnlOffset)) + {/*ƫΪ0յƫΪӦLINKȲž߱źŻ*/ + for (ii = 0; ii < dquCICfgDtStr.SgnlCfgDtStrLen; ii++) + { + wSignalAttribute = dsuStaticHeadStru.pSignalStru[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId]].wAttribute; + if (0x4000U != (wSignalAttribute & 0x4000U)) + { + if (dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId) + { + /*źŻLINKLINKͬһLINKҴźŻΪͷߵķźŻ*/ + if (dquCICfgDtStr.SgnlCfgDtStr[ii].InFirstPhySecId == pLgScCfgDtStr->wRelativePhySecId) + { + /*ǰ߼ΪѯźŻڷһ + ҵǰ߼Ϊеһһ(һIFѾͨƫѯ)*/ + pLgScCfgDtStr->wRelateBeginSigId[pLgScCfgDtStr->chRelateBeginSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; + pLgScCfgDtStr->chRelateBeginSigSum++; + } + + if ((0U == pLgScCfgDtStr->dwOrgnOffset) && (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength != pLgScCfgDtStr->dwTmnlOffset)) + {/*߼ƫΪ0յ㲻һLINK*/ + if (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wOrgnLink) + {/*źŻLINK뱾߼ͬ*/ + pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; + pLgScCfgDtStr->chRelateEndSigSum++; + } + } + else if ((0U != pLgScCfgDtStr->dwOrgnOffset) && (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength == pLgScCfgDtStr->dwTmnlOffset)) + {/*߼㲻ΪһLINKյһLINK*/ + if (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wTmnlLink) + {/*źŻLINK뱾߼յͬ*/ + pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; + pLgScCfgDtStr->chRelateEndSigSum++; + } + } + else + { + if ((dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wOrgnLink) || (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wTmnlLink)) + {/*źŻLINK߼յLINKͬΪ߼ιնźŻ*/ + pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; + pLgScCfgDtStr->chRelateEndSigSum++; + } + } + } + else + { + /*źŻLINKLINKΪͬһǾͷߵķźŻ*/ + if (((dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wOrgnLink) || (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == pLgScCfgDtStr->wTmnlLink)) + && ((pLgScCfgDtStr->dwOrgnOffset <= dquCICfgDtStr.SgnlCfgDtStr[ii].dwProtectOff) && (dquCICfgDtStr.SgnlCfgDtStr[ii].dwProtectOff <= pLgScCfgDtStr->dwTmnlOffset))) + {/*źŻLINK߼յLINKͬźŻLINKƫڱ߼ƫΧ֮ڼΪ߼ιʼźŻ*/ + pLgScCfgDtStr->wRelateBeginSigId[pLgScCfgDtStr->chRelateBeginSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; + pLgScCfgDtStr->chRelateBeginSigSum++; + } + if ((0U == pLgScCfgDtStr->dwOrgnOffset) && (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength != pLgScCfgDtStr->dwTmnlOffset)) + {/*߼ƫΪ0յ㲻һLINK*/ + if ((dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == pLgScCfgDtStr->wOrgnLink) && (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wOrgnLink]].wOrgnJointMainLkId)) + {/*źŻⷽһLINK뱾߼ͬLINKΪ߼LINK*/ + pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; + pLgScCfgDtStr->chRelateEndSigSum++; + } + } + else if ((0U != pLgScCfgDtStr->dwOrgnOffset) && (dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].dwLength == pLgScCfgDtStr->dwTmnlOffset)) + {/*߼㲻ΪһLINKյһLINK*/ + if ((dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == pLgScCfgDtStr->wTmnlLink) && (dquCICfgDtStr.SgnlCfgDtStr[ii].wProtectLinkId == dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLgScCfgDtStr->wTmnlLink]].wTmnlJointMainLkId)) + {/*źŻⷽһLINK뱾߼յͬLINKΪ߼յLINK*/ + pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; + pLgScCfgDtStr->chRelateEndSigSum++; + } + } + else + { + if ((dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == pLgScCfgDtStr->wOrgnLink) || (dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId == pLgScCfgDtStr->wTmnlLink)) + {/*źŻⷽһLINK߼յLINKͬΪ߼ιնźŻ*/ + pLgScCfgDtStr->wRelateEndSigId[pLgScCfgDtStr->chRelateEndSigSum] = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; + pLgScCfgDtStr->chRelateEndSigSum++; + } + } + } + } + else + { + /*ťźŻ߼ιźŻ*/ + } + + if ((LOGSEC_RELATE_SIG_SUM_MAX < pLgScCfgDtStr->chRelateEndSigSum) || (LOGSEC_RELATE_SIG_SUM_MAX < pLgScCfgDtStr->chRelateBeginSigSum)) + { + rtnvalue = 0U; + debug_infor_printf((const)"LogicSecCfgDtStruFromDquSgmtStr Error: LogSec Rel Begin or End Signal Num Is Exceed Max\n"); + break; + } + else + { + /*ʼ*/ + } + } + } + else + {/*߼Ϊͬһзͷβ*/ + pLgScCfgDtStr->chRelateBeginSigSum = 0U; + pLgScCfgDtStr->chRelateEndSigSum = 0U; + } +#if 0 + /* Ԥ*/ + /*߼ιߵ*/ + pLgScCfgDtStr->chRelateContactSwSum = 0U; + for (ii = 0U; ii < LSDataLen.LSRouteStrLen; ii++) + {/*·ID·δ*/ + for (jj = 0U; jj < OTHER_CI_MAX_DEV_NUM; jj++) + { + if (CI_DEVICE_TYPE_CONNECT_SWITCH == LSData.pLSOterCiStr[LSData.pLSRouteStr[ii].wCBTCOtherCIID].otherCiDevInfoBuf[jj].wDevType) + {/*ȡ豸Ϊߵ豸ID*/ + for (kk = 0U; kk < wContactSwIdIndex; kk++) + {/*豸IDȥ*/ + if (wContactSwIdBuf[kk] == LSData.pLSOterCiStr[LSData.pLSRouteStr[ii].wCBTCOtherCIID].otherCiDevInfoBuf[jj].wId) + { + chForeachContactFlag = 1U; + } + } + if (1U != chForeachContactFlag) + {/*ߵID洢һ*/ + wContactSwIdBuf[wContactSwIdIndex] = LSData.pLSOterCiStr[LSData.pLSRouteStr[ii].wCBTCOtherCIID].otherCiDevInfoBuf[jj].wId; + wContactSwIdIndex++; + chForeachContactFlag = 0U; + } + } + } + } + for (ii = 0; ii < wContactSwIdIndex; ii++) + { + wTempLinkId = dsuStaticHeadStru.pPointStru[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wContactSwIdBuf[ii]]].wSideLkId; + if (0U == dsuStaticHeadStru.pPointStru[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wContactSwIdBuf[ii]]].dwSideLkOfst) + {/*ߵڲƫΪ0˵ߵLINKǴƫ*/ + while (3U != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wTmnlPointType) + {/*LINKβңֱҵһLINKյ˵Ϊʱĵűǽ·ĵ*/ + wTempLinkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wTmnlJointMainLkId; + } + wContactSwRelateSwId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wTmnlPointId; + } + else + {/*ߵڲƫΪ0˵ߵLINKǴƫ*/ + while (3U != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wOrgnPointType) + {/*LINKβңֱҵһLINK˵Ϊʱĵűǽ·ĵ*/ + wTempLinkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wOrgnJointMainLkId; + } + wContactSwRelateSwId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTempLinkId]].wOrgnPointId; + } + for (jj = 0U; jj < dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wContactSwRelateSwId]].SwitchLogSecSum; jj++) + {/*Ӧҵ߼*/ + if (pLgScCfgDtStr->LogicSectionId == dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wContactSwRelateSwId]].SwitchLogSecIdBuf[jj]) + {/*ߵҵĵ߼ǵǰΣߵΪǰεĹߵ*/ + pLgScCfgDtStr->wRelateContactSwId[pLgScCfgDtStr->chRelateContactSwSum] = wContactSwRelateSwId; + (pLgScCfgDtStr->chRelateContactSwSum)++; + } + } + } +#endif + + /*by cgh 20230919 ߼SPKSвҶӦ߼ζӦSPKS*/ + pLgScCfgDtStr->chSpksNum = 0u; + /* ߼SPKSвҶӦ߼ID */ + for (ii = 0u; ii < dsuDataLenStru.wLogSecSpksLen; ii++) + { + for (jj = 0u; jj < dsuStaticHeadStru.pLogSecSpksButtonStru[ii].wLogSecNum; jj++) + { + /* жϵǰSPKSťǷ */ + if (dsuStaticHeadStru.pLogSecSpksButtonStru[ii].wRelateLogSecId[jj] == pLgScCfgDtStr->LogicSectionId) + { + if (pLgScCfgDtStr->chSpksNum < LOGIC_SECTION_SPKS_MAX_NUM) + { + pLgScCfgDtStr->wSpksIdBuff[pLgScCfgDtStr->chSpksNum] = dsuStaticHeadStru.pLogSecSpksButtonStru[ii].wId; + pLgScCfgDtStr->chSpksNum++; + } + } + else + { + } + } + } + + /* ߼ιPSD*/ + pLgScCfgDtStr->logSecRltPsdSum = 0u; + for (ii = 0u; ii < dsuDataLenStru.wScreenLen; ii++)/*ȫ*/ + { + /*߼ιlink*/ + for (jj = 0u; jj < pLgScCfgDtStr->chLinkNum; jj++) + { + /* жlinkǷڱ߼link */ + if (dsuStaticHeadStru.pScreenStru[ii].wRelatLkId == pLgScCfgDtStr->szLinkIdBuff[jj]) + { + if (pLgScCfgDtStr->logSecRltPsdSum < LOGSEC_RELATE_PSD_MAX) + { + pLgScCfgDtStr->logSecRltPsdBuf[pLgScCfgDtStr->logSecRltPsdSum] = dsuStaticHeadStru.pScreenStru[ii].wId; + pLgScCfgDtStr->logSecRltPsdSum++; + } + } + else + { + } + } + } + + /* ߼ιESB*/ + pLgScCfgDtStr->logSecRltEsbSum = 0u; + for (ii = 0u; ii < dsuDataLenStru.wEmergStopLen; ii++)/*ť*/ + { + /*߼ιlink*/ + for (jj = 0u; jj < pLgScCfgDtStr->chLinkNum; jj++) + { + /* жlinkǷڱ߼link */ + if (dsuStaticHeadStru.pEmergStopStru[ii].wRelatLkId == pLgScCfgDtStr->szLinkIdBuff[jj]) + { + if (pLgScCfgDtStr->logSecRltEsbSum < LOGSEC_RELATE_ESB_MAX) + { + pLgScCfgDtStr->logSecRltEsbBuf[pLgScCfgDtStr->logSecRltEsbSum] = dsuStaticHeadStru.pEmergStopStru[ii].wId; + pLgScCfgDtStr->logSecRltEsbSum++; + } + } + else + { + } + } + } + + + } + else + { + /*ʧ*/ + rtnvalue = 0u; + } + return rtnvalue; +} + + +/********************************************* +*ܣʼṹ +*˵pProtectLinkνṹָ +pOvlpCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OverlapCfgDtStruFromDquStr(DSU_PROTECT_LINK_STRU * pProtectLink, OverlapConfigDataStruct* pOvlpCfgDtStr) +{ + UINT16 j = 0u; + UINT16 i = 0u; + UINT16 k = 0u; + UINT16 l = 0u; + UINT16 wPhySecId = 0u; /*ʱα*/ + DSU_AXLE_SGMT_STRU* pAxleSgmt; + DSU_ROUTE_STRU* pRoute; + UINT8 rtnvalue = 0u; + UINT8 handleFlag = 0u;/*־*/ + UINT8 cTmpLogicSectionSum = 0u;/* ߼ */ + UINT8 isEachInvFlag = 0U; + + /*ڲ*/ + if((NULL == pProtectLink) || (NULL == pOvlpCfgDtStr)) + { + /*ʧ*/ + return 0u; + } + + pOvlpCfgDtStr->OverlapId = pProtectLink->wId; + pOvlpCfgDtStr->BelongCiId =(UINT8)dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[0]]].wManagePhysicalCI; + pOvlpCfgDtStr->BelongVirCiId = (UINT8)dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[0]]].BelongVirCI; + /*Ŀ ID(ֶ)*/ + pOvlpCfgDtStr->PhySecSum = 0u; + for(j=0u;jwIncludeAxleSgmtNum;j++) + { + /*ȡΰļ*/ + wPhySecId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[j]]].wRelatePhysicalSgmtId; + if(0xFFFFu != wPhySecId) + { + if(pOvlpCfgDtStr->PhySecSum == 0u) + { + pOvlpCfgDtStr->PhySecIdBuf[pOvlpCfgDtStr->PhySecSum] = wPhySecId; + pOvlpCfgDtStr->PhySecSum++; + } + else + { + /*ӦIDظforѭȥ*/ + for(i=0u;iPhySecSum;i++) + { + if(pOvlpCfgDtStr->PhySecIdBuf[i] == wPhySecId) + { + handleFlag = 1u;/*ʾҵͬID*/ + break; + } + else + { + + } + } + + if (handleFlag != 1u) + {/*δҵͬID*/ + + pOvlpCfgDtStr->PhySecIdBuf[pOvlpCfgDtStr->PhySecSum] = wPhySecId; + pOvlpCfgDtStr->PhySecSum++; + } + } + + } + } + /*Ŀ (ֶ)*/ + pOvlpCfgDtStr->SwitchSum = 0u; + for(i=0u;iwIncludeAxleSgmtNum;i++) + { + /*ȡΰļ*/ + pAxleSgmt = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[i]]; + for(j=0u;jwRelatPointNum;j++) + { + /*ӼлȡϢ*/ + pOvlpCfgDtStr->ConditionSwitchStru[pOvlpCfgDtStr->SwitchSum].SwitchId = pAxleSgmt->wRelatPointId[j]; + pOvlpCfgDtStr->ConditionSwitchStru[pOvlpCfgDtStr->SwitchSum].SwitchPosition = (UINT8)pAxleSgmt->wRelatPointStatus[j]; + pOvlpCfgDtStr->SwitchSum++; + } + } + /*ԶźoverlapIDĿ (ֶ)*/ + pOvlpCfgDtStr->TriPhySecSum = 0u; + /*1ӵͼ·ҵζӦ·ֻܲһ;*/ + for(i=0u;iwProtectLinkNum;j++) + { + if(pProtectLink->wId == pRoute->wProtectLinkId[j]) + { + /*2ҵ˶ӦĽ·ٵеĽ·ѰҵӦĽ·ڶӦĽ·ϻȡζӦͣID*/ + for(k=0u;kwId) + { + pOvlpCfgDtStr->TriPhySecIdBuf[pOvlpCfgDtStr->TriPhySecSum] = LSData.pLSRouteStr[k].wFHQD_TW_WLQDId; + pOvlpCfgDtStr->TriPhySecSum++; + } + } + } + } + } + + /*,ҵζӦ۷·۷Σ޵жԱΣ*/ + pOvlpCfgDtStr->RetRoutAndTrkPhySecSum = 0u; + pOvlpCfgDtStr->InvOppOverlapSum = 0u; + pOvlpCfgDtStr->FloodGateIdSum = 0u; + pOvlpCfgDtStr->AxisSecFarId = 0u; + + for(k = 0u; k < LSDataLen.LSOverlapLockCondStruLen; k++) + { + if(LSData.pLSOverlapLockCondStru[k].wOverlapId == pProtectLink->wId) + {/*ҵӦıĿ*/ + + for(l = 0u; l < OVLP_LOCK_COND_MAX_INCL_RET_ROUTE_N_PHY_SEC_NUM; l++) + { + if( + (UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeRetTrkPhySecId[l]) + && + (0u != LSData.pLSOverlapLockCondStru[k].szIncludeRetTrkPhySecId[l]) + && + (UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeReturnRouteId[l]) + && + (0u != LSData.pLSOverlapLockCondStru[k].szIncludeReturnRouteId[l])) + { + pOvlpCfgDtStr->ReturnRouteIdBuf[pOvlpCfgDtStr->RetRoutAndTrkPhySecSum] = LSData.pLSOverlapLockCondStru[k].szIncludeReturnRouteId[l]; + pOvlpCfgDtStr->RetTrkPhySecIdBuf[pOvlpCfgDtStr->RetRoutAndTrkPhySecSum] = LSData.pLSOverlapLockCondStru[k].szIncludeRetTrkPhySecId[l]; + pOvlpCfgDtStr->RetRoutAndTrkPhySecSum++; + } + + } + + /*޵жԱ*/ + for (l = 0u; l < OVLP_LOCK_COND_MAX_INCL_INV_OPP_OVLP_NUM; l++) + { + if ( + (UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeInvOppOverlapId[l]) + && + (0u != LSData.pLSOverlapLockCondStru[k].szIncludeInvOppOverlapId[l])) + { + pOvlpCfgDtStr->InvOppOverlapIdBuff[pOvlpCfgDtStr->InvOppOverlapSum] = LSData.pLSOverlapLockCondStru[k].szIncludeInvOppOverlapId[l]; + pOvlpCfgDtStr->InvOppOverlapSum++; + } + + } + + + /*飨ֶΣ*/ + if ((UINT16_MAX != LSData.pLSOverlapLockCondStru[k].overlapLocProSwitchGroupID) && (0U != LSData.pLSOverlapLockCondStru[k].overlapLocProSwitchGroupID)) + {/*IDЧ*/ + for (l = 0u;l < LSDataLen.LSFHDaoChaStrLen;l++) + {/**/ + if((LSData.pLSFHDaoChaStr+l)->wId == LSData.pLSOverlapLockCondStru[k].overlapLocProSwitchGroupID) + { + for(j = 0u;j < FHDC_MAX_INCLUDE_POINT_NUM;j++) + { + if((0u != (LSData.pLSFHDaoChaStr+l)->wPointId[j]) && (UINT16_MAX != (LSData.pLSFHDaoChaStr+l)->wPointId[j])) + { + pOvlpCfgDtStr->ProtectSwitchStru[pOvlpCfgDtStr->ProtectSwitchSum].ProtectSwitchId = (LSData.pLSFHDaoChaStr+l)->wPointId[j]; + pOvlpCfgDtStr->ProtectSwitchStru[pOvlpCfgDtStr->ProtectSwitchSum].ProtectPosition = (UINT8)(LSData.pLSFHDaoChaStr+l)->wPointSta[j]; + pOvlpCfgDtStr->ProtectSwitchSum++; + } + } + } + } + } + + /*飨ֶΣ*/ + for(l = 0u; l < ROUTE_MAX_FLOOD_GATE_NUM; l++) + { + if((UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeFloodGateId[l]) + && + (0u != LSData.pLSOverlapLockCondStru[k].szIncludeFloodGateId[l]) + && (ROUTE_MAX_FLOOD_GATE_NUM > pOvlpCfgDtStr->FloodGateIdSum)) + { + pOvlpCfgDtStr->FloodGateIdBuff[pOvlpCfgDtStr->FloodGateIdSum] = LSData.pLSOverlapLockCondStru[k].szIncludeFloodGateId[l]; + pOvlpCfgDtStr->FloodGateIdSum++; + } + } + break; + } + + } + + /* ߼ĿID */ + for (i = 0u; i < pProtectLink->wIncludeAxleSgmtNum; i++) + { + for (j = 0u; j < dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[i]]].wIncludeLogicSgmtNum;j++) + { + pOvlpCfgDtStr->szLogicSectionIdBuf[cTmpLogicSectionSum] = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[i]]].wLogicSgmtId[j]; + cTmpLogicSectionSum++; + } + } + if (0u == cTmpLogicSectionSum) + { + rtnvalue = 0u; + } + else + { + pOvlpCfgDtStr->AxisSecFarId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pProtectLink->wIncludeAxleSgmtId[pProtectLink->wIncludeAxleSgmtNum - 1]]].wId; + pOvlpCfgDtStr->cLogicSectionSum = cTmpLogicSectionSum; + rtnvalue = 1u; + } + + /* ʼ*/ + isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION); + pOvlpCfgDtStr->InvSecAndConSwiSum = 0u; + + /*þɰ汾·*/ + if (FUNC_SWITCH_OFF == isEachInvFlag) + { + for (k = 0u; k < LSDataLen.LSOverlapLockCondStruLen; k++) + { + if (LSData.pLSOverlapLockCondStru[k].wOverlapId == pProtectLink->wId) + {/*ҵӦıĿ*/ + + /**/ + for (l = 0U; l < OVLP_LOCK_COND_MAX_INCL_INV_SEC_N_CON_SWI_NUM; l++) + { + if ((UINT16_MAX != LSData.pLSOverlapLockCondStru[k].szIncludeInvSecAndConSwiId[l]) + && (0U != LSData.pLSOverlapLockCondStru[k].szIncludeInvSecAndConSwiId[l])) + { + pOvlpCfgDtStr->InvSecAndConSwiIdBuf[pOvlpCfgDtStr->InvSecAndConSwiSum] = LSData.pLSOverlapLockCondStru[k].szIncludeInvSecAndConSwiId[l]; + pOvlpCfgDtStr->InvSecAndConSwiSum++; + } + } + } + } + } + /*°߼λޱת*/ + else + { + /*ΰ߼*/ + for (k = 0U; k < pOvlpCfgDtStr->cLogicSectionSum; k++) + { + /*μ*/ + for (l = 0U; l < LSDataLen.LSIntruPhySecStrLen; l++) + { + /*α߼ID뱣ΰ߼IDһ£޴뱣*/ + if ((pOvlpCfgDtStr->szLogicSectionIdBuf[k] == LSData.pLSIntruPhySecStr[l].belongLogSecId)&&(0U!= LSData.pLSIntruPhySecStr[l].belongLogSecId)) + { + if (OVLP_INVASECT_N_CONDSWIT_SUM_MAX > pOvlpCfgDtStr->InvSecAndConSwiSum) + { + pOvlpCfgDtStr->InvSecAndConSwiIdBuf[pOvlpCfgDtStr->InvSecAndConSwiSum] = LSData.pLSIntruPhySecStr[l].wId; + pOvlpCfgDtStr->InvSecAndConSwiSum++; + } + else + { + /*Χʼʧ*/ + rtnvalue = 0U; + break; + } + } + else + { + /**/ + } + } + + if (0U == rtnvalue) + { + debug_infor_printf((const)"[OverLapInv] OverLapID:%d ERROR: InvSecAndConSwiSum Is Exceed MAX\n", pOvlpCfgDtStr->OverlapId); + break; + } + else + { + /**/ + } + + } + } + + /*־дӡ*/ + if ((0U < pOvlpCfgDtStr->InvSecAndConSwiSum) && (1U == rtnvalue)) + { + for ( i = 0U; i < pOvlpCfgDtStr->InvSecAndConSwiSum; i++) + { + debug_infor_printf((const)"[OverLapInv] OverlapID:%d, InvData:%d\n", pOvlpCfgDtStr->OverlapId, pOvlpCfgDtStr->InvSecAndConSwiIdBuf[i]); + } + } + else + { + ; + } + return rtnvalue; +} + + +/********************************************* +*ܣʼνӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OverlapConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + + callFun = dfsEmapInit (FSName); + callFun *= InitLS_RouteStruct (FSName); + callFun *= InitLS_OverlapLockCondStru(FSName); + callFun *= InitLS_FHDaoChaStru(FSName); + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.OvlapCfgDtStrLen = dsuDataLenStru.wProtectLinkLen; + for(i = 0u; i < dsuDataLenStru.wProtectLinkLen; i++) + { + if (i >= OVERLAP_SUM_MAX) + { + rtnvalue = 0u; + break; + } + rtnvalue = OverlapCfgDtStruFromDquStr(dsuStaticHeadStru.pProtectLinkStru+i, &dquCICfgDtStr.OvlapCfgDtStr[i]); + if (0u == rtnvalue) + { + break; + } + } + } + + + return rtnvalue; +} + +/********************************************* +*ܣͣťӿݽṹ +*˵pEmergStopESBṹָ +pEsbCfgDtStrESBݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 EsbCfgDtStruFromDquEmergStr(DSU_EMERG_STOP_STRU * pEmergStop,EsbConfigDataStruct* pEsbCfgDtStr) +{ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 rtnvalue = 0u; + UINT16 Linkindex = 0u; + + /*ڲ*/ + if((NULL == pEmergStop) || (NULL == pEsbCfgDtStr)) + { + /*ʧ*/ + return 0u; + } + + pEsbCfgDtStr->EsbId = pEmergStop->wId; + rtnvalue = GetDsuLinkIndexNum(pEmergStop->wRelatLkId,&Linkindex); + if(CI_SUCCESS == rtnvalue) + { + pEsbCfgDtStr->BelongCiId = (UINT8)dsuStaticHeadStru.pLinkStru[Linkindex].wManagePhysicalCI; + pEsbCfgDtStr->BelongVirCiId = (UINT8)dsuStaticHeadStru.pLinkStru[Linkindex].wBelongVirtualCI; + for (i = 0u; i < dsuDataLenStru.wStationLen; i++) + { + for (j = 0u; j < 2u; j++) + { + if (pEsbCfgDtStr->EsbId == (dsuStaticHeadStru.pStationStru + i)->wEmergStopId[j]) + { + pEsbCfgDtStr->BelongPlatFormId = (dsuStaticHeadStru.pStationStru + i)->wATSStationId; + break; + } + } + } + + for(i=0u;iwId == (RelayData.pRelayEmgcyStpStr+i)->wEmgcyStopBtnId) + { + pEsbCfgDtStr->EsbRelayId = (RelayData.pRelayEmgcyStpStr+i)->wEmgcyStopBtnRelayId; + pEsbCfgDtStr->wEsbRelayId2 = (RelayData.pRelayEmgcyStpStr + i)->wEmgcyStopBtnRelayId2; + pEsbCfgDtStr->EsbDisRelayId = (RelayData.pRelayEmgcyStpStr+i)->wEmgcyStopBtnIndicateRelayId; + pEsbCfgDtStr->EsbCutRelayId = (RelayData.pRelayEmgcyStpStr + i)->wEmgcyStopCutRelayId; + pEsbCfgDtStr->EsbCutDisRelayId = (RelayData.pRelayEmgcyStpStr + i)->wEmgcyStopCutIndicateRelayId; + pEsbCfgDtStr->EsbRepRelayId = (RelayData.pRelayEmgcyStpStr+i)->wRepEmgcyStopBtnRelayId; + pEsbCfgDtStr->EsbBuzzRelayId = (RelayData.pRelayEmgcyStpStr+i)->wEmgcyStopBuzzRelayId; + pEsbCfgDtStr->ESSRelayId = (RelayData.pRelayEmgcyStpStr + i)->wESSRelayId; + pEsbCfgDtStr->ESSSteadyIndicatRelayId = (RelayData.pRelayEmgcyStpStr + i)->wESSSteadyIndicatRelayId; + pEsbCfgDtStr->ESSFlashIndicatRelayId = (RelayData.pRelayEmgcyStpStr + i)->wESSFlashIndicatRelayId; + pEsbCfgDtStr->CancelEsbRelayId = (RelayData.pRelayEmgcyStpStr + i)->wCancelEsbRelayId; + pEsbCfgDtStr->EsbPlatformDisRelayId = (RelayData.pRelayEmgcyStpStr + i)->wEsbPlatformDisRelayId; + pEsbCfgDtStr->EsbCutoffBuzzRelayId = (RelayData.pRelayEmgcyStpStr + i)->wCutoffEsbBuzzRelayId; + pEsbCfgDtStr->VirtualAttribute = ESB_VIRTUAL_ATTR_NO;/**/ + pEsbCfgDtStr->ConfigAtsCiEssSteadyMask = ESS_MASK_NO;/*ʼδȵ״̬λ*/ + pEsbCfgDtStr->ConfigAtsCiEssFlashMask = ESS_MASK_NO;/*ʼδ״̬λ*/ + rtnvalue = 1u; + return rtnvalue; + } + } + } + + pEsbCfgDtStr->EsbRelayId = 0u; + pEsbCfgDtStr->EsbRepRelayId = 0u; + pEsbCfgDtStr->VirtualAttribute = ESB_VIRTUAL_ATTR_NO;/**/ + rtnvalue = 0u; + return rtnvalue; +} + + +/********************************************* +*ܣʼͣťӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 EsbConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + + callFun = dfsEmapInit (FSName); + callFun *= InitRelay_EmgcyStpStru (FSName); + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.EsbCfgDtStrLen = dsuDataLenStru.wEmergStopLen; + for(i=0u;i= ESB_SUM_MAX) + { + rtnvalue = 0u; + break; + } + + (void)EsbCfgDtStruFromDquEmergStr(dsuStaticHeadStru.pEmergStopStru+i,&dquCICfgDtStr.EsbCfgDtStr[i]); + } + } + + return rtnvalue; +} + + + +/********************************************* +*ܣݽṹ +*˵pScreenŽṹָ +pPsdCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PsdCfgDtStruFromDquEmergStr(DSU_SCREEN_STRU * pScreen,PsdConfigDataStruct* pPsdCfgDtStr) +{ + UINT16 i = 0u; + UINT8 j = 0U; + UINT8 rtnvalue = 0u; + UINT16 stationId = 0u; + UINT16 linkindex = 0u; + + /*ڲ*/ + if((NULL == pScreen) || (NULL == pPsdCfgDtStr)) + { + /*ʧ*/ + return 0u; + } + + pPsdCfgDtStr->PsdId = pScreen->wId; + rtnvalue = GetDsuLinkIndexNum(pScreen->wRelatLkId,&linkindex); + if(CI_SUCCESS == rtnvalue) + { + pPsdCfgDtStr->BelongCiId = (UINT8)dsuStaticHeadStru.pLinkStru[linkindex].wManagePhysicalCI; + pPsdCfgDtStr->BelongVirCIid = (UINT8)dsuStaticHeadStru.pLinkStru[linkindex].wBelongVirtualCI; + if ((UINT16_MAX != pScreen->wLocalPlatformId) && (0U != pScreen->wLocalPlatformId)) + { + stationId = dsuStaticHeadStru.pStationStru[dsuStationIndex[pScreen->wLocalPlatformId]].wStationID; + pPsdCfgDtStr->BelongStationId = (UINT8)(stationId & 0x00FFu);/*ǵվŲᳬ255Ϊ˺PSDϵͳIDͳһֻȡֽ*/ + } + else + { + pPsdCfgDtStr->BelongStationId = 0U; + } + pPsdCfgDtStr->RelatedOutStationRouteSum = 0u; + (void)memset(pPsdCfgDtStr->RelatedOutStationRouteIdBuf,0,sizeof(UINT16) * RALATED_OUT_STATION_ROUTE_SUM_MAX); + for (i = 0u; i < dsuDataLenStru.wStationLen; i++) + { + for (j = 0u; j < 2u; j++) + { + if (pPsdCfgDtStr->PsdId == (dsuStaticHeadStru.pStationStru + i)->wScreenId[j]) + { + pPsdCfgDtStr->BelongPlatformId = (dsuStaticHeadStru.pStationStru + i)->wATSStationId; + break; + } + } + } + for(i=0u;iwId == (RelayData.pRelayScreenStr+i)->wScreenId) + { + pPsdCfgDtStr->CloseDriveRelayId = (RelayData.pRelayScreenStr+i)->wRelayCloseDoorId; + pPsdCfgDtStr->DoorStateRelayId = (RelayData.pRelayScreenStr+i)->wRelayDoorClosedId; + pPsdCfgDtStr->wDoorStateRelayId2 = (RelayData.pRelayScreenStr + i)->wRelayDoorClosedId2; + pPsdCfgDtStr->MutualLockRelayId = (RelayData.pRelayScreenStr+i)->wRelayRelatedId; + pPsdCfgDtStr->wMutualLockRelayId2 = (RelayData.pRelayScreenStr + i)->wRelayRelatedId2; + pPsdCfgDtStr->OpenFourEditGroupDriveRelayId = (RelayData.pRelayScreenStr+i)->wRelayFourEditGroupOpenDoorId; + pPsdCfgDtStr->OpenSixEditGroupDriveRelayId = (RelayData.pRelayScreenStr+i)->wRelaySixEditGroupOpenDoorId; + pPsdCfgDtStr->OpenEightEditGroupDriveRelayId = (RelayData.pRelayScreenStr+i)->wRelayEightEditGroupOpenDoorId; + pPsdCfgDtStr->wRelayDoorButtonId = (RelayData.pRelayScreenStr+i)->wRelayDoorButtonId; + pPsdCfgDtStr->doorReopenRelayId = (RelayData.pRelayScreenStr+i)->doorReopenRelayId; + pPsdCfgDtStr->departureConfirmRelayId = (RelayData.pRelayScreenStr+i)->departureConfirmRelayId; + pPsdCfgDtStr->detectStartRelayId = (RelayData.pRelayScreenStr+i)->detectStartRelayId; + pPsdCfgDtStr->detectStopRelayId = (RelayData.pRelayScreenStr+i)->detectStopRelayId; + pPsdCfgDtStr->obstacleRelayId = (RelayData.pRelayScreenStr+i)->obstacleRelayId; + pPsdCfgDtStr->gapDetMuLockRelayId = (RelayData.pRelayScreenStr+i)->gapDetMuLockRelayId; + pPsdCfgDtStr->closeStateRelayId = (RelayData.pRelayScreenStr+i)->closeStateRelayId; + pPsdCfgDtStr->ClearPasseSteadyLightRelayId = (RelayData.pRelayScreenStr + i)->wClearPasseSteadyLightRelayId; + pPsdCfgDtStr->ClearPasseFlashLightRelayId = (RelayData.pRelayScreenStr + i)->wClearPasseFlashLightRelayId; + pPsdCfgDtStr->ClearPassengerButtonRelayId = (RelayData.pRelayScreenStr + i)->wClearPassengerButtonRelayId; + pPsdCfgDtStr->wCleFarePCBButtonRelayId = (RelayData.pRelayScreenStr + i)->wCleFarePCBButtonRelayId; + pPsdCfgDtStr->wCleFarePDBFlaLigRelayId = (RelayData.pRelayScreenStr + i)->wCleFarePDBFlaLigRelayId; + pPsdCfgDtStr->wPobIndicatorRelayId = (RelayData.pRelayScreenStr + i)->wPobBsdRelayId; + pPsdCfgDtStr->wPcbIndicatorRelayId = (RelayData.pRelayScreenStr + i)->wPcbBsdRelayId; + pPsdCfgDtStr->wVideoQkLight1RelayId = (RelayData.pRelayScreenStr + i)->wVideoQkLight1RelayId; + pPsdCfgDtStr->wVideoQkLight2RelayId = (RelayData.pRelayScreenStr + i)->wVideoQkLight2RelayId; + pPsdCfgDtStr->VirtualAttribute = PSD_VIRTUAL_ATTR_NO;/*ʼΪ*/ + rtnvalue = 1u; + return rtnvalue; + + } + } + } + + pPsdCfgDtStr->CloseDriveRelayId = 0u; + pPsdCfgDtStr->DoorStateRelayId = 0u; + pPsdCfgDtStr->MutualLockRelayId = 0u; + pPsdCfgDtStr->OpenFourEditGroupDriveRelayId = 0u; + pPsdCfgDtStr->OpenSixEditGroupDriveRelayId = 0u; + pPsdCfgDtStr->OpenEightEditGroupDriveRelayId = 0u; + pPsdCfgDtStr->wRelayDoorButtonId = 0u; + pPsdCfgDtStr->doorReopenRelayId = 0u; + pPsdCfgDtStr->departureConfirmRelayId = 0u; + pPsdCfgDtStr->detectStartRelayId = 0u; + pPsdCfgDtStr->detectStopRelayId = 0u; + pPsdCfgDtStr->obstacleRelayId = 0u; + pPsdCfgDtStr->gapDetMuLockRelayId = 0u; + pPsdCfgDtStr->closeStateRelayId = 0u; + pPsdCfgDtStr->ClearPasseSteadyLightRelayId = 0u; + pPsdCfgDtStr->ClearPasseFlashLightRelayId = 0u; + pPsdCfgDtStr->ClearPassengerButtonRelayId = 0u; + pPsdCfgDtStr->wCleFarePCBButtonRelayId = 0U; + pPsdCfgDtStr->wCleFarePDBFlaLigRelayId = 0U; + pPsdCfgDtStr->wPobIndicatorRelayId = 0U; + pPsdCfgDtStr->wPcbIndicatorRelayId = 0U; + pPsdCfgDtStr->VirtualAttribute = PSD_VIRTUAL_ATTR_NO;/*ʼΪ*/ + rtnvalue = 0u; + return rtnvalue; +} + + +/********************************************* +*ܣʼݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PsdConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 sumTemp = 0u; + UINT16 startSignalId = 0u; + UINT16 startAxisSectionWId = 0u; /*ʼ˼link*/ + UINT16 endAxisSectionWId = 0u; /*ն˼link*/ + UINT16 linkId = 0u; + UINT8 flagBreak = 0u;/*жѭ־*/ + + callFun = dfsEmapInit (FSName); + callFun *= InitRelay_ScreenStru (FSName); + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.PsdCfgDtStrLen =dsuDataLenStru.wScreenLen; + + for(i=0u;i= PSD_SUM_MAX) + { + rtnvalue = 0u; + break; + } + (void)PsdCfgDtStruFromDquEmergStr(dsuStaticHeadStru.pScreenStru+i,&dquCICfgDtStr.PsdCfgDtStr[i]); + for(j = 0u;j < dsuDataLenStru.wRouteLen;j++) + {/*н·*/ + flagBreak = 0u; + startSignalId = dsuStaticHeadStru.pRouteStru[j].wStartSignalId;/*ȡ·ʼźŻID*/ + linkId = (dsuStaticHeadStru.pSignalStru + dsuSignalIndex[startSignalId])->wLkId;/*ȡʼźŻLinkID*/ + + if(linkId == dsuStaticHeadStru.pScreenStru[i].wRelatLkId) + {/*ʼźŻLinkID == LinkID*/ + sumTemp = dquCICfgDtStr.PsdCfgDtStr[i].RelatedOutStationRouteSum; + dquCICfgDtStr.PsdCfgDtStr[i].RelatedOutStationRouteIdBuf[sumTemp] = dsuStaticHeadStru.pRouteStru[j].wId; + dquCICfgDtStr.PsdCfgDtStr[i].RelatedOutStationRouteSum++; + + if(dquCICfgDtStr.PsdCfgDtStr[i].RelatedOutStationRouteSum >= RALATED_OUT_STATION_ROUTE_SUM_MAX) + { + flagBreak = 1u; + break; + } + } + } + if (1u== flagBreak) + { + rtnvalue =0u; + break; + } + if (1u == rtnvalue) + { + for(j = 0u;j < dsuDataLenStru.wAxleSgmtLen; j++ ) + {/*мĿ*/ + startAxisSectionWId = dsuStaticHeadStru.pAxleSgmtStru[j].wOrgnLkId; /*ȡʼlink*/ + endAxisSectionWId = dsuStaticHeadStru.pAxleSgmtStru[j].wTmnlLkId; /*ȡնlink*/ + /*ʼ˼LinkID == ն˼LinkID*/ + if((startAxisSectionWId == dsuStaticHeadStru.pScreenStru[i].wRelatLkId) && (endAxisSectionWId == dsuStaticHeadStru.pScreenStru[i].wRelatLkId)) + { + /*ҵεID*/ + dquCICfgDtStr.PsdCfgDtStr[i].PsdRelationPhySecId = dsuStaticHeadStru.pAxleSgmtStru[j].wRelatePhysicalSgmtId; + break; + } + + } + } + if ((0u == rtnvalue) || (j == dsuDataLenStru.wAxleSgmtLen)) + { + break; + } + + } + if(1u==rtnvalue) + { + for(i=0u;i= AUTO_ROUTE_SUM_MAX) + { + rtnvalue = 0u; + break; + } + dquCICfgDtStr.AutoRouteCfgDtStr[i].AutoRouteId = LSData.pLSAutoRouteStr[i].wId; + dquCICfgDtStr.AutoRouteCfgDtStr[i].BelongCiId = (UINT8)dsuStaticHeadStru.pRouteStru[ dsuRouteIndex[LSData.pLSAutoRouteStr[i].szIncludeRouteId[0]]].wManageCI ; + dquCICfgDtStr.AutoRouteCfgDtStr[i].RouteSum = 0u; + for(j=0u;j= AUTO_RETURN_SUM_MAX) + { + rtnvalue = 0u; + break; + } + dquCICfgDtStr.AutoRtnRouteCfgDtStr[i].AutoReturnId = LSData.pLSAutoRtnRouteStr[i].wId; + dquCICfgDtStr.AutoRtnRouteCfgDtStr[i].BelongCiId = (UINT8)dsuStaticHeadStru.pRouteStru[ dsuRouteIndex[LSData.pLSAutoRtnRouteStr[i].szIncludeRouteId[0]]].wManageCI ; + dquCICfgDtStr.AutoRtnRouteCfgDtStr[i].RouteSum = 0u; + for(j=0u;j= REVERSE_ROUTE_SUM_MAX) + { + retValue = 0u; + break; + } + dquCICfgDtStr.ReverseRouteCfgDtStr[i].ReverseRouteId = LSData.pLSReverseRouteStr[i].wId; + dquCICfgDtStr.ReverseRouteCfgDtStr[i].BelongCiId = (UINT8)dsuStaticHeadStru.pRouteStru[ dsuRouteIndex[LSData.pLSReverseRouteStr[i].wId]].wManageCI ; + dquCICfgDtStr.ReverseRouteCfgDtStr[i].AutoSigRouteIncludeSum= 0u; + for(j=0u;j= ROUTE_LONG_SUM_MAX) + { + rtnvalue = 0u; + break; + } + dquCICfgDtStr.LongRouteCfgDtStr[i].LongRouteId = LSData.pLSLongRouteStr[i].wId; + dquCICfgDtStr.LongRouteCfgDtStr[i].SubRouteSum = 0u; + for(j=0u;j= NONROUTE_ID_NUM_MAX) + { + rtnvalue = 0u; + break; + } + rtnvalue = NonRouteCfgDtStruFrmLSStr(LSData.pLSNoRouteDcStr+i,&dquCICfgDtStr.NonRouteCfgDtStr[i]); + if (0u == rtnvalue) + { + break; + } + } + } + + return rtnvalue; +} + +/********************************************* +*ܣǽ·ݽṹ +*˵pLSNoRouteDcStrǽ·ṹָ +pNonRouteCfgDtStrǽ·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 NonRouteCfgDtStruFrmLSStr( LS_NoRouteDcStru * pLSNoRouteDcStr,NonRouteConfigDataStruct * pNonRouteCfgDtStr) +{ + UINT16 i=0u,j=0u,k=0u; + UINT8 rtnvalue = 0u; + UINT8 flagBreak = 0u;/*ʱжϱ־*/ + UINT8 isEachInvFlag = 0U; + + /*ڲ*/ + if((NULL == pLSNoRouteDcStr) || (NULL == pNonRouteCfgDtStr)) + { + /*ʧ*/ + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + if (1u == rtnvalue) + { + pNonRouteCfgDtStr->NonRouteId = (UINT8)pLSNoRouteDcStr->wId; + /*źŻ*/ + pNonRouteCfgDtStr->SignalSum = 0u; + + for(i=0u;iwIncludeSignal == LSData.pLSSignalStr[i].wId) + { + for(j=0u;jSignalIdBuf[j] = LSData.pLSSignalStr[i].wSignalId[j]; + pNonRouteCfgDtStr->SignalSum++; + } + } + + } + } + + + /**/ + pNonRouteCfgDtStr->PhySectionSum = 0u; + for(i=0u;iwWuliJianchaType == LSData.pLSPhyAndChkStaStr[i].wId) + { + for(j=0u;jNonRoutePhySecStru[j].PhySectionId = LSData.pLSPhyAndChkStaStr[i].wPhysicalSgmtId[j]; + if (0xAAu == LSData.pLSPhyAndChkStaStr[i].wCheckState[j]) + {/*˼ΪǷлռ*/ + + /*뷭ΪΪ*/ + pNonRouteCfgDtStr->NonRoutePhySecStru[j].CheckState = NONROUTE_SECTION_OCCUPY_CHECK_NO; + + } + else if (0x55u == LSData.pLSPhyAndChkStaStr[i].wCheckState[j]) + {/*˼Ϊռ*/ + + /*뷭ΪΪռ*/ + pNonRouteCfgDtStr->NonRoutePhySecStru[j].CheckState = NONROUTE_SECTION_OCCUPY_CHECK_YES; + } + else + { + /*޲*/ + } + pNonRouteCfgDtStr->PhySectionSum++; + } + } + } + } + } + + if (1u == rtnvalue) + { + flagBreak = 0u; + /**/ + pNonRouteCfgDtStr->SwitchSum = 0u; + for(i=0u;iwIncludePoint[i]) + { + pNonRouteCfgDtStr->NonRouteSwitStru[i].SwitchId = pLSNoRouteDcStr->wIncludePoint[i]; + pNonRouteCfgDtStr->NonRouteSwitStru[i].SwitchPos = (UINT8)pLSNoRouteDcStr->wIncludePointSta[i]; + pNonRouteCfgDtStr->SwitchSum++; + } + } + /*ǽ·ݳʼ*/ + if((pLSNoRouteDcStr->wFHPointId != 0u) && (UINT16_MAX != pLSNoRouteDcStr->wFHPointId)) + { + pNonRouteCfgDtStr->ProtectSwitchSum = 0u;/*ʼΪ0*/ + for(i=0u;iwId == pLSNoRouteDcStr->wFHPointId) + { + for(j=0u;jProtectSwitchSum wPointId[j]) && (UINT16_MAX != (LSData.pLSFHDaoChaStr+i)->wPointId[j])) + { + pNonRouteCfgDtStr->NonRouteProtectSwitchStru[pNonRouteCfgDtStr->ProtectSwitchSum].ProtectSwitchId = (LSData.pLSFHDaoChaStr+i)->wPointId[j]; + pNonRouteCfgDtStr->NonRouteProtectSwitchStru[pNonRouteCfgDtStr->ProtectSwitchSum].ProtectPosition =(UINT8)(LSData.pLSFHDaoChaStr+i)->wPointSta[j]; + pNonRouteCfgDtStr->ProtectSwitchSum++; + } + } + else + { + flagBreak = 1u; + } + + if (1u == flagBreak) + {/*˳ѭ*/ + break; + } + } + } + if (1u == flagBreak) + {/*˳мѭ*/ + break; + } + } + } + + + if (1u == flagBreak) + { + rtnvalue = 0u; + } + + } + + if (1u == rtnvalue) + { + /*жź*/ + pNonRouteCfgDtStr->EnemySignalSum = 0u; + for (i = 0; i < NR_MAX_INCLUDE_DDXH_NUM; i++) + { + if (pLSNoRouteDcStr->wDiDuiXinhao[i] != 0u) + { + pNonRouteCfgDtStr->EnemySignalSum++; + } + } + } + + if (1u == rtnvalue) + { + flagBreak = 0u; + for(i=0u;iEnemySignalSum;i++) + { + for(j=0u;jwDiDuiXinhao[i] == LSData.pLSDDXHStr[j].wId) + { + pNonRouteCfgDtStr->EnemySignalStru[i].EnemySigId = LSData.pLSDDXHStr[j].wDiDuiXinHaoId; + pNonRouteCfgDtStr->EnemySignalStru[i].SwitchSum = 0u; + for(k=0u;kEnemySignalStru[i].EnemySwitchStru[k].SwitchId = LSData.pLSDDXHStr[j].wPointId[k]; + pNonRouteCfgDtStr->EnemySignalStru[i].EnemySwitchStru[k].SwitchPos = (UINT8)LSData.pLSDDXHStr[j].wPointSta[k]; + pNonRouteCfgDtStr->EnemySignalStru[i].SwitchSum++; + } + + } + } + } + else + { + flagBreak = 1u; + } + if (1u == flagBreak) + {/*˳мѭ*/ + break; + } + + } + if (1u == flagBreak) + {/*˳ѭ*/ + break; + } + } + if (1u == flagBreak) + { + rtnvalue = 0u; + } + } + + if (1u == rtnvalue) + { + /*/ͬԳ̵*/ + for (i = 0u; i < RelayDataLen.RelayNoRouteDcStrLen; i++) + { + if (pLSNoRouteDcStr->wId == RelayData.pRelayNoRouteDcStr[i].wId) + { + pNonRouteCfgDtStr->ApplyTryTrainRelayId = RelayData.pRelayNoRouteDcStr[i].wRelayShenQingScId; + pNonRouteCfgDtStr->AgreeTryTrainRelayId = RelayData.pRelayNoRouteDcStr[i].wRelayTongYiScId; + pNonRouteCfgDtStr->DrvApplyTryTrainRelayId = RelayData.pRelayNoRouteDcStr[i].wRelayDrvShiCheShengQingId; + pNonRouteCfgDtStr->ColAgreeTryTrainRelayId = RelayData.pRelayNoRouteDcStr[i].wRelayColTongYiScId; + } + } + + /*ǽ·νṹ*/ + + if (1u == rtnvalue) + { + pNonRouteCfgDtStr->IntruPhySecSum = 0u; + + isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION); + + /*þɰ汾·*/ + if (FUNC_SWITCH_OFF == isEachInvFlag) + { + for (i = 0u; i < ROUTE_MAX_QXQD_NUM; i++) + { + if (0u != pLSNoRouteDcStr->wIntrudePhySecId[i]) + { + pNonRouteCfgDtStr->IntruPhySecSum++; + pNonRouteCfgDtStr->IntruPhySecStru[i].SwitchSum = 0u; + for (j = 0u; j < LSDataLen.LSIntruPhySecStrLen; j++) + { + if (LSData.pLSIntruPhySecStr[j].wId == pLSNoRouteDcStr->wIntrudePhySecId[i]) + { + /*·еμIDμеIDͬʱ, + μеIDֵ ṹSectionId*/ + pNonRouteCfgDtStr->IntruPhySecStru[i].SectionId = LSData.pLSIntruPhySecStr[j].wIntrudePhySecId; + for (k = 0u; k < QINXIAN_SWITCH_MAX_NUM; k++) + { + if (0u != LSData.pLSIntruPhySecStr[j].wPointId[k]) + { + pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[k].SwitchId = LSData.pLSIntruPhySecStr[j].wPointId[k]; + pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[k].SwitchPos = (UINT8)LSData.pLSIntruPhySecStr[j].wPointSta[k]; + pNonRouteCfgDtStr->IntruPhySecStru[i].SwitchSum++; + } + } + + } + } + } + } + } + else + { + /*ǽ·*/ + for (i = 0U; i < pNonRouteCfgDtStr->PhySectionSum; i++) + { + /*μ*/ + for (j = 0; j < LSDataLen.LSIntruPhySecStrLen; j++) + { + if ((LSData.pLSIntruPhySecStr[j].belongPhySecId == pNonRouteCfgDtStr->NonRoutePhySecStru[i].PhySectionId) && (0U != LSData.pLSIntruPhySecStr[j].belongPhySecId)) + { + /*ݷ*/ + if (NONROUTE_ENEMY_SIGNAL_SUM_MAX > pNonRouteCfgDtStr->IntruPhySecSum) + { + pNonRouteCfgDtStr->IntruPhySecStru[pNonRouteCfgDtStr->IntruPhySecSum].SectionId = LSData.pLSIntruPhySecStr[j].wIntrudePhySecId; + for (k = 0u; k < QINXIAN_SWITCH_MAX_NUM; k++) + { + if (0u != LSData.pLSIntruPhySecStr[j].wPointId[k]) + { + pNonRouteCfgDtStr->IntruPhySecStru[pNonRouteCfgDtStr->IntruPhySecSum].ConditionSwitchStru[k].SwitchId = LSData.pLSIntruPhySecStr[j].wPointId[k]; + pNonRouteCfgDtStr->IntruPhySecStru[pNonRouteCfgDtStr->IntruPhySecSum].ConditionSwitchStru[k].SwitchPos = (UINT8)LSData.pLSIntruPhySecStr[j].wPointSta[k]; + pNonRouteCfgDtStr->IntruPhySecStru[pNonRouteCfgDtStr->IntruPhySecSum].SwitchSum++; + } + } + + } + else + { + /*ǽ·Χʼʧ*/ + rtnvalue = 0U; + break; + } + pNonRouteCfgDtStr->IntruPhySecSum++; + + + } + } + if (0U == rtnvalue) + { + debug_infor_printf((const)"[NonRouteInv] NonRouteID:%d ERROR:IntruPhySecSum Is Exceed MAX\n", pNonRouteCfgDtStr->NonRouteId); + break; + } + else + { + /**/ + } + } + } + + /*־дӡǽ·޹ϵ*/ + if ((0U < pNonRouteCfgDtStr->IntruPhySecSum) && (1U == rtnvalue)) + { + for (i = 0U; i < pNonRouteCfgDtStr->IntruPhySecSum; i++) + { + debug_infor_printf((const)"[NonRouteInv] NonRouteID:%d, InvSecID:%d, SwitchID:%d-%d-%d-%d-%d-%d, SwitchState:%d-%d-%d-%d-%d-%d\n", pNonRouteCfgDtStr->NonRouteId, pNonRouteCfgDtStr->IntruPhySecStru[i].SectionId, + pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[0].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[1].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[2].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[3].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[4].SwitchId, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[5].SwitchId, + pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[0].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[1].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[2].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[3].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[4].SwitchPos, pNonRouteCfgDtStr->IntruPhySecStru[i].ConditionSwitchStru[5].SwitchPos); + } + } + else + { + ; + } + } + } + + return rtnvalue; +} + + + +/********************************************* +*ܣʼʾ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 IndicatorConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u,j=0u; + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + + callFun = InitRelay_BaoJingDengStru(FSName); + callFun *= InitRelay_NoReturnStru(FSName); + /*ʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.IndctCfgDtStrLen = RelayDataLen.RelayBjdStrLen; + dquCICfgDtStr.NonReturnCfgSum = RelayDataLen.RelayNoRtnStruLen; + for(i=0u;i= INDICATOR_MAX_SIZE) + { + rtnvalue = 0u; + break; + } + + dquCICfgDtStr.IndctCfgDtStr[i].IndicatorId = RelayData.pRelayBjdStr[i].wId; /*޸IDΪԭıIDظ*/ + dquCICfgDtStr.IndctCfgDtStr[i].IdSum = 0u; + dquCICfgDtStr.IndctCfgDtStr[i].AvalibleFlag = RelayData.pRelayBjdStr[i].wBjdYouXiao; + + for(j=0;j= NON_AUTO_RETURN_SUM_MAX) + { + rtnvalue = 0u; + break; + } + dquCICfgDtStr.NonAutoReturnCfgDataSt[i].NonAutoReturnId = RelayData.pRelayNoRtnStru[i].wId; + + /*ʾ*/ + for (j = 0U; j < RelayDataLen.RelayBjdStrLen; j++) + { + if (RelayData.pRelayNoRtnStru[i].wWuRenReturnRelayId == RelayData.pRelayBjdStr[j].wId) + { + + dquCICfgDtStr.NonAutoReturnCfgDataSt[i].BelongCiId = (UINT8)RelayData.pRelayBjdStr[j].wBelongCiId; + dquCICfgDtStr.NonAutoReturnCfgDataSt[i].BelongVirCiId = RelayData.pRelayBjdStr[j].wBelongVirCIid; + } + } + dquCICfgDtStr.NonAutoReturnCfgDataSt[i].NonAutoRtnLghtRlyId = RelayData.pRelayNoRtnStru[i].wWuRenReturnDisRelayId; + dquCICfgDtStr.NonAutoReturnCfgDataSt[i].NonAutoRtnRlyId = RelayData.pRelayNoRtnStru[i].wWuRenReturnRelayId; + } + } + + if(1u == rtnvalue) + { + if(FUNC_SWITCH_ON == includeVirFlag) + { + rtnvalue = InitBaojingdeng_UseVirCI(); + } + } + return rtnvalue; +} + + +/********************************************* +*ܣ +*˵pEmapFloodGateStr Žṹָ(ӵͼ) +* pRouteCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 FloodGateCfgDtStruFrmLSStr(DSU_FLOOD_GATE_STRU * pEmapFloodGateStr,FloodGateConfigDataStruct * pFloodGateCfgDtStr) +{ + UINT16 i = 0u;/*ʱ*/ + UINT16 jj = 0u;/*ʱ*/ + UINT16 ii = 0U; + UINT16 kk = 0U; + UINT16 floodLinkId = 0u;/*Link ID*/ + UINT8 rtVal = CI_ERROR; + UINT16 linkIndex = 0u; + + if((NULL != pEmapFloodGateStr) &&(NULL != pFloodGateCfgDtStr)) + { + rtVal = CI_SUCCESS; + } + else + { + rtVal = CI_ERROR; + } + if (CI_SUCCESS == rtVal) + { + /*ӵӵͼлȡϢ*/ + + + /*ȡID*/ + pFloodGateCfgDtStr->FloodGateId = pEmapFloodGateStr->wId; + + /**/ + floodLinkId = pEmapFloodGateStr->wFloodGateLinkID;/*Link ID*/ + rtVal = GetDsuLinkIndexNum(floodLinkId, &linkIndex); + if (CI_SUCCESS == rtVal) + { + pFloodGateCfgDtStr->BelongCiId = (UINT8)dsuStaticHeadStru.pLinkStru[linkIndex].wManagePhysicalCI;/*idֵ*/ + pFloodGateCfgDtStr->BelongVirId = (UINT8)dsuStaticHeadStru.pLinkStru[linkIndex].wBelongVirtualCI;/*idֵ*/ + + /*ŹӽϢ*/ + pFloodGateCfgDtStr->AccessAxisNum = pEmapFloodGateStr->wAccessAxisNum; + if (pFloodGateCfgDtStr->AccessAxisNum < FLOOD_GATE_ACCESS_AXIS_NUM_MAX) + { + for (jj = 0U; jj < pFloodGateCfgDtStr->AccessAxisNum; jj++) + { + pFloodGateCfgDtStr->AccessAxisId[jj] = pEmapFloodGateStr->wAccessAxisId[jj]; + } + } + else + { + rtVal = CI_ERROR; /*ýӽγޣسʼʧ*/ + } + } + + if (CI_SUCCESS == rtVal) + { + /*ŹϢ*/ + pFloodGateCfgDtStr->ProtectAxisNum = pEmapFloodGateStr->wProtectAxisNum; + if (pFloodGateCfgDtStr->ProtectAxisNum < FLOOD_GATE_PROTECT_AXIS_NUM_MAX) + { + for (jj = 0U; jj < pFloodGateCfgDtStr->ProtectAxisNum; jj++) + { + pFloodGateCfgDtStr->ProtectAxisId[jj] = pEmapFloodGateStr->wProtectAxisId[jj]; + } + } + else + { + rtVal = CI_ERROR; /*÷γޣسʼʧ*/ + } + } + + if (CI_SUCCESS == rtVal) + { + /*ŹϢ*/ + pFloodGateCfgDtStr->ProtectPhySecNum = 0U; + for (jj = 0U; jj < pEmapFloodGateStr->wProtectAxisNum; jj++) + { + for (ii = 0U; ii < pFloodGateCfgDtStr->ProtectPhySecNum; ii++) + { + if (pFloodGateCfgDtStr->ProtectPhySecIdBuf[ii] == dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pEmapFloodGateStr->wProtectAxisId[jj]]].wRelatePhysicalSgmtId) + { + break; /*Ѿӹ*/ + } + else + { + + } + } + + if ((ii == pFloodGateCfgDtStr->ProtectPhySecNum) && (pFloodGateCfgDtStr->ProtectPhySecNum < FLOOD_GATE_PROTECT_PHYSECTION_NUM_MAX)) + { + pFloodGateCfgDtStr->ProtectPhySecIdBuf[pFloodGateCfgDtStr->ProtectPhySecNum] = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pEmapFloodGateStr->wProtectAxisId[jj]]].wRelatePhysicalSgmtId; + pFloodGateCfgDtStr->ProtectPhySecNum++; + } + } + + /*ڷID*/ + for (ii = 0U; ii < dquCICfgDtStr.PsclSgmtCfgDtStrLen; ii++) + { + /*зŵķͬӦзID*/ + for (jj = 0U; jj < pFloodGateCfgDtStr->ProtectPhySecNum; jj++) + { + if (dquCICfgDtStr.PsclSgmtCfgDtStr[ii].PhysicalSectionId == pFloodGateCfgDtStr->ProtectPhySecIdBuf[jj]) + {/*ڷidֵνṹ*/ + for (kk = 0U; kk < dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum; kk++) + { + if (dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateId[kk] == pFloodGateCfgDtStr->FloodGateId) + { + break; /*ѾӹķID*/ + } + else + { + ; /**/ + } + } + if ((kk == dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum) && (FLOOD_GATE_SUM_MAX > dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum)) + { + dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateId[dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum] = pFloodGateCfgDtStr->FloodGateId; + dquCICfgDtStr.PsclSgmtCfgDtStr[ii].LocatedFloodGateSum++; + } + } + } + } + + /*ŹӽϢ*/ + pFloodGateCfgDtStr->AccessPhySecNum = 0U; + for (jj = 0U; jj < pEmapFloodGateStr->wAccessAxisNum; jj++) + { + for (ii = 0U; ii < pFloodGateCfgDtStr->AccessPhySecNum; ii++) + { + if (pFloodGateCfgDtStr->AccessPhySecStru[ii].AccessPhySecId == dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pEmapFloodGateStr->wAccessAxisId[jj]]].wRelatePhysicalSgmtId) + { + break; /*Ѿӹ*/ + } + else + { + + } + } + + if ((ii == pFloodGateCfgDtStr->AccessPhySecNum) && (pFloodGateCfgDtStr->AccessPhySecNum < FLOOD_GATE_ACCESS_PHYSECTION_NUM_MAX)) + { + pFloodGateCfgDtStr->AccessPhySecStru[pFloodGateCfgDtStr->AccessPhySecNum].AccessPhySecId = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[pEmapFloodGateStr->wAccessAxisId[jj]]].wRelatePhysicalSgmtId; + pFloodGateCfgDtStr->AccessPhySecStru[pFloodGateCfgDtStr->AccessPhySecNum].AccessPhySecDir = pEmapFloodGateStr->wAccessAxisDir[jj]; + pFloodGateCfgDtStr->AccessPhySecNum++; + } + } + + for (i = 0u; i < RelayDataLen.RelayFloodGateStrLen; i++) + { + if (i >= FLOOD_GATE_SUM_MAX) + { + rtVal = CI_ERROR; + break; + } + if (pFloodGateCfgDtStr->FloodGateId == RelayData.pRelayFloodGateStr[i].wFloodGateId) + { + pFloodGateCfgDtStr->CloseApplyRelayId = RelayData.pRelayFloodGateStr[i].wCloseApplyRelayId; + pFloodGateCfgDtStr->OpenLockRelayId = RelayData.pRelayFloodGateStr[i].wOpenCloseRelayId; + pFloodGateCfgDtStr->AllowCloseRelayId = RelayData.pRelayFloodGateStr[i].wAllowRequestRelayId; +#if 0 + /*ַʽΪǷڼʧ*/ + if (RelayData.pRelayFloodGateStr[i].wOpenCloseRelayId != 0u && + RelayData.pRelayFloodGateStr[i].wOpenCloseRelayId != 0xffffu) + {/*ſ̵Ϊ0ʱȡ̵IDֵŵID*/ + for (jj = 0u; jj < RelayDataLen.RelayCfgDtStrLen; jj++) + { + if (RelayData.pRelayFloodGateStr[i].wOpenCloseRelayId == RelayData.pRelayCfgDtStr[jj].RelayId) + { + pFloodGateCfgDtStr->BelongCiId = RelayData.pRelayCfgDtStr[jj].BelongCiId; + break; + } + } + } +#endif + break; + } + } + } + } + return rtVal; +} + + +/********************************************* +*ܣ· +*˵pLSRouteStr·ṹָ +pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*mod by qw.liu 2022-02-22 ӵʽӽΣʽCBTCӽΡμ +*********************************************/ +UINT8 RouteCfgDtStruFrmLSRouteStr( LS_RouteStruct * pLSRouteStr,RouteConfigDataStruct * pRouteCfgDtStr, OverlapConfigDataStruct* overlapStr) +{ + UINT16 i=0u,j=0u,k=0u,m=0u,n=0u; + UINT16 devId = 0u; + UINT16 lastDevId = 0u;/*һ*/ + UINT8 index=0u; + UINT8 findFlag = 0U; + UINT8 rtnvalue = CI_ERROR; + UINT8 flagBreak = 0u; + UINT8 findRouteProtectDirChangeFlag = 0u;/*ҵ·η仯*/ + /*ͳЧղID*/ + UINT8 zhaoChaPhySecNum = 0u; + UINT8 iIndex=0u; + /*ȥID*/ + UINT16 routeId = 0u; /*·ID */ + UINT8 routeDir = 0u; /*· */ + UINT16 axleSgmtNum = 0u; /*·ļĿ*/ + UINT16 axleSgmtId = 0u; /*·һεID*/ + /*·źŻID*/ + UINT16 routeStartSignal = 0u; /*·ʼźŻ*/ + UINT16 routeEndSignal = 0u; /*·նźŻ*/ + DSU_ROUTE_STRU* pDsuRouteStr = NULL; + DSU_LOGIC_SGMT_STRU* pLogicSgmeStr = NULL; + DSU_AXLE_SGMT_STRU* pAxleSgmtStr = NULL; + DSU_BLOC_ACCESS_LINK_STRU* pBlocAccessStr = NULL; + DSU_CBTC_ACCESS_LINK_STRU* pCbtcAccessStr = NULL; + DSU_CBTC_TRG_AREA_STRU* pCbtcTriggerStr = NULL; /*CBTCνṹ*/ + DSU_PROTECT_LINK_STRU* pProtectStru = NULL;/**/ + UINT8 lineIdentity; + UINT8 ciType = 0u;/**/ + UINT16 firstAxleSecId = 0u;/*һID*/ + UINT16 lastAxleSecId = 0u;/*һID*/ + UINT16 axleNum = 0u;/**/ + DSU_AXLE_SGMT_STRU *pDsuAxleSgmt = NULL;/**/ + DSU_AXLE_SGMT_STRU *pDsuRouteLastAxleSgmt = NULL;/**/ + DSU_LINK_STRU *pDsuLink = NULL;/*LINK*/ + DSU_LINK_STRU *pDsuLinkNext = NULL;/*һLINK*/ + UINT16 firstProtectId = 0u;/*һID*/ + DSU_AXLE_SGMT_STRU * pProtectFirstAxleSec = NULL;/*εһνṹ*/ + DSU_LINK_STRU *pDsuProtectFstAxleSecStartLink = NULL;/*εһLINK*/ + DSU_LINK_STRU *pDsuProtectFstAxleSecEndLink = NULL;/*εһյLINK*/ + DSU_LINK_STRU *pRouteLastLink = NULL;/*·һLINK*/ + UINT8 baseDir = 0u;/*׼*/ + UINT16 lkIndex = 0u;/*link*/ + UINT16 axleSecIndex = 0u;/**/ + UINT16 dirChangeLinkId = 0u;/*仯LINK*/ + UINT8 flagFind = 0u; + UINT16 dirChangeAxleSecId = 0u;/*仯ID*/ + UINT16 dirChangePhySecId = 0u;/*仯ID*/ + UINT16 dirChangePhySecIndex = 0u;/*仯*/ + UINT16 axleSecId = 0u;/*ID*/ + DSU_LINK_STRU* pRouteIncLinkStru = NULL; /*·linkṹ*/ + DSU_LINK_STRU * pRouteFirstLinkStru = NULL; + DSU_LINK_STRU * pRouteSecondLinkStru = NULL; + UINT16 zCPhySecId= 0u; + UINT8 checkResult = 0u; + UINT16 signalIndex = 0u; + UINT8 overlapIndex = 0u; + RouteTriggerPhySectionStruct* pRouteTriggerPhySecStr = NULL; + UINT8 chCheckLogIdSameFlag = 0U; + UINT8 isEachInvFlag = 0U; + UINT16 wLgcSecIndex = 0U; /*߼*/ + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*??????:0x55:????;0xAA:????*/ + + /*ڲ*/ + if((NULL != pLSRouteStr) && (NULL != pRouteCfgDtStr)) + { + rtnvalue = CI_SUCCESS; + + pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pLSRouteStr->wRouteId]; + + pRouteCfgDtStr->RouteId = pLSRouteStr->wRouteId; + pRouteCfgDtStr->BelongCiId = (UINT8)pDsuRouteStr->wManageCI; + + if (pLSRouteStr->wDir == dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown) + { + pRouteCfgDtStr->RouteDirection = CI_SYSTEM_DIRECTION_DOWN; + } + else + { + pRouteCfgDtStr->RouteDirection = CI_SYSTEM_DIRECTION_UP; + } + + pRouteCfgDtStr->LeadProperty = pLSRouteStr->wYinDao; + + pRouteCfgDtStr->RouteSignalOpenColor = (UINT8)pLSRouteStr->wStarSignalClr; + pRouteCfgDtStr->LeadOpenColor = (UINT8)pLSRouteStr->wStarSigYinDaoClr; + + /*ȥӵͼȥʼ˺նźŻ*/ + pRouteCfgDtStr->StartSignalId = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[pLSRouteStr->wRouteId]].wStartSignalId; + pRouteCfgDtStr->EndSignalId = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[pLSRouteStr->wRouteId]].wEndSignalId; + pRouteCfgDtStr->AirShaftRouteType = 0u; /*ĬϲǷ羮·*/ + pRouteCfgDtStr->AutoTriggerType = 0u; /*ĬϲԶ·*/ + /*·*/ + if(SIGNALINDEXNUM >= (pRouteCfgDtStr->StartSignalId)) + { + signalIndex = dsuSignalIndex[pRouteCfgDtStr->StartSignalId]; + if(signalIndex < dsuDataLenStru.wSignalLen) + { + pRouteCfgDtStr->BelongVirCIid = (UINT8)(dsuStaticHeadStru.pSignalStru[signalIndex].wBelongVirCI); + } + else + { + rtnvalue = CI_ERROR; + } + } + else + { + rtnvalue = CI_ERROR; + } + + ciType = (UINT8)(dsuStaticHeadStru.pCIStruStru[dsuCIIndex[pRouteCfgDtStr->BelongCiId]].wType);/*·*/ + + /*·*/ + if(0x01u == (pDsuRouteStr->wRouteType & 0x01u)) + { + /*·Ϊг·*/ + pRouteCfgDtStr->RouteType = ROUTE_TYPE_LIECHE; + } + else if(0x02u == (pDsuRouteStr->wRouteType & 0x02u)) + { + /*·Ϊ۷·*/ + pRouteCfgDtStr->RouteType = ROUTE_TYPE_RETURN; + + /*û۷·۷·г·*/ + if ((CI_TYPE_TCC == ciType) || (CI_TYPE_CLD == ciType)) + { + pRouteCfgDtStr->RouteType = ROUTE_TYPE_LIECHE; + } + else + { + } + } + else if(0x0100u == (pDsuRouteStr->wRouteType & 0x0100u)) + { + /*·Ϊ·*/ + pRouteCfgDtStr->RouteType = ROUTE_TYPE_DIAOCHE; + } + else if(0u == pDsuRouteStr->wRouteType) + { + pRouteCfgDtStr->RouteType = 0u; + } + else if(0u != (0xffu&pDsuRouteStr->wRouteType)) + { + /*ͲΪ0,ҵֽڲΪ0,·Ϊг·*/ + pRouteCfgDtStr->RouteType = ROUTE_TYPE_LIECHE; + } + else + { + pRouteCfgDtStr->RouteType = 0u; + } + + /*ý·*/ + pRouteCfgDtStr->ConfigRouteType = pRouteCfgDtStr->RouteType; + /*۷·,ý·*/ + if (0x02u == (pDsuRouteStr->wRouteType & 0x02u)) + { + pRouteCfgDtStr->ConfigRouteType = ROUTE_TYPE_RETURN; + } + else + { + } + + if (0x0800u == (pDsuRouteStr->wRouteType & 0x0800u)) + { /*羮·*/ + pRouteCfgDtStr->AirShaftRouteType = ROUTE_TYPE_AIRSHAFT; + } + else + { + } + + /*Զ·*/ + if (0x1000u == (pDsuRouteStr->wRouteType & 0x1000u)) + {/*Զ·*/ + pRouteCfgDtStr->AutoTriggerType = ROUTE_TYPE_AUTO_TRIGGER; + } + else + { + } + + /*ý·*/ + pRouteCfgDtStr->cRouteRukuProperty = ROUTE_RUKU_PROPERTY_NO; + if (0x0010U == (pDsuRouteStr->wRouteType & 0x0010U)) + { + pRouteCfgDtStr->cRouteRukuProperty = ROUTE_RUKU_PROPERTY_YES; + } + else + { + /*·*/ + } + + /*Զź*/ + pRouteCfgDtStr->AutoSigProperty = ROUTE_AUTOSIG_PROPERTY_NO; + if(0xaau == pDsuRouteStr->wAttribute) + { + pRouteCfgDtStr->AutoSigProperty = ROUTE_AUTOSIG_PROPERTY_YES; + } + else + { + } + + /*Զ·*/ + pRouteCfgDtStr->AutoRouteProperty = ROUTE_AUTOROUTE_PROPERTY_NO; + for(i=0u;iwRouteId) + { + pRouteCfgDtStr->AutoRouteProperty = ROUTE_AUTOROUTE_PROPERTY_YES; + break; + } + else + { + } + + } + } + + /*Զ۷·*/ + for(i=0u;iwRouteId) + { + pRouteCfgDtStr->AutoRouteProperty = ROUTE_AUTOROUTE_PROPERTY_YES; + break; + } + else + { + } + } + } + + for(i=0u;iwRouteId) + { + pRouteCfgDtStr->AutoRouteProperty = ROUTE_AUTOROUTE_PROPERTY_YES; + break; + } + else + { + } + } + } + + + pRouteCfgDtStr->ReverseRouteProperty = ROUTE_REVERSE_PROPERTY_NO; + /*·*/ + for(i = 0u;i < LSDataLen.LSReverseRouteStrLen;i++) + {/*·ен·*/ + if(LSData.pLSReverseRouteStr[i].wId == pLSRouteStr->wRouteId) + {/*·IDڷ·гֹ·з*/ + pRouteCfgDtStr->ReverseRouteProperty = ROUTE_REVERSE_PROPERTY_YES; + break; + } + else + { + } + } + + pRouteCfgDtStr->cCbtcProperty = ROUTE_CBTC_PROPERTY_NO; /*ʼ·ΪCBTC*/ + /*·linkȷ·CBTC*/ + for (i = 0U; i < pDsuRouteStr->wIncludeLinkNum; i++) + { + pRouteIncLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[i]]; + if (0x55U != pRouteIncLinkStru->cCbtcProperty) + { + break; /*linkCBTCԣֹͣ*/ + } + else + { + /*linkCBTCԣ*/ + } + } + + if ((i == pDsuRouteStr->wIncludeLinkNum) && (0U != i)) + { + pRouteCfgDtStr->cCbtcProperty = ROUTE_CBTC_PROPERTY_YES; /*linkCBTCԣ·CBTC*/ + } + else + { + /*linkCBTCԣ·CBTC*/ + } + + pRouteCfgDtStr->HaveDirChangePointInRoute = ROUTE_NOT_HAVE_DIR_CHANGE_POINT;/*·Ĭûз仯*/ + + pRouteCfgDtStr->HaveDirChangePointAfterRoute = ROUTE_NOT_HAVE_DIR_CHANGE_POINT;/*·Ĭûз仯*/ + /*·Ŀ (ֶ)*/ + pRouteCfgDtStr->RoutePhySecSum = 0u; + + for(i=0u;iwPhySecCheckStaId == LSData.pLSPhyAndChkStaStr[i].wId) + { + for(j=0u;jRoutePhySecSum)) + { + rtnvalue = CI_ERROR; + break; + } + pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].PhysicalSectionId =LSData.pLSPhyAndChkStaStr[i].wPhysicalSgmtId[j]; + pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].CheckProperty =(UINT8)LSData.pLSPhyAndChkStaStr[i].wCheckState[j]; + + /*շǷӦȡ*/ + if (0u == pRouteCfgDtStr->RoutePhySecSum) + {/*ԵһLinkΪ׼*/ + /*ȡ·һ*/ + firstAxleSecId = pDsuRouteStr->wIncludeAxleSgmtId[0];/*һ*/ + lastAxleSecId = pDsuRouteStr->wIncludeAxleSgmtId[pDsuRouteStr->wIncludeAxleSgmtNum-1u];/*һ*/ + axleNum = pDsuRouteStr->wIncludeAxleSgmtNum;/**/ + + + /*·һβӦȡ*/ + pRouteCfgDtStr->RoutePhySectionStru[0].LockDirShouldOpposedToRoute + = ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK; + + /*һΣ·пз仯*/ + /*׼*/ + if ((1u < axleNum) && (1u < pDsuRouteStr->wIncludeLinkNum)) + { + /*㵽յ㣬յ㵽*/ + /*·һιLINK1ǰLINK֮ӹϵ(LINKһյ㵽) + յӹϵ(յLINKһ㵽յ)*/ + pDsuAxleSgmt = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[firstAxleSecId]; + + /*·һLINKṹ*/ + pRouteFirstLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[0]]; + /*·ڶLINKṹ*/ + pRouteSecondLinkStru = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[1]]; + + if (pDsuAxleSgmt->wRelatePhysicalSgmtId == pRouteCfgDtStr->RoutePhySectionStru[0].PhysicalSectionId) + {/*ܶ*/ + + + if ((pRouteFirstLinkStru->wOrgnJointMainLkId == pRouteSecondLinkStru->wId) || + (pRouteFirstLinkStru->wOrgnJointSideLkId == pRouteSecondLinkStru->wId)) + {/*һLINKLINKIdӲLINKidڶLINKidͬΪյ㵽*/ + baseDir = TERMINAL_TO_ORIGIN;/*յ㵽*/ + } + else if ((pRouteFirstLinkStru->wTmnlJointMainLkId == pRouteSecondLinkStru->wId) || + (pRouteFirstLinkStru->wTmnlJointSideLkId == pRouteSecondLinkStru->wId)) + { + baseDir = ORIGIN_TO_TERMINAL;/*㵽յ*/ + } + else + { + /*ǣݴ*/ + } + + /*ֱӲLINK仯*/ + flagFind = 0u; + for (lkIndex=0u;(lkIndex < (pDsuRouteStr->wIncludeLinkNum - 1u))&&((DSU_ROUTE_STRU_wLinkId-1u)>lkIndex);lkIndex++) + { + + pDsuLink = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[lkIndex]]; + + + if (ORIGIN_TO_TERMINAL == baseDir) + {/*㵽յ*/ + if ((pDsuLink->wTmnlJointMainLkId == pDsuRouteStr->wLinkId[lkIndex+1u]) || + (pDsuLink->wTmnlJointSideLkId == pDsuRouteStr->wLinkId[lkIndex+1u]) + ) + {/*LINKյLINK յӲLINKΪһLINK*/ + pDsuLinkNext = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[lkIndex+1u]];/*һLINK*/ + + if ((pDsuLinkNext->wTmnlJointMainLkId == pDsuRouteStr->wLinkId[lkIndex]) || + (pDsuLinkNext->wTmnlJointSideLkId == pDsuRouteStr->wLinkId[lkIndex]) + ) + {/*һLINKյLINK յӲLINKΪLINK*/ + /*˵ҵ仯*/ + dirChangeLinkId = pDsuRouteStr->wLinkId[lkIndex+1u];/*仯LINKΪһLINK*/ + findFlag = 1u; + } + else + { + } + } + else + { + } + + } + + else if (TERMINAL_TO_ORIGIN == baseDir) + {/*յ㵽*/ + if ((pDsuLink->wOrgnJointMainLkId == pDsuRouteStr->wLinkId[lkIndex+1u]) || + (pDsuLink->wOrgnJointSideLkId == pDsuRouteStr->wLinkId[lkIndex+1u]) + ) + {/*LINKLINK ӲLINKΪһLINK*/ + pDsuLinkNext = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteStr->wLinkId[lkIndex+1u]];/*һLINK*/ + + if ((pDsuLinkNext->wOrgnJointMainLkId == pDsuRouteStr->wLinkId[lkIndex]) || + (pDsuLinkNext->wOrgnJointSideLkId == pDsuRouteStr->wLinkId[lkIndex]) + ) + {/*һLINKLINK ӲLINKΪLINK*/ + /*˵ҵ仯*/ + + dirChangeLinkId = pDsuRouteStr->wLinkId[lkIndex+1u];/*仯LINKΪһLINK*/ + findFlag = 1u; + } + else + { + } + } + else + { + } + + } + else + { + /*޲*/ + } + + if (1u == findFlag) + {/*ҵ˳ѭ*/ + break; + } + else + { + } + } + + /*·Σҵ仯*/ + for (axleSecIndex =0u;(axleSecIndexwIncludeAxleSgmtNum)&&(DSU_ROUTE_STRU_AxleSgmtId >axleSecIndex);axleSecIndex++) + { + axleSecId = pDsuRouteStr->wIncludeAxleSgmtId[axleSecIndex]; + pDsuAxleSgmt = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[axleSecId]; + if ((pDsuAxleSgmt->wOrgnLkId == dirChangeLinkId) || + (pDsuAxleSgmt->wTmnlLkId == dirChangeLinkId)) + {/*εLINKյLINKΪ仯LINK˼Ϊ仯*/ + dirChangeAxleSecId = pDsuAxleSgmt->wId;/*ҵ仯ID*/ + dirChangePhySecId = pDsuAxleSgmt->wRelatePhysicalSgmtId;/*¼仯ID*/ + break; + } + else + { + } + } + + } + else + { + } + + } + else + { + } + + findRouteProtectDirChangeFlag = 0u; + /*ĬϽ·뱣֮ûз仯*/ + pRouteCfgDtStr->HaveDirChangePointAfterRoute = ROUTE_NOT_HAVE_DIR_CHANGE_POINT; + if (0u == dirChangeAxleSecId)/*·ûз仯*/ + { + /*·һκͱ֮Ƿз仯*/ + if (pDsuRouteStr->wProtectLinkNum > 0u) + {/*б*/ + firstProtectId = pDsuRouteStr->wProtectLinkId[0];/*ȡһID*/ + + if (firstProtectId <= PROTECT_INDEX_NUM) + { + /*ȡñνṹ*/ + pProtectStru = dsuStaticHeadStru.pProtectLinkStru + dsuProtectLinkIndex[firstProtectId]; + + if (pProtectStru->wIncludeAxleSgmtNum > 0u) + {/*α0*/ + + pProtectFirstAxleSec = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[pProtectStru->wIncludeAxleSgmtId[0]]; + + /*εһLINK*/ + pDsuProtectFstAxleSecStartLink = + dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pProtectFirstAxleSec->wOrgnLkId]; + /*εһյLINK*/ + pDsuProtectFstAxleSecEndLink = + dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pProtectFirstAxleSec->wTmnlLkId]; + + /*·һ*/ + pDsuRouteLastAxleSgmt = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[lastAxleSecId]; + + /*·һLINK*/ + pRouteLastLink = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteLastAxleSgmt->wTmnlLkId]; + if ((pRouteLastLink->wTmnlJointMainLkId == pDsuProtectFstAxleSecEndLink->wId) || + (pRouteLastLink->wTmnlJointSideLkId == pDsuProtectFstAxleSecEndLink->wId)) + {/*·һLINKյLINKڱεһյLINK + ·һLINKյӲLINKڱεһյLINK*/ + if ((pDsuProtectFstAxleSecEndLink->wTmnlJointMainLkId == pRouteLastLink->wId) || + (pDsuProtectFstAxleSecEndLink->wTmnlJointSideLkId == pRouteLastLink->wId)) + {/*εһյLINKյLINKڽ·һLINK + εһյLINKյӲLINKڽ·һLINK*/ + /*Զҵ仯*/ + findRouteProtectDirChangeFlag = 1u; + } + } + + /*·һLINK*/ + pRouteLastLink = dsuStaticHeadStru.pLinkStru + dsuLinkIndex[pDsuRouteLastAxleSgmt->wOrgnLkId]; + if ((pRouteLastLink->wOrgnJointMainLkId == pDsuProtectFstAxleSecStartLink->wId) || + (pRouteLastLink->wOrgnJointSideLkId == pDsuProtectFstAxleSecStartLink->wId)) + {/*·һLINKLINKڱεһLINK + ·һLINKӲLINKڱεһLINK*/ + if ((pDsuProtectFstAxleSecStartLink->wOrgnJointMainLkId == pRouteLastLink->wId) || + (pDsuProtectFstAxleSecStartLink->wOrgnJointSideLkId == pRouteLastLink->wId)) + {/*εһLINKLINKڽ·һLINK + εһLINKӲLINKڽ·һLINK*/ + /*Զҵ仯*/ + findRouteProtectDirChangeFlag = 1u; + } + } + + if (1u == findRouteProtectDirChangeFlag) + { + /*·з仯*/ + pRouteCfgDtStr->HaveDirChangePointAfterRoute = ROUTE_HAVE_DIR_CHANGE_POINT; + } + else + {/*·ûз仯*/ + pRouteCfgDtStr->HaveDirChangePointAfterRoute = ROUTE_NOT_HAVE_DIR_CHANGE_POINT; + } + } + else + { + } + } + else + { + } + + + } + else + { + } + } + else + { + } + + } + else if (0u < pRouteCfgDtStr->RoutePhySecSum) + {/*ΣΪ仯LINKѾڴˣ + ֻҪζӦLINKӦǷdirChangeLinkIndex*/ + pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].LockDirShouldOpposedToRoute = + ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*ĬϲӦȡ*/ + if (0u < dirChangePhySecId) + {/*з仯*/ + if (pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].PhysicalSectionId + == dirChangePhySecId) + { + dirChangePhySecIndex = pRouteCfgDtStr->RoutePhySecSum;/**/ + + pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].LockDirShouldOpposedToRoute = + ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK;/*ӦȡһΪ˼*/ + } + else + {/*ڷ仯ID*/ + if (0u == dirChangePhySecIndex) + {/*ûID*/ + pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].LockDirShouldOpposedToRoute = + ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*Ӧȡ*/ + } + else + { + if (pRouteCfgDtStr->RoutePhySecSum > dirChangePhySecIndex) + {/*pRouteCfgDtStr->RoutePhySecSumû++֮ǰ*/ + pRouteCfgDtStr->RoutePhySectionStru[pRouteCfgDtStr->RoutePhySecSum].LockDirShouldOpposedToRoute = + ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK;/*ӦȡһΪ˼*/ + } + else + { + } + + } + } + + + }else + { + } + + } + else + { + /*ڣ*/ + } + if (dirChangePhySecId >0u) + { + pRouteCfgDtStr->HaveDirChangePointInRoute = ROUTE_HAVE_DIR_CHANGE_POINT;/*з仯*/ + } + else + { + } + pRouteCfgDtStr->RoutePhySecSum++; + } + } + + if (ROUTE_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointInRoute) + { + debug_infor_printf((const)"RouteId:%d HaveDirChangePointInRoute dirChangedPhyId:%d\n",pRouteCfgDtStr->RouteId,dirChangePhySecId); + } + else + { + } + + if (ROUTE_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointAfterRoute) + { + debug_infor_printf((const)"RouteId:%d HaveDirChangePointAfterRoute \n",pRouteCfgDtStr->RouteId); + } + else + { + } + } + } + + + + if(CI_SUCCESS == rtnvalue) + { + if (CI_TRADITION_RAILWAY == lineIdentity) + { + /*·Ŀ (ֶ)*/ + pRouteCfgDtStr->RouteSwitchSum = (UINT8)pDsuRouteStr->wIncludePointNum; + for(i=0u;iRouteSwitchSum;i++) + { + if((ROUTE_SWITCH_SUM_MAX > i)&&(DSU_ROUTE_STRU_SWITCH > i)) + { + pRouteCfgDtStr->RouteSwitchStru[i].SwitchId = pDsuRouteStr->wPointId[i]; + pRouteCfgDtStr->RouteSwitchStru[i].SwitchPosition = (UINT8)pDsuRouteStr->wPointStatus[i]; + pRouteCfgDtStr->RouteSwitchStru[i].SwitchProperty = 0xffu; + } + else + { + rtnvalue = CI_ERROR; + break; + } + } + + + pRouteCfgDtStr->RouteLastSwichPhySecId = 0u;/*·Զ˵id*/ + + flagBreak = 0u; + + /*·Զ˵id*/ + if (pRouteCfgDtStr->RouteSwitchSum > 0U) + {/*ȷв*/ + /*·Σĸΰ*/ + if(ROUTE_PHYSICALSECTION_SUM_MAX >= pRouteCfgDtStr->RoutePhySecSum) + { + for (i = pRouteCfgDtStr->RoutePhySecSum;i >0u;i--) + { + if(PHYSICAL_SECTION_SUM_MAX >= dquCICfgDtStr.PsclSgmtCfgDtStrLen) + { + for (j=0u;jRoutePhySectionStru[i-1u].PhysicalSectionId) + { + if ((UINT8)0xaa==dquCICfgDtStr.PsclSgmtCfgDtStr[j].PhySecType ) + {/*в*/ + pRouteCfgDtStr->RouteLastSwichPhySecId = dquCICfgDtStr.PsclSgmtCfgDtStr[j].PhysicalSectionId; + flagBreak = 1u; + break; + } + else + { + } + } + else + { + } + } + if (1u == flagBreak) + { + break; + } + else + { + } + } + else + { + rtnvalue = CI_ERROR; + } + } + if (0u == pRouteCfgDtStr->RouteLastSwichPhySecId) + { + debug_infor_printf((const)"Route %d RouteLastSwichPhySecId is 0.\r\n",pRouteCfgDtStr->RouteId); + } + else + { + } + } + else + { + rtnvalue = CI_ERROR; + } + } + + if((0u !=pLSRouteStr->wFHDCId) && (UINT16_MAX != pLSRouteStr->wFHDCId)) + { + pRouteCfgDtStr->RouteProtectSwitchSum = 0u;/*ʼΪ0*/ + for(i=0u;iwId == pLSRouteStr->wFHDCId) + { + for(j=0u;jwPointId[j]) && (UINT16_MAX != (LSData.pLSFHDaoChaStr+i)->wPointId[j])) + { + if(ROUTE_PROTECTSWI_SUM_MAX > pRouteCfgDtStr->RouteProtectSwitchSum) + { + pRouteCfgDtStr->RouteProtectSwitchStru[pRouteCfgDtStr->RouteProtectSwitchSum].ProtectSwitchId = (LSData.pLSFHDaoChaStr+i)->wPointId[j]; + pRouteCfgDtStr->RouteProtectSwitchStru[pRouteCfgDtStr->RouteProtectSwitchSum].ProtectPosition =(UINT8)(LSData.pLSFHDaoChaStr+i)->wPointSta[j]; + pRouteCfgDtStr->RouteProtectSwitchSum++; + } + else + { + rtnvalue = CI_ERROR; + break; + } + } + else + { + } + } + } + else + { + } + } + } + else + { + } + }/* zt ɾش 2022-02-15 */ + else + { + + } + } + else + { + } + if(CI_SUCCESS == rtnvalue) + { + pRouteCfgDtStr->RouteInitEnemyStatus = ROUTE_INIT_NOT_ENEMY;/*ʼɲж*/ + /*·صжźĿ (ֶ)*/ + pRouteCfgDtStr->RouteEnemySignalSum = 0u; + if(pLSRouteStr->wDDXHId != 0u) + { + findFlag = 0u; + for(j=0u;jwDDXHId == LSData.pLSDDXHZStru[j].wId) + { + for(k=0u;kRouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].SignalId = LSData.pLSDDXHStr[m].wDiDuiXinHaoId; + pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].SwitchSum = 0u; + for(n=0u;n pRouteCfgDtStr->RouteEnemySignalSum) + { + pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].ConditionSwitchStru[n].SwitchId = LSData.pLSDDXHStr[m].wPointId[n]; + pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].ConditionSwitchStru[n].SwitchPosition = (UINT8)LSData.pLSDDXHStr[m].wPointSta[n]; + pRouteCfgDtStr->RouteEnemySigStru[pRouteCfgDtStr->RouteEnemySignalSum].SwitchSum++; + } + else + { + rtnvalue = CI_ERROR; + } + } + else + { + } + } + pRouteCfgDtStr->RouteEnemySignalSum++; + } + else + { + } + } + } + else + { + } + } + findFlag = 1u; + } + else + { + } + + } + if (0u == findFlag) + { + pRouteCfgDtStr->RouteInitEnemyStatus = ROUTE_INIT_ENEMY; + } + else + { + pRouteCfgDtStr->RouteInitEnemyStatus = ROUTE_INIT_NOT_ENEMY; + } + } + else + { + } + + } + + if(CI_SUCCESS == rtnvalue) + { + /*CBTC·ӽĿ (ֶ)*/ + pRouteCfgDtStr->CbtcNearConditionSum = (UINT8)pDsuRouteStr->wCBTCAccessLinkNum; + if(ROUTE_NEARSEC_CONDITION_SUM_MAX >= pDsuRouteStr->wCBTCAccessLinkNum) + { + for(i=0u;i< pDsuRouteStr->wCBTCAccessLinkNum;i++) + { + pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecSum = 0u; + pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum = 0u; + pCbtcAccessStr = dsuStaticHeadStru.pCBTCAccessLinkStru + dsuCBTCAccessLinkIndex[pDsuRouteStr->wCBTCAccessLinkId[i]]; + if((ROUTE_CBTCNEAR_LOGSEC_SUM_MAX >= pCbtcAccessStr->wIncludeLogicSgmtNum) && + (ROUTE_CBTCNEAR_LOGSEC_SUM_MAX >pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecSum)) + { + for(j=0u;jwIncludeLogicSgmtNum;j++) + { + pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecIdBuf[pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecSum] = pCbtcAccessStr->wIncludeLogicSgmtId[j]; + pRouteCfgDtStr->CbtcNearLogSecStru[i].NearLogicSecSum++; + + } + } + else + { + rtnvalue = CI_ERROR; + } + if(CI_SUCCESS==rtnvalue) + { + for(k=0u;kwCBTCAccessLinkRelatePointNum[i];k++) + { + if(ROUTE_CONDITION_SWITCH_SUM_MAX > pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum) + { + pRouteCfgDtStr->CbtcNearLogSecStru[i].ConditionSwitchStru[pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum].SwitchId = pDsuRouteStr->wCBTCAccessLinkRelatePointId[i][k]; + pRouteCfgDtStr->CbtcNearLogSecStru[i].ConditionSwitchStru[pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum].SwitchPosition = (UINT8)pDsuRouteStr->wCBTCAccessLinkRelatePointSta[i][k]; + pRouteCfgDtStr->CbtcNearLogSecStru[i].SwitchSum++; + } + else + { + rtnvalue = CI_ERROR; + } + } + } + else + { + ; /*޲*/ + } + } + } + else + { + rtnvalue = CI_ERROR; + } + } + else + { + } + + if(CI_SUCCESS == rtnvalue) + { + /*ʽ·ӽĿ (ֶ)*/ + if (ROUTE_NEARSEC_CONDITION_SUM_MAX >= pDsuRouteStr->wBlogAccessLinkNum) + { + pRouteCfgDtStr->BlocNearConditionSum = (UINT8)pDsuRouteStr->wBlogAccessLinkNum; + for (i = 0; i< pDsuRouteStr->wBlogAccessLinkNum; i++) + { + pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum = 0; + pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum = 0; + + pBlocAccessStr = dsuStaticHeadStru.pBLOCAccessLinkStru + dsuBLOCAccessLinkIndex[pDsuRouteStr->wBlogAccessLinkId[i]]; + if ((ROUTE_BLOCNEAR_PHYSEC_SUM_MAX >= pBlocAccessStr->wIncludeAxleSgmtNum) && + (ROUTE_BLOCNEAR_PHYSEC_SUM_MAX >pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum)) + { + for (j = 0; j< pBlocAccessStr->wIncludeAxleSgmtNum; j++) + { + pAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[pBlocAccessStr->wIncludeAxleSgmtId[j]]; + for (k=0;kBlocNearPhySecStru[i].NearPhySecSum;k++) /*ȥأظͬһ*/ + { + if (pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecIdBuf[k] == pAxleSgmtStr->wRelatePhysicalSgmtId) + { + break; + } + else + { + ; + } + } + if (k == pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum) + { + pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecIdBuf[pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum] = pAxleSgmtStr->wRelatePhysicalSgmtId; + pRouteCfgDtStr->BlocNearPhySecStru[i].NearPhySecSum++; + for (k = 0; k< pAxleSgmtStr->wRelatPointNum; k++) + { + if (ROUTE_CONDITION_SWITCH_SUM_MAX > pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum) + { + pRouteCfgDtStr->BlocNearPhySecStru[i].ConditionSwitchStru[pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum].SwitchId = pAxleSgmtStr->wRelatPointId[k]; + pRouteCfgDtStr->BlocNearPhySecStru[i].ConditionSwitchStru[pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum].SwitchPosition = (UINT8)pAxleSgmtStr->wRelatPointStatus[k]; + pRouteCfgDtStr->BlocNearPhySecStru[i].SwitchSum++; + } + else + { + rtnvalue = CI_ERROR; + } + } + } + else + { + ; + } + + } + + } + else + { + rtnvalue = CI_ERROR; + } + + } + } + else + { + rtnvalue = CI_ERROR; + } + } + else + { + } + if(CI_SUCCESS == rtnvalue) + { + /*ʽ·Ŀ (ֶ)*/ + /*Ŀǰѯ֧CBTCΰĵϢʴ˰汾CBTC·ҲʽдڻŻ*/ + for (i = 0U; (i < pDsuRouteStr->wCbtcTrgAreaNum) && (ROUTE_BLOC_TRIGGERPHY_NUM > i); i++) + { /*·CBTC*/ + pRouteTriggerPhySecStr = &(pRouteCfgDtStr->BlocTriggerPhySecStru[i]); + pRouteTriggerPhySecStr->TriggerPhySecSum = 0U; + pRouteTriggerPhySecStr->SwitchSum = 0U; + + pCbtcTriggerStr = dsuStaticHeadStru.pCbtcTrgAreaStru + dsuCbtcTrgAreaIndex[pDsuRouteStr->wCbtcTrgAreaId[i]]; + if ((NULL != pCbtcTriggerStr) && (NULL != pCbtcTriggerStr->wLogicSgmtId)) + { + for (j = 0U; (j < pCbtcTriggerStr->wLogicSgmtNum) && (ROUTE_CBTCTRIGGER_LOGSEC_SUM_MAX > j); j++) + { + pLogicSgmeStr = dsuStaticHeadStru.pLogicSgmtStru + dsuLogicSgmtIndex[pCbtcTriggerStr->wLogicSgmtId[j]]; + for (m = 0U; m < ROUTE_BLOCTRIGGER_CONDITION_SUM_MAX; m++) + {/*߼ȥ*/ + if (pLogicSgmeStr->wRelatPhySecId == pRouteTriggerPhySecStr->TriggerPhySecIdBuf[m]) + { + chCheckLogIdSameFlag = 1U; + break; + } + } + if (1U != chCheckLogIdSameFlag) + {/*ǰб޶Ӧ*/ + pRouteTriggerPhySecStr->TriggerPhySecIdBuf[pRouteTriggerPhySecStr->TriggerPhySecSum] = pLogicSgmeStr->wRelatPhySecId; + pRouteTriggerPhySecStr->TriggerPhySecSum++; + for (k = 0U; k < pLogicSgmeStr->chSwitchNum; k++) + { + if (ROUTE_CONDITION_SWITCH_SUM_MAX > pRouteTriggerPhySecStr->SwitchSum) + { + pRouteTriggerPhySecStr->ConditionSwitchStru[pRouteTriggerPhySecStr->SwitchSum].SwitchId = pLogicSgmeStr->wSwitchId[k]; + pRouteTriggerPhySecStr->ConditionSwitchStru[pRouteTriggerPhySecStr->SwitchSum].SwitchPosition = pLogicSgmeStr->chSwitchPosition[k]; + pRouteTriggerPhySecStr->SwitchSum++; + } + else + { + rtnvalue = CI_ERROR; + } + } + } + /*cgh-20230530---ȥر־*/ + chCheckLogIdSameFlag = 0U; + } + } + } + + /*·Ŀ (ֶ)*/ + pRouteCfgDtStr->RouteAssocSwitchSum = 0u; + + if((0u != pLSRouteStr->wDrvSwiGrpId) && (UINT16_MAX != pLSRouteStr->wDrvSwiGrpId)) + { + for(i = 0u; i < LSDataLen.LSAssocSwitchGroupStruLen; i++) + { + if((LSData.pLSAssocSwitchGroupStru + i)->wId == pLSRouteStr->wDrvSwiGrpId) + { + for(j = 0u; j < DRV_SWI_GRP_MAX_INCLUDE_POINT_NUM; j++) + { + if((0u !=(LSData.pLSAssocSwitchGroupStru + i)->wPointId[j]) && (UINT16_MAX != (LSData.pLSAssocSwitchGroupStru + i)->wPointId[j])) + { + if(ROUTE_DRIVED_SWITCH_SUM_MAX > pRouteCfgDtStr->RouteAssocSwitchSum) + { + pRouteCfgDtStr->RouteAssocSwitchStru[pRouteCfgDtStr->RouteAssocSwitchSum].SwitchId = (LSData.pLSAssocSwitchGroupStru + i)->wPointId[j]; + pRouteCfgDtStr->RouteAssocSwitchStru[pRouteCfgDtStr->RouteAssocSwitchSum].SwitchPosition = (UINT8)(LSData.pLSAssocSwitchGroupStru + i)->wPointSta[j]; + + pRouteCfgDtStr->RouteAssocSwitchSum++; + } + else + { + rtnvalue = CI_ERROR; + } + } + else + { + } + } + break; + } + else + { + } + } + } + else + { + } + + /*·۷źŻĿ (ֶ)*/ + pRouteCfgDtStr->RouteReturnSigSum = 0u; + index=0u; + for(i=0u;iwReturnSignalId == LSData.pLSSignalStr[i].wId) + { + for(j=0u;j index) + { + pRouteCfgDtStr->RouteReturnSigIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j]; + index++; + } + else + { + rtnvalue = CI_ERROR; + } + } + else + { + } + } + } + else + { + } + } + pRouteCfgDtStr->RouteReturnSigSum = index; + if (ROUTE_TYPE_RETURN == pRouteCfgDtStr->RouteType )/*۷·*/ + { + if (0u == pLSRouteStr->wReturnSignalId)/*۷źŻû*/ + { + debug_infor_printf((const)"\nRoute %d return signal not config.",pRouteCfgDtStr->RouteId); + DebugPrintAppError(ERROR_RTNROUTE_RTNSIG_NOCONFIG,CI_DEVICE_TYPE_ROUTE,pRouteCfgDtStr->RouteId,PRINT_ONCE); + } + else if (0u == pRouteCfgDtStr->RouteReturnSigSum)/*ˣźŻҲӦID*/ + { + debug_infor_printf((const)"\nRoute %d return signalGroup %d invalid .",pRouteCfgDtStr->RouteId,pLSRouteStr->wReturnSignalId); + DebugPrintAppError(ERROR_RTNROUTE_RTNSIG_INVALID,CI_DEVICE_TYPE_ROUTE,((UINT32)pRouteCfgDtStr->RouteId<<16u)+pLSRouteStr->wReturnSignalId,PRINT_ONCE); + } + else + { + /*޲*/ + } + } + else + { + } + + /*·طĿ (ֶ)*/ + pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pLSRouteStr->wRouteId]; + + pRouteCfgDtStr->OverlapSum = (UINT8)pDsuRouteStr->wProtectLinkNum; + for (i = 0; (i < pDsuRouteStr->wProtectLinkNum) && (i < ROUTE_PROTECTSECGROUP_SUM_MAX); i++) + { + + pRouteCfgDtStr->OverlapIdBuf[i] = pDsuRouteStr->wProtectLinkId[i]; + for (j = 0; j < OVERLAP_SUM_MAX; j++) + { + if (overlapStr[j].OverlapId == pRouteCfgDtStr->OverlapIdBuf[i]) + { + overlapIndex = (UINT8)overlapStr[j].OverlapRouteSum; + if (overlapIndex < OVERLAP_ROUTE_SUM_MAX) + { + overlapStr[j].OverlapRouteIdBuf[overlapIndex] = pRouteCfgDtStr->RouteId; + overlapStr[j].OverlapRouteSum++; + } + break; + } + else + { + /**/ + } + } + } + /*·ȥID (ʼֶ) ҪΪ0*/ + pRouteCfgDtStr->RouteLeavePhySecId = 0u; + + routeId = pLSRouteStr->wRouteId; + routeDir = pLSRouteStr->wDir; /*ʹõ߼*/ + + /*ȡ·ļĿ*/ + axleSgmtNum = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[routeId]].wIncludeAxleSgmtNum; + + /*ȡ·һα*/ + axleSgmtId = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[routeId]].wIncludeAxleSgmtId[axleSgmtNum-1u]; + } + if(CI_SUCCESS == rtnvalue) + { + if (CI_TRADITION_RAILWAY == lineIdentity) + {/*ͳǹ·*/ + /*·ȥΪ·նźŻڷһΣܲڣն赲źŻ*/ + routeEndSignal = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[routeId]].wEndSignalId;/*·նźŻ*/ + if(SIGNAL_SUM_MAX >= dquCICfgDtStr.SgnlCfgDtStrLen) + { + for (i = 0u;i < dquCICfgDtStr.SgnlCfgDtStrLen;i++) + {/*źŻ*/ + if (routeEndSignal == dquCICfgDtStr.SgnlCfgDtStr[i].SignalId) + {/*ҵ·նźŻ*/ + pRouteCfgDtStr->RouteLeavePhySecId = dquCICfgDtStr.SgnlCfgDtStr[i].InFirstPhySecId; + break; + } + else + { + } + } + } + else + { + rtnvalue = CI_ERROR; + } + } + else + { + /* zt ɾش 2022-02-15 */ + } + } + else + { + } + if(CI_SUCCESS==rtnvalue) + { + /*νӦͣID (ֶ)*/ + pRouteCfgDtStr->StopSteadyPhySecId = pLSRouteStr->wFHQD_TW_WLQDId; + + /*/ղ̵ID (ֶ)*/ + for(i=0u;iThatZhaoChaRelayId = 0u; + pRouteCfgDtStr->ThisZhaoChaRelayId = 0u; + pRouteCfgDtStr->cancelZhaochaRelayId = 0u; + pRouteCfgDtStr->CancelZhaoChaRelayOnRelayIntrf = 0u; + pRouteCfgDtStr->ThatZhaoChaPhySecSum = 0u; + pRouteCfgDtStr->RelayBenDuanZcIdOnRelayIntrf = 0u; + pRouteCfgDtStr->RelayDuiDuanZcIdOnRelayIntrf = 0u; + + if(RelayData.pRelayZhaoChaStr[i].wRouteId == pLSRouteStr->wRouteId) + { + pRouteCfgDtStr->ThatZhaoChaRelayId = RelayData.pRelayZhaoChaStr[i].wRelayDuiDuanZcId; + pRouteCfgDtStr->ThisZhaoChaRelayId = RelayData.pRelayZhaoChaStr[i].wRelayBenDuanZcId; + pRouteCfgDtStr->cancelZhaochaRelayId = RelayData.pRelayZhaoChaStr[i].wCancelRelayId; + pRouteCfgDtStr->CancelZhaoChaRelayOnRelayIntrf = RelayData.pRelayZhaoChaStr[i].wCancelRelayIdOnRelayInterface; + pRouteCfgDtStr->RelayBenDuanZcIdOnRelayIntrf = RelayData.pRelayZhaoChaStr[i].wRelayBenDuanZcIdOnRelayInterface; + pRouteCfgDtStr->RelayDuiDuanZcIdOnRelayIntrf = RelayData.pRelayZhaoChaStr[i].wRelayDuiDuanZcIdOnRelayInterface; + + pRouteCfgDtStr->wCbtcThatZhaoChaRelayId = RelayData.pRelayZhaoChaStr[i].wCbtcRelayDuiDuanZcId; + pRouteCfgDtStr->wCbtcThisZhaoChaRelayId = RelayData.pRelayZhaoChaStr[i].wCbtcRelayBenDuanZcId; + pRouteCfgDtStr->wCbtccancelZhaochaRelayId = RelayData.pRelayZhaoChaStr[i].wCbtcCancelRelayId; + /*ͳЧղID*/ + zhaoChaPhySecNum = 0u; + + for(iIndex = 0u; iIndex < ROUTE_THATZC_PHYSEC_SUM_MAX; iIndex++) + { + zCPhySecId = RelayData.pRelayZhaoChaStr[i].wRelayZhaoChaPhySecId[iIndex]; + + + /*ͳЧղID*/ + if((0xffffu != zCPhySecId)&&(0u != zCPhySecId)) + { + pRouteCfgDtStr->ThatZhaoChaPhySecIdBuf[zhaoChaPhySecNum] = zCPhySecId; + zhaoChaPhySecNum++; + } + else + { + } + } + pRouteCfgDtStr->ThatZhaoChaPhySecSum = zhaoChaPhySecNum; + + break; /* һ·ӦֻһղϢ */ + } + else + { + } + } + + /*Ա·ʼźŻΪնźŻ۷·*/ + pRouteCfgDtStr->SignalOpposedRouteSum = 0u; + index=0u; + routeStartSignal = pRouteCfgDtStr->StartSignalId; + for(i = 0u; i index) + { + pRouteCfgDtStr->SignalOpposedRouteIdBuf[index] = LSData.pLSRouteStr[i].wRouteId; + index++; + } + else + { + rtnvalue = CI_ERROR; + index = 0u; + debug_infor_printf((const)"error: SignalOpposedRouteIdBuf not enough space"); + break; + } + + } + else + { + } + } + else + { + } + + } + pRouteCfgDtStr->SignalOpposedRouteSum = index; + + if(CI_SUCCESS == rtnvalue) + {/*Ա·ʼźŻΪնźŻĽ·*/ + pRouteCfgDtStr->SigisEndSigRouteSum = 0u; + index=0u; + routeStartSignal = pRouteCfgDtStr->StartSignalId; + for(i = 0; i index) + { + pRouteCfgDtStr->SigisEndSigRouteIdBuf[index] = LSData.pLSRouteStr[i].wRouteId; + index++; + } + else + { + rtnvalue = CI_ERROR; + index = 0u; + debug_infor_printf((const)"error: SigisEndSigRouteIdBuf not enough space"); + break; + } + + } + } + + } + pRouteCfgDtStr->SigisEndSigRouteSum = index; + } + + if(CI_SUCCESS == rtnvalue) + { + /*·طźŻĿ (ֶ)*/ + pRouteCfgDtStr->RouteInitFSStatus = ROUTE_INIT_NOT_FS; + pRouteCfgDtStr->RouteFSSignalSum = 0u; + index=0u; + findFlag = 0u; + for(i=0u;iwFS_SignalId) && (65535u!=pLSRouteStr->wFS_SignalId)) + { + if(pLSRouteStr->wFS_SignalId == LSData.pLSSignalStr[i].wId) + { + for(j=0u;j index) + { + pRouteCfgDtStr->RouteFSSignalIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j]; + index++; + } + else + { + rtnvalue = CI_ERROR; + index = 0u; + debug_infor_printf((const)"error: RouteFSSignalIdBuf not enough space"); + break; + } + + } + else + { + } + } + findFlag = 1u; + } + else + { + } + if (0u == findFlag) + { + pRouteCfgDtStr->RouteInitFSStatus = ROUTE_INIT_FS; + } + else + { + pRouteCfgDtStr->RouteInitFSStatus = ROUTE_INIT_NOT_FS; + } + } + else + { + } + } + + } + else + { + } + pRouteCfgDtStr->RouteFSSignalSum = index; + + /*·رźŻĿ (ֶ)*/ + if(CI_SUCCESS == rtnvalue) + { + pRouteCfgDtStr->OpenNeedCloseSigSum = 0u; + index=0u; + for(i=0u;iwSignalClsId == LSData.pLSSignalStr[i].wId) + { + for(j=0u;j index) + { + pRouteCfgDtStr->OpenNeedCloseSigIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j]; + index++; + } + else + { + rtnvalue = CI_ERROR; + index = 0u; + debug_infor_printf((const)"error: OpenNeedCloseSigIdBuf not enough space"); + break; + } + } + else + { + } + } + } + else + { + } + } + } + else + { + } + pRouteCfgDtStr->OpenNeedCloseSigSum = index; + /*·迪źŻĿ (ֶ)*/ + if(CI_SUCCESS == rtnvalue) + { + pRouteCfgDtStr->OpenNeedOpenSigSum = 0u; + index=0u; + for(i=0u;iwSignalOpenId == LSData.pLSSignalStr[i].wId) + { + for(j=0u;j index) + { + pRouteCfgDtStr->OpenNeedOpenSigIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j]; + index++; + } + else + { + rtnvalue = CI_ERROR; + index = 0u; + debug_infor_printf((const)"error: OpenNeedOpenSigIdBuf not enough space"); + break; + } + } + else + { + } + } + } + else + { + } + } + } + else + { + } + pRouteCfgDtStr->OpenNeedOpenSigSum = index; + + /*TODO:ȡCBTC迪źŻpRouteCfgDtStrṹӦ:@liuchang*/ + + /*ͬʱźŻĿ (ֶ)*/ + if(CI_SUCCESS == rtnvalue) + { + pRouteCfgDtStr->CBTCOpenNeedOpenSigSum = 0u; + index = 0u; + for (i = 0u; i < LSDataLen.LSSignalStrLen; i++) + { + /*LSDataеźŻṹ壬ҵIDõwCBTCSignalOpenIdһµID*/ + + if (pLSRouteStr->wCBTCSignalOpenId == LSData.pLSSignalStr[i].wId) + { + /*ҵLSDataеCBTC·迪źŻ*/ + for (j = 0u; j < MAX_INCLUDE_SIGNAL_NUM; j++) + { + if (0u != LSData.pLSSignalStr[i].wSignalId[j]) + { + /*ֻCBTC·迪źŻĿźŻ*/ + if (ROUTE_OPENNEEDOPENSIG_SUM_MAX > index) + { + /*LSDataCBTC·迪źŻеźŻIDֵpRouteCfgDtStrеCBTCOpenNeedOpenSigIdBuf*/ + pRouteCfgDtStr->CBTCOpenNeedOpenSigIdBuf[index] = LSData.pLSSignalStr[i].wSignalId[j]; + index++; + } + else + { + rtnvalue = CI_ERROR; + index = 0u; + debug_infor_printf((const)"error: CBTCOpenNeedOpenSigIdBuf not enough space"); + break; + } + } + else + { + } + } + break; + } + else + { + } + } + } + else + { + } + pRouteCfgDtStr->CBTCOpenNeedOpenSigSum = index; + + /*ͬʱźŻĿ (ֶ)*/ + if(CI_SUCCESS == rtnvalue) + { + pRouteCfgDtStr->OnlyOneOpenSigSum = 0u; + index=0u; + for(i=0u;iwBTSOpenId == LSData.pLSSignalStr[i].wId) + { + for(j=0u;j index) + { + pRouteCfgDtStr->OnlyOneOpenSigIdBuf[index]=LSData.pLSSignalStr[i].wSignalId[j]; + index++; + } + else + { + rtnvalue = CI_ERROR; + index = 0u; + debug_infor_printf((const)"error: OnlyOneOpenSigIdBuf not enough space"); + break; + } + } + else + { + } + } + } + else + { + } + } + } + else + { + } + pRouteCfgDtStr->OnlyOneOpenSigSum = index; + #if 0 /* ֱӷŵ */ + /*CBTC·Psd (ֶ)*/ + /*CBTC·Esb (ֶ)*/ + pRouteCfgDtStr->CbtcEsbSum = 0u; + pRouteCfgDtStr->CbtcPsdSum = 0u; + for(i=0u;iwCBTCOtherCIID) + { + for(j=0u;jCbtcEsbIdBuf[pRouteCfgDtStr->CbtcEsbSum] = LSData.pLSOterCiStr[i].wEmgClsBtn[j]; + pRouteCfgDtStr->CbtcEsbSum++; + } + else + { + } + } + for(k=0u;kCbtcPsdIdBuf[pRouteCfgDtStr->CbtcPsdSum] = LSData.pLSOterCiStr[i].wPsdId[k]; + pRouteCfgDtStr->CbtcPsdSum++; + } + else + { + } + } + } + else + { + } + } + + /*BLOC·Psd (ֶ)*/ + /*BLOC·Esb (ֶ)*/ + pRouteCfgDtStr->BlocEsbSum = 0u; + pRouteCfgDtStr->BlocPsdSum = 0u; + for(i=0u;iwBLCKOtherCIID) + { + for(j=0u;jBlocEsbIdBuf[pRouteCfgDtStr->BlocEsbSum] = LSData.pLSOterCiStr[i].wEmgClsBtn[j]; + pRouteCfgDtStr->BlocEsbSum++; + } + else + { + } + } + for(k=0u;kBlocPsdIdBuf[pRouteCfgDtStr->BlocPsdSum] = LSData.pLSOterCiStr[i].wPsdId[k]; + pRouteCfgDtStr->BlocPsdSum++; + } + else + { + } + } + } + else + { + } + } + #else + /* ãBlocCBTC */ + pRouteCfgDtStr->BlockOtherCiSum = 0u; + pRouteCfgDtStr->CbtcOtherCiSum = 0u; + for(i=0u;iwBLCKOtherCIID) + { + for(j=0u;j< OTHER_CI_MAX_DEV_NUM;j++) + { + checkResult = CheckInputOtherCiDevInfoValid(&LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j]); + if(CI_SUCCESS == checkResult) + { + if(ROUTE_OHTER_CHECK_SUM_MAX > (pRouteCfgDtStr->BlockOtherCiSum)) + { + pRouteCfgDtStr->BlockOtherCiBuff[pRouteCfgDtStr->BlockOtherCiSum].DevId = LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wId; + pRouteCfgDtStr->BlockOtherCiBuff[pRouteCfgDtStr->BlockOtherCiSum].DevStatus = LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wDevStatus; + pRouteCfgDtStr->BlockOtherCiBuff[pRouteCfgDtStr->BlockOtherCiSum].DevType = (UINT8)(LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wDevType); + pRouteCfgDtStr->BlockOtherCiSum++; + } + else + { + rtnvalue = CI_ERROR; + debug_infor_printf((const)"error: BlockOtherCiBuff not enough space"); + break; + } + } + else + { + } + } + } + else + { + } + + if(LSData.pLSOterCiStr[i].wId == pLSRouteStr->wCBTCOtherCIID) + { + for(j=0u;j< OTHER_CI_MAX_DEV_NUM;j++) + { + checkResult = CheckInputOtherCiDevInfoValid(&LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j]); + if(CI_SUCCESS == checkResult) + { + if(ROUTE_OHTER_CHECK_SUM_MAX > (pRouteCfgDtStr->CbtcOtherCiSum)) + { + pRouteCfgDtStr->CbtcOtherCiBuff[pRouteCfgDtStr->CbtcOtherCiSum].DevId = LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wId; + pRouteCfgDtStr->CbtcOtherCiBuff[pRouteCfgDtStr->CbtcOtherCiSum].DevStatus = LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wDevStatus; + pRouteCfgDtStr->CbtcOtherCiBuff[pRouteCfgDtStr->CbtcOtherCiSum].DevType = (UINT8)(LSData.pLSOterCiStr[i].otherCiDevInfoBuf[j].wDevType); + pRouteCfgDtStr->CbtcOtherCiSum++; + } + else + { + rtnvalue = CI_ERROR; + debug_infor_printf((const)"error: CbtcOtherCiBuff not enough space"); + break; + } + } + else + { + } + } + } + else + { + } + } + + #endif + + /*ȡ·ڷһ߼ID (ֶ)*/ + devId = pDsuRouteStr->wIncludeAxleSgmtId[0]; + + for (i=0u;iwDir) + { + /*LINKͬ*/ + index = 0u; + pRouteCfgDtStr->InFirstLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index]; + } + else + { + /*LINK෴*/ + index = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[i].wIncludeLogicSgmtNum - 1u); + if(MAX_ALEX_HAVE_LG_NUM > index) + { + pRouteCfgDtStr->InFirstLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index]; + } + else + { + rtnvalue = CI_ERROR; + debug_infor_printf((const)"error: InFirstLogSec,wLogicSgmtId not enough space"); + } + } + + break; + } + else + { + } + } + + /*·һ߼ID*/ + lastDevId = pDsuRouteStr->wIncludeAxleSgmtId[pDsuRouteStr->wIncludeAxleSgmtNum-1u]; + for (i=0u;iwDir) + { + /*ȡһ߼*/ + if (ROUTE_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointInRoute) + { + /*·LINKͬз仯㣬仯һLINKն˶Զ*/ + index = 0U; + pRouteCfgDtStr->InLastLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index]; + } + else + { + index = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[i].wIncludeLogicSgmtNum - 1u); + if (MAX_ALEX_HAVE_LG_NUM > index) + { + pRouteCfgDtStr->InLastLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index]; + } + else + { + rtnvalue = CI_ERROR; + debug_infor_printf((const)"error: InLastLogSec,wLogicSgmtId not enough space"); + } + } + } + else + { + /*·LINK෴з仯㣬仯һLINKʼ˶Զ*/ + if (ROUTE_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointInRoute) + { + /*·LINKͬз仯㣬仯һLINKն˶Զ*/ + index = (UINT8)(dsuStaticHeadStru.pAxleSgmtStru[i].wIncludeLogicSgmtNum - 1U); + if (MAX_ALEX_HAVE_LG_NUM > index) + { + pRouteCfgDtStr->InLastLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index]; + } + else + { + rtnvalue = CI_ERROR; + debug_infor_printf((const)"error: InLastLogSec,wLogicSgmtId not enough space"); + } + } + else + { + index = 0u; + pRouteCfgDtStr->InLastLogSecId = dsuStaticHeadStru.pAxleSgmtStru[i].wLogicSgmtId[index]; + } + } + + break; + } + else + { + ; /**/ + } + } + + /* ݶȡ */ + pRouteCfgDtStr->floodGateSum = 0u; + (void)CommonMemSet(pRouteCfgDtStr->floodGateIdBuf, (UINT32)(sizeof(pRouteCfgDtStr->floodGateIdBuf)/sizeof(UINT8)),0, (UINT32)(sizeof(pRouteCfgDtStr->floodGateIdBuf)/sizeof(UINT8))); + for (i =0u;i < ROUTE_FLOOD_GATE_SUM_MAX;i++) + { + /* 0xFFFF Чֵ */ + if ((UINT16_MAX != pLSRouteStr->wFloodGateIdBuf[i]) && (0u != pLSRouteStr->wFloodGateIdBuf[i])) + { + pRouteCfgDtStr->floodGateIdBuf[pRouteCfgDtStr->floodGateSum] = pLSRouteStr->wFloodGateIdBuf[i]; + pRouteCfgDtStr->floodGateSum++; + } + else + { + } + } + + /*ΪӽʱǷʱֵ*/ + pRouteCfgDtStr->RouteNeedDelayUnlock = pLSRouteStr->wNeedDelayUnlock; + + /*̵ͬID (ֶ)*/ + for(i=0u;iDCRouteDCQJId = 0u; + pRouteCfgDtStr->DCRouteTAJId = 0u; + + if(RelayData.pRelayDCAgreeStr[i].wRouteId == pLSRouteStr->wRouteId) + { + pRouteCfgDtStr->DCRouteDCQJId = RelayData.pRelayDCAgreeStr[i].DCRouteDCQJId; + pRouteCfgDtStr->DCRouteTAJId = RelayData.pRelayDCAgreeStr[i].DCRouteTAJId; + break; + } + else + { + } + } + } + else + { + } + if(CI_SUCCESS == rtnvalue) + { + /*ʼ·߼*/ + rtnvalue = RouteConfigDataStruLogDataInit(pRouteCfgDtStr,pLSRouteStr); + } + else + { + } + + /*·νṹ*/ + if (CI_SUCCESS == rtnvalue) + { + pRouteCfgDtStr->RouteInitInstruStatus = ROUTE_INIT_NOT_INSTRU; + isEachInvFlag = GetCiFunctionSwitchConfig(FUNC_INTRUSEC_VAIN_NEWVERSION); + + /*þɰ汾·*/ + if (FUNC_SWITCH_OFF == isEachInvFlag) + { + + pRouteCfgDtStr->RouteIntruPhySecSum = 0u; + for (i = 0u; i < ROUTE_MAX_QXQD_NUM; i++) + { + if ((0u != pLSRouteStr->wIntrudePhySecId[i]) && (UINT16_MAX != pLSRouteStr->wIntrudePhySecId[i])) + { + findFlag = 0u; + pRouteCfgDtStr->RouteIntruPhySecSum++; + pRouteCfgDtStr->RouteIntruPhySecStru[i].SwitchSum = 0u; + for (j = 0u; j < LSDataLen.LSIntruPhySecStrLen; j++) + { + if (LSData.pLSIntruPhySecStr[j].wId == pLSRouteStr->wIntrudePhySecId[i]) + { + /*·еμIDμеIDͬʱ, + μеIDֵ pRouteCfgDtStr->RouteIntruPhySecStru[i].SectionId*/ + pRouteCfgDtStr->RouteIntruPhySecStru[i].SectionId = LSData.pLSIntruPhySecStr[j].wIntrudePhySecId; + + for (k = 0u; k < QINXIAN_SWITCH_MAX_NUM; k++) + { + if ((0u != LSData.pLSIntruPhySecStr[j].wPointId[k]) && (UINT16_MAX != LSData.pLSIntruPhySecStr[j].wPointId[k])) + { + pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[k].SwitchId = LSData.pLSIntruPhySecStr[j].wPointId[k]; + pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[k].SwitchPosition = (UINT8)LSData.pLSIntruPhySecStr[j].wPointSta[k]; + pRouteCfgDtStr->RouteIntruPhySecStru[i].SwitchSum++; + } + else + { + } + + } + findFlag = 1u; + break; + } + else + { + } + } + if (0u == findFlag) + { + pRouteCfgDtStr->RouteInitInstruStatus = ROUTE_INIT_INSTRU; + } + else + { + pRouteCfgDtStr->RouteInitInstruStatus = ROUTE_INIT_NOT_INSTRU; + } + } + else + { + } + } + + /*·޷ʼ*/ + for (i = 0U; i < pRouteCfgDtStr->RouteIntruPhySecSum; i++) + { + for (j = 0U; j < pRouteCfgDtStr->RouteInLogTrackSum; j++) + { + wLgcSecIndex = dsuLogicSgmtIndex[pRouteCfgDtStr->RouteInLogTrackIdBuf[j]]; + for (k = 0U; k < dquCICfgDtStr.lgcSctCfgDtStr[wLgcSecIndex].chSecInvSecAndConSwiSum; k++) + { + if (pLSRouteStr->wIntrudePhySecId[i] == dquCICfgDtStr.lgcSctCfgDtStr[wLgcSecIndex].wszSecInvSecAndConSwiId[k]) + { + pRouteCfgDtStr->RouteIntruPhySecStru[i].chCondSwitLockDir = dquCICfgDtStr.lgcSctCfgDtStr[wLgcSecIndex].chSecInvSecLockDir[k]; + + break; + } + else + { + ;/*ѯ*/ + } + } + } + } + } + /*߼λ*/ + else + { + pRouteCfgDtStr->RouteIntruPhySecSum = 0u; + + pRouteCfgDtStr->RouteInitInstruStatus = ROUTE_INIT_NOT_INSTRU; + /*·߼*/ + for (i = 0U; i < pRouteCfgDtStr->RouteInLogTrackSum; i++) + { + /*תμ*/ + for (j = 0U; j < LSDataLen.LSIntruPhySecStrLen; j++) + { + /*·߼IDIDһʱμеID޷ֵ pRouteCfgDtStr->RouteIntruPhySecStru[i].SectionId*/ + if ((LSData.pLSIntruPhySecStr[j].belongLogSecId == pRouteCfgDtStr->RouteInLogTrackIdBuf[i]) && (0U != LSData.pLSIntruPhySecStr[j].belongLogSecId)) + { + if (ROUTE_INTRUDEPHYSEC_SUM_MAX > pRouteCfgDtStr->RouteIntruPhySecSum) + { + pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].SectionId = LSData.pLSIntruPhySecStr[j].wIntrudePhySecId; + pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].chCondSwitLockDir = LSData.pLSIntruPhySecStr[j].wCondSwitLockDir; + + /*μе޵ϢֵpRouteCfgDtStr->RouteIntruPhySecStru*/ + pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].SwitchSum = 0u; + for (k = 0U; k < QINXIAN_SWITCH_MAX_NUM; k++) + { + if ((0u != LSData.pLSIntruPhySecStr[j].wPointId[k]) && (UINT16_MAX != LSData.pLSIntruPhySecStr[j].wPointId[k])) + { + pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].ConditionSwitchStru[k].SwitchId = LSData.pLSIntruPhySecStr[j].wPointId[k]; + pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].ConditionSwitchStru[k].SwitchPosition = (UINT8)LSData.pLSIntruPhySecStr[j].wPointSta[k]; + pRouteCfgDtStr->RouteIntruPhySecStru[pRouteCfgDtStr->RouteIntruPhySecSum].SwitchSum++; + } + else + { + ; + } + } + pRouteCfgDtStr->RouteIntruPhySecSum++; + } + else + { + /*·Χʼʧ*/ + rtnvalue = CI_ERROR; + break; + } + } + else + { + /**/ + } + } + + if (CI_ERROR == rtnvalue) + { + debug_infor_printf((const)"[RouteInv] RouteID:%d ERROR: RouteIntruPhySecSum Is Exceed MAX\n", pRouteCfgDtStr->RouteId); + break; + } + else + { + /**/ + } + } + } + + /*־дӡ·*/ + if ((0U < pRouteCfgDtStr->RouteIntruPhySecSum) && (CI_SUCCESS == rtnvalue)) + { + for ( i = 0U; i < pRouteCfgDtStr->RouteIntruPhySecSum; i++) + { + debug_infor_printf((const)"[RouteInv] RouteID:%d, InvSecID:%d, Dir:%d, SwitchID:%d-%d-%d-%d-%d-%d, SwitchState:%d-%d-%d-%d-%d-%d\n", pRouteCfgDtStr->RouteId, pRouteCfgDtStr->RouteIntruPhySecStru[i].SectionId, pRouteCfgDtStr->RouteIntruPhySecStru[i].chCondSwitLockDir, + pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[0].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[1].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[2].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[3].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[4].SwitchId, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[5].SwitchId, + pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[0].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[1].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[2].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[3].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[4].SwitchPosition, pRouteCfgDtStr->RouteIntruPhySecStru[i].ConditionSwitchStru[5].SwitchPosition); + + + } + } + else + { + ; + } + } + + +#if 0 + /*ʼ·*/ + if (CI_SUCCESS == rtnvalue) + { + + if (SIGNAL_VIRTUAL_NO == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->StartSignalId]].signalVirtualAttr + && SIGNAL_VIRTUAL_NO == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->EndSignalId]].signalVirtualAttr) + { + pRouteCfgDtStr->MainRouteProperty = ROUTE_MAIN_PROPERTY; + } + else + { + pRouteCfgDtStr->MainRouteProperty = ROUTE_SUB_PROPERTY; + pRouteCfgDtStr->RouteSubSum = 0U; + } + } + else + { + } +#endif + } + else + { + rtnvalue = CI_ERROR; + } + return rtnvalue; +} + +/* +*ܣ·߼ݳʼ +*˵pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*/ +UINT8 RouteConfigDataStruLogDataInit(RouteConfigDataStruct * pRouteCfgDtStr, LS_RouteStruct * pLSRouteStr) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 k = 0u; + UINT8 phyShouldFlag = 0u; + UINT8 rtnvalue = CI_ERROR; + UINT8 cRouteDir = 0u; + UINT16 routeAxleNum = 0u; + UINT16 routeAxleId = 0u; + UINT16 axleLTrackId = 0u; + UINT16 axleBelongPhy = 0u; /**/ + + DSU_ROUTE_STRU* pDsuRouteStr = NULL; + DSU_AXLE_SGMT_STRU* pDsuAxleSgmtStr = NULL; /*Ϣṹ*/ + + if((NULL != pRouteCfgDtStr) && (NULL != pLSRouteStr)) + { + rtnvalue = CI_SUCCESS; + /*ʼΪ0*/ + pRouteCfgDtStr->RouteInLogTrackSum = 0u; + for(i = 0U; i < MAX_ROUTE_IN_LT_NUM; i++) + { + pRouteCfgDtStr->RouteInLogTrackIdBuf[i] = 0u; + } + /*ȡ·ļ*/ + pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pRouteCfgDtStr->RouteId]; + routeAxleNum = pDsuRouteStr->wIncludeAxleSgmtNum; + + /*ȡ·ʼźŻϢ*/ + cRouteDir = pLSRouteStr->wDir; + /*ڷ仯*/ + if(ROUTE_NOT_HAVE_DIR_CHANGE_POINT == pRouteCfgDtStr->HaveDirChangePointInRoute) + { + /*Ϊ0x55(linkͬ)*/ + if(CI_SYSTEM_DIRECTION_UP == cRouteDir) + { + for(i = 0U; i < routeAxleNum; i++) + { + /*ȡϢ*/ + routeAxleId = pDsuRouteStr->wIncludeAxleSgmtId[i]; + pDsuAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[routeAxleId]; + for(j = 0U; j < pDsuAxleSgmtStr->wIncludeLogicSgmtNum; j++) + { + axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[j]; + /*·߼ID*/ + pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId; + } + } + } + /*Ϊ0xaa(link෴,߼ȡ)*/ + else if(CI_SYSTEM_DIRECTION_DOWN == cRouteDir) + { + for(i = 0U; i < routeAxleNum; i++) + { + /*ȡϢ*/ + routeAxleId = pDsuRouteStr->wIncludeAxleSgmtId[i]; + pDsuAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[routeAxleId]; + + for(j = pDsuAxleSgmtStr->wIncludeLogicSgmtNum; j > 0U; j--) + { + axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[j-1U]; + /*·߼ID*/ + pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId; + } + } + } + /**/ + else + { + /*ʧ*/ + rtnvalue = CI_ERROR; + debug_infor_printf((const)"\nROUTE_startSignalDir err %d\n",pRouteCfgDtStr->RouteId); + } + } + /*ڷ仯*/ + else + { + /*Ϊ0x55(linkͬ)*/ + if(CI_SYSTEM_DIRECTION_UP == cRouteDir) + { + for(i = 0u; i < routeAxleNum; i++) + { + phyShouldFlag = 0u; + /*ȡϢ*/ + routeAxleId = pDsuRouteStr->wIncludeAxleSgmtId[i]; + pDsuAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[routeAxleId]; + axleBelongPhy = pDsuAxleSgmtStr->wRelatePhysicalSgmtId; + for(j = 0u; j < pRouteCfgDtStr->RoutePhySecSum; j++) + { + /*ƥ*/ + if(axleBelongPhy == pRouteCfgDtStr->RoutePhySectionStru[j].PhysicalSectionId) + { + /*·Ӧȡ*/ + if(ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == pRouteCfgDtStr->RoutePhySectionStru[j].LockDirShouldOpposedToRoute) + { + phyShouldFlag = 1u; + + } + } + } + /*ιȡ*/ + if(1u == phyShouldFlag) + { + for(k = pDsuAxleSgmtStr->wIncludeLogicSgmtNum; k > 0u; k--) + { + axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[k-1u]; + /*·߼ID*/ + pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId; + } + } + /*ȡ*/ + else + { + for(k = 0u; k < pDsuAxleSgmtStr->wIncludeLogicSgmtNum; k++) + { + axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[k]; + /*·߼ID*/ + pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId; + } + } + } + } + /*Ϊ0xaa(link෴,߼ȡ)*/ + else if(CI_SYSTEM_DIRECTION_DOWN == cRouteDir) + { + for(i = 0u; i < routeAxleNum; i++) + { + phyShouldFlag = 0u; + /*ȡϢ*/ + routeAxleId = pDsuRouteStr->wIncludeAxleSgmtId[i]; + pDsuAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[routeAxleId]; + axleBelongPhy = pDsuAxleSgmtStr->wRelatePhysicalSgmtId; + for(j = 0u; j < pRouteCfgDtStr->RoutePhySecSum; j++) + { + /*ƥ*/ + if(axleBelongPhy == pRouteCfgDtStr->RoutePhySectionStru[j].PhysicalSectionId) + { + /*·Ӧȡ*/ + if(ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == pRouteCfgDtStr->RoutePhySectionStru[j].LockDirShouldOpposedToRoute) + { + phyShouldFlag = 1u; + + } + } + } + /*ιȡ*/ + if(1u == phyShouldFlag) + { + for(k = 0u; k < pDsuAxleSgmtStr->wIncludeLogicSgmtNum; k++) + { + axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[k]; + /*·߼ID*/ + pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId; + } + } + /*ȡ,߼ΰ*/ + else + { + for(k = pDsuAxleSgmtStr->wIncludeLogicSgmtNum; k > 0u; --k) + { + axleLTrackId = pDsuAxleSgmtStr->wLogicSgmtId[k-1U]; + /*·߼ID*/ + pRouteCfgDtStr->RouteInLogTrackIdBuf[(pRouteCfgDtStr->RouteInLogTrackSum)++] = axleLTrackId; + } + } + } + } + else + { + /*ʧ*/ + rtnvalue = CI_ERROR; + debug_infor_printf((const)"\nROUTE_startSignalDir err %d\n",pRouteCfgDtStr->RouteId); + } + } + } + else + { + /*ʧ*/ + rtnvalue = CI_ERROR; + } + + + return(rtnvalue); +} + +/********************************************* +*ܣʼ· +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteConfigDataStructInit(CHAR * FSName) +{ + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + UINT8 execRet = 0u; + + UINT8 lineIdentity = CI_TRADITION_RAILWAY; + + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*??????:0x55:????;0xAA:????*/ + + callFun = dfsEmapInit(FSName); + callFun *= InitLS_RouteStruct(FSName); + callFun *= InitLS_AutoRtnRouteStru(FSName); + callFun *= InitLS_ReverseRouteStru(FSName); + callFun *= InitLS_RoutePhyAndCheckStaStru( FSName); + callFun *= InitLS_FHDaoChaStru(FSName); + callFun *= InitLS_DrivedSwitchGroupStru(FSName); + callFun *= InitLS_DDXHStru(FSName); + callFun *= InitLS_DDXHZStru(FSName); + callFun *= InitLS_SignalStruct(FSName); + callFun *= InitLS_OtherCIStruct(FSName); + /*add in 2013.05.03ںRouteCfgDtStruFrmLSRouteStr()ǰ*/ + callFun *= InitRelay_ZhaoChaStru(FSName); + + callFun *= InitRelay_DCAgreeStru(FSName);/*ʼ̵ͬ*/ + callFun *= InitLS_SGBJStru(FSName); /*ʼⱨ*/ + callFun *= InitLS_TransRouteRtnDataStruct(FSName); /*ʼת۷źŻ*/ + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + /*ӵͼʼɹִ*/ + dquCICfgDtStr.RouteCfgDtStrLen = LSDataLen.LSRouteStrLen; + + for(i=0u;i= ROUTE_SUM_MAX) + { + rtnvalue = 0u; + } + /*ִУѭ*/ + execRet = RouteCfgDtStruFrmLSRouteStr(LSData.pLSRouteStr + i,&(dquCICfgDtStr.RouteCfgDtStr[i]), dquCICfgDtStr.OvlapCfgDtStr); + if(execRet > 0u) + { + } + else + {/*úʧܣ0*/ + rtnvalue = 0u; + } + + if (1U == rtnvalue) + { + /*ʼ·ʽӽ߼*/ + execRet = RouteBlocNearLogSecInit(LSData.pLSRouteStr + i, &(dquCICfgDtStr.RouteCfgDtStr[i])); + if (0U < execRet) + { + ; /*ִ*/ + } + else + {/*úʧܣ0*/ + rtnvalue = 0u; + } + } + + if (1U != rtnvalue) + { + break; + } + } + } + + if (1u == rtnvalue) + { + for(i=0u;i= ROUTE_SUM_MAX) + { + rtnvalue = 0u; + } + execRet = RouteOpposedConfigDataInite(dquCICfgDtStr.RouteCfgDtStr,&(dquCICfgDtStr.RouteCfgDtStr[i])); + /*ִ·ʼ*/ + if(execRet > 0u) + { + } + else + {/*úʧܣ0*/ + rtnvalue = 0u; + } + + + if (1U == rtnvalue) + { + /*ʼ·һȥ߼*/ + execRet = RouteFirstLeaveLogSecInit(LSData.pLSRouteStr + i, &(dquCICfgDtStr.RouteCfgDtStr[i])); + if (0U < execRet) + { + ; /*ִ*/ + } + else + {/*úʧܣ0*/ + rtnvalue = 0u; + } + } + + + if (1U != rtnvalue) + { + break; + } + } + } + if (1u == rtnvalue) + { + for (i = 0u; i= ROUTE_SUM_MAX) + { + rtnvalue = 0u; + } + execRet = RouteOutLgcSecConfigDataInit(&(dquCICfgDtStr.RouteCfgDtStr[i])); + /*ִ·ʼ*/ + if (execRet > 0u) + { + } + else + {/*úʧܣ0*/ + rtnvalue = 0u; + } + + if (1U != rtnvalue) + { + break; + } + } + } + + /*·ӽ·ݳʼ*/ + if (1u == rtnvalue) + { + for (i = 0u; i < LSDataLen.LSRouteStrLen; i++) + { + if (i >= ROUTE_SUM_MAX) + { + rtnvalue = 0u; + } + if ((CI_TYPE_ZX == (UINT8)dsuStaticHeadStru.pCIStruStru[dsuCIIndex[dquCICfgDtStr.RouteCfgDtStr[i].BelongCiId]].wType) + || (CI_TYPE_SCX == (UINT8)dsuStaticHeadStru.pCIStruStru[dsuCIIndex[dquCICfgDtStr.RouteCfgDtStr[i].BelongCiId]].wType)) + { + execRet = RouteMainProConfigDataInit(dquCICfgDtStr.RouteCfgDtStr, &(dquCICfgDtStr.RouteCfgDtStr[i])); + if (execRet > 0u) + { + } + else + {/*úʧܣ0*/ + rtnvalue = 0u; + } + if (1U != rtnvalue) + { + break; + } + } + else + { + dquCICfgDtStr.RouteCfgDtStr[i].MainOrSubData.RouteBelMainSum = 0U; + dquCICfgDtStr.RouteCfgDtStr[i].MainOrSubData.RouteSubSum = 0U; + dquCICfgDtStr.RouteCfgDtStr[i].MainOrSubData.MainRouteProperty = ROUTE_INIT_PROPERTY; /*ĬΪͨ·*/ + } + } + } + + /*߼ι·*/ + if (1u == rtnvalue) + { + for (i = 0u; i < dquCICfgDtStr.lgcSctCfgDtStrLen; i++) + { + execRet = LogRelateRouteDataInit(dquCICfgDtStr.RouteCfgDtStr, &(dquCICfgDtStr.lgcSctCfgDtStr[i]));/*߼ι·*/ + execRet *= LogRelateProSwDataInit(dquCICfgDtStr.RouteCfgDtStr, &(dquCICfgDtStr.lgcSctCfgDtStr[i]));/*߼ι*/ + if (execRet > 0u) + { + + } + else + {/*úʧܣ0*/ + rtnvalue = 0u; + } + if (1U != rtnvalue) + { + break; + } + } + } + + /*·ⱨ*/ + if (1U == rtnvalue) + { + for (i = 0U; i < LSDataLen.LSRouteStrLen; i++) + { + if (i >= ROUTE_SUM_MAX) + { + rtnvalue = 0U; + } + else + { + /*ִ*/ + } + + execRet = RouteRelatedSGBJCfgDataInit(&(dquCICfgDtStr.RouteCfgDtStr[i]), LSData.pLSSGBJStru); /*·ⱨ*/ + + if (execRet > 0U) + { + /*ִ*/ + } + else + { + rtnvalue = 0U; /*ʧܣ0*/ + } + + if (1U != rtnvalue) + { + break; + } + } + } + /*· ת۷źŻ*/ + if (1U == rtnvalue) + { + for (i = 0U; i < LSDataLen.LSRouteStrLen; i++) + { + if (i >= ROUTE_SUM_MAX) + { + rtnvalue = 0U; + } + else + { + /*ִ*/ + } + + execRet = RouteRelatedTransZFSigInit(&(dquCICfgDtStr.RouteCfgDtStr[i]), LSData.pLSTransRouteZFSigStru); /*·ת۷źŻ*/ + + if (execRet > 0U) + { + /*ִ*/ + } + else + { + rtnvalue = 0U; /*ʧܣ0*/ + } + + if (1U != rtnvalue) + { + break; + } + } + } + return rtnvalue; +} + +/********************************************* +*ܣнͨŹϵ豸IPȥݣÿ17ݣ +*˵Dataͨ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 TransmitRelationDataStruFrmSZ(UINT16 Data[]) +{ + UINT8 rtnvalue = 0u; + UINT16 i=0u; + UINT16 j =0u; + UINT16 Type = 0u; + UINT16 findIndex = 0u;/*ڼеzcdusͨŹϵҵ0δҵֵҵ*/ + UINT8 tmpCiId=0u; /*ʱci id*/ + UINT8 tmpOtherSysType =0u;/*ʱϵͳ*/ + UINT8 findFlag = 0u; /*ҵ־*/ + + /*ڲ*/ + if(NULL == Data) + { + /*ʧ*/ + return 0u; + } + else + { + } + + if((0x3c00u != (Data[0]&0xFF00u))) + { + rtnvalue = 1u; + return rtnvalue; + } + else + { } +#if 0 + /*ڶЧݳ*/ + for(i=0u;i>8); + dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum = 0; + dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceIdBuf[dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum] = (UINT8)(Data[2+i]&0x00FF); + dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum++; + dquCICfgDtStr.TrsmtRlsDtStrLen++; + Type = (Data[2+i]&0xFF00); + } + /*ͬͨ豸ֻ¼һIDͺ(Ĭͬ豸дһ)*/ + else + { + dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen-1].DeviceIdBuf[dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen-1].DeviceSum] = (UINT8)(Data[2+i]&0x00FF); + dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen-1].DeviceSum++; + } + } +#endif + /*ڶЧݳ*/ + for(i=0u;i>8u); + + findFlag = 0u; + + for (j=0u;j>8u); + dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum = 0u; + dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceIdBuf[dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum] = (UINT8)(Data[2u+i]&0x00FFu); + dquCICfgDtStr.TrsmtRlsDtStr[dquCICfgDtStr.TrsmtRlsDtStrLen].DeviceSum++; + dquCICfgDtStr.TrsmtRlsDtStrLen++; + Type = (Data[2u+i]&0xFF00u); + + + } + else if (1u == findFlag) + {/*ҵҵĽṹ豸*/ + dquCICfgDtStr.TrsmtRlsDtStr[findIndex].DeviceIdBuf[dquCICfgDtStr.TrsmtRlsDtStr[findIndex].DeviceSum] = (UINT8)(Data[2U+i]&0x00FFu); + dquCICfgDtStr.TrsmtRlsDtStr[findIndex].DeviceSum++; + } + else + { + /*Ƿֵ*/ + } + } + + + + rtnvalue = 1u; + return rtnvalue; +} + +/********************************************* +*ܣʼͨŹϵݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 TransmitRelationDataStructInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + UINT16 i,j; + UINT8 funcRtn = 0u; + UINT16 Data[ZC_DSU_TRANSMIT_DATA_LEN/2U]; + /*ȡ ͨŹϵ */ + funcRtn = dquGetConfigData(FSName,DEVICE_IP_TYPE, ZC_DSU_TRANSMIT_DATA_ID,&pDataAddr,&DataSize); + + if(funcRtn == 0u) + { + /*ʧ*/ + rtnValue = 0u; + return rtnValue; + } + /*ø*/ + if(DataSize%ZC_DSU_TRANSMIT_DATA_LEN != 0u) + { + rtnValue = 0u; + debug_infor_printf((const)"\nCI_DEVICE_IP_DATA,ZC_DSU_COMM,len %d not equal to fs",CI_SYSTEM_CI_FUNC_SWITCH_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(DEVICE_IP_TYPE<<8)+ZC_DSU_TRANSMIT_DATA_ID,PRINT_ONCE); + return rtnValue; + } + for(i=0u;iOpposedRouteSum = 0u; + for(i=0u; iRoutePhySecSum; i++) + {/*·*/ + + for(j=0u; jRouteId == RouteCfgDtStr[j].RouteId) + { + /*ȥ·*/ + } + else + { + for (k = 0u; k < RouteCfgDtStr[j].RoutePhySecSum; k++) + {/*ý·*/ + + if (pRouteCfgDtStr->RoutePhySectionStru[i].PhysicalSectionId == RouteCfgDtStr[j].RoutePhySectionStru[k].PhysicalSectionId) + {/*ͬ*/ + + Flag = 0u; + for (n = 0u; n < ROUTE_OPPOSED_ROUTE_SUM_MAX; n++) + {/*ִ·飬ǷѾӸõִ·*/ + + if (pRouteCfgDtStr->OpposedRouteIdBuf[n] == RouteCfgDtStr[j].RouteId) + { + Flag = 1u; + break; + /*Ѿ*/ + } + } + if (Flag == 1u) + { + /*Ѿڣ*/ + } + else + { + /*ӵִ·*/ + pRouteCfgDtStr->OpposedRouteIdBuf[index] = RouteCfgDtStr[j].RouteId;/*ִ*/ + index++; + } + } + } + + } + } + } + + pRouteCfgDtStr->OpposedRouteSum = index; + return rtnvalue; +} + + +/********************************************* +*ܣͬһ·Σڱ·Ҳڵ߼+ +* ͬһ߼Σڱ·߼γʼ +*˵pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteOutLgcSecConfigDataInit(RouteConfigDataStruct * pRouteCfgDtStr) +{ + UINT16 i = 0u, j = 0u; + UINT8 rtnvalue = 0u; + UINT8 szHitSwProLgcSec[LOGIC_SECTION_SUM_MAX] = { 0U }; + UINT8 szHitRouteLgcSec[LOGIC_SECTION_SUM_MAX] = { 0U }; + PhysicalSectionConfigDataStruct *pPhySecCfgDtSt = NULL; + SwitchConfigDataStruct *pSwitchCfgDtSt = NULL; + UINT16 wPhyIndex = 0U; + UINT16 wSwitchIndex = 0U; + if (NULL != pRouteCfgDtStr) + { + rtnvalue = 1U; + for (i = 0u; i < pRouteCfgDtStr->RouteInLogTrackSum; i++) + { + + if (LOGIC_SECTION_SUM_MAX > pRouteCfgDtStr->RouteInLogTrackIdBuf[i]) + { + szHitRouteLgcSec[pRouteCfgDtStr->RouteInLogTrackIdBuf[i]] = 1U; + } + else + { + rtnvalue = 0U; + break; + } + } + + if (1U == rtnvalue) + { + pRouteCfgDtStr->RouteInSwitOtherPosLogSecSum = 0U; + for (i = 0u; i < pRouteCfgDtStr->RouteSwitchSum; i++) + { + wSwitchIndex = dsuPointIndex[pRouteCfgDtStr->RouteSwitchStru[i].SwitchId]; + pSwitchCfgDtSt = &dquCICfgDtStr.SwchCfgDtStr[wSwitchIndex]; + for (j = 0U; j < pSwitchCfgDtSt->SwitchLogSecSum; j++) + { + if (LOGIC_SECTION_SUM_MAX > pSwitchCfgDtSt->SwitchLogSecIdBuf[j]) + { + if (1U != szHitRouteLgcSec[pSwitchCfgDtSt->SwitchLogSecIdBuf[j]]) + { + pRouteCfgDtStr->RouteInSwitOtherPosLogSecIdBuf[pRouteCfgDtStr->RouteInSwitOtherPosLogSecSum++] = pSwitchCfgDtSt->SwitchLogSecIdBuf[j]; + } + szHitSwProLgcSec[pSwitchCfgDtSt->SwitchLogSecIdBuf[j]] = 1U; + } + else + { + rtnvalue = 0U; + break; + } + } + } + } + + if (1U == rtnvalue) + { + pRouteCfgDtStr->RouteOutLogSecSum = 0U; + for (i = 0u; i < pRouteCfgDtStr->RoutePhySecSum; i++) + { + wPhyIndex = dsuPhysicalSgmtIndex[pRouteCfgDtStr->RoutePhySectionStru[i].PhysicalSectionId]; + pPhySecCfgDtSt = &dquCICfgDtStr.PsclSgmtCfgDtStr[wPhyIndex]; + for (j = 0U; j < pPhySecCfgDtSt->LogSectionSum; j++) + { + if (LOGIC_SECTION_SUM_MAX > pPhySecCfgDtSt->LogSectionIdBuf[j]) + { + if ((1U != szHitRouteLgcSec[pPhySecCfgDtSt->LogSectionIdBuf[j]]) + &&(1U!= szHitSwProLgcSec[pPhySecCfgDtSt->LogSectionIdBuf[j]])) + { + pRouteCfgDtStr->RouteOutLogSecSumIdBuf[pRouteCfgDtStr->RouteOutLogSecSum++] = pPhySecCfgDtSt->LogSectionIdBuf[j]; + } + } + else + { + rtnvalue = 0U; + break; + } + } + } + } + } + + return rtnvalue; +} +/********************************************* +*ܣʼSpksݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SpksConfigDataStructInit(CHAR * FSName) +{ + UINT8 rtnvalue = 0U; + UINT8 tmpRet = 0U; + UINT16 i=0U; + + tmpRet = dfsEmapInit (FSName); + tmpRet *= InitRelaySpksStru(FSName); + + if (1U == tmpRet) + { + rtnvalue = 1U; + } + else + { + rtnvalue = 0U; + } + + /*ӵͼʼɹִ*/ + if(1U == rtnvalue) + { + if (0U == dsuDataLenStru.wSpksButtonLen) + { + /*Ϊӵͼ߼SPKSеĸ*/ + dquCICfgDtStr.spksDataConfigStrLen = dsuDataLenStru.wLogSecSpksLen; + } + else + { + /*ΪӵͼSPKSеĸ*/ + dquCICfgDtStr.spksDataConfigStrLen = dsuDataLenStru.wSpksButtonLen; + } + for (i = 0U; i < dquCICfgDtStr.spksDataConfigStrLen; i++) + { + if (i >= SPKS_SUM_MAX) + { + rtnvalue = 0U; + } + if (1U == rtnvalue) + { + if (0U == dsuDataLenStru.wSpksButtonLen) + { + /*ӵӵͼ߼SPKSгʼ*/ + rtnvalue = ReadDataFromDquLogSpksData(dsuStaticHeadStru.pLogSecSpksButtonStru + i, &dquCICfgDtStr.spksDataConfigStr[i]); + } + else + { + /*ӵӵͼSPKSгʼ*/ + rtnvalue = ReadDataFromDquPhySpksData(dsuStaticHeadStru.pSpksButtonStru + i, &dquCICfgDtStr.spksDataConfigStr[i]); + } + } + if (1U == rtnvalue) + { + rtnvalue = ReadSpksConfigDataFromDquData(&dquCICfgDtStr.spksDataConfigStr[i]); + } + if (0U == rtnvalue) + { + break; + } + } + } + if (1u == rtnvalue) + { + /*ʼζӦSPKSϢ*/ + for (i = 0u; i < dsuDataLenStru.wPhysicalSgmtLen; i++) + { + if (i >= PHYSICAL_SECTION_SUM_MAX) + { + rtnvalue = 0u; + } + else + { + rtnvalue = PhysicRelateSpksStr(&dquCICfgDtStr.PsclSgmtCfgDtStr[i]); + } + if (0u == rtnvalue) + { + break; + } + } + } + + return rtnvalue; +} + +/********************************************* +*ܣʼŽݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MJConfigDataStructInit(CHAR* FSName) +{ + UINT8 rtnvalue = 0u; + UINT8 tmpRet = 0u; + + tmpRet = dfsEmapInit(FSName); + tmpRet *= InitRelay_MJStru(FSName); + + if (1u == tmpRet) + { + rtnvalue = 1u; + } + else + { + rtnvalue = 0u; + } + + /*ӵͼʼɹִ*/ + if (1u == rtnvalue) + { + /*ΪŽ*/ + dquCICfgDtStr.mjDataConfigStrLen = RelayDataLen.RelayMJStrLen; + /*ȡŽݵdquCICfgDtStr*/ + rtnvalue = ReadMJConfigDataFromDquData(dquCICfgDtStr.mjDataConfigStr); + + } + + return rtnvalue; +} + +/********************************************* +*ܣʼȫԶ۷·ݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 AllAutoReturnCfgDtStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u,j=0u; + + callFun = dfsEmapInit (FSName); + callFun *= InitLS_AllAutoRtnRouteStru(FSName); + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + /*ӵͼʼɹִ*/ + + dquCICfgDtStr.AllAutoRtnRouteCfgDtStrLen = LSDataLen.LSAllAutoRtnRouteStrLen; + for(i=0u;i= ALL_AUTO_RETURN_SUM_MAX) + { + rtnvalue = 0u; + break; + } + dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].AllAutoReturnId = LSData.pLSAllAutoRtnRouteStr[i].wId; + dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].BelongCiId = (UINT8)dsuStaticHeadStru.pRouteStru[ dsuRouteIndex[LSData.pLSAllAutoRtnRouteStr[i].szIncludeRouteId[0]]].wManageCI ; + dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RouteSum = 0u; + dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RebackRouteSum = 0u; + + for(j=0u;j=(AARR_MAX_INCLUDE_ROUTE_NUM-2u)) + { + dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RebackRouteIdBuf[dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RebackRouteSum] = LSData.pLSAllAutoRtnRouteStr[i].szIncludeRouteId[j]; + dquCICfgDtStr.AllAutoRtnRouteCfgDtStr[i].RebackRouteSum += 1u; + + } + } + + + } + } + } + return rtnvalue; +} + +/********************************************* +*ܣʼŽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GaragedoorConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT8 i=0u; + + callFun = dfsEmapInit (FSName); + callFun *= InitRelay_GaragedoorStru (FSName); + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + if (1u == rtnvalue) + { + /*ӵͼʼɹִ*/ + dquCICfgDtStr.GaragedoorCfgDtStrLen = dsuDataLenStru.wDepotGateLen; + for(i=0u;i=GARAGE_DOOR_SUM_MAX) + { + rtnvalue = 0u; + break; + } + (void)GaragedoorCfgDtStruFromDquStr(dsuStaticHeadStru.pDepotGateStru + i,&dquCICfgDtStr.GaragedoorCfgDtStr[i]); + } + + } + + return rtnvalue; +} + +/* +: ʼ·豸ݽṹ(ṹ) +: CHAR * FSName ļָ +: +ֵ: 0 ʧ + 1 ɹ +*/ +UINT8 DiffLineDevConfigDataStructInit(CHAR * FSName) +{ + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 i = 0u; /*ѭ*/ + UINT8 retVal = 0u; /*ֵ*/ + UINT8 dquGetConfDataRetVal = 0u; /*ȡݺֵ*/ + + /*ȡDZ·豸*/ + dquGetConfDataRetVal = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_DIFF_LINE_DEV_ID, &pDataAddr, &DataSize); + + if(1u == dquGetConfDataRetVal) + { + if(0u != DataSize) + { + if(0u == (DataSize % CI_SYSTEM_CI_DIFF_LINE_DEV_LEN)) + { + /* dqu */ + (void)CommonMemSet(dquCICfgDtStr.dquCIfg_DiffLineDevData, (UINT32)sizeof(dquCICfgDtStr.dquCIfg_DiffLineDevData), 0, (UINT32)sizeof(dquCICfgDtStr.dquCIfg_DiffLineDevData)); + + /*ø*/ + tempDquDiffLineDevDataLen= (UINT16) (DataSize / CI_SYSTEM_CI_DIFF_LINE_DEV_LEN); + pTempDquDiffLineDevData = (DquDiffLineDevStruct *)MyNew((UINT32)(tempDquDiffLineDevDataLen * sizeof(DquDiffLineDevStruct))); + + if(NULL == pTempDquDiffLineDevData) + { + tempDquDiffLineDevDataLen = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->signalNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->switchNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->psdNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->esbNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->spksNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->axisSectNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->physSectNum = 0u; + + retVal = 0u; + } + else + { + for (i = 0u; i < tempDquDiffLineDevDataLen; i++) + { + (void)PZDquDiffLineDevDataFromChar(pDataAddr, pTempDquDiffLineDevData + i); + + pDataAddr += CI_SYSTEM_CI_DIFF_LINE_DEV_LEN; + + (void)ReadDquDiffLineDevDataToConfig(pTempDquDiffLineDevData + i, dquCICfgDtStr.dquCIfg_DiffLineDevData); + } + + retVal = 1u; + } + } + else + { + dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->signalNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->switchNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->psdNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->esbNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->spksNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->axisSectNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->physSectNum = 0u; + + debug_infor_printf((const)"\nCI_CONFIG_DATA,NEIGHBOUR_LINE_DATA,len %d not equal to fs",CI_SYSTEM_CI_DIFF_LINE_DEV_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_CI_DIFF_LINE_DEV_ID,PRINT_ONCE); + + retVal = 0u; + } + } + else + { + dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->signalNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->switchNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->psdNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->esbNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->spksNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->axisSectNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->physSectNum = 0u; + + retVal = 1u; + } + } + else + { + dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->signalNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->switchNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->psdNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->esbNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->spksNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->axisSectNum = 0u; + dquCICfgDtStr.dquCIfg_DiffLineDevData->physSectNum = 0u; + + retVal = 0u; + } + + return retVal; +} + +/********************************************* +*ܣó +*˵physicalId ID +pGaragedoorCfgDtStr ݽṹָ +*ֵvoid +*********************************************/ +void SetGardoorphySecData(GaragedoorConfigDataStruct* pGaragedoorCfgDtStr, UINT16 physicalId) +{ + UINT16 k = 0u; /*ѭ*/ + + for (k = 0u; k < pGaragedoorCfgDtStr->GardoorphySecSum; k++) + { + if (pGaragedoorCfgDtStr->GardoorphySecBuf[k] == physicalId) + { + /*Ѱ*/ + + break; + } + + } + if ((k == pGaragedoorCfgDtStr->GardoorphySecSum)&&(physicalId != 0u)) + { + pGaragedoorCfgDtStr->GardoorphySecBuf[pGaragedoorCfgDtStr->GardoorphySecSum] = physicalId; + pGaragedoorCfgDtStr->GardoorphySecSum ++; + } +} + +/********************************************* +*ܣŽӿݽṹ +*˵pGaragedoor ṹָ +pGaragedoorCfgDtStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GaragedoorCfgDtStruFromDquStr(DSU_DEPOT_GATE_STRU * pGaragedoor,GaragedoorConfigDataStruct* pGaragedoorCfgDtStr) +{ + UINT16 i = 0u; + UINT16 index = 0u; + UINT8 rtnvalue = CI_ERROR; + UINT16 j = 0u; + UINT16 physicalId = 0u; + UINT16 k = 0u; + UINT16 l=0u; + UINT16 linkindex = 0u; + /*ڲ*/ + if((NULL == pGaragedoor) || (NULL == pGaragedoorCfgDtStr)) + { + /*ʧ*/ + rtnvalue = CI_ERROR; + } + else + { + rtnvalue = CI_SUCCESS; + pGaragedoorCfgDtStr->GaragedoorId = pGaragedoor->wId; + rtnvalue = GetDsuLinkIndexNum(pGaragedoor->wDepotGateLinkID,&linkindex); + if(CI_SUCCESS == rtnvalue) + { + pGaragedoorCfgDtStr->BelongCiId = (UINT8)dsuStaticHeadStru.pLinkStru[linkindex].wManagePhysicalCI; + pGaragedoorCfgDtStr->BelongVirCiId = (UINT8)dsuStaticHeadStru.pLinkStru[linkindex].wBelongVirtualCI; + } + if(CI_SUCCESS == rtnvalue) + { + for(i=0u;iwId == (RelayData.pRelayGaragedoorStr+i)->wGaragedoorId) + { + pGaragedoorCfgDtStr->GardoorOpenRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorOpenRelayId; + pGaragedoorCfgDtStr->GardoorCloseRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorCloseRelayId; + pGaragedoorCfgDtStr->GardoorOpenOrderRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorOpenOrderRelayId; + pGaragedoorCfgDtStr->GardoorCloseOrderRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorCloseOrderRelayId; + pGaragedoorCfgDtStr->GardoorModeStateRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorModeStateRelayId; + pGaragedoorCfgDtStr->GardoorFaultStateRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorFaultStateRelayId; + pGaragedoorCfgDtStr->GardoorPangLuRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorPangLuRelayId; + pGaragedoorCfgDtStr->GardoorKGHRelayId = (RelayData.pRelayGaragedoorStr+i)->wGardoorKGHRelayId; + /* + * ȡŵ:źŻspks·AߡλϢ + */ + if (pGaragedoor->wProectSignalNum <= GARAGE_DOOR_SIG_MAX) + { + pGaragedoorCfgDtStr->phySecAKUId = pGaragedoor->wAPhysicalSgmtId; + pGaragedoorCfgDtStr->depotAttribute = (UINT8)pGaragedoor->sDepotAttribute; + pGaragedoorCfgDtStr->signalSum = pGaragedoor->wProectSignalNum; + pGaragedoorCfgDtStr->GardoorLinkId = pGaragedoor->wDepotGateLinkID; + pGaragedoorCfgDtStr->GardoorOffset = pGaragedoor->dwDepotGateLinkoffset; + for (index = 0u;index < pGaragedoorCfgDtStr->signalSum;index++) + { + + pGaragedoorCfgDtStr->signalIdBuff[index] = pGaragedoor->wProtectSignalId[index]; + } + } + else + { + rtnvalue = CI_ERROR; + } + if (pGaragedoor->wRouteInsideNum <= GARAGE_DOOR_ENTER_ROUTE_MAX) + { + pGaragedoorCfgDtStr->GardoorRouteSum = (UINT8)(pGaragedoor->wRouteInsideNum); + for (index = 0u;index < pGaragedoor->wRouteInsideNum;index++) + { + if (0u != pGaragedoor->wRouteInsideId[index]) + { + for (j = 0u; j< LSDataLen.LSRouteStrLen;j++) + { /*ҳӦĽ·IDӦ±*/ + if (pGaragedoor->wRouteInsideId[index] == dquCICfgDtStr.RouteCfgDtStr[j].RouteId) + { + for (l=0u;lGardoorRouteBuf[index] = pGaragedoor->wRouteInsideId[index]; + } + break; + } + + } + /*ҵӦĽ·ID*/ + break; + } + } + } + } + } + else + { + rtnvalue = CI_ERROR; + } + + if (pGaragedoor->wRouteOutsideNum <= GARAGE_DOOR_EXIT_ROUTE_MAX) + { + for (index = 0u;index < pGaragedoor->wRouteOutsideNum;index++) + { + if (0u != pGaragedoor->wRouteOutsideId[index]) + { + for (j = 0u; j< LSDataLen.LSRouteStrLen;j++) + { + if (pGaragedoor->wRouteOutsideId[index] == dquCICfgDtStr.RouteCfgDtStr[j].RouteId) + { + for (l=0u;lGardoorRouteBuf[pGaragedoorCfgDtStr->GardoorRouteSum + index] = pGaragedoor->wRouteOutsideId[index]; + + } + break; + } + + } + /*ҵӦĽ·ID*/ + break; + } + } + } + } + pGaragedoorCfgDtStr->GardoorRouteSum += (UINT8)(pGaragedoor->wRouteOutsideNum); + } + else + { + rtnvalue = CI_ERROR; + } + + if (pGaragedoor->wSpksNum <= GARAGE_DOOR_SPKS_MAX) + { + pGaragedoorCfgDtStr->GardoorSpksSum = pGaragedoor->wSpksNum; + for (index = 0u; index < pGaragedoorCfgDtStr->GardoorSpksSum;index++) + { + pGaragedoorCfgDtStr->spksIdBuff[index] = pGaragedoor->wSpksId[index]; + } + } + else + { + rtnvalue = CI_ERROR; + } + + break; + + } + } + if (CI_SUCCESS != rtnvalue) + { + pGaragedoorCfgDtStr->GardoorOpenRelayId = 0u; + pGaragedoorCfgDtStr->GardoorCloseRelayId = 0u; + pGaragedoorCfgDtStr->GardoorOpenOrderRelayId = 0u; + pGaragedoorCfgDtStr->GardoorCloseOrderRelayId = 0u; + pGaragedoorCfgDtStr->GardoorModeStateRelayId = 0u; + pGaragedoorCfgDtStr->GardoorSpksSum = 0u; + pGaragedoorCfgDtStr->depotAttribute = 0U; + pGaragedoorCfgDtStr->phySecAKUId = 0U; + pGaragedoorCfgDtStr->GardoorLinkId = 0U; + pGaragedoorCfgDtStr->GardoorOffset = 0U; + pGaragedoorCfgDtStr->signalSum = 0u; + pGaragedoorCfgDtStr->GardoorphySecSum = 0u; + rtnvalue = CI_ERROR; + } + } + } + return rtnvalue; +} + +/********************************************* +*ܣSPKSṹSPKS̵ID +*˵pSpksDataConfigźŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReadSpksConfigDataFromDquData(SpksDataConfigStruct* pSpksDataConfig) +{ + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + UINT16 k = 0u; + /*ڲ*/ + if (pSpksDataConfig!= NULL) + { + /*ʼǰȫΪ0*/ + pSpksDataConfig->colRelayId = 0u; + pSpksDataConfig->displayRelayId = 0u; + pSpksDataConfig->cutRelayId = 0u; + pSpksDataConfig->repRelayId = 0u; + pSpksDataConfig->cutDisplayRelayId = 0u; + pSpksDataConfig->menjinJSRelayId = 0u; /*SPKSŽ̵ID */ + pSpksDataConfig->VirtualAttribute = SPKS_VIRTUAL_ATTR_NO;/*ʼΪ*/ + if (NULL != RelayData.pRelaySpksStr) + { + for (i=0u;i < RelayDataLen.RelaySpksStrLen; i++) + { + if (RelayData.pRelaySpksStr[i].id == pSpksDataConfig->spksId ) + { + if ((0x0u != RelayData.pRelaySpksStr[i].colRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].colRelayId)) + { + pSpksDataConfig->colRelayId = RelayData.pRelaySpksStr[i].colRelayId; +#if 0 + pSpksDataConfig->belongCiId = GetBelongCiByRelayId(pSpksDataConfig->colRelayId); +#endif + } + else + { + /*޲*/ + } + if ((0x0u != RelayData.pRelaySpksStr[i].disRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].disRelayId)) + { + pSpksDataConfig->displayRelayId = RelayData.pRelaySpksStr[i].disRelayId; + } + else + { + /*޲*/ + } + if ((0x0u != RelayData.pRelaySpksStr[i].cutRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].cutRelayId)) + { + pSpksDataConfig->cutRelayId = RelayData.pRelaySpksStr[i].cutRelayId; + } + else + { + /*޲*/ + } + if ((0x0u != RelayData.pRelaySpksStr[i].repRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].repRelayId)) + { + pSpksDataConfig->repRelayId = RelayData.pRelaySpksStr[i].repRelayId;/*Ӽ̵ֵ*/ + } + else + { + /*޲*/ + } + if ((0x0u != RelayData.pRelaySpksStr[i].cutDisRelayId) && (0xffffu != RelayData.pRelaySpksStr[i].cutDisRelayId)) + { + pSpksDataConfig->cutDisplayRelayId = RelayData.pRelaySpksStr[i].cutDisRelayId;/*spks·ָʾƼ̵ֵ*/ + } + else + { + /*޲*/ + } + if ((0x0U != RelayData.pRelaySpksStr[i].outsideRelayId) && (0xffffU != RelayData.pRelaySpksStr[i].outsideRelayId)) + { + pSpksDataConfig->outsideRelayId = RelayData.pRelaySpksStr[i].outsideRelayId;/*spksָʾ*/ + } + else + { + /*޲*/ + } + + pSpksDataConfig->VirtualAttribute = SPKS_VIRTUAL_ATTR_NO;/*̵вҵΪSPKSΪ*/ + if (0u == pSpksDataConfig->colRelayId) + { + debug_infor_printf((const)"Spks %d COLLJ %d not config.",pSpksDataConfig->spksId,pSpksDataConfig->colRelayId); + DebugPrintAppError(ERROR_SPKS_COLLJ_NOT_CONFIG,CI_DEVICE_TYPE_SPKS,pSpksDataConfig->spksId,PRINT_ONCE); + } + else + { + + for (k=0u;kcolRelayId) + { + if (RelayData.pRelayCfgDtStr[k].CollMode != RELAY_COLL_MODE_DOUBLE) + { + debug_infor_printf((const)"Spks %d COLLJ %d not double coll-mode.",pSpksDataConfig->spksId,pSpksDataConfig->colRelayId); + DebugPrintAppError(ERROR_SPKS_COLLJ_NOT_DOUBLE_COLL,CI_DEVICE_TYPE_SPKS,((UINT32)pSpksDataConfig->spksId<<16u)+pSpksDataConfig->colRelayId,PRINT_ONCE); + } + else + { + } + break; + } + else + { + } + + } + + + } + pSpksDataConfig->VirtualAttribute = SPKS_VIRTUAL_ATTR_NO;/*̵вҵΪSPKSΪ*/ + break; + } + else + { + } + } + + rtnvalue = 1u; + } + else + { + rtnvalue = 0u; + } + } + else + { + rtnvalue = 0u; + } + return rtnvalue; +} + +/********************************************* +*ܣŽṹŽ̵ID +*˵pSpksDSUźŻݽṹָ +pSpksDataConfigźŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReadMJConfigDataFromDquData( MJDataConfigStruct* pMJDataConfig) +{ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 wSpksCount = 0u;/*ŽSPKS*/ + UINT8 rtnvalue = 0u; + /*ڲ*/ + if (pMJDataConfig != NULL) + { + rtnvalue = 1u; + + /*Ž*/ + for (i = 0u; i < RelayDataLen.RelayMJStrLen; i++) + { + if (i >= MJ_SUM_MAX) + { + rtnvalue = 0u; + break; + } + else + { + /*ֵʼǰȫΪ0*/ + pMJDataConfig[i].mjId = 0u; + pMJDataConfig[i].mjjsRelayId = 0u; + pMJDataConfig[i].relSpkscount = 0u; + wSpksCount = 0u; /*SPKSգۼ*/ + (void)CommonMemSet(pMJDataConfig[i].relSpksIdBuff, (UINT32)(sizeof(pMJDataConfig[i].relSpksIdBuff) / sizeof(UINT8)), 0, (UINT32)(sizeof(pMJDataConfig[i].relSpksIdBuff) / sizeof(UINT8))); + + if (0u != RelayData.pMjStr[i].mjid) + { + pMJDataConfig[i].mjId = RelayData.pMjStr[i].mjid; + + if ((0x0u != RelayData.pMjStr[i].mjjsRelayId) && (0xffffu != RelayData.pMjStr[i].mjjsRelayId)) + { + pMJDataConfig[i].mjjsRelayId = RelayData.pMjStr[i].mjjsRelayId; + pMJDataConfig[i].belongCiId = (UINT8)GetCiIdByOcId(RelayData.pMjStr[i].ocId); + } + else + { + /*Ž̵ȡΪ0*/ + debug_infor_printf((const)"MJ %d COLLJ %d not config.", pMJDataConfig[i].mjId, pMJDataConfig[i].mjjsRelayId); + } + + for (j = 0; j < MJ_MAX_SPKSNUM; j++) + { + + /*ѭȡŽSPKSID*/ + if (0u != RelayData.pMjStr[i].spksId[j]) + { + pMJDataConfig[i].relSpksIdBuff[j] = RelayData.pMjStr[i].spksId[j]; + wSpksCount++; + } + else + { + /*SPKSIDΪ0ȡ*/ + break; + } + } + pMJDataConfig[i].relSpkscount = wSpksCount; + + } + else + { + /*Ž̵ȡΪ0*/ + rtnvalue = 0u; + break; + } + } + } + } + else + { + rtnvalue = 0u; + } + return rtnvalue; +} + +/********************************************* +*ܣʼŽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 FloodGateConfigDataStructInit(CHAR * FSName) +{ + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i = 0u; + + callFun = dfsEmapInit (FSName); + callFun *= InitRelay_FloodGateStru (FSName); /*ʼ̵-ű*/ + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.FloodGateCfgDtStrLen =dsuDataLenStru.wFloodGateLen; + + + + for(i=0u;i= FLOOD_GATE_SUM_MAX) + { + rtnvalue = 0u; + break; + } + + rtnvalue = FloodGateCfgDtStruFrmLSStr(dsuStaticHeadStru.pFloodGateStru + i, &dquCICfgDtStr.FloodGateCfgDtStr[i]); + if (0u == rtnvalue) + { + break; + } + + } + } + + return rtnvalue; +} + + + +/* +*ܣϢϷԼ +*˵pSpksDSU豸Ϣݽṹָ +*ֵCI_ERRORʧܣCI_SUCESSɹ +*/ +UINT8 CheckInputOtherCiDevInfoValid(const LS_OtherCiDevInfoStruct *pOtherCiDevInfo) +{ + UINT8 ret = CI_ERROR; + + if (pOtherCiDevInfo != NULL) + { + if ((UINT8_MAX == pOtherCiDevInfo->wDevStatus) + || (0u == pOtherCiDevInfo->wDevStatus) + || (UINT16_MAX == pOtherCiDevInfo->wId) + || (0u == pOtherCiDevInfo->wId) + || (UINT16_MAX == pOtherCiDevInfo->wDevType) + || (0u == pOtherCiDevInfo->wDevType)) + { + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + } + } + + return ret; +} + +/* +*ܣݼ̵Id +*˵ݼ̵IDָ +*ֵ0 ʧܣ>0 ɹ +* ̵ݶȡ +*/ +UINT8 GetBelongCiByRelayId(UINT16 relayId ) +{ + UINT8 ciId = 0u; + UINT16 ii = 0u; + + if ((RelayDataLen.RelayCfgDtStrLen > 0u) && (RelayData.pRelayCfgDtStr != NULL)) + { + for (ii =0u;iisrcCiId; + cLocalWorkType = GetLocalRcWorkMode(); + /* */ + if ((tmpLocalCiId < CI_SUM_MAX) && (tmpLocalCiId > 0u) + && ((RC_WORK_MODE_TIOC == cLocalWorkType) || ((RC_WORK_MODE_CI == cLocalWorkType) && (CI_DEVICE_TYPE_CUTOFF_POINT != pDquCiTransmitStr->devType)))) + { + /* ĿIDǷѾӹ */ + for(ii = 0u; iidstCiId) + { + /* ҵ˳ */ + break; + } + } + /* ûӣһ */ + if (ii>= dquCICfgDtStr.CiTransmitStrLen[tmpLocalCiId]) + { + dquCICfgDtStr.CiTransmitStrLen[tmpLocalCiId]++; + } + pTmpCiTransConfig = &dquCICfgDtStr.CiTransmitStru[tmpLocalCiId][ii]; + pTmpCiTransConfig->destCiId = pDquCiTransmitStr->dstCiId; + pTmpCiTransConfig->srcCiId = pDquCiTransmitStr->srcCiId; + + switch (pDquCiTransmitStr->devType) + { + case CI_DEVICE_TYPE_SWITCH: /* */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < SWITCH_SUM_MAX)) + { + pTmpCiTransConfig->switchIdBuf[pTmpCiTransConfig->switchNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->switchNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_SIGNAL: /* źŻ */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < SIGNAL_SUM_MAX)) + { + pTmpCiTransConfig->signalIdBuf[pTmpCiTransConfig->signalNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->signalNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_PHYSEC: /* */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < PHYSICAL_SECTION_SUM_MAX)) + { + pTmpCiTransConfig->phySecIdBuf[pTmpCiTransConfig->phySecNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->phySecIdLockDirFlag[pTmpCiTransConfig->phySecNum] = pDquCiTransmitStr->phyLockDirOppOrNot;/*շǷȡ־*/ + pTmpCiTransConfig->phySecNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_LOGICSEC: /* ߼ */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < LOGIC_SECTION_SUM_MAX)) + { + pTmpCiTransConfig->logicSecIdBuf[pTmpCiTransConfig->logicSecNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->logicSecNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_ESB: /* ESB */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < ESB_SUM_MAX)) + { + pTmpCiTransConfig->esbIdBuf[pTmpCiTransConfig->esbNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->esbNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_PSD: /* PSD */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < PSD_SUM_MAX)) + { + pTmpCiTransConfig->psdIdBuf[pTmpCiTransConfig->psdNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->psdNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_ROUTE: /* · */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < ROUTE_SUM_MAX)) + { + pTmpCiTransConfig->routeIdBuf[pTmpCiTransConfig->routeNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->routeNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_OVERLAP: /* */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < OVERLAP_SUM_MAX)) + { + pTmpCiTransConfig->overlapIdBuf[pTmpCiTransConfig->overlapNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->overlapNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_SPKS: /* SPKS */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < SPKS_SUM_MAX)) + { + pTmpCiTransConfig->spksIdBuff[pTmpCiTransConfig->spksNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->spksNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_FLOODGATE:/**/ + { + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < FLOOD_GATE_SUM_MAX)) + { + pTmpCiTransConfig->floodGateIdBuf[pTmpCiTransConfig->floodGateNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->floodGateNum++; + rtnValue = 1u; + } + } + break; + case CI_DEVICE_TYPE_RELAY: /* ղ̵ */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < RELAY_SUM_MAX)) + { + pTmpCiTransConfig->zcjIdBuf[pTmpCiTransConfig->zcjNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->zcjNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_CUTOFF_POINT: /* ֽ */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < RELAY_SUM_MAX)) + { + pTmpCiTransConfig->wCutoffPointBuf[pTmpCiTransConfig->wCutoffPointNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->wCutoffPointNum++; + rtnValue = 1u; + } + break; + case CI_DEVICE_TYPE_AUTOROUTE:/* cgh-ϲCID-2539-7Զͨ */ + if ((pDquCiTransmitStr->devId > 0u) && (pDquCiTransmitStr->devId < AUTO_ROUTE_SUM_MAX) && + (pTmpCiTransConfig->autoRouteNum < AUTO_ROUTE_SUM_MAX)) + { + pTmpCiTransConfig->autoRouteIdBuf[pTmpCiTransConfig->autoRouteNum] = pDquCiTransmitStr->devId; + pTmpCiTransConfig->autoRouteNum++; + rtnValue = 1u; + } + break; + default: + rtnValue = 0u; + break; + } + } + else if ((RC_WORK_MODE_CI == cLocalWorkType) && (CI_DEVICE_TYPE_CUTOFF_POINT == pDquCiTransmitStr->devType)) + { + rtnValue = 1u; /*CIģʽֽ㣬1*/ + } + else + { + rtnValue = 0u; + } + } + else + { + rtnValue = 0u; + } + return rtnValue; +} + +/* +: ·豸DquCfg·豸 +: DquDiffLineDevStruct *pDquDiffLineDevData ·豸 +: DiffLineDevStruct *pDiffLineDevData DquCfg·豸ָ +ֵ: 0 ʧ + 1 ɹ +*/ +UINT8 ReadDquDiffLineDevDataToConfig(DquDiffLineDevStruct *pDquDiffLineDevData, DiffLineDevStruct *pDiffLineDevData) +{ + UINT8 retVal = 0u; + + if ((NULL != pDquDiffLineDevData) && (NULL != pDiffLineDevData)) + { + switch (pDquDiffLineDevData->devType) + { + case CI_DEVICE_TYPE_SWITCH: /* */ + if ((0u < pDquDiffLineDevData->devId) && (SWITCH_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_SWITCH_SUM_MAX > pDiffLineDevData->switchNum)) + { + pDiffLineDevData->switchIdBuf[pDiffLineDevData->switchNum] = pDquDiffLineDevData->devId; + pDiffLineDevData->switchNum++; + pDiffLineDevData->diffLineDevSum++; + retVal = 1u; + } + break; + case CI_DEVICE_TYPE_SIGNAL: /* źŻ */ + if ((0u < pDquDiffLineDevData->devId) && (SIGNAL_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_SIGNAL_MAX > pDiffLineDevData->signalNum)) + { + pDiffLineDevData->signalIdBuf[pDiffLineDevData->signalNum] = pDquDiffLineDevData->devId; + pDiffLineDevData->signalNum++; + pDiffLineDevData->diffLineDevSum++; + retVal = 1u; + } + break; + case CI_DEVICE_TYPE_ESB: /* ESB */ + if ((0u < pDquDiffLineDevData->devId) && (ESB_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_ESB_SUM_MAX > pDiffLineDevData->esbNum)) + { + pDiffLineDevData->esbIdBuf[pDiffLineDevData->esbNum] = pDquDiffLineDevData->devId; + pDiffLineDevData->esbNum++; + pDiffLineDevData->diffLineDevSum++; + retVal = 1u; + } + break; + case CI_DEVICE_TYPE_PSD: /* PSD */ + if ((0u < pDquDiffLineDevData->devId) && (PSD_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_PSD_SUM_MAX > pDiffLineDevData->psdNum)) + { + pDiffLineDevData->psdIdBuf[pDiffLineDevData->psdNum] = pDquDiffLineDevData->devId; + pDiffLineDevData->psdNum++; + pDiffLineDevData->diffLineDevSum++; + retVal = 1u; + } + break; + case CI_DEVICE_TYPE_SPKS: /* SPKS */ + if ((0u < pDquDiffLineDevData->devId) && (SPKS_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_SPKS_SUM_MAX > pDiffLineDevData->spksNum)) + { + pDiffLineDevData->spksIdBuff[pDiffLineDevData->spksNum] = pDquDiffLineDevData->devId; + pDiffLineDevData->spksNum++; + pDiffLineDevData->diffLineDevSum++; + retVal = 1u; + } + break; + case CI_DEVICE_TYPE_AXISSEC: /**/ + if ((0u < pDquDiffLineDevData->devId) && (AXIS_SECTION_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_AXIS_SECT_SUM_MAX > pDiffLineDevData->axisSectNum)) + { + pDiffLineDevData->axisSectIdBuff[pDiffLineDevData->axisSectNum] = pDquDiffLineDevData->devId; + pDiffLineDevData->axisSectNum++; + pDiffLineDevData->diffLineDevSum++; + retVal = 1u; + } + break; + case CI_DEVICE_TYPE_PHYSEC: /**/ + if ((0u < pDquDiffLineDevData->devId) && (PHYSICAL_SECTION_SUM_MAX > pDquDiffLineDevData->devId) && (DIFF_LINE_PHYS_SECT_SUM_MAX > pDiffLineDevData->physSectNum)) + { + pDiffLineDevData->physSectIdBuff[pDiffLineDevData->physSectNum] = pDquDiffLineDevData->devId; + pDiffLineDevData->physSectNum++; + pDiffLineDevData->diffLineDevSum++; + retVal = 1u; + } + break; + default: + retVal = 0u; + break; + } + + } + else + { + retVal = 0u; + } + + return retVal; +} + +/********************************************* +*ܣʼվźŻ߼ݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OutStationSigRelLogSecStruInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8 funcRtn = 0u; + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + UINT16 ii = 0u; + DquOutStationSigStruct * pDquOutStationSigInfoStr = NULL; + + /*ȡվźŻ߼εϵͳ*/ + funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_OUTSIG_RALATE_LOG_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + /*ø*/ + if(DataSize % CI_SYSTEM_OUTSIG_RALATE_LOG_LEN != 0u) + { + rtnValue = 0u; + debug_infor_printf((const)"\nCI_CONFIG_DATA,BLOC_TSR_LOGIC,len %d not equal to fs",CI_SYSTEM_OUTSIG_RALATE_LOG_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_OUTSIG_RALATE_LOG_ID,PRINT_ONCE); + } + else + { + dquOutStationSigStrLen = (UINT16)(DataSize / CI_SYSTEM_OUTSIG_RALATE_LOG_LEN); + pDquOutStationSigStr = (DquOutStationSigStruct *)MyNew((UINT32)(dquOutStationSigStrLen * sizeof(DquOutStationSigStruct))); + if(NULL == pDquOutStationSigStr) + { + dquOutStationSigStrLen = 0u; + rtnValue = 0u; + } + else + { + for (ii = 0u;ii < dquOutStationSigStrLen;ii++) + { + pDquOutStationSigInfoStr = pDquOutStationSigStr + ii; + (void)PZDquOutStationSigReltLogSec(pDataAddr,pDquOutStationSigInfoStr); + pDataAddr += CI_SYSTEM_OUTSIG_RALATE_LOG_LEN; + } + rtnValue = 1u; + } + } + } + + return rtnValue; +} + +/********************************************* +*ܣʼܿݽṹ +*˵FSNameļָ +*ֵ +*********************************************/ +void CiFunctionSwitchStructInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8 funcRtn = 0u; + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 ii = 0u; + DquCiFuncSwitchStructNew * pTempDquCiFuncSwitchStru = NULL; + + /*ȡܿñ*/ + funcRtn = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_FUNC_SWITCH_ID, &pDataAddr, &DataSize); + if((0u == funcRtn) || (0u == DataSize)) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + /*ø*/ + if(0u != (DataSize % CI_SYSTEM_CI_FUNC_SWITCH_LEN)) + { + rtnValue = 0u; + debug_infor_printf((const)"\nCI_CONFIG_DATA,CI_FUNC_SWITCH,len %d not equal to fs",CI_SYSTEM_CI_FUNC_SWITCH_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_CI_FUNC_SWITCH_ID,PRINT_ONCE); + } + else + { + dquCiFuncSwitchStruLen = (UINT16)(DataSize / CI_SYSTEM_CI_FUNC_SWITCH_LEN); + pDquCiFuncSwitchStru = (DquCiFuncSwitchStructNew *)MyNew((UINT32)(dquCiFuncSwitchStruLen * sizeof(DquCiFuncSwitchStructNew))); + + if(NULL == pDquCiFuncSwitchStru) + { + dquCiFuncSwitchStruLen = 0u; + rtnValue = 0u; + } + else + { + rtnValue = 1u; + + for (ii = 0u; ii < dquCiFuncSwitchStruLen; ii++) + { + pTempDquCiFuncSwitchStru = pDquCiFuncSwitchStru + ii; + + rtnValue = PZDquCiFunctionSwitchInfo(pDataAddr, pTempDquCiFuncSwitchStru); + pDataAddr += CI_SYSTEM_CI_FUNC_SWITCH_LEN; + + if (0u == rtnValue) + { + break; + } + } + } + } + } + +} + +/********************************************* +*ܣʼǰ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 CiPatternInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8 funcRtn = 0u; + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 ii = 0u; + UINT16 len = 0u; + UINT16 val = 0u; + UINT8 findFlag = 0u; + UINT8 chLocalCiId = GetSystemParaLocalCiId(); + + /*ȡñ*/ + funcRtn = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_PATTERN_ID, &pDataAddr, &DataSize); + if (funcRtn == 0u) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + /*ø*/ + if ((DataSize % CI_SYSTEM_CI_PATTERN_LEN) != 0u) + { + rtnValue = 0u; + } + else + { + len = (UINT16)(DataSize / CI_SYSTEM_CI_PATTERN_LEN); + rtnValue = 1u; + for (ii = 0u; ii < len; ii++) + { + if (*pDataAddr == chLocalCiId) + { + rtnValue = SetLocalCiPattern(*(pDataAddr + 1)); + + if (1u == rtnValue) + { + rtnValue = SetLocalCiDistributedIO(pDataAddr[2]); + } + + if (1u == rtnValue) + { + val = dquCiShortFromChar(&pDataAddr[3]); + SetLocalCiUTProtSecUnlockTime(val); + + val = dquCiShortFromChar(&pDataAddr[5]); + SetLocalCiCTProtSecUnlockTime(val); + + val = dquCiShortFromChar(&pDataAddr[7]); + SetLocalCiUTNearUnLockTime(val); + + val = dquCiShortFromChar(&pDataAddr[9]); + SetLocalCiCTNearUnLockTime(val); + + SetLocalWaysidePattern(pDataAddr[11]); + rtnValue = SetLocalRcWorkMode(pDataAddr[12]); + + } + findFlag = 1u; + } + else + { + if (1U == rtnValue) + { + /*ʼ*/ + rtnValue = SetOtherCiPara(pDataAddr); + } + else + { + /*ʼ*/ + } + + } + if (0U == rtnValue) + { + break; + } + else + { + pDataAddr += CI_SYSTEM_CI_PATTERN_LEN; + } + } + + if (0u == findFlag) + { + rtnValue = 0u;/*δҵʼʧ*/ + } + } + } + + return rtnValue; +} + +/********************************************* +*ܣʼݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InvSecNdConSwiConfDataStruInit(CHAR* FSName) +{ + UINT8 funcRetVal = 0u; + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 condSwitDataSum = 0u; + + funcRetVal = dfsEmapInit(FSName); + + if(0u != funcRetVal) + {/*ӵͼʼɹִ*/ + dquCICfgDtStr.InvSecCfgDtStrLen = LSDataLen.LSIntruPhySecStrLen; + + /*ݵ νṹ */ + for(i = 0u; i < LSDataLen.LSIntruPhySecStrLen; i++) + { + if (i >= INVA_SECT_N_COND_SWIT_SUM_MAX)/*±ڵֵʼʧ*/ + { + funcRetVal = 0u; + break; + } + dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].InvSecAndConSwiId = LSData.pLSIntruPhySecStr[i].wId; + dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].InvaSectId = LSData.pLSIntruPhySecStr[i].wIntrudePhySecId; + dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitDataSum = 0u; + + condSwitDataSum = 0u; + + for (j = 0u; j < QINXIAN_SWITCH_MAX_NUM; j++) + { + if ((0x0000U != LSData.pLSIntruPhySecStr[i].wPointId[j]) && (UINT16_MAX != LSData.pLSIntruPhySecStr[i].wPointId[j]) + && (0x0000U != LSData.pLSIntruPhySecStr[i].wPointSta[j]) && (UINT16_MAX != LSData.pLSIntruPhySecStr[i].wPointSta[j])) + { + dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitDataBuff[condSwitDataSum].CondSwitId = LSData.pLSIntruPhySecStr[i].wPointId[j]; + + if ((1u == LSData.pLSIntruPhySecStr[i].wPointSta[j]) || (2u == LSData.pLSIntruPhySecStr[i].wPointSta[j])) + {/*λ*/ + dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitDataBuff[condSwitDataSum].CondSwitStat = LSData.pLSIntruPhySecStr[i].wPointSta[j]; + } + else + { + funcRetVal = 0u; + break; + } + condSwitDataSum++; + + } + } + if (0u == funcRetVal) + { + break; + } + dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitDataSum = condSwitDataSum; + dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].CondSwitLockDir = LSData.pLSIntruPhySecStr[i].wCondSwitLockDir; + } + + } + else + {/*ӵͼʼʧܣʧ˳*/ + dquCICfgDtStr.InvSecCfgDtStrLen = 0u; + } + + return funcRetVal; +} + + +/********************************************* +*ܣźŻǷ״̬ +*˵pSgnlCfgDtStrźŻݽṹָ +*ֵ: +*********************************************/ +void SetSignalDrvEnable(SignalConfigDataStruct* pSgnlCfgDtStr) +{ + UINT8 LxDrvEnableFlg = 0u; + UINT8 ZxDrvEnableFlg = 0u; + UINT8 YxDrvEnableFlg = 0u; + UINT8 DdDrvEnableFlg = 0u; + UINT8 DxDrvEnableFlg = 0u; + + if(pSgnlCfgDtStr != NULL) + { + LxDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->LxRelayId); + ZxDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->ZxRelayId); + YxDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->YxRelayId); + DdDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->DdRelayId); + DxDrvEnableFlg = GetRelayDrvEnableByRelayId(pSgnlCfgDtStr->DxRelayId); + if ((SIGNAL_DRV_ENABLE == LxDrvEnableFlg)||(SIGNAL_DRV_ENABLE == ZxDrvEnableFlg)|| + (SIGNAL_DRV_ENABLE == YxDrvEnableFlg)||(SIGNAL_DRV_ENABLE == DdDrvEnableFlg)|| + (SIGNAL_DRV_ENABLE == DxDrvEnableFlg)) + { + pSgnlCfgDtStr->driveEnable = SIGNAL_DRV_ENABLE; + } + else + { + pSgnlCfgDtStr->driveEnable = SIGNAL_DRV_DISABLE; + } + } +} + +/* +*ܣݼ̵Id жǷ +*˵̵ID +*ֵSIGNAL_DRV_ENABLE SIGNAL_DRV_DISABLE +* ̵ݶȡ +* ⣺δøü̵Ϊ +*/ +UINT8 GetRelayDrvEnableByRelayId(UINT16 relayId ) +{ + UINT8 enableFlg = SIGNAL_DRV_DISABLE; + UINT16 ii = 0u; + /* ̵δãΪ0Ϊü̵ */ + if ((RelayDataLen.RelayCfgDtStrLen > 0u) && (RelayData.pRelayCfgDtStr != NULL)) + { + for (ii =0u;iiwAttribute; + if ((0x8000u & sigAttrEmap) == 0x8000u) + { + pSgnlCfgDtStr->signalVirtualAttr = SIGNAL_VIRTUAL_YES; + } + else + { + pSgnlCfgDtStr->signalVirtualAttr = SIGNAL_VIRTUAL_NO; + } + + } + return ret; +} + +/********************************************* +*ܣʼ豸ݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 VirtualDeviceInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8 funcRtn = 0u; + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + UINT16 ii = 0u; + DquVirtualDeviceStruct * pDquVirtualDeviceInfoStr = NULL; + + /*ȡ豸ϵͳ*/ + funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_VIRTUAL_DEV_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + /*ø*/ + if(0u != (DataSize % CI_SYSTEM_CI_VIRTUAL_DEV_LEN)) + { + debug_infor_printf((const)"\nCI_CONFIG_DATA,VIRTUAL_DEVICE,len %d not equal to fs",CI_SYSTEM_CI_VIRTUAL_DEV_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<8u)+CI_SYSTEM_CI_VIRTUAL_DEV_ID,PRINT_ONCE); + rtnValue = 0u; + } + else + { + dquVirtualDeviceStrLen = (UINT16)(DataSize / CI_SYSTEM_CI_VIRTUAL_DEV_LEN); + pDquVirtualDeviceStr = (DquVirtualDeviceStruct *)MyNew((UINT32)(dquVirtualDeviceStrLen * sizeof(DquVirtualDeviceStruct))); + if(NULL == pDquVirtualDeviceStr) + { + dquVirtualDeviceStrLen = 0u; + rtnValue = 0u; + } + else + { + rtnValue = 1u; + for (ii = 0u;ii < dquVirtualDeviceStrLen;ii++) + { + pDquVirtualDeviceInfoStr = pDquVirtualDeviceStr + ii; + rtnValue &=PZDquVirtualDeviceInfoFromChar(pDataAddr,pDquVirtualDeviceInfoStr); + pDataAddr += CI_SYSTEM_CI_VIRTUAL_DEV_LEN; + } + } + } + } + + return rtnValue; +} + +/********************************************* +*ܣʼվźŻļݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OutStationSigRelAxisSecStruInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8 funcRtn = 0u; + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + UINT16 ii = 0u; + DquOutStationSigStruct * pDquOutStationSigInfoStr = NULL; + + /*ȡվźŻεϵͳ*/ + funcRtn = dquGetConfigData(FSName,CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_OUTSIG_RALATE_AXIS_ID,&pDataAddr,&DataSize); + if(funcRtn == 0u) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + /*ø*/ + if(DataSize % CI_SYSTEM_OUTSIG_RALATE_AXIS_LEN != 0u) + { + rtnValue = 0u; + } + else + { + dquOutStationSigStrLen = (UINT16)(DataSize / CI_SYSTEM_OUTSIG_RALATE_AXIS_LEN); + pDquOutStationSigStr = (DquOutStationSigStruct *)MyNew((UINT32)(dquOutStationSigStrLen * sizeof(DquOutStationSigStruct))); + if(NULL == pDquOutStationSigStr) + { + dquOutStationSigStrLen = 0u; + rtnValue = 0u; + } + else + { + rtnValue = 1u; + for (ii = 0u;ii < dquOutStationSigStrLen;ii++) + { + pDquOutStationSigInfoStr = pDquOutStationSigStr + ii; + rtnValue &= PZDquOutStationSigAxisSecInfo(pDataAddr,pDquOutStationSigInfoStr); + pDataAddr += CI_SYSTEM_OUTSIG_RALATE_AXIS_LEN; + + /*źŻʽʱټתΪ߼*/ + rtnValue &= sigRelatedAxisSecToLogSecTrans(pDquOutStationSigInfoStr); + } + } + } + } + + return rtnValue; +} + +/********************************************* +*ܣӵʽʱݣΣʽʱýṹ(߼)ת +*˵pDquOutStationSigStrRef ʽʱݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +static UINT8 sigRelatedAxisSecToLogSecTrans(DquOutStationSigStruct * pDquOutStationSigStrRef) +{ + UINT16 i = 0u; /*ѭ*/ + UINT16 j = 0u; /*ѭ*/ + UINT16 k = 0u; /*ѭ*/ + UINT16 logSecCnt = 0u; /*߼μֵ*/ + UINT16 axisSecLogSecNum = 0u; /*ΰ߼Ŀ*/ + UINT16 axisSecLogsecIdBuf[200] = {0u}; /*ΰ߼IDBuf*/ + UINT16 axisSecId = 0u; /*ID*/ + UINT16 relatedAxisSecSum = 0u; /*źŻļĿ*/ + UINT16 logSecIdBufIdx = 0u; /*߼±*/ + UINT8 retVal = 1u; /*ֵ*/ + + DSU_AXLE_SGMT_STRU * pQueryAxleSgmtStru = NULL;/*Ϣṹָ*/ + + if(NULL == pDquOutStationSigStrRef) + {/*Чж*/ + retVal = 0u; + } + else + { + relatedAxisSecSum = pDquOutStationSigStrRef->wRelatedAxisSecSum; /*źŻʽʱټĿ*/ + + if(relatedAxisSecSum > 0u) + { + for(i = 0u; i < relatedAxisSecSum;i++) + {/*źŻʽʱټתΪ߼*/ + axisSecId = pDquOutStationSigStrRef->wRelatedAxisSecIdBuf[i]; + + if ((0u != axisSecId) && (UINT16_MAX != axisSecId)) + { + for(j = 0u; j < dsuDataLenStru.wAxleSgmtLen; j++) + {/*ӵͼαĿ*/ + pQueryAxleSgmtStru = dsuStaticHeadStru.pAxleSgmtStru + j; + if(pQueryAxleSgmtStru->wId == axisSecId) + { + axisSecLogSecNum = pQueryAxleSgmtStru->wIncludeLogicSgmtNum; + for(k = 0u; k < axisSecLogSecNum; k ++) + { + axisSecLogsecIdBuf[logSecIdBufIdx] = pQueryAxleSgmtStru->wLogicSgmtId[k]; + logSecIdBufIdx++; + } + + logSecCnt = logSecCnt + axisSecLogSecNum; /*߼Ŀۼ*/ + } + } + } + } + + pDquOutStationSigStrRef->wRalatedLogSecSum = logSecCnt; /*ֵ߼Ŀ*/ + + (void)memcpy(pDquOutStationSigStrRef->wRalatedLogSecIdBuf,axisSecLogsecIdBuf,(logSecIdBufIdx+1U)*2U); /*ֵ߼IDBuf, (logSecIdBufIdx+1)*2ԪΪ16*/ + + } + } + + return retVal; +} + +/********************************************* +*ܣݵӵͼźŻźŻѹص +*˵pSgnlDSUźŻݽṹָ +* pSgnlCfgDtStrźŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SetSignalCrossCloseAttr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr) +{ + UINT8 ret = CI_SUCCESS; + UINT16 sigAttrEmap = 0u;/*ӵͼźŻ*/ + + /*ڲ*/ + if((NULL == pSgnl) || (NULL == pSgnlCfgDtStr)) + { + /*ʧ*/ + ret = CI_ERROR; + } + if (CI_SUCCESS == ret) + { + sigAttrEmap = pSgnl->wAttribute; + if ((0x0040u & sigAttrEmap) == 0x0040u) + { + pSgnlCfgDtStr->signalCrossCloseAttr = SIGNAL_CROSS_ClOSE_YES; + } + else + { + pSgnlCfgDtStr->signalCrossCloseAttr = SIGNAL_CROSS_ClOSE_NO; + } + + } + return ret; +} + + +/********************************************* +*ܣʼιղ̵ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayPhySecFaultLockZCStruInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8 funcRtn = 0u; + RelayConfigDataStruct* pRlyDfgDtStr = NULL; + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 j = 0u; + UINT16 ii =0u;/*α*/ + UINT16 kk = 0u; + + UINT16 zhaoChaJDQNum = 0u;/*ղ̵*/ + UINT16 relayId =0u; + UINT16 pPhyBuf[1][MAX_LOCK_EXCEPT_SECTION_NUM] = {{0u}}; + UINT32 excelId = 0u; /*excel id*/ + UINT32 sheetId = 0u; /*sheet id*/ + UINT32 rowLen = 0u; /*г*/ + UINT8 localCiPattern = 0u; /*CIģʽ*/ + + /*Ѿʼˣǵִй*/ + if(NULL != dquCICfgDtStr.RelayCfgDtStr) + { + localCiPattern = GetLocalCiPattern(); + if (CI_PATTERN_TRADITIONAL == localCiPattern) + { + excelId = CI_DATA_TYPE; + sheetId = RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID; + rowLen = LEN_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID; + } + else + { + excelId = OC_DATA_TYPE; + sheetId = OC_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID; + rowLen = OC_LEN_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID; + } + + /*ȡ ιղ̵ */ + funcRtn = dquGetConfigData(FSName, excelId, sheetId,&pDataAddr,&DataSize); + if(funcRtn == 0u) + { + /*ʧ*/ + rtnValue = 0u; + } + else + {/*óɹ*/ + rtnValue = 1u; + } + + if (1u == rtnValue) + { + /**/ + if(DataSize% rowLen != 0u) + { + rtnValue = 0u; + debug_infor_printf((const)"\nCI_RELAY_DATA,RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID,len %d not equal to fs", rowLen); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(excelId <<8)+ rowLen,PRINT_ONCE); + } + } + + if (1u == rtnValue) + { + zhaoChaJDQNum = (UINT16)(DataSize/ rowLen); + + dquCICfgDtStr.RelayCfgDtStrLen = RelayDataLen.RelayCfgDtStrLen; + + LockExceptZhaoChaRelayNum = 0u;/*ղ̵*/ + + for (ii =0u;ii= RELAY_SUM_MAX) + { + rtnValue = 0u; + break; + } + + pRlyDfgDtStr = &dquCICfgDtStr.RelayCfgDtStr[j]; + + /*ݽṹ*/ + if (pRlyDfgDtStr->RelayId == relayId) + { + /*¼ղ̵͹ղ̵ID*/ + LockExceptZhaoChaRelayId[LockExceptZhaoChaRelayNum] = relayId; + LockExceptZhaoChaRelayNum++; + + pRlyDfgDtStr->LockExceptPhySecNum = 0u; + for (kk=0u;kkLockExceptPhySecIdBuf[pRlyDfgDtStr->LockExceptPhySecNum] = pPhyBuf[0][kk]; + pRlyDfgDtStr->LockExceptPhySecNum++; + } + + } + + break; + } + + } + } + + + } + + } + + return rtnValue; +} + +/********************************************* +*ܣFSӦ䵽ṹ +*˵pSrc FSݽṹָ룬pDesҪֵĽṹָ룬ArrBuffṹԱָ룬realRowCountʵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OcStruFromChar(const UINT8 *pSrc, UINT8 *pDes, const UINT8 *ArrBuff, const UINT16 realRowCount) +{ + UINT8 rtnValue = 0u; + UINT8 *pTempSrc = NULL; + UINT8 *pTempDes = NULL; + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 len = 0u; + UINT8 num = 0u; + UINT16 totalByteLen = 0u; + + /*η*/ + if ((NULL == pSrc) || (NULL == pDes) || (NULL == ArrBuff)) + { + rtnValue = 0u; + } + else + { + pTempSrc = pSrc; + pTempDes = pDes; + + /*ȡṹԱ*/ + num = ArrBuff[0]; + + if (num < MEMBERA_SUM_MAX) + { + rtnValue = 1u; + + for (i = 1u; i <= num; i++) + { + /*˳ȡṹijһԱij*/ + len = ArrBuff[i]; + /*ͳֽ*/ + totalByteLen = totalByteLen + len; + /*һֽ*/ + if(totalByteLen <= realRowCount) + { + switch (len) + { + /*һֽ*/ + case CHAR_LEN: + /*ṹԱֵ*/ + *pTempDes = *pTempSrc; + pTempDes += CHAR_LEN; + pTempSrc += CHAR_LEN; + break; + /*ֽ*/ + case SHORT_LEN: + for (j = 0u; j < SHORT_LEN; j++) + { + /*ṹԱֵֽ*/ + *(pTempDes + SHORT_LEN - 1u - j) = *(pTempSrc + j); + } + pTempDes += SHORT_LEN; + pTempSrc += SHORT_LEN; + break; + /*ĸֽ*/ + case LONG_LEN: + for (j = 0u; j < LONG_LEN; j++) + { + /*ṹԱֵĸֽ*/ + *(pTempDes + LONG_LEN - 1u - j) = *(pTempSrc + j); + } + pTempDes += LONG_LEN; + pTempSrc += LONG_LEN; + break; + default: + /*ṹԱȴ*/ + rtnValue *= 0u; + break; + } + } + else + { + rtnValue = 0u; + break; + } + + } + } + } + + return rtnValue; +} + +/********************************************* +*ܣȡFSñݣЧ +*˵UINT16* len,FSNameļָ룬DataTypeIDͣConfigId + StrArrLenṹ鳤ȣStrLenṹ峤ȣ + pStrҪݵĽṹָ룬ArrBuffṹԱ +*ֵ0ʧܣ +*********************************************/ +UINT8 OCConfigDataStructInit(UINT16* len, CHAR* FSName, UINT32 DataTypeID, UINT32 ConfigId, UINT16 StrArrLen, void* pStr, UINT8* ArrBuff) +{ + UINT8 rtnValue = 0u; + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 j = 0u; + UINT8* pTemp = NULL; + UINT16 realRowCount = 0u; /*ʵʱݵ*/ + UINT16 realRowLen = 0u; /*ʵʱݵһеij*/ + + if ((NULL != len) && (NULL != FSName) && (NULL != pStr) && (NULL != ArrBuff)) + { + /*ȡ*/ + rtnValue = dquGetConfigDataNew(FSName, DataTypeID, ConfigId,&pDataAddr,&DataSize,&realRowCount); + if (1u == rtnValue) + { + /*ݶȡȷ*/ + if((0u != DataSize) && (0u != realRowCount)) + { + if(0u != (DataSize% realRowCount)) + { + debug_infor_printf((const)"\nOC_CI_CONFIG len %x %d %d not equal to fs", ConfigId,DataSize,realRowCount); + rtnValue = 0u; + } + else + { + /*ȡȣһֽ*/ + *len = realRowCount; + realRowLen = (UINT16)(DataSize / realRowCount); + + if (*len < StrArrLen) + { + /*ݵṹ*/ + for (j = 0u; j < *len; j++) + { + pTemp = (UINT8*)pStr + j * realRowLen; + + /*ݽṹ*/ + rtnValue *= OcStruFromChar(pDataAddr, pTemp, ArrBuff, realRowLen); + + pDataAddr += realRowLen; + } + } + else + { + } + + } + } + else + { + } + } + else + { + } + } + else + { + } + + return rtnValue; +} + +/********************************************* +*ܣʼOC ñ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OCSwitchConfigDataStructInit(CHAR *FSName) +{ + UINT8 rtnValue = 0u; + UINT16 len = 0u; + UINT16 i = 0u; + UINT8 ArrBuff[MEMBERA_SUM_MAX] = { 0u }; + OCSwitchConfigDataStruct OCSwitchCfgStrBuff[SWITCH_SUM_MAX] = { 0u }; + + /*index0ṹԱ˳ṹԱ*/ + ArrBuff[0] = OC_SWITCH_CFG_STR_MEMBER_NUM; + ArrBuff[1] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchId); + ArrBuff[2] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].BelongOcId); + (void)memset(dquCICfgDtStr.OCSwitchCfgStr, 0x00, sizeof(OCSwitchConfigDataStruct) * SWITCH_SUM_MAX); + + rtnValue = OCConfigDataStructInit(&len, FSName, OC_DATA_TYPE, OC_SWITCH_ID, SWITCH_SUM_MAX, \ + (void*)OCSwitchCfgStrBuff, ArrBuff); + + if (1u == rtnValue) + { + /*OCSwitchCfgStr鳤*/ + dquCICfgDtStr.OCSwitchCfgStrLen = len; + for (i = 0u; i < len; i++) + { + if (OCSwitchCfgStrBuff[i].SwitchId < SWITCH_SUM_MAX) + { + dquCICfgDtStr.OCSwitchCfgStr[OCSwitchCfgStrBuff[i].SwitchId] = OCSwitchCfgStrBuff[i]; + } + } + } + + return rtnValue; +} + +/********************************************* +*ܣʼOC ñݡOC2.1.6 +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OCSwitchConfigDataStructInit_OLD(CHAR *FSName) +{ + UINT8 rtnValue = 0u; + UINT16 len = 0u; + UINT16 i = 0u; + UINT8 ArrBuff[MEMBERA_SUM_MAX] = { 0u }; + OCSwitchConfigDataStruct_2 OCSwitchCfgStrBuff[SWITCH_SUM_MAX] = { 0u }; + + /*index0ṹԱ˳ṹԱ*/ + ArrBuff[0] = OC_SWITCH_CFG_STR_MEMBER_NUM_OLD; + ArrBuff[1] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchId); + ArrBuff[2] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].BelongOcId); + ArrBuff[3] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchModuleIdAddrA); + ArrBuff[4] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchMachinePosAddrA); + ArrBuff[5] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchModuleIdAddrB); + ArrBuff[6] = (UINT8)sizeof(OCSwitchCfgStrBuff[0].SwitchMachinePosAddrB); + (void)memset(dquCICfgDtStr.OCSwitchCfgStr, 0x00, sizeof(OCSwitchConfigDataStruct) * SWITCH_SUM_MAX); + + rtnValue = OCConfigDataStructInit(&len, FSName, OC_DATA_TYPE, OC_SWITCH_ID, SWITCH_SUM_MAX, \ + (void*)OCSwitchCfgStrBuff, ArrBuff); + + if (1u == rtnValue) + { + /*OCSwitchCfgStr鳤*/ + dquCICfgDtStr.OCSwitchCfgStrLen = len; + for (i = 0u; i < len; i++) + { + if (OCSwitchCfgStrBuff[i].SwitchId < SWITCH_SUM_MAX) + { + dquCICfgDtStr.OCSwitchCfgStr[OCSwitchCfgStrBuff[i].SwitchId].SwitchId = OCSwitchCfgStrBuff[i].SwitchId; + dquCICfgDtStr.OCSwitchCfgStr[OCSwitchCfgStrBuff[i].SwitchId].BelongOcId = OCSwitchCfgStrBuff[i].BelongOcId; + } + } + } + + return rtnValue; +} + +/********************************************* +*ܣOC źŻ +*˵pDataAddr ݵַpOCSignalCfgStr ocݽṹ壻SwitchIdźŻID +* dataLen ÿֽڳ +*ֵ0ʧܣ1ɹ +*ע +*********************************************/ +void R_OCSignalConfigDataFromChar(UINT8* pDataAddr,UINT16 dataLen) +{ + UINT8* pData = NULL; + UINT16 wSignalIdTemp = 0u; + + if (NULL == pDataAddr) + { + ; /*ڲΪգн*/ + } + else + { + pData = pDataAddr; + wSignalIdTemp = ShortFromChar(pData); + + if (wSignalIdTemp < SIGNAL_SUM_MAX) + { + /*źŻID--2ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].SignalId = wSignalIdTemp; + pData += 2u; + + /*OC--2ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].BelongOcId = ShortFromChar(pData); + pData += 2u; + + /* RCI */ +#if 1 + /*źŻģAϵID--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].SignalModuleIdAddrA = *pData; + pData++; + + /*AϵƵλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].RedPosAddrA = *pData; + pData++; + + /*AϵƵƵλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].YellowPosAddrA = *pData; + pData++; + + /*Aϵ̵Ƶλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].GreenPosAddrA = *pData; + pData++; + + /*Aϵ׵Ƶλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].WhitePosAddrA = *pData; + pData++; + + /*AϵƵλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].BluePosAddrA = *pData; + pData++; + + /*źŻģBϵID--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].SignalModuleIdAddrB = *pData; + pData++; + + /*BϵƵλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].RedPosAddrB = *pData; + pData++; + + /*BϵƵƵλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].YellowPosAddrB = *pData; + pData++; + + /*Bϵ̵Ƶλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].GreenPosAddrB = *pData; + pData++; + + /*Bϵ׵Ƶλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].WhitePosAddrB = *pData; + pData++; + + /*BϵƵλַ--1ֽ*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].BluePosAddrB = *pData; + pData++; + +#endif + + + /*۳ťɼ̵ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainBtnCollRelayId = ShortFromChar(pData); + pData += 2u; + + /*۳ťɼ̵2 ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainBtnCollRelayId_2 = ShortFromChar(pData); + pData += 2u; + + /*۳ťָʾƼ̵ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainBtnIndicatorRelayId = ShortFromChar(pData); + pData += 2u; + + /*۳ťָʾƼ̵2 ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainBtnIndicatorRelayId_2 = ShortFromChar(pData); + pData += 2u; + + /*۳·ť̵ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainCutBtnRelayId = ShortFromChar(pData); + pData += 2u; + + /*۳·ť̵2 ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainCutBtnRelayId_2 = ShortFromChar(pData); + pData += 2u; + + /*۳·ťָʾƼ̵ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainCutBtnIndicatorRelayId = ShortFromChar(pData); + pData += 2u; + + /*۳·ťָʾƼ̵2 ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].DetainCutBtnIndicatorRelayId_2 = ShortFromChar(pData); + pData += 2u; + if (32U < dataLen) + { + /*ȡ۳ťɼ̵1 ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].CancelDetainBtnCollRelayId = ShortFromChar(pData); + pData += 2u; + /*ȡ۳ťɼ̵2 ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].CancelDetainBtnCollRelayId_2 = ShortFromChar(pData); + pData += 2u; + } + else + { + /*ȡ۳ťɼ̵1 ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].CancelDetainBtnCollRelayId = 0U; + /*ȡ۳ťɼ̵2 ID*/ + dquCICfgDtStr.OCSignalCfgStr[wSignalIdTemp].CancelDetainBtnCollRelayId_2 = 0U; + } + } + + } + +} + +/********************************************* +*ܣʼOC źŻñ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*עm by yt ޸ARظ޸ijʼOC_ݱСģñźŻģñģñijʼʽijʼʽһ +*********************************************/ +#if 0 +UINT8 OCSignalCfgStrConfDataStruInit(CHAR *FSName) +{ + UINT8 rtnValue = 0u; + UINT16 len = 0u; + UINT16 i = 0u; + UINT8 ArrBuff[24] = { 0u }; + OCSignalConfigDataStruct OCSignalCfgStrBuff[SIGNAL_SUM_MAX] = { 0u }; + + /*index0ṹԱ˳ṹԱ*/ + ArrBuff[0] = OC_SIGNAL_CFG_STR_MEMBER_NUM; + ArrBuff[1] = sizeof(OCSignalCfgStrBuff[0].SignalId); + ArrBuff[2] = sizeof(OCSignalCfgStrBuff[0].BelongOcId); + ArrBuff[3] = sizeof(OCSignalCfgStrBuff[0].SignalModuleIdAddrA); + ArrBuff[4] = sizeof(OCSignalCfgStrBuff[0].RedPosAddrA); + ArrBuff[5] = sizeof(OCSignalCfgStrBuff[0].YellowPosAddrA); + ArrBuff[6] = sizeof(OCSignalCfgStrBuff[0].GreenPosAddrA); + ArrBuff[7] = sizeof(OCSignalCfgStrBuff[0].WhitePosAddrA); + ArrBuff[8] = sizeof(OCSignalCfgStrBuff[0].BluePosAddrA); + ArrBuff[9] = sizeof(OCSignalCfgStrBuff[0].SignalModuleIdAddrB); + ArrBuff[10] = sizeof(OCSignalCfgStrBuff[0].RedPosAddrB); + ArrBuff[11] = sizeof(OCSignalCfgStrBuff[0].YellowPosAddrB); + ArrBuff[12] = sizeof(OCSignalCfgStrBuff[0].GreenPosAddrB); + ArrBuff[13] = sizeof(OCSignalCfgStrBuff[0].WhitePosAddrB); + ArrBuff[14] = sizeof(OCSignalCfgStrBuff[0].BluePosAddrB); + ArrBuff[15] = sizeof(OCSignalCfgStrBuff[0].DetainBtnCollRelayId); + ArrBuff[16] = sizeof(OCSignalCfgStrBuff[0].DetainBtnIndicatorRelayId); + ArrBuff[17] = sizeof(OCSignalCfgStrBuff[0].DetainCutBtnRelayId); + ArrBuff[18] = sizeof(OCSignalCfgStrBuff[0].DetainCutBtnIndicatorRelayId); + + (void)memset(dquCICfgDtStr.OCSignalCfgStr, 0x00, sizeof(OCSignalConfigDataStruct) * SIGNAL_SUM_MAX); + + rtnValue = OCConfigDataStructInit(&len, FSName, OC_DATA_TYPE, OC_SIGNAL_ID, SIGNAL_SUM_MAX, \ + (void*)OCSignalCfgStrBuff, ArrBuff); + + if (1u == rtnValue) + { + /*OCSignalCfgStr鳤*/ + dquCICfgDtStr.OCSignalCfgStrLen = len; + for (i = 0u; i < len; i++) + { + if (OCSignalCfgStrBuff[i].SignalId < SIGNAL_SUM_MAX) + { + dquCICfgDtStr.OCSignalCfgStr[OCSignalCfgStrBuff[i].SignalId] = OCSignalCfgStrBuff[i]; + } + } + } + + return rtnValue; +} +#endif +UINT8 OCSignalCfgStrConfDataStruInit(CHAR* FSName) +{ + UINT8 rtnValue = 0u; + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT8 funcRtn = 0u; + UINT16 realRowCount = 0u; /*ʵʱݵ*/ + UINT16 i = 0u; + UINT16 wDataLen = 0u; /*ݿ*/ + + /*ڲ*/ + if (NULL == FSName) + { + ; /*ڲϷ*/ + } + else + { + /*ȡOCݱ*/ + funcRtn = dquGetConfigDataNew(FSName, OC_DATA_TYPE, OC_SIGNAL_ID, &pDataAddr, &DataSize, &realRowCount); + if (0u == funcRtn) + { + rtnValue = 0u; + } + else + { + rtnValue = 1u; + funcRtn = CommonMemSet(dquCICfgDtStr.OCSignalCfgStr, (UINT32)(SIGNAL_SUM_MAX * sizeof(OCSignalConfigDataStruct)), 0u, (UINT32)(SIGNAL_SUM_MAX * sizeof(OCSignalConfigDataStruct))); + + if (1u == funcRtn) + { + /**/ + } + if ((0u != DataSize) && (0u != realRowCount)) + { + if (0u == (DataSize % realRowCount)) + { + /*ÿֽڳ*/ + wDataLen = (UINT16)(DataSize / realRowCount); + /*źŻ*/ + dquCICfgDtStr.OCSignalCfgStrLen = realRowCount; + + for (i = 0u; i < realRowCount; i++) + { + /*źŻñ*/ + R_OCSignalConfigDataFromChar(pDataAddr, wDataLen); + pDataAddr += wDataLen; + } + } + else + { + /*ݴ*/ + rtnValue = 0u; + } + + + } + else + { + ; /**/ + } + } + + } + + return rtnValue; +} + +/********************************************* +*ܣOCźŻǷλ +*˵źŻID +*ֵ01 +*********************************************/ +UINT8 OcSignalHasBlue(const UINT16 signalId) +{ + UINT8 rtn = 0u; + + if ((signalId < SIGNAL_SUM_MAX)&&(0U < signalId)) + { + if ((dquCICfgDtStr.OCSignalCfgStr[signalId].BluePosAddrA > 0u) && (dquCICfgDtStr.OCSignalCfgStr[signalId].BluePosAddrA < 255U)) + { + rtn = 1u; + } + } + + return rtn; +} + + +/********************************************* +*ܣʼOC ñ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OCPhySecConfigDataStructInit(CHAR *FSName) +{ + UINT8 rtnValue = 1u; + UINT16 len = 0u; + UINT16 i = 0u; + UINT8 ArrBuff[MEMBERA_SUM_MAX] = { 0u }; + OCPhysicalSectionConfigDataStruct OCPhySecCfgStrBuff[PHYSICAL_SECTION_SUM_MAX] = { 0u }; + + /*index0ṹԱ˳ṹԱ*/ + ArrBuff[0] = OC_PHYSEC_CFG_STR_MEMBER_NUM; + ArrBuff[1] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionId); + ArrBuff[2] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].BelongOcId); + ArrBuff[3] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionModuleIdAddrA); + ArrBuff[4] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionPosAddrA); + ArrBuff[5] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionModuleIdAddrB); + ArrBuff[6] = (UINT8)sizeof(OCPhySecCfgStrBuff[0].PhysicalSectionPosAddrB); + + (void)memset(dquCICfgDtStr.OCPhySecCfgStr, 0x00, sizeof(OCPhysicalSectionConfigDataStruct) * PHYSICAL_SECTION_SUM_MAX); + + rtnValue = OCConfigDataStructInit(&len, FSName, OC_DATA_TYPE, OC_PHYSEC_ID, PHYSICAL_SECTION_SUM_MAX, \ + (void*)OCPhySecCfgStrBuff, ArrBuff); + + if (1u == rtnValue) + { + /*OCPhySecCfgStr鳤*/ + dquCICfgDtStr.OCPhySecCfgStrLen = len; + for (i = 0u; i < len; i++) + { + if (OCPhySecCfgStrBuff[i].PhysicalSectionId < PHYSICAL_SECTION_SUM_MAX) + { + dquCICfgDtStr.OCPhySecCfgStr[OCPhySecCfgStrBuff[i].PhysicalSectionId] = OCPhySecCfgStrBuff[i]; + } + } + } + + return rtnValue; +} + +/* ȡOc IdId +* ˵ +* UINT16 ocIdoc +* ֵ +* UINT16id +*/ +UINT16 GetCiIdByOcId(UINT16 ocId) +{ + UINT16 i = 0u; /*ѭ*/ + UINT16 j = 0u; /*ѭ*/ + UINT16 ciId = 0u; /*CI ID*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + + for (i = 0u; i < dquCICfgDtStr.TrsmtRlsDtStrLen; i++) + { + if (CI_SYSTEM_TYPE_OC == dquCICfgDtStr.TrsmtRlsDtStr[i].SystemType) + { + for (j = 0u; j < dquCICfgDtStr.TrsmtRlsDtStr[i].DeviceSum; j++) + { + if(TRANSMIT_OBJECT_DEVICE_SUM_MAX > j) + { + if (ocId == dquCICfgDtStr.TrsmtRlsDtStr[i].DeviceIdBuf[j]) + { + ciId = dquCICfgDtStr.TrsmtRlsDtStr[i].CiId; + + isBreak = 1u; /*˳*/ + break; + } + } + } + } + if (1u == isBreak) /*˳*/ + { + break; + } + } + + return ciId; +} + +/********************************************* +*ܣʼվ̨ſݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PscConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + + callFun = dfsEmapInit (FSName); + + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + else + {/*ӵͼʼɹִ*/ + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.PscCfgDtStrLen = dsuDataLenStru.wPSCLen;/*psc*/ + for(i=0u;i= PSC_SUM_MAX) + { + rtnvalue = 0u; + break; + } + rtnvalue &= PscCfgDtStruFromDquPointStr(dsuStaticHeadStru.pPSCStru+i,&dquCICfgDtStr.PscCfgDtStr[i]); + } + } + + return rtnvalue; +} + +/********************************************* +*ܣPSCṹPSCṹ +*˵pPointվ̨ſṹָ +pPscCfgDtStrվ̨ſݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PscCfgDtStruFromDquPointStr(DSU_PSC_STRU* pPoint,PscConfigDataStruct* pPscCfgDtStr) +{ + UINT16 j=0u; + UINT8 rtnvalue = 0u; + + /*ڲ*/ + if((NULL == pPoint) || (NULL == pPscCfgDtStr)) + { + /*ʧ*/ + rtnvalue = 0u; + } + else + { + pPscCfgDtStr->PscId = pPoint->wId; + pPscCfgDtStr->psdSum = 0u; + for(j=0;j<4u;j++) + { + pPscCfgDtStr->psdIdBuff[j] = ((0xffffu!=pPoint->wContainPSDID[j] ) ? pPoint->wContainPSDID[j] : 0U); + if (0U!=pPscCfgDtStr->psdIdBuff[j]) + { + pPscCfgDtStr->psdSum++; + } + } + rtnvalue = 1u; + } + + return rtnvalue; +} + + +/********************************************* +*ܣʼԶ·ݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GroupAutoRouteCfgDtStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i=0u; + UINT16 j=0u; + + callFun = dfsEmapInit (FSName); + callFun *= InitLS_GroupAutoRouteStru(FSName); + /*ӵͼʼʧܣʧ˳*/ + if(0u == callFun) + { + rtnvalue = 0u; + } + /*ӵͼʼɹִ*/ + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.GroupAutoRouteStrLen = LSDataLen.LSGroupAutoRouteStruLen; + for(i=0u;i jj) + { + if(virCIid == g_VirtualCIStructData.virtualCi[jj].virtualCiId) + { + ocNum = PZDquVirCIWithOCRelatFromChar(pDataAddr,g_VirtualCIStructData.virtualCi[jj].IncludeOCid); + g_VirtualCIStructData.virtualCi[jj].IncludeOCNum = ocNum; + break; + } + else + { + } + } + else + { + } + } + pDataAddr += CI_SYSTEM_VIRCI_INCLUDEOC_LEN-2U; + } + rtnValue = 1u; + } + } + + return rtnValue; +} + +/********************************************* +*ܣʼʹõı +*˵void +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitBaojingdeng_UseVirCI(void) +{ + UINT16 ii = 0u; + UINT8 localCi = GetSystemParaLocalCiId(); /*ID*/ + UINT16 bjdNum= 0u; + UINT8 reVal = CI_ERROR; + for(ii=0u;ii bjdNum) + { + reVal = CI_SUCCESS; + g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wId = RelayData.pRelayBjdStr[ii].wId; + g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wBjdID = RelayData.pRelayBjdStr[ii].wBjdID; + g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wBelongCiId = localCi; + g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wBelongVirCIid = RelayData.pRelayBjdStr[ii].wBelongVirCIid; + g_VirtualCIStructData.LocalCIBaojingdeng[bjdNum].wBjdDevID = RelayData.pRelayBjdStr[ii].cBjdDevId; + bjdNum += 1U; + } + else + { + reVal = CI_ERROR; + bjdNum = 0u; + break; + } + } + } + g_VirtualCIStructData.LocalCIBaojingdengNum = bjdNum; + return reVal; +} +/* +*ܣݼ̵Id +*˵ݼ̵IDָ +*ֵ0 ʧܣ>0 ɹ +* ̵ݶȡ +*/ +UINT8 GetBelongVirCiByRelayId(UINT16 relayId ) +{ + UINT8 VirCIid = 0u; + UINT16 ii = 0u; + + if ((0u < RelayDataLen.RelayCfgDtStrLen) && (NULL != RelayData.pRelayCfgDtStr)) + { + for (ii =0u;iiwId = pLink->wId; + pLinkScCfgDtStr->dwLength = pLink->dwLength; + pLinkScCfgDtStr->wLinkLine = pLink->wLinkLine; + pLinkScCfgDtStr->wOrgnPointType = pLink->wOrgnPointType; + pLinkScCfgDtStr->wOrgnPointId = pLink->wOrgnPointId; + pLinkScCfgDtStr->wOrgnJointMainLkId = pLink->wOrgnJointMainLkId; + pLinkScCfgDtStr->wOrgnJointSideLkId = pLink->wOrgnJointSideLkId; + pLinkScCfgDtStr->wTmnlPointType = pLink->wTmnlPointType; + pLinkScCfgDtStr->wTmnlPointId = pLink->wTmnlPointId; + pLinkScCfgDtStr->wTmnlJointMainLkId = pLink->wTmnlJointMainLkId; + pLinkScCfgDtStr->wTmnlJointSideLkId = pLink->wTmnlJointSideLkId; + pLinkScCfgDtStr->wManageTioc = pLink->wManagePhysicalCI; + pLinkScCfgDtStr->chLogicLineRelation = pLink->wLinkLogicDirUpAndDown; + pLinkScCfgDtStr->chLogicDirChanged = pLink->wLogicDirChanged; + pLinkScCfgDtStr->chRelPhySecIsAGorBG = LINK_REL_PHYSEC_IS_DEFAULT; /*ȳʼΪAGBG*/ + + for (i = 0u; i < dsuDataLenStru.wStationLen; i++) + { + if (pLinkScCfgDtStr->wId == (dsuStaticHeadStru.pStationStru + i)->wLinkId) + { + pLinkScCfgDtStr->wBelongPlatformId = (dsuStaticHeadStru.pStationStru + i)->wATSStationId; + + /*linkͣͨͣȷlinkAG/BG*/ + if ((8U == ((dsuStaticHeadStru.pStationStru + i)->dwAttribute & 8U)) && (16U == ((dsuStaticHeadStru.pStationStru + i)->dwAttribute & 16U))) + { + /*ͣԵ4λΪ15λΪ1ʾ߻ѹ*/ + if (0U == ((dsuStaticHeadStru.pStationStru + i)->dwAttribute & 32U)) + { + pLinkScCfgDtStr->chRelPhySecIsAGorBG = LINK_REL_PHYSEC_IS_AG; /*ͣԵ6λΪ0ʾAG*/ + } + else + { + pLinkScCfgDtStr->chRelPhySecIsAGorBG = LINK_REL_PHYSEC_IS_BG; /*ͣԵ6λΪ1ʾBG*/ + } + } + else + { + /*ǿ߻ѹ죬*/ + } + } + + } + + if ((LINK_TGEVACUATEDIR_UP == pLink->wLinkTG_EvacuateDir) || (LINK_TGEVACUATEDIR_DOWN == pLink->wLinkTG_EvacuateDir) || (LINK_TGEVACUATEDIR_ALL == pLink->wLinkTG_EvacuateDir)) + { + pLinkScCfgDtStr->chLinkTgEvacuateDir = pLink->wLinkTG_EvacuateDir; + } + else + { + rtnvalue = 0U; + } + + if (1U == rtnvalue) + { + if ((LINK_LINXIAN_YES == pLink->wLinxian) || (LINK_LINXIAN_NO == pLink->wLinxian)) + { + pLinkScCfgDtStr->chLinkLinXian = pLink->wLinxian; + } + else + { + rtnvalue = 0U; + } + } + } + return rtnvalue; +} + +/********************************************* +*ܣʼLINKݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +* 2022.3.8 +*********************************************/ +UINT8 LinkConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0U; + UINT8 callFun = 0U; + UINT16 i = 0U; + + callFun = dfsEmapInit(FSName); + + /*ӵͼʼʧܣʧ˳*/ + if (0U == callFun) + { + rtnvalue = 0U; + } + else + { + rtnvalue = 1U; + } + + if (1U == rtnvalue) + { + dquCICfgDtStr.LinkCfgDtStrLen = dsuDataLenStru.wLinkLen; + for (i = 0U; i < dsuDataLenStru.wLinkLen; i++) + { + if (LINK_SUM_MAX > i) + { + rtnvalue = LinkCfgDtStruFromDquLinkStr(dsuStaticHeadStru.pLinkStru + i, &dquCICfgDtStr.LinkCfgDtStr[i]); + } + else + { + rtnvalue = 0U; + } + + if (0U == rtnvalue) + { + break; + } + else + { + ; /*ִ*/ + } + } + } + else + { + ; + } + + if (1U == rtnvalue) + { + for (i = 0U; i < dsuDataLenStru.wLinkLen; i++) + { + if (LINK_SUM_MAX > i) + { + rtnvalue = AgLinkExistRelCGFlagCalc(&dquCICfgDtStr.LinkCfgDtStr[i]); + rtnvalue &= BGLinkRelAGLinkCal(&dquCICfgDtStr.LinkCfgDtStr[i]); + } + else + { + rtnvalue = 0U; + } + + if (0U == rtnvalue) + { + break; + } + else + { + ; /*ִ*/ + } + } + } + else + { + ; + } + + return rtnvalue; +} + +/********************************************* +*ܣݽṹ +*˵pAxis ṹָ +pAxisCfgDtStr ݽṹָ +*ֵ0ʧܣ1ɹ +* 2022.3.11 +*********************************************/ +UINT8 AxisCfgDtStruFromDquAxisStr(DSU_AXLE_STRU* pAxis, AxisConfigStru* pAxisCfgDtStr) +{ + UINT8 rtnvalue = 0u; + + /*ڲ*/ + if ((NULL == pAxis) || (NULL == pAxisCfgDtStr)) + { + /*ʧ*/ + return 0u; + } + + /*ֱӴӼлȡ*/ + pAxisCfgDtStr->wId = pAxis->wId; + pAxisCfgDtStr->dwAxleKilo = pAxis->dwAxleKilo; + pAxisCfgDtStr->wType = pAxis->wType; + pAxisCfgDtStr->chKiloType = pAxis->dwAxleKiloPlueMinusSign; + pAxisCfgDtStr->wLkId = pAxis->wLkId; + pAxisCfgDtStr->dwLkOfst = pAxis->dwLkOfst; + + rtnvalue = 1u; + return rtnvalue; +} + +/********************************************* +*ܣʼݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +* 2022.3.11 +*********************************************/ +UINT8 AxisConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i = 0u; + + callFun = dfsEmapInit(FSName); + + /*ӵͼʼʧܣʧ˳*/ + if (0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.AxisCfgDtStrLen = dsuDataLenStru.wAxlecounterLen; + for (i = 0u; i < dsuDataLenStru.wAxlecounterLen; i++) + { + if (i >= AXIS_NUM_MAX) + { + rtnvalue = 0u; + break; + } + rtnvalue &= AxisCfgDtStruFromDquAxisStr(dsuStaticHeadStru.pAxleStru + i, &dquCICfgDtStr.AxisCfgDtStr[i]); + } + } + + return rtnvalue; +} + +/* +: ʼֽ豸ݽṹ(ṹ) +: CHAR * FSName ļָ +: +ֵ: 0 ʧ +1 ɹ +*/ +UINT8 CutoffPointConfigDataStructInit(CHAR * FSName) +{ + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 i = 0u; /*ѭ*/ + UINT8 retVal = 0u; /*ֵ*/ + UINT8 dquGetConfDataRetVal = 0u; /*ȡݺֵ*/ + + /*ȡDZ·豸*/ + dquGetConfDataRetVal = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_CUTOFF_POINT_ID, &pDataAddr, &DataSize); + + if (1u == dquGetConfDataRetVal) + { + if (0u != DataSize) + { + if (0u == (DataSize % CI_SYSTEM_CI_CUTOFF_POINT_LEN)) + { + /* dqu */ + (void)CommonMemSet(dquCICfgDtStr.stCutoffPointCfgDt, (UINT32)sizeof(dquCICfgDtStr.stCutoffPointCfgDt), 0, (UINT32)sizeof(dquCICfgDtStr.stCutoffPointCfgDt)); + + /*ø*/ + dquCutoffPointDataLen = (UINT16)(DataSize / CI_SYSTEM_CI_CUTOFF_POINT_LEN); + pstDquCutoffPointData = (DquCutoffPointStruct *)MyNew((UINT32)(dquCutoffPointDataLen * sizeof(DquCutoffPointStruct))); + + if (NULL == pstDquCutoffPointData) + { + + + retVal = 0u; + } + else + { + dquCICfgDtStr.wCfgCfgDtLen = dquCutoffPointDataLen; + retVal = 1u; + for (i = 0u; i < dquCutoffPointDataLen; i++) + { + retVal &= PZDquCutoffPointDataFromChar(pDataAddr, pstDquCutoffPointData + i); + + pDataAddr += CI_SYSTEM_CI_CUTOFF_POINT_LEN; + + retVal &= ReadDquCutoffPointDataToConfig(pstDquCutoffPointData + i, &dquCICfgDtStr.stCutoffPointCfgDt[i]); + } + + } + } + else + { + debug_infor_printf((const)"\nCI_CONFIG_DATA,CUT_OFF_DATA,len %d not equal to fs", CI_SYSTEM_CI_CUTOFF_POINT_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software, CI_DEVICE_TYPE_FS_TABLE, ((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE << 8u) + CI_SYSTEM_CI_CUTOFF_POINT_ID, PRINT_ONCE); + + retVal = 0u; + } + } + else + { + + retVal = 1u; + } + } + else + { + retVal = 0u; + } + + return retVal; +} + +/* +: ֽDquCfgзֽ +: DquCutoffPointStruct *pCutoffPointDevData ֽ豸 +: CfpConfigStru *pstCutoffPointData DquCfg ֽ豸ָ +ֵ: 0 ʧ +1 ɹ +*/ +static UINT8 ReadDquCutoffPointDataToConfig(DquCutoffPointStruct* pCutoffPointDevData, CfpConfigStru* pstCutoffPointData) +{ + UINT8 retVal = 0u; + UINT8 chLocalCiId = 0U; + UINT32 dwLinkOff = 0U; + UINT16 wLinkId = 0U; + UINT16 wLinkIdBelongCiId = 0U;/*ֽLINKID*/ + UINT16 ii = 0U; + + if ((NULL != pCutoffPointDevData) && (NULL != pstCutoffPointData)) + { + retVal = 1U; + pstCutoffPointData->wPointId = pCutoffPointDevData->wCutoffPointId; + pstCutoffPointData->wLinkId = pCutoffPointDevData->wCutoffPointLinkId; + pstCutoffPointData->dwOffset = pCutoffPointDevData->dwCutoffPointLinkOff; + + chLocalCiId = GetSystemParaLocalCiId(); + + wLinkId = pCutoffPointDevData->wCutoffPointLinkId; + dwLinkOff = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wLinkId]].dwLength; + wLinkIdBelongCiId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wLinkId]].wManagePhysicalCI; + + if (chLocalCiId == wLinkIdBelongCiId) + { + /*ֽlinkΪֽڷһlinkΪlink*/ + pstCutoffPointData->wInFirstLink = wLinkId; + } + else + { + /*linkΪlinkοoffset,offsetΪ0link߼linkΪֽڷһlink + linkΪlinkοoffset,offsetΪ0link߼linkΪֽڷһlink*/ + if (0U == pstCutoffPointData->dwOffset) + { + pstCutoffPointData->wInFirstLink = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wLinkId]].wOrgnJointMainLkId; + } + else if (dwLinkOff == pstCutoffPointData->dwOffset) + { + pstCutoffPointData->wInFirstLink = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wLinkId]].wTmnlJointMainLkId; + } + else + { + pstCutoffPointData->wInFirstLink = 0U; + /**/ + retVal = 0U; + } + } + + if (chLocalCiId == (UINT8)pCutoffPointDevData->wRelativeTioc1) + { + pstCutoffPointData->wLocalTiocId = chLocalCiId; + pstCutoffPointData->wOtherTiocId = pCutoffPointDevData->wRelativeTioc2; + retVal = EnsureCfpLocDir(pstCutoffPointData); /* ȷֽķ */ + } + else if (chLocalCiId == (UINT8)pCutoffPointDevData->wRelativeTioc2) + { + pstCutoffPointData->wLocalTiocId = chLocalCiId; + pstCutoffPointData->wOtherTiocId = pCutoffPointDevData->wRelativeTioc1; + retVal = EnsureCfpLocDir(pstCutoffPointData); /* ȷֽķ */ + } + else + { + pstCutoffPointData->wLocalTiocId = pCutoffPointDevData->wRelativeTioc2; + pstCutoffPointData->wOtherTiocId = pCutoffPointDevData->wRelativeTioc1;/*޹طֽ*/ + pstCutoffPointData->chLocDir = CI_SYSTEM_DIRECTION_NONE; + } + + /*ʼֽRCźŻ*/ + pstCutoffPointData->wRelAdjacentRcSignalId = 0U; + + for (ii = 0U; ii < dquCICfgDtStr.SgnlCfgDtStrLen; ii++) + { + if ((chLocalCiId == pstCutoffPointData->wLocalTiocId) && (chLocalCiId != dquCICfgDtStr.SgnlCfgDtStr[ii].BelongCiId) && (pstCutoffPointData->wInFirstLink == dquCICfgDtStr.SgnlCfgDtStr[ii].wOutFirstLinkId)) + { + pstCutoffPointData->wRelAdjacentRcSignalId = dquCICfgDtStr.SgnlCfgDtStr[ii].SignalId; /*źŻDZźŻⷽһlinkΪֽڷһlink*/ + break; + } + else + { + /**/ + } + } + } + else + { + retVal = 0u; + } + + return retVal; +} + +/* +: ʼ߱豸ݽṹ(ṹ) +: CHAR * FSName ļָ +: +ֵ: 0 ʧ +1 ɹ +*/ +UINT8 LinkLineConfigDataStructInit(CHAR * FSName) +{ + UINT16 i = 0U; + UINT8 retVal = 0U; /*ֵ*/ + + retVal = dquCbtcConfigDataInit(FSName); /*ʼϵͳ*/ + + if (0U != retVal) + { + dquCICfgDtStr.wLinkLineCfgDtLen = cbtcConfigDataStru.BoundaryAxleInfoLen; + + if (LINK_LINE_SUM_MAX >= dquCICfgDtStr.wLinkLineCfgDtLen) + { + /* dqu */ + (void)CommonMemSet(dquCICfgDtStr.LinkLineCfgDtStr, (UINT32)sizeof(dquCICfgDtStr.LinkLineCfgDtStr), 0u, (UINT32)sizeof(dquCICfgDtStr.LinkLineCfgDtStr)); + + for (i = 0U; i < dquCICfgDtStr.wLinkLineCfgDtLen; i++) + { + retVal = ReadDquLinkLineDataToConfig(cbtcConfigDataStru.cbtcBoundaryAxleInfo + i, &dquCICfgDtStr.LinkLineCfgDtStr[i]); + + if (1U == retVal) + { + /*ȡ*/ + } + else + { + break; /*ֹͣ0*/ + } + } + } + else + { + debug_infor_printf((const)"\nInit Error! LINK_LINE_DATA Len %d Exceed Max!\n", dquCICfgDtStr.wLinkLineCfgDtLen); + + retVal = 0U; + } + } + else + { + /*ϵͳݳʼʧܣ0*/ + } + + return retVal; +} + +/* +* : ϵͳDquCfg +* : CBTC_BOUNDARY_AXLE_CONFIG_STRU* pCbtcBoundaryAxleInfo ϵͳ豸 +* : LinkLineStru *pDstLinkLineData DquCfg 豸ָ +* ֵ : 0 ʧ +* 1 ɹ +* Modified By LQ 2023.11.14 +*/ +UINT8 ReadDquLinkLineDataToConfig(CBTC_BOUNDARY_AXLE_CONFIG_STRU* pCbtcBoundaryAxleInfo, LinkLineStru *pDstLinkLineData) +{ + UINT8 retVal = 0U; + + if ((NULL != pCbtcBoundaryAxleInfo) && (NULL != pDstLinkLineData)) + { + retVal = 1U; + pDstLinkLineData->wId = pCbtcBoundaryAxleInfo->wIndex; + pDstLinkLineData->wAxisSecId = pCbtcBoundaryAxleInfo->wAxleSecId; + pDstLinkLineData->cLinkLineType = pCbtcBoundaryAxleInfo->cLinkLineType; + pDstLinkLineData->cInType = pCbtcBoundaryAxleInfo->cEntranceType; + pDstLinkLineData->cStorageLineType = pCbtcBoundaryAxleInfo->cStorageLineType; + } + else + { + retVal = 0U; + } + + return retVal; +} + +/********************************************* +*ܣʼ豸ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReverseCutConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i = 0u; + + if (NULL != FSName) + { + + callFun = InitRelay_ReverseCutStru(FSName); + } + else + { + rtnvalue = 0u; + } + /*ӵͼʼʧܣʧ˳*/ + if (0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.wReverseCutCfgLen = RelayDataLen.RelayReverseCutStrLen; + for (i = 0u; i= REVERSE_CUT_SUM_MAX) + { + rtnvalue = 0u; + break; + } + else + { + ; + } + + rtnvalue &= ReverseCutCfgDtStruFromDquStr(RelayData.pRelayReverseCutStr + i, &dquCICfgDtStr.stReverseCutCfgDtStr[i]); + } + } + else + { + ; + } + + return rtnvalue; +} + +/********************************************* +*ܣ豸ݽṹ +*˵pLogicSgmt߼νṹָ +pLgScCfgDtStr߼ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReverseCutCfgDtStruFromDquStr(Relay_ReverseCutStruct* pReverseCutRelay, ReverseCutCfgDataStru* pReverseCutCfgDtStr) +{ + UINT8 rtnvalue = 0u; + UINT16 jj = 0U; + + /*ڲ*/ + if ((NULL != pReverseCutRelay) && (NULL != pReverseCutCfgDtStr)) + { + + pReverseCutCfgDtStr->wId = pReverseCutRelay->wReverseCutRelayId; + for (jj = 0u; jjwReverseCutRelayId == RelayData.pRelayCfgDtStr[jj].RelayId) + { + pReverseCutCfgDtStr->chBelongCiId = RelayData.pRelayCfgDtStr[jj].BelongCiId; + break; + } + else + { + ; + } + } + pReverseCutCfgDtStr->wReverseRelayId = pReverseCutRelay->wReverseCutRelayId; + rtnvalue = 1u; + } + else + { + /*ʧ*/ + return 0u; + } + return rtnvalue; +} + +/********************************************* +*ܣʼTIOCATS豸ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GatewayConfigDataStructInit(CHAR * FSName) +{ + + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 i = 0u; /*ѭ*/ + UINT16 j = 0U; + UINT8 retVal = 0u; /*ֵ*/ + UINT8 dquGetConfDataRetVal = 0u; /*ȡݺֵ*/ + TransmitRelationDataStruct* pTrsmtRlsDtStr = NULL; + /*ȡDZ·豸*/ + if (NULL != FSName) + { + dquGetConfDataRetVal = dquGetConfigData(FSName, CI_SYSTEM_PARAMETER_DATA_TYPE, CI_SYSTEM_CI_GATEWAY_DEVICE_ID, &pDataAddr, &DataSize); + + if (1u == dquGetConfDataRetVal) + { + if (0u != DataSize) + { + if (0u == (DataSize % CI_SYSTEM_CI_GATEWAY_DEVICE_LEN)) + { + /* dqu */ + + /*ø*/ + dquGatewayDeviceDataLen = (UINT16)(DataSize / CI_SYSTEM_CI_GATEWAY_DEVICE_LEN); + pstDquGatewayDeviceData = (DquGatewayDeviceStruct *)MyNew((UINT32)(dquGatewayDeviceDataLen * sizeof(DquGatewayDeviceStruct))); + (void)CommonMemSet(pstDquGatewayDeviceData, (UINT32)(dquGatewayDeviceDataLen * sizeof(DquGatewayDeviceStruct)), 0, (UINT32)(sizeof(dquCICfgDtStr.stCutoffPointCfgDt))); + + if (NULL == pstDquGatewayDeviceData) + { + retVal = 0u; + } + else + { + for (i = 0u; i < dquGatewayDeviceDataLen; i++) + { + (void)PZDquGatewayDeviceDataFromChar(pDataAddr, pstDquGatewayDeviceData + i); + + pDataAddr += CI_SYSTEM_CI_GATEWAY_DEVICE_LEN; + for (j = 0U; j < dquCICfgDtStr.TrsmtRlsDtStrLen; j++) + { + if ((pstDquGatewayDeviceData[i].wTiocId == dquCICfgDtStr.TrsmtRlsDtStr[j].CiId) + && (CI_SYSTEM_TYPE_ATS == dquCICfgDtStr.TrsmtRlsDtStr[j].SystemType)) + { + pTrsmtRlsDtStr = &dquCICfgDtStr.TrsmtRlsDtStr[j]; + + (void)ReadGatewayDeviceCfgDtStru(pstDquGatewayDeviceData + i, pTrsmtRlsDtStr); + break; + } + } + } + + retVal = 1u; + } + } + else + { + debug_infor_printf((const)"\nCI_CONFIG_DATA,CUT_OFF_DATA,len %d not equal to fs", CI_SYSTEM_CI_CUTOFF_POINT_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software, CI_DEVICE_TYPE_FS_TABLE, (CI_SYSTEM_PARAMETER_DATA_TYPE << 8) + CI_SYSTEM_CI_GATEWAY_DEVICE_ID, PRINT_ONCE); + + retVal = 0u; + } + } + else + { + + retVal = 1u; + } + } + else + { + retVal = 0u; + } + } + else + { + retVal = 0u; + } + + return retVal; +} + +/********************************************* +*ܣ豸ݽṹ +*˵pLogicSgmt߼νṹָ +pLgScCfgDtStr߼ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReadGatewayDeviceCfgDtStru(DquGatewayDeviceStruct* pGatewayDeviceRelay, TransmitRelationDataStruct* pTrsmtRlsDtStr) +{ + UINT8 rtnvalue = 0u; + + /*ڲ*/ + if ((NULL != pGatewayDeviceRelay) && (NULL != pTrsmtRlsDtStr)) + { + pTrsmtRlsDtStr->wGatewayComputerId = pGatewayDeviceRelay->wGatewayDeviceId; + + rtnvalue = 1u; + } + else + { + /*ʧ*/ + return 0u; + } + return rtnvalue; +} + +/********************************************* +*ܣʼݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 EaConfigDataStructInit(CHAR * FSName) +{ + + UINT8 rtnvalue = 0u; + UINT8 callFun = 0u; + UINT16 i = 0u; + + callFun = dfsEmapInit(FSName); + + /*ӵͼʼʧܣʧ˳*/ + if (0u == callFun) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + } + + if (1u == rtnvalue) + { + dquCICfgDtStr.wEaCfgLen = dsuDataLenStru.wEaLen; + for (i = 0u; i < dsuDataLenStru.wEaLen; i++) + { + if (i >= EA_CFG_SUM_MAX) + { + rtnvalue = 0u; + break; + } + rtnvalue &= EaConfigDataStruFromDquEaStr(dsuStaticHeadStru.pEaStru + i, &dquCICfgDtStr.szEaCfgDtStr[i]); + } + } + + return rtnvalue; +} + +/********************************************* +*ܣݽṹ +*˵pEa ṹָ +pEaCfgDtStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 EaConfigDataStruFromDquEaStr(DSU_EMAP_EA_STRU* pEa, EaConfigStru* pEaCfgDtStr) +{ + UINT8 rtnvalue = 0u; + + /*ڲ*/ + if ((NULL == pEa) || (NULL == pEaCfgDtStr)) + { + /*ʧ*/ + return 0u; + } + + /*ֱӴLINKлȡ*/ + pEaCfgDtStr->wId = pEa->wId; + pEaCfgDtStr->chStartLinkNum = pEa->chStartLinkNum; + (void)CommonMemCpy(pEaCfgDtStr->szStartLinkId, (UINT32)(sizeof(UINT16) * EA_BD_LINK_SUM_MAX), pEa->szStartLinkId, (UINT32)(sizeof(UINT16) * EA_BD_LINK_SUM_MAX)); + (void)CommonMemCpy(pEaCfgDtStr->szStartLinkDir, (UINT32)(sizeof(UINT8) * EA_BD_LINK_SUM_MAX), pEa->szStartLinkDir, (UINT32)(sizeof(UINT8) * EA_BD_LINK_SUM_MAX)); + pEaCfgDtStr->chEndLinkNum = pEa->chEndLinkNum; + (void)CommonMemCpy(pEaCfgDtStr->szEndLinkId, (UINT32)(sizeof(UINT16) * EA_BD_LINK_SUM_MAX), pEa->szEndLinkId, (UINT32)(sizeof(UINT16) * EA_BD_LINK_SUM_MAX)); + (void)CommonMemCpy(pEaCfgDtStr->szEndLinkDir, (UINT32)(sizeof(UINT8) * EA_BD_LINK_SUM_MAX), pEa->szEndLinkDir, (UINT32)(sizeof(UINT8) * EA_BD_LINK_SUM_MAX)); + + rtnvalue = 1u; + return rtnvalue; +} +/********************************************* +*ܣOC ñ +*˵pDataAddr ݵַ +*ֵ0ʧܣ1ɹ +*עcgh-ϲCID-2539-5޸ijʼOC_ݱСģñźŻģñģñijʼʽijʼʽһ +*********************************************/ +void R_OCSwitchConfigDataFromChar(UINT8* pDataAddr) +{ + UINT8* pData = NULL; + UINT16 SwitchIdTemp = 0u; + if (NULL == pDataAddr) + { + ; /*ڲΪգн*/ + } + else + { + pData = pDataAddr; + SwitchIdTemp = ShortFromChar(pData); + + if (SwitchIdTemp < SWITCH_SUM_MAX) + { + /*ID--2ֽ*/ + dquCICfgDtStr.OCSwitchCfgStr[SwitchIdTemp].SwitchId = SwitchIdTemp; + pData += 2u; + + /*OC--2ֽ*/ + dquCICfgDtStr.OCSwitchCfgStr[SwitchIdTemp].BelongOcId = ShortFromChar(pData); + pData += 2u; + } + } +} + +/********************************************* +*ܣ·ӽ·ݳʼ +*˵pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteMainProConfigDataInit(RouteConfigDataStruct* RouteCfgDtStr, RouteConfigDataStruct* pRouteCfgDtStr) +{ + UINT16 i = 0U, j = 0U, k = 0U; + UINT8 rtnvalue = 0U; + UINT8 chMainIncSubLogSum = 0U;/*ӽ·Խ·߼ΰ·߼ηΧڵĿ*/ + UINT16 wMaybeSubIdBuf[ROUTE_SUB_INCLUDE_SUM_MAX] = { 0U };/*·ӽ·ID*/ + UINT8 chMaybeSubIdIndex = 0U;/*·ӽ·ID*/ + UINT8 chMainIncSubIndex = 0U;/*·ӽ·ID*/ + UINT16 wMaybeMainIdBuf[ROUTE_SUB_INCLUDE_SUM_MAX] = { 0U };/*ӽ··ID*/ + UINT8 chMaybeMainIdIndex = 0U;/*ӽ··ID*/ + UINT8 chSubBelMainIndex = 0U;/*ӽ··ID*/ + LOD_STRU strCurRouteSigPoint = { 0U };/*ǰ·ڷһLINK*/ + LOD_STRU strFindRouteSigPoint = { 0U };/*·ڷһLINK*/ + UINT8 chDirChangeNum = 0U;/*·ڷһLINK͵ǰ·ڷһLINK֮䷽仯Ŀ*/ + DSU_ROUTE_STRU* pDsuRouteStr = NULL; + + /*·ӽ·Ŀӽ··ĿʼΪ0*/ + pRouteCfgDtStr->MainOrSubData.RouteBelMainSum = 0U; + pRouteCfgDtStr->MainOrSubData.RouteSubSum = 0U; + + /*·ԳʼֵΪͨ·*/ + pRouteCfgDtStr->MainOrSubData.MainRouteProperty = ROUTE_INIT_PROPERTY; + + for (i = 0U; i < dquCICfgDtStr.RouteCfgDtStrLen; i++) + {/*н·Ľ·е߼ζڵǰ·аǰ·Ϊ·ԣӦĽ·Ϊӽ·*/ + for (j = 0U; j < RouteCfgDtStr[i].RouteInLogTrackSum; j++) + {/*·е߼*/ + for (k = 0U; k < pRouteCfgDtStr->RouteInLogTrackSum; k++) + {/*ǰ·߼*/ + if (pRouteCfgDtStr->RouteInLogTrackIdBuf[k] == RouteCfgDtStr[i].RouteInLogTrackIdBuf[j]) + { + chMainIncSubLogSum++; + } + else + { + /**/ + } + } + } + + if ((RouteCfgDtStr[i].RouteInLogTrackSum == chMainIncSubLogSum) || (pRouteCfgDtStr->RouteInLogTrackSum == chMainIncSubLogSum)) + { + pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pRouteCfgDtStr->RouteId]; + strCurRouteSigPoint.Lnk = pDsuRouteStr->wOrgnLkId; + strCurRouteSigPoint.Off = 0U; + + pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[RouteCfgDtStr[i].RouteId]; + strFindRouteSigPoint.Lnk = pDsuRouteStr->wOrgnLkId; + strFindRouteSigPoint.Off = 0U; + + chDirChangeNum = GetDirChangeNumBtwPoints(&strCurRouteSigPoint, &strFindRouteSigPoint); /*ѯǰlinkźŻlinkķ仯*/ + + if (((RouteCfgDtStr[i].RouteDirection == pRouteCfgDtStr->RouteDirection) && (0U == chDirChangeNum)) + || ((RouteCfgDtStr[i].RouteDirection != pRouteCfgDtStr->RouteDirection) + && (1U == chDirChangeNum))) + { + /*·շһ£ûз仯·з仯(з仯㣬2·ڷһLINK֮䷽仯ĿΪ0ų仯㵼µĽ·һ£Ƿֶν·ϵ) + շһµ·ڷڷ仯㣨2·ڷһLINK֮䷽仯ĿΪ1ųǷֶν·ϵ*/ + if ((pRouteCfgDtStr->RouteInLogTrackSum) > (RouteCfgDtStr[i].RouteInLogTrackSum)) + {/*ǰ··߼Σǰ·Ϊ·ԣһҪһֱͨ۷*/ + wMaybeSubIdBuf[chMaybeSubIdIndex] = RouteCfgDtStr[i].RouteId; + chMaybeSubIdIndex++; + } + else if ((pRouteCfgDtStr->RouteInLogTrackSum) < (RouteCfgDtStr[i].RouteInLogTrackSum)) + {/*ǰ·߼αĽ·ǰ·Ϊӽ·ԣһҪһֱͨ۷*/ + wMaybeMainIdBuf[chMaybeMainIdIndex] = RouteCfgDtStr[i].RouteId; + chMaybeMainIdIndex++; + } + else + { + /*޲Խ·Խиֵ*/ + } + } + else + { + /*ͬ*/ + } + } + chMainIncSubLogSum = 0U; + } + + /*۵ǰ··ӽ·ʼźŻһǷֶ*/ + for (i = 0U; i < chMaybeSubIdIndex; i++) + { + /*ӿ·ӽ·ɸѡӽ·*/ + if (pRouteCfgDtStr->StartSignalId == RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].StartSignalId) + { + /*·Ӧĵһӽ·ʼźŻͬ*/ + if (SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].EndSignalId]].signalFenDuanAttr) + { + /*һӽ·նźŻΪֶ*/ + pRouteCfgDtStr->MainOrSubData.RouteSubIdBuf[chMainIncSubIndex] = wMaybeSubIdBuf[i]; + chMainIncSubIndex++; + } + else + { + ; /**/ + } + } + else if (pRouteCfgDtStr->EndSignalId != RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].EndSignalId) + { + /*·Ӧķһӽ·:ӽ·նźŻ·նźŻһ*/ + if (SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].StartSignalId]].signalFenDuanAttr) + { + /*ȷӽ·ʼźŻΪֶԣΪ·ȷһӽ·*/ + pRouteCfgDtStr->MainOrSubData.RouteSubIdBuf[chMainIncSubIndex] = wMaybeSubIdBuf[i]; + chMainIncSubIndex++; + } + else + { + ; /**/ + } + } + else + { + /*·Ӧһӽ·:ӽ·նźŻ·նźŻһ*/ + /*ȷӽ·ʺ··һ Ҵȷӽ·ʼźűΪֶԼΪյӽ·*/ + if ((pRouteCfgDtStr->ConfigRouteType == RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].ConfigRouteType) + && (SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeSubIdBuf[i]]].StartSignalId]].signalFenDuanAttr)) + { + pRouteCfgDtStr->MainOrSubData.RouteSubIdBuf[chMainIncSubIndex] = wMaybeSubIdBuf[i]; + chMainIncSubIndex++; + } + else + { + ; /*·Ҳͬʵӽ·*/ + } + } + if (0U < chMainIncSubIndex) + { + pRouteCfgDtStr->MainOrSubData.MainRouteProperty = ROUTE_MAIN_PROPERTY; + } + } + + for (i = 0U; i < chMaybeMainIdIndex; i++) + { + if ((SIGNAL_FENDUAN_NO == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeMainIdBuf[i]]].StartSignalId]].signalFenDuanAttr) + && (SIGNAL_FENDUAN_NO == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeMainIdBuf[i]]].EndSignalId]].signalFenDuanAttr) + && ((SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->StartSignalId]].signalFenDuanAttr) + || (SIGNAL_FENDUAN_YES == dquCICfgDtStr.SgnlCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->EndSignalId]].signalFenDuanAttr))) + { + /*·ʼնźŻֶ߱ԣӿӽ··ɸѡ·*/ + if (pRouteCfgDtStr->EndSignalId != RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeMainIdBuf[i]]].EndSignalId) + {/*ȷ·նźŻӽ·նźŻһ£Ϊӽ·ȷһ·*/ + pRouteCfgDtStr->MainOrSubData.RouteBelMainIdBuf[chSubBelMainIndex] = wMaybeMainIdBuf[i]; + chSubBelMainIndex++; + } + else + {/*ȷ·նźŻӽ·նźŻһ£ӽ··ѡ·һµĴȷ·Ϊյ·*/ + if (RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[wMaybeMainIdBuf[i]]].ConfigRouteType == pRouteCfgDtStr->ConfigRouteType) + { + pRouteCfgDtStr->MainOrSubData.RouteBelMainIdBuf[chSubBelMainIndex] = wMaybeMainIdBuf[i]; + chSubBelMainIndex++; + } + } + } + if (0U < chSubBelMainIndex) + { + pRouteCfgDtStr->MainOrSubData.MainRouteProperty = ROUTE_SUB_PROPERTY; + } + } + + if ((ROUTE_SUB_INCLUDE_SUM_MAX < chMainIncSubIndex) && (ROUTE_SUB_INCLUDE_SUM_MAX < chSubBelMainIndex)) + { + rtnvalue = 0U; + } + else + { + pRouteCfgDtStr->MainOrSubData.RouteSubSum = chMainIncSubIndex; + pRouteCfgDtStr->MainOrSubData.RouteBelMainSum = chSubBelMainIndex; + rtnvalue = 1U; + } + + return rtnvalue; +} + +/********************************************* +*ܣ߼ι·ݳʼ +*˵pRouteCfgDtStr·ݽṹָ pLogCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LogRelateRouteDataInit(RouteConfigDataStruct* RouteCfgDtStr, LogicSectionConfigDataStruct* pLogCfgDtStr) +{ + UINT16 i = 0U; + UINT16 j = 0U; + UINT8 rtnvalue = 0U; + + /*߼ΰ·ĿʼΪ0*/ + pLogCfgDtStr->chRelateRouteSum = 0U; + for (i = 0U; i < dquCICfgDtStr.RouteCfgDtStrLen; i++) + {/*н·,߼Σ˽·Ϊ߼ι·*/ + for (j = 0; j < RouteCfgDtStr[i].RouteInLogTrackSum; j++) + { + if (RouteCfgDtStr[i].RouteInLogTrackIdBuf[j] == pLogCfgDtStr->LogicSectionId) + { + pLogCfgDtStr->wRelateRouteId[pLogCfgDtStr->chRelateRouteSum] = RouteCfgDtStr[i].RouteId; + (pLogCfgDtStr->chRelateRouteSum)++; + break; + } + } + } + if (LOGSEC_RELATE_ROUTE_SUM_MAX >= pLogCfgDtStr->chRelateRouteSum) + { + rtnvalue = 1U; + } + else + { + rtnvalue = 0U; + } + return rtnvalue; +} + +/********************************************* +*ܣ߼ιݳʼ +*˵pRouteCfgDtStr·ݽṹָ pLogCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LogRelateProSwDataInit(RouteConfigDataStruct* RouteCfgDtStr, LogicSectionConfigDataStruct* pLgScCfgDtStr) +{ + UINT8 rtnvalue = 1U; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 kk = 0U; + UINT8 hh = 0U; + UINT8 mm = 0U; + UINT16 wProtectSwSum = 0U;/*߼ι*/ + UINT16 wProtectSwId = 0U;/*߼ιIDɱ*/ + UINT8 chProtectSwFlag = 0U;/*߼ιȥر־*/ + + /*߼ι*/ + pLgScCfgDtStr->chRelateProSwSum = 0U; + for (ii = 0; ii < pLgScCfgDtStr->chLogsecSwitchSum; ii++) + {/*߼ΰе*/ + wProtectSwSum = dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[pLgScCfgDtStr->LogsecSwitchIdStru[ii].SwitchId]].wProtectSwitchNum; + for (jj = 0; jj < wProtectSwSum; jj++) + {/*Ӧķ*/ + wProtectSwId = dquCICfgDtStr.SwchCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[pLgScCfgDtStr->LogsecSwitchIdStru[ii].SwitchId]].wszProtectSwitchIdBuf[jj]; + chProtectSwFlag = 0U; + for (kk = 0U; kk < pLgScCfgDtStr->chRelateRouteSum; kk++) + {/*߼ιĽ·*/ + for (hh = 0U; hh < dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchSum; hh++) + {/*ѯ߼ι··÷߼ιλ·һ*/ + if (dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectSwitchId == wProtectSwId) + { + for (mm = 0U; mm < pLgScCfgDtStr->chRelateProSwSum; mm++) + {/*IDȥ*/ + if ((pLgScCfgDtStr->wRelateProSwId[mm].SwitchId == dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectSwitchId) + &&(pLgScCfgDtStr->wRelateProSwId[mm].SwitchPosition == dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectPosition)) + { + chProtectSwFlag = 1U; + break; + } + } + if (1U != chProtectSwFlag) + {/*ǰвIDŽ*/ + pLgScCfgDtStr->wRelateProSwId[pLgScCfgDtStr->chRelateProSwSum].SwitchId = dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectSwitchId; + pLgScCfgDtStr->wRelateProSwId[pLgScCfgDtStr->chRelateProSwSum].SwitchPosition = dquCICfgDtStr.RouteCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuRouteIndex[pLgScCfgDtStr->wRelateRouteId[kk]]].RouteProtectSwitchStru[hh].ProtectPosition; + (pLgScCfgDtStr->chRelateProSwSum)++; + break; + } + } + } + } + } + } + if (LOGSEC_RELATE_PRO_SW_SUM_MAX < pLgScCfgDtStr->chRelateProSwSum) + { + rtnvalue = 0U; + } + return rtnvalue; +} + +/********************************************* +*ܣݵӵͼźŻźŻֶ +*˵pSgnlDSUźŻݽṹָ +* pSgnlCfgDtStrźŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SetSignalFenDuanAttr(DSU_SIGNAL_STRU* pSgnl, SignalConfigDataStruct* pSgnlCfgDtStr) +{ + UINT8 ret = CI_SUCCESS; + UINT16 sigAttrEmap = 0u;/*ӵͼźŻ*/ + + /*ڲ*/ + if ((NULL == pSgnl) || (NULL == pSgnlCfgDtStr)) + { + /*ʧ*/ + ret = CI_ERROR; + } + if (CI_SUCCESS == ret) + { + sigAttrEmap = pSgnl->wAttribute; + if (0x0080U == (0x0080U & sigAttrEmap)) + { + pSgnlCfgDtStr->signalFenDuanAttr = SIGNAL_FENDUAN_YES; + } + else + { + pSgnlCfgDtStr->signalFenDuanAttr = SIGNAL_FENDUAN_NO; + } + + } + return ret; +} + +/********************************************* +*ܣӵӵͼ߼SPKSṹSPKS̵ID +*˵pSpksDSU߼SPKSݽṹָ +pSpksDataConfigSPKSݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20230919 +*********************************************/ +UINT8 ReadDataFromDquLogSpksData(const DSU_LOGSEC_SPKS_BUTTON_STRU* pSpks, SpksDataConfigStruct* pSpksDataConfig) +{ + UINT16 i = 0U; + UINT8 rtnvalue = 0U; + UINT16 j = 0U; + UINT16 wLogRelatePhySum = 0U;/*߼ιĿ*/ + /*ڲ*/ + if ((pSpks != NULL) && (pSpksDataConfig != NULL)) + { + + /* ӵͼݻ */ + pSpksDataConfig->spksId = pSpks->wId; + pSpksDataConfig->belongCiId = (UINT8)(pSpks->wManageCI); + pSpksDataConfig->belongVirCIid = (UINT8)pSpks->wManageVirCI; + pSpksDataConfig->wSpksRelPlatFormId = pSpks->wPlatFormId; + pSpksDataConfig->wSpksLogSecNum = pSpks->wLogSecNum; + + (void)CommonMemSet(pSpksDataConfig->wSpksLogSecIdBuff, (UINT32)(sizeof(pSpksDataConfig->wSpksLogSecIdBuff) / sizeof(UINT8)), 0, (UINT32)(sizeof(pSpksDataConfig->wSpksLogSecIdBuff) / sizeof(UINT8))); + for (i = 0u; (i < pSpksDataConfig->wSpksLogSecNum) && (i < SPKS_MAX_LOG_SEC_NUM) && (i < DSU_SPKS_STRU_LOGSECID); i++) + { + pSpksDataConfig->wSpksLogSecIdBuff[i] = pSpks->wRelateLogSecId[i]; + } + + (void)CommonMemSet(pSpksDataConfig->spksPhySecIdBuff, (UINT32)(sizeof(pSpksDataConfig->spksPhySecIdBuff) / sizeof(UINT8)), 0, (UINT32)(sizeof(pSpksDataConfig->spksPhySecIdBuff) / sizeof(UINT8))); + for (i = 0U; i < pSpksDataConfig->wSpksLogSecNum; i++) + { + for (j = 0U; j < wLogRelatePhySum; j++) + { + if (dquCICfgDtStr.lgcSctCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLogicSgmtIndex[pSpksDataConfig->wSpksLogSecIdBuff[i]]].wRelativePhySecId == pSpksDataConfig->spksPhySecIdBuff[j]) + { + break; + } + } + if (wLogRelatePhySum == j) + { + pSpksDataConfig->spksPhySecIdBuff[wLogRelatePhySum] = dquCICfgDtStr.lgcSctCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLogicSgmtIndex[pSpksDataConfig->wSpksLogSecIdBuff[i]]].wRelativePhySecId; + wLogRelatePhySum++; + } + } + pSpksDataConfig->phySecNum = wLogRelatePhySum; + + if ((0U == pSpksDataConfig->wSpksLogSecNum) || (0U == pSpksDataConfig->phySecNum)) + { + /*SPKSΣʧ*/ + rtnvalue = 0U; + } + else + { + rtnvalue = 1U; + } + + } + else + { + rtnvalue = 0U; + } + return rtnvalue; +} + +/********************************************* +*ܣӵӵͼSPKSṹSPKS +*˵pSpksDSUSPKSݽṹָ +pSpksDataConfigSPKSݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20230919 +*********************************************/ +UINT8 ReadDataFromDquPhySpksData(const DSU_SPKS_BUTTON_STRU* pSpks, SpksDataConfigStruct* pSpksDataConfig) +{ + UINT16 i = 0U; + UINT8 rtnvalue = 0U; + /*ڲ*/ + if ((pSpks != NULL) && (pSpksDataConfig != NULL)) + { + + /* ӵͼݻ */ + pSpksDataConfig->spksId = pSpks->wId; + pSpksDataConfig->belongCiId = (UINT8)(pSpks->wManageCI); + pSpksDataConfig->belongVirCIid = (UINT8)pSpks->wManageVirCI; + pSpksDataConfig->wSpksRelPlatFormId = (UINT8)pSpks->wPlatFormId; + pSpksDataConfig->phySecNum = pSpks->wPhysicalSgmtNum; + (void)CommonMemSet(pSpksDataConfig->spksPhySecIdBuff, (UINT32)(sizeof(pSpksDataConfig->spksPhySecIdBuff) / sizeof(UINT8)), 0, (UINT32)(sizeof(pSpksDataConfig->spksPhySecIdBuff) / sizeof(UINT8))); + for (i = 0u; (i < pSpksDataConfig->phySecNum) && (i < SPKS_MAX_SEC_NUM) && (i < DSU_SPKS_STRU_PHYID); i++) + { + pSpksDataConfig->spksPhySecIdBuff[i] = pSpks->wRelatePhysicalSgmtId[i]; + } + + if (0U == pSpksDataConfig->phySecNum) + { + /*SPKSΣʧ*/ + rtnvalue = 0U; + } + else + { + rtnvalue = 1U; + } + + } + else + { + rtnvalue = 0U; + } + return rtnvalue; +} + +/********************************************* +*ܣζӦSPKSϢ +*˵pPsclSgmtCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20230919 +*********************************************/ +UINT8 PhysicRelateSpksStr(PhysicalSectionConfigDataStruct* pPsclSgmtCfgDtStr) +{ + UINT8 rtnvalue = 0U; + UINT16 ii = 0U; + UINT16 jj = 0U; + + /*ڲ*/ + if (NULL != pPsclSgmtCfgDtStr) + { + /* SPKS */ + pPsclSgmtCfgDtStr->spksNum = 0u; + + for (jj = 0u; jj < dquCICfgDtStr.spksDataConfigStrLen; jj++) + { + for (ii = 0u; ii < dquCICfgDtStr.spksDataConfigStr[jj].phySecNum; ii++) + { + /* жϵǰSPKSťǷ */ + if (dquCICfgDtStr.spksDataConfigStr[jj].spksPhySecIdBuff[ii] == pPsclSgmtCfgDtStr->PhysicalSectionId) + { + if (pPsclSgmtCfgDtStr->spksNum < PHYSICAL_SECTION_SPKS_MAX_NUM) + { + pPsclSgmtCfgDtStr->spksIdBuff[pPsclSgmtCfgDtStr->spksNum] = dquCICfgDtStr.spksDataConfigStr[jj].spksId; + pPsclSgmtCfgDtStr->spksNum++; + } + } + else + { + ; /**/ + } + } + } + rtnvalue = 1U; + + } + return rtnvalue; +} + +/********************************************* +*ܣʼⱨݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SGBJConfigDataStructInit(CHAR* FSName) +{ + UINT8 rtnvalue = 0U; + UINT8 callFun = 0U; + UINT16 i = 0U; + UINT16 j = 0U; + UINT16 k = 0U; + UINT8 cRouteRelFlag = FLAG_UNSET; + UINT8 cRelayBelongCi_1 = 0U; /*̵1CI*/ + UINT8 cRelayBelongCi_2 = 0U; /*̵2CI*/ + + callFun = dfsEmapInit(FSName); + callFun *= InitLS_SGBJStru(FSName); + + /*ӵͼʼʧܣʧ˳*/ + if (1U == callFun) + { + rtnvalue = 1U; + dquCICfgDtStr.wSGBJCfgLen = LSDataLen.LSSGBJStruLen; + + if (SGBJ_SUM_MAX > LSDataLen.LSSGBJStruLen) + { + for (i = 0U; i < LSDataLen.LSSGBJStruLen; i++) + { + cRelayBelongCi_1 = 0U; /*ÿһⱨһCI*/ + cRelayBelongCi_2 = 0U; + + dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJId = LSData.pLSSGBJStru[i].wSGBJId; + dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelayId = LSData.pLSSGBJStru[i].wSGBJRelayId; + dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelayId_2 = LSData.pLSSGBJStru[i].wSGBJRelayId_2; + dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelPhySecNum = LSData.pLSSGBJStru[i].wSGBJRelPhySecNum; + + for (j = 0U; j < SGBJ_REL_PHYSEC_SUM_MAX; j++) + { + dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelPhySecId[j] = LSData.pLSSGBJStru[i].szSGBJRelPhySecId[j]; + } + + /*ʼⱨ·*/ + for (j = 0U; j < dquCICfgDtStr.RouteCfgDtStrLen; j++) + { + cRouteRelFlag = FLAG_UNSET; /*ÿһΣһα־*/ + for (k = 0U; k < dquCICfgDtStr.RouteCfgDtStr[j].wRelatedSGBJNum; k++) + { + if (dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJId == dquCICfgDtStr.RouteCfgDtStr[j].szRelatedSGBJId[k]) + { + if (SGBJ_INCLUDE_ROUTE_SUM_MAX > dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelatedRouteNum) + { + dquCICfgDtStr.SGBJCfgDataStru[i].szSGBJRelatedRouteId[dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelatedRouteNum] = dquCICfgDtStr.RouteCfgDtStr[j].RouteId; + dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelatedRouteNum++; + cRouteRelFlag = FLAG_SET; + } + else + { + rtnvalue = 0U; /*ޣ0*/ + } + } + else + { + /**/ + } + + if ((1U == rtnvalue) && (FLAG_UNSET == cRouteRelFlag)) + { + /**/ + } + else + { + break; /*޻ѹ˽·ֹͣ*/ + } + } + + if (1U == rtnvalue) + { + /**/ + } + else + { + break; /*ޣֹͣ0*/ + } + } + + for (j = 0U; j < RelayDataLen.RelayCfgDtStrLen; j++) + { + if (dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelayId == RelayData.pRelayCfgDtStr[j].RelayId) + { + cRelayBelongCi_1 = RelayData.pRelayCfgDtStr[j].BelongCiId; + } + + if (dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJRelayId_2 == RelayData.pRelayCfgDtStr[j].RelayId) + { + cRelayBelongCi_2 = RelayData.pRelayCfgDtStr[j].BelongCiId; + } + + if ((0U != cRelayBelongCi_1) && (0U != cRelayBelongCi_2)) + { + break; + } + } + + if ((0U != rtnvalue) && (0U != cRelayBelongCi_1) && (cRelayBelongCi_1 == cRelayBelongCi_2)) + { + dquCICfgDtStr.SGBJCfgDataStru[i].cBelongCiId = cRelayBelongCi_1; + } + else + { + rtnvalue = 0U; /*ʼʧܣֹͣ0*/ + break; + } + } + } + else + { + rtnvalue = 0U; /*ⱨޣʼʧ*/ + } + } + else + { + rtnvalue = 0U; + } + + return rtnvalue; +} + +/********************************************* +*ܣ·ⱨݳʼ +*˵RouteConfigDataStruct* pRouteCfgDtStr ·ݽṹָ +* LS_SGBJStruct* pLSSGBJStr ⱨṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteRelatedSGBJCfgDataInit(RouteConfigDataStruct* pRouteCfgDtStr, LS_SGBJStruct* pLSSGBJStr) +{ + UINT16 i = 0U; + UINT16 j = 0U; + UINT8 k = 0U; + UINT16 wTempRelatedSGBJNum = 0U; + UINT8 rtnvalue = 0U; + UINT8 cSGBJRelFlag = FLAG_UNSET; + UINT16 wInFstPhySecIndex = 0U; /*·ڷһ*/ + UINT16 wStartSignalIndex = 0U; /*·ʼźŻ*/ + UINT16 wOutFstPhySecIndex = 0U; /*·ʼźŻⷽһ*/ + UINT8 cInFstPhySecLjkFlag = 0U; /*·ڷһм*/ + UINT8 cOutFstPhySecLjkFlag = 0U; /*·ʼźŻⷽһм*/ + + if ((NULL != pRouteCfgDtStr) && (NULL != pLSSGBJStr)) + { + rtnvalue = 1U; + pRouteCfgDtStr->cSGBJDelayOpenFlag = ROUTE_SGBJ_DELAY_OPEN_INVALID; /*ȳʼʱű־Ч*/ + + /*ȡ·ڷһμʼźŻⷽһм*/ + wInFstPhySecIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuPhysicalSgmtIndex[pRouteCfgDtStr->RoutePhySectionStru[0].PhysicalSectionId]; + cInFstPhySecLjkFlag = dquCICfgDtStr.PsclSgmtCfgDtStr[wInFstPhySecIndex].LjkSecFlag; + wStartSignalIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex[pRouteCfgDtStr->StartSignalId]; + wOutFstPhySecIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuPhysicalSgmtIndex[dquCICfgDtStr.SgnlCfgDtStr[wStartSignalIndex].OutFirstPhySecId]; + cOutFstPhySecLjkFlag = dquCICfgDtStr.PsclSgmtCfgDtStr[wOutFstPhySecIndex].LjkSecFlag; + + /*ⱨʼ·ⱨ*/ + for (i = 0U; i < LSDataLen.LSSGBJStruLen; i++) + { + cSGBJRelFlag = FLAG_UNSET; /*ÿһΣһα־*/ + + /*ⱨ*/ + for (j = 0U; j < pLSSGBJStr[i].wSGBJRelPhySecNum; j++) + { + /*·ڷΣжϽ·ڷǷΪⱨ*/ + for (k = 0U; k < pRouteCfgDtStr->RoutePhySecSum; k++) + { + if (pRouteCfgDtStr->RoutePhySectionStru[k].PhysicalSectionId == pLSSGBJStr[i].szSGBJRelPhySecId[j]) + { + if (ROUTE_RELATED_SGBJ_NUM_MAX > wTempRelatedSGBJNum) + { + pRouteCfgDtStr->szRelatedSGBJId[wTempRelatedSGBJNum] = pLSSGBJStr[i].wSGBJId; /*·ڷΪⱨΣΪ·ⱨ*/ + wTempRelatedSGBJNum++; + cSGBJRelFlag = FLAG_SET; + + /*·ⱨ·ڷⷽһξмԣʱ־Ч*/ + if ((0xaaU == cInFstPhySecLjkFlag) || (0xaaU == cOutFstPhySecLjkFlag)) + { + pRouteCfgDtStr->cSGBJDelayOpenFlag = ROUTE_SGBJ_DELAY_OPEN_VALID; /*ʱ־Ч*/ + } + else + { + /*ʱ־Ч*/ + } + } + else + { + rtnvalue = 0U; /*ޣ0*/ + } + + break; /*޻·ѹⱨֹͣ*/ + } + else + { + /**/ + } + } + + if (FLAG_UNSET == cSGBJRelFlag) + { + /*·δΣжϽ·ʼźŻⷽһǷΪ*/ + if (pLSSGBJStr[i].szSGBJRelPhySecId[j] == dquCICfgDtStr.SgnlCfgDtStr[wStartSignalIndex].OutFirstPhySecId) + { + if (ROUTE_RELATED_SGBJ_NUM_MAX > wTempRelatedSGBJNum) + { + pRouteCfgDtStr->szRelatedSGBJId[wTempRelatedSGBJNum] = pLSSGBJStr[i].wSGBJId; /*·ʼźŻⷽһΪⱨΣΪ·ⱨ*/ + wTempRelatedSGBJNum++; + cSGBJRelFlag = FLAG_SET; + + /*·ⱨ·ڷⷽһξмԣʱ־Ч*/ + if ((0xaaU == cInFstPhySecLjkFlag) || (0xaaU == cOutFstPhySecLjkFlag)) + { + pRouteCfgDtStr->cSGBJDelayOpenFlag = ROUTE_SGBJ_DELAY_OPEN_VALID; /*ʱ־Ч*/ + } + else + { + /*ʱ־Ч*/ + } + } + else + { + rtnvalue = 0U; /*ޣ0*/ + } + } + else + { + /*·ʼźŻⷽһηⱨΣ*/ + } + } + else + { + /*·ΣжϽ·ʼźŻⷽһǷΪ*/ + } + + if ((1U == rtnvalue) && (FLAG_UNSET == cSGBJRelFlag)) + { + /**/ + } + else + { + break; /*޻·ѹⱨֹͣ*/ + } + } + + if (1U == rtnvalue) + { + /**/ + } + else + { + break; /*ޣֹͣ*/ + } + } + } + else if (NULL != pRouteCfgDtStr) /* (NULL == pLSSGBJStr)*/ + { + wTempRelatedSGBJNum = 0U; + pRouteCfgDtStr->cSGBJDelayOpenFlag = ROUTE_SGBJ_DELAY_OPEN_INVALID; + rtnvalue = 1U; /*ⱨΪ01*/ + } + else + { + /*ηǷ0*/ + } + + if (1U == rtnvalue) + { + pRouteCfgDtStr->wRelatedSGBJNum = wTempRelatedSGBJNum; + } + else + { + /*0*/ + } + + return rtnvalue; +} + +/********************************************* +*ܣ·ʽӽ߼ +*˵pLSRouteStr·ṹָ + pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*by cgh 20231014 +*********************************************/ +UINT8 RouteBlocNearLogSecInit(LS_RouteStruct* pLSRouteStr, RouteConfigDataStruct* pRouteCfgDtStr) +{ + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT16 kk = 0U; + UINT8 rtnvalue = CI_ERROR; + DSU_ROUTE_STRU* pDsuRouteStr = NULL;/*ӵͼ·ṹ*/ + DSU_BLOC_ACCESS_LINK_STRU* pBlocAccessStr = NULL;/*ӵͼʽӽα*/ + DSU_AXLE_SGMT_STRU* pAxleSgmtStr = NULL;/*ӵͼα*/ + LOD_STRU strFirstPoint = { 0U };/*ѯλõĵһ*/ + LOD_STRU strNextPoint = { 0U }; /*ѯλõһ*/ + UINT8 chDirChangeNum = 0U;/*仯Ŀ*/ + + /*ڲ*/ + if ((NULL != pLSRouteStr) && (NULL != pRouteCfgDtStr)) + { + rtnvalue = CI_SUCCESS; + + pDsuRouteStr = dsuStaticHeadStru.pRouteStru + dsuRouteIndex[pLSRouteStr->wRouteId]; + + strFirstPoint.Lnk = pDsuRouteStr->wOrgnLkId; + strFirstPoint.Off = 1U; + + /*ʽ·ӽĿ (ֶ)*/ + if (ROUTE_NEARSEC_CONDITION_SUM_MAX >= pDsuRouteStr->wBlogAccessLinkNum) + { + for (ii = 0U; ii < pDsuRouteStr->wBlogAccessLinkNum; ii++) + { + pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum = 0U; + pBlocAccessStr = dsuStaticHeadStru.pBLOCAccessLinkStru + dsuBLOCAccessLinkIndex[pDsuRouteStr->wBlogAccessLinkId[ii]]; + + if ((ROUTE_BLOCNEAR_PHYSEC_SUM_MAX >= pBlocAccessStr->wIncludeAxleSgmtNum) && + (ROUTE_CBTCNEAR_LOGSEC_SUM_MAX > pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum)) + { + for (jj = 0U; jj < pBlocAccessStr->wIncludeAxleSgmtNum; jj++) + { + pAxleSgmtStr = dsuStaticHeadStru.pAxleSgmtStru + dsuAxleSgmtIndex[pBlocAccessStr->wIncludeAxleSgmtId[jj]]; + + strNextPoint.Lnk = pAxleSgmtStr->wOrgnLkId; + strNextPoint.Off = 1U; + /*ѯ·ǰ֮޷仯*/ + chDirChangeNum = GetDirChangeNumBtwPoints(&strFirstPoint, &strNextPoint); + + if (((0U == (chDirChangeNum % 2U)) && (DIR_SAME == pLSRouteStr->wDir)) || ((0U != (chDirChangeNum % 2U)) && (DIR_CONVERT == pLSRouteStr->wDir))) + { + /*ż仯ҽ·߼һ || 仯ҽ·߼෴ζӦ߼δӺǰ洢*/ + for (kk = (pAxleSgmtStr->wIncludeLogicSgmtNum - 1U); kk >= 0U; kk--) + { + pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecIdBuf[pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum] = pAxleSgmtStr->wLogicSgmtId[kk]; + pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum++; + + if (0U == kk) + { + break; + } + else + { + ; /**/ + } + } + } + else if (((0U == (chDirChangeNum % 2U)) && (DIR_CONVERT == pLSRouteStr->wDir)) || ((0U != (chDirChangeNum % 2U)) && (DIR_SAME == pLSRouteStr->wDir))) + { + /*ż仯ҽ·߼෴ || 仯ҽ·߼һ£ζӦ߼δӺǰ洢*/ + for (kk = 0U; kk < pAxleSgmtStr->wIncludeLogicSgmtNum; kk++) + { + pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecIdBuf[pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum] = pAxleSgmtStr->wLogicSgmtId[kk]; + pRouteCfgDtStr->BlocNearPhySecStru[ii].BlocNearLogSecSum++; + } + } + else + { + rtnvalue = CI_ERROR; + } + } + } + else + { + rtnvalue = CI_ERROR; + } + } + } + else + { + rtnvalue = CI_ERROR; + } + } + else + { + rtnvalue = CI_ERROR; + } + return rtnvalue; +} + + +/********************************************* +*ܣ·һȥ߼ +*˵pLSRouteStr·ṹָ + pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*by cgh 20231014 +*********************************************/ +UINT8 RouteFirstLeaveLogSecInit(LS_RouteStruct* pLSRouteStr, RouteConfigDataStruct* pRouteCfgDtStr) +{ + UINT8 lineIdentity = 0U; + UINT16 routeId = 0U; + UINT16 routeEndSignal = 0U;/*·նźŻ*/ + UINT8 rtnvalue = CI_ERROR; + UINT16 j = 0U; + + /*ڲ*/ + if ((NULL != pLSRouteStr) && (NULL != pRouteCfgDtStr)) + { + rtnvalue = CI_SUCCESS; + routeId = pLSRouteStr->wRouteId; + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF); + pRouteCfgDtStr->RouteLeaveLogicSecId = 0u; + + if (CI_TRADITION_RAILWAY == lineIdentity) + {/*ͳǹ·*/ + /*·ȥΪ·նźŻڷһΣܲڣն赲źŻ*/ + routeEndSignal = dsuStaticHeadStru.pRouteStru[dsuRouteIndex[routeId]].wEndSignalId;/*·նźŻ*/ + + /*ҵԸźŻΪʼźŻĽ·*/ + for (j = 0U; j < ROUTE_SUM_MAX; j++) + { + if (routeEndSignal == dquCICfgDtStr.RouteCfgDtStr[j].StartSignalId) + { + pRouteCfgDtStr->RouteLeaveLogicSecId = dquCICfgDtStr.RouteCfgDtStr[j].InFirstLogSecId; + break; + } + else + { + /**/ + } + } + + } + else + { + ; + } + } + else + { + rtnvalue = CI_ERROR; + } + return rtnvalue; +} + +/********************************************* +*ܣת·۷źŻidݳʼ +*˵RouteConfigDataStruct* pRouteCfgDtStr ·ݽṹָ +* LS_TransRouteZFSigStruct* pTransRouteZFSigStruc ת·۷źŻidṹָ +*ֵ0ʧܣ1ɹ +*Create fan 20240725 +*********************************************/ +UINT8 RouteRelatedTransZFSigInit(RouteConfigDataStruct* pRouteCfgDtStr, LS_TransRouteZFSigStruct* pTransRouteZFSigStruct) +{ + UINT8 rtnvalue = CI_ERROR; + UINT8 i = 0U; + if ((NULL != pRouteCfgDtStr) && (NULL != pTransRouteZFSigStruct)) + { + rtnvalue = CI_SUCCESS; + /*ʼźŻΪ0*/ + pRouteCfgDtStr->wRelatedTransZFSigId = 0U; + /*ת۷źŻidʼ·*/ + for (i = 0U; i < LSDataLen.LSTransRouteZFSigStruLen; i++) + { + /*ҶӦ·*/ + if (pRouteCfgDtStr->RouteId == pTransRouteZFSigStruct[i].wRouteId) + { + pRouteCfgDtStr->wRelatedTransZFSigId = pTransRouteZFSigStruct[i].wTransRouteZFSigId; + break; + } + } + } + else if (NULL== pTransRouteZFSigStruct) + { + pRouteCfgDtStr->wRelatedTransZFSigId = 0U; + rtnvalue = 1U; /*ת۷źŻΪգ1*/ + } + else + { + /*ηǷ0*/ + } + return rtnvalue; +} + +/********************************************* +*ܣAG LINKǷڹCGԼ +*˵pLinkScCfgDtStr LINKݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20240821 +*********************************************/ +UINT8 AgLinkExistRelCGFlagCalc(LinkDataConfigStru* pLinkScCfgDtStr) +{ + UINT8 rtnvalue = 0U; + UINT16 wOrgnLinkAbgFlag = 0U; /*LINK ABG־*/ + UINT16 wTmnlLinkAbgFlag = 0U; /*յLINK ABG־*/ + + /*ڲ*/ + if (NULL == pLinkScCfgDtStr) + { + /*ʧ*/ + rtnvalue = 0U; + } + else + { + rtnvalue = 1U; + + pLinkScCfgDtStr->chExistRelCGFlag = LINK_EXIST_REL_CG_DEFAULT; + + if (LINK_REL_PHYSEC_IS_AG == pLinkScCfgDtStr->chRelPhySecIsAGorBG) + { + if ((65535U == pLinkScCfgDtStr->wOrgnJointMainLkId) || (65535U == pLinkScCfgDtStr->wTmnlJointMainLkId)) + { + pLinkScCfgDtStr->chExistRelCGFlag = LINK_EXIST_REL_CG_NO; + } + else + { + wOrgnLinkAbgFlag = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wOrgnJointMainLkId]].chRelPhySecIsAGorBG; + wTmnlLinkAbgFlag = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wTmnlJointMainLkId]].chRelPhySecIsAGorBG; + + /*LINKһBG򲻴CG*/ + if ((LINK_REL_PHYSEC_IS_BG != wOrgnLinkAbgFlag) && (LINK_REL_PHYSEC_IS_BG != wTmnlLinkAbgFlag)) + { + pLinkScCfgDtStr->chExistRelCGFlag = LINK_EXIST_REL_CG_YES; + } + else + { + pLinkScCfgDtStr->chExistRelCGFlag = LINK_EXIST_REL_CG_NO; + } + } + } + else + { + ; /*ֵΪĬ*/ + } + + } + return rtnvalue; +} + +/********************************************* +*ܣBGlinkAGlink +*˵LinkDataConfigStru* pLinkScCfgDtStr LINKݽṹָ +* ֵ0 ʧ +* 1 ɹ +*Creatd By LQ 2024.08.22 +*********************************************/ +UINT8 BGLinkRelAGLinkCal(LinkDataConfigStru* pLinkScCfgDtStr) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wOrgLinkId = 0U; /*link*/ + UINT16 wTmlLinkId = 0U; /*յlink*/ + UINT8 cOrgLinkAttr = LINK_REL_PHYSEC_IS_DEFAULT; /*linkAG/BG*/ + UINT8 cTmlLinkAttr = LINK_REL_PHYSEC_IS_DEFAULT; /*յlinkAG/BG*/ + UINT16 wBGRelAGLinkId = 0U; /*BGAGlink*/ + UINT16 wBGRelCGLinkId = 0U; /*BGCGlink*/ + + if (NULL != pLinkScCfgDtStr) + { + if (LINK_REL_PHYSEC_IS_BG == pLinkScCfgDtStr->chRelPhySecIsAGorBG) + { + if ((UINT16_MAX != pLinkScCfgDtStr->wOrgnJointMainLkId) && (0U != pLinkScCfgDtStr->wOrgnJointMainLkId)) + { + cOrgLinkAttr = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wOrgnJointMainLkId]].chRelPhySecIsAGorBG; + wOrgLinkId = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wOrgnJointMainLkId]].wId; + + if (LINK_REL_PHYSEC_IS_AG == cOrgLinkAttr) + { + wBGRelAGLinkId = wOrgLinkId; /*BGlinkΪAG*/ + } + else if (LINK_REL_PHYSEC_IS_DEFAULT == cOrgLinkAttr) + { + wBGRelCGLinkId = wOrgLinkId; /*BGlinkΪCG*/ + } + else + { + /*BGlinkΪB2G*/ + } + } + else + { + /*ͷߣ*/ + } + + if ((UINT16_MAX != pLinkScCfgDtStr->wTmnlJointMainLkId) && (0U != pLinkScCfgDtStr->wTmnlJointMainLkId)) + { + cTmlLinkAttr = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wTmnlJointMainLkId]].chRelPhySecIsAGorBG; + wTmlLinkId = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkScCfgDtStr->wTmnlJointMainLkId]].wId; + + if (LINK_REL_PHYSEC_IS_AG == cTmlLinkAttr) + { + wBGRelAGLinkId = wTmlLinkId; /*BGյlinkΪAG*/ + } + else if (LINK_REL_PHYSEC_IS_DEFAULT == cTmlLinkAttr) + { + wBGRelCGLinkId = wTmlLinkId; /*BGյlinkΪCG*/ + } + else + { + /*BGյlinkΪB2G*/ + } + } + else + { + /*ͷߣ*/ + } + + if ((0U == wBGRelAGLinkId) && (0U != wBGRelCGLinkId)) + { + /*CGͨCGѰBGAG*/ + wOrgLinkId = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wBGRelCGLinkId]].wOrgnJointMainLkId; /*CGlink*/ + wTmlLinkId = dquCICfgDtStr.LinkCfgDtStr[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wBGRelCGLinkId]].wTmnlJointMainLkId; /*CGյlink*/ + + if (wOrgLinkId == pLinkScCfgDtStr->wId) + { + wBGRelAGLinkId = wTmlLinkId; /*CGյlinkΪAG*/ + } + else if (wTmlLinkId == pLinkScCfgDtStr->wId) + { + wBGRelAGLinkId = wOrgLinkId; /*CGlinkΪAG*/ + } + else + { + /**/ + } + } + else + { + /**/ + } + } + else + { + /*BG*/ + } + + pLinkScCfgDtStr->wBGLinkRelAGLink = wBGRelAGLinkId; + cRetVal = CI_SUCCESS; + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* ʼֽбֽ㷽 +* ˵CfpConfigStru *pstCutoffPointData DquCfg ֽ豸ָ루Σ +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.10.16 +*/ +static UINT8 EnsureCfpLocDir(CfpConfigStru* pstCutoffPointData) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wCfpLocLinkId = 0U; /*ֽlinkID*/ + UINT32 dwCfpLocLinkLen = 0U; /*ֽlink*/ + + if (NULL != pstCutoffPointData) + { + cRetVal = CI_SUCCESS; + wCfpLocLinkId = pstCutoffPointData->wLinkId; + dwCfpLocLinkLen = dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wCfpLocLinkId]].dwLength; + + if (LINK_DIRCHANGE_NONE == dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wCfpLocLinkId]].wLogicDirChanged) + { + /*ûз仯㣬ݷֽlinkƫȷֽķ*/ + if (((wCfpLocLinkId == pstCutoffPointData->wInFirstLink) && (0U == pstCutoffPointData->dwOffset)) + || ((wCfpLocLinkId != pstCutoffPointData->wInFirstLink) && (dwCfpLocLinkLen == pstCutoffPointData->dwOffset))) + { + /*ֽlinkڱƫΪ0򣨷ֽlinkڱƫΪlinkȣڷֽ߼*/ + pstCutoffPointData->chLocDir = EMAP_SAME_DIR; + } + else if (((wCfpLocLinkId == pstCutoffPointData->wInFirstLink) && (dwCfpLocLinkLen == pstCutoffPointData->dwOffset)) + || ((wCfpLocLinkId != pstCutoffPointData->wInFirstLink) && (0U == pstCutoffPointData->dwOffset))) + { + /*ֽlinkڱƫΪlinkȣ򣨷ֽlinkڱƫΪ0ڷֽ߼*/ + pstCutoffPointData->chLocDir = EMAP_CONVER_DIR; + } + else + { + pstCutoffPointData->chLocDir = CI_SYSTEM_DIRECTION_NONE; + cRetVal = CI_ERROR; /*󣬷0ʧܣʼʧ*/ + debug_infor_printf((const)"\nEnsureCfpLocDir Error: Cfp ID Is [%d]", pstCutoffPointData->wPointId); + } + } + else + { + if ((0U == pstCutoffPointData->dwOffset) && (LINK_DIRCHANGE_BEGIN == dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wCfpLocLinkId]].wLogicDirChanged)) + { + /*ֽڷ仯㣬ֽoffsetΪ0Զڷֽ߼*/ + pstCutoffPointData->chLocDir = EMAP_SAME_DIR; + } + else if ((dwCfpLocLinkLen == pstCutoffPointData->dwOffset) && (LINK_DIRCHANGE_END == dsuStaticHeadStru.pLinkStru[dsuLinkIndex[wCfpLocLinkId]].wLogicDirChanged)) + { + /*ֽڷ仯㣬ֽoffsetΪ0յԶڷֽ߼*/ + pstCutoffPointData->chLocDir = EMAP_CONVER_DIR; + } + else + { + pstCutoffPointData->chLocDir = CI_SYSTEM_DIRECTION_NONE; + cRetVal = CI_ERROR; /*󣬷0ʧܣʼʧ*/ + debug_infor_printf((const)"\nEnsureCfpLocDir Error: Cfp ID Is [%d]", pstCutoffPointData->wPointId); + } + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/********************************************* +*ܣʼ۷ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +* by cgh 20241031 +*********************************************/ +static UINT8 NonAutoReturnStructInit(CHAR* FSName) +{ + UINT8 rtnvalue = 0U; + UINT8 callFun = 0U; + UINT16 i = 0U; + + callFun = dfsEmapInit(FSName); + + /*ӵͼʼʧܣʧ˳*/ + if (0U == callFun) + { + rtnvalue = 0U; + } + else + { + rtnvalue = 1U; + } + + if (1U == rtnvalue) + { + for (i = 0U; i < dquCICfgDtStr.NonReturnCfgSum; i++) + { + if (i >= NON_AUTO_RETURN_SUM_MAX) + { + rtnvalue = 0U; + } + else + { + rtnvalue = NonReturnStruFromDquStr(dsuStaticHeadStru.pARStru + i, &dquCICfgDtStr.NonAutoReturnCfgDataSt[i]); + } + + if (0U == rtnvalue) + { + break; + } + else + { + ; /*ʼ*/ + } + + } + } + else + { + ; + } + + return rtnvalue; +} + +/********************************************* +*ܣ۷ݽṹ +*˵pNonReturn ۷ṹָ + pNonReturnCfgDtStr ۷ݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20241031 +*********************************************/ +static UINT8 NonReturnStruFromDquStr(DSU_AR_STRU* pNonReturn, NonAutoReturnConfigDataStruct* pNonReturnCfgDtStr) +{ + UINT8 rtnvalue = 0u; + + /*ڲ*/ + if ((NULL != pNonReturn) && (NULL != pNonReturnCfgDtStr)) + { + /*ֱӴ۷лȡ*/ + pNonReturnCfgDtStr->NonAutoReturnRelLightId = pNonReturn->wARLampID; + pNonReturnCfgDtStr->NonAutoReturnRelButtonId = pNonReturn->wARButtonId; + + rtnvalue = 1u; + } + else + { + ; + } + + + return rtnvalue; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIInit.h b/TSCP/src/APP/ciapp/QueryFiles/dquCIInit.h new file mode 100644 index 0000000..08a6680 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIInit.h @@ -0,0 +1,935 @@ +/************************************************************************ +* +* ļ dquCIInit.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ϵͳݳʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_CI_INIT_H +#define DQU_CI_INIT_H + +#include "dquCIStru.h" +#include "dquCIJDQStruInit.h" +#include "dquCILSStruInit.h" +#include "dquEmapInit.h" +#include "dquCIPZStruFrmChar.h" +#include "dquCbtcConfigData.h" +#include "dquCIReadCommonChar.h" +#include "../DebugPrint/DebugPrint.h" +#include "../DebugPrint/ErrorCode.h" +#include "../DebugPrint/ErrorDeviceType.h" +#include "../PSC/PSCConfigDataManage.h" +#include "../CutoffPoint/CutoffPointConfigDataManage.h" +#include "AxisConfigDataManage.h" +#include "LinkLineConfigDataManage.h" +#include "ReverseCutConfigDataManage.h" +#include "EvacuationAreaManage.h" +#include "NonAutoReturnConfigDataManage.h" +#include "../SGBJ/SGBJConfigDataManage.h" +#include "../Section/AxisSectionConfigDataManage.h" + +#define ORIGIN_TO_TERMINAL ((UINT8)0x55) /*㵽յ*/ +#define TERMINAL_TO_ORIGIN ((UINT8)0xAA) /*յ㵽*/ +/*ڼ¼ṹԱֵ*/ +#define MEMBERA_SUM_MAX ((UINT8)40) + + + +/*1ֽ*/ +#define CHAR_LEN ((UINT8)1) +/*2ֽ*/ +#define SHORT_LEN ((UINT8)2) +/*4ֽ*/ +#define LONG_LEN ((UINT8)4) + +/*dquCICfgDtStr.OCSwitchCfgStrгԱ*/ +#define OC_SWITCH_CFG_STR_MEMBER_NUM ((UINT8)2) + +/*dquCICfgDtStr.OCSwitchCfgStrгԱ_ɰ*/ +#define OC_SWITCH_CFG_STR_MEMBER_NUM_OLD ((UINT8)6) + +/*dquCICfgDtStr.OCSignalCfgStrгԱ*/ +#define OC_SIGNAL_CFG_STR_MEMBER_NUM ((UINT8)18) +/*dquCICfgDtStr.OCPhySecCfgStrгԱ*/ +#define OC_PHYSEC_CFG_STR_MEMBER_NUM ((UINT8)6) + +#define AXIS_TYPE_YONGLIE ((UINT8)(0x01)) /**/ +#define AXIS_TYPE_KEANDA ((UINT8)(0x02)) /*ư*/ + +#define INDICATOR_MAX_SIZE ((UINT16)2000) /*С*/ + +/*ѹ켰ɢ*/ +#define LINK_TGEVACUATEDIR_UP ((UINT8)0X55) /*ֻ·*/ +#define LINK_TGEVACUATEDIR_DOWN ((UINT8)0XAA) /*ֻ·*/ +#define LINK_TGEVACUATEDIR_ALL ((UINT8)0XFF) /*жĬ*/ + +/*linkεAG/BG*/ +#define LINK_REL_PHYSEC_IS_AG ((UINT8)0x55) /*linkΪAG*/ +#define LINK_REL_PHYSEC_IS_BG ((UINT8)0xAA) /*linkΪBG*/ +#define LINK_REL_PHYSEC_IS_DEFAULT ((UINT8)0xFF) /*linkηAGҷBG*/ + +/*LINKǷڹCG*/ +#define LINK_EXIST_REL_CG_YES ((UINT8)0x55) /*LinkڹCG*/ +#define LINK_EXIST_REL_CG_NO ((UINT8)0xAA) /*LinkڹCG*/ +#define LINK_EXIST_REL_CG_DEFAULT ((UINT8)0xFF) /*LinkҪCG*/ + +/**/ +#define LINK_LINXIAN_YES ((UINT8)0x55) /*Link*/ +#define LINK_LINXIAN_NO ((UINT8)0xFF) /*Link*/ + +typedef struct +{ + RelayConfigDataStruct RelayCfgDtStr[RELAY_SUM_MAX]; /*̵*/ + CHAR RelayName[RELAY_SUM_MAX][JDQ_NAME_LEN]; /*̵*/ + UINT16 RelayCfgDtStrLen; + SignalConfigDataStruct SgnlCfgDtStr[SIGNAL_SUM_MAX]; /*źŻ*/ + UINT16 SgnlCfgDtStrLen; + SwitchConfigDataStruct SwchCfgDtStr[SWITCH_SUM_MAX]; /**/ + UINT16 SwchCfgDtStrLen; + PhysicalSectionConfigDataStruct PsclSgmtCfgDtStr[PHYSICAL_SECTION_SUM_MAX]; /**/ + UINT16 PsclSgmtCfgDtStrLen; + AxisSectionConfigDataStruct AxisSctCfgDtStr[AXIS_SECTION_SUM_MAX]; /**/ + UINT16 AxisSctCfgDtStrLen; + LogicSectionConfigDataStruct lgcSctCfgDtStr[LOGIC_SECTION_SUM_MAX]; /*߼*/ + UINT16 lgcSctCfgDtStrLen; + EsbConfigDataStruct EsbCfgDtStr[ESB_SUM_MAX]; /*ESB*/ + UINT16 EsbCfgDtStrLen; + PsdConfigDataStruct PsdCfgDtStr[PSD_SUM_MAX]; /**/ + UINT16 PsdCfgDtStrLen; + AutoRouteConfigDataStruct AutoRouteCfgDtStr[AUTO_ROUTE_SUM_MAX]; /*Զ·*/ + UINT16 AutoRouteCfgDtStrLen; + AutoReturnConfigDataStruct AutoRtnRouteCfgDtStr[AUTO_RETURN_SUM_MAX]; /*Զ۷·*/ + UINT16 AutoRtnRouteCfgDtStrLen; + ReverseRouteConfigDataStruct ReverseRouteCfgDtStr[REVERSE_ROUTE_SUM_MAX]; /*·*/ + UINT16 ReverseRouteCfgDtStrLen; + LongRouteConfigDataStruct LongRouteCfgDtStr[ROUTE_LONG_SUM_MAX]; /*·*/ + UINT16 LongRouteCfgDtStrLen; + NonRouteConfigDataStruct NonRouteCfgDtStr[NONROUTE_ID_NUM_MAX]; + UINT16 NonRouteCfgDtStrLen; + IndicatorConfigDataStruct IndctCfgDtStr[INDICATOR_MAX_SIZE]; /*ָʾ*/ + UINT16 IndctCfgDtStrLen; + OverlapConfigDataStruct OvlapCfgDtStr[OVERLAP_SUM_MAX]; /*overlap*/ + UINT16 OvlapCfgDtStrLen; + RouteConfigDataStruct RouteCfgDtStr[ROUTE_SUM_MAX]; /*·*/ + UINT16 RouteCfgDtStrLen; + SystemParameterStructNew SystemParaStrNew; /*µCIϵͳò[]*/ + UINT16 SystemParamStrLen; + CiTransmitStruct CiTransmitStru[CI_SUM_MAX][CI_SUM_MAX]; /* ,CiTransmitStru[CI_SUM_MAX] ԷͷΪڶĿ귽Ϊ*/ + UINT8 CiTransmitStrLen[CI_SUM_MAX]; /* ʾӦͨŶݵĸ */ + TransmitRelationDataStruct TrsmtRlsDtStr[500]; /*ͨŶ*/ + UINT16 TrsmtRlsDtStrLen; + AllAutoReturnConfigDataStruct AllAutoRtnRouteCfgDtStr[ALL_AUTO_RETURN_SUM_MAX]; /*ȫԶ۷·*/ + UINT16 AllAutoRtnRouteCfgDtStrLen; + GaragedoorConfigDataStruct GaragedoorCfgDtStr[GARAGE_DOOR_SUM_MAX]; /**/ + UINT16 GaragedoorCfgDtStrLen; + SpksDataConfigStruct spksDataConfigStr[SPKS_SUM_MAX]; /* SPKS */ + UINT16 spksDataConfigStrLen; + MJDataConfigStruct mjDataConfigStr[MJ_SUM_MAX]; /* Ž */ + UINT16 mjDataConfigStrLen; + FloodGateConfigDataStruct FloodGateCfgDtStr[FLOOD_GATE_SUM_MAX]; /**/ + UINT16 FloodGateCfgDtStrLen; + WashMachineConfigDataStruct WashMachineCfgStr[WASHMACHINE_SUM_MAX]; /*ϴ*/ + UINT16 WashMachineCfgDtStrLen; + + InvSecConfigDataStruct dquCIfg_InvSecConfigDataStru[INVA_SECT_N_COND_SWIT_SUM_MAX]; /*ݽṹ*/ + UINT16 InvSecCfgDtStrLen; + + DiffLineDevStruct dquCIfg_DiffLineDevData[1]; + + OCSwitchConfigDataStruct OCSwitchCfgStr[SWITCH_SUM_MAX]; /*oc*/ + UINT16 OCSwitchCfgStrLen; + + OCSignalConfigDataStruct OCSignalCfgStr[SIGNAL_SUM_MAX]; /*ocźŻ*/ + UINT16 OCSignalCfgStrLen; + + OCPhysicalSectionConfigDataStruct OCPhySecCfgStr[PHYSICAL_SECTION_SUM_MAX]; /*oc*/ + UINT16 OCPhySecCfgStrLen; + + PscConfigDataStruct PscCfgDtStr[PSC_SUM_MAX]; /*վ̨ſ*/ + UINT16 PscCfgDtStrLen; + + GroupAutoRouteConfigDataStruct GroupAutoRouteCfgStr[GROUP_AUTO_ROUTE_SUM_MAX]; /*Զ·*/ + UINT16 GroupAutoRouteStrLen; + + LinkDataConfigStru LinkCfgDtStr[LINK_SUM_MAX]; /*LINK*/ + UINT16 LinkCfgDtStrLen; /* add 2022.3.8 */ + + AxisConfigStru AxisCfgDtStr[AXIS_NUM_MAX]; /**/ + UINT16 AxisCfgDtStrLen; + + CfpConfigStru stCutoffPointCfgDt[CUTOFF_POINT_SUM_MAX]; /*ֽ*/ + UINT16 wCfgCfgDtLen; + + LinkLineStru LinkLineCfgDtStr[LINK_LINE_SUM_MAX]; /* */ + UINT16 wLinkLineCfgDtLen; /* add 20220507 */ + + ReverseCutCfgDataStru stReverseCutCfgDtStr[REVERSE_CUT_SUM_MAX]; /*豸*/ + UINT16 wReverseCutCfgLen; + + EaConfigStru szEaCfgDtStr[EA_CFG_SUM_MAX]; /**/ + UINT16 wEaCfgLen; /*ݳ*/ + + NonAutoReturnConfigDataStruct NonAutoReturnCfgDataSt[NON_AUTO_RETURN_SUM_MAX]; /*۷*/ + UINT16 NonReturnCfgSum; /*۷ť*/ + + SGBJConfigDataStruct SGBJCfgDataStru[SGBJ_SUM_MAX]; /*ⱨ*/ + UINT16 wSGBJCfgLen; /*ⱨ*/ +} dquCIConfigDataStr; + + +extern dquCIConfigDataStr dquCICfgDtStr; + + +/********************************************* +*ܣʼ̵ݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayConfigDataStructInit(CHAR* FSName); + +/********************************************* +*ܣʼιղ̵ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayPhySecFaultLockZCStruInit(CHAR* FSName); + +/********************************************* +*ܣʼϵͳݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SystemParameterStructInit(CHAR* FSName); + +/********************************************* +*ܣȡźŻ +*˵pRelaySgnl̵źŻṹָ + pSgnlDSUźŻṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 getSignalType(Relay_SignalStruct* pRelaySgnl,DSU_SIGNAL_STRU* pSgnl); + +/********************************************* +*ܣźŻṹźŻ̵ṹ +*˵pSgnlDSUźŻݽṹָ + pSgnlCfgDtStrźŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SglCfgDtStruFromDquSignalStr(DSU_SIGNAL_STRU* pSgnl,SignalConfigDataStruct* pSgnlCfgDtStr); + +/********************************************* +*ܣʼźŻ̵ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SignalConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣϴ +*˵relayWashMachineStruct:ϴ̵ṹָ + pWashMachineCfgDtStr:ϴýṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 WashMachineCfgDtStruFromDquStr(Relay_WashMachineStruct * relayWashMachineStruct,WashMachineConfigDataStruct* pWashMachineCfgDtStr); + +/********************************************* +*ܣʼϴ̵ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 WashMachineConfigDataStructInit(CHAR * FSName); + + + +/********************************************* +*ܣӵṹ̵ṹ +*˵pPoint̵ṹָ + pSwitchCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SwitchCfgDtStruFromDquPointStr(DSU_POINT_STRU* pPoint,SwitchConfigDataStruct* pSwitchCfgDtStr); + +/* zt ɾش 2022-02-15 */ + + +/********************************************* +*ܣʼ̵ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SwitchConfigDataStructInit(CHAR * FSName); + + + +/********************************************* +*ܣνṹμ̵ṹ +*˵pPhysicalSgmtνṹָ + pPsclSgmtCfgDtStrݽṹָ + pSgnlCfgDtStrźŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PhySgmtCfgDtStruFromDquSgmtStr(DSU_PHYSICAL_SGMT_STRU* pPhysicalSgmt,PhysicalSectionConfigDataStruct* pPsclSgmtCfgDtStr,SignalConfigDataStruct* pSgnlCfgDtStr); +/********************************************* +*ܣʼμ̵ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PsclSgmtConfigDataStructInit(CHAR * FSName); + + + +/********************************************* +*ܣݽṹ +*˵pAxleSgmtνṹָ + pAxScCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 AxisSecCfgDtStruFromDquSgmtStr(DSU_AXLE_SGMT_STRU* pAxleSgmt,AxisSectionConfigDataStruct* pAxScCfgDtStr); +/********************************************* +*ܣʼݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 AxisSectionConfigDataStructInit(CHAR * FSName); + + +/********************************************* +*ܣ߼ݽṹ +*˵pLogicSgmt߼νṹָ + pLgScCfgDtStr߼ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LogicSecCfgDtStruFromDquSgmtStr(DSU_LOGIC_SGMT_STRU* pLogicSgmt,LogicSectionConfigDataStruct* pLgScCfgDtStr); +/********************************************* +*ܣʼ߼ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LogicSecConfigDataStructInit(CHAR * FSName); + + + + +/********************************************* +*ܣͣťӿݽṹ +*˵pEmergStopESBṹָ + pEsbCfgDtStrESBݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 EsbCfgDtStruFromDquEmergStr(DSU_EMERG_STOP_STRU * pEmergStop,EsbConfigDataStruct* pEsbCfgDtStr); +/********************************************* +*ܣʼͣťӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 EsbConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣݽṹ +*˵pScreenŽṹָ +pPsdCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PsdCfgDtStruFromDquEmergStr(DSU_SCREEN_STRU * pScreen, PsdConfigDataStruct* pPsdCfgDtStr); + +/********************************************* +*ܣʼṹ +*˵pProtectLinkνṹָ + pOvlpCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OverlapCfgDtStruFromDquStr(DSU_PROTECT_LINK_STRU * pProtectLink,OverlapConfigDataStruct* pOvlpCfgDtStr); + +/********************************************* +*ܣʼνӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OverlapConfigDataStructInit(CHAR * FSName); + +/***** +ݼ +*******************/ + +/********************************************* +*ܣʼԶ·ݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 AutoRouteConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣʼԶ۷·ݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 AutoReturnConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣʼ·ӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReverseRouteCfgDtStructInit(CHAR * FSName); + +/********************************************* +*ܣʼϽ·ݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LongRouteConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣǽ·ݽṹ +*˵pLSNoRouteDcStrǽ·ṹָ + pNonRouteCfgDtStrǽ·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 NonRouteCfgDtStruFrmLSStr( LS_NoRouteDcStru * pLSNoRouteDcStr,NonRouteConfigDataStruct * pNonRouteCfgDtStr); + + +/********************************************* +*ܣʼǽ·ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 NonRouteConfigDataStructInit(CHAR * FSName); + + + +/********************************************* +*ܣ· +*˵pLSRouteStr·ṹָ + pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteCfgDtStruFrmLSRouteStr( LS_RouteStruct * pLSRouteStr,RouteConfigDataStruct * pRouteCfgDtStr, OverlapConfigDataStruct* overlapStr); + +/********************************************* +*ܣʼ· +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteConfigDataStructInit(CHAR * FSName); + + +/********************************************* +*ܣнͨŹϵ豸IPȥݣÿ17ݣ +*˵Dataͨ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 TransmitRelationDataStruFrmSZ(UINT16 Data[]); + +/********************************************* +*ܣʼͨŹϵݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 TransmitRelationDataStructInit(CHAR* FSName); + + +/********************************************* +*ܣʼݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PsdConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣʼʾ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 IndicatorConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣʼ̵еĽṹ壬ʼϵͳݡͨݣ +* ʼվźŻ߼/ݡʼ豸̵ݡʼ/߼ݡ +* ʼESBááΡơSPKSݣ +* ʼԶͨ·Զ۷·ȫԶ۷··šϽ··ǽ·ͨŹϵš· +* 豸ȣݡ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayInit(CHAR* FSName); + +/********************************************* +*ܣִ·ʼ +*˵RouteCfgDtStr· + pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteOpposedConfigDataInite(RouteConfigDataStruct * RouteCfgDtStr,RouteConfigDataStruct * pRouteCfgDtStr); + +/********************************************* +*ܣʼȫԶ۷·ݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 AllAutoReturnCfgDtStructInit(CHAR * FSName); + +/********************************************* +*ܣʼŽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GaragedoorConfigDataStructInit(CHAR * FSName); +/********************************************* +*ܣŽӿݽṹ +*˵pGaragedoor ṹָ + pGaragedoorCfgDtStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GaragedoorCfgDtStruFromDquStr(DSU_DEPOT_GATE_STRU * pGaragedoor,GaragedoorConfigDataStruct* pGaragedoorCfgDtStr); + +/* +: ʼ·豸ݽṹ(ṹ) +: CHAR * FSName ļָ +: +ֵ: 0 ʧ + 1 ɹ +*/ +UINT8 DiffLineDevConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣʼŽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 FloodGateConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣʼվźŻ߼ݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OutStationSigRelLogSecStruInit(CHAR* FSName); + +/********************************************* +*ܣʼܿݽṹ +*˵FSNameļָ +*ֵ +*********************************************/ +void CiFunctionSwitchStructInit(CHAR* FSName); + +/********************************************* +*ܣʼݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 CiPatternInit(CHAR* FSName); + +/********************************************* +*ܣʼ豸ݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 VirtualDeviceInit(CHAR* FSName); + +/********************************************* +*ܣʼվźŻļݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OutStationSigRelAxisSecStruInit(CHAR* FSName); + +/********************************************* +*ܣ +*˵pEmapFloodGateStr Žṹָ(ӵͼ) +* pRouteCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 FloodGateCfgDtStruFrmLSStr(DSU_FLOOD_GATE_STRU * pEmapFloodGateStr, FloodGateConfigDataStruct * pFloodGateCfgDtStr); + + +/********************************************* +*ܣϵ +*˵ + pSwitchCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SwitchCfgDtStruFromLSProHostStr(SwitchConfigDataStruct* pSwitchCfgDtStr); + +/********************************************* +*ܣFSӦ䵽ṹ +*˵pSrc FSݽṹָ룬pDesҪֵĽṹָ룬ArrBuffṹԱָ룬realRowCountʵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OcStruFromChar(const UINT8 *pSrc, UINT8 *pDes, const UINT8 *ArrBuff, const UINT16 realRowCount); + +/********************************************* +*ܣȡFSñݣЧ +*˵FSNameļָ룬DataTypeIDͣConfigId + StrArrLenṹ鳤ȣStrLenṹ峤ȣ + pStrҪݵĽṹָ룬ArrBuffṹԱ +*ֵ0ʧܣ +*********************************************/ +UINT8 OCConfigDataStructInit(UINT16* len, CHAR* FSName, UINT32 DataTypeID, UINT32 ConfigId, UINT16 StrArrLen, void* pStr, UINT8* ArrBuff); + +/********************************************* +*ܣʼOC ñ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OCSwitchConfigDataStructInit(CHAR *FSName); + +/********************************************* +*ܣʼOC ñݡOC2.1.6 +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OCSwitchConfigDataStructInit_OLD(CHAR *FSName); + +/********************************************* +*ܣOC źŻ +*˵pDataAddr ݵַpOCSignalCfgStr ocݽṹ壻SwitchIdźŻID +* dataLen ÿֽڳ +*ֵ0ʧܣ1ɹ +*ע +*********************************************/ +void R_OCSignalConfigDataFromChar(UINT8* pDataAddr,UINT16 dataLen); + +/********************************************* +*ܣʼOC źŻñ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OCSignalCfgStrConfDataStruInit(CHAR *FSName); + +/********************************************* +*ܣOCźŻǷλ +*˵źŻID +*ֵ01 +*********************************************/ +UINT8 OcSignalHasBlue(const UINT16 signalId); + +/********************************************* +*ܣʼOC ñ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 OCPhySecConfigDataStructInit(CHAR *FSName); + +/* ȡOc IdId +* ˵ +* UINT16 ocIdoc +* ֵ +* UINT16id +*/ +UINT16 GetCiIdByOcId(UINT16 ocId); + +/********************************************* +*ܣʼվ̨ſݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PscConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣPSCṹPSCṹ +*˵pPointվ̨ſṹָ +pPscCfgDtStrվ̨ſݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PscCfgDtStruFromDquPointStr(DSU_PSC_STRU* pPoint,PscConfigDataStruct* pPscCfgDtStr); + +/********************************************* +*ܣʼԶ·ݽӿݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GroupAutoRouteCfgDtStructInit(CHAR * FSName); + +/********************************************* +*ܣȡOCϵ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReadVirCIWithOCRelationData(CHAR* FSName); +/********************************************* +*ܣʼʹõı +*˵void +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitBaojingdeng_UseVirCI(void); +/* +*ܣݼ̵Id +*˵ݼ̵IDָ +*ֵ0 ʧܣ>0 ɹ +* ̵ݶȡ +*/ +UINT8 GetBelongVirCiByRelayId(UINT16 relayId ); + +/* +*ܣȡdsuϢ +*˵const UINT16 linkId LINKID + UINT16 *LinkIndex LinkIndex +*ֵCI_SUCCESSɹ +* CI_ERROR ʧ +*/ +UINT8 GetDsuLinkIndexNum(const UINT16 linkId,UINT16 *pLinkIndex); + +/********************************************* +*ܣȡźŻ븴ʾźŻϵ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReadSigWithFushiSigRelatData(CHAR* FSName); + +/********************************************* +*ܣȡSPKSϽSPKSϵ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReadTotalSpksWithSpksRelatData(CHAR* FSName); + +/* +*ܣ·߼ݳʼ +*˵pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*/ +UINT8 RouteConfigDataStruLogDataInit(RouteConfigDataStruct * pRouteCfgDtStr, LS_RouteStruct * pLSRouteStr); + +/* +*ܣ߼ +*˵pSwitchStr ӵͼṹָ +* pSwitchCfgDtStr ýṹָ +*ֵ0ʧܣ1ɹ +*/ +UINT8 SwitchCfgLogTrackInitDquStr(DSU_POINT_STRU* pSwitchStr,SwitchConfigDataStruct* pSwitchCfgDtStr); + +/********************************************* +*ܣLINKݽṹ +*˵pLink LINKṹָ +pLinkScCfgDtStr LINKݽṹָ +*ֵ0ʧܣ1ɹ +* 2022.3.8 +*********************************************/ +UINT8 LinkCfgDtStruFromDquLinkStr(DSU_LINK_STRU* pLink, LinkDataConfigStru* pLinkScCfgDtStr); + +/********************************************* +*ܣʼLINKݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +* 2022.3.8 +*********************************************/ +UINT8 LinkConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣݽṹ +*˵pAxis ṹָ +pAxisCfgDtStr ݽṹָ +*ֵ0ʧܣ1ɹ +* 2022.3.11 +*********************************************/ +UINT8 AxisCfgDtStruFromDquAxisStr(DSU_AXLE_STRU* pAxis, AxisConfigStru* pAxisCfgDtStr); + +/********************************************* +*ܣʼݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +* 2022.3.11 +*********************************************/ +UINT8 AxisConfigDataStructInit(CHAR * FSName); + +/* +: ʼֽ豸ݽṹ(ṹ) +: CHAR * FSName ļָ +: +ֵ: 0 ʧ +1 ɹ +*/ +UINT8 CutoffPointConfigDataStructInit(CHAR * FSName); + +/* +: ʼ߱豸ݽṹ(ṹ) +: CHAR * FSName ļָ +: +ֵ: 0 ʧ +1 ɹ +*/ +UINT8 LinkLineConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣʼ豸ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReverseCutConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣ豸ݽṹ +*˵pLogicSgmt߼νṹָ +pLgScCfgDtStr߼ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReverseCutCfgDtStruFromDquStr(Relay_ReverseCutStruct* pReverseCutRelay, ReverseCutCfgDataStru* pReverseCutCfgDtStr); + +/********************************************* +*ܣʼTIOCATS豸ݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GatewayConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣͬһ·Σڱ·Ҳڵ߼+ +* ͬһ߼Σڱ·߼γʼ +*˵pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteOutLgcSecConfigDataInit(RouteConfigDataStruct * pRouteCfgDtStr); + +/********************************************* +*ܣ豸ݽṹ +*˵pLogicSgmt߼νṹָ +pLgScCfgDtStr߼ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ReadGatewayDeviceCfgDtStru(DquGatewayDeviceStruct* pGatewayDeviceRelay, TransmitRelationDataStruct* pTrsmtRlsDtStr); + +/********************************************* +*ܣݽṹ +*˵pEa ṹָ +pEaCfgDtStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 EaConfigDataStruFromDquEaStr(DSU_EMAP_EA_STRU* pEa, EaConfigStru* pEaCfgDtStr); + +/********************************************* +*ܣʼݽṹ----ṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 EaConfigDataStructInit(CHAR * FSName); + +/********************************************* +*ܣOC ñ +*˵pDataAddr ݵַ +*ֵ0ʧܣ1ɹ +*עcgh-ϲCID-2539-5޸ijʼOC_ݱСģñźŻģñģñijʼʽijʼʽһ +*********************************************/ +void R_OCSwitchConfigDataFromChar(UINT8* pDataAddr); + +/********************************************* +*ܣ·ӽ·ݳʼ +*˵pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteMainProConfigDataInit(RouteConfigDataStruct* RouteCfgDtStr, RouteConfigDataStruct* pRouteCfgDtStr); + +/********************************************* +*ܣ߼ι·ݳʼ +*˵pRouteCfgDtStr·ݽṹָ pLogCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LogRelateRouteDataInit(RouteConfigDataStruct* RouteCfgDtStr, LogicSectionConfigDataStruct* pLogCfgDtStr); +/********************************************* +*ܣ߼ιݳʼ +*˵pRouteCfgDtStr·ݽṹָ pLogCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LogRelateProSwDataInit(RouteConfigDataStruct* RouteCfgDtStr, LogicSectionConfigDataStruct* pLgScCfgDtStr); + + +/********************************************* +*ܣݵӵͼźŻźŻֶ +*˵pSgnlDSUźŻݽṹָ +* pSgnlCfgDtStrźŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SetSignalFenDuanAttr(DSU_SIGNAL_STRU* pSgnl, SignalConfigDataStruct* pSgnlCfgDtStr); + +/********************************************* +*ܣӵӵͼ߼SPKSṹSPKS̵ID +*˵pSpksDSU߼SPKSݽṹָ +pSpksDataConfigSPKSݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20230919 +*********************************************/ +UINT8 ReadDataFromDquLogSpksData(const DSU_LOGSEC_SPKS_BUTTON_STRU* pSpks, SpksDataConfigStruct* pSpksDataConfig); + +/********************************************* +*ܣӵӵͼSPKSṹSPKS +*˵pSpksDSUSPKSݽṹָ +pSpksDataConfigSPKSݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20230919 +*********************************************/ +UINT8 ReadDataFromDquPhySpksData(const DSU_SPKS_BUTTON_STRU* pSpks, SpksDataConfigStruct* pSpksDataConfig); + +/********************************************* +*ܣζӦSPKSϢ +*˵pPsclSgmtCfgDtStrݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20230919 +*********************************************/ +UINT8 PhysicRelateSpksStr(PhysicalSectionConfigDataStruct* pPsclSgmtCfgDtStr); + +/********************************************* +*ܣʼⱨݽṹ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 SGBJConfigDataStructInit(CHAR* FSName); + +/********************************************* +*ܣ·ⱨݳʼ +*˵RouteConfigDataStruct* pRouteCfgDtStr ·ݽṹָ +* LS_SGBJStruct* pLSSGBJStr ⱨṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RouteRelatedSGBJCfgDataInit(RouteConfigDataStruct* pRouteCfgDtStr, LS_SGBJStruct* pLSSGBJStr); + +/********************************************* +*ܣ·ʽӽ߼ +*˵pLSRouteStr·ṹָ + pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*by cgh 20231014 +*********************************************/ +UINT8 RouteBlocNearLogSecInit(LS_RouteStruct* pLSRouteStr, RouteConfigDataStruct* pRouteCfgDtStr); + + +/********************************************* +*ܣ·һȥ߼ +*˵pLSRouteStr·ṹָ + pRouteCfgDtStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*by cgh 20231014 +*********************************************/ +UINT8 RouteFirstLeaveLogSecInit(LS_RouteStruct* pLSRouteStr, RouteConfigDataStruct* pRouteCfgDtStr); + +/********************************************* +*ܣ·ת·۷źŻidݳʼ +*˵RouteConfigDataStruct* pRouteCfgDtStr ·ݽṹָ +* LS_TransRouteZFSigStruct* pTransRouteZFSigStruc ת·۷źŻidṹָ +*ֵ0ʧܣ1ɹ +*Create fan 20240725 +*********************************************/ +UINT8 RouteRelatedTransZFSigInit(RouteConfigDataStruct* pRouteCfgDtStr, LS_TransRouteZFSigStruct* pTransRouteZFSigStruct); + +/********************************************* +*ܣAG LINKǷڹCGԼ +*˵pLinkScCfgDtStr LINKݽṹָ +*ֵ0ʧܣ1ɹ +* by cgh 20240821 +*********************************************/ +UINT8 AgLinkExistRelCGFlagCalc(LinkDataConfigStru* pLinkScCfgDtStr); + +/********************************************* +*ܣBGlinkAGlink +*˵LinkDataConfigStru* pLinkScCfgDtStr LINKݽṹָ +* ֵ0 ʧ +* 1 ɹ +*Creatd By LQ 2024.08.22 +*********************************************/ +UINT8 BGLinkRelAGLinkCal(LinkDataConfigStru* pLinkScCfgDtStr); + +#endif + diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIInterFace.c b/TSCP/src/APP/ciapp/QueryFiles/dquCIInterFace.c new file mode 100644 index 0000000..d3be220 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIInterFace.c @@ -0,0 +1,4562 @@ +/************************************************************************ +* +* ļ dquCIInterFace.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* CIݽӿڴ +* ʹע +* ޸ļ¼ 20150723޸ReadRouteConfigData()ֻȡڱĽ· +* +************************************************************************/ +#include "dquCIInterFace.h" +#include "commonQueryStruDef.h" +#include "dquCbtcType.h" +#include "dquIdmapQuery.h" +#include "dsuEmapDefine.h" +#include "LinkConfigDataManage.h" +#include "dsuRssp2Func.h" +#include "CommonMemory.h" +#include "Convert.h" +#include "dfsDataRead.h" +#include "dquDataTypeDefine.h" +#include "dquIdmapInit.h" +#include "dfsDataRead.h" +#include "SystemParameterManage.h" +#include "../Initial/InitialProcess.h" +#include "dquIdmapQuery.h" + +/********************************************* +*ܣΪCIʹõĹݸֵ +*˵dsuEmapStru ӵͼܽṹ +*ֵ +*********************************************/ +static void CIInitEmap(DSU_EMAP_STRU dsuEmapStruPar); +/********************************************* +*ܣʼ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +/**************************************************************************************** + + ܣҳlinkα + ڲUINT16 wLinkId linkIDϢ + ڲ + ֵ ѯʧ:0xffff;ѯɹIDϢ + 㷨 1αҹΣҵlink +*******************************************************************************************/ +static UINT16 FindLinkBelongAxleSgmt(UINT16 wLinkId); + +UINT8 InitAll(CHAR* FSName) +{ + UINT8 RtnVal = 0u; + UINT8 cFunRetVal = 0u; + + UINT8 szFSFILEVersionFS[DFS_VERSION_LENGTH] = { 0U }; + + UINT8 szFSPUBVersionFS[DFS_VERSION_LENGTH] = { 0U }; + + UINT8 szFSPRIVVersionFS[DFS_VERSION_LENGTH_PRIV] = { 0U }; + + UINT8 szFSOCVersionFS[DFS_VERSION_LENGTH_PRIV] = { 0U }; + + /* ݰ汾ųʼ */ + + /*ӵͼ汾*/ + cFunRetVal = dquGetFSVersion(FSName, szFSFILEVersionFS); + if (1u == cFunRetVal) + { + SetTiocFsVersion(szFSFILEVersionFS); + } + /*ݽṹ汾*/ + cFunRetVal = dquGetPublicFSVersion(FSName, szFSPUBVersionFS); + cFunRetVal &= dquGetPrivateFSVersion(FSName, szFSPRIVVersionFS); + cFunRetVal &= dquGetOcDataFSVersion(FSName, szFSOCVersionFS); + + if (1u == cFunRetVal) + { + RtnVal = CheckTiocPublicFsVersion(szFSPUBVersionFS); + if (CI_SUCCESS == RtnVal) + { + /*˽ݽṹ汾*/ + RtnVal = CheckTiocPrivateFsVersion(szFSPRIVVersionFS); + + if (CI_SUCCESS == RtnVal) + { + /*ݽṹ汾żͨ*/ + + /*OCݽṹ*/ + RtnVal = CheckTiocOcFsVersion(szFSOCVersionFS); + + if (CI_SUCCESS == RtnVal) + { + /*ݽṹ汾żͨ*/ + } + else + { + /*ݴ˰汾OCݽṹ*/ + debug_infor_printf((const)"Error: OC FS Version %d.%d.%d.%d Is Not Compatible\n", szFSOCVersionFS[0], szFSOCVersionFS[1], 0u, 0u); + } + } + else + { + /*ݴ˰汾˽ݽṹ*/ + debug_infor_printf((const)"Error: Private FS Version %d.%d.%d.%d Is Not Compatible\n", szFSPRIVVersionFS[0], szFSPRIVVersionFS[1], 0u, 0u); + } + } + else + { + /*ݴ˰汾ݽṹ*/ + debug_infor_printf((const)"Error: Public FS Version %d.%d.%d.%d Is Not Compatible\n", szFSPUBVersionFS[0], szFSPUBVersionFS[1], szFSPUBVersionFS[2], szFSPUBVersionFS[3]); + + } + } + else + { + /*ȡݽṹͷеİ汾ʧ*/ + debug_infor_printf((const)"Error: Public or Private FS Version Read Faild\n"); + RtnVal = CI_ERROR; + } + if (CI_ERROR != RtnVal) + { + RtnVal = dquSetInitEmapRef(&dsuEmapStru);/*õӵͼ̬ṹ,ָѯ*/ + + RtnVal &= dquSetInitStaticLimitLinkRef(&gg_ppDsuLimitStcLinkIdx);/*þ̬LINKѯʼָ*/ + + RtnVal &= dquSetInitEmapExtendRef(&dsuEmapExtendStru); + + RtnVal &= dfsEmapInit(FSName);/*ӵͼʼ*/ + } + + if (0u != RtnVal) + { + CIInitEmap(dsuEmapStru);/*ΪCIʹõĹݸֵ*/ + + RtnVal = CiPatternInit(FSName); /*ʼǰ*/ + if (0u != RtnVal) /*ʼǰ*/ + { + /*ʼϵͳݽṹ*/ + /*ʼ*/ + InitLocalCIHaveVirCI_UseVirCI(); + /**/ + CiFunctionSwitchStructInit(FSName); + if (1u != ReadCiFuncSwitchConfigData(CiFuncSwitConfStruNew)) + { + RtnVal = 0u; + } + RtnVal *= RelayInit(FSName); + if (0u != RtnVal) + { + RtnVal *= MaskInit(FSName); + if (0u == RtnVal) + { +#ifdef PLATFORM_2OO2 + + (void)printf("Mask Init Error\n"); + debug_infor_printf((const)"Mask Init Error\n"); +#endif + } + CheckOverlapMaskBit();/*鱣λ*/ + } + else + { +#ifdef PLATFORM_2OO2 + + (void)printf("Relay Init Error\n"); + debug_infor_printf((const)"Relay Init Error\n"); +#endif + } + } + else + { +#ifdef PLATFORM_2OO2 + (void)printf("CiPattern Init Error\n"); + debug_infor_printf((const)"CiPattern Init Error\n"); +#endif + } + } + else + { +#ifdef PLATFORM_2OO2 + + (void)printf("Emap Init Error\n"); + debug_infor_printf((const)"Emap Init Error\n"); +#endif + } + return RtnVal; +} + +/********************************************* +*ܣ鱣λ + ͬһ·бλһ +*˵ +*ֵ +*********************************************/ +void CheckOverlapMaskBit(void) +{ + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 k = 0u; + UINT16 overlapId = 0u; + UINT16 overlapIdNext = 0u; + UINT16 overlapIdMax = 0u;/*󱣻id*/ + + UINT16 cizc_Overlap_maskId = 0u; + UINT16 cizc_Overlap_maskId_next = 0u; + UINT8 ciId = 0u; + UINT8 flag1=0u; + UINT8 flag2 =0u; + UINT8 flagMax = 0u; + UINT16 maskId = 0u; + UINT16 maskIdNext = 0u; + for(i=0u;iBelongCiId; + if (2u <= pRouteCfgDtStr->OverlapSum )/*ڵ2*/ + { + overlapIdMax = pRouteCfgDtStr->OverlapIdBuf[0]; + for (j=1u;jOverlapSum;j++) + { + if (pRouteCfgDtStr->OverlapIdBuf[j] > overlapIdMax) + { + overlapIdMax = pRouteCfgDtStr->OverlapIdBuf[j]; + } + else + { + } + } + + /*ȡÿεıţӦCI-ZCλ*/ + for (j=0u;jOverlapSum-1u;j++) + { + if (pRouteCfgDtStr->OverlapIdBuf[j] < pRouteCfgDtStr->OverlapIdBuf[j+1u]) + { + overlapId = pRouteCfgDtStr->OverlapIdBuf[j]; + overlapIdNext = pRouteCfgDtStr->OverlapIdBuf[j+1u]; + } + else + { + overlapId = pRouteCfgDtStr->OverlapIdBuf[j+1u]; + overlapIdNext = pRouteCfgDtStr->OverlapIdBuf[j]; + + } + + flag1 = 0u; + flag2 = 0u; + flagMax = 0u; + for (k=0u;k<=ConfigCiToZcMaskIdMax[ciId];k++) + { + if ((ConfigCiToZcMaskConfigDataStru[ciId][k].DeviceId == overlapId) + && (ConfigCiToZcMaskConfigDataStru[ciId][k].DeviceType == CI_DEVICE_TYPE_OVERLAP) + && (ConfigCiToZcMaskConfigDataStru[ciId][k].MaskType == MASK_TYPE_OVERLAP_LOCKSTATE)) + { + flag1 = 1u; + maskId = ConfigCiToZcMaskConfigDataStru[ciId][k].MaskId; + } + else + { + } + + if ((ConfigCiToZcMaskConfigDataStru[ciId][k].DeviceId == overlapIdNext) + && (ConfigCiToZcMaskConfigDataStru[ciId][k].DeviceType == CI_DEVICE_TYPE_OVERLAP) + && (ConfigCiToZcMaskConfigDataStru[ciId][k].MaskType == MASK_TYPE_OVERLAP_LOCKSTATE)) + { + flag2 = 1u; + maskIdNext = ConfigCiToZcMaskConfigDataStru[ciId][k].MaskId; + } + else + { + } + + if ((ConfigCiToZcMaskConfigDataStru[ciId][k].DeviceId == overlapIdMax) + && (ConfigCiToZcMaskConfigDataStru[ciId][k].DeviceType == CI_DEVICE_TYPE_OVERLAP) + && (ConfigCiToZcMaskConfigDataStru[ciId][k].MaskType == MASK_TYPE_OVERLAP_LOCKSTATE)) + { + flagMax = 1u; + } + else + { + } + + if ((1u==flag1) && (1u==flag2)) + { + if (maskId != maskIdNext) + { + /*ͬһ·CI-ZCλȣ򷢴֡*/ + debug_infor_printf((const)"Route %d overLaps: %d and %d mask not same.",pRouteCfgDtStr->RouteId,overlapId,overlapIdNext); + DebugPrintAppError(ERROR_ONEROUTE_OVERLAP_CIZCMASK_NOT_SAME,pRouteCfgDtStr->RouteId,((UINT32)overlapId<<16u)+overlapIdNext,PRINT_ONCE); + } + else + { + } + break; + } + else + { + } + } +#if 0 + if (0u == flag1) + { + debug_infor_printf((const)"Route %d overLap %d CI-ZC mask not config",pRouteCfgDtStr->RouteId,overlapId); + DebugPrintAppError(ERROR_ROUTE_OVERLAP_CIZCMASK_NOT_CONFIG,CI_DEVICE_TYPE_OVERLAP,((pRouteCfgDtStr->RouteId) <<16u)+overlapId,PRINT_ONCE); + } + else + { + } +#endif + if (0u==flagMax) + { + debug_infor_printf((const)"Route %d overLap %d CI-ZC mask not config",pRouteCfgDtStr->RouteId,overlapIdMax); + DebugPrintAppError(ERROR_ROUTE_OVERLAP_CIZCMASK_NOT_CONFIG,CI_DEVICE_TYPE_OVERLAP,(((UINT32)pRouteCfgDtStr->RouteId) <<16u)+overlapIdNext,PRINT_ONCE); + } + else + { + } + } + } + else + { + } + + } +} + +/********************************************* +*ܣ̵ +*˵ciIdID pRelayConfigDataStru̵ݽṹָ +*̵ֵ +*********************************************/ +INT16 ReadRelayConfigData(const UINT8 ciId,RelayConfigDataStruct* pRelayConfigDataStru) +{ + UINT16 i=0u; + INT16 DataNum = 0; + + if ((0u == ciId) || (NULL == pRelayConfigDataStru)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + if (0 == DataNum) + { + for(i=0u;isignalVirtualAttr) == SIGNAL_VIRTUAL_NO) + {/*ΪźŻ*/ + switch (pSgnl->SignalType) + { + case SIGNAL_TYPE_THREE_ALL_YINDAO:/*̵LX YD 1DS 2DS*/ + case SIGNAL_TYPE_THREE_NOGREEN_YINDAO: + case SIGNAL_TYPE_THREE_NOYELLOW_YINDAO: + case SIGNAL_TYPE_THREE_ALL_YINDAO_NOY: + case SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->YxRelayId) + { + debug_infor_printf((const)"Signal %d YDJ %d not config",pSgnl->SignalId,pSgnl->YxRelayId); + DebugPrintAppError(ERROR_SIGNAL_YDJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->SecDsRelayId) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->SecDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_2DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + break; + } + case SIGNAL_TYPE_THREE_ALL_NOYINDAO: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->ZxRelayId) + { + debug_infor_printf((const)"Signal %d ZXJ %d not config",pSgnl->SignalId,pSgnl->ZxRelayId); + DebugPrintAppError(ERROR_SIGNAL_ZXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + + case SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO: + case SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO: + case SIGNAL_TYPE_TWO_ALL_NOYINDAO: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + + + + + case SIGNAL_TYPE_TWO_NOGREEN_NOYINDAO: + { + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_DIAOCHE: + { + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_JINKUCHUKU: + { + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + + + case SIGNAL_TYPE_TWO_JINKU_RGY: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->YxRelayId) + { + debug_infor_printf((const)"Signal %d YDJ %d not config",pSgnl->SignalId,pSgnl->YxRelayId); + DebugPrintAppError(ERROR_SIGNAL_YDJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_THREE_JINKU_YINDAO: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->YxRelayId) + { + debug_infor_printf((const)"Signal %d YDJ %d not config",pSgnl->SignalId,pSgnl->YxRelayId); + DebugPrintAppError(ERROR_SIGNAL_YDJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->SecDsRelayId) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->SecDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_2DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_THREE_DIAOCHE_YINDAO: + { + if (0u == pSgnl->YxRelayId) + { + debug_infor_printf((const)"Signal %d YDJ %d not config",pSgnl->SignalId,pSgnl->YxRelayId); + DebugPrintAppError(ERROR_SIGNAL_YDJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->SecDsRelayId) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->SecDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_2DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_4_ALL_NOYINDAO_ZX: + { + if (0u == pSgnl->DdRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->DdRelayId); + DebugPrintAppError(ERROR_SIGNAL_DDJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->ZxRelayId) + { + debug_infor_printf((const)"Signal %d ZXJ %d not config",pSgnl->SignalId,pSgnl->ZxRelayId); + DebugPrintAppError(ERROR_SIGNAL_ZXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->SecDsRelayId) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->SecDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_2DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->GreenRelayId_wh) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->GreenRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_GREENJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->YellowRelayId_wh) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->YellowRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_YELLOWJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->BlueDsRelayId_wh) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->BlueDsRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_BLUEJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + break; + } + case SIGNAL_TYPE_4_NOGREEN_NOYINDAO_ZX: + { + if (0u == pSgnl->DdRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->DdRelayId); + DebugPrintAppError(ERROR_SIGNAL_DDJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->BlueDsRelayId_wh) + { + debug_infor_printf((const)"Signal %d BlueDJ %d not config",pSgnl->SignalId,pSgnl->BlueDsRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_BLUEJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_5_NOGREEN_YINDAO_CD: + { + + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->YxRelayId) + { + debug_infor_printf((const)"Signal %d YDJ %d not config",pSgnl->SignalId,pSgnl->YxRelayId); + DebugPrintAppError(ERROR_SIGNAL_YDJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->SecDsRelayId) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->SecDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_2DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + + break; + } + case SIGNAL_TYPE_5_NOY_NOYINDAO_CD: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->ZxRelayId) + { + debug_infor_printf((const)"Signal %d ZXJ %d not config",pSgnl->SignalId,pSgnl->ZxRelayId); + DebugPrintAppError(ERROR_SIGNAL_ZXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->SecDsRelayId) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->SecDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_2DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_4_ALL_NOYINDAO_CD: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->GreenRelayId_wh) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->GreenRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_GREENJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_5_NOY_NOYINDAO_WB: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->SecDsRelayId) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->SecDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_2DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_3_RGG_CD: + case SIGNAL_TYPE_3_RGG_NOGREEN_CD: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + + case SIGNAL_TYPE_3_NOGREENWHITE_CD: + { + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_4_ALL_NOYINDAO_NOYELLOWONLY_ZX: + { + if (0u == pSgnl->DdRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->DdRelayId); + DebugPrintAppError(ERROR_SIGNAL_DDJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->GreenRelayId_wh) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->GreenRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_GREENJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->BlueDsRelayId_wh) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->BlueDsRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_BLUEJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->SecDsRelayId) + { + debug_infor_printf((const)"Signal %d 2DJ %d not config",pSgnl->SignalId,pSgnl->SecDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_2DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_4_NOGREENBLUE_NOYINDAO_ZX: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_3_ALL_NOYINDAO_CD: + { + if (0u == pSgnl->LxRelayId) + { + debug_infor_printf((const)"Signal %d LXJ %d not config",pSgnl->SignalId,pSgnl->LxRelayId); + DebugPrintAppError(ERROR_SIGNAL_LXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->DxRelayId) + { + debug_infor_printf((const)"Signal %d DXJ %d not config",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + case SIGNAL_TYPE_1_ALL_END: + { + if (0u == pSgnl->FirDsRelayId) + { + debug_infor_printf((const)"Signal %d 1DJ %d not config",pSgnl->SignalId,pSgnl->FirDsRelayId); + DebugPrintAppError(ERROR_SIGNAL_1DJ_NOT_CONFIG,CI_DEVICE_TYPE_SIGNAL,(UINT32)pSgnl->SignalId,PRINT_ONCE); + } + else + { + } + break; + } + default: + /*ɴ֧*/ + break; + } + + if (pSgnl->YxRelayId>0u) + { + collMode = GetRelayCollectMode(pSgnl->YxRelayId); + if (collMode != RELAY_COLL_MODE_DOUBLE) + { + debug_infor_printf((const)"Signal %d YXJ %d not double-coll mode.",pSgnl->SignalId,pSgnl->YxRelayId); + DebugPrintAppError(ERROR_SIGNAL_YXJ_NOT_DOUBLE_COLL,CI_DEVICE_TYPE_RELAY,(((UINT32)pSgnl->SignalId<<16u)+pSgnl->YxRelayId),PRINT_ONCE); + } + else + { + } + } + else + { + } + + if (pSgnl->DxRelayId>0u) + { + collMode = GetRelayCollectMode(pSgnl->DxRelayId); + if (collMode != RELAY_COLL_MODE_DOUBLE) + { + debug_infor_printf((const)"Signal %d DXJ %d not double-coll mode.",pSgnl->SignalId,pSgnl->DxRelayId); + DebugPrintAppError(ERROR_SIGNAL_DXJ_NOT_DOUBLE_COLL,CI_DEVICE_TYPE_RELAY,(((UINT32)pSgnl->SignalId<<16u)+pSgnl->DxRelayId),PRINT_ONCE); + } + else + { + } + } + else + { + } + + if (pSgnl->GreenRelayId_wh>0u) + { + collMode = GetRelayCollectMode(pSgnl->GreenRelayId_wh); + if (collMode != RELAY_COLL_MODE_DOUBLE) + { + debug_infor_printf((const)"Signal %d GREENJ %d not double-coll mode.",pSgnl->SignalId,pSgnl->GreenRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_GREENJ_NOT_DOUBLE_COLL,CI_DEVICE_TYPE_RELAY,(((UINT32)pSgnl->SignalId<<16u)+pSgnl->GreenRelayId_wh),PRINT_ONCE); + } + else + { + } + } + else + { + } + + if (pSgnl->YellowRelayId_wh>0u) + { + collMode = GetRelayCollectMode(pSgnl->YellowRelayId_wh); + if (collMode != RELAY_COLL_MODE_DOUBLE) + { + debug_infor_printf((const)"Signal %d YELLOWJ %d not double-coll mode.",pSgnl->SignalId,pSgnl->YellowRelayId_wh); + DebugPrintAppError(ERROR_SIGNAL_YELLOWJ_NOT_DOUBLE_COLL,CI_DEVICE_TYPE_RELAY,(((UINT32)pSgnl->SignalId<<16)+pSgnl->YellowRelayId_wh),PRINT_ONCE); + } + else + { + } + } + else + { + } + } + } + + pSignalConfigDataStru[dquCICfgDtStr.SgnlCfgDtStr[i].SignalId].signalProSecSum = 0u;/*ɳʼ*/ + } + else + { + /*ʧ*/ + DataNum = -1; + break; + } + + } + } + + if (DataNum >= 0) + { + /*ݵӵͼ·ݣҽ·նźŻı*/ + for (i = 0u;i < dsuDataLenStru.wRouteLen;i++) + { + tempRouteRecord = dsuStaticHeadStru.pRouteStru[i]; + tempSigCfgDataPtr = &(pSignalConfigDataStru[tempRouteRecord.wEndSignalId]); + + for (j = 0u;j < tempRouteRecord.wProtectLinkNum;j++) + { + tempProSec = tempRouteRecord.wProtectLinkId[j]; + if ((tempProSec != 0u) && (tempProSec != UINT16_MAX)) + { + for (k = 0u;k < tempSigCfgDataPtr->signalProSecSum;k++) + { + if (tempProSec == tempSigCfgDataPtr->signalProSecBuf[k]) + { + /*˵ñѾӹ*/ + break; + } + else + { + } + } + + if (k == tempSigCfgDataPtr->signalProSecSum) + { + /*˵ñûбӹ*/ + tempSigCfgDataPtr->signalProSecBuf[tempSigCfgDataPtr->signalProSecSum] = tempProSec; + tempSigCfgDataPtr->signalProSecSum = tempSigCfgDataPtr->signalProSecSum + 1u; + } + else + { + } + } + else + { + } + } + } + } + else + { + } + + + return DataNum; +} + +/********************************************* +*ܣϴ +*˵ciIdID +pWashMachineConfigDataStruϴݽṹָ +*ֵ ϴ +*********************************************/ +UINT16 ReadWashMachineConfigData(const UINT8 ciId,WashMachineConfigDataStruct* pWashMachineConfigDataStru) +{ + UINT16 i=0u; + UINT16 DataNum = 0u; + + if ((0u == ciId) || (NULL == pWashMachineConfigDataStru)) + { + DataNum = 0u; + } + else + { + for(i = 0u;i < dquCICfgDtStr.WashMachineCfgDtStrLen;i++) + { + if (ciId == dquCICfgDtStr.WashMachineCfgStr[i].BelongCiId) + { + /*鲻Խ磬Խֱӷʧ*/ + if(dquCICfgDtStr.WashMachineCfgStr[i].WashMachineId < WASHMACHINE_SUM_MAX) + { + pWashMachineConfigDataStru[dquCICfgDtStr.WashMachineCfgStr[i].WashMachineId] = dquCICfgDtStr.WashMachineCfgStr[i]; + DataNum++; + + } + else + { + /*ʧ*/ + break; + } + } + } + if(i < dquCICfgDtStr.WashMachineCfgDtStrLen) + { + DataNum = 0u; + } + + } + return DataNum; +} + +/********************************************* +*ܣ +*˵ciIdID pSwitchConfigDataStruݽṹָ +*ֵ +*********************************************/ +INT16 ReadSwitchConfigData(const UINT8 ciId,SwitchConfigDataStruct* pSwitchConfigDataStru) +{ + UINT16 i=0u; + INT16 DataNum = -1; + UINT16 logIndex = 0U; + UINT8 swIndex = 0U; + UINT16 switchId = 0U; + + if ((0u == ciId) || (NULL == pSwitchConfigDataStru)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for(i=0u;iwTrackSecNumLen;i++) + { + for (j=0u;jpTrackSecNumStru[i].wTrackNum;j++) + { + if (dsuIdmapStru.dsuStaticIdmapStru->pTrackSecNumStru[i].dwTrackSecId[j]!=0u) + { + Link=dsuIdmapStru.dsuStaticIdmapStru->pTrackSecNumStru[i].wLinkId; + phySec=FindLinkBelongAxleSgmt(Link);/*LinkӦ*/ + if ((phySec!=0U)&&(phySec!=UINT16_MAX)) + { + if ( phySec< PHYSICAL_SECTION_SUM_MAX) + { + retRes = 0; + + if (pPhysicalSectionConfigDataStru[phySec].trackSecNum < PHY_SEC_TRACK_SEC_MAX_SUM) + { + retRes = 0; + } + else + { + retRes = -1; + } + } + else + { + retRes = -1; + } + if (0 == retRes) + { + pPhysicalSectionConfigDataStru[phySec].trackSecBuf[pPhysicalSectionConfigDataStru[phySec].trackSecNum++]=dsuIdmapStru.dsuStaticIdmapStru->pTrackSecNumStru[i].dwTrackSecId[j]; + } + + } + } + } + } + } + } + else + { + retRes = -1; + } + + return retRes; +} +/********************************************* +*ܣ +*˵ciIdID pPhysicalSectionConfigDataStruݽṹָ +*ֵ +*********************************************/ +INT16 ReadPhySicalSectionConfigData(const UINT8 ciId,PhysicalSectionConfigDataStruct* pPhysicalSectionConfigDataStru) +{ + UINT16 i=0u; + INT16 DataNum = -1; + DSU_ROUTE_STRU tempRouteRecord = { 0u }; + UINT16 j = 0u, k = 0u, m = 0u; + UINT16 tempProSec = 0u;/*IDʱ*/ + UINT16 tempPhySec = 0u;/*IDʱ*/ + UINT16 tempAxleSec = 0u;/*IDʱ*/ + UINT16 gdIndex = 0u; + DSU_PROTECT_LINK_STRU tempDsuProStru = { 0u }; + PhysicalSectionConfigDataStruct *tempPhySecCfgDataPtr = NULL; + UINT16 logIndex = 0u; + UINT8 logsecSum = 0U; + + if ((0u == ciId) || (NULL == pPhysicalSectionConfigDataStru)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for(i=0u;i= 0) + { + /*ݵӵͼ·ݣʼζӦĽ·ID*/ + for (i = 0u;i < dsuDataLenStru.wRouteLen;i++) + { + tempRouteRecord = dsuStaticHeadStru.pRouteStru[i]; + + for (j = 0u;j < tempRouteRecord.wProtectLinkNum;j++) + { + tempProSec = tempRouteRecord.wProtectLinkId[j]; + + if ((tempProSec != 0u) && (tempProSec != UINT16_MAX)) + { + tempDsuProStru = dsuStaticHeadStru.pProtectLinkStru[dsuProtectLinkIndex[tempProSec]]; + for (k = 0u;k < tempDsuProStru.wIncludeAxleSgmtNum;k++) + { + tempAxleSec = tempDsuProStru.wIncludeAxleSgmtId[k]; + if ((tempAxleSec != 0u) && (tempAxleSec != UINT16_MAX)) + { + tempPhySec = dsuStaticHeadStru.pAxleSgmtStru[dsuAxleSgmtIndex[tempAxleSec]].wRelatePhysicalSgmtId;/*ҵӦ*/ + tempPhySecCfgDataPtr = &(pPhysicalSectionConfigDataStru[tempPhySec]); + for (m=0u;mproLockRouteSum;m++) + { + if (tempRouteRecord.wId == tempPhySecCfgDataPtr->proLockRouteIdBuf[m]) + { + /*˵·Ѿ*/ + break; + } + } + + if (m == tempPhySecCfgDataPtr->proLockRouteSum) + { + if (tempPhySecCfgDataPtr->proLockRouteSum < PHY_SEC_PRO_LOCK_ROUTE_MAX_NUM) + {/*±αնӦĽ·IDС*/ + /*˵·ûб*/ + tempPhySecCfgDataPtr->proLockRouteIdBuf[tempPhySecCfgDataPtr->proLockRouteSum] = tempRouteRecord.wId; + tempPhySecCfgDataPtr->proLockRouteSum = tempPhySecCfgDataPtr->proLockRouteSum + 1u; + } + else + { + debug_infor_printf((const)"Physec %d proLockRouteSum exceed MACRO %d\r\n", + tempPhySecCfgDataPtr->PhysicalSectionId, + PHY_SEC_PRO_LOCK_ROUTE_MAX_NUM); + } + } + } + } + } + } + } + } + + + return DataNum; +} + +/********************************************* +*ܣ +*˵ciIdID pAxisSectionConfigDataStruݽṹָ +*ֵ +*********************************************/ +INT16 ReadAxisSectionConfigData(const UINT8 ciId,AxisSectionConfigDataStruct* AxisSectionConfigDataSt, UINT16 * pAcNum, AxisSectionConfigDataStruct * pAcConfigDataStru) +{ + UINT16 i=0u; + INT16 DataNum = -1; + UINT16 j = 0u; + UINT8 cLinkLineAttr = RC_LINK_LINE_NO; + UINT8 cFuncRet = CI_ERROR; + + if ((0u == ciId) || (NULL == AxisSectionConfigDataSt)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for(i=0u;i i) + { + bjdYouXiao = RelayData.pRelayBjdStr[i].wBjdYouXiao; + if((ciId == RelayData.pRelayBjdStr[i].wBelongCiId)&&((0xAAu == bjdYouXiao)||(0xBBu == bjdYouXiao)||(0xDDu == bjdYouXiao))) + { + /*鲻Խ磬Խֱӷʧ*/ + if(dquCICfgDtStr.IndctCfgDtStr[i].IndicatorId < INDICATOR_SUM_MAX) + { + IndicatorConfigDataSt[dquCICfgDtStr.IndctCfgDtStr[i].IndicatorId] = dquCICfgDtStr.IndctCfgDtStr[i]; + DataNum++; + } + else + { + /*ʧ*/ + DataNum = -1; + break; + } + } + } + } + } + + return DataNum; +} +/********************************************* +*ܣָʾƱ +*˵ciIdIDIndicatorConfigDataStru ָʾݽṹָ +*ֵ +*********************************************/ +INT16 ReadIndicatorConfigData_Vir(const UINT8 ciId, const UINT8 virCIid,IndicatorConfigDataStruct* pIndicatorConfigDataStru) +{ + UINT16 i=0u; + INT16 DataNum = -1; + UINT8 bjdYouXiao = 0u; + + + if ((0u == ciId) || (NULL == pIndicatorConfigDataStru)||(0u == virCIid)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + if (0 == DataNum) + { + for(i=0u;i dquCICfgDtStr.IndctCfgDtStr[i].IndicatorId) + { + pIndicatorConfigDataStru[dquCICfgDtStr.IndctCfgDtStr[i].IndicatorId] = dquCICfgDtStr.IndctCfgDtStr[i]; + DataNum++; + } + else + { + /*ʧ*/ + DataNum = -1; + break; + } + } + + } + } + + return DataNum; +} +/********************************************* +*ܣ +*˵ciIdIDpOverlapConfigDataStru ݽṹָ, +*ֵ +*********************************************/ +INT16 ReadOverlapConfigData(const UINT8 ciId,OverlapConfigDataStruct* pOverlapConfigDataStru) +{ + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 k = 0u; + INT16 DataNum = -1; + UINT16 RouteOverlapSum = 0u; + UINT16 CurOverlapId = 0u; + + if ((0u == ciId) || (NULL == pOverlapConfigDataStru)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for(i=0u;i= 0) + { + /*·кеıγʼ*/ + for(i=0u;i 0u) + { + for(j = 0u; j < RouteOverlapSum; j++) + { + CurOverlapId = dquCICfgDtStr.RouteCfgDtStr[i].OverlapIdBuf[j]; + if((pOverlapConfigDataStru[CurOverlapId].BelongCiId!= ciId) + &&(pOverlapConfigDataStru[CurOverlapId].OverlapId!= CurOverlapId)) + {/*δʼı*/ + for(k=0u;k= CI_SYSTEM_PARA_SUM_MAX) + { + rtnVal = 0u; + break; + } + paraId = dquCICfgDtStr.SystemParaStrNew.ParaStru[i].SysParaId; + if (paraId < CI_SYSTEM_PARA_SUM_MAX) + { + SystemParameterStru->ParaStru[paraId] = dquCICfgDtStr.SystemParaStrNew.ParaStru[i]; + } + else + { + rtnVal = 0u; + break; + } + + } + if (1u == rtnVal) + { /*ӹѯ*/ + /*ƶߴٶȣλdfsInitSubSystemCommonConfigData_CCת*/ + SystemParameterStru->MaxLineLimitSpeed = dquCICfgDtStr.SystemParaStrNew.MaxLineLimitSpeed; + + /*ʱ(km/h)δеλת*/ + SystemParameterStru->MaxTsrSpeed = dquCICfgDtStr.SystemParaStrNew.MaxTsrSpeed; + + /*NTPУʱʱСʱ*/ + SystemParameterStru->TimeZoneDifference = dquCICfgDtStr.SystemParaStrNew.TimeZoneDifference; + + /*ͬʻ˫Сȫ(cm))*/ + SystemParameterStru->MABackDistance = dquCICfgDtStr.SystemParaStrNew.MABackDistance; + + /*һõʱ*/ + SystemParameterStru->MaxTsrNum = dquCICfgDtStr.SystemParaStrNew.MaxTsrNum; + + /*һʱٱа*/ + SystemParameterStru->MaxSectionOfTsr = dquCICfgDtStr.SystemParaStrNew.MaxSectionOfTsr; + + /*IVOC-IVOCŹжʱ䣨ms*/ + SystemParameterStru->IvocIvocCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.IvocIvocCommunicationErrorTime; + + /*IVOC-OCͨŹжʱ(ms)*/ + SystemParameterStru->IvocOcCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.IvocOcCommunicationErrorTime; + + /*VOBC-ITSͨŹжʱ(ms)*/ + SystemParameterStru->VobcAtsCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.VobcAtsCommunicationErrorTime; + + /*TMC-ITSͨŹжʱ䣨ms*/ + SystemParameterStru->TmcItsCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.TmcItsCommunicationErrorTime; + + /*ITS-OCͨŹжʱ䣨ms*/ + SystemParameterStru->ItsOcCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.ItsOcCommunicationErrorTime; + + /*OC-PSDͨŹжʱ䣨ms*/ + SystemParameterStru->OcPsdCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.OcPsdCommunicationErrorTime; + + /*IVOC-TSLͨŹжʱ䣨ms*/ + SystemParameterStru->IvocTslCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.IvocTslCommunicationErrorTime; + + /*OC-TSLͨŹжʱ䣨ms*/ + SystemParameterStru->OcTslCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.OcTslCommunicationErrorTime; + + /*㾫ȷͣMA쳤ȣcm*/ + SystemParameterStru->MALengthForATOParking = dquCICfgDtStr.SystemParaStrNew.MALengthForATOParking; + + /*ϵͳ߼зĹϵ*/ + SystemParameterStru->LinkLogicDirUpAndDown = dquCICfgDtStr.SystemParaStrNew.LinkLogicDirUpAndDown; + + /*ʻ˫Сȫ(cm)*/ + SystemParameterStru->OppositeTrackDistance = dquCICfgDtStr.SystemParaStrNew.OppositeTrackDistance; + + /*վ̨׷ʱг루cm*/ + SystemParameterStru->StationTrackDistance = dquCICfgDtStr.SystemParaStrNew.StationTrackDistance; + + /*·½ƶ루λm*/ + SystemParameterStru->MaxMALength = dquCICfgDtStr.SystemParaStrNew.MaxMALength; + + /*TIOCͨжʱ λms*/ + SystemParameterStru->CiAndCiTransmitBadEnsureTime = dquCICfgDtStr.SystemParaStrNew.CiAndCiTransmitBadEnsureTime; + + /*OC-TMCͨŹжʱ䣨ms*/ + SystemParameterStru->TmcOcCommunicationErrorTime = dquCICfgDtStr.SystemParaStrNew.TmcOcCommunicationErrorTime; + if (CI_TYPE_TCC == dsuStaticHeadStru.pCIStruStru[dsuCIIndex[ciId]].wType) + { + SystemParameterStru->CiType = CI_TYPE_CLD; + } + else + { + SystemParameterStru->CiType = (UINT8)dsuStaticHeadStru.pCIStruStru[dsuCIIndex[ciId]].wType; + } + + SystemParameterStru->dwLineMinTrainLength = dquCICfgDtStr.SystemParaStrNew.dwLineMinTrainLength; + + SystemParameterStru->chZXDynamicTestSwitch = (UINT8)(~dquCICfgDtStr.SystemParaStrNew.chZXDynamicTestSwitch); + + SystemParameterStru->chDynamicTestSwitch = (UINT8)(~dquCICfgDtStr.SystemParaStrNew.chDynamicTestSwitch); + + SystemParameterStru->chWLSFunSwitch = dquCICfgDtStr.SystemParaStrNew.chWLSFunSwitch; + + SystemParameterStru->dwEaFrontDis = dquCICfgDtStr.SystemParaStrNew.dwEaFrontDis; + + SystemParameterStru->dwEaBehindDis = dquCICfgDtStr.SystemParaStrNew.dwEaBehindDis; + + SystemParameterStru->CiAndVobcTransmitBadEnsureTime = dquCICfgDtStr.SystemParaStrNew.CiAndVobcTransmitBadEnsureTime; + SystemParameterStru->CiAndZcTransmitBadEnsureTime = dquCICfgDtStr.SystemParaStrNew.CiAndZcTransmitBadEnsureTime; + SystemParameterStru->CiAndCiTransmitBadEnsureTime = dquCICfgDtStr.SystemParaStrNew.CiAndCiTransmitBadEnsureTime; + + SystemParameterStru->CiAndPsdTransmitBadEnsureTime = dquCICfgDtStr.SystemParaStrNew.CiAndPsdTransmitBadEnsureTime; + SystemParameterStru->dwVersionOfZCToCI = dquCICfgDtStr.SystemParaStrNew.dwVersionOfZCToCI; + SystemParameterStru->dwVersionOfVOBCToCI = dquCICfgDtStr.SystemParaStrNew.dwVersionOfVOBCToCI; + SystemParameterStru->CiAndPscTransmitBadEnsureTime = dquCICfgDtStr.SystemParaStrNew.CiAndPscTransmitBadEnsureTime; + + SystemParameterStru->cAwakeCheckSpksSwitch = dquCICfgDtStr.SystemParaStrNew.cAwakeCheckSpksSwitch; + SystemParameterStru->dwVobcCiBackUpCommErrorTime = dquCICfgDtStr.SystemParaStrNew.dwVobcCiBackUpCommErrorTime; + SystemParameterStru->VerSionBtwAxisAndCi = dquCICfgDtStr.SystemParaStrNew.VerSionBtwAxisAndCi; + SystemParameterStru->dwHitSoftWallSwitch = dquCICfgDtStr.SystemParaStrNew.dwHitSoftWallSwitch; + SystemParameterStru->dwOverlapLockType = dquCICfgDtStr.SystemParaStrNew.dwOverlapLockType; + SystemParameterStru->dwCDOccuCheckFlag = dquCICfgDtStr.SystemParaStrNew.dwCDOccuCheckFlag; + SystemParameterStru->chNoCGFollowUtSwitch = dquCICfgDtStr.SystemParaStrNew.chNoCGFollowUtSwitch; + } + } + + return rtnVal; +} + + + + +/********************************************* +*ܣCI-ATS +*˵ciIdID MaskConfigDataStruλݽṹָ +*ֵλֵ +*********************************************/ +UINT16 ReadCiToAtsMaskConfigData(const UINT8 ciId, MaskConfigDataStruct* MaskConfigDataStru) +{ + UINT16 i=0u; + + if ((0u == ciId) || (NULL == MaskConfigDataStru) || (ConfigCiToAtsMaskIdMax[ciId] >= CI_TO_ATS_MASK_SUM_MAX)) + { + return 0u; + } + + for(i=0u;i<=ConfigCiToAtsMaskIdMax[ciId];i++) + { + MaskConfigDataStru[i] = ConfigCiToAtsMaskConfigDataStru[ciId][i]; + } + + /*λֵ*/ + return ConfigCiToAtsMaskIdMax[ciId]; +} + +/********************************************* +*ܣCI-ZC +*˵ciIdID MaskConfigDataStruλݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT16 ReadCiToZcMaskConfigData(const UINT8 ciId, MaskConfigDataStruct* MaskConfigDataStru) +{ + UINT16 i=0u; + + if ((0u == ciId) || (NULL == MaskConfigDataStru) || (ConfigCiToZcMaskIdMax[ciId] >= CI_TO_ZC_MASK_SUM_MAX)) + { + return 0u; + } + + for(i=0u;i<=ConfigCiToZcMaskIdMax[ciId];i++) + { + MaskConfigDataStru[i] = ConfigCiToZcMaskConfigDataStru[ciId][i]; + } + /*λֵ*/ + return ConfigCiToZcMaskIdMax[ciId]; +} +/********************************************* +*ܣZC-CI +*˵ciIdID MaskConfigDataStru λݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT16 ReadZcToCiMaskConfigData(const UINT8 ciId, MaskConfigDataStruct* MaskConfigDataStru) +{ + UINT16 i=0u; + + if ((0u == ciId) || (NULL == MaskConfigDataStru) || (ConfigZcToCiMaskIdMax[ciId] >= ZC_TO_CI_MASK_SUM_MAX)) + { + return 0u; + } + + for(i=0u;i<=ConfigZcToCiMaskIdMax[ciId];i++) + { + MaskConfigDataStru[i] = ConfigZcToCiMaskConfigDataStru[ciId][i]; + } + + /*λֵ*/ + return ConfigZcToCiMaskIdMax[ciId]; +} +/********************************************* +*ܣCI-LEU +*˵ciIdID MaskConfigDataStruλݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT16 ReadCiToLeuMaskConfigData(const UINT8 ciId, MaskConfigDataStruct* MaskConfigDataStru) +{ + UINT16 i=0u; + + if ((0u == ciId) || (NULL == MaskConfigDataStru) || (ConfigCiToLeuMaskIdMax[ciId] >= CI_TO_LEU_MASK_SUM_MAX)) + { + return 0u; + } + + for(i=0u;i<=ConfigCiToLeuMaskIdMax[ciId];i++) + { + MaskConfigDataStru[i] = ConfigCiToLeuMaskConfigDataStru[ciId][i]; + } + + /*λֵ*/ + return ConfigCiToLeuMaskIdMax[ciId]; +} +/********************************************* +*ܣӦ̵̼ +*˵ciIdID +*̵ֵID +*********************************************/ +UINT16 ReadJkjRelayId(const UINT8 ciId) +{ + UINT16 i=0u; + + if (0u == ciId) + { + return 0u; + } + + for(i=0u;i ciId) && (NULL != pDiffLineDevData)) + { + *pDiffLineDevData = *dquCICfgDtStr.dquCIfg_DiffLineDevData; + DataNum = dquCICfgDtStr.dquCIfg_DiffLineDevData->diffLineDevSum; + } + + return DataNum; +} + +/********************************************* +*ܣܿ +*˵ +*ֵ0 ޹ܿݻݴ +* 1 йܿ +*********************************************/ +UINT16 ReadCiFuncSwitchConfigData(DquCiFuncSwitchStructNew* pCiFuncSwitConfStru) +{ + UINT16 retVal = 0u; + UINT16 ii = 0u; + + DquCiFuncSwitchStructNew * pTmpFuncSwitch = NULL; + + if (NULL == pCiFuncSwitConfStru) + { + retVal = 0u; + } + else + { + retVal = 1u; + if (dquCiFuncSwitchStruLen < CI_FUNCTION_SWITCH_SUM_MAX) + { + for (ii=0u;iiwCiFuncSwitchId < CI_FUNCTION_SWITCH_SUM_MAX) + { + pCiFuncSwitConfStru[pTmpFuncSwitch->wCiFuncSwitchId] = *pTmpFuncSwitch; + } + else + { + retVal = 0u; + break; + } + } + } + else + { + retVal = 0u; + } + + } + + return retVal; +} + +/* +: +: const UINT8 ciId ID + pInvSecConfigDataStruct InvSecConfigDataStru[] ݽṹ +: +ֵ: 0 + >1 +*/ +INT16 ReadInvaSectionConfigData(const UINT8 ciId, InvSecConfigDataStruct pInvSecConfigDataStru[]) +{ + UINT16 i = 0u; + INT16 DataNum = 0; + + if ((0u != ciId) && (NULL != pInvSecConfigDataStru)) + { + + for(i = 0u; i < dquCICfgDtStr.InvSecCfgDtStrLen; i++) + { + /*鲻Խ磬Խֱӷʧ*/ + if((dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].InvSecAndConSwiId < INVA_SECT_N_COND_SWIT_SUM_MAX) && + (dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].InvSecAndConSwiId > 0u)) + { + pInvSecConfigDataStru[dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i].InvSecAndConSwiId] = dquCICfgDtStr.dquCIfg_InvSecConfigDataStru[i]; + DataNum ++; + } + else + { + /*ʧ*/ + DataNum = -1; + break; + } + } + } + + return DataNum; +} + +/* +: +: const UINT8 ciId ID + FloodGateConfigDataStruct floodGateConfigDataStru[] ݽṹ +: +ֵ: 0 + >1 +*/ +INT16 ReadFloodGateConfigData(const UINT8 ciId, FloodGateConfigDataStruct floodGateConfigDataStru[]) +{ + UINT16 i = 0u; + INT16 DataNum = 0; + UINT8 localID = 0U; + + localID = GetSystemParaLocalCiId(); + if ((0u != ciId) && (NULL != floodGateConfigDataStru)) + { + for(i = 0u; i < dquCICfgDtStr.FloodGateCfgDtStrLen; i++) + { + /*鲻Խ磬Խֱӷʧ*/ + if((dquCICfgDtStr.FloodGateCfgDtStr[i].FloodGateId < FLOOD_GATE_SUM_MAX) && + (dquCICfgDtStr.FloodGateCfgDtStr[i].FloodGateId > 0u)) + { + floodGateConfigDataStru[dquCICfgDtStr.FloodGateCfgDtStr[i].FloodGateId] = dquCICfgDtStr.FloodGateCfgDtStr[i]; + if (dquCICfgDtStr.FloodGateCfgDtStr[i].BelongCiId == localID) + { + DataNum++; + } + } + else + { + /*ʧ*/ + DataNum = -1; + break; + } + } + } + + return DataNum; +} + + +/********************************************* +*ܣվ̨ſ +*˵ciIdID pPscConfigDataStruվ̨ſݽṹָ +*ֵPSC +*********************************************/ +INT16 ReadPscConfigData(const UINT8 ciId,PscConfigDataStruct* pPscConfigDataStru) +{ + UINT16 i=0u; + INT16 DataNum = -1; + + if ((0u == ciId) || (NULL == pPscConfigDataStru)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for(i=0u;i0,ʧ +*********************************************/ +UINT8 NeibourToLocalDevConfDataManage(const UINT8 LocalciId) +{ + UINT8 j=0u; /*α*/ + UINT8 k=0u; /*α*/ + UINT8 retVal = 0u; /*ֵ*/ + UINT8 funcVal = 1u;/*־*/ + if (0u == LocalciId) + {/*IDЧֱӷʧ*/ + retVal = 1u; + } + else + { + for (j = 0u;j < CI_SUM_MAX;j++) + {/*dquCICfgDtStr.CiTransmitStru[][]1ά*/ + + if (j != LocalciId) + {/*1άͷDZ*/ + + for (k = 0u;k< CI_SUM_MAX;k++) + {/*dquCICfgDtStr.CiTransmitStru[][]2ά*/ + + if (LocalciId == dquCICfgDtStr.CiTransmitStru[j][k].destCiId) + { + /*͸źŻ*/ + funcVal = AddExtendSignalIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].signalNum,dquCICfgDtStr.CiTransmitStru[j][k].signalIdBuf); + + /*͸ĵ*/ + funcVal *= AddExtendSwitchIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].switchNum,dquCICfgDtStr.CiTransmitStru[j][k].switchIdBuf); + + /*͸*/ + funcVal *= AddExtendPhySecIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].phySecNum,dquCICfgDtStr.CiTransmitStru[j][k].phySecIdBuf); + + /*͸߼*/ + funcVal *= AddExtendLogSecIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].logicSecNum,dquCICfgDtStr.CiTransmitStru[j][k].logicSecIdBuf); + + /*͸Ľ·*/ + funcVal *= AddExtendRouteIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].routeNum,dquCICfgDtStr.CiTransmitStru[j][k].routeIdBuf); + + /*͸Esb*/ + funcVal *= AddExtendEsbIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].esbNum,dquCICfgDtStr.CiTransmitStru[j][k].esbIdBuf); + + /*͸Psd*/ + funcVal *= AddExtendPsdIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].psdNum,dquCICfgDtStr.CiTransmitStru[j][k].psdIdBuf); + + /*͸Spks*/ + funcVal *= AddExtendSpksIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].spksNum,dquCICfgDtStr.CiTransmitStru[j][k].spksIdBuff); + + /*͸Relay*/ + funcVal *= AddExtendRelayIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].zcjNum,dquCICfgDtStr.CiTransmitStru[j][k].zcjIdBuf); + /*͸ļݣתΪ*/ + funcVal *= AddExtendAxisSecIdDataManage(AxisSectionConfigDataStru,dquCICfgDtStr.CiTransmitStru[j][k].phySecNum,dquCICfgDtStr.CiTransmitStru[j][k].phySecIdBuf); + /*͸ķ*/ + funcVal *= AddExtendFloodGateIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].floodGateNum,dquCICfgDtStr.CiTransmitStru[j][k].floodGateIdBuf); + + /*͸ı*/ + funcVal *= AddExtendOverlapIdDataManage(dquCICfgDtStr.CiTransmitStru[j][k].overlapNum,dquCICfgDtStr.CiTransmitStru[j][k].overlapIdBuf); + + if (0u == funcVal) + {/*͸豸ݣʧܷ1*/ + retVal = 1u; + break; + } + } + } + if(1u == retVal) + { + break; + } + } + } + } + + return retVal; +} + +/********************************************* +*ܣΪCIʹõĹݸֵ +*˵dsuEmapStru ӵͼܽṹ +*ֵ +*mod by qw.liu 2022-02-22 ߼εӵͼ +*********************************************/ + +static void CIInitEmap(DSU_EMAP_STRU dsuEmapStruPar) +{ + dsuDataLenStru = *(dsuEmapStruPar.dsuDataLenStru);/**/ + dsuStaticHeadStru = *(dsuEmapStruPar.dsuStaticHeadStru);/**/ + + LINKINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->LINKINDEXNUM; /*ռС*/ + dsuLinkIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuLinkIndex; /*linkϢ*/ + dsuPointIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuPointIndex; /*Ϣ*/ + dsuBaliseIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuBaliseIndex; /*ӦϢ*/ + dsuSignalIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuSignalIndex; /*źŻϢ*/ + SIGNALINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->SIGNALINDEXNUM; /*źŻϢС*/ + dsuAxleIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuAxleIndex; /*Ϣ*/ + dsuScreenIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuScreenIndex; /*ȫϢ*/ + STATIONINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->STATIONINDEXNUM; /*վռС*/ + dsuStationIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuStationIndex; /*վ̨Ϣ*/ + dsuEmergStopIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuEmergStopIndex; /*ͣťϢ*/ + AXLESGMTINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->AXLESGMTINDEXNUM; /*ռС*/ + dsuAxleSgmtIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuAxleSgmtIndex; /*Ϣ*/ + + LOGICSGMTINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->LOGICSGMTINDEXNUM; ; /*ռС*/ + dsuLogicSgmtIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuLogicSgmtIndex; ; /*Ϣ*/ + + dsuStopPointIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuStopPointIndex; /*ͣϢ*/ + dsuTrainLineIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuTrainLineIndex; /*Ϣ*/ + dsuExitRouteIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuExitRouteIndex; /*˳CBTCϢ*/ + dsuRunLevelIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuRunLevelIndex; /*վӪϢ*/ + dsuStaticResSpeedIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuStaticResSpeedIndex; /*̬ϢϢ*/ + GRADEINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->GRADEINDEXNUM; /*¶ռС*/ + dsuGradeIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuGradeIndex; /*¶Ϣ*/ + dsuRouteIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuRouteIndex; /*·Ϣ*/ + PROTECT_INDEX_NUM = dsuEmapStruPar.dsuEmapIndexStru->PROTECTLINKINDEXNUM; /*ռС*/ + dsuProtectLinkIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuProtectLinkIndex; /*·Ϣ*/ + dsuCBTCAccessLinkIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuCBTCAccessLinkIndex; /*CBTC·ӽϢ*/ + dsuBLOCAccessLinkIndex= dsuEmapStruPar.dsuEmapIndexStru->dsuBLOCAccessLinkIndex; /*BLOC·ӽϢ*/ + dsuDefaultRoutIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuDefaultRoutIndex; /*ĬгϢ*/ + dsuARInIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuARInIndex; /*۷Ϣ*/ + dsuAROutIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuAROutIndex; /*۷˳Ϣ*/ + dsuATSIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuATSIndex; /*ATSϢ*/ + dsuCIIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuCIIndex; /*CIϢ*/ + dsuARIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuARIndex; /*ӵĽṹԶ۷Ӧ*/ + dsuZCComZoneIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuZCComZoneIndex; /*ӵZC򣬶Ӧ 2012.1.5*/ + dsuConResSpeedIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuConResSpeedIndex; /*ͳһ*/ + dsuConGradeIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuConGradeIndex; /*ͳһ¶*/ + dsuZCDividPointIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuZCDividPointIndex; /*ZCֽ*/ + dsuPhysicalSgmtIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuPhysicalSgmtIndex; /**/ + BLOCTRGAREAINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->BLOCTRGAREAINDEXNUM;/*С*/ + dsuBlocTrgAreaIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuBlocTrgAreaIndex; /*ʽ*/ + CBTCTRGAREAINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->CBTCTRGAREAINDEXNUM;/*С*/ + dsuCbtcTrgAreaIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuCbtcTrgAreaIndex; /*CBTC*/ + dsuPlatFormIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuPlatFormIndex; /*վ̨*/ + COMEGOINDEXNUM = dsuEmapStruPar.dsuEmapIndexStru->COMEGOINDEXNUM; /*·С*/ + dsuComeGoIndex= dsuEmapStruPar.dsuEmapIndexStru->dsuComeGoIndex; /*·*/ + dsuFloodGateIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuFloodGateIndex; /**/ + dsuSpksButtonIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuSpksButtonIndex; /*SPKSť*/ + dsuDepotGateIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuDepotGateIndex; /**/ + dsuTunnelIndex = dsuEmapStruPar.dsuEmapIndexStru->dsuTunnelIndex; /**/ +} +/**************************************************************************************** + + ܣҳlinkα + ڲUINT16 wLinkId linkIDϢ + ڲ + ֵ ѯʧ:0xffff;ѯɹIDϢ + 㷨 1αҹΣҵlink +*******************************************************************************************/ +static UINT16 FindLinkBelongAxleSgmt(UINT16 wLinkId) +{ + struct DSU_AxleSgmtStruct *pstAxleSgmtStruct;/*ָϢĽṹָ*/ + UINT16 i=0u;/*ѭñ*/ + UINT16 phySecID= 0u; /* ID*/ + + /*жЧ*/ + + if((wLinkId>LINKINDEXNUM)||(dsuLinkIndex[wLinkId] == 0xFFFFu)) + { + /*Чش*/ + phySecID = 0u; + } + else + { + /*Ϣ*/ + pstAxleSgmtStruct = dsuStaticHeadStru.pAxleSgmtStru; + + for (i=0u; iwOrgnLkId == wLinkId) || (pstAxleSgmtStruct->wTmnlLkId == wLinkId) + || (pstAxleSgmtStruct->wMiddleLinkId[0] == wLinkId) || (pstAxleSgmtStruct->wMiddleLinkId[1] == wLinkId)) + { + /*α*/ + phySecID = pstAxleSgmtStruct->wRelatePhysicalSgmtId;/*鵽ID*/ + + break; + } + else + { + pstAxleSgmtStruct++; + } + + } + } + + return phySecID; + } + +/********************************************* +*ܣݸݶ豸豸 +*˵PsdConfigDataStruct* psdCfgData +* EsbConfigDataStruct* esbCfgData ESB +* SpksDataConfigStruct *spksCfgData SPKS +*ֵCI_SUCCESS ɹ +* CI_ERROR ʧ +*********************************************/ +UINT8 ReadVirtualDevicesInit(PsdConfigDataStruct* psdCfgData, EsbConfigDataStruct* esbCfgData, SpksDataConfigStruct *spksCfgData, RelayConfigDataStruct *relayCfgData,IndicatorConfigDataStruct *pIndicatorConfigDataStruct) +{ + UINT16 i = 0u; + UINT16 j = 0u; + UINT8 ret = CI_SUCCESS; + UINT8 belongCiId = 0u; + UINT8 localCiId = 0u; + UINT8 relayVirtAttr = 0u; + + /*ڲ*/ + if( (NULL == psdCfgData) || + (NULL == esbCfgData) || + (NULL == spksCfgData) || + (NULL == relayCfgData) || + (NULL == pDquVirtualDeviceStr)|| + (NULL == pIndicatorConfigDataStruct)) + { + /*ʧ*/ + ret = CI_ERROR; + } + + if (CI_SUCCESS == ret) + { + InitVirtualZDZFData(); /*ʼ۷ť豸״̬*/ + + /*PSD豸Լ*/ + for (i = 0u;i < dquVirtualDeviceStrLen;i++) + { + for (j = 0u;j < PSD_SUM_MAX;j++) + { + if (0u != psdCfgData[j].PsdId) + { + if ((pDquVirtualDeviceStr[i].vDeviceType == CI_DEVICE_TYPE_PSD) && (pDquVirtualDeviceStr[i].vDeviceId == psdCfgData[j].PsdId)) + {/*豸дڸPSD IDΪ*/ + psdCfgData[j].VirtualAttribute = PSD_VIRTUAL_ATTR_YES; + } + } + } + } + + /*ESB豸Լ*/ + for (i = 0u;i < dquVirtualDeviceStrLen;i++) + { + for (j = 0u;j < ESB_SUM_MAX;j++) + { + if (0u != esbCfgData[j].EsbId) + { + if ((pDquVirtualDeviceStr[i].vDeviceType == CI_DEVICE_TYPE_ESB) && (pDquVirtualDeviceStr[i].vDeviceId == esbCfgData[j].EsbId)) + {/*豸дڸESB IDΪ*/ + esbCfgData[j].VirtualAttribute = ESB_VIRTUAL_ATTR_YES; + } + } + } + } + + /*SPKS豸Լ*/ + for (i = 0u;i < dquVirtualDeviceStrLen;i++) + { + for (j = 0u;j < SPKS_SUM_MAX;j++) + { + if (0u != spksCfgData[j].spksId) + { + if ((pDquVirtualDeviceStr[i].vDeviceType == CI_DEVICE_TYPE_SPKS) && (pDquVirtualDeviceStr[i].vDeviceId == spksCfgData[j].spksId)) + {/*豸дڸSPKS IDΪ*/ + spksCfgData[j].VirtualAttribute = SPKS_VIRTUAL_ATTR_YES; + } + } + } + } + /*̵豸Լ*/ + for (i = 0u; i < dquVirtualDeviceStrLen; i++) + { + for (j = 0u; j < RELAY_SUM_MAX; j++) + { + if (0u != relayCfgData[j].RelayId) + { + if ((pDquVirtualDeviceStr[i].vDeviceType == CI_DEVICE_TYPE_RELAY) && (pDquVirtualDeviceStr[i].vDeviceId == relayCfgData[j].RelayId)) + {/*豸дڸü̵ IDΪ*/ + relayCfgData[j].VirtualAttribute = RELAY_VIRTUAL_ATTR_YES; + } + } + } + } + /*۷ťʼ*/ + for (i = 0u; i < INDICATOR_SUM_MAX; i++) + { + if (INDICATOR_TYPE_EXPRESS_RETURN == pIndicatorConfigDataStruct[i].IndicatorType) + { + for (j = 0u; j < 3u; j++) + { + relayVirtAttr = GetRelayVirtAttr(pIndicatorConfigDataStruct[i].IdBuf[j]); + if (RELAY_VIRTUAL_ATTR_YES != relayVirtAttr) + { + break; + } + } + if (RELAY_VIRTUAL_ATTR_YES == relayVirtAttr) + { + belongCiId = GetRelayBelongCiId(pIndicatorConfigDataStruct[i].IdBuf[0]); + localCiId = GetSystemParaLocalCiId(); + if (localCiId == belongCiId) + { + VirtualZDZFAJData.belongCiId = belongCiId; + VirtualZDZFAJData.virtualDevType = CI_DEVICE_TYPE_AUTORETURN; + } + } + break; + } + } + + } + return ret; +} + +/* +* ȡӵͼУ汾 +* ˵ + EmapCheckVerConfigStru emapVerArr[]:洢ӵͼУõĽṹ +* ֵ: + +*/ +void ReadEmapCiConfig(EmapCiConfigStru emapVerArr[]) +{ + UINT16 ciStruSum = 0u; + UINT16 i; + UINT8 ciId; + UINT8 jj = 0U; + + if (NULL != emapVerArr) + { + ciStruSum = dsuDataLenStru.wCILen; + + for (i = 0u;i < ciStruSum;i++) + { + ciId = (UINT8)(dsuStaticHeadStru.pCIStruStru[i].wID); + emapVerArr[ciId].devId = ciId; + emapVerArr[ciId].ciType = (UINT8)(dsuStaticHeadStru.pCIStruStru[i].wType); + if (CI_TYPE_TCC == dsuStaticHeadStru.pCIStruStru[i].wType) + { + emapVerArr[ciId].ciType = CI_TYPE_CLD; + } + emapVerArr[ciId].dataVerCheckCIAndVOBC = dsuStaticHeadStru.pCIStruStru[i].dwVersionOfCIToVOBC; + emapVerArr[ciId].dataVerCheckCIAndZC = dsuStaticHeadStru.pCIStruStru[i].dwVersionOfCIToZC; + emapVerArr[ciId].dataVerCheckCIAndATS = dsuStaticHeadStru.pCIStruStru[i].dwVersionOfCIToATS; + emapVerArr[ciId].dataVerCheckCIAndTMC = dsuStaticHeadStru.pCIStruStru[i].dwVersionOfCIToTMC; + + /*УϢ*/ + emapVerArr[ciId].chAdjoinCICount = dsuStaticHeadStru.pCIStruStru[i].dwAdjoinCICount; + for (jj = 0U; jj < CI_TRAINSMIT_CI_MAX_NUM; jj++) + { + emapVerArr[ciId].wAdjoinCIId[jj] = dsuStaticHeadStru.pCIStruStru[i].dwAdjoinCIId[jj]; + emapVerArr[ciId].dwAdjoinCIShareCheckData[jj] = dsuStaticHeadStru.pCIStruStru[i].dwAdjoinCIShareCheckData[jj]; + } + + for (jj = 0U; jj < CI_TRAINSMIT_AXIS_MAX_NUM; jj++) + { + emapVerArr[ciId].ciTransmitAxisId[jj] = dsuStaticHeadStru.pCIStruStru[i].dwCIToAxleID[jj]; + emapVerArr[ciId].ciTransmitAxisCheckData[jj] = dsuStaticHeadStru.pCIStruStru[i].dwCIToAxleShareCheckData[jj]; + } + + /*OCϵͳУϢ*/ + emapVerArr[ciId].chAdjoinOcCount = dsuStaticHeadStru.pCIStruStru[i].chAdjoinOcCount; + for (jj = 0U; jj < CI_TRAINSMIT_OC_MAX_NUM; jj++) + { + emapVerArr[ciId].wAdjoinOcId[jj] = dsuStaticHeadStru.pCIStruStru[i].wAdjoinOcId[jj]; + emapVerArr[ciId].dwAdjoinOcShareCheckData[jj] = dsuStaticHeadStru.pCIStruStru[i].dwAdjoinOcShareCheckData[jj]; + } + } + } +} + +/* +* ͨŶձʼ +* ˵ void +* ֵ 0: ʼʧ +* 1: ʼɹ +*/ +UINT8 HLHTCiIdMapInitial(void) +{ + UINT8 retVal = CI_ERROR;/*ֵ*/ + UINT8 retOfDataRead = 0u; + UINT8 retOfDfsIdmapInit = 0u; + UINT8 chSysType = 0U; + retOfDataRead = dataRead((const)DataPath);/*ȡFSļ*/ + + if(1u == retOfDataRead) + {/*ȡɹ*/ + chSysType = GetCbtcSysType(); + if ((DQU_CBTC_HLT == chSysType)|| (DQU_CBTC_CC == chSysType)) + {/*ֻϵͳΪͨʱųʼŶձ*/ + retVal = dquSetInitIdmapRef(&dsuIdmapStru); + + retOfDfsIdmapInit = dfsIdmapInit((const)DataPath); + + if (1u == retOfDfsIdmapInit) + {/*ȡɹ*/ + retVal &= CI_SUCCESS; + } + else + {/*ȡʧ*/ + retVal = CI_ERROR; + } + } + else + { + retVal = CI_SUCCESS; + } + } + else + {/*ȡʧ*/ + retVal = CI_ERROR; + } + + return retVal;/*ֵ*/ +} + +/* +*: +* 豸Ʋѯͨ +*˵: +* : +* const UINT16 LocalDevName 豸ID +* const UINT16 logId 豸ID +* : +* UINT32 *pHlhtId ͨIDָ +*ֵ: +* 0 ѯʧ +* 1 ѯɹ +*/ +UINT8 dquDevName2HlhtId(const UINT16 LocalDevName, const UINT16 logId, UINT32 *pHlhtId) +{ + UINT8 retVal = CI_ERROR; /*ֵ*/ + UINT8 retOfQueryDevId = 0u; /*ѯֵ*/ + UINT32 hlhtId = 0u; /*ͨID*/ + UINT32 szHlhtIdBuf[2] = {0u, 0u}; /*VOBCITEĻͨID*/ + UINT32 dwIdIndex = 0u; /**/ + UINT8 devType = 0u; /*豸*/ + UINT8 devId = 0u; /*豸ID*/ + + if((NULL != pHlhtId) && (0xFFFFu != LocalDevName) && (0u != LocalDevName)) + {/*Ч*/ + devType = (UINT8)((LocalDevName >> 8u) & 0x00FFu); + devId = (UINT8)((LocalDevName >> 0u) & 0x00FFu); + + switch(devType) + { + case DEVTYPE_ZC: + retOfQueryDevId = dquQueryOutDevId(QFUN_IDMAP_ZC_ID, devId, &hlhtId); + break; + case DEVTYPE_ATS: + retOfQueryDevId = dquQueryOutDevId(QFUN_IDMAP_ATS_ID, devId, &hlhtId); + break; + case DEVTYPE_CI: + retOfQueryDevId = dquQueryOutDevId(QFUN_IDMAP_CI_ID, devId, &hlhtId); + break; + case DEVTYPE_VOBC: + retOfQueryDevId = dquQueryOutVobcDevId(devId, szHlhtIdBuf); + + switch(logId) + { + case 1u: + dwIdIndex = 0u; + break; + case 2u: + dwIdIndex = 1u; + break; + default: + dwIdIndex = 0u; + break; + } + + hlhtId = szHlhtIdBuf[dwIdIndex]; + break; + case DEVTYPE_DSU: + retOfQueryDevId = dquQueryOutDevId(IDMAP_DSU_ID, devId, &hlhtId); + break; + case DEVTYPE_AXLE: + retOfQueryDevId = dquQueryOutDevId(IDMAP_AXLE_ID, devId, &hlhtId); + break; + case DEVTYPE_ITE: + retOfQueryDevId = dquQueryOutIteDevId((UINT16)devId, szHlhtIdBuf); + + switch (logId) + { + case 1U: + dwIdIndex = 0U; + break; + case 2U: + dwIdIndex = 1U; + break; + default: + dwIdIndex = 0U; + retOfQueryDevId = 0U; /*ITE߼IDֵǷʧ*/ + break; + } + + hlhtId = szHlhtIdBuf[dwIdIndex]; + break; + default: + retOfQueryDevId = 0u; + break; + } + + if(1U == retOfQueryDevId) + { + *pHlhtId = hlhtId; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + {/*Ч*/ + retVal = CI_ERROR; + } + + return retVal; +} + + +/************************************************************************ +ܣHlhtIDתvobcڲ +룺 +IN UINT32 EtcsId ETCSID + +OUT UINT16 *pDevName 2ֽڲţλ豸 λ豸) +OUT UINT16 *pEndId vobcʹö˱ 1-TC1 2-TC2 0-2IPβ೵ +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquHlhtId2VobcName(IN UINT32 EtcsId, OUT UINT16 *pDevName, OUT UINT16 *pEndId) +{ + UINT8 ret = 0U; + UINT8 endId = 0U; + UINT16 index = 0U; + RSSP2_DEVICE_TYPE type = DEVICE_TYPE_UNKNOWN; + + if ((NULL != pDevName) && (NULL != pEndId)) + { + *pDevName = 0; + *pEndId = 0; + ret = 1; + } + else + { + ret = 0; + } + + if (1U == ret) + { + endId = GET_VOBC_END_ID(EtcsId); + switch (endId) + { + case 1: + *pEndId = VOBC_ENDID_TC1; + break; + case 2: + *pEndId = VOBC_ENDID_TC2; + break; + case 3: + *pEndId = VOBC_ENDID_REDUN; + break; + case 0: + *pEndId = VOBC_ENDID_REDUN; + break; + default: + ret = 0; + break; + } + } + + (void)GetEtcsTypeFromEtcsId(EtcsId, &type); + if ((DEVICE_TYPE_ATP != type) && (DEVICE_TYPE_AOM != type)) + { + ret = 0; + } + + if (1U == ret) + { + if (DEVICE_TYPE_ATP == type) + { + ret = dquQueryVobcDevLgId2Index(EtcsId, ETCSID_MASK, &index, pEndId); + } + else + { + ret = dquQueryAOMDevBits2Index(EtcsId, ETCSID_MASK, &index); + } + } + + if (1U == ret) + { + if (DEVICE_TYPE_ATP == type) + { + *pDevName = DEVTYPE_VOBC * 256U + index; + } + else + { + *pDevName = DEVTYPE_AOM * 256U + index; + } + } + return ret; +} + +/********************************************* +*ܣԶͨ· +*˵ GroupAutoRouteConfigDataStruct* pGroupAutoRouteConfigDataStru Զ·ݽṹָ +*ֵԶͨ· +*********************************************/ +INT16 ReadGroupAutoRouteConfigData(GroupAutoRouteConfigDataStruct* pGroupAutoRouteConfigDataStru) +{ + UINT16 i=0u; + INT16 DataNum = -1; + + if(NULL == pGroupAutoRouteConfigDataStru) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + if(GROUP_AUTO_ROUTE_SUM_MAX > dquCICfgDtStr.GroupAutoRouteStrLen) + { + for(i=0u;i dquCICfgDtStr.GroupAutoRouteCfgStr[i].GroupAutoRouteId) + { + pGroupAutoRouteConfigDataStru[dquCICfgDtStr.GroupAutoRouteCfgStr[i].GroupAutoRouteId] = dquCICfgDtStr.GroupAutoRouteCfgStr[i]; + DataNum++; + } + else + { + /*ʧ*/ + DataNum = -1; + break; + } + + } + } + else + { + /*ʧ*/ + DataNum = -1; + } + } + + return DataNum; +} + +/********************************************* +*ܣLink +*˵LinkDataConfigStru Linkݽṹָ +*ֵLink +1create 2022.02.28 +*********************************************/ +INT16 ReadLinkConfigData(LinkDataConfigStru* pLinkConfigAddr) +{ + UINT16 i = 0u; + INT16 DataNum = -1; + UINT16 indexAc = 0u; + UINT8 indexLink = 0u; + UINT16 indexStation = 0u; + + if ((NULL == pLinkConfigAddr) || (LINK_SUM_MAX < dsuDataLenStru.wLinkLen)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for (i = 0u; i < dsuDataLenStru.wLinkLen; i++) + { + if (LINK_SUM_MAX > dquCICfgDtStr.LinkCfgDtStr[i].wId) + { + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId] = dquCICfgDtStr.LinkCfgDtStr[i]; + + DataNum++; + for (indexAc = 0u; indexAc < dsuDataLenStru.wAxleSgmtLen; indexAc++) + { + if ((0u != dquCICfgDtStr.AxisSctCfgDtStr[indexAc].AxisSectionId) + && (UINT16_MAX != dquCICfgDtStr.AxisSctCfgDtStr[indexAc].AxisSectionId) + && (0u != dquCICfgDtStr.AxisSctCfgDtStr[indexAc].chLinkNum) + && (UINT8_MAX != dquCICfgDtStr.AxisSctCfgDtStr[indexAc].chLinkNum)) + { + for (indexLink = 0u; indexLink < dquCICfgDtStr.AxisSctCfgDtStr[indexAc].chLinkNum; indexLink++) + { + if (dquCICfgDtStr.AxisSctCfgDtStr[indexAc].szLinkIdBuff[indexLink] == pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].wId) + { + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].wRelatedPhySec = dquCICfgDtStr.AxisSctCfgDtStr[indexAc].RelativePhySecId; + break; + } + } + } + } + + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].wStopAreaId = 0u; + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].chSwTrack = LINK_SW_TRACK_NO; + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].chRevertArea = LINK_REVERT_AREA_NO; + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].chPlatform = LINK_PLATFORM_NO; + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].wPlatformId = 0u; + + for (indexStation = 0u; indexStation < dsuDataLenStru.wStationLen; indexStation++) + { + if (dquCICfgDtStr.LinkCfgDtStr[i].wId == dsuStaticHeadStru.pStationStru[indexStation].wLinkId) + { + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].wStopAreaId = dsuStaticHeadStru.pStationStru[indexStation].wId; + + if (((dsuStaticHeadStru.pStationStru[indexStation].dwAttribute & (UINT32)EMAP_STATION_AREA) != 0u) + && ((dsuStaticHeadStru.pStationStru[indexStation].dwAttribute & EMAP_VC_STATION_AREA) == 0u)) + { + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].chPlatform = LINK_PLATFORM_YES; + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].wPlatformId = dsuStaticHeadStru.pStationStru[indexStation].wATSStationId; + } + else + { + ; + } + + if ((dsuStaticHeadStru.pStationStru[indexStation].dwAttribute & (UINT32)EMAP_SLEEP_AREA) != 0u) + { + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].chSwTrack = LINK_SW_TRACK_YES; + } + else + { + ; + } + + if (0u != (dsuStaticHeadStru.pStationStru[indexStation].dwAttribute & (UINT32)EMAP_REVERT_AREA)) + { + pLinkConfigAddr[dquCICfgDtStr.LinkCfgDtStr[i].wId].chRevertArea = LINK_REVERT_AREA_YES; + } + else + { + ; + } + } + else + { + ; + } + } + } + else + { + DataNum = -1; + break; + } + } + } + return DataNum; +} + +/********************************************* +*ܣ +*˵pAxisConfigAddr ݽṹָ +*ֵ +1create 2022.03.11 +*********************************************/ +INT16 ReadAxisConfigData(AxisConfigStru* pAxisConfigAddr) +{ + UINT16 i = 0u; + INT16 DataNum = -1; + + if ((NULL == pAxisConfigAddr) || (AXIS_NUM_MAX < dsuDataLenStru.wAxlecounterLen)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for (i = 0u; i < dsuDataLenStru.wAxlecounterLen; i++) + { + if (AXIS_NUM_MAX > dquCICfgDtStr.AxisCfgDtStr[i].wId) + { + pAxisConfigAddr[dquCICfgDtStr.AxisCfgDtStr[i].wId] = dquCICfgDtStr.AxisCfgDtStr[i]; + DataNum++; + } + else + { + DataNum = -1; + break; + } + } + } + return DataNum; +} + +/********************************************* +*ܣֽ +*˵ciIdID pstCutoffConfigDataݽṹָ +*ֵعֽID +*********************************************/ +INT16 ReadCutoffPointConfigData(const UINT8 ciId, CfpConfigStru* pstCutoffConfigData) +{ + UINT16 i = 0u; + INT16 DataNum = -1; + + if ((0u == ciId) || (NULL == pstCutoffConfigData)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for (i = 0u; i> 24) ^ pData[i]]; + i++; + } + } + else + { + Crc = 0; + } + return Crc; +} + + +/** +* @brief CRC32 ƽ̨֡ʹ +* @param pData ָ +* @param dataLen ݳ +* @return ΪCRCֵ +* @details +* £ע⣺CRCǴݵһֽڵBITʼ +* õĶʽ0x4c11db7LʼֵΪ0x00000000,δ񣬽ϵΪ0x00000000 +* dataLen=0ֵҲΪ0 +*/ +UINT32 Tioc_PlatCommonCrc32(const UINT8* pData, UINT32 dataLen) +{ + /*- ʼ */ + UINT32 crc = 0U; + UINT32 i = 0U; + + + static const UINT32 s_CrcTable[256] = { + 0x00000000u,0x04c11db7u,0x09823b6eu,0x0d4326d9u,0x130476dcu,0x17c56b6bu, + 0x1a864db2u,0x1e475005u,0x2608edb8u,0x22c9f00fu,0x2f8ad6d6u,0x2b4bcb61u, + 0x350c9b64u,0x31cd86d3u,0x3c8ea00au,0x384fbdbdu,0x4c11db70u,0x48d0c6c7u, + 0x4593e01eu,0x4152fda9u,0x5f15adacu,0x5bd4b01bu,0x569796c2u,0x52568b75u, + 0x6a1936c8u,0x6ed82b7fu,0x639b0da6u,0x675a1011u,0x791d4014u,0x7ddc5da3u, + 0x709f7b7au,0x745e66cdu,0x9823b6e0u,0x9ce2ab57u,0x91a18d8eu,0x95609039u, + 0x8b27c03cu,0x8fe6dd8bu,0x82a5fb52u,0x8664e6e5u,0xbe2b5b58u,0xbaea46efu, + 0xb7a96036u,0xb3687d81u,0xad2f2d84u,0xa9ee3033u,0xa4ad16eau,0xa06c0b5du, + 0xd4326d90u,0xd0f37027u,0xddb056feu,0xd9714b49u,0xc7361b4cu,0xc3f706fbu, + 0xceb42022u,0xca753d95u,0xf23a8028u,0xf6fb9d9fu,0xfbb8bb46u,0xff79a6f1u, + 0xe13ef6f4u,0xe5ffeb43u,0xe8bccd9au,0xec7dd02du,0x34867077u,0x30476dc0u, + 0x3d044b19u,0x39c556aeu,0x278206abu,0x23431b1cu,0x2e003dc5u,0x2ac12072u, + 0x128e9dcfu,0x164f8078u,0x1b0ca6a1u,0x1fcdbb16u,0x018aeb13u,0x054bf6a4u, + 0x0808d07du,0x0cc9cdcau,0x7897ab07u,0x7c56b6b0u,0x71159069u,0x75d48ddeu, + 0x6b93dddbu,0x6f52c06cu,0x6211e6b5u,0x66d0fb02u,0x5e9f46bfu,0x5a5e5b08u, + 0x571d7dd1u,0x53dc6066u,0x4d9b3063u,0x495a2dd4u,0x44190b0du,0x40d816bau, + 0xaca5c697u,0xa864db20u,0xa527fdf9u,0xa1e6e04eu,0xbfa1b04bu,0xbb60adfcu, + 0xb6238b25u,0xb2e29692u,0x8aad2b2fu,0x8e6c3698u,0x832f1041u,0x87ee0df6u, + 0x99a95df3u,0x9d684044u,0x902b669du,0x94ea7b2au,0xe0b41de7u,0xe4750050u, + 0xe9362689u,0xedf73b3eu,0xf3b06b3bu,0xf771768cu,0xfa325055u,0xfef34de2u, + 0xc6bcf05fu,0xc27dede8u,0xcf3ecb31u,0xcbffd686u,0xd5b88683u,0xd1799b34u, + 0xdc3abdedu,0xd8fba05au,0x690ce0eeu,0x6dcdfd59u,0x608edb80u,0x644fc637u, + 0x7a089632u,0x7ec98b85u,0x738aad5cu,0x774bb0ebu,0x4f040d56u,0x4bc510e1u, + 0x46863638u,0x42472b8fu,0x5c007b8au,0x58c1663du,0x558240e4u,0x51435d53u, + 0x251d3b9eu,0x21dc2629u,0x2c9f00f0u,0x285e1d47u,0x36194d42u,0x32d850f5u, + 0x3f9b762cu,0x3b5a6b9bu,0x0315d626u,0x07d4cb91u,0x0a97ed48u,0x0e56f0ffu, + 0x1011a0fau,0x14d0bd4du,0x19939b94u,0x1d528623u,0xf12f560eu,0xf5ee4bb9u, + 0xf8ad6d60u,0xfc6c70d7u,0xe22b20d2u,0xe6ea3d65u,0xeba91bbcu,0xef68060bu, + 0xd727bbb6u,0xd3e6a601u,0xdea580d8u,0xda649d6fu,0xc423cd6au,0xc0e2d0ddu, + 0xcda1f604u,0xc960ebb3u,0xbd3e8d7eu,0xb9ff90c9u,0xb4bcb610u,0xb07daba7u, + 0xae3afba2u,0xaafbe615u,0xa7b8c0ccu,0xa379dd7bu,0x9b3660c6u,0x9ff77d71u, + 0x92b45ba8u,0x9675461fu,0x8832161au,0x8cf30badu,0x81b02d74u,0x857130c3u, + 0x5d8a9099u,0x594b8d2eu,0x5408abf7u,0x50c9b640u,0x4e8ee645u,0x4a4ffbf2u, + 0x470cdd2bu,0x43cdc09cu,0x7b827d21u,0x7f436096u,0x7200464fu,0x76c15bf8u, + 0x68860bfdu,0x6c47164au,0x61043093u,0x65c52d24u,0x119b4be9u,0x155a565eu, + 0x18197087u,0x1cd86d30u,0x029f3d35u,0x065e2082u,0x0b1d065bu,0x0fdc1becu, + 0x3793a651u,0x3352bbe6u,0x3e119d3fu,0x3ad08088u,0x2497d08du,0x2056cd3au, + 0x2d15ebe3u,0x29d4f654u,0xc5a92679u,0xc1683bceu,0xcc2b1d17u,0xc8ea00a0u, + 0xd6ad50a5u,0xd26c4d12u,0xdf2f6bcbu,0xdbee767cu,0xe3a1cbc1u,0xe760d676u, + 0xea23f0afu,0xeee2ed18u,0xf0a5bd1du,0xf464a0aau,0xf9278673u,0xfde69bc4u, + 0x89b8fd09u,0x8d79e0beu,0x803ac667u,0x84fbdbd0u,0x9abc8bd5u,0x9e7d9662u, + 0x933eb0bbu,0x97ffad0cu,0xafb010b1u,0xab710d06u,0xa6322bdfu,0xa2f33668u, + 0xbcb4666du,0xb8757bdau,0xb5365d03u,0xb1f740b4u + }; + + /*- */ + while (i < dataLen) + { + /*- CRC */ + crc = (crc << 8) ^ s_CrcTable[(crc >> 24) ^ (*(pData + i))]; /* parasoft-suppress MISRA2004-17_1 "ΪߴЧʣʹָ" */ + i++; + } + /*- CRC */ + return crc; +} + + + + +/********************************************* +*ܣ +*˵EaConfigStru ݽṹָ +*ֵ +*********************************************/ +INT16 ReadEaConfigData(EaConfigStru* pEaConfigAddr) +{ + UINT16 i = 0u; + INT16 DataNum = -1; + + if ((NULL == pEaConfigAddr) || (EA_CFG_SUM_MAX < dsuDataLenStru.wEaLen)) + { + DataNum = -1; + } + else + { + DataNum = 0; + } + + if (0 == DataNum) + { + for (i = 0u; i < dsuDataLenStru.wEaLen; i++) + { + if (EA_CFG_SUM_MAX > dquCICfgDtStr.szEaCfgDtStr[i].wId) + { + pEaConfigAddr[i] = dquCICfgDtStr.szEaCfgDtStr[i]; + + DataNum++; + } + else + { + DataNum = -1; + break; + } + } + } + return DataNum; +} + +/********************************************* +*ܣȡTIOCȫɸЧ־ +*˵ciIdID +*ֵTIOCȫɸЧ־ TIOC_WLSCTEEN_VALID TIOC_WLSCTEEN_UNVALID +*********************************************/ +UINT8 GetWLScreenTypeById(const UINT8 ciId) +{ + UINT8 cRetVal = TIOC_WLSCTEEN_VALID; + + cRetVal = dsuStaticHeadStru.pCIStruStru[dsuCIIndex[ciId]].cWLScreenType; + + return cRetVal; +} + +/********************************************* +*ܣⱨ +*˵const UINT8 cLocalCiId ID +* SGBJConfigDataStruct* pSGBJConfigDataStru ⱨݽṹָ +*ֵ-1 ȡʧ + ⱨ +*********************************************/ +INT16 ReadSGBJConfigData(const UINT8 cLocalCiId, SGBJConfigDataStruct* pSGBJConfigDataStru) +{ + INT16 dataNum = -1; + UINT16 i = 0U; + UINT8 cSGBJbelongCiId = 0U; + UINT16 wSGBJId = 0U; + + if ((NULL != pSGBJConfigDataStru) && (0U != cLocalCiId)) + { + dataNum = 0; + } + else + { + dataNum = -1; + } + + if (0 == dataNum) + { + for (i = 0U; i < dquCICfgDtStr.wSGBJCfgLen; i++) + { + + wSGBJId = dquCICfgDtStr.SGBJCfgDataStru[i].wSGBJId; + if (wSGBJId < SGBJ_SUM_MAX) + { + pSGBJConfigDataStru[wSGBJId] = dquCICfgDtStr.SGBJCfgDataStru[i]; + cSGBJbelongCiId = dquCICfgDtStr.SGBJCfgDataStru[i].cBelongCiId; + if (cLocalCiId == cSGBJbelongCiId) + { + dataNum++; + } + else + { + /**/ + } + } + else + { + dataNum = -1; /*ʧ*/ + break; + } + } + } + else + { + dataNum = -1; /*-1*/ + } + + return dataNum; +} + +/********************************************* +*ܣȷεı߽ +*˵const UINT16 wAxleId ID +* ֵ1 ߽ +* 0 DZ߽ +*********************************************/ +UINT8 EnsureAxleBorderAtrr(const UINT16 wAxleId) +{ + UINT8 cRetVal = CI_ERROR; + DSU_AXLE_SGMT_STRU* pTempAxleSgmtStru = NULL; + UINT16 wOrgnJointMainLkId = 0U; /*link*/ + UINT16 wOrgnJointSideLkId = 0U; /*link*/ + UINT16 wTmnlJointMainLkId = 0U; /*յlink*/ + UINT16 wTmnlJointSideLkId = 0U; /*յlink*/ + UINT8 cCurCiId = 0U; + + if ((0U < wAxleId) && (AXIS_SECTION_SUM_MAX > wAxleId)) + { + pTempAxleSgmtStru = &dsuStaticHeadStru.pAxleSgmtStru[g_dsuEmapStru->dsuEmapIndexStru->dsuAxleSgmtIndex[wAxleId]]; + cCurCiId = pTempAxleSgmtStru->wManagePhysicalCI; + + /*жϼlinkڵlinkǷ*/ + wOrgnJointMainLkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]].wOrgnJointMainLkId; + wOrgnJointSideLkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]].wOrgnJointSideLkId; + wTmnlJointMainLkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]].wTmnlJointMainLkId; + wTmnlJointSideLkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]].wTmnlJointSideLkId; + + if ((0U != wOrgnJointMainLkId) && (UINT16_MAX != wOrgnJointMainLkId)) + { + if (cCurCiId != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wOrgnJointMainLkId]].wManagePhysicalCI) + { + cRetVal = CI_SUCCESS; /*linkDZüμΪ߽Σسɹ*/ + } + } + + if ((0U != wOrgnJointSideLkId) && (UINT16_MAX != wOrgnJointSideLkId)) + { + if (cCurCiId != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wOrgnJointSideLkId]].wManagePhysicalCI) + { + cRetVal = CI_SUCCESS; /*linkDZüμΪ߽Σسɹ*/ + } + } + + if ((0U != wTmnlJointMainLkId) && (UINT16_MAX != wTmnlJointMainLkId)) + { + if (cCurCiId != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTmnlJointMainLkId]].wManagePhysicalCI) + { + cRetVal = CI_SUCCESS; /*linkDZüμΪ߽Σسɹ*/ + } + } + + if ((0U != wTmnlJointSideLkId) && (UINT16_MAX != wTmnlJointSideLkId)) + { + if (cCurCiId != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTmnlJointSideLkId]].wManagePhysicalCI) + { + cRetVal = CI_SUCCESS; /*linkDZüμΪ߽Σسɹ*/ + } + } + + /*жϼյlinkڵlinkǷ*/ + wOrgnJointMainLkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]].wOrgnJointMainLkId; + wOrgnJointSideLkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]].wOrgnJointSideLkId; + wTmnlJointMainLkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]].wTmnlJointMainLkId; + wTmnlJointSideLkId = dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]].wTmnlJointSideLkId; + + if ((0U != wOrgnJointMainLkId) && (UINT16_MAX != wOrgnJointMainLkId)) + { + if (cCurCiId != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wOrgnJointMainLkId]].wManagePhysicalCI) + { + cRetVal = CI_SUCCESS; /*linkDZüμΪ߽Σسɹ*/ + } + } + + if ((0U != wOrgnJointSideLkId) && (UINT16_MAX != wOrgnJointSideLkId)) + { + if (cCurCiId != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wOrgnJointSideLkId]].wManagePhysicalCI) + { + cRetVal = CI_SUCCESS; /*linkDZüμΪ߽Σسɹ*/ + } + } + + if ((0U != wTmnlJointMainLkId) && (UINT16_MAX != wTmnlJointMainLkId)) + { + if (cCurCiId != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTmnlJointMainLkId]].wManagePhysicalCI) + { + cRetVal = CI_SUCCESS; /*linkDZüμΪ߽Σسɹ*/ + } + } + + if ((0U != wTmnlJointSideLkId) && (UINT16_MAX != wTmnlJointSideLkId)) + { + if (cCurCiId != dsuStaticHeadStru.pLinkStru[g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wTmnlJointSideLkId]].wManagePhysicalCI) + { + cRetVal = CI_SUCCESS; /*linkDZüμΪ߽Σسɹ*/ + } + } + } + else + { + ; + } + + return cRetVal; +} + +/********************************************* +*ܣȷڼǷΪ泵 +*˵const UINT16 wAxleId ID +* ֵ1 +* 0 +* Created By LQ 2025.03.08 +*********************************************/ +UINT8 EnsureNearAxleStorageLineAtrr(const UINT16 wAxleId) +{ + UINT8 cRetVal = CI_SUCCESS; + DSU_AXLE_SGMT_STRU* pTempAxleSgmtStru = NULL; + UINT8 ii = 0U; + UINT16 wTempAxleId = 0U; + UINT16 jj = 0U; + UINT8 cFindFlag = CI_ERROR; + + if ((0U < wAxleId) && (AXIS_SECTION_SUM_MAX > wAxleId)) + { + pTempAxleSgmtStru = &dsuStaticHeadStru.pAxleSgmtStru[g_dsuEmapStru->dsuEmapIndexStru->dsuAxleSgmtIndex[wAxleId]]; + + /*ѯڵļ޴泵*/ + for (ii = 0U; ii < 16U; ii++) + { + wTempAxleId = pTempAxleSgmtStru->wOrgnAxleSgmtId[ii]; + for (jj = 0U; jj < dquCICfgDtStr.wLinkLineCfgDtLen; jj++) + { + if (wTempAxleId == dquCICfgDtStr.LinkLineCfgDtStr[jj].wAxisSecId) + { + if (0x55U == dquCICfgDtStr.LinkLineCfgDtStr[jj].cStorageLineType) + { + cFindFlag = CI_SUCCESS; + break; + } + else + { + /**/ + } + } + else + { + /**/ + } + } + + if (CI_SUCCESS == cFindFlag) + { + break; /*ڼΪ泵ߣֹͣ*/ + } + else + { + /**/ + } + } + + if (CI_ERROR == cFindFlag) + { + /*ѯյڵļ޴泵*/ + for (ii = 0U; ii < 16U; ii++) + { + wTempAxleId = pTempAxleSgmtStru->wTmnlAxleSgmtId[ii]; + for (jj = 0U; jj < dquCICfgDtStr.wLinkLineCfgDtLen; jj++) + { + if (wTempAxleId == dquCICfgDtStr.LinkLineCfgDtStr[jj].wAxisSecId) + { + if (0x55U == dquCICfgDtStr.LinkLineCfgDtStr[jj].cStorageLineType) + { + cFindFlag = CI_SUCCESS; + break; + } + else + { + /**/ + } + } + else + { + /**/ + } + } + + if (CI_SUCCESS == cFindFlag) + { + break; /*ڼΪ泵ߣֹͣ*/ + } + else + { + /**/ + } + } + } + else + { + ; + } + + if (CI_ERROR == cFindFlag) + { + cRetVal = CI_ERROR; /*ڼ޴泵ߣʧ*/ + } + else + { + cRetVal = CI_SUCCESS; /*ڼΪ泵ߣسɹ*/ + } + } + else + { + ; + } + + return cRetVal; +} + diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIInterFace.h b/TSCP/src/APP/ciapp/QueryFiles/dquCIInterFace.h new file mode 100644 index 0000000..2a5813f --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIInterFace.h @@ -0,0 +1,503 @@ +/************************************************************************ +* +* ļ dquCIInterFace.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* CIݽӿڽṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_CI_INTERFACE +#define DQU_CI_INTERFACE + +#include "dquCIInit.h" +#include "dquEmapInit.h" +#include "dquMaskInit.h" +#include "../System/SystemParameterManage.h" +#include "dquIdmapInit.h" +#include "../DataManage/DeviceConfigDataManage.h" +#include "../Initial/ConfigDataReadManage.h" +#include "../DebugPrint/DebugPrint.h" +#include "../DebugPrint/ErrorCode.h" +#include "../DebugPrint/ErrorDeviceType.h" +#include "../Section/LinkConfigDataManage.h" +#include "AxisConfigDataManage.h" +#include "../Section/AxisSectionConfigDataManage.h" +#include "../VirtualDevice/VirtualDevDataManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif +/********************************************* +*ܣʼ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitAll(CHAR* FSName); + +/********************************************* +*ܣ̵ +*˵ciIdID pRelayConfigDataStru̵ݽṹָ +*̵ֵ +*********************************************/ +INT16 ReadRelayConfigData(const UINT8 ciId, RelayConfigDataStruct* pRelayConfigDataStru);/*̵ݷRelayCurSumͬ*/ + +/********************************************* +*ܣźŻ +*˵ciIdID pSignalConfigDataStruźŻݽṹָ +*ֵźŻ +*********************************************/ +INT16 ReadSignalConfigData(const UINT8 ciId,SignalConfigDataStruct* pSignalConfigDataStru);/*źŻ*/ + +/********************************************* +*ܣϴ +*˵ciIdID + pWashMachineConfigDataStruϴݽṹָ +*ֵ ϴ +*********************************************/ +UINT16 ReadWashMachineConfigData(const UINT8 ciId,WashMachineConfigDataStruct* pWashMachineConfigDataStru); + + +/********************************************* +*ܣ +*˵ciIdID pSwitchConfigDataStruݽṹָ +*ֵ +*********************************************/ +INT16 ReadSwitchConfigData(const UINT8 ciId,SwitchConfigDataStruct* pSwitchConfigDataStru);/**/ + +/********************************************* + *ܣ + *˵ciIdID pPhysicalSectionConfigDataStruݽṹָ + *ֵ +*********************************************/ +INT16 ReadPhySicalSectionConfigData(const UINT8 ciId,PhysicalSectionConfigDataStruct* pPhysicalSectionConfigDataStru);/**/ + +/********************************************* +*ܣ +*˵ciIdID AxisSectionConfigDataStruݽṹָ +*ֵ +*********************************************/ +INT16 ReadAxisSectionConfigData(const UINT8 ciId, AxisSectionConfigDataStruct* AxisSectionConfigDataSt, UINT16 * pAcNum, AxisSectionConfigDataStruct * pAcConfigDataStru);/**/ + +/********************************************* +*ܣ߼ +*˵ciIdIDpLogicSectionConfigDataStru ߼ݽṹָ +*ֵ߼ +*********************************************/ +INT16 ReadLogicSectionConfigData(const UINT8 ciId,LogicSectionConfigDataStruct* pLogicSectionConfigDataStru);/*߼*/ + +/********************************************* +*ܣͣť +*˵ciIdID pEsbConfigDataStruͣݽṹָ +*ֵͣť +*********************************************/ +INT16 ReadEsbConfigData(const UINT8 ciId,EsbConfigDataStruct* pEsbConfigDataStru);/*ͣť*/ + + +/********************************************* +*ܣ +*˵ciIdID pPsdConfigDataStruݽṹָ +*ֵ +*********************************************/ +INT16 ReadPsdConfigData(const UINT8 ciId,PsdConfigDataStruct* pPsdConfigDataStru);/**/ + +/********************************************* +*ܣ· +*˵ciIdIDpRouteConfigDataStru ·ݽṹָ +*ֵ· +*********************************************/ +INT16 ReadRouteConfigData(const UINT8 ciId,RouteConfigDataStruct* pRouteConfigDataStru);/*·*/ + +/********************************************* +*ܣǽ· +*˵pNonRouteConfigDataStru ǽ·ݽṹָ +*ֵǽ· +*********************************************/ +UINT16 ReadNonRouteConfigData(NonRouteConfigDataStruct* pNonRouteConfigDataStru);/*ǽ·*/ + +/********************************************* +*ܣԶͨ· +*˵ciIdID pAutoRouteConfigDataStruԶ·ݽṹָ +*ֵԶͨ· +*********************************************/ +INT16 ReadAutoRouteConfigData(const UINT8 ciId,AutoRouteConfigDataStruct* pAutoRouteConfigDataStru);/*Զͨ·*/ + +/********************************************* +*ܣԶ۷· +*˵ciIdID pAutoReturnConfigDataStruԶ۷ݽṹָ +*ֵԶ۷· +*********************************************/ +INT16 ReadAutoReturnConfigData(const UINT8 ciId,AutoReturnConfigDataStruct* pAutoReturnConfigDataStru);/*Զ۷·*/ + +/********************************************* +*ܣ· +*˵ciIdID pReverseRouteConfigDataStru·ݽṹָ +*ֵ· +*********************************************/ +INT16 ReadReverseRouteConfigData(const UINT8 ciId,ReverseRouteConfigDataStruct* pReverseRouteConfigDataStru); + + +/********************************************* +*ܣ· +*˵ pLongRouteConfigDataStru ·ݽṹָ +*ֵ· +*********************************************/ +INT16 ReadLongRouteConfigData(LongRouteConfigDataStruct* pLongRouteConfigDataStru);/*·*/ + +/********************************************* +*ܣָʾƱ +*˵ciIdIDIndicatorConfigDataStru ָʾݽṹָ +*ֵ +*********************************************/ +INT16 ReadIndicatorConfigData(const UINT8 ciId,IndicatorConfigDataStruct* IndicatorConfigDataSt);/*ָʾƱ*/ + +/********************************************* +*ܣָʾƱ +*˵ciIdIDIndicatorConfigDataStru ָʾݽṹָ +*ֵ +*********************************************/ +INT16 ReadIndicatorConfigData_Vir(const UINT8 ciId, const UINT8 virCIid,IndicatorConfigDataStruct* pIndicatorConfigDataStru);/*ָʾƱ*/ + + +/********************************************* +*ܣ +*˵ciIdIDpOverlapConfigDataStru ݽṹָ +*ֵ +*********************************************/ +INT16 ReadOverlapConfigData(const UINT8 ciId,OverlapConfigDataStruct* pOverlapConfigDataStru);/**/ + +/********************************************* + *ܣͨŹϵ + *˵ciIdID TransmitRelationDataStruͨŹϵݽṹָ + *ֵͨŹϵ +*********************************************/ +UINT16 ReadTransmitRelationConfigData(const UINT8 ciId,TransmitRelationDataStruct* TransmitRelationDataStru);/*ͨŹϵ*/ + + +/********************************************* +*ܣCI-ATS +*˵ciIdID MaskConfigDataStruλݽṹָ +*ֵλֵ +*********************************************/ +UINT16 ReadCiToAtsMaskConfigData(const UINT8 ciId, MaskConfigDataStruct* MaskConfigDataStru);/*CI-ATS*/ + +/********************************************* +*ܣCI-ZC + *˵ciIdID MaskConfigDataStruλݽṹָ +*ֵλֵ +*********************************************/ +UINT16 ReadCiToZcMaskConfigData(const UINT8 ciId, MaskConfigDataStruct* MaskConfigDataStru);/*CI-ZC*/ + +/********************************************* + *ܣZC-CI + *˵ciIdID MaskConfigDataStru λݽṹָ + *ֵλֵ +*********************************************/ +UINT16 ReadZcToCiMaskConfigData(const UINT8 ciId, MaskConfigDataStruct* MaskConfigDataStru);/*ZC-CI*/ + +/********************************************* +*ܣCI-LEU +*˵ciIdID MaskConfigDataStruλݽṹָ +*ֵλ +*********************************************/ +UINT16 ReadCiToLeuMaskConfigData(const UINT8 ciId, MaskConfigDataStruct* MaskConfigDataStru);/*CI-LEU*/ + +/********************************************* +*ܣӦ̵̼ +*˵ciIdID +*̵ֵID +*********************************************/ +UINT16 ReadJkjRelayId(const UINT8 ciId); + +/********************************************* +*ܣͷڴ +*˵ +*ֵ +*********************************************/ +void FreeMem(void); + +/********************************************* +*ܣڴռ +*˵pMemռ䳤 +*ֵ +*********************************************/ +void MyFree(void ** pMem); + +/********************************************* +*ܣȫԶ۷· +*˵ciIdID pAllAutoReturnConfigDataStruȫԶ۷ݽṹָ +*ֵȫԶ۷· +*********************************************/ +INT16 ReadAllAutoReturnConfigData(const UINT8 ciId,AllAutoReturnConfigDataStruct* pAllAutoReturnConfigDataStru); /*ȫԶ۷·*/ + +/********************************************* +*ܣ +*˵ciIdID pGaragedoorConfigDataStruݽṹָ +*ֵ +*********************************************/ +INT16 ReadGaragedoorConfigData(const UINT8 ciId,GaragedoorConfigDataStruct* pGaragedoorConfigDataStru); +/********************************************* +*ܣSPKS +*˵ciIdID spksConfig SPKSݽṹָ +*ֵSPKS +*********************************************/ +INT16 ReadSpksConfigData(const UINT8 ciId,SpksDataConfigStruct* spksConfig); +/********************************************* +*ܣŽ +*˵ciIdID mjConfig Žݽṹָ +*ֵSPKS +*********************************************/ +INT16 ReadMJConfigData(const UINT8 ciId, MJDataConfigStruct* mjConfig); + +/********************************************* +*ܣվ̨ſ +*˵ciIdID pPscConfigDataStruվ̨ſݽṹָ +*ֵPSC +*********************************************/ +INT16 ReadPscConfigData(const UINT8 ciId,PscConfigDataStruct* pPscConfigDataStru); + +/********************************************* +*ܣ۷ +*˵ciIdID pNonReturnConfigDataStru۷ݽṹָ +*ֵ۷ +*********************************************/ +INT16 ReadNonReturnConfigData(const UINT8 ciId, NonAutoReturnConfigDataStruct* pNonReturnConfigDataStru); +/********************************************* +*ܣCI֮ +*˵ciIdID pCiTransmitStru ݽṹָ +*ֵ뱾ͨŵĿ +*********************************************/ +UINT16 ReadCiTransConfigData(const UINT8 ciId,CiTransmitStruct* pCiTransmitStru); + +/* +: ȡ·豸 +: const UINT8 ciId ID +: DiffLineDevStruct* pDiffLineDevData ·豸ָ +ֵ: [0-65535]·豸 +*/ +UINT16 ReadDiffLineDevConfigData(const UINT8 ciId, DiffLineDevStruct* pDiffLineDevData); + +/********************************************* +*ܣܿ +*˵ +*ֵ뱾ͨŵĿ +*********************************************/ +UINT16 ReadCiFuncSwitchConfigData(DquCiFuncSwitchStructNew* pCiFuncSwitConfStru); + + +/********************************************* +*ܣ͸豸 +*˵LocalciIdID +*ֵ0,ɹ +* >0,ʧ +*********************************************/ +UINT8 NeibourToLocalDevConfDataManage(const UINT8 LocalciId); + +/* +: +: const UINT8 ciId ID + pInvSecConfigDataStruct InvSecConfigDataStru[] ݽṹ +: +ֵ: 0 + >1 +*/ +INT16 ReadInvaSectionConfigData(const UINT8 ciId, InvSecConfigDataStruct pInvSecConfigDataStru[]); + +/********************************************* +*ܣʼݽṹ----ṹ +*˵pPhysicalSectionConfigDataStruݽṹָ +*ֵ +*********************************************/ +INT16 ReadTrackSectionConfigData(PhysicalSectionConfigDataStruct* pPhysicalSectionConfigDataStru); + +/********************************************* +*ܣݸݶ豸豸 +*˵PsdConfigDataStruct* psdCfgData +* EsbConfigDataStruct* esbCfgData ESB +* SpksDataConfigStruct *spksCfgData SPKS +*ֵCI_SUCCESS ɹ +* CI_ERROR ʧ +*********************************************/ +UINT8 ReadVirtualDevicesInit(PsdConfigDataStruct* psdCfgData, EsbConfigDataStruct* esbCfgData, SpksDataConfigStruct *spksCfgData, RelayConfigDataStruct *relayCfgData,IndicatorConfigDataStruct *pIndicatorConfigDataStruct); + +/* +* ȡӵͼУ汾 +* ˵ + EmapCheckVerConfigStru emapVerArr[]:洢ӵͼУõĽṹ +* ֵ: + +*/ +void ReadEmapCiConfig(EmapCiConfigStru emapVerArr[]); + +/* +* ͨŶձʼ +* ˵ void +* ֵ 0: ʼʧ +* 1: ʼɹ +*/ +UINT8 HLHTCiIdMapInitial(void); + +/* +*: +* 豸Ʋѯͨ +*˵: +* : +* const UINT16 LocalDevName 豸ID +* const UINT16 logId 豸ID +* : +* UINT32 *pHlhtId ͨIDָ +*ֵ: +* 0 ѯʧ +* 1 ѯɹ +*/ +UINT8 dquDevName2HlhtId(const UINT16 LocalDevName, const UINT16 logId, UINT32 *pHlhtId); + + + +/********************************************* +*ܣ鱣λ +*˵ +*ֵ +*********************************************/ +void CheckOverlapMaskBit(void); + +/* +: +: const UINT8 ciId ID + FloodGateConfigDataStruct floodGateConfigDataStru[] ݽṹ +: +ֵ: 0 + >1 +*/ +INT16 ReadFloodGateConfigData(const UINT8 ciId, FloodGateConfigDataStruct floodGateConfigDataStru[]); + +/********************************************* +*ܣϵͳ +*˵ciIdIDSystemParaStruct ϵͳݽṹָ +*ֵó +*********************************************/ +UINT8 ReadSystemParamConfDataNew(const UINT8 ciId,SystemParameterStructNew* SystemParameterStru); + +/********************************************* +*ܣԶͨ· +*˵ GroupAutoRouteConfigDataStruct* pGroupAutoRouteConfigDataStru Զ·ݽṹָ +*ֵԶͨ· +*********************************************/ +INT16 ReadGroupAutoRouteConfigData(GroupAutoRouteConfigDataStruct* pGroupAutoRouteConfigDataStru); + +/********************************************* +*ܣLink +*˵LinkDataConfigStru Linkݽṹָ +*ֵLink +1create 2022.02.28 +*********************************************/ +INT16 ReadLinkConfigData(LinkDataConfigStru* pLinkConfigAddr); + +/********************************************* +*ܣ +*˵pAxisConfigAddr ݽṹָ +*ֵ +1create 2022.03.11 +*********************************************/ +INT16 ReadAxisConfigData(AxisConfigStru* pAxisConfigAddr); + +/********************************************* +*ܣֽ +*˵ciIdID pstCutoffConfigDataݽṹָ +*ֵعֽID +*********************************************/ +INT16 ReadCutoffPointConfigData(const UINT8 ciId, CfpConfigStru* pstCutoffConfigData); + +/********************************************* +*ܣ豸 +*˵ciIdID pstReverseConfigData 豸ݽṹָ +*ֵعֽID +*********************************************/ +INT16 ReadReverseCutConfigData(const UINT8 ciId, ReverseCutCfgDataStru* pstReverseConfigData); +/************************************************************************ +ܣHlhtIDתvobcڲ +룺 +IN UINT32 EtcsId ETCSID + +OUT UINT16 *pDevName 2ֽڲţλ豸 λ豸) +OUT UINT16 *pEndId vobcʹö˱ 1-TC1 2-TC2 0-2IPβ೵ +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquHlhtId2VobcName(IN UINT32 EtcsId, OUT UINT16 *pDevName, OUT UINT16 *pEndId); + +/************************************************** +*ܣȡVOBC豸Ӧλѯvobc +***************************************************/ +UINT8 dquQueryVobcDevLgId2Index(UINT32 devId, UINT32 bitMask, UINT16 *pInDevIndex, UINT16 *wLogicId); + +/* +* CRC32£ע⣺CRCǴݵһֽڵBITʼ +* õĶʽ0x4c10db7LʼֵΪ0x00000000,δ񣬽ϵΪ0x00000000 +* DataLen=0ֵҲΪ0. +* ˵ pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵΪCRCֵ +*/ +UINT32 Tioc_CommonCrc32(const UINT8 *pData, UINT32 DataLen); + +/** +* @brief CRC32 ƽ̨֡ʹ +* @param pData ָ +* @param dataLen ݳ +* @return ΪCRCֵ +* @details +* £ע⣺CRCǴݵһֽڵBITʼ +* õĶʽ0x4c11db7LʼֵΪ0x00000000,δ񣬽ϵΪ0x00000000 +* dataLen=0ֵҲΪ0 +*/ +UINT32 Tioc_PlatCommonCrc32(const UINT8* pData, UINT32 dataLen); + + +/********************************************* +*ܣ +*˵EaConfigStru ݽṹָ +*ֵ +*********************************************/ +INT16 ReadEaConfigData(EaConfigStru* pEaConfigAddr); + +/********************************************* +*ܣȡTIOCȫɸЧ־ +*˵ciIdID +*ֵTIOCȫɸЧ־ TIOC_WLSCTEEN_VALID TIOC_WLSCTEEN_UNVALID +*********************************************/ +UINT8 GetWLScreenTypeById(const UINT8 ciId); + +/********************************************* +*ܣⱨ +*˵const UINT8 cLocalCiId ID +* pSGBJConfigDataStruct* SGBJConfigDataStru ⱨݽṹָ +*ֵ-1 ȡʧ + ⱨ +*********************************************/ +INT16 ReadSGBJConfigData(const UINT8 cLocalCiId, SGBJConfigDataStruct* pSGBJConfigDataStru); + +/********************************************* +*ܣȷεı߽ +*˵const UINT16 wAxleId ID +* ֵ1 ߽ +* 0 DZ߽ +*********************************************/ +UINT8 EnsureAxleBorderAtrr(const UINT16 wAxleId); + +/********************************************* +*ܣȷڼǷΪ泵 +*˵const UINT16 wAxleId ID +* ֵ1 +* 0 +* Created By LQ 2025.03.08 +*********************************************/ +UINT8 EnsureNearAxleStorageLineAtrr(const UINT16 wAxleId); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruFrmChar.c b/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruFrmChar.c new file mode 100644 index 0000000..967b32c --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruFrmChar.c @@ -0,0 +1,1133 @@ +/************************************************************************ +* +* ļ dquCIJDQStruFrmChar.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ݵ̵ṹ崦 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "dquCIJDQStruFrmChar.h" +#include "dquCIReadCommonChar.h" + +/********************************************* +*ܣʼ̵ӿݽṹ +*˵pDataAddrݵַ pRelayCfgDtStr̵ݽṹָ룬Name̵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayConfigDataStruFromChar(UINT8 * pDataAddr,RelayConfigDataStruct* pRelayCfgDtStr,CHAR* Name) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT16 i=0u; + UINT16 OcIdBuff = 0u; + UINT8 localCiPattern = 0u; /*CIģʽ*/ + + if ((NULL == pDataAddr) || (NULL == pRelayCfgDtStr) || (NULL == Name)) + { + rtnvalue = 0u; + return rtnvalue; + } + + localCiPattern = GetLocalCiPattern(); + /*̵ID (ֶ)*/ + pRelayCfgDtStr->RelayId = dquCiShortFromChar(pData); + pData += 2u; + + for(i=0u;iBelongCiId = (UINT8)(dquCiShortFromChar(pData)); + pRelayCfgDtStr->BelongOcId = 0u; + } + else + { + /*OC ID (ֶ)*/ + OcIdBuff = dquCiShortFromChar(pData); + pRelayCfgDtStr->BelongCiId = (UINT8)(GetCiIdByOcId(OcIdBuff)); + pRelayCfgDtStr->BelongOcId = OcIdBuff; + pRelayCfgDtStr->BelongDrvOcId = pRelayCfgDtStr->BelongOcId; + pRelayCfgDtStr->BelongVirCIid = GetOCBelongVirCIid((UINT8)OcIdBuff); + } + pData += 2u; + + /*ɼģʽ(ǰڵ/ڵ/˫ڵ) (ֶ)*/ + pRelayCfgDtStr->CollMode = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Aϵǰڵɼַ (ֶ)*/ + pRelayCfgDtStr->ForeNodeCollAddrA = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Aϵǰڵɼλ (ֶ)*/ + pRelayCfgDtStr->ForeNodeCollPosA = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Aϵڵɼַ (ֶ)*/ + pRelayCfgDtStr->BackNodeCollAddrA = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Aϵڵɼλ (ֶ)*/ + pRelayCfgDtStr->BackNodeCollPosA = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Bϵǰڵɼַ (ֶ)*/ + pRelayCfgDtStr->ForeNodeCollAddrB = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Bϵǰڵɼλ (ֶ)*/ + pRelayCfgDtStr->ForeNodeCollPosB = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Bϵڵɼַ (ֶ)*/ + pRelayCfgDtStr->BackNodeCollAddrB = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Bϵڵɼλ (ֶ)*/ + pRelayCfgDtStr->BackNodeCollPosB = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Aϵַ (ֶ)*/ + pRelayCfgDtStr->DrvAddrA = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Aϵλ (ֶ)*/ + pRelayCfgDtStr->DrvPosA = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Bϵַ (ֶ)*/ + pRelayCfgDtStr->DrvAddrB = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + /*Bϵλ (ֶ)*/ + pRelayCfgDtStr->DrvPosB = (UINT8)(dquCiShortFromChar(pData)); + pData += 2u; + + rtnvalue = 1u; + return rtnvalue; +} + + + +/********************************************* +*ܣʼͣť̵ṹ +*˵pDataAddrݵַ pEmgcyStpStrͣť̵ݽṹָ realRowLen ÿֽڵij +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_EmegencyStopStructFromChar(UINT8 * pDataAddr,Relay_EmgcyStpStruct* pEmgcyStpStr, UINT16 realRowLen) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 localCiPattern = 0u; /*CIģʽ*/ + + if ((NULL == pDataAddr) || (NULL == pEmgcyStpStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + localCiPattern = GetLocalCiPattern(); + pEmgcyStpStr->wEmgcyStopBtnId = dquCiShortFromChar(pData); /*ͣťID */ + pData += 2u; + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pEmgcyStpStr->wOcId = dquCiShortFromChar(pData); /*OC ID*/ + pData += 2u; + } + pEmgcyStpStr->wEmgcyStopBtnRelayId = dquCiShortFromChar(pData); /*ͣť̵ID */ + pData += 2u; + if (CI_PATTERN_TRADITIONAL == localCiPattern) + { + pEmgcyStpStr->wRepEmgcyStopBtnRelayId = dquCiShortFromChar(pData); /*ʾͣť̵ID */ + pData += 2u; + } + else + { + pEmgcyStpStr->wEmgcyStopBtnRelayId2 = dquCiShortFromChar(pData); /*ͣť̵ID 2*/ + pData += 2u; + pEmgcyStpStr->wEmgcyStopBtnIndicateRelayId = dquCiShortFromChar(pData); + pData += 2u; + pEmgcyStpStr->wEmgcyStopCutRelayId = dquCiShortFromChar(pData); + pData += 2u; + pEmgcyStpStr->wEmgcyStopCutIndicateRelayId = dquCiShortFromChar(pData); + pData += 2u; + pEmgcyStpStr->wEmgcyStopBuzzRelayId = dquCiShortFromChar(pData); + pData += 2u; + pEmgcyStpStr->wESSRelayId = dquCiShortFromChar(pData); + pData += 2u; + pEmgcyStpStr->wESSSteadyIndicatRelayId = dquCiShortFromChar(pData); + pData += 2u; + pEmgcyStpStr->wESSFlashIndicatRelayId = dquCiShortFromChar(pData); + pData += 2u; + } + if (22U < realRowLen) + { + /*ȡͣť̵ID*/ + pEmgcyStpStr->wCancelEsbRelayId = dquCiShortFromChar(pData); + pData += 2u; + /*ͣťվָ̨ʾƼ̵ID*/ + pEmgcyStpStr->wEsbPlatformDisRelayId = dquCiShortFromChar(pData); + pData += 2u; + /*г̵ID*/ + pEmgcyStpStr->wCutoffEsbBuzzRelayId = dquCiShortFromChar(pData); + pData += 2u; + } + else + { + /*ȡͣť̵ID*/ + pEmgcyStpStr->wCancelEsbRelayId = 0U; + /*ͣťվָ̨ʾƼ̵ID*/ + pEmgcyStpStr->wEsbPlatformDisRelayId = 0U; + /*г̵ID*/ + pEmgcyStpStr->wCutoffEsbBuzzRelayId = 0U; + } + rtnvalue = 1u; + return rtnvalue; +} +/********************************************* +*ܣݵż̵ṹ +*˵pDataAddrݵַ pScrnStrż̵ݽṹָ,UINT16 rowLen һݵij +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_ScreenStructFromChar(UINT8 * pDataAddr,Relay_ScreenStruct* pScrnStr, UINT16 rowLen) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 localCiPattern = 0u; /*CIģʽ*/ + + if ((NULL == pDataAddr) || (NULL == pScrnStr)) + { + rtnvalue = 0u; + } + else + { + localCiPattern = GetLocalCiPattern(); + pScrnStr->wScreenId = dquCiShortFromChar(pData); /*ID (ֶ)*/ + pData += 2u; + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pScrnStr->wOcId = dquCiShortFromChar(pData); /*OC ID*/ + pData += 2u; + } + pScrnStr->wRelayRelatedId = dquCiShortFromChar(pData); /*̵ID */ + pData += 2u; + + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pScrnStr->wRelayRelatedId2 = dquCiShortFromChar(pData); /*̵ID2 */ + pData += 2; + } + pScrnStr->wRelayDoorClosedId = dquCiShortFromChar(pData); /*Źؼ̵ID */ + pData += 2u; + + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pScrnStr->wRelayDoorClosedId2 = dquCiShortFromChar(pData); /*Źؼ̵ID2 */ + pData += 2; + } + pScrnStr->wRelayCloseDoorId = dquCiShortFromChar(pData); /*ż̵ID */ + pData += 2u; + pScrnStr->wRelayFourEditGroupOpenDoorId = dquCiShortFromChar(pData); /*4鿪ż̵ID */ + pData += 2u; + pScrnStr->wRelaySixEditGroupOpenDoorId = dquCiShortFromChar(pData); /*6鿪ż̵ID */ + pData += 2u; + pScrnStr->wRelayEightEditGroupOpenDoorId = dquCiShortFromChar(pData); /*8鿪ż̵ID */ + pData += 2u; + pScrnStr->wRelayDoorButtonId = dquCiShortFromChar(pData); /*PSDť̵*/ + pData += 2u; + pScrnStr->doorReopenRelayId = dquCiShortFromChar(pData); /*վ̨ٴοż̵ID*/ + pData += 2u; + pScrnStr->departureConfirmRelayId = dquCiShortFromChar(pData); /*ȷϼ̵ID*/ + pData += 2u; + pScrnStr->detectStartRelayId = dquCiShortFromChar(pData); /*̵̽ID*/ + pData += 2u; + pScrnStr->detectStopRelayId = dquCiShortFromChar(pData); /*̵ֹͣ̽ID*/ + pData += 2u; + pScrnStr->obstacleRelayId = dquCiShortFromChar(pData); /*ϰ̵ID*/ + pData += 2u; + pScrnStr->gapDetMuLockRelayId = dquCiShortFromChar(pData); /*϶̽⻥̵ID*/ + pData += 2u; + pScrnStr->closeStateRelayId = dquCiShortFromChar(pData); /*״̵̬ID*/ + pData += 2u; + + if (36U < rowLen) + { + pScrnStr->wClearPasseSteadyLightRelayId = dquCiShortFromChar(pData); /*ȷϰťָʾȵƼ̵ID*/ + pData += 2u; + pScrnStr->wClearPasseFlashLightRelayId = dquCiShortFromChar(pData); /*ȷϰťָʾƼ̵ID*/ + pData += 2u; + pScrnStr->wClearPassengerButtonRelayId = dquCiShortFromChar(pData); /*ȷϰť̵ID*/ + pData += 2u; + } + + if (42U < rowLen) + { + pScrnStr->wCleFarePCBButtonRelayId = dquCiShortFromChar(pData); /*ȷPCBť̵*/ + pData += 2u; + pScrnStr->wCleFarePDBFlaLigRelayId = dquCiShortFromChar(pData); /*ȷPDBťָʾƼ̵*/ + pData += 2u; + } + + if (46U < rowLen) + { + pScrnStr->wPobBsdRelayId = dquCiShortFromChar(pData); /*վ̨ٿŰťָʾƼ̵*/ + pData += 2u; + pScrnStr->wPcbBsdRelayId = dquCiShortFromChar(pData); /*վ̨ٹŰťָʾƼ̵*/ + pData += 2u; + } + + if (50U < rowLen) + { + pScrnStr->wVideoQkLight1RelayId = dquCiShortFromChar(pData); /*ͰťƵָʾ1̵̣*/ + pData += 2U; + pScrnStr->wVideoQkLight2RelayId = dquCiShortFromChar(pData); /*ͰťƵָʾ2죩̵*/ + pData += 2U; + } + + rtnvalue = 1u; + } + + return rtnvalue; +} +/********************************************* +*ܣݵμ̵ṹ +*˵pDataAddrݵַpPhysclSgmtStr μ̵ݽṹָ +* UINT16 realRowLen һʵֽ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_PhysicalSegmentStructFromChar(UINT8 * pDataAddr,Relay_PhysicalSegmentStruct* pPhysclSgmtStr,UINT16 realRowLen) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 localCiPattern = 0u; /*CIģʽ*/ + UINT16 index = 0u; + + if ((NULL == pDataAddr) || (NULL == pPhysclSgmtStr)) + { + rtnvalue = 0u; + } + else + { + localCiPattern = GetLocalCiPattern(); + pPhysclSgmtStr->wPhysicalId = dquCiShortFromChar(pData); /*ID*/ + pData += 2u; + index += 2u; + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pPhysclSgmtStr->wOcId = dquCiShortFromChar(pData); /*OC ID*/ + pData += 2u; + index += 2u; + } + pPhysclSgmtStr->wRelayRailwayId = dquCiShortFromChar(pData); /*̵ID */ + pData += 2u; + index += 2u; + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pPhysclSgmtStr->wRelayRailwayId2 = dquCiShortFromChar(pData); /*̵ID2 */ + pData += 2; + } + pPhysclSgmtStr->wRelayAxleRetrunId = dquCiShortFromChar(pData); /*Ḵλ̵ID */ + pData += 2u; + index += 2u; + pPhysclSgmtStr->wRelayAxleZongRetrunId = dquCiShortFromChar(pData); /*ܸλ̵ID */ + pData += 2u; + index += 2u; + pPhysclSgmtStr->wRelayAxlePreResetId = dquCiShortFromChar(pData); /*Ԥλ״̵̬ID */ + pData += 2u; + index += 2u; + if (CI_PATTERN_TRADITIONAL == localCiPattern) + { + pPhysclSgmtStr->wRepRelayTrainId = dquCiShortFromChar(pData); /*ʾ̵ID */ + pData += 2u; + index += 2u; + } + /*Ƚֽ*/ + if(index + 2u <= realRowLen) + { + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pPhysclSgmtStr->wRepRelayZongResetShowId = dquCiShortFromChar(pData); /*ܸλʾ */ + pData += 2u; + index += 2u; + } + } + + rtnvalue = 1u; + } + return rtnvalue; +} + +/********************************************* +*ܣݵ̵ṹ +*˵pDataAddrݵַpPhysclSgmtStr ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_PointStructFromChar(UINT8 * pDataAddr,Relay_PointStruct* pSwitchStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ:0x55:ǹ콻ͨ0xAA:콻ͨ*/ + if ((NULL == pDataAddr) || (NULL == pSwitchStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + if (CI_TRADITION_RAILWAY == lineIdentity) + {/*ǹ·*/ + pSwitchStr->wPointId = dquCiShortFromChar(pData); /*ID*/ + pData += 2u; + + /*OCID*/ + pData += 2u; + pSwitchStr->wRelayDingBiaoId = dquCiShortFromChar(pData); /*̵ID */ + pData += 2u; + pSwitchStr->wRelayFanBiaoId = dquCiShortFromChar(pData); /*̵ID */ + pData += 2u; + + pSwitchStr->wRelayYunCaoId = dquCiShortFromChar(pData); /*ʲټ̵ID*/ + pData += 2u; + pSwitchStr->wRelayDingCaoId = dquCiShortFromChar(pData); /*ټ̵ID */ + pData += 2u; + pSwitchStr->wRelayFanCaoId = dquCiShortFromChar(pData); /*ټ̵ID */ + pData += 2u; + pSwitchStr->wRelayZongDingBiaoId = dquCiShortFromChar(pData); /*̵ܶID */ + pData += 2u; + pSwitchStr->wRelayZongFanBiaoId = dquCiShortFromChar(pData); /*̵ܷID */ + pData += 2u; + pSwitchStr->wDFHId = dquCiShortFromChar(pData); /*DFH̵ID*/ + pData += 2u; + + pSwitchStr->wRelayShadowDingBiaoId = dquCiShortFromChar(pData); /*̵ID */ + pData += 2u; + pSwitchStr->wRelayShadowFanBiaoId = dquCiShortFromChar(pData); /*̵ID */ + pData += 2u; + }/* zt ɾش 2022-02-15 */ + else + { + + } + + rtnvalue = 1u; + return rtnvalue; +} +/********************************************* +*ܣݵźŻ̵ṹ +*˵pDataAddrݵַ pSgnlStrźŻ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_SignalStructFromChar(UINT8 * pDataAddr,Relay_SignalStruct* pSgnlStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pSgnlStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pSgnlStr->wSignalId = dquCiShortFromChar(pData); /*źŻID*/ + pData += 2u; + + /*OC ID*/ + pData += 2U; + pSgnlStr->wRelayDengSiId_1 = dquCiShortFromChar(pData); /*1˿̵ID*/ + pData += 2u; + pSgnlStr->wRelayDengSiId_2 = dquCiShortFromChar(pData); /*1˿̵ID*/ + pData += 2u; + pSgnlStr->wRelayTrainSignalId = dquCiShortFromChar(pData); /*гźż̵ID*/ + pData += 2u; + pSgnlStr->wRelayZhengXianId = dquCiShortFromChar(pData); /*źż̵ID*/ + pData += 2u; + pSgnlStr->wRelayYinDaoId = dquCiShortFromChar(pData); /*źż̵ID*/ + pData += 2u; + pSgnlStr->wRelayDianDengId = dquCiShortFromChar(pData); /*Ƽ̵ID*/ + pData += 2u; + pSgnlStr->wRelayDiaoCheSignalId = dquCiShortFromChar(pData); /*źż̵ID*/ + pData += 2u; + pSgnlStr->wSignalDrvColType = dquCiShortFromChar(pData); /*źŻɼModified on 20160330*/ + pData += 2u; + + pSgnlStr->DetainBtnCollRelayId = dquCiShortFromChar(pData);/*۳ť̵*/ + pData+=2u; + pSgnlStr->DetainBtnIndicatorRelayId = dquCiShortFromChar(pData);/*۳ťָʾƼ̵*/ + pData+=2u; + pSgnlStr->DetainCutBtnRelayId = dquCiShortFromChar(pData);/*۳ť·̵*/ + pData+=2u; + pSgnlStr->DetainCutBtnIndicatorRelayId = dquCiShortFromChar(pData);/*۳·ťָʾƼ̵ID*/ + pData+=2u; + + rtnvalue = 1u; + return rtnvalue; + +} + +/********************************************* +*ܣݵϴ̵ṹ +*˵pDataAddrݵַ pWashMachineStr ϴ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_WashMachineStructFromChar(UINT8 * pDataAddr,Relay_WashMachineStruct * pWashMachineStr, UINT16 realRowLen) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 1U; + UINT16 index = 0U; + + if ((NULL == pDataAddr) || (NULL == pWashMachineStr)) + { + rtnvalue = 0U; + + } + if(1U == rtnvalue) + { + pWashMachineStr->wId = dquCiShortFromChar(pData); /*ϴID*/ + pData += 2U; + pWashMachineStr->WashMachineReadyRelayId = dquCiShortFromChar(pData); /*ϴ̵ID*/ + pData += 2U; + pWashMachineStr->WashMachineRequestVerifyRelayId = dquCiShortFromChar(pData); /*ϴָȷϼ̵ID*/ + pData += 2U; + pWashMachineStr->TrainEmergencyStopRelayId = dquCiShortFromChar(pData); /*г̵ͣID*/ + pData += 2U; + pWashMachineStr->HeadWashAllowRelayId = dquCiShortFromChar(pData); /*1̵ID*/ + pData += 2U; + pWashMachineStr->TailWashAllowRelayId = dquCiShortFromChar(pData); /*2̵ID*/ + pData += 2U; + pWashMachineStr->WashTrainRequestRelayId= dquCiShortFromChar(pData); /*ϴ̵ID*/ + pData += 2U; + + pWashMachineStr->TrainHeadStopSteadyRelayId = dquCiShortFromChar(pData); /*гͣ1̵ID*/ + pData += 2U; + pWashMachineStr->TrainTailStopSteadyRelayId = dquCiShortFromChar(pData); /*гͣ2̵ID*/ + pData += 2U; + pWashMachineStr->TrainOutWashPortAllowRelayId = dquCiShortFromChar(pData);/*̵ID*/ + pData += 2U; + pWashMachineStr->PauseTrainWashRequestRelayId = dquCiShortFromChar(pData); /*ͣϴ̵ID*/ + pData += 2U; + pWashMachineStr->TrainPassRequestRelayId = dquCiShortFromChar(pData); /*̵ͨID*/ + pData += 2U; + + index += 24U; + if (index + 2U <= realRowLen) + { + pWashMachineStr->WashModeBackRelayId = dquCiShortFromChar(pData); /*ȫԶϴģʽ̵(ֶ:ɼ̵)*/ + pData += 2U; + + pWashMachineStr->WashModeRelayId = dquCiShortFromChar(pData);/*ȫԶԶϴģʽ̵ֶ:̵)*/ + pData += 2U; + pWashMachineStr->wDownWashAllowRelayId = dquCiShortFromChar(pData);/*ģʽϴͬⰴť̵ID(ֶ:ɼ̵)*/ + pData += 2U; + pWashMachineStr->wDownWashAllowLightRelayId = dquCiShortFromChar(pData);/*ģʽϴָͬʾƼ̵IDֶ:̵)*/ + pData += 2U; + pWashMachineStr->wDownWashAllowPassRelayId = dquCiShortFromChar(pData);/*ģʽϴͬͨť̵ID(ֶ:ɼ̵)*/ + pData += 2U; + pWashMachineStr->wDownWashRelateRoute1Id = dquCiShortFromChar(pData);/*ģʽϴ߿̨ʾ1·ID*/ + pData += 2U; + pWashMachineStr->wDownWashRelateRoute1CheckType = *pData;/*ģʽϴ߿̨ʾ1·״̬*/ + pData += 1U; + pWashMachineStr->wDownWashRelRoute1LightRelayId = dquCiShortFromChar(pData);/*ģʽϴ߿̨ʾ1̵IDֶ:̵)*/ + pData += 2U; + pWashMachineStr->wDownWashRelateRoute2Id = dquCiShortFromChar(pData);/*ģʽϴ߿̨ʾ2·ID*/ + pData += 2U; + pWashMachineStr->wDownWashRelateRoute2CheckType = *pData;/*ģʽϴ߿̨ʾ2·״̬*/ + pData += 1U; + pWashMachineStr->wDownWashRelRoute2LightRelayId = dquCiShortFromChar(pData);/*ģʽϴ߿̨ʾ2̵IDֶ:̵)*/ + pData += 2U; + + index += 20U; + } + + rtnvalue = 1U; + } + + return rtnvalue; + +} +/********************************************* +*ܣݵǽ·ݼ̵ṹ +*˵pDataAddrݵַ pNoRotStrǽ·ݼ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_NoRouteDcStruFromChar(UINT8 * pDataAddr,Relay_NoRouteDcStruct* pNoRotStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pNoRotStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pNoRotStr->wId = dquCiShortFromChar(pData); /*ǽ·ID*/ + pData += 2u; + pNoRotStr->wRelayShenQingScId = dquCiShortFromChar(pData); /* βɼԳ̵ID */ + pData += 2u; + pNoRotStr->wRelayTongYiScId = dquCiShortFromChar(pData); /* ͬԳ̵ID */ + pData += 2u; + + pNoRotStr->wRelayDrvShiCheShengQingId = dquCiShortFromChar(pData); /* ԳԳ̵ID */ + pData += 2u; + + pNoRotStr->wRelayColTongYiScId = dquCiShortFromChar(pData); /* Գ߲ɼͬԳ̵ID */ + pData += 2u; + + rtnvalue = 1u; + return rtnvalue; + +} +/********************************************* +*ܣݵղ̵ṹ +*˵pDataAddrݵַ pZCStr ղ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_ZhaoChaStruFromChar(UINT8 * pDataAddr,Relay_ZhaoChaStruct* pZCStr,UINT16 realRowLen) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0U; + UINT8 i = 0U; + UINT16 index = 0U; + UINT8 chLocalCiPattern = 0U; + + chLocalCiPattern = GetLocalCiPattern(); + + if ((NULL == pDataAddr) || (NULL == pZCStr)) + { + rtnvalue = 0U; + return rtnvalue; + } + + pZCStr->wRouteId = dquCiShortFromChar(pData); /*·ID*/ + pData += 2U; + index += 2U; + pZCStr->wRelayBenDuanZcId = dquCiShortFromChar(pData); /*˼̵ID*/ + pData += 2U; + index += 2U; + pZCStr->wRelayDuiDuanZcId = dquCiShortFromChar(pData); /*Զ˼̵ID*/ + pData += 2U; + index += 2U; + pZCStr->wCancelRelayId = dquCiShortFromChar(pData); /*ȡղ̵ID*/ + pData += 2U; + index += 2U; + + /*ղ1-5ID*/ + for(i=0u; iwRelayZhaoChaPhySecId[i] = dquCiShortFromChar(pData); + pData += 2U; + index += 2U; + } + + if (CI_PATTERN_TRADITIONAL == chLocalCiPattern) + { + pZCStr->wCancelRelayIdOnRelayInterface = dquCiShortFromChar(pData); /*̵ӿȡղ̵ID*/ + pData += 2u; + index += 2u; + + if ((index + 4u) <= realRowLen) + { + pZCStr->wRelayBenDuanZcIdOnRelayInterface = dquCiShortFromChar(pData); /*̵ӿڱղ̵ID*/ + pData += 2u; + index += 2u; + pZCStr->wRelayDuiDuanZcIdOnRelayInterface = dquCiShortFromChar(pData); /*̵ӿڶԶղ̵ID*/ + pData += 2u; + index += 2u; + } + } + else if (CI_PATTERN_FULL_ELECTRONIC == chLocalCiPattern) + { + if ((index + 6U) <= realRowLen) + { + pZCStr->wCbtcRelayBenDuanZcId = dquCiShortFromChar(pData); /*CBTC˼̵ID*/ + pData += 2U; + index += 2U; + pZCStr->wCbtcRelayDuiDuanZcId = dquCiShortFromChar(pData); /*CBTCԶ˼̵ID*/ + pData += 2U; + index += 2U; + pZCStr->wCbtcCancelRelayId = dquCiShortFromChar(pData); /*CBTCȡղ̵ID*/ + pData += 2U; + index += 2U; + } + } + else + { + ; /*Ƿֵ*/ + } + rtnvalue = 1U; + return rtnvalue; + +} +/********************************************* +*ܣݵƼ̵ṹ +*˵pDataAddrݵַ pBjdStr Ƽ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_BaoJingDengStruFromChar(UINT8 * pDataAddr,Relay_BaoJingDengStruct* pBjdStr,UINT32 dwRowLen) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT16 i=0u; + UINT8 localCiPattern = 0u; /*CIģʽ*/ + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT16 OCid = 0u; + + if ((NULL == pDataAddr) || (NULL == pBjdStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + localCiPattern = GetLocalCiPattern(); + pBjdStr->wId = dquCiShortFromChar(pData); /*ID*/ + pData += 2u; + pBjdStr->wBelongCiId = dquCiShortFromChar(pData); /*ID*/ + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + OCid = pBjdStr->wBelongCiId;/*ӦȫȡOCid*/ + pBjdStr->wBelongCiId = GetCiIdByOcId(pBjdStr->wBelongCiId);/*ҵ0CidӦid*/ + if(FUNC_SWITCH_ON == includeVirFlag) + { + pBjdStr->wBelongVirCIid = GetOCBelongVirCIid((UINT8)OCid);/*ҵ0CidӦid*/ + } + else + { + pBjdStr->wBelongVirCIid = 0u; + } + } + pData += 2u; + pBjdStr->wBjdID = dquCiShortFromChar(pData); /*ID*/ + pData += 2u; + pBjdStr->wBjdYouXiao = *pData; /*ǷЧ*/ + pData += 1u; + for(i=0u;iwBjdJdqId[i] = dquCiShortFromChar(pData); /*Զ˼̵ID*/ + pData += 2u; + } + + if (15U < dwRowLen) + { + pBjdStr->cBjdDevId = *pData; + pData += 1; + } + + rtnvalue = 1u; + return rtnvalue; + +} + +/********************************************* +*ܣݵ۷̵ṹ +*˵pDataAddrݵַ pWuRenRtnStr۷̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_NoReturnStruFromChar(UINT8 * pDataAddr,Relay_NoReturnStruct* pWuRenRtnStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 localCiPattern = 0u; /*CIģʽ*/ + + if ((NULL == pDataAddr) || (NULL == pWuRenRtnStr)) + { + rtnvalue = 0u; + } + else + { + localCiPattern = GetLocalCiPattern(); + pWuRenRtnStr->wId = dquCiShortFromChar(pData); /*ID*/ + pData += 2u; + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pWuRenRtnStr->ocId = dquCiShortFromChar(pData); /*OC ID*/ + pData += 2u; + } + pWuRenRtnStr->wWuRenReturnRelayId = dquCiShortFromChar(pData); /*̵ID*/ + pData += 2u; + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pWuRenRtnStr->wWuRenReturnDisRelayId = dquCiShortFromChar(pData); /*۷ָʾƼ̵ID*/ + pData += 2u; + } + + rtnvalue = 1u; + } + + return rtnvalue; +} + +/********************************************* +*ܣʼż̵ṹ +*˵pDataAddrݵַ pGaragedoorStrż̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_GaragedoorStructFromChar(UINT8 * pDataAddr,Relay_GaragedoorStruct* pGaragedoorStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pGaragedoorStr)) + { + rtnvalue = 0u; + } + else + { + pGaragedoorStr->wGaragedoorId = dquCiShortFromChar(pData); /* ID */ + pData += 2u; + pGaragedoorStr->wGardoorCloseRelayId = dquCiShortFromChar(pData); /* Źż̵ID*/ + pData += 2u; + pGaragedoorStr->wGardoorOpenRelayId = dquCiShortFromChar(pData); /* ſż̵ID*/ + pData += 2u; + pGaragedoorStr->wGardoorCloseOrderRelayId = dquCiShortFromChar(pData); /* Ź̵ID*/ + pData += 2u; + pGaragedoorStr->wGardoorOpenOrderRelayId = dquCiShortFromChar(pData); /* ſ̵ID*/ + pData += 2u; + pGaragedoorStr->wGardoorModeStateRelayId = dquCiShortFromChar(pData); /* ģʽ״̵̬ID*/ + pData += 2u; + pGaragedoorStr->wGardoorFaultStateRelayId = dquCiShortFromChar(pData); /* Źϼ̵ID*/ + pData += 2u; + pGaragedoorStr->wGardoorPangLuRelayId = dquCiShortFromChar(pData); /* ·̵ID*/ + pData += 2u; + pGaragedoorStr->wGardoorKGHRelayId = dquCiShortFromChar(pData); /* ſغڵ̵ID*/ + pData += 2u; + rtnvalue = 1u; + } + return rtnvalue; +} + + +/********************************************* +*ܣݵSPKS̵ṹ +*˵pDataAddrݵַ pSpksStr SPKSݽṹָ realRowLen ÿһݳ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_SpksDataFromChar(UINT8 * pDataAddr,RelaySpksStruct* pSpksStr, UINT16 realRowLen) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 localCiPattern = 0u; /*CIģʽ*/ + + if ((NULL == pDataAddr) || (NULL == pSpksStr)) + { + rtnvalue = 0u; + } + else + { + localCiPattern = GetLocalCiPattern(); + + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + pSpksStr->id = dquCiShortFromChar(pData); /* ID */ + pData += 2u; + + pSpksStr->ocId = dquCiShortFromChar(pData); /*OC ID*/ + pData += 2u; + + pSpksStr->colRelayId = dquCiShortFromChar(pData); /* ɼ̵ID */ + pData += 2u; + + pSpksStr->disRelayId = dquCiShortFromChar(pData); /* ʾƼ̵ID */ + pData += 2u; + + pSpksStr->cutRelayId = dquCiShortFromChar(pData); /* ·̵ID */ + pData += 2u; + + pSpksStr->cutDisRelayId = dquCiShortFromChar(pData); /*SPKS·ťָʾƼ̵ID*/ + pData += 2u; + + pSpksStr->outsideRelayId = dquCiShortFromChar(pData); /*SPKSָʾƼ̵*/ + pData += 2u; + + + } + else if (CI_PATTERN_TRADITIONAL == localCiPattern) + { + pSpksStr->id = dquCiShortFromChar(pData); /* ID */ + pData += 2u; + + pSpksStr->colRelayId = dquCiShortFromChar(pData); /* ɼ̵ID */ + pData += 2u; + + pSpksStr->disRelayId = dquCiShortFromChar(pData); /* ʾƼ̵ID */ + pData += 2u; + + pSpksStr->cutRelayId = dquCiShortFromChar(pData); /* ·̵ID */ + pData += 2u; + + pSpksStr->cutDisRelayId = dquCiShortFromChar(pData); /*SPKS·ťָʾƼ̵ID*/ + pData += 2u; + + pSpksStr->outsideRelayId = dquCiShortFromChar(pData); /*SPKSָʾƼ̵*/ + pData += 2u; + + pSpksStr->repRelayId = dquCiShortFromChar(pData); /* ʾ̵ID */ + pData += 2u; + } + else + { + /**/ + ; + } + rtnvalue = 1u; + } + + return rtnvalue; +} + +/********************************************* +*ܣݵŽ̵ṹ +*˵pDataAddrݵַ pMjStr Žݽṹָ realRowLen ÿһݳ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_MJDataFromChar(UINT8* pDataAddr, Relay_MJStruct* pMjStr, UINT16 realRowLen) +{ + UINT8* pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 localCiPattern = 0u; /*CIģʽ*/ + UINT8 realSPKSNum = 0u; /*ʵдSPKS*/ + UINT8 ii = 0u; + UINT16 wSpksId = 0U; + + if ((NULL == pDataAddr) || (NULL == pMjStr)) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1U; + localCiPattern = GetLocalCiPattern(); + realSPKSNum = (UINT8)((realRowLen - 6u) / 2u); /*ȥŽID OCID MJ̵ID6ֽ*/ + + if ((CI_PATTERN_FULL_ELECTRONIC == localCiPattern)|| (CI_PATTERN_TRADITIONAL == localCiPattern)) + { + pMjStr->mjid = dquCiShortFromChar(pData); /* ID */ + pData += 2u; + + pMjStr->ocId = dquCiShortFromChar(pData); /*OC ID*/ + pData += 2u; + + pMjStr->mjjsRelayId = dquCiShortFromChar(pData); /* Ž̵ID */ + pData += 2u; + + for ( ii = 0u; ii < realSPKSNum; ii++) + { + wSpksId = dquCiShortFromChar(pData); + pData += 2u; + + if ((0U == ii) && ((0U == wSpksId) || (UINT16_MAX <= wSpksId))) + { + rtnvalue = 0U; /*SPKS IDǷֹͣȡ0*/ + break; + } + else + { + pMjStr->spksId[ii] = wSpksId; + } + } + } + else + { + /**/ + ; + } + } + + return rtnvalue; +} + + +/********************************************* +*ܣݵż̵ṹ +*˵pDataAddrݵַ pFloodGateStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_FloodGateStructFromChar(UINT8 * pDataAddr,Relay_FloodGateStruct* pFloodGateStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pFloodGateStr)) + { + rtnvalue = 0u; + } + else + { + pFloodGateStr->wFloodGateId = dquCiShortFromChar(pData); /* ID */ + pData += 2u; + pFloodGateStr->wCloseApplyRelayId = dquCiShortFromChar(pData); /* ̵ID */ + pData += 2u; + pFloodGateStr->wOpenCloseRelayId = dquCiShortFromChar(pData); /* ռ̵ID */ + pData += 2u; + pFloodGateStr->wAllowRequestRelayId = dquCiShortFromChar(pData); /* ̵ID */ + pData += 2u; + + rtnvalue = 1u; + } + + return rtnvalue; +} + +/********************************************* +*ܣݵ̵ͬṹ +*˵pDataAddrݵַ pWashMachineStr ϴ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_DCAgreeStructFromChar(UINT8 * pDataAddr,Relay_DCAgreeStruct * pDCAgreeStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 1u; + + if ((NULL == pDataAddr) || (NULL == pDCAgreeStr)) + { + rtnvalue = 0u; + + } + if(1u == rtnvalue) + { + pDCAgreeStr->wRouteId = dquCiShortFromChar(pData); /*·ID*/ + pData += 2u; + pDCAgreeStr->DCRouteDCQJId = dquCiShortFromChar(pData); /*ͬ-̵ID*/ + pData += 2u; + pDCAgreeStr->DCRouteTAJId = dquCiShortFromChar(pData); /*ͬ-ͬⰴť̵ID*/ + pData += 2u; + + rtnvalue = 1u; + } + + return rtnvalue; + +} + +/********************************************* +*ܣʼ̵νṹ +*˵ pDataAddrݵַ pRelayCfgDtStr̵ݽṹָ + pRelayId̵idַ pSecBufidеַ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayCfgFaultLockPhySecFromChar(UINT8 * pDataAddr,RelayConfigDataStruct* pRelayCfgDtStr, + UINT16 *pRelayId,UINT16 pSecBuf[][MAX_LOCK_EXCEPT_SECTION_NUM]) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT16 i=0u; + + if ((NULL == pDataAddr) || (NULL == pRelayCfgDtStr) || (NULL == pRelayId) || (NULL == pSecBuf)) + { + rtnvalue = 0u; + + } + else + { + rtnvalue = 1u; + + /*̵ID (ֶ)*/ + *pRelayId = dquCiShortFromChar(pData); + pData += 2u; + + /*ID(ֶ)*/ + for (i=0u;iwReverseCutRelayId = dquCiShortFromChar(pData); /*·ID*/ + pData += 2u; + + + rtnvalue = 1u; + } + + return rtnvalue; + +} +/********************************************* +*ܣݵOCվָʾƵƼ̵ṹ +*˵pDataAddrݵַ pBjdStr Ƽ̵ݽṹָ +*ֵ0ʧܣ1ɹ +* cgh-ϲCID-3037-3 +*********************************************/ +UINT8 R_OCIndicStruFromChar(UINT8* pDataAddr, OCStationIndicConfigDataStru* pIndicStru) +{ + UINT8* pData = pDataAddr; + UINT16 i = 0u; + UINT16 OCid = 0u; + UINT8 reVal = CI_ERROR; + UINT16 ocid = 0u; + UINT8 localCiId = GetSystemParaLocalCiId(); + UINT8 belongCiId = 0u; + UINT16 indicatorId = 0u; + UINT8 avalibleFlag = 0u; + UINT16 relayID = 0u; + if ((NULL != pData) && (NULL != pIndicStru)) + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + reVal = CI_ERROR; + + pData += 2; /*ID*/ + ocid = dquCiShortFromChar(pData); /*ID*/ + pData += 2; + belongCiId = (UINT8)GetCiIdByOcId(ocid); + if (localCiId == belongCiId) + { + + indicatorId = dquCiShortFromChar(pData); /*ID*/ + pData += 2; + avalibleFlag = *pData; /*ǷЧ*/ + pData += 1; + + if (INDICATOR_DATA_RELAY == avalibleFlag) + { + reVal = CI_SUCCESS; + + pIndicStru->OcId = (UINT8)ocid; + pIndicStru->IndicatorId = (UINT8)indicatorId; + pIndicStru->IndicatorType = (UINT8)indicatorId;/*ͺIDͬ*/ + + for (i = 0; i < INDICATOR_RELAY_SUM_MAX; i++) + { + relayID = dquCiShortFromChar(pData); /*̵ID*/ + pData += 2; + if ((0u == relayID) || (UINT16_MAX == relayID)) + { + } + else + { + pIndicStru->IdBuf[i] = relayID;/*̵ID*/ + pIndicStru->IdSum++;/*̵Ŀ*/ + } + } + } + + } + } + + return reVal; +} + + diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruFrmChar.h b/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruFrmChar.h new file mode 100644 index 0000000..f630921 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruFrmChar.h @@ -0,0 +1,152 @@ +/************************************************************************ +* +* ļ dquCIJDQStruFrmChar.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ݵ̵ṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_CI_JDQ_STRU_FRM_CHAR +#define DQU_CI_JDQ_STRU_FRM_CHAR + + +#include "dquEmapInit.h" +#include "dquCIJDQStru.h" +#include "dquCIInit.h" +/********************************************* +*ܣʼ̵ӿݽṹ +*˵pDataAddrݵַ pRelayCfgDtStr̵ݽṹָ룬Name̵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayConfigDataStruFromChar(UINT8 * pDataAddr,RelayConfigDataStruct* pRelayCfgDtStr,CHAR* Name); +/********************************************* +*ܣʼͣť̵ṹ +*˵pDataAddrݵַ pEmgcyStpStrͣť̵ݽṹָ realRowLen ÿֽڵij +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_EmegencyStopStructFromChar(UINT8 * pDataAddr,Relay_EmgcyStpStruct* pEmgcyStpStr,UINT16 realRowLen); + +/********************************************* +*ܣݵż̵ṹ +*˵pDataAddrݵַ pScrnStrż̵ݽṹָ,UINT16 rowLen һݵij +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_ScreenStructFromChar(UINT8* pDataAddr, Relay_ScreenStruct* pScrnStr, UINT16 rowLen); + +/********************************************* +*ܣݵμ̵ṹ +*˵pDataAddrݵַpPhysclSgmtStr μ̵ݽṹָ +* UINT16 realRowLen һʵֽ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_PhysicalSegmentStructFromChar(UINT8 * pDataAddr,Relay_PhysicalSegmentStruct* pPhysclSgmtStr,UINT16 realRowLen); + + +/********************************************* +*ܣݵ̵ṹ +*˵pDataAddrݵַpSwitchStr ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_PointStructFromChar(UINT8 * pDataAddr,Relay_PointStruct* pSwitchStr); + +/********************************************* +*ܣݵźŻ̵ṹ +*˵pDataAddrݵַ pSgnlStrźŻ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_SignalStructFromChar(UINT8 * pDataAddr,Relay_SignalStruct* pSgnlStr); +/********************************************* +*ܣݵϴ̵ṹ +*˵pDataAddrݵַ pWashMachineStr ϴ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_WashMachineStructFromChar(UINT8 * pDataAddr,Relay_WashMachineStruct * pWashMachineStr,UINT16 realRowLen); + +/********************************************* +*ܣݵǽ·ݼ̵ṹ +*˵pDataAddrݵַ pNoRotStrǽ·ݼ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_NoRouteDcStruFromChar(UINT8 * pDataAddr,Relay_NoRouteDcStruct* pNoRotStr); + +/********************************************* +*ܣݵղ̵ṹ +*˵pDataAddrݵַ pZCStr ղ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_ZhaoChaStruFromChar(UINT8 * pDataAddr,Relay_ZhaoChaStruct* pZCStr,UINT16 realRowLen); + +/********************************************* +*ܣݵƼ̵ṹ +*˵pDataAddrݵַ pBjdStr Ƽ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_BaoJingDengStruFromChar(UINT8 * pDataAddr,Relay_BaoJingDengStruct* pBjdStr, UINT32 dwRowLen); +/********************************************* +*ܣݵ۷̵ṹ +*˵pDataAddrݵַ pWuRenRtnStr۷̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_NoReturnStruFromChar(UINT8 * pDataAddr,Relay_NoReturnStruct* pWuRenRtnStr); +/********************************************* +*ܣʼż̵ṹ +*˵pDataAddrݵַ pGaragedoorStrż̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_GaragedoorStructFromChar(UINT8 * pDataAddr,Relay_GaragedoorStruct* pGaragedoorStr); + + +/********************************************* +*ܣݵSPKS̵ṹ +*˵pDataAddrݵַ pSpksStr SPKSݽṹָ realRowLenÿһݳ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_SpksDataFromChar(UINT8 * pDataAddr,RelaySpksStruct* pSpksStr,UINT16 realRowLen); + +/********************************************* +*ܣݵŽ̵ṹ +*˵pDataAddrݵַ pMjStr Žݽṹָ realRowLen ÿһݳ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_MJDataFromChar(UINT8* pDataAddr, Relay_MJStruct* pMjStr, UINT16 realRowLen); + +/********************************************* +*ܣݵż̵ṹ +*˵pDataAddrݵַ pFloodGateStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_FloodGateStructFromChar(UINT8 * pDataAddr,Relay_FloodGateStruct* pFloodGateStr); + +/********************************************* +*ܣݵ̵ͬṹ +*˵pDataAddrݵַ pWashMachineStr ϴ̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_DCAgreeStructFromChar(UINT8 * pDataAddr,Relay_DCAgreeStruct * pDCAgreeStr); + +/********************************************* +*ܣʼ̵νṹ +*˵ pDataAddrݵַ pRelayCfgDtStr̵ݽṹָ + pRelayId̵idַ pSecBufidеַ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 RelayCfgFaultLockPhySecFromChar(UINT8 * pDataAddr,RelayConfigDataStruct* pRelayCfgDtStr,UINT16 *pRelayId,UINT16 pSecBuf[][MAX_LOCK_EXCEPT_SECTION_NUM]); + +/********************************************* +*ܣݵ豸̵ṹ +*˵pDataAddrݵַ pReverseCutDtStr 豸̵ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 R_ReverseCutStrFromChar(UINT8 * pDataAddr, Relay_ReverseCutStruct * pReverseCutDtStr); +/********************************************* +*ܣݵOCվָʾƵƼ̵ṹ +*˵pDataAddrݵַ pBjdStr Ƽ̵ݽṹָ +*ֵ0ʧܣ1ɹ +* cgh-ϲCID-3037-3 +*********************************************/ +UINT8 R_OCIndicStruFromChar(UINT8* pDataAddr, OCStationIndicConfigDataStru* pIndicStru); +#endif diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruInit.c b/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruInit.c new file mode 100644 index 0000000..1def5dd --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruInit.c @@ -0,0 +1,1625 @@ +/************************************************************************ +* +* ļ dquCIJDQStruInit.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ̵ݽṹʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "dquCIJDQStruInit.h" + + + +/*********ȫֵļ̵Ϣݱ*******/ +RelayDataStruct_Config RelayData; + RelayDataStruct_ConfigLen RelayDataLen; + +/***************************/ + + +/********************************************* +*ܣźŻ̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_SignalStru(CHAR* CIDataName) +{ + UINT8 funcRtn; + Relay_SignalStruct* pSgnlStr; /*ʱźŻ̵*/ + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + UINT16 j; + UINT8 rtnValue = 0u; + UINT8 localCiPattern; + UINT32 excelId = 0U; + UINT32 sheetId = 0U; + UINT32 rowLen = 0U; + /*Ѿʼˣǵִй*/ + if(NULL != RelayData.pRelaySignalStr) + { + rtnValue = 1u; + return rtnValue; + } + else + { + rtnValue = 1u; + localCiPattern = GetLocalCiPattern(); + if (CI_PATTERN_TRADITIONAL == localCiPattern) + { + excelId = CI_DATA_TYPE; + sheetId = RELAY_SIGNAL; + rowLen = LEN_RELAY_SIGNAL; + } + else + { + excelId = OC_DATA_TYPE; + sheetId = OC_SIGNAL_RELAY_ID; + rowLen = LEN_OC_SIGNAL_RELAY; + } + } + /*ȡ Ĭг */ + funcRtn = dquGetConfigData(CIDataName, excelId, sheetId,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + /*ʧ*/ + rtnValue = 0u; + return rtnValue; + } + else + { + } + /*ø*/ + if(0u != DataSize%LEN_OC_SIGNAL_RELAY) + { + rtnValue = 0u; + debug_infor_printf((const)"\nCI_RELAY_DATA,SIGNAL_RELAY,len %d not equal to fs",LEN_RELAY_SIGNAL); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_DATA_TYPE<<8u)+RELAY_SIGNAL,PRINT_ONCE); + return rtnValue; + } + + RelayDataLen.RelaySignalStrLen = (UINT16)(DataSize/ LEN_OC_SIGNAL_RELAY); + + if(LEN_OC_SIGNAL_RELAY > DataSize) + { + RelayData.pRelaySignalStr = (Relay_SignalStruct *) MyNew ((UINT32)sizeof(Relay_SignalStruct) ); + rtnValue = 1u; + return rtnValue; + } + else + { + /*ִ*/ + } + + + /*̬ռ*/ + RelayData.pRelaySignalStr = (Relay_SignalStruct *) MyNew ((UINT32)(sizeof(Relay_SignalStruct) * RelayDataLen.RelaySignalStrLen)); + /*̬ռʧ*/ + if(NULL == RelayData.pRelaySignalStr) + { + RelayDataLen.RelaySignalStrLen = 0u; + rtnValue = 0u; + return rtnValue; + } + else + { + /*ڴΪЧ*/ + (void)memset(RelayData.pRelaySignalStr, 0x00,sizeof(Relay_SignalStruct) * RelayDataLen.RelaySignalStrLen); + } + + /*ݵ Ĭг ṹ */ + for(j=0u;jDataSize ) + {/*һ*/ + RelayData.pRelayDCAgreeStr = (Relay_DCAgreeStruct *) MyNew ((UINT32)sizeof(Relay_DCAgreeStruct) ); + rtnValue = 1u; + } + else + { + + /*̬ռ*/ + RelayData.pRelayDCAgreeStr = (Relay_DCAgreeStruct *) MyNew ((UINT32)(sizeof(Relay_DCAgreeStruct) * RelayDataLen.RelayDCAgreeStrLen)); + + if(NULL == RelayData.pRelayDCAgreeStr) + {/*̬ռʧ*/ + RelayDataLen.RelayDCAgreeStrLen = 0u; + rtnValue = 0u; + } + else + { + /*ڴΪЧ*/ + (void)memset(RelayData.pRelayDCAgreeStr, 0x00,sizeof(Relay_DCAgreeStruct) * RelayDataLen.RelayDCAgreeStrLen); + /*ݵ Ĭг ṹ */ + rtnValue = 1u; + for(j = 0u;j < RelayDataLen.RelayDCAgreeStrLen;j++) + { + pDCAgreeStr = RelayData.pRelayDCAgreeStr + j; + + /*ݽṹ*/ + rtnValue &= R_DCAgreeStructFromChar(pDataAddr,pDCAgreeStr); + pDataAddr += LEN_RELAY_DCAGREE_ID; + + } + } + } + } + } + } + return rtnValue; + +} + +/********************************************* +*ܣ䵹豸̵ṹ---ڲ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_ReverseCutStru(CHAR* CIDataName) +{ + UINT8 funcRtn = 0u; + Relay_ReverseCutStruct* pReverseCutStr = NULL; /*豸̵*/ + UINT8* pDataAddr =NULL; /*ݵַ*/ + UINT32 DataSize=0U; /*ݴСֽ*/ + UINT16 j=0U; + UINT8 rtnValue = 0u; + UINT8 localCiPattern = 0U; + localCiPattern = GetLocalCiPattern(); + + /*Ѿʼˣǵִй ȫӲóʼű*/ + if (NULL != RelayData.pRelayReverseCutStr ) + { + rtnValue = 1u; + } + else + { + /*ȡ豸̵ݱ*/ + funcRtn = dquGetConfigData(CIDataName, OC_DATA_TYPE, OC_RELAY_REVERSE_CUT_ID, &pDataAddr, &DataSize); + if (0u == funcRtn) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + + if ((0u != DataSize%OC_LEN_REVERSE_CUT)) + { /*øΪݴ*/ + debug_infor_printf((const)"\nCI_RELAY_DATA,REVERSE_CUT len %d not equal to fs", OC_LEN_REVERSE_CUT); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software, CI_DEVICE_TYPE_FS_TABLE, ((UINT32)OC_DATA_TYPE << 8u) + OC_RELAY_REVERSE_CUT_ID, PRINT_ONCE); + rtnValue = 0u; + } + else + { + RelayDataLen.RelayReverseCutStrLen = (UINT16)(DataSize / OC_LEN_REVERSE_CUT);/*ṹ*/ + + if (OC_LEN_REVERSE_CUT > DataSize) + {/*һ*/ + RelayData.pRelayReverseCutStr = (Relay_ReverseCutStruct *)MyNew((UINT32)sizeof(Relay_ReverseCutStruct)); + rtnValue = 1u; + } + else + { + + /*̬ռ*/ + RelayData.pRelayReverseCutStr = (Relay_ReverseCutStruct *)MyNew((UINT32)(sizeof(Relay_ReverseCutStruct) * RelayDataLen.RelayReverseCutStrLen)); + + if (NULL == RelayData.pRelayReverseCutStr) + {/*̬ռʧ*/ + RelayDataLen.RelayReverseCutStrLen = 0u; + rtnValue = 0u; + } + else + { + /*ڴΪЧ*/ + (void)CommonMemSet(RelayData.pRelayReverseCutStr, (UINT32)(sizeof(Relay_ReverseCutStruct) * RelayDataLen.RelayReverseCutStrLen), + 0x00, (UINT32)(sizeof(Relay_ReverseCutStruct) * RelayDataLen.RelayReverseCutStrLen)); + /*ݵ Ĭг ṹ */ + rtnValue = 1u; + for (j = 0u; j < RelayDataLen.RelayReverseCutStrLen; j++) + { + pReverseCutStr = RelayData.pRelayReverseCutStr + j; + + /*ݽṹ*/ + rtnValue &= R_ReverseCutStrFromChar(pDataAddr, pReverseCutStr); + pDataAddr += OC_LEN_REVERSE_CUT; + + } + } + } + } + } + } + return rtnValue; +} + diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruInit.h b/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruInit.h new file mode 100644 index 0000000..1344741 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIJDQStruInit.h @@ -0,0 +1,177 @@ +/************************************************************************ +* +* ļ dquCIJDQStruInit.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ̵ݽṹʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_CI_JDQ_STRU_INIT +#define DQU_CI_JDQ_STRU_INIT + +#include "CommonTypes.h" +#include "dquCIJDQStruFrmChar.h" + +/*̵ݽṹ*/ +typedef struct SConfig_RelayDataStruct +{ + Relay_EmgcyStpStruct* pRelayEmgcyStpStr; /*ͣť̵ṹ*/ + Relay_ScreenStruct* pRelayScreenStr ; /*ż̵ṹ*/ + Relay_PhysicalSegmentStruct* pRelayPhysicalSgmtStr ;/*μ̵ṹ*/ + Relay_PointStruct* pRelayPointStr ; /*̵ṹ*/ + Relay_SignalStruct* pRelaySignalStr ; /*źŻ̵ṹ*/ + Relay_NoRouteDcStruct* pRelayNoRouteDcStr ;/*ǽ·̵*/ + Relay_ZhaoChaStruct* pRelayZhaoChaStr ; /*ղ̵*/ + Relay_BaoJingDengStruct* pRelayBjdStr ; /*ʾƼ̵ṹ*/ + Relay_NoReturnStruct * pRelayNoRtnStru; /*۷*/ + RelayConfigDataStruct * pRelayCfgDtStr ; + Relay_GaragedoorStruct *pRelayGaragedoorStr; /*ż̵ṹ*/ + RelaySpksStruct *pRelaySpksStr; /* SPKS̵ */ + Relay_MJStruct* pMjStr; /* Ž̵ṹ */ + Relay_FloodGateStruct *pRelayFloodGateStr; /* ż̵ */ + Relay_WashMachineStruct *pRelayWashMachineStr; /*ϴ̵ṹ*/ + Relay_DCAgreeStruct *pRelayDCAgreeStr;/*̵ͬṹ*/ + Relay_ReverseCutStruct *pRelayReverseCutStr;/*豸̵ṹ*/ +} RelayDataStruct_Config; +/*̵鳤Ƚṹ*/ +typedef struct S_RelayDataStructLen +{ + UINT16 RelayEmgcyStpStrLen ; /*ͣť̵ṹ鳤*/ + UINT16 RelayScreenStrLen ; /*ż̵ṹ鳤*/ + UINT16 RelayPhysicalSgmtStrLen ;/*μ̵ṹ鳤*/ + UINT16 RelayPointStrLen ; /*̵ṹ鳤*/ + UINT16 RelaySignalStrLen ; /*źŻ̵ṹ鳤*/ + UINT16 RelayNoRouteDcStrLen; /*ǽ·̵*/ + UINT16 RelayZhaoChaStrLen; /*ղ̵*/ + UINT16 RelayBjdStrLen; /*ʾƼ̵ṹ*/ + UINT16 RelayNoRtnStruLen; /*۷*/ + UINT16 RelayCfgDtStrLen; + UINT16 RelayGaragedoorStrLen; /*ż̵*/ + UINT16 RelaySpksStrLen; /* SPKSռС */ + UINT16 RelayMJStrLen; /* Ž̵ռС */ + UINT16 RelayFloodGateStrLen; /*ż̵*/ + UINT16 RelayWashMachineStrLen; /*ϴ̵ṹ*/ + UINT16 RelayMonoRailPointStrLen ; /*̵ṹ鳤*/ + UINT16 RelayDCAgreeStrLen;/*̵ͬṹ*/ + UINT16 RelayReverseCutStrLen;/*豸̵ṹ*/ +} RelayDataStruct_ConfigLen; + +/*********ȫֵļ̵Ϣݱ*******/ +extern RelayDataStruct_Config RelayData; +extern RelayDataStruct_ConfigLen RelayDataLen; + +/***************************/ + +/********************************************* +*ܣźŻ̵ṹ---ڲ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_SignalStru(CHAR* CIDataName); + +/********************************************* +*ܣϴ̵ṹ---ڲ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_WashMachineStru(CHAR* CIDataName); +/********************************************* +*ܣ̵ṹ---ڲ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_PointStru(CHAR* CIDataName); +/********************************************* +*ܣμ̵ṹ---ڲ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_PhysicalSgmtStru(CHAR* CIDataName); +/********************************************* +*ܣǽ·̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_NoRouteDcStru(CHAR* CIDataName); +/********************************************* +*ܣղ̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_ZhaoChaStru(CHAR* CIDataName); + +/********************************************* +*ܣ䱨ƽṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_BaoJingDengStru(CHAR* CIDataName); +/********************************************* +*ܣż̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_ScreenStru(CHAR* CIDataName); +/********************************************* +*ܣͣť̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_EmgcyStpStru(CHAR* CIDataName); +/********************************************* +*ܣ۷ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_NoReturnStru(CHAR* CIDataName); + +/********************************************* +*ܣ䳵ż̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_GaragedoorStru(CHAR* CIDataName); + + +/********************************************* +*ܣʼSPKS̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelaySpksStru(CHAR* CIDataName); + +/********************************************* +*ܣʼŽ̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_MJStru(CHAR* CIDataName); + +/********************************************* +*ܣŰť̵ṹ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_FloodGateStru(CHAR* CIDataName); +/* zt ɾش 2022-02-15 */ + +/********************************************* +*ܣ̵ͬṹ---ڲ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_DCAgreeStru(CHAR* CIDataName); + +/********************************************* +*ܣ䵹豸̵ṹ---ڲ +*˵CIDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitRelay_ReverseCutStru(CHAR* CIDataName); + + +#endif diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCILSStru.h b/TSCP/src/APP/ciapp/QueryFiles/dquCILSStru.h new file mode 100644 index 0000000..b81d3e7 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCILSStru.h @@ -0,0 +1,415 @@ +/************************************************************************ +* +* ļ dquCILSStru.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ·ṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_DI_LS_STRU +#define DQU_DI_LS_STRU + +#include "CommonTypes.h" +#include "CiConfigData.h" + + +#define LS_DATA_TYPE ((UINT32)0X70) /*CI-*/ + +#define LS_DATA_DUAL_BYTE_ELEM_LEN ((UINT8)2) + +#define MULTISWITCH_DATA_ID ((UINT8)17) +#define MULTISWITCH_DATA_LEN ((UINT8)42) + +#define LONG_ROUTE_DATA_ID ((UINT8)8) /*CI -- ·*/ +#define LONG_ROUTE_DATA_LEN ((UINT8)18) + +#define AUTO_ROUTE_DATA_ID ((UINT8)10) /*CI -- Զͨ·*/ +#define AUTO_ROUTE_DATA_LEN ((UINT8)62) + +#define NO_ROUTE_DATA_ID ((UINT8)9) /*CI -- ǽ·*/ +#define NO_ROUTE_DATA_LEN ((UINT8)64) + +#define AUTO_RTN_ROUTE_DATA_ID ((UINT8)11) /*CI -- Զ۷·*/ +#define AUTO_RTN_ROUTE_DATA_LEN ((UINT8)38) + +#define REVERSE_ROUTE_DATA_ID ((UINT8)14) /*CI -- ·*/ +#define REVERSE_ROUTE_DATA_LEN ((UINT8)22) + +#define ALLAUTO_RTN_ROUTE_DATA_ID ((UINT8)13) /*ȫԶ۷ID*/ +#define ALLAUTO_RTN_ROUTE_DATA_LEN ((UINT8)30) + +#define PHY_SGMT_CHECK_STATE_DATA_ID ((UINT8)2) /*CI -- ·μԱ*/ +#define PHY_SGMT_CHECK_STATE_DATA_LEN ((UINT8)50) + +#define FHDC_POINT_DATA_ID ((UINT8)3) /*CI -- */ +#define FHDC_POINT_DATA_LEN ((UINT8)34) + +#define DRV_SWI_GRP_POINT_DATA_ID ((UINT8)15) /*CI -- */ +#define DRV_SWI_GRP_POINT_DATA_LEN ((UINT8)34) + +#define DDXH_DATA_ID ((UINT8)4) /*CI -- жźż*/ +#define DDXH_DATA_LEN ((UINT8)68) + +#define DDXHZ_DATA_ID ((UINT8)12) /*CI -- жźż*/ +#define DDXHZ_DATA_LEN ((UINT8)98) + +#define SIGNAL_DATA_ID ((UINT8)5) /*CI -- źŻ*/ +#define SIGNAL_DATA_LEN ((UINT8)32) + +#define INTRU_PHYSEC_DATA_ID ((UINT8)6) /*CI -- μ*/ +#define INTRU_PHYSEC_LEN ((UINT8)37) + +#define OTHER_CI_DATA_ID ((UINT8)7) /*CI -- */ +#define OTHER_CI_DATA_LEN ((UINT8)42) + +#define ROUTE_DATA_ID ((UINT32)1) /*CI -- ·*/ +#define ROUTE_DATA_LEN ((UINT32)53) /*51:ӲΪӽʱǷʱ +2 CBTC迪*/ + +#define OVERLAP_LOCK_COND_DATA_ID ((UINT8)16) /*CI -- */ +#define OVERLAP_LOCK_COND_DATA_LEN ((UINT8)44)/*һУIDUDE2*/ +/*Ծμ*/ +#define PHYSICAL_INTRU_DATA_ID ((UINT8)18) /*CI -- Ծ*/ +#define PHYSICAL_INTRU_DATA_LEN ((UINT8)10)/*εμг*/ + +/*ʹ*/ +#define FLOOD_GATE_DATA_ID ((UINT8)19) /*CI -- ű*/ +#define FLOOD_GATE_DATA_LEN ((UINT8)22) + +#define PROSWITCH_HOSTSWITCH_MAP_ID ((UINT8)20) /*CI - ӦϵID*/ +#define PROSWITCH_HOSTSWITCH_MAP_LEN ((UINT8)36) /*18У18*2 = 36*/ + +#define GROUP_AUTO_ROUTE_DATA_ID ((UINT8)21) /*CI -- Զͨ·*/ + +#define LOGIC_SEC_INTRU_DATA_ID ((UINT8)22) /*CI -- ߼α*/ + +#define LOGIC_SEC_LTRL_DFNC_ID ((UINT8)23) /*CI -- ߼β(Lateral Denfence)*/ + +#define SGBJ_CI_DATA_ID ((UINT8)24U) /*CI -- ⱨ*/ + +#define CONTACT_CONFIG_CI_DATA_ID ((UINT8)25U) /*CI-߼ι豸*/ + +#define LOGIC_SEC_EACHINTRU_DATA_ID ((UINT8)26) /*CI -- ߼λα*/ + +#define TRANSROUTE_ZHEFANSIG_ID ((UINT8)27) /*CI -- ת·۷źŻid*/ + +#define CONTACT_DATA_LEN ((UINT8)12U) + +/*ʹ*/ +/* zt ɾش 2022-02-15 */ + +#define LR_MAX_INCLUDE_ROUTE_NUM ((UINT8)8) +#define NR_MAX_INCLUDE_POINT_NUM ((UINT8)8) +#define NR_MAX_INCLUDE_DDXH_NUM ((UINT8)8) +#define AR_MAX_INCLUDE_ROUTE_NUM ((UINT8)20) +#define ARR_MAX_INCLUDE_ROUTE_NUM ((UINT8)8) +#define RR_MAX_INCLUDE_ROUTE_NUM ((UINT8)10) +#define AARR_MAX_INCLUDE_ROUTE_NUM ((UINT8)4) /*ȫԶ۷Ľ·Ŀ*/ + +#define OVLP_LOCK_COND_MAX_INCL_RET_ROUTE_N_PHY_SEC_NUM ((UINT8)5) /*۷·۷Ŀ*/ +#define OVLP_LOCK_COND_MAX_INCL_INV_SEC_N_CON_SWI_NUM ((UINT8)4) /*μĿ*/ +#define OVLP_LOCK_COND_MAX_INCL_INV_OPP_OVLP_NUM ((UINT8)4) /*޵жԱĿ*/ + +#define MAX_INCLUDE_PHYSC_SGMT_NUM ((UINT8)16) + +#define FHDC_MAX_INCLUDE_POINT_NUM ((UINT8)8) +#define DRV_SWI_GRP_MAX_INCLUDE_POINT_NUM ((UINT8)8) +#define DDXH_MAX_INCLUDE_POINT_NUM ((UINT8)16) +#define DDXHZ_MAX_DDXH_NUM ((UINT8)48) +#define MAX_INCLUDE_SIGNAL_NUM ((UINT8)15) +#define QXQD_MAX_INCLUDE_POINT_NUM ((UINT8)8) /*ñ*/ +#define OTHER_MAX_PSD_NUM ((UINT8)4) +#define OTHER_MAX_EMERG_CLSBTN_NUM ((UINT8)4) +#define OTHER_CI_MAX_DEV_NUM ((UINT8)10) + +#define LOG_CONTACT_CONFIG_MAX_NUM ((UINT8)2) /*߼ι豸*/ + +#define ROUTE_MAX_QXQD_NUM ((UINT8)4) + +#define ROUTE_MAX_FLOOD_GATE_NUM ((UINT8)2) /* */ + + +#define ROUTE_MAX_MONO_RAIL_SWITCH_NUM ((UINT8)10) /*·ڵĿ*/ + +#define PHYSICAL_INCL_INV_SWICH_NUM ((UINT8)4) /*μĿ*/ + +#define LOGIC_INCL_INV_SWICH_NUM ((UINT8)4) /*߼μĿ*/ + +#define LOGIC_LTARL_DFNC_SWITCH_NUM ((UINT8)8) /*߼εIJĿ*/ + +#define SGBJ_RELATED_PHYSEC_SUM_MAX ((UINT16)6) /*ⱨֵ*/ + +/*·ݽṹ*/ +typedef struct S_LongRouteStruct +{ + UINT16 wId; /*ID */ + UINT16 szIncludeRouteId[LR_MAX_INCLUDE_ROUTE_NUM]; /*·ID*/ +} LS_LongRouteStru; + +/*ǽ·ݽṹ*/ +typedef struct S_NoRouteDcStruct +{ + UINT16 wId; /*ID */ + UINT16 wIncludeSignal; /*ǽ·źŻID*/ + UINT16 wWuliJianchaType; /*κͼID*/ + UINT16 wIncludePoint[NR_MAX_INCLUDE_POINT_NUM]; /**/ + UINT16 wIncludePointSta[NR_MAX_INCLUDE_POINT_NUM]; /*״̬*/ + UINT16 wFHPointId; /*Id*/ + UINT16 wDiDuiXinhao[NR_MAX_INCLUDE_DDXH_NUM]; /*ǽ·жźŽṹ*/ + UINT16 wIntrudePhySecId[ROUTE_MAX_QXQD_NUM]; /*ID,add in 2013.12.26*/ +} LS_NoRouteDcStru; + +/*Զ·ݽṹ*/ +typedef struct S_AutoRouteStruct +{ + UINT16 wId; /*ID */ + UINT16 szIncludeRouteId[AR_MAX_INCLUDE_ROUTE_NUM]; /*·ID*/ +} LS_AutoRouteStru; + +/*Զ·ݽṹ*/ +typedef struct S_GroupAutoRouteStruct +{ + UINT16 wId; /*ID */ + UINT16 szIncludeAutoRouteId[AR_MAX_INCLUDE_ROUTE_NUM]; /*Զ·ID*/ +} LS_GroupAutoRouteStru; + +/*Զ۷·ݽṹ*/ +typedef struct S_AutoRtnRouteStruct +{ + UINT16 wId; /*ID */ + UINT16 szIncludeRouteId[ARR_MAX_INCLUDE_ROUTE_NUM]; /*·ID*/ +} LS_AutoRtnRouteStru; + +/*·ݽṹ*/ +typedef struct S_ReverseRouteStruct +{ + UINT16 wId; /*ID */ + UINT16 szIncludeRouteId[RR_MAX_INCLUDE_ROUTE_NUM]; /*·ID*/ +} LS_ReverseRouteStru; + +/*·μԱݽṹ*/ +typedef struct S_RoutePhyAndCheckStateStruct +{ + UINT16 wId; /*ID */ + UINT16 wPhysicalSgmtId[MAX_INCLUDE_PHYSC_SGMT_NUM]; /*ID*/ + UINT16 wCheckState[MAX_INCLUDE_PHYSC_SGMT_NUM]; /*·ID*/ +} LS_RoutePhyAndCheckStateStruct; + + +/*ݽṹ*/ +typedef struct S_RouteFHDaoChaStruct +{ + UINT16 wId; /*ID */ + UINT16 wPointId[FHDC_MAX_INCLUDE_POINT_NUM]; /*ID*/ + UINT16 wPointSta[FHDC_MAX_INCLUDE_POINT_NUM]; /*״̬*/ +} LS_FHDaoChaStruct; + + +/*ݽṹ*/ +typedef struct S_RouteDrivedSwitchGroupStruct +{ + UINT16 wId; /*ID */ + UINT16 wPointId[DRV_SWI_GRP_MAX_INCLUDE_POINT_NUM]; /*ID*/ + UINT16 wPointSta[DRV_SWI_GRP_MAX_INCLUDE_POINT_NUM]; /*״̬*/ +} LS_RouteDrivedSwitchGroupStruct; + +/*жźṹ*/ +typedef struct S_DiDuiXinHaoZuStruct +{ + UINT16 wId; /*ID */ + UINT16 wDiDuiXinHaoId[DDXHZ_MAX_DDXH_NUM]; /*жźID*/ +} LS_DDXHZStruct; + +/*жźűݽṹ*/ +typedef struct S_DiDuiXinHaoStruct +{ + UINT16 wId; /*ID */ + UINT16 wDiDuiXinHaoId; /*жźID*/ + UINT16 wPointId[DDXH_MAX_INCLUDE_POINT_NUM]; /*ID*/ + UINT16 wPointSta[DDXH_MAX_INCLUDE_POINT_NUM]; /*״̬*/ +} LS_DDXHStruct; + +/*źŻݽṹ*/ +typedef struct S_SignalStruct +{ + UINT16 wId; /*ID */ + UINT16 wSignalId[MAX_INCLUDE_SIGNAL_NUM]; /*źŻID*/ +} LS_SignalStruct; + +/*μݽṹ*/ +typedef struct S_IntrudePhySectionStruct +{ + UINT16 wId; /*ID */ + UINT16 wIntrudePhySecId; /*ID*/ + UINT16 wPointId[QINXIAN_SWITCH_MAX_NUM]; /*ID*/ + UINT16 wPointSta[QINXIAN_SWITCH_MAX_NUM]; /*״̬*/ + UINT8 wCondSwitLockDir; /**/ + UINT16 belongLogSecId; /*߼IDޱʹ*/ + UINT16 belongPhySecId; /*IDޱʹ*/ +} LS_IntrudePhySectionStruct; + +/*߼ι豸ṹ*/ +typedef struct S_ContactLineStruct +{ + UINT16 wId; /*߼ID */ + UINT16 wPointId[LOG_CONTACT_CONFIG_MAX_NUM]; /*߼ιߵID*/ + UINT8 wPointSta[LOG_CONTACT_CONFIG_MAX_NUM]; /*߼ιߵ״̬*/ + UINT16 wAxisSecId[LOG_CONTACT_CONFIG_MAX_NUM]; /*߼ιߵڼID*/ +} LS_ContactLineStruct; + +/*ݽṹ*/ +#if 0 +typedef struct S_OtherCIStruct +{ + UINT16 wId; /*ID */ + UINT16 wPsdId[OTHER_MAX_PSD_NUM]; /*ID*/ + UINT16 wEmgClsBtn[OTHER_MAX_EMERG_CLSBTN_NUM]; /*رհť*/ +} LS_OtherCIStruct; +#else +typedef struct S_OtherCiDevInfoStruct +{ + UINT16 wId; /* 豸ID */ + UINT16 wDevType; /* 豸 */ + UINT8 wDevStatus; /* 豸״̬ */ +} LS_OtherCiDevInfoStruct; +typedef struct S_OtherCIStruct +{ + UINT16 wId; /*ID */ + LS_OtherCiDevInfoStruct otherCiDevInfoBuf[OTHER_CI_MAX_DEV_NUM]; /*رհť*/ +} LS_OtherCIStruct; +#endif + + +/*-·ݽṹ*/ +typedef struct S_RouteStruct +{ + UINT16 wRouteId; /*·ID */ + UINT8 wDir; /*· */ + UINT16 wType; /*·*/ + UINT8 wYinDao; /**/ + UINT16 wStarBtnSignal; /*ʼ˰ťӦźŻID*/ + UINT16 wFlexibleSignal; /*ͨťӦźŻID*/ + UINT16 wEndBtnSignal; /*ն˰ťӦźŻID*/ + UINT16 wStarSignalClr; /*ʼźŻʾɫ*/ + UINT16 wStarSigYinDaoClr; /*ʼźŻɫ*/ + UINT16 wPhySecCheckStaId; /*μID*/ + UINT16 wFHDCId; /*·ID*/ + UINT16 wDDXHId; /*жźżID*/ + UINT16 wIntrudePhySecId[ROUTE_MAX_QXQD_NUM]; /*ID*/ + UINT16 wReturnSignalId; /*·۷źŻID*/ + UINT16 wFHQD_TW_WLQDId; /*νӦͣID*/ + UINT16 wFS_SignalId; /*·ؿɷźŻID*/ + UINT16 wSignalClsId; /*·رźŻID*/ + UINT16 wSignalOpenId; /*·迪źŻID*/ + UINT16 wCBTCSignalOpenId; /*·迪źŻID*/ + UINT16 wBlocSignalOpenId; /*󱸽·迪źŻID*/ + UINT16 wBTSOpenId; /*ͬʱźŻ*/ + UINT16 wDrvSwiGrpId; /*ID*/ + UINT16 wCBTCOtherCIID; /*CBTCID*/ + UINT16 wBLCKOtherCIID; /*ʽID*/ + UINT16 wFloodGateIdBuf[ROUTE_MAX_FLOOD_GATE_NUM]; /**/ + UINT8 wNeedDelayUnlock; /*·˽⡢ȡҪʱ*/ +} LS_RouteStruct; +/*ȫԶ۷·ݽṹ*/ +typedef struct S_AllAutoRtnRouteStruct +{ + UINT16 wId; /*ID */ + UINT16 szIncludeRouteId[AARR_MAX_INCLUDE_ROUTE_NUM]; /*·ID*/ +} LS_AllAutoRtnRouteStru; + + +/*ݽṹ*/ +typedef struct S_OverlapLockCondStruct +{ + UINT16 wOverlapId; /*ID */ + UINT16 szIncludeReturnRouteId[OVLP_LOCK_COND_MAX_INCL_RET_ROUTE_N_PHY_SEC_NUM]; /*۷·ID*/ + UINT16 szIncludeRetTrkPhySecId[OVLP_LOCK_COND_MAX_INCL_RET_ROUTE_N_PHY_SEC_NUM]; /*۷ID*/ + UINT16 szIncludeInvSecAndConSwiId[OVLP_LOCK_COND_MAX_INCL_INV_SEC_N_CON_SWI_NUM]; /*μ*/ + UINT16 szIncludeInvOppOverlapId[OVLP_LOCK_COND_MAX_INCL_INV_OPP_OVLP_NUM]; /*޵жԱ*/ + UINT16 overlapLocProSwitchGroupID; /*շID*/ + UINT16 szIncludeFloodGateId[ROUTE_MAX_FLOOD_GATE_NUM]; /*ID*/ +} LS_OveralpLockCondStru; + +/*·ڶ࿪ݽṹ*/ +typedef struct S_RouteMonoRailSwitchStruct +{ + UINT16 routeId; /*ID */ + UINT16 monoRailSwitNum; + UINT16 monoRailSwitIdt[ROUTE_MAX_MONO_RAIL_SWITCH_NUM]; /**/ + UINT16 monoRailSwitSta[ROUTE_MAX_MONO_RAIL_SWITCH_NUM]; /**/ +} LS_RouteMonoRailSwitStru; + +/*μݽṹ*/ +typedef struct S_PhySectionIntrudeStruct +{ + UINT16 physicalId; /*ID */ + UINT16 phyInvSecAndConSwiId[SEC_INVASECT_N_CONDSWIT_SUM_MAX]; /*μID*/ +} LS_PhySectionIntrudeStruct; + +/*߼μݽṹ*/ +typedef struct S_LogSectionIntrudeStruct +{ + UINT16 wLogSecId; /*߼ID */ + UINT16 wszLogicInvSecAndConSwiId[LOGSEC_INV_N_CONDSWIT_SUM_MAX]; /*μID*/ +} LS_LgcSectionIntrudeStruct; +/*Źݽṹ*/ +typedef struct S_FloodGatePhySecStruct +{ + UINT16 wPhysecId; /*ID */ + UINT16 wPhysecType; /*,0x55:Σ 0xaa:ӽ*/ +} LS_FloodGatePhySecStruct; + + + +/*Ӧϵ*/ +typedef struct S_ProSwitchHostSwitchMapStruct +{ + UINT16 wProSwitchID;/*ID*/ + UINT16 wHostSwitchIDBuf[SWITCH_HOST_SWITCH_MAX_NUM];/*ID*/ +}LS_ProSwitchHostSwitchMapStruct; + +/*ṹ*/ +typedef struct S_LgcLrtlDfncSwitchStruct +{ + UINT16 wPointId; /*ID */ + UINT16 wPointSta; /*״̬*/ +} LS_LgcLrtlDfncSwitchStruct; + +/*߼βṹ*/ +typedef struct S_LogSecLrtlDfncStruct +{ + UINT16 wLogSecId; /*߼ID */ + LS_LgcLrtlDfncSwitchStruct stLrtlDfncSwitch[LOGIC_LTARL_DFNC_SWITCH_NUM]; /*߼βID*/ + UINT8 szProtectLockDir[LOGIC_LTARL_DFNC_SWITCH_NUM]; /*UTռѹʱշ*/ +} LS_LgcSecLrtlDfncStruct; + +/*ⱨݽṹ*/ +typedef struct S_SGBJStruct +{ + UINT16 wSGBJId; /*ⱨID */ + UINT16 wSGBJRelayId; /*ⱨ̵ID1*/ + UINT16 wSGBJRelayId_2; /*ⱨ̵ID2*/ + UINT16 wSGBJRelPhySecNum; /*ⱨ*/ + UINT16 szSGBJRelPhySecId[SGBJ_RELATED_PHYSEC_SUM_MAX]; /*ⱨID*/ +} LS_SGBJStruct; + +/*߼λޱ*/ +typedef struct S_EachLgcIntrudeStruct +{ + UINT16 wLogSecId1; /*߼1ID */ + UINT16 wLogSecId2; /*߼2ID */ + UINT8 wLogSec1_CheckDir; /*߼1߼2Ľӽ*/ + UINT8 wLogSec2_CheckDir; /*߼2߼1Ľӽ*/ +} LS_EachLgcIntrudeStruct; + +typedef struct S_TransRouteZFSigStruct +{ + UINT16 wRouteId; /*ת·ID */ + UINT16 wTransRouteZFSigId; /*ת۷źŻID*/ +} LS_TransRouteZFSigStruct; + +#endif + diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruFrmChar.c b/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruFrmChar.c new file mode 100644 index 0000000..beab3d9 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruFrmChar.c @@ -0,0 +1,1060 @@ +/************************************************************************ +* +* ļ dquCILSStruFrmChar.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ݵ·ת +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "dquCILSStruFrmChar.h" +#include "dquCIReadCommonChar.h" +/********************************************* +*ܣݵ·ת +*˵pDataAddrݵַ pLongRouteStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_LongRouteStruFromChar(UINT8 * pDataAddr,LS_LongRouteStru* pLongRouteStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pLongRouteStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pLongRouteStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iszIncludeRouteId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + rtnvalue = 1u; + return rtnvalue; +} +/********************************************* +*ܣݵǽ·ݽṹת +*˵pDataAddrݵַ pNoRouteDcStrǽ·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_NoRouteDcStruFromChar(UINT8 * pDataAddr,LS_NoRouteDcStru* pNoRouteDcStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pNoRouteDcStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + /*ID*/ + pNoRouteDcStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + /*ǽ·źŻID*/ + pNoRouteDcStr->wIncludeSignal = dquCiShortFromChar(pData); + pData+=2u; + + /*κͼID*/ + pNoRouteDcStr->wWuliJianchaType = dquCiShortFromChar(pData); + pData+=2u; + + /**/ + for(i=0u;iwIncludePoint[i] = dquCiShortFromChar(pData); + pData+=2u; + pNoRouteDcStr->wIncludePointSta[i] = dquCiShortFromChar(pData); + pData+=2u; + } + /*Id*/ + pNoRouteDcStr->wFHPointId = dquCiShortFromChar(pData); + pData+=2u; + + /*ǽ·жźŽṹ*/ + for(i=0u;iwDiDuiXinhao[i] = dquCiShortFromChar(pData); + pData+=2u; + + } + + /*ID*/ + for(i=0u; iwIntrudePhySecId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + rtnvalue = 1u; + return rtnvalue; +} + + +/********************************************* +*ܣݵԶ·ת +*˵pDataAddrݵַ pAutoRouteStrԶ·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_AutoRouteStruFromChar(UINT8 * pDataAddr,LS_AutoRouteStru* pAutoRouteStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pAutoRouteStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pAutoRouteStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iszIncludeRouteId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + pData+=20u; + rtnvalue = 1u; + return rtnvalue; +} + +/********************************************* +*ܣݵԶ۷·ת +*˵pDataAddrݵַ pAutoRtnRouteStrԶ۷·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_AutoRtnRouteStruFromChar(UINT8 * pDataAddr,LS_AutoRtnRouteStru* pAutoRtnRouteStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pAutoRtnRouteStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pAutoRtnRouteStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iszIncludeRouteId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + pData+=20u; + rtnvalue = 1u; + return rtnvalue; +} + +/********************************************* +*ܣݵ·ת +*˵pDataAddrݵַ pReverseRouteStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_ReverseRouteStruFromChar(UINT8 * pDataAddr,LS_ReverseRouteStru* pReverseRouteStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pReverseRouteStr)) + { + rtnvalue = 0u; + } + else + { + pReverseRouteStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iszIncludeRouteId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + rtnvalue = 1u; + } + return rtnvalue; +} + +/********************************************* +*ܣݵԶ·μת +*˵pDataAddrݵַ pRoutePhyAndCheckStateStr Զ·μݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_RoutePhyCheckStaStruFromChar(UINT8 * pDataAddr,LS_RoutePhyAndCheckStateStruct* pRoutePhyAndCheckStateStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pRoutePhyAndCheckStateStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pRoutePhyAndCheckStateStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iwPhysicalSgmtId[i] = dquCiShortFromChar(pData); + pData+=2u; + pRoutePhyAndCheckStateStr->wCheckState[i] = *pData; + pData++; + } + rtnvalue = 1u; + return rtnvalue; +} + +/********************************************* +*ܣݵת +*˵pDataAddrݵַ pFHDaoChaStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_FHDaoChaStruFromChar(UINT8 * pDataAddr,LS_FHDaoChaStruct* pFHDaoChaStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pFHDaoChaStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pFHDaoChaStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iwPointId[i] = dquCiShortFromChar(pData); + pData+=2u; + pFHDaoChaStr->wPointSta[i] = dquCiShortFromChar(pData); + pData+=2u; + } + rtnvalue = 1u; + return rtnvalue; +} + +/********************************************* +*ܣݵת +*˵pDataAddrݵַ pDrivedSwitchGroupStruݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_DrvSwiGrpStruFromChar(UINT8 * pDataAddr, LS_RouteDrivedSwitchGroupStruct * pDrivedSwitchGroupStru) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pDrivedSwitchGroupStru)) + { + rtnvalue = 0u; + } + else + { + pDrivedSwitchGroupStru->wId = dquCiShortFromChar(pData); + + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + + for(i = 0u; i < DRV_SWI_GRP_MAX_INCLUDE_POINT_NUM; i++) + { + pDrivedSwitchGroupStru->wPointId[i] = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + + pDrivedSwitchGroupStru->wPointSta[i] = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + } + + rtnvalue = 1u; + } + + return rtnvalue; +} + + +/********************************************* +*ܣݵжźת +*˵pDataAddrݵַ pDDXHStr жźݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_DDXHStruFromChar(UINT8 * pDataAddr,LS_DDXHStruct* pDDXHStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pDDXHStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pDDXHStr->wId = dquCiShortFromChar(pData); + pData+=2u; + pDDXHStr->wDiDuiXinHaoId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iwPointId[i] = dquCiShortFromChar(pData); + pData+=2u; + pDDXHStr->wPointSta[i] = dquCiShortFromChar(pData); + pData+=2u; + } + rtnvalue = 1u; + return rtnvalue; +} +/********************************************* +*ܣݵжźת +*˵pDataAddrݵַ pDDXHZStrжźݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_DDXHZStruFromChar(UINT8 * pDataAddr,LS_DDXHZStruct* pDDXHZStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pDDXHZStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pDDXHZStr->wId = dquCiShortFromChar(pData); + pData+=2u; + for(i=0u;iwDiDuiXinHaoId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + rtnvalue = 1u; + return rtnvalue; +} +/********************************************* +*ܣݵźŻת +*˵pDataAddrݵַ pSignalStr źŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_SignalStruFromChar(UINT8 * pDataAddr,LS_SignalStruct* pSignalStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pSignalStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pSignalStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + + for(i=0u;iwSignalId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + rtnvalue = 1u; + return rtnvalue; +} +/********************************************* +*ܣݵμݽṹת +*˵pDataAddrݵַ pIntruPhySecStrμݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_IntrudePhySecStruFromChar(UINT8 * pDataAddr,LS_IntrudePhySectionStruct* pIntruPhySecStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pIntruPhySecStr)) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + pIntruPhySecStr->wId = dquCiShortFromChar(pData); + pData += 2u; + + if (PHYSICAL_SECTION_SUM_MAX < dquCiShortFromChar(pData)) + { + rtnvalue = 0u; + } + else + { + pIntruPhySecStr->wIntrudePhySecId = dquCiShortFromChar(pData); + pData += 2u; + for (i = 0u; i < QXQD_MAX_INCLUDE_POINT_NUM; i++) + { + if (SWITCH_SUM_MAX < dquCiShortFromChar(pData)) + { + rtnvalue = 0u; + break; + } + else + { + pIntruPhySecStr->wPointId[i] = dquCiShortFromChar(pData); + pData += 2u; + pIntruPhySecStr->wPointSta[i] = dquCiShortFromChar(pData); + pData += 2u; + } + } + if (1U == rtnvalue) + { + pIntruPhySecStr->wCondSwitLockDir = *(pData); + pData += 1u; + } + } + } + return rtnvalue; +} + + +/********************************************* +*ܣݵݽṹת +*˵pDataAddrݵַ pOtherCIStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_OtherCIStruFromChar(UINT8 * pDataAddr,LS_OtherCIStruct* pOtherCIStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pOtherCIStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pOtherCIStr->wId = dquCiShortFromChar(pData); + pData+=2u; + +#if 0 + for(i=0;iwPsdId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + for(i=0;iwEmgClsBtn[i] = dquCiShortFromChar(pData); + pData+=2u; + } +#else + /* һ֧ܹ10豸Ϣ */ + for(i=0u;iotherCiDevInfoBuf[i].wDevType = *(pData); + pData+=1u; + pOtherCIStr->otherCiDevInfoBuf[i].wId = dquCiShortFromChar(pData); + pData+=2u; + pOtherCIStr->otherCiDevInfoBuf[i].wDevStatus = *(pData); + pData+=1u; + } +#endif + rtnvalue = 1u; + return rtnvalue; +} + +/********************************************* +*ܣݵ-ݽṹת +*˵pDataAddrݵַpFloodGateStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_ProSwitchHostSwStruFromChar(UINT8 * pDataAddr,LS_ProSwitchHostSwitchMapStruct* pProHostSwitchMapStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtVal = 0u; + UINT16 index = 0u; + if ((NULL == pDataAddr) || (NULL == pProHostSwitchMapStr)) + { + rtVal = 0u; + } + else + { + rtVal = 1u; + } + if (1u == rtVal) + { + /*ID */ + pProHostSwitchMapStr->wProSwitchID = dquCiShortFromChar(pData); + index +=2u; + + /*ID*/ + for (i=0u;iwHostSwitchIDBuf[i] = dquCiShortFromChar((UINT8*)(&pData[index])); + index +=2u; + + } + } + + return rtVal; +} +/********************************************* +*ܣݵ·ݽṹת +*˵pDataAddrݵַpRouteStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_RouteStruFromChar(UINT8 * pDataAddr,LS_RouteStruct* pRouteStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pRouteStr)) + { + rtnvalue = 0u; + return rtnvalue; + } + + /*·ID */ + pRouteStr->wRouteId = dquCiShortFromChar(pData); + pData+=2u; + + /*· */ + pRouteStr->wDir = *pData; + pData++; + + + + /**/ + pRouteStr->wYinDao = *pData; + pData++; + + /*ʼ˰ťӦźŻID*/ + pRouteStr->wStarBtnSignal = dquCiShortFromChar(pData); + pData+=2u; + + /*ͨťӦźŻID*/ + pRouteStr->wFlexibleSignal = dquCiShortFromChar(pData); + pData+=2u; + + /*ն˰ťӦźŻID*/ + pRouteStr->wEndBtnSignal = dquCiShortFromChar(pData); + pData+=2u; + + /*ʼźŻʾɫ*/ + pRouteStr->wStarSignalClr = dquCiShortFromChar(pData); + pData+=2u; + + /*ʼźŻɫ*/ + pRouteStr->wStarSigYinDaoClr = dquCiShortFromChar(pData); + pData+=2u; + + /*μID*/ + pRouteStr->wPhySecCheckStaId= dquCiShortFromChar(pData); + pData+=2u; + + /*·ID*/ + pRouteStr->wFHDCId= dquCiShortFromChar(pData); + pData+=2u; + + /*жźżID*/ + + pRouteStr->wDDXHId = dquCiShortFromChar(pData); + pData+=2u; + + /*ID*/ + for(i=0;iwIntrudePhySecId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + + /*·۷źŻID*/ + pRouteStr->wReturnSignalId = dquCiShortFromChar(pData); + pData+=2u; + + /*νӦͣID*/ + pRouteStr->wFHQD_TW_WLQDId = dquCiShortFromChar(pData); + pData+=2u; + + /*·ؿɷźŻID*/ + pRouteStr->wFS_SignalId = dquCiShortFromChar(pData); + pData+=2u; + + /*·رźŻID*/ + pRouteStr->wSignalClsId = dquCiShortFromChar(pData); + pData+=2u; + + + /*·迪źŻID*/ + pRouteStr->wCBTCSignalOpenId = dquCiShortFromChar(pData); + pData += 2u; + + /*·迪źŻID*/ + pRouteStr->wSignalOpenId = dquCiShortFromChar(pData); + pData+=2u; + + + /*ͬʱźŻ*/ + pRouteStr->wBTSOpenId = dquCiShortFromChar(pData); + pData+=2u; + + /*ID*/ + pRouteStr->wDrvSwiGrpId = dquCiShortFromChar(pData); + pData+=2u; + + /*CBTCID*/ + pRouteStr->wCBTCOtherCIID = dquCiShortFromChar(pData); + pData+=2u; + /*ʽID*/ + pRouteStr->wBLCKOtherCIID = dquCiShortFromChar(pData); + pData+=2u; + + /* ID */ + for(i=0u;iwFloodGateIdBuf[i] = dquCiShortFromChar(pData); + pData+=2u; + } + /*·˽⡢ȡҪʱ*/ + pRouteStr->wNeedDelayUnlock = *pData; + pData++; + + rtnvalue = 1u; + return rtnvalue; +} +/********************************************* +*ܣݵȫԶ۷·ת +*˵pDataAddrݵַ pAllAutoRtnRouteStrȫԶ۷·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_AllAutoRtnRouteStruFromChar(UINT8 * pDataAddr,LS_AllAutoRtnRouteStru* pAllAutoRtnRouteStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pAllAutoRtnRouteStr)) + { + rtnvalue = 0u; + } + else + { + pAllAutoRtnRouteStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iszIncludeRouteId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + pData+=20u; + rtnvalue = 1u; + } + return rtnvalue; +} + +/********************************************* +*ܣݵת +*˵ + pDataAddrݵַ + pOverlapLockCondStru ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_OverlapLockCondStruFromChar(UINT8 * pDataAddr, LS_OveralpLockCondStru * pOverlapLockCondStru) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pOverlapLockCondStru)) + { + rtnvalue = 0u; + } + else + { + /*ȡID*/ + pOverlapLockCondStru->wOverlapId = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + + /*ȡΰ۷·ID*/ + for(i = 0u; i < OVLP_LOCK_COND_MAX_INCL_RET_ROUTE_N_PHY_SEC_NUM; i++) + { + pOverlapLockCondStru->szIncludeReturnRouteId[i] = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + } + + /*ȡΰ۷ID*/ + for(i = 0u; i < OVLP_LOCK_COND_MAX_INCL_RET_ROUTE_N_PHY_SEC_NUM; i++) + { + pOverlapLockCondStru->szIncludeRetTrkPhySecId[i] = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + } + + /*ȡΰμID*/ + for(i = 0u; i < OVLP_LOCK_COND_MAX_INCL_INV_SEC_N_CON_SWI_NUM; i++) + { + pOverlapLockCondStru->szIncludeInvSecAndConSwiId[i] = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + } + + /*ȡΰ޵жԱID*/ + for(i = 0u; i < OVLP_LOCK_COND_MAX_INCL_INV_OPP_OVLP_NUM; i++) + { + pOverlapLockCondStru->szIncludeInvOppOverlapId[i] = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + } + + /*ȡID*/ + pOverlapLockCondStru->overlapLocProSwitchGroupID = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + + /*ȡΰID*/ + for(i = 0u; i < ROUTE_MAX_FLOOD_GATE_NUM; i++) + { + pOverlapLockCondStru->szIncludeFloodGateId[i] = dquCiShortFromChar(pData); + pData += LS_DATA_DUAL_BYTE_ELEM_LEN; + } + + rtnvalue = 1u; + } + return rtnvalue; +} + +/* zt ɾش 2022-02-15 */ + + + +/********************************************* +*ܣݵμϵת +*˵ + pDataAddrݵַ + pLSPhyIntruPhySecStru μݽṹ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_PhySecIntrudeStruFromChar(UINT8 * pDataAddr, LS_PhySectionIntrudeStruct* pLSPhyIntruPhySecStru) +{ + UINT8 * pData = pDataAddr; + + UINT16 i = 0u; + + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pLSPhyIntruPhySecStru)) + { + rtnvalue = 0u; + return rtnvalue; + } + + pLSPhyIntruPhySecStru->physicalId = dquCiShortFromChar(pData); + + pData += 2u; + + for(i = 0u; i < PHYSICAL_INCL_INV_SWICH_NUM ; i++) + { + pLSPhyIntruPhySecStru->phyInvSecAndConSwiId[i] = dquCiShortFromChar(pData); + pData += 2u; + + } + + rtnvalue = 1u; + + return rtnvalue; +} + +/********************************************* +*ܣݵԶ·ת +*˵pDataAddrݵַ pGroupAutoRtnRouteStr Զ·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_GroupAutoRtnRouteStruFrmChar(UINT8 * pDataAddr,LS_GroupAutoRouteStru* pGroupAutoRtnRouteStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pGroupAutoRtnRouteStr)) + { + rtnvalue = 0u; + } + else + { + pGroupAutoRtnRouteStr->wId = dquCiShortFromChar(pData); + pData+=2u; + + for(i=0u;iszIncludeAutoRouteId[i] = dquCiShortFromChar(pData); + pData+=2u; + } + rtnvalue = 1u; + } + return rtnvalue; +} + +/********************************************* +*ܣݵ߼μϵת +*˵ +* pDataAddrݵַ +* pLSLgcIntruSecStru ߼μݽṹ +*ֵ0ʧܣ1ɹ +* qw.liu Ӷȡ߼ +*********************************************/ +UINT8 LS_LgcSecIntrudeStruFromChar(UINT8 * pDataAddr, LS_LgcSectionIntrudeStruct* pLSLgcIntruSecStru) +{ + UINT8 * pData = pDataAddr; + + UINT16 i = 0u; + + UINT8 rtnvalue = 0u; + + if ((NULL != pDataAddr) && (NULL != pLSLgcIntruSecStru)) + { + + + pLSLgcIntruSecStru->wLogSecId = dquCiShortFromChar(pData); + + pData += 2u; + + for (i = 0u; i < LOGIC_INCL_INV_SWICH_NUM; i++) + { + pLSLgcIntruSecStru->wszLogicInvSecAndConSwiId[i] = dquCiShortFromChar(pData); + pData += 2u; + + } + + rtnvalue = 1u; + } + else + { + rtnvalue = 0u; + } + return rtnvalue; +} + +/********************************************* +*ܣݵ߼βϵת +*˵ +* pDataAddrݵַ +* pLSLgcSecLtrlDfncStru ߼βݽṹ +*ֵ0ʧܣ1ɹ +* +*********************************************/ +UINT8 LS_LgcSecLrtlDfncStruFromChar(UINT8 * pDataAddr, LS_LgcSecLrtlDfncStruct* pLSLgcSecLtrlDfncStru) +{ + UINT8 * pData = pDataAddr; + + UINT16 i = 0u; + + UINT8 rtnvalue = 0u; + + /*TODO ȡ߼β @liuchang*/ + if ((NULL != pDataAddr) && (NULL != pLSLgcSecLtrlDfncStru)) + { + + + pLSLgcSecLtrlDfncStru->wLogSecId = dquCiShortFromChar(pData); + + pData += 2u; + + for (i = 0u; i < LOGIC_LTARL_DFNC_SWITCH_NUM; i++) + { + pLSLgcSecLtrlDfncStru->stLrtlDfncSwitch[i].wPointId= dquCiShortFromChar(pData); + pData += 2U; + pLSLgcSecLtrlDfncStru->stLrtlDfncSwitch[i].wPointSta = dquCiShortFromChar(pData); + pData += 2U; + pLSLgcSecLtrlDfncStru->szProtectLockDir[i] = *pData; + pData += 1U; + + } + + + rtnvalue = 1u; + } + else + { + rtnvalue = 0u; + } + return rtnvalue; +} + +/********************************************* +* ܣݵⱨת +* ˵pDataAddrݵַ +* pLSSGBJStru ⱨݽṹ +* ֵ0ʧܣ1ɹ +* ɶⱨModified by LQ 2023.11.13 +*********************************************/ +UINT8 LS_SGBJStruFromChar(UINT8* pDataAddr, LS_SGBJStruct* pLSSGBJStru) +{ + UINT8* pData = pDataAddr; + UINT16 i = 0U; + UINT16 wRelPhySecNum = 0U; + UINT8 rtnvalue = 0U; + + if ((NULL != pDataAddr) && (NULL != pLSSGBJStru)) + { + rtnvalue = 1U; + + pLSSGBJStru->wSGBJId = dquCiShortFromChar(pData); + pData += 2U; + + pLSSGBJStru->wSGBJRelayId = dquCiShortFromChar(pData); + pData += 2U; + + pLSSGBJStru->wSGBJRelayId_2 = dquCiShortFromChar(pData); + pData += 2U; + + pLSSGBJStru->wSGBJRelPhySecNum = dquCiShortFromChar(pData); + pData += 2U; + + wRelPhySecNum = pLSSGBJStru->wSGBJRelPhySecNum; + + if (SGBJ_RELATED_PHYSEC_SUM_MAX >= wRelPhySecNum) + { + for (i = 0U; i < wRelPhySecNum; i++) + { + pLSSGBJStru->szSGBJRelPhySecId[i] = dquCiShortFromChar(pData); + pData += 2U; + } + } + else + { + rtnvalue = 0U; /*·ޣʼʧ*/ + } + } + else + { + rtnvalue = 0U; + } + + return rtnvalue; +} + +/********************************************* +*ܣݵ߼ι豸ݽṹת +*˵pDataAddrݵַ logContactStr߼ι豸ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_ContactCfgDtStruFromChar(UINT8 * pDataAddr, LS_ContactLineStruct* logContactStr) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == logContactStr)) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + logContactStr->wId = dquCiShortFromChar(pData); + pData += 2u; + + if (LOGIC_SECTION_SUM_MAX < dquCiShortFromChar(pData)) + { + rtnvalue = 0u; + } + else + { + for (i = 0u; i < LOG_CONTACT_CONFIG_MAX_NUM; i++) + { + + logContactStr->wPointId[i] = dquCiShortFromChar(pData); + pData += 2u; + logContactStr->wPointSta[i] = *pData; + pData += 1u; + logContactStr->wAxisSecId[i] = dquCiShortFromChar(pData); + pData += 2u; + } + } + } + return rtnvalue; +} + +/********************************************* +*ܣݵ߼λ +*˵ +* pDataAddrݵַ +* pLSLgcIntruSecStru ߼μݽṹ +*ֵ0ʧܣ1ɹ +* LC +*********************************************/ +UINT8 LS_LgcSecInvEachStruFromChar(UINT8* pDataAddr, LS_EachLgcIntrudeStruct* pLSLgcInvEachStru) +{ + UINT8* pData = pDataAddr; + + UINT16 i = 0u; + + UINT8 rtnvalue = 0u; + + if ((NULL != pDataAddr) && (NULL != pLSLgcInvEachStru)) + { + pLSLgcInvEachStru->wLogSecId1 = dquCiShortFromChar(pData); + pData += 2u; + + pLSLgcInvEachStru->wLogSecId2 = dquCiShortFromChar(pData); + pData += 2u; + + pLSLgcInvEachStru->wLogSec1_CheckDir = *(pData); + pData += 1u; + + pLSLgcInvEachStru->wLogSec2_CheckDir = *(pData); + pData += 1u; + + rtnvalue = 1u; + } + else + { + rtnvalue = 0u; + } + return rtnvalue; +} + +/********************************************* +* ܣݵת۷źŻת +* ˵pDataAddrݵַ +* pTransRouteZFSigStru ת۷źŻidݽṹ +* ֵ0ʧܣ1ɹ +* fan +*********************************************/ +UINT8 LS_TransZFSigFromChar(UINT8* pDataAddr, LS_TransRouteZFSigStruct* pTransRouteZFSigStru) +{ + UINT8 * pData = pDataAddr; + UINT16 i = 0u; + UINT8 rtnvalue = 0u; + + if ((NULL == pDataAddr) || (NULL == pTransRouteZFSigStru)) + { + rtnvalue = 0u; + } + else + { + pTransRouteZFSigStru->wRouteId = dquCiShortFromChar(pData); + pData += 2u; + + pTransRouteZFSigStru->wTransRouteZFSigId = dquCiShortFromChar(pData); + pData += 2u; + + rtnvalue = 1u; + } + return rtnvalue; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruFrmChar.h b/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruFrmChar.h new file mode 100644 index 0000000..4b39b27 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruFrmChar.h @@ -0,0 +1,205 @@ +/************************************************************************ +* +* ļ dquCILSStruFrmChar.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ݵ·תṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_DI_LS_FRM_CHAR +#define DQU_DI_LS_FRM_CHAR + +#include "dquCILSStru.h" +#include "dquEmapInit.h" + +/********************************************* +*ܣݵ·ת +*˵pDataAddrݵַ pLongRouteStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_LongRouteStruFromChar(UINT8 * pDataAddr,LS_LongRouteStru* pLongRouteStr); +/********************************************* +*ܣݵǽ·ݽṹת +*˵pDataAddrݵַ pNoRouteDcStrǽ·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_NoRouteDcStruFromChar(UINT8 * pDataAddr,LS_NoRouteDcStru* pNoRouteDcStr); +/********************************************* +*ܣݵԶ·ת +*˵pDataAddrݵַ pAutoRouteStrԶ·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_AutoRouteStruFromChar(UINT8 * pDataAddr,LS_AutoRouteStru* pAutoRouteStr); +/********************************************* +*ܣݵԶ۷·ת +*˵pDataAddrݵַ pAutoRtnRouteStrԶ۷·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_AutoRtnRouteStruFromChar(UINT8 * pDataAddr,LS_AutoRtnRouteStru* pAutoRtnRouteStr); +/********************************************* +*ܣݵ·ת +*˵pDataAddrݵַ pReverseRouteStr·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_ReverseRouteStruFromChar(UINT8 * pDataAddr,LS_ReverseRouteStru* pReverseRouteStr); +/********************************************* +*ܣݵԶ·μת +*˵pDataAddrݵַ pRoutePhyAndCheckStateStr Զ·μݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_RoutePhyCheckStaStruFromChar(UINT8 * pDataAddr,LS_RoutePhyAndCheckStateStruct* pRoutePhyAndCheckStateStr); +/********************************************* +*ܣݵת +*˵pDataAddrݵַ pFHDaoChaStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_FHDaoChaStruFromChar(UINT8 * pDataAddr,LS_FHDaoChaStruct* pFHDaoChaStr); + +/********************************************* +*ܣݵת +*˵pDataAddrݵַ pFHDaoChaStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_DrvSwiGrpStruFromChar(UINT8 * pDataAddr, LS_RouteDrivedSwitchGroupStruct * pDrivedSwitchGroupStru); + + +/********************************************* +*ܣݵжźת +*˵pDataAddrݵַ pDDXHStr жźݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_DDXHStruFromChar(UINT8 * pDataAddr,LS_DDXHStruct* pDDXHStr); +/********************************************* +*ܣݵźŻת +*˵pDataAddrݵַ pSignalStr źŻݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_SignalStruFromChar(UINT8 * pDataAddr,LS_SignalStruct* pSignalStr); +/********************************************* +*ܣݵμݽṹת +*˵pDataAddrݵַ pIntruPhySecStrμݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_IntrudePhySecStruFromChar(UINT8 * pDataAddr,LS_IntrudePhySectionStruct* pIntruPhySecStr); + +/********************************************* +*ܣݵݽṹת +*˵pDataAddrݵַ pOtherCIStrݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_OtherCIStruFromChar(UINT8 * pDataAddr,LS_OtherCIStruct* pOtherCIStr); +/********************************************* +*ܣݵ·ݽṹת +*˵pDataAddrݵַpRouteStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_RouteStruFromChar(UINT8 * pDataAddr,LS_RouteStruct* pRouteStr); +/********************************************* +*ܣݵжźת +*˵pDataAddrݵַ pDDXHZStrжźݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_DDXHZStruFromChar(UINT8 * pDataAddr,LS_DDXHZStruct* pDDXHZStr); + +/********************************************* +*ܣݵȫԶ۷·ת +*˵pDataAddrݵַ pAllAutoRtnRouteStrȫԶ۷·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_AllAutoRtnRouteStruFromChar(UINT8 * pDataAddr,LS_AllAutoRtnRouteStru* pAllAutoRtnRouteStr); + +/********************************************* +*ܣݵת +*˵pDataAddrݵַ + pOverlapLockCondStru ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_OverlapLockCondStruFromChar(UINT8 * pDataAddr, LS_OveralpLockCondStru * pOverlapLockCondStru); + +/* zt ɾش 2022-02-15 */ + +/********************************************* +*ܣݵμϵת +*˵ + pDataAddrݵַ + pLSPhyIntruPhySecStru μݽṹ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_PhySecIntrudeStruFromChar(UINT8 * pDataAddr, LS_PhySectionIntrudeStruct* pLSPhyIntruPhySecStru); + +/********************************************* +*ܣݵ-ݽṹת +*˵pDataAddrݵַpProHostSwitchMapStr ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_ProSwitchHostSwStruFromChar(UINT8 * pDataAddr,LS_ProSwitchHostSwitchMapStruct* pProHostSwitchMapStr); + +/********************************************* +*ܣݵԶ·ת +*˵pDataAddrݵַ pGroupAutoRtnRouteStr Զ·ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_GroupAutoRtnRouteStruFrmChar(UINT8 * pDataAddr,LS_GroupAutoRouteStru* pGroupAutoRtnRouteStr); + +/********************************************* +*ܣݵ߼μϵת +*˵ +* pDataAddrݵַ +* pLSLgcIntruSecStru ߼μݽṹ +*ֵ0ʧܣ1ɹ +* qw.liu Ӷȡ߼ +*********************************************/ +UINT8 LS_LgcSecIntrudeStruFromChar(UINT8 * pDataAddr, LS_LgcSectionIntrudeStruct* pLSLgcIntruSecStru); + +/********************************************* +*ܣݵ߼βϵת +*˵ +* pDataAddrݵַ +* pLSLgcSecLtrlDfncStru ߼βݽṹ +*ֵ0ʧܣ1ɹ +* +*********************************************/ +UINT8 LS_LgcSecLrtlDfncStruFromChar(UINT8 * pDataAddr, LS_LgcSecLrtlDfncStruct* pLSLgcSecLtrlDfncStru); + +/********************************************* +* ܣݵⱨת +* ˵pDataAddrݵַ +* pLSSGBJStru ⱨݽṹ +* ֵ0ʧܣ1ɹ +* ɶⱨ2023.09.22 by LQ +*********************************************/ +UINT8 LS_SGBJStruFromChar(UINT8* pDataAddr, LS_SGBJStruct* pLSSGBJStru); + + +/********************************************* +*ܣݵ߼ι豸ݽṹת +*˵pDataAddrݵַ logContactStr߼ι豸ݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 LS_ContactCfgDtStruFromChar(UINT8 * pDataAddr, LS_ContactLineStruct* logContactStr); + + +/********************************************* +*ܣݵ߼λ +*˵ +* pDataAddrݵַ +* pLSLgcIntruSecStru ߼μݽṹ +*ֵ0ʧܣ1ɹ +* LC +*********************************************/ +UINT8 LS_LgcSecInvEachStruFromChar(UINT8* pDataAddr, LS_EachLgcIntrudeStruct* pLSLgcInvEachStru); + +/********************************************* +* ܣݵת۷źŻת +* ˵pDataAddrݵַ +* pTransRouteZFSigStru ת۷źŻidݽṹ +* ֵ0ʧܣ1ɹ +* fan +*********************************************/ +UINT8 LS_TransZFSigFromChar(UINT8* pDataAddr, LS_TransRouteZFSigStruct* pTransRouteZFSigStru); + +#endif diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruInit.c b/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruInit.c new file mode 100644 index 0000000..04600fa --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCILSStruInit.c @@ -0,0 +1,2354 @@ +/************************************************************************ +* +* ļ dquCILSStruInit.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ṹ嶨崦 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "dquCILSStruInit.h" +#include "dquCILSStru.h" +#include "DebugPrintInterface.h" + +/*********ȫֵϢݱ*******/ +LSDataStruct LSData; +LSDataStructLen LSDataLen; +/***************************/ + + + +/********************************************* +*ܣ䳤·ݽṹ +*˵LSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitLS_LongRouteStru(CHAR* LSDataName) +{ + UINT8 funcRtn; + LS_LongRouteStru* pLsLongRouteStr; /*ʱ·*/ + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + UINT16 j = 0u; + UINT8 rtnValue = 0u; + + /*Ѿʼˣǵִй*/ + if(LSData.pLSLongRouteStr != NULL) + { + rtnValue = 1u; + return rtnValue; + } + /*ȡ Ĭг */ + funcRtn = dquGetConfigData(LSDataName,LS_DATA_TYPE,LONG_ROUTE_DATA_ID,&pDataAddr,&DataSize); + if(funcRtn == 0u) + { + /*ʧ*/ + rtnValue = 0u; + return rtnValue; + } + /*ø*/ + if(DataSize%LONG_ROUTE_DATA_LEN != 0u) + { + debug_infor_printf((const)"\nCI_LS_DATA,LONG_ROUTE len %d not equal to fs",LONG_ROUTE_DATA_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(LS_DATA_TYPE<<8)+LONG_ROUTE_DATA_ID,PRINT_ONCE); + rtnValue = 0u; + return rtnValue; + } + + LSDataLen.LSLongRouteStrLen = (UINT16)(DataSize/LONG_ROUTE_DATA_LEN); + + if(DataSize DataSize) + {/*·вһ:飬ֱӷسɹ*/ + LSData.pLSReverseRouteStr = (LS_ReverseRouteStru *) MyNew((UINT32)(sizeof(LS_ReverseRouteStru))); + } + else + { + /*̬ռ*/ + LSData.pLSReverseRouteStr = (LS_ReverseRouteStru *) MyNew((UINT32)(sizeof(LS_ReverseRouteStru) * LSDataLen.LSReverseRouteStrLen)); + /*̬ռʧ*/ + if(NULL == LSData.pLSReverseRouteStr) + { + /*ռʧܣ鳤0Խ磬ֱӷʧ*/ + LSDataLen.LSReverseRouteStrLen = 0u; + + rtnValue = 0u; + } + else + { + /*ڴΪЧ*/ + (void)memset(LSData.pLSReverseRouteStr, 0x00,sizeof(LS_ReverseRouteStru) * LSDataLen.LSReverseRouteStrLen); + } + + if(1u == rtnValue) + { + /*ݵ·ṹ */ + for(j = 0u;j < LSDataLen.LSReverseRouteStrLen;j++) + { + pLsReverseRouteStr = LSData.pLSReverseRouteStr + j; + + /*ݽṹ*/ + rtnValue &= LS_ReverseRouteStruFromChar(pDataAddr,pLsReverseRouteStr); + pDataAddr += REVERSE_ROUTE_DATA_LEN; + + } + } + else + { + } + } + } + else + { + } + + + } + return rtnValue; +} + + + +/********************************************* +*ܣǽ·ݽṹ +*˵LSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitLS_NoRouteDcStru(CHAR* LSDataName) +{ + UINT8 funcRtn; + LS_NoRouteDcStru* pNoRouteDcStr; /*ʱ*/ + UINT8* pDataAddr; /*ݵַ*/ + UINT32 DataSize; /*ݴСֽ*/ + UINT16 j; + UINT8 rtnValue = 0u; + + /*Ѿʼˣǵִй*/ + if(LSData.pLSNoRouteDcStr != NULL) + { + rtnValue = 1u; + return rtnValue; + } + /*ȡ Ĭг */ + funcRtn = dquGetConfigData(LSDataName,LS_DATA_TYPE,NO_ROUTE_DATA_ID,&pDataAddr,&DataSize); + if(funcRtn == 0u) + { + /*ʧ*/ + rtnValue = 0u; + return rtnValue; + } + /*ø*/ + if(DataSize%NO_ROUTE_DATA_LEN != 0u) + { + debug_infor_printf((const)"\nCI_LS_DATA,NO_ROUTE len %d not equal to fs",NO_ROUTE_DATA_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(LS_DATA_TYPE<<8)+NO_ROUTE_DATA_ID,PRINT_ONCE); + rtnValue = 0u; + return rtnValue; + } + + LSDataLen.LSNoRouteDcStrLen = (UINT16)(DataSize/NO_ROUTE_DATA_LEN); + + if(DataSize DataSize) + { + LSData.pLSPhyIntruPhySecStru = (LS_PhySectionIntrudeStruct *)MyNew((UINT32)sizeof(LS_PhySectionIntrudeStruct)); + rtnValue = 1u; + return rtnValue; + } + else + { + /*ִ*/ + } + + /*̬ռ*/ + LSData.pLSPhyIntruPhySecStru = (LS_PhySectionIntrudeStruct *)MyNew((UINT32)(sizeof(LS_PhySectionIntrudeStruct) * LSDataLen.LS_PhySectionIntrudeStruLen)); + /*̬ռʧ*/ + if(NULL == LSData.pLSPhyIntruPhySecStru) + { + /*鳤0Խ*/ + LSDataLen.LS_PhySectionIntrudeStruLen = 0u; + + rtnValue = 0u; + + return rtnValue; + } + else + { + /*ڴΪЧ*/ + (void)memset(LSData.pLSPhyIntruPhySecStru, 0x00, sizeof(LS_PhySectionIntrudeStruct) * LSDataLen.LS_PhySectionIntrudeStruLen); + } + + /*ݵ Ĭг ṹ */ + rtnValue = 1u; + for(struInx = 0u; struInx < LSDataLen.LS_PhySectionIntrudeStruLen; struInx++) + { + pLSPhyIntruPhySecStru = LSData.pLSPhyIntruPhySecStru + struInx; + + /*ݽṹ*/ + rtnValue &= LS_PhySecIntrudeStruFromChar(pDataAddr, pLSPhyIntruPhySecStru); + + pDataAddr += PHYSICAL_INTRU_DATA_LEN; + } + + + return rtnValue; +} + + +/********************************************* +*ܣ-Ӧϵṹ +*˵LSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 InitLS_ProSwitchHostMapStru(CHAR* LSDataName) +{ + UINT8 funcRtn; + LS_ProSwitchHostSwitchMapStruct* pProHostSwitchMapStr = NULL; /*ʱ*/ + UINT8* pDataAddr = NULL; /*ݵַ*/ + UINT16 index = 0u; /**/ + UINT32 DataSize = 0u; /*ݴСֽ*/ + UINT16 j = 0u; + UINT8 rtnValue = 0u; + UINT8 hasInited = 0u;/*ǷѾʼ*/ + + /*Ѿʼˣǵִй*/ + if(LSData.pLSProSwitchHostSwitchMapStru != NULL) + { + hasInited = 1u; + rtnValue = 1u; + } + else + { + hasInited = 0u; + } + + if (0u == hasInited) + {/*δʼ*/ + if (NULL == LSDataName) + { + rtnValue = 0u; + } + else + { + rtnValue = 1u; + } + if (1u == rtnValue) + { + /*ȡ Ӧϵ */ + funcRtn = dquGetConfigData(LSDataName,LS_DATA_TYPE,PROSWITCH_HOSTSWITCH_MAP_ID,&pDataAddr,&DataSize); + if(funcRtn == 0u) + { + /*ʧ*/ + rtnValue = 0u; + } + else + { + rtnValue = 1u; + } + } + + + if (1u == rtnValue) + { + /*ø*/ + if((DataSize%PROSWITCH_HOSTSWITCH_MAP_LEN) != 0u) + { + debug_infor_printf((const)"\nCI_CI_DATA,PROSWITCH_HOSTSWITCH_DATA len %d not equal to fs",PROSWITCH_HOSTSWITCH_MAP_LEN); + DebugPrintAppError(ERROR_fs_columns_len_not_equal_to_ci_software,CI_DEVICE_TYPE_FS_TABLE,(UINT32)((LS_DATA_TYPE<<8)+PROSWITCH_HOSTSWITCH_MAP_ID),PRINT_ONCE); + rtnValue = 0u; + } + } + + if (1u == rtnValue) + { + LSDataLen.LS_ProSwitchHostSwitchMapStruLen = (UINT16)(DataSize/PROSWITCH_HOSTSWITCH_MAP_LEN); + + if(DataSize64*/ + +#define CI_SYSTEM_CI_TRANSMIT_ID ((UINT8)0x02) +#define CI_SYSTEM_CI_TRANSMIT_LEN ((UINT8)10)/*޸20170321޸ԭӿһУշǷȡ*/ + +#define CI_SYSTEM_OUTSIG_RALATE_LOG_ID ((UINT8)0x03) +#define CI_SYSTEM_OUTSIG_RALATE_LOG_LEN ((UINT8)52) + +#define CI_SYSTEM_CI_FUNC_SWITCH_ID ((UINT8)0x04) +#define CI_SYSTEM_CI_FUNC_SWITCH_LEN ((UINT8)3) + +#define CI_SYSTEM_CI_DIFF_LINE_DEV_ID ((UINT8)0x05) +#define CI_SYSTEM_CI_DIFF_LINE_DEV_LEN ((UINT8)5) + +#define CI_SYSTEM_CI_VIRTUAL_DEV_ID ((UINT8)0x06) +#define CI_SYSTEM_CI_VIRTUAL_DEV_LEN ((UINT8)3) + +#define CI_SYSTEM_OUTSIG_RALATE_AXIS_ID ((UINT8)0x07) /*޸20181121»ӵʽʱ()*/ +#define CI_SYSTEM_OUTSIG_RALATE_AXIS_LEN ((UINT8)82) + +#define CI_SYSTEM_CI_PATTERN_ID ((UINT8)0x08) /*ñ*/ +#define CI_SYSTEM_CI_PATTERN_LEN ((UINT8)13) /*޸Ϊ13ǷֲʽUT/CTνͣʱ䣬UT/CTӽʱʱ*/ + +#define CI_SYSTEM_VIRCI_INCLUDEOC_ID ((UINT8)0x09) /*OCӦϵ*/ +#define CI_SYSTEM_VIRCI_INCLUDEOC_LEN ((UINT8)22) + +#define CI_SYSTEM_CI_CUTOFF_POINT_ID ((UINT8)0x0C) +#define CI_SYSTEM_CI_CUTOFF_POINT_LEN ((UINT8)12) + +#define CI_SYSTEM_CI_LINK_LINE_ID ((UINT8)0x0D) + +#define CI_SYSTEM_CI_GATEWAY_DEVICE_ID ((UINT8)0x0E) /*豸ʾATSضӦϵ*/ +#define CI_SYSTEM_CI_GATEWAY_DEVICE_LEN ((UINT8)4) /*豸*/ + +#define CI_SYSTEM_ZSPKS_INCLUDE_ID ((UINT8)0x0a) /*SPKSϽSPKSϵ*/ +#define CI_SYSTEM_ZSPKS_INCLUDE_LEN ((UINT8)62) + +#define CI_SYSTEM_SIGWITHFUSHISIG_ID ((UINT8)0x0b) /*źŻ븴ʾźŻϵ*/ +#define CI_SYSTEM_SIGWITHFUSHISIG_LEN ((UINT8)12) /*źŻ븴ʾźŻϵ*/ + +#endif + diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIPZStruFrmChar.c b/TSCP/src/APP/ciapp/QueryFiles/dquCIPZStruFrmChar.c new file mode 100644 index 0000000..28ce3e8 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIPZStruFrmChar.c @@ -0,0 +1,441 @@ +/************************************************************************ +* +* ļ dquCIPZStruFrmChar.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ݵCIñת +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "dquCIPZStruFrmChar.h" +#include "dquEmapInit.h" +#include "dquCIReadCommonChar.h" + +DquCiTransmitStruct *pDquCiTranmitInfoStr = NULL; /*ӿݱӳṹ*/ +UINT16 dquCiTranmitInfoLen = 0u; + + +DquOutStationSigStruct *pDquOutStationSigStr = NULL; /*վźŻ߼()ݱӳṹ*/ +UINT16 dquOutStationSigStrLen = 0u; + +DquCiFuncSwitchStructNew *pDquCiFuncSwitchStru = NULL; /*ܿݱӳṹ*/ +UINT16 dquCiFuncSwitchStruLen = 0u; + +DquDiffLineDevStruct *pTempDquDiffLineDevData = NULL; /*·豸ݱӳṹ*/ +UINT16 tempDquDiffLineDevDataLen = 0u; + +DquVirtualDeviceStruct *pDquVirtualDeviceStr = NULL; /*豸ݱӳṹ*/ +UINT16 dquVirtualDeviceStrLen = 0u; + +DquCutoffPointStruct *pstDquCutoffPointData = NULL; /*ֽ豸ݱӳṹ*/ +UINT16 dquCutoffPointDataLen =0U; /*ֽ豸ݱ*/ + +DquGatewayDeviceStruct * pstDquGatewayDeviceData=NULL; /*豸Ϣ*/ +UINT16 dquGatewayDeviceDataLen = 0u; /**/ +/********************************************* +*ܣݵCIñת +*˵pDataAddrݵַpPZSysParStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZ_SystemParaStruFromCharNew(UINT8 * pDataAddr,ParaStruct* pPZSysParStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + + + if ((NULL == pDataAddr) || (NULL == pPZSysParStr)) + { + rtnvalue = 0u; + } + else + { + rtnvalue = 1u; + + pPZSysParStr->SysParaId = dquCiShortFromChar(pDataAddr); /**/ + pDataAddr += 2u; + + pPZSysParStr->SysParaValue = dquCiShortFromChar(pDataAddr); /*ȡֵ*/ + pDataAddr += 2u; + } + + return rtnvalue; +} + + +/********************************************* +*ܣݵCIñת +*˵pDataAddrݵַpPZSysParStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquCiTransmitInfoFromChar(UINT8 * pDataAddr,DquCiTransmitStruct* pCiTransmitStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + + if ((NULL != pDataAddr) && (NULL != pCiTransmitStr)) + { + + pCiTransmitStr->seq = dquCiShortFromChar(pData); /* */ + pData += 2u; + + pCiTransmitStr->devType = *pData; /* 豸 */ + pData += 1u; + + pCiTransmitStr->devId = dquCiShortFromChar(pData); /* 豸 */ + pData += 2u; + + pCiTransmitStr->srcCiId = dquCiShortFromChar(pData); /* CI */ + pData += 2u; + + pCiTransmitStr->dstCiId= dquCiShortFromChar(pData); /*CI */ + pData += 2u; + + pCiTransmitStr->phyLockDirOppOrNot = *pData; /*շǷȡ־*/ + pData += 1u; + + rtnvalue = 1u; + } + return rtnvalue; + +} + +/* +: ԭʼתΪ·豸 +: UINT8 * pDataAddr ݵַ +: DquDiffLineDevStruct * pDiffLineDevData ·ݽṹָ +ֵ: 0 ʧ + 1 ɹ +*/ +UINT8 PZDquDiffLineDevDataFromChar(UINT8 * pDataAddr, DquDiffLineDevStruct * pDiffLineDevData) +{ + UINT8 retVal = 0u; + + if ((NULL != pDataAddr) && (NULL != pDiffLineDevData)) + { + + pDiffLineDevData->devSn = dquCiShortFromChar(pDataAddr); /**/ + pDataAddr += 2u; + + pDiffLineDevData->devType = *pDataAddr; /*豸*/ + pDataAddr += 1u; + + pDiffLineDevData->devId = dquCiShortFromChar(pDataAddr); /*豸*/ + pDataAddr += 2u; + + retVal = 1u; + } + + return retVal; +} + + +/********************************************* +*ܣӵʽʱݱʽʱýṹת +*˵pDataAddrݵַ +* pDquOutStationSigStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquOutStationSigReltLogSec(UINT8 * pDataAddr, DquOutStationSigStruct *pOutStationSigStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 ii; + UINT16 logSecId = 0u; + + + if ((NULL != pDataAddr) && (NULL != pOutStationSigStr)) + { + pOutStationSigStr->wRalatedLogSecSum = 0u; /*߼ʼΪ0*/ + + pOutStationSigStr->wSignalId = dquCiShortFromChar(pData); /* źŻID*/ + pData += 2u; + + for(ii = 0u;ii < OUTSTATION_SIGNAL_RALATED_LOGSEC_SUM_MAX;ii++) + { + logSecId = dquCiShortFromChar(pData); /*߼ID*/ + pData += 2u; + + if(0u != logSecId) + { + pOutStationSigStr->wRalatedLogSecIdBuf[pOutStationSigStr->wRalatedLogSecSum] = logSecId; + pOutStationSigStr->wRalatedLogSecSum++; + } + else + { + } + } + rtnvalue = 1u; + } + else + { + } + return rtnvalue; + +} + +/********************************************* +*ܣӹܿݱܿýṹת +*˵pDataAddr ݵַ +* pDquCiFuncSwitchStru CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquCiFunctionSwitchInfo(UINT8 * pDataAddr, DquCiFuncSwitchStructNew * pCiFuncSwitchStru) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 ii = 0u; + + if ((NULL != pDataAddr) && (NULL != pCiFuncSwitchStru)) + { + pCiFuncSwitchStru->wCiFuncSwitchId = dquCiShortFromChar(pData); /*ܱ*/ + pData += 2u; + + pCiFuncSwitchStru->wCiFuncSwitchVal = *pData; /*ܿȡֵ*/ + pData += 1u; + + rtnvalue = 1u; + } + return rtnvalue; + +} + +/********************************************* +*ܣ豸ݱ豸ýṹת +*˵pDataAddrݵַ +* pVirtualDeviceStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquVirtualDeviceInfoFromChar(UINT8 * pDataAddr, DquVirtualDeviceStruct *pVirtualDeviceStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + + if ((NULL != pData) && (NULL != pVirtualDeviceStr)) + { + + pVirtualDeviceStr->vDeviceId = dquCiShortFromChar(pData); /*豸ID*/ + pData += 2u; + + pVirtualDeviceStr->vDeviceType = *pData; /* 豸*/ + pData += 1u; + + rtnvalue = 1u; + } + + return rtnvalue; +} + +/********************************************* +*ܣӵʽʱݣΣʽʱýṹת +*˵pDataAddrݵַ +* pDquOutStationSigStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquOutStationSigAxisSecInfo(UINT8 * pDataAddr, DquOutStationSigStruct *pOutStationSigStr) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u; + UINT8 ii; + UINT16 axisSecId = 0u; + + + if ((NULL != pDataAddr) && (NULL != pOutStationSigStr)) + { + pOutStationSigStr->wRelatedAxisSecSum = 0u; /*ʼΪ0*/ + + pOutStationSigStr->wSignalId = dquCiShortFromChar(pData); /* źŻID*/ + pData += 2u; + + for(ii = 0u;ii < OUTSTATION_SIGNAL_RELATED_AXISSEC_SUM_MAX;ii++) + { + axisSecId = dquCiShortFromChar(pData); /*ID*/ + pData += 2u; + + if(0u != axisSecId) + { + pOutStationSigStr->wRelatedAxisSecIdBuf[pOutStationSigStr->wRelatedAxisSecSum] = axisSecId; + pOutStationSigStr->wRelatedAxisSecSum++; + } + else + { + } + } + rtnvalue = 1u; + } + else + { + } + return rtnvalue; + +} +/********************************************* +*ܣOCӦϵݱṹת +*˵pDataAddrݵַ +* pIncludeOCBuf OC +*ֵ +*********************************************/ +UINT8 PZDquVirCIWithOCRelatFromChar(UINT8 * pDataAddr, UINT8 *pIncludeOCBuf) +{ + UINT8 * pData = pDataAddr; + UINT8 rtnvalue = 0u;/*Ŀ*/ + UINT16 ocid = 0u; + UINT8 OCNum = 0u; + UINT8 i =0u; + + if ((NULL != pData) && (NULL != pIncludeOCBuf)) + { + for(i=0u;i<(CI_SYSTEM_VIRCI_INCLUDEOC_LEN-2u)/2u;i++) + { + ocid = ShortFromChar(pData); + pData+=2u; + if(VIRTUAL_CI_INCLUDE_OC_MAX > OCNum) + { + if(ocid < UINT16_MAX) + { + pIncludeOCBuf[OCNum++] =(UINT8)ocid; + } + } + } + rtnvalue = OCNum; + } + + return rtnvalue; +} + +/********************************************* +*ܣȡÿźŻ븴ʾźŻ +*˵pDataAddrݵַ +* pFushiSignalIdBuf źŻʾźŻID +*ֵźŻʾźŻ +*********************************************/ +UINT8 PZDquSigWithFushiSigFromChar(UINT8* pDataAddr, UINT16* pFushiSignalIdBuf) +{ + UINT8* pData = pDataAddr; + UINT8 rtnvalue = 0;/*Ŀ*/ + UINT16 fushiSignalId = 0u; + UINT8 fushiSignalNum = 0u; + UINT8 i = 0u; + + if ((NULL != pData) && (NULL != pFushiSignalIdBuf)) + { + for (i = 0U; i < (CI_SYSTEM_SIGWITHFUSHISIG_LEN - 2U) / 2U; i++) + { + fushiSignalId = ShortFromChar(pData); + pData += 2; + if (SIGNAL_FUSHINUM_MAX > fushiSignalNum) + { + if ((fushiSignalId < UINT16_MAX) && (0U != fushiSignalId)) + { + pFushiSignalIdBuf[fushiSignalNum++] = fushiSignalId; + SetSignalIsfushiFlag(fushiSignalId, SIGNALTYPE_FUSHI_YES);/*ݣźŻĸʾ*/ + } + } + } + rtnvalue = fushiSignalNum; + } + + return rtnvalue; +} + +/********************************************* +*ܣȡÿSPKSϽSPKSϵ +*˵pDataAddrݵַ +* pSpksIncludeSpksIdBuf ϽspksID +*ֵźŻʾźŻ +*********************************************/ +UINT8 PZDquTotalSpksWithSpksFromChar(UINT8* pDataAddr, UINT16* pSpksIncludeSpksIdBuf) +{ + UINT8* pData = pDataAddr; + UINT8 rtnvalue = 0;/*Ŀ*/ + UINT16 spksId = 0u; + UINT8 spksNum = 0u; + UINT8 i = 0u; + + if ((NULL != pData) && (NULL != pSpksIncludeSpksIdBuf)) + { + for (i = 0U; i < (CI_SYSTEM_ZSPKS_INCLUDE_LEN - 2U) / 2U; i++) + { + spksId = ShortFromChar(pData); + pData += 2; + if (INCLUDELESPKS_MAX_NUM > spksNum) + { + if ((spksId < UINT16_MAX) && (0U != spksId)) + { + pSpksIncludeSpksIdBuf[spksNum++] = spksId; + } + } + } + rtnvalue = spksNum; + } + + return rtnvalue; +} + +/* +: ԭʼתΪֽ +: UINT8 * pDataAddr ݵַ +: DquCutoffPointStruct * pCutoffPointData ֽݽṹָ +ֵ: 0 ʧ +1 ɹ +*/ +UINT8 PZDquCutoffPointDataFromChar(UINT8 * pDataAddr, DquCutoffPointStruct * pCutoffPointData) +{ + UINT8 retVal = 0u; + + if ((NULL != pDataAddr) && (NULL != pCutoffPointData)) + { + + pCutoffPointData->wCutoffPointId = dquCiShortFromChar(pDataAddr); /**/ + pDataAddr += 2u; + + pCutoffPointData->wCutoffPointLinkId = dquCiShortFromChar(pDataAddr); /*LinkId*/ + pDataAddr += 2u; + + pCutoffPointData->dwCutoffPointLinkOff = dquCiLongFromChar(pDataAddr); /*LinkId*/ + pDataAddr += 4u; + + pCutoffPointData->wRelativeTioc1 = dquCiShortFromChar(pDataAddr); /*Tioc1*/ + pDataAddr += 2u; + + pCutoffPointData->wRelativeTioc2 = dquCiShortFromChar(pDataAddr); /*Tioc2*/ + pDataAddr += 2u; + retVal = 1u; + } + + return retVal; +} + +/* +: ԭʼתΪTIOC ATS豸 +: UINT8 * pDataAddr ݵַ +: DquGatewayDeviceStruct * pGatewayDeviceData ݽṹָ +ֵ: 0 ʧ +1 ɹ +*/ +UINT8 PZDquGatewayDeviceDataFromChar(UINT8 * pDataAddr, DquGatewayDeviceStruct * pGatewayDeviceData) +{ + /*ʼ*/ + UINT8 retVal = 0u; + + /*Ϊ*/ + if ((NULL != pDataAddr) && (NULL != pGatewayDeviceData)) + { + + pGatewayDeviceData->wTiocId = dquCiShortFromChar(pDataAddr); /*ID*/ + pDataAddr += 2u; + + pGatewayDeviceData->wGatewayDeviceId = dquCiShortFromChar(pDataAddr); /*ID*/ + pDataAddr += 2u; + + retVal = 1u; + } + else + { + + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIPZStruFrmChar.h b/TSCP/src/APP/ciapp/QueryFiles/dquCIPZStruFrmChar.h new file mode 100644 index 0000000..919d7e1 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIPZStruFrmChar.h @@ -0,0 +1,192 @@ +/************************************************************************ +* +* ļ dquCIPZStruFrmChar.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ݵCIñת +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_CIPZ_FRM_CHAR +#define DQU_CIPZ_FRM_CHAR + +#include "dquCIPZStru.h" + +#define OUTSTATION_SIGNAL_RALATED_LOGSEC_SUM_MAX ((UINT8)25) /*վźŻ߼Ŀ*/ +#define OUTSTATION_SIGNAL_RELATED_AXISSEC_SUM_MAX ((UINT8)40) /*վźŻĿ*/ + +/* ͨ豸 */ +typedef struct S_DQU_CI_TRANSMIT_STRU +{ + UINT16 seq; /* к */ + UINT16 devType; /* 豸 */ + UINT16 devId; /* 豸ID */ + UINT16 srcCiId; /* ID */ + UINT16 dstCiId; /* ID */ + UINT16 phyLockDirOppOrNot;/*շǷȡ*/ +} DquCiTransmitStruct; + + +/* ͨ豸 */ +typedef struct S_DQU_DIFF_LINE_DEV_STRU +{ + UINT16 devSn; /* к */ + UINT8 devType; /* 豸 */ + UINT16 devId; /* 豸ID */ +} DquDiffLineDevStruct; + +/*վźŻ߼ݽṹ*/ +typedef struct S_DQU_OutStationSigStruct +{ + UINT16 wSignalId; /*źŻID*/ + UINT16 wRalatedLogSecSum; /*߼Ŀ*/ + UINT16 wRalatedLogSecIdBuf[SIGNAL_RELATED_LOGSEC_MAX_SUM]; /*߼ID*/ + UINT16 wRelatedAxisSecSum; /*Ŀ*/ + UINT16 wRelatedAxisSecIdBuf[SIGNAL_RELATED_AXISSEC_MAX_SUM]; /*ID*/ +}DquOutStationSigStruct; + +/*豸ݽṹ*/ +typedef struct S_DQU_VirtualDeviceStruct +{ + UINT16 vDeviceId; /*豸ID*/ + UINT16 vDeviceType; /*豸*/ +}DquVirtualDeviceStruct; + + +/*豸ݽṹ*/ +typedef struct S_DQU_CutoffPointStruct +{ + UINT16 wCutoffPointId; /*豸ID*/ + UINT16 wCutoffPointLinkId; /*ֽLinkId*/ + UINT32 dwCutoffPointLinkOff; /*ֽLinkOff*/ + UINT16 wRelativeTioc1; /*Tioc1*/ + UINT16 wRelativeTioc2; /*Tioc1*/ +}DquCutoffPointStruct; + +typedef struct S_DQU_GatewayDeviceConfigStruct +{ + UINT16 wTiocId; /* TIOC */ + UINT16 wGatewayDeviceId; /* 豸+ */ +}DquGatewayDeviceStruct; + +extern DquCiTransmitStruct *pDquCiTranmitInfoStr; /*ӿݱӳṹ*/ +extern UINT16 dquCiTranmitInfoLen; + +extern DquOutStationSigStruct *pDquOutStationSigStr; /*վźŻ߼ݱӳṹ*/ +extern UINT16 dquOutStationSigStrLen ; + +extern DquCiFuncSwitchStructNew *pDquCiFuncSwitchStru; /*ܿݱӳṹ*/ +extern UINT16 dquCiFuncSwitchStruLen; + +extern DquDiffLineDevStruct *pTempDquDiffLineDevData; /*·豸ӳṹ*/ +extern UINT16 tempDquDiffLineDevDataLen; + +extern DquVirtualDeviceStruct *pDquVirtualDeviceStr; /*豸ӳṹ*/ +extern UINT16 dquVirtualDeviceStrLen; + +extern DquCutoffPointStruct *pstDquCutoffPointData; +extern UINT16 dquCutoffPointDataLen; + +extern DquGatewayDeviceStruct * pstDquGatewayDeviceData; +extern UINT16 dquGatewayDeviceDataLen; + +/********************************************* +*ܣݵCIñת +*˵pDataAddrݵַpCiTransmitStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquCiTransmitInfoFromChar(UINT8 * pDataAddr,DquCiTransmitStruct* pCiTransmitStr); + +/* +: ԭʼתΪ·豸 +: UINT8 * pDataAddr ݵַ +: DquDiffLineDevStruct * pDiffLineDevData ·ݽṹָ +ֵ: 0 ʧ + 1 ɹ +*/ +UINT8 PZDquDiffLineDevDataFromChar(UINT8 * pDataAddr, DquDiffLineDevStruct * pDiffLineDevData); + +/********************************************* +*ܣӵʽʱݱʽʱýṹת +*˵pDataAddrݵַ +* pDquOutStationSigStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquOutStationSigReltLogSec(UINT8 * pDataAddr,DquOutStationSigStruct *pOutStationSigStr); + +/********************************************* +*ܣӹܿݱܿýṹת +*˵pDataAddr ݵַ +* pDquCiFuncSwitchStru CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquCiFunctionSwitchInfo(UINT8 * pDataAddr, DquCiFuncSwitchStructNew *pCiFuncSwitchStru); + +/********************************************* +*ܣ豸ݱ豸ýṹת +*˵pDataAddrݵַ +* pVirtualDeviceStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquVirtualDeviceInfoFromChar(UINT8 * pDataAddr, DquVirtualDeviceStruct *pVirtualDeviceStr); + +/********************************************* +*ܣӵʽʱݣΣʽʱýṹת +*˵pDataAddrݵַ +* pDquOutStationSigStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZDquOutStationSigAxisSecInfo(UINT8 * pDataAddr, DquOutStationSigStruct *pOutStationSigStr); + +/********************************************* +*ܣݵCIñת +*˵pDataAddrݵַpPZSysParStr CIݽṹָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 PZ_SystemParaStruFromCharNew(UINT8 * pDataAddr,ParaStruct* pPZSysParStr); +/********************************************* +*ܣOCӦϵݱṹת +*˵pDataAddrݵַ +* pIncludeOCBuf OC +*ֵ +*********************************************/ +UINT8 PZDquVirCIWithOCRelatFromChar(UINT8 * pDataAddr, UINT8 *pIncludeOCBuf); + +/********************************************* +*ܣȡÿźŻ븴ʾźŻ +*˵pDataAddrݵַ +* pFushiSignalIdBuf źŻʾźŻID +*ֵźŻʾźŻ +*********************************************/ +UINT8 PZDquSigWithFushiSigFromChar(UINT8* pDataAddr, UINT16* pFushiSignalIdBuf); + +/********************************************* +*ܣȡÿSPKSϽSPKSϵ +*˵pDataAddrݵַ +* pSpksIncludeSpksIdBuf ϽspksID +*ֵźŻʾźŻ +*********************************************/ +UINT8 PZDquTotalSpksWithSpksFromChar(UINT8* pDataAddr, UINT16* pSpksIncludeSpksIdBuf); + +/* +: ԭʼתΪֽ +: UINT8 * pDataAddr ݵַ +: DquCutoffPointStruct * pCutoffPointData ֽݽṹָ +ֵ: 0 ʧ +1 ɹ +*/ +UINT8 PZDquCutoffPointDataFromChar(UINT8 * pDataAddr, DquCutoffPointStruct * pCutoffPointData); + +/* +: ԭʼתΪTIOC ATS豸 +: UINT8 * pDataAddr ݵַ +: DquGatewayDeviceStruct * pGatewayDeviceData ݽṹָ +ֵ: 0 ʧ +1 ɹ +*/ +UINT8 PZDquGatewayDeviceDataFromChar(UINT8 * pDataAddr, DquGatewayDeviceStruct * pGatewayDeviceData); +#endif + diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIReadCommonChar.c b/TSCP/src/APP/ciapp/QueryFiles/dquCIReadCommonChar.c new file mode 100644 index 0000000..62122f8 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIReadCommonChar.c @@ -0,0 +1,99 @@ +/************************************************************************ +* +* ļ dquCIReadCommonChar.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ӵײݶȡֽں滻ͨõ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "dquCIReadCommonChar.h" + + +/********************************************* +*ܣݵUINT32 ת +*˵pDataAddrݵַ +*ֵpDataAddrȡĸֽݣЧֵ0 +*********************************************/ +UINT32 dquCiLongFromChar(UINT8 * pDataAddr) +{ + UINT32 tmpVal = 0u; + /* Ϊշ0 0xffffFF */ + if (pDataAddr != NULL) + { + tmpVal = LongFromChar(pDataAddr); + if (tmpVal == UINT32_MAX) + { + tmpVal = 0u; + } + } + + return tmpVal; +} + +/********************************************* +*ܣݵUINT16 ת +*˵pDataAddrݵַ +*ֵpDataAddrȡֽݣЧֵ0 +*********************************************/ +UINT16 dquCiShortFromChar(UINT8 * pDataAddr) +{ + UINT16 tmpVal = 0u; + /* Ϊշ0 0xffffFF */ + if (pDataAddr != NULL) + { + tmpVal = ShortFromChar(pDataAddr); + if (tmpVal == UINT16_MAX) + { + tmpVal = 0u; + } + } + + return tmpVal; +} + + +/********************************************* +*ܣݵUINT32 Сת +*˵pDataAddrݵַ +*ֵpDataAddrȡĸֽݣЧֵ0 +*********************************************/ +UINT32 dquCiLongFromCharLe(UINT8 * pDataAddr) +{ + UINT32 tmpVal = 0u; + /* Ϊշ0 0xffffFF */ + if (pDataAddr != NULL) + { + tmpVal = LongFromCharLE(pDataAddr); + if (tmpVal == UINT32_MAX) + { + tmpVal = 0u; + } + } + + return tmpVal; +} + +/********************************************* +*ܣݵUINT16 С˶ת +*˵pDataAddrݵַ +*ֵpDataAddrȡֽݣЧֵ0 +*********************************************/ +UINT16 dquCiShortFromCharLe(UINT8 * pDataAddr) +{ + UINT16 tmpVal = 0u; + /* Ϊշ0 0xffffFF */ + if (pDataAddr != NULL) + { + tmpVal = ShortFromCharLE(pDataAddr); + if (tmpVal == UINT16_MAX) + { + tmpVal = 0u; + } + } + + return tmpVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIReadCommonChar.h b/TSCP/src/APP/ciapp/QueryFiles/dquCIReadCommonChar.h new file mode 100644 index 0000000..de3ee97 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIReadCommonChar.h @@ -0,0 +1,54 @@ +/************************************************************************ +* +* ļ dquCIReadCommonChar.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ݵ·תṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef _DQU_CI_READ_COMMON_CHAR_H_ +#define _DQU_CI_READ_COMMON_CHAR_H_ + +#include "dquCILSStru.h" +#include "dquEmapInit.h" + +#ifdef __cplusplus +extern "C" { +#endif +/********************************************* +*ܣݵUINT32 ת +*˵pDataAddrݵַ +*ֵpDataAddrȡĸֽݣЧֵ0 +*********************************************/ +UINT32 dquCiLongFromChar(UINT8 * pDataAddr); + +/********************************************* +*ܣݵUINT16 ת +*˵pDataAddrݵַ +*ֵpDataAddrȡֽݣЧֵ0 +*********************************************/ +UINT16 dquCiShortFromChar(UINT8 * pDataAddr); + + +/********************************************* +*ܣݵUINT32 Сת +*˵pDataAddrݵַ +*ֵpDataAddrȡĸֽݣЧֵ0 +*********************************************/ +UINT32 dquCiLongFromCharLe(UINT8 * pDataAddr); + +/********************************************* +*ܣݵUINT16 С˶ת +*˵pDataAddrݵַ +*ֵpDataAddrȡֽݣЧֵ0 +*********************************************/ +UINT16 dquCiShortFromCharLe(UINT8 * pDataAddr); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquCIStru.h b/TSCP/src/APP/ciapp/QueryFiles/dquCIStru.h new file mode 100644 index 0000000..d8f6b03 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquCIStru.h @@ -0,0 +1,26 @@ +/************************************************************************ +* +* ļ dquCIStru.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_CI_STRUCT_H +#define DQU_CI_STRUCT_H + +#include "CommonTypes.h" +#include "dquCILSStru.h" +#include "dquCIJDQStru.h" + +/***************/ +#define DEVICE_IP_TYPE ((UINT32)0x40) + +#define ZC_DSU_TRANSMIT_DATA_ID ((UINT32)4) +#define ZC_DSU_TRANSMIT_DATA_LEN ((UINT16)(34+30)) + +#endif diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.c b/TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.c new file mode 100644 index 0000000..71bb91a --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.c @@ -0,0 +1,4488 @@ +/************************************************************************ +* +* ļ dquMaskInit.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* λʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "dquMaskInit.h" +#include "commonQueryStruDef.h" +#include "SignalDefine.h" +#include "../Signal/SignalConfigDataManage.h" + + +UINT16 ConfigCiToLeuMaskCurSum[CI_SUM_MAX] = {0u}; /*CIվLeuλǰ*/ +UINT16 ConfigZcToCiMaskCurSum[CI_SUM_MAX] = {0u}; /*CIվZCλǰ*/ +UINT16 ConfigCiToZcMaskCurSum[CI_SUM_MAX] = {0u}; /*CIվZCλǰ*/ +UINT16 ConfigCiToAtsMaskCurSum[CI_SUM_MAX] = {0u}; /*CIվATSλǰ*/ + +UINT16 ConfigCiToLeuMaskIdMax[CI_SUM_MAX] = {0u}; /*CIվLeuλֵ*/ +UINT16 ConfigZcToCiMaskIdMax[CI_SUM_MAX] = {0u}; /*CIվZCλֵ*/ +UINT16 ConfigCiToZcMaskIdMax[CI_SUM_MAX] = {0u}; /*CIվZCλֵ*/ +UINT16 ConfigCiToAtsMaskIdMax[CI_SUM_MAX] = {0u}; /*CIվATSλֵ*/ + + +MaskConfigDataStruct ConfigCiToAtsMaskConfigDataStru[CI_SUM_MAX][CI_TO_ATS_MASK_SUM_MAX]; /*CIվATSλ*/ +MaskConfigDataStruct ConfigCiToZcMaskConfigDataStru[CI_SUM_MAX][CI_TO_ZC_MASK_SUM_MAX]; /*CIվZCλ*/ +MaskConfigDataStruct ConfigZcToCiMaskConfigDataStru[CI_SUM_MAX][ZC_TO_CI_MASK_SUM_MAX]; /*ZCվCIλ*/ +MaskConfigDataStruct ConfigCiToLeuMaskConfigDataStru[CI_SUM_MAX][CI_TO_LEU_MASK_SUM_MAX]; /*CILEUλ*/ + + +UINT8 MaskCfgDtStruFrmCI2ZCLogSgmt(UINT8 * FSDataName); +UINT8 MaskCfgDtStruFrmZC2CiRouteMask(UINT8 * FSDataName); +/********************************************* +*ܣCIATSλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSSwitchMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = CI_ERROR; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow = 0u; /*λ*/ + UINT16 DeviceID = 0u; /*豸ID*/ + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT16 rowCount = 0u; + UINT8 rowLenth = 0u;/*ֽ*/ + + /*Ӧÿһ*/ + UINT8 MaskType[]={0u,MASK_TYPE_SWITCH_DINGWEI,MASK_TYPE_SWITCH_FANWEI,MASK_TYPE_SWITCH_SIKAI,MASK_TYPE_SWITCH_DYNAMIC_JICHA, + MASK_TYPE_SWITCH_MOVING,MASK_TYPE_SWITCH_DANSUO,MASK_TYPE_SWITCH_FENGSUO,MASK_TYPE_SWITCH_YINDAOSUO,MASK_TYPE_SWITCH_PROTECTLOCK,MASK_TYPE_SWITCH_BYPASS, + MASK_TYPE_SWITCH_OPEN_CAP,MASK_TYPE_SWITCH_SUDDEN_JICHA,0u}; + UINT16 BuChang = 0u;/**/ + + funcRtn = dquGetConfigDataNew(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_SWITCH_MASK_ID,&pDataAddr,&DataSize,&rowCount); + if(funcRtn==0u) + { + /**/ + } + else + { + funcRtn = CI_SUCCESS; + /*ݶȡ*/ + if((0u < DataSize) && (0u < rowCount)) + { + if(0u == DataSize % rowCount) + { + /*һֽ*/ + rowLenth = (UINT8)(DataSize / rowCount); + for(;DataSize>0u;DataSize-=2u) + { + residue = (UINT16)(BuChang%(rowLenth/2u)); + /*һеģһһid*/ + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + + pDataLin = pDataAddr + rowLenth -2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow < CI_SUM_MAX) + { + pDataAddr+=2u; + BuChang++; + } + else + { + funcRtn = CI_ERROR; + break; + } + } + /*ڶλֵ*/ + else if((0u < residue) && (residue < ((rowLenth / 2u)-1u))) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + if((CI_SUM_MAX > MaskRow)&&(CI_TO_ATS_MASK_SUM_MAX > tempMaskId)&&(0u ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { + funcRtn = CI_ERROR; + break; + } + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + } + else + { + funcRtn = CI_ERROR; + } + } + else + { + funcRtn = CI_SUCCESS; + } + } + return funcRtn; +} +/* zt ɾش 2022-02-15 */ +/********************************************* +*ܣCI-ATSźŻλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*1zt 2022.02.28 źŻ쳣رλ +*2qw.liu 2022.08.10 źŻϱλ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSSignalMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 rowCount = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT8 reVal = CI_ERROR; + UINT8 rowLenth = 0u;/*г*/ + + UINT8 MaskType[] = { 0u,MASK_TYPE_SIGNAL_RED,MASK_TYPE_SIGNAL_YELLOW,MASK_TYPE_SIGNAL_GREEN,MASK_TYPE_SIGNAL_WHITE, + MASK_TYPE_SIGNAL_REDYELLOW,MASK_TYPE_SIGNAL_LIGHTSTATE,MASK_TYPE_SIGNAL_BREAK,MASK_TYPE_SIGNAL_FENGSUO,MASK_TYPE_SIGNAL_CENTER_DETAIN, + MASK_TYPE_SIGNAL_LOCAL_DETAIN,MASK_TYPE_SIGNAL_LINSHIXIANSU_SET,MASK_TYPE_SIGNAL_DOUBLE_GREEN,MASK_TYPE_SIGNAL_DOUBLE_YELLOW, + MASK_TYPE_SIGNAL_GREEN_YELLOW,MASK_TYPE_SIGNAL_MAINTAINSTATE,MASK_TYPE_SIGNAL_CLOSE_ABNORMAL,MASK_TYPE_SIGNAL_OC_BOARD_FAULT, + MASK_TYPE_SIGNAL_CANCEL_DET_ERR,MASK_TYPE_SIGNAL_DET_ERR,MASK_TYPE_SIGNAL_RELAY_DETAIN,MASK_TYPE_SIGNAL_AUTO_DERAIN,0U, + 0u }; + UINT16 BuChang = 0u; +#if 0 + funcRtn = dquGetConfigData(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_SIGNAL_MASK_ID,&pDataAddr,&DataSize); +#endif + funcRtn = dquGetConfigDataNew(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_SIGNAL_MASK_ID,&pDataAddr,&DataSize,&rowCount); + if(0u == funcRtn) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + + if(CI_SUCCESS == reVal) + { + reVal = CI_ERROR;/*ʧ*/ + if(0u < DataSize) + { + if(0u < rowCount) + { + if(0u == (DataSize % rowCount)) + { + rowLenth =(UINT8)(DataSize/rowCount); + reVal = CI_SUCCESS; + } + } + } + else + { + reVal = CI_SUCCESS; + } + } + + if(CI_SUCCESS == reVal) + { + for(;DataSize>0u;DataSize-=2u) + { + residue = (UINT16)(BuChang%(rowLenth/2u)); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + + pDataLin = pDataAddr + rowLenth - 2u;/*ʹָָCI*/ + MaskRow = ShortFromChar(pDataLin);/*ȡCI*/ + + pDataAddr+=2u; + BuChang++; + } + else if((residue > 0u ) && (residue < (rowLenth/2u -1u))) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + if((0xFFFFu == tempMaskId)||(0u == tempMaskId))/*λЧֵ*/ + { + pDataAddr+=2u; + BuChang++; + } + else if((CI_SUM_MAX > MaskRow)&&(CI_TO_ATS_MASK_SUM_MAX > tempMaskId)&&(0u ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + + pDataAddr+=2u; + BuChang++; + } + else + { + reVal = CI_ERROR;/**/ + break; + } + + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + } + + + return reVal; +} + +/********************************************* +*ܣCI-ATSλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSPsdMask(UINT8* FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, * pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow = 0u; + UINT16 DeviceID = 0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT32 realRow = 0u; + UINT8 rowLen = 0u; + +#if 1 + UINT8 MaskType[] = { 0u,MASK_TYPE_PSD_STATE_ATS,MASK_TYPE_MUTUALLOCK_STATE,MASK_TYPE_REMORA_STATE, + MASK_TYPE_PSD_PCB,MASK_TYPE_PSD_POB,MASK_TYPE_PSD_PSB,MASK_TYPE_PSD_PCB_INVALID, + MASK_TYPE_PSD_POB_INVALID,MASK_TYPE_PSD_PSB_INVALID,MASK_TYPE_PSD_JXTC_PANGLU, + MASK_TYPE_PSD_PCBPSBDPB_PANGLU_STATE,MASK_TYPE_PSD_PDB_FLASH_STATE, + MASK_TYPE_PSD_VIDEO_QK_LU,MASK_TYPE_PSD_VIDEO_QK_HONG,0U }; +#else + UINT8 MaskType[] = { 0u,MASK_TYPE_PSD_STATE_ATS,MASK_TYPE_MUTUALLOCK_STATE,MASK_TYPE_REMORA_STATE, MASK_TYPE_PSD_PCB,MASK_TYPE_PSD_POB,MASK_TYPE_PSD_PSB,MASK_TYPE_PSD_PCB_INVALID,MASK_TYPE_PSD_POB_INVALID,MASK_TYPE_PSD_PSB_INVALID,0 }; +#endif + + UINT16 BuChang = 0u; + funcRtn = dquGetConfigDataNew(FSDataName, CI_ATS_MASK_TYPE, CI_ATS_PSD_MASK_ID, &pDataAddr, &DataSize, &realRow); + rowLen = (UINT8)(DataSize / realRow); + if (funcRtn == 0u) + { + funcRtn = 0u; + return funcRtn; + } + + if (DataSize % rowLen != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if (DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for (; DataSize > 0u; DataSize -= 2u) + { + residue = BuChang % (rowLen / 2u); + if (0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + + pDataLin = pDataAddr + rowLen - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if (MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + pDataAddr += 2u; + BuChang++; + } + else if ((residue > 0u) && (residue < rowLen / 2u - 1u)) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if ((0xFFFFu != tempMaskId) && (0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_PSD; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = MaskType[BuChang % ((UINT16)rowLen / 2U)]; + + /*ͳЧλ*/ + if (ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + + pDataAddr += 2u; + BuChang++; + } + else + { + pDataAddr += 2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} + +/********************************************* +*ܣCI-ATSͣťλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSEsbMask(UINT8* FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr = NULL; + UINT8* pDataLin = NULL; + UINT32 DataSize = 0u; + UINT16 MaskRow = 0u; + UINT16 DeviceID = 0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT32 realRow = 0u; + UINT8 rowLen = 0u; + UINT16 i = 0U; + UINT8 chBreakFlag = 0U; + + UINT8 MaskType[] = { 0u, MASK_TYPE_ESP_STATE, MASK_TYPE_ESS_STEADY_STATE, MASK_TYPE_ESP_FLASH_STATE, MASK_TYPE_CANCEL_ESP_FAULT, MASK_TYPE_ESP_FAULT, 0u }; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigDataNew(FSDataName, CI_ATS_MASK_TYPE, CI_ATS_ESB_MASK_ID, &pDataAddr, &DataSize, &realRow); + rowLen = (UINT8)(DataSize / realRow); + if (funcRtn == 0u) + { + funcRtn = 0u; + return funcRtn; + } + + if (DataSize % rowLen != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if (DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for (; DataSize > 0U; DataSize -= 2u) + { + residue = BuChang % (rowLen / 2u); + if (0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + + pDataLin = pDataAddr + rowLen - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if (MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + pDataAddr += 2u; + BuChang++; + } + else if ((residue > 0u) && (residue < rowLen / 2u - 1u)) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if ((0xFFFFu != tempMaskId) && (0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_ESB; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = MaskType[BuChang % ((UINT16)rowLen / 2u)]; + + /*/ȵλǷñ־*/ + for (i = 0U; i < dquCICfgDtStr.EsbCfgDtStrLen; i++) + { + chBreakFlag = 0U; + if ((ESB_SUM_MAX > dquCICfgDtStr.EsbCfgDtStr[i].EsbId) && (dquCICfgDtStr.EsbCfgDtStr[i].EsbId == DeviceID)) + { + if (MASK_TYPE_ESS_STEADY_STATE == ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType) + { + dquCICfgDtStr.EsbCfgDtStr[i].ConfigAtsCiEssSteadyMask = ESS_MASK_YES; + chBreakFlag = 1U; + + } + else if (MASK_TYPE_ESP_FLASH_STATE == ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType) + { + dquCICfgDtStr.EsbCfgDtStr[i].ConfigAtsCiEssFlashMask = ESS_MASK_YES; + chBreakFlag = 1U; + } + else + { + /**/ + ; + } + } + if (1U == chBreakFlag) + { + break; + } + } + + /*ͳЧλ*/ + if (ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + pDataAddr += 2u; + BuChang++; + } + else + { + pDataAddr += 2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} + +/********************************************* +*ܣCI-ATS߼λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSLogSgmt(UINT8 * FSDataName) +{ + UINT8 funcRtn = CI_ERROR; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT16 rowCount = 0u; + UINT8 rowLenth = 0u;/*ֽ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_LOGICSECTION_CTOCCUPY, + MASK_TYPE_LOGICSECTION_UTOCCUPY, + MASK_TYPE_LOGICSECTION_LINSHIXIANSU_SET, + MASK_TYPE_LOGICSECTION_ROUTELOCK, + MASK_TYPE_LOGICSECTION_PROTECTLOCK, + MASK_TYPE_LOGICSECTION_FAULTLOCK, + MASK_TYPE_LOGICSECTION_JUMPLOCK, + MASK_TYPE_UPWARD_DIRECTION, + MASK_TYPE_DOWNWARD_DIRECTION, + MASK_TYPE_LOGICSECTION_ARB, + MASK_TYPE_LOGICSECTION_SPKS_FLOCK,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigDataNew(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_LOGIC_SGMT_MASK_ID,&pDataAddr,&DataSize,&rowCount); + if(0u == funcRtn) + { + funcRtn = CI_ERROR; + } + else + { + funcRtn = CI_SUCCESS; + if((0u < DataSize) && (0u < rowCount)) + { + if(0u == DataSize % rowCount) + { + /*һֽ*/ + rowLenth = (UINT8)(DataSize / rowCount); + for(;DataSize>0u;DataSize-=2u) + { + residue = (UINT16)(BuChang%((UINT16)rowLenth/2U)); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + + pDataLin = pDataAddr + rowLenth -2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX > MaskRow) + { + pDataAddr+=2u; + BuChang++; + } + else + { + funcRtn = CI_ERROR; + break; + } + + } + else if(residue < rowLenth/2u-1u) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((CI_SUM_MAX > MaskRow)&&(CI_TO_ATS_MASK_SUM_MAX > tempMaskId)&&(0u ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { +#if 0 /* TODO */ + funcRtn = CI_ERROR; + break; +#endif + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + } + else + { + funcRtn = CI_ERROR; + } + } + else + { + funcRtn = CI_SUCCESS; + } + } + return funcRtn; +/**********************************************************************/ +#if 0 + if(DataSize%CI_ATS_LOGIC_SGMT_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ATS_LOGIC_SGMT_MASK_LEN/2); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + + pDataLin = pDataAddr + CI_ATS_LOGIC_SGMT_MASK_LEN -2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + pDataAddr+=2u; + BuChang++; + } + else if((residue>0u)&&(residue < CI_ATS_LOGIC_SGMT_MASK_LEN/2-1)) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFF != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_LOGICSEC; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = MaskType[BuChang%(CI_ATS_LOGIC_SGMT_MASK_LEN/2u)]; + + + /*ͳЧλ*/ + if(ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +#endif +} +/********************************************* +*ܣCI-ATS·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSRouteMask(UINT8* FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, * pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow = 0u; + UINT16 DeviceID = 0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT16 realRowCount = 0u; /*ʵʱݵ*/ + UINT16 rowDataLen = 0u; /*һݵֽڳ*/ + + UINT8 MaskType[] = { 1u,MASK_TYPE_ROUTE_ALLLOCK, MASK_TYPE_ROUTE_XUANPAI, MASK_TYPE_ROUTE_DELAYUNLOCK, + MASK_TYPE_ROUTE_EXISTENCE, MASK_TYPE_ROUTE_NEARLOCK, MASK_TYPE_ROUTE_YINDAOLOCK, + MASK_TYPE_ROUTE_DC_QINGQIU, MASK_TYPE_ROUTE_DC_AGREE, MASK_TYPE_ROUTE_AUTO_TRIGGER, 1u }; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigDataNew(FSDataName, CI_ATS_MASK_TYPE, CI_ATS_ROUTE_MASK_ID, &pDataAddr, &DataSize, &realRowCount); + if (funcRtn == 0u) + { + funcRtn = 0u; + return funcRtn; + } + rowDataLen = (UINT16)(DataSize / realRowCount); /*һݵij*/ + if (DataSize % rowDataLen != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if (DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for (; DataSize > 0u; DataSize -= 2u) + { + residue = BuChang % (rowDataLen / 2u); + if (0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + rowDataLen - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if (MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + pDataAddr += 2u; + BuChang++; + } + else if ((residue > 0u) && (residue < ((rowDataLen / 2u) - 1u))) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if ((0xFFFFu != tempMaskId) && (0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_ROUTE; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang % (rowDataLen / 2u)]); + + + /*ͳЧλ*/ + if (ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + pDataAddr += 2u; + BuChang++; + } + else + { + pDataAddr += 2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-ATSԶ۷·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSARRtMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_AUTORETURN_STATE, 1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_AR_ROUTE_MASK_ID,&pDataAddr,&DataSize); + if(0u ==funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u !=DataSize%CI_ATS_AR_ROUTE_MASK_LEN ) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u ==DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ATS_AR_ROUTE_MASK_LEN/2u); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ATS_AR_ROUTE_MASK_LEN - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + pDataAddr+=2u; + BuChang++; + } + else if(2u > residue) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_AUTORETURN; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ATS_AR_ROUTE_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-ATSԶͨ·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSARtMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_AUTOROUTE_STATE, 1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_AUTO_ROUTE_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u != DataSize%CI_ATS_AUTO_ROUTE_MASK_LEN) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ATS_AUTO_ROUTE_MASK_LEN/2u); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ATS_AUTO_ROUTE_MASK_LEN - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + pDataAddr+=2u; + BuChang++; + } + else if (2u > residue) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_AUTOROUTE; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ATS_AUTO_ROUTE_MASK_LEN/2U)]); + + + /*ͳЧλ*/ + if(ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { + } + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-ATSλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSPhySecMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[] = { + 1u, + MASK_TYPE_PHYSECTION_STARTLOCK, +#if 0 + MASK_TYPE_PHYSECTION_ROUTELOCK_SHOW, + MASK_TYPE_PHYSECTION_PROTECTLOCK, + MASK_TYPE_PHYSECTION_FAULTLOCK, + MASK_TYPE_AXISSECTION_ARB, +#endif + + MASK_TYPE_PHYSECTION_FLOCK, +#if 0 + MASK_TYPE_PHYSECTION_JUMPLOCK, +#endif + MASK_TYPE_PHYSECTION_PRERESET, + MASK_TYPE_PHYSECTION_UT_OCC, + MASK_TYPE_PHYSEC_FLOCK_SPKS + }; + + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_PHYSEC_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u !=DataSize%CI_ATS_PHYSEC_MASK_LEN) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u ==DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + for(;DataSize>0u;DataSize-=CI_ATS_DATA_ELEMENT_LEN) + { + residue = BuChang%(CI_ATS_PHYSEC_MASK_LEN/CI_ATS_DATA_ELEMENT_LEN); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ATS_PHYSEC_MASK_LEN - CI_ATS_DATA_ELEMENT_LEN; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow ) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + pDataAddr+=CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + else if(residue < ((CI_ATS_PHYSEC_MASK_LEN/CI_ATS_DATA_ELEMENT_LEN) - 1u)) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_PHYSEC; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ATS_PHYSEC_MASK_LEN/CI_ATS_DATA_ELEMENT_LEN)]); + + + /*ͳЧλ*/ + if(ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { + } + + pDataAddr+=CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + else + { + pDataAddr+=CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-ATS SPKS״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSSPKSMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={0u,MASK_TYPE_SPKS_OPENSTATE,MASK_TYPE_SPKS_ISOLATE_BUTTON_STATE,0u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_SPKS_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u != DataSize%CI_ATS_SPKS_MASK_LEN ) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ATS_SPKS_MASK_LEN/2u); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ATS_SPKS_MASK_LEN - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow ) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + pDataAddr+=2u; + BuChang++; + } + else if (3u > residue) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_SPKS; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ATS_SPKS_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { + } + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-ATS ϴ״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSWashM(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={0u,MASK_TYPE_WASHMACHINE_READYSTATE,MASK_TYPE_WASHMACHINE_WORKMODE,0u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_WASHMACHINE_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u != DataSize%CI_ATS_WASHMACHINE_MASK_LEN ) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ATS_WASHMACHINE_MASK_LEN/2u); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ATS_WASHMACHINE_MASK_LEN - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + pDataAddr+=2u; + BuChang++; + } + else if(3u >residue) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_WASHMACHINE; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ATS_WASHMACHINE_MASK_LEN/2U)]); + + + /*ͳЧλ*/ + if(ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { + } + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} + +/********************************************* +*ܣCI-ATS ״̬λ +*˵FSDataNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSFloodGate(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr = NULL; + UINT8* pDataLin = NULL; + UINT16 index =0u; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[] = { + 0u, + MASK_TYPE_FD_OPENLOCK_TO_ATS, /*״̬*/ + MASK_TYPE_FLOODGATE_CLOSEAPLAY_STATE, /*״̬*/ + MASK_TYPE_FLOODGATE_AGREECLOSE_TOATS, /*ͬر״̬*/ + 0u + }; + UINT16 BuChang = 0u; + + if (NULL == FSDataName) + { + funcRtn = 0u; + } + + else + { + funcRtn = 1u; + } + if (1u == funcRtn) + { + funcRtn = dquGetConfigData((CHAR*)FSDataName,CI_ATS_MASK_TYPE,CI_ATS_FLOODGATE_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + } + else + { + funcRtn = 1u; + } + } + else + { + } + + if (1u == funcRtn) + { + if((DataSize%CI_ATS_FLOODGATE_MASK_LEN) != 0u) + { + funcRtn = 0u; + } + else + { + } + } + else + { + } + + if (1u == funcRtn) + { + for(;DataSize>0u;DataSize-=CI_ATS_DATA_ELEMENT_LEN) + { + residue = BuChang%(CI_ATS_FLOODGATE_MASK_LEN/CI_ATS_DATA_ELEMENT_LEN); + if(0u == residue) + { + DeviceID = ShortFromChar((UINT8*)(&pDataAddr[index])); + /*pDataLin = pDataAddr + (CI_ATS_FLOODGATE_MASK_LEN - CI_ATS_DATA_ELEMENT_LEN);*/ + pDataLin = (UINT8*)(&pDataAddr[index + (CI_ATS_FLOODGATE_MASK_LEN - CI_ATS_DATA_ELEMENT_LEN)]); + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow ) + { + funcRtn = 0u; + break; + } + else + { + } + + /*pDataAddr+=CI_ATS_DATA_ELEMENT_LEN;*/ + index+=(UINT16)CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + else if (residue < (UINT16)((UINT16)(CI_ATS_FLOODGATE_MASK_LEN/2u) - 1u)) + { + /*ȡλID*/ + tempMaskId = ShortFromChar((UINT8*)(&pDataAddr[index])); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + if ((MaskRow < CI_SUM_MAX) &&(tempMaskId ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { + } + } + else + { + } + /*pDataAddr+=CI_ATS_DATA_ELEMENT_LEN;*/ + index+=(UINT16)CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + else + { + /*pDataAddr+=CI_ATS_DATA_ELEMENT_LEN;*/ + index+=(UINT16)CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + } + } + + return funcRtn; +} + +/********************************************* +*ܣCI-ATS ״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSGarageDoor(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[] = { + 0u, + MASK_TYPE_GARAGEDOOR_OPEN_STATE, + MASK_TYPE_GARAGEDOOR_CLOSE_STATE, + MASK_TYPE_GARAGEDOOR_MODE_STATE, + MASK_TYPE_GARAGEDOOR_FAULT_STATE, + MASK_TYPE_GARAGEDOOR_PANGLU_STATE, + 0u}; + + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_GARAGEDOOR_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u != DataSize%CI_ATS_GARAGEDOOR_MASK_LEN) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + + for(;DataSize>0u;DataSize-=CI_ATS_DATA_ELEMENT_LEN) + { + residue = BuChang%(CI_ATS_GARAGEDOOR_MASK_LEN/CI_ATS_DATA_ELEMENT_LEN); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ATS_GARAGEDOOR_MASK_LEN - CI_ATS_DATA_ELEMENT_LEN; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + pDataAddr+=CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + else if (residue < ((CI_ATS_GARAGEDOOR_MASK_LEN/2u) - 1u)) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_GARAGEDOOR; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ATS_GARAGEDOOR_MASK_LEN/CI_ATS_DATA_ELEMENT_LEN)]); + + + /*ͳЧλ*/ + if(ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + else + { + } + pDataAddr+=CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + else + { + pDataAddr+=CI_ATS_DATA_ELEMENT_LEN; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/***** +******CIATSλ +********/ + +/***** +******CIZCλ +********/ +/********************************************* +*ܣCI-ZCλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCSwitchMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_SWITCH_DINGWEI_LOGIC,MASK_TYPE_SWITCH_FANWEI_LOGIC,MASK_TYPE_SWITCH_LOCKSTATE,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_SWITCH_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u != DataSize%CI_ZC_SWITCH_MASK_LEN ) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u == DataSize ) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + for(;DataSize>0u;DataSize-=2u) + { + BuChang = BuChang%(CI_ZC_SWITCH_MASK_LEN/2u); + if(0u == BuChang) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_SWITCH_MASK_LEN -2u; + MaskRow = ShortFromChar(pDataLin); + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + } + + /* ID */ + else if (BuChang < ((CI_ZC_SWITCH_MASK_LEN/2u)-1u)) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_SWITCH; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_SWITCH_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + else + { + } + } + else + { + /* ȡID:˶δΪʱʹ */ + UINT16 tmpCiId = ShortFromChar(pDataAddr); + if (MaskRow != tmpCiId) + { + /* IDôʱش */ + } + } + pDataAddr+=2u; + BuChang++; + } + funcRtn = 1u; + return funcRtn; +} +/* zt ɾش 2022-02-15 */ +/********************************************* +*ܣCI-ZCźŻλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCSignalMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[] = { 1u,MASK_TYPE_SIGNAL_OPENSTATE,MASK_ZC_CI_TYPE_SIGNAL_OCCUPYED,MASK_TYPE_SIGNAL_LIGHTSTATE,MASK_ZC_CI_SIG_ENGINEERV_NEAR,MASK_CI_ZC_SIG_ENGINCROSS_STE,MASK_CI_ZC_SIGNAL_OCCUPYED_REC,1u }; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_SIGNAL_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_ZC_SIGNAL_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + if(BuChang%(CI_ZC_SIGNAL_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_SIGNAL_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + } + /*34 zc-ci λ ,ID,ȱ֤ */ + else if ((1u != (BuChang % (CI_ZC_SIGNAL_MASK_LEN / 2u))) + && (5u != (BuChang % (CI_ZC_SIGNAL_MASK_LEN / 2u))) + && (6u != (BuChang % (CI_ZC_SIGNAL_MASK_LEN / 2u)))) + { + pDataAddr += 2u; + BuChang++; + } + else + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_SIGNAL; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_SIGNAL_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣZC-CIźŻλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmZCCISignalMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 ii =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + SignalConfigDataStruct *pSignalCconfigData = NULL; + + UINT8 MaskType[] = { 1u,MASK_TYPE_SIGNAL_OPENSTATE,MASK_ZC_CI_TYPE_SIGNAL_OCCUPYED,MASK_TYPE_SIGNAL_LIGHTSTATE,MASK_ZC_CI_SIG_ENGINEERV_NEAR,MASK_CI_ZC_SIG_ENGINCROSS_STE,MASK_CI_ZC_SIGNAL_OCCUPYED_REC,1u }; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_SIGNAL_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_ZC_SIGNAL_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + if(BuChang%(CI_ZC_SIGNAL_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_SIGNAL_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + } + /*ڶ ci-zc λ ,ID */ + else if ((1u == (BuChang % (CI_ZC_SIGNAL_MASK_LEN / 2U))) || (5u == BuChang % (CI_ZC_SIGNAL_MASK_LEN / 2U)) || (6u == BuChang % (CI_ZC_SIGNAL_MASK_LEN / 2U)) || (7u == BuChang % (CI_ZC_SIGNAL_MASK_LEN / 2U))) + { + pDataAddr += 2u; + BuChang++; + } + /*вzc-ciλ*/ + else + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + pSignalCconfigData = NULL; + + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_SIGNAL; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_SIGNAL_MASK_LEN/2u)]); + + for(ii=0u;iiConfigZcCiSignalCrossMask = SIGNAL_CONFIG_CROSS_MASK_YES; + break; + } + + } + } + + /*ͳЧλ*/ + if(ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigZcToCiMaskIdMax[MaskRow]) + { + ConfigZcToCiMaskIdMax[MaskRow] = ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigZcToCiMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + } + + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-ZCλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCPsdMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_PSD_STATE,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_PSD_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_ZC_PSD_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0U;DataSize-=2u) + { + if(BuChang%(CI_ZC_PSD_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_PSD_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + } + else if(BuChang%(CI_ZC_PSD_MASK_LEN/2u) == 1u) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_PSD; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_PSD_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + else + { + /* ID */ + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} + +/********************************************* +*ܣCI-ZCͣťλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCEsbMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_ESP_STATE,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_ESB_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_ZC_ESB_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0U;DataSize-=2u) + { + if(BuChang%(CI_ZC_ESB_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_ESB_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + } + else if(BuChang%(CI_ZC_ESB_MASK_LEN/2u) == 1u) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_ESB; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_ESB_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} + +/********************************************* +*ܣCI-ZC߼λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCI2ZCLogSgmt(UINT8 * FSDataName) +{ + UINT8 funcRtn = 1u; + UINT8* pDataAddr,*pDataLin; + UINT32 dataSize = 0u; + UINT16 i =0u; + UINT16 maskRow=0u; + UINT16 deviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + const UINT8 MaskType[]={1u,MASK_TYPE_LOGICSECTION_CTOCCUPY,MASK_TYPE_LOGICSECTION_UTOCCUPY,MASK_TYPE_LOGICSECTION_TXOCCUPY,MASK_TYPE_LOGICSECTION_LINSHIXIANSU_SET, + MASK_TYPE_LOGICSECTION_LOCK,MASK_TYPE_LOGICSECTION_DIR_UP,MASK_TYPE_LOGICSECTION_DIR_DOWN,1u}; + UINT16 buChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_LOGIC_SGMT_MASK_ID,&pDataAddr,&dataSize); + if (funcRtn == 1u) + { + if(dataSize > 0u) + { + if(dataSize%CI_ZC_LOGIC_SGMT_MASK_LEN != 0u) + { + funcRtn = 0u; /* һݵı˵ݲ߲һ */ + } + } + else + { + funcRtn = 1u; /* */ + } + + } + else + { + funcRtn = 0u; /* ʧ */ + } + + if ((funcRtn ==1u) && (dataSize > 0u)) + { + for(;dataSize>0u;dataSize-=2u) + { + buChang = buChang%(CI_ZC_LOGIC_SGMT_MASK_LEN/2u); + if(buChang == 0u) + { + deviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_LOGIC_SGMT_MASK_LEN -2u; + maskRow = ShortFromChar(pDataLin); + + if (maskRow >= CI_SUM_MAX) + { /* ʧ*/ + funcRtn = 0u; + break; + } + } + else if( (4u ConfigCiToZcMaskIdMax[maskRow]) + { + ConfigCiToZcMaskIdMax[maskRow] = ConfigCiToZcMaskConfigDataStru[maskRow][tempMaskId].MaskId; + } + ConfigCiToZcMaskCurSum[maskRow]++; + } + } + else + { + /* ԼϢ */ + } + pDataAddr+=2u; + buChang++; + } + } + + return funcRtn; +} + +/********************************************* +*ܣZC-CI߼λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmZCCILogSgmtMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_LOGICSECTION_CTOCCUPY,MASK_TYPE_LOGICSECTION_UTOCCUPY,MASK_TYPE_LOGICSECTION_TXOCCUPY,MASK_TYPE_LOGICSECTION_LINSHIXIANSU_SET, + MASK_TYPE_LOGICSECTION_LOCK,MASK_TYPE_LOGICSECTION_DIR_UP,MASK_TYPE_LOGICSECTION_DIR_DOWN,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_LOGIC_SGMT_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u != DataSize%CI_ZC_LOGIC_SGMT_MASK_LEN) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + for(;DataSize>0u;DataSize-=2u) + { + BuChang = BuChang%(CI_ZC_LOGIC_SGMT_MASK_LEN/2u); + if(0u == BuChang) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_LOGIC_SGMT_MASK_LEN -2u; + MaskRow = ShortFromChar(pDataLin); + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + } + + else if (5u > BuChang ) + { /* ZCCIλ 1,2,3*/ + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_LOGICSEC; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_LOGIC_SGMT_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigZcToCiMaskIdMax[MaskRow]) + { + ConfigZcToCiMaskIdMax[MaskRow] = ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigZcToCiMaskCurSum[MaskRow]++; + } + else + { + } + } + else + { + /* */ + } + pDataAddr+=2u; + BuChang++; + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣZC-CI ·λ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmZC2CiRouteMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 1u; + UINT8* pDataAddr,*pDataLin; + UINT32 dataSize = 0u; + UINT16 i =0u; + UINT16 maskRow=0u; + UINT16 deviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + const UINT8 MaskType[]={1u,MASK_TYPE_ROUTE_LOCKSTATE,MASK_TYPE_ROUTE_STOPE_APPLY,MASK_TYPE_ROUTE_STOPENABLEE_STATUS,1u}; + UINT16 buChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_ROUTE_MASK_ID,&pDataAddr,&dataSize); + if(funcRtn== 1u) + { + if (dataSize > 0u) + { + if(dataSize%CI_ZC_ROUTE_MASK_LEN != 0u) + { /* ݲһΪݴ */ + funcRtn = 0u; + dataSize = 0u; + } + } + else + { + /**/ + funcRtn = 1u; + } + } + else + { + funcRtn = 0u; + dataSize = 0u; + } + + for(;dataSize>0u;dataSize-=2u) + { + buChang = buChang%(CI_ZC_ROUTE_MASK_LEN/2u); + if(buChang == 0u) + { + deviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_ROUTE_MASK_LEN -2u; + maskRow = ShortFromChar(pDataLin); + /*鲻Խ磬Խֱӷʧ*/ + if(maskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + break; + } + + } + else if(buChang == 3u) + {/* 3 */ + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0U != tempMaskId)) + { + ConfigZcToCiMaskConfigDataStru[maskRow][tempMaskId].DeviceId = deviceID; + ConfigZcToCiMaskConfigDataStru[maskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_ROUTE; + ConfigZcToCiMaskConfigDataStru[maskRow][tempMaskId].MaskId = tempMaskId; + ConfigZcToCiMaskConfigDataStru[maskRow][tempMaskId].MaskType = MaskType[buChang]; + + + /*ͳЧλ*/ + if(ConfigZcToCiMaskConfigDataStru[maskRow][tempMaskId].MaskId > ConfigZcToCiMaskIdMax[maskRow]) + { + ConfigZcToCiMaskIdMax[maskRow] = ConfigZcToCiMaskConfigDataStru[maskRow][tempMaskId].MaskId; + } + + ConfigZcToCiMaskCurSum[maskRow]++; + } + } + else + { + /* λ */ + } + pDataAddr+=2u; + buChang++; + } + + return funcRtn; +} +/********************************************* +*ܣCI-ZC·λ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCRouteMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_ROUTE_LOCKSTATE,MASK_TYPE_ROUTE_STOPE_APPLY,MASK_TYPE_ROUTE_STOPENABLEE_STATUS,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_ROUTE_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u != DataSize%CI_ZC_ROUTE_MASK_LEN) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + for(;DataSize>0u;DataSize-=2u) + { + BuChang = BuChang%(CI_ZC_ROUTE_MASK_LEN/2u); + if(0u == BuChang) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_ROUTE_MASK_LEN -2u; + MaskRow = ShortFromChar(pDataLin); + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + } + else if (3u > BuChang) + {/* 1,2 */ + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_ROUTE; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = MaskType[BuChang]; + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + else + { + } + } + else + { + /* ID */ + } + pDataAddr+=2u; + BuChang++; + } + funcRtn = 1u; + return funcRtn; +} + +/********************************************* +*ܣCI-ZCλ Σ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCAxleSgmtMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 wPhysicId = 0u; + UINT16 axleId = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_PHYSECTION_HEAD_STD,MASK_TYPE_PHYSECTION_HEAD_XTD,MASK_TYPE_PHYSECTION_OCCUPY, + MASK_TYPE_PHYSECTION_ROUTELOCK,MASK_TYPE_PHYSECTION_JUMPLOCK_ZC,MASK_TYPE_AXISSECTION_ARB,MASK_TYPE_LIECHE_STOPSTATE, + MASK_TYPE_PHYSECTION_HEAD_STD,MASK_TYPE_PHYSECTION_HEAD_XTD,MASK_TYPE_PHYSECTION_JUMPLOCK_APPLY, + MASK_TYPE_PHYSECTION_JUMPLOCK_CANCEL,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_AXLE_SGMT_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_ZC_AXLE_SGMT_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ZC_AXLE_SGMT_MASK_LEN/2u); + + if(BuChang%(CI_ZC_AXLE_SGMT_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + axleId = DeviceID; + pDataLin = pDataAddr + CI_ZC_AXLE_SGMT_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + for(i=0u;i ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} + +/********************************************* +*ܣZC-CIλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmZCCIAxleSgmtMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT16 wPhysicId = 0u; + UINT8 MaskType[]={1u,MASK_TYPE_PHYSECTION_HEAD_STD,MASK_TYPE_PHYSECTION_HEAD_XTD,MASK_TYPE_PHYSECTION_OCCUPY, + MASK_TYPE_PHYSECTION_ROUTELOCK,MASK_TYPE_PHYSECTION_JUMPLOCK_ZC,MASK_TYPE_AXISSECTION_ARB,MASK_TYPE_LIECHE_STOPSTATE, + MASK_TYPE_PHYSECTION_HEAD_STD,MASK_TYPE_PHYSECTION_HEAD_XTD,MASK_TYPE_PHYSECTION_JUMPLOCK_APPLY, + MASK_TYPE_PHYSECTION_JUMPLOCK_CANCEL,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_AXLE_SGMT_MASK_ID,&pDataAddr,&DataSize); + if(0U == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_ZC_AXLE_SGMT_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ZC_AXLE_SGMT_MASK_LEN/2u); + + if(residue == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_AXLE_SGMT_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + for(i=0u;i ConfigZcToCiMaskIdMax[MaskRow]) + { + ConfigZcToCiMaskIdMax[MaskRow] = ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigZcToCiMaskCurSum[MaskRow]++; + } + pDataAddr+=2u; + BuChang++; + } + else + { + /* */ + pDataAddr+=2u; + BuChang++; + } + } + + funcRtn = 1u; + return funcRtn; + +} + + +/********************************************* +*ܣCI-ZCλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCOverLapMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_OVERLAP_LOCKSTATE,MASK_TYPE_OVERLAP_UNLOCK_APPLY,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_OVER_LAP_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + + if(0u != DataSize%CI_ZC_OVER_LAP_MASK_LEN) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + else + { + } + for(;DataSize>0u;DataSize-=2u) + { + BuChang = BuChang%(CI_ZC_OVER_LAP_MASK_LEN/2u); + if(0u == BuChang) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_OVER_LAP_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + else + { + } + } + else if (3u > BuChang) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_OVERLAP; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_OVER_LAP_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + else + { + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-ZC۷λ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCReturnMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 j=0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_PLAT_AUTORETURNSIG_FLASH,MASK_TYPE_PLAT_AUTORETURNSIG_STEADY,MASK_TYPE_PLAT_AUTORETURNSIG_BUTTONSTAT,1u}; + UINT16 BuChang = 0u; + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + UINT8 findFlag = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_RETURN_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_ZC_RETURN_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ZC_RETURN_MASK_LEN/2u); + + if(residue == 0u) + { + pDataLin = pDataAddr; /*pDataLin*/ + DeviceID = ShortFromChar(pDataLin); + pDataLin = pDataAddr + CI_ZC_RETURN_MASK_LEN -2u; + MaskRow = ShortFromChar(pDataLin); + BuChang++; + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + findFlag = 0u;/*ʼҵ־*/ + for(i=0u;i ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + + } + } + funcRtn = 1u; + return funcRtn; +} + +/********************************* ************ +*ܣZC-CI۷λ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmZCCIRtnMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 j = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT8 findFlag = 0u; + + UINT8 MaskType[]={1u,MASK_TYPE_PLAT_AUTORETURNSIG_FLASH,MASK_TYPE_PLAT_AUTORETURNSIG_STEADY,MASK_TYPE_PLAT_AUTORETURNSIG_BUTTONSTAT,1u}; + UINT16 BuChang = 0u; + UINT8 includeVirFlag= GetCiFunctionSwitchConfig(FUNC_INCLUDEVIRCI_FLAG); + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_RETURN_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_ZC_RETURN_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ZC_RETURN_MASK_LEN/2u); + + if(residue == 0u) + { + pDataLin = pDataAddr; /*pDataLin*/ + DeviceID = ShortFromChar(pDataLin); + pDataLin = pDataAddr + CI_ZC_RETURN_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + findFlag = 0u; + for(i=0u;i= 3u) && (residue <(CI_ZC_RETURN_MASK_LEN/2u))) + { + pDataAddr+=2u; + BuChang++; + } + else + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_PLATFORM; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_RETURN_MASK_LEN/2u)]); + + /*ͳЧλ*/ + if(ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigZcToCiMaskIdMax[MaskRow]) + { + ConfigZcToCiMaskIdMax[MaskRow] = ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigZcToCiMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + + } + } + funcRtn = 1u; + return funcRtn; +} + +/********************************************* +*ܣZC-CI·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCComeGoMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0; + + UINT16 MaskRow = 0xff; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT8 MaskType[]={1u, MASK_TYPE_ROUTE_LOCKSTATE,1u}; + UINT16 BuChang = 0u; + + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_COMEGO_MASK_ID,&pDataAddr,&DataSize); + + if(0u == funcRtn) + { + return funcRtn; + } + + if(0u != DataSize%CI_ZC_COMEGO_ROUTE_MASK_LEN) + { + funcRtn = 0u; + return funcRtn; + } + + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + + for(;DataSize>0u;DataSize-=2u) + { + if(0u == BuChang%(CI_ZC_COMEGO_ROUTE_MASK_LEN/2u)) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_COMEGO_ROUTE_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + + /*鲻Խ磬Խֱӷʧ*/ + if((MaskRow >= CI_SUM_MAX) ||(DeviceID > COMEGOINDEXNUM)) + { + funcRtn = 0u; + return funcRtn; + } + + } + else if ((BuChang%(CI_ZC_COMEGO_ROUTE_MASK_LEN/2u)) == 1u ) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_ROUTE; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_COMEGO_ROUTE_MASK_LEN/2u)]); + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + pDataAddr += 2u; + BuChang++; + } + else + { + pDataAddr += 2u; + BuChang++; + } + } + + funcRtn = 1u; + return funcRtn; +} + +/***** +****** +********/ +/********************************************* +*ܣCILEUλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCILEUSwitchMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,1u,MASK_TYPE_SWITCH_DINGWEI_LOGIC,MASK_TYPE_SWITCH_FANWEI_LOGIC}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_LEU_MASK_TYPE,CI_LEU_SWITCH_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_LEU_SWITCH_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + if(BuChang%(CI_LEU_SWITCH_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataAddr+=2u; + BuChang++; + + #if 1 + MaskRow = ShortFromChar(pDataAddr); + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + #else + for(i=0;i= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + /*ҵӦCI_ID˳forѭ*/ + break; + } + } + #endif + } + else if(1u == BuChang%(CI_LEU_SWITCH_MASK_LEN/2u)) + { + pDataAddr+=2u; + BuChang++; + } + else + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_SWITCH; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_LEU_SWITCH_MASK_LEN/2u)]); + + /*ͳЧλ*/ + if(ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToLeuMaskIdMax[MaskRow]) + { + ConfigCiToLeuMaskIdMax[MaskRow] = ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToLeuMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} + +/* zt ɾش 2022-02-15 */ + +/********************************************* +*ܣCI-LEUλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCILEUPsdMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,1u,MASK_TYPE_PSD_STATE}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_LEU_MASK_TYPE,CI_LEU_PSD_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if(DataSize%CI_LEU_PSD_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + if(BuChang%(CI_LEU_PSD_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataAddr+=2u; + BuChang++; + MaskRow = ShortFromChar(pDataAddr); + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + } + else if(BuChang%(CI_LEU_PSD_MASK_LEN/2u) == 2u) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_PSD; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_LEU_PSD_MASK_LEN/2u)]); + + /*ͳЧλ*/ + if(ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToLeuMaskIdMax[MaskRow]) + { + ConfigCiToLeuMaskIdMax[MaskRow] = ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToLeuMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-LEU·λ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCILEURouteMask(UINT8 * FSDataName) + +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,MASK_TYPE_ROUTE_SIGNAL_STATE,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_LEU_MASK_TYPE,CI_LEU_ROUTE_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + return funcRtn; + } + + if((DataSize%CI_LEU_ROUTE_MASK_LEN) != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + if(BuChang%(CI_LEU_ROUTE_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_LEU_ROUTE_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + } + else if((BuChang%(CI_LEU_ROUTE_MASK_LEN/2u)) == 1u) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_ROUTE; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_LEU_ROUTE_MASK_LEN/2u)]); + + /*ͳЧλ*/ + if(ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToLeuMaskIdMax[MaskRow]) + { + ConfigCiToLeuMaskIdMax[MaskRow] = ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToLeuMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} +/********************************************* +*ܣCI-LEUλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCILEUOverLapMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,1u,MASK_TYPE_OVERLAP_LOCKSTATE}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_LEU_MASK_TYPE,CI_LEU_OVER_LAP_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + return funcRtn; + } + + if(DataSize%CI_LEU_OVER_LAP_MASK_LEN != 0u) + { + funcRtn = 0u; + return funcRtn; + } + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + return funcRtn; + } + for(;DataSize>0u;DataSize-=2u) + { + if(BuChang%(CI_LEU_OVER_LAP_MASK_LEN/2u) == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataAddr+=2u; + BuChang++; + +#if 1 + MaskRow = ShortFromChar(pDataAddr); + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + +#else + for(i=0u;i= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + /*ҵӦCI_ID˳forѭ*/ + break; + } + } +#endif + } + else if(1u == BuChang%(CI_LEU_OVER_LAP_MASK_LEN/2u)) + { + pDataAddr+=2u; + BuChang++; + } + else + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_OVERLAP; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_LEU_OVER_LAP_MASK_LEN/2u)]); + + /*ͳЧλ*/ + if(ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToLeuMaskIdMax[MaskRow]) + { + ConfigCiToLeuMaskIdMax[MaskRow] = ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToLeuMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + } + funcRtn = 1u; + return funcRtn; +} + + +/********************************************* +*ܣCI-LEUźŻλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCILEUSignalMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={1u,1u,MASK_TYPE_SIGNAL_LINSHIXIANSU_SET}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_LEU_MASK_TYPE,CI_LEU_SIGNAL_MASK_ID,&pDataAddr,&DataSize); + if(0u != funcRtn) + { + if(0u == (DataSize % CI_LEU_SIGNAL_MASK_LEN)) + { + if(0u != DataSize) + { + for(;DataSize > 0u;DataSize -= 2u) + { + if(0u == BuChang%(CI_LEU_SIGNAL_MASK_LEN/2u)) + { + DeviceID = ShortFromChar(pDataAddr); + pDataAddr+=2u; + BuChang++; + + + } + else if(1u == BuChang%(CI_LEU_SIGNAL_MASK_LEN/2u)) + { + #if 1 + MaskRow = ShortFromChar(pDataAddr); + pDataAddr+=2u; + BuChang++; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + break; + } + + #else + for(i=0u;i= CI_SUM_MAX) + { + funcRtn = 0u; + return funcRtn; + } + + /*ҵӦCI_ID˳forѭ*/ + break; + } + } + DataSize += 2u; + #endif + } + else + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_SIGNAL; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_LEU_SIGNAL_MASK_LEN/2u)]); + + /*ͳЧλ*/ + if(ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToLeuMaskIdMax[MaskRow]) + { + ConfigCiToLeuMaskIdMax[MaskRow] = ConfigCiToLeuMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToLeuMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + } + if(DataSize <= 0u) + { + funcRtn = 1u; + } + else + { + funcRtn = 0u; + } + } + else + { + /**/ + funcRtn = 1u; + } + } + else + { + /*ݳȲ*/ + funcRtn = 0u; + } + } + else + { + funcRtn = 0u; + } + + return funcRtn; +} + +/********************************************* +*ܣʼλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskInit(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8 ciPattern = 0U; + UINT16 i = 0U; + /***** + ******CIATSλ + ********/ + /*CI-ATSλ*/ + funcRtn = MaskCfgDtStruFrmCIATSSwitchMask(FSDataName); + /*CI-ATSźŻλ*/ + funcRtn *= MaskCfgDtStruFrmCIATSSignalMask(FSDataName); + /*CI-ATSλ*/ + funcRtn *= MaskCfgDtStruFrmCIATSPsdMask( FSDataName); + /*CI-ATSͣťλ*/ + funcRtn *= MaskCfgDtStruFrmCIATSEsbMask( FSDataName); + /*CI-ATS߼λ*/ + funcRtn *= MaskCfgDtStruFrmCIATSLogSgmt( FSDataName); + /*CI-ATS·λ*/ + funcRtn *= MaskCfgDtStruFrmCIATSRouteMask( FSDataName); + /*ci-atsԶ۷λ*/ + funcRtn *= MaskCfgDtStruFrmCIATSARRtMask(FSDataName); + /*CI-ATSλ*/ + funcRtn *= MaskCfgDtStruFrmCIATSPhySecMask( FSDataName); + /*CI-ATSԶͨ·λ*/ + funcRtn *= MaskCfgDtStruFrmCIATSARtMask(FSDataName); + /*ci-atsȫԶ۷λ*/ + funcRtn *= MaskCfgDtStruFrmCIATSAARRtMask(FSDataName); + + /*CI-ATS SPKSλ*/ + funcRtn *= MaskCfgDtStruFrmCIATSSPKSMask(FSDataName); + + /*CI-ATS ϴλ*/ + funcRtn *= MaskCfgDtStruFrmCIATSWashM(FSDataName); + + /*CI-ATS λ*/ + funcRtn *= MaskCfgDtStruFrmCIATSGarageDoor(FSDataName); + + /*CI-ATS λ*/ + funcRtn *= MaskCfgDtStruFrmCIATSFloodGate(FSDataName); + + /* zt ɾش 2022-02-15 */ + + /***** + ******CIATSλ + ********/ + + + /***** + ******CIZCλ ɾ + ********/ + ciPattern = GetLocalRcWorkMode(); + if(RC_WORK_MODE_CI == ciPattern) + { + /*CI-ZCλ*/ + funcRtn *= MaskCfgDtStruFrmCIZCSwitchMask( FSDataName); + /* zt ɾش 2022-02-15 */ + /*CI-ZCźŻλ*/ + funcRtn *= MaskCfgDtStruFrmCIZCSignalMask( FSDataName); + /*CI-ZCλ*/ + funcRtn *= MaskCfgDtStruFrmCIZCPsdMask( FSDataName); + /*CI-ZCͣťλ*/ + funcRtn *= MaskCfgDtStruFrmCIZCEsbMask( FSDataName); + /*CI-ZC߼λ*/ + funcRtn *= MaskCfgStruFrmZCCILogSgmtMask( FSDataName); + /*ZC-CI߼λ*/ + funcRtn *= MaskCfgDtStruFrmCI2ZCLogSgmt(FSDataName); + /*CI-ZC·λ*/ + funcRtn *= MaskCfgStruFrmCIZCRouteMask( FSDataName); + funcRtn *= MaskCfgDtStruFrmZC2CiRouteMask(FSDataName); + /*CI-ZCλ*/ + funcRtn *= MaskCfgStruFrmCIZCAxleSgmtMask( FSDataName); + /*CI-ZCλ*/ + funcRtn *= MaskCfgStruFrmCIZCOverLapMask( FSDataName); + /*CI-ZC۷λ*/ + funcRtn *= MaskCfgStruFrmCIZCReturnMask( FSDataName); + /*ZC-CIźŻλ*/ + funcRtn *= MaskCfgDtStruFrmZCCISignalMask(FSDataName); + /*ZC-CIλ*/ + funcRtn *= MaskCfgStruFrmZCCIAxleSgmtMask( FSDataName); + /*ZC-CI۷λ*/ + funcRtn *= MaskCfgStruFrmZCCIRtnMask(FSDataName); + /*CI_ZC·λ*/ + funcRtn *= MaskCfgStruFrmCIZCComeGoMask(FSDataName); + /*CI-ZCλ*/ + funcRtn *= MaskCfgStruFrmCIZCGaragedoor( FSDataName); + /*ZC-CIλ*/ + funcRtn *= MaskCfgStruFrmZCCIGaragedoor( FSDataName); + /*CI-ZC SPKSλ*/ + funcRtn *= MaskCfgDtStruFrmCIZCSPKSMask(FSDataName); + /*CI-ZC ״̬λ*/ + funcRtn *= MaskCfgStruFrmCIZCFloodGateMask(FSDataName); + /***** + ******CIZCλ + ********/ + + + } + + /***** + ******CILEUλ + ********/ + /*CI-LEUλ*/ + funcRtn *= MaskCfgStruFrmCILEUSwitchMask(FSDataName); + /* zt ɾش 2022-02-15 */ + /*CI-LEUλ*/ + funcRtn *= MaskCfgDtStruFrmCILEUPsdMask(FSDataName); + /*CI-LEU·λ*/ + funcRtn *= MaskCfgDtStruFrmCILEURouteMask(FSDataName); + /*CI-LEUλ*/ + funcRtn *= MaskCfgStruFrmCILEUOverLapMask(FSDataName); + /*CI-LEUźŻλ*/ + funcRtn *= MaskCfgStruFrmCILEUSignalMask(FSDataName); + /*λֵ*/ + for ( i = 0U; i < CI_SUM_MAX; i++) + { + if (CI_TO_LEU_MASK_SUM_MAX <= ConfigCiToLeuMaskIdMax[i]) + { + funcRtn = CI_ERROR; + debug_infor_printf((const)"CI TO LEU Mask Is Exceed MAX\n"); + } + else if (CI_TO_ZC_MASK_SUM_MAX <= ConfigCiToZcMaskIdMax[i]) + { + funcRtn = CI_ERROR; + debug_infor_printf((const)"CI TO ZC Mask Is Exceed MAX\n"); + } + else if (CI_TO_ATS_MASK_SUM_MAX <= ConfigCiToAtsMaskIdMax[i]) + { + funcRtn = CI_ERROR; + debug_infor_printf((const)"CI TO ATS Mask Is Exceed MAX\n"); + } + else if (ZC_TO_CI_MASK_SUM_MAX <= ConfigZcToCiMaskIdMax[i]) + { + funcRtn = CI_ERROR; + debug_infor_printf((const)"ZC TO CI Mask Is Exceed MAX\n"); + } + else + { + /*λֵͨ*/ + } + } + + + return funcRtn; +} +/********************************************* +*ܣCI-ATSȫԶ۷·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSAARRtMask(UINT8 *FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8 *pDataAddr = NULL, *pDataLin = NULL; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={0u,MASK_TYPE_ALLAUTORETURN_STATE, 0u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ATS_MASK_TYPE,CI_ATS_AAR_ROUTE_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + } + else + { + if(DataSize%CI_ATS_AAR_ROUTE_MASK_LEN != 0u) + { + funcRtn = 0u; + } + else + { + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + } + else + { + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ATS_AAR_ROUTE_MASK_LEN/2u); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ATS_AAR_ROUTE_MASK_LEN - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + break; + } + + pDataAddr+=2u; + BuChang++; + } + else if((residue>0u) && (residue<2u)) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_ALLAUTORETURN; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ATS_AAR_ROUTE_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToAtsMaskIdMax[MaskRow]) + { + ConfigCiToAtsMaskIdMax[MaskRow] = ConfigCiToAtsMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToAtsMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + funcRtn = 1u; + } + } + } + } + + return funcRtn; +} + + +/********************************************* +*ܣCI-ZCλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCGaragedoor(UINT8 * FSDataName) +{ + UINT8 funcRtn = 1u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT16 residue = 0u; + + UINT8 MaskType[]={1u,MASK_TYPE_GARAGEDOOR_STATE,MASK_TYPE_GARAGEDOOR_APPLYCLOSE_STATE,MASK_TYPE_GARAGEDOOR_ALLOWCLOSE_STATE,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_GARAGE_DOOR_MASK_ID,&pDataAddr,&DataSize); + if(0u == funcRtn) + { + funcRtn = 0u; + } + else + { + if(0u != DataSize%CI_ZC_GARAGE_DOOR_MASK_LEN) + { + funcRtn = 0u; + } + else + { + if(0u == DataSize) + { + /**/ + funcRtn = 1u; + } + else + { + } + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ZC_GARAGE_DOOR_MASK_LEN/2u); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_GARAGE_DOOR_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(CI_SUM_MAX <= MaskRow) + { + funcRtn = 0u; + break; + } + else + { + } + + } + else if(3u > residue) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_GARAGEDOOR; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_GARAGE_DOOR_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + else + { + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + if ( 0u == funcRtn) + { + break; + } + else + { + } + } + } + + } + + return funcRtn; +} + +/********************************************* +*ܣCI-ZC ״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCFloodGateMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr = NULL; + UINT8* pDataLin = NULL; + UINT16 index = 0u;/**/ + UINT32 DataSize = 0u; + UINT16 MaskRow=0u;/*ID*/ + UINT16 DeviceID=0u; + UINT16 residue = 0u;/**/ + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={0u,MASK_TYPE_FD_OPENLOCK_TO_ZC,MASK_TYPE_FLOODGATE_CLOSEAPLAY_STATE,MASK_TYPE_FLOODGATE_SQGM_TOZC,MASK_TYPE_FLOODGATE_YXGM_FROMZC,0u}; + UINT16 BuChang = 0u; + + if (NULL == FSDataName) + { + funcRtn = 0u; + } + else + { + funcRtn = 1u; + } + if (1u == funcRtn) + { + funcRtn = dquGetConfigData((CHAR*)FSDataName,CI_ZC_MASK_TYPE,CI_ZC_FLOODGATE_MASK_ID,&pDataAddr,&DataSize); + } + + if (1u == funcRtn) + { + if((DataSize%CI_ZC_FLOODGATE_MASK_LEN) != 0u) + { + funcRtn = 0u; + } + else + { + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + } + + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ZC_FLOODGATE_MASK_LEN/2u); + if(0u == residue) + {/*Ϊ0ǵһ,Ϊ0ʱidID*/ + DeviceID = ShortFromChar((UINT8*)(&pDataAddr[index])); + /*pDataLin = pDataAddr + (CI_ZC_FLOODGATE_MASK_LEN -2u);*/ /*ȡһеĵַ*/ + pDataLin = (UINT8*)(&pDataAddr[index + (CI_ZC_FLOODGATE_MASK_LEN -2u)]);/*ȡһеĵַ*/ + BuChang++; + MaskRow = ShortFromChar(pDataLin); + /*pDataAddr+=2;*/ + index +=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + break; + } + } + else if ((0u < residue) && (residue < ((CI_ZC_FLOODGATE_MASK_LEN/2u) -2u)))/*2е4ΪCI-ZCţ5zc-ci6CIidܹ6УҪ-2*/ + { + /*ȡλID*/ + tempMaskId = ShortFromChar((UINT8*)(&pDataAddr[index])); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + if ((MaskRow < CI_SUM_MAX)&&(tempMaskId < CI_TO_ZC_MASK_SUM_MAX)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_FLOODGATE; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_FLOODGATE_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + + } + /*pDataAddr+=2u;*/ + index +=2u; + BuChang++; + } + else if (residue == (UINT16)((CI_ZC_FLOODGATE_MASK_LEN/2u) -2u))/*zc-ciλ*/ + { + /*ȡλID*/ + tempMaskId = ShortFromChar((UINT8*)(&pDataAddr[index])); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + if ((MaskRow < CI_SUM_MAX)&&(tempMaskId < ZC_TO_CI_MASK_SUM_MAX)) + { + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_FLOODGATE; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_FLOODGATE_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigZcToCiMaskIdMax[MaskRow]) + { + ConfigZcToCiMaskIdMax[MaskRow] = ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigZcToCiMaskCurSum[MaskRow]++; + } + } + + /*pDataAddr+=2u;*/ + index +=2u; + BuChang++; + } + else + { + /*pDataAddr+=2u;*/ + index +=2u; + BuChang++; + } + if ( 0u == funcRtn) + { + break; + } + } + } + } + + return funcRtn; +} +/********************************************* +*ܣCI-ZC SPKS״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCSPKSMask(UINT8 * FSDataName) +{ + UINT8 funcRtn = 0u; + UINT8* pDataAddr, *pDataLin; + UINT32 DataSize = 0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 residue = 0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + + UINT8 MaskType[]={0u,MASK_TYPE_SPKS_OPENSTATE_ZC,0u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_SPKS_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn == 0u) + { + funcRtn = 0u; + } + else + { + if(DataSize%CI_ZC_SPKS_MASK_LEN != 0u) + { + funcRtn = 0u; + } + else + { + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + } + + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ZC_SPKS_MASK_LEN/2u); + if(0u == residue) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_SPKS_MASK_LEN - 2u; + MaskRow = ShortFromChar(pDataLin); + + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + break; + } + + pDataAddr+=2u; + BuChang++; + } + else if(residue == 1u) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_SPKS; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_SPKS_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigCiToZcMaskIdMax[MaskRow]) + { + ConfigCiToZcMaskIdMax[MaskRow] = ConfigCiToZcMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigCiToZcMaskCurSum[MaskRow]++; + } + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + } + } + + } + + return funcRtn; +} + + +/********************************************* +*ܣZC-CIλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmZCCIGaragedoor(UINT8 * FSDataName) +{ + UINT8 funcRtn = 1u; + UINT8* pDataAddr,*pDataLin; + UINT32 DataSize = 0u; + UINT16 i =0u; + UINT16 MaskRow=0u; + UINT16 DeviceID=0u; + UINT16 tempMaskId = 0u; /*λIDʱ*/ + UINT16 residue = 0u; + + UINT8 MaskType[]={1u,MASK_TYPE_GARAGEDOOR_STATE,MASK_TYPE_GARAGEDOOR_APPLYCLOSE_STATE,MASK_TYPE_GARAGEDOOR_ALLOWCLOSE_STATE,1u}; + UINT16 BuChang = 0u; + funcRtn = dquGetConfigData(FSDataName,CI_ZC_MASK_TYPE,CI_ZC_GARAGE_DOOR_MASK_ID,&pDataAddr,&DataSize); + if(funcRtn==0u) + { + funcRtn = 0u; + } + else + { + if(DataSize%CI_ZC_GARAGE_DOOR_MASK_LEN != 0u) + { + funcRtn = 0u; + } + else + { + if(DataSize == 0u) + { + /**/ + funcRtn = 1u; + } + for(;DataSize>0u;DataSize-=2u) + { + residue = BuChang%(CI_ZC_GARAGE_DOOR_MASK_LEN/2u); + if(residue == 0u) + { + DeviceID = ShortFromChar(pDataAddr); + pDataLin = pDataAddr + CI_ZC_GARAGE_DOOR_MASK_LEN -2u; + BuChang++; + MaskRow = ShortFromChar(pDataLin); + pDataAddr+=2u; + /*鲻Խ磬Խֱӷʧ*/ + if(MaskRow >= CI_SUM_MAX) + { + funcRtn = 0u; + break; + } + } + else if(residue==3u) + { + /*ȡλID*/ + tempMaskId = ShortFromChar(pDataAddr); + + /*00xFFFFЧλ*/ + if((0xFFFFu != tempMaskId)&&(0u != tempMaskId)) + { + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceId = DeviceID; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].DeviceType = CI_DEVICE_TYPE_GARAGEDOOR; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId = tempMaskId; + ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskType = (UINT8)(MaskType[BuChang%(CI_ZC_GARAGE_DOOR_MASK_LEN/2u)]); + + + /*ͳЧλ*/ + if(ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId > ConfigZcToCiMaskIdMax[MaskRow]) + { + ConfigZcToCiMaskIdMax[MaskRow] = ConfigZcToCiMaskConfigDataStru[MaskRow][tempMaskId].MaskId; + } + else + { + /*do nothing*/ + } + + ConfigZcToCiMaskCurSum[MaskRow]++; + } + + pDataAddr+=2u; + BuChang++; + } + else + { + pDataAddr+=2u; + BuChang++; + } + if ( 0u == funcRtn) + { + break; + } + } + } + + } + + return funcRtn; +} diff --git a/TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.h b/TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.h new file mode 100644 index 0000000..61c2818 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dquMaskInit.h @@ -0,0 +1,410 @@ +/************************************************************************ +* +* ļ dquMaskInit.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* λʼ +* ʹע +* ޸ļ¼ ԾλCI-ZCλֽڳ20Ϊ26Modified By RenjuWu20151015 +* +************************************************************************/ +#ifndef DQU_MASK_INIT +#define DQU_MASK_INIT + +#include "dquCIInit.h" + +/***** +******CILEUλ +********/ +/*CI-LEUλID*/ +#define CI_LEU_MASK_TYPE ((UINT32)0xB2) +#define CI_LEU_SWITCH_MASK_ID ((UINT32)1) /*CI-ZCλ*/ +#define CI_LEU_SWITCH_MASK_LEN ((UINT32)8) /*CI-ZCλֽڳ--1г*/ +#define CI_LEU_PSD_MASK_ID ((UINT32)2) /*CI-LEUλ*/ +#define CI_LEU_PSD_MASK_LEN ((UINT32)6) /*CI-LEUλֽڳ--1г*/ +#define CI_LEU_ROUTE_MASK_ID ((UINT32)3) /*CI-LEU·λ*/ +#define CI_LEU_ROUTE_MASK_LEN ((UINT32)6) /*CI-LEU·λֽڳ--1г*/ +#define CI_LEU_OVER_LAP_MASK_ID ((UINT32)4) /*CI-LEUλ*/ +#define CI_LEU_OVER_LAP_MASK_LEN ((UINT32)6) /*CI-LEUλֽڳ--1г*/ +#define CI_LEU_SIGNAL_MASK_ID ((UINT32)5) /*CI-LEUźŻλ*/ +#define CI_LEU_SIGNAL_MASK_LEN ((UINT32)6) /*CI-LEUźŻλֽڳ--1г*/ +/* zt ɾش 2022-02-15 */ + +/*CI-ZCλID*/ +#define CI_ZC_MASK_TYPE ((UINT32)0xB3) +#define CI_ZC_SWITCH_MASK_ID ((UINT32)1) /*CI-ZCλ*/ +#define CI_ZC_SWITCH_MASK_LEN ((UINT32)10) /*CI-ZCλֽڳ--1г*/ + +#define CI_ZC_SIGNAL_MASK_ID ((UINT32)2) /*CI-ZCźŻλ*/ +#define CI_ZC_SIGNAL_MASK_LEN ((UINT32)16) /*CI-ZCźŻλֽڳ--1г*/ + +#define CI_ZC_PSD_MASK_ID ((UINT32)3) /*CI-ZCλ*/ +#define CI_ZC_PSD_MASK_LEN ((UINT32)6) /*CI-ZCλֽڳ--1г*/ + +#define CI_ZC_ESB_MASK_ID ((UINT32)4) /*CI-ZCͣťλ*/ +#define CI_ZC_ESB_MASK_LEN ((UINT32)6) /*CI-ZCͣťλֽڳ--1г*/ + +#define CI_ZC_LOGIC_SGMT_MASK_ID ((UINT32)6) /*CI-ZC߼λ*/ +#define CI_ZC_LOGIC_SGMT_MASK_LEN ((UINT32)18) /*CI-ZC߼λֽڳ--1г*/ + +#define CI_ZC_ROUTE_MASK_ID ((UINT32)7) /*CI-ZC·λ*/ +#define CI_ZC_ROUTE_MASK_LEN ((UINT32)10) /*CI-ZC·λֽڳ--1г*/ + +#define CI_ZC_AXLE_SGMT_MASK_ID ((UINT32)5) /*CI-ZCλ*/ +#define CI_ZC_AXLE_SGMT_MASK_LEN ((UINT32)26) /*CI-ZCλֽڳ--1гȣModified 20151015*/ + +#define CI_ZC_OVER_LAP_MASK_ID ((UINT32)8) /*CI-ZCλ*/ +#define CI_ZC_OVER_LAP_MASK_LEN ((UINT32)8) /*CI-ZCλֽڳ--1г*/ + +#define CI_ZC_RETURN_MASK_ID ((UINT32)9) /*CI-ZC۷λ*/ +#define CI_ZC_RETURN_MASK_LEN ((UINT32)10) /*CI-ZC۷λֽڳ--1г*/ + +#define CI_ZC_COMEGO_MASK_ID ((UINT32)10) /*CI_ZC·λ*/ +#define CI_ZC_COMEGO_ROUTE_MASK_LEN ((UINT32)6) /*CI_ZC·λֽڳ--1г*/ + +/**/ +#define CI_ZC_FLOODGATE_MASK_ID ((UINT32)11) /*CI_ZCλ*/ +#define CI_ZC_FLOODGATE_MASK_LEN ((UINT32)12) /*CI_ZCλ-1г*/ + +/**/ +#define CI_ZC_GARAGE_DOOR_MASK_ID ((UINT32)12) /*CI_ZCλ*/ +#define CI_ZC_GARAGE_DOOR_MASK_LEN ((UINT32)10) /*CI_ZCλֽڳ--1г*/ + +/*SPKS*/ +#define CI_ZC_SPKS_MASK_ID ((UINT32)13) /*CI-ZC SPKS״̬λ*/ +#define CI_ZC_SPKS_MASK_LEN ((UINT32)6) /*CI-ZC SPKS״̬λֽڳ--1г*/ + +/* zt ɾش 2022-02-15 */ +/*λID*/ +#define CI_ATS_DATA_ELEMENT_LEN ((UINT32)2) /*CI-ATS1Ԫس*/ + +#define CI_ATS_MASK_TYPE ((UINT32)0xB1) +#define CI_ATS_SWITCH_MASK_ID ((UINT32)1) /*CI-ATSλ*/ +#define CI_ATS_SWITCH_MASK_LEN ((UINT32)22) /*CI-ATSλֽڳ--1г*/ +#define CI_ATS_SIGNAL_MASK_ID ((UINT32)2) /*CI-ATSźŻλ*/ +#if 0 +#define CI_ATS_SIGNAL_MASK_LEN ((UINT32)26) /*CI-ATSźŻλֽڳ--1г*/ +#endif +#define CI_ATS_SIGNAL_MASK_LEN ((UINT32)34) /*CI-ATSźŻλֽڳ--1г,人4ʾ5ʾCI16.5 data17.5*/ + +#define CI_ATS_PSD_MASK_ID ((UINT32)3) /*CI-ATSλ*/ + +#if 1 +#define CI_ATS_PSD_MASK_LEN ((UINT32)26) /*CI-ATSλֽڳ--1г*/ +#else +#define CI_ATS_PSD_MASK_LEN ((UINT32)22) /*CI-ATSλֽڳ--1г*/ +#endif + +#define CI_ATS_ESB_MASK_ID ((UINT32)4) /*CI-ATSͣťλ*/ +#define CI_ATS_ESB_MASK_LEN ((UINT32)6) /*CI-ATSͣťλֽڳ--1г*/ +#define CI_ATS_LOGIC_SGMT_MASK_ID ((UINT32)5) /*CI-ATS߼λ*/ +#define CI_ATS_LOGIC_SGMT_MASK_LEN ((UINT32)14) /*CI-ATS߼λֽڳ--1г*/ +#define CI_ATS_ROUTE_MASK_ID ((UINT32)6) /*CI-ATS·λ*/ +#define CI_ATS_ROUTE_MASK_LEN ((UINT32)22) /*CI-ATS·λֽڳ--1г*/ +#define CI_ATS_AR_ROUTE_MASK_ID ((UINT32)7) /*CI-ATSԶ۷·λ*/ +#define CI_ATS_AR_ROUTE_MASK_LEN ((UINT32)6) /*CI-ATSԶ۷·λֽڳ--1г*/ +#define CI_ATS_AUTO_ROUTE_MASK_ID ((UINT32)8) /*CI-ATSԶͨ·λ*/ +#define CI_ATS_AUTO_ROUTE_MASK_LEN ((UINT32)6) /*CI-ATSԶͨ·λֽڳ--1г*/ +#define CI_ATS_PHYSEC_MASK_ID ((UINT32)9) /*CI-ATSλ*/ +#define CI_ATS_PHYSEC_MASK_LEN ((UINT32)14) /*CI-ATSλֽڳ--1г*/ + +#define CI_ATS_SPKS_MASK_ID ((UINT32)10) /*CI-ATS SPKS״̬λ*/ +#define CI_ATS_SPKS_MASK_LEN ((UINT32)8) /*CI-ATS SPKS״̬λֽڳ--1гȣ2018.03.19 6Ϊ8CI_ATS SPKSλһп·״̬λ*/ + +#define CI_ATS_WASHMACHINE_MASK_ID ((UINT32)11) /*CI-ATS ϴ״̬λ*/ +#define CI_ATS_WASHMACHINE_MASK_LEN ((UINT32)8) /*CI-ATS ϴ״̬λֽڳ--1г*/ + +#define CI_ATS_AAR_ROUTE_MASK_ID ((UINT32)12) /*CI-ATSȫԶ۷·λ*/ +#define CI_ATS_AAR_ROUTE_MASK_LEN ((UINT32)6) /*CI-ATSȫԶ۷·λֽڳ--1г*/ + +#define CI_ATS_GARAGEDOOR_MASK_ID ((UINT32)13) /*CI-ATS ״̬λ*/ +#define CI_ATS_GARAGEDOOR_MASK_LEN ((UINT32)14) /*CI-ATS ״̬λֽڳ--1г*/ + +#define CI_ATS_FLOODGATE_MASK_ID ((UINT32)24) /*CI_ATSλ*/ +#define CI_ATS_FLOODGATE_MASK_LEN ((UINT32)10) /*CI_ATSλֽڳ--1г*/ + +/* zt ɾش 2022-02-15 */ + + + +extern MaskConfigDataStruct ConfigCiToAtsMaskConfigDataStru[CI_SUM_MAX][CI_TO_ATS_MASK_SUM_MAX]; /*CIվATSλ*/ +extern UINT16 ConfigCiToAtsMaskCurSum[CI_SUM_MAX] ; /*CIվATSλǰ*/ +extern UINT16 ConfigCiToAtsMaskIdMax[CI_SUM_MAX] ; /*CIվATSλֵ*/ + +extern MaskConfigDataStruct ConfigCiToZcMaskConfigDataStru[CI_SUM_MAX][CI_TO_ZC_MASK_SUM_MAX]; /*CIվZCλ*/ +extern UINT16 ConfigCiToZcMaskCurSum[CI_SUM_MAX] ; /*CIվZCλǰ*/ +extern UINT16 ConfigCiToZcMaskIdMax[CI_SUM_MAX] ; /*CIվZCλֵ*/ + +extern MaskConfigDataStruct ConfigZcToCiMaskConfigDataStru[CI_SUM_MAX][ZC_TO_CI_MASK_SUM_MAX]; /*ZCվCIλ*/ +extern UINT16 ConfigZcToCiMaskCurSum[CI_SUM_MAX] ; /*CIվZCλǰ*/ +extern UINT16 ConfigZcToCiMaskIdMax[CI_SUM_MAX] ; /*CIվZCλֵ*/ + +extern MaskConfigDataStruct ConfigCiToLeuMaskConfigDataStru[CI_SUM_MAX][CI_TO_LEU_MASK_SUM_MAX]; /*CILEUλ*/ +extern UINT16 ConfigCiToLeuMaskCurSum[CI_SUM_MAX] ; /*CIվLeuλǰ*/ +extern UINT16 ConfigCiToLeuMaskIdMax[CI_SUM_MAX] ; /*CIվLeuλֵ*/ + +/***** +******CIATSλ +********/ +/********************************************* +*ܣCIATSλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSSwitchMask(UINT8 * FSDataName); +/* zt ɾش 2022-02-15 */ +/********************************************* +*ܣCI-ATSźŻλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSSignalMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATSλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSPsdMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATSͣťλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSEsbMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATS߼λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSLogSgmt(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATS·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSRouteMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATSλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSPhySecMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATSԶͨ·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSARtMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATSԶ۷·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSARRtMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATS SPKS״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSSPKSMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ATS ϴ״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSWashM(UINT8 * FSDataName); + +/********************************************* +*ܣCI-ATS ״̬λ +*˵FSDataNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSFloodGate(UINT8 * FSDataName); + +/********************************************* +*ܣCI-ATS ״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSGarageDoor(UINT8 * FSDataName); + +/********************************************* +*ܣCI-ATSȫԶ۷·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIATSAARRtMask(UINT8 *FSDataName); +/***** +******CIATSλ +********/ + +/***** +******CIZCλ +********/ +/********************************************* +*ܣCI-ZCλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCSwitchMask(UINT8 * FSDataName); +/* zt ɾش 2022-02-15 */ +/********************************************* +*ܣCI-ZCźŻλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCSignalMask(UINT8 * FSDataName); +/********************************************* +*ܣZC-CIźŻλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmZCCISignalMask(UINT8 * FSDataName); + + +/********************************************* +*ܣCI-ZCλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCPsdMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ZCͣťλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCEsbMask(UINT8 * FSDataName); + + +/********************************************* +*ܣZC-CI߼λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmZCCILogSgmtMask(UINT8 * FSDataName); + + +/********************************************* +*ܣCI-ZC·λ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCRouteMask(UINT8 * FSDataName); + + +/********************************************* +*ܣCI-ZCλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCAxleSgmtMask(UINT8 * FSDataName); +/********************************************* +*ܣZC-CIλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmZCCIAxleSgmtMask(UINT8 * FSDataName); + + +/********************************************* +*ܣCI-ZCλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCOverLapMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-ZC۷λ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCReturnMask(UINT8 * FSDataName); +/********************************************* +*ܣZC-CI۷λ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmZCCIRtnMask(UINT8 * FSDataName); + +/********************************************* +*ܣZC-CI·λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCComeGoMask(UINT8 * FSDataName) ; +/********************************************* +*ܣCI-ZCλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCGaragedoor(UINT8 * FSDataName); +/********************************************* +*ܣCI-ZC SPKS״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCIZCSPKSMask(UINT8 * FSDataName); + +/********************************************* +*ܣCI-ZC ״̬λ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCIZCFloodGateMask(UINT8 * FSDataName); + + +/********************************************* +*ܣZC-CIλ +*˵FSDataNameָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmZCCIGaragedoor(UINT8 * FSDataName); +/***** +******CIZCλ +********/ + +/***** +******CILEUλ +********/ +/********************************************* +*ܣCILEUλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCILEUSwitchMask(UINT8 * FSDataName); +/* zt ɾش 2022-02-15 */ +/********************************************* +*ܣCI-LEUλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCILEUPsdMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-LEUλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgDtStruFrmCILEURouteMask(UINT8 * FSDataName); +/********************************************* +*ܣCI-LEUλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCILEUOverLapMask(UINT8 * FSDataName); + +/********************************************* +*ܣʼλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskInit(UINT8 * FSDataName); + +/********************************************* +*ܣCI-LEUźŻλ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 MaskCfgStruFrmCILEUSignalMask(UINT8 * FSDataName); + +#endif diff --git a/TSCP/src/APP/ciapp/QueryFiles/dqucijdqstru.h b/TSCP/src/APP/ciapp/QueryFiles/dqucijdqstru.h new file mode 100644 index 0000000..69f1b50 --- /dev/null +++ b/TSCP/src/APP/ciapp/QueryFiles/dqucijdqstru.h @@ -0,0 +1,459 @@ +/************************************************************************ +* +* ļ dqucijdqstru.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ṹ嶨 +* ʹע +* ޸ļ¼ 2014.12.17 ׷SPKS,ȫԶϴ̵,ż̵ +* +************************************************************************/ +#ifndef DQU_CI_JDX_STRU +#define DQU_CI_JDX_STRU + +#include "CommonTypes.h" +#include "CiConfigData.h" + +/***IDID**/ +#define CI_DATA_TYPE ((UINT8)0x71) + + +/*̵ñID*/ +#define RELAY_RELAY_CONFIG_ID ((UINT8)1) +#define LEN_RELAY_RELAY_CONFIG ((UINT8)46) +/*ͣť̵ID*/ +#define RELAY_EMERG_STOP_ID ((UINT8)2) +#define LEN_EMERG_STOP ((UINT8)6) +/*ż̵ID*/ +#define RELAY_SCREEN_ID ((UINT8)3) +#define LEN_RELAY_SCREEN ((UINT8)30) /*޸ļ¼2018.11.21 16Ϊ28V15.0ݽṹ*/ +/*μ̵ID*/ +#define RELAY_PHYSICAL_SGMT ((UINT8)0x4) +#define LEN_RELAY_PHYSICAL_SGMT ((UINT8)12)/*޸ļ¼20170207գ68ԭӼḴλ̵Уռֽ*/ +/*̵*/ +#define RELAY_POINT ((UINT8)0x5) +#define LEN_RELAY_POINT ((UINT8)18) /*̵һУDFH̵ID16Ϊ18Modifyed by RenjuWu on 20170807*/ + +/* zt ɾش 2022-02-15 */ + +/*źŻ̵*/ +#define RELAY_SIGNAL ((UINT8)0x6) +#define LEN_RELAY_SIGNAL ((UINT8)30)/*Modified By RenjuWu 20160330*/ +/*ǽ·̵ID*/ +#define RELAY_NO_ROUTE_ID ((UINT8)7) +#define LEN_RELAY_NO_ROUTE ((UINT8)10) +/*ղ̵*/ +#define RELAY_ZHAO_CHA_ID ((UINT8)0x8) +#define LEN_RELAY_ZHAO_CHA ((UINT8)22) +/*ʾƼ̵*/ +#define RELAY_BJD_ID ((UINT8)0x9) +#define LEN_RELAY_BJD ((UINT8)15) +/*۷*/ +#define RELAY_NO_RETURN_ID ((UINT8)0x0A) +#define LEN_RELAY_NO_RETURN ((UINT8)4) + +/* ywlou20141217 add s */ +/* SPKS̵ */ +#define RELAY_SPKS_ID ((UINT8)13) +#define LEN_RELAY_SPKS ((UINT8)8) + +/* Ž̵ */ +#define RELAY_MJ_ID ((UINT8)32)/* Ž 32*/ +#define LEN_RELAY_MJ ((UINT8)13) + +/*ż̵*/ +#define RELAY_GARAGE_DOOR_ID ((UINT8)0x0E) +#define LEN_GARAGE_DOOR ((UINT8)18) /* 20190517ӳſ״̬ڵ̵ by cyl*/ + +/*ż̵*//* zhangyeh 20141223 */ +#define RELAY_FLOOD_GATE_ID ((UINT8)0x0B) +#define LEN_FLOOD_GATE ((UINT8)8) + +/*ϴ*/ +#define RELAY_WASH_MACHINE_ID ((UINT8)0x0C) +#define LEN_RELAY_WASH_MACHINE ((UINT8)24) /*޸ļ¼2019.04.02 22Ϊ24ϴ̵ͨV16.0ݽṹ*/ + +/*̵ͬ*/ +#define RELAY_DCAGREE_ID ((UINT8)17) /*̵ͬ-*/ +#define LEN_RELAY_DCAGREE_ID ((UINT8)6) /*̵ͬ-г*/ + +/*ιղ̵*/ +#define RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID ((UINT8)18) /*ιղ̵-*/ +#define LEN_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID ((UINT8)22) /*ιղ̵-г*/ + +/*̵ӿźŻɫñ*/ +#define RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID ((UINT8)19) /*̵ӿźŻɫñ-*/ +#define LEN_RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID ((UINT8)8) /*̵ӿźŻɫñ-г*/ + +/*ղ̵*/ +#define RELAY_ZHAOCHA_CI_CHECK_ID ((UINT8)20) + +#define BJD_MAX_NUM ((UINT8)4) + +#define JDQ_NAME_LEN ((UINT8)16) + + +/***OC_ݱID**/ +#define OC_DATA_TYPE ((UINT8)0x73) + +/*̵ñID*/ +#define OC_RELAY_RELAY_CONFIG_ID ((UINT8)1) +#define OC_LEN_RELAY_RELAY_CONFIG ((UINT8)46) + +/*ñ*/ +#define OC_SWITCH_ID ((UINT8)2) +#define LEN_OC_SWITCH ((UINT8)8) +/*̵ñ*/ +#define OC_SWITCH_RELAY_ID ((UINT8)4) +#define LEN_OC_SWITCH_RELAY ((UINT8)24) +/*źŻñ*/ +#define OC_SIGNAL_ID ((UINT8)5) +#define LEN_OC_SIGNAL ((UINT8)24) + +/*źŻ̵ñ*/ +#define OC_SIGNAL_RELAY_ID ((UINT8)7) +#define LEN_OC_SIGNAL_RELAY ((UINT8)28) + + +/*ñ*/ +#define OC_PHYSEC_ID ((UINT8)8) +#define LEN_OC_PHYSEC ((UINT8)8) + +/*μ̵ID*/ +#define OC_RELAY_PHYSICAL_SGMT ((UINT8)10) +#define OC_LEN_RELAY_PHYSICAL_SGMT ((UINT8)16) /*mod by qw.liu 2022-02-22 ˹ ̵ṹ 1 2̵*/ + +/*ż̵ID*/ +#define OC_RELAY_SCREEN_ID ((UINT8)11) +#define OC_LEN_RELAY_SCREEN ((UINT8)36) + +/*ͣť̵ID*/ +#define OC_RELAY_EMERG_STOP_ID ((UINT8)12) +#define OC_LEN_EMERG_STOP ((UINT8)22) + +/* SPKS̵ */ +#define OC_RELAY_SPKS_ID ((UINT8)13) +#define OC_LEN_RELAY_SPKS ((UINT8)14) + +/* Ž̵ */ +#define OC_RELAY_MJ_ID ((UINT8)32) /* Ž 32*/ +#define OC_LEN_RELAY_MJ ((UINT8)13) + +/*۷*/ +#define OC_RELAY_NO_RETURN_ID ((UINT8)14) +#define OC_LEN_RELAY_NO_RETURN ((UINT8)8) + +/*ʾƼ̵*/ +#define OC_RELAY_BJD_ID ((UINT8)15) +#define OC_LEN_RELAY_BJD ((UINT8)15) + +/*OCùϵ*/ +#define OC_CI_RELATION_ID ((UINT8)16) +#define LEN_OC_CI_RELATION ((UINT8)22) + +/*ģñ*/ +#define OC_IN_OUT_TYPE_ID ((UINT8)17) +#define OC_IN_OUT_TYPE_LEN ((UINT8)5) + +/*ղ̵*/ +#define OC_RELAY_ZHAO_CHA_ID ((UINT8)18) +#define OC_LEN_RELAY_ZHAO_CHA ((UINT8)16) + +/*ȫԶϴ̵*/ +#define OC_RELAY_WASH_MACHINE_ID ((UINT8)19) +#define OC_LEN_RELAY_WASH_MACHINE ((UINT8)24) + +/*ǽ·̵*/ +#define OC_RELAY_NO_ROUTE_ID ((UINT8)20) +#define OC_LEN_RELAY_NO_ROUTE ((UINT8)10) + +/*ż̵*/ +#define OC_RELAY_GARAGE_DOOR_ID ((UINT8)21) +#define OC_LEN_GARAGE_DOOR ((UINT8)18) + +/*ż̵*/ +#define OC_RELAY_FLOOD_GATE_ID ((UINT8)22) +#define OC_LEN_FLOOD_GATE ((UINT8)8) + +/*ιղ̵*/ +#define OC_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID ((UINT8)23) /*ιղ̵-*/ +#define OC_LEN_RELAY_ZHAOCHA_PHY_LOCK_EXCEPT_ID ((UINT8)22) /*ιղ̵-г*/ + +/*̵ӿźŻɫñ*/ +#define OC_RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID ((UINT8)24) /*̵ӿźŻɫñ-*/ +#define OC_LEN_RELAY_DRVCOLL_SIGNAL_OPEN_COLOR_ID ((UINT8)8) /*̵ӿźŻɫñ-г*/ + +/*OC ߽ӿڼ̵ñ*/ +#define OC_LIAISON_RELAY_ID ((UINT8)28) + +#define OC_RELAY_REVERSE_CUT_ID ((UINT8)30) +#define OC_LEN_REVERSE_CUT ((UINT8)2) + +/*ͣť̵ṹ*/ +typedef struct S_Relay_EmegencyStopStruct +{ + UINT16 wEmgcyStopBtnId; /*ͣťID*/ + UINT16 wOcId; /*OC ID*/ + UINT16 wEmgcyStopBtnRelayId; /*ͣť̵ID*/ + UINT16 wEmgcyStopBtnRelayId2; /*ͣť̵ID2 add by qw.liu 2022-02-22 ˹ťɼ*/ + UINT16 wEmgcyStopBtnIndicateRelayId; /*ͣťָʾƼ̵ID*/ + UINT16 wRepEmgcyStopBtnRelayId; /*ʾͣť̵ID*/ + UINT16 wEmgcyStopCutRelayId; /*ͣ·ť̵ID*/ + UINT16 wEmgcyStopCutIndicateRelayId; /*ͣ·ťָʾƼ̵ID*/ + UINT16 wEmgcyStopBuzzRelayId; /*̵ͣID*/ + UINT16 wESSRelayId; /*ͣؼ̵ID*/ + UINT16 wESSSteadyIndicatRelayId; /*ͣȵƼ̵ID*/ + UINT16 wESSFlashIndicatRelayId; /*ͣƼ̵ID*/ + UINT16 wCancelEsbRelayId; /*ȡͣť̵ID*/ + UINT16 wEsbPlatformDisRelayId; /*ͣťվָ̨ʾƼ̵ID*/ + UINT16 wCutoffEsbBuzzRelayId; /*г̵ID*/ +} Relay_EmgcyStpStruct; + +/*ż̵ṹ*/ +typedef struct S_Relay_ScreenStruct +{ + UINT16 wScreenId; /*ID*/ + UINT16 wOcId; /*OC ID*/ + UINT16 wRelayRelatedId; /*̵ID*/ + UINT16 wRelayRelatedId2; /*̵ID2*/ + UINT16 wRelayCloseDoorId; /*ż̵ID*/ + UINT16 wRelayFourEditGroupOpenDoorId; /*ı鿪ż̵ID*/ + UINT16 wRelaySixEditGroupOpenDoorId; /*鿪ż̵ID*/ + UINT16 wRelayEightEditGroupOpenDoorId; /*˱鿪ż̵ID*/ + UINT16 wRelayDoorClosedId; /*Źؼ̵ID*/ + UINT16 wRelayDoorClosedId2; /*Źؼ̵ID2*/ + UINT16 wRelayDoorButtonId; /*PSDť̵*/ + UINT16 doorReopenRelayId; /*վ̨ٴοż̵ID*/ + UINT16 departureConfirmRelayId; /*ȷϼ̵ID*/ + UINT16 detectStartRelayId; /*϶̵̽ID*/ + UINT16 detectStopRelayId; /*ֹͣ϶̵̽ID*/ + UINT16 obstacleRelayId; /*ϰ̵ID*/ + UINT16 gapDetMuLockRelayId; /*϶̽⻥̵ID*/ + UINT16 closeStateRelayId; /*Ź״̵̬ID*/ + UINT16 wClearPasseSteadyLightRelayId; /*ȵƼ̵ID*/ + UINT16 wClearPasseFlashLightRelayId; /*Ƽ̵ID*/ + UINT16 wClearPassengerButtonRelayId; /*ȷϰť̵ID*/ + UINT16 wCleFarePCBButtonRelayId; /*ȷPCBť̵*/ + UINT16 wCleFarePDBFlaLigRelayId; /*ȷPDBťָʾƼ̵*/ + UINT16 wPobBsdRelayId; /*ٿŰťָʾƼ̵*/ + UINT16 wPcbBsdRelayId; /*ٹŰťָʾƼ̵*/ + UINT16 wVideoQkLight1RelayId; /*ͰťƵָʾ1̵̣*/ + UINT16 wVideoQkLight2RelayId; /*ͰťƵָʾ2죩̵*/ +} Relay_ScreenStruct; + +/*μ̵ṹ*/ +typedef struct S_Relay_PhysicalSegmentStruct +{ + UINT16 wPhysicalId; /*ID*/ + UINT16 wOcId; /*OC ID*/ + UINT16 wRelayRailwayId; /*̵ID*/ + UINT16 wRelayRailwayId2; /*̵ID2 add by qw.liu 2022-02-22 ӹ̵2*/ + UINT16 wRelayAxleRetrunId; /*Ḵλ̵ID*/ + UINT16 wRelayAxleZongRetrunId; /*ܸλ̵ID*/ + UINT16 wRelayAxlePreResetId; /*Ԥλ״̵̬ID*/ + UINT16 wRepRelayTrainId; /*ʾ̵ID*/ + UINT16 wRepRelayZongResetShowId; /*ܸλʾ*/ +} Relay_PhysicalSegmentStruct; + +/*̵ṹ*/ +typedef struct S_Relay_PointStruct +{ + UINT16 wPointId; /*ID*/ + UINT16 wRelayDingBiaoId; /*̵ID*/ + UINT16 wRelayFanBiaoId; /*̵ID*/ + UINT16 wRelayShadowDingBiaoId; /*̵ID*/ + UINT16 wRelayShadowFanBiaoId; /*̵ID*/ + UINT16 wRelayYunCaoId; /*ʲټ̵ID*/ + UINT16 wRelayDingCaoId; /*ټ̵ID*/ + UINT16 wRelayFanCaoId; /*ټ̵ID*/ + UINT16 wRelayZongDingBiaoId; /*̵ܶID*/ + UINT16 wRelayZongFanBiaoId; /*̵ܶID*/ + /*Ϊؼ̵*/ + UINT16 wGZJId; /*ϼ̵ID (ֶ)*/ + UINT16 wJTYJaId; /*ֳ״̵̬ID (ֶ)*/ + UINT16 wQQJId; /*̵ֳID(ֶ)*/ + UINT16 wSJFId; /*ռ̵ID (ֶ)*/ + UINT16 wTYJId; /*ֳͬƼ̵ID (ֶ)*/ + UINT16 wThreeNId; /*Nλʾ̵ID(ֶ)*/ + UINT16 wThreeLId; /*Lλʾ̵ID (ֶ)*/ + UINT16 wThreeRId; /*Rλʾ̵ID(ֶ)*/ + UINT16 wFiveNId; /*忪Nλʾ̵ID (ֶ)*/ + UINT16 wFiveL1Id; /*忪L1λʾ̵ID(ֶ)*/ + UINT16 wFiveL2Id; /*忪L2λʾ̵ID(ֶ)*/ + UINT16 wFiveR1Id; /*忪R1λʾ̵ID (ֶ)*/ + UINT16 wFiveR2Id; /*忪R2λʾ̵ID (ֶ)*/ + UINT16 wThreeNYCId; /*Nλ̵ID(ֶ)*/ + UINT16 wThreeLYCId; /*Lλ̵ID (ֶ)*/ + UINT16 wThreeRYCId; /*Rλ̵ID(ֶ)*/ + UINT16 wFiveNYCId; /*忪Nλ̵ID (ֶ)*/ + UINT16 wFiveL1YCId; /*忪L1λ̵ID(ֶ)*/ + UINT16 wFiveL2YCId; /*忪L2λ̵ID(ֶ)*/ + UINT16 wFiveR1YCId; /*忪R1λ̵ID (ֶ)*/ + UINT16 wFiveR2YCId; /*忪R2λ̵ID (ֶ)*/ + UINT16 wDFHId; /*DFH̵IDֶΣ*/ +} Relay_PointStruct; +/*źŻ̵ṹ*/ +typedef struct S_Relay_SignalStruct +{ + UINT16 wSignalId; /*źŻID*/ + UINT16 wRelayDengSiId_1; /*1˿̵ID*/ + UINT16 wRelayDengSiId_2; /*2˿̵ID*/ + UINT16 wRelayTrainSignalId; /*гźż̵ID*/ + UINT16 wRelayZhengXianId; /*źż̵ID*/ + UINT16 wRelayYinDaoId; /*źż̵ID*/ + UINT16 wRelayDianDengId; /*Ƽ̵ID*/ + UINT16 wRelayDiaoCheSignalId; /*źż̵ID*/ + UINT16 wRelayYellowId_wh; /*ƵƼ̵ID for人*/ + UINT16 wRelayGreenId_wh; /*̵Ƽ̵ID for人*/ + UINT16 wRelayBlueDsId_wh; /*Ƶ˿̵ID for人*/ + UINT16 wRepRelayTrainSignalId; /*ʾгźż̵ID for人*/ + UINT16 wRelayDriveDetainId; /*վ۳̵ID for人*/ + UINT16 wRelayCollDetainId; /*վɼ۳̵ID for人*/ + UINT16 wSignalDrvColType; /*źŻɼͣ20160330ݽṹ䶯޸*/ + UINT16 DetainBtnCollRelayId; /*۳ťɼ̵ID*/ + UINT16 DetainBtnIndicatorRelayId; /*۳ťָʾƼ̵ID*/ + UINT16 DetainCutBtnRelayId; /*۳·ť̵ID*/ + UINT16 DetainCutBtnIndicatorRelayId; /*۳·ťָʾƼ̵ID*/ +} Relay_SignalStruct; + +/*ǽ·̵ṹ*/ +typedef struct S_Relay_NoRouteDcStruct +{ + UINT16 wId; /*ǽ·ID*/ + UINT16 wRelayShenQingScId; /*Գ̵ID*/ + UINT16 wRelayTongYiScId; /*ͬԳ̵ID*/ + UINT16 wRelayDrvShiCheShengQingId; /* ԳԳ̵ID */ + UINT16 wRelayColTongYiScId; /* ԳͬԳ̵ID */ +} Relay_NoRouteDcStruct; + +/*ղ̵ṹ*/ +typedef struct S_Relay_ZhaoChaStruct +{ + UINT16 wRouteId; /*·ID*/ + UINT16 wRelayBenDuanZcId; /*ղ̵ID*/ + UINT16 wRelayDuiDuanZcId; /*Զղ̵ID*/ + UINT16 wCancelRelayId; /*ȡղ̵ID */ + UINT16 wRelayZhaoChaPhySecId[ROUTE_THATZC_PHYSEC_SUM_MAX]; /*ղ1-5ID*/ + UINT16 wCancelRelayIdOnRelayInterface; /*̵ӿȡղ̵ID */ + UINT16 wRelayBenDuanZcIdOnRelayInterface; /*̵ӿڱղ̵ID*/ + UINT16 wRelayDuiDuanZcIdOnRelayInterface; /*̵ӿڶԶղ̵ID*/ + UINT16 wCbtcRelayBenDuanZcId; /*CBTCղ̵ID*/ + UINT16 wCbtcRelayDuiDuanZcId; /*CBTCԶղ̵ID*/ + UINT16 wCbtcCancelRelayId; /*CBTC-ȡղ̵ID */ +} Relay_ZhaoChaStruct; + +/*ʾƼ̵ṹ*/ +typedef struct S_Relay_BaoJingDengStruct +{ + UINT16 wId; /*ID*/ + UINT16 wBelongCiId; /**/ + UINT8 wBelongVirCIid; /**/ + UINT16 wBjdID; /*ID*/ + UINT8 wBjdYouXiao; /*ǷЧ*/ + UINT16 wBjdJdqId[BJD_MAX_NUM]; /*Զղ̵ID*/ + UINT8 cBjdDevId; /*豸ID*/ +} Relay_BaoJingDengStruct; + +/*۷ṹ*/ +typedef struct S_Relay_WuRenReturnStruct +{ + UINT16 wId; /*ID*/ + UINT16 ocId; /*OC ID*/ + UINT16 wWuRenReturnRelayId; /*۷̵ID*/ + UINT16 wWuRenReturnDisRelayId; /*۷ָʾƼ̵ID*/ + +} Relay_NoReturnStruct; + + +/*Žṹ*/ +typedef struct S_Relay_GaragedoorStruct +{ + UINT16 wGaragedoorId; /*ID*/ + UINT16 wGardoorOpenRelayId; /*ſż̵ID*/ + UINT16 wGardoorCloseRelayId; /*Źż̵ID*/ + UINT16 wGardoorOpenOrderRelayId; /*ſ̵ID*/ + UINT16 wGardoorCloseOrderRelayId; /*Ź̵ID*/ + UINT16 wGardoorModeStateRelayId; /*ģʽ״̵̬ID*/ + UINT16 wGardoorFaultStateRelayId; /*Ź״̵̬ID*/ + UINT16 wGardoorPangLuRelayId; /*·̵ID*/ + UINT16 wGardoorKGHRelayId; /*ſ״̬ڵ̵ID*/ +} Relay_GaragedoorStruct; + +/* SPKS̵ṹ */ +typedef struct SRelaySpksStruct +{ + UINT16 id; /* ID */ + UINT16 ocId; /*OC ID*/ + UINT16 colRelayId; /* ɼ̵ID */ + UINT16 disRelayId; /* ʾƼ̵ID */ + UINT16 cutRelayId; /*·̵ID*/ + UINT16 cutDisRelayId; /*·ָʾƼ̵ID*/ + UINT16 repRelayId; /*ʾ̵ID*/ + UINT16 outsideRelayId; /*spksʾƼ̵*/ +} RelaySpksStruct; + +/* Žݽṹ */ +typedef struct S_Relay_MJStruct +{ + UINT16 mjid; /* ŽID */ + UINT16 ocId; /*OC ID*/ + UINT16 mjjsRelayId; /* Ž̵ID */ + UINT16 spksId[MJ_MAX_SPKSNUM]; /*SPKSID*/ + +} Relay_MJStruct; + +/*ż̵ṹ*/ +typedef struct S_Relay_FloodGateStruct +{ + UINT16 wFloodGateId; /* ID */ + UINT16 wCloseApplyRelayId; /* ̵ID */ + UINT16 wOpenCloseRelayId; /* ռ̵ID */ + UINT16 wAllowRequestRelayId; /* ̵ID */ + +} Relay_FloodGateStruct; + +/*ϴ̵ṹ*/ + +typedef struct S_Relay_WashMachineStruct +{ + UINT16 wId; /*ϴID*/ + UINT16 WashMachineReadyRelayId; /*ȫԶϴ̵(ֶ:ɼ̵)*/ + UINT16 WashMachineRequestVerifyRelayId; /*ȫԶϴȷϼ̵ID (ֶ:ɼ̵)*/ + UINT16 TrainEmergencyStopRelayId; /*ȫԶг̵ͣ(ֶ:ɼ̵)*/ + UINT16 HeadWashAllowRelayId; /*ȫԶͷϴ̵(ֶ:ɼ̵)*/ + UINT16 TailWashAllowRelayId; /*ȫԶβϴ̵(ֶ:ɼ̵)*/ + UINT16 WashTrainRequestRelayId; /*ȫԶϴ̵(ֶ:̵)*/ + UINT16 TrainHeadStopSteadyRelayId; /*ȫԶͷͣȼ̵(ֶ:̵)*/ + UINT16 TrainTailStopSteadyRelayId; /*ȫԶβͣȼ̵(ֶ:̵)*/ + UINT16 TrainPassRequestRelayId; /*ȫԶ̵ͨ(ֶ:̵)*/ + UINT16 TrainOutWashPortAllowRelayId; /*ȫԶг̵(ֶ:ɼ̵)*/ + UINT16 PauseTrainWashRequestRelayId; /*ȫԶͣϴ̵(ֶ:̵)*/ + UINT16 WashModeBackRelayId; /*ȫԶϴģʽ̵(ֶ:ɼ̵)*/ + UINT16 WashModeRelayId; /*ȫԶԶϴģʽ̵ֶ:̵)*/ + UINT16 wDownWashAllowRelayId; /*ģʽϴͬⰴť̵ID(ֶ:ɼ̵)*/ + UINT16 wDownWashAllowLightRelayId; /*ģʽϴָͬʾƼ̵IDֶ:̵)*/ + UINT16 wDownWashAllowPassRelayId; /*ģʽϴͬͨť̵ID(ֶ:ɼ̵)*/ + UINT16 wDownWashRelateRoute1Id; /*ģʽϴ߿̨ʾ1·ID*/ + UINT8 wDownWashRelateRoute1CheckType; /*ģʽϴ߿̨ʾ1·״̬*/ + UINT16 wDownWashRelRoute1LightRelayId; /*ģʽϴ߿̨ʾ1̵IDֶ:̵)*/ + UINT16 wDownWashRelateRoute2Id; /*ģʽϴ߿̨ʾ2·ID*/ + UINT8 wDownWashRelateRoute2CheckType; /*ģʽϴ߿̨ʾ2·״̬*/ + UINT16 wDownWashRelRoute2LightRelayId; /*ģʽϴ߿̨ʾ2̵IDֶ:̵)*/ + +} Relay_WashMachineStruct; + +typedef struct S_Relay_DCAgreeStruct +{ + UINT16 wRouteId; /*·ID*/ + UINT16 DCRouteDCQJId;/*·̵ID*/ + UINT16 DCRouteTAJId;/*·ͬⰴť̵ID*/ +}Relay_DCAgreeStruct; + +typedef struct S_Relay_ReverseCutStruct +{ + UINT16 wReverseCutRelayId; /*м̵ID*/ +}Relay_ReverseCutStruct; + +#endif diff --git a/TSCP/src/APP/ciapp/Relay/RelayConfigDataManage.c b/TSCP/src/APP/ciapp/Relay/RelayConfigDataManage.c new file mode 100644 index 0000000..433f2b2 --- /dev/null +++ b/TSCP/src/APP/ciapp/Relay/RelayConfigDataManage.c @@ -0,0 +1,1660 @@ +/******************************************************** +* +* RelayConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ̵ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "RelayConfigDataManage.h" + +/*ղ̵ID*/ +UINT16 LockExceptZhaoChaRelayNum = 0u; +/*ղ̵ID*/ +UINT16 LockExceptZhaoChaRelayId[MAX_LOCK_EXCEPT_ZHAO_RELAY_NUM]; + +/*********************¼ӵģ޸processiotociʱ*****************/ +BoardConfigStruct BoardConfigForeNodeA[OC_SUM_MAX][BOARD_MAX_ADDR];/*ǰڵAϵ忨*/ +BoardConfigStruct BoardConfigForeNodeB[OC_SUM_MAX][BOARD_MAX_ADDR];/*ǰڵBϵ忨*/ +BoardConfigStruct BoardConfigBackNodeA[OC_SUM_MAX][BOARD_MAX_ADDR];/*ڵAϵ忨*/ +BoardConfigStruct BoardConfigBackNodeB[OC_SUM_MAX][BOARD_MAX_ADDR];/*ڵBϵ忨*/ + + +RelayConfigDataStruct RelayConfigDataStru[RELAY_SUM_MAX] = {0u}; /*̵ݽṹ*/ +UINT16 LocalCiRelayIdBuf[RELAY_SUM_MAX] = {0u}; /*屾̵IDӳ*/ +INT16 RelayCurSum = 0; /*̵ǰ*/ + +BoardDataStruct CiCollBoardDataStru[BOARD_SUM_MAX]; /*ɼݽṹ*/ +UINT16 CiCollBoardCurSum = 0u; /*ɼ嵱ǰ*/ + +BoardDataStruct CiDrvBoardDataStru[BOARD_SUM_MAX]; /*ݽṹ*/ +UINT16 CiDrvBoardCurSum = 0u; /*嵱ǰ*/ +ZhaochaCheckConfigDataStruct ZhaochaCheckConfigDataStru[ZHAOCHA_CHECK_SUM_MAX] = {0u};/*ղ̵ݽṹ*/ +/*ղղ̵ID*/ +UINT16 CiCheckZhaoChaRelayNum = 0u; + +OcConnetDataCfgStruct OcConnetDataCfgStru[OC_LIAISON_DEV_SUM_MAX] = {0u}; /*߽ӿڼ̵ñ*/ +UINT16 OcConnetDataDevNum = 0u; + +/********************OC******************/ +OcDrvBoardDataStruct LocalCIOcDrvBoardConfigDataArr[OC_SUM_MAX];/*屾صOC忨*/ +UINT8 LocalCiOcSum = 0U; + +OcDrvBoardsStruct LocalOcDrvBoardsMap[OC_SUM_MAX];/*ocdrv忨ӳϵ*/ +UINT8 LocalOcSum = 0U;/*oc*/ + +/********************OC******************/ + + +UINT16 totalRelayNum = 0u;/*͸Relay*/ +/* +* ȡָID̵ +* ˵ const UINT16 relayId, ̵ID +* ֵ RELAY_SUM_MAX: ȡʧ +* = 1u) && (relayId < RELAY_SUM_MAX)) + { + retVal = relayId; + } + + return retVal; +} + +/* +* ȡ̵ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ̵ǰ +*/ +UINT16 GetRelayCurSum(void) +{ + UINT16 retVal = 0u; + if (RelayCurSum >= (INT16)RELAY_SUM_MAX) + { + retVal = RELAY_SUM_MAX; + } + else if (RelayCurSum < 0) + { + retVal = 0u; + } + else + {/*RelayCurSum[0,RELAY_SUM_MAX)ʱǿת֤ȫ*/ + retVal = (UINT16)RelayCurSum; + } + return retVal; +} + +/* +* ȡָ±Ӧļ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetRelayId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + if (bufIndex < GetRelayCurSum()) + { + retVal = LocalCiRelayIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID̵ID +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRelayBelongCiId(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].BelongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵ɼģʽ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ɼģʽ +*/ +UINT8 GetRelayCollectMode(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].CollMode; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Aϵǰڵɼַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵǰڵɼַ +*/ +UINT8 GetRelayForeNodeCollAddrA(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].ForeNodeCollAddrA; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Aϵǰڵɼλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵǰڵɼλ +*/ +UINT8 GetRelayForeNodeCollPosA(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].ForeNodeCollPosA; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Aϵڵɼַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵڵɼַ +*/ +UINT8 GetRelayBackNodeCollAddrA(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].BackNodeCollAddrA; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Aϵڵɼλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵڵɼλ +*/ +UINT8 GetRelayBackNodeCollPosA(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].BackNodeCollPosA; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Aϵַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵַ +*/ +UINT8 GetRelayDrvAddrA(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].DrvAddrA; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Aϵλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵλ +*/ +UINT8 GetRelayDrvPosA(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].DrvPosA; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Bϵǰڵɼַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵǰڵɼַ +*/ +UINT8 GetRelayForeNodeCollAddrB(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].ForeNodeCollAddrB; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Bϵǰڵɼλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵǰڵɼλ +*/ +UINT8 GetRelayForeNodeCollPosB(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].ForeNodeCollPosB; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Bϵڵɼַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵڵɼַ +*/ +UINT8 GetRelayBackNodeCollAddrB(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].BackNodeCollAddrB; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Bϵڵɼλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵڵɼλ +*/ +UINT8 GetRelayBackNodeCollPosB(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].BackNodeCollPosB; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Bϵַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵַ +*/ +UINT8 GetRelayDrvAddrB(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].DrvAddrB; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Bϵλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵλ +*/ +UINT8 GetRelayDrvPosB(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].DrvPosB; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDIJɼṹ +* ˵ void +* ֵ 0: ȡʧ +* >0: ɼṹ +*/ +UINT16 GetColRelayStructSum(void) +{ + UINT16 retVal = 0u; + if (CiCollBoardCurSum >= BOARD_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = CiCollBoardCurSum; + } + return retVal; +} + +/* +* ȡָIDIJɼṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ȡݳɹ +*/ +BoardDataStruct* GetColRelayStruct(void) +{ + return CiCollBoardDataStru; + +} + +/* +* ȡָIDṹ +* ˵ void +* ֵ 0: ȡʧ +* >0: ɼṹ +*/ +UINT16 GetDrvRelayStructSum(void) +{ + return CiDrvBoardCurSum; +} + +/* +* ȡָIDṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ȡݳɹ +*/ +BoardDataStruct* GetDrvRelayStruct(void) +{ + return CiDrvBoardDataStru; +} + +/* +* ȡָɼַλõļ̵ID +* ˵ const UINT8 RelayAdrr, ɼַ +* const UINT8 Pos, ɼλ +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetColRelayID(const UINT8 ocId, const UINT8 RelayAdrr, const UINT8 Pos) +{ + UINT16 BoardSum = 0u; + UINT8 ii = 0u; + UINT16 retVal = CI_ERROR; + BoardSum = GetColRelayStructSum(); + + for (ii = 0u; ii < BoardSum; ii++) + { + if ((ocId== CiCollBoardDataStru[ii].OcId)&& (RelayAdrr == CiCollBoardDataStru[ii].BoardAddress)) + { + retVal = CiCollBoardDataStru[ii].RelayIdBuf[Pos]; + break; + } + } + + return retVal; +} + +/* +* ȡָɼַλõļ̵ɼϢ +* ˵ const UINT8 RelayAdrr, ɼַ +* const UINT8 Pos, ɼλ +* ֵ 0: ȡʧ +* >0: ɼϢ +*/ +UINT8 GetColRelayInfo(const UINT8 ocId,const UINT8 RelayAdrr, const UINT8 Pos) +{ + UINT16 ii = 0u; + UINT8 retVal = CI_ERROR; + +#if 0 + for (ii = 1u; ii < RELAY_SUM_MAX; ii++) + { + if (RelayConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + { + /*̵ɼַͲɼλþӦ򷵻ضӦIJɼϢ*/ + if ((RelayAdrr == RelayConfigDataStru[ii].ForeNodeCollAddrA) && (Pos == RelayConfigDataStru[ii].ForeNodeCollPosA - 1u)) + { + retVal = RELAY_COLL_FORENODE_A; + } + else if ((RelayAdrr == RelayConfigDataStru[ii].ForeNodeCollAddrB) && (Pos == RelayConfigDataStru[ii].ForeNodeCollPosB - 1u)) + { + retVal = RELAY_COLL_FORENODE_B; + } + else if ((RelayAdrr == RelayConfigDataStru[ii].BackNodeCollAddrA) && (Pos == RelayConfigDataStru[ii].BackNodeCollPosA - 1u)) + { + retVal = RELAY_COLL_BACKNODE_A; + } + else if ((RelayAdrr == RelayConfigDataStru[ii].BackNodeCollAddrB) && (Pos == RelayConfigDataStru[ii].BackNodeCollPosB - 1u)) + { + retVal = RELAY_COLL_BACKNODE_B; + } + else + { + /*ִ*/ + } + + if(CI_ERROR != retVal) + {/*˵Ѿѯ*/ + break; + } + } + + + } +#endif + + if (RelayAdrr < BOARD_MAX_ADDR) + { + if (Pos + 1u < BOARD_POS_MAX+1u) + { + if (BoardConfigForeNodeA[ocId][RelayAdrr].Pos[Pos+1u]>0u) + { + retVal = RELAY_COLL_FORENODE_A; + } + else if (BoardConfigForeNodeB[ocId][RelayAdrr].Pos[Pos+1u]>0u) + { + retVal = RELAY_COLL_FORENODE_B; + } + else if (BoardConfigBackNodeA[ocId][RelayAdrr].Pos[Pos+1u]>0u) + { + retVal = RELAY_COLL_BACKNODE_A; + } + else if (BoardConfigBackNodeB[ocId][RelayAdrr].Pos[Pos+1u]>0u) + { + retVal = RELAY_COLL_BACKNODE_B; + } + else + { + /**/ + } + } + } + + + + return retVal; +} + +/* +* ļ̵ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 RelayConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 relayConfigDataSum = 0u; /*̵豸*/ + UINT8 retVal = CI_SUCCESS; + + /*̵ID*/ + relayConfigDataSum = GetRelayCurSum(); + if (relayConfigDataSum >= RELAY_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < RELAY_SUM_MAX; ii++) + { + if (jj == relayConfigDataSum) + {/*Ч*/ + + break; + } + + if (RelayConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + LocalCiRelayIdBuf[jj] = RelayConfigDataStru[ii].RelayId; + jj++; + } + + } + } + + + return retVal; +} + + +/* +* ʼoc忨 +* ˵ +* ֵ void +*/ +void InitOcDrvBoardCfg(void) +{ + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 kk = 0u; + for (ii = 0u; ii < OC_SUM_MAX; ii++) + { + LocalCIOcDrvBoardConfigDataArr[ii].OcId = 0u; + LocalCIOcDrvBoardConfigDataArr[ii].DrvBoardNum = 0u; + for (jj = 0u; jj < OC_BOARD_SUM_MAX; jj++) + { + LocalCIOcDrvBoardConfigDataArr[ii].DrvBoardDataArr[jj].BoardAddress = 0u; + LocalCIOcDrvBoardConfigDataArr[ii].DrvBoardDataArr[jj].OcId = 0u; + for (kk = 0u; kk < BOARD_POS_MAX; kk++) + { + LocalCIOcDrvBoardConfigDataArr[ii].DrvBoardDataArr[jj].RelayIdBuf[kk] = 0u; + } + + } + } + + for (ii = 0u; ii < OC_SUM_MAX; ii++) + { + LocalOcDrvBoardsMap[ii].OcId = 0u; + LocalOcDrvBoardsMap[ii].DrvBoardSum = 0u; + for (jj = 0u; jj < OC_BOARD_SUM_MAX; jj++) + { + LocalOcDrvBoardsMap[ii].DrvBoardAddrArr[jj] = 0u; + } + + } +} + +/* +* Ѱ忨תoc忨 +* ˵ +* ֵ void +*/ +void ConvertBoardCfgToOcDrvBoardCfg(void) +{ + UINT16 ii = 0u; + UINT16 jj = 0u; + + UINT8 findOcFlag = 0u; + UINT16 findOcIndex = 0u; + + UINT8 findBoardFlag = 0u; + UINT8 findBoardIndex = 0u; + + LocalCiOcSum = 0u; + + for (ii = 0u; ii < CiDrvBoardCurSum; ii++)/*忨*/ + { + findOcFlag = 0u; + + for (jj = 0u; jj < LocalCiOcSum; jj++) + { + if (LocalCIOcDrvBoardConfigDataArr[jj].OcId == CiDrvBoardDataStru[ii].OcId) + { + findOcFlag = 1u; + findOcIndex = jj; + break; + } + + } + if (findOcFlag == 0u) + { + findOcIndex = LocalCiOcSum; + } + /*findindexпûҵģoc idҪһֵ*/ + LocalCIOcDrvBoardConfigDataArr[findOcIndex].OcId = CiDrvBoardDataStru[ii].OcId; + + /*ӴocҰ忨ַҲŵģΪcidrvboarddatastruDzظ*/ + for (jj = 0u; jj < LocalCIOcDrvBoardConfigDataArr[findOcIndex].DrvBoardNum; jj++) + { + if (LocalCIOcDrvBoardConfigDataArr[findOcIndex].DrvBoardDataArr[jj].BoardAddress == + CiDrvBoardDataStru[ii].BoardAddress) + {/*ҵ*/ + findBoardFlag = 1u; + findBoardIndex = (UINT8)jj; + break; + } + /*û*/ + findBoardIndex = (UINT8)LocalCIOcDrvBoardConfigDataArr[findOcIndex].DrvBoardNum; + } + + + /*̵idֵ*/ + + + + + + + if (findBoardIndex == 0u) + { + LocalCIOcDrvBoardConfigDataArr[findOcIndex].DrvBoardNum++;/*ûţʹð忨ĿΪȻĿ+1*/ + } + + + if (findOcFlag == 0u) + { + LocalCiOcSum++;/*ûţʹocĿΪȻĿ+1*/ + } + } + + /*************************************뿪****************************/ + LocalOcSum = 0u; + for (ii = 0u; ii < CiDrvBoardCurSum; ii++) + { + findOcFlag = 0u; + findOcIndex = 0u; + for (jj = 0u; jj < LocalOcSum; jj++) + { + if (LocalOcDrvBoardsMap[jj].OcId == CiDrvBoardDataStru[ii].OcId) + { + /*ҵoc*/ + findOcFlag = 1u; + findOcIndex = jj; + break; + } + findOcIndex = LocalOcSum; + } + /*ocİ忨ֵַ*/ + LocalOcDrvBoardsMap[findOcIndex].OcId = CiDrvBoardDataStru[ii].OcId; + + + if (findOcFlag == 0u) + { + LocalOcSum++; + } + } +} + +/* +* ݼ̵ɲɼ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 ConvertRelayConfigToBoardConfig(void) +{ + + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT16 index = 0u; + UINT8 isAdded = 0u;/*־Ƿ˸õַ*/ + UINT8 reVal = CI_ERROR; + UINT8 localCi = 0u; + UINT16 relaySum = GetRelayCurSum(); + + if (0U == relaySum) + { + reVal = CI_SUCCESS; + } + else + { + + /*Ӳɼַ*/ + for (ii = 0u; ii < relaySum; ii++) + { + index = GetRelayConfigBufIndex(LocalCiRelayIdBuf[ii]);/*ȡ̵*/ + + if (RELAY_SUM_MAX <= index) + { + reVal = CI_ERROR; + break; + } + else + { + reVal = CI_SUCCESS; + } + + if (CI_SUCCESS == reVal) + { + localCi = GetSystemParaLocalCiId(); + + if ((RelayConfigDataStru[index].BelongCiId == localCi) && (0u != localCi)) + {/*̵ΪŴ*/ + + if (RELAY_COLL_MODE_FORE == RelayConfigDataStru[index].CollMode) + {/*ǰڵɼ*/ + if (((0u != RelayConfigDataStru[index].ForeNodeCollAddrA) && (0u != RelayConfigDataStru[index].ForeNodeCollPosA)) && + ((0u != RelayConfigDataStru[index].ForeNodeCollAddrB) && (0u != RelayConfigDataStru[index].ForeNodeCollPosB))) + { + /*ͨ*/ + } + else + { + debug_infor_printf((const)"ConvertRelayConfigToBoardConfig failed: Relay %d config Error.\n", RelayConfigDataStru[index].RelayId); + reVal = CI_ERROR; + break; + } + } + else if (RELAY_COLL_MODE_DOUBLE == RelayConfigDataStru[index].CollMode) + {/*˫ڵɼ*/ + if ((0u != RelayConfigDataStru[index].ForeNodeCollAddrA) && (0u != RelayConfigDataStru[index].ForeNodeCollPosA) && + (0u != RelayConfigDataStru[index].ForeNodeCollAddrB) && (0u != RelayConfigDataStru[index].ForeNodeCollPosB) && + (0u != RelayConfigDataStru[index].BackNodeCollAddrA) && (0u != RelayConfigDataStru[index].BackNodeCollPosA) && + (0u != RelayConfigDataStru[index].BackNodeCollAddrB) && (0u != RelayConfigDataStru[index].BackNodeCollPosB) + ) + { + /*ͨ*/ + } + else + { + debug_infor_printf((const)"ConvertRelayConfigToBoardConfig failed: Relay %d config Error.\n", RelayConfigDataStru[index].RelayId); + reVal = CI_ERROR; + break; + } + } + else if (RELAY_COLL_MODE_BACK == RelayConfigDataStru[index].CollMode) + {/*ڵɼ*/ + if ((0u != RelayConfigDataStru[index].BackNodeCollAddrA) && (0u != RelayConfigDataStru[index].BackNodeCollPosA) && + (0u != RelayConfigDataStru[index].BackNodeCollAddrB) && (0u != RelayConfigDataStru[index].BackNodeCollPosB)) + { + /*ͨ*/ + } + else + { + debug_infor_printf((const)"ConvertRelayConfigToBoardConfig failed: Relay %d config Error.\n", RelayConfigDataStru[index].RelayId); + reVal = CI_ERROR; + break; + } + } + else if (RELAY_COLL_MODE_AFORE_BBCAK == RelayConfigDataStru[index].CollMode) + {/*˫ڵɼ*/ + if ((0u != RelayConfigDataStru[index].ForeNodeCollAddrA) && (0u != RelayConfigDataStru[index].ForeNodeCollPosA) && + (0u != RelayConfigDataStru[index].BackNodeCollAddrB) && (0u != RelayConfigDataStru[index].BackNodeCollPosB) + ) + { + /*ͨ*/ + } + else + { + debug_infor_printf((const)"ConvertRelayConfigToBoardConfig failed: Relay %d config Error.\n", RelayConfigDataStru[index].RelayId); + reVal = CI_ERROR; + break; + } + } + else if (RELAY_COLL_MODE_ABACK_BFORE == RelayConfigDataStru[index].CollMode) + {/*˫ڵɼ*/ + if ((0u != RelayConfigDataStru[index].ForeNodeCollAddrB) && (0u != RelayConfigDataStru[index].ForeNodeCollPosB) && + (0u != RelayConfigDataStru[index].BackNodeCollAddrA) && (0u != RelayConfigDataStru[index].BackNodeCollPosA)) + { + /*ͨ*/ + } + else + { + debug_infor_printf((const)"ConvertRelayConfigToBoardConfig failed: Relay %d config Error.\n", RelayConfigDataStru[index].RelayId); + + reVal = CI_ERROR; + break; + + } + } + else + {/*ûвɼЧɼʽ*/ + + } + + + /*ǰɼģʽ˫ɼģʽ*/ + if ((RELAY_COLL_MODE_FORE == RelayConfigDataStru[index].CollMode) + || (RELAY_COLL_MODE_DOUBLE == RelayConfigDataStru[index].CollMode) + || (RELAY_COLL_MODE_AFORE_BBCAK == RelayConfigDataStru[index].CollMode) + || (RELAY_COLL_MODE_ABACK_BFORE == RelayConfigDataStru[index].CollMode)) + { + /*Aϵǰɼַ*/ + isAdded = 0u; + for (jj = 0u; jj < CiCollBoardCurSum; jj++) + { + if (jj < BOARD_SUM_MAX) + { + if ((CiCollBoardDataStru[jj].OcId == RelayConfigDataStru[index].BelongOcId) && (RelayConfigDataStru[index].ForeNodeCollAddrA == CiCollBoardDataStru[jj].BoardAddress)) + {/*ַѾ*/ + if (0u != RelayConfigDataStru[index].BelongOcId) + { + CiCollBoardDataStru[jj].OcId = (UINT8)RelayConfigDataStru[index].BelongOcId; + } + else + { + } + + if (0U != RelayConfigDataStru[index].ForeNodeCollPosA) + { + CiCollBoardDataStru[jj].RelayIdBuf[RelayConfigDataStru[index].ForeNodeCollPosA - 1u] + = RelayConfigDataStru[index].RelayId; + isAdded = 1u;/*ӱ־*/ + + + /*********************¼ӵģ޸processiotociʱǰA*****************/ + if (BOARD_MAX_ADDR > RelayConfigDataStru[index].ForeNodeCollAddrA) + { + if (RelayConfigDataStru[index].ForeNodeCollPosA < (BOARD_POS_MAX + 1u)) + { + BoardConfigForeNodeA[RelayConfigDataStru[index].BelongOcId][RelayConfigDataStru[index].ForeNodeCollAddrA].Pos[RelayConfigDataStru[index].ForeNodeCollPosA] = 1u; + } + else + { + } + } + else + { + } + } + else + { + } + break; + } + else + { + } + } + else + { + isAdded = 1u;/*ֵ1*/ + } + } + if (0u == isAdded) + {/*ַδ*/ + if (0u != RelayConfigDataStru[index].BelongOcId) + { + CiCollBoardDataStru[CiCollBoardCurSum].OcId = (UINT8)RelayConfigDataStru[index].BelongOcId; + } + if (0U != RelayConfigDataStru[index].ForeNodeCollPosA) + { + CiCollBoardDataStru[CiCollBoardCurSum].BoardAddress = RelayConfigDataStru[index].ForeNodeCollAddrA; + CiCollBoardDataStru[CiCollBoardCurSum].RelayIdBuf[RelayConfigDataStru[index].ForeNodeCollPosA - 1u] + = RelayConfigDataStru[index].RelayId; + CiCollBoardCurSum++; + + /*********************¼ӵģ޸processiotociʱǰA*****************/ + if (BOARD_MAX_ADDR > RelayConfigDataStru[index].ForeNodeCollAddrA) + { + if (RelayConfigDataStru[index].ForeNodeCollPosA < (BOARD_POS_MAX + 1u)) + { + BoardConfigForeNodeA[RelayConfigDataStru[index].BelongOcId][RelayConfigDataStru[index].ForeNodeCollAddrA].Pos[RelayConfigDataStru[index].ForeNodeCollPosA] = 1u; + } + else + { + } + } + else + { + } + } + else + { + } + } + else + { + } + + + + /*Bϵǰɼַ*/ + isAdded = 0u; + for (jj = 0u; jj < CiCollBoardCurSum; jj++) + { + if (BOARD_SUM_MAX > jj) + { + if ((CiCollBoardDataStru[jj].OcId == RelayConfigDataStru[index].BelongOcId) && (RelayConfigDataStru[index].ForeNodeCollAddrB == CiCollBoardDataStru[jj].BoardAddress)) + {/*ַѾ*/ + if (0u != RelayConfigDataStru[index].BelongOcId) + { + CiCollBoardDataStru[jj].OcId = (UINT8)RelayConfigDataStru[index].BelongOcId; + } + else + { + } + + if (0U != RelayConfigDataStru[index].ForeNodeCollPosB) + { + CiCollBoardDataStru[jj].RelayIdBuf[RelayConfigDataStru[index].ForeNodeCollPosB - 1u] + = RelayConfigDataStru[index].RelayId; + isAdded = 1u;/*ӱ־*/ + + /*********************¼ӵģ޸processiotociʱǰB*****************/ + if (BOARD_MAX_ADDR > RelayConfigDataStru[index].ForeNodeCollAddrB) + { + if (RelayConfigDataStru[index].ForeNodeCollPosB < (BOARD_POS_MAX + 1u)) + { + BoardConfigForeNodeB[RelayConfigDataStru[index].BelongOcId][RelayConfigDataStru[index].ForeNodeCollAddrB].Pos[RelayConfigDataStru[index].ForeNodeCollPosB] = 1u; + } + else + { + } + } + else + { + } + } + else + { + } + break; + } + else + { + } + } + else + { + isAdded = 1u;/*ֵ1*/ + } + } + if (0u == isAdded) + {/*ַδ*/ + if (0u != RelayConfigDataStru[index].BelongOcId) + { + CiCollBoardDataStru[CiCollBoardCurSum].OcId = (UINT8)RelayConfigDataStru[index].BelongOcId; + } + if (0U != RelayConfigDataStru[index].ForeNodeCollPosB) + { + CiCollBoardDataStru[CiCollBoardCurSum].BoardAddress = RelayConfigDataStru[index].ForeNodeCollAddrB; + CiCollBoardDataStru[CiCollBoardCurSum].RelayIdBuf[RelayConfigDataStru[index].ForeNodeCollPosB - 1u] + = RelayConfigDataStru[index].RelayId; + CiCollBoardCurSum++; + + /*********************¼ӵģ޸processiotociʱǰB*****************/ + if (RelayConfigDataStru[index].ForeNodeCollAddrB < BOARD_MAX_ADDR) + { + if (RelayConfigDataStru[index].ForeNodeCollPosB < (BOARD_POS_MAX + 1u)) + { + BoardConfigForeNodeB[RelayConfigDataStru[index].BelongOcId][RelayConfigDataStru[index].ForeNodeCollAddrB].Pos[RelayConfigDataStru[index].ForeNodeCollPosB] = 1u; + } + else + { + } + } + else + { + } + } + else + { + } + } + else + { + } + + + + } + else + { + ; + } + + /*ɼģʽ˫ɼģʽ*/ + if ((RELAY_COLL_MODE_BACK == RelayConfigDataStru[index].CollMode) + || (RELAY_COLL_MODE_DOUBLE == RelayConfigDataStru[index].CollMode) + || (RELAY_COLL_MODE_AFORE_BBCAK == RelayConfigDataStru[index].CollMode) + || (RELAY_COLL_MODE_ABACK_BFORE == RelayConfigDataStru[index].CollMode)) + { + /*Aϵɼַ*/ + isAdded = 0u; + + for (jj = 0u; jj < CiCollBoardCurSum; jj++) + { + if (BOARD_SUM_MAX > jj) + { + if ((CiCollBoardDataStru[jj].OcId == RelayConfigDataStru[index].BelongOcId) && (RelayConfigDataStru[index].BackNodeCollAddrA == CiCollBoardDataStru[jj].BoardAddress)) + {/*ַѾ*/ + if (0u != RelayConfigDataStru[index].BelongOcId) + { + CiCollBoardDataStru[jj].OcId = (UINT8)RelayConfigDataStru[index].BelongOcId; + } + else + { + } + + if (0U != RelayConfigDataStru[index].BackNodeCollPosA) + { + CiCollBoardDataStru[jj].RelayIdBuf[RelayConfigDataStru[index].BackNodeCollPosA - 1u] + = RelayConfigDataStru[index].RelayId; + isAdded = 1u;/*ӱ־*/ + + /*********************¼ӵģ޸processiotociʱA*****************/ + if (BOARD_MAX_ADDR > RelayConfigDataStru[index].BackNodeCollAddrA) + { + if (RelayConfigDataStru[index].BackNodeCollPosA < (BOARD_POS_MAX + 1u)) + { + BoardConfigBackNodeA[RelayConfigDataStru[index].BelongOcId][RelayConfigDataStru[index].BackNodeCollAddrA].Pos[RelayConfigDataStru[index].BackNodeCollPosA] = 1u; + } + else + { + } + } + else + { + } + } + break; + } + else + { + } + } + else + { + isAdded = 1u; + } + } + if (0u == isAdded) + {/*ַδ*/ + if (0u != RelayConfigDataStru[index].BelongOcId) + { + CiCollBoardDataStru[CiCollBoardCurSum].OcId = (UINT8)RelayConfigDataStru[index].BelongOcId; + } + else + { + } + if (0U != RelayConfigDataStru[index].BackNodeCollPosA) + { + CiCollBoardDataStru[CiCollBoardCurSum].BoardAddress = RelayConfigDataStru[index].BackNodeCollAddrA; + CiCollBoardDataStru[CiCollBoardCurSum].RelayIdBuf[RelayConfigDataStru[index].BackNodeCollPosA - 1u] + = RelayConfigDataStru[index].RelayId; + CiCollBoardCurSum++; + + /*********************¼ӵģ޸processiotociʱA*****************/ + if (BOARD_MAX_ADDR > RelayConfigDataStru[index].BackNodeCollAddrA) + { + if ((BOARD_POS_MAX + 1u) > RelayConfigDataStru[index].BackNodeCollPosA) + { + BoardConfigBackNodeA[RelayConfigDataStru[index].BelongOcId][RelayConfigDataStru[index].BackNodeCollAddrA].Pos[RelayConfigDataStru[index].BackNodeCollPosA] = 1u; + } + else + { + } + } + else + { + } + } + else + { + } + } + else + { + } + + + + /*Bϵɼַ*/ + isAdded = 0u; + for (jj = 0u; jj < CiCollBoardCurSum; jj++) + { + if (jj < BOARD_SUM_MAX) + { + if ((CiCollBoardDataStru[jj].OcId == RelayConfigDataStru[index].BelongOcId) && (RelayConfigDataStru[index].BackNodeCollAddrB == CiCollBoardDataStru[jj].BoardAddress)) + {/*ַѾ*/ + if (0u != RelayConfigDataStru[index].BelongOcId) + { + CiCollBoardDataStru[jj].OcId = (UINT8)RelayConfigDataStru[index].BelongOcId; + } + else + { + } + + if (0U != RelayConfigDataStru[index].BackNodeCollPosB) + { + CiCollBoardDataStru[jj].RelayIdBuf[RelayConfigDataStru[index].BackNodeCollPosB - 1u] + = RelayConfigDataStru[index].RelayId; + isAdded = 1u;/*ӱ־*/ + + /*********************¼ӵģ޸processiotociʱB*****************/ + if (BOARD_MAX_ADDR > RelayConfigDataStru[index].BackNodeCollAddrB) + { + if (RelayConfigDataStru[index].BackNodeCollPosB < (BOARD_POS_MAX + 1u)) + { + BoardConfigBackNodeB[RelayConfigDataStru[index].BelongOcId][RelayConfigDataStru[index].BackNodeCollAddrB].Pos[RelayConfigDataStru[index].BackNodeCollPosB] = 1u; + } + else + { + } + } + else + { + } + } + else + { + } + break; + } + else + { + } + } + else + { + isAdded = 1u; + } + } + if (0u == isAdded) + {/*ַδ*/ + if (0u != RelayConfigDataStru[index].BelongOcId) + { + CiCollBoardDataStru[CiCollBoardCurSum].OcId = (UINT8)RelayConfigDataStru[index].BelongOcId; + } + else + { + } + if (0U != RelayConfigDataStru[index].BackNodeCollPosB) + { + CiCollBoardDataStru[CiCollBoardCurSum].BoardAddress = RelayConfigDataStru[index].BackNodeCollAddrB; + CiCollBoardDataStru[CiCollBoardCurSum].RelayIdBuf[RelayConfigDataStru[index].BackNodeCollPosB - 1u] + = RelayConfigDataStru[index].RelayId; + CiCollBoardCurSum++; + + /*********************¼ӵģ޸processiotociʱB*****************/ + if (BOARD_MAX_ADDR > RelayConfigDataStru[index].BackNodeCollAddrB) + { + if (RelayConfigDataStru[index].BackNodeCollPosB < (BOARD_POS_MAX + 1u)) + { + BoardConfigBackNodeB[RelayConfigDataStru[index].BelongOcId][RelayConfigDataStru[index].BackNodeCollAddrB].Pos[RelayConfigDataStru[index].BackNodeCollPosB] = 1u; + } + else + { + } + } + else + { + } + } + else + { + } + } + else + { + } + + + } + else + { + ; + } + + /*ַ*/ + if ((0u != RelayConfigDataStru[index].DrvAddrA) + && (0u != RelayConfigDataStru[index].DrvAddrB)) + { + /*Aϵַ*/ + isAdded = 0u; + for (jj = 0u; jj < CiDrvBoardCurSum; jj++) + { + if (BOARD_SUM_MAX > jj) + { + if ((CiDrvBoardDataStru[jj].OcId == RelayConfigDataStru[index].BelongDrvOcId) && (RelayConfigDataStru[index].DrvAddrA == CiDrvBoardDataStru[jj].BoardAddress)) + {/*ַѾ*/ + if (0u != RelayConfigDataStru[index].BelongDrvOcId) + { + CiDrvBoardDataStru[jj].OcId = (UINT8)RelayConfigDataStru[index].BelongDrvOcId; + } + else + { + } + + CiDrvBoardDataStru[jj].RelayIdBuf[RelayConfigDataStru[index].DrvPosA - 1u] + = RelayConfigDataStru[index].RelayId; + isAdded = 1u;/*ӱ־*/ + break; + } + else + { + } + } + else + { + isAdded = 1u; + } + } + if (0u == isAdded) + {/*ַδ*/ + if (0u != RelayConfigDataStru[index].BelongDrvOcId) + { + CiDrvBoardDataStru[CiDrvBoardCurSum].OcId = (UINT8)RelayConfigDataStru[index].BelongDrvOcId; + } + else + { + } + + CiDrvBoardDataStru[CiDrvBoardCurSum].BoardAddress = RelayConfigDataStru[index].DrvAddrA; + CiDrvBoardDataStru[CiDrvBoardCurSum].RelayIdBuf[RelayConfigDataStru[index].DrvPosA - 1u] + = RelayConfigDataStru[index].RelayId; + CiDrvBoardCurSum++; + } + else + { + } + + /*Bϵַ*/ + isAdded = 0u; + for (jj = 0u; jj < CiDrvBoardCurSum; jj++) + { + if (BOARD_SUM_MAX > jj) + { + if ((CiDrvBoardDataStru[jj].OcId == RelayConfigDataStru[index].BelongDrvOcId) && (RelayConfigDataStru[index].DrvAddrB == CiDrvBoardDataStru[jj].BoardAddress)) + {/*ַѾ*/ + if (0u != RelayConfigDataStru[index].BelongDrvOcId) + { + CiDrvBoardDataStru[jj].OcId = (UINT8)RelayConfigDataStru[index].BelongDrvOcId; + } + else + { + } + + CiDrvBoardDataStru[jj].RelayIdBuf[RelayConfigDataStru[index].DrvPosB - 1u] + = RelayConfigDataStru[index].RelayId; + isAdded = 1u;/*ӱ־*/ + break; + } + else + { + } + } + else + { + isAdded = 1u; + } + } + if (0u == isAdded) + {/*ַδ*/ + if (0u != RelayConfigDataStru[index].BelongDrvOcId) + { + CiDrvBoardDataStru[CiDrvBoardCurSum].OcId = (UINT8)RelayConfigDataStru[index].BelongDrvOcId; + } + else + { + } + + CiDrvBoardDataStru[CiDrvBoardCurSum].BoardAddress = RelayConfigDataStru[index].DrvAddrB; + CiDrvBoardDataStru[CiDrvBoardCurSum].RelayIdBuf[RelayConfigDataStru[index].DrvPosB - 1u] + = RelayConfigDataStru[index].RelayId; + CiDrvBoardCurSum++; + } + else + { + } + } + else + { + ; + } + } + else + { + ; + } + } + else + { + ; + } + } + } + return reVal; +} + +/* +* ȡ̵ +* ˵ +* ֵ +* CI_ERROR,ʧ + 0x55: + 0xaa: +*/ +UINT8 GetRelayVirtAttr(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].VirtualAttribute; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ̵ +* ˵ relayNum ̵ +* relayIdBuff ͸ļ̵ID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendRelayIdDataManage(UINT16 relayNum,const UINT16 *relayIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + totalRelayNum = GetRelayCurSum(); + + if ((totalRelayNum + relayNum) >= RELAY_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = totalRelayNum; + totalRelayNum += relayNum; + for(ii = 0u;ii< relayNum;ii++) + { + LocalCiRelayIdBuf[index+ii] = relayIdBuff[ii];/*׷ӵLocalCiRelayIdBuf*/ + } + } + + return retVal; +} + +/* +* ȡ͸Լ̵ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ̵ǰ +*/ +UINT16 GetTotalRelayCurNum(void) +{ + UINT16 retVal = 0u; + if (totalRelayNum >= RELAY_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = totalRelayNum; + } + return retVal; +} + +/**************************************ֽ---ղ****************/ + +/* +* ȡ̵Ĺղ +* ˵ +* ֵ +* CI_ERROR,ȡΪ0߻ȡʧ + >0ղ +*/ +UINT16 GetRelayLockExceptPhySecNum(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (RELAY_SUM_MAX > bufIndex) + { + retVal = RelayConfigDataStru[bufIndex].LockExceptPhySecNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡ̵ĹղID +* ˵ +* ֵ +* CI_ERROR,ʧ + 0x55: + 0xaa: +*/ +UINT16* GetRelayLockExceptPhySecIdBuf(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (RELAY_SUM_MAX > bufIndex) + { + pRetVal = RelayConfigDataStru[bufIndex].LockExceptPhySecIdBuf; + } + else + { + } + + return pRetVal; +} + +/* +* ȡָID̵ID +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRelayBelongVirCiId(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].BelongVirCIid; + } + else + { + retVal = 0u; + } + return retVal; +} +/*********************************ֽ---ղ--------------------END****/ +/* +* ȡղ̵ṹ +* ˵ void +* ֵ ղ̵ṹָ +*/ +ZhaochaCheckConfigDataStruct* GetZhaochaCheckConfigDataStru(void) +{ + return(ZhaochaCheckConfigDataStru); +} + +/* +* ȡղ̵ +* ˵ void +* ֵ ȡղ̵ +*/ +UINT16 GetZhaochaCheckConfigDataNum(void) +{ + return(CiCheckZhaoChaRelayNum); +} + + +/* +* ȡ߽ӿڼ̵ṹ +* ˵ void +* ֵ ߽ӿڼ̵ṹָ +*/ +OcConnetDataCfgStruct* GetOcConnetDataCfgStruc(void) +{ + return(OcConnetDataCfgStru); +} + +/* +* ȡ߽ӿڼ̵ +* ˵ void +* ֵ ȡ߽ӿڼ̵ +*/ +UINT16 GetOcConnetDataDevNum(void) +{ + return OcConnetDataDevNum; +} + +/* +* ȡָID̵OCID +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: OC ID +*/ +UINT16 GetRelayBelongOCId(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayConfigDataStru[bufIndex].BelongOcId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Relay/RelayConfigDataManage.h b/TSCP/src/APP/ciapp/Relay/RelayConfigDataManage.h new file mode 100644 index 0000000..6c3d8d5 --- /dev/null +++ b/TSCP/src/APP/ciapp/Relay/RelayConfigDataManage.h @@ -0,0 +1,486 @@ +/******************************************************** +* +* RelayConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ̵ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _RELAY_CONFIG_DATA_MANAGE_H_ +#define _RELAY_CONFIG_DATA_MANAGE_H_ + + + +#include "RelayDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*̵ӿݽṹ*/ +typedef struct S_RelayConfigDataStruct +{ + UINT16 RelayId; /*̵ID (ֶ)*/ + UINT8 BelongCiId; /*ID (ֶ)*/ + UINT16 BelongOcId; /*OC id*/ + UINT16 BelongDrvOcId; /*OC id*/ + UINT8 BelongVirCIid; /*OC id*/ + UINT8 CollMode; /*ɼģʽ(ǰڵ/ڵ/˫ڵ) (ֶ)*/ + UINT8 ForeNodeCollAddrA; /*Aϵǰڵɼַ (ֶ)*/ + UINT8 ForeNodeCollPosA; /*Aϵǰڵɼλ (ֶ)*/ + UINT8 BackNodeCollAddrA; /*Aϵڵɼַ (ֶ)*/ + UINT8 BackNodeCollPosA; /*Aϵڵɼַ (ֶ)*/ + UINT8 DrvAddrA; /*Aϵַ (ֶ)*/ + UINT8 DrvPosA; /*Aϵλ (ֶ)*/ + UINT8 ForeNodeCollAddrB; /*Bϵǰڵɼַ (ֶ)*/ + UINT8 ForeNodeCollPosB; /*Bϵǰڵɼλ (ֶ)*/ + UINT8 BackNodeCollAddrB; /*Bϵڵɼַ (ֶ)*/ + UINT8 BackNodeCollPosB; /*Bϵڵɼλ (ֶ)*/ + UINT8 DrvAddrB; /*Bϵַ (ֶ)*/ + UINT8 DrvPosB; /*Bϵλ (ֶ)*/ + UINT8 VirtualAttribute; /*̵*/ + UINT16 LockExceptPhySecNum; /*ղ̵ĹID*/ + UINT16 LockExceptPhySecIdBuf[MAX_LOCK_EXCEPT_SECTION_NUM]; /*ղ̵ĹID*/ +} RelayConfigDataStruct; + +/*ղ̵ݽṹ*/ +typedef struct S_ZhaochaCheckTypeStruct +{ + UINT8 CheckType; /**/ + UINT8 DevType; /* 豸 (ֶ)*/ + UINT16 DevId; /* 豸ID (ֶ)*/ +} ZhaochaCheckTypeStruct; + +/*ղ̵ݽṹ*/ +typedef struct S_ZhaochaCheckConfigDataStruct +{ + UINT16 ZhaochaRelayId; /*ղ̵ID*/ + UINT16 ZhaochaCheckSum; /*ղĿ*/ + ZhaochaCheckTypeStruct ZhaochaCheckTypeBuf[ZHAOCHA_CHECK_TYPE_SUN_MAX]; /*ղ*/ +} ZhaochaCheckConfigDataStruct; + + +/*ɼݽṹ*/ +typedef struct S_BoardDataStruct +{ + UINT8 OcId; /*oc id*/ + UINT8 BoardAddress; /*·ַ (ֶ)*/ + UINT16 RelayIdBuf[BOARD_POS_MAX]; /*·Ӧļ̵ (ֶ)*/ +} BoardDataStruct; + +/*****************OC**********************/ +typedef struct S_OcBoardDataStruct +{ + UINT16 OcId; /*OcId*/ +#if 0 + UINT16 CollBoardNum; /*ɼ忨*/ + BoardDataStruct CollBoardDataArr[OC_BOARD_SUM_MAX]; /*OC·ӦIJɼ忨ַͼ̵(ֶ)*/ +#endif + BoardDataStruct DrvBoardDataArr[OC_BOARD_SUM_MAX]; /*OC·Ӧ忨ַͼ̵ (ֶ)*/ + UINT16 DrvBoardNum; /*忨*/ +}OcDrvBoardDataStruct; + +typedef struct S_OcDrvBoardAddrsStruct +{ + UINT16 OcId; + UINT16 DrvBoardAddrArr[OC_BOARD_SUM_MAX]; + UINT8 DrvBoardSum; +}OcDrvBoardsStruct;/*һocӦ忨ַoc忨ӳϵ*/ + +/*OC ߽ӿڼ̵ñ-̵Ϣ*/ +typedef struct S_OcConnetRelayCfgStruct +{ + UINT8 RelayType; /*̵*/ + UINT16 RelayId; /*ɼ̵ID*/ + UINT16 DrvRelayId; /*̵*/ +}OcConnetRelayCfgStruct; + +/*OC ߽ӿڼ̵ñ*/ +typedef struct S_OcConnetDataCfgStruct +{ + UINT8 DevType; /* 豸 (ֶ)*/ + UINT16 DevId; /* 豸ID (ֶ)*/ + OcConnetRelayCfgStruct OcConnetRelayDataBuf[OC_LIAISON_RELAY_SUM_MAX]; /*̵*/ + UINT8 DevIsThisLine; /*豸Ƿ·*/ +}OcConnetDataCfgStruct; + + + + +/*****************OC**********************/ + +/*********************¼ӵģ޸processiotociʱ*****************/ +typedef struct S_BoardConfigStruct +{ + UINT16 Pos[BOARD_POS_MAX+1u];/*̵λ*/ +}BoardConfigStruct; + +/*******************************ȫֱ*******************************/ +/*ղ̵*/ +extern UINT16 LockExceptZhaoChaRelayNum; +/*ղ̵ID*/ +extern UINT16 LockExceptZhaoChaRelayId[MAX_LOCK_EXCEPT_ZHAO_RELAY_NUM]; + +/*ղղ̵ID*/ +extern UINT16 CiCheckZhaoChaRelayNum; +extern OcConnetDataCfgStruct OcConnetDataCfgStru[OC_LIAISON_DEV_SUM_MAX]; /*߽ӿڼ̵ñ*/ + +/*OC ߽ӿڼ̵ñ豸*/ +extern UINT16 OcConnetDataDevNum; + +/*********************¼ӵģ޸processiotociʱ*****************/ +extern BoardConfigStruct BoardConfigForeNodeA[OC_SUM_MAX][BOARD_MAX_ADDR];/*ǰڵAϵ忨*/ +extern BoardConfigStruct BoardConfigForeNodeB[OC_SUM_MAX][BOARD_MAX_ADDR];/*ǰڵBϵ忨*/ +extern BoardConfigStruct BoardConfigBackNodeA[OC_SUM_MAX][BOARD_MAX_ADDR];/*ڵAϵ忨*/ +extern BoardConfigStruct BoardConfigBackNodeB[OC_SUM_MAX][BOARD_MAX_ADDR];/*ڵBϵ忨*/ + + +extern RelayConfigDataStruct RelayConfigDataStru[RELAY_SUM_MAX]; /*̵ݽṹ*/ +extern UINT16 LocalCiRelayIdBuf[RELAY_SUM_MAX]; /*屾̵IDӳ*/ +extern INT16 RelayCurSum;/*̵ǰ*/ + +extern BoardDataStruct CiCollBoardDataStru[BOARD_SUM_MAX]; /*ɼݽṹ*/ +extern UINT16 CiCollBoardCurSum; /*ɼ嵱ǰ*/ + +extern BoardDataStruct CiDrvBoardDataStru[BOARD_SUM_MAX]; /*ݽṹ*/ +extern UINT16 CiDrvBoardCurSum; /*嵱ǰ*/ +extern ZhaochaCheckConfigDataStruct ZhaochaCheckConfigDataStru[ZHAOCHA_CHECK_SUM_MAX];/*ղ̵ݽṹ*/ + /*ղղ̵ID*/ + +/********************OC******************/ +extern OcDrvBoardDataStruct LocalCIOcDrvBoardConfigDataArr[OC_SUM_MAX];/*屾صOC忨*/ +extern UINT8 LocalCiOcSum; + +extern OcDrvBoardsStruct LocalOcDrvBoardsMap[OC_SUM_MAX];/*ocdrv忨ӳϵ*/ +extern UINT8 LocalOcSum; + + /********************OC******************/ + + +extern UINT16 totalRelayNum; + +/* +* ȡָID̵ +* ˵ const UINT16 relayId, ̵ID +* ֵ RELAY_SUM_MAX: ȡʧ +* 0: ̵ǰ +*/ +UINT16 GetRelayCurSum(void); + +/* +* ȡָ±Ӧļ̵ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetRelayId(const UINT16 bufIndex); + +/* +* ȡָID̵ID +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRelayBelongCiId(const UINT16 relayId); + +/* +* ȡָID̵ɼģʽ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ɼģʽ +*/ +UINT8 GetRelayCollectMode(const UINT16 relayId); + +/* +* ȡָID̵Aϵǰڵɼַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵǰڵɼַ +*/ +UINT8 GetRelayForeNodeCollAddrA(const UINT16 relayId); + +/* +* ȡָID̵Aϵǰڵɼλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵǰڵɼλ +*/ +UINT8 GetRelayForeNodeCollPosA(const UINT16 relayId); + +/* +* ȡָID̵Aϵڵɼַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵڵɼַ +*/ +UINT8 GetRelayBackNodeCollAddrA(const UINT16 relayId); + +/* +* ȡָID̵Aϵڵɼλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵڵɼλ +*/ +UINT8 GetRelayBackNodeCollPosA(const UINT16 relayId); + +/* +* ȡָID̵Aϵַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵַ +*/ +UINT8 GetRelayDrvAddrA(const UINT16 relayId); + +/* +* ȡָID̵Aϵλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵλ +*/ +UINT8 GetRelayDrvPosA(const UINT16 relayId); + +/* +* ȡָID̵Bϵǰڵɼַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵǰڵɼַ +*/ +UINT8 GetRelayForeNodeCollAddrB(const UINT16 relayId); + +/* +* ȡָID̵Bϵǰڵɼλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵǰڵɼλ +*/ +UINT8 GetRelayForeNodeCollPosB(const UINT16 relayId); + +/* +* ȡָID̵Bϵڵɼַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵڵɼַ +*/ +UINT8 GetRelayBackNodeCollAddrB(const UINT16 relayId); + +/* +* ȡָID̵Bϵڵɼλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵڵɼλ +*/ +UINT8 GetRelayBackNodeCollPosB(const UINT16 relayId); + +/* +* ȡָID̵Bϵַ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵַ +*/ +UINT8 GetRelayDrvAddrB(const UINT16 relayId); + +/* +* ȡָID̵Bϵλ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵλ +*/ +UINT8 GetRelayDrvPosB(const UINT16 relayId); + +/* +* ȡָIDIJɼṹ +* ˵ void +* ֵ 0: ȡʧ +* >0: ɼṹ +*/ +UINT16 GetColRelayStructSum(void); + +/* +* ȡָIDIJɼṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ȡݳɹ +*/ +BoardDataStruct* GetColRelayStruct(void); + +/* +* ȡָIDṹ +* ˵ void +* ֵ 0: ȡʧ +* >0: ɼṹ +*/ +UINT16 GetDrvRelayStructSum(void); + +/* +* ȡָIDṹ +* ˵ void +* ֵ NULL: ȡʧ +* !NULL: ȡݳɹ +*/ +BoardDataStruct* GetDrvRelayStruct(void); + +/* +* ȡָɼַλõļ̵ID +* ˵ const UINT8 RelayAdrr, ɼַ +* const UINT8 Pos, ɼλ +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetColRelayID(const UINT8 ocId, const UINT8 RelayAdrr, const UINT8 Pos); + +/* +* ȡָɼַλõļ̵ɼϢ +* ˵ const UINT8 RelayAdrr, ɼַ +* const UINT8 Pos, ɼλ +* ֵ 0: ȡʧ +* >0: ɼϢ +*/ +UINT8 GetColRelayInfo(const UINT8 ocId, const UINT8 RelayAdrr, const UINT8 Pos); + +/* +* ļ̵ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 RelayConfigDataManage(void); + +/* +* ݼ̵ɲɼ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 ConvertRelayConfigToBoardConfig(void); + +/* +* ȡ̵ +* ˵ +* ֵ +* CI_ERROR,ʧ + 0x55: + 0xaa: +*/ +UINT8 GetRelayVirtAttr(const UINT16 relayId); + +/* +* ̵ +* ˵ relayNum ̵ +* relayIdBuff ͸ļ̵ID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendRelayIdDataManage(UINT16 relayNum,const UINT16 *relayIdBuff); + +/* +* ȡ͸Լ̵ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ̵ǰ +*/ +UINT16 GetTotalRelayCurNum(void); + +/* +* ȡ̵Ĺղ +* ˵ +* ֵ +* CI_ERROR,ȡΪ0߻ȡʧ + >0ղ +*/ +UINT16 GetRelayLockExceptPhySecNum(const UINT16 relayId); + + +/* +* ȡ̵ĹղID +* ˵ +* ֵ +* CI_ERROR,ʧ + 0x55: + 0xaa: +*/ +UINT16* GetRelayLockExceptPhySecIdBuf(const UINT16 relayId); + +/* +* ʼoc忨 +* ˵ +* ֵ void +*/ +void InitOcDrvBoardCfg(void); + +/* +* Ѱ忨תoc忨 +* ˵ +* ֵ void +*/ +void ConvertBoardCfgToOcDrvBoardCfg(void); +/* +* ȡָID̵ID +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRelayBelongVirCiId(const UINT16 relayId); + +/* +* ȡղ̵ +* ˵ void +* ֵ ȡղ̵ +*/ +UINT16 GetZhaochaCheckConfigDataNum(void); + + +/* +* ȡղ̵ṹ +* ˵ void +* ֵ ղ̵ṹָ +*/ +ZhaochaCheckConfigDataStruct* GetZhaochaCheckConfigDataStru(void); + +/* +* ȡ߽ӿڼ̵ṹ +* ˵ void +* ֵ ߽ӿڼ̵ṹָ +*/ +OcConnetDataCfgStruct* GetOcConnetDataCfgStruc(void); + +/* +* ȡ߽ӿڼ̵ +* ˵ void +* ֵ ȡ߽ӿڼ̵ +*/ +UINT16 GetOcConnetDataDevNum(void); + +/* +* ȡָID̵OCID +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: OC ID +*/ +UINT16 GetRelayBelongOCId(const UINT16 relayId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Relay/RelayDataManage.c b/TSCP/src/APP/ciapp/Relay/RelayDataManage.c new file mode 100644 index 0000000..51e7fdd --- /dev/null +++ b/TSCP/src/APP/ciapp/Relay/RelayDataManage.c @@ -0,0 +1,919 @@ +/******************************************************** +* +* RelayDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2011-04-26 +* ߣ +* ̵ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "RelayDataManage.h" + + + + +RelayDataStruct RelayDataStru[RELAY_SUM_MAX]; /*̵ݽṹ*/ + +/* +* ȡָID̵ +* ˵ +* ֵ + RelayDataStruct* +*/ +RelayDataStruct* GetRelayData(void) +{ + return RelayDataStru; +} + +/* +* ȡָID̵Aϵǰڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵǰڵɼ״̬ +*/ +UINT8 GetForeNodeACollState(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵ID±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].ForeNodeACollState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵Aϵǰڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 foreNodeACollState, Aϵǰڵɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetForeNodeACollState(const UINT16 relayId, const UINT8 foreNodeACollState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if ((RELAY_STATE_DOWN == foreNodeACollState) || (RELAY_STATE_UP == foreNodeACollState)) + { + RelayDataStru[bufIndex].ForeNodeACollState = foreNodeACollState; /*̵Aϵǰڵɼ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Aϵڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵڵɼ״̬ +*/ +UINT8 GetBackNodeACollState(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].BackNodeACollState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵Aϵڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 backNodeACollState, Aϵڵɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetBackNodeACollState(const UINT16 relayId, const UINT8 backNodeACollState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if ((RELAY_STATE_DOWN == backNodeACollState) || (RELAY_STATE_UP == backNodeACollState)) + { + RelayDataStru[bufIndex].BackNodeACollState = backNodeACollState; /*̵Aϵڵɼ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Bϵǰڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵǰڵɼ״̬ +*/ +UINT8 GetForeNodeBCollState(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].ForeNodeBCollState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵Bϵǰڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 foreNodeBCollState, Bϵǰڵɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetForeNodeBCollState(const UINT16 relayId, const UINT8 foreNodeBCollState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if ((RELAY_STATE_DOWN == foreNodeBCollState) || (RELAY_STATE_UP == foreNodeBCollState)) + { + RelayDataStru[bufIndex].ForeNodeBCollState = foreNodeBCollState; /*̵Bϵǰڵɼ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵Bϵڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵڵɼ״̬ +*/ +UINT8 GetBackNodeBCollState(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].BackNodeBCollState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵Bϵڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 backNodeBCollState, Bϵڵɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetBackNodeBCollState(const UINT16 relayId, const UINT8 backNodeBCollState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if ((RELAY_STATE_DOWN == backNodeBCollState) || (RELAY_STATE_UP == backNodeBCollState)) + { + RelayDataStru[bufIndex].BackNodeBCollState = backNodeBCollState; /*̵Bϵڵɼ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵ɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 ProcessRelayCollState(const UINT16 relayId)/*liu 06-29*/ +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 colMode = 0u; /*ɼ*/ + UINT8 returnValue = CI_SUCCESS;/*ֵĬϳɹ*/ + + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex >= RELAY_SUM_MAX) + { + returnValue = CI_ERROR; + } + else + { + colMode = GetRelayCollectMode(relayId); + switch (colMode) + { + case RELAY_COLL_MODE_FORE: + /*ǰڵɼ*/ + if ((RELAY_STATE_UP == RelayDataStru[bufIndex].ForeNodeACollState) || + (RELAY_STATE_UP == RelayDataStru[bufIndex].ForeNodeBCollState)) + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_UP; + } + else + { + /*ȫֵ*/ + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN; + } + break; + case RELAY_COLL_MODE_BACK: + /*ڵɼ*/ + if ((RELAY_STATE_UP == RelayDataStru[bufIndex].BackNodeACollState) || + (RELAY_STATE_UP == RelayDataStru[bufIndex].BackNodeBCollState)) + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN; + } + else + { + + /*ȫֵ*/ + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_UP; + } + break; + case RELAY_COLL_MODE_DOUBLE: + /*˫ڵɼ*/ + if ((RELAY_STATE_UP == RelayDataStru[bufIndex].ForeNodeACollState) || + (RELAY_STATE_UP == RelayDataStru[bufIndex].ForeNodeBCollState)) + {/*ǰɼ*/ + + if ((RELAY_STATE_DOWN == RelayDataStru[bufIndex].BackNodeACollState) && + (RELAY_STATE_DOWN == RelayDataStru[bufIndex].BackNodeBCollState)) + {/*ɼ*/ + + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_UP;/*ɼΪ*/ + } + else + { + /*ǰɼһ*/ + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } + } + else if ((RELAY_STATE_DOWN == RelayDataStru[bufIndex].ForeNodeACollState) && + (RELAY_STATE_DOWN == RelayDataStru[bufIndex].ForeNodeBCollState)) + {/*ǰɼ*/ + + if ((RELAY_STATE_UP == RelayDataStru[bufIndex].BackNodeACollState) || + (RELAY_STATE_UP == RelayDataStru[bufIndex].BackNodeBCollState)) + {/*ɼ*/ + + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + } + else + { + /*ǰɼһ*/ + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } + } + else + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } + + break; + case RELAY_COLL_MODE_AFORE_BBCAK: + /*AǰBɼ*/ + if (RELAY_STATE_UP == RelayDataStru[bufIndex].ForeNodeACollState) + { + if (RELAY_STATE_DOWN == RelayDataStru[bufIndex].BackNodeBCollState) + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_UP;/*ɼΪ*/ + } + else + { + /*ǰɼһ*/ + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == RelayDataStru[bufIndex].ForeNodeACollState) + { + if (RELAY_STATE_UP == RelayDataStru[bufIndex].BackNodeBCollState) + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + } + else + { + /*ǰɼһ*/ + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } + } + else + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } + break; + case RELAY_COLL_MODE_ABACK_BFORE: + /*ABǰɼ*/ + if (RELAY_STATE_UP == RelayDataStru[bufIndex].BackNodeACollState) + { + if (RELAY_STATE_DOWN == RelayDataStru[bufIndex].ForeNodeBCollState) + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + } + else + { + /*ǰɼһ*/ + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } + } + else if (RELAY_STATE_DOWN == RelayDataStru[bufIndex].BackNodeACollState) + { + if (RELAY_STATE_UP == RelayDataStru[bufIndex].ForeNodeBCollState) + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_UP;/*ɼΪ*/ + } + else + { + /*ǰɼһ*/ + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } +#if 0 + /*԰汾δBϵ*/ + gDiDeviceIdInfo[wBufIndex].chRelayCollState = DI_OUT_DATA_UP;/*ɼΪ*/ +#endif + } + else + { + RelayDataStru[bufIndex].RelayCollState = RELAY_STATE_DOWN;/*ɼΪ*/ + returnValue = CI_ERROR; + } + break; + default: + /*ɴ֧*/ + break; + } + } + + + return returnValue; +} + +/* +* ȡָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ɼ̵״̬ +*/ +UINT8 GetRelayCollState(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].RelayCollState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ̵״̬ +*/ +UINT8 GetRelayDriveState(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].RelayDriveState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 relayDrvState, ̵״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetRelayDriveState(const UINT16 relayId, const UINT8 relayDrvState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if ((RELAY_DRIVE_STATE_DOWN == relayDrvState) || (RELAY_DRIVE_STATE_UP == relayDrvState) + || (RELAY_DRIVE_STATE_NULL == relayDrvState)) + { + RelayDataStru[bufIndex].RelayDriveState = relayDrvState; /*ָID̵״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵״̬ں +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ״̬ں +*/ +UINT32 GetRelayStateUpdateCycNum(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].StateUpdateCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵״̬ں +* ˵ const UINT16 relayId, ̵ID +* const UINT32 updateCycNum, ̵ں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetRelayStateUpdateCycNum(const UINT16 relayId, const UINT32 updateCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + + RelayDataStru[bufIndex].StateUpdateCycNum = updateCycNum; /*ָID̵״̬ں*/ + + retVal = CI_SUCCESS; + + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ü̵״̬ +* ˵ +* ֵ +*/ +void ClearRelayDriveState(void) +{ + UINT16 ii = 0u; + UINT16 relaySum = GetRelayCurSum();/*ȡ̵*/ + + for (ii = 0u; ii < relaySum; ii++) + { + (void)SetRelayDriveState(GetRelayId(ii),RELAY_DRIVE_STATE_NULL); + } +} + +/* +* ü̵ABϵɼ +* ˵ +* ֵ +*/ +void ResetRelayABCollState(void) +{ + UINT16 ii = 0u; + UINT16 relayId = 0u;/*̵ID*/ + UINT16 relaySum = GetRelayCurSum();/*ȡ̵*/ + UINT8 Resetresult = CI_ERROR; + + for (ii = 0u; ii < relaySum; ii++) + { + relayId = GetRelayId(ii); + Resetresult = SetBackNodeACollState(relayId, RELAY_STATE_DOWN);/*Aϵɼ*/ + if(CI_ERROR == Resetresult) + { + /*ʧ*/ + } + Resetresult = SetForeNodeACollState(relayId, RELAY_STATE_DOWN);/*Aϵǰɼ*/ + if(CI_ERROR == Resetresult) + { + /*ʧ*/ + } + Resetresult = SetBackNodeBCollState(relayId, RELAY_STATE_DOWN);/*Bϵɼ*/ + if(CI_ERROR == Resetresult) + { + /*ʧ*/ + } + Resetresult = SetForeNodeBCollState(relayId, RELAY_STATE_DOWN);/*Bϵǰɼ*/ + if(CI_ERROR == Resetresult) + { + /*ʧ*/ + } + } +} + +/* +* ָID̵ɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 relayColState, ̵״̬ +* ֵ +* +*/ +void SetRelayCollState(const UINT16 relayId, const UINT8 relayColState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ̵±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if ((RELAY_DRIVE_STATE_DOWN == relayColState) || (RELAY_DRIVE_STATE_UP == relayColState) + || (RELAY_DRIVE_STATE_NULL == relayColState)) + { + RelayDataStru[bufIndex].RelayCollState = relayColState; /*ָID̵ɼ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 hunXianState, ̵״̬ +* ֵ +* +*/ +void SetRelayHunXianState(const UINT16 relayId, const UINT8 hunXianState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if((RELAY_HUNXIAN_STATE_YES == hunXianState) || (RELAY_HUNXIAN_STATE_NO == hunXianState)) + { + RelayDataStru[bufIndex].RelayHunXianState = hunXianState; /*ָID̵״̬״̬*/ + } + + } + +} + +/* +* ȡָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* +* ֵ 0: ȡʧ +* >0: ̵״̬ +*/ +UINT8 GetRelayHunXianState(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].RelayHunXianState; /*ָID̵״̬״̬*/ + } + return(retVal); +} + +/* +* ȡָID̵ʼں +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetRelayHunXianStarCycNum(const UINT16 relayId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].HunXianStarCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵ʼں +* ˵ const UINT16 relayId, ̵ID +* const UINT32 updateCycNum, ̵ʼں +* ֵ +*/ +void SetRelayHunXianStarCycNum(const UINT16 relayId, const UINT32 CycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + RelayDataStru[bufIndex].HunXianStarCycNum = CycNum; /*ָID̵״̬ں*/ + } + else + { + /**/ + } +} +/* +* ȡָID̵ʼں +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ʼں +* cgh-ϲCID-2349-4 +*/ +UINT32 GetRelayDriveStartCycNum(const UINT16 relayId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].DriveStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID̵ʼں +* ˵ const UINT16 relayId, ̵ID +* const UINT32 CycNum, ̵ʼں +* ֵ +* * cgh-ϲCID-2349-4 +*/ +void SetRelayDriveStartCycNum(const UINT16 relayId, const UINT32 CycNum) +{ + UINT16 bufIndex = 0; /*±*/ + bufIndex = GetRelayConfigBufIndex(relayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + RelayDataStru[bufIndex].DriveStartCycNum = CycNum; /*ָID̵״̬ں*/ + } + else + { + /**/ + } +} + +/* +* ָID̵Aϵɼ忨״̬ +* ˵ const UINT16 wRelayId ̵ID +* const UINT8 cBoardState 忨״̬ +* ֵ void +* Created By LQ 2024.04.10 +*/ +void SetRelayACollBoardState(const UINT16 wRelayId, const UINT8 cBoardState) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetRelayConfigBufIndex(wRelayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if ((RELAY_BOARD_FAULT_NO == cBoardState) || (RELAY_BOARD_FAULT_YES == cBoardState)) + { + RelayDataStru[bufIndex].ACollBoardState = cBoardState; /*ð忨״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָID̵Aϵɼ忨״̬ +* ˵ const UINT16 wRelayId ̵ID +* ֵ 0 ȡʧ +* 0x55 忨δ +* 0xaa 忨 +* Created By LQ 2024.04.10 +*/ +UINT8 GetRelayACollBoardState(const UINT16 wRelayId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(wRelayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].ACollBoardState; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ָID̵Bϵɼ忨״̬ +* ˵ const UINT16 wRelayId ̵ID +* const UINT8 cBoardState 忨״̬ +* ֵ void +* Created By LQ 2024.04.10 +*/ +void SetRelayBCollBoardState(const UINT16 wRelayId, const UINT8 cBoardState) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetRelayConfigBufIndex(wRelayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + if ((RELAY_BOARD_FAULT_NO == cBoardState) || (RELAY_BOARD_FAULT_YES == cBoardState)) + { + RelayDataStru[bufIndex].BCollBoardState = cBoardState; /*ð忨״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָID̵Bϵɼ忨״̬ +* ˵ const UINT16 wRelayId ̵ID +* ֵ 0 ȡʧ +* 0x55 忨δ +* 0xaa 忨 +* Created By LQ 2024.04.10 +*/ +UINT8 GetRelayBCollBoardState(const UINT16 wRelayId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRelayConfigBufIndex(wRelayId); /*ȡ±*/ + + if (bufIndex < RELAY_SUM_MAX) + { + retVal = RelayDataStru[bufIndex].BCollBoardState; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Relay/RelayDataManage.h b/TSCP/src/APP/ciapp/Relay/RelayDataManage.h new file mode 100644 index 0000000..d885fa3 --- /dev/null +++ b/TSCP/src/APP/ciapp/Relay/RelayDataManage.h @@ -0,0 +1,295 @@ +/******************************************************** +* +* RelayDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ̵ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _RELAY_DATA_MANAGE_H_ +#define _RELAY_DATA_MANAGE_H_ + + + +#include "RelayConfigDataManage.h" +#include "CommonTypes.h" + + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*̵ݽṹ*/ +typedef struct S_RelayDataStruct +{ + UINT16 RelayId; /*̵ID (ʼֶ)*/ + UINT8 ForeNodeACollState; /*Aϵǰڵɼ״̬ (ֶ̬)*/ + UINT8 BackNodeACollState; /*Aϵڵɼ״̬ (ֶ̬)*/ + UINT8 ForeNodeBCollState; /*Bϵǰڵɼ״̬ (ֶ̬)*/ + UINT8 BackNodeBCollState; /*Bϵڵɼ״̬ (ֶ̬)*/ + UINT8 ACollBoardState; /*Aϵɼ忨״̬ (ֶ̬Σ0x55δϣ0xaa)*/ + UINT8 BCollBoardState; /*Bϵɼ忨״̬ (ֶ̬Σ0x55δϣ0xaa)*/ + UINT8 RelayCollState; /*̵ɼ״̬(ֶ̬)*/ + UINT8 RelayDriveState; /*̵״̬(/) (ֶ̬)*/ + UINT32 StateUpdateCycNum; /*̵ (ֶ̬)*/ + UINT8 RelayHunXianState; /*̵״̬*/ + UINT32 HunXianStarCycNum; /*̵ʼ*/ + UINT32 DriveStartCycNum; /*ʼ*/ +} RelayDataStruct; + +extern RelayDataStruct RelayDataStru[RELAY_SUM_MAX]; /*̵ݽṹ*/ + +/* +* ȡָID̵ +* ˵ +* ֵ + RelayDataStruct* +*/ +RelayDataStruct* GetRelayData(void); + +/* +* ȡָID̵Aϵǰڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵǰڵɼ״̬ +*/ +UINT8 GetForeNodeACollState(const UINT16 relayId); + +/* +* ָID̵Aϵǰڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 foreNodeACollState, Aϵǰڵɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetForeNodeACollState(const UINT16 relayId, const UINT8 foreNodeACollState); + +/* +* ȡָID̵Aϵڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Aϵڵɼ״̬ +*/ +UINT8 GetBackNodeACollState(const UINT16 relayId); + +/* +* ָID̵Aϵڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 backNodeACollState, Aϵڵɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetBackNodeACollState(const UINT16 relayId, const UINT8 backNodeACollState); + +/* +* ȡָID̵Bϵǰڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵǰڵɼ״̬ +*/ +UINT8 GetForeNodeBCollState(const UINT16 relayId); + +/* +* ָID̵Bϵǰڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 foreNodeBCollState, Bϵǰڵɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetForeNodeBCollState(const UINT16 relayId, const UINT8 foreNodeBCollState); + +/* +* ȡָID̵Bϵڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: Bϵڵɼ״̬ +*/ +UINT8 GetBackNodeBCollState(const UINT16 relayId); + +/* +* ָID̵Bϵڵɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 backNodeBCollState, Bϵڵɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetBackNodeBCollState(const UINT16 relayId, const UINT8 backNodeBCollState); + +/* +* ָID̵ɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 ProcessRelayCollState(const UINT16 relayId); + +/* +* ȡָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ɼ̵״̬ +*/ +UINT8 GetRelayCollState(const UINT16 relayId); + +/* +* ȡָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ̵״̬ +*/ +UINT8 GetRelayDriveState(const UINT16 relayId); + +/* +* ָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 relayDrvState, ̵״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetRelayDriveState(const UINT16 relayId, const UINT8 relayDrvState); + +/* +* ȡָID̵״̬ں +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ״̬ں +*/ +UINT32 GetRelayStateUpdateCycNum(const UINT16 relayId); + +/* +* ָID̵״̬ں +* ˵ const UINT16 relayId, ̵ID +* const UINT32 updateCycNum, ̵ں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetRelayStateUpdateCycNum(const UINT16 relayId, const UINT32 updateCycNum); + +/* +* ü̵״̬ +* ˵ +* ֵ +*/ +void ClearRelayDriveState(void); + +/* +* ü̵ABϵɼ +* ˵ +* ֵ +*/ +void ResetRelayABCollState(void); + +/* +* ָID̵ɼ״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 relayColState, ̵״̬ +* ֵ +* +*/ +void SetRelayCollState(const UINT16 relayId, const UINT8 relayColState); + + +/* +* ָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* const UINT8 hunXianState, ̵״̬ +* ֵ +* +*/ +void SetRelayHunXianState(const UINT16 relayId, const UINT8 hunXianState); + +/* +* ȡָID̵״̬ +* ˵ const UINT16 relayId, ̵ID +* +* ֵ 0: ȡʧ +* >0: ̵״̬ +*/ +UINT8 GetRelayHunXianState(const UINT16 relayId); + +/* +* ָID̵ʼں +* ˵ const UINT16 relayId, ̵ID +* const UINT32 updateCycNum, ̵ʼں +* ֵ +*/ +void SetRelayHunXianStarCycNum(const UINT16 relayId, const UINT32 CycNum); + +/* +* ȡָID̵ʼں +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetRelayHunXianStarCycNum(const UINT16 relayId); + +/* +* ȡָID̵ʼں +* ˵ const UINT16 relayId, ̵ID +* ֵ 0: ȡʧ +* >0: ʼں +* cgh-ϲCID-2349-4 +*/ +UINT32 GetRelayDriveStartCycNum(const UINT16 relayId); + + +/* +* ָID̵ʼں +* ˵ const UINT16 relayId, ̵ID +* const UINT32 CycNum, ̵ʼں +* ֵ +* * cgh-ϲCID-2349-4 +*/ +void SetRelayDriveStartCycNum(const UINT16 relayId, const UINT32 CycNum); + +/* +* ָID̵Aϵɼ忨״̬ +* ˵ const UINT16 wRelayId ̵ID +* const UINT8 cBoardState 忨״̬ +* ֵ void +* Created By LQ 2024.04.10 +*/ +void SetRelayACollBoardState(const UINT16 wRelayId, const UINT8 cBoardState); + +/* +* ȡָID̵Aϵɼ忨״̬ +* ˵ const UINT16 wRelayId ̵ID +* ֵ 0 ȡʧ +* 0x55 忨δ +* 0xaa 忨 +* Created By LQ 2024.04.10 +*/ +UINT8 GetRelayACollBoardState(const UINT16 wRelayId); + +/* +* ָID̵Bϵɼ忨״̬ +* ˵ const UINT16 wRelayId ̵ID +* const UINT8 cBoardState 忨״̬ +* ֵ void +* Created By LQ 2024.04.10 +*/ +void SetRelayBCollBoardState(const UINT16 wRelayId, const UINT8 cBoardState); + +/* +* ȡָID̵Bϵɼ忨״̬ +* ˵ const UINT16 wRelayId ̵ID +* ֵ 0 ȡʧ +* 0x55 忨δ +* 0xaa 忨 +* Created By LQ 2024.04.10 +*/ +UINT8 GetRelayBCollBoardState(const UINT16 wRelayId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Relay/RelayDefine.h b/TSCP/src/APP/ciapp/Relay/RelayDefine.h new file mode 100644 index 0000000..ef3d093 --- /dev/null +++ b/TSCP/src/APP/ciapp/Relay/RelayDefine.h @@ -0,0 +1,110 @@ +/******************************************************** +* +* RelayConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ̵ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _RELAY_CONFIG_H_ +#define _RELAY_CONFIG_H_ + + +/*ϵͳͷļ*/ +#include "../System/SystemConfigDefine.h" + + + +/*ֵ*/ +#define RELAY_SUM_MAX ((UINT16)5000) /*̵ֵ*/ +#define BOARD_SUM_MAX ((UINT16)240) /*һվɼĿֵ*/ +#define BOARD_POS_MAX ((UINT16)40) /*һ·ɼĿֵ*/ +#define ZHAOCHA_CHECK_SUM_MAX ((UINT16)50) /*ղ̵ղ̵ֵ*/ +#define ZHAOCHA_CHECK_TYPE_SUN_MAX ((UINT16)10) /*ղ̵ֵ*/ + +#define BOARD_COLL_POS_NUM ((UINT16)32) /*ɼϲɼ*/ +#define BOARD_DRV_POS_NUM ((UINT16)16) /**/ +#define BOARD_COLL_DATA_LEN ((UINT16)4) /*ɼϲɼֽ*/ +#define BOARD_DRV_DATA_LEN ((UINT16)2) /*ֽ*/ + +/************************OC*************************/ +#define OC_BOARD_SUM_MAX ((UINT8)44) /*һOCӦ44*/ +#define OC_COLL_BOARD_POS_NUM ((UINT16)40) /*һOC·ɼĿֵ*/ +#define OC_LIAISON_RELAY_SUM_MAX ((UINT16)3) /*߽ӿڼ̵ֵ*/ +#define OC_LIAISON_DEV_SUM_MAX ((UINT16)100) /*߽ӿڼ̵豸*/ + +/*̵״̬*/ +#define RELAY_STATE_DOWN ((UINT8)0x55) /**/ +#define RELAY_STATE_UP ((UINT8)0xaa) /**/ + + +/*̵״̬*/ +#define RELAY_DRIVE_STATE_DOWN ((UINT8)0x55) /**/ +#define RELAY_DRIVE_STATE_UP ((UINT8)0xaa) /**/ +#define RELAY_DRIVE_STATE_NULL ((UINT8)0xFF) /*Ч*/ + + +/*̵ɼ*/ +#define RELAY_COLL_FORENODE_A ((UINT8)0x01) /*Aϵǰɼ*/ +#define RELAY_COLL_FORENODE_B ((UINT8)0x02) /*Bϵǰɼ*/ +#define RELAY_COLL_BACKNODE_A ((UINT8)0x03) /*Aϵɼ*/ +#define RELAY_COLL_BACKNODE_B ((UINT8)0x04) /*Bϵɼ*/ + +/*̵ɼģʽ*/ +#define RELAY_COLL_MODE_FORE ((UINT8)0x01) /*ǰڵɼ*/ +#define RELAY_COLL_MODE_BACK ((UINT8)0x02) /*ڵɼ*/ +#define RELAY_COLL_MODE_DOUBLE ((UINT8)0x03) /*˫ڵɼ*/ +#define RELAY_COLL_MODE_AFORE_BBCAK ((UINT8)0x04) /*ǰڵɼ*/ +#define RELAY_COLL_MODE_ABACK_BFORE ((UINT8)0x05) /*ڵɼ*/ + +#define RELAY_VIRTUAL_ATTR_YES ((UINT8)0x55) /*̵*/ +#define RELAY_VIRTUAL_ATTR_NO ((UINT8)0xaa) /*̵*/ + +#define ZCJ_SUM_MAX ((UINT16)66) + +/*********************¼ӵģ޸processiotociʱ*****************/ +#define BOARD_MAX_ADDR ((UINT16)254)/*忨ַ*/ + + +#define MAX_LOCK_EXCEPT_SECTION_NUM ((UINT16)10) /*ղ̵Ĺ*/ + +#define MAX_LOCK_EXCEPT_ZHAO_RELAY_NUM ((UINT16)300) /*ղ̵*/ + +#define ZHAOCHA_CHECK_SPKS_YES ((UINT8)0x01) /*SPKSťЧ*/ +#define ZHAOCHA_CHECK_PHY_FLOCK_YES ((UINT8)0x02) /*η*/ + +#define DEV_IS_THIS_LINE_YES ((UINT8)0x55) /*豸DZ·*/ +#define DEV_IS_THIS_LINE_NO ((UINT8)0xaa) /*豸·*/ + +/*OC߼̵Ͷ*/ +#define SIGNAL_LXJ_TYPE ((UINT8)0x01) /*LXJ̵*/ +#define PHY_GJ_TYPE ((UINT8)0x02) /*GJ̵*/ +#define SWITCH_DBJ_TYPE ((UINT8)0x03) /*DBJ̵*/ +#define SWITCH_FBJ_TYPE ((UINT8)0x04) /*FBJ̵*/ +#define SWITCH_DSJ_TYPE ((UINT8)0x05) /*DSJ̵*/ +#define SWITCH_DSQJ_TYPE ((UINT8)0x06) /*DSJ̵ǰڵ㣩*/ +#define SWITCH_DSHJ_TYPE ((UINT8)0x07) /*DSJ̵ڵ㣩*/ +#define SWITCH_BYPASSJ_TYPE ((UINT8)0x08) /*·̵*/ +#define SIGNAL_YXJ_TYPE ((UINT8)0x09) /*YXJ̵*/ +#define SIGNAL_DXJ_TYPE ((UINT8)0x0A) /*DXJ̵*/ +#define CHECK_ZCJ_TYPE ((UINT8)0x0B) /*ZCJ̵*/ + +/*̵*/ +#define RELAY_HUNXIAN_NUM ((UINT8)10) /*̵*/ +#define RELAY_HUNXIAN_STATE_YES ((UINT8)0xaa) /*̵*/ +#define RELAY_HUNXIAN_STATE_NO ((UINT8)0x55) /*̵δ*/ + +/*̵ʱ*/ +#define RELAY_DRIVE_MAX_NUM ((UINT8)10) /*̵*/ + +/*̵忨״̬*/ +#define RELAY_BOARD_FAULT_NO ((UINT8)0x55) /*忨״̬δ*/ +#define RELAY_BOARD_FAULT_YES ((UINT8)0xaa) /*忨״̬*/ + +#endif + diff --git a/TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.c b/TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.c new file mode 100644 index 0000000..ae4bbcc --- /dev/null +++ b/TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.c @@ -0,0 +1,1583 @@ +#include "RRMDataPrepare.h" +#include "LinkConfigDataManage.h" +#include "SystemParameterManage.h" +#include "AxisSectionConfigDataManage.h" +#include "WLBrakeDataManage.h" +#include "EnvelopeDefine.h" +#include "ELMDataPrepare.h" +#include "EnvelopeManageAPI.h" +#include "SignalDataManage.h" +#include "dsuStruct.h" +#include "ESBDataManage.h" +#include "PSDDataManage.h" +#include "EvacuationAreaManage.h" +#include +#include "DeviceConfigDataManage.h" + +/** + * @brief ӡDebugϢ + * @param[in] UINT8 level ־ + * @param[in] const char *fmt ӡϢ + * @return + * @note ͨⲿӿڣʵֱģĴӡ + */ +void rrm_PrintDebugInfo(UINT8 level,const char *fmt, ...) +{ + va_list para; + CHAR tmpPrintBuf[RRM_PRINT_LEN] = {'\0'}; + + if (RRM_LOG_LEVEL >= level) + { + va_start(para,fmt); + (void)vsnprintf(tmpPrintBuf,RRM_PRINT_LEN,fmt,para); + va_end(para); + + debug_infor_printf((const)"%s",tmpPrintBuf); + } + else + { + /** ־𲻹*/ + } +} + + +/** +* @brief ȡRRMܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ + CI_ERROR ܹر +* @note +*/ +UINT8 rrm_PrepareRRMSwitch(void) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = GetCiFunctionSwitchConfig(FUNC_RRM_SWITCH); + + ASSERT_SETRET(FUNC_SWITCH_ON == funRtn,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + +/** +* @brief ȡվ֧ԶRMܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ + CI_ERROR ܹر +* @note +*/ +UINT8 rrm_PrepareRRMStaSwitch(void) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = GetCiFunctionSwitchConfig(FUNC_DEPART_RRM_SWITCH); + + ASSERT_SETRET(FUNC_SWITCH_ON == funRtn,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + + +/** + * @brief ȡгRRM״̬ + * @param[in] UINT16 trainID гID + * @param[out] + * @return + * @note + */ +UINT8 rrm_PrepareRRMRequest(UINT16 trainID) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = TRAIN_RRM_RQST_NO; + funRtn = GetTrainRrmRqst(trainID); + + if (TRAIN_RRM_RQST_YES == funRtn) + { + ret = CI_SUCCESS; + } + else + { + /* гδRRM */ + } + return ret; +} + +/** + * @brief ȡгһվ̨ + * @param[in] UINT16 trainID гID + * @param[out] + * @return UINT16 + * @note + */ +UINT16 rrm_PrepareNextStaOfTrain(UINT16 trainID) +{ + return GetTrainAtsLgcStation(trainID); +} + +/** + * @brief ȡгİ + * @param[in] гID + * @param[out] + * @return NULL UCT߲ѯʧܣNULLѯȷ + * @note by cgh 20240403 + */ +const EnvelopeStruct* rrm_PrepareTrainRelELM(UINT16 trainID) +{ + const EnvelopeStruct* pEnvelop = NULL; + UINT8 ElmCnt = 0u; + UINT16 envelopeId[TRAIN_REL_ENVELOPE_SUM_MAX] = { 0u }; + + ElmCnt = elm_GetTrainRelELM(trainID, envelopeId); + pEnvelop = elm_GetEnvelopeInfoByID(envelopeId[0u]); + + if ((1u == ElmCnt) && (NULL != pEnvelop) && + ((TYPE_UCT_ENVELOPE == pEnvelop->envelopeType) || (TYPE_CT_ENVELOPE == pEnvelop->envelopeType))) + { + /** ѯȷ*/ + } + else + { + pEnvelop = NULL; + } + return pEnvelop; +} + + +/** + * @brief ȡгǷΪ + * @param[in] const EnvelopeStruct* pTrainELM + * @param[out] + * @return UINT8 + CI_SUCCESS + CI_ERROR + * @note + */ +UINT8 rrm_PrepareTrainAreaIsZX(IN const EnvelopeStruct* pTrainELM) +{ + UINT8 ret = CI_ERROR; + UINT8 chTiocType = GetLocalCiType(); + UINT8 chLocalId = GetSystemParaLocalCiId(); + UINT16 headOCId = 0u; + UINT16 tailOCId = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTrainELM) || (0u == pTrainELM->ACCnt),ret,0x80000000u); + + headOCId = (UINT8)GetAxisBelongTioc(pTrainELM->ACID[pTrainELM->ACCnt - 1u]); + tailOCId = (UINT8)GetAxisBelongTioc(pTrainELM->ACID[0u]); + + if ((headOCId == tailOCId) && (headOCId == chLocalId) && ((CI_TYPE_ZX == chTiocType) || (CI_TYPE_SCX == chTiocType))) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + + return ret; +} + + +/** + * @brief ȡιATS߼վ̨ID + * @param[in] UINT16 ACID + * @param[out] + * @return UINT16 + 0:βΪվ̨ + 0xffffu:ѯʧ + ѯȷ + * @note + */ +UINT16 rrm_PrepareAtsLgcStaOfAC(UINT16 ACID) +{ + UINT16 ret = 0xffffu; + UINT8 tmpLinkcnt = 0u; + const UINT16 *pLinkIdBuf = NULL; + UINT16 startLinkofSta = 0u; + UINT16 endLinkofSta = 0u; + + + /*- ȡlinkϢ */ + tmpLinkcnt = GetAxisLinkSum(ACID); + pLinkIdBuf = GetAxisLinkIdBuf(ACID); + + if ((0u == tmpLinkcnt) || (NULL == pLinkIdBuf)) + { + /** ѯʧ */ + } + else + { + startLinkofSta = GetLinkPlatfrm(pLinkIdBuf[0u]); + endLinkofSta = GetLinkPlatfrm(pLinkIdBuf[tmpLinkcnt - 1u]); + + if (startLinkofSta == endLinkofSta) + { + ret = startLinkofSta; + } + else + { + /** ѯʧ */ + } + } + + return ret; +} + + +/** + * @brief ȡǷΪ۷ + * @param[in] UINT16 ACID + * @param[out] + * @return UINT8 + CI_SUCCESS ۷ + CI_ERROR Ϊ۷ + * @note + */ + UINT8 rrm_PrepareACisRevertArea(UINT16 ACID) + { + UINT8 ret = CI_ERROR; + UINT8 tmpLinkcnt = 0u; + const UINT16 *pLinkIdBuf = NULL; + UINT8 cycle = 0u; + UINT8 isRevertArea = LINK_REVERT_AREA_NO; + + /*- ȡlinkϢ */ + tmpLinkcnt = GetAxisLinkSum(ACID); + pLinkIdBuf = GetAxisLinkIdBuf(ACID); + + if ((0u == tmpLinkcnt) || (NULL == pLinkIdBuf)) + { + /** ѯʧ */ + } + else + { + for (cycle = 0u; cycle < tmpLinkcnt;cycle++) + { + isRevertArea = IsLinkRevertArea(pLinkIdBuf[cycle]); + + if (CI_SUCCESS != isRevertArea) + { + break; + } + } + + if (cycle == tmpLinkcnt) + {/** ۷ */ + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + return ret; + } + + + /** + * @brief η + * @param[in] const UINT16 wCurACID ǰID + * @param[in] const UINT16 wNextACID һID + * @param[out] + * @return UINT8 + CI_SUCCESS ͨ + CI_ERROR 鲻ͨ + CI_TRUE ޱ + * @note by cgh 20240425 + */ + UINT8 rrm_PrepareACisOverlapLock(const UINT16 wCurACID, const UINT16 wNextACID) + { + UINT8 chReVal = CI_ERROR; + UINT16 wCurPhySecId = 0U;/*ǰID*/ + UINT16 wNextPhySecId = 0U;/*һID*/ + UINT16 wCurPhySecLockRouteId = 0U;/*ǰ·*/ + UINT16 wNextPhySecLockRouteId = 0U;/*һ·*/ + UINT8 chOverlopExistCheck = CI_ERROR;/*δڼ*/ + UINT16 wPhySecPLockRouteId = 0U;/*η·*/ + UINT16 chOverlopId = 0U;/*ID*/ + + if ((0U < wCurACID) && (AXIS_SECTION_SUM_MAX > wCurACID) && (0U < wNextACID) && (AXIS_SECTION_SUM_MAX > wNextACID)) + { + wCurPhySecId = GetAxisSecRelativePhySecId(wCurACID); + wNextPhySecId = GetAxisSecRelativePhySecId(wNextACID); + + if ((0U < wCurPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wCurPhySecId) && (0U < wNextPhySecId) && (PHYSICAL_SECTION_SUM_MAX > wNextPhySecId)) + { + wCurPhySecLockRouteId = GetPhySecRLockBelongRouteId(wCurPhySecId); + wNextPhySecLockRouteId = GetPhySecRLockBelongRouteId(wNextPhySecId); + + if ((wCurPhySecLockRouteId == wNextPhySecLockRouteId) && (0U != wCurPhySecLockRouteId)) + { + /*վ̨κվ̨·һ£·޳վźŻʱռɣ*/ + chReVal = CI_SUCCESS; + } + else + { + chOverlopExistCheck = rrm_OverlapExistCheck(wCurACID); + + if (CI_SUCCESS == chOverlopExistCheck) + { + chReVal = CI_TRUE; /*ûбΣ˲ɹ*/ + } + else + { + wPhySecPLockRouteId = GetPhySecPLockBelongRouteId(wNextPhySecId); + if(wCurPhySecLockRouteId == wPhySecPLockRouteId) + { + chOverlopId = GetRouteOverlapLockedId(wPhySecPLockRouteId); + chReVal = OverlapUsableCheck(chOverlopId); + } + else + { + chReVal = CI_ERROR; /*վ̨·վηղһ£ʧ*/ + } + } + } + } + else + { + ; /*Ƿ*/ + } + } + else + { + ; /*Ƿ*/ + } + + return chReVal; + } + +/** + * @brief ȡгз򼰼 + * @param[in] UINT16 trainID гID + * @param[out] UINT8 *pDir г + * @param[out] UINT8 *pACT г + * @return + * @note + */ +void rrm_PrepareTrainDirAndAct(UINT16 trainID,OUT UINT8 *pDir,OUT UINT8 *pACT) +{ + /** ڲУ */ + ASSERT_RET_NO_VALUE(NULL == pDir,0x80000000u); + ASSERT_RET_NO_VALUE(NULL == pACT,0x40000000u); + + *pDir = GetTrainDir(trainID); + *pACT = GetTrainActive(trainID); +} + + +/** + * @brief ȡȫ߽״̬ + * @param[in] + * @param[out] + * @return UINT8 + CI_SUCCESS ȫ߽״̬ + CI_ERROR δȫ߽״̬ + * @note + */ +UINT8 rrm_PrepareWLBrake(void) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = WlbGetState(); + + /** ÷ֵ */ + ASSERT_SETRET(WLB_SET == funRtn,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + +/** + * @brief ȡͷռѹǰǷ + * @param[in] const EnvelopeStruct* pTemp Ϣ + * @param[out] + * @return UINT8 + CI_SUCCESS ǰ + CI_ERROR ǰ + * @note + */ +UINT8 rrm_PrepareForwardTrain(IN const EnvelopeStruct* pTemp) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 funRtn = 0u; + UINT8 elmCnt = 0u; + UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + const EnvelopeStruct* pTempInfo = NULL; + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0u == pTemp->ACCnt),ret,0x80000000u); + + /** ȡϵİϢ */ + elmCnt = elm_GetEnvelopeIDsInAC(pTemp->ACID[pTemp->ACCnt - 1u],envelopeIDs); + + if (SECTION_REL_ENVELOPE_SUM_MAX <= elmCnt) + { + /** ѯ*/ + } + else + { + for (cycle = 0u; cycle < elmCnt; cycle++) + { + pTempInfo = elm_GetEnvelopeInfoByID(envelopeIDs[cycle]); + + if (NULL == pTempInfo) + { + /** ѯ*/ + break; + } + else + { + if (pTempInfo->id == pTemp->id) + { + /** 磬 */ + } + else + { + /** Ƚϰǰϵ */ + funRtn = elm_PrepareRelationBtwEnvelope(pTemp,pTemp->startPos,pTempInfo); + + if (0x01U == funRtn) + { + /** AڰBǰ, */ + } + else + { + /** ǰڰ磬ѭ */ + break; + } + } + } + } + + if (cycle == elmCnt) + { + /** ǰ */ + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + return ret; +} + + +/** + * @brief ȡβڼǷڱ + * @param[in] UINT16 trainID гID + * @param[in] const EnvelopeStruct* pTemp гϢ + * @param[out] + * @return UINT8 + CI_SUCCESS 󷽲ڱ + CI_ERROR 󷽴ڱ + * @note + */ +UINT8 rrm_PrepareBackHaveSameTrain(UINT16 trainID,IN const EnvelopeStruct* pTemp) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 localOCId = GetSystemParaLocalCiId(); + UINT8 cycle = 0u; + UINT8 cycleElm = 0u; + UINT8 cycleTrain = 0u; + UINT8 acCnt = 0u; + UINT16 arACID[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT8 nextOCId = 0u; + UINT8 ACIsOwn = 0u; + UINT8 elmCnt = 0u; + UINT8 trainIsOwn = 0u; + UINT16 tailLinkID = 0u; + UINT16 tailBelongOCId = 0u; + UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + const EnvelopeStruct* pTempInfo = NULL; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0u == pTemp->ACCnt),ret,0x80000000u); + + /** ѯβ󷽼 */ + acCnt = elm_PrepareAdjacentAC(pTemp->ACID[0u], ((UINT8)~(pTemp->startPos.Dir)), arACID, &cDirectionPointFlag); + + if (UINT8_MAX == acCnt) + { + /** ѯʧܣᱨ */ + errorCode += 0x40000000u; + } + else + { + /** 鿴ͨųȫβǷڱOC */ + if (TYPE_CT_ENVELOPE == pTemp->envelopeType) + { + /** ȡгȫβ */ + tailLinkID = GetTrainSafeTailLink(trainID); + + /** ȡβOC */ + tailBelongOCId = (UINT8)GetLinkManageTiocById(tailLinkID); + + if (tailBelongOCId == localOCId) + { + trainIsOwn = ELM_BELONG_OWNER; + } + else + { + trainIsOwn = ELM_BELONG_OTHER; + } + } + else + { + /** CT磬 */ + } + + + for (cycle = 0u; cycle < acCnt;cycle++) + { + /** ȡǷڱ */ + ACIsOwn = rrm_PrepareACIsSelf(arACID[cycle],&nextOCId); + + /** ȡϵİϢ */ + elmCnt = elm_GetEnvelopeIDsInAC(arACID[cycle],envelopeIDs); + + /** жǷ˳ */ + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX <= elmCnt,errorCode,0x20000000u); + + if ((0u == elmCnt) || (ELM_BELONG_OWNER == ACIsOwn)) + { + /** 󷽼᲻ڰڱOC */ + } + else + { + for (cycleElm = 0u; cycleElm < elmCnt; cycleElm++) + { + pTempInfo = elm_GetEnvelopeInfoByID(envelopeIDs[cycleElm]); + + /** жǷ˳ */ + ASSERT_BREAK((NULL == pTempInfo) || (0u == pTempInfo->trianCnt),errorCode,0x10000000u); + + /** 󷽰ڱTIOC㱨 */ + for (cycleTrain = 0u; cycleTrain < pTempInfo->trianCnt;cycleTrain++) + { + if (((ELM_BELONG_OWNER != ACIsOwn) && (TYPE_UKT_ENVELOPE == pTempInfo->envelopeType) && (TYPE_UCT_ENVELOPE == pTemp->envelopeType)) + || ((ELM_BELONG_OTHER == trainIsOwn) && (TYPE_UKT_ENVELOPE == pTempInfo->envelopeType) && (TYPE_CT_ENVELOPE == pTemp->envelopeType)) + ||(pTempInfo->trainID[cycleTrain] == trainID)) + { + /** UCT󷽼ΪDZΪUTռѹ߿ֽ󷽼ΪDZΪUTռѹߺ󷽰ڱ */ + errorCode += 0x08000000u; + break; + } + else + { + /** */ + } + } + + /** 󷽰ڱѭ */ + ASSERT_BREAK(cycleTrain != pTempInfo->trianCnt,errorCode,0x04000000u); + } + + /** ѯʧܻߺ󷽰ڱTIOC㱨 */ + ASSERT_BREAK(cycleElm != elmCnt,errorCode,0x02000000u); + } + } + + if (cycle == acCnt) + { + /** 󷽲ڱ */ + ret = CI_SUCCESS; + } + else + { + /** ѯʧܻߺ󷽴ڱ */ + ret = CI_ERROR; + ASSER_DEBUG(0u != errorCode,RRM_LOG(RRM_LOG_ERROR,"errno:0x%08x info:Train%d back has sameTrain.",errorCode,trainID)); + } + } + + return ret; +} + +/** + * @brief ȡβ߼ + * @param[in] UINT16 trainID гID + * @param[in] const EnvelopeStruct* pTemp Ϣ + * @param[out] + * @return UINT16 + ѯʧܣ0 + ѯɹβ߼ + * @note + */ +UINT16 rrm_PrepareSecIDofTail(UINT16 trainID,IN const EnvelopeStruct* pTemp) +{ + UINT16 ret = 0u; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT8 logSectionSum = 0; + UINT16 *logIdBuf = NULL; + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0u == pTemp->ACCnt),ret,0x80000000u); + + /** ѯβ󷽼Ƿڱ */ + funRtn = rrm_PrepareBackHaveSameTrain(trainID,pTemp); + + if (CI_SUCCESS == funRtn) + { + /*ȡ߼Ϣ*/ + logSectionSum = GetAxisSecLogSectionSum(pTemp->ACID[0u]); + logIdBuf = GetAxisSecLogSectionIdBuf(pTemp->ACID[0u]); + + if ((0u == logSectionSum) || (NULL == logIdBuf)) + { + /** ѯ */ + errorCode += 0x40000000u; + } + else + { + if (ELM_DIR_SAME == pTemp->startPos.Dir) + { + ret = logIdBuf[0u]; + } + else + { + ret = logIdBuf[logSectionSum - 1u]; + } + } + } + else + { + /** ӡάϢ */ + ASSER_DEBUG(0u != errorCode,RRM_LOG(RRM_LOG_ERROR,"errno:0x%08x info:Train%d not report to ATS.",errorCode,trainID)); + } + + return ret; +} + + /** + * @brief ѯǰ/󷽼 + * @param[in] UINT16 ACID ׼ID + * @param[in] UINT8 dir ѯ + * @param[out] UINT16 arACID[AC_MAXCNT_IN_SWITCH] ڼID + * @return UINT8_MAX ѯʧ + 0~AC_MAXCNT_IN_SWITCH ѯɹ + * @note + */ +UINT8 rrm_PrepareAdjacentAC(UINT16 ACID, UINT8 dir, INOUT UINT16 arACID[AC_MAXCNT_IN_SWITCH], OUT UINT8* directionPointFlag) +{ + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 retVal = 0U; + + retVal = elm_PrepareAdjacentAC(ACID, dir, arACID, &cDirectionPointFlag); + + *directionPointFlag = cDirectionPointFlag; + return retVal; +} + +/** + * @brief ȡǷڱOC + * @param[in] UINT16 acID ID + * @param[out] UINT8 *pOCId OCid + * @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ + * @note + */ +UINT8 rrm_PrepareACIsSelf(UINT16 acID,UINT8 *pOCId) +{ + return elm_PrepareACIsSelf(acID,pOCId); +} + + +/** + * @brief ȡѰ· + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT16 + 0δѰ· + Ѱ·ID + * @note + */ +UINT16 rrm_PrepareAcofRoute(UINT16 acID) +{ + return GetAxisSecLockBelongRoute(acID); +} + + + /** + * @brief ȡ·ʼźŻ״̬ + * @param[in] UINT16 routeID ·ID + * @param[out] + * @return UINT8 + CI_SUCCESS źŻ + CI_ERROR źŻر + * @note + */ +UINT8 rrm_PrepareOriginSigStatOfRoute(UINT16 routeID) +{ + UINT8 ret = CI_ERROR; + UINT16 sigId = 0u; + UINT8 sigColor = 0u; + UINT8 sigStatus = SIGNAL_CLOSE; + + sigId = GetRouteStartSignalId(routeID); + + if (0u == sigId) + { + /** ѯʧ*/ + } + else + { + /** ȡź״̬ */ + sigColor = GetSignalCurColor(sigId); + sigStatus = GetSignalOpenCloseState(sigColor); + + /** úֵ */ + ASSERT_SETRET(SIGNAL_OPEN == sigStatus,ret,CI_SUCCESS,CI_ERROR); + } + return ret; +} + +/** + * @brief ͨIDȡ״̬ + * @param[in] UINT16 ACID ID + * @return ELM_AC_OCC ռ + ELM_AC_FREE + * @note + */ +UINT8 rrm_PrepareACStatus(UINT16 ACID) +{ + return elm_PrepareACStatus(ACID); +} + + +/** + * @brief ȡε״̬շ + * @param[in] UINT16 ACID ID + * @param[in] UINT16 flag + * @param[out] UINT8* pLockStat ״̬ + * @param[out] UINT8* pLockDir շ + * @return + * @note + */ +void rrm_PrepareACLockStatAndDir(UINT16 ACID,UINT8 flag,OUT UINT8* pLockStat,OUT UINT8* pLockDir) +{ + UINT16 phyID = 0U; + UINT16 RLockBelongRouteId = 0U; + UINT16 PLockBelongRouteId = 0U; + UINT8 LockStatus = PHYSICAL_SECTION_LOCK_NO; + UINT8 tmpDir = 0U; + UINT8 LockDir = 0U; + UINT8 chPhySecLockShouldOppsed = ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK;/*շǷӦȡ*/ + + /** ڲУ */ + ASSERT_RET_NO_VALUE(NULL == pLockStat,0x80000000u); + ASSERT_RET_NO_VALUE(NULL == pLockDir,0x40000000u); + + /** ͨλȡȡID */ + phyID = GetAxisSecRelativePhySecId(ACID); + + if (TYPE_OF_PATH_C == flag) + { + RLockBelongRouteId = GetPhySecRLockBelongRouteId(phyID); + PLockBelongRouteId = GetPhySecPLockBelongRouteId(phyID); + } + else + { + RLockBelongRouteId = GetPhySecRLockBelongRouteId(phyID); + } + + //ȡ״̬ + LockStatus = GetPhySecLockState(phyID); + /** ȡշ */ + tmpDir = GetPhySecLockDirection(phyID); + + if (0U < RLockBelongRouteId) + { + chPhySecLockShouldOppsed = GetRoutePhySecShouldLockOppose(RLockBelongRouteId, phyID); + if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == chPhySecLockShouldOppsed) + { + tmpDir = ~tmpDir; + } + } + LockDir = ConvertDirectionToLogic(tmpDir); + + if (((0u == RLockBelongRouteId) && (0u == PLockBelongRouteId)) || (DIR_INVALID == LockDir) + || ((PHYSICAL_SECTION_LOCK_NORMAL != LockStatus) && (PHYSICAL_SECTION_LOCK_PROTECT != LockStatus))) + { + (*pLockStat) = SEC_LOCK_ERROR; + (*pLockDir) = 0u; + } + else + { + (*pLockStat) = SEC_LOCK_OK; + (*pLockDir) = LockDir; + } +} + +/** + * @brief ȡη״̬ͷԭ + * @param[in] UINT16 acID ID + * @param[out] UINT8 *pFlockStatus ״̬ + * @param[out] UINT8 *pFlockType ԭ + * @return + * @note + */ +void rrm_PrepareACFLockStatusAndType(UINT16 acID,OUT UINT8 *pFlockStatus,OUT UINT8 *pFlockType) +{ + UINT16 phyID = 0u; + + /** ڲУ */ + ASSERT_RET_NO_VALUE(NULL == pFlockStatus,0x80000000u); + ASSERT_RET_NO_VALUE(NULL == pFlockType,0x40000000u); + + /** ͨλȡȡID */ + phyID = GetAxisSecRelativePhySecId(acID); + + /** ȡ״̬ͷ */ + (*pFlockStatus) = GetPhySecFLockState(phyID); + (*pFlockType) = GetPhySecFLockType(phyID); +} + + + /** + * @brief ȡĵλǷȷ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS λȷ + CI_ERROR λòȷ + * @note + */ +UINT8 rrm_PrepareSwitchStatOfAC(UINT16 acID) +{ + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 tmpSwPos = SWITCH_POSITION_INVALID; + UINT8 tmpSwCntInAC = 0u; + const AxisSwitchStruct * pSwitchInfoBuf = NULL; + + /** ȡϵĵϢ*/ + tmpSwCntInAC = GetAxisSwitchSum(acID); + pSwitchInfoBuf = GetAxisSwitchIdStru(acID); + + if (NULL == pSwitchInfoBuf) + { + /** ѯ */ + } + else + { + for (cycle = 0u; cycle < tmpSwCntInAC; cycle++) + { + tmpSwPos = GetSwitchCurPosition(pSwitchInfoBuf[cycle].SwitchId); + + if (tmpSwPos == pSwitchInfoBuf[cycle].SwitchPosition) + { + /** λȷ*/ + } + else + { + /** λòȷ */ + break; + } + } + /** úֵ */ + ASSERT_SETRET(cycle == tmpSwCntInAC,ret,CI_SUCCESS,CI_ERROR); + } + return ret; +} + +/** + * @brief ȡϹESBǷ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS ESBδ + CI_ERROR ESB + * @note + */ + UINT8 rrm_PrepareESBStatOfAC(UINT16 acID) + { + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 cycleESB = 0u; + UINT8 chLinkNum = 0u; + UINT8 ESBStatus = ESB_STATE_VALID_YES; + const UINT16 *pLinkIdBuf = NULL; + const DSU_DEVICE_IN_LINK_STRU* pTempDeviceStru = NULL; + + chLinkNum = GetAxisLinkSum(acID); + pLinkIdBuf = GetAxisLinkIdBuf(acID); + + if ((0u == chLinkNum) || (NULL == pLinkIdBuf)) + { + /** ѯʧ*/ + } + else + { + for (cycle = 0u; cycle < chLinkNum;cycle++) + { + /** Ƿȷ*/ + if ((NULL == g_dsuEmapExtendStru) || (NULL == g_dsuEmapExtendStru->pDsuDeviceInLinkIdx) || (NULL == g_dsuEmapStru) + || (pLinkIdBuf[cycle] > g_dsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM) || (0xFFFFU == g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkIdBuf[cycle]])) + { + /** ڲ쳣ѯʧ*/ + break; + } + else + { + /** ҵLink豸ӳϵϢַ*/ + pTempDeviceStru = g_dsuEmapExtendStru->pDsuDeviceInLinkIdx + pLinkIdBuf[cycle]; + + if (NULL != pTempDeviceStru) + { + /*- LinkESB */ + for (cycleESB = 0u;cycleESB < pTempDeviceStru->struESBDev.wDevCount;cycleESB++) + { + ESBStatus = GetEsbState(pTempDeviceStru->struESBDev.wDevSetId[cycleESB]); + + if (ESB_STATE_VALID_NO == ESBStatus) + { + /** ESBδ£*/ + } + else + { + break; + } + } + + if (cycleESB != pTempDeviceStru->struESBDev.wDevCount) + { + break; + } + else + { + /** */ + } + } + else + { + /** ѯʧ*/ + break; + } + } + } + + /** úֵ */ + ASSERT_SETRET(cycle == chLinkNum,ret,CI_SUCCESS,CI_ERROR); + } + + return ret; + } + + + /** + * @brief ȡϹPSDǷ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS PSDδ + CI_ERROR PSD + * @note + */ + UINT8 rrm_PreparePSDStatOfAC(UINT16 acID) + { + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 cyclePSD = 0u; + UINT8 chLinkNum = 0u; + UINT8 PSDStatus = PSD_STATE_OPEN; + const UINT16 *pLinkIdBuf = NULL; + const DSU_DEVICE_IN_LINK_STRU* pTempDeviceStru = NULL; + + chLinkNum = GetAxisLinkSum(acID); + pLinkIdBuf = GetAxisLinkIdBuf(acID); + + if ((0u == chLinkNum) || (NULL == pLinkIdBuf)) + { + /** ѯʧ*/ + } + else + { + for (cycle = 0u; cycle < chLinkNum;cycle++) + { + /** Ƿȷ*/ + if ((NULL == g_dsuEmapExtendStru) || (NULL == g_dsuEmapExtendStru->pDsuDeviceInLinkIdx) || (NULL == g_dsuEmapStru) + || (pLinkIdBuf[cycle] > g_dsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM) || (0xFFFFU == g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[pLinkIdBuf[cycle]])) + { + /** ڲ쳣ѯʧ*/ + break; + } + else + { + /** ҵLink豸ӳϵϢַ*/ + pTempDeviceStru = g_dsuEmapExtendStru->pDsuDeviceInLinkIdx + pLinkIdBuf[cycle]; + + if (NULL != pTempDeviceStru) + { + /*- LinkPSD */ + for (cyclePSD = 0u;cyclePSD < pTempDeviceStru->struScreenDev.wDevCount;cyclePSD++) + { + PSDStatus = GetPsdState(pTempDeviceStru->struScreenDev.wDevSetId[cyclePSD]); + + if (PSD_STATE_CLOSE == PSDStatus) + { + /** Źرգ*/ + } + else + { + break; + } + } + + if (cyclePSD != pTempDeviceStru->struScreenDev.wDevCount) + { + break; + } + else + { + /** */ + } + } + else + { + /** ѯʧ*/ + break; + } + } + } + + /** úֵ */ + ASSERT_SETRET(cycle == chLinkNum,ret,CI_SUCCESS,CI_ERROR); + } + + return ret; + } + + + /** + * @brief ȡǷ˰ȫǷڰȫ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS δаȫ + CI_ERROR ν˰ȫ + * @note + */ + UINT8 rrm_PrepareSafeProtectOfAC(UINT16 acID) + { + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT8 cycle = 0u; + UINT8 chLgcNum = 0u; + const UINT16 *pLgcIdBuf = NULL; + + chLgcNum = GetAxisSecLogSectionSum(acID); + pLgcIdBuf = GetAxisSecLogSectionIdBuf(acID); + + if ((0u == chLgcNum) || (NULL == pLgcIdBuf)) + { + /** ѯʧ */ + } + else + { + for (cycle = 0u;cycle < chLgcNum; cycle++) + { + funRtn = IsLgcInEa(pLgcIdBuf[cycle]); + if (CI_SUCCESS == funRtn) + { + /** ڷ*/ + } + else + { + /** ڷ */ + break; + } + } + + /** úֵ */ + ASSERT_SETRET(cycle == chLgcNum,ret,CI_SUCCESS,CI_ERROR); + } + + return ret; + } + + + /** + * @brief ȡǷ޻߲ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS δаȫ + CI_ERROR ν˰ȫ + * @note + */ + UINT8 rrm_PrepareVainAndLtrlDfncCheck(UINT16 acID) + { + UINT8 ret = CI_ERROR; + UINT8 cycle = 0u; + UINT8 VainCheckFlag = CI_ERROR; + UINT8 LtrlDfncCheckFlag = CI_ERROR; + UINT8 chLogSecCnt = 0u; + const UINT16* pLogSecCntBuff = NULL; + UINT16 DevId = 0u; + UINT8 DevState = 0u; + + /** ȡ߼ID */ + chLogSecCnt = GetAxisSecLogSectionSum(acID); + pLogSecCntBuff = GetAxisSecLogSectionIdBuf(acID); + + if ((0u == chLogSecCnt) || (NULL == pLogSecCntBuff)) + { + /** ѯ */ + } + else + { + for (cycle = 0u; cycle < chLogSecCnt;cycle++) + { + VainCheckFlag = LogicIntruSecVainCheck(pLogSecCntBuff[cycle],&DevId,&DevState); + LtrlDfncCheckFlag = LogicSecSwitchLtrlDfncCheck(pLogSecCntBuff[cycle],&DevId,&DevState); + + if ((CI_ERROR == VainCheckFlag) || (CI_ERROR == LtrlDfncCheckFlag)) + { + break; + } + else + { + /** */ + } + } + + + /** úֵ */ + ASSERT_SETRET(cycle == chLogSecCnt,ret,CI_SUCCESS,CI_ERROR); + } + + return ret; + } + + /** + * @brief ȡǰزѯĶ˵ǷΪ仯㣨Ԥ߹ܣ + * @param[in] UINT16 acID ID + * @param[in] UINT8 Dir ѯ + * @param[out] + * @return UINT8 + DIR_CHANGE: ڷ仯 + DIR_UNCHANGE ڷ仯 + UINT8_MAX ѯʧ + * @note + */ + UINT8 rrm_PrepareDirChangeOfAC(UINT16 acID,UINT8 Dir) + { + UINT8 ret = DIR_UNCHANGE; + return ret; + } + + /** + * @brief гRRMȨ״̬ȨɼһTIOC ID + * @param[in] UINT16 trainID гID + * @param[in] UINT8 rrmReply rrmȨ״̬ + * @param[in] UINT8 rrmReason rrmȨ + * @param[in] UINT8 nextOCId һTIOC ID + * @param[out] + * @return + * @note + */ +void rrm_SetRRMResult(UINT16 trainID,UINT8 rrmReply,UINT8 rrmReason,UINT8 nextOCId) +{ + UINT16 wRcIdWithType = 0x3c00U; + + wRcIdWithType |= (UINT16)nextOCId; + + SetTrainRrmState(trainID,rrmReply); + SetTrainRrmReson(trainID,rrmReason); + SetTrainNextTioc(trainID, wRcIdWithType); /*һID0x3cIVOCʱ޷ȡͨID*/ +} + +/** + * @brief ȡ·Ƿڱ + * @param[in] UINT16 CurACID ǰ + * @param[out] + * @return UINT8 + CI_SUCCESS ߱ + CI_ERROR ߱ + * @note by cgh 20231102 ֧һվ̨ñԶRM + */ +UINT8 rrm_OverlapExistCheck(UINT16 CurACID) +{ + UINT8 chReval = CI_ERROR; + UINT16 wCurAcRelatePhyId = 0U;/*ǰιID*/ + UINT16 wRLockBelongRouteId = 0U;/*·*/ + UINT16 wRouteIdOverlopSum = 0U;/*·Ŀ*/ + + if ((0U < CurACID) && (AXIS_SECTION_SUM_MAX > CurACID)) + { + wCurAcRelatePhyId = GetAxisSecRelativePhySecId(CurACID); + if ((0U < wCurAcRelatePhyId) && (PHYSICAL_SECTION_SUM_MAX > wCurAcRelatePhyId)) + { + wRLockBelongRouteId = GetPhySecRLockBelongRouteId(wCurAcRelatePhyId); + if ((0U < wRLockBelongRouteId) && (ROUTE_SUM_MAX > wRLockBelongRouteId)) + { + wRouteIdOverlopSum = GetRouteOverlapSum(wRLockBelongRouteId); + if (0U == wRouteIdOverlopSum) + { + chReval = CI_SUCCESS; + } + else + { + ; /*ʧ*/ + } + } + else + { + ; /*ʧ*/ + } + } + else + { + ; /*ʧ*/ + } + } + else + { + ; /*ʧ*/ + } + + return chReval; +} + +/** + * @brief ȡϹķ״̬ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS ״̬ͨ + CI_ERROR ״̬鲻ͨ + * @note by cgh 20240222 + */ +UINT8 rrm_PrepareFGStatOfAC(UINT16 acID) +{ + UINT8 ret = CI_ERROR; + UINT16 ii = 0U; + UINT16 wCurAcRelatePhyId = 0U;/*ǰιID*/ + UINT16 wPhySecRelFloodGateNum = 0U; /*ιķ*/ + UINT16* pPhyLocatedFloodId = NULL;/*ڷID*/ + UINT8 chFloodState = 0u;/*״̬*/ + + if ((0U < acID) && (AXIS_SECTION_SUM_MAX > acID)) + { + wCurAcRelatePhyId = GetAxisSecRelativePhySecId(acID); + if ((0U < wCurAcRelatePhyId) && (PHYSICAL_SECTION_SUM_MAX > wCurAcRelatePhyId)) + { + + wPhySecRelFloodGateNum = GetPhySecLocatedFloodSum(wCurAcRelatePhyId); + pPhyLocatedFloodId = GetPhySecLocatedFloodId(wCurAcRelatePhyId); + + if ((0U == wPhySecRelFloodGateNum) && (NULL != pPhyLocatedFloodId)) + { + /*IDϷҲţͨ*/ + ret = CI_SUCCESS; + } + else if ((FLOOD_GATE_SUM_MAX > wPhySecRelFloodGateNum) && (NULL != pPhyLocatedFloodId)) + { + /*1ſ״̬Ϊ*/ + for (ii = 0U; ii < wPhySecRelFloodGateNum; ii++) + { + chFloodState = GetFloodGateCurOpenLockState(pPhyLocatedFloodId[ii]); + if (FLOOD_GATE_OPENLOCK == chFloodState) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + + /*2Ź״̬Ϊδ*/ + if (CI_SUCCESS == ret) + { + chFloodState = GetFloodGateCurCloseRequestSta(pPhyLocatedFloodId[ii]); + if (FLOOD_GATE_NOT_CLOSEREQ == chFloodState) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + + /*3ŵǰͬ״̬Ϊͬ*/ + if (CI_SUCCESS == ret) + { + chFloodState = GetFloodGateCurAgreeCloseSta(pPhyLocatedFloodId[ii]); + if (FLOOD_GATE_NOT_AGREE_CLOSE == chFloodState) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + + if (CI_SUCCESS != ret) + { + ret = CI_ERROR; + break; /*һż鲻ֹͨͣ飬ʧ*/ + } + else + { + /**/ + } + } + } + else + { + ; /*ݲϷ0ʧ*/ + } + } + else + { + ; /*ID󣬷ؼ鲻ͨ*/ + } + } + else + { + ; /*ID󣬷ؼ鲻ͨ*/ + } + + return ret; +} + +/** + * @brief ȡϹεƶ״̬ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS ƶ״̬ͨ + CI_ERROR ƶ״̬鲻ͨ + * @note by cgh 20240222 + */ +UINT8 rrm_PrepareAreaUrgentStatOfAC(UINT16 acID) +{ + UINT8 ret = CI_ERROR; + UINT16 wCurAcRelatePhyId = 0U;/*ǰιID*/ + UINT8 chPhySecAreaUrgentState = 0U;/*ƶ״̬*/ + + if ((0U < acID) && (AXIS_SECTION_SUM_MAX > acID)) + { + wCurAcRelatePhyId = GetAxisSecRelativePhySecId(acID); + if ((0U < wCurAcRelatePhyId) && (PHYSICAL_SECTION_SUM_MAX > wCurAcRelatePhyId)) + { + chPhySecAreaUrgentState = GetPhySecAreaUrgentState(wCurAcRelatePhyId); + + if (PHYSEC_AREA_URGENT_NO == chPhySecAreaUrgentState) + { + /*ƶ״̬Чͨ*/ + ret = CI_SUCCESS; + } + else + { + /*ƶ߷Ƿֵ鲻ͨ*/ + ret = CI_ERROR; + } + } + else + { + ; /*ID󣬷ؼ鲻ͨ*/ + } + } + else + { + ; /*ID󣬷ؼ鲻ͨ*/ + } + return ret; +} + +/** +* @brief жRCǷΪ߻Գ +* @param[in] const UINT8 cRcId RC ID +* @param[out] +* @return CI_SUCCESS 1 ߻Գ + CI_ERROR 0 ҷԳ +* @note Created By LQ 2024.02.28 +*/ +UINT8 rrm_PrepareRcIsZXorSCX(const UINT8 cRcId) +{ + UINT8 retVal = CI_ERROR; + UINT8 cCiType = 0U; + + if ((0U < cRcId) && (CI_SUM_MAX > cRcId)) + { + cCiType = GetCiType(cRcId); + ASSERT_SETRET(((CI_TYPE_ZX == cCiType) || (CI_TYPE_SCX == cCiType)), retVal, CI_SUCCESS, CI_ERROR); + } + else + { + /*ηǷ0ʧ*/ + } + + return retVal; +} + +/** + * @brief гǷڷֽδƽRCRRM + * @param[in] const UINT16 wTrainID гID + * @param[in] const EnvelopeStruct* pTemp гϢ + * @param[out] + * @return CI_SUCCESS 1 ɹ + CI_ERROR 0 ʧ + * @note Created By LQ 2024.03.01 + */ +UINT8 rrm_CfpTrainApplyCheck(const UINT16 wTrainID, IN const EnvelopeStruct* pTemp) +{ + UINT8 retVal = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 cAxisSecNum = 0U; /*󷽼*/ + UINT16 szAxisSecId[AC_MAXCNT_IN_SWITCH] = { 0U }; /*󷽼ID*/ + UINT8 cNextRcId = 0U; + UINT8 cAxisSecIsOwnFlag = 0U; /*ǷΪ־*/ + UINT8 cElmNum = 0U; + UINT16 szEnvelopeID[SECTION_REL_ENVELOPE_SUM_MAX] = { 0U }; + const EnvelopeStruct* pTempInfo = NULL; + UINT8 cDirChangePointFlag = 0U; /*Ƿз仯־*/ + UINT8 cTrainInCfpFlag = FLAG_UNSET; /*гǷѹֽ־*/\ + UINT16 wCfpId = 0U; /*ֽID*/ + UINT16 wCfpTrainId = 0U; /*ֽгID*/ + UINT8 cRrmSrcRcApplyState = TRAIN_RRM_LOCALCI_NOT_APPLY; /*ԴRC״̬*/ + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0U == pTemp->ACCnt), retVal, 0x80000000U); + ASSERT_RET_VALUE((0U == (wTrainID & 0x00FFU)) || (0x00FFU == (wTrainID & 0x00FFU)), retVal, 0x40000000U); + ASSERT_RET_VALUE((TYPE_CT_ENVELOPE != pTemp->envelopeType) && (TYPE_UCT_ENVELOPE != pTemp->envelopeType), retVal, 0x20000000U); + + cAxisSecNum = elm_PrepareAdjacentAC(pTemp->ACID[0U], ((UINT8)~(pTemp->startPos.Dir)), szAxisSecId, &cDirChangePointFlag); /** ѯβ󷽼 */ + + if (UINT8_MAX == cAxisSecNum) + { + errorCode += 0x10000000U; /*󷽼βѯʧܣ¼*/ + } + else + { + for (ii = 0U; ii < cAxisSecNum; ii++) + { + cAxisSecIsOwnFlag = rrm_PrepareACIsSelf(szAxisSecId[ii], &cNextRcId); /*жϼ*/ + cElmNum = elm_GetEnvelopeIDsInAC(szAxisSecId[ii], szEnvelopeID); /*ȡϵİϢ*/ + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX <= cElmNum, errorCode, 0x08000000U); + + if ((0U != cElmNum) && (ELM_BELONG_OWNER != cAxisSecIsOwnFlag)) + { + /*󷽼ڰҲڱRC*/ + for (jj = 0U; jj < cElmNum; jj++) + { + pTempInfo = elm_GetEnvelopeInfoByID(szEnvelopeID[jj]); + ASSERT_BREAK(NULL == pTempInfo, errorCode, 0x04000000U); + + /*ǿգǷ*/ + for (kk = 0U; kk < pTempInfo->trianCnt; kk++) + { + if ((pTempInfo->trainID[kk] & 0x00FFU) == (wTrainID & 0x00FFU)) + { + /*󷽼βڱҰ磬жгΪֽ㣬ֹͣ*/ + cTrainInCfpFlag = FLAG_SET; + break; + } + else + { + /**/ + } + } + + if (kk != pTempInfo->trianCnt) + { + break; + } + else + { + /**/ + } + } + + if (jj != cElmNum) + { + break; + } + else + { + /**/ + } + } + else + { + /**/ + } + } + + if (FLAG_UNSET != cTrainInCfpFlag) + { + /*гѹֽ㣬жϱRCǷյRCRRM*/ + wCfpId = GetAxisRelateCfpId(pTemp->ACID[0U]); + wCfpTrainId = GetCfpRrmTrainId(wCfpId); + cRrmSrcRcApplyState = GetCfpRrmSrcApplyState(wCfpId); + + if (((wCfpTrainId & 0x00FFU) == (wTrainID & 0x00FFU)) && (TRAIN_RRM_LOCALCI_APPLY == cRrmSrcRcApplyState)) + { + retVal = CI_SUCCESS; /*ֽյԴRCRRM1ɹ*/ + } + else + { + errorCode += 0x02000000U; + retVal = CI_ERROR; + } + } + else if(0U == errorCode) + { + retVal = CI_SUCCESS; /*δֽ㣬1ɹ*/ + } + else + { + retVal = CI_ERROR; /*0ʧ*/ + } + + ASSER_DEBUG(0U != errorCode, RRM_LOG(RRM_LOG_ERROR, "errno:0x%08x info:Train%d back has sameTrain.", errorCode, wTrainID)); + } + + return retVal; +} + +/** +* @brief жͣǷڱ +* @param[in] const UINT16 wAtsLgcStaId ͣID +* @param[out] +* @return CI_SUCCESS ڱ + CI_ERROR ڱ +* @note bv cgh 20240918 +*/ +UINT8 rrm_PrepareAtsLgcStaIsOwn(const UINT16 wAtsLgcStaId) +{ + UINT8 retVal = CI_ERROR; + UINT16 wAtsLgcStaBelCiId = 0U; + UINT8 chLocalCiId = 0U;/*ID*/ + + if ((0U != wAtsLgcStaId) && (UINT16_MAX != wAtsLgcStaId)) + { + wAtsLgcStaBelCiId = GetAtsLgcStationBelongTioc(wAtsLgcStaId); + chLocalCiId = GetSystemParaLocalCiId(); + + if ((wAtsLgcStaBelCiId == (UINT16)chLocalCiId) && (0U != wAtsLgcStaBelCiId)) + { + /*ڱ*/ + ; + } + else + { + retVal = CI_SUCCESS; + } + } + else + { + /*ηǷڱʧ*/ + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.h b/TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.h new file mode 100644 index 0000000..92ca297 --- /dev/null +++ b/TSCP/src/APP/ciapp/RemoteRM/RRMDataPrepare.h @@ -0,0 +1,444 @@ +/****************************************************************************** +** ļ: RRMDataPrepare.h +** : ԶRMģ׼ +*******************************************************************************/ +#ifndef RRM_DATA_PREPARE_H_ +#define RRM_DATA_PREPARE_H_ + +#include "RRMDefine.h" +#include "EnvelopeDefine.h" +#include "ELMDataPrepare.h" +#include "EnvelopeManageAPI.h" +#include "TrainDataManage.h" +#include "AxisSectionConfigDataManage.h" +#include "PhysicalSectionDataManage.h" +#include "RouteDataManage.h" +#include "EnvelopeLogicProcess.h" + + +#define RRM_LOG_FATAL 0u /** ά־--ά */ +#define RRM_LOG_ERROR 1u /*ά־--󼶱*/ +#define RRM_LOG_WARING 2u /*ά־--漶*/ +#define RRM_LOG_DEBUG 3u /*ά־--Լ*/ +#define RRM_LOG_LEVEL RRM_LOG_DEBUG /*ά־--ǰ־*/ +#define RRM_PRINT_LEN 1280u /* ά־ӡӡ 1024+256 */ + + +/** ־ӡ */ +#define RRM_LOG_LOC(level,fmt,...) rrm_PrintDebugInfo(level,fmt" line:%d fun:%s.\n",##__VA_ARGS__,__LINE__,__FUNCTION__); + +#define RRM_LOG(level,fmt,...) rrm_PrintDebugInfo(level,fmt,##__VA_ARGS__); + +#if (kPLATFORM==kWINDOWS) +#define RRM_LOG_TIME(level,fmt,...) { \ + SYSTEMTIME sys; \ + GetLocalTime(&sys); \ + rrm_PrintDebugInfo(level,fmt" time:%02d:%02d:%02d.%03d.\n",##__VA_ARGS__,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds); \ +} +#else +#define RRM_LOG_TIME(level,fmt,...) rrm_PrintDebugInfo(level,fmt" time:%08d.\n",##__VA_ARGS__,TimeStamp); +#endif + + +/** + * @brief ӡDebugϢ + * @param[in] UINT8 level ־ + * @param[in] const char *fmt ӡϢ + * @return + * @note ͨⲿӿڣʵֱģĴӡ + */ +void rrm_PrintDebugInfo(UINT8 level, const char *fmt, ...); + + +/** +* @brief ȡRRMܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ + CI_ERROR ܹر +* @note +*/ +UINT8 rrm_PrepareRRMSwitch(void); + + +/** +* @brief ȡվ֧ԶRMܿ +* @param[in] +* @param[out] +* @return CI_SUCCESS ܴ + CI_ERROR ܹر +* @note +*/ +UINT8 rrm_PrepareRRMStaSwitch(void); + +/** + * @brief ȡгRRM״̬ + * @param[in] UINT16 trainID гID + * @param[out] + * @return + * @note + */ +UINT8 rrm_PrepareRRMRequest(UINT16 trainID); + + +/** + * @brief ȡгһվ̨ + * @param[in] UINT16 trainID гID + * @param[out] + * @return UINT16 + * @note + */ +UINT16 rrm_PrepareNextStaOfTrain(UINT16 trainID); + +/** + * @brief ȡгİ + * @param[in] гID + * @param[out] + * @return NULL UCT߲ѯʧܣNULLѯȷ + * @note + */ +const EnvelopeStruct* rrm_PrepareTrainRelELM(UINT16 trainID); + + +/** + * @brief ȡгǷΪ + * @param[in] const EnvelopeStruct* pTrainELM + * @param[out] + * @return UINT8 + CI_SUCCESS + CI_ERROR + * @note + */ +UINT8 rrm_PrepareTrainAreaIsZX(IN const EnvelopeStruct* pTrainELM); + + +/** + * @brief ȡιATS߼վ̨ID + * @param[in] UINT16 ACID + * @param[out] + * @return UINT16 + 0:βΪվ̨ + 0xffffu:ѯʧ + ѯȷ + * @note + */ +UINT16 rrm_PrepareAtsLgcStaOfAC(UINT16 ACID); + +/** + * @brief ȡǷΪ۷ + * @param[in] UINT16 ACID + * @param[out] + * @return UINT8 + CI_SUCCESS ۷ + CI_ERROR Ϊ۷ + * @note + */ + UINT8 rrm_PrepareACisRevertArea(UINT16 ACID); + + + /** + * @brief η + * @param[in] const UINT16 wCurACID ǰID + * @param[in] const UINT16 wNextACID һID + * @param[out] + * @return UINT8 + CI_SUCCESS ͨ + CI_ERROR 鲻ͨ + CI_TRUE ޱ + * @note by cgh 20240425 + */ + UINT8 rrm_PrepareACisOverlapLock(const UINT16 wCurACID, const UINT16 wNextACID); + +/** + * @brief ȡгз򼰼 + * @param[in] UINT16 trainID гID + * @param[out] UINT8 *pDir г + * @param[out] UINT8 *pACT г + * @return + * @note + */ +void rrm_PrepareTrainDirAndAct(UINT16 trainID,OUT UINT8 *pDir,OUT UINT8 *pACT); + + +/** + * @brief ȡȫ߽״̬ + * @param[in] + * @param[out] + * @return UINT8 + CI_SUCCESS ȫ߽״̬ + CI_ERROR δȫ߽״̬ + * @note + */ +UINT8 rrm_PrepareWLBrake(void); + + +/** + * @brief ȡͷռѹǰǷ + * @param[in] const EnvelopeStruct* pTemp Ϣ + * @param[out] + * @return UINT8 + CI_SUCCESS ǰ + CI_ERROR ǰ + * @note + */ +UINT8 rrm_PrepareForwardTrain(IN const EnvelopeStruct* pTemp); + + +/** + * @brief ȡβڼǷڱ + * @param[in] UINT16 trainID гID + * @param[in] const EnvelopeStruct* pTemp Ϣ + * @param[out] + * @return UINT8 + CI_SUCCESS 󷽲ڱ + CI_ERROR 󷽴ڱ + * @note + */ +UINT8 rrm_PrepareBackHaveSameTrain(UINT16 trainID,IN const EnvelopeStruct* pTemp); + + +/** + * @brief ȡβ߼ + * @param[in] UINT16 trainID гID + * @param[in] const EnvelopeStruct* pTemp Ϣ + * @param[out] + * @return UINT16 + ѯʧܣ0 + ѯɹβ߼ + * @note + */ +UINT16 rrm_PrepareSecIDofTail(UINT16 trainID,IN const EnvelopeStruct* pTemp); + + + /** + * @brief ѯǰ/󷽼 + * @param[in] UINT16 ACID ׼ID + * @param[in] UINT8 dir ѯ + * @param[out] UINT16 arACID[AC_MAXCNT_IN_SWITCH] ڼID + * @return UINT8_MAX ѯʧ + 0~AC_MAXCNT_IN_SWITCH ѯɹ + * @note + */ +UINT8 rrm_PrepareAdjacentAC(UINT16 ACID, UINT8 dir, INOUT UINT16 arACID[AC_MAXCNT_IN_SWITCH], OUT UINT8* directionPointFlag); + + +/** + * @brief ȡǷڱOC + * @param[in] UINT16 acID ID + * @param[out] UINT8 *pOCId OCid + * @return ELM_BELONG_OTHER OC + ELM_BELONG_OWNER ڱOC + Ƿ + * @note + */ + UINT8 rrm_PrepareACIsSelf(UINT16 acID,UINT8 *pOCId); + + + /** + * @brief ȡѰ· + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT16 + 0xffffu,ѯʧ + 0δѰ· + Ѱ·ID + * @note + */ + UINT16 rrm_PrepareAcofRoute(UINT16 acID); + + /** + * @brief ȡ·ʼźŻ״̬ + * @param[in] UINT16 routeID ·ID + * @param[out] + * @return UINT8 + CI_SUCCESS źŻ + CI_ERROR źŻر + * @note + */ + UINT8 rrm_PrepareOriginSigStatOfRoute(UINT16 routeID); + + + /** + * @brief ͨIDȡ״̬ + * @param[in] UINT16 ACID ID + * @return ELM_AC_OCC ռ + ELM_AC_FREE + * @note + */ +UINT8 rrm_PrepareACStatus(UINT16 ACID); + + +/** + * @brief ȡε״̬շ + * @param[in] UINT16 ACID ID + * @param[in] UINT16 flag + * @param[out] UINT8* pLockStat ״̬ + * @param[out] UINT8* pLockDir շ + * @return + * @note + */ +void rrm_PrepareACLockStatAndDir(UINT16 ACID,UINT8 flag,OUT UINT8* pLockStat,OUT UINT8* pLockDir); + + + /** + * @brief ȡη״̬ͷԭ + * @param[in] UINT16 acID ID + * @param[out] UINT8 *pFlockStatus ״̬ + * @param[out] UINT8 *pFlockType ԭ + * @return + * @note + */ + void rrm_PrepareACFLockStatusAndType(UINT16 acID,OUT UINT8 *pFlockStatus,OUT UINT8 *pFlockType); + + /** + * @brief ȡĵλǷȷ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS λȷ + CI_ERROR λòȷ + * @note + */ + UINT8 rrm_PrepareSwitchStatOfAC(UINT16 acID); + + /** + * @brief ȡϹESBǷ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS ESBδ + CI_ERROR ESB + * @note + */ + UINT8 rrm_PrepareESBStatOfAC(UINT16 acID); + + + /** + * @brief ȡϹPSDǷ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS PSDδ + CI_ERROR PSD + * @note + */ + UINT8 rrm_PreparePSDStatOfAC(UINT16 acID); + + + /** + * @brief ȡǷ˰ȫǷڰȫ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS δаȫ + CI_ERROR ν˰ȫ + * @note + */ + UINT8 rrm_PrepareSafeProtectOfAC(UINT16 acID); + + + /** + * @brief ȡǷ޻߲ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS δаȫ + CI_ERROR ν˰ȫ + * @note + */ + UINT8 rrm_PrepareVainAndLtrlDfncCheck(UINT16 acID); + + /** + * @brief ȡǰزѯĶ˵ǷΪ仯㣨Ԥ߹ܣ + * @param[in] UINT16 acID ID + * @param[in] UINT8 Dir ѯ + * @param[out] + * @return UINT8 + DIR_CHANGE: ڷ仯 + DIR_UNCHANGE ڷ仯 + UINT8_MAX ѯʧ + * @note + */ + UINT8 rrm_PrepareDirChangeOfAC(UINT16 acID,UINT8 Dir); + + +/** + * @brief гRRMȨ״̬ȨɼһTIOC ID + * @param[in] UINT16 trainID гID + * @param[in] UINT8 rrmReply rrmȨ״̬ + * @param[in] UINT8 rrmReason rrmȨ + * @param[in] UINT8 nextOCId һTIOC ID + * @param[out] + * @return + * @note + */ +void rrm_SetRRMResult(UINT16 trainID,UINT8 rrmReply,UINT8 rrmReason,UINT8 nextOCId); + +/** + * @brief ȡ·Ƿڱ + * @param[in] UINT16 CurACID ǰ + * @param[out] + * @return UINT8 + CI_SUCCESS ߱ + CI_ERROR ߱ + * @note by cgh 20231102 ֧һվ̨ñԶRM + */ +UINT8 rrm_OverlapExistCheck(UINT16 CurACID); + +/** + * @brief ȡϹķ״̬ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS ״̬ͨ + CI_ERROR ״̬鲻ͨ + * @note by cgh 20240222 + */ +UINT8 rrm_PrepareFGStatOfAC(UINT16 acID); + +/** + * @brief ȡϹεƶ״̬ + * @param[in] UINT16 acID ID + * @param[out] + * @return UINT8 + CI_SUCCESS ƶ״̬ͨ + CI_ERROR ƶ״̬鲻ͨ + * @note by cgh 20240222 + */ +UINT8 rrm_PrepareAreaUrgentStatOfAC(UINT16 acID); + +/** +* @brief жRCǷΪ߻Գ +* @param[in] const UINT8 cRcId RC ID +* @param[out] +* @return CI_SUCCESS 1 ߻Գ + CI_ERROR 0 ҷԳ +* @note Created By LQ 2024.02.28 +*/ +UINT8 rrm_PrepareRcIsZXorSCX(const UINT8 cRcId); + +/** + * @brief гǷڷֽδƽRCRRM + * @param[in] const UINT16 wTrainID гID + * @param[in] const EnvelopeStruct* pTemp гϢ + * @param[out] + * @return CI_SUCCESS 1 ɹ + CI_ERROR 0 ʧ + * @note Created By LQ 2024.03.01 + */ +UINT8 rrm_CfpTrainApplyCheck(const UINT16 wTrainID, IN const EnvelopeStruct* pTemp); + +/** +* @brief жͣǷڱ +* @param[in] const UINT16 wAtsLgcStaId ͣID +* @param[out] +* @return CI_SUCCESS ڱ + CI_ERROR ڱ +* @note bv cgh 20240918 +*/ +UINT8 rrm_PrepareAtsLgcStaIsOwn(const UINT16 wAtsLgcStaId); + +#endif + + + \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/RemoteRM/RRMDefine.h b/TSCP/src/APP/ciapp/RemoteRM/RRMDefine.h new file mode 100644 index 0000000..6268459 --- /dev/null +++ b/TSCP/src/APP/ciapp/RemoteRM/RRMDefine.h @@ -0,0 +1,71 @@ +/****************************************************************************** +** ļ: RRMDefine.h +** : ԶRMģrrm +*******************************************************************************/ +#ifndef RRM_DEFINE_H_ +#define RRM_DEFINE_H_ +#include "EnvelopeDefine.h" +#include "SectionDefine.h" + +#define RRM_CHECK_VALID 0x55u /* Ҫ */ +#define RRM_CHECK_UNVALID 0xaau /* Ҫ */ + + +#define MAX_OBS_IN_RRM_PATH 50U /** RRM·аϰϢ */ +#define MAX_AC_IN_RRM_PATH 40U /** RRM·аļ */ +#define MAX_LINK_IN_RRM_PATH (MAX_AC_IN_RRM_PATH * AXIS_INCLUDE_LINK_SUM_MAX) /** RRM·аlink */ +#define MAX_SEC_IN_RRM_PATh (AXIS_INCLUDE_LOG_SUM_MAX * MAX_AC_IN_RRM_PATH) /** RRM·а߼ */ + +#define TYPE_OF_PATH_A 0x01u /** ռѹ */ +#define TYPE_OF_PATH_B 0x02u /** ͷǰ/ֽ㵽һվ̨֮ */ +#define TYPE_OF_PATH_C 0x03u /** һվ̨ǰ*/ + +#define SEC_LOCK_OK 0x55u /** */ +#define SEC_LOCK_ERROR 0xaau /** δ*/ + +#define DIR_CHANGE 0x55u /** ڷ仯 */ +#define DIR_UNCHANGE 0xaa /** ڷ仯 */ + + +/** ·аļ*/ +typedef struct +{ + UINT16 acCnt; + UINT8 pathType[MAX_AC_IN_RRM_PATH]; + UINT8 runDir[MAX_AC_IN_RRM_PATH]; + UINT16 ACID[MAX_AC_IN_RRM_PATH]; +}RRMPathOfACSeqStruct; + +/** ·аLink*/ +typedef struct +{ + UINT16 linkCnt; + UINT8 pathType[MAX_LINK_IN_RRM_PATH]; + UINT8 runDir[MAX_LINK_IN_RRM_PATH]; + UINT16 LinkID[MAX_LINK_IN_RRM_PATH]; +}RRMPathOfLinkSeqStruct; + +/** ·а߼*/ +typedef struct +{ + UINT16 secCnt; + UINT8 pathType[MAX_SEC_IN_RRM_PATh]; + UINT8 runDir[MAX_SEC_IN_RRM_PATh]; + UINT16 SecID[MAX_SEC_IN_RRM_PATh]; +}RRMPathOfSecSeqStruct; + + +/** ӿڽṹ */ +typedef struct +{ + UINT8 trainCnt; /** г */ + UINT16 TrainID[TRAIN_SUM_MAX_IN_OC]; /** гID*/ + UINT16 TailSecID[TRAIN_SUM_MAX_IN_OC]; /** гβռõ߼ID*/ +}ATSTrainInfoStru; + + +#endif + + + + diff --git a/TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.c b/TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.c new file mode 100644 index 0000000..1a26b59 --- /dev/null +++ b/TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.c @@ -0,0 +1,2032 @@ + #include "RRMDataPrepare.h" + #include "RRMManageAPI.h" + +#if LINE_MAX_TRAIN > 255 +#error LINE_MAX_TRAINֵܳ255Ŀǰ豸ID壨ͣ1ֽڣ+ID1ֽڣ +#endif + + +/**============================================= ̬ ==================================================== */ +static UINT8 rrm_AddACInRRMPathSeq(UINT16 ACID,UINT8 dir,UINT8 type,OUT RRMPathOfACSeqStruct* pACSeq); /** ӼϢRRM· */ + + +static UINT8 rrm_CheckObsAndSafeProtect(UINT8 funValid,UINT16 trainID,IN const RRMPathOfACSeqStruct* pACSeq,OUT UINT8* rrmReason); /** RRM·ϰǷҪν˰ȫ */ +static UINT8 rrm_CheckSecStatus(UINT8 funValid,UINT16 trainID,IN const RRMPathOfACSeqStruct* pACSeq,OUT UINT8* rrmReason); /** RRM·ǷҪ󣨿//շһ£ */ +static UINT8 rrm_CheckSignalStatus(UINT8 funValid,UINT16 trainID,IN const RRMPathOfACSeqStruct* pACSeq,OUT UINT8* rrmReason); /** гͷǰһվվ̨ն֮źŻ״̬Ϊ */ +static UINT8 rrm_CheckNextStation(UINT8 funValid,UINT16 trainID,UINT16 searchNextStaID,OUT UINT8* rrmReason); /** ѯһվϢǷг͵һվһ*/ +static UINT8 rrm_CheckRRMPathAndSwtich(UINT8 funValid,UINT16 trainID,IN const EnvelopeStruct* pTemp,OUT RRMPathOfACSeqStruct* pACSeq, \ + OUT UINT8 *pNextTIOC,OUT UINT16 *pNextSta,OUT UINT8* rrmReason); /** ѯRRM·״̬Ƿȷ */ +static UINT8 rrm_CheckWLBrake(UINT8 funValid,UINT16 trainID,OUT UINT8* rrmReason); /* Ƿȫ߽ƶ */ +static UINT8 rrm_CheckDirAndActIsSame(UINT8 funValid,UINT16 trainID, IN const EnvelopeStruct* pTemp,OUT UINT8* rrmReason); /* гзͼǷһ */ +static UINT8 rrm_CheckTrainInSta(UINT8 funValid,UINT16 trainID, IN const EnvelopeStruct* pTemp,OUT UINT8* rrmReason); /* гǷվ̨ */ +static UINT8 rrm_ChecKForwardTrainAndArea(UINT8 funValid,UINT16 trainID, IN const EnvelopeStruct* pTemp,OUT UINT8* rrmReason); /* гǷǰгǷ */ +static void rrm_ProcessTrainRRMRequst(UINT16 trainID); /* ԶRM */ + +/** + * @brief ǷгͷĿվ̨ռѹδ + * @param[in] UINT16 trainID гID + * @param[in] IN const EnvelopeStruct* pTemp ָ + * @param[out] UINT16* pNextSta һվ̨ + * @return UINT8 + CI_ERROR + CI_SUCCESS + * by cgh 20241022 + */ +static UINT8 rrm_CheckTrainHeadInFreeSta(UINT16 trainID, IN const EnvelopeStruct* pTemp, OUT UINT16* pNextSta); + + + +/** + * @brief ӼϢRRM· + * @param[in] UINT16 ACID ID + * @param[in] UINT8 dir + * @param[in] UINT8 type + * @param[out] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @return UINT8 + CI_SUCCESS ɹ + CI_ERROR ʧ + * @note + */ +static UINT8 rrm_AddACInRRMPathSeq(UINT16 ACID,UINT8 dir,UINT8 type,OUT RRMPathOfACSeqStruct* pACSeq) +{ + UINT8 ret = CI_ERROR; + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pACSeq) || (MAX_AC_IN_RRM_PATH <= pACSeq->acCnt),ret,0x80000000u); + ASSERT_RET_VALUE((ELM_DIR_SAME != dir) && (ELM_DIR_CONVERT != dir),ret,0x40000000u); + ASSERT_RET_VALUE((TYPE_OF_PATH_A != type) && (TYPE_OF_PATH_B != type) && (TYPE_OF_PATH_C != type),ret,0x20000000u); + + + pACSeq->ACID[pACSeq->acCnt] = ACID; + pACSeq->runDir[pACSeq->acCnt] = dir; + pACSeq->pathType[pACSeq->acCnt] = type; + pACSeq->acCnt++; + ret = CI_SUCCESS; + + return ret; +} + + + + +/** + * @brief RRM·ϰǷҪν˰ȫ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_CheckObsAndSafeProtect(UINT8 funValid,UINT16 trainID,IN const RRMPathOfACSeqStruct* pACSeq,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT16 cycle = 0u; + UINT8 FlockStatus = ELM_AC_OCC; + UINT8 FlockType = SEC_LOCK_ERROR; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pACSeq,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x40000000u); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffu; + } + else + { + for(cycle = 0u; cycle < pACSeq->acCnt;cycle++) + { + /** ȡεķ״̬ */ + rrm_PrepareACFLockStatusAndType(pACSeq->ACID[cycle],&FlockStatus,&FlockType); + if (PHYSICAL_SECTION_FLOCK_NO == FlockStatus) + { + /** δESBǷ */ + funRtn = rrm_PrepareESBStatOfAC(pACSeq->ACID[cycle]); + if (CI_ERROR == funRtn) + { + *rrmReason = TRAIN_RRM_RESON_08; + errorCode += 0x20000000u; + break; + } + else + { + /** */ + } + + + /** PSDǷ*/ + funRtn = rrm_PreparePSDStatOfAC(pACSeq->ACID[cycle]); + if (CI_ERROR == funRtn) + { + *rrmReason = TRAIN_RRM_RESON_09; + errorCode += 0x10000000u; + break; + } + else + { + /** */ + } + + /** Ƿڷ */ + funRtn = rrm_PrepareSafeProtectOfAC(pACSeq->ACID[cycle]); + if (CI_ERROR == funRtn) + { + *rrmReason = TRAIN_RRM_RESON_06; + errorCode += 0x08000000u; + break; + } + else + { + /** */ + } + + /** ȡǷ޻߲ */ + funRtn = rrm_PrepareVainAndLtrlDfncCheck(pACSeq->ACID[cycle]); + if (CI_ERROR == funRtn) + { + *rrmReason = TRAIN_RRM_RESON_06; + errorCode += 0x04000000u; + break; + } + else + { + /** */ + } + + /** */ + funRtn = rrm_PrepareFGStatOfAC(pACSeq->ACID[cycle]); + if (CI_ERROR == funRtn) + { + *rrmReason = TRAIN_RRM_RESON_0C; + errorCode += 0x01000000u; + break; + } + else + { + /** */ + } + + /** ȡǷƶ */ + funRtn = rrm_PrepareAreaUrgentStatOfAC(pACSeq->ACID[cycle]); + if (CI_ERROR == funRtn) + { + *rrmReason = TRAIN_RRM_RESON_06; + errorCode += 0x00800000u; + break; + } + else + { + /** */ + } + + } + else + { + if (PHY_SEC_FLOCK_TYPE_SPKS == FlockType) + { + *rrmReason = TRAIN_RRM_RESON_07; + } + else + { + *rrmReason = TRAIN_RRM_RESON_06; + } + errorCode += 0x02000000u; + break; + } + } + + if (cycle == pACSeq->acCnt) + { + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + + ASSER_DEBUG(0u != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,"errno:0x%08x info:Train%d not allow RRM by Obs error or Safe Protect.",errorCode,trainID)); + return ret; +} + + +/** + * @brief RRM·ǷҪ󣨿//շһ£ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_CheckSecStatus(UINT8 funValid,UINT16 trainID,IN const RRMPathOfACSeqStruct* pACSeq,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0U; + UINT16 cycle = 0U; + UINT8 acOccStatus = ELM_AC_OCC; + UINT8 acLockStatus = SEC_LOCK_ERROR; + UINT8 acLockDir = 0U; + UINT8 isReverArea = CI_ERROR; + UINT8 isOverlapLock = CI_ERROR; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pACSeq,ret,0x80000000U); + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x40000000U); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffU; + } + else + { + for(cycle = 0u; cycle < pACSeq->acCnt;cycle++) + { + /** ȡռ״̬ */ + acOccStatus = rrm_PrepareACStatus(pACSeq->ACID[cycle]); + rrm_PrepareACLockStatAndDir(pACSeq->ACID[cycle],pACSeq->pathType[cycle],&acLockStatus,&acLockDir); + + if (TYPE_OF_PATH_A == pACSeq->pathType[cycle]) + { + isReverArea = rrm_PrepareACisRevertArea(pACSeq->ACID[cycle]); + + if (CI_SUCCESS == isReverArea) + { + if (SEC_LOCK_ERROR == acLockStatus) + { + /** ۷򣬲鳵շ */ + errorCode += 0x20000000U; + } + else + { + ; /** */ + } + } + else + { + if ((SEC_LOCK_ERROR == acLockStatus) || (acLockDir != pACSeq->runDir[cycle])) + { + errorCode += 0x10000000U; + } + else + { + ; /** */ + } + } + } + else if (TYPE_OF_PATH_C == pACSeq->pathType[cycle]) + { + isOverlapLock = rrm_PrepareACisOverlapLock(pACSeq->ACID[cycle - 1U], pACSeq->ACID[cycle]); + if (CI_TRUE == isOverlapLock) + { + ; /*ûбΣ˲*/ + } + else + { + if ((CI_ERROR == isOverlapLock) || (ELM_AC_FREE != acOccStatus) || (SEC_LOCK_ERROR == acLockStatus) || (acLockDir != pACSeq->runDir[cycle])) + { + /** ʧ */ + errorCode += 0x08000000U; + } + else + { + ; /** */ + } + } + } + else + { + if ((ELM_AC_FREE != acOccStatus) || (SEC_LOCK_ERROR == acLockStatus) || (acLockDir != pACSeq->runDir[cycle])) + { + errorCode += 0x04000000U; + } + else + { + ; /** */ + } + } + + if (0U != errorCode) + { + break; + } + else + { + ; /**/ + } + } + + if (cycle == pACSeq->acCnt) + { + ret = CI_SUCCESS; + } + else + { + *rrmReason = TRAIN_RRM_RESON_06; + ret = CI_ERROR; + } + } + + ASSER_DEBUG(0U != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,"errno:0x%08x info:Train%d not allow RRM by SEC%d status error.",errorCode,trainID,pACSeq->ACID[cycle])); + return ret; +} + + +/** + * @brief гͷǰһվվ̨ն֮źŻ״̬Ϊ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_CheckSignalStatus(UINT8 funValid,UINT16 trainID,IN const RRMPathOfACSeqStruct* pACSeq,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT16 cycle = 0u; + UINT16 headOfRoute = 0u; + UINT16 tempofRoute = 0u; + UINT8 sigOfRoutePass = CI_ERROR; + UINT8 flag = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pACSeq,ret,0x80000000u); + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x40000000u); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffu; + } + else + { + for (cycle = 0u; cycle < pACSeq->acCnt;cycle++) + { + if (((0u == flag) && (TYPE_OF_PATH_A == pACSeq->pathType[cycle])) || + (TYPE_OF_PATH_C == pACSeq->pathType[cycle])) + { + /** 账*/ + } + else if ((0u != cycle) && (TYPE_OF_PATH_B == pACSeq->pathType[cycle])) + { + if (0u == flag) + { + /** ѯͷռѹĽ·*/ + headOfRoute = rrm_PrepareAcofRoute(pACSeq->ACID[cycle - 1u]); + flag = 0xffu; + } + else + { + /** 账*/ + } + + /** ѯǰѰ· */ + tempofRoute = rrm_PrepareAcofRoute(pACSeq->ACID[cycle]); + + if ((0u == headOfRoute) || (0u == tempofRoute)) + { + /** ν·δô϶δ */ + break; + } + else if (tempofRoute == headOfRoute) + { + /** жϸý·ʼźŻ״̬*/ + } + else + { + /** жϸý·ʼźŻ״̬Ƿ񿪷 */ + sigOfRoutePass = rrm_PrepareOriginSigStatOfRoute(tempofRoute); + + if (CI_SUCCESS == sigOfRoutePass) + { + /** źſţ*/ + } + else + { + break; + } + } + } + else + { + /** ·*/ + break; + } + } + + if (cycle == pACSeq->acCnt) + { + ret = CI_SUCCESS; + } + else + { + *rrmReason = TRAIN_RRM_RESON_05; + errorCode += 0x20000000u; + ret = CI_ERROR; + } + } + + ASSER_DEBUG(0u != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,"errno:0x%08x info:Train%d not allow RRM by route%d signal not open.",errorCode,trainID,tempofRoute)); + return ret; +} + + + +/** + * @brief ѯһվϢǷг͵һվһ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] UINT16 searchNextStaID ѯһվ̨ID + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_CheckNextStation(UINT8 funValid,UINT16 trainID,UINT16 searchNextStaID,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT16 trainNextStaID = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x80000000u); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffu; + } + else + { + /** ȡгһվ̨*/ + trainNextStaID = rrm_PrepareNextStaOfTrain(trainID); + + if (trainNextStaID == searchNextStaID) + { + ret = CI_SUCCESS; + } + else + { + *rrmReason = TRAIN_RRM_RESON_0B; + errorCode += 0x40000000u; + ret = CI_ERROR; + } + } + + ASSER_DEBUG(0u != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,"errno:0x%08x info:Train%d not allow RRM by dst error.",errorCode,trainID)); + return ret; +} + +/** + * @brief ѯRRM·״̬Ƿȷ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] IN const EnvelopeStruct* pTemp ָ + * @param[out] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @param[out] UINT8 *pNextTIOC һTIOC ID + * @param[out] UINT16 *pNextSta һվ̨ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_CheckRRMPathAndSwtich(UINT8 funValid,UINT16 trainID,IN const EnvelopeStruct* pTemp,OUT RRMPathOfACSeqStruct* pACSeq,OUT UINT8 *pNextTIOC,OUT UINT16 *pNextSta,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 validFlag = 0u; + UINT8 funRtn = CI_ERROR; + UINT16 nexStaID = 0u; + UINT8 nextOCId = 0u; + UINT8 ACIsOwn = 0u; + UINT8 cycle = 0u; + UINT8 cyclePath = 0u; + UINT16 curACID = 0u; + UINT8 curDir = 0u; + UINT16 nextACCnt = 0u; + UINT16 nextACId[AC_MAXCNT_IN_SWITCH] = {0u}; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 chAtsLgcStaIsOwnCheck = CI_ERROR;/*ATS·ͣIDǷڱ*/ + UINT16 wAtsLgcStaId = 0U; + UINT8 chHeadStationCheck = 0U;/*ͷվ̨*/ + + /** ڲУ*/ + ASSERT_RET_VALUE((NULL == pTemp) || (0u == pTemp->ACCnt),ret,0x80000000u); + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x40000000u); + ASSERT_RET_VALUE(NULL == pACSeq,ret,0x20000000u); + ASSERT_RET_VALUE(NULL == pNextTIOC,ret,0x10000000u); + ASSERT_RET_VALUE(NULL == pNextSta,ret,0x08000000u); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffu; + } + else + { + /** 泵β */ + curACID = pTemp->ACID[0u]; + curDir = pTemp->startPos.Dir; + funRtn = rrm_AddACInRRMPathSeq(curACID,curDir,TYPE_OF_PATH_A,pACSeq); + ASSER_ERROR(CI_ERROR ==funRtn,errorCode,0x04000000u); + + if (0u == errorCode) + { + /** 泵Χڵļ */ + for (cycle = 1u; cycle < pTemp->ACCnt;cycle++) + { + nextACCnt = rrm_PrepareAdjacentAC(curACID, curDir, nextACId, &cDirectionPointFlag); + + /** ѯΣλòҪ߲ѯͷʧ */ + if ((1u == nextACCnt) && (nextACId[0u] == pTemp->ACID[cycle])) + { + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + /** ׼ѯ */ + curACID = nextACId[0u]; + + /** ѯɹļ뵽 */ + funRtn = rrm_AddACInRRMPathSeq(curACID,curDir,TYPE_OF_PATH_A,pACSeq); + ASSERT_BREAK(CI_ERROR == funRtn,errorCode,0x02000000u); + } + else + { + /** ѯΣλòҪ߲ѯͷʧܻ߰· */ + errorCode += 0x01000000u; + break; + } + } + + /** ѯͷһվ̨֮ļ */ + if (cycle == pTemp->ACCnt) + { + chHeadStationCheck = rrm_CheckTrainHeadInFreeSta(trainID, pTemp,&nexStaID); + if (CI_SUCCESS == chHeadStationCheck) + { + /** ҵһվ̨ѯվ̨ǰϢ */ + nextACCnt = rrm_PrepareAdjacentAC(curACID, curDir, nextACId, &cDirectionPointFlag); + + if (0U == nextACCnt) + { + /** һĿΪ0˵Ǿͷߣʱ¼һվ̨ǰΣҪ¼¼߼վ̨ID by cgh 20231102*/ + ; + } + else + { + /** ѯΣλòҪ */ + ASSER_ERROR(1u != nextACCnt, errorCode, 0x00004000u); + + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + curACID = nextACId[0U]; + + /** ѯɹļ뵽*/ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_C, pACSeq); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00002000u); + } + + /** һվվ̨ID*/ + *pNextSta = nexStaID; + + /** ѭ */ + validFlag = 0xffu; + } + else + { + nexStaID = 0U; /**/ + } + + while (0u == validFlag) + { + /** rrm_AddACInRRMPathSeqѭ */ + nextACCnt = rrm_PrepareAdjacentAC(curACID, curDir, nextACId, &cDirectionPointFlag); + + /** ѯΣλòҪ߲ѯͷʧ */ + ASSERT_BREAK((1u != nextACCnt) || (nextACId[0u] == pACSeq->ACID[pACSeq->acCnt - 1u]), errorCode, 0x00800000u); + + /** жǷΪվ̨ */ + nexStaID = rrm_PrepareAtsLgcStaOfAC(nextACId[0u]); + ASSERT_BREAK(0xffffu == nexStaID, errorCode, 0x00400000u); + + /** ѯǷڱ */ + ACIsOwn = rrm_PrepareACIsSelf(nextACId[0u], &nextOCId); + ASSERT_BREAK(0u == nextOCId, errorCode, 0x00200000u); + + if ((ELM_BELONG_OWNER != ACIsOwn) && (0u != nextOCId)) + { + /*Ҫжϼ + *жվ̨гֽҳͷڿվ̨ʱȲ鵽վ̨첢ҽTYPE_OF_PATH_BμʱΪռöʧܣ + *RCRRM󷽰*/ + wAtsLgcStaId = rrm_PrepareNextStaOfTrain(trainID); + + chAtsLgcStaIsOwnCheck = rrm_PrepareAtsLgcStaIsOwn(wAtsLgcStaId); + + if (CI_SUCCESS == chAtsLgcStaIsOwnCheck) + { + /*RRMվ̨IDΪվ̨гǰ·г󷽻гǰΪйվ̨й + *ӦֱӼʧܲRC*/ + + *pNextTIOC = nextOCId; /** һTIOC ID*/ + } + else + { + ; + } + ASSER_ERROR(CI_ERROR == chAtsLgcStaIsOwnCheck, errorCode, 0x00100000U); + validFlag = 0xffu; /** ˳ѭ */ + } + else if (0u != nexStaID) + { + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + /** ׼ѯ */ + curACID = nextACId[0u]; + + /** ѯɹļ뵽*/ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_B, pACSeq); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x00080000u); + + /** ҵһվ̨ѯվ̨ǰϢ */ + nextACCnt = rrm_PrepareAdjacentAC(curACID, curDir, nextACId, &cDirectionPointFlag); + + if (0U == nextACCnt) + { + /** һĿΪ0˵Ǿͷߣʱ¼һվ̨ǰΣҪ¼¼߼վ̨ID by cgh 20231102*/ + ; + } + else + { + /** ѯΣλòҪ */ + ASSERT_BREAK((1u != nextACCnt) || (nextACId[0u] == pACSeq->ACID[pACSeq->acCnt - 1u]), errorCode, 0x00040000u); + + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + /** ׼ѯ */ + curACID = nextACId[0u]; + + /** ѯɹļ뵽*/ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_C, pACSeq); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x00020000u); + } + + /** һվվ̨ID*/ + *pNextSta = nexStaID; + + /** ˳ѭ */ + validFlag = 0xffu; + } + else + { + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + /** ׼ѯ */ + curACID = nextACId[0u]; + + /** ѯɹļ뵽*/ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_B, pACSeq); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x00010000u); + } + } + + if (0u != errorCode) + { + if (0x00100000U == (errorCode & 0x00100000U)) + { + *rrmReason = TRAIN_RRM_RESON_0B; + } + else + { + *rrmReason = TRAIN_RRM_RESON_0A; + } + ret = CI_ERROR; + } + else + { + /** У·ڵĵλǷȷ */ + for (cyclePath = 0u; cyclePath < pACSeq->acCnt; cyclePath++) + { + funRtn = rrm_PrepareSwitchStatOfAC(pACSeq->ACID[cyclePath]); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x00008000u); + } + + if (cyclePath == pACSeq->acCnt) + { + ret = CI_SUCCESS; + } + else + { + *rrmReason = TRAIN_RRM_RESON_0A; + ret = CI_ERROR; + } + } + } + else + { + *rrmReason = TRAIN_RRM_RESON_0A; + ret = CI_ERROR; + } + } + else + { + /** ʧ */ + *rrmReason = TRAIN_RRM_RESON_0A; + ret = CI_ERROR; + } + } + + debug_infor_printf((const)"rrm_CheckRRMPathAndSwtich:num = %d\n", pACSeq->acCnt); + debug_out_array(0xAA, pACSeq->ACID, pACSeq->acCnt * 2u); + + ASSER_DEBUG(0u != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,"errno:0x%08x info:Train%d not allow RRM by seach Path error .",errorCode,trainID)); + return ret; +} + + +/** + * @brief Ƿȫ߽ƶ + * @param[in] UINT8 funValid Ա־ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_CheckWLBrake(UINT8 funValid,UINT16 trainID,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = rrm_PrepareWLBrake(); + UINT32 errorCode = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x80000000u); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffu; + } + else + { + if (CI_SUCCESS == funRtn) + { + errorCode += 0x40000000u; + *rrmReason = TRAIN_RRM_RESON_02; + ret = CI_ERROR; + } + else + { + ret = CI_SUCCESS; + } + } + ASSER_DEBUG(0u != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,(const)"errno:0x%08x info:Train%d not allow RRM by WlBrake .",errorCode,trainID)); + return ret; +} + +/** + * @brief гзͼǷһ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] IN const EnvelopeStruct* pTemp ָ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_CheckDirAndActIsSame(UINT8 funValid,UINT16 trainID, IN const EnvelopeStruct* pTemp,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 chDir = 0u; + UINT8 chAct = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0u == pTemp->trianCnt),ret,0x80000000u); + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x40000000u); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffu; + } + else + { + /** ȡгļ */ + rrm_PrepareTrainDirAndAct(trainID,&chDir,&chAct); + + if ((trainID == pTemp->trainID[pTemp->trianCnt - 1u]) + && (pTemp->ACTPort[pTemp->trianCnt - 1u] == chAct)) + { + /** зһ */ + ret = CI_SUCCESS; + } + else + { + + errorCode += 0x10000000u; + *rrmReason = TRAIN_RRM_RESON_17; + ret = CI_ERROR; + } + } + + ASSER_DEBUG(0u != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,(const)"errno:0x%08x info:Train%d not allow RRM by Dir or act not same .",errorCode,trainID)); + return ret; +} + + +/** + * @brief гǷվ̨ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] IN const EnvelopeStruct* pTemp ָ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_CheckTrainInSta(UINT8 funValid,UINT16 trainID, IN const EnvelopeStruct* pTemp,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0U; + UINT8 RRMStaSwitch = rrm_PrepareRRMStaSwitch(); + UINT16 headRelStaID = 0U; + UINT16 tailRelStaID = 0U; + UINT16 trainNextSta = 0U; + UINT16 preEnvelopeid = 0U; + UINT16 backEnvelopeid = 0U; + UINT8 chCheckFlag = CI_ERROR; + UINT8 chHeadAcStatus = 0U; /*ͷռ״̬*/ + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0U == pTemp->ACCnt),ret,0x80000000U); + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x40000000U); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffU; + } + else + { + headRelStaID = rrm_PrepareAtsLgcStaOfAC(pTemp->ACID[pTemp->ACCnt - 1U]); + tailRelStaID = rrm_PrepareAtsLgcStaOfAC(pTemp->ACID[0U]); + ASSER_ERROR((0xffffU == headRelStaID) || (0xffffU == tailRelStaID),errorCode,0x20000000U); + + if (0U == errorCode) + { + trainNextSta = rrm_PrepareNextStaOfTrain(trainID); + + if (0U != headRelStaID) + { + ret = CI_ERROR; + if (trainNextSta == headRelStaID) + { + chHeadAcStatus = rrm_PrepareACStatus(pTemp->ACID[pTemp->ACCnt - 1U]); + if (ELM_AC_OCC == chHeadAcStatus) + { + /** гվ̨ */ + errorCode += 0x10000000U; + *rrmReason = TRAIN_RRM_RESON_0D; + } + else + { + /*ͷ뵫ռѹδ룬ȴ*/ + ret = CI_SUCCESS; + } + } + else + { + if (CI_SUCCESS == RRMStaSwitch) + { + /*ֽ㣬ǰΪվֳ̨֧վRRMǰԼ磬Ҫسɹ*/ + chCheckFlag = elm_GetNearEnvelopRelSameTra(pTemp->id, &preEnvelopeid, &backEnvelopeid); + if ((CI_SUCCESS == chCheckFlag) && (0U != preEnvelopeid)) + { + ret = CI_SUCCESS; + } + else + { + /** гվ̨ */ + errorCode += 0x01000000U; + *rrmReason = TRAIN_RRM_RESON_0E; + } + + } + else + { + /** гվ̨ */ + errorCode += 0x08000000U; + *rrmReason = TRAIN_RRM_RESON_0E; + } + } + } + else if(0U != tailRelStaID) + { + if (CI_SUCCESS == RRMStaSwitch) + { + if (trainNextSta == tailRelStaID) + { + /** гվ̨ */ + errorCode += 0x04000000U; + *rrmReason = TRAIN_RRM_RESON_0D; + ret = CI_ERROR; + + } + else + { + /** RRM */ + ret = CI_SUCCESS; + } + } + else + { + /** гվ̨ */ + errorCode += 0x02000000U; + *rrmReason = TRAIN_RRM_RESON_0E; + ret = CI_ERROR; + } + } + else + { + /** RRM */ + ret = CI_SUCCESS; + } + } + } + ASSER_DEBUG(0U != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,(const)"errno:0x%08x info:Train%d In sta not allow RRM.",errorCode,trainID)); + return ret; +} + + +/** + * @brief гǷǰгǷ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] IN const EnvelopeStruct* pTemp ָ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note + */ +static UINT8 rrm_ChecKForwardTrainAndArea(UINT8 funValid,UINT16 trainID, IN const EnvelopeStruct* pTemp,OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT32 errorCode = 0u; + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0u == pTemp->trianCnt),ret,0x80000000u); + ASSERT_RET_VALUE(NULL == rrmReason,ret,0x40000000u); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffu; + } + else + { + if ((0u == pTemp->headTrainID) && (trainID == pTemp->trainID[pTemp->trianCnt - 1u])) + { + /** жгͷռѹǷͨų */ + funRtn = rrm_PrepareForwardTrain(pTemp); + if (CI_SUCCESS == funRtn) + { + /** жгǷ񶼴 */ + funRtn = rrm_PrepareTrainAreaIsZX(pTemp); + + if (CI_SUCCESS == funRtn) + { + ret = CI_SUCCESS; + } + else + { + errorCode += 0x20000000u; + ret = CI_ERROR; + *rrmReason = TRAIN_RRM_RESON_16; + } + } + else + { + errorCode += 0x10000000u; + ret = CI_ERROR; + *rrmReason = TRAIN_RRM_RESON_16; + } + } + else + { + errorCode += 0x08000000u; + ret = CI_ERROR; + *rrmReason = TRAIN_RRM_RESON_16; + } + } + + ASSER_DEBUG(0u != errorCode,RRM_LOG_LOC(RRM_LOG_ERROR,(const)"errno:0x%08x info:Train%d ChecKForwardTrainAndArea error.",errorCode,trainID)); + return ret; +} + + +/** + * @brief ԶRM + * @param[in] UINT16 trainID гID + * @param[out] + * @return + * @note + */ +static void rrm_ProcessTrainRRMRequst(UINT16 trainID) +{ + UINT8 funValid = RRM_CHECK_VALID; + UINT8 funRtn = CI_ERROR; + UINT32 errorCode = 0u; + const EnvelopeStruct* pTemp = NULL; + UINT8 rrmReason = TRAIN_RRM_RESON_FF; + UINT8 NextTIOC = 0u; + UINT16 NextSta = 0u; + RRMPathOfACSeqStruct ACSeq = {0u}; + UINT8 chRrmDstAllowed = TRAIN_RRM_OTHERCI_NOT_ALLOW;/* ԶRM-ĿTIOC*/ + UINT16 wAxisRelateCfpId = 0U;/*ιֽID*/ + UINT16 trainNextStaID = 0U;/*г͵һվID*/ + UINT8 cLocalCiId = 0U; + + /** ȡгUCT */ + pTemp = rrm_PrepareTrainRelELM(trainID); + + /** жгǷUCT */ + if (NULL == pTemp) + { + RRM_LOG(RRM_LOG_FATAL,"info:Train%d not exit UCT ELM.\n!",trainID); + rrm_SetRRMResult(trainID,TRAIN_RRM_DEFAULT,TRAIN_RRM_RESON_FF,0u); + } + else + { + /** гǷڷֽδƽRCRRM */ + funRtn = rrm_CfpTrainApplyCheck(trainID, pTemp); + ASSERT_SETRET(CI_SUCCESS == funRtn, rrmReason, rrmReason, TRAIN_RRM_RESON_15); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x80000000u); + + /** гǷǰгǷ */ + funRtn = rrm_ChecKForwardTrainAndArea(funValid, trainID, pTemp, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x40000000u); + + /** гǷվ̨ */ + funRtn = rrm_CheckTrainInSta(funValid, trainID, pTemp, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x20000000u); + + /** гзͼǷһ */ + funRtn = rrm_CheckDirAndActIsSame(funValid, trainID, pTemp, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x10000000u); + + /** Ƿȫ߽ƶ*/ + funRtn = rrm_CheckWLBrake(funValid, trainID, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000u); + + /** ѯRRM·״̬Ƿȷ */ + funRtn = rrm_CheckRRMPathAndSwtich(funValid, trainID, pTemp, &ACSeq, &NextTIOC, &NextSta, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x04000000u); + + /** гͷǰһվվ̨ն(򵽷ֽ)֮źŻ״̬Ϊ */ + funRtn = rrm_CheckSignalStatus(funValid, trainID, &ACSeq, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x02000000u); + + /** 鱾RRM·ǷҪ󣨿//շһ£ */ + funRtn = rrm_CheckSecStatus(funValid, trainID, &ACSeq, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x01000000u); + + /** 鱾RRM·ϰǷҪν˰ȫ */ + funRtn = rrm_CheckObsAndSafeProtect(funValid, trainID, &ACSeq, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00800000u); + + if ((RRM_CHECK_VALID == funValid) && (0u == errorCode)) + { + if (0U == NextTIOC) + { + /** ·ڱ*/ + /*ѯRM·ʱ鵽һվIDһIDʱһIDΪ0˵վ̨ + *г͵ġз򡱲ѯֽ㴦վ̨Ȼɼ + *ѯһվϢǷг͵һվһ */ + funRtn = rrm_CheckNextStation(funValid, trainID, NextSta, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00400000u); + + if (RRM_CHECK_VALID == funValid) + { + rrm_SetRRMResult(trainID, TRAIN_RRM_YES, TRAIN_RRM_RESON_FF, 0U); + } + else + { + /** ʧ */ + rrm_SetRRMResult(trainID, TRAIN_RRM_NO, rrmReason, 0u); + RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d not allow RRM.", errorCode, trainID); + } + } + else + { + /*ԶRM*/ + if (0U != NextSta) + { + /*ѯRM·ʱ鵽һվIDһIDʱһIDΪ0˵վ̨г͵ġз򡱲ѯֽ㴦վ̨Ȼͨ*/ + /*ԶRM:ѯֽ㴦վ̨*/ + rrmReason = TRAIN_RRM_RESON_0B; + funRtn = CI_ERROR; + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00200000u); + + rrm_SetRRMResult(trainID, TRAIN_RRM_NO, rrmReason, NextTIOC); + RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d OtherCI not allow RRM.", errorCode, trainID); + } + else + { + funRtn = rrm_PrepareRcIsZXorSCX(NextTIOC); /*һǷΪ߻Գ*/ + if (CI_SUCCESS == funRtn) + { + /*ͨʣ*/ + wAxisRelateCfpId = GetAxisRelateCfpId(ACSeq.ACID[ACSeq.acCnt - 1U]); + SetCfpRrmSrcApplyState(wAxisRelateCfpId, TRAIN_RRM_LOCALCI_APPLY); + SetCfpRrmTrainId(wAxisRelateCfpId, trainID); + + trainNextStaID = rrm_PrepareNextStaOfTrain(trainID); + SetCfpRrmTrainNextStaId(wAxisRelateCfpId, trainNextStaID); + + cLocalCiId = GetSystemParaLocalCiId(); + SetCfpRrmSrcRcId(wAxisRelateCfpId, cLocalCiId); + + /*ԶRMʱĿTIOC״̬*/ + chRrmDstAllowed = GetCfpRrmDstAllowState(wAxisRelateCfpId); + if (TRAIN_RRM_OTHERCI_ALLOW == chRrmDstAllowed) + { + rrm_SetRRMResult(trainID, TRAIN_RRM_YES, TRAIN_RRM_RESON_FF, NextTIOC); + } + else + { + rrmReason = TRAIN_RRM_RESON_15; + rrm_SetRRMResult(trainID, TRAIN_RRM_NO, rrmReason, NextTIOC); + errorCode += 0x00100000U; + RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d OtherCI not allow RRM.", errorCode, trainID); + } + } + else + { + funValid = RRM_CHECK_UNVALID; + rrmReason = TRAIN_RRM_RESON_16; + rrm_SetRRMResult(trainID, TRAIN_RRM_NO, rrmReason, NextTIOC); + errorCode += 0x00080000U; + RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d OtherCI not allow RRM.", errorCode, trainID); + } + } + } + } + else + { + /** ʧ */ + rrm_SetRRMResult(trainID, TRAIN_RRM_NO, rrmReason, 0u); + RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d not allow RRM.", errorCode, trainID); + } + } +} + +/** + * @brief ԶRM + * @param[in] + * @param[out] + * @return + * @note + */ +void rrm_MainProcess(void) +{ + UINT16 cycle = 0u; + UINT8 rrmFunSwitch = rrm_PrepareRRMSwitch(); + UINT8 rrmRequest = CI_ERROR; + + /** жϹܿǷ */ + if (CI_SUCCESS == rrmFunSwitch) + { + /*- ԶRM */ + for (cycle = 1u; cycle < TRAIN_SUM_MAX;cycle++) + { + /** ȡгRRM״̬ */ + rrmRequest = rrm_PrepareRRMRequest(cycle); + + if (CI_SUCCESS == rrmRequest) + { + /** гRRM */ + rrm_ProcessTrainRRMRequst(cycle); + } + else + { + /** гδ룬гRRM־λΪĬֵԭΪĬֵ */ + rrm_SetRRMResult(cycle,TRAIN_RRM_DEFAULT,TRAIN_RRM_RESON_FF,0u); + } + } + } + else + { + /** ܿδ򿪣账 */ + } +} + + +/** + * @brief ӿڣȡ͸ATSUCTгϢ + * @param[in] + * @param[out] ATSTrainInfoStru* pInfo) + * @return + * @note + */ +void rrm_GetInfToATSUCTInfo(OUT ATSTrainInfoStru* pInfo) +{ + UINT16 cycle = 0u; + UINT16 secTail = 0u; + const EnvelopeStruct* pTemp = NULL; + + /** ڲУ */ + if (NULL == pInfo) + { + /** ڲ*/ + } + else + { + /** ջ */ + (void)CommonMemSet(pInfo, (UINT32)sizeof(ATSTrainInfoStru), 0u , (UINT32)sizeof(ATSTrainInfoStru)); + + for (cycle = 0u; cycle < LINE_MAX_TRAIN;cycle++) + { + /** ȡгİ */ + pTemp = rrm_PrepareTrainRelELM(cycle); + + if ((NULL != pTemp) && (pInfo->trainCnt < TRAIN_SUM_MAX_IN_OC)) + { + secTail = rrm_PrepareSecIDofTail(cycle,pTemp); + + if (0u != secTail) + { + pInfo->TrainID[pInfo->trainCnt] = (UINT16)(cycle & 0x00ffu) + (UINT16)(DEVTYPE_VOBC << 8u); + pInfo->TailSecID[pInfo->trainCnt] = secTail; + pInfo->trainCnt++; + } + else + { + /** ѯʧܣATS㱨UCTг */ + } + } + else + { + /** */ + } + } + } +} + +/** + * @brief RRM + * @param[in] const UINT16 wTrainID гID + * @param[in] const UINT16 wTrainNextStaId гһվվ̨ID + * @param[in] const UINT16 wAxisSecId ߽ID + * @param[in] const UINT8 chCheckDir ѯ + * @param[out] + * @return CI_ERROR ʧ + * CI_SUCCESS ɹ + * @note by cgh 20240221 + */ +UINT8 rrm_OtherCiConditionsCheck(const UINT16 wTrainID, const UINT16 wTrainNextStaId, const UINT16 wAxisSecId, const UINT8 chCheckDir) +{ + UINT8 chReval = CI_ERROR;/**/ + UINT8 funValid = RRM_CHECK_VALID; + UINT8 funRtn = CI_ERROR; + UINT32 errorCode = 0U; + UINT8 rrmReason = TRAIN_RRM_RESON_FF; + UINT8 NextTIOC = 0U; + UINT16 NextSta = 0U; + RRMPathOfACSeqStruct ACSeq = { 0U }; + EnvelopeStruct* pTemp = NULL; + UINT8 chRrmDstAllowed = TRAIN_RRM_OTHERCI_NOT_ALLOW;/* ԶRM-ĿTIOC*/ + UINT16 wAxisRelateCfpId = 0U;/*ιֽID*/ + UINT8 cLocalCiId = 0U; + + /*η*/ + ASSERT_RET_VALUE(((0U == (wTrainID & 0x00FFU)) || (0x00FFU == (wTrainID & 0x00FFU))), chReval, 0x80000000U); + ASSERT_RET_VALUE((0U == wTrainNextStaId) || (UINT16_MAX == wTrainNextStaId), chReval, 0x40000000U); + ASSERT_RET_VALUE((0U == wAxisSecId) || (AXIS_SECTION_SUM_MAX <= wAxisSecId), chReval, 0x20000000U); + ASSERT_RET_VALUE((EMAP_CONVER_DIR != chCheckDir) && (EMAP_SAME_DIR != chCheckDir), chReval, 0x10000000U); + + /** гŷֽ㣬ʱȡгUCT */ + pTemp = rrm_PrepareTrainRelELM(wTrainID); + + if (NULL != pTemp) + { + /*˵гŷֽ,ʱҪ鳵μͷǷվ̨*/ + /** гǷǰгǷ */ + funRtn = rrm_ChecKForwardTrainAndArea(funValid, wTrainID, pTemp, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x08000000U); + + /** гǷվ̨ */ + funRtn = rrm_CheckOtherCiTrainInSta(funValid, wTrainID, wTrainNextStaId, pTemp, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x04000000U); + } + else + { + ; /*гڷֽ㣬м*/ + } + + /** Ƿȫ߽ƶ*/ + funRtn = rrm_CheckWLBrake(funValid, wTrainID, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x02000000U); + + /** ѯRRM·״̬Ƿȷ */ + funRtn = rrm_CheckOtherCiRRMPathAndSw(funValid, wTrainID, wTrainNextStaId,pTemp, wAxisSecId, chCheckDir, &ACSeq, &NextTIOC, &NextSta, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x01000000U); + + /** ֽһվվ̨ն֮źŻ״̬Ϊ */ + funRtn = rrm_CheckOtherCiSigStatus(funValid, wTrainID, &ACSeq, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00800000U); + + /** RRM·ǷҪ󣨿//շһ£ */ + funRtn = rrm_CheckSecStatus(funValid, wTrainID, &ACSeq, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00400000U); + + /** RRM·ϰǷҪν˰ȫ */ + funRtn = rrm_CheckObsAndSafeProtect(funValid, wTrainID, &ACSeq, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00200000U); + + if ((RRM_CHECK_VALID == funValid) && (0U == errorCode)) + { + if (0U == NextTIOC) + { + /** ѯһվϢǷг͵һվһ */ + funRtn = rrm_CheckOtherCiNextStation(funValid, wTrainID, wTrainNextStaId, NextSta, &rrmReason); + ASSERT_SETRET(CI_SUCCESS == funRtn, funValid, funValid, RRM_CHECK_UNVALID); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00100000U); + + if (RRM_CHECK_VALID == funValid) + { + SetTrainOtherRcRrmReson(wTrainID, TRAIN_RRM_RESON_FF); + chReval = CI_SUCCESS; /*سɹ*/ + } + else + { + SetTrainOtherRcRrmReson(wTrainID, rrmReason); + } + } + else + { + /*ԶRM*/ + if (0U != NextSta) + { + /*ѯRM·ʱ鵽һվIDһIDʱһIDΪ0˵վ̨г͵ġз򡱲ѯֽ㴦վ̨Ȼͨ*/ + /*ԶRM:ѯֽ㴦վ̨*/ + SetTrainOtherRcRrmReson(wTrainID, TRAIN_RRM_RESON_0B); + errorCode += 0x00080000u; + } + else + { + funRtn = rrm_PrepareRcIsZXorSCX(NextTIOC); /*һǷΪ߻Գ*/ + if ((CI_SUCCESS == funRtn) && (0U < ACSeq.acCnt)) + { + /*ͨʣ*/ + wAxisRelateCfpId = GetAxisRelateCfpId(ACSeq.ACID[ACSeq.acCnt - 1U]); + SetCfpRrmSrcApplyState(wAxisRelateCfpId, TRAIN_RRM_LOCALCI_APPLY); + SetCfpRrmTrainId(wAxisRelateCfpId, wTrainID); + + SetCfpRrmTrainNextStaId(wAxisRelateCfpId, wTrainNextStaId); + + cLocalCiId = GetSystemParaLocalCiId(); + SetCfpRrmSrcRcId(wAxisRelateCfpId, cLocalCiId); + + /*ԶRMʱĿTIOC״̬*/ + chRrmDstAllowed = GetCfpRrmDstAllowState(wAxisRelateCfpId); + if (TRAIN_RRM_OTHERCI_ALLOW == chRrmDstAllowed) + { + SetTrainOtherRcRrmReson(wTrainID, TRAIN_RRM_RESON_FF); + chReval = CI_SUCCESS; /*سɹ*/ + } + else + { + SetTrainOtherRcRrmReson(wTrainID, TRAIN_RRM_RESON_15); + errorCode += 0x00040000U; + } + } + else + { + SetTrainOtherRcRrmReson(wTrainID, TRAIN_RRM_RESON_16); + errorCode += 0x00020000U; + } + } + } + } + else + { + SetTrainOtherRcRrmReson(wTrainID, rrmReason); + errorCode += 0x00010000U; + } + + ASSER_DEBUG(0U != errorCode, RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d rrm_OtherCiConditionsCheck ERROR:not allow RRM.", errorCode, wTrainID)); + + return chReval; +} + +/** + * @brief гǷվ̨ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] const UINT16 wTrainNextStaId гһվվ̨ID + * @param[in] IN const EnvelopeStruct* pTemp ָ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note by cgh 20240222 + */ +UINT8 rrm_CheckOtherCiTrainInSta(UINT8 funValid, UINT16 trainID, const UINT16 wTrainNextStaId, IN const EnvelopeStruct* pTemp, OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0U; + UINT16 headRelStaID = 0U; + UINT8 chHeadAcStatus = 0U; /*ͷռ״̬*/ + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0U == pTemp->ACCnt), ret, 0x80000000U); + ASSERT_RET_VALUE(NULL == rrmReason, ret, 0x40000000U); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffU; + } + else + { + headRelStaID = rrm_PrepareAtsLgcStaOfAC(pTemp->ACID[pTemp->ACCnt - 1U]); + ASSER_ERROR((0xffffu == headRelStaID), errorCode, 0x20000000U); + + if (0U == errorCode) + { + if (0U != headRelStaID) + { + ret = CI_ERROR; + if (wTrainNextStaId == headRelStaID) + { + chHeadAcStatus = rrm_PrepareACStatus(pTemp->ACID[pTemp->ACCnt - 1U]); + if (ELM_AC_OCC == chHeadAcStatus) + { + /** гվ̨ */ + errorCode += 0x10000000U; + *rrmReason = TRAIN_RRM_RESON_0D; + } + else + { + /*뵫ռѹδ룬ȴ*/ + ret = CI_SUCCESS; + } + } + else + { + /** гվ̨ */ + errorCode += 0x08000000U; + *rrmReason = TRAIN_RRM_RESON_0E; + } + } + else + { + /** RRM */ + ret = CI_SUCCESS; + } + } + } + ASSER_DEBUG(0U != errorCode, RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d rrm_CheckOtherCiTrainInSta error:In sta not allow RRM.", errorCode, trainID)); + return ret; +} + +/** + * @brief ѯRRM·״̬Ƿȷ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] UINT16 wAtsLgcStaId ATSͣID + * @param[out] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @param[out] UINT8 *pNextTIOC һTIOC ID + * @param[out] UINT16 *pNextSta һվ̨ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note by cgh 20240221 + */ +UINT8 rrm_CheckOtherCiRRMPathAndSw(UINT8 funValid, UINT16 trainID, UINT16 wAtsLgcStaId, IN const EnvelopeStruct* pTemp,UINT16 wAxieSecId, UINT8 chCheckDir, OUT RRMPathOfACSeqStruct* pACSeq, OUT UINT8* pNextTIOC, OUT UINT16* pNextSta, OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0U; + UINT8 validFlag = 0U; + UINT8 funRtn = CI_ERROR; + UINT16 nexStaID = 0U; + UINT8 nextOCId = 0U; + UINT8 ACIsOwn = 0U; + UINT16 cyclePath = 0U; + UINT16 curACID = 0U; + UINT8 curDir = 0U; + UINT16 nextACCnt = 0u; + UINT16 nextACId[AC_MAXCNT_IN_SWITCH] = { 0U }; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 cycle = 0U; + UINT8 chAtsLgcStaIsOwnCheck = CI_ERROR;/*ATS·ͣIDǷڱ*/ + UINT8 chHeadStationCheck = 0U;/*ͷվ̨*/ + + /** ڲУ*/ + ASSERT_RET_VALUE(NULL == rrmReason, ret, 0x80000000U); + ASSERT_RET_VALUE(NULL == pACSeq, ret, 0x40000000U); + ASSERT_RET_VALUE(NULL == pNextTIOC, ret, 0x20000000U); + ASSERT_RET_VALUE(NULL == pNextSta, ret, 0x10000000U); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffU; + } + else + { + if (NULL != pTemp) + { + if ((wAxieSecId == pTemp->ACID[0U]) && (chCheckDir == pTemp->startPos.Dir)) + { + /*˵гǿŷֽԶRM*/ + curACID = pTemp->ACID[0U]; + curDir = pTemp->startPos.Dir; + + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_A, pACSeq); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x04000000U); + + for (cycle = 1U; cycle < pTemp->ACCnt; cycle++) + { + nextACCnt = rrm_PrepareAdjacentAC(curACID, curDir, nextACId, &cDirectionPointFlag); + + /** ѯΣλòҪ߲ѯͷʧ */ + if ((1U == nextACCnt) && (nextACId[0U] == pTemp->ACID[cycle])) + { + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + /** ׼ѯ */ + curACID = nextACId[0U]; + + /** ѯɹļ뵽 */ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_A, pACSeq); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x02000000U); + } + else + { + /** ѯΣλòҪ߲ѯͷʧܻ߰· */ + errorCode += 0x01000000U; + break; + } + } + + /*Ϊ˵гŷֽ㣬ʱг·Ѿӹȡһ*/ + nextACCnt = rrm_PrepareAdjacentAC(curACID, curDir, nextACId, &cDirectionPointFlag); + ASSER_ERROR(((1U != nextACCnt) && (0U != nextACCnt)), errorCode, 0x00800000U); + + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + /** ׼ѯ */ + curACID = nextACId[0U]; + } + else + { + errorCode += 0x08000000U; + } + } + else + { + /** ķֽ*/ + curACID = wAxieSecId; + curDir = chCheckDir; + } + + if (0U == errorCode) + { + chHeadStationCheck = rrm_CheckTrainHeadInFreeSta(trainID, pTemp,&nexStaID); + if (CI_SUCCESS == chHeadStationCheck) + { + if (0U == nextACCnt) + { + /** һĿΪ0˵Ǿͷߣʱ¼һվ̨ǰΣҪ¼¼߼վ̨ID by cgh 20231102*/ + ; + } + else + { + /** ѯɹļ뵽*/ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_C, pACSeq); + ASSER_ERROR(CI_ERROR == funRtn, errorCode, 0x00002000u); + } + + /** һվվ̨ID*/ + *pNextSta = nexStaID; + + /** ѭ */ + validFlag = 0xffu; + } + else + { + nexStaID = 0U; /**/ + } + } + else + { + ; /*ִм*/ + } + + + /** ѯֽ㵽һվ̨֮ļ */ + while ((0U == validFlag) && (0U == errorCode)) + { + /** жǷΪվ̨ */ + nexStaID = rrm_PrepareAtsLgcStaOfAC(curACID); + ASSERT_BREAK(0xffffU == nexStaID, errorCode, 0x00400000U); + + /** ѯǷڱ */ + ACIsOwn = rrm_PrepareACIsSelf(curACID, &nextOCId); + ASSERT_BREAK(0U == nextOCId, errorCode, 0x00200000U); + + /** rrm_AddACInRRMPathSeqѭ */ + nextACCnt = rrm_PrepareAdjacentAC(curACID, curDir, nextACId, &cDirectionPointFlag); + + if ((ELM_BELONG_OWNER != ACIsOwn) && (0u != nextOCId)) + { + /*Ҫжϼ + *жվ̨гֽҳͷڿվ̨ʱȲ鵽վ̨첢ҽTYPE_OF_PATH_BμʱΪռöʧܣRCRRM󷽰*/ + + chAtsLgcStaIsOwnCheck = rrm_PrepareAtsLgcStaIsOwn(wAtsLgcStaId); + if (CI_SUCCESS == chAtsLgcStaIsOwnCheck) + { + /*RRMվ̨IDΪվ̨гǰ·г󷽻гǰΪйվ̨й + *ӦֱӼʧܲRC*/ + + *pNextTIOC = nextOCId; /** һTIOC ID*/ + } + else + { + ; + } + ASSER_ERROR(CI_ERROR == chAtsLgcStaIsOwnCheck, errorCode, 0x00004000U); + validFlag = 0xffu; /** ˳ѭ */ + } + else if (0U != nexStaID) + { + if (0U == nextACCnt) + { + /** һĿΪ0˵Ǿͷߣʱ¼һվ̨ǰΣҪ¼¼߼վ̨ID by cgh 20231102*/ + ; + } + else + { + /** ѯɹļ뵽*/ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_B, pACSeq); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x00100000U); + + /** ѯΣλòҪ */ + ASSERT_BREAK((1U != nextACCnt) || (nextACId[0U] == pACSeq->ACID[pACSeq->acCnt - 1U]), errorCode, 0x00080000U); + + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + /** ׼ѯ */ + curACID = nextACId[0U]; + + /** ѯɹļ뵽*/ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_C, pACSeq); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x00040000U); + } + + /** һվվ̨ID*/ + *pNextSta = nexStaID; + + /** ˳ѭ */ + validFlag = 0xffU; + } + else + { + + /** ѯɹļ뵽*/ + funRtn = rrm_AddACInRRMPathSeq(curACID, curDir, TYPE_OF_PATH_B, pACSeq); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x00020000U); + + /** ѯΣλòҪ߲ѯͷʧ */ + ASSERT_BREAK((1U != nextACCnt) || (nextACId[0U] == pACSeq->ACID[pACSeq->acCnt - 1U]), errorCode, 0x00010000U); + + /** жǷ仯 */ + curDir = (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) ? ((UINT8)(~curDir)) : curDir; + + /** ׼ѯ */ + curACID = nextACId[0U]; + } + } + + if (0U != errorCode) + { + if (0x00004000U == (errorCode & 0x00004000U)) + { + *rrmReason = TRAIN_RRM_RESON_0B; + } + else + { + *rrmReason = TRAIN_RRM_RESON_0A; + } + ret = CI_ERROR; + } + else + { + /** У·ڵĵλǷȷ */ + for (cyclePath = 0U; cyclePath < pACSeq->acCnt; cyclePath++) + { + funRtn = rrm_PrepareSwitchStatOfAC(pACSeq->ACID[cyclePath]); + ASSERT_BREAK(CI_ERROR == funRtn, errorCode, 0x00008000U); + } + + if (cyclePath == pACSeq->acCnt) + { + ret = CI_SUCCESS; + } + else + { + *rrmReason = TRAIN_RRM_RESON_0A; + ret = CI_ERROR; + } + } + } + + debug_infor_printf((const)"rrm_CheckOtherCiRRMPathAndSw:num = %d\n", pACSeq->acCnt); + debug_out_array(0xAA, pACSeq->ACID, pACSeq->acCnt * 2u); + + ASSER_DEBUG(0U != errorCode, RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d rrm_CheckOtherCiRRMPathAndSw error:not allow RRM by seach Path error .", errorCode, trainID)); + return ret; +} + +/** + * @brief ѯһվϢǷг͵һվһ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] const UINT16 wTrainNextStaId гһվվ̨ID + * @param[in] UINT16 searchNextStaID ѯһվ̨ID + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note by cgh 20240221 + */ +UINT8 rrm_CheckOtherCiNextStation(UINT8 funValid,UINT16 trainID, const UINT16 wTrainNextStaId, const UINT16 searchNextStaID, OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0U; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == rrmReason, ret, 0x80000000U); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffU; + } + else + { + if (wTrainNextStaId == searchNextStaID) + { + ret = CI_SUCCESS; + } + else + { + *rrmReason = TRAIN_RRM_RESON_0B; + errorCode += 0x40000000U; + ret = CI_ERROR; + } + } + + ASSER_DEBUG(0U != errorCode, RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d rrm_CheckOtherCiNextStation error:not allow RRM by dst error.", errorCode, trainID)); + return ret; +} + +/** + * @brief гͷǰһվվ̨ն֮źŻ״̬Ϊ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note BY CGH 20240222 + */ +UINT8 rrm_CheckOtherCiSigStatus(UINT8 funValid, UINT16 trainID, IN const RRMPathOfACSeqStruct* pACSeq, OUT UINT8* rrmReason) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0U; + UINT16 cycle = 0U; + UINT16 headOfRoute = 0U; /*ͷڽ·ID*/ + UINT16 tempofRoute = 0U; + UINT8 sigOfRoutePass = CI_ERROR; + UINT8 cCheckFlag = FLAG_UNSET; + UINT8 cLocalCiId = 0U; + UINT8 cRouteBelongCiId = 0U; + UINT8 cRouteState = 0U; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pACSeq, ret, 0x80000000U); + ASSERT_RET_VALUE(NULL == rrmReason, ret, 0x40000000U); + + if (RRM_CHECK_UNVALID == funValid) + { + ret = 0xffU; + } + else + { + for (cycle = 0U; cycle < pACSeq->acCnt; cycle++) + { + if (TYPE_OF_PATH_A == pACSeq->pathType[cycle]) + { + /*dzΣ³ɳͷһ·*/ + headOfRoute = rrm_PrepareAcofRoute(pACSeq->ACID[cycle]); + if (0U == headOfRoute) + { + cCheckFlag = FLAG_SET; /** ν·δô϶δ */ + } + else + { + ; + } + } + else if (TYPE_OF_PATH_C == pACSeq->pathType[cycle]) + { + /** 账*/ + } + else if (TYPE_OF_PATH_B == pACSeq->pathType[cycle]) + { + /** ѯǰѰ· */ + tempofRoute = rrm_PrepareAcofRoute(pACSeq->ACID[cycle]); + + if (0U == tempofRoute) + { + cCheckFlag = FLAG_SET; /** ν·δô϶δ */ + } + else if (tempofRoute == headOfRoute) + { + /** жϸý·ʼźŻ״̬*/ + } + else + { + /** жϸý·ʼźŻ״̬Ƿ񿪷 */ + sigOfRoutePass = rrm_PrepareOriginSigStatOfRoute(tempofRoute); + + if (CI_SUCCESS == sigOfRoutePass) + { + /** źſţ*/ + } + else + { + cLocalCiId = GetSystemParaLocalCiId(); + cRouteBelongCiId = GetRouteBelongCiId(tempofRoute); + cRouteState = GetRouteState(tempofRoute); + + if ((cLocalCiId != cRouteBelongCiId) && (0U != cRouteBelongCiId) && (0U != cLocalCiId) + && ((ROUTE_STATE_NEAR_LOCK == cRouteState) || (ROUTE_STATE_AUTO_UNLOCK == cRouteState) + || (ROUTE_STATE_DELAY_UNLOCK == cRouteState) || (ROUTE_STATE_HALF_UNLOCK == cRouteState))) + { + /*DZڵźرգ*/ + } + else + { + cCheckFlag = FLAG_SET; /*ڵźŹرգʧ*/ + } + } + } + } + else + { + cCheckFlag = FLAG_SET; /** ·󣬼ʧ*/ + } + + if (FLAG_SET == cCheckFlag) + { + break; + } + else + { + ; /**/ + } + } + + if (cycle == pACSeq->acCnt) + { + ret = CI_SUCCESS; + } + else + { + *rrmReason = TRAIN_RRM_RESON_05; + errorCode += 0x20000000u; + ret = CI_ERROR; + } + } + + ASSER_DEBUG(0U != errorCode, RRM_LOG_LOC(RRM_LOG_ERROR, "errno:0x%08x info:Train%d rrm_CheckOtherCiSigStatus error:not allow RRM by route%d signal not open.", errorCode, trainID, tempofRoute)); + return ret; +} + +/** + * @brief ǷгͷĿվ̨ռѹδ + * @param[in] UINT16 trainID гID + * @param[in] IN const EnvelopeStruct* pTemp ָ + * @param[out] UINT16* pNextSta һվ̨ + * @return UINT8 + CI_ERROR + CI_SUCCESS + * by cgh 20241022 + */ +static UINT8 rrm_CheckTrainHeadInFreeSta(UINT16 trainID, IN const EnvelopeStruct* pTemp, OUT UINT16* pNextSta) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0U; + UINT16 headRelStaID = 0U; + UINT16 trainNextSta = 0U; + UINT8 chHeadAcStatus = 0U; /*ͷռ״̬*/ + + /** ڲУ */ + ASSERT_RET_VALUE((NULL == pTemp) || (0U == pTemp->ACCnt), errorCode, 0x80000000U); + + headRelStaID = rrm_PrepareAtsLgcStaOfAC(pTemp->ACID[pTemp->ACCnt - 1U]); + + ASSER_ERROR((0xffffU == headRelStaID), errorCode, 0x40000000U); + + if (0U == errorCode) + { + trainNextSta = rrm_PrepareNextStaOfTrain(trainID); + + if (0U != headRelStaID) + { + + if (trainNextSta == headRelStaID) + { + chHeadAcStatus = rrm_PrepareACStatus(pTemp->ACID[pTemp->ACCnt - 1U]); + if (ELM_AC_FREE == chHeadAcStatus) + { + *pNextSta = headRelStaID; + ret = CI_SUCCESS; + } + else + { + /*Ŀվ̨ռãǰ鷵ش󣬴˴ʵɴΪ쳣 */ + ret = CI_ERROR; + } + } + else + { + errorCode = 0x20000000U; + /*Ŀվִ̨·*/ + ret = CI_ERROR; + } + } + else + { + /** ͷվ̨ */ + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + ASSER_DEBUG(0U != errorCode, RRM_LOG_LOC(RRM_LOG_ERROR, (const)"errno:0x%08x info:Train%d headexistStationButNotNextSta.", errorCode, trainID)); + return ret; +} + diff --git a/TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.h b/TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.h new file mode 100644 index 0000000..1c89d66 --- /dev/null +++ b/TSCP/src/APP/ciapp/RemoteRM/RRMManageAPI.h @@ -0,0 +1,103 @@ +/****************************************************************************** +** ļ: RRMManageAPI.h +** : ԶRMģӿ +*******************************************************************************/ +#ifndef RRM_MANAGE_API_H_ +#define RRM_MANAGE_API_H_ +#include "RRMDefine.h" + + +/** + * @brief ӿڣԶRM + * @param[in] + * @param[out] + * @return + * @note + */ +void rrm_MainProcess(void); + + +/** + * @brief ӿڣȡ͸ATSUCTгϢ + * @param[in] + * @param[out] ATSTrainInfoStru* pInfo) + * @return + * @note + */ +void rrm_GetInfToATSUCTInfo(OUT ATSTrainInfoStru* pInfo); + +/** + * @brief RRM + * @param[in] const UINT16 wTrainID гID + * @param[in] const UINT16 wTrainNextStaId гһվվ̨ID + * @param[in] const UINT16 wAxisSecId ߽ID + * @param[in] const UINT8 chCheckDir ѯ + * @param[out] + * @return CI_ERROR ʧ + * CI_SUCCESS ɹ + * @note by cgh 20240221 + */ +UINT8 rrm_OtherCiConditionsCheck(const UINT16 wTrainID, const UINT16 wTrainNextStaId, const UINT16 wAxisSecId, const UINT8 chCheckDir); + +/** + * @brief гǷվ̨ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] const UINT16 wTrainNextStaId гһվվ̨ID + * @param[in] IN const EnvelopeStruct* pTemp ָ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note by cgh 20240222 + */ +UINT8 rrm_CheckOtherCiTrainInSta(UINT8 funValid, UINT16 trainID, const UINT16 wTrainNextStaId, IN const EnvelopeStruct* pTemp, OUT UINT8* rrmReason); + +/** + * @brief ѯRRM·״̬Ƿȷ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] UINT16 wAtsLgcStaId ATSͣID + * @param[out] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @param[out] UINT8 *pNextTIOC һTIOC ID + * @param[out] UINT16 *pNextSta һվ̨ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note by cgh 20240221 + */ +UINT8 rrm_CheckOtherCiRRMPathAndSw(UINT8 funValid, UINT16 trainID, UINT16 wAtsLgcStaId, IN const EnvelopeStruct* pTemp, UINT16 wAxieSecId, UINT8 chCheckDir, OUT RRMPathOfACSeqStruct* pACSeq, OUT UINT8* pNextTIOC, OUT UINT16* pNextSta, OUT UINT8* rrmReason); + +/** + * @brief ѯһվϢǷг͵һվһ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] const UINT16 wTrainNextStaId гһվվ̨ID + * @param[in] UINT16 searchNextStaID ѯһվ̨ID + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note by cgh 20240221 + */ +UINT8 rrm_CheckOtherCiNextStation(UINT8 funValid, UINT16 trainID, const UINT16 wTrainNextStaId, const UINT16 searchNextStaID, OUT UINT8* rrmReason); + +/** + * @brief гͷǰһվվ̨ն֮źŻ״̬Ϊ + * @param[in] UINT8 funValid Ա־ + * @param[in] UINT16 trainID гID + * @param[in] RRMPathOfACSeqStruct* pACSeq RRM·ļ + * @param[out] UINT8* rrmReason + * @return UINT8 + CI_ERROR ʧ + CI_SUCCESS ɹ + 0xFF δ + * @note BY CGH 20240222 + */ +UINT8 rrm_CheckOtherCiSigStatus(UINT8 funValid, UINT16 trainID, IN const RRMPathOfACSeqStruct* pACSeq, OUT UINT8* rrmReason); + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ReverseCut/ReverseCutConfigDataManage.c b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutConfigDataManage.c new file mode 100644 index 0000000..f268dd8 --- /dev/null +++ b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutConfigDataManage.c @@ -0,0 +1,168 @@ +/******************************************************** +* +* ReverseCutConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2022-06-15 +* ߣ +* װݹ +* ޸ļ¼ +* +********************************************************/ + +#include "ReverseCutConfigDataManage.h" + + +ReverseCutCfgDataStru gstReverseCutCfgData[REVERSE_CUT_SUM_MAX] = { 0U }; /*嵹װýṹ*/ +UINT16 gReverseCutCfgIdBuf[REVERSE_CUT_SUM_MAX] = { 0U }; /*嵹װID */ +INT16 gReverseCutCfgSum = 0; /*嵹װ */ + + +/* +* ȡװõǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: װõǰ +*/ +UINT16 GetReverseCutCurSum(void) +{ + UINT16 retVal = 0u; + if ((INT16)REVERSE_CUT_SUM_MAX <= gReverseCutCfgSum) + { + retVal = REVERSE_CUT_SUM_MAX; + } + else if (0 > gReverseCutCfgSum) + { + retVal = 0u; + } + else + { + retVal = (UINT16)gReverseCutCfgSum; + } + return retVal; +} + +/* +* ȡָID +* ˵ const UINT16 wReverseCutId, ID +* ֵ REVERSE_CUT_SUM_MAX: ȡʧ +* wReverseCutId)) + { + wRetVal = wReverseCutId; + } + + return wRetVal; +} + +/* +* ȡָ±ӦĵID +* ˵ const UINT16 wBufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetReverseCutId(const UINT16 wBufIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 wReverseCutCurSum = GetReverseCutCurSum(); + if (wBufIndex < wReverseCutCurSum) + { + retVal = gReverseCutCfgIdBuf[wBufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDм̵ID +* ˵ const UINT16 wReverseCutId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetReverseCutRelayId(const UINT16 wReverseCutId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRetVal = CI_ERROR; + + wBufIndex = GetReverseCutCfgBufIndex(wReverseCutId); /*ȡ±*/ + + if (REVERSE_CUT_SUM_MAX > wBufIndex) + { + wRetVal = gstReverseCutCfgData[wBufIndex].wReverseRelayId; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/* +* ȡָID豸ID +* ˵ const UINT16 wReverseCutId, ID +* ֵ 0: ȡʧ +* >0: TIOC ID +*/ +UINT8 GetReverseCutBelongCiId(const UINT16 wReverseCutId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = CI_ERROR; + + wBufIndex = GetReverseCutCfgBufIndex(wReverseCutId); /*ȡ±*/ + + if (REVERSE_CUT_SUM_MAX > wBufIndex) + { + chRetVal = gstReverseCutCfgData[wBufIndex].chBelongCiId; + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + +/* +* ĵ豸 +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 ReverseCutConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 wReverseCutDataSum = 0u; /*źŻ豸*/ + UINT8 ret = CI_ERROR; + UINT8 localCiId = GetSystemParaLocalCiId(); + + /*źŻID*/ + wReverseCutDataSum = GetReverseCutCurSum(); + if (wReverseCutDataSum < REVERSE_CUT_SUM_MAX) + {/**/ + + for (ii = 0u; ii < REVERSE_CUT_SUM_MAX; ii++) + { + if (jj == wReverseCutDataSum) + {/*Ч*/ + + break; + } + if (localCiId == gstReverseCutCfgData[ii].chBelongCiId) + {/*òΪЧ*/ + + gReverseCutCfgIdBuf[jj] = gstReverseCutCfgData[ii].wId; + jj++; + } + } + ret = CI_SUCCESS; + } + + return ret; + +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ReverseCut/ReverseCutConfigDataManage.h b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutConfigDataManage.h new file mode 100644 index 0000000..32598fa --- /dev/null +++ b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutConfigDataManage.h @@ -0,0 +1,89 @@ +/******************************************************** +* +* ReverseCutConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2022-06-15 +* ߣ +* װݹͷļ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _REVERSE_CUT_CONFIG_DATA_MANAGE_H_ +#define _REVERSE_CUT_CONFIG_DATA_MANAGE_H_ + +#include "ReverseCutDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + /*ݽṹ*/ + typedef struct S_ReverseCutConfigDataStruct + { + UINT16 wId; /*ֶţ̵IDһ*/ + UINT8 chBelongCiId; /*TIOC ID*/ + UINT16 wReverseRelayId; /*м̵ID ()*/ + }ReverseCutCfgDataStru; + + /*******************************ȫֱ*******************************/ + extern ReverseCutCfgDataStru gstReverseCutCfgData[REVERSE_CUT_SUM_MAX]; /*嵹װýṹ*/ + extern UINT16 gReverseCutCfgIdBuf[REVERSE_CUT_SUM_MAX]; /*嵹װID */ + extern INT16 gReverseCutCfgSum; /*嵹װ */ + + /* + * ȡװõǰ + * ˵ void + * ֵ 0: ȡʧ + * >0: װõǰ + */ + UINT16 GetReverseCutCurSum(void); + + /* + * ȡָID + * ˵ const UINT16 wReverseCutId, ID + * ֵ LOGIC_SECTION_SUM_MAX: ȡʧ + * 0: ID + */ + UINT16 GetReverseCutId(const UINT16 wBufIndex); + + /* + * ȡָIDм̵ID + * ˵ const UINT16 wReverseCutId, ID + * ֵ 0: ȡʧ + * >0: ID + */ + UINT16 GetReverseCutRelayId(const UINT16 wReverseCutId); + + /* + * ȡָID豸ID + * ˵ const UINT16 wReverseCutId, ID + * ֵ 0: ȡʧ + * >0: TIOC ID + */ + UINT8 GetReverseCutBelongCiId(const UINT16 wReverseCutId); + + /* + * ĵ豸 + * ˵ + * ֵ CI_SUCCESS,ɹ + * CI_ERROR,ʧ + */ + UINT8 ReverseCutConfigDataManage(void); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDataManage.c b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDataManage.c new file mode 100644 index 0000000..14ee6d2 --- /dev/null +++ b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDataManage.c @@ -0,0 +1,240 @@ +/******************************************************** +* +* ReverseCutDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2022-06-15 +* ߣ +* װö̬ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "ReverseCutDataManage.h" +#include "ReverseCutConfigDataManage.h" + +ReverseCutDataStru gstReverseCutData[REVERSE_CUT_SUM_MAX] = { 0U }; /*嵹װݶ̬ݽṹ*/ +UINT8 gTiocSystemMode = 0U; /*TIOCģʽ (Ӱģʽ ģʽ)*/ +UINT8 gTiocSystemCutState = 0U; /*TIOCܷ״̬ (ܷлĬ)*/ +UINT8 gTiocCanntCutReason = 0U; /*ɵԭ*/ + + +/* +* ȡTIOCɵ״̬ +* ˵ void +* ֵ REVERSE_CUT_STATE_NORMAL: ɵ +* REVERSE_CUT_STATE_EXCEPTION: 쳣ɵ +* REVERSE_CUT_STATE_DEFAULT: Ĭϵ״̬(ģʽ) +*/ +UINT8 GetTiocSystemCutState(void) +{ + UINT8 retVal = 0u; + + if ((REVERSE_CUT_STATE_NORMAL == gTiocSystemCutState) + || (REVERSE_CUT_STATE_EXCEPTION == gTiocSystemCutState) + || (REVERSE_CUT_STATE_DEFAULT == gTiocSystemCutState)) + { + retVal = gTiocSystemCutState; + } + else + { + retVal = REVERSE_CUT_STATE_DEFAULT; + } + return retVal; +} + + +/* +* TIOCɵ״̬ +* ˵ const UINT8 chSystemCutState ϵͳɵ״̬ +* ֵ +*/ +void SetTiocSystemCutState(const UINT8 chSystemCutState) +{ + if ((REVERSE_CUT_STATE_NORMAL == chSystemCutState) + || (REVERSE_CUT_STATE_EXCEPTION == chSystemCutState) + || (REVERSE_CUT_STATE_DEFAULT == chSystemCutState)) + { + gTiocSystemCutState = chSystemCutState; + } + else + { + gTiocSystemCutState = REVERSE_CUT_STATE_EXCEPTION; + } +} +/* +* ȡTIOCɵԭ +* ˵ void +* ֵ REVERSE_REASON_OC_COMM_ERR : ͨ쳣 +* REVERSE_REASON_IVOC_COMM_ERR: IVOCͨ쳣 +* REVERSE_REASON_AXLE_COMM_ERR: ϵͳͨ쳣 +*/ +UINT8 GetTiocCanntCutReason(void) +{ + UINT8 retVal = gTiocCanntCutReason; + + return retVal; +} + +/* +* TIOCɵԭ +* ˵ const UINT8 chCanntCutReason ɵԭ +* ֵ +*/ +void SetTiocCanntCutReason(const UINT8 chCanntCutReason) +{ + if ((REVERSE_REASON_OC_COMM_ERR == chCanntCutReason) + || (REVERSE_REASON_IVOC_COMM_ERR == chCanntCutReason) + || (REVERSE_REASON_AXLE_COMM_ERR == chCanntCutReason)) + { + gTiocCanntCutReason |= chCanntCutReason; + } + else if (0U == chCanntCutReason) + { + gTiocCanntCutReason = 0U; + } + else + { + gTiocCanntCutReason = REVERSE_REASON_OC_COMM_ERR | REVERSE_REASON_IVOC_COMM_ERR | REVERSE_REASON_AXLE_COMM_ERR; + } +} + +/* +* TIOCģʽ +* ˵ const UINT8 chSystemMode ϵͳģʽ +* ֵ +*/ +void SetTiocSystemMode(const UINT8 chSystemMode) +{ + if ((REVERSE_MODE_MAIN == chSystemMode) + || (REVERSE_MODE_SHADOW == chSystemMode)) + { + gTiocSystemMode = chSystemMode; + } + else + { + gTiocSystemMode = REVERSE_MODE_SHADOW; + } +} +/* +* ȡTIOCģʽ +* ˵ void +* ֵ REVERSE_MODE_MAIN: ģʽ +* REVERSE_MODE_SHADOW: Ӱģʽ +*/ +UINT8 GetTiocSystemMode(void) +{ + UINT8 retVal = 0u; + + if ((REVERSE_MODE_MAIN == gTiocSystemMode) + || (REVERSE_MODE_SHADOW == gTiocSystemMode)) + { + retVal = gTiocSystemMode; + } + else + { + retVal = REVERSE_MODE_SHADOW; + } + return retVal; +} + + +/* +* ȡָIDװ״̬ +* ˵ const UINT16 wReverseCutId, ID +* ֵ 0: ȡʧ +* REVERSE_DEVICE_CUT_STATE_UP: 豸״̬ +* REVERSE_DEVICE_CUT_STATE_DOWN豸״̬ +*/ +UINT8 GetReverseCutState(const UINT16 wReverseCutId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = CI_ERROR; + + wBufIndex = GetReverseCutCfgBufIndex(wReverseCutId); /*ȡ±*/ + + if (REVERSE_CUT_SUM_MAX > wBufIndex) + { + chRetVal = (UINT8)gstReverseCutData[wBufIndex].wReverseState; + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + +/* +* ָIDװ״̬ +* ˵ const UINT16 wReverseCutId, ID +* const UINT8 chReverseCutState,״̬ +* ֵ +*/ +void SetReverseCutState(const UINT16 wReverseCutId,const UINT8 chReverseCutState) +{ + UINT16 wBufIndex = 0u; /*±*/ + + wBufIndex = GetReverseCutCfgBufIndex(wReverseCutId); /*ȡ±*/ + + if (REVERSE_CUT_SUM_MAX > wBufIndex) + { + if ((REVERSE_DEVICE_CUT_STATE_UP == chReverseCutState) + || (REVERSE_DEVICE_CUT_STATE_DOWN == chReverseCutState)) + { + gstReverseCutData[wBufIndex].wReverseState = chReverseCutState; + } + } + else + { + + } +} + +/* +* 豸ݳʼ +* ˵ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 ReverseCutDataManageInit(void) +{ + UINT8 ret = CI_ERROR; + UINT16 wReverseCutSum = 0u; + UINT16 wReverseCutId = 0u; + UINT16 i = 0u; + UINT16 wIndex = 0u; + UINT8 chDsnLinSwitch = 0U; + chDsnLinSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + /* ȡ߽ */ + wReverseCutSum = GetReverseCutCurSum(); + if (REVERSE_CUT_SUM_MAX > wReverseCutSum) + { + for (i = 0u; i < wReverseCutSum; i++) + { + /* ȡ߽ID */ + wReverseCutId = GetCfpId(i); + wIndex = GetReverseCutCfgBufIndex(wReverseCutId); + gstReverseCutData[wIndex].wReverseCutId = wReverseCutId; + gstReverseCutData[wIndex].wReverseState= REVERSE_DEVICE_CUT_STATE_DOWN; + } + if (FUNC_SWITCH_ON == chDsnLinSwitch) + { + gTiocSystemMode = REVERSE_MODE_SHADOW; + gTiocSystemCutState = REVERSE_CUT_STATE_EXCEPTION; + gTiocCanntCutReason = REVERSE_REASON_OC_COMM_ERR | REVERSE_REASON_IVOC_COMM_ERR | REVERSE_REASON_AXLE_COMM_ERR; + } + else + { + gTiocSystemMode = REVERSE_MODE_MAIN; + gTiocSystemCutState = REVERSE_CUT_STATE_EXCEPTION; + gTiocCanntCutReason = 0U; + } + ret = CI_SUCCESS; + } + else + { + ;/* ʼʧ */ + } + + + return ret; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDataManage.h b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDataManage.h new file mode 100644 index 0000000..3e9445e --- /dev/null +++ b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDataManage.h @@ -0,0 +1,115 @@ +/******************************************************** +* +* ReverseCutDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2022-06-15 +* ߣ +* װö̬ݹͷļ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _REVERSE_CUT_DATA_MANAGE_H_ +#define _REVERSE_CUT_DATA_MANAGE_H_ + + +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "ReverseCutDefine.h" +#include "../CutoffPoint/CutoffPointConfigDataManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /*ݽṹ*/ + typedef struct S_ReverseCutDataStruct + { + UINT16 wReverseCutId; /*״̬*/ + UINT16 wReverseState; /*״̬*/ + }ReverseCutDataStru; + + /*******************************ȫֱ*******************************/ + extern ReverseCutDataStru gstReverseCutData[REVERSE_CUT_SUM_MAX]; /*嵹װݶ̬ݽṹ*/ + extern UINT8 gTiocSystemMode; + extern UINT8 gTiocSystemCutState; + extern UINT8 gTiocCanntCutReason; + +/* +* ȡTIOCɵ״̬ +* ˵ void +* ֵ REVERSE_CUT_STATE_NORMAL: ɵ +* REVERSE_CUT_STATE_EXCEPTION: 쳣ɵ +* REVERSE_CUT_STATE_DEFAULT: Ĭϵ״̬(ģʽ) +*/ +UINT8 GetTiocSystemCutState(void); + + +/* +* TIOCģʽ +* ˵ const UINT8 chSystemCutState ϵͳɵ״̬ +* ֵ +*/ +void SetTiocSystemCutState(const UINT8 chSystemCutState); + +/* +* ȡTIOCɵԭ +* ˵ void +* ֵ REVERSE_REASON_OC_COMM_ERR : ͨ쳣 +* REVERSE_REASON_IVOC_COMM_ERR: IVOCͨ쳣 +* REVERSE_REASON_AXLE_COMM_ERR: ϵͳͨ쳣 +*/ +UINT8 GetTiocCanntCutReason(void); + +/* +* TIOCɵԭ +* ˵ const UINT8 chCanntCutReason ɵԭ +* ֵ +*/ +void SetTiocCanntCutReason(const UINT8 chCanntCutReason); + +/* +* TIOCģʽ +* ˵ const UINT8 chSystemMode ϵͳģʽ +* ֵ +*/ +void SetTiocSystemMode(const UINT8 chSystemMode); +/* +* ȡTIOCģʽ +* ˵ void +* ֵ REVERSE_MODE_MAIN: ģʽ +* REVERSE_MODE_SHADOW: Ӱģʽ +*/ +UINT8 GetTiocSystemMode(void); + + +/* +* ȡָIDװ״̬ +* ˵ const UINT16 wReverseCutId, ID +* ֵ 0: ȡʧ +* REVERSE_DEVICE_CUT_STATE_UP: 豸״̬ +* REVERSE_DEVICE_CUT_STATE_DOWN豸״̬ +*/ +UINT8 GetReverseCutState(const UINT16 wReverseCutId); + +/* +* ָIDװ״̬ +* ˵ const UINT16 wReverseCutId, ID +* const UINT8 chReverseCutState,״̬ +* ֵ +*/ +void SetReverseCutState(const UINT16 wReverseCutId, const UINT8 chReverseCutState); + +/* +* 豸ݳʼ +* ˵ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 ReverseCutDataManageInit(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDefine.h b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDefine.h new file mode 100644 index 0000000..325b0d7 --- /dev/null +++ b/TSCP/src/APP/ciapp/ReverseCut/ReverseCutDefine.h @@ -0,0 +1,34 @@ +/******************************************************** +* +* ReverseCutDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2022-06-15 +* ߣ +* װö̬ݹͷļ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _REVERSE_CUT_DEFINE_H_ +#define _REVERSE_CUT_DEFINE_H_ + +/*豸ֵ*/ +#define REVERSE_CUT_SUM_MAX ((UINT16)1000) /*嵹豸ֵ*/ +/*ÿ豸״̬*/ +#define REVERSE_DEVICE_CUT_STATE_UP ((UINT8)0xAA) /*豸״̬ */ +#define REVERSE_DEVICE_CUT_STATE_DOWN ((UINT8)0x55) /*豸״̬ */ + +/*ܷ״̬ ģʽдĬֵ*/ +#define REVERSE_CUT_STATE_NORMAL ((UINT8)0xAA) /*״̬ ɵ*/ +#define REVERSE_CUT_STATE_EXCEPTION ((UINT8)0x55) /*״̬ ɵ*/ +#define REVERSE_CUT_STATE_DEFAULT ((UINT8)0x00) /*״̬ Ĭֵ*/ + +/*ģʽ*/ +#define REVERSE_MODE_MAIN ((UINT8)0x55) /*ģʽ ģʽ*/ +#define REVERSE_MODE_SHADOW ((UINT8)0xAA) /*ģʽ ģʽ*/ + +/*ɵԭ*/ +#define REVERSE_REASON_OC_COMM_ERR ((UINT8)0x01) /*ɵԭ OCͨŹ*/ +#define REVERSE_REASON_IVOC_COMM_ERR ((UINT8)0x02) /*ɵԭ IVOCͨŹ*/ +#define REVERSE_REASON_AXLE_COMM_ERR ((UINT8)0x04) /*ɵԭ ϵͳͨŹ*/ +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteConfigDataManage.c b/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteConfigDataManage.c new file mode 100644 index 0000000..163e7d6 --- /dev/null +++ b/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteConfigDataManage.c @@ -0,0 +1,224 @@ +/******************************************************** +* +* ReverseRouteConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-10-22 +* ߣ +* ·ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "ReverseRouteConfigDataManage.h" + +ReverseRouteConfigDataStruct ReverseRouteConfigDataStru[ROUTE_SUM_MAX] = {0u}; /*巴·ýṹ ROUTE_SUM_MAX:ʹ"·",ΪreverseRouteId·IDŽ·ID,ûжһ෴·ID;ReverseRouteConfigDataStru[]±ǰ·IDӳ*/ +UINT16 LocalCiReverseRouteIdBuf[REVERSE_ROUTE_SUM_MAX] = {0u}; /*屾·IDӳREVERSE_ROUTE_SUM_MAX:LocalCiReverseRouteIdBuf[]ID̴ŵ*/ +INT16 ReverseRouteCurSum = 0; /*·ǰ*/ + + +/* +* ȡ·ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ·ǰ +*/ +UINT16 GetReverseRouteCurSum(void) +{ + UINT16 reverseRouteCurSum = 0u; + if (ReverseRouteCurSum >= (INT16)REVERSE_ROUTE_SUM_MAX) + { + reverseRouteCurSum = REVERSE_ROUTE_SUM_MAX; + } + else if (ReverseRouteCurSum < 0) + { + reverseRouteCurSum = 0u; + } + else + { + reverseRouteCurSum = (UINT16)ReverseRouteCurSum; + } + return reverseRouteCurSum; +} + + +/* +* ȡָ±Ӧķ·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetReverseRouteRouteId(const UINT16 bufIndex) +{ + UINT16 reverseRouteId = 0u; + if (bufIndex < GetReverseRouteCurSum()) + { + reverseRouteId = LocalCiReverseRouteIdBuf[bufIndex]; + } + else + { + reverseRouteId = CI_ERROR; + } + return reverseRouteId; +} + +/* +* ȡָID·± +* ˵ const UINT16 reverseRouteId, ·ID +* ֵ 0: ȡʧ +* >0: ָID·± +*/ +UINT16 GetReverseRouteBufIndex(const UINT16 reverseRouteId) +{ + UINT16 bufIndex = 0u; + if ((reverseRouteId >= 1u) && (reverseRouteId < ROUTE_SUM_MAX)) + {/*ROUTE_SUM_MAX:ʹ"·",ΪreverseRouteId·IDĽ·ID,ûжһ෴·ID*/ + + bufIndex = reverseRouteId; + } + else + { + bufIndex = ROUTE_SUM_MAX; + } + + return bufIndex; +} + +/* +* ȡ· +* ˵ void +* ֵ · +*/ +ReverseRouteConfigDataStruct* GetReverseRouteConfigData(void) +{ + return ReverseRouteConfigDataStru; +} + + +/* +* ȡָID··Ŀ +* ˵ const UINT16 reverseRouteId, ·ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT8 GetReverseRouteIncludeRouteSum(const UINT16 reverseRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 routeSum = 0u; + + + bufIndex = GetReverseRouteBufIndex(reverseRouteId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + {/*ROUTE_SUM_MAX:ʹ"·",ΪreverseRouteId·IDĽ·ID,ûжһ෴·ID*/ + + routeSum = ReverseRouteConfigDataStru[bufIndex].AutoSigRouteIncludeSum; + } + else + { + routeSum = CI_ERROR; + } + return routeSum; +} + +/* +* ȡָID·ID +* ˵ const UINT16 reverseRouteId, ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetReverseRouteBelongCiId(const UINT16 reverseRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ciId = 0u; + + + bufIndex = GetReverseRouteBufIndex(reverseRouteId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + {/*ROUTE_SUM_MAX:ʹ"·",ΪreverseRouteId·IDĽ·ID,ûжһ෴·ID*/ + + ciId = ReverseRouteConfigDataStru[bufIndex].BelongCiId; + } + else + { + ciId = CI_ERROR; + } + return ciId; +} + +/* +* ȡָID·ԶźŽ·ID +* ˵ const UINT8 reverseRouteId, ·ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetReverseRouteIncludeRouteBuf(const UINT16 reverseRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *routeIdBuf = NULL; + + bufIndex = GetReverseRouteBufIndex(reverseRouteId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + {/*ROUTE_SUM_MAX:ʹ"·",ΪreverseRouteId·IDĽ·ID,ûжһ෴·ID*/ + + routeIdBuf = ReverseRouteConfigDataStru[bufIndex].AutoSigRouteIdBuf; + } + else + { + routeIdBuf = NULL; + } + return routeIdBuf; +} + + +/* +* ķ· +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 ReverseRouteConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 reverseRouteConfigDataSum = 0u; /*·豸*/ + UINT8 retVal = CI_SUCCESS; + + /*淴·Id*/ + reverseRouteConfigDataSum = GetReverseRouteCurSum(); + if (reverseRouteConfigDataSum >= REVERSE_ROUTE_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + if(CI_SUCCESS == retVal) + { + for (ii = 0u; ii < ROUTE_SUM_MAX; ii++) + {/*ROUTE_SUM_MAX:ʹ"·",ΪreverseRouteId·IDĽ·ID,ûжһ෴·ID*/ + + if (jj == reverseRouteConfigDataSum) + {/*Ч*/ + + break; + } + + if(0u != ReverseRouteConfigDataStru[ii].ReverseRouteId ) + {/*òΪЧ*/ + if (ReverseRouteConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + + LocalCiReverseRouteIdBuf[jj] = ReverseRouteConfigDataStru[ii].ReverseRouteId; + jj++; + } + + } + + + } + } + return retVal; +} + + + diff --git a/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteConfigDataManage.h b/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteConfigDataManage.h new file mode 100644 index 0000000..bf0360f --- /dev/null +++ b/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteConfigDataManage.h @@ -0,0 +1,110 @@ +/******************************************************** +* +* ReverseRouteConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-10-22 +* ߣ +* ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _REVERSEROUTE_CONFIG_DATA_MANAGE_H_ +#define _REVERSEROUTE_CONFIG_DATA_MANAGE_H_ + + +#include "ReverseRouteDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../Route/RouteDefine.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*·ݽṹ*/ +typedef struct S_ReverseRouteConfigDataStruct +{ + UINT16 ReverseRouteId; /*·ID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 AutoSigRouteIncludeSum; /*·ԶźŽ·Ŀ (ֶ)*/ + UINT16 AutoSigRouteIdBuf[REVERSE_ROUTE_INCLUDE_AUTOSIGROUTE_SUM_MAX]; /*·ԶźŽ·ID (ֶ)*/ +} ReverseRouteConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern ReverseRouteConfigDataStruct ReverseRouteConfigDataStru[ROUTE_SUM_MAX]; +extern UINT16 LocalCiReverseRouteIdBuf[REVERSE_ROUTE_SUM_MAX]; +extern INT16 ReverseRouteCurSum; + +/* +* ȡ·ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ·ǰ +*/ +UINT16 GetReverseRouteCurSum(void); + +/* +* ȡָ±Ӧķ·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetReverseRouteRouteId(const UINT16 bufIndex); + +/* +* ȡָID·± +* ˵ const UINT16 reverseRouteId, ·ID +* ֵ 0: ȡʧ +* >0:ָID·± +*/ +UINT16 GetReverseRouteBufIndex(const UINT16 reverseRouteId); + +/* +* ȡ· +* ˵ void +* ֵ · +*/ +ReverseRouteConfigDataStruct* GetReverseRouteConfigData(void); + + +/* +* ȡָID··Ŀ +* ˵ const UINT16 reverseRouteId, ·ID +* ֵ 0: ȡʧ +* >0: ·Ŀ +*/ +UINT8 GetReverseRouteIncludeRouteSum(const UINT16 reverseRouteId); + +/* +* ȡָID·ID +* ˵ const UINT16 reverseRouteId, ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetReverseRouteBelongCiId(const UINT16 reverseRouteId); + +/* +* ȡָID·ԶźŽ·ID +* ˵ const UINT8 reverseRouteId, ·ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16* GetReverseRouteIncludeRouteBuf(const UINT16 reverseRouteId); + + +/* +* ķ· +* ˵ +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 ReverseRouteConfigDataManage(void); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteDefine.h b/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteDefine.h new file mode 100644 index 0000000..c09cf31 --- /dev/null +++ b/TSCP/src/APP/ciapp/ReverseRoute/ReverseRouteDefine.h @@ -0,0 +1,28 @@ +/******************************************************** +* +* ReverseRouteDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-10-22 +* ߣ +* Խ·ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _REVERSEROUTE_CONFIG_H_ +#define _REVERSEROUTE_CONFIG_H_ + + + +/*·ֵ*/ +#define REVERSE_ROUTE_SUM_MAX ((UINT16)150) /*巴·ֵ*/ + + +/*ֵ*/ +#define REVERSE_ROUTE_INCLUDE_AUTOSIGROUTE_SUM_MAX ((UINT16)10) /*巴·ԶźŽ·ֵ*/ + + +#endif + diff --git a/TSCP/src/APP/ciapp/Route/DynamicRouteDataManage.c b/TSCP/src/APP/ciapp/Route/DynamicRouteDataManage.c new file mode 100644 index 0000000..9a0c729 --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/DynamicRouteDataManage.c @@ -0,0 +1,4066 @@ +#include "DynamicRouteDataManage.h" +#include "PhysicalSectionDataManage.h" +#include "InterlockCommonManage.h" + +DynamicRouteDataStruct gDynamicRouteDataSt[ROUTE_DYNAMIC_SUM_MAX]; +UINT16 gDynamicRouteSum = 0U; +UINT16 gSzDanamicRouteIdBuff[ROUTE_DYNAMIC_SUM_MAX] = {0U}; + +/** +* @brief ö̬·״̬ +* @param const UINT16 dynamicRouteId ̬·ID +* @param const UINT8 dyRouteState ̬·״̬ +* @return CI_ERROR:ʧܣCI:SUCCESS:ɹ +* @note +*/ +static UINT8 SetDynamicRouteState(const UINT16 dynamicRouteId, const UINT8 dyRouteState); + +/** +* @brief ̬·ѡ +* @param const UINT16 wDrId +* @return +* @note +*/ +static void DrFirstXuanPaiProc(const UINT16 wDrId); + +/** +* @brief ̬·ѡŴ +* @param const UINT16 wDrId +* @return +* @note +*/ +static void DrXuanPaiProc(const UINT16 wDrId); + +/** +* @brief ̬·մ +* @param const UINT16 wDrId +* @return +* @note +*/ +static void DrLockProc(const UINT16 wDrId); + +/** +* @brief ն̬·ж +* @param const UINT16 wDrId ̬·ID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockDynamicRouteProc(const UINT16 wDrId); + +#if 1 +/** +* @brief ն̬·ӽ·ж +* @param const UINT16 routeId ·ID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockDrSubRouteProc(const UINT16 wSubRouteId); + +/** +* @brief CBTC̬·ӽ· +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockCbtcDrSubRouteCheck(UINT16 const wSubRouteId); + +/** +* @brief յʽ̬·ӽ· +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockBlocDrSubRouteCheck(UINT16 const wSubRouteId); + +/** +* @brief VBTC̬·ӽ·۷ +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockCbtcDrSubReturnRouteCheck(UINT16 const wSubRouteId); + +/** +* @brief պ󱸶̬·ӽ·۷ +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockBlocDrSubReturnRouteCkeck(UINT16 const wSubRouteId); + +/** +* @brief ն̬·ӽ·״̬ж +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockDrSubRouteSwitchCheck(UINT16 wSubRouteId, UINT8 functionId, UINT8 sendLevel); + +/** +* @brief ն̬·ӽ·λüɶԼ +* @param UINT16 const routeId +* @param UINT16 *pDevId +* @param UINT8 *pDevState +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 DrSubRouteSwiPosAndMoveValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel); + +/** +* @brief ն̬·ӽ·λüɶԼ +* @param UINT16 const routeId +* @param UINT16 *pDevId +* @param UINT8 *pDevState +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 DrSubRouteProtSwiPosMovValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel); +#endif + +/** +* @brief ̬·ӽ· +* @param const UINT16 wDrId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetDynamicRouteProc(const UINT16 wDrId); + +/** +* @brief ̬·ӽ· +* @param const UINT16 wDrId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetDrSubRouteProc(const UINT16 routeId); + +/** +* @brief ̬·ӽ·(г·) +* @param const UINT16 routeId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetDrSubRlTrainRouteCheck(UINT16 const routeId); + +/** +* @brief ̬·CBTCӽ·(CBTCг·) +* @param const UINT16 routeId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetCbtcDrSubRouteCheck(UINT16 const routeId); + +/** +* @brief ̬·ӽ·(г·) +* @param const UINT16 routeId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetBlocDrSubRouteCheck(UINT16 const routeId); + +/** +* @brief ̬·ӽ·(۷·) +* @param const UINT16 routeId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetDrSubRrRouteCheck(UINT16 const routeId); + +/** +* @brief ̬·CBTC۷ӽ·(CBTC۷·) +* @param const UINT16 routeId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetCbtcDrSubReturnRouteCheck(UINT16 const routeId); + +/** +* @brief ̬·۷ӽ·(۷·) +* @param const UINT16 routeId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetBlocDrSubReturnRouteCheck(UINT16 const routeId); + +/** +* @brief ̬·ӽ· +* @param const UINT16 routeId +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 SetDrSubRouteSwitchCheck(UINT16 routeId, UINT8 functionId, UINT8 sendLevel); + +/** +* @brief ȡ̬· +* @param +* @return ̬· +* @note +*/ +UINT16 GetDynamicRouteSum(void) +{ + UINT16 wRetVal = 0u; + if (ROUTE_DYNAMIC_SUM_MAX <= gDynamicRouteSum) + { + wRetVal = ROUTE_DYNAMIC_SUM_MAX; + } + else + { + wRetVal = gDynamicRouteSum; + } + return wRetVal; +} + +/** +* @brief ȡ̬·ID +* @param +* @return ̬·ID +* @note +*/ +UINT16 GetDynamicRouteId(const UINT16 wIndex) +{ + UINT16 wRetVal = 0u; + UINT16 wDynamicRouteSum = GetDynamicRouteSum(); + + if (wIndex < wDynamicRouteSum) + { + wRetVal = gSzDanamicRouteIdBuff[wIndex]; + } + else + { + /* */ + } + return wRetVal; +} + +/** +* @brief ȡ̬· +* @param +* @return ̬· +* @note +*/ +UINT16 GetDrBufIndex(const UINT16 wDrId) +{ + UINT16 wRetVal = ROUTE_DYNAMIC_SUM_MAX; + if (ROUTE_DYNAMIC_SUM_MAX > wDrId) + { + wRetVal = wDrId; + } + else + { + /* */ + } + return wRetVal; +} + +/** +* @brief ȡСö̬·IDС״̬У +* @param +* @return ̬·ID +* @note +*/ +UINT16 GetUsableDrId(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 wDrId = 0u; + + for (ii = 1u; ii < ROUTE_DYNAMIC_SUM_MAX; ii++) + { + if (ROUTE_DYNAMIC_STATE_IDLE == gDynamicRouteDataSt[ii].dynamicRouteState) + { + wDrId = gDynamicRouteDataSt[ii].dynamicRouteId; + break; + } + } + return wDrId; +} + +/** +* @brief ȡ̬·״̬ +* @param +* @return ̬·״̬ +* @note +*/ +UINT8 GetDynamicRouteState(const UINT16 wDrId) +{ + UINT8 chRetVal = ROUTE_DYNAMIC_STATE_IDLE; + UINT16 wBufIndex = 0u; + wBufIndex = GetDrBufIndex(wDrId); + if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex) + { + chRetVal = gDynamicRouteDataSt[wBufIndex].dynamicRouteState; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ̬·ӽ·Ŀ +* @param +* @return ̬·ӽ·Ŀ +* @note +*/ +UINT8 GetDrSubRouteSum(const UINT16 wDrId) +{ + UINT8 chRetVal = 0u; + UINT16 wBufIndex = 0u; + wBufIndex = GetDrBufIndex(wDrId); + if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex) + { + chRetVal = gDynamicRouteDataSt[wBufIndex].subRouteSum; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ö̬·ӽ· +* @param +* @return +* @note +*/ +void SetDrSubRoute(const UINT16 wDrId, const UINT8 chSubSum, UINT16 szSubId[ROUTE_SUBROUTE_SUM_MAX]) +{ + UINT16 wBufIndex = 0u; + UINT8 ii = 0u; + wBufIndex = GetDrBufIndex(wDrId); + if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex) + { + gDynamicRouteDataSt[wBufIndex].subRouteSum = chSubSum; + for (ii = 0u; ii < chSubSum; ii++) + { + gDynamicRouteDataSt[wBufIndex].subRouteIdBuf[ii] = szSubId[ii]; + } + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_FIRST_XUANPAI, 0u); + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ̬·ӽ·ID +* @param +* @return ̬·ӽ·ID +* @note +*/ +UINT16 * GetDrSubRouteIdBuf(const UINT16 wDrId) +{ + UINT16 * pRetVal = NULL; + UINT16 wBufIndex = 0u; + wBufIndex = GetDrBufIndex(wDrId); + if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex) + { + pRetVal = gDynamicRouteDataSt[wBufIndex].subRouteIdBuf; + } + else + { + ; /* */ + } + return pRetVal; +} + +/** +* @brief ȡ̬·ѡʼں +* @param +* @return ̬·ӽ·ѡʼں +* @note +*/ +UINT32 GetDrXuanPaiStartCyc(const UINT16 wDrId) +{ + UINT32 dwRetVal = 0u; + UINT16 wBufIndex = 0u; + wBufIndex = GetDrBufIndex(wDrId); + if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex) + { + dwRetVal = gDynamicRouteDataSt[wBufIndex].xuanpaiStartCycleNum; + } + else + { + ; /* */ + } + return dwRetVal; +} + +/** +* @brief ȡ̬·ʼں +* @param +* @return ̬·ӽ·ʼں +* @note +*/ +UINT32 GetDrLockStartCyc(const UINT16 wDrId) +{ + UINT32 dwRetVal = 0u; + UINT16 wBufIndex = 0u; + wBufIndex = GetDrBufIndex(wDrId); + if (ROUTE_DYNAMIC_SUM_MAX > wBufIndex) + { + dwRetVal = gDynamicRouteDataSt[wBufIndex].lockStartCycleNum; + } + else + { + ; /* */ + } + return dwRetVal; +} + +/** +* @brief ö̬·״̬ +* @param const UINT16 dynamicRouteId ̬·ID +* @param const UINT8 dyRouteState ̬·״̬ +* @return CI_ERROR:ʧܣCI:SUCCESS:ɹ +* @note +*/ +static UINT8 SetDynamicRouteState(const UINT16 dynamicRouteId, const UINT8 dyRouteState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetDrBufIndex(dynamicRouteId); /*ȡ±*/ + + if (ROUTE_DYNAMIC_SUM_MAX > bufIndex) + { + retVal = CI_SUCCESS; + } + else + { + ; /* */ + } + + if (CI_SUCCESS == retVal) + { + if (ROUTE_DYNAMIC_STATE_IDLE == dyRouteState) + {/* ̬· */ + + gDynamicRouteDataSt[bufIndex].xuanpaiStartCycleNum = 0u; /*·ѡʼ*/ + gDynamicRouteDataSt[bufIndex].lockStartCycleNum = 0u; + } + else if(ROUTE_DYNAMIC_STATE_FIRST_XUANPAI == dyRouteState) + {/* ̬·ѡ */ + gDynamicRouteDataSt[bufIndex].xuanpaiStartCycleNum = Get2oo2CurCycleNum(); /*ý·ѡʼ*/ + gDynamicRouteDataSt[bufIndex].lockStartCycleNum = 0u; + } + else if (ROUTE_DYNAMIC_STATE_XUANPAI == dyRouteState) + {/* ̬·ѡ */ + + gDynamicRouteDataSt[bufIndex].xuanpaiStartCycleNum = 0u; /*ý·ѡʼ*/ + gDynamicRouteDataSt[bufIndex].lockStartCycleNum = Get2oo2CurCycleNum(); + } + else if (ROUTE_DYNAMIC_STATE_LOCK == dyRouteState) + {/* ̬· */ + gDynamicRouteDataSt[bufIndex].xuanpaiStartCycleNum = 0u; + gDynamicRouteDataSt[bufIndex].lockStartCycleNum = 0u; + } + else + { + retVal = CI_ERROR; + } + } + + if (CI_SUCCESS == retVal) + { + gDynamicRouteDataSt[bufIndex].dynamicRouteState = dyRouteState; /*·״̬*/ + } + + return retVal; +} + +/** +* @brief ö̬·״̬(ö̬·״̬ͨ˺ +* @param const UINT16 dynamicRouteId ̬·ID +* @param const UINT8 dyRouteState ̬·״̬ +* @return +* @note +*/ +void SetDynamicRouteStateProcess(const UINT16 dynamicRouteId, const UINT8 dyRouteState, const UINT8 chFlag) +{ + UINT8 subRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + UINT8 halfRouteLgcNum = 0u; + + subRouteSum = GetDrSubRouteSum(dynamicRouteId); /*ӽ·*/ + pSubRouteIdBuf = GetDrSubRouteIdBuf(dynamicRouteId); /*ӽ·*/ + + debug_infor_printf((const)"Dynamic route:%d set state:%d cause:%x\n", dynamicRouteId, dyRouteState, chFlag); + + if (subRouteSum == 0u) + {/* ϶̬·ӽ·ĿΪ0 */ + if ((ROUTE_DYNAMIC_STATE_IDLE == dyRouteState) + || (ROUTE_DYNAMIC_STATE_XUANPAI == dyRouteState) + || (ROUTE_DYNAMIC_STATE_LOCK == dyRouteState)) + {/* ϶̬·/ѡ/ʱ϶̬·ӽ·Ϊ0˵϶̬·ڴ汻д + ղ */ + SetPlatOverFlag(); + } + else + { + ; /* */ + } + } + else + { + if (ROUTE_DYNAMIC_STATE_IDLE == dyRouteState) + { /*ö̬·*/ + for (ii = 0u; ii < subRouteSum; ii++) + { + halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]); + if (0u != halfRouteLgcNum) + {/* ˽·Ϊֽ·ֽ·߼Dzֽ·ʱŲΪ */ + SetRouteHalfPhySecUsingState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); + if (SET_DR_IDLE_CAUSE_FINISHED == chFlag) + { + ; /* */ + } + else + { + /*ý·0*/ + SetHalfRouteLockLgcSec(pSubRouteIdBuf[ii], 0U, NULL); + /*гԴ0*/ + SetHalfRouteTrainLocLgcSec(pSubRouteIdBuf[ii], 0U, NULL); + /*õɶ־*/ + SetHalfRouteSwitchMoveValid(pSubRouteIdBuf[ii], ROUTE_HALF_SWITCH_MOVE_INVALID); + /*ԴгIDΪ0*/ + SetHalfRouteResReqTrainId(pSubRouteIdBuf[ii], 0U); + } + } + else + { + SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); /*ӽ·*/ + } + } + } + else if (ROUTE_DYNAMIC_STATE_FIRST_XUANPAI == dyRouteState) + {/*ö̬·ѡ*/ + + for (ii = 0u; ii < subRouteSum; ii++) + { + halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]); + if (0u != halfRouteLgcNum) + {/* ˽·Ϊֽ·ֽ·߼Dzֽ·ʱŲΪ */ + SetRouteHalfPhySecUsingState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_YES); + } + else + { + SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_YES); /*ӽ·*/ + } + } + } + else if (ROUTE_DYNAMIC_STATE_XUANPAI == dyRouteState) + { /*ö̬·ѡ*/ + ; /* */ + } + else if (ROUTE_DYNAMIC_STATE_LOCK == dyRouteState) + { /*ö̬·*/ + + for (ii = 0u; ii < subRouteSum; ii++) + { + halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]); + if (0u != halfRouteLgcNum) + {/* ˽·Ϊֽ·ֽ·߼Dzֽ·ʱŲΪ */ + SetRouteHalfPhySecUsingState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); + } + else + { + SetRoutePhySectionOccupyState(pSubRouteIdBuf[ii], PHYSICAL_SECTION_USING_NO); /*ӽ·*/ + } + } + } + else + { + /* ״̬󲻿 */ + return; + } + + /*ö̬·״̬*/ + (void)SetDynamicRouteState(dynamicRouteId, dyRouteState); + } +} + +/* +* ʼ̬· +* ˵ void +* ֵ +* +*/ +void InitialDynamicRouteData(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 dynamicRouteId = 0u; + + for (ii = 1u; ii < ROUTE_DYNAMIC_SUM_MAX; ii++) + { + gDynamicRouteDataSt[ii].dynamicRouteId = ii; + gDynamicRouteDataSt[ii].dynamicRouteState =ROUTE_DYNAMIC_STATE_IDLE; + gSzDanamicRouteIdBuff[gDynamicRouteSum++] = gDynamicRouteDataSt[ii].dynamicRouteId; + } + +} + +/** +* @brief ̬·״̬ +* @param +* @return +* @note +*/ +void DynamicRouteLogicProcess(void) +{ + UINT8 chDrState = 0u; /*̬·״̬*/ + UINT16 wDrId = 0u; /*̬·ID*/ + UINT16 ii = 0u; /*ѭ*/ + UINT16 dynamicRouteSum = 0U; + UINT8 chStartLockFlag = CI_START_LOCK_YES; + + chStartLockFlag = GetStartLockFlag(); + if (CI_START_LOCK_NO != chStartLockFlag) + { /*δϵ*/ + ; /* */ + } + else + { + dynamicRouteSum = GetDynamicRouteSum(); + /*̬·*/ + for (ii = 0u; ii < dynamicRouteSum; ii++) + { + wDrId = GetDynamicRouteId(ii); + chDrState = GetDynamicRouteState(wDrId); + + if (ROUTE_DYNAMIC_STATE_IDLE == chDrState) + {/* · */ + ; /* */ + } + else if (ROUTE_DYNAMIC_STATE_FIRST_XUANPAI == chDrState) + {/* ̬·ѡ */ + DrFirstXuanPaiProc(wDrId); + } + else if (ROUTE_DYNAMIC_STATE_XUANPAI == chDrState) + {/* ̬·ѡ */ + DrXuanPaiProc(wDrId); + } + else if (ROUTE_DYNAMIC_STATE_LOCK == chDrState) + {/* ̬· */ + DrLockProc(wDrId); + } + else + { + /* ״̬쳣 */ + SetPlatOverFlag(); + } + } + } +} + +/** +* @brief ̬·ѡ +* @param const UINT16 wDrId ̬·ID +* @return +* @note +*/ +static void DrFirstXuanPaiProc(const UINT16 wDrId) +{ + UINT8 chDrSubRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pDrSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT8 chCount = 0u; + UINT8 halfRouteLgcNum = 0u; + + chDrSubRouteSum = GetDrSubRouteSum(wDrId); /*ӽ·*/ + pDrSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*ӽ·*/ + + chFunRtn = SetDynamicRouteProc(wDrId); + if (CI_SUCCESS == chFunRtn) + { + for (ii = 0u; ii < chDrSubRouteSum; ii++) + { + halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pDrSubRouteIdBuf[ii]); + if (0u != halfRouteLgcNum) + {/* ȡ״̬ *//* ˽·Ϊֽ·ֽ·߼Dzֽ·ʱŲΪ */ + chFunRtn = RouteHalfFirstXuanProc(pDrSubRouteIdBuf[ii]); + } + else + {/* ȡ·״̬ */ + chFunRtn = RouteFirstXuanProc(pDrSubRouteIdBuf[ii]); + } + if (CI_SUCCESS == chFunRtn) + {/* óɹ */ + chCount++; + } + else if (RETURN_FIRSTXUANPAI_ERR_WAIT == chFunRtn) + {/* õȴ */ + ; + } + else + {/* ʧ */ + break; + } + } + + if (chCount == chDrSubRouteSum) + { + /* н·óɹö̬·ѡ */ + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_XUANPAI, 0u); + DrXuanPaiProc(wDrId); + } + else if (ii == chDrSubRouteSum) + { + ; /* õȴ */ + } + else + { + /* ʧܣö̬· */ + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT); + } + } + else + { + /* ʧܣö̬· */ + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT); + } +} + +/** +* @brief ̬·ѡŴ +* @param const UINT16 wDrId ̬·ID +* @return +* @note +*/ +static void DrXuanPaiProc(const UINT16 wDrId) +{ + UINT8 chDrSubRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pDrSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT8 halfRouteLgcNum = 0u; + UINT8 chkSwitchPos = CI_ERROR; + UINT8 RtnTemp = CI_ERROR; + + chDrSubRouteSum = GetDrSubRouteSum(wDrId); /*ӽ·*/ + pDrSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*ӽ·*/ + + if (NULL != pDrSubRouteIdBuf) + { + chFunRtn = LockDynamicRouteProc(wDrId); + if (RETURN_LOCK_ERR_SWITPOS == chFunRtn) + { + /*ʧܣλô*/ + + for (ii = 0u; ii < chDrSubRouteSum; ii++) + { + halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pDrSubRouteIdBuf[ii]); + if (0u != halfRouteLgcNum) + {/* ˽·Ϊֽ·ֽ·߼Dzֽ·ʱŲΪ */ + chkSwitchPos = ChekRouteHalfSwPosRight(pDrSubRouteIdBuf[ii]);/*λǷȷ*/ + if (CI_SUCCESS == chkSwitchPos) + { + ; /* ·λȷ */ + } + else + { + RtnTemp = RouteLockHalfDriveSwitch(pDrSubRouteIdBuf[ii]); + if (CI_ERROR == RtnTemp) + { + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT); /*-->ö̬·*/ + } + else + { + ; /* */ + } + } + } + else + { + chkSwitchPos = CheckRouteSwitchPosRight(pDrSubRouteIdBuf[ii]); + + if (CI_SUCCESS == chkSwitchPos) + { /*·λȷ*/ + } + else + { /*δλ*/ + RtnTemp = RouteLockDriveSwitch(pDrSubRouteIdBuf[ii], SWITCH_NEED_DRIV_FALSE); + if (CI_ERROR == RtnTemp) + { + /*ʧ*/ + SetRoutAssoSwitSingOperStat(pDrSubRouteIdBuf[ii], SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT); /*-->ö̬·*/ + } + else + { + ; /* */ + } + } + } + + if (CI_SUCCESS != chkSwitchPos) + {/* ʧ */ + break; + } + else + { + ; /* */ + } + } + + } + else if (CI_SUCCESS == chFunRtn) + { + for (ii = 0u; ii < chDrSubRouteSum; ii++) + { + SetRoutAssoSwitSingOperStat(pDrSubRouteIdBuf[ii], SWITCH_SINGLE_OPERATED_FALSE);/*·鱻ٹʷ*/ + + SetRouteBelongDrId(pDrSubRouteIdBuf[ii], wDrId); /*-->ý·̬·*/ + + halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pDrSubRouteIdBuf[ii]); + if (0u != halfRouteLgcNum) + {/* ˽·Ϊֽ·ֽ·߼Dzֽ·ʱŲΪ */ + SetRouteStateManage(pDrSubRouteIdBuf[ii], ROUTE_STATE_HALF_LOCK); /* ý· */ + RouteHalfLockManage(pDrSubRouteIdBuf[ii]); + } + else + { + /* ·óȻó쳣״̬Դ״̬״̬Ƚý· */ + SetRouteStateManage(pDrSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCK); /*-->ý·*/ + + /* ·쳣̬·ԶóﵽԶŵЧ */ + SetRouteStateManage(pDrSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCKERR); /*-->ý·쳣*/ + + SetRouteGroupRouteCmdFlag(pDrSubRouteIdBuf[ii], ROUTE_GROUPROUTE_CMD_YES);/*ý·Ͻ·־*/ + } + } + + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_LOCK, 0u); /*-->ö̬·*/ + } + else + { /*·ʧ*/ + + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT); /*-->ö̬·*/ + } + } +} + +/** +* @brief ̬·մ +* @param const UINT16 wDrId ̬·ID +* @return +* @noteִԶ߼϶̬·ӽ·ɽԶ洢 +* ֱֽ·ʾѾȫɿţ϶̬·ڽ +*/ +static void DrLockProc(const UINT16 wDrId) +{ + UINT8 chSubRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + UINT16 wBelongDrId = 0u; + UINT8 chRouteState = 0u; + UINT8 chFlag = FLAG_UNSET; + UINT8 halfRouteLgcNum = 0u; + + chSubRouteSum = GetDrSubRouteSum(wDrId); /*ӽ·*/ + pSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*ӽ·*/ + + for (ii = 0u; ii < chSubRouteSum; ii++) + { + chRouteState = GetRouteState(pSubRouteIdBuf[ii]); + wBelongDrId = GetRouteBelongDrId(pSubRouteIdBuf[ii]); + halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]); + if (0u != halfRouteLgcNum) + {/* ˽·Ϊֽ·ֽ·߼Dzֽ·ʱŲΪ */ + if (((ROUTE_STATE_HALF_LOCK == chRouteState) || (ROUTE_STATE_HALF_UNLOCKDELAY == chRouteState) || (ROUTE_STATE_HALF_UNLOCK == chRouteState)) + && (wBelongDrId == wDrId)) + { + ; /* ״̬㣬 */ + } + else + { + chFlag = FLAG_SET; + } + } + else + { + if ((ROUTE_STATE_FIRST_LOCKERR == chRouteState) + && (wBelongDrId != wDrId)) + { /*ӽ·״̬Ϊ쳣*/ + chFlag = FLAG_SET; + } + else + { + ; /* */ + } + } + if (FLAG_SET == chFlag) + { + break; + } + else + { + ; /* */ + } + } + + chFlag = FLAG_UNSET; + if ((0u != ii) && (ii == chSubRouteSum)) + { + for (ii = chSubRouteSum - 1u; 0u <= ii; ii--)/*˳жмbreak*/ + { + chRouteState = GetRouteState(pSubRouteIdBuf[ii]); + wBelongDrId = GetRouteBelongDrId(pSubRouteIdBuf[ii]); + if ((ROUTE_STATE_YUXIAN_OPEN == chRouteState) || + (ROUTE_STATE_NEAR_OPEN == chRouteState)) + { /*ӽ·״̬ΪԤȿ||ӽ*/ + + ; /* ѿŽ·, */ + } + else if (ROUTE_STATE_FIRST_LOCK == chRouteState) + { /*·*/ + chFlag = FLAG_SET; + } + else if ((ROUTE_STATE_HALF_LOCK == chRouteState) || (ROUTE_STATE_HALF_UNLOCKDELAY == chRouteState) || (ROUTE_STATE_HALF_UNLOCK == chRouteState)) + {/*գн·*/ + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FINISHED); /*ö̬·*/ + chFlag = FLAG_SET; + } + else + { + if ((ROUTE_STATE_FIRST_LOCKERR != chRouteState) || + (wBelongDrId != wDrId)) + { /*ӽ·״̬Ϊ쳣||̬·Ϊ·*/ + + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT); /*ö̬·*/ + } + else + { + SetRouteStateManage(pSubRouteIdBuf[ii], ROUTE_STATE_FIRST_LOCK); /*ý·*/ + } + + chFlag = FLAG_SET; + } + if ((0u == ii) || (FLAG_SET == chFlag)) + { + break; + } + else + { + ; /* */ + } + } + } + else + { + SetDynamicRouteStateProcess(wDrId, ROUTE_DYNAMIC_STATE_IDLE, SET_DR_IDLE_CAUSE_FAULT); /*ö̬·*/ + } +} + +/** +* @brief ն̬·ж +* @param const UINT16 wDrId ̬·ID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockDynamicRouteProc(const UINT16 wDrId) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_DYNAMIC_ROUTE_LOGIC; + + /*Ϸͼ*/ + UINT8 const sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + UINT8 halfRouteLgcNum = 0u; + + + /* ֲʼ */ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + UINT8 chSubRouteSum = 0u; /*ӽ·Ŀ*/ + UINT16* pSubRouteIdBuf = NULL; /*ӽ·ID*/ + UINT8 ii = 0u; + UINT8 reResult = CI_ERROR; + UINT8 chFlag = FLAG_UNSET; + + chSubRouteSum = GetDrSubRouteSum(wDrId); /*ӽ·*/ + pSubRouteIdBuf = GetDrSubRouteIdBuf(wDrId); /*ӽ·*/ + + devId = wDrId; + devState = GetDynamicRouteState(wDrId); + if (devState != ROUTE_DYNAMIC_STATE_XUANPAI) + { /*̬·Ϊѡ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_STATE, devState, sendLevel); + reResult = CI_ERROR; + } + else + { + reResult = CI_SUCCESS; + } + + if (CI_SUCCESS == reResult) + { + devState = SystemOverTimeCheck(GetDrLockStartCyc(wDrId), GetSystemParaZuheRXuanPaiCnt()); + if (CI_TIME_OUT == devState) + { /*ѡųʱ*/ + + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, devId, ETYPE_ROUTE_XUANPAI_OVERTIME, devState, sendLevel); + + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + + for (ii = 0u; ii < chSubRouteSum; ii++) + { + + halfRouteLgcNum = GetHalfRouteLockLgcSecSum(pSubRouteIdBuf[ii]); + if (0u != halfRouteLgcNum) + {/* ˽·Ϊֽ·ֽ·߼Dzֽ·ʱŲΪ */ + /* Ϊ· */ + reResult = LockRouteHalfProc(pSubRouteIdBuf[ii]); + } + else + { + reResult = LockDrSubRouteProc(pSubRouteIdBuf[ii]); + } + + if (RETURN_LOCK_ERR_SWITPOS == reResult) + { + chFlag = FLAG_SET; + } + else + { + ; /* */ + } + + if (CI_ERROR == reResult) + { + break; + } + else + { + ; /* */ + } + } + } + + if ((FLAG_SET == chFlag) && (CI_SUCCESS == reResult)) + { + /* ɹҪ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + } + else + { + ; /* */ + } + + return reResult; +} + +#if 1 +/** +* @brief ն̬·ӽ·ж +* @param const UINT16 routeId ·ID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockDrSubRouteProc(const UINT16 wSubRouteId) +{ + UINT8 chRouteType = 0u; /*·*/ + UINT8 chRouteLevel = 0u; /*·ල*/ + UINT8 chRtn = CI_ERROR; /*ֵ*/ + UINT8 retval = 0u; + + chRouteType = GetRouteType(wSubRouteId); /*ȡ·*/ + chRouteLevel = GetRouteLevel(wSubRouteId); /*ȡ·ල*/ + + if (ROUTE_TYPE_LIECHE == chRouteType) + { /*г·*/ + if (ROUTE_LEVEL_CBTC == chRouteLevel) + { /*VBTC*/ + /*VBTCг·߼*/ + chRtn = LockCbtcDrSubRouteCheck(wSubRouteId); + } + else + { + /*յʽг·߼*/ + chRtn = LockBlocDrSubRouteCheck(wSubRouteId); + } + } + else if(ROUTE_TYPE_RETURN == chRouteType) + { + /*۷·*/ + if (ROUTE_LEVEL_CBTC == chRouteLevel) + { /*CBTC*/ + + /*CBTC۷·߼*/ + chRtn = LockCbtcDrSubReturnRouteCheck(wSubRouteId); + } + else + { + /*յʽ۷·߼*/ + chRtn = LockBlocDrSubReturnRouteCkeck(wSubRouteId); + } + } + else + { + /*Ƿ·*/ + } + + /*շֵ*/ + if (CI_SUCCESS == chRtn) + { + /*ճɹ*/ + + retval= CI_SUCCESS; + } + else if (RETURN_LOCK_ERR_SWITPOS == chRtn) + { /*λòȷ*/ + + retval= RETURN_LOCK_ERR_SWITPOS; + } + else + { /*ʧ*/ + + retval= CI_ERROR; + } + return retval; +} + +/** +* @brief CBTC̬·ӽ· +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockCbtcDrSubRouteCheck(UINT16 const wSubRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_CBTC_T_ROUTE; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ /*Ϸͼ*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*ATS*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 routeStateFlag = ROUTE_STATE_FLAG_NO; /*·״̬תƱ־*/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(wSubRouteId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + routeStateFlag = GetRouteStateFlag(wSubRouteId); /* ȡ·״̬תƱ־*/ + + /* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(wSubRouteId); + if (ROUTE_LEVEL_CBTC == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡг·*/ + devState = GetRouteType(wSubRouteId); + if (ROUTE_TYPE_LIECHE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_TYPE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬ΪС/ս */ + devState = GetRouteState(wSubRouteId); + if ((ROUTE_STATE_IDLE == devState) || (ROUTE_STATE_HALF_UNLOCK == devState)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetCbtcRouteSectionCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = RouteIntruSecVainCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټޣʧֱܺӷ͸ATS*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + if ((ROUTE_REVERSE_PROPERTY_YES == GetRouteReverseProperty(wSubRouteId)) || (ROUTE_TYPE_AIRSHAFT == GetAirShaftRouteType(wSubRouteId))) + { /*·εռ״̬֮ǰڲռ״̬źų·ڷһ߼ΣźŻؿ*/ + /*羮·׷ٰ·*/ + devId = 0u; + devState = 0u; + checkResult = RouteAllSecOccuClearCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_MERGY_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼ЧԼ*/ + checkResult = LockCBTCRouteSectionCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*ֶν·*/ + checkResult = RouteFenDuanConditionCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + /* سɹ */ + return reResult; +} + +/** +* @brief յʽ̬·ӽ· +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockBlocDrSubRouteCheck(UINT16 const wSubRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_BLOC_T_ROUTE; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*Ϸͼ*/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(wSubRouteId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(wSubRouteId); + if ((devState == ROUTE_LEVEL_BLOC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + if (CI_SUCCESS == reResult) + { + /* ·ǡг·*/ + devState = GetRouteType(wSubRouteId); + if (devState == ROUTE_TYPE_LIECHE) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_TYPE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬ΪС*/ + devState = GetRouteState(wSubRouteId); + if (ROUTE_STATE_IDLE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + if (CI_SUCCESS == reResult) + { + /**/ + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټޣʧֱܺӷ͸ATS*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼μ*/ + checkResult = LockBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + +/** +* @brief VBTC̬·ӽ·۷ +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockCbtcDrSubReturnRouteCheck(UINT16 const wSubRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_CBTC_R_ROUTE; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*Ϸͼ*/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(wSubRouteId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + /* ߼ */ + + /* ·ලģʽΪCBTC*/ + devState = GetRouteLevel(wSubRouteId); + if ((devState == ROUTE_LEVEL_CBTC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡ۷·*/ + devState = GetRouteType(wSubRouteId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_TYPE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬ΪС*/ + devState = GetRouteState(wSubRouteId); + if (ROUTE_STATE_IDLE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټޣʧֱܺӷ͸ATS*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = CBTCRouteFloodGateCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼μ*/ + checkResult = LockBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*ֶν·*/ + checkResult = RouteFenDuanConditionCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + +/** +* @brief պ󱸶̬·ӽ·۷ +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockBlocDrSubReturnRouteCkeck(UINT16 const wSubRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_LOCK_BLOC_R_ROUTE; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT8 devState = 0u; /*豸״̬*/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 sendLevel = ESEND_LEVEL_ZERO; /*Ϸͼ*/ + UINT8 cAutoStateFlag = CI_ERROR; + + cAutoStateFlag = AutoSignalOrRouteValid(wSubRouteId); /*ȡԶ*/ + if (cAutoStateFlag == CI_SUCCESS) + { + /*Զ·ԶźŲATS*/ + sendLevel = ESEND_LEVEL_ZERO; + } + else + { + sendLevel = ESEND_LEVEL_ATS; + } + + /* ߼ */ + + /* ·ලģʽΪʽ*/ + devState = GetRouteLevel(wSubRouteId); + if ((devState == ROUTE_LEVEL_BLOC)) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_LEVEL, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /* ·ǡ۷·*/ + devState = GetRouteType(wSubRouteId); + if (devState == ROUTE_TYPE_RETURN) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_TYPE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* ·״̬ΪС*/ + devState = GetRouteState(wSubRouteId); + if (ROUTE_STATE_IDLE == devState) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_ROUTE, wSubRouteId, ETYPE_ROUTE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* źŻ */ + checkResult = SetBlocRouteSignalCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*ղȷ*/ + + checkResult = RouteRelayZhaoChaCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = SetBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /* */ + checkResult = LockBlocRouteSwitchCheck(wSubRouteId, functionId, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = checkResult; + + } + } + + /**/ + if (CI_SUCCESS == reResult) + { + devId = 0u; + devState = 0u; + checkResult = RouteIntruSecVainCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ѡ֮ǰټޣʧֱܺӷ͸ATS*/ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_INTRU_OCU_STATE, devState, ESEND_LEVEL_ATS); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /**/ + checkResult = BlocRouteFloodGateCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + if (CI_SUCCESS == reResult) + { + /*·εķǽ·ҷǵ߼μ*/ + checkResult = LockBlocRouteSectionCheck(wSubRouteId, functionId, sendLevel); + if (CI_SUCCESS == checkResult) + { + reResult = CI_SUCCESS; + } + else + { + reResult = CI_ERROR; + } + } + + /* سɹ */ + return reResult; +} + +/** +* @brief ն̬·ӽ·״̬ж +* @param UINT16 wSubRouteId ӽ·ID +* @param UINT8 functionId +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹRETURN_LOCK_ERR_SWITPOS:λòȷ +* @note +*/ +static UINT8 LockDrSubRouteSwitchCheck(UINT16 wSubRouteId, UINT8 functionId, UINT8 sendLevel) +{ + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + + UINT8 reResultP = CI_ERROR; /*ξֲ鷵ֵ*/ + + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + UINT8 lineIdentity = CI_TRADITION_RAILWAY; + + lineIdentity = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·ʶ*/ + + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchYLockCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + if (CI_SUCCESS == reResult) + { + /*·еδ*/ + devId = 0u; + devState = 0u; + checkResult = RouteSwitchFLockCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + /*·δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteReltProtSwitchFLockCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_FLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + } + + if (CI_SUCCESS == reResult) + { + if (CI_TRADITION_RAILWAY == lineIdentity) + { + /*·еλȷλòȷɶ*/ + devId = 0u; + devState = 0u; + + checkResult = DrSubRouteSwiPosAndMoveValCheck(wSubRouteId, &devId, &devState, sendLevel); + + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + /*·*/ + if (CI_SUCCESS == reResult) + { + checkResult = RouteAllLtrlDfncSwitchCheck(wSubRouteId, &devId, &devState); + if (CI_SUCCESS == checkResult) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_NO_UT_CT_OCU_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + if (CI_SUCCESS == reResult) + { + if (CI_TRADITION_RAILWAY == lineIdentity) + { + /* + ·еλȷ + ȷRETURN_LOCK_ERR_SWITPOS + ȷCI_SUCCESS + */ + devId = 0u; + devState = 0u; + checkResult = RouteAllSwitchPosCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResult = RETURN_LOCK_ERR_SWITPOS; + + } + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + } + + if ((CI_SUCCESS == reResult) || (RETURN_LOCK_ERR_SWITPOS == reResult)) + {/*·շ*/ + /*·δ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchYLockCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResultP = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_SWITCH, devId, ETYPE_SWT_YLOCK_STATE, devState, sendLevel); + /* ʧܷ */ + reResultP = CI_ERROR; + } + + if (CI_SUCCESS == reResultP) + { + /*·λȷλòȷɶ*/ + devId = 0u; + devState = 0u; + checkResult = DrSubRouteProtSwiPosMovValCheck(wSubRouteId, &devId, &devState, sendLevel); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResultP = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResultP = CI_ERROR; + } + } + else + { + reResultP = CI_ERROR; + } + + if (CI_SUCCESS == reResultP) + { + /*·λȷ*/ + devId = 0u; + devState = 0u; + checkResult = RouteRelatedProSwitchPosCheck(wSubRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResultP = CI_SUCCESS; + } + else + { + /* ʧܷ */ + reResultP = RETURN_LOCK_ERR_SWITPOS; + } + } + else + { + reResultP = CI_ERROR; + } + + if (CI_ERROR == reResultP) + {/*ļΪܵļΪ*/ + reResult = CI_ERROR; + } + else if (CI_SUCCESS == reResultP) + { + /*ļΪɹܵļֲ*/ + } + else if (RETURN_LOCK_ERR_SWITPOS == reResultP) + {/*ļΪλôܵļΪλô*/ + reResult = RETURN_LOCK_ERR_SWITPOS; + } + else + {/*ڵܵĽΪ*/ + reResult = CI_ERROR; + } + + } + else + { + /* ʧܷ */ + reResult = CI_ERROR; + } + + + + /* ؽ */ + return reResult; +} + +/** +* @brief ն̬·ӽ·λüɶԼ +* @param UINT16 const routeId +* @param UINT16 *pDevId +* @param UINT8 *pDevState +* @param UINT8 sendLevel +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 DrSubRouteSwiPosAndMoveValCheck(UINT16 const routeId, UINT16 *pDevId, UINT8 *pDevState, UINT8 sendLevel) +{ + /* · */ + UINT8 const checkSum = GetRouteSwitchSum(routeId); + RouteSwitchStruct* const dataIdBuf = GetRouteSwitchData(routeId); + + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + UINT8 switchPos = 0u; + + UINT8 switchMoveState = 0u; + UINT8 reVal = CI_ERROR; + UINT8 checkResult = 0u; + UINT8 routeType = 0u; + UINT8 funcSwitch = 0u; /*ܿ*/ + UINT8 cLocalCiId = 0u; + UINT8 chDrMoveValid = 0u; + + funcSwitch = GetCiFunctionSwitchConfig(FUNC_ROUTE_DRV_SWITCH_EARLY); + cLocalCiId = GetSystemParaLocalCiId(); + chDrMoveValid = GetHalfRouteSwitchMoveValid(routeId); + + routeType = GetRouteType(routeId); + + /**/ + if (checkSum == 0u) + { + /*޼*/ + reVal = CI_SUCCESS; + } + else if (NULL == dataIdBuf) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + /*ʼ*/ + /* ·еλȷ ҲΪ λòȷɶ*/ + for (i = 0u; i wDrIndex) + { + (void)CommonMemCpy(&gDynamicRouteDataSt[wDrIndex], (UINT32)sizeof(DynamicRouteDataStruct), &pDataBuff[copyIndex], (UINT32)sizeof(DynamicRouteDataStruct)); + copyIndex += (UINT32)sizeof(DynamicRouteDataStruct); + } + } + ret = copyIndex; + } + return ret; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Route/DynamicRouteDataManage.h b/TSCP/src/APP/ciapp/Route/DynamicRouteDataManage.h new file mode 100644 index 0000000..79fb07e --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/DynamicRouteDataManage.h @@ -0,0 +1,172 @@ +/******************************************************** +* +* DynamicRouteDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2023-05-05 +* ߣ +* ̬·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _DYNAMIC_ROUTE_DATA_MANAGE_H_ +#define _DYNAMIC_ROUTE_DATA_MANAGE_H_ + + +#include "CommonTypes.h" +#include "RouteDefine.h" +#include "../System/CiSystemDefine.h" +#include "RouteConfigDataManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +#define SET_DR_IDLE_CAUSE_FINISHED ((UINT8)0x55u) /*̬·Ϊɣö̬·*/ +#define SET_DR_IDLE_CAUSE_FAULT ((UINT8)0xAAu) /*̬·ÿ*/ + +/*·ݽṹ*/ +typedef struct S_DynamicRouteDataStruct +{ + UINT16 dynamicRouteId; /*̬·ID */ + UINT8 dynamicRouteState; /*̬·״̬*/ + UINT8 subRouteSum; /*̬·ӽ·Ŀ */ + UINT16 subRouteIdBuf[ROUTE_SUBROUTE_SUM_MAX]; /*̬·ӽ·ID*/ + UINT32 xuanpaiStartCycleNum; /*̬·ѡʼں*/ + UINT32 lockStartCycleNum; /*̬·ʼں*/ +} DynamicRouteDataStruct; + +/*******************************ȫֱ*******************************/ +extern DynamicRouteDataStruct gDynamicRouteDataSt[ROUTE_DYNAMIC_SUM_MAX]; +extern UINT16 gDynamicRouteSum; +extern UINT16 gSzDanamicRouteIdBuff[ROUTE_DYNAMIC_SUM_MAX]; + +/** +* @brief ȡ̬· +* @param +* @return ̬· +* @note +*/ +extern UINT16 GetDynamicRouteSum(void); + +/** +* @brief ȡ̬·ID +* @param +* @return ̬·ID +* @note +*/ +extern UINT16 GetDynamicRouteId(const UINT16 wIndex); + +/** +* @brief ȡ̬· +* @param +* @return ̬· +* @note +*/ +extern UINT16 GetDrBufIndex(const UINT16 wDrId); + +/** +* @brief ȡСö̬·IDС״̬У +* @param +* @return ̬·ID +* @note +*/ +extern UINT16 GetUsableDrId(void); + +/** +* @brief ȡ̬·״̬ +* @param +* @return ̬·״̬ +* @note +*/ +extern UINT8 GetDynamicRouteState(const UINT16 wDrId); + +/** +* @brief ȡ̬·ӽ·Ŀ +* @param +* @return ̬·ӽ·Ŀ +* @note +*/ +extern UINT8 GetDrSubRouteSum(const UINT16 wDrId); + +/** +* @brief ȡ̬·ӽ·ID +* @param +* @return ̬·ӽ·ID +* @note +*/ +extern UINT16 * GetDrSubRouteIdBuf(const UINT16 wDrId); + +/** +* @brief ȡ̬·ѡʼں +* @param +* @return ̬·ӽ·ѡʼں +* @note +*/ +extern UINT32 GetDrXuanPaiStartCyc(const UINT16 wDrId); + +/** +* @brief ȡ̬·ʼں +* @param +* @return ̬·ӽ·ʼں +* @note +*/ +extern UINT32 GetDrLockStartCyc(const UINT16 wDrId); + +/** +* @brief ö̬·״̬(ö̬·״̬ͨ˺ +* @param const UINT16 dynamicRouteId ̬·ID +* @param const UINT8 dyRouteState ̬·״̬ +* @return +* @note +*/ +extern void SetDynamicRouteStateProcess(const UINT16 dynamicRouteId, const UINT8 dyRouteState, const UINT8 chFlag); + +/* +* ʼ̬· +* ˵ void +* ֵ +* +*/ +extern void InitialDynamicRouteData(void); + +/** +* @brief ̬·״̬ +* @param +* @return +* @note +*/ +extern void DynamicRouteLogicProcess(void); + +/** +* @brief ö̬·ӽ· +* @param +* @return +* @note +*/ +extern void SetDrSubRoute(const UINT16 wDrId, const UINT8 chSubSum, UINT16 szSubId[ROUTE_SUBROUTE_SUM_MAX]); + +/** +* @brief ȡ϶̬· +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +extern UINT32 GetDrTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex); + +/** +* @brief г +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +extern UINT32 SetDrTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Route/LogicalRouteDataManage.c b/TSCP/src/APP/ciapp/Route/LogicalRouteDataManage.c new file mode 100644 index 0000000..35d15f3 --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/LogicalRouteDataManage.c @@ -0,0 +1,4393 @@ +#include "LogicalRouteDataManage.h" +#include "PhysicalSectionDataManage.h" +#include "InterlockCommonManage.h" +#include "../LogicProcess/LogicalRouteLogicCheck.h" +#include "LogicSectionDataManage.h" + +LogicalRouteDataStruct LogicalRouteDataStru[ROUTE_LOGICAL_SUM_MAX]; +UINT16 LogicalRouteSum = 0U; +UINT16 LogicalRouteIdBuff[ROUTE_LOGICAL_SUM_MAX] = { 0U }; + +/** +* @brief ߼·״̬ +* @param +* @return +* @note +*/ +void LogicalRouteProcess(void) +{ + UINT8 chLogRouteState = 0u; /*߼·״̬*/ + UINT16 wLogRouteId = 0u; /*߼·ID*/ + UINT16 ii = 0u; /*ѭ*/ + UINT16 logicRouteSum = 0U; + UINT8 chStartLockFlag = CI_START_LOCK_YES; + UINT16 wSignalId = 0U; + + chStartLockFlag = GetStartLockFlag(); + if (CI_START_LOCK_NO != chStartLockFlag) + { /*δϵ*/ + ; /* */ + } + else + { + logicRouteSum = GetLogicalRouteSum(); + /*߼·*/ + for (ii = 0u; ii < logicRouteSum; ii++) + { + wLogRouteId = GetLogicalRouteId(ii); + if (0U != wLogRouteId) + { + chLogRouteState = GetLogicalRouteState(wLogRouteId); + LogicRouteLevelConfirmProcess(wLogRouteId); + switch (chLogRouteState) + { + case ROUTE_LOGICAL_STATE_IDLE: + /* ߼· */ + ; /* */ + break; + case ROUTE_LOGICAL_STATE_FIRST_XUANPAI: + /* ߼·ѡ */ + LogRouteFirstXuanPaiProc(wLogRouteId); + break; + case ROUTE_LOGICAL_STATE_XUANPAI: + /* ߼·ѡ */ + LogRouteXuanPaiProc(wLogRouteId); + break; + case ROUTE_LOGICAL_STATE_LOCK: + /* ߼· */ + LogRouteLockProc(wLogRouteId); + break; + case ROUTE_LOGICAL_STATE_OPEN: + /* ߼·*/ + LogRouteOpenManage(wLogRouteId); + break; + case ROUTE_LOGICAL_STATE_LOCKERR: + LogRouteLockErrManage(wLogRouteId); + break; + case ROUTE_LOGICAL_STATE_UNLOCKWAIT: + /* ߼·ȴ*/ + LogRouteLgcSecResUnlockManage(wLogRouteId); + break; + case ROUTE_LOGICAL_STATE_UNLOCKDELAY: + /* ߼·ʱ*/ + LogRouteUnlockDelayManage(wLogRouteId); + break; + default: + /* ״̬쳣 */ + SetPlatOverFlag(); + SetErrorData(EFUNC_PLAT_OVER, CI_DEVICE_TYPE_ROUTE, wLogRouteId, ETYPE_ROUTE_STATE, chLogRouteState, ESEND_LEVEL_ZERO);/*¼崻*/ + break; + } + } + } + /*ÿڳ߼··źŻ쳣رյı־λ(·߼)*/ + for (ii = 0u; ii < logicRouteSum; ii++) + { + wLogRouteId = GetLogicalRouteId(ii); + wSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + + if ((0U != wLogRouteId) && (0U != wSignalId)) + { + SetLogRouteSignalErrCloseFlag(wSignalId, LOG_ROUTE_SIGNAL_CLOSE_NOERR); + } + } + } +} + +/** +* @brief ʼ߼· +* @param +* @return ߼· +* @noteby cgh 20231010 +*/ +void InitialLogicalRouteData(void) +{ + UINT16 ii = 0U; /*α*/ + + for (ii = 1U; ii < ROUTE_LOGICAL_SUM_MAX; ii++) + { + LogicalRouteDataStru[ii].wLogRouteId = ii; /*߼·ID */ + LogicalRouteDataInitial(ii); + LogicalRouteIdBuff[LogicalRouteSum++] = LogicalRouteDataStru[ii].wLogRouteId; + } +} + +/** +* @brief ߼·ݳʼ +* @param const UINT16 wIndex ߼· +* @return ߼· +* @noteby cgh 20231012 +*/ +void LogicalRouteDataInitial(const UINT16 wIndex) +{ + UINT16 kk = 0U; + + if (wIndex < ROUTE_LOGICAL_SUM_MAX) + { + LogicalRouteDataStru[wIndex].chLogRouteDir = CI_SYSTEM_DIRECTION_NONE; /*߼·Ӫ */ + LogicalRouteDataStru[wIndex].chLogicRouteState = ROUTE_LOGICAL_STATE_IDLE; /*߼·״̬*/ + LogicalRouteDataStru[wIndex].chLogRouteLevel = ROUTE_LEVEL_BLOC; /*߼·ල(ʽ/CBTC) (ֶ̬)*/ + LogicalRouteDataStru[wIndex].chLogRouteBelongCiId = 0U; /*߼·*/ + LogicalRouteDataStru[wIndex].chLogicRouteOpenColor = SIGNAL_SHOWCOLOUR_INVALID; /*߼·ɫ*/ + LogicalRouteDataStru[wIndex].wLogRouteInLogSecSum = 0U; /*߼·߼*/ + for (kk = 0U; kk < MAX_ROUTE_IN_LT_NUM; kk++) + { + LogicalRouteDataStru[wIndex].szLogRouteInLogSecIdBuf[kk] = 0U; /*߼·߼ID*/ + LogicalRouteDataStru[wIndex].szLogRouteTrainLogSecIdBuf[kk] = 0U; /*߼·г߼ID*/ + } + LogicalRouteDataStru[wIndex].chLogRouteSwitchMoveFlag = ROUTE_LOGICAL_SWITCH_MOVE_INVALID; /*߼·Ƿɶ־*/ + LogicalRouteDataStru[wIndex].wLogRouteTrainLogSecSum = 0U; /*߼·г߼*/ + LogicalRouteDataStru[wIndex].wLogRouteRelateBeginSigId = 0U; /*߼·ʼźŻID*/ + LogicalRouteDataStru[wIndex].dwLogRouteChuXuanStartCycNum = 0U; /*߼·ѡʼں*/ + LogicalRouteDataStru[wIndex].dwLogRouteXuanPaiStartCycNum = 0U; /*߼·ѡʼں*/ + LogicalRouteDataStru[wIndex].dwLogRouteLockStartCycNum = 0U; /*߼·ʼں*/ + LogicalRouteDataStru[wIndex].dwDelayErrLockStartCycNum = 0U; /*ʽʱʼں*/ + LogicalRouteDataStru[wIndex].chLogRouteRecoverOpenState = ROUTE_REPEATOPEN_SET_NO; /*߼·źؿ־*/ + + LogicalRouteDataStru[wIndex].szLogRouteApplyResTrainId = 0U; /*߼·ATSԴгID*/ + LogicalRouteDataStru[wIndex].chLogRouteRelatePsdSum = 0U; /*߼·*/ + LogicalRouteDataStru[wIndex].routeInSwitOtherPosLogSecSum = 0U; /*·ڵķǽ·߼*/ + LogicalRouteDataStru[wIndex].routeOutLogSecSum = 0U; /*·ιķǽ·ҷǵ߼ */ + + for (kk = 0U; kk < ROUTE_PSD_SUM_MAX; kk++) + { + LogicalRouteDataStru[wIndex].szLogRouteRelatePsdIdBuf[kk] = 0U; /*߼·ID*/ + } + LogicalRouteDataStru[wIndex].chLogRouteRelateEsbSum = 0U; /*߼·ͣť*/ + for (kk = 0U; kk < ROUTE_ESB_SUM_MAX; kk++) + { + LogicalRouteDataStru[wIndex].szLogRouteRelateEsbIdBuf[kk] = 0U; /*߼·ͣťID*/ + } + for (kk = 0U; kk < MAX_ROUTE_IN_LT_NUM; kk++) + { + LogicalRouteDataStru[wIndex].routeInSwitOtherPosLogSecIdBuf[kk] = 0U; /*·ڵķǽ·߼ID*/ + } + for (kk = 0U; kk < MAX_ROUTE_IN_LT_NUM; kk++) + { + LogicalRouteDataStru[wIndex].routeOutLogSecSumIdBuf[kk] = 0U; /*·ιķǽ·ҷǵ߼ID */ + } + } + else + { + ; /**/ + } +} + +/** +* @brief ȡ߼· +* @param +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT16 GetLogicalRouteSum(void) +{ + UINT16 wRetVal = 0U; + if (ROUTE_LOGICAL_SUM_MAX <= LogicalRouteSum) + { + wRetVal = ROUTE_LOGICAL_SUM_MAX; + } + else + { + wRetVal = LogicalRouteSum; + } + return wRetVal; +} + +/** +* @brief ȡ߼·ṹ +* @param +* @return ߼·ṹ +* @noteby lq 20231016 +*/ +LogicalRouteDataStruct* GetLogicalRouteStr(void) +{ + return LogicalRouteDataStru; +} + +/** +* @brief ȡ߼·ID +* @param const UINT16 wIndex ߼· +* @return ߼·ID +* @noteby cgh 20231010 +*/ +UINT16 GetLogicalRouteId(const UINT16 wIndex) +{ + UINT16 wRetVal = 0U; + UINT16 wLogicalRouteSum = GetLogicalRouteSum(); + + if (wIndex < wLogicalRouteSum) + { + wRetVal = LogicalRouteIdBuff[wIndex]; + } + else + { + /* */ + } + return wRetVal; +} + +/** +* @brief ȡ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT16 GetLogRouteBufIndex(const UINT16 wLogRouteId) +{ + UINT16 wRetVal = ROUTE_LOGICAL_SUM_MAX; + + if (ROUTE_LOGICAL_SUM_MAX > wLogRouteId) + { + wRetVal = wLogRouteId; + } + else + { + /* */ + } + return wRetVal; +} + +/** +* @brief ȡС߼·IDС״̬У +* @param +* @return ߼·ID +* @noteby cgh 20231011 +*/ +UINT16 GetUsableLogicalRouteId(void) +{ + UINT16 ii = 0U; /*α*/ + UINT16 wLogicalRouteId = 0U; + + for (ii = 1U; ii < ROUTE_LOGICAL_SUM_MAX; ii++) + { + if (ROUTE_LOGICAL_STATE_IDLE == LogicalRouteDataStru[ii].chLogicRouteState) + { + wLogicalRouteId = LogicalRouteDataStru[ii].wLogRouteId; + break; + } + } + return wLogicalRouteId; +} + +/** +* @brief ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteDir ߼· +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteDir(const UINT16 wLogRouteId, const UINT8 chLogRouteDir) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if ((CI_SYSTEM_DIRECTION_DOWN == chLogRouteDir) || (CI_SYSTEM_DIRECTION_UP == chLogRouteDir)) + { + LogicalRouteDataStru[wBufIndex].chLogRouteDir = chLogRouteDir; + } + else + { + ; /*Ϸ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteDir(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = CI_SYSTEM_DIRECTION_NONE; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogRouteDir; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·״̬ù߼·״̬ñͨ +* @param const UINT16 wLogRouteId, ߼·ID const UINT8 chLogRouteState ߼·״̬ +* @return CI_ERROR + CI_SUCCESS +* @noteby cgh 20231012 +*/ +void SetLogRouteStateManage(const UINT16 wLogRouteId,const UINT8 chLogRouteState) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wResReqTrainId = 0U; + UINT16 wLogRouteTrainId = 0U; + UINT32 dwCurCycNum = 0U; + + chRetVal = LogRouteStateValidCheck(chLogRouteState); + + dwCurCycNum = Get2oo2CurCycleNum(); + + if (CI_SUCCESS == chRetVal) + { + switch (chLogRouteState) + { + case ROUTE_LOGICAL_STATE_IDLE: + /* ߼· */ + + /*ý·δ*/ + SetLogRouteSectionUsingState(wLogRouteId, PHYSICAL_SECTION_USING_NO); + /*ý·߼: δ*/ + SetLogRouteSecLockState(wLogRouteId, LOG_SECTION_LOGLOCK_NO); + /*ȡ·ķ*/ + SetLogRouteProSwLockState(wLogRouteId, SWITCH_LOCK_PROTECT_CANCEL); + + + break; + case ROUTE_LOGICAL_STATE_FIRST_XUANPAI: + /* ߼·ѡ */ + + /*ý·߼*/ + SetLogRouteSectionUsingState(wLogRouteId, PHYSICAL_SECTION_USING_YES); + + break; + case ROUTE_LOGICAL_STATE_XUANPAI: + /* ߼·ѡ */ + + /*⴦*/ + + break; + case ROUTE_LOGICAL_STATE_LOCK: + /* ߼· */ + + /*ý·δ*/ + SetLogRouteSectionUsingState(wLogRouteId, PHYSICAL_SECTION_USING_NO); + /*ý·߼: */ + SetLogRouteSecLockState(wLogRouteId, LOG_SECTION_LOGLOCK_NORMAL); + + /*õɶ־*/ + SetLogicalRouteSwitchMoveFlag(wLogRouteId, ROUTE_LOGICAL_SWITCH_MOVE_INVALID); + + /*߼·: */ + SetLogRouteProSwLockState(wLogRouteId, SWITCH_LOCK_PROTECT_SET); + + /*·صλ*/ + ClearLogRouteSwitchDrivePos(wLogRouteId); + /*·صλ*/ + ClearLogRouteSwitchDanCaoPos(wLogRouteId); + + + /*гԴΤ*/ + wLogRouteTrainId = GetLogicalRouteApplyResTrainId(wLogRouteId); + SetLogRouteLogSecResTrainId(wLogRouteId, wLogRouteTrainId); + + break; + case ROUTE_LOGICAL_STATE_OPEN: + /* ߼·*/ + CleanLogRoutePhySecPreOccuSta(wLogRouteId); + break; + case ROUTE_LOGICAL_STATE_LOCKERR: + /*߼·쳣*/ + + break; + case ROUTE_LOGICAL_STATE_UNLOCKWAIT: + /* ߼·ȴ*/ + + break; + case ROUTE_LOGICAL_STATE_UNLOCKDELAY: + /* ߼·ʱ*/ + SetLogRouFirDelayErLockStaCyc(wLogRouteId, dwCurCycNum); + break; + + default: + + /*·״̬쳣*/ + /*xxxxx崻*/ + break; + } + + /*ý·״̬*/ + (void)SetLogicalRouteState(wLogRouteId, chLogRouteState); + + } + else + { + /*¼ϵͳ*/ + SetErrorData(EFUNC_LOGIC_MANAGE_SYETEM, + EFUNC_LOGIC_MANAGE_SYETEM, + CI_ERROR, + ETYPE_SYSTEM_EXCEPT, + CI_ERROR, ESEND_LEVEL_ZERO); + + } + +} + +/** +* @brief ߼·״̬ЧԼ +* @param const UINT8 chLogRouteState ߼·״̬ +* @return CI_ERROR: Ч CI_SUCCESS: Ч +* @noteby cgh 20231010 +*/ +UINT8 LogRouteStateValidCheck(const UINT8 chLogRouteState) +{ + UINT8 retVal = CI_ERROR; + + if ((ROUTE_LOGICAL_STATE_IDLE == chLogRouteState) || + (ROUTE_LOGICAL_STATE_FIRST_XUANPAI == chLogRouteState) || + (ROUTE_LOGICAL_STATE_XUANPAI == chLogRouteState) || + (ROUTE_LOGICAL_STATE_LOCK == chLogRouteState) || + (ROUTE_LOGICAL_STATE_OPEN == chLogRouteState) || + (ROUTE_LOGICAL_STATE_UNLOCKWAIT == chLogRouteState) || + (ROUTE_LOGICAL_STATE_UNLOCKDELAY == chLogRouteState) || + (ROUTE_LOGICAL_STATE_LOCKERR == chLogRouteState)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ߼·״̬ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogicRouteState ߼·״̬ +* @return CI_ERROR ʧ +* CI_SUCCESS óɹ +* @noteby cgh 20231010 +*/ +UINT8 SetLogicalRouteState(const UINT16 wLogRouteId, const UINT8 chLogicRouteState) +{ + UINT16 wBufIndex = 0U; + UINT8 chRetVal = CI_ERROR; + UINT32 dwCurCycNum = 0U;/*ǰں*/ + UINT16 kk = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + dwCurCycNum = Get2oo2CurCycleNum(); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + if (CI_SUCCESS == chRetVal) + { + chRetVal = LogRouteStateValidCheck(chLogicRouteState); + } + else + { + ; /**/ + } + if (CI_SUCCESS == chRetVal) + { + if (ROUTE_LOGICAL_STATE_IDLE == chLogicRouteState) + { + /*ʼṹеΪʼֵ*/ + LogicalRouteDataInitial(wBufIndex); + } + else if (ROUTE_LOGICAL_STATE_FIRST_XUANPAI == chLogicRouteState) + { + /*߼·ѡں*/ + LogicalRouteDataStru[wBufIndex].dwLogRouteChuXuanStartCycNum = dwCurCycNum; + } + else if (ROUTE_LOGICAL_STATE_XUANPAI == chLogicRouteState) + { + /*߼·ѡں*/ + LogicalRouteDataStru[wBufIndex].dwLogRouteXuanPaiStartCycNum = dwCurCycNum; + } + else if (ROUTE_LOGICAL_STATE_LOCK == chLogicRouteState) + { + /*߼·ѡѡںţ߼·ں*/ + LogicalRouteDataStru[wBufIndex].dwLogRouteChuXuanStartCycNum = 0U; + LogicalRouteDataStru[wBufIndex].dwLogRouteXuanPaiStartCycNum = 0U; + LogicalRouteDataStru[wBufIndex].dwLogRouteLockStartCycNum = dwCurCycNum; + } + else if (ROUTE_LOGICAL_STATE_OPEN == chLogicRouteState) + { + + } + else if (ROUTE_LOGICAL_STATE_LOCKERR == chLogicRouteState) + { + + } + else if (ROUTE_LOGICAL_STATE_UNLOCKWAIT == chLogicRouteState) + { + + } + else if (ROUTE_LOGICAL_STATE_UNLOCKDELAY == chLogicRouteState) + { + LogicalRouteDataStru[wBufIndex].dwDelayErrLockStartCycNum = dwCurCycNum; + } + else + { + ; /**/ + } + + LogicalRouteDataStru[wBufIndex].chLogicRouteState = chLogicRouteState; /*߼·״̬*/ + } + else + { + ; /**/ + } + return chRetVal; +} + + +/* +* ߼·֮ǰռ״̬ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERROR:ʧ +* CI_SUCCESS:ɹ +*/ +void CleanLogRoutePhySecPreOccuSta(const UINT16 wLogRouteId) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 wLogRouteSignalId = 0U; + UINT16 PhySecId = 0u; + UINT8 ii = 0u; + + LogSecIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + logSecSum = GetLogicalRouteInLogSecSum(wLogRouteId); + wLogRouteSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + if ((NULL != LogSecIdBuff) && (0U != logSecSum)) + { + for (ii = 0U; ii < logSecSum; ii++) + { + PhySecId = GetLgcSecRelativePhySecId(LogSecIdBuff[ii]); + + CleanPhySecPreMergeState(PhySecId); + } + } + + /*ӽ֮ǰռ*/ + PhySecId = GetSignalOutFirstPhySecId(wLogRouteSignalId); + CleanPhySecPreMergeState(PhySecId); +} +/** +* @brief ȡ߼·״̬ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·״̬ +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteState(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogicRouteState; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·ල +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteLevel ߼·ල +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteLevel(const UINT16 wLogRouteId, const UINT8 chLogRouteLevel) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if ((ROUTE_LEVEL_CBTC == chLogRouteLevel) || (ROUTE_LEVEL_BLOC == chLogRouteLevel)) + { + LogicalRouteDataStru[wBufIndex].chLogRouteLevel = chLogRouteLevel; + } + else + { + ; /*Ϸ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼·ල +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ල +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteLevel(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogRouteLevel; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteBelongCiId ߼· +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteBelongCiId(const UINT16 wLogRouteId, const UINT8 chLogRouteBelongCiId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if (0U < chLogRouteBelongCiId) + { + LogicalRouteDataStru[wBufIndex].chLogRouteBelongCiId = chLogRouteBelongCiId; + } + else + { + ; /*Ϸ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteBelongCiId(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogRouteBelongCiId; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·ɫ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteDir ߼·ɫ +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteOpenColor(const UINT16 wLogRouteId, const UINT8 chLogRouteOpenColor) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if ((SIGNAL_SHOWCOLOUR_YELLOWCLOSE == chLogRouteOpenColor) || (SIGNAL_SHOWCOLOUR_GREENCLOSE == chLogRouteOpenColor) + || (SIGNAL_SHOWCOLOUR_INVALID == chLogRouteOpenColor)) + { + LogicalRouteDataStru[wBufIndex].chLogicRouteOpenColor = chLogRouteOpenColor; + } + else + { + ; /*Ϸ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼·ɫ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231011 +*/ +UINT8 GetLogicalRouteOpenColor(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogicRouteOpenColor; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·߼ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 wLogRouteInLogSecSum ߼·߼Ŀ +* @param const UINT16* wLogRouteInLogSecIdbuf ߼·߼ID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteInLogSecData(const UINT16 wLogRouteId, const UINT8 wLogRouteInLogSecSum, const UINT16* wLogRouteInLogSecIdbuf) +{ + UINT16 wBufIndex = 0U; + UINT16 ii = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if ((NULL != wLogRouteInLogSecIdbuf) && (MAX_ROUTE_IN_LT_NUM > wLogRouteInLogSecSum)) + { + (void)CommonMemSet(LogicalRouteDataStru[wBufIndex].szLogRouteInLogSecIdBuf, \ + (UINT32)sizeof(LogicalRouteDataStru[wBufIndex].szLogRouteInLogSecIdBuf), \ + 0U, (UINT32)sizeof(LogicalRouteDataStru[wBufIndex].szLogRouteInLogSecIdBuf)); + + for (ii = 0U; ii < wLogRouteInLogSecSum; ii++) + { + LogicalRouteDataStru[wBufIndex].szLogRouteInLogSecIdBuf[ii] = wLogRouteInLogSecIdbuf[ii]; + } + LogicalRouteDataStru[wBufIndex].wLogRouteInLogSecSum = wLogRouteInLogSecSum; + } + else + { + (void)CommonMemSet(LogicalRouteDataStru[wBufIndex].szLogRouteInLogSecIdBuf, \ + (UINT32)sizeof(LogicalRouteDataStru[wBufIndex].szLogRouteInLogSecIdBuf), \ + 0U, (UINT32)sizeof(LogicalRouteDataStru[wBufIndex].szLogRouteInLogSecIdBuf)); + + LogicalRouteDataStru[wBufIndex].wLogRouteInLogSecSum = 0U; + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼·߼ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteInLogSecSum(const UINT16 wLogRouteId) +{ + UINT16 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].wLogRouteInLogSecSum; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ߼·߼ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteInLogSecId(const UINT16 wLogRouteId) +{ + UINT16* chRetVal = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].szLogRouteInLogSecIdBuf; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ·ڵķǽ·߼ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ +* @noteby cgh 20231011 +*/ +UINT16 GetLogRInSwitOtherPosLogSecSum(const UINT16 wLogRouteId) +{ + UINT16 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].routeInSwitOtherPosLogSecSum; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ·ڵķǽ·߼ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogRInSwitOtherPosLogSecID(const UINT16 wLogRouteId) +{ + UINT16* chRetVal = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].routeInSwitOtherPosLogSecIdBuf; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ·ιķǽ·ҷǵ߼ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteOutLogSecSum(const UINT16 wLogRouteId) +{ + UINT16 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].routeOutLogSecSum; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ·ιķǽ·ҷǵ߼ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteOutLogSecID(const UINT16 wLogRouteId) +{ + UINT16* chRetVal = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].routeOutLogSecSumIdBuf; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·Ƿɶ־ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteLevel ߼·Ƿɶ־ +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteSwitchMoveFlag(const UINT16 wLogRouteId, const UINT8 chLogRouteSwitchMoveFlag) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if ((ROUTE_LOGICAL_SWITCH_MOVE_VALID == chLogRouteSwitchMoveFlag) || (ROUTE_LOGICAL_SWITCH_MOVE_INVALID == chLogRouteSwitchMoveFlag)) + { + LogicalRouteDataStru[wBufIndex].chLogRouteSwitchMoveFlag = chLogRouteSwitchMoveFlag; + } + else + { + ; /*Ϸ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼·Ƿɶ־ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·Ƿɶ־ +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteSwitchMoveFlag(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogRouteSwitchMoveFlag; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·гµ߼ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteTrainLogSecSum ߼·гµ߼Ŀ +* @param const UINT16 wLogRouteTrainLogSecId ߼·гµ߼ID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteTrainLogSecData(const UINT16 wLogRouteId,const UINT16 wLogRouteTrainLogSecSum,const UINT16* wLogRouteTrainLogSecId) +{ + UINT16 wBufIndex = 0U; + UINT16 ii = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if ((NULL != wLogRouteTrainLogSecId) && (MAX_ROUTE_IN_LT_NUM > wLogRouteTrainLogSecSum)) + { + (void)CommonMemSet(LogicalRouteDataStru[wBufIndex].szLogRouteTrainLogSecIdBuf, \ + (UINT32)sizeof(LogicalRouteDataStru[wBufIndex].szLogRouteTrainLogSecIdBuf), \ + 0U, (UINT32)sizeof(LogicalRouteDataStru[wBufIndex].szLogRouteTrainLogSecIdBuf)); + + for (ii = 0U; ii < wLogRouteTrainLogSecSum; ii++) + { + LogicalRouteDataStru[wBufIndex].szLogRouteTrainLogSecIdBuf[ii] = wLogRouteTrainLogSecId[ii]; + } + LogicalRouteDataStru[wBufIndex].wLogRouteTrainLogSecSum = wLogRouteTrainLogSecSum; + } + else + { + (void)CommonMemSet(LogicalRouteDataStru[wBufIndex].szLogRouteTrainLogSecIdBuf, \ + (UINT32)sizeof(LogicalRouteDataStru[wBufIndex].szLogRouteTrainLogSecIdBuf), \ + 0U, (UINT32)sizeof(LogicalRouteDataStru[wBufIndex].szLogRouteTrainLogSecIdBuf)); + + LogicalRouteDataStru[wBufIndex].wLogRouteTrainLogSecSum = 0U; + } + } + else + { + ; /**/ + } +} + +/** +* @brief ȡ߼·гµ߼ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·гµ߼ +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteTrainLogSecSum(const UINT16 wLogRouteId) +{ + UINT16 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].wLogRouteTrainLogSecSum; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ߼·гµ߼ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·гµ߼ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteTrainLogSecId(const UINT16 wLogRouteId) +{ + UINT16* chRetVal = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].szLogRouteTrainLogSecIdBuf; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·ʼźŻID +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteRelateBeginSigId ߼·ʼźŻID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteRelateBeginSigId(const UINT16 wLogRouteId, const UINT16 wLogRouteRelateBeginSigId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if (SIGNAL_SUM_MAX > wLogRouteRelateBeginSigId) + { + LogicalRouteDataStru[wBufIndex].wLogRouteRelateBeginSigId = wLogRouteRelateBeginSigId; + } + else + { + ; /*Ϸ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼·ʼźŻID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ʼźŻID +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteRelateBeginSigId(const UINT16 wLogRouteId) +{ + UINT16 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].wLogRouteRelateBeginSigId; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·ѡʼں +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 dwCyc ߼·ѡʼں +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteChuXuanStartCycNum(const UINT16 wLogRouteId, const UINT32 dwCyc) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ·±*/ + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + LogicalRouteDataStru[wBufIndex].dwLogRouteChuXuanStartCycNum = dwCyc; + } + else + { + /**/ + } +} + +/** +* @brief ȡ߼·ѡʼں +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ѡʼں +* @noteby cgh 20231011 +*/ +UINT32 GetLogRouteChuXuanStartCycNum(const UINT16 wLogRouteId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ±*/ + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + retVal = LogicalRouteDataStru[wBufIndex].dwLogRouteChuXuanStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ߼·ѡʼں +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 dwCyc ߼·ѡʼں +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteXuanPaiStartCycNum(const UINT16 wLogRouteId, const UINT32 dwCyc) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ·±*/ + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + LogicalRouteDataStru[wBufIndex].dwLogRouteXuanPaiStartCycNum = dwCyc; + } + else + { + /**/ + } +} + +/** +* @brief ȡ߼·ѡʼں +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ѡʼں +* @noteby cgh 20231011 +*/ +UINT32 GetLogRouteXuanPaiStartCycNum(const UINT16 wLogRouteId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ±*/ + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + retVal = LogicalRouteDataStru[wBufIndex].dwLogRouteXuanPaiStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ߼·ʼں +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 dwCyc ߼·ʼں +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteLockStartCycNum(const UINT16 wLogRouteId, const UINT32 dwCyc) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ·±*/ + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + LogicalRouteDataStru[wBufIndex].dwLogRouteLockStartCycNum = dwCyc; + } + else + { + /**/ + } +} + +/** +* @brief ȡ߼·ʼں +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ʼں +* @noteby cgh 20231011 +*/ +UINT32 GetLogRouteLockStartCycNum(const UINT16 wLogRouteId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ±*/ + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + retVal = LogicalRouteDataStru[wBufIndex].dwLogRouteLockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ߼·ʽʱʼں +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 dwCyc ߼·ʽʱʼں +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteDelayErrLockStartCyc(const UINT16 wLogRouteId, const UINT32 dwCyc) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ·±*/ + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + LogicalRouteDataStru[wBufIndex].dwDelayErrLockStartCycNum = dwCyc; + } + else + { + /**/ + } +} + +/** +* @brief ȡ߼·ʽʱʼں +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ʽʱʼں +* @noteby cgh 20231011 +*/ +UINT32 GetLogRouteDelayErrLockStartCyc(const UINT16 wLogRouteId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); /*ȡ±*/ + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + retVal = LogicalRouteDataStru[wBufIndex].dwDelayErrLockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ߼·źؿ־ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteRecoverOpenState ߼·źؿ־ +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteRecoverOpenState(const UINT16 wLogRouteId, const UINT8 chLogRouteRecoverOpenState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + if ((ROUTE_REPEATOPEN_SET_YES == chLogRouteRecoverOpenState) || (ROUTE_REPEATOPEN_SET_NO == chLogRouteRecoverOpenState)) + { + LogicalRouteDataStru[wBufIndex].chLogRouteRecoverOpenState = chLogRouteRecoverOpenState; + } + else + { + ; /*Ϸ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼·źؿ־ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·źؿ־ +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteRecoverOpenState(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogRouteRecoverOpenState; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·ATSԴг +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteApplyResTrainId ߼·ATSԴгID +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteApplyResTrainData(const UINT16 wLogRouteId, const UINT16 wLogRouteApplyResTrainId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + LogicalRouteDataStru[wBufIndex].szLogRouteApplyResTrainId = wLogRouteApplyResTrainId; + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼·ATSԴгID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ATSԴгID +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteApplyResTrainId(const UINT16 wLogRouteId) +{ + UINT16 chRetVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].szLogRouteApplyResTrainId; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteRelatePsdId ߼·ID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteRelatePsdIdData(const UINT16 wLogRouteId, const UINT16 wLogRouteRelatePsdId) +{ + UINT16 wBufIndex = 0U; + UINT8 chLogRouteRelatePsdSum = 0U; + UINT16 ii = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if ((ROUTE_LOGICAL_SUM_MAX > wBufIndex) && (0U != wLogRouteRelatePsdId)) + { + chLogRouteRelatePsdSum = LogicalRouteDataStru[wBufIndex].chLogRouteRelatePsdSum; + + if (MAX_ROUTE_IN_LT_NUM > chLogRouteRelatePsdSum) + { + for (ii = 0U; ii < chLogRouteRelatePsdSum; ii++) + { + if (LogicalRouteDataStru[wBufIndex].szLogRouteRelatePsdIdBuf[ii] == wLogRouteRelatePsdId) + { + break; + } + else + { + ; /**/ + } + } + + if (chLogRouteRelatePsdSum == ii) + { + LogicalRouteDataStru[wBufIndex].szLogRouteRelatePsdIdBuf[chLogRouteRelatePsdSum] = wLogRouteRelatePsdId; + LogicalRouteDataStru[wBufIndex].chLogRouteRelatePsdSum = chLogRouteRelatePsdSum + 1U; + } + else + { + ; /*Ѵڲ*/ + } + } + else + { + ; /*Ƿ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231011 +*/ +UINT8 GetLogicalRouteeRelatePsdSum(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogRouteRelatePsdSum; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ߼·ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteRelatePsdId(const UINT16 wLogRouteId) +{ + UINT16* chRetVal = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].szLogRouteRelatePsdIdBuf; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·ͣť +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteRelateEsbId ߼·ͣťID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteRelateEsbIdData(const UINT16 wLogRouteId, const UINT16 wLogRouteRelateEsbId) +{ + UINT16 wBufIndex = 0U; + UINT8 chLogRouteRelateEsbSum = 0U; + UINT16 ii = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if ((ROUTE_LOGICAL_SUM_MAX > wBufIndex) && (0U != wLogRouteRelateEsbId)) + { + chLogRouteRelateEsbSum = LogicalRouteDataStru[wBufIndex].chLogRouteRelateEsbSum; + + if (MAX_ROUTE_IN_LT_NUM > chLogRouteRelateEsbSum) + { + for (ii = 0U; ii < chLogRouteRelateEsbSum; ii++) + { + if (LogicalRouteDataStru[wBufIndex].szLogRouteRelateEsbIdBuf[ii] == wLogRouteRelateEsbId) + { + break; + } + else + { + ; /**/ + } + } + + if (chLogRouteRelateEsbSum == ii) + { + LogicalRouteDataStru[wBufIndex].szLogRouteRelateEsbIdBuf[chLogRouteRelateEsbSum] = wLogRouteRelateEsbId; + LogicalRouteDataStru[wBufIndex].chLogRouteRelateEsbSum = chLogRouteRelateEsbSum + 1U; + } + else + { + ; /*Ѵڲ*/ + } + } + else + { + ; /*Ƿ*/ + } + } + else + { + ; /* */ + } +} + +/** +* @brief ȡ߼·ͣť +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ͣť +* @noteby cgh 20231011 +*/ +UINT8 GetLogicalRouteeRelateEsbSum(const UINT16 wLogRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].chLogRouteRelateEsbSum; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ȡ߼·ͣťID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ͣťID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteRelateEsbId(const UINT16 wLogRouteId) +{ + UINT16* chRetVal = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetLogRouteBufIndex(wLogRouteId); + + if (ROUTE_LOGICAL_SUM_MAX > wBufIndex) + { + chRetVal = LogicalRouteDataStru[wBufIndex].szLogRouteRelateEsbIdBuf; + } + else + { + ; /* */ + } + return chRetVal; +} + +/** +* @brief ߼·ѡ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteFirstXuanPaiProc(const UINT16 wLogRouteId) +{ + UINT8 chFunRtn = CI_ERROR; + + /*߼·*/ + chFunRtn = SetLogRouteCheckProcess(wLogRouteId); + + if (CI_SUCCESS == chFunRtn) + {/*ͨ*/ + + /*ж߼·Ƿɹ*/ + chFunRtn = LogRouteUseStateCheck(wLogRouteId); + if (CI_SUCCESS == chFunRtn) + {/*߼·ѡ״̬*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_XUANPAI); + LogRouteXuanPaiProc(wLogRouteId); + } + else + { + /*ʧܣý·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + } + else + { + /*鲻ͨ ý·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + + + +} + +/** +* @brief ߼·ѡŴ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteXuanPaiProc(const UINT16 wLogRouteId) +{ + UINT8 chFunRtn = CI_ERROR; + UINT8 chDriveRtn = CI_ERROR; + UINT16 ii = 0U; + UINT8 routSwitDrvOvtmFlag = CI_ERROR; + UINT8 routeSWPositionFlag = CI_ERROR; + + + /*߼·*/ + chFunRtn = LockLogRouteCheckProcess(wLogRouteId); + /*·ڵǷʱ*/ + routSwitDrvOvtmFlag = ChekLogRouteSwDrvOvTime(wLogRouteId); + + if (CI_SUCCESS == chFunRtn) + {/*ͨ*/ + + routeSWPositionFlag= ChekLogRouteSwPosRight(wLogRouteId); + + /*ټλȷ*/ + if (CI_SUCCESS== routeSWPositionFlag) + { + /*߼·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_LOCK); + LogRouteLockProc(wLogRouteId); + } + else + { + /*·ڷǷʱ*/ + if (CI_SUCCESS == routSwitDrvOvtmFlag) + { + /**/ + } + else + { + /*鲻ͨý·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + + } + + } + else if (RETURN_LOCK_ERR_SWITPOS == chFunRtn) + {/*λòȷ */ + + if (CI_SUCCESS == routSwitDrvOvtmFlag) + {/*δʱ*/ + chDriveRtn = LogRouteLockDriveSwitch(wLogRouteId); + if (CI_SUCCESS == chDriveRtn) + { + /*ɹ*/ + } + else + { + /*ʧܣý·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + } + else + {/*ʱ*/ + + /*ý·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + } + else + { + /*鲻ͨý·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + +} + +/** +* @brief ߼·մ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteLockProc(const UINT16 wLogRouteId) +{ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT16 wLogSignalId = 0U; /*߼·źŻ*/ + UINT16 wLogRouteTrainLogSecSum = 0U; /*г߼*/ + UINT16* wLogRouteTrainLogSecIdBuf = NULL; + UINT8 checkResult = CI_ERROR; + + if ((0U != wLogRouteId) && (ROUTE_LOGICAL_SUM_MAX != wLogRouteId)) + { + wLogSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + wLogRouteTrainLogSecSum = GetLogicalRouteTrainLogSecSum(wLogRouteId); + if (0U == wLogRouteTrainLogSecSum) + { + /*гԴ,*/ + } + else + { + /*гԴ*/ + SetLogRouteTrainLocLogSecState(wLogRouteId, LOG_SECTION_LOGLOCK_NORMAL); + SetLogRouteTrainLocPhySecState(wLogRouteId, PHYSICAL_SECTION_LOCK_NORMAL); + } + if (0U == wLogSignalId) + { + /*·δźŻȴ*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_UNLOCKWAIT); + } + else + { + startSignalCurColor = GetSignalCurColor(wLogSignalId); + openCloseState = GetSignalOpenCloseState(startSignalCurColor); + if (SIGNAL_OPEN == openCloseState) + { + + /*źŻѿ,߼·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_OPEN); + /*߼*/ + LogRouteOpenManage(wLogRouteId); + + } + else + { + /*źŻδţ鿪߼źŻ*/ + checkResult = OpenLogRouteSignalProc(wLogRouteId); + if (CI_SUCCESS == checkResult) + { + /*ͨ״̬źŻ,źŻ߼·*/ + } + else if (LOG_ROUTE_TRAIN_CROSS == checkResult) + { + /*ѹźŻ*/ + /*߼·״̬Ϊȴ*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_UNLOCKWAIT); + } + else + { + /*żʧܣ߼·쳣*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_LOCKERR); + } + } + } + } +} + +/** +* @brief ߼·쳣մ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteLockErrManage(const UINT16 wLogRouteId) +{ + UINT8 openCloseState = 0u; /*·ʼźŻ״̬*/ + UINT8 startSignalCurColor = 0u; /*ʼźŻǰɫ*/ + UINT16 wLogSignalId = 0U; /*߼·źŻ*/ + UINT8 wLogRouteSignalErrCloseFlag = 0U; + UINT8 checkResult = CI_ERROR; + + wLogSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + startSignalCurColor = GetSignalCurColor(wLogSignalId); + openCloseState = GetSignalOpenCloseState(startSignalCurColor); + + if (SIGNAL_OPEN == openCloseState) + { + wLogRouteSignalErrCloseFlag = GetLogRouteSignalErrCloseFlag(wLogSignalId); + if (LOG_ROUTE_SIGNAL_CLOSE_ERR == wLogRouteSignalErrCloseFlag) + { + DriveLogRouteSignalClose(wLogSignalId); /*̬·һźŻһźŻֲͨһڹرδرգر*/ + } + else + { + /*źŻѿ,߼·*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_OPEN); + /*߼*/ + LogRouteOpenManage(wLogRouteId); + } + } + else + { + /*źŻδţ鿪߼źŻ*/ + checkResult = OpenLogRouteSignalProc(wLogRouteId); + if (CI_SUCCESS == checkResult) + { + /*ͨźŻţֱźŻź߿߼*/ + } + else if (LOG_ROUTE_TRAIN_CROSS == checkResult) + { + /*ѹźŻ*/ + /*߼·״̬Ϊȴ*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_UNLOCKWAIT); + } + else + { + /*żʧܣ߼·쳣*/ + /*쳣رյı־*/ + SetLogRouteSignalErrCloseFlag(wLogSignalId, LOG_ROUTE_SIGNAL_CLOSE_ERR); + } + } + +} + +/* +* ߼·г״̬ +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetLogRouteTrainLocLogSecState(const UINT16 wLogRouteId, const UINT8 lockState) +{ + UINT16 wLogRouteTrainLogSecSum = 0U; /*г߼*/ + UINT16* wLogRouteTrainLogSecIdBuf = NULL; + UINT8 wLogrouteDir = 0u; + UINT16 i = 0u; + UINT8 curLockState = 0u; /*εǰ״̬*/ + UINT16 validRouteId = 0u; /*ǰյĽ·*/ + UINT8 validRouteDir = 0u; + UINT8 funcRet = 0U; + UINT8 keepWork = CI_ERROR; + + wLogRouteTrainLogSecSum = GetLogicalRouteTrainLogSecSum(wLogRouteId); + wLogRouteTrainLogSecIdBuf = GetLogicalRouteTrainLogSecId(wLogRouteId); + /*·*/ + wLogrouteDir = GetLogicalRouteDir(wLogRouteId); + /*ݺϷ*/ + if ((0u != wLogRouteTrainLogSecSum) && (NULL != wLogRouteTrainLogSecIdBuf)) + { + for (i = 0u; i < wLogRouteTrainLogSecSum; i++) + { + funcRet = CheckLgcSecInLogRoute(wLogRouteId, wLogRouteTrainLogSecIdBuf[i]); + if (CI_SUCCESS == funcRet) + { + if (LOG_SECTION_LOGLOCK_NORMAL == lockState) + { + funcRet = CI_SUCCESS; + curLockState = 0u; + /*ȡǰ״̬*/ + curLockState = GetLogSecLockState(wLogRouteTrainLogSecIdBuf[i]); + if ((LOG_SECTION_LOCK_NORMAL == curLockState) || (LOG_SECTION_LOCK_DELAY == curLockState)) + { + validRouteId = GetLogSecLockBelongRoute(wLogRouteTrainLogSecIdBuf[i]); + validRouteDir = GetRouteDirection(validRouteId); + /*֮ǰ·δ*/ + SetLogSecLockState(wLogRouteTrainLogSecIdBuf[i], LOG_SECTION_LOCK_NO, validRouteId, validRouteDir); + } + + /*ȡǰ߼״̬*/ + keepWork = LogSecLockInLogRouteProcess(wLogRouteId, wLogRouteTrainLogSecIdBuf[i]); + if (CI_ERROR == keepWork) + { + break; + } + } + else + { + /**/ + } + } + } + } + else + { + /**/ + } +} + +/* +* ߼·г״̬, Ҫִ߼մ +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetLogRouteTrainLocPhySecState(const UINT16 wLogRouteId, const UINT8 lockState) +{ + UINT8 routePhySecSum = 0U; /*·Ŀ*/ + UINT16 pRoutePhySecIdBuf[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; /*·µID*/ + UINT8 keepWork = CI_ERROR; + UINT8 ii = 0u; /**/ + UINT8 curLockState = 0U; /*εǰ״̬*/ + UINT8 phyLgcSecSum = 0U; + UINT16 *pPhyLgcSecBuf = NULL; + UINT8 jj = 0U; + UINT8 wCurLogicRouteLogLockState = 0U; + UINT16 lgcRLockId = 0U; + UINT8 validRouteSum = 0U; + UINT16 validRouteIdBuf[ROUTE_TRAIN_LOC_MAX_SUM] = { 0U }; /*ҪЧ·ID*/ + UINT16 validRouteId = 0U; + UINT8 phySecSum = 0U; /**/ + RoutePhysicalSectionStruct* pPhySecDataStru = NULL; /*νṹָ*/ + UINT16 phySecRLockId = 0U; + UINT8 cLocalCiId = 0U; + UINT8 cRouteBelongCiId = 0U; + + /*ȡ߼·Ϣ*/ + routePhySecSum = GetLogicRouteTrainLogIncPhySec(wLogRouteId, &pRoutePhySecIdBuf); + + if (0u == routePhySecSum) + { + keepWork = CI_ERROR; + } + else + { + keepWork = CI_SUCCESS; + } + + if (CI_SUCCESS == keepWork) + { + for (ii = 0u; ii < routePhySecSum; ii++) + { + phyLgcSecSum = GetPhySecIncLogSecSum(pRoutePhySecIdBuf[ii]); + pPhyLgcSecBuf = GetPhySecIncLogSecIdBuf(pRoutePhySecIdBuf[ii]); + if (PHYSICAL_SECTION_LOCK_NORMAL == lockState) + { /**/ + curLockState = 0u; + curLockState = GetPhySecLockState(pRoutePhySecIdBuf[ii]); /*ȡεǰ״̬*/ + + if ((PHYSICAL_SECTION_LOCK_NORMAL == curLockState) || + (PHYSICAL_SECTION_LOCK_DELAY == curLockState)) + { /*||ʱ*/ + for (jj = 0U; jj < phyLgcSecSum; jj++) + { + wCurLogicRouteLogLockState = GetLogSecLogLockState(pPhyLgcSecBuf[jj]); + if (LOG_SECTION_LOGLOCK_NORMAL == wCurLogicRouteLogLockState) + { + /*߼߼·ѳ߼ȡε*/ + } + else + { + /*δ߼·յ߼οǷռѹ·*/ + lgcRLockId = GetLogSecLockBelongRoute(pPhyLgcSecBuf[jj]); + if (0U == lgcRLockId) + { + ; /*˵߼ǿеģû*/ + } + else + { + break; + } + } + } + + validRouteId = GetPhySecRLockBelongRouteId(pRoutePhySecIdBuf[ii]); /*ȡ·ID*/ + /*¼Ч·ID*/ + if (jj == phyLgcSecSum) + { + SetPhySecLockState(pRoutePhySecIdBuf[ii], PHYSICAL_SECTION_LOCK_NO, validRouteId, GetRouteDirection(validRouteId)); /*δ*/ + } + + for (jj = 0U; jj < validRouteSum; jj++) + { + if (validRouteId == validRouteIdBuf[jj]) + { + /*ȥ*/ + break; + } + } + + if (validRouteSum == jj) + { + /*δظ*/ + if (ROUTE_TRAIN_LOC_MAX_SUM > validRouteSum) + { + validRouteIdBuf[validRouteSum++] = validRouteId; + } + else + { + keepWork = CI_ERROR; + } + } + } + else + { + /**/ + } + if (CI_ERROR == keepWork) + { + break; + } + } + else + { + /**/ + } + } + } + + if (CI_SUCCESS == keepWork) + { + for (ii = 0U; ii < validRouteSum; ii++) + { + if (0u < validRouteIdBuf[ii]) + { + phySecSum = 0u; + pPhySecDataStru = NULL; + + phySecSum = GetRoutePhysicalSectionSum(validRouteIdBuf[ii]); /*ȡ·*/ + pPhySecDataStru = GetRouteSectionData(validRouteIdBuf[ii]); /*ȡ·*/ + + if ((0u == phySecSum) || (NULL == pPhySecDataStru)) + { + keepWork = CI_ERROR; + + } + else + { + for (jj = 0u; jj < phySecSum; jj++) + { + phySecRLockId = GetPhySecRLockBelongRouteId(pPhySecDataStru[jj].PhysicalSectionId); + if (validRouteIdBuf[ii] == phySecRLockId) + { + break; + } + else + { + ; + } + } + + cLocalCiId = GetSystemParaLocalCiId(); + cRouteBelongCiId = GetRouteBelongCiId(validRouteIdBuf[ii]); + if (jj == phySecSum) + { + if ((0U != cLocalCiId) && (cLocalCiId == cRouteBelongCiId)) + { + (void)SetRouteState(validRouteIdBuf[ii], ROUTE_STATE_IDLE); + /*ȡ·ķ*/ + SetRouteRelProSwitchLockSta(validRouteIdBuf[ii], SWITCH_LOCK_PROTECT_CANCEL); + } + else + { + /*RC춯̬·*/ + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_SEC_LOCK_APPLY, 0U, validRouteIdBuf[ii], cRouteBelongCiId); + } + } + else + { + if ((0U != cLocalCiId) && (cLocalCiId == cRouteBelongCiId)) + { + (void)SetRouteState(validRouteIdBuf[ii], ROUTE_STATE_HALF_UNLOCK); + } + else + { + /*RC춯̬·*/ + AddCiSendToCiCmdInfo(CI_CMD_ROUTE_SEC_LOCK_APPLY, 0U, validRouteIdBuf[ii], cRouteBelongCiId); + } + } + } + } + } + } +} + +/* +* ߼·ڵ״̬ +* ˵ const UINT16 wLogRouteId, ·ID +* const UINT8 useState, ״̬ +* ֵ +* LC +*/ +void SetLogRouteSectionUsingState(const UINT16 logRouteId,const UINT8 useState) +{ + UINT16* LogSecIdBuff = NULL; + UINT16 logSecSum = 0U; + UINT16 ii = 0U; + UINT16 wPhySecId = 0U; + + if ((0U != logRouteId)&&(ROUTE_LOGICAL_SUM_MAX > logRouteId) + &&((PHYSICAL_SECTION_USING_YES == useState)|| (PHYSICAL_SECTION_USING_NO == useState))) + {/*ȡ߼·߼*/ + LogSecIdBuff = GetLogicalRouteInLogSecId(logRouteId); + logSecSum = GetLogicalRouteInLogSecSum(logRouteId); + + /*߼Σȡ*/ + for (ii = 0; ii < logSecSum; ii++) + { + wPhySecId = GetLgcSecRelativePhySecId(LogSecIdBuff[ii]); + + if (PHYSICAL_SECTION_USING_YES == useState) + {/**/ + (void)SetPhySecUseStateByLogRoute(wPhySecId, PHYSICAL_SECTION_USING_YES, logRouteId); + } + else if (PHYSICAL_SECTION_USING_NO == useState) + {/*δ*/ + (void)SetPhySecUseStateByLogRoute(wPhySecId, PHYSICAL_SECTION_USING_NO, logRouteId); + } + else + { + /*ɴ֧*/ + } + + } + } + else + { + /**/ + } +} + +/* +* ߼·߼Դ +* ˵ const UINT16 routeId, ·ID +* ֵ void +* fan 2023-10-11 +*/ +void LogRouteLgcSecResUnlockManage(const UINT16 logRouteId) +{ + /*ʼ*/ + UINT8 chRouteState = 0u; + UINT8 chRouteRepeatOpenFlag = 0U; + UINT16 routeLogNum = 0u; + UINT16 wTrainId = 0U; + UINT16 ii = 0U; + UINT16* routeLogSecId = NULL; + UINT16 wStartSignalId = 0U; + UINT8 chStartSignalCurColor = 0U; + UINT8 chOpenCloseState = 0U; + UINT16 wUnlockLgcSecId = 0U; /*߼ID*/ + UINT16 wPreUnlockLgcSecId = 0U; /*·߼һ߼*/ + UINT8 chLgcLockState = 0U;/*߼״̬*/ + UINT8 chPreLgcLockState = 0U;/*һ߼״̬*/ + UINT8 chPreLgcLogRouteId = 0U;/*һ߼߼·*/ + UINT8 checkFlag = 0U; + + /*ȡ·Ϣ*/ + chRouteState = GetLogicalRouteState(logRouteId);/*߼·״̬*/ + wStartSignalId = GetLogicalRouteRelateBeginSigId(logRouteId);/*·ʼźŻ*/ + if (0U != wStartSignalId) + { + /*ʼźŻ*/ + chStartSignalCurColor = GetSignalCurColor(wStartSignalId); + chOpenCloseState = GetSignalOpenCloseState(chStartSignalCurColor);/*ʼźŻ״̬*/ + } + else + { + ; /**/ + } + chRouteRepeatOpenFlag = GetLogicalRouteRecoverOpenState(logRouteId);/*ؿ־*/ + + if ((0U != wStartSignalId)&&(SIGNAL_OPEN == chOpenCloseState)) + {/*ʼźŻҿ򲻽*/ + + } + /*ʼźŻرջûʼźŻ*/ + else if ((ROUTE_REPEATOPEN_SET_YES != chRouteRepeatOpenFlag) + && (ROUTE_LOGICAL_STATE_UNLOCKWAIT == chRouteState)) /*״̬ж*/ + { + /*ȡ߼·߼*/ + routeLogNum = GetLogicalRouteInLogSecSum(logRouteId); + routeLogSecId= GetLogicalRouteInLogSecId(logRouteId);/*߼ID*/ + if ((0u < routeLogNum) + && (MAX_ROUTE_IN_LT_NUM > routeLogNum)) + { + /*ȡղ Ԥ*/ + + /*ÿڻȡһû߼*/ + for (ii = 0U; ii < routeLogNum; ii++) + { + + wPreUnlockLgcSecId = wUnlockLgcSecId;/*һ߼ID*/ + wUnlockLgcSecId = routeLogSecId[ii];/*ȡǰ߼ID*/ + /*ij߼ζԸ߼·Ľ*/ + /*ÿڼһյ߼*/ + checkFlag = CheckLogRouteIdBelLogSec(wUnlockLgcSecId, logRouteId); /*жϴ߼Ƿ񱻱߼·*/ + if (CI_SUCCESS == checkFlag) + { + chLgcLockState = GetLogSecLogLockState(wUnlockLgcSecId); + if ((LOG_SECTION_LOGLOCK_EXCEPT == chLgcLockState)) + { + break; /*״̬*/ + } + if (LOG_SECTION_LOGLOCK_NORMAL == chLgcLockState) + { + checkFlag = CheckLogRouteLgcSecResUnlock(wUnlockLgcSecId, wPreUnlockLgcSecId, logRouteId); + if (CI_SUCCESS == checkFlag) + { + LgcSecLogicalUnlockProc(logRouteId, wUnlockLgcSecId, wPreUnlockLgcSecId); /*ӵǰ߼ɾ߼·߼߼·--*/ + } + else + { + break; /*ڲ*/ + } + } + else + { + ; /**/ + } + } + else + { + /*DZ߼·յ߼Σִн*/ + } + } + /*ij·߼ȫ*/ + checkFlag = LogRouteLogSecReleaseCheck(logRouteId); + if (CI_SUCCESS == checkFlag) + { + /*ȫ*/ + SetLogRouteProSwLockState(logRouteId, SWITCH_LOCK_PROTECT_CANCEL); + /*ÿ*/ + (void)SetLogicalRouteState(logRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + else + { + ;/* ʱ״̬*/ + } + } + else + { + ; /**/ + } + } + else /*ֻͷԴ*/ + { + ; /**/ + } +} + +/* +* ߼ε߼· +* ˵ const UINT16 logSecId, ߼ID + const UINT16 preLogSecId, һ߼ID + const UINT16 wLogRouteId, ߼·ID +* ֵ CI_SUCCESSͨ CI_ERRORʧ +* fan 2023-10-11 +*/ +UINT8 CheckLogRouteLgcSecResUnlock(const UINT16 logSecId, const UINT16 preLogSecId, const UINT16 logRouteId) +{ + UINT8 chKeepWork = CI_SUCCESS; + UINT8 occupyFlag = CI_ERROR; + UINT8 chLgcLockState = 0U;/*߼״̬*/ + UINT8 chLogSecReleaseFlag = 0U; /*߼гͷ־*/ + UINT8 logRouteCheck = 0U; /*߼ڸ߼·±*/ + UINT8 chLgcResTrainSum = 0U; + UINT16 wTrainId = 0U; /*гID*/ + + if (0U == preLogSecId) + { + /*·һ߼*/ + chKeepWork = CI_SUCCESS; + } + else + { + /*߼һպռ*/ + logRouteCheck = CheckLogRouteIdBelLogSec(preLogSecId, logRouteId); + if (CI_SUCCESS == logRouteCheck) + { + /*һ߼λý·ܽ*/ + chKeepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepWork) + { + logRouteCheck = CheckLogRouteIdBelLogSec(logSecId, logRouteId); + if (CI_SUCCESS == logRouteCheck)/*и߼·*/ + { + occupyFlag = GetLogSecCurCtOrUtOccupyState(logSecId);/*ȡǰ߼ռ״̬*/ + if (LOGICSECTION_OCCUPY_NO == occupyFlag) + { + chLgcLockState = GetLogSecLogLockState(logSecId);/*߼ε߼ձ־*/ + wTrainId = GetLogicalRouteApplyResTrainId(logRouteId); + } + else + { + /*ռ*/ + chKeepWork = CI_ERROR; + } + } + else + { + /*߼Ѿ˽·*/ + chKeepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepWork) + { + chKeepWork = CI_ERROR; + /*߼*/ + if (LOG_SECTION_LOGLOCK_NORMAL == chLgcLockState) + { + /*ȷǸý·г߼*/ + chLogSecReleaseFlag = GetLogSecTrainRelease(logSecId, wTrainId); + + if(LOGIC_SECTION_TRAIN_UNLOCK_YES == chLogSecReleaseFlag) + { + /*߼εΪ߼*/ + chKeepWork = CI_SUCCESS; + } + else + { + chKeepWork = CI_ERROR; + } + } + else + { + chKeepWork = CI_ERROR; + } + } + debug_infor_printf((const)"LogSecRes Unlock LgcId: %d TrainId:%d Cyc Checkstatus:%d\n", logSecId, wTrainId, Get2oo2CurCycleNum(), chKeepWork); + return chKeepWork; +} + +/* +* ߼ε߼· +* ˵ const UINT16 wLogRouteId, ߼·ID +const UINT16 logSectionId ߼ID +const UINT16 preLogSecId һ߼ID +* ֵ void +* fan 20231012 +*/ +void LgcSecLogicalUnlockProc(const UINT16 logRouteId, const UINT16 logSectionId, const UINT16 preLogSecId) +{ + /*ʼ*/ + UINT8 checkValue = 0u; + UINT8 logRouteSum = 0u; /*߼ι߼·*/ + UINT8 chCheckSum = 0u; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT16 chDevId = 0U; + UINT8 chDevState = 0U; + UINT8 chProSwState = 0U; + LogsecSwitchStruct* pstLogicSecSwitchBuf = NULL; /*߼εĵṹ*/ + UINT16 wTrainId = 0U; + UINT16 wLgcBufIndex = 0U; + LogicSectionDataStruct *pstLgcSecInfo = GetLogicSecData(); + LogicTrainResStruct * pstTrainResInfo = NULL; + UINT8 checkPre = 0U; + UINT8 chLogSecReleaseFlag = 0U; /*ȡ߼Դгͷű־*/ + UINT8 chLgcResTrainSum = 0U; /*߼Դг*/ + UINT8 chTrainSum = 0U; + + wLgcBufIndex = GetlogSectionBufIndex(logSectionId); + + /*гԴϢ*/ + + /*һѾ޸óԴ*/ + wTrainId = GetLogicalRouteApplyResTrainId(logRouteId); + if (0U != preLogSecId) + { + checkPre = CheckLogRouteIdBelLogSec(preLogSecId, logRouteId); + } + + if ((0U == preLogSecId) || (CI_ERROR == checkPre)) + { + /*Ƿյָг*/ + chLogSecReleaseFlag = GetLogSecTrainRelease(logSectionId, wTrainId); + if (((LOGIC_SECTION_TRAIN_UNLOCK_YES == chLogSecReleaseFlag) || (0U == wTrainId)) + && (NULL == pstTrainResInfo)) + { + chLgcResTrainSum = GetLogSecTrainInfoSum(logSectionId); + for (jj = 0U; jj < chLgcResTrainSum; jj++) + { + /*ɾгӦ߼Դ*/ + if (pstLgcSecInfo[wLgcBufIndex].szTrainResData[jj].wTrainId == wTrainId) + { + ; /**/ + } + else + { + (void)CommonMemCpy((void*)(&pstLgcSecInfo[wLgcBufIndex].szTrainResData[chTrainSum++]), (UINT32)sizeof(LogicTrainResStruct), + (void*)(&pstLgcSecInfo[wLgcBufIndex].szTrainResData[jj]), (UINT32)sizeof(LogicTrainResStruct)); + } + } + debug_infor_printf((const)"LogSecRes Release LgcId: %d Cyc%d \n", logSectionId, Get2oo2CurCycleNum()); + /*0 */ + for (jj = chTrainSum; jj < chLgcResTrainSum; jj++) + { + (void)ComMemSet(&(pstLgcSecInfo[wLgcBufIndex].szTrainResData[jj]), (UINT16)sizeof(LogicTrainResStruct), 0U); + } + pstLgcSecInfo[wLgcBufIndex].chTrainInfoSum = chTrainSum; + + /*߼βٹ߼·*/ + checkValue = DelLogSecBelongLogRouteId(logSectionId, logRouteId); + + /*߼ε߼״̬*/ + logRouteSum = GetLogSecLockBelLogRouteSum(logSectionId); + if ((0u == logRouteSum) && (CI_SUCCESS == checkValue)) + { + /*ɾɹ߼ι߼·ĿΪ0߼״̬δ*/ + SetLogSecLogLockState(logSectionId, LOG_SECTION_LOGLOCK_NO, 0U); + + } + else + { + ; /**/ + } + } + } + else + { + debug_infor_printf((const)"LogSecRes Release ERROR LgcId: %d TrainId:%d Cyc%d \n" + , logSectionId, wTrainId, Get2oo2CurCycleNum()); + } +} + + +/** +* @brief ߼·źſŴ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteOpenManage(const UINT16 wLogRouteId) +{ + UINT16 wSignalId = 0U; + UINT8 curColor = 0u; + UINT8 sigState = 0u; + UINT8 checkResult = CI_ERROR; + UINT8 funcId = EFUNC_LogRouteOpenManage;/*ID*/ + UINT8 wSignalCrossState = 0U; + + wSignalId = GetLogicalRouteRelateBeginSigId(wLogRouteId); + curColor = GetSignalCurColor(wSignalId); + sigState = GetSignalOpenCloseState(curColor); + + if (SIGNAL_OPEN == sigState) + { + /*źŻѾţάźŻţ쳣رպգѹرȴ״̬*/ + checkResult = KeepOpenLogRouteSignalProc(wLogRouteId); + if (CI_SUCCESS == checkResult) + { + /*ֳɹ*/ + } + else if (LOG_ROUTE_TRAIN_CROSS == checkResult) + { + /*ѹźŻ*/ + /*߼·״̬Ϊȴ*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_UNLOCKWAIT); + + } + else + { + /*ʧ,߼·״̬Ϊ߼쳣*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_LOCKERR); + } + } + else + { + /*߼·״̬Ϊ߼쳣*/ + SetLogRouteStateManage(wLogRouteId, ROUTE_LOGICAL_STATE_LOCKERR); + + /*źŻϹرձ*/ + SetErrorData(funcId, CI_DEVICE_TYPE_SIGNAL, wSignalId, ETYPE_SIG_START_OPEN_STATE, sigState, ESEND_LEVEL_ATS); + } +} + +/* +* ָID߼·гԴǷ߼ +* ˵ const UINT16 routeId, ·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: гԴ +* CI_ERROR: гԴ +*/ +UINT8 CheckLgcSecHaveTrainLocRoute(const UINT16 logRouteId, const UINT16 lgcSecId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = CI_ERROR; + UINT8 ii = 0U; + + bufIndex = GetLogRouteBufIndex(logRouteId); /*ȡ·±*/ + if (ROUTE_LOGICAL_SUM_MAX > bufIndex) + { + + for (ii = 0U; ii < LogicalRouteDataStru[bufIndex].wLogRouteTrainLogSecSum; ii++) + { + if (lgcSecId == LogicalRouteDataStru[bufIndex].szLogRouteTrainLogSecIdBuf[ii]) + { + reVal = CI_SUCCESS; + break; + } + else + { + ; /*ִ*/ + } + } + + if (ii == LogicalRouteDataStru[bufIndex].wLogRouteTrainLogSecSum) + { + /*δҵͬ߼*/ + reVal = CI_ERROR; + } + else + { + + } + + } + else + { + /**/ + reVal = CI_ERROR; + } + return reVal; +} + +/* +* ȷָID߼·ʼźŻɫ +* ˵ const UINT16 routeId, ·ID +* ֵ +* Created By LQ 2023/10/11 +*/ +void LogicRouteOpenColorProc(const UINT16 logRouteId) +{ + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 wLogicRouteIncLogSecNum = 0U; /*߼·߼*/ + UINT16* pLogicRouteIncLogSecId = NULL; /*߼·߼ID*/ + UINT8 cLogSecIncSwitchNum = 0U; /*߼ΰĵ*/ + LogsecSwitchStruct * pLogSecIncSwitchStru = NULL; /*߼ΰĵṹ*/ + UINT16 wStartSignalId = 0U; /*߼·ʼźŻID*/ + UINT8 cSiganlFengDengType = SIGNAL_TYPE_FENG_NO; /*źŻ*/ + UINT8 cSignalDrvColor = SIGNAL_SHOWCOLOUR_INVALID; /*źŻɫ*/ + UINT8 cSwitchFanWeiFlag = FLAG_UNSET; /*߼ελ־*/ + + if ((0U < logRouteId) && (ROUTE_LOGICAL_SUM_MAX > logRouteId)) + { + wLogicRouteIncLogSecNum = GetLogicalRouteInLogSecSum(logRouteId); + pLogicRouteIncLogSecId = GetLogicalRouteInLogSecId(logRouteId); + + if ((0U != wLogicRouteIncLogSecNum) && (NULL != pLogicRouteIncLogSecId)) + { + /*߼·߼ΣжǷڹλ߼*/ + for (ii = 0U; ii < wLogicRouteIncLogSecNum; ii++) + { + cLogSecIncSwitchNum = GetLogicSecSwitchSum(pLogicRouteIncLogSecId[ii]); + pLogSecIncSwitchStru = GetLogicSecSwitchIdStru(pLogicRouteIncLogSecId[ii]); + if ((0U != cLogSecIncSwitchNum) && (NULL != pLogSecIncSwitchStru)) + { + for (jj = 0U; jj < cLogSecIncSwitchNum; jj++) + { + if (SWITCH_POSITION_FANWEI == pLogSecIncSwitchStru[jj].SwitchPosition) + { + cSwitchFanWeiFlag = FLAG_SET; /*߼ιλֹͣ*/ + break; + } + else + { + /**/ + } + } + } + else + { + /*߼β*/ + } + + if (FLAG_SET == cSwitchFanWeiFlag) + { + break; /*߼ιλֹͣ*/ + } + else + { + /**/ + } + } + + wStartSignalId = GetLogicalRouteRelateBeginSigId(logRouteId); + cSiganlFengDengType = GetSignalFengDengType(wStartSignalId); /*ȡźŻ*/ + + /*ݵλúͷȷ߼·ʼźŻɫ*/ + if (FLAG_SET == cSwitchFanWeiFlag) + { + /*߼ιλ*/ + switch (cSiganlFengDengType) + { + case SIGNAL_TYPE_FENG_NO: + case SIGNAL_TYPE_FENG_GREEN: + { + /*ڵڷλδƵƣźŻɫΪ*/ + cSignalDrvColor = SIGNAL_SHOWCOLOUR_YELLOWCLOSE; + break; + } + case SIGNAL_TYPE_FENG_YELLOW: + { + /*ڵڷλҷƵƣźŻɫΪ*/ + cSignalDrvColor = SIGNAL_SHOWCOLOUR_GREENCLOSE; + break; + } + default: + /*ɴ֧*/ + break; + } + } + else + { + /*߼ιλ*/ + switch (cSiganlFengDengType) + { + case SIGNAL_TYPE_FENG_NO: + case SIGNAL_TYPE_FENG_YELLOW: + { + /*ڵڷλδ̵ƣźŻɫΪ*/ + cSignalDrvColor = SIGNAL_SHOWCOLOUR_GREENCLOSE; + break; + } + case SIGNAL_TYPE_FENG_GREEN: + { + /*ڵڷλҷ̵ƣźŻɫΪ*/ + cSignalDrvColor = SIGNAL_SHOWCOLOUR_YELLOWCLOSE; + break; + } + default: + /*ɴ֧*/ + break; + } + } + } + else + { + /*ȡ߼ʧܣ*/ + } + + SetLogicalRouteOpenColor(logRouteId, cSignalDrvColor); + } + else + { + /*ηǷ*/ + } +} + +/** +* @brief ߼·ʽʱ +* @param const UINT16 wLogicalRouteId ߼·ID +* @return +* @noteby cgh 20231012 +*/ +void LogRouteUnlockDelayManage(const UINT16 wLogicalRouteId) +{ + UINT32 dwDelayStartCycNum = 0U; /*߼·ιϽʱʼ*/ + UINT32 dwDelayTotalCycSum = 0U; /*߼·ιϽʱ*/ + UINT8 chCheckTimeState = 0U; /*ʱ*/ + UINT16 wFirstNormalLockLogId = 0U; /*߼·һյ߼ID*/ + UINT16 wRelativePhySecId = 0U; /*߼ιID*/ + + /*ʱʱ临˽ʱ*/ + dwDelayTotalCycSum = GetSystemParaBlocRouteDelayCyc(); /*ȡʽ·ʱ*/ + dwDelayStartCycNum = GetLogRouteDelayErrLockStartCyc(wLogicalRouteId); /*ȡ߼·Ͻʼ*/ + /*ʱʱ*/ + chCheckTimeState = SystemOverTimeCheck(dwDelayStartCycNum, dwDelayTotalCycSum); + + if (CI_TIME_OUT == chCheckTimeState) + { + wFirstNormalLockLogId = GetLogRouteFirNormalLockLogId(wLogicalRouteId); + wRelativePhySecId = GetLgcSecRelativePhySecId(wFirstNormalLockLogId); + + SetLogRouFirDelayErLockStaCyc(wLogicalRouteId,0U); + /*ڱ߼·յ߼߼쳣*/ + SetPhyIncLogSecLogLockState(wRelativePhySecId, LOG_SECTION_LOGLOCK_EXCEPT, wLogicalRouteId); + /*߼·ʽʱںΪ0*/ + SetLogSecLogRDelayErrLockCyc(wFirstNormalLockLogId,0U); + } + else + { + ; /*ʱ䲻ȴ*/ + } +} + +/* +: ߼· +: const UINT16 logRouteId ·ID +: +ֵ: CI_SUCCESS,մɹ +CI_ERROR,մʧ +*/ +UINT8 LogRouteLockDriveSwitch(const UINT16 logRouteId) +{ + UINT8 ii = 0u; + UINT8 switchSum = 0u; + UINT16 switchId = 0u; + UINT8 switchExpPosition = SWITCH_POSITION_INVALID; /*λ*/ + UINT8 switchDancaoPosition = SWITCH_POSITION_INVALID; /*Чλ*/ + RouteSwitchStruct pRouteSwitchStru[ROUTE_SWITCH_SUM_MAX] = {0U}; /*ݽṹָ*/ + UINT8 innerSwitchRetVal = CI_ERROR; /*·ڵǷɱĽ*/ + UINT8 assocSwitchRetVal = CI_ERROR; /*ǷɱĽ*/ + UINT8 assocSwitchSum = 0u; /*Ŀ*/ + RouteAssocSwitchStruct routeAssocSwitchStru = { 0,0 }; /**/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct pRouteProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + if ((0u == logRouteId) || (logRouteId >= ROUTE_SUM_MAX)) + { + innerSwitchRetVal = CI_ERROR; + } + else + { + innerSwitchRetVal = CI_SUCCESS; + + /*ȡ߼·ڵ*/ + switchSum = GetLogRouteSWData(logRouteId, pRouteSwitchStru); + /*ȡ߼·ڷ*/ + routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, pRouteProtectSwitchStru); + + /* ෴λȡ· */ + for (ii = 0u; ii < switchSum; ii++) + { + switchId = pRouteSwitchStru[ii].SwitchId; + switchExpPosition = pRouteSwitchStru[ii].SwitchPosition; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + + if ((SWITCH_POSITION_INVALID == switchDancaoPosition) + || + (switchDancaoPosition == switchExpPosition)) + {/*Ч λ붯λһ*/ + innerSwitchRetVal = CI_SUCCESS; + } + else + { + /*ٵ෴λȡ·*/ + innerSwitchRetVal = CI_ERROR; + break; + } + } + + if (CI_SUCCESS == innerSwitchRetVal) + { + + + /* ෴λȡ· */ + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = pRouteProtectSwitchStru[ii].ProtectSwitchId; + switchExpPosition = pRouteProtectSwitchStru[ii].ProtectPosition; + switchDancaoPosition = GetSwitchDanCaoPostition(switchId); + + if ((SWITCH_POSITION_INVALID == switchDancaoPosition) + || + (switchDancaoPosition == switchExpPosition)) + {/*Ч λ붯λһ*/ + innerSwitchRetVal = CI_SUCCESS; + } + else + { + /*ٵ෴λȡ·*/ + innerSwitchRetVal = CI_ERROR; + break; + } + } + } + else + { + innerSwitchRetVal = CI_ERROR; + } + + + + if (CI_SUCCESS == innerSwitchRetVal) + { + /*·*/ + LogRouteDrvInnerSwitch(logRouteId, SWITCH_NEED_DRIV_TRUE); + } + else + { + LogRouteDrvInnerSwitch(logRouteId, SWITCH_NEED_DRIV_FALSE); + } + + } + + return innerSwitchRetVal; + + + + +} + +/* +* ȡ߼·߼ηϢ +* ˵ const UINT16 logRouteId, ·ID +* OUT RouteProtectSwitchStruct szRouteProtectSwitchStruct[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetLogRouteProSwData(const UINT16 logRouteId, OUT RouteProtectSwitchStruct szRouteProSwitchStruct[ROUTE_PROTECTSWI_SUM_MAX]) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + UINT8 keepWork = CI_ERROR; + UINT8 ii = 0U; /*ѭ*/ + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT16 phySecId = 0U; + UINT8 phySecSum = 0U; + UINT8 proSwSum = 0U; + UINT8 outTmpProSwSum = 0U; + RouteProtectSwitchStruct szTmpProSwStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; + LogsecSwitchStruct* pLgcProSwStru = NULL; /*߼ιϢ*/ + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + + logSectionSum = GetLogicalRouteInLogSecSum(logRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId); + + /*μ*/ + if (NULL != szRouteProSwitchStruct) + { + keepWork = CI_SUCCESS; + /*·߼*/ + for (ii = 0U; ii < logSectionSum; ii++) + { + + proSwSum = GetLgcRelateProSwSum(pLogIdBuff[ii]); + pLgcProSwStru = GetLgcRelateProSwStru(pLogIdBuff[ii]); + + if (NULL != pLgcProSwStru) + { + /*ȥز*/ + for (jj = 0U; jj < proSwSum; jj++) + { + for (kk = 0U; kk < outTmpProSwSum; kk++) + { + if (pLgcProSwStru[jj].SwitchId == szTmpProSwStru[kk].ProtectSwitchId) + { + break; + } + else + { + /*ִ*/ + } + } + if (kk == outTmpProSwSum) + { + if (ROUTE_PROTECTSWI_SUM_MAX > outTmpProSwSum) + { + szTmpProSwStru[outTmpProSwSum].ProtectSwitchId = pLgcProSwStru[jj].SwitchId; + szTmpProSwStru[outTmpProSwSum].ProtectPosition = pLgcProSwStru[jj].SwitchPosition; + outTmpProSwSum++; + } + else + { + break; + } + } + } + } + else + { + keepWork = CI_ERROR; + } + + /*δظ*/ + if (jj != proSwSum) + { + keepWork = CI_ERROR; + } + else + { + ; + } + + if (CI_ERROR == keepWork) + { + break; + } + else + { + ; + } + } + + /*ִɣδԽ*/ + if (ii == logSectionSum) + { + reVal = outTmpProSwSum; + for (ii = 0U; ii < outTmpProSwSum; ii++) + { + szRouteProSwitchStruct[ii] = szTmpProSwStru[ii]; + } + } + + + } + else + { + /*ʧ*/ + reVal = 0u; + } + + return reVal; +} + +/* +* ȡ߼·ڵϢ +* ˵ const UINT16 logRouteId, ·ID +* OUT RouteProtectSwitchStruct szRouteProtectSwitchStruct[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetLogRouteSWData(const UINT16 logRouteId, OUT RouteSwitchStruct szRouteSwitchStruct[ROUTE_SWITCH_SUM_MAX]) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + UINT8 keepWork = CI_ERROR; + UINT8 ii = 0U; /*ѭ*/ + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT16 phySecId = 0U; + UINT8 phySecSum = 0U; + UINT8 switchSum = 0U; + UINT8 outTmpProSwSum = 0U; + + RouteSwitchStruct szTmpSwStru[ROUTE_SWITCH_SUM_MAX] = { 0U }; + LogsecSwitchStruct* pLgcSwStru = NULL; /*߼ιϢ*/ + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + + logSectionSum = GetLogicalRouteInLogSecSum(logRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId); + + /*μ*/ + if (NULL != szRouteSwitchStruct) + { + keepWork = CI_SUCCESS; + /*·߼*/ + for (ii = 0U; ii < logSectionSum; ii++) + { + switchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSwStru = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + + if (NULL != pLgcSwStru) + { + /*ȥز*/ + for (jj = 0U; jj < switchSum; jj++) + { + for (kk = 0U; kk < outTmpProSwSum; kk++) + { + if (pLgcSwStru[jj].SwitchId == szTmpSwStru[kk].SwitchId) + { + break; + } + else + { + /*ִ*/ + } + } + if (kk == outTmpProSwSum) + { + if (ROUTE_PROTECTSWI_SUM_MAX > outTmpProSwSum) + { + szTmpSwStru[outTmpProSwSum].SwitchId = pLgcSwStru[jj].SwitchId; + szTmpSwStru[outTmpProSwSum].SwitchPosition = pLgcSwStru[jj].SwitchPosition; + outTmpProSwSum++; + } + else + { + break; + } + } + } + } + else + { + keepWork = CI_ERROR; + } + + /*δظ*/ + if (jj != switchSum) + { + keepWork = CI_ERROR; + } + else + { + ; + } + + if (CI_ERROR == keepWork) + { + break; + } + else + { + ; + } + } + + /*ִɣδԽ*/ + if (ii == logSectionSum) + { + reVal = outTmpProSwSum; + for (ii = 0U; ii < outTmpProSwSum; ii++) + { + szRouteSwitchStruct[ii] = szTmpSwStru[ii]; + } + } + + + } + else + { + /*ʧ*/ + reVal = 0u; + } + + return reVal; +} + + +/* +* ߼·߼״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetLogRouteSecLockState(const UINT16 logRouteId, const UINT8 lockState) +{ + /*ʼ*/ + UINT16 i = 0u; + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT8 curLockState = 0u; /*εǰ״̬*/ + UINT16 validRouteId = 0u; + UINT8 routeDir = 0u; + UINT8 validRouteDir = 0u; + UINT8 chTrainSum = 0U; + UINT8 funcRet = 0U; + UINT8 logRouteSum = 0U; + LogicTrainResStruct stTmpResInfo[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + LogicTrainResStruct* pstLgcResInfo = NULL; + + /*ȡ·߼Ϣ*/ + logSectionSum = GetLogicalRouteInLogSecSum(logRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId); + routeDir = GetLogicalRouteDir(logRouteId); + + /*ݺϷ*/ + if ((0u != logSectionSum) && (NULL != pLogIdBuff)) + { + for (i = 0u; i < logSectionSum; i++) + { + /**/ + if (LOG_SECTION_LOGLOCK_NORMAL == lockState) + { + SetLogSecLogLockState(pLogIdBuff[i], LOG_SECTION_LOGLOCK_NORMAL, routeDir); + SetLogSecRelateLogRouteData(logRouteId, pLogIdBuff[i]); + } + /*δ*/ + else if (LOG_SECTION_LOGLOCK_NO == lockState) + { + (void)DelLogSecBelongLogRouteId(pLogIdBuff[i], logRouteId); + logRouteSum = GetLogSecLockBelLogRouteSum(pLogIdBuff[i]); + if (0U == logRouteSum) + { + SetLogSecLogLockState(pLogIdBuff[i], LOG_SECTION_LOGLOCK_NO, routeDir); + } + } + /**/ + else if (LOG_SECTION_LOGLOCK_EXCEPT == lockState) + { + SetLogSecLogLockState(pLogIdBuff[i], LOG_SECTION_LOGLOCK_EXCEPT, routeDir); + } + else + { + /**/ + } + } + } + else + { + /**/ + } +} + +/* +* +* ߼·״̬ +* ˵ const UINT16 logRouteId, ·ID +* const UINT8 lockCommand, ״̬ +* ֵ void +*/ +void SetLogRouteProSwLockState(const UINT16 logRouteId, const UINT8 lockCommand) +{ + UINT8 ii = 0u; /**/ + UINT16 protectSwitchId = 0u; /*ID*/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, routeProtectSwitchStru); /*ȡ*/ + + if ((0u != routeProtectSwitchSum) + && ((SWITCH_LOCK_PROTECT_SET == lockCommand) || (SWITCH_LOCK_PROTECT_CANCEL == lockCommand))) + { + + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + protectSwitchId = routeProtectSwitchStru[ii].ProtectSwitchId; + SetSwitchLockStatus(SWITCH_PLOCKTYPE_LOGROUTE, logRouteId, protectSwitchId, lockCommand); /*õ״̬*/ + /*RC 13.0.0 ޣ˫һ*/ +#if 0 + if (SWITCH_TYPE_DOUBLE == GetSwitchType(protectSwitchId)) + { /*˫*/ + SetSwitchLockStatus(SWITCH_PLOCKTYPE_LOGROUTE, logRouteId, GetDSwitchOtherId(protectSwitchId), lockCommand); /*õ״̬*/ + } + else + { + } +#endif + } + } + else + { + ; /*Ϊ0Ϸ*/ + } +} + +/** +* @brief ߼ζӦ߼·ʽʱ +* @param const UINT32 dwCyc ں +* @return +* @noteby cgh 20231013 +*/ +void SetLogSecLogRDelayErrLockCyc(const UINT16 wLogSectionId, const UINT32 dwCyc) +{ + UINT8 chLogSecLockBelLogRouteSum = 0U;/*߼߼·Ŀ*/ + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT8 ii = 0U; + UINT16 wLogSecBelLogRouteId = 0U;/*߼߼·ID*/ + UINT32 dwLogRouteDelayErrLockStartCyc = 0U;/*߼·ʽʱʼں*/ + + chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSectionId); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSectionId); + + if (NULL != szLogSecLockBelLogRouteData) + { + for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++) + { + wLogSecBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId; + dwLogRouteDelayErrLockStartCyc = GetLogRouteDelayErrLockStartCyc(wLogSecBelLogRouteId); + if (0U != dwLogRouteDelayErrLockStartCyc) + { + SetLogRouteDelayErrLockStartCyc(wLogSecBelLogRouteId, dwCyc); + } + else + { + ; /**/ + } + } + } + else + { + ; /**/ + } +} + +/* +* ߼·ü鴦 +* ˵ const UINT16 logRouteId ߼· +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CHECK_SECTION_USE +*/ +UINT8 LogRoutePhySecUseLogicProcess(const UINT16 logRouteId) +{ + /**/ + UINT8 const functionId = EFUNC_LogRoureUsingStateCheck; + + /* ֲʼ */ + UINT8 reResult = CI_ERROR; /*ֵ*/ + UINT8 checkResult = CI_ERROR; /**/ + UINT16 devId = 0u; /*豸ID*/ + UINT8 devState = 0u; /*豸״̬*/ + + /**/ + UINT8 triggerFlag = 0u; + UINT8 sendLevel = ESEND_LEVEL_ATS; /*ATS*/ + + + /* ·ȫ = δá*/ + devId = 0u; + devState = 0u; + checkResult = LogRouteAllSecUseVainCheck(logRouteId, &devId, &devState); + if (checkResult == CI_SUCCESS) + { + /* ͨ */ + reResult = CI_SUCCESS; + } + else + { + /* ¼ */ + SetErrorData(functionId, CI_DEVICE_TYPE_PHYSEC, devId, ETYPE_PS_USE_STATE, devState, sendLevel); + /* ʧܷ */ + reResult = CI_ERROR; + + } + + return reResult; +} + +/* +* ߼·δ״̬ +* ˵ UINT16 const routeId +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteAllSecUseVainCheck(UINT16 const logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + + + UINT8 reVal = CI_ERROR; + + /* ·*/ + UINT8 routeSecSum = 0u;/*·*/ + RoutePhysicalSectionStruct* pRouteSecDataBuf = NULL;/*·*/ + + + UINT8 phyBelongCi = 0u;/**/ + UINT8 commState = 0u;/*ͨ״̬*/ + + UINT16 phySecProtectUseRouteId = 0u; + UINT16 phySecUseRouteId = 0u; + UINT16 phySecUseByLogRouteId = 0u; + + + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT16 wPhySecId = 0U; + /*ȡ·߼Ϣ*/ + logSectionSum = GetLogicalRouteInLogSecSum(logRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId); + + + /* ָռ */ + if ((0u == logSectionSum) || (NULL == pLogIdBuff)) + { + /*ݴָΪ*/ + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + /*ʼ·*/ + for (i = 0u; i < logSectionSum; i++) + { + wPhySecId = GetLgcSecRelativePhySecId(pLogIdBuff[i]); + devId = wPhySecId; + devState = GetPhySecUseState(devId); + + /* 鱾 */ + if (PHYSICAL_SECTION_USING_NO == devState) + { + /* ͨ*/ + + } + else + { + phySecProtectUseRouteId = GetPhySecProtectUseRouteId(devId); + phySecUseRouteId = GetPhySecUseRouteId(devId); + phySecUseByLogRouteId = GetPhySecUseLogRouteId(devId); + if (CI_SUCCESS == reVal) + { + if (0u == phySecProtectUseRouteId) + { + reVal = CI_ERROR;/*ִе˴phySecProtectUseRouteIdΪ0˵󣬵ȫ*/ + } + } + /*ٵǰα··áܰ·*/ + if (CI_SUCCESS == reVal) + { + if ((0u < phySecUseRouteId) || (0u < phySecUseByLogRouteId)) + { + reVal = CI_ERROR; + } + } + /*ڼηʱǰλûλǷ뱾·Ҫλͬ*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckPhysecUseStateInLogRoute(devId, logRouteId); + } + + if (CI_SUCCESS != reVal) + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + break; + } + } + + } + + /*߼·ε*/ + if (CI_SUCCESS == reVal) + { + reVal = CheckProSwUseStateInLogRoute(logRouteId, &devId, &devState); + /*ʧܣ˳*/ + if (CI_SUCCESS != reVal) + { + /*״̬һ·ع״̬*/ + *pDevId = devId; + *pDevState = devState; + + } + } + } + + + return reVal; +} + +/* +*ܣδڽ·ʱε״̬·ҪǷһ +*˵const UINT16 devId ID +* const UINT16 routeId ѾûҪøεĽ· +*ֵ0ʧ +* 1ɹ +*/ +UINT8 CheckPhysecUseStateInLogRoute(const UINT16 devId, const UINT16 logRouteId) +{ + RouteSwitchStruct pRouteSwitchStruct[ROUTE_SWITCH_SUM_MAX] = { 0U }; + UINT8 routeSwitchSum = 0u; + UINT8 reVal = CI_ERROR; + UINT16* pPhySecIncludeSwitch = NULL; + UINT8 phyIncludeSwitchSum = 0u; + UINT8 i = 0u; + UINT16 routeSwitchID = 0u; + UINT8 routeSwitchPos = 0u; + UINT8 j = 0u; + UINT16 phySecIncludeSwitchID = 0u; + UINT8 phySecIncludeSwitchPos = 0u; + UINT8 SwitchExpDrvPos = 0u;/*λ*/ + + routeSwitchSum = GetLogRouteSWData(logRouteId, pRouteSwitchStruct); /*ڰ·ڵĵ*/ + + pPhySecIncludeSwitch = GetPhySecIncludeSwitch(devId);/*ȡΰ*/ + phyIncludeSwitchSum = GetPhyIncludeSwitchSum(devId); + + if ((NULL == pRouteSwitchStruct) || (NULL == pPhySecIncludeSwitch)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + /*εǰλ뱾·ڵλǷͬ*/ + if (CI_SUCCESS == reVal) + { + for (j = 0u; j < phyIncludeSwitchSum; j++) + { + phySecIncludeSwitchID = pPhySecIncludeSwitch[j]; + phySecIncludeSwitchPos = GetSwitchCurPosition(phySecIncludeSwitchID); + /*·ÿһ*/ + for (i = 0u; i < routeSwitchSum; i++)/*ý·ĵ*/ + { + routeSwitchID = pRouteSwitchStruct[i].SwitchId; + routeSwitchPos = pRouteSwitchStruct[i].SwitchPosition; + if (phySecIncludeSwitchID == routeSwitchID) + { + if (phySecIncludeSwitchPos == routeSwitchPos) + { + reVal = CI_SUCCESS; + } + else + {/*õλǷ·Ҫλͬ*/ + SwitchExpDrvPos = GetSwitchPreExpDrvPosition(routeSwitchID); + if ((SWITCH_POSITION_DINGWEI == routeSwitchPos) && (SWITCH_DRIVE_POS_DINGWEI == SwitchExpDrvPos)) + { + reVal = CI_SUCCESS; + } + else if ((SWITCH_POSITION_FANWEI == routeSwitchPos) && (SWITCH_DRIVE_POS_FANWEI == SwitchExpDrvPos)) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + + } + } + /*ʧܺ*/ + if (CI_ERROR == reVal) + { + break; + } + } + /*ʧܺ*/ + if (CI_ERROR == reVal) + { + break; + } + } + + } + return reVal; +} + + + +/* +*ܣ߼·ε +*˵const UINT16 logRouteId ߼· +*UINT16* pDevId , UINT8* pDevState +*ֵ0ʧ +* 1ɹ +*/ +UINT8 CheckProSwUseStateInLogRoute(UINT16 const logRouteId, UINT16* pDevId, UINT8* pDevState) +{ + UINT8 reVal = CI_ERROR; + UINT8 i = 0u; /* ѭ */ + UINT16 devId = 0u; + UINT8 devState = 0u; + /*·*/ + UINT8 routeProSwitchSum = 0u;/*·*/ + RouteProtectSwitchStruct pRouteProSwitchDataBuf[ROUTE_PROTECTSWI_SUM_MAX] = { 0U };/*·*/ + UINT16 phySecProtectUseRouteId = 0u; + UINT16 phySecUseRouteId = 0u; + UINT16 phySecUseByLogRouteId = 0u; + + UINT8 switchCurPosition = 0u; + UINT8 SwitchDrvPos = 0u; + UINT16 proSwitchId = 0u;/*ID*/ + UINT16 proSwitchSecId = 0u;/*ID*/ + UINT8 proSwitchRoutePos = 0u;/*·Ҫķλ*/ + + if ((0U < logRouteId) && (ROUTE_LOGICAL_SUM_MAX > logRouteId) && (NULL != pDevId) && (NULL != pDevState)) + { + /*ȡ·Ϣ*/ + routeProSwitchSum = GetLogRouteProSwData(logRouteId, pRouteProSwitchDataBuf); + if (0U != routeProSwitchSum) + { + /*߼·ε*/ + for (i = 0u; i < routeProSwitchSum; i++) + { + proSwitchId = pRouteProSwitchDataBuf[i].ProtectSwitchId;/*id*/ + proSwitchRoutePos = pRouteProSwitchDataBuf[i].ProtectPosition;/*·Ҫķλ*/ + switchCurPosition = GetSwitchCurPosition(proSwitchId); + proSwitchSecId = GetSwitchPhySectionId(proSwitchId);/*ȡid*/ + devState = GetPhySecUseState(proSwitchSecId); /*ȡ״̬*/ + + /* 鱾 */ + if (PHYSICAL_SECTION_USING_NO == devState) + { + /* ͨ*/ + reVal = CI_SUCCESS; + } + else + { + phySecUseRouteId = GetPhySecUseRouteId(proSwitchSecId); + phySecProtectUseRouteId = GetPhySecProtectUseRouteId(proSwitchSecId); + if ((0u < phySecUseRouteId) || (0u < phySecProtectUseRouteId)) + { + reVal = CI_SUCCESS;/*ִе˴˴뱣ֵ֤һ0*/ + } + else + { + reVal = CI_ERROR; + } + + if (CI_SUCCESS == reVal) + { + /*鵱ǰλûλǷ뱾·Ҫķλͬ*/ + if (proSwitchRoutePos == switchCurPosition) + { + reVal = CI_SUCCESS; + } + else + { + /*õλǷ·Ҫλͬ*/ + SwitchDrvPos = GetSwitchPreExpDrvPosition(proSwitchId); + if ((SWITCH_POSITION_DINGWEI == proSwitchRoutePos) && (SWITCH_DRIVE_POS_DINGWEI == SwitchDrvPos)) + { + reVal = CI_SUCCESS; + } + else if ((SWITCH_POSITION_FANWEI == proSwitchRoutePos) && (SWITCH_DRIVE_POS_FANWEI == SwitchDrvPos)) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + } + + /*ʧܣ˳*/ + if (CI_SUCCESS != reVal) + { + /*״̬һ·ع״̬*/ + *pDevId = proSwitchSecId; + *pDevState = devState; + break; + } + } + } + } + else + { + reVal = CI_SUCCESS; /*޷سɹ*/ + } + } + else + { + /*ηǷʧ*/ + } + + return reVal; +} + +/* +*ܣȡָID߼· +*˵const UINT16 wlogicRouteId ߼·ID +* UINT16 szPhySecId[] ߼·ID飨أ +*ֵ0: ȡʧ +* >0: ȡɹ +* Created By LQ 2023/10/14 +*/ +UINT8 GetLogicRouteIncPhySec(const UINT16 wlogicRouteId, UINT16 szPhySecId[]) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 wRouteIncLogSecNum = 0U; /*߼·߼*/ + UINT16* pRouteIncLogSecId = NULL; /*߼·߼ID*/ + UINT16 wLogSecRelPhySecId = 0U; /*߼ιId*/ + UINT8 cRouteIncPhySecNum = 0U; /*߼·*/ + + if ((0U < wlogicRouteId) && (ROUTE_LOGICAL_SUM_MAX > wlogicRouteId) && (NULL != szPhySecId)) + { + wRouteIncLogSecNum = GetLogicalRouteInLogSecSum(wlogicRouteId); + pRouteIncLogSecId = GetLogicalRouteInLogSecId(wlogicRouteId); + + if ((0U != wRouteIncLogSecNum) && (NULL != pRouteIncLogSecId)) + { + for (ii = 0U; ii < wRouteIncLogSecNum; ii++) + { + wLogSecRelPhySecId = GetLgcSecRelativePhySecId(pRouteIncLogSecId[ii]); /*ȡ߼·*/ + if (0U != wLogSecRelPhySecId) + { + if (0U == cRouteIncPhySecNum) + { + szPhySecId[cRouteIncPhySecNum] = wLogSecRelPhySecId; + cRouteIncPhySecNum++; + } + else + { + for (jj = 0U; jj < cRouteIncPhySecNum; jj++) + { + if (wLogSecRelPhySecId == szPhySecId[jj]) + { + break; /*IDѰֹͣ*/ + } + else + { + /*δظ*/ + } + } + + if (jj == cRouteIncPhySecNum) + { + szPhySecId[cRouteIncPhySecNum] = wLogSecRelPhySecId; /*Ϊ߼·Ӱ*/ + cRouteIncPhySecNum++; + } + else + { + /*IDѰ*/ + } + } + + retVal = cRouteIncPhySecNum; /**/ + } + else + { + retVal = CI_ERROR; /*ȡ߼·ʧܣʧ*/ + } + } + } + else + { + retVal = CI_ERROR; /*ȡ߼·߼ʧܣʧ*/ + } + } + else + { + retVal = CI_ERROR; /*ηǷʧ*/ + } + + return retVal; +} + +/* +*ܣȡָID߼·°(ΰ߼·вż) +*˵const UINT16 wlogicRouteId ߼·ID +* UINT16 szPhySecId[] ߼·°ID飨أ +*ֵ0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetLogicRouteTrainLogIncPhySec(const UINT16 wlogicRouteId, UINT16 szPhySecId[]) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT8 jj = 0U; + UINT16 wRouteIncLogSecNum = 0U; /*߼·°߼*/ + UINT16* pRouteIncLogSecId = NULL; /*߼·°߼ID*/ + UINT16 wLogSecRelPhySecId = 0U; /*߼γ¹Id*/ + UINT8 cRouteIncPhySecNum = 0U; /*߼·°*/ + UINT8 keepWork = CI_ERROR; + + if ((0U < wlogicRouteId) && (ROUTE_LOGICAL_SUM_MAX > wlogicRouteId) && (NULL != szPhySecId)) + { + wRouteIncLogSecNum = GetLogicalRouteTrainLogSecSum(wlogicRouteId); + pRouteIncLogSecId = GetLogicalRouteTrainLogSecId(wlogicRouteId); + + if ((0U != wRouteIncLogSecNum) && (NULL != pRouteIncLogSecId)) + { + for (ii = 0U; ii < wRouteIncLogSecNum; ii++) + { + wLogSecRelPhySecId = GetLgcSecRelativePhySecId(pRouteIncLogSecId[ii]); /*ȡ߼ι*/ + if (0U != wLogSecRelPhySecId) + { + keepWork = CheckPhySecInLogRoute(wlogicRouteId, wLogSecRelPhySecId); /*߼·еβż*/ + if (CI_ERROR != keepWork) + { + if (0U == cRouteIncPhySecNum) + { + szPhySecId[cRouteIncPhySecNum] = wLogSecRelPhySecId; + cRouteIncPhySecNum++; + } + else + { + for (jj = 0U; jj < cRouteIncPhySecNum; jj++) + { + if (wLogSecRelPhySecId == szPhySecId[jj]) + { + break; /*IDѰֹͣ*/ + } + else + { + /*δظ*/ + } + } + + if (jj == cRouteIncPhySecNum) + { + szPhySecId[cRouteIncPhySecNum] = wLogSecRelPhySecId; /*Ϊ߼·Ӱ*/ + cRouteIncPhySecNum++; + } + else + { + /*IDѰ*/ + } + } + + retVal = cRouteIncPhySecNum; /**/ + } + else + { + ; /*DZ߼·Σ*/ + } + } + else + { + retVal = CI_ERROR; /*ȡ߼·ʧܣʧ*/ + } + } + } + else + { + retVal = CI_ERROR; /*ȡ߼·߼ʧܣʧ*/ + } + } + else + { + retVal = CI_ERROR; /*ηǷʧ*/ + } + + return retVal; +} + +/* +*ܣʼ߼·ͬһ·Σڱ·Ҳڵ߼+ͬһ߼Σڱ·߼ +* ˵UINT16 const logRouteId ߼·ID +* ֵ0ʧܣ1ɹ +* ********************************************/ +void LogRouteOutLgcSecConfigDataInit(UINT16 const logRouteId) +{ + UINT16 i = 0U, j = 0U; + UINT8 k = 0U; + UINT8 rtnvalue = CI_ERROR; + + UINT8 szHitSwProLgcSec[LOGIC_SECTION_SUM_MAX] = { 0U };/*߼·߼α־λ¼*/ + UINT8 szHitRouteLgcSec[LOGIC_SECTION_SUM_MAX] = { 0U };/*߼·߼α־λ¼*/ + UINT16 wSwitchId = 0U; + + UINT16 logRouteIndex = 0U; /*߼·*/ + UINT16 logSecBelSwitchSum = 0U; /*߼Ŀ*/ + UINT16* logSecBelSwitchBuf = NULL;/*߼ID*/ + + UINT16 routeInSwitOtherPosLogSecSum = 0U; /*·ڵķǽ·߼*/ + UINT16 routeInSwitOtherPosLogSecIdBuf[MAX_ROUTE_IN_LT_NUM] = { 0U }; /*·ڵķǽ·߼ID*/ + UINT16 routeOutLogSecSum = 0U; /*·ιķǽ·ҷǵ߼ */ + UINT16 routeOutLogSecSumIdBuf[MAX_ROUTE_IN_LT_NUM] = { 0U }; /*·ιķǽ·ҷǵ߼ID */ + + UINT16 routeLogSecSum = 0U; /*·߼Ŀ*/ + UINT16* pRouteLogSecIdBuf = NULL; /*·߼ID*/ + UINT8 routePhySecSum = 0U; /*·Ŀ*/ + UINT16 pRoutePhySecIdBuf[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; /*·ID*/ + + UINT8 routeSwitchSum = 0U; /*·ĵĿ*/ + RouteSwitchStruct pRouteSwitchStruct[ROUTE_SWITCH_SUM_MAX] = {0U}; /*·ĵID*/ + + UINT16* pPhySecIncludeSwitch = NULL; /*ΰĵID*/ + UINT8 chPhyIncludeSwitchSum = 0u; /*ΰĵ*/ + + /*ȡ·߼Ϣ*/ + routeLogSecSum = GetLogicalRouteInLogSecSum(logRouteId); + pRouteLogSecIdBuf =GetLogicalRouteInLogSecId(logRouteId); + /*ȡ·Ϣ*/ + routeSwitchSum = GetLogRouteSWData(logRouteId, pRouteSwitchStruct); + /*ȡ·Ϣ*/ + routePhySecSum = GetLogicRouteIncPhySec(logRouteId, &pRoutePhySecIdBuf); + + + rtnvalue = CI_SUCCESS; + for (i = 0u; i < routeLogSecSum; i++) + { + if (LOGIC_SECTION_SUM_MAX > pRouteLogSecIdBuf[i]) + { + /*Ѹý·߼־λ1*/ + szHitRouteLgcSec[pRouteLogSecIdBuf[i]] = 1U; + } + else + { + rtnvalue = CI_ERROR; + break; + } + } + + if ((CI_SUCCESS == rtnvalue) && (NULL != pRouteSwitchStruct)) + { + routeInSwitOtherPosLogSecSum = 0U; + /*·е*/ + for (i = 0u; i < routeSwitchSum; i++) + { + wSwitchId = pRouteSwitchStruct[i].SwitchId;/*ȡ*/ + + logSecBelSwitchSum = GetSwitchLogSecSum(wSwitchId); + logSecBelSwitchBuf = GetSwitchLogSecBuf(wSwitchId); + + /*߼*/ + for (j = 0U; j < logSecBelSwitchSum; j++) + { + if (LOGIC_SECTION_SUM_MAX > logSecBelSwitchBuf[j]) + { + /*߼βڽ·߼*/ + if (1U != szHitRouteLgcSec[logSecBelSwitchBuf[j]]) + { + routeInSwitOtherPosLogSecIdBuf[routeInSwitOtherPosLogSecSum] = logSecBelSwitchBuf[j]; + routeInSwitOtherPosLogSecSum++; + } + szHitSwProLgcSec[logSecBelSwitchBuf[j]] = 1U; + } + else + { + rtnvalue = CI_ERROR; + break; + } + } + } + } + + if (CI_SUCCESS == rtnvalue) + { + /*߼·*/ + for (k = 0U; k < routePhySecSum; k++) + { + /*ȡΰ*/ + chPhyIncludeSwitchSum = GetPhyIncludeSwitchSum(pRoutePhySecIdBuf[k]); + + /*δڵʱŽж*/ + if(0U logSecBelSwitchBuf[j]) + { + /*߼β߼·߼ Ҳ߼·߼ */ + if ((1U != szHitRouteLgcSec[logSecBelSwitchBuf[j]]) + && (1U != szHitSwProLgcSec[logSecBelSwitchBuf[j]])) + { + /*߼ѱ*/ + routeOutLogSecSumIdBuf[routeOutLogSecSum] = logSecBelSwitchBuf[j]; + routeOutLogSecSum++; + } + } + else + { + rtnvalue = CI_ERROR; + break; + } + } + } + } + } + + /**/ + if (CI_SUCCESS == rtnvalue) + { + logRouteIndex = GetLogRouteBufIndex(logRouteId); + LogicalRouteDataStru[logRouteIndex].routeInSwitOtherPosLogSecSum = routeInSwitOtherPosLogSecSum; + LogicalRouteDataStru[logRouteIndex].routeOutLogSecSum = routeOutLogSecSum; + for (i = 0U; i < routeInSwitOtherPosLogSecSum; i++) + { + LogicalRouteDataStru[logRouteIndex].routeInSwitOtherPosLogSecIdBuf[i] = routeInSwitOtherPosLogSecIdBuf[i]; + } + for (i = 0U; i < routeOutLogSecSum; i++) + { + LogicalRouteDataStru[logRouteIndex].routeOutLogSecSumIdBuf[i] = routeOutLogSecSumIdBuf[i]; + } + } + + +} + + +/* +: ߼· + : const UINT16 routeId ·ID + : const UINT8 DrivFlag ־ +ֵ : +*/ +void LogRouteDrvInnerSwitch(const UINT16 logRouteId, const UINT8 DrivFlag) +{ + UINT8 ii = 0u; + UINT8 jj = 0U; + UINT8 funRtn = 0U; + + UINT16 switchId = 0u; + UINT8 switchExpPos = SWITCH_POSITION_INVALID; /*λ*/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + UINT8 switchSum = 0U; /**/ + RouteSwitchStruct pSwitchData[ROUTE_SWITCH_SUM_MAX] = {0U};/**/ + + /*ȡ·߼Ϣ*/ + + switchSum = GetLogRouteSWData(logRouteId, pSwitchData); + routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, routeProtectSwitchStru); /*ȡ*/ + + if (SWITCH_NEED_DRIV_TRUE == DrivFlag) + {/*Ҫ·ڵ*/ + + for (ii = 0u; ii < switchSum; ii++) + { + + switchId = pSwitchData[ii].SwitchId; + switchExpPos = pSwitchData[ii].SwitchPosition; + funRtn = SwitchDriveProcess(switchId, switchExpPos); /*ý·ڵ״̬Ϊ*/ + + } + + for (ii = 0u; ii < routeProtectSwitchSum; ii++) + { + switchId = routeProtectSwitchStru[ii].ProtectSwitchId; + switchExpPos = routeProtectSwitchStru[ii].ProtectPosition; + funRtn = SwitchDriveProcess(switchId, switchExpPos); /*ý·״̬Ϊ*/ + } + } +} + +/* +* ߼·ڵλȷ +* ˵ const UINT16 wLogRouteId, ·ID +* ֵ UINT8 +* CI_SUCCESS:λȷ +* CI_ERROR:λòȷ +*/ +UINT8 ChekLogRouteSwPosRight(const UINT16 logRouteId) +{ + UINT8 retVal = CI_ERROR; + + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct* pLgcSecSwitchData = NULL; + UINT8 ii = 0u; /*ѭ*/ + UINT8 jj = 0U; + RouteSwitchStruct* pRouteSwitchStru = NULL; /**/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + /* ֲʼ */ + UINT16 i = 0u; /* ѭ */ + UINT16 SwitchId = 0u; + UINT8 SwitchPos = SWITCH_POSITION_INVALID; + UINT8 switchCurPos = SWITCH_POSITION_INVALID; + /*ȡ·߼Ϣ*/ + logSectionSum = GetLogicalRouteInLogSecSum(logRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId); + /*ȡ*/ + routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, routeProtectSwitchStru); + + + if ((0u == logSectionSum) || (NULL == pLogIdBuff)) + { + /*߼Σ󳡾*/ + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if ((NULL != pLgcSecSwitchData) + && (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)) + { + /*ʼ·ڵ*/ + for (i = 0u; i < lgcSecSwitchSum; i++) + { + SwitchId = pLgcSecSwitchData[i].SwitchId; + SwitchPos = pLgcSecSwitchData[i].SwitchPosition; + switchCurPos = GetSwitchCurPosition(SwitchId); + + if ((switchCurPos == SwitchPos) + && ((SWITCH_POSITION_DINGWEI == SwitchPos) + || (SWITCH_POSITION_FANWEI == SwitchPos))) + { + + + } + + else + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + /*ڳʱ*/ + break; + } + } + } + } + } + + if (CI_SUCCESS == retVal) + { + if ((0u == routeProtectSwitchSum)) + { + /*޼*/ + retVal = CI_SUCCESS; + } + else + { + /*ʼ·*/ + for (i = 0u; i < routeProtectSwitchSum; i++) + { + SwitchId = routeProtectSwitchStru[i].ProtectSwitchId; + SwitchPos = routeProtectSwitchStru[i].ProtectPosition; + switchCurPos = GetSwitchCurPosition(SwitchId); + + if ((switchCurPos == SwitchPos) + && ((SWITCH_POSITION_DINGWEI == SwitchPos) + || (SWITCH_POSITION_FANWEI == SwitchPos))) + { + /*λһ*/ + } + + else + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + /*ڳʱ*/ + break; + } + } + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ߼·Ƿеʱ +* ˵ const UINT16 wLogRouteId, ·ID +* ֵ UINT8 +CI_SUCCESS:·޵ʱ +CI_ERROR:·еʱ +*/ +UINT8 ChekLogRouteSwDrvOvTime(const UINT16 logRouteId) +{ + UINT8 retVal = CI_ERROR; + + UINT8 lgcSecSwitchSum = 0U; /*߼ι*/ + LogsecSwitchStruct* pLgcSecSwitchData = NULL; + UINT8 ii = 0u; /*ѭ*/ + RouteSwitchStruct* pRouteSwitchStru = NULL; /**/ + UINT8 routeProtectSwitchSum = 0u; /*Ŀ*/ + RouteProtectSwitchStruct routeProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; /**/ + + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + + UINT16 i = 0u; /* ѭ */ + UINT16 SwitchId = 0u; + UINT8 SwitchPos = SWITCH_POSITION_INVALID; + UINT8 SwitchDrivOvtmDrvPos = SWITCH_DRIVE_POS_INVALID; + + /*ȡ·߼Ϣ*/ + logSectionSum = GetLogicalRouteInLogSecSum(logRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(logRouteId); + /*ȡ*/ + routeProtectSwitchSum = GetLogRouteProSwData(logRouteId, routeProtectSwitchStru); + + + if ((0u == logSectionSum) || (NULL == pLogIdBuff)) + { + /*߼Σ󳡾*/ + retVal = CI_ERROR; + } + else + { + retVal = CI_SUCCESS; + for (ii = 0u; ii < logSectionSum; ii++) + { + lgcSecSwitchSum = GetLogicSecSwitchSum(pLogIdBuff[ii]); + pLgcSecSwitchData = GetLogicSecSwitchIdStru(pLogIdBuff[ii]); + if ((NULL != pLgcSecSwitchData) + && (lgcSecSwitchSum < LOGSEC_INCLUDE_SWITCH_SUM_MAX)) + { + /*ʼ·ڵ*/ + for (i = 0u; i < lgcSecSwitchSum; i++) + { + SwitchId = pLgcSecSwitchData[i].SwitchId; + SwitchPos = pLgcSecSwitchData[i].SwitchPosition; + SwitchDrivOvtmDrvPos = GetSwitchDrivOvtmDrvPosition(SwitchId); + + if (SWITCH_POSITION_DINGWEI == SwitchPos) + { + /*λȷ*/ + if (SWITCH_DRIVE_POS_DINGWEI == SwitchDrivOvtmDrvPos) + { + retVal = CI_ERROR; + } + + } + else if (SWITCH_POSITION_FANWEI == SwitchPos) + { + /*λȷ*/ + if (SWITCH_DRIVE_POS_FANWEI == SwitchDrivOvtmDrvPos) + { + retVal = CI_ERROR; + } + + } + else + { + /*ô*/ + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + /*ڳʱ*/ + break; + } + } + } + } + } + + if (CI_SUCCESS == retVal) + { + if ((0u == routeProtectSwitchSum)) + { + /*޼*/ + retVal = CI_SUCCESS; + } + else + { + /*ʼ·*/ + for (i = 0u; i < routeProtectSwitchSum; i++) + { + SwitchId = routeProtectSwitchStru[i].ProtectSwitchId; + SwitchPos = routeProtectSwitchStru[i].ProtectPosition; + SwitchDrivOvtmDrvPos = GetSwitchDrivOvtmDrvPosition(SwitchId); + + if (SWITCH_POSITION_DINGWEI == SwitchPos) + { + if (SWITCH_DRIVE_POS_DINGWEI == SwitchDrivOvtmDrvPos) + { + retVal = CI_ERROR; + } + + } + else if (SWITCH_POSITION_FANWEI == SwitchPos) + { + if (SWITCH_DRIVE_POS_FANWEI == SwitchDrivOvtmDrvPos) + { + retVal = CI_ERROR; + } + + } + else + { + /*ô*/ + retVal = CI_ERROR; + } + + if (CI_SUCCESS != retVal) + { + /*ڳʱ*/ + break; + } + } + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/** +* @brief ʽ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogSecId ߼ID +* @return +* @noteby cgh 20231020 +*/ +void ErrLockFaultUnLockLogRoute(const UINT16 wLogSecId, const UINT16 wLogRouteId) +{ + UINT8 chLogRouteLogSecHaveUnLock = 0U;/*߼·ڷ߼ǷѾȫ*/ + UINT8 chLogSecLockBelLogRouteSum = 0U;/*߼߼·Ŀ*/ + LogSecLockBelLogRouteStruct szLogSecLockBelLogRouteData[LOGSEC_RELATE_ROUTE_SUM_MAX] = { 0U }; + UINT16 ii = 0U; + UINT16 wLogSecBelLogRouteId = 0U;/*߼߼·ID*/ + + if ((0U < wLogSecId) && (LOGIC_SECTION_SUM_MAX > wLogSecId) && (0U < wLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wLogRouteId)) + { + chLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteBuf(wLogSecId, szLogSecLockBelLogRouteData); + + if (0U != chLogSecLockBelLogRouteSum) + { + for (ii = 0U; ii < chLogSecLockBelLogRouteSum; ii++) + { + wLogSecBelLogRouteId = szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId; + chLogRouteLogSecHaveUnLock = CheckLogRouteLogSecHaveUnLock(wLogSecBelLogRouteId); + chLogRouteLogSecHaveUnLock &= DelLogSecBelongLogRouteId(wLogSecId, wLogSecBelLogRouteId); + + if (CI_SUCCESS == chLogRouteLogSecHaveUnLock) + { + /*߼·Ӧ߼ѾȫöӦ߼·*/ + SetLogRouteStateManage(wLogSecBelLogRouteId, ROUTE_LOGICAL_STATE_IDLE); + } + else + { + ; /**/ + } + } + } + else + { + ; /*ִ*/ + } + } + else + { + ; /**/ + } +} +/** +* @brief ߼·߼߼մ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogSecId ߼ID +* @return CI_SUCCESS߼·߼ճɹ +* CI_ERROR߼·߼ʧ +*/ +UINT8 LogSecLockInLogRouteProcess(const UINT16 wLogRouteId,const UINT16 wLogSecId) +{ + UINT8 funcRet = CI_ERROR; + UINT8 curLogLockState = 0u; /*εǰ߼״̬*/ + UINT8 validLogRouteIdBuf[ROUTE_LOGICAL_SUM_MAX] = { 0U }; /*ҪЧ߼·ID*/ + UINT8 LogSecLockBelLogRouteSum = 0U; + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT8 ii = 0U; + LogSecLockBelLogRouteStruct* szLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + UINT8 validRouteSum = 0U; /*߼·*/ + UINT16 validRouteId = 0u; /*ǰյĽ·*/ + UINT16 LogicalRouteInLogSecSum = 0U; + UINT16* wLogicalRouteInLogSecIdBuf = NULL; + UINT8 oldLogLockState = 0U; + UINT8 retValue = CI_ERROR; + UINT8 wLogrouteDir = 0u; + + curLogLockState = GetLogSecLogLockState(wLogSecId); + LogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSecId); + szLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSecId); + wLogrouteDir = GetLogicalRouteDir(wLogRouteId); + if ((0U < LogSecLockBelLogRouteSum) && (NULL != szLogSecLockBelLogRouteData)) + { + funcRet = CI_SUCCESS; + if (LOG_SECTION_LOGLOCK_NORMAL == curLogLockState) + { + for (jj = 0U; jj < LogSecLockBelLogRouteSum; jj++) + { + if (wLogRouteId != szLogSecLockBelLogRouteData[jj].wLogSecLockBelLogRouteId) + { + validRouteId = szLogSecLockBelLogRouteData[jj].wLogSecLockBelLogRouteId; + /*Ϊǰ߼·շгԴά*/ + SetLogSecLogLockState(wLogSecId, LOG_SECTION_LOGLOCK_NORMAL, wLogrouteDir); + /*߼յ·*/ + funcRet = DelLogSecBelongLogRouteId(wLogSecId, validRouteId); + + if (CI_SUCCESS == funcRet) + { + for (kk = 0U; kk < validRouteSum; kk++) + { + if (validRouteId == validLogRouteIdBuf[kk]) + { + /*ȥ*/ + break; + } + } + if (validRouteSum == kk) + { + /*δظ*/ + if (ROUTE_LOGICAL_SUM_MAX > validRouteSum) + { + validLogRouteIdBuf[validRouteSum++] = (UINT8)validRouteId; + } + else + { + funcRet = CI_ERROR; /*߼·ޣʧܴ*/ + } + } + } + else + { + ; /*Ƿʧ*/ + } + } + + if (CI_ERROR == funcRet) + { + break; + } + } + + if (CI_SUCCESS == funcRet) + { + /*߼·*/ + for (ii = 0U; ii < validRouteSum; ii++) + { + if ((0U < validLogRouteIdBuf[ii]) && (wLogRouteId != validLogRouteIdBuf[ii])) + { + LogicalRouteInLogSecSum = GetLogicalRouteInLogSecSum(validLogRouteIdBuf[ii]); + wLogicalRouteInLogSecIdBuf = GetLogicalRouteInLogSecId(validLogRouteIdBuf[ii]); + + for (kk = 0U; kk < LogicalRouteInLogSecSum; kk++) + { + oldLogLockState = GetLogSecLogLockState(wLogicalRouteInLogSecIdBuf[kk]); + retValue = CheckLgcSecHaveTrainLocRoute(wLogRouteId, wLogicalRouteInLogSecIdBuf[kk]); + if ((LOG_SECTION_LOGLOCK_NO != oldLogLockState) && (CI_ERROR == retValue)) + { + break; /*·л߼Ҳdzµ߼(Ѿµ߼·)Խ˽·ΪУҪͷ*/ + } + } + + if (kk == LogicalRouteInLogSecSum) + { + /*߼·߼ζδգѾ߼·һ߼Σø߼·Уĵȳͷ*/ + (void)SetLogicalRouteState(validLogRouteIdBuf[ii], ROUTE_LOGICAL_STATE_IDLE); + } + } + } + } + } + } + else + { + ; /*ݲϷʧ*/ + } + + return funcRet; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Route/LogicalRouteDataManage.h b/TSCP/src/APP/ciapp/Route/LogicalRouteDataManage.h new file mode 100644 index 0000000..8addcd1 --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/LogicalRouteDataManage.h @@ -0,0 +1,799 @@ +/******************************************************** +* +* LogicalRouteDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2023-10-10 +* ߣ +* ߼·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* by cgh 20231010 +* +********************************************************/ + +#ifndef _LOGICAL_ROUTE_DATA_MANAGE_H_ +#define _LOGICAL_ROUTE_DATA_MANAGE_H_ + + +#include "CommonTypes.h" +#include "RouteDefine.h" +#include "SectionDefine.h" +#include "LogicSectionConfigDataManage.h" +#include "RouteConfigDataManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*߼·ݽṹ*/ +typedef struct S_LogicalRouteDataStruct +{ + UINT16 wLogRouteId; /*߼·ID */ + UINT8 chLogRouteDir; /*߼·Ӫ */ + UINT8 chLogicRouteState; /*߼·״̬*/ + UINT8 chLogRouteLevel; /*߼·ල(ʽ/CBTC) (ֶ̬)*/ + UINT8 chLogRouteBelongCiId; /*߼·*/ + UINT8 chLogicRouteOpenColor; /*߼·ɫ*/ + UINT16 wLogRouteInLogSecSum; /*߼·߼*/ + UINT16 szLogRouteInLogSecIdBuf[MAX_ROUTE_IN_LT_NUM]; /*߼·߼ID*/ + UINT8 chLogRouteSwitchMoveFlag; /*߼·Ƿɶ־*/ + UINT16 wLogRouteTrainLogSecSum; /*߼·г߼*/ + UINT16 szLogRouteTrainLogSecIdBuf[MAX_ROUTE_IN_LT_NUM]; /*߼·г߼ID*/ + UINT16 wLogRouteRelateBeginSigId; /*߼·ʼźŻID*/ + UINT32 dwLogRouteChuXuanStartCycNum; /*߼·ѡʼں*/ + UINT32 dwLogRouteXuanPaiStartCycNum; /*߼·ѡʼں*/ + UINT32 dwLogRouteLockStartCycNum; /*߼·ʼں*/ + UINT32 dwDelayErrLockStartCycNum; /*ʽʱʼں*/ + UINT8 chLogRouteRecoverOpenState; /*߼·źؿ־*/ + UINT16 szLogRouteApplyResTrainId; /*߼·ATSԴгID*/ + UINT8 chLogRouteRelatePsdSum; /*߼·*/ + UINT16 szLogRouteRelatePsdIdBuf[ROUTE_PSD_SUM_MAX]; /*߼·ID*/ + UINT8 chLogRouteRelateEsbSum; /*߼·ͣť*/ + UINT16 szLogRouteRelateEsbIdBuf[ROUTE_ESB_SUM_MAX]; /*߼·ͣťID*/ + + UINT16 routeInSwitOtherPosLogSecSum; /*·ڵķǽ·߼*/ + UINT16 routeInSwitOtherPosLogSecIdBuf[MAX_ROUTE_IN_LT_NUM]; /*·ڵķǽ·߼ID*/ + UINT16 routeOutLogSecSum; /*·ιķǽ·ҷǵ߼ */ + UINT16 routeOutLogSecSumIdBuf[MAX_ROUTE_IN_LT_NUM]; /*·ιķǽ·ҷǵ߼ID */ + +} LogicalRouteDataStruct; + +/*******************************ȫֱ*******************************/ +extern LogicalRouteDataStruct LogicalRouteDataStru[ROUTE_LOGICAL_SUM_MAX]; +extern UINT16 LogicalRouteSum; +extern UINT16 LogicalRouteIdBuff[ROUTE_LOGICAL_SUM_MAX]; + +/** +* @brief ߼·״̬ +* @param +* @return +* @note +*/ +void LogicalRouteProcess(void); + +/** +* @brief ʼ߼· +* @param +* @return ߼· +* @noteby cgh 20231010 +*/ +void InitialLogicalRouteData(void); + +/** +* @brief ߼·ݳʼ +* @param const UINT16 wIndex ߼· +* @return ߼· +* @noteby cgh 20231012 +*/ +void LogicalRouteDataInitial(const UINT16 wIndex); + +/** +* @brief ȡ߼· +* @param +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT16 GetLogicalRouteSum(void); + +/** +* @brief ȡ߼·ṹ +* @param +* @return ߼·ṹ +* @noteby lq 20231016 +*/ +LogicalRouteDataStruct* GetLogicalRouteStr(void); + +/** +* @brief ȡ߼·ID +* @param const UINT16 wIndex ߼· +* @return ߼·ID +* @noteby cgh 20231010 +*/ +UINT16 GetLogicalRouteId(const UINT16 wIndex); + +/** +* @brief ȡ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT16 GetLogRouteBufIndex(const UINT16 wLogRouteId); + +/** +* @brief ȡС߼·IDС״̬У +* @param +* @return ߼·ID +* @noteby cgh 20231011 +*/ +UINT16 GetUsableLogicalRouteId(void); + +/** +* @brief ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteDir ߼· +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteDir(const UINT16 wLogRouteId, const UINT8 chLogRouteDir); + +/** +* @brief ȡ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteDir(const UINT16 wLogRouteId); + +/** +* @brief ߼·״̬ù߼·״̬ñͨ +* @param const UINT16 wLogRouteId, ߼·ID const UINT8 chLogRouteState ߼·״̬ +* @return CI_ERROR + CI_SUCCESS +* @noteby cgh 20231012 +*/ +void SetLogRouteStateManage(const UINT16 wLogRouteId, const UINT8 chLogRouteState); + +/** +* @brief ߼·״̬ЧԼ +* @param const UINT8 chLogRouteState ߼·״̬ +* @return CI_ERROR: Ч CI_SUCCESS: Ч +* @noteby cgh 20231010 +*/ +UINT8 LogRouteStateValidCheck(const UINT8 chLogRouteState); + + + +/** +* @brief ߼·״̬ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogicRouteState ߼·״̬ +* @return CI_ERROR ʧ +* CI_SUCCESS óɹ +* @noteby cgh 20231010 +*/ +UINT8 SetLogicalRouteState(const UINT16 wLogRouteId, const UINT8 chLogicRouteState); + +/* +* ߼·֮ǰռ״̬ +* ˵ const UINT16 wLogRouteId, ߼·ID +* ֵ CI_ERROR:ʧ +* CI_SUCCESS:ɹ +*/ +void CleanLogRoutePhySecPreOccuSta(const UINT16 wLogRouteId); + +/** +* @brief ȡ߼·״̬ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·״̬ +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteState(const UINT16 wLogRouteId); + +/** +* @brief ߼·ල +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteLevel ߼·ල +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteLevel(const UINT16 wLogRouteId, const UINT8 chLogRouteLevel); + +/** +* @brief ȡ߼·ල +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteLevel(const UINT16 wLogRouteId); + +/** +* @brief ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteBelongCiId ߼· +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteBelongCiId(const UINT16 wLogRouteId, const UINT8 chLogRouteBelongCiId); + +/** +* @brief ȡ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteBelongCiId(const UINT16 wLogRouteId); + +/** +* @brief ߼·ɫ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteDir ߼·ɫ +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteOpenColor(const UINT16 wLogRouteId, const UINT8 chLogRouteOpenColor); + +/** +* @brief ȡ߼·ɫ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231011 +*/ +UINT8 GetLogicalRouteOpenColor(const UINT16 wLogRouteId); + +/** +* @brief ߼·߼ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteInLogSecSum ߼·߼Ŀ +* @param const UINT16* wLogRouteInLogSecIdbuf ߼·߼ID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteInLogSecData(const UINT16 wLogRouteId, const UINT8 wLogRouteInLogSecSum, const UINT16* wLogRouteInLogSecIdbuf); + +/** +* @brief ȡ߼·߼ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteInLogSecSum(const UINT16 wLogRouteId); + +/** +* @brief ȡ߼·߼ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteInLogSecId(const UINT16 wLogRouteId); + +/** +* @brief ȡ·ڵķǽ·߼ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ +* @noteby cgh 20231011 +*/ +UINT16 GetLogRInSwitOtherPosLogSecSum(const UINT16 wLogRouteId); + +/** +* @brief ȡ·ڵķǽ·߼ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogRInSwitOtherPosLogSecID(const UINT16 wLogRouteId); +/** +* @brief ȡ·ιķǽ·ҷǵ߼ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteOutLogSecSum(const UINT16 wLogRouteId); + + +/** +* @brief ȡ·ιķǽ·ҷǵ߼ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·߼ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteOutLogSecID(const UINT16 wLogRouteId); +/** +* @brief ߼·Ƿɶ־ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteLevel ߼·Ƿɶ־ +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteSwitchMoveFlag(const UINT16 wLogRouteId, const UINT8 chLogRouteSwitchMoveFlag); + +/** +* @brief ȡ߼·Ƿɶ־ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·Ƿɶ־ +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteSwitchMoveFlag(const UINT16 wLogRouteId); + +/** +* @brief ߼·гµ߼ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteTrainLogSecSum ߼·гµ߼Ŀ +* @param const UINT16 wLogRouteTrainLogSecId ߼·гµ߼ID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteTrainLogSecData(const UINT16 wLogRouteId, const UINT16 wLogRouteTrainLogSecSum, const UINT16* wLogRouteTrainLogSecId); + +/** +* @brief ȡ߼·гµ߼ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·гµ߼ +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteTrainLogSecSum(const UINT16 wLogRouteId); + +/** +* @brief ȡ߼·гµ߼ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·гµ߼ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteTrainLogSecId(const UINT16 wLogRouteId); + +/** +* @brief ߼·ʼźŻID +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteRelateBeginSigId ߼·ʼźŻID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteRelateBeginSigId(const UINT16 wLogRouteId, const UINT16 wLogRouteRelateBeginSigId); + +/** +* @brief ȡ߼·ʼźŻID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ʼźŻID +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteRelateBeginSigId(const UINT16 wLogRouteId); + +/** +* @brief ߼·ѡʼں +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 dwCyc ߼·ѡʼں +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteChuXuanStartCycNum(const UINT16 wLogRouteId, const UINT32 dwCyc); + +/** +* @brief ȡ߼·ѡʼں +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ѡʼں +* @noteby cgh 20231011 +*/ +UINT32 GetLogRouteChuXuanStartCycNum(const UINT16 wLogRouteId); + +/** +* @brief ߼·ѡʼں +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 dwCyc ߼·ѡʼں +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteXuanPaiStartCycNum(const UINT16 wLogRouteId, const UINT32 dwCyc); + +/** +* @brief ȡ߼·ѡʼں +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ѡʼں +* @noteby cgh 20231011 +*/ +UINT32 GetLogRouteXuanPaiStartCycNum(const UINT16 wLogRouteId); + +/** +* @brief ߼·ʼں +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 dwCyc ߼·ʼں +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteLockStartCycNum(const UINT16 wLogRouteId, const UINT32 dwCyc); + +/** +* @brief ȡ߼·ʼں +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ʼں +* @noteby cgh 20231011 +*/ +UINT32 GetLogRouteLockStartCycNum(const UINT16 wLogRouteId); + +/** +* @brief ߼·ʽʱʼں +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 dwCyc ߼·ʽʱʼں +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteDelayErrLockStartCyc(const UINT16 wLogRouteId, const UINT32 dwCyc); + +/** +* @brief ȡ߼·ʽʱʼں +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ʽʱʼں +* @noteby cgh 20231011 +*/ +UINT32 GetLogRouteDelayErrLockStartCyc(const UINT16 wLogRouteId); + +/** +* @brief ߼·źؿ־ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT8 chLogRouteRecoverOpenState ߼·źؿ־ +* @return +* @noteby cgh 20231010 +*/ +void SetLogicalRouteRecoverOpenState(const UINT16 wLogRouteId, const UINT8 chLogRouteRecoverOpenState); + +/** +* @brief ȡ߼·źؿ־ +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·źؿ־ +* @noteby cgh 20231010 +*/ +UINT8 GetLogicalRouteRecoverOpenState(const UINT16 wLogRouteId); + +/** +* @brief ߼·ATSԴг +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteApplyResTrainId ߼·ATSԴгID +* @return +* @noteby cgh 20231011 +*/ +void SetLogRouteApplyResTrainData(const UINT16 wLogRouteId, const UINT16 wLogRouteApplyResTrainId); + +/** +* @brief ȡ߼·ATSԴгID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ATSԴгID +* @noteby cgh 20231011 +*/ +UINT16 GetLogicalRouteApplyResTrainId(const UINT16 wLogRouteId); + +/** +* @brief ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteRelatePsdId ߼·ID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteRelatePsdIdData(const UINT16 wLogRouteId, const UINT16 wLogRouteRelatePsdId); + +/** +* @brief ȡ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼· +* @noteby cgh 20231011 +*/ +UINT8 GetLogicalRouteeRelatePsdSum(const UINT16 wLogRouteId); + +/** +* @brief ȡ߼·ID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteRelatePsdId(const UINT16 wLogRouteId); + +/** +* @brief ߼·ͣť +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteRelateEsbId ߼·ͣťID +* @return +* @noteby cgh 20231011 +*/ +void SetLogicalRouteRelateEsbIdData(const UINT16 wLogRouteId, const UINT16 wLogRouteRelateEsbId); + +/** +* @brief ȡ߼·ͣť +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ͣť +* @noteby cgh 20231011 +*/ +UINT8 GetLogicalRouteeRelateEsbSum(const UINT16 wLogRouteId); + +/** +* @brief ȡ߼·ͣťID +* @param const UINT16 wLogRouteId ߼·ID +* @return ߼·ͣťID +* @noteby cgh 20231011 +*/ +UINT16* GetLogicalRouteRelateEsbId(const UINT16 wLogRouteId); + +/** +* @brief ߼ѡ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteFirstXuanPaiProc(const UINT16 wLogRouteId); + +/** +* @brief ߼·ѡŴ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteXuanPaiProc(const UINT16 wLogRouteId); + +/** +* @brief ߼·մ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteLockProc(const UINT16 wLogRouteId); + +/** +* @brief ߼·쳣մ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteLockErrManage(const UINT16 wLogRouteId); + +/* +* ߼·г״̬ +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetLogRouteTrainLocLogSecState(const UINT16 wLogRouteId, const UINT8 lockState); + +/* +* ߼·г״̬, Ҫִ߼մ +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetLogRouteTrainLocPhySecState(const UINT16 wLogRouteId, const UINT8 lockState); + +/* +* ߼·ڵ״̬ +* ˵ const UINT16 logRouteId, ·ID +* const UINT8 useState, ״̬ +* ֵ +* LC +*/ +void SetLogRouteSectionUsingState(const UINT16 logRouteId, const UINT8 useState); + +/* +* ߼·߼Դ +* ˵ const UINT16 routeId, ·ID +* ֵ void +* fan 2023-10-11 +*/ +void LogRouteLgcSecResUnlockManage(const UINT16 logRouteId); + +/* +* ߼ε߼· +* ˵ const UINT16 logSecId, ߼ID +const UINT16 preLogSecId, һ߼ID +const UINT16 logRouteId, ߼·ID +* ֵ CI_SUCCESSͨ CI_ERRORʧ +* fan 2023-10-11 +*/ +UINT8 CheckLogRouteLgcSecResUnlock(const UINT16 logSecId, const UINT16 preLogSecId, const UINT16 logRouteId); + +/* +* ߼ε߼· +* ˵ const UINT16 logRouteId, ߼·ID +const UINT16 logSectionId ߼ID +const UINT16 preLogSecId һ߼ID +* ֵ void +* fan 20231012 +*/ +void LgcSecLogicalUnlockProc(const UINT16 logRouteId, const UINT16 logSectionId, const UINT16 preLogSecId); + +/** +* @brief ߼·źſŴ +* @param wLogRouteId ߼·ID +* @return +* @note +*/ +void LogRouteOpenManage(const UINT16 wLogRouteId); + +/* +* ָID߼·гԴǷ߼ +* ˵ const UINT16 routeId, ·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: гԴ +* CI_ERROR: гԴ +*/ +UINT8 CheckLgcSecHaveTrainLocRoute(const UINT16 logRouteId, const UINT16 lgcSecId); + +/* +* ȷָID߼·ʼźŻɫ +* ˵ const UINT16 routeId, ·ID +* ֵ +* Created By LQ 2023/10/11 +*/ +void LogicRouteOpenColorProc(const UINT16 logRouteId); + +/** +* @brief ߼·ʽʱ +* @param const UINT16 wLogicalRouteId ߼·ID +* @return +* @noteby cgh 20231012 +*/ +void LogRouteUnlockDelayManage(const UINT16 wLogicalRouteId); + +/* +: ߼· +: const UINT16 logRouteId ·ID +: +ֵ: CI_SUCCESS,մɹ + CI_ERROR,մʧ +*/ +UINT8 LogRouteLockDriveSwitch(const UINT16 logRouteId); + +/* +* ȡ߼·߼ηϢ +* ˵ const UINT16 logRouteId, ·ID +* OUT RouteProtectSwitchStruct szRouteProtectSwitchStruct[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetLogRouteProSwData(const UINT16 logRouteId, OUT RouteProtectSwitchStruct szRouteProSwitchStruct[ROUTE_PROTECTSWI_SUM_MAX]); + +/* +* ȡ߼·ڵϢ +* ˵ const UINT16 logRouteId, ·ID +* OUT RouteProtectSwitchStruct szRouteProtectSwitchStruct[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetLogRouteSWData(const UINT16 logRouteId, OUT RouteSwitchStruct szRouteSwitchStruct[ROUTE_SWITCH_SUM_MAX]); + +/* +* ߼·߼״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockState, ״̬ +* ֵ void +*/ +void SetLogRouteSecLockState(const UINT16 logRouteId, const UINT8 lockState); + +/* +* ߼·״̬ +* ˵ const UINT16 logRouteId, ·ID +* const UINT8 lockCommand, ״̬ +* ֵ void +*/ +void SetLogRouteProSwLockState(const UINT16 logRouteId, const UINT8 lockCommand); + +/** +* @brief ߼ζӦ߼·ʽʱ +* @param const UINT32 dwCyc ں +* @return +* @noteby cgh 20231013 +*/ +void SetLogSecLogRDelayErrLockCyc(const UINT16 wLogSectionId, const UINT32 dwCyc); + +/* +* ߼·ü鴦 +* ˵ const UINT16 logRouteId ߼· +* ֵ CI_ERROR +* CI_SUCCESS +* ϱ룺 EFUNC_CHECK_SECTION_USE +*/ +UINT8 LogRoutePhySecUseLogicProcess(const UINT16 logRouteId); + +/* +* ߼·δ״̬ +* ˵ UINT16 const routeId +* UINT16 *pDevId, 豸Idأ +* UINT8 *pDevState, 豸״̬أ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 LogRouteAllSecUseVainCheck(UINT16 const logRouteId, UINT16* pDevId, UINT8* pDevState); + +/* +*ܣδڽ·ʱε״̬·ҪǷһ +*˵const UINT16 devId ID +* const UINT16 routeId ѾûҪøεĽ· +*ֵ0ʧ +* 1ɹ +*/ +UINT8 CheckPhysecUseStateInLogRoute(const UINT16 devId, const UINT16 logRouteId); + +/* +*ܣ߼·ε +*˵const UINT16 logRouteId ߼· +*UINT16* pDevId , UINT8* pDevState +*ֵ0ʧ +* 1ɹ +*/ +UINT8 CheckProSwUseStateInLogRoute(UINT16 const logRouteId, UINT16* pDevId, UINT8* pDevState); + +/* +*ܣȡָID߼· +*˵const UINT16 wlogicRouteId ߼·ID +* UINT16 szPhySecId[] ߼·ID飨أ +*ֵ0: ȡʧ +* >0: ȡɹ +* Created By LQ 2023/10/14 +*/ +UINT8 GetLogicRouteIncPhySec(const UINT16 wlogicRouteId, UINT16 szPhySecId[]); + +/* +*ܣȡָID߼·°(ΰ߼·вż) +*˵const UINT16 wlogicRouteId ߼·ID +* UINT16 szPhySecId[] ߼·°ID飨أ +*ֵ0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetLogicRouteTrainLogIncPhySec(const UINT16 wlogicRouteId, UINT16 szPhySecId[]); + + +/* +*ܣʼ߼·ͬһ·Σڱ·Ҳڵ߼+ͬһ߼Σڱ·߼ +* ˵UINT16 const logRouteId ߼·ID +* ֵ0ʧܣ1ɹ +* ********************************************/ +void LogRouteOutLgcSecConfigDataInit(UINT16 const logRouteId); + +/* +: ߼· + : const UINT16 routeId ·ID + : const UINT8 DrivFlag ־ +ֵ : +*/ +void LogRouteDrvInnerSwitch(const UINT16 logRouteId, const UINT8 DrivFlag); + +/* +* ߼·ڵλȷ +* ˵ const UINT16 logRouteId, ·ID +* ֵ UINT8 +* CI_SUCCESS:λȷ +* CI_ERROR:λòȷ +*/ +UINT8 ChekLogRouteSwPosRight(const UINT16 logRouteId); + +/* +* ߼·Ƿеʱ +* ˵ const UINT16 logRouteId, ·ID +* ֵ UINT8 +CI_SUCCESS:·޵ʱ +CI_ERROR:·еʱ +*/ +UINT8 ChekLogRouteSwDrvOvTime(const UINT16 logRouteId); + +/** +* @brief ʽ߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogSecId ߼ID +* @return +* @noteby cgh 20231020 +*/ +void ErrLockFaultUnLockLogRoute(const UINT16 wLogSecId, const UINT16 wLogRouteId); + +/** +* @brief ߼·߼߼մ +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogSecId ߼ID +* @return CI_SUCCESS߼·߼ճɹ +* CI_ERROR߼·߼ʧ +*/ +UINT8 LogSecLockInLogRouteProcess(const UINT16 wLogRouteId, const UINT16 wLogSecId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Route/LongRouteConfigDataManage.c b/TSCP/src/APP/ciapp/Route/LongRouteConfigDataManage.c new file mode 100644 index 0000000..20c7e1a --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/LongRouteConfigDataManage.c @@ -0,0 +1,221 @@ +/******************************************************** +* +* LongRouteConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "LongRouteConfigDataManage.h" + + + +LongRouteConfigDataStruct LongRouteConfigDataStru[ROUTE_LONG_SUM_MAX]; /*峤·ݽṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +INT16 LongRouteCurSum = 0; /*·ǰ*/ +UINT16 LocalCiLongRouteIdBuf[ROUTE_LONG_SUM_MAX] = {0u}; /*屾·IDӳ*/ + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_LONG_SUM_MAX: ȡʧ +* = 1u) && (routeId < ROUTE_LONG_SUM_MAX)) + { + retVal = routeId; + } + + return retVal; +} + +/* +* ȡ·ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ·ǰ +*/ +UINT16 GetLongRouteCurSum(void) +{ + UINT16 retVal = 0u; + if (LongRouteCurSum >= (INT16)ROUTE_LONG_SUM_MAX ) + { + retVal = ROUTE_LONG_SUM_MAX; + } + else if (LongRouteCurSum < 0) + { + retVal = 0u; + } + else + { + retVal = (UINT16)LongRouteCurSum; + } + return retVal; +} + + +/* +* ȡָ±ӦĽ·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetLongRouteId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 curLongRouteSum = 0u; + curLongRouteSum = GetLongRouteCurSum(); + + if ((ROUTE_LONG_SUM_MAX > bufIndex ) && (bufIndex <= curLongRouteSum)) + { + retVal = LocalCiLongRouteIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡ· +* ˵ +* ֵ LongRouteConfigDataStruct* +*/ +LongRouteConfigDataStruct *GetLongRouteConfigData(void) +{ + return LongRouteConfigDataStru; +} + + +/* +* ȡָID·ӽ·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetLongRouteSubRouteSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetLongRouteConfigBufIndex(routeId); /*ȡ±*/ + + if (bufIndex < ROUTE_LONG_SUM_MAX) + { + retVal = LongRouteConfigDataStru[bufIndex].SubRouteSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ӽ·ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +UINT16* GetLongRouteSubRouteIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetLongRouteConfigBufIndex(routeId); /*ȡ±*/ + + if (bufIndex < ROUTE_LONG_SUM_MAX) + { + retVal = LongRouteConfigDataStru[bufIndex].SubRouteIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID·һ·Id +* ˵ const UINT16 routeId, ·ID +* ֵ UINT16 ·Id +*/ +UINT16 GetLongRouteLastRouteId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 subRouteSum = 0u; + UINT16 retVal = 0u; + + bufIndex = GetLongRouteConfigBufIndex(routeId); /*ȡ±*/ + + if (bufIndex < ROUTE_LONG_SUM_MAX) + { + subRouteSum = LongRouteConfigDataStru[bufIndex].SubRouteSum; + if ((subRouteSum > 0u) && (subRouteSum <= ROUTE_SUBROUTE_SUM_MAX)) + { + /*һ·ID Զ˽·ʼ*/ + retVal = LongRouteConfigDataStru[bufIndex].SubRouteIdBuf[0]; + } + else + { + retVal = 0u; + } + } + else + { + retVal = 0u; + } + return retVal; +} + +/* +* ij· +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 LongRouteConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 longRouteConfigDataSum = 0u; /*·豸*/ + UINT8 retVal = CI_SUCCESS; + UINT8 chRouteBelongCi = 0U; + UINT8 chLocalCi = GetSystemParaLocalCiId(); + /*·ID*/ + longRouteConfigDataSum = GetLongRouteCurSum(); + if (longRouteConfigDataSum >= ROUTE_LONG_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < ROUTE_LONG_SUM_MAX; ii++) + { + if (jj == longRouteConfigDataSum) + {/*Ч*/ + + break; + } + chRouteBelongCi = GetRouteBelongCiId(LongRouteConfigDataStru[ii].SubRouteIdBuf[0]); + if(chLocalCi == chRouteBelongCi) + { + LocalCiLongRouteIdBuf[jj] = LongRouteConfigDataStru[ii].LongRouteId; + jj++; + } + + } + } + + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Route/LongRouteConfigDataManage.h b/TSCP/src/APP/ciapp/Route/LongRouteConfigDataManage.h new file mode 100644 index 0000000..d51b239 --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/LongRouteConfigDataManage.h @@ -0,0 +1,108 @@ +/******************************************************** +* +* LongRouteConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _LONG_ROUTE_CONFIG_DATA_MANAGE_H_ +#define _LONG_ROUTE_CONFIG_DATA_MANAGE_H_ + + +#include "CommonTypes.h" +#include "RouteDefine.h" +#include "../System/CiSystemDefine.h" +#include "RouteConfigDataManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*·ݽṹ*/ +typedef struct S_LongRouteConfigDataStruct +{ + UINT16 LongRouteId; /*·ID (ֶ)*/ + UINT8 SubRouteSum; /*·ӽ·Ŀ (ֶ)*/ + UINT16 SubRouteIdBuf[ROUTE_SUBROUTE_SUM_MAX]; /*·ӽ·ID (ֶ)*/ +} LongRouteConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern LongRouteConfigDataStruct LongRouteConfigDataStru[ROUTE_LONG_SUM_MAX]; /*峤·ݽṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern INT16 LongRouteCurSum; /*·ǰ*/ +extern UINT16 LocalCiLongRouteIdBuf[ROUTE_LONG_SUM_MAX]; /*屾·IDӳ*/ + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_SUM_MAX: ȡʧ +* 0: ·ǰ +*/ +UINT16 GetLongRouteCurSum(void); + +/* +* ȡָ±ӦĽ·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetLongRouteId(const UINT16 bufIndex); + +/* +* ȡ· +* ˵ +* ֵ LongRouteConfigDataStruct* +*/ +LongRouteConfigDataStruct *GetLongRouteConfigData(void); + +/* +* ȡָID·ӽ·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetLongRouteSubRouteSum(const UINT16 routeId); + + +/* +* ȡָID·ӽ·ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +UINT16* GetLongRouteSubRouteIdBuf(const UINT16 routeId); + +/* +* ȡָID·һ·Id +* ˵ const UINT16 routeId, ·ID +* ֵ UINT16 ·Id +*/ +UINT16 GetLongRouteLastRouteId(const UINT16 routeId); +/* +* ij· +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 LongRouteConfigDataManage(void); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Route/LongRouteDataManage.c b/TSCP/src/APP/ciapp/Route/LongRouteDataManage.c new file mode 100644 index 0000000..c9e9fd1 --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/LongRouteDataManage.c @@ -0,0 +1,120 @@ +/******************************************************** +* +* LongRouteDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "LongRouteDataManage.h" + + +LongRouteDataStruct LongRouteDataStru[ROUTE_LONG_SUM_MAX]; /*峤·ݽṹ*/ + + + + + + +/* +* ȡָID·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT8 GetLongRouteState(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetLongRouteConfigBufIndex(routeId); /*ȡ±*/ + + if (bufIndex < ROUTE_LONG_SUM_MAX) + { + retVal = LongRouteDataStru[bufIndex].LongRouteState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 routeState, ·״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetLongRouteState(const UINT16 routeId, const UINT8 routeState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetLongRouteConfigBufIndex(routeId); /*ȡ±*/ + + if (bufIndex >= ROUTE_LONG_SUM_MAX) + { + retVal = CI_ERROR; + } + + if(CI_SUCCESS == retVal) + { + if (ROUTE_LONG_STATE_IDLE ==routeState) + { /**/ + + LongRouteDataStru[bufIndex].LongXuanPaiStartCycNum = 0u; /*·ѡʼ*/ + } + else if (ROUTE_LONG_STATE_XUANPAI ==routeState) + { /*ѡ*/ + + LongRouteDataStru[bufIndex].LongXuanPaiStartCycNum = Get2oo2CurCycleNum(); /*ý·ѡʼ*/ + } + else if (ROUTE_LONG_STATE_LOCK ==routeState) + { /**/ + + } + else + { + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + LongRouteDataStru[bufIndex].LongRouteState = routeState; /*·״̬*/ + } + + return retVal; +} + + +/* +* ȡָID·ѡʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetLongRouteXuanPaiStartCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetLongRouteConfigBufIndex(routeId); /*ȡ±*/ + + if (bufIndex < ROUTE_LONG_SUM_MAX) + { + retVal = LongRouteDataStru[bufIndex].LongXuanPaiStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + diff --git a/TSCP/src/APP/ciapp/Route/LongRouteDataManage.h b/TSCP/src/APP/ciapp/Route/LongRouteDataManage.h new file mode 100644 index 0000000..7880b6e --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/LongRouteDataManage.h @@ -0,0 +1,73 @@ +/******************************************************** +* +* LongRouteDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _LONG_ROUTE_DATA_MANAGE_H_ +#define _LONG_ROUTE_DATA_MANAGE_H_ + + +#include "CommonTypes.h" +#include "RouteDefine.h" +#include "LongRouteConfigDataManage.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../System/CiSystemDefine.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*·ݽṹ*/ +typedef struct S_LongRouteDataStruct +{ + UINT16 LongRouteId; /*·ID (ʼֶ)*/ + UINT8 LongRouteState; /*·״̬ (ֶ̬)*/ + UINT32 LongXuanPaiStartCycNum; /*ѡʼں (ֶ̬)*/ +} LongRouteDataStruct; + +extern LongRouteDataStruct LongRouteDataStru[ROUTE_LONG_SUM_MAX]; /*峤·ݽṹ*/ + +/* +* ȡָID·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT8 GetLongRouteState(const UINT16 routeId); + +/* +* ָID·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 routeState, ·״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetLongRouteState(const UINT16 routeId, const UINT8 routeState); + +/* +* ȡָID·ѡʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetLongRouteXuanPaiStartCycNum(const UINT16 routeId); + + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Route/RouteConfigDataManage.c b/TSCP/src/APP/ciapp/Route/RouteConfigDataManage.c new file mode 100644 index 0000000..92d85ee --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/RouteConfigDataManage.c @@ -0,0 +1,3577 @@ +/******************************************************** +* +* RouteConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ݹ +* ޸ļ¼ 1. 20150723޸RouteConfigDataManage()ΪֻȡڱĽ· +* 2. 20150723AddExtendRouteIdDataManage()ȡ͸Ľ·ݡ +* +********************************************************/ + +#include "../Switch/SwitchDataManage.h" +#include "RouteConfigDataManage.h" + +RouteConfigDataStruct RouteConfigDataStru[ROUTE_SUM_MAX]; /*·ݽṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiRouteIdBuf[ROUTE_SUM_MAX] = {0u}; /*屾·IDӳ*/ +INT16 RouteCurSum = 0; /*·ǰ(͸Ľ·),·⴦*/ + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_SUM_MAX: ȡʧ +* routeId)) + { + retVal = routeId; + } + else + { + ; + } + + return retVal; +} + +/* +* ȡ·ǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ·ǰ +*/ +UINT16 GetRouteCurSum(void) +{ + UINT16 retVal = 0u; + if (RouteCurSum >= (INT16)ROUTE_SUM_MAX ) + { + retVal = ROUTE_SUM_MAX; + } + else if (RouteCurSum < 0) + { + retVal = 0u; + } + else + { + retVal = (UINT16)RouteCurSum; + } + return retVal; +} + +/* +* ȡ· +* ˵ +* ֵ + RouteConfigDataStruct* +*/ +RouteConfigDataStruct *GetRouteConfigData(void) +{ + return RouteConfigDataStru; +} + + +/* +* ȡָ±ӦĽ·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetRouteId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + if (bufIndex < GetRouteCurSum()) + { + retVal = LocalCiRouteIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ID +* ˵ UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRouteBelongCiId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BelongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRouteDirection(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteDirection; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetRouteType(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteType; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDý· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetConfigRouteType(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].ConfigRouteType; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetRouteLeadProperty(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].LeadProperty; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·Զ· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զ· +*/ +UINT8 GetRouteAutoRouteProperty(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].AutoRouteProperty; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·Զź +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զź +*/ +UINT8 GetRouteAutoSigProperty(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 property = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + property = RouteConfigDataStru[bufIndex].AutoSigProperty; + } + else + { + property = CI_ERROR; + } + return property; +} + + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetRouteReverseProperty(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 property = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + property = RouteConfigDataStru[bufIndex].ReverseRouteProperty; + } + else + { + property = CI_ERROR; + } + return property; +} + +/* +* ȡָID·źſʾɫ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·źſɫ +*/ +UINT8 GetRouteSignalOpenColor(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteSignalOpenColor; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·źſʾɫ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·źſɫ +*/ +UINT8 GetRouteLeadSignalOpenColor(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].LeadOpenColor; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ʼźŻID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ʼźŻID +*/ +UINT16 GetRouteStartSignalId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].StartSignalId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ֹźŻID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ֹźŻID +*/ +UINT16 GetRouteEndSignalId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].EndSignalId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRoutePhysicalSectionSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RoutePhySecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·νṹ +* ˵ const UINT16 routeId, ·ID +* ֵ nullȡʧ +* !null: ·νṹָ +*/ +RoutePhysicalSectionStruct* GetRouteSectionData(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RoutePhysicalSectionStruct* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RoutePhySectionStru; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteSwitchSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteSwitchSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +RouteSwitchStruct* GetRouteSwitchData(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RouteSwitchStruct* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteSwitchStru; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteRelatedProtectSwitchSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteProtectSwitchSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +RouteProtectSwitchStruct* GetRouteRelatedProtSwitchData(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RouteProtectSwitchStruct* pRetVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + pRetVal = RouteConfigDataStru[bufIndex].RouteProtectSwitchStru; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* ȡָID·Զ˵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT16 GetRouteLastSwichPhySecId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteLastSwichPhySecId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteAssocSwitchSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteAssocSwitchSum; + } + + return retVal; +} + + +/* +* ȡָID·ָ +* ˵ const UINT16 routeId, ·ID +* const UINT8 drvSwiIndex +* RouteAssocSwitchStruct * pRouteAssocSwitchStru ݽṹ +* ֵ +* +*/ +void GetRouteAssocSwitchData(const UINT16 routeId, const UINT8 drvSwiIndex, RouteAssocSwitchStruct * pRouteAssocSwitchStru) +{ + UINT16 bufIndex = 0u; /*±*/ + + if(NULL != pRouteAssocSwitchStru) + { + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if(bufIndex < ROUTE_SUM_MAX) + { + if(drvSwiIndex < RouteConfigDataStru[bufIndex].RouteAssocSwitchSum) + { + *pRouteAssocSwitchStru = RouteConfigDataStru[bufIndex].RouteAssocSwitchStru[drvSwiIndex]; + } + + } + + } +} + +/* +* ȡָID·жźĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: жźĿ +*/ +UINT8 GetRouteEnemySignalSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteEnemySignalSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·жź +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: жźŽṹָ +*/ +RouteEnemySignalStruct* GetRouteEnemySignalData(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RouteEnemySignalStruct* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteEnemySigStru; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteIntrudePhySectionSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteIntruPhySecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: νṹָ +*/ +RouteIntrudePhySectionStruct* GetRouteIntrudePhySectionData(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RouteIntrudePhySectionStruct* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteIntruPhySecStru; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·ʽӽĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʽӽĿ +*/ +UINT8 GetRouteBlocNearSecConditionSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocNearConditionSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ʽӽνṹ +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ʽӽIDָ +*/ +RouteNearPhySectionStruct* GetRouteBlocNearPhySectionStru(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RouteNearPhySectionStruct* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocNearPhySecStru; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID·CBTCӽĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʽӽĿ +*/ +UINT8 GetRouteCbtcNearSecConditionSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CbtcNearConditionSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·CBTCӽνṹ +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: CBTCӽIDָ +*/ +RouteNearLogicSectionStruct* GetRouteCbtcNearLogSectionStru(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RouteNearLogicSectionStruct* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CbtcNearLogSecStru; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·߼Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ߼Ŀ +*/ +UINT8 GetRouteLightLogSectionSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteLightLogSecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ߼IDָ +*/ +UINT16* GetRouteLightLogSectionIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteLightLogSecIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·۷źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ۷źŻĿ +*/ +UINT8 GetRouteReturnSignalSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteReturnSigSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·۷źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ۷źŻIDָ +*/ +UINT16* GetRouteReturnSignalIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteReturnSigIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteOverlapSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].OverlapSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +UINT16* GetRouteOverlapIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].OverlapIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·ȥID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȥID +*/ +UINT16 GetRouteLeavePhySecId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR;/*ֵ*/ + + UINT8 railwayType = CI_TRADITION_RAILWAY; + + railwayType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if(CI_TRADITION_RAILWAY == railwayType) + {/*ͳǹ*/ + retVal = RouteConfigDataStru[bufIndex].RouteLeavePhySecId; + }/* zt ɾش 2022-02-15 */ + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ͣID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣID +*/ +UINT16 GetRouteStopSteadyPhySecId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].StopSteadyPhySecId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ղ̵ID +*/ +UINT16 GetRouteThisZhaoChaRelayId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].ThisZhaoChaRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ȡղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȡ̵ID +*/ +UINT16 GetRouteCancleZhaoChaRelayId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].cancelZhaochaRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ȡָID·Զղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զղ̵ID +*/ +UINT16 GetRouteThatZhaoChaRelayId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].ThatZhaoChaRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: źŻĿ +*/ +UINT8 GetRouteFengSuoSignalSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteFSSignalSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: źŻIDָ +*/ +UINT16* GetRouteFengSuoSignalIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteFSSignalIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·رźŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: رźŻĿ +*/ +UINT8 GetRouteOpenNeedCloseSigSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].OpenNeedCloseSigSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·رźŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: رźŻIDָ +*/ +UINT16* GetRouteOpenNeedCloseSigIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].OpenNeedCloseSigIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·迪źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: 迪źŻĿ +*/ +UINT8 GetRouteOpenNeedOpenSigSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].OpenNeedOpenSigSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·迪źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: 迪źŻIDָ +*/ +UINT16* GetRouteOpenNeedOpenSigIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].OpenNeedOpenSigIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID·CBTC迪źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: 迪źŻĿ +*/ +UINT8 GetRouteCbtcNeedOpenSigSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CBTCOpenNeedOpenSigSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·CBTC迪źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: 迪źŻIDָ +*/ +UINT16* GetRouteCbtcNeedOpenSigIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CBTCOpenNeedOpenSigIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} +/* +* ȡָID·ͬʱźŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͬʱźŻĿ +*/ +UINT8 GetRouteOnlyOneOpenSigSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].OnlyOneOpenSigSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ͬʱźŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ͬʱźŻIDָ +*/ +UINT16* GetRouteOnlyOneOpenSigIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].OnlyOneOpenSigIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡָID·һID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ǽ·һ +* >0: ·һID +*/ +UINT16 GetRouteFirstPhySectionId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 phySecSum = 0u; /*·*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex >= ROUTE_SUM_MAX) + { + retVal = CI_ERROR; + } + else + { + phySecSum = RouteConfigDataStru[bufIndex].RoutePhySecSum; + + if (phySecSum > 0u) + { + retVal = RouteConfigDataStru[bufIndex].RoutePhySectionStru[0].PhysicalSectionId; + } + else + { + retVal = CI_ERROR; + } + } + return retVal; + + +} + + +/* +* ȡָID·һID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ǽ·һ +* >0: ·һID +*/ +UINT16 GetRouteLastPhySectionId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 phySecSum = 0u; /*·*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex >= ROUTE_SUM_MAX) + { + retVal = CI_ERROR; + } + else + { + phySecSum = RouteConfigDataStru[bufIndex].RoutePhySecSum; + + if (phySecSum > 0u) + { + retVal = RouteConfigDataStru[bufIndex].RoutePhySectionStru[phySecSum-1U].PhysicalSectionId; + } + else + { + retVal = CI_ERROR; + } + } + + return retVal; + +} + + +/* +* ȡָID·һID +* ˵ const UINT16 routeId, ·ID +* const UINT16 phySectionId, ID +* ֵ CI_ERROR: ʧ +* >0: һID +*/ +UINT16 GetRouteNextPhySecId(const UINT16 routeId, const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 phySecSum = 0u; /*·*/ + UINT8 ii = 0u; /*ѭ*/ + UINT16 retVal = CI_ERROR; + + UINT8 railwayType = CI_TRADITION_RAILWAY; + + UINT16 phySecInx = 0u; + + UINT16 phySecIdt = 0u; + UINT16 switchIdt = 0u; + UINT8 switchPos = 0u; + + UINT8 switchCurPos = 0u; + + UINT16 switchInx = 0u; + + UINT8 switIsMatch = CI_FALSE; + + RouteConfigDataStruct *pRouteConfDataStru = NULL; + + railwayType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/**/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex >= ROUTE_SUM_MAX) + { + retVal = CI_ERROR; + } + else + { + phySecSum = RouteConfigDataStru[bufIndex].RoutePhySecSum; + + if (phySecSum == 0u) + { + retVal = CI_ERROR; + } + else + { + /*ID*/ + for (ii = 0u; ii < phySecSum; ii++) + { + if (phySectionId == RouteConfigDataStru[bufIndex].RoutePhySectionStru[ii].PhysicalSectionId) + { + if (ii < (phySecSum - 1u)) + { + /**/ + retVal = RouteConfigDataStru[bufIndex].RoutePhySectionStru[ii+1U].PhysicalSectionId; + } + else if (ii == (phySecSum - 1u)) + { + if(CI_TRADITION_RAILWAY == railwayType) + { + /*ηȥ*/ + retVal = RouteConfigDataStru[bufIndex].RouteLeavePhySecId; + }/* zt ɾش 2022-02-15 */ + else + { + + } + } + else + { + retVal = CI_ERROR; + } + + break; + } + } + } + } + + return retVal; +} + + +/* +* Ľ· +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 RouteConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 routeConfigDataSum = 0u; /*·豸*/ + UINT8 retVal = CI_SUCCESS; + + /*·ID*/ + routeConfigDataSum = GetRouteCurSum(); + if (routeConfigDataSum >= ROUTE_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < ROUTE_SUM_MAX; ii++) + { + if (jj == routeConfigDataSum) + {/*Ч*/ + + break; + } + + if (RouteConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + LocalCiRouteIdBuf[jj] = RouteConfigDataStru[ii].RouteId; + jj++; + } + + } + } + + + return retVal; +} + + +/* +* ȡBloc·ͣťĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteBlocEsbSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocEsbSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡCbtc·ͣťĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteCbtcEsbSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CbtcEsbSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡBloc·ͣť +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťָ +*/ +UINT16* GetRouteBlocEsbIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocEsbIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡCbtc·ͣť +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťָ +*/ +UINT16* GetRouteCbtcEsbIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CbtcEsbIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡBloc·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteBlocPsdSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocPsdSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡCbtc·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteCbtcPsdSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CbtcPsdSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡBloc· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťָ +*/ +UINT16* GetRouteBlocPsdIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocPsdIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡCbtc· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťָ +*/ +UINT16* GetRouteCbtcPsdIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CbtcPsdIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + + +/* +* ȡ·ڷһ߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ڷһ߼ID +*/ +UINT16 GetRouteInFirstLogSecId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].InFirstLogSecId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡ·ڷһ߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ڷһ߼ID +*/ +UINT16 GetRouteInLastLogSecId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].InLastLogSecId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָID·ԶղĿ +* ˵ const UINT16 routeId, ·ID +* ֵ ԶղĿ +*/ +UINT8 GetRouteThatZhaoChaPhySecSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].ThatZhaoChaPhySecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ԶղID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ԶղIDָ +*/ +UINT16* GetRouteThatZhaoChaPhySecIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].ThatZhaoChaPhySecIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID·ִ·ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ִ·IDָ +*/ +UINT16* GetRouteOpposedRouteIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + returnValue = RouteConfigDataStru[bufIndex].OpposedRouteIdBuf; + } + return returnValue; +} + +/* +* ȡָID·ִ·IDĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ִ·Ŀ +*/ +UINT8 GetRouteOpposedRouteIdSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + returnValue = RouteConfigDataStru[bufIndex].OpposedRouteSum; + } + return returnValue; +} + +/* +* ȡָID·ʼźŻΪնźŻ۷·ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ָID·ʼźŻΪնźŻ۷·IDָ +*/ +UINT16* GetReturnEndSigAsStartSigRoute(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* returnValue = NULL; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + returnValue = RouteConfigDataStru[bufIndex].SignalOpposedRouteIdBuf; + } + + return returnValue; +} + +/* +* ȡָID·ʼźŻΪնźŻ۷·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ ָID·ʼźŻΪնźŻ۷·Ŀ +*/ +UINT8 GetRtnEndSigAsStartSigRouteSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + returnValue = RouteConfigDataStru[bufIndex].SignalOpposedRouteSum; + } + + return returnValue; +} + + +/* +* ȡBlocĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteBlocOtherCiSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + ret = RouteConfigDataStru[bufIndex].BlockOtherCiSum; + } + else + { + ret = CI_ERROR; + } + + return ret; +} + + +/* +* ȡCbtc·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteCbtcOtherCiSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + ret = RouteConfigDataStru[bufIndex].CbtcOtherCiSum; + } + else + { + ret = CI_ERROR; + } + + return ret; +} + +/* +* ȡBloc· +* ˵ const UINT16 routeId, ·ID +* ֵ Bloc· +*/ + +RouteOtherCheckStruct* GetRouteBlocOtherCiBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + + RouteOtherCheckStruct* ret = NULL; + + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + ret = RouteConfigDataStru[bufIndex].BlockOtherCiBuff; + } + else + { + ret = NULL; + } + + return ret; +} + +/* +* ȡCbtc· +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* != NULL: CBTC· +*/ + +RouteOtherCheckStruct* GetRouteCbtcOtherCiBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RouteOtherCheckStruct* ret = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + ret = RouteConfigDataStru[bufIndex].CbtcOtherCiBuff; + } + else + { + ret = NULL; + } + + return ret; +} + +/* +* ȡĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT16 GetRouteFloodGateSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 ret = (UINT16)CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + ret = RouteConfigDataStru[bufIndex].floodGateSum; + } + else + { + ret = CI_ERROR; + } + + return ret; +} + +/* +* ȡID +* ˵ const UINT16 routeId, ·ID +* ֵ ID +*/ +UINT16* GetRouteFloodGateBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* ret = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + ret = RouteConfigDataStru[bufIndex].floodGateIdBuf; + } + else + { + ret = NULL; + } + + return ret; +} + +/* +* · +* ˵ routeSum · +* routeIdBuff ͸Ľ·ID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendRouteIdDataManage(UINT16 routeSum,const UINT16 *routeIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if (((UINT16)RouteCurSum + routeSum) >= ROUTE_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = (UINT16)RouteCurSum; + RouteCurSum += (INT16)routeSum; + for(ii = 0u;ii< routeSum;ii++) + { + LocalCiRouteIdBuf[index+ii] = routeIdBuff[ii];/*׷ӵLocalCiRouteIdBuf*/ + } + } + + return retVal; +} +/* +* ȡ羮· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: 羮· +*/ +UINT8 GetAirShaftRouteType(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + ret = RouteConfigDataStru[bufIndex].AirShaftRouteType; + } + + return ret; +} +/* +* ȡԶ· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զ· +*/ +UINT8 GetAutoTriggerType(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + ret = RouteConfigDataStru[bufIndex].AutoTriggerType; + } + + return ret; +} +/* +* ȡָID·νṹ +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +RouteTriggerPhySectionStruct* GetRouteBlocTrigLogSecStru(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + RouteTriggerPhySectionStruct* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocTriggerPhySecStru; + } + else + { + retVal = NULL; + } + return retVal; +} +/* +* ·ȫΪм +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS: ȫΪм +* CI_ERROR: ȫΪм +*/ +UINT8 CheckRoutePhysicalType(const UINT16 routeId) +{ + RoutePhysicalSectionStruct* physicalStru = NULL; /*۷źŻΪʼ˵Ľ·Ϣ*/ + UINT8 routeSecNum = 0u; /*۷źŻΪʼ˵Ľ·*/ + UINT8 ii = 0u; + UINT8 reVal = CI_ERROR; + routeSecNum = GetRoutePhysicalSectionSum(routeId); + physicalStru = GetRouteSectionData(routeId); + if (NULL == physicalStru) + { + /*޼*/ + reVal = CI_ERROR; + } + else + { + /*ʼ*/ + for (ii = 0u; ii < routeSecNum; ii++) + { + if (PHYSICAL_SECTION_LJK_YES != GetPhySecLjkFlag(physicalStru[ii].PhysicalSectionId)) + { + reVal = CI_ERROR; + break; + } + else + { + reVal = CI_SUCCESS; + } + } + } + return reVal; +} + + +/* +* ȡָID·ʼж״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_INIT_EMEMY: ʼж +* ROUTE_INIT_NOT_EMEMY: ʼ޵ж +*/ +UINT8 GetRouteInitEnemyStatus(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = ROUTE_INIT_ENEMY; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteInitEnemyStatus; + } + else + { + retVal = ROUTE_INIT_ENEMY; + } + return retVal; +} + + +/* +* ȡָID·ʼ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_INIT_INSTRU: ʼ +* ROUTE_INIT_NOT_INSTRU: ʼ +*/ +UINT8 GetRouteInitInstruStatus(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = ROUTE_INIT_INSTRU; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteInitInstruStatus; + } + else + { + retVal = ROUTE_INIT_INSTRU; + } + return retVal; +} + + +/* +* ȡָID·ʼ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_INIT_FS: ʼ +* ROUTE_INIT_NOT_FS: ʼ޷ +*/ +UINT8 GetRouteInitFSStatus(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = ROUTE_INIT_FS; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteInitFSStatus; + } + else + { + retVal = ROUTE_INIT_FS; + } + return retVal; +} + +/* +* ȡָID·ͬⰴť̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ >0: ̵ID +* 0: û +*/ +UINT16 GetRouteDCTAJId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].DCRouteTAJId; + } + else + { + retVal = 0u; + } + return retVal; +} + + +/* +* ȡָID·̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ >0: ̵ID +* 0: û +*/ +UINT16 GetRouteDCQJId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].DCRouteDCQJId; + } + else + { + retVal = 0u; + } + return retVal; +} + +/* +* ȡָID·״̬/쳣/Ԥʱ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ʱ +*/ +UINT8 GetRouteNeedDelayUnlock(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RouteNeedDelayUnlock; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·̵ӿµȡղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȡ̵ID +*/ +UINT16 GetRouteCancleZCRelayId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].CancelZhaoChaRelayOnRelayIntrf; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ȡָID·̵ӿµıղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ̵ӿµıղ̵ID +*/ +UINT16 GetRouteRelayBenDuanZcIdOnRelay(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RelayBenDuanZcIdOnRelayIntrf; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ȡָID·̵ӿµĶԶղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ̵ӿµĶԶղ̵ID +*/ +UINT16 GetRouteRelayDuiDuanZcIdOnRelay(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].RelayDuiDuanZcIdOnRelayIntrf; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/**********************************************************************************/ +/* +* ȡָID·Ƿз仯 +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ƿз仯 +*/ +UINT8 GetRouteHaveDirChangePointIn(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].HaveDirChangePointInRoute; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·뱣֮Ƿз仯 +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ƿз仯 +*/ +UINT8 GetRouteHaveDirChangePointAfter(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].HaveDirChangePointAfterRoute; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ָǷȡ +* ˵ const UINT16 routeId, ·ID +* const UINT16 phySecIdID +* ֵ 0: ʧ +* >0: Ƿȡ +*/ +UINT8 GetRoutePhySecShouldLockOppose(const UINT16 routeId,const UINT16 phySecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + for (ii=0u;ii0: ID +*/ +UINT8 GetRouteBelongVirCiId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].BelongVirCIid; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·߼ +* ˵ const UINT16 routeId, ·ID +* +* ֵ 0: ȡʧ +* >0: ߼ +*/ +UINT16 GetRouteLogSectionSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].RouteInLogTrackSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ NULL: ȡʧ +* ǿ: ߼ID +*/ +UINT16* GetRouteLogSectionIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].RouteInLogTrackIdBuf; + } + return retVal; +} + +/* +* ȡָID·ڵķǽ·߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ 0: ȡʧ +* >0: ߼ +* add 20221005 ·ǰ⶯ +*/ +UINT16 GetRouteSwitOtherLogSecSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].RouteInSwitOtherPosLogSecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ڵķǽ·߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ NULL: ȡʧ +* ǿ: ߼ID +* add 20221005 ·ǰ⶯ +*/ +UINT16* GetRouteSwitOtherPosLogSecIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].RouteInSwitOtherPosLogSecIdBuf; + } + return retVal; +} + +/* +* ȡָID·ιķǽ·ҷǵ߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ 0: ȡʧ +* >0: ߼ +* add 20221005 ·ǰ⶯ +*/ +UINT16 GetRouteOutLogSecSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].RouteOutLogSecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ιķǽ·ҷǵ߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ NULL: ȡʧ +* ǿ: ߼ID +* add 20221005 ·ǰ⶯ +*/ +UINT16* GetRouteOutLogSecSumIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].RouteOutLogSecSumIdBuf; + } + return retVal; +} + +/* +* ȡ·߼εһ߼ID +* ˵ const UINT16 routeId, ·ID +* const UINT16 logSectionId, ߼ID +* ֵ CI_ERROR: ʧ +* >0: һ߼ID +*/ +UINT16 GetRouteNextLogSecId(const UINT16 routeId, const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 logSecSum = 0u; /*·߼*/ + UINT16 i = 0u; /*ѭ*/ + UINT16* logSecIdBuf = NULL; + UINT16 retVal = CI_ERROR; + + /*ȡ·߼Ϣ*/ + bufIndex = GetRouteConfigBufIndex(routeId); + logSecSum = GetRouteLogSectionSum(routeId); + logSecIdBuf = GetRouteLogSectionIdBuf(routeId); + + if (ROUTE_SUM_MAX > bufIndex) + { + if((0u < logSecSum) ) + { + for(i = 0u; i < logSecSum; i++) + { + /*ҵ߼*/ + if(logSecIdBuf[i] == logSectionId) + { + /*ǰβǽ·߼*/ + if(i < (logSecSum - 1u)) + { + /*һ߼*/ + retVal = logSecIdBuf[i + 1U]; + } + /*һ߼*/ + else if(i == (logSecSum - 1u)) + { + /*ر߼*/ + retVal = logSecIdBuf[i]; + } + else + { + /*ش*/ + retVal = CI_ERROR; + } + } + else + { + } + } + } + else + { + } + } + else + { + } + return(retVal); + +} + + +/* +* ȡ·Ӧλ +* ˵ const UINT16 wRouteId, ·ID +* const UINT16 logSectionId, ߼ID +* ֵ CI_ERROR: ʧ +* : SwitchState +* SWITCH_POSITION_DINGWEI:λ +* SWITCH_POSITION_FANWEI: λ +* 0xFF ·޴˷ +*/ +UINT8 GetRouteProtectSwitchState(const UINT16 wRouteId, const UINT16 wSwitchId) +{ + /* · */ + UINT8 chRetVal = CI_ERROR; + UINT8 chProtectSwSum = 0U; + UINT8 ii = 0U; + RouteProtectSwitchStruct* stProtectSwBuf = NULL; + + chProtectSwSum = GetRouteRelatedProtectSwitchSum(wRouteId); + stProtectSwBuf = GetRouteRelatedProtSwitchData(wRouteId); + if ((ROUTE_PROTECTSWI_SUM_MAX > chProtectSwSum) && (NULL != stProtectSwBuf)) + { + if ((0U != wSwitchId) && (UINT16_MAX != wSwitchId)) + { + for (ii = 0U; ii < chProtectSwSum; ii++) + { + if (stProtectSwBuf[ii].ProtectSwitchId == wSwitchId) + { + chRetVal = stProtectSwBuf[ii].ProtectPosition; + break; + } + else + { + /*ִ*/ + } + } + + if (ii == chProtectSwSum) + { + chRetVal = UINT8_MAX; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; + +} + + +/* +* ȡ·Ƿ +* ˵ const UINT16 wRouteId, ·ID +* const UINT16 logSectionId, ߼ID +* ֵ CI_ERROR: ʧ +* ROUTE_INC_PROTECT_SW_YES: +* ROUTE_INC_PROTECT_SW_NO:δ +*/ +UINT8 GetRouteIncProtectSwitch(const UINT16 wRouteId, const UINT16 wSwitchId) +{ + /* · */ + UINT8 chRetVal = CI_ERROR; + UINT8 chProtectSwSum = 0U; + UINT8 ii = 0U; + RouteProtectSwitchStruct* stProtectSwBuf = NULL; + + chProtectSwSum = GetRouteRelatedProtectSwitchSum(wRouteId); + stProtectSwBuf = GetRouteRelatedProtSwitchData(wRouteId); + if ((ROUTE_PROTECTSWI_SUM_MAX > chProtectSwSum) && (NULL != stProtectSwBuf)) + { + if ((0U != wSwitchId) && (UINT16_MAX != wSwitchId)) + { + for (ii = 0U; ii < chProtectSwSum; ii++) + { + if (stProtectSwBuf[ii].ProtectSwitchId == wSwitchId) + { + chRetVal = ROUTE_INC_PROTECT_SW_YES; + break; + } + else + { + /*ִ*/ + } + } + + if (ii == chProtectSwSum) + { + chRetVal = ROUTE_INC_PROTECT_SW_NO; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; + +} +/* +* ȡ·һ߼ +* ˵ const UINT16 routeId, ·ID +* +* ֵ ߼ID +*/ +UINT16 GetRouteLastLogSectionId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + UINT16* logSecIdBuf = NULL; + UINT16 logSecSum = 0u; /*·߼*/ + + logSecSum = GetRouteLogSectionSum(routeId); + logSecIdBuf = GetRouteLogSectionIdBuf(routeId); + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + if (0u < logSecSum) + { + retVal = logSecIdBuf[logSecSum]; + } + else + { + } + } + else + { + retVal = 0u; + } + return retVal; +} +/* +* ȡָID·ʼźŻΪն˵Ľ·Ŀ +* ˵ UINT16 routeId, ·ID +* ֵ ʼźŻΪն˵Ľ·Ŀ +*/ +UINT8 GetRouteStartSigisEndRouteSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].SigisEndSigRouteSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ʼźŻΪն˵Ľ·ID +* ˵ UINT16 routeId, ·ID +* ֵ ʼźŻΪն˵Ľ·ID +*/ +UINT16* GetRouteStartSigisEndRouteBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteConfigDataStru[bufIndex].SigisEndSigRouteIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} +/* +* ȡָID·󱸿迪źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: 迪źŻIDָ +*/ +UINT16* GetBlocRouteOpenNeedOpenSigBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocOpenNeedOpenSigIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} +/* +* ȡָID·󱸿迪źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: 迪źŻĿ +*/ +UINT8 GetBlocRouteOpenNeedOpenSigSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].BlocOpenNeedOpenSigSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/****************************ֶν·***************************************/ + +/* +* ȡָID·ķֶν· +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_MAIN_PROPERTY: · +* ROUTE_SUB_PROPERTY ӽ· +* ROUTE_INIT_PROPERTY: ͨ· +* 0u ȡʧ +*/ +UINT8 GetRouteMainorSubPropert(const UINT16 routeId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].MainOrSubData.MainRouteProperty; + } + else + { + } + return retVal; +} + +/* +* ȡָID·ӽ·Ŀ +* ˵ const UINT16 mainrouteId, ·ID +* ֵ >0 ROUTE_SUB_PROPERTY ӽ·Ŀ +* 0 ȡʧ +*/ +UINT8 GetSubRouteSum(const UINT16 mainrouteId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetRouteConfigBufIndex(mainrouteId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if (ROUTE_MAIN_PROPERTY == RouteConfigDataStru[bufIndex].MainOrSubData.MainRouteProperty) + { + retVal = RouteConfigDataStru[bufIndex].MainOrSubData.RouteSubSum; + } + else + { + /*·0*/ + } + + } + else + { + /*0*/ + } + return retVal; +} + + +/* +* ȡָID·ӽ·ID +* ˵ const UINT16 mainrouteId, ·ID +* ֵ !NULL ӽ· +* NULL ȡʧ +*/ +UINT16* GetSubRouteBuff(const UINT16 mainrouteId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(mainrouteId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if (ROUTE_MAIN_PROPERTY == RouteConfigDataStru[bufIndex].MainOrSubData.MainRouteProperty) + { + retVal = RouteConfigDataStru[bufIndex].MainOrSubData.RouteSubIdBuf; + } + else + { + /*·NULL*/ + } + + } + else + { + /*NULL*/ + } + return retVal; +} + +/* +* ȡָIDӽ·ĶӦ· +* ˵ const UINT16 subrouteId, ·ID +* ֵ >0 · +* 0 ȡʧ +*/ +UINT8 GetMainRouteSum(const UINT16 subrouteId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetRouteConfigBufIndex(subrouteId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if (ROUTE_SUB_PROPERTY == RouteConfigDataStru[bufIndex].MainOrSubData.MainRouteProperty) + { + retVal = RouteConfigDataStru[bufIndex].MainOrSubData.RouteBelMainSum; + } + else + { + /*ӽ·NULL*/ + } + + } + else + { + /*NULL*/ + } + return retVal; +} + +/* +* ȡָID·ĶӦ· +* ˵ const UINT16 subrouteId, ·ID +* ֵ !NULL · +* NULL ȡʧ +*/ +UINT16* GetMainRouteBuff(const UINT16 subrouteId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(subrouteId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if (ROUTE_SUB_PROPERTY == RouteConfigDataStru[bufIndex].MainOrSubData.MainRouteProperty) + { + retVal = RouteConfigDataStru[bufIndex].MainOrSubData.RouteBelMainIdBuf; + } + else + { + /*ӽ·NULL*/ + } + + } + else + { + /*NULL*/ + } + return retVal; +} + +/* +* ȡָID·CBTCղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ղ̵ID +* by cgh 20230728 ֺ󱸼CBTCղ +*/ +UINT16 GetRouteCbtcThisZhaoChaRelayId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].wCbtcThisZhaoChaRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·CBTCԶղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ղ̵ID +* by cgh 20230728 ֺ󱸼CBTCղ +*/ +UINT16 GetRouteCbtcThatZhaoChaRelayId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].wCbtcThatZhaoChaRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·CBTCȡղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ղ̵ID +* by cgh 20230728 ֺ󱸼CBTCղ +*/ +UINT16 GetRouteCbtcCancelZhaochaRelay(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].wCbtccancelZhaochaRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ⱨźſʱ־ +* ˵ const UINT16 routeId ·ID +* ֵ 0: ȡʧ +* >0: ʱ־ +*/ +UINT8 GetRouteSGBJDelayFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].cSGBJDelayOpenFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ⱨ +* ˵ const UINT16 routeId ·ID +* ֵ 0: ȡʧ +* >0: ⱨ +*/ +UINT16 GetRouteRelSGBJNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].wRelatedSGBJNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ⱨID +* ˵ const UINT16 routeId ·ID +* ֵ NULL: ȡʧ +* NULL: ⱨID +*/ +UINT16* GetRouteRelSGBJIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].szRelatedSGBJId; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID·CBTC +* ˵ const UINT16 routeId ·ID +* ֵ 0: ȡʧ +* >0: CBTC +* Created By LQ 2023.12.08 +*/ +UINT8 GetRouteCbtcProperty(const UINT16 routeId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].cCbtcProperty; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·һȥ߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȥ߼ID +* BY LC +*/ +UINT16 GetRouteLeaveLogicSecId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR;/*ֵ*/ + + UINT8 railwayType = CI_TRADITION_RAILWAY; + + railwayType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/*ȡ·*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if (CI_TRADITION_RAILWAY == railwayType) + {/*ͳǹ*/ + retVal = RouteConfigDataStru[bufIndex].RouteLeaveLogicSecId; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ת·۷źŻID +* ˵ const UINT16 routeId ·ID +* ֵ 0: δöӦ +* >0: ӦźŻID +* Created by fan 202400812 +*/ +UINT16 GetRouteTransRoutZFSigID(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteConfigDataStru[bufIndex].wRelatedTransZFSigId; + } + else + { + retVal = 0U; + } + return retVal; +} + +/* +* ȡָID· +* ˵const UINT16 wRouteId ·ID +* ֵ0 ȡʧ +* 0x55 · +* 0xaa · +* Created By LQ 2024.09.05 +*/ +UINT8 GetRouteRukuProperty(const UINT16 wRouteId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetRouteConfigBufIndex(wRouteId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + cRetVal = RouteConfigDataStru[bufIndex].cRouteRukuProperty; + } + else + { + cRetVal = CI_ERROR; + } + + return cRetVal; +} + +/* +* ȡָڱ·Ƿеڱ +* ˵ const UINT16 wRouteId, ·ID +* ֵ 0 +* > 0 · +* BY CGH 20241202 +*/ +UINT8 GetOthCiRouteExistLocalCiSw(const UINT16 wRouteId) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 chLocalCiId = 0U;/*ID*/ + UINT8 chRouteBelCiId = 0U;/*·ID*/ + UINT8 chRouteSwitchSum = 0U;/*·Ŀ*/ + RouteSwitchStruct* szRouteSwitchData = NULL;/*·*/ + UINT8 ii = 0U; + UINT8 chSwitchBelCiId = 0U;/*ID*/ + UINT8 chRouteProSwitchSum = 0U;/*·Ŀ*/ + RouteProtectSwitchStruct* szRouteProSwitchData = NULL;/*·*/ + + chLocalCiId = GetSystemParaLocalCiId(); + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId)) + { + chRouteBelCiId = GetRouteBelongCiId(wRouteId); + chRouteSwitchSum = GetRouteSwitchSum(wRouteId); + szRouteSwitchData = GetRouteSwitchData(wRouteId); + chRouteProSwitchSum = GetRouteRelatedProtectSwitchSum(wRouteId); + szRouteProSwitchData = GetRouteRelatedProtSwitchData(wRouteId); + + if ((chLocalCiId != chRouteBelCiId) && (0U != chRouteBelCiId) && (0U != chLocalCiId)) + { + if (NULL != szRouteSwitchData) + { + for (ii = 0U; ii < chRouteSwitchSum; ii++) + { + chSwitchBelCiId = GetSwitchBelongCiId(szRouteSwitchData[ii].SwitchId); + if (chLocalCiId == chSwitchBelCiId) + { + chRetVal = chRouteBelCiId; + break; + } + else + { + ; /**/ + } + } + if (ii == chRouteSwitchSum) + { + if (NULL != szRouteProSwitchData) + { + for (ii = 0U; ii < chRouteProSwitchSum; ii++) + { + chSwitchBelCiId = GetSwitchBelongCiId(szRouteProSwitchData[ii].ProtectSwitchId); + if (chLocalCiId == chSwitchBelCiId) + { + chRetVal = chRouteBelCiId; + break; + } + else + { + ; /**/ + } + } + } + else + { + ; + } + } + else + { + ; /*Ѿеڱټ*/ + } + } + else + { + ; + } + } + else + { + ; /*·*/ + } + } + else + { + ; + } + + return chRetVal; +} + +/* +* · +* ˵ const UINT16 wRouteId, ·ID +* UINT8* chCiId +* ֵ CI_ERRORڵ +* CI_SUCCESSȫڽ· +* BY CGH 20241203 +*/ +UINT8 CheckRouteSwitchBelCi(const UINT16 wRouteId,UINT8* chCiId) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 chRouteBelCiId = 0U;/*·ID*/ + UINT8 chRouteSwitchSum = 0U;/*·Ŀ*/ + RouteSwitchStruct* szRouteSwitchData = NULL;/*·*/ + UINT8 ii = 0U; + UINT8 chSwitchBelCiId = 0U;/*ID*/ + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId) && (NULL != chCiId)) + { + chRetVal = CI_SUCCESS; + chRouteBelCiId = GetRouteBelongCiId(wRouteId); + chRouteSwitchSum = GetRouteSwitchSum(wRouteId); + szRouteSwitchData = GetRouteSwitchData(wRouteId); + *chCiId = 0U; + + if (NULL != szRouteSwitchData) + { + for (ii = 0U; ii < chRouteSwitchSum; ii++) + { + chSwitchBelCiId = GetSwitchBelongCiId(szRouteSwitchData[ii].SwitchId); + if (chRouteBelCiId != chSwitchBelCiId) + { + chRetVal = CI_ERROR; + *chCiId = chSwitchBelCiId; + break; + } + else + { + ; /**/ + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* · +* ˵ const UINT16 wRouteId, ·ID +* UINT8* chCiId +* ֵ CI_ERRORڵ +* CI_SUCCESSȫڽ· +* BY CGH 20241203 +*/ +UINT8 CheckRouteProSwitchBelCi(const UINT16 wRouteId,UINT8* chCiId) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 chRouteBelCiId = 0U;/*·ID*/ + UINT8 ii = 0U; + UINT8 chSwitchBelCiId = 0U;/*ID*/ + UINT8 chRouteProSwitchSum = 0U;/*·Ŀ*/ + RouteProtectSwitchStruct* szRouteProSwitchData = NULL;/*·*/ + + if ((0U < wRouteId) && (ROUTE_SUM_MAX > wRouteId) && (NULL != chCiId)) + { + chRetVal = CI_SUCCESS; + chRouteBelCiId = GetRouteBelongCiId(wRouteId); + chRouteProSwitchSum = GetRouteRelatedProtectSwitchSum(wRouteId); + szRouteProSwitchData = GetRouteRelatedProtSwitchData(wRouteId); + *chCiId = 0U; + + if (NULL != szRouteProSwitchData) + { + for (ii = 0U; ii < chRouteProSwitchSum; ii++) + { + chSwitchBelCiId = GetSwitchBelongCiId(szRouteProSwitchData[ii].ProtectSwitchId); + if (chRouteBelCiId != chSwitchBelCiId) + { + chRetVal = CI_ERROR; + *chCiId = chSwitchBelCiId; + break; + } + else + { + ; /**/ + } + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Route/RouteConfigDataManage.h b/TSCP/src/APP/ciapp/Route/RouteConfigDataManage.h new file mode 100644 index 0000000..e2e4598 --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/RouteConfigDataManage.h @@ -0,0 +1,1369 @@ +/******************************************************** +* +* RouteConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ROUTE_CONFIG_DATA_MANAGE_H_ +#define _ROUTE_CONFIG_DATA_MANAGE_H_ + + +#include "CommonTypes.h" +#include "RouteDefine.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + + + +#ifdef __cplusplus +extern "C" { +#endif + +/*·ṹ*/ +typedef struct S_Route_Condition_Switch +{ + UINT16 SwitchId; /*ID (ֶ)*/ + UINT8 SwitchPosition; /*λ(μλö) (ֶ)*/ +} RouteConditionSwitchStruct; + +/*·ӽνṹ*/ +typedef struct S_Route_Near_PhySection +{ + UINT8 NearPhySecSum; /*ӽĿ(ֶ)*/ + UINT16 NearPhySecIdBuf[ROUTE_BLOCNEAR_PHYSEC_SUM_MAX]; /*ӽID(ֶ)*/ + UINT8 SwitchSum; /*Ŀ(ֶ)*/ + RouteConditionSwitchStruct ConditionSwitchStru[ROUTE_CONDITION_SWITCH_SUM_MAX]; /*ṹ(ֶ)*/ + UINT8 BlocNearLogSecSum; /*ʽӽ߼Ŀ(ֶ)*/ + UINT16 BlocNearLogSecIdBuf[ROUTE_CBTCNEAR_LOGSEC_SUM_MAX]; /*ʽӽ߼ID(ֶ)*/ +}RouteNearPhySectionStruct; + +/*·ӽ߼νṹ*/ +typedef struct S_Route_Near_LogicSection +{ + UINT8 NearLogicSecSum; /*ӽ߼Ŀ(ֶ)*/ + UINT16 NearLogicSecIdBuf[ROUTE_CBTCNEAR_LOGSEC_SUM_MAX]; /*ӽ߼ID(ֶ)*/ + UINT8 SwitchSum; /*Ŀ(ֶ)*/ + RouteConditionSwitchStruct ConditionSwitchStru[ROUTE_CONDITION_SWITCH_SUM_MAX]; /*ṹ(ֶ)*/ +}RouteNearLogicSectionStruct; + +/*·νṹ*/ +typedef struct S_Route_Intrude_PhySection +{ + UINT16 SectionId; /*ID (ֶ)*/ + UINT8 SwitchSum; /*Ŀ (ֶ)*/ + RouteConditionSwitchStruct ConditionSwitchStru[ROUTE_CONDITION_SWITCH_SUM_MAX]; /*ṹ(ֶ)*/ + UINT8 chCondSwitLockDir; /*CT г*/ +} RouteIntrudePhySectionStruct; + + +/*·жźŽṹ*/ +typedef struct S_Route_Enemy_Signal +{ + UINT16 SignalId; /*жźID (ֶ)*/ + UINT8 SwitchSum; /*صĿ (ֶ)*/ + RouteConditionSwitchStruct ConditionSwitchStru[ROUTE_CONDITION_SWITCH_SUM_MAX]; /*ṹ(ֶ)*/ +} RouteEnemySignalStruct; + + +/*·ݽṹ*/ +typedef struct S_Route_PhysicalSection +{ + UINT16 PhysicalSectionId; /*ID (ֶ)*/ + UINT8 CheckProperty; /* (ֶ)*/ + UINT8 LockDirShouldOpposedToRoute; /*շǷӦ·෴*/ +} RoutePhysicalSectionStruct; + + +/*·ṹ*/ +typedef struct S_Route_Switch +{ + UINT16 SwitchId; /*ID (ֶ)*/ + UINT8 SwitchPosition; /*λ μλö (ֶ)*/ + UINT8 SwitchProperty; /*(·еĵ/) (ֶ)*/ +} RouteSwitchStruct; + +/*·ṹ*/ +typedef struct S_Route_Protect_Switch +{ + UINT16 ProtectSwitchId; /*ID (ֶ)*/ + UINT8 ProtectPosition; /*λ (ֶ)*/ +} RouteProtectSwitchStruct; + +/*·ṹ*/ +typedef struct S_Route_Drived_Switch +{ + UINT16 SwitchId; /*ID*/ + UINT8 SwitchPosition; /*λ*/ +} RouteAssocSwitchStruct; + + +/*·ṹ*/ +typedef struct S_Route_Other +{ + UINT8 DevType; /* 豸 (ֶ)*/ + UINT16 DevId; /* 豸ID (ֶ)*/ + UINT8 DevStatus; /* 豸״̬ (ֶ) */ +} RouteOtherCheckStruct; + +typedef struct S_Route_MonoRail_Leave_PhySec +{ + UINT16 leavePhySecId; + UINT16 switchSum; /*Ŀ(ֶ)*/ + RouteConditionSwitchStruct switchStru[ROUTE_MONORAIL_PHY_SEC_SWIT_SUM_MAX]; /*ṹ(ֶ)*/ +}RouteMonoRailLeavePhySecStruct; + +/*·νṹ*/ +typedef struct S_Route_Trigger_PhySection +{ + UINT8 TriggerPhySecSum; /*Ŀ(ֶ)*/ + UINT16 TriggerPhySecIdBuf[ROUTE_BLOCTRIGGER_CONDITION_SUM_MAX]; /*ID(ֶ)*/ + UINT8 SwitchSum; /*Ŀ(ֶ)*/ + RouteConditionSwitchStruct ConditionSwitchStru[ROUTE_CONDITION_SWITCH_SUM_MAX]; /*ṹ(ֶ)*/ +}RouteTriggerPhySectionStruct; + +/*·߼νṹ*/ +typedef struct S_Route_Trigger_LogicSection +{ + UINT8 TriggerLogicSecSum; /*߼Ŀ(ֶ)*/ + UINT16 TriggerLogicSecIdBuf[ROUTE_CBTCTRIGGER_LOGSEC_SUM_MAX]; /*߼ID(ֶ)*/ + UINT8 SwitchSum; /*Ŀ(ֶ)*/ + RouteConditionSwitchStruct ConditionSwitchStru[ROUTE_CONDITION_SWITCH_SUM_MAX]; /*ṹ(ֶ)*/ +}RouteTriggerLogicSectionStruct; + +/*·ӽ·*//*add by cgh 20230428*/ +typedef struct S_Route_MainOrSub_ConfigData +{ + UINT8 MainRouteProperty; /*·(·/ӽ·)*/ /*add by cgh 20230427 */ + UINT8 RouteSubSum; /*·ӽ·Ŀ*/ /*add by cgh 20230428*/ + UINT16 RouteSubIdBuf[ROUTE_SUB_INCLUDE_SUM_MAX];/*·ӽ·ID*/ /*add by cgh 20230428*/ + UINT8 RouteBelMainSum; /*ӽ··Ŀ*/ /*add by cgh 20230428*/ + UINT16 RouteBelMainIdBuf[ROUTE_MAIN_BELONG_SUM_MAX];/*ӽ··ID add by cgh 20230428*/ +}RouteMainOrSubConfigData; + +/*·ݽṹ*/ +typedef struct S_RouteConfigDataStruct +{ + UINT16 RouteId; /*·ID (ֶ)*/ + UINT8 BelongCiId; /*ID (ֶ)*/ + UINT8 BelongVirCIid; /*ID*/ + UINT8 RouteDirection; /*·(/) (ֶ)*/ + UINT8 RouteType; /*·(г·/۷·/·) (ֶ)*/ + UINT8 ConfigRouteType; /*ý·(г·/۷·/·) (ֶ)*/ + UINT8 LeadProperty; /*·(/) (ֶ)*/ + UINT8 AutoRouteProperty; /*Զ·(߱/߱) (ֶ)*/ + UINT8 AutoSigProperty; /*Զź(߱/߱) (ֶ)*/ + UINT8 ReverseRouteProperty; /*·ԣ߱/߱)(ֶ)*/ + UINT8 RouteSignalOpenColor; /*·ʼźſʾɫ(μźŻɫ) (ֶ)*/ + UINT8 LeadOpenColor; /*·ʼźʾɫ(μźŻɫ) (ֶ)*/ + UINT16 StartSignalId; /*·ʼźŻID (ֶ)*/ + UINT16 EndSignalId; /*·ֹźŻID (ֶ)*/ + UINT8 RoutePhySecSum; /*·Ŀ (ֶ)*/ + RoutePhysicalSectionStruct RoutePhySectionStru[ROUTE_PHYSICALSECTION_SUM_MAX]; /*· (ֶ)*/ + UINT8 RouteSwitchSum; /*·Ŀ (ֶ)*/ + RouteSwitchStruct RouteSwitchStru[ROUTE_SWITCH_SUM_MAX]; /*·ṹ (ֶ)*/ + UINT8 RouteProtectSwitchSum; /*·Ŀ (ֶ)*/ + RouteProtectSwitchStruct RouteProtectSwitchStru[ROUTE_PROTECTSWI_SUM_MAX]; /*·ṹ (ֶ)*/ + UINT16 RouteLastSwichPhySecId; /*·Զ˵ID (ֶ)*/ + + UINT8 RouteInitEnemyStatus; /*·ʼж״̬*/ + UINT8 RouteEnemySignalSum; /*·صжźĿ (ֶ)*/ + RouteEnemySignalStruct RouteEnemySigStru[ROUTE_ENEMYSIGNAL_SUM_MAX]; /*·صжźŽṹ (ֶ)*/ + + UINT8 RouteInitInstruStatus; /*·ʼ״̬*/ + UINT8 RouteIntruPhySecSum; /*·Ŀ (ֶ)*/ + RouteIntrudePhySectionStruct RouteIntruPhySecStru[ROUTE_INTRUDEPHYSEC_SUM_MAX]; /*·νṹ (ֶ)*/ + + UINT8 BlocNearConditionSum; /*ʽ·ӽĿ (ֶ)*/ + RouteNearPhySectionStruct BlocNearPhySecStru[ROUTE_NEARSEC_CONDITION_SUM_MAX]; /*ʽ·ӽνṹ (ֶ)*/ + UINT8 CbtcNearConditionSum; /*CBTC·ӽĿ (ֶ)*/ + RouteNearLogicSectionStruct CbtcNearLogSecStru[ROUTE_NEARSEC_CONDITION_SUM_MAX]; /*CBTC·ӽ߼νṹ (ֶ)*/ + UINT8 RouteLightLogSecSum; /*·߼Ŀ (ֶ)*/ + UINT16 RouteLightLogSecIdBuf[ROUTE_LIGHT_LOGSEC_SUM_MAX]; /*·߼ID (ֶ)*/ + UINT8 RouteReturnSigSum; /*·۷źŻĿ (ֶ)*/ + UINT16 RouteReturnSigIdBuf[ROUTE_RETURNSIGNAL_SUM_MAX]; /*·۷źŻID (ֶ)*/ + UINT8 OverlapSum; /*·طĿ (ֶ)*/ + UINT16 OverlapIdBuf[ROUTE_PROTECTSECGROUP_SUM_MAX]; /*·طID (ֶ)*/ + UINT16 RouteLeavePhySecId; /*·ȥID (ʼֶ)*/ + UINT16 RouteLeaveLogicSecId; /*·һȥ߼ID (ʼֶ)*/ + UINT16 RouteMonoRailLeavePhySecSum; + RouteMonoRailLeavePhySecStruct RouteMonoRailLeavePhySecStru[ROUTE_MONORAIL_LEAVE_PHY_SEC_SUM_MAX]; + UINT16 StopSteadyPhySecId; /*νӦͣID (ֶ)*/ + UINT16 ThisZhaoChaRelayId; /*ղ̵ID (ֶ)*/ + UINT16 ThatZhaoChaRelayId; /*Զղ̵ID (ֶ)*/ + UINT16 cancelZhaochaRelayId; /* ȡղ̵ID(ֶ) ̵ */ + UINT16 wCbtcThisZhaoChaRelayId; /*ղ̵ID (ֶ)*/ + UINT16 wCbtcThatZhaoChaRelayId; /*Զղ̵ID (ֶ)*/ + UINT16 wCbtccancelZhaochaRelayId; /* ȡղ̵ID(ֶ) ̵ */ + + UINT8 RouteInitFSStatus; /*·ʼ״̬*/ + UINT8 RouteFSSignalSum; /*·طźŻĿ (ֶ)*/ + UINT16 RouteFSSignalIdBuf[ROUTE_FENGSUO_SIGNAL_SUM_MAX]; /*·طźŻID (ֶ)*/ + + UINT8 OpenNeedCloseSigSum; /*·رźŻĿ (ֶ)*/ + UINT16 OpenNeedCloseSigIdBuf[ROUTE_OPENNEEDCLOSESIG_SUM_MAX]; /*·رźŻID (ֶ)*/ + UINT8 OpenNeedOpenSigSum; /*·迪źŻĿ (ֶ)*/ + UINT16 OpenNeedOpenSigIdBuf[ROUTE_OPENNEEDOPENSIG_SUM_MAX]; /*·迪źŻID (ֶ)*/ + UINT8 CBTCOpenNeedOpenSigSum; /*CBTC·迪źŻĿ (ֶ)*/ + UINT16 CBTCOpenNeedOpenSigIdBuf[ROUTE_OPENNEEDOPENSIG_SUM_MAX]; /*CBTC·迪źŻID (ֶ)*/ + + UINT8 BlocOpenNeedOpenSigSum; /*󱸽·迪źŻĿ (ֶ)*/ + UINT16 BlocOpenNeedOpenSigIdBuf[ROUTE_OPENNEEDOPENSIG_SUM_MAX]; /*󱸽·迪źŻID (ֶ)*/ + + UINT8 OnlyOneOpenSigSum; /*·迪źŻĿ (ֶ)*/ + UINT16 OnlyOneOpenSigIdBuf[ROUTE_ONLYONEOPENSIG_SUM_MAX]; /*·ͬʱźŻID (ֶ)*/ + UINT8 BlocEsbSum; /*ʽ·Esb (ֶ)*/ + UINT16 BlocEsbIdBuf[ROUTE_ESB_SUM_MAX]; /*ʽ·Esb Id (ֶ)*/ + UINT8 CbtcEsbSum; /*CBTC·Esb (ֶ)*/ + UINT16 CbtcEsbIdBuf[ROUTE_ESB_SUM_MAX]; /*CBTC·Esb Id (ֶ)*/ + UINT8 BlocPsdSum; /*ʽ·Psd (ֶ)*/ + UINT16 BlocPsdIdBuf[ROUTE_PSD_SUM_MAX]; /*ʽ·Psd Id (ֶ)*/ + UINT8 CbtcPsdSum; /*CBTC·Psd (ֶ)*/ + UINT16 CbtcPsdIdBuf[ROUTE_PSD_SUM_MAX]; /*CBTC·Psd Id (ֶ)*/ + UINT16 InFirstLogSecId; /*ڷһ߼*/ + UINT16 InLastLogSecId; /*ڷһ߼*/ + UINT8 ThatZhaoChaPhySecSum; /*ԶղĿ (ֶ)*/ + UINT16 ThatZhaoChaPhySecIdBuf[ROUTE_THATZC_PHYSEC_SUM_MAX]; /*ԶղID (ֶ)*/ + UINT8 OpposedRouteSum; /*ִ·Ŀ (ֶ)*/ + UINT16 OpposedRouteIdBuf[ROUTE_OPPOSED_ROUTE_SUM_MAX]; /*ִ·ID (ֶ)*/ + UINT8 SignalOpposedRouteSum; /*Ա·ʼźŻΪնźŻ۷·Ŀ(ֶ)*/ + UINT16 SignalOpposedRouteIdBuf[ROUTE_SIGNAL_OPPOSED_ROUTE_SUM_MAX]; /*Ա·ʼźŻΪնźŻ۷·ID(ֶ)*/ + UINT8 floodGateSum; /* */ + UINT16 floodGateIdBuf[ROUTE_FLOOD_GATE_SUM_MAX]; /* ID */ + UINT8 CbtcOtherCiSum; /* CBTC */ + RouteOtherCheckStruct CbtcOtherCiBuff[ROUTE_OHTER_CHECK_SUM_MAX]; /* CBTCϢ */ + UINT8 BlockOtherCiSum; /* ʽ */ + RouteOtherCheckStruct BlockOtherCiBuff[ROUTE_OHTER_CHECK_SUM_MAX]; /* ʽϢ */ + + UINT8 RouteAssocSwitchSum; /*·Ŀ (ֶ)*/ + RouteAssocSwitchStruct RouteAssocSwitchStru[ROUTE_DRIVED_SWITCH_SUM_MAX]; /*·ṹ (ֶ)*/ + UINT8 AirShaftRouteType; /*羮·*/ + UINT8 AutoTriggerType; /*Զ*/ + RouteTriggerPhySectionStruct BlocTriggerPhySecStru[ROUTE_BLOC_TRIGGERPHY_NUM]; /*ʽ·νṹ (ֶ)*/ + RouteTriggerLogicSectionStruct CbtcTriggerLogSecStru[1]; /*CBTC·߼νṹ (ֶ)Ԥ*/ + + UINT16 DCRouteDCQJId;/*·̵ID*/ + UINT16 DCRouteTAJId;/*·ͬⰴť̵ID*/ + + UINT8 RouteNeedDelayUnlock; /* ·״̬/쳣/Ԥգȡ˽ҪʱֶΣ*/ + + UINT16 CancelZhaoChaRelayOnRelayIntrf;/*̵ӿȡղ̵*/ + + UINT8 HaveDirChangePointInRoute;/*·ڲǷз仯*/ + + UINT8 HaveDirChangePointAfterRoute;/*·棨·뱣м䣩Ƿз仯*/ + UINT16 RelayBenDuanZcIdOnRelayIntrf; /*̵ӿڱղ̵ID*/ + UINT16 RelayDuiDuanZcIdOnRelayIntrf; /*̵ӿڶԶղ̵ID*/ + + UINT8 SigisEndSigRouteSum; /*Ա·ʼźŻΪնźŻĽ·Ŀ(ֶ)*/ + UINT16 SigisEndSigRouteIdBuf[ROUTE_SIGNAL_OPPOSED_ROUTE_SUM_MAX]; /*Ա·ʼźŻΪնźŻĽ·ID(ֶ)*/ + + + UINT16 RouteInLogTrackSum; /*·߼ID*/ + UINT16 RouteInLogTrackIdBuf[MAX_ROUTE_IN_LT_NUM]; /*·߼ID (ֶ)*/ + + UINT16 RouteInSwitOtherPosLogSecSum; /*·ڵķǽ·߼ID*/ /*ͬλùͬ߼Σ˴ǽ·ڵIJڽ·λù߼*/ /*add 20221002 TIOC5.0*/ + UINT16 RouteInSwitOtherPosLogSecIdBuf[MAX_ROUTE_IN_LT_NUM]; /*·ڵķǽ·߼ID*/ /*ͬλùͬ߼Σ˴ǽ·ڵIJڽ·λù߼ID*/ /*add 20221002 TIOC5.0*/ + + UINT16 RouteOutLogSecSum; /*·ιķǽ·ҷǵ߼ID ˴ڽ·εڽ·Ҳڽ·ڵ߼ε߼*/ /*add 20221002 TIOC5.0*/ + UINT16 RouteOutLogSecSumIdBuf[MAX_ROUTE_IN_LT_NUM]; /*·ιķǽ·ҷǵ߼ID ˴ڽ·εڽ·Ҳڽ·ڵ߼ε߼ID*/ /*add 20221002 TIOC5.0*/ + RouteMainOrSubConfigData MainOrSubData; /*·Ӧӽ··*/ /*add cgh 20230508*/ + + UINT8 cSGBJDelayOpenFlag; /*·ⱨʱű־0xAAʱţ0x55ʱ*/ + UINT16 wRelatedSGBJNum; /*·ⱨ*/ + UINT16 szRelatedSGBJId[ROUTE_RELATED_SGBJ_NUM_MAX]; /*·ⱨID*/ + UINT8 cCbtcProperty; /*·CBTCԣ0x55CBTC0xAACBTC*/ + UINT16 wRelatedTransZFSigId; /*·ת۷źŻid δĬ0*/ + UINT8 cRouteRukuProperty; /*ǷΪ·0x55 ·0xaa ·*/ +}RouteConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern RouteConfigDataStruct RouteConfigDataStru[ROUTE_SUM_MAX]; /*·ݽṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiRouteIdBuf[ROUTE_SUM_MAX]; +extern INT16 RouteCurSum; + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_SUM_MAX: ȡʧ +* 0: ·ǰ +*/ +UINT16 GetRouteCurSum(void); + +/* +* ȡ· +* ˵ + UINT16 routeId +* ֵ + RouteConfigDataStruct* +*/ +RouteConfigDataStruct *GetRouteConfigData(void); + +/* +* ȡָ±ӦĽ·ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetRouteId(const UINT16 bufIndex); + +/* +* ȡָID·ID +* ˵ UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRouteBelongCiId(const UINT16 routeId); + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRouteDirection(const UINT16 routeId); + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetRouteType(const UINT16 routeId); + +/* +* ȡָIDý· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetConfigRouteType(const UINT16 routeId); + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetRouteLeadProperty(const UINT16 routeId); + +/* +* ȡָID·Զ· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զ· +*/ +UINT8 GetRouteAutoRouteProperty(const UINT16 routeId); + +/* +* ȡָID·Զź +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զź +*/ +UINT8 GetRouteAutoSigProperty(const UINT16 routeId); + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: · +*/ +UINT8 GetRouteReverseProperty(const UINT16 routeId); + +/* +* ȡָID·źſʾɫ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·źſɫ +*/ +UINT8 GetRouteSignalOpenColor(const UINT16 routeId); + +/* +* ȡָID·źſʾɫ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·źſɫ +*/ +UINT8 GetRouteLeadSignalOpenColor(const UINT16 routeId); + +/* +* ȡָID·ʼźŻID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ʼźŻID +*/ +UINT16 GetRouteStartSignalId(const UINT16 routeId); + +/* +* ȡָID·ֹźŻID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ֹźŻID +*/ +UINT16 GetRouteEndSignalId(const UINT16 routeId); + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRoutePhysicalSectionSum(const UINT16 routeId); + +/* +* ȡָID·νṹ +* ˵ const UINT16 routeId, ·ID +* ֵ nullȡʧ +* !null: ·νṹָ +*/ +RoutePhysicalSectionStruct* GetRouteSectionData(const UINT16 routeId); + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteSwitchSum(const UINT16 routeId); + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +RouteSwitchStruct* GetRouteSwitchData(const UINT16 routeId); + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteRelatedProtectSwitchSum(const UINT16 routeId); + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ṹָ +*/ +RouteProtectSwitchStruct* GetRouteRelatedProtSwitchData(const UINT16 routeId); + +/* +* ȡָID·Զ˵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT16 GetRouteLastSwichPhySecId(const UINT16 routeId); + +/* +* ȡָID·жźĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: жźĿ +*/ +UINT8 GetRouteEnemySignalSum(const UINT16 routeId); + +/* +* ȡָID·жź +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: жźŽṹָ +*/ +RouteEnemySignalStruct* GetRouteEnemySignalData(const UINT16 routeId); + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteIntrudePhySectionSum(const UINT16 routeId); + +/* +* ȡָID· +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: νṹָ +*/ +RouteIntrudePhySectionStruct* GetRouteIntrudePhySectionData(const UINT16 routeId); + +/* +* ȡָID·ʽӽĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʽӽĿ +*/ +UINT8 GetRouteBlocNearSecConditionSum(const UINT16 routeId); + +/* +* ȡָID·ʽӽνṹ +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ʽӽIDָ +*/ +RouteNearPhySectionStruct* GetRouteBlocNearPhySectionStru(const UINT16 routeId); + +/* +* ȡָID·CBTCӽĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʽӽĿ +*/ +UINT8 GetRouteCbtcNearSecConditionSum(const UINT16 routeId); + +/* +* ȡָID·CBTCӽνṹ +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: CBTCӽIDָ +*/ +RouteNearLogicSectionStruct* GetRouteCbtcNearLogSectionStru(const UINT16 routeId); + +/* +* ȡָID·߼Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ߼Ŀ +*/ +UINT8 GetRouteLightLogSectionSum(const UINT16 routeId); + +/* +* ȡָID·߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ߼IDָ +*/ +UINT16* GetRouteLightLogSectionIdBuf(const UINT16 routeId); + +/* +* ȡָID·۷źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ۷źŻĿ +*/ +UINT8 GetRouteReturnSignalSum(const UINT16 routeId); + +/* +* ȡָID·۷źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ۷źŻIDָ +*/ +UINT16* GetRouteReturnSignalIdBuf(const UINT16 routeId); + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteOverlapSum(const UINT16 routeId); + +/* +* ȡָID·ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +UINT16* GetRouteOverlapIdBuf(const UINT16 routeId); + +/* +* ȡָID·ȥID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȥID +*/ +UINT16 GetRouteLeavePhySecId(const UINT16 routeId); + +/* +* ȡָID·ͣID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣID +*/ +UINT16 GetRouteStopSteadyPhySecId(const UINT16 routeId); + +/* +* ȡָID·ղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ղ̵ID +*/ +UINT16 GetRouteThisZhaoChaRelayId(const UINT16 routeId); + +/* +* ȡָID·Զղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զղ̵ID +*/ +UINT16 GetRouteThatZhaoChaRelayId(const UINT16 routeId); + +/* +* ȡָID·ȡղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȡ̵ID +*/ +UINT16 GetRouteCancleZhaoChaRelayId(const UINT16 routeId); + +/* +* ȡָID·źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: źŻĿ +*/ +UINT8 GetRouteFengSuoSignalSum(const UINT16 routeId); + +/* +* ȡָID·źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: źŻIDָ +*/ +UINT16* GetRouteFengSuoSignalIdBuf(const UINT16 routeId); + +/* +* ȡָID·رźŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: رźŻĿ +*/ +UINT8 GetRouteOpenNeedCloseSigSum(const UINT16 routeId); + +/* +* ȡָID·رźŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: رźŻIDָ +*/ +UINT16* GetRouteOpenNeedCloseSigIdBuf(const UINT16 routeId); + +/* +* ȡָID·迪źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: 迪źŻĿ +*/ +UINT8 GetRouteOpenNeedOpenSigSum(const UINT16 routeId); + +/* +* ȡָID·迪źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: 迪źŻIDָ +*/ +UINT16* GetRouteOpenNeedOpenSigIdBuf(const UINT16 routeId); + +/* +* ȡָID·ͬʱźŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͬʱźŻĿ +*/ +UINT8 GetRouteOnlyOneOpenSigSum(const UINT16 routeId); + +/* +* ȡָID·ͬʱźŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ͬʱźŻIDָ +*/ +UINT16* GetRouteOnlyOneOpenSigIdBuf(const UINT16 routeId); + +/* +* ȡָID·һID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ǽ·һ +* >0: ·һID +*/ +UINT16 GetRouteFirstPhySectionId(const UINT16 routeId); + +/* +* ȡָID·һID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ǽ·һ +* >0: ·һID +*/ +UINT16 GetRouteLastPhySectionId(const UINT16 routeId); + +/* +* ȡָID·һID +* ˵ const UINT16 routeId, ·ID +* const UINT16 phySectionId, ID +* ֵ CI_ERROR: ʧ +* >0: һID +*/ +UINT16 GetRouteNextPhySecId(const UINT16 routeId, const UINT16 phySectionId); + +/* +* Ľ· +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 RouteConfigDataManage(void); + + +/* +* ȡBloc·ͣťĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteBlocEsbSum(const UINT16 routeId); + + +/* +* ȡCbtc·ͣťĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteCbtcEsbSum(const UINT16 routeId); + + +/* +* ȡBloc·ͣť +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťָ +*/ +UINT16* GetRouteBlocEsbIdBuf(const UINT16 routeId); + +/* +* ȡCbtc·ͣť +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťָ +*/ +UINT16* GetRouteCbtcEsbIdBuf(const UINT16 routeId); + +/* +* ȡBloc·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteBlocPsdSum(const UINT16 routeId); + + +/* +* ȡCbtc·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteCbtcPsdSum(const UINT16 routeId); + +/* +* ȡBloc· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťָ +*/ +UINT16* GetRouteBlocPsdIdBuf(const UINT16 routeId); + +/* +* ȡCbtc· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťָ +*/ +UINT16* GetRouteCbtcPsdIdBuf(const UINT16 routeId); + +/* +* ȡ·ڷһ߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ڷһ߼ID +*/ +UINT16 GetRouteInFirstLogSecId(const UINT16 routeId); + +/* +* ȡ·ڷһ߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ڷһ߼ID +*/ +UINT16 GetRouteInLastLogSecId(const UINT16 routeId); + +/* +* ȡָID·ԶղĿ +* ˵ const UINT16 routeId, ·ID +* ֵ ԶղĿ +*/ +UINT8 GetRouteThatZhaoChaPhySecSum(const UINT16 routeId); + +/* +* ȡָID·ԶղID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ԶղIDָ +*/ +UINT16* GetRouteThatZhaoChaPhySecIdBuf(const UINT16 routeId); + +/* +* ȡָID·ִ·ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ִ·IDָ +*/ +UINT16* GetRouteOpposedRouteIdBuf(const UINT16 routeId); + +/* +* ȡָID·ִ·IDĿ +* ˵ const UINT16 routeId, ·ID +* ֵ ȡָID·ִ·IDĿ +* +*/ +UINT8 GetRouteOpposedRouteIdSum(const UINT16 routeId); + +/* +* ȡָID·ʼźŻΪնźŻ۷·ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ָID·ʼźŻΪնźŻ۷·IDָ +*/ +UINT16* GetReturnEndSigAsStartSigRoute(const UINT16 routeId); + +/* +* ȡָID·ʼźŻΪնźŻ۷·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ ָID·ʼźŻΪնźŻ۷·Ŀ +*/ +UINT8 GetRtnEndSigAsStartSigRouteSum(const UINT16 routeId); + +/* +* ȡBlocĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteBlocOtherCiSum(const UINT16 routeId); + + +/* +* ȡCbtc·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͣťĿ +*/ +UINT8 GetRouteCbtcOtherCiSum(const UINT16 routeId); + +/* +* ȡBloc· +* ˵ const UINT16 routeId, ·ID +* ֵ Bloc· +*/ +RouteOtherCheckStruct* GetRouteBlocOtherCiBuf(const UINT16 routeId); + +/* +* ȡCbtc· +* ˵ const UINT16 routeId, ·ID +* ֵ CBTC· +*/ +RouteOtherCheckStruct* GetRouteCbtcOtherCiBuf(const UINT16 routeId); + +/* +* ȡĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT16 GetRouteFloodGateSum(const UINT16 routeId); + +/* +* ȡID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16* GetRouteFloodGateBuf(const UINT16 routeId); + +/* +* ȡָID·Ŀ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetRouteAssocSwitchSum(const UINT16 routeId); + +/* +* ȡָID·ָ +* ˵ const UINT16 routeId, ·ID +* const UINT8 drvSwiIndex +* RouteAssocSwitchStruct * pRouteAssocSwitchStru ݽṹ +* ֵ +* +*/ +void GetRouteAssocSwitchData(const UINT16 routeId, const UINT8 drvSwiIndex, RouteAssocSwitchStruct * pRouteAssocSwitchStru); + +/* +* · +* ˵ routeSum · +* routeIdBuff ͸Ľ·ID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendRouteIdDataManage(UINT16 routeSum,const UINT16 *routeIdBuff); +/* +* ȡ羮· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: 羮· +*/ +UINT8 GetAirShaftRouteType(const UINT16 routeId); +/* +* ȡԶ· +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զ· +*/ +UINT8 GetAutoTriggerType(const UINT16 routeId); +/* +* ȡָID·νṹ +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +RouteTriggerPhySectionStruct* GetRouteBlocTrigLogSecStru(const UINT16 routeId); +/* +* ·ȫΪм +* ˵ const UINT16 routeId, ·ID +* ֵ CI_SUCCESS: ȫΪм +* CI_ERROR: ȫΪм +*/ +UINT8 CheckRoutePhysicalType(const UINT16 routeId); + +/* +* ȡָID·ʼж״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_INIT_EMEMY: ʼж +* ROUTE_INIT_NOT_EMEMY: ʼ޵ж +*/ +UINT8 GetRouteInitEnemyStatus(const UINT16 routeId); + +/* +* ȡָID·ʼ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_INIT_INSTRU: ʼ +* ROUTE_INIT_NOT_INSTRU: ʼ +*/ +UINT8 GetRouteInitInstruStatus(const UINT16 routeId); + +/* +* ȡָID·ʼ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_INIT_FS: ʼ +* ROUTE_INIT_NOT_FS: ʼ޷ +*/ +UINT8 GetRouteInitFSStatus(const UINT16 routeId); + +/* +* ȡָID·̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ >0: ̵ID +* 0: û +*/ +UINT16 GetRouteDCQJId(const UINT16 routeId); + +/* +* ȡָID·ͬⰴť̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ >0: ̵ID +* 0: û +*/ +UINT16 GetRouteDCTAJId(const UINT16 routeId); + +/* +* ȡָID·״̬/쳣/Ԥʱ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ʱ +*/ +UINT8 GetRouteNeedDelayUnlock(const UINT16 routeId); + +/* +* ȡָID·̵ӿµȡղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȡ̵ID +*/ +UINT16 GetRouteCancleZCRelayId(const UINT16 routeId); + +/* +* ȡָID·̵ӿµĶԶղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ̵ӿµĶԶղ̵ID +*/ +UINT16 GetRouteRelayDuiDuanZcIdOnRelay(const UINT16 routeId); + + +/* +* ȡָID·̵ӿµıղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ̵ӿµıղ̵ID +*/ +UINT16 GetRouteRelayBenDuanZcIdOnRelay(const UINT16 routeId); + +/* +* ȡָID·Ƿз仯 +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ƿз仯 +*/ +UINT8 GetRouteHaveDirChangePointIn(const UINT16 routeId); + +/* +* ȡָID·뱣֮Ƿз仯 +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Ƿз仯 +*/ +UINT8 GetRouteHaveDirChangePointAfter(const UINT16 routeId); + +/* +* ȡָID·ָǷȡ +* ˵ const UINT16 routeId, ·ID +* const UINT16 phySecIdID +* ֵ 0: ʧ +* >0: Ƿȡ +*/ +UINT8 GetRoutePhySecShouldLockOppose(const UINT16 routeId,const UINT16 phySecId); +/* +* ȡָID·ID +* ˵ UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetRouteBelongVirCiId(const UINT16 routeId); + +/* +* ȡָID·߼ +* ˵ const UINT16 routeId, ·ID +* +* ֵ 0: ȡʧ +* >0: ߼ +*/ +UINT16 GetRouteLogSectionSum(const UINT16 routeId); + +/* +* ȡָID·߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ NULL: ȡʧ +* ǿ: ߼ID +*/ +UINT16* GetRouteLogSectionIdBuf(const UINT16 routeId); + +/* +* ȡָID·ڵķǽ·߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ 0: ȡʧ +* >0: ߼ +* add 20221005 ·ǰ⶯ +*/ +UINT16 GetRouteSwitOtherLogSecSum(const UINT16 routeId); + +/* +* ȡָID·ڵķǽ·߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ NULL: ȡʧ +* ǿ: ߼ID +* add 20221005 ·ǰ⶯ +*/ +UINT16* GetRouteSwitOtherPosLogSecIdBuf(const UINT16 routeId); + +/* +* ȡָID·ιķǽ·ҷǵ߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ 0: ȡʧ +* >0: ߼ +* add 20221005 ·ǰ⶯ +*/ +UINT16 GetRouteOutLogSecSum(const UINT16 routeId); + +/* +* ȡָID·ιķǽ·ҷǵ߼ID +* ˵ const UINT16 routeId, ·ID +* +* ֵ NULL: ȡʧ +* ǿ: ߼ID +* add 20221005 ·ǰ⶯ +*/ +UINT16* GetRouteOutLogSecSumIdBuf(const UINT16 routeId); + +/* +* ȡ·߼εһ߼ID +* ˵ const UINT16 routeId, ·ID +* const UINT16 logSectionId, ߼ID +* ֵ CI_ERROR: ʧ +* >0: һ߼ID +*/ +UINT16 GetRouteNextLogSecId(const UINT16 routeId, const UINT16 logSectionId); + + +/* +* ȡ·Ӧλ +* ˵ const UINT16 wRouteId, ·ID +* const UINT16 logSectionId, ߼ID +* ֵ CI_ERROR: ʧ +* : SwitchState +* SWITCH_POSITION_DINGWEI:λ +* SWITCH_POSITION_FANWEI: λ +*/ +UINT8 GetRouteProtectSwitchState(const UINT16 wRouteId, const UINT16 wSwitchId); + +/* +* ȡ·Ƿ +* ˵ const UINT16 wRouteId, ·ID +* const UINT16 logSectionId, ߼ID +* ֵ CI_ERROR: +* CI_SUCCESS: +*/ +UINT8 GetRouteIncProtectSwitch(const UINT16 wRouteId, const UINT16 wSwitchId); + +/* +* ȡ·һ߼ +* ˵ const UINT16 routeId, ·ID +* +* ֵ ߼ID +*/ +UINT16 GetRouteLastLogSectionId(const UINT16 routeId); +/* +* ȡָID·CBTC迪źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: 迪źŻĿ +*/ +UINT8 GetRouteCbtcNeedOpenSigSum(const UINT16 routeId); + + +/* +* ȡָID·CBTC迪źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: 迪źŻIDָ +*/ +UINT16* GetRouteCbtcNeedOpenSigIdBuf(const UINT16 routeId); +/* +* ȡָID·󱸿迪źŻID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: 迪źŻIDָ +*/ +UINT16* GetBlocRouteOpenNeedOpenSigBuf(const UINT16 routeId); +/* +* ȡָID·󱸿迪źŻĿ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: 迪źŻĿ +*/ +UINT8 GetBlocRouteOpenNeedOpenSigSum(const UINT16 routeId); +/* +* ȡָID·ʼźŻΪն˵Ľ· +* ˵ UINT16 routeId, ·ID +* ֵ ʼźŻΪն˵Ľ·Ŀ +*/ +UINT8 GetRouteStartSigisEndRouteSum(const UINT16 routeId); +/* +* ȡָID·ʼźŻΪն˵Ľ·ID +* ˵ UINT16 routeId, ·ID +* ֵ ʼźŻΪն˵Ľ·ID +*/ +UINT16* GetRouteStartSigisEndRouteBuf(const UINT16 routeId); + + + +/************************ֶν·***************************************/ + + +/* +* ȡָID·ķֶν· +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_MAIN_PROPERTY: · +* ROUTE_SUB_PROPERTY ӽ· +* ROUTE_INIT_PROPERTY: ͨ· +* 0u ȡʧ +*/ +UINT8 GetRouteMainorSubPropert(const UINT16 routeId); + +/* +* ȡָID·ӽ·Ŀ +* ˵ const UINT16 mainrouteId, ·ID +* ֵ >0 ROUTE_SUB_PROPERTY ӽ·Ŀ +* 0 ȡʧ +*/ +UINT8 GetSubRouteSum(const UINT16 mainrouteId); + +/* +* ȡָID·ӽ·ID +* ˵ const UINT16 mainrouteId, ·ID +* ֵ !NULL ӽ· +* NULL ȡʧ +*/ +UINT16* GetSubRouteBuff(const UINT16 mainrouteId); + +/* +* ȡָIDӽ·ĶӦ· +* ˵ const UINT16 subrouteId, ·ID +* ֵ >0 · +* 0 ȡʧ +*/ +UINT8 GetMainRouteSum(const UINT16 subrouteId); + +/* +* ȡָID·ĶӦ· +* ˵ const UINT16 subrouteId, ·ID +* ֵ !NULL · +* NULL ȡʧ +*/ +UINT16* GetMainRouteBuff(const UINT16 subrouteId); + +/* +* ȡָID·CBTCղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ղ̵ID +* by cgh 20230728 ֺ󱸼CBTCղ +*/ +UINT16 GetRouteCbtcThisZhaoChaRelayId(const UINT16 routeId); + +/* +* ȡָID·CBTCԶղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ղ̵ID +* by cgh 20230728 ֺ󱸼CBTCղ +*/ +UINT16 GetRouteCbtcThatZhaoChaRelayId(const UINT16 routeId); + +/* +* ȡָID·CBTCȡղ̵ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ղ̵ID +* by cgh 20230728 ֺ󱸼CBTCղ +*/ +UINT16 GetRouteCbtcCancelZhaochaRelay(const UINT16 routeId); + +/* +* ȡָID·ⱨźſʱ־ +* ˵ const UINT16 routeId ·ID +* ֵ 0: ȡʧ +* >0: ʱ־ +*/ +UINT8 GetRouteSGBJDelayFlag(const UINT16 routeId); + +/* +* ȡָID·ⱨ +* ˵ const UINT16 routeId ·ID +* ֵ 0: ȡʧ +* >0: ⱨ +*/ +UINT16 GetRouteRelSGBJNum(const UINT16 routeId); + +/* +* ȡָID·ⱨID +* ˵ const UINT16 routeId ·ID +* ֵ NULL: ȡʧ +* NULL: ⱨID +*/ +UINT16* GetRouteRelSGBJIdBuf(const UINT16 routeId); + +/* +* ȡָID·CBTC +* ˵ const UINT16 routeId ·ID +* ֵ 0: ȡʧ +* >0: CBTC +* Created By LQ 2023.12.08 +*/ +UINT8 GetRouteCbtcProperty(const UINT16 routeId); + +/* +* ȡָID·һȥ߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȥ߼ID +* BY LC +*/ +UINT16 GetRouteLeaveLogicSecId(const UINT16 routeId); + +/* +* ȡָID·ת·۷źŻID +* ˵ const UINT16 routeId ·ID +* ֵ 0: δöӦ +* >0: ӦźŻID +* Created by fan 20240812 +*/ +UINT16 GetRouteTransRoutZFSigID(const UINT16 routeId); + +/* +* ȡָID· +* ˵const UINT16 wRouteId ·ID +* ֵ0 ȡʧ +* 0x55 · +* 0xaa · +* Created By LQ 2024.09.05 +*/ +UINT8 GetRouteRukuProperty(const UINT16 wRouteId); + +/* +* ȡָڱ·Ƿеڱ +* ˵ const UINT16 wRouteId, ·ID +* ֵ CI_ERROR +* CI_SUCCESS +* BY CGH 20241202 +*/ +UINT8 GetOthCiRouteExistLocalCiSw(const UINT16 wRouteId); + +/* +* · +* ˵ const UINT16 wRouteId, ·ID +* UINT8* chCiId +* ֵ CI_ERRORڵ +* CI_SUCCESSȫڽ· +* BY CGH 20241203 +*/ +UINT8 CheckRouteSwitchBelCi(const UINT16 wRouteId, UINT8* chCiId); + +/* +* · +* ˵ const UINT16 wRouteId, ·ID +* UINT8* chCiId +* ֵ CI_ERRORڵ +* CI_SUCCESSȫڽ· +* BY CGH 20241203 +*/ +UINT8 CheckRouteProSwitchBelCi(const UINT16 wRouteId, UINT8* chCiId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Route/RouteDataManage.c b/TSCP/src/APP/ciapp/Route/RouteDataManage.c new file mode 100644 index 0000000..a11d4a7 --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/RouteDataManage.c @@ -0,0 +1,5749 @@ +/******************************************************** +* +* RouteDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ݹ +* ޸ļ¼ +* +********************************************************/ + + +#include "RouteDataManage.h" +#include "LogicSectionDataManage.h" +#include "AxisSort.h" +#include "AxisSort_api.h" +#include "InterlockCommonManage.h" + +RouteDataStruct RouteDataStru[ROUTE_SUM_MAX]; /*·ݽṹ*/ + + +/* +* ȡָID· +* ˵ +* ֵ + RouteDataStruct * +*/ +RouteDataStruct *GetRouteData(void) +{ + return RouteDataStru; +} + + +/* +* ȡָID·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT8 GetRouteState(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RouteState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ǰһ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT8 GetRoutePreState(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + returnValue = RouteDataStru[bufIndex].RoutePreState; + } + + return returnValue; +} + +/* +* ָID·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 routeState, ·״̬ +* ֵ CI_ERROR +* CI_SUCCESS +* edit cgh 20250224 +*/ +UINT8 SetRouteState(const UINT16 routeId, const UINT8 routeState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + UINT32 dwCurCycleNum = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex >= ROUTE_SUM_MAX) + { + retVal = CI_ERROR; + } + + if(CI_SUCCESS == retVal) + { + if (0u == RouteStateValidCheck(routeState)) + { + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + dwCurCycleNum = Get2oo2CurCycleNum(); + if (ROUTE_STATE_IDLE == routeState) + { /*·*/ + + RouteDataStru[bufIndex].XuanPaiStartCycNum = 0u; /*·ѡʼ*/ + RouteDataStru[bufIndex].RouteLockStartCycNum = 0u; /*·ʼں*/ + RouteDataStru[bufIndex].DelayUnlockStartCycNum = 0u; /*·ʱʼں*/ + RouteDataStru[bufIndex].LeadFaultOpenStartCycNum = 0u; /*·ʼں*/ + RouteDataStru[bufIndex].ZongQuXiaoFlag = ROUTE_ZONGQUXIAO_SET_NO; /*·ȡ־*/ + RouteDataStru[bufIndex].ZongRenJieFlag = ROUTE_ZONGRENJIE_SET_NO; /*·˽־*/ + RouteDataStru[bufIndex].RepeatOpenFlag = ROUTE_REPEATOPEN_SET_NO; /*·źؿ־*/ + RouteDataStru[bufIndex].chRouteXiansuConfirm = ROUTE_XIANSU_CONFIRM_NO; /*·źؿ־*/ + RouteDataStru[bufIndex].StopCheckFlag = ROUTE_STOPCHECK_SET_NO; /*·ֹͣ־*/ + RouteDataStru[bufIndex].StopKeepCheckFlag = ROUTE_STOPCHECK_SET_NO; /*·ֹͣ־*/ + RouteDataStru[bufIndex].BelongLongRouteId = 0u; /*··*/ + RouteDataStru[bufIndex].StopensureFlag = ROUTE_STOPENSURE_NO; /*·֤ͣ־*/ + RouteDataStru[bufIndex].RecoverOpenState = ROUTE_RECOVER_STA_INIT;/*Ҳ·ָ״̬һν·״̬ת*/ + RouteDataStru[bufIndex].cResReqOtherCIId = 0u; + RouteDataStru[bufIndex].dwFirstElockStartCycNum = 0u; + RouteDataStru[bufIndex].dwDelayOpenStartCycNum = 0U; /*ⱨ·ʱʼ*/ + ClearRouteResReqTrainBuf(routeId); + } + else if ((ROUTE_STATE_FIRST_XUANPAI == routeState) + || (ROUTE_STATE_LEAD_FIRST_XUANPAI == routeState) + || (ROUTE_STATE_HALF_FIRST_XUAN == routeState)) + { /*·ѡ ѡ ֽ·ѡ*/ + + RouteDataStru[bufIndex].XuanPaiStartCycNum = dwCurCycleNum; /*ý·ѡʼ*/ + } + else if ((ROUTE_STATE_XUANPAI == routeState)||(ROUTE_STATE_HALF_XUANPAI == routeState) || (ROUTE_STATE_LEAD_XUANPAI == routeState)) + { /*·ѡ ѡ ֽ·ѡ*/ + + if (0u == RouteDataStru[bufIndex].XuanPaiStartCycNum) + { + RouteDataStru[bufIndex].XuanPaiStartCycNum = dwCurCycleNum; /*ý·ѡʼ*/ + } + } + else if ((ROUTE_STATE_FIRST_LOCK == routeState) + || (ROUTE_STATE_LEAD_LOCK == routeState) + || (ROUTE_STATE_HALF_LOCK == routeState)) + { /*·*//**//**/ + + RouteDataStru[bufIndex].XuanPaiStartCycNum = 0u; /*·ѡʼ*/ + + if (ROUTE_STATE_FIRST_LOCK == routeState) + { + RouteDataStru[bufIndex].RecoverOpenState = ROUTE_RECOVER_STA_INIT;/*ζգ׼ź*/ + } + } + else if (ROUTE_STATE_DELAY_UNLOCK == routeState) + { /*ʱ*/ + + RouteDataStru[bufIndex].cResReqOtherCIId = 0u; + ClearRouteResReqTrainBuf(routeId); + RouteDataStru[bufIndex].DelayUnlockStartCycNum = dwCurCycleNum; /*ý·ʱʼں*/ + } + else if ((ROUTE_STATE_NEAR_LOCKERR == routeState) || (ROUTE_STATE_AUTO_UNLOCKERR == routeState)|| (ROUTE_STATE_FIRST_LOCKERR == routeState)) + { /*ӽ쳣Զ쳣+·쳣*/ + + RouteDataStru[bufIndex].DelayUnlockStartCycNum = 0u; /*·ʱʼں*/ + } + else + {/**/ + } + + if ((ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState)) + { /*Ԥȿ||ӽ||*/ + + RouteDataStru[bufIndex].RepeatOpenFlag = ROUTE_REPEATOPEN_SET_NO; /*·źؿ־*/ + } + + if (ROUTE_STATE_HALF_UNLOCKDELAY == routeState) + { /*гȫպ󣬻гʧͨź󵹼ʱʼ״̬*/ + if (0U == RouteDataStru[bufIndex].dwFirstElockStartCycNum) + { + RouteDataStru[bufIndex].dwFirstElockStartCycNum = dwCurCycleNum; /*ý·һյ߼ʱιʼں*/ + } + else + { + ; /*Чٸ£ֹظˢں*/ + } + + /*⣻ý·״̬ʹõǴ˺ò*/ + SetRouFirDelayErlockStaCycNum(routeId,dwCurCycleNum); + } + + RouteDataStru[bufIndex].RoutePreState = RouteDataStru[bufIndex].RouteState;/*浱ǰ·״̬*/ + RouteDataStru[bufIndex].RouteState = routeState; /*·״̬*/ + + if ((ROUTE_STATE_AUTO_UNLOCK==RouteDataStru[bufIndex].RoutePreState) || (ROUTE_STATE_AUTO_UNLOCKERR== RouteDataStru[bufIndex].RoutePreState)) + { + /*·֮ǰԶԶ쳣ҽ·ǰԶԶ쳣*/ + if ((ROUTE_STATE_AUTO_UNLOCK != routeState) && (ROUTE_STATE_AUTO_UNLOCKERR != routeState)) + { + RouteDataStru[bufIndex].RouteLockStartCycNum = 0U; + } + } + + if ((ROUTE_STATE_FIRST_LOCK == routeState) || (ROUTE_STATE_FIRST_LOCKERR == routeState) + || (ROUTE_STATE_YUXIAN_LOCK == routeState) || (ROUTE_STATE_YUXIAN_OPEN == routeState) + || (ROUTE_STATE_NEAR_LOCK == routeState) || (ROUTE_STATE_NEAR_LOCKERR == routeState) || (ROUTE_STATE_NEAR_OPEN == routeState) + || (ROUTE_STATE_LEAD_LOCK == routeState) || (ROUTE_STATE_LEAD_LOCKERR == routeState) || (ROUTE_STATE_LEAD_OPEN == routeState) + || (ROUTE_STATE_HALF_LOCK == routeState)) + { + RouteDataStru[bufIndex].XuanPaiStartCycNum = 0U; + /*ý·ʼں*/ + if (0U == RouteDataStru[bufIndex].RouteLockStartCycNum) + { + RouteDataStru[bufIndex].RouteLockStartCycNum = dwCurCycleNum; + } + } + } + + + + return retVal; +} + +/* +* ȡָID·ල仯ں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ල仯ں +* by cgh 20240325 +*/ +UINT32 GetRouteLevelChangeCyc(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RouteLevelChangeCyc; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ල +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ල +*/ +UINT8 GetRouteLevel(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RouteLevel; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·ල +* ˵ const UINT16 routeId, ·ID +* const UINT8 routeLevel, · +* ֵ +* +*/ +void SetRouteLevel(const UINT16 routeId, const UINT8 routeLevel) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT32 dwCurCyc = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + + if ((ROUTE_LEVEL_CBTC == routeLevel) || (ROUTE_LEVEL_BLOC == routeLevel)) + { + RouteDataStru[bufIndex].RoutePreLevel = RouteDataStru[bufIndex].RouteLevel;/*浱ǰ·ල*/ + RouteDataStru[bufIndex].RouteLevel = routeLevel; /*·*/ + } + else + { + /**/ + } + + if (routeLevel == (UINT8)(~RouteDataStru[bufIndex].RoutePreLevel)) + { + dwCurCyc = Get2oo2CurCycleNum(); + RouteDataStru[bufIndex].RouteLevelChangeCyc = dwCurCyc;/*·ල仯ں*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + +/* +* ȡָID·ӦԶ·ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զ·ID +*/ +UINT16 GetRouteAutoRouteId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].AutoRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·Զ۷·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զ·״̬ +*/ +UINT16 GetRouteAutoReturnId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].AutoReturnId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + + + +/* +* ָID·Զ۷·Id +* ˵ const UINT16 routeId, ·ID +* const UINT8 autoRouteState, Զ·״̬ +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ݳɹ +*/ +UINT8 SetRouteAutoReturnId(const UINT16 routeId, const UINT16 autoDataId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 autoRouteProperty = GetRouteAutoRouteProperty(routeId); + RouteDataStruct *routeDataStru = GetRouteData(); + UINT8 retVal = CI_SUCCESS; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if (0u == autoDataId) + { + routeDataStru[bufIndex].AutoReturnId = 0u; /*ȡԶ·״̬*/ + + retVal = CI_SUCCESS; + } + else if ((autoRouteProperty == ROUTE_AUTOROUTE_PROPERTY_YES) && + (routeDataStru[bufIndex].AutoRouteId == 0u) && + (routeDataStru[bufIndex].AutoReturnId == 0u)&& + (routeDataStru[bufIndex].AllAutoReturnId == 0u)) + { + /*Զ۷Զ·ͬʱ*/ + routeDataStru[bufIndex].AutoReturnId = autoDataId; /*Զ·״̬*/ + + retVal = CI_SUCCESS; + } + else + { + /*routeDataStru[bufIndex].AutoReturnId = 0u;*/ /*Զ·״̬*/ + + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ԶźʧЧ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ԶźʧЧ״̬ +*/ +UINT8 GetRouteAutoSigLoseEfficacyFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 autoSigPropertyLoseEfficacyFlag = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + autoSigPropertyLoseEfficacyFlag = RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag; + } + else + { + autoSigPropertyLoseEfficacyFlag = CI_ERROR; + } + return autoSigPropertyLoseEfficacyFlag; +} + + +/* +* ָID·ԶźʧЧ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 autoSigPropertyLoseEfficacyFlag, ·ԶźʧЧñ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteAutoSigLoseEfficacyFlag(const UINT16 routeId, const UINT8 autoSigPropertyLoseEfficacyFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + UINT8 curLoseEfficacyFlag = 0u; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = CI_SUCCESS; + curLoseEfficacyFlag = RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag; + if (ROUTE_AUTOSIG_LOSE_DSSET_YES == autoSigPropertyLoseEfficacyFlag) + { + if(ROUTE_AUTOSIG_LOSE_SET_INVALID == curLoseEfficacyFlag) + {/*ָ·߱"Զź"ԶźʧЧ־䲻*/ + retVal = CI_ERROR; + } + else if ((ROUTE_AUTOSIG_LOSE_REVSET_YES == curLoseEfficacyFlag) || (ROUTE_AUTOSIG_LOSE_REVDSSET_YES == curLoseEfficacyFlag)) + { + /*ǰѱùʧЧ־ʱҪóɷ·Ͷ˿ʧЧ־*/ + RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_REVDSSET_YES; /*ԶźʧЧ־*/ + retVal = CI_SUCCESS; + } + else + {/*δùʧЧ־*/ + RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_DSSET_YES; /*ԶźʧЧ־*/ + retVal = CI_SUCCESS; + } + } + else if (ROUTE_AUTOSIG_LOSE_DSSET_NO == autoSigPropertyLoseEfficacyFlag) + { + if(ROUTE_AUTOSIG_LOSE_SET_INVALID == curLoseEfficacyFlag) + {/*ָ·߱"Զź"ԶźʧЧ־䲻*/ + retVal = CI_ERROR; + } + else if ((ROUTE_AUTOSIG_LOSE_DSSET_YES == curLoseEfficacyFlag) || (ROUTE_AUTOSIG_LOSE_SET_NO == curLoseEfficacyFlag)) + { + /*ǰֻΪ˿ùʧЧ־Ч*/ + RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_SET_NO; /*ԶźЧ־*/ + retVal = CI_SUCCESS; + } + else + {/*ǰ·ùԶźʧЧ־*/ + RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_REVSET_YES; /*ԶźʧЧ־*/ + retVal = CI_SUCCESS; + } + } + else if (ROUTE_AUTOSIG_LOSE_REVSET_YES == autoSigPropertyLoseEfficacyFlag) + { + if(ROUTE_AUTOSIG_LOSE_SET_INVALID == curLoseEfficacyFlag) + {/*ָ·߱"Զź"ԶźʧЧ־䲻*/ + retVal = CI_ERROR; + } + else if ((ROUTE_AUTOSIG_LOSE_DSSET_YES == curLoseEfficacyFlag) || (ROUTE_AUTOSIG_LOSE_REVDSSET_YES == curLoseEfficacyFlag)) + { + /*ǰѱùʧЧ־ʱҪóɷ·Ͷ˿ʧЧ־*/ + RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_REVDSSET_YES; /*ԶźʧЧ־*/ + retVal = CI_SUCCESS; + } + else + {/*δùʧЧ־*/ + RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_REVSET_YES; /*ԶźʧЧ־*/ + retVal = CI_SUCCESS; + } + } + else if (ROUTE_AUTOSIG_LOSE_SET_NO == autoSigPropertyLoseEfficacyFlag) + { + if(ROUTE_AUTOSIG_LOSE_SET_INVALID == curLoseEfficacyFlag) + {/*ָ·߱"Զź"ԶźʧЧ־䲻*/ + retVal = CI_ERROR; + } + else if ((ROUTE_AUTOSIG_LOSE_REVSET_YES == curLoseEfficacyFlag) || (ROUTE_AUTOSIG_LOSE_SET_NO == curLoseEfficacyFlag)) + { + /*ǰֻΪ·ùʧЧ־Ч*/ + RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_SET_NO; /*ԶźЧ־*/ + retVal = CI_SUCCESS; + } + else + {/*ǰΪ˿ùԶźʧЧ־*/ + RouteDataStru[bufIndex].AutoSigPropertyLoseEfficacyFlag = ROUTE_AUTOSIG_LOSE_DSSET_YES; /*ԶźʧЧ־*/ + retVal = CI_SUCCESS; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + + } + + return retVal; +} + + +/* +* ȡָID·Զ·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_AUTOROUTE_NONE 0x01 Զ + ROUTE_AUTOROUTE_NORMAL 0x02 ͨԶ· + ROUTE_AUTOROUTE_RETURN 0x03 Զ۷· + ROUTE_AUTOROUTE_ERROR 0xFF Զ +*/ +UINT8 GetRouteAutoRouteSetState(const UINT16 routeId) +{ + UINT16 const autoRouteId = GetRouteAutoRouteId(routeId); + UINT16 const autoReturnId = GetRouteAutoReturnId(routeId); + UINT16 const allAutoReturnId = GetRouteAllAutoReturnId(routeId); + UINT8 retVal = 0u; + if (((0u < autoRouteId) && ((0u < autoReturnId)||(0u < allAutoReturnId)))||((0u < autoReturnId )&&(0u < allAutoReturnId ))) + { + retVal = ROUTE_AUTOROUTE_ERROR; + } + else if ((0u < autoRouteId ) && (0u ==autoReturnId)&&(0u == allAutoReturnId )) + { + retVal = ROUTE_AUTOROUTE_NORMAL; + } + else if ((0u ==autoRouteId ) && (0u < autoReturnId)&&(0u == allAutoReturnId)) + { + retVal = ROUTE_AUTOROUTE_RETURN; + } + else if ((0u == autoRouteId) && (0u < allAutoReturnId)&& (0u ==autoReturnId )) + { + retVal = ROUTE_ALLAUTOROUTE_RETURN; + } + else + { + retVal = ROUTE_AUTOROUTE_NONE; + } + return retVal; +} + +/* +* ȡָID·Զź״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_AUTOSIGROUTE_YES 0xaa ·ԶźŽ· + ROUTE_AUTOSIGROUTE_NO 0x55 ·ԶźŽ· +*/ +UINT8 GetRouteAutoSigSetState(const UINT16 routeId) +{ + UINT8 autoSigRouteState = 0u; + UINT8 autoSigProperty = GetRouteAutoSigProperty(routeId);/*ȡ·Զź*/ + UINT8 autoSigPropertyLoseEfficacyFlag = GetRouteAutoSigLoseEfficacyFlag(routeId);/*ȡ·ԶźʧЧ־*/ + if(ROUTE_AUTOSIG_PROPERTY_YES == autoSigProperty) + { + if(ROUTE_AUTOSIG_LOSE_SET_NO == autoSigPropertyLoseEfficacyFlag) + { + autoSigRouteState = ROUTE_AUTOSIGROUTE_YES; + } + else + { + autoSigRouteState = ROUTE_AUTOSIGROUTE_NO; + } + + } + else + { + autoSigRouteState = ROUTE_AUTOSIGROUTE_NO; + } + return autoSigRouteState; + +} + +/* +* ָID·Զ·Id +* ˵ const UINT16 routeId, ·ID +* const UINT8 autoDataId, Զ·ID +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ݳɹ +*/ +UINT8 SetRouteAutoRouteId(const UINT16 routeId, const UINT16 autoDataId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 autoRouteProperty = GetRouteAutoRouteProperty(routeId); + UINT8 retVal = CI_SUCCESS; + + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if (autoDataId == 0u) + { + RouteDataStru[bufIndex].AutoRouteId = 0u; /*ȡԶ·״̬*/ + + retVal = CI_SUCCESS; + } + else if ((autoRouteProperty == ROUTE_AUTOROUTE_PROPERTY_YES) && + (RouteDataStru[bufIndex].AutoReturnId == 0u) && + (RouteDataStru[bufIndex].AutoRouteId == 0u)&& + (RouteDataStru[bufIndex].AllAutoReturnId == 0u)) + { + /*Զ۷Զ·ͬʱ*/ + RouteDataStru[bufIndex].AutoRouteId = autoDataId; /*Զ·״̬*/ + SetRouteLgcSecShareFlag(routeId, LOGIC_SECTION_RES_SHARE_YES); + + retVal = CI_SUCCESS; + } + else + { + /*RouteDataStru[bufIndex].AutoRouteId = 0;*/ /*Զ·״̬*/ + + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ѡʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetRouteXuanPaiStartCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].XuanPaiStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·ѡʼں +* ˵ const UINT16 routeId, ·ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetRouteXuanPaiStartCycNum(const UINT16 routeId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].XuanPaiStartCycNum = startCycNum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָID·źſʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetRouteOpenSigStatrtCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RouteOpenSigStatrtCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* 趨ָID·źſʼں +* ˵ const UINT16 routeId, ·ID +* ֵ +* +*/ +void SetRouteOpenSigStartCycNum(const UINT16 routeId, const UINT32 signalOpenStartCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].RouteOpenSigStatrtCycNum = signalOpenStartCycNum; /*·ڷźſʼں*/ + + } + else + { + /**/ + } +} + + +/* +* ȡָID·ʱʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʽʱʼں +*/ +UINT32 GetRouteDelayUnlockStartCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].DelayUnlockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID··ڷźſʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ڷźſʼں +*/ +UINT32 GetRouteLeadFaultOpenStartCyc(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].LeadFaultOpenStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID··ڷźſʼں +* ˵ const UINT16 routeId, ·ID +* const UINT32 faultOpenStartCycNum, ·ڷźſʼں +* ֵ +* +*/ +void SetRouteLeadFaultOpenStartCyc(const UINT16 routeId, const UINT32 faultOpenStartCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].LeadFaultOpenStartCycNum = faultOpenStartCycNum; /*·ڷźſʼں*/ + } + else + { + /**/ + } +} + + +/* +* ȡָID·ʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetRouteLockStartCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RouteLockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡ·Overlapʼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetOverlapLockStartCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].OverlapLockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ý·Overlapʼ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockFlag, ձ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetOverlapLockStartCycNum(const UINT16 routeId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 overlapSum = 0u; + UINT8 retVal = CI_SUCCESS; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + overlapSum = GetRouteOverlapSum(routeId); + if ((overlapSum > 0u) && (overlapSum <= ROUTE_PROTECTSECGROUP_SUM_MAX)) + { + RouteDataStru[bufIndex].OverlapLockStartCycNum = startCycNum; /*·ڷźſʼں*/ + } + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡ·OverlapID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȡ״̬ +*/ +UINT16 GetRouteOverlapLockedId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].OverlapLockedId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡ·Overlapձ־ +* ˵ const UINT16 routeId, ·ID +* ֵ + ROUTE_OVERLAP_SET_NO 0x55 δ + ROUTE_OVERLAP_SET_YES 0xaa + ROUTE_OVERLAP_SET_NULL 0xff ޱ +*/ +UINT8 GetRouteOverlapLockFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + /*··*/ + UINT8 overlapSum = GetRouteOverlapSum(routeId); + UINT16* pOverlapIdBuf = GetRouteOverlapIdBuf(routeId); + UINT8 ii = 0u; + UINT8 retVal = ROUTE_OVERLAP_SET_NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex >= ROUTE_SUM_MAX) + { + retVal = ROUTE_OVERLAP_SET_NULL; + } + else + { + if (overlapSum > 0u) + { + for (ii = 0u; ii < overlapSum; ii++) + { + if (pOverlapIdBuf[ii] == RouteDataStru[bufIndex].OverlapLockedId) + { + /**/ + retVal = ROUTE_OVERLAP_SET_YES; + break; + } + } + if(ii == overlapSum) + { + /*δ*/ + retVal = ROUTE_OVERLAP_SET_NO; + } + + } + else + { + /*ûб·*/ + retVal = ROUTE_OVERLAP_SET_NULL; + } + } + return retVal; + +} + +/* +* ý·OverlapID +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockFlag, ձ־ +* ֵ void +*/ +void SetRouteOverlapLockedId(const UINT16 routeId, const UINT16 OverlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + /*··*/ + UINT8 const overlapSum = GetRouteOverlapSum(routeId); + UINT16* const pOverlapIdBuf = GetRouteOverlapIdBuf(routeId); + UINT8 ii = 0u; + UINT8 retVal = CI_SUCCESS; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + + if (bufIndex >= ROUTE_SUM_MAX) + { + retVal = CI_ERROR; + } + else + { + if (overlapSum > 0u) + { + if (OverlapId == 0u) + { + /*ȡOverlap*/ + RouteDataStru[bufIndex].OverlapLockedId = OverlapId; + retVal = CI_SUCCESS; + } + else + { + /*Overlap*/ + for (ii = 0u; ii < overlapSum; ii++) + { + if (pOverlapIdBuf[ii] == OverlapId) + { + RouteDataStru[bufIndex].OverlapLockedId = OverlapId; /*·overlapձ־*/ + retVal = CI_SUCCESS; + break; + } + } + if(ii == overlapSum) + { + retVal = CI_ERROR; + } + + } + } + else + { + retVal = CI_ERROR; + } + } + if(CI_ERROR == retVal) + { + debug_infor_printf((const)"SetRouteOverlapLockedId ERROR routeId:%d OverlapId: %d\n", routeId, OverlapId); + } +} + + +/* +* ȡָID·ȡ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȡ״̬ +*/ +UINT8 GetRouteZongQuXiaoFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].ZongQuXiaoFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·ȡ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 cancelState, ȡ״̬ +* ֵ void +*/ +void SetRouteZongQuXiaoFlag(const UINT16 routeId, const UINT8 cancelState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_ZONGQUXIAO_SET_NO == cancelState) || (ROUTE_ZONGQUXIAO_SET_YES == cancelState)) + { + + RouteDataStru[bufIndex].ZongQuXiaoFlag = cancelState; /*·ȡ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + if (CI_ERROR == retVal) + { + debug_infor_printf((const)"SetRouteZongQuXiaoFlag ERROR, RouteId:%d, cancelState:%d\n", routeId,cancelState); + } +} + + +/* +* ȡָID·˽״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ˽״̬ +*/ +UINT8 GetRouteZongRenJieFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].ZongRenJieFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·˽״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 cancelState, ˽״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteZongRenJieFlag(const UINT16 routeId, const UINT8 cancelState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_ZONGRENJIE_SET_NO == cancelState) || (ROUTE_ZONGRENJIE_SET_YES == cancelState)) + { + RouteDataStru[bufIndex].ZongRenJieFlag = cancelState; /*·˽״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·ؿ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ؿ״̬ +*/ +UINT8 GetRouteRepeatOpenFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RepeatOpenFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·ؿ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 repeatOpenFlag, ؿ־ +* ֵ +* +*/ +void SetRouteRepeatOpenFlag(const UINT16 routeId, const UINT8 repeatOpenFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_REPEATOPEN_SET_NO == repeatOpenFlag) || (ROUTE_REPEATOPEN_SET_YES == repeatOpenFlag)) + { + + RouteDataStru[bufIndex].RepeatOpenFlag = repeatOpenFlag; /*·źؿ״̬*/ + + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָID·ֹͣ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֹͣ״̬ +*/ +UINT8 GetRouteStopCheckFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].StopCheckFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·ֹͣ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 stopCheckState, ֹͣ״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteStopCheckFlag(const UINT16 routeId, const UINT8 stopCheckState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_STOPCHECK_SET_NO == stopCheckState) || (ROUTE_STOPCHECK_SET_YES == stopCheckState)) + { + RouteDataStru[bufIndex].StopCheckFlag = stopCheckState; /*·ֹͣ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID··ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetRouteBelongLongRouteId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].BelongLongRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID··ID +* ˵ const UINT16 routeId, ·ID +* const UINT16 belongLongRouteId, ·ID +* ֵ +* +*/ +void SetRouteBelongLongRouteId(const UINT16 routeId, const UINT16 belongLongRouteId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].BelongLongRouteId = belongLongRouteId; /*··ID*/ + } + else + { + /**/ + } +} + + +/* +* ·״̬ЧԼ +* ˵ const UINT8 routeState, ·״̬ +* ֵ 0: Ч +* 1: Ч +*/ +UINT8 RouteStateValidCheck(const UINT8 routeState) +{ + UINT8 retVal = CI_SUCCESS; + if ((ROUTE_STATE_IDLE == routeState) || + (ROUTE_STATE_FIRST_XUANPAI == routeState) || + (ROUTE_STATE_XUANPAI ==routeState) || + (ROUTE_STATE_FIRST_LOCK == routeState) || + (ROUTE_STATE_FIRST_LOCKERR == routeState) || + (ROUTE_STATE_YUXIAN_LOCK == routeState) || + (ROUTE_STATE_YUXIAN_OPEN == routeState) || + (ROUTE_STATE_NEAR_LOCK == routeState) || + (ROUTE_STATE_NEAR_LOCKERR == routeState) || + (ROUTE_STATE_NEAR_OPEN == routeState) || + (ROUTE_STATE_DELAY_UNLOCK == routeState) || + (ROUTE_STATE_AUTO_UNLOCK == routeState) || + (ROUTE_STATE_AUTO_UNLOCKERR == routeState) || + (ROUTE_STATE_LEAD_FIRST_XUANPAI == routeState) || + (ROUTE_STATE_LEAD_XUANPAI == routeState) || + (ROUTE_STATE_LEAD_LOCK == routeState) || + (ROUTE_STATE_LEAD_LOCKERR == routeState) || + (ROUTE_STATE_LEAD_OPEN == routeState) || + (ROUTE_STATE_HALF_FIRST_XUAN == routeState) || + (ROUTE_STATE_HALF_XUANPAI == routeState) || + (ROUTE_STATE_HALF_LOCK == routeState) || + (ROUTE_STATE_HALF_UNLOCK == routeState) || + (ROUTE_STATE_HALF_UNLOCKDELAY == routeState)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDͨ·ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT16 GetRouteThroughRouteId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if ((bufIndex < ROUTE_SUM_MAX) && + (GetConfigRouteType(routeId) == ROUTE_TYPE_RETURN)) + { + retVal = RouteDataStru[bufIndex].ThroughRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָID·ȫԶ۷·Id +* ˵ const UINT16 routeId, ·ID +* const UINT16 autoDataId, ȫԶ·Id +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ݳɹ +*/ +UINT8 SetRouteAllAutoReturnId(const UINT16 routeId, const UINT16 autoDataId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 autoRouteProperty = GetRouteAutoRouteProperty(routeId); + RouteDataStruct *routeDataStru = GetRouteData(); + UINT8 returnValue = CI_ERROR; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if (0u == autoDataId) + { + routeDataStru[bufIndex].AllAutoReturnId = 0u; /*ȡԶ·״̬*/ + + returnValue = CI_SUCCESS; + } + else if ((autoRouteProperty == ROUTE_AUTOROUTE_PROPERTY_YES) && + (routeDataStru[bufIndex].AutoRouteId == 0u) && + (routeDataStru[bufIndex].AutoReturnId == 0u)&& + (routeDataStru[bufIndex].AllAutoReturnId == 0u)) + { + /*ȫԶ۷/Զ۷/Զ·ͬʱ*/ + routeDataStru[bufIndex].AllAutoReturnId = autoDataId; /*ȫԶ·״̬*/ + + returnValue = CI_SUCCESS; + } + else + { + /*routeDataStru[bufIndex].AutoReturnId = 0u;*/ /*Զ·״̬*/ + + returnValue = CI_ERROR; + } + } + + return returnValue; +} +/* +* ȡָID·ȫԶ۷·ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȫԶ۷·id +*/ +UINT16 GetRouteAllAutoReturnId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 allAutoReturnId = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + allAutoReturnId = RouteDataStru[bufIndex].AllAutoReturnId; + } + + return allAutoReturnId; +} + + +/* +* ȡָID·֤ͣ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* 1: ȡݳɹ +*/ +UINT8 GetRouteStopensureFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 stopensureFlag = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + stopensureFlag = RouteDataStru[bufIndex].StopensureFlag; + } + + return stopensureFlag; + +} + +/* +* ָID·֤ͣ־ +* ˵ const UINT16 routeId, ·ID +* ֵ +* +*/ +void SetRouteStopensureFlag(const UINT16 routeId, const UINT8 stopensureFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_STOPENSURE_YES == stopensureFlag) || (ROUTE_STOPENSURE_NO == stopensureFlag)) + { + + RouteDataStru[bufIndex].StopensureFlag = stopensureFlag; /*֤ͣ־*/ + + } + } +} + +/* +* ȡָID·Դȡ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* 1: ȡݳɹ +*/ +UINT8 GetRouteResourceCancelFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 resourcecancelFlag = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + resourcecancelFlag = RouteDataStru[bufIndex].ResourcecancelFlag; + } + + return resourcecancelFlag; + +} +/* +* ָID·Դȡ־ +* ˵ const UINT16 routeId, ·ID +* ֵ +* +*/ +void SetRouteResourceCancelFlag(const UINT16 routeId, const UINT8 resourcecancelFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_RESOURCECANCEL_YES == resourcecancelFlag) || (ROUTE_RESOURCECANCEL_NO == resourcecancelFlag)) + { + + RouteDataStru[bufIndex].ResourcecancelFlag = resourcecancelFlag; /*Դȡ־*/ + + } + } +} + +#if 0 +/* +* ȡָ·ʼIDźŻSPKSرձ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: SPKSźŹرձ־ +*/ +UINT8 GetSPKSToRouteCloseFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + reVal = RouteDataStru[bufIndex].SPKSToRouteCloseFlag; + } + return reVal; +} + + +/* +* ָ·ʼIDźŻSPKSرձ־ +* ˵ const UINT16 routeId, ·ID + const UINT8 closeFlag, SPKSźŹرձ־ +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 SetSPKSToRouteCloseFlag(const UINT16 routeId,const UINT8 closeFlag) +{ + UINT16 bufIndex = 0u; + UINT8 reVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].SPKSToRouteCloseFlag = closeFlag; + reVal = CI_SUCCESS; + } + + return reVal; +} +#endif + +/* +* ȡָID·ֹּͣ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֹּͣ״̬ +*/ +UINT8 GetRouteStopKeepCheckFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].StopKeepCheckFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·ֹּͣ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 stopKeepCheckState, ֹּͣ״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteStopKeepCheckFlag(const UINT16 routeId, const UINT8 stopKeepCheckState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_STOPCHECK_SET_NO == stopKeepCheckState) || (ROUTE_STOPCHECK_SET_YES == stopKeepCheckState)) + { + RouteDataStru[bufIndex].StopKeepCheckFlag = stopKeepCheckState; /*·ֹּͣ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·״̬ +* ˵ const UINT16 routeId, ·ID +* UINT8 *pRouteAssoSwitSingOperStat ·״̬ +* ֵ +* +*/ +void GetRoutAssoSwitSingOperStat(const UINT16 routeId, UINT8 *pRouteAssoSwitSingOperStat) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if(NULL != pRouteAssoSwitSingOperStat) + { + if (bufIndex < ROUTE_SUM_MAX) + { + *pRouteAssoSwitSingOperStat = RouteDataStru[bufIndex].RouteAssoSwitSingOperStat; + } + + } +} + +/* +* ָID·״̬ +* ˵ const UINT16 routeId, ·ID +* UINT8 RouteAssoSwitSingOperStat ״̬ +* ֵ +* +*/ +void SetRoutAssoSwitSingOperStat(const UINT16 routeId, UINT8 RouteAssoSwitSingOperStat) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].RouteAssoSwitSingOperStat = RouteAssoSwitSingOperStat; + } + +} + +/* +* ȡָID·״̬־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬־ +*/ +UINT8 GetRouteStateFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RouteStateFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·״̬־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 routeLevel, ·״̬־ +* ֵ void +*/ +void SetRouteStateFlag(const UINT16 routeId, const UINT8 routeStateFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].RouteStateFlag = routeStateFlag; /*·״̬־*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + if (CI_ERROR == retVal) + { + debug_infor_printf((const)"SetRouteStateFlag ERROR, RouteId:%d , routeStateFlag: %d \n", routeId, routeStateFlag); + } +} + +#if 0 +/* +* ָ·SPKSָҪؿźű־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, SPKSָҪؿźű־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteSpksReOpenSigFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_SPKS_RE_OPEN_SIG_YES == flag) || (ROUTE_SPKS_RE_OPEN_SIG_NO == flag)) + { + RouteDataStru[bufIndex].SpksReOpenSigFlag = flag; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָ·Ŀ۳ָҪؿźű־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, ۳ָҪؿźű־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteDetainReOpenSigFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_DETAIN_RE_OPEN_SIG_YES == flag) || (ROUTE_DETAIN_RE_OPEN_SIG_NO == flag)) + { + RouteDataStru[bufIndex].DetainReOpenSigFlag = flag; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ·SPKSָҪؿźű־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·SPKSָҪؿźű־ +*/ +UINT8 GetRouteSpksReOpenSigFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].SpksReOpenSigFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ·Ŀ۳ָҪؿźű־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0:ȡʧ +* >0:·Ŀ۳ָҪؿźű־ +*/ +UINT8 GetRouteDetainReOpenSigFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].DetainReOpenSigFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·Ŀ۳źŹرձ־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, ۳źŹرձ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteDetainCloseFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_DETAIN_CLOSE_SIG_YES == flag) || (ROUTE_DETAIN_CLOSE_SIG_NO == flag)) + { + RouteDataStru[bufIndex].DetainToRouteCloseFlag = flag; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ·Ŀ۳źŹرձ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·Ŀ۳źŹرձ־ +*/ +UINT8 GetRouteDetainToRouteCloseFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].DetainToRouteCloseFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +#endif + +/* +* ָ·гʻ·־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, гʻ·־ +* ֵ +* +*/ +void SetRouteTrainEnterFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_TRAIN_ENTER_FLAG_YES == flag) || (ROUTE_TRAIN_ENTER_FLAG_NO == flag)) + { + RouteDataStru[bufIndex].TrainEnterFlag = flag; + + } + else + { + /**/ + } + } + else + { + /**/ + } +} +/* +* ȡָ·гʻ·־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·гʻ·־ +*/ +UINT8 GetRouteTrainEnterFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].TrainEnterFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·˽ʱ +* ˵ const UINT16 routeId, ·ID +* const UINT32 delayType, ˽ʱ +* ֵ +* +*/ +void SetRouteZongRenJieDelayType(const UINT16 routeId, const UINT8 delayType) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_ZRJ_DELAY_TYPE_IDLE == delayType) || (ROUTE_ZRJ_DELAY_TYPE_ALL_EXP == delayType) || (ROUTE_ZRJ_DELAY_TYPE_EXP_TO_OCCUPY == delayType) || (ROUTE_ZRJ_DELAY_TYPE_INVALID == delayType)) + { + RouteDataStru[bufIndex].ZongRenJieDelayType = delayType; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + +/* +* ָ·ȡʱ־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 delayflag, ȡʱ־ +* ֵ +* +*/ +void SetRouteZongQuXiaoDelayFlag(const UINT16 routeId, const UINT8 delayflag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_ZQX_DELAY_YES == delayflag) || (ROUTE_ZQX_DELAY_NO == delayflag)) + { + RouteDataStru[bufIndex].CancleDelayflag = delayflag; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + +/* +* ȡָ·ȡʱ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ȡ־ +*/ +UINT8 GetRouteZongQuXiaoDelayFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].CancleDelayflag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ·˽ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·˽ʱ +*/ +UINT8 GetRouteZongRenJieDelayType(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].ZongRenJieDelayType; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·SPKSPSD۳ָؿźű־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, ˽ʱ +* ֵ +* +*/ +void SetRouteRecoverState(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_RECOVER_STA_INIT == flag) || (ROUTE_RECOVER_STA_WAIT == flag) || (ROUTE_RECOVER_STA_STAY == flag)) + { + RouteDataStru[bufIndex].RecoverOpenState = flag; + + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָ·SPKSPSD۳ָؿźű־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: SPKSPSD۳ָؿźű־ +*/ +UINT8 GetRouteRecoverOpenFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RecoverOpenState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·гǷʻý·־ñ־;۷ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag, гǷʻý·־ +* ֵ +* +*/ +void SetTrainEnterRouteFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((TRAIN_ENTER_ROUTE_FLAG_YES == flag) || (TRAIN_ENTER_ROUTE_FLAG_NO == flag)) + { + RouteDataStru[bufIndex].TrainEnterRouteFlag = flag; + } + else + { + /**/ + } + } + else + { + /**/ + } +} +/* +* ȡָ·гǷʻý·־ñ־;۷ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·гǷʻý·־ +*/ +UINT8 GetTrainEnterRouteFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].TrainEnterRouteFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·ձID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ձID +*/ +UINT16 GetRouteAtsExpLkOverlapId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].atsExptLkOverlapId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·ձID +* ˵ const UINT16 routeId, ·ID +* const UINT16 expLkOverlapId, atsֵط͵ձId +* ֵ +* +*/ +void SetRouteAtsExpLkOverlapId(const UINT16 routeId, const UINT16 expLkOverlapId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if ((bufIndex < ROUTE_SUM_MAX) && (UINT16_MAX != expLkOverlapId)) + { + RouteDataStru[bufIndex].atsExptLkOverlapId = expLkOverlapId; /*atsֵط͵ձID*/ + } + else + { + /**/ + } +} + + +/* +* ȡ·UT +* ˵ const UINT16 routeId,·ID +* ֵ 0: ʧ +* : +*/ +UINT16 GetOtherCIRouteOvlpUTUnlockCnt(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].OtherCIRouteOvlpUTUnlockCount; + } + return retVal; +} + +/* +* ·UT +* ˵ const UINT16 routeId, ·ID +* const UINT16 count, ·ν +* ֵ +* +*/ +void SetOtherCIRouteOvlpUTUnlockCnt(const UINT16 routeId,const UINT16 count) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (bufIndex < ROUTE_SUM_MAX) + { + if (count != RouteDataStru[bufIndex].OtherCIRouteOvlpUTUnlockCount) + { + RouteDataStru[bufIndex].OtherCIRouteOvlpUTUnlockCount = count; + } + } +} + +/* +* ȡ·CT +* ˵ const UINT16 routeId,·ID +* ֵ 0: ʧ +* : +*/ +UINT16 GetOtherCIRouteOverlapCTUnlockCount(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].OtherCIRouteOvlpCTUnlockCount; + } + return retVal; +} + +/* +* ·CT +* ˵ const UINT16 routeId, ·ID +* const UINT16 count, ·ν +* ֵ +* +*/ +void SetOtherCIRouteOverlapCTUnlockCount(const UINT16 routeId,const UINT16 count) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (bufIndex < ROUTE_SUM_MAX) + { + if (count != RouteDataStru[bufIndex].OtherCIRouteOvlpCTUnlockCount) + { + RouteDataStru[bufIndex].OtherCIRouteOvlpCTUnlockCount = count; + } + } +} + + +/* +* ָ·迪Ųʱؿźű־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, ؿźű־ +* ֵ +* +*/ +void SetRouteNeedOpenReopenFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + if ((ROUTE_NEEDOPEN_REOPEN_NO == flag) || (ROUTE_NEEDOPEN_REOPEN_YES == flag) ) + { + RouteDataStru[bufIndex].NeedOpenNotTrueRepeatFlag = flag; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָ·迪Ųʱؿźű־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ؿźű־ +*/ +UINT8 GetRouteNeedOpenReopenFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].NeedOpenNotTrueRepeatFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID·迪ŲʱʼźŻؿʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ؿʼں +*/ +UINT32 GetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].NeedOpenNotTrueRepeatStartCount; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* 趨ָID·迪ŲʱʼźŻؿʼں +* ˵ const UINT16 routeId, ·ID +* const UINT32 signalOpenStartCycNum źſʼ +* ֵ +* +*/ +void SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(const UINT16 routeId, const UINT32 signalOpenStartCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].NeedOpenNotTrueRepeatStartCount = signalOpenStartCycNum; + } + else + { + /**/ + } +} + + +/* +* ָ·ĵ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT32 dcqState, ״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteDCQState(const UINT16 routeId, const UINT8 dcqState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_DCQ_REQUEST == dcqState) || (ROUTE_DCQ_NOT_REQUEST == dcqState) ) + { + RouteDataStru[bufIndex].DCQState = dcqState; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ·ĵ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetRouteDCQState(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].DCQState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·ĵͬ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT32 dcTyState, ״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteDCTYState(const UINT16 routeId, const UINT8 dcTyState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_DCT_AGREE == dcTyState) || (ROUTE_DCT_NOT_AGREE == dcTyState) ) + { + RouteDataStru[bufIndex].DCTYState = dcTyState; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ·ĵͬ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͬ״̬ +*/ +UINT8 GetRouteDCTYState(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].DCTYState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָ·ĵͬⲻźؿ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͬؿ־ +*/ +UINT8 GetRouteDCTYNotSatisfySignalReOpenFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].DCTYNotSatisfySignalReOpenFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·ĵͬⲻźؿ־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 dcTyState, ͬؿ־ +* ֵ +* +*/ +void SetRouteDCTYNotSatisfySignalReOpenFlag(const UINT16 routeId, const UINT8 dcTyFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_DCTY_REOPEN == dcTyFlag) || (ROUTE_DCTY_REOPEN_NO == dcTyFlag) ) + { + RouteDataStru[bufIndex].DCTYNotSatisfySignalReOpenFlag = dcTyFlag; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָ·ĵͬʼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͬʼ +*/ +UINT32 GetRouteDCTYNotSatisfyStartCnt(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].DCTYNotSatisfyStartCount; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·ĵͬⲻʼ +* ˵ const UINT16 routeId, ·ID +* const UINT32 dcTyState, ͬʼ +* ֵ +* +*/ +void SetRouteDCTYNotSatisfyStartCnt(const UINT16 routeId, const UINT32 dcTyCount) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].DCTYNotSatisfyStartCount = dcTyCount; + } + else + { + /**/ + } +} +/* +* ָʽ·նźŻ״̬鲻ͨźű̿״̬ʼ +* ˵ const UINT16 routeId, ·ID +* const UINT32 CycleNum, ں +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteKeepSigTolerateCyc(const UINT16 routeId, const UINT32 dwCycleNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].RouteKeepSignalTolerateCycNum = dwCycleNum; + retVal = CI_SUCCESS; + + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָʽ·նźŻ״̬鲻ͨźű̿״̬ʼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT32 GetRouteKeepSigTolerateCyc(const UINT16 routeId, UINT32 *pTolerateCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if(NULL != pTolerateCycNum) + { + if (ROUTE_SUM_MAX > bufIndex) + { + *pTolerateCycNum = RouteDataStru[bufIndex].RouteKeepSignalTolerateCycNum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + + +/* +* ôԶźŽ·ȡ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 cmdFlag ־ +* ֵ +*/ +void SetCancleAutoSigCmdFlag(const UINT16 routeId,const UINT8 cmdFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].CancleAutoSigCmd = cmdFlag; + } + else + { + /**/ + } +} + +/* +* ȡָ·ȡ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ȡ +*/ +UINT8 GetCancleAutoSigCmdFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].CancleAutoSigCmd; + } + else + { + retVal = CI_ERROR; + } + return(retVal); +} + +/* +* Զźȡ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 cancleState ·ȡ״̬ +* ֵ +*/ +void SetAutoSigCancleState(const UINT16 routeId,const UINT8 cancleState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].AutoSigCancleState = cancleState; + } + else + { + /**/ + } +} + +/* +* ȡָ·ȡ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ȡ״̬ +*/ +UINT8 GetAutoSigCancleState(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].AutoSigCancleState; + } + else + { + retVal = CI_ERROR; + } + return(retVal); +} + +/* +* ȡָ·֤ͣгID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֤ͣгID +*/ +UINT16 GetRouteStopEnassureTrainId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].wStopEnsureTrainId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ý·ѯ֤ͣгID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +*/ +void SetRouteStopEnsureTrainId(const UINT16 routeId, const UINT16 wTrainId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].wStopEnsureTrainId = wTrainId; + } + else + { + /**/ + } +} + +/* +* ȡָ·ԴȡгID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֤ͣгID +*/ +UINT16 GetRouteResourceCancelTrainId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].wResourceCancelTrainId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ý·ѯԴȡгID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +*/ +void SetRouteResourceCancelTrainId(const UINT16 routeId, const UINT16 wTrainId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].wResourceCancelTrainId = wTrainId; + } + else + { + /**/ + } +} + +/* +* ȡָ·Ҫ۷гID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֤ͣгID +*/ +UINT16 GetRouteZhefanJiesuoTrainId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].wZhefanjiesuoTrainId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·Ҫ۷гID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +*/ +void SetRouteZhefanJiesuoTrainId(const UINT16 routeId, const UINT16 wTrainId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].wZhefanjiesuoTrainId = wTrainId; + } + else + { + /**/ + } +} + + +/* +* ȡ·ӽг +* ˵ const UINT16 routeId, ·ID +* ֵ 0u ޳ӽ +* ӽгı߱ +*/ +UINT16 GetRouteNearestTrainId(const UINT16 wRouteId) +{ + UINT16 wRetVal = 0u; + UINT16 wLogSecId = 0u; + UINT8 cRouteDir = CI_SYSTEM_DIRECTION_NONE; + UINT8 cLogSecLinkSum = 0u; + UINT16 * pLogSecLinkIdBuf = NULL; + UINT8 cLinkIndex = 0u; + UINT8 i = 0u; + UINT8 cTrainRunDir = 0u; + UINT8 cSysLogDir = CI_SYSTEM_DIRECTION_NONE;/* ϵͳ߼ */ + + UINT16 cSignalId = 0u; + LOD_STRU pLgcStartPoint = { 0u }; /*ռѹ߼ʼλ*/ + LOD_STRU pSignalProtePoint = { 0u }; /*źŻλ*/ + LOD_STRU pTrainMinTailPoint = { 0u }; /*гȫβλ*/ + UINT8 cDirChangedNum1 = 0U; /*仯1*/ + UINT8 cDirChangedNum2 = 0U; /*仯2*/ + UINT8 chTrainLevel = 0U; /*гм*/ + + TRAIN_SEQUANCE_s tmpTrainInfo = { 0u }; + + /* ȡӽռѹ߼ */ + wLogSecId = GetRouteHaveTrainNearLogSecId(wRouteId); + cLogSecLinkSum = GetSecIntrudeLinkSum(wLogSecId); + pLogSecLinkIdBuf = GetSecIntrudeLinkIdBuf(wLogSecId); + + /*ȡ·ʼźŻ*/ + cSignalId = GetRouteStartSignalId(wRouteId); + + /* ѯ߼ιlink */ + if ((0u != cLogSecLinkSum) && (NULL != pLogSecLinkIdBuf)) + { + /* ݽ·linkϵгг */ + cRouteDir = GetSignalDirection(cSignalId);/*źŻ*/ + + pLgcStartPoint.Lnk = pLogSecLinkIdBuf[0U]; + pLgcStartPoint.Off = 0U; + + pSignalProtePoint.Lnk = GetSignalProtectLink(cSignalId); + pSignalProtePoint.Off = GetSignalProtectLinkOff(cSignalId); + + cDirChangedNum1 = GetDirChangeNumBtwPoints(&pLgcStartPoint, &pSignalProtePoint); /*ռѹεźŻ֮linkжٷ仯*/ + /*ݷ任ת*/ + cRouteDir = TransDirByChangeNum(cRouteDir, cDirChangedNum1); + + + + if (DIR_SAME == cRouteDir) + { + for (i = 0u; i < cLogSecLinkSum; i++) + { + cLinkIndex = cLogSecLinkSum - i; + cLinkIndex--; + tmpTrainInfo.u16TrainID = NAME_FAILUREAREA; + tmpTrainInfo.u8TrainType = TYPE_FAILURE; + + tmpTrainInfo = as_GetLinkLastTrain(pLogSecLinkIdBuf[cLinkIndex]); + cTrainRunDir = GetTrainDir(tmpTrainInfo.u16TrainID); + /*ȡгȫβ߼linkǷз仯*/ + pTrainMinTailPoint.Lnk = GetTrainMinTailLink(tmpTrainInfo.u16TrainID); + pTrainMinTailPoint.Off = GetTrainMinTailOffset(tmpTrainInfo.u16TrainID); + + cDirChangedNum2 = GetDirChangeNumBtwPoints(&pLgcStartPoint, &pTrainMinTailPoint); /*鰲ȫβ߼linkжٷ仯*/ + /*ݷ任ת*/ + cTrainRunDir = TransDirByChangeNum(cTrainRunDir, cDirChangedNum2); + + /*ȡгм*/ + chTrainLevel = GetTrainLevel(tmpTrainInfo.u16TrainID); + if (0U != cTrainRunDir) + { + if ((NAME_FAILUREAREA != tmpTrainInfo.u16TrainID) && (TYPE_FAILURE != tmpTrainInfo.u8TrainType) + && (cTrainRunDir == cRouteDir) && (TRAIN_LEVEL_VBTC == chTrainLevel)) + { + wRetVal = tmpTrainInfo.u16TrainID; + break; + } + else + { + ; + } + } + else + { + /*޲*/ + } + } + } + else if (DIR_CONVERT == cRouteDir) + { + for (i = 0u; i < cLogSecLinkSum; i++) + { + tmpTrainInfo.u16TrainID = NAME_FAILUREAREA; + tmpTrainInfo.u8TrainType = TYPE_FAILURE; + + tmpTrainInfo = as_GetLinkFirstTrain(pLogSecLinkIdBuf[i]); + cTrainRunDir = GetTrainDir(tmpTrainInfo.u16TrainID); + /*ȡгȫβ߼linkǷз仯*/ + pTrainMinTailPoint.Lnk = GetTrainMinTailLink(tmpTrainInfo.u16TrainID); + pTrainMinTailPoint.Off = GetTrainMinTailOffset(tmpTrainInfo.u16TrainID); + + cDirChangedNum2 = GetDirChangeNumBtwPoints(&pLgcStartPoint, &pTrainMinTailPoint); /*鰲ȫβ߼linkжٷ仯*/ + /*ݷ任ת*/ + cTrainRunDir = TransDirByChangeNum(cTrainRunDir, cDirChangedNum2); + + /*ȡгм*/ + chTrainLevel = GetTrainLevel(tmpTrainInfo.u16TrainID); + if (0U != cTrainRunDir) + { + if ((NAME_FAILUREAREA != tmpTrainInfo.u16TrainID) && (TYPE_FAILURE != tmpTrainInfo.u8TrainType) + && (cTrainRunDir == cRouteDir) && (TRAIN_LEVEL_VBTC == chTrainLevel)) + { + wRetVal = tmpTrainInfo.u16TrainID; + break; + } + else + { + ; + + } + } + else + { + /*޲*/ + } + } + } + else + { + /*޲*/ + } + + } + else + { + ; + } + return wRetVal; +} + +/* +* ȡ·ӽгг·ķ +* ˵ const UINT16 routeId, ·ID +* ֵ 0u ޳ӽ +* ӽгı߱ +*/ +UINT16 GetRouteNODirNearestTrainId(const UINT16 wRouteId) +{ + UINT16 wRetVal = 0u; + UINT16 wLogSecId = 0u; + UINT8 cRouteLevel = ROUTE_LEVEL_BLOC; /*·ල*/ + UINT8 cRouteDir = CI_SYSTEM_DIRECTION_NONE; + UINT8 cLogSecLinkSum = 0u; + UINT16 * pLogSecLinkIdBuf = NULL; + UINT8 cLinkIndex = 0u; + UINT8 i = 0u; + UINT8 cSysLogDir = CI_SYSTEM_DIRECTION_NONE;/* ϵͳ߼ */ + UINT16 cSignalId = 0u; + LOD_STRU pLgcStartPoint = { 0u }; /*ռѹ߼ʼλ*/ + LOD_STRU pSignalProtePoint = { 0u }; /*źŻλ*/ + LOD_STRU pTrainMinTailPoint = { 0u }; /*гȫβλ*/ + UINT8 cDirChangedNum1 = 0U; /*仯1*/ + + TRAIN_SEQUANCE_s tmpTrainInfo = { 0u }; + + LOD_STRU pLgcEndPoint = { 0u }; /*ռѹ߼նλ*/ + + cRouteLevel = GetRouteLevel(wRouteId); /*ȡ·ල*/ + cSignalId = GetRouteStartSignalId(wRouteId); + + /* ȡӽռѹ߼ */ + wLogSecId = GetRouteHaveTrainNearLogSecId(wRouteId); + cLogSecLinkSum = GetSecIntrudeLinkSum(wLogSecId); + pLogSecLinkIdBuf = GetSecIntrudeLinkIdBuf(wLogSecId); + + /* ѯ߼ιlink */ + if ((0u != cLogSecLinkSum) && (NULL != pLogSecLinkIdBuf)) + { + /* ݽ·linkϵгг */ + cRouteDir = GetSignalDirection(cSignalId);/*źŻ*/ + + pLgcStartPoint.Lnk = pLogSecLinkIdBuf[0U]; + pLgcStartPoint.Off = 0U; + + pSignalProtePoint.Lnk = GetSignalProtectLink(cSignalId); + pSignalProtePoint.Off = GetSignalProtectLinkOff(cSignalId); + + cDirChangedNum1 = GetDirChangeNumBtwPoints(&pLgcStartPoint, &pSignalProtePoint); /*ռѹεźŻ֮linkжٷ仯*/ + /*ݷ任ת*/ + cRouteDir = TransDirByChangeNum(cRouteDir, cDirChangedNum1); + + /*·߼һ*/ + if (DIR_SAME == cRouteDir) + { + for (i = 0u; i < cLogSecLinkSum; i++) + { + cLinkIndex = cLogSecLinkSum - i; + cLinkIndex--; + tmpTrainInfo.u16TrainID = NAME_FAILUREAREA; + tmpTrainInfo.u8TrainType = TYPE_FAILURE; + + tmpTrainInfo = as_GetLinkLastTrain(pLogSecLinkIdBuf[cLinkIndex]);/*ȡһгϢ*/ + + /*жϲǹгIDڹʹ*/ + if ((NAME_FAILUREAREA != tmpTrainInfo.u16TrainID) && (TYPE_FAILURE != tmpTrainInfo.u8TrainType)) /*г*/ + { + wRetVal = tmpTrainInfo.u16TrainID; + break; + } + else + { + /**/ + } + } + } + /*·߼෴*/ + else if (DIR_CONVERT == cRouteDir) + { + for (i = 0u; i < cLogSecLinkSum; i++) + { + tmpTrainInfo.u16TrainID = NAME_FAILUREAREA; + tmpTrainInfo.u8TrainType = TYPE_FAILURE; + + tmpTrainInfo = as_GetLinkFirstTrain(pLogSecLinkIdBuf[i]);/*ȡһгϢ*/ + + /*жϲǹгIDڹʹ*/ + if ((NAME_FAILUREAREA != tmpTrainInfo.u16TrainID) && (TYPE_FAILURE != tmpTrainInfo.u8TrainType)) + { + wRetVal = tmpTrainInfo.u16TrainID; + break; + } + else + { + /**/ + + } + } + } + else + { + /*޲*/ + } + + + } + else + { + ; + } + + return wRetVal; +} + + + +/* +* ·ԴݱԴ +* ˵ const UINT16 routeId, ·ID +* ֵ 0u ޳ӽ +* ӽгı߱ +* ޸bug YF0083-119 +*/ +void RouteResourceToOverlap(const UINT16 wRouteId) +{ + UINT16 wRouteLockOverlapId = 0u; + UINT8 cOverlapCiId = 0u; + UINT8 cLocalCiId = 0u;/*ID*/ + UINT8 cTrainSum = 0u; + LogicTrainResStruct * pLogicTrainResData = NULL; + UINT16 wRouteLastLogicSectionId = 0u; + UINT8 ii = 0u; + + wRouteLockOverlapId = GetRouteOverlapLockedId(wRouteId); + if (0u != wRouteLockOverlapId) + { + cOverlapCiId = GetOverlapBelongCiId(wRouteLockOverlapId); + cLocalCiId = GetSystemParaLocalCiId(); + + if ((0u != cLocalCiId) && (cOverlapCiId == cLocalCiId)) + { + wRouteLastLogicSectionId = GetRouteInLastLogSecId(wRouteId); + cTrainSum = GetLogSecTrainInfoSum(wRouteLastLogicSectionId); + pLogicTrainResData = GetLogSecTrainInfo(wRouteLastLogicSectionId); + + if ((0u != cTrainSum) && (NULL != pLogicTrainResData)) + { + for (ii = 0u; ii < cTrainSum; ii++) + { + /* гӵε߼ */ + SetOverlapTrainLockApply(wRouteLockOverlapId, pLogicTrainResData[ii].wTrainId); + } + } + else + { + + } + } + else + { + + } + } + else + { + + } + +} + + +/* +* ȡָID·ԴID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetRouteResReqOtherCIId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].cResReqOtherCIId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID·ԴID +* ˵ const UINT16 routeId, ·ID +* const UINT8 cOtherCiId, +* ֵ +* +*/ +void SetRouteResReqOtherCIId(const UINT16 routeId, const UINT8 cOtherCiId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + RouteDataStru[bufIndex].cResReqOtherCIId = cOtherCiId; + } + else + { + /**/ + } +} + +/* +* ȡָID·Դг +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 * GetRouteResReqTrainIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].wszResReqTrainId; + } + else + { + retVal = NULL; + } + + return retVal; +} + + +/* +* ָID·ԴгID +* ˵ const UINT16 routeId, ·ID +* const UINT8 wTrainId, г +* ֵ +* ޸bug YF0083-119 +*/ +void SetRouteResReqTrainId(const UINT16 routeId, const UINT16 wTrainId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ii = 0U; + UINT8 chReqTrainSum = 0U; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (( ROUTE_SUM_MAX> bufIndex )&& (0u != wTrainId)) + { + chReqTrainSum = RouteDataStru[bufIndex].chResReqTrainSum; + + if ((ROUTE_APPLY_RECD_TRAIN_SUM_MAX - 1U) > chReqTrainSum) + { + for (ii = 0U; ii < chReqTrainSum; ii++) + { + if (RouteDataStru[bufIndex].wszResReqTrainId[ii] == wTrainId) + { + break; + } + else + { + ; /*ִ*/ + } + } + + if (ii == chReqTrainSum) + { + RouteDataStru[bufIndex].wszResReqTrainId[chReqTrainSum] = wTrainId; + RouteDataStru[bufIndex].chResReqTrainSum = chReqTrainSum + 1U; + } + else + { + + } + } + else + { + + } + } + else + { + /**/ + } +} + +/* +* ָID·Դг +* ˵ const UINT16 routeId, ·ID +* ֵ +* +*/ +void ClearRouteResReqTrainBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ii = 0U; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX> bufIndex) + { + + for (ii = 0U; ii < ROUTE_APPLY_RECD_TRAIN_SUM_MAX; ii++) + { + RouteDataStru[bufIndex].wszResReqTrainId[ii] = 0; + + } + + RouteDataStru[bufIndex].chResReqTrainSum = 0U; + } + else + { + /**/ + } +} + +/* +* ɾָгID +* ˵ UINT16 routeId, ·ID +* UINT16 wTrainId гID +* ֵ +* ޸bug YF0083-119 +*/ +void RemoveRouteReqResTrain(UINT16 routeId, UINT16 wTrainId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 chReqTrainSum = 0U; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX> bufIndex) + { + chReqTrainSum = RouteDataStru[bufIndex].chResReqTrainSum; + + if ((ROUTE_APPLY_RECD_TRAIN_SUM_MAX - 1U) > chReqTrainSum) + { + for (ii = 0U; ii < chReqTrainSum; ii++) + { + if (RouteDataStru[bufIndex].wszResReqTrainId[ii] == wTrainId) + { + break; + } + else + { + ; /*ִ*/ + } + } + + if (ii == chReqTrainSum) + { + /*δҵ */ + } + else + { + for (jj = ii + 1U; jj < chReqTrainSum; jj++) + { + RouteDataStru[bufIndex].wszResReqTrainId[jj - 1U] = RouteDataStru[bufIndex].wszResReqTrainId[jj]; + } + RouteDataStru[bufIndex].wszResReqTrainId[jj] = 0U; + + + RouteDataStru[bufIndex].chResReqTrainSum -= 1U; + + if (0u == RouteDataStru[bufIndex].chResReqTrainSum) + { + RouteDataStru[bufIndex].cResReqOtherCIId = 0U; + } + else + { + + } + } + } + else + { + + } + } + else + { + /**/ + } + + + +} + +/* +* ȡָ·г +* ˵ const UINT16 wRouteId, ·ID +* +* ֵ +*/ +UINT8 GetRouteResReqTrainSum(const UINT16 wRouteId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = CI_ERROR; + + wBufIndex = GetRouteConfigBufIndex(wRouteId); /*ȡ±*/ + + if (ROUTE_SUM_MAX > wBufIndex) + { + if (ROUTE_APPLY_RECD_TRAIN_SUM_MAX > RouteDataStru[wBufIndex].chResReqTrainSum) + { + chRetVal = RouteDataStru[wBufIndex].chResReqTrainSum; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + +/* +* ȡָ·֤ͣں +* ˵ const UINT16 routeId, ·ID +* ֵ ں +*/ +UINT32 GetRouteStopEnassureCyc(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].dwStopEnsureCyc; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ý·ѯ֤ͣں +* ˵ const UINT16 routeId, ·ID +* const UINT32 dwCyc ں +* ֵ +*/ +void SetRouteStopEnsureCyc(const UINT16 routeId, const UINT32 dwCyc) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].dwStopEnsureCyc = dwCyc; + } + else + { + /**/ + } +} + +/* +* ȡָ·Դȡں +* ˵ const UINT16 routeId, ·ID +* ֵ ں +*/ +UINT32 GetRouteResourceCancelCyc(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].dwResourceCancelCyc; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ý·ѯԴȡں +* ˵ const UINT16 routeId, ·ID +* const UINT32 dwCyc ں +* ֵ +*/ +void SetRouteResourceCancelCyc(const UINT16 routeId, const UINT32 dwCyc) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].dwResourceCancelCyc = dwCyc; + } + else + { + /**/ + } +} + +/* +* ȡָ·Ҫг۷ں +* ˵ const UINT16 routeId, ·ID +* ֵ ں +*/ +UINT32 GetRouteZhefanJiesuoCyc(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].dwRouteZhefanjiesuoCyc; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·Ҫг۷ں +* ˵ const UINT16 routeId, ·ID +* const UINT32 dwCyc ں +* ֵ +*/ +void SetRouteZhefanJiesuoCyc(const UINT16 routeId, const UINT32 dwCyc) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].dwRouteZhefanjiesuoCyc = dwCyc; + } + else + { + /**/ + } +} +/* +* @brief ITS·TrainID +* @details ¼ITS·ָ·гIDԱ·ʱ߼ԴϿӸгID +* @param const UINT16 routeId ·ID +* const UINT16 trainID гID +* @note WQM 20220310 +*/ +void SetITSRouteApplyTrainIDInfo(const UINT16 routeId, const UINT16 trainId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 i = 0u; + UINT8 trainIdSum = 0u; + + /** μ*/ + if ((0u < routeId) && (ROUTE_SUM_MAX > routeId) && (TRAIN_ID_MIN < trainId) && (TRAIN_ID_MAX > trainId)) + { + bufIndex = GetRouteConfigBufIndex(routeId); /** ȡ·±*/ + trainIdSum = RouteDataStru[bufIndex].ITSRouteApplyTrainIdSum; /** ȡITS·гID¼*/ + /** ±ϷгIDϷ*/ + if (ROUTE_APPLY_RECD_TRAIN_SUM_MAX >= trainIdSum) + { + /** гIDΪ0*/ + if (0u == trainIdSum) + { + /*δ¼гId*/ + RouteDataStru[bufIndex].ITSRouteApplyTrainIdBuf[trainIdSum] = trainId; /** ¼гID*/ + RouteDataStru[bufIndex].ITSRouteApplyTrainIdSum++; /** гID1*/ + } + /** м¼гId*/ + else + { + + /** гIDΪ0гID*/ + for (i = 0u; i < trainIdSum; i++) + { + /** ѯѼ¼гIdǷ뵱ǰ¼гIdͬ*/ + if (trainId == RouteDataStru[bufIndex].ITSRouteApplyTrainIdBuf[i]) + { + break; /** Ѽ¼гId¼гIDͬѭ*/ + } + else + { + + } + } + + /** ±гIDδѯ¼гIDһгID󲻻Խ*/ + if ((i == trainIdSum) && (ROUTE_APPLY_RECD_TRAIN_SUM_MAX > trainIdSum)) + { + /*гIdδ¼гIDδޣ*/ + RouteDataStru[bufIndex].ITSRouteApplyTrainIdBuf[trainIdSum] = trainId; /** ¼гID*/ + RouteDataStru[bufIndex].ITSRouteApplyTrainIdSum++; /** гID1*/ + } + else + { + /*ѴгIdгIDѳޣٴ*/ + } + } + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* @brief ȡָ·ITS·гID¼ +* @param const UINT16 routeId ·ID +* @return UINT8 retVal ¼гID +* @retval CI_ERROR ĬϷֵ +* ¼гID +* @note WQM 20220310 +*/ +UINT8 GetITSRouteApplyTrainIdSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + /** μ*/ + if ((0u < routeId) && (ROUTE_SUM_MAX > routeId)) + { + bufIndex = GetRouteConfigBufIndex(routeId); /** ȡ·±*/ + /** ±Ϸ*/ + retVal = RouteDataStru[bufIndex].ITSRouteApplyTrainIdSum; /** ؼ¼гID*/ + + } + else + { + /*ʧ*/ + } + return retVal; +} + +/* +* @brief ȡָ·ITS·¼гID +* @param const UINT16 routeId ·ID +* @return UINT16 * retVal ¼гID +* @retval NULL ĬϷֵ +* ¼гID +* @note WQM 20220310 +*/ +UINT16 * GetITSRouteApplyTrainIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + + /** μ*/ + if ((0u < routeId) && (ROUTE_SUM_MAX > routeId)) + { + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + /** ±Ϸ*/ + retVal = RouteDataStru[bufIndex].ITSRouteApplyTrainIdBuf; /** ؼ¼гIDָ*/ + + } + else + { + + } + return retVal; +} + +/* +* @brief ָ·ITS·¼гIDϢ +* @param const UINT16 routeId ·ID +* @note WQM 20220310 +*/ +void ClearITSRouteApplyTrainIDInfo(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 i = 0u; /**/ + + /** μ*/ + if ((0u < routeId) && (ROUTE_SUM_MAX > routeId)) + { + bufIndex = GetRouteConfigBufIndex(routeId); /** ȡ·±*/ + /** δԽ磬гID*/ + for (i = 0u; i < ROUTE_APPLY_RECD_TRAIN_SUM_MAX; i++) + { + RouteDataStru[bufIndex].ITSRouteApplyTrainIdBuf[i] = 0u; /** ͨITS·¼гID*/ + } + RouteDataStru[bufIndex].ITSRouteApplyTrainIdSum = 0u; /** ITS·гID¼*/ + + } + else + { + /**/ + } +} + +/* +* @brief ý·ùԴCIId +* @details ¼CiIDյñΪԴ +* @param const UINT16 routeId ·ID +* const UINT8 chCiId CiID +* @return +*/ +void SetRouteOvlapShrCiId(const UINT16 routeId, const UINT8 chCiId) +{ + UINT16 bufIndex = 0u; /*±*/ + + /** ȡ·±*/ + bufIndex = GetRouteConfigBufIndex(routeId); + /** ±ϷгIDϷ*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].chShareOverlapCiId = chCiId; + } + else + { + /**/ + } +} + +/* +* @brief ȡ·ùԴCIId +* @param const UINT16 routeId ·ID +* @return UINT8 retVal ¼Ci ID +* @retval CI_ERROR ĬϷֵ +* ¼CiId +*/ +UINT8 GetRouteOvlapShrCiId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /** ȡ·±*/ + /** ±Ϸ*/ + if(ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].chShareOverlapCiId; /** ؼ¼гID*/ + } + else + { + /*ʧ*/ + } + + return retVal; +} + +/* +* @brief ȡ·ȷ״̬ +* @param const UINT16 routeId ·ID +* @return UINT8 retVal ¼Ci ID +* @retval CI_ERROR ĬϷֵ +* ·ȷ״̬ +*/ +UINT8 GetRouteXiansuConfirmStt(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /** ȡ·±*/ + /** ±Ϸ*/ + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].chRouteXiansuConfirm; /** ؽ·״̬*/ + } + else + { + /*ʧ*/ + } + + return retVal; +} + +/* +* @brief ý·ȷ״̬ +* @details ȷϺ󣬵ʽ·״̬ +* @param const UINT16 routeId ·ID +* const UINT8 chXianSuRemoveStt chXianSuRemoveStt +* @return +*/ +void SetRouteXianSuConfirmStt(const UINT16 routeId, const UINT8 chXianSuConfirmStt) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /** ȡ·±*/ + /** ±Ϸ*/ + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_XIANSU_CONFIRM_NO == chXianSuConfirmStt) + || (ROUTE_XIANSU_CONFIRM_YES == chXianSuConfirmStt)) + { + RouteDataStru[bufIndex].chRouteXiansuConfirm= chXianSuConfirmStt; /** ؽ·״̬*/ + } + else + { + ; + } + } + else + { + /*ʧ*/ + } + +} +/* +* ñҪձ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag ־ +* ֵ +* cgh-ϲCID-2539-10 +*/ +void SetRouteOverlapNeedCIlockFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + if ((OVERLAPCILOCK_YES == flag) || (OVERLAPCILOCK_NO == flag)) + { + RouteDataStru[bufIndex].OverlapNeedCIlockFlag = flag; + } + + } + else + { + /**/ + } +} + +/* +* ȡҪձ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag ־ +* ֵ +* cgh-ϲCID-2539-10 +*/ +UINT8 GetRouteOverlapNeedCIlockFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].OverlapNeedCIlockFlag; + } + else + { + /**/ + } + return reVal; +} + +/* +* ñչб־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag ־ +* ֵ +* cgh-ϲCID-2539-10 +*/ +void SetRouteOverlapLockProcFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].OverlapLockProcFlag = flag; + } + else + { + /**/ + } +} + +/* +* ȡչб־ +* ˵ const UINT16 routeId, ·ID +* +* ֵ >0 չб־ +* 0 ȡʧ +* cgh-ϲCID-2539-10 +*/ +UINT8 GetRouteOverlapLockProcFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].OverlapLockProcFlag; + } + else + { + /**/ + } + return reVal; +} +/* +* ý·ǷϽ·־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag ־ +* ֵ +* cgh-ϲCID-2539-10 +*/ +void SetRouteGroupRouteCmdFlag(const UINT16 routeId, const UINT8 flag) +{ + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].GroupRouteCmdFlag = flag; + } + else + { + /**/ + } +} + +/* +* ȡ·ǷϽ·־ +* ˵ const UINT16 routeId, ·ID +* +* ֵ >0 Ͻ·־ +* 0 ȡʧ +* cgh-ϲCID-2539-10 +*/ +UINT8 GetRouteGroupRouteCmdFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].GroupRouteCmdFlag; + } + else + { + /**/ + } + return reVal; +} + +/* +* ý·Զ־ +* ˵ UINT16 routeId Զ· +* UINT8 setFlag õԶ־ +* ֵ +* cgh-ϲCID-3037-4 +*/ +void SetRouteAutoTriggerFlag(UINT16 routeId, UINT8 setFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((AUTO_TRIGGER_SET_YES == setFlag) || (AUTO_TRIGGER_SET_NO == setFlag)) + { + RouteDataStru[bufIndex].AutoTriggerFlag = setFlag; /*Զ־*/ + } + } +} + +/* +* ȡָ·Զ־ +* ˵ const UINT16 routeId, ·ID +* +* ֵ >0 Ͻ·־ +* 0 ȡʧ +* cgh-ϲCID-3037-4 +*/ +UINT8 GetRouteAutoTriggerFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].AutoTriggerFlag; + } + else + { + /**/ + } + return reVal; +} + +/** +* @brief ȡ·ǰ߼ +* @param[in] const UINT16 wRouteId ·ID +* @param[out] UINT16 szLgcId[MAX_ROUTE_IN_LT_NUM] ߼ID +* @return ߼ +*/ +UINT16 GetRouteLockLgc(const UINT16 wRouteId, UINT16 szLgcId[MAX_ROUTE_IN_LT_NUM]) +{ + UINT16 wLgcNum = 0u; + UINT16 wLgcIndex = 0u; + UINT16 * pRouteLgc = NULL; + UINT8 chLockState = 0u; + UINT16 wRtn = 0u; + wLgcNum = GetRouteLogSectionSum(wRouteId); + pRouteLgc = GetRouteLogSectionIdBuf(wRouteId); + if ((0u == wLgcNum) || (NULL == pRouteLgc)) + { + ; /* λ */ + } + else + { + for (wLgcIndex = 0u; wLgcIndex < wLgcNum; wLgcIndex++) + { + chLockState = GetLogSecLockState(pRouteLgc[wLgcIndex]); + if (LOG_SECTION_LOCK_NORMAL == chLockState) + { + szLgcId[wRtn++] = pRouteLgc[wLgcIndex]; + } + else + { + ; /* ߼η״̬ */ + } + } + } + return wRtn; +} + +/* +* ȡָID·տɶ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: տɶ־ +*/ +UINT8 GetHalfRouteSwitchMoveValid(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].HalfRouteDataSt.HalfRouteSwitchMoveValid; + } + else + { + /**/ + } + return reVal; +} + +/* +* ָID·տɶ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 switchMoveValid, ɶ־ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +void SetHalfRouteSwitchMoveValid(const UINT16 routeId, const UINT8 switchMoveValid) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_HALF_SWITCH_MOVE_VALID == switchMoveValid) || (ROUTE_HALF_SWITCH_MOVE_INVALID == switchMoveValid)) + { + RouteDataStru[bufIndex].HalfRouteDataSt.HalfRouteSwitchMoveValid = switchMoveValid; /*ÿɶ־*/ + } + else + { + RouteDataStru[bufIndex].HalfRouteDataSt.HalfRouteSwitchMoveValid = ROUTE_HALF_SWITCH_MOVE_INVALID; + } + } +} + +/* +* ȡָID·ԴгID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ԴгID +*/ +UINT16 GetHalfRouteResReqTrainId(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].HalfRouteDataSt.HalfResReqTrainId; + } + else + { + /**/ + } + return reVal; +} + +/* +* ָID·ԴгID +* ˵ const UINT16 routeId, ·ID +* const UINT8 trainId, гID +* ֵ CI_ERROR +* CI_SUCCESS +*/ +void SetHalfRouteResReqTrainId(const UINT16 routeId, const UINT16 trainId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((0U != trainId) && (UINT16_MAX!= trainId)) + { + RouteDataStru[bufIndex].HalfRouteDataSt.HalfResReqTrainId = trainId; /*гID*/ + } + else + { + RouteDataStru[bufIndex].HalfRouteDataSt.HalfResReqTrainId = 0U; + } + } +} + +/* +* ȡָID·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·߼ +*/ +UINT8 GetHalfRouteLockLgcSecSum(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum; + } + else + { + /**/ + } + return reVal; +} + + +/* +* ȡָID·߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ߼ID +*/ +UINT16 * GetHalfRouteLockLgcSecIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 * reVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf; + } + else + { + /**/ + } + return reVal; +} + +/* +* ָID·߼ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lgcSecNum, ߼ +* const UINT16 *pLgcSecIdBuf ߼ID +* ֵ +* +*/ +void SetHalfRouteLockLgcSec(const UINT16 routeId,const UINT8 lgcSecNum, const UINT16 *pLgcSecIdBuf) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ii = 0U; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((NULL != pLgcSecIdBuf) && (MAX_ROUTE_IN_LT_NUM > lgcSecNum)) + { + (void)CommonMemSet(RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf,\ + (UINT32)sizeof(RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf),\ + 0, (UINT32)sizeof(RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf)); + for (ii = 0U; ii < lgcSecNum; ii++) + { + RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf[ii] = pLgcSecIdBuf[ii]; + } + RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum = lgcSecNum; + } + else + { + (void)CommonMemSet(RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf, \ + (UINT32)sizeof(RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf), \ + 0, (UINT32)sizeof(RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf)); + RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum = 0U; + } + } +} + +/* +* ȡָID·г߼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·г߼ +*/ +UINT8 GetHalfRouteTrainLocLgcSecNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum; + } + else + { + /**/ + } + return reVal; +} + + +/* +* ȡָID·г߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: г߼ID +*/ +UINT16 * GetHalfRouteTrainLocLgcSecIdBuf(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 * reVal = NULL; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf; + } + else + { + /**/ + } + return reVal; +} + +/* +* ָID·г߼Ϣ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lgcSecNum, ߼ +* const UINT16 *pLgcSecIdBuf ߼ID +* ֵ +* +*/ +void SetHalfRouteTrainLocLgcSec(const UINT16 routeId, const UINT8 lgcSecNum, const UINT16 *pLgcSecIdBuf) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ii = 0U; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((NULL != pLgcSecIdBuf) && (ROUTE_TRAIN_LOC_MAX_LGC_SUM > lgcSecNum)) + { + (void)CommonMemSet(RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf, \ + (UINT32)sizeof(RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf), \ + 0, (UINT32)sizeof(RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf)); + for (ii = 0U; ii < lgcSecNum; ii++) + { + RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf[ii] = pLgcSecIdBuf[ii]; + } + RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum = lgcSecNum; + } + else + { + (void)CommonMemSet(RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf, \ + (UINT32)sizeof(RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf), \ + 0, (UINT32)sizeof(RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf)); + RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum = 0U; + } + } +} + + +/* +* ָID·г߼Ϣ +* ˵ const UINT16 routeId, ·ID +* OUT UINT16 szRouteHalfPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetRouteHalfPhysicalSecData(const UINT16 routeId,OUT UINT16 szRouteHalfPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX]) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + UINT8 ii = 0U; /*ѭ*/ + UINT8 jj = 0U; + UINT16 phySecId = 0U; + UINT8 phySecSum = 0U; + UINT16 szTmpPhySecIdBuf[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + /*μ*/ + if (NULL != szRouteHalfPhySecData) + { + if (ROUTE_SUM_MAX > bufIndex) + { + /*·߼*/ + for (ii = 0U; ii < RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum; ii++) + { + phySecId =GetLgcSecRelativePhySecId( RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf[ii]); + + /*ȥ*/ + for (jj = 0U; jj < phySecSum; jj++) + { + if (szTmpPhySecIdBuf[jj] == phySecId) + { + break; + } + else + { + ; /* ִ*/ + } + } + + /*δظ*/ + if (jj == phySecSum) + { + if (phySecSum < ROUTE_PHYSICALSECTION_SUM_MAX) + { + szTmpPhySecIdBuf[phySecSum++] = phySecId; + } + else + { + break; + } + } + } + + /*ִɣδԽ*/ + if (ii == RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum) + { + reVal = phySecSum; + for (ii = 0U; ii < phySecSum; ii++) + { + szRouteHalfPhySecData[ii] = szTmpPhySecIdBuf[ii]; + } + } + + } + else + { + /*ʧ*/ + reVal = 0u; + } + } + else + { + /*ʧ*/ + reVal = 0u; + } + + return reVal; +} + + +/* +* ָID·гϢ +* ˵ const UINT16 routeId, ·ID +* OUT UINT16 szRouteHalfPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetRouteTrainLocPhySecData(const UINT16 routeId, OUT UINT16 szRouteTrainLocPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX]) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + UINT8 ii = 0U; /*ѭ*/ + UINT8 jj = 0U; + UINT16 phySecId = 0U; + UINT8 phySecSum = 0U; + UINT16 szTmpPhySecIdBuf[ROUTE_PHYSICALSECTION_SUM_MAX] = { 0U }; + UINT8 funcRet = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + /*μ*/ + if (NULL != szRouteTrainLocPhySecData) + { + if (ROUTE_SUM_MAX > bufIndex) + { + /*߼*/ + for (ii = 0U; ii < RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum; ii++) + { + funcRet = CheckLgcSecInHalfRoute(routeId, RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf[ii]); /*ڲֽ·е߼βż*/ + if (CI_SUCCESS == funcRet) + { + phySecId = GetLgcSecRelativePhySecId(RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf[ii]); + /*ȥ*/ + for (jj = 0U; jj < phySecSum; jj++) + { + if (szTmpPhySecIdBuf[jj] == phySecId) + { + break; + } + else + { + ; /* ִ*/ + } + } + + /*δظ*/ + if (jj == phySecSum) + { + if (phySecSum < ROUTE_PHYSICALSECTION_SUM_MAX) + { + szTmpPhySecIdBuf[phySecSum++] = phySecId; + } + else + { + break; + } + } + } + else + { + ; /*DZֽ·Σ*/ + } + } + + /*ִɣδԽ*/ + if (ii == RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum) + { + reVal = phySecSum; + for (ii = 0U; ii < phySecSum; ii++) + { + szRouteTrainLocPhySecData[ii] = szTmpPhySecIdBuf[ii]; + } + } + + } + else + { + /*ʧ*/ + reVal = 0u; + } + } + else + { + /*ʧ*/ + reVal = 0u; + } + + return reVal; +} +/* +* ָID·շϢ +* ˵ const UINT16 routeId, ·ID +* OUT RouteProtectSwitchStruct szRouteProtectSwitchStruct[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetRouteHalfProSwData(const UINT16 routeId, OUT RouteProtectSwitchStruct szRouteProSwitchStruct[ROUTE_PROTECTSWI_SUM_MAX]) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + UINT8 keepWork = CI_ERROR; + UINT8 ii = 0U; /*ѭ*/ + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT16 phySecId = 0U; + UINT8 phySecSum = 0U; + UINT8 proSwSum = 0U; + UINT8 outTmpProSwSum = 0U; + RouteProtectSwitchStruct szTmpProSwStru[ROUTE_PROTECTSWI_SUM_MAX] = { 0U }; + LogsecSwitchStruct *pLgcProSwStru = NULL; + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + /*μ*/ + if (NULL != szRouteProSwitchStruct) + { + if (ROUTE_SUM_MAX > bufIndex) + { + keepWork = CI_SUCCESS; + /*·߼*/ + for (ii = 0U; ii < RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum; ii++) + { + proSwSum = GetLgcRelateProSwSum( RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf[ii]); + pLgcProSwStru = GetLgcRelateProSwStru(RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf[ii]); + + if (NULL != pLgcProSwStru) + { + /*ȥز*/ + for (jj = 0U; jj < proSwSum; jj++) + { + for (kk = 0U; kk < outTmpProSwSum; kk++) + { + if (pLgcProSwStru[jj].SwitchId == szTmpProSwStru[kk].ProtectSwitchId) + { + break; + } + else + { + /*ִ*/ + } + } + if (kk == outTmpProSwSum) + { + if (ROUTE_PROTECTSWI_SUM_MAX > outTmpProSwSum) + { + szTmpProSwStru[outTmpProSwSum].ProtectSwitchId = pLgcProSwStru[jj].SwitchId; + szTmpProSwStru[outTmpProSwSum].ProtectPosition = pLgcProSwStru[jj].SwitchPosition; + outTmpProSwSum++; + } + else + { + break; + } + } + } + } + else + { + keepWork = CI_ERROR; + } + + /*δظ*/ + if (jj != proSwSum) + { + keepWork = CI_ERROR; + } + else + { + ; + } + + if (CI_ERROR == keepWork) + { + break; + } + else + { + ; + } + } + + /*ִɣδԽ*/ + if (ii == RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum) + { + reVal = outTmpProSwSum; + for (ii = 0U; ii < outTmpProSwSum;ii++) + { + szRouteProSwitchStruct[ii] = szTmpProSwStru[ii]; + } + } + + } + else + { + /*ʧ*/ + reVal = 0u; + } + } + else + { + /*ʧ*/ + reVal = 0u; + } + + return reVal; +} + +/* +* ȡָID·гԴǷ߼ +* ˵ const UINT16 routeId, ·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: гԴ +* CI_ERROR: гԴ +*/ +UINT8 CheckLgcSecNotInTrainLoc(const UINT16 routeId,const UINT16 lgcSecId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = CI_ERROR; + UINT8 ii = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + for (ii = 0U; ii < RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum; ii++) + { + if (lgcSecId == RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf[ii]) + { + break; + } + else + { + ; /*ִ*/ + } + } + + if (ii == RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum) + { + /*δҵͬ߼*/ + reVal = CI_SUCCESS; + } + + } + else + { + /**/ + } + return reVal; +} + + +/* +* г·Ϊhalfunlock +* ˵ const UINT16 routeId, ·ID +* +* ֵ +* +*/ +void SetTrainLocRouteHalfUnlock(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 rLockRouteId = 0U; + UINT8 reVal = CI_ERROR; + UINT8 ii = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + for (ii = 0U; ii < RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum; ii++) + { + rLockRouteId = GetLogSecLockBelongRoute(RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf[ii]); + SetRouteStateManage(rLockRouteId,ROUTE_STATE_HALF_UNLOCK); + } + + } + else + { + /**/ + } +} +/* +* ȡָID·гԴ߼ +* ˵ const UINT16 routeId, ·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: гԴ +* CI_ERROR: гԴ +*/ +UINT8 CheckLgcSecHaveTrainLoc(const UINT16 routeId, const UINT16 lgcSecId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = CI_ERROR; + UINT8 ii = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + for (ii = 0U; ii < RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum; ii++) + { + if (lgcSecId == RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecIdBuf[ii]) + { + reVal = CI_SUCCESS; + break; + } + else + { + ; /*ִ*/ + } + } + + if (ii == RouteDataStru[bufIndex].HalfRouteDataSt.TrainLocLgcSecNum) + { + /*δҵͬ߼*/ + reVal = CI_ERROR; + } + else + { + + } + + } + else + { + /**/ + reVal = CI_ERROR; + } + return reVal; +} + +/* +* ȡָID·гԴ߼ +* ˵ const UINT16 routeId, ·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: ڰԤ +* CI_ERROR: ڰԤ +*/ +UINT8 CheckLgcSecInHalfRoute(const UINT16 routeId, const UINT16 lgcSecId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = CI_ERROR; + UINT8 ii = 0U; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + for (ii = 0U; ii < RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum; ii++) + { + if (lgcSecId == RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecIdBuf[ii]) + { + reVal = CI_SUCCESS; + break; + } + else + { + ; /*ִ*/ + } + } + + if (ii == RouteDataStru[bufIndex].HalfRouteDataSt.RouteLockLgcSecNum) + { + /*δҵͬ߼*/ + reVal = CI_ERROR; + } + else + { + + } + + } + else + { + /**/ + reVal = CI_ERROR; + } + return reVal; +} +/* +* ȡָID·̬·ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ̬·ID +*/ +UINT16 GetRouteBelongDrId(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].wBelongDrId; + } + else + { + retVal = 0u; + } + return retVal; +} + + +/* +* ָID·̬·ID +* ˵ const UINT16 routeId, ·ID +* const UINT16 belongDrId, ̬·ID +* ֵ +* +*/ +void SetRouteBelongDrId(const UINT16 routeId, const UINT16 belongDrId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].wBelongDrId = belongDrId; /*·̬·ID*/ + } + else + { + /**/ + } +} +/* +* ȡָID·һյ߼ʱιʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetRouFirstElockStaCycNum(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].dwFirstElockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָID·һյ߼ʱιʼں +* ˵ const UINT16 routeId, ·ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetRouFirstElockStaCycNum(const UINT16 routeId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].dwFirstElockStartCycNum = startCycNum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡ·ӽǷпг +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERROR ӽпг +* CI_SUCCESS ӽ޿г +* edit cgh 20241128 +*/ +UINT8 GetRouteSuspiciousInNearSec(const UINT16 routeId) +{ + UINT8 wRetVal = CI_ERROR; /*ֵ*/ + UINT16 wLogSecId = 0u; + UINT8 logSecIndex = 0u; + UINT8 logSecBelongCiId = 0U; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 localCiId = 0U; + UINT8 funcRet = 0U; + UINT8 cTrainRunDir = 0u; + UINT8 nearCbtcSecConditionSum = 0u; /*CBTCӽ*/ + RouteNearLogicSectionStruct* nearLogicSecStru = NULL; /*ӽ߼νṹ*/ + UINT8 chRouteNearSecSearchState = ROUTE_NEAR_SEC_HAVE_UT;/*·ӽβѯ״̬Ϊйϳ*/ + + /* ȡӽռѹ߼ */ + localCiId = GetSystemParaLocalCiId(); + nearCbtcSecConditionSum = GetRouteCbtcNearSecConditionSum(routeId); /*ȡCBTC·ӽ߼Ŀ*/ + nearLogicSecStru = GetRouteCbtcNearLogSectionStru(routeId); /*ȡCBTC·ӽ߼νṹ*/ + + if ((0u < nearCbtcSecConditionSum) + && (ROUTE_NEARSEC_CONDITION_SUM_MAX >= nearCbtcSecConditionSum) + && (NULL != nearLogicSecStru)) + {/*жӽ*/ + + for (ii = 0U; ii < nearCbtcSecConditionSum; ii++) + { + funcRet = GetRouteNearSecFitSwIndex(routeId, ii); + + if (CI_SUCCESS == funcRet) + { + /*ǰӽηϵλã˳ѭ*/ + break; + } + } + + /*߱һȫϵλõĽӽ*/ + if ((ii != nearCbtcSecConditionSum) + &&(0U!=nearLogicSecStru[ii].NearLogicSecSum)) + { + /*ýӽ߼*/ + for (logSecIndex =0U; logSecIndex= nearCbtcSecConditionSum) + && (NULL != nearLogicSecStru) + &&(nearSecIndex0: ·Դȡʱ־ +*/ +UINT8 GetRouteResCancelDelayFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].CancelResDelayflag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ·ⱨʱʼں +* ˵const UINT16 routeId, ·ID +* const UINT32 dwCyc ں +* ֵ +*/ +void SetRouteDelayOpenStartCyc(const UINT16 routeId, const UINT32 dwCyc) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + RouteDataStru[bufIndex].dwDelayOpenStartCycNum = dwCyc; + } + else + { + /**/ + } +} + +/* +* ȡָ·ⱨʱʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʱʼں +*/ +UINT32 GetRouteDelayOpenStartCyc(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + retVal = RouteDataStru[bufIndex].dwDelayOpenStartCycNum; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ý·Ҫⱨ־ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +*/ +void SetRouteDriveSGBJFlag(UINT16 routeId, UINT8 setFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_DRIVE_SGBJ_VALID == setFlag) || (ROUTE_DRIVE_SGBJ_INVALID == setFlag)) + { + RouteDataStru[bufIndex].cRouteNeedDriveSGBJFlag = setFlag; /*ⱨ־*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָ·Ҫⱨ־ +* ˵ const UINT16 routeId ·ID +* ֵ >0 ⱨ־ +* 0 ȡʧ +*/ +UINT8 GetRouteDriveSGBJFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].cRouteNeedDriveSGBJFlag; + } + else + { + /**/ + } + return reVal; +} + +/* +* ָ·Ͻ·ⱨʱ־ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +*/ +void SetRelZuHeRouteSGBJDelayFlag(UINT16 routeId, UINT8 setFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_SGBJ_DELAY_OPEN_VALID == setFlag) || (ROUTE_SGBJ_DELAY_OPEN_INVALID == setFlag)) + { + RouteDataStru[bufIndex].cRelZuHeRouteSGBJDelayFlag = setFlag; /*ⱨʱ־*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָ·Ͻ·ⱨʱ־ +* ˵ const UINT16 routeId ·ID +* ֵ >0 ⱨʱ־ +* 0 ȡʧ +*/ +UINT8 GetRelZuHeRouteSGBJDelayFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±,󷵻MAXֵ>0*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].cRelZuHeRouteSGBJDelayFlag; + } + else + { + /**/ + } + return reVal; +} + + +/* ·ǷѰ״̬Źŷʹã +* ˵ const UINT16 routeId ·ID +* ֵ CI_ERRORʧ +* ROUTE_TRANSACT_YES ·Ѱ +* ROUTE_TRANSACT_NO ·δ +*/ + +UINT8 CheckRouteTransactState(const UINT16 routeId) +{ + UINT8 retVal = CI_ERROR; + UINT8 routeState = 0U; + UINT16 lastPhyLockId = 0U; /*·һID*/ + UINT8 lastPhyLockState = 0U; /*һ״̬*/ + + routeState = GetRouteState(routeId); /*ȡ·״̬*/ + lastPhyLockId = GetRouteLastPhySectionId(routeId); + lastPhyLockState = GetPhySecLockState(lastPhyLockId); + + if ((0U != routeId) && (ROUTE_SUM_MAX > routeId)) + { + if (((ROUTE_STATE_IDLE != routeState) + && (ROUTE_STATE_FIRST_XUANPAI != routeState) + && (ROUTE_STATE_XUANPAI != routeState) + && (ROUTE_STATE_LEAD_FIRST_XUANPAI != routeState) + && (ROUTE_STATE_LEAD_XUANPAI != routeState) + && (ROUTE_STATE_LEAD_LOCK != routeState) + && (ROUTE_STATE_LEAD_LOCKERR != routeState) + && (ROUTE_STATE_LEAD_OPEN != routeState)) + || (((ROUTE_STATE_FIRST_XUANPAI == routeState) || (ROUTE_STATE_XUANPAI == routeState)) + && ((PHYSICAL_SECTION_LOCK_NORMAL == lastPhyLockState) || + (PHYSICAL_SECTION_LOCK_DELAY == lastPhyLockState) || + (PHYSICAL_SECTION_LOCK_FAULTDELAY == lastPhyLockState)))) + + {/*·״̬ΪԤѡѡһΪ״̬жΪѰ״̬*/ + retVal = ROUTE_TRANSACT_YES; + } + else + { + retVal = ROUTE_TRANSACT_NO; + } + } + else + { + /*ؼʧ*/ + } + return retVal; +} + + +/* ȡ·ڵĵCTռѹ߼ΣUTռѹʧܣ +* ˵ const UINT16 garageDoorId +* logSecId[MAX_ROUTE_IN_LT_NUM] ߼ID +* UINT8 logSecNum ߼ +* ֵ CI_ERRORѯʧ,logSecId[0U]UTռѹ߼ +* CI_SUCCESS ѯɹ +*/ +UINT8 GetCTLogSecOfRoute(const UINT16 routeId, OUT UINT16 logSecId[MAX_ROUTE_IN_LT_NUM], OUT UINT8 logSecNum) +{ + UINT8 retVal = CI_ERROR; + UINT8 i = 0U; + UINT16* logSecinRouteIdbuff = NULL; /*߼*/ + UINT16 logSecRouteNum = 0U; /*߼Ŀ*/ + UINT8 tmplogState = 0U; /*߼ռѹ״̬*/ + UINT8 wlogSecCount = 0U; + + + logSecRouteNum = GetRouteLogSectionSum(routeId); /*ý·߼Ŀ*/ + logSecinRouteIdbuff = GetRouteLogSectionIdBuf(routeId); /*·߼*/ + if (0U < logSecRouteNum) + { + retVal = CI_SUCCESS; + /*ӽ·նǰұռѹ߼*/ + for (i = 0U; i < logSecRouteNum; i++) + { + tmplogState = GetLogSecCurCtOrUtOccupyState(logSecinRouteIdbuff[i]); + if (LOGICSECTION_OCCUPY_NO == tmplogState) + { + /*һ*/ + } + else if (LOGICSECTION_OCCUPY_CT == tmplogState) + { + logSecId[wlogSecCount] = logSecinRouteIdbuff[i]; + wlogSecCount++; + } + else + { + /*UTռãʧ*/ + logSecId[0U] = logSecinRouteIdbuff[i]; + retVal = CI_ERROR; + break; + } + + } + } + logSecNum = wlogSecCount; + return retVal; +} + +/* +* ȡָID·֮ǰල +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·֮ǰල +*/ +UINT8 GetRoutePreLevel(const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (bufIndex < ROUTE_SUM_MAX) + { + retVal = RouteDataStru[bufIndex].RoutePreLevel; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ý·ⱨ־ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +* Created By LQ 2024.08.19 +*/ +void SetRouteHasDrivedSGBJFlag(UINT16 routeId, UINT8 setFlag) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_HAS_DRIVED_SGBJ_VALID == setFlag) || (ROUTE_HAS_DRIVED_SGBJ_INVALID == setFlag)) + { + RouteDataStru[bufIndex].cRouteDrivedSGBJFlag = setFlag; /*ý·ⱨ־*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָ·Ҫⱨ־ +* ˵ const UINT16 routeId ·ID +* ֵ 0x55 δ +* 0xAA +* Created By LQ 2024.08.19 +*/ +UINT8 GetRouteHasDrivedSGBJFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 reVal = ROUTE_HAS_DRIVED_SGBJ_INVALID; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].cRouteDrivedSGBJFlag; + } + else + { + /**/ + } + + return reVal; +} + +/* +* ý·ӽ״̬ѯ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +* by cgh 20241128 +*/ +void SetRouteNearSecSearchState(UINT16 routeId, UINT8 setFlag) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_NEAR_SEC_HAVE_UT == setFlag) || (ROUTE_NEAR_SEC_NOT_HAVE_UT == setFlag)) + { + RouteDataStru[bufIndex].chRouteNearSecSearchState = setFlag; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָ·ӽ״̬ѯ +* ˵ const UINT16 routeId ·ID +* ֵ ROUTE_NEAR_SEC_HAVE_UT ӽйϳ +* ROUTE_NEAR_SEC_NOT_HAVE_UT ӽ޹ϳ +* by cgh 20241128 +*/ +UINT8 GetRouteNearSecSearchState(const UINT16 routeId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 reVal = ROUTE_NEAR_SEC_HAVE_UT; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].chRouteNearSecSearchState; + } + else + { + /**/ + } + + return reVal; +} + +/* +* ȡ·ӽǷпг +* ˵ const UINT16 routeId, ·ID +* UINT8* chOtherCiId ID +* ֵ CI_ERROR ӽпг +* CI_SUCCESS ӽ޿г +* edit cgh 20241128 +*/ +UINT8 GetRouteOtherCiNearSecState(const UINT16 routeId) +{ + UINT8 wRetVal = CI_ERROR; + UINT16 wLogSecId = 0U; + UINT8 logSecIndex = 0u; + UINT8 logSecBelongCiId = 0U; + UINT8 ii = 0U; + UINT8 localCiId = 0U; + UINT8 funcRet = CI_ERROR; + UINT8 nearCbtcSecConditionSum = 0u; /*CBTCӽ*/ + RouteNearLogicSectionStruct* nearLogicSecStru = NULL; /*ӽ߼νṹ*/ + + + /* ȡӽռѹ߼ */ + localCiId = GetSystemParaLocalCiId(); + nearCbtcSecConditionSum = GetRouteCbtcNearSecConditionSum(routeId); /*ȡCBTC·ӽ߼Ŀ*/ + nearLogicSecStru = GetRouteCbtcNearLogSectionStru(routeId); /*ȡCBTC·ӽ߼νṹ*/ + + if ((0u < nearCbtcSecConditionSum) + && (ROUTE_NEARSEC_CONDITION_SUM_MAX >= nearCbtcSecConditionSum) + && (NULL != nearLogicSecStru)) + {/*жӽ*/ + + for (ii = 0U; ii < nearCbtcSecConditionSum; ii++) + { + funcRet = GetRouteNearSecFitSwIndex(routeId, ii); + + if (CI_SUCCESS == funcRet) + { + /*ǰӽηϵλã˳ѭ*/ + break; + } + else + { + ;/**/ + } + } + + /*߱һȫϵλõĽӽ*/ + if ((ii != nearCbtcSecConditionSum) + && (0U != nearLogicSecStru[ii].NearLogicSecSum)) + { + wRetVal = CI_SUCCESS; + /*ýӽ߼*/ + for (logSecIndex = 0U; logSecIndex < nearLogicSecStru[ii].NearLogicSecSum; logSecIndex++) + { + wLogSecId = nearLogicSecStru[ii].NearLogicSecIdBuf[logSecIndex]; + logSecBelongCiId = GetLogSecBelongCiId(wLogSecId); + + if ((localCiId == logSecBelongCiId) && (0U != localCiId)) + { + funcRet = GetLogicSupicTrainStat(wLogSecId); /*ȡǷ߱ɳ*/ + if (CI_ERROR == funcRet) + { + /*пɳ˳*/ + wRetVal = CI_ERROR; + break; + } + else + { + ; /**/ + } + } + else + { + ; /*ڱ*/ + } + } + + } + else + { + + /*ûзλõ*/ + wRetVal = CI_ERROR; + } + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ָ·ڿ־ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +* by cgh 20241202 +*/ +void SetRouteApplySwitchCheckFlag(UINT16 routeId, UINT8 setFlag) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + if ((ROUTE_APPLY_SWITCH_CHECK_NO == setFlag) || (ROUTE_APPLY_SWITCH_CHECK_YES == setFlag) + || (ROUTE_APPLY_SWITCH_CHECK_DEF == setFlag)) + { + RouteDataStru[bufIndex].chRouteApplySwitchCheckFlag = setFlag; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ȡָ·ڿ־ +* ˵ const UINT16 routeId ·ID +* ֵ ·ڿ־ +* by cgh 20241202 +*/ +UINT8 GetRouteApplySwitchCheckFlag(const UINT16 routeId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 reVal = ROUTE_APPLY_SWITCH_CHECK_NO; + + bufIndex = GetRouteConfigBufIndex(routeId); /*ȡ·±*/ + + if (ROUTE_SUM_MAX > bufIndex) + { + reVal = RouteDataStru[bufIndex].chRouteApplySwitchCheckFlag; + } + else + { + ; /**/ + } + + return reVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Route/RouteDataManage.h b/TSCP/src/APP/ciapp/Route/RouteDataManage.h new file mode 100644 index 0000000..1ae84d4 --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/RouteDataManage.h @@ -0,0 +1,1642 @@ +/******************************************************** +* +* RouteDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ROUTE_DATA_MANAGE_H_ +#define _ROUTE_DATA_MANAGE_H_ + +#include "RouteDefine.h" +#include "RouteConfigDataManage.h" +#include "CommonTypes.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../System/CiSystemDefine.h" +#include "../ReverseRoute/ReverseRouteConfigDataManage.h" +#include "../Train/TrainDefine.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*·̬ݽṹ*/ +typedef struct S_HalfRouteDataStruct +{ + UINT8 HalfRouteSwitchMoveValid; /*Ƿɶ*/ + UINT8 RouteLockLgcSecNum; /*߼*/ + UINT16 RouteLockLgcSecIdBuf[MAX_ROUTE_IN_LT_NUM]; /*߼ID*/ + UINT16 HalfResReqTrainId; /*ԴгID*/ + UINT8 TrainLocLgcSecNum; /*г߼*/ + UINT16 TrainLocLgcSecIdBuf[ROUTE_TRAIN_LOC_MAX_LGC_SUM]; /*г߼ID*/ +}HalfRouteDataStruct; + + +/*·̬ݽṹ*/ +typedef struct S_RouteDataStruct +{ + UINT16 RouteId; /*·ID (ʼֶ)*/ + UINT8 RouteState; /*·״̬ (ֶ̬)*/ + UINT8 RoutePreState; /* ǰһ·״̬ */ + UINT8 RoutePreLevel; /*·֮ල(ʽ/CBTC) (ֶ̬)*/ + UINT8 RouteLevel; /*·ල(ʽ/CBTC) (ֶ̬)*/ + UINT32 RouteLevelChangeCyc; /*·ල仯ʼں*/ + UINT16 AutoRouteId; /*Զ·Id(δ/) (ֶ̬)*/ + UINT16 AutoReturnId; /*Զ۷·Id(δ/) (ֶ̬)*/ + UINT32 XuanPaiStartCycNum; /*ѡʼں (ֶ̬)*/ + UINT32 RouteLockStartCycNum; /*·ʼں (ֶ̬)*/ + UINT32 OverlapLockStartCycNum; /*ʼں (ֶ̬)*/ + UINT32 RouteOpenSigStatrtCycNum; /*·źſʼں (ֶ̬)*/ + UINT32 DelayUnlockStartCycNum; /*·ʱʼں (ֶ̬)*/ + UINT32 LeadFaultOpenStartCycNum; /*źڷһιźſʼں (ֶ̬)*/ + UINT16 OverlapLockedId; /*ǰ·OverlapչOverlapId*/ + UINT8 ZongQuXiaoFlag; /*ȡ־(δ/) (ֶ̬)*/ + UINT8 ZongRenJieFlag; /*˽־(δ/) (ֶ̬)*/ + UINT8 RepeatOpenFlag; /*źؿ־(δ/) (ֶ̬)*/ + UINT8 StopCheckFlag; /*ֹͣ־(δ/) (ֶ̬)*/ + UINT8 StopKeepCheckFlag; /* ʱ */ + UINT8 AutoSigPropertyLoseEfficacyFlag; /*ԶźʧЧ־δ/ãֶ̬Σ*/ + UINT16 BelongLongRouteId; /*·ID (ֶ̬)*/ + UINT16 ThroughRouteId; /*ͨ·ID(0δ/) (ʼֶ)*/ + UINT16 AllAutoReturnId; /*ȫԶ۷·Id(δ/) (ֶ̬)*/ + UINT8 StopensureFlag; /*֤ͣ־(δ/) (ֶ̬)*/ + UINT8 ResourcecancelFlag; /*Դȡ־(/) (ֶ̬)*/ + UINT8 SPKSToRouteCloseFlag; /*SPKS½·ʼźŻرձ־ֶ̬Σ*/ + UINT8 RouteAssoSwitSingOperStat; /*·״̬*/ + UINT8 RouteInnerSwitDrivState; /*·ڵ״̬*/ + UINT8 RouteAssocSwitDrivState; /*·״̬*/ + UINT8 RouteStateFlag; /*·״̬־1ʾЧ0ʾЧ*/ + UINT8 TrainEnterFlag; /*гʻ־*/ + UINT8 ZongRenJieDelayType; /*˽ʱͣΪʱȫνһռѹǰ쳣գеα쳣*/ + UINT8 RecoverOpenState; /*·Ҫؿ״̬ڴPSDSPKS۳ָؿź*/ + UINT8 TrainEnterRouteFlag; /*гʻ·־ڳ;۷ʹ*/ + UINT16 atsExptLkOverlapId; /*ATSֵյOverlapId*/ + UINT16 OtherCIRouteOvlpUTUnlockCount; /*·UTUT*/ + UINT16 OtherCIRouteOvlpCTUnlockCount; /*·CTCT*/ + UINT8 NeedOpenNotTrueRepeatFlag; /*迪Ųʱؿ־*/ + UINT32 NeedOpenNotTrueRepeatStartCount; /*迪Ųʱؿʼ*/ + UINT8 DCQState; /*״̬*/ + UINT8 DCTYState; /*ͬ״̬*/ + + UINT8 DCTYNotSatisfySignalReOpenFlag; /*ͬⲻ-źؿ־*/ + UINT32 DCTYNotSatisfyStartCount; /*ͬⲻ-ʼ*/ + UINT8 CancleDelayflag; /*ȡ·ʱ־*/ + UINT8 CancelResDelayflag; /*Դȡ־λ*/ + UINT32 RouteKeepSignalTolerateCycNum; /*ʽ·źſ״̬£նźŻ״̬鲻ͨźű̿״̬ʼ*/ + UINT8 AutoSigCancleState; /*ԶźŽ·ȡ״̬*/ + UINT8 CancleAutoSigCmd; /*Զźȡ־*/ + + UINT8 OverlapNeedCIlockFlag; /*Ҫձ־*/ + UINT8 OverlapLockProcFlag; /*·ıչ*/ + UINT8 GroupRouteCmdFlag; /*·ǷϽ·־ն·ڸ·״̬ãк*/ + UINT8 AutoTriggerFlag; /*·ǷԶ*/ + + UINT16 wStopEnsureTrainId; /*·֤ͣгID*/ + UINT32 dwStopEnsureCyc; /* ֤ͣѯں */ + + UINT16 wResourceCancelTrainId; /*·ԴȡгID*/ + UINT32 dwResourceCancelCyc; /* Դȡѯں */ + + UINT16 wZhefanjiesuoTrainId; /*·ӽijҪг;۷ijID*/ + UINT32 dwRouteZhefanjiesuoCyc; /*·ӽijҪг;۷ں*/ + + UINT8 cResReqOtherCIId; /*ԴID*/ + UINT8 chResReqTrainSum; + UINT16 wszResReqTrainId[ROUTE_APPLY_RECD_TRAIN_SUM_MAX]; /*ԴгID*/ + UINT8 ITSRouteApplyTrainIdSum; /*ITS·гID¼*/ + UINT16 ITSRouteApplyTrainIdBuf[ROUTE_APPLY_RECD_TRAIN_SUM_MAX]; /*ͨITS·¼гID*/ + UINT8 chShareOverlapCiId; /*ID*/ + UINT8 chRouteXiansuConfirm; /*·ȷ״̬*/ + HalfRouteDataStruct HalfRouteDataSt; /*·״̬*/ + UINT16 wBelongDrId; /*̬·ID*/ + UINT32 dwFirstElockStartCycNum; /*·һյ߼ʱιʼں*/ + UINT8 cRelZuHeRouteSGBJDelayFlag; /*Ͻ·ʱű־*/ + UINT32 dwDelayOpenStartCycNum; /*ⱨ·ʱʱʼ*/ + UINT8 cRouteNeedDriveSGBJFlag; /*·ⱨ־0x55 Ч0xAA Ч*/ + UINT8 cRouteDrivedSGBJFlag; /*·ⱨ־0x55 δ0xAA */ + UINT8 chRouteNearSecSearchState; /*·ӽ״̬*/ + UINT8 chRouteApplySwitchCheckFlag; /*·ڿ־*/ +} RouteDataStruct; + + +extern RouteDataStruct RouteDataStru[ROUTE_SUM_MAX]; /*·ݽṹ*/ +/* +* ȡָID· +* ˵ +* ֵ + RouteDataStruct * +*/ +RouteDataStruct *GetRouteData(void); + +/* +* ȡָID·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT8 GetRouteState(const UINT16 routeId); + +/* +* ȡָID·ǰһ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT8 GetRoutePreState(const UINT16 routeId); + +/* +* ָID·״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 routeState, ·״̬ +* ֵ CI_ERROR +* CI_SUCCESS +* edit cgh 20250224 +*/ +UINT8 SetRouteState(const UINT16 routeId, const UINT8 routeState); + +/* +* ȡָID·ල仯ں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ල仯ں +* by cgh 20240325 +*/ +UINT32 GetRouteLevelChangeCyc(const UINT16 routeId); + +/* +* ȡָID·ල +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ල +*/ +UINT8 GetRouteLevel(const UINT16 routeId); + +/* +* ָID·ල +* ˵ const UINT16 routeId, ·ID +* const UINT8 routeLevel, · +* ֵ +* +*/ +void SetRouteLevel(const UINT16 routeId, const UINT8 routeLevel); + +/* +* ȡָID·Զ۷·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զ·״̬ +*/ +UINT16 GetRouteAutoReturnId(const UINT16 routeId); + +/* +* ָID·Զ۷·Id +* ˵ const UINT16 routeId, ·ID +* const UINT8 autoRouteState, Զ·״̬ +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ݳɹ +*/ +UINT8 SetRouteAutoReturnId(const UINT16 routeId, const UINT16 autoDataId); + + +/* +* ȡָID·ԶźʧЧ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ԶźʧЧ״̬ +*/ +UINT8 GetRouteAutoSigLoseEfficacyFlag(const UINT16 routeId); + +/* +* ָID·ԶźʧЧ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 autoSigPropertyLoseEfficacyFlag, ·ԶźʧЧñ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteAutoSigLoseEfficacyFlag(const UINT16 routeId, const UINT8 autoSigPropertyLoseEfficacyFlag); + +/* +* ȡָID·ӦԶ·ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: Զ·ID +*/ +UINT16 GetRouteAutoRouteId(const UINT16 routeId); + +/* +* ָID·Զ·Id +* ˵ const UINT16 routeId, ·ID +* const UINT8 autoRouteState, Զ·״̬ +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ݳɹ +*/ +UINT8 SetRouteAutoRouteId(const UINT16 routeId, const UINT16 autoDataId); + + +/* +* ȡָID·Զ·״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_AUTOROUTE_NONE 0x01 Զ + ROUTE_AUTOROUTE_NORMAL 0x02 ͨԶ· + ROUTE_AUTOROUTE_RETURN 0x03 Զ۷· + ROUTE_AUTOROUTE_ERROR 0xFF Զ +*/ +UINT8 GetRouteAutoRouteSetState(const UINT16 routeId); + +/* +* ȡָID·Զź״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ ROUTE_AUTOSIGROUTE_YES 0xaa ·ԶźŽ· + ROUTE_AUTOSIGROUTE_NO 0x55 ·ԶźŽ· +*/ +UINT8 GetRouteAutoSigSetState(const UINT16 routeId); + + +/* +* ȡָID·ѡʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetRouteXuanPaiStartCycNum(const UINT16 routeId); + +/* +* ȡָID·źſʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ѡʼں +*/ +UINT32 GetRouteOpenSigStatrtCycNum(const UINT16 routeId); + +/* +* 趨ָID·źſʼں +* ˵ const UINT16 routeId, ·ID +* ֵ +* +*/ +void SetRouteOpenSigStartCycNum(const UINT16 routeId, const UINT32 signalOpenStartCycNum); + +/* +* ȡָID·ʱʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʽʱʼں +*/ +UINT32 GetRouteDelayUnlockStartCycNum(const UINT16 routeId); + +/* +* ȡָID··ڷźſʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ڷźſʼں +*/ +UINT32 GetRouteLeadFaultOpenStartCyc(const UINT16 routeId); + +/* +* ָID··ڷźſʼں +* ˵ const UINT16 routeId, ·ID +* const UINT32 faultOpenStartCycNum, ·ڷźſʼں +* ֵ +* +*/ +void SetRouteLeadFaultOpenStartCyc(const UINT16 routeId, const UINT32 faultOpenStartCycNum); + +/* +* ȡָID·ʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetRouteLockStartCycNum(const UINT16 routeId); + + +/* +* ȡ·Overlapʼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetOverlapLockStartCycNum(const UINT16 routeId); + +/* +* ý·Overlapʼ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockFlag, ձ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetOverlapLockStartCycNum(const UINT16 routeId, const UINT32 startCycNum); + +/* +* ȡ·Overlapձ־ +* ˵ const UINT16 routeId, ·ID +* ֵ + ROUTE_OVERLAP_SET_NO 0x55 δ + ROUTE_OVERLAP_SET_YES 0xaa + ROUTE_OVERLAP_SET_NULL 0xff ޱ +*/ +UINT8 GetRouteOverlapLockFlag(const UINT16 routeId); + +/* +* ȡ·OverlapID +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockFlag, ձ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT16 GetRouteOverlapLockedId(const UINT16 routeId); + +/* +* ý·OverlapID +* ˵ const UINT16 routeId, ·ID +* const UINT8 lockFlag, ձ־ +* ֵ void +*/ +void SetRouteOverlapLockedId(const UINT16 routeId, const UINT16 OverlapId); + +/* +* ȡָID·ȡ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȡ״̬ +*/ +UINT8 GetRouteZongQuXiaoFlag(const UINT16 routeId); + +/* +* ָID·ȡ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 cancelState, ȡ״̬ +* ֵ void +*/ +void SetRouteZongQuXiaoFlag(const UINT16 routeId, const UINT8 cancelState); + +/* +* ȡָID·˽״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ˽״̬ +*/ +UINT8 GetRouteZongRenJieFlag(const UINT16 routeId); + +/* +* ָID·˽״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 cancelState, ˽״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteZongRenJieFlag(const UINT16 routeId, const UINT8 cancelState); + +/* +* ȡָID·ؿ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ؿ״̬ +*/ +UINT8 GetRouteRepeatOpenFlag(const UINT16 routeId); + +/* +* ָID·ؿ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 repeatOpenFlag, ؿ־ +* ֵ +* +*/ +void SetRouteRepeatOpenFlag(const UINT16 routeId, const UINT8 repeatOpenFlag); + +/* +* ȡָID·ֹͣ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֹͣ״̬ +*/ +UINT8 GetRouteStopCheckFlag(const UINT16 routeId); + +/* +* ָID·ֹͣ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 stopCheckState, ֹͣ״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteStopCheckFlag(const UINT16 routeId, const UINT8 stopCheckState); + +/* +* ȡָID··ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetRouteBelongLongRouteId(const UINT16 routeId); + +/* +* ָID··ID +* ˵ const UINT16 routeId, ·ID +* const UINT16 belongLongRouteId, ·ID +* ֵ +* +*/ +void SetRouteBelongLongRouteId(const UINT16 routeId, const UINT16 belongLongRouteId); + +/* +* ·״̬ЧԼ +* ˵ const UINT8 routeState, ·״̬ +* ֵ 0: Ч +* 1: Ч +*/ +UINT8 RouteStateValidCheck(const UINT8 routeState); +/* +* ָID·ȫԶ۷·Id +* ˵ const UINT16 routeId, ·ID +* const UINT16 autoDataId, ȫԶ·ID +* ֵ CI_ERROR: ʧ +* CI_SUCCESS: ݳɹ +*/ +UINT8 SetRouteAllAutoReturnId(const UINT16 routeId, const UINT16 autoDataId); +/* +* ȡָIDͨ·ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT16 GetRouteThroughRouteId(const UINT16 routeId); + + +/* +* ȡָID·ȫԶ۷·ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ȫԶ·״̬ +*/ +UINT16 GetRouteAllAutoReturnId(const UINT16 routeId); + + +/* +* ȡָID·֤ͣ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* 1: ȡݳɹ +*/ +UINT8 GetRouteStopensureFlag(const UINT16 routeId); + +/* +* ָID·֤ͣ־ +* ˵ const UINT16 routeId, ·ID +* ֵ +* +*/ +void SetRouteStopensureFlag(const UINT16 routeId, const UINT8 stopensureFlag); + +/* +* ȡָID·Դȡ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* 1: ȡݳɹ +*/ +UINT8 GetRouteResourceCancelFlag(const UINT16 routeId); + +/* +* ָID·Դȡ־ +* ˵ const UINT16 routeId, ·ID +* ֵ +* +*/ +void SetRouteResourceCancelFlag(const UINT16 routeId, const UINT8 resourcecancelFlag); + +#if 0 +/* +* ȡָ·ʼIDźŻSPKSرձ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: SPKSźŹرձ־ +*/ +UINT8 GetSPKSToRouteCloseFlag(const UINT16 routeId); + + +/* +* ָ·ʼIDźŻSPKSرձ־ +* ˵ const UINT16 routeId, ·ID + const UINT8 closeFlag, SPKSźŹرձ־ +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 SetSPKSToRouteCloseFlag(const UINT16 routeId,const UINT8 closeFlag); +#endif + +/* +* ȡָID·ֹּͣ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֹּͣ״̬ +*/ +UINT8 GetRouteStopKeepCheckFlag(const UINT16 routeId); + +/* +* ָID·ֹּͣ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 stopKeepCheckState, ֹּͣ״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteStopKeepCheckFlag(const UINT16 routeId, const UINT8 stopKeepCheckState); + +/* +* ȡָID·״̬ +* ˵ const UINT16 routeId, ·ID +* UINT8 *pRouteAssoSwitSingOperStat ·״̬ +* ֵ +* +*/ +void GetRoutAssoSwitSingOperStat(const UINT16 routeId, UINT8 *pRouteAssoSwitSingOperStat); + +/* +* ָID·״̬ +* ˵ const UINT16 routeId, ·ID +* UINT8 RouteAssoSwitSingOperStat ״̬ +* ֵ +* +*/ +void SetRoutAssoSwitSingOperStat(const UINT16 routeId, UINT8 RouteAssoSwitSingOperStat); + +/* +* ȡָID·״̬־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·״̬־ +*/ +UINT8 GetRouteStateFlag(const UINT16 routeId); +/* +* ָID·״̬־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 routeLevel, ·״̬־ +* ֵ void +*/ +void SetRouteStateFlag(const UINT16 routeId, const UINT8 routeStateFlag); +/* +* ָID·ѡʼں +* ˵ const UINT16 routeId, ·ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ѡʼں +*/ +UINT8 SetRouteXuanPaiStartCycNum(const UINT16 routeId, const UINT32 startCycNum); + +#if 0 +/* +* ָ·SPKSָҪؿźű־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, SPKSָҪؿźű־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteSpksReOpenSigFlag(const UINT16 routeId, const UINT8 flag); + +/* +* ָ·Ŀ۳ָҪؿźű־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, ۳ָҪؿźű־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteDetainReOpenSigFlag(const UINT16 routeId, const UINT8 flag); + +/* +* ȡָ·SPKSָҪؿźű־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·SPKSָҪؿźű־ +*/ +UINT8 GetRouteSpksReOpenSigFlag(const UINT16 routeId); + +/* +* ȡָ·Ŀ۳ָҪؿźű־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0:ȡʧ +* >0:·Ŀ۳ָҪؿźű־ +*/ +UINT8 GetRouteDetainReOpenSigFlag(const UINT16 routeId); + +/* +* ָ·Ŀ۳źŹرձ־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, ۳źŹرձ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteDetainCloseFlag(const UINT16 routeId, const UINT8 flag); + +/* +* ȡָ·Ŀ۳źŹرձ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·Ŀ۳źŹرձ־ +*/ +UINT8 GetRouteDetainToRouteCloseFlag(const UINT16 routeId); +#endif + +/* +* ָ·гʻ·־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, гʻ·־ +* ֵ +* +*/ +void SetRouteTrainEnterFlag(const UINT16 routeId, const UINT8 flag); +/* +* ȡָ·гʻ·־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·гʻ·־ +*/ +UINT8 GetRouteTrainEnterFlag(const UINT16 routeId); + +/* +* ָ·˽ʱ +* ˵ const UINT16 routeId, ·ID +* const UINT32 delayType, ˽ʱ +* ֵ +* +*/ +void SetRouteZongRenJieDelayType(const UINT16 routeId, const UINT8 delayType); + +/* +* ȡָ·˽ʱ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·˽ʱ +*/ +UINT8 GetRouteZongRenJieDelayType(const UINT16 routeId); + +/* +* ָ·SPKSPSD۳ָؿźű־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, ˽ʱ +* ֵ +* +*/ +void SetRouteRecoverState(const UINT16 routeId,const UINT8 flag); + +/* +* ȡָ·SPKSPSD۳ָؿźű־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: SPKSPSD۳ָؿźű־ +*/ +UINT8 GetRouteRecoverOpenFlag(const UINT16 routeId); + +/* +* ָ·гǷʻý·־ñ־;۷ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag, гǷʻý·־ +* ֵ +* +*/ +void SetTrainEnterRouteFlag(const UINT16 routeId, const UINT8 flag); + +/* +* ȡָ·гǷʻý·־ñ־;۷ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·гǷʻý·־ +*/ +UINT8 GetTrainEnterRouteFlag(const UINT16 routeId); + +/* +* ȡָID·ձID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ձID +*/ +UINT16 GetRouteAtsExpLkOverlapId(const UINT16 routeId); + +/* +* ָID·ձID +* ˵ const UINT16 routeId, ·ID +* const UINT16 expLkOverlapId, atsֵط͵ձId +* ֵ +* +*/ +void SetRouteAtsExpLkOverlapId(const UINT16 routeId, const UINT16 expLkOverlapId); + +/* +* ȡ·UT +* ˵ const UINT16 routeId,·ID +* ֵ 0: ʧ +* : +*/ +UINT16 GetOtherCIRouteOvlpUTUnlockCnt(const UINT16 routeId); + +/* +* ·UT +* ˵ const UINT16 routeId, ·ID +* const UINT16 count, ·ν +* ֵ +* +*/ +void SetOtherCIRouteOvlpUTUnlockCnt(const UINT16 routeId,const UINT16 count); + + +/* +* ȡ·CT +* ˵ const UINT16 routeId,·ID +* ֵ 0: ʧ +* : +*/ +UINT16 GetOtherCIRouteOverlapCTUnlockCount(const UINT16 routeId); + +/* +* ·CT +* ˵ const UINT16 routeId, ·ID +* const UINT16 count, ·ν +* ֵ +* +*/ +void SetOtherCIRouteOverlapCTUnlockCount(const UINT16 routeId,const UINT16 count); + + +/* +* ָ·迪Ųʱؿźű־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 flag, ؿźű־ +* ֵ +* +*/ +void SetRouteNeedOpenReopenFlag(const UINT16 routeId, const UINT8 flag); + + +/* +* ȡָ·迪Ųʱؿźű־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ؿźű־ +*/ +UINT8 GetRouteNeedOpenReopenFlag(const UINT16 routeId); + +/* +* ȡָID·迪ŲʱʼźŻؿʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ؿʼں +*/ +UINT32 GetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(const UINT16 routeId); + +/* +* 趨ָID·迪ŲʱʼźŻؿʼں +* ˵ const UINT16 routeId, ·ID +* const UINT32 signalOpenStartCycNum źſʼ +* ֵ +* +*/ +void SetRouteNeedOpenNotTrueSigRepeatOpenStartCycNum(const UINT16 routeId, const UINT32 signalOpenStartCycNum); + +/* +* ָ·ĵ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT32 dcqState, ״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteDCQState(const UINT16 routeId, const UINT8 dcqState); + +/* +* ȡָ·ĵ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetRouteDCQState(const UINT16 routeId); + +/* +* ָ·ĵͬ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT32 dcTyState, ״̬ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteDCTYState(const UINT16 routeId, const UINT8 dcTyState); + +/* +* ȡָ·ĵͬ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͬ״̬ +*/ +UINT8 GetRouteDCTYState(const UINT16 routeId); + +/* +* ȡָ·ĵͬⲻźؿ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͬ״̬ +*/ +UINT8 GetRouteDCTYNotSatisfySignalReOpenFlag(const UINT16 routeId); + +/* +* ָ·ĵͬⲻźؿ־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 dcTyState, ͬؿ־ +* ֵ +* +*/ +void SetRouteDCTYNotSatisfySignalReOpenFlag(const UINT16 routeId, const UINT8 dcTyFlag); + +/* +* ȡָ·ĵͬʼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ͬʼ +*/ +UINT32 GetRouteDCTYNotSatisfyStartCnt(const UINT16 routeId); + + +/* +* ָ·ĵͬⲻʼ +* ˵ const UINT16 routeId, ·ID +* const UINT32 dcTyState, ͬʼ +* ֵ +* +*/ +void SetRouteDCTYNotSatisfyStartCnt(const UINT16 routeId, const UINT32 dcTyCount); + +/* +* ָʽ·նźŻ״̬鲻ͨźű̿״̬ʼ +* ˵ const UINT16 routeId, ·ID +* const UINT32 CycleNum, ں +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetRouteKeepSigTolerateCyc(const UINT16 routeId, const UINT32 dwCycleNum); + +/* +* ȡָʽ·նźŻ״̬鲻ͨźű̿״̬ʼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT32 GetRouteKeepSigTolerateCyc(const UINT16 routeId, UINT32 *pTolerateCycNum); + +/* +* ָ·ȡʱ־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 delayflag, ȡʱ־ +* ֵ +* +*/ +void SetRouteZongQuXiaoDelayFlag(const UINT16 routeId, const UINT8 delayflag); + + +/* +* ȡָ·ȡʱ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ȡ־ +*/ +UINT8 GetRouteZongQuXiaoDelayFlag(const UINT16 routeId); + +/* +* ôԶźŽ·ȡ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 cmdFlag ־ +* ֵ +*/ +void SetCancleAutoSigCmdFlag(const UINT16 routeId,const UINT8 cmdFlag); + +/* +* ȡָ·ȡ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ȡ +*/ +UINT8 GetCancleAutoSigCmdFlag(const UINT16 routeId); + +/* +* Զźȡ״̬ +* ˵ const UINT16 routeId, ·ID +* const UINT8 cancleState ·ȡ״̬ +* ֵ +*/ +void SetAutoSigCancleState(const UINT16 routeId,const UINT8 cancleState); + +/* +* ȡָ·ȡ״̬ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·ȡ״̬ +*/ +UINT8 GetAutoSigCancleState(const UINT16 routeId); + +/* +* ȡָ·֤ͣгID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֤ͣгID +*/ +UINT16 GetRouteStopEnassureTrainId(const UINT16 routeId); + +/* +* ý·ѯ֤ͣгID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +*/ +void SetRouteStopEnsureTrainId(const UINT16 routeId, const UINT16 wTrainId); + +/* +* ȡָ·ԴȡгID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֤ͣгID +*/ +UINT16 GetRouteResourceCancelTrainId(const UINT16 routeId); + +/* +* ý·ѯԴȡгID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +*/ +void SetRouteResourceCancelTrainId(const UINT16 routeId, const UINT16 wTrainId); + +/* +* ȡָ·Ҫ۷гID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ֤ͣгID +*/ +UINT16 GetRouteZhefanJiesuoTrainId(const UINT16 routeId); + +/* +* ָ·Ҫ۷гID +* ˵ const UINT16 routeId, ·ID +* const UINT16 wTrainId г +* ֵ +*/ +void SetRouteZhefanJiesuoTrainId(const UINT16 routeId, const UINT16 wTrainId); + + + + + + +/* +* ȡ·ӽг +* ˵ const UINT16 routeId, ·ID +* ֵ 0u ޳ӽ +* ӽгı߱ +*/ +UINT16 GetRouteNearestTrainId(const UINT16 wRouteId); + +/* +* ȡ·ӽгг·ķ +* ˵ const UINT16 routeId, ·ID +* ֵ 0u ޳ӽ +* ӽгı߱ +*/ +UINT16 GetRouteNODirNearestTrainId(const UINT16 wRouteId); + +/* +* ·ԴݱԴ +* ˵ const UINT16 routeId, ·ID +* ֵ 0u ޳ӽ +* ӽгı߱ +*/ +void RouteResourceToOverlap(const UINT16 wRouteId); + +/* +* ȡָID·ԴID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetRouteResReqOtherCIId(const UINT16 routeId); + + +/* +* ָID·ԴID +* ˵ const UINT16 routeId, ·ID +* const UINT8 cOtherCiId, +* ֵ +* +*/ +void SetRouteResReqOtherCIId(const UINT16 routeId, const UINT8 cOtherCiId); + +/* +* ȡָID·Դг +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 * GetRouteResReqTrainIdBuf(const UINT16 routeId); + +/* +* ȡָ·г +* ˵ const UINT16 wRouteId, ·ID +* +* ֵ +*/ +UINT8 GetRouteResReqTrainSum(const UINT16 wRouteId); + +/* +* ɾָгID +* ˵ UINT16 routeId, ·ID +* UINT16 wTrainId гID +* ֵ +*/ +void RemoveRouteReqResTrain(UINT16 routeId, UINT16 wTrainId); + +/* +* ָID·Դг +* ˵ const UINT16 routeId, ·ID +* ֵ +* +*/ +void ClearRouteResReqTrainBuf(const UINT16 routeId); + +/* +* ָID·ԴгID +* ˵ const UINT16 routeId, ·ID +* const UINT8 wTrainId, г +* ֵ +* +*/ +void SetRouteResReqTrainId(const UINT16 routeId, const UINT16 wTrainId); + +/* bug 20220420 wqm 淶ɾ*/ + + +/* +* ȡָ·֤ͣں +* ˵ const UINT16 routeId, ·ID +* ֵ ں +*/ +UINT32 GetRouteStopEnassureCyc(const UINT16 routeId); + + +/* +* ý·ѯ֤ͣں +* ˵ const UINT16 routeId, ·ID +* const UINT32 dwCyc ں +* ֵ +*/ +void SetRouteStopEnsureCyc(const UINT16 routeId, const UINT32 dwCyc); + +/* +* ȡָ·Դȡں +* ˵ const UINT16 routeId, ·ID +* ֵ ں +*/ +UINT32 GetRouteResourceCancelCyc(const UINT16 routeId); + +/* +* ý·ѯԴȡں +* ˵ const UINT16 routeId, ·ID +* const UINT32 dwCyc ں +* ֵ +*/ +void SetRouteResourceCancelCyc(const UINT16 routeId, const UINT32 dwCyc); + +/* +* ȡָ·Ҫг۷ں +* ˵ const UINT16 routeId, ·ID +* ֵ ں +*/ +UINT32 GetRouteZhefanJiesuoCyc(const UINT16 routeId); + +/* +* ָ·Ҫг۷ں +* ˵ const UINT16 routeId, ·ID +* const UINT32 dwCyc ں +* ֵ +*/ +void SetRouteZhefanJiesuoCyc(const UINT16 routeId, const UINT32 dwCyc); + + +/* +* @brief ITS·TrainID +* @details ¼ITS·ָ·гIDԱ·ʱ߼ԴϿӸгID +* @param const UINT16 routeId ·ID +* const UINT16 trainID гID +* @note WQM 20220310 +*/ +void SetITSRouteApplyTrainIDInfo(const UINT16 routeId, const UINT16 trainId); + +/* +* @brief ȡָ·ITS·гID¼ +* @param const UINT16 routeId ·ID +* @return UINT8 retVal ¼гID +* @retval CI_ERROR ĬϷֵ +* ¼гID +* @note WQM 20220310 +*/ +UINT8 GetITSRouteApplyTrainIdSum(const UINT16 routeId); + +/* +* @brief ȡָ·ITS·¼гID +* @param const UINT16 routeId ·ID +* @return UINT16 * retVal ¼гID +* @retval NULL ĬϷֵ +* ¼гID +* @note WQM 20220310 +*/ +UINT16 * GetITSRouteApplyTrainIdBuf(const UINT16 routeId); + +/* +* @brief ָ·ITS·¼гIDϢ +* @param const UINT16 routeId ·ID +* @note WQM 20220310 +*/ +void ClearITSRouteApplyTrainIDInfo(const UINT16 routeId); + +/* +* @brief ý·ùԴCIId +* @details ¼CiIDյñΪԴ +* @param const UINT16 routeId ·ID +* const UINT8 chCiId CiID +* @return +*/ +void SetRouteOvlapShrCiId(const UINT16 routeId, const UINT8 chCiId); + +/* +* @brief ȡ·ùԴCIId +* @param const UINT16 routeId ·ID +* @return UINT8 retVal ¼Ci ID +* @retval CI_ERROR ĬϷֵ +* ¼CiId +*/ +UINT8 GetRouteOvlapShrCiId(const UINT16 routeId); + +/* +* @brief ȡ·ȷ״̬ +* @param const UINT16 routeId ·ID +* @return UINT8 retVal ¼Ci ID +* @retval CI_ERROR ĬϷֵ +* ·ȷ״̬ +*/ +UINT8 GetRouteXiansuConfirmStt(const UINT16 routeId); +/* +* @brief ý·ȷ״̬ +* @details ȷϺ󣬵ʽ·״̬ +* @param const UINT16 routeId ·ID +* const UINT8 chXianSuRemoveStt chXianSuRemoveStt +* @return +*/ +void SetRouteXianSuConfirmStt(const UINT16 routeId, const UINT8 chXianSuConfirmStt); + +/* +* ñҪձ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag ־ +* ֵ +* cgh-ϲCID-2539-10 +*/ +void SetRouteOverlapNeedCIlockFlag(const UINT16 routeId, const UINT8 flag); + +/* +* ȡҪձ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag ־ +* ֵ +* cgh-ϲCID-2539-10 +*/ +UINT8 GetRouteOverlapNeedCIlockFlag(const UINT16 routeId); + +/* +* ñչб־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag ־ +* ֵ +* cgh-ϲCID-2539-10 +*/ +void SetRouteOverlapLockProcFlag(const UINT16 routeId, const UINT8 flag); + +/* +* ȡչб־ +* ˵ const UINT16 routeId, ·ID +* +* ֵ >0 չб־ +* 0 ȡʧ +* cgh-ϲCID-2539-10 +*/ +UINT8 GetRouteOverlapLockProcFlag(const UINT16 routeId); +/* +* ý·ǷϽ·־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 flag ־ +* ֵ +* cgh-ϲCID-2539-10 +*/ +void SetRouteGroupRouteCmdFlag(const UINT16 routeId, const UINT8 flag); + +/* +* ȡ·ǷϽ·־ +* ˵ const UINT16 routeId, ·ID +* +* ֵ >0 Ͻ·־ +* 0 ȡʧ +* cgh-ϲCID-2539-10 +*/ +UINT8 GetRouteGroupRouteCmdFlag(const UINT16 routeId); +/* +* ý·Զ־ +* ˵ UINT16 routeId Զ· +* UINT8 setFlag õԶ־ +* ֵ +* cgh-ϲCID-3037-4 +*/ +void SetRouteAutoTriggerFlag(UINT16 routeId, UINT8 setFlag); +/* +* ȡָ·Զ־ +* ˵ const UINT16 routeId, ·ID +* +* ֵ >0 Ͻ·־ +* 0 ȡʧ +* cgh-ϲCID-3037-4 +*/ +UINT8 GetRouteAutoTriggerFlag(const UINT16 routeId); + +/** +* @brief ȡ·ǰ߼ +* @param[in] const UINT16 wRouteId ·ID +* @param[out] UINT16 szLgcId[MAX_ROUTE_IN_LT_NUM] ߼ID +* @return ߼ +*/ +UINT16 GetRouteLockLgc(const UINT16 wRouteId, UINT16 szLgcId[MAX_ROUTE_IN_LT_NUM]); + +/* +* ȡָID·տɶ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: տɶ־ +*/ +UINT8 GetHalfRouteSwitchMoveValid(const UINT16 routeId); + +/* +* ָID·տɶ־ +* ˵ const UINT16 routeId, ·ID +* const UINT8 switchMoveValid, ɶ־ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +void SetHalfRouteSwitchMoveValid(const UINT16 routeId, const UINT8 switchMoveValid); + +/* +* ȡָID·ԴгID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ԴгID +*/ +UINT16 GetHalfRouteResReqTrainId(const UINT16 routeId); + +/* +* ָID·ԴгID +* ˵ const UINT16 routeId, ·ID +* const UINT8 trainId, гID +* ֵ CI_ERROR +* CI_SUCCESS +*/ +void SetHalfRouteResReqTrainId(const UINT16 routeId, const UINT16 trainId); + + +/* +* ȡָID·߼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·߼ +*/ +UINT8 GetHalfRouteLockLgcSecSum(const UINT16 routeId); + +/* +* ȡָID·߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: ߼ID +*/ +UINT16 * GetHalfRouteLockLgcSecIdBuf(const UINT16 routeId); + +/* +* ָID·߼ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lgcSecNum, ߼ +* const UINT16 *pLgcSecIdBuf ߼ID +* ֵ +* +*/ +void SetHalfRouteLockLgcSec(const UINT16 routeId, const UINT8 lgcSecNum, const UINT16 *pLgcSecIdBuf); + +/* +* ȡָID·г߼ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·г߼ +*/ +UINT8 GetHalfRouteTrainLocLgcSecNum(const UINT16 routeId); + +/* +* ȡָID·г߼ID +* ˵ const UINT16 routeId, ·ID +* ֵ NULL: ȡʧ +* !NULL: г߼ID +*/ +UINT16 * GetHalfRouteTrainLocLgcSecIdBuf(const UINT16 routeId); + +/* +* ָID·г߼Ϣ +* ˵ const UINT16 routeId, ·ID +* const UINT8 lgcSecNum, ߼ +* const UINT16 *pLgcSecIdBuf ߼ID +* ֵ +* +*/ +void SetHalfRouteTrainLocLgcSec(const UINT16 routeId, const UINT8 lgcSecNum, const UINT16 *pLgcSecIdBuf); + + +/* +* ָID·г߼Ϣ +* ˵ const UINT16 routeId, ·ID +* OUT UINT16 szRouteHalfPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetRouteHalfPhysicalSecData(const UINT16 routeId, OUT UINT16 szRouteHalfPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX]); + +/* +* ָID·г߼Ϣ +* ˵ const UINT16 routeId, ·ID +* OUT UINT16 szRouteHalfPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetRouteTrainLocPhySecData(const UINT16 routeId, OUT UINT16 szRouteTrainLocPhySecData[ROUTE_PHYSICALSECTION_SUM_MAX]); + +/* +* ָID·շϢ +* ˵ const UINT16 routeId, ·ID +* OUT RouteProtectSwitchStruct szRouteProtectSwitchStruct[ROUTE_PROTECTSWI_SUM_MAX] ID +* +* ֵ 0ʧ >0 +* +*/ +UINT8 GetRouteHalfProSwData(const UINT16 routeId, OUT RouteProtectSwitchStruct szRouteProSwitchStruct[ROUTE_PROTECTSWI_SUM_MAX]); + +/* +* ȡָID·гԴǷ߼ +* ˵ const UINT16 routeId, ·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: гԴ +* CI_ERROR: гԴ +*/ +UINT8 CheckLgcSecNotInTrainLoc(const UINT16 routeId, const UINT16 lgcSecId); + +/* +* ȡָID·̬·ID +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ̬·ID +*/ +UINT16 GetRouteBelongDrId(const UINT16 routeId); + +/* +* ָID·̬·ID +* ˵ const UINT16 routeId, ·ID +* const UINT16 belongDrId, ̬·ID +* ֵ +* +*/ +void SetRouteBelongDrId(const UINT16 routeId, const UINT16 belongDrId); +/* +* ȡָID·һյ߼ʱιʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetRouFirstElockStaCycNum(const UINT16 routeId); +/* +* ָID·һյ߼ʱιʼں +* ˵ const UINT16 routeId, ·ID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetRouFirstElockStaCycNum(const UINT16 routeId, const UINT32 startCycNum); + + +/* +* ȡָID·гԴ߼ +* ˵ const UINT16 routeId, ·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: гԴ +* CI_ERROR: гԴ +*/ +UINT8 CheckLgcSecHaveTrainLoc(const UINT16 routeId, const UINT16 lgcSecId); + +/* +* ȡָID·гԴ߼ +* ˵ const UINT16 routeId, ·ID +* const UINT16 lgcSecId +* ֵ CI_SUCCESS: ڰԤ +* CI_ERROR: ڰԤ +*/ +UINT8 CheckLgcSecInHalfRoute(const UINT16 routeId, const UINT16 lgcSecId); + +/* +* г·Ϊhalfunlock +* ˵ const UINT16 routeId, ·ID +* +* ֵ +* +*/ +void SetTrainLocRouteHalfUnlock(const UINT16 routeId); + +/* +* ɾ·гԴ +* ˵ const UINT16 routeId, ·ID +* const UINT16 trainId, гID +* ֵ +*/ +void RemoveRouteInCiRes(const UINT16 routeId, const UINT16 trainId); + +/* +* ָ·Դȡʱ־ +* ˵ const UINT16 routeId, ·ID +* const UINT32 delayflag, Դȡʱ־ +* ֵ +* +*/ +void SetRouteResCancelDelayFlag(const UINT16 routeId, const UINT8 delayflag); + +/* +* ȡָ·Դȡʱ־ +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·Դȡʱ־ +*/ +UINT8 GetRouteResCancelDelayFlag(const UINT16 routeId); + + +/* +* ȡ·ӽǷпг +* ˵ const UINT16 routeId, ·ID +* ֵ CI_ERROR ӽпг +* CI_SUCCESS ӽ޿г +* edit cgh 20241128 +*/ +UINT8 GetRouteSuspiciousInNearSec(const UINT16 routeId); +/* +* ȡ·ӽηϵλ +* ˵ const UINT16 nearSecIndex,ӽ± +* ֵ CI_ERROR ϵλ +* CI_SUCCESS ϵλ +*/ +UINT8 GetRouteNearSecFitSwIndex(const UINT16 routeId, const UINT8 nearSecIndex); + +/* +* ָ·ⱨʱʼں +* ˵const UINT16 routeId, ·ID +* const UINT32 dwCyc ں +* ֵ +*/ +void SetRouteDelayOpenStartCyc(const UINT16 routeId, const UINT32 dwCyc); + +/* +* ȡָ·ⱨʱʼں +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ʱʼں +*/ +UINT32 GetRouteDelayOpenStartCyc(const UINT16 routeId); + +/* +* ý·Ҫⱨ־ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +*/ +void SetRouteDriveSGBJFlag(UINT16 routeId, UINT8 setFlag); + +/* +* ȡָ·Ҫⱨ־ +* ˵ const UINT16 routeId ·ID +* ֵ >0 ⱨ־ +* 0 ȡʧ +*/ +UINT8 GetRouteDriveSGBJFlag(const UINT16 routeId); + +/* +* ָ·Ͻ·ⱨʱ־ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +*/ +void SetRelZuHeRouteSGBJDelayFlag(UINT16 routeId, UINT8 setFlag); + +/* +* ȡָ·Ͻ·ⱨʱ־ +* ˵ const UINT16 routeId ·ID +* ֵ >0 ⱨ־ +* 0 ȡʧ +*/ +UINT8 GetRelZuHeRouteSGBJDelayFlag(const UINT16 routeId); + + +/* ·ǷѰ״̬Źŷʹã +* ˵ const UINT16 routeId ·ID +* ֵ CI_ERRORʧ +* ROUTE_TRANSACT_YES ·Ѱ +* ROUTE_TRANSACT_NO ·δ +*/ +UINT8 CheckRouteTransactState(const UINT16 routeId); + +/* ȡ·ڵĵCTռѹ߼ΣUTռѹʧܣ +* ˵ const UINT16 garageDoorId +* logSecId[MAX_ROUTE_IN_LT_NUM] ߼ID +* UINT8 logSecNum ߼ +* ֵ CI_ERRORѯʧ +* CI_SUCCESS ѯɹ +*/ +UINT8 GetCTLogSecOfRoute(const UINT16 routeId, OUT UINT16 logSecId[MAX_ROUTE_IN_LT_NUM], OUT UINT8 logSecNum); + +/* +* ȡָID·֮ǰල +* ˵ const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ·֮ǰල +*/ +UINT8 GetRoutePreLevel(const UINT16 routeId); + +/* +* ý·ⱨ־ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +* Created By LQ 2024.08.19 +*/ +void SetRouteHasDrivedSGBJFlag(UINT16 routeId, UINT8 setFlag); + +/* +* ȡָ·Ҫⱨ־ +* ˵ const UINT16 routeId ·ID +* ֵ 0x55 δ +* 0xAA +* Created By LQ 2024.08.19 +*/ +UINT8 GetRouteHasDrivedSGBJFlag(const UINT16 routeId); + +/* +* ý·ӽ״̬ѯ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +* by cgh 20241128 +*/ +void SetRouteNearSecSearchState(UINT16 routeId, UINT8 setFlag); + +/* +* ȡָ·ӽ״̬ѯ +* ˵ const UINT16 routeId ·ID +* ֵ ROUTE_NEAR_SEC_HAVE_UT ӽйϳ +* ROUTE_NEAR_SEC_NOT_HAVE_UT ӽ޹ϳ +* by cgh 20241128 +*/ +UINT8 GetRouteNearSecSearchState(const UINT16 routeId); + +/* +* ȡ·ӽǷпг +* ˵ const UINT16 routeId, ·ID +* UINT8* chOtherCiId ID +* ֵ CI_ERROR ӽпг +* CI_SUCCESS ӽ޿г +* edit cgh 20241128 +*/ +UINT8 GetRouteOtherCiNearSecState(const UINT16 routeId); + +/* +* ָ·ڿ־ +* ˵UINT16 routeId õĽ·ID +* UINT8 setFlag ñ־ +* ֵ +* by cgh 20241202 +*/ +void SetRouteApplySwitchCheckFlag(UINT16 routeId, UINT8 setFlag); + +/* +* ȡָ·ڿ־ +* ˵ const UINT16 routeId ·ID +* ֵ ·ڿ־ +* by cgh 20241202 +*/ +UINT8 GetRouteApplySwitchCheckFlag(const UINT16 routeId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Route/RouteDefine.h b/TSCP/src/APP/ciapp/Route/RouteDefine.h new file mode 100644 index 0000000..26883bb --- /dev/null +++ b/TSCP/src/APP/ciapp/Route/RouteDefine.h @@ -0,0 +1,383 @@ +/******************************************************** +* +* RouteConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-13 +* ߣ +* ·ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _ROUTE_CONFIG_H_ +#define _ROUTE_CONFIG_H_ + + + +/**/ +#define ROUTE_SUM_MAX ((UINT16)1500) /*·ֵ*/ +#define ROUTE_LONG_SUM_MAX ((UINT16)3000) /*峤·ֵ*/ +#define ROUTE_DYNAMIC_SUM_MAX ((UINT16)100) /*嶯̬·ֵ*/ +#define ROUTE_LOGICAL_SUM_MAX ((UINT16)100) /*߼·ֵ*/ + + +#define ROUTE_CONDITION_SWITCH_SUM_MAX ((UINT16)16) /*ֵ*/ +#define ROUTE_PROTECTUNLOCK_SWIT_SUM_MAX ((UINT16)2) /*·صֵ*/ +#define ROUTE_PHYSICALSECTION_SUM_MAX ((UINT16)16) /*·ֵ*/ +#define ROUTE_SWITCH_SUM_MAX ((UINT16)24) /*·ֵ()*/ +#define ROUTE_PROTECTSWI_SUM_MAX ((UINT16)8) /*·ֵ*/ +#define ROUTE_ENEMYSIGNAL_SUM_MAX ((UINT16)48) /*·صжźֵ*/ +#define ROUTE_INTRUDEPHYSEC_SUM_MAX ((UINT16)20) /*·ֵ*/ +#define ROUTE_BLOCNEAR_PHYSEC_SUM_MAX ((UINT16)40) /*·ʽӽֵ(CI21.3һ޸빫ѯһ)*/ +#define ROUTE_NEARSEC_CONDITION_SUM_MAX ((UINT16)30) /*·ӽֵ*/ +#define ROUTE_CBTCNEAR_LOGSEC_SUM_MAX ((UINT16)40) /*·CBTCӽ߼ֵ(CI21.3һ޸빫ѯһ)*/ +#define ROUTE_BLOCTRIGGER_CONDITION_SUM_MAX ((UINT16)16) /*·ֵ*/ +#define ROUTE_CBTCTRIGGER_LOGSEC_SUM_MAX ((UINT16)24) /*·CBTC߼ֵ*/ +#define ROUTE_LIGHT_LOGSEC_SUM_MAX ((UINT16)10) /*·߼ֵ*/ +#define ROUTE_RETURNSIGNAL_SUM_MAX ((UINT16)15) /*·۷źŻֵ*/ +#define ROUTE_PROTECTSECGROUP_SUM_MAX ((UINT16)4) /*·رֵ*/ +#define ROUTE_FENGSUO_SIGNAL_SUM_MAX ((UINT16)15) /*·طźŻֵ*/ +#define ROUTE_OPENNEEDCLOSESIG_SUM_MAX ((UINT16)15) /*·رźֵ*/ +#define ROUTE_OPENNEEDOPENSIG_SUM_MAX ((UINT16)15) /*·迪źֵ*/ +#define ROUTE_ONLYONEOPENSIG_SUM_MAX ((UINT16)15) /*·ͬʱźֵ*/ +#define ROUTE_SUBROUTE_SUM_MAX ((UINT16)8) /*峤·ӽ·ֵ*/ +#define ROUTE_ESB_SUM_MAX ((UINT16)4) /*վ̨ͣťֵ*/ +#define ROUTE_PSD_SUM_MAX ((UINT16)4) /*վֵ̨*/ +#define ROUTE_THATZC_PHYSEC_SUM_MAX ((UINT16)4) /*Զղֵ*/ +#define ROUTE_OPPOSED_ROUTE_SUM_MAX ((UINT16)540) /*ִ·ֵ*/ +#define ROUTE_SIGNAL_OPPOSED_ROUTE_SUM_MAX ((UINT16)100) /*Ա·ʼźŻΪնźŻ۷·Ŀ*/ +#define ROUTE_FLOOD_GATE_SUM_MAX ((UINT16)2) /* ·Ÿ */ +#define ROUTE_OHTER_CHECK_SUM_MAX ((UINT16)10) /* · */ +#define ROUTE_DRIVED_SWITCH_SUM_MAX ((UINT16)8) /*·ֵ*/ +#define MAX_ROUTE_IN_LT_NUM ((UINT16)100) /*·߼Ŀ*/ +#define ROUTE_BLOC_TRIGGERPHY_NUM ((UINT16)30) /*·ʽֵ*/ +#define MAX_POINT_IN_LOGROUTE ((UINT16)50) /*߼·а*/ + +#define ROUTE_MONORAIL_LEAVE_PHY_SEC_SUM_MAX ((UINT8)5) /*嵥··ȥֵ*/ +#define ROUTE_MONORAIL_PHY_SEC_SWIT_SUM_MAX ((UINT8)5) /*嵥·ֵ*/ + +#define ROUTE_APPLY_RECD_TRAIN_SUM_MAX ((UINT8)20) /*ITS·ֵ֧гֵ*/ /* WQM 20220310*/ + +#define ROUTE_RELATED_SGBJ_NUM_MAX ((UINT16)50U) /*·ⱨĿ*/ + +/*μ־*/ +#define ROUTE_PHYSICALSECTION_CHECK_NO ((UINT8)0x55) /**/ +#define ROUTE_PHYSICALSECTION_CHECK_YES ((UINT8)0xaa) /**/ + +/*·*/ +#define ROUTE_SWITCH_PROPERTY_INROUTE ((UINT8)0x55) /*·е*/ +#define ROUTE_SWITCH_PROPERTY_PROTECT ((UINT8)0xaa) /**/ + +/*߼·źŻ쳣رձ־*/ +#define LOG_ROUTE_SIGNAL_CLOSE_ERR ((UINT8)0x55) /*߼·źŻ쳣ر*/ +#define LOG_ROUTE_SIGNAL_CLOSE_NOERR ((UINT8)0xaa) /*߼·źŻδ쳣ر*/ + +/*·*/ +#define ROUTE_LEAD_PROPERTY_NO ((UINT8)0x55) /**/ +#define ROUTE_LEAD_PROPERTY_YES ((UINT8)0xaa) /*·ΪCBTC*/ +#define ROUTE_LEAD_PROPERTY_CBTC_YES ((UINT8)0xbb) /*·ΪCBTC*/ + +/*·Զ·*/ +#define ROUTE_AUTOROUTE_PROPERTY_NO ((UINT8)0x55) /*߱Զ·*/ +#define ROUTE_AUTOROUTE_PROPERTY_YES ((UINT8)0xaa) /*߱Զ·*/ + +/*·Զź*/ +#define ROUTE_AUTOSIG_PROPERTY_NO ((UINT8)0x55) /*߱Զź*/ +#define ROUTE_AUTOSIG_PROPERTY_YES ((UINT8)0xaa) /*߱Զź*/ + +/*·*/ +#define ROUTE_REVERSE_PROPERTY_NO ((UINT8)0x55) /*߱*/ +#define ROUTE_REVERSE_PROPERTY_YES ((UINT8)0xaa) /*߱*/ + +/*·*/ +#define ROUTE_TYPE_LIECHE ((UINT8)0x11) /*г·*/ +#define ROUTE_TYPE_RETURN ((UINT8)0x22) /*۷·*/ +#define ROUTE_TYPE_DIAOCHE ((UINT8)0x44) /*·*/ +#define ROUTE_TYPE_ZUHE ((UINT8)0x55) /*ϵ·*/ +#define ROUTE_TYPE_AIRSHAFT ((UINT8)0x33) /*羮·*/ +#define ROUTE_TYPE_AUTO_TRIGGER ((UINT8)0x66) /*Զ·*/ +#define ROUTE_TYPE_RUKU ((UINT8)0x77) /*·*/ + +/*·״̬*/ +#define ROUTE_STATE_IDLE ((UINT8)0x01) /*·*/ +#define ROUTE_STATE_FIRST_XUANPAI ((UINT8)0x02) /*·ѡ*/ +#define ROUTE_STATE_XUANPAI ((UINT8)0x03) /*·ѡ*/ +#define ROUTE_STATE_FIRST_LOCK ((UINT8)0x04) /*·*/ +#define ROUTE_STATE_FIRST_LOCKERR ((UINT8)0x05) /*·쳣*/ +#define ROUTE_STATE_YUXIAN_LOCK ((UINT8)0x06) /*Ԥ*/ +#define ROUTE_STATE_YUXIAN_OPEN ((UINT8)0x07) /*Ԥȿ*/ +#define ROUTE_STATE_NEAR_LOCK ((UINT8)0x08) /*ӽ*/ +#define ROUTE_STATE_NEAR_LOCKERR ((UINT8)0x09) /*ӽ쳣*/ +#define ROUTE_STATE_LEAD_FIRST_XUANPAI ((UINT8)0x0A) /*ѡ*/ +#define ROUTE_STATE_NEAR_OPEN ((UINT8)0x10) /*ӽ*/ +#define ROUTE_STATE_DELAY_UNLOCK ((UINT8)0x20) /*ʱ*/ +#define ROUTE_STATE_AUTO_UNLOCK ((UINT8)0x30) /*Զ*/ +#define ROUTE_STATE_AUTO_UNLOCKERR ((UINT8)0x40) /*Զ쳣*/ +#define ROUTE_STATE_LEAD_XUANPAI ((UINT8)0x50) /*ѡ*/ +#define ROUTE_STATE_LEAD_LOCK ((UINT8)0x60) /**/ +#define ROUTE_STATE_LEAD_LOCKERR ((UINT8)0x70) /*쳣*/ +#define ROUTE_STATE_LEAD_OPEN ((UINT8)0x80) /**/ +#define ROUTE_STATE_HALF_FIRST_XUAN ((UINT8)0x91) /*ճѡ״̬´*/ +#define ROUTE_STATE_HALF_XUANPAI ((UINT8)0x92) /*ѡţ״̬¶*/ +#define ROUTE_STATE_HALF_LOCK ((UINT8)0x94) /*գ״̬ճгµ*/ +#define ROUTE_STATE_HALF_UNLOCKDELAY ((UINT8)0x97) /*·һյ߼ʱι*/ +#define ROUTE_STATE_HALF_UNLOCK ((UINT8)0x98) /*гȫպ󣬻гʧͨźתΪ״̬*/ + +#define ROUTE_LONG_STATE_IDLE ((UINT8)0xA1) /*·*/ +#define ROUTE_LONG_STATE_XUANPAI ((UINT8)0xA2) /*·ѡ*/ +#define ROUTE_LONG_STATE_LOCK ((UINT8)0xA3) /*·*/ + +#define ROUTE_DYNAMIC_STATE_IDLE ((UINT8)0xB1) /*̬·*/ +#define ROUTE_DYNAMIC_STATE_FIRST_XUANPAI ((UINT8)0xB2) /*̬·ѡ*/ +#define ROUTE_DYNAMIC_STATE_XUANPAI ((UINT8)0xB3) /*̬·ѡ*/ +#define ROUTE_DYNAMIC_STATE_LOCK ((UINT8)0xB4) /*̬·*/ + +#define ROUTE_LOGICAL_STATE_IDLE ((UINT8)0xC1) /*߼·*/ +#define ROUTE_LOGICAL_STATE_FIRST_XUANPAI ((UINT8)0xC2) /*߼·ѡ*/ +#define ROUTE_LOGICAL_STATE_XUANPAI ((UINT8)0xC3) /*߼·ѡ*/ +#define ROUTE_LOGICAL_STATE_LOCK ((UINT8)0xC4) /*߼·*/ +#define ROUTE_LOGICAL_STATE_OPEN ((UINT8)0xC5) /*߼·*/ +#define ROUTE_LOGICAL_STATE_UNLOCKWAIT ((UINT8)0xC6) /*߼·ȴ*/ +#define ROUTE_LOGICAL_STATE_UNLOCKDELAY ((UINT8)0xC7) /*߼·ʱ*/ +#define ROUTE_LOGICAL_STATE_LOCKERR ((UINT8)0xC8) /*߼·쳣*/ + + +#define LOG_ROUTE_TRAIN_CROSS ((UINT8)0xaa) /*߼·гѹ״̬*/ +/*·ල*/ +#define ROUTE_LEVEL_BLOC ((UINT8)0x55) /*ʽ*/ +#define ROUTE_LEVEL_CBTC ((UINT8)0xaa) /*CBTC*/ + +/*Զ·*/ +#define ROUTE_AUTOROUTE_NONE ((UINT8)0x01) /*Զ*/ +#define ROUTE_AUTOROUTE_NORMAL ((UINT8)0x02) /*ͨԶ·*/ +#define ROUTE_AUTOROUTE_RETURN ((UINT8)0x03) /*Զ۷·*/ +#define ROUTE_AUTOROUTE_ERROR ((UINT8)0xFF) /*Զ*/ +#define ROUTE_ALLAUTOROUTE_RETURN ((UINT8)0x04) /*ȫԶ۷·*/ + +/*ԶźŽ·״̬*/ +#define ROUTE_AUTOSIGROUTE_NO ((UINT8)0x55) /*·ԶźŽ·*/ +#define ROUTE_AUTOSIGROUTE_YES ((UINT8)0xaa) /*·ΪԶźŽ·*/ + + +/*·overlapñ־*/ +#define ROUTE_OVERLAP_SET_NO ((UINT8)0x55) /*δ*/ +#define ROUTE_OVERLAP_SET_YES ((UINT8)0xaa) /**/ +#define ROUTE_OVERLAP_SET_NULL ((UINT8)0xff) /*ޱ*/ + +/*·ȡ־*/ +#define ROUTE_ZONGQUXIAO_SET_NO ((UINT8)0x55) /*δ*/ +#define ROUTE_ZONGQUXIAO_SET_YES ((UINT8)0xaa) /**/ + +/*·˽־*/ +#define ROUTE_ZONGRENJIE_SET_NO ((UINT8)0x55) /*δ*/ +#define ROUTE_ZONGRENJIE_SET_YES ((UINT8)0xaa) /**/ + +/*·źؿ־*/ +#define ROUTE_REPEATOPEN_SET_NO ((UINT8)0x55) /*δ*/ +#define ROUTE_REPEATOPEN_SET_YES ((UINT8)0xaa) /**/ + +/*ֹͣ־*/ +#define ROUTE_STOPCHECK_SET_NO ((UINT8)0x55) /*δ*/ +#define ROUTE_STOPCHECK_SET_YES ((UINT8)0xaa) /**/ + +/*ԶźʧЧ־*/ +#define ROUTE_AUTOSIG_LOSE_SET_NO ((UINT8)0x55) /*δ(ԶźЧ)*/ +#define ROUTE_AUTOSIG_LOSE_REVSET_YES ((UINT8)0xaa) /*·(ԶźʧЧ)*/ +#define ROUTE_AUTOSIG_LOSE_DSSET_YES ((UINT8)0xbb) /*˿(ԶźʧЧ)*/ +#define ROUTE_AUTOSIG_LOSE_DSSET_NO ((UINT8)0xcc) /*˿(ԶźЧ)*/ +#define ROUTE_AUTOSIG_LOSE_REVDSSET_YES ((UINT8)0xdd) /*·˿(ԶźʧЧ)*/ +#define ROUTE_AUTOSIG_LOSE_SET_INVALID ((UINT8)0xff) /*Զź*/ + +/*֤ͣ־*/ +#define ROUTE_STOPENSURE_YES ((UINT8)0x55) /*֤ͣ*/ +#define ROUTE_STOPENSURE_NO ((UINT8)0xaa) /*δ֤ͣ*/ + +/*ȡԴı־*/ +#define ROUTE_RESOURCECANCEL_YES ((UINT8)0x55) /*ȡԴ*/ +#define ROUTE_RESOURCECANCEL_NO ((UINT8)0xaa) /*ȡԴ*/ + +/*ǷSPKS½·ʼźŻص*/ +#define ROUTE_CLOSE_SPKS_YES ((UINT8)0x55) /*SPKS½·ʼźŻص*/ +#define ROUTE_CLOSE_SPKS_NO ((UINT8)0xaa) /*SPKS½·ʼźŻص*/ + +/*,·ڵ*/ +#define ROUTE_INNER_SWITCH ((UINT8)0x01) +#define ROUTE_ASSOC_SWITCH ((UINT8)0x02) + +/*Ƿ񱻵*/ +#define SWITCH_SINGLE_OPERATED_TRUE ((UINT8)0x55) +#define SWITCH_SINGLE_OPERATED_FALSE ((UINT8)0xAA) + +/*Ƿڱ*/ +#define SWITCH_IN_DRIVING_TRUE ((UINT8)0x55) +#define SWITCH_IN_DRIVING_FALSE ((UINT8)0xAA) + +/*ǷҪ*/ +#define SWITCH_NEED_DRIV_TRUE ((UINT8)0x55) +#define SWITCH_NEED_DRIV_FALSE ((UINT8)0xAA) + +/*ǷԱ*/ +#define SWITCH_CAN_BE_DRIVED_TRUE ((UINT8)0x55) +#define SWITCH_CAN_BE_DRIVED_FALSE ((UINT8)0xAA) +/*·״̬תƱ־ǷЧ*/ +#define ROUTE_STATE_FLAG_YES ((UINT8)0x55) /*·״̬תƱ־Ч*/ +#define ROUTE_STATE_FLAG_NO ((UINT8)0xaa) /*·״̬תƱ־Ч*/ + +/*SPKSָҪؿźű־öֵ*/ +#define ROUTE_SPKS_RE_OPEN_SIG_YES ((UINT8)0x55) +#define ROUTE_SPKS_RE_OPEN_SIG_NO ((UINT8)0xaa) + +/*۳ָҪؿźű־öֵ*/ +#define ROUTE_DETAIN_RE_OPEN_SIG_YES ((UINT8)0x55) +#define ROUTE_DETAIN_RE_OPEN_SIG_NO ((UINT8)0xaa) + +/*۳źŹرձ־*/ +#define ROUTE_DETAIN_CLOSE_SIG_YES ((UINT8)0x55) +#define ROUTE_DETAIN_CLOSE_SIG_NO ((UINT8)0xaa) + +/*·гʻ·־öֵ*/ +#define ROUTE_TRAIN_ENTER_FLAG_YES ((UINT8)0x55) +#define ROUTE_TRAIN_ENTER_FLAG_NO ((UINT8)0xaa) + +/*˽ʱͣΪʱȫνһ*/ +#define ROUTE_ZRJ_DELAY_TYPE_IDLE ((UINT8)0x55)/*ʱȫν*/ +#define ROUTE_ZRJ_DELAY_TYPE_ALL_EXP ((UINT8)0xaa) /*еα쳣*/ +#define ROUTE_ZRJ_DELAY_TYPE_EXP_TO_OCCUPY ((UINT8)0x5a) /*һռѹǰ쳣*/ +#define ROUTE_ZRJ_DELAY_TYPE_INVALID ((UINT8)0x00)/*Чֵ*/ + +/*ȡ·ʱ־*/ +#define ROUTE_ZQX_DELAY_YES ((UINT8)0x55) /*ʱ־ʱ*/ +#define ROUTE_ZQX_DELAY_NO ((UINT8)0xaa) /*ʱ־*/ + +#define RUUTE_RESCANCEL_DELAY_YES ((UINT8)0x55) /*Դȡʱ־ʱ*/ +#define RUUTE_RESCANCEL_DELAY_NO ((UINT8)0xaa) /*Դȡʱ־*/ + +/*PSDSPKS۳ָؿźŹõĽ·״̬־궨*/ +#define ROUTE_RECOVER_STA_INIT ((UINT8)0x55)/*ʼ̬·лӽšԤȿʱ״̬*/ +#define ROUTE_RECOVER_STA_WAIT ((UINT8)0xaa) /*ȴPSDSPKS۳ָ״̬*/ +#define ROUTE_RECOVER_STA_STAY ((UINT8)0x5a) /*ȴʱ״̬һ״̬·ԶؿDZ־ٴתROUTE_RE_OPEN_STA_INIT*/ + + +#define ROUTE_NEEDOPEN_REOPEN_NO ((UINT8)0x55) /*迪Ų㣬ؿ־*/ +#define ROUTE_NEEDOPEN_REOPEN_YES ((UINT8)0xaa) /*迪Ų㣬ؿ־*/ + +#define AUTO_ROUTE_CANCLE_NO ((UINT8)0x01) /*ԶźȡЧ*/ +#define AUTO_ROUTE_CANCLE_WAIT ((UINT8)0x02) /*Զźȡȴ*/ +#define AUTO_ROUTE_CANCLE_FAIL ((UINT8)0x03) /*Զźȡʧ*/ +#define AUTO_ROUTE_CANCLE_SUCCESS ((UINT8)0x04) /*Զźȡɹ*/ + +#define AUTO_ROUTE_CANCLE_CMD_YES ((UINT8)0xaa) /*ԶźȡЧ*/ +#define AUTO_ROUTE_CANCLE_CMD_NO ((UINT8)0x55) /*ԶźȡЧ*/ + +/*гʻ·־*/ +#define TRAIN_ENTER_ROUTE_FLAG_YES ((UINT8)0x55) +#define TRAIN_ENTER_ROUTE_FLAG_NO ((UINT8)0xaa) + +#define ROUTE_INIT_ENEMY ((UINT8)0xaa)/*·ʼж*/ +#define ROUTE_INIT_NOT_ENEMY ((UINT8)0x55) + +#define ROUTE_INIT_INSTRU ((UINT8)0xaa)/*·ʼ*/ +#define ROUTE_INIT_NOT_INSTRU ((UINT8)0x55) + +#define ROUTE_INIT_FS ((UINT8)0xaa)/*·ʼ*/ +#define ROUTE_INIT_NOT_FS ((UINT8)0x55) + +#define ROUTE_DCQ_REQUEST ((UINT8)0xaa) /**/ +#define ROUTE_DCQ_NOT_REQUEST ((UINT8)0x55) /*޵*/ + +#define ROUTE_DCT_AGREE ((UINT8)0xaa) /*ͬ*/ +#define ROUTE_DCT_NOT_AGREE ((UINT8)0x55) /*޵ͬ*/ + + +#define ROUTE_DCTY_REOPEN ((UINT8)0xaa) /*ͬؿ*/ +#define ROUTE_DCTY_REOPEN_NO ((UINT8)0x55) /*ͬⲻؿ*/ + +#define ROUTE_NEED_DELAY_UNLOCK ((UINT8)0xaa) /*·״̬/쳣/Ԥգȡ˽Ҫʱ*/ +#define ROUTE_NEED_DELAY_UNLOCK_NO ((UINT8)0x55) /*ȡ˽ⲻҪʱ*/ + +#define ROUTE_SIGNAL_TOLERATE_OPEN_COUNT ((UINT8)5) /*ʽ·źſ״̬£նźŻ״̬鲻ͨźű̿״̬*/ + + + +#define ROUTE_PHYSEC_SHOULD_NOT_OPPOSE_LOCK ((UINT8)0x55) /*Ӧȡ*/ +#define ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK ((UINT8)0xAA) /*Ӧȡ*/ + +#define ROUTE_NOT_HAVE_DIR_CHANGE_POINT ((UINT8)0x55) /*ûз仯*/ +#define ROUTE_HAVE_DIR_CHANGE_POINT ((UINT8)0xAA) /*з仯*/ + +#define ROUTE_AUTOSIG_DSBREAK_LOSE_EFFICACY ((UINT8)0xAA) /*˿˿ԶźʧЧԶؿ*/ +#define ROUTE_AUTOSIG_DSBREAK_NOT_LOSE_EFFICACY ((UINT8)0x55) /*˿˿ԶźŲʧЧԶؿ*/ + +#define OVERLAP_OCC ((UINT8)0xAA) /*ռ*/ + +#define ROUTE_INC_PROTECT_SW_YES ((UINT8)0x55) /*·*/ +#define ROUTE_INC_PROTECT_SW_NO ((UINT8)0xAA) /*·δ*/ + + +#define ROUTE_XIANSU_CONFIRM_YES ((UINT8)0xAA) /* ·ȷ*/ +#define ROUTE_XIANSU_CONFIRM_NO ((UINT8)0x55) /* ·δȷ*/ + +#define ROUTE_CHUXUAN_OVERTIME_CYCLE_NUM (UINT8)(10) /*·ѡѡţóʱʱ䣬10*/ + +#define OVERTIME_YES (UINT8)(0xaa) /*ʱ*/ +#define OVERTIME_NO (UINT8)(0x55) /*δʱ*/ + +#define OVERLAPCILOCK_YES (UINT8)(0xaa) /*ձ־*/ +#define OVERLAPCILOCK_NO (UINT8)(0x55) /*β*/ + +#define OVERLAP_LOCK_SELF_PROC_YES ((UINT8)0xaa) /*չ*/ +#define OVERLAP_LOCK_PROC_NO ((UINT8)0x55) /*βչ*/ +#define OVERLAP_LOCK_ATS_PROC_YES ((UINT8)0xbb) /*ATSչ*/ + +#define ROUTE_GROUPROUTE_CMD_YES ((UINT8)0xaa) /*·Ͻ·־*/ +#define ROUTE_GROUPROUTE_CMD_NO ((UINT8)0x55) /*·Ͻ·־*/ + +#define ROUTE_MAIN_PROPERTY ((UINT8)0x55) /*·*/ +#define ROUTE_SUB_PROPERTY ((UINT8)0xaa) /*ӽ·*/ +#define ROUTE_INIT_PROPERTY ((UINT8)0xff) /*ͨ·*/ + +#define ROUTE_SUB_INCLUDE_SUM_MAX ((UINT16)10) /*·ӽ·Ŀֵ*/ +#define ROUTE_MAIN_BELONG_SUM_MAX ((UINT16)10) /*ӽ··Ŀֵ*/ + +#define ROUTE_TRAIN_LOC_MAX_LGC_SUM ((UINT16)10) /*г߼*/ + +#define ROUTE_HALF_SWITCH_MOVE_VALID ((UINT8)0xaa) /*ؽ·־*/ +#define ROUTE_HALF_SWITCH_MOVE_INVALID ((UINT8)0x55) /*ؽ·*/ + +#define ROUTE_TRAIN_LOC_MAX_SUM ((UINT8)4) /*гռѹ·*/ + +#define ROUTE_HALF_FLAG_VALID ((UINT8)0xaa) /*ؽ·־Ч*/ +#define ROUTE_HALF_FLAG_INVALID ((UINT8)0x55) /*ؽ·־Ч*/ + +#define ROUTE_SGBJ_DELAY_OPEN_VALID ((UINT8)0xaa) /*ⱨʱЧʱ*/ +#define ROUTE_SGBJ_DELAY_OPEN_INVALID ((UINT8)0x55) /*ⱨʱЧʱ*/ + +#define ROUTE_DRIVE_SGBJ_VALID ((UINT8)0xaa) /*·ⱨ־Ч*/ +#define ROUTE_DRIVE_SGBJ_INVALID ((UINT8)0x55) /*·ⱨ־Ч*/ + +#define ROUTE_HAS_DRIVED_SGBJ_VALID ((UINT8)0xaa) /*·ⱨ*/ +#define ROUTE_HAS_DRIVED_SGBJ_INVALID ((UINT8)0x55) /*·δⱨ*/ + +#define ROUTE_LOGICAL_SWITCH_MOVE_VALID ((UINT8)0xaa) /*߼·־*/ +#define ROUTE_LOGICAL_SWITCH_MOVE_INVALID ((UINT8)0x55) /*߼·*/ + +#define ROUTE_TRANSACT_YES ((UINT8)0xaa) /*·Ѱ״̬Źرշ飩*/ +#define ROUTE_TRANSACT_NO ((UINT8)0x55) /*·δ״̬Źرշ飩*/ + +#define ROUTE_CBTC_PROPERTY_YES ((UINT8)0x55) /*·CBTCԣlinkCBTCԣ*/ +#define ROUTE_CBTC_PROPERTY_NO ((UINT8)0xaa) /*·CBTCԣlinkCBTCԣ*/ + +#define ROUTE_RUKU_PROPERTY_YES ((UINT8)0x55U) /*·*/ +#define ROUTE_RUKU_PROPERTY_NO ((UINT8)0xaaU) /*·*/ + +#define ROUTE_NEAR_SEC_HAVE_UT ((UINT8)0x55) /*ӽйϳ*/ +#define ROUTE_NEAR_SEC_NOT_HAVE_UT ((UINT8)0xaa) /*ӽ޹ϳ*/ + +#define ROUTE_APPLY_SWITCH_CHECK_NO ((UINT8)0x55) /*·־_ͨ*/ +#define ROUTE_APPLY_SWITCH_CHECK_YES ((UINT8)0xaa) /*·־_ͨ*/ +#define ROUTE_APPLY_SWITCH_CHECK_DEF ((UINT8)0xFF) /*·־_Ĭ*/ + +#endif + diff --git a/TSCP/src/APP/ciapp/SGBJ/SGBJConfigDataManage.c b/TSCP/src/APP/ciapp/SGBJ/SGBJConfigDataManage.c new file mode 100644 index 0000000..f3663a1 --- /dev/null +++ b/TSCP/src/APP/ciapp/SGBJ/SGBJConfigDataManage.c @@ -0,0 +1,255 @@ +/******************************************************** +* +* SGBJConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2023-09-23 +* ߣ +* ⱨݹ +* ޸ļ¼ +* +********************************************************/ + +#include "SGBJConfigDataManage.h" +#include "CiSystemDefine.h" +#include "SystemParameterManage.h" + +SGBJConfigDataStruct SGBJConfigDataStru[SGBJ_SUM_MAX]; /*ⱨýṹ*/ +UINT16 LocalCiSGBJlIdBuf[SGBJ_SUM_MAX] = { 0U }; /*ⱨID*/ +INT16 SGBJCurSum = 0; /*ⱨ*/ + + +/* +* ȡָIDⱨ +* ˵ const UINT16 wSGBJId ⱨID +* ֵ SIGNAL_SUM_MAX: ȡʧ +* : ȡɹ +*/ +UINT16 GetSGBJConfigBufIndex(const UINT16 wSGBJId) +{ + UINT16 retVal = SGBJ_SUM_MAX; + + if ((1U <= wSGBJId) && (SGBJ_SUM_MAX > wSGBJId)) + { + retVal = wSGBJId; + } + + return retVal; +} + +/* +* ȡⱨǰ +* ˵void +* ֵ 0: ȡʧ +* >0: ⱨǰ +*/ +UINT16 GetSGBJCurSum(void) +{ + UINT16 retVal = 0U; + + if (0 > SGBJCurSum) + { + retVal = 0U; + } + else if (SGBJ_SUM_MAX <= (UINT16)SGBJCurSum) + { + retVal = SGBJ_SUM_MAX; + } + else + { + retVal = (UINT16)SGBJCurSum; + } + + return retVal; +} + +/* +* ⱨ +* ˵ +* ֵ CI_SUCCESS ɹ +* CI_ERROR ʧ +*/ +UINT8 SGBJConfigDataManage(void) +{ + UINT16 ii = 0u; + UINT16 jj = 0u; + UINT16 wSGBJCurSum = 0u; /*ⱨ*/ + UINT8 cLocalCiId = 0U; + UINT8 retVal = CI_ERROR; + + wSGBJCurSum = GetSGBJCurSum(); + + if (wSGBJCurSum < SGBJ_SUM_MAX) + { + retVal = CI_SUCCESS; + + for (ii = 0u; ii < SGBJ_SUM_MAX; ii++) + { + if (jj == wSGBJCurSum) + { + break; + } + + cLocalCiId = GetSystemParaLocalCiId(); + + if (SGBJConfigDataStru[ii].cBelongCiId == cLocalCiId) + { + LocalCiSGBJlIdBuf[jj] = SGBJConfigDataStru[ii].wSGBJId; + jj++; + } + } + } + else + { + retVal = CI_ERROR; /*ݳޣʧ*/ + } + + return retVal; +} + +/* +* ȡָ±ӦⱨID +* ˵ const UINT16 bufIndex ± +* ֵ 0: ȡʧ +* >0: ⱨID +*/ +UINT16 GetSGBJIdByIndex(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 wSGBJCurNum = 0U; + + wSGBJCurNum = GetSGBJCurSum(); + if (bufIndex < wSGBJCurNum) + { + retVal = LocalCiSGBJlIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDⱨļ̵ID1 +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ 0: ȡʧ +* >0: ⱨļ̵ID1 +*/ +UINT16 GetSGBJRelayId(const UINT16 wSGBJlId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSGBJConfigBufIndex(wSGBJlId); /*ȡⱨ±*/ + + if (SGBJ_SUM_MAX > bufIndex) + { + retVal = SGBJConfigDataStru[bufIndex].wSGBJRelayId; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡָIDⱨļ̵ID2 +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ 0: ȡʧ +* >0: ⱨļ̵ID2 +*/ +UINT16 GetSGBJRelayId_2(const UINT16 wSGBJlId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSGBJConfigBufIndex(wSGBJlId); /*ȡⱨ±*/ + + if (SGBJ_SUM_MAX > bufIndex) + { + retVal = SGBJConfigDataStru[bufIndex].wSGBJRelayId_2; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡָIDⱨID +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ 0: ȡʧ +* >0: ⱨID +*/ +UINT8 GetSGBJBelongCiId(const UINT16 wSGBJlId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSGBJConfigBufIndex(wSGBJlId); /*ȡⱨ±*/ + + if (SGBJ_SUM_MAX > bufIndex) + { + retVal = SGBJConfigDataStru[bufIndex].cBelongCiId; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡָIDⱨĽ· +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ 0: ȡʧ +* >0: Ľ· +*/ +UINT16 GetSGBJRelRouteNum(const UINT16 wSGBJlId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSGBJConfigBufIndex(wSGBJlId); /*ȡⱨ±*/ + + if (SGBJ_SUM_MAX > bufIndex) + { + retVal = SGBJConfigDataStru[bufIndex].wSGBJRelatedRouteNum; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡָIDⱨĽ·ID +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ NULL: ȡʧ +* NULL: Ľ·ID +*/ +UINT16* GetSGBJRelRouteIdBuf(const UINT16 wSGBJlId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetSGBJConfigBufIndex(wSGBJlId); /*ȡⱨ±*/ + + if (SGBJ_SUM_MAX > bufIndex) + { + retVal = SGBJConfigDataStru[bufIndex].szSGBJRelatedRouteId; + } + else + { + retVal = NULL; + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/SGBJ/SGBJConfigDataManage.h b/TSCP/src/APP/ciapp/SGBJ/SGBJConfigDataManage.h new file mode 100644 index 0000000..e1cc6dc --- /dev/null +++ b/TSCP/src/APP/ciapp/SGBJ/SGBJConfigDataManage.h @@ -0,0 +1,118 @@ +/******************************************************** +* +* SGBJConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2023-09-23 +* ߣ +* ⱨݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SGBJ_CONFIG_DATA_MANAGE_H_ +#define _SGBJ_CONFIG_DATA_MANAGE_H_ + + +#include "SGBJDefine.h" +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct S_SGBJConfigDataStruct +{ + UINT16 wSGBJId; /*ⱨID*/ + UINT16 wSGBJRelayId; /*ⱨ̵ID1*/ + UINT16 wSGBJRelayId_2; /*ⱨ̵ID2*/ + UINT16 wSGBJRelPhySecNum; /*ⱨ*/ + UINT16 wSGBJRelPhySecId[SGBJ_REL_PHYSEC_SUM_MAX]; /*ⱨID*/ + UINT16 wSGBJRelatedRouteNum; /*ⱨ·*/ + UINT16 szSGBJRelatedRouteId[SGBJ_INCLUDE_ROUTE_SUM_MAX]; /*ⱨЧ·ID*/ + UINT8 cBelongCiId; /*ID*/ +}SGBJConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern SGBJConfigDataStruct SGBJConfigDataStru[SGBJ_SUM_MAX]; /*ⱨýṹ*/ +extern UINT16 LocalCiSGBJlIdBuf[SGBJ_SUM_MAX]; +extern INT16 SGBJCurSum; + +/* +* ȡָIDⱨ +* ˵ const UINT16 wSGBJId ⱨID +* ֵ SIGNAL_SUM_MAX: ȡʧ +* : ȡɹ +*/ +UINT16 GetSGBJConfigBufIndex(const UINT16 wSGBJId); + +/* +* ȡⱨǰ +* ˵void +* ֵ 0: ȡʧ +* >0: ⱨǰ +*/ +UINT16 GetSGBJCurSum(void); + +/* +* ⱨ +* ˵ +* ֵ CI_SUCCESS ɹ +* CI_ERROR ʧ +*/ +UINT8 SGBJConfigDataManage(void); + +/* +* ȡָ±ӦⱨID +* ˵ const UINT16 bufIndex ± +* ֵ 0: ȡʧ +* >0: ⱨID +*/ +UINT16 GetSGBJIdByIndex(const UINT16 bufIndex); + +/* +* ȡָIDⱨļ̵ID1 +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ 0: ȡʧ +* >0: ⱨļ̵ID1 +*/ +UINT16 GetSGBJRelayId(const UINT16 wSGBJlId); + +/* +* ȡָIDⱨļ̵ID2 +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ 0: ȡʧ +* >0: ⱨļ̵ID2 +*/ +UINT16 GetSGBJRelayId_2(const UINT16 wSGBJlId); + +/* +* ȡָIDⱨID +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ 0: ȡʧ +* >0: ⱨID +*/ +UINT8 GetSGBJBelongCiId(const UINT16 wSGBJlId); + +/* +* ȡָIDⱨĽ· +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ 0: ȡʧ +* >0: Ľ· +*/ +UINT16 GetSGBJRelRouteNum(const UINT16 wSGBJlId); + +/* +* ȡָIDⱨĽ·ID +* ˵ const UINT16 wSGBJlId ⱨID +* ֵ NULL: ȡʧ +* NULL: Ľ·ID +*/ +UINT16* GetSGBJRelRouteIdBuf(const UINT16 wSGBJlId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/SGBJ/SGBJDefine.h b/TSCP/src/APP/ciapp/SGBJ/SGBJDefine.h new file mode 100644 index 0000000..a1cfd88 --- /dev/null +++ b/TSCP/src/APP/ciapp/SGBJ/SGBJDefine.h @@ -0,0 +1,25 @@ +/******************************************************** +* +* SGBJDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2023-09-23 +* ߣ +* ⱨͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SGBJ_CONFIG_H_ +#define _SGBJ_CONFIG_H_ + +#define SGBJ_SUM_MAX ((UINT16)200) /*ⱨֵ*/ + +#define SGBJ_REL_PHYSEC_SUM_MAX ((UINT16)6) /*ⱨֵ*/ + +#define SGBJ_INCLUDE_ROUTE_SUM_MAX ((UINT16)40) /*ⱨĽ·ֵ*/ + +#endif + + diff --git a/TSCP/src/APP/ciapp/SPKS/SpksConfigDataManage.c b/TSCP/src/APP/ciapp/SPKS/SpksConfigDataManage.c new file mode 100644 index 0000000..5e8f5a3 --- /dev/null +++ b/TSCP/src/APP/ciapp/SPKS/SpksConfigDataManage.c @@ -0,0 +1,906 @@ +/******************************************************** +* +* SpksConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-05 +* ߣ +* SPKS +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ +#include "SpksConfigDataManage.h" +#include "../System/CiSystemDefine.h" +#include "PhysicalSectionConfigDataManage.h" + +SpksDataConfigStruct spksDataConfigBuff[SPKS_SUM_MAX]; /* ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹ */ +UINT16 spksDataConfigIdxBuff[SPKS_SUM_MAX] = { 0u }; /* */ +MJDataConfigStruct MjDataConfigBuff[MJ_SUM_MAX]; /*Ž̵Ϣ 20230417lc*/ +INT16 gmjSum = 0; +INT16 spksSum = 0; + +UINT16 totalSpksNum = 0u;/*͸Spks*/ +UINT16 localCiMJBuff[MJ_SUM_MAX] = { 0u }; /*Ž*/ + /* + * ȡָIDSPKS + * ˵ const UINT16 spksId, spksId + * ֵ SPKS_SUM_MAX: ȡʧ + * = 1u) && (spksId < SPKS_SUM_MAX)) + { + /* Ŀǰӳ䷽ʽֱ豸ID˸ôֱʹ豸ID */ + index = spksId; + } + + return index; + } + + + /* + * ȡָIDSPKSӦθ + * ˵ SPKSӦ + * ֵ + * ֵ 0: ȡʧ + * >0: ҳɹ + */ + UINT16 GetSpksPhySecSumByIndex(UINT16 spksIndex) + { + UINT16 phySecCount = 0u; + + if((spksIndex >= 1u) && (spksIndex < SPKS_SUM_MAX)) + { + phySecCount = spksDataConfigBuff[spksIndex].phySecNum; + } + else + { + phySecCount = 0u; + } + return phySecCount; + } + + /* + * ȡָIDSPKSƶID + * ˵spksIndex:spkssecIndex + * ֵ + * 0: + * >0: ӦID + */ + UINT16 GetSpksPhySecId(UINT16 spksIndex,UINT16 secIndex) + { + UINT16 phySecId = 0u; + + if((spksIndex >= 1u) && (spksIndex < SPKS_SUM_MAX) && (secIndex < SPKS_MAX_SEC_NUM)) + { + phySecId = spksDataConfigBuff[spksIndex].spksPhySecIdBuff[secIndex]; + } + else + { + phySecId = 0u; + } + + return phySecId; + } + + /* + * ȡSPKSǰ + * ˵ void + * ֵ 0: ȡʧ + * >0: SPKSǰ + */ + UINT16 GetSpksSum(void) + { + UINT16 sum = 0u; + if (spksSum >= (INT16)SPKS_SUM_MAX) + { + sum = SPKS_SUM_MAX ; + } + else if (spksSum < 0) + { + sum = 0u ; + } + else + { + sum = (UINT16)spksSum; + } + + return sum; + } + + /* ȡָŵSPKSID + * ˵ const UINT16 spksIndex, spks + * ֵ 0: ȡʧ + * >0: ҳɹ + */ + UINT16 GetSpksIdByIndex(const UINT16 spksIndex) + { + UINT16 ret = 0u; + if (spksIndex < GetTotalSpksCurNum() ) + { + ret = spksDataConfigIdxBuff[spksIndex]; + } + + return ret; + } + + /* + * SPKS + * ˵ + * ֵ CI_SUCCESS,ɹ + * CI_ERROR,ʧ + */ + UINT8 SpksConfigDataManage(void) + { + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 spksDataSum = 0u; /*źŻ豸*/ + UINT8 ret = CI_ERROR; + UINT8 localCiId = GetSystemParaLocalCiId(); + + /*źŻID*/ + spksDataSum = GetSpksSum(); + totalSpksNum = spksDataSum; + if (spksDataSum < SPKS_SUM_MAX) + {/**/ + + for (ii = 0u; ii < SPKS_SUM_MAX; ii++) + { + if (jj == spksDataSum) + {/*Ч*/ + + break; + } + if(localCiId == spksDataConfigBuff[ii].belongCiId) + {/*òΪЧ*/ + + spksDataConfigIdxBuff[jj] = spksDataConfigBuff[ii].spksId; + jj++; + } + } + ret = CI_SUCCESS; + } + + return ret; + + } + + /* + * ȡָIDӦIJɼ̵ID + * ˵ UINT16 spksId + * ֵ 0: ȡʧ + * >0: ̵ID + */ + UINT16 GetSpksColRelayId(UINT16 spksId) + { + UINT16 bufIndex = 0u; /*±*/ + UINT16 ret = 0u; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + ret = spksDataConfigBuff[bufIndex].colRelayId; + } + + return ret; + } + + /* + * ȡָIDӦ·̵ID + * ˵ UINT16 spksId + * ֵ 0: ȡʧ + * >0: ̵ID + */ + UINT16 GetSpksCutRelayId(UINT16 spksId) + { + UINT16 bufIndex = 0u; /*±*/ + UINT16 ret = 0u; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + ret = spksDataConfigBuff[bufIndex].cutRelayId; + } + + return ret; + } + + /* + * ȡָIDӦıʾ̵ID + * ˵ void + * ֵ 0: ȡʧ + * >0: ̵ID + */ + UINT16 GetSpksDisRelayId(UINT16 spksId) + { + UINT16 bufIndex = 0u; /*±*/ + UINT16 ret = 0u; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + ret = spksDataConfigBuff[bufIndex].displayRelayId; + } + + return ret; + } + + /* + * ȡָIDSpksID + * ˵ const UINT16 spksId, spksId + * ֵ 0: ȡʧ + * >0: ID + */ + UINT8 GetSpksBelongCiId(const UINT16 spksId) + { + UINT16 bufIndex = 0u; /*±*/ + UINT8 ciId = 0u; + + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + ciId = spksDataConfigBuff[bufIndex].belongCiId; + } + else + { + ciId = 0u; + } + + return ciId; + } + + /* + * Spks + * ˵ spksSum SPKS + * spksIdBuff ͸SpksID + * ֵ 1,ɹ + * 0,ʧ + */ + UINT8 AddExtendSpksIdDataManage(UINT16 spksNum,const UINT16 *spksIdBuff) + { + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if ((totalSpksNum + spksNum) >= SPKS_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = totalSpksNum; + totalSpksNum += spksNum; + for(ii = 0u;ii< spksNum;ii++) + { + spksDataConfigIdxBuff[index+ii] = spksIdBuff[ii];/*׷ӵspksDataConfigIdxBuff*/ + } + } + + return retVal; + } + + /* + * ȡ͸ԼSpksǰ + * ˵ void + * ֵ 0: ȡʧ + * >0: Spksǰ + */ + UINT16 GetTotalSpksCurNum(void) + { + UINT16 retVal = 0u; + if (totalSpksNum >= SPKS_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = totalSpksNum; + } + return retVal; + } + + /* + * ȡָID SPKS + * ˵ const UINT16 spksId, SPKS ID + * ֵ 0: ȡʧ + * >0: SPKS + */ + UINT8 GetSpksVirtualAttribute(const UINT16 spksId) + { + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡSPKS±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + retVal = spksDataConfigBuff[bufIndex].VirtualAttribute; + } + else + { + retVal = CI_ERROR; + } + return retVal; + } + +/* +* ȡָIDSpksID +* ˵ const UINT16 spksId, spksId +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSpksBelongVirCiId(const UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 virciId = 0u; + + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + virciId = spksDataConfigBuff[bufIndex].belongVirCIid; + } + else + { + virciId = 0u; + } + + return virciId; +} +/***********ֽ spksʾ̵********************************************/ +/* +* ȡָID spksʾ̵ID +* ˵ const UINT16 spksId +* ֵ 0: ȡʧ +* >0: spksӼ̵ID +*/ +UINT16 GetSpksRepRelayId(const UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡspks±*/ + + if (SPKS_SUM_MAX > bufIndex) + { + retVal = spksDataConfigBuff[bufIndex].repRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + + +/* +* ȡָ·̵IDӦıʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSpksCutDisRelayId(UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 ret = 0u; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (SPKS_SUM_MAX > bufIndex) + { + ret = spksDataConfigBuff[bufIndex].cutDisplayRelayId; + } + + return ret; +} + +/***********ֽ spksʾ̵*********END***********************************/ + +/* +* SPKS־ +* ˵ UINT16 spksId SPKS ID +* UINT8 totalspksFlag SPKS־ +* ֵ +*/ +void SetSpksIstotalSpksFlag(UINT16 spksId, UINT8 totalspksFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (SPKS_SUM_MAX > bufIndex) + { + spksDataConfigBuff[bufIndex].IstotalSpksFlag = totalspksFlag; + } +} +/* +* ȡSPKS־ +* ˵ UINT16 spksId SPKS ID +* UINT8 totalspksFlag SPKS־ +* ֵ SPKS־ +*/ +UINT8 GetSpksIstotalSpksFlag(UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reval = 0u; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (SPKS_SUM_MAX > bufIndex) + { + reval = spksDataConfigBuff[bufIndex].IstotalSpksFlag; + } + return reval; +} + + +/* +* SPKSspksĿ +* ˵ UINT16 spksId SPKS ID +* UINT8 totalspksFlag SPKS־ +* ֵ +*/ +void SetSpksIncludeSpksNum(UINT16 spksId, UINT8 includeSpksNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (SPKS_SUM_MAX > bufIndex) + { + spksDataConfigBuff[bufIndex].IncludeSpksNum = includeSpksNum; + } +} + +/* +* ȡSPKSSPKSĿ +* ˵ UINT16 spksId SPKS ID +* +* ֵ +*/ +UINT8 GetSpksIncludeSpksNum(UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = 0u; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (SPKS_SUM_MAX > bufIndex) + { + reVal = spksDataConfigBuff[bufIndex].IncludeSpksNum; + if (INCLUDELESPKS_MAX_NUM < reVal) + { + reVal = 0u; + } + } + + return reVal; +} + +/* +* ȡSPKS־ +* ˵ UINT16 spksId SPKS ID +* +* ֵ SPKS ID +*/ +UINT16* GetSpksIncludeSpksIdBuf(UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* pIncludeSpksIdBuf = NULL; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (SPKS_SUM_MAX > bufIndex) + { + pIncludeSpksIdBuf = spksDataConfigBuff[bufIndex].IncludeSpksIdBuf; + } + + return pIncludeSpksIdBuf; +} + +/* +* ȡָIDӦʾƼ̵ +* ˵ UINT16 spksId SPKS ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSpksOutsideRelayId(UINT16 spksId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16 ret = 0; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (SPKS_SUM_MAX > bufIndex) + { + ret = spksDataConfigBuff[bufIndex].outsideRelayId; + } + + return ret; +} + +/* +* ȡŽǰ +* ˵ void +* ֵ Žǰ +*/ +UINT16 GetMjjsSum(void) +{ + UINT16 sum = 0U; + if ((INT16)MJ_SUM_MAX <= gmjSum) + { + sum = MJ_SUM_MAX; + } + else if (0 > gmjSum) + { + sum = 0u; + } + else + { + sum = (UINT16)gmjSum; + } + return sum; +} + +/* ȡָŽŽ̵ID +* ˵ const UINT16 mjjsIndex, +* ֵ 0: ȡʧ +* >0: Ž̵ID +*/ +UINT16 GetMjjsRelayId(const UINT16 mjid) +{ + UINT16 retval = CI_ERROR; + UINT16 buffIndex = 0u; + buffIndex = GetMJBufIndex(mjid); + + if (MJ_SUM_MAX > buffIndex) + { + retval = MjDataConfigBuff[buffIndex].mjjsRelayId; + } + else + { + retval = 0U; + } + return retval; +} + +/* ȡָŵŽ̵ӦSPKSID +* ˵ const UINT16 mjjsIndex, Ž̵ + const UINT16 spksIndex, spks +* ֵ 0: ȡʧ +* >0: ҳɹ +*/ +UINT16 GetSpksIdByMjjsIndex(const UINT16 mjid, const UINT16 spksIndex) +{ + UINT16 retval = 0U; + UINT16 buffIndex = 0u; + buffIndex = GetMJBufIndex(mjid); + + if ((MJ_SUM_MAX > buffIndex) && (MJ_MAX_SPKSNUM > spksIndex)) + { + retval = MjDataConfigBuff[buffIndex].relSpksIdBuff[spksIndex]; + } + else + { + } + return retval; +} + +/* +* ȡŽ̵Ӧspks +* ˵ UINT16 mjjsIndex mjjs ID +* ֵ Ž̵Ӧspks +*/ +UINT8 GetSpksCountByMjID(const UINT16 mjid) +{ + UINT8 retval = CI_ERROR; + UINT16 buffIndex = 0u; + buffIndex = GetMJBufIndex(mjid); + + if (MJ_SUM_MAX > buffIndex) + { + retval = MjDataConfigBuff[buffIndex].relSpkscount; + } + else + { + retval = 0U; + } + return retval; + +} + +/* ȡָŽID +* ˵ const UINT16 mjid, +* ֵ 0: ȡʧ +* >0: Ž̵ +*/ +UINT8 GetMjBelongCIID(const UINT16 mjid) +{ + UINT8 retval = CI_ERROR; + UINT16 buffIndex = 0u; + buffIndex = GetMJBufIndex(mjid); + + if (MJ_SUM_MAX > buffIndex) + { + retval = MjDataConfigBuff[buffIndex].belongCiId; + } + else + { + retval = 0U; + } + return retval; +} +/* +* ȡָIDޱ +* ˵ const UINT16 signalId, źŻD +* ֵ SIGNAL_SUM_MAX: ȡʧ +* mjid)) + { + retVal = mjid; + } + + return retVal; +} + +/* +* ȡָ±ӦŽID +* ˵ const UINT16 bufIndex ± +* ֵ 0: ȡʧ +* >0: ŽID +*/ +UINT16 GetMJIdByIndex(const UINT16 mjIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 wMJCurNum = 0U; + + wMJCurNum = GetMjjsSum(); + if (mjIndex < wMJCurNum) + { + retVal = localCiMJBuff[mjIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* Ž +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 MjConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 curMjConfigDataSum = 0u; /*ǰESB豸*/ + UINT8 reVal = CI_SUCCESS; + UINT8 localCi = 0u; + + localCi = GetSystemParaLocalCiId(); + curMjConfigDataSum = GetMjjsSum(); + if (curMjConfigDataSum >= MJ_SUM_MAX) + {/**/ + + reVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < MJ_SUM_MAX; ii++) + { + if (jj == curMjConfigDataSum) + {/*Ч*/ + + break; + } + + if (MjDataConfigBuff[ii].belongCiId == localCi) + {/*òΪЧݣ*/ + + localCiMJBuff[jj] = MjDataConfigBuff[ii].mjId; + jj++; + } + } + } + + + return reVal; +} + +/* +* ȡָID Spksվ̨ID +* ˵ const UINT16 spksId SPKS ID +* ֵ 0: ȡʧ +* >0: SPKSվ̨ID +* Created By LQ 2023.11.14 +*/ +UINT16 GetSpksRelPlatFormId(const UINT16 wSpksId) +{ + UINT16 retVal = CI_ERROR; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSpksConfigBufIndex(wSpksId); /*ȡSPKS±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + retVal = spksDataConfigBuff[bufIndex].wSpksRelPlatFormId; + } + else + { + /*ηǷʧ*/ + } + + return retVal; +} + +/* +* ȡָIDѩվ̨SPKS +* ˵ const UINT16 wPlatFormId վ̨ID +* UINT16 pPlatFormRelSpksId[] վ̨SPKS ID飨Σ +* ֵ 0: ȡʧ +* >0: վ̨SPKS +* Created By LQ 2023.11.14 +*/ +UINT8 GetPlatFormRelSpksNum(const UINT16 wPlatFormId, UINT16 pPlatFormRelSpksId[PLATFORM_REL_SPKS_NUM_MAX]) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 wSpksCurSum = 0U; /*SPKSǰ*/ + UINT16 wSpksId = 0U; + UINT16 wTempPlatFormId = 0U; /*SPKSվ̨ID*/ + UINT8 cRelSpksNum = 0U; /*վ̨SPKS*/ + + if ((0U != wPlatFormId) && (NULL != pPlatFormRelSpksId)) + { + wSpksCurSum = GetTotalSpksCurNum(); /*ȡڿSPKS*/ + for (ii = 0U; ii < wSpksCurSum; ii++) + { + wSpksId = GetSpksIdByIndex(ii); + wTempPlatFormId = GetSpksRelPlatFormId(wSpksId); + + if (wPlatFormId == wTempPlatFormId) + { + if (PLATFORM_REL_SPKS_NUM_MAX > cRelSpksNum) + { + pPlatFormRelSpksId[cRelSpksNum] = wSpksId; + cRelSpksNum++; + } + else + { + cRelSpksNum = CI_ERROR; /*ֹͣʧ*/ + break; + } + } + else + { + /**/ + } + + } + + retVal = cRelSpksNum; + } + else + { + /*ηǷ0*/ + } + + return retVal; +} + +/* +* ȡָIDѩվ̨ +* ˵ const UINT16 wPlatFormId ѩվ̨ID +* ֵ 0: ȡʧ +* >0: ѩվ̨ +* Created By LQ 2023.11.23 +*/ +UINT8 GetAreaSnowPlatFormBelongCiId(const UINT16 wPlatFormId) +{ + UINT8 retVal = CI_ERROR; + UINT16 ii = 0U; + UINT16 wSpksCurSum = 0U; /*SPKSǰ*/ + UINT16 wSpksId = 0U; + UINT16 wTempPlatFormId = 0U; /*SPKSվ̨ID*/ + + if (0U != wPlatFormId) + { + wSpksCurSum = GetTotalSpksCurNum(); /*ȡڿSPKS*/ + for (ii = 0U; ii < wSpksCurSum; ii++) + { + wSpksId = GetSpksIdByIndex(ii); + wTempPlatFormId = GetSpksRelPlatFormId(wSpksId); + + if (wPlatFormId == wTempPlatFormId) + { + retVal = GetSpksBelongCiId(wSpksId); /*SPKSID*/ + } + else + { + /**/ + } + } + } + else + { + /*ηǷ0*/ + } + + return retVal; +} + + + +/* +* ָSPKSǷ +* ˵ const UINT16 spksId SPKS ID +* ֵ CI_SUCCESS: +* CI_ERROR: +* UINT8_MAXѯʧ +* Created By LQ 2023.11.14 +*/ +UINT8 CheckSpksRelSecBelongCI(const UINT16 wSpksId) +{ + UINT8 retVal = CI_ERROR; + UINT16 bufIndex = 0u; /*±*/ + UINT16 phySecSum = 0U; /*SPKSĿ*/ + UINT16 tmpPphySecId = 0U; + UINT16 i = 0U; + UINT8 cPhySecBelongCiId = 0U; + UINT8 localCIID = 0U; + + bufIndex = GetSpksConfigBufIndex(wSpksId); /*ȡSPKS±*/ + localCIID = GetSystemParaLocalCiId(); /*ȡID*/ + + if (SPKS_SUM_MAX > bufIndex) + { + phySecSum = GetSpksPhySecSumByIndex(bufIndex); + retVal = CI_SUCCESS; + if ((SPKS_MAX_SEC_NUM >= phySecSum) && (0U < phySecSum)) + { + for (i = 0U; i < phySecSum; i++) + { + tmpPphySecId = GetSpksPhySecId(bufIndex, i); + cPhySecBelongCiId = GetPhySecBelongCiId(tmpPphySecId); + + /*SPKSδ*/ + if ((localCIID == cPhySecBelongCiId) && (0U != localCIID)) + { + + retVal = CI_ERROR; + break; + + } + } + } + else + { + /*ʧ*/ + retVal = UINT8_MAX; + } + } + else + { + /*ηǷʧ*/ + retVal = UINT8_MAX; + } + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/SPKS/SpksConfigDataManage.h b/TSCP/src/APP/ciapp/SPKS/SpksConfigDataManage.h new file mode 100644 index 0000000..899d9fd --- /dev/null +++ b/TSCP/src/APP/ciapp/SPKS/SpksConfigDataManage.h @@ -0,0 +1,350 @@ +/******************************************************** +* +* SPKSDataConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-05 +* ߣ +* SPKS +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SPKS_CONFIG_DATA_MANAGE_H_ +#define _SPKS_CONFIG_DATA_MANAGE_H_ + +#include "CommonTypes.h" +#include "SpksDefine.h" +#include "../System/SystemParameterManage.h" +typedef struct +{ + UINT16 spksId; /* spks */ + UINT16 colRelayId; /* spksӦIJɼ̵ID ̵ */ + UINT16 displayRelayId; /* ɼӦ̵ ̵ */ + UINT16 cutRelayId; /*spks·̵ID ̵*/ + UINT16 repRelayId; /*spksʾ̵ID ̵*/ + UINT16 cutDisplayRelayId; /*spks·ָʾƼ̵ID ̵*/ + UINT16 menjinJSRelayId; /*spksŽ̵ID ̵*/ + UINT16 spksPhySecIdBuff[SPKS_MAX_SEC_NUM]; /* spksӦķб,ӵͼ */ + UINT16 phySecNum; /* spksӦķ */ + UINT8 belongCiId; /* 㣺 ID */ + UINT8 belongVirCIid; /*ȡID*/ + UINT8 VirtualAttribute; /**/ + + UINT8 IstotalSpksFlag; /*SPKSSPKS־עӵйϽspksʱô˱־*/ + UINT8 IncludeSpksNum; /*SPKSSPKSĿ*/ + UINT16 IncludeSpksIdBuf[INCLUDELESPKS_MAX_NUM]; /*SPKSSPKSID*/ + UINT16 outsideRelayId; /*SPKS ID*/ + UINT16 wSpksLogSecIdBuff[SPKS_MAX_LOG_SEC_NUM]; /* spksӦķ߼б,ӵͼ */ + UINT16 wSpksLogSecNum; /* spksӦķ߼ */ + UINT16 wSpksRelPlatFormId; /*SPKSվ̨ID*/ +} SpksDataConfigStruct; + + +typedef struct +{ + UINT16 mjId; /* spks */ + UINT16 mjjsRelayId; /* Ž̵ID ̵ */ + UINT8 belongCiId; /* ID */ + UINT8 relSpkscount; /*SPKS*/ + UINT16 relSpksIdBuff[MJ_MAX_SPKSNUM]; /*SPKS*/ +} MJDataConfigStruct; + +/*******************************ȫֱ*******************************/ +extern SpksDataConfigStruct spksDataConfigBuff[SPKS_SUM_MAX]; /* ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹ */ +extern UINT16 spksDataConfigIdxBuff[SPKS_SUM_MAX]; /* */ +extern MJDataConfigStruct MjDataConfigBuff[MJ_SUM_MAX]; /*Ž̵Ϣ 20230417lc*/ +extern INT16 gmjSum; +extern INT16 spksSum; + +extern UINT16 totalSpksNum;/*͸Spks*/ +extern UINT16 localCiMJBuff[MJ_SUM_MAX]; /*Ž*/ + +#ifdef __cplusplus +extern "C" { +#endif + + + /* + * ȡָIDSPKS + * ˵ const UINT16 spksId, spks ID + * ֵ SPKS_SUM_MAX: ȡʧ + * 0: ҳɹ + */ + UINT16 GetSpksPhySecSumByIndex(UINT16 spksIndex); + + /* + * ȡָIDSPKSƶID + * ˵spksIndex:spkssecIndex + * ֵ + * 0: + * >0: ӦID + */ + UINT16 GetSpksPhySecId(UINT16 spksIndex,UINT16 secIndex); + + /* + * ȡSPKSǰ + * ˵ void + * ֵ 0: ȡʧ + * >0: SPKSǰ + */ + UINT16 GetSpksSum(void); + + /* + * ȡָIDӦIJɼ̵ID + * ˵ UINT16 spksId + * ֵ 0: ȡʧ + * >0: ̵ID + */ + UINT16 GetSpksColRelayId(UINT16 spksId); + + /* + * ȡָIDӦıʾ̵ID + * ˵ void + * ֵ 0: ȡʧ + * >0: ̵ID + */ + UINT16 GetSpksDisRelayId(UINT16 spksId); + + /* + * ȡָIDӦ·̵ID + * ˵ void + * ֵ 0: ȡʧ + * >0: ̵ID + */ + UINT16 GetSpksCutRelayId(UINT16 spksId); + + /* + * SPKS + * ˵ + * ֵ CI_SUCCESS,ɹ + * CI_ERROR,ʧ + */ + UINT8 SpksConfigDataManage(void); + + /* + * ȡָIDSpksID + * ˵ const UINT16 spksId, źŻID + * ֵ 0: ȡʧ + * >0: ID + */ + UINT8 GetSpksBelongCiId(const UINT16 spksId); + + /* + * Spks + * ˵ spksSum SPKS + * spksIdBuff ͸SpksID + * ֵ 1,ɹ + * 0,ʧ + */ + UINT8 AddExtendSpksIdDataManage(UINT16 spksNum,const UINT16 *spksIdBuff); + + /* + * ȡ͸ԼSpksǰ + * ˵ void + * ֵ 0: ȡʧ + * >0: Spksǰ + */ + UINT16 GetTotalSpksCurNum(void); + + /* + * ȡָID SPKS + * ˵ const UINT16 spksId, SPKS ID + * ֵ 0: ȡʧ + * >0: SPKS + */ + UINT8 GetSpksVirtualAttribute(const UINT16 spksId); + +/* +* ȡָID spksʾ̵ID +* ˵ const UINT16 spksId +* ֵ 0: ȡʧ +* >0: spksӼ̵ID +*/ +UINT16 GetSpksRepRelayId(const UINT16 spksId); + + + + +/* +* ȡָ·̵IDӦıʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSpksCutDisRelayId(UINT16 spksId); + +/* +* ȡָIDSpksID +* ˵ const UINT16 spksId, spksId +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSpksBelongVirCiId(const UINT16 spksId); + +/* +* SPKS־ +* ˵ UINT16 spksId SPKS ID +* UINT8 totalspksFlag SPKS־ +* ֵ +*/ +void SetSpksIstotalSpksFlag(UINT16 spksId, UINT8 totalspksFlag); +/* +* ȡSPKS־ +* ˵ UINT16 spksId SPKS ID +* UINT8 totalspksFlag SPKS־ +* ֵ SPKS־ +*/ +UINT8 GetSpksIstotalSpksFlag(UINT16 spksId); +/* +* SPKSspksĿ +* ˵ UINT16 spksId SPKS ID +* UINT8 totalspksFlag SPKS־ +* ֵ +*/ +void SetSpksIncludeSpksNum(UINT16 spksId, UINT8 includeSpksNum); +/* +* ȡSPKSSPKSĿ +* ˵ UINT16 spksId SPKS ID +* +* ֵ +*/ +UINT8 GetSpksIncludeSpksNum(UINT16 spksId); +/* +* ȡSPKS־ +* ˵ UINT16 spksId SPKS ID +* +* ֵ SPKS ID +*/ +UINT16* GetSpksIncludeSpksIdBuf(UINT16 spksId); + +/* +* ȡָIDӦʾƼ̵ +* ˵ UINT16 spksId SPKS ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSpksOutsideRelayId(UINT16 spksId); + + +/* +* Žǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: Žǰ +*/ +UINT16 GetMjjsSum(void); + +/* ȡָŵŽ̵ID + * ˵ const UINT16 spksIndex, spks + * ֵ 0: ȡʧ + * >0: ҳɹ + */ +UINT16 GetMjjsRelayId(const UINT16 mjid); + + + +/* ȡָŵŽ̵ӦSPKSID +* ˵ const UINT16 mjjsIndex Ž̵ + const UINT16 spksIndex, spks +* ֵ 0: ȡʧ +* >0: ҳɹ +*/ +UINT16 GetSpksIdByMjjsIndex(const UINT16 mjid, const UINT16 spksIndex); + +/*ȡŽ̵Ӧspks*/ +UINT8 GetSpksCountByMjID(const UINT16 mjid); + +/* ȡָŽID +* ˵ const UINT16 mjid, +* ֵ 0: ȡʧ +* >0: Ž̵ +*/ +UINT8 GetMjBelongCIID(const UINT16 mjid); + +/* +* ȡָIDޱ +* ˵ const UINT16 signalId, źŻD +* ֵ SIGNAL_SUM_MAX: ȡʧ +* 0: ŽID +*/ +UINT16 GetMJIdByIndex(const UINT16 mjIndex); + +/* +* Ž +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 MjConfigDataManage(void); + +/* +* ȡָID Spksվ̨ID +* ˵ const UINT16 spksId SPKS ID +* ֵ 0: ȡʧ +* >0: SPKSվ̨ID +* Created By LQ 2023.11.14 +*/ +UINT16 GetSpksRelPlatFormId(const UINT16 wSpksId); + +/* +* ȡָIDѩվ̨SPKS +* ˵ const UINT16 wPlatFormId վ̨ID +* UINT16 pPlatFormRelSpksId[] վ̨SPKS ID飨Σ +* ֵ 0: ȡʧ +* >0: վ̨SPKS +* Created By LQ 2023.11.14 +*/ +UINT8 GetPlatFormRelSpksNum(const UINT16 wPlatFormId, UINT16 pPlatFormRelSpksId[PLATFORM_REL_SPKS_NUM_MAX]); + +/* +* ȡָIDѩվ̨ +* ˵ const UINT16 wPlatFormId ѩվ̨ID +* ֵ 0: ȡʧ +* >0: ѩվ̨ +* Created By LQ 2023.11.23 +*/ +UINT8 GetAreaSnowPlatFormBelongCiId(const UINT16 wPlatFormId); + + +/* +* ָSPKSǷ +* ˵ const UINT16 spksId SPKS ID +* ֵ CI_SUCCESS: +* CI_ERROR: +* UINT8_MAXѯʧ +* Created By LQ 2023.11.14 +*/ +UINT8 CheckSpksRelSecBelongCI(const UINT16 wSpksId); + +#ifdef __cplusplus +}; +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/SPKS/SpksDataManage.c b/TSCP/src/APP/ciapp/SPKS/SpksDataManage.c new file mode 100644 index 0000000..5228bb3 --- /dev/null +++ b/TSCP/src/APP/ciapp/SPKS/SpksDataManage.c @@ -0,0 +1,270 @@ +/******************************************************** +* +* SpksDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-05 +* ߣ +* SPKS +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ +#include "SpksDataManage.h" +#include "SpksConfigDataManage.h" +#include "../System/CiSystemDefine.h" + +SpksDataStruct spksDataBuff[SPKS_SUM_MAX]; /* */ + +/* +* ȡָSPKS +* ˵ +* ֵ + SpksDataStruct* +*/ +SpksDataStruct * GetSpksData(void) +{ + return spksDataBuff; +} + +/* +* ȡָID spksť״̬ +* ˵ const UINT16 spksId, spks ID +* ֵ 0: ȡʧ +* >0: spksť״̬ +*/ +UINT8 GetSpksState(const UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 status = CI_ERROR; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + status = spksDataBuff[bufIndex].status; + } + + return status; +} + +/* +* ָID Spksť״̬ +* ˵ const UINT16 spksId, ťID +* const UINT8 spksState, ť״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSpksState(const UINT16 spksId, const UINT8 spksState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = CI_ERROR; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + if ((SPKS_STATUS_NO == spksState) || (SPKS_STATUS_YES == spksState)) + { + spksDataBuff[bufIndex].status = spksState; + + ret = CI_SUCCESS; + } + else + { + ret = CI_ERROR; + } + } + else + { + ret = CI_ERROR; + } + + return ret; +} + +/* +* ȡָID spks·״̬ +* ˵ const UINT16 spksId, spks ID +* ֵ 0: ȡʧ +* >0: spksť״̬ +*/ +UINT8 GetSpksCutState(const UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 status = CI_ERROR; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + status = spksDataBuff[bufIndex].cutStatus; + } + + return status; +} + +/* +* ָID Spks·״̬ +* ˵ const UINT16 spksId, ťID +* const UINT8 spksCutState, ·״̬ +* ֵ +* +*/ +void SetSpksCutState(const UINT16 spksId, const UINT8 spksCutState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + if ((SPKS_STATUS_NO == spksCutState) || (SPKS_STATUS_YES == spksCutState)) + { + spksDataBuff[bufIndex].cutStatus = spksCutState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + +/* +* SPKS״̬ʼ +* ˵ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SpksDataManageInit(void) +{ + UINT8 ret = CI_ERROR; + UINT16 tmpSpksSum = 0u; + UINT16 ii = 0u; + UINT16 spksId = 0u; + + tmpSpksSum = GetTotalSpksCurNum();/*͸ԼSPKSĿ,ڵSPKS_SUM_MAX0*/ + for (ii = 0u; ii < tmpSpksSum; ii++) + { + spksId = GetSpksIdByIndex(ii); + spksDataBuff[spksId].spksId = spksId; /*spks ID*/ + if (SPKS_VIRTUAL_ATTR_YES == GetSpksVirtualAttribute(spksId)) + {/*SPKSʼΪδ*/ + spksDataBuff[spksId].status = SPKS_STATUS_NO; + } + else + {/*SPKSʼΪ*/ + spksDataBuff[spksId].status = SPKS_STATUS_YES; + } + spksDataBuff[spksId].cutStatus = SPKS_CUT_NO; /*spks·δ*/ + spksDataBuff[spksId].flockStartNum = 0u; + spksDataBuff[spksId].TotalSpksDriveOutDis = TOTALSPKSDRIVE_INVALID;/*Ч*/ + } + ret = CI_SUCCESS; + + return ret; +} + +/* +* ָID Spks ʼ +* ˵ const UINT16 spksId, ťID +* const UINT32 spksCutState, ʼ +*/ +void SetSpksflockStartNum(const UINT16 spksId, const UINT32 flockStartNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + if (0u == flockStartNum)/*0ֵ*/ + { + spksDataBuff[bufIndex].flockStartNum = flockStartNum; + } + else + { + if (0u == spksDataBuff[bufIndex].flockStartNum)/*֮ǰΪ0*/ + { + spksDataBuff[bufIndex].flockStartNum = flockStartNum; + } + } + } + else + { + + } +} + +/* +* ȡָID Spks ʼ +* ˵ const UINT16 spksId, ťID +* +* ֵʼ +*/ +UINT32 GetSpksflockStartNum(const UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 ret = CI_ERROR; + + bufIndex = GetSpksConfigBufIndex(spksId); /*ȡ±*/ + + if (bufIndex < SPKS_SUM_MAX) + { + ret = spksDataBuff[bufIndex].flockStartNum; + } + else + { + } + return ret; +} + +/* +* SPKSSPKSƱ־ +* ˵ const UINT16 spksId, ťID +* const UINT8 driveFlag ñ־ +* ֵ +*/ +void SetDriveOutDisFlag(const UINT16 spksId,const UINT8 driveFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetSpksConfigBufIndex(spksId); + if(SPKS_SUM_MAX > bufIndex) + { + if((TOTALSPKSDRIVE_YES == driveFlag)||(TOTALSPKSDRIVE_NO == driveFlag)||(TOTALSPKSDRIVE_INVALID == driveFlag)) + { + spksDataBuff[bufIndex].TotalSpksDriveOutDis = driveFlag; + } + } + else + { + /**/ + } + +} +/* +* ȡSPKSSPKSƱ־ +* ˵ const UINT16 spksId, ťID +* +* ֵñ־ +*/ +UINT8 GetDriveOutDisFlag(const UINT16 spksId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 ret = 0u; + bufIndex = GetSpksConfigBufIndex(spksId); + if(SPKS_SUM_MAX > bufIndex) + { + ret = spksDataBuff[bufIndex].TotalSpksDriveOutDis; + } + else + { + /**/ + } + return ret; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/SPKS/SpksDataManage.h b/TSCP/src/APP/ciapp/SPKS/SpksDataManage.h new file mode 100644 index 0000000..af743dc --- /dev/null +++ b/TSCP/src/APP/ciapp/SPKS/SpksDataManage.h @@ -0,0 +1,120 @@ +/******************************************************** +* +* SPKSDataConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-05 +* ߣ +* SPKS +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SPKS_DATA_MANAGE_CONFIG_H_ +#define _SPKS_DATA_MANAGE_CONFIG_H_ +#include "../SPKS/SpksDefine.h" +#include "CommonTypes.h" + +typedef struct +{ + UINT16 spksId; /* spks */ + UINT8 status; /* spks״̬ */ + UINT8 cutStatus; /* spks·״̬ */ + UINT32 flockStartNum; /*ʼ*/ + UINT8 TotalSpksDriveOutDis; /*SKPKSSPKSָʾƱ־*/ +} SpksDataStruct; + +extern SpksDataStruct spksDataBuff[SPKS_SUM_MAX]; /* */ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * ȡָSPKS + * ˵ + * ֵ + SpksDataStruct* + */ + SpksDataStruct * GetSpksData(void); + + + /* + * ȡָID spksť״̬ + * ˵ const UINT16 spksId, spks ID + * ֵ 0: ȡʧ + * >0: ͣť״̬ + */ + UINT8 GetSpksState(const UINT16 spksId); + + /* + * ָID Spksť״̬ + * ˵ const UINT16 spksId, spks ID + * const UINT8 spksState, spks״̬ + * ֵ 0: ʧ + * 1: óɹ + */ + UINT8 SetSpksState(const UINT16 spksId, const UINT8 spksState); + + /* + * ȡָID spks·״̬ + * ˵ const UINT16 spksId, spks ID + * ֵ 0: ȡʧ + * >0: ͣť״̬ + */ + UINT8 GetSpksCutState(const UINT16 spksId); + + /* + * ָID Spks·״̬ + * ˵ const UINT16 spksId, ťID + * const UINT8 spksCutState, ·״̬ + * ֵ + * + */ + void SetSpksCutState(const UINT16 spksId, const UINT8 spksCutState); + + + /* + * SPKS״̬ʼ + * ˵ + * ֵ 0: ʧ + * 1: óɹ + */ + UINT8 SpksDataManageInit(void); + + /* + * ָID Spks ʼ + * ˵ const UINT16 spksId, ťID + * const UINT32 spksCutState, ʼ + */ + void SetSpksflockStartNum(const UINT16 spksId, const UINT32 flockStartNum); + + /* + * ȡָID Spks ʼ + * ˵ const UINT16 spksId, ťID + * + * ֵʼ + */ + UINT32 GetSpksflockStartNum(const UINT16 spksId); + + /* + * SPKSSPKSƱ־ + * ˵ const UINT16 spksId, ťID + * const UINT8 driveFlag ñ־ + * ֵ + */ + void SetDriveOutDisFlag(const UINT16 spksId, const UINT8 driveFlag); + /* + * ȡSPKSSPKSƱ־ + * ˵ const UINT16 spksId, ťID + * + * ֵñ־ + */ + UINT8 GetDriveOutDisFlag(const UINT16 spksId); + +#ifdef __cplusplus +}; +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/SPKS/SpksDefine.h b/TSCP/src/APP/ciapp/SPKS/SpksDefine.h new file mode 100644 index 0000000..9b53341 --- /dev/null +++ b/TSCP/src/APP/ciapp/SPKS/SpksDefine.h @@ -0,0 +1,45 @@ +/******************************************************** +* +* SPKSDataConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-05 +* ߣ +* SPKSس +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SPKS_DATA_CONFIG_H_ +#define _SPKS_DATA_CONFIG_H_ + + +/* SPKSֵ */ +#define SPKS_SUM_MAX ((UINT16)500) /* SPKSֵ */ +#define SPKS_MAX_SEC_NUM ((UINT16)100) /* SPKSťӦ */ +#define MJ_MAX_SPKSNUM ((UINT16)15) /* һŽɹSPKS */ +#define SPKS_MAX_MJNUM ((UINT16)15) /* һSPKSɹŽ */ +#define MJ_SUM_MAX ((UINT16)500) /* Ž̵ֵ */ +#define SPKS_MAX_LOG_SEC_NUM ((UINT16)200) /* SPKSťӦ߼ */ +#define PLATFORM_REL_SPKS_NUM_MAX ((UINT8)8) /* վ̨SPKSֵ */ + +/* SPKS״̬ */ +#define SPKS_STATUS_NO ((UINT8)0x55) /* δ */ +#define SPKS_STATUS_YES ((UINT8)0xaa) /* */ + +/* SPKS·״̬ */ +#define SPKS_CUT_NO ((UINT8)0x55) /* δ· */ +#define SPKS_CUT_YES ((UINT8)0xaa) /* · */ + +#define SPKS_VIRTUAL_ATTR_YES ((UINT8)0x55) /*SPKS*/ +#define SPKS_VIRTUAL_ATTR_NO ((UINT8)0xaa) /*SPKS*/ + +#define INCLUDELESPKS_MAX_NUM (UINT8)40 + +/* SPKSSPKSָʾ״̬ */ +#define TOTALSPKSDRIVE_YES (UINT8)0xaa /* SPKSЧ*/ +#define TOTALSPKSDRIVE_NO (UINT8)0x55 /* SPKSЧ */ +#define TOTALSPKSDRIVE_INVALID (UINT8)0xFF /* ĬЧ */ + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/AxisConfigDataManage.c b/TSCP/src/APP/ciapp/Section/AxisConfigDataManage.c new file mode 100644 index 0000000..f63ea9d --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/AxisConfigDataManage.c @@ -0,0 +1,120 @@ +#include "AxisConfigDataManage.h" + +AxisConfigStru g_szAxisData[AXIS_NUM_MAX] = { 0u };/*Ϣ*/ +UINT16 g_axisNum = 0;/**/ + +/** +* @brief ȡ +* @param +* @return +*/ +UINT16 GetAxleNum(void) +{ + return g_axisNum; +} + +/** +* @brief IDȡ洢 +* @param wId +* @return +*/ +UINT16 GetAxisIndexById(UINT16 wId) +{ + UINT16 index = UINT16_MAX; + + if ((0u < wId) && (AXIS_NUM_MAX > wId)) + { + index = wId; + } + else + { + ; + } + + return index; +} + +/** +* @brief IDȡ +* @param wId +* @return +*/ +UINT32 GetAxisKmById(UINT16 wId) +{ + UINT32 rtnValue = UINT32_MAX; + UINT16 index = UINT16_MAX; + + index = GetAxisIndexById(wId); + + if (UINT16_MAX != index) + { + rtnValue = g_szAxisData[index].dwAxleKilo; + } + + return rtnValue; +} + +/** +* @brief ȡID +* @param wIndex +* @return ID +*/ +UINT16 GetAxisIdByIndex(UINT16 wIndex) +{ + UINT16 rtnValue = 0u; + + if (wIndex < AXIS_NUM_MAX) + { + rtnValue = g_szAxisData[wIndex].wId; + } + + return rtnValue; +} + +/** +* @brief IDȡlink +* @param wId +* @return link +*/ +UINT16 GetAxisLinkId(UINT16 wId) +{ + UINT16 rtnValue = UINT16_MAX; + UINT16 index = UINT16_MAX; + + index = GetAxisIndexById(wId); + + if (UINT16_MAX != index) + { + rtnValue = g_szAxisData[index].wLkId; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief IDȡlinkƫ +* @param wId +* @return linkƫ +*/ +UINT32 GetAxisOffsetById(UINT16 wId) +{ + UINT32 rtnValue = UINT32_MAX; + UINT16 index = UINT16_MAX; + + index = GetAxisIndexById(wId); + + if (UINT16_MAX != index) + { + rtnValue = g_szAxisData[index].dwLkOfst; + } + else + { + ; + } + + return rtnValue; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/AxisConfigDataManage.h b/TSCP/src/APP/ciapp/Section/AxisConfigDataManage.h new file mode 100644 index 0000000..a28f13b --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/AxisConfigDataManage.h @@ -0,0 +1,84 @@ +/********************************************************************************************************************* +* ļ AxisConfigDataManage.h ݹͷļ +* Ȩ˵ ؿƼ +* 汾 1.0 +* ʱ 2022.3.11 +* OC +* ݹ +* +* +* ʹע +* ޸ļ¼ +**************************************************************************************************************/ +#ifndef _AXIS_CONFIG_DATA_MANAGE_H_ +#define _AXIS_CONFIG_DATA_MANAGE_H_ + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define AXIS_NUM_MAX 1000u /**/ + +#include "dsuStruct.h" +typedef struct +{ + UINT16 wId; /**/ + UINT16 wType; /*Ϣ*/ + UINT32 dwAxleKilo; /**/ + UINT16 wLkId; /*link*/ + UINT32 dwLkOfst; /*linkƫ(cm)*/ + UINT8 chKiloType; /**/ +}AxisConfigStru, *pAxisConfigStru; + +/*******************************ȫֱ*******************************/ +extern AxisConfigStru g_szAxisData[AXIS_NUM_MAX]; +extern UINT16 g_axisNum; +/** +* @brief ȡ +* @param +* @return +*/ +extern UINT16 GetAxleNum(void); + +/** +* @brief IDȡ洢 +* @param wId +* @return +*/ +extern UINT16 GetAxisIndexById(UINT16 wId); + +/** +* @brief IDȡ +* @param wId +* @return +*/ +extern UINT32 GetAxisKmById(UINT16 wId); + +/** +* @brief ȡID +* @param wIndex +* @return ID +*/ +extern UINT16 GetAxisIdByIndex(UINT16 wIndex); + +/** +* @brief IDȡlink +* @param wId +* @return link +*/ +extern UINT16 GetAxisLinkId(UINT16 wId); + +/** +* @brief IDȡlinkƫ +* @param wId +* @return linkƫ +*/ +extern UINT32 GetAxisOffsetById(UINT16 wId); +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/TSCP/src/APP/ciapp/Section/AxisSectionConfigDataManage.c b/TSCP/src/APP/ciapp/Section/AxisSectionConfigDataManage.c new file mode 100644 index 0000000..9b09620 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/AxisSectionConfigDataManage.c @@ -0,0 +1,1127 @@ +/******************************************************** +* +* AxisSectionConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "AxisSectionConfigDataManage.h" +#include "ELMDataPrepare.h" + + + + +AxisSectionConfigDataStruct AxisSectionConfigDataStru[AXIS_SECTION_SUM_MAX]; /*ݽṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiAxisSectionIdBuf[AXIS_SECTION_SUM_MAX] = {0u}; /*屾IDӳ*/ +INT16 AxisSectionCurSum = 0; /*߼εǰ*/ +UINT16 totalAxisNum = 0u; /*+ļID*/ + +/* +* ȡεǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ᵱǰ +*/ +UINT16 GetAxisSecCurSum(void) +{ + UINT16 retVal = 0u; + if ((INT16)AXIS_SECTION_SUM_MAX <= AxisSectionCurSum) + { + retVal = AXIS_SECTION_SUM_MAX; + } + else if (0 > AxisSectionCurSum) + { + retVal = 0u; + } + else + { + retVal = (UINT16)AxisSectionCurSum; + } + return retVal; +} + +/* +* ȡ +* ˵ void +* ֵ ݽṹָ +*/ +AxisSectionConfigDataStruct* GetAxisSecConfigData(void) +{ + return AxisSectionConfigDataStru; +} + +/* +* ȡָ±ӦļID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetAxisSecId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 dwTotalAxiscNum = GetTotalAxisCurNum(); + if (bufIndex < dwTotalAxiscNum) + { + retVal = LocalCiAxisSectionIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SECTION_SUM_MAX: ȡʧ +* = 1u) && (axisSectionId < AXIS_SECTION_SUM_MAX)) + { + retVal = axisSectionId; + } + else + { + retVal = AXIS_SECTION_SUM_MAX; + } + + return retVal; +} + +/* +* ȡָIDID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetAxisSecRelativePhySecId(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].RelativePhySecId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼Ŀ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ߼Ŀ +*/ +UINT8 GetAxisSecLogSectionSum(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].LogSectionSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼ID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ߼IDָ +*/ +UINT16* GetAxisSecLogSectionIdBuf(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].LogSectionIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ļ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 AxisSectionConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 axisSectionConfigDataSum = 0u; /*豸*/ + UINT8 retVal = CI_SUCCESS; + + /*ID*/ + axisSectionConfigDataSum = GetAxisSecCurSum(); + totalAxisNum = axisSectionConfigDataSum; + if (axisSectionConfigDataSum >= AXIS_SECTION_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < AXIS_SECTION_SUM_MAX; ii++) + { + if (jj == axisSectionConfigDataSum) + {/*Ч*/ + + break; + } + + if (AxisSectionConfigDataStru[ii].AxisSectionId != 0u) + {/*òΪЧ*/ + LocalCiAxisSectionIdBuf[jj] = AxisSectionConfigDataStru[ii].AxisSectionId; + jj++; + } + + + } + } + + return retVal; +} + + + /* + * ȡָIDεĿ + * ˵ const UINT16 axisSectionId, ID + * ֵ 0: ȡʧ + * >0: Ŀ + */ +UINT8 GetAxisSwitchSum(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].AxisSwitchSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDεID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: IDָ +*/ +AxisSwitchStruct* GetAxisSwitchIdStru(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + AxisSwitchStruct* retVal = NULL; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].AxisSwitchIdStru; + } + else + { + retVal = NULL; + } + return retVal; +} + + + +/* +* ȡ͸Լ߼εǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ߼εǰ +*/ +UINT16 GetTotalAxisCurNum(void) +{ + UINT16 retVal = 0u; + if (totalAxisNum >= AXIS_SECTION_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = totalAxisNum; + } + return retVal; +} +/* +* ȡָIDlink +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: link +*/ +UINT8 GetAxisLinkSum(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].chLinkNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDlinkID +* ˵ const UINT16 axisSectionId, ID +* ֵ NULL: ȡʧ +* >0: linkID +* ޸bug YF0083-119 +*/ +UINT16* GetAxisLinkIdBuf(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].szLinkIdBuff; + } + else + { + + } + + return retVal; +} + +/* +* ȡָID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 GetAxisOrgnAxisId(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].wOrgnAxisId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDյ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 GetAxisTmnlAxisId(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].wTmnlAxisId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ȡIDӳַԼεǰ +* @param +* @return εǰ +*/ +UINT16 GetLocalCiAxisSectionIdBuf(const UINT16 **pIdBuff) +{ + UINT16 wAcSum = 0u; + + if (NULL == pIdBuff) + { + ; + } + else + { + (*pIdBuff) = LocalCiAxisSectionIdBuf; + wAcSum = totalAxisNum; + } + + return wAcSum; +} + +/** +* @brief ȡIDLocalCiAxisSectionIdBufеֵ +* @param +* @return LocalCiAxisSectionIdBufеֵ +* @note 1 bug 20220420 wqm ȫֱЧԼ +* 2޸bug YF0083-119 +*/ +UINT16 GetLocalCiAxisSectionIndex(UINT16 axisID) +{ + UINT16 wACIndex = UINT16_MAX; + UINT16 cycle = 0; + + /** bug 20220420 wqm ȫֱЧԼ */ + if (AXIS_SECTION_SUM_MAX > totalAxisNum) + { + for (cycle = 0; cycle < totalAxisNum; cycle++) + { + if (LocalCiAxisSectionIdBuf[cycle] == axisID) + { + wACIndex = cycle + 1U; + break; + } + else + { + + } + } + } + else + { + /** Чֵ */ + } + + return wACIndex; +} + +/* +* ȡָIDTIOC +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: TIOC +*/ +UINT16 GetAxisBelongTioc(const UINT16 wAcId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + UINT16 wLinkId = 0u; + + bufIndex = GetAxisSecConfigBufIndex(wAcId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + wLinkId = AxisSectionConfigDataStru[bufIndex].szLinkIdBuff[0]; + retVal = GetLinkManageTiocById(wLinkId); + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDǷΪ߼ +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SEC_LINK_LINE_YES: ߼ +* AXIS_SEC_LINK_LINE_NO: ߼ +*/ +UINT8 GetAxisSecLinkLineFlag(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = AXIS_SEC_LINK_LINE_NO; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].chLinkLine; + } + else + { + retVal = AXIS_SEC_LINK_LINE_NO; + } + return retVal; +} + + +/* +* ȡָIDǷΪڼ +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SEC_ENTRANCE_YES: ڼ +* AXIS_SEC_ENTRANCE_NO: ڼ +*/ +UINT8 GetAxisSecEntranceFlag(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = AXIS_SEC_ENTRANCE_NO; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].chEntrance; + } + else + { + retVal = AXIS_SEC_ENTRANCE_NO; + } + return retVal; +} + + +/* +* ȡͨļ +* ˵ const UINT16 wAxisSecASum A +* UINT16* pAxisSecABuf AIDŵַ +* const UINT16 wAxisSecBSum B +* UINT16* pAxisSecBBuf BIDŵַ +* ֵ 0 ʧܣɹ +* @note lxc 20220617 +*/ +UINT8 GetAxisSecListByStartingAndEnd(const UINT8 cAxisSecASum, UINT16* pAxisSecAIdBuf, const UINT8 cAxisSecBSum, UINT16* pAxisSecBIdBuf,UINT8 cDir, UINT16* pOutputIdBuf) +{ + UINT8 cRetSum = 0u; + UINT8 cFunRetVal = CI_ERROR; + UINT16 cLinkAHeadId = 0u; + UINT16 cLinkATainId = 0u; + UINT16 cLinkBHeadId = 0u; + UINT16 cLinkBTainId = 0u; + UINT32 dwDis = UINT32_MAX; + LOD_STRU pointA = { 0u }; + LOD_STRU pointB = { 0u }; + UINT8 cEmapDir = 0u; + UINT16 wDevSum = 0u; + UINT16 szDevIdBuf[100] = { 0u }; + + UINT8 cTmpASAHeadNum = 0u; + UINT16* pTmpASAHeadLinkIdBuf = NULL; + UINT8 cTmpASHeadBNum = 0u; + UINT16* pTmpASBHeadLinkIdBuf = NULL; + + UINT8 cTmpASATailNum = 0u; + UINT16* pTmpASATailLinkIdBuf = NULL; + UINT8 cTmpASTailBNum = 0u; + UINT16* pTmpASBTailLinkIdBuf = NULL; + + if ((NULL == pAxisSecAIdBuf) || (NULL == pAxisSecBIdBuf) || (NULL == pOutputIdBuf) + || (0u == cAxisSecASum) || (0u == cAxisSecBSum)) + { + ; /* ʧ */ + } + else + { + /* жϷ */ + if ((DIR_SAME == cDir) || (DIR_CONVERT == cDir)) + { + cFunRetVal = CI_SUCCESS; + } + + if (CI_SUCCESS == cFunRetVal) + { + /* ȡAеlinkͷ */ + cTmpASAHeadNum = GetAxisLinkSum(pAxisSecAIdBuf[cAxisSecASum - 1u]); + pTmpASAHeadLinkIdBuf = GetAxisLinkIdBuf(pAxisSecAIdBuf[cAxisSecASum - 1u]); + /* ȡBеlinkͷ */ + cTmpASHeadBNum = GetAxisLinkSum(pAxisSecBIdBuf[cAxisSecBSum - 1u]); + pTmpASBHeadLinkIdBuf = GetAxisLinkIdBuf(pAxisSecBIdBuf[cAxisSecBSum - 1u]); + + /* ȡAеlinkβ */ + cTmpASATailNum = GetAxisLinkSum(pAxisSecAIdBuf[0u]); + pTmpASATailLinkIdBuf = GetAxisLinkIdBuf(pAxisSecAIdBuf[0u]); + /* ȡBеlinkβ */ + cTmpASTailBNum = GetAxisLinkSum(pAxisSecBIdBuf[0u]); + pTmpASBTailLinkIdBuf = GetAxisLinkIdBuf(pAxisSecBIdBuf[0u]); + + if ((0u != cTmpASAHeadNum) && (NULL != pTmpASAHeadLinkIdBuf) + && (0u != cTmpASHeadBNum) && (NULL != pTmpASBHeadLinkIdBuf) + && (0u != cTmpASATailNum) && (NULL != pTmpASATailLinkIdBuf) + && (0u != cTmpASTailBNum) && (NULL != pTmpASBTailLinkIdBuf)) + { + /* ݷȡͷβlink */ + if (DIR_SAME == cDir) + { + cLinkAHeadId = pTmpASAHeadLinkIdBuf[0]; + cLinkBHeadId = pTmpASBHeadLinkIdBuf[0]; + + cLinkATainId = pTmpASATailLinkIdBuf[cTmpASATailNum - 1u]; + cLinkBTainId = pTmpASBTailLinkIdBuf[cTmpASTailBNum - 1u]; + } + else + { + cLinkAHeadId = pTmpASAHeadLinkIdBuf[cTmpASAHeadNum - 1u]; + cLinkBHeadId = pTmpASBHeadLinkIdBuf[cTmpASHeadBNum - 1u]; + + cLinkATainId = pTmpASATailLinkIdBuf[0]; + cLinkBTainId = pTmpASBTailLinkIdBuf[0]; + } + } + else + { + cFunRetVal = CI_ERROR; + } + } + + if (CI_SUCCESS == cFunRetVal) + { + pointA.Lnk = cLinkAHeadId; + pointB.Lnk = cLinkBHeadId; + pointA.Off = 0u; + pointB.Off = 0u; + dwDis = dsuLenByPoint(&pointA,&pointB,&wDevSum,szDevIdBuf,&cEmapDir); + + if ((UINT32_MAX != dwDis) && ((EMAP_SAME_DIR == cEmapDir) || (EMAP_CONVER_DIR == cEmapDir))) + { + /* ȡѯ */ + if (((EMAP_SAME_DIR == cEmapDir) && (DIR_SAME == cDir)) + || ((EMAP_CONVER_DIR == cEmapDir) && (DIR_CONVERT == cDir))) + { + /* AdzβBdzͷ */ + pointA.Lnk = cLinkBHeadId; + pointB.Lnk = cLinkATainId; + } + else + { + /* AdzͷBdzβ*/ + pointA.Lnk = cLinkAHeadId; + pointB.Lnk = cLinkBTainId; + } + pointA.Off = 0u; + pointB.Off = 0u; + } + else + { + cFunRetVal = CI_ERROR; + } + } + + if (CI_SUCCESS == cFunRetVal) + { + /* ͷβȡ */ + cRetSum = elm_PrepACBtwPointsBySwitchSta(pointB,pointA,pOutputIdBuf); + } + } + + + return cRetSum; +} + +/** +* @brief ѯǰ/󷽼 +* @param[in] UINT16 ACID ׼ID +* @param[in] UINT8 dir ѯ +* @param[out] UINT16 arACID[5] ڼID +* param[out] UINT8* DirectionPointFlag Ƿ񾭹仯 DIRECTIONPOINT_FLAG_VALID +* @return UINT8_MAX ѯʧ +0~AC_MAXCNT_IN_SWITCH ѯɹ +* @note +*/ +UINT8 FindAdjacentAC(UINT16 ACID, UINT8 dir, INOUT UINT16 arACID[5],UINT8* DirectionPointFlag) +{ + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 retVal = 0U; + retVal = elm_PrepareAdjacentAC(ACID, dir, arACID, &cDirectionPointFlag); + *DirectionPointFlag = cDirectionPointFlag; + return retVal; + +} + +/** + * @brief ȡ߼ + * @param[in] UINT16 wAcId ID + * @param[in] UINT8 chDir + * @param[out] UINT16 * pLgcIdBuf ߼ID + * @return ߼UINT8_MAXʧܣ0·ն + * @note + */ +UINT8 FindACAdjacentLogSec(UINT16 wAcId, UINT8 chDir, UINT16 * pLgcIdBuf) +{ + UINT16 wAxleId = 0u; + UINT8 chRtn = UINT8_MAX; + UINT16 wSwitchId = 0u; + struct_PathPoint strTmp = { 0u }; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 chLinkNum = 0u; /*ΰLINK*/ + UINT16 * pLinkIdBuf = NULL; /*ΰlinkID*/ + if ((EMAP_SAME_DIR != chDir) && (EMAP_CONVER_DIR != chDir) && (NULL != pLgcIdBuf)) + { + ; /* μʧܣ0 */ + } + else + { + + chLinkNum = GetAxisLinkSum(wAcId); + pLinkIdBuf = GetAxisLinkIdBuf(wAcId); + + if (EMAP_SAME_DIR == chDir) + {/* link߼ͬ */ + wAxleId = GetAxisTmnlAxisId(wAcId); /* ȡն˼ */ + strTmp.wLinkId = GetAxisLinkId(wAxleId); + strTmp.dwOffset = GetAxisOffsetById(wAxleId); + if (strTmp.wLinkId != pLinkIdBuf[chLinkNum - 1u]) + {/* ն˼linkǼն˵link˵Ѿһlink*/ + if (0U == strTmp.dwOffset) + { + strTmp.dwOffset++; + } + else + { + strTmp.dwOffset--; + } + } + else + { + strTmp.wLinkId = FindAdjacentLinkIDSafe(strTmp.wLinkId, EMAP_SAME_DIR, &wSwitchId, &cDirectionPointFlag); + if (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) + { + strTmp.dwOffset = GetLinkLengthById(strTmp.wLinkId) - 1u; + } + else + { + strTmp.dwOffset = 1u; + } + } + } + else + {/* link߼෴ */ + wAxleId = GetAxisOrgnAxisId(wAcId); /* ȡʼ˼ */ + strTmp.wLinkId = GetAxisLinkId(wAxleId); + strTmp.dwOffset = GetAxisOffsetById(wAxleId); + if (strTmp.wLinkId != pLinkIdBuf[0u]) + {/* ʼ˼linkǼʼ˵link˵Ѿһlink */ + if (0U != strTmp.dwOffset) + { + strTmp.dwOffset--; + } + else + { + strTmp.dwOffset++; + } + } + else + { + strTmp.wLinkId = FindAdjacentLinkIDSafe(strTmp.wLinkId, EMAP_CONVER_DIR, &wSwitchId, &cDirectionPointFlag); + + if (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) + { + strTmp.dwOffset = 1u; + } + else + { + strTmp.dwOffset = GetLinkLengthById(strTmp.wLinkId) - 1u; + } + } + } + + /* ȡ߼ */ + if (0u == strTmp.wLinkId) + {/* ·ն˷0 */ + chRtn = 0u; + } + else if (UINT16_MAX == strTmp.wLinkId) + {/* ѯUINT8_MAX */ + chRtn = UINT8_MAX; + } + else + { + chRtn = GetPointBelongLogSecEx(strTmp, pLgcIdBuf); + if (0u == chRtn) + {/* ѯʧ */ + chRtn = UINT8_MAX; + } + else + { + ; + } + } + } + + return chRtn; +} + +/* +* ȡ߼״̬ +* ˵ UINT8 dir + UINT16 ACId ID +* ֵ LOGICSECTION_OCCUPY_UT ͨųռ + LOGICSECTION_OCCUPY_NO ޳ռúͨųռ +*/ +UINT8 GetACAdjoinLogSecStatus(UINT8 dir,UINT16 ACId) +{ + UINT8 ret = LOGICSECTION_OCCUPY_UT; + UINT8 logSecStatus = LOGICSECTION_OCCUPY_UT; + UINT8 cycle = 0u; + UINT8 logSecCnt = 0; + UINT16 logSecBuff[AC_MAXCNT_IN_SWITCH] = {0u}; + + /** ڲУ */ + ASSERT_RET_VALUE((EMAP_CONVER_DIR != dir) && (EMAP_SAME_DIR != dir),ret,0x80000000u); + + /** ȡ߼ */ + logSecCnt = FindACAdjacentLogSec(ACId,dir,logSecBuff); + + if (0u == logSecCnt) + { + ret = LOGICSECTION_OCCUPY_NO; + } + else if(UINT8_MAX == logSecCnt) + { + ret = LOGICSECTION_OCCUPY_UT; + } + else + { + for (cycle = 0u; cycle < logSecCnt; cycle++) + { + logSecStatus = GetLogSecCurCtOrUtOccupyState(logSecBuff[cycle]); + + if (LOGICSECTION_OCCUPY_UT == logSecStatus) + { + break; + } + } + + if (cycle == logSecCnt) + { + ret = LOGICSECTION_OCCUPY_NO; + } + else + { + ret = LOGICSECTION_OCCUPY_UT; + } + } + + return ret; +} + +/** + * @brief ȡĿǰԴǷ + * @param[in] UINT16 ACID id + * @param[out] + * @return CI_ERROR δ + CI_SUCCESS + UINT8_MAX ѯ + * @note + */ +UINT8 GetACRelSwLogSecLock(UINT16 ACID) +{ + UINT8 ret = UINT8_MAX; + UINT8 cycleac = 0u; + UINT8 cycleLogSec = 0u; + UINT8 cycleSec = 0u; + UINT8 chLogSecCnt = 0u; + const UINT16* pLogSecCntBuff = NULL; + UINT16 wPhyId = 0u; + UINT8 ACCnt = 0u; + UINT16* pACBuff = NULL; + UINT8 TrainLockCnt = 0u; + UINT8 logSecInPhy = 0u; + UINT16* pLogSecInphyBuff = NULL; + UINT8 LogSecLkInphyCnt = 0u; + UINT16 LogSecLkInphy[AXIS_INCLUDE_LOG_SUM_MAX] = {0u}; + + /** ޻ӽжϲԴǷз䣬δݵ˹ϵռã*/ + wPhyId = GetAxisSecRelativePhySecId(ACID); + ACCnt = GetPAxisSectionSum(wPhyId); + pACBuff = GetPAxisSectionIdBuf(wPhyId); + + if ((0u == ACCnt) || (NULL == pACBuff)) + { + /** עҪɾifж */ + ret = UINT8_MAX; + } + else + { + /** ȡΰ߼δͷŵ߼ */ + logSecInPhy = GetPhySecIncLogSecSum(wPhyId); + pLogSecInphyBuff = GetPhySecIncLogSecIdBuf(wPhyId); + + if ((0u == logSecInPhy) || (NULL == pLogSecInphyBuff)) + { + /** עҪɾifж */ + ret = UINT8_MAX; + } + else + { + + /** ȡδͷŵ߼ */ + for (cycleSec = 0u; cycleSec < logSecInPhy;cycleSec++) + { + /** ȡ߼αյ */ + TrainLockCnt = GetLogSecTrainInfoSum(pLogSecInphyBuff[cycleSec]); + + if (0U < TrainLockCnt) + { + LogSecLkInphy[LogSecLkInphyCnt] = pLogSecInphyBuff[cycleSec]; + LogSecLkInphyCnt += 1u; + } + else + { + /** */ + } + } + + if (0u == LogSecLkInphyCnt) + { + /** ˵Դȫͷţյ˹ϵ */ + ret = CI_ERROR; + } + else + { + /** жδͷŵ߼ǷΪ߼ */ + chLogSecCnt = GetAxisSecLogSectionSum(ACID); + pLogSecCntBuff = GetAxisSecLogSectionIdBuf(ACID); + + if ((0u == chLogSecCnt) || (NULL == pLogSecCntBuff)) + { + /** עҪɾifж */ + ret = UINT8_MAX; + } + else + { + /** ѯδͷŵ߼ǷΪ߼ */ + for (cycleLogSec = 0u;cycleLogSec < chLogSecCnt; cycleLogSec++) + { + for (cycleSec = 0u; cycleSec < LogSecLkInphyCnt;cycleSec++) + { + if (pLogSecCntBuff[cycleLogSec] == LogSecLkInphy[cycleSec]) + { + break; + } + } + + if (cycleSec == LogSecLkInphyCnt) + { + /** ˵ڷDZ߼δͷ*/ + break; + } + } + + if ((cycleLogSec == chLogSecCnt) && (chLogSecCnt == LogSecLkInphyCnt)) + { + /** ˵δͷŵ߼ζڱᣬݵ˹ϵ */ + ret = CI_ERROR; + } + else + { + /** ˵δͷŵIJȫڱᣬ谴հ*/ + ret = CI_SUCCESS; + } + } + } + } + } + + return ret; +} + +/** +* @brief ȡζӦķֽID +* @param[in] const UINT16 wAxisSecId ID +* @return 0 ʧܣ ֽID +* @note by cgh 20240221 +*/ +UINT16 GetAxisRelateCfpId(const UINT16 wAxisSecId) +{ + UINT16 wReval = 0U; + UINT16 wBufIndex = 0U; /*±*/ + UINT8 ii = 0U; + UINT8 wAxisSecRelateLinkNum = 0U;/*ιLINK*/ + UINT16* pAxisSecRelateLinkId = NULL;/*ιLINK ID*/ + UINT16 wCfpInFirstLink = 0U;/*ֽڷһLINK*/ + UINT16 wCfpNum = 0U;/*ֽĿ*/ + UINT16 wCfpIndex = 0U;/*ֽ±*/ + UINT16 wCfpId = 0U;/*ֽID*/ + + wBufIndex = GetAxisSecConfigBufIndex(wAxisSecId); /*ȡ±*/ + + if ((0U < wBufIndex) && (AXIS_SECTION_SUM_MAX > wBufIndex)) + { + pAxisSecRelateLinkId = GetAxisLinkIdBuf(wAxisSecId); + wAxisSecRelateLinkNum = GetAxisLinkSum(wAxisSecId); + + if ((0U < wAxisSecRelateLinkNum) && (AXIS_INCLUDE_LINK_SUM_MAX >= wAxisSecRelateLinkNum) && (NULL != pAxisSecRelateLinkId)) + { + wCfpNum = GetCfpSum(); + for (wCfpIndex = 0U; wCfpIndex < wCfpNum; wCfpIndex++) + { + wCfpId = GetCfpId(wCfpIndex); + wCfpInFirstLink = GetCfpInFirstLink(wCfpId); + for (ii = 0U; ii < wAxisSecRelateLinkNum; ii++) + { + if (pAxisSecRelateLinkId[ii] == wCfpInFirstLink) + { + /*ιLINKһΪ0ʱֽڷһLINKʹLINKͬΪҪҵķֽ*/ + wReval = wCfpId; + break; + } + else + { + ; /**/ + } + } + + if (wCfpId == wReval) + { + break; + } + else + { + /**/ + } + } + } + else + { + /*ȡΰlinkʧܣ0ʧ*/ + } + } + else + { + ; /*IDϷ*/ + } + + return wReval; +} +/* +* ȡָID +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SEC_LINXIAN_YES: ߱(DZ·) +* AXIS_SEC_LINXIAN_NO: ߱(·) +*/ +UINT8 GetAxisSecLinXianFlag(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = AXIS_SEC_LINXIAN_NO; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].chAxisLinXian; + } + else + { + retVal = AXIS_SEC_LINXIAN_NO; + } + return retVal; +} + +/* +* ȡָIDεĴ泵 +* ˵ const UINT16 axisSectionId ID +* ֵ 0 ȡʧ +* 0x55 д泵 +* 0xAA д泵 +*/ +UINT8 GetAxisSecStorageLineProperty(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].chStorageLineProperty; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDܳ +* ˵ const UINT16 axisSectionId ID +* ֵ 0 >0 linkܳ +*/ +UINT32 GetAxisSecTotalLen(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 axisLinkLen = 0U;/*link cm*/ + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + axisLinkLen = AxisSectionConfigDataStru[bufIndex].dwAxisTotalLen; + } + else + { + ; /*0*/ + } + return axisLinkLen; +} + +/* +* ȡָIDεı߽ +* ˵const UINT16 axisSectionId ID +* ֵ0 ȡʧ +* 0x55 ߽ +* 0xAA DZ߽ +*/ +UINT8 GetAxisSecBorderProperty(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionConfigDataStru[bufIndex].cBorderAttr; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/AxisSectionConfigDataManage.h b/TSCP/src/APP/ciapp/Section/AxisSectionConfigDataManage.h new file mode 100644 index 0000000..19bc44f --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/AxisSectionConfigDataManage.h @@ -0,0 +1,318 @@ +/******************************************************** +* +* AxisSectionConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _AXIS_SECTION_CONFIG_DATA_MANAGE_H_ +#define _AXIS_SECTION_CONFIG_DATA_MANAGE_H_ + + +#include "SectionDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../Section/PhysicalSectionDataManage.h" +#include "AxisConfigDataManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +/*ΰṹ*/ +typedef struct S_Axis_Switch +{ + UINT16 SwitchId; /*ID*/ + UINT8 SwitchPosition; /*λ*/ +} AxisSwitchStruct; +/*ݽṹ*/ +typedef struct S_AxisSectionConfigDataStruct +{ + UINT16 AxisSectionId; /*ID (ֶ)*/ + UINT16 RelativePhySecId; /*ID (ֶ)*/ + UINT8 LogSectionSum; /*߼Ŀ (ֶ)*/ + UINT16 LogSectionIdBuf[AXIS_INCLUDE_LOG_SUM_MAX]; /*߼ID (ֶ)*/ + UINT8 AxisSwitchSum; /*ĵ*/ + AxisSwitchStruct AxisSwitchIdStru[AXIS_INCLUDE_SWITCH_SUM_MAX]; /*ĵID*/ + UINT8 chLinkNum; /*link*/ + UINT16 szLinkIdBuff[AXIS_INCLUDE_LINK_SUM_MAX]; /*link*/ + UINT16 wOrgnAxisId; /* */ + UINT16 wTmnlAxisId; /* յ */ + UINT8 chLinkLine; /* ߱־ */ + UINT8 chEntrance; /* */ + UINT8 chStorageLineProperty; /*泵*/ + UINT8 cBorderAttr; /*߽*/ + UINT8 chAxisLinXian; /*-ǷΪ·-ӵͼLink*/ + UINT32 dwAxisTotalLen; /*linkܳ*/ +} AxisSectionConfigDataStruct; + +extern AxisSectionConfigDataStruct AxisSectionConfigDataStru[AXIS_SECTION_SUM_MAX]; /*ݽṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiAxisSectionIdBuf[AXIS_SECTION_SUM_MAX]; +extern INT16 AxisSectionCurSum; +extern UINT16 totalAxisNum; + +/* +* ȡεǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ᵱǰ +*/ +UINT16 GetAxisSecCurSum(void); + +/* +* ȡ +* ˵ void +* ֵ ݽṹָ +*/ +AxisSectionConfigDataStruct* GetAxisSecConfigData(void); + +/* +* ȡָ±ӦļID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetAxisSecId(const UINT16 bufIndex); + +/* +* ȡָID +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SECTION_SUM_MAX: ȡʧ +* 0: ID +*/ +UINT16 GetAxisSecRelativePhySecId(const UINT16 axisSectionId); + +/* +* ȡָID߼Ŀ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ߼Ŀ +*/ +UINT8 GetAxisSecLogSectionSum(const UINT16 axisSectionId); + +/* +* ȡָID߼ID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ߼IDָ +*/ +UINT16* GetAxisSecLogSectionIdBuf(const UINT16 axisSectionId); + +/* +* ļ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 AxisSectionConfigDataManage(void); + + /* + * ȡָIDεĿ + * ˵ const UINT16 axisSectionId, ID + * ֵ 0: ȡʧ + * >0: Ŀ + */ +UINT8 GetAxisSwitchSum(const UINT16 axisSectionId); + +/* +* ȡָIDεID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: IDָ +*/ +AxisSwitchStruct* GetAxisSwitchIdStru(const UINT16 axisSectionId); + +/* +* ȡ͸Լ߼εǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ߼εǰ +*/ +UINT16 GetTotalAxisCurNum(void); + +/* +* ȡָIDlink +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: link +*/ +UINT8 GetAxisLinkSum(const UINT16 axisSectionId); + +/* +* ȡָIDlinkID +* ˵ const UINT16 axisSectionId, ID +* ֵ NULL: ȡʧ +* >0: linkID +*/ +UINT16* GetAxisLinkIdBuf(const UINT16 axisSectionId); + +/* +* ȡָID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 GetAxisOrgnAxisId(const UINT16 axisSectionId); + +/* +* ȡָIDյ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 GetAxisTmnlAxisId(const UINT16 axisSectionId); + +/** +* @brief ȡIDӳַԼεǰ +* @param +* @return εǰ +*/ +UINT16 GetLocalCiAxisSectionIdBuf(const UINT16 **pIdBuff); + + +/** +* @brief ȡIDLocalCiAxisSectionIdBufеֵ +* @param +* @return LocalCiAxisSectionIdBufеֵ +*/ +UINT16 GetLocalCiAxisSectionIndex(UINT16 axisID); + +/* +* ȡָIDTIOC +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: TIOC +*/ +UINT16 GetAxisBelongTioc(const UINT16 wAcId); + +/* +* ȡָIDǷΪ߼ +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SEC_LINK_LINE_YES: ߼ +* AXIS_SEC_LINK_LINE_NO: ߼ +*/ +UINT8 GetAxisSecLinkLineFlag(const UINT16 axisSectionId); + +/* +* ȡָIDǷΪڼ +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SEC_LINK_LINE_YES: ڼ +* AXIS_SEC_LINK_LINE_NO: ڼ +*/ +UINT8 GetAxisSecEntranceFlag(const UINT16 axisSectionId); +/* +* ȡͨļ +* ˵ const UINT16 wAxisSecASum A +* UINT16* pAxisSecABuf AIDŵַ +* const UINT16 wAxisSecBSum B +* UINT16* pAxisSecBBuf BIDŵַ +* ֵ 0 ʧܣɹ +*/ +UINT8 GetAxisSecListByStartingAndEnd(const UINT8 cAxisSecASum, UINT16* pAxisSecAIdBuf, const UINT8 cAxisSecBSum, UINT16* pAxisSecBIdBuf, UINT8 cDir, UINT16* pOutputIdBuf); + +/** +* @brief ѯǰ/󷽼 +* @param[in] UINT16 ACID ׼ID +* @param[in] UINT8 dir ѯ +* @param[out] UINT16 arACID[5] ڼID +* param[out] UINT8* DirectionPointFlag Ƿ񾭹仯 DIRECTIONPOINT_FLAG_VALID +* @return UINT8_MAX ѯʧ +0~AC_MAXCNT_IN_SWITCH ѯɹ +* @note +*/ +UINT8 FindAdjacentAC(UINT16 ACID, UINT8 dir, INOUT UINT16 arACID[5], UINT8* DirectionPointFlag); + + +/** + * @brief ȡ߼ + * @param[in] UINT16 wAcId ID + * @param[in] UINT8 chDir + * @param[out] UINT16 * pLgcIdBuf ߼ID + * @return ߼UINT8_MAXʧܣ0·ն + * @note + */ +UINT8 FindACAdjacentLogSec(UINT16 wAcId, UINT8 chDir, UINT16 * pLgcIdBuf); + +/* +* ȡ߼״̬ +* ˵ UINT8 dir + UINT16 ACId ID +* ֵ LOGICSECTION_OCCUPY_UT ͨųռ + LOGICSECTION_OCCUPY_NO ޳ռúͨųռ +*/ +UINT8 GetACAdjoinLogSecStatus(UINT8 dir,UINT16 ACId); + + +/** + * @brief ȡĿǰԴǷ + * @param[in] UINT16 ACID id + * @param[out] + * @return CI_ERROR δ + CI_SUCCESS + UINT8_MAX ѯ + * @note + */ +UINT8 GetACRelSwLogSecLock(UINT16 ACID); + +/** +* @brief ȡζӦķֽID +* @param[in] const UINT16 wAxisSecId ID +* @return 0 ʧܣ ֽID +* @note by cgh 20240221 +*/ +UINT16 GetAxisRelateCfpId(const UINT16 wAxisSecId); + +/* +* ȡָID +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SEC_LINXIAN_YES: ߱(DZ·) +* AXIS_SEC_LINXIAN_NO: ߱(·) +*/ +UINT8 GetAxisSecLinXianFlag(const UINT16 axisSectionId); + +/* +* ȡָIDεĴ泵 +* ˵ const UINT16 axisSectionId ID +* ֵ 0 ȡʧ +* 0x55 д泵 +* 0xAA д泵 +*/ +UINT8 GetAxisSecStorageLineProperty(const UINT16 axisSectionId); + +/* +* ȡָIDܳ +* ˵ const UINT16 axisSectionId ID +* ֵ 0 >0 linkܳ +*/ +UINT32 GetAxisSecTotalLen(const UINT16 axisSectionId); + +/* +* ȡָIDεı߽ +* ˵const UINT16 axisSectionId ID +* ֵ0 ȡʧ +* 0x55 ߽ +* 0xAA DZ߽ +*/ +UINT8 GetAxisSecBorderProperty(const UINT16 axisSectionId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Section/AxisSectionDataManage.c b/TSCP/src/APP/ciapp/Section/AxisSectionDataManage.c new file mode 100644 index 0000000..368b9d7 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/AxisSectionDataManage.c @@ -0,0 +1,789 @@ +/******************************************************** +* +* AxisSectionDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "AxisSectionDataManage.h" + + +AxisSectionDataStruct AxisSectionDataStru[AXIS_SECTION_SUM_MAX] = { 0 }; /*ݽṹ*/ + +/* +* ȡ +* ˵ +* ֵ + AxisSectionDataStruct* +*/ +AxisSectionDataStruct *GetAxisSecData(void) +{ + return AxisSectionDataStru; +} +/* +* ȡָIDID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAxisSectionBelongCiId(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionDataStru[bufIndex].BelongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDARB״̬ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ARB״̬ +*/ +UINT8 GetAxisSecArbState(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionDataStru[bufIndex].AxisArbState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDARB״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 arbState, ARB״̬ +* ֵ +* +*/ +void SetAxisSecArbState(const UINT16 axisSectionId, const UINT8 arbState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + if ((AXIS_SECTION_ARB_NO == arbState) || (AXIS_SECTION_ARB_YES == arbState)) + { + AxisSectionDataStru[bufIndex].AxisArbState = arbState; /*ARB״̬*/ + SetAxisIncludeLogSecArbState(axisSectionId,arbState);/*üΰ߼ARB״̬*/ + SetAxisRelatePhySecArbState(axisSectionId, arbState);/*üιARB״̬*/ + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/************************************Ծ****************************************************/ + +/* +* ȡָIDԾ־ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetAxisSecJumpLockApplyFlag(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + retVal = AxisSectionDataStru[bufIndex].AxisJumpLockApplyFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDԾ־ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockApplyFlag, Ծ־ +* ֵ +* +*/ +void SetAxisSecJumpLockApplyFlag(const UINT16 axisSectionId, const UINT8 jumpLockApplyFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + if ((AXIS_SECTION_JUMPLOCK_APPLY_NO == jumpLockApplyFlag) || (AXIS_SECTION_JUMPLOCK_APPLY_YES == jumpLockApplyFlag)) + { + AxisSectionDataStru[bufIndex].AxisJumpLockApplyFlag = jumpLockApplyFlag; /*Ծ־*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/*-----ָ------*/ + +/* +* ȡָIDԾȡ־ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetAxisSecJLockCancelApplyFlag(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + retVal = AxisSectionDataStru[bufIndex].AxisJumpLockCancelApplyFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDԾȡ־ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockCancelApplyFlag, Ծȡ־ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetAxisSecJLockCancelApplyFlag(const UINT16 axisSectionId, const UINT8 jumpLockCancelApplyFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + if ((AXSEC_CANCEL_JUMPLOCK_APPLY_NO == jumpLockCancelApplyFlag) || + (AXSEC_CANCEL_JUMPLOCK_APPLY_YES == jumpLockCancelApplyFlag)) + { + AxisSectionDataStru[bufIndex].AxisJumpLockCancelApplyFlag = jumpLockCancelApplyFlag; /*Ծȡ־*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/*-----ָ------*/ + +/* +* ȡָIDԾں +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ծں +*/ +UINT32 GetAxisSecJumpLockApplyCylce(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + retVal = AxisSectionDataStru[bufIndex].AxisJumpLockApplyCylce; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDԾȡ־ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockApplyCycle, Ծں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetAxisSecJumpLockApplyCylce(const UINT16 axisSectionId, const UINT32 jumpLockApplyCycle) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + AxisSectionDataStru[bufIndex].AxisJumpLockApplyCylce = jumpLockApplyCycle; /*Ծȡ־*/ + + retVal = CI_SUCCESS; + + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/*-----ָ------*/ + +/* +* ȡָIDԾ״̬ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetAxisJumpLockState(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + retVal = AxisSectionDataStru[bufIndex].AxisJumpLockState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDԾ״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void SetAxisJumpLockState(const UINT16 axisSectionId, const UINT8 jumpLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + if ((AXIS_SECTION_JUMPLOCK_STATE_IDLE == jumpLockState) || + (AXIS_SECTION_JUMPLOCK_STATE_XUANPAI == jumpLockState) || + (AXIS_SECTION_JUMPLOCK_STATE_LOCK == jumpLockState) ) + {/*Ծ״̬ΪСѡš*/ + AxisSectionDataStru[bufIndex].AxisJumpLockState = jumpLockState; /*Ծ״̬*/ + } + else + { + } + } + else + { + /**/ + } +} +/* +* ȡָIDID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAxisSectionBelongVirCiId(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionDataStru[bufIndex].BelongVirCIid; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/************************************Ծ****************************************************/ + + +/* +* ȡָIDռ״̬ +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SECTION_OCCUPY_NO: δռ +* AXIS_SECTION_OCCUPY_YES: ռ +*/ +UINT8 GetAxisOccupyState(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = AXIS_SECTION_OCCUPY_YES; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + retVal = AxisSectionDataStru[bufIndex].AxisOccStatus; + } + else + { + retVal = AXIS_SECTION_OCCUPY_YES; + } + return retVal; +} + +/* +* ָIDռ״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 occupyState, ռ״̬ +* ֵ +* +*/ +void SetAxisOccupyState(const UINT16 axisSectionId, const UINT8 occupyState) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT32 dwCycNum = 0U;/*ռʼ*/ + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + dwCycNum = Get2oo2CurCycleNum(); + + if (AXIS_SECTION_SUM_MAX > bufIndex ) + { + if ((AXIS_SECTION_OCCUPY_YES == occupyState) || + (AXIS_SECTION_OCCUPY_NO == occupyState)) + { + AxisSectionDataStru[bufIndex].AxisOccStatus = occupyState; /*ռÿ״̬*/ + + if (AXIS_SECTION_OCCUPY_YES == occupyState) + { + if (0U == AxisSectionDataStru[bufIndex].dwAxisOccCycNum) + { + AxisSectionDataStru[bufIndex].dwAxisOccCycNum = dwCycNum; + } + else + { + ; /*0˵Ѿù*/ + } + } + else + { + AxisSectionDataStru[bufIndex].dwAxisOccCycNum = 0U; + } + } + else + { + + } + } + else + { + /**/ + } +} + +/** +* @brief ȡ·ID +* @param ID +* @return ·ID0:δ +*/ +UINT16 GetAxisSecLockBelongRoute(const UINT16 wAcId) +{ + UINT16 wPhyId = 0u; + UINT16 wRouteId = 0u; + wPhyId = GetAxisSecRelativePhySecId(wAcId); + wRouteId = GetPhySecRLockBelongRouteId(wPhyId); + return wRouteId; +} + +/* +* ָIDΰ߼Ծ״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ void +* עڸATSλʾ߼,by-cgh-2023.06.28 +*/ +void SetAxisInCludeLogJumpLockState(const UINT16 axisSectionId, const UINT8 jumpLockState) +{ + UINT16* pLogSectionIdBuf = NULL; + UINT8 chLogSectionSum = 0U; + UINT8 ii = 0U; + + pLogSectionIdBuf = GetAxisSecLogSectionIdBuf(axisSectionId); + chLogSectionSum = GetAxisSecLogSectionSum(axisSectionId); + + if (NULL != pLogSectionIdBuf) + { + for (ii = 0U; ii < chLogSectionSum; ii++) + { + if ((LOGIC_SECTION_JUMP_LOCK_NO == jumpLockState) || (LOGIC_SECTION_JUMP_LOCK_YES == jumpLockState)) + { + SetLogSecJumpLockState(pLogSectionIdBuf[ii], jumpLockState); + } + } + } +} + +/* +* ָΰ߼ARB״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 chState,ARB״̬ +* ֵ void +* עby-cgh-2023.09.05 +*/ +void SetAxisIncludeLogSecArbState(const UINT16 wAxisSectionId, const UINT8 chState) +{ + UINT16* pLogSectionIdBuf = NULL;/*ΰ߼ID*/ + UINT8 chLogSectionSum = 0U;/*ΰ߼Ŀ*/ + UINT8 ii = 0U; + + pLogSectionIdBuf = GetAxisSecLogSectionIdBuf(wAxisSectionId); + chLogSectionSum = GetAxisSecLogSectionSum(wAxisSectionId); + + if (NULL != pLogSectionIdBuf) + { + for (ii = 0U; ii < chLogSectionSum; ii++) + { + if ((LGC_SECTION_ARB_NO == chState) || (LGC_SECTION_ARB_YES == chState)) + { + SetLgcArbState(pLogSectionIdBuf[ii], chState); + } + } + } +} + +/* +* ָιARB״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 chState,ARB״̬ +* ֵ void +* עby-cgh-2023.09.05 +*/ +void SetAxisRelatePhySecArbState(const UINT16 wAxisSectionId, const UINT8 chState) +{ + UINT16 wAxisRelatePhySecId = 0U;/*ιID*/ + UINT8 ii = 0U; + UINT16* pAxisSecIdBuf = NULL;/*ιΰļID*/ + UINT8 chAxisSecSum = 0U;/*ιΰļĿ*/ + UINT8 chAxisArbState = 0U;/*ARB״̬*/ + + wAxisRelatePhySecId = GetAxisSecRelativePhySecId(wAxisSectionId); + + if (AXIS_SECTION_ARB_YES == chState) + { + SetPhySecArbState(wAxisRelatePhySecId, chState);/*һARBARB״̬*/ + } + else + { + /*÷ARBҪеļζڷARB״̬*/ + pAxisSecIdBuf = GetPAxisSectionIdBuf(wAxisRelatePhySecId); + chAxisSecSum = GetPAxisSectionSum(wAxisRelatePhySecId); + + if (NULL != pAxisSecIdBuf) + { + for (ii = 0U; ii < chAxisSecSum; ii++) + { + chAxisArbState = GetAxisSecArbState(pAxisSecIdBuf[ii]); + if (AXIS_SECTION_ARB_YES == chAxisArbState) + { + break; + } + } + if (ii == chAxisSecSum) + { + SetPhySecArbState(wAxisRelatePhySecId, chState);/*ARB״̬*/ + } + } + } +} + +/* +* ȡָIDռʼں +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ռʼں +* by cgh 20240815 +*/ +UINT32 GetAxisSecOccCyc(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex) + { + retVal = AxisSectionDataStru[bufIndex].dwAxisOccCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDλüලЧгID +* ˵const UINT16 wAxisSectionId ID +* const UINT16 wTrainId гID +* ֵ +* Created By LQ 2024.08.18 +*/ +void SetAxisPosMonitorTrainId(const UINT16 wAxisSectionId, const UINT16 wTrainId) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetAxisSecConfigBufIndex(wAxisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex) + { + if (TRAIN_SUM_MAX > (wTrainId & 0x00FFU)) + { + AxisSectionDataStru[bufIndex].wPosMonitorTrainId = wTrainId; + } + else + { + /*IDǷ*/ + } + } + else + { + /*μʧܣ*/ + } +} + +/* +* ȡָIDλüලЧгID +* ˵const UINT16 wAxisSectionId ID +* ֵ255 ȡʧ +* <255 гID +* Created By LQ 2024.08.18 +*/ +UINT16 GetAxisPosMonitorTrainId(const UINT16 wAxisSectionId) +{ + UINT16 wRetVal = TRAIN_SUM_MAX; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetAxisSecConfigBufIndex(wAxisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex) + { + wRetVal = AxisSectionDataStru[bufIndex].wPosMonitorTrainId; + } + else + { + /*μʧܣ255*/ + } + + return wRetVal; +} + +/* +* ȡָIDռں +* ˵const UINT16 wAxisSectionId ID +* ֵUINT32_MAX ȡʧ ռں +* Created By fan 2024.08.19 +*/ +UINT32 GetAxisRecentUtOccupyCyc(const UINT16 wAxisSectionId) +{ + UINT32 wRetVal = UINT32_MAX; + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetAxisSecConfigBufIndex(wAxisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex) + { + wRetVal = AxisSectionDataStru[bufIndex].dwUtOccupyCycNum; + } + else + { + /*μʧܣUINT32_MAX*/ + } + + return wRetVal; +} +/* +* ָIDռں +* ˵const UINT16 wAxisSectionId ID UINT32 ں +* ֵ +* Created By fan 2024.08.19 +*/ +void SetAxisRecentUtOccupyCyc(const UINT16 wAxisSectionId, const UINT32 dwCycNum) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetAxisSecConfigBufIndex(wAxisSectionId); /*ȡ±*/ + + if (AXIS_SECTION_SUM_MAX > bufIndex) + { + AxisSectionDataStru[bufIndex].dwUtOccupyCycNum = dwCycNum; + } + else + { + ; /*ȡʧܲ*/ + } +} +/** +* ܣѯ¼ϻռ״̬ +* +* ֵ +* Create: fan 2024/08/20 +*/ +void AxisSecUtOccpyUpdate(void) +{ + UINT16 i = 0u; + UINT16 wPhyNum = 0u; + UINT8 chLocalCiId = 0u;/*id*/ + UINT8 chPhyCiId = 0u; /*Ci*/ + UINT16 wPhyId = 0u; /*id*/ + UINT16 wAxisSecId = 0U; /*id*/ + UINT8 phySecContainAxisSecSum; /*ι*/ + UINT16* phySecContainAxisSecIdBuf = NULL; /*ι*/ + UINT8 linkNum = 0U; /*ilnk*/ + UINT16* pLinkBuf = NULL; /*link*/ + UINT8 j = 0U; + UINT8 jj = 0U; + UINT8 k = 0U; + UINT8 chOccState = 0U; /*ռñ־*/ + UINT8 chUtOccupyFlag = CI_ERROR; /*Ƿ¼Utռ ERROR*/ + UINT8 cLinkIncTrainSum = 0u; /*linkг*/ + TRAIN_SEQUANCE_s linkInctrainList[SIZE_MAX_TRAINOFAC] = { 0u }; /*linkϵг*/ + UINT8 isUseNvram = TRAIN_NVRAM_POS_FLAG_YES; + UINT32 dwCurCyc = Get2oo2CurCycleNum(); /*ǰں*/ + chLocalCiId = GetSystemParaLocalCiId(); + wPhyNum = GetPhySecCurSum(); + for (i = 0u; i < wPhyNum; i++) + { + /* */ + wPhyId = GetPhySecId(i); + chPhyCiId = GetPhySecBelongCiId(wPhyId); + chOccState = GetPhySecCurOccupyState(wPhyId); + /* ±TIOCгռõ */ + if ((chLocalCiId == chPhyCiId) &&(SECTION_OCCUPY_YES == chOccState)) + { + phySecContainAxisSecSum = GetPAxisSectionSum(wPhyId); + phySecContainAxisSecIdBuf = GetPAxisSectionIdBuf(wPhyId); + + if ((0u != phySecContainAxisSecSum) && (NULL != phySecContainAxisSecIdBuf)) + { + for (j = 0u; j < phySecContainAxisSecSum; j++) + { + /*link޻*/ + wAxisSecId = phySecContainAxisSecIdBuf[j]; + linkNum = GetAxisLinkSum(wAxisSecId); + pLinkBuf = GetAxisLinkIdBuf(wAxisSecId); + if ((0U != linkNum) && (NULL != pLinkBuf)) + { + chUtOccupyFlag = CI_SUCCESS; + for (jj = 0; jj < linkNum; jj++) + { + cLinkIncTrainSum = as_GetLinkTrainList(pLinkBuf[jj], linkInctrainList, SIZE_MAX_TRAINOFAC); + for (k = 0U; k < cLinkIncTrainSum; k++) + { + + if (NAME_FAILUREAREA != linkInctrainList[k].u16TrainID) + { + /*ǹ */ + /*fan0824 NvramҲûռ*/ + isUseNvram = GetTrainNvramPosFlag(linkInctrainList[k].u16TrainID); + if (TRAIN_NVRAM_POS_FLAG_NO != isUseNvram) + { + chUtOccupyFlag = CI_ERROR; /*Nvramֹͣ顣ʧ*/ + break; + } + else + { + ; /**/ + } + } + else + { + chUtOccupyFlag = CI_ERROR; /*ڹϳֹͣ顣ʧ*/ + break; + } + + } + + + } + } + else + { + /*ȡʧ */ + chUtOccupyFlag = CI_ERROR; + } + + /*л¼ռ*/ + if (CI_ERROR == chUtOccupyFlag) + { + SetAxisRecentUtOccupyCyc(wAxisSecId, dwCurCyc); + } + else + { + ; /**/ + } + } + } + } + else + { + ; /**/ + } + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/AxisSectionDataManage.h b/TSCP/src/APP/ciapp/Section/AxisSectionDataManage.h new file mode 100644 index 0000000..3205076 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/AxisSectionDataManage.h @@ -0,0 +1,263 @@ +/******************************************************** +* +* AxisSectionDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _AXIS_SECTION_DATA_MANAGE_H_ +#define _AXIS_SECTION_DATA_MANAGE_H_ + + +#include "SectionDefine.h" +#include "AxisSectionConfigDataManage.h" +#include "CommonTypes.h" +#include "AxisSort_api.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*ݽṹ*/ +typedef struct S_AxisSectionDataStruct +{ + UINT16 AxisSectionId; /*ID (ʼֶ)*/ + UINT8 AxisArbState; /*ARB״̬ (ֶ̬)*/ + UINT8 BelongCiId; /*ID(ʼֶ)*/ + UINT8 BelongVirCIid; /*ID(ʼֶ)*/ + + UINT8 AxisJumpLockApplyFlag; /*Ծ־*/ + UINT8 AxisJumpLockCancelApplyFlag; /*Ծȡ־*/ + UINT32 AxisJumpLockApplyCylce; /*Ծں*/ + + UINT8 AxisJumpLockState; /*Ծ״̬*/ + UINT8 AxisOccStatus; /*ռ״̬ */ + UINT32 dwAxisOccCycNum; /*ռʼ*/ + UINT16 wPosMonitorTrainId; /*ιλüලЧгID*/ + UINT32 dwUtOccupyCycNum; /*ռ*/ +} AxisSectionDataStruct; + + +extern AxisSectionDataStruct AxisSectionDataStru[AXIS_SECTION_SUM_MAX]; +/* +* ȡ +* ˵ +* ֵ + AxisSectionDataStruct* +*/ +AxisSectionDataStruct *GetAxisSecData(void); +/* +* ȡָIDID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAxisSectionBelongCiId(const UINT16 axisSectionId); + +/* +* ȡָIDARB״̬ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ARB״̬ +*/ +UINT8 GetAxisSecArbState(const UINT16 axisSectionId); + +/* +* ָIDARB״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 arbState, ARB״̬ +* ֵ +* +*/ +void SetAxisSecArbState(const UINT16 axisSectionId, const UINT8 arbState); + +/* +* ȡָIDԾ־ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetAxisSecJumpLockApplyFlag(const UINT16 axisSectionId); + +/* +* ָIDԾ־ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockApplyFlag, Ծ־ +* ֵ +* +*/ +void SetAxisSecJumpLockApplyFlag(const UINT16 axisSectionId, const UINT8 jumpLockApplyFlag); + +/* +* ȡָIDԾȡ־ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetAxisSecJLockCancelApplyFlag(const UINT16 axisSectionId); + +/* +* ָIDԾȡ־ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockCancelApplyFlag, Ծȡ־ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetAxisSecJLockCancelApplyFlag(const UINT16 axisSectionId, const UINT8 jumpLockCancelApplyFlag); + +/* +* ȡָIDԾ״̬ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetAxisJumpLockState(const UINT16 axisSectionId); + +/* +* ָIDԾ״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void SetAxisJumpLockState(const UINT16 axisSectionId, const UINT8 jumpLockState); + +/* +* ȡָIDԾں +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ծں +*/ +UINT32 GetAxisSecJumpLockApplyCylce(const UINT16 axisSectionId); + +/* +* ָIDԾȡ־ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockApplyCycle, Ծں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetAxisSecJumpLockApplyCylce(const UINT16 axisSectionId, const UINT32 jumpLockApplyCycle); +/* +* ȡָIDID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAxisSectionBelongVirCiId(const UINT16 axisSectionId); + +/* +* ȡָIDռ״̬ +* ˵ const UINT16 axisSectionId, ID +* ֵ AXIS_SECTION_OCCUPY_NO: δռ +* AXIS_SECTION_OCCUPY_YES: ռ +*/ +UINT8 GetAxisOccupyState(const UINT16 axisSectionId); + +/* +* ָIDռ״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 occupyState, ռ״̬ +* ֵ +* +*/ +void SetAxisOccupyState(const UINT16 axisSectionId, const UINT8 occupyState); + +/** +* @brief ȡ·ID +* @param ID +* @return ·ID0:δ +*/ +UINT16 GetAxisSecLockBelongRoute(const UINT16 wAcId); + +/* +* ָIDΰ߼Ծ״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ void +* עڸATSλʾ߼,by-cgh-2023.06.28 +*/ +void SetAxisInCludeLogJumpLockState(const UINT16 axisSectionId, const UINT8 jumpLockState); + +/* +* ָΰ߼ARB״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 chState,ARB״̬ +* ֵ void +* עby-cgh-2023.09.05 +*/ +void SetAxisIncludeLogSecArbState(const UINT16 wAxisSectionId, const UINT8 chState); + +/* +* ָιARB״̬ +* ˵ const UINT16 axisSectionId, ID +* const UINT8 chState,ARB״̬ +* ֵ void +* עby-cgh-2023.09.05 +*/ +void SetAxisRelatePhySecArbState(const UINT16 wAxisSectionId, const UINT8 chState); + +/* +* ȡָIDռʼں +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ռʼں +* by cgh 20240815 +*/ +UINT32 GetAxisSecOccCyc(const UINT16 axisSectionId); + +/* +* ָIDλüලЧгID +* ˵const UINT16 wAxisSectionId ID +* const UINT16 wTrainId гID +* ֵ +* Created By LQ 2024.08.18 +*/ +void SetAxisPosMonitorTrainId(const UINT16 wAxisSectionId, const UINT16 wTrainId); + +/* +* ȡָIDλüලЧгID +* ˵const UINT16 wAxisSectionId ID +* ֵ255 ȡʧ +* <255 гID +* Created By LQ 2024.08.18 +*/ +UINT16 GetAxisPosMonitorTrainId(const UINT16 wAxisSectionId); + +/* +* ȡָIDռں +* ˵const UINT16 wAxisSectionId ID +* ֵUINT32_MAX ȡʧ ռں +* Created By fan 2024.08.19 +*/ +UINT32 GetAxisRecentUtOccupyCyc(const UINT16 wAxisSectionId); +/* +* ָIDռں +* ˵const UINT16 wAxisSectionId ID UINT32 ں +* ֵ +* Created By fan 2024.08.19 +*/ +void SetAxisRecentUtOccupyCyc(const UINT16 wAxisSectionId, const UINT32 dwCycNum); +/** +* ܣѯ¼ϻռ״̬ +* +* ֵ +* Create: fan 2024/08/20 +*/ +void AxisSecUtOccpyUpdate(void); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Section/LinkConfigDataManage.c b/TSCP/src/APP/ciapp/Section/LinkConfigDataManage.c new file mode 100644 index 0000000..d102c02 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/LinkConfigDataManage.c @@ -0,0 +1,4296 @@ +/**************************************************************************************************** +* ļ : APP_LinkManage.c +* Ȩ˵ : ؿƼɷ޹˾ +* 汾 : 1.0 +* ʱ : 2022.02.28 +* : TIOC +* : LINKݹԴļ +* ʹע : +* +* ޸ļ¼ : +* +**************************************************************************************************/ +#include "LinkConfigDataManage.h" +#include "SwitchConfigDataManage.h" +#include "SwitchDataManage.h" +#include "CiSystemDefine.h" +#include "EnvelopeDefine.h" +#include "SectionStateProcess_define.h" +#include "AxisConfigDataManage.h" + +LinkDataConfigStru g_szLinkConfigData[LINK_SUM_MAX] = { 0u }; +UINT16 g_linkNum = 0u; + +/** +* @brief жгռѹ߼УǷҪж߼ελ +* @param const UINT16 wLgcId ߼ID +* @param const str_Zone strZone гռѹ +* @return CI_ERROR:ҪλãCI_SUCCESS:Ҫ +* @note +*/ +static UINT8 IsLgcNeedCheckSwitchPos(const UINT16 wLgcId, const str_Zone strZone); + +/** +* @brief GetLinkNum ȡLINK +* @param void +* @return ɹLINK ʧ UINT16_MAX +*/ +UINT16 GetLinkNum(void) +{ + UINT16 wRetVal = UINT16_MAX; + + if ((0u < g_linkNum) && (LINK_SUM_MAX > g_linkNum)) + { + wRetVal = g_linkNum; + } + else + { + ; /*ʧ*/ + } + return wRetVal; +} + +/** +* @brief GetLinkData ȡLINK +* @param void +* @return LINK +*/ +LinkDataConfigStru * GetLinkData(void) +{ + return g_szLinkConfigData; +} + +/** +* @brief GetLinkDataById IDȡLINK +* @param linkId +* @return LINK +*/ +LinkDataConfigStru * GetLinkDataById(const UINT16 linkId) +{ + LinkDataConfigStru * rtnValue = NULL; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + + if (UINT16_MAX != index) + { + rtnValue = &g_szLinkConfigData[index]; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief GetLinkDataByIndex ȡLINK +* @param linkIndex +* @return LINK +*/ +LinkDataConfigStru * GetLinkDataByIndex(const UINT16 linkIndex) +{ + LinkDataConfigStru * rtnValue = NULL; + + if (linkIndex < LINK_SUM_MAX) + { + rtnValue = &g_szLinkConfigData[linkIndex]; + } + else + { + ; /*±*/ + } + + return rtnValue; +} + +/** +* @brief GetLinkIndexById ݱŻȡ +* @param linkId +* @return LINK +*/ +UINT16 GetLinkIndexById(const UINT16 linkId) +{ + UINT16 index = UINT16_MAX; + + if ((0u != linkId) && (LINK_SUM_MAX > linkId)) + { + index = linkId; + } + else + { + ; + } + + return index; +} + +/** +* @brief GetLinkLengthById ȡLINK +* @param linkId +* @return LINK +*/ +UINT32 GetLinkLengthById(const UINT16 linkId) +{ + UINT32 rtnValue = UINT32_MAX; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].dwLength; + } + else + { + ; /*id */ + } + + if (0u == rtnValue) + { + rtnValue = UINT32_MAX; + } + + return rtnValue; +} +#if 0 +/** +* @brief GetLinkPointType ȡLINK˵ +* @param linkId +* @return LINK +*/ +UINT8 GetLinkPointType(const UINT16 linkId,UINT8 * pOrgnPointType, UINT8 * pTmnlPointType) +{ + UINT8 rtnValue = CI_ERROR; + UINT16 index = 0u; + + if ((NULL != pOrgnPointType) && (NULL != pTmnlPointType)) + { + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + *pOrgnPointType = g_szLinkConfigData[index].wOrgnPointType; + *pTmnlPointType = g_szLinkConfigData[index].wTmnlPointType; + rtnValue = CI_SUCCESS; + } + else + { + ; /*id */ + } + } + else + { + ;/* ʧ */ + } + + return rtnValue; +} +#endif + +/** +* @brief GetLinkLineById ȡLINKϢ +* @param linkId +* @return LINKϢ 0x55:У0xaa: +*/ +UINT16 GetLinkLineById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wLinkLine; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkOrgnPointTypeId ȡLINK˵ +* @param linkId +* @return LINK˵ +*/ +UINT16 GetLinkOrgnPointTypeById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wOrgnPointType; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkOrgnPointIdById ȡLINK˵ +* @param linkId +* @return LINK˵ +*/ +UINT16 GetLinkOrgnPointIdById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wOrgnPointId; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkOrgnJointMainLkIdById ȡLINKӵlink +* @param linkId +* @return LINKӵlink +*/ +UINT16 GetLinkOrgnJointMainLkIdById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wOrgnJointMainLkId; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkOrgnJointSideLkIdById ȡLINKӵڲlink +* @param linkId +* @return LINKӵڲlink +*/ +UINT16 GetLinkOrgnJointSideLkIdById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wOrgnJointSideLkId; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkTmnlPointTypeById ȡLINKյ˵ +* @param linkId +* @return LINKյ˵ +*/ +UINT16 GetLinkTmnlPointTypeById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wTmnlPointType; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkTmnlPointIdById ȡLINKյ˵ +* @param linkId +* @return LINKյ˵ +*/ +UINT16 GetLinkTmnlPointIdById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wTmnlPointId; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkTmnlJointMainLkById ȡLINKյӵlink +* @param linkId +* @return LINKյӵlink +*/ +UINT16 GetLinkTmnlJointMainLkById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wTmnlJointMainLkId; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkTmnlJointSideLkById ȡLINKյӵڲlink +* @param linkId +* @return LINKյӵڲlink +*/ +UINT16 GetLinkTmnlJointSideLkById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wTmnlJointSideLkId; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkManageOcById ȡLINKOC +* @param linkId +* @return LINKTIOC +*/ +UINT16 GetLinkManageTiocById(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wManageTioc; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief GetLinkLogicDirChangedById ȡLINK߼仯 +* @param linkId +* @return LINK߼仯 +*/ +UINT8 GetLinkLogicDirChangedById(const UINT16 linkId) +{ + UINT8 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].chLogicDirChanged; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief ȡlink߼зĹϵ +* @param linkId +* @return LINK߼зĹϵ +*/ +UINT8 GetLinkLogicLineReleationById(const UINT16 linkId) +{ + UINT8 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].chLogicLineRelation; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief ȡLINKα +* @param linkId +* @return LINKα +*/ +UINT16 GetLinkRelatedPhySec(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wRelatedPhySec; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief ȡLINK˵Ϣ +* @param chDir +* @param wLinkId LINK +* @param pLinkPoint ˵Ϣ +* @return CI_SUCCESS:ɹCI_ERROR:ʧ +*/ +UINT8 GetLinkPointInfo(UINT8 chDir, UINT16 wLinkId, pLinkPointData pLinkPoint) +{ + UINT8 rtnValue = CI_ERROR; + LinkDataConfigStru * pLinkDataTemp = NULL; + + pLinkDataTemp = GetLinkDataById(wLinkId); + + if ((NULL == pLinkPoint) || (NULL == pLinkDataTemp)) + { + /* ָΪջlink */ + } + else if((DIR_SAME != chDir) && (DIR_CONVERT != chDir)) + { + /* 򲻺Ϸ */ + } + else + { + pLinkPoint->wLinkId = pLinkDataTemp->wId; + pLinkPoint->wPointType = UINT16_MAX; + pLinkPoint->wPointId = UINT16_MAX; + pLinkPoint->wMainLinkId = UINT16_MAX; + pLinkPoint->wSideLinkId = UINT16_MAX; + + /* ߼ͬ */ + if (DIR_SAME == chDir) + { + pLinkPoint->wPointType = pLinkDataTemp->wTmnlPointType; /* ȡյ˵ */ + pLinkPoint->wPointId = pLinkDataTemp->wTmnlPointId; /* ȡյ˵ */ + pLinkPoint->wMainLinkId = pLinkDataTemp->wTmnlJointMainLkId;/* ȡյLINK */ + pLinkPoint->wSideLinkId = pLinkDataTemp->wTmnlJointSideLkId;/* ȡյڲLINK */ + } + else + { + /* ߼෴ */ + pLinkPoint->wPointType = pLinkDataTemp->wOrgnPointType; /* ȡ˵ */ + pLinkPoint->wPointId = pLinkDataTemp->wOrgnPointId; /* ȡ˵ */ + pLinkPoint->wMainLinkId = pLinkDataTemp->wOrgnJointMainLkId;/* ȡLINK */ + pLinkPoint->wSideLinkId = pLinkDataTemp->wOrgnJointSideLkId;/* ȡڲLINK */ + } + + rtnValue = CI_SUCCESS; + } + return rtnValue; +} + +/** +* @brief ݲѯȡlink˵ƫ +* @param wLinkId link +* @return CI_SUCCESS:ɹCI_ERROR_:ʧ +*/ +UINT8 GetLinkOffsetByDir(struct_PathPoint* pPoint, UINT8 chDir, UINT8 chPointType, UINT32 dwDistance) +{ + UINT8 chRtn = CI_ERROR; + UINT32 dwRtn = UINT32_MAX; + + if(NULL == pPoint) + { + ;/*ѯʧ*/ + } + else + { + dwRtn = GetLinkLengthById(pPoint->wLinkId); + if (UINT32_MAX != dwRtn) + { + if ((0u == pPoint->dwOffset) && ((pPoint->dwOffset + dwDistance) <= dwRtn) && + (((POINT_START == chPointType) && (DIR_SAME == chDir)) || ((POINT_END == chPointType) && (DIR_CONVERT == chDir)))) + { + /*߼Ϊ0x55ʱѯlinkн㣬ǰƫdwDistance + ߼Ϊ0xaaʱѯlinkнյ㣬յƫdwDistance*/ + pPoint->dwOffset += dwDistance; + chRtn = CI_SUCCESS; + + } + else if ((0u == pPoint->dwOffset) && ((dwRtn - pPoint->dwOffset) >= dwDistance) && + (((POINT_END == chPointType) && (DIR_SAME == chDir)) || ((POINT_START == chPointType) && (DIR_CONVERT == chDir)))) + { + /*߼Ϊ0x55ʱѯlinkнյ㣬յƫdwDistance + ߼Ϊ0xaaʱѯlinkн㣬ǰƫdwDistance*/ + pPoint->dwOffset = dwRtn - dwDistance; + chRtn = CI_SUCCESS; + } + else if (((pPoint->dwOffset + dwDistance) <= dwRtn) && + (((OFFEST_FOWARD == chPointType) && (DIR_SAME == chDir)) || ((OFFEST_BACK == chPointType) && (DIR_CONVERT == chDir)))) + { + /*߼Ϊ0x55ʱڵǰƫdwDistance + ߼Ϊ0xaaʱڵƫdwDistance*/ + pPoint->dwOffset += dwDistance; + chRtn = CI_SUCCESS; + } + else if ((pPoint->dwOffset >= dwDistance) && + (((OFFEST_BACK == chPointType) && (DIR_SAME == chDir)) || ((OFFEST_FOWARD == chPointType) && (DIR_CONVERT == chDir)))) + { + /*߼Ϊ0x55ʱڵƫdwDistance + ߼Ϊ0xaaʱڵǰƫdwDistance*/ + pPoint->dwOffset -= dwDistance; + chRtn = CI_SUCCESS; + } + else + { + /*ٴij*/ + } + } + } + + return chRtn; +} + +/** +* @brief ȡLinkʱĵ״̬ +* @param UINT16 wSwitchID +* @param UINT16 wlinkA +* @param UINT16 wlinkB +* @param UINT8 *exSwitchStatus +* @return ʧܣCI_ERRORɹCI_SUCCESS +*/ +UINT8 dsuSwitchStatusBtwLink(UINT16 wSwitchID, UINT16 wlinkA, UINT16 wlinkB, UINT8 *exSwitchStatus) +{ + UINT8 chRtn = CI_ERROR; + UINT8 linkAInSwType = SW_DEFAUT_LINK; + UINT8 linkBInSwType = SW_DEFAUT_LINK; + UINT8 chFunRtnA = CI_ERROR; + UINT8 chFunRtnB = CI_ERROR; + + /*ȡlinkڵ*/ + chFunRtnA = dsuLinkofSwitchPos(wlinkA, wSwitchID, &linkAInSwType); + chFunRtnB = dsuLinkofSwitchPos(wlinkB, wSwitchID, &linkBInSwType); + + if ((CI_SUCCESS == chFunRtnA) && (CI_SUCCESS == chFunRtnB)) + { + if (((SW_CON_LINK == linkAInSwType) && (SW_MAIN_LINK == linkBInSwType)) || + ((SW_CON_LINK == linkBInSwType) && (SW_MAIN_LINK == linkAInSwType))) + { + /*õΪλ*/ + (*exSwitchStatus) = SWITCH_POSITION_DINGWEI; + chRtn = CI_SUCCESS; + } + else if (((SW_CON_LINK == linkAInSwType) && (SW_SIDE_LINK == linkBInSwType)) || + ((SW_CON_LINK == linkBInSwType) && (SW_SIDE_LINK == linkAInSwType))) + { + /*õΪλ*/ + (*exSwitchStatus) = SWITCH_POSITION_FANWEI; + chRtn = CI_SUCCESS; + } + else + { + ;/*ѯ*/ + } + } + else + { + /*ѯ*/ + ; + } + return chRtn; +} + +/** +* @brief жlinkЧ +* @param wId +* @return CI_ERROR:Ч CI_SUCCESS:Ч +*/ +UINT8 IsLinkIdValid(UINT16 wId) +{ + UINT8 rtnValue = CI_ERROR; + UINT16 index = 0u; + + index = GetLinkIndexById(wId); + if (UINT16_MAX != index) + { + rtnValue = CI_SUCCESS; + } + + return rtnValue; +} + +/** +* @brief УlinkIDƫǷЧ +* @param wLinkIdlink dwOffestƫ +* @param dwLinkOffset +* @return CI_ERROR:ЧCI_SUCCESS:Ч +*/ +UINT8 CheckLinkValid(UINT16 wLinkId, UINT32 dwOffest) +{ + UINT8 cRetVal = CI_ERROR; + UINT32 dwLinkLen = 0u; + + dwLinkLen = GetLinkLengthById(wLinkId); + + if ((UINT32_MAX != dwLinkLen) && (dwOffest <= dwLinkLen)) + { + cRetVal = CI_SUCCESS; + } + else + { + ; + } + + return cRetVal; +} + +/** +* @brief ѯijһλָƶָλüҹĵϢ +* @param struct_PathPoint pStart +* @param UINT32 dwDistance +* @param UINT8 chDir +* @param struct_PathPoint *pEnd ѯյ +* @param UINT16 * pSwitchId ͨĵID +* @return 0ѯʧܣ1ѯ·նˣ2ͨ3ѯɹ +*/ +UINT8 dsuNewLocAndObsByOffsetDis(IN struct_PathPoint pStart, IN UINT32 dwDistance, IN UINT8 chDir, OUT struct_PathPoint *pEnd, OUT UINT16 * pSwitchId) +{ + UINT8 chRtn = 0u; + UINT8 chCycle = 0u; + UINT16 wCurLinkId = 0u; /*ǰlink ID*/ + UINT16 wNextLinkId = 0u; /*ǰlink ID*/ + UINT16 wPointId = UINT16_MAX; + UINT32 dwLinkLen = 0u; + UINT32 dwSearchLenth = 0u; + UINT8 chBreakRtn = CI_ERROR; + UINT8 chFunRtn = CI_ERROR; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 cDirectionPointCnt = 0U; /*仯*/ + + if ((NULL == pEnd) + || ((DIR_SAME != chDir) && (DIR_CONVERT != chDir)) + || (NULL == pSwitchId)) + { + /*ڲʧܣش*/ + } + else + { + /*ȡǰlink*/ + wCurLinkId = pStart.wLinkId; + *pSwitchId = UINT16_MAX; + /*ȡǰlink*/ + dwLinkLen = GetLinkLengthById(wCurLinkId); + + if (UINT32_MAX != dwLinkLen) + { + if (DIR_SAME == chDir) + { + dwSearchLenth = dwLinkLen - pStart.dwOffset; + } + else + { + dwSearchLenth = pStart.dwOffset; + } + + /*жǷѯ*/ + if (dwSearchLenth >= dwDistance) + { + /*ѯɹ,ͬһlink*/ + chRtn = 3u; + pEnd->wLinkId = wCurLinkId; + pEnd->dwOffset = pStart.dwOffset; + (void)GetLinkOffsetByDir(pEnd, chDir, OFFEST_FOWARD, dwDistance); + } + else + { + while (chCycle < FIND_FRONT_PROTECT_POINT_TIME) + { + chCycle++; + /*ѯһlink ID*/ + wNextLinkId = FindAdjacentLinkIDSafe(wCurLinkId, chDir, &wPointId, &cDirectionPointFlag); + + if ((UINT16_MAX == wNextLinkId) && (UINT16_MAX != wPointId)) + {/* λò㣬ѯʧ */ + *pSwitchId = wPointId; + + pEnd->wLinkId = wCurLinkId; + pEnd->dwOffset = 0u; + /*ݷ仯Ϣתѯһlink*/ + chDir = TransDirectionPointDir(cDirectionPointFlag, chDir, &cDirectionPointCnt); + + (void)GetLinkOffsetByDir(pEnd, chDir, POINT_END, 0u); + + chRtn = 2u;/* Ŀ */ + + chBreakRtn = CI_SUCCESS; + + } + else if ((UINT16_MAX != wNextLinkId) && (0u != wNextLinkId)) + { + chFunRtn = dsuCheckLinkFitPointSafe(wCurLinkId, chDir, &wPointId); + if (CI_ERROR == chFunRtn) + { + /* ͨյΪ */ + *pSwitchId = wPointId; + pEnd->wLinkId = wCurLinkId; + pEnd->dwOffset = 0u; + (void)GetLinkOffsetByDir(pEnd, chDir, POINT_END, 0u); + + chRtn = 2u;/* λò· */ + chBreakRtn = CI_SUCCESS; + } + else + { + ; + } + + if (CI_SUCCESS != chBreakRtn) + { + /*ݷ仯Ϣתѯһlink*/ + chDir = TransDirectionPointDir(cDirectionPointFlag, chDir, &cDirectionPointCnt); + + /*ȡǰlink*/ + dwLinkLen = GetLinkLengthById(wNextLinkId); + + if (UINT32_MAX == dwLinkLen) + { + /*ѯʧܣش*/ + chRtn = 0u; + chBreakRtn = CI_SUCCESS; + } + else if ((dwLinkLen + dwSearchLenth) < dwDistance) + { + dwSearchLenth += dwLinkLen; + wCurLinkId = wNextLinkId; + } + else + { + /*ҳɹ*/ + pEnd->wLinkId = wNextLinkId; + pEnd->dwOffset = 0u; + (void)GetLinkOffsetByDir(pEnd, chDir, POINT_START, dwDistance - dwSearchLenth); + chFunRtn = dsuCheckLinkFitPointSafe(wNextLinkId, chDir, &wPointId); + if (CI_ERROR == chFunRtn) + { + /* ͨ */ + *pSwitchId = wPointId; + + chRtn = 2u;/* λò· */ + } + else + { + chRtn = 3u; + } + chBreakRtn = CI_SUCCESS; + } + } + else + { + ; + } + } + else if(0u == wNextLinkId) + { + /*·յ㣬سɹ*/ + pEnd->wLinkId = wCurLinkId; + pEnd->dwOffset = 0u; + (void)GetLinkOffsetByDir(pEnd, chDir, POINT_END, 0u); + chRtn = 1u; + chBreakRtn = CI_SUCCESS; + } + else + { + pEnd->wLinkId = pStart.wLinkId; + pEnd->dwOffset = pStart.dwOffset; + chRtn = 0u; + chBreakRtn = CI_SUCCESS; + } + + if (CI_SUCCESS == chBreakRtn) + { + break; + } + } + } + } + else + { + /*ѯ*/ + } + } + + return chRtn; +} + +/** +* @brief ѯǰlinklink,ڵԭ²ѯʧʱصıϢ +* @param UINT16 wCurrentLinkId ǰlink +* @param UINT8 chDirection ѯ +* @param UINT16 *pSwitchId +* @param UINT8* directionPointFlag 仯Ϣ +* @return һlink ʧܣUINT16_MAX·յ㣺0u +*/ +UINT16 FindAdjacentLinkIDSafe(UINT16 wCurrentLinkId, UINT8 chDirection, UINT16 *pSwitchId,UINT8* directionPointFlag) +{ + UINT16 wFindLinkId = 0u;/*ֵ*/ + UINT8 bReturn = CI_ERROR; + UINT8 cSwitchPos = SWITCH_POSITION_INVALID; + LinkPointDataStru pathTreeTemp = { 0u };/*˵Ϣ*/ + DSU_POINT_STRU * pSwitchTemp = NULL; + UINT8 cDirectionPointfirst = 0U; /*仯1*/ + UINT8 cDirectionPointsecond = 0U; /*仯2*/ + UINT8 cDirectionPointCnt = 0U; /*仯*/ + + + if ((NULL != pSwitchId)&&(NULL != directionPointFlag)) + { + *pSwitchId = UINT16_MAX; + *directionPointFlag = DIRECTIONPOINT_FLAG_INVALID; /*־λ*/ + bReturn = CI_SUCCESS; + } + else + { + bReturn = CI_ERROR; + } + + if (CI_SUCCESS == bReturn) + { + /*ѯlink˵Ϣ*/ + bReturn = GetLinkPointInfo(chDirection, wCurrentLinkId, &pathTreeTemp); + } + else + { + ; /*쳣*/ + } + + if (CI_SUCCESS != bReturn) + { + /*زѯʧ*/ + wFindLinkId = UINT16_MAX; + } + else + { + if (UINT16_MAX == pathTreeTemp.wMainLinkId) + { + /*linkյ˵Ϊ·յ㣬linkѯʧ*/ + wFindLinkId = 0u; + } + else + { + if (EMAP_AXLE_DOT == pathTreeTemp.wPointType) + { + /* ˵Ϊ,ȡһlinkIDжһlinkǷΪlink */ + wFindLinkId = pathTreeTemp.wMainLinkId; + + /*˵Ϊ㣬ѯlinkһlinkIDǷз仯㣬link仯ΪԶ㣬ֱӷlinkID仯Ϣ*/ + cDirectionPointfirst = GetLinkLogicDirChangedById(wCurrentLinkId); + cDirectionPointsecond = GetLinkLogicDirChangedById(wFindLinkId); + if (((LINK_DIRCHANGE_BEGIN == cDirectionPointfirst) || (LINK_DIRCHANGE_END == cDirectionPointfirst)) + && (cDirectionPointsecond == cDirectionPointfirst)) + { + *directionPointFlag = DIRECTIONPOINT_FLAG_VALID; + } + else + { + ; /*û仯㣬*/ + } + chDirection = TransDirectionPointDir((*directionPointFlag), chDirection, &cDirectionPointCnt); + + bReturn = GetLinkPointInfo(chDirection, wFindLinkId, &pathTreeTemp); + if (CI_SUCCESS != bReturn) + { + /*زѯʧ*/ + wFindLinkId = UINT16_MAX; + } + else + { + /* жǷΪ */ + if (EMAP_POINT_DOT == pathTreeTemp.wPointType) + { + *pSwitchId = pathTreeTemp.wPointId; + } + } + + } + else if (EMAP_POINT_DOT == pathTreeTemp.wPointType) + { + /* ˵Ϊ,ȡϢṹ*/ + cSwitchPos = GetSwitchCurPosition(pathTreeTemp.wPointId); + if (SWITCH_POSITION_DINGWEI == cSwitchPos) + { + /*ڶλյμΪ*/ + *pSwitchId = pathTreeTemp.wPointId; + wFindLinkId = pathTreeTemp.wMainLinkId; + } + else if (SWITCH_POSITION_FANWEI == cSwitchPos) + { + pSwitchTemp = g_dsuEmapStru->dsuStaticHeadStru->pPointStru + g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[pathTreeTemp.wPointId]; + if (wCurrentLinkId == pSwitchTemp->wConfluentLkId) + { + /*ڷλѯlinkΪlink*/ + *pSwitchId = pathTreeTemp.wPointId; + wFindLinkId = pathTreeTemp.wSideLinkId; + } + else + { + /*ڷλѯlinkΪλ/λlink*/ + *pSwitchId = pathTreeTemp.wPointId; + wFindLinkId = pathTreeTemp.wMainLinkId; + } + } + else + { + /*Ŀ*/ + *pSwitchId = pathTreeTemp.wPointId; + wFindLinkId = UINT16_MAX; + } + } + else + { + /*linkյ˵Ϊ·յ㣬linkѯʧ*/ + wFindLinkId = 0u; + } + } + } + + return wFindLinkId; +} + +/** +* @brief linkͨʱжӹϵ뵱ǰĵ״̬Ƿƥ䡣 +* @param UINT16 wStartLinkId link +* @param UINT8 chDir +* @param UINT16 *pSwitchId +* @return CI_SUCCESSƥ䣻CI_ERRORƥ +*/ +UINT8 dsuCheckLinkFitPointSafe(UINT16 wStartLinkId, UINT8 chDir, UINT16 *pSwitchId) +{ + UINT8 rtnValue = CI_ERROR;/*ֵ*/ + UINT8 chSwitchPos = 0u; + LinkPointDataStru pathTreeTemp = { 0u }; + UINT16 wMainLink = 0u; + UINT16 wSideLink = 0u; + UINT16 wConfluentLink = 0u; + UINT8 chSwitchCurPos = 0u; + UINT8 chKeepWork = CI_ERROR; + DSU_POINT_STRU * pSwitchTemp = NULL; + + /*ȡlink˵Ϣ*/ + rtnValue = GetLinkPointInfo(chDir, wStartLinkId, &pathTreeTemp); + + if (CI_ERROR == rtnValue) + { + ; + } + else if (pathTreeTemp.wPointType != EMAP_POINT_DOT) + { + /*ǵƥ*/ + rtnValue = CI_SUCCESS; + } + else + { + /*ùõϢ*/ + pSwitchTemp = g_dsuEmapStru->dsuStaticHeadStru->pPointStru + g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[pathTreeTemp.wPointId]; + wMainLink = pSwitchTemp->wMainLkId; + + chSwitchCurPos = GetSwitchCurPosition(pathTreeTemp.wPointId); + if (wStartLinkId == wMainLink) + { + /*λ*/ + chSwitchPos = SWITCH_POSITION_DINGWEI; + chKeepWork = CI_SUCCESS; + } + else + { + /*λ*/ + wSideLink = pSwitchTemp->wSideLkId; + if (wStartLinkId == wSideLink) + { + chSwitchPos = SWITCH_POSITION_FANWEI; + chKeepWork = CI_SUCCESS; + } + else + { + /**/ + wConfluentLink = pSwitchTemp->wConfluentLkId; + if (wStartLinkId == wConfluentLink) + { + /*жϵǷЧλ*/ + if ((SWITCH_POSITION_DINGWEI == chSwitchCurPos) + || (SWITCH_POSITION_FANWEI == chSwitchCurPos)) + { + /*״̬*/ + rtnValue = CI_SUCCESS; + (*pSwitchId) = pathTreeTemp.wPointId; + } + else + { + /*״̬ƥ*/ + (*pSwitchId) = pathTreeTemp.wPointId; + rtnValue = CI_ERROR; + } + } + else + { + /*ɴ֧*/ + rtnValue = CI_ERROR; + } + } + } + + + /*жϵ״̬Ƿ*/ + if (CI_SUCCESS == chKeepWork) + { + if (chSwitchPos == chSwitchCurPos) + { + /*״̬*/ + rtnValue = CI_SUCCESS; + (*pSwitchId) = pathTreeTemp.wPointId; + } + else + { + /*״̬ƥ*/ + (*pSwitchId) = pathTreeTemp.wPointId; + rtnValue = CI_ERROR; + } + } + } + return rtnValue; +} + +/** +* @brief ѯAǷBλùϵֻӦͬһlinkλñȽϻغϣ +* @param p_strPathPoint pPointA +* @param p_strPathPoint pPointB +* @param UINT8 dir +* @return ѯʧܣCI_ERRORغϣCI_SUCCESSABǰFLAG_SETBAǮFLAG_UNSET +*/ +UINT8 dsuJudgeLinkAandLinkBPosition(p_strPathPoint pPointA, p_strPathPoint pPointB, UINT8 dir) +{ + UINT8 chRtn = CI_ERROR; + UINT16 LinkNearA = 0u;/* Blink */ + UINT8 chFunRtn = CI_ERROR; + struct_PathPoint tempPointA = { 0u }; + struct_PathPoint tempPointB = { 0u }; + UINT16 wSwitchId = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 cDirectionPointCnt = 0U; /*仯*/ + + /* ڲ */ + if ((NULL == pPointA) || (NULL == pPointB)) + { + ;/*ڲ*/ + } + else if ((DIR_CONVERT != dir) && (DIR_SAME != dir)) + { + ;/*ڲ*/ + } + else if (pPointA->wLinkId == pPointB->wLinkId) + { + if (pPointA->dwOffset == pPointB->dwOffset) + { + /*ABغ*/ + chRtn = CI_SUCCESS; + } + else if (((pPointA->dwOffset > pPointB->dwOffset) && (DIR_SAME == dir)) || + ((pPointA->dwOffset < pPointB->dwOffset) && (DIR_CONVERT == dir))) + { + /*ABǰ*/ + chRtn = FLAG_SET; + } + else + { + /*BAǰ*/ + chRtn = FLAG_UNSET; + } + + } + else + { + /*ͨlink IDͷlink˵Ϣ*/ + tempPointA.wLinkId = pPointA->wLinkId; + + /*ѯAlinkȷطdirյ*/ + chFunRtn = GetLinkOffsetByDir(&tempPointA, dir, POINT_END, 0u); + /* ѯAڵlink */ + LinkNearA = FindAdjacentLinkIDSafe(pPointA->wLinkId, dir, &wSwitchId, &cDirectionPointFlag); + tempPointB.wLinkId = LinkNearA; + + /*ѯBʱAǷڷ仯㣬Ҫķ*/ + dir = TransDirectionPointDir(cDirectionPointFlag, dir, &cDirectionPointCnt); + /*ѯLinkNearBطdir*/ + chFunRtn &= GetLinkOffsetByDir(&tempPointB, dir, POINT_START, 0u); + + if ((CI_SUCCESS == chFunRtn) && (pPointA->dwOffset == tempPointA.dwOffset)) + { + if (pPointB->dwOffset == tempPointB.dwOffset) + { + /*ABغ*/ + chRtn = CI_SUCCESS; + } + else + { + /*ABͬһlink*/ + chRtn = CI_ERROR; + } + + } + else + { + /*ABͬһlink*/ + } + } + return chRtn; +} + +/** +* @brief ѯAǷBλùϵlink +* @param p_strPathPoint pPointA +* @param p_strPathPoint pPointB +* @param UINT8 dir +* @return ѯʧܣCI_ERROR + غϣCI_SUCCESS + ABǰFLAG_SET + BAǮFLAG_UNSET +*/ +UINT8 dsuJudgePointAandPointBPosition(p_strPathPoint pPointA, p_strPathPoint pPointB, UINT8 dir) +{ + UINT8 chRtn = CI_ERROR; + struct_PathPoint tempPointA = { 0u }; + struct_PathPoint tempPointB = { 0u }; + UINT32 dwLen = UINT32_MAX; + UINT8 chRtnDir = 0u; + + /* ڲ */ + if ((NULL == pPointA) || (NULL == pPointB)) + { + ;/*ڲ*/ + } + else if ((DIR_CONVERT != dir) && (DIR_SAME != dir)) + { + ;/*ڲ*/ + } + else + { + tempPointA.wLinkId = pPointA->wLinkId; + tempPointA.dwOffset = pPointA->dwOffset; + tempPointB.wLinkId = pPointB->wLinkId; + tempPointB.dwOffset = pPointB->dwOffset; + dwLen = DsuAPointToBPoint(&tempPointA, &tempPointB, &chRtnDir); + if (UINT32_MAX == dwLen) + { + ; + } + else if(0u == dwLen) + { + chRtn = CI_SUCCESS; + } + else if (chRtnDir == dir) + { + chRtn = FLAG_SET; + } + else + { + chRtn = FLAG_UNSET; + } + } + return chRtn; +} + +/** +* @brief ȡָlinkϵռѹΧ +* @param p_StrZone pZone +* @param UINT16 wLinkId link +* @param p_strPathPoint pStartPoint linkռѹ +* @param p_strPathPoint pEndPoint linkռѹյ +* @return CI_ERRORʧ CI_SUCCESSɹ +*/ +UINT8 dsuZoneStartEndPointInLink(p_StrZone pZone, IN const UINT16 wLinkId, OUT p_strPathPoint pStartPoint, OUT p_strPathPoint pEndPoint) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cKeepWork = CI_ERROR; + UINT16 i = UINT16_MAX; + UINT32 dwLinkLen = UINT32_MAX; + UINT8 cDirChangedNum = 0U; /*ڴڵķ仯*/ + UINT8 cTempZoneDir = 0U; + LOD_STRU LODStartStru = { 0U }; /**/ + LOD_STRU LODEndStru = { 0U }; /*յ*/ + + if ((NULL == pStartPoint) || (NULL == pEndPoint) || (NULL == pZone)) + { + ;/* ַ */ + } + else + { + /* ڴʼΪȫֵ */ + pStartPoint->wLinkId = UINT16_MAX; + pStartPoint->dwOffset = UINT32_MAX; + pEndPoint->wLinkId = UINT16_MAX; + pEndPoint->dwOffset = UINT32_MAX; + + dwLinkLen = GetLinkLengthById(wLinkId); + + if (UINT32_MAX != dwLinkLen) + { + /* 1.жгǷlink */ + for (i = 0u; i < pZone->pLinkSeq.cLinkCnt; i++) + { + if (wLinkId == pZone->pLinkSeq.szLinkId[i]) + { + cKeepWork = CI_SUCCESS; + break; + } + else + { + } + } + + if (CI_SUCCESS == cKeepWork) + { + /* гlink */ + if ((wLinkId == pZone->pStart.wLinkId) && (wLinkId == pZone->pEnd.wLinkId)) + { + /* յ㶼link,ݷжϴռѹյ */ + if (DIR_SAME == pZone->Dir) + { + pStartPoint->wLinkId = pZone->pStart.wLinkId; + pStartPoint->dwOffset = pZone->pStart.dwOffset; + pEndPoint->wLinkId = pZone->pEnd.wLinkId; + pEndPoint->dwOffset = pZone->pEnd.dwOffset; + } + else + { + pStartPoint->wLinkId = pZone->pEnd.wLinkId; + pStartPoint->dwOffset = pZone->pEnd.dwOffset; + pEndPoint->wLinkId = pZone->pStart.wLinkId; + pEndPoint->dwOffset = pZone->pStart.dwOffset; + } + } + else if ((wLinkId != pZone->pStart.wLinkId) && (wLinkId != pZone->pEnd.wLinkId)) + { + /* յ㶼,ѹlink */ + pStartPoint->wLinkId = wLinkId; + pStartPoint->dwOffset = 0u; + pEndPoint->wLinkId = wLinkId; + pEndPoint->dwOffset = dwLinkLen; + + } + else if (wLinkId == pZone->pStart.wLinkId) + { + /* յ㲻 */ + if (DIR_SAME == pZone->Dir) + { + pStartPoint->wLinkId = pZone->pStart.wLinkId; + pStartPoint->dwOffset = pZone->pStart.dwOffset; + pEndPoint->wLinkId = wLinkId; + pEndPoint->dwOffset = dwLinkLen; + } + else + { + pStartPoint->wLinkId = wLinkId; + pStartPoint->dwOffset = 0u; + pEndPoint->wLinkId = pZone->pStart.wLinkId; + pEndPoint->dwOffset = pZone->pStart.dwOffset; + } + } + else + { + /* 㲻յ */ + LODStartStru.Lnk = pZone->pStart.wLinkId; + LODStartStru.Off = pZone->pStart.dwOffset; + LODStartStru.Dir = pZone->Dir; + + LODEndStru.Lnk = pZone->pEnd.wLinkId; + LODEndStru.Off = pZone->pEnd.dwOffset; + LODEndStru.Dir = pZone->Dir; + + cTempZoneDir = pZone->Dir; + cDirChangedNum = GetDirChangeNumBtwPoints(&LODStartStru, &LODEndStru); /*ȡڵķ仯*/ + + /*жǷڷ仯,ת*/ + cTempZoneDir = TransDirByChangeNum(cTempZoneDir, cDirChangedNum); + + if (0U != cTempZoneDir) + { + if (DIR_SAME == cTempZoneDir) + { + pStartPoint->wLinkId = wLinkId; + pStartPoint->dwOffset = 0u; + pEndPoint->wLinkId = pZone->pEnd.wLinkId; + pEndPoint->dwOffset = pZone->pEnd.dwOffset; + } + else + { + pStartPoint->wLinkId = pZone->pEnd.wLinkId; + pStartPoint->dwOffset = pZone->pEnd.dwOffset; + pEndPoint->wLinkId = wLinkId; + pEndPoint->dwOffset = dwLinkLen; + } + } + else + { + /*޲*/ + } + } + + cRetVal = CI_SUCCESS; + } + else + { + } + } + else + { + } + + + } + + return cRetVal; +} + +/** +* @brief жϵǷ +* @param strPoint Ϣ +* @param strZone Ϣ +* @return CI_SUCCESSڣCI_ERROR +* @note ڲŻ 20220421 wqm ÷ֵCI_ERROR +*/ +UINT8 IsPointInPath(struct_PathPoint strPoint, str_Zone strZone) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 chFunARtn = CI_ERROR; + UINT8 chFunBRtn = CI_ERROR; + UINT8 i = 0u; + struct_PathPoint strStartPoint = { 0u }; + struct_PathPoint strEndPoint = { 0u }; + UINT8 cDir = DIR_INVALID; + LinkDataConfigStru * pLinkInfo = NULL; + + cRetVal = IsLinkIdValid(strPoint.wLinkId); + + if (CI_SUCCESS == cRetVal) + { + if (0u == strZone.pLinkSeq.cLinkCnt) + { + cRetVal = CI_ERROR; + } + else + { + for (i = 0u; i < strZone.pLinkSeq.cLinkCnt; i++) + { + if (strZone.pLinkSeq.szLinkId[i] == strPoint.wLinkId) + { + break; + } + } + + if (strZone.pLinkSeq.cLinkCnt != i) + {/* ȡlinkϵʵռѹ */ + cRetVal = dsuZoneStartEndPointInLink(&strZone, strPoint.wLinkId, &strStartPoint, &strEndPoint); + pLinkInfo = GetLinkDataById(strPoint.wLinkId); + + if ((CI_SUCCESS == cRetVal) && (NULL != pLinkInfo)) + {/* ȡ˵λùϵ */ + + cDir = ConvertDirectionToLogic((UINT8)pLinkInfo->wLinkLine); + chFunARtn = dsuJudgeLinkAandLinkBPosition(&strPoint, &strStartPoint, cDir); + chFunBRtn = dsuJudgeLinkAandLinkBPosition(&strPoint, &strEndPoint, cDir); + + /* һغϣλùϵһ£˵ */ + if ((CI_ERROR == chFunARtn) || (CI_SUCCESS == chFunARtn) + || (CI_ERROR == chFunBRtn) || (CI_SUCCESS == chFunBRtn) + || (chFunARtn != chFunBRtn)) + { + cRetVal = CI_ERROR; + } + else + { + /* 㲻 */ + cRetVal = CI_SUCCESS; + } + } + else + { + /** ڲŻ 20220421 wqm ˴ӦذȫCI_ERROR*/ + cRetVal = CI_ERROR; + } + } + else + { + cRetVal = CI_SUCCESS; + } + } + } + else + { + cRetVal = CI_ERROR; + } + + return cRetVal; +} + +/** +* @brief ͨյlinklinkеϢѯlinklinkС +* @param UINT16 linkA +* @param UINT16 linkB +* @param UINT8 chDir +* @param p_strPointInArea pSwInfo Ϣ +* @param p_StrPathLinkInfo pLinkSeq link +* @return CI_ERRORʧ CI_SUCCESSɹ +*/ +UINT8 dsuLinkSeqBtwLinkBaseSwitchInfo(UINT16 linkA, UINT16 linkB, UINT8 chDir, IN p_strPointInArea pSwInfo, OUT p_StrPathLinkInfo pLinkSeq) +{ + UINT8 chRtn = CI_ERROR; /*طֵ*/ + UINT8 chFunRtn = CI_ERROR; /*ѯֵ*/ + UINT8 dquNum = 0u; + UINT8 chSwCycle = 0u; /*Ϣ*/ + UINT16 currentLinkID = UINT16_MAX; + LinkPointDataStru pathTree = { 0u }; /*link˵Ϣ*/ + UINT8 cQueryDir = 0U; /*linkѯ*/ + UINT8 cCurLinkDirChanged = LINK_DIRCHANGE_NONE; /*ǰLink仯*/ + UINT8 cNxtLinkDirChanged = LINK_DIRCHANGE_NONE; /*һLink仯*/ + /*ڲ*/ + if ((NULL == pLinkSeq) || (NULL == pSwInfo)) + { + /*ںǷʧ*/ + } + else if ((DIR_SAME != chDir) && (DIR_CONVERT != chDir)) + { + /*ںǷʧ*/ + } + else + { + /*ʼ*/ + (void)CommonMemSet(pLinkSeq, (UINT32)sizeof(str_PathLinkInfo), 0u, (UINT32)sizeof(str_PathLinkInfo)); + + /*жlink IDǷȷ*/ + chFunRtn = IsLinkIdValid(linkA); + chFunRtn &= IsLinkIdValid(linkB); + + if (CI_SUCCESS == chFunRtn) + { + /*òѯ*/ + currentLinkID = linkA; + pLinkSeq->cLinkCnt = 0u; + cQueryDir = chDir; + + while ((DSU_ROUTE_STRU_wLinkId > dquNum) && (CI_SUCCESS == chFunRtn)) + { + if (currentLinkID == linkB) + { + pLinkSeq->szLinkId[pLinkSeq->cLinkCnt] = currentLinkID; + pLinkSeq->cLinkCnt++; + chRtn = CI_SUCCESS; + break; + } + else + { + pLinkSeq->szLinkId[pLinkSeq->cLinkCnt] = currentLinkID; + pLinkSeq->cLinkCnt++; + + chFunRtn = GetLinkPointInfo(cQueryDir, currentLinkID, &pathTree); + cCurLinkDirChanged = GetLinkLogicDirChangedById(currentLinkID); + + if (EMAP_POINT_DOT == pathTree.wPointType) + { + /*linkӵĶ˵Ϊ*/ + for (chSwCycle = 0u; chSwCycle < pSwInfo->SwitchNum; chSwCycle++) + { + /*òѯδɹ*/ + chFunRtn = CI_ERROR; + + if (pathTree.wPointId == pSwInfo->SwitchInfo[chSwCycle].pointID) + { + /*ݵ״̬һ׼link*/ + if (UINT16_MAX == pathTree.wSideLinkId) + { + /*˵ǴӶλ߷λһlink*/ + chFunRtn = CI_SUCCESS; + currentLinkID = pathTree.wMainLinkId; + } + else if (SWITCH_POSITION_DINGWEI == pSwInfo->SwitchInfo[chSwCycle].status) + { + chFunRtn = CI_SUCCESS; + currentLinkID = pathTree.wMainLinkId; + } + else if (SWITCH_POSITION_FANWEI== pSwInfo->SwitchInfo[chSwCycle].status) + { + chFunRtn = CI_SUCCESS; + currentLinkID = pathTree.wSideLinkId; + } + else + { + /*ѯʧ*/ + } + break; + } + else + { + /**/ + } + } + } + else + { + /*ǵһ׼link*/ + currentLinkID = pathTree.wMainLinkId; + } + + /*жlink IDǷȷ*/ + chFunRtn &= IsLinkIdValid(currentLinkID); + + /*жǷڷ仯*/ + cNxtLinkDirChanged = GetLinkLogicDirChangedById(currentLinkID); + if (((LINK_DIRCHANGE_BEGIN == cNxtLinkDirChanged) || (LINK_DIRCHANGE_END == cNxtLinkDirChanged)) + && (cNxtLinkDirChanged == cCurLinkDirChanged)) + { + /*ڷ仯*/ + cQueryDir = ~cQueryDir; + } + else + { + /*ڷ仯㣬*/ + } + } + + /*ѭֹѭpLinkSeq->LockLinkIdԽ*/ + dquNum++; + } + + if (CI_SUCCESS == chRtn) + { + /*ѯɹ*/ + } + else + { + /*ѯɹ*/ + (void)CommonMemSet(pLinkSeq, (UINT32)sizeof(str_PathLinkInfo), 0u, (UINT32)sizeof(str_PathLinkInfo)); + } + } + else + { + /*link ID󣬲*/ + } + } + + return chRtn; +} + +/** +* @brief ͨеĵϢѯlinkС +* @param struct_PathPoint pStart +* @param struct_PathPoint pEnd յ +* @param UINT8 chDir +* @param p_strPointInArea pSwInfo Ϣ +* @param p_StrPathLinkInfo pLinkSeq link +* @return CI_ERRORʧ CI_SUCCESSɹ +*/ +UINT8 dsuLinkSeqInAreaBaseSwitchInfo(struct_PathPoint pStart, struct_PathPoint pEnd, UINT8 chDir, IN p_strPointInArea pSwInfo, OUT p_StrPathLinkInfo pLinkSeq) +{ + UINT8 chRtn = CI_ERROR; /*طֵ*/ + + /*˺Ϊײ㺯ķװڲȫɱúУ*/ + chRtn = dsuLinkSeqBtwLinkBaseSwitchInfo(pStart.wLinkId, pEnd.wLinkId, chDir, pSwInfo, pLinkSeq); + + return chRtn; +} + +/** +* @brief ѯA㵽Bľ롣 +* @param p_strPathPoint pAPoint +* @param p_strPathPoint pBPoint +* @param UINT8 *pDir +* @return ѯʧܣUINT32_MAXΪ0ʾغ +*/ +UINT32 DsuAPointToBPoint(p_strPathPoint pAPoint, p_strPathPoint pBPoint, UINT8 *pDir) +{ + UINT32 dwRetVal = UINT32_MAX; + LOD_STRU LODAPointStru = { 0u }; + LOD_STRU LODBPointStru = { 0u }; + UINT8 cEmpDir = EMAP_SAME_DIR; + UINT16 wlinkNum = 0u; + UINT16 szLinkIdBuf[USE_DSU_TWOPOINT_LINK_SIZE] = { 0u }; + + if ((NULL != pDir) && (0u != pAPoint->wLinkId) && (0u != pBPoint->wLinkId)) + { + LODAPointStru.Lnk = pAPoint->wLinkId; + LODAPointStru.Off = pAPoint->dwOffset; + LODAPointStru.Dir = EMAP_SAME_DIR; + + LODBPointStru.Lnk = pBPoint->wLinkId; + LODBPointStru.Off = pBPoint->dwOffset; + LODBPointStru.Dir = EMAP_SAME_DIR; + + dwRetVal = dsuLenByPoint(&LODAPointStru, &LODBPointStru, &wlinkNum, szLinkIdBuf, &cEmpDir); + + if (UINT32_MAX != dwRetVal) + { + if (EMAP_SAME_DIR == cEmpDir) + { + *pDir = DIR_SAME; + } + else + { + *pDir = DIR_CONVERT; + } + } + } + else + { + ; + } + + return dwRetVal; +} + +/** +* @brief ѯlinkڵλá +* @param UINT16 wLinkID +* @param UINT16 wSwitchId +* @param UINT8 *p_LinkInSW +* @return CI_ERROR:ѯʧܣCI_SUCCESS:ѯɹ +*/ +UINT8 dsuLinkofSwitchPos(UINT16 wLinkID, UINT16 wSwitchId, UINT8 *p_LinkInSW) +{ + UINT8 chRtn = CI_ERROR; /*ֵ*/ + DSU_POINT_STRU * pSwitchTemp = NULL; + + if (NULL != p_LinkInSW) + { + pSwitchTemp = g_dsuEmapStru->dsuStaticHeadStru->pPointStru + g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wSwitchId]; + + if (NULL != pSwitchTemp) + { + if (wLinkID == pSwitchTemp->wConfluentLkId) + { + /*linkΪĻlink*/ + *p_LinkInSW = SW_CON_LINK; + } + else if (wLinkID == pSwitchTemp->wMainLkId) + { + /*linkΪĶλlink*/ + *p_LinkInSW = SW_MAIN_LINK; + } + else if (wLinkID == pSwitchTemp->wSideLkId) + { + /*linkΪķλlink*/ + *p_LinkInSW = SW_SIDE_LINK; + } + else + { + *p_LinkInSW = SW_DEFAUT_LINK; + } + chRtn = CI_SUCCESS; + } + else + { + ; /*ѯ󣬷*/ + } + } + else + { + ; /* ʧ */ + } + + return chRtn; +} + +/** +* @brief ѯA㵽BlinkС +* @param p_strPathPoint pAPoint +* @param p_strPathPoint pBPoint +* @param UINT8 *pDir +* @param UINT16 * pLinkNum LINK +* @param UINT16 * pLinkIdBuf LINKŻ +* @return CI_ERROR:ѯʧܣCI_SUCCESS:ѯɹ +*/ +UINT8 DsuLinkSeqBtwPoints(p_strPathPoint pAPoint, p_strPathPoint pBPoint, OUT UINT8 *pDir, OUT UINT16 * pLinkNum, OUT UINT16 * pLinkIdBuf) +{ + UINT32 dwRetVal = UINT32_MAX; + LOD_STRU LODAPointStru = { 0u }; + LOD_STRU LODBPointStru = { 0u }; + UINT8 cEmpDir = EMAP_SAME_DIR; + UINT16 wlinkNum = 0u; + UINT16 szLinkIdBuf[USE_DSU_TWOPOINT_LINK_SIZE] = { 0u }; + UINT8 chRtn = CI_ERROR; + + if ((NULL != pDir) && (0u != pAPoint->wLinkId) && (0u != pBPoint->wLinkId)) + { + LODAPointStru.Lnk = pAPoint->wLinkId; + LODAPointStru.Off = pAPoint->dwOffset; + LODAPointStru.Dir = EMAP_SAME_DIR; + + LODBPointStru.Lnk = pBPoint->wLinkId; + LODBPointStru.Off = pBPoint->dwOffset; + LODBPointStru.Dir = EMAP_SAME_DIR; + + dwRetVal = dsuLenByPoint(&LODAPointStru, &LODBPointStru, pLinkNum, pLinkIdBuf, &cEmpDir); + + if (UINT32_MAX != dwRetVal) + { + if (EMAP_SAME_DIR == cEmpDir) + { + *pDir = DIR_SAME; + } + else + { + *pDir = DIR_CONVERT; + } + chRtn = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; + } + + return chRtn; +} + +/** +* @brief ȡlinkڵǰ·˹ϵID +* @param wLinkId +* @return linkڵǰ·˹ϵID +*/ +UINT16 GetLinkBelongAcId(UINT16 wLinkId) +{ + UINT16 szLink[AXIS_INCLUDE_LINK_SUM_MAX];/* link */ + UINT8 chLinkNum = 0u; /* link */ + UINT16 wRtn = 0u; + UINT8 chFunRtn = CI_ERROR; + LinkPointDataStru strPoint = { 0u }; + UINT16 wNextLinkId = 0u; + UINT16 wSwitchId = 0u; + UINT8 chAcLinkNum = 0u; + UINT16 * pAcLinkId = NULL; + UINT8 chAcNum = 0u; + UINT16 * pAcId = NULL; + UINT16 wPhySecId = 0u; + UINT8 chAcIndex = 0u; + UINT8 chLinkIndex = 0u; + UINT8 chAcLinkIndex = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + chFunRtn = IsLinkIdValid(wLinkId); + + if (CI_SUCCESS == chFunRtn) + { + wPhySecId = GetLinkRelatedPhySec(wLinkId); + /* ѯlinkΰlink */ + szLink[chLinkNum++] = wLinkId; + + /* 鵽ζ˵ */ + chFunRtn = GetLinkPointInfo(DIR_CONVERT, wLinkId, &strPoint); + wNextLinkId = wLinkId; + while ((EMAP_POINT_DOT == strPoint.wPointType) && (CI_SUCCESS == chFunRtn) && (UINT16_MAX != wNextLinkId) && (0U != wNextLinkId)) + { + /*ѯڵ㣬Ƿ仯*/ + wNextLinkId = FindAdjacentLinkIDSafe(wNextLinkId, DIR_CONVERT, &wSwitchId, &cDirectionPointFlag); + if ((UINT16_MAX != wNextLinkId)&&(0U != wNextLinkId)) + {/* ˵Ŀ */ + szLink[chLinkNum++] = wNextLinkId; + chFunRtn = GetLinkPointInfo(DIR_CONVERT, wNextLinkId, &strPoint); + } + } + + if (CI_SUCCESS == chFunRtn) + { + /* 鵽ζ˵ */ + chFunRtn = GetLinkPointInfo(DIR_SAME, wLinkId, &strPoint); + wNextLinkId = wLinkId; + while ((EMAP_POINT_DOT == strPoint.wPointType) && (CI_SUCCESS == chFunRtn) && (UINT16_MAX != wNextLinkId) && (0U != wNextLinkId)) + { + /*ѯڵ㣬Ƿ仯*/ + wNextLinkId = FindAdjacentLinkIDSafe(wNextLinkId, DIR_SAME, &wSwitchId, &cDirectionPointFlag); + if ((UINT16_MAX != wNextLinkId) && (0U != wNextLinkId)) + {/* ˵Ŀ */ + szLink[chLinkNum++] = wNextLinkId; + chFunRtn = GetLinkPointInfo(DIR_SAME, wNextLinkId, &strPoint); + } + } + + if (CI_SUCCESS == chFunRtn) + { + chAcNum = GetPAxisSectionSum(wPhySecId); + pAcId = GetPAxisSectionIdBuf(wPhySecId); + if ((0u != chAcNum) && (NULL != pAcId)) + { + for (chAcIndex = 0u; chAcIndex < chAcNum; chAcIndex++) + {/* linkΰļ */ + chAcLinkNum = GetAxisLinkSum(pAcId[chAcIndex]); + pAcLinkId = GetAxisLinkIdBuf(pAcId[chAcIndex]); + if ((0u != chAcLinkNum) && (NULL != pAcLinkId)) + { + for (chLinkIndex = 0u; chLinkIndex < chLinkNum; chLinkIndex++) + {/* ҵlink */ + for (chAcLinkIndex = 0u; chAcLinkIndex < chAcLinkNum; chAcLinkIndex++) + { + if (szLink[chLinkIndex] == pAcLinkId[chAcLinkIndex]) + {/* ڼΰlink֮ */ + break; + } + } + if (chAcLinkIndex == chAcLinkNum) + {/* linkδڸüҵ */ + break; + } + } + if (chLinkIndex == chLinkNum) + {/* linkڼΰlinkҵ */ + wRtn = pAcId[chAcIndex]; + } + } + } + } + } + } + } + + return wRtn; +} + +/************************************************************************ +ܣλϢת +ڲ: UINT16 wLinkSrc, UINT32 dwOffsetSrc +ڲ: UINT16* wLinkDst, UINT32* dwOffsetDst +ֵ: ѯʧܻѯ·ն˻λòΪlink˵: CI_ERROR; ѯɹ: CI_SUCCESS +************************************************************************/ +UINT8 dsuCheckSameLoc(UINT16 wLinkSrc, UINT32 dwOffsetSrc, UINT16* wLinkDst, UINT32* dwOffsetDst) +{ + UINT32 tmpLinkLen = 0u; /*ʱ*/ + UINT8 chReturnValue = CI_ERROR; /*ؽ,Ĭʧ*/ + UINT8 chDirTemp = 0u; + UINT8 chDirChangeTimes = 0u; /*linkı*/ + UINT16 wLinkId = 0u; /*link*/ + UINT8 chFunRtn = CI_ERROR; + UINT16 wSwitchId = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + chFunRtn = CheckLinkValid(wLinkSrc, dwOffsetSrc); + /*жЧ*/ + if (CI_SUCCESS != chFunRtn) + { + /*Ч룬ѯʧܣĬֵ*/ + ; + } + else + { + /*ȡԴlinkij*/ + tmpLinkLen = GetLinkLengthById(wLinkSrc); + + if (dwOffsetSrc == tmpLinkLen) + { + /*ԴlinkƫΪǰlink,յӵͼlink*/ + *wLinkDst = FindAdjacentLinkIDSafe(wLinkSrc, EMAP_SAME_DIR, &wSwitchId, &cDirectionPointFlag); + if ((UINT16_MAX == (*wLinkDst)) || (0u == (*wLinkDst))) + { + /*ѯʧܻѯ·նˣʧ*/ + ; + } + else + { + if (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) + { + *dwOffsetDst = GetLinkLengthById((*wLinkDst)); + } + else + { + *dwOffsetDst = 0u; + } + chReturnValue = CI_SUCCESS; + } + } + else if (0u == dwOffsetSrc) + { + /*ԴlinkƫΪǰlinkС,յӵͼķlinkյ*/ + *wLinkDst = FindAdjacentLinkIDSafe(wLinkSrc, EMAP_CONVER_DIR, &wSwitchId, &cDirectionPointFlag); + if ((UINT16_MAX == (*wLinkDst)) || (0u == (*wLinkDst))) + { + /*ѯʧܻѯ·նˣʧ*/ + ; + } + else + { + if (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) + { + *dwOffsetDst = 0u; + } + else + { + *dwOffsetDst = GetLinkLengthById((*wLinkDst)); + } + chReturnValue = CI_SUCCESS; + } + } + else + { + /*ǰƫlink,߲ΪǰlinkʼˡҲΪն,ѯʧ*/ + ; + } + } + return chReturnValue; +} + + +/********************************************* +ܣlinkлüα +linkId ׵ַLinkNum link +AxleSgmtId αַ +AxleSgmtNum 鳤 +ֵCI_ERRORʧܣCI_SUCCESSɹ +עlink +**********************************************/ +UINT8 GetAxisSeqFromLinkSeq(UINT16* linkId, UINT16 LinkNum, UINT16 *AxleSgmtId, UINT16 * AxleSgmtNum, UINT16 maxSize) +{ + UINT8 rtnValue = CI_ERROR; + UINT8 buffValidFlag = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT8 execValid = CI_ERROR; + UINT16 acNum = 0U; + UINT16 tmpLinkCnt = 0U; + UINT16 tmpLinkId[LINK_SUM_MAX] = { 0U }; /*ͬһΰlink*/ + UINT16 tmpSameLinkOfACCnt = 0U; + UINT16 tmpSameLinkOfACID[PHYSICAL_INCLUDE_AXIS_SUM_MAX] = { 0U }; /*ͬһΰlink*/ + UINT16 tmpSearchedFlag[LINK_SUM_MAX] = { 0U }; /*linkǷѾ*/ + UINT16 linkIndex = 0U; + UINT16 linkOfPhyId = 0U; + UINT16 tmplinkOfPhyId = 0U; + UINT16 cycleone = 0U; + UINT16 cycleTwo = 0U; + UINT16 cycleAC = 0U; + UINT16 cycleLink = 0U; + UINT16 cycleLinkInAC = 0U; + UINT16 cycleSw = 0U; + UINT16 tmpACCnt = 0U; + UINT8 tmpLinkCntInAC = 0U; + UINT8 tmpSwCntInAC = 0U; + UINT8 tmpLinkinSwType = SW_DEFAUT_LINK; + UINT8 tmpSwPos = SWITCH_POSITION_INVALID; + const UINT16* pACIDBuf = NULL; + const UINT16* pLinkIDBuf = NULL; + const AxisSwitchStruct* pSwitchInfoBuf = NULL; + UINT8 chFlagOne = FLAG_UNSET; + UINT8 chFlagTwo = FLAG_UNSET; + UINT8 chCheckStart = FLAG_UNSET; + UINT16 szCheckedSw[AXIS_INCLUDE_SWITCH_SUM_MAX] = { 0U }; + UINT8 chCheckedSwNum = 0U; + UINT8 chCheckedFlag = CI_ERROR; + UINT8 chLoopIndex = 0U; + UINT16 szLoopLinkId[AXIS_INCLUDE_LINK_SUM_MAX] = { 0U }; + AxisSwitchStruct szLoopSwitchInfo[AXIS_INCLUDE_SWITCH_SUM_MAX] = { 0U }; + + + /*μ*/ + if ((NULL == linkId) || (0U == LinkNum) || (NULL == AxleSgmtId) || (NULL == AxleSgmtNum) || (acNum >= maxSize)) + { + ; + } + else + { + buffValidFlag = CI_SUCCESS; + rtnValue = CI_SUCCESS; + } + + + if (CI_SUCCESS == rtnValue) + { + for (cycleone = 0U; cycleone < LinkNum; cycleone++) + { + /** */ + tmpLinkCnt = 0U; + (void)CommonMemSet(tmpLinkId, (UINT32)(sizeof(UINT16) * LINK_SUM_MAX), 0, (UINT32)(sizeof(UINT16) * LINK_SUM_MAX)); + tmpSameLinkOfACCnt = 0U; + (void)CommonMemSet(tmpSameLinkOfACID, (UINT32)(sizeof(UINT16) * PHYSICAL_INCLUDE_AXIS_SUM_MAX), 0, (UINT32)(sizeof(UINT16) * PHYSICAL_INCLUDE_AXIS_SUM_MAX)); + + + /** ȡlink */ + linkIndex = GetLinkIndexById(linkId[cycleone]); + if (linkIndex >= LINK_SUM_MAX) + { + chFlagOne = FLAG_SET; + } + else if (UINT8_MAX == tmpSearchedFlag[linkIndex]) + { + ;/*link账 */ + } + else + { + /*- һȡͬһεlink */ + linkOfPhyId = GetLinkRelatedPhySec(linkId[cycleone]); + + if (0U == linkOfPhyId) + { + /** ݲѯ*/ + chFlagOne = FLAG_SET; + } + else + { + /** */ + } + if (FLAG_UNSET == chFlagOne) + { + tmpLinkId[tmpLinkCnt++] = linkId[cycleone]; + tmpSearchedFlag[linkIndex] = UINT8_MAX; + + /*ѯlinkͬlink*/ + for (cycleTwo = cycleone + 1U; cycleTwo < LinkNum; cycleTwo++) + { + /*ȡlink*/ + tmplinkOfPhyId = GetLinkRelatedPhySec(linkId[cycleTwo]); + linkIndex = GetLinkIndexById(linkId[cycleTwo]); + + if ((linkOfPhyId == tmplinkOfPhyId) && (UINT16_MAX != linkIndex)) + { + /*עtmpLinkIdԽΪһԽ*/ + tmpLinkId[tmpLinkCnt++] = linkId[cycleTwo]; + tmpSearchedFlag[linkIndex] = UINT8_MAX; + } + else + { + /**/ + } + } + + /*- ڶͳһεмᣬҵlinkļ*/ + tmpACCnt = GetPAxisSectionSum(linkOfPhyId); + pACIDBuf = GetPAxisSectionIdBuf(linkOfPhyId); + + if ((0U == tmpACCnt) || (NULL == pACIDBuf)) + { + /** ѯ */ + chFlagOne = FLAG_SET; + } + else if (1U == tmpACCnt) + { + /** ֱ*/ + if (acNum < maxSize) + { + AxleSgmtId[acNum++] = pACIDBuf[0]; + } + else + { + /** AxleSgmtIdռ䲻 */ + buffValidFlag = CI_ERROR; + } + } + else + { + /** ڵҪж*/ + for (cycleAC = 0U; cycleAC < tmpACCnt; cycleAC++) + { + /** ȡϵlink*/ + tmpLinkCntInAC = GetAxisLinkSum(pACIDBuf[cycleAC]); + pLinkIDBuf = GetAxisLinkIdBuf(pACIDBuf[cycleAC]); + + if ((0U == tmpLinkCntInAC) || (NULL == pLinkIDBuf)) + { + /*ѯʧ*/ + break; + } + else + { + /* жlinkǷȫڼ᷶Χ */ + for (cycleLink = 0U; cycleLink < tmpLinkCnt; cycleLink++) + { + for (cycleLinkInAC = 0U; cycleLinkInAC < tmpLinkCntInAC; cycleLinkInAC++) + { + if (pLinkIDBuf[cycleLinkInAC] == tmpLinkId[cycleLink]) + { + /** ͬһεlinkڼ᷶Χ */ + break; + } + else + { + /** */ + } + } + + if (cycleLinkInAC == tmpLinkCntInAC) + { + /** linkڸüᣬ˼᲻ҪѰļ*/ + break; + } + else + { + /* */ + } + } + + if (cycleLink == tmpLinkCnt) + { + /** üеlink,üID */ + tmpSameLinkOfACID[tmpSameLinkOfACCnt++] = pACIDBuf[cycleAC]; + } + else + { + /** */ + } + } + } + + /** жִǷɹ */ + if ((cycleAC == tmpACCnt) && (0U != tmpSameLinkOfACCnt)) + { + /** ִȷִ*/ + } + else + { + /** */ + chFlagOne = FLAG_SET; + } + + /*- ԼڵĵУ*/ + if (FLAG_UNSET == chFlagOne) + { + if (1U == tmpSameLinkOfACCnt) + { + /** ֻѯһеУ飬жϵ*/ + if (acNum < maxSize) + { + AxleSgmtId[acNum++] = tmpSameLinkOfACID[0]; + } + else + { + /** AxleSgmtIdռ䲻 */ + buffValidFlag = CI_ERROR; + } + } + else + { + /** ˷֧execValidһóɳɹ*/ + execValid = CI_ERROR; + + for (cycleAC = 0U; cycleAC < tmpSameLinkOfACCnt; cycleAC++) + { + /** Ҫ */ + chCheckStart = FLAG_UNSET; + + /** ȡϵĵϢ*/ + tmpSwCntInAC = GetAxisSwitchSum(tmpSameLinkOfACID[cycleAC]); + pSwitchInfoBuf = GetAxisSwitchIdStru(tmpSameLinkOfACID[cycleAC]); + + /** ȡϵlink*/ + tmpLinkCntInAC = GetAxisLinkSum(tmpSameLinkOfACID[cycleAC]); + pLinkIDBuf = GetAxisLinkIdBuf(tmpSameLinkOfACID[cycleAC]); + + if ((NULL == pSwitchInfoBuf) || (NULL == pLinkIDBuf)) + { + /*ѯʧ*/ + break; + } + else + { + /* ñ־λ */ + chCheckedSwNum = 0U; + (void)CommonMemCpy(&szLoopLinkId[0], (UINT32)(sizeof(UINT16) * tmpLinkCntInAC), &pLinkIDBuf[0], (UINT32)(sizeof(UINT16) * tmpLinkCntInAC)); + (void)CommonMemCpy(&szLoopSwitchInfo[0], (UINT32)(sizeof(AxisSwitchStruct) * tmpSwCntInAC), &pSwitchInfoBuf[0], (UINT32)(sizeof(AxisSwitchStruct) * tmpSwCntInAC)); + /** Уϵϵļ */ + if ((pLinkIDBuf[0] == tmpLinkId[0]) + || (pLinkIDBuf[0] == tmpLinkId[tmpLinkCnt - 1])) + { + ; /* εһlink */ + } + else if ((pLinkIDBuf[tmpLinkCntInAC - 1] == tmpLinkId[0]) + || (pLinkIDBuf[tmpLinkCntInAC - 1] == tmpLinkId[tmpLinkCnt - 1])) + {/* εһlinkһlinkҪ */ + for (chLoopIndex = 0U; chLoopIndex < tmpLinkCntInAC / 2U; chLoopIndex++) + {/* link */ + szLoopLinkId[chLoopIndex] = pLinkIDBuf[tmpLinkCntInAC - chLoopIndex - 1]; + szLoopLinkId[tmpLinkCntInAC - chLoopIndex - 1] = pLinkIDBuf[chLoopIndex]; + } + if (0U == tmpLinkCntInAC % 2U) + { + ; /* ż */ + } + else + {/* ΰlinkɺ󣬸ֵмlink */ + szLoopLinkId[tmpLinkCntInAC / 2] = pLinkIDBuf[tmpLinkCntInAC / 2]; + } + for (chLoopIndex = 0U; chLoopIndex < tmpSwCntInAC / 2U; chLoopIndex++) + {/* Ϣ */ + szLoopSwitchInfo[chLoopIndex].SwitchId = pSwitchInfoBuf[tmpSwCntInAC - chLoopIndex - 1].SwitchId; + szLoopSwitchInfo[chLoopIndex].SwitchPosition = pSwitchInfoBuf[tmpSwCntInAC - chLoopIndex - 1].SwitchPosition; + szLoopSwitchInfo[tmpSwCntInAC - chLoopIndex - 1].SwitchId = pSwitchInfoBuf[chLoopIndex].SwitchId; + szLoopSwitchInfo[tmpSwCntInAC - chLoopIndex - 1].SwitchPosition = pSwitchInfoBuf[chLoopIndex].SwitchPosition; + } + if (0U == tmpSwCntInAC % 2U) + { + ; /* ż */ + } + else + {/* ΰɺ󣬸ֵмϢ */ + szLoopSwitchInfo[tmpSwCntInAC / 2].SwitchId = pSwitchInfoBuf[tmpSwCntInAC / 2].SwitchId; + szLoopSwitchInfo[tmpSwCntInAC / 2].SwitchPosition = pSwitchInfoBuf[tmpSwCntInAC / 2].SwitchPosition; + } + } + else + { + ; /* εһlinkҲһlinkĬ˳ */ + } + + for (cycleLinkInAC = 0U; cycleLinkInAC < tmpLinkCntInAC; cycleLinkInAC++) + { + if (FLAG_UNSET == chCheckStart) + { + for (cycleLink = 0U; cycleLink < tmpLinkCnt; cycleLink++) + { + if (tmpLinkId[cycleLink] == szLoopLinkId[cycleLinkInAC]) + { + /** ҵҪʼlink */ + chCheckStart = FLAG_SET; + } + } + } + else + { + /** 账 */ + } + + if (FLAG_UNSET == chCheckStart) + { + /** 账 */ + } + else + { + /* ñ־λ */ + chFlagTwo = FLAG_UNSET; + + for (cycleSw = 0U; cycleSw < tmpSwCntInAC; cycleSw++) + { + funRtn = dsuLinkofSwitchPos(szLoopLinkId[cycleLinkInAC], szLoopSwitchInfo[cycleSw].SwitchId, &tmpLinkinSwType); + + if (CI_ERROR == funRtn) + { + /** ѯ󣬷*/ + chFlagTwo = FLAG_SET; + } + else if ((SW_CON_LINK == tmpLinkinSwType) || (SW_MAIN_LINK == tmpLinkinSwType) || (SW_SIDE_LINK == tmpLinkinSwType)) + { + chCheckedFlag = IsMenberOfSeq(szLoopSwitchInfo[cycleSw].SwitchId, chCheckedSwNum, szCheckedSw); + if (CI_SUCCESS != chCheckedFlag) + { + if (SW_CON_LINK == tmpLinkinSwType) + { + tmpSwPos = GetSwitchCurPosition(szLoopSwitchInfo[cycleSw].SwitchId); + + if (((SWITCH_POSITION_DINGWEI == tmpSwPos) || (SWITCH_POSITION_FANWEI == tmpSwPos)) && + (tmpSwPos != szLoopSwitchInfo[cycleSw].SwitchPosition)) + { + /** λȷԤڣ*/ + chFlagTwo = FLAG_SET; + } + else + { + /**/ + } + } + else + { + /** ǵlink,ĵλ,*/ + } + szCheckedSw[chCheckedSwNum++] = szLoopSwitchInfo[cycleSw].SwitchId; + } + else + { + ; /* Ѿλá */ + } + } + else + { + /** ǵlink,ĵλ,*/ + } + + if (FLAG_SET == chFlagTwo) + { + break; + } + else + { + ; + } + } + + /** жϲѯ */ + if (cycleSw != tmpSwCntInAC) + { + /** Ҫ󣬲 */ + break; + } + else + { + /** Ҫ һ*/ + } + } + } + + if ((FLAG_SET == chCheckStart) && (cycleLinkInAC == tmpLinkCntInAC)) + { + /** üΪҪҵļ*/ + if (acNum < maxSize) + { + AxleSgmtId[acNum++] = tmpSameLinkOfACID[cycleAC]; + } + else + { + /** AxleSgmtIdռ䲻 */ + buffValidFlag = CI_ERROR; + } + + execValid = CI_SUCCESS; + } + else + { + /** Ҫ󣬼*/ + } + } + } + + /** жִǷɹ */ + if ((cycleAC == tmpSameLinkOfACCnt) && (CI_SUCCESS == execValid)) + { + /** ִȷִ*/ + } + else + { + /** */ + chFlagOne = FLAG_SET; + } + } + } + else + { + ;/* ҪѭʲôҲ */ + } + } + } + else + { + ;/* ҪѭʲôҲ */ + } + } + + if (FLAG_SET == chFlagOne) + { + break; + } + else + { + ; + } + } + + /** ÷ؽ*/ + if ((cycleone == LinkNum) && (CI_SUCCESS == buffValidFlag)) + { + (*AxleSgmtNum) = acNum; + rtnValue = CI_SUCCESS; + } + else + { + /** ѯʧ*/ + (*AxleSgmtNum) = 0U; + rtnValue = CI_ERROR; + } + } + else + { + /** ڲ󣬲*/ + } + + return rtnValue; +} + +/** +* @brief ͨյlinklinklinkϢѯlinkĵϢ +* @param UINT16 linkA +* @param UINT16 linkB +* @param UINT8 chDir +* @param IN p_StrPathLinkInfo pLinkSeq +* @param OUT p_strPointInArea pSwInfo +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +*/ +UINT8 dsuSwitchInfoBtwLinkBaseLinkSeq(UINT16 linkA, UINT16 linkB, UINT8 chDir, IN p_StrPathLinkInfo pLinkSeq, OUT p_strPointInArea pSwInfo) +{ + UINT8 chRtn = CI_ERROR; /*طֵ*/ + UINT8 chFunRtn = CI_ERROR; /*ѯֵ*/ + UINT8 chCycle = 0u; /*link*/ + UINT16 currentLinkID = UINT16_MAX; /*ǰlink*/ + UINT16 wPreLinkID = UINT16_MAX; /*һlink*/ + UINT16 nextLinkID = UINT16_MAX; /*next link*/ + UINT8 exStatus = 0u; /*link֮ĵ״̬*/ + LinkPointDataStru pathTree = { 0u }; /*link˵Ϣ*/ + UINT8 chBreakRtn = FLAG_UNSET; + UINT8 cTmpIndex = 0u; + UINT8 cQueryDir = 0U; /*linkѯ*/ + UINT8 cCurLinkDirChanged = LINK_DIRCHANGE_NONE; /*ǰLink仯*/ + UINT8 cPreLinkDirChanged = LINK_DIRCHANGE_NONE; /*һLink仯*/ + + /*ڲ*/ + if ((NULL == pLinkSeq) || (NULL == pSwInfo)) + { + /*ںǷʧ*/ + } + else if ((DIR_SAME != chDir) && (DIR_CONVERT != chDir)) + { + /*ںǷʧ*/ + } + else if ((0u == pLinkSeq->cLinkCnt) || + (linkA != pLinkSeq->szLinkId[0]) || + (linkB != pLinkSeq->szLinkId[pLinkSeq->cLinkCnt - 1U])) + { + /*linkIDյlinkIDƻյ㲻ϣںǷʧ*/ + ; + } + else + { + /*ʼϢ*/ + (void)CommonMemSet(pSwInfo, (UINT32)sizeof(str_PointInArea), 0u, (UINT32)sizeof(str_PointInArea)); + + + cTmpIndex = pLinkSeq->cLinkCnt - 1u; + cQueryDir = chDir; + + /*αеlink*/ + for (chCycle = 0u; chCycle < pLinkSeq->cLinkCnt; chCycle++) + { + /*÷ֵΪʧ*/ + chRtn = CI_ERROR; + + /*˵link*/ + currentLinkID = pLinkSeq->szLinkId[chCycle]; + if (0U < chCycle) + { + wPreLinkID = pLinkSeq->szLinkId[chCycle - 1U]; /*ǰlinkһlink*/ + } + else + { + wPreLinkID = 0U; + } + + /*жϷ仯*/ + cCurLinkDirChanged = GetLinkLogicDirChangedById(currentLinkID); + cPreLinkDirChanged = GetLinkLogicDirChangedById(wPreLinkID); + if (((LINK_DIRCHANGE_BEGIN == cPreLinkDirChanged) || (LINK_DIRCHANGE_END == cPreLinkDirChanged)) + && (cPreLinkDirChanged == cCurLinkDirChanged)) + { + /*ڷ仯*/ + cQueryDir = ~cQueryDir; + } + else + { + /*ڷ仯㣬*/ + } + + /* ȡǰlink˵Ϣ */ + + chFunRtn = GetLinkPointInfo(cQueryDir, pLinkSeq->szLinkId[chCycle], &pathTree); + + if ((chCycle == cTmpIndex) && (CI_SUCCESS == chFunRtn)) + { + /*òѯɹ*/ + chRtn = CI_SUCCESS; + } + else if ((chCycle != cTmpIndex) && (CI_SUCCESS == chFunRtn)) + { + if (EMAP_POINT_DOT == pathTree.wPointType) + { + nextLinkID = pLinkSeq->szLinkId[chCycle + 1U]; + chFunRtn = dsuSwitchStatusBtwLink(pathTree.wPointId, currentLinkID, nextLinkID, &exStatus); + + if (CI_ERROR == chFunRtn) + { + /*ѯ󣬷*/ + chBreakRtn = FLAG_SET; + } + else + { + pSwInfo->SwitchInfo[pSwInfo->SwitchNum].pointID = pathTree.wPointId; + pSwInfo->SwitchInfo[pSwInfo->SwitchNum].status = exStatus; + pSwInfo->SwitchNum++; + } + + } + else + { + /*ѯ*/ + } + + /*òѯɹ*/ + chRtn = CI_SUCCESS; + } + else + { + /*ѯʧܣ*/ + chBreakRtn = FLAG_SET; + } + + if (FLAG_SET == chBreakRtn) + { + chRtn = CI_ERROR; + break; + } + else + { + } + } + + if (CI_SUCCESS == chRtn) + { + /*ѯɹ*/ + } + else + { + /*ѯɹ*/ + (void)CommonMemSet(pSwInfo, (UINT32)sizeof(str_PointInArea), 0u, (UINT32)sizeof(str_PointInArea)); + } + } + + return chRtn; +} + +/** +* @brief ȡ߼ +* @param struct_PathPoint strPoint +* @return ߼ID +* @note жϵ㴦߼ʱж߼еλãҵ߼ +*/ +UINT16 GetPointBelongLogSec(struct_PathPoint strPoint) +{ + UINT16 wLogicSum = 0u; + UINT16 wLogicId = 0u; + UINT16 wIndex = 0u; + UINT16 wLinkNum = 0U; + str_Zone strZone = { 0u }; + UINT16 wOrgnLink = 0u; + UINT16 wTmanLink = 0u; + UINT32 dwOrgnOffset = UINT32_MAX; + UINT32 dwTmnlOffset = UINT32_MAX; + UINT32 dwLen = UINT32_MAX; + LOD_STRU strPointA = { 0u }; + LOD_STRU strPointB = { 0u }; + UINT8 chFunRtn = CI_ERROR; + UINT16 wRtn = 0u; + str_PointInArea strSwitchInfo = { 0u }; + UINT8 chSwitchIndex = 0u; + UINT8 chSwitchPos = 0u; + UINT16 wszLogicIdBuf[PHYSICAL_INCLUDE_LOG_SUM_MAX * 2U] = { 0U }; + + + + chFunRtn = CheckLinkValid(strPoint.wLinkId, strPoint.dwOffset); + + if (CI_SUCCESS == chFunRtn) + { + chFunRtn = GetLinkRelLgcId(1, &strPoint.wLinkId, &wLogicSum, wszLogicIdBuf); + } + else + { + ; /* DO NOTHING */ + } + + if (CI_SUCCESS == chFunRtn) + { + for (wIndex = 0u; wIndex < wLogicSum; wIndex++) + { + wLogicId = wszLogicIdBuf[wIndex]; + strZone.pStart.wLinkId = GetLgcSecOrgnLink(wLogicId); + strZone.pStart.dwOffset = GetLgcSecOrgnOffset(wLogicId); + strZone.pEnd.wLinkId = GetLgcSecTmnlLink(wLogicId); + strZone.pEnd.dwOffset = GetLgcSecTmnlOffset(wLogicId); + strPointA.Lnk = strZone.pStart.wLinkId; + strPointA.Off = strZone.pStart.dwOffset; + strPointB.Lnk = strZone.pEnd.wLinkId; + strPointB.Off = strZone.pEnd.dwOffset; + dwLen = dsuLenByPoint(&strPointA, &strPointB, &wLinkNum, strZone.pLinkSeq.szLinkId, &strZone.Dir); + /*ᳬUINT8_MAX*/ + strZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + if (UINT32_MAX != dwLen) + { + chFunRtn = IsPointInPath(strPoint, strZone); + if (CI_ERROR == chFunRtn) + { + chFunRtn = dsuSwitchInfoBtwLinkBaseLinkSeq(strZone.pStart.wLinkId, strZone.pEnd.wLinkId, strZone.Dir, &strZone.pLinkSeq, &strSwitchInfo); + if (CI_SUCCESS == chFunRtn) + { + for (chSwitchIndex = 0u; chSwitchIndex < strSwitchInfo.SwitchNum; chSwitchIndex++) + { + chSwitchPos = GetSwitchCurPosition(strSwitchInfo.SwitchInfo[chSwitchIndex].pointID); + if (chSwitchPos != strSwitchInfo.SwitchInfo[chSwitchIndex].status) + { + break; + } + } + + if (chSwitchIndex == strSwitchInfo.SwitchNum) + { + wRtn = wLogicId; + break; + } + } + } + } + } + } + else + { + ; + } + return wRtn; +} + +/** +* @brief ȡ߼ +* @param struct_PathPoint strPoint +* @return ߼ID +*/ +UINT8 GetLogSecBtwTwoPoints(struct_PathPoint strStart, struct_PathPoint strEnd, UINT16 * pLogSecNum, UINT16 szLogId[]) +{ + UINT16 wLogicSum = 0u; + UINT16 wLogicId = 0u; + UINT16 wIndex = 0u; + str_Zone strZone = { 0u }; + UINT16 wOrgnLink = 0u; + UINT16 wTmanLink = 0u; + UINT32 dwOrgnOffset = UINT32_MAX; + UINT32 dwTmnlOffset = UINT32_MAX; + UINT32 dwLen = UINT32_MAX; + LOD_STRU strPointA = { 0u }; + LOD_STRU strPointB = { 0u }; + UINT8 chFunRtn = CI_ERROR; + UINT16 wRtn = 0u; + struct_PathPoint strOrgn = { 0u }; + struct_PathPoint strTmnl = { 0u }; + UINT16 wNum = 0u; + str_Zone strZoneLgc = { 0u }; + UINT16 wLink = 0u; + UINT8 chLinkNum = 0u; + UINT16 wSwitchId = 0u; + UINT8 chEstatus = 0u; + UINT8 chSwitchPos = 0u; + UINT16 wLinkNum = 0u; + UINT8 chLgcSwPosCheckFlag = CI_ERROR; /* ߼εͨ־ */ + UINT16 wLogicIdBuf[PHYSICAL_INCLUDE_LOG_SUM_MAX * 2U] = { 0U }; + UINT16 wPrePhyId = 0u; + UINT16 wCurPhyId = 0u; + UINT8 chLgcSwIndex = 0u; + UINT8 chLgcSwNum = 0u; + LogsecSwitchStruct * pLgcSwInfo = NULL; + UINT16 wTmpLgcNum = 0u; + UINT8 chFitSwNum = 0u; + UINT8 chMaxFitSwNum = 0u; + UINT8 chSwCurPos = 0u; + + + /* μ */ + if ((NULL == pLogSecNum) || (NULL == szLogId)) + { + chFunRtn = CI_ERROR; + } + else + { + chFunRtn = CheckLinkValid(strStart.wLinkId, strStart.dwOffset); + chFunRtn &= CheckLinkValid(strEnd.wLinkId, strEnd.dwOffset); + } + + /* гռѹ */ + if (CI_SUCCESS == chFunRtn) + { + strZone.pStart.wLinkId = strStart.wLinkId; + strZone.pStart.dwOffset = strStart.dwOffset; + strZone.pEnd.wLinkId = strEnd.wLinkId; + strZone.pEnd.dwOffset = strEnd.dwOffset; + strPointA.Lnk = strZone.pStart.wLinkId; + strPointA.Off = strZone.pStart.dwOffset; + strPointB.Lnk = strZone.pEnd.wLinkId; + strPointB.Off = strZone.pEnd.dwOffset; + dwLen = dsuLenByPoint(&strPointA, &strPointB, &wLinkNum, strZone.pLinkSeq.szLinkId, &strZone.Dir); + strZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + if (UINT32_MAX != dwLen) + { + chFunRtn = GetLinkRelLgcId(strZone.pLinkSeq.cLinkCnt, strZone.pLinkSeq.szLinkId,&wLogicSum, wLogicIdBuf); + } + else + { + chFunRtn = CI_ERROR; + } + } + else + { + ; + } + + /* Ѱ߼ */ + if (CI_SUCCESS == chFunRtn) + { + for (wIndex = 0u; wIndex < wLogicSum; wIndex++) + {/* ߼ */ + wLogicId = wLogicIdBuf[wIndex]; + wCurPhyId = GetLgcSecRelativePhySecId(wLogicId); + if (wCurPhyId != wPrePhyId) + { + wTmpLgcNum = wNum; + chMaxFitSwNum = 0u; + } + else + { + ; /* do nothing */ + } + strOrgn.wLinkId = GetLgcSecOrgnLink(wLogicId); + strOrgn.dwOffset = GetLgcSecOrgnOffset(wLogicId); + strTmnl.wLinkId = GetLgcSecTmnlLink(wLogicId); + strTmnl.dwOffset = GetLgcSecTmnlOffset(wLogicId); + chFunRtn = CheckLinkValid(strOrgn.wLinkId, strOrgn.dwOffset); + chFunRtn &= CheckLinkValid(strTmnl.wLinkId, strTmnl.dwOffset); + chFitSwNum = 0u; + if (CI_ERROR == chFunRtn) + { + break; + } + /* ȡ߼ */ + strZoneLgc.pStart.wLinkId = strOrgn.wLinkId; + strZoneLgc.pStart.dwOffset = strOrgn.dwOffset; + strZoneLgc.pEnd.wLinkId = strTmnl.wLinkId; + strZoneLgc.pEnd.dwOffset = strTmnl.dwOffset; + strPointA.Lnk = strZoneLgc.pStart.wLinkId; + strPointA.Off = strZoneLgc.pStart.dwOffset; + strPointB.Lnk = strZoneLgc.pEnd.wLinkId; + strPointB.Off = strZoneLgc.pEnd.dwOffset; + dwLen = dsuLenByPoint(&strPointA, &strPointB, &wLinkNum, strZoneLgc.pLinkSeq.szLinkId, &strZoneLgc.Dir); + strZoneLgc.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + if (UINT32_MAX != dwLen) + { + ; + } + else + { + chFunRtn = CI_ERROR; + } + + if (CI_SUCCESS == chFunRtn) + {/* ߼γɵǷཻ */ + chFunRtn = CheckZoneIsCrossing(&strZone, &strZoneLgc); + if (CI_ERROR == chFunRtn) + {/* ཻ */ + chFunRtn = CI_SUCCESS; + chLinkNum = GetSecIntrudeLinkSum(wLogicId); + chLgcSwPosCheckFlag = IsLgcNeedCheckSwitchPos(wLogicId, strZone); + chLgcSwNum = GetLogicSecSwitchSum(wLogicId); + pLgcSwInfo = GetLogicSecSwitchIdStru(wLogicId); + if ((chLinkNum > 1u) && (CI_SUCCESS == chLgcSwPosCheckFlag)) + {/* ߼βֻһlink */ + for (chLgcSwIndex = 0u; chLgcSwIndex < chLgcSwNum; chLgcSwIndex++) + { + chSwCurPos = GetSwitchCurPosition(pLgcSwInfo[chLgcSwIndex].SwitchId); + if (((SWITCH_POSITION_DINGWEI == chSwCurPos) || (SWITCH_POSITION_FANWEI == chSwCurPos)) + && (chSwCurPos != pLgcSwInfo[chLgcSwIndex].SwitchPosition)) + { + chFunRtn = CI_ERROR; + } + else + { + ; /* do nothing */ + } + } + } + else + { + chFunRtn = CI_SUCCESS; + } + if ((chLinkNum > 1u) && (CI_ERROR == chLgcSwPosCheckFlag)) + { + for (chLgcSwIndex = 0u; chLgcSwIndex < chLgcSwNum; chLgcSwIndex++) + { + chSwCurPos = GetSwitchCurPosition(pLgcSwInfo[chLgcSwIndex].SwitchId); + if ((chSwCurPos == pLgcSwInfo[chLgcSwIndex].SwitchPosition) + || ((SWITCH_POSITION_DINGWEI != chSwCurPos) && (SWITCH_POSITION_FANWEI != chSwCurPos))) + { + chFitSwNum++; + } + else + { + ; /* do nothing */ + } + } + if (chFitSwNum == chLgcSwNum) + {/* неλ */ + chFitSwNum = (UINT8)LOGSEC_INCLUDE_SWITCH_SUM_MAX + 1u; + } + else + { + ; /* do nothing */ + } + if (chFitSwNum > chMaxFitSwNum) + { + chMaxFitSwNum = chFitSwNum; + szLogId[wTmpLgcNum] = wLogicId; + wNum = wTmpLgcNum + 1u; + } + else if (chFitSwNum == chMaxFitSwNum) + { + szLogId[wNum++] = wLogicId; + } + else + { + ; /* do nothing */ + } + } + else + { + if (CI_SUCCESS == chFunRtn) + { + if (SIZE_MAX_SECTION_INAC > wNum) + { + szLogId[wNum++] = wLogicId; + } + } + else + { + ; /* do nothing */ + } + } + chFunRtn = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; + } + wPrePhyId = wCurPhyId; + } + (*pLogSecNum) = wNum; + } + else + { + ; + } + + + + return chFunRtn; +} + +/** +* @brief жǷཻ +* @param p_StrZone pZoneA +* @param p_StrZone pZoneB +* @return CI_ERROR ཻ CI_SUCCESS ཻ +*/ +UINT8 CheckZoneIsCrossing(p_StrZone pZoneA, p_StrZone pZoneB) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 chFunRtnA = CI_ERROR; + UINT8 chFunRtnB = CI_ERROR; + UINT8 chFunRtnC = CI_ERROR; + UINT8 chFunRtnD = CI_ERROR; + UINT16 wLinkId = 0u; + UINT8 i = 0u; + UINT8 j = 0u; + UINT8 cDir = DIR_INVALID; + struct_PathPoint strAStartPoint = { 0u }; + struct_PathPoint strAEndPoint = { 0u }; + struct_PathPoint strBStartPoint = { 0u }; + struct_PathPoint strBEndPoint = { 0u }; + LinkDataConfigStru * pLink = NULL; + + if ((NULL != pZoneA) && (NULL != pZoneB) + && (0u != pZoneA->pLinkSeq.cLinkCnt) && (0u != pZoneB->pLinkSeq.cLinkCnt)) + { + for (i = 0u; i < pZoneA->pLinkSeq.cLinkCnt; i++) + { + for (j = 0u; j < pZoneB->pLinkSeq.cLinkCnt; j++) + { + if (pZoneA->pLinkSeq.szLinkId[i] == pZoneB->pLinkSeq.szLinkId[j]) + { + break; + } + else + { + ; + } + } + + if (j != pZoneB->pLinkSeq.cLinkCnt) + { + break; + } + } + + if (i == pZoneA->pLinkSeq.cLinkCnt) + { + cRetVal = CI_SUCCESS;/* ཻ */ + } + else + { + wLinkId = pZoneA->pLinkSeq.szLinkId[i]; + pLink = GetLinkDataById(wLinkId); + + /* ȡlinkϵռѹ */ + chFunRtnA = dsuZoneStartEndPointInLink(pZoneA, wLinkId, &strAStartPoint, &strAEndPoint); + chFunRtnA &= dsuZoneStartEndPointInLink(pZoneB, wLinkId, &strBStartPoint, &strBEndPoint); + + if (CI_ERROR == chFunRtnA) + { + /* ѯʧ·ཻ */ + cRetVal = CI_ERROR; + } + else + { + cDir = (DIR_SAME == pLink->wLinkLine) ? DIR_SAME : DIR_CONVERT; + + chFunRtnA = dsuJudgeLinkAandLinkBPosition(&strAStartPoint, &strBStartPoint, cDir); + chFunRtnB = dsuJudgeLinkAandLinkBPosition(&strAStartPoint, &strBEndPoint, cDir); + chFunRtnC = dsuJudgeLinkAandLinkBPosition(&strAEndPoint, &strBStartPoint, cDir); + chFunRtnD = dsuJudgeLinkAandLinkBPosition(&strAEndPoint, &strBEndPoint, cDir); + + if ((CI_ERROR == chFunRtnA) || (CI_ERROR == chFunRtnB) || (CI_ERROR == chFunRtnC) || (CI_ERROR == chFunRtnD)) + { + /* ʧܣȫ */ + cRetVal = CI_ERROR; + } + else if ((CI_SUCCESS == chFunRtnA) || (CI_SUCCESS == chFunRtnB) || (CI_SUCCESS == chFunRtnC) || (CI_SUCCESS == chFunRtnD)) + { + /* ڽ */ + cRetVal = CI_ERROR; + } + else if ((chFunRtnA == chFunRtnB) && (chFunRtnB == chFunRtnC) && (chFunRtnC == chFunRtnD)) + { + /* ûн */ + cRetVal = CI_SUCCESS; + } + else + { + /* ڽ */ + cRetVal = CI_ERROR; + } + } + } + + } + else + { + ; + } + return cRetVal; +} + +/** +* @brief жϵǷڱ +* @param wLink +* @param dwOffset +* @return CI_ERROR ڱ CI_SUCCESS ڱ +* @note ޸BUG YF0083-130 +*/ +UINT8 IsPointManaged(const UINT16 wLink, const UINT32 dwOffset) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chLocalId = 0u; + UINT16 wLinkTioc = 0u; + UINT8 checkResult = CI_ERROR; + + /* ޸BUG YF0083-130*/ + /** УlinkIDƫǷЧ*/ + checkResult = CheckLinkValid(wLink, dwOffset); + /** ȡǰID*/ + chLocalId = GetSystemParaLocalCiId(); + /** УЧ*/ + if (CI_ERROR == checkResult) + { + /* úгעlink IDƫЧʱӦע˷صڱ*/ + chRtn = CI_ERROR; + } + else + { + /** УЧȡlinkID*/ + wLinkTioc = GetLinkManageTiocById(wLink); + if (chLocalId == wLinkTioc) + { + /** ڱ*/ + chRtn = CI_ERROR; + } + else + { + /** 㲻ڱ*/ + chRtn = CI_SUCCESS; + } + } + + return chRtn; +} + +/** +* @brief жLINKǷΪ߻ѹ +* @param linkId +* @return CI_SUCCESS:linkΪ߻ѹ죻CI_ERROR:linkΪ߻ѹ +*/ +UINT8 IsLinkSwTrack(const UINT16 linkId) +{ + UINT8 rtnValue = CI_ERROR; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + if (LINK_SW_TRACK_YES == g_szLinkConfigData[index].chSwTrack) + { + rtnValue = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; /*id */ + } + + return rtnValue; +} + + +/** +* @brief жLINKǷΪ۷ +* @param linkId +* @return CI_SUCCESS:linkΪ۷CI_ERROR:linkΪ۷ +*/ +extern UINT8 IsLinkRevertArea(const UINT16 linkId) +{ + UINT8 rtnValue = CI_ERROR; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + if (LINK_REVERT_AREA_YES == g_szLinkConfigData[index].chRevertArea) + { + rtnValue = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief ȡLINKͣ +* @param linkId +* @return LINKͣ +*/ +UINT16 GetLinkStopAreaId(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wStopAreaId; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/********************************************* +ܣȡзϵλеһ +szAxisId ׵ַwAxisNum wAxisNum + + +ֵ0ʧܣ AxisIDɹ +**********************************************/ +UINT16 GetAxisIdFromAxisSeqSafeSw(UINT16* szAxisId, UINT16 wAxisNum) +{ + /*ʼ*/ + UINT8 chAxisSwitchIdSum = 0U; + AxisSwitchStruct *pAxisSwitchIdBuf = NULL; + UINT16 wAxisBelongPhyId = 0U; + UINT16 wFirstAxisBelongPhyId = 0U; + UINT16 wRetAxisId = 0U; + UINT8 chSwitchCurPos = 0U; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 chCycFlag = 0U; + UINT8 chKeepWork = CI_ERROR; + + if ((NULL == szAxisId) || (0U == wAxisNum) || (AC_MAXCNT_IN_SWITCH < wAxisNum)) + { + /*μʧ*/ + chKeepWork = CI_ERROR; + } + else + { + /*μɹ*/ + chKeepWork = CI_SUCCESS; + } + + if (CI_SUCCESS == chKeepWork) + { + chCycFlag = CI_SUCCESS; + wFirstAxisBelongPhyId = GetAxisSecRelativePhySecId(szAxisId[0]); + for (ii = 0U; ii < wAxisNum; ii++) + { + wAxisBelongPhyId = GetAxisSecRelativePhySecId(szAxisId[ii]); + if (wFirstAxisBelongPhyId == wAxisBelongPhyId) + { + chAxisSwitchIdSum = GetAxisSwitchSum(szAxisId[ii]); + pAxisSwitchIdBuf = GetAxisSwitchIdStru(szAxisId[ii]); + + if (0U != chAxisSwitchIdSum) + { + for (jj = 0U; jj < chAxisSwitchIdSum; jj++) + { + chSwitchCurPos = GetSwitchCurPosition(pAxisSwitchIdBuf[jj].SwitchId); + + if (((SWITCH_POSITION_DINGWEI == chSwitchCurPos) || (SWITCH_POSITION_FANWEI == chSwitchCurPos)) + && (chSwitchCurPos == pAxisSwitchIdBuf[jj].SwitchPosition)) + { + + } + else + { + break; + } + } + if (jj == chAxisSwitchIdSum) + { + wRetAxisId = szAxisId[ii]; + chCycFlag = CI_ERROR; + } + } + else + { + wRetAxisId = szAxisId[0]; + } + } + else + { + chCycFlag = CI_ERROR; + chKeepWork = CI_ERROR; + } + + if (CI_SUCCESS != chCycFlag) + { + break; + } + else + { + /*DO NOTHING*/ + } + } + } + + if (CI_SUCCESS == chKeepWork) + { + ; /*DO NOTHING*/ + } + else + { + wRetAxisId = 0U; + } + + return wRetAxisId; +} + +/** +* @brief ȡ +* @param wLinkId +* @param dwLinkOffset +* @return +*/ +UINT32 GetPointKm(UINT16 wLinkId, UINT32 dwLinkOffset) +{ + UINT32 rtnValue = UINT32_MAX; + UINT32 dwLinkLen = UINT32_MAX; + UINT16 wOrgnLinkId = 0u; + UINT16 wOrgnLinkType = 0u; + UINT16 wOrgnPointType = 0u; + UINT16 wTmnlPointType = 0u; + + wOrgnPointType = GetLinkOrgnPointTypeById(wLinkId); /* ȡlink˵ */ + wTmnlPointType = GetLinkTmnlPointTypeById(wLinkId); /* ȡlinkյ˵ */ + dwLinkLen = GetLinkLengthById(wLinkId); + + if ((dwLinkOffset <= dwLinkLen) && (UINT32_MAX != dwLinkLen)) + { + if (EMAP_END_DOT != wOrgnPointType) + {/* linkʼ˲Ϊ·ն */ + if (EMAP_AXLE_DOT == wOrgnPointType) + {/* ʼΪ */ + rtnValue = GetAxisKmById(GetLinkOrgnPointIdById(wLinkId)); + } + else if (EMAP_POINT_DOT == wOrgnPointType) + {/* ʼΪ */ + rtnValue = GetSwitchKmById(GetLinkOrgnPointIdById(wLinkId)); + } + else + { + ; /* ʹ󣬲ܷ֧ */ + } + + if (UINT32_MAX != rtnValue) + { + rtnValue += dwLinkOffset; + } + else + { + ; /* */ + } + } + else if (EMAP_END_DOT != wTmnlPointType) + {/* linkն˲Ϊ·ն */ + if (EMAP_AXLE_DOT == wTmnlPointType) + {/* ʼΪ */ + rtnValue = GetAxisKmById(GetLinkTmnlPointTypeById(wLinkId)); + } + else if (EMAP_POINT_DOT == wTmnlPointType) + {/* նΪ */ + rtnValue = GetSwitchKmById(GetLinkTmnlPointTypeById(wLinkId)); + } + else + { + ; /* ʹ󣬲ܷ֧ */ + } + + rtnValue = GetAxisKmById(GetLinkTmnlPointIdById(wLinkId)); + if (UINT32_MAX != rtnValue) + { + rtnValue = rtnValue - (dwLinkLen - dwLinkOffset); + } + else + { + ; + } + } + else + { + ; /*DO NOTHING rtn invalid value*/ + } + } + else + { + ; /*DO NOTHING rtn invalid value*/ + } + + return rtnValue; +} + +/** +* @brief жLINKǷΪվ̨ +* @param linkId +* @return CI_SUCCESS:linkΪվ̨CI_ERROR:linkΪվ̨ +*/ +UINT8 IsLinkPlatform(const UINT16 linkId) +{ + UINT8 rtnValue = CI_ERROR; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + if (LINK_PLATFORM_YES == g_szLinkConfigData[index].chPlatform) + { + rtnValue = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief ȡ߼ +* @param struct_PathPoint strPoint +* @param UINT16 * pLgcIdBuf ߼ID +* @return ߼ +* @note +*/ +UINT8 GetPointBelongLogSecEx(struct_PathPoint strPoint, UINT16 * pLgcIdBuf) +{ + UINT16 wLogicSum = 0u; + UINT16 wLogicId = 0u; + UINT16 wIndex = 0u; + UINT16 wLinkNum = 0U; + str_Zone strZone = { 0u }; + UINT16 wOrgnLink = 0u; + UINT16 wTmanLink = 0u; + UINT32 dwOrgnOffset = UINT32_MAX; + UINT32 dwTmnlOffset = UINT32_MAX; + UINT32 dwLen = UINT32_MAX; + LOD_STRU strPointA = { 0u }; + LOD_STRU strPointB = { 0u }; + UINT8 chFunRtn = CI_ERROR; + UINT8 chRtn = 0u; + UINT16 wszLogicIdBuf[PHYSICAL_INCLUDE_LOG_SUM_MAX * 2U] = { 0U }; + + + chFunRtn = CheckLinkValid(strPoint.wLinkId, strPoint.dwOffset); + + if (CI_SUCCESS == chFunRtn) + { + chFunRtn = GetLinkRelLgcId(1, &strPoint.wLinkId, &wLogicSum, wszLogicIdBuf); + } + else + { + ; /* DO NOTHING */ + } + if ((CI_SUCCESS == chFunRtn) && (NULL != pLgcIdBuf)) + { + for (wIndex = 0u; wIndex < wLogicSum; wIndex++) + { + wLogicId = wszLogicIdBuf[wIndex]; + strZone.pStart.wLinkId = GetLgcSecOrgnLink(wLogicId); + strZone.pStart.dwOffset = GetLgcSecOrgnOffset(wLogicId); + strZone.pEnd.wLinkId = GetLgcSecTmnlLink(wLogicId); + strZone.pEnd.dwOffset = GetLgcSecTmnlOffset(wLogicId); + strPointA.Lnk = strZone.pStart.wLinkId; + strPointA.Off = strZone.pStart.dwOffset; + strPointB.Lnk = strZone.pEnd.wLinkId; + strPointB.Off = strZone.pEnd.dwOffset; + dwLen = dsuLenByPoint(&strPointA, &strPointB, &wLinkNum, strZone.pLinkSeq.szLinkId, &strZone.Dir); + /*ᳬUINT8_MAX*/ + strZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + if (UINT32_MAX != dwLen) + { + chFunRtn = IsPointInPath(strPoint, strZone); + if (CI_ERROR == chFunRtn) + {/* ¼߼ */ + pLgcIdBuf[chRtn++] = wLogicId; + } + else + { + ; + } + } + else + {/* ѯʧܣ */ + chRtn = 0u; + break; + } + } + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡlink߼վ̨ +* @param linkId +* @return link߼վ̨;0:linkΪվ̨ +*/ +UINT16 GetLinkPlatfrm(const UINT16 linkId) +{ + UINT16 rtnValue = 0u; + UINT16 index = 0u; + + index = GetLinkIndexById(linkId); + if (UINT16_MAX != index) + { + rtnValue = g_szLinkConfigData[index].wPlatformId; + } + else + { + ; /*id */ + } + + return rtnValue; +} + +/** +* @brief ȡATS߼վ̨tioc +* @param const UINT16 wLgcStation +* @return ATS߼վ̨tioc +* @note +*/ +UINT16 GetAtsLgcStationBelongTioc(const UINT16 wLgcStation) +{ + UINT16 wTiocId = 0u; + UINT16 wLinkIndex = 0u; + UINT16 wLinkPltfrm = 0u; + + for (wLinkIndex = 0u; wLinkIndex < LINK_SUM_MAX; wLinkIndex++) + { + if (g_szLinkConfigData[wLinkIndex].wPlatformId == wLgcStation) + { + wTiocId = g_szLinkConfigData[wLinkIndex].wManageTioc; + break; + } + else + { + ; + } + } + return wTiocId; +} + +/** +* @brief ȡվ̨Link +* @param const UINT16 wLgcStation +* @return վ̨Link +* @note +*/ +UINT16 GetLinkIDBelongPlatForm(const UINT16 wPlatform) +{ + UINT16 wLinkId = 0u; + UINT16 wLinkIndex = 0u; + UINT16 wLinkNum = 0u; + UINT16 wLinkPltfrm = 0u; + wLinkNum = GetLinkNum(); + for (wLinkIndex = 0u; wLinkIndex < wLinkNum; wLinkIndex++) + { + if (g_szLinkConfigData[wLinkIndex].wBelongPlatformId == wPlatform) + { + wLinkId = g_szLinkConfigData[wLinkIndex].wId; + break; + } + else + { + ; + } + } + return wLinkId; +} +/** +* @brief жLINKǷ +* @param const UINT16 wLinkId link +* @return CI_ERROR:linkCI_SUCCESS:linkδ +* @note +*/ +UINT8 IsLinkFlock(const UINT16 wLinkId) +{ + UINT8 chRtn = CI_ERROR; + UINT16 wPhyId = 0u; + UINT8 chFlock = 0u; + wPhyId = GetLinkRelatedPhySec(wLinkId); + chFlock = GetPhySecFLockState(wPhyId); + if (PHYSICAL_SECTION_FLOCK_NO == chFlock) + { + chRtn = CI_SUCCESS; + } + else + { + chRtn = CI_ERROR; + } + return chRtn; +} + +/** +* @brief ӪתΪ߼ +* @param const UINT8 chDir Ӫ +* @return DIR_SAME:link߼ͬ + DIR_CONVERT:link߼෴ + DIR_INVALID:Ч +* @note +*/ +UINT8 ConvertDirectionToLogic(const UINT8 chDir) +{ + UINT8 chLinkLogicDirUpAndDown = 0U; + UINT8 chRtn = DIR_INVALID; + if ((CI_SYSTEM_DIRECTION_UP == chDir) || (CI_SYSTEM_DIRECTION_DOWN == chDir)) + { + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + if (chLinkLogicDirUpAndDown == chDir) + { + chRtn = DIR_CONVERT; + } + else + { + chRtn = DIR_SAME; + } + } + else + {/* */ + chRtn = DIR_INVALID; + } + return chRtn; +} + +/** +* @brief ߼תΪӪ +* @param const UINT8 chDir ߼ +* @return 0x55: +* 0xaa: +* 0xff:Ч +*/ +UINT8 ConvertLogicDirToRun(const UINT8 chDir) +{ + UINT8 chLinkLogicDirUpAndDown = 0U; + UINT8 chRtn = CI_SYSTEM_DIRECTION_NONE; + + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + + if (((DIR_CONVERT == chDir) || (DIR_SAME == chDir)) && ((0x55U == chLinkLogicDirUpAndDown) || (0xaaU == chLinkLogicDirUpAndDown))) + { + if (DIR_CONVERT == chDir) + { + chRtn = chLinkLogicDirUpAndDown; + } + else + { + chRtn = ~chLinkLogicDirUpAndDown; + } + } + else + { + chRtn = CI_SYSTEM_DIRECTION_NONE; /*󣬷Ч*/ + } + + return chRtn; +} + +/* +* ǰ߼ȡ +* ˵ +* const UINT8 chTrainDir гз +* ֵ ȡз +*/ +UINT8 ConvertTrainDir(UINT8 chTrainDir) +{ + UINT8 retval = 0u; + if (DIR_CONVERT == chTrainDir) + { + retval = DIR_SAME; + } + else if (DIR_SAME == chTrainDir) + { + retval = DIR_CONVERT; + } + else + { + retval = DIR_INVALID; + } + return retval; +} + +/** +* @brief жгռѹ߼УǷҪж߼ελ +* @param const UINT16 wLgcId ߼ID +* @param const str_Zone strZone гռѹ +* @return CI_ERROR:ҪλãCI_SUCCESS:Ҫ +* @note +*/ +static UINT8 IsLgcNeedCheckSwitchPos(const UINT16 wLgcId, const str_Zone strZone) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chLgcSwitchNum = 0u; + LogsecSwitchStruct * pLgcSwitchInfo = NULL; + UINT8 chSwitchIndex = 0u; + UINT8 chLinkIndex = 0u; + UINT8 chLinkType = SW_DEFAUT_LINK; + UINT8 chFunRtn = CI_ERROR; + chLgcSwitchNum = GetLogicSecSwitchSum(wLgcId); + pLgcSwitchInfo = GetLogicSecSwitchIdStru(wLgcId); + if ((0u == chLgcSwitchNum) || (NULL == pLgcSwitchInfo)) + { + ; /* ߼βȡʧܣλ */ + } + else + { + for (chSwitchIndex = 0u; chSwitchIndex < chLgcSwitchNum; chSwitchIndex++) + {/* ߼ΰ */ + for (chLinkIndex = 0u; chLinkIndex < strZone.pLinkSeq.cLinkCnt; chLinkIndex++) + {/* link */ + chFunRtn = dsuLinkofSwitchPos(strZone.pLinkSeq.szLinkId[chLinkIndex], pLgcSwitchInfo[chSwitchIndex].SwitchId, &chLinkType); + + if ((CI_SUCCESS == chFunRtn) && ((UINT8)SW_CON_LINK == chLinkType)) + {/* ߼εlinkҪλ */ + chRtn = CI_SUCCESS; + break; + } + else + { + ; /* */ + } + } + if (CI_SUCCESS == chRtn) + { + break; + } + else + { + ; /* */ + } + } + } + return chRtn; +} + +/** +* @brief ݷ仯ת־ת +* @param UINT8 wFlag 任־λ +* @param UINT8 wPointDir ѯ +* @param UINT8* wPointCnt 任Σ +* @return 任ķ +*/ +UINT8 TransDirectionPointDir(UINT8 wFlag, UINT8 wPointDir, UINT8* wPointCnt) +{ + UINT8 reVal = 0U; + + if (((DIRECTIONPOINT_FLAG_VALID != wFlag) && (DIRECTIONPOINT_FLAG_INVALID != wFlag)) + || ((DIR_CONVERT != wPointDir) && (DIR_SAME != wPointDir)) || (NULL == wPointCnt)) + { + /*η*/ + } + else + { + if (DIRECTIONPOINT_FLAG_VALID == wFlag) + { + switch (wPointDir) + { + case DIR_CONVERT: + reVal = DIR_SAME; + break; + case DIR_SAME: + reVal = DIR_CONVERT; + break; + default: + /*ɴ֧*/ + break; + } + (*wPointCnt)++; + } + else + { + reVal = wPointDir; /*޷任־άԭз*/ + } + } + + return reVal; +} + +/** +* @brief ж㷽Ƿͬ(гͬ򡢶ʻж) +* @param[in] const LOD_STRU strPointA A +* @param[in] const LOD_STRU strPointB B +* @param[out] +* @return CI_ERROR:ʧܣFLAG_SET:ͬFLAG_UNSET: +*/ +UINT8 IsPointABSameDir(const LOD_STRU strPointA, const LOD_STRU strPointB) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chDirChangeNum = 0U; + UINT8 chDirChangeResult = 0U; + + /** ڲУ */ + chRtn = CheckLinkValid(strPointA.Lnk, strPointA.Off); + chRtn &= CheckLinkValid(strPointB.Lnk, strPointB.Off); + + if (CI_SUCCESS == chRtn) + { + chDirChangeNum = GetDirChangeNumBtwPoints(&(strPointA), &(strPointB)); + if (UINT8_MAX != chDirChangeNum) + { + /*ݷ仯÷ֵ*/ + chDirChangeResult = chDirChangeNum % 2U; + if (0U == chDirChangeResult) + { + /*ڻż仯*/ + chRtn = strPointA.Dir == strPointB.Dir? FLAG_SET : FLAG_UNSET; + } + else + { + /*仯*/ + chRtn = strPointA.Dir == strPointB.Dir ? FLAG_UNSET : FLAG_SET; + } + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /* 벻Ϸ */ + } + return chRtn; +} + +/* +* ݷ任żĻ +* ˵UINT8 Dir, +* UINT8 wChangeNum 任 +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 TransDirByChangeNum(UINT8 Dir, UINT8 wChangeNum) +{ + UINT8 wDirRevel = 0U; + + if (((DIR_CONVERT != Dir) && (DIR_SAME != Dir))||(UINT8_MAX == wChangeNum)) + { + /*η*/ + } + else + { + if (0U != (wChangeNum % 2U)) + { + wDirRevel = ~Dir; + } + else + { + wDirRevel = Dir; /*ż任㣬ת*/ + } + } + + return wDirRevel; +} + + +/* +* ѯվ̨linkⷽһ߼ + * @param[in] UINT16 wLinkId վ̨LinkID + * @param[in] UINT8 chDir ѯ + * @param[out] UINT16 * pLgcIdBuf ߼ID + * @return ߼UINT8_MAXʧܣ0·ն +*/ +UINT8 FindPlatFormLinkOutLog(UINT16 wLinkId, UINT8 chDir, UINT16 * pLgcIdBuf) +{ + UINT8 chRtn = UINT8_MAX; + struct_PathPoint strTmp = { 0u }; + UINT16 wSwitchId = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + if ((EMAP_SAME_DIR != chDir) && (EMAP_CONVER_DIR != chDir) && (NULL == pLgcIdBuf)) + { + ; /* μʧܣ0 */ + } + else + { + if (EMAP_SAME_DIR == chDir) /*վ̨linkⷽlink֮ڷ仯*/ + { + strTmp.wLinkId = FindAdjacentLinkIDSafe(wLinkId, EMAP_SAME_DIR, &wSwitchId, &cDirectionPointFlag); + if (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) + { + strTmp.dwOffset = GetLinkLengthById(strTmp.wLinkId) - 1u; + } + else + { + strTmp.dwOffset = 1u; + } + } + else + { + strTmp.wLinkId = FindAdjacentLinkIDSafe(wLinkId, EMAP_CONVER_DIR, &wSwitchId, &cDirectionPointFlag); + + if (DIRECTIONPOINT_FLAG_VALID == cDirectionPointFlag) + { + strTmp.dwOffset = 1u; + } + else + { + strTmp.dwOffset = GetLinkLengthById(strTmp.wLinkId) - 1u; + } + } + + /* ȡ߼ */ + if (0u == strTmp.wLinkId) + {/* ·ն˷0 */ + chRtn = 0u; + } + else if (UINT16_MAX == strTmp.wLinkId) + {/* ѯUINT8_MAX */ + chRtn = UINT8_MAX; + } + else + { + chRtn = GetPointBelongLogSecEx(strTmp, pLgcIdBuf); + if (0u == chRtn) + {/* ѯʧ */ + chRtn = UINT8_MAX; + } + else + { + ; + } + } + } + + return chRtn; +} + +/** +* @brief ȡlinkѹ켰ɢ· +* @param wLinkId +* @return 0 ʧ + >0 linkѹ켰ɢ· +* by cgh 20240105 +*/ +UINT8 GetLinkTgEvacuateDir(const UINT16 wLinkId) +{ + UINT8 chRtnValue = CI_ERROR; + UINT16 wIndex = 0U; + + wIndex = GetLinkIndexById(wLinkId); + + if ((0U < wIndex) && (LINK_SUM_MAX > wIndex)) + { + chRtnValue = g_szLinkConfigData[wIndex].chLinkTgEvacuateDir; + } + else + { + ; /*id */ + } + + return chRtnValue; +} + +/** +* @brief ȡlink ߼ +* @param IN UINT16 *pLinkId linkID UINT8 linkNum link +* @param OUT UINT16 *pLgcSum ߼ +* @param OUT UINT16 pLgcIdBuf[SIZE_MAX_SECTION_BT_TRAIN] ߼ID +* @return CI_ERROR ʧ CI_SUCCESS ɹ +* @note +*/ +UINT8 GetLinkRelLgcId(UINT8 linkNum, UINT16 *pLinkId, UINT16 *pLgcSum, UINT16 *pLgcIdBuf) +{ + UINT8 chRetVal = CI_ERROR; /*ֵ*/ + UINT8 ii = 0U; /*ѭ*/ + UINT16 wPhySecId = 0U; + UINT16 wPrePhySecId = 0U; + UINT16 wPhyRelLgcSum = 0U; + UINT16 *wPhyRelLgcId = NULL; + UINT16 wAllLinkLgcSum = 0U; + UINT16 szAllLinkLgcIdBuf[PHYSICAL_INCLUDE_LOG_SUM_MAX*2U] = {0U}; /*ε߼*/ + if ((linkNum != 0U) + &&(pLgcSum!=NULL) + && (pLinkId !=NULL) + &&(pLgcIdBuf!=NULL)) + { + *pLgcSum = 0U; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + for (ii = 0U; ii < linkNum; ii++) + { + wPhySecId = GetLinkRelatedPhySec(pLinkId[ii]); + wPhyRelLgcSum = GetPhySecIncLogSecSum(wPhySecId); + wPhyRelLgcId = GetPhySecIncLogSecIdBuf(wPhySecId); + + if ((wPhyRelLgcSum > 0U)&&(wPhyRelLgcId!=NULL)) + { + if ((wAllLinkLgcSum + wPhyRelLgcSum) < (PHYSICAL_INCLUDE_LOG_SUM_MAX * 2U)) + { + if (wPhySecId != wPrePhySecId) + { + /*ȥأʹøúҪlinkд,һһ¼ɱ֤ظ*/ + (void)CommonMemCpy((void*)&szAllLinkLgcIdBuf[wAllLinkLgcSum], (UINT32)(sizeof(UINT16)*(PHYSICAL_INCLUDE_LOG_SUM_MAX * 2U - wAllLinkLgcSum)), (void *)wPhyRelLgcId, (UINT32)sizeof(UINT16)*wPhyRelLgcSum); + wAllLinkLgcSum += wPhyRelLgcSum; + wPrePhySecId = wPhySecId; + } + else + { + /*ִ*/ + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + if (CI_SUCCESS != chRetVal) + { + break; + } + + } + } + else + { + /* DO NOTHING */ + } + + if (CI_SUCCESS == chRetVal) + { + if (wAllLinkLgcSum < (PHYSICAL_INCLUDE_LOG_SUM_MAX * 2U)) + { + *pLgcSum = wAllLinkLgcSum; + (void)CommonMemCpy((void*)pLgcIdBuf, (UINT32)(sizeof(UINT16)*(PHYSICAL_INCLUDE_LOG_SUM_MAX * 2U)), (void *)szAllLinkLgcIdBuf, (UINT32)(sizeof(UINT16)*(PHYSICAL_INCLUDE_LOG_SUM_MAX * 2U))); + } + else + { + /* DO NOTHING */ + } + } + else + { + /* DO NOTHING */ + } + return chRetVal; +} + +/** +* @brief ȡзϵλм +* @param szAxisId ׵ַ + wAxisNum θ +* @param OUTchOutAxisSecSum ļĿ + szOutAxisSecIdBuf ļ +* @return ϵļĿ +* @note by cgh 20240514 +*/ +UINT8 GetAllAxisFromAxisSeqSafeSw(UINT16* szAxisId, UINT16 wAxisNum, UINT16* szOutAxisSecIdBuf) +{ + /*ʼ*/ + UINT8 chAxisSwitchIdSum = 0U; + AxisSwitchStruct* pAxisSwitchIdBuf = NULL; + UINT16 wAxisBelongPhyId = 0U; + UINT16 wFirstAxisBelongPhyId = 0U; + UINT8 chSwitchCurPos = 0U; + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 chKeepWork = CI_ERROR; + UINT16 szTempAxisIdBuf[AC_MAXCNT_IN_SWITCH] = { 0U };/*ʱID*/ + UINT8 chOutAxisSecSum = 0U;/*˹ϵļĿ*/ + + if ((NULL == szAxisId) || (0U == wAxisNum) || (AC_MAXCNT_IN_SWITCH < wAxisNum) || (NULL == szOutAxisSecIdBuf)) + { + ; /*Ŀ0*/ + } + else + { + wFirstAxisBelongPhyId = GetAxisSecRelativePhySecId(szAxisId[0]); + for (ii = 0U; ii < wAxisNum; ii++) + { + wAxisBelongPhyId = GetAxisSecRelativePhySecId(szAxisId[ii]); + if (wFirstAxisBelongPhyId == wAxisBelongPhyId) + { + chAxisSwitchIdSum = GetAxisSwitchSum(szAxisId[ii]); + pAxisSwitchIdBuf = GetAxisSwitchIdStru(szAxisId[ii]); + + if (0U != chAxisSwitchIdSum) + { + chKeepWork = CI_SUCCESS; + for (jj = 0U; jj < chAxisSwitchIdSum; jj++) + { + chSwitchCurPos = GetSwitchCurPosition(pAxisSwitchIdBuf[jj].SwitchId); + + if (((SWITCH_POSITION_DINGWEI == chSwitchCurPos) || (SWITCH_POSITION_FANWEI == chSwitchCurPos)) + && (chSwitchCurPos == pAxisSwitchIdBuf[jj].SwitchPosition)) + { + ; /**/ + } + else + { + /*һĵ*/ + break; + } + } + + if (jj == chAxisSwitchIdSum) + { + /**/ + szTempAxisIdBuf[chOutAxisSecSum] = szAxisId[ii]; + chOutAxisSecSum++; + } + } + else + { + /*ûеֱӼ*/ + szTempAxisIdBuf[chOutAxisSecSum] = szAxisId[ii]; + chOutAxisSecSum++; + } + } + else + { + ; /*ֻ*/ + } + } + /*FORѭѾȷ*/ + (void)CommonMemCpy((void*)szOutAxisSecIdBuf, (UINT32)(sizeof(UINT16) * (AC_MAXCNT_IN_SWITCH)), (void*)szTempAxisIdBuf, (UINT32)(sizeof(UINT16) * (AC_MAXCNT_IN_SWITCH))); + + } + + return chOutAxisSecSum; +} + +/** +* @brief жϳԱǷ +* @param const UINT16 wMem Աֵ +* @param const UINT8 chNum гԱ +* @param UINT16 * pSeq +* @return CI_ERROR:ԱڣCI_SUCCESS:Ա +*/ +UINT8 IsMenberOfSeq(const UINT16 wMem, const UINT8 chNum, UINT16 * pSeq) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + if ((0u != chNum) && (NULL != pSeq)) + { + for (chIndex = 0u; chIndex < chNum; chIndex++) + { + if (wMem == pSeq[chIndex]) + { + chRtn = CI_SUCCESS; + break; + } + else + { + ; /* */ + } + } + } + else + { + ; /* */ + } + return chRtn; +} + +/* +* @brief ȡlinkεAG/BG +* @param wLinkId +* @return 0x55 AG +* 0xAA BG +* 0xFF AGBG +* Created By LQ 20240815 +*/ +UINT8 GetLinkRelPhySecAGorBGAttr(const UINT16 wLinkId) +{ + UINT8 chRtnValue = LINK_REL_PHYSEC_DEFAULT; + UINT16 wIndex = 0U; + + wIndex = GetLinkIndexById(wLinkId); + + if ((0U < wIndex) && (LINK_SUM_MAX > wIndex)) + { + chRtnValue = g_szLinkConfigData[wIndex].chRelPhySecIsAGorBG; + } + else + { + ; /*δ󣬷Ĭֵ*/ + } + + return chRtnValue; +} + +/* +* @brief ȡBGlinkAGlinkBG1 +* @param const UINT16 wBGLinkId BGlink +* @return BGlinkAG link ID +* Created By LQ 20240815 +*/ +UINT16 GetBGLinkRelAGLinkId(const UINT16 wBGLinkId) +{ + UINT16 wRtnVal = 0U; + UINT16 wIndex = 0U; + + wIndex = GetLinkIndexById(wBGLinkId); + if ((0U < wIndex) && (LINK_SUM_MAX > wIndex)) + { + wRtnVal = g_szLinkConfigData[wIndex].wBGLinkRelAGLink; + } + else + { + ; /*δ󣬷Ĭֵ*/ + } + + return wRtnVal; +} + +/* +* @brief ȡlinkβɼռ״̬ +* @param wLinkId +* @return 0x55 +* 0xAA ռ +* Created By LQ 20240815 +*/ +UINT8 GetLinkOrgAxleSecOccSta(const UINT16 wLinkId) +{ + UINT8 cRetVal = AXIS_SECTION_OCCUPY_YES; /*βɼռ״̬*/ + UINT16 wIndex = 0U; + UINT16 wOrgLinkId = 0U; /*linkID*/ + UINT16 wOrgAxleSecId = 0U; /*ڼID*/ + UINT8 cOrgAxleSecOccState = AXIS_SECTION_OCCUPY_YES; /*ڼռ״̬*/ + + wIndex = GetLinkIndexById(wLinkId); + + if ((0U < wIndex) && (LINK_SUM_MAX > wIndex)) + { + wOrgLinkId = GetLinkOrgnJointMainLkIdById(wLinkId); + if ((0U != wOrgLinkId) && (UINT16_MAX != wOrgLinkId)) + { + wOrgAxleSecId = GetLinkBelongAcId(wOrgLinkId); + cOrgAxleSecOccState = GetAxisOccupyState(wOrgAxleSecId); + if (AXIS_SECTION_OCCUPY_NO == cOrgAxleSecOccState) + { + cRetVal = AXIS_SECTION_OCCUPY_NO; + } + else + { + cRetVal = AXIS_SECTION_OCCUPY_YES; + } + } + else + { + cRetVal = AXIS_SECTION_OCCUPY_NO; /*linkͷΪ*/ + } + } + else + { + ; /*δ󣬷ռ*/ + } + + return cRetVal; +} + +/* +* @brief ȡlinkյβɼռ״̬ +* @param wLinkId +* @return 0x55 +* 0xAA ռ +* Created By LQ 20240815 +*/ +UINT8 GetLinkTmlAxleSecOccSta(const UINT16 wLinkId) +{ + UINT8 cRetVal = AXIS_SECTION_OCCUPY_YES; /*βɼռ״̬*/ + UINT16 wIndex = 0U; + UINT16 wTmlLinkId = 0U; /*յlinkID*/ + UINT16 wTmlAxleSecId = 0U; /*յڼID*/ + UINT8 cTmlAxleSecOccState = AXIS_SECTION_OCCUPY_YES; /*յڼβɼռ״̬*/ + + wIndex = GetLinkIndexById(wLinkId); + + if ((0U < wIndex) && (LINK_SUM_MAX > wIndex)) + { + wTmlLinkId = GetLinkTmnlJointMainLkById(wLinkId); + + if ((0U != wTmlLinkId) && (UINT16_MAX != wTmlLinkId)) + { + wTmlAxleSecId = GetLinkBelongAcId(wTmlLinkId); + cTmlAxleSecOccState = GetAxisOccupyState(wTmlAxleSecId); + if (AXIS_SECTION_OCCUPY_NO == cTmlAxleSecOccState) + { + cRetVal = AXIS_SECTION_OCCUPY_NO; + } + else + { + cRetVal = AXIS_SECTION_OCCUPY_YES; + } + } + else + { + cRetVal = AXIS_SECTION_OCCUPY_NO; /*linkͷΪ*/ + } + } + else + { + ; /*δ󣬷ռ*/ + } + + return cRetVal; +} + +/* +* @brief ȡAG LINKǷڹCG־ +* @param wLinkId +* @return LINK_EXIST_REL_CG_DEFAULT *LinkҪCG +* LINK_EXIST_REL_CG_YES +* LINK_EXIST_REL_CG_NO +* by cgh 20240821 +*/ +UINT8 GetAgLinkExistRelCgFlag(const UINT16 wLinkId) +{ + UINT8 chRtnValue = AGLINK_EXIST_REL_CG_DEFAULT; + UINT16 wIndex = 0U; + + wIndex = GetLinkIndexById(wLinkId); + + if ((0U < wIndex) && (LINK_SUM_MAX > wIndex)) + { + chRtnValue = g_szLinkConfigData[wIndex].chExistRelCGFlag; + } + else + { + ; /*δ󣬷Ĭֵ*/ + } + + return chRtnValue; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/LinkConfigDataManage.h b/TSCP/src/APP/ciapp/Section/LinkConfigDataManage.h new file mode 100644 index 0000000..0583327 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/LinkConfigDataManage.h @@ -0,0 +1,735 @@ +/**************************************************************************************************** +* ļ : APP_LinkManage.h +* Ȩ˵ : ؿƼɷ޹˾ +* 汾 : 1.0 +* ʱ : 2022.02.28 +* : TIOC +* : LINKݹͷļ +* ʹע : +* +* ޸ļ¼ : +* +**************************************************************************************************/ +#ifndef _LINK_CONFIG_DATA_MANAGE_H_ +#define _LINK_CONFIG_DATA_MANAGE_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "Commontypes.h" +#include "dsuStruct.h" +#include "SectionDefine.h" +#include "dquQuery.h" + + +/* LINK߼ */ +#define DIR_SAME 0x55u /* ߼ͬ */ +#define DIR_CONVERT 0xAAu /* ߼෴ */ +#define DIR_INVALID 0xFFU /*Ч*/ + +#define FLAG_SET 0x55u /* λ */ +#define FLAG_UNSET 0xAAu /* δλ */ + +#define FIND_FRONT_PROTECT_POINT_TIME 20U /* ǰѭ */ +#define MAX_POINT_IN_AREA 50u /*а*/ +#define USE_DSU_TWOPOINT_LINK_SIZE 100 /*òѯ֮ʱlink*/ + +#define DIRECTIONPOINT_FLAG_VALID 0x55U /*任־ Ч*/ +#define DIRECTIONPOINT_FLAG_INVALID 0xAAU /*任־ Ч*/ + +/*====================link˵߻linkеһƫ================================*/ +typedef enum OFFSET_BASE_TYPE_EU +{ + POINT_START = 0x00U, /*linkн*/ + POINT_END = 0x01U, /*linkнյ*/ + OFFEST_FOWARD = 0x02U, /*linkенǰƫ*/ + OFFEST_BACK = 0x03U, /*linkенƫ*/ +}eu_OffestBaseType; + +/*linkλ*/ +typedef enum SWITCH_LINK_NAME_EU +{ + SW_DEFAUT_LINK = 0U, /*ǵlink*/ + SW_CON_LINK = 1U, /*link*/ + SW_MAIN_LINK = 2U, /*λlink*/ + SW_SIDE_LINK = 3U, /*λlink*/ + +}eu_SwLinkName; + +typedef struct +{ + UINT16 wId; /*link*/ + UINT32 dwLength; /*linkȣcm*/ + UINT16 wLinkLine; /*Link·Ϣ*/ + UINT16 wOrgnPointType; /*link˵*/ + UINT16 wOrgnPointId; /*link˵*/ + UINT16 wOrgnJointMainLkId; /*linkӵlink*/ + UINT16 wOrgnJointSideLkId; /*linkӵڲlink*/ + UINT16 wTmnlPointType; /*linkյ˵*/ + UINT16 wTmnlPointId; /*linkյ˵*/ + UINT16 wTmnlJointMainLkId; /*linkյӵlink*/ + UINT16 wTmnlJointSideLkId; /*linkյӵڲlink*/ + + UINT16 wBelongPlatformId; /*Linkվ̨ID*/ + UINT16 wManageTioc; /*TIOC*/ + + UINT8 chLogicLineRelation; /*ϵͳ߼зĹϵ*/ + UINT8 chLogicDirChanged; /*Link߼仯*/ + UINT16 wRelatedPhySec; /**/ + UINT8 chSwTrack; /*߻ѹ*/ + UINT16 wStopAreaId; /*linkͣ*/ + UINT8 chPlatform; /*վ̨*/ + UINT16 wPlatformId; /*߼վ̨ID(Ĭ0linkΪվ̨ΪЧֵRRMʹ)*/ + UINT8 chRevertArea; /* ۷ */ + UINT8 chLinkTgEvacuateDir; /*ѹ켰ɢ·*/ + UINT8 chLinkLinXian; /*Link*/ + UINT8 chRelPhySecIsAGorBG; /*LinkΪAG/BG0x55 AG;0xAA BG;0xFF AGBG*/ + UINT8 chExistRelCGFlag; /*LINKǷڹCG־*/ + UINT16 wBGLinkRelAGLink; /*BGlinkAGlink*/ +}LinkDataConfigStru; + +typedef struct +{ + UINT16 wLinkId; /* LINK */ + UINT16 wPointType; /* ˵ */ + UINT16 wPointId; /* ˵ */ + UINT16 wMainLinkId; /* link */ + UINT16 wSideLinkId; /* ڲlink */ +}LinkPointDataStru,*pLinkPointData; + +/*λϢṹ*/ +typedef struct +{ + UINT16 wLinkId; /*Link*/ + UINT32 dwOffset; /*Linkƫ*/ +}struct_PathPoint, *p_strPathPoint; + +/* ·Ϣ */ +typedef struct PATH_LINK_INFO_STRU +{ + UINT8 cLinkCnt; /*link*/ + UINT16 szLinkId[LINK_SUM_MAX]; /*·ID*/ +}str_PathLinkInfo, *p_StrPathLinkInfo; + +/*гռѹ*/ +typedef struct ZONE_STRU +{ + UINT8 Dir; + struct_PathPoint pStart; + struct_PathPoint pEnd; + str_PathLinkInfo pLinkSeq; +}str_Zone, *p_StrZone; + +/*·еϢ*/ +typedef struct AREA_OF_POINT_INFO_STRU +{ + UINT16 pointID; /*ID*/ + UINT8 status; /*״̬*/ +}str_AreaOfPointInfo, *p_strAreaOfPointInfo; + +/*·еĵϢ*/ +typedef struct POINT_IN_AREA_STRU +{ + UINT8 SwitchNum; + str_AreaOfPointInfo SwitchInfo[MAX_POINT_IN_AREA]; +}str_PointInArea, *p_strPointInArea; + +extern LinkDataConfigStru g_szLinkConfigData[LINK_SUM_MAX]; +extern UINT16 g_linkNum; + +/** +* @brief GetLinkNum ȡLINK +* @param void +* @return LINK +*/ +extern UINT16 GetLinkNum(void); + +/** +* @brief GetLinkData ȡLINK +* @param void +* @return LINK +*/ +extern LinkDataConfigStru * GetLinkData(void); + +/** +* @brief GetLinkDataById IDȡLINK +* @param linkId +* @return LINK +*/ +extern LinkDataConfigStru * GetLinkDataById(const UINT16 linkId); + +/** +* @brief GetLinkDataByIndex ȡLINK +* @param linkIndex +* @return LINK +*/ +extern LinkDataConfigStru * GetLinkDataByIndex(const UINT16 linkIndex); + +/** +* @brief GetLinkIndexById ݱŻȡ +* @param linkId +* @return LINK +*/ +extern UINT16 GetLinkIndexById(const UINT16 linkId); + +/** +* @brief GetLinkLengthById ȡLINK +* @param linkId +* @return LINK +*/ +extern UINT32 GetLinkLengthById(const UINT16 linkId); + +#if 0 +/** +* @brief GetLinkPointType ȡLINK˵ +* @param linkId +* @return LINK +*/ +extern UINT8 GetLinkPointType(const UINT16 linkId, UINT8 * pOrgnPointType, UINT8 * pTmnlPointType); +#endif +/** +* @brief GetLinkLineById ȡLINKϢ +* @param linkId +* @return LINKϢ 0x55:У0xaa: +*/ +extern UINT16 GetLinkLineById(const UINT16 linkId); + +/** +* @brief GetLinkOrgnPointTypeId ȡLINK˵ +* @param linkId +* @return LINK˵ +*/ +extern UINT16 GetLinkOrgnPointTypeById(const UINT16 linkId); + +/** +* @brief GetLinkOrgnPointIdById ȡLINK˵ +* @param linkId +* @return LINK˵ +*/ +extern UINT16 GetLinkOrgnPointIdById(const UINT16 linkId); + +/** +* @brief GetLinkOrgnJointMainLkIdById ȡLINKӵlink +* @param linkId +* @return LINKӵlink +*/ +extern UINT16 GetLinkOrgnJointMainLkIdById(const UINT16 linkId); + +/** +* @brief GetLinkOrgnJointSideLkIdById ȡLINKӵڲlink +* @param linkId +* @return LINKӵڲlink +*/ +extern UINT16 GetLinkOrgnJointSideLkIdById(const UINT16 linkId); + +/** +* @brief GetLinkTmnlPointTypeById ȡLINKյ˵ +* @param linkId +* @return LINKյ˵ +*/ +extern UINT16 GetLinkTmnlPointTypeById(const UINT16 linkId); + +/** +* @brief GetLinkTmnlPointIdById ȡLINKյ˵ +* @param linkId +* @return LINKյ˵ +*/ +extern UINT16 GetLinkTmnlPointIdById(const UINT16 linkId); + +/** +* @brief GetLinkTmnlJointMainLkById ȡLINKյӵlink +* @param linkId +* @return LINKյӵlink +*/ +extern UINT16 GetLinkTmnlJointMainLkById(const UINT16 linkId); + +/** +* @brief GetLinkTmnlJointSideLkById ȡLINKյӵڲlink +* @param linkId +* @return LINKյӵڲlink +*/ +extern UINT16 GetLinkTmnlJointSideLkById(const UINT16 linkId); + +/** +* @brief GetLinkManageOcById ȡLINKTIOC +* @param linkId +* @return LINKOC +*/ +extern UINT16 GetLinkManageTiocById(const UINT16 linkId); + +/** +* @brief GetLinkLogicDirChangedById ȡLINK߼仯 +* @param linkId +* @return LINK߼仯 +*/ +extern UINT8 GetLinkLogicDirChangedById(const UINT16 linkId); + +/** +* @brief ȡlink߼зĹϵ +* @param linkId +* @return LINK߼зĹϵ +*/ +extern UINT8 GetLinkLogicLineReleationById(const UINT16 linkId); + +/** +* @brief ȡLINK˵Ϣ +* @param chDir +* @param wLinkId LINK +* @param pLinkPoint ˵Ϣ +* @return OC_SUCCESS:ɹOC_ERROR:ʧ +*/ +extern UINT8 GetLinkPointInfo(UINT8 chDir, UINT16 wLinkId, pLinkPointData pLinkPoint); + +/** +* @brief ݲѯȡlink˵ƫ +* @param wLinkId link +* @return OC_SUCCESS:ɹOC_ERROR_:ʧ +*/ +extern UINT8 GetLinkOffsetByDir(struct_PathPoint* pPoint, UINT8 chDir, UINT8 chPointType, UINT32 dwDistance); + +/*ܣȡLinkʱĵ״̬*/ +extern UINT8 dsuSwitchStatusBtwLink(UINT16 wSwitchID, UINT16 wlinkA, UINT16 wlinkB, UINT8 *exSwitchStatus); + +/** +* @brief жlinkЧ +* @param wId +* @return OC_ERROR:Ч OC_SUCCESS:Ч +*/ +extern UINT8 IsLinkIdValid(UINT16 wId); + +/** +* @brief УlinkIDƫǷЧ +* @param wLinkIdlink dwOffestƫ +* @param dwLinkOffset +* @return CI_ERROR:ЧCI_SUCCESS:Ч +*/ +extern UINT8 CheckLinkValid(UINT16 wLinkId, UINT32 dwOffest); + +/** +* @brief ѯijһλָƶָλüҹĵϢ +* @param struct_PathPoint pStart +* @param UINT32 dwDistance +* @param UINT8 chDir +* @param struct_PathPoint *pEnd ѯյ +* @param UINT16 * pSwitchId ͨĵID +* @return 0ѯʧܣ1ѯ·նˣ2ͨ3ѯɹ4ͨҲռ +*/ +extern UINT8 dsuNewLocAndObsByOffsetDis(IN struct_PathPoint pStart, IN UINT32 dwDistance, IN UINT8 chDir, OUT struct_PathPoint *pEnd, OUT UINT16 * pSwitchId); + +/** +* @brief ѯǰlinklink,ڵԭ²ѯʧʱصıϢ +* @param UINT16 wCurrentLinkId ǰlink +* @param UINT8 chDirection ѯ +* @param UINT16 *pSwitchId +* @return һlink ʧܣUINT16_MAX·յ㣺0u +*/ +extern UINT16 FindAdjacentLinkIDSafe(UINT16 wCurrentLinkId, UINT8 chDirection, UINT16* pSwitchId, UINT8* directionPointFlag); + +/** +* @brief linkͨʱжӹϵ뵱ǰĵ״̬Ƿƥ䡣 +* @param UINT16 wStartLinkId link +* @param UINT8 chDir +* @param UINT16 *pSwitchId +* @return CI_SUCCESSƥ䣻CI_ERRORƥ +*/ +extern UINT8 dsuCheckLinkFitPointSafe(UINT16 wStartLinkId, UINT8 chDir, UINT16 *pSwitchId); + +/** +* @brief ѯAǷBλùϵֻӦͬһlinkλñȽϻغϣ +* @param p_strPathPoint pPointA +* @param p_strPathPoint pPointB +* @param UINT8 dir +* @return ѯʧܣCI_ERRORغϣCI_SUCCESSABǰFLAG_SETBAǮFLAG_UNSET +*/ +extern UINT8 dsuJudgeLinkAandLinkBPosition(p_strPathPoint pPointA, p_strPathPoint pPointB, UINT8 dir); + +/** +* @brief ȡָlinkϵռѹΧ +* @param p_StrZone pZone +* @param UINT16 wLinkId link +* @param p_strPathPoint pStartPoint linkռѹ +* @param p_strPathPoint pEndPoint linkռѹյ +* @return CI_ERRORʧ CI_SUCCESSɹ +*/ +extern UINT8 dsuZoneStartEndPointInLink(p_StrZone pZone, IN const UINT16 wLinkId, OUT p_strPathPoint pStartPoint, OUT p_strPathPoint pEndPoint); + +/** +* @brief жϵǷ +* @param strPoint Ϣ +* @param strZone Ϣ +* @return CI_SUCCESSڣCI_ERROR +*/ +extern UINT8 IsPointInPath(struct_PathPoint strPoint, str_Zone strZone); + +/** +* @brief ͨյlinklinkеϢѯlinklinkС +* @param UINT16 linkA +* @param UINT16 linkB +* @param UINT8 chDir +* @param p_strPointInArea pSwInfo Ϣ +* @param p_StrPathLinkInfo pLinkSeq link +* @return CI_ERRORʧ CI_SUCCESSɹ +*/ +extern UINT8 dsuLinkSeqBtwLinkBaseSwitchInfo(UINT16 linkA, UINT16 linkB, UINT8 chDir, IN p_strPointInArea pSwInfo, OUT p_StrPathLinkInfo pLinkSeq); + +/** +* @brief ͨеĵϢѯlinkС +* @param struct_PathPoint pStart +* @param struct_PathPoint pEnd յ +* @param UINT8 chDir +* @param p_strPointInArea pSwInfo Ϣ +* @param p_StrPathLinkInfo pLinkSeq link +* @return CI_ERRORʧ CI_SUCCESSɹ +*/ +extern UINT8 dsuLinkSeqInAreaBaseSwitchInfo(struct_PathPoint pStart, struct_PathPoint pEnd, UINT8 chDir, IN p_strPointInArea pSwInfo, OUT p_StrPathLinkInfo pLinkSeq); + +/** +* @brief ѯA㵽Bľ롣 +* @param p_strPathPoint pAPoint +* @param p_strPathPoint pBPoint +* @param UINT8 *pDir +* @return ѯʧܣUINT32_MAX +*/ +extern UINT32 DsuAPointToBPoint(p_strPathPoint pAPoint, p_strPathPoint pBPoint, UINT8 *pDir); + +/** +* @brief ѯlinkڵλá +* @param UINT16 wLinkID +* @param UINT16 wSwitchId +* @param UINT8 *p_LinkInSW +* @return CI_ERROR:ѯʧܣCI_SUCCESS:ѯɹ +*/ +extern UINT8 dsuLinkofSwitchPos(UINT16 wLinkID, UINT16 wSwitchId, UINT8 *p_LinkInSW); + +/** +* @brief ȡLINKα +* @param linkId +* @return LINKα +*/ +extern UINT16 GetLinkRelatedPhySec(const UINT16 linkId); + +/** +* @brief ѯA㵽BlinkС +* @param p_strPathPoint pAPoint +* @param p_strPathPoint pBPoint +* @param UINT8 *pDir +* @param UINT16 * pLinkNum LINK +* @param UINT16 * pLinkIdBuf LINKŻ +* @return CI_ERROR:ѯʧܣCI_SUCCESS:ѯɹ +*/ +extern UINT8 DsuLinkSeqBtwPoints(p_strPathPoint pAPoint, p_strPathPoint pBPoint, OUT UINT8 *pDir, OUT UINT16 * pLinkNum, OUT UINT16 * pLinkIdBuf); + +/** +* @brief ȡlinkڵǰ·˹ϵID +* @param wLinkId +* @return linkڵǰ·˹ϵID +*/ +extern UINT16 GetLinkBelongAcId(UINT16 wLinkId); + +/************************************************************************ +ܣλϢת +ڲ: UINT16 wLinkSrc, UINT32 dwOffsetSrc +ڲ: UINT16* wLinkDst, UINT32* dwOffsetDst +ֵ: ѯʧܻѯ·ն˻λòΪlink˵: CI_ERROR; ѯɹ: CI_SUCCESS +************************************************************************/ +extern UINT8 dsuCheckSameLoc(UINT16 wLinkSrc, UINT32 dwOffsetSrc, UINT16* wLinkDst, UINT32* dwOffsetDst); + +/** +* @brief ѯAǷBλùϵlink +* @param p_strPathPoint pPointA +* @param p_strPathPoint pPointB +* @param UINT8 dir +* @return ѯʧܣCI_ERRORغϣCI_SUCCESSABǰFLAG_SETBAǮFLAG_UNSET +*/ +extern UINT8 dsuJudgePointAandPointBPosition(p_strPathPoint pPointA, p_strPathPoint pPointB, UINT8 dir); + +/********************************************* +ܣlinkлüα +linkId ׵ַLinkNum link +AxleSgmtId αַ +AxleSgmtNum 鳤 +ֵCI_ERRORʧܣCI_SUCCESSɹ +**********************************************/ +extern UINT8 GetAxisSeqFromLinkSeq(UINT16* linkId, UINT16 LinkNum, UINT16 *AxleSgmtId, UINT16 * AxleSgmtNum,UINT16 maxSize); + +/** +* @brief ͨյlinklinklinkϢѯlinkĵϢ +* @param UINT16 linkA +* @param UINT16 linkB +* @param UINT8 chDir +* @param IN p_StrPathLinkInfo pLinkSeq +* @param OUT p_strPointInArea pSwInfo +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +*/ +extern UINT8 dsuSwitchInfoBtwLinkBaseLinkSeq(UINT16 linkA, UINT16 linkB, UINT8 chDir, IN p_StrPathLinkInfo pLinkSeq, OUT p_strPointInArea pSwInfo); + +/** +* @brief ȡ߼ +* @param struct_PathPoint strPoint +* @return ߼ID +*/ +extern UINT16 GetPointBelongLogSec(struct_PathPoint strPoint); + +/** +* @brief ȡ߼ +* @param struct_PathPoint strPoint +* @return ߼ID +*/ +extern UINT8 GetLogSecBtwTwoPoints(struct_PathPoint strStart, struct_PathPoint strEnd, UINT16 * pLogSecNum, UINT16 szLogId[]); + +/** +* @brief жǷཻ +* @param p_StrZone pZoneA +* @param p_StrZone pZoneB +* @return CI_ERROR ཻ CI_SUCCESS ཻ +*/ +extern UINT8 CheckZoneIsCrossing(p_StrZone pZoneA, p_StrZone pZoneB); + +/** +* @brief жϵǷڱ +* @param wLink +* @param dwOffset +* @return CI_ERROR ڱ CI_SUCCESS ڱ +*/ +extern UINT8 IsPointManaged(const UINT16 wLink, const UINT32 dwOffset); + +/** +* @brief жLINKǷΪ߻ѹ +* @param linkId +* @return CI_SUCCESS:linkΪ߻ѹ죻CI_ERROR:linkΪ߻ѹ +*/ +extern UINT8 IsLinkSwTrack(const UINT16 linkId); + +/** +* @brief жLINKǷΪ۷ +* @param linkId +* @return CI_SUCCESS:linkΪ۷CI_ERROR:linkΪ۷ +*/ +extern UINT8 IsLinkRevertArea(const UINT16 linkId); + +/** +* @brief ȡLINKͣ +* @param linkId +* @return LINKͣ +*/ +extern UINT16 GetLinkStopAreaId(const UINT16 linkId); + +/********************************************* +ܣȡзϵλеһ +szAxisId ׵ַwAxisNum wAxisNum + + +ֵ0ʧܣ AxisIDɹ +**********************************************/ +extern UINT16 GetAxisIdFromAxisSeqSafeSw(UINT16* szAxisId, UINT16 wAxisNum); + +/** +* @brief ȡ +* @param wLinkId +* @param dwLinkOffset +* @return +*/ +extern UINT32 GetPointKm(UINT16 wLinkId, UINT32 dwLinkOffset); + +/** +* @brief жLINKǷΪվ̨ +* @param linkId +* @return CI_SUCCESS:linkΪվ̨CI_ERROR:linkΪվ̨ +*/ +extern UINT8 IsLinkPlatform(const UINT16 linkId); + +/** +* @brief ȡ߼ +* @param struct_PathPoint strPoint +* @param UINT16 * pLgcIdBuf ߼ID +* @return ߼ +* @note +*/ +extern UINT8 GetPointBelongLogSecEx(struct_PathPoint strPoint, UINT16 * pLgcIdBuf); + +/** +* @brief ȡlink߼վ̨ +* @param linkId +* @return link߼վ̨;0:linkΪվ̨ +*/ +extern UINT16 GetLinkPlatfrm(const UINT16 linkId); + +/** +* @brief ȡATS߼վ̨tioc +* @param const UINT16 wLgcStation +* @return ATS߼վ̨tioc +* @note +*/ +extern UINT16 GetAtsLgcStationBelongTioc(const UINT16 wLgcStation); + +/** +* @brief ȡվ̨Link +* @param const UINT16 wLgcStation +* @return վ̨Link +* @note +*/ +UINT16 GetLinkIDBelongPlatForm(const UINT16 wPlatform); + +/** +* @brief жLINKǷ +* @param const UINT16 wLinkId link +* @return CI_ERROR:linkCI_SUCCESS:linkδ +* @note +*/ +extern UINT8 IsLinkFlock(const UINT16 wLinkId); + +/** +* @brief ӪתΪ߼ +* @param const UINT8 chDir Ӫ +* @return DIR_SAME:link߼ͬ +DIR_CONVERT:link߼෴ +DIR_INVALID:Ч +* @note +*/ +extern UINT8 ConvertDirectionToLogic(const UINT8 chDir); + +/** +* @brief ߼תΪӪ +* @param const UINT8 chDir ߼ +* @return 0x55: +* 0xaa: +* 0xff:Ч +*/ +UINT8 ConvertLogicDirToRun(const UINT8 chDir); + +/* +* ǰ߼ȡ +* ˵ +* const UINT8 chTrainDir гз +* ֵ ȡз +*/ +extern UINT8 ConvertTrainDir(UINT8 chTrainDir); + +/** +* @brief ݷ仯ת־ת +* @param UINT8 wFlag 任־λ +* @param UINT8 wPointDir ѯ +* @param UINT8* wPointCnt 任Σ +* @return 任ķ +*/ +UINT8 TransDirectionPointDir(UINT8 wFlag, UINT8 wPointDir, UINT8* wPointCnt); + +/** +* @brief ж㷽Ƿͬ(гͬ򡢶ʻж) +* @param[in] const LOD_STRU strPointA A +* @param[in] const LOD_STRU strPointB B +* @param[out] +* @return CI_ERROR:ʧܣFLAG_SET:ͬFLAG_UNSET: +*/ +extern UINT8 IsPointABSameDir(const LOD_STRU strPointA, const LOD_STRU strPointB); + +/* +* ݷ任żĻ +* ˵UINT8 Dir, +* UINT8 wChangeNum 任 +* ֵ 0: ȡʧ +* >0: +*/ +extern UINT8 TransDirByChangeNum(UINT8 Dir, UINT8 wChangeNum); + +/* +* ѯվ̨linkⷽһ߼ + * @param[in] UINT16 wLinkId վ̨LinkID + * @param[in] UINT8 chDir ѯ + * @param[out] UINT16 * pLgcIdBuf ߼ID + * @return ߼UINT8_MAXʧܣ0·ն +*/ +UINT8 FindPlatFormLinkOutLog(UINT16 wLinkId, UINT8 chDir, UINT16 * pLgcIdBuf); + +/** +* @brief ȡlinkѹ켰ɢ· +* @param wLinkId +* @return 0 ʧ + >0 linkѹ켰ɢ· +* by cgh 20240105 +*/ +UINT8 GetLinkTgEvacuateDir(const UINT16 wLinkId); + +/** +* @brief ȡlink ߼ +* @param IN UINT16 *pLinkId linkID UINT8 linkNum link +* @param OUT UINT16 *pLgcSum ߼ +* @param OUT UINT16 pLgcIdBuf[SIZE_MAX_SECTION_BT_TRAIN] ߼ID +* @return CI_ERROR ʧ CI_SUCCESS ɹ +* @note +*/ +UINT8 GetLinkRelLgcId(UINT8 linkNum, UINT16 *pLinkId, UINT16 *pLgcSum, UINT16 *pLgcIdBuf); + +/** +* @brief ȡзϵλм +* @param szAxisId ׵ַ + wAxisNum θ +* @param OUTchOutAxisSecSum ļĿ + szOutAxisSecIdBuf ļ +* @return ϵļĿ +* @note by cgh 20240514 +*/ +UINT8 GetAllAxisFromAxisSeqSafeSw(UINT16* szAxisId, UINT16 wAxisNum, UINT16* szOutAxisSecIdBuf); + +/** +* @brief жϳԱǷ +* @param const UINT16 wMem Աֵ +* @param const UINT8 chNum гԱ +* @param UINT16 * pSeq +* @return CI_ERROR:ԱڣCI_SUCCESS:Ա +*/ +UINT8 IsMenberOfSeq(const UINT16 wMem, const UINT8 chNum, UINT16 * pSeq); + +/* +* @brief ȡlinkεAG/BG +* @param wLinkId +* @return 0x55 AG +* 0xAA BG +* 0xFF AGBG +* Created By LQ 20240815 +*/ +UINT8 GetLinkRelPhySecAGorBGAttr(const UINT16 wLinkId); + +/* +* @brief ȡBGlinkAGlinkBG1 +* @param const UINT16 wBGLinkId BGlink +* @return BGlinkAG link ID +* Created By LQ 20240815 +*/ +UINT16 GetBGLinkRelAGLinkId(const UINT16 wBGLinkId); + +/* +* @brief ȡlinkβɼռ״̬ +* @param wLinkId +* @return 0x55 +* 0xAA ռ +* Created By LQ 20240815 +*/ +UINT8 GetLinkOrgAxleSecOccSta(const UINT16 wLinkId); + +/* +* @brief ȡlinkյβɼռ״̬ +* @param wLinkId +* @return 0x55 +* 0xAA ռ +* Created By LQ 20240815 +*/ +UINT8 GetLinkTmlAxleSecOccSta(const UINT16 wLinkId); + +/* +* @brief ȡAG LINKǷڹCG־ +* @param wLinkId +* @return LINK_EXIST_REL_CG_DEFAULT *LinkҪCG +* LINK_EXIST_REL_CG_YES +* LINK_EXIST_REL_CG_NO +* by cgh 20240821 +*/ +UINT8 GetAgLinkExistRelCgFlag(const UINT16 wLinkId); + +#ifdef __cplusplus +} +#endif + +#endif // !_LINK_CONFIG_DATA_MANAGE_H_ diff --git a/TSCP/src/APP/ciapp/Section/LinkLineConfigDataManage.h b/TSCP/src/APP/ciapp/Section/LinkLineConfigDataManage.h new file mode 100644 index 0000000..4bbb83e --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/LinkLineConfigDataManage.h @@ -0,0 +1,25 @@ +#ifndef _LINK_LINE_CONFIG_DATA_MANAGE_H_ +#define _LINK_LINE_CONFIG_DATA_MANAGE_H_ + +#include "Commontypes.h" +#include "SectionDefine.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct +{ + UINT16 wId; /* ߱ */ + UINT16 wAxisSecId; /* α */ + UINT8 cLinkLineType; /* */ + UINT8 cInType; /* ڼ */ + UINT8 cStorageLineType; /*泵*/ +}LinkLineStru; + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/LogicSectionConfigDataManage.c b/TSCP/src/APP/ciapp/Section/LogicSectionConfigDataManage.c new file mode 100644 index 0000000..5c9caf0 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/LogicSectionConfigDataManage.c @@ -0,0 +1,1465 @@ +/******************************************************** +* +* LogicSectionConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ߼ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "LogicSectionConfigDataManage.h" +#include "LinkConfigDataManage.h" +#include "AxisSectionConfigDataManage.h" + + + + +LogicSectionConfigDataStruct LogicSectionConfigDataStru[LOGIC_SECTION_SUM_MAX]; /*߼ݽṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiLogicSectionIdBuf[LOGIC_SECTION_SUM_MAX] = {0u}; /*屾߼IDӳ*/ +INT16 LogicSectionCurSum = 0; /*߼εǰ*/ +UINT16 totalLogicSectionNum = 0u;/*͸߼*/ + + + + +/* +* ȡ߼εǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ߼εǰ +*/ +UINT16 GetLogicSecCurSum(void) +{ + UINT16 retVal = 0u; + if ((INT16)LOGIC_SECTION_SUM_MAX <= LogicSectionCurSum) + { + retVal = LOGIC_SECTION_SUM_MAX; + } + else if (0 > LogicSectionCurSum) + { + retVal = 0u; + } + else + { + retVal = (UINT16)LogicSectionCurSum; + } + return retVal; +} + +/* +* ȡָID߼ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ LOGIC_SECTION_SUM_MAX: ȡʧ +* logSectionId)) + { + retVal = logSectionId; + } + else + { + ; + } + + return retVal; +} + +/* +* ȡָ±Ӧ߼ID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ߼ID +*/ +UINT16 GetLogicSecId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 totalLogSecCurNum = GetTotalLogSecCurNum(); + if (bufIndex < totalLogSecCurNum) + { + retVal = LocalCiLogicSectionIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼ID +* ˵ const UINT16 logicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetLogSecBelongCiId(const UINT16 logicSecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logicSecId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionConfigDataStru[bufIndex].belongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ߼ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 LogicSectionConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 logicSectionConfigDataSum = 0u; /*߼豸*/ + UINT8 retVal = CI_SUCCESS; + UINT8 localCiId = GetSystemParaLocalCiId(); + + /*߼ID*/ + logicSectionConfigDataSum = GetLogicSecCurSum(); + totalLogicSectionNum = logicSectionConfigDataSum; + if (LOGIC_SECTION_SUM_MAX <= logicSectionConfigDataSum) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < LOGIC_SECTION_SUM_MAX; ii++) + { + if (jj == logicSectionConfigDataSum) + {/*Ч*/ + + break; + } + + if (0u != LogicSectionConfigDataStru[ii].LogicSectionId) + {/*òΪЧ*/ + if(localCiId == LogicSectionConfigDataStru[ii].belongCiId ) + { + LocalCiLogicSectionIdBuf[jj] = LogicSectionConfigDataStru[ii].LogicSectionId; + jj++; + } + + } + + + } + } + + + return retVal; +} + +/* +* ߼ +* ˵ logSecSum ߼ +* logSecIdBuff ͸߼ID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendLogSecIdDataManage(UINT16 logSecSum,const UINT16 *logSecIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if (LOGIC_SECTION_SUM_MAX <=(totalLogicSectionNum + logSecSum)) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = totalLogicSectionNum; + totalLogicSectionNum += logSecSum; + for(ii = 0u;ii< logSecSum;ii++) + { + LocalCiLogicSectionIdBuf[index+ii] = logSecIdBuff[ii];/*׷ӵLocalCiLogicSectionIdBuf*/ + } + } + + return retVal; +} + +/* +* ȡ͸Լ߼εǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ߼εǰ +*/ +UINT16 GetTotalLogSecCurNum(void) +{ + UINT16 retVal = 0u; + if (LOGIC_SECTION_SUM_MAX <= totalLogicSectionNum) + { + retVal = 0u; + } + else + { + retVal = totalLogicSectionNum; + } + return retVal; +} +/* +* ȡָID߼ID +* ˵ const UINT16 logicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetLogSecBelongVirCiId(const UINT16 logicSecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logicSecId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionConfigDataStru[bufIndex].belongVirCI; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼Ŀ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +* qw.liu 2022-03-01 +*/ +UINT8 GetSecIntrudeLgcSectionSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chSecInvSecAndConSwiSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼ +* ˵ const UINT16 phySectionId, ID +* ֵ NULL: ȡʧ +* !NULL: νṹָ +* : qw.liu 2022-03-01 +*/ +UINT16* GetSecIntrudeLgcSectionData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].wszSecInvSecAndConSwiId; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* ȡָID߼޷ +* ˵ const UINT16 phySectionId, ID +* ֵ NULL: ȡʧ +* !NULL: νṹָ +* : +*/ +UINT8* GetSecIntrudeLgcSecDirData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].chSecInvSecLockDir; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} +/* +* ȡָID߼ιID +* ˵ const UINT16 wLgcId, ID +* ֵ 0: ȡʧ +* >0: Id +* qw.liu 2022-03-01 +*/ +UINT16 GetLgcSecRelativePhySecId(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRetVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wRetVal = LogicSectionConfigDataStru[wBufIndex].wRelativePhySecId; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/* +* ȡָID߼ι +* ˵ const UINT16 wLgcId, ID +* ֵ 0: ȡʧ +* >0: +* qw.liu 2022-03-01 +*/ +UINT8 GetLgcSecRelativeAxleSecSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chRetVal = LogicSectionConfigDataStru[wBufIndex].chRelativeAxleSum; + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + +/* +* ȡָID߼ι +* ˵ const UINT16 wLgcId,߼ID +* ֵ NULL: ȡʧ +* : linkID +* qw.liu 2022-03-01 +*/ +UINT16* GetLgcSecRltvAxleSecIdBuf(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].wRelativeAxleSecId; + } + else + { + ; + } + return pRetVal; +} + +/* +* ȡָID߼εlink +* ˵ const UINT16 wLgcId,߼ID +* ֵ 0: ȡʧ +* >0: LINK +* qw.liu 2022-03-01 +*/ +UINT8 GetSecIntrudeLinkSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chLinkNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼εlinkID +* ˵ const UINT16 wLgcId,߼ID +* ֵ NULL: ȡʧ +* : linkID +* qw.liu 2022-03-01 +*/ +UINT16* GetSecIntrudeLinkIdBuf(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].szLinkIdBuff; + } + else + { + ; + } + return pRetVal; +} + +/* +* ȡָID߼link +* ˵ const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: linkId +* 2022-03-18 +*/ +UINT16 GetLgcSecOrgnLink(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRetVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wRetVal = LogicSectionConfigDataStru[wBufIndex].wOrgnLink; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/* +* ȡָID߼յlink +* ˵ const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: linkId +* 2022-03-18 +*/ +UINT16 GetLgcSecTmnlLink(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRetVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wRetVal = LogicSectionConfigDataStru[wBufIndex].wTmnlLink; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/* +* ȡָID߼ƫ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ UINT32_MAX: ȡʧ +* UINT32_MAX: ƫ +* 2022-03-18 +*/ +UINT32 GetLgcSecOrgnOffset(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT32 wRetVal = UINT32_MAX; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wRetVal = LogicSectionConfigDataStru[wBufIndex].dwOrgnOffset; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/* +* ȡָID߼յƫ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ UINT32_MAX: ȡʧ +* UINT32_MAX: ƫ +* 2022-03-18 +* @note ڲŻ 20220418 wqm ޸ЧֵΪUINT32_MAX +*/ +UINT32 GetLgcSecTmnlOffset(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT32 wRetVal = UINT32_MAX; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wRetVal = LogicSectionConfigDataStru[wBufIndex].dwTmnlOffset; + } + else + { + wRetVal = UINT32_MAX; + } + return wRetVal; +} + +/** +* @brief ѯ߼ελùϵ +* @param UINT16 wLogA +* @param UINT16 wLogB +* @param UINT8 dir +* @return ѯʧܣCI_ERRORͬ㣺CI_SUCCESSABǰFLAG_SETBAǰFLAG_UNSET +*/ +UINT8 dsuJudgeLogAandLogBPosition(UINT16 wLogA, UINT16 wLogB, UINT8 dir) +{ + struct_PathPoint strPointA = { 0u }; + struct_PathPoint strPointB = { 0u }; + UINT8 chRtn = CI_ERROR; + + /* μ */ + if ((DIR_SAME != dir) && (DIR_CONVERT != dir)) + { + ; + } + else + { + strPointA.wLinkId = GetLgcSecOrgnLink(wLogA); + strPointA.dwOffset = GetLgcSecOrgnOffset(wLogA); + strPointB.wLinkId = GetLgcSecOrgnLink(wLogB); + strPointB.dwOffset = GetLgcSecOrgnOffset(wLogB); + + chRtn = CheckLinkValid(strPointA.wLinkId, strPointA.dwOffset); + chRtn &= CheckLinkValid(strPointB.wLinkId, strPointB.dwOffset); + } + + /* ߼ʼ˽бȽ */ + if (CI_SUCCESS == chRtn) + { + chRtn = dsuJudgePointAandPointBPosition(&strPointA, &strPointB, dir); + } + else + { + ; + } + + return chRtn; +} + +/** +* @brief շȡ߼ ε߼ +* @param UINT16 wLgcSec +* @return 0u:ѯʧ ߼ +* @note +*/ +UINT16 GetLgcSecSeqBelongAc(const UINT16 wStartLgcSec, UINT16 wCurrentAxisSecId ,const UINT8 chDir,OUT UINT16 wszOutLgcSec[AXIS_INCLUDE_LOG_SUM_MAX]) +{ + UINT16 rtn = 0u; /* ֵ */ + UINT16 wOutLgcSecSum = 0U; + UINT8 chKeepWork = CI_ERROR; + UINT16 ii = 0U; + + UINT16 wAxisSecIncLogicSum = 0U; + UINT16 *pAxisSecIncLogicSecIdBuf = NULL; + + wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wCurrentAxisSecId); + pAxisSecIncLogicSecIdBuf = GetAxisSecLogSectionIdBuf(wCurrentAxisSecId); + + if ((DIR_SAME == chDir) || (DIR_CONVERT == chDir)) + { + chKeepWork = CI_SUCCESS; + } + else + { + chKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == chKeepWork) + { + if ((0U != wAxisSecIncLogicSum) + && (pAxisSecIncLogicSecIdBuf != NULL)) + { + ; /**/ + } + else + { + chKeepWork = CI_ERROR; + } + } + + if (CI_SUCCESS == chKeepWork) + { + if (DIR_SAME == chDir) + { + for (ii = 0U; ii < wAxisSecIncLogicSum; ii++) + { + if (wStartLgcSec == pAxisSecIncLogicSecIdBuf[ii]) + { + break; + } + else + { + ; /*ִ*/ + } + } + + if (ii == wAxisSecIncLogicSum) + { + ii = 0U; /*δҵ߼Σؼΰ߼*/ + } + + for (; ii < wAxisSecIncLogicSum; ii++) + { + wszOutLgcSec[wOutLgcSecSum++] = pAxisSecIncLogicSecIdBuf[ii]; + } + } + else + { + for (ii = 0U; ii < wAxisSecIncLogicSum; ii++) + { + if (wStartLgcSec == pAxisSecIncLogicSecIdBuf[ii]) + { + break; + } + else + { + ; /*ִ*/ + } + } + + ii = ii + 1U; + + if (ii > wAxisSecIncLogicSum) + { + ii = wAxisSecIncLogicSum; /*δҵ߼Σؼΰ߼*/ + } + + for (; ii > 0U; ii--) + { + wszOutLgcSec[wOutLgcSecSum++] = pAxisSecIncLogicSecIdBuf[ii - 1U]; + } + } + } + + if (CI_SUCCESS == chKeepWork) + { + rtn = wOutLgcSecSum; + } + else + { + rtn = 0U; + } + return rtn; +} + +/* +* ȡָID߼εĿ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetLogicSecSwitchSum(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chLogsecSwitchSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼εID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: IDָ +*/ +LogsecSwitchStruct* GetLogicSecSwitchIdStru(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogsecSwitchStruct* retVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].LogsecSwitchIdStru; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID߼βĿ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetLgcSecLtrlDfncSwSum(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chLogLtrlDfncSwitchSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼βṹ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: IDָ +*/ +LogsecSwitchStruct* GetLgcSecLtrlDfncSwStru(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogsecSwitchStruct* retVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].LogLtrlDfncSwitchStru; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID߼βշ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: շ +*/ +UINT8* GetLgcSecLtrlDfncLockDir(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8* retVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].szLgcDfncLockDir; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID߼߼Ŀ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼Ŀ +* cgh 2023-05-06 +*/ +UINT8 GetLogBeginLogSecSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chBeginLogSecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼߼ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼νṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogBeginLogSecData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].wBeginLogSecId; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} +/* +* ȡָID߼յ߼Ŀ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: յ߼Ŀ +* cgh 2023-05-06 +*/ +UINT8 GetLogEndLogSecSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chEndLogSecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼յ߼ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: յ߼νṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogEndLogSecData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].wEndLogSecId; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} +/* +* ȡָID߼ιʼźŻĿ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼ιʼźŻĿ +* cgh 2023-05-06 +*/ +UINT8 GetLogRelateBeginSigSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chRelateBeginSigSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼ιʼźŻ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ιʼźŻṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogRelateBeginSigData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].wRelateBeginSigId; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* ȡָID߼ιնźŻĿ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼ιնźŻĿ +* cgh 2023-05-06 +*/ +UINT8 GetLogRelateEndSigSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chRelateEndSigSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼ιնźŻ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ιնźŻṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogRelateEndSigData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].wRelateEndSigId; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} +/* +* ȡָID߼ι·Ŀ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼ι·Ŀ +* cgh 2023-05-06 +*/ +UINT8 GetLogRelateRouteSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chRelateRouteSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼ι· +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ι·ṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogRelateRouteData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].wRelateRouteId; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} +/* +* ȡָID߼ιߵĿ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼ιߵĿ +* cgh 2023-05-06 +*/ +UINT8 GetLogRelateContactSwSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chRelateContactSwSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼ιߵ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ιߵṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogRelateContactSwData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].wRelateContactSwId; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* ȡָID߼ιĿ +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: Ŀ +* : cgh 2023-05-06 +*/ +UINT8 GetLgcRelateProSwSum(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chRelateProSwSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼ιṹ +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: IDָ +* : cgh 2023-05-06 +*/ +LogsecSwitchStruct* GetLgcRelateProSwStru(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogsecSwitchStruct* retVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].wRelateProSwId; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָ߼SPKSĿ +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ spks +* by cgh 20230919 +*/ +UINT8 GetLogSecSpksSum(const UINT16 wLogicSecId) +{ + UINT8 spksNum = 0U; + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); + + if (wBufIndex < LOGIC_SECTION_SUM_MAX) + { + spksNum = LogicSectionConfigDataStru[wBufIndex].chSpksNum; + } + + return spksNum; +} + +/* +* ȡָ߼ָ±SPKSID +* ˵ const UINT16 wLogicSecId, ߼ID +* wSpksIndex± +* ֵ spksId صSPKS ID +* by cgh 20230919 +*/ +UINT16 GetLogSecSpksIdBySpksIdx(const UINT16 wLogicSecId, UINT16 wSpksIndex) +{ + UINT8 chSpksNum = 0U; + UINT16 wSpksId = 0U; + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); + + if (wBufIndex < LOGIC_SECTION_SUM_MAX) + { + chSpksNum = LogicSectionConfigDataStru[wBufIndex].chSpksNum; + } + if (wSpksIndex < chSpksNum) + { + wSpksId = LogicSectionConfigDataStru[wBufIndex].wSpksIdBuff[wSpksIndex]; + } + + return wSpksId; +} + +/* +* ȡָID߼ι豸 +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetLgcSecContactLineCheckSum(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].chContactLineCheckSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼ιߵ豸ṹ +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +LogsecContacSwitchStruct* GetLgcSecContactSwitchCheckStru(const UINT16 wLogicSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogsecContacSwitchStruct* retVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionConfigDataStru[wBufIndex].LogContactSwitchCheckStru; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID߼ιߵڼμID +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ιߵڼμIDṹָ +*/ +UINT16* GetLogContactAxisCheckData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ·±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionConfigDataStru[wBufIndex].chContactAxisCheckID; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* ȡָID߼εCBTC +* ˵ const UINT16 logicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: CBTC +* Created By LQ 2023.12.08 +*/ +UINT8 GetLogSecCbtcProperty(const UINT16 logicSecId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logicSecId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionConfigDataStru[bufIndex].cCbtcProperty; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼ιPSD +* ˵ const UINT16 logicSecId, ߼ID +* ֵ UINT8_MAX: ȡʧ +* PSD +* Created By fan 2024.4.11 +*/ +UINT8 GetLogSecPsdSum(const UINT16 logicSecId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = UINT8_MAX; + + bufIndex = GetlogSectionBufIndex(logicSecId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionConfigDataStru[bufIndex].logSecRltPsdSum; + } + else + { + ; /**/ + } + return retVal; +} + +/* +* ȡָ߼ָ±PSDID +* ˵ const UINT16 wLogicSecId, ߼ID UINT8 wPsdIndex± +* ֵ 0 : ʧ >0 PsdID +* Created By fan 2024.4.11 +*/ +UINT16 GetLogSecPsdByIdx(const UINT16 wLogicSecId, UINT8 wPsdIndex) +{ + UINT8 chPsdNum = 0U; + UINT16 chPsdId = 0U; + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); + + if (wBufIndex < LOGIC_SECTION_SUM_MAX) + { + chPsdNum = GetLogSecPsdSum(wLogicSecId); + if ((wPsdIndex < chPsdNum) && (LOGSEC_RELATE_PSD_MAX >= chPsdNum)) + { + chPsdId = LogicSectionConfigDataStru[wBufIndex].logSecRltPsdBuf[wPsdIndex]; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + return chPsdId; +} + +/* +* ȡָID߼ιEsb +* ˵ const UINT16 logicSecId, ߼ID +* ֵ UINT8_MAX: ȡʧ +* Esb +* Created By fan 2024.4.11 +*/ +UINT8 GetLogSecEsbSum(const UINT16 logicSecId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = UINT8_MAX; + + bufIndex = GetlogSectionBufIndex(logicSecId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionConfigDataStru[bufIndex].logSecRltEsbSum; + } + else + { + ; /**/ + } + return retVal; +} + +/* +* ȡָ߼ָ±EsbID +* ˵ const UINT16 wLogicSecId, ߼ID UINT8 wEsbIndex± +* ֵ 0 : ʧ >0 EsbID +* Created By fan 2024.4.11 +*/ +UINT16 GetLogSecEsbByIdx(const UINT16 wLogicSecId, UINT8 wEsbIndex) +{ + UINT8 chEsbNum = 0U; + UINT16 chEsbId = 0U; + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogicSecId); + + if (wBufIndex < LOGIC_SECTION_SUM_MAX) + { + chEsbNum = GetLogSecEsbSum(wLogicSecId); + if ((wEsbIndex < chEsbNum) && (LOGSEC_RELATE_ESB_MAX >= chEsbNum)) + { + chEsbId = LogicSectionConfigDataStru[wBufIndex].logSecRltEsbBuf[wEsbIndex]; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + return chEsbId; +} + +/* +* ߼Ƿڴ䷶Χ +* ˵ const UINT16 wCheckLogSecId, ߼ID +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20240522 +*/ +UINT8 CheckLogSecBelSendRange(const UINT16 wCheckLogSecId) +{ + UINT8 retVal = CI_ERROR; + UINT16 wLogSecSum = 0U;/*߼Ŀ*/ + UINT16 ii = 0U; + UINT16 wLogSecId = 0U;/*߼ID*/ + + if ((0U < wCheckLogSecId) && (LOGIC_SECTION_SUM_MAX > wCheckLogSecId)) + { + /*ʼ*/ + retVal = CI_SUCCESS; + wLogSecSum = GetTotalLogSecCurNum(); + for (ii = 0U; ii < wLogSecSum; ii++) + { + wLogSecId = GetLogicSecId(ii);/*ȡļиµ߼ID*/ + if (wCheckLogSecId == wLogSecId) + { + retVal = CI_ERROR; + break; + } + else + { + ; /*do nothing*/ + } + } + } + else + { + ; /**/ + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/LogicSectionConfigDataManage.h b/TSCP/src/APP/ciapp/Section/LogicSectionConfigDataManage.h new file mode 100644 index 0000000..094e152 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/LogicSectionConfigDataManage.h @@ -0,0 +1,548 @@ +/******************************************************** +* +* LogicSectionConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ߼ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _LOGIC_SECTION_CONFIG_DATA_MANAGE_H_ +#define _LOGIC_SECTION_CONFIG_DATA_MANAGE_H_ + + +#include "SectionDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*߼ΰṹ*/ +typedef struct S_Logsec_Switch +{ + UINT16 SwitchId; /*ID*/ + UINT8 SwitchPosition; /*λ*/ +} LogsecSwitchStruct; + +/*߼ιߵ豸ṹ*/ +typedef struct S_Logsec_ContactSwitch +{ + UINT16 ContactSwitchId; /*ID*/ + UINT8 ContactSwitchCheckState; /*״̬*/ +} LogsecContacSwitchStruct; + +typedef struct S_LogicSectionConfigDataStruct +{ + UINT16 LogicSectionId; /*߼ID (ʼֶ)*/ + UINT8 belongCiId; /* ߼ */ + UINT8 belongVirCI; /* ߼ */ + UINT16 wRelativePhySecId; /* add by qw.liu 2022-02-22 ID*/ + UINT8 chRelativeAxleSum; /* add 20220919 TIOC5.0 */ + UINT16 wRelativeAxleSecId[LOGSEC_INCLUDE_AXIS_SUM_MAX]; /* add by qw.liu 2022-02-22 ID*//* modify 20220919 TIOC5.0 ޸Ϊ*/ + + UINT8 chLinkNum; /*link*/ + UINT16 szLinkIdBuff[LOGSEC_INCLUDE_LINK_SUM_MAX]; /*link*/ + UINT8 chSecInvSecAndConSwiSum; /*ΰμ*/ + UINT16 wszSecInvSecAndConSwiId[LOGSEC_INV_N_CONDSWIT_SUM_MAX]; /*μ*/ + UINT8 chSecInvSecLockDir[LOGSEC_INV_N_CONDSWIT_SUM_MAX]; /*μӦ*/ + UINT16 wOrgnLink; /* ߼link */ + UINT32 dwOrgnOffset; /* ߼ƫ */ + UINT16 wTmnlLink; /* ߼յlink */ + UINT32 dwTmnlOffset; /* ߼յƫ */ + UINT8 chLogsecSwitchSum; /*߼ΰĵ*/ + LogsecSwitchStruct LogsecSwitchIdStru[LOGSEC_INCLUDE_SWITCH_SUM_MAX]; /*߼ΰĵID*/ + UINT8 chLogLtrlDfncSwitchSum; /*߼βĵ*/ + LogsecSwitchStruct LogLtrlDfncSwitchStru[LOGSEC_LTRL_DFNC_SUM_MAX]; /*߼βĵID*/ + UINT8 szLgcDfncLockDir[LOGSEC_LTRL_DFNC_SUM_MAX]; /*UTռѹշ*/ + UINT8 chBeginLogSecSum; /* add by cgh 20220408 ߼*/ + UINT16 wBeginLogSecId[LOGSEC_NEXT_LOGSEC_SUM_MAX]; /* add by cgh 20220408 ߼ID*/ + UINT8 chEndLogSecSum; /* add by cgh 20220408 յ߼*/ + UINT16 wEndLogSecId[LOGSEC_NEXT_LOGSEC_SUM_MAX]; /* add by cgh 20220408 յ߼ID*/ + UINT8 chRelateBeginSigSum; /* add by cgh 20220504 ߼ιʼźŻ*/ + UINT16 wRelateBeginSigId[LOGSEC_RELATE_SIG_SUM_MAX];/* add by cgh 20220504 ߼ιʼźŻID*/ + UINT8 chRelateEndSigSum; /* add by cgh 20220504 ߼ιնźŻ*/ + UINT16 wRelateEndSigId[LOGSEC_RELATE_SIG_SUM_MAX];/* add by cgh 20220504 ߼ιնźŻID*/ + UINT8 chRelateRouteSum; /* add by cgh 20220504 ߼ι·*/ + UINT16 wRelateRouteId[LOGSEC_RELATE_ROUTE_SUM_MAX];/* add by cgh 20220504 ߼ι·ID*/ + UINT8 chRelateProSwSum; /* add by cgh 20220504 ߼ι*/ + LogsecSwitchStruct wRelateProSwId[LOGSEC_RELATE_PRO_SW_SUM_MAX];/* add by cgh 20220504 ߼ιID*/ + UINT8 chRelateContactSwSum; /* add by cgh 20220504 ߼ιߵ*/ + UINT16 wRelateContactSwId[LOGSEC_RELATE_CON_SW_SUM_MAX];/* add by cgh 20220504 ߼ιߵID*/ + UINT8 chSpksNum; /*add by cgh 20230919 ߼ζӦspks */ + UINT16 wSpksIdBuff[LOGIC_SECTION_SPKS_MAX_NUM];/*add by cgh 20230919 ߼ζӦspksIdб */ + + UINT8 chContactLineCheckSum; /*߼ι豸ֶΣ*/ + LogsecContacSwitchStruct LogContactSwitchCheckStru[PHY_SEC_CONTACT_CHECK_MAX_NUM]; /*߼ιߵ豸ṹ(ֶ)*/ + UINT16 chContactAxisCheckID[PHY_SEC_CONTACT_CHECK_MAX_NUM]; /*߼ιߵڼμIDֶΣ*/ + UINT8 cCbtcProperty; /*߼CBTCԣ0x55CBTC0xaaCBTC*/ + + UINT8 logSecRltPsdSum; /*߼ι*/ + UINT16 logSecRltPsdBuf[LOGSEC_RELATE_PSD_MAX]; /*߼ιID*/ + UINT8 logSecRltEsbSum; /*ť*/ + UINT16 logSecRltEsbBuf[LOGSEC_RELATE_ESB_MAX]; /*߼ιťID*/ +} LogicSectionConfigDataStruct; + +/*******************************ȫֱ*******************************/ +extern LogicSectionConfigDataStruct LogicSectionConfigDataStru[LOGIC_SECTION_SUM_MAX]; /*߼ݽṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiLogicSectionIdBuf[LOGIC_SECTION_SUM_MAX]; /*屾߼IDӳ*/ +extern INT16 LogicSectionCurSum; /*߼εǰ*/ +extern UINT16 totalLogicSectionNum;/*͸߼*/ + + +/* +* ȡ߼εǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ߼εǰ +*/ +UINT16 GetLogicSecCurSum(void); + +/* +* ȡָID߼ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ LOGIC_SECTION_SUM_MAX: ȡʧ +* 0: ߼ID +*/ +UINT16 GetLogicSecId(const UINT16 bufIndex); + +/* +* ߼ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 LogicSectionConfigDataManage(void); + + + +/* +* ȡָID߼ID +* ˵ const UINT16 logicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetLogSecBelongCiId(const UINT16 logicSecId); + +/* +* ߼ +* ˵ logSecSum ߼ +* logSecIdBuff ͸߼ID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendLogSecIdDataManage(UINT16 logSecSum,const UINT16 *logSecIdBuff); + +/* +* ȡ͸Լ߼εǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ߼εǰ +*/ +UINT16 GetTotalLogSecCurNum(void); +/* +* ȡָID߼ID +* ˵ const UINT16 logicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetLogSecBelongVirCiId(const UINT16 logicSecId); + +/* +* ȡָID߼ιID +* ˵ const UINT16 wLgcId, ID +* ֵ 0: ȡʧ +* >0: Id +* qw.liu 2022-03-01 +*/ +UINT8 GetLgcSecRelativeAxleSecSum(const UINT16 wLgcId); + + +/* +* ȡָID߼ι +* ˵ const UINT16 wLgcId,߼ID +* ֵ NULL: ȡʧ +* : linkID +* qw.liu 2022-03-01 +*/ +UINT16* GetLgcSecRltvAxleSecIdBuf(const UINT16 wLgcId); +/* +* ȡָID߼ιID +* ˵ const UINT16 wLgcId, ID +* ֵ 0: ȡʧ +* >0: Id +* qw.liu 2022-03-01 +*/ +UINT16 GetLgcSecRelativePhySecId(const UINT16 wLgcId); + +/* +* ȡָID߼ +* ˵ const UINT16 phySectionId, ID +* ֵ NULL: ȡʧ +* !NULL: νṹָ +* : qw.liu 2022-03-01 +*/ +UINT16* GetSecIntrudeLgcSectionData(const UINT16 wLgcId); + +/* +* ȡָID߼޷ +* ˵ const UINT16 phySectionId, ID +* ֵ NULL: ȡʧ +* !NULL: νṹָ +* : +*/ +UINT8* GetSecIntrudeLgcSecDirData(const UINT16 wLgcId); + + +/* +* ȡָID߼Ŀ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +* qw.liu 2022-03-01 +*/ +UINT8 GetSecIntrudeLgcSectionSum(const UINT16 wLgcId); + +/* +* ȡָID߼εlink +* ˵ const UINT16 wLgcId,߼ID +* ֵ 0: ȡʧ +* >0: LINK +* qw.liu 2022-03-01 +*/ +UINT8 GetSecIntrudeLinkSum(const UINT16 wLgcId); + +/* +* ȡָID߼εlinkID +* ˵ const UINT16 wLgcId,߼ID +* ֵ NULL: ȡʧ +* : linkID +* qw.liu 2022-03-01 +*/ +UINT16* GetSecIntrudeLinkIdBuf(const UINT16 wLgcId); + +/* +* ȡָID߼link +* ˵ const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: linkId +* 2022-03-18 +*/ +UINT16 GetLgcSecOrgnLink(const UINT16 wLgcId); + +/* +* ȡָID߼յlink +* ˵ const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: linkId +* 2022-03-18 +*/ +UINT16 GetLgcSecTmnlLink(const UINT16 wLgcId); + +/* +* ȡָID߼ƫ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ UINT32_MAX: ȡʧ +* UINT32_MAX: ƫ +* 2022-03-18 +*/ +UINT32 GetLgcSecOrgnOffset(const UINT16 wLgcId); + +/* +* ȡָID߼յƫ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ UINT32_MAX: ȡʧ +* UINT32_MAX: ƫ +* 2022-03-18 +*/ +UINT32 GetLgcSecTmnlOffset(const UINT16 wLgcId); + +/** +* @brief ѯ߼ελùϵ +* @param UINT16 wLogA +* @param UINT16 wLogB +* @param UINT8 dir +* @return ѯʧܣCI_ERRORͬ㣺CI_SUCCESSABǰFLAG_SETBAǰFLAG_UNSET +*/ +UINT8 dsuJudgeLogAandLogBPosition(UINT16 wLogA, UINT16 wLogB, UINT8 dir); + +/** +* @brief շȡ߼ ε߼ +* @param UINT16 wLgcSec +* @return 0u:ѯʧ ߼ +* @note +*/ +UINT16 GetLgcSecSeqBelongAc(const UINT16 wStartLgcSec, UINT16 wCurrentAxisSecId, const UINT8 chDir, OUT UINT16 wszOutLgcSec[AXIS_INCLUDE_LOG_SUM_MAX]); + +/* +* ȡָID߼εĿ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetLogicSecSwitchSum(const UINT16 wLogicSecId); + + +/* +* ȡָID߼εID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: IDָ +*/ +LogsecSwitchStruct* GetLogicSecSwitchIdStru(const UINT16 wLogicSecId); + +/* +* ȡָID߼βĿ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetLgcSecLtrlDfncSwSum(const UINT16 wLogicSecId); + + +/* +* ȡָID߼βṹ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: IDָ +*/ +LogsecSwitchStruct* GetLgcSecLtrlDfncSwStru(const UINT16 wLogicSecId); + +/* +* ȡָID߼βշ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: շ +*/ +UINT8* GetLgcSecLtrlDfncLockDir(const UINT16 wLogicSecId); + +/* +* ȡָID߼߼Ŀ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼Ŀ +* cgh 2023-05-06 +*/ +UINT8 GetLogBeginLogSecSum(const UINT16 wLgcId); +/* +* ȡָID߼߼ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼νṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogBeginLogSecData(const UINT16 wLgcId); +/* +* ȡָID߼յ߼Ŀ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: յ߼Ŀ +* cgh 2023-05-06 +*/ +UINT8 GetLogEndLogSecSum(const UINT16 wLgcId); +/* +* ȡָID߼յ߼ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: յ߼νṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogEndLogSecData(const UINT16 wLgcId); +/* +* ȡָID߼ιʼźŻĿ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼ιʼźŻĿ +* cgh 2023-05-06 +*/ +UINT8 GetLogRelateBeginSigSum(const UINT16 wLgcId); +/* +* ȡָID߼ιʼźŻ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ιʼźŻṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogRelateBeginSigData(const UINT16 wLgcId); + +/* +* ȡָID߼ιնźŻĿ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼ιնźŻĿ +* cgh 2023-05-06 +*/ +UINT8 GetLogRelateEndSigSum(const UINT16 wLgcId); +/* +* ȡָID߼ιնźŻ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ιնźŻṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogRelateEndSigData(const UINT16 wLgcId); +/* +* ȡָID߼ι·Ŀ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼ι·Ŀ +* cgh 2023-05-06 +*/ +UINT8 GetLogRelateRouteSum(const UINT16 wLgcId); +/* +* ȡָID߼ι· +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ι·ṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogRelateRouteData(const UINT16 wLgcId); +/* +* ȡָID߼ιߵĿ +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼ιߵĿ +* cgh 2023-05-06 +*/ +UINT8 GetLogRelateContactSwSum(const UINT16 wLgcId); +/* +* ȡָID߼ιߵ +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ιߵṹָ +* : cgh 2023-05-06 +*/ +UINT16* GetLogRelateContactSwData(const UINT16 wLgcId); + +/* +* ȡָID߼ιĿ +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: Ŀ +* : cgh 2023-05-06 +*/ +UINT8 GetLgcRelateProSwSum(const UINT16 wLogicSecId); +/* +* ȡָID߼ιṹ +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: IDָ +* : cgh 2023-05-06 +*/ +LogsecSwitchStruct* GetLgcRelateProSwStru(const UINT16 wLogicSecId); + +/* +* ȡָ߼SPKSĿ +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ spks +* by cgh 20230919 +*/ +UINT8 GetLogSecSpksSum(const UINT16 wLogicSecId); + +/* +* ȡָ߼ָ±SPKSID +* ˵ const UINT16 wLogicSecId, ߼ID +* wSpksIndex± +* ֵ spksId صSPKS ID +* by cgh 20230919 +*/ +UINT16 GetLogSecSpksIdBySpksIdx(const UINT16 wLogicSecId, UINT16 wSpksIndex); + +/* +* ȡָID߼ι豸 +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetLgcSecContactLineCheckSum(const UINT16 wLogicSecId); + + +/* +* ȡָID߼ιߵ豸ṹ +* ˵ const UINT16 wLogicSecId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: IDָ +*/ +LogsecContacSwitchStruct* GetLgcSecContactSwitchCheckStru(const UINT16 wLogicSecId); + +/* +* ȡָID߼ιߵڼμID +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼ιߵڼμIDṹָ +*/ +UINT16* GetLogContactAxisCheckData(const UINT16 wLgcId); + +/* +* ȡָID߼εCBTC +* ˵ const UINT16 logicSecId, ߼ID +* ֵ 0: ȡʧ +* >0: CBTC +* Created By LQ 2023.12.08 +*/ +UINT8 GetLogSecCbtcProperty(const UINT16 logicSecId); + +/* +* ȡָID߼ιPSD +* ˵ const UINT16 logicSecId, ߼ID +* ֵ UINT8_MAX: ȡʧ +* PSD +* Created By fan 2024.4.11 +*/ +UINT8 GetLogSecPsdSum(const UINT16 logicSecId); + +/* +* ȡָ߼ָ±PSDID +* ˵ const UINT16 wLogicSecId, ߼ID UINT8 wPsdIndex± +* ֵ 0 : ʧ >0 PsdID +* Created By fan 2024.4.11 +*/ +UINT16 GetLogSecPsdByIdx(const UINT16 wLogicSecId, UINT8 wPsdIndex); + +/* +* ȡָID߼ιEsb +* ˵ const UINT16 logicSecId, ߼ID +* ֵ UINT8_MAX: ȡʧ +* Esb +* Created By fan 2024.4.11 +*/ +UINT8 GetLogSecEsbSum(const UINT16 logicSecId); + +/* +* ȡָ߼ָ±EsbID +* ˵ const UINT16 wLogicSecId, ߼ID UINT8 wEsbIndex± +* ֵ 0 : ʧ >0 EsbID +* Created By fan 2024.4.11 +*/ +UINT16 GetLogSecEsbByIdx(const UINT16 wLogicSecId, UINT8 wEsbIndex); + +/* +* ߼Ƿڴ䷶Χ +* ˵ const UINT16 wCheckLogSecId, ߼ID +* ֵ CI_ERROR +* CI_SUCCESS +* by cgh 20240522 +*/ +UINT8 CheckLogSecBelSendRange(const UINT16 wCheckLogSecId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Section/LogicSectionDataManage.c b/TSCP/src/APP/ciapp/Section/LogicSectionDataManage.c new file mode 100644 index 0000000..5dbedea --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/LogicSectionDataManage.c @@ -0,0 +1,5733 @@ +/******************************************************** +* +* LogicSectionDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ߼ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "LogicSectionDataManage.h" +#include "../Route/RouteDataManage.h" +#include "../Route/RouteDefine.h" +#include "../Switch/SwitchDefine.h" +#include "SectionStateProcess_api.h" +#include "AxisSort_api.h" +#include "AxisAssertManageAPI.h" +#include "LogicalRouteDataManage.h" +#include "InterlockCommonManage.h" + +LogicSectionDataStruct LogicSectionDataStru[LOGIC_SECTION_SUM_MAX]; /*߼ݽṹ*/ +static TsrDataStruct g_TsrDataStru[TSR_MAX_SUM] = { 0u }; /*ʱ*/ +static UINT8 g_TsrSum = 0u; /* ʱ */ + +UINT8 WholeLineLinShiXianSuFlag = WHOLE_LINE_LINSHIXIANSUSET_NO; /*ȫʱٱ־Ĭ*/ + +/* +* ȡ߼ +* ˵ void +* ֵ 0: ȡʧ +* >0: ߼ǰ +*/ +LogicSectionDataStruct* GetLogicSecData(void) +{ + return LogicSectionDataStru; +} + +/* +* ȡָID߼֮ǰռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ֮ǰռ״̬ +*/ +UINT8 GetLogSecPreOccupyState(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + if (LogicSectionDataStru[bufIndex].PreOccupyState == LOGICSECTION_OCCUPY_NO) + { + retVal = SECTION_OCCUPY_NO; + } + else + { + retVal = SECTION_OCCUPY_YES; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼εǰռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetLogSecCurOccupyState(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + if (LogicSectionDataStru[bufIndex].CurOccupyState == LOGICSECTION_OCCUPY_NO) + { + retVal = SECTION_OCCUPY_NO; + } + else + { + retVal = SECTION_OCCUPY_YES; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼εǰCTUTռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetLogSecCurCtOrUtOccupyState(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + retVal = LogicSectionDataStru[bufIndex].CurOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID߼ʱ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ǰʱ״̬ +*/ +UINT8 GetLogSecLinShiXianSuSetState(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 funRetVal = 0u; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + funRetVal = LogicSectionDataStru[bufIndex].LinShiXianSuSetFlag; + } + else + { + funRetVal = CI_ERROR; + } + return funRetVal; +} + +/* +* ָID߼εǰռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 curOccupyState, ǰռ״̬ +* ֵ +* +*/ +void SetLogSecCurOccupyState(const UINT16 logSectionId, const UINT8 curOccupyState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + if ((LOGICSECTION_OCCUPY_UT == curOccupyState) || + (LOGICSECTION_OCCUPY_CT == curOccupyState) || + (LOGICSECTION_OCCUPY_NO == curOccupyState)) + { + LogicSectionDataStru[bufIndex].CurOccupyState = curOccupyState; /*߼εǰռ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ָID߼֮ǰռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 curOccupyState, ֮ǰռ״̬ +* ֵ +* +*/ +void SetLogSecPreOccupyState(const UINT16 logSectionId, const UINT8 curOccupyState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + if ((LOGICSECTION_OCCUPY_UT == curOccupyState) || + (LOGICSECTION_OCCUPY_CT == curOccupyState) || + (LOGICSECTION_OCCUPY_NO == curOccupyState)) + { + LogicSectionDataStru[bufIndex].PreOccupyState = curOccupyState; /*߼֮ǰռ״̬*/ + + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + + +/* +* ָID߼ʱ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 linShiXianSuSetState, ʱ״̬ +* ֵ +* +*/ +void SetLogSecLinShiXianSuState(const UINT16 logSectionId, const UINT8 linShiXianSuSetState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if ((LOGSEC_LSXS_SET_STATE_NO == linShiXianSuSetState) || + (LOGSEC_LSXS_SET_STATE_YES == linShiXianSuSetState) || + (LOGSEC_LSXS_SET_STATE_INVALID == linShiXianSuSetState)) + { + LogicSectionDataStru[bufIndex].LinShiXianSuSetFlag= linShiXianSuSetState; /*߼ʱ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ָλӦ߼ռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 occupyStateMask, ǰռλ +* ֵ +* +*/ +void SetLogSecMask(const UINT16 logSectionId, const UINT8 occupyStateMask) +{ + UINT16 bufIndex = 0u; /*±*/ + + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + LogicSectionDataStru[bufIndex].zcMaskData |= occupyStateMask; + LogicSectionDataStru[bufIndex].maskCount++; + if (LogicSectionDataStru[bufIndex].maskCount == 2u) + { + if (LOGIC_MASK_CT == LogicSectionDataStru[bufIndex].zcMaskData) + { + SetLogSecPreOccupyState(logSectionId, GetLogSecCurCtOrUtOccupyState(logSectionId)); + SetLogSecOccupyState(logSectionId, LOGICSECTION_OCCUPY_CT); + + } + else if (LOGIC_MASK_UT == LogicSectionDataStru[bufIndex].zcMaskData) + { + SetLogSecPreOccupyState(logSectionId, GetLogSecCurCtOrUtOccupyState(logSectionId)); + SetLogSecOccupyState(logSectionId, LOGICSECTION_OCCUPY_UT); + } + else if (LOGIC_MASK_NO == LogicSectionDataStru[bufIndex].zcMaskData) + { + SetLogSecPreOccupyState(logSectionId, GetLogSecCurCtOrUtOccupyState(logSectionId)); + SetLogSecOccupyState(logSectionId, LOGICSECTION_OCCUPY_NO); + } + else + { /* lλ֣CT UT ͬʱ㣬ΪZCʹUTռ */ + SetLogSecPreOccupyState(logSectionId, GetLogSecCurCtOrUtOccupyState(logSectionId)); + SetLogSecOccupyState(logSectionId, LOGICSECTION_OCCUPY_UT); + } + + LogicSectionDataStru[bufIndex].zcMaskData = 0u; + LogicSectionDataStru[bufIndex].maskCount = 0u; + } + } + else + { + /**/ + } +} + + +/* +* ȡָ߼ռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 GetLogSecOccupyState(const UINT16 logSectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + retVal = LogicSectionDataStru[bufIndex].OccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID߼ռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 curOccupyState, ǰռ״̬ +* ֵ +* +*/ +void SetLogSecOccupyState(const UINT16 logSectionId, const UINT8 curOccupyState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if ((LOGICSECTION_OCCUPY_UT == curOccupyState) || + (LOGICSECTION_OCCUPY_CT == curOccupyState) || + (LOGICSECTION_OCCUPY_NO == curOccupyState)) + { + LogicSectionDataStru[bufIndex].OccupyState = curOccupyState; /*߼εǰռ״̬*/ + + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + +/* +* ָID߼ͨųλRMռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 curOccupyState, ǰռ״̬ +* ֵ +*ע߼ͨųλRMռ״̬úA by yt 2022519 +*/ +void SetLogSecTXOccupyState(const UINT16 logSectionId, const UINT8 curOccupyState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if ((LOGICSECTION_OCCUPY_TX == curOccupyState) || + (LOGICSECTION_OCCUPY_NO_TX == curOccupyState)) + { + LogicSectionDataStru[bufIndex].TXOccupyState = curOccupyState; /*߼εǰռ״̬*/ + } + else + { + ; /*ռ״̬󣬲ִиֵ*/ + } + } + else + { + ; /*±󣬲ִиֵ*/ + } + +} + +/* +* ȡָID߼ͨųռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ʧ +* 0x55޳ռ +* 0xaaͨųռ +*/ +UINT8 GetLogSecTXOccupyState(const UINT16 logSectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].TXOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡȫʱٱ־ +* ˵ +* +* ֵ ȫʱٱ־ +*/ +UINT8 GetWholeLineLinShiXianSuFlag(void) +{ + return WholeLineLinShiXianSuFlag; +} + +/* +* ȫʱٱ־ +* ˵ UINT8 flag,ٱ־ +* +* ֵ +* +*/ +void SetWholeLineLinShiXianSuFlag(UINT8 flag) +{ + if((WHOLE_LINE_LINSHIXIANSUSET_NO == flag) ||(WHOLE_LINE_LINSHIXIANSUSET_YES == flag) ) + { + WholeLineLinShiXianSuFlag = flag; + } + else + { + /**/ + } +} + +/* +* ȡָID߼֮ǰCT/UTռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ֮ǰCT/UTռ״̬ +*/ +UINT8 GetLogSecPreCtOrUtOccupyState(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + retVal = LogicSectionDataStru[bufIndex].PreOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ߼״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼״̬ +*/ +UINT8 GetLogSecLockState(const UINT16 logSectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogLockState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + + +/* +* ȡָ߼շ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼շ +*/ +UINT8 GetLogSecLockDir(const UINT16 logSectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogLockDir; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָ߼״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ +* ޸bug YF0083-119 +*/ +void SetLogSecLockState(const UINT16 logSectionId,const UINT8 lockState,const UINT16 routeId, const UINT8 lockDir) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /*δ*/ + if(LOG_SECTION_LOCK_NO == lockState) + { + if ((LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[bufIndex].LogLockState) + || (LOG_SECTION_LOCK_EXCEPT == LogicSectionDataStru[bufIndex].LogLockState) + || (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[bufIndex].LogLockState)) + { + /*ڱ·*/ + if (routeId == LogicSectionDataStru[bufIndex].LogLockBelongRoute) + { + if (0u == LogicSectionDataStru[bufIndex].wPLockBelongRouteId) + { + /*δ״̬ս·Ϊ0*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_NO; + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = 0u; + LogicSectionDataStru[bufIndex].LogLockDir = 0u; + } + else + { + /* ͬʱ·ķգҪԭɷ״̬ */ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_PROTECT; + } + + /*߼ԴϢ*/ + ClearLgcSecResTrain(logSectionId); + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0u; + LogicSectionDataStru[bufIndex].LogUnlockStartCycNum = 0u; + } + else if(LogicSectionDataStru[bufIndex].wPLockBelongRouteId == routeId) + { + /* */ + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = 0u; + } + else + { + /* ڱ· */ + } + } + else if((LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[bufIndex].LogLockState) + && (routeId != LogicSectionDataStru[bufIndex].wPLockBelongRouteId)) + { + ;/* ʣ·ķգ޴ */ + } + else + { + /*δ״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_NO; + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = 0u; + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0u; + LogicSectionDataStru[bufIndex].LogUnlockStartCycNum = 0u; + LogicSectionDataStru[bufIndex].LogLockDir = 0u; + ClearLgcSecResTrain(logSectionId); + } + } + /**/ + else if(LOG_SECTION_LOCK_NORMAL == lockState) + { + /*״̬ս·*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_NORMAL; + LogicSectionDataStru[bufIndex].LogLockBelongRoute = routeId; + LogicSectionDataStru[bufIndex].LogLockDir = lockDir; + + } + else if (LOG_SECTION_LOCK_PROTECT == lockState) + { /**/ + if(LOG_SECTION_LOCK_NO == LogicSectionDataStru[bufIndex].LogLockState) + { + /* óɷ */ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_PROTECT; + } + else + { + + } + + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = routeId; + LogicSectionDataStru[bufIndex].LogLockDir = lockDir; + } + /*աʱ*/ + else + { + SetRouFirDelayErlockStaCycNum(routeId, 0U); + LogicSectionDataStru[bufIndex].LogLockState = lockState; + LogicSectionDataStru[bufIndex].LogUnlockStartCycNum = 0u; + } + } + else + { + /**/ + } +} + +/* +* ȡָ߼· +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼· +*/ +UINT16 GetLogSecLockBelongRoute(const UINT16 logSectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogLockBelongRoute; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ߼ʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼ʱʼں +*/ +UINT32 GetLogUnlockStartCycNum(const UINT16 logSectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogUnlockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ߼ʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* const UINT32 startCycNum ʼں +* ֵ +* +*/ +void SetLogUnlockStartCycNum(const UINT16 logSectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + LogicSectionDataStru[bufIndex].LogUnlockStartCycNum = startCycNum; + } + else + { + /**/ + } +} + + +/* +* ÷DZָID߼״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 lockState, ״̬ +* const UINT16 routeId, ·ID +* const UINT8 lockDirection, շ +* ֵ +* ޸bug YF0083-119 +*/ +void SetLogSecLockStateOtherCI(const UINT16 logSectionId, const UINT8 lockState, const UINT16 routeId, const UINT8 lockDirection) +{ + /*ʼ*/ + UINT8 localCiId = 0u; + UINT16 bufIndex = 0u; /*±*/ + UINT16 wCurRouteId = 0U; + UINT8 cCurRouteBelongCiId = 0U; + UINT8 cCurRouteState = 0U; + UINT8 routeBelongCi = 0u; + UINT8 logBelongCi = 0u; + UINT8 expRouteBelongCi = 0u; + UINT8 chNewRouteCurState = 0U;/*µĽ·ǰ״̬*/ + UINT8 chNewRoutePreState = 0U;/*µĽ·֮ǰ״̬*/ + UINT8 chOldRoutePreState = 0U;/*ɵĽ·֮ǰ״̬*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + localCiId = GetSystemParaLocalCiId(); + + + if(LOGIC_SECTION_SUM_MAX > bufIndex) + { + logBelongCi = GetLogSecBelongCiId(logSectionId); + expRouteBelongCi = GetRouteBelongCiId(routeId); + if ((LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[bufIndex].LogLockState) && (logBelongCi == localCiId) + && ((LOG_SECTION_LOCK_NORMAL != lockState) || (localCiId == expRouteBelongCi))) + {/*ε״̬ɱ´ģ״̬Ϊ·DZΪZHGɷתΪգˢ״̬*/ + + } + /*ϵ*/ + else if(LOG_SECTION_LOCK_START == lockState) + { + /*״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_START; + } + /**/ + else if(LOG_SECTION_LOCK_NO == lockState) + { + /*աʱ*/ + if((LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[bufIndex].LogLockState) || + (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[bufIndex].LogLockState)|| + (LOG_SECTION_LOCK_EXCEPT == LogicSectionDataStru[bufIndex].LogLockState)) + { + routeBelongCi = GetRouteBelongCiId(LogicSectionDataStru[bufIndex].LogLockBelongRoute); + /*ս·DZ*/ + if(routeBelongCi != localCiId) + { + if ((0U != LogicSectionDataStru[bufIndex].wPLockBelongRouteId) && (logBelongCi == localCiId)) + { + /*20241030Ӽڱɶ30ջˢ⣺ijһ·ڿ1·ڷһΣڿ1DZΣ + ͬʱ·պͷգڸνʱ1Ҫڿ߼εδ״̬ڿڴ˴òδգ + ֻûз·ڿֻ1ˢ״̬¸һֱ޷*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_PROTECT; /*ڷ·ڱΪ*/ + } + else + { + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_NO; /*Ϊδ*/ + LogicSectionDataStru[bufIndex].LogLockDir = 0U; + } + + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0U; + ClearLgcSecResTrain(logSectionId); + } + else + { + + } + } + else + { + if (LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[bufIndex].LogLockState) + {/*߼βڱҵǰ״̬DZգ߼ε״̬ô״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_NO; /*###δ*/ + + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0U; /*ν··ID*/ + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = 0U; /*η·ID*/ + LogicSectionDataStru[bufIndex].LogLockDir = 0U; /*շ*/ + ClearLgcSecResTrain(logSectionId); + } + else + { + + } + + if (0U == LogicSectionDataStru[bufIndex].LogLockState) + {/*߼βڱһδյ߼ε״̬Ϣʱε״̬ô߼״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_NO; + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0u; + LogicSectionDataStru[bufIndex].LogLockDir = 0u; + + ClearLgcSecResTrain(logSectionId); + } + else + { + + } + + logBelongCi = GetLogSecBelongCiId(logSectionId); + /*߼βDZ*/ + if((logBelongCi != localCiId) && ((LOG_SECTION_LOCK_START == LogicSectionDataStru[bufIndex].LogLockState) + || (0U == LogicSectionDataStru[bufIndex].LogLockState))) + { + /*״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_NO; + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0u; + LogicSectionDataStru[bufIndex].LogLockDir = 0u; + + ClearLgcSecResTrain(logSectionId); + } + else + { + + } + } + } + /**/ + else if(LOG_SECTION_LOCK_NORMAL == lockState) + { + routeBelongCi = GetRouteBelongCiId(routeId); + if(routeBelongCi != localCiId) + { + wCurRouteId = GetLogSecLockBelongRoute(logSectionId); + cCurRouteBelongCiId = GetRouteBelongCiId(wCurRouteId); + cCurRouteState = GetRouteState(wCurRouteId); + chOldRoutePreState = GetRoutePreState(wCurRouteId); + chNewRouteCurState = GetRouteState(routeId); + chNewRoutePreState = GetRoutePreState(routeId); + + if ((routeId != wCurRouteId) && (localCiId == cCurRouteBelongCiId) + && ((ROUTE_STATE_HALF_UNLOCK == cCurRouteState) + || (ROUTE_STATE_FIRST_LOCK == chNewRouteCurState) || (ROUTE_STATE_FIRST_LOCK == chNewRoutePreState) + || (ROUTE_STATE_FIRST_LOCK == cCurRouteState) || (ROUTE_STATE_FIRST_LOCK == chOldRoutePreState))) + { + /*ʱµIJڱĽ·ǰΪ֮ǰΪԭ״̬֮ǰҪͨŲã*/ + } + else + { + /*״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = LOG_SECTION_LOCK_NORMAL; + LogicSectionDataStru[bufIndex].LogLockBelongRoute = routeId; + LogicSectionDataStru[bufIndex].LogLockDir = lockDirection; + } + } + else + { + + } + } + /**/ + else if(LOG_SECTION_LOCK_EXCEPT == lockState) + { + SetRouFirDelayErlockStaCycNum(routeId, 0U); + routeBelongCi = GetRouteBelongCiId(LogicSectionDataStru[bufIndex].LogLockBelongRoute); + /*֮ǰղڱ*/ + if(routeBelongCi != localCiId) + { + /*ٴղڱڱ״̬dzʼֵ*/ + if((expRouteBelongCi != localCiId) || (LOG_SECTION_LOCK_START == LogicSectionDataStru[bufIndex].LogLockState) + || (0U == LogicSectionDataStru[bufIndex].LogLockState)) + { + /*״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = lockState; + LogicSectionDataStru[bufIndex].LogLockBelongRoute = routeId; + LogicSectionDataStru[bufIndex].LogLockDir = lockDirection; /*YF0083-2431·ڱгڴηɳγֹգø߼ηΪ0*/ + } + else + { + + } + } + else + { + + } + } + /*ʱ*/ + else if(LOG_SECTION_LOCK_DELAY == lockState) + { + if(expRouteBelongCi != localCiId) + { + if(LOG_SECTION_LOCK_NO != LogicSectionDataStru[bufIndex].LogLockState) + { + /*״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = lockState; + LogicSectionDataStru[bufIndex].LogLockDir = lockDirection; + LogicSectionDataStru[bufIndex].LogLockBelongRoute = routeId; + } + else + { + + } + } + else + { + + } + } + else if (LOG_SECTION_LOCK_PROTECT == lockState) + { + /**/ + cCurRouteBelongCiId = GetRouteBelongCiId(LogicSectionDataStru[bufIndex].LogLockBelongRoute); + if (logBelongCi != localCiId) + { + if ((localCiId == cCurRouteBelongCiId) && (localCiId == expRouteBelongCi)) + { + /*ZHG⣬ǰ··ͷ·Ϊˢ״̬*/ + } + else + { + LogicSectionDataStru[bufIndex].LogLockState = lockState; + + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = routeId; + LogicSectionDataStru[bufIndex].LogLockDir = lockDirection; /*շ*/ + if (LogicSectionDataStru[bufIndex].LogLockBelongRoute != 0u) + { + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0u; + } + else + { + + } + } + } + else + { + if ((localCiId != cCurRouteBelongCiId) && (cCurRouteBelongCiId == expRouteBelongCi)) + { + /*ΪZHG···δ״̬*/ + LogicSectionDataStru[bufIndex].LogLockState = lockState; + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = routeId; + LogicSectionDataStru[bufIndex].LogLockDir = lockDirection; /*շ*/ + if (0U != LogicSectionDataStru[bufIndex].LogLockBelongRoute) + { + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0U; + } + else + { + /**/ + } + } + else + { + /*߼ΪηԼ*/ + } + } + } + else + { + /**/ + } + } + else + { + + } +} + +/* +* ȡָ߼Դг +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ Դг +*/ +UINT8 GetLogSecTrainInfoSum(const UINT16 wLogSectionId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if (LOGIC_SECTION_RES_SUM_MAX > LogicSectionDataStru[wBufIndex].chTrainInfoSum) + { + chRetVal = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + +/* +* ȡָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ NULL: ȡʧ +* !NULL: ߼ԴгϢ +*/ +LogicTrainResStruct *GetLogSecTrainInfo(const UINT16 wLogSectionId) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogicTrainResStruct * pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = (LogicTrainResStruct *)LogicSectionDataStru[wBufIndex].szTrainResData; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* ȡָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ NULL: ȡʧ +* !NULL: ߼ԴгϢ +* ޸bug YF0083-119 +*/ +LogicTrainResStruct *GetLogSecTrainInfoById(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chTrainSum = 0U; + UINT8 ii = 0U; + LogicTrainResStruct * pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chTrainSum = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].wTrainId == wTrnId) + { + pRetVal = (LogicTrainResStruct *)(&LogicSectionDataStru[wBufIndex].szTrainResData[ii]); + break; + } + else + { + + } + } + } + else + { + pRetVal = NULL; + } + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* Ƴָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ +* +*/ +void RemoveLogSecTrainInfoById(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chTrainSum = 0U; + UINT8 ii = 0U; + UINT8 chNeedKeepSum = 0U; + LogicTrainResStruct * pLogicTrainInfo = NULL; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chTrainSum = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].wTrainId == wTrnId) + { + ; /*ִ*/ + } + else + { + LogicSectionDataStru[wBufIndex].szTrainResData[chNeedKeepSum++] = LogicSectionDataStru[wBufIndex].szTrainResData[ii]; + } + } + LogicSectionDataStru[wBufIndex].chTrainInfoSum = chNeedKeepSum; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} +/* +* ȡǷг߼ձ־ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 GetLogSecTrainLockSendFlag(const UINT16 wLogSectionId,const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = CI_ERROR; + UINT8 chRRouteCheck = CI_ERROR; + UINT16 wRLockBelongRouteId = 0U; + UINT8 chLgcResShrFlag = 0U; + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogSectionId, wTrnId); + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wRLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + chRRouteCheck = CheckRouteStateNotYinDaoLock(wRLockBelongRouteId); + + chLgcResShrFlag = GetLogSecResShareFlag(wLogSectionId); + if (CI_SUCCESS == chRRouteCheck) + { + if ((LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState)) + { + if (LOGIC_SECTION_RES_SHARE_YES==chLgcResShrFlag) + { + chRetVal = CI_SUCCESS; + } + else if (NULL != pLogicSecTrainResInfo) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + + +/* +* ȡг߼۷״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ CI_ERROR +* CI_SUCCESS +* ޸bug YF0083-119 +*/ +UINT8 GetLogSecTrainReturnState(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = CI_ERROR; + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogSectionId, wTrnId); + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if (NULL != pLogicSecTrainResInfo) + { + chRetVal = pLogicSecTrainResInfo->chLogicReturnState; + } + else + { + + } + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + +/* +* ȡг߼Դ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ LOGIC_SECTION_RES_UNUSABLE +* LOGIC_SECTION_RES_USABLE +*/ +UINT8 GetLogSecTrainResUsableState(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = LOGIC_SECTION_RES_UNUSABLE; + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogSectionId, wTrnId); + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if (NULL != pLogicSecTrainResInfo) + { + chRetVal = pLogicSecTrainResInfo->chLogicResUsable; + } + else + { + chRetVal = LOGIC_SECTION_RES_UNUSABLE; + } + } + else + { + chRetVal = LOGIC_SECTION_RES_UNUSABLE; + } + return chRetVal; +} +/* +* г߼۷״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ CI_ERROR +* CI_SUCCESS +* ޸bug YF0083-119 +*/ +void SetLogSecTrainReturnState(const UINT16 wLogSectionId, const UINT16 wTrnId, const UINT8 chResReturnState) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogSectionId, wTrnId); + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if (NULL != pLogicSecTrainResInfo) + { + if ((LOGIC_SECTION_TRAIN_RETURN_NO == chResReturnState) + || (LOGIC_SECTION_TRAIN_RETURN_YES == chResReturnState)) + { + pLogicSecTrainResInfo->chLogicReturnState = chResReturnState; + } + else + { + + } + } + else + { + + } + } + else + { + ; + } +} +/* +* Ϊг߼ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ VOID +* qw.liu 2022-03-03 +*/ +void AddLogSecTrainRes(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + UINT16 wRLockBelongRouteId = 0U; + UINT8 autoRouteType = 0U; + UINT8 autoProtRouteType = 0U;/*·Զ*/ + UINT8 autoSigRouteType = 0U; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogSectionId, wTrnId); + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + /*ȡ߼ս·ID*/ + wRLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + if (0u != wRLockBelongRouteId) + { + /*ȡԶ·:ͨԶ·Զ۷·*/ + autoRouteType = GetRouteAutoRouteSetState(wRLockBelongRouteId); + /*ȡ·ǰǷΪԶźŽ·*/ + autoSigRouteType = GetRouteAutoSigSetState(wRLockBelongRouteId); + } + + if ((NULL == pLogicSecTrainResInfo) + && ((LOGIC_SECTION_RES_SUM_MAX-1U)> LogicSectionDataStru[wBufIndex].chTrainInfoSum)) + { + /*ǰ߼Ϊ·գκг*/ + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].wTrainId = wTrnId; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chTrainApplyState = LOGIC_SECTION_TRAIN_APPLY_NO; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicResUsable = LOGIC_SECTION_RES_UNUSABLE; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicReturnState = LOGIC_SECTION_TRAIN_RETURN_NO; + LogicSectionDataStru[wBufIndex].chTrainInfoSum += 1U; + } + else + { + } + + if ((ROUTE_AUTOROUTE_NORMAL == autoRouteType) + || (ROUTE_AUTOROUTE_NORMAL == autoProtRouteType) + || (ROUTE_AUTOSIGROUTE_YES == (ROUTE_AUTOSIGROUTE_YES & autoSigRouteType))) + { + ; /*Զ·Զź ȡԴ*/ + } + else + { + SetLogSecResShareFlag(wLogSectionId, LOGIC_SECTION_RES_SHARE_NO); + } + } + else + { + + } +} + +/* +* г߼ +* ˵ const UINT16 logSectionId, ߼ID, +* const UINT16 wTrnId гID +* ֵ VOID +*/ +void AddLogSecTrainResFromCI(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + UINT16 wRLockBelongRouteId = 0U; + UINT8 autoRouteType = 0U; + UINT8 autoProtRouteType = 0U;/*·Զ*/ + UINT8 autoSigRouteType = 0U; + UINT8 trainTransSta = 0U; + UINT8 trainInRoutePos = 0U; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogSectionId, wTrnId); + trainTransSta = GetTrainTransitmitStat(wTrnId); + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + /*ȡ߼ս·ID*/ + wRLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + if (0u != wRLockBelongRouteId) + { + /*ȡԶ·:ͨԶ·Զ۷·*/ + autoRouteType = GetRouteAutoRouteSetState(wRLockBelongRouteId); + /*ȡ·ǰǷΪԶźŽ·*/ + autoSigRouteType = GetRouteAutoSigSetState(wRLockBelongRouteId); + } + + if ((NULL == pLogicSecTrainResInfo) + && ((LOGIC_SECTION_RES_SUM_MAX - 1U)> LogicSectionDataStru[wBufIndex].chTrainInfoSum)) + { + /*ǰ߼Ϊ·գκг*/ + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].wTrainId = wTrnId; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chTrainApplyState = LOGIC_SECTION_TRAIN_APPLY_NO; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicResUsable = LOGIC_SECTION_RES_UNUSABLE; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicReturnState = LOGIC_SECTION_TRAIN_RETURN_NO; + LogicSectionDataStru[wBufIndex].chTrainInfoSum += 1U; + } + else + { + } + + if (TRANSMIT_STATE_GOOD == trainTransSta) + { + trainInRoutePos = dsuTrainMinHeadCrossSignal(wTrnId, wRLockBelongRouteId); + if ((ROUTE_AUTOROUTE_NORMAL == autoRouteType) + || (ROUTE_AUTOROUTE_NORMAL == autoProtRouteType) + || (ROUTE_AUTOSIGROUTE_YES == (ROUTE_AUTOSIGROUTE_YES & autoSigRouteType)) + || (TRAIN_ENTER_ROUTE_FULL == trainInRoutePos) + || (TRAIN_ENTER_ROUTE_TAIL == trainInRoutePos)) + { + ; /*Զ·Զź ȡԴ*/ + } + else + { + SetLogSecResShareFlag(wLogSectionId, LOGIC_SECTION_RES_SHARE_NO); + } + } + } + else + { + + } +} + +/* +* ߼·߼ԴгID +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT16 wTrainId г +* ֵ +*/ +void SetLogRouteLogSecResTrainId(const UINT16 wLogRouteId, const UINT16 wTrainId) +{ + UINT16 logSectionSum = 0u; /*߼*/ + UINT16* pLogIdBuff = NULL; + UINT16 ii = 0U; + UINT16 wLogicSecId = 0U; + UINT16 wBufIndex = 0u; /*±*/ + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + + if ((0U < wLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wLogRouteId) && (0U != wTrainId)) + { + /*ȡ·߼Ϣ*/ + logSectionSum = GetLogicalRouteInLogSecSum(wLogRouteId); + pLogIdBuff = GetLogicalRouteInLogSecId(wLogRouteId); + if ((0U != logSectionSum) && (NULL != pLogIdBuff)) + { + for (ii = 0U; ii < logSectionSum; ii++) + { + wLogicSecId = pLogIdBuff[ii]; + wBufIndex = GetlogSectionBufIndex(wLogicSecId); /*ȡ±*/ + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogicSecId, wTrainId); + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if ((NULL == pLogicSecTrainResInfo) + && ((LOGIC_SECTION_RES_SUM_MAX - 1U) > LogicSectionDataStru[wBufIndex].chTrainInfoSum)) + { + /*ǰ߼Ϊ·գκг*/ + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].wTrainId = wTrainId; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chTrainApplyState = LOGIC_SECTION_TRAIN_APPLY_NO; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicResUsable = LOGIC_SECTION_RES_UNUSABLE; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicReturnState = LOGIC_SECTION_TRAIN_RETURN_NO; + LogicSectionDataStru[wBufIndex].chTrainInfoSum += 1U; + } + else + { + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicReturnState = LOGIC_SECTION_TRAIN_RETURN_NO; + } + } + } + } + } + else + { + /*ηǷ*/ + } +} + +/* +* TIOCг߼ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 cTrainSumг +* UINT16* pTrainIdг +* ֵ VOID +* qw.liu 2022-03-03 +* ޸bug YF0083-119 +*/ +void AddLogSecOtherTIOCTrainRes(const UINT16 wLogSectionId, const UINT8 cTrainSum,UINT16* pTrainId) +{ + UINT16 bufIndex = 0u; + LogicSectionDataStruct * tmpLogicSectionDataStru = NULL; + UINT8 cTmpTrainSum = 0u; + LogicTrainResStruct szTmpTrainResData[LOGIC_SECTION_RES_SUM_MAX] = {0u}; + UINT8 i = 0u; + UINT8 j = 0u; + + if ((NULL != pTrainId) && (LOGIC_SECTION_RES_SUM_MAX >= cTrainSum)) + { + tmpLogicSectionDataStru = GetLogicSecData();/*᷵NULL*/ + bufIndex = GetlogSectionBufIndex(wLogSectionId); + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if (0u == cTrainSum) + { + tmpLogicSectionDataStru[bufIndex].chTrainInfoSum = 0u; + } + else + { + for (i = 0u; i < cTrainSum;i++) + { + for (j = 0u; j < tmpLogicSectionDataStru[bufIndex].chTrainInfoSum;j++) + { + if (pTrainId[i] == tmpLogicSectionDataStru[bufIndex].szTrainResData[j].wTrainId) + { + if (LOGIC_SECTION_RES_SUM_MAX > cTmpTrainSum) + { + szTmpTrainResData[cTmpTrainSum] = tmpLogicSectionDataStru[bufIndex].szTrainResData[j]; + cTmpTrainSum++; + } + else + { + + } + break; + } + else + { + ;/* ޴ */ + } + } + + if (j == tmpLogicSectionDataStru[bufIndex].chTrainInfoSum) + { + /* δҵӳ */ + if (LOGIC_SECTION_RES_SUM_MAX > cTmpTrainSum) + { + szTmpTrainResData[cTmpTrainSum].wTrainId = pTrainId[i]; + szTmpTrainResData[cTmpTrainSum].chTrainApplyState = LOGIC_SECTION_TRAIN_APPLY_NO; + szTmpTrainResData[cTmpTrainSum].chLogicResUsable = LOGIC_SECTION_RES_UNUSABLE; + szTmpTrainResData[cTmpTrainSum].chLogicReturnState = LOGIC_SECTION_TRAIN_RETURN_NO; + szTmpTrainResData[cTmpTrainSum].chLogicUnlockState = LOGIC_SECTION_TRAIN_UNLOCK_NO; + szTmpTrainResData[cTmpTrainSum].dwRcvUnlockCmdCyc = 0u; + cTmpTrainSum++; + } + else + { + + } + } + else + { + + } + } + + /* ں֮ԴϢд߼ */ + for (i = 0u; i < cTmpTrainSum; i++) + { + tmpLogicSectionDataStru[bufIndex].szTrainResData[i] = szTmpTrainResData[i]; + } + tmpLogicSectionDataStru[bufIndex].chTrainInfoSum = cTmpTrainSum; + } + } + else + { + + } + } + else + { + ;/* ޴ */ + } +} + + + +/* +* ߼гԴϢ +* ˵ UINT16 wLogSecId, ߼ID +* ֵ +*޸ģ߼·гϢ +*/ +void ClearLgcSecResTrain(UINT16 wLogSecId) +{ + UINT8 chTrainResSum = 0U; + UINT16 wBufIndex = 0U; + UINT8 ii = 0U; + UINT8 logRouteSum = 0; + UINT16 wTrainId = 0U; /*гID*/ + UINT16 chFlag = 0U; + UINT8 chNeedKeepSum = 0U; + chTrainResSum = GetLogSecTrainInfoSum(wLogSecId); + wBufIndex = GetlogSectionBufIndex(wLogSecId); + if ((LOGIC_SECTION_SUM_MAX <= wBufIndex)) + { + ; /**/ + } + else + { + for (ii = 0U; ii wBufIndex) + { + /*ȡ߼ս·ID*/ + wRLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + + /*ȡ·Ƿ·*/ + chRRouteCheck = CheckRouteStateNotYinDaoLock(wRLockBelongRouteId); + + if ((CI_TYPE_TCC == chLocalCiType) || (CI_TYPE_CLD == chLocalCiType)) + { + /* ȡ·*/ + chRouteType = GetConfigRouteType(wRLockBelongRouteId); + } + else + { + /* ȡ·*/ + chRouteType = GetRouteType(wRLockBelongRouteId); + } + + /*ȡ߼ιΡ·һ*/ + wLgcRelativePhy = GetLgcSecRelativePhySecId(wLogSectionId); + wRouteLastPhy = GetRouteLastPhySectionId(wRLockBelongRouteId); + + /*ȡԴ־*/ + chLgcResShareFlag = GetLogSecResShareFlag(wLogSectionId); + + /*Զ· || Զź :Զ*/ + + if (0u != wRLockBelongRouteId) + { + cRouteCId = GetRouteBelongCiId(wRLockBelongRouteId); + } + else + { + /*޲*/ + } + + if (0u != wRLockBelongRouteId) + { + /*ȡԶ·:ͨԶ·Զ۷·*/ + autoRouteType = GetRouteAutoRouteSetState(wRLockBelongRouteId); + /*ȡ·ǰǷΪԶźŽ·*/ + autoSigRouteType = GetRouteAutoSigSetState(wRLockBelongRouteId); + } + else + { + ; /**/ + } + + if ((ROUTE_TYPE_RETURN == chRouteType)&&(wLgcRelativePhy ==wRouteLastPhy)) + { + chLgcResReturn = LOGIC_SECTION_TRAIN_RETURN_YES; + } + else + { + chLgcResReturn = LOGIC_SECTION_TRAIN_RETURN_NO; + } + strTrainMinTail.wLinkId = GetTrainMinTailLink(wTrnId); + strTrainMinTail.dwOffset = GetTrainMinTailOffset(wTrnId); + wMinTailPointBelongLogSecId = GetPointBelongLogSec(strTrainMinTail); + trainInLockRoute = GetTrainInLgcPRLock(wLogSectionId, wMinTailPointBelongLogSecId); + chLgcSecResCanAdd = GetLgcSecResCanAdd(wLogSectionId, wTrnId); + if ((CI_SUCCESS == chRRouteCheck) && (ROUTE_TYPE_DIAOCHE != chRouteType)) + { + if (LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState) + { + if ((NULL == pLogicSecTrainResInfo) + && (((LOGIC_SECTION_RES_SHARE_YES == chLgcResShareFlag)&&(CI_SUCCESS == chLgcSecResCanAdd)) + || (CI_SUCCESS== trainInLockRoute))) + { + /*ûигԴҹԴгڽ·*/ + if ((0u != cLocalCiId) && ((cLocalCiId == cRouteCId))) + { + /*ǰ߼Ϊ·գκг*/ + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].wTrainId = wTrnId; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chTrainApplyState = LOGIC_SECTION_TRAIN_APPLY_YES; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicResUsable = LOGIC_SECTION_RES_UNUSABLE; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum].chLogicReturnState = chLgcResReturn; + LogicSectionDataStru[wBufIndex].chTrainInfoSum += 1U; + + + if ((ROUTE_AUTOROUTE_NORMAL == autoRouteType) + || (ROUTE_AUTOROUTE_NORMAL == autoProtRouteType) + || (ROUTE_AUTOSIGROUTE_YES == (ROUTE_AUTOSIGROUTE_YES & autoSigRouteType))) + { + ; /*Զ·Զź ȡԴ*/ + } + else + { + trainInRoutePos = dsuTrainMinHeadCrossSignal(wTrnId, wRLockBelongRouteId); + if ((TRAIN_ENTER_ROUTE_FULL == trainInRoutePos) || (TRAIN_ENTER_ROUTE_TAIL == trainInRoutePos)) + { + ; /* V12.0.22*/ + } + else + { + SetLogSecResShareFlag(wLogSectionId, LOGIC_SECTION_RES_SHARE_NO); + } + } + + } + else if(0u != cRouteCId) + { + /* ߼Դ */ + SetLogSecResReqOtherCIId(wLogSectionId,cRouteCId); + SetLogSecResReqTrainId(wLogSectionId, wTrnId); + } + else + { + /*޲*/ + } + } + else if (NULL != pLogicSecTrainResInfo) + { + pLogicSecTrainResInfo->chTrainApplyState = LOGIC_SECTION_TRAIN_APPLY_YES; + } + else + { + /*޲*/ + } + } + else + { + + } + } + else + { + + } + } + else + { + + } +} + +/* +* ȡָг߼չ߼·ID +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ =0ڸó߼·>0 ó߼·ID +*/ +UINT16 GetLogSecBelongLogRouteId(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRLockBelongLogRouteId = 0U; + UINT8 wLogSecLockBelLogRouteSum = 0U; + UINT16 wLogicalRouteApplyResTrainId = 0U; + UINT16 retVal = 0U; + UINT8 ii = 0U; + LogSecLockBelLogRouteStruct* pLogSecLockBelLogRouteData = NULL;/*߼߼·*/ + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wLogSecLockBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogSectionId); + pLogSecLockBelLogRouteData = GetLogSecLockBelLogRouteData(wLogSectionId); + if (NULL != pLogSecLockBelLogRouteData) + { + for (ii = 0U; ii < wLogSecLockBelLogRouteSum; ii++) + { + wRLockBelongLogRouteId = pLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId; + wLogicalRouteApplyResTrainId = GetLogicalRouteApplyResTrainId(wRLockBelongLogRouteId); + + if (wTrnId == wLogicalRouteApplyResTrainId) + { + retVal = wRLockBelongLogRouteId; + break; + } + } + } + } + return retVal; +} + + +/* +* ߼·г߼ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ VOID +*/ +void SetLogRouteLogSecTrainLockApply(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT8 wLogSecLogLockState = 0U; + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogSectionId, wTrnId); + wLogSecLogLockState = GetLogSecLogLockState(wLogSectionId); + if (LOG_SECTION_LOGLOCK_NORMAL == wLogSecLogLockState) + { + if (NULL != pLogicSecTrainResInfo) + { + pLogicSecTrainResInfo->chTrainApplyState = LOGIC_SECTION_TRAIN_APPLY_YES; + } + else + { + /*޲*/ + } + } +} + +/* +* ȡָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ NULL: ȡʧ +* !NULL: ߼ԴгϢ +*/ +UINT8 GetLgcSecResCanAdd(const UINT16 wLogSectionId,const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRLockBelongRouteId = 0U; + UINT16 wRLockStartSignalId = 0U; + UINT16 wPLockStartSignalId = 0U; + UINT16 wPLockEndSignalId = 0U; + UINT16 wRLockLightUpTrainId = 0U; + UINT16 wPLockLightUpTrainId = 0U; + UINT16 wRouteLockOverLapId = 0U; + UINT8 chOverLapBelongCiId = 0U; + UINT8 chTrainCrossPLockStt = 0U; + UINT8 chTrainCrossRLockStt = 0U; + UINT8 cRouteCId = 0u; + UINT8 cLocalCiId = 0u; + UINT8 chLgcResShareFlag = 0U; + UINT8 autoRouteType = 0U; + UINT8 autoSigRouteType = 0U; + UINT8 autoProtRouteType = 0U; + UINT8 chLocalTiocCanAddFlag = CI_ERROR; + UINT8 chHitSoftWallSwitch = 0U;/*ײǽ״̬*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + cLocalCiId = GetSystemParaLocalCiId(); + chHitSoftWallSwitch = GetHitSoftWallSwitch(); + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + /*ȡ߼ս·ID*/ + wRLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + + if (0u != wRLockBelongRouteId) + { + cRouteCId = GetRouteBelongCiId(wRLockBelongRouteId); + } + else + { + /*޲*/ + } + if (0u != wRLockBelongRouteId) + { + /*ȡԶ·:ͨԶ·Զ۷·*/ + autoRouteType = GetRouteAutoRouteSetState(wRLockBelongRouteId); + /*ȡ·ǰǷΪԶźŽ·*/ + autoSigRouteType = GetRouteAutoSigSetState(wRLockBelongRouteId); + /* ȡ·ʼźŻID*/ + wRLockStartSignalId = GetRouteStartSignalId(wRLockBelongRouteId); + wRLockLightUpTrainId = GetSignalLightUpTrainId(wRLockStartSignalId); + chTrainCrossRLockStt = dsuTrainCrossSignal(wTrnId, wRLockBelongRouteId); + } + else + { + ; /**/ + } + + if (0U != cLocalCiId) + { + if (cLocalCiId == cRouteCId) + { + if ((wTrnId & 0x00ffU) == wRLockLightUpTrainId) + { + chLocalTiocCanAddFlag = CI_SUCCESS; + } + else + { + if ((TRAIN_ENTER_ROUTE_FULL == chTrainCrossRLockStt) || (TRAIN_ENTER_ROUTE_TAIL == chTrainCrossRLockStt)) /*ȱYF0083-9522023-07-03*/ + { + + chLocalTiocCanAddFlag = CI_SUCCESS; + } + else + { + ; /**/ + } + } + } + else if (0U != wRLockBelongRouteId) + { + chLocalTiocCanAddFlag = CI_SUCCESS; + } + else + { + ; /**/ + } + + /*ײǽأعرգԶ·/ԶźҲֻӽгԴ*/ + if (((ROUTE_AUTOROUTE_NORMAL == autoRouteType) + || (ROUTE_AUTOROUTE_NORMAL == autoProtRouteType) + || (ROUTE_AUTOSIGROUTE_YES == (ROUTE_AUTOSIGROUTE_YES & autoSigRouteType))) + && (FUNC_HITSOFTWALL_ON == chHitSoftWallSwitch)) + { + chLocalTiocCanAddFlag = CI_SUCCESS; /*Զ·Զź ȡԴ*/ + } + else + { + ; /**/ + } + } + else + { + chLocalTiocCanAddFlag = CI_ERROR; + } + } + return chLocalTiocCanAddFlag; +} + + +/* +* ȡгǷ߼· +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ CI_ERROR: +* CI_SUCCESS: +*/ +UINT8 GetTrainInLgcPRLock(const UINT16 wLogSectionId, const UINT16 wMinTailPointBelongLogSecId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRLockBelongRouteId = 0U; + UINT16 wTrainMinTailLockBelongRouteId = 0U; + UINT8 cLocalCiId = 0u; + UINT8 chLocalTiocCanAddFlag = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + cLocalCiId = GetSystemParaLocalCiId(); + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + /*ȡ߼ս·ID*/ + wRLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + + if ((0U != cLocalCiId)&&(0U!=wRLockBelongRouteId)) + { + + wTrainMinTailLockBelongRouteId = GetLogSecLockBelongRoute(wMinTailPointBelongLogSecId); + if (wRLockBelongRouteId == wTrainMinTailLockBelongRouteId) + { + chLocalTiocCanAddFlag = CI_SUCCESS; + } + else + { + ; /*DO NOTHING*/ + } + } + else + { + ; /*DO NOTHING*/ + } + } + else + { + chLocalTiocCanAddFlag = CI_ERROR; /*쳣±꣬ش*/ + } + return chLocalTiocCanAddFlag; +} + +/* +* ȡָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ NULL: ȡʧ +* !NULL: ߼ԴгϢ +*/ +UINT16 GetLogSecTrainIdByIndex(const UINT16 wLogSectionId, const UINT8 chIndex) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRetVal = 0U; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + + if (LOGIC_SECTION_RES_SUM_MAX > chIndex) + { + + wRetVal = LogicSectionDataStru[wBufIndex].szTrainResData[chIndex].wTrainId; + } + else + { + wRetVal = 0U; + } + } + else + { + wRetVal = 0U; + } + return wRetVal; +} + +/* +* г߼ο״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* const UINT8 chUseState ״̬ +* ֵ VOID +* ޸bug YF0083-119 +*/ +void SetLogSecTrainUseState(const UINT16 wLogSectionId, const UINT16 wTrnId,const UINT8 chUseState) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chTrainSum = 0U; + UINT8 ii = 0U; + UINT8 chLogRouteLogicLockState = 0U; /*߼·߼״̬*/ + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + chLogRouteLogicLockState = GetLogSecLogLockState(wLogSectionId); + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chTrainSum = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + if ((LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOGLOCK_NORMAL == chLogRouteLogicLockState)) + { + if ((LOGIC_SECTION_RES_USABLE == chUseState) + || (LOGIC_SECTION_RES_UNUSABLE == chUseState)) + { + + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].wTrainId == wTrnId) + { + LogicSectionDataStru[wBufIndex].szTrainResData[ii].chLogicResUsable = chUseState; + break; + } + else + { + + } + } + } + else + { + + } + } + else + { + + } + } + else + { + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].wTrainId == wTrnId) + { + LogicSectionDataStru[wBufIndex].szTrainResData[ii].chLogicResUsable = LOGIC_SECTION_RES_UNUSABLE; + break; + } + else + { + + } + } + } + else + { + + } + } + } + else + { + + } +} + +/* +* ȡг߼״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ 0ʧ 0x55: 0xaa:δ +* ޸bug YF0083-119 +*/ +UINT8 GetLogSecTrainApply(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chTrainSum = 0U; + UINT8 ii = 0U; + UINT8 chRetVal = 0U; + UINT8 chLogRouteLogicLockState = 0U; /*߼·߼״̬*/ + chLogRouteLogicLockState = GetLogSecLogLockState(wLogSectionId); + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if ((LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOGLOCK_NORMAL == chLogRouteLogicLockState)) + { + + chTrainSum = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].wTrainId == wTrnId) + { + chRetVal = LogicSectionDataStru[wBufIndex].szTrainResData[ii].chTrainApplyState; + break; + } + else + { + + } + } + } + else + { + chRetVal = 0U; + } + } + else + { + chRetVal = 0U; + } + } + else + { + chRetVal = 0U; + } + + return chRetVal; +} + +/* +* г߼ͷ״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* const UINT8 chUseState ״̬ +* const UINT8 chTrainlevel г𣺱0 VBTVΪ0X03 UR 0X01 +* ֵ VOID +* ޸bug YF0083-119 +*/ +void SetLogSecTrainRelease(const UINT16 wLogSectionId, const UINT16 wTrnId, const UINT8 chTrainlevel) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chTrainSum = 0U; + UINT8 ii = 0U; + UINT32 dwCurCycNum = 0U; + UINT8 wLogSecLogLockState = 0U; + dwCurCycNum = Get2oo2CurCycleNum(); + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wLogSecLogLockState = GetLogSecLogLockState(wLogSectionId); + if ((LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOGLOCK_NORMAL == wLogSecLogLockState)) + { + chTrainSum = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].wTrainId == wTrnId) + { + LogicSectionDataStru[wBufIndex].szTrainResData[ii].chLogicUnlockState = LOGIC_SECTION_TRAIN_UNLOCK_YES; + LogicSectionDataStru[wBufIndex].szTrainResData[ii].dwRcvUnlockCmdCyc = dwCurCycNum; + LogicSectionDataStru[wBufIndex].szTrainResData[ii].chTrainLevel = chTrainlevel; + break; + } + else + { + + } + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ȡг߼ͷ״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ 0ʧ 0x55: 0xaa:δ +*/ +UINT8 GetLogSecTrainRelease(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chTrainSum = 0U; + UINT8 ii = 0U; + UINT8 chRetVal = 0U; + UINT32 dwCurCycNum = 0U; + UINT8 wLogSecLogLockState = 0U; + dwCurCycNum = Get2oo2CurCycleNum(); + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wLogSecLogLockState = GetLogSecLogLockState(wLogSectionId); + if ((LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOGLOCK_NORMAL == wLogSecLogLockState)) + { + + chTrainSum = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].wTrainId == wTrnId) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].dwRcvUnlockCmdCyc == dwCurCycNum) + { + /*յ Ч*/ + chRetVal = LogicSectionDataStru[wBufIndex].szTrainResData[ii].chLogicUnlockState; + } + else + { + chRetVal = LOGIC_SECTION_TRAIN_UNLOCK_NO; + } + break; + } + } + } + else + { + chRetVal = 0U; + } + } + else + { + chRetVal = 0U; + } + } + else + { + chRetVal = 0U; + } + + return chRetVal; +} + +/* +* ȡ߼Դͷ״̬г򷵻룩 +* ˵ const UINT16 wLogSectionId, ߼ID +* ֵ 0ʧ 0x55: 0xaa:δ +*/ +UINT8 GetLogSecReleaseFlag(const UINT16 wLogSectionId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chTrainSum = 0U; + UINT8 ii = 0U; + UINT8 chRetVal = LOGIC_SECTION_TRAIN_UNLOCK_NO; + UINT32 dwCurCycNum = 0U; + dwCurCycNum = Get2oo2CurCycleNum(); + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if ((LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState)) + { + + chTrainSum = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if ((LogicSectionDataStru[wBufIndex].szTrainResData[ii].dwRcvUnlockCmdCyc == dwCurCycNum) + &&(LOGIC_SECTION_TRAIN_UNLOCK_YES == LogicSectionDataStru[wBufIndex].szTrainResData[ii].chLogicUnlockState)) + { + /*յ Ч*/ + chRetVal = LogicSectionDataStru[wBufIndex].szTrainResData[ii].chLogicUnlockState; + break; + } + else + { + chRetVal = LOGIC_SECTION_TRAIN_UNLOCK_NO; + } + } + } + else + { + chRetVal = LOGIC_SECTION_TRAIN_UNLOCK_NO; + } + } + else + { + chRetVal = LOGIC_SECTION_TRAIN_UNLOCK_NO; + } + } + else + { + chRetVal = LOGIC_SECTION_TRAIN_UNLOCK_NO; + } + + return chRetVal; +} + +/* +* ȡ߼ͷг +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ 0г 0x03:VBTC 0x01:VBTC +*/ +UINT8 GetLogSecReleaseTrainLevel(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chTrainSum = 0U; + UINT8 ii = 0U; + UINT8 chRetVal = TRAIN_LEVEL_UR; + UINT32 dwCurCycNum = 0U; + UINT8 wLogSecLogLockState = 0U; + dwCurCycNum = Get2oo2CurCycleNum(); + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wLogSecLogLockState = GetLogSecLogLockState(wLogSectionId); + if ((LOG_SECTION_LOCK_PROTECT == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState) + || (LOG_SECTION_LOGLOCK_NORMAL == wLogSecLogLockState)) + { + + chTrainSum = LogicSectionDataStru[wBufIndex].chTrainInfoSum; + if (LOGIC_SECTION_RES_SUM_MAX > chTrainSum) + { + for (ii = 0U; ii < chTrainSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].wTrainId == wTrnId) + { + if (LogicSectionDataStru[wBufIndex].szTrainResData[ii].dwRcvUnlockCmdCyc == dwCurCycNum) + { + /*յ Ч*/ + chRetVal = LogicSectionDataStru[wBufIndex].szTrainResData[ii].chTrainLevel; + } + else + { + chRetVal = TRAIN_LEVEL_UR; + } + break; + } + } + } + else + { + chRetVal = 0U; + } + } + else + { + chRetVal = 0U; + } + } + else + { + chRetVal = 0U; + } + + return chRetVal; +} + +#if 0 +/* +* гͷ߼Դ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 wTrnIdгID +* ֵ VOID +*/ +void LogSecTrainLockRelease(const UINT16 wLogSectionId, const UINT16 wTrnId) +{ + UINT16 wBufIndex = 0u; /*±*/ + LogicTrainResStruct * pLogicSecTrainResInfo = NULL; + UINT8 routeDir = 0u; + UINT16 i = 0u; + UINT16 j = 0u; + UINT16 routeId = 0u; + UINT16 logBelongAxisId = 0u; /*߼ļ*/ + UINT16 logBelongPhyId = 0u; + UINT8 checkValue = 0u; + UINT16 logRoute = 0u; + UINT8 logUlockState = 0u; + UINT16* routeLogIdBuf = NULL; + UINT16 fLockLogId = 0u; + UINT16 dlockLogId = 0u; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ߼±*/ + pLogicSecTrainResInfo = GetLogSecTrainInfoById(wLogSectionId, wTrnId); + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if((NULL != pLogicSecTrainResInfo) + &&(1u == LogicSectionDataStru[wBufIndex].chTrainInfoSum) + &&((LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState)||(LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState))) + { + /*߼ֻһгԴ,屾Դ*/ + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum-1u].wTrainId = 0u; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum-1u].chTrainApplyState = LOGIC_SECTION_TRAIN_APPLY_NO; + LogicSectionDataStru[wBufIndex].szTrainResData[LogicSectionDataStru[wBufIndex].chTrainInfoSum-1u].chLogicResUsable = LOGIC_SECTION_RES_USABLE; + LogicSectionDataStru[wBufIndex].chTrainInfoSum -= 1u; + /*ȡ·ID·򣬽·һյ߼*/ + routeId = GetLogSecLockBelongRoute(wLogSectionId); + routeDir = GetRouteDirection(routeId); + routeLogIdBuf = GetRouteLogSectionIdBuf(routeId); + fLockLogId = GetRouteFirstNormalLockLogId(routeId); + dlockLogId = GetRouteFirstDelayLockLogId(routeId); + if((wLogSectionId == routeLogIdBuf[0])&&((wLogSectionId == fLockLogId)||(wLogSectionId == dlockLogId))) + {/*߼,ʱ·״̬ת*/ + SetLogSecLockState(wLogSectionId,LOG_SECTION_LOCK_NO,routeId,routeDir); + SetLogUnlockStartCycNum(wLogSectionId,0u); + SetRouteStateManage(routeId, ROUTE_STATE_AUTO_UNLOCK); + } + else if((wLogSectionId == fLockLogId)||(wLogSectionId == dlockLogId)) + {/*߼νʱ*/ + SetLogSecLockState(wLogSectionId,LOG_SECTION_LOCK_NO,routeId,routeDir); + SetLogUnlockStartCycNum(wLogSectionId,0u); + } + else + { + /*˳壬*/ + } + logBelongAxisId = GetLogSecBelongAxisSecId(wLogSectionId); + logBelongPhyId = GetAxisSecRelativePhySecId(logBelongAxisId); + checkValue = CheckPhyInLogUlock(logBelongPhyId,routeId,&logRoute); + if(CI_SUCCESS == checkValue) + { + if(logBelongPhyId == GetRouteLastSwichPhySecId(routeId)) + { + /*·յ,˴Խķ*/ + SetRouteRelatedProtectSwitchLockState(routeId, SWITCH_LOCK_PROTECT_CANCEL); + } + if(0u == logRoute) + { /*߼ȫҲ߼·,ν*/ + SetPhySecLockState(logBelongPhyId, PHYSICAL_SECTION_LOCK_NO, routeId, routeDir); + } + } + logUlockState = CheckRouteLogSecHaveUnLock(routeId); + if(CI_SUCCESS == logUlockState) + { + /*·ȫ*/ + if (ROUTE_STATE_FLAG_YES == GetRouteStateFlag(routeId)) + {/*CBTC׷ٰ·־Ч򲻸ı·״̬Զʱ·ȫ*/ + } + else + {/*CBTC׷ٰ·־Чý·*/ + SetRouteStateManage(routeId, ROUTE_STATE_IDLE); /*ý·*/ + } + } + } + else if((NULL != pLogicSecTrainResInfo) + &&(1u < LogicSectionDataStru[wBufIndex].chTrainInfoSum) + &&((LOG_SECTION_LOCK_NORMAL == LogicSectionDataStru[wBufIndex].LogLockState)||(LOG_SECTION_LOCK_DELAY == LogicSectionDataStru[wBufIndex].LogLockState))) + { + /*߼жгԴ,屾ID,г*/ + for(i = 0u;i < LogicSectionDataStru[wBufIndex].chTrainInfoSum;i++) + { + if(wTrnId == LogicSectionDataStru[wBufIndex].szTrainResData[i].wTrainId) + { + j = i; + } + else + { + LogicSectionDataStru[wBufIndex].szTrainResData[j].wTrainId = LogicSectionDataStru[wBufIndex].szTrainResData[i].wTrainId; + LogicSectionDataStru[wBufIndex].szTrainResData[j].chTrainApplyState == LogicSectionDataStru[wBufIndex].szTrainResData[i].chTrainApplyState; + LogicSectionDataStru[wBufIndex].szTrainResData[j].chLogicResUsable == LogicSectionDataStru[wBufIndex].szTrainResData[i].chLogicResUsable; + j += 1u; + } + } + LogicSectionDataStru[wBufIndex].chTrainInfoSum -= 1u; + } + else + { + /*߼г룬*/ + } + + } + else + { + /*߼IDϷ*/ + } + +} +#endif + +/* +* ָ߼η·ID +* ˵const UINT16 wLogSectionId ߼ID +* const UINT16 wPLockRouteId ·ID +* ֵ +* Created By LQ 2024.06.11 +*/ +void SetLogSecPLockRouteId(const UINT16 wLogSectionId, const UINT16 wPLockRouteId) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if ((LOGIC_SECTION_SUM_MAX > wBufIndex) && (ROUTE_SUM_MAX > wPLockRouteId)) + { + LogicSectionDataStru[wBufIndex].wPLockBelongRouteId = wPLockRouteId; /*÷·ID*/ + } + else + { + /*ηǷ*/ + } +} + +/* +* ȡָ߼· +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼· +*/ +UINT16 GetLogSecPLockRouteId(const UINT16 logSectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].wPLockBelongRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡ߼ηԴID +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0u +* ID +*/ +UINT8 GetLogSecResReqOtherCIId(const UINT16 wLogSectionId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = 0u; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chRetVal = LogicSectionDataStru[wBufIndex].cResReqOtherCIId; + } + else + { + ;/* 0u */ + } + return chRetVal; +} +/* +* ߼ηԴID +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 cOtherId,ID +* +*/ +void SetLogSecResReqOtherCIId(const UINT16 wLogSectionId, const UINT8 cOtherId) +{ + UINT16 wBufIndex = 0u; /*±*/ + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + LogicSectionDataStru[wBufIndex].cResReqOtherCIId = cOtherId; + } + else + { + ; + } +} + +/* +* ȡ߼ηCIԴгID +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0u +* гID +*/ +UINT16 GetLogSecResReqTrainId(const UINT16 wLogSectionId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 chRetVal = 0u; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chRetVal = LogicSectionDataStru[wBufIndex].wResReqTrainId; + } + else + { + ;/* 0u */ + } + return chRetVal; +} +/* +* ߼ηCIԴгID +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 wTrainId,гID +* +*/ +void SetLogSecResReqTrainId(const UINT16 wLogSectionId, const UINT16 wTrainId) +{ + UINT16 wBufIndex = 0u; /*±*/ + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + LogicSectionDataStru[wBufIndex].wResReqTrainId = wTrainId; + } + else + { + ; + } +} + +/** +* @brief ߼Դ۷״̬ +* @param UINT16 wLogicId +* @param UINT8 chFlag +* @return +*/ +void SetLogSecAllTrainReturnState(const UINT16 wLogicId, const UINT8 chFlag) +{ + UINT8 chTrainSum = 0u; + LogicTrainResStruct * pTrainInLogic = NULL; + UINT8 chTrainIndex = 0u; + UINT16 wTrainId = 0u; + + chTrainSum = GetLogSecTrainInfoSum(wLogicId); + pTrainInLogic = GetLogSecTrainInfo(wLogicId); + + if (0u == chTrainSum) + { + ; + } + else + { + for (chTrainIndex = 0u; chTrainIndex < chTrainSum; chTrainIndex++) + { + wTrainId = pTrainInLogic[chTrainIndex].wTrainId; + SetLogSecTrainReturnState(wLogicId, wTrainId, chFlag); + } + } +} + +/** +* @brief ߼ռ״̬ +* @param +* @return +*/ +void SetAllLgcOccupyState(void) +{ + UINT16 wLgcSum = 0u; + UINT16 wIndex = 0u; + UINT16 wLgcId = 0u; + UINT8 chLgcStatus = 0u; + + wLgcSum = GetTotalLogSecCurNum(); + for (wIndex = 0u; wIndex < wLgcSum; wIndex++) + { + wLgcId = GetLogicSecId(wIndex); + chLgcStatus = ssp_GetSecStatus(wLgcId); + if (STATUS_CT == chLgcStatus) + {/* ߼VBTCռãͨų */ + SetLogSecOccupyState(wLgcId, LOGICSECTION_OCCUPY_CT); + SetLogSecTXOccupyState(wLgcId, LOGICSECTION_OCCUPY_TX); + } + else if (STATUS_FREE == chLgcStatus) + {/* ߼οУͨų */ + SetLogSecOccupyState(wLgcId, LOGICSECTION_OCCUPY_NO); + SetLogSecTXOccupyState(wLgcId, LOGICSECTION_OCCUPY_NO_TX); + + } + else if(STATUS_AT == chLgcStatus) + {/* ߼ͨRMռãUTͨų */ + SetLogSecOccupyState(wLgcId, LOGICSECTION_OCCUPY_UT); + SetLogSecTXOccupyState(wLgcId, LOGICSECTION_OCCUPY_TX); + } + else + {/* ߼UTռ */ + SetLogSecOccupyState(wLgcId, LOGICSECTION_OCCUPY_UT); + SetLogSecTXOccupyState(wLgcId, LOGICSECTION_OCCUPY_NO_TX); + } + } +} + +/* +* @brief ȡָID߼ιԴ־ +* @param const UINT16 wLgcSecId, ߼ID +* @return 0x55: Դ +* 0xaa: ǹԴ +* CI_ERROR:ʧ +*/ +UINT8 GetLogSecResShareFlag(const UINT16 wLgcSecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 funRetVal = 0u; + + /*ȡ±*/ + bufIndex = GetlogSectionBufIndex(wLgcSecId); + + /*±ǷϷ*/ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /*ش洢±*/ + funRetVal = LogicSectionDataStru[bufIndex].chResShareFlag; + } + else + { + /*ش*/ + funRetVal = CI_ERROR; + } + return funRetVal; +} + +/* +* @brief ָID߼ιԴ־ +* @param const UINT16 wLgcSecId, ߼ID +* @param const UINT16 chShrFlag, Դ־ +* @return +*/ +void SetLogSecResShareFlag(const UINT16 wLgcSecId, const UINT8 chShrFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(wLgcSecId); /*ȡ±*/ + + /*±ǷϷ*/ + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + /*־״̬ǷϷ*/ + if ((LOGIC_SECTION_RES_SHARE_YES == chShrFlag) || + (LOGIC_SECTION_RES_SHARE_NO == chShrFlag)) + { + /*ñ־λ*/ + LogicSectionDataStru[bufIndex].chResShareFlag = chShrFlag; /*߼ιԴ־*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ɾָ߼гԴ +* ˵ UINT16 wLogSecId, ߼ID +* UINT8 chTrainId ɾгԴ± +* ֵ +*/ +void RemoveLgcSecResTrain(UINT16 wLogSecId, UINT16 wTrainId) +{ + UINT8 jj = 0U; + UINT16 wLgcResTrainId= 0U; + UINT8 chLgcResTrainSum = 0U; + UINT8 chKeepWork = CI_ERROR; + UINT16 wLgcBufIndex = 0U; + UINT8 chNeedKeepSum = 0U; + + LogicSectionDataStruct *pstLgcSecInfo = NULL; + chLgcResTrainSum = GetLogSecTrainInfoSum(wLogSecId); + pstLgcSecInfo = GetLogicSecData(); + wLgcBufIndex = GetlogSectionBufIndex(wLogSecId); + if ((NULL!=pstLgcSecInfo) + &&(CI_ERROR != chLgcResTrainSum)) + { + chKeepWork = CI_SUCCESS; /*ִ*/ + } + else + { + chKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == chKeepWork) + { + chNeedKeepSum = 0U; + for (jj = 0U; jj < chLgcResTrainSum; jj++) + { + wLgcResTrainId = GetLogSecTrainIdByIndex(wLogSecId, jj); + + if (wLgcResTrainId == wTrainId) + { + /*ɾгӦ߼Դ*/ + (void)ComMemSet((void *)&pstLgcSecInfo[wLgcBufIndex].szTrainResData[jj], (UINT16)sizeof(LogicTrainResStruct), 0U); + debug_infor_printf((const)"LogSecRes Remove LgcId: %d TrainId:%d Cyc\n" + , wLogSecId + , wTrainId + , Get2oo2CurCycleNum()); + } + else + { + pstLgcSecInfo[wLgcBufIndex].szTrainResData[chNeedKeepSum++] = pstLgcSecInfo[wLgcBufIndex].szTrainResData[jj]; + } + + } + pstLgcSecInfo[wLgcBufIndex].chTrainInfoSum = chNeedKeepSum; + } + else + { + } +} + +/* +* TIOC߼ʱٱ־ +* ˵ +* ֵ +*/ +void ClearLocalTiocLogSecTsr(void) +{ + UINT16 wLgcSum = 0u; + UINT16 wIndex = 0u; + UINT16 wLgcId = 0u; + UINT8 cLogSecTiocId = 0u; + UINT8 cLocalTiocId = 0u; + + cLocalTiocId = GetSystemParaLocalCiId(); + wLgcSum = GetLogicSecCurSum(); + for (wIndex = 0u; wIndex < wLgcSum; wIndex++) + { + wLgcId = GetLogicSecId(wIndex); + cLogSecTiocId = GetLogSecBelongCiId(wLgcId); + + if ((cLocalTiocId == cLogSecTiocId) && (0u != cLocalTiocId)) + { + /* ñı־λ */ + SetLogSecLinShiXianSuState(wLgcId, LOGSEC_LSXS_SET_STATE_NO); + } + } +} + +/* +* ȡʱ +* ˵ +* ֵ +*/ +UINT8 GetTsrSum(void) +{ + return g_TsrSum; +} + +/* +* ȡָ߼ηλСʱֵ +* ˵UINT16* minSpeed Сʱֵ() +* UINT16 logSum ߼() +* UINT16 szLogId[] ߼ID() +* ֵ CI_ERROR ȡʧ +* CI_SUCCESS ȡɹ +*/ +UINT8 GetBackUpVobcMinTsr(UINT16* minSpeed, UINT16 logSum, UINT16 szLogId[]) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 cTsrSum = 0U; + TsrDataStruct* pTsrData = NULL; + UINT8 jj = 0u; + UINT8 kk = 0U; + UINT8 mm = 0U; + + pTsrData = GetTsrData(); + + if (NULL != szLogId) + { + /* ȡ */ + cTsrSum = GetTsrSum(); + + if (TSR_MAX_SUM >= cTsrSum) + { + chRetVal = CI_SUCCESS; + for (jj = 0u; jj < cTsrSum; jj++) + { + if (pTsrData[jj].cSpeed < *minSpeed) + { + for (mm == 0U; mm < pTsrData[jj].cLogSecSum; mm++) + { + for (kk = 0U; kk < logSum; kk++) + { + if (pTsrData[jj].szLogSecId[mm] == szLogId[kk]) + { + *minSpeed = pTsrData[jj].cSpeed; + } + else + { + ; /*ڲѯΧڵIJжϣѯΧǰվ̨ⷽһ߼*/ + } + } + } + } + else + { + ; /*ٶȴIJǣС*/ + } + } + } + else + { + /*ʱ ֹͣ*/ + chRetVal = CI_ERROR; + } + } + else + { + ; /*δ󷵻ʧ*/ + } + + return chRetVal; +} +/* +* ʱ +* ˵ UINT8 cTsrSum +* ֵ +*/ +void SetTsrSum(UINT8 cTsrSum) +{ + if (TSR_MAX_SUM >= cTsrSum) + { + g_TsrSum = cTsrSum; + } +} + +/* +* ȡʱ +* ˵ +* ֵ +*/ +TsrDataStruct* GetTsrData(void) +{ + return &g_TsrDataStru; +} + +/* +* ʱʱ +* ˵ UINT8 cTsrSum +* TsrDataStruct* TsrData +* ֵ CI_ERRORʧ;CI_SUCCESS ɹ +*/ +UINT8 SetLocalTsrData(UINT8 cTsrSum, TsrDataStruct* pTsrData,UINT8 cAllLineTsrState, UINT8 cAllLineTsrSpeed) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 i = 0u; + UINT8 j = 0u; + UINT8 x = 0u; + UINT16 wLocalLogSecSum = 0u; + UINT16 wLogSecId = 0u; + UINT8 cLogSecTiocId = 0u; + UINT8 cTiocId = 0u; + UINT8 cLogSecTsrState = LOGSEC_LSXS_SET_STATE_INVALID; + UINT8 cLogSecSwitchSum = 0u; + LogsecSwitchStruct* pLgcSecSwitchStru = NULL; + UINT8 cLogSecPosFlag = FLAG_UNSET; /*߼ζλ־*/ + + if ((TSR_MAX_SUM >= cTsrSum) && (NULL != pTsrData)) + { + + /* ȫʱϢ */ + if (0xAAu == cAllLineTsrState) + { + /* ȫʱ */ + SetAllLineTsrState(CI_ALL_LINE_TSR_VALID); + SetAllLineTsrSpeed(cAllLineTsrSpeed); + } + else + { + /* ȫʱ */ + SetAllLineTsrState(CI_ALL_LINE_TSR_UNVALID); + SetAllLineTsrSpeed(0u); + } + + /* ʱ */ + SetTsrSum(cTsrSum); + /* */ + for (i = 0u; i < cTsrSum; i++) + { + g_TsrDataStru[i].cSpeed = pTsrData[i].cSpeed; + g_TsrDataStru[i].cLogSecSum = pTsrData[i].cLogSecSum; + + for (j = 0u; j < g_TsrDataStru[i].cLogSecSum;j++) + { + g_TsrDataStru[i].szLogSecId[j] = pTsrData[i].szLogSecId[j]; + } + } + + /* ߼ϵʱ */ + cTiocId = GetSystemParaLocalCiId(); + wLocalLogSecSum = GetLogicSecCurSum(); + if (LOGIC_SECTION_SUM_MAX > wLocalLogSecSum) + { + for (x = 0u; x < wLocalLogSecSum;x++) + { + wLogSecId = GetLogicSecId(x); + cLogSecTiocId = GetLogSecBelongCiId(wLogSecId); + cLogSecPosFlag = FLAG_UNSET; /*ÿһ߼Σһα־*/ + + if ((0u != wLogSecId) && (UINT16_MAX != wLogSecId) && (0u != cLogSecTiocId) && (cLogSecTiocId == cTiocId)) + { + /* жǷʱ */ + cRetVal = IsInTsrLogSecIdBuf(wLogSecId); + cLogSecTsrState = GetLogSecLinShiXianSuSetState(wLogSecId); + /*ʱ*/ + if (0U != cRetVal) + { + /*ʱȡֵ*/ + SetLogSecXiansuSpeed(wLogSecId, cRetVal); + /* Ҫʱ */ + if (LOGSEC_LSXS_SET_STATE_YES != cLogSecTsrState) + { + SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_YES); + ClearLgcSecBelongRtXsCfm(wLogSecId); + } + } + else + { + SetLogSecXiansuSpeed(wLogSecId, 0U); + if (0xAAu == cAllLineTsrState) + { + /*δʱٵȫʱЧ÷ǵλ߼ʱٱ־Ч*/ + cLogSecSwitchSum = GetLogicSecSwitchSum(wLogSecId); /*ȡ߼ΰĵ*/ + pLgcSecSwitchStru = GetLogicSecSwitchIdStru(wLogSecId); /*ȡ߼ΰĵID*/ + if (NULL != pLgcSecSwitchStru) + { + for (j = 0u; j < cLogSecSwitchSum; j++) + { + if (SWITCH_POSITION_DINGWEI == pLgcSecSwitchStru->SwitchPosition) + { + /**/ + } + else + { + cLogSecPosFlag = FLAG_SET; /*߼δڵڷλֹͣ*/ + break; + } + } + + if ((FLAG_UNSET == cLogSecPosFlag) && (LOGSEC_LSXS_SET_STATE_YES != cLogSecTsrState)) + { + /*߼δλʱٱ־Чʱٱ־Ч*/ + SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_YES); + ClearLgcSecBelongRtXsCfm(wLogSecId); /*ʱȷ״̬*/ + } + else + { + /*ּʱٱ־*/ + } + } + else + { + /**/ + } + } + else + { + /*δʱȫʱЧ߼ʱЧ*/ + if (LOGSEC_LSXS_SET_STATE_NO != cLogSecTsrState) + { + SetLogSecLinShiXianSuState(wLogSecId, LOGSEC_LSXS_SET_STATE_NO); + } + } + } + } + } + } + cRetVal = CI_SUCCESS; + } + else + { + ; /* ʧ */ + } + + return cRetVal; +} + +/************************************Ծ****************************************************/ + + +/* +* ȡָID߼ͷԾгID +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: гID +*/ +UINT16 GetLogSecJumpLockTrainId(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ȡͷԾгID */ + retVal = LogicSectionDataStru[bufIndex].JumpLockTrainId; + } + else + { + /** ȡʧ */ + retVal = 0u; + } + return retVal; +} + +/* +* ָID߼ͷԾгID +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 trainId, гID +* ֵ +* +*/ +void SetLogSecJumpLockTrainId(const UINT16 logSectionId, const UINT16 trainId) +{ + UINT16 bufIndex = 0u; /*±*/ + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** гͷŹԾ */ + if (((TRAIN_ID_MIN < trainId) && (TRAIN_ID_MAX > trainId)) + && (0u == LogicSectionDataStru[bufIndex].JumpLockTrainId)) + { + /** ͷԾгID */ + LogicSectionDataStru[bufIndex].JumpLockTrainId = trainId; + } + else + { + /** */ + } + } + else + { + /** */ + } +} + +/* +* ָID߼ԾгID +* ˵ const UINT16 logSectionId, ߼ID +* ֵ +* +*/ +void ClearLogSecJumpLockTrainId(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ԾгID */ + LogicSectionDataStru[bufIndex].JumpLockTrainId = 0u; + } + else + { + /** */ + } +} + +/* +* жԾгID߼ԾгIDǷͬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 trainId, гID +* ֵ CI_ERROR ͬһг + CI_SUCCESS ͬһг +* +*/ +UINT8 JudgeLogSecJumpLockRelTrainId(const UINT16 logSectionId, const UINT16 trainId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + UINT16 logSecTrainId = 0u; + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ԾͷггIDͬ */ + if ((TRAIN_ID_MIN < trainId) && (TRAIN_ID_MAX > trainId)) + { + logSecTrainId = GetLogSecJumpLockTrainId(logSectionId); + if (trainId == logSecTrainId) + { + /** IDԾгIDͬ */ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR;/** */ + } + } + else + { + /** */ + } + } + else + { + /** */ + } + return retVal; +} + +#if 0 + +/*HERE +* ȡָID߼Ծ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetLogSecJumpLockApplyFlag(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogJumpLockApplyFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID߼Ծ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockApplyFlag, Ծ־ +* ֵ +* +*/ +void SetLogSecJumpLockApplyFlag(const UINT16 logSectionId, const UINT8 jumpLockApplyFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if ((LOGIC_SECTION_JUMPLOCK_APPLY_NO == jumpLockApplyFlag) || (LOGIC_SECTION_JUMPLOCK_APPLY_YES == jumpLockApplyFlag)) + { + LogicSectionDataStru[bufIndex].LogJumpLockApplyFlag = jumpLockApplyFlag; /*߼Ծ־*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָID߼Ծͷű־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetLogSecJumpLockRelaseFlag(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogJumpLockRelaseFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID߼Ծͷű־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockCancelApplyFlag, Ծȡ־ +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetLogSecJumpLockRelaseFlag(const UINT16 logSectionId, const UINT8 jumpLockApplyRelaseFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if ((LOGSEC_JUMPLOCK_RELE_NO == jumpLockApplyRelaseFlag) || + (LOGSEC_JUMPLOCK_RELE_YES == jumpLockApplyRelaseFlag)) + { + LogicSectionDataStru[bufIndex].LogJumpLockRelaseFlag = jumpLockApplyRelaseFlag; /*߼Ծͷű־*/ + + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + +/* +* ȡָID߼Ծں +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծں +*/ +UINT32 GetLogSecJumpLockApplyCylce(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = 0u; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogJumpLockApplyCylce; /** ߼Ծں */ + } + else + { + retVal = 0u; + } + return retVal; +} + + +/* +* ָID߼Ծں +* ˵ const UINT16 logSectionId, ߼ID +* const UINT32 jumpLockApplyCycle, Ծں +* ֵ +*/ +void SetLogSecJumpLockApplyCylce(const UINT16 logSectionId, const UINT32 jumpLockApplyCycle) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + LogicSectionDataStru[bufIndex].LogJumpLockApplyCylce = jumpLockApplyCycle; /*߼Ծں*/ + } + else + { + /**/ + } +} + +#endif + +/* +* ȡָID߼Ծ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծ״̬ +*/ +UINT8 GetLogSecJumpLockState(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogJumpLockState; /*߼Ծ״̬*/ + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָID߼Ծ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void SetLogSecJumpLockState(const UINT16 logSectionId, const UINT8 jumpLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if ((LOGIC_SECTION_JUMP_LOCK_NO == jumpLockState) || (LOGIC_SECTION_JUMP_LOCK_YES == jumpLockState)) + { + LogicSectionDataStru[bufIndex].LogJumpLockState = jumpLockState; /*߼Ծ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָID߼Ծʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծʱʼں +*/ +UINT32 GetLogSecJumpDelayUnlocStartCyc(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = 0u; + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ȡ߼Ծʱʼں */ + retVal = LogicSectionDataStru[bufIndex].LogSecJumpDelayUnlockStartCyc; + } + else + { + /** ȡʧ */ + retVal = 0u; + } + return retVal; +} + + +/* +* ָID߼Ծʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* const UINT32 startCycNum, ʼں +* ֵ +* +*/ +void SetLogSecJumpDelayUnlocStartCyc(const UINT16 logSectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ߼Ծʱʼں */ + LogicSectionDataStru[bufIndex].LogSecJumpDelayUnlockStartCyc = startCycNum; + } + else + { + /** */ + } +} + +/* +* ȡָID߼Ծʱñ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծʱñ־ +*/ +UINT8 GetLogSecJumpDelayUnlockFlag(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ȡ߼Ծʱʼں */ + retVal = LogicSectionDataStru[bufIndex].LogJumpLockDelayUnlockFlag; + } + else + { + /** ȡʧ */ + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID߼Ծʱñ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpDelayUnlockFlag, ʱñ־ +* ֵ +* +*/ +void SetLogSecJumpDelayUnlockFlag(const UINT16 logSectionId, const UINT8 jumpDelayUnlockFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** κϷ */ + if ((LOGIC_JUMPUNLOCK_DELAY_SET_NO == jumpDelayUnlockFlag) || (LOGIC_JUMPUNLOCK_DELAY_SET_YES == jumpDelayUnlockFlag)) + { + /** ߼Ծʱñ־ */ + LogicSectionDataStru[bufIndex].LogJumpLockDelayUnlockFlag = jumpDelayUnlockFlag; + } + else + { + /** */ + } + } + else + { + /** */ + } +} + +/* +* ȡָID߼Ծ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetLogSecJumpLockPermFlag(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ȡ߼Ծ־ */ + retVal = LogicSectionDataStru[bufIndex].LogSecJumpLockPermFlag; + } + else + { + /** ȡʧ */ + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID߼Ծ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockPermFlag, Ծ־ +* ֵ +* +*/ +void SetLogSecJumpLockPermFlag(const UINT16 logSectionId, const UINT8 jumpLockPermFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** κϷ */ + if ((LOGIC_JUMPUNLOCK_PERMISSIVE_YES == jumpLockPermFlag) || (LOGIC_JUMPUNLOCK_PERMISSIVE_NO == jumpLockPermFlag)) + { + /** ߼Ծʱñ־ */ + LogicSectionDataStru[bufIndex].LogSecJumpLockPermFlag = jumpLockPermFlag; + } + else + { + /** */ + } + } + else + { + /** */ + } +} + +#if 0 +/* HERE +* ȡָIDID +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetAxisSectionBelongVirCiId(const UINT16 axisSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetAxisSecConfigBufIndex(axisSectionId); /*ȡ±*/ + + if (bufIndex < AXIS_SECTION_SUM_MAX) + { + retVal = AxisSectionDataStru[bufIndex].BelongVirCIid; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +#endif + +/* +* ߼Ծ߼ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void LogJumpLockCmdManage(const UINT16 logSectionId, const UINT8 jumpLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 checkResult = CI_ERROR; + + /** ȡ߼±*/ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ*/ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ߼Ծ*/ + if (LOGIC_SECTION_JUMP_LOCK_YES == jumpLockState) + { + /** ߼Ծ */ + checkResult = CheckLogJumpLockApply(logSectionId); + /** ߼Ծ */ + if (CI_ERROR == checkResult) + { + /** Ծ־Ϊֹ */ + SetLogSecJumpLockPermFlag(logSectionId, LOGIC_JUMPUNLOCK_PERMISSIVE_NO); + } + else + { + /** Ծ־Ϊ */ + SetLogSecJumpLockPermFlag(logSectionId, LOGIC_JUMPUNLOCK_PERMISSIVE_YES); + /** ߼Ծ */ + SetLogSecJumpLockState(logSectionId, LOGIC_SECTION_JUMP_LOCK_YES); + } + } + /** ߼Ծδ*/ + else if (LOGIC_SECTION_JUMP_LOCK_NO == jumpLockState) + { + /** Ծ־Ϊֹ */ + SetLogSecJumpLockPermFlag(logSectionId, LOGIC_JUMPUNLOCK_PERMISSIVE_NO); + /** Ծδ */ + SetLogSecJumpLockState(logSectionId, LOGIC_SECTION_JUMP_LOCK_NO); + } + else + { + /** */ + } + + SetLogRelaPhySecJumpLockSta(logSectionId); + } + else + { + /** */ + } +} + + +/* +* ȡʱٸ +* ˵ pData ݵַ +* dwIndex +* ֵ д +*/ +UINT32 GetTsrFollowData(UINT8* pData, UINT32 dwIndex) +{ + UINT32 dwRetVal = 0u; + UINT8 ii = 0u; + UINT8 jj = 0u; + + if ((NULL != pData) && (UINT32_MAX >= dwIndex)) + { + dwRetVal = dwIndex; + + /* */ + pData[dwRetVal] = g_TsrSum; + dwRetVal++; + + for (ii = 0u; ii < g_TsrSum;ii++) + { + /* ֵ */ + pData[dwRetVal] = g_TsrDataStru[ii].cSpeed; + dwRetVal++; + + /* */ + pData[dwRetVal] = g_TsrDataStru[ii].cLogSecSum; + dwRetVal++; + + for (jj = 0u;jj < g_TsrDataStru[ii].cLogSecSum;jj++) + { + /* εID */ + ShortToChar(g_TsrDataStru[ii].szLogSecId[jj], &pData[dwRetVal]); + dwRetVal += 2u; + } + } + + } + else + { + dwRetVal = dwIndex; + } + + return dwRetVal; +} + +/* +* ʱٸ +* ˵ pData ݵַ +* dwIndex +* ֵ +*/ +UINT32 SetTsrFollowData(UINT8* pData, UINT32 dwIndex) +{ + UINT32 dwRetVal = 0u; + UINT8 ii = 0u; + UINT8 jj = 0u; + + if ((NULL != pData) && (UINT32_MAX >= dwIndex)) + { + dwRetVal = dwIndex; + + /* */ + g_TsrSum = pData[dwRetVal]; + dwRetVal++; + + for (ii= 0u; ii < g_TsrSum;ii++) + { + /* ٶ */ + g_TsrDataStru[ii].cSpeed = pData[dwRetVal]; + dwRetVal++; + + g_TsrDataStru[ii].cLogSecSum = pData[dwRetVal]; + dwRetVal++; + + for (jj = 0u; jj < g_TsrDataStru[ii].cLogSecSum; jj++) + { + g_TsrDataStru[ii].szLogSecId[jj] = ShortFromChar(&pData[dwRetVal]); + dwRetVal += 2u; + } + } + } + else + { + dwRetVal = dwIndex; + } + + return dwRetVal; +} + +/** +* @brief ߼Ƿس +* @param wLgcId ߼ID +* @return CI_SUCCESSسCI_ERRORس +* @note ˺ж߼ΪCTռú +*/ +UINT8 IsLogicHaveNoSupicTrain(UINT16 wLgcId) +{ + UINT8 chLinkNum = 0u; + UINT16 *pLinkId = NULL; + UINT8 chIndex = 0u; + UINT8 chRtn = CI_ERROR; + TRAIN_SEQUANCE_s strTmpF = { 0u }; + TRAIN_SEQUANCE_s strTmpB = { 0u }; + UINT8 chTrainNum = 0u; + chLinkNum = GetSecIntrudeLinkSum(wLgcId); + pLinkId = GetSecIntrudeLinkIdBuf(wLgcId); + if (0u != chLinkNum) + { + for (chIndex = 0u; chIndex < chLinkNum; chIndex++) + { + chTrainNum = as_GetLinkTrainNum(pLinkId[chIndex]); + if (0u != chTrainNum) + { + strTmpF = as_GetLinkLastTrain(pLinkId[chIndex]); + + strTmpB = as_GetLinkFirstTrain(pLinkId[chIndex]); + if ((TRAIN_SUM_MAX == strTmpB.u16TrainID) || (TRAIN_SUM_MAX == strTmpF.u16TrainID)) + { + break; + } + else + { + ; + } + } + else + { + ; + } + } + if (chIndex == chLinkNum) + { + chRtn = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; + } + return chRtn; +} + +/************************************Ծ****************************************************/ + +/* +* @brief ߼г״̬ +* @details г󣬵ʽ·״̬ +* @param const UINT16 routeId ·ID +* const UINT8 chCiId CiID +* @return +*/ +void SetLgcXianSuRemoveState(const UINT16 wLgcId, const UINT8 chXianSuRemoveStt) +{ + UINT16 bufIndex = 0u; /*±*/ + + /** ȡ·±*/ + bufIndex = GetlogSectionBufIndex(wLgcId); + /** ±ϷгIDϷ*/ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if ((LOGIC_XIANSU_REMOVE_YES == chXianSuRemoveStt) + || (LOGIC_XIANSU_REMOVE_NO == chXianSuRemoveStt)) + { + LogicSectionDataStru[bufIndex].chXianSuRemoveState = chXianSuRemoveStt; + } + else + { + /*޴*/ + } + } + else + { + /**/ + } +} + +#if 0 +/* +* ȡ߼г״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0u +* г״̬ +*/ +UINT8 GetLgcXianSuRemoveState(const UINT16 wLogSectionId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = 0u; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chRetVal = LogicSectionDataStru[wBufIndex].chXianSuRemoveState; + } + else + { + ;/* 0u */ + } + return chRetVal; +} +#endif + +/** +* @brief ߼Ƿʱ +* @param wLogSecId ߼ID +* @return UINT8_MAX 쳣 +* 0 ʱ +* >0 ʱȡֵ +* @note by cgh 20240411 +*/ +UINT8 IsInTsrLogSecIdBuf(UINT16 wLogSecId) +{ + UINT8 cRetVal = UINT8_MAX; + UINT8 i = 0U; + UINT8 j = 0U; + + if ((0U != wLogSecId) && (UINT16_MAX != wLogSecId)) + { + cRetVal = 0U; + for (i = 0U; i < g_TsrSum; i++) + { + for (j = 0U; j < g_TsrDataStru[i].cLogSecSum; j++) + { + if (g_TsrDataStru[i].szLogSecId[j] == wLogSecId) + { + /* ҵ߼ */ + cRetVal = g_TsrDataStru[i].cSpeed; + break; + } + else + { + ; /**/ + } + } + if (0U != cRetVal) + { + /*Ѿҵ*/ + break; + } + } + } + else + { + ; /*Ƿ*/ + } + + return cRetVal; +} + +/* +* ָ߼ι·ȷ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ +* +*/ +void ClearLgcSecBelongRtXsCfm(const UINT16 wLgcSecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 cTiocId = 0u; + UINT8 cRouteBelongCiId = 0U; + UINT16 wPLockRouteId = 0U; + UINT16 wRLockRouteId = 0U; /** ȡ߼± */ + UINT16 wRelPhySecId = 0U; /*߼ιID*/ + + bufIndex = GetlogSectionBufIndex(wLgcSecId); + cTiocId = GetSystemParaLocalCiId(); + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + wRelPhySecId = GetLgcSecRelativePhySecId(wLgcSecId); + wRLockRouteId = GetPhySecRLockBelongRouteId(wRelPhySecId); + wPLockRouteId = GetPhySecPLockBelongRouteId(wRelPhySecId); + if (0U != wRLockRouteId) + { + cRouteBelongCiId = GetRouteBelongCiId(wRLockRouteId); + if (cRouteBelongCiId == cTiocId) + { + SetRouteXianSuConfirmStt(wRLockRouteId, ROUTE_XIANSU_CONFIRM_NO); + } + else + { + ; + } + } + else + { + ; + } + + if (0U != wPLockRouteId) + { + cRouteBelongCiId = GetRouteBelongCiId(wPLockRouteId); + if (cRouteBelongCiId == cTiocId) + { + SetRouteXianSuConfirmStt(wPLockRouteId, ROUTE_XIANSU_CONFIRM_NO); + } + else + { + ; + } + } + else + { + ; + } + } + else + { + /** */ + } +} + +/* +* TIOCָID߼ʱ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 linShiXianSuSetState, ʱ״̬ +* ֵ +* +*/ +void SetLogSecXSSttOtherTioc(const UINT16 logSectionId, const UINT8 linShiXianSuSetState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if (LogicSectionDataStru[bufIndex].LinShiXianSuSetFlag == LOGSEC_LSXS_SET_STATE_NO) + { + if (LOGSEC_LSXS_SET_STATE_YES == linShiXianSuSetState) + { + ClearLgcSecBelongRtXsCfm(logSectionId); + LogicSectionDataStru[bufIndex].LinShiXianSuSetFlag = linShiXianSuSetState; + } + else if ((LOGSEC_LSXS_SET_STATE_NO == linShiXianSuSetState)|| + (LOGSEC_LSXS_SET_STATE_INVALID == linShiXianSuSetState)) + { + LogicSectionDataStru[bufIndex].LinShiXianSuSetFlag = linShiXianSuSetState; + } + else + { + /**/ + ; + } + } + else + { + if ((LOGSEC_LSXS_SET_STATE_NO == linShiXianSuSetState) || + (LOGSEC_LSXS_SET_STATE_YES == linShiXianSuSetState) || + (LOGSEC_LSXS_SET_STATE_INVALID == linShiXianSuSetState)) + { + LogicSectionDataStru[bufIndex].LinShiXianSuSetFlag = linShiXianSuSetState; /*߼ʱ״̬*/ + } + else + { + /**/ + } + } + } + else + { + /**/ + } +} +#if 0 +/* +* @func ߼ǷԴ +* @param UINT16 wLgcSecId, ߼ID + +* @return CI_ERROR +* CI_SUCCESS +*/ +UINT8 LgcHaveUseableRes(UINT16 wLgcSecId) +{ + /*ʼ*/ + UINT8 ii = 0u; /* ѭ */ + UINT8 chLogResTrainSum = 0u; + UINT16 wLgcSecResTrainId = 0U; + LogicTrainResStruct * pstLogicResTrainInfo = NULL; + + UINT8 chRetVal = CI_ERROR; + + chLogResTrainSum = GetLogSecTrainInfoSum(wLgcSecId); + + /*߼ԴϢ*/ + for (ii = 0U; ii < chLogResTrainSum; ii++) + { + wLgcSecResTrainId = GetLogSecTrainIdByIndex(wLgcSecId, ii); + pstLogicResTrainInfo = GetLogSecTrainInfoById(wLgcSecId, wLgcSecResTrainId); + /*ȡгԴϢΪ*/ + if (NULL != pstLogicResTrainInfo) + { + if (LOGIC_SECTION_RES_USABLE == pstLogicResTrainInfo->chLogicResUsable) + { + chRetVal = CI_SUCCESS; + break; + } + else + { + ; /**/ + } + } + else + { + ; /*ܷ֧*/ + } + } + + + return (chRetVal); +} +#endif + +/* +* ȡָ߼ARB״̬ +* ˵ const UINT16 wLgcId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼ARB״̬ +*/ +UINT8 GetLgcArbState(const UINT16 wLgcId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].chArbState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ƶ߼ARB״̬ +* ˵ const UINT16 wLgcId, ߼ID +* const UINT8 chArb ARB״̬ +* ֵ +*/ +void SetLgcArbState(const UINT16 wLgcId, const UINT8 chArb) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ±*/ + + if ((LOGIC_SECTION_SUM_MAX > bufIndex) + && ((LGC_SECTION_ARB_NO == chArb) || (LGC_SECTION_ARB_YES == chArb))) + { + LogicSectionDataStru[bufIndex].chArbState = chArb; + } + else + { + ; + } +} + +/* +* ߼ARB״̬ +* ˵ +* ֵ +*/ +void SetLgcArbStateProc(void) +{ + UINT8 chLocalId = 0u; + UINT8 chBelongTioc = 0u; + UINT16 wLgcNum = 0u; + UINT16 wLgcIndex = 0u; + UINT8 chAcNum = 0u; + UINT16 wLgcId = 0u; + UINT16 * pAcId = NULL; + UINT8 chAcIndex = 0u; + UINT8 chAcArbState = 0u; + UINT8 cRcWorkMode = 0U; + UINT8 cflag = 0U; + + cRcWorkMode = GetLocalRcWorkMode(); + + chLocalId = GetSystemParaLocalCiId(); + + /* ȡ߼ */ + wLgcNum = GetTotalLogSecCurNum();/*ڵLOGIC_SECTION_SUM_MAX0*/ + for (wLgcIndex = 0u; wLgcIndex < wLgcNum; wLgcIndex++) + { + + wLgcId = GetLogicSecId(wLgcIndex); + chBelongTioc = GetLogSecBelongCiId(wLgcId); + chAcNum = GetLgcSecRelativeAxleSecSum(wLgcId); + pAcId = GetLgcSecRltvAxleSecIdBuf(wLgcId); + if ((0u != chAcNum) && (NULL != pAcId) && (chLocalId == chBelongTioc)) + { + for (chAcIndex = 0u; chAcIndex < chAcNum; chAcIndex++) + { + cflag = 0U; + if (RC_WORK_MODE_TIOC == cRcWorkMode) + { + chAcArbState = aam_GetAxisStatusAPI(pAcId[chAcIndex]); + if (AAM_STATUS_ARB == chAcArbState) + {/* ARB߼ARB */ + SetLgcArbState(wLgcId, LGC_SECTION_ARB_YES); + cflag = 1U; + } + else + {/* ηARB߼ηARB */ + SetLgcArbState(wLgcId, LGC_SECTION_ARB_NO); + } + } + else if (RC_WORK_MODE_CI == cRcWorkMode) + { + chAcArbState = GetAxisSecArbState(pAcId[chAcIndex]); + if (AXIS_SECTION_ARB_YES == chAcArbState) + {/* ARB߼ARB */ + SetLgcArbState(wLgcId, LGC_SECTION_ARB_YES); + cflag = 1U; + } + else + {/* ηARB߼ηARB */ + SetLgcArbState(wLgcId, LGC_SECTION_ARB_NO); + } + } + else + { + /*RCģʽ*/ + } + if (1U == cflag) + { + break; + } + } + } + else + { + /* ݻȡʧܻ߲Ϊ߼Σ */ + } + } +} +/* +* ȡָ߼ʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼ʱʼں +*/ +UINT32 GetLogDelayErrlockStartCycNum(const UINT16 logSectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + retVal = LogicSectionDataStru[bufIndex].LogErrlockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָ߼ʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* const UINT32 startCycNum ʼں +* ֵ +* +*/ +void SetLogDelayErrlockStartCycNum(const UINT16 logSectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + if (0U == startCycNum) + { + LogicSectionDataStru[bufIndex].LogErrlockStartCycNum = 0U; + } + else + { + if (0U == LogicSectionDataStru[bufIndex].LogErrlockStartCycNum) + { + LogicSectionDataStru[bufIndex].LogErrlockStartCycNum = startCycNum; + } + else + { + ; /*ѾЧټ*/ + } + } + } + else + { + /**/ + } +} + + +/** +* @brief ȡ߼Ƿس +* @param wLgcId ߼ID +* @return CI_SUCCESSسCI_ERRORس +* @note ȡг鿴Ƿпг +*/ +UINT8 GetLogicSupicTrainStat(UINT16 wLgcId) +{ + UINT8 chLinkNum = 0u; + UINT8 trainIndex = 0U; + UINT16 *pLinkId = NULL; + UINT8 chIndex = 0u; + UINT8 chRtn = CI_ERROR; + TRAIN_SEQUANCE_s strTmp[SIZE_MAX_TRAINOFAC] = { 0u }; + TRAIN_SEQUANCE_s strTmpB = { 0u }; + UINT8 chTrainNum = 0u; + chLinkNum = GetSecIntrudeLinkSum(wLgcId); + pLinkId = GetSecIntrudeLinkIdBuf(wLgcId); + + /*linkΪ0*/ + if (0u != chLinkNum) + { + /*Link*/ + for (chIndex = 0u; chIndex < chLinkNum; chIndex++) + { + /*ȡLinkгϢ*/ + chTrainNum = as_GetLinkTrainList(pLinkId[chIndex], strTmp, SIZE_MAX_TRAINOFAC); + if (0u != chTrainNum) + { + for (trainIndex = 0U; trainIndex < chTrainNum; trainIndex++) + { + if (NAME_FAILUREAREA == strTmp[trainIndex].u16TrainID) + { + /*ҵس˳*/ + break; + } + else + { + ; + } + } + + if (trainIndex != chTrainNum) + { + /*س˳*/ + break; + } + + } + } + if (chIndex == chLinkNum) + { + /*ɣس*/ + chRtn = CI_SUCCESS; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + chRtn = CI_ERROR; + } + + return chRtn; +} + +/* +* ߼αԴ״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chUseState ״̬ +* ֵ VOID +* by cgh 20230630 ¼Դ״̬ +*/ +void SetLogSecProResUseState(const UINT16 wLogSectionId, const UINT8 chUseState) +{ + UINT16 wBufIndex = 0u; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if ((LOGIC_SECTION_PRO_RES_USABLE == chUseState) || (LOGIC_SECTION_PRO_RES_UNUSABLE == chUseState)) + { + LogicSectionDataStru[wBufIndex].chLogicProResUsable = chUseState; + } + } +} + +/* +* ȡ߼αԴ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ LOGIC_SECTION_PRO_RES_UNUSABLE +* LOGIC_SECTION_PRO_RES_USABLE +* * by cgh 20230630 ¼Դ״̬ +*/ +UINT8 GetLogSecProResUseState(const UINT16 wLogSectionId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 chRetVal = LOGIC_SECTION_RES_UNUSABLE; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chRetVal = LogicSectionDataStru[wBufIndex].chLogicProResUsable; + } + else + { + ; /*Ƿز*/ + } + return chRetVal; +} + +/* +* ȡָ߼շǷӦȡ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ CI_ERROR: ȡ +* CI_SUCCESS: ȡ +* by cgh 20230802 ATSշλʱʹ +*/ +UINT8 GetLogSecLockDirOpposedFlag(const UINT16 wLogSectionId) +{ + UINT8 retVal = CI_ERROR; + UINT16 wRLockRouteId = 0U;/*߼·*/ + UINT16 wLogSecBelongPhyId = 0U;/*߼*/ + UINT8 chLockDirOpposedFlag = 0U;/*շǷȡ־*/ + + wRLockRouteId = GetLogSecLockBelongRoute(wLogSectionId); + wLogSecBelongPhyId = GetLgcSecRelativePhySecId(wLogSectionId); + chLockDirOpposedFlag = GetRoutePhySecShouldLockOppose(wRLockRouteId, wLogSecBelongPhyId); + + if (ROUTE_PHYSEC_SHOULD_OPPOSE_LOCK == chLockDirOpposedFlag) + { + retVal = CI_SUCCESS; + } + else + { + ; /*շҪȡ˵߼ҲҪȡ*/ + } + return retVal; +} + +/* +* ȡָ߼Ƿ߱ԴԶǰ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ CI_ERROR: ߱ +* CI_SUCCESS: ߱ +* by cgh 20230802 IVOCԴԶϢ +*/ +UINT8 GetLogSecHaveResOpp(const UINT16 wLogicSecId) +{ + UINT8 retVal = CI_ERROR; + UINT16 wRLockRouteId = 0U;/*߼·*/ + UINT16 wPLockRouteId = 0U;/*߼η·*/ + UINT16 wRouteLogSecSum = 0U;/*·߼Ŀ*/ + UINT16* pRouteLogSecId = NULL;/*·߼ID*/ + UINT16 wOverlapLockedId = 0U;/*·ID*/ + UINT8 chLogicSectionSum = 0U;/*ζӦ߼Ŀ*/ + UINT16* pLogicSectionIdBuf = NULL;/*ΰ߼ID*/ + UINT8 chLogSecLockState = 0U;/*߼״̬*/ + UINT8 chLogSecLockDir = 0U;/*߼Ӫ*/ + UINT8 chLogSecLockSysDir = 0U;/*߼߼*/ + + wRLockRouteId = GetLogSecLockBelongRoute(wLogicSecId); + wPLockRouteId = GetLogSecPLockRouteId(wLogicSecId); + chLogSecLockState = GetLogSecLockState(wLogicSecId); + + if (0U < wRLockRouteId) + { + /*ǰ߼ξ߱·ջŽ·ռ*/ + wRouteLogSecSum = GetRouteLogSectionSum(wRLockRouteId); + pRouteLogSecId = GetRouteLogSectionIdBuf(wRLockRouteId); + if ((pRouteLogSecId[wRouteLogSecSum - 1U] == wLogicSecId) && (LOG_SECTION_LOCK_NORMAL == chLogSecLockState)) + { + /*ǰѯ߼Ϊ·һβգ*/ + retVal = CI_SUCCESS; + } + } + else if (0U < wPLockRouteId) + { + /*ǰ߼νΪգΪһ*/ + wOverlapLockedId = GetRouteOverlapLockedId(wPLockRouteId); + chLogicSectionSum = GetOverlapLogicSectionSum(wOverlapLockedId); + pLogicSectionIdBuf = GetOverlapLogicSectionBuf(wOverlapLockedId); + chLogSecLockDir = GetLogSecLockDir(wLogicSecId); + chLogSecLockSysDir = ConvertDirectionToLogic(chLogSecLockDir); + + if (((pLogicSectionIdBuf[chLogicSectionSum - 1U] == wLogicSecId) && (DIR_SAME == chLogSecLockSysDir)) + || ((pLogicSectionIdBuf[0] == wLogicSecId) && (DIR_CONVERT == chLogSecLockSysDir))) + { + /*ǰѯ߼շ߼ͬ򱣻һ߼෴εһ߼*/ + retVal = CI_SUCCESS; + } + } + else + { + ; /*߱ǰ*/ + } + return retVal; +} + + +/* +* η״̬ +* ˵ const UINT16 logicSecId, ߼ID +* ֵ: +*/ +void ClearLogicSecPLock(const UINT16 logicSecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_SUCCESS; + bufIndex = GetlogSectionBufIndex(logicSecId); /*ȡ±*/ + + + if (bufIndex >= LOGIC_SECTION_SUM_MAX) + { + retVal = CI_ERROR; + } + + else + { + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = 0; + } +} + +/* +* ߼SPKS״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chLogicSpksFLockState ߼SPKS״̬ +* ֵ VOID +* by cgh 20230919 +*/ +void SetLogSecSpksFLockState(const UINT16 wLogSectionId, const UINT8 chLogicSpksFLockState) +{ + UINT16 wBufIndex = 0u; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if ((LOGIC_SECTION_SPKS_FLOCK_NO == chLogicSpksFLockState) || (LOGIC_SECTION_SPKS_FLOCK_YES == chLogicSpksFLockState)) + { + LogicSectionDataStru[wBufIndex].chLogicSpksFLockState = chLogicSpksFLockState; + } + } +} + +/* +* ȡ߼SPKS״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ LOGIC_SECTION_SPKS_FLOCK_NO δ +* LOGIC_SECTION_SPKS_FLOCK_YES +* by cgh 20230919 +*/ +UINT8 GetLogSecSpksFLockState(const UINT16 wLogSectionId) +{ + UINT16 wBufIndex = 0U; /*±*/ + UINT8 chRetVal = LOGIC_SECTION_SPKS_FLOCK_YES; + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + chRetVal = LogicSectionDataStru[wBufIndex].chLogicSpksFLockState; + } + else + { + ; /*Ƿز*/ + } + return chRetVal; +} + +/* +* ȡָID߼߼· +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼߼· +* cgh 2023-10-10 +*/ +UINT8 GetLogSecLockBelLogRouteSum(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionDataStru[wBufIndex].chLogSecLockBelLogRouteSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼߼· +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼߼· +* : cgh 2023-10-10 +*/ +LogSecLockBelLogRouteStruct* GetLogSecLockBelLogRouteData(const UINT16 wLgcId) +{ + UINT16 wBufIndex = 0U; /*±*/ + LogSecLockBelLogRouteStruct* pRetVal = NULL; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ߼±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + pRetVal = LogicSectionDataStru[wBufIndex].szLogSecLockBelLogRouteData; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + + + +/* +* ָ߼Ƿָ߼· +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 wLogRouteId, ߼·ID +* ֵ CI_SUCCESS߼ι߼·CI_ERROR +* fan 2023-10-11 +*/ +UINT8 CheckLogRouteIdBelLogSec(const UINT16 logSectionId, const UINT16 wLogRouteId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 logRoutSum = 0U; /*߼߼·*/ + LogSecLockBelLogRouteStruct* logRoutBuf = NULL; /*߼߼·*/ + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + logRoutBuf = LogicSectionDataStru[bufIndex].szLogSecLockBelLogRouteData; + logRoutSum = LogicSectionDataStru[bufIndex].chLogSecLockBelLogRouteSum; + for (ii = 0U; ii < logRoutSum; ii++) + { + if (logRoutBuf[ii].wLogSecLockBelLogRouteId == wLogRouteId) + { + retVal = CI_SUCCESS; + break; + } + else + { + ; /**/ + } + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ߼ɾָ߼·ID +* ˵ const UINT16 logSectionId, ߼ID +const UINT16 wLogRouteId, ߼·ID +* +* ֵ CI_ERROR ɾʧ Ci_SUCCESSS ɾɹ +* fan 2023-10-11 +*/ +UINT8 DelLogSecBelongLogRouteId(const UINT16 logSectionId, const UINT16 wLogRouteId) +{ + + UINT16 bufIndex = 0U; /*±*/ + LogSecLockBelLogRouteStruct* logRoutBuf = NULL; /*߼߼·*/ + UINT8 logRoutSum = 0U; /*߼߼·*/ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 chNeedKeepSum = 0U; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + logRoutBuf = LogicSectionDataStru[bufIndex].szLogSecLockBelLogRouteData; + logRoutSum = LogicSectionDataStru[bufIndex].chLogSecLockBelLogRouteSum; + if (LOGSEC_RELATE_ROUTE_SUM_MAX >= logRoutSum) + { + for (ii = 0U; ii < logRoutSum; ii++) + { + if (LogicSectionDataStru[bufIndex].szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId == wLogRouteId) + { + ; /*ִ*/ + } + else + { + (void)CommonMemCpy((void*)(&logRoutBuf[chNeedKeepSum]), (UINT32)sizeof(LogSecLockBelLogRouteStruct), (void*)(&logRoutBuf[ii]), (UINT32)sizeof(LogSecLockBelLogRouteStruct)); + chNeedKeepSum++; + } + } + /* 0ֹ*/ + (void)ComMemSet(&logRoutBuf[chNeedKeepSum], (UINT16)sizeof(LogSecLockBelLogRouteStruct), 0U); + LogicSectionDataStru[bufIndex].chLogSecLockBelLogRouteSum = chNeedKeepSum;/*޸߼·*/ + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ߼ָ߼·ID +* ˵ const UINT16 logSectionId, ߼ID +const UINT16 wLogRouteId, ߼·ID +* +* ֵ CI_ERROR ʧ Ci_SUCCESSS ӳɹ +* fan 2023-10-11 +*/ +UINT8 AddLogSecBelongLogRouteId(const UINT16 logSectionId, const UINT16 wLogRouteId) +{ + UINT16 bufIndex = 0U; /*±*/ + LogSecLockBelLogRouteStruct* logRoutBuf = NULL; /*߼߼·*/ + UINT16 logRoutSum = 0U; /*߼߼·*/ + UINT8 retVal = CI_ERROR; + UINT8 ii = 0U; + UINT8 chNeedKeepSum = 0U; + + bufIndex = GetlogSectionBufIndex(logSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + logRoutSum = LogicSectionDataStru[bufIndex].chLogSecLockBelLogRouteSum; + if (LOGSEC_RELATE_ROUTE_SUM_MAX > logRoutSum) + { + logRoutBuf = LogicSectionDataStru[bufIndex].szLogSecLockBelLogRouteData; + logRoutBuf[logRoutSum].wLogSecLockBelLogRouteId = wLogRouteId; + logRoutBuf[logRoutSum].wLogSecLockBelLogRouteId = 0U; + logRoutBuf[logRoutSum].chLogSecLockBelLogRouteState = LOG_SECTION_LOGLOCK_NO; + LogicSectionDataStru[bufIndex].chLogSecLockBelLogRouteSum++; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + + +/* +* ȡָ߼߼״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼߼״̬ +* by cgh 20231012 +*/ +UINT8 GetLogSecLogLockState(const UINT16 wLogSectionId) +{ + + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionDataStru[wBufIndex].LogSecLogLockState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָ߼߼շ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼߼շ +* by cgh 20231013 +*/ +UINT8 GetLogSecLogLockDir(const UINT16 wLogSectionId) +{ + + UINT16 wBufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + retVal = LogicSectionDataStru[wBufIndex].LogSecLogLockDir; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָ߼״̬뷽 +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 chLogLockState ߼߼״̬ +* const UINT8 chLogLockDir ߼߼շ +* ֵ +* by cgh 20231012 +*/ +void SetLogSecLogLockState(const UINT16 wLogSectionId, const UINT8 chLogLockState, const UINT8 chLogLockDir) +{ + UINT16 wBufIndex = 0U; /*±*/ + UINT16 LogSecLockBelongRouteId = 0U; + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if (LOG_SECTION_LOGLOCK_NO == chLogLockState) + { + LogicSectionDataStru[wBufIndex].LogSecLogLockState = chLogLockState; + LogicSectionDataStru[wBufIndex].LogSecLogLockDir = 0U; + + LogSecLockBelongRouteId = GetLogSecLockBelongRoute(wLogSectionId); + if (0U != LogSecLockBelongRouteId) + { + /*»н·գ߼·۷ֽ·ɾгԴ*/ + } + else + { + LogicSectionDataStru[wBufIndex].chTrainInfoSum = 0U; + (void)CommonMemSet(LogicSectionDataStru[wBufIndex].szTrainResData, \ + (UINT32)sizeof(LogicSectionDataStru[wBufIndex].szTrainResData), \ + 0U, (UINT32)sizeof(LogicSectionDataStru[wBufIndex].szTrainResData)); + } + + } + else if (LOG_SECTION_LOGLOCK_NORMAL == chLogLockState) + { + LogicSectionDataStru[wBufIndex].LogSecLogLockState = chLogLockState; + LogicSectionDataStru[wBufIndex].LogSecLogLockDir = chLogLockDir; + } + else if (LOG_SECTION_LOGLOCK_EXCEPT == chLogLockState) + { /**/ + LogicSectionDataStru[wBufIndex].LogSecLogLockState = chLogLockState; + LogicSectionDataStru[wBufIndex].LogSecLogLockDir = chLogLockDir; + } + else + { + LogicSectionDataStru[wBufIndex].LogSecLogLockState = chLogLockState; + LogicSectionDataStru[wBufIndex].LogSecLogLockDir = chLogLockDir; + } + } + else + { + /**/ + } +} + +#if 0 +/* +* ȡ߼·ijһǷ߱ԴԶǰ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ CI_ERROR: һ߼ +* CI_SUCCESS: һ߼ +* by cgh 20231016 +*/ +UINT8 CheckLogRouteSecHaveResOpp(const UINT16 wLogicSecId) +{ + UINT8 chLogSecBelLogRouteSum = 0U;/*߼߼·ID*/ + UINT8 ii = 0U; + LogSecLockBelLogRouteStruct* szLogSecBelLogRouteData = NULL;/*߼߼·*/ + UINT16 wLogSecBelLogRouteId = 0U;/*߼߼·ID*/ + UINT16 wLogRouteIncLogSecSum = 0U;/*߼·߼Ŀ*/ + UINT16* szLogRouteIncLogSecIdBuf = NULL;/*߼·߼ID*/ + UINT8 chReval = CI_ERROR; + UINT8 chLogSecLogLockState = 0U;/*߼߼״̬*/ + UINT8 chKeepFlag = 0U; + + chLogSecBelLogRouteSum = GetLogSecLockBelLogRouteSum(wLogicSecId); + szLogSecBelLogRouteData = GetLogSecLockBelLogRouteData(wLogicSecId); + + if ((NULL != szLogSecBelLogRouteData) && (0U < chLogSecBelLogRouteSum)) + { + for (ii = 0U; ii < chLogSecBelLogRouteSum; ii++) + { + wLogSecBelLogRouteId = szLogSecBelLogRouteData[ii].wLogSecLockBelLogRouteId; + if ((0U < wLogSecBelLogRouteId) && (ROUTE_LOGICAL_SUM_MAX > wLogSecBelLogRouteId)) + { + wLogRouteIncLogSecSum = GetLogicalRouteInLogSecSum(wLogSecBelLogRouteId); + szLogRouteIncLogSecIdBuf = GetLogicalRouteInLogSecId(wLogSecBelLogRouteId); + + if (NULL != szLogRouteIncLogSecIdBuf) + { + if (wLogicSecId == szLogRouteIncLogSecIdBuf[wLogRouteIncLogSecSum - 1]) + { + /*ǰ߼Ϊ߼·һ߼Σ*/ + } + else + { + chKeepFlag = 1U;/*ǰ߼βΪ߼·һ߼Σ*/ + } + } + else + { + chKeepFlag = 1U; /*쳣*/ + } + } + else + { + chKeepFlag = 1U; /*쳣*/ + } + + if (1U == chKeepFlag) + { + break; + } + } + + if (chLogSecBelLogRouteSum == ii) + { + /*ǰΪ߼·һΣѯ״̬*/ + chLogSecLogLockState = GetLogSecLogLockState(wLogicSecId); + + if (LOG_SECTION_LOGLOCK_NORMAL == chLogSecLogLockState) + { + /*ǰ״̬Ϊ߼գǰͨ*/ + chReval = CI_SUCCESS; + } + else + { + ; /*άּ鲻ͨ*/ + } + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} +#endif + + +/** +* @brief ߼߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteRelatePsdId ߼·ID +* @return +* @noteby cgh 20231011 +*/ +void SetLogSecRelateLogRouteData(const UINT16 wLogRouteId, const UINT16 wLogSecId) +{ + UINT16 wBufIndex = 0U; + UINT8 chLogSecRelateLogRouteSum = 0U; + UINT16 ii = 0U; + + + wBufIndex = GetlogSectionBufIndex(wLogSecId); + + if ((LOGIC_SECTION_SUM_MAX > wBufIndex)&& (0U != wLogRouteId)) + { + chLogSecRelateLogRouteSum = LogicSectionDataStru[wBufIndex].chLogSecLockBelLogRouteSum; + + if (LOGSEC_RELATE_ROUTE_SUM_MAX > chLogSecRelateLogRouteSum) + { + for (ii = 0U; ii < chLogSecRelateLogRouteSum; ii++) + { + if (LogicSectionDataStru[wBufIndex].szLogSecLockBelLogRouteData[ii].wLogSecLockBelLogRouteId == wLogRouteId) + { + break; + } + else + { + ; /**/ + } + } + + if (chLogSecRelateLogRouteSum == ii) + { + LogicSectionDataStru[wBufIndex].szLogSecLockBelLogRouteData[chLogSecRelateLogRouteSum].wLogSecLockBelLogRouteId = wLogRouteId; + LogicSectionDataStru[wBufIndex].chLogSecLockBelLogRouteSum = chLogSecRelateLogRouteSum + 1U; + } + else + { + ; /*Ѵڲ*/ + } + } + else + { + ; /*Ƿ*/ + } + } + else + { + ; /* */ + } +} + +/* +* ÷ָID߼ε߼״̬뷽 +* ˵ const UINT16 logSectionId ߼ID +* const UINT8 chLogLockState ߼߼״̬ +* const UINT8 chLogLockDir ߼߼շ +* const UINT8 cLogLockBelLogRouteSum ߼߼߼· +* ֵ +* Created By LQ 2023/10/20 +*/ +void SetLogSecLogLockStateOtherCi(const UINT16 wLogSectionId, const UINT8 chLogLockState, const UINT8 chLogLockDir, const UINT8 cLogLockBelLogRouteSum) +{ + UINT16 wBufIndex = 0U; /*±*/ + UINT8 cLogSecLockState = 0U; /*߼״̬*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if (LOG_SECTION_LOGLOCK_NO == chLogLockState) + { + LogicSectionDataStru[wBufIndex].LogSecLogLockState = chLogLockState; + LogicSectionDataStru[wBufIndex].LogSecLogLockDir = 0U; + + cLogSecLockState = GetLogSecLockState(wLogSectionId); + if (LOG_SECTION_LOCK_NO == cLogSecLockState) + { + /*·պ߼վδգ߼ԴгϢ*/ + LogicSectionDataStru[wBufIndex].chTrainInfoSum = 0U; + (void)CommonMemSet(LogicSectionDataStru[wBufIndex].szTrainResData, (UINT32)sizeof(LogicSectionDataStru[wBufIndex].szTrainResData), 0U, (UINT32)sizeof(LogicSectionDataStru[wBufIndex].szTrainResData)); + } + else + { + /*ڽ·գԴ*/ + } + } + else if (LOG_SECTION_LOGLOCK_NORMAL == chLogLockState) + { + LogicSectionDataStru[wBufIndex].LogSecLogLockState = chLogLockState; + LogicSectionDataStru[wBufIndex].LogSecLogLockDir = chLogLockDir; + } + else if (LOG_SECTION_LOGLOCK_EXCEPT == chLogLockState) + { + LogicSectionDataStru[wBufIndex].LogSecLogLockState = chLogLockState; + LogicSectionDataStru[wBufIndex].LogSecLogLockDir = chLogLockDir; + } + else + { + /**/ + } + + /*߼·ڿֽ·׷߼·ֽ·߼ʱ߼·Ϊ1Added By LQ 2025.03.10*/ + LogicSectionDataStru[wBufIndex].chLogSecLockBelLogRouteSum = cLogLockBelLogRouteSum; + } + else + { + /**/ + } +} + +/** +* @brief շȡָIDгԴõ߼ +* @param const UINT16 wAxleId ID +* const UINT16 wTrainId гID +* const UINT8 cDir ߼ +* UINT16 pOutLgcSec[TRAIN_INCLUDE_RES_MAX_SUM] Դõ߼ID飨Σ +* @return wAxleId)) + && ((0U < (wTrainId & 0x00FFU)) && (0x00FFU > (wTrainId & 0x00FFU))) + && ((DIR_SAME == cDir) || (DIR_CONVERT == cDir)) + && (NULL != pOutLgcSec)) + { + wAxisSecIncLogicSum = GetAxisSecLogSectionSum(wAxleId); + pAxisSecIncLogicSecIdBuf = GetAxisSecLogSectionIdBuf(wAxleId); + + if ((0U < wAxisSecIncLogicSum) && (NULL != pAxisSecIncLogicSecIdBuf)) + { + if (DIR_SAME == cDir) + { + for (ii = 0U; ii < wAxisSecIncLogicSum; ii++) + { + cResUsableState = GetLogSecTrainResUsableState(pAxisSecIncLogicSecIdBuf[ii], wTrainId); /*ȡ߼ζӦгԴ*/ + if (LOGIC_SECTION_RES_USABLE == cResUsableState) + { + pOutLgcSec[cOutLgcSecSum] = pAxisSecIncLogicSecIdBuf[ii]; /*˳߼*/ + cOutLgcSecSum++; + cQueryFlag = FLAG_SET; + } + else if(FLAG_SET == cQueryFlag) + { + (void)CommonMemSet(pOutLgcSec, (UINT32)(cOutLgcSecSum * sizeof(UINT16)), 0U, (UINT32)(cOutLgcSecSum * sizeof(UINT16))); /*;鵽Դ֮ǰ洢߼*/ + cOutLgcSecSum = 0U; + cQueryFlag = FLAG_UNSET; /*λ*/ + } + else + { + /**/ + } + } + } + else + { + for (ii = wAxisSecIncLogicSum; ii > 0U; ii--) + { + cResUsableState = GetLogSecTrainResUsableState(pAxisSecIncLogicSecIdBuf[ii - 1U], wTrainId); /*ȡ߼ζӦгԴ*/ + if (LOGIC_SECTION_RES_USABLE == cResUsableState) + { + pOutLgcSec[cOutLgcSecSum] = pAxisSecIncLogicSecIdBuf[ii - 1U]; /*˳߼*/ + cOutLgcSecSum++; + cQueryFlag = FLAG_SET; + } + else if (FLAG_SET == cQueryFlag) + { + (void)CommonMemSet(pOutLgcSec, (UINT32)(cOutLgcSecSum * sizeof(UINT16)), 0U, (UINT32)(cOutLgcSecSum * sizeof(UINT16))); /*;鵽Դ֮ǰ洢߼*/ + cOutLgcSecSum = 0U; + cQueryFlag = FLAG_UNSET; /*λ*/ + } + else + { + /**/ + } + } + } + retVal = cOutLgcSecSum; + } + else + { + /*ȡΰ߼ʧܣUINT8_MAXʧ*/ + } + } + else + { + /*ηǷUINT8_MAXʧ*/ + } + + return retVal; +} + +/* +* ȡָID߼ABLӽñ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ABLг߼ʹñ־ +*/ +UINT8 GetLogSecAblUseFlag(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ȡABLг߼ʹñ־ */ + retVal = LogicSectionDataStru[bufIndex].chAblRelLogSecUsableFlag; + } + else + { + /** ȡʧ */ + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID߼ABLӽñ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 ablUseFlag, ABLӽñ־ +* ֵ +* +*/ +void SetLogSecAblUseFlag(const UINT16 logSectionId, const UINT8 ablUseFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** κϷ */ + if ((LOGIC_ABLNEAR_USE_FLAG_YES == ablUseFlag) || (LOGIC_ABLNEAR_USE_FLAG_NO == ablUseFlag)) + { + /** ָID߼ABLӽñ־*/ + LogicSectionDataStru[bufIndex].chAblRelLogSecUsableFlag = ablUseFlag; + } + else + { + /** */ + } + } + else + { + /** */ + } +} + +/* +* ȡָID߼ʱȡֵ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ UINT8_MAX: ȡʧ +* >0: ʱȡֵ +* BY CGH 20240415 +*/ +UINT8 GetLogSecXiansuSpeed(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = UINT8_MAX; + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ȡָID߼ʱȡֵ */ + retVal = LogicSectionDataStru[bufIndex].chLinShiXianSuSetSpeed; + } + else + { + ; /*MAX*/ + } + return retVal; +} + + +/* +* ָID߼ʱȡֵ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 ablUseFlag, ʱȡֵ +* ֵ +* BY CGH 20240415 +*/ +void SetLogSecXiansuSpeed(const UINT16 logSectionId, const UINT8 chXiansuSpeed) +{ + UINT16 bufIndex = 0U; /*±*/ + + /** ȡ߼± */ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ */ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /** ָID߼ʱȡֵ*/ + LogicSectionDataStru[bufIndex].chLinShiXianSuSetSpeed = chXiansuSpeed; + } + else + { + /** */ + } +} + +/* +* CI͵߼η·ID +* ˵const UINT16 wLogSectionId ߼ID +* const UINT16 wPLockRouteId ·ID +* ֵ +* Created By LQ 2024.06.11 +*/ +void SetLogSecOtherCiPLockRouteId(const UINT16 wLogSectionId, const UINT16 wPLockRouteId) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId) ; /*ȡ±*/ + + if ((LOGIC_SECTION_SUM_MAX > wBufIndex) && (ROUTE_SUM_MAX > wPLockRouteId)) + { + LogicSectionDataStru[wBufIndex].OtherCiPLockBelongRouteId = wPLockRouteId; /*CI·ID*/ + } + else + { + /*ηǷ*/ + } +} + +/* +* CI͵߼η·ID +* ˵const UINT16 wLogSectionId ߼ID +* ֵCI͵߼η·ID +* Created By LQ 2024.06.11 +*/ +UINT16 GetLogSecOtherCiPLockRouteId(const UINT16 wLogSectionId) +{ + UINT16 wRetVal = 0U; + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wRetVal = LogicSectionDataStru[wBufIndex].OtherCiPLockBelongRouteId; /*CI·ID*/ + } + else + { + /*ηǷ*/ + } + + return wRetVal; +} + +/* +* ȡָID߼η·ͱ־ +* ˵const UINT16 wLogSecId ߼ID +* ֵ CI_ERROR 0 +* CI_SUCCESS 1 +* Created By LQ 2024.06.11 +*/ +UINT8 GetLogSecPLockRouteCmdSendFlag(const UINT16 wLogSecId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 bufIndex = 0U; + UINT8 cLocalCiId = 0U; + UINT8 cSecBelongCiId = 0U; /*CI*/ + UINT8 cSecLockState = PHYSICAL_SECTION_LOCK_NO; /*״̬*/ + UINT16 wSecRLockBelongRouteId = 0U; /*ν··*/ + UINT16 wSecPLockBelongRouteId = 0U; /*η·*/ + UINT8 cRRouteBelongCiId = 0u; /*··CI*/ + UINT8 cPRouteBelongCiId = 0u; /*·CI*/ + UINT16 OtherCiPLockRouteId = 0U; /*CI͵߼η·ID*/ + + bufIndex = GetlogSectionBufIndex(wLogSecId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + /******** 1.жǷΪ ********/ + cLocalCiId = GetSystemParaLocalCiId(); + cSecBelongCiId = GetLogSecBelongCiId(wLogSecId); + + if ((0U != cLocalCiId) && (cLocalCiId == cSecBelongCiId)) + { + /******** 2.жǷΪջʱ ********/ + cSecLockState = GetLogSecLockState(wLogSecId); + + if ((LOG_SECTION_LOCK_NORMAL == cSecLockState) || (LOG_SECTION_LOCK_DELAY == cSecLockState)) + { + /********* 3.жǷ··DZң·ҲDZ޷· ********/ + wSecRLockBelongRouteId = GetLogSecLockBelongRoute(wLogSecId); /*ȡ··*/ + cRRouteBelongCiId = GetRouteBelongCiId(wSecRLockBelongRouteId); + wSecPLockBelongRouteId = GetLogSecPLockRouteId(wLogSecId); /*ȡ·*/ + cPRouteBelongCiId = GetRouteBelongCiId(wSecPLockBelongRouteId); + + if ((cLocalCiId != cRRouteBelongCiId) && (0U != cRRouteBelongCiId) && ((cRRouteBelongCiId == cPRouteBelongCiId) || (0U == cPRouteBelongCiId))) + { + /********* 4.жǷ񱾿η···η·ͬ ********/ + OtherCiPLockRouteId = GetLogSecOtherCiPLockRouteId(wLogSecId); + if (OtherCiPLockRouteId != wSecPLockBelongRouteId) + { + cRetVal = CI_SUCCESS; /*η···η·ͬ1*/ + } + else + { + /*·ͬ*/ + } + } + else + { + /*··㣬*/ + } + } + else + { + /*״̬㣬*/ + } + } + else + { + /*DZΣ*/ + } + } + else + { + cRetVal = CI_ERROR; /*߼IDǷ0*/ + } + + return cRetVal; +} + + +/* +* ý·ȥεABLг־ +* ˵UINT16 wLogSectionId ȥ߼ID +* UINT8 setFlag ȥεABLг־ +* ֵ +*/ +void SetRouteLeaveLogSecFlag(UINT16 wLogSectionId, UINT8 setFlag) +{ + + UINT16 wBufIndex = 0u; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + if ((LOGSEC_LEAVE_LOGSEC_REPLY_YES == setFlag) || (LOGSEC_LEAVE_LOGSEC_REPLY_NO == setFlag)) + { + LogicSectionDataStru[wBufIndex].cRouteLeaveLogFlag = setFlag; + } + } + +} + +/* +* ȡ߼εABLг־ +* ˵ const UINT16 wLogSectionId ȥ߼ID +* ֵ >0 ȥεABLг־ +* 0 ȡʧ +*/ +UINT8 GetRouteLeaveLogFlag(const UINT16 wLogSectionId) +{ + UINT8 wRetVal = 0U; + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (LOGIC_SECTION_SUM_MAX > wBufIndex) + { + wRetVal = LogicSectionDataStru[wBufIndex].cRouteLeaveLogFlag; /*߼εABLг־*/ + } + else + { + /*ηǷ*/ + } + return wRetVal; +} + +/* +* ȡָID߼߼· +* ˵ const UINT16 wLgcId, ߼ID +* OUT LogSecLockBelLogRouteStruct szLogSecLockBelLogRouteData[LOGSEC_RELATE_ROUTE_SUM_MAX] ָID߼߼· +* ֵ ָID߼߼·Ŀ +* : cgh 2024-09-10 +*/ +UINT8 GetLogSecLockBelLogRouteBuf(const UINT16 wLgcId,OUT LogSecLockBelLogRouteStruct szLogSecLockBelLogRouteData[LOGSEC_RELATE_ROUTE_SUM_MAX]) +{ + UINT16 wBufIndex = 0U; /*±*/ + UINT8 chReval = CI_ERROR; + + wBufIndex = GetlogSectionBufIndex(wLgcId); /*ȡ߼±*/ + + if ((LOGIC_SECTION_SUM_MAX > wBufIndex) && (NULL != szLogSecLockBelLogRouteData)) + { + chReval = LogicSectionDataStru[wBufIndex].chLogSecLockBelLogRouteSum; + (void)CommonMemCpy((void*)(szLogSecLockBelLogRouteData), (UINT32)(LOGSEC_RELATE_ROUTE_SUM_MAX * (UINT32)sizeof(LogSecLockBelLogRouteStruct)), (void*)(LogicSectionDataStru[wBufIndex].szLogSecLockBelLogRouteData), (UINT32)(LOGSEC_RELATE_ROUTE_SUM_MAX * (UINT32)sizeof(LogSecLockBelLogRouteStruct))); + } + else + { + + } + return chReval; +} + +/* +* ûͨ߼״̬ +* ˵UINT16 wLogSectionId, ID + const UINT8 lockState,״̬ +* ֵ +* by cgh 20250117 +*/ +void SetLogSecLockStateHlht(UINT16 wLogSectionId, const UINT8 lockState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 preLockState = 0u; + + bufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + LogicSectionDataStru[bufIndex].LogLockState = lockState; + } + else + { + /**/ + } +} + +/* +* ûͨ߼ϵ״̬ +* ˵UINT16 wLogSectionId ߼ID +* const UINT8 lockState ϵ״̬ +* ֵ +*/ +void SetLogSecStartLockStateHlht(UINT16 wLogSectionId, const UINT8 lockState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 preLockState = 0u; + + bufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + preLockState = LogicSectionDataStru[bufIndex].LogLockState; + + if (LOG_SECTION_LOCK_START != preLockState) + { + if (LOG_SECTION_LOCK_START == lockState) + { + LogicSectionDataStru[bufIndex].LogLockState = lockState; + } + else + { + /*άֵǰ״̬*/ + } + } + else + { + LogicSectionDataStru[bufIndex].LogLockState = lockState; + } + } + else + { + /**/ + } +} + +/* +* ûͨ߼εշ +* ˵UINT16 wLogSectionId, ߼ID + const UINT8 lockDir,շ +* ֵ +* by cgh 20250117 +*/ +void SetLogSecLockDirHlht(UINT16 wLogSectionId, const UINT8 lockDir) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + if (CI_SYSTEM_DIRECTION_NONE == lockDir) + { + LogicSectionDataStru[bufIndex].LogLockDir = CI_SYSTEM_DIRECTION_NONE; + } + else + { + LogicSectionDataStru[bufIndex].LogLockDir = lockDir; + } + } + else + { + /**/ + } +} + +/* +* ûͨ߼αĽ·ID +* ˵UINT16 wLogSectionId, ߼ID + const UINT16 routeId,Ľ·ID +* ֵ +* by 20250117 +*/ +void SetLogSecPLockRouteIdHlht(UINT16 wLogSectionId, const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + LogicSectionDataStru[bufIndex].wPLockBelongRouteId = routeId; + } + else + { + /**/ + } +} + +/* +* ûͨ߼Ľ·ID +* ˵UINT16 wLogSectionId, ߼ID + const UINT16 routeId,Ľ·ID +* ֵ +* by 20250117 +*/ +void SetLogSecRLockRouteIdHlht(UINT16 wLogSectionId, const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetlogSectionBufIndex(wLogSectionId); /*ȡ±*/ + + if (bufIndex < LOGIC_SECTION_SUM_MAX) + { + LogicSectionDataStru[bufIndex].LogLockBelongRoute = 0U; + } + else + { + /**/ + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/LogicSectionDataManage.h b/TSCP/src/APP/ciapp/Section/LogicSectionDataManage.h new file mode 100644 index 0000000..f76d995 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/LogicSectionDataManage.h @@ -0,0 +1,1301 @@ +/******************************************************** +* +* LogicSectionDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-20 +* ߣ +* ߼ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _LOGIC_SECTION_DATA_MANAGE_H_ +#define _LOGIC_SECTION_DATA_MANAGE_H_ + + +#include "SectionDefine.h" +#include "LogicSectionConfigDataManage.h" +#include "CommonTypes.h" +#include "../DataManage/DeviceDataManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + /*add by qw.liu 2022-02-23 Ӽ¼гԴ״̬*/ +typedef struct S_LogicTrainResStruct +{ + UINT16 wTrainId; /*гID*/ + UINT8 chTrainApplyState; /*г״̬*/ + UINT8 chLogicResUsable; /*гԴ״̬ 0x55 0xaa */ + UINT8 chLogicReturnState; /*۷߼α־ 0x55 ۷ 0xaa ۷*/ + UINT8 chLogicUnlockState; /*гͷű־ 0x55 0xaa δ*/ + UINT8 chTrainLevel; /*г гĬ0 VBTC Ϊ0x03*/ + UINT32 dwRcvUnlockCmdCyc; /*յ*/ +}LogicTrainResStruct; + + +/*add by cgh 2023-10-11*/ +typedef struct S_LogSecLockBelLogRouteStruct +{ + UINT16 wLogSecLockBelLogRouteId; /*߼߼·ID*/ + UINT8 chLogSecLockBelLogRouteState; /*߼߼·״̬*/ + UINT8 wLogSecLockBelLogRouteDir; /*߼α߼·յķ*/ + +}LogSecLockBelLogRouteStruct; + +typedef struct S_LogicSectionDataStruct +{ + UINT16 LogicSectionId; /*߼ID (ʼֶ)*/ + UINT16 BelongAxisSecId; /*ID (ʼֶ)*/ + UINT8 PreOccupyState; /*߼֮ǰռ״̬(/ռ) (ֶ̬)*/ + UINT8 CurOccupyState; /*߼εǰռ״̬(/ռ) (ֶ̬)*/ + UINT8 LinShiXianSuSetFlag; /*߼ʱ״̬(Ч//δ)(ֶ̬)*/ + UINT8 chLinShiXianSuSetSpeed; /*߼ʱٶֵ(ֶ̬)*/ + UINT8 zcMaskData; /* ZCλ״̬,bit0:UT bit1:CT */ + UINT8 maskCount; /* ߼ռõҪλһλۼ1Σ2 */ + UINT8 OccupyState; /*߼γʼ״̬/ռãֶ̬Σ*/ + UINT8 TXOccupyState; /*߼ͨųռóʼ״̬/ռãֶ̬Σ*/ /*TSCIϲ 20221208-lc*/ + UINT8 LogLockState; /*߼״̬*/ + UINT8 LogLockDir; /*շ*/ + UINT16 LogLockBelongRoute; /*߼·*/ + UINT32 LogUnlockStartCycNum; /*߼ʱʼں*/ + UINT16 wPLockBelongRouteId; /*յĽ·*/ + UINT16 OtherCiPLockBelongRouteId; /*͵η·ID (ֶ̬)*/ + UINT8 chTrainInfoSum; /*add by qw.liu 2022-02-23 гϢ*/ + LogicTrainResStruct szTrainResData[LOGIC_SECTION_RES_SUM_MAX]; /*add by qw.liu 2022-02-23 гԴϢṹ*/ + + UINT8 cResReqOtherCIId; /*ԴID*/ + UINT16 wResReqTrainId; /*ԴгID*/ + UINT8 chResShareFlag; /*Դ־ 0x55 Դ 0xAAǹԴ*/ + UINT16 JumpLockTrainId; /*ԾгIDֶ̬Σ*/ + UINT8 LogJumpLockState; /*߼Ծ״̬ 0x55 δգ0xAA գֶ̬Σ*/ + UINT8 LogJumpLockDelayUnlockFlag; /*߼Ծʱñ־ 0x55 δã0xaa ãֶ̬Σ*/ + UINT32 LogSecJumpDelayUnlockStartCyc; /*߼Ծʱʼں (ֶ̬)*/ + UINT8 LogSecJumpLockPermFlag; /*߼Ծ־ 0x55 0xaa ֹ (ֶ̬)*/ + UINT8 chXianSuRemoveState; /*г״̬*/ + UINT8 chArbState; /*߼ARB״̬*/ + UINT32 LogErrlockStartCycNum; /*߼ʱùʼں*/ + UINT8 chLogicProResUsable; /*߼ηԴ״̬ 0x55 0xaa */ + UINT8 chLogicSpksFLockState; /*߼αSPKS״̬ 0x55 δ 0xaa */ + UINT8 chLogSecLockBelLogRouteSum; /*߼߼·*//* add 20231010 cgh*/ + LogSecLockBelLogRouteStruct szLogSecLockBelLogRouteData[LOGSEC_RELATE_ROUTE_SUM_MAX];/*߼߼·*//* add 20231010 cgh*/ + + UINT8 LogSecLogLockState; /*߼߼״̬*//* add 20231012 cgh*/ + UINT8 LogSecLogLockDir; /*߼߼շ*//* add 20231013 cgh*/ + + UINT8 chAblRelLogSecUsableFlag; /*ABLг߼ʹñ־*/ + UINT8 cRouteLeaveLogFlag; /*һȥABLгǷͨͷ*/ +} LogicSectionDataStruct; + +/* ʱٽṹ */ +typedef struct S_TsrDataStruct +{ + UINT8 cSpeed;/* ֵÿСʱ */ + UINT8 cLogSecSum;/* ߼ */ + UINT16 szLogSecId[TSR_SEC_MAX_SUM];/* ߼ID */ +} TsrDataStruct; + +/*******************************ȫֱ*******************************/ +extern LogicSectionDataStruct LogicSectionDataStru[LOGIC_SECTION_SUM_MAX]; /*߼ݽṹ*/ +extern UINT8 WholeLineLinShiXianSuFlag; /*ȫʱٱ־Ĭ*/ +/* +* ȡ߼ +* ˵ void +* ֵ 0: ȡʧ +* >0: ߼ǰ +*/ +LogicSectionDataStruct* GetLogicSecData(void); + +/* +* ȡָID߼֮ǰռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ֮ǰռ״̬ +*/ +UINT8 GetLogSecPreOccupyState(const UINT16 logSectionId); + +/* +* ȡָID߼εǰռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetLogSecCurOccupyState(const UINT16 logSectionId); + +/* +* ȡָID߼εǰCTUTռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetLogSecCurCtOrUtOccupyState(const UINT16 logSectionId); + +/* +* ȡָID߼ʱ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ǰʱ״̬ +*/ +UINT8 GetLogSecLinShiXianSuSetState(const UINT16 logSectionId); + +/* +* ָID߼εǰռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 curOccupyState, ǰռ״̬ +* ֵ +* +*/ +void SetLogSecCurOccupyState(const UINT16 logSectionId, const UINT8 curOccupyState); + +/* +* ָID߼֮ǰռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 curOccupyState, ֮ǰռ״̬ +* ֵ +* +*/ +void SetLogSecPreOccupyState(const UINT16 logSectionId, const UINT8 curOccupyState); + + +/* +* ָID߼ʱ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 linShiXianSuSetState, ʱ״̬ +* ֵ +* +*/ +void SetLogSecLinShiXianSuState(const UINT16 logSectionId, const UINT8 linShiXianSuSetState); + +/* +* ָλӦ߼ռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 occupyStateMask, ǰռλ +* ֵ +* +*/ +void SetLogSecMask(const UINT16 logSectionId, const UINT8 occupyStateMask); + + +/* +* ȡָ߼ռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 GetLogSecOccupyState(const UINT16 logSectionId); +/* +* ָID߼ռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 curOccupyState, ǰռ״̬ +* ֵ +* +*/ +void SetLogSecOccupyState(const UINT16 logSectionId, const UINT8 curOccupyState); + +/* +* ָID߼ͨųλRMռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 curOccupyState, ǰռ״̬ +* ֵ +*ע߼ͨųλRMռ״̬úA by yt 2022519 +*/ +void SetLogSecTXOccupyState(const UINT16 logSectionId, const UINT8 curOccupyState); + +/* +* ȡָID߼ͨųռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ʧ +* 0x55޳ռ +* 0xaaͨųռ +*/ +UINT8 GetLogSecTXOccupyState(const UINT16 logSectionId); + +/* +* ȡȫʱٱ־ +* ˵ +* +* ֵ ȫʱٱ־ +*/ +UINT8 GetWholeLineLinShiXianSuFlag(void); + +/* +* ȫʱٱ־ +* ˵ UINT8 flag,ٱ־ +* +* ֵ +* +*/ +void SetWholeLineLinShiXianSuFlag(UINT8 flag); + +/* +* ȡָ߼״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* 1: ߼״̬ +*/ +UINT8 GetLogSecLockState(const UINT16 logSectionId); + + +/* +* ȡָ߼շ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼շ +*/ +UINT8 GetLogSecLockDir(const UINT16 logSectionId); + +/* +* ָ߼״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ +* +*/ +void SetLogSecLockState(const UINT16 logSectionId,const UINT8 lockState,const UINT16 routeId,const UINT8 lockDir); + +/* +* ȡָ߼· +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼· +*/ +UINT16 GetLogSecLockBelongRoute(const UINT16 logSectionId); + +/* +* ȡָID߼֮ǰCT/UTռ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ֮ǰCT/UTռ״̬ +*/ +UINT8 GetLogSecPreCtOrUtOccupyState(const UINT16 logSectionId); + +/* +* ָ߼ʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* const UINT32 startCycNum ʼں +* ֵ +* +*/ +void SetLogUnlockStartCycNum(const UINT16 logSectionId, const UINT32 startCycNum); + +/* +* ÷DZָID߼״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 lockState, ״̬ +* const UINT16 routeId, ·ID +* const UINT8 lockDirection, շ +* ֵ +* +*/ +void SetLogSecLockStateOtherCI(const UINT16 logSectionId, const UINT8 lockState, const UINT16 routeId, const UINT8 lockDirection); + +/* +* ȡָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ NULL: ȡʧ +* !NULL: ߼ԴгϢ +*/ +LogicTrainResStruct *GetLogSecTrainInfoById(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* ȡָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ NULL: ȡʧ +* !NULL: ߼ԴгϢ +*/ +LogicTrainResStruct *GetLogSecTrainInfo(const UINT16 wLogSectionId); + +/* +* Ƴָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ +* +*/ +void RemoveLogSecTrainInfoById(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* ȡָ߼Դг +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ Դг +*/ +UINT8 GetLogSecTrainInfoSum(const UINT16 wLogSectionId); + +/* +* ȡǷг߼ձ־ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 GetLogSecTrainLockSendFlag(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* ȡг߼۷״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 GetLogSecTrainReturnState(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* г߼۷״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ CI_ERROR +* CI_SUCCESS +*/ +void SetLogSecTrainReturnState(const UINT16 wLogSectionId, const UINT16 wTrnId, const UINT8 chResReturnState); + +/* +* г߼ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ VOID +* qw.liu 2022-03-03 +*/ +void AddLogSecTrainRes(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* г߼ +* ˵ const UINT16 logSectionId, ߼ID, +* const UINT16 wTrnId гID +* ֵ VOID +*/ +void AddLogSecTrainResFromCI(const UINT16 wLogSectionId, const UINT16 wTrnId); +/* +* ߼·߼ԴгID +* ˵ const UINT16 wLogRouteId, ߼·ID +* const UINT16 wTrainId г +* ֵ +*/ +void SetLogRouteLogSecResTrainId(const UINT16 wLogRouteId, const UINT16 wTrainId); + + +/* +* TIOCг߼ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 cTrainSumг +* UINT16* pTrainIdг +* ֵ VOID +* qw.liu 2022-03-03 +*/ +void AddLogSecOtherTIOCTrainRes(const UINT16 wLogSectionId, const UINT8 cTrainSum, UINT16* pTrainId); +#if 1 +/* +* ɾָ߼гԴ +* ˵ UINT16 wLogSecId, ߼ID +* UINT16 wTrainId ɾгԴ± +* ֵ +*/ +void RemoveLgcSecResTrain(UINT16 wLogSecId, UINT16 wTrainId); +#endif +/* +* г߼ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ VOID +*/ +void SetLogSecTrainLockApply(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* ȡָг߼չ߼·ID +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ =0ڸó߼·>0 ó߼·ID +*/ +UINT16 GetLogSecBelongLogRouteId(const UINT16 wLogSectionId, const UINT16 wTrnId); +/* +* ߼·г߼ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ VOID +*/ +void SetLogRouteLogSecTrainLockApply(const UINT16 wLogSectionId, const UINT16 wTrnId); +#if 0 +/* +* гͷ߼Դ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 wTrnIdгID +* ֵ VOID +*/ +void LogSecTrainLockRelease(const UINT16 wLogSectionId, const UINT16 wTrnId); +#endif + +/* +* ָ߼η·ID +* ˵const UINT16 wLogSectionId ߼ID +* const UINT16 wPLockRouteId ·ID +* ֵ +* Created By LQ 2024.06.11 +*/ +void SetLogSecPLockRouteId(const UINT16 wLogSectionId, const UINT16 wPLockRouteId); + +/* +* ȡָ߼· +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼· +*/ +UINT16 GetLogSecPLockRouteId(const UINT16 logSectionId); + +/* +* г߼ο״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* const UINT8 chUseState ״̬ +* ֵ VOID +*/ +void SetLogSecTrainUseState(const UINT16 wLogSectionId, const UINT16 wTrnId, const UINT8 chUseState); + +/* +* ȡָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ NULL: ȡʧ +* !NULL: ߼ԴгϢ +*/ +UINT16 GetLogSecTrainIdByIndex(const UINT16 wLogSectionId, const UINT8 chIndex); + +/* +* ȡг߼״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ 0ʧ 0x55: 0xaa:δ +*/ +UINT8 GetLogSecTrainApply(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* г߼ͷ״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* const UINT8 chUseState ״̬ +* const UINT8 chTrainlevel г𣺱0 VBTVΪ0X03 UR 0X01 +* ֵ VOID +*/ +void SetLogSecTrainRelease(const UINT16 wLogSectionId, const UINT16 wTrnId, const UINT8 chTrainlevel); + + +/* +* ȡг߼ͷ״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ 0ʧ 0x55: 0xaa:δ +*/ +UINT8 GetLogSecTrainRelease(const UINT16 wLogSectionId, const UINT16 wTrnId); +/* +* ȡ߼Դͷ״̬г򷵻룩 +* ˵ const UINT16 wLogSectionId, ߼ID +* ֵ 0ʧ 0x55: 0xaa:δ +*/ +UINT8 GetLogSecReleaseFlag(const UINT16 wLogSectionId); + +/* +* ȡ߼ͷг +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT16 wTrnId гID +* ֵ 0г 0x03:VBTC 0x01:VBTC +*/ +UINT8 GetLogSecReleaseTrainLevel(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* ߼гԴϢ +* ˵ UINT16 wLogSecId, ߼ID +* ֵ +* ޸ģ߼·гϢ +*/ +void ClearLgcSecResTrain(UINT16 wLogSecId); + +/* +* ȡ߼ηԴID +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0u +* ID +*/ +UINT8 GetLogSecResReqOtherCIId(const UINT16 wLogSectionId); +/* +* ߼ηԴID +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 cOtherId,ID +* +*/ +void SetLogSecResReqOtherCIId(const UINT16 wLogSectionId, const UINT8 cOtherId); + +/* +* ȡ߼ηCIԴгID +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0u +* гID +*/ +UINT16 GetLogSecResReqTrainId(const UINT16 wLogSectionId); + +/* +* ߼ηCIԴгID +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 wTrainId,гID +* +*/ +void SetLogSecResReqTrainId(const UINT16 wLogSectionId, const UINT16 wTrainId); + +/** +* @brief ߼Դ۷״̬ +* @param UINT16 wLogicId +* @param UINT8 chFlag +* @return +*/ +void SetLogSecAllTrainReturnState(const UINT16 wLogicId, const UINT8 chFlag); + +/** +* @brief ߼ռ״̬ +* @param +* @return +*/ +void SetAllLgcOccupyState(void); + +/* +* ߼гԴϢ +* ˵ UINT16 wLogSecId, ߼ID +* ֵ +*/ +void CpyLgcSecResTrain(UINT16 wLogSecId, UINT8 chTrainSum, LogicTrainResStruct *pstLgcResInfo); + +/* +* ȡָ߼ʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼ʱʼں +*/ +UINT32 GetLogUnlockStartCycNum(const UINT16 logSectionId); + +/* +* @brief ȡָID߼ιԴ־ +* @param const UINT16 wLgcSecId, ߼ID +* @return 0x55: Դ +* 0xaa: ǹԴ +* CI_ERROR:ʧ +*/ +UINT8 GetLogSecResShareFlag(const UINT16 wLgcSecId); + +/* +* @brief ָID߼ιԴ־ +* @param const UINT16 wLgcSecId, ߼ID +* @param const UINT16 chShrFlag, Դ־ +* @return +*/ +void SetLogSecResShareFlag(const UINT16 wLgcSecId, const UINT8 chShrFlag); + +/* +* ȡʱ +* ˵ +* ֵ +*/ +extern UINT8 GetTsrSum(void); + + +/* +* ȡָ߼ηλСʱֵ +* ˵UINT16* minSpeed Сʱֵ() +* UINT16 logSum ߼() +* UINT16 szLogId[] ߼ID() +* ֵ CI_ERROR ȡʧ +* CI_SUCCESS ȡɹ +*/ +UINT8 GetBackUpVobcMinTsr(UINT16* minSpeed, UINT16 logSum, UINT16 szLogId[]); + +/* +* ʱ +* ˵ UINT8 cTsrSum +* ֵ +*/ +void SetTsrSum(UINT8 cTsrSum); + +/* +* ȡʱ +* ˵ +* ֵ +*/ +extern TsrDataStruct* GetTsrData(void); + +/* +* ʱʱ +* ˵ UINT8 cTsrSum +* TsrDataStruct* TsrData +* ֵ CI_ERRORʧ;CI_SUCCESS ɹ +*/ +extern UINT8 SetLocalTsrData(UINT8 cTsrSum, TsrDataStruct* pTsrData, UINT8 cAllLineTsrState, UINT8 cAllLineTsrSpeed); + +/* +* TIOC߼ʱٱ־ +* ˵ +* ֵ +*/ +extern void ClearLocalTiocLogSecTsr(void); + +/* +* ȡָID߼ͷԾгID +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: гID +*/ +UINT16 GetLogSecJumpLockTrainId(const UINT16 logSectionId); + +/* +* ָID߼ͷԾгID +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 trainId, гID +* ֵ +* +*/ +void SetLogSecJumpLockTrainId(const UINT16 logSectionId, const UINT16 trainId); + +/* +* ָID߼ԾгID +* ˵ const UINT16 logSectionId, ߼ID +* ֵ +* +*/ +void ClearLogSecJumpLockTrainId(const UINT16 logSectionId); + +/* +* жԾͷгIDԾгIDǷͬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 trainId, гID +* ֵ CI_ERROR ͬһг +CI_SUCCESS ͬһг +* +*/ +UINT8 JudgeLogSecJumpLockRelTrainId(const UINT16 logSectionId, const UINT16 trainId); + +#if 0 + + +/*HERE +* ȡָID߼Ծ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetLogSecJumpLockApplyFlag(const UINT16 logSectionId); + +/* +* ָID߼Ծ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockApplyFlag, Ծ־ +* ֵ +* +*/ +void SetLogSecJumpLockApplyFlag(const UINT16 logSectionId, const UINT8 jumpLockApplyFlag); + +/* +* ȡָID߼Ծȡ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetLogSecJumpLockRelaseFlag(const UINT16 logSectionId); + +/* +* ָID߼Ծȡ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockCancelApplyFlag, Ծȡ־ +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetLogSecJumpLockRelaseFlag(const UINT16 logSectionId, const UINT8 jumpLockCancelApplyFlag); + +/* +* ȡָID߼Ծں +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծں +*/ +UINT32 GetLogSecJumpLockApplyCylce(const UINT16 logSectionId); + +/* +* ָID߼Ծں +* ˵ const UINT16 logSectionId, ߼ID +* const UINT32 jumpLockApplyCycle, Ծں +* ֵ +*/ +void SetLogSecJumpLockApplyCylce(const UINT16 logSectionId, const UINT32 jumpLockApplyCycle); + + +#endif +/* +* ȡָID߼Ծ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծ״̬ +*/ +UINT8 GetLogSecJumpLockState(const UINT16 logSectionId); + +/* +* ָID߼Ծ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void SetLogSecJumpLockState(const UINT16 logSectionId, const UINT8 jumpLockState); + +/* +* ȡָID߼Ծʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծʱʼں +*/ +UINT32 GetLogSecJumpDelayUnlocStartCyc(const UINT16 logSectionId); + +/* +* ָID߼Ծʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* const UINT32 startCycNum, ʼں +* ֵ +* +*/ +void SetLogSecJumpDelayUnlocStartCyc(const UINT16 logSectionId, const UINT32 startCycNum); + +/* +* ȡָID߼Ծʱñ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծʱñ־ +*/ +UINT8 GetLogSecJumpDelayUnlockFlag(const UINT16 logSectionId); + +/* +* ָID߼Ծʱñ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpDelayUnlockFlag, ʱñ־ +* ֵ +* +*/ +void SetLogSecJumpDelayUnlockFlag(const UINT16 logSectionId, const UINT8 jumpDelayUnlockFlag); + +/* +* ȡָID߼Ծ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: Ծ־ +*/ +UINT8 GetLogSecJumpLockPermFlag(const UINT16 logSectionId); + +/* +* ָID߼Ծ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockPermFlag, Ծ־ +* ֵ +* +*/ +void SetLogSecJumpLockPermFlag(const UINT16 logSectionId, const UINT8 jumpLockPermFlag); + +/* +* ߼Ծ߼ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void LogJumpLockCmdManage(const UINT16 logSectionId, const UINT8 jumpLockState); + +/* +* ȡʱٸ +* ˵ pData ݵַ +* dwIndex +* ֵ д +*/ +UINT32 GetTsrFollowData(UINT8* pData, UINT32 dwIndex); +/* +* ʱٸ +* ˵ pData ݵַ +* dwIndex +* ֵ +*/ +UINT32 SetTsrFollowData(UINT8* pData, UINT32 dwIndex); + +/** +* @brief ߼Ƿس +* @param wLgcId ߼ID +* @return CI_SUCCESSسCI_ERRORس +* @note ˺ж߼ΪCTռú +*/ +UINT8 IsLogicHaveNoSupicTrain(UINT16 wLgcId); + +/* +* @brief ߼г״̬ +* @details г󣬵ʽ·״̬ +* @param const UINT16 routeId ·ID +* const UINT8 chCiId CiID +* @return +*/ +void SetLgcXianSuRemoveState(const UINT16 wLgcId, const UINT8 chXianSuRemoveStt); + +#if 0 +/* +* ȡ߼г״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0u +* г״̬ +*/ +UINT8 GetLgcXianSuRemoveState(const UINT16 wLogSectionId); +#endif + +/* +* TIOCָID߼ʱ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 linShiXianSuSetState, ʱ״̬ +* ֵ +* +*/ +void SetLogSecXSSttOtherTioc(const UINT16 logSectionId, const UINT8 linShiXianSuSetState); + +/* +* ָ߼ι·ȷ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ +* +*/ +void ClearLgcSecBelongRtXsCfm(const UINT16 wLgcSecId); + +/* +* ȡг߼Դ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ LOGIC_SECTION_RES_UNUSABLE +* LOGIC_SECTION_RES_USABLE +*/ +UINT8 GetLogSecTrainResUsableState(const UINT16 wLogSectionId, const UINT16 wTrnId); + +/* +* ȡָ߼ԴгϢ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ NULL: ȡʧ +* !NULL: ߼ԴгϢ +*/ +UINT8 GetLgcSecResCanAdd(const UINT16 wLogSectionId, const UINT16 wTrnId); +#if 0 +/* +* @func ߼ǷԴ +* @param UINT16 wLgcSecId, ߼ID + +* @return CI_ERROR +* CI_SUCCESS +*/ +UINT8 LgcHaveUseableRes(UINT16 wLgcSecId); +#endif + +/* +* ȡָ߼ARB״̬ +* ˵ const UINT16 wLgcId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼ARB״̬ +*/ +UINT8 GetLgcArbState(const UINT16 wLgcId); + +/* +* ƶ߼ARB״̬ +* ˵ const UINT16 wLgcId, ߼ID +* const UINT8 chArb ARB״̬ +* ֵ +*/ +void SetLgcArbState(const UINT16 wLgcId, const UINT8 chArb); + +/* +* ߼ARB״̬ +* ˵ +* ֵ +*/ +void SetLgcArbStateProc(void); +/* +* ȡָ߼ʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼ʱʼں +*/ +UINT32 GetLogDelayErrlockStartCycNum(const UINT16 logSectionId); +/* +* ָ߼ʱʼں +* ˵ const UINT16 logSectionId, ߼ID +* const UINT32 startCycNum ʼں +* ֵ +* +*/ +void SetLogDelayErrlockStartCycNum(const UINT16 logSectionId, const UINT32 startCycNum); + +/** +* @brief ȡ߼Ƿس +* @param wLgcId ߼ID +* @return CI_SUCCESSسCI_ERRORس +* @note ȡг鿴Ƿпг +*/ +UINT8 GetLogicSupicTrainStat(UINT16 wLgcId); + +/* +* ȡгǷ߼λ򱣻· +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ CI_ERROR: +* CI_SUCCESS: +*/ +UINT8 GetTrainInLgcPRLock(const UINT16 wLogSectionId, const UINT16 wMinTailPointBelongLogSecId); + +/* +* ߼αԴ״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chUseState ״̬ +* ֵ VOID +* by cgh 20230630 ¼Դ״̬ +*/ +void SetLogSecProResUseState(const UINT16 wLogSectionId, const UINT8 chUseState); + +/* +* ȡ߼αԴ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ LOGIC_SECTION_PRO_RES_UNUSABLE +* LOGIC_SECTION_PRO_RES_USABLE +* * by cgh 20230630 ¼Դ״̬ +*/ +UINT8 GetLogSecProResUseState(const UINT16 wLogSectionId); + +/* +* ȡָ߼շǷӦȡ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ CI_ERROR: ȡ +* CI_SUCCESS: ȡ +* by cgh 20230802 ATSշλʱʹ +*/ +UINT8 GetLogSecLockDirOpposedFlag(const UINT16 wLogSectionId); + +/* +* ȡָ߼Ƿ߱ԴԶǰ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ CI_ERROR: ߱ +* CI_SUCCESS: ߱ +* by cgh 20230802 IVOCԴԶϢ +*/ +UINT8 GetLogSecHaveResOpp(const UINT16 wLogicSecId); + +/* +* η״̬ +* ˵ const UINT16 logicSecId, ߼ID +* ֵ: +*/ +void ClearLogicSecPLock(const UINT16 logicSecId); + +/* +* ߼SPKS״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* const UINT8 chLogicSpksFLockState ߼SPKS״̬ +* ֵ VOID +* by cgh 20230919 +*/ +void SetLogSecSpksFLockState(const UINT16 wLogSectionId, const UINT8 chLogicSpksFLockState); + +/* +* ȡ߼SPKS״̬ +* ˵ const UINT16 logSectionId, ߼ID +* +* ֵ LOGIC_SECTION_SPKS_FLOCK_NO δ +* LOGIC_SECTION_SPKS_FLOCK_YES +* by cgh 20230919 +*/ +UINT8 GetLogSecSpksFLockState(const UINT16 wLogSectionId); + +/* +* ȡָID߼߼· +* ˵const UINT16 wLgcId, ߼ID +* ֵ 0: ȡʧ +* >0: ߼߼· +* cgh 2023-10-10 +*/ +UINT8 GetLogSecLockBelLogRouteSum(const UINT16 wLgcId); + +/* +* ȡָID߼߼· +* ˵ const UINT16 wLgcId, ߼ID +* ֵ NULL: ȡʧ +* !NULL: ߼߼· +* : cgh 2023-10-10 +*/ +LogSecLockBelLogRouteStruct* GetLogSecLockBelLogRouteData(const UINT16 wLgcId); + +/* +* ָ߼ɾָ߼·ID +* ˵ const UINT16 logSectionId, ߼ID +const UINT16 wLogRouteId, ߼·ID +* +* ֵ CI_ERROR ɾʧ Ci_SUCCESSS ɾɹ +* fan 2023-10-11 +*/ +UINT8 DelLogSecBelongLogRouteId(const UINT16 logSectionId, const UINT16 wLogRouteId); + +/* +* ָ߼ָ߼·ID +* ˵ const UINT16 logSectionId, ߼ID +const UINT16 wLogRouteId, ߼·ID +* +* ֵ CI_ERROR ʧ Ci_SUCCESSS ӳɹ +* fan 2023-10-11 +*/ +UINT8 AddLogSecBelongLogRouteId(const UINT16 logSectionId, const UINT16 wLogRouteId); + + + +/* +* ȡָ߼߼״̬ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼߼״̬ +* by cgh 20231012 +*/ +UINT8 GetLogSecLogLockState(const UINT16 wLogSectionId); + +/* +* ȡָ߼߼շ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ 0: ȡʧ +* >0: ߼߼շ +* by cgh 20231013 +*/ +UINT8 GetLogSecLogLockDir(const UINT16 wLogSectionId); + +/* +* ָ߼״̬뷽 +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 chLogLockState ߼߼״̬ +* const UINT8 chLogLockDir ߼߼շ +* ֵ +* by cgh 20231012 +*/ +void SetLogSecLogLockState(const UINT16 wLogSectionId, const UINT8 chLogLockState, const UINT8 chLogLockDir); + + + + +#if 0 +/* +* ȡ߼·ijһǷ߱ԴԶǰ +* ˵ const UINT16 wLogSectionId, ߼ID +* +* ֵ CI_ERROR: һ߼ +* CI_SUCCESS: һ߼ +* by cgh 20231016 +*/ +UINT8 CheckLogRouteSecHaveResOpp(const UINT16 wLogicSecId); +#endif + + +/** +* @brief ߼߼· +* @param const UINT16 wLogRouteId ߼·ID +* @param const UINT16 wLogRouteRelatePsdId ߼·ID +* @return +* @noteby cgh 20231011 +*/ +void SetLogSecRelateLogRouteData(const UINT16 wLogRouteId, const UINT16 wLogSecId); + +/* +* ÷ָID߼ε߼״̬뷽 +* ˵ const UINT16 logSectionId ߼ID +* const UINT8 chLogLockState ߼߼״̬ +* const UINT8 chLogLockDir ߼߼շ +* const UINT8 cLogLockBelLogRouteSum ߼߼߼· +* ֵ +* Created By LQ 2023/10/20 +*/ +void SetLogSecLogLockStateOtherCi(const UINT16 wLogSectionId, const UINT8 chLogLockState, const UINT8 chLogLockDir, const UINT8 cLogLockBelLogRouteSum); + +/* +* ָ߼Ƿָָ߼· +* ˵ const UINT16 logSectionId, ߼ID +* const UINT16 wLogRouteId, ߼·ID +* ֵ CI_SUCCESS߼ι߼·CI_ERROR +* fan 2023-10-11 +*/ +UINT8 CheckLogRouteIdBelLogSec(const UINT16 logSectionId, const UINT16 wLogRouteId); + +/** +* @brief շȡָIDгԴõ߼ +* @param const UINT16 wAxleId ID +* const UINT16 wTrainId гID +* const UINT8 cDir ߼ +* UINT16 pOutLgcSec[TRAIN_INCLUDE_RES_MAX_SUM] Դõ߼ID飨Σ +* @return 0 ʱȡֵ +* @note by cgh 20240411 +*/ +UINT8 IsInTsrLogSecIdBuf(UINT16 wLogSecId); + +/* +* ȡָID߼ABLӽñ־ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ 0: ȡʧ +* >0: ABLг߼ʹñ־ +*/ +UINT8 GetLogSecAblUseFlag(const UINT16 logSectionId); + +/* +* ָID߼ABLӽñ־ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 ablUseFlag, ABLӽñ־ +* ֵ +* +*/ +void SetLogSecAblUseFlag(const UINT16 logSectionId, const UINT8 ablUseFlag); + +/* +* ȡָID߼ʱȡֵ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ UINT8_MAX: ȡʧ +* >0: ʱȡֵ +* BY CGH 20240415 +*/ +UINT8 GetLogSecXiansuSpeed(const UINT16 logSectionId); + +/* +* ָID߼ʱȡֵ +* ˵ const UINT16 logSectionId, ߼ID +* const UINT8 ablUseFlag, ʱȡֵ +* ֵ +* BY CGH 20240415 +*/ +void SetLogSecXiansuSpeed(const UINT16 logSectionId, const UINT8 chXiansuSpeed); + +/* +* CI͵߼η·ID +* ˵const UINT16 wLogSectionId ߼ID +* const UINT16 wPLockRouteId ·ID +* ֵ +* Created By LQ 2024.06.11 +*/ +void SetLogSecOtherCiPLockRouteId(const UINT16 wLogSectionId, const UINT16 wPLockRouteId); + +/* +* CI͵߼η·ID +* ˵const UINT16 wLogSectionId ߼ID +* ֵCI͵߼η·ID +* Created By LQ 2024.06.11 +*/ +UINT16 GetLogSecOtherCiPLockRouteId(const UINT16 wLogSectionId); + +/* +* ȡָID߼η·ͱ־ +* ˵const UINT16 wLogSecId ߼ID +* ֵ CI_ERROR 0 +* CI_SUCCESS 1 +* Created By LQ 2024.06.11 +*/ +UINT8 GetLogSecPLockRouteCmdSendFlag(const UINT16 wLogSecId); + + +/* +* ý·ȥεABLг־ +* ˵UINT16 wLogSectionId ȥ߼ID +* UINT8 setFlag ȥεABLг־ +* ֵ +*/ +void SetRouteLeaveLogSecFlag(UINT16 wLogSectionId, UINT8 setFlag); + +/* +* ȡ߼εABLг־ +* ˵ const UINT16 wLogSectionId ȥ߼ID +* ֵ >0 ȥεABLг־ +* 0 ȡʧ +*/ +UINT8 GetRouteLeaveLogFlag(const UINT16 wLogSectionId); + +/* +* ȡָID߼߼· +* ˵ const UINT16 wLgcId, ߼ID +* OUT LogSecLockBelLogRouteStruct szLogSecLockBelLogRouteData[LOGSEC_RELATE_ROUTE_SUM_MAX] ָID߼߼· +* ֵ ָID߼߼·Ŀ +* : cgh 2024-09-10 +*/ +UINT8 GetLogSecLockBelLogRouteBuf(const UINT16 wLgcId, OUT LogSecLockBelLogRouteStruct szLogSecLockBelLogRouteData[LOGSEC_RELATE_ROUTE_SUM_MAX]); + +/* +* ûͨ߼״̬ +* ˵UINT16 wLogSectionId, ID + const UINT8 lockState,״̬ +* ֵ +* by cgh 20250117 +*/ +void SetLogSecLockStateHlht(UINT16 wLogSectionId, const UINT8 lockState); + +/* +* ûͨ߼ϵ״̬ +* ˵UINT16 wLogSectionId ߼ID +* const UINT8 lockState ϵ״̬ +* ֵ +*/ +void SetLogSecStartLockStateHlht(UINT16 wLogSectionId, const UINT8 lockState); + +/* +* ûͨ߼εշ +* ˵UINT16 wLogSectionId, ߼ID + const UINT8 lockDir,շ +* ֵ +* by cgh 20250117 +*/ +void SetLogSecLockDirHlht(UINT16 wLogSectionId, const UINT8 lockDir); + +/* +* ûͨ߼αĽ·ID +* ˵UINT16 wLogSectionId, ߼ID + const UINT16 routeId,Ľ·ID +* ֵ +* by 20250117 +*/ +void SetLogSecPLockRouteIdHlht(UINT16 wLogSectionId, const UINT16 routeId); + +/* +* ûͨ߼Ľ·ID +* ˵UINT16 wLogSectionId, ߼ID + const UINT16 routeId,Ľ·ID +* ֵ +* by 20250117 +*/ +void SetLogSecRLockRouteIdHlht(UINT16 wLogSectionId, const UINT16 routeId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Section/PhysicalSectionConfigDataManage.c b/TSCP/src/APP/ciapp/Section/PhysicalSectionConfigDataManage.c new file mode 100644 index 0000000..1358e09 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/PhysicalSectionConfigDataManage.c @@ -0,0 +1,1568 @@ +/******************************************************** +* +* PhysicalSectionConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* νӿݹ +* ޸ļ¼ +* +********************************************************/ + +#include "PhysicalSectionConfigDataManage.h" +#include "AxisSectionConfigDataManage.h" + + + +PhysicalSectionConfigDataStruct PhysicalSectionConfigDataStru[PHYSICAL_SECTION_SUM_MAX]; /*ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiPhysicalSectionIdBuf[PHYSICAL_SECTION_SUM_MAX] = {0u}; /*屾IDӳ*/ +INT16 PhysicalSectionCurSum = 0; /*εǰ*/ +UINT16 totalPhysicalSectionNum = 0u;/*͸*/ + + +/* +* ȡָID +* ˵ const UINT16 phySectionId, ID +* ֵ PHYSICAL_SECTION_SUM_MAX: ȡʧ +* = 1u) && (phySectionId < PHYSICAL_SECTION_SUM_MAX)) + { + retVal = phySectionId; + } + else + { + ; + } + + return retVal; +} + + +/* +* ȡεǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: εǰ +*/ +UINT16 GetPhySecCurSum(void) +{ + UINT16 retVal = 0u; + if (PhysicalSectionCurSum >= (INT16)PHYSICAL_SECTION_SUM_MAX ) + { + retVal = PHYSICAL_SECTION_SUM_MAX; + } + else if (PhysicalSectionCurSum < 0) + { + retVal = 0u; + } + else + {/*[0,PHYSICAL_SECTION_SUM_MAX)ǿת֤ȫ*/ + retVal = (UINT16)PhysicalSectionCurSum; + } + return retVal; +} + +/* +* ȡָID +* ˵ +* ֵ + PhysicalSectionConfigDataStruct* +*/ +PhysicalSectionConfigDataStruct* GetPhySecConfigData(void) +{ + return PhysicalSectionConfigDataStru; +} + +/* +* ȡָ±ӦID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetPhySecId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 phySecTotalNum = GetTotalPhySecCurNum(); + if (bufIndex < phySecTotalNum) + { + retVal = LocalCiPhysicalSectionIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPhySecBelongCiId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].BelongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetPhySecType(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].PhySecType; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDмα־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: мα־ +*/ +UINT8 GetPhySecLjkFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].LjkSecFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDι̵ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPhySecGdRelayId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].GdRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDι̵ID2 +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPhySecGdRelayId2(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].wGdRelayId2; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDθλ̵ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: λ̵ID +*/ +UINT16 GetPhySecFWRelayId(const UINT16 phySectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].FWRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 PhySectionConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 phySectionConfigDataSum = 0u; /*豸*/ + UINT8 retVal = CI_SUCCESS; + + /*ID*/ + phySectionConfigDataSum = GetPhySecCurSum(); + totalPhysicalSectionNum = phySectionConfigDataSum; + if (phySectionConfigDataSum >= PHYSICAL_SECTION_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < PHYSICAL_SECTION_SUM_MAX; ii++) + { + if (jj == phySectionConfigDataSum) + {/*Ч*/ + + break; + } + + if (PhysicalSectionConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + LocalCiPhysicalSectionIdBuf[jj] = PhysicalSectionConfigDataStru[ii].PhysicalSectionId; + jj++; + } + + + } + } + + return retVal; +} + +/* +* ȡָSPKSĿ +* ˵ phySecId +* ֵ spks +*/ +UINT8 GetPhySecSpksSum(UINT16 phySecId) +{ + UINT8 spksNum = 0u; + UINT16 bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + spksNum = PhysicalSectionConfigDataStru[bufIndex].spksNum; + } + + return spksNum; +} + +/* +* ȡָ ָ±SPKSID +* ˵ phySecId +* spksIdIdx Spks± +* ֵ >0 spksId 0 : +*/ +UINT16 GetPhySecSpksIdBySpksIdx(UINT16 phySecId,UINT16 idx) +{ + UINT8 spksNum = 0u; + UINT16 spksId = 0u; + UINT16 bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + spksNum = PhysicalSectionConfigDataStru[bufIndex].spksNum; + } + if (idx < spksNum) + { + spksId = PhysicalSectionConfigDataStru[bufIndex].spksIdBuff[idx]; + } + + return spksId; +} + +/* +* ȡָΪⷽһεźŻĿ +* ˵ phySecId +* ֵ źŻ +*/ +UINT8 GetPhySecAsOutFirstPhySecSigSum(UINT16 phySecId) +{ + UINT8 sigNum = 0u; + UINT16 bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + sigNum = PhysicalSectionConfigDataStru[bufIndex].relateOutStationSignalNum; + } + + return sigNum; +} + +/* +* ȡָΪⷽһεźŻID +* ˵ phySecId +* idx źŻ± +* ֵ >0 sigId 0 : +*/ +UINT16 GetPhySecAsOutFstPhySecSigId(UINT16 phySecId,UINT16 idx) +{ + UINT8 sigNum = 0u; + UINT16 sigId = 0u; + UINT16 bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + sigNum = PhysicalSectionConfigDataStru[bufIndex].relateOutStationSignalNum; + if (idx < sigNum) + { + sigId = PhysicalSectionConfigDataStru[bufIndex].relateOutStationSignalIdBuff[idx]; + } + } + + return sigId; +} + +/* +* +* ˵ phySecSum +* phySecIdBuff ͸ID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendPhySecIdDataManage(UINT16 phySecSum,const UINT16 *phySecIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if ((totalPhysicalSectionNum + phySecSum) >= PHYSICAL_SECTION_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = totalPhysicalSectionNum; + totalPhysicalSectionNum += phySecSum; + for(ii = 0u;ii< phySecSum;ii++) + { + LocalCiPhysicalSectionIdBuf[index+ii] = phySecIdBuff[ii];/*׷ӵLocalCiPhysicalSectionIdBuf*/ + } + } + + return retVal; +} + +/* +* ȡ͸Լεǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: εǰ +*/ +UINT16 GetTotalPhySecCurNum(void) +{ + UINT16 retVal = 0u; + if (totalPhysicalSectionNum > PHYSICAL_SECTION_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = totalPhysicalSectionNum; + } + return retVal; +} + +/* +* ȡָIDID +* ˵ const UINT16 trackSectionId, ID +* ֵ ERROR: ȡʧ +* >0: ID +*/ +UINT16 GetTrackToPhySectionId(const UINT32 trackSectionId) +{ + UINT16 i=0u; + UINT16 j=0u; + UINT16 phySec = 0u; + UINT8 foundFlag = 0u; + for (i = 0u;i0: ܸλ̵ID +*/ +UINT16 GetPhySecZFWRelayId(const UINT16 phySectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].ZFWRelayId; /*ȡܸλ̵ID*/ + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDǷZCϽ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* 0x55: ZCϽ +* 0xAA: βZCϽ +*/ +UINT8 GetPhySecManagedByZcFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].managedByZcFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDĿ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPAxisSectionSum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].AxisSectionSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDΰ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: IDָ +*/ +UINT16* GetPAxisSectionIdBuf(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * retVal = NULL; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].AxisSectionIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָIDĿ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetSecIntrudePhySectionSum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ·±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].SecInvSecAndConSwiSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID +* ˵ const UINT16 phySectionId, ID +* ֵ NULL: ȡʧ +* !NULL: νṹָ +*/ +UINT16* GetSecIntrudePhySectionData(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ·±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].SecInvSecAndConSwiId; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָIDμԤλ״̵̬ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ԥλ״̵̬ID +*/ +UINT16 GetPhySecPreResetRelayId(const UINT16 phySectionId) +{ + + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].PreResetRelayId; /*ȡԤλ״̵̬ID*/ + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDڵķ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ûз +* >0: +*/ +UINT16 GetPhySecLocatedFloodSum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].LocatedFloodGateSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDڵķId +* ˵ const UINT16 phySectionId, ID +* ֵ NULL: ûз +* !NULL: Id +*/ +UINT16* GetPhySecLocatedFloodId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].LocatedFloodGateId; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָID θʾ̵ID +* ˵ const UINT16 phyId +* ֵ 0: ȡʧ +* >0: θӹ̵ID +*/ +UINT16 GetPhySecRepGdRelayId(const UINT16 phyId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetPhySecConfigBufIndex(phyId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].RepGdRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDļϵͳId +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ϵͳId +*/ +UINT8 GetPhySecBelongAxisSysId(const UINT16 phySecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = (UINT8)PhysicalSectionConfigDataStru[bufIndex].BelongAxleSysID; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} +/* +* ȡָIDID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPhySecBelongVirCiId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].BelongVirCI; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDǷ· +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ƿ· +*/ +UINT8 GetPhyIsThisLineState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].PhyIsThisLine; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDܸλʾ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ܸλʾ +*/ +UINT16 GetPhySecZFWShowRelayId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].ZFWShowRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָIDΰ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ʧ +* 1:ɹ +*/ +UINT8 SetPhySecIncludeSwitch(const UINT16 phySectionId) +{ + UINT8 reVal = CI_ERROR; + UINT8 axisSecSum = 0u; + UINT16* pAxisSecIdBuf=NULL; + UINT16 devId = 0u; + UINT8 axisSwitchSum=0u; + AxisSwitchStruct* pAxisSwitchStruct = NULL; + UINT16 i = 0u; /* ѭ */ + UINT16 j = 0u; /* ѭ */ + UINT16 k = 0u; /* ѭ */ + UINT16 bufIndex = 0u; /*±*/ + UINT8 includeSwitchSum = 0u; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + + if(CI_SUCCESS==reVal) + { + axisSecSum = GetPAxisSectionSum(phySectionId); + pAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId); + if(NULL != pAxisSecIdBuf) + { + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + + if(CI_SUCCESS==reVal) + { + for(i=0u;(axisSecSum > i)&&(PHYSICAL_INCLUDE_AXIS_SUM_MAX > i);i++) + { + axisSwitchSum = GetAxisSwitchSum(pAxisSecIdBuf[i]);/*ΰ*/ + pAxisSwitchStruct= GetAxisSwitchIdStru(pAxisSecIdBuf[i]);/*ΰ*/ + if(NULL == pAxisSwitchStruct) + { + reVal = CI_ERROR; + } + else + { + /*ʲôҲ*/ + } + if(CI_SUCCESS == reVal) + { + for(j = 0u;(j < axisSwitchSum)&&(AXIS_INCLUDE_SWITCH_SUM_MAX > j);j++) + { + devId = pAxisSwitchStruct[j].SwitchId;/**/ + if(PHYSICAL_INCLUDE_SWITCH_SUM_MAX > includeSwitchSum) + { + for(k = 0u;k < PHYSICAL_INCLUDE_SWITCH_SUM_MAX;k++)/*ҸõIDǷѾ*/ + { + if(devId == PhysicalSectionConfigDataStru[bufIndex].PhyIncludeSwitch[k]) + { + break; + } + } + if(PHYSICAL_INCLUDE_SWITCH_SUM_MAX == k)/**/ + { + PhysicalSectionConfigDataStru[bufIndex].PhyIncludeSwitch[includeSwitchSum++] = devId; + } + + } + else + { + reVal = CI_ERROR; + } + } + + } + } + } + + if(CI_SUCCESS == reVal) + { + PhysicalSectionConfigDataStru[bufIndex].PhyIncludeSwitchSum = includeSwitchSum; + } + + return reVal; +} +/* +* ȡָIDΰ +* ˵ const UINT16 phySectionId, ID +* ֵ صID +*/ +UINT16* GetPhySecIncludeSwitch(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* pPhyIncludeSwitch = NULL; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + pPhyIncludeSwitch = PhysicalSectionConfigDataStru[bufIndex].PhyIncludeSwitch; + } + else + { + pPhyIncludeSwitch = NULL; + } + return pPhyIncludeSwitch; +} +/* +* ȡָIDΰĿ +* ˵ const UINT16 phySectionId, ID +* ֵ 0:ʧ +* >0:ɹ +* +*/ +UINT8 GetPhyIncludeSwitchSum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 phyIncludeSwitchSum = 0u; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + phyIncludeSwitchSum = PhysicalSectionConfigDataStru[bufIndex].PhyIncludeSwitchSum; + } + + return phyIncludeSwitchSum; +} + +/* +* ȡָIDιID +* ˵ const UINT16 phySectionId, ID +* ֵ ιID +*/ +UINT16 GetPhySecReleatedGdId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].wReleatedGd; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָι߼Id +* ˵ const UINT16 phySecId, ID +* ֵ ȡָι߼Id +*/ +UINT16* GetPhySecIncLogSecIdBuf(const UINT16 phySecId) +{ + UINT16* retBuf = NULL; + + UINT16 bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if ( PHYSICAL_SECTION_SUM_MAX>bufIndex) + { + retBuf = PhysicalSectionConfigDataStru[bufIndex].LogSectionIdBuf; + } + else + { + ; /*DO NOTHING*/ + } + + return retBuf; +} +/* +* ȡָι߼ +* ˵ const UINT16 phySecId, ID +* ֵ ȡָι߼ +*/ +UINT8 GetPhySecIncLogSecSum(const UINT16 phySecId) +{ + UINT8 routeSum = 0u; + + UINT16 bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX >bufIndex) + { + routeSum = PhysicalSectionConfigDataStru[bufIndex].LogSectionSum; + } + + return routeSum; +} + +/* +* ȡָIDι̵ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPhySecGdDrvRelayId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].GdDrvRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDγ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ι̼γ +*/ +UINT32 GetPhySecRelayMinAcLen(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = 0U; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionConfigDataStru[bufIndex].wPhySecLen; + } + else + { + retVal = 0U; + } + return retVal; +} + +/* +* ֱ γ +* ˵ const UINT16 wPhySecId +* ֵ +*Create fan 20240822 +*/ +void AddAdjacentPhySec(const UINT16 wPhySecId) +{ + UINT32 dwAcLen = 0U; + UINT8 phyAcNum = 0; /*μ*/ + UINT16 bufIndex = 0U; + UINT8 jj = 0U; + UINT8 k = 0U; + UINT16* pACBuff = NULL; /*μ*/ + UINT16 wAcStratLink = 0U;/*ʼlink*/ + UINT16 wAxisID = 0U; /**/ + UINT16 wAcTerminLink = 0U; /*նlink*/ + UINT16 phySectionConfigDataSum = 0u; /*豸*/ + UINT8 chAcLinkSum = 0; + UINT16* pAclinkBuf = NULL; + UINT16 wStartNearLink = 0U; /*ʼlink*/ + UINT16 wTmmNearLink = 0U;/*նlink*/ + UINT16 wStartNearSec = 0U; + UINT16 wTmmNearSec = 0U; + UINT8 chStartAddFlag = CI_ERROR; + UINT8 chTmmAddFlag = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + if ( PHYSICAL_SECTION_SUM_MAX> bufIndex) + { + phyAcNum = GetPAxisSectionSum(wPhySecId); + pACBuff = GetPAxisSectionIdBuf(wPhySecId); + PhysicalSectionConfigDataStru[bufIndex].wPhySecLen = UINT32_MAX; + PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum = 0U; + PhysicalSectionConfigDataStru[bufIndex].chNearPhySecNum = 0U; + PhysicalSectionConfigDataStru[bufIndex].chArbPossibleTag = CI_SUCCESS; + if ((0U != phyAcNum) && (NULL != pACBuff)) + { + /**/ + for (jj = 0u; jj < phyAcNum; jj++) + { + dwAcLen = GetAxisSecTotalLen(pACBuff[jj]);/*γ*/ + chAcLinkSum = GetAxisLinkSum(pACBuff[jj]); + pAclinkBuf = GetAxisLinkIdBuf(pACBuff[jj]); + wAcStratLink = pAclinkBuf[0]; + wAcTerminLink = pAclinkBuf[chAcLinkSum-(UINT8)1U]; + if (PhysicalSectionConfigDataStru[bufIndex].wPhySecLen > dwAcLen) + { + PhysicalSectionConfigDataStru[bufIndex].wPhySecLen = dwAcLen;/*̼*/ + } + else + { + ; /**/ + } + /*ȡʼ*/ + wStartNearLink = GetLinkOrgnJointMainLkIdById(wAcStratLink); + wStartNearSec = GetLinkRelatedPhySec(wStartNearLink); /*ն˼ᴦΪ0*/ + chStartAddFlag = CI_ERROR; + + /*ȡն*/ + wTmmNearLink = GetLinkTmnlJointMainLkById(wAcTerminLink); + wTmmNearSec = GetLinkRelatedPhySec(wTmmNearLink); + chTmmAddFlag = CI_ERROR; + + for (k = 0; k < PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum; k++) + { + if (PhysicalSectionConfigDataStru[bufIndex].AdjacentPhySecBuf[k] == wStartNearSec) + { + chStartAddFlag = CI_SUCCESS; + } + if (PhysicalSectionConfigDataStru[bufIndex].AdjacentPhySecBuf[k] == wTmmNearSec) + { + chTmmAddFlag = CI_SUCCESS; + } + } + /*ֱ*/ + if((CI_ERROR == chStartAddFlag) && (0U != wStartNearSec) + && (PHYSEC_ADJACENT_SEC_SUM_MAX> PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum)) + { + PhysicalSectionConfigDataStru[bufIndex].AdjacentPhySecBuf[PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum] = wStartNearSec; + PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum++; + } + else + { + ; /*ǰ*/ + } + if ((CI_ERROR == chTmmAddFlag) && (0U != wTmmNearSec) + && (PHYSEC_ADJACENT_SEC_SUM_MAX>PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum)) + { + PhysicalSectionConfigDataStru[bufIndex].AdjacentPhySecBuf[PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum] = wTmmNearSec; + PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum++; + } + else + { + ; /**/ + } + } + } + else + { + PhysicalSectionConfigDataStru[bufIndex].wPhySecLen = 0U;; + } + } + +} + +/* +* ηΧ +* ˵ const UINT16 wPhySecId +* ֵ +*Create fan 20240822 +*/ +void AddNearPhySec(const UINT16 wPhySecId) +{ + UINT32 dwPhySecLen = 0U; /**/ + UINT32 dwCheckNearLen = 0U; /*õĽӽȷΧ*/ + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 kk = 0U; + UINT16 wAdjacentPhySec = 0U; /*ֱ*/ + UINT16* wAdjacentPhyBuf = NULL; /*ֱ*/ + UINT8 chAdjacentPhyNum = 0U; /*ֱ*/ + UINT8 chNearSecNum = 0U; /**/ + UINT16* dwNearSecBuf = NULL; /**/ + UINT8 chTwoStepNearSecNum = 0U; /**/ + UINT16* dwTwoStepNearSecBuf = NULL; /**/ + UINT8 chAddCheck = CI_ERROR; + UINT32 dwIndirectLen = 0U; /*ҵ*/ + UINT8 chBelongCi = 0U; /*ci*/ + UINT8 chCiType = 0U; + UINT16 wArbProtectDis = GetSystemParaValue(ARB_CHECK_ALXE_SEC_LEN); + dwCheckNearLen = (UINT32)(wArbProtectDis * 100U); + if (0U == dwCheckNearLen) + { + debug_infor_printf((const)"AddNearPhySec Fail: ArbCheckDistance =%d .\n", dwCheckNearLen); + } + chAdjacentPhyNum = GetAdjacentPhySecNum(wPhySecId); + wAdjacentPhyBuf = GetAdjacentPhySecBuf(wPhySecId);/*ֱ*/ + for (ii = 0; ii < chAdjacentPhyNum; ii++) + { + wAdjacentPhySec = wAdjacentPhyBuf[ii]; + dwPhySecLen = GetPhySecRelayMinAcLen(wAdjacentPhySec); + chBelongCi = GetPhySecBelongCiId(wAdjacentPhySec); + chCiType = GetCiType(chBelongCi); + if (CI_TYPE_CLD == chCiType) + { + ; /*ֱڳ */ + } + else if (dwPhySecLen < dwCheckNearLen) + { + /*ֱڵijȲ*/ + chNearSecNum = GetAdjacentPhySecNum(wAdjacentPhySec); + dwNearSecBuf = GetAdjacentPhySecBuf(wAdjacentPhySec); + for (jj = 0; jj < chNearSecNum; jj++) + { + /*Ӽڽ*/ + dwIndirectLen = GetPhySecRelayMinAcLen(dwNearSecBuf[jj]); + chBelongCi = GetPhySecBelongCiId(dwNearSecBuf[jj]); + chCiType = GetCiType(chBelongCi); + if (0u == dwIndirectLen) + { + /*Ѿ*/ + SetPhyPossibleArbTag(wPhySecId, CI_ERROR); + debug_infor_printf((const)"AddNearPhy Sec%d Fail: Search %d Out Range.\n", wPhySecId, dwNearSecBuf[jj]); + break; /*ȲԽRC䷶Χ ޷Arb*/ + } + else + { + /*ڱRCͷΧ*/ + chAddCheck = CheckNearPhySec(dwNearSecBuf[jj], wPhySecId); + chBelongCi = GetPhySecBelongCiId(dwNearSecBuf[jj]); + chCiType = GetCiType(chBelongCi); + if (CI_SUCCESS == chAddCheck) + { + /*ӳɹ*/ + + /*жǷһ*/ + if (CI_TYPE_CLD == chCiType) + { + ; /*һڳ ټ*/ + } + else if (dwPhySecLen + dwIndirectLen < dwCheckNearLen) /*ֱ + һڵСڲҳ ڲٲ*/ + { + chTwoStepNearSecNum = GetAdjacentPhySecNum(dwNearSecBuf[jj]); + dwTwoStepNearSecBuf = GetAdjacentPhySecBuf(dwNearSecBuf[jj]); + for (kk = 0; kk < chTwoStepNearSecNum; kk++) + { + /*Ӽڽ*/ + dwIndirectLen = GetPhySecRelayMinAcLen(dwTwoStepNearSecBuf[kk]); + if (0U == dwIndirectLen) + { + /*벻Խ*/ + SetPhyPossibleArbTag(wPhySecId, CI_ERROR); + debug_infor_printf((const)"AddNearPhy Sec%d Fail: Search %d Out Range.\n", wPhySecId, dwTwoStepNearSecBuf[kk]); + break; /*ȲԽRC䷶Χ ޷Arb*/ + } + else + { + chAddCheck = CheckNearPhySec(dwTwoStepNearSecBuf[kk], wPhySecId); + /*ݲٲ*/ + } + } + } + else + { + ; /*㹻*/ + } + } + } + } + } + else + { + ; /*ѾжϷΧ */ + } + } +} +/* +* ȡηΧֱ +* ˵ const UINT16 wPhySecId +* ֵ ֱ +* Create fan 20240822 +*/ +UINT8 GetAdjacentPhySecNum(const UINT16 wPhySecId) +{ + UINT16 bufIndex = 0U; + UINT8 retValue = 0U; + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retValue = PhysicalSectionConfigDataStru[bufIndex].chAdjacentPhySecNum; + } + return retValue; +} + +/* +* ȡηΧֱ +* ˵ const UINT16 wPhySecId, ID +* ֵ NULL: +* !NULL: ֱid +* Create fan 20240822 +*/ +UINT16* GetAdjacentPhySecBuf(const UINT16 wPhySecId) +{ + UINT16 bufIndex = 0U; + UINT16* retValue = NULL; + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retValue = PhysicalSectionConfigDataStru[bufIndex].AdjacentPhySecBuf; + } + return retValue; +} +/* +* ڽΧ޸ +* ˵ const UINT16 wPhySecId ΣUINT16 basePhysec +* ֵ CI_SUCCESS CI_ERROR +*Create fan 20240822 +*/ +UINT8 CheckNearPhySec(const UINT16 wPhySecId, const UINT16 basePhysec) +{ + UINT8 retValue = CI_SUCCESS; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT16* wAdjacentPhyBuf = NULL; /*ֱ*/ + UINT16 chAdjacentPhyNum = 0U; /*ֱ*/ + UINT8 chNearSecNum = 0U; /**/ + UINT16* dwNearSecBuf = NULL; /**/ + UINT16 bufIndex = 0U; + UINT8 chCiType = 0U; + UINT8 chBelongCi = 0U; + + bufIndex = GetPhySecConfigBufIndex(basePhysec); /*ȡ±*/ + chAdjacentPhyNum = GetAdjacentPhySecNum(basePhysec); + wAdjacentPhyBuf = GetAdjacentPhySecBuf(basePhysec); + chNearSecNum = PhysicalSectionConfigDataStru[bufIndex].chNearPhySecNum; + + /*ǻ׼*/ + if (wPhySecId == basePhysec) + { + retValue = CI_ERROR; + } + + /*һ ֱ*/ + if (CI_ERROR != retValue) + { + for (ii = 0; ii < chAdjacentPhyNum; ii++) + { + if (wPhySecId == wAdjacentPhyBuf[ii]) + { + retValue = CI_ERROR; + break; + } + } + } + + /*ڶ м*/ + if (CI_SUCCESS == retValue) + { + for (jj = 0; jj < chNearSecNum; jj++) + { + if (wPhySecId == PhysicalSectionConfigDataStru[bufIndex].IndirectNearPhySecBuf[jj]) + { + retValue = CI_ERROR; + break; + } + } + } + /**/ + if ((CI_SUCCESS == retValue) &&(PHYSEC_INDIRECTNEAR_SEC_SUM_MAX>chNearSecNum)) + { + PhysicalSectionConfigDataStru[bufIndex].IndirectNearPhySecBuf[chNearSecNum] = wPhySecId; + PhysicalSectionConfigDataStru[bufIndex].chNearPhySecNum++; + } + else + { + retValue = CI_ERROR; + } + return retValue; +} + +/* +* ȡηΧڼ +* ˵ const UINT16 wPhySecId +* ֵ +* Create fan 20240822 +*/ +UINT8 GetNearPhySecNum(const UINT16 wPhySecId) +{ + UINT16 bufIndex = 0U; + UINT8 retValue = 0U; + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retValue = PhysicalSectionConfigDataStru[bufIndex].chNearPhySecNum; + } + return retValue; +} + +/* +* ȡηΧڼ +* ˵ const UINT16 wPhySecId, ID +* ֵ NULL: +* !NULL:id +* Create fan 20240822 +*/ +UINT16* GetIndirectNearPhySecBuf(const UINT16 wPhySecId) +{ + UINT16 bufIndex = 0U; + UINT16* retValue = NULL; + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retValue = PhysicalSectionConfigDataStru[bufIndex].IndirectNearPhySecBuf; + } + return retValue; +} + +/* +* +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +* fan 2024/08/23 +*/ +UINT8 PhySectionNearConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 wPhySecId = 0U; + UINT8 retVal = CI_SUCCESS; + UINT16* wAdjacentPhyBuf = NULL; /*ֱ*/ + UINT8 chAdjacentPhyNum = 0U; /*ֱ*/ + UINT8 chNearSecNum = 0U; /**/ + UINT16* dwNearSecBuf = NULL; /**/ + UINT8 chLocalCiType = GetLocalCiType(); + UINT8 chLocal = GetSystemParaLocalCiId(); + UINT8 chBelongCi = 0U; + + /*ID*/ + + if (totalPhysicalSectionNum >= PHYSICAL_SECTION_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + /*һ ֱӸӷΧ γ*/ + for (ii = 0u; ii < totalPhysicalSectionNum; ii++) + { + wPhySecId = LocalCiPhysicalSectionIdBuf[ii]; + AddAdjacentPhySec(wPhySecId); + } + + /* ڶ ʼ÷Χڼ*/ + for (ii = 0u; ii < totalPhysicalSectionNum; ii++) + { + wPhySecId = LocalCiPhysicalSectionIdBuf[ii]; + chBelongCi = GetPhySecBelongCiId(wPhySecId); + if (chBelongCi == chLocal) + { + AddNearPhySec(wPhySecId); + } + else + { + ; /**/ + } + } + +#if 1 + /*ӡ*/ + for (ii = 0u; ii < totalPhysicalSectionNum; ii++) + { + wPhySecId = LocalCiPhysicalSectionIdBuf[ii]; + chAdjacentPhyNum = GetAdjacentPhySecNum(wPhySecId); + wAdjacentPhyBuf = GetAdjacentPhySecBuf(wPhySecId); + + debug_infor_printf((const)"\nInitNear Sec:%d: belongCI :%d Add_Adjacent-", wPhySecId, GetPhySecBelongCiId(wPhySecId)); + for (jj = 0U; jj < chAdjacentPhyNum; jj++) + { + debug_infor_printf((const)"%d-", wAdjacentPhyBuf[jj]); + } + debug_infor_printf((const)"Total_Adjacent : %d", chAdjacentPhyNum); + if (chLocal == GetPhySecBelongCiId(wPhySecId)) + { + debug_infor_printf((const)"\nPossibleTag : %d ", GetPhyPossibleArbTag(wPhySecId)); + chNearSecNum = GetNearPhySecNum(wPhySecId); /**/ + dwNearSecBuf = GetIndirectNearPhySecBuf(wPhySecId); /**/ + debug_infor_printf((const)"Add_Near--"); + for (jj = 0U; jj < chNearSecNum; jj++) + { + debug_infor_printf((const)"%d: --", dwNearSecBuf[jj]); + } + debug_infor_printf((const)"Total_Near %d .", chNearSecNum); + } + } + +#endif + } + return retVal; +} + +/* +* ȡοɷжΪArb +* ˵ const UINT16 wPhySecId, ID +* ֵ CI_SUCCESS CI_ERRORݲ +* Create fan 20240822 +*/ +UINT8 GetPhyPossibleArbTag(const UINT16 wPhySecId) +{ + UINT16 bufIndex = 0U; + UINT8 retValue = CI_ERROR; + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retValue = PhysicalSectionConfigDataStru[bufIndex].chArbPossibleTag; + } + return retValue; +} + +/* +* οɷжΪArb +* ˵ const UINT16 wPhySecId, IDUINT8 chArbTag +* ֵ void +* Create fan 20240822 +*/ +void SetPhyPossibleArbTag(const UINT16 wPhySecId, UINT8 chArbTag) +{ + UINT16 bufIndex = 0U; + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + if ((PHYSICAL_SECTION_SUM_MAX > bufIndex)&& + ((CI_SUCCESS == chArbTag)||(CI_ERROR == chArbTag))) + { + PhysicalSectionConfigDataStru[bufIndex].chArbPossibleTag = chArbTag; + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/PhysicalSectionConfigDataManage.h b/TSCP/src/APP/ciapp/Section/PhysicalSectionConfigDataManage.h new file mode 100644 index 0000000..c60f321 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/PhysicalSectionConfigDataManage.h @@ -0,0 +1,507 @@ +/******************************************************** +* +* PhysicalSectionConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PHYSICAL_SECTION_CONFIG_DATA_MANAGE_H_ +#define _PHYSICAL_SECTION_CONFIG_DATA_MANAGE_H_ + + +#include "SectionDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../FloodGate/FloodGateDefine.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct S_PhysicalSectionConfigData +{ + UINT16 PhysicalSectionId; /*ID (ֶ)*/ + UINT8 BelongCiId; /*ID (ֶ)*/ + UINT8 BelongVirCI; /*CI*/ + UINT16 BelongOcId; /*OC ID (ֶ)*/ + UINT8 managedByZcFlag; /*ǷZCϽ(ֶ)*/ + UINT8 PhySecType; /*(޲/в) (ֶ)*/ + UINT8 LjkSecFlag; /*мα־(м/м) (ֶ)*/ + UINT16 GdRelayId; /*̵ID (ֶ)*/ + UINT16 wGdRelayId2; /*̵ID2 (ֶ) ˹*/ + UINT16 RepGdRelayId; /*ӹ̵ID*/ + UINT16 FWRelayId; /*λ̵ID (ֶ)*/ + UINT8 spksNum; /* ζӦspks */ + UINT16 spksIdBuff[PHYSICAL_SECTION_SPKS_MAX_NUM]; /* ζӦspksIdб */ + UINT8 relateOutStationSignalNum; /* ζӦijվźŻ */ + UINT16 relateOutStationSignalIdBuff[PHY_SEC_REL_OUTSTATION_SIGNAL_MAX_NUM]; /* ζӦվźŻIdб */ + UINT32 trackSecBuf[PHY_SEC_TRACK_SEC_MAX_SUM];/*ΰĹID*/ + UINT8 trackSecNum;/*ΰĹ*/ + UINT16 proLockRouteIdBuf[PHY_SEC_PRO_LOCK_ROUTE_MAX_NUM];/*αնӦĽ·ID*/ + UINT8 proLockRouteSum;/*αնӦĽ·ID*/ + UINT16 ZFWRelayId; /*ܸλ̵ID (ֶ)*/ + UINT16 PreResetRelayId; /*Ԥλ״̵̬ID (ֶ)*/ + UINT16 RepRelayTrainId; /*ʾ̵ID (ֶ)*/ + UINT8 AxisSectionSum; /*Ŀ (ֶ)*/ + UINT16 AxisSectionIdBuf[PHYSICAL_INCLUDE_AXIS_SUM_MAX]; /*ΰID (ʼֶ)*/ + UINT8 SecInvSecAndConSwiSum; /*ΰμ*/ + UINT16 SecInvSecAndConSwiId[SEC_INVASECT_N_CONDSWIT_SUM_MAX]; /*μ*/ + UINT16 LocatedFloodGateSum; /*ι*/ + UINT16 LocatedFloodGateId[FLOOD_GATE_SUM_MAX]; /*ڷId*/ + UINT16 BelongAxleSysID; /*ϵͳID*/ + UINT8 PhyIsThisLine; /*Ƿ·*/ + UINT16 ZFWShowRelayId; /*ܸλʾ*/ + UINT16 PhyIncludeSwitch[PHYSICAL_INCLUDE_SWITCH_SUM_MAX];/*ΰID*/ + UINT8 PhyIncludeSwitchSum;/*ΰĿ*/ + UINT16 wReleatedGd; /* ID */ + UINT8 LogSectionSum; /*߼Ŀ (ֶ)*/ + UINT16 LogSectionIdBuf[PHYSICAL_INCLUDE_LOG_SUM_MAX]; /*ΰ߼ID (ʼֶ)*/ + UINT16 GdDrvRelayId; /*̵ID (ֶ-ʹ)*/ + UINT8 chAdjacentPhySecNum; /*ֱ*/ + UINT8 chNearPhySecNum; /*ελֱ*/ + UINT32 wPhySecLen; /*γȣ᳤̼*/ + UINT16 AdjacentPhySecBuf[PHYSEC_ADJACENT_SEC_SUM_MAX]; /*ֱ*/ + UINT16 IndirectNearPhySecBuf[PHYSEC_INDIRECTNEAR_SEC_SUM_MAX]; /*λڼڽ*/ + UINT8 chArbPossibleTag; /*ǷArb*/ +} PhysicalSectionConfigDataStruct; + + + +typedef struct S_OC_PhysicalSectionConfigDataStruct +{ + UINT16 PhysicalSectionId; /*ID(ֶ)*/ + UINT16 BelongOcId; /*OCID(ֶ)*/ + UINT8 PhysicalSectionModuleIdAddrA; /*AϵģID(ֶ)*/ + UINT8 PhysicalSectionPosAddrA; /*Aϵλ(ֶ)*/ + UINT8 PhysicalSectionModuleIdAddrB; /*BϵģID(ֶ)*/ + UINT8 PhysicalSectionPosAddrB; /*Bϵλ(ֶ)*/ +}OCPhysicalSectionConfigDataStruct; + + +/*******************************ȫֱ*******************************/ +extern PhysicalSectionConfigDataStruct PhysicalSectionConfigDataStru[PHYSICAL_SECTION_SUM_MAX]; /*ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiPhysicalSectionIdBuf[PHYSICAL_SECTION_SUM_MAX]; /*屾IDӳ*/ +extern INT16 PhysicalSectionCurSum; +extern UINT16 totalPhysicalSectionNum; + +/* +* ȡָID +* ˵ const UINT16 phySectionId, ID +* ֵ PHYSICAL_SECTION_SUM_MAX: ȡʧ +* 0: εǰ +*/ +UINT16 GetPhySecCurSum(void); +/* +* ȡָIDĿ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPAxisSectionSum(const UINT16 phySectionId); + +/* +* ȡָIDΰ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ߼IDָ +*/ +UINT16* GetPAxisSectionIdBuf(const UINT16 phySectionId); +/* +* ȡָID +* ˵ +* ֵ + PhysicalSectionConfigDataStruct* +*/ +PhysicalSectionConfigDataStruct* GetPhySecConfigData(void); + +/* +* ȡָ±ӦID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetPhySecId(const UINT16 bufIndex); + +/* +* ȡָIDID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPhySecBelongCiId(const UINT16 phySectionId); + +/* +* ȡָID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetPhySecType(const UINT16 phySectionId); + +/* +* ȡָIDмα־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: мα־ +*/ +UINT8 GetPhySecLjkFlag(const UINT16 phySectionId); + +/* +* ȡָIDι̵ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPhySecGdRelayId(const UINT16 phySectionId); + +/* +* ȡָIDθλ̵ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: λ̵ID +*/ +UINT16 GetPhySecFWRelayId(const UINT16 phySectionId); + +/* +* +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 PhySectionConfigDataManage(void); + +/* +* ȡָSPKSĿ +* ˵ phySecId +* ֵ spks +*/ +UINT8 GetPhySecSpksSum(UINT16 phySecId); + +/* +* ȡָ ָ±SPKSID +* ˵ phySecId +* spksIdIdx Spks± +* ֵ >0 spksId 0 +*/ +UINT16 GetPhySecSpksIdBySpksIdx(UINT16 phySecId,UINT16 idx); + +/* +* +* ˵ phySecSum +* phySecIdBuff ͸ID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendPhySecIdDataManage(UINT16 phySecSum,const UINT16 *phySecIdBuff); + +/* +* ȡ͸Լεǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: εǰ +*/ +UINT16 GetTotalPhySecCurNum(void); + +/* +* ȡָΪⷽһεźŻĿ +* ˵ phySecId +* ֵ źŻ +*/ +UINT8 GetPhySecAsOutFirstPhySecSigSum(UINT16 phySecId); + +/* +* ȡָΪⷽһεźŻID +* ˵ phySecId +* sigIdIdx źŻ± +* ֵ >0 sigId 0 : +*/ +UINT16 GetPhySecAsOutFstPhySecSigId(UINT16 phySecId,UINT16 idx); + +/* +* ȡָIDID +* ˵ const UINT16 trackSectionId, ID +* ֵ ERROR: ȡʧ +* >0: ID +*/ +UINT16 GetTrackToPhySectionId(const UINT32 trackSectionId); + +/* +* ȡָαʱܶӦĽ·ID +* ˵ const UINT16 phySecId, ID +* ֵ + ָαʱܶӦĽ·ID +*/ +UINT16* GetPhySecProLockRouteIdBuf(const UINT16 phySecId); +/* +* ȡָαʱܶӦĽ·ID +* ˵ const UINT16 phySecId, ID +* ֵ +ָαʱܶӦĽ·ID +*/ +UINT8 GetPhySecProLockRouteSum(const UINT16 phySecId); + +/* +* ûͨͨŽӿϵ״̬ +* ˵ UINT16 phySectionIdID +* const UINT8 lockState ϵ״̬ +* ֵ +* CI_ERRORʧ +*/ +void SetPhySecStartLockStateHlht(UINT16 phySectionId, const UINT8 lockState); + +/* +* ȡָIDܸλ̵ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ܸλ̵ID +*/ +UINT16 GetPhySecZFWRelayId(const UINT16 phySectionId); + +/* +* ȡָIDǷZCϽ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* 0x55: ZCϽ +* 0xAA: βZCϽ +*/ +UINT8 GetPhySecManagedByZcFlag(const UINT16 phySectionId); +/* +* ȡָIDĿ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ŀ +*/ +UINT8 GetSecIntrudePhySectionSum(const UINT16 phySectionId); + +/* +* ȡָID +* ˵ const UINT16 phySectionId, ID +* ֵ NULL: ȡʧ +* !NULL: νṹָ +*/ +UINT16* GetSecIntrudePhySectionData(const UINT16 phySectionId); + +/* +* ȡָIDμԤλ״̵̬ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ԥλ״̵̬ID +*/ +UINT16 GetPhySecPreResetRelayId(const UINT16 phySectionId); + + +/* +* ȡָIDڵķ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ûз +* >0: +*/ +UINT16 GetPhySecLocatedFloodSum(const UINT16 phySectionId); + +/* +* ȡָIDڵķId +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ûз +* >0: Id +*/ +UINT16* GetPhySecLocatedFloodId(const UINT16 phySectionId); + +/* +* ȡָID θʾ̵ID +* ˵ const UINT16 phyId +* ֵ 0: ȡʧ +* >0: θӹ̵ID +*/ +UINT16 GetPhySecRepGdRelayId(const UINT16 phyId); + +/* +* ȡָIDļϵͳId +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ϵͳId +*/ +UINT8 GetPhySecBelongAxisSysId(const UINT16 phySecId); + +/* +* ȡָIDID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetPhySecBelongVirCiId(const UINT16 phySectionId); + +/* +* ȡָIDܸλʾ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ܸλʾ +*/ +UINT16 GetPhySecZFWShowRelayId(const UINT16 phySectionId); +/* +* ȡָIDΰ +* ˵ const UINT16 phySectionId, ID +* ֵ صID +*/ +UINT16* GetPhySecIncludeSwitch(const UINT16 phySectionId); +/* +* ȡָIDΰĿ +* ˵ const UINT16 phySectionId, ID +* ֵ 0:ʧ +* >0:ɹ +* +*/ +UINT8 GetPhyIncludeSwitchSum(const UINT16 phySectionId); +/* +* ָIDΰ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ʧ +* 1:ɹ +*/ +UINT8 SetPhySecIncludeSwitch(const UINT16 phySectionId); +/* +* ȡָIDι̵ID2 +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPhySecGdRelayId2(const UINT16 phySectionId); + +/* +* ȡָIDιID +* ˵ const UINT16 phySectionId, ID +* ֵ ιID +*/ +UINT16 GetPhySecReleatedGdId(const UINT16 phySectionId); + +/* +* ȡָι߼Id +* ˵ const UINT16 phySecId, ID +* ֵ ȡָι߼Id +*/ +UINT16* GetPhySecIncLogSecIdBuf(const UINT16 phySecId); + +/* +* ȡָι߼ +* ˵ const UINT16 phySecId, ID +* ֵ ȡָι߼ +*/ +UINT8 GetPhySecIncLogSecSum(const UINT16 phySecId); + +/* +* ȡָIDι̵ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetPhySecGdDrvRelayId(const UINT16 phySectionId); +/* +* ȡָIDγ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ι̼γ +*/ +UINT32 GetPhySecRelayMinAcLen(const UINT16 phySectionId); +/* +* ȡָIDǷ· +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ƿ· +*/ +UINT8 GetPhyIsThisLineState(const UINT16 phySectionId); +/* +* ֱγ +* ˵ const UINT16 wPhySecId +* ֵ +*Create fan 20240822 +*/ +void AddAdjacentPhySec(const UINT16 wPhySecId); +/* +* ηΧ +* ˵ const UINT16 wPhySecId +* ֵ +*Create fan 20240822 +*/ +void AddNearPhySec(const UINT16 wPhySecId); +/* +* ȡηΧֱ +* ˵ const UINT16 wPhySecId +* ֵ ֱ +* Create fan 20240822 +*/ +UINT8 GetAdjacentPhySecNum(const UINT16 wPhySecId); +/* +* ȡηΧֱ +* ˵ const UINT16 wPhySecId, ID +* ֵ NULL: +* !NULL: ֱid +* Create fan 20240822 +*/ +UINT16* GetAdjacentPhySecBuf(const UINT16 wPhySecId); +/* +* ڽΧ޸ +* ˵ const UINT16 wPhySecIdUINT16 basePhysec +* ֵ CI_SUCCESS CI_ERROR +*Create fan 20240822 +*/ +UINT8 CheckNearPhySec(const UINT16 wPhySecId, const UINT16 basePhysec); + +/* +* ȡηΧڼ +* ˵ const UINT16 wPhySecId +* ֵ +* Create fan 20240822 +*/ +UINT8 GetNearPhySecNum(const UINT16 wPhySecId); + +/* +* ȡηΧڼ +* ˵ const UINT16 wPhySecId, ID +* ֵ NULL: +* !NULL:id +* Create fan 20240822 +*/ +UINT16* GetIndirectNearPhySecBuf(const UINT16 wPhySecId); +/* +* +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +* fan 2024/08/23 +*/ +UINT8 PhySectionNearConfigDataManage(void); +/* +* ȡοɷжΪArb +* ˵ const UINT16 wPhySecId, ID +* ֵ CI_SUCCESS CI_ERRORݲ +* Create fan 20240822 +*/ +UINT8 GetPhyPossibleArbTag(const UINT16 wPhySecId); +/* +* οɷжΪArb +* ˵ const UINT16 wPhySecId, IDUINT8 chArbTag +* ֵ void +* Create fan 20240822 +*/ +void SetPhyPossibleArbTag(const UINT16 wPhySecId, UINT8 chArbTag); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Section/PhysicalSectionDataManage.c b/TSCP/src/APP/ciapp/Section/PhysicalSectionDataManage.c new file mode 100644 index 0000000..5e17407 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/PhysicalSectionDataManage.c @@ -0,0 +1,4010 @@ +/******************************************************** +* +* PhysicalSectionDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + + +#include "PhysicalSectionDataManage.h" +#include "AxisAssertManageAPI.h" + + + +PhysicalSectionDataStruct PhysicalSectionDataStru[PHYSICAL_SECTION_SUM_MAX]; /*ݽṹ*/ + + +/* +* ȡָID +* ˵ +* ֵ + PhysicalSectionDataStruct* +*/ +PhysicalSectionDataStruct* GetPhySecData(void) +{ + return PhysicalSectionDataStru; +} + +/* +* ȡָID״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPhySecUseState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SecUseState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* η״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ: 1:ɹ + 0:ʧ +*/ +UINT16 ClearPhySecPLock(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_SUCCESS; + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + + if (bufIndex >= PHYSICAL_SECTION_SUM_MAX) + { + retVal = CI_ERROR; + } + + else + { + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0; + } + + + return retVal; +} +/* +* ָID״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 useState, ״̬ +* const UINT16 routeId, ·ID +* ֵ void +*/ +void SetPhySecUseState(const UINT16 phySectionId, const UINT8 useState, const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + + if (bufIndex >= PHYSICAL_SECTION_SUM_MAX) + { + retVal = CI_ERROR; + } + + if(CI_SUCCESS == retVal) + { + if ((useState != PHYSICAL_SECTION_USING_NO) && + (useState != PHYSICAL_SECTION_USING_YES) && + (useState != PHYSICAL_SECTION_USING_APPLY) && + (useState != PHYSICAL_SECTION_USING_CANCEL)) + { /*״̬Ч*/ + + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + if (PHYSICAL_SECTION_USING_NO == useState) + { /*δ*/ + if (0u == routeId) + { + /*·*/ + PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u; /*ս·ID*/ + PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*ս·ID*/ + + } + else if(routeId == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) + { + /*·*/ + PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u; /*ս·ID*/ + } + else if(routeId == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId) + { + PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*ս·ID*/ + } + else + { + retVal = CI_ERROR; + } + + if((CI_SUCCESS == retVal)&&(0u == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)&&(0u == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) && (0u == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId)) + { + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_NO; /*δ״̬*/ + } + } + else if (PHYSICAL_SECTION_USING_YES == useState) + { /**/ + if ((0u == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) || + (routeId == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId)) + { + PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = routeId; /*ս·ID*/ + + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_YES; /*״̬*/ + } + else + { + retVal = CI_ERROR; + } + } + else if (PHYSICAL_SECTION_USING_APPLY == useState) + { /*ȴ*/ + if (0u == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) + { + PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = routeId; /*ս·ID*/ + + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_APPLY; /*״̬*/ + } + else + { + retVal = CI_ERROR; + } + } + else + { /*ȴȡ*/ + if (routeId == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) + { + PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = routeId; /*ս·ID*/ + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_CANCEL; /*״̬*/ + } + else + { + retVal = CI_ERROR; + } + } + } + if (CI_ERROR == retVal) + { + debug_infor_printf((const)"SetPhySecUseState ERROR, pyhSecId:%d , Stata:%d , RouteId: %d\n", phySectionId, useState, routeId); + } +} + + +/* +* @brief ָIDε߼״̬ +* @param const UINT16 phySectionId, ID +* const UINT8 useState, ״̬ +* const UINT16 routeId, ߼·ID +* @return +* @noteby cgh 20231010 +*/ +UINT8 SetPhySecUseStateByLogRoute(const UINT16 phySectionId, const UINT8 useState, const UINT16 logrouteId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = CI_SUCCESS; + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + + if (bufIndex >= PHYSICAL_SECTION_SUM_MAX) + { + retVal = CI_ERROR; + } + + if (CI_SUCCESS == retVal) + { + if ((useState != PHYSICAL_SECTION_USING_NO) && + (useState != PHYSICAL_SECTION_USING_YES)) + { /*״̬Ч*/ + + retVal = CI_ERROR; + } + } + + + if (CI_SUCCESS == retVal) + { + if (PHYSICAL_SECTION_USING_NO == useState) + { /*δ*/ + if (0U == logrouteId) + { + /*·*/ + PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId = 0u; /*߼·ID*/ + PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*ս·ID*/ + PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u; /*ս·ID*/ + } + else if (logrouteId == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId) + { + /*·*/ + PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId = 0u; /*߼·ID*/ + } + else + { + retVal = CI_ERROR; + } + + if ((CI_SUCCESS == retVal) + && (0U == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId) + && (0U == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) + && (0U == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId)) + { + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_NO; /*δ״̬*/ + } + } + else if (PHYSICAL_SECTION_USING_YES == useState) + { /**/ + if ((0U == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId) || + (logrouteId == PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId)) + { + PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId = logrouteId; /*ս·ID*/ + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_YES; /*״̬*/ + } + else + { + retVal = CI_ERROR; + } + } + else + { + ; /**/ + } + + } + + return retVal; +} +/* +* ָIDη״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 useState, ״̬ +* const UINT16 routeId, ·ID +* ֵ void +*/ +void SetPhySecProtectUseState(const UINT16 phySectionId, const UINT8 useState, const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + + if (bufIndex >= PHYSICAL_SECTION_SUM_MAX) + { + retVal = CI_ERROR; + } + + if(CI_SUCCESS == retVal) + { + if ((useState != PHYSICAL_SECTION_USING_NO) && + (useState != PHYSICAL_SECTION_USING_YES) && + (useState != PHYSICAL_SECTION_USING_APPLY) && + (useState != PHYSICAL_SECTION_USING_CANCEL)) + { /*״̬Ч*/ + + retVal = CI_ERROR; + } + } + + if(CI_SUCCESS == retVal) + { + if (PHYSICAL_SECTION_USING_NO == useState) + { /*δ*/ + if (0u == routeId) + { + /*·*/ + PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u; /*ս·ID*/ + PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*ս·ID*/ + + } + else if(routeId == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId) + { + /*·*/ + PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId = 0u; /*ս·ID*/ + } + else if(routeId == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId) + { + PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = 0u; /*ս·ID*/ + } + else + { + retVal = CI_ERROR; + } + + if((CI_SUCCESS == retVal)&&(0u == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)&&(0u == PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId)) + { + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_NO; /*δ״̬*/ + } + } + else if (PHYSICAL_SECTION_USING_YES == useState) + { /**/ + if ((0u == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId) || + (routeId == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId)) + { + PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = routeId; /*ս·ID*/ + + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_YES; /*״̬*/ + } + else + { + retVal = CI_ERROR; + } + } + else if (PHYSICAL_SECTION_USING_APPLY == useState) + { /*ȴ*/ + if (0u == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId) + { + PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = routeId; /*ս·ID*/ + + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_APPLY; /*״̬*/ + } + else + { + retVal = CI_ERROR; + } + } + else + { /*ȴȡ*/ + if (routeId == PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId) + { + PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId = routeId; /*ս·ID*/ + PhysicalSectionDataStru[bufIndex].SecUseState = PHYSICAL_SECTION_USING_CANCEL; /*״̬*/ + } + else + { + retVal = CI_ERROR; + } + } + } + if (CI_ERROR == retVal) + { + debug_infor_printf((const)"SetPhySecProtectUseState ERROR, pyhSecId:%d , Stata:%d , RouteId: %d\n", phySectionId, useState, routeId); + } +} + +/* +* ȡָID·ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetPhySecUseRouteId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SecUseBelongRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼·ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetPhySecUseLogRouteId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SecUseBelongLogRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPhySecLockState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].LockState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 lockState, ״̬ +* const UINT16 routeId, ·ID +* const UINT8 lockDirection, շ +* ֵ +* +*/ +void SetPhySecLockState(const UINT16 phySectionId, const UINT8 lockState, const UINT16 routeId, const UINT8 lockDirection) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + + if (bufIndex >= PHYSICAL_SECTION_SUM_MAX) + { + /*ֵ*/ + } + else + { + if (PHYSICAL_SECTION_LOCK_START == lockState) + { /*ϵ*/ + + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###ϵ*/ + } + else if (PHYSICAL_SECTION_LOCK_NO == lockState) + { /*δ*/ + + if ((PHYSICAL_SECTION_LOCK_NORMAL == PhysicalSectionDataStru[bufIndex].LockState) + || (PHYSICAL_SECTION_LOCK_EXCEPT == PhysicalSectionDataStru[bufIndex].LockState) + || (PHYSICAL_SECTION_LOCK_DELAY == PhysicalSectionDataStru[bufIndex].LockState)) + { /*->*/ + if (PhysicalSectionDataStru[bufIndex].RLockBelongRouteId == routeId) + { + /*ڱ·ÿ*/ + if (PhysicalSectionDataStru[bufIndex].PLockBelongRouteId == 0u) + { + /*ޱ*/ + PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO; + + PhysicalSectionDataStru[bufIndex].LockDirection = 0u; /*շ*/ + } + else + { + /*б*/ + PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_PROTECT; /*###÷*/ + } + + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u; /*ν··ID*/ + + PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u; /*ʱʼ*/ + + PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u; /*ʱʽʱ*/ + + } + else if (PhysicalSectionDataStru[bufIndex].PLockBelongRouteId == routeId) + { + /*ͬʱڵķ*/ + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u; /*η·ID*/ + } + else + { + + /*ڱ·*/ + } + } + else + { + if ((PHYSICAL_SECTION_LOCK_PROTECT == PhysicalSectionDataStru[bufIndex].LockState) && + (PhysicalSectionDataStru[bufIndex].PLockBelongRouteId != routeId)) + { + + /*->Ҳڱ·յķ*/ + } + else + { + PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO; /*###δ*/ + + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u; /*ν··ID*/ + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u; /*η·ID*/ + PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u; /*ʱʼ*/ + PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u; /*ʱʽʱ*/ + PhysicalSectionDataStru[bufIndex].LockDirection = 0u; /*շ*/ + } + } + } + else if (PHYSICAL_SECTION_LOCK_NORMAL == lockState) + { /**/ + + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###*/ + + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId; + PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection; /*շ*/ + } + else if (PHYSICAL_SECTION_LOCK_EXCEPT == lockState) + { /*쳣*/ + + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###쳣*/ + /*PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u; ʱʽʱ*/ + } + else if (PHYSICAL_SECTION_LOCK_PROTECT == lockState) + { /**/ + + if (PHYSICAL_SECTION_LOCK_NO == PhysicalSectionDataStru[bufIndex].LockState) + { /*ǰδ*/ + + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###÷*/ + } + + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = routeId; + PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection; /*շ*/ + } + else if (PHYSICAL_SECTION_LOCK_DELAY == lockState) + { /*ʱ*/ + + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###ʱ*/ + } + else if (PHYSICAL_SECTION_LOCK_FAULTDELAY == lockState) + { /*ʽʱ*/ + + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###ʽʱ*/ + } + else + { + /*״̬Ч*/ + } + } +} + +/* +* ÷DZָID״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 lockState, ״̬ +* const UINT16 routeId, ·ID +* const UINT8 lockDirection, շ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecLockStateOtherCI(const UINT16 phySectionId, const UINT8 lockState, const UINT16 routeId, const UINT8 lockDirection) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 returnValue = CI_SUCCESS; + UINT8 cLocalCiId = 0U; + UINT16 wCurRouteId = 0U; + UINT8 cCurRouteBelongCiId = 0U; /*ǰս·CI*/ + UINT8 cInputRouteBelongCiId = 0U; /*ν·CI*/ + UINT8 cRouteState = 0U; + UINT8 chNewRouteCurState = 0U;/*µĽ·ǰ״̬*/ + UINT8 chNewRoutePreState = 0U;/*µĽ·֮ǰ״̬*/ + UINT8 chOldRoutePreState = 0U;/*ɵĽ·֮ǰ״̬*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex >= PHYSICAL_SECTION_SUM_MAX) + { + returnValue = CI_ERROR; + } + else + { + cLocalCiId = GetSystemParaLocalCiId(); + cInputRouteBelongCiId = GetRouteBelongCiId(routeId); + if((PHYSICAL_SECTION_LOCK_PROTECT==PhysicalSectionDataStru[bufIndex].LockState) && (GetPhySecBelongCiId(phySectionId)== GetSystemParaLocalCiId()) + && ((PHYSICAL_SECTION_LOCK_NORMAL != lockState) || (cLocalCiId == cInputRouteBelongCiId))) + {/*ε״̬ɱ´ģ״̬Ϊ·DZΪZHGɷתΪգˢ״̬*/ + returnValue = CI_SUCCESS; + } + else if (PHYSICAL_SECTION_LOCK_START == lockState) + { /*ϵ*/ + + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###ϵ*/ + } + else if (PHYSICAL_SECTION_LOCK_NO == lockState) + { /*δ*/ + + if ((PHYSICAL_SECTION_LOCK_NORMAL == PhysicalSectionDataStru[bufIndex].LockState) + || (PHYSICAL_SECTION_LOCK_EXCEPT == PhysicalSectionDataStru[bufIndex].LockState) + || (PHYSICAL_SECTION_LOCK_DELAY == PhysicalSectionDataStru[bufIndex].LockState)) + { /*->*/ + + if (GetRouteBelongCiId(PhysicalSectionDataStru[bufIndex].RLockBelongRouteId) == GetSystemParaLocalCiId()) + { + } + else + { + /*ڱ·ÿ*/ + if (PhysicalSectionDataStru[bufIndex].PLockBelongRouteId == 0u) + { + /*ޱ*/ + PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO; + + PhysicalSectionDataStru[bufIndex].LockDirection = 0u; /*շ*/ + } + else + { + /*б*/ + PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_PROTECT; /*###÷*/ + } + + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u; /*ν··ID*/ + + PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u; /*ʱʼ*/ + + PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u; /*ʱʽʱ*/ + } + } + else + { + if (PHYSICAL_SECTION_LOCK_PROTECT == PhysicalSectionDataStru[bufIndex].LockState) + {/*βڱҵǰ״̬DZգε״̬ô״̬*/ + PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO; /*###δ*/ + + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0; /*ν··ID*/ + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0; /*η·ID*/ + PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0; /*ʱʼ*/ + PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0; /*ʱʽʱ*/ + PhysicalSectionDataStru[bufIndex].LockDirection = 0; /*շ*/ + } + + if (0U == PhysicalSectionDataStru[bufIndex].LockState) + {/*βڱһδյε״̬Ϣʱε״̬ô״̬*/ + PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO; /*###δ*/ + + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u; /*ν··ID*/ + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u; /*η·ID*/ + PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u; /*ʱʼ*/ + PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u; /*ʱʽʱ*/ + PhysicalSectionDataStru[bufIndex].LockDirection = 0u; /*շ*/ + } + + if((GetSystemParaLocalCiId()!= GetPhySecBelongCiId(phySectionId)) && (PhysicalSectionDataStru[bufIndex].LockState == PHYSICAL_SECTION_LOCK_START)) + {/*δϵǰPHYSICAL_SECTION_LOCK_START״̬ϵPHYSICAL_SECTION_LOCK_NO + ҪΪPHYSICAL_SECTION_LOCK_NO*/ + PhysicalSectionDataStru[bufIndex].LockState = PHYSICAL_SECTION_LOCK_NO; /*###δ*/ + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u; /*ν··ID*/ + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u; /*η·ID*/ + PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = 0u; /*ʱʼ*/ + PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u; /*ʱʽʱ*/ + PhysicalSectionDataStru[bufIndex].LockDirection = 0u; /*շ*/ + } + } + SetProtectSecLockDelayTimeFlag(phySectionId, PROTECTSECLOCKDELAY_NO); + SetPhySecLockDelayStartCycNum(phySectionId, 0u); /*ʱں*/ + + } + else if (PHYSICAL_SECTION_LOCK_NORMAL == lockState) + { /**/ + if (cInputRouteBelongCiId == cLocalCiId) + { + /**/ + } + else + { + wCurRouteId = GetPhySecRLockBelongRouteId(phySectionId); + cCurRouteBelongCiId = GetRouteBelongCiId(wCurRouteId); + cRouteState = GetRouteState(wCurRouteId); + chOldRoutePreState = GetRoutePreState(wCurRouteId); + chNewRouteCurState = GetRouteState(routeId); + chNewRoutePreState = GetRoutePreState(routeId); + + if ((routeId != wCurRouteId) && (cLocalCiId == cCurRouteBelongCiId) + && ((ROUTE_STATE_HALF_UNLOCK == cRouteState) + || (ROUTE_STATE_FIRST_LOCK == chNewRouteCurState) || (ROUTE_STATE_FIRST_LOCK == chNewRoutePreState) + || (ROUTE_STATE_FIRST_LOCK == cRouteState) || (ROUTE_STATE_FIRST_LOCK == chOldRoutePreState))) + { + /*ʱµIJڱĽ·ǰΪ֮ǰΪԭ״̬֮ǰҪͨŲã*/ + } + else + { + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###*/ + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId; + PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection; /*շ*/ + } + } + } + else if (PHYSICAL_SECTION_LOCK_EXCEPT == lockState) + { /*쳣*/ + if (GetRouteBelongCiId(PhysicalSectionDataStru[bufIndex].RLockBelongRouteId) == GetSystemParaLocalCiId()) + { + } + else + { + if ((GetRouteBelongCiId(routeId) != GetSystemParaLocalCiId()) || (PhysicalSectionDataStru[bufIndex].LockState == 0u)|| (PhysicalSectionDataStru[bufIndex].LockState == PHYSICAL_SECTION_LOCK_START)) + { + /* + * ͵״̬쳣 + * ս·ڱֱӸ£ս·ڱҪжµǰ·״̬Ƿ00Ϊdzʼʱ + * + * + * + */ + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###쳣*/ + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId; /*###쳣*/ + PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection; /*YF0083-2431·ڱгڴηɳγֹգø߼ηΪ0*/ + } + + /*PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = 0u; ʱʽʱ*/ + } + SetProtectSecLockDelayTimeFlag(phySectionId, PROTECTSECLOCKDELAY_NO); + SetPhySecLockDelayStartCycNum(phySectionId, 0u); /*ʱں*/ + + } + else if (PHYSICAL_SECTION_LOCK_PROTECT == lockState) + { + /**/ + cCurRouteBelongCiId = GetRouteBelongCiId(PhysicalSectionDataStru[bufIndex].RLockBelongRouteId); + if (GetPhySecBelongCiId(phySectionId) == GetSystemParaLocalCiId()) + { + if ((cLocalCiId != cCurRouteBelongCiId) && (cCurRouteBelongCiId == cInputRouteBelongCiId)) + { + /*ΪZHG···δ״̬*/ + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*÷*/ + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = routeId; + PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection; /*շ*/ + if (0U != PhysicalSectionDataStru[bufIndex].RLockBelongRouteId) + { + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0U; + } + } + else + { + /*ΪηԼ*/ + } + } + else + { + if ((cLocalCiId == cCurRouteBelongCiId) && (cLocalCiId == cInputRouteBelongCiId)) + { + /*ZHG⣬ǰ··ͷ·Ϊˢ״̬*/ + } + else + { + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###÷*/ + + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = routeId; + PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection; /*շ*/ + if ((PhysicalSectionDataStru[bufIndex].RLockBelongRouteId != 0u) && (GetRouteBelongCiId(PhysicalSectionDataStru[bufIndex].RLockBelongRouteId) != GetSystemParaLocalCiId())) + { + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u; + } + } + } + } + else if (PHYSICAL_SECTION_LOCK_DELAY == lockState) + { /*ʱ*/ + /* ڴδյӳ״̬ */ + if (GetRouteBelongCiId(routeId) == GetSystemParaLocalCiId()) + {/*·ڱ򲻸*/ + } + else + { + if(PHYSICAL_SECTION_LOCK_NO != PhysicalSectionDataStru[bufIndex].LockState) + { + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###ʱ*/ + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId;/*ʱ·ID*/ + PhysicalSectionDataStru[bufIndex].LockDirection = lockDirection; /*շ*/ + } + } + } + else if (PHYSICAL_SECTION_LOCK_FAULTDELAY == lockState) + { /*ʽʱ*/ + /* ڴδյӳ״̬ */ + if(PHYSICAL_SECTION_LOCK_NO != PhysicalSectionDataStru[bufIndex].LockState) + { + PhysicalSectionDataStru[bufIndex].LockState = lockState; /*###ʽʱ*/ + } + } + else + { /*״̬Ч*/ + + returnValue = CI_ERROR; + } + } + + + return returnValue; +} + +/* +* ȡָIDη״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetPhySecFLockState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].FLockState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDη״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 fLockState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecFLockState(const UINT16 phySectionId, const UINT8 fLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex >= PHYSICAL_SECTION_SUM_MAX) + { + retVal = CI_ERROR; + } + else + { + if ((fLockState == PHYSICAL_SECTION_FLOCK_NO) || (fLockState == PHYSICAL_SECTION_FLOCK_YES)) + {/*״̬Ϊδ*/ + + PhysicalSectionDataStru[bufIndex].FLockState = fLockState; + retVal = CI_SUCCESS; + } + else + {/*״̬ȷ*/ + retVal = CI_ERROR; + } + } + return retVal; + + +} + +/* +* ȡָIDν··ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ··ID +*/ +UINT16 GetPhySecRLockBelongRouteId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].RLockBelongRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָη·ID +* ˵const UINT16 wPhySectionId ID +* const UINT16 wPLockRouteId ·ID +* ֵ +* Created By LQ 2024.06.11 +*/ +void SetPhySecPLockRouteId(const UINT16 wPhySectionId, const UINT16 wPLockRouteId) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); /*ȡ±*/ + + if ((PHYSICAL_SECTION_SUM_MAX > wBufIndex) && (ROUTE_SUM_MAX > wPLockRouteId)) + { + PhysicalSectionDataStru[wBufIndex].PLockBelongRouteId = wPLockRouteId; /*÷·ID*/ + } + else + { + /*ηǷ*/ + } +} + +/* +* ȡָIDη·ID +* ˵ const UINT16 phySectionId, ID +* ֵ ·ID +*/ +UINT16 GetPhySecPLockBelongRouteId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].PLockBelongRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDշ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: շ +*/ +UINT8 GetPhySecLockDirection(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].LockDirection; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID֮ǰɼ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ֮ǰɼ״̬ +*/ +UINT8 GetPhySecPreOccupyState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].PreOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָID֮ǰɼ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 preCollState, ֮ǰɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecPreOccupyState(const UINT16 phySectionId, const UINT8 preCollState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((SECTION_OCCUPY_NO == preCollState) || (SECTION_OCCUPY_YES == preCollState)) + { + PhysicalSectionDataStru[bufIndex].PreOccupyState = preCollState; /*εǰɼ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDεǰɼ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰɼ״̬ +*/ +UINT8 GetPhySecCurOccupyState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].CurOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDεǰOcĹɼ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰɼ״̬ +*/ +UINT8 GetPhySecCurOcGdOccupyState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].CurOcGdOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDεǰOcɼ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curCollState, ǰɼ״̬ +* ֵ +* +*/ +void SetPhySecCurOcGdOccupyState(const UINT16 phySectionId, const UINT8 curCollState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((SECTION_OCCUPY_NO == curCollState) || (SECTION_OCCUPY_YES == curCollState) || + (SECTION_OCCUPY_FAULT == curCollState)) + { + PhysicalSectionDataStru[bufIndex].PreOcGdOccupyState = PhysicalSectionDataStru[bufIndex].CurOcGdOccupyState; /*֮ǰɼ״̬*/ + PhysicalSectionDataStru[bufIndex].CurOcGdOccupyState = curCollState; /*εǰɼ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDεǰιɼ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰɼ״̬ +*/ +UINT8 GetPhySecCurAxisGdOccupyState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].CurAxleGdOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDεǰռòɼ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curCollState, ǰɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecCurAxisGdOccupyState(const UINT16 phySectionId, const UINT8 curCollState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + if ((SECTION_OCCUPY_NO == curCollState) || (SECTION_OCCUPY_YES == curCollState) || (SECTION_OCCUPY_FAULT == curCollState)) + { + PhysicalSectionDataStru[bufIndex].PreAxleGdOccupyState = PhysicalSectionDataStru[bufIndex].CurAxleGdOccupyState; /*֮ǰɼ״̬*/ + PhysicalSectionDataStru[bufIndex].CurAxleGdOccupyState = curCollState; /*εǰɼ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDεǰɼ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curCollState, ǰɼ״̬ +* ֵ +* +*/ +void SetPhySecCurOccupyState(const UINT16 phySectionId, const UINT8 curCollState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 dwCurCycNum = 0U; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((SECTION_OCCUPY_NO == curCollState) || (SECTION_OCCUPY_YES == curCollState)) + { + dwCurCycNum = Get2oo2CurCycleNum(); + + if (SECTION_OCCUPY_NO == curCollState) + { + PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum = 0U; /*βɼռʼΪ0*/ + } + else if (0U == PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum) + { + PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum = dwCurCycNum; /*βɼռʼ*/ + } + else + { + /**/ + } + + PhysicalSectionDataStru[bufIndex].PreOccupyState = PhysicalSectionDataStru[bufIndex].CurOccupyState; /*֮ǰɼ״̬*/ + PhysicalSectionDataStru[bufIndex].CurOccupyState = curCollState; /*εǰɼ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָID֮ǰں״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰں״̬ +*/ +UINT8 GetPhySecPreMergeState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].PreMergeOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDεǰں״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰں״̬ +*/ +UINT8 GetPhySecCurMergeState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].CurMergeOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDεǰռԭں״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰں״̬ +*/ +UINT8 GetPhySecCurAndMergeState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].CurAndMergeOccupyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDεǰں״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curProcState, ǰں״̬ +* ֵ +* +*/ +void SetPhySecCurMergeState(const UINT16 phySectionId, const UINT8 curProcState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((SECTION_OCCUPY_NO == curProcState) || (SECTION_OCCUPY_YES == curProcState)) + { + + /*ռ״̬仯*/ + if (PhysicalSectionDataStru[bufIndex].CurMergeOccupyState != curProcState) + { + /*֮ǰں״̬*/ + PhysicalSectionDataStru[bufIndex].PreMergeOccupyState = PhysicalSectionDataStru[bufIndex].CurMergeOccupyState; + } + + PhysicalSectionDataStru[bufIndex].CurMergeOccupyState = curProcState; /*εǰں״̬*/ + + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ָIDεǰռԭں״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curProcState, ǰں״̬ +* ֵ +* +*/ +void SetPhySecCurAndMergeState(const UINT16 phySectionId, const UINT8 curProcState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((SECTION_OCCUPY_NO == curProcState) || (SECTION_OCCUPY_YES == curProcState)) + { + + /*ռ״̬仯*/ + if (PhysicalSectionDataStru[bufIndex].CurAndMergeOccupyState != curProcState) + { + /*֮ǰں״̬*/ + PhysicalSectionDataStru[bufIndex].PreAndMergeOccupyState = PhysicalSectionDataStru[bufIndex].CurAndMergeOccupyState; + } + + PhysicalSectionDataStru[bufIndex].CurAndMergeOccupyState = curProcState; /*εǰں״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ָID֮ǰں״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curProcState, ֮ǰں״̬ +* ֵ +* +*/ +void SetPhySecPreMergeState(const UINT16 phySectionId, const UINT8 preProcState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((SECTION_OCCUPY_NO == preProcState) || (SECTION_OCCUPY_YES == preProcState)) + { + + /*֮ǰں״̬*/ + PhysicalSectionDataStru[bufIndex].PreMergeOccupyState = preProcState; + + } + else + { + /**/ + } + } + else + { + /**/ + } +} +/* +* ָID֮ǰں״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curProcState, ǰں״̬ +* ֵ +* +*/ +void CleanPhySecPreMergeState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + /*֮ǰں״̬*/ + PhysicalSectionDataStru[bufIndex].PreMergeOccupyState = SECTION_OCCUPY_NO; + + } + else + { + /**/ + } +} + + +/* +* ȡָIDͣ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ͣ״̬ +*/ +UINT8 GetPhySecStopSteadyFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].StopSteadyFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDͣ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 stopSteadyState, ͣ״̬ +* ֵ +* +*/ +void SetPhySecStopSteadyFlag(const UINT16 phySectionId, const UINT8 stopSteadyState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((PHYSICAL_SECTION_STOPSTEADY_NO == stopSteadyState) || (PHYSICAL_SECTION_STOPSTEADY_YES == stopSteadyState)) + { + + PhysicalSectionDataStru[bufIndex].StopSteadyFlag = stopSteadyState; /*ͣ״̬*/ + + } + else + { + /**/ + } + } + else + { + /**/ + } +} + + +/* +* ȡָIDռóڼ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ռóڼ +*/ +UINT32 GetSecCurOccupyStartCycNum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SecCurOccupyStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDռñгڼ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ռóڼ +*/ +UINT32 GetSecOccuToClearStartCycNum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SecOccuToClearStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDռóڼ +* ˵ const UINT16 phySectionId, ID +* const UINT8 cycCount, ռóڼ +* ֵ +* +*/ +void SetSecCurOccupyStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].SecCurOccupyStartCycNum = startCycNum; + } + else + { + /**/ + } +} + + +/* +* ָIDUTCTռʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, ռʼں +* ֵ +* +*/ +void SetSecUtOrCtOccuStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].UtOrCtOccuStartCycNum = startCycNum; + } + else + { + /**/ + } +} + +/* +* ȡָIDUTCTռʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ռóڼ +*/ +UINT32 GetSecUtOrCtOccuStartCycNum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].UtOrCtOccuStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDռñгڼ +* ˵ const UINT16 phySectionId, ID +* const UINT8 cycCount, ռóڼ +* ֵ +* +*/ +void SetSecOccuToClearStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].SecOccuToClearStartCycNum = startCycNum; + } + else + { + /**/ + } +} + + +/* +* ȡָIDԶʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Զʼں +*/ +UINT32 GetPhySecAutoUnlockStartCycNum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDԶʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Զʼں +* ֵ +* +*/ +void SetPhySecAutoUnlockStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].AutoUnlockStartCycNum = startCycNum; /*Զʼں*/ + } + else + { + /**/ + } +} + +/* +* ȡָIDʽʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Զʼں +*/ +UINT32 GetPhySecFaultUnlockStartCycNum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDʽʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Զʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecFaultUnlockStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].FaultUnlockStartCycNum = startCycNum; /*Զʼں*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ״̬ЧԼ +* ˵ const UINT8 lockState, ״̬ +* ֵ 0: Ч +* 1: Ч +*/ +UINT8 PhySecLockStateValidCheck(const UINT8 lockState) +{ + UINT8 retVal = CI_SUCCESS; + if ((PHYSICAL_SECTION_LOCK_START == lockState) || + (PHYSICAL_SECTION_LOCK_NO == lockState) || + (PHYSICAL_SECTION_LOCK_NORMAL ==lockState) || + (PHYSICAL_SECTION_LOCK_EXCEPT == lockState) || + (PHYSICAL_SECTION_LOCK_PROTECT == lockState) || + (PHYSICAL_SECTION_LOCK_DELAY == lockState) || + (PHYSICAL_SECTION_LOCK_FAULTDELAY == lockState)) + { + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDμḴλʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ḵλʼں +*/ +UINT32 GetPhySecResetStartCycNum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SectionResetStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +void SetPhySecSectionResetType(const UINT16 phySectionId, const UINT8 resetType) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].SectionResetType = resetType; /*μḴλ*/ + } + else + { + /**/ + } +} + +UINT8 GetPhySecSectionResetType(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SectionResetType; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDμḴλʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Ḵλʼں +* ֵ +* +*/ +void SetPhySecResetStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].SectionResetStartCycNum = startCycNum; /*μḴλʼں*/ + } + else + { + /**/ + } +} + + + +/* +* ȡָIDʱձ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ʱ־ +*/ +UINT8 GetProtectSecLockDelayTimeFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].ProtectSecLockDelayTimeFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDʱձ־ +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Ḵλʼں +* ֵ +* +*/ +void SetProtectSecLockDelayTimeFlag(const UINT16 phySectionId, const UINT8 delayTimeFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].ProtectSecLockDelayTimeFlag = delayTimeFlag; /*μḴλʼں*/ + + } + else + { + /**/ + } +} + + +/* +* Ƚռʱ +* ˵ const UINT16 phySectionId, ID +* const UINT16 otherSectionId, һID +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 CompareOccuTime(const UINT16 sectionId, const UINT16 otherSectionId) +{ + UINT8 retVal = CI_ERROR; + UINT32 secCurOccupyStartCyc = 0u; + UINT32 otherSecCurOccupyStartCyc = 0u; + INT32 cmpResult = 0; + + secCurOccupyStartCyc = GetSecCurOccupyStartCycNum(sectionId); /*οʼռں*/ + otherSecCurOccupyStartCyc = GetSecCurOccupyStartCycNum(otherSectionId); /*һοʼռں*/ + cmpResult =(INT32)(secCurOccupyStartCyc - otherSecCurOccupyStartCyc); + if ( (cmpResult > 0) && (otherSecCurOccupyStartCyc != 0u) ) /* ռʱΪ0ΪûгռãγԷ */ + { + + retVal = CI_ERROR; /*εռʱһεռʱ*/ + } + else + { + retVal = CI_SUCCESS; /*εռʱСһεռʱ*/ + } + + return retVal; +} + + +/* +* ȡָIDArb״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Arb״̬ +*/ +UINT8 GetPhySecArbState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].ArbState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDArb״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 arbState, Arb״̬ +* ֵ +* +*/ +void SetPhySecArbState(const UINT16 phySectionId, const UINT8 arbState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((AXIS_SECTION_ARB_NO == arbState) || (AXIS_SECTION_ARB_YES == arbState)) + { + PhysicalSectionDataStru[bufIndex].ArbState = arbState; /*ARB״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDֹͣ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ֹͣ״̬ +*/ +UINT8 GetPhySectionStopCheckFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].StopCheckFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDֹͣ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 stopCheckState, ֹͣ״̬ +* ֵ +* +*/ +void SetPhySectionStopCheckFlag(const UINT16 phySectionId, const UINT8 stopCheckState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((PHYSICAL_STOPCHECK_SET_NO == stopCheckState) || (PHYSICAL_STOPCHECK_SET_YES == stopCheckState)) + { + PhysicalSectionDataStru[bufIndex].StopCheckFlag = stopCheckState; /*ֹͣ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDԾ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ״̬ +*/ +UINT8 GetPhySecJumpLockState(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].JumpLockState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDԾ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void SetPhySecJumpLockState(const UINT16 phySectionId, const UINT8 jumpLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((PHYSICAL_SECTION_JUMP_LOCK_YES == jumpLockState) || (PHYSICAL_SECTION_JUMP_LOCK_NO == jumpLockState)) + { + PhysicalSectionDataStru[bufIndex].JumpLockState = jumpLockState; /*Ծ״̬*/ + } + else + { + /**/ + } + /*ȡԾգͬʱȡ߼εԾ״̬*/ + if (PHYSICAL_SECTION_JUMP_LOCK_NO == jumpLockState) + { + SetPhyIncludeLogJumpLockState(phySectionId, jumpLockState); + } + } + else + { + /**/ + } +} + +/* +* ȡָIDԾʱʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ծʱʼں +*/ +UINT32 GetPhySecJumpDelayUnlocStartCyc(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SecJumpDelayUnlockStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDԾʱʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Ծʱʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecJumpDelayUnlocStartCyc(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].SecJumpDelayUnlockStartCycNum = startCycNum; /*Ծʱʼں*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDԾʱñ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ծʱñ־ +*/ +UINT8 GetPhySecJumpDelayUnlockFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].JumpLockDelayUnlockFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDԾʱñ־ +* ˵ const UINT16 phySectionId, ID +* const UINT8 jumpDelayUnlockFlag, Ծʱñ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetPhySecJumpDelayUnlockFlag(const UINT16 phySectionId, const UINT8 jumpDelayUnlockFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_SUCCESS; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((PHYSICAL_JUMPUNLOCK_DELAY_SET_NO == jumpDelayUnlockFlag) || (PHYSICAL_JUMPUNLOCK_DELAY_SET_YES == jumpDelayUnlockFlag)) + { + PhysicalSectionDataStru[bufIndex].JumpLockDelayUnlockFlag = jumpDelayUnlockFlag; /*Ծʱñ־*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡη״̬־ +* ˵UINT16 phySecId Id +* ֵ δ: SPKS_STATUS_NO +* : SPKS_STATUS_YES +*/ +UINT8 GetPhySecFlockFlag(UINT16 phySecId) +{ + UINT8 spksNum = 0u; /* spks */ + UINT16 spksId = 0u; /* spksID */ + UINT16 jj = 0u; /* ѭ */ + UINT8 spksStatus = SPKS_STATUS_NO; /*SPKSť״̬*/ + + spksNum = GetPhySecSpksSum(phySecId); + for (jj = 0u;jj < spksNum;jj++) + { + spksId = GetPhySecSpksIdBySpksIdx(phySecId,jj); + if ((spksId > 0u ) && (SPKS_STATUS_YES == GetSpksState(spksId)) && (SPKS_CUT_NO == GetSpksCutState(spksId))) + { + spksStatus = SPKS_STATUS_YES; + break; + } + } + + if ((GetSystemParaLocalCiId() != GetPhySecBelongCiId(phySecId))&& + (PHYSICAL_SECTION_FLOCK_YES == GetPhySecFLockState(phySecId))) + { + spksStatus = SPKS_STATUS_YES; + } + + return spksStatus; +} + +/* +* ȡָIDʱʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ʱʼں +*/ +UINT32 GetPhySecLockDelayStartCycNum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].LockDelayStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDʱʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, ʱʼں +* ֵ +* +*/ +void SetPhySecLockDelayStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].LockDelayStartCycNum = startCycNum; /*ʱʼں*/ + } + else + { + /**/ + } +} + +/* +* εͣϢΪδͣ +* ˵ void +* ֵ void +*/ +void ResetPhySecStopSteadyInfo(void) +{ + UINT16 phySectionDataSum = 0u; /**/ + UINT16 phySectionId = 0u; /*ID*/ + UINT16 ii = 0u; /*α*/ + phySectionDataSum = GetPhySecCurSum(); /*Ŀ,ֻбβδͣ״̬*/ + + if (phySectionDataSum >= PHYSICAL_SECTION_SUM_MAX) + {/**/ + } + else + { + for (ii = 0u; ii < phySectionDataSum; ii++) + { + phySectionId = GetPhySecId(ii);/*ȡļиµID*/ + PhysicalSectionDataStru[phySectionId].StopSteadyFlag = PHYSICAL_SECTION_STOPSTEADY_NO; + } + } +} + +/* +* ûͨ״̬ +* ˵ +UINT16 phySectionId, ID +const UINT8 lockState,״̬ +* ֵ + +*/ +void SetPhySecLockStateHlht(UINT16 phySectionId, const UINT8 lockState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 preLockState = 0u; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + preLockState = PhysicalSectionDataStru[bufIndex].LockState; + + if(PHYSICAL_SECTION_LOCK_START != preLockState) + { + PhysicalSectionDataStru[bufIndex].LockState = lockState; + } + else + { + ; + } + } + else + { + /**/ + } +} + +/* +* ûͨͨŽӿϵ״̬ +* ˵ UINT16 phySectionIdID +* const UINT8 lockState ϵ״̬ +* ֵ +* CI_ERRORʧ +*/ +void SetPhySecStartLockStateHlht(UINT16 phySectionId, const UINT8 lockState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 preLockState = 0u; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + preLockState = PhysicalSectionDataStru[bufIndex].LockState; + + if(PHYSICAL_SECTION_LOCK_START != preLockState) + { + if(PHYSICAL_SECTION_LOCK_START == lockState) + { + PhysicalSectionDataStru[bufIndex].LockState = lockState; + } + } + else + { + PhysicalSectionDataStru[bufIndex].LockState = lockState; + } + } + else + { + /**/ + } +} + +/* +* ûͨν·Ľ·ID +* ˵ +UINT16 phySectionId, ID +const UINT16 routeId,ν··ID +* ֵ + +*/ +void SetPhySecRLockRouteIdHlht(UINT16 phySectionId, const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if(PHYSICAL_SECTION_LOCK_START != PhysicalSectionDataStru[bufIndex].LockState) + { + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = routeId; + } + else + { + if(0u == routeId) + { + PhysicalSectionDataStru[bufIndex].RLockBelongRouteId = 0u; + } + else + { + ; + } + } + } + else + { + /**/ + } +} +/* +* ûͨαĽ·ID +* ˵ +UINT16 phySectionId, ID +const UINT16 routeId,αĽ·ID +* ֵ + +*/ +void SetPhySecPLockRouteIdHlht(UINT16 phySectionId, const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if(PHYSICAL_SECTION_LOCK_START != PhysicalSectionDataStru[bufIndex].LockState) + { + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = routeId; + } + else + { + if(0U == routeId) + { + PhysicalSectionDataStru[bufIndex].PLockBelongRouteId = 0u; + } + else + { + ; + } + } + + } + else + { + /**/ + } +} + +/* +* ûͨεշ +* ˵ +UINT16 phySectionId, ID +const UINT8 lockDir,շ +* ֵ + +*/ +void SetPhySecLockDirHlht(UINT16 phySectionId, const UINT8 lockDir) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if(PHYSICAL_SECTION_LOCK_START != PhysicalSectionDataStru[bufIndex].LockState) + { + PhysicalSectionDataStru[bufIndex].LockDirection = lockDir; + } + else + { + if(CI_SYSTEM_DIRECTION_NONE == lockDir) + { + PhysicalSectionDataStru[bufIndex].LockDirection = CI_SYSTEM_DIRECTION_NONE; + } + else + { + ; + } + } + } + else + { + /**/ + } +} + +/* +* η +* ˵ +UINT16 phySectionId, ID +const UINT8 fLockType,η +* ֵ + +*/ +void SetPhySecFLockType(const UINT16 phySectionId, const UINT8 fLockType) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((PHY_SEC_FLOCK_TYPE_NONE == fLockType) || (PHY_SEC_FLOCK_TYPE_SPKS == fLockType) || (PHY_SEC_FLOCK_TYPE_CMD == fLockType)|| (PHY_SEC_FLOCK_TYPE_SPKSCMD == fLockType)) + { + PhysicalSectionDataStru[bufIndex].FLockType = fLockType; + } + } + +} + +/* +* ȡη +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: η +*/ +UINT8 GetPhySecFLockType(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].FLockType; + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡܸλ̵״̬Ч +* ˵ const UINT16 phySecId, ID +* ֵ CI_ERROR Ч +* CI_SUCCESS Ч +*/ +UINT8 GetZFWValidByPhySecId(const UINT16 phySecId) +{ + UINT16 relayId = 0u; + UINT16 relayCollState = 0u; + UINT8 retVal = CI_ERROR; + + relayId = GetPhySecZFWRelayId(phySecId); /*ȡܸλ̵ID*/ + + if ((0u == relayId) || (UINT16_MAX == relayId)) + { + retVal = CI_SUCCESS; /*δܸλ̵Ḵλʱм飩ĬЧ*/ + } + else + { + /*ܸλ̵ж״̬Ч*/ + relayCollState = GetRelayCollState(relayId); /*ȡָIDܸλ̵״̬*/ + + if (RELAY_STATE_UP == relayCollState) + { + retVal = CI_SUCCESS; /*ܸλ̵Ϊ״̬ʱΪЧִмḴλ*/ + } + else + { + retVal = CI_ERROR; /*ܸλ̵Ϊ״̬ʱΪЧܽмḴλ*/ + } + } + + return retVal; +} + +/* +* ȡܸλ̵״̬Ч +* ˵ const UINT16 ciId, ciId +* ֵ UINT16 relayId, ܸλ̵ID +*/ +UINT16 GetZFWRelayId(const UINT16 ciId) +{ + UINT16 ii = 0u; /*ѭ*/ + UINT16 phySecId = 0u; + UINT16 relayId = 0u; + UINT16 phySecSum = 0u; + UINT8 belongCiId = 0u; /*ID*/ + + phySecSum = GetPhySecCurSum(); + + for (ii = 0u; ii < phySecSum; ii++) + { + phySecId = 0u; /*ID*/ + belongCiId = 0u; /*ID*/ + + phySecId = GetPhySecId(ii);/*ȡID*/ + if ((phySecId > 0u) && (phySecId < PHYSICAL_SECTION_SUM_MAX)) + { + relayId = GetPhySecZFWRelayId(phySecId); /*ȡܸλ̵ID*/ + belongCiId = GetPhySecBelongCiId(phySecId); /*ȡID*/ + + if ((0u == relayId) || (UINT16_MAX == relayId) || (belongCiId != ciId) || (0u == ciId)) + { + relayId = 0u;/*δܸλ̵Ḵλʱм飩ĬЧ*/ + } + else + { + break; + } + } + } + return relayId; +} + +/* +* ȡܸλ̵״̬Ч +* ˵ const UINT16 ciId, ciId +* ֵ UINT16 relayId, ܸλ̵ID +*/ +UINT16 GetZFWRelayId_UseVirCI(const UINT16 ciId,UINT8 virCIid) +{ + UINT16 ii = 0u; /*ѭ*/ + UINT16 phySecId = 0u; + UINT16 relayId = 0u; + UINT16 phySecSum = 0u; + UINT8 belongCiId = 0u; /*ID*/ + UINT8 belongVirCIid = 0u; + + phySecSum = GetPhySecCurSum(); + + for (ii = 0u; ii < phySecSum; ii++) + { + phySecId = 0u; /*ID*/ + belongCiId = 0u; /*ID*/ + + phySecId = GetPhySecId(ii);/*ȡID*/ + if ((0u < phySecId) && (PHYSICAL_SECTION_SUM_MAX > phySecId)) + { + relayId = GetPhySecZFWRelayId(phySecId); /*ȡܸλ̵ID*/ + belongCiId = GetPhySecBelongCiId(phySecId); /*ȡID*/ + belongVirCIid = GetPhySecBelongVirCiId(phySecId); + + if ((0u == relayId) || (UINT16_MAX == relayId) || (belongCiId != ciId) + || (0u == ciId)||(belongVirCIid != virCIid)) + { + relayId = 0u;/*δܸλ̵Ḵλʱм飩ĬЧ*/ + } + else + { + break; + } + } + } + return relayId; +} +/* +* ȡָIDεǰCTUTռ״̬ +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetPhySecCurCtOrUtOccupyState(const UINT16 phySecId) +{ + UINT16 axisSecId = 0u; /*ID*/ + UINT16 axisSecSum = 0u; /*Ŀ*/ + UINT16* axisSecIdBuf = NULL; /**/ + UINT16 logicSecSum = 0u; /*߼Ŀ*/ + UINT16* logicSecIdBuf = NULL; /*߼Id*/ + UINT8 occupyState = LOGICSECTION_OCCUPY_UT; /*߼ռ״̬ʼΪUTռ*/ + UINT16 ii = 0u; /*α*/ + UINT16 kk = 0u; /*α*/ + UINT8 retVal = CI_ERROR; + + axisSecSum = GetPAxisSectionSum(phySecId); /*ȡΰļĿ*/ + axisSecIdBuf = GetPAxisSectionIdBuf(phySecId); /*ȡΰļ*/ + for (ii = 0u;ii < axisSecSum; ii++) + { + axisSecId = axisSecIdBuf[ii]; /*ID*/ + logicSecSum = GetAxisSecLogSectionSum(axisSecId); /*ȡΰ߼Ŀ*/ + logicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId); /*ȡΰ߼*/ + + for (kk = 0u; kk< logicSecSum; kk++) + { + occupyState = GetLogSecOccupyState(logicSecIdBuf[kk]); + /*ͨųռ͵ʱ*/ + /*εǰCTUTռ״ֻ̬Ҫһ߼CTռãΪCT˳ж*/ + if (LOGICSECTION_OCCUPY_CT == occupyState) + { + retVal = LOGICSECTION_OCCUPY_CT; + break; + } + else if(LOGICSECTION_OCCUPY_UT == occupyState) + { + retVal = LOGICSECTION_OCCUPY_UT; + } + else + { + /*޳ռã*/ + } + } + /* ֻҪһ߼CTռãΪCT˳ж */ + if (LOGICSECTION_OCCUPY_CT == retVal) + { + break; + } + } + + return retVal; +} + +/* +* ȡָIDεǰͨųռ״̬ +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetPhySecCurTxOccupyState(const UINT16 phySecId) +{ + UINT16 axisSecId = 0u; /*ID*/ + UINT16 axisSecSum = 0u; /*Ŀ*/ + UINT16* axisSecIdBuf = NULL; /**/ + UINT16 logicSecSum = 0u; /*߼Ŀ*/ + UINT16* logicSecIdBuf = NULL; /*߼Id*/ + UINT8 occupyState = LOGICSECTION_OCCUPY_TX; /*߼ռ״̬ʼΪTXλõRMռ*/ + UINT16 ii = 0u; /*α*/ + UINT8 kk = 0u; /*α*/ + UINT8 retVal = CI_ERROR; + + axisSecSum = GetPAxisSectionSum(phySecId); /*ȡΰļĿ*/ + axisSecIdBuf = GetPAxisSectionIdBuf(phySecId); /*ȡΰļ*/ + + if ((0u < axisSecSum) && (NULL != axisSecIdBuf)) + { + for (ii = 0u; ii < axisSecSum; ii++) + { + axisSecId = axisSecIdBuf[ii]; /*ID*/ + logicSecSum = GetAxisSecLogSectionSum(axisSecId); /*ȡΰ߼Ŀ*/ + logicSecIdBuf = GetAxisSecLogSectionIdBuf(axisSecId); /*ȡΰ߼*/ + + if ((0u < logicSecSum) && (NULL != logicSecIdBuf)) + { + for (kk = 0u; kk < logicSecSum; kk++) + { + occupyState = GetLogSecTXOccupyState(logicSecIdBuf[kk]); + /*ͨųռ͵ʱ*/ + /*εǰͨųռ״ֻ̬Ҫһ߼ͨųռãΪͨųռã˳ж*/ + if (LOGICSECTION_OCCUPY_TX == occupyState) + { + retVal = LOGICSECTION_OCCUPY_TX; + break; + } + else if (LOGICSECTION_OCCUPY_NO_TX == occupyState) + { + retVal = LOGICSECTION_OCCUPY_NO_TX; + } + else + { + /*޳ռã*/ + } + } + /* ֻҪһ߼TXռãΪTX˳ж */ + if (LOGICSECTION_OCCUPY_TX == retVal) + { + break; + } + else + { + ; /*ִ*/ + } + } + + } + } + + + + return retVal; +} + + +/* +* ȡָIDCTUTռ״̬ +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetPhySecPreOccState(const UINT16 phySecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].UtOrCtOccFlag; /*ȡռ״̬*/ + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ָIDCTUTռ״̬ +* ˵ const UINT16 phySecId, ID + const UINT8 flag ֮ǰCTUTռ״̬ +* ֵ +* +*/ +void SetPhySecPreOccState(const UINT16 phySecId, const UINT8 flag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((LOGICSECTION_OCCUPY_UT == flag) || (LOGICSECTION_OCCUPY_CT == flag) + || (LOGICSECTION_OCCUPY_NO == flag)) + {/*ǰ״̬־Ϊͨųͨųռ״̬*/ + PhysicalSectionDataStru[bufIndex].UtOrCtOccFlag = flag; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ָIDεǰԤλ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 preResetState, Ԥλ״̬ +* ֵ +* +*/ +void SetPhySecPreResetState(const UINT16 phySectionId, const UINT8 preResetState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((PHYSICAL_SECTION_PRE_RESET_YES == preResetState) || (PHYSICAL_SECTION_PRE_RESET_NO == preResetState)) + { + PhysicalSectionDataStru[bufIndex].PhySecPreResetState = preResetState; /*Ԥλ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDμԤλ״̬ +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ǰԤλ״̬ +*/ +UINT8 GetPhySecPreResetState(const UINT16 phySecId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySecId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].PhySecPreResetState; /*ȡμԤλ״̬*/ + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/**********JumpLockStateToZC******/ + +/* +* ȡָIDθZCԾ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ״̬ +*/ +UINT8 GetPhySecJumpLockStateToZC(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].JumpLockStateToZC; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDθZCԾ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void SetPhySecJumpLockStateToZC(const UINT16 phySectionId, const UINT8 jumpLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((PHYSICAL_SECTION_JUMP_LOCK_YES == jumpLockState) || (PHYSICAL_SECTION_JUMP_LOCK_NO == jumpLockState)) + { + PhysicalSectionDataStru[bufIndex].JumpLockStateToZC = jumpLockState; /*ZCԾ״̬*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} +/* +* ָIDιARB״̬ +* ˵ UINT16 phySecId, ID +* UINT8 arbState, arb״̬ +* ֵ CI_ERROR: ʧ +* 1: óɹ +*/ +void SetPhyContainAxisSecArbState(UINT16 phySecId,UINT8 arbState) +{ + UINT8 phySecContainAxisSecSum = 0u; + UINT16* phySecContainAxisSecIdBuf = NULL; + UINT8 reVal = CI_ERROR; + UINT8 jj =0u; + phySecContainAxisSecSum = GetPAxisSectionSum(phySecId); + phySecContainAxisSecIdBuf = GetPAxisSectionIdBuf(phySecId); + if ((0u == phySecContainAxisSecSum)) + { + reVal = CI_ERROR; + } + else + { + reVal = CI_SUCCESS; + } + if (CI_SUCCESS == reVal) + { + if((AXIS_SECTION_ARB_YES == arbState)||(AXIS_SECTION_ARB_NO ==arbState)) + { + for (jj = 0u; jj < phySecContainAxisSecSum; jj++) + { + SetAxisSecArbState(phySecContainAxisSecIdBuf[jj], arbState);/*üARB*/ + } + } + else + { + } + + } + else + { + } +} + +/* +* ȡָIDη·ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetPhySecProtectUseRouteId(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SecProUseBelongRouteId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/** +* @brief ARBô +* @note ֮󣬵ô˺εARB״̬ +*/ +void SetPhySecArbStateProc(void) +{ + UINT16 i = 0u; + UINT16 wPhyNum = 0u; + UINT8 chLocalCiId = 0u; + UINT8 chPhyCiId = 0u; + UINT16 wPhyId = 0u; + UINT8 chPhyArbState = 0u; + UINT8 chSetArbState = 0u; + + chLocalCiId = GetSystemParaLocalCiId(); + if (0u != chLocalCiId) + { + wPhyNum = GetPhySecCurSum(); + for (i = 0u; i < wPhyNum; i++) + {/* */ + wPhyId = GetPhySecId(i); + chPhyCiId = GetPhySecBelongCiId(wPhyId); + /* TIOC */ + if (chLocalCiId == chPhyCiId) + { + chPhyArbState = aam_GetPhyIsARB(wPhyId); + if (AAM_API_AC_ARB == chPhyArbState) + {/* ARB */ + chSetArbState = AXIS_SECTION_ARB_YES; + } + else + {/* ηARB */ + chSetArbState = AXIS_SECTION_ARB_NO; + } + /* ARB״̬ */ + SetPhySecArbState(wPhyId, chSetArbState); + /*Arb״̬ùarb*/ + SetPhyContainAxisSecArbState(wPhyId, chSetArbState); + } + else + { + ; + } + } + } + else + { + ; + } +} + +/* +* ȡָεļ +* ˵ const UINT16 wPhySecId, ID +* ֵ UINT16_MAX ʧ; ɹ +*/ +UINT16 GetAxisSecIdByPhySecIdAndSwSta(const UINT16 wPhySecId) +{ + UINT16 wRetVal = UINT16_MAX; + UINT8 cAxisSectionSum = 0u; + UINT16* pAxisSectionIdBuf = NULL; + UINT16 wAxisSectionId = 0u; + UINT8 cAxisSwitchSum = 0u; + AxisSwitchStruct* pAxisSwitchInfo = NULL; + UINT8 cSwitchState = SWITCH_POSITION_INVALID; + UINT8 ii = 0u; + UINT8 jj = 0u; + + cAxisSectionSum = GetPAxisSectionSum(wPhySecId); + pAxisSectionIdBuf = GetPAxisSectionIdBuf(wPhySecId); + + if (0u != cAxisSectionSum) + { + for (ii = 0u;ii < cAxisSectionSum;ii++) + { + /* ȡID */ + wAxisSectionId = pAxisSectionIdBuf[ii]; + + /* ȡιĵ */ + cAxisSwitchSum = GetAxisSwitchSum(wAxisSectionId); + pAxisSwitchInfo = GetAxisSwitchIdStru(wAxisSectionId); + + if (NULL != pAxisSwitchInfo) + { + for (jj = 0u; jj < cAxisSwitchSum; jj++) + { + /* ȡ״̬ */ + cSwitchState = GetSwitchCurPosition(pAxisSwitchInfo[jj].SwitchId); + + if (cSwitchState != pAxisSwitchInfo[jj].SwitchPosition) + { + break; + } + else + { + } + } + + if (jj != cAxisSwitchSum) + { + wAxisSectionId = 0u; + } + else + { + } + } + else + { + wAxisSectionId = 0u; + } + + if (0u != wAxisSectionId) + { + wRetVal = wAxisSectionId; + break; + } + else + { + } + } + } + else + { + ; /* ʧ */ + } + + return wRetVal; +} + +/**********JumpLockStateToZC****END**/ + +/* +* ߼Ծ״̬Ծ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ +*/ +void SetLogRelaPhySecJumpLockSta(const UINT16 logSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 phySecId = 0u; + UINT8 phyRelativeAxisSecNum = 0u; + UINT16* phyRelativeAxisSecIdBuf = NULL; + UINT8 ii = 0u; + UINT8 jj = 0u; + UINT8 axisRelativeLogSecNum = 0u; + UINT16* axisRelativeLogSecIdBuf = NULL; + UINT8 logJumpLockState = LOGIC_SECTION_JUMP_LOCK_NO; + + /** ȡ߼±*/ + bufIndex = GetlogSectionBufIndex(logSectionId); + + /** ±Ϸ*/ + if (LOGIC_SECTION_SUM_MAX > bufIndex) + { + + /** ȡ߼ιID*/ + phySecId = GetLgcSecRelativePhySecId(logSectionId); + + /** ȡιļID*/ + phyRelativeAxisSecNum = GetPAxisSectionSum(phySecId); + phyRelativeAxisSecIdBuf = GetPAxisSectionIdBuf(phySecId); + if ((0u < phyRelativeAxisSecNum) && (NULL != phyRelativeAxisSecIdBuf )) + { + for (ii = 0u; ii < phyRelativeAxisSecNum; ii++) + { + /** ȡι߼ID*/ + axisRelativeLogSecNum = GetAxisSecLogSectionSum(phyRelativeAxisSecIdBuf[ii]); + axisRelativeLogSecIdBuf = GetAxisSecLogSectionIdBuf(phyRelativeAxisSecIdBuf[ii]); + if ((0u < axisRelativeLogSecNum) && (NULL != axisRelativeLogSecIdBuf)) + { + for (jj = 0u; jj < axisRelativeLogSecNum; jj++) + { + logJumpLockState = GetLogSecJumpLockState(axisRelativeLogSecIdBuf[jj]); + /** һ߼Ծѭ*/ + if (LOGIC_SECTION_JUMP_LOCK_YES == logJumpLockState) + { + break; + } + } + + if (jj == axisRelativeLogSecNum) + { + /** üι߼Ծվδ*/ + } + else + { + /** üι߼һԾ*/ + break; + } + } + else + { + /** */ + } + } + + /** ι߼Ծվδ*/ + if (ii == phyRelativeAxisSecNum) + { + SetPhySecJumpLockState(phySecId, PHYSICAL_SECTION_JUMP_LOCK_NO); + } + else + { + /** ι߼һԾ*/ + SetPhySecJumpLockState(phySecId, PHYSICAL_SECTION_JUMP_LOCK_YES); + } + } + else + { + /** */ + } + } + else + { + /** */ + } +} +/* +* ǷָSPKS +* ˵ const UINT16 phySecId, ID + const UINT16 spksIdָSPKS ID +* ֵ 0: ʧ +* 1: ɹ +* cgh-ϲCID-2539-1 +*/ +UINT8 CheckPhySecFlockBlongSpks(const UINT16 phySecId, const UINT16 spksId) +{ + UINT8 SpksOfPhyFlockSum = 0u; + UINT16 SpksOfPhyFlockId = 0u; + UINT8 ii = 0u; + UINT8 SpksState = 0u; + UINT8 ret = CI_ERROR; + SpksOfPhyFlockSum = GetPhySecSpksSum(phySecId); + for (ii = 0u; ii < SpksOfPhyFlockSum; ii++) + { + SpksOfPhyFlockId = GetPhySecSpksIdBySpksIdx(phySecId, ii); + SpksState = GetSpksState(SpksOfPhyFlockId); + if ((SPKS_STATUS_YES == SpksState) && (SpksOfPhyFlockId != spksId)) + { + ret = CI_ERROR; + break; + } + else + { + ret = CI_SUCCESS; + } + } + + return ret; +} + +/* +* ָIDΰ߼Ծ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* by-cgh-20230628-Ծ״̬ʱͬʱ߼Ծ״̬ +*/ +void SetPhyIncludeLogJumpLockState(const UINT16 phySectionId, const UINT8 jumpLockState) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16* pLogSecBuf = NULL; + UINT8 chLogSecSum = 0U; + UINT8 ii = 0U; + + pLogSecBuf = GetPhySecIncLogSecIdBuf(phySectionId); + chLogSecSum = GetPhySecIncLogSecSum(phySectionId); + + if (NULL != pLogSecBuf) + { + for (ii = 0U; ii < chLogSecSum; ii++) + { + if (PHYSICAL_SECTION_JUMP_LOCK_NO == jumpLockState) + { + SetLogSecJumpLockState(pLogSecBuf[ii], LOGIC_SECTION_JUMP_LOCK_NO); + } + else + { + /*ڴ˺߼Ծ*/ + } + } + } +} + +/* +* ʱʽʱ +* ˵ const UINT16 wPhySectionId, ID +* const UINT16 wPhyErrUnlockTime ʱʽʱ +* by cgh 20230630 ݵʱ +*/ +void SetPhyErrUnlockTime(const UINT16 wPhySectionId, const UINT16 wPhyErrUnlockTime) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); ; /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > wBufIndex) + { + PhysicalSectionDataStru[wBufIndex].wPhyErrUnlockTime = wPhyErrUnlockTime; /*ʱ*/ + } +} + +/* +* ʱʽʱ +* ˵ const UINT16 wLogSectionId, ID +* ֵʱʱ +* * by cgh 20230630 ݵʱ +*/ +UINT16 GetPhyErrUnlockTime(const UINT16 wPhySectionId) +{ + UINT16 wBufIndex = 0U; /*±*/ + UINT16 reVal = 0U; + wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); ; /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > wBufIndex) + { + reVal = PhysicalSectionDataStru[wBufIndex].wPhyErrUnlockTime; /*ʱ*/ + } + return reVal; +} + +/* +* ָIDƶ״̬ +* ˵const UINT16 wPhySecId ID +* const UINT8 cAreaUrgentState ƶ״̬ +* ֵ +* Created By LQ 2023.11.09 +*/ +void SetPhySecAreaUrgentState(const UINT16 wPhySecId, const UINT8 cAreaUrgentState) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + if ((cAreaUrgentState == PHYSEC_AREA_URGENT_NO) || (cAreaUrgentState == PHYSEC_AREA_URGENT_YES)) + { + PhysicalSectionDataStru[bufIndex].cAreaUrgentBrakeState = cAreaUrgentState; + } + else + { + /*״̬Ƿ*/ + } + } + else + { + /*IDǷ*/ + } +} + +/* +* ȡָIDƶ״̬ +* ˵const UINT16 wPhySecId ID +* ֵ 0 ȡʧ +* >0 ƶ״̬ +* Created By LQ 2023.11.09 +*/ +UINT8 GetPhySecAreaUrgentState(const UINT16 wPhySecId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + retVal = PhysicalSectionDataStru[bufIndex].cAreaUrgentBrakeState; + } + else + { + /*IDǷʧ*/ + } + + return retVal; +} + +/* +* ͣгID +* ˵ const UINT16 wPhySectionId, ID +* const UINT16 wPhyStopSteadyTrainId ͣгID +*/ +void SetPhyStopSteadyTrainId(const UINT16 wPhySectionId, const UINT16 wPhyStopSteadyTrainId) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); ; /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > wBufIndex) + { + PhysicalSectionDataStru[wBufIndex].StopSteadyTrainId = wPhyStopSteadyTrainId; /*ͣгID*/ + } +} + +/* +* ͣгID +* ˵ const UINT16 wLogSectionId, ID +* ֵͣгID +*/ +UINT16 GetPhyStopSteadyTrainId(const UINT16 wPhySectionId) +{ + UINT16 wBufIndex = 0U; /*±*/ + UINT16 reVal = 0U; + wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); ; /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > wBufIndex) + { + reVal = PhysicalSectionDataStru[wBufIndex].StopSteadyTrainId; /*ʱ*/ + } + return reVal; +} + +/* +* ȡָIDεСȡֵ +* ˵ const UINT16 wPhySectionId, ID +* ֵ UINT8_MAX: ȡʧ +* >0: ʱȡֵ +* BY CGH 20240429 +*/ +UINT8 GetPhySecMinXiansuSpeed(const UINT16 wPhySectionId) +{ + UINT8 retVal = UINT8_MAX; + UINT8 chPhyIncLogSecSum = 0U;/*ΰ߼Ŀ*/ + UINT16* szPhySecIncLogId = NULL;/*ΰ߼ID*/ + UINT8 ii = 0U; + UINT8 chTsrDataSpeed = 0U;/*ֵ*/ + + + /** ±Ϸ */ + if (PHYSICAL_SECTION_SUM_MAX > wPhySectionId) + { + chPhyIncLogSecSum = GetPhySecIncLogSecSum(wPhySectionId); + szPhySecIncLogId = GetPhySecIncLogSecIdBuf(wPhySectionId); + + if (NULL != szPhySecIncLogId) + { + for (ii = 0U; ii < chPhyIncLogSecSum; ii++) + { + chTsrDataSpeed = GetLogSecXiansuSpeed(szPhySecIncLogId[ii]); + + if ((0U != chTsrDataSpeed) && (UINT8_MAX != chTsrDataSpeed)) + { + if (chTsrDataSpeed < retVal) + { + /*иСȡС*/ + retVal = chTsrDataSpeed; + } + else + { + ; /*޸С*/ + } + } + else + { + ; /*ٻǷ*/ + } + } + } + else + { + ; + } + } + else + { + ; /*MAX*/ + } + return retVal; +} + +/* +* CI͵η·ID +* ˵const UINT16 wPhySectionId ID +* const UINT16 wPLockRouteId ·ID +* ֵ +* Created By LQ 2024.06.11 +*/ +void SetPhySecOtherCiPLockRouteId(const UINT16 wPhySectionId, const UINT16 wPLockRouteId) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); /*ȡ±*/ + + if ((PHYSICAL_SECTION_SUM_MAX > wBufIndex) && (ROUTE_SUM_MAX > wPLockRouteId)) + { + PhysicalSectionDataStru[wBufIndex].OtherCiPLockBelongRouteId = wPLockRouteId; /*CI·ID*/ + } + else + { + /*ηǷ*/ + } +} + +/* +* CI͵η·ID +* ˵const UINT16 wPhySectionId ID +* ֵCI͵η·ID +* Created By LQ 2024.06.11 +*/ +UINT16 GetPhySecOtherCiPLockRouteId(const UINT16 wPhySectionId) +{ + UINT16 wRetVal = 0U; + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetPhySecConfigBufIndex(wPhySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > wBufIndex) + { + wRetVal = PhysicalSectionDataStru[wBufIndex].OtherCiPLockBelongRouteId; /*CI·ID*/ + } + else + { + /*ηǷ*/ + } + + return wRetVal; +} + +/* +* ȡָIDη·ͱ־ +* ˵const UINT16 wPhySecId ID +* ֵ CI_ERROR 0 +* CI_SUCCESS 1 +* Created By LQ 2024.06.11 +*/ +UINT8 GetPhySecPLockRouteCmdSendFlag(const UINT16 wPhySecId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 bufIndex = 0U; + UINT8 cLocalCiId = 0U; + UINT8 cSecBelongCiId = 0U; /*CI*/ + UINT8 cSecLockState = PHYSICAL_SECTION_LOCK_NO; /*״̬*/ + UINT16 wSecRLockBelongRouteId = 0U; /*ν··*/ + UINT16 wSecPLockBelongRouteId = 0U; /*η·*/ + UINT8 cRRouteBelongCiId = 0u; /*··CI*/ + UINT8 cPRouteBelongCiId = 0u; /*·CI*/ + UINT16 wOtherCiPLockRouteId = 0U; /*CI͵η·ID*/ + + bufIndex = GetPhySecConfigBufIndex(wPhySecId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + /******** 1.жǷΪ ********/ + cLocalCiId = GetSystemParaLocalCiId(); + cSecBelongCiId = GetPhySecBelongCiId(wPhySecId); + + if ((0U != cLocalCiId) && (cLocalCiId == cSecBelongCiId)) + { + /******** 2.жǷΪջʱ ********/ + cSecLockState = GetPhySecLockState(wPhySecId); + + if ((PHYSICAL_SECTION_LOCK_NORMAL == cSecLockState) || (PHYSICAL_SECTION_LOCK_DELAY == cSecLockState)) + { + /********* 3.жǷ··DZң·ҲDZ޷· ********/ + wSecRLockBelongRouteId = GetPhySecRLockBelongRouteId(wPhySecId); /*ȡ··*/ + cRRouteBelongCiId = GetRouteBelongCiId(wSecRLockBelongRouteId); + wSecPLockBelongRouteId = GetPhySecPLockBelongRouteId(wPhySecId); /*ȡ·*/ + cPRouteBelongCiId = GetRouteBelongCiId(wSecPLockBelongRouteId); + + if ((cLocalCiId != cRRouteBelongCiId) && (0U != cRRouteBelongCiId) && ((cRRouteBelongCiId == cPRouteBelongCiId) || (0U == cPRouteBelongCiId))) + { + /********* 4.жǷ񱾿η···η·ͬ ********/ + wOtherCiPLockRouteId = GetPhySecOtherCiPLockRouteId(wPhySecId); + if (wOtherCiPLockRouteId != wSecPLockBelongRouteId) + { + cRetVal = CI_SUCCESS; /*η···η·ͬ1*/ + } + else + { + /*·ͬ*/ + } + } + else + { + /*··㣬*/ + } + } + else + { + /*״̬㣬*/ + } + } + else + { + /*DZΣ*/ + } + } + else + { + cRetVal = CI_ERROR; /*IDǷ0*/ + } + + return cRetVal; +} + +/* +* ȡָIDABLгռ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* 0xaa ABLռ 0x55 ABL +* Created By fan 2024.08.15 +*/ +UINT8 GetPhySecABLTrainFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].chABLTrainFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID֮ǰABLгռñ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* 0xaa ABLռ 0x55 ABL +* Created By fan 2024.08.15 +*/ +UINT8 GetPhySecPreABLTrainFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].chPreABLTrainFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDABLгռñ־ +* ˵ const UINT16 phySectionId, ID ablTrainFlag Ƿг 0xaa 0x55 0Ĭ +* ֵ +* Created By fan 2024.08.15 +*/ +void SetPhySecABLTrainFlag(const UINT16 phySectionId,UINT8 ablTrainFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 checkFlag = CI_SUCCESS; + UINT32 dwCurCyc = Get2oo2CurCycleNum(); + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + if ((PHYSICAL_SECTION_ABLOCCUPY_YES == ablTrainFlag) || (PHYSICAL_SECTION_ABLOCCUPY_NO == ablTrainFlag) + || (PHYSICAL_SECTION_ABLOCCUPY_DEFAULT == ablTrainFlag)) + { + if ((dwCurCyc == PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc) && + (PHYSICAL_SECTION_ABLOCCUPY_YES == PhysicalSectionDataStru[bufIndex].chABLTrainFlag)) + { + ; /*ڵǰѾùABL зABL*/ + } + else if ((dwCurCyc == PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc) && + ((PHYSICAL_SECTION_ABLOCCUPY_YES == ablTrainFlag) || (PHYSICAL_SECTION_ABLOCCUPY_NO == ablTrainFlag))) + { + /*ڵǰѾù־ ¼*/ + PhysicalSectionDataStru[bufIndex].chABLTrainFlag = ablTrainFlag; + } + else if ((dwCurCyc == PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc)&& (PHYSICAL_SECTION_ABLOCCUPY_DEFAULT == ablTrainFlag)) + { + ; /*Ѹ¹ΪĬϼ*/ + } + else if (dwCurCyc != PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc) + { + /*ڵһθ ֮ǰ־ */ + PhysicalSectionDataStru[bufIndex].chPreABLTrainFlag = PhysicalSectionDataStru[bufIndex].chABLTrainFlag; + PhysicalSectionDataStru[bufIndex].dwAblTagSetCyc = dwCurCyc; + PhysicalSectionDataStru[bufIndex].chABLTrainFlag = ablTrainFlag; + } + else + { + ; /**/ + } + } + else + { + /**/ + } + } + else + { + /**/ + } +} +/* +* ȡָIDλռñ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0x55 δûռ 0xaa ռ +* Created By fan 2024.08.19 +*/ +UINT8 GetPhySecUTTrainFlag(const UINT16 phySectionId) +{ + + UINT8 retVal = PHYSICAL_AXIS_UT_YES; + UINT8 jj = 0U; + UINT8 phySecContainAxisSecSum; /*ι*/ + UINT16* phySecContainAxisSecIdBuf = NULL; /*ι*/ + UINT32 dwAxisUtOccupyCyc = 0U; /*λռ*/ + UINT32 dwCurCyc = Get2oo2CurCycleNum(); /*ǰں*/ + /*λռ򷵻ػ*/ + phySecContainAxisSecSum = GetPAxisSectionSum(phySectionId); + phySecContainAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId); + if ((0u == phySecContainAxisSecSum)|| (NULL == phySecContainAxisSecIdBuf)) + { + retVal = PHYSICAL_AXIS_UT_YES; + } + else + { + retVal = PHYSICAL_AXIS_UT_NO; + for (jj = 0u; jj < phySecContainAxisSecSum; jj++) + { + dwAxisUtOccupyCyc = GetAxisRecentUtOccupyCyc(phySecContainAxisSecIdBuf[jj]); + if ((dwAxisUtOccupyCyc == dwCurCyc)||(UINT32_MAX ==dwAxisUtOccupyCyc)) + { + /*ǰмл ȡʧ ֹ*/ + retVal = PHYSICAL_AXIS_UT_YES; + break; + } + } + } + return retVal; +} + +/* +* ָIDڼλռ +* ˵ const UINT16 phySectionId, ID, ռñ־ +* ֵ +* Created By fan 2024.08.19 +*/ +void SetPhySecUTTrainFlag(const UINT16 phySectionId, UINT8 ablTrainFlag) +{ + UINT8 phySecContainAxisSecSum; /*ι*/ + UINT16* phySecContainAxisSecIdBuf = NULL; /*ι*/ + UINT8 jj = 0U; + UINT32 dwCurCyc = Get2oo2CurCycleNum(); /*ǰں*/ + if (PHYSICAL_AXIS_UT_YES == ablTrainFlag) + { + phySecContainAxisSecSum = GetPAxisSectionSum(phySectionId); + phySecContainAxisSecIdBuf = GetPAxisSectionIdBuf(phySectionId); + if ((0u != phySecContainAxisSecSum) && (NULL != phySecContainAxisSecIdBuf)) + { + for (jj = 0u; jj < phySecContainAxisSecSum; jj++) + { + SetAxisRecentUtOccupyCyc(phySecContainAxisSecIdBuf[jj], dwCurCyc); + } + } + else + { + ; /*ȡʧ*/ + } + } + else + { + ; /*¸ռ*/ + } +} + +/* +* ȡָIDʪ־ +* ˵const UINT16 phySectionId, ID +* ֵ0x55 Ч +* 0xAA Ч +* Created By LQ 2024.09.20 +*/ +UINT8 GetPhySecInHumidRailFlag(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = PHYSEC_IN_HUMID_RAIL_YES; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].cPhySecInHumidRailFlag; + } + else + { + /**/ + } + + return retVal; +} + +/* +* ָIDʪ־ +* ˵const UINT16 phySectionId, ID +* const UINT8 cInHumidRailFlag ʪ־ +* ֵ +* Created By LQ 2024.09.20 +*/ +void SetPhySecInHumidRailFlag(const UINT16 phySectionId, const UINT8 cInHumidRailFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + if ((PHYSEC_IN_HUMID_RAIL_YES == cInHumidRailFlag) || (PHYSEC_IN_HUMID_RAIL_NO == cInHumidRailFlag)) + { + PhysicalSectionDataStru[bufIndex].cPhySecInHumidRailFlag = cInHumidRailFlag; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ʪʪ־ +* ˵const UINT32 dwAreaHumidRailId ʪID +* ֵ +* Created By LQ 2024.09.20 +*/ +void SetPlatFormRelPSHumidRailFlag(const UINT32 dwAreaHumidRailId) +{ + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT8 cPlatFormRelSpksNum = 0U; /*վ̨SPKS*/ + UINT16 szPlatFormRelSpksId[PLATFORM_REL_SPKS_NUM_MAX] = { 0U }; /*վ̨SPKS ID*/ + UINT16 wCurPhySecNum = 0U; + UINT16 wPhySecId = 0U; + UINT16 wSpksIndex = 0U; + UINT16 wSpksRelPhySecNum = 0U; /*SPKS*/ + UINT16 wSpksRelPhySecId = 0U; /*SPKSID*/ + UINT8 cPhySecBelongCiId = 0U; /*SPKSε*/ + UINT8 cLocalCiId = 0U; /*CI ID*/ + + if (0U != dwAreaHumidRailId) + { + cLocalCiId = GetSystemParaLocalCiId(); + cPlatFormRelSpksNum = GetPlatFormRelSpksNum((UINT16)dwAreaHumidRailId, szPlatFormRelSpksId); /*ȡվ̨SPKS*/ + + if (CI_ERROR != cPlatFormRelSpksNum) + { + /*վ̨SPKSSPKSıʪ־Ч*/ + for (ii = 0U; ii < cPlatFormRelSpksNum; ii++) + { + wSpksIndex = GetSpksConfigBufIndex(szPlatFormRelSpksId[ii]); + wSpksRelPhySecNum = GetSpksPhySecSumByIndex(wSpksIndex); + + for (jj = 0U; jj < wSpksRelPhySecNum; jj++) + { + wSpksRelPhySecId = GetSpksPhySecId(szPlatFormRelSpksId[ii], jj); + cPhySecBelongCiId = GetPhySecBelongCiId(wSpksRelPhySecId); + + if ((cLocalCiId == cPhySecBelongCiId) && (0U != cLocalCiId)) + { + SetPhySecInHumidRailFlag(wSpksRelPhySecId, PHYSEC_IN_HUMID_RAIL_YES); /*δʪ*/ + } + else + { + /**/ + } + } + } + } + else + { + /*ȡվ̨SPKSʧܣʪЧ*/ + wCurPhySecNum = GetPhySecCurSum(); + for (jj = 0U; jj < wCurPhySecNum; jj++) + { + wPhySecId = GetPhySecId(jj); + SetPhySecInHumidRailFlag(wPhySecId, PHYSEC_IN_HUMID_RAIL_YES); + } + } + } + else + { + /**/ + } +} + +/* +* ȡָIDιǷ߱ARB״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ PHY_SECTION_ARB_NO: δARB +* PHY_SECTION_ARB_YES: ARB +* by cgh 20241030 +*/ +UINT8 GetPhySecRelLogSecExistArb(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = PHY_SECTION_ARB_NO; + UINT8 ii = 0U; + UINT8 chPhySecInLogSecSum = 0U;/*ΰ߼Ŀ*/ + UINT16* szPhySecInLogSecBuf = NULL;/*ΰ߼*/ + UINT8 chLogSecArbState = 0U;/*߼ARB״̬*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (PHYSICAL_SECTION_SUM_MAX > bufIndex) + { + chPhySecInLogSecSum = GetPhySecIncLogSecSum(phySectionId); + szPhySecInLogSecBuf = GetPhySecIncLogSecIdBuf(phySectionId); + + if (NULL != szPhySecInLogSecBuf) + { + for (ii = 0U; ii < chPhySecInLogSecSum; ii++) + { + chLogSecArbState = GetLgcArbState(szPhySecInLogSecBuf[ii]); + if (LGC_SECTION_ARB_YES == chLogSecArbState) + { + retVal = PHY_SECTION_ARB_YES; + break; + } + else + { + ; /**/ + } + } + } + else + { + ; /*ǷطARB*/ + } + } + else + { + ; /*ǷطARB*/ + } + return retVal; +} + +/* +* ȡָIDβɼռʼ +* ˵const UINT16 phySectionId, ID +* ֵβɼռʼ +*/ +UINT32 GetSecColOccupyStartCycNum(const UINT16 phySectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + retVal = PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDβɼռʼ +* ˵const UINT16 phySectionId, ID +* const UINT8 startCycNum ɼռʼ +* ֵ +*/ +void SetSecColOccupyStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetPhySecConfigBufIndex(phySectionId); /*ȡ±*/ + + if (bufIndex < PHYSICAL_SECTION_SUM_MAX) + { + PhysicalSectionDataStru[bufIndex].SecColOccupyStartCycNum = startCycNum; + } + else + { + /**/ + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Section/PhysicalSectionDataManage.h b/TSCP/src/APP/ciapp/Section/PhysicalSectionDataManage.h new file mode 100644 index 0000000..9ed0d12 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/PhysicalSectionDataManage.h @@ -0,0 +1,1020 @@ +/******************************************************** +* +* PhysicalSectionDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _PHYSICAL_SECTION_DATA_MANAGE_H_ +#define _PHYSICAL_SECTION_DATA_MANAGE_H_ + + +#include "SectionDefine.h" +#include "PhysicalSectionConfigDataManage.h" +#include "AxisSectionConfigDataManage.h" +#include "LogicSectionConfigDataManage.h" +#include "CommonTypes.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../System/CiSystemDefine.h" +#include "../LogRecord/LogRecord.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ݽṹ*/ +typedef struct S_PhysicalSectionDataStruct +{ + UINT16 PhysicalSectionId; /*ID (ʼֶ)*/ + UINT8 SecUseState; /*״̬(δ/) (ֶ̬)*/ + UINT16 SecUseBelongRouteId; /*ν··ID (ֶ̬)*/ + UINT16 SecProUseBelongRouteId; /*η·ID (ֶ̬)ͬһν·úͷõĽ·id*/ + + UINT16 SecUseBelongLogRouteId; /*ν·߼·ID (ֶ̬)*/ + UINT8 LockState; /*״̬ (ֶ̬)*/ + UINT8 FLockState; /*η״̬ (ֶ̬)*/ + UINT16 RLockBelongRouteId; /*ν··ID (ֶ̬)*/ + UINT16 PLockBelongRouteId; /*η·ID (ֶ̬)*/ + UINT16 OtherCiPLockBelongRouteId; /*͵η·ID (ֶ̬)*/ + UINT8 LockDirection; /*շ (ֶ̬)*/ + UINT8 PreOccupyState; /*֮ǰɼ״̬(/ռ) (ֶ̬)*/ + UINT8 CurOccupyState; /*ǰɼ״̬(/ռ) (ֶ̬)*/ + UINT8 PreMergeOccupyState; /*֮ǰںϺ״̬(/ռ) (ֶ̬)*/ + UINT8 CurMergeOccupyState; /*ǰںϺ״̬(/ռ) (ֶ̬)*/ + UINT8 PreAndMergeOccupyState; /*֮ǰռԭںϺ״̬(/ռ) (ֶ̬)*/ + UINT8 CurAndMergeOccupyState; /*ǰռԭںϺ״̬(/ռ) (ֶ̬)*/ + + /*μׯվȫҪʹ OCռ״̬뵱ǰռ״̬ں*/ + UINT8 PreOcGdOccupyState; /*֮ǰocռ״̬(ֶ̬)*/ + UINT8 CurOcGdOccupyState; /*ǰocռ״̬(ֶ̬)*/ + UINT8 PreAxleGdOccupyState; /*֮ǰռ״̬(ֶ̬)*/ + UINT8 CurAxleGdOccupyState; /*ǰռ״̬(ֶ̬)*/ + + UINT8 ArbState; /*ARB״̬ (ֶ̬)*/ + UINT8 StopSteadyFlag; /*ͣϢ(δͣ/ͣ) (ֶ̬)*/ + UINT32 SecColOccupyStartCycNum; /*βɼռʼ (ֶ̬)*/ + UINT32 SecCurOccupyStartCycNum; /*εǰռÿʼ (ֶ̬)*/ + UINT32 SecOccuToClearStartCycNum; /*ռñпʼ (ֶ̬)*/ + UINT32 AutoUnlockStartCycNum; /*Զʱʼ (ֶ̬)*/ + UINT32 FaultUnlockStartCycNum; /*ʽʱʼ (ֶ̬)*/ + UINT8 SectionResetType; /*μḴλ*/ + UINT32 SectionResetStartCycNum; /*μḴλʼ (ֶ̬)*/ + UINT8 ProtectSecLockDelayTimeFlag;/*ʱ־(ֶ̬)*/ + UINT8 StopCheckFlag; /*ֹͣ־(δ/) (ֶ̬)*/ + UINT8 JumpLockState; /*Ծ״̬ (ֶ̬)*/ + UINT8 PhySecPreResetState; /*Ԥλ״̬ (ֶ̬)*/ + UINT32 SecJumpDelayUnlockStartCycNum; /*Ծʱʼ (ֶ̬)*/ + UINT8 JumpLockDelayUnlockFlag; /*Ծʱñ־ֶ̬Σ*/ + UINT32 LockDelayStartCycNum; /* ʱʼں(ֶ̬) */ + UINT8 FLockType;/*ηԭ򣬿SPKS£Ҳֵطε¡ҪSPKSָؿź߼*/ + UINT8 UtOrCtOccFlag; /*ڽʱ¼һڽ·һγռ*/ + UINT32 UtOrCtOccuStartCycNum; /*εǰռÿʼ (ֶ̬)ռͱ仯ʱ¸ֵ*/ + UINT8 JumpLockStateToZC;/*ZC͵Ծ״̬*/ + UINT16 wPhyErrUnlockTime;/*ʽʱʱ*/ + UINT8 cAreaUrgentBrakeState; /*ƶ״̬*/ + + UINT16 StopSteadyTrainId; /*ͣгID*/ + UINT8 chABLTrainFlag; /*ǷABLг־ 0xaaABLռ*/ + UINT8 chPreABLTrainFlag; /*һABLг־ 0xaaABLռ ÿڸ*/ + UINT32 dwAblTagSetCyc; /*ABL־*/ + UINT8 cPhySecInHumidRailFlag; /*ʪ־0x55 Ч0xAA Ч*/ +} PhysicalSectionDataStruct; + +extern PhysicalSectionDataStruct PhysicalSectionDataStru[PHYSICAL_SECTION_SUM_MAX]; /*ݽṹ*/ + +/* +* η״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ: 1:ɹ + 0:ʧ +*/ +UINT16 ClearPhySecPLock(const UINT16 phySectionId); + +/* +* ȡָID +* ˵ +* ֵ + PhysicalSectionDataStruct* +*/ +PhysicalSectionDataStruct* GetPhySecData(void); + +/* +* ȡָID״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPhySecUseState(const UINT16 phySectionId); + +/* +* ָID״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 useState, ״̬ +* const UINT16 routeId, ·ID +* ֵ void +*/ +void SetPhySecUseState(const UINT16 phySectionId, const UINT8 useState, const UINT16 routeId); + +/* +* @brief ָIDε߼״̬ +* @param const UINT16 phySectionId, ID +* const UINT8 useState, ״̬ +* const UINT16 routeId, ߼·ID +* @return +* @noteby cgh 20231010 +*/ +UINT8 SetPhySecUseStateByLogRoute(const UINT16 phySectionId, const UINT8 useState, const UINT16 logrouteId); + +/* +* ȡָID·ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetPhySecUseRouteId(const UINT16 phySectionId); + +/* +* ȡָID߼·ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetPhySecUseLogRouteId(const UINT16 phySectionId); + +/* +* ȡָID״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetPhySecLockState(const UINT16 phySectionId); + +/* +* ָID״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 lockState, ״̬ +* const UINT16 routeId, ·ID +* const UINT8 lockDirection, շ +* ֵ +* +*/ +void SetPhySecLockState(const UINT16 phySectionId, const UINT8 lockState, const UINT16 routeId, const UINT8 lockDirection); + +/* +* ȡָIDη״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetPhySecFLockState(const UINT16 phySectionId); + +/* +* ָIDη״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 fLockState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecFLockState(const UINT16 phySectionId, const UINT8 fLockState); + +/* +* ȡָIDշ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: շ +*/ +UINT8 GetPhySecLockDirection(const UINT16 phySectionId); + +/* +* ȡָIDν··ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ··ID +*/ +UINT16 GetPhySecRLockBelongRouteId(const UINT16 phySectionId); + +/* +* ָη·ID +* ˵const UINT16 wPhySectionId ID +* const UINT16 wPLockRouteId ·ID +* ֵ +* Created By LQ 2024.06.11 +*/ +void SetPhySecPLockRouteId(const UINT16 wPhySectionId, const UINT16 wPLockRouteId); + +/* +* ȡָIDη·ID +* ˵ const UINT16 phySectionId, ID +* ֵ ·ID +*/ +UINT16 GetPhySecPLockBelongRouteId(const UINT16 phySectionId); + +/* +* ȡָID֮ǰɼ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ֮ǰɼ״̬ +*/ +UINT8 GetPhySecPreOccupyState(const UINT16 phySectionId); + +/* +* ָID֮ǰɼ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 preCollState, ֮ǰɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecPreOccupyState(const UINT16 phySectionId, const UINT8 preCollState); + +/* +* ȡָIDεǰɼ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰɼ״̬ +*/ +UINT8 GetPhySecCurOccupyState(const UINT16 phySectionId); + +/* +* ָIDεǰɼ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curCollState, ǰɼ״̬ +* ֵ +* +*/ +void SetPhySecCurOccupyState(const UINT16 phySectionId, const UINT8 curCollState); + +/* +* ȡָID֮ǰں״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰں״̬ +*/ +UINT8 GetPhySecPreMergeState(const UINT16 phySectionId); + +/* +* ȡָIDεǰں״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰں״̬ +*/ +UINT8 GetPhySecCurMergeState(const UINT16 phySectionId); + +/* +* ȡָIDεǰռԭں״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰں״̬ +*/ +UINT8 GetPhySecCurAndMergeState(const UINT16 phySectionId); + +/* +* ָIDεǰں״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curProcState, ǰں״̬ +* ֵ +* +*/ +void SetPhySecCurMergeState(const UINT16 phySectionId, const UINT8 curProcState); + +/* +* ָIDεǰռԭں״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curProcState, ǰں״̬ +* ֵ +* +*/ +void SetPhySecCurAndMergeState(const UINT16 phySectionId, const UINT8 curProcState); + +/* +* ȡָIDͣ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ͣ״̬ +*/ +UINT8 GetPhySecStopSteadyFlag(const UINT16 phySectionId); + +/* +* ָIDͣ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 stopSteadyState, ͣ״̬ +* ֵ +* +*/ +void SetPhySecStopSteadyFlag(const UINT16 phySectionId, const UINT8 stopSteadyState); + +/* +* ȡָIDռóڼ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ռóڼ +*/ +UINT32 GetSecCurOccupyStartCycNum(const UINT16 phySectionId); + +/* +* ȡָIDռñгڼ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ռóڼ +*/ +UINT32 GetSecOccuToClearStartCycNum(const UINT16 phySectionId); + +/* +* ָIDռóڼ +* ˵ const UINT16 phySectionId, ID +* const UINT8 cycCount, ռóڼ +* ֵ +* +*/ +void SetSecCurOccupyStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum); + +/* +* ָIDռñгڼ +* ˵ const UINT16 phySectionId, ID +* const UINT8 cycCount, ռóڼ +* ֵ +* +*/ +void SetSecOccuToClearStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum); + +/* +* ȡָIDԶʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Զʼں +*/ +UINT32 GetPhySecAutoUnlockStartCycNum(const UINT16 phySectionId); + +/* +* ָIDԶʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Զʼں +* ֵ +* +*/ +void SetPhySecAutoUnlockStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum); + +/* +* ȡָIDʽʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Զʼں +*/ +UINT32 GetPhySecFaultUnlockStartCycNum(const UINT16 phySectionId); + +/* +* ָIDʽʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Զʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecFaultUnlockStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum); + +/* +* ״̬ЧԼ +* ˵ const UINT8 lockState, ״̬ +* ֵ 0: Ч +* 1: Ч +*/ +UINT8 PhySecLockStateValidCheck(const UINT8 lockState); + +/* +* ָID֮ǰں״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curProcState, ǰں״̬ +* ֵ +* +*/ +void CleanPhySecPreMergeState(const UINT16 phySectionId); + +/* +* ȡָIDμḴλʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ḵλʼں +*/ +UINT32 GetPhySecResetStartCycNum(const UINT16 phySectionId); + +/* +* ָIDμḴλʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Ḵλʼں +* ֵ +* +*/ +void SetPhySecResetStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum); + +UINT8 GetPhySecSectionResetType(const UINT16 phySectionId); + +void SetPhySecSectionResetType(const UINT16 phySectionId, const UINT8 resetType); + +/* +* ÷DZָID״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 lockState, ״̬ +* const UINT16 routeId, ·ID +* const UINT8 lockDirection, շ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecLockStateOtherCI(const UINT16 phySectionId, const UINT8 lockState, const UINT16 routeId, const UINT8 lockDirection); + + +/* +* ȡָIDʱձ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ḵλʼں +*/ +UINT8 GetProtectSecLockDelayTimeFlag(const UINT16 phySectionId); + +/* +* ָIDʱձ־ +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Ḵλʼں +* ֵ +* +*/ +void SetProtectSecLockDelayTimeFlag(const UINT16 phySectionId, const UINT8 delayTimeFlag); + +/* +* Ƚռʱ +* ˵ const UINT16 phySectionId, ID +* const UINT16 otherSectionId, һID +* ֵ 0: ʧ +* 1: ɹ +*/ +UINT8 CompareOccuTime(const UINT16 sectionId, const UINT16 otherSectionId); + +/* +* ȡָIDArb״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Arb״̬ +*/ +UINT8 GetPhySecArbState(const UINT16 phySectionId); + +/* +* ָIDArb״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 arbState, Arb״̬ +* ֵ +* +*/ +void SetPhySecArbState(const UINT16 phySectionId, const UINT8 arbState); + +/* +* ȡָIDֹͣ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ֹͣ״̬ +*/ +UINT8 GetPhySectionStopCheckFlag(const UINT16 phySectionId); + + +/* +* ָIDֹͣ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 stopCheckState, ֹͣ״̬ +* ֵ +* +*/ +void SetPhySectionStopCheckFlag(const UINT16 phySectionId, const UINT8 stopCheckState); + +/* +* ȡָIDԾ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ״̬ +*/ +UINT8 GetPhySecJumpLockState(const UINT16 phySectionId); + +/* +* ָIDԾ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void SetPhySecJumpLockState(const UINT16 phySectionId, const UINT8 jumpLockState); + +/* +* ȡָIDԾʱʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ծʱʼں +*/ +UINT32 GetPhySecJumpDelayUnlocStartCyc(const UINT16 phySectionId); + +/* +* ָIDԾʱʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, Ծʱʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecJumpDelayUnlocStartCyc(const UINT16 phySectionId, const UINT32 startCycNum); + +/* +* ȡָIDԾʱñ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ծʱñ־ +*/ +UINT8 GetPhySecJumpDelayUnlockFlag(const UINT16 phySectionId); + +/* +* ָIDԾʱñ־ +* ˵ const UINT16 phySectionId, ID +* const UINT8 jumpDelayUnlockFlag, Ծʱñ־ +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetPhySecJumpDelayUnlockFlag(const UINT16 phySectionId, const UINT8 jumpDelayUnlockFlag); +/* +* ָID֮ǰں״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curProcState, ֮ǰں״̬ +* ֵ +* +*/ +void SetPhySecPreMergeState(const UINT16 phySectionId, const UINT8 preProcState); +/* +* ȡη״̬־ +* ˵UINT16 phySecId Id +* ֵ δ: SPKS_STATUS_NO +* : SPKS_STATUS_YES +*/ +UINT8 GetPhySecFlockFlag(UINT16 phySecId); + + +/* +* ȡָIDʱʼں +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ʱʼں +*/ +UINT32 GetPhySecLockDelayStartCycNum(const UINT16 phySectionId); + +/* +* ָIDʱʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, ʱʼں +* ֵ +* +*/ +void SetPhySecLockDelayStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum); + +/* +* εͣϢΪδͣ +* ˵ void +* ֵ void +*/ +void ResetPhySecStopSteadyInfo(void); + +/* +* ûͨ״̬ +* ˵ +UINT16 phySectionId, ID +const UINT8 lockState,״̬ +* ֵ + +*/ +void SetPhySecLockStateHlht(UINT16 phySectionId, const UINT8 lockState); +/* +* ûͨν·Ľ·ID +* ˵ +UINT16 phySectionId, ID +const UINT16 routeId,ν··ID +* ֵ + +*/ +void SetPhySecRLockRouteIdHlht(UINT16 phySectionId, const UINT16 routeId); +/* +* ûͨαĽ·ID +* ˵ +UINT16 phySectionId, ID +const UINT16 routeId,αĽ·ID +* ֵ + +*/ +void SetPhySecPLockRouteIdHlht(UINT16 phySectionId, const UINT16 routeId); + +/* +* ûͨεշ +* ˵ +UINT16 phySectionId, ID +const UINT8 lockDir,շ +* ֵ + +*/ +void SetPhySecLockDirHlht(UINT16 phySectionId, const UINT8 lockDir); + +/* +* η +* ˵ +UINT16 phySectionId, ID +const UINT8 fLockType,η +* ֵ + +*/ +void SetPhySecFLockType(const UINT16 phySectionId, const UINT8 fLockType); + +/* +* ȡη +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: η +*/ +UINT8 GetPhySecFLockType(const UINT16 phySectionId); + +/* +* ȡܸλ̵״̬Ч +* ˵ const UINT16 phySecId, ID +* ֵ CI_ERROR Ч + CI_SUCCESS Ч +*/ +UINT8 GetZFWValidByPhySecId(const UINT16 phySecId); + +/* +* ȡܸλ̵״̬Ч +* ˵ const UINT16 ciId, ciId +* ֵ UINT16 relayId, ܸλ̵ID +*/ +UINT16 GetZFWRelayId(const UINT16 ciId); +/* +* ȡܸλ̵״̬Ч +* ˵ const UINT16 ciId, ciId +* ֵ UINT16 relayId, ܸλ̵ID +*/ +UINT16 GetZFWRelayId_UseVirCI(const UINT16 ciId,UINT8 virCIid); + +/* +* ָIDUTCTռʼں +* ˵ const UINT16 phySectionId, ID +* const UINT32 startCycNum, ռʼں +* ֵ +* +*/ +void SetSecUtOrCtOccuStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum); + +/* +* ȡָIDUTCTռóڼ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ռóڼ +*/ +UINT32 GetSecUtOrCtOccuStartCycNum(const UINT16 phySectionId); + +/* +* ȡָIDεǰCTUTռ״̬ +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetPhySecCurCtOrUtOccupyState(const UINT16 phySecId); + +/* +* ȡָIDεǰͨųռ״̬ +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetPhySecCurTxOccupyState(const UINT16 phySecId); + +/* +* ȡָIDCTUTռ״̬ +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ǰռ״̬ +*/ +UINT8 GetPhySecPreOccState(const UINT16 phySecId); + +/* +* ָIDCTUTռ״̬ +* ˵ const UINT16 phySecId, ID + const UINT8 flag ֮ǰCTUTռ״̬ +* ֵ +* +*/ +void SetPhySecPreOccState(const UINT16 phySecId, const UINT8 flag); + +/* +* ָIDεǰԤλ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 preResetState, Ԥλ״̬ +* ֵ +* +*/ +void SetPhySecPreResetState(const UINT16 phySectionId, const UINT8 preResetState); + +/* +* ȡָIDμԤλ״̬ +* ˵ const UINT16 phySecId, ID +* ֵ 0: ȡʧ +* >0: ǰԤλ״̬ +*/ +UINT8 GetPhySecPreResetState(const UINT16 phySecId); + + +/* +* ȡָIDθZCԾ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: Ծ״̬ +*/ +UINT8 GetPhySecJumpLockStateToZC(const UINT16 phySectionId); + + +/* +* ָIDθZCԾ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* +*/ +void SetPhySecJumpLockStateToZC(const UINT16 phySectionId, const UINT8 jumpLockState); + + +/* +* ȡָIDεǰOcĹɼ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰɼ״̬ +*/ +UINT8 GetPhySecCurOcGdOccupyState(const UINT16 phySectionId); + +/* +* ָIDεǰOcɼ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curCollState, ǰɼ״̬ +* ֵ +* +*/ +void SetPhySecCurOcGdOccupyState(const UINT16 phySectionId, const UINT8 curCollState); + +/* +* ָIDεǰռòɼ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 curCollState, ǰɼ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetPhySecCurAxisGdOccupyState(const UINT16 phySectionId, const UINT8 curCollState); + +/* +* ȡָIDεǰιɼ״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ǰɼ״̬ +*/ +UINT8 GetPhySecCurAxisGdOccupyState(const UINT16 phySectionId); + +/* +* ָIDιARB״̬ +* ˵ UINT16 phySecId, ID +* UINT8 arbState, arb״̬ +* ֵ CI_ERROR: ʧ +* 1: óɹ +*/ +void SetPhyContainAxisSecArbState(UINT16 phySecId,UINT8 arbState); +/* +* ָIDη״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 useState, ״̬ +* const UINT16 routeId, ·ID +* ֵ void +*/ +void SetPhySecProtectUseState(const UINT16 phySectionId, const UINT8 useState, const UINT16 routeId); +/* +* ȡָIDη·ID +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* >0: ·ID +*/ +UINT16 GetPhySecProtectUseRouteId(const UINT16 phySectionId); + +/** +* @brief ARBô +* @note ֮󣬵ô˺εARB״̬ +*/ +void SetPhySecArbStateProc(void); + +/* +* ȡָεļ +* ˵ const UINT16 wPhySecId, ID +* ֵ UINT16_MAX ʧ; ɹ +*/ +UINT16 GetAxisSecIdByPhySecIdAndSwSta(const UINT16 wPhySecId); + +/* +* ߼Ծ״̬Ծ״̬ +* ˵ const UINT16 logSectionId, ߼ID +* ֵ +*/ +void SetLogRelaPhySecJumpLockSta(const UINT16 logSectionId); +/* +* ǷָSPKS +* ˵ const UINT16 phySecId, ID + const UINT16 spksIdָSPKS ID +* ֵ 0: ʧ +* 1: ɹ +* cgh-ϲCID-2539-1 +*/ +UINT8 CheckPhySecFlockBlongSpks(const UINT16 phySecId, const UINT16 spksId); + +/* +* ָIDΰ߼Ծ״̬ +* ˵ const UINT16 phySectionId, ID +* const UINT8 jumpLockState, Ծ״̬ +* ֵ +* by-cgh-20230628-Ծ״̬ʱͬʱ߼Ծ״̬ +*/ +void SetPhyIncludeLogJumpLockState(const UINT16 phySectionId, const UINT8 jumpLockState); + +/* +* ʱʽʱ +* ˵ const UINT16 wPhySectionId, ID +* const UINT16 wPhyErrUnlockTime ʱʽʱ +* by cgh 20230630 ݵʱ +*/ +void SetPhyErrUnlockTime(const UINT16 wPhySectionId, const UINT16 wPhyErrUnlockTime); + +/* +* ʱʽʱ +* ˵ const UINT16 wLogSectionId, ID +* ֵʱʱ +* * by cgh 20230630 ݵʱ +*/ +UINT16 GetPhyErrUnlockTime(const UINT16 wPhySectionId); + +/* +* ָIDƶ״̬ +* ˵const UINT16 wPhySecId ID +* const UINT8 cAreaUrgentState ƶ״̬ +* ֵ +* Created By LQ 2023.11.09 +*/ +void SetPhySecAreaUrgentState(const UINT16 wPhySecId, const UINT8 cAreaUrgentState); + +/* +* ȡָIDƶ״̬ +* ˵const UINT16 wPhySecId ID +* ֵ 0 ȡʧ +* >0 ƶ״̬ +* Created By LQ 2023.11.09 +*/ +UINT8 GetPhySecAreaUrgentState(const UINT16 wPhySecId); + +/* +* ͣгID +* ˵ const UINT16 wPhySectionId, ID +* const UINT16 wPhyStopSteadyTrainId ͣгID +*/ +void SetPhyStopSteadyTrainId(const UINT16 wPhySectionId, const UINT16 wPhyStopSteadyTrainId); + +/* +* ͣгID +* ˵ const UINT16 wLogSectionId, ID +* ֵͣгID +*/ +UINT16 GetPhyStopSteadyTrainId(const UINT16 wPhySectionId); + +/* +* ȡָIDεСȡֵ +* ˵ const UINT16 wPhySectionId, ID +* ֵ UINT8_MAX: ȡʧ +* >0: ʱȡֵ +* BY CGH 20240429 +*/ +UINT8 GetPhySecMinXiansuSpeed(const UINT16 wPhySectionId); + +/* +* CI͵η·ID +* ˵const UINT16 wPhySectionId ID +* const UINT16 wPLockRouteId ·ID +* ֵ +* Created By LQ 2024.06.11 +*/ +void SetPhySecOtherCiPLockRouteId(const UINT16 wPhySectionId, const UINT16 wPLockRouteId); + +/* +* CI͵η·ID +* ˵const UINT16 wPhySectionId ID +* ֵCI͵η·ID +* Created By LQ 2024.06.11 +*/ +UINT16 GetPhySecOtherCiPLockRouteId(const UINT16 wPhySectionId); + +/* +* ȡָIDη·ͱ־ +* ˵const UINT16 wPhySecId ID +* ֵ CI_ERROR 0 +* CI_SUCCESS 1 +* Created By LQ 2024.06.11 +*/ +UINT8 GetPhySecPLockRouteCmdSendFlag(const UINT16 wPhySecId); + +/* +* ȡָIDABLгռ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* 0xaa ABLռ 0x55 ABL +* Created By fan 2024.08.15 +*/ +UINT8 GetPhySecABLTrainFlag(const UINT16 phySectionId); + +/* +* ȡָID֮ǰABLгռñ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0: ȡʧ +* 0xaa ABLռ 0x55 ABL +* Created By fan 2024.08.15 +*/ +UINT8 GetPhySecPreABLTrainFlag(const UINT16 phySectionId); + +/* +* ָIDABLгռò +* ˵ const UINT16 phySectionId, ID ablTrainFlag Ƿг 0xaa/0x55 +* ֵ +* Created By fan 2024.08.15 +*/ +void SetPhySecABLTrainFlag(const UINT16 phySectionId, UINT8 ablTrainFlag); +/* +* ȡָIDλռñ־ +* ˵ const UINT16 phySectionId, ID +* ֵ 0x55 δûռ 0xaa ռ +* Created By fan 2024.08.19 +*/ +UINT8 GetPhySecUTTrainFlag(const UINT16 phySectionId); + +/* +* ָIDڼλռ +* ˵ const UINT16 phySectionId, ID, ռñ־ +* ֵ +* Created By fan 2024.08.19 +*/ +void SetPhySecUTTrainFlag(const UINT16 phySectionId, UINT8 ablTrainFlag); + +/* +* ȡָIDʪ־ +* ˵const UINT16 phySectionId, ID +* ֵ0x55 Ч +* 0xAA Ч +* Created By LQ 2024.09.20 +*/ +UINT8 GetPhySecInHumidRailFlag(const UINT16 phySectionId); + +/* +* ָIDʪ־ +* ˵const UINT16 phySectionId, ID +* const UINT8 cInHumidRailFlag ʪ־ +* ֵ +* Created By LQ 2024.09.20 +*/ +void SetPhySecInHumidRailFlag(const UINT16 phySectionId, const UINT8 cInHumidRailFlag); + +/* +* ʪʪ־ +* ˵const UINT32 dwAreaHumidRailId ʪID +* ֵ +* Created By LQ 2024.09.20 +*/ +void SetPlatFormRelPSHumidRailFlag(const UINT32 dwAreaHumidRailId); + +/* +* ȡָIDιǷ߱ARB״̬ +* ˵ const UINT16 phySectionId, ID +* ֵ PHY_SECTION_ARB_NO: δARB +* PHY_SECTION_ARB_YES: ARB +* by cgh 20241030 +*/ +UINT8 GetPhySecRelLogSecExistArb(const UINT16 phySectionId); + +/* +* ȡָIDβɼռʼ +* ˵const UINT16 phySectionId, ID +* ֵβɼռʼ +*/ +UINT32 GetSecColOccupyStartCycNum(const UINT16 phySectionId); + +/* +* ָIDβɼռʼ +* ˵const UINT16 phySectionId, ID +* const UINT8 startCycNum ɼռʼ +* ֵ +*/ +void SetSecColOccupyStartCycNum(const UINT16 phySectionId, const UINT32 startCycNum); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Section/SectionDefine.h b/TSCP/src/APP/ciapp/Section/SectionDefine.h new file mode 100644 index 0000000..93f8746 --- /dev/null +++ b/TSCP/src/APP/ciapp/Section/SectionDefine.h @@ -0,0 +1,355 @@ +/******************************************************** +* +* SectionDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SECTION_CONFIG_H_ +#define _SECTION_CONFIG_H_ + +/**/ +#define PHYSICAL_SECTION_SUM_MAX ((UINT16)1000) /*ֵ*/ +#define AXIS_SECTION_SUM_MAX ((UINT16)1200) /*ֵ*/ +#define AXIS_INCLUDE_LOG_SUM_MAX ((UINT16)50) /*߼ֵ*/ +#define LOGIC_SECTION_SUM_MAX ((UINT16)1500) /*߼ֵ*/ +#define PHYSICAL_INCLUDE_AXIS_SUM_MAX ((UINT16)10) /*ΰֵ*/ +#define AXIS_INCLUDE_SWITCH_SUM_MAX ((UINT16)4) /*ΰĵֵ*/ +#define AXIS_INCLUDE_LINK_SUM_MAX ((UINT16)5) /*ΰLINKֵ*/ +#define LOGSEC_INCLUDE_LINK_SUM_MAX ((UINT16)8) /*߼ΰLINKֵ*/ +#define PHYSICAL_INCLUDE_SWITCH_SUM_MAX ((UINT16)10) /*ΰĵֵ*/ +#define SEC_INVASECT_N_CONDSWIT_SUM_MAX ((UINT16)12) /*ΰֵ*/ +#define LOGSEC_INV_N_CONDSWIT_SUM_MAX ((UINT16)8) /*߼ΰֵ*/ +#define LINK_SUM_MAX ((UINT16)1300) /*LINKֵ*//* add 2022.02.28 */ +#define LOGSEC_INCLUDE_AXIS_SUM_MAX ((UINT16)8) /*߼ΰļֵ*//* add 20220919 TIOC5.0*/ +#define LOGSEC_INCLUDE_SWITCH_SUM_MAX ((UINT16)4) /*߼ΰĵֵ*//* add 20220921 TIOC5.0*/ +#define LOGSEC_LTRL_DFNC_SUM_MAX ((UINT16)8) /*߼βֵ*//* add 20220921 TIOC5.0*/ +#define PHYSICAL_INCLUDE_LOG_SUM_MAX ((UINT16)200) /*ΰ߼ֵ*//* add 20220921 TIOC5.0*/ +#define LOGSEC_NEXT_LOGSEC_SUM_MAX ((UINT16)16) /*߼߼ֵ*//* add 20230408 cgh*/ +#define LOGSEC_RELATE_SIG_SUM_MAX ((UINT16)2) /*߼ιźŻֵ*//* add 20230504 cgh*/ +#define LOGSEC_RELATE_ROUTE_SUM_MAX ((UINT16)200) /*߼ι·ֵ*//* add 20230504 cgh*/ +#define LOGSEC_RELATE_PRO_SW_SUM_MAX ((UINT16)8) /*߼ιֵ*//* add 20230504 cgh*/ +#define LOGSEC_RELATE_CON_SW_SUM_MAX ((UINT16)4) /*߼ιߵֵ*//* add 20230504 cgh*/ +#define PHYSEC_RELATE_ROUTE_SUM_MAX ((UINT16)24) /*ι·ֵ*//* add 20231113 lq*/ +#define LOGSEC_RELATE_PSD_MAX ((UINT8)0X04U) /*߼ιֵ*//* add 20240410 fan*/ +#define LOGSEC_RELATE_ESB_MAX ((UINT8)0X04U) /*߼ιťֵ*//* add 20240410 fan*/ + +#define QINXIAN_SWITCH_MAX_NUM ((UINT8)0X16U) /*ι add 20240607 LC */ + +#define PHYSEC_ADJACENT_SEC_SUM_MAX ((UINT8)15) /*ֱ*//* add 20240821 fan*/ +#define PHYSEC_INDIRECTNEAR_SEC_SUM_MAX ((UINT8)100) /*һΧڼڽ*//* add 20240821 fan*/ + +/**/ +#define PHYSICAL_SEC_TYPE_NOSWITCH ((UINT8)0x55) /*޲*/ +#define PHYSICAL_SEC_TYPE_SWITCH ((UINT8)0xaa) /*в*/ + +/*мαʶ*/ +#define PHYSICAL_SECTION_LJK_NO ((UINT8)0x55) /*м*/ +#define PHYSICAL_SECTION_LJK_YES ((UINT8)0xaa) /*м*/ + +/*״̬*/ +#define PHYSICAL_SECTION_USING_NO ((UINT8)0x11) /*δ*/ +#define PHYSICAL_SECTION_USING_YES ((UINT8)0x22) /**/ +#define PHYSICAL_SECTION_USING_APPLY ((UINT8)0x44) /**/ +#define PHYSICAL_SECTION_USING_CANCEL ((UINT8)0x88) /*ȡ*/ + + +/*α߼״̬*/ +#define PHYSICAL_SECTION_USING_BYLOG_NO ((UINT8)0x55) /*δ*/ +#define PHYSICAL_SECTION_USING_BYLOG_YES ((UINT8)0xaa) /**/ + +/*״̬*/ +#define PHYSICAL_SECTION_LOCK_START ((UINT8)0x01) /*ϵ*/ +#define PHYSICAL_SECTION_LOCK_NO ((UINT8)0x02) /*δ*/ +#define PHYSICAL_SECTION_LOCK_NORMAL ((UINT8)0x04) /**/ +#define PHYSICAL_SECTION_LOCK_EXCEPT ((UINT8)0x08) /*쳣*/ +#define PHYSICAL_SECTION_LOCK_PROTECT ((UINT8)0x10) /**/ +#define PHYSICAL_SECTION_LOCK_DELAY ((UINT8)0x20) /*ʱ*/ +#define PHYSICAL_SECTION_LOCK_FAULTDELAY ((UINT8)0x30) /*ʽʱ*/ + +#define PHYSICAL_SECTION_JUMP_LOCK_NO ((UINT8)0x55) /*δԾ*/ +#define PHYSICAL_SECTION_JUMP_LOCK_YES ((UINT8)0xAA) /*Ծ*/ + +/*η״̬*/ +#define PHYSICAL_SECTION_FLOCK_NO ((UINT8)0x55) /*δ*/ +#define PHYSICAL_SECTION_FLOCK_YES ((UINT8)0xaa) /*η*/ + +/*ͣ״̬*/ +#define PHYSICAL_SECTION_STOPSTEADY_NO ((UINT8)0x55) /*δͣ*/ +#define PHYSICAL_SECTION_STOPSTEADY_YES ((UINT8)0xaa) /*ͣ*/ + +#if 0 +#define LOGICAL_SECTION_LOCK_DIR_UPLINK ((UINT8)0x55) /**/ +#define LOGICAL_SECTION_LOCK_DIR_DOWNLINK ((UINT8)0xaa) /**/ +#define LOGICAL_SECTION_LOCK_DIR_NO ((UINT8)0x00) /*շ*/ + +#define LOGICAL_SECTION_LOCK_NO ((UINT8)0x02) /*δ*/ +#define LOGICAL_SECTION_LOCK_NORMAL ((UINT8)0x04) /**/ +#define LOGICAL_SECTION_LOCK_EXCEPT ((UINT8)0x08) /*쳣*/ +#define LOGICAL_SECTION_LOCK_PROTECT ((UINT8)0x10) /**/ +#define LOGICAL_SECTION_LOCK_ILLEGAL ((UINT8)0x20) /*Ƿ*/ + +/*η״̬*/ +#define LOGICAL_SECTION_FLOCK_NO ((UINT8)0x55) /*δ*/ +#define LOGICAL_SECTION_FLOCK_YES ((UINT8)0xaa) /*η*/ +#define LOGICAL_SECTION_FLOCK_ILLEGAL ((UINT8)0xFF) /*η*/ +#endif + +/*ռ״̬*/ +#define SECTION_OCCUPY_NO ((UINT8)0x55) /*ο*/ +#define SECTION_OCCUPY_YES ((UINT8)0xaa) /*ռ*/ +#define SECTION_OCCUPY_FAULT ((UINT8)0x5a) /*״̬*/ + +/*ABLռñ־*/ +#define PHYSICAL_SECTION_ABLOCCUPY_NO ((UINT8)0x55) /*ABLռ*/ +#define PHYSICAL_SECTION_ABLOCCUPY_YES ((UINT8)0xaa) /*ABLռ*/ +#define PHYSICAL_SECTION_ABLOCCUPY_DEFAULT ((UINT8)0xff) /*Ĭϱ־λ*/ + +/*λռñ־*/ +#define PHYSICAL_AXIS_UT_NO ((UINT8)0x55) /*δûռ*/ +#define PHYSICAL_AXIS_UT_YES ((UINT8)0xaa) /*ռ*/ + +/*ARB״̬*/ +#define AXIS_SECTION_ARB_NO ((UINT8)0x55) /*δARB*/ +#define AXIS_SECTION_ARB_YES ((UINT8)0xaa) /*ARB*/ + + +/*ռ״̬*/ +#define AXIS_SECTION_OCCUPY_NO ((UINT8)0x55) /*δռ*/ +#define AXIS_SECTION_OCCUPY_YES ((UINT8)0xaa) /*ռ*/ + + + +/*߼ռ״̬*/ +#define LOGICSECTION_OCCUPY_UT ((UINT8)0xaa) /*ͨųռ*/ +#define LOGICSECTION_OCCUPY_CT ((UINT8)0xbb) /*ͨųռ*/ +#define LOGICSECTION_OCCUPY_NO ((UINT8)0x55) /*޳ռ*/ + +/*߼ͨųλõRMռ״̬*/ +#define LOGICSECTION_OCCUPY_TX (UINT8)0xaa /*ͨųռ*/ +#define LOGICSECTION_OCCUPY_NO_TX (UINT8)0x55 /*޳ͨųռ*/ + +/*ʱձ־*/ +#define PROTECTSECLOCKDELAY_NO ((UINT8)0x00) /*ʱ*/ +#define PROTECTSECLOCKDELAY_YES ((UINT8)0x01) /*ʱ*/ + + +/*߼ʱ״̬*/ +#define LOGSEC_LSXS_SET_STATE_NO ((UINT8)0x55) /*δʱ*/ +#define LOGSEC_LSXS_SET_STATE_YES ((UINT8)0xAA) /*ʱ*/ +#define LOGSEC_LSXS_SET_STATE_INVALID ((UINT8)0xFF) /*ʱЧ*/ + +/*ȫʱٱ־*/ +#define WHOLE_LINE_LINSHIXIANSUSET_NO ((UINT8)0x55) /*ȫʱ*/ +#define WHOLE_LINE_LINSHIXIANSUSET_YES ((UINT8)0xAA) /*ȫһ߼ʱ*/ + +/* spks */ +#define PHYSICAL_SECTION_SPKS_MAX_NUM ((UINT16)10) /* һζӦspks */ +#define LOGIC_SECTION_SPKS_MAX_NUM ((UINT16)10) /* һ߼ζӦspks */ + +#define PHY_SEC_REL_OUTSTATION_SIGNAL_MAX_NUM ((UINT16)5) /* һζӦվźŻ */ + +#define PHY_SEC_TRACK_SEC_MAX_SUM ((UINT16)20)/*ΰε*/ + +#define PHY_SEC_PRO_LOCK_ROUTE_MAX_NUM ((UINT16)30) /*αնӦĽ·*/ + +/*߼豸*/ +#define PHY_SEC_CONTACT_CHECK_MAX_NUM ((UINT8)2U) /*߼ι豸*/ + + +/*߼ռ״̬λ*/ +#define LOGIC_MASK_CT ((UINT8)0x02) /*ͨųռλ*/ +#define LOGIC_MASK_UT ((UINT8)0x01) /*ͨųռλ*/ +#define LOGIC_MASK_NO ((UINT8)0x00) /*޳ռλ*/ + +/*߼״̬*/ +#define LOG_SECTION_LOCK_NO ((UINT8)0x01) /*߼δ*/ +#define LOG_SECTION_LOCK_NORMAL ((UINT8)0x02) /*߼*/ +#define LOG_SECTION_LOCK_DELAY ((UINT8)0x03) /*߼ʱ*/ +#define LOG_SECTION_LOCK_EXCEPT ((UINT8)0x04) /*߼쳣*/ +#define LOG_SECTION_LOCK_START ((UINT8)0x05) /*߼ϵ*/ +#define LOG_SECTION_LOCK_PROTECT ((UINT8)0x06) /*߼η*/ + +#define LOG_SECTION_LOGLOCK_NO ((UINT8)0xA1) /*߼߼δ(߼·߼״̬)*/ +#define LOG_SECTION_LOGLOCK_NORMAL ((UINT8)0xA2) /*߼߼(߼·߼״̬)*/ +#define LOG_SECTION_LOGLOCK_EXCEPT ((UINT8)0xA3) /*߼߼쳣(߼·߼״̬)*/ + +/*ֹͣ־*/ +#define PHYSICAL_STOPCHECK_SET_NO ((UINT8)0x55) /*δ*/ +#define PHYSICAL_STOPCHECK_SET_YES ((UINT8)0xaa) /**/ + +/*Ծʱñ־*/ +#define PHYSICAL_JUMPUNLOCK_DELAY_SET_NO ((UINT8)0x55) /*δ*/ +#define PHYSICAL_JUMPUNLOCK_DELAY_SET_YES ((UINT8)0xaa) /**/ + +/*ηͺ궨*/ +#define PHY_SEC_FLOCK_TYPE_NONE ((UINT8)0x55) /*޷*/ +#define PHY_SEC_FLOCK_TYPE_SPKSCMD ((UINT8)0x10) /*SPKS ηη*/ +#define PHY_SEC_FLOCK_TYPE_SPKS ((UINT8)0xAA) /*SPKS δηη*/ +#define PHY_SEC_FLOCK_TYPE_CMD ((UINT8)0x20) /*SPKSδ ηη*/ + + +/*ǷZCϽ*/ +#define PHY_SEC_MANAGED_BY_ZC_YES ((UINT8)0x55) /*ZCϽ*/ +#define PHY_SEC_MANAGED_BY_ZC_NO ((UINT8)0xAA) /*βZCϽ*/ + + +/*Ԥλ״̬*/ +#define PHYSICAL_SECTION_PRE_RESET_YES ((UINT8)0x55) /*Ԥλ*/ +#define PHYSICAL_SECTION_PRE_RESET_NO ((UINT8)0xaa) /*δԤλ*/ + +#define AXIS_SECTION_JUMPLOCK_APPLY_NO ((UINT8)0x55) /*Ծ*/ +#define AXIS_SECTION_JUMPLOCK_APPLY_YES ((UINT8)0xAA) /*Ծ*/ + +#define AXSEC_CANCEL_JUMPLOCK_APPLY_NO ((UINT8)0x55) /*ȡԾ*/ +#define AXSEC_CANCEL_JUMPLOCK_APPLY_YES ((UINT8)0xAA) /*ȡԾ*/ + +#define AXIS_SECTION_JUMPLOCK_STATE_IDLE ((UINT8)1) /*Ծ״̬-*/ +#define AXIS_SECTION_JUMPLOCK_STATE_XUANPAI ((UINT8)2) /*Ծ״̬-ѡ*/ +#define AXIS_SECTION_JUMPLOCK_STATE_LOCK ((UINT8)3) /*Ծ״̬-*/ + +#define OC_GD_STATE_IDLE ((UINT8)0x55) /*OCγ*/ +#define OC_GD_STATE_OCCUPY ((UINT8)0xaa) /*OCռ*/ +#define OC_GD_STATE_FAULT ((UINT8)0x5a) /*OCι*/ + +#define HAVE_DIANSHILINSHIXIANSU ((UINT8)0x55) /*еʽʱ*/ +#define NON_DIANSHILINSHIXIANSU ((UINT8)0xaa) /*޵ʽʱ*/ + +#define HAVE_JZQ_LINSHIXIANSU ((UINT8)0x55) /*ZCͨжϺüʱ*/ +#define NON_JZQ_LINSHIXIANSU ((UINT8)0xaa) /*ZCͨжϺ󣬲üʱ*/ + +#define CHECK_SECFLOCK ((UINT8)0xaa) /*·η*/ +#define NON_CHECK_SECFLOCK ((UINT8)0x55) /*·η*/ + +#define LOGIC_SECTION_RES_SUM_MAX ((UINT8)10U) /*߼Դֵ*/ + +#define LOGIC_SECTION_RES_USABLE ((UINT8)0x55U) /*߼Դ*/ +#define LOGIC_SECTION_RES_UNUSABLE ((UINT8)0xAAU) /*߼Դ*/ + +#define LOGIC_SECTION_TRAIN_APPLY_YES ((UINT8)0x55U) /*߼г*/ +#define LOGIC_SECTION_TRAIN_APPLY_NO ((UINT8)0xAAU) /*߼гδ*/ + +#define LOGIC_SECTION_TRAIN_RETURN_YES ((UINT8)0x55U) /*߼г۷ʶ*/ +#define LOGIC_SECTION_TRAIN_RETURN_NO ((UINT8)0xAAU) /*߼ηг۷ʶ*/ + +#define LOGIC_SECTION_TRAIN_UNLOCK_YES ((UINT8)0x55U) /*߼Դг*/ +#define LOGIC_SECTION_TRAIN_UNLOCK_NO ((UINT8)0xAAU) /*߼Դгδ*/ + +#define LOGIC_SECTION_RES_SHARE_YES ((UINT8)0x55U) /*߼Դ־ɹ*/ +#define LOGIC_SECTION_RES_SHARE_NO ((UINT8)0xAAU) /*߼Դ־ɹ*/ + +#define LINK_LINE_SUM_MAX ((UINT8)100U) /* */ +#define AXIS_SEC_LINK_LINE_YES ((UINT8)0x55u) /* Ϊ */ +#define AXIS_SEC_LINK_LINE_NO ((UINT8)0xAAu) /* βΪ */ + +#define AXIS_SEC_ENTRANCE_YES ((UINT8)0x55u) /* Ϊڼ */ +#define AXIS_SEC_ENTRANCE_NO ((UINT8)0xAAu) /* βΪڼ */ + +#define AXIS_SEC_STORAGE_LINE_YES ((UINT8)0x55u) /* ξд泵 */ +#define AXIS_SEC_STORAGE_LINE_NO ((UINT8)0xAAu) /* βд泵 */ + +#define AXIS_SEC_LINXIAN_YES ((UINT8)0x55U) /*ξ(DZ·)*/ +#define AXIS_SEC_LINXIAN_NO ((UINT8)0xFFU) /*β(·)*/ + +#define AXIS_BORDER_AXLE_YES ((UINT8)0x55U) /*߽*/ +#define AXIS_BORDER_AXLE_NO ((UINT8)0xAAU) /*DZ߽*/ + +/* ʱϢ */ +#define TSR_SEC_MAX_SUM ((UINT8)50u) /* ٵĿ */ +#define TSR_MAX_SUM ((UINT8)20u) /* ʱٵ */ + +#if 0 +#define LOGIC_SECTION_JUMPLOCK_APPLY_NO ((UINT8)0x55) /*߼Ծ*/ +#define LOGIC_SECTION_JUMPLOCK_APPLY_YES ((UINT8)0xAA) /*߼Ծ*/ + +#define LOGSEC_JUMPLOCK_RELE_NO ((UINT8)0x55) /*߼Ծͷ*/ +#define LOGSEC_JUMPLOCK_RELE_YES ((UINT8)0xAA) /*߼Ծͷ*/ + +#define LOGIC_SECTION_JUMPLOCK_STATE_IDLE ((UINT8)1) /*߼Ծ״̬-*/ +#define LOGIC_SECTION_JUMPLOCK_STATE_XUANPAI ((UINT8)2) /*߼Ծ״̬-ѡ*/ +#define LOGIC_SECTION_JUMPLOCK_STATE_LOCK ((UINT8)3) /*߼Ծ״̬-*/ + +#endif + +#define LOGIC_SECTION_JUMP_LOCK_NO ((UINT8)0x55) /*߼Ծδ*/ +#define LOGIC_SECTION_JUMP_LOCK_YES ((UINT8)0xAA) /*߼Ծ*/ + +/*߼Ծʱñ־*/ +#define LOGIC_JUMPUNLOCK_DELAY_SET_NO ((UINT8)0x55) /*δ*/ +#define LOGIC_JUMPUNLOCK_DELAY_SET_YES ((UINT8)0xaa) /**/ + +/*߼Ծ־*/ +#define LOGIC_JUMPUNLOCK_PERMISSIVE_YES ((UINT8)0x55) /*Ծͨ*/ +#define LOGIC_JUMPUNLOCK_PERMISSIVE_NO ((UINT8)0xaa) /*ֹԾδͨ*/ + +#define LOGIC_ABLNEAR_USE_FLAG_YES ((UINT8)0x55) /*߼ABLӽο*/ +#define LOGIC_ABLNEAR_USE_FLAG_NO ((UINT8)0xaa) /*߼ABLӽβ*/ + + +#define LOGIC_XIANSU_REMOVE_YES ((UINT8)0x55) /*г*/ +#define LOGIC_XIANSU_REMOVE_NO ((UINT8)0xAA) /*δг*/ + +#define LINK_SW_TRACK_YES ((UINT8)0x55) /* linkΪ߻ѹ */ +#define LINK_SW_TRACK_NO ((UINT8)0xAA) /* linkΪ߻ѹ */ + +#define LINK_REVERT_AREA_YES ((UINT8)0x55) /* linkΪ۷ */ +#define LINK_REVERT_AREA_NO ((UINT8)0xAA) /* linkΪ۷ */ + +#define LINK_PLATFORM_YES ((UINT8)0x55) /* linkΪվ̨ */ +#define LINK_PLATFORM_NO ((UINT8)0xaa) /* linkΪվ̨ */ + +#define POINT_BELONG_LGC_MAX ((UINT8)0x05u) /* ߼ */ + +/*߼ARB״̬*/ +#define LGC_SECTION_ARB_NO ((UINT8)0x55) /*δARB*/ +#define LGC_SECTION_ARB_YES ((UINT8)0xaa) /*ARB*/ + +/*߼ηԴ*/ +#define LOGIC_SECTION_PRO_RES_USABLE ((UINT8)0x55U) /*߼ηԴ*/ +#define LOGIC_SECTION_PRO_RES_UNUSABLE ((UINT8)0xAAU) /*߼ηԴ*/ + +/*߼SPKS״̬*/ +#define LOGIC_SECTION_SPKS_FLOCK_NO ((UINT8)0x55) /*߼SPKS״̬δ*/ +#define LOGIC_SECTION_SPKS_FLOCK_YES ((UINT8)0xaa) /*߼SPKS״̬*/ + +/*߼״̬*/ +#define LOGIC_SECTION_USING_YSE ((UINT8)0x55) /*߼α߼·*/ +#define LOGIC_SECTION_USING_NO ((UINT8)0xaa) /*߼α߼·ȡ*/ + +/*ƶ״̬*/ +#define PHYSEC_AREA_URGENT_NO ((UINT8)0x55) /*ƶ״̬Ч*/ +#define PHYSEC_AREA_URGENT_YES ((UINT8)0xaa) /*ƶ״̬Ч*/ + +/*߼CBTC*/ +#define LOGSEC_CBTC_PROPERTY_YES ((UINT8)0x55) /*߼ξCBTCԣlinkCBTCԣ*/ +#define LOGSEC_CBTC_PROPERTY_NO ((UINT8)0xaa) /*߼βCBTCԣlinkCBTCԣ*/ + +/*߼ABLӽ־*/ +#define LOGSEC_LEAVE_LOGSEC_REPLY_YES ((UINT8)0xaa) /*ȥεABLгͨ*/ +#define LOGSEC_LEAVE_LOGSEC_REPLY_NO ((UINT8)0x55) /*ȥεABLг鲻ͨ*/ + +/*linkεAG/BG*/ +#define LINK_REL_PHYSEC_AG ((UINT8)0x55) /*linkΪAG*/ +#define LINK_REL_PHYSEC_BG ((UINT8)0xAA) /*linkΪBG*/ +#define LINK_REL_PHYSEC_DEFAULT ((UINT8)0xFF) /*linkηAGҷBG*/ + +/*LINKǷڹCG*/ +#define AGLINK_EXIST_REL_CG_YES ((UINT8)0x55) /*LinkڹCG*/ +#define AGLINK_EXIST_REL_CG_NO ((UINT8)0xAA) /*LinkڹCG*/ +#define AGLINK_EXIST_REL_CG_DEFAULT ((UINT8)0xFF) /*LinkҪCG*/ + +/*ʪ־*/ +#define PHYSEC_IN_HUMID_RAIL_NO ((UINT8)0x55) /*Ч*/ +#define PHYSEC_IN_HUMID_RAIL_YES ((UINT8)0xAA) /*Ч*/ + +/*ARB״̬*/ +#define PHY_SECTION_ARB_NO ((UINT8)0x55) /*δARB*/ +#define PHY_SECTION_ARB_YES ((UINT8)0xaa) /*ARB*/ + +#endif diff --git a/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess.c b/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess.c new file mode 100644 index 0000000..68313ac --- /dev/null +++ b/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess.c @@ -0,0 +1,1001 @@ +/****************************************************************************** +** ļ: SectionStateProcess.c +** : ״̬ģ飬ssp +*******************************************************************************/ + +#include "SectionStateProcess_define.h" +#include "../AxisSort/AxisSort_api.h" +#include "SectionStateProcess_api.h" +#include "AxisSectionConfigDataManage.h" +#include "EnvelopeManageAPI.h" +#include "ELMDataPrepare.h" +#include "LinkConfigDataManage.h" +#include "LogicSectionConfigDataManage.h" + + +/* ״̬ݽṹ */ +typedef struct +{ + UINT16 u16ID; /* ID */ + UINT8 u8Status; /* ״̬ STATUS_UT,STATUS_CT,STATUS_ARB,STATUS_FREE */ +}SSP_STATUS_s; + + +/* ߼״̬Ϣ */ +static UINT16 s_pSecNum = DEFAULT_ZERO; /* ߼ */ +static UINT16 s_pSecIndex[SIZE_MAX_SECTION + 1U]; /* ߼ */ +static SSP_STATUS_s s_pSecState[SIZE_MAX_SECTION + 1U]; /*߼״̬Ϣ*/ +static UINT8 outString_lgc[SIZE_MAX_SECTION * 2U] = { 0u }; /*߼ռ״̬-άݴӡݻ*/ + +/* ״̬Ϣ */ +static UINT16 s_pAxisNum = DEFAULT_ZERO; /* */ +static UINT16 s_pAxisIndex[SIZE_MAX_AC + 1U]; /* */ +static SSP_STATUS_s s_pAxisState[SIZE_MAX_AC + 1U]; /* ״̬Ϣ */ /*Ԥ*/ + +/**/ +static void FreeAll(void); +/*Ϊͨų߼CTռ*/ +static void CreateCT(void); +/*CTUTϣUT*/ +static void CreateUT(void); +/*U16ҸֵӦĽDZ*/ +static UINT8 u16Find(IN UINT8 u8Num, IN const UINT16 u16List[], IN UINT16 u16Val, OUT UINT8 *pu8Index); +/*ȡͨųCTռѹ߼(ȫ-ȫǰ)*/ +static UINT16 GetCTSecList(IN UINT16 u16TrainID, OUT UINT16 u16SecList[SIZE_MAX_SECTION_BT_TRAIN]); +/*ü߼ε״̬*/ +static void SetACSecState(UINT16 u16ACID, UINT8 u8State); +/*ܼUT߼*/ +static void MixACCreateUTSec(UINT16 u16ACID); +/*ȡг߼ID*/ +static UINT16 GetTrainOrgnSec(UINT16 u16TrainID); +/*ȡгյ߼ID*/ +static UINT16 GetTrainTmnlSec(UINT16 u16TrainID); +/*ӡ߼ռ״̬*/ +static void LogPrintf_LgcOccState(void); +/************´ⲿӿڻȡ**************/ +/*ȡָгȼ*/ +static UINT8 TrainDataMange_GetTrainLevel(UINT16 TrainID); +/*гյ(Ҷ)ɸѡǷЧ*/ +static UINT8 elm_IsTrainTmnlUT(UINT16 TrainID); +/*г()ɸѡǷЧ*/ +static UINT8 elm_IsTrainOrgnUT(UINT16 TrainID); +/***************************************************************************** +* @name ssp_Init +* @brief SSPģʼ +* @param[in] +* @return +* @note +*****************************************************************************/ +void ssp_Init(void) +{ + UINT16 u16ACID = DEFAULT_ZERO; /* ACID */ + UINT16 u16Index = DEFAULT_ZERO; /* ѭID */ + + /*- ʼ */ + (void)memset(s_pSecIndex, 0, sizeof(s_pSecIndex)); + (void)memset(s_pSecState, 0, sizeof(s_pSecState)); + + s_pSecNum = DEFAULT_ZERO; + + /* ߼״̬ʼ */ + for (u16Index = 1U; u16Index <= SIZE_MAX_SECTION; u16Index++) + { + /*߼IDǷܲѯӦļID*/ + u16ACID = GetLgcSecRelativeAxleSecSum(u16Index); + if (DEFAULT_ZERO != u16ACID) + { + if (s_pSecNum < SIZE_MAX_SECTION) + { + s_pSecNum++; + s_pSecIndex[u16Index] = s_pSecNum; + s_pSecState[s_pSecNum].u16ID = u16Index; + s_pSecState[s_pSecNum].u8Status = STATUS_UT; + } + else + { + debug_infor_printf((const)"FATAL:[SSP][ZC%d]߼"); + } + } + } + + s_pAxisNum = DEFAULT_ZERO; + /*- @alias ״̬ʼ */ + for (u16Index = 1U; u16Index <= SIZE_MAX_AC; u16Index++) + { + if (s_pAxisNum < SIZE_MAX_AC) + { + s_pAxisNum++; + s_pAxisIndex[u16Index] = s_pAxisNum; + s_pAxisState[s_pAxisNum].u16ID = u16Index; + s_pAxisState[s_pAxisNum].u8Status = STATUS_UT; + } + else + { + debug_infor_printf((const)"FATAL:[SSP]ڼ"); + } + } + +} + + +/***************************************************************************** +* @name ssp_MainProcess +* @brief SSPģ߼ +* @param[in] +* @return +* @note +*****************************************************************************/ +void ssp_MainProcess(void) +{ + /*״̬ */ + FreeAll(); + + /*ͨųCTռ */ + CreateCT(); + + /*UTռ */ + CreateUT(); + + /* ߼ռ״̬߼ģ */ + SetAllLgcOccupyState(); + + /*ӡ߼ռϢ*/ + LogPrintf_LgcOccState( ); +} +/***************************************************************************** +* @name GetCTSecList +* @brief ȡͨųCTռѹ߼(ȫ-ȫǰ) +* @param[in] u16TrainID гID +* @param[out] u16SecList ߼ +* @return ߼ +* @note ߼Ǵʼ˵ն˵ģ͵ӵͼһ¡ +* гɸѡЧ˵߼δ޳ +*****************************************************************************/ +static UINT16 GetCTSecList(IN UINT16 u16TrainID, OUT UINT16 u16SecList[SIZE_MAX_SECTION_BT_TRAIN]) +{ + UINT8 u8LocValid = DEFAULT_ZERO; /* λЧԱ־ */ + UINT8 u8OrgUT = DEFAULT_ZERO; /* ʼɸѡ״̬ */ + UINT8 u8TmmlUT = DEFAULT_ZERO; /* նɸѡ״̬ */ + UINT8 u8TrainDir = DEFAULT_ZERO; /* гз */ + UINT8 u8FirstSecIndex = DEFAULT_ZERO; /* ׸CTε */ + UINT16 u16SecNum = DEFAULT_ZERO; /* ߼ */ + UINT16 sTmpList[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /* ߼б */ + + struct_PathPoint start = { 0u }; + struct_PathPoint end = { 0u }; + UINT8 u8dirTemp = DEFAULT_ZERO; + UINT8 u8Ret = CI_ERROR; + + u8LocValid = TrainManage_GetTrainLocValid(u16TrainID); + + /*- гλǷЧ */ + if (FLAG_SET == u8LocValid) + { + u8TrainDir = GetTrainSafeTailDir(u16TrainID);/*ȫβ*/ + u8OrgUT = elm_IsTrainOrgnUT(u16TrainID); + u8TmmlUT = elm_IsTrainTmnlUT(u16TrainID); + + /*- гǷ߼ */ + if (EMAP_SAME_DIR == u8TrainDir) + { + (void)TrainManage_GetTrainSafeLoc(FINDHEADSAFEFLAG, u16TrainID, &end.wLinkId, &end.dwOffset, &u8dirTemp); + (void)TrainManage_GetTrainSafeLoc(FINDTAILSAFEFLAG, u16TrainID, &start.wLinkId, &start.dwOffset, &u8dirTemp); + } + /*- гǷ߼ */ + else if (EMAP_CONVER_DIR == u8TrainDir) + { + (void)TrainManage_GetTrainSafeLoc(FINDHEADSAFEFLAG, u16TrainID, &start.wLinkId, &start.dwOffset, &u8dirTemp); + (void)TrainManage_GetTrainSafeLoc(FINDTAILSAFEFLAG, u16TrainID, &end.wLinkId, &end.dwOffset, &u8dirTemp); + } + else + { + /*޲*/ + ; + } + + /*ȡռѹ߼УǴҵsTmpList[0]ʼڵ߼*/ + u8Ret = GetLogSecBtwTwoPoints(start, end, &u16SecNum, sTmpList); + if ((SIZE_MAX_SECTION_BT_TRAIN >= u16SecNum) && (CI_SUCCESS == u8Ret)) + { + (void)memmove(u16SecList, &sTmpList[u8FirstSecIndex], u16SecNum * sizeof(UINT16)); + } + else + { + ; + } + +#if 0 + /***********************޳ctɸѡЧڵ߼ΣĿǰctutϵʱct´*****************************************/ + /*- Ƿѯʧ */ + if (DEFAULT_ZERO == u16SecNum) + { + /*- ޴ */ + ; + } + /*- Ƿֻ1߼ */ + else if (1U == u16SecNum) + { + /* ֻ1߼ʱһɸѡ޳*/ + /*ɸѡǷЧ */ + if ((FLAG_SET == u8OrgUT) || (FLAG_SET == u8TmmlUT)) + { + /*- ûCT */ + u16SecNum = 0u; + } + } + else + { + /* 2߼ΣɸѡЧ˵߼޳(άUT) */ + /*- ʼɸѡǷЧ */ + if (FLAG_SET == u8OrgUT) + { + /*- ʼɸѡΪCT */ + u8FirstSecIndex++; + u16SecNum--; + } + + /*- նɸѡǷЧ */ + if (FLAG_SET == u8TmmlUT) + { + /*- βΪCT */ + u16SecNum--; + } + } + memmove(u16SecList, &sTmpList[u8FirstSecIndex], u16SecNum * sizeof(UINT16)); +#endif + } + else + { + ; + } + /*- ߼*/ + return u16SecNum; +} +/***************************************************************************** +* @name CreateUT +* @brief CTUTϣUT +* @param[in] +* @return +* @note +*****************************************************************************/ +static void CreateUT(void) +{ + UINT8 u8OccState = DEFAULT_ZERO; /* CIռ״̬ */ + UINT8 u8Index = DEFAULT_ZERO; /* ѭ */ + UINT8 u8TrainNum = DEFAULT_ZERO; /* г */ + UINT8 u8OrgUT = DEFAULT_ZERO; /* ǰɸѡ״̬ */ + UINT8 u8EndUT = DEFAULT_ZERO; /* ɸѡ״̬ */ + UINT8 u8UTTrainCnt = DEFAULT_ZERO; /* UT */ + UINT8 u8ATTrainCnt = DEFAULT_ZERO; /* AT */ + UINT16 u16AxisIndex = DEFAULT_ZERO; /* Ϣ */ + UINT16 u16TmpACID = DEFAULT_ZERO; /* ID */ + + EnvelopeStruct TrainEL[SIZE_MAX_TRAINOFAC] = { 0U }; /* га */ + + UINT8 u8ACState = DEFAULT_ZERO; /* ״̬ */ + + /*м */ + /*- 1 ; Ƿβ? ; */ + for (u16AxisIndex = 1U; u16AxisIndex <= s_pAxisNum; u16AxisIndex++) + { + /*- ȡϵг */ + u8TrainNum = elm_GetEnvelopeInAC(s_pAxisState[u16AxisIndex].u16ID, TrainEL); + u8ATTrainCnt = 0U; + u8UTTrainCnt = 0U; + /*г */ + if (SECTION_REL_ENVELOPE_SUM_MAX != u8TrainNum) + { + for (u8Index = DEFAULT_ZERO; u8Index < u8TrainNum; u8Index++) + { + if (TYPE_CT == TrainEL[u8Index].envelopeType) /*CTгſǰˣCTгTrainEL[u8Index].trainID[0]*/ + { + if (FLAG_SET == TrainManage_GetTrainLocValid(TrainEL[u8Index].trainID[0])) + { + /*- гλЧ */ + u8ATTrainCnt = u8ATTrainCnt + 1U; + /*ҵʼlinkļID*/ + u16TmpACID = GetLinkBelongAcId(TrainEL[u8Index].startPos.Lnk); + if (u16TmpACID == s_pAxisState[u16AxisIndex].u16ID) + { + u8OrgUT = elm_IsTrainOrgnUT(TrainEL[u8Index].trainID[0]); + } + else + { + u8OrgUT = FLAG_UNSET; + } + + /*ҵնlinkļID*/ + u16TmpACID = GetLinkBelongAcId(TrainEL[u8Index].endPos.Lnk); + if (u16TmpACID == s_pAxisState[u16AxisIndex].u16ID) + { + u8EndUT = elm_IsTrainTmnlUT(TrainEL[u8Index].trainID[0]); + } + else + { + u8EndUT = FLAG_UNSET; + } + /*- ǷǷͨųɸѡЧг */ + if ((FLAG_SET == u8EndUT) || (FLAG_SET == u8OrgUT)) + { + u8UTTrainCnt = u8UTTrainCnt + 1U;/*UT1 */ + } + else + { + ; + } + } + else + { + u8UTTrainCnt = u8UTTrainCnt + 1U;/*UT1 */ + } + + } + else + { + ; /* CTг */ + } + } + } + else + { + ; /*Ƿֵд*/ + } + /*- Ƿгȫɸѡͨų */ + if ((DEFAULT_ZERO < u8ATTrainCnt) && (DEFAULT_ZERO == u8UTTrainCnt)) + { + /*- ״̬ΪCT */ + s_pAxisState[u16AxisIndex].u8Status = STATUS_CT; + /* CTռѾǰͳһӹﲻٴ */ + } + /*- Ƿ */ + else if ((DEFAULT_ZERO < u8UTTrainCnt) && (DEFAULT_ZERO < u8ATTrainCnt)) + { + debug_infor_printf((const)"Axis ID:[%d] Is Filled With CT And UT Train\n", s_pAxisState[u16AxisIndex].u16ID); + /* ռҴɸѡг˵CTUTܵļ */ + /*- ״̬ΪUT */ + s_pAxisState[u16AxisIndex].u8Status = STATUS_UT; + /*- ϲUT߼ */ + MixACCreateUTSec(s_pAxisState[u16AxisIndex].u16ID); + } + else + { + u8OccState = elm_PrepareACStatus(s_pAxisState[u16AxisIndex].u16ID); + u8ACState = aam_GetACAssertStatus(s_pAxisState[u16AxisIndex].u16ID); + /*- CIǷռ */ + if (ELM_AC_OCC == u8OccState) + { + if ((0u == u8TrainNum) && + ((AAM_API_AC_ARB == u8ACState) || (AAM_API_AC_REDUNARB == u8ACState) || (AAM_API_AC_REDUNUT == u8ACState))) + { + /*arbarb࣬ut࣬߼οУ账*/ + } + else + { + SetACSecState(s_pAxisState[u16AxisIndex].u16ID, STATUS_UT); /*- ϵ߼UT*/ + s_pAxisState[u16AxisIndex].u8Status = STATUS_UT; /*¼ռ״̬ΪUTռ*/ + } + } + else + { + /*none*/ + } + } + } +} + +/***************************************************************************** +* @name FreeAll +* @brief й +* @param[in] +* @return +* @note +*****************************************************************************/ +static void FreeAll(void) +{ + UINT16 u16Index = DEFAULT_ZERO; /* ѭ */ + + /* ߼ΣΪ */ + for (u16Index = 1U; u16Index <= s_pSecNum; u16Index++) + { + /* ߼״̬Ϊ */ + s_pSecState[u16Index].u8Status = STATUS_FREE; + } + + /* мᣬΪ */ + for (u16Index = 1U; u16Index <= s_pAxisNum; u16Index++) + { + /* ü״̬Ϊ */ + s_pAxisState[u16Index].u8Status = STATUS_FREE; + } +} + +/***************************************************************************** +* @name CalcSecOrder +* @brief ߼λ +* @param[in] u16Sec1 ߼1 ID +* @param[in] u16Sec2 ߼2 ID +* @return Sec1ָSec2ķ +* EMAP_CONVER_DIR ӵͼ +* EMAP_SAME_DIR ӵͼ +* DEFAULT_ZERO λͬ +* 0xFF ʧ +* @note +*****************************************************************************/ +static UINT8 CalcSecOrder(UINT16 u16Sec1, UINT16 u16Sec2) +{ + UINT8 u8Rslt = INVALID_8; + + u8Rslt = dsuJudgeLogAandLogBPosition(u16Sec1, u16Sec2, EMAP_SAME_DIR); + /*- ж߼1߼2ǰ˳*/ + switch (u8Rslt) + { + case FLAG_SET: + u8Rslt = EMAP_CONVER_DIR; /*12*/ + break; + case FLAG_UNSET: + u8Rslt = EMAP_SAME_DIR; /*12*/ + break; + case CI_SUCCESS: + u8Rslt = DEFAULT_ZERO; /*ͬ*/ + break; + default: + u8Rslt = INVALID_8; + break; + } + return u8Rslt; + +} + +/***************************************************************************** +* @name MixACCreateUTSec +* @brief ܼUT߼ +* @param[in] u16ACID +* @return +* @note עֻCTеĻܼ +* CTĴUT᲻ô˺UT +*****************************************************************************/ +static void MixACCreateUTSec(UINT16 u16ACID) +{ + UINT8 u8Rslt = DEFAULT_ZERO; /* ʱ */ + INT8 u8SecIndex = 0; /* ߼ */ + UINT8 u8TrainIndex = DEFAULT_ZERO; /* ѭ */ + UINT8 u8TrainNum = DEFAULT_ZERO; /* г */ + UINT8 u8SecNum = DEFAULT_ZERO; /* ߼ */ + UINT16 u16SecID = DEFAULT_ZERO; /* ߼ID */ + + UINT16 u16TmpHeadACID = DEFAULT_ZERO; /* ͷID */ + UINT16 u16TmpTailACID = DEFAULT_ZERO; /* βID */ + UINT8 u8OrgUT = DEFAULT_ZERO; /* ǰɸѡ״̬ */ + UINT8 u8EndUT = DEFAULT_ZERO; /* ɸѡ״̬ */ + UINT8 u8TrainHeadDir = DEFAULT_ZERO; /*гͷ*/ + UINT8 u8TrainTailDir = DEFAULT_ZERO; /*гβ*/ + + UINT16* plogicSecIdBuf = NULL; /*Id*/ + + EnvelopeStruct TrainEnvelope[SIZE_MAX_TRAINOFAC] = { 0U }; /* га */ + + u8TrainNum = elm_GetEnvelopeInAC(u16ACID, TrainEnvelope); + + /*תΪ߼,ȡϵ߼б,߼бΪlink */ + u8SecNum = GetAxisSecLogSectionSum(u16ACID); + plogicSecIdBuf = GetAxisSecLogSectionIdBuf(u16ACID); + if (0u < u8SecNum) + { + /* г */ + for (u8TrainIndex = DEFAULT_ZERO; u8TrainIndex < u8TrainNum; u8TrainIndex++) + { + /*ҵʼlinkļID*/ + u16TmpTailACID = GetLinkBelongAcId(TrainEnvelope[u8TrainIndex].startPos.Lnk); + u8OrgUT = elm_IsTrainOrgnUT(TrainEnvelope[u8TrainIndex].trainID[0]); + if ((u16ACID == u16TmpTailACID) && (FLAG_SET == u8OrgUT)) + { + u16SecID = GetTrainOrgnSec(TrainEnvelope[u8TrainIndex].trainID[0]); + u8TrainTailDir = GetTrainSafeTailDir(TrainEnvelope[u8TrainIndex].trainID[0]); + u8TrainTailDir = ~u8TrainTailDir; + + if (EMAP_SAME_DIR == u8TrainTailDir) + { + u8Rslt = u16Find(u8SecNum, plogicSecIdBuf, u16SecID, &u8SecIndex); + if (CI_SUCCESS == u8Rslt) + { + /*Ҷڵ߼ƫһλΪҶ߼εɸѡ״̬ct*/ + u8SecIndex++; + } + else + { + u8SecIndex = (INT8)u8SecNum; + } + while ((UINT8)u8SecIndex < u8SecNum) /*(ɸѡЧڵ߼)*/ + { + /* ߼UTռ */ + if (STATUS_CT == s_pSecState[s_pSecIndex[s_pSecState[s_pSecIndex[plogicSecIdBuf[u8SecIndex]]].u16ID]].u8Status) + { + break; /*ͨųռѹٿͨųUTռѹ*/ + } + else + { + s_pSecState[s_pSecIndex[plogicSecIdBuf[u8SecIndex]]].u8Status = STATUS_UT; + debug_infor_printf((const)"CTɸѡЧ߼[%d]UTռ\n", s_pSecIndex[plogicSecIdBuf[u8SecIndex]]); + u8SecIndex++; + } + } + } + else + { + u8Rslt = u16Find(u8SecNum, plogicSecIdBuf, u16SecID, &u8SecIndex); + if (CI_SUCCESS == u8Rslt) + { + /*ڵ߼ƫһλΪ߼εɸѡ״̬ct*/ + u8SecIndex--; + } + else + { + u8SecIndex = -1; + } + while (0 <= u8SecIndex) /*(ɸѡЧڵ߼)*/ + { + /* ߼UTռ */ + if (STATUS_CT == s_pSecState[s_pSecIndex[s_pSecState[s_pSecIndex[plogicSecIdBuf[u8SecIndex]]].u16ID]].u8Status) + { + break; /*ͨųռѹٿͨųUTռѹ*/ + } + else + { + s_pSecState[s_pSecIndex[plogicSecIdBuf[u8SecIndex]]].u8Status = STATUS_UT; + debug_infor_printf((const)"CTɸѡЧ߼[%d]UTռ\n", s_pSecIndex[plogicSecIdBuf[u8SecIndex]]); + u8SecIndex--; + } + } + } + + } + else + { + + } + + u8SecIndex = 0; + /*ҵնlinkļID*/ + u16TmpHeadACID = GetLinkBelongAcId(TrainEnvelope[u8TrainIndex].endPos.Lnk); + u8EndUT = elm_IsTrainTmnlUT(TrainEnvelope[u8TrainIndex].trainID[0]); + if ((u16ACID == u16TmpHeadACID) && (FLAG_SET == u8EndUT)) + { + u16SecID = GetTrainTmnlSec(TrainEnvelope[u8TrainIndex].trainID[0]); + u8TrainHeadDir = GetTrainSafeHeadDir(TrainEnvelope[u8TrainIndex].trainID[0]); + + if (EMAP_SAME_DIR == u8TrainHeadDir) + { + u8Rslt = u16Find(u8SecNum, plogicSecIdBuf, u16SecID, &u8SecIndex); + if (CI_SUCCESS == u8Rslt) + { + /*Ҷڵ߼ƫһλΪҶ߼εɸѡ״̬ct*/ + u8SecIndex++; + } + else + { + u8SecIndex = (INT8)u8SecNum; + } + while ((UINT8)u8SecIndex < u8SecNum) /*(ɸѡЧڵ߼)*/ + { + /* ߼UTռ */ + if (STATUS_CT == s_pSecState[s_pSecIndex[s_pSecState[s_pSecIndex[plogicSecIdBuf[u8SecIndex]]].u16ID]].u8Status) + { + break; /*ͨųռѹٿͨųUTռѹ*/ + } + else + { + s_pSecState[s_pSecIndex[plogicSecIdBuf[u8SecIndex]]].u8Status = STATUS_UT; + debug_infor_printf((const)"CTɸѡЧ߼[%d]UTռ\n", s_pSecIndex[plogicSecIdBuf[u8SecIndex]]); + u8SecIndex++; + } + } + } + else + { + u8Rslt = u16Find(u8SecNum, plogicSecIdBuf, u16SecID, &u8SecIndex); + if (CI_SUCCESS == u8Rslt) + { + /*ڵ߼ƫһλΪ߼εɸѡ״̬ct*/ + u8SecIndex--; + } + else + { + u8SecIndex = -1; + } + while (0 <= u8SecIndex) /*(ɸѡЧڵ߼)*/ + { + /* ߼UTռ */ + if (STATUS_CT == s_pSecState[s_pSecIndex[s_pSecState[s_pSecIndex[plogicSecIdBuf[u8SecIndex]]].u16ID]].u8Status) + { + break; /*ͨųռѹٿͨųUTռѹ*/ + } + else + { + s_pSecState[s_pSecIndex[plogicSecIdBuf[u8SecIndex]]].u8Status = STATUS_UT; + debug_infor_printf((const)"CTɸѡЧ߼[%d]UTռ\n", s_pSecIndex[plogicSecIdBuf[u8SecIndex]]); + u8SecIndex--; + } + } + } + } + else + { + + } + } + } + else + { + ; + } + +} + +/***************************************************************************** +* @name SetACSecState +* @brief ü߼ε״̬ +* @param[in] u16ACID ID +* @param[in] u8State ״̬(STATUS_UT,STATUS_CT,STATUS_ARB,STATUS_FREE) +* @return +* @note +*****************************************************************************/ +static void SetACSecState(UINT16 u16ACID, UINT8 u8State) +{ + UINT8 u8Index = DEFAULT_ZERO; /* ѭ */ + UINT8 u8SecNum = DEFAULT_ZERO; /* ߼ */ + UINT16* plogicSecIdBuf = NULL; /*Id*/ + + /*- ȡϵ߼б */ + u8SecNum = GetAxisSecLogSectionSum(u16ACID); + plogicSecIdBuf = GetAxisSecLogSectionIdBuf(u16ACID); + if (0u < u8SecNum) + { + /*- ߼б߼״̬*/ + for (u8Index = DEFAULT_ZERO; u8Index < u8SecNum; u8Index++) + { + /*ǷDZZC߼ */ + if (DEFAULT_ZERO < s_pSecIndex[plogicSecIdBuf[u8Index]]) + { + /* ߼״̬ */ + s_pSecState[s_pSecIndex[plogicSecIdBuf[u8Index]]].u8Status = u8State; + debug_infor_printf((const)"Axis ID:[%d] LogicSection ID:[%d] Is Filled With UT Train\n", u16ACID, s_pSecIndex[plogicSecIdBuf[u8Index]]); + } + else + { + /*- ɴ֧ */ + } + } + } + else + { + ; + } + +} + +/***************************************************************************** +* @name CreateCT +* @brief Ϊͨų߼CTռ +* @param[in] +* @return +* @note +*****************************************************************************/ +static void CreateCT(void) +{ + UINT8 u8Index = DEFAULT_ZERO; /* ѭ */ + UINT16 u16Num = DEFAULT_ZERO; /* */ + UINT8 u8Stat = STATUS_UT; /* ״̬ */ + UINT16 u16TrainID = DEFAULT_ZERO; /* гID */ + UINT16 u16List[SIZE_MAX_SECTION_BT_TRAIN] = {0u}; /* б */ + UINT8 u8TrainLocValid = DEFAULT_ZERO; /*гλǷЧ*/ + UINT8 u8TrainLevel = DEFAULT_ZERO; /*геȼ*/ + UINT8 u8TrainSlpStt = DEFAULT_ZERO;/*г״̬*/ + + /*- г1 ; Ƿβ? ; */ + for (u16TrainID = 1U; u16TrainID < SIZE_MAX_LINETRAIN; u16TrainID++) + { + u8TrainLocValid = TrainManage_GetTrainLocValid(u16TrainID); + if (FLAG_SET == u8TrainLocValid) + { + u8TrainLevel = TrainDataMange_GetTrainLevel(u16TrainID); + u8TrainSlpStt = TrainManage_GetTrainSleepState(u16TrainID); + + if ((TRAIN_LEVEL_VBTC == u8TrainLevel) || (TRAIN_SLEEP_YES == u8TrainSlpStt)) + { + /*гȼVBTC߳ҪCT*/ + u8Stat = STATUS_CT; + } + else + { + u8Stat = STATUS_AT; + } + /*- ѯгռõ߼ */ + u16Num = GetCTSecList(u16TrainID, u16List); + if (SIZE_MAX_SECTION_BT_TRAIN >= u16Num ) + { + /*- @alias ߼УԱ߼CT/ATռ */ + for (u8Index = DEFAULT_ZERO; u8Index < u16Num; u8Index++) + { + if (DEFAULT_ZERO != s_pSecIndex[u16List[u8Index]]) + { + /*߼CTռ */ + s_pSecState[s_pSecIndex[u16List[u8Index]]].u8Status = u8Stat; + debug_infor_printf((const)"LogicSection [%d] is CT Occupy\n", u16List[u8Index]); + } + else + { + ; + } + } + } + else + { + ; + } + } + else + { + ; + } + } +} + + +/***************************************************************************** +* @name GetTrainOrgnSec +* @brief ȡг߼ID +* @param[in] u16TrainID гID +* @return ߼ID(Чʱ0) +* @note +*****************************************************************************/ +static UINT16 GetTrainOrgnSec(UINT16 u16TrainID) +{ + UINT16 u16RetSgmtID = DEFAULT_ZERO; /*ֵ*/ + struct_PathPoint pos = { 0U }; + UINT8 u8dirTemp = DEFAULT_ZERO; + + /*ȡβ*/ + (void)TrainManage_GetTrainSafeLoc(FINDTAILSAFEFLAG, u16TrainID, &pos.wLinkId, &pos.dwOffset, &u8dirTemp); + + /*- תΪ߼ƫ */ + u16RetSgmtID = GetPointBelongLogSec(pos); + + return u16RetSgmtID; +} + +/***************************************************************************** +* @name GetTrainTmnlSec +* @brief ȡгյ߼ID +* @param[in] u16TrainID гID +* @return ߼ID(Чʱ0) +* @note +*****************************************************************************/ +static UINT16 GetTrainTmnlSec(UINT16 u16TrainID) +{ + UINT16 u16RetSgmtID = DEFAULT_ZERO; /*ֵ*/ + struct_PathPoint pos = { 0U }; + UINT8 u8dirTemp = DEFAULT_ZERO; + + /*ȡͷ*/ + (void)TrainManage_GetTrainSafeLoc(FINDHEADSAFEFLAG, u16TrainID, &pos.wLinkId, &pos.dwOffset, &u8dirTemp); + + /*- תΪ߼ƫ */ + u16RetSgmtID = GetPointBelongLogSec(pos); + + return u16RetSgmtID; +} + +/***************************************************************************** +* @name u16Find +* @brief U16ҸֵӦĽDZ +* @param[in] u8Num 鳤 +* @param[in] u16List +* @param[in] u16Val ֵ +* @param[out] pu8Index ֵӦĽDZ +* @return Ƿҵ: CI_SUCCESS ҵCI_ERROR ûҵ +* @note +*****************************************************************************/ +static UINT8 u16Find(IN UINT8 u8Num, IN const UINT16 u16List[], IN UINT16 u16Val, OUT UINT8 *pu8Index) +{ + UINT8 u8Ret = CI_ERROR; /* ֵ */ + UINT8 u8Index = DEFAULT_ZERO; /* ѭ */ + + /*- @alias 飬ظֵӦĽDZ꼰ѯ */ + for (u8Index = DEFAULT_ZERO; u8Index < u8Num; u8Index++) + { + if (u16List[u8Index] == u16Val) + { + *pu8Index = u8Index; + u8Ret = CI_SUCCESS; + break; + } + else + { + ; + } + } + return u8Ret; +} + + + +/***************************************************************************** +* @name ssp_GetSecStatus +* @brief ȡ߼״̬ +* @param[in] u16SecID ߼ID +* @return STATUS_UT,STATUS_CT,STATUS_ARB,STATUS_FREE +* @note DZ߼Σ̶ STATUS_UT +*****************************************************************************/ +UINT8 ssp_GetSecStatus(UINT16 u16SecID) +{ + UINT8 u8State = STATUS_UT; /* ״̬ */ + + /*- ߼ǷڱZC */ + if ((u16SecID <= SIZE_MAX_SECTION) && (DEFAULT_ZERO != s_pSecIndex[u16SecID])) + { + /*- ߼״̬ */ + u8State = s_pSecState[s_pSecIndex[u16SecID]].u8Status; + } + else + { + ; + } + + /*- ߼״̬ */ + return u8State; +} + + +/*********Ǵⲿӿڻȡ***************************************************/ + +/***************************************************************************** +* @name TrainDataMange_GetTrainLevel +* @brief ȡָгȼ +* @param[in] TiranID гID +* @return геȼ +* @note гģлȡ +*****************************************************************************/ +static UINT8 TrainDataMange_GetTrainLevel(UINT16 TrainID) +{ + UINT8 level = DEFAULT_ZERO; + UINT16 IDIndex = DEFAULT_ZERO; + if (TrainID > DEFAULT_ZERO) + { + IDIndex = GetTrainId(TrainID - 1U); + level = GetTrainLevel(IDIndex); + } + else + { + ; + } + return level; +} + + +/***************************************************************************** +* @name elm_IsTrainOrgnUT +* @brief CTг()ɸѡǷЧ +* @param[in] u16TrainID гID +* @return CTɸѡǷЧ: FLAG_SET UTFLAG_UNSET +* @note עֻCT +*****************************************************************************/ +static UINT8 elm_IsTrainOrgnUT(UINT16 TrainID) +{ + UINT8 u8Clear = FLAG_UNSET; + const EnvelopeStruct* pEL = NULL; + + /*IDȡ*/ + pEL = elm_GetEnvelopeInfoByTrainID(TrainID); + if (NULL != pEL) + { + /*- βɸѡ״̬ */ + if ((DEFAULT_ZERO != pEL->tailTrainID) && (TYPE_CT == pEL->envelopeType)) + { + u8Clear = FLAG_SET; + } + else + { + /*޲*/ + } + } + else + { + ; + } + /*- ɸѡ״̬*/ + return u8Clear; +} + +/***************************************************************************** +* @name elm_IsTrainTmnlUT +* @brief CTгյ(Ҷ)ɸѡǷЧ +* @param[in] u16TrainID гID +* @return CTɸѡǷЧ: FLAG_SET пɣFLAG_UNSET +* @note עֻCT +*****************************************************************************/ +static UINT8 elm_IsTrainTmnlUT(UINT16 TrainID) +{ + UINT8 u8Clear = FLAG_UNSET; + const EnvelopeStruct* pEL = NULL; + + /*IDȡ*/ + pEL = elm_GetEnvelopeInfoByTrainID(TrainID); + if (NULL != pEL) + { + /*- ͷɸѡ״̬ */ + if ((DEFAULT_ZERO != pEL->headTrainID) && (TYPE_CT == pEL->envelopeType)) + { + u8Clear = FLAG_SET; + } + else + { + /*޲*/ + } + } + else + { + ; + } + + /*- ɸѡ״̬*/ + return u8Clear; + +} + + +/** +* @brief ӡ߼ռ״̬ +* @param +* @return +*/ +static void LogPrintf_LgcOccState(void) +{ + UINT16 wLgcSum = 0u; /*߼*/ + UINT16 wIndex = 0u; /*黺*/ + UINT16 wLgcId = 0u; + UINT8 ii = 0u; + UINT8 wLgcBelongCIId = 0u; + UINT8 chLgcStatus = 0u; + UINT8 localCiId = 0u; + + localCiId = GetSystemParaLocalCiId(); /*ID*/ + wLgcSum = GetTotalLogSecCurNum(); /*ȡ߼*/ + /*մӡ*/ + CleanString(outString_lgc); + for (ii = 0u; ii < wLgcSum; ii++) + { + wLgcId = GetLogicSecId(ii); + wLgcBelongCIId = GetLogSecBelongCiId(wLgcId); /*ȡ߼ID*/ + /*߼Ϊ*/ + if (localCiId == wLgcBelongCIId) + { + chLgcStatus = ssp_GetSecStatus(wLgcId); + + ShortToChar(wLgcId, &outString_lgc[wIndex]);/*ӡ߼ID*/ + wIndex += 2u; + outString_lgc[wIndex] = chLgcStatus;/*߼ռ״̬*/ + wIndex++; + } + else + { + /*DZ߼Σӡ*/ + } + } + if (wIndex == 0u) + {/*߼ݣӡ*/ + } + else + { +#ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nLogicSectionOccupyState:%d\nLogicSectionId(2)-LogicSecOccupyState(1):%d", (UINT16)sizeof(SSP_STATUS_s), wIndex); + debug_out_array(0xAA, outString_lgc, wIndex); +#endif + +#ifdef PLATFORM_LABVIEW_DEBUG + Out_Array_Buffer(0, "\nLogicSectionOccupyState:%d", (UINT16)sizeof(SSP_STATUS_s)); + Out_Array_Buffer(0, "LogicSectionId(2)-LogicSecOccupyState(1):", wIndex); + Out_Array_Buffer(16, outString_lgc, wIndex); +#endif + + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess_api.h b/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess_api.h new file mode 100644 index 0000000..0a2e69b --- /dev/null +++ b/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess_api.h @@ -0,0 +1,30 @@ +/****************************************************************************** +** ļ: SectionStateProcess_api.h ( ״̬ⲿú ) +** : ״̬ģ飬ssp +*******************************************************************************/ + +#ifndef INC_SSP_API_INC +#define INC_SSP_API_INC + +#include "SectionStateProcess_define.h" + +/* + * @brief ȡ߼״̬(ӿģ) + * @param[in] u16SecID ߼ID + * @return STATUS_UT,STATUS_CT,STATUS_ARB,STATUS_FREE + * @note DZΣ̶ STATUS_UT + */ +UINT8 ssp_GetSecStatus(UINT16 u16SecID); + +/*- + * @brief SSPģʼ + */ +void ssp_Init(void); + +/*- + * @brief SSPģ߼ + */ +void ssp_MainProcess(void); + +#endif + diff --git a/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess_define.h b/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess_define.h new file mode 100644 index 0000000..08baaa6 --- /dev/null +++ b/TSCP/src/APP/ciapp/SectionStateProcess/SectionStateProcess_define.h @@ -0,0 +1,29 @@ +/****************************************************************************** +** ļ: SectionStateProcess_define.h +** : ״̬ģ飬ssp +*******************************************************************************/ +#ifndef INC_SSP_DEFINE_INC +#define INC_SSP_DEFINE_INC + +#include "CommonTypes.h" +#include +#include "CiSystemDefine.h" +#include "AxisSort.h" + +/* ״̬ */ +#define STATUS_UT (0x00U) /* ͨųռ */ +#define STATUS_AT (0x33U) /* ATռ(λû㱨ķCBTC) */ +#define STATUS_CT (0x55U) /* CTռ(λû㱨CBTC) */ +#define STATUS_ARB (0xCCU) /* */ +#define STATUS_FREE (0xAAU) /* */ + + +#define SIZE_MAX_SECTION_INAC (AXIS_INCLUDE_LOG_SUM_MAX) /*SSPģ߼*/ +#define SIZE_MAX_AC (AXIS_SECTION_SUM_MAX) /* SSPģı */ +#define SIZE_MAX_LINK (LINK_SUM_MAX) /* SSPģıLink */ +#define SIZE_MAX_SECTION (LOGIC_SECTION_SUM_MAX) /* SSPģı߼ */ + +#define SIZE_MAX_SECTION_BT_TRAIN (50U) /*ռѹ߼θ*/ + +#endif + diff --git a/TSCP/src/APP/ciapp/Signal/SignalConfigDataManage.c b/TSCP/src/APP/ciapp/Signal/SignalConfigDataManage.c new file mode 100644 index 0000000..f6475e1 --- /dev/null +++ b/TSCP/src/APP/ciapp/Signal/SignalConfigDataManage.c @@ -0,0 +1,1864 @@ +/******************************************************** +* +* SignalConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* źŻݹ +* ޸ļ¼ +* +********************************************************/ + +#include "../Section/PhysicalSectionDataManage.h" +#include "SignalConfigDataManage.h" +#include "ELMDataPrepare.h" + + +SignalConfigDataStruct SignalConfigDataStru[SIGNAL_SUM_MAX]; /*źŻýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiSignalIdBuf[SIGNAL_SUM_MAX] = {0u}; /*屾źŻIDӳ*/ +INT16 SignalCurSum = 0; /*ڱźŻǰ*/ +UINT16 totalSignalNum = 0u;/*͸źŻ*/ + + +UINT16 SignalTypeNum = 0u; /*õźŻ*/ +/*źŻͺ󱸿ɫýṹ*/ +SignalDrvTypeOpenColorConfig SignalTypeOpenColorConfigStru[SIGNAL_MAX_DRVCOLL_TYPE_NUM]; + +/* +* ȡָIDźŻ +* ˵ const UINT16 signalId, źŻD +* ֵ SIGNAL_SUM_MAX: ȡʧ +* signalId)) + { + retVal = signalId; + } + + return retVal; +} + + +/* +* ȡźŻǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: źŻǰ +*/ +UINT16 GetSignalCurSum(void) +{ + UINT16 retVal = 0u; + if ((INT16)SIGNAL_SUM_MAX <=SignalCurSum) + { + retVal = SIGNAL_SUM_MAX; + } + else if (0 > SignalCurSum) + { + retVal = 0; + } + else + { + retVal = (UINT16)SignalCurSum; + } + return retVal; +} + +/* +* ȡָIDźŻ +* ˵ +* ֵ + SignalConfigDataStruct * +*/ +SignalConfigDataStruct *GetSignalConfigData(void) +{ + return SignalConfigDataStru; +} + + +/* +* ȡָ±ӦźŻID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: źŻID +*/ +UINT16 GetSignalId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 totalSignalCurNum = 0u; + totalSignalCurNum = GetTotalSignalCurNum(); + if (bufIndex < totalSignalCurNum) + { + retVal = LocalCiSignalIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSignalBelongCiId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].BelongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻķ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻķ +*/ +UINT8 GetSignalDirection(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].Direction; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻӪ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻӪ +*/ +UINT8 GetSignalOperDirection(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].OperDirection; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻ +*/ +UINT8 GetSignalType(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].SignalType; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻ1˿̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: 1˿̵ID +*/ +UINT16 GetSignalFirstDsRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].FirDsRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻ2˿̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: 2˿̵ID +*/ +UINT16 GetSignalSecondDsRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].SecDsRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻгźż̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: гźż̵ID +*/ +UINT16 GetSignalLxRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].LxRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻźż̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źż̵ID +*/ +UINT16 GetSignalZxRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].ZxRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻźż̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źż̵ID +*/ +UINT16 GetSignalYxRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].YxRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: Ƽ̵ID +*/ +UINT16 GetSignalDdRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].DdRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSignalDxRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].DxRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻƵƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSignalYellowRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].YellowRelayId_wh; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻ̵Ƽ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSignalGreenRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].GreenRelayId_wh; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSignalBlueRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].BlueDsRelayId_wh; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* źŻ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 SignalConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 signalConfigDataSum = 0u; /*źŻ豸*/ + UINT8 retVal = CI_SUCCESS; + + /*źŻID*/ + signalConfigDataSum = GetSignalCurSum(); + totalSignalNum = signalConfigDataSum; + if (signalConfigDataSum >= SIGNAL_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < SIGNAL_SUM_MAX; ii++) + { + if (jj == signalConfigDataSum) + {/*Ч*/ + + break; + } + + if (SignalConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + LocalCiSignalIdBuf[jj] = SignalConfigDataStru[ii].SignalId; + jj++; + } + + + } + } + + + return retVal; +} + +/* +* ȡָIDźŻڷһID +* ˵ const UINT16 signalId, źŻID +* const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ڷһID +*/ +UINT16 GetSignalInFirstPhySecId(const UINT16 signalId,const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + UINT8 railwayType = CI_TRADITION_RAILWAY; + + UINT16 routePhySecInx = 0u; + + railwayType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/**/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if(CI_TRADITION_RAILWAY == railwayType) + {/*ͳǹ·*/ + retVal = SignalConfigDataStru[bufIndex].InFirstPhySecId; + }/* zt ɾش 2022-02-15 */ + else + { + + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + +/* +* ȡָIDźŻڷյĵһID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ڷյĵһID +*/ +UINT16 GetSignalInFirstLockedPhySecId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + UINT16 routePhySecInx = 0u; + UINT16 routeId = 0u; + UINT16 phySecId = 0u; + UINT16 lockRouteId; + + UINT8 railwayType = CI_TRADITION_RAILWAY; + + railwayType = GetCiFunctionSwitchConfig(LINE_RAILWAY_TYPE_CONF);/**/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if(CI_TRADITION_RAILWAY == railwayType) + {/*ͳǹ·*/ + phySecId = SignalConfigDataStru[bufIndex].InFirstPhySecId;/*ȻȡźŻڷһ*/ + lockRouteId = GetPhySecRLockBelongRouteId(phySecId);/*·ID*/ + + if(CI_ERROR != lockRouteId) + { + retVal = SignalConfigDataStru[bufIndex].InFirstPhySecId; + } + }/* zt ɾش 2022-02-15 */ + else + { + /*· */ + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻⷽһID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ⷽһID +*/ +UINT16 GetSignalOutFirstPhySecId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].OutFirstPhySecId; + if (0xffffU == retVal) /*УźŻⷽһ0xffffķǷ*/ + { + retVal = 0u; + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; +} + + +/* +* ȡָIDźŻ߼Ŀ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: εĿ +*/ +UINT16 GetSignalRelatedLogSecSum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].relatedLogSecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻ߼ID +* ˵ const UINT16 signalId, źŻID +* ֵ NULL: ȡʧ +* !NULL: ε׵ַ +*/ +UINT16 *GetSignalRelatedLogSecIdBuf(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].ralatedLogSecIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָIDźŻǷѶ +* ˵ const UINT16 signalId, źŻID +* ֵ SIGNAL_DRV_ENABLE: ɼ +* SIGNAL_DRV_DISABLE: ɼ +*/ +UINT8 GetSignalDrvEnable(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = SIGNAL_DRV_DISABLE; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].driveEnable; + } + + return retVal; +} + +/* +* ȡָIDźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ +* SIGNAL_TYPE_FENG_YELLOW 0x55 Ƶ +* SIGNAL_TYPE_FENG_GREEN 0xaa ̵ +* SIGNAL_TYPE_FENG_NO 0xff +*/ +UINT8 GetSignalFengDengType(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].SignalFengDengType; + } + + return retVal; +} +/* +* ȡʼźŻͬĽ·Ŀ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼźŻͬĽ·Ŀ +*/ +UINT16 GetStartSignalRouteSum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].startSigRouSum; + } + + return retVal; +} +/* +* ȡʼźŻͬĽ·ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼźŻͬĽ·ID +*/ +UINT16* GetStartSignalRouteBuf(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].startSigRouBuf; + } + + return retVal; +} +/* +* źŻ +* ˵ signalSum źŻ +* signalIdBuff ͸źŻID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendSignalIdDataManage(UINT16 sigSum,const UINT16 *signalIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if ((totalSignalNum + sigSum) >= SIGNAL_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = totalSignalNum; + totalSignalNum += sigSum; + for(ii = 0u;ii< sigSum;ii++) + { + LocalCiSignalIdBuf[index+ii] = signalIdBuff[ii];/*׷ӵLocalCiSignalIdBuf*/ + } + } + + return retVal; +} + +/* +* ȡ͸ԼźŻǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: źŻǰ +*/ +UINT16 GetTotalSignalCurNum(void) +{ + UINT16 retVal = 0u; + if (totalSignalNum >= SIGNAL_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = totalSignalNum; + } + return retVal; +} + +/* +* ȡָIDźŻǷΪźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻ +*/ +UINT8 GetSignalVirtualAttr(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].signalVirtualAttr; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡԸźŻΪվźŻPSDID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ԸźŻΪվźŻPSDID +*/ +UINT16* GetSignalRelatedPsdBuf(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].signalPsdIdBuf; + } + + return retVal; +} +/* +* ȡԸźŻΪվźŻPSDID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ԸźŻΪվźŻPSDID +*/ +UINT8 GetSignalRelatedPsdSum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].signalPsdSum; + } + + return retVal; +} + +/* +* ȡźŻı +* ˵ const UINT16 signalId, źŻID +* ֵ +źŻı +*/ +UINT8 GetSignalProSecIdSum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].signalProSecSum; + } + + return retVal; +} +/* +* ȡźŻıID +* ˵ const UINT16 signalId, źŻID +* ֵ +źŻıID +*/ +UINT16* GetSignalProSecIdBuf(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].signalProSecBuf; + } + + return retVal; +} + +/* +* ȡʼźŻͬCIĵĽ·Ŀ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼźŻͬCIĵĽ·Ŀ +*/ +UINT16 GetStartSignalCIRouteSum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].startSigCiRouteSum; + } + + return retVal; +} + +/* +* ȡָIDźŻļĿ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: εĿ +*/ +UINT16 GetSignalRelatedAxisSecSum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].relatedAxisSecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻļID +* ˵ const UINT16 signalId, źŻID +* ֵ NULL: ȡʧ +* !NULL: ε׵ַ +*/ +UINT16 *GetSignalRelatedAxisSecIdBuf(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *retVal = NULL; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].relatedAxisSecIdBuf; + } + else + { + retVal = NULL; + } + return retVal; +} + +/* +* ȡָIDźŻǷΪѹصźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻ +*/ +UINT8 GetSignalCrossCloseAttr(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].signalCrossCloseAttr; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻ۳״̬ɼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT16 GetSignalDetainRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].detainRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + + + +/* +* ȡָIDźŻǷ˿ѹλ +* ˵ const UINT16 sigalId, źŻID +* ֵ 0: ȡʧ +* >0: Ƿÿѹλ +*/ +UINT8 GetSigConfZcCiSignalCrossMask(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].ConfigZcCiSignalCrossMask; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/**********************ֽ źŻͺɫͺ󱸿ɫֵ**********************************************/ + + +/* +* ȡָIDźŻͶӦ󱸿ɫ +* ˵ UINT16 wSignalId, źŻID +* ֵ 0: ȡʧ +* >0: 󱸿ɫɫ +*/ +UINT8 GetSignalBlockOpenColorValue(UINT16 wSignalId) +{ + UINT16 ii = 0u; /*±*/ + + UINT8 chRtVal = 0U; + + for (ii = 0u; ii < SIGNAL_MAX_DRVCOLL_TYPE_NUM; ii++) + { + if (SignalTypeOpenColorConfigStru[ii].SignalId == wSignalId) + { + chRtVal = SignalTypeOpenColorConfigStru[ii].BlockOpenColorValue[0]; + break; + } + } + + return chRtVal; +} + +/**********************ֽ źŻͺɫͺ󱸿ɫֵ****END**********************************************/ + + + +/**RepLxRelayId*********ֽ źŻʾгźż̵********************************************/ +/* +* ȡָIDźŻʾгźż̵ID +* ˵ const UINT16 sigalId, źŻID +* ֵ 0: ȡʧ +* >0: гźż̵ +*/ +UINT16 GetSignalRepLxRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + retVal = SignalConfigDataStru[bufIndex].RepLxRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/**RepLxRelayId*********ֽ źŻʾгźż̵*********END***********************************/ + + + +/* +* ȡָIDźŻ۳̵ +* ˵ const UINT16 sigalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳̵ +*/ +UINT16 GetSignalDetainDriveRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + retVal = SignalConfigDataStru[bufIndex].DetainDriveRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻ۳·̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT16 GetSignalDetainCutRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].detainCutRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻOc ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: Oc ID +*/ +UINT16 GetSignalBelongOcId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].BelongOcId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDźŻڷһID +* ˵ const UINT16 signalId, źŻID +* const UINT16 PhysicalSectionId, ID +* ֵ +* +*/ +void SetSignalInFirstPhySecId(const UINT16 signalId, const UINT16 PhysicalSectionId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 routePhySecInx = 0u; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalConfigDataStru[bufIndex].InFirstPhySecId = PhysicalSectionId; + } + else + { + /**/ + } +} + + +/* +* ȡźŻɫ +* ˵ const UINT16 signalColor, źŻɫ +* ֵ SIGNAL_LIGHT_EXTICT_STATE_YES: +* SIGNAL_LIGHT_EXTICT_STATE_NO: +*/ +UINT8 GetSignalColorLevel(const UINT8 signalColor) +{ + UINT8 retLevel = 0u; + if ((signalColor & 0x80u) == 0x80u) + { + retLevel = SIGNAL_LIGHT_EXTICT_STATE_NO; + } + else + { + retLevel = SIGNAL_LIGHT_EXTICT_STATE_YES; + } + return retLevel; +} + +/* +* ȡָIDźŻ۳״ָ̬ʾƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״ָ̬ʾƼ̵ID +*/ +UINT16 GetSignalDetainDisRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + retVal = SignalConfigDataStru[bufIndex].detainDisplayRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻ۳·״ָ̬ʾƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳·״ָ̬ʾƼ̵ID +*/ +UINT16 GetSignalDetainCutDisRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + retVal = SignalConfigDataStru[bufIndex].detainCutDisplayRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDźŻID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSignalBelongVirCiId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].BelongVirCI; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻǷΪ· +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ǷΪ· +*/ +UINT8 GetSignalIsThisLineState(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].SignalIsThisLine; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDźŻǷΪʾźŻ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalIsFushiFlag ʾźŻ־ +*/ +void SetSignalIsfushiFlag(const UINT16 signalId, const UINT8 signalIsFushiFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalConfigDataStru[bufIndex].SignalIsFushiFlag = signalIsFushiFlag; + } + else + { + } +} +/* +* ȡָIDźŻǷΪʾźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ǷΪʾźŻ +*/ +UINT8 GetSignalIsfushiFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0; /*±*/ + + UINT8 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].SignalIsFushiFlag; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDźŻĸʾźŻ +* ˵ const UINT16 signalId, źŻID +* const UINT8 fushiSigNum ʾźŻ +*/ +void SetSignalFushiSignalNum(const UINT16 signalId, const UINT8 fushiSigNum) +{ + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalConfigDataStru[bufIndex].SignalFushiSignalNum = fushiSigNum; + } + else + { + + } +} + +/* +* ȡָIDźŻĸʾźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ ʾźŻ + +*/ +UINT8 GetSignalFushiSignalNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reval = 0u; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reval = SignalConfigDataStru[bufIndex].SignalFushiSignalNum; + if (SIGNAL_FUSHINUM_MAX < reval) + { + reval = 0u; + } + } + else + { + } + return reval; +} + +/* +* ָIDźŻĸʾźŻID +* ˵ const UINT16 signalId, źŻID +* ֵ ʾźŻID + +*/ +UINT16* GetSignalFushiSignalIdBuf(const UINT16 signalId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT16* pFushiSignalIdBuf = NULL; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + pFushiSignalIdBuf = SignalConfigDataStru[bufIndex].SignalFushiSignalIdBuf; + } + else + { + } + return pFushiSignalIdBuf; +} + +/* +* ȡָIDźŻLink +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: LinkId +* qw.liu 2022-03-04 +*/ +UINT16 GetSignalProtectLink(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 wRetVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + wRetVal = SignalConfigDataStru[bufIndex].wProtectLinkId; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/* +* ȡָIDźŻOFF +* ˵ const UINT16 signalId, źŻID +* ֵ UINT32_MAX: ȡʧ +* : Link OFF +* qw.liu 2022-03-04 +*/ +UINT32 GetSignalProtectLinkOff(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT32 dwRetVal = UINT32_MAX; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + dwRetVal = SignalConfigDataStru[bufIndex].dwProtectOff; + } + else + { + dwRetVal = UINT32_MAX; + } + return dwRetVal; +} + +/* +* ȡָIDźŻܱ־ +* ˵ const UINT16 signalId, źŻID +* ֵ UINT8_MAX: ȡʧ +* : Link OFF +* qw.liu 2022-03-04 +*/ +UINT8 GetSignalShine(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 chRetVal = UINT8_MAX; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + chRetVal = SignalConfigDataStru[bufIndex].chShineSignal; + } + else + { + chRetVal = CI_ERROR; + } + return chRetVal; +} + +/* +* ȡָIDźŻⷽһlink +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: LinkId +* 2022-03-04 +*/ +UINT16 GetSignalOutFirstLink(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 wRetVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + wRetVal = SignalConfigDataStru[bufIndex].wOutFirstLinkId; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/* +* ȡָIDźŻ۳·̵2 ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT16 GetSignalDetainCutRelayId_2(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].detainCutRelayId_2; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDźŻ۳״̬ɼ̵2 ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT16 GetSignalDetainRelayId_2(const UINT16 signalId) +{ + UINT16 bufIndex = 0; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].detainRelayId_2; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻ۳·״ָ̬ʾƼ̵2 ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳·״ָ̬ʾƼ̵ID +*/ +UINT16 GetSignalDetainCutDisRelayId_2(const UINT16 signalId) +{ + UINT16 bufIndex = 0; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + retVal = SignalConfigDataStru[bufIndex].detainCutDisplayRelayId_2; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻ۳״ָ̬ʾƼ̵2 ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״ָ̬ʾƼ̵ID +*/ +UINT16 GetSignalDetainDisRelayId_2(const UINT16 signalId) +{ + UINT16 bufIndex = 0; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + retVal = SignalConfigDataStru[bufIndex].detainDisplayRelayId_2; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻȡ۳ťɼ̵1ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡ۳ť̵1ID +*/ +UINT16 GetSignalCancelDetainBtnRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + retVal = SignalConfigDataStru[bufIndex].cancelDetainBtnCollRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻȡ۳ťɼ̵2ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡ۳ť̵2ID +*/ +UINT16 GetSigCancelDetainBtnRelayId_2(const UINT16 signalId) +{ + UINT16 bufIndex = 0; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + retVal = SignalConfigDataStru[bufIndex].cancelDetainBtnCollRelayId_2; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָźŻESB +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻESB +*/ +UINT8 GetSignalRelatedEsbSum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].signalEsbSum; + } + else + { + /*ηǷCI_ERROR*/ + } + + + return retVal; +} + +/* +* ȡָźŻESBID +* ˵ const UINT16 signalId, źŻID +* ֵ NULL: ȡʧ +* NULL: źŻESBID +*/ +UINT16* GetSignalRelatedEsbBuf(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16* retVal = NULL; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].signalEsbIdBuf; + } + else + { + /*ηǷNULL*/ + } + + return retVal; +} + +/* +* ȡָIDźŻгź̵IDʹã +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: гź̵ID +*/ +UINT16 GetSignalLxDrvRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].LxDrvRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDźŻź̵IDʹã +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ź̵ID +*/ +UINT16 GetSignalYxDrvRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].YxDrvRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻź̵IDʹã +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ź̵ID +*/ +UINT16 GetSignalDxDrvRelayId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + retVal = SignalConfigDataStru[bufIndex].DxDrvRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDźŻⷽһ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ߼ID +*/ +UINT16 GetSignalOutFirstLogSec(const UINT16 signalId) +{ + UINT16 outPhySecId = 0U;/*ⷽһID*/ + UINT8 phySecIncLogSecSum = 0U; /*ΰ߼*/ + UINT16* phySecIncLogSecId = NULL; /*ΰ߼ID*/ + UINT8 i = 0U; + UINT32 startLength = UINT16_MAX; + UINT32 endLength = UINT16_MAX; + UINT16 firstLogSecId = 0U; + LOD_STRU signalPoint = { 0U }; /*źŻλ*/ + LOD_STRU logSecStartPoint = { 0U }; /*߼ʼλ*/ + LOD_STRU logSecEndtPoint = { 0U }; /*߼ʼλ*/ + UINT16 retVal = 0U; + UINT8 logSecCount = 0U; + UINT16 logSecIdbuff[PHYSICAL_INCLUDE_SWITCH_SUM_MAX] = { 0U }; + UINT8 posCheck = CI_ERROR; + UINT16 devId = 0U; + UINT8 devState = 0U; + outPhySecId = GetSignalOutFirstPhySecId(signalId); + + if (0U != outPhySecId) + { + /*ȡι߼Ϣ*/ + phySecIncLogSecSum = GetPhySecIncLogSecSum(outPhySecId); + phySecIncLogSecId = GetPhySecIncLogSecIdBuf(outPhySecId); + /*ȡźŻλϢ*/ + signalPoint.Lnk = GetSignalProtectLink(signalId); + signalPoint.Off = GetSignalProtectLinkOff(signalId); + + + if ((0U != phySecIncLogSecSum) && (NULL != phySecIncLogSecId)) + { + for (i = 0U; i < phySecIncLogSecSum; i++) + { + logSecEndtPoint.Lnk = GetLgcSecTmnlLink(phySecIncLogSecId[i]); + logSecEndtPoint.Off = GetLgcSecTmnlOffset(phySecIncLogSecId[i]); + + + logSecStartPoint.Lnk = GetLgcSecOrgnLink(phySecIncLogSecId[i]); + logSecStartPoint.Off = GetLgcSecOrgnOffset(phySecIncLogSecId[i]); + + startLength = elm_PrepareDistanceBtwPoints(signalPoint, logSecStartPoint); + endLength = elm_PrepareDistanceBtwPoints(signalPoint, logSecEndtPoint); + /*ѯźŻlink߼*/ + if ((0U == startLength) || (0U == endLength)) + { + logSecIdbuff[logSecCount] = phySecIncLogSecId[i]; + logSecCount++; + } + + } + /*ж߼εĵλǷ*/ + for ( i = 0U; i < logSecCount; i++) + { + posCheck = LogicSecRelativeSwitchPosCheck(logSecIdbuff[i], &devId, &devState); + if (CI_SUCCESS == posCheck) + { + retVal = logSecIdbuff[i]; + break; + } + + } + } + } + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Signal/SignalConfigDataManage.h b/TSCP/src/APP/ciapp/Signal/SignalConfigDataManage.h new file mode 100644 index 0000000..b9ab851 --- /dev/null +++ b/TSCP/src/APP/ciapp/Signal/SignalConfigDataManage.h @@ -0,0 +1,745 @@ +/******************************************************** +* +* SignalConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* źŻݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SIGNAL_CONFIG_DATA_MANAGE_H_ +#define _SIGNAL_CONFIG_DATA_MANAGE_H_ + + +#include "SignalDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*źŻݽṹ*/ +typedef struct S_SignalConfigDataStruct +{ + UINT16 SignalId; /* źŻID (ֶ) */ + UINT8 BelongCiId; /* ID (ֶ) */ + UINT8 BelongVirCI; /**/ + UINT16 BelongOcId; /* OC ID (ֶ) */ + UINT8 driveEnable; /* Ƿ */ + UINT8 Direction; /*źŻ(/) (ֶ)*/ + UINT8 OperDirection; /*źŻӪ*/ + UINT8 SignalType; /*źŻ(г//г) (ֶ)*/ + UINT8 SignalFengDengType; /*źŻ*/ + UINT16 FirDsRelayId; /*1˿̵ID (ֶ)*/ + UINT16 SecDsRelayId; /*2˿̵ID (ֶ)*/ + UINT16 LxRelayId; /*гźż̵ID (ֶ)*/ + UINT16 ZxRelayId; /*źż̵ID (ֶ)*/ + UINT16 YxRelayId; /*źż̵ID (ֶ)*/ + UINT16 DdRelayId; /*Ƽ̵ID (ֶ)*/ + UINT16 DxRelayId; /*źż̵ID (ֶ)*/ + UINT16 YellowRelayId_wh; /*ƵƼ̵ID for人*/ + UINT16 GreenRelayId_wh; /*̵Ƽ̵ID for人*/ + UINT16 BlueDsRelayId_wh; /*˿̵ID for人*/ + UINT16 RepLxRelayId; /*ʾгźż̵ID for人*/ + UINT16 DetainDriveRelayId; /*վ۳̵ID for人*/ + UINT16 detainRelayId; /*۳״̬ɼ̵ID (ֶ)*/ + UINT16 detainDisplayRelayId; /*۳״ָ̬ʾƼ̵ID (ֶ)*/ + UINT16 detainCutRelayId; /*۳·ɼ̵ID (ֶ)*/ + UINT16 detainCutDisplayRelayId; /*۳·ָʾƵID (ֶ)*/ + UINT16 InFirstPhySecId; /*źŻڷһID (ֶ)*/ + UINT16 InFirstMonoRailRoutePhySecSum; /*źŻڷ·Ŀ(ֶ)*/ + UINT16 InFirstMonoRailRouteIdBuf[SIGNAL_IN_1ST_MR_ROUTE_PHYSEC_MAX_SUM]; /*źŻڷ·Ŀ (ֶ)*/ + UINT16 InFirstMonoRailPhySecIdBuf[SIGNAL_IN_1ST_MR_ROUTE_PHYSEC_MAX_SUM]; /*źŻڷһĿ (ֶ)*/ + UINT16 OutFirstPhySecId; /*źŻⷽһID (ֶ)*/ + UINT16 relatedLogSecSum; /*߼Ŀ*/ + UINT16 ralatedLogSecIdBuf[SIGNAL_RELATED_LOGSEC_MAX_SUM]; /*߼ID*/ + UINT16 relatedAxisSecSum; /*Ŀ*/ + UINT16 relatedAxisSecIdBuf[SIGNAL_RELATED_AXISSEC_MAX_SUM]; /*ID*/ + + UINT16 startSigRouSum; /*ʼźŻͬĽ·Ŀ*/ + UINT16 startSigRouBuf[SIGNAL_EQUAL_ROUTE_MAX_SUM]; /*ʼźŻͬĽ·ID*/ + UINT8 signalVirtualAttr; /*źŻԣֶΣ*/ + UINT8 signalCrossCloseAttr; /*źŻѹصԣֶΣ*/ + UINT8 signalProSecSum;/*źŻıID*/ + UINT8 startSigCiRouteSum;/*ΪųZCԶ·ĵĽ·øֶ*/ + UINT16 signalPsdIdBuf[SIGNAL_RELATED_PSD_MAX_SUM];/*ԸźŻΪվźŻPSD*/ + UINT16 signalProSecBuf[SIGNAL_PRO_SEC_MAX_SUM];/*źŻıID*/ + UINT8 signalPsdSum; + UINT8 ConfigZcCiSignalCrossMask;/*ǷZC-CIźŻѹλ*/ + UINT8 SignalIsThisLine; /*źŻǷ·*/ + + UINT16 detainRelayId_2; /*۳״̬ɼ̵2ID (ֶ) lc-TSCIϲ 20221208*/ + UINT16 detainDisplayRelayId_2; /*۳״ָ̬ʾƼ̵2ID (ֶ) lc-TSCIϲ 20221208*/ + UINT16 detainCutRelayId_2; /*۳·ɼ̵2ID (ֶ) lc-TSCIϲ 20221208*/ + UINT16 detainCutDisplayRelayId_2; /*۳·ָʾƵ2ID (ֶ) lc-TSCIϲ 20221208*/ + UINT16 cancelDetainBtnCollRelayId; /*ȡ۳ťɼ̵1ID*/ + UINT16 cancelDetainBtnCollRelayId_2; /*ȡ۳ťɼ̵2ID*/ + UINT8 SignalIsFushiFlag; /*źŻǷʾźŻ,ݶCIݶ*/ + + UINT8 SignalFushiSignalNum; /*źŻʾźŻ*/ + UINT16 SignalFushiSignalIdBuf[SIGNAL_FUSHINUM_MAX];/*źŻʾźŻID*/ + + UINT16 wProtectLinkId; /*źŻLink add by qw.liu 2022-03-04*/ + UINT32 dwProtectOff; /*źŻOff add by qw.liu 2022-03-04*/ + UINT8 chShineSignal; /* źŻܱ־ add by qw.liu 2022-03-04*/ + UINT16 wOutFirstLinkId; /* źŻⷽһlink add 2022.3.4 */ + UINT16 wInFirstLinkId; /* źŻڷһlink add 2024.10.17 */ + UINT8 signalFenDuanAttr; /*źŻֶԣֶΣ*/ + UINT8 signalEsbSum; /*źŻESB*/ + UINT16 signalEsbIdBuf[SIGNAL_RELATED_ESB_MAX_SUM]; /*źŻESBID*/ + + UINT16 LxDrvRelayId; /*гź̵ID(ֶ-ʹ)*/ + UINT16 YxDrvRelayId; /*ź̵ID(ֶ-ʹ)*/ + UINT16 DxDrvRelayId; /*ź̵ID(ֶ-ʹ)*/ +} SignalConfigDataStruct; + +typedef struct S_OC_SignalConfigDataStruct +{ + UINT16 SignalId; /*źŻID(ֶ)*/ + UINT16 BelongOcId; /*OCID(ֶ)*/ + UINT8 SignalModuleIdAddrA; /*źŻģAϵID(ֶ)*/ + UINT8 RedPosAddrA; /*AϵƵλַ(ֶ)*/ + UINT8 YellowPosAddrA; /*AϵƵƵλַ(ֶ)*/ + UINT8 GreenPosAddrA; /*Aϵ̵Ƶλַ(ֶ)*/ + UINT8 WhitePosAddrA; /*Aϵ׵Ƶλַ(ֶ)*/ + UINT8 BluePosAddrA; /*AϵƵλַ(ֶ)*/ + UINT8 SignalModuleIdAddrB; /*źŻģBϵID(ֶ)*/ + UINT8 RedPosAddrB; /*BϵƵλַ(ֶ)*/ + UINT8 YellowPosAddrB; /*BϵƵƵλַ(ֶ)*/ + UINT8 GreenPosAddrB; /*Bϵ̵Ƶλַ(ֶ)*/ + UINT8 WhitePosAddrB; /*Bϵ׵Ƶλַ(ֶ)*/ + UINT8 BluePosAddrB; /*BϵƵλַ(ֶ)*/ + UINT16 DetainBtnCollRelayId; /*۳ťɼ̵ID*/ + UINT16 DetainBtnCollRelayId_2; /*۳ťɼ̵2 ID*/ + UINT16 DetainBtnIndicatorRelayId; /*۳ťָʾƼ̵ID*/ + UINT16 DetainBtnIndicatorRelayId_2; /*۳ťָʾƼ̵2 ID*/ + UINT16 DetainCutBtnRelayId; /*۳·ť̵ID*/ + UINT16 DetainCutBtnRelayId_2; /*۳·ť̵2 ID*/ + UINT16 DetainCutBtnIndicatorRelayId; /*۳·ťָʾƼ̵ID*/ + UINT16 DetainCutBtnIndicatorRelayId_2; /*۳·ťָʾƼ̵2 ID*/ + UINT16 CancelDetainBtnCollRelayId; /*ȡ۳ťɼ̵1 ID*/ + UINT16 CancelDetainBtnCollRelayId_2; /*ȡ۳ťɼ̵2 ID*/ +}OCSignalConfigDataStruct; + +typedef struct S_SignalDrvTypeOpenColorConfig +{ + UINT16 SignalId; /*źŻid*/ + UINT8 BlockOpenColorValue[SIGNAL_BLOCK_OPEN_COLORS_MAX_NUM];/*󱸿ɫ*/ +}SignalDrvTypeOpenColorConfig; + + +/*******************************ȫֱ*******************************/ +extern SignalConfigDataStruct SignalConfigDataStru[SIGNAL_SUM_MAX]; /*źŻýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiSignalIdBuf[SIGNAL_SUM_MAX]; /*屾źŻIDӳ*/ +extern INT16 SignalCurSum; /*ڱźŻǰ*/ +extern UINT16 totalSignalNum;/*͸źŻ*/ +extern UINT16 SignalTypeNum; /*õźŻ*/ +extern SignalDrvTypeOpenColorConfig SignalTypeOpenColorConfigStru[SIGNAL_MAX_DRVCOLL_TYPE_NUM]; + +/* +* ȡָIDźŻ +* ˵ const UINT16 signalId, źŻD +* ֵ SIGNAL_SUM_MAX: ȡʧ +* 0: źŻǰ +*/ +UINT16 GetSignalCurSum(void); + +/* +* ȡָ±ӦźŻID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: źŻID +*/ +UINT16 GetSignalId(const UINT16 bufIndex); + +/* +* ȡָIDźŻID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSignalBelongCiId(const UINT16 signalId); + +/* +* ȡָIDźŻķ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻķ +*/ +UINT8 GetSignalDirection(const UINT16 signalId); + +/* +* ȡָIDźŻӪ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻӪ +*/ +UINT8 GetSignalOperDirection(const UINT16 signalId); + +/* +* ȡָIDźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻ +*/ +UINT8 GetSignalType(const UINT16 signalId); + +/* +* ȡָIDźŻ1˿̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: 1˿̵ID +*/ +UINT16 GetSignalFirstDsRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻ2˿̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: 2˿̵ID +*/ +UINT16 GetSignalSecondDsRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻгźż̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: гźż̵ID +*/ +UINT16 GetSignalLxRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻźż̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źż̵ID +*/ +UINT16 GetSignalZxRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻźż̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źż̵ID +*/ +UINT16 GetSignalYxRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: Ƽ̵ID +*/ +UINT16 GetSignalDdRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSignalDxRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻƵƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSignalYellowRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻ̵Ƽ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSignalGreenRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSignalBlueRelayId(const UINT16 signalId); + +/* +* źŻ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 SignalConfigDataManage(void); + +/* +* ȡָIDźŻڷһID +* ˵ const UINT16 signalId, źŻID +* const UINT16 routeId, ·ID +* ֵ 0: ȡʧ +* >0: ڷһID +*/ +UINT16 GetSignalInFirstPhySecId(const UINT16 signalId,const UINT16 routeId); + +/* +* ȡָIDźŻڷյĵһID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ڷյĵһID +*/ +UINT16 GetSignalInFirstLockedPhySecId(const UINT16 signalId); + +/* +* ȡָIDźŻⷽһID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ⷽһID +*/ +UINT16 GetSignalOutFirstPhySecId(const UINT16 signalId); + +/* +* ȡָIDźŻ߼Ŀ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: εĿ +*/ +UINT16 GetSignalRelatedLogSecSum(const UINT16 signalId); + +/* +* ȡָIDźŻ߼ID +* ˵ const UINT16 signalId, źŻID +* ֵ NULL: ȡʧ +* !NULL: ε׵ַ +*/ +UINT16 *GetSignalRelatedLogSecIdBuf(const UINT16 signalId); + + +/* +* ȡָIDźŻǷѶ +* ˵ const UINT16 signalId, źŻID +* ֵ SIGNAL_DRV_ENABLE: ɼ +* SIGNAL_DRV_DISABLE: ɼ +*/ +UINT8 GetSignalDrvEnable(const UINT16 signalId); + +/* +* ȡָIDźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ +* SIGNAL_TYPE_FENG_YELLOW 0x55 Ƶ +* SIGNAL_TYPE_FENG_GREEN 0xaa ̵ +* SIGNAL_TYPE_FENG_NO 0xff +*/ +UINT8 GetSignalFengDengType(const UINT16 signalId); + + +/* +* ȡʼźŻͬĽ·Ŀ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼźŻͬĽ·Ŀ +*/ +UINT16 GetStartSignalRouteSum(const UINT16 signalId); +/* +* ȡʼźŻͬĽ·ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼźŻͬĽ·ID +*/ +UINT16* GetStartSignalRouteBuf(const UINT16 signalId); +/* +* źŻ +* ˵ signalSum źŻ +* signalIdBuff źŻID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendSignalIdDataManage(UINT16 sigSum,const UINT16 *signalIdBuff); + +/* +* ȡ͸ԼźŻǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ͸źŻ +*/ +UINT16 GetTotalSignalCurNum(void); + +/* +* ȡָIDźŻǷΪźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻ +*/ +UINT8 GetSignalVirtualAttr(const UINT16 signalId); + +/* +* ȡԸźŻΪվźŻPSDID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ԸźŻΪվźŻPSDID +*/ +UINT16* GetSignalRelatedPsdBuf(const UINT16 signalId); + +/* +* ȡԸźŻΪվźŻPSDID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ԸźŻΪվźŻPSDID +*/ +UINT8 GetSignalRelatedPsdSum(const UINT16 signalId); +/* +* ȡźŻı +* ˵ const UINT16 signalId, źŻID +* ֵ + źŻı +*/ +UINT8 GetSignalProSecIdSum(const UINT16 signalId); +/* +* ȡźŻıID +* ˵ const UINT16 signalId, źŻID +* ֵ + źŻıID +*/ +UINT16* GetSignalProSecIdBuf(const UINT16 signalId); + +/* +* ȡʼźŻͬCIĵĽ·Ŀ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼźŻͬCIĵĽ·Ŀ +*/ +UINT16 GetStartSignalCIRouteSum(const UINT16 signalId); + +/* +* ȡָIDźŻļĿ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: εĿ +*/ +UINT16 GetSignalRelatedAxisSecSum(const UINT16 signalId); + +/* +* ȡָIDźŻļID +* ˵ const UINT16 signalId, źŻID +* ֵ NULL: ȡʧ +* !NULL: ε׵ַ +*/ +UINT16 *GetSignalRelatedAxisSecIdBuf(const UINT16 signalId); + +/* +* ȡָIDźŻǷΪѹصźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻ +*/ +UINT8 GetSignalCrossCloseAttr(const UINT16 signalId); + +/* +* ȡָIDźŻ۳״̬ɼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT16 GetSignalDetainRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻǷ˿ѹλ +* ˵ const UINT16 sigalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT8 GetSigConfZcCiSignalCrossMask(const UINT16 signalId); + +/**********************ֽ źŻͺɫ**********************************************/ + +/* +* ȡָIDźŻͶӦ󱸿ɫ +* ˵ UINT16 wSignalId, źŻID +* ֵ 0: ȡʧ +* >0: 󱸿ɫɫ +*/ +UINT8 GetSignalBlockOpenColorValue(UINT16 wSignalId); +/**********************ֽ źŻͺɫ****END**********************************************/ + + +/* +* ȡָIDźŻʾгźż̵ +* ˵ const UINT16 sigalId, źŻID +* ֵ 0: ȡʧ +* >0: гźż̵ +*/ +UINT16 GetSignalRepLxRelayId(const UINT16 signalId); + + + +/* +* ȡָIDźŻ۳̵ID +* ˵ const UINT16 sigalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳̵ +*/ +UINT16 GetSignalDetainDriveRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻOc ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: Oc ID +*/ +UINT16 GetSignalBelongOcId(const UINT16 signalId); + +/* +* ָIDźŻڷһID +* ˵ const UINT16 signalId, źŻID +* const UINT16 PhysicalSectionId, ID +* ֵ +* +*/ +void SetSignalInFirstPhySecId(const UINT16 signalId, const UINT16 PhysicalSectionId); + +/* +* ȡźŻɫ +* ˵ const UINT16 signalColor, źŻɫ +* ֵ SIGNAL_LIGHT_EXTICT_STATE_YES: +* SIGNAL_LIGHT_EXTICT_STATE_NO: +*/ +UINT8 GetSignalColorLevel(const UINT8 signalColor); + + +/* +* ȡָIDźŻ۳״ָ̬ʾƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״ָ̬ʾƼ̵ID +*/ +UINT16 GetSignalDetainDisRelayId(const UINT16 signalId); + + +/* +* ȡָIDźŻ۳·״ָ̬ʾƼ̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳·״ָ̬ʾƼ̵ID +*/ +UINT16 GetSignalDetainCutDisRelayId(const UINT16 signalId); +/* +* ȡָIDźŻID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSignalBelongVirCiId(const UINT16 signalId); + + +/* +* ȡָIDźŻǷΪ· +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ǷΪ· +*/ +UINT8 GetSignalIsThisLineState(const UINT16 signalId); + +/* +* ȡָIDźŻǷΪʾźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ǷΪʾźŻ +*/ +UINT8 GetSignalIsfushiFlag(const UINT16 signalId); +/* +* ָIDźŻǷΪʾźŻ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalIsFushiFlag ʾźŻ־ +*/ +void SetSignalIsfushiFlag(const UINT16 signalId,const UINT8 signalIsFushiFlag); +/* +* ָIDźŻĸʾźŻ +* ˵ const UINT16 signalId, źŻID +* const UINT8 fushiSigNum ʾźŻ +*/ +void SetSignalFushiSignalNum(const UINT16 signalId,const UINT8 fushiSigNum); +/* +* ָIDźŻĸʾźŻ +* ˵ const UINT16 signalId, źŻID +* ֵ ʾźŻ + +*/ +UINT8 GetSignalFushiSignalNum(const UINT16 signalId); +/* +* ָIDźŻĸʾźŻID +* ˵ const UINT16 signalId, źŻID +* ֵ ʾźŻID + +*/ +UINT16* GetSignalFushiSignalIdBuf(const UINT16 signalId); + +/* +* ȡָIDźŻܱ־ +* ˵ const UINT16 signalId, źŻID +* ֵ UINT8_MAX: ȡʧ +* : Link OFF +* qw.liu 2022-03-04 +*/ +UINT8 GetSignalShine(const UINT16 signalId); + +/* +* ȡָIDźŻOFF +* ˵ const UINT16 signalId, źŻID +* ֵ UINT32_MAX: ȡʧ +* : Link OFF +* qw.liu 2022-03-04 +*/ +UINT32 GetSignalProtectLinkOff(const UINT16 signalId); + +/* +* ȡָIDźŻLink +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: LinkId +* qw.liu 2022-03-04 +*/ +UINT16 GetSignalProtectLink(const UINT16 signalId); + +/* +* ȡָIDźŻⷽһlink +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: LinkId +* 2022-03-04 +*/ +UINT16 GetSignalOutFirstLink(const UINT16 signalId); + +/* +* ȡָIDźŻ۳·̵ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT16 GetSignalDetainCutRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻ۳·̵2 ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT16 GetSignalDetainCutRelayId_2(const UINT16 signalId); +/* +* ȡָIDźŻ۳״̬ɼ̵2 ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״̬ɼ̵ID +*/ +UINT16 GetSignalDetainRelayId_2(const UINT16 signalId); +/* +* ȡָIDźŻ۳·״ָ̬ʾƼ̵2 ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳·״ָ̬ʾƼ̵ID +*/ +UINT16 GetSignalDetainCutDisRelayId_2(const UINT16 signalId); +/* +* ȡָIDźŻ۳״ָ̬ʾƼ̵2 ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳״ָ̬ʾƼ̵ID +*/ +UINT16 GetSignalDetainDisRelayId_2(const UINT16 signalId); + +/* +* ȡָIDźŻȡ۳ťɼ̵1ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡ۳ť̵1ID +*/ +UINT16 GetSignalCancelDetainBtnRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻȡ۳ťɼ̵2ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡ۳ť̵2ID +*/ +UINT16 GetSigCancelDetainBtnRelayId_2(const UINT16 signalId); + +/* +* ȡָźŻESB +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻESB +*/ +UINT8 GetSignalRelatedEsbSum(const UINT16 signalId); + +/* +* ȡָźŻESBID +* ˵ const UINT16 signalId, źŻID +* ֵ NULL: ȡʧ +* NULL: źŻESBID +*/ +UINT16* GetSignalRelatedEsbBuf(const UINT16 signalId); + +/* +* ȡָIDźŻгź̵IDʹã +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: гź̵ID +*/ +UINT16 GetSignalLxDrvRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻź̵IDʹã +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ź̵ID +*/ +UINT16 GetSignalYxDrvRelayId(const UINT16 signalId); + +/* +* ȡָIDźŻź̵IDʹã +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ź̵ID +*/ +UINT16 GetSignalDxDrvRelayId(const UINT16 signalId); + + +/* +* ȡָIDźŻⷽһ߼ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ߼ID +*/ +UINT16 GetSignalOutFirstLogSec(const UINT16 signalId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Signal/SignalDataManage.c b/TSCP/src/APP/ciapp/Signal/SignalDataManage.c new file mode 100644 index 0000000..a9072a4 --- /dev/null +++ b/TSCP/src/APP/ciapp/Signal/SignalDataManage.c @@ -0,0 +1,5091 @@ +/******************************************************** +* +* SignalDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* źŻݹ +* ޸ļ¼ +* +********************************************************/ + +#include "SignalDataManage.h" +#include "LinkConfigDataManage.h" +#include "CommonMemory.h" +#include "TrainDataManage.h" +#include "AxisSort_api.h" +#include "CutoffPointDataManage.h" +#include "CutoffPointConfigDataManage.h" +#include "TrainOnAcManage.h" +#include "EnvelopeManage.h" + +SignalDataStruct SignalDataStru[SIGNAL_SUM_MAX]; /*źŻݽṹ*/ + + +/* +* ȡָIDź +* ˵ +* ֵ + SignalDataStruct* +*/ +SignalDataStruct *GetSignalData(void) +{ + return SignalDataStru; +} + +/* +* ȡָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSignalFLockState(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 fLockState = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + fLockState = SignalDataStru[bufIndex].FLockState; + } + return fLockState; +} + + +/* +* ָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 fLockState, ״̬ +* ֵ +* +*/ +void SetSignalFLockState(const UINT16 signalId, const UINT8 fLockState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_FENGSUO_NO == fLockState) || (SIGNAL_FENGSUO_YES == fLockState)) + { + SignalDataStru[bufIndex].FLockState= fLockState; /*źŻ״̬*/ + } + } +} + + +/* +* ȡָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSignalLightExtinctState(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 lightExtinctState = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + lightExtinctState = SignalDataStru[bufIndex].LightExtinctState; + } + return lightExtinctState; +} + + +/* +* ָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 ligheCloseState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalLightExtinctState(const UINT16 signalId, const UINT8 lightExtinctState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + UINT8 cSleepTrainLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_NO; /*߳źŻ־*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_ALL_YES == lightExtinctState)) + { + /*SignalDataStru[bufIndex].LightExtinctState = lightExtinctState; źŻ״̬*/ + + reVal = CI_SUCCESS; + + if (SIGNAL_LIGHT_EXTICT_STATE_ALL_YES == lightExtinctState) + {/*ZCͨжϵȫվ ȫЧ*/ + SignalDataStru[bufIndex].LightExtinctState = SIGNAL_LIGHT_EXTICT_STATE_YES; + } + else if (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) + {/*ν״̬Ϊ*/ + if (SignalDataStru[bufIndex].SignalLightOnStateCycCount >= SIGNAL_LIGHTON_MID_COUNT) + {/*֮ǰΪ*/ + /*ӵжϣֹ103 104 103 104...*/ + if (SignalDataStru[bufIndex].SignalLightOnStateCycCount >= (SIGNAL_LIGHTON_MID_COUNT + SIGNAL_LIGHTON_CHECK_VALUE)) + {/*Ч ΪЧ ֹԽ*/ + SignalDataStru[bufIndex].SignalLightOnStateCycCount = (SIGNAL_LIGHTON_MID_COUNT + SIGNAL_LIGHTON_CHECK_VALUE); + + SignalDataStru[bufIndex].LightExtinctState = SIGNAL_LIGHT_EXTICT_STATE_YES; + } + else + { + SignalDataStru[bufIndex].SignalLightOnStateCycCount++; + } + } + else + {/*֮ǰΪ 1*/ + SignalDataStru[bufIndex].SignalLightOnStateCycCount = (SIGNAL_LIGHTON_MID_COUNT + 1U); + } + } + else + {/*ν״̬Ϊ*/ + cSleepTrainLightUpFlag = GetSleepTrainLightUpSignalFlag(signalId); + if (SIGNAL_SLEEP_TRAIN_LIGHTUP_YES != cSleepTrainLightUpFlag) + { + /*߳ƣ*/ + if (SignalDataStru[bufIndex].SignalLightOnStateCycCount < SIGNAL_LIGHTON_MID_COUNT) + {/*֮ǰΪ*/ + /*ӵжϣֹ97 96 97 96...*/ + if (SignalDataStru[bufIndex].SignalLightOnStateCycCount <= (SIGNAL_LIGHTON_MID_COUNT - SIGNAL_LIGHTON_CHECK_VALUE)) + {/*Ч ΪЧ ֹԽ*/ + SignalDataStru[bufIndex].SignalLightOnStateCycCount = (SIGNAL_LIGHTON_MID_COUNT - SIGNAL_LIGHTON_CHECK_VALUE); + + SignalDataStru[bufIndex].LightExtinctState = SIGNAL_LIGHT_EXTICT_STATE_NO; + } + else + { + SignalDataStru[bufIndex].SignalLightOnStateCycCount--; + } + } + else + {/*֮ǰΪ 1*/ + SignalDataStru[bufIndex].SignalLightOnStateCycCount = (SIGNAL_LIGHTON_MID_COUNT - 1U); + } + } + else + { + /*ǰ߳ƣ*/ + } + } + } + } + return reVal; +} +/* +* ָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 ligheCloseState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetNearCISigLightExtinctState(const UINT16 signalId, const UINT8 lightExtinctState) +{ + UINT16 bufIndex = 0u;/*±*/ + UINT8 reVal = CI_ERROR; + UINT8 localCi = 0u;/*ID*/ + UINT8 belongCiId = 0u;/*·ID*/ + + bufIndex = GetSignalConfigBufIndex(signalId);/*ȡźŻ±*/ + localCi = GetSystemParaLocalCiId();/*ID*/ + belongCiId = GetSignalBelongCiId(signalId);/*ȡźŻ*/ + if(localCi != belongCiId) + { + if (SIGNAL_SUM_MAX > bufIndex) + { + if ((SIGNAL_LIGHT_EXTICT_STATE_NO == lightExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_YES == lightExtinctState) || (SIGNAL_LIGHT_EXTICT_STATE_ALL_YES == lightExtinctState)) + { + SignalDataStru[bufIndex].LightExtinctState = lightExtinctState; + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + else + { + reVal = CI_ERROR; + } + } + else + { + reVal = SetSignalLightExtinctState(signalId,lightExtinctState);/*ñָIDźŻ״̬*/ + } + return reVal; +} + +/* +* ȡָIDźŻ֮ǰʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ֮ǰʾɫ +*/ +UINT8 GetSignalPreColor(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].PreColor; + } + return reVal; +} + +/* +* ȡָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ֮ǰʾɫ +*/ +UINT8 GetSignalCurColor(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].CurColor; + } + return reVal; +} + + +/* +* ָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 curColor, ǰʾɫ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalCurColor(const UINT16 signalId, const UINT8 curColor) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT8 preDrvColor = 0u;/*֮ǰɫ*/ + UINT8 reVal = CI_ERROR; + UINT32 curCycle = 0u;/*ǰ*/ + UINT16 relayId = 0u; + UINT8 relayState = 0u; /*̵״̬*/ + UINT8 signalColorValid = 0u; + + preDrvColor = GetSignalPreDriveColor(signalId);/*ȡ֮ǰɫ*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + curCycle = Get2oo2CurCycleNum();/*ȡǰ*/ + + + if (SIGNAL_SUM_MAX > bufIndex) + { + SignalDataStru[bufIndex].PreColor = SignalDataStru[bufIndex].CurColor;/*źŻ֮ǰʾɫ*/ + + signalColorValid = CheckSignalShowColorValid(curColor); + if (CI_SUCCESS == signalColorValid) + { + SignalDataStru[bufIndex].CurColor = curColor; /*źŻǰʾɫ*/ + + /*Ϊ˽תΪתΪ֮,̵ʼڲ*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = 0u;/*źŻ̵ʼ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + + /*ǰ̵*/ + if (SIGNAL_SHOWCOLOUR_GREEN == SignalDataStru[bufIndex].CurColor) + { + /*̵δ˿*/ + SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_NO; + } + /*Ƶ*/ + else if(SIGNAL_SHOWCOLOUR_YELLOW == SignalDataStru[bufIndex].CurColor) + { + /*ûƵδ˿*/ + SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO; + } + /*׵*/ + else if(SIGNAL_SHOWCOLOUR_WHITE == SignalDataStru[bufIndex].CurColor) + { + /*ð׵δ˿*/ + SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_NO; + } + /**/ + else if(SIGNAL_SHOWCOLOUR_REDYELLOW == SignalDataStru[bufIndex].CurColor) + { + /*úƵδ˿*/ + SignalDataStru[bufIndex].RedYellowDsBreakFlag = SIGNAL_DS_BREAK_NO; + } + /**/ + else if(SIGNAL_SHOWCOLOUR_RED_WHITE == SignalDataStru[bufIndex].CurColor) + { + /*ú׵δ˿*/ + SignalDataStru[bufIndex].RedWhiteDsBreakFlag = SIGNAL_DS_BREAK_NO; + } + /*̻*/ + else if(SIGNAL_SHOWCOLOUR_GREENYELLOW == SignalDataStru[bufIndex].CurColor) + { + /*̻Ƶδ˿*/ + SignalDataStru[bufIndex].GreenYellowDsBreakFlag = SIGNAL_DS_BREAK_NO; + } + /*˫*/ + else if(SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == SignalDataStru[bufIndex].CurColor) + { + /*˫̵δ˿*/ + SignalDataStru[bufIndex].DoubleGreenDsBreakFlag = SIGNAL_DS_BREAK_NO; + } + /*˫*/ + else if(SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == SignalDataStru[bufIndex].CurColor) + { + /*˫Ƶδ˿*/ + SignalDataStru[bufIndex].DoubleYellowDsBreakFlag = SIGNAL_DS_BREAK_NO; + } + else + { + /**/ + } + } + else + {/*ʾɫЧ*/ + + switch (SignalDataStru[bufIndex].PreColor) + { + case SIGNAL_SHOWCOLOUR_RED:/*֮ǰ*/ + if(SIGNAL_DRIVECOLOUR_REDYELLOW == SignalDataStru[bufIndex].PreDriveColor) + {/*״Ϊ:Ƶ,ǺƷ˿*/ + relayId = GetSignalFirstDsRelayId(signalId); + relayState = GetRelayCollState(relayId); + if(RELAY_STATE_UP == relayState) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + else if(SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor) + { + relayId = GetSignalFirstDsRelayId(signalId); + relayState = GetRelayCollState(relayId); + if(RELAY_STATE_UP ==relayState) + {/*״Ϊ:Ƶ(׵)תΪ,2DJδʱ*/ + if(RELAY_STATE_UP == GetRelayCollState(GetSignalSecondDsRelayId(signalId))) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + else if(SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor) + { + if(SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if(SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if(SIGNAL_DRIVECOLOUR_GREENCLOSE == SignalDataStru[bufIndex].PreDriveColor) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if(SIGNAL_DRIVECOLOUR_YELLOWCLOSE == SignalDataStru[bufIndex].PreDriveColor) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_RED_WHITE == SignalDataStru[bufIndex].PreDriveColor) + {/*״Ϊ:׵,ǺƷ˿*/ + if(GetRelayCollState(GetSignalFirstDsRelayId(signalId)) == RELAY_STATE_UP) + {/*2DJɼЧɫʱֺƣȴ2DJ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + else if (SIGNAL_DRIVECOLOUR_GREENYELLOW == SignalDataStru[bufIndex].PreDriveColor)/*--->̻*/ + {/*״Ϊ:̻Ƶ*/ + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_YELLOW == SignalDataStru[bufIndex].PreDriveColor)/*֮ǰƵ,-->*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE == SignalDataStru[bufIndex].PreDriveColor)/*֮ǰ̻,-->̻*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_DOUBLE_GREEN == SignalDataStru[bufIndex].PreDriveColor)/*֮ǰ˫,-->˫*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW == SignalDataStru[bufIndex].PreDriveColor)/*֮ǰ˫,-->˫*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_GREEN == SignalDataStru[bufIndex].PreDriveColor)/*֮ǰ̵,-->*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + } + break; + case SIGNAL_SHOWCOLOUR_GREEN:/*֮ǰ*/ + if(SIGNAL_DRIVECOLOUR_GREENCLOSE == SignalDataStru[bufIndex].PreDriveColor) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + if (SIGNAL_OPEN_TO_CLOSE_TIME_DELAY >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE == SignalDataStru[bufIndex].PreDriveColor)/*--̻*/ + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*źŻ̵*/ + } + else + { + if (SIGNAL_OPEN_TO_CLOSE_TIME_DELAY >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*źŻ̵*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_GREENYELLOW == SignalDataStru[bufIndex].PreDriveColor)/*--̻*/ + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*źŻ̵*/ + } + else + { + if (SIGNAL_OPEN_TO_CLOSE_TIME_DELAY >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREEN;/*źŻ̵*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor)/*-->*/ + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_YELLOW == SignalDataStru[bufIndex].PreDriveColor)/*-->*/ + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_GREEN;/*źŻ̵*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_GREEN;/*źŻ̵*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + /*̵*/ + else if(SIGNAL_DRIVECOLOUR_GREEN == SignalDataStru[bufIndex].PreDriveColor) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_YES;/*̵ƶ˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + break; + case SIGNAL_SHOWCOLOUR_YELLOW:/*֮ǰ*/ + if(SIGNAL_DRIVECOLOUR_YELLOWCLOSE == SignalDataStru[bufIndex].PreDriveColor) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOW;/*źŻ*/ + } + else + { + if (SIGNAL_RELAY_ACTION_TIMEMAX >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOW;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + if (SIGNAL_OPEN_TO_CLOSE_TIME_DELAY >= (curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum)) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor)/*-->*/ + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_OPEN_TO_CLOSE_TIME_DELAY) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_GREEN == SignalDataStru[bufIndex].PreDriveColor)/*-->*/ + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_YELLOW;/*źŻƵ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_YELLOW;/*źŻƵ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + /*Ƶ*/ + else if(SIGNAL_DRIVECOLOUR_YELLOW == SignalDataStru[bufIndex].PreDriveColor) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*ûƵƶ˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + break; + case SIGNAL_SHOWCOLOUR_WHITE:/*֮ǰ*/ + /*׵*/ + if(SIGNAL_DRIVECOLOUR_WHITE == SignalDataStru[bufIndex].PreDriveColor) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_WHITEBREAK;/*źŻ׶*/ + SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_YES;/*ð׵ƶ˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_WHITEBREAK;/*źŻ׶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + + break; + case SIGNAL_SHOWCOLOUR_REDYELLOW:/*֮ǰ*/ + if (GetRelayCollState(GetSignalFirstDsRelayId(signalId)) == RELAY_STATE_DOWN) + {/*1˿̵*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + if(GetRelayCollState(GetSignalSecondDsRelayId(signalId)) == RELAY_STATE_DOWN) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDYELLOW;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + SignalDataStru[bufIndex].RedYellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*úƶ˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDYELLOW;/*źŻ*/ + } + } + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + } + + break; + case SIGNAL_SHOWCOLOUR_GREENCLOSE:/*֮ǰ*/ + if (preDrvColor == SIGNAL_DRIVECOLOUR_GREEN) + { + /*֮ǰ*/ + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*źŻ*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_OPEN_TO_CLOSE_TIME_DELAY) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor)/*𵽺*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_GREENYELLOW == SignalDataStru[bufIndex].PreDriveColor)/*-->̻*/ + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_OPEN_TO_CLOSE_TIME_DELAY) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENCLOSE;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + break; + case SIGNAL_SHOWCOLOUR_YELLOWCLOSE:/*֮ǰ*/ + if (preDrvColor == SIGNAL_DRIVECOLOUR_YELLOW) + {/*֮ǰΪ*/ + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWCLOSE;/*źŻ*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_RED == SignalDataStru[bufIndex].PreDriveColor) + { + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_OPEN_TO_CLOSE_TIME_DELAY) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_REDCLOSE == SignalDataStru[bufIndex].PreDriveColor) + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + break; + case SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE:/*֮ǰ̻*/ + { + if (SIGNAL_DRIVECOLOUR_GREENYELLOW == preDrvColor)/*̻-->̻*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*źŻ̻*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*źŻ̻*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_GREEN == preDrvColor)/*̻-->*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*źŻ̻*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*źŻ̻*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_GREENCLOSE == preDrvColor)/*̻-->*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*źŻ̻*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE;/*źŻ̻*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_RED == preDrvColor)/*̻-->*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_REDCLOSE == preDrvColor)/*̻-->*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_REDCLOSE;/*źŻ*/ + } + } + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + break; + case SIGNAL_SHOWCOLOUR_REDCLOSE:/*֮ǰ*/ + if (preDrvColor == SIGNAL_DRIVECOLOUR_RED) + {/*֮ǰΪ*/ + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + } + } + else if(SIGNAL_DRIVECOLOUR_REDCLOSE == preDrvColor) + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + } + } + else if ((SIGNAL_DRIVECOLOUR_YELLOW==preDrvColor ) || (SIGNAL_DRIVECOLOUR_YELLOWCLOSE==preDrvColor ) + || (SIGNAL_DRIVECOLOUR_GREEN==preDrvColor ) || (SIGNAL_DRIVECOLOUR_GREENCLOSE==preDrvColor ) + || (SIGNAL_DRIVECOLOUR_GREENYELLOW==preDrvColor)) + { + if (0u ==SignalDataStru[bufIndex].RelayActaionStartCycNum ) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDCLOSE;/*źŻ*/ + } + } + + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + break; + case SIGNAL_SHOWCOLOUR_RED_WHITE:/*֮ǰ*/ + if (GetRelayCollState(GetSignalFirstDsRelayId(signalId)) == RELAY_STATE_DOWN) + {/*1˿̵*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + if(GetRelayCollState(GetSignalSecondDsRelayId(signalId)) == RELAY_STATE_DOWN) + {/*źűڼ2DJ*/ + if (SignalDataStru[bufIndex].RelayActaionStartCycNum == 0u) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = Get2oo2CurCycleNum();/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED_WHITE;/*źŻ*/ + } + else + { + if ((Get2oo2CurCycleNum() - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + SignalDataStru[bufIndex].RedWhiteDsBreakFlag = SIGNAL_DS_BREAK_YES;/*ú׶˿־*/ + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED_WHITE;/*źŻ*/ + } + } + } + else + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_RED;/*źŻ*/ + } + } + break; + case SIGNAL_SHOWCOLOUR_GREENYELLOW:/*֮ǰʾ̻Ƶ*/ + { + if (SIGNAL_DRIVECOLOUR_GREEN == preDrvColor)/*֮ǰ̵ƣ̻--̣10*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*źŻ̻*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*źŻ̻*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_REDCLOSE == preDrvColor)/*֮ǰ̵ƣ̻--10*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*źŻ̻*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*źŻ̻*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if (SIGNAL_DRIVECOLOUR_RED == preDrvColor)/*֮ǰ̵ƣ̻--죬10*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + else if ((SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE == preDrvColor) || + (SIGNAL_DRIVECOLOUR_GREENCLOSE == preDrvColor))/*֮ǰ̵ƣ̻--̻/10*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*źŻ̻*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENYELLOW;/*źŻ̻*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + /*̻Ƶ*/ + else if(SIGNAL_DRIVECOLOUR_GREENYELLOW == preDrvColor) + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].GreenYellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*̻ƶ˿־*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + break; + case SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW:/*֮ǰʾ˫Ƶ*/ + { + if (SIGNAL_DRIVECOLOUR_RED == preDrvColor)/*˫Ƶ*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + /*˫*/ + else if(SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW == preDrvColor) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DoubleYellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*˫ƶ˿־*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_YELLOWBREAK;/*źŻƶ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + break; + case SIGNAL_SHOWCOLOUR_DOUBLE_GREEN:/*֮ǰʾ˫̵*/ + { + if (SIGNAL_DRIVECOLOUR_RED == preDrvColor)/*˫̵*/ + { + if (0u == SignalDataStru[bufIndex].RelayActaionStartCycNum) + { + /*̵ʼΪ0*/ + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) <= SIGNAL_RELAY_ACTION_TIMEMAX) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_DRIVECOLOUR_RED;/*źŻ*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + /*˫*/ + else if(SIGNAL_DRIVECOLOUR_DOUBLE_GREEN == preDrvColor) + { + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DoubleGreenDsBreakFlag = SIGNAL_DS_BREAK_YES;/*˫̶˿־*/ + } + else + { + /*̵ʱȴ*/ + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_GREENBREAK;/*źŻ̶*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + break; + case SIGNAL_SHOWCOLOUR_GREENBREAK:/*̶*/ + case SIGNAL_SHOWCOLOUR_YELLOWBREAK:/*ƶ*/ + case SIGNAL_SHOWCOLOUR_WHITEBREAK:/*׶*/ + {/*֮ǰɫΪǺƶ˿̶ϻ߻ƶϻ߰׶ϣƻʱ*/ + if ((SIGNAL_DRIVECOLOUR_RED == preDrvColor) || (SIGNAL_SHOWCOLOUR_REDCLOSE == preDrvColor)) + { + if (0u ==SignalDataStru[bufIndex].RelayActaionStartCycNum ) + {/*̵ʼΪ0*/ + + SignalDataStru[bufIndex].RelayActaionStartCycNum = curCycle;/*õǰ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + if ((curCycle - SignalDataStru[bufIndex].RelayActaionStartCycNum) > SIGNAL_RELAY_ACTION_TIMEMAX) + {/*̵ʱȴ*/ + + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + else + { + /*źŻǰɫãάַǺƶ˿*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + } + } + } + } + break; + default: + SignalDataStru[bufIndex].CurColor = SIGNAL_SHOWCOLOUR_REDBREAK;/*źŻ*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + break; + } + } + + /*źŻ*/ + if (GetSignalOpenCloseState(curColor) == SIGNAL_OPEN) + { + /*ź*/ + SignalDataStru[bufIndex].DriveSigOpenStartCycNum = 0u; + } + else + {/*źر*/ + + /*źر*/ + SignalDataStru[bufIndex].DriveSigCloseStartCycNum = 0u; + } + + reVal = CI_SUCCESS; + } + return reVal; +} +/* +* ָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 curColor, ǰʾɫ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetNearCISignalCurColor(const UINT16 signalId, const UINT8 curColor) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 localCi = 0u;/*ID*/ + UINT8 belongCiId = 0u;/*·ID*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + localCi = GetSystemParaLocalCiId();/*ID*/ + belongCiId = GetSignalBelongCiId(signalId);/*ȡźŻ*/ + if(localCi !=belongCiId) + { + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].PreColor = SignalDataStru[bufIndex].CurColor;/*źŻ֮ǰʾɫ*/ + SignalDataStru[bufIndex].CurColor = curColor; /*źŻǰʾɫ*/ + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + else + { + reVal = SetSignalCurColor(signalId,curColor); + } + return reVal; +} +/* +* ȡָIDźŻ֮ǰʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʾɫ +*/ +UINT8 GetSignalPreDriveColor(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].PreDriveColor; + } + return reVal; +} + +/* +* ָIDźŻ֮ǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 driveColor, ʾɫ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalPreDriveColor(const UINT16 signalId, const UINT8 driveColor) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if (SignalDataStru[bufIndex].PreDriveColor != driveColor) + { + /*һѾı ù*/ + (void)SetSignalDiffColorOpenStartCyc(signalId, 0U); /*źŻɫڵǰɫʼ*/ + } + SignalDataStru[bufIndex].PreDriveColor = driveColor; + + reVal = CI_SUCCESS; + } + return reVal; +} + +/* +* ȡָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʾɫ +*/ +UINT8 GetSignalCurDriveColor(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].CurDriveColor; + } + return reVal; +} + + +/* +* ָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 driveColor, ʾɫ +* ֵ +* +*/ +void SetSignalCurDriveColor(const UINT16 signalId, const UINT8 driveColor) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 curDrvColor = 0u;/*ǰɫ*/ + UINT8 sigDrvEnable = 0u;/*źŻǷ־*/ + UINT8 sigVirtAttr = 0u;/*źŻ*/ + UINT8 localCiPattern = CI_PATTERN_TRADITIONAL; + UINT8 chDriveColor = SIGNAL_DRIVECOLOUR_RED; + UINT8 funSwitchGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*ʾ̻ƹܿǷ*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + curDrvColor = GetSignalCurDriveColor(signalId);/*ȡǰɫ*/ + sigDrvEnable = GetSignalDrvEnable(signalId);/*ȡźŻǷ־*/ + sigVirtAttr = GetSignalVirtualAttr(signalId);/*ȡźŻ*/ + + localCiPattern = GetLocalCiPattern(); + if (CI_PATTERN_FULL_ELECTRONIC == localCiPattern) + { + sigDrvEnable = SIGNAL_DRV_ENABLE; + } + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((CI_SUCCESS == CheckSignalDriveColorValid(driveColor)) && + ((SIGNAL_DRV_ENABLE == sigDrvEnable)|| (SIGNAL_VIRTUAL_YES == sigVirtAttr))) + {/*ɫЧңźŻΪźŻ߿źŻ*/ + if (SIGNAL_DRIVECOLOUR_NULL == driveColor) + { + /*źɫЧ*/ + SignalDataStru[bufIndex].CurDriveColor = SIGNAL_DRIVECOLOUR_NULL; + } + else if ((SIGNAL_DRIVECOLOUR_RED == driveColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == driveColor)) + {/*źŻɫΪ*/ + + if ((FUNC_SWITCH_ON == funSwitchGreenYellow) && (SIGNAL_DRIVECOLOUR_REDCLOSE == driveColor)) + { + chDriveColor = SIGNAL_DRIVECOLOUR_RED; + } + else + { + chDriveColor = driveColor; + } + SignalDataStru[bufIndex].CurDriveColor = chDriveColor; /*źŻǰʾɫ*/ + + if (SignalDataStru[bufIndex].DriveSigCloseStartCycNum == 0u) + { + if (GetSignalType(signalId) == SIGNAL_TYPE_TWO_JINKU_RGY) + { + /**/ + SignalDataStru[bufIndex].DriveSigCloseStartCycNum = 0u; + } + else + { + /*źر*/ + SignalDataStru[bufIndex].DriveSigCloseStartCycNum = Get2oo2CurCycleNum(); + } + + + } + else + { + /**/ + } + + /*ź*/ + SignalDataStru[bufIndex].DriveSigOpenStartCycNum = 0u; + } + else if(SIGNAL_DRIVECOLOUR_NULL == curDrvColor)/*֮ǰΪЧ*/ + {/*ź*/ + + SignalDataStru[bufIndex].CurDriveColor = driveColor; /*źŻǰʾɫ*/ + + /*źر*/ + SignalDataStru[bufIndex].DriveSigCloseStartCycNum = 0u; + + if (SignalDataStru[bufIndex].DriveSigOpenStartCycNum == 0u) + { + + if (GetSignalType(signalId) == SIGNAL_TYPE_TWO_JINKU_RGY) + { + /**/ + SignalDataStru[bufIndex].DriveSigOpenStartCycNum = 0u; + } + else + { + /*ź*/ + SignalDataStru[bufIndex].DriveSigOpenStartCycNum = Get2oo2CurCycleNum(); + } + + } + else + { + /**/ + } + } + else + {/**/ + + /**/ + } + } + else + { + /*źɫЧ*/ + SignalDataStru[bufIndex].CurDriveColor = SIGNAL_DRIVECOLOUR_NULL; + } + + if( (SignalDataStru[bufIndex].PreDriveColor != SignalDataStru[bufIndex].CurDriveColor) + && + (SignalDataStru[bufIndex].CurDriveColor != SIGNAL_DRIVECOLOUR_NULL)) + {/*źɫIJҸɫЧʱ,ɫʼں,±֮ǰɫ.δΪ˽̻ʱ,ڼֻƵƵ*/ + SignalDataStru[bufIndex].DriveNewSigStartCycNum = Get2oo2CurCycleNum(); + SignalDataStru[bufIndex].OldDriveColor = SignalDataStru[bufIndex].PreDriveColor; + } + else + { + /*κδ*/ + ; + } + } + else + { + /**/ + } +} + + +/* +* ȡָIDźŻ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].DsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻ̵˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalGreenDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].GreenDsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻƵ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalYellowDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].YellowDsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻ׵˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalWhiteDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].WhiteDsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻƵ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalRedYellowDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].RedYellowDsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻ׵˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalRedWhiteDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].RedWhiteDsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻ̻Ƶ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalGreenYellowDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].GreenYellowDsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻ˫̵˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalDoubleGreenDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].DoubleGreenDsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻ˫Ƶ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSigDoubleYellowDsBreakFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].DoubleYellowDsBreakFlag; + } + return reVal; +} + +/* +* ȡָIDźŻʼں +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSignalDriveOpenStartCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].DriveSigOpenStartCycNum; + } + return reVal; +} + +/* +* ȡָIDźŻرʼں +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: رʼں +*/ +UINT32 GetSignalDriveCloseStartCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].DriveSigCloseStartCycNum; + } + return reVal; +} + +/* +* ȡָIDźŻźʼں +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źʼں +*/ +UINT32 GetSignalDriveNewSigStartCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].DriveNewSigStartCycNum; + } + + return reVal; +} + +/* +* ȡָIDźŻźŻɫ仯֮ǰ,źŻʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʾɫ +*/ +UINT8 GetSignalOldDriveColor(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].OldDriveColor; + } + + return reVal; +} + +/* +* źŻʾɫЧ +* ˵ const UINT8 showColor, źŻʾɫ +* ֵ 0: ʾЧ +* 1: ʾЧ +*/ +UINT8 CheckSignalShowColorValid(const UINT8 showColor) +{ + UINT8 reVal = CI_ERROR; + + if ((SIGNAL_SHOWCOLOUR_RED == showColor) || (SIGNAL_SHOWCOLOUR_GREEN == showColor) || (SIGNAL_SHOWCOLOUR_YELLOW == showColor) + || (SIGNAL_SHOWCOLOUR_REDYELLOW == showColor) || (SIGNAL_SHOWCOLOUR_WHITE == showColor) || (SIGNAL_SHOWCOLOUR_REDCLOSE == showColor) + || (SIGNAL_SHOWCOLOUR_GREENCLOSE == showColor) || (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == showColor) || (SIGNAL_SHOWCOLOUR_RED_WHITE == showColor) + || (SIGNAL_SHOWCOLOUR_GREENYELLOW == showColor) || (SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == showColor) + || (SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == showColor) || (SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == showColor) + ) + { + reVal = CI_SUCCESS; /*źŻʾЧ*/ + } + return reVal; +} + + +/* +* źŻɫЧ +* ˵ const UINT8 drvColor, źŻɫ +* ֵ 0: Ч +* 1: Ч +*/ +UINT8 CheckSignalDriveColorValid(const UINT8 drvColor) +{ + UINT8 reVal = CI_ERROR; + + + if ((SIGNAL_DRIVECOLOUR_RED == drvColor) || (SIGNAL_DRIVECOLOUR_YELLOW == drvColor) || (SIGNAL_DRIVECOLOUR_REDYELLOW == drvColor) + || (SIGNAL_DRIVECOLOUR_GREEN == drvColor) || (SIGNAL_DRIVECOLOUR_YELLOWCLOSE == drvColor) || (SIGNAL_DRIVECOLOUR_REDCLOSE == drvColor) + || (SIGNAL_DRIVECOLOUR_GREENCLOSE == drvColor) || (SIGNAL_DRIVECOLOUR_WHITE == drvColor)|| (SIGNAL_DRIVECOLOUR_RED_WHITE == drvColor) + || (SIGNAL_DRIVECOLOUR_GREENYELLOW == drvColor) || (SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE == drvColor) + || (SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == drvColor) || (SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == drvColor) + ||(SIGNAL_DRIVECOLOUR_NULL == drvColor)) + { + reVal = CI_SUCCESS; /*źŻЧ*/ + } + + return reVal; +} + + +/* +* ȡͨųѹͨźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalCrossState(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_CROSS_STATE_NO == SignalDataStru[bufIndex].SignalCrossState) || (SIGNAL_CROSS_STATE_YES == SignalDataStru[bufIndex].SignalCrossState)) + { + reVal = SignalDataStru[bufIndex].SignalCrossState; + } + } + return reVal; +} + + +/* +* ͨųѹͨźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +*/ +UINT8 SetSignalCrossState(const UINT16 signalId, const UINT8 signalCrossState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_CROSS_STATE_NO == signalCrossState) || (SIGNAL_CROSS_STATE_YES == signalCrossState)) + { + SignalDataStru[bufIndex].SignalCrossState = signalCrossState; /*ͨųѹͨźŻ״̬*/ + reVal = CI_SUCCESS; + } + } + return reVal; +} + +/* +* ȡźŻɫŹر״̬ +* ˵ UINT8 signalColor +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalOpenCloseState(UINT8 signalColor) +{ + UINT8 reVal = SIGNAL_CLOSE; + + if ((SIGNAL_SHOWCOLOUR_GREEN == signalColor) || + (SIGNAL_SHOWCOLOUR_YELLOW == signalColor) || + (SIGNAL_SHOWCOLOUR_REDYELLOW == signalColor) || + (SIGNAL_SHOWCOLOUR_WHITE == signalColor) || + (SIGNAL_SHOWCOLOUR_GREENCLOSE == signalColor) || + (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == signalColor) || + (SIGNAL_SHOWCOLOUR_RED_WHITE == signalColor) || + (SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == signalColor) || + (SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == signalColor) || + (SIGNAL_SHOWCOLOUR_GREENYELLOW == signalColor) || + (SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == signalColor) + ) + { /*̵||Ƶ||Ƶ||׵||||||׵||˫||˫||̻||̻*/ + + reVal = SIGNAL_OPEN; /*źſ*/ + } + return reVal; +} + +/* +* ȡźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalYLockOpenState(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_OPEN == SignalDataStru[bufIndex].SignalYLockOpenState) || (SIGNAL_CLOSE == SignalDataStru[bufIndex].SignalYLockOpenState)) + { + reVal = SignalDataStru[bufIndex].SignalYLockOpenState; + } + } + return reVal; +} + +/* +* ȡźŻеĽ·ǷCBTCĽ·ҲзCBTC·ı־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalLeadRouteCbtcFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_LEADROUTE_ALLCBTC == SignalDataStru[bufIndex].SignalLeadRouteCbtcFlag) + || (SIGNAL_LEADROUTE_ALL_NO_CBTC == SignalDataStru[bufIndex].SignalLeadRouteCbtcFlag) + || (SIGNAL_LEADROUTE_CBTC_ANDNO == SignalDataStru[bufIndex].SignalLeadRouteCbtcFlag)) + { + reVal = SignalDataStru[bufIndex].SignalLeadRouteCbtcFlag; + } + } + return reVal; +} + +/* +* źŻ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 setState, ״̬ +* ֵ +* +*/ +void SetSignalYLockOpenState(const UINT16 signalId, const UINT8 setState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_OPEN == setState) && + (SignalDataStru[bufIndex].SignalLeadProperty == SIGNAL_LEAD_PROPERTY_YES) && + (GetSignalOpenCloseState(GetSignalCurColor(signalId)) == SIGNAL_CLOSE) + ) + { + /*źſ źŻǰر*/ + SignalDataStru[bufIndex].SignalYLockOpenState = setState; /*״̬*/ + } + else if (SIGNAL_CLOSE == setState) + { + SignalDataStru[bufIndex].SignalYLockOpenState = setState; /*״̬*/ + } + else + { + /**/ + } + } +} + +/* +* ȡָIDźŻ۳־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳־ +*/ +UINT8 GetSignalDetainFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + UINT8 sigRelayDetainFlag = SIGNAL_RELAY_DETAIN_NO; /*źŻӲ߿۳־*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + sigRelayDetainFlag = GetSignalRelayDetainFlag(signalId);/*ȡźŻӲ߿۳־*/ + + if (SIGNAL_RELAY_DETAIN_NO == sigRelayDetainFlag) + {/*Ӳδ۳*ȡATSֵؿ۳״̬*/ + + if ((SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag)&& (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto)) + {/*ATSδ۳ δԶ۳δ˹۳*/ + + if (SIGNAL_DETAIN_NO ==SignalDataStru[bufIndex].XiandiDetainFlag ) + {/*ֵδ۳*/ + + reVal = SIGNAL_DETAIN_NO;/*ֵءATSδ۳*/ + } + else + { + /*ֵؿ۳*/ + reVal = SIGNAL_DETAIN_XIANDI;/*ֵؿ۳ATSδ۳*/ + } + } + else + {/*ATS۳*/ + + if (SIGNAL_DETAIN_NO ==SignalDataStru[bufIndex].XiandiDetainFlag ) + {/*ֵδ۳*/ + if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) + {/*ATSδ˹۳*/ + reVal = SIGNAL_DETAIN_ATS_AUTO; + } + else if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto) + { + reVal = SIGNAL_DETAIN_ATS; + } + else + { + ; /**/ + } + + } + else + { + /*ֵؿ۳*/ + if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) + {/*ATSδ˹۳*/ + + reVal = SIGNAL_DETAIN_XIANDI_ATSAUTO;/*ATSԶ۳+ֵؿ۳*/ + } + else if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto) + {/*ATSδԶ۳*/ + reVal = SIGNAL_DETAIN_YES;/*ATS˹۳+ֵؿ۳*/ + } + else + { + ; /**/ + } + } + } + } + else if (SIGNAL_RELAY_DETAIN_YES == sigRelayDetainFlag) + {/*Ӳ߿۳Ч*/ + reVal = SIGNAL_RELAY_DETAIN_YES; /*Ӳ߿۳*/ + } + else + { + /*do noting*/ + } +#if 0 + if (SignalDataStru[bufIndex].AtsDetainFlag == SIGNAL_DETAIN_NO) + {/*ATSδ۳*/ + + if (SignalDataStru[bufIndex].XiandiDetainFlag == SIGNAL_DETAIN_NO) + {/*ֵδ۳*/ + + reVal = SIGNAL_DETAIN_NO;/*ֵءATSδ۳*/ + } + else + { + /*ֵؿ۳*/ + reVal = SIGNAL_DETAIN_XIANDI;/*ֵؿ۳ATSδ۳*/ + } + } + else + {/*ATS۳*/ + + if (SignalDataStru[bufIndex].XiandiDetainFlag == SIGNAL_DETAIN_NO) + {/*ֵδ۳*/ + + reVal = SIGNAL_DETAIN_ATS;/*ֵδ۳ATS۳*/ + } + else + { + /*ֵؿ۳*/ + reVal = SIGNAL_DETAIN_YES;/*ֵؿ۳ATS۳*/ + } + } +#endif + } + return reVal; +} + + + +/* +* ָIDźŻ۳״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 setState, ״̬ +* ֵ +* +*/ +void SetSignalDetainState(const UINT16 signalId, const UINT8 setState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + if (SIGNAL_DETAIN_YES == setState) + {/*ATS˹۳+ֵؿ۳*/ + + SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_YES; + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_YES; + } + else if (SIGNAL_DETAIN_NO == setState) + {/*ATSֵؾδ۳*/ + + SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_NO; + } + else if (SIGNAL_DETAIN_XIANDI == setState) + {/*ֵذ۳*/ + + SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_YES; + } + else if (SIGNAL_DETAIN_ATS == setState) + {/*ATS˹۳*/ + + SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_YES; + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_NO; + } + else if (SIGNAL_DETAIN_ATS_AUTO == setState) + {/*ATSԶ۳*/ + + SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_YES; + SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_NO; + } + else if (SIGNAL_DETAIN_XIANDI_ATSAUTO == setState) + {/*ATSԶ۳+ֵؿ۳*/ + + SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_YES; + SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_YES; + } + else + { + /**/ + } + } +} + +/* +* ָIDźŻ۳־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 setState, ״̬ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetSignalDetainFlag(const UINT16 signalId, const UINT8 setState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + if (SIGNAL_DETAIN_ATS == setState) + {/*ats˹۳*/ + + /*ѰATSԶ۳ תΪATS˹۳*/ + if (SIGNAL_DETAIN_YES == SignalDataStru[bufIndex].AtsDetainFlagAuto) + { + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO; + } + SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_YES; + reVal = CI_SUCCESS; + } + else if (SIGNAL_DETAIN_ATS_AUTO == setState) + {/*atsԶ۳*/ + + /*ѰATS˹۳ ٰԶ۳*/ + if (SIGNAL_DETAIN_YES == SignalDataStru[bufIndex].AtsDetainFlag) + { + reVal = CI_ERROR; + } + else + { + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_YES; + reVal = CI_SUCCESS; + } + } + else if (SIGNAL_DETAIN_ATS_NO == setState) + {/*atsȡ۳ ȡ˹Զ۳*/ + + SignalDataStru[bufIndex].AtsDetainFlag = SIGNAL_DETAIN_NO; + SignalDataStru[bufIndex].AtsDetainFlagAuto = SIGNAL_DETAIN_NO; + reVal = CI_SUCCESS; + } + else if (SIGNAL_DETAIN_XIANDI == setState) + {/*ֵذ۳*/ + + SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_YES; + reVal = CI_SUCCESS; + } + else if (SIGNAL_DETAIN_XIANDI_NO == setState) + {/*ֵȡ۳*/ + + SignalDataStru[bufIndex].XiandiDetainFlag = SIGNAL_DETAIN_NO; + reVal = CI_SUCCESS; + } + else if (SIGNAL_DETAIN_CI_RELAY_YES == setState) + {/*Ӳ߿۳*/ + + SignalDataStru[bufIndex].RealyDetainFlag = SIGNAL_RELAY_DETAIN_YES; + reVal = CI_SUCCESS; + } + else if (SIGNAL_DETAIN_CI_RELAY_NO == setState) + {/*ȡӲ߿۳*/ + + SignalDataStru[bufIndex].RealyDetainFlag = SIGNAL_RELAY_DETAIN_NO; + reVal = CI_SUCCESS; + } + else + { + reVal = CI_ERROR; + } + } + return reVal; +} + +/* +* ȡԶźŶӦĽ·ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻID +*/ +UINT16 GetSignalAutoRouteId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 returnValue = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡָźŻ*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + returnValue = SignalDataStru[bufIndex].AutoRouteId; + } + + return returnValue; +} + +/* +* ԶźŶӦԶźŻID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalAutoRouteId(const UINT16 signalId,const UINT16 routeId) +{ + UINT8 ret = CI_SUCCESS; + UINT16 bufIndex = 0u; /*±*/ + + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡָźŻ*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].AutoRouteId = routeId; + } + else + { + ret = CI_ERROR; + } + + return ret; +} + + +/* +* ȡָIDźŻʱñ־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʱ״̬ +*/ +UINT8 GetSignalLinShiXianSuSetFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 funRetVal = 0u; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + funRetVal = SignalDataStru[bufIndex].LinShiXianSuSetFlag; + } + else + { + funRetVal = CI_ERROR; + } + return funRetVal; +} + + +/* +* ָIDźŻʱٱ־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 setState, ״̬ +* ֵ +* +*/ +void SetSignalLinShiXianSuSetFlag(const UINT16 signalId, const UINT8 linShiXianSuSetState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_LINSHIXIANSUSET_STATE_NO == linShiXianSuSetState) || + (SIGNAL_LINSHIXIANSUSET_STATE_YES == linShiXianSuSetState) || + (SIGNAL_LINSHIXIANSUSET_STATE_INVALID == linShiXianSuSetState)) + { + SignalDataStru[bufIndex].LinShiXianSuSetFlag = linShiXianSuSetState; /*źŻʱٱ־*/ + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +UINT8 GetSignalPLockCommand(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 funRetVal = 0u; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + funRetVal = SignalDataStru[bufIndex].PLockCommand; + } + else + { + funRetVal = CI_ERROR; + } + return funRetVal; +} + + +/* +* ָIDźŻ쳣رձ־ +* ˵ const UINT16 signalId, źŻID + const UINT8 curColor, ǰʾɫ + const UINT8 setStateǰ״̬ +* ֵ +* +*/ +void SetSignalPLockCommand(const UINT16 signalId, const UINT8 pLockCommand) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].PLockCommand = pLockCommand; /*߼֮ǰռ״̬*/ + + } + else + { + /**/ + } +} + +/* +* ȡźŻͨЧ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: Ч +*/ +UINT8 GetSignalProSecValid(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 funRetVal = 0u; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + funRetVal = SignalDataStru[bufIndex].ProSecValid; + } + else + { + funRetVal = CI_ERROR; + } + return funRetVal; +} + + +/* +* źŻͨЧ +* ˵ +const UINT16 signalId, źŻID +const UINT8 proSecValid:Ч +* ֵ: +* +* +*/ +void SetSignalProSecValid(const UINT16 signalId, const UINT8 proSecValid) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_PRO_SEC_VALID == proSecValid) || (SIGNAL_PRO_SEC_INVALID == proSecValid)) + { + SignalDataStru[bufIndex].ProSecValid = proSecValid; + } + else + { + /**/ + } + } + else + { + /**/ + } +} +/* +* źŻɫѾţĿɫ¼ù̬ʼ +* ˵ + const UINT16 signalId, źŻID + const UINT32 cycNum:ʼں +* ֵ: +* 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalDiffColorOpenStartCyc(const UINT16 signalId,const UINT32 cycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 funRetVal = 0u; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].DiffColorOpenStartCycNum = cycNum; + + funRetVal = CI_SUCCESS; + } + else + { + funRetVal = CI_ERROR; + } + return funRetVal; +} + +/* +* ȡźŻɫѾţĿɫ¼ù̬ʼ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSignalDiffColorOpenStartCyc(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].DiffColorOpenStartCycNum; + } + + return reVal; +} + +/* +* ָIDźŻɼʼں +* ˵ + const UINT16 signalId, źŻID + const UINT32 cycNum:ʼں +* ֵ: +* 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalCollOpenStartCycNum(const UINT16 signalId,const UINT32 cycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 funRetVal = 0u; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].CollSigOpenStartCycNum = cycNum; + + funRetVal = CI_SUCCESS; + } + else + { + funRetVal = CI_ERROR; + } + return funRetVal; +} + +/* +* ȡָIDźŻɼʼں +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSignalCollOpenStartCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].CollSigOpenStartCycNum; + } + return reVal; +} + +/* +* ȡźŻӲ߿۳״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalRelayDetainFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_RELAY_DETAIN_NO == SignalDataStru[bufIndex].RealyDetainFlag ) || (SIGNAL_RELAY_DETAIN_YES == SignalDataStru[bufIndex].RealyDetainFlag)) + { + reVal = SignalDataStru[bufIndex].RealyDetainFlag; + } + } + return reVal; +} + + +/* +* źŻӲ߿۳״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ +* +*/ +void SetSignalRelayDetainFlag(const UINT16 signalId, const UINT8 signalRelayDetainState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_RELAY_DETAIN_NO == signalRelayDetainState) || (SIGNAL_RELAY_DETAIN_YES == signalRelayDetainState)) + { + SignalDataStru[bufIndex].RealyDetainFlag = signalRelayDetainState; /*źŻӲ߿۳״̬*/ + } + } +} + +#if 0 + + +/* +* ȡźŻӲ߿۳ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalRelayDetainCmd(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_DETAIN_CI_RELAY_NO == SignalDataStru[bufIndex].RealyDetainFlag ) || + (SIGNAL_DETAIN_CI_RELAY_YES == SignalDataStru[bufIndex].RealyDetainFlag) ) + { + reVal = SignalDataStru[bufIndex].RelayDetainCmd; + } + } + return reVal; +} +#endif + +/* +* źŻӲ߿۳ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +*/ +UINT8 SetSignalRelayDetainCmd(const UINT16 signalId, const UINT8 signalRelayDetainCmd) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_DETAIN_CI_RELAY_NO == signalRelayDetainCmd) || + (SIGNAL_DETAIN_CI_RELAY_YES == signalRelayDetainCmd) ) + { + SignalDataStru[bufIndex].RelayDetainCmd = signalRelayDetainCmd; /*źŻӲ߿۳״̬*/ + reVal = CI_SUCCESS; + } + } + return reVal; +} + + +/*******************NeighbourSignalDetainDrive վźŻ۳***************************************/ + +/* +* ȡվźŻ۳ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalNeighbourDetainDrive(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO == SignalDataStru[bufIndex].NeighbourSignalDetainDrive ) || + (NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES == SignalDataStru[bufIndex].NeighbourSignalDetainDrive) ) + { + reVal = SignalDataStru[bufIndex].NeighbourSignalDetainDrive; + } + } + return reVal; +} + + +/* +* վźŻ۳ +* ˵ const UINT16 signalId, źŻID +* const UINT8 drive۳ +* ֵ +* +*/ +void SetSignalNeighbourDetainDrive(const UINT16 signalId, const UINT8 drive) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES == drive) || + (NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO == drive) ) + { + SignalDataStru[bufIndex].NeighbourSignalDetainDrive = drive; /*վźŻ۳*/ + } + } +} + + +/*******************NeighbourSignalDetainDrive վźŻ۳******END*********************************/ + +/* +* ȡָIDźŻ֮ǰ仯ʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ֮ǰ仯ʾɫ +*/ +UINT8 GetSignalPreChangedDriveColor(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].PreChangedDriveColor; + } + return reVal; +} + +/* +* ָIDźŻ֮ǰ仯ʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 driveColor, ʾɫ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalPreChangedDriveColor(const UINT16 signalId, const UINT8 driveColor) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].PreChangedDriveColor = driveColor; + + reVal = CI_SUCCESS; + } + return reVal; +} + +/* +* ά޵״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 maintainState, ά޵״̬ +* ֵ void +*/ +void SetSignalMaintainState(const UINT16 signalId, const UINT8 maintainState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + if((MAINTAIN_STATE_YES ==maintainState)||(MAINTAIN_STATE_NO == maintainState)) + { + SignalDataStru[bufIndex].MaintainLightState = maintainState; + } + + } +} + +/* +* ȡά޵״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: ά޵״̬ +*/ +UINT8 GetSignalMaintainState(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].MaintainLightState; + } + return reVal; +} + +/* +* źŻνӽгID +* ˵ const UINT16 signalId, źŻID +* const UINT8 maintainState, ά޵״̬ +* ֵ void +*/ +void SetSignalLightUpTrainId(const UINT16 signalId, const UINT16 wTrainId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + SignalDataStru[bufIndex].wSignalLightUpTrainId = wTrainId; + } +} + +/* +* ȡźŻνӽгID +* ˵ const UINT16 signalId, źŻID +* ֵ νӽгID +* 0:ʧ +*/ +UINT16 GetSignalLightUpTrainId(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].wSignalLightUpTrainId; + } + else + { + reVal = CI_ERROR; + } + return reVal; +} + +/* +* ȡźŻlinkĿ +* ˵ const UINT16 signalId, źŻID +* ֵ linkĿ +* create 2022.3.4 +*/ +UINT16 GetSignalLightUpLinkIdSum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = 0u; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].wSignalLightUpLinkIdSum; + } + return reVal; +} + +/* +* ȡźŻLINK +* ˵ const UINT16 signalId, źŻID +* ֵ link +* create 2022.3.4 +*/ +UINT16 * GetSignalLightUpLinkIdBuf(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 * reVal = NULL; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + reVal = SignalDataStru[bufIndex].szSignalLightUpLinkIdBuf; + } + return reVal; +} + +/** +* @brief źŻlink +* @param wSignalId źŻ +* @param pLinkNum link +* @param szLinkIdBuf link +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +* ޸bug YF0083-119 +*/ +UINT8 CalSignalLightUpLinkSeq(IN const UINT16 wSignalId, OUT UINT16 * pLinkNum, OUT UINT16 szLinkIdBuf[]) +{ + UINT8 cRetVal = CI_ERROR; + UINT8 cKeepWork = CI_ERROR; + UINT16 wLightUpLinkSum = 0u; + UINT16 wszLightUpLinkIdBuf[MAX_SIGNAL_LIGHTUPLINK_NUM] = { 0u }; + UINT16 wSignalOutFirstLinkId = 0u; + UINT16 wSignalProtectLinkId = 0U; /*źŻlinkID*/ + UINT32 dwSignalOutFirstLinkOff = 0u; + UINT32 dwSignalLightUpLinkLength = 0u; /*źŻƾ*/ + UINT8 cSignalProtectDir = UINT8_MAX; + UINT32 dwSearchLen = UINT32_MAX; + UINT16 wCurrentLink = UINT16_MAX; + UINT16 wNextLink = UINT16_MAX; + UINT16 wPointId = UINT16_MAX; + UINT8 cSearchDir = UINT8_MAX; + UINT8 cRetMem = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 cDirectionPointCnt = 0U; /*仯*/ + + dwSignalLightUpLinkLength = GetSystemParaValue(SIGNAL_LIGHTUP_SEC_LEN_ID); + dwSignalLightUpLinkLength *= 100u; + + /*μ*/ + if ((0u < wSignalId) && (SIGNAL_SUM_MAX > wSignalId)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == cKeepWork) + { + /*μ*/ + if ((NULL != pLinkNum) && (NULL != szLinkIdBuf)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + + } + + if (CI_SUCCESS == cKeepWork) + { + /* ݼ */ + if ((0u != dwSignalLightUpLinkLength) && (UINT32_MAX != dwSignalLightUpLinkLength)) + { + cKeepWork = CI_SUCCESS; + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + + } + + if (CI_SUCCESS == cKeepWork) + { + wSignalProtectLinkId = GetSignalProtectLink(wSignalId); /*ȡźŻLINKLink飬ֹźŻڷ仯*/ + wSignalOutFirstLinkId = GetSignalOutFirstLink(wSignalId); + dwSignalOutFirstLinkOff = GetLinkLengthById(wSignalOutFirstLinkId); + wCurrentLink = wSignalProtectLinkId; + /*ֵ*/ + if ((UINT16_MAX != wSignalOutFirstLinkId) && (UINT32_MAX != dwSignalOutFirstLinkOff)) + { + cSignalProtectDir = GetSignalDirection(wSignalId); + + if (wSignalProtectLinkId == wSignalOutFirstLinkId) + { + dwSearchLen = dwSignalOutFirstLinkOff; /*LinkΪⷽһLinkҪӳ*/ + } + else + { + dwSearchLen = 0U; /*Ϊⷽһlinkӳ*/ + } + + /*źŻ*/ + if (DIR_SAME == cSignalProtectDir) + { + cSearchDir = DIR_CONVERT; + } + else if (DIR_CONVERT == cSignalProtectDir) + { + cSearchDir = DIR_SAME; + } + else + { + cSearchDir = DIR_INVALID; + cKeepWork = CI_ERROR; + } + if (CI_SUCCESS == cKeepWork) + { + do + { + /*ȡһlinkID*/ + wNextLink = FindAdjacentLinkIDSafe(wCurrentLink, cSearchDir, &wPointId, &cDirectionPointFlag); + + if (MAX_SIGNAL_LIGHTUPLINK_NUM > wLightUpLinkSum) + { + if ((wCurrentLink == wSignalProtectLinkId) && (wSignalProtectLinkId != wSignalOutFirstLinkId)) + { + ; /*ǰlinkΪlinkȡĵһlinkңlinkⷽһlinkʱһlinkУźŻڷϣ*/ + } + else + { + wszLightUpLinkIdBuf[wLightUpLinkSum] = wCurrentLink; + wLightUpLinkSum++; + } + } + else + { + ; + } + + if ((UINT16_MAX != wNextLink) && (0u != wNextLink) && (dwSearchLen < dwSignalLightUpLinkLength)) + { + cKeepWork = dsuCheckLinkFitPointSafe(wCurrentLink, cSearchDir, &wPointId); + if (CI_SUCCESS == cKeepWork) + { + /*ȡɹ*/ + wCurrentLink = wNextLink; + /*з仯㣬תѯһlink*/ + cSearchDir = TransDirectionPointDir(cDirectionPointFlag, cSearchDir, &cDirectionPointCnt); + + dwSearchLen += GetLinkLengthById(wCurrentLink); + if ((dwSearchLen >= dwSignalLightUpLinkLength) && (MAX_SIGNAL_LIGHTUPLINK_NUM > wLightUpLinkSum)) + { + wszLightUpLinkIdBuf[wLightUpLinkSum] = wCurrentLink; + wLightUpLinkSum++; + } + else + { + + } + } + else + { + /*λãֹͣ*/ + dwSearchLen = UINT32_MAX; + cKeepWork = CI_SUCCESS; + } + } + else + { + dwSearchLen = UINT32_MAX; + } + } while (dwSearchLen < dwSignalLightUpLinkLength); + + } + else + { + + } + } + else + { + /*ŵһЧ*/ + cKeepWork = CI_SUCCESS; + } + } + else + { + + } + + + + if (CI_SUCCESS == cKeepWork) + { + /*ͨ*/ + cRetMem = CommonMemCpy(szLinkIdBuf, (UINT32)(MAX_SIGNAL_LIGHTUPLINK_NUM * sizeof(UINT16)), wszLightUpLinkIdBuf, (UINT32)(wLightUpLinkSum * sizeof(UINT16))); + if (CI_SUCCESS == cRetMem) + { + /**/ + *pLinkNum = wLightUpLinkSum; + cRetVal = CI_SUCCESS; + } + else + { + + } + + } + else + { + cRetVal = CI_ERROR; + } + + return cRetVal; +} + +/** +* @brief źŻLinkID +* @param UINT16 wSignalId +* @param UINT16 wLinkSum +* @param UINT16 szLinkBuf[] +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +*/ +UINT8 SetSignalLightUpLinkIdBuf(const UINT16 wSignalId, UINT16 wLinkSum, const UINT16 szLinkBuf[]) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 ii = 0u; + UINT16 jj = 0u; + + UINT16 wSignalIndex = GetSignalConfigBufIndex(wSignalId); + + + if (SIGNAL_SUM_MAX != wSignalIndex) + { + /*źŻ*/ + for (jj = 0u; jj < MAX_SIGNAL_LIGHTUPLINK_NUM; jj++) + { + SignalDataStru[wSignalIndex].szSignalLightUpLinkIdBuf[jj] = 0u; + } + + if (wLinkSum < MAX_SIGNAL_LIGHTUPLINK_NUM) + { + if (NULL != szLinkBuf) + { + for (ii = 0u; ii < wLinkSum; ii++) + { + SignalDataStru[wSignalIndex].szSignalLightUpLinkIdBuf[ii] = szLinkBuf[ii]; + } + SignalDataStru[wSignalIndex].wSignalLightUpLinkIdSum = wLinkSum; + cRetVal = CI_SUCCESS; + } + } + + } + return cRetVal; +} + +/** +* @brief ˢźŻlink +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +* ޸bug YF0083-119 +*/ +UINT8 RefreshSignalLightUpLink(void) +{ + UINT16 ii = 0u; + UINT8 cRetVal = CI_ERROR; + UINT16 wSignalId = 0u; + UINT8 cKeepWork = CI_ERROR; + UINT8 cRetMem = 0u; + UINT16 wLightUpLinkSum = 0u; + UINT16 szLightUpLinkIdBuf[MAX_SIGNAL_LIGHTUPLINK_NUM] = { 0u }; + UINT16 chOcId = 0u; + UINT16 wSignalOcId = 0u; + + /*ȡID*/ + chOcId = GetSystemParaLocalCiId(); + + if ((UINT8_MAX != chOcId) && (0u != chOcId)) + { + cKeepWork = CI_SUCCESS; + } + else + { + /*Ϣ ID*/ + cKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == cKeepWork) + { + for (ii = 0u; ii < SIGNAL_SUM_MAX; ii++) + { + wSignalId = GetSignalId(ii); + wSignalOcId = GetSignalBelongCiId(wSignalId); + + if (chOcId == wSignalOcId) + { + /*ȡźŻγɹ*/ + cKeepWork = CalSignalLightUpLinkSeq(wSignalId, &wLightUpLinkSum, szLightUpLinkIdBuf); + if (CI_SUCCESS == cKeepWork) + { + /*øźŻ*/ + cKeepWork = SetSignalLightUpLinkIdBuf(wSignalId, wLightUpLinkSum, szLightUpLinkIdBuf); + } + else + { + cKeepWork = CI_ERROR; + } + + if (CI_SUCCESS == cKeepWork) + { + /*յ*/ + cRetMem = CommonMemSet(szLightUpLinkIdBuf, (UINT32)sizeof(szLightUpLinkIdBuf), 0u, (UINT32)sizeof(szLightUpLinkIdBuf)); + if (CI_SUCCESS == cRetMem) + { + wLightUpLinkSum = 0u; + } + else + { + cKeepWork = CI_ERROR; + } + } + else + { + + } + if (CI_SUCCESS != cKeepWork) + { + /*Ϣ źŻβѯʧ*/ + break; + } + else + { + + } + } + else + { + ;/* OC */ + } + } + } + else + { + + } + + /*ִгɹ*/ + if (CI_SUCCESS == cKeepWork) + { + /*سɹ*/ + cRetVal = CI_SUCCESS; + } + else + { + cRetVal = CI_ERROR; + } + + return cRetVal; +} + +/** +* @brief ˢźŻ״̬ +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +*/ +UINT8 RefreshSignalLightUpState(void) +{ + UINT8 cKeepWork = CI_ERROR; + UINT8 cRetVal = CI_ERROR; + UINT16 wSignalIndex = 0u; + UINT16 wSignalId = 0u; + UINT16 wSignalLightUpLinkIdSum = 0u; + UINT16 * pSignalLightUpLinkIdBuff = NULL; + UINT16 wLinkIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chOcId = 0u; + UINT16 wSignalOcId = 0u; + UINT16 wPhySecId = 0u; + UINT8 chOccState = 0u; + UINT8 chTrainLevel = 0u; + UINT8 chFlag = 0u; + UINT8 chDir = 0u; + TRAIN_SEQUANCE_s strTmp = { 0u }; + UINT8 chLinkOcId = 0u; + UINT8 chOtherFlag = FLAG_UNSET; + UINT32 dwDdLen = 0u; + UINT32 dwUsedLen = 0u; + UINT32 dwLinkLen = 0u; + CfpTrainInfoStru strCfpOther = { 0u }; + UINT16 wCfpId = 0u; + UINT16 wLink = 0u; + UINT32 dwOffset = 0u; + UINT8 chTransmitStat = 0u; + UINT32 dwLeftLen = 0u; + UINT8 chTrainNum = 0u; + UINT8 chPhyFree = CI_ERROR; + UINT8 cDirectionPointfirst = 0U; /*仯1*/ + UINT8 cDirectionPointsecond = 0U; /*仯2*/ + UINT8 cDirectionPointCnt = 0U; /*仯*/ + UINT8 cDirectionProtectLinkPoint = 0U; /*źŻlink仯*/ + UINT8 cDirectionOutFirstLinkPoint = 0U; /*źŻⷽһlink仯*/ + UINT16 wSignalOutFirstLinkId = 0u; /*źŻⷽһlink*/ + UINT16 wSignalProtectLinkId = 0U; /*źŻlinkID*/ + UINT16 wOutFstPhySecId = 0U; /*źŻⷽһ*/ + UINT8 cPhySecBelongCiId = 0U; /*źŻⷽһCI*/ + UINT8 cSleepTrainLightUpFlag = SIGNAL_SLEEP_TRAIN_LIGHTUP_YES; /*߳źŻ־*/ + UINT8 cCommState = TRANSMIT_STATE_BAD; + + dwDdLen = GetSystemParaValue(SIGNAL_LIGHTUP_SEC_LEN_ID); + dwDdLen *= 100u; + chOcId = GetSystemParaLocalCiId(); + if ((0u != chOcId) && (UINT8_MAX != chOcId)) + { + cKeepWork = CI_SUCCESS; + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWork) + { + for (wSignalIndex = 0u; wSignalIndex < SIGNAL_SUM_MAX; wSignalIndex++) + { + dwUsedLen = 0u; + chOtherFlag = FLAG_UNSET; + chOccState = SECTION_OCCUPY_NO; + wSignalId = GetSignalId(wSignalIndex); + wSignalOcId = GetSignalBelongCiId(wSignalId); + SetSignalLightUpTrainId(wSignalId, 0U); + /* ֻΪźŻ */ + if (wSignalOcId == chOcId) + { + wSignalLightUpLinkIdSum = GetSignalLightUpLinkIdSum(wSignalId); + pSignalLightUpLinkIdBuff = GetSignalLightUpLinkIdBuf(wSignalId); + wSignalProtectLinkId = GetSignalProtectLink(wSignalId); /*ȡźŻLINKLink飬ֹźŻڷ仯*/ + wSignalOutFirstLinkId = GetSignalOutFirstLink(wSignalId); + chDir = GetSignalDirection(wSignalId); + wTrainId = 0u; + chFlag = GetSignalShine(wSignalId); + + if ((UINT16_MAX == wSignalId) + || (UINT16_MAX == wSignalLightUpLinkIdSum) + || (NULL == pSignalLightUpLinkIdBuff) + || ((DIR_SAME != chDir) && (DIR_CONVERT != chDir))) + { + cKeepWork = CI_ERROR; + + } + else + { + cKeepWork = CI_SUCCESS; + } + + if(CI_SUCCESS == cKeepWork) + {/* Σг */ + if (wSignalProtectLinkId != wSignalOutFirstLinkId) + { + cDirectionProtectLinkPoint = GetLinkLogicDirChangedById(wSignalProtectLinkId); + cDirectionOutFirstLinkPoint = GetLinkLogicDirChangedById(wSignalOutFirstLinkId); /*linkⷽһlinklinkڷ仯㣬Ҫ*/ + if (((LINK_DIRCHANGE_BEGIN == cDirectionProtectLinkPoint) || (LINK_DIRCHANGE_END == cDirectionOutFirstLinkPoint)) + && (cDirectionProtectLinkPoint == cDirectionOutFirstLinkPoint)) + { + chDir = TransDirectionPointDir(DIRECTIONPOINT_FLAG_VALID, chDir, &cDirectionPointCnt); /*з仯㣬ת*/ + } + else + { + ; /*ûз任㣬DZ䷽*/ + } + } + { + ; /*linkⷽһlinkҪת*/ + } + for (wLinkIndex = 0u; wLinkIndex < wSignalLightUpLinkIdSum; wLinkIndex++) + { + chLinkOcId = (UINT8)GetLinkManageTiocById(pSignalLightUpLinkIdBuff[wLinkIndex]); + if (chLinkOcId == chOcId) + { + dwLinkLen = GetLinkLengthById(pSignalLightUpLinkIdBuff[wLinkIndex]); + dwUsedLen += dwLinkLen; + wPhySecId = GetLinkRelatedPhySec(pSignalLightUpLinkIdBuff[wLinkIndex]); + chOccState = GetPhySecCurOccupyState(wPhySecId); + chPhyFree = IsPhyFree(wPhySecId); + if ((SECTION_OCCUPY_YES == chOccState) || (CI_ERROR == chPhyFree)) + { + if (DIR_SAME == chDir) + { + chTrainNum = as_GetLinkTrainNum(pSignalLightUpLinkIdBuff[wLinkIndex]); + strTmp = as_GetLinkLastTrain(pSignalLightUpLinkIdBuff[wLinkIndex]); + } + else + { + chTrainNum = as_GetLinkTrainNum(pSignalLightUpLinkIdBuff[wLinkIndex]); + strTmp = as_GetLinkFirstTrain(pSignalLightUpLinkIdBuff[wLinkIndex]); + } + + if (0u != chTrainNum) + { + wTrainId = strTmp.u16TrainID; + SetSignalLightUpTrainId(wSignalId, wTrainId); + } + else + { + ;/* ޴ */ + } + } + else + { + ;/*޴*/ + } + } + else + { + wLink = pSignalLightUpLinkIdBuff[wLinkIndex]; + if (DIR_SAME == chDir) + { + dwOffset = GetLinkLengthById(wLink); + } + else + { + dwOffset = 0u; + } + chOtherFlag = FLAG_SET; + } + + /*Ƿз仯㣬˴飬ǰlinkѰȶ꣬һlinkʱмз仯㣬仯㣬һlinkı䷽*/ + if (wLinkIndex < (wSignalLightUpLinkIdSum - 1U)) + { + cDirectionPointfirst = GetLinkLogicDirChangedById(pSignalLightUpLinkIdBuff[wLinkIndex]); + cDirectionPointsecond = GetLinkLogicDirChangedById(pSignalLightUpLinkIdBuff[(wLinkIndex + 1u)]); /*todoԽ*/ + if (((LINK_DIRCHANGE_BEGIN == cDirectionPointfirst) || (LINK_DIRCHANGE_END == cDirectionPointfirst)) + && (cDirectionPointsecond == cDirectionPointfirst)) + { + chDir = TransDirectionPointDir(DIRECTIONPOINT_FLAG_VALID, chDir, &cDirectionPointCnt); /*з仯㣬ת*/ + } + else + { + ; /*ûз任㣬DZ䷽*/ + } + } + else + { + ; /*һlinkҪǷ仯⣬ֹԽ*/ + } + + + if ((((SECTION_OCCUPY_YES == chOccState) || (CI_ERROR == chPhyFree)) && (0u != chTrainNum)) + || (FLAG_SET == chOtherFlag)) + { + break; + } + else + { + ;/* ޴ */ + } + } + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWork) + { + if (SIGNAL_LIGHT_CONFIG_LIGHT == chFlag) + { + /* */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + if (FLAG_SET == chOtherFlag) /*źŻֽij*/ + { + wCfpId = GetCfpIdByPoint(wLink, dwOffset); + strCfpOther = GetCfpOtherOcTrainInfo(wCfpId); + chTransmitStat = GetCiTransmitState(CI_SYSTEM_TYPE_CI, chLinkOcId); + dwLeftLen = dwDdLen - dwUsedLen; + + if ((TRANSMIT_STATE_GOOD != chTransmitStat) || ((UINT32_MAX != strCfpOther.dwDis) && (dwLeftLen < strCfpOther.dwDis))) + { + ; /*ͨŲãTIOCгռãѳƾ룬õνӽгID*/ + } + else + { + SetSignalLightUpTrainId(wSignalId, strCfpOther.wTrainId); + } + } + } + else if ((0u != wTrainId) && (UINT16_MAX != wTrainId)) + { + chTrainLevel = GetTrainLevel(wTrainId); + if (TRAIN_LEVEL_VBTC == chTrainLevel) + {/* CBTC */ + if (SIGNAL_LIGHT_CONFIG_CBTC_LIGHT == chFlag) + { + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + else + { + /* źŻβѯĵһгΪVBTCźŻ */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO); + } + } + else + {/* OCΪVBTC */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + } + else if ((SECTION_OCCUPY_YES == chOccState) && (0u != chTrainNum)) + {/* ռãδѯгϢ */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + else if (FLAG_SET == chOtherFlag) + { + wCfpId = GetCfpIdByPoint(wLink, dwOffset); + strCfpOther = GetCfpOtherOcTrainInfo(wCfpId); + chTransmitStat = GetCiTransmitState(CI_SYSTEM_TYPE_CI, chLinkOcId); + dwLeftLen = dwDdLen - dwUsedLen; + if ((0u == wCfpId) || (TRANSMIT_STATE_GOOD != chTransmitStat)) + {/* TIOCͨŹϣ */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + else + { + SetSignalLightUpTrainId(wSignalId, strCfpOther.wTrainId); + if ((0u == strCfpOther.wTrainId) && (SIGNAL_LIGHT_CONFIG_CBTC_CLOSE != chFlag)) /*RC޳ռãźŻΪ̬ʱ߼*/ + {/* TIOC޳ռã */ + + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO); + } + else if ((UINT32_MAX != strCfpOther.dwDis) && (dwLeftLen < strCfpOther.dwDis)) + {/* TIOCгռãΪVBTCѳƾ룬 */ + SetSignalLightUpTrainId(wSignalId, 0U); + if (SIGNAL_LIGHT_CONFIG_CBTC_CLOSE != chFlag) /*RCгռãΪVBTCѳƾ룬źŻΪ̬ʱ߼*/ + { + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO); + } + else + { + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + } + else if (TRAIN_LEVEL_VBTC == strCfpOther.chTrainLevel) + {/*TIOCVBTCռãҪ鿴ǷΪ̬ƣCBTCӽ*/ + if (SIGNAL_LIGHT_CONFIG_CBTC_LIGHT == chFlag) + { + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + else + { + /* źŻβѯĵһгΪVBTCźŻ */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO); + } + } + else + {/* */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + } + } + else + { + /* ûв鵽г */ + if ((0u != wSignalLightUpLinkIdSum) && (SIGNAL_LIGHT_CONFIG_CBTC_CLOSE != chFlag)) + { + /* ÿźŻƣݵǷзͨųռжϵ */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_NO); + } + else + { + /* Ϊ0߳źŻ */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + } + + wOutFstPhySecId = GetSignalOutFirstPhySecId(wSignalId); + cPhySecBelongCiId = GetPhySecBelongCiId(wOutFstPhySecId); + + if (chOcId != cPhySecBelongCiId) + { + /*źŻⷽһλRCͨRCӿе߳źŻ־źŻ*/ + + cCommState = GetCiTransmitState(CI_SYSTEM_TYPE_CI, cPhySecBelongCiId); + if (TRANSMIT_STATE_GOOD == cCommState) + { + /*źŻⷽһRCͨͨ߳źŻ־ˢźŻ״̬*/ + cSleepTrainLightUpFlag = GetSleepTrainLightUpSignalFlag(wSignalId); + if (SIGNAL_SLEEP_TRAIN_LIGHTUP_YES == cSleepTrainLightUpFlag) + { + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + else + { + /*ּ״̬*/ + } + } + else + { + SetSleepTrainLightUpSignalFlag(wSignalId, SIGNAL_SLEEP_TRAIN_LIGHTUP_NO); /*źŻⷽһRCͨ쳣߳źŻ־*/ + } + } + else + { + SetSleepTrainLightUpSignalFlag(wSignalId, SIGNAL_SLEEP_TRAIN_LIGHTUP_NO); /*źŻⷽһڱ߳źŻ־*/ + } + } + else + { + /* ѯʧ */ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + } + } + else + { + ;/* */ + } + + /*߳߻ѹնźŻƴ*/ + SleepTrainSignalLightUpProc(wSignalId); + } + } + else + { + ;/*޴*/ + } + + cRetVal = cKeepWork; + + return cRetVal; +} + +/** +* @brief źŻƴ +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +*/ +UINT8 SignalLightUpProc(void) +{ + UINT8 chRtnVal = CI_ERROR; + chRtnVal = RefreshSignalLightUpLink(); + chRtnVal *= RefreshSignalLightUpState(); + return chRtnVal; +} + +/* +* źŻ̳ӽ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +* cgh-ϲCID-2341-5 +*/ +void SetSigEngineerVehicleNearSte(const UINT16 signalId, const UINT8 sigEngineerVehicleNearState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIG_ENGINEERVEHICNEAR_STE_NO == sigEngineerVehicleNearState) || (SIG_ENGINEERVEHICNEAR_STE_YES == sigEngineerVehicleNearState)) + { + SignalDataStru[bufIndex].EngineerVehicleNearState = sigEngineerVehicleNearState; /*źŻ̳ӽ״̬*/ + } + } +} + +/* +* ȡźŻ̳ӽ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0:źŻ̳ӽ״̬ +* cgh-ϲCID-2341-5 +*/ +UINT8 GetSigEngineerVehicleNearSte(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].EngineerVehicleNearState; /*źŻ̳ӽ״̬*/ + } + return reVal; +} + +/* +* źŻ̳ѹر״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +* cgh-ϲCID-2341-5 +*/ +void SetSigEnginVehicCrossCloseSte(const UINT16 signalId, const UINT8 sigEngineerVehicCrossCloseSte) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((ENGIN_VEHIC_CROSSCLOSE_STE_NO == sigEngineerVehicCrossCloseSte) || (ENGIN_VEHIC_CROSSCLOSE_STE_YES == sigEngineerVehicCrossCloseSte)) + { + SignalDataStru[bufIndex].EngineerVehicleCrossClose = sigEngineerVehicCrossCloseSte; /*źŻ̳ѹر״̬*/ + } + } +} + +/* +* ȡźŻ̳ѹر״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +* cgh-ϲCID-2341-5 +*/ +UINT8 GetSigEnginVehicCrossCloseSte(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].EngineerVehicleCrossClose; + } + return reVal; +} + +/* +* źŻ̳ѹر· +* ˵ const UINT16 signalId, źŻID + const UINT16 routeId ·ID +*cgh-ϲCID-2341-5 +*/ +void SetEnginVehicCroCloBelongRoute(const UINT16 signalId, const UINT16 routeId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].EnginVehicCroCloBelongRoute = routeId; + } +} + +/* +* ȡźŻ̳ѹر· +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: źŻ̳ѹر· +* cgh-ϲCID-2341-5 +*/ +UINT16 GetEnginVehicCroCloBelongRoute(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].EnginVehicCroCloBelongRoute; + } + return reVal; +} +/* +* OC-ָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 curColor, ǰʾɫ +*ֵ +* WGY ޸ĹȱݣźŻƶ˿ʱֵźŻɫ +*/ +void OcSetSignalCurColor(const UINT16 signalId, const UINT8 curColor) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 signalColorValid = 0u; + UINT8 signalState = 0u; + UINT8 funSwitchGreenYellow = GetCiFunctionSwitchConfig(CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow);/*ʾ̻ƹܿǷ*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if(SIGNAL_SUM_MAX > bufIndex) + { + /*źŻǰɫ*/ + SignalDataStru[bufIndex].CurColor = curColor; + signalColorValid = CheckSignalShowColorValid(curColor); + /*ɫЧ*/ + if(CI_SUCCESS == signalColorValid) + { + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + } + /*Բͬɫö˿״̬*/ + switch(curColor) + { + /*źŻ*/ + case SIGNAL_SHOWCOLOUR_RED: + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + break; + /*źŻ*/ + case SIGNAL_SHOWCOLOUR_GREEN: + case SIGNAL_SHOWCOLOUR_DOUBLE_GREEN: + SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + break; + /*źŻ*/ + case SIGNAL_SHOWCOLOUR_YELLOW: + case SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW: + SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + break; + /*̻*/ + case SIGNAL_SHOWCOLOUR_GREENYELLOW: + SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + break; + /**/ + case SIGNAL_SHOWCOLOUR_WHITE: + SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + break; + /**/ + case SIGNAL_SHOWCOLOUR_REDYELLOW: + SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + break; + /**/ + case SIGNAL_SHOWCOLOUR_RED_WHITE: + SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + break; + /*źŻ*/ + case SIGNAL_SHOWCOLOUR_GREENCLOSE: + case SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE: + case SIGNAL_SHOWCOLOUR_YELLOWCLOSE: + if (FUNC_SWITCH_ON == funSwitchGreenYellow) + { + SignalDataStru[bufIndex].BlueDsBreakFlag = SIGNAL_DS_BREAK_NO;/*δ˿־*/ + } + else + { + ; /**/ + } + break; + /*ƶ*/ + case SIGNAL_SHOWCOLOUR_YELLOWBREAK: + SignalDataStru[bufIndex].YellowDsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + break; + /*̶*/ + case SIGNAL_SHOWCOLOUR_GREENBREAK: + SignalDataStru[bufIndex].GreenDsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + break; + /**/ + case SIGNAL_SHOWCOLOUR_REDBREAK: + SignalDataStru[bufIndex].DsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + break; + /*׶*/ + case SIGNAL_SHOWCOLOUR_WHITEBREAK: + SignalDataStru[bufIndex].WhiteDsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + break; + case SIGNAL_SHOWCOLOUR_BLUEBREAK: + SignalDataStru[bufIndex].BlueDsBreakFlag = SIGNAL_DS_BREAK_YES;/*ö˿־*/ + break; + default: + /*ɴ֧*/ + break; + } + signalState = GetSignalOpenCloseState(curColor); + /*źŻ*/ + if (SIGNAL_OPEN == signalState) + { + /*ź*/ + SignalDataStru[bufIndex].DriveSigOpenStartCycNum = 0u; + } + else + {/*źر*/ + + /*źر*/ + SignalDataStru[bufIndex].DriveSigCloseStartCycNum = 0u; + } + } + +} +/* +* ȡOCźŻ忨״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: OCźŻ忨״̬ +*/ +UINT8 GetSignalBoardState(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].SignalBoardState; + } + return reVal; +} + +/* +* OCźŻ忨״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 boardState 忨״̬ + +*/ +void SetSignalBoardState(const UINT16 signalId, const UINT8 boardState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].SignalBoardState = boardState; + } +} + +/* +* ȡOCźŻȫʼ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: OCźŻȫʼ +*/ +UINT32 GetOcSignalStartCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].OcSignalStartCycNum; + } + return reVal; +} + +/* +* OCźŻȫʼ +* ˵ const UINT16 signalId, źŻID + +*/ +void SetOcSignalStartCycNum(const UINT16 signalId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].OcSignalStartCycNum = startCycNum; + } +} + +/* +* ȡźŻ̵ʼʼ +* ˵ const UINT16 signalId, źŻID +* ֵ ̵ʼʼ +*/ +UINT32 GetSigRelayActStartCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].RelayActaionStartCycNum; + } + return reVal; +} + +/* +* ȡźŻԸʽ۳ť1־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalDetainBtnActFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_ZFS_BTN_ACT_FLAG_NO == SignalDataStru[bufIndex].DetainBtnActivateFlag) || (SIGNAL_ZFS_BTN_ACT_FLAG_YES == SignalDataStru[bufIndex].DetainBtnActivateFlag)) + { + reVal = SignalDataStru[bufIndex].DetainBtnActivateFlag; + } + } + return reVal; +} + +/* +* źŻԸʽ۳ť1־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalZFSBtnActFlag źŻԸʽť־ +* ֵ +* +*/ +void SetSignalDetainBtnActFlag(const UINT16 signalId, const UINT8 signalZFSBtnActFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_ZFS_BTN_ACT_FLAG_NO == signalZFSBtnActFlag) || (SIGNAL_ZFS_BTN_ACT_FLAG_YES == signalZFSBtnActFlag)) + { + SignalDataStru[bufIndex].DetainBtnActivateFlag = signalZFSBtnActFlag; /*źŻӲ߿۳״̬*/ + } + } +} + +/* +* źŻԸʽȡ۳ť1ϱ־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalZFSBtnErrFlag źŻԸʽťϱ־ +* ֵ +* +*/ +void SetSignalCancelDetainBtnErrFlag(const UINT16 signalId, const UINT8 signalZFSBtnErrFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == signalZFSBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == signalZFSBtnErrFlag)) + { + SignalDataStru[bufIndex].CancelDetainBtnErrFlag = signalZFSBtnErrFlag; /*źŻӲ߿۳״̬*/ + } + } +} + +/* +* ȡźŻԸʽȡ۳ť1ϱ־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalCancelDetainBtnErrFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == SignalDataStru[bufIndex].CancelDetainBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == SignalDataStru[bufIndex].CancelDetainBtnErrFlag)) + { + reVal = SignalDataStru[bufIndex].CancelDetainBtnErrFlag; + } + } + return reVal; +} + +/* +* źŻ۳ť1 +* const UINT16 signalId źŻID +* const UINT32 startCycNum ں +* +* ֵ +*/ +void SetDetainBtnPressCycNum(const UINT16 signalId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].DetainBtnPressCycNum = startCycNum; + } +} + +/* +* ȡźŻ۳ť1 +* const UINT16 signalId źŻID +* +* ֵ źŻ۳ť1 +*/ +UINT32 GetDetainBtnPressCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].DetainBtnPressCycNum; + } + return reVal; +} + +/* +* źŻȡ۳ť +* const UINT16 signalId źŻID +* const UINT32 startCycNum ں +* +* ֵ +*/ +void SetCancelDetainBtnPressCycNum(const UINT16 signalId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].CancelDetainBtnPressCycNum = startCycNum; + } +} + +/* +* ȡźŻȡ۳ť +* const UINT16 signalId źŻID +* +* ֵ źŻȡ۳ť +*/ +UINT32 GetCancelDetainBtnPressCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].CancelDetainBtnPressCycNum; + } + return reVal; +} + +/* +* źŻԸʽȡ۳ť1Ч־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalZFSBtnValidFlag źŻԸʽťЧ־ +* ֵ +*/ +void SetCancelDetainBtnValidFlag(const UINT16 signalId, const UINT8 signalZFSBtnValidFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_CANCEL_DETAIN_VALID_NO == signalZFSBtnValidFlag) || (SIGNAL_CANCEL_DETAIN_VALID_YES == signalZFSBtnValidFlag)) + { + SignalDataStru[bufIndex].CancelDetainBtnValidFlag = signalZFSBtnValidFlag; /*źŻӲ߿۳״̬*/ + } + } + else + { + /*±󣬲*/ + } +} + +/* +* ȡźŻԸʽȡ۳ť1Ч־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetCancelDetainBtnValidFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_CANCEL_DETAIN_VALID_NO == SignalDataStru[bufIndex].CancelDetainBtnValidFlag) + || (SIGNAL_CANCEL_DETAIN_VALID_YES == SignalDataStru[bufIndex].CancelDetainBtnValidFlag)) + { + reVal = SignalDataStru[bufIndex].CancelDetainBtnValidFlag; + } + } + else + { + /*±󣬲*/ + } + + return reVal; +} + +/* +* źŻԸʽ۳ť1ϱ־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalZFSBtnErrFlag źŻԸʽťϱ־ +* ֵ +* +*/ +void SetSignalDetainBtnErrFlag(const UINT16 signalId, const UINT8 signalZFSBtnErrFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == signalZFSBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == signalZFSBtnErrFlag)) + { + SignalDataStru[bufIndex].DetainBtnErrFlag = signalZFSBtnErrFlag; /*źŻӲ߿۳״̬*/ + } + } +} + +/* +* ȡźŻԸʽ۳ť1ϱ־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalDetainBtnErrFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_ZFS_BTN_ERR_FLAG_NO == SignalDataStru[bufIndex].DetainBtnErrFlag) || (SIGNAL_ZFS_BTN_ERR_FLAG_YES == SignalDataStru[bufIndex].DetainBtnErrFlag)) + { + reVal = SignalDataStru[bufIndex].DetainBtnErrFlag; + } + } + return reVal; +} + +/* +* 鵱ǰźŻʾɫǷϷ +* ˵ const UINT8 chSignalCurColor źŻǰʾɫ +* ֵ CI_SUCCESS: Ϸ +* CI_ERROR: Ϸ +* by cgh 20230719 źŻǰʾɫʱнӿУ +*/ +UINT8 CheckSignalCurColor(const UINT8 chSignalCurColor) +{ + UINT8 reVal = CI_ERROR; + if ((SIGNAL_SHOWCOLOUR_RED == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_YELLOW == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_REDYELLOW == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_GREEN == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_YELLOWCLOSE == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_GREENCLOSE == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_WHITE == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_RED_WHITE == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_REDBREAK == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_GREENBREAK == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_YELLOWBREAK == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_WHITEBREAK == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_GREENYELLOW == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_GREEN_OR_GREENYELLOW == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_DOUBLE_GREEN == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_GREEN_OR_YELLOW == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_INVALID == chSignalCurColor) + || (SIGNAL_SHOWCOLOUR_REDCLOSE == chSignalCurColor)) + { + reVal = CI_SUCCESS; + } + else + { + ; /*źŻʾɫϷ*/ + } + return reVal; +} + +/* +* жָIDźŻǷĿ۳ +* ˵ const UINT16 signalId, źŻID +* ֵ aa: Ŀ۳ +* 55: δ˹۳ +* 5a: δԶ۳ +*/ +UINT8 GetSignalATSDetainFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = SIGNAL_ATS_DETAIN_YES; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) && (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto)) + {/*ATSδ۳*/ + reVal = SIGNAL_ATS_DETAIN_NO; + } + else if ((SIGNAL_DETAIN_YES == SignalDataStru[bufIndex].AtsDetainFlag) && (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto)) + {/*ATS˹۳*/ + reVal = SIGNAL_ATS_DETAIN_YES; + + } + else if ((SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) && (SIGNAL_DETAIN_YES == SignalDataStru[bufIndex].AtsDetainFlagAuto)) + {/*ATSԶ۳*/ + reVal = SIGNAL_ATS_DETAIN_AUTO_YES; + } + else + { + reVal = SIGNAL_ATS_DETAIN_YES; + } + + } + return reVal; +} + +/* +* жָIDźŻǷվ۳ +* ˵ const UINT16 signalId, źŻID +* ֵ CI_ERROR: վ۳ +* CI_SUCCESS: δվ۳ +*/ +UINT8 GetSignalLocalDetainFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = SIGNAL_XIANDI_DETAIN_YES; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].XiandiDetainFlag) + {/*ֵδ۳*/ + + reVal = SIGNAL_XIANDI_DETAIN_NO; + } + else + {/*ֵؿ۳*/ + reVal = SIGNAL_XIANDI_DETAIN_YES; + } + } + return reVal; +} + +/* +* ߼·źŻ쳣رձ־ +* ˵ const UINT16 signalId, źŻID +* ֵ LOG_ROUTE_SIGNAL_CLOSE_ERR쳣ر +* LOG_ROUTE_SIGNAL_CLOSE_NOERRδ쳣ر +*/ +UINT8 GetLogRouteSignalErrCloseFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((LOG_ROUTE_SIGNAL_CLOSE_ERR == SignalDataStru[bufIndex].LogRouteSignalErrCloseFlag) || (LOG_ROUTE_SIGNAL_CLOSE_NOERR == SignalDataStru[bufIndex].LogRouteSignalErrCloseFlag)) + { + reVal = SignalDataStru[bufIndex].LogRouteSignalErrCloseFlag; + } + } + + return reVal; +} + + +/* +* ߼·źŻ쳣رձ־ +* ˵ const UINT8 wFlag, 쳣رձ־ +* const UINT16 signalId, źŻID +* ֵ void +*/ +void SetLogRouteSignalErrCloseFlag(const UINT16 signalId, const UINT8 wFlag) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((LOG_ROUTE_SIGNAL_CLOSE_ERR == wFlag) || (LOG_ROUTE_SIGNAL_CLOSE_NOERR == wFlag)) + { + SignalDataStru[bufIndex].LogRouteSignalErrCloseFlag = wFlag; /*źŻ쳣رձ־*/ + } + } +} + + +/* +* ȡָIDźŻ۳־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳־ +*/ +UINT8 GetSignalSoftDetainFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) && (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto)) + {/*ATSδ۳ δԶ۳δ˹۳*/ + + if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].XiandiDetainFlag) + {/*ֵδ۳*/ + + reVal = SIGNAL_DETAIN_NO;/*ֵءATSδ۳*/ + } + else + { + /*ֵؿ۳*/ + reVal = SIGNAL_DETAIN_XIANDI;/*ֵؿ۳ATSδ۳*/ + } + } + else + {/*ATS۳*/ + + if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].XiandiDetainFlag) + {/*ֵδ۳*/ + if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) + {/*ATSδ˹۳*/ + reVal = SIGNAL_DETAIN_ATS_AUTO; + } + else if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto) + { + reVal = SIGNAL_DETAIN_ATS; + } + else + { + ; /**/ + } + + } + else + { + /*ֵؿ۳*/ + if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlag) + {/*ATSδ˹۳*/ + + reVal = SIGNAL_DETAIN_XIANDI_ATSAUTO;/*ATSԶ۳+ֵؿ۳*/ + } + else if (SIGNAL_DETAIN_NO == SignalDataStru[bufIndex].AtsDetainFlagAuto) + {/*ATSδԶ۳*/ + reVal = SIGNAL_DETAIN_YES;/*ATS˹۳+ֵؿ۳*/ + } + else + { + ; /**/ + } + } + } + + + } + return reVal; +} + +/* +* ȡźŻгѹڷһռѹ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0:źŻгѹڷһռѹ״̬ +*/ +UINT8 GetSigVobcCrossInPhyOccSta(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].VobcCroSigInPhyOccSta; /*źŻгѹڷһռѹ״̬*/ + } + return reVal; +} + +/* +* źŻгѹڷһռѹ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 SigVobcCrossInPhyOccSta ռѹ״̬ +* ֵ +*/ +void SetSigVobcCrossInPhyOccSta(const UINT16 signalId, const UINT8 SigVobcCrossInPhyOccSta) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SECTION_OCCUPY_NO == SigVobcCrossInPhyOccSta) || (SECTION_OCCUPY_YES == SigVobcCrossInPhyOccSta)) + { + SignalDataStru[bufIndex].VobcCroSigInPhyOccSta = SigVobcCrossInPhyOccSta; /*źŻ̳ѹر״̬*/ + } + } +} + +/* +* źŻȡ۳ť󴥷 +* const UINT16 signalId źŻID +* const UINT32 startCycNum ں +* +* ֵ +* Created By LQ 2024.04.11 +*/ +void SetCancelDetErrTrigPressCycNum(const UINT16 signalId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + SignalDataStru[bufIndex].CancelDetainErrTrigPressCycNum = startCycNum; + } + else + { + /*δ󣬲*/ + } +} + +/* +* ȡźŻȡ۳ť󴥷 +* const UINT16 signalId źŻID +* +* ֵ źŻȡ۳ť󴥷 +* Created By LQ 2024.04.11 +*/ +UINT32 GetCancelDetErrTrigPressCycNum(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + reVal = SignalDataStru[bufIndex].CancelDetainErrTrigPressCycNum; + } + else + { + /*δ󣬷ʧ*/ + } + + return reVal; +} + +/* +* źŻȡ۳ťɼ̵״̬ +* ˵const UINT16 signalId, źŻID +* const UINT8 cRelayDownState ̵״̬ +* ֵ +* Created By LQ 2024.04.11 +*/ +void SetCancelDetainRelayDownState(const UINT16 signalId, const UINT8 cRelayDownState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_RELAY_ERROR_DOWN_NO == cRelayDownState) || (SIGNAL_RELAY_ERROR_DOWN_YES == cRelayDownState)) + { + SignalDataStru[bufIndex].CancelDetainRelayDownState = cRelayDownState; /*ȡ۳ťɼ̵״̬*/ + } + else + { + /*״̬󣬲*/ + } + } + else + { + /*±󣬲*/ + } +} + +/* +* ȡźŻȡ۳ťɼ̵״̬ +* ˵const UINT16 signalId, źŻID +* ֵ 0 ȡʧ +* 0x55 +* 0xaa ͨ쳣 +* Created By LQ 2024.04.11 +*/ +UINT8 GetCancelDetainRelayDownState(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 reVal = CI_ERROR; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + if ((SIGNAL_RELAY_ERROR_DOWN_NO == SignalDataStru[bufIndex].CancelDetainRelayDownState) + || (SIGNAL_RELAY_ERROR_DOWN_YES == SignalDataStru[bufIndex].CancelDetainRelayDownState)) + { + reVal = SignalDataStru[bufIndex].CancelDetainRelayDownState; + } + else + { + /*״̬󣬷0ʧ*/ + } + } + else + { + /*±󣬷0ʧ*/ + } + + return reVal; +} + +/* +* ߳նźŻ״̬ +* ˵const UINT16 wSignalId źŻID +* ֵ +* Created By LQ 2024.08.21 +*/ +void SleepTrainSignalLightUpProc(const UINT16 wSignalId) +{ + UINT16 wSignalIndex = 0U; + UINT16 wOutFstPhySecId = 0U; /*źŻⷽһ*/ + UINT8 cPhySecBelongCiId = 0U; /*ⷽһCI*/ + UINT8 cLocalCiId = 0U; + UINT8 cPhySecIncAxleSecNum = 0U; /*ⷽһΰļ*/ + UINT16* pPhySecIncAxleSecID = NULL; /*ⷽһΰļID*/ + UINT16 wACIdIndex = 0U; /*AGID*/ + UINT8 cACRelEnvNum = 0U; /*AGİ*/ + UINT16 szACRelEnvID[SECTION_REL_ENVELOPE_SUM_MAX] = { 0U }; /*AGİID*/ + const EnvelopeStruct* pEnvelope = NULL; + UINT8 cSleepState = TRAIN_SLEEP_NO; /*г״̬*/ + UINT8 cSignalBelongCiId = 0U; /*źŻCI*/ + UINT16 wCutoffPointId = 0U; /*ֽID*/ + + wSignalIndex = GetSignalConfigBufIndex(wSignalId); /*ȡźŻ±*/ + + if (SIGNAL_SUM_MAX > wSignalIndex) + { + wOutFstPhySecId = GetSignalOutFirstPhySecId(wSignalId); + cPhySecBelongCiId = GetPhySecBelongCiId(wOutFstPhySecId); + cLocalCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if ((0U != cLocalCiId) && (cPhySecBelongCiId == cLocalCiId)) + { + /*źŻⷽһڱж*/ + cPhySecIncAxleSecNum = GetPAxisSectionSum(wOutFstPhySecId); + pPhySecIncAxleSecID = GetPAxisSectionIdBuf(wOutFstPhySecId); + + if ((1U == cPhySecIncAxleSecNum) && (NULL != pPhySecIncAxleSecID)) + { + /*ǵΣж*/ + wACIdIndex = GetLocalCiAxisSectionIndex(pPhySecIncAxleSecID[0]); + cACRelEnvNum = elm_GetACRelEnvelopeCnt(wACIdIndex, szACRelEnvID); + + if (1U == cACRelEnvNum) + { + pEnvelope = elm_GetEnvelopeInfoPtr(szACRelEnvID[0]); + if ((NULL != pEnvelope) && (TYPE_CT_ENVELOPE == pEnvelope->envelopeType)) + { + /*νһCT磬жϸгǷ*/ + cSleepState = GetTrainSleepState(pEnvelope->trainID[0]); + if (TRAIN_SLEEP_YES == cSleepState) + { + /*߳ôźŻ*/ + cSignalBelongCiId = GetSignalBelongCiId(wSignalId); + if (cSignalBelongCiId == cLocalCiId) + { + /*źŻźŻ*/ + (void)SetSignalLightExtinctState(wSignalId, SIGNAL_LIGHT_EXTICT_STATE_YES); + SetSleepTrainLightUpSignalFlag(wSignalId, SIGNAL_SLEEP_TRAIN_LIGHTUP_YES); /*߳źŻ־Ч*/ + } + else + { + /*DZźŻֽͨϢźŻRCźŻ*/ + wCutoffPointId = GetAxisRelateCfpId(pPhySecIncAxleSecID[0]); + + if (0U != wCutoffPointId) + { + SetCfpSignalLightUpFlag(wCutoffPointId, SIGNAL_SLEEP_TRAIN_LIGHTUP_YES); + } + else + { + /*ȡֽʧܣ*/ + } + } + } + else + { + /*߳*/ + } + } + else + { + /*ȡʧܻCT磬*/ + } + } + else + { + /*ް粻߳*/ + } + } + else + { + /*ȡΰļʧܻ߻ѹ죨βߣ*/ + } + } + else + { + /*ηDZ*/ + } + } + else + { + /*μʧܣ*/ + } +} + +/* +* ȡ߳źŻ־ +* ˵const UINT16 signalId źŻID +* ֵ0x55 Ч +* 0xAA Ч +* Created By LQ 2024.08.21 +*/ +UINT8 GetSleepTrainLightUpSignalFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 cRetVal = SIGNAL_SLEEP_TRAIN_LIGHTUP_NO; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + cRetVal = SignalDataStru[bufIndex].cSleepTrainLightUpFlag; + } + else + { + /*μʧܣ*/ + } + + return cRetVal; +} + +/* +* ߳źŻ־ +* ˵const UINT16 signalId, źŻID +* const UINT8 cLightUpFlag ־ +* ֵ +* Created By LQ 2024.08.21 +*/ +void SetSleepTrainLightUpSignalFlag(const UINT16 signalId, const UINT8 cLightUpFlag) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX >bufIndex) + { + if ((SIGNAL_SLEEP_TRAIN_LIGHTUP_YES == cLightUpFlag) || (SIGNAL_SLEEP_TRAIN_LIGHTUP_NO == cLightUpFlag)) + { + SignalDataStru[bufIndex].cSleepTrainLightUpFlag = cLightUpFlag; /*߳źŻ־*/ + } + else + { + /*Ƿ־*/ + } + } + else + { + /*μʧܣ*/ + } +} + +/* +* ȡźŻʪ־ +* ˵const UINT16 signalId źŻID +* ֵ0x55 Ч +* 0xAA Ч +* Created By LQ 2024.09.20 +*/ +UINT8 GetSignalInHumidRailFlag(const UINT16 signalId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 cRetVal = SIGNAL_IN_HUMID_RAIL_YES; + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡźŻ±*/ + + if (bufIndex < SIGNAL_SUM_MAX) + { + cRetVal = SignalDataStru[bufIndex].cInHumidRailFlag; + } + else + { + /*μʧܣ*/ + } + + return cRetVal; +} + +/* +* źŻʪ־ +* ˵const UINT16 signalId źŻID +* const UINT8 cInHumidRailFlag źŻʪ־ +* ֵ +* Created By LQ 2024.09.20 +*/ +void SetSignalInHumidRailFlag(const UINT16 signalId, const UINT8 cInHumidRailFlag) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetSignalConfigBufIndex(signalId); /*ȡ±*/ + + if (SIGNAL_SUM_MAX > bufIndex) + { + if ((SIGNAL_IN_HUMID_RAIL_YES == cInHumidRailFlag) || (SIGNAL_IN_HUMID_RAIL_NO == cInHumidRailFlag)) + { + SignalDataStru[bufIndex].cInHumidRailFlag = cInHumidRailFlag; + } + else + { + /*Ƿ־*/ + } + } + else + { + /*μʧܣ*/ + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Signal/SignalDataManage.h b/TSCP/src/APP/ciapp/Signal/SignalDataManage.h new file mode 100644 index 0000000..1e667d4 --- /dev/null +++ b/TSCP/src/APP/ciapp/Signal/SignalDataManage.h @@ -0,0 +1,1035 @@ +/******************************************************** +* +* SignalDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* źŻݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SIGNAL_DATA_MANAGE_H_ +#define _SIGNAL_DATA_MANAGE_H_ + + +#include "SignalDefine.h" +#include "SignalConfigDataManage.h" + +#include "CommonTypes.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../System/CiSystemDefine.h" +#include "../Relay/RelayDataManage.h" +#include "../LogRecord/LogRecord.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + + + +/*źŻ̬ݽṹ*/ +typedef struct S_SignalDataStruct +{ + UINT16 SignalId; /*źŻID (ֶ)*/ + UINT16 AutoRouteId; /* ԶźŽ·IDֶ */ + UINT8 LinShiXianSuSetFlag; /*źŻʱ״̬(Ч//δ)(ֶ̬)*/ + UINT8 FLockState; /*źŻ״̬(δ/) (ֶ̬)*/ + UINT8 LightExtinctState; /*źŻ״̬(/) (ֶ̬)*/ + UINT8 PreColor; /*źŻ֮ǰʾɫ (ֶ̬) */ + UINT8 CurColor; /*źŻǰʾɫ (ֶ̬) */ + UINT8 OldDriveColor; /*źŻɫ仯֮ǰ,źŻʾɫ (ֶ̬) */ + UINT8 PreDriveColor; /*֮ǰ()źŻʾɫ (ֶ̬) */ + UINT8 PreChangedDriveColor; /*һα仯ɫڸOCźŻɫֵ by shl*/ + UINT8 CurDriveColor; /*ǰ()źŻʾɫ (ֶ̬) */ + UINT32 DriveNewSigStartCycNum; /*źŻʾɫʼ*/ + UINT32 DriveSigOpenStartCycNum; /*źŻʼ (ֶ̬)*/ + UINT32 DriveSigCloseStartCycNum; /*źŻرʼ (ֶ̬)*/ + UINT32 CollSigOpenStartCycNum; /*ɼźŻʼ (ֶ̬)*/ + UINT8 DsBreakFlag; /*˿˿־ (ֶ̬) */ + UINT8 GreenDsBreakFlag; /*̵˿˿־*/ + UINT8 YellowDsBreakFlag; /*Ƶ˿˿־*/ + UINT8 WhiteDsBreakFlag; /*׵˿˿־*/ + UINT8 RedYellowDsBreakFlag; /*ƶ˿־*/ + UINT8 RedWhiteDsBreakFlag; /*׶˿־*/ + UINT8 GreenYellowDsBreakFlag; /*̻ƶ˿*/ + UINT8 DoubleGreenDsBreakFlag; /*˫̶˿*/ + UINT8 DoubleYellowDsBreakFlag; /*˫ƶ˿*/ + UINT8 BlueDsBreakFlag; /*ƶ˿*/ + UINT8 SignalCrossState; /*ͨųѹͨźŻ״̬(ֶ̬)*/ + UINT8 SignalLeadProperty; /*źŻ (ʼֶ)*/ + UINT8 SignalLeadRouteCbtcFlag; /*źŻеĽ·ǷCBTCĽ·ҲзCBTC·ı־(ʼֶ)*/ + UINT8 SignalYLockOpenState; /*źſ״̬/رգ (ֶ̬) */ + UINT8 AtsDetainFlag; /*Ats˹۳־ (ֶ̬)*/ + UINT8 AtsDetainFlagAuto; /*ATSԶ۳־ (ֶ̬)*/ + UINT8 XiandiDetainFlag; /*ֵؿ۳־ (ֶ̬)*/ + UINT8 RealyDetainFlag; /*Ӳߣ̵۳־ (ֶ̬)*/ + UINT8 DetainBtnActivateFlag; /*۳ť1־0x55δ0xaa*/ + UINT8 DetainBtnErrFlag; /*۳ť1ϱ־0x55δϣ0xaa*/ + UINT8 CancelDetainBtnErrFlag; /*ȡ۳ť1ϱ־0x55δϣ0xaa*/ + UINT32 DetainBtnPressCycNum; /*۳ť1*/ + UINT32 CancelDetainBtnPressCycNum; /*ȡ۳ť*/ + UINT32 CancelDetainErrTrigPressCycNum; /*ȡ۳ť󴥷*/ + UINT8 CancelDetainBtnValidFlag; /*ȡ۳ťЧ־0x55Ч0xaaЧ*/ + UINT8 CancelDetainRelayDownState; /*ȡ۳ťɼ̵״̬0x55ɼ£0xaaͨ쳣*/ + UINT8 PLockCommand;/*ͨ*/ + UINT32 RelayActaionStartCycNum; /*źŻ̵ʼ*/ + UINT32 DiffColorOpenStartCycNum;/*źŻɫѾţĿɫ¼ù̬ʼڡ磺̵ƣZXJϣһֱǻƵơCIһں󣬻ر*/ + UINT32 SignalLightOnStateCycCount; /*źŻյǿƵǿ״ֵ̬*/ + UINT8 ProSecValid;/*ͨЧ*/ + UINT8 RelayDetainCmd; /*Ӳ߿۳*/ + UINT8 NeighbourSignalDetainDrive;/*վźŻ۳*/ + UINT8 MaintainLightState; /*źŻά޵״̬*/ + UINT16 wSignalLightUpLinkIdSum; /*link*/ /* add 2022.3.4 */ + UINT16 szSignalLightUpLinkIdBuf[MAX_SIGNAL_LIGHTUPLINK_NUM];/*linkID*//* add 2022.3.4 */ + UINT16 wSignalLightUpTrainId; /*źŻνӽгID*/ + UINT8 EngineerVehicleNearState; /*̳ӽ״̬*/ + UINT8 EngineerVehicleCrossClose; /*̳ѹر*/ + UINT16 EnginVehicCroCloBelongRoute;/*̳ѹر·*/ + UINT8 SignalBoardState; /*OCźŻ忨״̬*/ + UINT32 OcSignalStartCycNum; /*OCźŻȫ̿ʼ*/ + UINT8 LogRouteSignalErrCloseFlag; /*߼·źŻ쳣رձ־(߼·쳣رʹ)*/ + UINT8 VobcCroSigInPhyOccSta; /*гѹźŻڷһռѹ״̬*/ + UINT8 cSleepTrainLightUpFlag; /*߳źŻ־0x55 Ч0xAA Ч*/ + UINT8 cInHumidRailFlag; /*źŻʪ־0x55 Ч0xAA Ч*/ +} SignalDataStruct; + +extern SignalDataStruct SignalDataStru[SIGNAL_SUM_MAX]; /*źŻݽṹ*/ +/* +* ȡָIDź +* ˵ +* ֵ + SignalDataStruct* +*/ +SignalDataStruct *GetSignalData(void); + +/* +* ȡָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSignalFLockState(const UINT16 signalId); + +/* +* ָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 fLockState, ״̬ +* ֵ +* +*/ +void SetSignalFLockState(const UINT16 signalId, const UINT8 fLockState); + +/* +* ȡָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSignalLightExtinctState(const UINT16 signalId); + +/* +* ָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 lightExtinctState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalLightExtinctState(const UINT16 signalId, const UINT8 lightExtinctState); +/* +* ָIDźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 ligheCloseState, ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetNearCISigLightExtinctState(const UINT16 signalId, const UINT8 lightExtinctState); + +/* +* ȡָIDźŻ֮ǰʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ֮ǰʾɫ +*/ +UINT8 GetSignalPreColor(const UINT16 signalId); + +/* +* ȡָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ֮ǰʾɫ +*/ +UINT8 GetSignalCurColor(const UINT16 signalId); + +/* +* ָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 curColor, ǰʾɫ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalCurColor(const UINT16 signalId, const UINT8 curColor); +/* +* ָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 curColor, ǰʾɫ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetNearCISignalCurColor(const UINT16 signalId, const UINT8 curColor); + +/* +* ȡָIDźŻ֮ǰʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʾɫ +*/ +UINT8 GetSignalPreDriveColor(const UINT16 signalId); + +/* +* ָIDźŻ֮ǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 driveColor, ʾɫ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalPreDriveColor(const UINT16 signalId, const UINT8 driveColor); + +/* +* ȡָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʾɫ +*/ +UINT8 GetSignalCurDriveColor(const UINT16 signalId); + +/* +* ָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 driveColor, ʾɫ +* ֵ +* +*/ +void SetSignalCurDriveColor(const UINT16 signalId, const UINT8 driveColor); + +/* +* ȡָIDźŻ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻ̵˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalGreenDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻƵ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalYellowDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻ׵˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalWhiteDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻƵ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalRedYellowDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻ׵˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalRedWhiteDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻ̻Ƶ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalGreenYellowDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻ˫̵˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSignalDoubleGreenDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻ˫Ƶ˿˿־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ˿־ +*/ +UINT8 GetSigDoubleYellowDsBreakFlag(const UINT16 signalId); + +/* +* ȡָIDźŻʼں +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSignalDriveOpenStartCycNum(const UINT16 signalId); + +/* +* ȡָIDźŻرʼں +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: رʼں +*/ +UINT32 GetSignalDriveCloseStartCycNum(const UINT16 signalId); + +/* +* ȡָIDźŻźʼں +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źʼں +*/ +UINT32 GetSignalDriveNewSigStartCycNum(const UINT16 signalId); +/* +* ȡָIDźŻźŻɫ仯֮ǰ,źŻʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʾɫ +*/ +UINT8 GetSignalOldDriveColor(const UINT16 signalId); + + +/* +* źŻʾɫЧ +* ˵ const UINT8 showColor, źŻʾɫ +* ֵ 0: ʾЧ +* 1: ʾЧ +*/ +UINT8 CheckSignalShowColorValid(const UINT8 showColor); + +/* +* źŻɫЧ +* ˵ const UINT8 drvColor, źŻɫ +* ֵ 0: Ч +* 1: Ч +*/ +UINT8 CheckSignalDriveColorValid(const UINT8 drvColor); + + +/* +* ȡźŻɫŹر״̬ +* ˵ UINT8 signalColor +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalOpenCloseState(UINT8 signalColor); + + +/* +* ȡͨųѹͨźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalCrossState(const UINT16 signalId); + + +/* +* ͨųѹͨźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +*/ +UINT8 SetSignalCrossState(const UINT16 signalId, const UINT8 signalCrossState); + +/* +* ȡźŻ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalYLockOpenState(const UINT16 signalId); + + +/* +* ȡźŻеĽ·ǷCBTCĽ·ҲзCBTC·ı־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalLeadRouteCbtcFlag(const UINT16 signalId); + +/* +* źŻ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 setState, ״̬ +* ֵ +* +*/ +void SetSignalYLockOpenState(const UINT16 signalId, const UINT8 setState); + +/* +* ȡָIDźŻ۳־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳־ +*/ +UINT8 GetSignalDetainFlag(const UINT16 signalId); + +/* +* ָIDźŻ۳״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 setState, ״̬ +* ֵ +* +*/ +void SetSignalDetainState(const UINT16 signalId, const UINT8 setState); + +/* +* ָIDźŻ۳־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 setState, ״̬ +* ֵ CI_ERROR +* CI_SUCCESS +*/ +UINT8 SetSignalDetainFlag(const UINT16 signalId, const UINT8 setState); + +/* +* ȡԶźŶӦĽ·ID +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: źŻID +*/ +UINT16 GetSignalAutoRouteId(const UINT16 signalId); + +/* +* ԶźŶӦĽ·ID +* ˵ const UINT16 signalId, źŻID +* const UINT16 routeId +* ֵ 0ʧ 1 ɹ +*/ +UINT8 SetSignalAutoRouteId(const UINT16 signalId,const UINT16 routeId); + +/* +* ȡָIDźŻʱñ־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʱ״̬ +*/ +UINT8 GetSignalLinShiXianSuSetFlag(const UINT16 signalId); + + +/* +* ָIDźŻָIDźŻʱٱ־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 setState, ״̬ +* ֵ +* +*/ +void SetSignalLinShiXianSuSetFlag(const UINT16 signalId, const UINT8 linShiXianSuSetState); + +/* +* ȡָIDźŻ쳣رձ־ +* ˵ const UINT16 signalId, źŻID +* ֵ +* +*/ +UINT8 GetSignalPLockCommand(const UINT16 signalId); + + +/* +* ָIDźŻ쳣رձ־ +* ˵ const UINT16 signalId, źŻID + const UINT8 curColor, ǰʾɫ + const UINT8 setStateǰ״̬ +* ֵ +* +*/ +void SetSignalPLockCommand(const UINT16 signalId, const UINT8 pLockCommand); + +/* +* ȡźŻͨЧ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: Ч +*/ +UINT8 GetSignalProSecValid(const UINT16 signalId); + + +/* +* źŻͨЧ +* ˵ +const UINT16 signalId, źŻID +const UINT8 proSecValid:Ч +* ֵ: +* +* +*/ +void SetSignalProSecValid(const UINT16 signalId, const UINT8 proSecValid); + +/* +* źŻɫѾţĿɫ¼ù̬ʼ +* ˵ + const UINT16 signalId, źŻID + const UINT32 cycNum:ʼں +* ֵ: +* 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalDiffColorOpenStartCyc(const UINT16 signalId,const UINT32 cycNum); + +/* +* ȡźŻɫѾţĿɫ¼ù̬ʼ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSignalDiffColorOpenStartCyc(const UINT16 signalId); + +/* +* ָIDźŻɼʼں +* ˵ + const UINT16 signalId, źŻID + const UINT32 cycNum:ʼں +* ֵ: +* 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalCollOpenStartCycNum(const UINT16 signalId,const UINT32 cycNum); + +/* +* ȡָIDźŻɼʼں +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSignalCollOpenStartCycNum(const UINT16 signalId); + +/* +* ȡźŻӲ߿۳״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalRelayDetainFlag(const UINT16 signalId); + +/* +* źŻӲ߿۳״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ +* +*/ +void SetSignalRelayDetainFlag(const UINT16 signalId, const UINT8 signalRelayDetainState); + +#if 0 +/* +* ȡźŻӲ߿۳ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalRelayDetainCmd(const UINT16 signalId); +#endif +/* +* źŻӲ߿۳ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +*/ +UINT8 SetSignalRelayDetainCmd(const UINT16 signalId, const UINT8 signalRelayDetainCmd); + +/* +* ȡվźŻ۳ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalNeighbourDetainDrive(const UINT16 signalId); + + +/* +* վźŻ۳ +* ˵ const UINT16 signalId, źŻID +* const UINT8 drive۳ +* ֵ +* +*/ +void SetSignalNeighbourDetainDrive(const UINT16 signalId, const UINT8 drive); + +/* +* ȡָIDźŻ֮ǰ仯ʾɫ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: 仯ʾɫ +*/ +UINT8 GetSignalPreChangedDriveColor(const UINT16 signalId); + +/* +* ָIDźŻ֮ǰ仯ʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 driveColor, ʾɫ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSignalPreChangedDriveColor(const UINT16 signalId, const UINT8 driveColor); +/* +* ά޵״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 maintainState, ά޵״̬ +* ֵ void +*/ +void SetSignalMaintainState(const UINT16 signalId, const UINT8 maintainState); +/* +* ȡά޵״̬ +* ˵ const UINT16 signalId, źŻID +* +* ֵ 0: ʧ +* >0: ά޵״̬ +*/ +UINT8 GetSignalMaintainState(const UINT16 signalId); + +/* +* ȡźŻlinkĿ +* ˵ const UINT16 signalId, źŻID +* ֵ linkĿ +* create 2022.3.4 +*/ +UINT16 GetSignalLightUpLinkIdSum(const UINT16 signalId); + +/* +* ȡźŻLINK +* ˵ const UINT16 signalId, źŻID +* ֵ link +* create 2022.3.4 +*/ +UINT16 * GetSignalLightUpLinkIdBuf(const UINT16 signalId); + +/** +* @brief źŻlink +* @param wSignalId źŻ +* @param pLinkNum link +* @param szLinkIdBuf link +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +*/ +UINT8 CalSignalLightUpLinkSeq(IN const UINT16 wSignalId, OUT UINT16 * pLinkNum, OUT UINT16 szLinkIdBuf[]); + +/** +* @brief źŻLinkID +* @param UINT16 wSignalId +* @param UINT16 wLinkSum +* @param UINT16 szLinkBuf[] +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +*/ +UINT8 SetSignalLightUpLinkIdBuf(const UINT16 wSignalId, UINT16 wLinkSum, const UINT16 szLinkBuf[]); + +/** +* @brief ˢźŻlink +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +*/ +UINT8 RefreshSignalLightUpLink(void); + +/** +* @brief ˢźŻ״̬ +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +*/ +UINT8 RefreshSignalLightUpState(void); + +/** +* @brief źŻƴ +* @return CI_SUCCESSɹCI_ERRORʧ +* @create 2022.3.4 +*/ +UINT8 SignalLightUpProc(void); + +/* +* źŻνӽгID +* ˵ const UINT16 signalId, źŻID +* const UINT8 maintainState, ά޵״̬ +* ֵ void +*/ +void SetSignalLightUpTrainId(const UINT16 signalId, const UINT16 wTrainId); + +/* +* ȡźŻνӽгID +* ˵ const UINT16 signalId, źŻID +* ֵ νӽгID +* 0:ʧ +*/ +UINT16 GetSignalLightUpTrainId(const UINT16 signalId); + +/* +* źŻ̳ӽ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +* cgh-ϲCID-2341-5 +*/ +void SetSigEngineerVehicleNearSte(const UINT16 signalId, const UINT8 sigEngineerVehicleNearState); + +/* +* ȡźŻ̳ӽ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0:źŻ̳ӽ״̬ +* cgh-ϲCID-2341-5 +*/ +UINT8 GetSigEngineerVehicleNearSte(const UINT16 signalId); + +/* +* źŻ̳ѹر״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +* cgh-ϲCID-2341-5 +*/ +void SetSigEnginVehicCrossCloseSte(const UINT16 signalId, const UINT8 sigEngineerVehicCrossCloseSte); + +/* +* ȡźŻ̳ѹر״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: óɹ +* cgh-ϲCID-2341-5 +*/ +UINT8 GetSigEnginVehicCrossCloseSte(const UINT16 signalId); + +/* +* źŻ̳ѹر· +* ˵ const UINT16 signalId, źŻID + const UINT16 routeId ·ID +*cgh-ϲCID-2341-5 +*/ +void SetEnginVehicCroCloBelongRoute(const UINT16 signalId, const UINT16 routeId); + +/* +* ȡźŻ̳ѹر· +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ʧ +* >0: źŻ̳ѹر· +* cgh-ϲCID-2341-5 +*/ +UINT16 GetEnginVehicCroCloBelongRoute(const UINT16 signalId); +/* +* OC-ָIDźŻǰʾɫ +* ˵ const UINT16 signalId, źŻID +* const UINT8 curColor, ǰʾɫ +*ֵ +* +*/ +void OcSetSignalCurColor(const UINT16 signalId, const UINT8 curColor); +/* +* ȡOCźŻ忨״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: OCźŻ忨״̬ +*/ +UINT8 GetSignalBoardState(const UINT16 signalId); + +/* +* OCźŻ忨״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 boardState źŻ忨״̬ + +*/ +void SetSignalBoardState(const UINT16 signalId, const UINT8 boardState); + +/* +* ȡOCźŻȫʼ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: OCźŻȫʼ +*/ +UINT32 GetOcSignalStartCycNum(const UINT16 signalId); + +/* +* OCźŻȫʼ +* ˵ const UINT16 signalId, źŻID + +*/ +void SetOcSignalStartCycNum(const UINT16 signalId, const UINT32 startCycNum); +/* +* ȡźŻ̵ʼʼ +* ˵ const UINT16 signalId, źŻID +* ֵ ̵ʼʼ +*/ +UINT32 GetSigRelayActStartCycNum(const UINT16 signalId); + +/* +* ȡźŻ۳ť1־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalDetainBtnActFlag(const UINT16 signalId); + +/* +* źŻ۳ť1־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalZFSBtnActFlag ť־ +* ֵ +* +*/ +void SetSignalDetainBtnActFlag(const UINT16 signalId, const UINT8 signalZFSBtnActFlag); + +/* +* źŻԸʽȡ۳ť1ϱ־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalZFSBtnErrFlag źŻԸʽťϱ־ +* ֵ +* +*/ +void SetSignalCancelDetainBtnErrFlag(const UINT16 signalId, const UINT8 signalZFSBtnErrFlag); + +/* +* ȡźŻԸʽȡ۳ť1ϱ־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalCancelDetainBtnErrFlag(const UINT16 signalId); + +/* +* źŻ۳ť1 +* const UINT16 signalId źŻID +* const UINT32 startCycNum ں +* +* ֵ +*/ +void SetDetainBtnPressCycNum(const UINT16 signalId, const UINT32 startCycNum); + +/* +* ȡźŻ۳ť1 +* const UINT16 signalId źŻID +* +* ֵ źŻ۳ť1 +*/ +UINT32 GetDetainBtnPressCycNum(const UINT16 signalId); + +/* +* źŻȡ۳ť +* const UINT16 signalId źŻID +* const UINT32 startCycNum ں +* +* ֵ +*/ +void SetCancelDetainBtnPressCycNum(const UINT16 signalId, const UINT32 startCycNum); + +/* +* ȡźŻȡ۳ť +* const UINT16 signalId źŻID +* +* ֵ źŻȡ۳ť +*/ +UINT32 GetCancelDetainBtnPressCycNum(const UINT16 signalId); + +/* +* źŻԸʽȡ۳ť1Ч־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalZFSBtnValidFlag źŻԸʽťЧ־ +* ֵ +*/ +void SetCancelDetainBtnValidFlag(const UINT16 signalId, const UINT8 signalZFSBtnValidFlag); + +/* +* ȡźŻԸʽȡ۳ť1Ч־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetCancelDetainBtnValidFlag(const UINT16 signalId); + +/* +* źŻԸʽ۳ť1ϱ־ +* ˵ const UINT16 signalId, źŻID +* const UINT8 signalZFSBtnErrFlag źŻԸʽťϱ־ +* ֵ +* +*/ +void SetSignalDetainBtnErrFlag(const UINT16 signalId, const UINT8 signalZFSBtnErrFlag); + +/* +* ȡźŻԸʽ۳ť1ϱ־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ȡɹ +*/ +UINT8 GetSignalDetainBtnErrFlag(const UINT16 signalId); + +/* +* 鵱ǰźŻʾɫǷϷ +* ˵ const UINT8 chSignalCurColor źŻǰʾɫ +* ֵ CI_SUCCESS: Ϸ +* CI_ERROR: Ϸ +* by cgh 20230719 źŻǰʾɫʱнӿУ +*/ +UINT8 CheckSignalCurColor(const UINT8 chSignalCurColor); + +/* +* жָIDźŻǷĿ۳ +* ˵ const UINT16 signalId, źŻID +* ֵ aa: Ŀ۳ +* 55: δ˹۳ +* 5a: δԶ۳ +*/ +UINT8 GetSignalATSDetainFlag(const UINT16 signalId); + +/* +* жָIDźŻǷֵؿ۳ +* ˵ const UINT16 signalId, źŻID +* ֵ CI_ERROR: ֵؿ۳ +* CI_SUCCESS: δֵؿ۳ +*/ +UINT8 GetSignalLocalDetainFlag(const UINT16 signalId); + +/* +* ߼·źŻ쳣رձ־ +* ˵ const UINT16 signalId, źŻID +* ֵ LOG_ROUTE_SIGNAL_CLOSE_ERR쳣ر +* LOG_ROUTE_SIGNAL_CLOSE_NOERRδ쳣ر +*/ +UINT8 GetLogRouteSignalErrCloseFlag(const UINT16 signalId); + +/* +* ߼·źŻ쳣رձ־ +* ˵ const UINT8 wFlag, 쳣رձ־ +* const UINT16 signalId, źŻID +* ֵ void +*/ +void SetLogRouteSignalErrCloseFlag(const UINT16 signalId, const UINT8 wFlag); + +/* +* ȡָIDźŻ۳־ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0: ۳־ +*/ +UINT8 GetSignalSoftDetainFlag(const UINT16 signalId); + +/* +* ȡźŻгѹڷһռѹ״̬ +* ˵ const UINT16 signalId, źŻID +* ֵ 0: ȡʧ +* >0:źŻгѹڷһռѹ״̬ +*/ +UINT8 GetSigVobcCrossInPhyOccSta(const UINT16 signalId); + +/* +* źŻгѹڷһռѹ״̬ +* ˵ const UINT16 signalId, źŻID +* const UINT8 SigVobcCrossInPhyOccSta ռѹ״̬ +* ֵ +*/ +void SetSigVobcCrossInPhyOccSta(const UINT16 signalId, const UINT8 SigVobcCrossInPhyOccSta); + +/* +* źŻȡ۳ť󴥷 +* const UINT16 signalId źŻID +* const UINT32 startCycNum ں +* +* ֵ +* Created By LQ 2024.04.11 +*/ +void SetCancelDetErrTrigPressCycNum(const UINT16 signalId, const UINT32 startCycNum); + +/* +* ȡźŻȡ۳ť󴥷 +* const UINT16 signalId źŻID +* +* ֵ źŻȡ۳ť󴥷 +* Created By LQ 2024.04.11 +*/ +UINT32 GetCancelDetErrTrigPressCycNum(const UINT16 signalId); + +/* +* źŻȡ۳ťɼ̵״̬ +* ˵const UINT16 signalId, źŻID +* const UINT8 cRelayDownState ̵״̬ +* ֵ +* Created By LQ 2024.04.11 +*/ +void SetCancelDetainRelayDownState(const UINT16 signalId, const UINT8 cRelayDownState); + +/* +* ȡźŻȡ۳ťɼ̵״̬ +* ˵const UINT16 signalId, źŻID +* ֵ 0 ȡʧ +* 0x55 +* 0xaa ͨ쳣 +* Created By LQ 2024.04.11 +*/ +UINT8 GetCancelDetainRelayDownState(const UINT16 signalId); + +/* +* ߳նźŻ״̬ +* ˵const UINT16 wSignalId źŻID +* ֵ +* Created By LQ 2024.08.21 +*/ +void SleepTrainSignalLightUpProc(const UINT16 wSignalId); + +/* +* ȡ߳źŻ־ +* ˵const UINT16 signalId źŻID +* ֵ0x55 Ч +* 0xAA Ч +* Created By LQ 2024.08.21 +*/ +UINT8 GetSleepTrainLightUpSignalFlag(const UINT16 signalId); + +/* +* ߳źŻ־ +* ˵const UINT16 signalId, źŻID +* const UINT8 cLightUpFlag ־ +* ֵ +* Created By LQ 2024.08.21 +*/ +void SetSleepTrainLightUpSignalFlag(const UINT16 signalId, const UINT8 cLightUpFlag); + +/* +* ȡźŻʪ־ +* ˵const UINT16 signalId źŻID +* ֵ0x55 Ч +* 0xAA Ч +* Created By LQ 2024.09.20 +*/ +UINT8 GetSignalInHumidRailFlag(const UINT16 signalId); + +/* +* źŻʪ־ +* ˵const UINT16 signalId źŻID +* const UINT8 cInHumidRailFlag źŻʪ־ +* ֵ +* Created By LQ 2024.09.20 +*/ +void SetSignalInHumidRailFlag(const UINT16 signalId, const UINT8 cInHumidRailFlag); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Signal/SignalDefine.h b/TSCP/src/APP/ciapp/Signal/SignalDefine.h new file mode 100644 index 0000000..234299a --- /dev/null +++ b/TSCP/src/APP/ciapp/Signal/SignalDefine.h @@ -0,0 +1,301 @@ +/******************************************************** +* +* SignalConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* źŻͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SIGNAL_CONFIG_H_ +#define _SIGNAL_CONFIG_H_ + + + +/*źŻֵ*/ +#define SIGNAL_SUM_MAX ((UINT16)1500) /*źŻֵ*/ + +/*źŻ*/ +#define SIGNAL_TYPE_THREE_ALL_YINDAO ((UINT8)0x1F) /*ʾźŻơ졢ơ̡ƣ*/ +#define SIGNAL_TYPE_THREE_ALL_NOYINDAO ((UINT8)0x20) /*ʾźŻơ졢ợ*/ +#define SIGNAL_TYPE_THREE_NOGREEN_YINDAO ((UINT8)0x21) /*ʾźŻ̵ơ졢ơƣ*/ +#define SIGNAL_TYPE_THREE_NOGREEN_NOYINDAO ((UINT8)0x22) /*ʾźŻ̵ơ졢ƣ*/ +#define SIGNAL_TYPE_THREE_NOYELLOW_NOYINDAO ((UINT8)0x23) /*ʾźŻƵơ졢̣*/ +#define SIGNAL_TYPE_THREE_NOYELLOW_YINDAO ((UINT8)0x24) /*źŻ(ʾ޻Ƶƣ)졢̡ƣ*/ +#define SIGNAL_TYPE_TWO_ALL_NOYINDAO ((UINT8)0x15) /*ʾźŻƣ졢̣*/ +#define SIGNAL_TYPE_TWO_NOGREEN_NOYINDAO ((UINT8)0x16) /*ʾźŻ̵ƣ죩*/ +#define SIGNAL_TYPE_DIAOCHE ((UINT8)0x19) /*źŻ졢ף*/ +#define SIGNAL_TYPE_JINKUCHUKU ((UINT8)0x25) /*źŻ׻ƣ*/ +#define SIGNAL_TYPE_THREE_ALL_YINDAO_NOY ((UINT8)0x26) /*źŻ졢̡ƣ(ʾƣɵƵƣ)*/ +#define SIGNAL_TYPE_3_NOGREEN_YINDAO_NOL ((UINT8)0x28) /*źŻ졢ơƣ(ʾ̵ƣ)*/ +#define SIGNAL_TYPE_TWO_JINKU_RGY ((UINT8)0x27) /*/źŻ졢̡ƣ(ʾ),ơ̵ƺƵ*/ +#define SIGNAL_TYPE_THREE_JINKU_YINDAO ((UINT8)0x1A) /*źŻ(ơס졢)ʾ»2019.1.15*/ +#define SIGNAL_TYPE_THREE_DIAOCHE_YINDAO ((UINT8)0x29) /*δźŻ졢סף(ʾ׵ƣ)*/ + +#define SIGNAL_TYPE_4_ALL_NOYINDAO_ZX ((UINT8)0x2A) /*ʾơ 졢̡*/ +#define SIGNAL_TYPE_4_NOGREEN_NOYINDAO_ZX ((UINT8)0x2B) /*ʾ̵ơɵƵƣ졢*/ +#define SIGNAL_TYPE_5_NOGREEN_YINDAO_CD ((UINT8)0x2C) /*ʾ̵ơɵ˫Ƶƣ졢ơ̡ס˫*/ +#define SIGNAL_TYPE_5_NOY_NOYINDAO_CD ((UINT8)0x2D) /*ʾƵơ졢̡˫̡*/ +#define SIGNAL_TYPE_4_ALL_NOYINDAO_CD ((UINT8)0x2E) /*ʾ*/ +#define SIGNAL_TYPE_5_NOY_NOYINDAO_WB ((UINT8)0x2f) /*λźŻƵƣס*/ +#define SIGNAL_TYPE_3_RGG_CD ((UINT8)0x30) /*3λ졢˫*/ +#define SIGNAL_TYPE_3_RGG_NOGREEN_CD ((UINT8)0x31) /*3λ졢̵̡̡*/ +#define SIGNAL_TYPE_3_NOGREENWHITE_CD ((UINT8)0x32) /*3λ̡졢ף̡׵*/ +#define SIGNAL_TYPE_4_ALL_NOYINDAO_NOYELLOWONLY_ZX ((UINT8)0x33) /*(UINT8)0x33 վźŻ(ơ̡졢ĵλλɵƵ)*/ +#define SIGNAL_TYPE_4_NOGREENBLUE_NOYINDAO_ZX ((UINT8)0x34) /*(UINT8)0x34 źŻơ̡졢ĵλ̡ƣɵƵƣ*/ +#define SIGNAL_TYPE_3_ALL_NOYINDAO_CD ((UINT8)0x35) /*(UINT8)0x35 źŻ(ơ)̣*/ +#define SIGNAL_TYPE_1_ALL_END ((UINT8)0x36) /*(UINT8)0x36 ʾͷ赲źŻ*/ +#define SIGNAL_TYPE_THREE_JINKU_OFF (UINT8)0x37 /*/źŻ(ơס졢)ʾ*/ + +/*źŻ״̬*/ +#define SIGNAL_PLOCK_CMD_CREATE ((UINT8)0x55) /**/ +#define SIGNAL_PLOCK_CMD_CANCEL ((UINT8)0xaa) /*ȡ*/ +#define SIGNAL_PLOCK_CMD_NONE ((UINT8)0xff) /**/ + +/*źŻ״̬*/ +#define SIGNAL_FENGSUO_NO ((UINT8)0x55) /*δ*/ +#define SIGNAL_FENGSUO_YES ((UINT8)0xaa) /**/ +#define SIGNAL_FENGSUO_ILLEGAL ((UINT8)0xFF) /*״̬Чֵ*/ + +/*źŻʱ״̬*/ +#define SIGNAL_LINSHIXIANSUSET_STATE_NO ((UINT8)0x55) /*ʱδ*/ +#define SIGNAL_LINSHIXIANSUSET_STATE_YES ((UINT8)0xAA) /*ʱ*/ +#define SIGNAL_LINSHIXIANSUSET_STATE_INVALID ((UINT8)0xFF) /*ʱЧ*/ + +/*źŻ״̬*/ +#define SIGNAL_LIGHT_EXTICT_STATE_NO ((UINT8)0x55) /**/ +#define SIGNAL_LIGHT_EXTICT_STATE_YES ((UINT8)0xaa) /**/ +#define SIGNAL_LIGHT_EXTICT_STATE_ALL_YES ((UINT8)0x80) /*ȫվ*/ + +/*źŻʾɫ*/ +/* bit0λ bit1Ƶλ,bit2:̵λ bit3:׵ƣbit4 bit5:˿ */ + +/*źŻɫλΪ1ɫλΪ0*/ +#define SIGNAL_SHOWCOLOUR_RED ((UINT8)0x01) /**/ +#define SIGNAL_SHOWCOLOUR_YELLOW ((UINT8)0x02) /*Ƶ*/ +#define SIGNAL_SHOWCOLOUR_REDYELLOW ((UINT8)0x03) /*Ƶ*/ +#define SIGNAL_SHOWCOLOUR_GREEN ((UINT8)0x04) /*̵*/ +#define SIGNAL_SHOWCOLOUR_YELLOWCLOSE ((UINT8)0x85) /**/ +#define SIGNAL_SHOWCOLOUR_REDCLOSE ((UINT8)0x86) /**/ +#define SIGNAL_SHOWCOLOUR_GREENCLOSE ((UINT8)0x87) /**/ +#define SIGNAL_SHOWCOLOUR_WHITE ((UINT8)0x08) /*׵*/ +#define SIGNAL_SHOWCOLOUR_RED_WHITE ((UINT8)0x09) /*ףɫƹİλ*/ +#define SIGNAL_SHOWCOLOUR_REDBREAK ((UINT8)0x40) /**/ +#define SIGNAL_SHOWCOLOUR_BLUEBREAK ((UINT8)0x50) /**/ +#define SIGNAL_SHOWCOLOUR_GREENBREAK ((UINT8)0x10) /*̶*/ +#define SIGNAL_SHOWCOLOUR_YELLOWBREAK ((UINT8)0x20) /*ƶ*/ +#define SIGNAL_SHOWCOLOUR_WHITEBREAK ((UINT8)0x30) /*׶*/ +#define SIGNAL_SHOWCOLOUR_GREENYELLOWCLOSE ((UINT8)0x8A) /*̻*/ +#define SIGNAL_SHOWCOLOUR_GREENYELLOW ((UINT8)0x0B) /*̻Ƶ*/ +#define SIGNAL_SHOWCOLOUR_GREEN_OR_GREENYELLOW ((UINT8)0x11) /*̵ƻ̻*/ +#define SIGNAL_SHOWCOLOUR_DOUBLE_GREEN ((UINT8)0x12) /*˫̵*/ +#define SIGNAL_SHOWCOLOUR_DOUBLE_YELLOW ((UINT8)0x13) /*˫Ƶ*/ +#define SIGNAL_SHOWCOLOUR_GREEN_OR_YELLOW ((UINT8)0x14) /*̻߻Ƶ*/ + +#define SIGNAL_SHOWCOLOUR_INVALID ((UINT8)0xFF) /*Чɫ*/ + +/*źŻɫ*/ +#define SIGNAL_DRIVECOLOUR_RED ((UINT8)0x01) /**/ +#define SIGNAL_DRIVECOLOUR_YELLOW ((UINT8)0x02) /*Ƶ*/ +#define SIGNAL_DRIVECOLOUR_REDYELLOW ((UINT8)0x03) /*Ƶ*/ +#define SIGNAL_DRIVECOLOUR_GREEN ((UINT8)0x04) /*̵*/ +#define SIGNAL_DRIVECOLOUR_YELLOWCLOSE ((UINT8)0x85) /**/ +#define SIGNAL_DRIVECOLOUR_REDCLOSE ((UINT8)0x86) /**/ +#define SIGNAL_DRIVECOLOUR_GREENCLOSE ((UINT8)0x87) /**/ +#define SIGNAL_DRIVECOLOUR_WHITE ((UINT8)0x08) /*׵*/ +#define SIGNAL_DRIVECOLOUR_RED_WHITE ((UINT8)0x09) /*׵*/ + +#define SIGNAL_DRIVECOLOUR_GREENYELLOWCLOSE ((UINT8)0x8A) /*̻*/ +#define SIGNAL_DRIVECOLOUR_GREENYELLOW ((UINT8)0x0B) /*̻Ƶ*/ +#define SIGNAL_DRIVECOLOUR_DOUBLE_GREEN ((UINT8)0x12) /*˫̵*/ +#define SIGNAL_DRIVECOLOUR_DOUBLE_YELLOW ((UINT8)0x13) /*˫Ƶ*/ +#define SIGNAL_DRIVECOLOUR_GREEN_OR_YELLOW ((UINT8)0x14) /*̻߻Ƶ*/ + + +#define SIGNAL_DRIVECOLOUR_NULL ((UINT8)0xFF) /*Ч*/ + + +/*źŻ˿˿־*/ +#define SIGNAL_DS_BREAK_NO ((UINT8)0x55) /*δ˿*/ +#define SIGNAL_DS_BREAK_YES ((UINT8)0xaa) /*˿*/ + + +/*źŻŹر״̬*/ +#define SIGNAL_CLOSE ((UINT8)0x55) /*ر*/ +#define SIGNAL_OPEN ((UINT8)0xaa) /**/ + +/*ͨųѹͨźŻ״̬*/ +#define SIGNAL_CROSS_STATE_NO ((UINT8)0x55) /*δѹ*/ +#define SIGNAL_CROSS_STATE_YES ((UINT8)0xaa) /*ѹ*/ + +/*źŻ״̬*/ +#define SIGNAL_LEAD_PROPERTY_NO ((UINT8)0x55) /**/ +#define SIGNAL_LEAD_PROPERTY_YES ((UINT8)0xaa) /**/ + +/*źŻ·ı־*/ +#define SIGNAL_LEADROUTE_ALLCBTC ((UINT8)0xFF) /*źŻ·ȫCBTC*/ +#define SIGNAL_LEADROUTE_ALL_NO_CBTC ((UINT8)0x55) /*źŻ·ȫڷCBTC*/ +#define SIGNAL_LEADROUTE_CBTC_ANDNO ((UINT8)0xaa) /*źŻ·CBTCҲڷCBTC*/ + +/*۳־*/ +#define SIGNAL_DETAIN_NO ((UINT8)0x55) /*ֵغATSδ۳ || ۳־*/ +#define SIGNAL_DETAIN_YES ((UINT8)0xaa) /*ֵغATS(˹)۳ || δ۳־*/ +#define SIGNAL_DETAIN_ATS ((UINT8)0x10) /*ATS۳˹ֵδ۳ || ATS˹۳*/ +#define SIGNAL_DETAIN_ATS_AUTO ((UINT8)0x90) /*ATS۳Զֵδ۳ || ATSԶ۳*/ +#define SIGNAL_DETAIN_XIANDI ((UINT8)0x20) /*ֵؿ۳ATSδ۳ || ֵذ۳*/ +#define SIGNAL_DETAIN_ATS_NO ((UINT8)0x30) /*ATSȡ۳*/ +#define SIGNAL_DETAIN_XIANDI_NO ((UINT8)0x40) /*ֵȡ۳*/ +#define SIGNAL_DETAIN_CI_RELAY_YES ((UINT8)0x70) /*Ӳ߿۳*/ +#define SIGNAL_DETAIN_CI_RELAY_NO ((UINT8)0x80) /*Ӳ߲۳*/ +#define SIGNAL_DETAIN_XIANDI_ATSAUTO ((UINT8)0xbb) /*ֵغATS۳(ATSԶ۳)*/ + +#define SIGNAL_RELAY_DETAIN_NO ((UINT8)0x50) /*źŻӲδ۳ */ +#define SIGNAL_RELAY_DETAIN_YES ((UINT8)0x60) /*źŻӲ߿۳ */ + +#define SIGNAL_XIANDI_DETAIN_NO ((UINT8)0x55) /*źŻվδ۳ */ +#define SIGNAL_XIANDI_DETAIN_YES ((UINT8)0xaa) /*źŻվ۳ */ + +#define SIGNAL_ATS_DETAIN_NO ((UINT8)0x55) /*źŻδ۳ */ +#define SIGNAL_ATS_DETAIN_YES ((UINT8)0xaa) /*źŻ˹۳ */ +#define SIGNAL_ATS_DETAIN_AUTO_YES ((UINT8)0x5a) /*źŻԶ۳ */ + +#define SIGNAL_ZFS_BTN_ACT_FLAG_NO ((UINT8)0x55) /*źŻԸʽť־Ч*/ +#define SIGNAL_ZFS_BTN_ACT_FLAG_YES ((UINT8)0xaa) /*źŻԸʽť־Ч*/ + +#define SIGNAL_ZFS_BTN_ERR_FLAG_NO ((UINT8)0x55) /*źŻԸʽťϱ־Ч*/ +#define SIGNAL_ZFS_BTN_ERR_FLAG_YES ((UINT8)0xaa) /*źŻԸʽťϱ־Ч*/ + +#define SIGNAL_CANCEL_DETAIN_VALID_NO ((UINT8)0x55) /*źŻԸʽȡ۳ťЧ*/ +#define SIGNAL_CANCEL_DETAIN_VALID_YES ((UINT8)0xaa) /*źŻԸʽȡ۳ťЧ*/ + +#define SIGNAL_RELAY_ERROR_DOWN_NO ((UINT8)0x55) /*ȡ۳ť̵*/ +#define SIGNAL_RELAY_ERROR_DOWN_YES ((UINT8)0xaa) /*ȡ۳ť̵ͨ쳣*/ + +#define SIGNAL_RELAY_ACTION_TIMEMAX ((UINT8)0x0a) /*źŻ̵*/ +#define SIGNAL_OPEN_TO_CLOSE_TIME_DELAY ((UINT8)0x07) /*źŻرն*/ + +#define SIGNAL_RELATED_LOGSEC_MAX_SUM ((UINT16)200) /*վźŻ߼Ŀ*/ +#define SIGNAL_RELATED_AXISSEC_MAX_SUM ((UINT16)40) /*վźŻĿ*/ + +/* źŻǷ */ +#define SIGNAL_DRV_ENABLE ((UINT8)0x55) /* ɼ */ +#define SIGNAL_DRV_DISABLE ((UINT8)0xAA) /* ֻɼ */ + +/*źŻϢ*/ +#define SIGNAL_TYPE_FENG_YELLOW ((UINT8)0x55) /* Ƶ */ +#define SIGNAL_TYPE_FENG_GREEN ((UINT8)0xaa) /* ̵ */ +#define SIGNAL_TYPE_FENG_NO ((UINT8)0xff) /* */ + +#define SIGNAL_EQUAL_ROUTE_MAX_SUM ((UINT16)150) /*ͬźŻΪʼ˵Ľ·Ŀ*/ + +#define SIGNAL_VIRTUAL_YES ((UINT8)0x55) /*źŻΪźŻ*/ +#define SIGNAL_VIRTUAL_NO ((UINT8)0xAA) /*źŻźŻ*/ + +#define SIGNAL_CROSS_ClOSE_YES ((UINT8)0x55) /*ѹص*/ +#define SIGNAL_CROSS_ClOSE_NO ((UINT8)0xAA) /*ǵѹص*/ + + +#define SIGNAL_RELATED_PSD_MAX_SUM ((UINT16)2) /*źŻPSD*/ +#define SIGNAL_RELATED_ESB_MAX_SUM ((UINT8)2) /*źŻESB*/ +#define SIGNAL_PRO_SEC_MAX_SUM ((UINT16)5)/*źŻı*/ + +#define SIGNAL_PRO_SEC_VALID ((UINT8)0x55)/*ͨЧ*/ +#define SIGNAL_PRO_SEC_INVALID ((UINT8)0xaa)/*ͨЧ*/ + + +#define SIGNAL_IN_1ST_MR_ROUTE_PHYSEC_MAX_SUM ((UINT16)5)/*źŻڷһĿ*/ +#define SIGNAL_LIGHTON_MID_COUNT ((UINT32)100) /*źŻǿƵǿƼмֵ*/ +#define SIGNAL_LIGHTON_CHECK_VALUE ((UINT32)2) /*źŻǿƵǿƼȷϲֵ*/ + +#define SIGNAL_CONFIG_CROSS_MASK_NO ((UINT8)0x55) /*ûźŻѹ*/ +#define SIGNAL_CONFIG_CROSS_MASK_YES ((UINT8)0xAA) /*źŻѹ*/ + +#define SIGNAL_BLOCK_OPEN_COLORS_MAX_NUM ((UINT8)3) /*źŻͶӦ󱸿ɫ*/ + +#define SIGNAL_MAX_DRVCOLL_TYPE_NUM ((UINT16)200) /*źŻ*/ + +#define NEIGHBOUR_SIGNAL_DETAIN_DRIVE_NO ((UINT8)0x55) /*վźŻ۳*/ +#define NEIGHBOUR_SIGNAL_DETAIN_DRIVE_YES ((UINT8)0xAA) /*վźŻ۳*/ + +#define MAINTAIN_STATE_NO ((UINT8)0x55) /*źŻά޵״̬*/ +#define MAINTAIN_STATE_YES ((UINT8)0xAA) /*źŻά޵״̬*/ + + +/*źŻ*/ +#define LINK_DIRECTION ((UINT8)0x55) /*LINK*/ +#define NOT_LINK_DIRECTION ((UINT8)0xaa) /*LINK*/ +/****************************************OC źŻ***************************************/ +#define OC_SIGNAL_SHOWCOLOR_RED ((UINT8)0xaa) /**/ +#define OC_SIGNAL_SHOWCOLOR_YELLOW ((UINT8)0x55) /*Ƶ*/ +#define OC_SIGNAL_SHOWCOLOR_YELLOW2 ((UINT8)0x53) /*Ƶ2*/ +#define OC_SIGNAL_SHOWCOLOR_REDYELLOW ((UINT8)0xa5) /*Ƶ*/ +#define OC_SIGNAL_SHOWCOLOR_GREEN ((UINT8)0x5a) /*̵*/ +#define OC_SIGNAL_SHOWCOLOR_GREEN2 ((UINT8)0x35) /*̵2*/ +#define OC_SIGNAL_SHOWCOLOR_WHITE ((UINT8)0xcc) /*׵*/ +#define OC_SIGNAL_SHOWCOLOR_REDWHITE ((UINT8)0x33) /*׵*/ +#define OC_SIGNAL_SHOWCOLOR_BLUE ((UINT8)0xc3) /**/ +#define OC_SIGNAL_SHOWCOLOR_GREENYELLOW ((UINT8)0x5c) /*̻Ƶ*/ +#define OC_SIGNAL_SHOWCOLOR_DOUBLEYELLOW ((UINT8)0xc5) /*˫Ƶ*/ +#define OC_SIGNAL_SHOWCOLOR_DOUBLEGREEN ((UINT8)0xa3) /*˫̵*/ + +#define OC_SIGNAL_SHOWCOLOR_ALL_CLOSE ((UINT8)0x3c) /*е*/ +#define OC_SIGNAL_SHOWCOLOR_RED_BREAK ((UINT8)0x99) /*ƶ˿*/ +#define OC_SIGNAL_SHOWCOLOR_YELLOW_BREAK ((UINT8)0x66) /*Ƶƶ˿*/ +#define OC_SIGNAL_SHOWCOLOR_GREEN_BREAK ((UINT8)0x0f) /*̵ƶ˿*/ +#define OC_SIGNAL_SHOWCOLOR_WHITE_BREAK ((UINT8)0xf0) /*׵ƶ˿*/ +#define OC_SIGNAL_SHOWCOLOR_BLUE_BREAK ((UINT8)0xff) /*ƶ˿*/ +#define OC_SIGNAL_SHOWCOLOR_YELLOW_2_BREAK ((UINT8)0x3a) /*Ƶ2˿*/ +#define OC_SIGNAL_SHOWCOLOR_GREEN_2_BREAK ((UINT8)0xac) /*̵2˿*/ +#define OC_SIGNAL_SHOWCOLOR_UNKNOWN ((UINT8)0x00) /*״̬δ֪ ݰն˿*/ + +#define OC_SIGNAL_DRIVECOLOR_RED ((UINT16)0x00aa) /*oc*/ +#define OC_SIGNAL_DRIVECOLOR_YELLOW ((UINT16)0x0055) /*ocƵ*/ +#define OC_SIGNAL_DRIVECOLOR_REDYELLOW ((UINT16)0x00a5) /*ocƵ*/ +#define OC_SIGNAL_DRIVECOLOR_GREEN ((UINT16)0x005a) /*oc̵*/ +#define OC_SIGNAL_DRIVECOLOR_CLOSE ((UINT16)0x5a00) /*oc*/ +#define OC_SIGNAL_DRIVECOLOR_BLUE ((UINT16)0xa500) /*oc*/ +#define OC_SIGNAL_DRIVECOLOR_WHITE ((UINT16)0xaa00) /*oc׵*/ +#define OC_SIGNAL_DRIVECOLOR_REDWHITE ((UINT16)0x5500) /*oc׵*/ +#define OC_SIGNAL_DRIVECOLOR_GREENYELLOW ((UINT16)0x5a55) /*oc̻Ƶ*/ +#define OC_SIGNAL_DRIVECOLOR_DOUBLEYELLOW ((UINT16)0x5555) /*oc˫Ƶ*/ +#define OC_SIGNAL_DRIVECOLOR_DOUBLEGREEN ((UINT16)0x5a5a) /*oc˫̵*/ + +#define MAX_SIGNAL_LIGHTUPLINK_NUM 50u /* źŻlink *//* 2022.3.4 */ + +#define SIGNAL_LIGHT_CONFIG_LIGHT ((UINT8)0x03u) /*źŻ*/ +#define SIGNAL_LIGHT_CONFIG_CBTC_CLOSE ((UINT8)0x01u) /*CBTCӽʱ*/ +#define SIGNAL_LIGHT_CONFIG_CBTC_LIGHT ((UINT8)0x02u) /*CBTCӽʱ*/ +#define SIGNAL_LIGHT_CONFIG_GEN ((UINT8)0x00u) /*źŻ*/ + +/*źŻ̳ӽ״̬*/ +#define SIG_ENGINEERVEHICNEAR_STE_NO ((UINT8)0x55) /*δӽ*/ +#define SIG_ENGINEERVEHICNEAR_STE_YES ((UINT8)0xaa) /*ӽ*/ + +/*źŻ̳ѹر*/ +#define ENGIN_VEHIC_CROSSCLOSE_STE_NO ((UINT8)0x55) /*δѹ*/ +#define ENGIN_VEHIC_CROSSCLOSE_STE_YES ((UINT8)0xaa) /*ѹ*/ + +#define OC_SIGNAL_BOARD_FAULT_YES (UINT8)0x55 /*źŻ忨*/ +#define OC_SIGNAL_BOARD_FAULT_NO (UINT8)0xaa /*źŻ忨δ*/ + +#define SIGNAL_FUSHINUM_MAX (UINT8)5 /*źŻĸʾźŻ*/ +#define SIGNALTYPE_FUSHI_YES (UINT8)0xaa /*ʽźŻ*/ + +#define SIGNAL_FENDUAN_YES ((UINT8)0x55) /*źŻзֶ*/ +#define SIGNAL_FENDUAN_NO ((UINT8)0xAA) /*źŻзֶ*/ + +/*߳źŻ־*/ +#define SIGNAL_SLEEP_TRAIN_LIGHTUP_YES ((UINT8)0xAAU) /*Ч*/ +#define SIGNAL_SLEEP_TRAIN_LIGHTUP_NO ((UINT8)0x55U) /*Ч*/ + +/*źŻʪ־*/ +#define SIGNAL_IN_HUMID_RAIL_NO ((UINT8)0x55U) /*Ч*/ +#define SIGNAL_IN_HUMID_RAIL_YES ((UINT8)0xAAU) /*Ч*/ + +#endif + + diff --git a/TSCP/src/APP/ciapp/Switch/SwitchConfigDataManage.c b/TSCP/src/APP/ciapp/Switch/SwitchConfigDataManage.c new file mode 100644 index 0000000..ff335b6 --- /dev/null +++ b/TSCP/src/APP/ciapp/Switch/SwitchConfigDataManage.c @@ -0,0 +1,1424 @@ +/******************************************************** +* +* SwitchConfigDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "SwitchConfigDataManage.h" + +SwitchConfigDataStruct SwitchConfigDataStru[SWITCH_SUM_MAX]; /*ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiSwitchIdBuf[SWITCH_SUM_MAX] = {0u}; /*屾IDӳ*/ +INT16 SwitchCurSum = 0; /*ǰ*/ +UINT16 totalSwitchNum = 0u;/*͸*/ + + +/* +* ȡָID +* ˵ const UINT16 switchId, ID +* ֵ SWITCH_SUM_MAX: ȡʧ +* = 1u) && (switchId < SWITCH_SUM_MAX)) + { + retVal = switchId; + } + + return retVal; +} + + +/* +* ȡǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchCurSum(void) +{ + UINT16 retVal = 0u; + if (SwitchCurSum >= (INT16)SWITCH_SUM_MAX) + { + retVal = SWITCH_SUM_MAX; + } + else if (SwitchCurSum < 0) + { + retVal = 0u; + } + else + {/*SwitchCurSum[0,SWITCH_SUM_MAX)ǿת֤ȫ*/ + retVal = (UINT16)SwitchCurSum; + } + return retVal; +} + + +/* +* ȡָ±ӦĵID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetSwitchId(const UINT16 bufIndex) +{ + UINT16 retVal = CI_ERROR; + UINT16 TotalSwitchCurNum = 0u; /*͸Լǰ*/ + TotalSwitchCurNum = GetTotalSwitchCurNum(); + if (bufIndex < TotalSwitchCurNum) + { + retVal = LocalCiSwitchIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID +* ˵ +* ֵ SwitchConfigDataStruct * +*/ +SwitchConfigDataStruct *GetSwitchConfigData(void) +{ + return SwitchConfigDataStru; +} + +/* +* ȡָIDID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSwitchBelongCiId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].BelongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡ˫һID +* ˵ void +* ֵ 0: ȡʧ +* >0: ·ǰ +*/ +UINT16 GetDSwitchOtherId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].DSwitchOtherId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetSwitchType(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + if ((0u < SwitchConfigDataStru[bufIndex].DSwitchOtherId ) && (SWITCH_SUM_MAX >= SwitchConfigDataStru[bufIndex].DSwitchOtherId)) + { + /* ˫ */ + retVal = SWITCH_TYPE_DOUBLE; + } + else if (0u == SwitchConfigDataStru[bufIndex].DSwitchOtherId) + { + /* */ + retVal = SWITCH_TYPE_SINGLE; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetSwitchPhySectionId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].SwitchPhySecId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchDbRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].DbRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDӰģʽλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchShadowDbRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].wShadowDbRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchFbRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FbRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDӰģʽλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchShadowFbRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].wShadowFbRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDʲټ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʲټ̵ID +*/ +UINT16 GetSwitchYcRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].YcRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDټ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʲټ̵ID +*/ +UINT16 GetSwitchDcRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].DcRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDټ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʲټ̵ID +*/ +UINT16 GetSwitchFcRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FcRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDܶλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchZDbRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].ZDbRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDܷλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchZFbRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].ZFbRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ĵ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 SwitchConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 switchConfigDataSum = 0u; /*豸*/ + UINT8 retVal = CI_SUCCESS; + + /*ID*/ + switchConfigDataSum = GetSwitchCurSum(); + totalSwitchNum = switchConfigDataSum; + if (switchConfigDataSum >= SWITCH_SUM_MAX) + {/**/ + + retVal = CI_ERROR; + } + else + { + for (ii = 0u; ii < SWITCH_SUM_MAX; ii++) + { + if (jj == switchConfigDataSum) + {/*Ч*/ + + break; + } + + if (SwitchConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + LocalCiSwitchIdBuf[jj] = SwitchConfigDataStru[ii].SwitchId; + jj++; + } + + + } + } + + + + return retVal; +} + +/* +* +* ˵ switchSum +* switchIdBuff ͸ĵID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendSwitchIdDataManage(UINT16 switchSum,const UINT16 *switchIdBuff) +{ + UINT16 index = 0u; /*±*/ + UINT16 ii = 0u; + UINT8 retVal = 1u; + + if ((totalSwitchNum + switchSum) >= SWITCH_SUM_MAX) + {/*ڷ*/ + retVal = 0u; + } + else + { + index = totalSwitchNum; + totalSwitchNum += switchSum; + for(ii = 0u;ii< switchSum;ii++) + { + LocalCiSwitchIdBuf[index+ii] = switchIdBuff[ii];/*׷ӵLocalCiSwitchIdBuf*/ + } + } + + return retVal; +} + +/* +* ȡ͸Լǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetTotalSwitchCurNum(void) +{ + UINT16 retVal = 0u; + if (totalSwitchNum >= SWITCH_SUM_MAX) + { + retVal = 0u; + } + else + { + retVal = totalSwitchNum; + } + return retVal; +} + +/* +* ȡϼ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchGZJId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].GZJId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡֳ״̵̬ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchJTYJaId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].JTYJaId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ̵ֳID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchQQJId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].QQJId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡռ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchSJFId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].SJFId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* zt ɾش 2022-02-15 */ + +/* +* ȡNλʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeNId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].ThreeNId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡLλʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeLId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].ThreeLId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡRλʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeRId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].ThreeRId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪Nλʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveNId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveNId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪L1λʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveL1Id(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveL1Id; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪L2λʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveL2Id(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveL2Id; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪R1λʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveR1Id(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveR1Id; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪R2λʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveR2Id(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveR2Id; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡNλ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeNYCId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].ThreeNYCId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡLλ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeLYCId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].ThreeLYCId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡRλ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeRYCId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].ThreeRYCId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪Nλ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveNYCId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveNYCId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪L1λ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveL1YCId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveL1YCId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪L2λ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveL2YCId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveL2YCId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪R1λ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveR1YCId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveR1YCId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡ忪R2λ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveR2YCId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FiveR2YCId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDDFH̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: DFH̵ID +*/ +UINT16 GetSwitchDFHRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].DFHRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* zt ɾش 2022-02-15 */ + + +/* +* ȡָIDID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16* GetSwitchHostSwitchIdBuf(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 *pRetVal = NULL; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > bufIndex ) + { + pRetVal = SwitchConfigDataStru[bufIndex].HostSwitchIdBuf; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* ȡָIDĿ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 GetSwitchHostSwitchNum(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > bufIndex ) + { + retVal = SwitchConfigDataStru[bufIndex].HostSwitchNum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDOc ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: Oc ID +*/ +UINT16 GetSwitchBelongOcId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].BelongOcId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSwitchBelongVirCiId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > bufIndex) + { + retVal = SwitchConfigDataStru[bufIndex].BelongVirCI; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDǷ· +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: Ƿ· +*/ +UINT8 GetSwitchIsThisLineState(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > bufIndex) + { + retVal = SwitchConfigDataStru[bufIndex].SwitchIsThisLine; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSwitchDsRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > bufIndex) + { + retVal = SwitchConfigDataStru[bufIndex].DsRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDǰڵ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ǰڵ̵ID +*/ +UINT16 GetSwitchDsQRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > bufIndex) + { + retVal = SwitchConfigDataStru[bufIndex].DsQRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDڵ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ڵ̵ID +*/ +UINT16 GetSwitchDsHRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > bufIndex) + { + retVal = SwitchConfigDataStru[bufIndex].DsHRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID·̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ·̵ID +*/ +UINT16 GetSwitchByPassRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > bufIndex) + { + retVal = SwitchConfigDataStru[bufIndex].ByPassRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ߼ +*/ +UINT16 GetSwitchLogSecSum(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16 retVal = CI_ERROR; + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].SwitchLogSecSum; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָID߼ID +* ˵ const UINT16 switchId, ID +* ֵ NULL: ȡʧ +* NULL: ߼ID +* ޸bug YF0083-119 +*/ +UINT16* GetSwitchLogSecBuf(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + + UINT16* retVal = NULL; + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].SwitchLogSecIdBuf; + } + else + { + + } + + return retVal; +} + +/* +* ȡָIDطID +* ˵ const UINT16 wSwitchId, ID +* ֵ 0: ȡʧ +* >0: ID +* qw.liu 2022-03-01 +*/ +UINT16* GetSwitchProtectSwitchIdBuf(const UINT16 wSwitchId) +{ + UINT16 wBufIndex = 0U; /*±*/ + UINT16 *pRetVal = NULL; + + wBufIndex = GetSwitchConfigBufIndex(wSwitchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > wBufIndex) + { + pRetVal = SwitchConfigDataStru[wBufIndex].wszProtectSwitchIdBuf; + } + else + { + pRetVal = NULL; + } + return pRetVal; +} + +/* +* ȡָIDĿ +* ˵ const UINT16 wSwitchId, ID +* ֵ 0: ȡʧ +* >0: +* qw.liu 2022-03-01 +*/ +UINT16 GetSwitchProtectSwitchNum(const UINT16 wSwitchId) +{ + UINT16 wBufIndex = 0u; /*±*/ + UINT16 wRetVal = CI_ERROR; + + wBufIndex = GetSwitchConfigBufIndex(wSwitchId); /*ȡ±*/ + + if (SWITCH_SUM_MAX > wBufIndex) + { + wRetVal = SwitchConfigDataStru[wBufIndex].wProtectSwitchNum; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/** +* @brief ȡ +* @param const UINT16 switchId ID +* @return +*/ +UINT32 GetSwitchKmById(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = UINT32_MAX; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].dwSwitchKilo; + } + else + { + ; /* */ + } + return retVal; +} + +/* +* ȡָIDλ̵IDʹã +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ̵ID +*/ +UINT16 GetSwitchFbDrvRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].FbDrvRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDλ̵IDʹã +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ̵ID +*/ +UINT16 GetSwitchDbDrvRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].DbDrvRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָID̵IDʹã +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSwitchDsDrvRelayId(const UINT16 switchId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + + bufIndex = GetSwitchConfigBufIndex(switchId); /*ȡ±*/ + + if (bufIndex < SWITCH_SUM_MAX) + { + retVal = SwitchConfigDataStru[bufIndex].DsDrvRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Switch/SwitchConfigDataManage.h b/TSCP/src/APP/ciapp/Switch/SwitchConfigDataManage.h new file mode 100644 index 0000000..e081d29 --- /dev/null +++ b/TSCP/src/APP/ciapp/Switch/SwitchConfigDataManage.h @@ -0,0 +1,569 @@ +/******************************************************** +* +* SwitchConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SWITCH_CONFIG_DATA_MANAGE_H_ +#define _SWITCH_CONFIG_DATA_MANAGE_H_ + + +#include "SwitchDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct S_SwitchConfigDataStruct +{ + UINT16 SwitchId; /*ID (ֶ)*/ + UINT8 BelongCiId; /*ID (ֶ)*/ + UINT16 BelongOcId; /*OC ID (ֶ)*/ + UINT8 BelongVirCI; /**/ + UINT16 DSwitchOtherId; /*˫һID (ֶ)*/ + UINT16 SwitchPhySecId; /*ID (ֶ)*/ + UINT16 SwitchPhySecIdNum; /*࿪ (ֶ)*/ + UINT16 FcRelayId; /*ټ̵ID (ֶ)*/ + UINT16 ZDbRelayId; /*̵ܶID (ֶ)*/ + UINT16 ZFbRelayId; /*̵ܷID (ֶ)*/ + /*йͨü̵*/ + UINT16 DbRelayId; /*̵ID (ֶ) λʾ̵ID*/ + UINT16 FbRelayId; /*̵ID (ֶ) ʾ̵ID*/ + UINT16 YcRelayId; /*ʲټ̵ID (ֶ) λ̵ID*/ + UINT16 DcRelayId; /*ټ̵ID (ֶ) λ̵ID*/ + UINT16 wShadowDbRelayId; /*Ӱģʽ̵ID (ֶ) ˹*/ + UINT16 wShadowFbRelayId; /*Ӱģʽ̵ID (ֶ) ˹*/ + /*Ϊؼ̵*/ + UINT16 GZJId; /*ϼ̵ID (ֶ)*/ + UINT16 JTYJaId; /*ֳ״̵̬ID (ֶ)*/ + UINT16 QQJId; /*̵ֳID(ֶ)*/ + UINT16 SJFId; /*ռ̵ID (ֶ)*/ + UINT16 TYJId; /*ֳͬƼ̵ID (ֶ)*/ + UINT16 ThreeNId; /*Nλʾ̵ID(ֶ)*/ + UINT16 ThreeLId; /*Lλʾ̵ID (ֶ)*/ + UINT16 ThreeRId; /*Rλʾ̵ID(ֶ)*/ + UINT16 FiveNId; /*忪Nλʾ̵ID (ֶ)*/ + UINT16 FiveL1Id; /*忪L1λʾ̵ID(ֶ)*/ + UINT16 FiveL2Id; /*忪L2λʾ̵ID(ֶ)*/ + UINT16 FiveR1Id; /*忪R1λʾ̵ID (ֶ)*/ + UINT16 FiveR2Id; /*忪R2λʾ̵ID (ֶ)*/ + UINT16 ThreeNYCId; /*Nλ̵ID(ֶ)*/ + UINT16 ThreeLYCId; /*Lλ̵ID (ֶ)*/ + UINT16 ThreeRYCId; /*Rλ̵ID(ֶ)*/ + UINT16 FiveNYCId; /*忪Nλ̵ID (ֶ)*/ + UINT16 FiveL1YCId; /*忪L1λ̵ID(ֶ)*/ + UINT16 FiveL2YCId; /*忪L2λ̵ID(ֶ)*/ + UINT16 FiveR1YCId; /*忪R1λ̵ID (ֶ)*/ + UINT16 FiveR2YCId; /*忪R2λ̵ID (ֶ)*/ + UINT16 DFHRelayId; /*DFH̵IDֶΣ*/ + UINT16 HostSwitchIdBuf[SWITCH_HOST_SWITCH_MAX_NUM];/*ID*/ + UINT16 HostSwitchNum; /*ID*/ + UINT16 SwitchLogSecSum; /*߼*/ + UINT16 SwitchLogSecIdBuf[SWITCH_LOG_TRACK_MAX_NUM]; /*߼*/ + UINT8 SwitchIsThisLine; /*Ƿ·*/ + UINT16 DsRelayId; /*̵ID*/ + UINT16 DsQRelayId; /*ǰڵ̵ID*/ + UINT16 DsHRelayId; /*ڵ̵ID*/ + UINT16 ByPassRelayId; /*·̵ID*/ + + UINT16 wProtectSwitchNum; /*鳤 add by qw.liu 2022-02-08*/ + UINT16 wszProtectSwitchIdBuf[SWITCH_PROTECT_SWITCH_MAX_NUM];/*ID add by qw.liu 2022-02-08*/ + + UINT32 dwSwitchKilo; /**/ + UINT8 chKiloType; /**/ + + UINT16 DbDrvRelayId; /*̵ID (ֶ-ʹ)*/ + UINT16 FbDrvRelayId; /*̵ID (ֶ-ʹ)*/ + UINT16 DsDrvRelayId; /*̵ID (ֶ-ʹ)*/ + UINT16 DsDrvQRelayId; /*ǰڵ̵ID (ֶ-ʹ)*/ + UINT16 DsDrvHRelayId; /*ڵ̵ID (ֶ-ʹ)*/ +} SwitchConfigDataStruct; + +typedef struct S_OC_SwitchConfigDataStruct +{ + UINT16 SwitchId; /*ID(ֶ)*/ + UINT16 BelongOcId; /*OCID(ֶ)*/ +}OCSwitchConfigDataStruct; + +/*ɰOCݱ*/ +typedef struct S_OC_SwitchConfigDataStruct_2 +{ + UINT16 SwitchId; /*ID(ֶ)*/ + UINT16 BelongOcId; /*OCID(ֶ)*/ + UINT8 SwitchModuleIdAddrA; /*AϵģID(ֶ)*/ + UINT8 SwitchMachinePosAddrA; /*Aϵת޻λ(ֶ)*/ + UINT8 SwitchModuleIdAddrB; /*BϵģID(ֶ)*/ + UINT8 SwitchMachinePosAddrB; /*Bϵת޻λ(ֶ)*/ +}OCSwitchConfigDataStruct_2; + +/*******************************ȫֱ*******************************/ +extern SwitchConfigDataStruct SwitchConfigDataStru[SWITCH_SUM_MAX]; /*ýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiSwitchIdBuf[SWITCH_SUM_MAX]; /*屾IDӳ*/ +extern INT16 SwitchCurSum; /*ǰ*/ +extern UINT16 totalSwitchNum;/*͸*/ + +/* +* ȡָID +* ˵ const UINT16 switchId, ID +* ֵ SWITCH_SUM_MAX: ȡʧ +* 0: ǰ +*/ +UINT16 GetSwitchCurSum(void); + +/* +* ȡָ±ӦĵID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetSwitchId(const UINT16 bufIndex); + +/* +* ȡָID +* ˵ +* ֵ SwitchConfigDataStruct * +*/ +SwitchConfigDataStruct *GetSwitchConfigData(void); + +/* +* ȡָIDID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSwitchBelongCiId(const UINT16 switchId); + +/* +* ȡ˫һID +* ˵ void +* ֵ 0: ȡʧ +* >0: ·ǰ +*/ +UINT16 GetDSwitchOtherId(const UINT16 switchId); + +/* +* ȡָID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT8 GetSwitchType(const UINT16 switchId); + +/* +* ȡָIDID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16 GetSwitchPhySectionId(const UINT16 switchId); + +/* +* ȡָIDλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchDbRelayId(const UINT16 switchId); + +/* +* ȡָIDλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchFbRelayId(const UINT16 switchId); + +/* +* ȡָIDʲټ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʲټ̵ID +*/ +UINT16 GetSwitchYcRelayId(const UINT16 switchId); + +/* +* ȡָIDټ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʲټ̵ID +*/ +UINT16 GetSwitchDcRelayId(const UINT16 switchId); + +/* +* ȡָIDټ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʲټ̵ID +*/ +UINT16 GetSwitchFcRelayId(const UINT16 switchId); + +/* +* ȡָIDܶλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchZDbRelayId(const UINT16 switchId); + +/* +* ȡָIDܷλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchZFbRelayId(const UINT16 switchId); + +/* +* ĵ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 SwitchConfigDataManage(void); + +/* +* +* ˵ switchSum +* switchIdBuff ͸ĵID +* ֵ 1,ɹ +* 0,ʧ +*/ +UINT8 AddExtendSwitchIdDataManage(UINT16 switchSum,const UINT16 *switchIdBuff); + +/* +* ȡ͸Լǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ͸źŻ +*/ +UINT16 GetTotalSwitchCurNum(void); + +/* +* ȡϼ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchGZJId(const UINT16 switchId); + +/* +* ȡֳ״̵̬ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchJTYJaId(const UINT16 switchId); +/* +* ȡ̵ֳID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchQQJId(const UINT16 switchId); +/* +* ȡռ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchSJFId(const UINT16 switchId); +/* zt ɾش 2022-02-15 */ +/* +* ȡNλʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeNId(const UINT16 switchId); +/* +* ȡLλʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeLId(const UINT16 switchId); +/* +* ȡRλʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeRId(const UINT16 switchId); +/* +* ȡ忪Nλʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveNId(const UINT16 switchId); +/* +* ȡ忪L1λʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveL1Id(const UINT16 switchId); +/* +* ȡ忪L2λʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveL2Id(const UINT16 switchId); +/* +* ȡ忪R1λʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveR1Id(const UINT16 switchId); +/* +* ȡ忪R2λʾ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveR2Id(const UINT16 switchId); +/* +* ȡNλ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeNYCId(const UINT16 switchId); +/* +* ȡLλ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeLYCId(const UINT16 switchId); +/* +* ȡRλ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchThreeRYCId(const UINT16 switchId); +/* +* ȡ忪Nλ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveNYCId(const UINT16 switchId); +/* +* ȡ忪L1λ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveL1YCId(const UINT16 switchId); +/* +* ȡ忪L2λ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveL2YCId(const UINT16 switchId); +/* +* ȡ忪R1λ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveR1YCId(const UINT16 switchId); +/* +* ȡ忪R2λ̵ID +* ˵ void +* ֵ 0: ȡʧ +* >0: ǰ +*/ +UINT16 GetSwitchFiveR2YCId(const UINT16 switchId); + +/* +* ȡָIDDFH̵ID + * ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: DFH̵ID +*/ +UINT16 GetSwitchDFHRelayId(const UINT16 switchId); + +/* zt ɾش 2022-02-15 */ + +/* +* ȡָIDID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT16* GetSwitchHostSwitchIdBuf(const UINT16 switchId); + +/* +* ȡָIDĿ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: +*/ +UINT16 GetSwitchHostSwitchNum(const UINT16 switchId); + +/* +* ȡָIDOc ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: Oc ID +*/ +UINT16 GetSwitchBelongOcId(const UINT16 switchId); +/* +* ȡָIDID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetSwitchBelongVirCiId(const UINT16 switchId); + +/* +* ȡָIDǷ· +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: Ƿ· +*/ +UINT8 GetSwitchIsThisLineState(const UINT16 switchId); + +/* +* ȡָID̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetSwitchDsRelayId(const UINT16 switchId); + +/* +* ȡָIDǰڵ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ǰڵ̵ID +*/ +UINT16 GetSwitchDsQRelayId(const UINT16 switchId); + +/* +* ȡָIDڵ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ڵ̵ID +*/ +UINT16 GetSwitchDsHRelayId(const UINT16 switchId); + +/* +* ȡָID·̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ·̵ID +*/ +UINT16 GetSwitchByPassRelayId(const UINT16 switchId); + +/* +* ȡָID߼ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ߼ +*/ +UINT16 GetSwitchLogSecSum(const UINT16 switchId); + +/* +* ȡָID߼ID +* ˵ const UINT16 switchId, ID +* ֵ NULL: ȡʧ +* NULL: ߼ID +*/ +UINT16* GetSwitchLogSecBuf(const UINT16 switchId); + +/* +* ȡָIDĿ +* ˵ const UINT16 wSwitchId, ID +* ֵ 0: ȡʧ +* >0: +* qw.liu 2022-03-01 +*/ +UINT16 GetSwitchProtectSwitchNum(const UINT16 wSwitchId); + +/* +* ȡָIDطID +* ˵ const UINT16 wSwitchId, ID +* ֵ 0: ȡʧ +* >0: ID +* qw.liu 2022-03-01 +*/ +UINT16* GetSwitchProtectSwitchIdBuf(const UINT16 wSwitchId); + +/* +* ȡָIDӰģʽλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchShadowFbRelayId(const UINT16 switchId); + +/* +* ȡָIDӰģʽλʾ̵ID +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λʾ̵ID +*/ +UINT16 GetSwitchShadowDbRelayId(const UINT16 switchId); + +/** +* @brief ȡ +* @param const UINT16 switchId ID +* @return +*/ +UINT32 GetSwitchKmById(const UINT16 switchId); + +/* +* ȡָIDλ̵IDʹã +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ̵ID +*/ +UINT16 GetSwitchFbDrvRelayId(const UINT16 switchId); + +/* +* ȡָIDλ̵IDʹã +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ̵ID +*/ +UINT16 GetSwitchDbDrvRelayId(const UINT16 switchId); + +/* +* ȡָID̵IDʹã +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ̵ID +*/ +UINT16 GetSwitchDsDrvRelayId(const UINT16 switchId); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Switch/SwitchDataManage.c b/TSCP/src/APP/ciapp/Switch/SwitchDataManage.c new file mode 100644 index 0000000..e9760f2 --- /dev/null +++ b/TSCP/src/APP/ciapp/Switch/SwitchDataManage.c @@ -0,0 +1,2778 @@ +/******************************************************** +* +* SwitchDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹ +* ޸ļ¼ +* +********************************************************/ + +#include "SwitchDataManage.h" +#include "../LogicProcess/InterlockLogicProcess.h" + + + +SwitchDataStruct SwitchDataStru[SWITCH_SUM_MAX]; /*ݽṹ*/ + + + + + +/* +* ȡָID +* ˵ +* ֵ + SwitchDataStruct * +*/ +SwitchDataStruct *GetSwitchData(void) +{ + return SwitchDataStru; +} + +/* +* ȡָ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= 0) + {/*ҿλ*/ + SwitchDataStru[bufIndex].PLockedRouteIdArr[emptyIndex] = pLockId;/*ñid*/ + SwitchDataStru[bufIndex].PLockedRouteNum++; /*id1*/ + } + 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=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= 0) + {/*ҿλ*/ + SwitchDataStru[bufIndex].PLockedOverlapIdArr[emptyIndex] = pLockId;/*ñid*/ + SwitchDataStru[bufIndex].PLockedOverlapNum++; /*id1*/ + } + 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=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= 0) + {/*ҿλ*/ + SwitchDataStru[bufIndex].PLockedNonRouteIdArr[emptyIndex] = pLockId;/*ñid*/ + SwitchDataStru[bufIndex].PLockedNonRouteNum++; /*id1*/ + } + 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=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; + SwitchDataStru[bufIndex].PLockedLogRouteNum = 0u; + for (ii=0u;ii 0u) + {/*յ豸Ŀ0*/ + SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_DAP; + } + else + { + if (cLocalCiId != cSwitchBelongCiId) + { + /*DZڽ·/νʱ·״̬*/ + } + else + { + SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_DANSUO; + } + } + } + else + {/**/ + if (SwitchDataStru[bufIndex].PLockedNonRouteNum + SwitchDataStru[bufIndex].PLockedOverlapNum + + SwitchDataStru[bufIndex].PLockedRouteNum + SwitchDataStru[bufIndex].PLockedLogRouteNum > 0u) + {/*յ豸Ŀ0*/ + SwitchDataStru[bufIndex].LockStatus = SWITCH_LOCK_STATUS_PROTECT; + } + else + { + if (cLocalCiId != cSwitchBelongCiId) + { + /*DZڽ·/νʱ·״̬*/ + } + 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 == SwitchDataStru[bufIndex].PLockedLogRouteIdArr[ii]) + { + emptyIndex = (INT16)ii;/*λֵΪ0ʾΪλס*/ + } + } + + if (pLockLogRouteId == SwitchDataStru[bufIndex].PLockedLogRouteIdArr[ii]) + {/*ҵյid*/ + findFlag = 1u; + } + } + + if (0u == findFlag) + {/*ûҵid*/ + if (emptyIndex >= 0) + {/*ҿλ*/ + SwitchDataStru[bufIndex].PLockedLogRouteIdArr[emptyIndex] = pLockLogRouteId;/*ñid*/ + SwitchDataStru[bufIndex].PLockedLogRouteNum++; /*id1*/ + } + 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 (SwitchDataStru[bufIndex].PLockedLogRouteIdArr[ii] == pLockLogRouteId) + { + targetIndex = (INT16)ii; + SwitchDataStru[bufIndex].PLockedLogRouteIdArr[ii] = 0;/*Ϊ0*/ + break; + } + } + + if (targetIndex >= 0)/*ҵ*/ + { + if (SwitchDataStru[bufIndex].PLockedLogRouteNum > 0U) + { + SwitchDataStru[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 ((SWITCH_POSITION_DINGWEI == curPosition) || (SWITCH_POSITION_FANWEI == curPosition)) + {/* zt ɾش 2022-02-15 */ + /*ǰλ*/ + SwitchDataStru[bufIndex].SingleSwitchCurPosition = curPosition; + + /*ʼʱ*/ + SetSwitchMoveStartCycNum(switchId,0u); + + SetSwitchDrivedFlag(switchId, SWITCH_DRIVED_FLAG_NO); + + } + else if ((SWITCH_POSITION_SIKAI == curPosition) || (SWITCH_POSITION_MOVE == curPosition)) + { + if (0U < SwitchDataStru[bufIndex].SwitDriveStartCycNum) + { + /*־*/ + SetSwitchDrivedFlag(switchId,SWITCH_DRIVED_FLAG_YES); + } + else + { + ; /**/ + } + + 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 + { + ; /*ǵλ/λԴӦ*/ + } +} + +/* +* ȡָIDATSϢ +* ˵ 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 + { + /*DZã*/ + } + } + 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 + { + /*DZã*/ + } + } + } + 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); +} diff --git a/TSCP/src/APP/ciapp/Switch/SwitchDataManage.h b/TSCP/src/APP/ciapp/Switch/SwitchDataManage.h new file mode 100644 index 0000000..94c8c69 --- /dev/null +++ b/TSCP/src/APP/ciapp/Switch/SwitchDataManage.h @@ -0,0 +1,686 @@ +/******************************************************** +* +* SwitchDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SWITCH_DATA_MANAGE_H_ +#define _SWITCH_DATA_MANAGE_H_ + +#include "SwitchDefine.h" +#include "SwitchConfigDataManage.h" +#include "CommonTypes.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../LogRecord/LogRecord.h" +#include "dquVobcCommonStru.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ݽṹ*/ +typedef struct S_SwitchDataStruct +{ + UINT16 SwitchId; /*ID (ֶ)*/ + UINT8 YLockState; /*״̬(δ/) (ֶ̬)*/ + UINT8 LockStatus; /*״̬ (ֶ̬)*/ + UINT8 FLockState; /*״̬(δ/) (ֶ̬)*/ + UINT8 SwitchPrePosition; /*֮ǰλ (ֶ̬)*/ + UINT8 SwitchCurPosition; /*ǰλ (ֶ̬)*/ + UINT8 SingleSwitchCurPosition; /*ǰλã忪 (ֶ̬)*/ + UINT8 SwitchColPosition; /*ǰɼλ*/ + UINT8 SwitchDrivePos; /*λã忪 (ֶ̬)*/ + UINT8 SwitchExpDrvPos; /*λã忪 (ֶ̬)*/ + UINT32 SwitMoveStartCycNum; /*ʼں (ֶ̬)*/ + UINT32 SwitDriveStartCycNum; /*ʼں (ֶ̬)*/ + UINT8 chSwitchDrivedFlag; /*־*/ + UINT8 SwitchDanCaoPostition; /*λ*/ + UINT8 switchDrivingState; /*״̬*/ + UINT8 switchPreExpDrvPos; /*¼õ֮ǰλ*/ + UINT8 switchDrivOvtmDrvPos; /*ʱλ*/ + /**/ + UINT8 switchFaultState; /*״̬*/ + UINT8 switchApplyState; /* ֳ״̬*/ + UINT8 switchAuthorizeState; /*ֳȨ״̬*/ + UINT8 switchKRState; /*״̬*/ + UINT8 switchGrndCtrlApprState; /*ֳͬ״̬*/ + UINT8 switchLastValidDrvPos; /*һЧλ*/ + UINT32 switchLastValidDrvPosCycleNum; /*һЧλòں*/ + UINT16 UsingBelongOverlapId; /*øõıID(Ϊ0 ʾδ)*/ + + UINT8 PLockedRouteNum;/*յĽ·IDֻڱļʹ*/ + UINT16 PLockedRouteIdArr[SWITCH_MAX_PROTECT_LOCKED_NUM]; /*յĽ·ID飬ֻڱļʹ*/ + + UINT8 PLockedOverlapNum;/*յıֻڱļʹ*/ + UINT16 PLockedOverlapIdArr[SWITCH_MAX_PROTECT_LOCKED_NUM];/*յıId飬ֻڱļʹ*/ + + UINT8 PLockedNonRouteNum;/*յķǽ·idֻڱļʹ*/ + UINT16 PLockedNonRouteIdArr[SWITCH_MAX_PROTECT_LOCKED_NUM];/*յķǽ·id飬ֻڱļʹ*/ + + UINT8 PLockedLogRouteNum;/*յ߼·idֻڱļʹ*/ + UINT16 PLockedLogRouteIdArr[SWITCH_MAX_PROTECT_LOCKED_NUM];/*յ߼·id飬ֻڱļʹ*/ + + UINT32 DFHRelayValidCycNum; /*DFH̵ЧDFH̵״̬Ч*/ + UINT32 SigleDFHRelayValidCycNum; /*DFH̵ЧDFH̵״̬Ч*/ + UINT32 YCRelayValidCycNum; /*YC̵ЧYC̵״̬Ч*/ + UINT32 SigleYCRelayValidCycNum; /*YC̵ЧYC̵״̬Ч*/ + UINT8 ConnetSwitchDsState; /*ߵ״̬*/ + UINT8 SwitchByPassState; /*·״̬*/ + UINT32 SwitchBypassStartCycNum; /*ߵ·δʱȡʼ*/ + UINT8 CiToAtsSwitchByPassNoCancelFlag; /*ǷѾATS͹δʱȡı־*/ + UINT8 chSwitchJichaState; /*״̬*/ + UINT8 cSwitchUsingState; /*״̬0x11δã0x22ã0x44ã0x88ȡ*/ + UINT32 SwitchCollTolerateCycNum; /*ɼĿ*/ +} SwitchDataStruct; + +/*******************************ȫֱ*******************************/ +extern SwitchDataStruct SwitchDataStru[SWITCH_SUM_MAX]; /*ݽṹ*/ + +/* +* ȡָID +* ˵ +* ֵ + SwitchDataStruct * +*/ +SwitchDataStruct *GetSwitchData(void); + +/* +* ȡָID״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchYLockState(const UINT16 switchId); + +/* +* ָID״̬ +* ˵ const UINT16 switchId, ID +* const UINT8 yLockState, ״̬ +* ֵ +* +*/ +void SetSwitchYLockState(const UINT16 switchId, const UINT8 yLockState); + +/* +* ȡָID״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchLockStatus(const UINT16 switchId); + + + +/* +* ָID״̬ +* ˵ const UINT16 switchId, ID +* const UINT8 lockStatus, ״̬ +* ֵ +* Modified By LQ 2024.12.09 +*/ +void SetOtherCiSwitchLockStatus(const UINT16 switchId, const UINT8 lockStatus); + +/* +* ָ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); + +/* +* ָID״̬ +* ˵ +* const UINT8 lockType, +* const UINT16 pLockId,յ߼id +* const UINT16 switchId, ID +* const UINT8 lockCommand, +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetSwitchLockStaUseByLogRoute(const UINT16 pLockLogRouteId, const UINT16 switchId, const UINT8 lockCommand); + +/* +* ȡָID״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchFLockState(const UINT16 switchId); + +/* +* ָID״̬ +* ˵ const UINT16 switchId, ID +* const UINT8 fLockState, ״̬ +* ֵ +* +*/ +void SetSwitchFLockState(const UINT16 switchId, const UINT8 fLockState); + +/* +* ȡָID֮ǰλ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ֮ǰλ +*/ +UINT8 GetSwitchPrePosition(const UINT16 switchId); + +/* +* ָID֮ǰλ +* ˵ const UINT16 switchId, ID +* const UINT8 prePosition, ֮ǰλ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSwitchPrePosition(const UINT16 switchId, const UINT8 prePosition); + +/* +* ȡָIDǰλ +* ˵ const UINT16 switchId, ID +* ֵ SWITCH_POSITION_INVALID: λЧ +* : ǰλ +*/ +UINT8 GetSwitchCurPosition(const UINT16 switchId); + +/* +* ȡָIDǰλ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ǰλ +*/ +UINT8 GetSingleSwitchCurPosition(const UINT16 switchId); +/* +* ָIDǰλ +* ˵ const UINT16 switchId, ID +* const UINT8 curPosition, ǰλ +* ֵ +* +*/ +void SetSingleSwitchCurPosition(const UINT16 switchId, const UINT8 curPosition); + +/* +* ָIDǰλ +* ˵ const UINT16 switchId, ID +* const UINT8 curPosition, ǰλ +* ֵ +* +*/ +void SetSwitchCurPosition(const UINT16 switchId, const UINT8 curPosition); + +/* +* ȡָIDλ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetSwitchDrivePostion(const UINT16 switchId); + +/* +* ָIDλ +* ˵ const UINT16 switchId, ID +* const UINT8 drivePosition, λ +* ֵ +* +*/ +void SetSwitchDrivePostion(const UINT16 switchId, const UINT8 drivePosition); + +/* +* ȡָIDʼں +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSwitchMoveStartCycNum(const UINT16 switchId); + +/* +* ָIDʼں +* ˵ const UINT16 switchId, ID +* const UINT32 moveStartCycNum, ʼں +* ֵ +* +*/ +void SetSwitchMoveStartCycNum(const UINT16 switchId, const UINT32 moveStartCycNum); + +/* +* ȡָIDʼں +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSwitchDriveStartCycNum(const UINT16 switchId); + +/* +* ָIDʼں +* ˵ const UINT16 switchId, ID +* const UINT32 driveStartCycNum, ʼں +* ֵ +* +*/ +void SetSwitchDriveStartCycNum(const UINT16 switchId, const UINT32 driveStartCycNum); + + + +/* +* ȡָIDλ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetSwitchDanCaoPostition(const UINT16 switchId); + +/* +* ָIDλ +* ˵ const UINT16 switchId, ID +* const UINT8 position, λ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSwitchDanCaoPosition(const UINT16 switchId, const UINT8 position); + +/* +* ȡָIDλ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetSwitchExpDrvPosition(const UINT16 switchId); + +/* +* ָIDλ +* ˵ const UINT16 switchId, ID +* const UINT8 drivePosition, λ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSwitchExpDrvPosition(const UINT16 switchId, const UINT8 drivePosition); + +/* +* ȡָID״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchDrivingState(const UINT16 switchId); + +/* +* ָID״̬ +* ˵ const UINT16 switchId, ID +* const UINT8 switchDrivingState, ״̬ +* ֵ +* +*/ +void SetSwitchDrivingState(const UINT16 switchId, const UINT8 switchDrivingState); + +/* +* ָID֮ǰϣλ +* ˵ const UINT16 switchId, ID +* const UINT8 drivePosition, λ +* ֵ +* +*/ +void SetSwitchPreExpDrvPosition(const UINT16 switchId, const UINT8 drivePosition); + +/* +* ȡָID֮ǰλ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetSwitchPreExpDrvPosition(const UINT16 switchId); + +/* +* ָIDʱλ +* ˵ const UINT16 switchId, ID +* const UINT8 drivePosition, λ +* ֵ +* +*/ +void SetSwitchDrivOvtmDrvPosition(const UINT16 switchId, const UINT8 drivePosition); + +/* +* ȡָIDʱλ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: λ +*/ +UINT8 GetSwitchDrivOvtmDrvPosition(const UINT16 switchId); +/* +* ָID״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ʧ +* >0: ״̬ +*/ +UINT8 SetSwitchFaultState(const UINT16 switchId,const UINT8 faultState); +/* +* ȡָID״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchFaultState(const UINT16 switchId); + +/* zt ɾش 2022-02-15 */ + +/* +* ָID״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetSwitchKRState(const UINT16 switchId, const UINT8 switchKRState); +/* +* ȡָID״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchKRState(const UINT16 switchId); + +/* zt ɾش 2022-02-15 */ + +/* +* ָIDһεЧλ +* ˵ const UINT16 switchId, ID +* const UINT8 drivePosition, λ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSwitchLastValidDrvPos(const UINT16 switchId, const UINT8 drivePosition); + +/* +* ȡָIDһεЧλ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: һεЧλ +*/ +UINT8 GetSwitchLastValidDrvPos(const UINT16 switchId); + +/* +* ָIDһЧں +* ˵ const UINT16 switchId, ID +* const UINT32 driveStartCycNum, ʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSwitchLastValidPosDrivCycNum(const UINT16 switchId, const UINT32 driveStartCycNum); + +/* +* ȡָIDһЧʼں +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSwitchLastValDrvPosStartCyc(const UINT16 switchId); + +/* +* ȡָID øõıID +* ˵ const UINT16 switchId, ID +* ֵ 0: δ +* >0: øõıID +*/ +UINT16 GetSwitchBelongOverlapId(const UINT16 switchId); + +/* +* ָID̵Чں +* ˵ const UINT16 switchId, ID +* const UINT32 validStartCycNum, ʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSwitchDFHRelayValidCycNum(const UINT16 switchId, const UINT32 validStartCycNum); + +/* +* ȡָID̵Чں +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSwitchDFHRelayValidCycNum(const UINT16 switchId); + +/* +* ָID̵Чں +* ˵ const UINT16 switchId, ID +* const UINT32 driveStartCycNum, ʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSigleSwitchDFHRelayValCyc(const UINT16 switchId, const UINT32 driveStartCycNum); + +/* +* ȡָID̵Чں +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSigleSwitchDFHRelayValCyc(const UINT16 switchId); + +/* +* ָIDʲټ̵Чں +* ˵ const UINT16 switchId, ID +* const UINT32 validStartCycNum, Чʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSwitchYCRelayValidCycNum(const UINT16 switchId, const UINT32 validStartCycNum); + +/* +* ȡָIDʲټ̵Чں +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSwitchYCRelayValidCycNum(const UINT16 switchId); + +/* +* ָIDʲټ̵Чں +* ˵ const UINT16 switchId, ID +* const UINT32 driveStartCycNum, ʼں +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetSingleSwitchYCRelayValCyc(const UINT16 switchId, const UINT32 driveStartCycNum); + +/* +* ȡָIDʲټ̵Чں +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetSingleSwitchYCRelayValCyc(const UINT16 switchId); + +/* +* ȡߵ״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetConnetSwitchDsState(const UINT16 switchId); + +/* +* ߵ״̬ +* ˵ const UINT16 switchId, ID +* const UINT8 dsState ״̬ +* ֵ +* +*/ +void SetConnetSwitchDsState(const UINT16 switchId, const UINT8 dsState); + +/* +* ȡߵ·״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ·״̬ +*/ +UINT8 GetConnetSwitchByPassState(const UINT16 switchId); + +/* +* ߵ·״̬ +* ˵ const UINT16 switchId, ID +* const UINT8 byPassState ·״̬ +* ֵ +* +*/ +void SetConnetSwitchByPassState(const UINT16 switchId, const UINT8 byPassState); + +/* +* ȡߵǷѾATSı־ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ǷѾATSı־ +*/ +UINT8 GetCiToAtsByPassNoCancelFlag(const UINT16 switchId); + +/* +* ߵǷѾATSı־ +* ˵ const UINT16 switchId, ID +* const UINT8 ciToAtsSendFlag Ƿ͵ı־ +* ֵ +* +*/ +void SetCiToAtsByPassNoCancelFlag(const UINT16 switchId, const UINT8 ciToAtsSendFlag); + +/* +* ȡе״̬ +* ˵DQU_POINT_STATUS_STRU* pSwitchInfo, ״̬ +* ֵ ɹ- ʧ-UINT16_MAX +* +*/ +UINT8 GetLocalSwitchState(DQU_POINT_STATUS_STRU* pSwitchInfo); +/* +* õ/λԴ߼ܵݴͣλ߷λԣִ߼ж +* ˵const UINT8 chCmdType +* עcgh-ϲCID-3037-6 +*/ +void SetSwitchTestLogicManage(const UINT8 chCmdType); + +/* +* ȡָIDATSϢ +* ˵ const UINT16 switchId, ID +* ֵ CI_ERROR: ATS +* SWITCH_POSITION_JICHA: ATS +* by cgh 20230919 ATS͵Ӱڲ߼ +*/ +UINT8 GetSwitchPrompylyAlarmInfo(const UINT16 wSwitchId); + +/* +* ȡָIDߵ·δʱȡʼ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ߵ·δʱȡʼں +*/ +UINT32 GetSwitchBypassStartCycNum(const UINT16 switchId); + +/* +* ָIDߵ·δʱȡʼ +* ˵ const UINT16 switchId, ID +* const UINT32 bypassStartCycNum, ߵ·δʱȡʼں +* ֵ +* +*/ +void SetSwitchBypassStartCycNum(const UINT16 switchId, const UINT32 bypassStartCycNum); + +/* +* ȡ־ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ־ +*/ +UINT8 GetSwitchDrivedFlag(const UINT16 switchId); + +/* +* õ־ +* ˵ const UINT16 switchId, ID +* const UINT8 chSwitchDrivedFlag ־ +* ֵ +* +*/ +void SetSwitchDrivedFlag(const UINT16 switchId, const UINT8 chSwitchDrivedFlag); + +/* +* ȡ״̬ +* ˵ const UINT16 switchId, ID +* ֵ 0: ȡʧ +* >0: ״̬ +*/ +UINT8 GetSwitchJichaState(const UINT16 switchId); + +/* +* õ״̬ +* ˵ const UINT16 switchId, ID +* const UINT8 dsState ״̬ +* ֵ +* +*/ +void SetSwitchJichaState(const UINT16 switchId, const UINT8 chJichaState); + +/* +* ȡ״̬ +* ˵const UINT16 wSwitchId ID +* ֵ0 ȡʧ +* 0x11 δ +* 0x22 +* 0x44 +* 0x88 ȡ +* Created By LQ 2024.12.05 +*/ +UINT8 GetSwitchUsingState(const UINT16 wSwitchId); + +/* +* õ״̬ +* ˵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); + +/* +* õɼʼ +* ˵ const UINT16 switchId, ID +* const UINT32 cycNum ں +* ֵ +*/ +void SetSwitchCollTolerateCycNum(const UINT16 switchId, const UINT32 cycNum); + +/* +* ȡɼʼ +* ˵ const UINT16 switchId, ID +* ֵ UINT32 ɼʼ +*/ +UINT32 GetSwitchCollTolerateCycNum(const UINT16 switchId); +/* +* õɼλ +* ˵ const UINT16 switchId, ID +* const UINT8 pos λ +* ֵ +* +*/ +void SetSwitchCollPos(const UINT16 switchId, const UINT8 chSwitchColpos); + +/* +* ȡɼλ +* ˵ const UINT16 switchId, ID +* ֵ ɼɼλ 1λ 2λ 4Ŀ 8ƶ +*/ +UINT8 GetSwitchCollPos(const UINT16 switchId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/Switch/SwitchDefine.h b/TSCP/src/APP/ciapp/Switch/SwitchDefine.h new file mode 100644 index 0000000..1db219f --- /dev/null +++ b/TSCP/src/APP/ciapp/Switch/SwitchDefine.h @@ -0,0 +1,145 @@ +/******************************************************** +* +* SwitchConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-19 +* ߣ +* ͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SWITCH_CONFIG_H_ +#define _SWITCH_CONFIG_H_ + + + +/*ֵ*/ +#define SWITCH_SUM_MAX ((UINT16)500) /*ֵ*/ +#define SWITCH_PHYSECID_SUM_MAX ((UINT16)5) /*ֵ*/ + +/**/ +#define SWITCH_TYPE_SINGLE ((UINT8)0x55) /**/ +#define SWITCH_TYPE_DOUBLE ((UINT8)0xaa) /*˫*/ + + +/*״̬*/ +#define SWITCH_LOCK_YINZONG_NO ((UINT8)0x55) /*δ*/ +#define SWITCH_LOCK_YINZONG_YES ((UINT8)0xaa) /**/ + +/*״̬*/ +#define SWITCH_LOCK_STATUS_NO ((UINT8)0x55) /*δ*/ +#define SWITCH_LOCK_STATUS_DANSUO ((UINT8)0x5a) /**/ +#define SWITCH_LOCK_STATUS_PROTECT ((UINT8)0xa5) /**/ +#define SWITCH_LOCK_STATUS_DAP ((UINT8)0xaa) /*ҷ*/ + +/*߼״̬(ڷ)*/ +#define SWITCH_LOCK_STATUS_DANSUO_NO ((UINT8)0x01) /*δ*/ +#define SWITCH_LOCK_STATUS_PROTECT_NO ((UINT8)0x10) /*δ*/ + +/**/ +#define SWITCH_LOCK_DANSUO_SET ((UINT8)0x01) /*õ*/ +#define SWITCH_LOCK_DANSUO_CANCEL ((UINT8)0x02) /*ȡ*/ +#define SWITCH_LOCK_PROTECT_SET ((UINT8)0x04) /*÷*/ +#define SWITCH_LOCK_PROTECT_CANCEL ((UINT8)0x08) /*ȡ*/ + + +/*״̬*/ +#define SWITCH_LOCK_FENGSUO_NO ((UINT8)0x55) /*δ*/ +#define SWITCH_LOCK_FENGSUO_YES ((UINT8)0xaa) /**/ + +/*λ״̬*/ +#define SWITCH_POSITION_DINGWEI ((UINT8)0x01) /*λ*/ +#define SWITCH_POSITION_FANWEI ((UINT8)0x02) /*λ*/ +#define SWITCH_POSITION_SIKAI ((UINT8)0x04) /*Ŀ*/ +#define SWITCH_POSITION_MOVE ((UINT8)0x08) /*ƶ*/ +#define SWITCH_POSITION_JICHA ((UINT8)0x10) /**/ +#define SWITCH_POSITION_INVALID ((UINT8)0xFF) /*λЧ*/ +/* zt ɾش 2022-02-15 */ +/*λ*/ +#define SWITCH_DRIVE_POS_DINGWEI ((UINT8)0x55) /*λ*/ +#define SWITCH_DRIVE_POS_FANWEI ((UINT8)0xaa) /*λ*/ +#define SWITCH_DRIVE_POS_INVALID ((UINT8)0xFF) /*Ч*/ +/* zt ɾش 2022-02-15 */ + +/*OCɼλ*/ +#define OC_SWITCH_POSITION_DINGWEI ((UINT8)0x55) /*ocλ*/ +#define OC_SWITCH_POSITION_FANWEI ((UINT8)0xaa) /*ocλ*/ +#define OC_SWITCH_POSITION_SIKAI ((UINT8)0xcc) /*ocĿ*/ +#define OC_SWITCH_POSITION_MOVE ((UINT8)0x3c) /*ocƶ*/ +#define OC_SWITCH_POSITION_UNKNOW ((UINT8)0x33) /*ocδ֪*/ + +/*OCλ*/ +#define OC_SWITCH_DRIVE_POS_DINGWEI ((UINT16)0x5555) /*λ*/ +#define OC_SWITCH_DRIVE_POS_FANWEI ((UINT16)0xaaaa) /*λ*/ +#define OC_SWITCH_DRIVE_POS_KEEP ((UINT16)0x55aa) /*λñ*/ + +#define OC_SWITCH_OTHER_BJ_STATE ((UINT8)0xf6) /*OCת޻˷ǣ״̬忨״̬*/ +#define OC_SWITCH_OPEN_CAP_STATE ((UINT8)0x01) /*OCת޻״̬忨״̬*/ + +/*߷*/ +#define SWIT_DRIV_PEAK_TIME_TRUE ((UINT8)0x55) /*վеڵ߷*/ +#define SWIT_DRIV_PEAK_TIME_FALSE ((UINT8)0xAA) /*վûеڵ߷*/ + +/*״̬*/ +#define SWIT_DRIV_IDLE_TIME ((UINT8)0x01) /*ڵ*/ +#define SWIT_DRIV_WAIT_TIME ((UINT8)0x02) /*ڵȴ*/ +#define SWIT_DRIV_PEAK_TIME ((UINT8)0x03) /*ڵ߷*/ +#define SWIT_DRIV_FLAT_TIME ((UINT8)0x04) /*ڵƽ*/ +/*״̬*/ +#define SWITCH_FAULT_STATE_YES ((UINT8)0x55) /**/ +#define SWITCH_FAULT_STATE_NO ((UINT8)0xAA) /*δ*/ + +/*״̬*/ +#define SWITCH_KERAO_STATE_YES ((UINT8)0x55) /**/ +#define SWITCH_KERAO_STATE_NO ((UINT8)0xAA) /**/ +/* zt ɾش 2022-02-15 */ + +#define SWITCH_LAST_DRV_STAY_MAX_NUM ((UINT8)10) /*һЧλ*/ + +#define SWITCH_MOVE_FAIL (UINT8)0x55 /*ƶʧ*/ +#define SWITCH_USING_NORMAL (UINT8)0xaa /*ƶ*/ + +#define SWITCH_MAX_PROTECT_LOCKED_NUM ((UINT16)0x4) /**/ + +#define SWITCH_PLOCKTYPE_DANSUO ((UINT8)0x1) /**/ +#define SWITCH_PLOCKTYPE_ROUTE ((UINT8)0x2) /*·*/ +#define SWITCH_PLOCKTYPE_OVERLAP ((UINT8)0x3) /*η*/ +#define SWITCH_PLOCKTYPE_NONROUTE ((UINT8)0x4) /*ǽ·*/ +#define SWITCH_PLOCKTYPE_NOROUTE_NOOVERLAP_NONONROUTE ((UINT8)0x5) /**/ +#define SWITCH_PLOCKTYPE_LOGROUTE ((UINT8)0x6) /*߼·*/ + +#define SWITCH_OPER_NO_DANCAO ((UINT8)0x55) /*ǵٲ·աաǽ·աԶ·*/ +#define SWITCH_OPER_DANCAO ((UINT8)0xaa) /*ٲ*/ +#define SWITCH_LOG_TRACK_MAX_NUM ((UINT16)10) /*߼*/ + +#define SWITCH_HOST_SWITCH_MAX_NUM ((UINT16)17) /*Ӧ*/ +#define SWITCH_PROTECT_SWITCH_MAX_NUM ((UINT16)17) /*Ӧ*/ + +#define SWITCH_BYPASS_YES ((UINT8)0xaa) /*ߵ·*/ +#define SWITCH_BYPASS_NO ((UINT8)0x55) /*ߵδ·*/ +#define CONNECT_SWITCH_DANSUO_YES ((UINT8)0xaa) /*ߵ*/ +#define CONNECT_SWITCH_DANSUO_NO ((UINT8)0x55) /*ߵδ*/ + +#define CI_ATS_SW_BYPASS_NOCANCEL_YES ((UINT8)0xaa) /*ѾATS͹·δʱȡ*/ +#define CI_ATS_SW_BYPASS_NOCANCEL_NO ((UINT8)0x55) /*δATS͹·δʱȡ*/ + + +#define SWITCH_POSITION_DYNAMIC_JICHA ((UINT8)0x55) /*̬*/ +#define SWITCH_POSITION_SUDDEN_JICHA ((UINT8)0xaa) /*̬*/ + +#define SWITCH_DRIVED_FLAG_YES ((UINT8)0x55) /**/ +#define SWITCH_DRIVED_FLAG_NO ((UINT8)0xaa) /*δ*/ + +/*״̬*/ +#define SWITCH_USING_NO ((UINT8)0x11) /*δ*/ +#define SWITCH_USING_YES ((UINT8)0x22) /**/ +#define SWITCH_USING_APPLY ((UINT8)0x44) /**/ +#define SWITCH_USING_CANCEL ((UINT8)0x88) /*ȡ*/ + +#define COLLTOLERATE_CYCNUM 2U /*ɼ*/ + +#endif + diff --git a/TSCP/src/APP/ciapp/System/CiSystemDefine.h b/TSCP/src/APP/ciapp/System/CiSystemDefine.h new file mode 100644 index 0000000..24b43d8 --- /dev/null +++ b/TSCP/src/APP/ciapp/System/CiSystemDefine.h @@ -0,0 +1,304 @@ +/******************************************************** +* +* CiSystemDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-05-18 +* ߣ +* ϵͳļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _CI_SYSTEM_DEFINE_H_ +#define _CI_SYSTEM_DEFINE_H_ + +/*CIվĿֵ*/ +#define CI_SUM_MAX ((UINT16)25) /*CIվĿֵ*/ +#define CI_COM_CI_MAX_NUM ((UINT16)5) /*ͨ*/ + + +/*ϵͳ*/ +#define CI_SYSTEM_TYPE_CI ((UINT8)0x3C) /*CI*/ +#define CI_SYSTEM_TYPE_ZC ((UINT8)0x1E) /*ZC*/ +#define CI_SYSTEM_TYPE_ATS ((UINT8)0x03) /*ATS*/ +#define CI_SYSTEM_TYPE_TMC ((UINT8)0x2B) /*TMC*/ +#define CI_SYSTEM_TYPE_XIANDI ((UINT8)0x4d) /*ֵ*/ +#define CI_SYSTEM_TYPE_LEU ((UINT8)0x5e) /*LEU*/ +#define CI_SYSTEM_TYPE_VOBC ((UINT8)0x14) /*VOBC*/ +#define CI_SYSTEM_TYPE_VOBC_BACKUP ((UINT8)0x13) /*ͨVOBC*/ +#define CI_SYSTEM_TYPE_PLATFORM ((UINT8)0x9f) /*PSD*/ +#define CI_SYSTEM_TYPE_PSC ((UINT8)0x61) /*PSC*/ +#define CI_SYSTEM_TYPE_OC ((UINT8)0x64) /*豸OC*/ +#define CI_SYSTEM_TYPE_AXIS ((UINT8)0xa0) /*ϵͳ*/ +#define CI_SYSTEM_TYPE_ATS_INTERFACE ((UINT8)0x7d) /*ATS*/ +#define CI_SYSTEM_TYPE_ITE ((UINT8)0x2F) /*ITE*/ + +/*ϵձ־*/ +#define CI_START_LOCK_YES ((UINT8)0xAA) /*ϵ*/ +#define CI_START_LOCK_NO ((UINT8)0x55) /*ϵ*/ +#define CI_START_LOCK_ERROR ((UINT8)0xFF) /*ϵʧ*/ + +/*ʱȡťǷЧ־*/ +#define CI_LINSHIXIANSU_CANCEL_BUTTON_VALID ((UINT8)0xAA) /*ʱȡťЧ*/ +#define CI_LINSHIXIANSU_CANCEL_BUTTON_INVALID ((UINT8)0x55) /*ʱȡťЧ*/ + +/*Ƿй˹ȡʱٵı־*/ +#define LABOUR_CANCEL_LSXS_DONE_YES ((UINT8)0xAA) /*й˹ȡZCͨŹϵ£*/ +#define LABOUR_CANCEL_LSXS_DONE_NO ((UINT8)0x55) /*δй˹ȡZCͨŹϵ£*/ + + +/*˹ȡʱ״̬Ǩ*/ +#define LINSHIXIANSU_COMM_GOOD_STATE ((UINT8)0x00) /*CIZCͨ״̬*/ +#define LINSHIXIANSU_COMM_BAD_STATE ((UINT8)0x01) /*CIZCͨŹ״̬*/ +#define LINSHIXIANSU_LABOURCANCLE_YES_STATE ((UINT8)0x02) /*ѽ˹ȡ״̬*/ + +/*ϵȫվ־*/ +#define CI_START_FLOCK_YES ((UINT8)0xAA) /*ȫվ*/ +#define CI_START_FLOCK_NO ((UINT8)0x55) /*ȫվ*/ +#define CI_START_FLOCK_ERROR ((UINT8)0xFF) /*ȫվʧ*/ + +/*ȫվƱ־*/ +#define CI_ALL_SIGNAL_BRIGHT_YES ((UINT8)0xAA) /*ȫվЧ*/ +#define CI_ALL_SIGNAL_BRIGHT_NO ((UINT8)0x55) /*ȫվЧ*/ + +/*ȫվ־*/ +#define CI_ALL_SWITCH_YLOCK_YES ((UINT8)0xAA) /*ȫվЧ*/ +#define CI_ALL_SWITCH_YLOCK_NO ((UINT8)0x55) /*ȫվЧ*/ + +/*ܸλ־*/ +#define CI_PHYSEC_GENERAL_RESET_YES ((UINT8)0xAA) /*ܸλ־Ч*/ +#define CI_PHYSEC_GENERAL_RESET_NO ((UINT8)0x55) /*ܸλ־Ч*/ + +/* ȷϱ־ */ +#define CI_TSR_SURE_YES ((UINT8)0xAA) /*ȷ*/ +#define CI_TSR_SURE_NO ((UINT8)0x55) /*δȷ*/ + +/*ϵͳ*/ +#define CI_SYSTEM_DIRECTION_UP ((UINT8)0x55) /**/ +#define CI_SYSTEM_DIRECTION_DOWN ((UINT8)0xAA) /**/ +#define CI_SYSTEM_DIRECTION_NONE ((UINT8)0xFF) /*Ч*/ + +/*豸*/ +#define CI_DEVICE_TYPE_SWITCH ((UINT8)0x01) /**/ +#define CI_DEVICE_TYPE_SIGNAL ((UINT8)0x02) /*źŻ*/ +#define CI_DEVICE_TYPE_PHYSEC ((UINT8)0x03) /**/ +#define CI_DEVICE_TYPE_LOGICSEC ((UINT8)0x04) /*߼*/ +#define CI_DEVICE_TYPE_OVERLAP ((UINT8)0x05) /**/ +#define CI_DEVICE_TYPE_ROUTE ((UINT8)0x06) /*·*/ +#define CI_DEVICE_TYPE_PLATFORM ((UINT8)0x07) /*վ̨*/ +#define CI_DEVICE_TYPE_AXISSEC ((UINT8)0x08) /**/ +#define CI_DEVICE_TYPE_ESB ((UINT8)0x09) /*վ̨رհť*/ +#define CI_DEVICE_TYPE_PSD ((UINT8)0x10) /*վ̨*/ +#define CI_DEVICE_TYPE_STOP ((UINT8)0x11) /*гͣϢ*/ +#define CI_DEVICE_TYPE_RELAY ((UINT8)0x12) /*̵*/ +#define CI_DEVICE_TYPE_GROUP_AUTO_ROUTE ((UINT8)0x13) /*Զ·*/ +#define CI_DEVICE_TYPE_CONNECT_SWITCH ((UINT8)0x14) /*ߵ*/ +#define CI_DEVICE_TYPE_NONROUTE ((UINT8)0xA1) /*ǽ·*/ +#define CI_DEVICE_TYPE_AUTORETURN ((UINT8)0xA2) /*Զ۷*/ +#define CI_DEVICE_TYPE_AUTOROUTE ((UINT8)0xA3) /*Զͨ*/ +#define CI_DEVICE_TYPE_LONGROUTE ((UINT8)0xA4) /*·*/ +#define CI_DEVICE_TYPE_SPKS ((UINT8)0xA5) /* SPKSť */ +#define CI_DEVICE_TYPE_GARAGEDOOR ((UINT8)0xA6) /**/ +#define CI_DEVICE_TYPE_WASHMACHINE ((UINT8)0xA7) /* ϴ */ +#define CI_DEVICE_TYPE_ALLAUTORETURN ((UINT8)0xA8) /*ȫԶ۷*/ +#define CI_DEVICE_TYPE_OTHER_CI ((UINT8)0xA9) /* */ +#define CI_DEVICE_TYPE_FLOODGATE ((UINT8)0xB0) /**/ +#define CI_DEVICE_TYPE_LEU ((UINT8)0xB1) /*LEU*/ +#define CI_DEVICE_TYPE_COMM_VOBC ((UINT8)0xB2) /*VOBCͨ*/ +#define CI_DEVICE_TYPE_WASH_LINE ((UINT8)0xB3) /*ϴ*/ +#define CI_DEVICE_TYPE_TAJ ((UINT8)0xB4) /*ͬⰴť̵*/ +#define CI_DEVICE_TYPE_CMDRPLY_VOBC ((UINT8)0xB5) /*VOBC ظ*/ +#define CI_DEVICE_TYPE_TSR_VOBC ((UINT8)0xB6) /*VOBC ʱ*/ +#define CI_DEVICE_TYPE_SLEEP_VOBC ((UINT8)0xB7) /*VOBC ˯г*/ +#define CI_DEVICE_TYPE_FAULT_VOBC ((UINT8)0xB8) /*VOBC г*/ +#define CI_DEVICE_TYPE_CUTOFF_POINT ((UINT8)0xB9) /*ֽ*/ +#define CI_DEVICE_TYPE_OC_BOARD ((UINT8)0xBA) /*OC 忨*/ +#define CI_DEVICE_TYPE_RES_ALIGNMENT ((UINT8)0xBB) /*ԴԶ*/ +#define CI_DEVICE_TYPE_WASH_ALLOW_PASS ((UINT8)0xBC) /*ϴͬͨ*/ +#define CI_DEVICE_TYPE_TRAIN_VOBC ((UINT8)0xBD) /*VOBC г*/ +#define CI_DEVICE_TYPE_BACKUP_VOBC ((UINT8)0xBE) /*VOBCг*/ +#define CI_DEVICE_TYPE_ZHAOCHA ((UINT8)0xC0) /*ղ*/ + + +#define CI_DEVICE_TYPE_CMD ((UINT8)0x0B) /**/ + +/**/ +#define CI_TYPE_ZX ((UINT8)0x01) /**/ +#define CI_TYPE_CLD ((UINT8)0x04) /**/ +#define CI_TYPE_SCX ((UINT8)0x02) /* Գ */ +#define CI_TYPE_TCC ((UINT8)0x03) /* ͣ */ +/*ʱ*/ +#define CI_TIME_NO ((UINT8)0x01) /*δʱ*/ +#define CI_TIME_IN ((UINT8)0x02) /*δʱ*/ +#define CI_TIME_OUT ((UINT8)0x03) /*ʱ*/ + +/*崻־*/ +#define CI_OVER_NO ((UINT8)0x55) /*δ崻*/ +#define CI_OVER_YES ((UINT8)0xaa) /*崻*/ + +/* TIOCɸЧ */ +#define TIOC_WLSCTEEN_VALID ((UINT8)0xAA) /* Ч */ +#define TIOC_WLSCTEEN_UNVALID ((UINT8)0x55) /* Ч */ + +/*****ֵ*****/ + +/*----------Common----------*/ +#define CI_ERROR ((UINT8)0x00) /*ʧ*/ +#define CI_SUCCESS ((UINT8)0x01) /*سɹ*/ +#define CI_ROUTE_RECOVER_ERR ((UINT8)0x03) /*ʧܣǴǻָؿĿǰֻ֣PSDSPKS۳*/ +#define CI_UNLOCK_OVERLAP_REQURE ((UINT8)0x02) /*CTʱ뱣ν*/ +#define CI_CHECK_LEN_ERROR ((UINT8)0x4) /*У*/ +#define CI_ERROR_QXZC ((UINT8)0x05) /*˽·ʱȡղ̵µµRouteExceptLastSecOccuClearCheckʧ*/ + +/*----------Common----------*/ +#define CI_TRUE ((UINT8)0x55) /*سɹ*/ +#define CI_FALSE ((UINT8)0xAA) /*ʧ*/ + +/*αֵ*/ +#define CURSOR_INCREACING_2 ((UINT8)0x02) /*2*/ +#define CURSOR_INCREACING_4 ((UINT8)0x04) /*4*/ + +/*----------Manage----------*/ +/* LockxxxRouteProc, LockxxxRouteLogicProcess*/ +#define RETURN_LOCK_ERR_SWITPOS ((UINT8)0x22) /*·ѡŵλô*/ + +#define RETURN_LOCK_ERR_WAIT_SWCHECK ((UINT8)0x2f) /*·ѡŵȴ*/ + +/* PhySecDelayUnlockLogicProcess*/ +#define RETURN_DELAYUNLOCK_ERR_TIMECOUNT ((UINT8)0x23) /*·رźδر*/ + +/* OpenxxxRouteLogicProcess*/ +#define RETURN_OPEN_ERR_SIGOPEN ((UINT8)0x24) /*·رźδر*/ + +#define RETURN_OPEN_ERR_NEEDOPEN ((UINT8)0x2d) /*·迪ţδ........*/ + +#define RETURN_DCTY_NOT_SATISIFY ((UINT8)0x2e) /*ͬⲻ........*/ + +#define RETURN_AUTOLOCK_ERR_EXCEPT ((UINT8)0x25) /*·δʼ*/ + +#define RETURN_LEADKEEP_SUCC_SETTIME ((UINT8)0x26) /*źſùʱ*/ + +#define RETURN_FIRSTXUANPAI_ERR_WAIT ((UINT8)0x27) /*·õȴ*/ + +#define RETURN_AUTOSIGNAL_THRSEC_CLEAR ((UINT8)0x28) /*ԶźŴδռ*/ + +#define RELAY_STATE_WAITE ((UINT8)0x29) /*̵Ϊ*/ + +#define RETURN_FIRSTXUANPAI_QUXIAOAUTOSIG_WAIT ((UINT8)0x2a) /*·ѡŵȴȡԶźŽ·*/ +#define RETURN_GRGDOOR_CLSCHK_WAITALLOW ((UINT8)0x2b) /* ڹռãȴZCIVOCظ */ +#define ROUTE_DELAY_UNLOCK ((UINT8)0x2c) /* ˽·ʻ־ҽ·ڷһοУʱ */ +#define RES_CHECK_STATE_WAITE ((UINT8)0x2d) /*Դ飬˼̵µȴ*/ +#define RETURN_WAIT_SWITCH_USING ((UINT8)0x30) /*ȴ*/ +#define RETURN_WAIT_SWITCH_CHECK ((UINT8)0x31) /*ȴ*/ + +#define RETURN_GRARAGEDOOR_WAIT_IVOC ((UINT8)0x55) /* Źرռ飺δյIVOCŹرȷϢ */ + +/*ӡ־ֵ*/ +#define RECORD_BUF_MAX 10000U + +/*UDP־ֵֵ*/ +#define UDPSEND_BUF_MAX 10000 + +/*ATSֵӦ֡*/ +#define CI_ATS_STATION_FRAME ((UINT8)0x71) /*վ״̬֡*/ +#define CI_ATS_DEVICE_STATE_FRAME ((UINT8)0x72) /*豸״̬֡*/ + +/* վģʽ */ +#define CI_MODE_ATS ((UINT8)0xaa) /* п */ +#define CI_MODE_CONSTRA_LOCAL ((UINT8)0x55) /* ǿվ */ +#define CI_MODE_CONSOLE ((UINT8)0x71) /* ̨ */ +#define CI_MODE_CI_LOCAL ((UINT8)0xff) /* ģʽ */ +#define CI_MODE_APPLAY_LOCAL ((UINT8)0xBB) /* վ */ + +/* Ȩʱ */ +#define CI_ALL_TSR_VALID ((UINT8)0x55) /* Ч */ +#define CI_ALL_TSR_UNVALID ((UINT8)0xAA) /* Ч */ + +/*ȫѩģʽ*/ +#define CI_ALL_SNOW_VALID ((UINT8)0x55) /*ȫѩģʽЧ*/ +#define CI_ALL_SNOW_UNVALID ((UINT8)0xAA) /*ȫѩģʽЧ*/ + +/*ȫѩģʽ*/ +#define CI_ITE_LINE_CUT_VALID ((UINT8)0x55) /*гITE*/ +#define CI_ITE_LINE_CUT_INVALID ((UINT8)0xAA) /*ʹITE*/ +#define CI_ITE_LINE_CUT_DEFAULT ((UINT8)0xFF) /*Ĭֵ*/ + +/*ȫʱ*/ +#define CI_ALL_LINE_TSR_VALID ((UINT8)0x55) /*ȫʱЧ*/ +#define CI_ALL_LINE_TSR_UNVALID ((UINT8)0xAA) /*ȫʱЧ*/ + +/* Գ״̬ */ +#define CI_TRAIN_TEST_OFF ((UINT8)0xFF) /* Գ ,Գɼ,TYSJ */ +#define CI_TRAIN_TEST_START ((UINT8)0x01) /* Գť */ +#define CI_TRAIN_TEST_ON ((UINT8)0x02) /* ԳУɼͬԳ̵ */ +#define CI_TRAIN_TEST_STOP ((UINT8)0x03) /* ԳȡԳť */ + +/*Գ복βͨŽӿʱԳ豸ID״̬*/ +#define COMM_TRAIN_TEST_SQAJ_SCX ((UINT8)0x01) /*ԳԳ豸Ӧ̵ӿڵSQAJ̵*/ +#define COMM_TRAIN_TEST_YSKJ_SCX ((UINT8)0x02) /*ԳͬԳ豸ɼӦ̵ӿڵTSKJ̵*/ +#define COMM_TRAIN_TEST_SQJ_CLD ((UINT8)0x03) /*Գ豸ɼӦ̵ӿڵSQAJ̵*/ +#define COMM_TRAIN_TEST_TYSJ_CLD ((UINT8)0x04) /*ͬԳ豸Ӧ̵ӿڵTYSJ̵*/ + +#define COMM_TRAIN_TEST_DEV_STATE_VALID ((UINT8)0x55) /*豸״̬Ч*/ +#define COMM_TRAIN_TEST_DEV_STATE_INVALID ((UINT8)0xAA) /*豸״̬Ч*/ + +#define VOBC_SUM_MAX 100U /*豸IDΪ1ֽڣĿǰVOBC100*/ +#define VOBC_BACKUP_SUM_MAX 256U /*ĿǰͨVOBC255*/ + +#define ITE_SUM_MAX ((UINT8)VOBC_SUM_MAX) /*ITEֵ*/ +#define VOBC_INC_ITE_SUM_MAX ((UINT16)2U) /*VOBCITEֵ*/ + +#define CI_TRADITION_RAILWAY ((UINT8)0x55) /*йͨ*/ +/* zt ɾش 2022-02-15 */ + +/*Զ·־*/ +#define AUTO_TRIGGER_SET_YES ((UINT8)0x55) /*Զ־*/ +#define AUTO_TRIGGER_SET_NO ((UINT8)0xAA) /*δԶ־*/ + +#define ZC_SUM_MAX ((UINT16)15) /*CIͨŵZC IDֵݶΪ15*/ +#define TMC_SUM_MAX ((UINT16)15) /*TIOCͨŵTMC IDֵݶΪ15*/ + +/*JKJɼ֮ΪЧ*/ +#define JKJ_REYLAY_VALID_CYCLE_NUM ((UINT16)10) /*JKJɼ֮ΪЧ*/ +#define JKJ_REYLAY_INVALID ((UINT8)0x55) /*JKJӦЧ*/ +#define JKJ_REYLAY_VALID ((UINT8)0xaa) /*JKJӦЧ*/ + +/*ZFWJɼ֮󱨾ܸλ̵Ч*/ +#define ZFWJ_REYLAY_VALID_CYCLE_NUM ((UINT32)3) /*ZFWJɼ֮ΪЧ*/ + +#define OC_SUM_MAX ((UINT16)100) /*CIͨŵOC IDֵ*/ +#define AXLE_SUM_MAX ((UINT16)100) /*CIͨŵļϵͳ IDֵ*/ + +#define TIOCFS_VERSION_LENGTH 4U /*汾ų*/ + +#define OVERLAPCILOCK_YES (UINT8)(0xaa) /*ձ־*/ +#define OVERLAPCILOCK_NO (UINT8)(0x55) /*β*/ + +/*վֵعվȡȨ־*/ +#define CONTRAL_POWER_NO ((UINT8)0x55)/*޿ȨȨ״̬*/ +#define CONTRAL_POWER_YES ((UINT8)0xaa)/*пȨ*/ + +/*ϵͳͨŵ*/ +#define CI_TRAINSMIT_AXIS_MAX_NUM ((UINT8)3) /*ϵͳͨŵ*/ + +/*ϵͳͨŵ*/ +#define CI_TRAINSMIT_CI_MAX_NUM ((UINT8)6) /*ϵͳͨŵ*/ + +/*OCϵͳͨŵ*/ +#define CI_TRAINSMIT_OC_MAX_NUM ((UINT8)10) /*OCϵͳͨŵ*/ + +#define OVERLAP_ROUTE_FLAG_YES 0xAAU /*־*/ +#define OVERLAP_ROUTE_FLAG_NO 0x55U /*־*/ + +/*LEUATSı־*/ +#define LEU_TO_ATS_ERRORFLAG_YES 0xAAU /*յLEUҪATS*/ +#define LEU_TO_ATS_ERRORFLAG_NO 0x55U /*յLEUATS*/ + +/*ѩģʽ*/ +#define CI_LOCAL_SNOW_UNVALID ((UINT8)0x55) /*ѩģʽЧ*/ +#define CI_LOCAL_SNOW_VALID ((UINT8)0xAA) /*ѩģʽЧ*/ + +#endif + diff --git a/TSCP/src/APP/ciapp/System/SystemConfigDefine.h b/TSCP/src/APP/ciapp/System/SystemConfigDefine.h new file mode 100644 index 0000000..a71feb5 --- /dev/null +++ b/TSCP/src/APP/ciapp/System/SystemConfigDefine.h @@ -0,0 +1,116 @@ +/******************************************************** +* +* SystemConfig.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-26 +* ߣ +* ϵͳͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + + +#ifndef _SYSTEM_CONFIG_H_ +#define _SYSTEM_CONFIG_H_ + + +#include "ci_integrate_config.h" +#if 0 +#define SCADE_MODE /*SCADEģʽ*/ +#endif + +#define PLATFORM_2OO2 /*2oo2ƽ̨*/ + + +#define LOGPRINT /*־ӡ*/ +#define APPCI_MAINTAIN_DEBUG /*ά޻ӿں*/ + +#ifndef PLATFORM_2OO2 + +#else +#define APPCI_LOG_RECORD /*־¼*/ +#endif + + +#ifdef PLATFORM_2OO2 +#define DataPath "RCI.FS" /*ļ洢·*/ +#endif + +/*******************************ϵͳͨǷʹЭغ꿪***********************************/ + + + +#ifdef PLATFORM_LABVIEW_DEBUG +/*ͨŽӿڿ*/ +#if 0 +#define ZC_USE_UDP /*ZCͨ*/ +#define ATS_USE_UDP /*ATSͨ*/ +#define CI_USE_UDP /*CIͨ*/ +#define VOBC_USE_UDP /*VOBCͨ*/ +#define PSD_USE_UDP /*PSDͨ*/ +#define LEU_USE_UDP /*Leuͨ*/ +#define MAINTEN_USE_UDP /*ά޻ͨ*/ +#endif +#define DataPath "CI.FS" /*ļ洢·*/ +#define LocalCiIdPath "LocalCiId.ini" /*IDļ*/ +#endif + +/*V13.0汾ݽṹ 2018.8.3*/ +/*汾*/ +#define VER_MAIN_SUBCI_CI_CID ((UINT8)19) /*ϵͳ汾*/ +#define VER_SUB_SUBCI_CI_CID ((UINT8)0) /*ϵͳӰ汾*/ +#define VER_BRUNCH_CI_CID ((UINT8)0) /*֧汾..........0....֧1 2 */ +#define VER_RETURN_SUBCI_CI_CID ((UINT8)2) /*ϵͳع汾*/ + +#ifdef SCADE_MODE +/*SCADE汾*/ +#define VER_SOFT_PRODUCT ((UINT8)40) /*Ʒ*/ +#define VER_SOFT_MODUAL_APP ((UINT8)2) /*ģ*/ +#define VER_SOFT_MIANVERSION ((UINT8)0) /*汾*/ +#define VER_SOFT_SUBVERSION ((UINT8)199) /*Ӱ汾*/ + +#else +/*д汾*/ +#define VER_SOFT_PRODUCT ((UINT8)40) /*Ʒ*/ +#define VER_SOFT_MODUAL_APP ((UINT8)1) /*ģ*/ +#define VER_SOFT_MIANVERSION ((UINT8)19) /*汾*/ +#define VER_SOFT_SUBVERSION ((UINT8)3) /*Ӱ汾*/ + +#endif + +/*ɼݵĹݽṹ汾*/ +#define VER_1_PUBLIC_FS_1 ((UINT8)30) +#define VER_1_PUBLIC_FS_2 ((UINT8)14) +#define VER_1_PUBLIC_FS_3 ((UINT8)0) +#define VER_1_PUBLIC_FS_4 ((UINT8)0) + +#define VER_2_PUBLIC_FS_1 ((UINT8)0) +#define VER_2_PUBLIC_FS_2 ((UINT8)0) +#define VER_2_PUBLIC_FS_3 ((UINT8)0) +#define VER_2_PUBLIC_FS_4 ((UINT8)0) + +#define VER_3_PUBLIC_FS_1 ((UINT8)0xFF) +#define VER_3_PUBLIC_FS_2 ((UINT8)0xFF) +#define VER_3_PUBLIC_FS_3 ((UINT8)0xFF) +#define VER_3_PUBLIC_FS_4 ((UINT8)0xFF) + + +/*ɼݵ˽ݽṹ汾*/ +#define VER_1_PRIVATE_FS_1 ((UINT8)39) +#define VER_1_PRIVATE_FS_2 ((UINT8)0) + +#define VER_2_PRIVATE_FS_1 ((UINT8)0xFF) +#define VER_2_PRIVATE_FS_2 ((UINT8)0xFF) + +#define VER_3_PRIVATE_FS_1 ((UINT8)0xFF) +#define VER_3_PRIVATE_FS_2 ((UINT8)0xFF) + +/*ɼOCݽṹ汾*/ +#define VER_1_OCDATA_FS_1 ((UINT8)27) /*oc 3.0 ݰ汾*/ +#define VER_1_OCDATA_FS_2 ((UINT8)0) + +#define VER_2_OCDATA_FS_1 ((UINT8)24) /*oc 2.1.6*/ +#define VER_2_OCDATA_FS_2 ((UINT8)1) +#endif diff --git a/TSCP/src/APP/ciapp/System/SystemParameterManage.c b/TSCP/src/APP/ciapp/System/SystemParameterManage.c new file mode 100644 index 0000000..0f93563 --- /dev/null +++ b/TSCP/src/APP/ciapp/System/SystemParameterManage.c @@ -0,0 +1,2889 @@ +/******************************************************** +* +* SystemParameterManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* ϵͳ +* ޸ļ¼ +* +********************************************************/ + +#include "SystemParameterManage.h" +#include "../QueryFiles/dquCIPZStru.h" + + + +UINT8 LocalCiId = 0u; /*ID*/ + +static UINT8 LocalCiPattern = 0u; /*ģʽ*/ +static UINT8 LocalCiIsDistributedIO = 0u;/*ǷǷֲʽIO*/ +static UINT16 LocalUTProtectSecUnlockTime = 0u;/*UTνͣʱ䣨s*/ +static UINT16 LocalCTProtectSecUnlockTime = 0u;/*CTνͣʱ䣨s*/ +static UINT16 LocalUTNearUnLockTime = 0u;/*UTӽʱʱ䣨s*/ +static UINT16 LocalCTNearUnLockTime = 0u;/*CTӽʱʱ䣨s*/ +static UINT8 LocalWaysidePattern = 0u; /*Լ̵ӿ*/ +/* RCϲTIOCܻ */ +static UINT8 LocalRcWorkMode = 0u; /* RCģʽ */ +static UINT8 gLocalRcLinkLineAttr = 0u; /* RC */ + +UINT8 gLocalOcType = 0u; /*OCݽṹ*/ + + +SystemParameterStructNew SystemParameterStruNew;/*ϵͳ*/ + +DquCiFuncSwitchStructNew CiFuncSwitConfStruNew[CI_FUNCTION_SWITCH_SUM_MAX];/*ܿؽṹ*/ + + +UINT32 StartUnlockCount = 0u; /*ϵ (ʼֶ)*/ +UINT32 RouteXuanPaiCount = 0u; /*·ѡų (ʼֶ)*/ +UINT32 RouteLockCount = 0u; /*·ճ (ʼֶ)*/ +UINT32 OverlapLockCount = 0u; /*ճ (ʼֶ)*/ +UINT32 RouteOpenSignalCount = 0u; /*·ųʱ(λ:s) (ֶ)*/ +UINT32 BlocRouteDelayCount = 0u; /*ʽ·ʱ (ʼֶ)*/ +UINT32 CbtcRouteDelayCount = 0u; /*CBTC·ʱ (ʼֶ)*/ +UINT32 LeadRouteFaultOpenCount = 0u; /*·ڷιźſų (ʼֶ)*/ +UINT32 SecDelayUnlockCount = 0u; /*ʱ (ʼֶ)*/ +UINT32 SignalOpenCount = 0u; /*źſų (ʼֶ)*/ +UINT32 SignalCloseCount = 0u; /*źŹرճ (ʼֶ)*/ +UINT32 SwitchMoveCount = 0u; /* (ʼֶ)*/ +UINT32 SwitchDriveCount = 0u; /* (ʼֶ)*/ +UINT32 ProtectSecUnlockCount = 0u; /*νͣ (ʼֶ)*/ +UINT32 OccupyToIdleCount = 0u; /*ռñмʱ (ʼֶ)*/ +UINT32 FaultUnlockCount = 0u; /*׹ʽʱ (ʼֶ)*/ +UINT32 SectionResetCount = 0u; /*Ḵλʱ (ʼֶ)*/ +UINT32 NonRouteXuanPaiCount = 0u; /*ǽ·ѡ (ʼֶ)*/ +UINT32 NonRouteDelayUnlockCount = 0u; /*ǽ·ʱ (ʼֶ)*/ +UINT32 SwitchDriveCuoFengCount = 0u; /*·ѡŵ (ʼֶ)*/ +UINT32 ZuheRouteXuanPaiCount = 0u; /*Ͻ·ѡ (ʼֶ)*/ +UINT32 CiAndZcTransmitBadEnsureCount = 0u; /*ZCͨжȷ(ʼֶ)*/ +UINT32 CiAndCiTransmitBadEnsureCount = 0u; /*ͨжȷ(ʼֶ)*/ +UINT32 CiAndVobcTransmitBadEnsureCount = 0u; /*Vobcͨжȷ(ʼֶ)*/ +UINT32 VobcAndCiBackUpCommBadCount = 0U; /*IvocVobcͨͨжȷ(ʼֶ)*/ +UINT32 CiAndPsdTransmitBadEnsureCount = 0u; /*PSDͨжȷ(ʼֶ)*/ +UINT32 TiocAndTmcTransmitBadEnsureCnt = 0u; /*TIOCTMCͨжȷ(ʼֶ)*/ +UINT32 WaitZCResponseCount = 0u; /*ȴZCʱ䣨رճţ(ʼֶ)*/ +UINT32 SecJumpLockDelayUnlockCount = 0u; /*ԾʱʼֶΣ*/ +UINT32 GaragedoorOperateCount = 0u; /*ŶʱʼֶΣ*/ +UINT32 CtProtectSecUnlockCount = 0u; /*ͨųռ÷νͣ (ʼֶ)*/ +UINT32 SingleSwitchMoveCount = 0u; /*쵥 (ʼֶ)*/ +UINT32 ThreeSwitchMoveCount = 0u; /* (ʼֶ)*/ +UINT32 FiveSwitchMoveCount = 0u; /*忪 (ʼֶ)*/ +UINT32 gapDetectTimeCount = 0u; /*϶̽ʱ䳬 (ʼֶ)*/ +UINT32 psdButtonPressTimeCount = 0u; /*վ̨ťʧЧʱ䳬 (ʼֶ)*/ +UINT32 DCTYWaitSignalOpenCount = 0u; /*ͬȴźſʱ(λ:s)*/ +UINT32 CiAndPscTransBadEnsureCount = 0u; /*Pscͨжȷʱ(λ:s)*/ +UINT32 ZFWJRelayDriveTimeCount = 0u; /*ܸλʱ(λ:s)*/ +UINT32 DHFRelayValidTimeCount = 0u; /*λDFH̵ʱ()*/ +UINT32 FirstOrderTimeCount = 0u; /*һЧʱ()*/ +UINT32 JXTCPulseContinueTimeCount = 0u; /*϶̽ʱ*/ +UINT32 labarUnlockOverlapTimeCount = 0u; /*˹ʱʱ*/ +UINT32 sigCollectRongrenCount = 0u; /*OCźŻȫʱ*/ +UINT32 AxleSectionUtRedundanceCount = 0U; /*UTռ*/ +UINT8 versionOfZCToCI = 0u; /*ZC-CIӿЭ汾ţadd by sds 2019-1-21*/ +UINT8 versionOfVOBCToCI = 0u; /*VOBC-CIӿЭ汾ţadd by sds 2019-1-21*/ +UINT8 versionOfTMCToTIOC = 0u; /*TMC-TIOCӿЭ汾*/ + +UINT16 wTsrMaxCmdSum = 0u; /* ǰʱ */ +UINT16 wTsrMaxSecSum = 0u; /* ǰʱ */ + +UINT32 CiAndAxleTransBadEnsureCnt = 0u; /*ϵͳͨжȷ(ʼֶ)*/ +UINT32 CiAndAxleTransBadEnsureTime = 0u; /*ϵͳͨжȷʱ(ʼֶ)*/ +UINT32 CiAndOcTransmitBadEnsureCount = 0u; /*Ocͨжȷ(ʼֶ)*/ +UINT32 CiAndOcTransmitBadEnsureTime = 0u; /*Ocͨжȷʱ(ʼֶ)*/ +UINT32 psdDrivCloseMaxTimeCount = 0u; /*Źرʱ*/ +UINT32 psdDrivOpenMaxTimeCount = 0u; /*Ŵʱ*/ +UINT32 SpksIndicDelayCount = 0u; /*SPKSťָʾƵʱʱ*/ +UINT32 mjjsOpenDelayCount = 0u; /*Žʱʱʱʱ*/ +UINT8 ciAndAxisPrtclCheckVer = 0u; /*֮Э汾*/ +UINT32 dwSelfButCollCount = 0u; /*ԸʽťӦ̵ɼʱ*/ +UINT32 dwSelfButErrCount = 0u; /*Ըʽ۳/ťжʱ*/ +UINT32 dwTrainRecycleCount = 0u; /*Դռʱ (ʼֶ)*/ +UINT32 dwSelfCancelButErrCount = 0u; /*Ըʽȡ۳/ťжʱ*/ +UINT32 dwRouteNearestTrainRenJieCount = 0U; /*·ӽгҪԽ·˽ʱʱȴʱ*/ +UINT32 dwSGBJRouteDelayOpenCount = 0U; /*ⱨ·ʱ*/ +UINT32 dwFloodGateDelayCloseCount = 0U; /*Žӽռӳٹ*/ +UINT32 dwSwitchBypassWaitCount = 0U; /*ߵδʱȡ·ȴ*/ +UINT32 dwSelfCancelButErrTriggerCount = 0U; /*Ըʽȡ۳/ť󴥷жʱ*/ +UINT16 wArbNearSecProtectDistance = 0U; /*ARB*/ +UINT32 dwArbNearSecNoUtCount = 0U; /*ARBʱ*/ +UINT32 dwNonReturnBtnErrEnsureTime = 0U;/*۷ťж*/ +UINT8 gCTFlyingRedunCount = 0u; +UINT16 StationTrackDistance = 0U; /*-վ̨׷ʱг루cm*/ +UINT32 LineMinTrainLength = 0U; /*-·С*/ +CiOcRelateion CiOcRelationArr[CI_SUM_MAX];/*ci ocϵ*/ + +static UINT16 g_TiocFsVersion[TIOCFS_VERSION_LENGTH] = { 0u };/* TIOCݰ汾 */ + +/* +* ϵͳʱת +* ˵ void +* ֵ void +*/ +void SystemParaTimeToCycleCount(void) +{ + UINT16 paraVal = 0u;/*ֵ*/ + + UINT32 appCycleTime = 0u; + + appCycleTime = GetSystemParaValue(AppCycleTime_ID); + + paraVal = GetSystemParaValue(StartUnlockTime_ID); + StartUnlockCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ϵ (ʼֶ)*/ + + paraVal = GetSystemParaValue(RouteXuanPaiTime_ID); + RouteXuanPaiCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*·ѡų (ʼֶ)*/ + + paraVal = GetSystemParaValue(RouteLockTime_ID); + RouteLockCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*·ճ (ʼֶ)*/ + + paraVal = GetSystemParaValue(OverlapLockTime_ID); + OverlapLockCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ճ (ʼֶ)*/ + + paraVal = GetSystemParaValue(RouteOpenSigTime_ID); + RouteOpenSignalCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*·ųʱ(λ:s) (ֶ)*/ + + paraVal = LocalUTNearUnLockTime; + BlocRouteDelayCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ʽ·ʱ (ʼֶ)*/ + + paraVal = LocalCTNearUnLockTime; + CbtcRouteDelayCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*CBTC·ʱ (ʼֶ)*/ + + paraVal = GetSystemParaValue(LeadRouteFaultOpenTime_ID); + LeadRouteFaultOpenCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*·ڷιźſų (ʼֶ)*/ + + paraVal = GetSystemParaValue(SecDelayUnlockTime_ID); + SecDelayUnlockCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ʱ (ʼֶ)*/ + + paraVal = GetSystemParaValue(SignalOpenTime_ID); + SignalOpenCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*źſų (ʼֶ)*/ + + paraVal = GetSystemParaValue(SignalCloseTime_ID); + SignalCloseCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*źŹرճ (ʼֶ)*/ + + paraVal = GetSystemParaValue(SwitchMoveTime_ID); + SwitchMoveCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /* (ʼֶ)*/ + + paraVal = GetSystemParaValue(SwitchDriveTime_ID); + SwitchDriveCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /* (ʼֶ)*/ + + paraVal = LocalUTProtectSecUnlockTime; + ProtectSecUnlockCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*νͣ (ʼֶ)*/ + + paraVal = GetSystemParaValue(OccupyToIdleTime_ID); + OccupyToIdleCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ռñмʱ (ʼֶ)*/ + + paraVal = GetSystemParaValue(FaultUnlockTime_ID); + FaultUnlockCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*׹ʽʱ (ʼֶ)*/ + + paraVal = GetSystemParaValue(SectionResetTime_ID); + SectionResetCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*Ḵλʱ (ʼֶ)*/ + + paraVal = GetSystemParaValue(NonRouteXuanPaiTime_ID); + NonRouteXuanPaiCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ǽ·ѡ (ʼֶ)*/ + + paraVal = GetSystemParaValue(NonRouteDelayUnlockTime_ID); + NonRouteDelayUnlockCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ǽ·ʱ (ʼֶ)*/ + + paraVal = GetSystemParaValue(SwitchDriveCuoFengTime_ID); + SwitchDriveCuoFengCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*·ѡŵ (ʼֶ)*/ + + paraVal = GetSystemParaValue(ZuheRouteXuanPaiTime_ID); + ZuheRouteXuanPaiCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*Ͻ·ѡ (ʼֶ)*/ + + paraVal = GetSystemParaValue(WaitZCResponseTime_ID); + WaitZCResponseCount = TimeToCycleCount((UINT32)paraVal,appCycleTime); /*ȴZCʱ䣨رճţ(ʼֶ)*/ + + paraVal = GetSystemParaValue(SecJumpLockDelayUnlockTime_ID); + SecJumpLockDelayUnlockCount = TimeToCycleCount((UINT32)paraVal * 1000U,appCycleTime); /*Ծʱ(ʼֶ)*/ + + paraVal = GetSystemParaValue(GaragedoorOperateTime_ID); + GaragedoorOperateCount = TimeToCycleCount((UINT32)paraVal * 1000U,appCycleTime); /*ŶʱʼֶΣ*/ + + paraVal = LocalCTProtectSecUnlockTime; + CtProtectSecUnlockCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ͨųռý·һµķνͣ (ʼֶ)*/ + + paraVal = GetSystemParaValue(SingleSwitchMoveTime_ID); + SingleSwitchMoveCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*쵥 (ʼֶ)*/ + + paraVal = GetSystemParaValue(ThreeSwitchMoveTime_ID); + ThreeSwitchMoveCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /* (ʼֶ)*/ + + paraVal = GetSystemParaValue(FiveSwitchMoveTime_ID); + FiveSwitchMoveCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*忪ʱ(s)*/ + + paraVal = GetSystemParaValue(gapDetectTime_ID); + gapDetectTimeCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*϶̽ⳬ (ʼֶ)*/ + + paraVal = GetSystemParaValue(psdButtonPressTime_ID); + psdButtonPressTimeCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*վ̨ťʧЧ (ʼֶ)*/ + + paraVal = GetSystemParaValue(DCTYWaitSignalOpenCount_ID); + DCTYWaitSignalOpenCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ͬȴźؿʱ(ʼֶ)*/ + + paraVal = GetSystemParaValue(ZFWJRelayDriveTime_ID); + ZFWJRelayDriveTimeCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ܸλ(ʼֶ)*/ + + paraVal = GetSystemParaValue(CiAndAxleTransmitBadEnsureTime_ID); + CiAndAxleTransBadEnsureTime = paraVal; /*CI-ϵͳͨŹжʱֵ*/ + CiAndAxleTransBadEnsureCnt = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*CI-ϵͳͨŹжʱ(ʼֶ)*/ + + paraVal = GetSystemParaValue(CiAndOCTransmitBadEnsureTime_ID); + CiAndOcTransmitBadEnsureTime = paraVal; /*CI-OCͨŹжʱֵ*/ + CiAndOcTransmitBadEnsureCount = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*CI-OCͨŹжʱ(ʼֶ)*/ + + paraVal = GetSystemParaValue(DHFRelayValidTime_ID); + DHFRelayValidTimeCount = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*λDFH̵ʱ(ʼֶ)*/ + + paraVal = GetSystemParaValue(FirstOrderTime_ID); + FirstOrderTimeCount = TimeToCycleCount((UINT32)paraVal*1000U, appCycleTime); /*һЧʱ()(ʼֶ)*/ + + paraVal = GetSystemParaValue(JXTCPulseContinueTime_ID); + JXTCPulseContinueTimeCount = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*϶̽ʱ(ʼֶ)*/ + + paraVal = GetSystemParaValue(LABAR_UNLOCK_OVERLAP_time); + labarUnlockOverlapTimeCount = TimeToCycleCount((UINT32)paraVal*1000U, appCycleTime); /*˹ʱʱ*/ + + paraVal = GetSystemParaValue(CONFIG_SIG_RONGREN_MAX_TIME); + sigCollectRongrenCount = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*֮ɼȫʱ*/ + + paraVal = GetSystemParaValue(AXLE_SEG_UT_REDUNDANCE_ID); + AxleSectionUtRedundanceCount = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*϶̽ʱ(ʼֶ)*/ + + paraVal = GetSystemParaValue(CONFIG_PSD_CLOSE_MAX_TIME); + psdDrivCloseMaxTimeCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*Źųʱ*/ + + paraVal = GetSystemParaValue(CONFIG_PSD_OPEN_MAX_TIME); + psdDrivOpenMaxTimeCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ſųʱ*/ + + paraVal = GetSystemParaValue(CONFIG_SPKSDELAY_TIME); + SpksIndicDelayCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*SPKSťָʾƵʱʱ()*/ + + ciAndAxisPrtclCheckVer = (UINT8)SystemParameterStruNew.VerSionBtwAxisAndCi; /*Э汾*/ + + /************************************Ϊӹѯлȡ********************************/ + CiAndZcTransmitBadEnsureCount = TimeToCycleCount(SystemParameterStruNew.CiAndZcTransmitBadEnsureTime, appCycleTime); /*ZCͨжȷ(ʼֶ)*/ + + CiAndCiTransmitBadEnsureCount = TimeToCycleCount(SystemParameterStruNew.CiAndCiTransmitBadEnsureTime, appCycleTime); /*ͨжȷ(ʼֶ)*/ + + CiAndVobcTransmitBadEnsureCount = TimeToCycleCount(SystemParameterStruNew.CiAndVobcTransmitBadEnsureTime, appCycleTime); /*Vobcͨжȷ(ʼֶ)*/ + + VobcAndCiBackUpCommBadCount = TimeToCycleCount(SystemParameterStruNew.dwVobcCiBackUpCommErrorTime, appCycleTime); /*IvocVOBCͨͨжȷ(ʼֶ)*/ + + CiAndPsdTransmitBadEnsureCount = TimeToCycleCount(SystemParameterStruNew.CiAndPsdTransmitBadEnsureTime, appCycleTime); /*Psdͨжȷ(ʼֶ)*/ + + TiocAndTmcTransmitBadEnsureCnt = TimeToCycleCount(SystemParameterStruNew.TmcOcCommunicationErrorTime, appCycleTime); /*Psdͨжȷ(ʼֶ)*/ + + versionOfZCToCI = (UINT8)SystemParameterStruNew.dwVersionOfZCToCI; /*ZC-CIӿЭ汾ţadd by sds 2019-1-21*/ + + versionOfVOBCToCI = (UINT8)SystemParameterStruNew.dwVersionOfVOBCToCI; /*VOBC-CIӿЭ汾ţadd by sds 2019-1-21*/ + + CiAndPscTransBadEnsureCount = TimeToCycleCount(SystemParameterStruNew.CiAndPscTransmitBadEnsureTime, appCycleTime); /*PSCͨжȷ(ʼֶ)*/ + + wTsrMaxCmdSum = SystemParameterStruNew.MaxTsrNum; /* ʱ */ + wTsrMaxSecSum = SystemParameterStruNew.MaxSectionOfTsr; /* ʱ */ + + paraVal = GetSystemParaValue(CT_FlYING_REDUN_TIME_ID); + gCTFlyingRedunCount = (UINT8)TimeToCycleCount((UINT32)paraVal, appCycleTime); /*ɳ崻ʼ*/ + + paraVal = GetSystemParaValue(CONFIG_MJJSOPENDELAY_TIME); + mjjsOpenDelayCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*SPKSťָʾƵʱʱ()*/ + + paraVal = GetSystemParaValue(ZFS_BUTTON_RELAY_COLL_TIME); + dwSelfButCollCount = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*ԸʽťӦ̵ɼʱ䣨ms(ʼֶ)*/ + + paraVal = GetSystemParaValue(ZFS_BUTTON_FAULT_ENSURE_TIME); + dwSelfButErrCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*Ըʽ۳/ťжʱ䣨s*/ + + paraVal = GetSystemParaValue(TRAIN_RECYCLE_RES_TIME); + dwTrainRecycleCount = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*Դռʱʱ䣨ms*/ + + paraVal = GetSystemParaValue(ZFS_CANCEL_BTN_ERR_ENSURE_TIME); + dwSelfCancelButErrCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*Ըʽȡ۳/ťжʱ䣨s*/ + + paraVal = GetSystemParaValue(ROUTE_NEAREST_TRAIN_RENJIE_TIME); + dwRouteNearestTrainRenJieCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*·ӽгҪ˽·ʱʱȴʱ䣨s*/ + + paraVal = GetSystemParaValue(SGBJ_ROUTE_DELAY_OPEN_TIME); + dwSGBJRouteDelayOpenCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*ⱨ·ʱŵȴʱ䣨s*/ + + paraVal = GetSystemParaValue(FLOODGATE_ACCESS_OCC_DELAY_OPEN_TIME); + dwFloodGateDelayCloseCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*Žӽռӳٹʱ(S)*/ + + paraVal = GetSystemParaValue(SWITCH_BYPASS_DELAY_TIME); + dwSwitchBypassWaitCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*·ߵδʱȡ·ȴʱ(S)*/ + + paraVal = GetSystemParaValue(ZFS_CANCEL_BTN_ERR_TRIGGER_TIME); + dwSelfCancelButErrTriggerCount = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*Ըʽȡ۳/ť󴥷жʱ䣨s*/ + + wArbNearSecProtectDistance = GetSystemParaValue(ARB_CHECK_ALXE_SEC_LEN); + + paraVal = GetSystemParaValue(ARB_CHECK_ALXE_TIME); + dwArbNearSecNoUtCount = TimeToCycleCount((UINT32)paraVal, appCycleTime); /*ARBμϴUTռþʱ (õλms)*/ + + StationTrackDistance = SystemParameterStruNew.StationTrackDistance; /*-վ̨׷ʱг루cm*/ + LineMinTrainLength = SystemParameterStruNew.dwLineMinTrainLength; /*-·С*/ + + paraVal = GetSystemParaValue(NONRETURN_BTN_ERR_ENSURE_TIME); + dwNonReturnBtnErrEnsureTime = TimeToCycleCount((UINT32)paraVal * 1000U, appCycleTime); /*۷ťжʱ䣨/S*/ +} + +/* +* ʱת +* ˵ const UINT32 deviceTime, 豸ʱ +* const UINT32 appTime, Ӧʱ +* ֵ +*/ +UINT32 TimeToCycleCount(const UINT32 deviceTime, const UINT32 appTime) +{ + UINT32 rev = 0u;/**/ + + /*appTimeΪ*/ + if (appTime == 0u) + { + /*Ϊ0*/ + + } + else + { + rev = deviceTime / appTime; + + if (deviceTime % appTime != 0u) + {/**/ + + rev++; + } + } + + return rev; +} + +/* +* ȡӦ(λ:ms) +* ˵ void +* ֵ UINT8 +*/ +UINT32 GetSystemParaAppCycleTime(void) +{ + UINT32 appCycle = 0u; + appCycle = (UINT32)GetSystemParaValue(AppCycleTime_ID); + return appCycle; +} + +/* +* ȡID +* ˵ void +* ֵ UINT8 +*/ +UINT8 GetSystemParaLocalCiId(void) +{ + return LocalCiId; +} + +/* +* ȡòֵ +* ˵ UINT16 paraID,ID +* ֵ +* UINT16ֵ +*/ +UINT16 GetSystemParaValue(UINT16 paraID) +{ + UINT16 retVal = 0u; + + if (CI_SYSTEM_PARA_SUM_MAX > paraID) + { + retVal = SystemParameterStruNew.ParaStru[paraID].SysParaValue; + } + else + { + ; + } + + return retVal; +} + +/* +* ȡ +* ˵ void +* ֵ UINT8 +*/ +UINT8 GetSystemParaCiSum(void) +{ + UINT8 CiSum = (UINT8)GetSystemParaValue(CiSum_ID); + return CiSum; +} + + +/* +* ȡϵͳϵ +* ˵ void +* ֵ ϵ +*/ +UINT32 GetSystemParaStartUnlockCyc(void) +{ + return StartUnlockCount; +} + + +/* +* ȡϵͳ·ѡų +* ˵ void +* ֵ ·ѡų +*/ +UINT32 GetSystemParaRouteXuanPaiCyc(void) +{ + return RouteXuanPaiCount; +} + +/* +* ȡϵͳ·ճ +* ˵ void +* ֵ ·ѡų +*/ +UINT32 GetSystemParaRouteLockCyc(void) +{ + return RouteLockCount; +} + +/* +* ȡϵͳճ +* ˵ void +* ֵ ·ѡų +*/ +UINT32 GetSystemParaOverlapLockCyc(void) +{ + return OverlapLockCount; +} + +/* +* ȡϵͳ·źų +* ˵ void +* ֵ ·ѡų +*/ +UINT32 GetSystemParaRouteOpenSigCyc(void) +{ + return RouteOpenSignalCount; +} + +/* +* ȡϵͳʽ·ʱ +* ˵ void +* ֵ ʽ·ʱ +*/ +UINT32 GetSystemParaBlocRouteDelayCyc(void) +{ + return BlocRouteDelayCount; +} + + +/* +* ȡϵͳCBTC·ʱ +* ˵ void +* ֵ CBTC·ʱ +*/ +UINT32 GetSystemParaCbtcRouteDelayCyc(void) +{ + return CbtcRouteDelayCount; +} + +/* +* ȡԴȡʱ˽ʱʱ +* ˵ void +* ֵ Դȡʱ +*/ +UINT32 GetRouteResCancelApplyCyc(void) +{ + UINT32 ResCancelApplyCycleCount = 0U; + + ResCancelApplyCycleCount = GetSystemParaCbtcRouteDelayCyc(); + + return ResCancelApplyCycleCount; +} + +/* +* ȡ·ӽгҪ˽·ʱʱȴ +* ˵ void +* ֵ CBTC·ʱ +*/ +UINT32 GetRouteTrainRanJieDelayCyc(void) +{ + return dwRouteNearestTrainRenJieCount; +} + +/* +* ȡϵͳ·ڷιźſų +* ˵ void +* ֵ ·ڷιźſų +*/ +UINT32 GetSystemParaLeadFaultOpenCyc(void) +{ + return LeadRouteFaultOpenCount; +} + + +/* +* ȡϵͳʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaSecDelayUnlockCyc(void) +{ + return SecDelayUnlockCount; +} + + +/* +* ȡϵͳźſų +* ˵ void +* ֵ źſų +*/ +UINT32 GetSystemParaSignalOpenCyc(void) +{ + return SignalOpenCount; +} + + +/* +* ȡϵͳźŹرճ +* ˵ void +* ֵ źŹرճ +*/ +UINT32 GetSystemParaSignalCloseCyc(void) +{ + return SignalCloseCount; +} + + +/* +* ȡϵͳ +* ˵ void +* ֵ +*/ +UINT32 GetSystemParaSwitchMoveCyc(void) +{ + return SwitchMoveCount; +} + + +/* +* ȡϵͳ +* ˵ void +* ֵ +*/ +UINT32 GetSystemParaSwitchDriveCyc(void) +{ + return SwitchDriveCount; +} + + +/* +* ȡϵͳνͣ +* ˵ void +* ֵ νͣ +*/ +UINT32 GetSystemParaProtSecUnlockCyc(void) +{ + return ProtectSecUnlockCount; +} + + +/* +* ȡCTռý·һµĽͣ +* ˵ void +* ֵ ͨųռ÷νͣ +*/ +UINT32 GetSystemParaCtProtSecUnlockCyc(void) +{ + return CtProtectSecUnlockCount; +} + +/* +* ȡϵͳռñмʱ +* ˵ void +* ֵ ռñмʱ +*/ +UINT32 GetSystemParaOccuToIdleCyc(void) +{ + return OccupyToIdleCount; +} + +/* +* ȡϵͳ׹ʽʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaFaultUnlockCyc(void) +{ + return FaultUnlockCount; +} + +/* +* ȡϵͳḴλʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaSectionResetCount(void) +{ + return SectionResetCount; +} + +/* +* Դճʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaTrainReCycleCount(void) +{ + return dwTrainRecycleCount; +} +/* +* ʱʱ +* ˵ UINT32 StartCount ʼʱ +* UINT32 MaxCount ʱ +* ֵ CI_TIME_NO δʱ +* CI_TIME_IN δʱ +* CI_TIME_OUT ʱ +*/ +UINT8 SystemOverTimeCheck(UINT32 StartCount, UINT32 MaxCount) +{ + UINT32 nowTime = 0u; + UINT32 subTime = 0u; + UINT8 retVal = CI_TIME_OUT; + + nowTime = Get2oo2CurCycleNum(); + + if (StartCount == 0u) + { + /*δʱ*/ + retVal = CI_TIME_NO; + } + else + { + subTime = nowTime - StartCount; + if (subTime <= MaxCount) + { + /*δʱ*/ + retVal = CI_TIME_IN; + } + else + { + /*ʱ*/ + retVal = CI_TIME_OUT; + } + } + return retVal; +} + +/* +* ʱǷﵽ򳬹ֵ +* ˵ UINT32 StartCount ʼʱ +* UINT32 MaxCount ʱ +* ֵ CI_TIME_NO δʱ +* CI_TIME_IN δʱ +* CI_TIME_OUT ʱ +*/ +UINT8 SystemOverOrEqualTimeCheck(UINT32 StartCount, UINT32 MaxCount) +{ + UINT32 nowTime = 0U; + UINT32 subTime = 0U; + UINT8 retVal = CI_TIME_OUT; + + nowTime = Get2oo2CurCycleNum(); + + if (StartCount == 0U) + { + /*ʼʱΪ0δʱ*/ + retVal = CI_TIME_NO; + } + else + { + subTime = nowTime - StartCount; + if (subTime < MaxCount) + { + /*ʼʱСֵδʱ*/ + retVal = CI_TIME_IN; + } + else + { + /*ʼʱڵֵʱ*/ + retVal = CI_TIME_OUT; + } + } + + return retVal; +} + + +/* +* ȡϵͳǽ·ѡ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaNonRouteXuanPaiCnt(void) +{ + return NonRouteXuanPaiCount; +} + + +/* +* ȡϵͳǽ·ʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaNonRDelayUnlockCnt(void) +{ + return NonRouteDelayUnlockCount; +} + +/* +* ȡ·ѡŵ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaSwDrvCuoFengCnt(void) +{ + return SwitchDriveCuoFengCount; +} + + +/* +* ȡϽ·ѡ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaZuheRXuanPaiCnt(void) +{ + return ZuheRouteXuanPaiCount; +} + +/* +* ȡZCͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndZcTransBadEnsureCnt(void) +{ + return CiAndZcTransmitBadEnsureCount; +} + +/* +* ȡTIOCTMCͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetTiocAndTmcTransBadEnsureCnt(void) +{ + return TiocAndTmcTransmitBadEnsureCnt; +} + +/* +* ȡϵͳͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndAxleTransBadEnsureCnt(void) +{ + return CiAndAxleTransBadEnsureCnt; +} + +/* +* ȡOCͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndOcTransmitBadEnsureCnt(void) +{ + return CiAndOcTransmitBadEnsureCount; /*ݶ10ڣ3룬*/ +} + +/* +* ȡͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndCiTransBadEnsureCnt(void) +{ + return CiAndCiTransmitBadEnsureCount; +} + +/* +* ȡVobcͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndVobcTransBadEnsureCnt(void) +{ + return CiAndVobcTransmitBadEnsureCount; +} + +/* +* ȡPSDͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndPsdTransBadEnsureCnt(void) +{ + return CiAndPsdTransmitBadEnsureCount; +} + +/* +* ȡ +* ˵ void +* ֵ +*/ +UINT8 GetLocalCiType(void) +{ + return SystemParameterStruNew.CiType; +} + + +/* +* ȡȴZCʱ +* ˵ void +* ֵ ȴZCʱ +*/ +UINT32 GetWaitZCResponseCount(void) +{ + return WaitZCResponseCount; +} + +/* +* ȡϵͳԾʱ +* ˵ void +* ֵ Ծʱ +*/ +UINT32 GetSysParaSecJLokDelayUnlockCyc(void) +{ + return SecJumpLockDelayUnlockCount; +} + + +/* +* ȡֵָܿ +* ˵ INT32 FunctionConfigIndex ָܿ + CLOSE_OPENED_SIG_LOCK_SWITCH رѿź + CLOSE_OPENED_SIG_LOCK_SIGNAL źŻرѿź + CHECK_SWITCH_LOCKING_BEFORE_LOCKING_SWITCH_CONF ʱ + CHECK_SWITCH_DANLOCK_FLOCKING_SWITCH_CONF ʱ + +* ֵ ֵָܿ0xAA0x550xFF +*/ +UINT8 GetCiFunctionSwitchConfig(UINT8 FunctionConfigIndex) +{ + UINT8 retVal = FUNC_SWITCH_UNDEF; + + if(CI_FUNCTION_SWITCH_SUM_MAX > FunctionConfigIndex) + { + retVal = CiFuncSwitConfStruNew[FunctionConfigIndex].wCiFuncSwitchVal; + } + else + { + retVal = FUNC_SWITCH_UNDEF; + + DebugPrintAppError(ERROR_INDEX_EXCEED,CI_DEVICE_TYPE_FS_TABLE,((UINT32)CI_SYSTEM_PARAMETER_DATA_TYPE<<24u)+((UINT32)CI_SYSTEM_CI_FUNC_SWITCH_ID<<16u)+ (UINT32)CI_FUNCTION_SWITCH_SUM_MAX,PRINT_CYCLE); + } + + return retVal; +} + +/* +* ȡͨжȷʱ䵥λ +* ˵ + +* ֵ ͨжȷʱ䵥λ +*/ +UINT32 GetCiAndCiTransmitBadEnsureTime(void) +{ + return SystemParameterStruNew.CiAndCiTransmitBadEnsureTime; +} +/* +* ȡVobcͨжȷʱ䵥λ +* ˵ + +* ֵ Vobcͨжȷʱ䵥λ +*/ +UINT32 GetCiAndVobcTransBadEnsureTime(void) +{ + return SystemParameterStruNew.CiAndVobcTransmitBadEnsureTime; +} + +/* +* ȡZCͨжȷʱ䵥λ +* ˵ + +* ֵ ZCͨжȷʱ䵥λ +*/ +UINT32 GetCiAndZcTransmitBadEnsureTime(void) +{ + return SystemParameterStruNew.CiAndZcTransmitBadEnsureTime; +} + +/* +* ȡTIOCTMCͨжȷʱ䵥λ +* ˵ + +* ֵ TIOCTMCͨжȷʱ䵥λ +*/ +UINT32 GetTiocAndTmcTransBadEnsureTime(void) +{ + return SystemParameterStruNew.TmcOcCommunicationErrorTime; +} + + +/* +* ȡϵͳͨжȷʱ䵥λ +* ˵ + +* ֵ ϵͳͨжȷʱ䵥λ +*/ +UINT32 GetCiAndAxleTransBadEnsureTime(void) +{ + return CiAndAxleTransBadEnsureTime; +} + +/* +* ȡOCͨжȷʱ䵥λ +* ˵ + +* ֵ OCͨжȷʱ䵥λ +*/ +UINT32 GetCiAndOcTransmitBadEnsureTime(void) +{ + return CiAndOcTransmitBadEnsureTime; +} + +/* +* ȡϵͳŶʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSysParaGaragedoorOperateCnt(void) +{ + return GaragedoorOperateCount; +} +/* zt ɾش 2022-02-15 */ + +/* +* ȡ϶̽ⳬ +* ˵ void +* ֵ ϶̽ⳬ +*/ +UINT32 GetGapDetectCount(void) +{ + return gapDetectTimeCount; +} + +/* +* ȡվ̨ťʧЧ +* ˵ void +* ֵ վ̨ťʧЧ +*/ +UINT32 GetPsdButtonPressCount(void) +{ + return psdButtonPressTimeCount; +} + +/* +* ȡܸλʧЧ +* ˵ void +* ֵ ܸλʧЧ +*/ +UINT32 GetZFWJRelayDriveTimeCount(void) +{ + return ZFWJRelayDriveTimeCount; +} + +/* +* λDFH̵ +* ˵ void +* ֵ DFH̵ +*/ +UINT32 GetDHFRelayValidTimeCount(void) +{ + return DHFRelayValidTimeCount; +} + + +/* +* ȡZC-CIӿЭ汾 +* ˵ void +* ֵ ZC-CIӿЭ汾 +*/ +UINT8 GetVersionOfZCToCI(void) +{ + return versionOfZCToCI; +} + +/* +* ȡTMC-TIOCӿЭ汾 +* ˵ void +* ֵ TMC-TIOCӿЭ汾 +*/ +UINT8 GetVersionOfTMCToTIOC(void) +{ + return versionOfZCToCI; +} + +/* +* ȡVOBC-CIӿЭ汾 +* ˵ void +* ֵ VOBC-CIӿЭ汾 +*/ +UINT8 GetVersionOfVOBCToCI(void) +{ + return versionOfVOBCToCI; +} + +/* +* ȡPscͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndPscTransBadEnsureCnt(void) +{ + return CiAndPscTransBadEnsureCount; +} + + + +/* +* ȡͬȴźſ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSysParaDCTYWaitSigOpenCnt(void) +{ + return DCTYWaitSignalOpenCount; +} + +/* +* ȡģʽ +* ˵void +* ֵģʽ +*/ +UINT8 GetLocalCiPattern(void) +{ + return LocalCiPattern; +} + + + + +/* +* ȡTIOC̬Կ +* ˵void +* ֵ߶̬Կ +*/ +UINT8 GetZXDynamicTestSwitch(void) +{ + return SystemParameterStruNew.chZXDynamicTestSwitch; +} + +/* +* ȡTIOC̬Կ +* ˵void +* ֵTIOC̬Կ +*/ +UINT8 GetDynamicTestSwitch(void) +{ + return SystemParameterStruNew.chDynamicTestSwitch; +} + +/* +* ñģʽ +* ˵CIģʽ +* ֵǷóɹ +*/ +UINT8 SetLocalCiPattern(UINT8 localCiPattern) +{ + UINT8 rtn = 0u; /*ֵ*/ + + if ((CI_PATTERN_TRADITIONAL == localCiPattern) || (CI_PATTERN_FULL_ELECTRONIC == localCiPattern)) + { + LocalCiPattern = localCiPattern; + rtn = 1u; + } + + return rtn; +} + +/* +* ñʽ/ֲʽIO +* ˵CI IOɷʽ +* ֵǷóɹ +*/ +UINT8 SetLocalCiDistributedIO(UINT8 distributedIO) +{ + UINT8 rtn = 0u; /*ֵ*/ + + if ((CI_CENTER_IO == distributedIO) || (CI_DISTRIBUTED_IO == distributedIO)) + { + LocalCiIsDistributedIO = distributedIO; + rtn = 1u; + } + + return rtn; +} + +/* +* ȡIO豸ɷʽ +* ˵CI IOɷʽ +* ֵIOɷʽ +*/ +UINT8 GetLocalCiDistributedIO(void) +{ + return LocalCiIsDistributedIO; +} + +/* +* ñUTʱͣʱ +* ˵ʱͣʱ +* ֵvoid +*/ +void SetLocalCiUTProtSecUnlockTime(UINT16 localUTProtectSecUnlockTime) +{ + LocalUTProtectSecUnlockTime = localUTProtectSecUnlockTime; +} + +/* +* ñCTʱͣʱ +* ˵ʱͣʱ +* ֵvoid +*/ +void SetLocalCiCTProtSecUnlockTime(UINT16 localCTProtectSecUnlockTime) +{ + LocalCTProtectSecUnlockTime = localCTProtectSecUnlockTime; +} + +/********/ +/* +* ñUTӽʱʱ +* ˵ʱͣʱ +* ֵvoid +*/ +void SetLocalCiUTNearUnLockTime(UINT16 localUTNearUnLockTime) +{ + LocalUTNearUnLockTime = localUTNearUnLockTime; +} + +/* +* ñCTӽʱʱ +* ˵ʱͣʱ +* ֵvoid +*/ +void SetLocalCiCTNearUnLockTime(UINT16 localCTNearUnLockTime) +{ + LocalCTNearUnLockTime = localCTNearUnLockTime; +} +/* +* һЧ +* ˵ void +* ֵ һЧ +*/ +UINT32 GetFirstOrderTimeCount(void) +{ + return FirstOrderTimeCount; +} + + +/* +* ȡ϶̽ +* ˵ void +* ֵ ϶̽ +*/ +UINT32 GetJXTCPulseContinueTimeCount(void) +{ + return JXTCPulseContinueTimeCount; +} + +/* +* ȡηͨųռѹ +* ˵ void +* ֵ UINT32 +* qw.liu 2022-02-22 +*/ +UINT32 GetSysParaAxleUtRedunCount(void) +{ + return AxleSectionUtRedundanceCount; +} + +/* +* ȡźŻγ᳤ +* ˵ void +* ֵ UINT32 +* qw.liu 2022-02-22 +*/ +UINT16 GetSigLightUpBigAxleSecLen(void) +{ + UINT16 wSigLightUpBigAxleSecLen = 0U; + + wSigLightUpBigAxleSecLen = GetSystemParaValue(SIGNAL_LIGHTUP_BIG_ALXE_SEC_LEN_ID); + + return wSigLightUpBigAxleSecLen; +} + +/* +* ȡźŻӳ᳤ +* ˵ void +* ֵ UINT32 +* qw.liu 2022-02-22 +*/ +UINT16 GetSigLightUpExAxleSecLen(void) +{ + UINT16 wSigLightUpExAxleSecLen = 0U; + + wSigLightUpExAxleSecLen = GetSystemParaValue(SIGNAL_LIGHTUP_EX_ALXE_SEC_LEN_ID); + + return wSigLightUpExAxleSecLen; +} + +/* +* ȡѹźŻ +* ˵ void +* ֵ UINT32 +* qw.liu 2022-03-03 +*/ +UINT16 GetSigCrossMaxLen(void) +{ + UINT16 wSigCrossMaxLen = 0U; + + wSigCrossMaxLen = GetSystemParaValue(SIGNAL_CROSS_MAX_LEN_ID); + + return wSigCrossMaxLen; +} + +/* +* ȡз +* ˵ void +* ֵ UINT32 +* qw.liu 2022-03-03 +*/ +UINT16 GetBackProtectMaxLen(void) +{ + + return StationTrackDistance; +} + +/* +* ȡ·С +* ˵ void +* ֵ UINT32 +* 2022-03-12 +*/ +UINT32 GetShortestTrainLen(void) +{ + return LineMinTrainLength; +} + + +/* +* ȡ ȫɸ +* ˵UINT8 +* ֵȫɸ +*/ +UINT8 GetWLSFunSwitch(void) +{ + return SystemParameterStruNew.chWLSFunSwitch; +} + +/* +* ȡTIOCݰ汾Ŵŵַ +* ˵ void +* ֵ NULL ʧ +* ɹ +* 2022-03-12 +*/ +UINT16* GetTiocFsVersion(void) +{ + return g_TiocFsVersion; +} + +/* +* TIOCݰ汾Ŵŵַ +* ˵ UINT8* pSrcFsVersion ӵͼ汾Ŵŵַ +* 2022-03-12 +*/ + +void SetTiocFsVersion(UINT8* pSrcFsVersion) +{ + UINT8 index = 0u; + + if (NULL != pSrcFsVersion) + { + g_TiocFsVersion[index] = (UINT16)pSrcFsVersion[index]; + index++; + g_TiocFsVersion[index] = (UINT16)pSrcFsVersion[index]; + index++; + g_TiocFsVersion[index] = (UINT16)(pSrcFsVersion[index] << 4u) + (UINT16)(pSrcFsVersion[index + 1u] >> 4u); + index++; + g_TiocFsVersion[index] = (UINT16)((UINT16)pSrcFsVersion[index] & 0x0Fu); + } + else + { + } +} + +/* +* УTIOCݽṹ汾 +* ˵ UINT8* pSrcFsVersion ݽṹ汾Ŵŵַ +* ֵCI_SUCCESS CI_ERROR +* 20240605 LC +*/ +UINT8 CheckTiocPublicFsVersion(UINT8* pSrcFsVersion) +{ + UINT8 retVal = CI_ERROR; + + if (NULL != pSrcFsVersion) + { + /*ѯݽṹ汾Ƿڿɼݵİ汾*/ + if ((VER_1_PUBLIC_FS_1 == pSrcFsVersion[0]) && (VER_1_PUBLIC_FS_2 == pSrcFsVersion[1]) && (VER_1_PUBLIC_FS_3 == pSrcFsVersion[2]) && (VER_1_PUBLIC_FS_4 == pSrcFsVersion[3])) + { + retVal = CI_SUCCESS; + } + else if ((VER_2_PUBLIC_FS_1 == pSrcFsVersion[0]) && (VER_2_PUBLIC_FS_2 == pSrcFsVersion[1]) && (VER_2_PUBLIC_FS_3 == pSrcFsVersion[2]) && (VER_2_PUBLIC_FS_4 == pSrcFsVersion[3])) + { + retVal = CI_SUCCESS; + } + else if ((VER_3_PUBLIC_FS_1 == pSrcFsVersion[0]) && (VER_3_PUBLIC_FS_2 == pSrcFsVersion[1]) && (VER_3_PUBLIC_FS_3 == pSrcFsVersion[2]) && (VER_3_PUBLIC_FS_4 == pSrcFsVersion[3])) + { + retVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + } + else + { + /*ʧ*/ + } + return retVal; +} + + +/* +* УTIOC˽ݽṹ汾 +* ˵ UINT8* pSrcFsVersion ˽ݽṹ汾Ŵŵַ +* ֵCI_SUCCESS CI_ERROR +* 20240605 LC +*/ +UINT8 CheckTiocPrivateFsVersion(UINT8* pSrcFsVersion) +{ + UINT8 retVal = CI_ERROR; + + if (NULL != pSrcFsVersion) + { + /*ѯ˽ݽṹ汾Ƿڿɼݵİ汾*/ + if ((VER_1_PRIVATE_FS_1 == pSrcFsVersion[0]) && (VER_1_PRIVATE_FS_2 == pSrcFsVersion[1])) + { + retVal = CI_SUCCESS; + } + else if ((VER_2_PRIVATE_FS_1 == pSrcFsVersion[0]) && (VER_2_PRIVATE_FS_2 == pSrcFsVersion[1])) + { + retVal = CI_SUCCESS; + } + else if ((VER_3_PRIVATE_FS_1 == pSrcFsVersion[0]) && (VER_3_PRIVATE_FS_2 == pSrcFsVersion[1])) + { + retVal = CI_SUCCESS; + } + else + { + /*ʧ*/ + } + } + else + { + /*ʧ*/ + } + return retVal; +} + +/* +* УOCݽṹ汾 +* ˵ UINT8* pSrcFsVersion ˽ݽṹ汾Ŵŵַ +* ֵCI_SUCCESS CI_ERROR +* 20250210 fan +*/ +UINT8 CheckTiocOcFsVersion(UINT8* pSrcFsVersion) +{ + UINT8 retVal = CI_ERROR; + + if (NULL != pSrcFsVersion) + { + /*ѯOCݽṹ汾Ƿڿɼݵİ汾*/ + if ((VER_1_OCDATA_FS_1 == pSrcFsVersion[0]) && (VER_1_OCDATA_FS_2 == pSrcFsVersion[1])) + { + retVal = SetLocalOcPattern(OC_DATA_TYPE_NEW); + } + else if ((VER_2_OCDATA_FS_1 == pSrcFsVersion[0]) && (VER_2_OCDATA_FS_2 == pSrcFsVersion[1])) + { + retVal = SetLocalOcPattern(OC_DATA_TYPE_OLD); + } + else + { + /*ʧ*/ + } + } + else + { + /*ʧ*/ + } + return retVal; +} + + +/********************************************* +*ܣȡ̬ +*˵UINT32* pConfigDataAdderBuf ̬ݴŵַ,UINT16 pConfigDataLenBuf ̬ݳȴŵַ,UINT16 wBufMaxLen +*ֵ̬ +*********************************************/ +UINT16 GetTiocSystemParameterData(UINT32* pConfigDataAdderBuf, UINT16* pConfigDataLenBuf, UINT16 wBufMaxLen) +{ + UINT16 wRetSum = 0u; + UINT16 wTmpConfigDataSum = 0u; + UINT16 wTmpLen = 0u; + + if ((NULL != pConfigDataAdderBuf) && (NULL != pConfigDataLenBuf) && (0u != wBufMaxLen) && (UINT16_MAX != wBufMaxLen)) + { + /*ģʽ*/ + wTmpLen = 1u + wTmpConfigDataSum; + + pConfigDataAdderBuf[wTmpConfigDataSum] = &LocalCiPattern; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT8); + wTmpConfigDataSum++; + + + /*ǷǷֲʽIO*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &LocalCiIsDistributedIO; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT8); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*UTνͣʱ䣨s*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &LocalUTProtectSecUnlockTime; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*CTνͣʱ䣨s*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &LocalCTProtectSecUnlockTime; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*UTӽʱʱ䣨s*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &LocalUTNearUnLockTime; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*CTӽʱʱ䣨s*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &LocalCTNearUnLockTime; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + + /*OCݽṹ*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &gLocalOcType; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT8); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*ϵ*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &StartUnlockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*·ѡų*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &RouteXuanPaiCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*·ճ*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &RouteLockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*ճ*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &OverlapLockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*·ųʱ*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &RouteOpenSignalCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*ʽ·ʱ*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &BlocRouteDelayCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*CBTC·ʱ*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CbtcRouteDelayCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/*޴ */ + } + /*·ڷιźſų*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &LeadRouteFaultOpenCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /*ʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SecDelayUnlockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /*źſų*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SignalOpenCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /*źŹرճ*/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SignalCloseCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /**/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SwitchMoveCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /**/ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SwitchDriveCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /*νͣ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &ProtectSecUnlockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ռñмʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &OccupyToIdleCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ׹ʽʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &FaultUnlockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ḵλʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SectionResetCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ǽ·ѡ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &NonRouteXuanPaiCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ǽ·ʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &NonRouteDelayUnlockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ·ѡŵ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SwitchDriveCuoFengCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ͻ·ѡ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &ZuheRouteXuanPaiCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ZCͨжȷ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndZcTransmitBadEnsureCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ͨжȷ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndCiTransmitBadEnsureCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Vobcͨжȷ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndVobcTransmitBadEnsureCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + + /* IVOCͨͨжȷ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &VobcAndCiBackUpCommBadCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + + /* PSDͨжȷ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndPsdTransmitBadEnsureCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ȴZCʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &WaitZCResponseCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ծʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SecJumpLockDelayUnlockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ŷʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &GaragedoorOperateCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ͨųռ÷νͣ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CtProtectSecUnlockCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* 쵥 */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SingleSwitchMoveCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &ThreeSwitchMoveCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* 忪 */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &FiveSwitchMoveCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ϶̽ʱ䳬 */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &gapDetectTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + + /* վ̨ťʧЧʱ䳬 */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &psdButtonPressTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ͬȴźſʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &DCTYWaitSignalOpenCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Pscͨжȷʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndPscTransBadEnsureCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ܸλʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &ZFWJRelayDriveTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* λDFH̵ʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &DHFRelayValidTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* һЧʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &FirstOrderTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ϶̽ʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &JXTCPulseContinueTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ˹ʱʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &labarUnlockOverlapTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ֮ɼȫʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &sigCollectRongrenCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* UTռ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &AxleSectionUtRedundanceCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Źųʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &psdDrivCloseMaxTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ſųʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &psdDrivOpenMaxTimeCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* SPKSťָʾƵʱʱ() */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &SpksIndicDelayCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* AXIS-CIӿЭ汾 */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &ciAndAxisPrtclCheckVer; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT8); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ZC-CIӿЭ汾 */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &versionOfZCToCI; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT8); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* VOBC-CIӿЭ汾 */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &versionOfVOBCToCI; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT8); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ϵͳͨжȷ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndAxleTransBadEnsureCnt; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ϵͳͨжȷʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndAxleTransBadEnsureTime; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ocͨжȷ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndOcTransmitBadEnsureCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ocͨжȷʱ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiAndOcTransmitBadEnsureTime; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ɳ崻ʼ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &gCTFlyingRedunCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* SPKSťָʾƵʱʱ() */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &mjjsOpenDelayCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ԸʽťӦ̵ɼʱ䣨ms(ʼֶ) */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwSelfButCollCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ըʽ۳/ťжʱ䣨s */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwSelfButErrCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Դռʱʱ䣨ms */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwTrainRecycleCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ըʽȡ۳/ťжʱ䣨s */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwSelfCancelButErrCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ·ӽгҪ˽·ʱʱȴʱ䣨s */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwRouteNearestTrainRenJieCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ⱨ·ʱʱ䣨s */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwSGBJRouteDelayOpenCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + + /* Žӽռӳٹʱ(S) */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwFloodGateDelayCloseCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + + /* ·ߵδʱȡ·ȴʱ(S) */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwSwitchBypassWaitCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* Ըʽȡ۳/ť󴥷жʱ䣨s */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwSelfCancelButErrTriggerCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ARB루/M */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &wArbNearSecProtectDistance; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ARBʱڣ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwArbNearSecNoUtCount; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ۷ťжʱ䣨/S */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &dwNonReturnBtnErrEnsureTime; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT32); + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* ci-ocϵ */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &CiOcRelationArr; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(CiOcRelateion)*CI_SUM_MAX; + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + /* TIOCݰ汾 */ + wTmpLen = 1u + wTmpConfigDataSum; + if (wBufMaxLen >= wTmpLen) + { + pConfigDataAdderBuf[wTmpConfigDataSum] = &g_TiocFsVersion; + pConfigDataLenBuf[wTmpConfigDataSum] = (UINT16)sizeof(UINT16)*TIOCFS_VERSION_LENGTH; + wTmpConfigDataSum++; + } + else + { + ;/* ޴ */ + } + + } + else + { + ;/*޴*/ + } + wRetSum = wTmpConfigDataSum; + return wRetSum; +} + +/* +* ȡɳ崻 +* ˵ void +* ֵ ɳ崻 +*/ +UINT8 GetCTFlyingRedunCount(void) +{ + return gCTFlyingRedunCount; +} + +/* +* ȡʱ +* ˵ void +* ֵ ʱ +*/ +UINT16 GetTsrMaxCmdSum(void) +{ + return wTsrMaxCmdSum; +} + +/* +* ȡʱٵ +* ˵ void +* ֵ ʱٵ +*/ +UINT16 GetTsrMaxSecSum(void) +{ + return wTsrMaxSecSum; +} + +/* +* ȡϵͳ߼зĹϵ +* ˵ void +* ֵ ϵͳ߼зĹϵ +*/ +UINT8 GetLinkLogicDirUpAndDown(void) +{ + return SystemParameterStruNew.LinkLogicDirUpAndDown; +} + +/* +* ȡɢǰ +* ˵void +* ֵɢǰ +*/ +UINT32 GetEaFrontDis(void) +{ + return SystemParameterStruNew.dwEaFrontDis; +} + +/* +* ȡɢ +* ˵void +* ֵɢ +*/ +UINT32 GetEaBehindDis(void) +{ + return SystemParameterStruNew.dwEaBehindDis; +} + + +/* +* RCģʽ +* ˵UINT8 localRcWorkMode RCģʽ +* ֵ1uɹ 0uʧ +*/ +UINT8 SetLocalRcWorkMode(UINT8 localRcWorkMode) +{ + UINT8 rtn = 0u; /*ֵ*/ + + if ((RC_WORK_MODE_CI == localRcWorkMode) || (RC_WORK_MODE_TIOC == localRcWorkMode)) + { + LocalRcWorkMode = localRcWorkMode; + rtn = 1u; + } + + return rtn; +} + +/* +* ȡRCģʽ +* ˵ +* ֵRCģʽ +*/ +UINT8 GetLocalRcWorkMode(void) +{ + return LocalRcWorkMode; +} +/* +* ȡ˹ʱ +* ˵ void +* ֵ ˹ʱ +*/ +UINT32 GetlabarUnlockOverlapTimeCount(void) +{ + return labarUnlockOverlapTimeCount; +} +/* +* ȡŹرճʱ +* ˵ void +* ֵ Źرճʱ +* cgh-ϲCID-2349-4 +*/ +UINT32 GetPsdDrivCloseMaxCount(void) +{ + return psdDrivCloseMaxTimeCount; +} +/* +* ȡŴ򿪳ʱ +* ˵ void +* ֵ Ŵ򿪳ʱ +* cgh-ϲCID-2349-4 +*/ +UINT32 GetPsdDrivOpenMaxCount(void) +{ + return psdDrivOpenMaxTimeCount; +} +/* +* ֮ɼȫʱ +* ˵ void +* ֵ ֮ɼȫʱ +*/ +UINT32 GetSigCollectRongernCount(void) +{ + return sigCollectRongrenCount; +} + +/* +* SPKSťָʾƵʱ +* ˵ void +* ֵ SPKSťָʾƵʱ +*/ +UINT32 GetSpksIndicDelayCount(void) +{ + return SpksIndicDelayCount; +} +/* +* ȡЭ汾 +* ˵ void +* ֵ Э汾 +* cgh-ϲCID-3037-13 +*/ +UINT8 GetCiAndAxisPrtclCheckVer(void) +{ + return ciAndAxisPrtclCheckVer; +} +/* +* ñԼ̵ӿ +* ˵Լ̵ӿ +* ֵ +*/ +void SetLocalWaysidePattern(UINT8 localWaysidePattern) +{ + + if ((RELAY_PATTERN_TRADITIONAL == localWaysidePattern) || (RELAY_PATTERN_FULL_ELECTRONIC == localWaysidePattern)) + { + LocalWaysidePattern = localWaysidePattern; + } + else + { + /*Ĭȫ*/ + LocalWaysidePattern = RELAY_PATTERN_FULL_ELECTRONIC; + } +} +/* +* ȡԼ̵ӿ +* ˵void +* ֵԼ̵ӿ +*/ +UINT8 GetLocalWaysidePattern(void) +{ + return LocalWaysidePattern; +} + +/* +* Žʱ +* ˵ void +* ֵ Žʱʱʱʱ +*/ +UINT32 GetMjjsOpenDelayCount(void) +{ + return mjjsOpenDelayCount; +} + +/* +* ȡԸʽťӦ̵ɼʱ +* ˵ void +* ֵ ԸʽťӦ̵ɼʱ +*/ +UINT32 GetSelfButCollCount(void) +{ + return dwSelfButCollCount; +} + +/* +* ȡԸʽ۳/ťжʱ +* ˵ void +* ֵ Ըʽťжʱ +*/ +UINT32 GetSelfButErrCount(void) +{ + return dwSelfButErrCount; +} + +/* +* ȡԸʽȡ۳/ťжʱ +* ˵ void +* ֵ Ըʽťжʱ +*/ +UINT32 GetSelfCancelButErrCount(void) +{ + return dwSelfCancelButErrCount; +} + +/* +* ȡⱨ·ʱʱ +* ˵ void +* ֵ ⱨ·ʱʱ +*/ +UINT32 GetSGBJRouteDelayOpenCount(void) +{ + return dwSGBJRouteDelayOpenCount; +} + +/* +* ȡѹ̼SPKS״̬ +* ˵ +* ֵѹ̼SPKS״̬ +*/ +UINT8 GetAwakeCheckSpksSwitch(void) +{ + return SystemParameterStruNew.cAwakeCheckSpksSwitch; +} + +/* +* ȡIVOCVOBCRCͨͨŹжʱ(ms) +* ˵ +* ֵIVOCRCͨͨŹжʱ +*/ +UINT32 GetVobcCiBackUpCommErrorTime(void) +{ + return SystemParameterStruNew.dwVobcCiBackUpCommErrorTime; +} + +/* +* ȡIVOCVOBCRCͨͨŹж +* ˵ void +* ֵ ʱ +*/ +UINT32 GetVobcCiBackUpCommErrorCount(void) +{ + return VobcAndCiBackUpCommBadCount; +} + +/* +* ȡŽӽռӳٹʱ +* ˵ void +* ֵ Žӽռӳٹʱ +*/ +UINT32 GetFloodGateDelayCloseCount(void) +{ + return dwFloodGateDelayCloseCount; +} + +/* +* ȡ·ߵδʱȡ·ȴʱ +* ˵ void +* ֵ ·ߵδʱȡ·ȴʱ +*/ +UINT32 GetSwitchBypassWaitCount(void) +{ + return dwSwitchBypassWaitCount; +} + +/* +* ȡײǽܿ +* ˵ +* ֵ0x55 ش +* 0xaa عر +*/ +UINT8 GetHitSoftWallSwitch(void) +{ + return SystemParameterStruNew.dwHitSoftWallSwitch; +} + +/* +* ȡշʽ +* ˵ +* ֵ0x01 ATS +* 0x02 CI +*/ +UINT8 GetOverlapLockTypeSwitch(void) +{ + return SystemParameterStruNew.dwOverlapLockType; +} + +/* +* ȡUDP־ʱְС(byte) +* ˵ void +* ֵ UINT16 ְС +* 20240214 LC +*/ +UINT16 GetLogSubPackDataLength(void) +{ + UINT16 wRtn = 0U; + + wRtn = GetSystemParaValue(LOG_SUBPACK_DATA_LENGTH); + + return wRtn; +} + +/* +* ȡԸʽȡ۳/ť󴥷жʱ +* ˵ void +* ֵ Ըʽȡ۳/ť󴥷жʱ +*/ +UINT32 GetSelfCancelButErrTriggerCount(void) +{ + return dwSelfCancelButErrTriggerCount; +} + +/* +* ò +* ˵UINT8* pDataAddr ݵַ +* ֵCI_SUCCESS ɹ CI_ERROR ʧ +* by cgh 20240605 +*/ +UINT8 SetOtherCiPara(UINT8* pDataAddr) +{ + UINT8 rtn = CI_ERROR; /*ֵ*/ + UINT16 val = 0U; + UINT16 wParaVal = 0U;/*ֵ*/ + + if(NULL != pDataAddr) + { + if (CI_SUM_MAX > *pDataAddr) + { + if (((CI_PATTERN_TRADITIONAL == pDataAddr[1]) || (CI_PATTERN_FULL_ELECTRONIC == pDataAddr[1])) + && ((CI_CENTER_IO == pDataAddr[2]) || (CI_DISTRIBUTED_IO == pDataAddr[2])) + && ((RC_WORK_MODE_CI == pDataAddr[12]) || (RC_WORK_MODE_TIOC == pDataAddr[12]))) + { + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].chOtherCiId = pDataAddr[0]; + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].chOtherCiType = pDataAddr[1]; + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].chOtherCiDistributedIO = pDataAddr[2]; + + wParaVal = ShortFromChar(&pDataAddr[3]); + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].wOtherCiUTProSecUnlockCyc = TimeToCycleCount((UINT32)wParaVal * 1000U, 300U); + wParaVal = ShortFromChar(&pDataAddr[5]); + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].wOtherCiCTProSecUnlockCyc = TimeToCycleCount((UINT32)wParaVal * 1000U, 300U); + wParaVal = ShortFromChar(&pDataAddr[7]); + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].wOtherCiUTNearUnLockCyc = TimeToCycleCount((UINT32)wParaVal * 1000U, 300U); + wParaVal = ShortFromChar(&pDataAddr[9]); + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].wOtherCiCTNearUnLockCyc = TimeToCycleCount((UINT32)wParaVal * 1000U, 300U); + + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].chOtherCiWaysidePattern = pDataAddr[11]; + SystemParameterStruNew.otherCICiParaStru[*pDataAddr].chOtherCiRcWorkMode = pDataAddr[12]; + + rtn = CI_SUCCESS; /*ֵ*/ + } + else + { + ; /*ش*/ + } + } + else + { + ; /*ش*/ + } + + } + else + { + ; /*ش*/ + } + + return rtn; +} + +/* +* ȡò +* ˵const UINT8 chOtherCiId ID +* ֵCI_SUCCESS ɹ CI_ERROR ʧ +* by cgh 20240605 +*/ +OtherCiParaStruct GetOtherCiPara(const UINT8 chOtherCiId) +{ + OtherCiParaStruct chReval = { 0U }; + + if (CI_SUM_MAX > chOtherCiId) + { + chReval = SystemParameterStruNew.otherCICiParaStru[chOtherCiId]; + } + else + { + ; /*0*/ + } + + return chReval; +} + +/* +* ȡCվBUTǿ׷ٹܿ +* ˵ +* ֵaaر 55 +* by cgh 20240815 +*/ +UINT8 GetNoCGFollowUtSwitch(void) +{ + return SystemParameterStruNew.chNoCGFollowUtSwitch; +} + +/* +* ȡARBμ鳤(m) +* ˵ void +* ֵ UINT16 wArbCheckMaxLen 鳤 +* by fan 20240820 +*/ +UINT16 GetArbCheckAxisLen(void) +{ + return wArbNearSecProtectDistance; +} + +/* +* ȡARBη +* ˵ void +* ֵ UINT32 +* by fan 20240820 +*/ +UINT32 GetArbProtectCheckTime(void) +{ + return dwArbNearSecNoUtCount; +} + +/* +* ȡ۷ťж +* ˵ void +* ֵ ۷ťж +* by cgh 20240905 +*/ +UINT32 GetdwNonReturnBtnErrEnsureCount(void) +{ + return dwNonReturnBtnErrEnsureTime; +} + +/* +* ñOC汾 +* ˵OC汾 +* ֵɹ CI_SUCCESS ʧCI_ERROR +* Create: fan 20250210 +*/ +UINT8 SetLocalOcPattern(UINT8 localOcPattern) +{ + UINT8 rtn = CI_ERROR; /*ֵ*/ + + if ((OC_DATA_TYPE_NEW == localOcPattern) || (OC_DATA_TYPE_OLD == localOcPattern)) + { + gLocalOcType = localOcPattern; + rtn = CI_SUCCESS; + } + + return rtn; +} + +/* +* ȡOC汾 +* ˵OC汾 +* ֵ0x55 °汾 0xaa Ͼɰ汾 +* Create: fan 20250210 +*/ +UINT8 GetLocalOcPattern() +{ + return gLocalOcType; +} + +/* +* ܣRC +* ˵UINT8 cLinkLineAttr RC +* ֵ1 ɹ +* 0 ʧ +*/ +UINT8 SetLocalRcLinkLineAttr(UINT8 cLinkLineAttr) +{ + UINT8 rtn = CI_ERROR; /*ֵ*/ + + if ((RC_LINK_LINE_YES == cLinkLineAttr) || (RC_LINK_LINE_NO == cLinkLineAttr)) + { + gLocalRcLinkLineAttr = cLinkLineAttr; + rtn = CI_SUCCESS; + } + else + { + /*ηǷʧ*/ + } + + return rtn; +} + +/* +* ܣȡRC +* ˵ +* ֵRC +*/ +UINT8 GetLocalRcLinkLineAttr(void) +{ + return gLocalRcLinkLineAttr; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/System/SystemParameterManage.h b/TSCP/src/APP/ciapp/System/SystemParameterManage.h new file mode 100644 index 0000000..822edb1 --- /dev/null +++ b/TSCP/src/APP/ciapp/System/SystemParameterManage.h @@ -0,0 +1,1385 @@ +/******************************************************** +* +* SystemParameterManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-03-21 +* ߣ +* ϵͳͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _SYSTEM_PARAMETER_MANAGE_H_ +#define _SYSTEM_PARAMETER_MANAGE_H_ + + +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../2oo2/2oo2InterfaceDataManage.h" +#include "DebugPrintInterface.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define CI_SYSTEM_PARA_SUM_MAX ((UINT16)200) /*CIϵͳò*/ + + +#define CI_FUNCTION_SWITCH_SUM_MAX ((UINT16)200) /*Ŀ*/ +#define CLOSE_OPENED_SIG_LOCK_SWITCH ((UINT8)1) /*رѿź*/ +#define CLOSE_OPENED_SIG_LOCK_SIGNAL ((UINT8)2) /*źŻرѿź*/ +#define CHECK_SWITCH_LOCKING_BEFORE_LOCKING_SWITCH_CONF ((UINT8)3) /*ʱ*/ +#define CHECK_SWITCH_DANLOCK_FLOCKING_SWITCH_CONF ((UINT8)4) /*ʱ*/ +#define VOBC_INTERFACE_IDENTITY ((UINT8)5) /*VOBCӿͱʶ1ΪFAO2Ϊͨ*/ +#define SCX_CLD_INTERFACE_TYPE ((UINT8)8) /*Գ복νӿͱʶ0x55Ϊ̵ӿڣ0xAAΪͨŽӿ*/ +#define LINE_RAILWAY_TYPE_CONF ((UINT8)9) /*·ͱʶ0x55Ϊǹ콻ͨ0xAAΪ콻ͨ*/ +#define DISTRIBUTED_IO_ENABLE_INDEX ((UINT8)10) /*ܿ10Ƿ÷ֲʽIO*/ +#define ARB_MOVE_SWITCH_CONF ((UINT8)11) /*ARBǷɶ0x55Ϊȡ0xAAΪȡ*/ +#define UNLOCK_OVERLAP_SWITCH_CONF ((UINT8)12) /*Σ0x55Ϊͳʽ0xAAΪʱZC뱣ν2018.11.05*/ +#define BLK_TEMP_SPEED_LIM_CONF ((UINT8)13) /*ʽʱݶȡͣ0x55ȡʽʱټα0xAAȡʽʱ߼α*/ +#define CI_FUNCTION_SWITCH_SHOW_SIGNAL_GreenYellow ((UINT8)14) /*Ƿʾ̻Ƶ*/ +#define FUNC_SIGNAL_LSXS_TYPE ((UINT8)15) /*źŻʱټ㷽ʽ 0xaaݽ·Ƿʱ 0x55õźŻǷʱ*/ +#define FUCN_IF_PSC ((UINT8)16) /*ǷPSCͨ*/ +#define FUNC_SWITCH_CHECK_END_SIGNAL_DS ((UINT8)17) /*նźŻ˿0x55:˿0xAA˿*/ +#define FUNC_RELAY_DETAIN_VALID_FLAG ((UINT8)18) /*źŻӲ߿۳Ч־0x55:Ч0xAAЧĬ0x55*/ +#define FUNC_SWITCH_SEND_UNLOCK_OVERLEP_TIMER_COUNTDOWN ((UINT8)19) /*CBTCģʽǷͱνʱϢ0x55:0xAA*/ +#define FUNC_SWITCH_USE_RELAY_INTERFACE_BETWEEN_NEIGHBOURCI ((UINT8)20) /*Ƿм̵ӿڣ0x55:ʹã0xAAʹ*/ +#define FUNC_SWITCH_JUMPLOCK_DRIVE_SWITCH ((UINT8)21) /*ԾǷ0x55:0xAA*/ +#define FUNC_CLD_GD_DIANLU_LINE ((UINT8)22) /*·Ƿʹù·0x55:ʹù·0xAAʹù·*/ +#define FUNC_SWITCH_AC_FACTORY ((UINT8)23) /*ϵͳұʶ0x55:ʹ,0x01:У0x02:ư*/ +#define FUNC_SIGNAL_ALARM_DUANSI_FLAG ((UINT8)24) /*˿˿Чʶ0x55:̵±ʾб0xAA:̵ʾб*/ +#define FUNC_DIANSHI_LINSHIXIANSU_FLAG ((UINT8)25) /*·Ƿֵ֧ʽʱ٣0x55:֧֣0xAA:֧*/ +#define FUNC_YDROUTE_SEC_FLOCK_CHECK_FLAG ((UINT8)26) /*·Ƿη0x55:飬0xAA:*/ +#define FUNC_JXTC_INTERFACE_MODE ((UINT8)27) /*϶̽ӿڷʽ0xaa:壬0x55:ƽ*/ +#define FUNC_DS_BREAK_AUTOSIG_LOSE_EFFICACY_FLAG ((UINT8)28) /*˿ϺԶźʧЧ0xaa:ʧЧ0x55:ʧЧ*/ +#define FUNC_DETAIN_OPEN_RED ((UINT8)29) /*۳Ƿ񿪷źơ0x55:۳رźŲ⴦0xaa:۳رźſź*/ +#define FUNC_INCLUDEVIRCI_FLAG ((UINT8)30) /*֧֡0x55:֧֡0xaa:֧*/ +#define FUNC_KOUCHE_CLOSE_YINDAO_FLAG ((UINT8)31) /*۳رźţ0x55:۳󲻹رźţ0xAA:۳رź*/ /* 2022/2/22, */ +#define FUNC_CHECK_FLOCK_BEFORE_DANSUO ((UINT8)32) /*ʱ0x55:ʱ0xAA:ʱ*/ /* 2022/4/7, */ +#define FUNC_CBTC_CHECK_JUMPLOCK_FLAG ((UINT8)33) /*CBTCģʽǷԾգ0x55:飻0xAA: 2022/4/7, */ +#define FUNC_PSD_SEND_ATS_STATE_FLAG ((UINT8)34) /*PSDʱATS״̬0x55:͹״̬0xAA:ʵ״̬*/ /* 2022/6/22, */ +#define FUNC_YD_PSWITCH_MOVE_SWITCH ((UINT8)35) /*·Ƿɶ 0x55ɶ0xaa ɶ*/ +#define FUNC_RESET_ARB_SWITCH ((UINT8)36) /*ϵ󣬾ͷ߼ֱARB0x55رգ0xAA*/ +#define FUNC_DSN_LINE_SWITCH ((UINT8)37) /*Ƿֵ֧ʿ᣺0x55֧֣0xAA֧*/ +#define FUNC_ARB_SWITCH ((UINT8)38) /* ARBܿ */ +#define FUNC_TOA_SWITCH ((UINT8)39) /* ֱռùܿ */ +#define FUNC_UCT_SWITCH ((UINT8)40) /* UCTܿ*/ +#define FUNC_TMC_SWITCH ((UINT8)41) /* TMCܿ (Ƿʼȫվʱ)*/ +#define FUNC_ROUTE_DRV_SWITCH_EARLY ((UINT8)42) /* ·ǰܿ 0x55:ָ֧ùܡ0xaa:ָ֧ù*//*ΪС߼Σֽ֧·ǰ*//*add 20221002 TIOC5.0*/ +#define FUNC_EA_SWITCH ((UINT8)43) /*ɢܿ*/ +#define FUNC_INTRUSEC_CHECKFLOCK_FLAG ((UINT8)44) /*жʱǷη 0x55:飻0xAA: 2022/8/25,*/ +#define FUNC_XIANSU_SWITCH ((UINT8)45) /*ģʽźſǷʱ٣0x55:飻0xaa:飩*/ +#define FUNC_RRM_SWITCH ((UINT8)46) /*ԶRMܿ*/ +#define FUNC_DEPART_RRM_SWITCH ((UINT8)47) /*վ֧ԶRMܿ*/ +#define FUNC_DA_SWITCH ((UINT8)48) /*ѹܿأ0x55:֧֣0xaa֧֣*/ +#define FUNC_OC_100_OR_200 ((UINT8)49) /*ִеԪʹͣ0x55:OC-1000xaaOC-200*/ +#define FUNC_OC_200_INOUTNET ((UINT8)50) /*OCͨʹã0x55:0xaa*/ +#define FUNC_ZIFUSHI_BUTTON ((UINT8)51) /*ťǷΪԸʽ0x55:Ըʽ0xaaԸʽ*/ +#define FUNC_JIZHONGQU_LINSHIXIASNSU_FLAG ((UINT8)52) /*ZCͨжϺǷüʱ٣0x55:ã0xaaã*/ +#define FUNC_REPEATE_OPEN_CHECK_SPKS ((UINT8)53) /*ʽ·ؿźǷSPKS״̬0x55:飬ʽؿ0xaa飬ؿ*/ +#define FUNC_SWITCH_SHIBIAO_PROMPTLY_ALARM ((UINT8)54) /*ʧǷATS0XAA 0X55ȴʱ䳬ޱ*/ +#define FUNC_FLOODGATE_NO_CLOSE_REQ_CHECK ((UINT8)55) /*гԴŹر״̬(oxAA:(),0X55:ر)*/ +#define FUNC_FLOODGATE_NO_OPEN_LOCK_CHECK ((UINT8)56) /*гԴſ״̬(oxAA:(),0X55:ر)*/ +#define FUNC_SETROUTE_CONNECT_CHECK ((UINT8)57) /*·(0XAA 0X55ر)*/ +#define FUNC_ROUTELOCK_OPEN_SIGNAL ((UINT8)58) /*·յǷؿźſ(0XAA򿪣ִУ 0X55رգִУ */ +#define FUNC_EVACUATE_RELATE_DIR_SWITCH ((UINT8)59) /*ɢп(0XAA 0X55ر)*/ +#define FUNC_TG_RELATE_DIR_SWITCH ((UINT8)60) /*ѹп(0XAA 0X55ر)*/ +#define FUNC_INTRUSEC_VAIN_NEWVERSION ((UINT8)61) /*°(0XAA 0X55)*/ +#define FUNC_LJK_EXIST_DB ((UINT8)62) /*RCල߻ѹгռѹܿ(0xAADB·俪 0x55أDB·)*/ +#define FUNC_ZQX_CHECK_HUMID_RAIL ((UINT8)63) /*ȡǷ·ʼźŻʪ췶Χ(0xAAȡʪģʽ״̬ 0x55أȡʪģʽ״̬)*/ +#define FUNC_AXIS_COMM_BAD_KEEP_CBTC ((UINT8)64) /*ϵͳͨжϺǷܹάCBTC(0xAAǣ 0x55)*/ +#define FUNC_INIT_XIANDI_HAVE_POWER ((UINT8)65) /*ϵʼֵǷȨ(0x55:޿Ȩ;0xAA:пȨ)*/ + + +#define CiSum_ID ((UINT16)1)/*ʵվ */ +#define AppCycleTime_ID ((UINT16)2)/*Ӧ(λ:ms) (ֶ)*/ +#define StartUnlockTime_ID ((UINT16)3)/*ϵʱ(λ:s) (ֶ)*/ +#define RouteXuanPaiTime_ID ((UINT16)4)/*·ѡųʱ(λ:s) (ֶ)*/ +#define RouteLockTime_ID ((UINT16)5)/*·ճʱ(λ:s) (ֶ)*/ +#define OverlapLockTime_ID ((UINT16)6)/*ճʱ(λ:s) (ֶ)*/ +#define RouteOpenSigTime_ID ((UINT16)7)/*·ųʱ(λ:s) (ֶ)*/ +#define BlocRouteDelayTime_ID ((UINT16)8)/*ʽ·ʱʱ(λ:s) (ֶ)*/ +#define CbtcRouteDelayTime_ID ((UINT16)9)/*CBTC·ʱʱ(λ:s) (ֶ)*/ +#define LeadRouteFaultOpenTime_ID ((UINT16)10)/*·ڷιźſųʱ(λ:s) (ֶ)*/ +#define SecDelayUnlockTime_ID ((UINT16)11)/*ʱʱ(λ:s) (ֶ)*/ +#define SignalOpenTime_ID ((UINT16)12)/*źſųʱ(λ:s) (ֶ)*/ +#define SignalCloseTime_ID ((UINT16)13)/*źŹرճʱ(λ:s) (ֶ)*/ +#define SwitchMoveTime_ID ((UINT16)14)/*ʱ(λ:s) (ֶ)*/ +#define SwitchDriveTime_ID ((UINT16)15)/*ʱ(λ:s) (ֶ)*/ +#define ProtectSecUnlockTime_ID ((UINT16)16)/*νͣʱ(λ:s) (ֶ)*/ +#define OccupyToIdleTime_ID ((UINT16)17)/*ռñмʱʱ(λ:s) (ֶ)*/ +#define FaultUnlockTime_ID ((UINT16)18)/*׹ιϽʱ(λ:s) (ֶ)*/ +#define SectionResetTime_ID ((UINT16)19)/*Ḵλʱʱ(λ:s) (ֶ)*/ +#define NonRouteXuanPaiTime_ID ((UINT16)20)/*ǽ·ѡʱ*/ +#define NonRouteDelayUnlockTime_ID ((UINT16)21)/*ǽ·ʱʱ*/ +#define SwitchDriveCuoFengTime_ID ((UINT16)22)/*·ѡŵʱ*/ +#define ZuheRouteXuanPaiTime_ID ((UINT16)23)/*Ͻ·ѡʱ*/ +#define WaitZCResponseTime_ID ((UINT16)24)/*ȴZCʱ䣨رճţʱ䵥λ*/ +#define SecJumpLockDelayUnlockTime_ID ((UINT16)25)/*Ծʱʱ(λ:s) (ֶ)*/ +#define GaragedoorOperateTime_ID ((UINT16)26)/*Ŷʱʱ(λ:s) (ֶ)*/ +#define CtProtectSecUnlockTime_ID ((UINT16)27) /*CTνͣʱ(s)*/ +#define SingleSwitchMoveTime_ID ((UINT16)28)/*쵥ʱ(s)*/ +#define ThreeSwitchMoveTime_ID ((UINT16)29)/*ʱ(s)*/ +#define FiveSwitchMoveTime_ID ((UINT16)30)/*忪ʱ(s)*/ +#define gapDetectTime_ID ((UINT16)31)/*϶̽ʱ*/ +#define psdButtonPressTime_ID ((UINT16)32)/*վ̨ťʧЧʱ䣨s*/ +#define DCTYWaitSignalOpenCount_ID ((UINT16)33)/*ͬȴźؿʱT(S)*/ +#define ZFWJRelayDriveTime_ID ((UINT16)34)/*ܸλʱT(S)*/ +#define CiAndAxleTransmitBadEnsureTime_ID ((UINT16)35)/*CI-ϵͳͨŹжʱ䣨룩*/ +#define CiAndOCTransmitBadEnsureTime_ID ((UINT16)36)/*CI-OCͨŹжʱ䣨룩*/ +#define DHFRelayValidTime_ID ((UINT16)37)/*λDFH̵ʱ()*/ +#define FirstOrderTime_ID ((UINT16)38)/*һЧʱ()*/ +#define JXTCPulseContinueTime_ID ((UINT16)39) /*϶̽ʱ䣨룩*/ +#define CLD_SERIAL_PORT_COM_ID ((UINT16)40) /*κԳߴͨŶ˿ڣʮƣ010201ʾCOM1,02ʾCOM2*/ +#define SCX_SERIAL_PORT_COM_ID ((UINT16)41) /*ԳߺͳδͨŶ˿ڣʮƣ010201ʾCOM1,02ʾCOM2*/ +#define LABAR_UNLOCK_OVERLAP_time ((UINT16)42U) /*˹ʱʱ䣨룩*/ +#define CONFIG_PSD_CLOSE_MAX_TIME ((UINT16)43U) /*Źرճʱ*/ +#define CONFIG_PSD_OPEN_MAX_TIME ((UINT16)44U) /*Ŵ򿪳ʱ*/ +#define CONFIG_SIG_RONGREN_MAX_TIME ((UINT16)45U) /*֮ɼȫʱ*/ +#define CONFIG_SPKSDELAY_TIME ((UINT16)46) /*SPKSťָʾƵʱʱ()*/ +#define CONFIG_CI_AXIS_PRTCL_VER (47U) /*ϵͳУЭ汾*/ +#define AXLE_SEG_UT_REDUNDANCE_ID (48U)/*UTռѹʱ(MS)*/ +#define SIGNAL_LIGHTUP_SEC_LEN_ID (49U)/*ӪҪźŻγףM*/ +#define SIGNAL_LIGHTUP_BIG_ALXE_SEC_LEN_ID (50U)/*źŻγ᳤(M)*/ +#define SIGNAL_LIGHTUP_EX_ALXE_SEC_LEN_ID (51U)/*źŻӳ᳤(M)*/ +#define SIGNAL_CROSS_MAX_LEN_ID (52U)/*źŻѹ(M)*/ +#define BACK_PROTECT_MAX_LEN_ID (53U)/*վ̨׷ٷ(M)*/ +#define SHORTEST_TRAIN_LEN_ID (54u)/*·̳*//* add 2022.3.12 */ +#define CT_FlYING_REDUN_TIME_ID (55u)/* ɳ崻ʱ䣨ms */ +#define DYTEST_SUM_MAX_ID (56u)/*ͬʱж̬г*/ +#define EA_MODE_ID (57u)/*ɢʽ*/ +#define EA_STATION_MODE_ID (58u)/*վ̨ɢʽ*/ +#define ZFS_BUTTON_RELAY_COLL_TIME (59U) /* ԸʽťӦ̵ɼʱ䣨ms*/ +#define ZFS_BUTTON_FAULT_ENSURE_TIME (60U) /* Ըʽ۳/ťжʱ䣨s*/ +#define CONFIG_MJJSOPENDELAY_TIME (61u) /*Žʱʱ()*/ +#define TRAIN_RECYCLE_RES_TIME (62U) /*гԴʱʱ䣨ms*/ +#define ZFS_CANCEL_BTN_ERR_ENSURE_TIME (63U) /* Ըʽȡ۳/ťжʱ䣨s*/ +#define ROUTE_NEAREST_TRAIN_RENJIE_TIME (64U) /*·ӽгҪ˽·ʱʱȴʱ䣨s*/ +#define SGBJ_ROUTE_DELAY_OPEN_TIME (65U) /*ⱨ·ʱʱ䣨s*/ +#define FLOODGATE_ACCESS_OCC_DELAY_OPEN_TIME (66U) /*Žӽռӳٹʱ(S)*/ +#define SWITCH_BYPASS_DELAY_TIME (67U) /*·ߵδʱȡ·ȴʱ(S)*/ +#define LOG_SUBPACK_DATA_LENGTH (68U) /*UDP־ʱÿְij(Byte)*/ +#define ZFS_CANCEL_BTN_ERR_TRIGGER_TIME (69U) /*Ըʽȡ۳ť󴥷жʱ䣨s*/ +#define ARB_CHECK_ALXE_SEC_LEN (70U) /*ARBμ᳤(M)*/ +#define ARB_CHECK_ALXE_TIME (71U) /*ARBμ޻ʱms*/ +#define NONRETURN_BTN_ERR_ENSURE_TIME (72U) /*۷ťжʱ䣨/S*/ + +#define FUNC_SWITCH_ON ((UINT8)0xAA) /*ÿش*/ +#define FUNC_SWITCH_OFF ((UINT8)0x55) /*ÿعر*/ +#define FUNC_SWITCH_UNDEF ((UINT8)0xFF) /*ÿδ*/ +#define LINE_FAO ((UINT8)0x01) /*·ΪFAO*/ +#define LINE_HLHT ((UINT8)0x02) /*·Ϊͨ*/ +#define LINE_FAOHLHT ((UINT8)0x03) /*·ΪFAO+ͨ»*/ +#define LINE_CC ((UINT8)0x05) /*·Ϊ· 15*/ +#define LINE_FAOHLHT_ONESELF ((UINT8)0x04) /*·ֻԼVOBCFAO+ͨӿ*/ +#define LINE_FAOHLHT_ONESELFSECOND ((UINT8)0x06) /*ڻͨϣɾվ̨ϢȫԶϴϢ*/ +#define SCX_CLD_INTERFACE_COMM ((UINT8)0xAA) /*Գ복βͨŽӿ*/ +#define SCX_CLD_INTERFACE_RELAY ((UINT8)0x55) /*Գ복βü̵ӿ*/ +#define SCX_CLD_SERIAL_PORT_COMM ((UINT8)0x5A) /*Գ복βôڽӿ*/ +#define SCX_NONELOCAL_MODE ((UINT8)0xA5) /*Գ*/ + +#define UP_VALID ((UINT8)0x55) /*۳̵Ч*/ +#define DOWN_VALID ((UINT8)0xaa) /*۳̵Ч*/ + +#define CI_PATTERN_TRADITIONAL ((UINT8)0x55) /*ͳ*/ +#define CI_PATTERN_FULL_ELECTRONIC ((UINT8)0xAA) /*ȫ*/ + +#define CI_CENTER_IO ((UINT8)0x55)/*ʽIO*/ +#define CI_DISTRIBUTED_IO ((UINT8)0xAA)/*ֲʽIO*/ + +#define Oc_Max_Board_Num (20U) /*һOC忨Ŀ*/ + +#define CI_SIGNAL_MAX ((UINT16)300) /*һCIźŻĿ*/ +#define CI_SWITCH_MAX ((UINT16)100) /*һCIĿ*/ +#define CI_GD_MAX ((UINT16)700) /**/ + +#define RC_WORK_MODE_CI ((UINT8)0x55u) /*ģʽ*/ +#define RC_WORK_MODE_TIOC ((UINT8)0xAAu) /*TIOCģʽ*/ + +#define RELAY_PATTERN_TRADITIONAL 0x55U /*̵ӿ*/ +#define RELAY_PATTERN_FULL_ELECTRONIC 0xAAU /*Ǽ̵ӿ*/ + +#define FUNC_HITSOFTWALL_ON ((UINT8)0x55) /*ײǽش*/ +#define FUNC_HITSOFTWALL_OFF ((UINT8)0xaa) /*ײǽعر*/ + +#define FUNC_OVERLAP_LOCK_BY_ATS ((UINT8)0x01) /*ATSձ*/ +#define FUNC_OVERLAP_LOCK_BY_CI ((UINT8)0x02) /*ձ*/ + +#define OC_DATA_TYPE_NEW ((UINT8)0x55u) /*OCݽṹ__OC3.0 ݽṹ26.0*/ +#define OC_DATA_TYPE_OLD ((UINT8)0xAAu) /*ݵOCݽṹ_OC2.1.6 ݽṹ24.0*/ + +#define RC_LINK_LINE_YES ((UINT8)0x55U) /*߱*/ +#define RC_LINK_LINE_NO ((UINT8)0xAAU) /*߱*/ + +/*ϵͳṹ*/ +typedef struct S_SystemParameterStruct +{ + UINT8 CiSum; /*ʵվ*/ + UINT32 AppCycleTime; /*Ӧ(λ:ms) (ֶ)*/ + UINT32 StartUnlockTime; /*ϵʱ(λ:s) (ֶ)*/ + UINT32 RouteXuanPaiTime; /*·ѡųʱ(λ:s) (ֶ)*/ + UINT32 RouteLockTime; /*·ճʱ(λ:s) (ֶ)*/ + UINT32 OverlapLockTime; /*ճʱ(λ:s) (ֶ)*/ + UINT32 RouteOpenSigTime; /*·ųʱ(λ:s) (ֶ)*/ + UINT32 BlocRouteDelayTime; /*ʽ·ʱʱ(λ:s) (ֶ)*/ + UINT32 CbtcRouteDelayTime; /*CBTC·ʱʱ(λ:s) (ֶ)*/ + UINT32 LeadRouteFaultOpenTime; /*·ڷιźſųʱ(λ:s) (ֶ)*/ + UINT32 SecDelayUnlockTime; /*ʱʱ(λ:s) (ֶ)*/ + UINT32 SignalOpenTime; /*źſųʱ(λ:s) (ֶ)*/ + UINT32 SignalCloseTime; /*źŹرճʱ(λ:s) (ֶ)*/ + UINT32 SwitchMoveTime; /*ʱ(λ:s) (ֶ)*/ + UINT32 SwitchDriveTime; /*ʱ(λ:s) (ֶ)*/ + UINT32 ProtectSecUnlockTime; /*νͣʱ(λ:s) (ֶ)*/ + UINT32 OccupyToIdleTime; /*ռñмʱʱ(λ:s) (ֶ)*/ + UINT32 FaultUnlockTime; /*׹ιϽʱ(λ:s) (ֶ)*/ + UINT32 SectionResetTime; /*Ḵλʱʱ(λ:s) (ֶ)*/ + UINT32 NonRouteXuanPaiTime; /*ǽ·ѡʱ*/ + UINT32 NonRouteDelayUnlockTime; /*ǽ·ʱʱ*/ + UINT32 SwitchDriveCuoFengTime; /*·ѡŵʱ*/ + UINT32 ZuheRouteXuanPaiTime; /*Ͻ·ѡʱ*/ + UINT32 WaitZCResponseTime; /*ȴZCʱ䣨رճţʱ䵥λ*/ + UINT32 SecJumpLockDelayUnlockTime; /*Ծʱʱ(λ:s) (ֶ)*/ + UINT32 GaragedoorOperateTime; /*Ŷʱʱ(λ:s) (ֶ)*/ + UINT32 CtProtectSecUnlockTime; /*ͨųռý·һµķνͣʱ(λ:s)(ֶ)*/ + UINT32 SingleSwitchMoveTime; /*쵥ʱ*/ + UINT32 ThreeSwitchMoveTime; /*ʱ*/ + UINT32 FiveSwitchMoveTime; /*忪ʱ*/ + UINT32 gapDetectTime; /*϶̽ʱ(λ:s)*/ + UINT32 psdButtonPressTime; /*վ̨ťʧЧʱ(λ:s)*/ + UINT32 dwDCTYWaitSignalOpenCount; /*ͬȴźؿʱ(λ:s)*/ + UINT32 ZFWJRelayDriveTime; /*ܸλʱ(λ:s)*/ + UINT32 CiAndAxleTransmitBadEnsureTime; /*ͨжȷʱ䵥λ*/ + UINT32 dwCiAndOcTransmitBadEnsureTime; /*OCͨжȷʱ䵥λ*/ + UINT32 AxleSectionUtRedundanceTime; /*UTռѹ*/ + + UINT8 CiType; /* 1Ϊ 4 Ϊ 5 ΪԳ */ + UINT32 CiAndZcTransmitBadEnsureTime; /*ZCͨжȷʱ䵥λ*/ + UINT32 CiAndCiTransmitBadEnsureTime; /*ͨжȷʱ䵥λ*/ + UINT32 CiAndVobcTransmitBadEnsureTime; /*Vobcͨжȷʱ䵥λ*/ + UINT32 CiAndPsdTransmitBadEnsureTime; /*PSDͨжȷʱ䵥λ*/ + UINT8 chVersionOfZCToCI; /*ZC-CIӿЭ汾ţadd by sds 2019-1-21*/ + UINT8 chVersionOfVOBCToCI; /*VOBC-CIӿЭ汾ţadd by sds 2019-1-21*/ + UINT32 CiAndPscTransmitBadEnsureTime; /*Pscͨжȷʱ䵥λ*/ + + /**********ϵͳ****************/ + UINT16 MaxLineLimitSpeed;/*·,˴ݿдŵUINT8km/hݣҪתcmpsλ*/ + UINT8 MaxTsrSpeed;/*ʱ*/ + UINT8 TimeZoneDifference;/*NTPУʱʱ.ʱ뱾ʱʱλʱӦʹʱӦ3600תΪ롣*/ + UINT16 MABackDistance;/*ȫ.ǵ£DZо·¶ȵȣƶȨǵİȫ*/ + UINT16 MaxTsrNum;/*һʱٵ*/ + UINT16 MaxSectionOfTsr;/*һʱٱа߼*/ + UINT32 IvocIvocCommunicationErrorTime;/*IVOC-IVOCŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 IvocOcCommunicationErrorTime;/*IVOC-OCͨŹжʱ(ms),add by yt202231գ䳵ϵͳ*/ + UINT32 TmcItsCommunicationErrorTime;/*TMC-ITSͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 TmcOcCommunicationErrorTime;/*TMC-OCͨŹжʱ(ms),add by yt202231գ䳵ϵͳ*/ + UINT32 ItsOcCommunicationErrorTime;/*ITS-OCͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 OcPsdCommunicationErrorTime;/*OC-PSDͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 IvocTslCommunicationErrorTime;/*IVOC-TSLͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 OcTslCommunicationErrorTime;/*OC-TSLͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT16 MALengthForATOParking; /*ATO׼ͣMA,add by yt202231գ䳵ϵͳ*/ + UINT8 LinkLogicDirUpAndDown; /*ϵͳ߼зĹϵ,add by yt202231գ䳵ϵͳ*/ + UINT16 OppositeTrackDistance; /*ʻ˫Сȫ루cm,add by yt202231գ䳵ϵͳ*/ + UINT16 StationTrackDistance; /*վ̨׷ʱг(cm),add by yt202231գ䳵ϵͳ*/ + UINT32 MaxMALength; /*·½ƶ루λm,add by yt202231գ䳵ϵͳ*/ + UINT32 VobcAtsCommunicationErrorTime;/*VOBCATSͨŹжʱ*/ + + /************************************************/ +} SystemParameterStruct; + +typedef struct S_Para +{ + UINT16 SysParaId; /**/ + UINT16 SysParaValue;/*ȡֵ*/ +}ParaStruct; + +/**/ +typedef struct S_OtherCiParaStruct +{ + UINT8 chOtherCiId; /*ID*/ + UINT8 chOtherCiType; /**/ + UINT8 chOtherCiDistributedIO; /*ֲʽ*/ + UINT32 wOtherCiUTProSecUnlockCyc; /*UTνͣʱ*/ + UINT32 wOtherCiCTProSecUnlockCyc; /*CTνͣʱ*/ + UINT32 wOtherCiUTNearUnLockCyc; /*ʽӽʱʱ*/ + UINT32 wOtherCiCTNearUnLockCyc; /*CBTCӽʱʱ*/ + UINT8 chOtherCiWaysidePattern; /*Լ̵ӿ*/ + UINT8 chOtherCiRcWorkMode; /*ģʽ*/ +}OtherCiParaStruct; + +/*ϵͳṹ*/ +typedef struct S_SystemParaStruct +{ + ParaStruct ParaStru[CI_SYSTEM_PARA_SUM_MAX]; + UINT8 CiType; /* 1Ϊ 4 Ϊ 5 ΪԳ */ + + UINT32 CiAndVobcTransmitBadEnsureTime ; + UINT32 CiAndZcTransmitBadEnsureTime ; + UINT32 CiAndCiTransmitBadEnsureTime ; + + UINT32 CiAndPsdTransmitBadEnsureTime ; + UINT32 dwVersionOfZCToCI ; + UINT32 dwVersionOfVOBCToCI ; + UINT32 CiAndPscTransmitBadEnsureTime ; + + /**********ϵͳ****************/ + UINT16 MaxLineLimitSpeed;/*·,˴ݿдŵUINT8km/hݣҪתcmpsλ*/ + UINT8 MaxTsrSpeed;/*ʱ*/ + UINT8 TimeZoneDifference;/*NTPУʱʱ.ʱ뱾ʱʱλʱӦʹʱӦ3600תΪ롣*/ + UINT16 MABackDistance;/*ȫ.ǵ£DZо·¶ȵȣƶȨǵİȫ*/ + UINT16 MaxTsrNum;/*һʱٵ*/ + UINT16 MaxSectionOfTsr;/*һʱٱа߼*/ + UINT32 IvocIvocCommunicationErrorTime;/*IVOC-IVOCŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 IvocOcCommunicationErrorTime;/*IVOC-OCͨŹжʱ(ms),add by yt202231գ䳵ϵͳ*/ + UINT32 TmcItsCommunicationErrorTime;/*TMC-ITSͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 TmcOcCommunicationErrorTime;/*TMC-OCͨŹжʱ(ms),add by yt202231գ䳵ϵͳ*/ + UINT32 ItsOcCommunicationErrorTime;/*ITS-OCͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 OcPsdCommunicationErrorTime;/*OC-PSDͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 IvocTslCommunicationErrorTime;/*IVOC-TSLͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 OcTslCommunicationErrorTime;/*OC-TSLͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT16 MALengthForATOParking; /*ATO׼ͣMA,add by yt202231գ䳵ϵͳ*/ + UINT8 LinkLogicDirUpAndDown; /*ϵͳ߼зĹϵ,add by yt202231գ䳵ϵͳ*/ + UINT16 OppositeTrackDistance; /*ʻ˫Сȫ루cm,add by yt202231գ䳵ϵͳ*/ + UINT16 StationTrackDistance; /*վ̨׷ʱг(cm),add by yt202231գ䳵ϵͳ*/ + UINT32 MaxMALength; /*·½ƶ루λm,add by yt202231գ䳵ϵͳ*/ + UINT32 VobcAtsCommunicationErrorTime;/*VOBCATSͨŹжʱ*/ + UINT32 dwLineMinTrainLength; /*ϵͳݣ·С*/ + UINT8 chZXDynamicTestSwitch; /*Ƿֶ֧̬ԣ55 رգAA aaر 55*/ + UINT8 chDynamicTestSwitch; /*Ƿֶ֧̬Կأ55 رգAA aaر 55*/ + UINT8 chWLSFunSwitch; /* Ƿ֧ȫɸܣ0x55 ֧ 0xAA֧ */ + UINT32 dwEaFrontDis; /*ɢǰ*/ + UINT32 dwEaBehindDis; /*ɢ*/ + UINT8 cAwakeCheckSpksSwitch; /*ѹмSPKS״̬أ0xaa飬0x55*/ + UINT32 dwVobcCiBackUpCommErrorTime; /*IVOC-RCVOBC-CIͨͨŹжʱ(ms)----䳵510Ŀ*/ + UINT16 VerSionBtwAxisAndCi; /*CIϵͳУЭ汾*/ + UINT8 dwHitSoftWallSwitch; /*ײǽܿ 55 aaر*/ + UINT8 dwOverlapLockType; /*շʽ 0x01 ATS 0x02 CI*/ + UINT8 dwCDOccuCheckFlag; /*ν·ռü 0x55 0xaa*/ + UINT8 chNoCGFollowUtSwitch; /*CվBUTǿ׷ٹܿ aa 55ر*/ + OtherCiParaStruct otherCICiParaStru[CI_SUM_MAX]; /**/ + /************************************************/ +}SystemParameterStructNew; + +/*ܿݽṹ*/ +typedef struct S_DQU_CiFuncSwitchStruct +{ + UINT8 wCiFuncSwitchBuf[CI_FUNCTION_SWITCH_SUM_MAX]; /*ܿ*/ +}DquCiFuncSwitchStruct; + +/*ܿݽṹ*/ +typedef struct S_DQU_CiFuncSwitchStructNew +{ + UINT16 wCiFuncSwitchId;/*ܿId*/ + UINT8 wCiFuncSwitchVal;/*ܿȡֵ*/ +}DquCiFuncSwitchStructNew; + +typedef struct S_CI_OC_Relation +{ + UINT16 CiId; + UINT16 OcIds[OC_SUM_MAX]; + UINT16 OcIdNum; +}CiOcRelateion; + + +/*******************************ȫֱ*******************************/ +extern UINT8 LocalCiId; /*ID*/ +extern SystemParameterStructNew SystemParameterStruNew;/*ϵͳ*/ +extern DquCiFuncSwitchStructNew CiFuncSwitConfStruNew[CI_FUNCTION_SWITCH_SUM_MAX];/*ܿؽṹ*/ +extern UINT32 StartUnlockCount; /*ϵ (ʼֶ)*/ +extern UINT32 RouteXuanPaiCount; /*·ѡų (ʼֶ)*/ +extern UINT32 RouteLockCount; /*·ճ (ʼֶ)*/ +extern UINT32 OverlapLockCount; /*ճ (ʼֶ)*/ +extern UINT32 RouteOpenSignalCount; /*·ųʱ(λ:s) (ֶ)*/ +extern UINT32 BlocRouteDelayCount; /*ʽ·ʱ (ʼֶ)*/ +extern UINT32 CbtcRouteDelayCount; /*CBTC·ʱ (ʼֶ)*/ +extern UINT32 LeadRouteFaultOpenCount; /*·ڷιźſų (ʼֶ)*/ +extern UINT32 SecDelayUnlockCount; /*ʱ (ʼֶ)*/ +extern UINT32 SignalOpenCount; /*źſų (ʼֶ)*/ +extern UINT32 SignalCloseCount; /*źŹرճ (ʼֶ)*/ +extern UINT32 SwitchMoveCount; /* (ʼֶ)*/ +extern UINT32 SwitchDriveCount; /* (ʼֶ)*/ +extern UINT32 ProtectSecUnlockCount; /*νͣ (ʼֶ)*/ +extern UINT32 OccupyToIdleCount; /*ռñмʱ (ʼֶ)*/ +extern UINT32 FaultUnlockCount; /*׹ʽʱ (ʼֶ)*/ +extern UINT32 SectionResetCount; /*Ḵλʱ (ʼֶ)*/ +extern UINT32 NonRouteXuanPaiCount; /*ǽ·ѡ (ʼֶ)*/ +extern UINT32 NonRouteDelayUnlockCount; /*ǽ·ʱ (ʼֶ)*/ +extern UINT32 SwitchDriveCuoFengCount; /*·ѡŵ (ʼֶ)*/ +extern UINT32 ZuheRouteXuanPaiCount; /*Ͻ·ѡ (ʼֶ)*/ +extern UINT32 CiAndZcTransmitBadEnsureCount; /*ZCͨжȷ(ʼֶ)*/ +extern UINT32 CiAndCiTransmitBadEnsureCount; /*ͨжȷ(ʼֶ)*/ +extern UINT32 CiAndVobcTransmitBadEnsureCount; /*Vobcͨжȷ(ʼֶ)*/ +extern UINT32 VobcAndCiBackUpCommBadCount; /*IvocVobcͨͨжȷ(ʼֶ)*/ +extern UINT32 CiAndPsdTransmitBadEnsureCount; /*PSDͨжȷ(ʼֶ)*/ +extern UINT32 TiocAndTmcTransmitBadEnsureCnt; /*TIOCTMCͨжȷ(ʼֶ)*/ +extern UINT32 WaitZCResponseCount; /*ȴZCʱ䣨رճţ(ʼֶ)*/ +extern UINT32 SecJumpLockDelayUnlockCount; /*ԾʱʼֶΣ*/ +extern UINT32 GaragedoorOperateCount; /*ŶʱʼֶΣ*/ +extern UINT32 CtProtectSecUnlockCount; /*ͨųռ÷νͣ (ʼֶ)*/ +extern UINT32 SingleSwitchMoveCount; /*쵥 (ʼֶ)*/ +extern UINT32 ThreeSwitchMoveCount; /* (ʼֶ)*/ +extern UINT32 FiveSwitchMoveCount; /*忪 (ʼֶ)*/ +extern UINT32 gapDetectTimeCount; /*϶̽ʱ䳬 (ʼֶ)*/ +extern UINT32 psdButtonPressTimeCount; /*վ̨ťʧЧʱ䳬 (ʼֶ)*/ +extern UINT32 DCTYWaitSignalOpenCount; /*ͬȴźſʱ(λ:s)*/ +extern UINT32 CiAndPscTransBadEnsureCount; /*Pscͨжȷʱ(λ:s)*/ +extern UINT32 ZFWJRelayDriveTimeCount; /*ܸλʱ(λ:s)*/ +extern UINT32 DHFRelayValidTimeCount; /*λDFH̵ʱ()*/ +extern UINT32 FirstOrderTimeCount; /*һЧʱ()*/ +extern UINT32 JXTCPulseContinueTimeCount; /*϶̽ʱ*/ +extern UINT32 labarUnlockOverlapTimeCount; /*˹ʱʱ*/ +extern UINT32 sigCollectRongrenCount; /*OCźŻȫʱ*/ +extern UINT32 AxleSectionUtRedundanceCount; /*UTռ*/ +extern UINT8 versionOfZCToCI; /*ZC-CIӿЭ汾ţadd by sds 2019-1-21*/ +extern UINT8 versionOfVOBCToCI; /*VOBC-CIӿЭ汾ţadd by sds 2019-1-21*/ +extern UINT8 versionOfTMCToTIOC; /*TMC-TIOCӿЭ汾*/ + +extern UINT16 wTsrMaxCmdSum; /* ǰʱ */ +extern UINT16 wTsrMaxSecSum; /* ǰʱ */ + +extern UINT32 CiAndAxleTransBadEnsureCnt; /*ϵͳͨжȷ(ʼֶ)*/ +extern UINT32 CiAndAxleTransBadEnsureTime; /*ϵͳͨжȷʱ(ʼֶ)*/ +extern UINT32 CiAndOcTransmitBadEnsureCount; /*Ocͨжȷ(ʼֶ)*/ +extern UINT32 CiAndOcTransmitBadEnsureTime; /*Ocͨжȷʱ(ʼֶ)*/ +extern UINT32 psdDrivCloseMaxTimeCount; /*Źرʱ*/ +extern UINT32 psdDrivOpenMaxTimeCount; /*Ŵʱ*/ +extern UINT32 SpksIndicDelayCount; /*SPKSťָʾƵʱʱ*/ +extern UINT32 mjjsOpenDelayCount; /*Žʱʱʱʱ*/ +extern UINT8 ciAndAxisPrtclCheckVer; /*֮Э汾*/ +extern UINT32 dwSelfButCollCount; /*ԸʽťӦ̵ɼʱ*/ +extern UINT32 dwSelfButErrCount; /*Ըʽ۳/ťжʱ*/ +extern UINT32 dwTrainRecycleCount; /*Դռʱ (ʼֶ)*/ +extern UINT32 dwSelfCancelButErrCount; /*Ըʽȡ۳/ťжʱ*/ +extern UINT32 dwRouteNearestTrainRenJieCount; /*·ӽгҪԽ·˽ʱʱȴʱ*/ +extern UINT32 dwSGBJRouteDelayOpenCount; /*ⱨ·ʱ*/ +extern UINT32 dwFloodGateDelayCloseCount; /*Žӽռӳٹ*/ +extern UINT32 dwSwitchBypassWaitCount; /*ߵδʱȡ·ȴ*/ +extern UINT32 dwSelfCancelButErrTriggerCount; /*Ըʽȡ۳/ť󴥷жʱ*/ +extern UINT16 wArbNearSecProtectDistance; /*ARB*/ +extern UINT32 dwArbNearSecNoUtCount; /*ARBʱ*/ +extern UINT32 dwNonReturnBtnErrEnsureTime; /*۷ťж*/ +extern UINT8 gCTFlyingRedunCount; +extern CiOcRelateion CiOcRelationArr[CI_SUM_MAX];/*ci ocϵ*/ + +/* +* ϵͳʱת +* ˵ void +* ֵ void +*/ +void SystemParaTimeToCycleCount(void); + +/* +* ʱת +* ˵ const UINT32 deviceTime, 豸ʱ +* const UINT32 appTime, Ӧʱ +* ֵ +*/ +UINT32 TimeToCycleCount(const UINT32 deviceTime, const UINT32 appTime); + +/* +* ȡں +* ˵ void +* ֵ UINT8 +*/ +UINT32 GetSystemParaAppCycleTime(void); + +/* +* ȡID +* ˵ void +* ֵ UINT8 +*/ +UINT8 GetSystemParaLocalCiId(void); + +/* +* ȡ +* ˵ void +* ֵ UINT8 +*/ +UINT8 GetSystemParaCiSum(void); + +/* +* ȡϵͳϵ +* ˵ void +* ֵ ϵ +*/ +UINT32 GetSystemParaStartUnlockCyc(void); + +/* +* ȡϵͳ·ѡų +* ˵ void +* ֵ ·ѡų +*/ +UINT32 GetSystemParaRouteXuanPaiCyc(void); + +/* +* ȡϵͳ·ճ +* ˵ void +* ֵ ·ѡų +*/ +UINT32 GetSystemParaRouteLockCyc(void); + +/* +* ȡϵͳճ +* ˵ void +* ֵ ·ѡų +*/ +UINT32 GetSystemParaOverlapLockCyc(void); + +/* +* ȡϵͳ·źų +* ˵ void +* ֵ ·ѡų +*/ +UINT32 GetSystemParaRouteOpenSigCyc(void); + +/* +* ȡϵͳʽ·ʱ +* ˵ void +* ֵ ʽ·ʱ +*/ +UINT32 GetSystemParaBlocRouteDelayCyc(void); + +/* +* ȡϵͳCBTC·ʱ +* ˵ void +* ֵ CBTC·ʱ +*/ +UINT32 GetSystemParaCbtcRouteDelayCyc(void); + +/* +* ȡԴȡʱ˽ʱʱ +* ˵ void +* ֵ Դȡʱ +*/ +UINT32 GetRouteResCancelApplyCyc(void); + +/* +* ȡ·ӽгҪ˽·ʱʱȴ +* ˵ void +* ֵ CBTC·ʱ +*/ +UINT32 GetRouteTrainRanJieDelayCyc(void); + +/* +* ȡϵͳ·ڷιźſų +* ˵ void +* ֵ ·ڷιźſų +*/ +UINT32 GetSystemParaLeadFaultOpenCyc(void); + +/* +* ȡϵͳʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaSecDelayUnlockCyc(void); + +/* +* ȡϵͳźſų +* ˵ void +* ֵ źſų +*/ +UINT32 GetSystemParaSignalOpenCyc(void); + +/* +* ȡϵͳźŹرճ +* ˵ void +* ֵ źŹرճ +*/ +UINT32 GetSystemParaSignalCloseCyc(void); + +/* +* ȡϵͳ +* ˵ void +* ֵ +*/ +UINT32 GetSystemParaSwitchMoveCyc(void); + +/* +* ȡϵͳ +* ˵ void +* ֵ +*/ +UINT32 GetSystemParaSwitchDriveCyc(void); + +/* +* ȡϵͳνͣ +* ˵ void +* ֵ νͣ +*/ +UINT32 GetSystemParaProtSecUnlockCyc(void); + +/* +* ȡCTռý·һµĽͣ +* ˵ void +* ֵ ͨųռ÷νͣ +*/ +UINT32 GetSystemParaCtProtSecUnlockCyc(void); + +/* +* ʱʱ +* ˵ UINT32 StartCount ʼʱ +* UINT32 MaxCount ʱ +* ֵ CI_TIME_NO δʱ +* CI_TIME_IN δʱ +* CI_TIME_OUT ʱ +*/ +UINT8 SystemOverTimeCheck(UINT32 StartCount, UINT32 MaxCount); + +/* +* ʱǷﵽ򳬹ֵ +* ˵ UINT32 StartCount ʼʱ +* UINT32 MaxCount ʱ +* ֵ CI_TIME_NO δʱ +* CI_TIME_IN δʱ +* CI_TIME_OUT ʱ +*/ +UINT8 SystemOverOrEqualTimeCheck(UINT32 StartCount, UINT32 MaxCount); + +/* +* ȡϵͳռñмʱ +* ˵ void +* ֵ ռñмʱ +*/ +UINT32 GetSystemParaOccuToIdleCyc(void); + +/* +* ȡϵͳ׹ʽʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaFaultUnlockCyc(void); + +/* +* ȡϵͳḴλʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaSectionResetCount(void); + +/* +* ȡϵͳǽ·ѡ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaNonRouteXuanPaiCnt(void); + +/* +* ȡϵͳǽ·ʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaNonRDelayUnlockCnt(void); + +/* +* ȡ·ѡŵ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaSwDrvCuoFengCnt(void); + +/* +* ȡϽ·ѡ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaZuheRXuanPaiCnt(void); + +/* +* ȡZCͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndZcTransBadEnsureCnt(void); + +/* +* ȡTIOCTMCͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetTiocAndTmcTransBadEnsureCnt(void); + +/* +* ȡͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndCiTransBadEnsureCnt(void); + +/* +* ȡVobcͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndVobcTransBadEnsureCnt(void); + +/* +* ȡPSDͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndPsdTransBadEnsureCnt(void); + +/* +* ȡ +* ˵ void +* ֵ +*/ +UINT8 GetLocalCiType(void); + +/* +* ȡȴZCʱ +* ˵ void +* ֵ ȴZCʱ +*/ +UINT32 GetWaitZCResponseCount(void); + +/* +* ȡϵͳԾʱ +* ˵ void +* ֵ Ծʱ +*/ +UINT32 GetSysParaSecJLokDelayUnlockCyc(void); + +/* +* ȡֵָܿ +* ˵ INT32 FunctionConfigIndex ָܿ + CLOSE_OPENED_SIG_LOCK_SWITCH رѿź + CLOSE_OPENED_SIG_LOCK_SIGNAL źŻرѿź + CHECK_SWITCH_LOCKING_BEFORE_LOCKING_SWITCH_CONF ʱ + CHECK_SWITCH_DANLOCK_FLOCKING_SWITCH_CONF ʱ + +* ֵ ֵָܿ0xAA0x550xFF +*/ +UINT8 GetCiFunctionSwitchConfig(UINT8 FunctionConfigIndex); + +/* +* ȡͨжȷʱ䵥λ +* ˵ + +* ֵ ͨжȷʱ䵥λ +*/ +UINT32 GetCiAndCiTransmitBadEnsureTime(void); +/* +* ȡVobcͨжȷʱ䵥λ +* ˵ + +* ֵ Vobcͨжȷʱ䵥λ +*/ +UINT32 GetCiAndVobcTransBadEnsureTime(void); + +/* +* ȡZCͨжȷʱ䵥λ +* ˵ + +* ֵ ZCͨжȷʱ䵥λ +*/ +UINT32 GetCiAndZcTransmitBadEnsureTime(void); + +/* +* ȡTIOCTMCͨжȷʱ䵥λ +* ˵ + +* ֵ TIOCTMCͨжȷʱ䵥λ +*/ +UINT32 GetTiocAndTmcTransBadEnsureTime(void); + +/* +* ȡϵͳŶʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSysParaGaragedoorOperateCnt(void); +/* +* ȡ϶̽ⳬ +* ˵ void +* ֵ ϶̽ⳬ +*/ +UINT32 GetGapDetectCount(void); + +/* +* ȡվ̨ťʧЧ +* ˵ void +* ֵ վ̨ťʧЧ +*/ +UINT32 GetPsdButtonPressCount(void); + +/* +* ȡܸλʧЧ +* ˵ void +* ֵ ܸλʧЧ +*/ +UINT32 GetZFWJRelayDriveTimeCount(void); + +/* +* λDFH̵ +* ˵ void +* ֵ DFH̵ +*/ +UINT32 GetDHFRelayValidTimeCount(void); + +/* +* ȡZC-CIӿЭ汾 +* ˵ void +* ֵ ZC-CIӿЭ汾 +*/ +UINT8 GetVersionOfZCToCI(void); + +/* +* ȡTMC-TIOCӿЭ汾 +* ˵ void +* ֵ TMC-TIOCӿЭ汾 +*/ +UINT8 GetVersionOfTMCToTIOC(void); + +/* +* ȡVOBC-CIӿЭ汾 +* ˵ void +* ֵ VOBC-CIӿЭ汾 +*/ +UINT8 GetVersionOfVOBCToCI(void); + +/* +* ȡPscͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndPscTransBadEnsureCnt(void); + +/* +* ȡͬȴźſ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSysParaDCTYWaitSigOpenCnt(void); + +/* +* ȡòֵ +* ˵ UINT16 paraID,ID +* ֵ UINT16ֵ +*/ +UINT16 GetSystemParaValue(UINT16 paraID); + +/* +* ȡϵͳͨжȷʱ䵥λ +* ˵ + +* ֵ ϵͳͨжȷʱ䵥λ +*/ +UINT32 GetCiAndAxleTransBadEnsureTime(void); + +/* +* ȡOCͨжȷʱ䵥λ +* ˵ + +* ֵ OCͨжȷʱ䵥λ +*/ +UINT32 GetCiAndOcTransmitBadEnsureTime(void); + +/* +* ȡOcͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndOcTransmitBadEnsureCnt(void); + + +/* +* ȡģʽ +* ˵void +* ֵģʽ +*/ +UINT8 GetLocalCiPattern(void); + +/* +* ñģʽ +* ˵CIģʽ +* ֵǷóɹ +*/ +UINT8 SetLocalCiPattern(UINT8 localCiPattern); + +/* +* ñUTʱͣʱ +* ˵ʱͣʱ +* ֵvoid +*/ +void SetLocalCiUTProtSecUnlockTime(UINT16 localUTProtectSecUnlockTime); + +/* +* ñCTʱͣʱ +* ˵ʱͣʱ +* ֵvoid +*/ +void SetLocalCiCTProtSecUnlockTime(UINT16 localCTProtectSecUnlockTime); + +/********/ +/* +* ñUTӽʱʱ +* ˵ʱͣʱ +* ֵvoid +*/ +void SetLocalCiUTNearUnLockTime(UINT16 localUTNearUnLockTime); + +/* +* ñCTӽʱʱ +* ˵ʱͣʱ +* ֵvoid +*/ +void SetLocalCiCTNearUnLockTime(UINT16 localCTNearUnLockTime); + +/* +* ñʽ/ֲʽIO +* ˵CI IOɷʽ +* ֵǷóɹ +*/ +UINT8 SetLocalCiDistributedIO(UINT8 distributedIO); + +/* +* ȡIO豸ɷʽ +* ˵CI IOɷʽ +* ֵIOɷʽ +*/ +UINT8 GetLocalCiDistributedIO(void); + + +/* +* һЧ +* ˵ void +* ֵ һЧ +*/ +UINT32 GetFirstOrderTimeCount(void); + +/* +* ȡ϶̽ +* ˵ void +* ֵ ϶̽ +*/ +UINT32 GetJXTCPulseContinueTimeCount(void); + +/* +* ȡηͨųռѹ +* ˵ void +* ֵ UINT32 +* qw.liu 2022-02-22 +*/ +UINT32 GetSysParaAxleUtRedunCount(void); + +/* +* ȡźŻγ᳤ +* ˵ void +* ֵ UINT32 +* qw.liu 2022-02-22 +*/ +UINT16 GetSigLightUpBigAxleSecLen(void); + +/* +* ȡźŻӳ᳤ +* ˵ void +* ֵ UINT32 +* qw.liu 2022-02-22 +*/ +UINT16 GetSigLightUpExAxleSecLen(void); + +/* +* ȡѹźŻ +* ˵ void +* ֵ UINT32 +* qw.liu 2022-03-03 +*/ +UINT16 GetSigCrossMaxLen(void); + +/* +* ȡз +* ˵ void +* ֵ UINT32 +* qw.liu 2022-03-03 +*/ +UINT16 GetBackProtectMaxLen(void); + +/* +* ȡ·С +* ˵ void +* ֵ UINT32 +* 2022-03-12 +*/ +UINT32 GetShortestTrainLen(void); + +/* +* ȡȫɸ +* ˵UINT8 +* ֵȫɸ +*/ +UINT8 GetWLSFunSwitch(void); + +/* +* ȡTIOCݰ汾Ŵŵַ +* ˵ void +* ֵ NULL ʧ +* ɹ +* 2022-03-12 +*/ +UINT16* GetTiocFsVersion(void); + +/* +* TIOCݰ汾Ŵŵַ +* ˵ UINT8* pSrcFsVersion ӵͼ汾Ŵŵַ +* 2022-03-12 +*/ +void SetTiocFsVersion(UINT8* pSrcFsVersion); + +/* +* УTIOCݽṹ汾 +* ˵ UINT8* pSrcFsVersion ݽṹ汾Ŵŵַ +* ֵCI_SUCCESS CI_ERROR +* 20240605 LC +*/ +UINT8 CheckTiocPublicFsVersion(UINT8* pSrcFsVersion); + + +/* +* УTIOC˽ݽṹ汾 +* ˵ UINT8* pSrcFsVersion ˽ݽṹ汾Ŵŵַ +* ֵCI_SUCCESS CI_ERROR +* 20240605 LC +*/ +UINT8 CheckTiocPrivateFsVersion(UINT8* pSrcFsVersion); + +/* +* УOCݽṹ汾 +* ˵ UINT8* pSrcFsVersion ˽ݽṹ汾Ŵŵַ +* ֵCI_SUCCESS CI_ERROR +* 20250210 fan +*/ +UINT8 CheckTiocOcFsVersion(UINT8* pSrcFsVersion); + +/********************************************* +*ܣȡ̬ +*˵UINT32* pConfigDataAdderBuf ̬ݴŵַ,UINT16 pConfigDataLenBuf ̬ݳȴŵַ,UINT16 wBufMaxLen +*ֵ̬ +*********************************************/ +UINT16 GetTiocSystemParameterData(UINT32* pConfigDataAdderBuf, UINT16* pConfigDataLenBuf, UINT16 wBufMaxLen); + +/* +* ȡɳ崻 +* ˵ void +* ֵ ɳ崻 +*/ +UINT8 GetCTFlyingRedunCount(void); + +/* +* ȡʱ +* ˵ void +* ֵ ʱ +*/ +extern UINT16 GetTsrMaxCmdSum(void); + +/* +* ȡʱٵ +* ˵ void +* ֵ ʱٵ +*/ +extern UINT16 GetTsrMaxSecSum(void); + +/* +* ȡϵͳ߼зĹϵ +* ˵ void +* ֵ ϵͳ߼зĹϵ +*/ +UINT8 GetLinkLogicDirUpAndDown(void); + +/* +* ȡTIOC̬Կ +* ˵void +* ֵ߶̬Կ +*/ +UINT8 GetZXDynamicTestSwitch(void); + +/* +* ȡTIOC̬Կ +* ˵void +* ֵTIOC̬Կ +*/ +UINT8 GetDynamicTestSwitch(void); + +/* +* ȡɢǰ +* ˵void +* ֵɢǰ +*/ +UINT32 GetEaFrontDis(void); + +/* +* ȡɢ +* ˵void +* ֵɢ +*/ +UINT32 GetEaBehindDis(void); + +/* +* ȡϵͳͨжȷ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetCiAndAxleTransBadEnsureCnt(void); + + +/* +* RCģʽ +* ˵UINT8 localRcWorkMode RCģʽ +* ֵ1uɹ 0uʧ +*/ +extern UINT8 SetLocalRcWorkMode(UINT8 localRcWorkMode); + +/* +* ȡRCģʽ +* ˵ +* ֵRCģʽ +*/ +extern UINT8 GetLocalRcWorkMode(void); +/* +* ȡ˹ʱ +* ˵ void +* ֵ ˹ʱ +*/ +UINT32 GetlabarUnlockOverlapTimeCount(void); + +/* +* ȡŹرճʱ +* ˵ void +* ֵ Źرճʱ +*/ +UINT32 GetPsdDrivCloseMaxCount(void); +/* +* ȡŴ򿪳ʱ +* ˵ void +* ֵ Ŵ򿪳ʱ +*/ +UINT32 GetPsdDrivOpenMaxCount(void); +/* +* ֮ɼȫʱ +* ˵ void +* ֵ ֮ɼȫʱ +*/ +UINT32 GetSigCollectRongernCount(void); +/* +* SPKSťָʾƵʱ +* ˵ void +* ֵ SPKSťָʾƵʱ +*/ +UINT32 GetSpksIndicDelayCount(void); +/* +* ȡЭ汾 +* ˵ void +* ֵ Э汾 +* cgh-ϲCID-3037-13 +*/ +UINT8 GetCiAndAxisPrtclCheckVer(void); +/* +* ñԼ̵ӿ +* ˵Լ̵ӿ +* ֵ +*/ +void SetLocalWaysidePattern(UINT8 localWaysidePattern); + +/* +* ȡԼ̵ӿ +* ˵void +* ֵԼ̵ӿ +*/ +UINT8 GetLocalWaysidePattern(void); + +/* +* Žʱ +* ˵ void +* ֵ SPKSťָʾƵʱ +*/ +UINT32 GetMjjsOpenDelayCount(void); + +/* +* ȡԸʽťӦ̵ɼʱ +* ˵ void +* ֵ ԸʽťӦ̵ɼʱ +*/ +UINT32 GetSelfButCollCount(void); + +/* +* ȡԸʽ۳/ťжʱ +* ˵ void +* ֵ Ըʽťжʱ +*/ +UINT32 GetSelfButErrCount(void); + +/* +* Դճʱ +* ˵ void +* ֵ ʱ +*/ +UINT32 GetSystemParaTrainReCycleCount(void); + +/* +* ȡԸʽȡ۳/ťжʱ +* ˵ void +* ֵ Ըʽťжʱ +*/ +UINT32 GetSelfCancelButErrCount(void); + +/* +* ȡⱨ·ʱʱ +* ˵ void +* ֵ ⱨ·ʱʱ +*/ +UINT32 GetSGBJRouteDelayOpenCount(void); + +/* +* ȡѹ̼SPKS״̬ +* ˵ +* ֵѹ̼SPKS״̬ +*/ +UINT8 GetAwakeCheckSpksSwitch(void); + +/* +* ȡIVOCVOBCRCͨͨŹжʱ(ms) +* ˵ +* ֵIVOCRCͨͨŹжʱ +*/ +UINT32 GetVobcCiBackUpCommErrorTime(void); + +/* +* ȡIVOCVOBCRCͨͨŹж +* ˵ void +* ֵ ʱ +*/ +UINT32 GetVobcCiBackUpCommErrorCount(void); + +/* +* ȡŽӽռӳٹʱ +* ˵ void +* ֵ Žӽռӳٹʱ +*/ +UINT32 GetFloodGateDelayCloseCount(void); + +/* +* ȡ·ߵδʱȡ·ȴʱ +* ˵ void +* ֵ ·ߵδʱȡ·ȴʱ +*/ +UINT32 GetSwitchBypassWaitCount(void); + +/* +* ȡײǽܿ +* ˵ +* ֵ0x55 ش +* 0xaa عر +*/ +UINT8 GetHitSoftWallSwitch(void); + +/* +* ȡշʽ +* ˵ +* ֵ0x01 ATS +* 0x02 CI +*/ +UINT8 GetOverlapLockTypeSwitch(void); + +/* +* ȡUDP־ʱְС(byte) +* ˵ void +* ֵ UINT16 ְС +* 20240214 LC +*/ +UINT16 GetLogSubPackDataLength(void); + +/* +* ȡԸʽȡ۳/ť󴥷жʱ +* ˵ void +* ֵ Ըʽȡ۳/ť󴥷жʱ +*/ +UINT32 GetSelfCancelButErrTriggerCount(void); + +/* +* ò +* ˵UINT8* pDataAddr ݵַ +* ֵCI_SUCCESS ɹ CI_ERROR ʧ +* by cgh 20240605 +*/ +UINT8 SetOtherCiPara(UINT8* pDataAddr); + +/* +* ȡò +* ˵const UINT8 chOtherCiId ID +* ֵCI_SUCCESS ɹ CI_ERROR ʧ +* by cgh 20240605 +*/ +OtherCiParaStruct GetOtherCiPara(const UINT8 chOtherCiId); + +/* +* ȡCվBUTǿ׷ٹܿ +* ˵ +* ֵaaر 55 +* by cgh 20240815 +*/ +UINT8 GetNoCGFollowUtSwitch(void); + +/* +* ȡARBμ鳤(m) +* ˵ void +* ֵ UINT16 wArbCheckMaxLen 鳤 +* by fan 20240820 +*/ +UINT16 GetArbCheckAxisLen(void); + +/* +* ȡARBη +* ˵ void +* ֵ UINT32 +* by fan 20240822 +*/ +UINT32 GetArbProtectCheckTime(void); + +/* +* ȡ۷ťж +* ˵ void +* ֵ ۷ťж +* by cgh 20240905 +*/ +UINT32 GetdwNonReturnBtnErrEnsureCount(void); + +/* +* ñOC汾 +* ˵OC汾 +* ֵɹ CI_SUCCESS ʧCI_ERROR +* Create: fan 20250210 +*/ +UINT8 SetLocalOcPattern(UINT8 localOcPattern); + +/* +* ȡOC汾 +* ˵OC汾 +* ֵ0x55 °汾 0xaa Ͼɰ汾 +* Create: fan 20250210 +*/ +UINT8 GetLocalOcPattern(); + +/* +* ܣRC +* ˵UINT8 cLinkLineAttr RC +* ֵ1 ɹ +* 0 ʧ +*/ +UINT8 SetLocalRcLinkLineAttr(UINT8 cLinkLineAttr); + +/* +* ܣȡRC +* ˵ +* ֵRC +*/ +UINT8 GetLocalRcLinkLineAttr(void); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/APP/ciapp/Train/EvacuationAreaManage.c b/TSCP/src/APP/ciapp/Train/EvacuationAreaManage.c new file mode 100644 index 0000000..fc79fc2 --- /dev/null +++ b/TSCP/src/APP/ciapp/Train/EvacuationAreaManage.c @@ -0,0 +1,3815 @@ +#include "EvacuationAreaManage.h" +#include "LinkConfigDataManage.h" +#include "AxisConfigDataManage.h" +#include "AxisSectionConfigDataManage.h" +#include "LogicSectionConfigDataManage.h" +#include "TrainDataManage.h" +#include "ParsePackGateWayData.h" +#include "dquCIInterFace.h" +#include "ELMDataPrepare.h" + +EaConfigStru g_szEaConfig[EA_CFG_SUM_MAX] = { 0u }; /* */ +UINT16 g_eaConfigNum = 0u; +AxisSectionConfigDataStruct g_szEaAcConfig[AXIS_SECTION_SUM_MAX] = { 0u }; /* ȫ߼ */ +UINT16 g_eaAcConfigNum = 0u; +static EaDataStru g_szEaData[EA_MAX_NUM] = { 0u }; /* ɢ */ +static UINT8 g_eaNum = 0u; /* ڽѽɢ */ + +/** +* @brief ͨгɢ +* @param +* @return +*/ +static void EaCmdProc(void); + +/** +* @brief ɢ +* @param chIndex +* @return CI_ERRORʧܣCI_SUCCESSɹ +*/ +static UINT8 EvacuationAreaCalcu(UINT8 chEaIndex, const UINT8 chType); + +/** +* @brief ȡͨųijһɢгǷͬ⽨ +* @param wEaTrainId ɢгID +* @return CI_ERROR ͬ CI_SUCCESS ͬ +*/ +static UINT8 GetAllCtTrainAgreeSetEva(UINT16 wEaTrainId); + +/** +* @brief ɢгߡɢԵ +* @param wTrainId ɢгID +* @param pMidLine ɢг߹ +* @param pMinEdge ɢС +* @param pMaxEdge ɢ +* @return CI_ERROR ʧ CI_SUCCESS ɹ +*/ +static UINT8 EaGetMidLineAndEdgeKm(const UINT8 chType, const UINT16 wTrainId, UINT8 * pEaOut, UINT32 * pMidLine, UINT32 * pMinEdge, UINT32 * pMaxEdge, UINT8* pEaconfigId); + +/** +* @brief ѯվһ䲻վ̨ķڵվ̨ +* @param const UINT16 eaConfigIndex +* @param const UINT32 wOrgnPointKmtemp С˹ +* @param const UINT32 wTmnlPointKmtemp ˹ +* @param UINT32* pMinEdge С +* @param UINT32* pMaxEdge +* @return CI_ERROR ʧ CI_SUCCESSɹ +* By LC 20231113 +**/ +UINT8 EaGetadjacentStationKM(const UINT16 eaConfigIndex, const UINT32 wOrgnPointKmtemp, const UINT32 wTmnlPointKmtemp, UINT32* pMinEdge, UINT32* pMaxEdge); + +/** +* @brief ȡ +* @param const UINT16 wAcId α +* @return AXIS_SECTION_SUM_MAX:ʧ +*/ +static UINT16 EaGetAcIndex(const UINT16 wAcId); + +/** +* @brief ȡΰlink +* @param const UINT16 wAcId α +* @return ΰlinkAXIS_INCLUDE_LINK_SUM_MAX:ʧ +*/ +static UINT8 EaGetAcLinkNum(const UINT16 wAcId); + +/** +* @brief ȡΰ +* @param const UINT16 wAcId α +* @return ΰlinkAXIS_INCLUDE_LINK_SUM_MAX:ʧ +*/ +static UINT16 EaGetAcOrgnAxisId(const UINT16 wAcId); + +/** +* @brief ȡΰյ +* @param const UINT16 wAcId α +* @return ΰlinkAXIS_INCLUDE_LINK_SUM_MAX:ʧ +*/ +static UINT16 EaGetAcTmnlAxisId(const UINT16 wAcId); + +/** +* @brief ȡΰlink +* @param const UINT16 wAcId α +* @return ΰlinkţNULL:ʧ +*/ +static UINT16 * EaGetAcLinkId(const UINT16 wAcId); + +/** +* @brief ȡΰ߼ +* @param const UINT16 wAcId α +* @return ΰ߼AXIS_INCLUDE_LOG_SUM_MAX:ʧ +*/ +static UINT8 EaGetAcLgcNum(const UINT16 wAcId); + +/** +* @brief ȡΰ߼α +* @param const UINT16 wAcId α +* @return ΰ߼αţNULL:ʧ +*/ +static UINT16 * EaGetAcLgcId(const UINT16 wAcId); + +/** +* @brief ɢȡ +* @param +* @return +*/ +static void EaAtsCancleProc(void); + +/** +* @brief ɢ״ȡ +* @param +* @return +*/ +static void EaAtsCancleFst(void); + +/** +* @brief ɢȡ +* @param +* @return +*/ + static void EaAtsCancleSnd(void); + +/** +* @brief ɢȡִ +* @param +* @return +*/ +static void EaAtsCancleExc(const UINT8 chEaIndex); + +/** +* @brief ȡָɢ +* @param const UINT8 chEaIndex ID +* @return +* by cgh 20240321 +*/ +static void EaCancleExc(const UINT8 chEaIndex); + +/* +* жξΪ +* ˵ chEaIndex ɢ +* ֵ CI_SUCCESS:ȫڱCI_ERROR:ȫڱ +*/ +static UINT8 EaIsLinkSeqAllLocal(UINT8 chEaIndex); + +/** +* @brief ȡг洢 +* @param const UINT16 wTrainId +* @param const UINT8 chType +* @return ɹ:ʧ:g_eaNum +*/ +static UINT8 PaGetIndex(const UINT16 wTrainId, const UINT8 chType); + +/** +* @brief ʼ +* @param +* @return CI_ERROR ʼʧ CI_SUCCESS ʼɹ +* by cgh 20250310 +*/ +UINT8 EaConfigInit(void) +{ + UINT16 wIndex = 0u; + UINT16 wEaMode = 0u; + UINT8 chRtn = CI_ERROR; + UINT8 chPointIndex = 0u; + UINT8 chStationFlag = CI_ERROR; + UINT16 wPlatformEaMode = 0u; + LOD_STRU pLODAStru = { 0U };/*λ*/ + LOD_STRU pLODBStru = { 0U };/*յλ*/ + UINT16 wTempLinkSum = 0U;/*LINKĿ*/ + UINT16 szTempLinkId[EA_SECTION_MAX_NUM] = { 0U };/*Link*/ + UINT8 chTempLinkIndex = 0U;/*ʱLINK*/ + UINT8 chEndLinkIdIndex = 0U;/*յLINK ID*/ + UINT8 chEaConfigLinkIndex = 0U;/*LINK*/ + UINT16 wAdjacentLinkId = 0U;/*LINK ID*/ + + /* ȡɢʽ */ + wEaMode = GetSystemParaValue(EA_MODE_ID); + wPlatformEaMode = GetSystemParaValue(EA_STATION_MODE_ID); + + if ((EA_MODE_PLATION != wEaMode) && (EA_MODE_SEC != wEaMode) && (EA_MODE_DIS != wEaMode)) + { + ; /* 㷽ʽΪվһ߰ʱTIOCʼʧ */ + } + else if ((EA_MODE_DIS == wEaMode) && (EA_STATION_MODE_DIS != wPlatformEaMode)) + { + ; /* ɢ뷽ʽ㣬վ̨ɢΪʱTIOCʼʧ */ + } + else if ((EA_STATION_MODE_DIS != wPlatformEaMode) && (EA_STATION_MODE_PLAT != wPlatformEaMode)) + { + ; /* վ̨ɢʽΪ߽վ̨TIOCʼʧ */ + } + else + { + chRtn = CI_SUCCESS; + } + + if (CI_SUCCESS == chRtn) + { + for (wIndex = 0U; wIndex < g_eaConfigNum; wIndex++) + { + if ((EA_MODE_PLATION == wEaMode) || (EA_MODE_SEC == wEaMode)) + { + /* վһ LINK*/ + for (chPointIndex = 0U; chPointIndex < g_szEaConfig[wIndex].chStartLinkNum; chPointIndex++) + { + for (chEndLinkIdIndex = 0U; chEndLinkIdIndex < g_szEaConfig[wIndex].chEndLinkNum; chEndLinkIdIndex++) + { + pLODAStru.Lnk = g_szEaConfig[wIndex].szStartLinkId[chPointIndex]; + pLODAStru.Off = 0U; + pLODAStru.Dir = g_szEaConfig[wIndex].szStartLinkDir[chPointIndex]; + + pLODBStru.Lnk = g_szEaConfig[wIndex].szEndLinkId[chEndLinkIdIndex]; + pLODBStru.Off = 0U; + pLODBStru.Dir = g_szEaConfig[wIndex].szEndLinkDir[chEndLinkIdIndex]; + + /* 㣬ҳ㵽յ·*/ + chRtn = TwoPointPathSearch(&pLODAStru, &pLODBStru, &wTempLinkSum, szTempLinkId); + + + if (CI_ERROR == chRtn) + { + break; + } + else + { + for (chTempLinkIndex = 0U; chTempLinkIndex < (UINT8)wTempLinkSum; chTempLinkIndex++) + { + /*ȥأѾڵLINKټ洢*/ + for (chEaConfigLinkIndex = 0U; chEaConfigLinkIndex < g_szEaConfig[wIndex].chEaConfigLinkSum; chEaConfigLinkIndex++) + { + if (szTempLinkId[chTempLinkIndex] == g_szEaConfig[wIndex].wSzEaConfigLinkId[chEaConfigLinkIndex]) + { + /*ѾڸLINK*/ + break; + } + else + { + ; /**/ + } + } + + if (chEaConfigLinkIndex == g_szEaConfig[wIndex].chEaConfigLinkSum) + { + if (EA_SECTION_MAX_NUM > g_szEaConfig[wIndex].chEaConfigLinkSum) + { + /*ڣµLINK*/ + g_szEaConfig[wIndex].wSzEaConfigLinkId[g_szEaConfig[wIndex].chEaConfigLinkSum] = szTempLinkId[chTempLinkIndex]; + g_szEaConfig[wIndex].chEaConfigLinkSum++; + } + else + { + /**/ + chRtn = CI_ERROR; + debug_infor_printf((const)" g_szEaConfig chEaConfigLinkSum more than Max.\r\n"); + break; + } + + } + else + { + ;/**/ + } + } + } + } + if (CI_ERROR == chRtn) + { + break; + } + else + { + ; + } + } + if (CI_ERROR == chRtn) + { + ; + } + else + { + if (0U == g_szEaConfig[wIndex].chEaConfigLinkSum) + { + debug_infor_printf((const)"wIndex:%d EaConfigInit chEaConfigLinkSum is zero\n", wIndex); + chRtn = CI_ERROR; + } + else + { + /*յվ̨ID*/ + for (chPointIndex = 0U; chPointIndex < g_szEaConfig[wIndex].chStartLinkNum; chPointIndex++) + { + if (DIR_SAME == g_szEaConfig[wIndex].szStartLinkDir[chPointIndex]) + { + /*߼ͬȡLINK*/ + wAdjacentLinkId = GetLinkOrgnJointMainLkIdById(g_szEaConfig[wIndex].szStartLinkId[chPointIndex]); + } + else if (DIR_CONVERT == g_szEaConfig[wIndex].szStartLinkDir[chPointIndex]) + { + /*߼෴ȡյLINK*/ + wAdjacentLinkId = GetLinkTmnlJointMainLkById(g_szEaConfig[wIndex].szStartLinkId[chPointIndex]); + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + chStationFlag = IsLinkPlatform(wAdjacentLinkId); + if (CI_SUCCESS == chStationFlag) + { + /*ڣµLINK*/ + g_szEaConfig[wIndex].wSzStartStationLinkId[g_szEaConfig[wIndex].chStartStationLinkSum] = wAdjacentLinkId; + g_szEaConfig[wIndex].chStartStationLinkSum++; + } + else + { + ; + } + } + else + { + debug_infor_printf((const)"EaConfigInit CalcStationStartLink fail.\r\n"); + break; + } + } + + if (CI_SUCCESS == chRtn) + { + for (chPointIndex = 0U; chPointIndex < g_szEaConfig[wIndex].chEndLinkNum; chPointIndex++) + { + if (DIR_SAME == g_szEaConfig[wIndex].szEndLinkDir[chPointIndex]) + { + /*յѯ߼ͬȡLINK*/ + wAdjacentLinkId = GetLinkOrgnJointMainLkIdById(g_szEaConfig[wIndex].szEndLinkId[chPointIndex]); + } + else if (DIR_CONVERT == g_szEaConfig[wIndex].szEndLinkDir[chPointIndex]) + { + /*߼෴ȡյLINK*/ + wAdjacentLinkId = GetLinkTmnlJointMainLkById(g_szEaConfig[wIndex].szEndLinkId[chPointIndex]); + } + else + { + chRtn = CI_ERROR; + } + + if (CI_SUCCESS == chRtn) + { + chStationFlag = IsLinkPlatform(wAdjacentLinkId); + if (CI_SUCCESS == chStationFlag) + { + g_szEaConfig[wIndex].wSzEndStationLinkId[g_szEaConfig[wIndex].chEndStationLinkSum] = wAdjacentLinkId; + g_szEaConfig[wIndex].chEndStationLinkSum++; + } + else + { + ; + } + } + else + { + debug_infor_printf((const)"REaConfigInit CalcStationEndLink fail.\r\n"); + break; + } + } + } + else + { + ; /*վ̨ʧ*/ + } + } + } + + if (CI_SUCCESS == chRtn) + { + debug_infor_printf((const)"wIndex:%d chEaConfigLinkSum = %d\n", wIndex, g_szEaConfig[wIndex].chEaConfigLinkSum); + for (chPointIndex = 0U; chPointIndex < g_szEaConfig[wIndex].chEaConfigLinkSum; chPointIndex++) + { + debug_infor_printf((const)"%d/",g_szEaConfig[wIndex].wSzEaConfigLinkId[chPointIndex]); + } + debug_infor_printf((const)"\nwIndex:%x chStartStationLinkSum = %d\n", wIndex, g_szEaConfig[wIndex].chStartStationLinkSum); + for (chPointIndex = 0U; chPointIndex < g_szEaConfig[wIndex].chStartStationLinkSum; chPointIndex++) + { + debug_infor_printf((const)"%d/", g_szEaConfig[wIndex].wSzStartStationLinkId[chPointIndex]); + } + + debug_infor_printf((const)"\nwIndex:%x chEndStationLinkSum = %d\n", wIndex, g_szEaConfig[wIndex].chEndStationLinkSum); + for (chPointIndex = 0U; chPointIndex < g_szEaConfig[wIndex].chEndStationLinkSum; chPointIndex++) + { + debug_infor_printf((const)"%d/",g_szEaConfig[wIndex].wSzEndStationLinkId[chPointIndex]); + } + debug_infor_printf((const)"\n"); + } + else + { + break; + } + + } + else + { + ; /*վһ䲻*/ + } + } + } + else + { + ; /* ʼʧ */ + } + return chRtn; +} + +/** +* @brief ɢ +* @return +*/ +void EvacuationAreaProcess(void) +{ + UINT8 index = 0u; + UINT16 wTrainId = 0u; + UINT8 chBuildedFlag = 0u; + UINT8 chEaCmd = 0u; + UINT8 chTrainAgreeFlag = CI_ERROR; + UINT8 chEaNum = 0u; + UINT8 chLocalId = GetSystemParaLocalCiId(); + UINT8 chSwitch = GetCiFunctionSwitchConfig(FUNC_EA_SWITCH); + UINT8 chDaSwitch = GetCiFunctionSwitchConfig(FUNC_DA_SWITCH); + UINT8 chPaType = 0u; + + chEaNum = GetEaNum(); + if (EA_MAX_NUM >= chEaNum) + { + for (index = 0u; index < chEaNum; index++) + { + wTrainId = GetEvacuatingTrainIdByIndex(index); + chPaType = GetPaTypeByIndex(index); + if (PA_TYPE_EA == chPaType) + {/* ɢҪгͬ */ + if ((0u != wTrainId) && (g_szEaData[index].chSrcTiocId == chLocalId)) + {/* ΪԴ */ + chBuildedFlag = GetEaBuildedFlag(index); + if (EA_IS_BUILDED == chBuildedFlag) + { + /* ɢѽ */ + ; + } + else if (EA_IS_NOT_BUILDED == chBuildedFlag) + { + /* ɢδ + 1ȴͨųظͬ⽨*/ + chTrainAgreeFlag = GetAllCtTrainAgreeSetEva(wTrainId); + if (0u != g_szEaData[index].chDstTiocId) + { + if ((CI_SUCCESS == chTrainAgreeFlag) && (EA_DST_ALLOWED_YES == g_szEaData[index].chDstAllowed)) + { + g_szEaData[index].chBuildedFlag = EA_IS_BUILDED; + } + else + { + ; + } + } + else + { + if (CI_SUCCESS == chTrainAgreeFlag) + { + g_szEaData[index].chBuildedFlag = EA_IS_BUILDED; + } + else + { + ; + } + } + } + else + { + /* Ƿ״̬ */ + ; + } + } + else if ((0u != wTrainId) && (g_szEaData[index].chDstTiocId == chLocalId)) + {/* ΪĿ */ + chTrainAgreeFlag = GetAllCtTrainAgreeSetEva(wTrainId); + if (CI_SUCCESS == chTrainAgreeFlag) + { + g_szEaData[index].chDstAllowed = EA_DST_ALLOWED_YES; + } + else + { + g_szEaData[index].chDstAllowed = EA_DST_ALLOWED_NO; + } + } + else + { + /*Ƿ*/ + ; + } + } + else + { + ; + } + } + /*ͨų*/ + EaCmdProc(); + + if (FUNC_SWITCH_ON == chSwitch) + { + /* ATSȡ */ + EaAtsCancleProc(); + } + else + { + ; + } + + if (FUNC_SWITCH_ON == chDaSwitch) + { + /* ATSȡѹȥ */ + DaAtsCancleProc(); + } + else + { + ; + } + } + else + { + ; + } +} +/** +* @brief ͨгɢ +* @param +* @return +*/ +static void EaCmdProc(void) +{ + UINT8 i = 0u; + UINT8 j = 0u; + UINT8 chTrainEaCmd = 0u; + UINT16 wTrainId = 0u; + UINT16 wEvaId = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT32 chTempRtn = CI_ERROR; + UINT8 chTransState = 0u; + UINT8 chZeroSpd = 0u; + UINT8 chTiocType = 0u; + UINT8 chLocalId = 0u; + UINT8 chEaSwitch = GetCiFunctionSwitchConfig(FUNC_EA_SWITCH); + UINT8 chDaSwitch = GetCiFunctionSwitchConfig(FUNC_DA_SWITCH); + UINT8 chDerailment = 0u; + UINT16 wLinkId = 0u; + UINT16 wLinkTioc = 0u; + + chTiocType = GetLocalCiType(); /* ȡTIOC */ + chLocalId = GetSystemParaLocalCiId(); + + if ((CI_TYPE_ZX == chTiocType) || (CI_TYPE_SCX == chTiocType)) + { + for (i = 0u; i < TRAIN_SUM_MAX; i++)/*г*/ + {/* гɢ */ + wTrainId = GetTrainId(i); + chTransState = GetTrainTransitmitStat(wTrainId); + chTrainEaCmd = GetTrainEaCmd(wTrainId); + chZeroSpd = GetTrainZeroState(wTrainId); + + if (((TRAIN_COMM_STATE_GOOD == chTransState) && (EA_PROTECT_BUILD == chTrainEaCmd) && (TRAIN_SPEED_ZERO_YES == chZeroSpd) && (FUNC_SWITCH_ON == chEaSwitch))) + { + for (j = 0u; j < g_eaNum; j++)/*ɢ*/ + { + /*жͨųǷѾ*/ + if ((wTrainId == g_szEaData[j].wTrainId) && (PA_TYPE_EA == g_szEaData[j].chPaType)) + { + SetTrainEaCmd(wTrainId, EA_PROTECT_DEFAULT); + break; + } + } + + if (g_eaNum == j) + { + if (EA_MAX_NUM > g_eaNum) + { + SetTrainEaCmd(wTrainId, EA_PROTECT_DEFAULT); + g_szEaData[g_eaNum].wTrainId = wTrainId; + g_szEaData[g_eaNum].chBuildedFlag = EA_IS_NOT_BUILDED; + g_szEaData[g_eaNum].chSrcTiocId = chLocalId; + g_szEaData[g_eaNum].chDstTiocId = 0u; + g_szEaData[g_eaNum].chDstAllowed = EA_DST_ALLOWED_NO; + g_szEaData[g_eaNum].chPaType = PA_TYPE_EA; + g_szEaData[g_eaNum].dwEaBuildCycNum = Get2oo2CurCycleNum(); + /*ӼLinkI*/ + chFunRtn = EvacuationAreaCalcu(g_eaNum, PA_TYPE_EA); + if (CI_SUCCESS == chFunRtn) + { + g_eaNum++; + } + else + { + g_szEaData[g_eaNum].wTrainId = 0u; + g_szEaData[g_eaNum].chBuildedFlag = 0u; + g_szEaData[g_eaNum].chSrcTiocId = 0u; + g_szEaData[g_eaNum].chDstTiocId = 0u; + g_szEaData[g_eaNum].chDstAllowed = 0u; + g_szEaData[g_eaNum].chPaType = 0u; + g_szEaData[g_eaNum].dwEaBuildCycNum = 0U; + SetPlatOverFlag(); + debug_infor_printf((const)"EaCmdProc is to shutdown,because build EA fail"); + } + } + else + { + SetPlatOverFlag(); + debug_infor_printf((const)"EaCmdProc is to shutdown,because the number of g_eaNum exceeds the limit"); + } + } + else + { + ; + } + } + else + { + ; + } + } + + for (i = 0u; i < TRAIN_SUM_MAX; i++)/*г*/ + {/* ггѹ */ + wTrainId = GetTrainId(i); + chDerailment = GetTrainDerailment(wTrainId); + wLinkId = GetTrainMaxHeadLink(wTrainId); + wLinkTioc = GetLinkManageTiocById(wLinkId); + + if ((FUNC_SWITCH_ON == chDaSwitch) && (TRAIN_DERAIL_NO != chDerailment) + && (wLinkTioc == chLocalId)) + { + for (j = 0u; j < g_eaNum; j++)/*ɢ*/ + { + /*жͨųǷѾ*/ + if ((wTrainId == g_szEaData[j].wTrainId) && (PA_TYPE_DA == g_szEaData[j].chPaType)) + { + break; + } + } + + if (g_eaNum == j) + { + if (EA_MAX_NUM > g_eaNum) + { + g_szEaData[g_eaNum].wTrainId = wTrainId; + g_szEaData[g_eaNum].chBuildedFlag = EA_IS_BUILDED; + g_szEaData[g_eaNum].chSrcTiocId = chLocalId; + g_szEaData[g_eaNum].chDstTiocId = 0u; + g_szEaData[g_eaNum].chDstAllowed = EA_DST_ALLOWED_NO; + g_szEaData[g_eaNum].chPaType = PA_TYPE_DA; + g_szEaData[g_eaNum].dwEaBuildCycNum = Get2oo2CurCycleNum(); + /*ӼLinkI*/ + chFunRtn = EvacuationAreaCalcu(g_eaNum, PA_TYPE_DA); + if (CI_SUCCESS == chFunRtn) + { + g_eaNum++; + } + else + { + g_szEaData[g_eaNum].wTrainId = 0u; + g_szEaData[g_eaNum].chBuildedFlag = 0u; + g_szEaData[g_eaNum].chSrcTiocId = 0u; + g_szEaData[g_eaNum].chDstTiocId = 0u; + g_szEaData[g_eaNum].chDstAllowed = 0u; + g_szEaData[g_eaNum].chPaType = 0u; + g_szEaData[g_eaNum].dwEaBuildCycNum = 0U; + SetPlatOverFlag(); + debug_infor_printf((const)"EaCmdProc is to shutdown,because build EA fail"); + } + } + else + { + SetPlatOverFlag(); + debug_infor_printf((const)"EaCmdProc is to shutdown,because the number of g_eaNum exceeds the limit"); + } + } + else + { + ; + } + } + else + { + ; + } + } + } + else + { + ; /* ߻Գߣɢ */ + } + + +} + +/** +* @brief ɢ +* @param chIndex +* @param chType +* @return CI_ERRORʧܣCI_SUCCESSɹ +*/ +static UINT8 EvacuationAreaCalcu(UINT8 chEaIndex, const UINT8 chType) +{ + UINT8 rtnValue = CI_ERROR; + UINT16 wTrainId = 0u; + UINT32 dwKm1 = 0u; + UINT32 dwKm2 = 0u; + UINT32 dwKmTemp = 0u; + UINT8 chIndex = 0u; + UINT16 wOrgnAxleId = 0u; + UINT16 wTmnlAxleId = 0u; + UINT16 wAcIndex = 0u; + UINT8 chLinkNum = 0u; + UINT16 * pLinkIdBuff = NULL; + UINT8 chLgcNum = 0u; + UINT16 * pLgcIdBuff = NULL; + UINT8 chLinkIndex = 0u; + UINT8 chLgcIndex = 0u; + UINT8 chEaAcIndex = 0u; + UINT32 dwOrgnAxleKm = 0u; + UINT32 dwTmnlAxleKm = 0u; + UINT8 chEaOut = 0u; + UINT8 chCalFlag = 0u; + UINT8 chPlatformFlag = 0u; + UINT16 wLinkTioc = 0u; + UINT8 chLocalId = 0u; + UINT8 chAcBelongCiId = 0; /*ID*/ + UINT8 chAcBelongCiType = 0; /**/ + UINT16 wEaMode = 0u; + UINT32 dwKmTmpMin = 0u; + UINT32 dwKmTmpMax = 0u; + UINT8 dwEaConfigId = 0u; + UINT8 chAxisSecAddFlag = CI_ERROR;/*Ƿ־*/ + UINT16 wAxisBelLinkId = 0U;/*LINK ID*/ + UINT16 wEaConfigIndex = 0U;/**/ + + chLocalId = GetSystemParaLocalCiId(); /* ȡID */ + + wTrainId = GetEvacuatingTrainIdByIndex(chEaIndex); /* ȡӦɢгID */ + + /* ߡ߽繫 */ + rtnValue = EaGetMidLineAndEdgeKm(chType, wTrainId, &chEaOut, &dwKmTemp, &dwKm2, &dwKm1, &dwEaConfigId); + + /* ȡɢ */ + wEaMode = GetSystemParaValue(EA_MODE_ID); + + if (CI_SUCCESS == rtnValue) + { + g_szEaData[chEaIndex].dwMidLine = dwKmTemp; + wEaConfigIndex = GetEaIndex(dwEaConfigId); + + for (wAcIndex = 0u; wAcIndex < g_eaAcConfigNum; wAcIndex++) + { + wOrgnAxleId = g_szEaAcConfig[wAcIndex].wOrgnAxisId; + wTmnlAxleId = g_szEaAcConfig[wAcIndex].wTmnlAxisId; + dwOrgnAxleKm = GetAxisKmById(wOrgnAxleId); + dwTmnlAxleKm = GetAxisKmById(wTmnlAxleId); + + /* ҳն */ + dwKmTmpMax = dwOrgnAxleKm > dwTmnlAxleKm ? dwOrgnAxleKm : dwTmnlAxleKm; + dwKmTmpMin = dwOrgnAxleKm < dwTmnlAxleKm ? dwOrgnAxleKm : dwTmnlAxleKm; + dwOrgnAxleKm = dwKmTmpMin; + dwTmnlAxleKm = dwKmTmpMax; + + + if ((EA_OUT_ONE == chEaOut) && (((dwOrgnAxleKm > dwKm2) && (dwOrgnAxleKm < dwKm1)) + || ((dwTmnlAxleKm > dwKm2) && (dwTmnlAxleKm < dwKm1)) + || ((dwOrgnAxleKm <= dwKm2) && (dwTmnlAxleKm >= dwKm1)))) + { + /* 㷽ʽΪ㣬ȡڷΧڻ߷ڼηΧڣ */ + chCalFlag = FLAG_SET; + } + else if ((EA_OUT_TWO == chEaOut) && (((dwOrgnAxleKm > dwKm2) && (dwOrgnAxleKm < dwKm1)) + || ((dwTmnlAxleKm > dwKm2) && (dwTmnlAxleKm < dwKm1)) + || ((dwOrgnAxleKm <= dwKm2) && (dwTmnlAxleKm >= dwKm1)))) + { + /* 㷽ʽΪվֻ̨ȡվ̨ */ + pLinkIdBuff = EaGetAcLinkId(g_szEaAcConfig[wAcIndex].AxisSectionId); + if (NULL == pLinkIdBuff) + { + rtnValue = CI_ERROR; + break; + } + else + { + ; + } + + chPlatformFlag = IsLinkPlatform(pLinkIdBuff[0]); + if (CI_SUCCESS == chPlatformFlag) + { + chCalFlag = FLAG_SET; + } + else + { + chCalFlag = FLAG_UNSET; + } + } + else if ((EA_OUT_FIVE == chEaOut) || (EA_OUT_THREE == chEaOut) || (EA_OUT_FOUR == chEaOut) || (EA_OUT_SIX == chEaOut)) + { + chCalFlag = FLAG_UNSET; + /*վһ䷽ʽҪȫ*/ + wAxisBelLinkId = g_szEaAcConfig[wAcIndex].szLinkIdBuff[0U]; + + for (chIndex = 0U; chIndex < g_szEaConfig[wEaConfigIndex].chEaConfigLinkSum; chIndex++) + { + if (wAxisBelLinkId == g_szEaConfig[wEaConfigIndex].wSzEaConfigLinkId[chIndex]) + { + /*дڸLINK*/ + break; + } + else + { + ; + } + } + + if (chIndex < g_szEaConfig[wEaConfigIndex].chEaConfigLinkSum) + { + chCalFlag = FLAG_SET; + } + else + { + ; + } + + if ((EA_OUT_SIX == chEaOut) || (EA_OUT_THREE == chEaOut)) + { + /*վһվ̨򣨲վ̨dzͷ߳βվ̨*/ + for (chIndex = 0U; chIndex < g_szEaConfig[wEaConfigIndex].chStartStationLinkSum; chIndex++) + { + if (wAxisBelLinkId == g_szEaConfig[wEaConfigIndex].wSzStartStationLinkId[chIndex]) + { + /*дڸLINK*/ + break; + } + else + { + ; + } + } + + if (chIndex < g_szEaConfig[wEaConfigIndex].chStartStationLinkSum) + { + chCalFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + if ((EA_OUT_SIX == chEaOut) || (EA_OUT_FOUR == chEaOut)) + { + /*վһվ̨򣨲վ̨dzͷ߳βյվ̨*/ + for (chIndex = 0U; chIndex < g_szEaConfig[wEaConfigIndex].chEndStationLinkSum; chIndex++) + { + if (wAxisBelLinkId == g_szEaConfig[wEaConfigIndex].wSzEndStationLinkId[chIndex]) + { + /*дڸLINK*/ + break; + } + else + { + ; + } + } + + if (chIndex < g_szEaConfig[wEaConfigIndex].chEndStationLinkSum) + { + chCalFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + } + else + { + chCalFlag = FLAG_UNSET; + } + + if (FLAG_SET == chCalFlag) + { + /*ȥ*/ + for (chIndex = 0u; chIndex < g_szEaData[chEaIndex].strAcInfo.chObjNum; chIndex++) + { + /*ǷѾ¼*/ + if (g_szEaData[chEaIndex].strAcInfo.szObjId[chIndex] == g_szEaAcConfig[wAcIndex].AxisSectionId) + { + break; + } + else + { + ; + } + } + /*ûм¼*/ + if (g_szEaData[chEaIndex].strAcInfo.chObjNum == chIndex) + { + /*жϸüǷԳ*/ + chAcBelongCiId = (UINT8)GetAxisBelongTiocAllLine(g_szEaAcConfig[wAcIndex].AxisSectionId); + chAcBelongCiType = GetCiType(chAcBelongCiId);/*ȡǰ*/ + /*ҪݹܿжǷн*/ + chAxisSecAddFlag = AxisSecAddProAreaCheck(g_szEaAcConfig[wAcIndex].AxisSectionId, chType, wTrainId); + + if (((CI_TYPE_ZX == chAcBelongCiType) || (CI_TYPE_SCX == chAcBelongCiType)) && (CI_SUCCESS == chAxisSecAddFlag)) + { + g_szEaData[chEaIndex].strAcInfo.szObjId[g_szEaData[chEaIndex].strAcInfo.chObjNum] = g_szEaAcConfig[wAcIndex].AxisSectionId; + g_szEaData[chEaIndex].strAcInfo.chObjNum++; + g_szEaData[chEaIndex].chEaConfigId = dwEaConfigId; + } + else + { + /*߻ԳӼ*/ + } + } + else + { + ; + } + } + else + { + ; + } + } + + if (EA_SECTION_MAX_NUM < g_szEaData[chEaIndex].strAcInfo.chObjNum) + { + rtnValue = CI_ERROR; + } + else + { + ; + } + } + + if (CI_SUCCESS == rtnValue) + { + /* ļ */ + for (chEaAcIndex = 0u; chEaAcIndex < g_szEaData[chEaIndex].strAcInfo.chObjNum; chEaAcIndex++) + { + chLinkNum = EaGetAcLinkNum(g_szEaData[chEaIndex].strAcInfo.szObjId[chEaAcIndex]); + pLinkIdBuff = EaGetAcLinkId(g_szEaData[chEaIndex].strAcInfo.szObjId[chEaAcIndex]); + if ((0u == chLinkNum) || (NULL == pLinkIdBuff)) + {/* ID */ + rtnValue = CI_ERROR; + (void)CommonMemSet(g_szEaData[chEaIndex].strLinkInfo.szObjId, (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM), 0u, (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM)); + g_szEaData[chEaIndex].strLinkInfo.chObjNum = 0u; + break; + } + else + {/* аlinkȥؼ¼ */ + for (chLinkIndex = 0u; chLinkIndex < chLinkNum; chLinkIndex++) + { + for (chIndex = 0u; chIndex < g_szEaData[chEaIndex].strLinkInfo.chObjNum; chIndex++) + { + if (g_szEaData[chEaIndex].strLinkInfo.szObjId[chIndex] == pLinkIdBuff[chLinkIndex]) + { + break; + } + else + { + ; + } + } + if (chIndex == g_szEaData[chEaIndex].strLinkInfo.chObjNum) + { + if (EA_SECTION_MAX_NUM > g_szEaData[chEaIndex].strLinkInfo.chObjNum) + { + g_szEaData[chEaIndex].strLinkInfo.szObjId[g_szEaData[chEaIndex].strLinkInfo.chObjNum] = pLinkIdBuff[chLinkIndex]; + g_szEaData[chEaIndex].strLinkInfo.chObjNum++; + wLinkTioc = GetLinkManageTiocById(pLinkIdBuff[chLinkIndex]); + if ((UINT8)wLinkTioc != chLocalId) + {/* ɢҳĿTIOC */ + g_szEaData[chEaIndex].chDstTiocId = (UINT8)wLinkTioc; + } + else + { + ; + } + } + else + { + ; + } + } + else + { + ; + } + } + } + } + } + + if (CI_SUCCESS == rtnValue) + { + /* ļ */ + for (chEaAcIndex = 0u; chEaAcIndex < g_szEaData[chEaIndex].strAcInfo.chObjNum; chEaAcIndex++) + { + chLgcNum = EaGetAcLgcNum(g_szEaData[chEaIndex].strAcInfo.szObjId[chEaAcIndex]); + pLgcIdBuff = EaGetAcLgcId(g_szEaData[chEaIndex].strAcInfo.szObjId[chEaAcIndex]); + if ((0u == chLgcNum) || (NULL == pLgcIdBuff)) + {/* ID */ + rtnValue = CI_ERROR; + (void)CommonMemSet(g_szEaData[chEaIndex].strLgcInfo.szObjId, (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM), 0u, (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM)); + g_szEaData[chEaIndex].strLgcInfo.chObjNum = 0u; + break; + } + else + {/* а߼ȥؼ¼ */ + for (chLgcIndex = 0u; chLgcIndex < chLgcNum; chLgcIndex++) + { + for (chIndex = 0u; chIndex < g_szEaData[chEaIndex].strLgcInfo.chObjNum; chIndex++) + { + if (g_szEaData[chEaIndex].strLgcInfo.szObjId[chIndex] == pLgcIdBuff[chLgcIndex]) + { + break; + } + else + { + ; + } + } + if (chIndex == g_szEaData[chEaIndex].strLgcInfo.chObjNum) + { + if (EA_SECTION_MAX_NUM > g_szEaData[chEaIndex].strLgcInfo.chObjNum) + { + g_szEaData[chEaIndex].strLgcInfo.szObjId[g_szEaData[chEaIndex].strLgcInfo.chObjNum] = pLgcIdBuff[chLgcIndex]; + g_szEaData[chEaIndex].strLgcInfo.chObjNum++; + } + else + { + ; + } + } + else + { + ; + } + } + } + + } + } + + if (CI_SUCCESS == rtnValue) + { + /*·*/ + RefreshEaLineType(chEaIndex); + } + + if (CI_SUCCESS == rtnValue) + { + debug_infor_printf((const)"Train:%x PaType = %x\n", wTrainId, g_szEaData[chEaIndex].chPaType); + + debug_infor_printf((const)"Train:%x pMidLine = %d pMinEdge = %d pMaxEdge = %d\n", wTrainId,dwKmTemp,dwKm2,dwKm1); + + debug_infor_printf((const)"Train:%x PaAcSeq:num = %d\n", wTrainId, g_szEaData[chEaIndex].strAcInfo.chObjNum); + for (chEaAcIndex = 0U; chEaAcIndex < g_szEaData[chEaIndex].strAcInfo.chObjNum; chEaAcIndex++) + { + debug_infor_printf((const)"%d/", g_szEaData[chEaIndex].strAcInfo.szObjId[chEaAcIndex]); + } + + debug_infor_printf((const)"\nTrain:%x PaLinkSeq:num = %d\n", wTrainId, g_szEaData[chEaIndex].strLinkInfo.chObjNum); + for (chEaAcIndex = 0U; chEaAcIndex < g_szEaData[chEaIndex].strLinkInfo.chObjNum; chEaAcIndex++) + { + debug_infor_printf((const)"%d/", g_szEaData[chEaIndex].strLinkInfo.szObjId[chEaAcIndex]); + } + + debug_infor_printf((const)"\nTrain:%x PaLgcSeq:num = %d\n", wTrainId, g_szEaData[chEaIndex].strLgcInfo.chObjNum); + for (chEaAcIndex = 0U; chEaAcIndex < g_szEaData[chEaIndex].strLgcInfo.chObjNum; chEaAcIndex++) + { + debug_infor_printf((const)"%d/", g_szEaData[chEaIndex].strLgcInfo.szObjId[chEaAcIndex]); + } + + debug_infor_printf((const)"\n"); + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ȡָɢгID +* @param chIndex ± +* @return гID +*/ +UINT16 GetEvacuatingTrainIdByIndex(UINT8 chIndex) +{ + UINT16 rtnValue = 0u; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].wTrainId; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ȡɢ־λ +* @param chIndex ± +* @return 0ĬֵEA_IS_BUILDEDѽEA_IS_NOT_BUILDEDδ +*/ +UINT8 GetEaBuildedFlag(UINT8 chIndex) +{ + UINT8 rtnValue = 0u; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].chBuildedFlag; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ȡɢlink +* @param chIndex ± +* @return ɢlink +*/ +UINT8 GetEaLinkNum(UINT8 chIndex) +{ + UINT8 rtnValue = 0u; + + if ((EA_MAX_NUM > chIndex) && (EA_SECTION_MAX_NUM >= g_szEaData[chIndex].strLinkInfo.chObjNum)) + { + rtnValue = g_szEaData[chIndex].strLinkInfo.chObjNum; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ȡɢlink +* @param chIndex ± +* @return ɢlink +*/ +UINT16 * GetEaLinkBuff(UINT8 chIndex) +{ + UINT16 * rtnValue = NULL; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].strLinkInfo.szObjId; + } + + return rtnValue; +} + +/** +* @brief ȡҪɢ +* @param +* @return Ҫɢ +*/ +UINT8 GetEaNum(void) +{ + UINT8 rtnValue = EA_MAX_NUM + 1U;/*ΪEA_MAX_NUM*/ + if (EA_MAX_NUM >= g_eaNum) + { + rtnValue = g_eaNum; + } + return rtnValue; +} + +/** +* @brief ȡͨųijһɢгǷͬ⽨ +* @param wEaTrainId ɢгID +* @return CI_ERROR ͬ CI_SUCCESS ͬ +*/ +static UINT8 GetAllCtTrainAgreeSetEva(UINT16 wEaTrainId) +{ + UINT8 rtnValue = CI_ERROR; + UINT8 cRetVal = EA_PROTECT_BUILD_N; + UINT8 i = 0u; + UINT8 j = 0u; + UINT8 chEaNum = 0u; + UINT8 chNoFindNum = 0u; + UINT8 chAllowFlag = 0u; + UINT8 chComState = 0u; + UINT16 wTrainId = 0u; + TrainEaStru * pTrainEaInfo = NULL; + UINT8 chMsgFromTiocId = 0u; + UINT8 chLevel = 0u; + UINT32 dwBuildCycNum = 0u; /*гɢں*/ + UINT8 chEaIndex = 0U; + cRetVal = EA_PROTECT_BUILD_Y; + + /*index ͽ*/ + for (chEaIndex = 0u; chEaIndex < g_eaNum; chEaIndex++) + { + if ((wEaTrainId == g_szEaData[chEaIndex].wTrainId) &&(PA_TYPE_EA == g_szEaData[chEaIndex].chPaType)) + { + break; + } + else + { + ; /* */ + } + } + dwBuildCycNum = EaGetBuildCycNum(chEaIndex); + + for (i = 0u; i < TRAIN_SUM_MAX; i++) /*еͨų*/ + { + wTrainId = GetTrainId(i); + chComState = GetTrainTransitmitStat(wTrainId); + chMsgFromTiocId = GetTrainMsgFromTiocId(wTrainId); + chLevel = GetTrainLevel(wTrainId); + if ((TRAIN_COMM_STATE_GOOD != chComState) || (0u != chMsgFromTiocId) || (TRAIN_LEVEL_VBTC != chLevel))/**/ + { + ; + } + else + { + chNoFindNum = 0u; + chEaNum = GetTrainEaNum(wTrainId); /*ȡͨųػظɢ*/ + + pTrainEaInfo = GetTrainEaInfo(wTrainId); + if (NULL == pTrainEaInfo) + { + cRetVal = EA_PROTECT_BUILD_N; + } + else + { + for (j = 0u; j < chEaNum; j++) + { + if (pTrainEaInfo[j].wEaTrainId == wEaTrainId) + { + chAllowFlag = pTrainEaInfo[j].chAgreeState; + if ((EA_PROTECT_BUILD_Y == chAllowFlag) &&(dwBuildCycNum == pTrainEaInfo[j].dwBuildCyc)) + { + /*ͬ⽨ںһ*/ + cRetVal = EA_PROTECT_BUILD_Y; + } + else + { + cRetVal = EA_PROTECT_BUILD_N; + debug_infor_printf((const)"Train:%d Not allowe Tirain%d to buildEA, buildCyc%d--answerCyc:%d\n", wTrainId, wEaTrainId, dwBuildCycNum, pTrainEaInfo[j].dwBuildCyc); + } + break; + } + else /*¼ûҵӦIDĴ*/ + { + chNoFindNum++; + } + } + } + + if ((EA_PROTECT_BUILD_N == cRetVal) || (chEaNum == chNoFindNum))/*һûͬ⣬гûյӦɢгID*/ + { + /* ͬ⣬ */ + cRetVal = EA_PROTECT_BUILD_N; + debug_infor_printf((const)"Train:%x not allowed to build %d\n", wTrainId, wEaTrainId); + break; + } + else + { + ; /* ͬ */ + } + } + } + + if (EA_PROTECT_BUILD_Y == cRetVal) + { + rtnValue = CI_SUCCESS; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ɢгߡɢԵ +* @param chType +* @param wTrainId ɢгID +* @param pMidLine ɢг߹ +* @param pMinEdge ɢС +* @param pMaxEdge ɢ +* @return CI_ERROR ʧ CI_SUCCESS ɹ +* edit cgh 20250310 +*/ +static UINT8 EaGetMidLineAndEdgeKm(const UINT8 chType, const UINT16 wTrainId, UINT8 * pEaOut, UINT32 * pMidLine, UINT32 * pMinEdge, UINT32 * pMaxEdge, UINT8 * pEaconfigId) +{ + UINT16 wMaxHeadLink = 0u; + UINT32 dwMaxHeadOff = 0u; + UINT16 wMinTailLink = 0u; + UINT32 dwMinTailOff = 0u; + UINT32 dwMaxHeadKm = 0u; + UINT32 dwMinTailKm = 0u; + UINT8 chRtn = CI_ERROR; + UINT16 wEaMode = 0u; + UINT16 wEaStationMode = 0u; + UINT8 chTrainDir_Maxhead = 0u; /*гǰΪ׼*/ + UINT8 chTrainDir_outTail = 0u; /*βķ򣬴ǰȡ*/ + UINT32 dwFrontDis = 0u; + UINT32 dwBehindDis = 0u; + UINT32 dwKm1 = 0u; /*ͷɢԵ*/ + UINT32 dwKm2 = 0u; /*βɢԵ*/ + UINT8 chPlatformFlag = CI_ERROR; + UINT16 wIndex = 0u; + UINT8 chTailPlatFlag = CI_ERROR; + UINT16 wACOfMaxSafeHeadLoc = 0u; /*гȫǰID*/ + UINT16 wACOfMinSafeTailLoc = 0u; /*гСȫID*/ + UINT16 wMaxHeadLinkOrgnPointID = 0u; /*ͷ˵ID*/ + UINT16 wMaxHeadLinkTmnlPointID = 0u; /*ͷյ˵ID*/ + UINT16 wMinTailLinkOrgnPointID = 0u; /*β˵ID*/ + UINT16 wMinTailLinkTmnlPointID = 0u; /*βյ˵ID*/ + UINT32 wMaxHeadLinkOrgnPointKm = 0u; /*ͷ㹫*/ + UINT32 wMaxHeadLinkTmnlPointKm = 0u; /*ͷյ㹫*/ + UINT32 wMinTailLinkOrgnPointKm = 0u; /*β㹫*/ + UINT32 wMinTailLinkTmnlPointKm = 0u; /*βյ㹫*/ + UINT16 wBasicLinkId = 0U;/*׼LINK ID*/ + UINT8 chConfigLinkIndex = 0U;/*LINK*/ + + /* ȡгλ */ + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); + dwMaxHeadOff = GetTrainMaxHeadOffset(wTrainId); + wMinTailLink = GetTrainMinTailLink(wTrainId); + dwMinTailOff = GetTrainMinTailOffset(wTrainId); + chTrainDir_Maxhead = GetTrainDir_MaxHead(wTrainId); + + wACOfMaxSafeHeadLoc = elm_PrepareACOfMaxSafeHeadLoc(wTrainId); /*ȡID*/ + wACOfMinSafeTailLoc = elm_PrepareACOfMinSafeTailLoc(wTrainId); + + /*ȡгλüεյID*/ + wMaxHeadLinkOrgnPointID = EaGetAcOrgnAxisId(wACOfMaxSafeHeadLoc); /*ͷ*/ + wMaxHeadLinkTmnlPointID = EaGetAcTmnlAxisId(wACOfMaxSafeHeadLoc); + wMinTailLinkOrgnPointID = EaGetAcOrgnAxisId(wACOfMinSafeTailLoc); /*β*/ + wMinTailLinkTmnlPointID = EaGetAcTmnlAxisId(wACOfMinSafeTailLoc); + + /* жгλЧ */ + chRtn = CheckLinkValid(wMaxHeadLink, dwMaxHeadOff); + chRtn &= CheckLinkValid(wMinTailLink, dwMinTailOff); + + if ((CI_ERROR == chRtn) || (NULL == pMidLine) + || (NULL == pMinEdge) || (NULL == pMaxEdge) + || ((DIR_SAME != chTrainDir_Maxhead) && (DIR_CONVERT != chTrainDir_Maxhead))) + {/* μʧܣʧ */ + chRtn = CI_ERROR; + } + else + { + dwMaxHeadKm = GetPointKm(wMaxHeadLink, dwMaxHeadOff); + dwMinTailKm = GetPointKm(wMinTailLink, dwMinTailOff); + /*ȡͷβյĹ*/ + wMaxHeadLinkOrgnPointKm = GetAxisKmById(wMaxHeadLinkOrgnPointID); /*ͷ*/ + wMaxHeadLinkTmnlPointKm = GetAxisKmById(wMaxHeadLinkTmnlPointID); + wMinTailLinkOrgnPointKm = GetAxisKmById(wMinTailLinkOrgnPointID); /*β*/ + wMinTailLinkTmnlPointKm = GetAxisKmById(wMinTailLinkTmnlPointID); + + chPlatformFlag = IsLinkPlatform(wMaxHeadLink); + chTailPlatFlag = IsLinkPlatform(wMinTailLink); + if ((UINT32_MAX == dwMaxHeadKm) || (UINT32_MAX == dwMinTailKm)) + { + chRtn = CI_ERROR; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + *pMidLine = (dwMaxHeadKm + dwMinTailKm) / 2u; /* ߹ */ + + wEaMode = GetSystemParaValue(EA_MODE_ID); + wEaStationMode = GetSystemParaValue(EA_STATION_MODE_ID); + if ((PA_TYPE_DA == chType) || (EA_MODE_DIS == wEaMode) || ((EA_STATION_MODE_DIS == wEaStationMode) && (wMaxHeadLink == wMinTailLink) && (CI_SUCCESS == chPlatformFlag))) + { + /* ȡɢΧ */ + dwFrontDis = GetEaFrontDis(); + dwBehindDis = GetEaBehindDis(); + chTrainDir_outTail = ConvertTrainDir(chTrainDir_Maxhead); /*ǰȡ*/ + + /*ͷ*/ + if (DIR_SAME == chTrainDir_Maxhead) + {/*ͷشǰۼ*/ + dwKm1 = dwMaxHeadKm + dwFrontDis; + } + else if (DIR_CONVERT == chTrainDir_Maxhead) + {/*ͷشǰۼ*/ + if (dwMaxHeadKm >= dwFrontDis) + { + dwKm1 = dwMaxHeadKm - dwFrontDis; + } + else + { + dwKm1 = 0u; + } + } + else + { + chRtn = CI_ERROR; + } + + /*β*/ + if (DIR_SAME == chTrainDir_outTail) + {/*βسβⷽۼ*/ + dwKm2 = dwMinTailKm + dwBehindDis; + } + else if (DIR_CONVERT == chTrainDir_outTail) + {/*βسβⷽۼ*/ + if (dwMinTailKm >= dwBehindDis) + { + dwKm2 = dwMinTailKm - dwBehindDis; + } + else + { + dwKm2 = 0u; + } + } + else + { + chRtn = CI_ERROR; + } + + *pMinEdge = (dwKm1 < dwKm2) ? dwKm1 : dwKm2; + *pMaxEdge = (dwKm1 < dwKm2) ? dwKm2 : dwKm1; + *pEaOut = EA_OUT_ONE; + } + else if ((EA_STATION_MODE_PLAT == wEaStationMode) && (wMaxHeadLink == wMinTailLink) && (CI_SUCCESS == chPlatformFlag)) + { + *pMinEdge = (dwMaxHeadKm < dwMinTailKm) ? dwMaxHeadKm : dwMinTailKm; + *pMaxEdge = (dwMaxHeadKm < dwMinTailKm) ? dwMinTailKm : dwMaxHeadKm; + *pEaOut = EA_OUT_TWO; + } + else if ((EA_MODE_SEC == wEaMode) || (EA_MODE_PLATION == wEaMode)) + { + if (CI_ERROR == chPlatformFlag) + { + /* ͷվ̨ѡȡͷѯ */ + wBasicLinkId = wMaxHeadLink; + } + else if(CI_ERROR == chTailPlatFlag) + {/* βվ̨ѡȡβѯ */ + wBasicLinkId = wMinTailLink; + } + else + { + /*ܷ֧Է*/ + } + + for (wIndex = 0u; wIndex < g_eaConfigNum; wIndex++) + { + for (chConfigLinkIndex = 0U; chConfigLinkIndex < g_szEaConfig[wIndex].chEaConfigLinkSum; chConfigLinkIndex++) + { + if (wBasicLinkId == g_szEaConfig[wIndex].wSzEaConfigLinkId[chConfigLinkIndex]) + { + break; + } + else + { + ; + } + } + + if (chConfigLinkIndex < g_szEaConfig[wIndex].chEaConfigLinkSum) + { + /*Ѿҵ*/ + break; + } + else + { + ; + } + } + + if (wIndex < g_eaConfigNum) + { + /*ǰʽΪվһ䲻վ̨гһڷվ̨䣬Ҫվ̨*/ + if (EA_MODE_SEC == wEaMode) + { + /*ͷվ̨β*/ + if ((CI_SUCCESS == chPlatformFlag) && (CI_ERROR == chTailPlatFlag)) + { + for (chConfigLinkIndex = 0U; chConfigLinkIndex < g_szEaConfig[wIndex].chStartStationLinkSum; chConfigLinkIndex++) + { + if (wMaxHeadLink == g_szEaConfig[wIndex].wSzStartStationLinkId[chConfigLinkIndex]) + { + break; + } + else + { + ; + } + } + + /*Dzվ̨*/ + if (chConfigLinkIndex < g_szEaConfig[wIndex].chStartStationLinkSum) + { + *pEaOut = EA_OUT_THREE; + } + else + { + for (chConfigLinkIndex = 0U; chConfigLinkIndex < g_szEaConfig[wIndex].chEndStationLinkSum; chConfigLinkIndex++) + { + if (wMaxHeadLink == g_szEaConfig[wIndex].wSzEndStationLinkId[chConfigLinkIndex]) + { + break; + } + else + { + ; + } + } + if (chConfigLinkIndex < g_szEaConfig[wIndex].chEndStationLinkSum) + { + *pEaOut = EA_OUT_FOUR; + } + else + { + chRtn = CI_ERROR; /*յ㶼Ҳ*/ + } + } + + } + /*ͷվ̨ βվ̨*/ + else if ((CI_ERROR == chPlatformFlag) && (CI_SUCCESS == chTailPlatFlag)) + { + { + for (chConfigLinkIndex = 0U; chConfigLinkIndex < g_szEaConfig[wIndex].chStartStationLinkSum; chConfigLinkIndex++) + { + if (wMinTailLink == g_szEaConfig[wIndex].wSzStartStationLinkId[chConfigLinkIndex]) + { + break; + } + else + { + ; + } + } + + /*Dzվ̨*/ + if (chConfigLinkIndex < g_szEaConfig[wIndex].chStartStationLinkSum) + { + *pEaOut = EA_OUT_THREE; + } + else + { + for (chConfigLinkIndex = 0U; chConfigLinkIndex < g_szEaConfig[wIndex].chEndStationLinkSum; chConfigLinkIndex++) + { + if (wMinTailLink == g_szEaConfig[wIndex].wSzEndStationLinkId[chConfigLinkIndex]) + { + break; + } + else + { + ; + } + } + if (chConfigLinkIndex < g_szEaConfig[wIndex].chEndStationLinkSum) + { + *pEaOut = EA_OUT_FOUR; + } + else + { + chRtn = CI_ERROR; /*յ㶼Ҳ*/ + } + } + + } + } + else if ((CI_ERROR == chPlatformFlag) && (CI_ERROR == chTailPlatFlag)) + { + /*гռѹվ̨*/ + *pEaOut = EA_OUT_FIVE; + } + else + { + chRtn = CI_ERROR;/*ɴ֧*/ + } + + *pEaconfigId = (UINT8)g_szEaConfig[wIndex].wId; + } + else if (EA_MODE_PLATION == wEaMode) + { + *pEaOut = EA_OUT_SIX; + *pEaconfigId = (UINT8)g_szEaConfig[wIndex].wId; + } + else + { + /*ɴ֧*/ + chRtn = CI_ERROR; + } + + + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; /* ܷ֧ */ + } + } + else + { + ; + } + } + + return chRtn; +} + +/** +* @brief ѯվһ䲻վ̨ķڵվ̨ +* @param const UINT16 eaConfigIndex +* @param const UINT32 wOrgnPointKmtemp С˹ +* @param const UINT32 wTmnlPointKmtemp ˹ +* @param UINT32* pMinEdge С +* @param UINT32* pMaxEdge +* @return CI_ERROR ʧ CI_SUCCESSɹ +* By LC 20231113 +**/ +UINT8 EaGetadjacentStationKM(const UINT16 eaConfigIndex, const UINT32 wOrgnPointKmtemp, const UINT32 wTmnlPointKmtemp, UINT32* pMinEdge, UINT32* pMaxEdge) +{ + UINT8 chPointIndex = 0U;/*ѭ*/ + UINT8 chRtn = CI_ERROR; + UINT16 trainAcId = 0U; + + UINT32 retvalStartKm = 0U; /*طʼ˹*/ + UINT32 retvalEndKm = 0U; /*طն˹*/ + + UINT16 beforStartLink = 0U; /*ʼLink*/ + UINT16 afterEndLink = 0U; /*նLink*/ + UINT8 chStationFlag = 0U; /*жϱ־linkǷΪվ̨*/ + UINT16 wSwitchId = 0U; + UINT8 cDirectionPointFlag = 0U; + UINT16 wAxleId = 0U; + UINT32 dwKmTemp = 0U; + + + retvalStartKm = g_szEaConfig[eaConfigIndex].dwMinKm; + retvalEndKm = g_szEaConfig[eaConfigIndex].dwMaxKm; + chRtn = CI_SUCCESS; + /*빫ڷʼ*/ + if ((wOrgnPointKmtemp < g_szEaConfig[eaConfigIndex].dwMinKm) || (wTmnlPointKmtemp < g_szEaConfig[eaConfigIndex].dwMinKm)) + { + for (chPointIndex = 0u; chPointIndex < g_szEaConfig[eaConfigIndex].chStartLinkNum; chPointIndex++) + {/* 㣬ҳ߽С */ + /* վ̨жǷΪվ̨ */ + beforStartLink = FindAdjacentLinkIDSafe(g_szEaConfig[eaConfigIndex].szStartLinkId[chPointIndex], DIR_CONVERT, &wSwitchId, &cDirectionPointFlag); + chStationFlag = IsLinkPlatform(beforStartLink); + + if (UINT16_MAX == beforStartLink) + { + chRtn = CI_ERROR; + break; + } + else if (CI_SUCCESS == chStationFlag) + { + ; + } + else + { + beforStartLink = g_szEaConfig[eaConfigIndex].szStartLinkId[chPointIndex]; + } + + wAxleId = GetLinkOrgnPointIdById(beforStartLink); + dwKmTemp = GetAxisKmById(wAxleId); + if (dwKmTemp < retvalStartKm) + { + retvalStartKm = dwKmTemp; + } + else + { + ;/* 踳ֵ */ + } + } + + } + /*빫ڷն*/ + else if ((wOrgnPointKmtemp > g_szEaConfig[eaConfigIndex].dwMaxKm) || (wTmnlPointKmtemp > g_szEaConfig[eaConfigIndex].dwMaxKm)) + { + for (chPointIndex = 0u; chPointIndex < g_szEaConfig[eaConfigIndex].chEndLinkNum; chPointIndex++) + {/* յ㣬ҳյ߽ */ + + afterEndLink = FindAdjacentLinkIDSafe(g_szEaConfig[eaConfigIndex].szEndLinkId[chPointIndex], DIR_SAME, &wSwitchId, &cDirectionPointFlag); + + chStationFlag = IsLinkPlatform(afterEndLink); + if (UINT16_MAX == afterEndLink) + { + chRtn = CI_ERROR; + break; + } + else if (CI_SUCCESS == chStationFlag) + { + ; + } + else + { + afterEndLink = g_szEaConfig[eaConfigIndex].szEndLinkId[chPointIndex]; + } + wAxleId = GetLinkTmnlPointIdById(afterEndLink); + dwKmTemp = GetAxisKmById(wAxleId); + if (dwKmTemp > retvalEndKm) + { + retvalEndKm = dwKmTemp; + } + else + { + ; /* 踳ֵ */ + } + } + } + else + { + /*빫겻ڷⷽվ̨*/ + chRtn = CI_ERROR; + } + *pMinEdge = retvalStartKm; + *pMaxEdge = retvalEndKm; + return chRtn; +} + + +/** +* @brief ȡ +* @param const UINT16 wAcId α +* @return AXIS_SECTION_SUM_MAX:ʧ +*/ +static UINT16 EaGetAcIndex(const UINT16 wAcId) +{ + UINT16 wRtn = AXIS_SECTION_SUM_MAX; + UINT16 wIndex = 0u; + + for (wIndex = 0u; wIndex < g_eaAcConfigNum; wIndex++) + { + if (g_szEaAcConfig[wIndex].AxisSectionId == wAcId) + { + wRtn = wIndex; + break; + } + else + { + ; + } + } + + return wRtn; +} + +/** +* @brief ȡΰlink +* @param const UINT16 wAcId α +* @return ΰlinkAXIS_INCLUDE_LINK_SUM_MAX:ʧ +*/ +static UINT8 EaGetAcLinkNum(const UINT16 wAcId) +{ + UINT8 chRtn = (UINT8)AXIS_INCLUDE_LINK_SUM_MAX; + UINT16 wIndex = AXIS_SECTION_SUM_MAX; + + wIndex = EaGetAcIndex(wAcId); + if (wIndex < AXIS_SECTION_SUM_MAX) + { + chRtn = g_szEaAcConfig[wIndex].chLinkNum; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡΰ +* @param const UINT16 wAcId α +* @return ΰlinkAXIS_INCLUDE_LINK_SUM_MAX:ʧ +*/ +static UINT16 EaGetAcOrgnAxisId(const UINT16 wAcId) +{ + UINT16 chRtn = AXIS_INCLUDE_LINK_SUM_MAX; + UINT16 wIndex = AXIS_SECTION_SUM_MAX; + + wIndex = EaGetAcIndex(wAcId); + if (wIndex < AXIS_SECTION_SUM_MAX) + { + chRtn = g_szEaAcConfig[wIndex].wOrgnAxisId; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡΰյ +* @param const UINT16 wAcId α +* @return ΰlinkAXIS_INCLUDE_LINK_SUM_MAX:ʧ +*/ +static UINT16 EaGetAcTmnlAxisId(const UINT16 wAcId) +{ + UINT16 chRtn = AXIS_INCLUDE_LINK_SUM_MAX; + UINT16 wIndex = AXIS_SECTION_SUM_MAX; + + wIndex = EaGetAcIndex(wAcId); + if (wIndex < AXIS_SECTION_SUM_MAX) + { + chRtn = g_szEaAcConfig[wIndex].wTmnlAxisId; + } + else + { + ; + } + return chRtn; +} + + +/** +* @brief ȡΰlink +* @param const UINT16 wAcId α +* @return ΰlinkţNULL:ʧ +*/ +static UINT16 * EaGetAcLinkId(const UINT16 wAcId) +{ + UINT16 * pRtn = NULL; + UINT16 wIndex = AXIS_SECTION_SUM_MAX; + + wIndex = EaGetAcIndex(wAcId); + if (wIndex < AXIS_SECTION_SUM_MAX) + { + pRtn = g_szEaAcConfig[wIndex].szLinkIdBuff; + } + else + { + ; + } + return pRtn; +} + +/** +* @brief ȡΰ߼ +* @param const UINT16 wAcId α +* @return ΰ߼AXIS_INCLUDE_LOG_SUM_MAX:ʧ +*/ +static UINT8 EaGetAcLgcNum(const UINT16 wAcId) +{ + UINT8 chRtn = (UINT8)AXIS_INCLUDE_LOG_SUM_MAX; + UINT16 wIndex = AXIS_SECTION_SUM_MAX; + + wIndex = EaGetAcIndex(wAcId); + if (wIndex < AXIS_SECTION_SUM_MAX) + { + chRtn = g_szEaAcConfig[wIndex].LogSectionSum; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡΰ߼α +* @param const UINT16 wAcId α +* @return ΰ߼αţNULL:ʧ +*/ +static UINT16 * EaGetAcLgcId(const UINT16 wAcId) +{ + UINT16 * pRtn = NULL; + UINT16 wIndex = AXIS_SECTION_SUM_MAX; + + wIndex = EaGetAcIndex(wAcId); + if (wIndex < AXIS_SECTION_SUM_MAX) + { + pRtn = g_szEaAcConfig[wIndex].LogSectionIdBuf; + } + else + { + ; + } + return pRtn; +} + +/** +* @brief ȡ߼ +* @param const UINT8 chIndex +* @return ߼ +*/ +UINT8 EaGetLgcNum(const UINT8 chIndex) +{ + UINT8 chRtn = 0u; + if (EA_MAX_NUM > chIndex) + { + chRtn = g_szEaData[chIndex].strLgcInfo.chObjNum; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡ߼α +* @param const UINT8 chIndex +* @return ߼α +*/ +UINT16 * EaGetLgcId(const UINT8 chIndex) +{ + UINT16 * pRtn = NULL; + if (EA_MAX_NUM > chIndex) + { + pRtn = g_szEaData[chIndex].strLgcInfo.szObjId; + } + else + { + ; + } + return pRtn; +} + +/** +* @brief ȡɢг߹ +* @param const UINT8 chIndex +* @return ɢг߹ +*/ +UINT32 EaGetMidLine(const UINT8 chIndex) +{ + UINT32 dwRtn = UINT32_MAX; + if (EA_MAX_NUM > chIndex) + { + dwRtn = g_szEaData[chIndex].dwMidLine; + } + else + { + ; + } + return dwRtn; +} + +/** +* @brief ɢȡ +* @param +* @return +*/ +static void EaAtsCancleProc(void) +{ + AtsEaMsgStru * strMsgFst = NULL; + AtsEaMsgStru * strMsgSnd = NULL; + strMsgFst = GetAtsEaMsgFst(); + strMsgSnd = GetAtsEaMsgSnd();/*᷵NULL*/ + + if ((strMsgFst->chFlag != FLAG_SET) && (strMsgSnd->chFlag != FLAG_SET)) + { + ; /* ûϢʲôҲ */ + } + else if ((strMsgFst->chFlag == FLAG_SET) && (strMsgSnd->chFlag != FLAG_SET)) + {/* ȡɢһϢ */ + EaAtsCancleFst(); + } + else + {/* ȡɢϢ */ + EaAtsCancleSnd(); + } + +} + +/** +* @brief ɢ״ȡ +* @param +* @return +*/ +static void EaAtsCancleFst(void) +{ + AtsEaMsgStru * strMsgFst = NULL; + AtsMsgCfmStru * strCfmFst = NULL; + UINT32 dwCycle = 0U; + UINT8 chLocalId = 0U; + UINT8 chRtn = CI_ERROR; + UINT8 szCrcTmp[1024] = { 0U }; + UINT32 ii = 0U; + UINT8 chFunRtn = CI_TIME_OUT; + UINT16 wTrainId = 0U; + UINT16 wTrainLgcId = 0U; + UINT8 chEaIndex = 0U; + UINT8 chEaAreaLinkType = 0U;/*ش洢ķ·*/ + UINT8 chEaCmdState = 0U;/*ɢ״̬*/ + + chLocalId = GetSystemParaLocalCiId(); + dwCycle = Get2oo2CurCycleNum(); + + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsEaMsgFst(); + strCfmFst = GetAtsEaCfmFst(); + + if (strMsgFst->dwCycle == dwCycle) + { + strCfmFst->chFlag = FLAG_SET; + strCfmFst->chTiocId = chLocalId; + strCfmFst->chStation = strMsgFst->chStation; + strCfmFst->chIndex = strMsgFst->chIndex; + strCfmFst->dwTime = dwCycle; + + chRtn = dquHlhtId2VobcName(strMsgFst->dwEaTrainId, &wTrainId, &wTrainLgcId); + + if (CI_ERROR == chRtn) + { + strCfmFst->chOpStatus = CONFIRM_UNKNOWN; + } + else + { + /* ȡ洢 */ + chEaIndex = PaGetIndex(wTrainId, PA_TYPE_EA); + if (chEaIndex == g_eaNum) + { + strCfmFst->chOpStatus = CONFIRM_FIRST_NOT_EA; + } + else + { + chEaCmdState = GetTrainEaCmdState(wTrainId); + if (TRAIN_EA_CMD_STATE_INVALID != chEaCmdState) + { + /* гǰɢ״̬ */ + strCfmFst->chOpStatus = CONFIRM_FIRST_EING; + } + else + { + chEaAreaLinkType = GetEaAreaLineType(chEaIndex); + if ((EA_AREA_ALL != strMsgFst->chLine) && (EA_AREA_ALL != chEaAreaLinkType) && (chEaAreaLinkType != strMsgFst->chLine)) + { + /*ATS··Ժͱش洢·෴ʱҪط*/ + strCfmFst->chOpStatus = CONFIRM_EALINE_DIFFERENT; + } + else + { + strCfmFst->chOpStatus = CONFIRM_FIRST_SUCCESS; + } + } + } + } + + szCrcTmp[ii] = strMsgFst->chAtsId; + ii++; + szCrcTmp[ii] = strMsgFst->chStation; + ii++; + szCrcTmp[ii] = strMsgFst->chIndex; + ii++; + LongToChar(strMsgFst->dwEaTrainId, &szCrcTmp[ii]); + ii += 4u; + LongToChar(strMsgFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii] = strMsgFst->chType; + ii++; + szCrcTmp[ii] = strMsgFst->chLine; + ii++; + strCfmFst->dwCrc32 = Tioc_CommonCrc32(szCrcTmp, ii); /* ATSšվšվšгͨID·ʱ䡢͡CRC */ + + if (CONFIRM_FIRST_SUCCESS != strCfmFst->chOpStatus) + { + ClearAtsEaMsgFirst(); + } + else + { + ; + } + } + else + {/* յATSȡɢһϢDZڣʱж */ + chFunRtn = SystemOverTimeCheck(strMsgFst->dwCycle, CONFIRM_TIMEOUT_CC); + if (CI_TIME_OUT == chFunRtn) + { + ClearAtsEaMsgFirst(); + } + else + { + ; + } + } +} + +/** +* @brief ɢȡ +* @param +* @return +*/ +static void EaAtsCancleSnd(void) +{ + AtsEaMsgStru * strMsgFst = NULL; + AtsEaMsgStru * strMsgSnd = NULL; + AtsMsgCfmStru * strCfmFst = NULL; + AtsMsgCfmStru * strCfmSnd = NULL; + UINT32 dwCycle = 0u; + UINT8 chLocalId = 0u; + UINT8 chFlag = FLAG_UNSET; + UINT8 szCrcTmp[1024] = { 0u }; + UINT32 ii = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT32 dwCrc = 0u; + UINT16 wTrainId = 0u; + UINT16 wTrainLgcId = 0u; + UINT8 chEaIndex = 0u; + UINT8 chEaCmdState = 0U;/*ɢ״̬*/ + + chLocalId = GetSystemParaLocalCiId(); + dwCycle = Get2oo2CurCycleNum(); + + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsEaMsgFst(); + strMsgSnd = GetAtsEaMsgSnd(); + strCfmFst = GetAtsEaCfmFst(); + strCfmSnd = GetAtsEaCfmSnd(); + + if (strMsgSnd->dwCycle == dwCycle) + { + strCfmSnd->chFlag = FLAG_SET; + strCfmSnd->chTiocId = chLocalId; + strCfmSnd->chStation = strMsgSnd->chStation; + strCfmSnd->chIndex = strMsgSnd->chIndex; + strCfmSnd->dwTime = dwCycle; + + if (FLAG_SET != strMsgFst->chFlag) + {/* δִ״ȡ */ + strCfmSnd->chOpStatus = CONFIRM_EA_SECOND_FIRST; + chFlag = FLAG_SET; + } + else if (strMsgSnd->dwEaTrainId != strMsgFst->dwEaTrainId) + {/* ATSгIDͬ */ + strCfmSnd->chOpStatus = CONFIRM_SECOND_EA_TRAINID; + chFlag = FLAG_SET; + } + else if ((strMsgSnd->chAtsId != strMsgFst->chAtsId) + || (strMsgSnd->chStation != strMsgFst->chStation) + || (strMsgSnd->chIndex != strMsgFst->chIndex) + || (strMsgSnd->chType != strMsgFst->chType) + || (strMsgSnd->chLine != strMsgFst->chLine)) + { + /* ATS벻һ£δ֪ */ + strCfmSnd->chOpStatus = CONFIRM_UNKNOWN; + chFlag = FLAG_SET; + } + else + { + /**/ + ; + } + + if (FLAG_UNSET == chFlag) + { + szCrcTmp[ii] = strMsgSnd->chTiocId; + ii++; + LongToChar(strCfmFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii] = strMsgSnd->chType; + ii++; + szCrcTmp[ii] = strMsgSnd->chLine; + ii++; + dwCrc = Tioc_CommonCrc32(szCrcTmp, ii); + if (dwCrc != strMsgSnd->dwCrc32) + { + /* CRC32ATSϢCRC32һ */ + strCfmSnd->chOpStatus = CONFIRM_EA_SECOND_CRC; + chFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + if (FLAG_UNSET == chFlag) + { + chFunRtn = dquHlhtId2VobcName(strMsgSnd->dwEaTrainId, &wTrainId, &wTrainLgcId); + chEaCmdState = GetTrainEaCmdState(wTrainId); + if (TRAIN_EA_CMD_STATE_INVALID != chEaCmdState) + { + /* гǰɢ״̬ */ + strCfmSnd->chOpStatus = CONFIRM_FIRST_EING; + chFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + ii = 0u; + szCrcTmp[ii++] = strMsgSnd->chAtsId; + szCrcTmp[ii++] = strMsgSnd->chStation; + szCrcTmp[ii++] = strMsgSnd->chIndex; + LongToChar(strMsgSnd->dwEaTrainId, &szCrcTmp[ii]); + ii += 4u; + LongToChar(strMsgFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + LongToChar(strMsgSnd->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii++] = strMsgSnd->chType; + szCrcTmp[ii++] = strMsgSnd->chLine; + strCfmSnd->dwCrc32 = Tioc_CommonCrc32(szCrcTmp, ii); + if (FLAG_UNSET == chFlag) + {/* ͨȷϳɹ */ + chFunRtn = dquHlhtId2VobcName(strMsgSnd->dwEaTrainId, &wTrainId, &wTrainLgcId); + if (CI_SUCCESS == chFunRtn) + { + chEaIndex = PaGetIndex(wTrainId, PA_TYPE_EA); + strCfmSnd->chOpStatus = CONFIRM_SECOND_SUCCESS; + EaAtsCancleExc(chEaIndex); + } + else + { + ; /* */ + } + } + else + { + ; + } + } + else + { + ; /** DZϢ */ + } + ClearAtsEaMsgFirst(); + ClearAtsEaMsgSecond(); + +} + +/** +* @brief ɢȡִ +* @param const UINT8 chEaIndex ID +* @return +* by cgh 20240321 +*/ +static void EaAtsCancleExc(const UINT8 chEaIndex) +{ + UINT8 chIndex = 0U; + UINT8 chPaType = 0U;/**/ + AtsEaMsgStru* strEaMsgSnd = NULL;/*ATSRCɢȡϢ*/ + AtsDaMsgStru* strDaMsgSnd = NULL;/*ATSRCѹȡϢ*/ + UINT8 chAtsMsgLine = 0U;/*ATSRCɢȡϢ·*/ + UINT8 chEaAreaLineType = 0U;/*ش洢ɢ·*/ + UINT8 chEaLinkSum = 0U;/*LINKĿ*/ + UINT16* szEaLinkIdBuf = NULL;/*LINK*/ + UINT8 ii = 0U; + UINT16 wLinkLineType = 0U;/*LINK·*/ + UINT16 szTempLinkId[EA_SECTION_MAX_NUM] = {0U};/*LINKʱ*/ + UINT8 chTempLinkSum = 0U;/*LINKʱĿ*/ + + + if ((EA_MAX_NUM > chEaIndex) && (0u < g_eaNum) && (chEaIndex < g_eaNum)) + { + strEaMsgSnd = GetAtsEaMsgSnd(); + strDaMsgSnd = GetAtsDaMsgSnd(); + chEaAreaLineType = GetEaAreaLineType(chEaIndex); + chPaType = GetPaTypeByIndex(chEaIndex); + if (PA_TYPE_DA == chPaType) + { + chAtsMsgLine = strDaMsgSnd->chLine; + } + else if (PA_TYPE_EA == chPaType) + { + chAtsMsgLine = strEaMsgSnd->chLine; + } + else + { + ; /*ȻֵATSȡ·ԣʱΪ0治ִ*/ + } + + if (0U != chAtsMsgLine) + { + if ((chAtsMsgLine == chEaAreaLineType) || (EA_AREA_ALL == chAtsMsgLine)) + { + /*ATS·ĺͱش洢ͬATS·ΪоȡֱӦķ*/ + for (chIndex = chEaIndex; chIndex < g_eaNum - 1u; chIndex++) + {/* ԱǰŲ */ + g_szEaData[chIndex] = g_szEaData[chIndex + 1u]; + } + + (void)CommonMemSet((void*)&g_szEaData[chIndex], (UINT32)sizeof(EaDataStru), (UINT8)0U, (UINT32)sizeof(EaDataStru));/* */ + g_eaNum--; + } + else + { + /*˴˴ǰ洢·һFFATSһ55/AA*/ + chEaLinkSum = EaGetLinkNum(chEaIndex); + szEaLinkIdBuf = EaGetLinkId(chEaIndex); + + for (ii = 0U; ii < chEaLinkSum; ii++) + { + wLinkLineType = GetLinkLineById(szEaLinkIdBuf[ii]); + if (chAtsMsgLine == wLinkLineType) + { + /*Ҫ޳ʱLINK*/ + } + else + { + /**/ + szTempLinkId[chTempLinkSum] = szEaLinkIdBuf[ii]; + chTempLinkSum++; + } + } + /*ݸֵط洢*/ + g_szEaData[chEaIndex].strLinkInfo.chObjNum = chTempLinkSum; + + (void)CommonMemCpy((void*)(&g_szEaData[chEaIndex].strLinkInfo.szObjId), (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM), (void*)(&szTempLinkId), (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM)); + if (0U == chTempLinkSum) + { + (void)CommonMemSet((void*)&g_szEaData[chEaIndex], (UINT32)sizeof(EaDataStru), (UINT8)0U, (UINT32)sizeof(EaDataStru));/* */ + g_eaNum--; + } + else + { + /*ǰڷϢ·*/ + ClearEaSecData(chEaIndex); + } + + debug_infor_printf((const)"EaAtsCancleExc after message:\n"); + + debug_infor_printf((const)"PaLineType: %d\n", g_szEaData[chEaIndex].chEaAreaLinkType); + + debug_infor_printf((const)"PaAcSeq:num = %d",g_szEaData[chEaIndex].strAcInfo.chObjNum); + debug_out_array(0xAA, g_szEaData[chEaIndex].strAcInfo.szObjId, g_szEaData[chEaIndex].strAcInfo.chObjNum * 2u); + + debug_infor_printf((const)"PaLinkSeq:num = %d",g_szEaData[chEaIndex].strLinkInfo.chObjNum); + debug_out_array(0xAA, g_szEaData[chEaIndex].strLinkInfo.szObjId, g_szEaData[chEaIndex].strLinkInfo.chObjNum * 2u); + + debug_infor_printf((const)"PaLgcSeq:num = %d",g_szEaData[chEaIndex].strLgcInfo.chObjNum); + debug_out_array(0xAA, g_szEaData[chEaIndex].strLgcInfo.szObjId, g_szEaData[chEaIndex].strLgcInfo.chObjNum * 2u); + } + } + else + { + ; /*ȡ*/ + } + + } + else + { + ; + } +} + +/** +* @brief ȡָɢ +* @param const UINT8 chEaIndex ID +* @return +* by cgh 20240321 +*/ +static void EaCancleExc(const UINT8 chEaIndex) +{ + UINT8 chIndex = 0U; + + if ((EA_MAX_NUM > chEaIndex) && (0u < g_eaNum) && (chEaIndex < g_eaNum)) + { + for (chIndex = chEaIndex; chIndex < g_eaNum - 1u; chIndex++) + {/* ԱǰŲ */ + if (chIndex < EA_MAX_NUM - 1U) + { + g_szEaData[chIndex] = g_szEaData[chIndex + 1u]; + } + else + { + ; /*ʵʲԽ磬Ϊg_eaNumֵ20,Ϊ˱淶*/ + } + } + + (void)CommonMemSet((void*)&g_szEaData[chIndex], (UINT32)sizeof(EaDataStru), (UINT8)0U, (UINT32)sizeof(EaDataStru));/* */ + g_eaNum--; + } + else + { + ; + } +} + +/* +* ȡɢ +* ˵ pData ݵַ +* dwIndex +* ֵ д +*/ +UINT32 GetEaTransferData(UINT8* pData, UINT32 dwIndex) +{ + UINT32 dwRetVal = 0u; + UINT8 ii = 0u; + UINT8 jj = 0u; + + dwRetVal = dwIndex; + + if ((NULL != pData) && (UINT32_MAX >= dwIndex)) + { + /* */ + pData[dwRetVal] = g_eaNum; + dwRetVal++; + + for (ii = 0u; ii < g_eaNum; ii++) + { + /* ɢгID */ + ShortToChar(g_szEaData[ii].wTrainId, &pData[dwRetVal]); + dwRetVal += 2u; + + /* ־ */ + pData[dwRetVal] = g_szEaData[ii].chBuildedFlag; + dwRetVal++; + + /* */ + pData[dwRetVal] = g_szEaData[ii].strAcInfo.chObjNum; + dwRetVal++; + for (jj = 0u; jj < g_szEaData[ii].strAcInfo.chObjNum; jj++) + {/* ID */ + ShortToChar(g_szEaData[ii].strAcInfo.szObjId[jj], &pData[dwRetVal]); + dwRetVal += 2u; + } + + /* link */ + pData[dwRetVal] = g_szEaData[ii].strLinkInfo.chObjNum; + dwRetVal++; + for (jj = 0u; jj < g_szEaData[ii].strLinkInfo.chObjNum; jj++) + {/* linkID */ + ShortToChar(g_szEaData[ii].strLinkInfo.szObjId[jj], &pData[dwRetVal]); + dwRetVal += 2u; + } + + /* ߼ */ + pData[dwRetVal] = g_szEaData[ii].strLgcInfo.chObjNum; + dwRetVal++; + for (jj = 0u; jj < g_szEaData[ii].strLgcInfo.chObjNum; jj++) + {/* ߼ID */ + ShortToChar(g_szEaData[ii].strLgcInfo.szObjId[jj], &pData[dwRetVal]); + dwRetVal += 2u; + } + + /* */ + LongToChar(g_szEaData[ii].dwMidLine, &pData[dwRetVal]); + dwRetVal += 4u; + + /* ID */ + pData[dwRetVal] = g_szEaData[ii].chSrcTiocId; + dwRetVal++; + + /* ID */ + pData[dwRetVal] = g_szEaData[ii].chDstTiocId; + dwRetVal++; + + /* ͬ״̬ */ + pData[dwRetVal] = g_szEaData[ii].chDstAllowed; + dwRetVal++; + + /* */ + pData[dwRetVal] = g_szEaData[ii].chPaType; + dwRetVal++; + + /* ɢʽΪվһʱӦķID 복 */ + pData[dwRetVal] = g_szEaData[ii].chEaConfigId; + dwRetVal++; + + /* */ + pData[dwRetVal] = g_szEaData[ii].chEaAreaLinkType; + dwRetVal++; + + /* ں*/ + LongToChar(g_szEaData[ii].dwEaBuildCycNum, &pData[dwRetVal]); + dwRetVal += 4u; + } + + } + else + { + ; + } + + return dwRetVal; +} + +/* +* ɢ +* ˵ pData ݵַ +* dwIndex +* ֵ +*/ +UINT32 SetEaTransferData(UINT8* pData, UINT32 dwIndex) +{ + UINT32 dwRetVal = 0u; + UINT8 ii = 0u; + UINT8 jj = 0u; + + dwRetVal = dwIndex; + + if ((NULL != pData) && (UINT32_MAX >= dwIndex)) + { + /* ɢ */ + g_eaNum = pData[dwRetVal]; + dwRetVal++; + + for (ii = 0u; ii < g_eaNum; ii++) + { + /* ɢгID */ + g_szEaData[ii].wTrainId = ShortFromChar(&pData[dwRetVal]); + dwRetVal += 2u; + + /* ־ */ + g_szEaData[ii].chBuildedFlag = pData[dwRetVal]; + dwRetVal++; + + /* Ϣ */ + g_szEaData[ii].strAcInfo.chObjNum = pData[dwRetVal]; + dwRetVal++; + for (jj = 0u; jj < g_szEaData[ii].strAcInfo.chObjNum; jj++) + { + g_szEaData[ii].strAcInfo.szObjId[jj] = ShortFromChar(&pData[dwRetVal]); + dwRetVal += 2u; + } + + /* linkϢ */ + g_szEaData[ii].strLinkInfo.chObjNum = pData[dwRetVal]; + dwRetVal++; + for (jj = 0u; jj < g_szEaData[ii].strLinkInfo.chObjNum; jj++) + { + g_szEaData[ii].strLinkInfo.szObjId[jj] = ShortFromChar(&pData[dwRetVal]); + dwRetVal += 2u; + } + + /* ߼Ϣ */ + g_szEaData[ii].strLgcInfo.chObjNum = pData[dwRetVal]; + dwRetVal++; + for (jj = 0u; jj < g_szEaData[ii].strLgcInfo.chObjNum; jj++) + { + g_szEaData[ii].strLgcInfo.szObjId[jj] = ShortFromChar(&pData[dwRetVal]); + dwRetVal += 2u; + } + + /* */ + g_szEaData[ii].dwMidLine = LongFromChar(&pData[dwRetVal]); + dwRetVal += 4u; + + /* */ + g_szEaData[ii].chSrcTiocId = pData[dwRetVal]; + dwRetVal++; + + /* */ + g_szEaData[ii].chDstTiocId = pData[dwRetVal]; + dwRetVal++; + + /* ͬ״̬ */ + g_szEaData[ii].chDstAllowed = pData[dwRetVal]; + dwRetVal++; + + /* */ + g_szEaData[ii].chPaType = pData[dwRetVal]; + dwRetVal++; + + /* ɢʽΪվһʱӦķID 복 */ + g_szEaData[ii].chEaConfigId = pData[dwRetVal]; + dwRetVal++; + + /* */ + g_szEaData[ii].chEaAreaLinkType = pData[dwRetVal]; + dwRetVal++; + + /* ں */ + g_szEaData[ii].dwEaBuildCycNum = LongFromChar(&pData[dwRetVal]); + dwRetVal += 4u; + } + } + else + { + ; + } + + return dwRetVal; +} + +/* +* жξΪ +* ˵ chEaIndex ɢ +* ֵ CI_SUCCESS:ȫڱCI_ERROR:ȫڱ +*/ +static UINT8 EaIsLinkSeqAllLocal(UINT8 chEaIndex) +{ + UINT8 chLocalId = 0u; + UINT16 wLinkTiocId = 0u; + UINT8 chLinkIndex = 0u; + UINT8 chRtn = CI_ERROR; + + chLocalId = GetSystemParaLocalCiId(); + for (chLinkIndex = 0u; chLinkIndex < g_szEaData[chEaIndex].strLinkInfo.chObjNum; chLinkIndex++) + { + wLinkTiocId = GetLinkManageTiocById(g_szEaData[chEaIndex].strLinkInfo.szObjId[chLinkIndex]); + if (wLinkTiocId != chLocalId) + { + break; + } + else + { + ; + } + } + + if (chLinkIndex == g_szEaData[chEaIndex].strLinkInfo.chObjNum) + { + chRtn = CI_SUCCESS; + } + else + { + chRtn = CI_ERROR; + } + + return chRtn; +} + +/** +* @brief ȡָTIOC +* @param chIndex ± +* @return TIOC +*/ +UINT8 GetEaSrcTiocByIndex(UINT8 chIndex) +{ + UINT8 rtnValue = 0u; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].chSrcTiocId; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ȡָĿTIOC +* @param chIndex ± +* @return ĿTIOC +*/ +UINT8 GetEaDstTiocByIndex(UINT8 chIndex) +{ + UINT8 rtnValue = 0u; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].chDstTiocId; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ȡָĿTIOCͬʶ +* @param chIndex ± +* @return ĿTIOCͬʶ +*/ +UINT8 GetEaDstAllowedByIndex(UINT8 chIndex) +{ + UINT8 rtnValue = 0u; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].chDstAllowed; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ڿķ +* @param EaDataStru * pEaData ڿķ +* @return +*/ +void EaNeighborUpdata(EaDataStru * pEaDataSt) +{ + UINT8 chEaIndex = 0u; + if (NULL != pEaDataSt) + { + for (chEaIndex = 0u; chEaIndex < g_eaNum; chEaIndex++) + {/* ǰڵķ */ + if ((g_szEaData[chEaIndex].wTrainId == pEaDataSt->wTrainId) && (g_szEaData[chEaIndex].chPaType == pEaDataSt->chPaType) + && (g_szEaData[chEaIndex].chSrcTiocId == pEaDataSt->chSrcTiocId)) + { + break; + } + } + + if (EA_MAX_NUM > g_eaNum) + { + /* ڿ */ + g_szEaData[chEaIndex].wTrainId = pEaDataSt->wTrainId; + g_szEaData[chEaIndex].strLgcInfo.chObjNum = pEaDataSt->strLgcInfo.chObjNum; + if (EA_SECTION_MAX_NUM >= g_szEaData[chEaIndex].strLgcInfo.chObjNum) + { + (void)CommonMemCpy(g_szEaData[chEaIndex].strLgcInfo.szObjId, (UINT32)(sizeof(UINT16) * g_szEaData[chEaIndex].strLgcInfo.chObjNum), pEaDataSt->strLgcInfo.szObjId, (UINT32)(sizeof(UINT16) * g_szEaData[chEaIndex].strLgcInfo.chObjNum)); + } + else + { + /*Ϣڿռ䣬п,崻*/ + SetPlatOverFlag(); + debug_infor_printf((const)"EaNeighborUpdata is to shutdown,because the number of strLgcInfo chObjNum exceeds the limit"); + } + g_szEaData[chEaIndex].chBuildedFlag = pEaDataSt->chBuildedFlag; + g_szEaData[chEaIndex].dwMidLine = pEaDataSt->dwMidLine; + g_szEaData[chEaIndex].chSrcTiocId = pEaDataSt->chSrcTiocId; + g_szEaData[chEaIndex].chDstTiocId = pEaDataSt->chDstTiocId; + g_szEaData[chEaIndex].chPaType = pEaDataSt->chPaType; + g_szEaData[chEaIndex].dwEaBuildCycNum = pEaDataSt->dwEaBuildCycNum; + g_szEaData[chEaIndex].chDstAllowed = EA_DST_ALLOWED_NO; + + if (chEaIndex < g_eaNum) + { + ; + } + else + { + g_eaNum++; + } + } + else + { + SetPlatOverFlag(); + debug_infor_printf((const)"EaNeighborUpdata is to shutdown,because the number of g_eaNum exceeds the limit"); + } + } + else + { + ; + } +} + +/** +* @brief ڿķ +* @param EaDataStru * pEaData ڿķ +* @return +*/ +void EaSetNeighborAllowFlag(UINT16 wTrainId, UINT8 chSrcTioc, UINT8 chDstTioc, UINT8 chFlag, UINT32 dwBuildCyc) +{ + UINT8 chEaIndex = 0u; + UINT32 dwLocalEaBuildCyc = 0U; + for (chEaIndex = 0u; chEaIndex < g_eaNum; chEaIndex++) + {/* ҳָɢг */ + if ((wTrainId == g_szEaData[chEaIndex].wTrainId) && (PA_TYPE_EA == g_szEaData[chEaIndex].chPaType)) + { + break; + } + } + dwLocalEaBuildCyc = EaGetBuildCycNum(chEaIndex); + if (chEaIndex < g_eaNum) + {/* ҵӦɢг */ + if ((g_szEaData[chEaIndex].chSrcTiocId == chSrcTioc) && (g_szEaData[chEaIndex].chDstTiocId == chDstTioc) + &&(dwLocalEaBuildCyc == dwBuildCyc)&& (0U != dwBuildCyc)) + {/* ĿTIOC뱾洢һ ںȷ*/ + g_szEaData[chEaIndex].chDstAllowed = chFlag; + } + else if ((g_szEaData[chEaIndex].chSrcTiocId == chSrcTioc) && (g_szEaData[chEaIndex].chDstTiocId == chDstTioc) + && (dwLocalEaBuildCyc != dwBuildCyc)) + { + g_szEaData[chEaIndex].chDstAllowed = EA_DST_ALLOWED_NO; + debug_infor_printf((const)"Train:%d not allowe build, localBuildCyc%d--desTiocAnsewerCyc:%d\n", wTrainId, dwLocalEaBuildCyc, dwBuildCyc); + } + else + { + ; /**/ + } + } + else + { + ; + } +} + +/* +* TIOCͨãɢ +* ˵ UINT8 chTiocId TIOC +* ֵ +*/ +void NeighborGoodEaProc(UINT8 chTiocId) +{ + UINT8 chEaIndex = 0u; + UINT8 chTransNum = 0u; + UINT16 *pTransIds = NULL; + UINT8 chTransIndex = 0u; + UINT8 *pTransTypes = NULL; + UINT32 *pTransCyc = NULL; + + /* ȡӶӦTIOCȡķϢ */ + chTransNum = GetTiocTransmitEaNum(chTiocId); + pTransIds = GetTiocTransmitEaIds(chTiocId); + pTransTypes = GetTiocTransmitPaTypes(chTiocId); + pTransCyc = GetTiocTransmitPaBuildCyc(chTiocId); + if (0u != g_eaNum) + { + for (chEaIndex = g_eaNum - 1u; 0u <= chEaIndex; chEaIndex--) + {/* ط */ + if (g_szEaData[chEaIndex].chSrcTiocId == chTiocId) + {/* TIOCΪѯTIOC */ + for (chTransIndex = 0u; chTransIndex < chTransNum; chTransIndex++) + { + if ((g_szEaData[chEaIndex].wTrainId == pTransIds[chTransIndex]) + && (g_szEaData[chEaIndex].chPaType == pTransTypes[chTransIndex]) + &&(g_szEaData[chEaIndex].dwEaBuildCycNum == pTransCyc[chTransIndex])) + { + break; + } + else + { + ; + } + } + + if (chTransIndex == chTransNum) + {/* δڽӿҵ */ + EaCancleExc(chEaIndex); + } + else + { + ; + } + } + else + { + ; + } + + if (0u == chEaIndex) + { + break; + } + else + { + ; + } + } + } + else + { + ; + } +} + +/** +* @brief жlinkǷڷ +* @param const UINT16 wLinkId link +* @return CI_ERROR:linkڷڣCI_SUCCESS:linkڷ +*/ +UINT8 IsLinkInEa(const UINT16 wLinkId) +{ + UINT8 chEaIndex = 0u; + UINT8 chLinkIndex = 0u; + UINT8 chRtn = CI_ERROR; + for (chEaIndex = 0u; chEaIndex < g_eaNum; chEaIndex++) + { + for (chLinkIndex = 0u; chLinkIndex < g_szEaData[chEaIndex].strLinkInfo.chObjNum; chLinkIndex++) + { + if (wLinkId == g_szEaData[chEaIndex].strLinkInfo.szObjId[chLinkIndex]) + { + break; + } + } + if (chLinkIndex < g_szEaData[chEaIndex].strLinkInfo.chObjNum) + { + break; + } + } + + if (chEaIndex < g_eaNum) + { + chRtn = CI_ERROR; + } + else + { + chRtn = CI_SUCCESS; + } + + return chRtn; +} + +/** +* @brief ѹȡ +* @param +* @return +*/ +void DaAtsCancleProc(void) +{ + AtsDaMsgStru * strMsgFst = NULL; + AtsDaMsgStru * strMsgSnd = NULL; + strMsgFst = GetAtsDaMsgFst(); + strMsgSnd = GetAtsDaMsgSnd(); + + if ((NULL == strMsgFst) || (NULL == strMsgSnd)) + { + ; + } + else + { + if ((strMsgFst->chFlag != FLAG_SET) && (strMsgSnd->chFlag != FLAG_SET)) + { + ; /* ûϢʲôҲ */ + } + else if ((strMsgFst->chFlag == FLAG_SET) && (strMsgSnd->chFlag != FLAG_SET)) + {/* ȡѹһϢ */ + DaAtsCancleFst(); + } + else + {/* ȡѹϢ */ + DaAtsCancleSnd(); + } + } +} + +/** +* @brief ȡѹ״δ +* @param +* @return +*/ +void DaAtsCancleFst(void) +{ + AtsDaMsgStru * strMsgFst = NULL; + AtsMsgCfmStru * strCfmFst = NULL; + UINT32 dwCycle = 0U; + UINT8 chLocalId = 0U; + UINT8 chRtn = CI_ERROR; + UINT8 szCrcTmp[1024] = { 0U }; + UINT32 ii = 0U; + UINT8 chFunRtn = CI_TIME_OUT; + UINT16 wTrainId = 0U; + UINT16 wTrainLgcId = 0U; + UINT8 chPaIndex = 0U; + UINT8 chDerailment = 0U; + UINT8 chEaAreaLinkType = 0U;/*·*/ + + chLocalId = GetSystemParaLocalCiId(); + dwCycle = Get2oo2CurCycleNum(); + + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsDaMsgFst(); + strCfmFst = GetAtsDaCfmFst(); + + if (strMsgFst->dwCycle == dwCycle) + { + strCfmFst->chFlag = FLAG_SET; + strCfmFst->chTiocId = chLocalId; + strCfmFst->chStation = strMsgFst->chStation; + strCfmFst->chIndex = strMsgFst->chIndex; + strCfmFst->dwTime = dwCycle; + + chRtn = dquHlhtId2VobcName(strMsgFst->dwDaTrainId, &wTrainId, &wTrainLgcId); + + if (CI_ERROR == chRtn) + {/* ȡгIDδ֪ */ + strCfmFst->chOpStatus = CONFIRM_DA_FST_UNKNOWN; + ClearAtsDaMsgFirst(); + } + else + { + chPaIndex = PaGetIndex(wTrainId, PA_TYPE_DA); + if (chPaIndex == g_eaNum) + {/* ѹδ */ + strCfmFst->chOpStatus = CONFIRM_DA_FST_UNSET; + } + else + { + chDerailment = GetTrainDerailment(wTrainId); + if (TRAIN_DERAIL_NO != chDerailment) + {/* гǰѹ״̬ */ + strCfmFst->chOpStatus = CONFIRM_DA_FST_DERAIL; + } + else + { + chEaAreaLinkType = GetEaAreaLineType(chPaIndex); + if ((EA_AREA_ALL != strMsgFst->chLine) && (EA_AREA_ALL != chEaAreaLinkType) && (chEaAreaLinkType != strMsgFst->chLine)) + { + /*ATS··Ժͱش洢·෴ʱҪط*/ + strCfmFst->chOpStatus = CONFIRM_EALINE_DIFFERENT; + } + else + { + strCfmFst->chOpStatus = CONFIRM_DA_FST_SUCCESS; + } + } + } + } + + szCrcTmp[ii] = strMsgFst->chAtsId; + ii++; + szCrcTmp[ii] = strMsgFst->chStation; + ii++; + szCrcTmp[ii] = strMsgFst->chIndex; + ii++; + LongToChar(strMsgFst->dwDaTrainId, &szCrcTmp[ii]); + ii += 4u; + LongToChar(strMsgFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii] = strMsgFst->chType; + ii++; + szCrcTmp[ii] = strMsgFst->chLine; + ii++; + strCfmFst->dwCrc32 = Tioc_CommonCrc32(szCrcTmp, ii); /* ATSšվšվšгͨID·ʱ䡢͡CRC */ + + if (CONFIRM_DA_FST_SUCCESS != strCfmFst->chOpStatus) + { + ClearAtsDaMsgFirst(); + } + else + { + ; + } + } + else + {/* յATSȡɢһϢDZڣʱж */ + chFunRtn = SystemOverTimeCheck(strMsgFst->dwCycle, CONFIRM_TIMEOUT_CC); + if (CI_TIME_OUT == chFunRtn) + { + ClearAtsDaMsgFirst(); + } + else + { + ; + } + } + +} + +/** +* @brief ȡѹδ +* @param +* @return +*/ +void DaAtsCancleSnd(void) +{ + AtsDaMsgStru * strMsgFst = NULL; + AtsDaMsgStru * strMsgSnd = NULL; + AtsMsgCfmStru * strCfmFst = NULL; + AtsMsgCfmStru * strCfmSnd = NULL; + UINT32 dwCycle = 0u; + UINT8 chLocalId = 0u; + UINT8 chFlag = FLAG_UNSET; + UINT8 szCrcTmp[1024] = { 0u }; + UINT32 ii = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT32 dwCrc = 0u; + UINT16 wTrainId = 0u; + UINT16 wTrainLgcId = 0u; + UINT8 chPaIndex = 0u; + UINT8 chDerailment = 0u; + + chLocalId = GetSystemParaLocalCiId(); + dwCycle = Get2oo2CurCycleNum(); + + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsDaMsgFst(); + strMsgSnd = GetAtsDaMsgSnd(); + strCfmFst = GetAtsDaCfmFst(); + strCfmSnd = GetAtsDaCfmSnd(); + + if (strMsgSnd->dwCycle == dwCycle) + { + strCfmSnd->chFlag = FLAG_SET; + strCfmSnd->chTiocId = chLocalId; + strCfmSnd->chStation = strMsgSnd->chStation; + strCfmSnd->chIndex = strMsgSnd->chIndex; + strCfmSnd->dwTime = dwCycle; + + if (FLAG_SET != strMsgFst->chFlag) + {/* δִ״ȡ */ + strCfmSnd->chOpStatus = CONFIRM_DA_SND_FIRST; + chFlag = FLAG_SET; + } + else if (strMsgSnd->dwDaTrainId != strMsgFst->dwDaTrainId) + {/* ATSгIDͬ */ + strCfmSnd->chOpStatus = CONFIRM_DA_SND_DIFF; + chFlag = FLAG_SET; + } + else if ((strMsgSnd->chAtsId != strMsgFst->chAtsId) + || (strMsgSnd->chStation != strMsgFst->chStation) + || (strMsgSnd->chIndex != strMsgFst->chIndex) + || (strMsgSnd->chType != strMsgFst->chType) + || (strMsgSnd->chLine != strMsgFst->chLine) + ) + {/* ATS벻һ£δ֪ */ + strCfmSnd->chOpStatus = CONFIRM_DA_SND_UNKNOWN; + chFlag = FLAG_SET; + } + else + { + /**/ + ; + } + + if (FLAG_UNSET == chFlag) + { + szCrcTmp[ii] = strMsgSnd->chTiocId; + ii++; + LongToChar(strCfmFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii] = strMsgSnd->chType; + ii++; + szCrcTmp[ii] = strMsgSnd->chLine; + ii++; + dwCrc = Tioc_CommonCrc32(szCrcTmp, ii); + if (dwCrc != strMsgSnd->dwCrc32) + { + /* CRC32ATSϢCRC32һ */ + strCfmSnd->chOpStatus = CONFIRM_DA_SND_CRC; + chFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + if (FLAG_UNSET == chFlag) + { + chFunRtn = dquHlhtId2VobcName(strMsgSnd->dwDaTrainId, &wTrainId, &wTrainLgcId); + chDerailment = GetTrainDerailment(wTrainId); + if (TRAIN_DERAIL_NO != chDerailment) + { + /* гǰѹ״̬ */ + strCfmSnd->chOpStatus = CONFIRM_DA_SND_DERAIL; + chFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + ii = 0u; + szCrcTmp[ii++] = strMsgSnd->chAtsId; + szCrcTmp[ii++] = strMsgSnd->chStation; + szCrcTmp[ii++] = strMsgSnd->chIndex; + LongToChar(strMsgSnd->dwDaTrainId, &szCrcTmp[ii]); + ii += 4u; + LongToChar(strMsgFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + LongToChar(strMsgSnd->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii++] = strMsgSnd->chType; + szCrcTmp[ii++] = strMsgSnd->chLine; + strCfmSnd->dwCrc32 = Tioc_CommonCrc32(szCrcTmp, ii); + if (FLAG_UNSET == chFlag) + {/* ͨȷϳɹ */ + strCfmSnd->chOpStatus = CONFIRM_DA_SND_SUCCESS; + chPaIndex = PaGetIndex(wTrainId, PA_TYPE_DA); + EaAtsCancleExc(chPaIndex); + } + else + { + ; + } + } + else + { + ; /** DZϢ */ + } + ClearAtsDaMsgFirst(); + ClearAtsDaMsgSecond(); + +} + +/** +* @brief ȡָ +* @param chIndex ± +* @return +*/ +UINT8 GetPaTypeByIndex(UINT8 chIndex) +{ + UINT8 rtnValue = 0u; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].chPaType; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ȡӦݱID +* @param chIndex ± +* @return ID +*/ +UINT8 GetEaConfigID(UINT8 chIndex) +{ + UINT8 rtnValue = 0u; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].chEaConfigId; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ȡlink +* @param const UINT8 chIndex +* @return link +*/ +UINT8 EaGetLinkNum(const UINT8 chIndex) +{ + UINT8 chRtn = 0u; + if (EA_MAX_NUM > chIndex) + { + chRtn = g_szEaData[chIndex].strLinkInfo.chObjNum; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡlink +* @param const UINT8 chIndex +* @return link +*/ +UINT16 * EaGetLinkId(const UINT8 chIndex) +{ + UINT16 * pRtn = NULL; + if (EA_MAX_NUM > chIndex) + { + pRtn = g_szEaData[chIndex].strLinkInfo.szObjId; + } + else + { + ; + } + return pRtn; +} + +/** +* @brief ȡ +* @param const UINT8 chIndex +* @return +*/ +UINT8 EaGetAcNum(const UINT8 chIndex) +{ + UINT8 chRtn = 0u; + if (EA_MAX_NUM > chIndex) + { + chRtn = g_szEaData[chIndex].strAcInfo.chObjNum; + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡα +* @param const UINT8 chIndex +* @return α +*/ +UINT16 * EaGetAcId(const UINT8 chIndex) +{ + UINT16 * pRtn = NULL; + if (EA_MAX_NUM > chIndex) + { + pRtn = g_szEaData[chIndex].strAcInfo.szObjId; + } + else + { + ; + } + return pRtn; +} + +/** +* @brief ж߼Ƿڷ +* @param const UINT16 wLgcId ߼α +* @return CI_ERROR:߼δڷڣCI_SUCCESS:߼βڷ +*/ +UINT8 IsLgcInEa(const UINT16 wLgcId) +{ + UINT8 chEaIndex = 0u; + UINT8 chLgcIndex = 0u; + UINT8 chRtn = CI_ERROR; + for (chEaIndex = 0u; chEaIndex < g_eaNum; chEaIndex++) + { + for (chLgcIndex = 0u; chLgcIndex < g_szEaData[chEaIndex].strLgcInfo.chObjNum; chLgcIndex++) + { + if (wLgcId == g_szEaData[chEaIndex].strLgcInfo.szObjId[chLgcIndex]) + { + break; + } + } + if (chLgcIndex < g_szEaData[chEaIndex].strLgcInfo.chObjNum) + { + break; + } + } + + if (chEaIndex < g_eaNum) + { + chRtn = CI_ERROR; + } + else + { + chRtn = CI_SUCCESS; + } + + return chRtn; +} + +/** +* @brief ȡг洢 +* @param const UINT16 wTrainId +* @param const UINT8 chType +* @return ɹ:ʧ:g_eaNum +*/ +static UINT8 PaGetIndex(const UINT16 wTrainId, const UINT8 chType) +{ + UINT8 chIndex = 0u; + UINT8 chLocalId = GetSystemParaLocalCiId(); + for (chIndex = 0u; chIndex < g_eaNum; chIndex++) + { + if ((wTrainId == g_szEaData[chIndex].wTrainId) && (g_szEaData[chIndex].chSrcTiocId == chLocalId) + && (chType == g_szEaData[chIndex].chPaType)) + { + break; + } + else + { + ; /* */ + } + } + + return chIndex; +} + + +/* +* ǷΪ +* ˵const UINT16 wAxisSecId ID +* const UINT8 chSetAreaType +* const UINT16 wTrainId гID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +* by cgh 20240105 +*/ +UINT8 AxisSecAddProAreaCheck(const UINT16 wAxisSecId,const UINT8 chSetAreaType,const UINT16 wTrainId) +{ + UINT8 chReval = CI_SUCCESS;/*ȫҪͨ*/ + UINT8 chEvacuateRelDirSwitch = 0U;/*ɢп*/ + UINT8 chTgRelDirSwitch = 0U; /*ѹп*/ + UINT16 wMaxHeadLink = 0U;/*гǰLINK*/ + UINT8 chTrainLinkLine = 0U;/*гLINK·*/ + UINT8 chAxisLinkTgEvacuateDir = 0U;/*LINKѹ켰ɢ·*/ + UINT16* wAxisIncLinkBuf = NULL;/*ΰLINK*/ + + if ((0U < wAxisSecId) && (AXIS_SECTION_SUM_MAX > wAxisSecId) + && ((PA_TYPE_DA == chSetAreaType) || (PA_TYPE_EA == chSetAreaType)) + && (((0U < wTrainId) && (TRAIN_SUM_MAX > wTrainId)) || ((TRAIN_ID_MIN < wTrainId) && (TRAIN_ID_MAX > wTrainId)))) + { + wAxisIncLinkBuf = EaGetAcLinkId(wAxisSecId); + + if (NULL != wAxisIncLinkBuf) + { + chAxisLinkTgEvacuateDir = GetLinkTgEvacuateDir(wAxisIncLinkBuf[0]); + + if (LINK_TGEVACUATEDIR_ALL == chAxisLinkTgEvacuateDir) + { + /*ζӦLINKѹ켰ɢ·ΪоֱӴ˼,ٽзͼж*/ + chReval = CI_SUCCESS; + } + else if((LINK_TGEVACUATEDIR_UP == chAxisLinkTgEvacuateDir) || (LINK_TGEVACUATEDIR_DOWN == chAxisLinkTgEvacuateDir)) + { + chEvacuateRelDirSwitch = GetCiFunctionSwitchConfig(FUNC_EVACUATE_RELATE_DIR_SWITCH); + chTgRelDirSwitch = GetCiFunctionSwitchConfig(FUNC_TG_RELATE_DIR_SWITCH); + + if ((FUNC_SWITCH_OFF == chEvacuateRelDirSwitch) && (FUNC_SWITCH_OFF == chTgRelDirSwitch)) + { + /*2ؾΪرգֱӴ˼,ٽзж*/ + chReval = CI_SUCCESS; + } + else + { + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); + chTrainLinkLine = GetLinkTgEvacuateDir(wMaxHeadLink); + + if (((PA_TYPE_EA == chSetAreaType) && (FUNC_SWITCH_ON == chEvacuateRelDirSwitch)) + || ((PA_TYPE_DA == chSetAreaType) && (FUNC_SWITCH_ON == chTgRelDirSwitch))) + { + if (LINK_TGEVACUATEDIR_ALL == chTrainLinkLine) + { + /*гǰLINKѹ켰ɢΪֱ*/ + chReval = CI_SUCCESS; + } + else if ((LINK_TGEVACUATEDIR_UP == chTrainLinkLine) || (LINK_TGEVACUATEDIR_DOWN == chTrainLinkLine)) + { + /*ɢҪ*/ + if (chAxisLinkTgEvacuateDir == chTrainLinkLine) + { + /*ζӦLINKѹ켰ɢ·гǰLINK·ͬ*/ + chReval = CI_SUCCESS; + } + else + { + chReval = CI_ERROR;/*Բͬ*/ + } + } + else + { + chReval = CI_SUCCESS; /*ݷǷ*/ + } + } + else + { + chReval = CI_SUCCESS; + } + } + } + else + { + chReval = CI_SUCCESS; /*ݷǷ*/ + } + } + else + { + chReval = CI_SUCCESS; /*ݷǷ*/ + } + } + else + { + chReval = CI_SUCCESS; /*У鲻ͨ*/ + } + + return chReval; +} + +/** +* @brief ȡ +* @param chIndex ± +* @return EA_AREA_UP +* EA_AREA_DOWN +* EA_AREA_ALL к +* by cgh 20240321 +*/ +UINT8 GetEaAreaLineType(UINT8 chIndex) +{ + UINT8 rtnValue = EA_AREA_ALL; + + if (EA_MAX_NUM > chIndex) + { + rtnValue = g_szEaData[chIndex].chEaAreaLinkType; + } + else + { + ; + } + + return rtnValue; +} + +/** +* @brief ڱȡϢ +* @param const UINT8 chEaIndex ID +* @return +* by cgh 20240326 +*/ +void ClearEaSecData(const UINT8 chEaIndex) +{ + UINT8 chEaSecIndex = 0U;/*ѭ*/ + UINT8 chEaTempIndex = 0U;/*ʱѭ*/ + UINT8 chLgcIndex = 0U;/*߼*/ + UINT16 szTempAxisSecId[EA_SECTION_MAX_NUM] = { 0U };/*ʱ*/ + UINT8 chTempAxisSecSum = 0U;/*ʱĿ*/ + UINT16 szTempLogSecId[EA_SECTION_MAX_NUM] = { 0U };/*߼ʱ*/ + UINT8 chTempLogSecSum = 0U;/*߼ʱĿ*/ + UINT8 chLinkNum = 0U;/*LINKĿ*/ + UINT16* pLinkIdBuff = NULL;/*LINK*/ + UINT8 chLgcNum = 0U;/*߼Ŀ*/ + UINT16* pLgcIdBuff =NULL;/*߼*/ + UINT8 ii = 0U; + UINT8 chFindFlag = CI_ERROR; + UINT8 chCheckFlag = CI_ERROR; + UINT16 wTempLinkLineType = 0U;/*ʱLINK·*/ + UINT16 wLinkLineType = 0U;/*LINK·*/ + + if ((EA_MAX_NUM > chEaIndex) && (0U < g_eaNum) && (chEaIndex < g_eaNum)) + { + chCheckFlag = CI_SUCCESS; + for (chEaSecIndex = 0U; chEaSecIndex < g_szEaData[chEaIndex].strAcInfo.chObjNum; chEaSecIndex++) + { + chFindFlag = CI_ERROR; + chLinkNum = EaGetAcLinkNum(g_szEaData[chEaIndex].strAcInfo.szObjId[chEaSecIndex]); + pLinkIdBuff = EaGetAcLinkId(g_szEaData[chEaIndex].strAcInfo.szObjId[chEaSecIndex]); + if ((0U == chLinkNum) || (NULL == pLinkIdBuff)) + { + szTempAxisSecId[chTempAxisSecSum] = g_szEaData[chEaIndex].strAcInfo.szObjId[chEaSecIndex]; + chTempAxisSecSum++; + } + else + { + for (ii = 0U; ii < chLinkNum; ii++) + { + for (chEaTempIndex = 0U; chEaTempIndex < g_szEaData[chEaIndex].strLinkInfo.chObjNum; chEaTempIndex++) + { + if (pLinkIdBuff[ii] == g_szEaData[chEaIndex].strLinkInfo.szObjId[chEaTempIndex]) + { + /*ӦLINKĿǰڷдڣ˼*/ + chFindFlag = CI_SUCCESS; + break; + } + else + { + ; + } + } + if (CI_SUCCESS == chFindFlag) + { + break; + } + } + + if (CI_SUCCESS == chFindFlag) + { + szTempAxisSecId[chTempAxisSecSum] = g_szEaData[chEaIndex].strAcInfo.szObjId[chEaSecIndex]; + chTempAxisSecSum++; + } + else + { + ; /*˵ѱȡ*/ + } + } + } + + /* ļ */ + for (chEaSecIndex = 0U; chEaSecIndex < chTempAxisSecSum; chEaSecIndex++) + { + chLgcNum = EaGetAcLgcNum(szTempAxisSecId[chEaSecIndex]); + pLgcIdBuff = EaGetAcLgcId(szTempAxisSecId[chEaSecIndex]); + + if ((0U == chLgcNum) || (NULL == pLgcIdBuff)) + { + chCheckFlag = CI_ERROR; + } + else + {/* а߼ȥؼ¼ */ + for (chEaTempIndex = 0U; chEaTempIndex < chLgcNum; chEaTempIndex++) + { + for (chLgcIndex = 0U; chLgcIndex < chTempLogSecSum; chLgcIndex++) + { + if (pLgcIdBuff[chEaTempIndex] == szTempLogSecId[chLgcIndex]) + { + break; + } + else + { + ; + } + } + if (chLgcIndex == chTempLogSecSum) + { + if (EA_SECTION_MAX_NUM > chTempLogSecSum) + { + szTempLogSecId[chTempLogSecSum] = pLgcIdBuff[chEaTempIndex]; + chTempLogSecSum++; + } + else + { + ; + } + } + else + { + ; + } + } + } + + } + if (CI_SUCCESS == chCheckFlag) + { + /*ζӦ߼зǷı߼Σάֲ*/ + + g_szEaData[chEaIndex].strAcInfo.chObjNum = chTempAxisSecSum; + (void)CommonMemCpy((void*)(&g_szEaData[chEaIndex].strAcInfo.szObjId), (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM), (void*)(&szTempAxisSecId), (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM)); + + g_szEaData[chEaIndex].strLgcInfo.chObjNum = chTempLogSecSum; + (void)CommonMemCpy((void*)(&g_szEaData[chEaIndex].strLgcInfo.szObjId), (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM), (void*)(&szTempLogSecId), (UINT32)(sizeof(UINT16) * EA_SECTION_MAX_NUM)); + + /*LINK·*/ + RefreshEaLineType(chEaIndex); + } + else + { + ; /*ı䣬άֲ*/ + } + } + else + { + + } +} + +/** +* @brief ·· +* @param const UINT8 chEaIndex ID +* @return +* by cgh 20240402 +*/ +void RefreshEaLineType(const UINT8 chEaIndex) +{ + UINT8 chEaTempIndex = 0U; + UINT16 wTempLinkLineType = 0U;/*ʱLINK·*/ + UINT16 wLinkLineType = 0U;/*LINK·*/ + + if (EA_MAX_NUM > chEaIndex) + { + wTempLinkLineType = GetLinkLineById(g_szEaData[chEaIndex].strLinkInfo.szObjId[0]); + /* LINK,ȷ */ + for (chEaTempIndex = 0u; chEaTempIndex < g_szEaData[chEaIndex].strLinkInfo.chObjNum; chEaTempIndex++) + { + wLinkLineType = GetLinkLineById(g_szEaData[chEaIndex].strLinkInfo.szObjId[chEaTempIndex]); + /*ѯѽӦLINK·*/ + + if (wTempLinkLineType == wLinkLineType) + { + ; + } + else + { + /*ֻҪһLINK·Ժͻ׼LINK·Բһ£*/ + break; + } + } + if (g_szEaData[chEaIndex].strLinkInfo.chObjNum == chEaTempIndex) + { + /*LINK·Ծͻ׼LINKһ£ȡ׼LINKΪ*/ + if (EMAP_LINK_LINE_UP == wLinkLineType) + { + g_szEaData[chEaIndex].chEaAreaLinkType = EA_AREA_UP; + } + else if (EMAP_LINK_LINE_DOWN == wLinkLineType) + { + g_szEaData[chEaIndex].chEaAreaLinkType = EA_AREA_DOWN; + } + else + { + g_szEaData[chEaIndex].chEaAreaLinkType = EA_AREA_ALL; + } + } + else + { + g_szEaData[chEaIndex].chEaAreaLinkType = EA_AREA_ALL; + } + } + else + { + + } +} + +/* +* ȡָIDTIOCţɲѯȫ߼ᣩ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: TIOC +*/ +UINT16 GetAxisBelongTiocAllLine(const UINT16 wAcId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = CI_ERROR; + UINT16 wLinkId = 0u; + UINT16 i = 0U; + + if (wAcId < AXIS_SECTION_SUM_MAX) + { + for (i = 0; i < AXIS_SECTION_SUM_MAX; i++) + { + if (wAcId == g_szEaAcConfig[i].AxisSectionId) + { + wLinkId = g_szEaAcConfig[i].szLinkIdBuff[0]; + retVal = GetLinkManageTiocById(wLinkId); + break; + } + else + { + /**/ + } + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡĽں +* ˵UINT8 chIndex +* ֵ UINT32 Tiocں +*/ +UINT32 EaGetBuildCycNum(const UINT8 chIndex) +{ + UINT32 retCycNum = 0U; + if (EA_MAX_NUM > chIndex) + { + retCycNum = g_szEaData[chIndex].dwEaBuildCycNum; + } + else + { + ; + } + return retCycNum; +} + +/* +* ݷŻȡ +* ˵UINT16 wEaId +* ֵ 0< +* 0 ݻȡʧ +* by cgh 20250311 +*/ +UINT16 GetEaIndex(const UINT16 wEaId) +{ + UINT16 wReval = 0U; + UINT16 wEaIndex = 0U; + + if (EA_CFG_SUM_MAX > wEaId) + { + for (wEaIndex = 0U; wEaIndex < g_eaConfigNum; wEaIndex++) + { + if (wEaId == g_szEaConfig[wEaIndex].wId) + { + wReval = wEaIndex; + break; + } + else + { + ; + } + } + } + else + { + ; + } + return wReval; +} + + diff --git a/TSCP/src/APP/ciapp/Train/EvacuationAreaManage.h b/TSCP/src/APP/ciapp/Train/EvacuationAreaManage.h new file mode 100644 index 0000000..6579ff8 --- /dev/null +++ b/TSCP/src/APP/ciapp/Train/EvacuationAreaManage.h @@ -0,0 +1,338 @@ +#ifndef _EVACUATION_AREA_MANAGE_H_ +#define _EVACUATION_AREA_MANAGE_H_ + +#include "TrainDefine.h" + +#define EA_CFG_SUM_MAX 50u /* */ +#define EA_BD_LINK_SUM_MAX 5u /* յ߽ */ +#define EA_MODE_DIS 0x55u /* ʽ */ +#define EA_MODE_SEC 0xAAu /* ʽվһ䲻վ̨ */ +#define EA_MODE_PLATION 0x33u /* ʽվһ京վ̨ */ +#define EA_STATION_MODE_DIS 0x01u /* վ̨ʽ */ +#define EA_STATION_MODE_PLAT 0x02u /* վ̨ʽվ̨ */ + +#define EA_OUT_ONE 1u /* 򰴾㣨Ҫȡ */ +#define EA_OUT_TWO 2u /* վ̨վ̨ */ +#define EA_OUT_THREE 3u /* վһҪվ̨ */ +#define EA_OUT_FOUR 4u /* վһҪյվ̨ */ +#define EA_OUT_FIVE 5u /* վһ䲻Ҫվ̨ */ +#define EA_OUT_SIX 6u /* վһҪ估վ̨ */ + +#define EA_DST_ALLOWED_YES 0x55u /* ʱĿTIOC */ +#define EA_DST_ALLOWED_NO 0xaau /* ʱĿTIOC */ + +#define PA_TYPE_EA 0x55u /* ɢ */ +#define PA_TYPE_DA 0xaau /* ѹ */ + +typedef struct +{ + UINT16 wId; /* ӵͼñ */ + UINT8 chStartLinkNum; /* ߽ */ + UINT16 szStartLinkId[EA_BD_LINK_SUM_MAX]; /* ߽link */ + UINT8 szStartLinkDir[EA_BD_LINK_SUM_MAX]; /* ߽ѯյ߼ */ + UINT8 chEndLinkNum; /* յ߽ */ + UINT16 szEndLinkId[EA_BD_LINK_SUM_MAX]; /* յ߽link */ + UINT8 szEndLinkDir[EA_BD_LINK_SUM_MAX]; /* յ߽ѯ߼ */ + UINT32 dwMinKm; /* һС */ + UINT32 dwMaxKm; /* һ */ + UINT8 chEaConfigLinkSum; /*ɢLINKĿ*/ + UINT16 wSzEaConfigLinkId[EA_SECTION_MAX_NUM]; /*ɢLINK*/ + UINT8 chStartStationLinkSum; /*Ӧվ̨LINKĿ*/ + UINT16 wSzStartStationLinkId[EA_BD_LINK_SUM_MAX]; /*Ӧվ̨LINK*/ + UINT8 chEndStationLinkSum; /*յӦվ̨LINKĿ*/ + UINT16 wSzEndStationLinkId[EA_BD_LINK_SUM_MAX]; /*յӦվ̨LINK*/ +}EaConfigStru; + +/* ṹ */ +typedef struct +{ + UINT8 chObjNum; /* */ + UINT16 szObjId[EA_SECTION_MAX_NUM]; /* */ +}EaObjStru; + +/* ɢṹ */ +typedef struct +{ + UINT16 wTrainId; /* ɢгID */ + UINT8 chBuildedFlag; /* ־ 0x55ѽ0xAAδ */ + EaObjStru strLinkInfo; /* ɢlinkϢ */ + EaObjStru strAcInfo; /* ɢϢ */ + EaObjStru strLgcInfo; /* ɢ߼Ϣ */ + UINT32 dwMidLine; /* ɢг߹ */ + UINT8 chSrcTiocId; /* ɢʱԴTIOC */ + UINT8 chDstTiocId; /* ɢʱĿTIOC */ + UINT8 chDstAllowed; /* ɢʱĿTIOC״̬ */ + UINT8 chPaType; /* ͣ0x55ɢ0xaaѹ */ + UINT8 chEaConfigId; /* ɢʽΪվһʱӦķID 복*/ + UINT8 chEaAreaLinkType; /* */ + UINT32 dwEaBuildCycNum; /*ɢʱԴTiocں*/ +}EaDataStru, *pEaData; + + +/** +* @brief ʼ +* @param +* @return CI_ERROR ʼʧ CI_SUCCESS ʼɹ +* by cgh 20250310 +*/ +UINT8 EaConfigInit(void); + +/** +* @brief ȡָɢгID +* @param chIndex ± +* @return гID +*/ +extern UINT16 GetEvacuatingTrainIdByIndex(UINT8 chIndex); + +/** +* @brief ȡɢ־λ +* @param chIndex ± +* @return DEFAULT_ZEROĬֵEA_IS_BUILDEDѽEA_IS_NOT_BUILDEDδ +*/ +extern UINT8 GetEaBuildedFlag(UINT8 chIndex); + +/** +* @brief ȡɢlink +* @param chIndex ± +* @return ɢlink +*/ +extern UINT8 GetEaLinkNum(UINT8 chIndex); + +/** +* @brief ȡɢlink +* @param chIndex ± +* @return ɢlink +*/ +extern UINT16 * GetEaLinkBuff(UINT8 chIndex); + +/** +* @brief ȡҪɢ +* @param +* @return Ҫɢ +*/ +extern UINT8 GetEaNum(void); + +/** +* @brief ɢ +* @return OC_ERRORʧܣOC_SUCCESSɹ +*/ +extern void EvacuationAreaProcess(void); + +/** +* @brief ȡ߼ +* @param const UINT8 chIndex +* @return ߼ +*/ +extern UINT8 EaGetLgcNum(const UINT8 chIndex); + +/** +* @brief ȡ߼α +* @param const UINT8 chIndex +* @return ߼α +*/ +extern UINT16 * EaGetLgcId(const UINT8 chIndex); + +/** +* @brief ȡɢг߹ +* @param const UINT8 chIndex +* @return ɢг߹ +*/ +extern UINT32 EaGetMidLine(const UINT8 chIndex); + +/* +* ȡɢ +* ˵ pData ݵַ +* dwIndex +* ֵ д +*/ +extern UINT32 GetEaTransferData(UINT8* pData, UINT32 dwIndex); + +/* +* ɢ +* ˵ pData ݵַ +* dwIndex +* ֵ +*/ +extern UINT32 SetEaTransferData(UINT8* pData, UINT32 dwIndex); + +/** +* @brief ȡָTIOC +* @param chIndex ± +* @return TIOC +*/ +extern UINT8 GetEaSrcTiocByIndex(UINT8 chIndex); + +/** +* @brief ȡָĿTIOC +* @param chIndex ± +* @return ĿTIOC +*/ +extern UINT8 GetEaDstTiocByIndex(UINT8 chIndex); + +/** +* @brief ȡָĿTIOCͬʶ +* @param chIndex ± +* @return ĿTIOCͬʶ +*/ +extern UINT8 GetEaDstAllowedByIndex(UINT8 chIndex); + +/** +* @brief ڿķ +* @param EaDataStru * pEaDataSt ڿķ +* @return +*/ +extern void EaNeighborUpdata(EaDataStru * pEaDataSt); + +/** +* @brief ڿķ +* @param EaDataStru * pEaData ڿķ +* @return +*/ +extern void EaSetNeighborAllowFlag(UINT16 wTrainId, UINT8 chSrcTioc, UINT8 chDstTioc, UINT8 chFlag,UINT32 dwBuildCyc); + +/* +* TIOCͨãɢ +* ˵ UINT8 chTiocId TIOC +* ֵ +*/ +extern void NeighborGoodEaProc(UINT8 chTiocId); + +/** +* @brief жlinkǷڷ +* @param const UINT16 wLinkId link +* @return CI_ERROR:linkڷڣCI_SUCCESS:linkڷ +*/ +extern UINT8 IsLinkInEa(const UINT16 wLinkId); + +/** +* @brief ѹȡ +* @param +* @return +*/ +extern void DaAtsCancleProc(void); + +/** +* @brief ȡѹ״δ +* @param +* @return +*/ +extern void DaAtsCancleFst(void); + +/** +* @brief ȡѹδ +* @param +* @return +*/ +extern void DaAtsCancleSnd(void); + +/** +* @brief ȡָ +* @param chIndex ± +* @return +*/ +extern UINT8 GetPaTypeByIndex(UINT8 chIndex); + +/** +* @brief ȡӦݱID +* @param chIndex ± +* @return ID +*/ +UINT8 GetEaConfigID(UINT8 chIndex); + +/** +* @brief ȡlink +* @param const UINT8 chIndex +* @return link +*/ +extern UINT8 EaGetLinkNum(const UINT8 chIndex); + +/** +* @brief ȡlink +* @param const UINT8 chIndex +* @return link +*/ +extern UINT16 * EaGetLinkId(const UINT8 chIndex); + +/** +* @brief ȡ +* @param const UINT8 chIndex +* @return +*/ +extern UINT8 EaGetAcNum(const UINT8 chIndex); + +/** +* @brief ȡα +* @param const UINT8 chIndex +* @return α +*/ +extern UINT16 * EaGetAcId(const UINT8 chIndex); + +/** +* @brief ж߼Ƿڷ +* @param const UINT16 wLgcId ߼α +* @return CI_ERROR:߼δڷڣCI_SUCCESS:߼βڷ +*/ +extern UINT8 IsLgcInEa(const UINT16 wLgcId); + +/* +* ǷΪ +* ˵const UINT16 wAxisSecId ID +* const UINT8 chSetAreaType +* const UINT16 wTrainId гID +* ֵ CI_ERROR 鲻ͨ +* CI_SUCCESS ͨ +* by cgh 20240105 +*/ +UINT8 AxisSecAddProAreaCheck(const UINT16 wAxisSecId, const UINT8 chSetAreaType, const UINT16 wTrainId); + +/** +* @brief ȡ +* @param chIndex ± +* @return EA_AREA_UP +* EA_AREA_DOWN +* EA_AREA_ALL к +* by cgh 20240321 +*/ +UINT8 GetEaAreaLineType(UINT8 chIndex); + +/** +* @brief ڱȡϢ +* @param const UINT8 chEaIndex ID +* @return +* by cgh 20240326 +*/ +void ClearEaSecData(const UINT8 chEaIndex); + +/** +* @brief ·· +* @param const UINT8 chEaIndex ID +* @return +* by cgh 20240402 +*/ +void RefreshEaLineType(const UINT8 chEaIndex); + +/* +* ȡָIDTIOCţɲѯȫ߼ᣩ +* ˵ const UINT16 axisSectionId, ID +* ֵ 0: ȡʧ +* >0: TIOC +*/ +UINT16 GetAxisBelongTiocAllLine(const UINT16 wAcId); + +/* +* ȡĽں +* ˵UINT8 chIndex +* ֵ UINT32 Tiocں +*/ +UINT32 EaGetBuildCycNum(const UINT8 chIndex); + +/* +* ݷŻȡ +* ˵UINT16 wEaId +* ֵ 0< +* 0 ݻȡʧ +* by cgh 20250311 +*/ +UINT16 GetEaIndex(const UINT16 wEaId); + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Train/TrainDataManage.c b/TSCP/src/APP/ciapp/Train/TrainDataManage.c new file mode 100644 index 0000000..d35b492 --- /dev/null +++ b/TSCP/src/APP/ciapp/Train/TrainDataManage.c @@ -0,0 +1,10849 @@ +#include "TrainDataManage.h" +#include "CiSystemDefine.h" +#include "CommonMemory.h" +#include "../Section/LinkConfigDataManage.h" +#include "dquCbtcConfigData.h" +#include "../Route/RouteConfigDataManage.h" +#include "HLHTHeadContexManage.h" +#include "ELMDataPrepare.h" +#include "SignalDataManage.h" +#include "ParsePackGateWayData.h" +#include "CRC32.h" +#include "dquCIInterFace.h" +#include "EnvelopeManageAPI.h" +#include "EnvelopeManage.h" +#include "WLBrakeDataManage.h" +#include "SectionStateProcess_define.h" +#include "AxisSort_api.h" + +TrainInfoStru gstTrainInfo[TRAIN_SUM_MAX] = { 0 }; +UINT16 gszTrainId[TRAIN_SUM_MAX] = { 0U }; +UINT16 gTrainSum = 0U; + +UINT8 gDyTestNum = 0u; +TrainDyInfoStru gszDyTestInfo[TRAIN_DYN_TEST_SUM_MAX] = { 0u }; + +UINT8 gAtsScreenNum = 0u; +TrainAtsScreenStru gszAtsScreenInfo[TRAIN_SUM_MAX] = { 0u }; + +UINT8 gFlyTrainCnt = 0U; /*ɳ崻г*/ +TrainFlyProtectStru gFlyTrainData[SHUT_DOWN_TRAIN_NUMMAX] = { 0 };/*ɳ崻г*/ + + +/** +* @brief гǰȫϢгȫλú +* @param UINT16 trainID +* @param UINT32 tailDistance +* @param UINT8 trainDirection +* @return +*/ +static void CalTailTrainSafePosFromUnSafe(UINT16 trainID, UINT32 tailDistance, UINT8 trainDirection); + +/** +* @brief гǰȫϢгȫλú +* @param UINT16 trainID +* @param UINT32 dwHeadDistance +* @param UINT8 chDir +* @return +*/ +static void CalHeadTrainSafePosFromUnSafe(UINT16 wTrainId, UINT32 dwHeadDistance, UINT8 chDir); + +/** +* @brief жгȫͷǷռĿ +* @param wLinkId гȫͷlink +* @return CI_ERROR:гȫͷռĿCI_SUCCESS:гȫͷδռĿ +* @note +*/ +static UINT8 IsTrainInSafeArea(UINT16 wLinkId, UINT32 dwOffset); + +#if 0 +/** +* @brief VBTCгȫλô +* @param UINT8 rtnValue +* @param UINT16 trainID +* @param TrainSafeLocStru *temp_TrainSafeLoc +* @return +*/ +static void UpdateVbtcTrainSafePos(UINT8 rtnValue, UINT16 trainID, TrainSafeLocStru *temp_TrainSafeLoc); +#endif + +#if 0 +/** +* @brief гȫλô +* @param UINT8 rtnValue +* @param UINT16 trainID +* @param TrainSafeLocStru *temp_TrainSafeLoc +* @param p_strPointInArea pSwitchInfo +* @return +*/ +static void UpdateTrainSafePos(UINT8 rtnValue, UINT16 trainID, TrainSafeLocStru *temp_TrainSafeLoc); +#endif + +/* гȫλ */ +static UINT8 CalTrainSafeLoc(UINT8 chFlag, UINT8 safeFlag, UINT16 wLink, UINT32 dwOffset, UINT32 dwDistance, UINT8 chDirection, + UINT16 *pSwitchId, TrainSafeLocStru *pStrSafeLoc); + +/* +* жгǷڶ̬б +* ˵ const UINT16 wTrainId гID +* ֵ CI_ERROR:гڶ̬бڣCI_SUCCESS:гڶ̬б +*/ +static UINT8 IsTrainDyTesting(const UINT16 wTrainId); + +/* +* гӽ̬б +* ˵ const UINT16 wTrainId гID +* ֵ +*/ +static void AddTrainDyTesting(const UINT16 wTrainId, const UINT16 wLinkId); + +/* +* жlinkǷгڶ̬ +* ˵ const UINT16 wLinkId linkID +* ֵ CI_ERROR:гڶ̬ԣCI_SUCCESS: +*/ +static UINT8 IsLinkTesting(UINT16 wLinkId); + +/** +* @brief гȫλü㺯 +* @param +* @return +*/ +static void CalTrainSafePosition(void); + +/* +* г̬Դ +* ˵ +* ֵ +*/ +static void TrainDynProc(void); + +/* +* гѴ +* ˵ +* ֵ +* noteг״̬ΪڻѣάָóΪ߳Ϊ߳ +*/ +static void TrainWakeProc(void); + +/* +* ԭɸѡ +* ˵ +* ֵ +*/ +static void TrainScreenProc(void); + +/** +* @brief Զɸѡ +* @param +* @return +*/ +static void TrainAtsScreenTidy(void); + +/** +* @brief Զɸѡ״ȷ +* @param +* @return +*/ +static void TrainAtsScreenFst(void); + +/** +* @brief жATSԶɸѡϢǷһ +* @param +* @return CI_ERROR:һ£CI_SUCCESS:һ +*/ +static UINT8 IsAtsFstSndSame(void); + +/** +* @brief Զɸѡٴȷ +* @param +* @return +*/ +static void TrainAtsScreenSnd(void); + +/** +* @brief Զɸѡ +* @param +* @return +*/ +static void TrainAtsScreenProc(void); + +/** +* @brief Զɸѡȷϴ +* @param +* @return +*/ +static void SetTrainAtsScreenProc(void); + +/* +* ȡָгͨжں +* ˵ const UINT16 wTrainId, гID +* ֵ гͨжں +*/ +static UINT32 GetTrainTransBadCyc(const UINT16 wTrainId); + +/* +* ָгܷתΪUCT +* ˵ const UINT16 wTrainId, гID +const UINT8 chFlag ־ +* ֵ +* note߳粻תΪUCT +*/ +static void SetTrainCanUct(const UINT16 wTrainId, const UINT8 chFlag); +/*================================================================================== +*ܣʼгϢṹ塣 +*úʵгϢṹijʼ +*ڲ; +*ڲ; +*ֵ: +*ؼ +*ע +12021619 +=====================================================================================*/ +UINT8 TrainDataModuleInit(void) +{ + UINT8 chCycle = 0U; + UINT8 cRetVal = CI_ERROR; + UINT8 ii = 0U; + + /*егϢṹ*/ + (void)CommonMemSet((void*)&gstTrainInfo, (UINT32)(sizeof(TrainInfoStru)*TRAIN_SUM_MAX), 0U, (UINT32)(sizeof(TrainInfoStru)*TRAIN_SUM_MAX)); + + /*еггδ*/ + for (chCycle = 1U; chCycle < TRAIN_SUM_MAX; chCycle++) + { + cRetVal = CI_SUCCESS; + gstTrainInfo[chCycle].wTrainId = (UINT16)((((UINT16)CI_SYSTEM_TYPE_VOBC) << 8) + chCycle); + gstTrainInfo[chCycle].dwIvocCycle = 0U; + gstTrainInfo[chCycle].chTrainDir = DIR_INVALID; + gstTrainInfo[chCycle].chTrainDir_MaxTail = DIR_INVALID; + gstTrainInfo[chCycle].chTrainDir_MaxHead = DIR_INVALID; + gstTrainInfo[chCycle].chTrainDir_MinHead = DIR_INVALID; + gstTrainInfo[chCycle].wTrainMaxHeadLink = 0U; + gstTrainInfo[chCycle].dwTrainMaxHeadOffset = UINT32_MAX; + gstTrainInfo[chCycle].wTrainMinTailLink = 0U; + gstTrainInfo[chCycle].dwTrainMinTailOffset = UINT32_MAX; + gstTrainInfo[chCycle].wTrainMinHeadLink = 0U; + gstTrainInfo[chCycle].dwTrainMinHeadOffset = UINT32_MAX; + gstTrainInfo[chCycle].wTrainMaxTailLink = 0U; + gstTrainInfo[chCycle].dwTrainMaxTailOffset = UINT32_MAX; + gstTrainInfo[chCycle].chSpeedDir = 0U; + gstTrainInfo[chCycle].wTrainSpeed = 0U; + gstTrainInfo[chCycle].chTransmitStat = TRAIN_COMM_STATE_UNKNOWN; + gstTrainInfo[chCycle].chTailScreenStat = 0U; + gstTrainInfo[chCycle].chHeadScreenStat = 0U; + gstTrainInfo[chCycle].strSafeLoc.wHeadLink = 0U; + gstTrainInfo[chCycle].strSafeLoc.wTailLink = 0U; + gstTrainInfo[chCycle].strSafeLoc.dwHeadOffset = UINT32_MAX; + gstTrainInfo[chCycle].strSafeLoc.dwTailOffset = UINT32_MAX; + gstTrainInfo[chCycle].chMsgFromTiocId = 0u; + gstTrainInfo[chCycle].chSwState = TRAIN_SLEEP_NO; + gstTrainInfo[chCycle].wSleepLink = 0u; + gstTrainInfo[chCycle].chWakeState = TRAIN_WAKE_DEFAULT; + gstTrainInfo[chCycle].chTrainReportState = 0U; + gstTrainInfo[chCycle].chDynCmd = TRAIN_CMD_DYM_NO; + gstTrainInfo[chCycle].chDynRpl = TRAIN_DYN_RPL_DEFAULT; + gstTrainInfo[chCycle].chScreenApply = TRAIN_SCREEN_DEFAULT; + gstTrainInfo[chCycle].chTrainHeadScreenConfirm = TRAIN_HEAD_CONFIRM_NO; + gstTrainInfo[chCycle].chTrainTailScreenConfirm = TRAIN_TAIL_CONFIRM_NO; + gstTrainInfo[chCycle].chAtsScreenConfirm = TRAIN_ATS_CONFIRM_NO; + gstTrainInfo[chCycle].chStopSteadyState = TRAIN_SS_NO; + gstTrainInfo[chCycle].chSleepCancleFlag = TRAIN_SLEEP_CANCLE_NO; + gstTrainInfo[chCycle].chEaCmd = EA_PROTECT_DEFAULT; + gstTrainInfo[chCycle].chTrainCanUct = FLAG_UNSET; + gstTrainInfo[chCycle].chActive = TRAIN_ACTIVE_NONE; + gstTrainInfo[chCycle].chRrmRqst = TRAIN_RRM_RQST_NO; + gstTrainInfo[chCycle].chRrmState = TRAIN_RRM_DEFAULT; + gstTrainInfo[chCycle].chRrmReson = TRAIN_RRM_RESON_FF; + gstTrainInfo[chCycle].chRrmResonFromOtherRc = TRAIN_RRM_RESON_FF; + gstTrainInfo[chCycle].wAtsLgcStation = 0u; + gstTrainInfo[chCycle].wNextTioc = 0u; + gstTrainInfo[chCycle].chDerailment = TRAIN_DERAIL_NO; + gstTrainInfo[chCycle].chNvramPosFlag = TRAIN_NVRAM_POS_FLAG_YES; + + gstTrainInfo[chCycle].strHeadTrainLocData.wHeadVobcId = UINT32_MAX; + gstTrainInfo[chCycle].strHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_DEFAULT; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = TRAIN_DIR_DEF; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = 0U; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = UINT32_MAX; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = 0U; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = UINT32_MAX; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = 0U; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = UINT32_MAX; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = 0U; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = UINT32_MAX; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = TRAIN_DIR_DEF; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = UINT16_MAX; + gstTrainInfo[chCycle].strHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = UINT16_MAX; + + /*ʼITE͵г*/ + for (ii = 0U; ii < TRAIN_INC_ITE_SUM_MAX; ii++) + { + gstTrainInfo[chCycle].szTrainIteData[ii].wTrainHeadLinkId = 0U; + gstTrainInfo[chCycle].szTrainIteData[ii].dwTrainHeadLinkOffset = UINT32_MAX; + gstTrainInfo[chCycle].szTrainIteData[ii].wTrainTailLinkId = 0U; + gstTrainInfo[chCycle].szTrainIteData[ii].dwTrainTailLinkOffset = UINT32_MAX; + gstTrainInfo[chCycle].szTrainIteData[ii].cTrainDir = TRAIN_DIR_DEF; + gstTrainInfo[chCycle].szTrainIteData[ii].wForWardOffset = UINT16_MAX; + gstTrainInfo[chCycle].szTrainIteData[ii].wBackOffset = UINT16_MAX; + } + + /*еĺгABLϢṹ*/ + (void)CommonMemSet((void*)&gstTrainInfo[chCycle].strAblTrainNeedData, (UINT32)sizeof(ABLTrainInfoStru), 0U, (UINT32)sizeof(ABLTrainInfoStru)); + gstTrainInfo[chCycle].wTrainHeadSigId = 0U; + gstTrainInfo[chCycle].wTrainHeadTrainId = TRAIN_ID_MAX; + gstTrainInfo[chCycle].chTrainLocReverseRouteFlag = TRAIN_LOC_REV_ROUTE_FLAG_NONE; + + gstTrainInfo[chCycle].chAblTrainDir = DIR_INVALID; + gstTrainInfo[chCycle].wAblTrainMaxHeadLink = 0U; + gstTrainInfo[chCycle].dwAblTrainMaxHeadOffset = UINT32_MAX; + gstTrainInfo[chCycle].wAblTrainMinTailLink = 0U; + gstTrainInfo[chCycle].dwAblTrainMinTailOffset = UINT32_MAX; + /*ʼʱɸѡ־ӦЧ*/ + gstTrainInfo[chCycle].chVirHeadScreenPassFlag = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; + gstTrainInfo[chCycle].chVirTailScreenPassFlag = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; + gstTrainInfo[chCycle].wEnterLjkLinkId = 0U; + gstTrainInfo[chCycle].dwTrainFullEnterLjkCycNum = 0U; + + gstTrainInfo[chCycle].chTrainPosMonitorState = TRAIN_POS_MONITOR_INVALID; /*гλüල״̬ʼΪЧ*/ + gstTrainInfo[chCycle].wTrainPosMonitorInLink = 0U; /*гλüලЧʱlinkΪ0*/ + gstTrainInfo[chCycle].dwStartFlyCycNum = 0U; /*ɳ¼ڳʼ*/ + gstTrainInfo[chCycle].chEaCmdState = TRAIN_EA_CMD_STATE_INVALID; /*гɢʼΪЧ*/ + gszTrainId[gTrainSum] = gstTrainInfo[chCycle].wTrainId; + gTrainSum++; + + } + + return cRetVal; +} + +/* +* ȡг +* ˵ void +* ֵ UINT16 ʼг +* : qw.liu 2022-02-25 +*/ +UINT16 GetTrainSum(void) +{ + UINT16 wRetVal = 0U; + if (TRAIN_SUM_MAX <= gTrainSum ) + { + wRetVal = TRAIN_SUM_MAX; + } + else + { + wRetVal = gTrainSum; + } + + return wRetVal; +} + +/* +* ȡָ±ӦгID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: гID +*/ +UINT16 GetTrainId(const UINT16 bufIndex) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wTrainSum = GetTrainSum(); + if (bufIndex < wTrainSum) + { + wRetVal = gszTrainId[bufIndex]; + } + else + { + wRetVal = CI_ERROR; + } + return wRetVal; +} + +/* +* ȡгϢṹ +* ˵ void +* ֵ TrainInfoStru * гϢṹ +* : qw.liu 2022-02-24 +* ޸bug YF0083-120 +*/ +TrainInfoStru * GetTrainInfoData(void) +{ + TrainInfoStru * ret = NULL; + if (NULL != gstTrainInfo) + { + ret = (TrainInfoStru *)gstTrainInfo; + } + else + { + ret = NULL; + } + return ret; +} + +/* +* ȡָг +* ˵ const UINT16 wTrainId, гID +* ֵ TRAIN_SUM_MAX: ȡʧ +* wTrainId)) + { + wRetVal = wTrainId & 0x00FFU; + } + else if((TRAIN_SUM_MAX > wTrainId) && (0u != wTrainId)) + { + wRetVal = wTrainId; + } + else + { + wRetVal = TRAIN_SUM_MAX; + } + + return wRetVal; +} + +/* +* ȡָгͨ״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: ͨ״̬ +* 0xAA: ʧͨ +* 0xFF: ͨ״̬δ֪ +* : qw.liu 2022-02-24 +*/ +UINT8 GetTrainTransitmitStat(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTransmitStat; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгȼ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x03: UR +* 0x04: ABL +* 0x01: VBTC +* 0x02: ITC +* 0xff : Ĭ/״̬ +* : qw.liu 2022-02-24 +*/ +UINT8 GetTrainLevel(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainLevel; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгȼ +* ˵ const UINT16 wTrainId, гID +* ֵ гٶ +* +* : qw.liu 2022-02-25 +*/ +UINT16 GetTrainSpeed(const UINT16 wTrainId) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wTrainSpeed; + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ȡָгзСȫˣ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: ߼ͬ +* 0xAA: ߼ +* 0xFF: Ч +* : qw.liu 2022-02-24 +*/ +UINT8 GetTrainDir(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainDir; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгȫ˵з +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: ߼ͬ +* 0xAA: ߼ +* 0xFF: Ч +*/ +UINT8 GetTrainDir_MaxTail(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainDir_MaxTail; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгȫǰ˵з +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: ߼ͬ +* 0xAA: ߼ +* 0xFF: Ч +*/ +UINT8 GetTrainDir_MaxHead(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainDir_MaxHead; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + + +/* +* ȡָгСȫǰ˵з +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: ߼ͬ +* 0xAA: ߼ +* 0xFF: Ч +*/ +UINT8 GetTrainDir_MinHead(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainDir_MinHead; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгǰɸ־ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: ǰɸѡͨ +* 0xAA: ǰδɸѡͨ +* : wsd 2022-03-10 +*/ +UINT8 GetTrainHeadScrStat(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chHeadScreenStat; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} +/* +* ȡָгɸ־ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: ɸѡͨ +* 0xAA: δɸѡͨ +* : wsd 2022-03-10 +*/ +UINT8 GetTrainTailScrStat(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTailScreenStat; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} +/* +* ȡָгٶȷ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: ٶȷ +* 0xAA: ٶȷ +* : qw.liu 2022-02-24 +*/ +UINT8 GetTrainSpeedDir(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chSpeedDir; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгǷڱ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* 0x55: гڱ +* 0xAA: гڱ +* : qw.liu 2022-02-24 +*/ +UINT8 GetTrainInCtrlZone(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainInZone; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгȫǰlinkId +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkID +* : qw.liu 2022-02-24 +*/ +UINT16 GetTrainMaxHeadLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wTrainMaxHeadLink; + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ȡָгȫlinkId +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkID +* : qw.liu 2022-02-24 +*/ +UINT16 GetTrainMaxTailLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wTrainMaxTailLink; + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ȡָгСȫǰlinkId +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkID +* : 2022.3.2 +*/ +UINT16 GetTrainMinHeadLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wTrainMinHeadLink; + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ȡָгСȫlinkId +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkID +* : 2022.3.2 +*/ +UINT16 GetTrainMinTailLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wTrainMinTailLink; + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ȡָгϢӳʱ +* ˵ const UINT16 wTrainId, гID +* ֵ Ϣӳʱ +* : 2022.3.2 +*/ +UINT32 GetTrainMsgDelayTime(const UINT16 wTrainId) +{ + UINT32 wRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].dwDelayTime; + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ȡָгȫǰƫ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkƫ +* : qw.liu 2022-02-24 +*/ +UINT32 GetTrainMaxHeadOffset(const UINT16 wTrainId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwTrainMaxHeadOffset; + } + else + { + dwRetVal = UINT32_MAX; + } + + return dwRetVal; +} + +/* +* ȡָгȫƫ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkƫ +* : qw.liu 2022-02-24 +*/ +UINT32 GetTrainMaxTailOffset(const UINT16 wTrainId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwTrainMaxTailOffset; + } + else + { + dwRetVal = UINT32_MAX; + } + + return dwRetVal; +} + +/* +* ȡָгСȫǰƫ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkƫ +* : 2022.3.2 +*/ +UINT32 GetTrainMinHeadOffset(const UINT16 wTrainId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwTrainMinHeadOffset; + } + else + { + dwRetVal = UINT32_MAX; + } + + return dwRetVal; +} + +/* +* ȡָгСȫƫ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkƫ +* : 2022.3.2 +*/ +UINT32 GetTrainMinTailOffset(const UINT16 wTrainId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwTrainMinTailOffset; + } + else + { + dwRetVal = UINT32_MAX; + } + + return dwRetVal; +} + +/* +* ȡָгСȫǰƫ +* ˵ const UINT16 wTrainId, гID +* ֵ г״̬ +* : 2022.3.2 +*/ +UINT8 GetTrainZeroState(const UINT16 wTrainId) +{ + UINT8 dwRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].chTrainZeroState; + } + else + { + dwRetVal = UINT8_MAX; + } + + return dwRetVal; +} + +/* +* ָгͨ״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTrainmitStat ͨ״̬ +* ֵ CI_ERROR: ʧ + CI_SUCCESS:ݳɹ +* 0x55 : ͨ״̬ +* 0xAA : ʧͨ +* 0xFF : ͨ״̬δ֪ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainTransmitStat(const UINT16 wTrainId,const UINT8 chTrainmitStat) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((TRAIN_COMM_STATE_GOOD == chTrainmitStat) + || (TRAIN_COMM_STATE_BAD == chTrainmitStat) + || (TRAIN_COMM_STATE_UNKNOWN == chTrainmitStat)) + { + gstTrainInfo[wBufIndex].chTransmitStat = chTrainmitStat; + gstTrainInfo[wBufIndex].dwTransBadCyc = Get2oo2CurCycleNum(); + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгеȼ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTrainLevel геȼ +* ֵ 0: ȡʧ + 1: ݳɹ +* 0x03: UR +* 0x04: ABL +* 0x01: VBTC +* 0x02: ITC +* 0xff : Ĭ/״̬ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainLevel(const UINT16 wTrainId, const UINT8 chTrainLevel) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + /*RC16.0 ñͳһмֵ*/ + if ((TRAIN_LEVEL_UR == chTrainLevel) + || (TRAIN_LEVEL_ABL == chTrainLevel) + || (TRAIN_LEVEL_VBTC == chTrainLevel) + ||(TRAIN_LEVEL_ITC == chTrainLevel) + || (TRAIN_LEVEL_BACKUP_UNKNOWN == chTrainLevel)) + { + gstTrainInfo[wBufIndex].chTrainLevel = chTrainLevel; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгСȫָͷз +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTrainDir гз +* ֵ 0: ȡʧ +1: ݳɹ +* 0x55: з +* 0xAA: з +* 0xFF: гĬз +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainDir(const UINT16 wTrainId, const UINT8 chTrainDir) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + UINT8 chDir = 0u; + UINT8 chLinkLogicDirUpAndDown = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((TRAIN_DIR_UP == chTrainDir) || (TRAIN_DIR_DOWN == chTrainDir)) + { + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + + if (chLinkLogicDirUpAndDown == chTrainDir) + { + chDir = DIR_CONVERT; + } + else + { + chDir = DIR_SAME; + } + + /*гСȫ˵з*/ + gstTrainInfo[wBufIndex].chTrainDir = chDir; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָг״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTrainZeroStt г״̬ +* ֵ 0: ȡʧ +1: ݳɹ +* 0x55: +* 0xAA: з +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainZeroState(const UINT16 wTrainId, const UINT8 chTrainZeroStt) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((TRAIN_SPEED_ZERO_YES == chTrainZeroStt) + || (TRAIN_SPEED_ZERO_NO == chTrainZeroStt)) + { + gstTrainInfo[wBufIndex].chTrainZeroState = chTrainZeroStt; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгǷڱ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTrainCtrlZonStat Ƿڱ +* ֵ 0: ȡʧ +* 1: ݳɹ +* 0x55: ڱ +* 0xAA: ڱ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainInCtrlZoneStat(const UINT16 wTrainId, const UINT8 chTrainCtrlZonStat) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((TRAIN_IN_CTRL_ZONE == chTrainCtrlZonStat) + || (TRAIN_NOT_IN_CTRL_ZONE == chTrainCtrlZonStat)) + { + gstTrainInfo[wBufIndex].chTrainInZone = chTrainCtrlZonStat; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫǰLinkId +* ˵ const UINT16 wTrainId, гID +* const UINT8 wTrainHeadLinkId гȫǰLk +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainMaxHeadLink(const UINT16 wTrainId, const UINT16 wTrainHeadLinkId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (UINT16_MAX != wTrainHeadLinkId) + { + gstTrainInfo[wBufIndex].wTrainMaxHeadLink = wTrainHeadLinkId; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫǰLinkId Off +* ˵ const UINT16 wTrainId, гID +* const UINT8 dwTrainHeadOff гȫǰOff +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainMaxHeadOffset(const UINT16 wTrainId, const UINT32 dwTrainHeadOff) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].dwTrainMaxHeadOffset = dwTrainHeadOff; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫLinkId +* ˵ const UINT16 wTrainId, гID +* const UINT8 wTrainTailLinkId гȫLk +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainMaxTailLink(const UINT16 wTrainId, const UINT16 wTrainTailLinkId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (UINT16_MAX != wTrainTailLinkId) + { + gstTrainInfo[wBufIndex].wTrainMaxTailLink = wTrainTailLinkId; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫLinkId Off +* ˵ const UINT16 wTrainId, гID +* const UINT8 dwTrainTailOff гȫOff +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainMaxTailOffset(const UINT16 wTrainId, const UINT32 dwTrainTailOff) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].dwTrainMaxTailOffset = dwTrainTailOff; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + + +/* +* ָгСȫǰLinkId +* ˵ const UINT16 wTrainId, гID +* const UINT8 wTrainHeadLinkId гȫǰLk +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainMinHeadLink(const UINT16 wTrainId, const UINT16 wTrainHeadLinkId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (UINT16_MAX != wTrainHeadLinkId) + { + gstTrainInfo[wBufIndex].wTrainMinHeadLink = wTrainHeadLinkId; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгСȫǰLinkId Off +* ˵ const UINT16 wTrainId, гID +* const UINT8 dwTrainHeadOff гȫǰOff +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainMinHeadOffset(const UINT16 wTrainId, const UINT32 dwTrainHeadOff) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].dwTrainMinHeadOffset = dwTrainHeadOff; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгСȫLinkId +* ˵ const UINT16 wTrainId, гID +* const UINT8 wTrainTailLinkId гȫLk +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainMinTailLink(const UINT16 wTrainId, const UINT16 wTrainTailLinkId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (UINT16_MAX != wTrainTailLinkId) + { + gstTrainInfo[wBufIndex].wTrainMinTailLink = wTrainTailLinkId; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгСȫLinkId Off +* ˵ const UINT16 wTrainId, гID +* const UINT8 dwTrainTailOff гȫOff +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 24 +*/ +UINT8 SetTrainMinTailOffset(const UINT16 wTrainId, const UINT32 dwTrainTailOff) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].dwTrainMinTailOffset = dwTrainTailOff; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} +/* +* ָгٶ +* ˵ const UINT16 wTrainId, гID +* const UINT8 wTrainTailLinkId гȫLk +* ֵ 0: ȡʧ +* 1 : ݳɹ +* : qw.liu 2022 - 02 - 26 +*/ +UINT8 SetTrainSpeed(const UINT16 wTrainId, const UINT16 wTrainSpd) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (UINT16_MAX != wTrainSpd) + { + gstTrainInfo[wBufIndex].wTrainSpeed = wTrainSpd; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгٶȷ +* ˵ const UINT16 wTrainId, гID +* const UINT8 dwTrainTailOff гȫOff +* ֵ 0: ȡʧ +* 1: ݳɹ +* : qw.liu 2022 - 02 - 26 +*/ +UINT8 SetTrainSpeedDir(const UINT16 wTrainId, const UINT8 chSpdDir) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((TRAIN_SPEED_DIR_BACKWARD==chSpdDir) + || (TRAIN_SPEED_DIR_FORWARD== chSpdDir)) + { + gstTrainInfo[wBufIndex].chSpeedDir = chSpdDir; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫͷlink +* ˵ const UINT16 wTrainId, гID +* const UINT16 wLinkId +* ֵ CI_ERROR: ʧ +CI_SUCCESS:ݳɹ +* : 2022.3.1 +*/ +UINT8 SetTrainSafeHeadLink(const UINT16 wTrainId, const UINT16 wLinkId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strSafeLoc.wHeadLink = wLinkId; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫͷlinkƫ +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwOffset ƫ +* ֵ CI_ERROR: ʧ +CI_SUCCESS:ݳɹ +* : 2022.3.1 +*/ +UINT8 SetTrainSafeHeadOffset(const UINT16 wTrainId, const UINT32 dwOffset) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strSafeLoc.dwHeadOffset = dwOffset; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫͷ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chDir +* ֵ CI_ERROR: ʧ +CI_SUCCESS:ݳɹ +* : 2022.3.1 +*/ +UINT8 SetTrainSafeHeadDir(const UINT16 wTrainId, const UINT8 chDir) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + if ((DIR_SAME == chDir) || (DIR_CONVERT == chDir)) + { + chRetVal = CI_SUCCESS; + } + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (CI_SUCCESS == chRetVal) + { + gstTrainInfo[wBufIndex].strSafeLoc.chHeadDir = chDir; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫͷlink +* ˵ const UINT16 wTrainId, гID +* const UINT16 wLinkId +* ֵ CI_ERROR: ʧ +CI_SUCCESS:ݳɹ +* : 2022.3.1 +*/ +UINT8 SetTrainSafeTailLink(const UINT16 wTrainId, const UINT16 wLinkId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strSafeLoc.wTailLink = wLinkId; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫͷlinkƫ +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwOffset ƫ +* ֵ CI_ERROR: ʧ +CI_SUCCESS:ݳɹ +* : 2022.3.1 +*/ +UINT8 SetTrainSafeTailOffset(const UINT16 wTrainId, const UINT32 dwOffset) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strSafeLoc.dwTailOffset = dwOffset; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгȫβ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chDir +* ֵ CI_ERROR: ʧ +CI_SUCCESS:ݳɹ +* : 2022.3.1 +*/ +UINT8 SetTrainSafeTailDir(const UINT16 wTrainId, const UINT8 chDir) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + if ((DIR_SAME == chDir) || (DIR_CONVERT == chDir)) + { + chRetVal = CI_SUCCESS; + } + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (CI_SUCCESS == chRetVal) + { + gstTrainInfo[wBufIndex].strSafeLoc.chTailDir = chDir; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгȫͷlink +* ˵ const UINT16 wTrainId, гID +* ֵ ȫͷlink +* : 2022.3.1 +*/ +UINT16 GetTrainSafeHeadLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = UINT16_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].strSafeLoc.wHeadLink; + } + else + { + wRetVal = UINT16_MAX; + } + + return wRetVal; +} + +/* +* ȡָгȫͷlinkƫ +* ˵ const UINT16 wTrainId, гID +* ֵ ȫͷlinkƫ +* : 2022.3.1 +*/ +UINT32 GetTrainSafeHeadOffset(const UINT16 wTrainId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].strSafeLoc.dwHeadOffset; + } + else + { + dwRetVal = UINT32_MAX; + } + + return dwRetVal; +} + +/* +* ȡָгȫͷ +* ˵ const UINT16 wTrainId, гID +* ֵ ȫͷ +* : 2022.3.1 +*/ +UINT8 GetTrainSafeHeadDir(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strSafeLoc.chHeadDir; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ȡָгȫβlink +* ˵ const UINT16 wTrainId, гID +* ֵ ȫβlink +* : 2022.3.1 +*/ +UINT16 GetTrainSafeTailLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = UINT16_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].strSafeLoc.wTailLink; + } + else + { + wRetVal = UINT16_MAX; + } + + return wRetVal; +} + +/* +* ȡָгȫͷlinkƫ +* ˵ const UINT16 wTrainId, гID +* ֵ ȫβlinkƫ +* : 2022.3.1 +*/ +UINT32 GetTrainSafeTailOffset(const UINT16 wTrainId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].strSafeLoc.dwTailOffset; + } + else + { + dwRetVal = UINT32_MAX; + } + + return dwRetVal; +} + +/* +* ȡָгȫβ +* ˵ const UINT16 wTrainId, гID +* ֵ ȫͷ +* : 2022.3.1 +*/ +UINT8 GetTrainSafeTailDir(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strSafeLoc.chTailDir; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ָгϢӳʱ +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwDelayTime +* ֵ CI_ERROR: ʧ +CI_SUCCESS:ݳɹ +* : 2022.3.1 +*/ +UINT8 SetTrainMsgDelayTime(const UINT16 wTrainId, const UINT32 dwDelayTime) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (UINT32_MAX != dwDelayTime) + { + gstTrainInfo[wBufIndex].dwDelayTime = dwDelayTime; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/**************************************************************************************** +ܣʶϢʾλΪͷȫλûβȫλãгķǰȫλ +ͷǰȫλûβǰȫλãгеľ루Dzʱۺ +õԼгз򣬲ѯؼõгȫλãͷȫλûβ +ȫλãɹ0x03ʧܸʧܵԭ򣬷ֱ𷵻ضӦϢ +PSע⣬úľֲṹڰ˳ͷͳβLinkOffsetϢDSUӦݱʶϢ +дӦϢṹ嶨壩 +עݹͨȷڵԭ°ȫλüʧܵʧܵĵIDΪ +ֵһַأʧܣ÷ֵΪֵ0xffffӦӿеwSwitchID +ڲUINT8 chFlag 㳵ͷdzβıʶϢ +UINT8 safeFlag Ƿȫλü־λ +UINT16 wLink1 link +UINT32 dwOffset1 linkƫ +UINT32 dwDistance +UINT8 chDirection гз +struct_DSU_SwitchInfo SwitchArray[DSU_SWITCH_NUM] ZCϽΧڵϢṹ +ڲstruct_DSU_TrainSafeLoc *TrainSafeLoc гλϢṹ +ֵUINT8 chReturnValue +0x03ȫλüɹ +0x02ȫλüʧܣԭλô +0x01ȫλüʧܣԭ·ͷ +0x00ȫλüʧܣԭڲ +*******************************************************************************************/ +/*8 гȫλü*/ +static UINT8 CalTrainSafeLoc(UINT8 chFlag, UINT8 safeFlag, UINT16 wLink, UINT32 dwOffset, UINT32 dwDistance, UINT8 chDirection, + UINT16 *pSwitchId, TrainSafeLocStru *pStrSafeLoc) +{ + UINT8 chReturnValue = 0u;/*ֵ*/ + UINT8 chFunRtn = 0u;/*ù֪ܺλúλжλáֵ*/ + UINT8 bTailDir = 0u;/*㳵βȫλʱķ*/ + struct_PathPoint strPoint = { 0u }; + struct_PathPoint strPointResult = { 0u }; + + chFunRtn = CheckLinkValid(wLink, dwOffset); + + /*жгλIDЧ*/ + if ((CI_SUCCESS != chFunRtn) || ((DIR_SAME != chDirection) && (DIR_CONVERT != chDirection)) + || (NULL == pSwitchId) || (NULL == pStrSafeLoc)) + { + ; + } + else + { + strPoint.wLinkId = wLink; + strPoint.dwOffset = dwOffset; + + if (CALSAFEPOSFLAG == safeFlag) + { + /*ѯͷȫλ*/ + if (FINDHEADSAFEFLAG == chFlag) + { + /*ù֪ܺλúλжλýвѯ*/ + chFunRtn = dsuNewLocAndObsByOffsetDis(strPoint, dwDistance, chDirection, &strPointResult, pSwitchId); + + chReturnValue = chFunRtn; + + /*·ͷѯʧܻѯɹ*/ + if ((3u == chFunRtn) || (1u == chFunRtn)) + { + /*óͷȫλ*/ + pStrSafeLoc->wHeadLink = strPointResult.wLinkId; + pStrSafeLoc->dwHeadOffset = strPointResult.dwOffset; + } + else + { + if (2u == chFunRtn) + { + /*λ(гLINKڷĵ)Ϊгȫλ*/ + pStrSafeLoc->wHeadLink = strPointResult.wLinkId; + pStrSafeLoc->dwHeadOffset = strPointResult.dwOffset; + } + else + { + /*ʧ*/ + } + } + } + else + { + /*ѯβȫλ*/ + if (FINDTAILSAFEFLAG == chFlag) + { + /*ѯβλҪгзķ㣬зĵߵ*/ + if (DIR_SAME == chDirection) + { + bTailDir = DIR_CONVERT; + } + else + { + bTailDir = DIR_SAME; + } + /*ù֪ܺλúλжλýвѯ*/ + chFunRtn = dsuNewLocAndObsByOffsetDis(strPoint, dwDistance, bTailDir, &strPointResult, pSwitchId); + + chReturnValue = chFunRtn; + + /*ѯɹھͷ߲ѯʧʱ*/ + if ((3u == chFunRtn) || (1u == chFunRtn)) + { + /*ɹزѯɹ*/ + pStrSafeLoc->wTailLink = strPointResult.wLinkId; + pStrSafeLoc->dwTailOffset = strPointResult.dwOffset; + } + else + { + + if (2u == chFunRtn) + { + /*λ(гLINKڷĵ)Ϊгȫλ*/ + pStrSafeLoc->wTailLink = strPointResult.wLinkId; + pStrSafeLoc->dwTailOffset = strPointResult.dwOffset; + } + else + { + /**/ + } + } + } + else + { + /*ʧܣĬֵ*/ + chReturnValue = 0u; + } + } + } + else if (CALOTHERFLAG == safeFlag) + { + /*ѯͷȫλ*/ + if (FINDHEADSAFEFLAG == chFlag) + { + /*ù֪ܺλúλжλýвѯ*/ + chFunRtn = dsuNewLocAndObsByOffsetDis(strPoint, dwDistance, chDirection, &strPointResult, pSwitchId); + + chReturnValue = chFunRtn; + + /*·ͷѯɹ*/ + if ((3u == chFunRtn) || (1u == chFunRtn)) + { + /*óͷȫλ*/ + pStrSafeLoc->wHeadLink = strPointResult.wLinkId; + pStrSafeLoc->dwHeadOffset = strPointResult.dwOffset; + } + else + { + /**/ + } + } + else + { + /*ѯβȫλ*/ + if (FINDTAILSAFEFLAG == chFlag) + { + /*ѯβλҪгзķ㣬зĵߵ*/ + if (DIR_SAME == chDirection) + { + bTailDir = DIR_CONVERT; + } + else + { + bTailDir = DIR_SAME; + } + chFunRtn = dsuNewLocAndObsByOffsetDis(strPoint, dwDistance, bTailDir, &strPointResult, pSwitchId); + + chReturnValue = chFunRtn; + + /*ʧܣزѯʧ*/ + if ((3u == chFunRtn) || (1u == chFunRtn)) + { + /*ɹزѯɹ*/ + pStrSafeLoc->wTailLink = strPointResult.wLinkId; + pStrSafeLoc->dwTailOffset = strPointResult.dwOffset; + } + else + { + /**/ + } + } + else + { + /*ʧܣĬֵ*/ + chReturnValue = 0u; + } + } + + } + else + { + /**/ + chReturnValue = 0u; + } + } + return chReturnValue; +} + +#if 0 +/** +* @brief гȫͷλô +* @param UINT8 rtnValue +* @param UINT16 trainID +* @param TrainSafeLocStru *temp_TrainSafeLoc +* @param p_strPointInArea pSwitchInfo +* @return +* @note ޸bug YF0083-115120 +*/ +void UpdateTrainSafePos(UINT8 rtnValue, UINT16 trainID, TrainSafeLocStru *temp_TrainSafeLoc) +{ + UINT16 trainMaxHeadLink = 0u; /*гȫǰ*/ + UINT32 trainMaxHeadOffset = 0u; /*гȫǰƫ*/ + UINT8 trainDir = CI_ERROR; /*г*/ + UINT16 wAcId = 0u; + UINT8 chSleepStt = 0u; + ELM_AxisLocStruct tmpACLoc = { 0u }; /* ˵λ*/ + UINT8 chFunRtn = CI_ERROR; + UINT16 wSleepLink = 0u; + UINT8 safeDir = 0u; + UINT8 changePNum = 0u; + LOD_STRU pSafeHead = { 0u }; + LOD_STRU pMaxHead = { 0u }; + UINT8 cDirectionPointCnt = 0U; /*仯*/ + UINT8 changePointFlag = 0u; + + /** μ*/ + if (NULL != temp_TrainSafeLoc) + { + wSleepLink = GetTrainSleepLink(trainID); + trainMaxHeadLink = GetTrainMaxHeadLink(trainID); + trainMaxHeadOffset = GetTrainMaxHeadOffset(trainID); + pMaxHead.Lnk = trainMaxHeadLink; + pMaxHead.Off = trainMaxHeadOffset; + trainDir = GetTrainDir_MaxHead(trainID);/*ȫǰλ*/ + wAcId = GetLinkBelongAcId(wSleepLink); + + chSleepStt = GetTrainSleepState(trainID); + if ((TRAIN_SLEEP_YES == chSleepStt) && (wSleepLink == temp_TrainSafeLoc->wHeadLink)) + { + chFunRtn = elm_PrepareACLoc(wAcId, trainDir, &tmpACLoc); + /*߹Դڷ仯㣬гʧ*/ + changePointFlag = GetLinkLogicDirChangedById(wSleepLink); + + if ((0u == wAcId) || (CI_SUCCESS != chFunRtn) + || (LINK_DIRCHANGE_NONE != changePointFlag)) + {/* ݲѯʧܣ߳״̬ */ + SetTrainSleepState(trainID, TRAIN_SLEEP_NO); + SetTrainSleepLink(trainID, 0u); + debug_infor_printf((const)"Train%x delete sleep state because data error.\n", trainID); + } + else + { + (void)SetTrainSafeHeadLink(trainID, tmpACLoc.endPos.Lnk); + (void)SetTrainSafeHeadOffset(trainID, tmpACLoc.endPos.Off); + (void)SetTrainSafeHeadDir(trainID, trainDir); + } + } + else + { + pSafeHead.Lnk = temp_TrainSafeLoc->wHeadLink; + pSafeHead.Off = temp_TrainSafeLoc->dwHeadOffset; + changePNum = GetDirChangeNumBtwPoints(&pSafeHead, &pMaxHead); + safeDir = TransDirByChangeNum(trainDir, changePNum); /*ݷ仯żת*/ + + /*ȫλòѯɹ*/ + if ((3u == rtnValue) || (1u == rtnValue)) + { + (void)SetTrainSafeHeadLink(trainID, temp_TrainSafeLoc->wHeadLink); + (void)SetTrainSafeHeadOffset(trainID, temp_TrainSafeLoc->dwHeadOffset); + (void)SetTrainSafeHeadDir(trainID, safeDir); + } + else if (2u == rtnValue) + { + /*ȫλڵѯʧܣгȫλΪ*/ + (void)SetTrainSafeHeadLink(trainID, temp_TrainSafeLoc->wHeadLink); + (void)SetTrainSafeHeadOffset(trainID, temp_TrainSafeLoc->dwHeadOffset); + (void)SetTrainSafeHeadDir(trainID, safeDir); + } + else + { + /*ȫλڲѯʧܣгǰȫλΪȫλ*/ + (void)SetTrainSafeHeadLink(trainID, trainMaxHeadLink); + (void)SetTrainSafeHeadOffset(trainID, trainMaxHeadOffset); + (void)SetTrainSafeHeadDir(trainID, safeDir); + } + } + (void)SetTrainSafeHeadFlag(trainID); + } + else + { + + } +} +#endif + +#if 0 +/** +* @brief VBTCгȫλô +* @param UINT8 rtnValue +* @param UINT16 trainID +* @param TrainSafeLocStru *temp_TrainSafeLoc +* @return +*/ +void UpdateVbtcTrainSafePos(UINT8 rtnValue, UINT16 trainID, TrainSafeLocStru *temp_TrainSafeLoc) +{ + UINT8 returnValue = 0u; /*ȽϰȫλMAյ˳ķֵ*/ + UINT8 trainDirection = 0u; /*гз*/ + UINT8 checkSafeBackRtn = 0u; /*ȽϰȫλǷԽMAķֵ*/ + UINT8 chDirIsSame = 0u; + UINT8 checkUnSafeBackRtn = 0u; /*Ƚг㱨λǷԽMAķֵ*/ + UINT8 chTrainDir = 0u; + UINT8 chMaDir = 0u; + struct_PathPoint strTemp = { 0u }; + struct_PathPoint strMaTemp = { 0u }; + UINT32 dwLen = UINT32_MAX; + UINT8 chPointDir = 0u; + /*гз*/ + chTrainDir = GetTrainDir(trainID); + chMaDir = GetTrainMaDir(trainID); + if (0x02 == rtnValue) + { + /*ȫλڵѯʧܣгȫλΪо*/ + SetTrainSafeHeadLink(trainID, temp_TrainSafeLoc->wHeadLink); + SetTrainSafeHeadOffset(trainID, temp_TrainSafeLoc->dwTailOffset); + } + else if ((0x01 == rtnValue) || (0x03 == rtnValue)) + { + /*жMAķгзǷһ,ݿǷ仯㣬г۷ʱһڻ᲻һ*/ + if (chTrainDir != chMaDir) + { + /*һ£гİȫλò*/ + SetTrainSafeHeadLink(trainID, temp_TrainSafeLoc->wHeadLink); + SetTrainSafeHeadOffset(trainID, temp_TrainSafeLoc->dwTailOffset); + } + else + { + /*һ*/ + /*ΪѯɹҪжгȫλǷԽľ֤ͣMA*/ + strTemp.wLinkId = temp_TrainSafeLoc->wHeadLink; + strTemp.dwOffset = temp_TrainSafeLoc->dwHeadOffset; + strMaTemp.wLinkId = GetTrainMaEndLink(trainID); + strMaTemp.dwOffset = GetTrainMaEndOffset(trainID); + + dwLen = DsuAPointToBPoint(&strTemp, &strMaTemp, &chPointDir); + if ((UINT32_MAX == dwLen) || ((DIR_SAME != chPointDir) && (DIR_CONVERT != chPointDir))) + { + /* ѯʧܣ */ + SetTrainSafeHeadLink(trainID, temp_TrainSafeLoc->wHeadLink); + SetTrainSafeHeadOffset(trainID, temp_TrainSafeLoc->dwTailOffset); + } + else if (chPointDir == chMaDir) + { + /*δԽMAյ㣬ȫλò*/ + SetTrainSafeHeadLink(trainID, temp_TrainSafeLoc->wHeadLink); + SetTrainSafeHeadOffset(trainID, temp_TrainSafeLoc->dwTailOffset); + } + else + { + /*ȫֵԽMAյ㣬ʵгǷԽ*/ + strTemp.wLinkId = GetTrainMaxHeadLink(trainID); + strTemp.dwOffset = GetTrainMaxHeadOffset(trainID); + + dwLen = DsuAPointToBPoint(&strTemp, &strMaTemp, &chPointDir); + if ((UINT32_MAX == dwLen) || ((DIR_SAME != chPointDir) && (DIR_CONVERT != chPointDir))) + { + /* ѯʧܣ */ + SetTrainSafeHeadLink(trainID, temp_TrainSafeLoc->wHeadLink); + SetTrainSafeHeadOffset(trainID, temp_TrainSafeLoc->dwTailOffset); + } + else if (chPointDir == chMaDir) + { + /*г㱨λδԽMAյ㣬ȫλԽȫλҪسMAյ(гܱ֤ͣµĵ)*/ + SetTrainSafeHeadLink(trainID, strMaTemp.wLinkId); + SetTrainSafeHeadOffset(trainID, strMaTemp.dwOffset); + } + else + { + /*г㱨λԽMAյ߲ѯʧܣгİȫλò*/ + SetTrainSafeHeadLink(trainID, temp_TrainSafeLoc->wHeadLink); + SetTrainSafeHeadOffset(trainID, temp_TrainSafeLoc->dwTailOffset); + } + } + } + } + else + { + /*ڲѯʧܣг*/ + SetTrainSafeHeadLink(trainID, GetTrainMaxHeadLink(trainID)); + SetTrainSafeHeadOffset(trainID, GetTrainMaxHeadOffset(trainID)); + } +} +#endif + +/** +* @brief гǰȫϢгȫͷλú +* @param UINT16 trainID +* @param UINT32 dwHeadDistance +* @param UINT8 chDir +* @return +*/ +static void CalHeadTrainSafePosFromUnSafe(UINT16 wTrainId, UINT32 dwHeadDistance, UINT8 chDir) +{ + UINT16 wTrainHeadLink = 0u; /*гͷLINK*/ + UINT32 dwTrainHeadOffset = 0u; /*гͷLINKƫ*/ + UINT16 wSwitchId = 0u; + UINT8 chFunRtn = 0u; /*ȫλü㷵ֵ*/ + TrainSafeLocStru Temp_TrainSafeLoc; /*гȫλýṹ*/ + UINT16 wHeadAcId = 0U;/*ID*/ + ELM_AxisLocStruct tmpHeadACLoc = { 0U }; /* ˵λ*/ + UINT8 chTempCheckFlag = CI_ERROR;/*ʱ־*/ + UINT8 chNvramPosFlag = 0U;/*NVRAMλñʶ*/ + UINT8 chSleepStt = 0U;/*г״̬*/ + UINT16 wSleepLink = 0U; + UINT16 wAcId = 0U; + ELM_AxisLocStruct tmpACLoc = { 0U }; /* ˵λ*/ + UINT8 changePointFlag = 0U; + LOD_STRU pSafeHead = { 0U }; + LOD_STRU pMaxHead = { 0U }; + UINT8 safeDir = 0U; + UINT8 changePNum = 0U; + + /*սṹ*/ + (void)memset(&Temp_TrainSafeLoc, 0x00, sizeof(TrainSafeLocStru)); + wTrainHeadLink = GetTrainMaxHeadLink(wTrainId); + dwTrainHeadOffset = GetTrainMaxHeadOffset(wTrainId); + chNvramPosFlag = GetTrainNvramPosFlag(wTrainId); + chSleepStt = GetTrainSleepState(wTrainId); + chTempCheckFlag = IsLinkSwTrack(wTrainHeadLink); + + /*㰲ȫλ*/ + wSwitchId = (UINT16)UINT16_MAX; + chFunRtn = CalTrainSafeLoc(FINDHEADSAFEFLAG, CALSAFEPOSFLAG, wTrainHeadLink, dwTrainHeadOffset, dwHeadDistance, chDir, &wSwitchId, &Temp_TrainSafeLoc); + + wSleepLink = GetTrainSleepLink(wTrainId); + pMaxHead.Lnk = wTrainHeadLink; + pMaxHead.Off = dwTrainHeadOffset; + wAcId = GetLinkBelongAcId(wSleepLink); + + chSleepStt = GetTrainSleepState(wTrainId); + if ((TRAIN_SLEEP_YES == chSleepStt) && (wSleepLink == Temp_TrainSafeLoc.wHeadLink)) + { + chTempCheckFlag = elm_PrepareACLoc(wAcId, chDir, &tmpACLoc); + /*߹Դڷ仯㣬гʧ*/ + changePointFlag = GetLinkLogicDirChangedById(wSleepLink); + + if ((0u == wAcId) || (CI_SUCCESS != chTempCheckFlag) + || (LINK_DIRCHANGE_NONE != changePointFlag)) + {/* ݲѯʧܣ߳״̬ */ + SetTrainSleepState(wTrainId, TRAIN_SLEEP_NO); + SetTrainSleepLink(wTrainId, 0U); + debug_infor_printf((const)"Train%x delete sleep state because data error.\n", wTrainId); + + SetTrainVirHeadScreenPassFlag(wTrainId,TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainFullEnterLjkCycNum(wTrainId, 0U); + SetTrainEnterLjkLinkId(wTrainId, 0U); + + /*ȡ߻ѹļϢʧܻ߻ѹڷ仯㣬üල״̬ΪЧ*/ + SetTrainPosMonitorState(wTrainId, TRAIN_POS_MONITOR_INVALID); + SetTrainPosMonitorInLink(wTrainId, 0U); + } + else + { + (void)SetTrainSafeHeadLink(wTrainId, tmpACLoc.endPos.Lnk); + (void)SetTrainSafeHeadOffset(wTrainId, tmpACLoc.endPos.Off); + (void)SetTrainSafeHeadDir(wTrainId, chDir); + } + } + else if ((TRAIN_NVRAM_POS_FLAG_NO != chNvramPosFlag) && (TRAIN_SLEEP_YES != chSleepStt) && (CI_SUCCESS == chTempCheckFlag) && (wTrainHeadLink == Temp_TrainSafeLoc.wHeadLink)) + { + /*гȫ߻ѹʹNVRAMλãڴǰǰ˵ǰ*/ + wHeadAcId = GetLinkBelongAcId(wTrainHeadLink); + chTempCheckFlag = elm_PrepareACLoc(wHeadAcId, chDir, &tmpHeadACLoc); + + if (CI_SUCCESS == chTempCheckFlag) + { + (void)SetTrainSafeHeadLink(wTrainId, tmpHeadACLoc.endPos.Lnk); + (void)SetTrainSafeHeadOffset(wTrainId, tmpHeadACLoc.endPos.Off); + (void)SetTrainSafeHeadDir(wTrainId, chDir); + } + else + { + (void)SetTrainSafeHeadLink(wTrainId, 0U); + (void)SetTrainSafeHeadOffset(wTrainId, UINT32_MAX); + SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainFullEnterLjkCycNum(wTrainId, 0U); + SetTrainEnterLjkLinkId(wTrainId, 0U); + + /*ȡгǰļϢʧܣüල״̬ΪЧ*/ + SetTrainPosMonitorState(wTrainId, TRAIN_POS_MONITOR_INVALID); + SetTrainPosMonitorInLink(wTrainId, 0U); + } + } + else + { + pSafeHead.Lnk = Temp_TrainSafeLoc.wHeadLink; + pSafeHead.Off = Temp_TrainSafeLoc.dwHeadOffset; + changePNum = GetDirChangeNumBtwPoints(&pSafeHead, &pMaxHead); + safeDir = TransDirByChangeNum(chDir, changePNum); /*ݷ仯żת*/ + + /*ȫλòѯɹ*/ + if ((3u == chFunRtn) || (1u == chFunRtn)) + { + (void)SetTrainSafeHeadLink(wTrainId, Temp_TrainSafeLoc.wHeadLink); + (void)SetTrainSafeHeadOffset(wTrainId, Temp_TrainSafeLoc.dwHeadOffset); + (void)SetTrainSafeHeadDir(wTrainId, safeDir); + } + else if (2u == chFunRtn) + { + /*ȫλڵѯʧܣгȫλΪ*/ + (void)SetTrainSafeHeadLink(wTrainId, Temp_TrainSafeLoc.wHeadLink); + (void)SetTrainSafeHeadOffset(wTrainId, Temp_TrainSafeLoc.dwHeadOffset); + (void)SetTrainSafeHeadDir(wTrainId, safeDir); + } + else + { + /*ȫλڲѯʧ*/ + (void)SetTrainSafeHeadLink(wTrainId, 0U); + (void)SetTrainSafeHeadOffset(wTrainId, UINT32_MAX); + } + } + (void)SetTrainSafeHeadFlag(wTrainId); +} + + + +/** +* @brief гǰȫϢгȫβλú +* @param UINT16 trainID +* @param UINT32 tailDistance +* @param UINT8 trainDirection Сȫ˷ +* @return +*/ +static void CalTailTrainSafePosFromUnSafe(UINT16 trainID, UINT32 tailDistance, UINT8 trainDirection) +{ + UINT16 trainTailLink = 0u; /*гβLINK*/ + UINT32 trainTailOffset = 0u; /*гβLINKƫ*/ + UINT16 wSwitchId = UINT16_MAX; /*ID*/ + TrainSafeLocStru strTrainSafeLoc; /*гȫλýṹ*/ + UINT8 calTailReturn = 0u; /*βȫλü㷵ֵ*/ + UINT16 wAcId = 0u; + UINT8 chSleepStt = 0u; + ELM_AxisLocStruct tmpACLoc = { 0u }; /* ˵λ*/ + UINT8 chFunRtn = CI_ERROR; + UINT16 wSleepLink = 0u; + UINT8 safeDir = 0u; + UINT8 changePNum = 0u; + LOD_STRU pSafeTail = { 0u }; + LOD_STRU pMinTail = { 0u }; + UINT16 wTailAcId = 0U;/*СID*/ + ELM_AxisLocStruct tmpTailACLoc = { 0U }; /* С˵λ*/ + UINT8 chTempCheckFlag = CI_ERROR;/*ʱ־*/ + UINT8 chNvramPosFlag = 0U;/*NVRAMλñʶ*/ + + + (void)memset(&strTrainSafeLoc, 0, sizeof(TrainSafeLocStru)); + /*ȡгǰȫβϢ*/ + trainTailLink = GetTrainMinTailLink(trainID); + trainTailOffset = GetTrainMinTailOffset(trainID); + chSleepStt = GetTrainSleepState(trainID); + chNvramPosFlag = GetTrainNvramPosFlag(trainID); + + chTempCheckFlag = IsLinkSwTrack(trainTailLink); + + pMinTail.Lnk = trainTailLink; + pMinTail.Off = trainTailOffset; + wSleepLink = GetTrainSleepLink(trainID); + wAcId = GetLinkBelongAcId(wSleepLink); + + /*㰲ȫλ*/ + calTailReturn = CalTrainSafeLoc(FINDTAILSAFEFLAG, CALSAFEPOSFLAG, trainTailLink, trainTailOffset, tailDistance, trainDirection, &wSwitchId, &strTrainSafeLoc); + if ((TRAIN_SLEEP_YES == chSleepStt) && (wSleepLink == strTrainSafeLoc.wTailLink)) + { + chFunRtn = elm_PrepareACLoc(wAcId, trainDirection, &tmpACLoc); + if ((0u == wAcId) || (CI_SUCCESS != chFunRtn)) + {/* ݲѯʧܣ߳״̬ */ + SetTrainSleepState(trainID, TRAIN_SLEEP_NO); + SetTrainSleepLink(trainID, 0u); + debug_infor_printf((const)"Train%x delete sleep state because data error.\n", trainID); + + SetTrainVirHeadScreenPassFlag(trainID, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(trainID, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainFullEnterLjkCycNum(trainID, 0U); + SetTrainEnterLjkLinkId(trainID, 0U); + + /*ȡ߻ѹļϢʧܣüල״̬ΪЧ*/ + SetTrainPosMonitorState(trainID, TRAIN_POS_MONITOR_INVALID); + SetTrainPosMonitorInLink(trainID, 0U); + } + else + { + (void)SetTrainSafeTailLink(trainID, tmpACLoc.startPos.Lnk); + (void)SetTrainSafeTailOffset(trainID, tmpACLoc.startPos.Off); + (void)SetTrainSafeTailDir(trainID, trainDirection);/*߳ȫβСȫδ仯㣬Сȫ˷*/ + } + } + else if ((TRAIN_NVRAM_POS_FLAG_NO != chNvramPosFlag) && (TRAIN_SLEEP_YES != chSleepStt) && (CI_SUCCESS == chTempCheckFlag) && (trainTailLink == strTrainSafeLoc.wTailLink)) + { + /*гȫ߻ѹʹNVRAMλãСǰ˵ǰ*/ + wTailAcId = GetLinkBelongAcId(trainTailLink); + chTempCheckFlag = elm_PrepareACLoc(wTailAcId, trainDirection, &tmpTailACLoc); + + if (CI_SUCCESS == chTempCheckFlag) + { + (void)SetTrainSafeTailLink(trainID, tmpTailACLoc.startPos.Lnk); + (void)SetTrainSafeTailOffset(trainID, tmpTailACLoc.startPos.Off); + (void)SetTrainSafeTailDir(trainID, trainDirection);/*߳ȫβСȫδ仯㣬Сȫ˷*/ + } + else + { + (void)SetTrainSafeTailLink(trainID, 0U); + (void)SetTrainSafeTailOffset(trainID, UINT32_MAX); + + SetTrainVirHeadScreenPassFlag(trainID, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(trainID, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainFullEnterLjkCycNum(trainID, 0U); + SetTrainEnterLjkLinkId(trainID, 0U); + + /*ȡгСļϢʧܣüල״̬ΪЧ*/ + SetTrainPosMonitorState(trainID, TRAIN_POS_MONITOR_INVALID); + SetTrainPosMonitorInLink(trainID, 0U); + } + + } + else + { + pSafeTail.Lnk = strTrainSafeLoc.wTailLink; + pSafeTail.Off = strTrainSafeLoc.dwTailOffset; + changePNum = GetDirChangeNumBtwPoints(&pSafeTail, &pMinTail); + safeDir = TransDirByChangeNum(trainDirection, changePNum); /*ݷ仯żת*/ + + if (2u == calTailReturn) + { + /*ڵȫλüʧܣгȫλĿ*/ + (void)SetTrainSafeTailLink(trainID, strTrainSafeLoc.wTailLink); + (void)SetTrainSafeTailOffset(trainID, strTrainSafeLoc.dwTailOffset); + (void)SetTrainSafeTailDir(trainID, safeDir); + } + else if ((3u == calTailReturn) || (1u == calTailReturn)) + { + /*ȫλüɹ*/ + (void)SetTrainSafeTailLink(trainID, strTrainSafeLoc.wTailLink); + (void)SetTrainSafeTailOffset(trainID, strTrainSafeLoc.dwTailOffset); + (void)SetTrainSafeTailDir(trainID, safeDir); + } + else + { + (void)SetTrainSafeTailLink(trainID, 0U); + (void)SetTrainSafeTailOffset(trainID, UINT32_MAX); + } + } +} + +/** +* @brief гȫλü㺯 +* @param +* @return +*/ +static void CalTrainSafePosition(void) +{ + UINT16 trainCycle = 0u;/*гѭƱ*/ + UINT16 wTailDis = 0u; /*վ̨׷ʱг з룬λcm*/ + UINT8 chDirHead = 0u;/*ͷгз*/ + UINT8 chDirTail = 0u;/*βгз*/ + UINT16 trainSpeed = 0u;/*гٶ*/ + FLOAT64 trainRedundancy = 0.0; + FLOAT64 gradeAcc = 0.0; + INT32 dwHeadDistance = 0; /*ͷ*/ + UINT16 wTrainId = UINT16_MAX; + UINT8 chTrainType = 0u; + CBTC_TRAIN_INFO_STRU strTrainInfo = { 0u }; + UINT32 dwDelayTime = 0u; + UINT8 chTrainSpeedDir = 0u; + UINT16 wMaxHeadLink = 0u; + UINT32 dwMaxHeadOffset = UINT32_MAX; + UINT16 wMinTailLink = 0u; + UINT32 dwMinTailOffset = UINT32_MAX; + UINT8 chFunRtn = CI_ERROR; + UINT8 chTransmitStat = TRAIN_COMM_STATE_BAD; + UINT8 chSleepState = 0u; + UINT32 dwTransBadCyc = 0u; + UINT32 dwCurCyc = 0u; + UINT8 chSss = 0u; + UINT8 chResult = CI_ERROR; + UINT32 dwTailDistance = 0U;/*о*/ + + wTailDis = GetBackProtectMaxLen(); + + /*г*/ + for (trainCycle = 0u; trainCycle < TRAIN_SUM_MAX; trainCycle++) + { + wTrainId = GetTrainId(trainCycle); + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); + dwMaxHeadOffset = GetTrainMaxHeadOffset(wTrainId); + wMinTailLink = GetTrainMinTailLink(wTrainId); + dwMinTailOffset = GetTrainMinTailOffset(wTrainId); + chFunRtn = CheckLinkValid(wMaxHeadLink, dwMaxHeadOffset); + chFunRtn &= CheckLinkValid(wMinTailLink, dwMinTailOffset); + /*OCΪλЧг㰲ȫ*/ + if (CI_SUCCESS == chFunRtn) + { + /*гǰȫλϢ*/ + chDirHead = GetTrainDir_MaxHead(wTrainId); + chDirTail = GetTrainDir(wTrainId); + /*ȡгٶ*/ + trainSpeed = GetTrainSpeed(wTrainId); + + /*ȡг*/ + chFunRtn = dquGetTrainType(wTrainId, &chTrainType); + + /*ȡгܲ*/ + chFunRtn &= dquGetCbtcTrainInfo(chTrainType, &strTrainInfo); + + if (CI_SUCCESS == chFunRtn) + { + /*гͨЭӳʱ*/ + dwDelayTime = GetTrainMsgDelayTime(wTrainId); + trainRedundancy = (FLOAT64)dwDelayTime / 1000.0; + + gradeAcc = (FLOAT64)strTrainInfo.WorstGrade / 10.0; + + chSss = GetTrainStopSteadyState(wTrainId); + chSleepState = GetTrainSleepState(wTrainId); + + if ((TRAIN_SS_YES == chSss) && (TRAIN_SLEEP_YES == chSleepState)) + { + /*߳ͣ׼ͣȣͨʱͷǰΪ0*/ + dwHeadDistance = 0; + } + else + { + /*Vt1/2at^2ʱСλȻ1*/ + dwHeadDistance = (INT32)((FLOAT64)trainSpeed * trainRedundancy) + 1 + + ((INT32)((FLOAT64)((FLOAT64)strTrainInfo.TrainMaxTracAcc + gradeAcc) * trainRedundancy * trainRedundancy / 2.0) + 1); + } + + + /*ͨгķǰȫλϢԼͷȫͷȫλ*/ + CalHeadTrainSafePosFromUnSafe(wTrainId, (UINT32)dwHeadDistance, chDirHead); + + /*㳵гijβȫ*/ + /*жгʱǴ״̬δͣ׼ͣȣзʵз෴*/ + chTrainSpeedDir = GetTrainSpeedDir(wTrainId); + + /*by cgh 20240417 гȫλü㣬жгٶȷҷͣ׼ͣȣа粻վ̨䣻*/ + if ((TRAIN_SPEED_FRONT != chTrainSpeedDir) && (TRAIN_SS_YES != chSss)) + { + if (wTailDis < (UINT32)dwHeadDistance) + { + /* з */ + dwTailDistance = wTailDis; + } + else + { + dwTailDistance = (UINT32)dwHeadDistance; + } + } + else + { + /*гβоϢ*/ + dwTailDistance = 0U; + } + + /*ͨгķǰȫλϢԼβȫβİȫλ*/ + CalTailTrainSafePosFromUnSafe(wTrainId, dwTailDistance, chDirTail); + chTransmitStat = GetTrainTransitmitStat(wTrainId); + dwTransBadCyc = GetTrainTransBadCyc(wTrainId); + dwCurCyc = Get2oo2CurCycleNum(); + chSleepState = GetTrainSleepState(wTrainId); + + if ((dwCurCyc != dwTransBadCyc) && (TRAIN_COMM_STATE_BAD == chTransmitStat) && (TRAIN_SLEEP_NO == chSleepState)) + { + chResult = SetTrainMaxHeadLink(wTrainId, 0u); + chResult &= SetTrainMaxHeadOffset(wTrainId, UINT32_MAX); + chResult &= SetTrainMinHeadLink(wTrainId, 0u); + chResult &= SetTrainMinHeadOffset(wTrainId, UINT32_MAX); + chResult &= SetTrainMaxTailLink(wTrainId, 0u); + chResult &= SetTrainMaxTailOffset(wTrainId, UINT32_MAX); + chResult &= SetTrainMinTailLink(wTrainId, 0u); + chResult &= SetTrainMinTailOffset(wTrainId, UINT32_MAX); + if (CI_ERROR == chResult) + { + ; /*ݲ*/ + } + } + else + { + ; + } + } + else + { + chResult = SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_BAD); + chResult &= SetTrainMaxHeadLink(wTrainId, 0u); + chResult &= SetTrainMaxHeadOffset(wTrainId, UINT32_MAX); + chResult &= SetTrainMinHeadLink(wTrainId, 0u); + chResult &= SetTrainMinHeadOffset(wTrainId, UINT32_MAX); + chResult &= SetTrainMaxTailLink(wTrainId, 0u); + chResult &= SetTrainMaxTailOffset(wTrainId, UINT32_MAX); + chResult &= SetTrainMinTailLink(wTrainId, 0u); + chResult &= SetTrainMinTailOffset(wTrainId, UINT32_MAX); + if (CI_ERROR == chResult) + { + ; /*ݲ*/ + } + } + } + else + { + /*аȫͨгķǰȫλü*/ + chResult = SetTrainSafeHeadLink(wTrainId, 0u); + chResult &= SetTrainSafeHeadOffset(wTrainId, UINT32_MAX); + chResult &= SetTrainSafeTailLink(wTrainId, 0u); + chResult &= SetTrainSafeTailOffset(wTrainId, UINT32_MAX); + if (CI_ERROR == chResult) + { + ; /*ݲ*/ + } + } + } +} + +/** +* @brief Ϣӳʱ +* @param UINT32 CurrentOwnSN ĵǰں +* @param UINT32 SNPeriod ͨڣCIϵͳУΪӦõ +* @param UINT32 srcRecvCiMsgSN,Էϴյı +* @param UINT32 srcCrntOwnMsgSN,Էʱ䵱ǰ +* @param UINT32 srcPreOwnMsgSN,Էϴյʱ䵱ʱ +* @param UINT32 srcPeriod,Էͨ +* @return Ϣӳʱ +*/ +INT32 CalVobcMsgDelayTime( + const UINT32 CurrentOwnSN, + const UINT32 SNPeriod, + const UINT32 srcRecvCiMsgSN, + const UINT32 srcCrntOwnMsgSN, + const UINT32 srcPreOwnMsgSN, + const UINT32 srcPeriod) +{ + INT32 RemainValidity = 0; + + /*ͨյϢеĻظ"һ"ϢʱRcvOppSN,ܵӳ, + ټȥϢڶԷ豸ڵʱ,Ӷõ˫Ĵӳ,Ϊӳ*/ + RemainValidity = (((INT32)CurrentOwnSN - (INT32)(srcRecvCiMsgSN))*((INT32)(SNPeriod)) - + ((INT32)(srcCrntOwnMsgSN)-(INT32)(srcPreOwnMsgSN))*((INT32)(srcPeriod))); + + return RemainValidity; +} + +/* +* гϢ +* ˵ void +* ֵ void +* : qw.liu 2022-03-04 +*/ +void ClearTrainInfo(UINT16 wTrainId) +{ + UINT16 wBufIndex = 0U; + UINT8 ii = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].chTrainLevel = TRAIN_LEVEL_UR; + gstTrainInfo[wBufIndex].dwIvocCycle = 0U; + gstTrainInfo[wBufIndex].chTrainDir = DIR_INVALID; + gstTrainInfo[wBufIndex].chTrainDir_MaxTail = DIR_INVALID; + gstTrainInfo[wBufIndex].chTrainDir_MaxHead = DIR_INVALID; + gstTrainInfo[wBufIndex].chTrainDir_MinHead = DIR_INVALID; + gstTrainInfo[wBufIndex].wTrainMaxHeadLink = 0U; + gstTrainInfo[wBufIndex].dwTrainMaxHeadOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].wTrainMinTailLink = 0U; + gstTrainInfo[wBufIndex].dwTrainMinTailOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].wTrainMinHeadLink = 0U; + gstTrainInfo[wBufIndex].dwTrainMinHeadOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].wTrainMaxTailLink = 0U; + gstTrainInfo[wBufIndex].dwTrainMaxTailOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].chSpeedDir = 0U; + gstTrainInfo[wBufIndex].wTrainSpeed = 0U; + gstTrainInfo[wBufIndex].chTransmitStat = TRAIN_COMM_STATE_UNKNOWN; + gstTrainInfo[wBufIndex].chTailScreenStat = 0U; + gstTrainInfo[wBufIndex].chHeadScreenStat = 0U; + gstTrainInfo[wBufIndex].chTrainModel = TRAIN_MODE_DEFAULT; + gstTrainInfo[wBufIndex].chSwState = TRAIN_SLEEP_NO; + gstTrainInfo[wBufIndex].wSleepLink = 0u; + gstTrainInfo[wBufIndex].chWakeState = TRAIN_WAKE_DEFAULT; + gstTrainInfo[wBufIndex].chTrainReportState = 0U; + gstTrainInfo[wBufIndex].chDynCmd = TRAIN_CMD_DYM_NO; + gstTrainInfo[wBufIndex].chDynRpl = TRAIN_DYN_RPL_DEFAULT; + gstTrainInfo[wBufIndex].chScreenApply = TRAIN_SCREEN_DEFAULT; + gstTrainInfo[wBufIndex].chTrainHeadScreenConfirm = TRAIN_HEAD_CONFIRM_NO; + gstTrainInfo[wBufIndex].chTrainTailScreenConfirm = TRAIN_TAIL_CONFIRM_NO; + gstTrainInfo[wBufIndex].chAtsScreenConfirm = TRAIN_ATS_CONFIRM_NO; + gstTrainInfo[wBufIndex].chStopSteadyState = TRAIN_SS_NO; + gstTrainInfo[wBufIndex].chSleepCancleFlag = TRAIN_SLEEP_CANCLE_NO; + gstTrainInfo[wBufIndex].chEaCmd = EA_PROTECT_DEFAULT; + gstTrainInfo[wBufIndex].chRrmRqst = TRAIN_RRM_RQST_NO; + gstTrainInfo[wBufIndex].chRrmState = TRAIN_RRM_DEFAULT; + gstTrainInfo[wBufIndex].chRrmReson = TRAIN_RRM_RESON_FF; + gstTrainInfo[wBufIndex].chRrmResonFromOtherRc = TRAIN_RRM_RESON_FF; + gstTrainInfo[wBufIndex].wAtsLgcStation = 0u; + gstTrainInfo[wBufIndex].wNextTioc = 0u; + gstTrainInfo[wBufIndex].chDerailment = TRAIN_DERAIL_NO; + gstTrainInfo[wBufIndex].chNvramPosFlag = TRAIN_NVRAM_POS_FLAG_YES; + + gstTrainInfo[wBufIndex].strHeadTrainLocData.wHeadVobcId = UINT32_MAX; + gstTrainInfo[wBufIndex].strHeadTrainLocData.chHeadTrainLocFlag = HEAD_TRAIN_LOC_DEFAULT; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainAtpLoc.chTrainDir = TRAIN_DIR_DEF; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMaxHeadLink = 0U; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMaxHeadOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainAtpLoc.wTrainMinTailLink = 0U; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainAtpLoc.dwTrainMinTailOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainIteLoc.wTrainMaxHeadLink = 0U; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMaxHeadOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainIteLoc.wTrainMinTailLink = 0U; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainIteLoc.dwTrainMinTailOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainIteLoc.chTrainDir = TRAIN_DIR_DEF; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainIteLoc.wLocHeadLoss = UINT16_MAX; + gstTrainInfo[wBufIndex].strHeadTrainLocData.strHeadTrainIteLoc.wLocTailLoss = UINT16_MAX; + + /*ITE͵гΪĬֵ*/ + for (ii = 0U; ii < TRAIN_INC_ITE_SUM_MAX; ii++) + { + gstTrainInfo[wBufIndex].szTrainIteData[ii].wTrainHeadLinkId = 0U; + gstTrainInfo[wBufIndex].szTrainIteData[ii].dwTrainHeadLinkOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].szTrainIteData[ii].wTrainTailLinkId = 0U; + gstTrainInfo[wBufIndex].szTrainIteData[ii].dwTrainTailLinkOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].szTrainIteData[ii].cTrainDir = TRAIN_DIR_DEF; + gstTrainInfo[wBufIndex].szTrainIteData[ii].wForWardOffset = UINT16_MAX; + gstTrainInfo[wBufIndex].szTrainIteData[ii].wBackOffset = UINT16_MAX; + } + + /*еĺгABLϢṹ*/ + (void)CommonMemSet((void*)&gstTrainInfo[wBufIndex].strAblTrainNeedData, (UINT32)sizeof(ABLTrainInfoStru), 0U, (UINT32)sizeof(ABLTrainInfoStru)); + gstTrainInfo[wBufIndex].wTrainHeadSigId = 0U; + gstTrainInfo[wBufIndex].wTrainHeadTrainId = TRAIN_ID_MAX; + gstTrainInfo[wBufIndex].chTrainLocReverseRouteFlag = TRAIN_LOC_REV_ROUTE_FLAG_NONE; + + gstTrainInfo[wBufIndex].chAblTrainDir = DIR_INVALID; + gstTrainInfo[wBufIndex].wAblTrainMaxHeadLink = 0U; + gstTrainInfo[wBufIndex].dwAblTrainMaxHeadOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].wAblTrainMinTailLink = 0U; + gstTrainInfo[wBufIndex].dwAblTrainMinTailOffset = UINT32_MAX; + + gstTrainInfo[wBufIndex].chVirHeadScreenPassFlag = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; + gstTrainInfo[wBufIndex].chVirTailScreenPassFlag = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; + gstTrainInfo[wBufIndex].wEnterLjkLinkId = 0U; + gstTrainInfo[wBufIndex].dwTrainFullEnterLjkCycNum = 0U; + + gstTrainInfo[wBufIndex].chTrainPosMonitorState = TRAIN_POS_MONITOR_INVALID; /*гλüල״̬ʼΪЧ*/ + gstTrainInfo[wBufIndex].wTrainPosMonitorInLink = 0U; /*гλüලЧʱlinkΪ0*/ + + gstTrainInfo[wBufIndex].dwStartFlyCycNum = 0U; + gstTrainInfo[wBufIndex].chEaCmdState = TRAIN_EA_CMD_STATE_INVALID; /*гɢЧ*/ + } + else + { + + } + + +} + +/* +* ָгITEϢ +* ˵const UINT16 wTrainId гID +* const UINT16 wIteLogId Ite߼ID +* ֵvoid +* Created By LQ 2024.06.06 +*/ +void ClearTrainIteInfo(const UINT16 wTrainId, const UINT16 wIteLogId) +{ + UINT16 wBufIndex = 0U; + UINT16 wIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && (0U < wIteLogId) && (TRAIN_INC_ITE_SUM_MAX >= wIteLogId)) + { + /*ITE͵гΪĬֵ*/ + wIndex = wIteLogId - 1U; + gstTrainInfo[wBufIndex].szTrainIteData[wIndex].wTrainHeadLinkId = 0U; + gstTrainInfo[wBufIndex].szTrainIteData[wIndex].dwTrainHeadLinkOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].szTrainIteData[wIndex].wTrainTailLinkId = 0U; + gstTrainInfo[wBufIndex].szTrainIteData[wIndex].dwTrainTailLinkOffset = UINT32_MAX; + gstTrainInfo[wBufIndex].szTrainIteData[wIndex].cTrainDir = TRAIN_DIR_DEF; + gstTrainInfo[wBufIndex].szTrainIteData[wIndex].wForWardOffset = UINT16_MAX; + gstTrainInfo[wBufIndex].szTrainIteData[wIndex].wBackOffset = UINT16_MAX; + } + else + { + /*гIDǷ*/ + } +} + +/* +* гϢ +* ˵ void +* ֵ void +*/ +void ClearBackUpTrainInfo(UINT16 wTrainId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + /*еĺгABLϢṹ*/ + (void)CommonMemSet((void*)&gstTrainInfo[wBufIndex].strAblTrainNeedData, (UINT32)sizeof(ABLTrainInfoStru), 0U, (UINT32)sizeof(ABLTrainInfoStru)); + } +} + +/** +* @brief ѯгڽ·λãʹгǰС +* @param UINT16 wTrainId гID +* @param UINT16 wRouteId ·ID +* @return 0ѯʧ +* 1гδʻ· +* 2гͷʻ·δѹ +* 3гѹʼźŻ +* 4гȫʻ· +* 5гͷ· +*/ +UINT8 dsuTrainCrossSignal(const UINT16 wTrainId, const UINT16 wRouteId) +{ + UINT8 chRouteDir = 0u; + UINT16 wStartSignal = 0u; + UINT16 wEndSignal = 0u; + struct_PathPoint strTrainMaxHead = { 0u }; + struct_PathPoint strTrainMinTail = { 0u }; + str_Zone strRouteZone = { 0u }; + UINT8 chRtnVal = CI_ERROR; + str_PointInArea strRouteSwitch = { 0u }; + UINT8 chSwitchNum = 0u; + RouteSwitchStruct * pRouteSwitch = NULL; + UINT8 chIndex = 0u; + UINT8 chFunRtn = 0u; + UINT32 dwLen = UINT32_MAX; + UINT32 dwSglCrossLen = 0u; + UINT8 chDirTemp = 0u; + str_Zone strTrainZone = { 0u }; + UINT16 wLinkNum = 0u; + LOD_STRU sLODTrain = { 0U }; /*гǰλ*/ + LOD_STRU sLODRoute = { 0U }; /*·ʼλ*/ + + wStartSignal = GetRouteStartSignalId(wRouteId); + wEndSignal = GetRouteEndSignalId(wRouteId); + chRouteDir = GetSignalDirection(wStartSignal); /*·źŻȷźŻڷһlink */ + strTrainMaxHead.wLinkId = GetTrainMaxHeadLink(wTrainId); + strTrainMaxHead.dwOffset = GetTrainMaxHeadOffset(wTrainId); + strTrainMinTail.wLinkId = GetTrainMinTailLink(wTrainId); + strTrainMinTail.dwOffset = GetTrainMinTailOffset(wTrainId); + strRouteZone.Dir = chRouteDir; + strRouteZone.pStart.wLinkId = GetSignalProtectLink(wStartSignal); + strRouteZone.pStart.dwOffset = GetSignalProtectLinkOff(wStartSignal); + strRouteZone.pEnd.wLinkId = GetSignalProtectLink(wEndSignal); + strRouteZone.pEnd.dwOffset = GetSignalProtectLinkOff(wEndSignal); + strTrainZone.Dir = GetTrainDir(wTrainId); + strTrainZone.pStart.wLinkId = strTrainMinTail.wLinkId; + strTrainZone.pStart.dwOffset = strTrainMinTail.dwOffset; + strTrainZone.pEnd.wLinkId = strTrainMaxHead.wLinkId; + strTrainZone.pEnd.dwOffset = strTrainMaxHead.dwOffset; + + chSwitchNum = GetRouteSwitchSum(wRouteId); + pRouteSwitch = GetRouteSwitchData(wRouteId); + + if ((DIR_SAME == chRouteDir) || (DIR_CONVERT == chRouteDir)) + { + chRtnVal = CI_SUCCESS; + } + else + { + ;/* βϷ */ + } + + if (CI_SUCCESS == chRtnVal) + { + chRtnVal = CheckLinkValid(strTrainMaxHead.wLinkId, strTrainMaxHead.dwOffset); + chRtnVal &= CheckLinkValid(strTrainMinTail.wLinkId, strTrainMinTail.dwOffset); + chRtnVal &= CheckLinkValid(strRouteZone.pStart.wLinkId, strRouteZone.pStart.dwOffset); + chRtnVal &= CheckLinkValid(strRouteZone.pEnd.wLinkId, strRouteZone.pEnd.dwOffset); + } + else + { + ;/* βϷ */ + } + + if (CI_SUCCESS == chRtnVal) + { + for (chIndex = 0u; chIndex < chSwitchNum; chIndex++) + { + strRouteSwitch.SwitchInfo[chIndex].pointID = pRouteSwitch[chIndex].SwitchId; + strRouteSwitch.SwitchInfo[chIndex].status = pRouteSwitch[chIndex].SwitchPosition; + } + strRouteSwitch.SwitchNum = chSwitchNum; + /* ȡ·link */ + chRtnVal = dsuLinkSeqInAreaBaseSwitchInfo(strRouteZone.pStart, strRouteZone.pEnd, strRouteZone.Dir, &strRouteSwitch, &strRouteZone.pLinkSeq); + chRtnVal &= DsuLinkSeqBtwPoints(&strTrainZone.pStart, &strTrainZone.pEnd, &strTrainZone.Dir, &wLinkNum, strTrainZone.pLinkSeq.szLinkId); + strTrainZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + } + else + { + ; + } + + if (CI_SUCCESS == chRtnVal) + { + chFunRtn = IsPointInPath(strTrainMaxHead, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + /* гȫǰ˲ڽ·ڣжгβ */ + chFunRtn = IsPointInPath(strTrainMinTail, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + chRtnVal = TRAIN_ENTER_ROUTE_NO;/* гβڽ· */ + chFunRtn = IsPointInPath(strRouteZone.pStart, strTrainZone); + if (CI_ERROR == chFunRtn) + { + chFunRtn = IsPointInPath(strRouteZone.pEnd, strTrainZone); + if (CI_ERROR == chFunRtn) + { + chRtnVal = TRAIN_ENTER_ROUTE_TAIL; + } + else + { + ; + } + } + else + { + ; + } + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_TAIL;/* гͷڽ·ڣβڽ· */ + } + } + else + { + /* гȫͷڽ· */ + chFunRtn = IsPointInPath(strTrainMinTail, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + dwSglCrossLen = (UINT32)GetSigCrossMaxLen()*100U; + dwLen = DsuAPointToBPoint(&strRouteZone.pStart, &strTrainMaxHead, &chDirTemp); + + if (0U == dwLen) + { + sLODTrain.Lnk = strTrainZone.pStart.wLinkId; + sLODTrain.Off = strTrainZone.pStart.dwOffset; + sLODTrain.Dir = strTrainZone.Dir; + sLODRoute.Lnk = strRouteZone.pStart.wLinkId; + sLODRoute.Off = strRouteZone.pStart.dwOffset; + sLODRoute.Dir = strRouteZone.Dir; + chFunRtn = IsPointABSameDir(sLODTrain, sLODRoute); + + if (FLAG_SET == chFunRtn) + { + /*гʻ·Ϊгͷʻ*/ + chRtnVal = TRAIN_ENTER_ROUTE_HEAD;/* гͷʻ*/ + } + else + { + chRtnVal = CI_ERROR; /*෴ʧ*/ + } + + } + else if ((UINT32_MAX == dwLen) || (chDirTemp != chRouteDir)) + { + chRtnVal = CI_ERROR;/* ѯ */ + } + else if(dwLen > dwSglCrossLen) + { + chRtnVal = TRAIN_ENTER_ROUTE_CROSS;/* гѹźŻ */ + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_HEAD;/* гͷʻ·δѹ */ + } + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_FULL;/* гȫʻ· */ + } + } + } + else + { + ; + } + + + + return chRtnVal; +} + + +/** +* @brief ѯгڽ·λ ʹгСǰС +* @param UINT16 wTrainId гID +* @param UINT16 wRouteId ·ID +* @return 0ѯʧ +* 1гδʻ· +* 2гͷʻ·δѹ +* 3гѹź +* 4гȫʻ· +* 5гͷ· +*/ +UINT8 dsuTrainMinHeadCrossSignal(const UINT16 wTrainId, const UINT16 wRouteId) +{ + UINT8 chRouteDir = 0u; + UINT16 wStartSignal = 0u; + UINT16 wEndSignal = 0u; + struct_PathPoint strTrainMinHead = { 0u }; + struct_PathPoint strTrainMinTail = { 0u }; + str_Zone strRouteZone = { 0u }; + UINT8 chRtnVal = CI_ERROR; + str_PointInArea strRouteSwitch = { 0u }; + UINT8 chSwitchNum = 0u; + RouteSwitchStruct * pRouteSwitch = NULL; + UINT8 chIndex = 0u; + UINT8 chFunRtn = 0u; + UINT32 dwLen = UINT32_MAX; + UINT8 chDirTemp = 0u; + str_Zone strTrainZone = { 0u }; + UINT16 wLinkNum = 0u; + LOD_STRU sLODTrain = { 0U }; /*гǰλ*/ + LOD_STRU sLODRoute = { 0U }; /*·ʼλ*/ + UINT32 dwSglCrossLen = 0U;/*ѹ룬*/ + + dwSglCrossLen = (UINT32)GetSigCrossMaxLen() * 100U; + wStartSignal = GetRouteStartSignalId(wRouteId); + wEndSignal = GetRouteEndSignalId(wRouteId); + chRouteDir = GetSignalDirection(wStartSignal); + strTrainMinHead.wLinkId = GetTrainMinHeadLink(wTrainId); + strTrainMinHead.dwOffset = GetTrainMinHeadOffset(wTrainId); + strTrainMinTail.wLinkId = GetTrainMinTailLink(wTrainId); + strTrainMinTail.dwOffset = GetTrainMinTailOffset(wTrainId); + strRouteZone.Dir = chRouteDir; + strRouteZone.pStart.wLinkId = GetSignalProtectLink(wStartSignal); + strRouteZone.pStart.dwOffset = GetSignalProtectLinkOff(wStartSignal); + strRouteZone.pEnd.wLinkId = GetSignalProtectLink(wEndSignal); + strRouteZone.pEnd.dwOffset = GetSignalProtectLinkOff(wEndSignal); + strTrainZone.Dir = GetTrainDir(wTrainId); + strTrainZone.pStart.wLinkId = strTrainMinTail.wLinkId; + strTrainZone.pStart.dwOffset = strTrainMinTail.dwOffset; + strTrainZone.pEnd.wLinkId = strTrainMinHead.wLinkId; + strTrainZone.pEnd.dwOffset = strTrainMinHead.dwOffset; + + chSwitchNum = GetRouteSwitchSum(wRouteId); + pRouteSwitch = GetRouteSwitchData(wRouteId); + + if ((DIR_SAME == chRouteDir) || (DIR_CONVERT == chRouteDir)) + { + chRtnVal = CI_SUCCESS; + } + else + { + ;/* βϷ */ + } + + if (CI_SUCCESS == chRtnVal) + { + chRtnVal = CheckLinkValid(strTrainMinHead.wLinkId, strTrainMinHead.dwOffset); + chRtnVal &= CheckLinkValid(strTrainMinTail.wLinkId, strTrainMinTail.dwOffset); + chRtnVal &= CheckLinkValid(strRouteZone.pStart.wLinkId, strRouteZone.pStart.dwOffset); + chRtnVal &= CheckLinkValid(strRouteZone.pEnd.wLinkId, strRouteZone.pEnd.dwOffset); + } + else + { + ;/* βϷ */ + } + + if (CI_SUCCESS == chRtnVal) + { + for (chIndex = 0u; chIndex < chSwitchNum; chIndex++) + { + strRouteSwitch.SwitchInfo[chIndex].pointID = pRouteSwitch[chIndex].SwitchId; + strRouteSwitch.SwitchInfo[chIndex].status = pRouteSwitch[chIndex].SwitchPosition; + } + strRouteSwitch.SwitchNum = chSwitchNum; + /* ȡ·link */ + chRtnVal = dsuLinkSeqInAreaBaseSwitchInfo(strRouteZone.pStart, strRouteZone.pEnd, strRouteZone.Dir, &strRouteSwitch, &strRouteZone.pLinkSeq); + chRtnVal &= DsuLinkSeqBtwPoints(&strTrainZone.pStart, &strTrainZone.pEnd, &strTrainZone.Dir, &wLinkNum, strTrainZone.pLinkSeq.szLinkId); + strTrainZone.pLinkSeq.cLinkCnt = (UINT8)wLinkNum; + } + else + { + ; + } + + if (CI_SUCCESS == chRtnVal) + { + chFunRtn = IsPointInPath(strTrainMinHead, strRouteZone); + /* гСȫǰ˲ڽ·ڣжгβ */ + if (CI_SUCCESS == chFunRtn) + { + chFunRtn = IsPointInPath(strTrainMinTail, strRouteZone); + if (CI_SUCCESS == chFunRtn) + { + chRtnVal = TRAIN_ENTER_ROUTE_NO;/* гβڽ· */ + chFunRtn = IsPointInPath(strRouteZone.pStart, strTrainZone); + if (CI_ERROR == chFunRtn) + { + chFunRtn = IsPointInPath(strRouteZone.pEnd, strTrainZone); + if (CI_ERROR == chFunRtn) + { + chRtnVal = TRAIN_ENTER_ROUTE_TAIL; + } + else + { + ; + } + } + else + { + ; + } + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_TAIL;/* гͷڽ·ڣβڽ· */ + } + } + /* гСȫͷڽ· */ + else + { + chFunRtn = IsPointInPath(strTrainMinTail, strRouteZone); + /*βڽ·*/ + if (CI_SUCCESS == chFunRtn) + { + dwLen = DsuAPointToBPoint(&strRouteZone.pStart, &strTrainMinHead, &chDirTemp); + + if (0U == dwLen) + { + sLODTrain.Lnk = strTrainZone.pStart.wLinkId; + sLODTrain.Off = strTrainZone.pStart.dwOffset; + sLODTrain.Dir = strTrainZone.Dir; + sLODRoute.Lnk = strRouteZone.pStart.wLinkId; + sLODRoute.Off = strRouteZone.pStart.dwOffset; + sLODRoute.Dir = strRouteZone.Dir; + chFunRtn = IsPointABSameDir(sLODTrain, sLODRoute); + + if (FLAG_SET == chFunRtn) + { + /*гʻ·Ϊгͷʻ*/ + chRtnVal = TRAIN_ENTER_ROUTE_HEAD;/* гͷʻ*/ + } + else + { + chRtnVal = CI_ERROR; /*෴ʧ*/ + } + } + else if ((UINT32_MAX == dwLen) || (chDirTemp != chRouteDir)) + { + chRtnVal = CI_ERROR;/* ѯ */ + } + else if (dwLen > dwSglCrossLen) + { + chRtnVal = TRAIN_ENTER_ROUTE_CROSS;/* гѹźŻ */ + } + else + { + chRtnVal = TRAIN_ENTER_ROUTE_HEAD;/* гͷʻ*/ + } + } + /*βڽ·*/ + else + { + chRtnVal = TRAIN_ENTER_ROUTE_FULL;/* гȫʻ· */ + } + } + } + else + { + ; + } + + + + return chRtnVal; +} +/* +* ָгȫͷǷռòͨ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chFlag +* ֵ CI_ERROR: ʧ +CI_SUCCESS:ݳɹ +* : 2022.3.1 +* ޸bug YF0083-119 +*/ +UINT8 SetTrainSafeHeadFlag(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + UINT8 chFunRtn = CI_ERROR; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chFunRtn = IsTrainInSafeArea(gstTrainInfo[wBufIndex].strSafeLoc.wHeadLink, gstTrainInfo[wBufIndex].strSafeLoc.dwHeadOffset); + if (CI_SUCCESS == chFunRtn) + { + gstTrainInfo[wBufIndex].strSafeLoc.chHeadFlag = TRAIN_HEAD_FLAG_NO; + } + else + { + gstTrainInfo[wBufIndex].strSafeLoc.chHeadFlag = TRAIN_HEAD_FLAG_YES; + } + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгȫͷռòͨ־ +* ˵ const UINT16 wTrainId, гID +* ֵ гȫͷռòͨ־ +TRAIN_HEAD_FLAG_YES:гȫͷռҲͨ +TRAIN_HEAD_FLAG_NO:гȫͷռҲͨ +* : 2022.3.1 +*/ +UINT8 GetTrainSafeHeadFlag(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strSafeLoc.chHeadFlag; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/** +* @brief Ϣӳʱ +* @param UINT16 wTrainId +* @return Ϣӳʱ +*/ +UINT32 GetVobcMsgDelayTime(UINT16 wTrainId) +{ + UINT32 RemainValidity = 0u; + INT32 dwFunRtn = 0; + UINT32 CurrentOwnSN = 0u; + UINT32 SNPeriod = 0u; + UINT32 srcRecvCiMsgSN = 0u; + UINT32 srcCrntOwnMsgSN = 0u; + UINT32 srcPreOwnMsgSN = 0u; + UINT32 srcPeriod = 0u; + UINT8 chId = 0u; + + chId = (UINT8)(wTrainId & UINT8_MAX); + + CurrentOwnSN = Get2oo2CurCycleNum(); + SNPeriod = GetSystemParaAppCycleTime(); + srcRecvCiMsgSN = GetHLHTHeadCtxSrcOppSN(CI_SYSTEM_TYPE_VOBC, chId); + srcCrntOwnMsgSN = GetHLHTHeadCtxSrcCrntSN(CI_SYSTEM_TYPE_VOBC, chId); + srcPreOwnMsgSN = GetHLHTHeadCtxSrcOwnSN(CI_SYSTEM_TYPE_VOBC, chId); + srcPeriod = GetHLHTHeadCtxComPeriod(CI_SYSTEM_TYPE_VOBC, chId); + + dwFunRtn = CalVobcMsgDelayTime(CurrentOwnSN, SNPeriod, srcRecvCiMsgSN, srcCrntOwnMsgSN, srcPreOwnMsgSN, srcPeriod); + + RemainValidity = (UINT32)dwFunRtn; + + return RemainValidity; +} + +/** +* @brief ȡг +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 GetTrainTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex + 1u; + UINT8 chIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chTransmitStat = 0u; + UINT16 wTrainIndex = 0u; + UINT8 chTrainNum = 0u; + if (NULL != pDataBuff) + { + for (chIndex = 0u; chIndex < (TRAIN_SUM_MAX - 1U); chIndex++) + { + wTrainId = GetTrainId(chIndex); + chTransmitStat = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_UNKNOWN != chTransmitStat) + { + wTrainIndex = GetTrainBufIndex(wTrainId); + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(TrainInfoStru), &gstTrainInfo[wTrainIndex], (UINT32)sizeof(TrainInfoStru)); + copyIndex += (UINT32)sizeof(TrainInfoStru); + chTrainNum++; + } + } + pDataBuff[curIndex] = chTrainNum; + ret = copyIndex; + } + return ret; +} + +/** +* @brief г +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 SetTrainTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex; + UINT8 chIndex = 0u; + UINT16 wTrainId = 0u; + UINT16 wTrainIndex = 0u; + UINT8 chTrainNum = 0u; + if (NULL != pDataBuff) + { + chTrainNum = pDataBuff[copyIndex++]; + for (chIndex = 0u; chIndex < chTrainNum; chIndex++) + { + wTrainId = ShortFromCharLE(&pDataBuff[copyIndex]); + wTrainIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wTrainIndex) + { + (void)CommonMemCpy(&gstTrainInfo[wTrainIndex], (UINT32)sizeof(TrainInfoStru), &pDataBuff[copyIndex], (UINT32)sizeof(TrainInfoStru)); + copyIndex += (UINT32)sizeof(TrainInfoStru); + } + } + ret = copyIndex; + } + return ret; +} + +/** +* @brief жгȫͷǷռĿ +* @param wLinkId гȫͷlink +* @return CI_ERROR:гȫͷռĿCI_SUCCESS:гȫͷδռĿ +* @note +*/ +static UINT8 IsTrainInSafeArea(UINT16 wLinkId, UINT32 dwOffset) +{ + UINT8 chSwitchNum = 0u; + LogsecSwitchStruct *pSwitchBuff = NULL; + UINT8 chIndex = 0u; + UINT8 chRtn = CI_ERROR; + UINT16 wSwitchId = 0u; + UINT8 chSwitchState = SWITCH_POSITION_SIKAI; + UINT16 szLgcIdBuf[POINT_BELONG_LGC_MAX] = { 0u }; + UINT8 chLgcNum = 0u; + struct_PathPoint strPoint = { 0u }; + UINT8 chLgcIndex = 0u; + UINT16 wPhyId = 0u; + UINT8 chPhyState = SECTION_OCCUPY_YES; + + /* μ */ + chRtn = CheckLinkValid(wLinkId, dwOffset); + if (CI_SUCCESS == chRtn) + { + strPoint.wLinkId = wLinkId; + strPoint.dwOffset = dwOffset; + chLgcNum = GetPointBelongLogSecEx(strPoint, szLgcIdBuf); + if ((0u == chLgcNum) || (POINT_BELONG_LGC_MAX < chLgcNum)) + {/* ȡ߼ʧܣֱӷʧ */ + chRtn = CI_ERROR; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + for (chLgcIndex = 0u; chLgcIndex < chLgcNum; chLgcIndex++) + {/* ߼Σ߼ΰռĿʧ */ + wPhyId = GetLgcSecRelativePhySecId(szLgcIdBuf[chLgcIndex]); + chPhyState = GetPhySecCurOccupyState(wPhyId); + chSwitchNum = GetLogicSecSwitchSum(szLgcIdBuf[chLgcIndex]); + pSwitchBuff = GetLogicSecSwitchIdStru(szLgcIdBuf[chLgcIndex]); + if (NULL == pSwitchBuff) + { + chRtn = CI_ERROR; + } + else if (SECTION_OCCUPY_YES == chPhyState) + { + for (chIndex = 0u; chIndex < chSwitchNum; chIndex++) + { + wSwitchId = pSwitchBuff[chIndex].SwitchId; + chSwitchState = GetSwitchCurPosition(wSwitchId); + if ((SWITCH_POSITION_DINGWEI != chSwitchState) && (SWITCH_POSITION_FANWEI != chSwitchState)) + {/* ռҵĿ */ + chRtn = CI_ERROR; + break; + } + else + { + ; + } + } + } + else + { + /**/ + ; + } + + if (CI_ERROR == chRtn) + { + break; + } + else + { + ; + } + } + } + else + { + ; + } + } + else + { + ; + } + return chRtn; +} + +/* +* ָгʱһгID +* ˵ const UINT16 wTrainId, гID +* const UINT16 wGroupOtherTrainId һгID +* ֵ 0: ȡʧ 1: ݳɹ +* : wsd 2022 - 06 - 16 +*/ +UINT8 SetGroupTrainOtherId(const UINT16 wTrainId, const UINT16 wGroupOtherTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (((TRAIN_ID_MIN < wGroupOtherTrainId) && (TRAIN_ID_MAX > wGroupOtherTrainId)) + || (TRAIN_ID_INVAL == wGroupOtherTrainId)) + { + gstTrainInfo[wBufIndex].wGroupOtherTrainId = wGroupOtherTrainId; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгʱһгID +* ˵ const UINT16 wTrainId, гID +* ֵ ȡɹ0x1400-0x14ff0xffff +* ȡʧܣ0 +* : wsd 2022-06-16 +*/ +UINT16 GetGroupTrainOtherId(const UINT16 wTrainId) +{ + UINT16 wRetVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wGroupOtherTrainId; + } + else + { + wRetVal = 0u; + } + + return wRetVal; +} + +/* +* ָг״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chGroupRunState ״̬ +* ֵ 0: ȡʧ 1: ݳɹ +* : wsd 2022 - 06 - 16 +*/ +UINT8 SetGroupTrainRunState(const UINT16 wTrainId, const UINT8 chGroupRunState) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((VOBC_CI_GROUP_NO == chGroupRunState) || + (VOBC_CI_GROUP_SET == chGroupRunState) || + (VOBC_CI_GROUP_RUN == chGroupRunState) || + (VOBC_CI_GROUP_REVERSE == chGroupRunState) || + (VOBC_CI_GROUP_EXIT == chGroupRunState)) + { + gstTrainInfo[wBufIndex].chGroupRunState = chGroupRunState; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָг״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ ȡɹ1DZ飬2齨3У4۷5 + ȡʧܣ0 +* : wsd 2022-06-16 +*/ +UINT8 GetGroupTrainRunState(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chGroupRunState; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ָгǰ󳵹ϵ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chGroupRunState ״̬ +* ֵ 0: ʧ 1: ݳɹ +* : wsd 2022 - 06 - 16 +*/ +UINT8 SetGroupTrainRelation(const UINT16 wTrainId, const UINT8 chGroupTrainReat) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if((VOBC_CI_GROUP_HEAD == chGroupTrainReat) || + (VOBC_CI_GROUP_TAIL == chGroupTrainReat) || + (VOBC_CI_GROUP_INVAL == chGroupTrainReat)) + { + gstTrainInfo[wBufIndex].chGroupTrainReat = chGroupTrainReat; + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* ȡָгǰ󳵹ϵ +* ˵ const UINT16 wTrainId, гID +* ֵ ȡɹ0x55Ϊǰ 0xaaΪ 0x5a DZ鳵 +* ȡʧܣ0 +* : wsd 2022-06-16 +*/ +UINT8 GetGroupTrainRelation(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chGroupTrainReat; + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* гAгBΪгж +* ˵ const UINT16 wTrainA, гAгB +* ֵ 0 :DZг +* 1:DZг +* : wsd 2022-06-16 +*/ +UINT8 isTwoGroupRunTrain(const UINT16 wTrainA, const UINT16 wTrainB) +{ + UINT16 wGroupOtherTrainA = 0u; + UINT16 wGroupOtherTrainB = 0u; + UINT8 chGroupStateA = 0U; + UINT8 chGroupStateB = 0U; + UINT8 chGroupRelateA = 0u; + UINT8 chGroupRelateB = 0u; + UINT8 chRetVal = CI_ERROR; + + if ((TRAIN_ID_MIN >= wTrainA) || (TRAIN_ID_MAX <= wTrainA) || + (TRAIN_ID_MIN >= wTrainB) || (TRAIN_ID_MAX <= wTrainB)) + { + chRetVal = CI_ERROR; + } + else + { + chRetVal = CI_SUCCESS; + } + + + if (CI_SUCCESS == chRetVal) + { + /*һID*/ + wGroupOtherTrainA = GetGroupTrainOtherId(wTrainA); + wGroupOtherTrainB = GetGroupTrainOtherId(wTrainB); + + /*г״̬*/ + chGroupStateA = GetGroupTrainRunState(wTrainA); + chGroupStateB = GetGroupTrainRunState(wTrainB); + + /*гǰ󳵹ϵ*/ + chGroupRelateA = GetGroupTrainRelation(wTrainA); + chGroupRelateB = GetGroupTrainRelation(wTrainB); + + /*ڱ״̬*/ + if ((VOBC_CI_GROUP_RUN == chGroupStateA) && + (VOBC_CI_GROUP_RUN == chGroupStateB)) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + /*Ϊһ*/ + if (CI_SUCCESS == chRetVal) + { + if ((wGroupOtherTrainA == wTrainB) && (wGroupOtherTrainB == wTrainA)) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + + } + } + else + { + /* */ + } + + /*ǰ󳵹ϵȷ*/ + if (CI_SUCCESS == chRetVal) + { + if ((chGroupRelateA != chGroupRelateB) && + (chGroupRelateA != VOBC_CI_GROUP_INVAL) && + (chGroupRelateB != VOBC_CI_GROUP_INVAL)) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + /* */ + } + } + + return chRetVal; +} + +/* +* ָIDгǷΪǰ +* ˵ const UINT16 wTrainId, гID +* ֵ 0 DZǰ + 1 DZǰ +* : wsd 2022-06-16 +*/ +UINT8 isGroupHeadTrain(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + UINT8 chGroupState = VOBC_CI_GROUP_NO; + UINT8 chGroupRelate = VOBC_CI_GROUP_INVAL; + UINT16 wGroupOther = TRAIN_ID_INVAL; + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + if (CI_SUCCESS == chRetVal) + { + chGroupState = GetGroupTrainRunState(wTrainId); + chGroupRelate = GetGroupTrainRelation(wTrainId); + wGroupOther = GetGroupTrainOtherId(wTrainId); + + /* 齨С۷*/ + if ((VOBC_CI_GROUP_SET == chGroupState) || + (VOBC_CI_GROUP_RUN == chGroupState) || + (VOBC_CI_GROUP_REVERSE == chGroupState)) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + + /*ǰһ鳵IDЧ*/ + if ((CI_SUCCESS == chRetVal)&& + (VOBC_CI_GROUP_HEAD == chGroupRelate)&& + (TRAIN_ID_INVAL != wGroupOther)) + { + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + + return chRetVal; +} + +/** +* @brief ȡϵͨг +* @param UINT16 wAcId α +* @param UINT16 szTrainId[TRAIN_SUM_MAX] ͨгID +* @return ͨг +* @note +*/ +UINT8 GetTrainInAc(UINT16 wAcId, UINT16 szTrainId[TRAIN_SUM_MAX]) +{ + UINT8 chIndex = 0u; + UINT8 chCtNum = 0u; + UINT16 wTrainId = 0u; + struct_PathPoint strMaxHead = { 0u }; + struct_PathPoint strMinTail = { 0u }; + UINT8 chFunRtn = CI_ERROR; + UINT8 chTransState = 0u; + UINT8 chDir = 0u; + UINT16 wLinkNum = 0u; + UINT16 szLinkId[LINK_SUM_MAX] = { 0u }; + UINT16 wAcNum = 0u; + UINT16 szAcId[SECTION_IN_ENVELOPE_SUM_MAX] = { 0u }; + UINT16 wAcIndex = 0u; + + for (chIndex = 0u; chIndex < TRAIN_SUM_MAX; chIndex++) + { + wAcIndex = 0u; + wAcNum = 0u; + wTrainId = GetTrainId(chIndex); + chTransState = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_GOOD == chTransState) + { + strMaxHead.wLinkId = GetTrainMaxHeadLink(wTrainId); + strMaxHead.dwOffset = GetTrainMaxHeadOffset(wTrainId); + strMinTail.wLinkId = GetTrainMinTailLink(wTrainId); + strMinTail.dwOffset = GetTrainMinTailOffset(wTrainId); + chFunRtn = DsuLinkSeqBtwPoints(&strMaxHead, &strMinTail, &chDir, &wLinkNum, szLinkId); + + if (CI_SUCCESS == chFunRtn) + { + chFunRtn = GetAxisSeqFromLinkSeq(szLinkId, wLinkNum, szAcId, &wAcNum, SECTION_IN_ENVELOPE_SUM_MAX); + if (CI_SUCCESS == chFunRtn) + { + for (wAcIndex = 0u; wAcIndex < wAcNum; wAcIndex++) + { + if (szAcId[wAcIndex] == wAcId) + { + break; + } + else + { + ; + } + } + } + else + { + ; + } + } + else + { + ; + } + + if ((CI_SUCCESS == chFunRtn) && (wAcIndex < wAcNum)) + { + szTrainId[chCtNum++] = wTrainId; + } + else + { + ; + } + } + else + { + ; + } + } + return chCtNum; +} + +/** +* @brief жгβǷοʻ +* @param UINT16 wTrainId гID +* @param struct_PathPoint strPoint յ +* @return CI_SUCCESS:гοʻCI_ERROR:гʻο +* @note +*/ +UINT8 IsTrainMoveToPoint(UINT16 wTrainId, struct_PathPoint strPoint) +{ + UINT32 dwLen = 0u; + struct_PathPoint strPointTrain = { 0u }; + UINT8 chDir = 0u; + UINT8 chTrainDir = 0u; + UINT8 chRtn = CI_SUCCESS; + UINT8 chSpeedDir = 0u; + UINT8 chLocalTiocId = 0u; + UINT16 wTrainTiocId = 0u; + UINT8 chConverTrainDir = 0u; + + chLocalTiocId = GetSystemParaLocalCiId(); + + chSpeedDir = GetTrainSpeedDir(wTrainId); + if (TRAIN_SPEED_FRONT == chSpeedDir) + { + strPointTrain.wLinkId = GetTrainMinTailLink(wTrainId); + strPointTrain.dwOffset = GetTrainMinTailOffset(wTrainId); + wTrainTiocId = GetLinkManageTiocById(strPointTrain.wLinkId); + chTrainDir = GetTrainDir(wTrainId);/*гСȫз*/ + chConverTrainDir = ConvertTrainDir(chTrainDir); + } + else + { + strPointTrain.wLinkId = GetTrainMaxHeadLink(wTrainId); + strPointTrain.dwOffset = GetTrainMaxHeadOffset(wTrainId); + wTrainTiocId = GetLinkManageTiocById(strPointTrain.wLinkId); + chTrainDir = GetTrainDir_MaxHead(wTrainId);/*гȫǰз*/ + chConverTrainDir = ConvertTrainDir(chTrainDir); + } + + if (0u == chLocalTiocId) + { + chRtn = CI_SUCCESS; + } + else if (chLocalTiocId == wTrainTiocId) + { + dwLen = DsuAPointToBPoint(&strPointTrain, &strPoint, &chDir); + if (UINT32_MAX == dwLen) + { + chRtn = CI_SUCCESS; + } + else if (((chDir == chTrainDir) && (TRAIN_SPEED_FRONT == chSpeedDir)) + || ((chDir == chConverTrainDir) && (TRAIN_SPEED_BACK == chSpeedDir))) + { + chRtn = CI_SUCCESS; + } + else + { + chRtn = CI_ERROR; + } + } + else + { + chRtn = CI_ERROR; + } + + return chRtn; +} + +/* +* ָгϢԴTIOC +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTiocId TIOC +* ֵ +*/ +void SetTrainMsgFromTiocId(const UINT16 wTrainId, const UINT8 chTiocId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].chMsgFromTiocId = chTiocId; + } + else + { + ; + } +} + +/* +* ȡָгԴTIOC +* ˵ const UINT16 wTrainId, гID +* ֵ ԴTIOC +*/ +UINT8 GetTrainMsgFromTiocId(const UINT16 wTrainId) +{ + UINT8 chRetVal = 0u; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chMsgFromTiocId; + } + else + { + ; + } + + return chRetVal; +} + +/* +* TIOCͨжϣг +* ˵ UINT8 chTiocId TIOC +* ֵ +*/ +void NeighborOutTrainProc(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chFromId = 0u; + for (chIndex = 0u; chIndex < TRAIN_SUM_MAX; chIndex++) + { + wTrainId = GetTrainId(chIndex); + chFromId = GetTrainMsgFromTiocId(wTrainId); + if (chFromId == chTiocId) + { + SetTrainMsgFromTiocId(wTrainId, 0u); + (void)SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_BAD); + } + else + { + ; + } + } +} + +/* +* TIOCͨãг +* ˵ UINT8 chTiocId TIOC +* ֵ +* notebug YF0083-205 +*/ +void NeighborGoodTrainProc(UINT8 chTiocId) +{ + UINT8 chIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chFromId = 0u; + UINT32 dwCurCyc = 0u; + UINT32 dwRecvCyc = 0u; + UINT8 chCtNum = 0u; + UINT16 *pCtIds = NULL; + UINT8 chCtIndex = 0u; + UINT16 dwCycTime = 0u; + UINT32 dwDelayTime = 0u; + UINT8 chLocalId = 0u; + + chLocalId = GetSystemParaLocalCiId(); + dwCycTime = GetSystemParaValue(AppCycleTime_ID); + dwCurCyc = Get2oo2CurCycleNum(); + for (chIndex = 0u; chIndex < TRAIN_SUM_MAX; chIndex++) + { + wTrainId = GetTrainId(chIndex); + chFromId = GetTrainMsgFromTiocId(wTrainId); + if (chFromId == chTiocId) + { + dwRecvCyc = GetCiTransmitRecvDataCycNum(chLocalId, CI_SYSTEM_TYPE_CI, chTiocId); + dwDelayTime = GetTrainMsgDelayTime(wTrainId); + chCtNum = GetTiocTransmitCtNum(chTiocId); + pCtIds = GetTiocTransmitCtIds(chTiocId); + for (chCtIndex = 0u; chCtIndex < chCtNum; chCtIndex++) + { + if (wTrainId == pCtIds[chCtIndex]) + { + break; + } + else + { + ; + } + } + + if (chCtIndex == chCtNum) + { + SetTrainMsgFromTiocId(wTrainId, 0u); + (void)SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_BAD); + } + else + { + dwDelayTime += ((dwCurCyc - dwRecvCyc) * ((UINT32)(dwCycTime))); + (void)SetTrainMsgDelayTime(wTrainId, dwDelayTime); + } + } + else + { + ; + } + } +} + +/* +* ָг״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chState ״̬ +* ֵ +*/ +void SetTrainSleepState(const UINT16 wTrainId, const UINT8 chState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && ((TRAIN_SLEEP_YES == chState) || (TRAIN_SLEEP_NO == chState))) + { + if ((TRAIN_SLEEP_YES == gstTrainInfo[wBufIndex].chSwState) && (TRAIN_SLEEP_NO == chState)) + { + gstTrainInfo[wBufIndex].chTrainCanUct = FLAG_SET; + } + else + { + ; /* */ + } + gstTrainInfo[wBufIndex].chSwState = chState; + } + else + { + ; + } +} + +/* +* ȡָг״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ г״̬ +*/ +UINT8 GetTrainSleepState(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_SLEEP_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chSwState; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгLinkId +* ˵ const UINT16 wTrainId, гID +* const UINT16 wLinkId link +* ֵ +*/ +void SetTrainSleepLink(const UINT16 wTrainId, const UINT16 wLinkId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].wSleepLink = wLinkId; + } + else + { + ; + } +} + +/* +* ȡָгlink +* ˵ const UINT16 wTrainId, гID +* ֵ гlink +*/ +UINT16 GetTrainSleepLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = 0u; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wSleepLink; + } + else + { + ; + } + + return wRetVal; +} + +/* +* ָгģʽ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chMode ģʽ +* ֵ +*/ +void SetTrainMode(const UINT16 wTrainId, const UINT8 chMode) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_MODE_DEFAULT == chMode) || (TRAIN_MODE_RM == chMode) + || (TRAIN_MODE_CM == chMode) || (TRAIN_MODE_AM == chMode) + || (TRAIN_MODE_EUM == chMode) || (TRAIN_MODE_RD == chMode) + || (TRAIN_MODE_AR == chMode) || (TRAIN_MODE_FAM == chMode) + || (TRAIN_MODE_CAM == chMode) || (TRAIN_MODE_RRM == chMode) + || (TRAIN_MODE_VCM == chMode))) + { + gstTrainInfo[wBufIndex].chTrainModel = chMode; + } + else + { + ; + } +} + +/* +* ȡָгģʽ +* ˵ const UINT16 wTrainId, гID +* ֵ гģʽ +*/ +UINT8 GetTrainMode(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_MODE_DEFAULT; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainModel; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָг״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chState ״̬ +* ֵ +*/ +void SetTrainWakeState(const UINT16 wTrainId, const UINT8 chState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_WAKE_SUCCESS == chState) || (TRAIN_WAKE_PROCESS == chState) + || (TRAIN_WAKE_FAILURE == chState) || (TRAIN_WAKE_DEFAULT == chState))) + { + gstTrainInfo[wBufIndex].chWakeState = chState; + } + else + { + ; + } +} + +/* +* ȡָг״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ г״̬ +*/ +UINT8 GetTrainWakeState(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_WAKE_DEFAULT; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chWakeState; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָг㱨״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chState г㱨״̬ +* ֵ +*/ +void SetTrainReportState(const UINT16 wTrainId, const UINT8 chState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].chTrainReportState = chState; + } + else + { + ; + } +} + +/* +* ȡָг㱨״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ г㱨״̬ +*/ +UINT8 GetTrainReportState(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainReportState; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָг̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chCmd ̬ +* ֵ +*/ +void SetTrainDynCmd(const UINT16 wTrainId, const UINT8 chCmd) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_CMD_DYM_YES == chCmd) || (TRAIN_CMD_DYM_NO == chCmd))) + { + gstTrainInfo[wBufIndex].chDynCmd = chCmd; + } + else + { + ; + } +} + +/* +* ȡָг̬ +* ˵ const UINT16 wTrainId, гID +* ֵ г̬ +*/ +UINT8 GetTrainDynCmd(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_CMD_DYM_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chDynCmd; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָг̬Իظ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chRpl ̬Իظ +* ֵ +*/ +void SetTrainDynRpl(const UINT16 wTrainId, const UINT8 chRpl) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_DYN_RPL_AGREE == chRpl) || (TRAIN_DYN_RPL_REFUSE == chRpl) + || (TRAIN_DYN_RPL_FAILURE == chRpl) || (TRAIN_DYN_RPL_DEFAULT == chRpl))) + { + gstTrainInfo[wBufIndex].chDynRpl = chRpl; + } + else + { + ; + } +} + +/* +* ȡָг̬Իظ +* ˵ const UINT16 wTrainId, гID +* ֵ г̬Իظ +*/ +UINT8 GetTrainDynRpl(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_DYN_RPL_DEFAULT; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chDynRpl; + } + else + { + ; + } + + return chRetVal; +} + +/* +* г̬Դ +* ˵ +* ֵ +*/ +static void TrainDynProc(void) +{ + UINT8 chTrainIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chDynCmd = 0u; + UINT16 wMaxHeadLink = 0u; + UINT16 wMinHeadLink = 0u; + UINT16 wMaxTailLink = 0u; + UINT16 wMinTailLink = 0u; + UINT16 wPhyId = 0u; + UINT8 chFlockState = 0u; + UINT16 wSysParamDyMax = GetSystemParaValue(DYTEST_SUM_MAX_ID); + UINT8 chDyMax = (UINT8)(wSysParamDyMax & 0x00ffu); + UINT8 chFunRtn = 0u; + UINT16 wGdId = 0u; + UINT8 chGdState = 0u; + UINT16 wElmTrainId = 0u; + UINT16 wNLink = 0u; + UINT16 wNNLink = 0u; + UINT16 wFLink = 0u; + UINT16 wFFLink = 0u; + UINT16 wSwitchId = 0u; + UINT8 chLinkTesting = CI_ERROR; + UINT16 wFPhyId = 0u; + UINT16 wNPhyId = 0u; + UINT8 chFPhyState = 0u; + UINT8 chNPhyState = 0u; + UINT8 chLinkSw = 0u; + UINT8 chDyTestSwitch = 0u; + UINT8 chZxDyTestSwitch = 0u; + UINT8 chLocalType = 0u; + UINT8 chWlbState = 0u; + const EnvelopeStruct* pElmTemp = NULL; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 cDirectionPointCnt = 0U; /*仯*/ + UINT8 cDirectionConvert = 0U; /*任,߼*/ + UINT8 cDirectionSame = 0U; /*任,߼ͬ*/ + UINT8 cAwakeCheckSpksSwitch = FUNC_SWITCH_ON; /*ѹмSPKS״̬*/ + UINT8 cPhySecFLockType = 0U; /*η*/ + UINT8 cAreaUrgentState = PHYSEC_AREA_URGENT_YES; /*г־*/ + UINT16 wGdRelAPhySecId = 0U; /*ŹAGID*/ + UINT8 chVirHeadScreenFlag = 0U;/*ǰɸ־*/ + UINT8 chVirTailScreenFlag = 0U;/*ɸ־*/ + UINT8 chSleepLinkCheckFlag = CI_ERROR;/*߻LINK־*/ + + /* ȡ̬Կ */ + chDyTestSwitch = GetDynamicTestSwitch(); + /* ȡ߶̬Կ */ + chZxDyTestSwitch = GetZXDynamicTestSwitch(); + /* ȡTIOC */ + chLocalType = GetLocalCiType(); + + cAwakeCheckSpksSwitch = GetAwakeCheckSpksSwitch(); + + if ((FUNC_SWITCH_ON == chDyTestSwitch) + && ((CI_TYPE_ZX != chLocalType) || (FUNC_SWITCH_ON == chZxDyTestSwitch))) + { + /* г */ + for (chTrainIndex = 0u; chTrainIndex < TRAIN_SUM_MAX; chTrainIndex++) + { + cAreaUrgentState = PHYSEC_AREA_URGENT_YES; /*ÿһһ־*/ + wTrainId = GetTrainId(chTrainIndex); + chDynCmd = GetTrainDynCmd(wTrainId); + cDirectionPointCnt = 0U; /*һ䷽仯*/ + cDirectionConvert = 0U; + cDirectionSame = 0U; + + /* ޶̬Ĭֵ */ + if (TRAIN_CMD_DYM_NO == chDynCmd) + { + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_DEFAULT); + } + else + { + chLinkTesting = CI_SUCCESS; + chFunRtn = IsTrainDyTesting(wTrainId); + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + wMaxTailLink = GetTrainMaxTailLink(wTrainId); + wMinTailLink = GetTrainMinTailLink(wTrainId); + wPhyId = GetLinkRelatedPhySec(wMaxHeadLink); + chFlockState = GetPhySecFLockState(wPhyId); + cPhySecFLockType = GetPhySecFLockType(wPhyId); + wElmTrainId = (wTrainId & 0x00ffu); + pElmTemp = elm_GetEnvelopeInfoByTrainID(wElmTrainId); + + wFLink = FindAdjacentLinkIDSafe(wMaxHeadLink, DIR_CONVERT, &wSwitchId, &cDirectionPointFlag); + + cDirectionConvert = TransDirectionPointDir(cDirectionPointFlag, DIR_CONVERT, &cDirectionPointCnt); /*ַ任㣬任㣬ͬʱתٲ黹޷仯*/ + + wFFLink = FindAdjacentLinkIDSafe(wFLink, cDirectionConvert, &wSwitchId, &cDirectionPointFlag); + + cDirectionConvert = TransDirectionPointDir(cDirectionPointFlag, cDirectionConvert, &cDirectionPointCnt); /*ַ任㣬ٴμ淴̬ʧ*/ + + wNLink = FindAdjacentLinkIDSafe(wMaxHeadLink, DIR_SAME, &wSwitchId, &cDirectionPointFlag); + + cDirectionSame = TransDirectionPointDir(cDirectionPointFlag, DIR_SAME, &cDirectionPointCnt); /*ַ任㣬任㣬ͬʱתٲ黹޷仯*/ + + wNNLink = FindAdjacentLinkIDSafe(wNLink, cDirectionSame, &wSwitchId, &cDirectionPointFlag); + + cDirectionSame = TransDirectionPointDir(cDirectionPointFlag, cDirectionSame, &cDirectionPointCnt); /*ַ任㣬ٴμ淴̬ʧ*/ + + chWlbState = WlbGetState(); + + cAreaUrgentState = GetPhySecAreaUrgentState(wPhyId); /*ȡεƶ־*/ + + wGdId = GetPhySecReleatedGdId(wPhyId); + + chVirHeadScreenFlag = GetTrainVirHeadScreenPassFlag(wTrainId); + chVirTailScreenFlag = GetTrainVirTailScreenPassFlag(wTrainId); + + if (0u == wGdId) + {/* ޳ţҪ鳵״̬ */ + chGdState = GARAGE_DOOR_STATE_OPEN; + } + else + { + wGdRelAPhySecId = GetGarageDoorAKuPhySec(wGdId); /*ȡŹAG*/ + if ((0U != wGdRelAPhySecId) && (wGdRelAPhySecId != wPhyId)) + { + chGdState = GARAGE_DOOR_STATE_OPEN; /*г߹dzΣ̬ԲҪ鳵״̬*/ + } + else + { + /* ȡ״̬ */ + chGdState = GetGaragedoorState(wGdId); + } + } + + if ((0u != wFLink) && (UINT16_MAX != wFLink)) + { + chLinkTesting &= IsLinkTesting(wFLink); + chLinkSw = IsLinkSwTrack(wFLink); + if (CI_SUCCESS == chLinkSw) + { + chFPhyState = SECTION_OCCUPY_NO; + } + else + {/* ̬Σ߻ѹ죬ռ״̬ */ + wFPhyId = GetLinkRelatedPhySec(wFLink); + chFPhyState = GetPhySecCurOccupyState(wFPhyId); + } + } + else if (UINT16_MAX == wFLink) + { + chFPhyState = SECTION_OCCUPY_YES; + } + else + { + chFPhyState = SECTION_OCCUPY_NO; + } + + if ((0u != wFFLink) && (UINT16_MAX != wFFLink)) + { + chLinkTesting &= IsLinkTesting(wFFLink); + } + else + { + ; + } + + if ((0u != wNLink) && (UINT16_MAX != wNLink)) + { + chLinkTesting &= IsLinkTesting(wNLink); + chLinkSw = IsLinkSwTrack(wNLink); + if (CI_SUCCESS == chLinkSw) + { + chNPhyState = SECTION_OCCUPY_NO; + } + else + {/* ̬Σ߻ѹ죬ռ״̬ */ + wNPhyId = GetLinkRelatedPhySec(wNLink); + chNPhyState = GetPhySecCurOccupyState(wNPhyId); + } + } + else if (UINT16_MAX == wNLink) + { + chNPhyState = SECTION_OCCUPY_YES; + } + else + { + chNPhyState = SECTION_OCCUPY_NO; + } + + if ((0u != wNNLink) && (UINT16_MAX != wNNLink)) + { + chLinkTesting &= IsLinkTesting(wNNLink); + } + else + { + ; + } + + chSleepLinkCheckFlag = IsLinkSwTrack(wMaxHeadLink); + + if (0U != cDirectionPointCnt) + {/*ڷ任㣬ʧ*/ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_FAILURE); + debug_infor_printf((const)"Train:%x dytest refuse: DirectionPointCnt: %d.\n", wTrainId, cDirectionPointCnt); + } + else if ((wMaxHeadLink != wMinHeadLink) || (wMinHeadLink != wMaxTailLink) + || (wMaxTailLink != wMinTailLink) || (CI_SUCCESS != chSleepLinkCheckFlag) + || (NULL == pElmTemp)) + {/* 붯̬г߻ѹ죬ʧ */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_FAILURE); + debug_infor_printf((const)"Train:%x dytest failure:chSleepLinkCheckFlag Error.\n", wTrainId); + } + else if ((PHYSICAL_SECTION_FLOCK_NO != chFlockState) + && ((FUNC_SWITCH_OFF != cAwakeCheckSpksSwitch) || ((FUNC_SWITCH_OFF == cAwakeCheckSpksSwitch) && (PHY_SEC_FLOCK_TYPE_SPKS != cPhySecFLockType)))) + {/* ηңSPKS򣨲SPKSҷSPKSͣͬ */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_REFUSE); + debug_infor_printf((const)"Train:%x dytest refuse: phy flock.\n", wTrainId); + } + else if ((gDyTestNum >= chDyMax) && (CI_ERROR == chFunRtn)) + {/* ͬʱ̬гͬ */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_REFUSE); + debug_infor_printf((const)"Train:%x dytest refuse: over max testing.\n", wTrainId); + } + else if (GARAGE_DOOR_STATE_OPEN != chGdState) + {/* δ򿪣ͬ */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_REFUSE); + debug_infor_printf((const)"Train:%x dytest refuse: gd open.\n", wTrainId); + } + else if (CI_ERROR == chLinkTesting) + {/* гڶ̬ԣͬ */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_REFUSE); + debug_infor_printf((const)"Train:%x dytest refuse: another train is dytesting.\n", wTrainId); + } + else if (((0u != pElmTemp->headTrainID) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != chVirHeadScreenFlag)) + || ((0u != pElmTemp->tailTrainID) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != chVirTailScreenFlag))) + {/* ͷ/βسͬ */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_REFUSE); + debug_infor_printf((const)"Train:%x dytest refuse: screen.\n", wTrainId); + } + else if ((SECTION_OCCUPY_NO != chFPhyState) || (SECTION_OCCUPY_NO != chNPhyState)) + {/* CDǿУͬ */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_REFUSE); + debug_infor_printf((const)"Train:%x dytest refuse: occ.\n", wTrainId); + } + else if ((WLB_UNSET != chWlbState) || (PHYSEC_AREA_URGENT_NO != cAreaUrgentState)) + {/* ȫ߽ƶ */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_REFUSE); + debug_infor_printf((const)"Train:%x dytest refuse: UrgentBrake.\n", wTrainId); + } + else + {/* ͬ⣬г붯̬б */ + SetTrainDynRpl(wTrainId, TRAIN_DYN_RPL_AGREE); + debug_infor_printf((const)"Train:%x dytest agree.\n", wTrainId); + if ((gDyTestNum < chDyMax) && (CI_ERROR == chFunRtn)) + { + AddTrainDyTesting(wTrainId, wMaxHeadLink); + } + else + { + ; + } + } + } + } + } + else + { + ; + } +} + +/* +* гѴ +* ˵ +* ֵ +* noteг״̬ΪڻѣάָóΪ߳Ϊ߳ +*/ +static void TrainWakeProc(void) +{ + UINT8 chTrainIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chWakeState = 0u; + UINT8 chTrainMode = 0u; + UINT16 wMaxHeadLink = 0u; + UINT16 wMinHeadLink = 0u; + UINT16 wMaxTailLink = 0u; + UINT16 wMinTailLink = 0u; + UINT16 wElmTrainId = 0u; + UINT16 wNAcId = 0u; + UINT16 wFAcId = 0u; + UINT16 wBAcId = 0u; + UINT8 chNAcState = 0u; + UINT8 chFAcState = 0u; + UINT8 chAcNum = 0u; + UINT16 szAcId[AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT16 wFLink = 0u; + UINT16 wNLink = 0u; + UINT16 wSwitchId = 0u; + UINT8 chSwAttributes = 0u; + UINT8 chTrainSlpStt = 0U; + UINT8 chTransState = 0u; + UINT8 chSleepCancle = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT16 wSleepLink = 0u; + UINT8 chSss = 0u; + UINT8 chZeroState = 0u; + UINT8 chFAttributes = 0u; + UINT8 chNAttributes = 0u; + const EnvelopeStruct* pElmTemp = NULL; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 chVirHeadScreenFlag = 0U;/*ǰɸ־*/ + UINT8 chVirTailScreenFlag = 0U;/*ɸ־*/ + UINT8 cLocalCiType = 0U; + UINT8 chBGAtsScreenAgUtCheck = 0U;/*BGԶɸѡAG UT*/ + + /* г */ + for (chTrainIndex = 0u; chTrainIndex < TRAIN_SUM_MAX; chTrainIndex++) + { + wTrainId = GetTrainId(chTrainIndex); + chWakeState = GetTrainWakeState(wTrainId); + chTrainMode = GetTrainMode(wTrainId); + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + wMaxTailLink = GetTrainMaxTailLink(wTrainId); + wMinTailLink = GetTrainMinTailLink(wTrainId); + wSleepLink = GetTrainSleepLink(wTrainId); + wElmTrainId = (wTrainId & 0x00ffu); + chTrainSlpStt = GetTrainSleepState(wTrainId); + pElmTemp = elm_GetEnvelopeInfoByTrainID(wElmTrainId); + wBAcId = GetLinkBelongAcId(wMaxHeadLink); + chAcNum = elm_PrepareAdjacentAC(wBAcId, DIR_CONVERT, szAcId, &cDirectionPointFlag); + if ((0u != chAcNum) && (UINT8_MAX != chAcNum)) + {/* ڼ */ + wFLink = FindAdjacentLinkIDSafe(wMaxHeadLink, DIR_CONVERT, &wSwitchId, &cDirectionPointFlag); /*ֻһlinkǷ仯*/ + chSwAttributes = IsLinkSwTrack(wFLink); + if (CI_SUCCESS == chSwAttributes) + {/* Ϊ߻ѹ죬ռ״̬ */ + chFAcState = ELM_AC_FREE; + } + else + {/* ȡڼռ״̬ */ + wFAcId = szAcId[0]; + chFAcState = elm_PrepareACStatus(wFAcId); + } + } + else if (UINT8_MAX == chAcNum) + {/* ѯ */ + wFAcId = UINT16_MAX; + chFAcState = ELM_AC_OCC; + } + else + {/* ڼΣռ״̬ */ + wFAcId = 0u; + chFAcState = ELM_AC_FREE; + } + + chAcNum = elm_PrepareAdjacentAC(wBAcId, DIR_SAME, szAcId, &cDirectionPointFlag); + if ((0u != chAcNum) && (UINT8_MAX != chAcNum)) + {/* ڼ */ + wNLink = FindAdjacentLinkIDSafe(wMaxHeadLink, DIR_SAME, &wSwitchId, &cDirectionPointFlag); /*ֻһlinkǷ仯*/ + chSwAttributes = IsLinkSwTrack(wNLink); + if (CI_SUCCESS == chSwAttributes) + {/* Ϊ߻ѹ죬ռ״̬ */ + chNAcState = ELM_AC_FREE; + } + else + {/* ȡڼռ״̬ */ + wNAcId = szAcId[0]; + chNAcState = elm_PrepareACStatus(wNAcId); + } + } + else if (UINT8_MAX == chAcNum) + {/* ѯ */ + wNAcId = UINT16_MAX; + chNAcState = ELM_AC_OCC; + } + else + {/* ڼΣռ״̬ */ + wNAcId = 0u; + chNAcState = ELM_AC_FREE; + } + + chZeroState = GetTrainZeroState(wTrainId); + chSss = GetTrainStopSteadyState(wTrainId); + chTransState = GetTrainTransitmitStat(wTrainId); + chSleepCancle = GetTrainSleepCancleFlag(wTrainId); + chFunRtn = IsLinkSwTrack(wMaxHeadLink); + chVirHeadScreenFlag = GetTrainVirHeadScreenPassFlag(wTrainId); + chVirTailScreenFlag = GetTrainVirTailScreenPassFlag(wTrainId); + chBGAtsScreenAgUtCheck = BGAtsScreenAgUtCheck(wMaxHeadLink); + + /* гڻѹ */ + if (TRAIN_COMM_STATE_GOOD == chTransState) + { + if ((wMaxHeadLink != wMinHeadLink) || (wMinHeadLink != wMaxTailLink) + || (wMaxTailLink != wMinTailLink) || (CI_SUCCESS != chFunRtn) + || (NULL == pElmTemp) || (TRAIN_SPEED_ZERO_YES != chZeroState) + || (TRAIN_SS_YES != chSss) || (CI_SUCCESS != chBGAtsScreenAgUtCheck)) + {/* г߻ѹȡʧܻг޶̬򲻴ٻδͣ׼ͣȻBGɸѡʱӽUCT\CTBGɸѡ */ + SetTrainScreenApply(wTrainId, TRAIN_SCREEN_DEFAULT); + } + else + { + if ((((0u != pElmTemp->headTrainID) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != chVirHeadScreenFlag)) + || ((0u != pElmTemp->tailTrainID) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != chVirTailScreenFlag))) + && (ELM_AC_FREE == chNAcState) && (ELM_AC_FREE == chFAcState)) + { + /* гͷ/βɸδ */ + if (TRAIN_MODE_FAM == chTrainMode) + { + /* FAMģʽԶɸѡ */ + SetTrainScreenApply(wTrainId, TRAIN_SCREEN_ATS); + } + else + { + if ((0u != pElmTemp->headTrainID) && (0u != pElmTemp->tailTrainID)) + { + /* ͷβɹδɣ˹ͷβɸѡ */ + SetTrainScreenApply(wTrainId, TRAIN_SCREEN_IVOC); + } + else if (0u != pElmTemp->headTrainID) + { + /* ͷɸδɣ˹ͷɸ */ + SetTrainScreenApply(wTrainId, TRAIN_HEAD_SCREEN_IVOC); + } + else + { + /* βɸδɣ˹βɸ */ + SetTrainScreenApply(wTrainId, TRAIN_TAIL_SCREEN_IVOC); + } + } + } + else + {/* ͷβɸɻɸѡɸѡ */ + SetTrainScreenApply(wTrainId, TRAIN_SCREEN_DEFAULT); + } + } + } + else + {/* ͨжϣɸѡ */ + SetTrainScreenApply(wTrainId, TRAIN_SCREEN_DEFAULT); + } + + /* ͨãΪУȡ + ߳ǰ/˿ɣ״̬*/ + if (((TRAIN_COMM_STATE_GOOD == chTransState) && (TRAIN_SLEEP_CANCLE_YES == chSleepCancle) + && (TRAIN_WAKE_PROCESS != chWakeState))) + { + SetTrainSleepState(wTrainId, TRAIN_SLEEP_NO); + SetTrainSleepLink(wTrainId, 0u); + debug_infor_printf((const)"Train%x delete sleep state because not in wakeing.\n", wTrainId); + } + else + { + ; + } + + if ((TRAIN_COMM_STATE_BAD == chTransState) + && (TRAIN_SLEEP_YES == chTrainSlpStt) + && (NULL != pElmTemp) + && (((0u != pElmTemp->headTrainID) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != chVirHeadScreenFlag)) + || ((0u != pElmTemp->tailTrainID) && (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != chVirTailScreenFlag)))) + { + SetTrainSleepState(wTrainId, TRAIN_SLEEP_NO); + debug_infor_printf((const)"Train%x delete sleep state because Suspic.\n", wTrainId); + } + + if (TRAIN_SLEEP_YES == chTrainSlpStt) + { + /* ȡ߻ѹlinkϢ */ + wFLink = FindAdjacentLinkIDSafe(wSleepLink, DIR_CONVERT, &wSwitchId, &cDirectionPointFlag); /*ֻһlinkǷ仯*/ + wNLink = FindAdjacentLinkIDSafe(wSleepLink, DIR_SAME, &wSwitchId, &cDirectionPointFlag); + chFAttributes = IsLinkSwTrack(wFLink); + chNAttributes = IsLinkSwTrack(wNLink); + if ((UINT16_MAX == wFLink) || (UINT16_MAX == wNLink)) + {/* ݻȡʧ */ + SetTrainSleepState(wTrainId, TRAIN_SLEEP_NO); + SetTrainSleepLink(wTrainId, 0u); + debug_infor_printf((const)"Train%x delete sleep state because neighbor occ.\n", wTrainId); + } + else + { + cLocalCiType = GetLocalCiType(); /*ȡCI*/ + if ((CI_TYPE_ZX == cLocalCiType) || (CI_TYPE_SCX == cLocalCiType)) + { + /*/Գڷ߻ѹռ*/ + chFunRtn = CI_SUCCESS; + if ((0U != wFLink) && (CI_SUCCESS != chFAttributes)) + { + if (ELM_AC_FREE == chFAcState) + { + ; /* οУ */ + } + else + { + chFunRtn = CI_ERROR; + } + } + else + { + ; /* ·ն˻߻ѹ죬 */ + } + + if ((0U != wNLink) && (CI_SUCCESS != chNAttributes)) + { + if (ELM_AC_FREE == chNAcState) + { + ; /* οУ */ + } + else + { + chFunRtn = CI_ERROR; + } + } + else + { + ; /* ·ն˻߻ѹ죬 */ + } + } + else + { + /*߻ѹռü*/ + chFunRtn = CLDSWAdjacentSecOccCheck(wSleepLink); + } + + if (CI_SUCCESS != chFunRtn) + { + /*ʧܣ*/ + SetTrainSleepState(wTrainId, TRAIN_SLEEP_NO); /*עɾlinkȻ޷̬*/ + debug_infor_printf((const)"Train[%x] Delete Sleep State Because Adjacent Sectioc Occ.\n", wTrainId); + } + else + { + /*ͨ*/ + } + } + } + else + { + ; /* Ϊг */ + } + } +} + +/* +* ԭɸѡ +* ˵ +* ֵ +*/ +static void TrainScreenProc(void) +{ + UINT8 chTrainIndex = 0u; + UINT16 wTrainId = 0u; + UINT16 wMaxHeadLink = 0u; + UINT16 wMinHeadLink = 0u; + UINT16 wMaxTailLink = 0u; + UINT16 wMinTailLink = 0u; + UINT16 wElmTrainId = 0u; + UINT8 chZeroState = 0u; + UINT8 chTrainHeadScreenConfirm = 0u; + UINT8 chTrainTailScreenConfirm = 0u; + UINT8 chAtsScreenConfirm = 0u; + UINT8 chScreenApply = 0u; + UINT16 wNAcId = 0u; + UINT16 wFAcId = 0u; + UINT16 wBAcId = 0u; + UINT8 chNAcState = 0u; + UINT8 chFAcState = 0u; + UINT8 chAcNum = 0u; + UINT16 szAcId[AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT8 chSss = 0u; + UINT16 wFLink = 0u; + UINT16 wNLink = 0u; + UINT16 wSwitchId = 0u; + UINT8 chSwAttributes = 0u; + const EnvelopeStruct* pElmTemp = NULL; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + UINT8 chBGAtsScreenAgUtCheck = 0U; /*BGԶɸѡAG UT*/ + + /* г */ + for (chTrainIndex = 0u; chTrainIndex < TRAIN_SUM_MAX; chTrainIndex++) + { + wTrainId = GetTrainId(chTrainIndex); + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + wMaxTailLink = GetTrainMaxTailLink(wTrainId); + wMinTailLink = GetTrainMinTailLink(wTrainId); + wElmTrainId = (wTrainId & 0x00ffu); + pElmTemp = elm_GetEnvelopeInfoByTrainID(wElmTrainId); + chZeroState = GetTrainZeroState(wTrainId); + chScreenApply = GetTrainScreenApply(wTrainId); + chTrainHeadScreenConfirm = GetTrainHeadScreenConfirm(wTrainId); + chTrainTailScreenConfirm = GetTrainTailScreenConfirm(wTrainId); + chAtsScreenConfirm = GetTrainAtsScreenConfirm(wTrainId); + wBAcId = GetLinkBelongAcId(wMaxHeadLink); + chAcNum = elm_PrepareAdjacentAC(wBAcId, DIR_CONVERT, szAcId, &cDirectionPointFlag); + chSss = GetTrainStopSteadyState(wTrainId); + if ((0u != chAcNum) && (UINT8_MAX != chAcNum)) + {/* ڼ */ + wFLink = FindAdjacentLinkIDSafe(wMaxHeadLink, DIR_CONVERT, &wSwitchId, &cDirectionPointFlag); /*ֻһlinkǷ仯*/ + chSwAttributes = IsLinkSwTrack(wFLink); + if (CI_SUCCESS == chSwAttributes) + {/* Ϊ߻ѹ죬ռ״̬ */ + chFAcState = ELM_AC_FREE; + } + else + {/* ȡڼռ״̬ */ + wFAcId = szAcId[0]; + chFAcState = elm_PrepareACStatus(wFAcId); + } + } + else if (UINT8_MAX == chAcNum) + { + /* ѯ */ + wFAcId = UINT16_MAX; + chFAcState = ELM_AC_OCC; + } + else + {/* ڼΣռ״̬ */ + wFAcId = 0u; + chFAcState = ELM_AC_FREE; + } + + chAcNum = elm_PrepareAdjacentAC(wBAcId, DIR_SAME, szAcId, &cDirectionPointFlag); + if ((0u != chAcNum) && (UINT8_MAX != chAcNum)) + {/* ڼ */ + wNLink = FindAdjacentLinkIDSafe(wMaxHeadLink, DIR_SAME, &wSwitchId, &cDirectionPointFlag); /*ֻһlinkǷ仯*/ + chSwAttributes = IsLinkSwTrack(wNLink); + if (CI_SUCCESS == chSwAttributes) + {/* Ϊ߻ѹ죬ռ״̬ */ + chNAcState = ELM_AC_FREE; + } + else + {/* ȡڼռ״̬ */ + wNAcId = szAcId[0]; + chNAcState = elm_PrepareACStatus(wNAcId); + } + } + else if (UINT8_MAX == chAcNum) + { + /* ѯ */ + wNAcId = UINT16_MAX; + chNAcState = ELM_AC_OCC; + } + else + {/* ڼΣռ״̬ */ + wNAcId = 0u; + chNAcState = ELM_AC_FREE; + } + + chSwAttributes = IsLinkSwTrack(wMaxHeadLink); + chBGAtsScreenAgUtCheck = BGAtsScreenAgUtCheck(wMaxHeadLink); + + if ((TRAIN_HEAD_CONFIRM_YES == chTrainHeadScreenConfirm) + && ((TRAIN_SCREEN_IVOC == chScreenApply) || (TRAIN_HEAD_SCREEN_IVOC == chScreenApply))) + { + if ((wMaxHeadLink != wMinHeadLink) || (wMinHeadLink != wMaxTailLink) + || (wMaxTailLink != wMinTailLink) || (CI_SUCCESS != chSwAttributes) + || (NULL == pElmTemp)) + {/* гԭ߻ѹ */ + ; + } + else if (TRAIN_SPEED_ZERO_YES != chZeroState) + {/* г */ + ; + } + else if (TRAIN_SS_YES != chSss) + {/* гδͣ׼ͣ */ + ; + } + else if((ELM_AC_FREE != chNAcState) || (ELM_AC_FREE != chFAcState)) + {/* βηǿ */ + ; + } + else if (CI_SUCCESS != chBGAtsScreenAgUtCheck) + { + /* AB(CG)ҪжAGг־ͽӽ״̬ */ + ; + } + else + { + /*ǰɸ־ЧIVOCǰ޿*/ + SetTrainEnterLjkLinkId(wTrainId, wMaxHeadLink); + SetTrainVirHeadScreenPassFlag(wTrainId,TRAIN_VIR_SCREEN_PASS_FLAG_VALID); + + /*ɸѡͨгλüලЧ*/ + SetTrainPosMonitorState(wTrainId, TRAIN_POS_MONITOR_VALID); + SetTrainPosMonitorInLink(wTrainId, wMaxHeadLink); + } + } + else + { + ; + } + + if ((TRAIN_TAIL_CONFIRM_YES == chTrainTailScreenConfirm) + && ((TRAIN_SCREEN_IVOC == chScreenApply) || (TRAIN_TAIL_SCREEN_IVOC == chScreenApply))) + { + if ((wMaxHeadLink != wMinHeadLink) || (wMinHeadLink != wMaxTailLink) + || (wMaxTailLink != wMinTailLink) || (CI_SUCCESS != chSwAttributes) + || (NULL == pElmTemp)) + {/* гδԭ߻ѹ */ + ; + } + else if (TRAIN_SPEED_ZERO_YES != chZeroState) + {/* г */ + ; + } + else if (TRAIN_SS_YES != chSss) + {/* гδͣ׼ͣ */ + ; + } + else if ((ELM_AC_FREE != chNAcState) || (ELM_AC_FREE != chFAcState)) + {/* λڼηǿ */ + ; + } + else if (CI_SUCCESS != chBGAtsScreenAgUtCheck) + { + /* AB(CG)ҪжAGг־ͽӽ״̬ */ + ; + } + else + { + SetTrainEnterLjkLinkId(wTrainId, wMaxHeadLink); + /*ɸ־ЧIVOC޿*/ + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_VALID); + + /*ɸѡͨгλüලЧ*/ + SetTrainPosMonitorState(wTrainId, TRAIN_POS_MONITOR_VALID); + SetTrainPosMonitorInLink(wTrainId, wMaxHeadLink); + } + } + else + { + ; + } + + if ((TRAIN_ATS_CONFIRM_YES == chAtsScreenConfirm) + && (TRAIN_SCREEN_ATS == chScreenApply)) + { + if ((wMaxHeadLink != wMinHeadLink) || (wMinHeadLink != wMaxTailLink) + || (wMaxTailLink != wMinTailLink) || (CI_SUCCESS != chSwAttributes) + || (NULL == pElmTemp)) + {/* гδԭ߻ѹ */ + ; + } + else if (TRAIN_SPEED_ZERO_YES != chZeroState) + {/* г */ + ; + } + else if (TRAIN_SS_YES != chSss) + {/* гδͣ׼ͣ */ + ; + } + else if ((ELM_AC_FREE != chNAcState) || (ELM_AC_FREE != chFAcState)) + {/* βڼηǿ */ + ; + } + else if (CI_SUCCESS != chBGAtsScreenAgUtCheck) + { + /* AB(CG)ҪжAGг־ͽӽ״̬ */ + ; + } + else + { + /*ǰɸ־ЧIVOCǰ޿*/ + SetTrainEnterLjkLinkId(wTrainId, wMaxHeadLink); + SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_VALID); + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_VALID); + + /*ɸѡͨгλüලЧ*/ + SetTrainPosMonitorState(wTrainId, TRAIN_POS_MONITOR_VALID); + SetTrainPosMonitorInLink(wTrainId, wMaxHeadLink); + } + } + else + { + ; + } + + SetTrainHeadScreenConfirm(wTrainId, TRAIN_HEAD_CONFIRM_NO); + SetTrainTailScreenConfirm(wTrainId, TRAIN_TAIL_CONFIRM_NO); + SetTrainAtsScreenConfirm(wTrainId, TRAIN_ATS_CONFIRM_NO); + } +} + +/** +* @brief Զɸѡ״ȷ +* @param +* @return +*/ +static void TrainAtsScreenFst(void) +{ + AtsScreenMsgFstStru * strMsgFst = NULL; + AtsMsgCfmStru * strCfmFst = NULL; + UINT32 dwCycle = 0u; + UINT8 chLocalId = 0u; + UINT8 chLocIndex = 0u; + UINT8 chAtsIndex = 0u; + UINT8 chFlag = FLAG_UNSET; + UINT8 szCrcTmp[1024] = { 0u }; + UINT32 ii = 0u; + UINT8 chFunRtn = CI_TIME_OUT; + UINT16 wTrainId = 0u; + UINT16 wTrainLgcId = 0u; + UINT8 dquHlhtId2VobcName_ret = 0u; + chLocalId = GetSystemParaLocalCiId(); + dwCycle = Get2oo2CurCycleNum(); + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsMsgFst(); + strCfmFst = GetAtsCfmFst(); + + if (strMsgFst->dwCycle == dwCycle) + { + strCfmFst->chFlag = FLAG_SET; + strCfmFst->chTiocId = chLocalId; + strCfmFst->chStation = strMsgFst->chStation; + strCfmFst->chIndex = strMsgFst->chIndex; + strCfmFst->dwTime = dwCycle; + + for (chAtsIndex = 0u; chAtsIndex < strMsgFst->chTrainNum; chAtsIndex++) + { + for (chLocIndex = 0u; chLocIndex < gAtsScreenNum; chLocIndex++) + { + dquHlhtId2VobcName_ret = dquHlhtId2VobcName(strMsgFst->strTrainInfo[chAtsIndex].dwTrainId, &wTrainId, &wTrainLgcId); /*Ż*/ + if ((wTrainId == gszAtsScreenInfo[chLocIndex].wTrainId) && (0u != dquHlhtId2VobcName_ret)) + {/* ҵг */ + break; + } + else + { + ; + } + } + + if (chLocIndex == gAtsScreenNum) + {/* 뱾дڲһгIDȷг */ + strCfmFst->chOpStatus = CONFIRM_FIRST_TRAINID; + chFlag = FLAG_SET; + } + else + { + if (strMsgFst->strTrainInfo[chAtsIndex].wLgcId == gszAtsScreenInfo[chLocIndex].wLgcId) + { + ; + } + else + {/* г߼뱾г߼βһ£ȷ߼ */ + strCfmFst->chOpStatus = CONFIRM_FIRST_LGCID; + chFlag = FLAG_SET; + } + } + + if (FLAG_SET == chFlag) + { + break; + } + else + { + ; + } + } + szCrcTmp[ii++] = strMsgFst->chAtsId; + LongToChar(strMsgFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii++] = strMsgFst->chTrainNum; + for (chAtsIndex = 0u; chAtsIndex < strMsgFst->chTrainNum; chAtsIndex++) + { + LongToChar(strMsgFst->strTrainInfo[chAtsIndex].dwTrainId, &szCrcTmp[ii]); + ii += 4u; + ShortToChar(strMsgFst->strTrainInfo[chAtsIndex].wLgcId, &szCrcTmp[ii]); + ii += 2u; + } + strCfmFst->dwCrc32 = Tioc_CommonCrc32(szCrcTmp, ii); + if (FLAG_UNSET == chFlag) + {/* ͨȷϳɹ */ + strCfmFst->chOpStatus = CONFIRM_FIRST_SUCCESS; + + } + else + { + ClearAtsMsgFirst(); /**1 */ + } + } + else + {/* յATSԶɸѡһϢDZڣʱж */ + chFunRtn = SystemOverTimeCheck(strMsgFst->dwCycle, CONFIRM_TIMEOUT_CC); + if (CI_TIME_OUT == chFunRtn) + { + ClearAtsMsgFirst(); + } + else + { + ; + } + } +} + +/** +* @brief жATSԶɸѡϢǷһ +* @param +* @return CI_ERROR:һ£CI_SUCCESS:һ +*/ +static UINT8 IsAtsFstSndSame(void) +{ + AtsScreenMsgFstStru * strMsgFst = NULL; + AtsScreenMsgSndStru * strMsgSnd = NULL; + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsMsgFst(); + strMsgSnd = GetAtsMsgSnd(); + + if ((strMsgFst->chAtsId == strMsgSnd->chAtsId) + && (strMsgFst->chStation == strMsgSnd->chStation) + && (strMsgFst->chIndex == strMsgSnd->chIndex) + && (strMsgFst->chTrainNum == strMsgSnd->chTrainNum)) + {/* ATS/վ/վ/гһ */ + chRtn = CI_SUCCESS; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + for (chIndex = 0u; chIndex < strMsgFst->chTrainNum; chIndex++) + { + if ((strMsgFst->strTrainInfo[chIndex].dwTrainId != strMsgSnd->strTrainInfo[chIndex].dwTrainId) + || (strMsgFst->strTrainInfo[chIndex].wLgcId != strMsgSnd->strTrainInfo[chIndex].wLgcId)) + {/* ϢгID/߼IDһ */ + chRtn = CI_ERROR; + break; + } + } + } + else + { + ; + } + return chRtn; +} + +/** +* @brief Զɸѡȷϴ +* @param +* @return +*/ +static void SetTrainAtsScreenProc(void) +{ + AtsScreenMsgSndStru * strMsgSnd = NULL; + UINT16 wTrainId = 0u; + UINT8 chIndex = 0u; + UINT16 wTrainLgcId = 0u; + strMsgSnd = GetAtsMsgSnd();/*᷵NULL*/ + for (chIndex = 0u; chIndex < strMsgSnd->chTrainNum; chIndex++) + { + (void)dquHlhtId2VobcName(strMsgSnd->strTrainInfo[chIndex].dwTrainId, &wTrainId, &wTrainLgcId); + SetTrainAtsScreenConfirm(wTrainId, TRAIN_ATS_CONFIRM_YES); + } +} + +/** +* @brief Զɸѡȷ +* @param +* @return +*/ +static void TrainAtsScreenSnd(void) +{ + AtsScreenMsgFstStru * strMsgFst = NULL; + AtsScreenMsgSndStru * strMsgSnd = NULL; + AtsMsgCfmStru * strCfmFst = NULL; + AtsMsgCfmStru * strCfmSnd = NULL; + UINT32 dwCycle = 0u; + UINT8 chLocalId = 0u; + UINT8 chLocIndex = 0u; + UINT8 chAtsIndex = 0u; + UINT8 chFlag = FLAG_UNSET; + UINT8 szCrcTmp[1024] = { 0u }; + UINT32 ii = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT32 dwCrc = 0u; + UINT16 wTrainId = 0u; + UINT16 wTrainLgcId = 0u; + UINT8 reflag = 0u; + chLocalId = GetSystemParaLocalCiId(); + dwCycle = Get2oo2CurCycleNum(); + + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsMsgFst(); + strMsgSnd = GetAtsMsgSnd(); + strCfmFst = GetAtsCfmFst(); + strCfmSnd = GetAtsCfmSnd(); + + if (strMsgSnd->dwCycle == dwCycle) + { + strCfmSnd->chFlag = FLAG_SET; + strCfmSnd->chTiocId = chLocalId; + strCfmSnd->chStation = strMsgSnd->chStation; + strCfmSnd->chIndex = strMsgSnd->chIndex; + strCfmSnd->dwTime = dwCycle; + for (chAtsIndex = 0u; chAtsIndex < strMsgSnd->chTrainNum; chAtsIndex++) + { + for (chLocIndex = 0u; chLocIndex < gAtsScreenNum; chLocIndex++) + { + reflag = dquHlhtId2VobcName(strMsgSnd->strTrainInfo[chAtsIndex].dwTrainId, &wTrainId, &wTrainLgcId); + if ((1u == reflag) && (wTrainId == gszAtsScreenInfo[chLocIndex].wTrainId)) + {/* ҵг */ + break; + } + else + { + ; + } + } + + if (chLocIndex == gAtsScreenNum) + {/* 뱾дڲһгIDȷг */ + strCfmSnd->chOpStatus = CONFIRM_SECOND_TRAINID; + chFlag = FLAG_SET; + } + else + { + if (strMsgSnd->strTrainInfo[chAtsIndex].wLgcId == gszAtsScreenInfo[chLocIndex].wLgcId) + { + ; + } + else + {/* г߼뱾г߼βһ£ȷ߼ */ + strCfmSnd->chOpStatus = CONFIRM_SECOND_LGCID; + chFlag = FLAG_SET; + } + } + + if (FLAG_SET == chFlag) + { + break; + } + else + { + ; + } + } + + if (FLAG_UNSET == chFlag) + { + ii = 0u; + szCrcTmp[ii++] = strMsgSnd->chTiocId; + LongToChar(strCfmFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii++] = strMsgSnd->chTrainNum; + for (chAtsIndex = 0u; chAtsIndex < strMsgSnd->chTrainNum; chAtsIndex++) + { + LongToChar(strMsgSnd->strTrainInfo[chAtsIndex].dwTrainId, &szCrcTmp[ii]); + ii += 4u; + ShortToChar(strMsgSnd->strTrainInfo[chAtsIndex].wLgcId, &szCrcTmp[ii]); + ii += 2u; + } + dwCrc = Tioc_CommonCrc32(szCrcTmp, ii); + if (dwCrc != strMsgSnd->dwCrc32) + {/* CRC32ATSϢCRC32һ */ + strCfmSnd->chOpStatus = CONFIRM_SECOND_CRC; + chFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + if (FLAG_UNSET == chFlag) + { + if (FLAG_SET != strMsgFst->chFlag) + {/* δ״ȷ */ + strCfmSnd->chOpStatus = CONFIRM_SECOND_FIRST; + chFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + if (FLAG_UNSET == chFlag) + { + chFunRtn = IsAtsFstSndSame(); + if (CI_SUCCESS != chFunRtn) + {/* Ϣݲһ */ + strCfmSnd->chOpStatus = CONFIRM_SECOND_DIFF; + chFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + ii = 0u; + szCrcTmp[ii++] = strMsgFst->chAtsId; + LongToChar(strMsgFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + LongToChar(strMsgSnd->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii++] = strMsgSnd->chTrainNum; + for (chAtsIndex = 0u; chAtsIndex < strMsgSnd->chTrainNum; chAtsIndex++) + { + LongToChar(strMsgSnd->strTrainInfo[chAtsIndex].dwTrainId, &szCrcTmp[ii]); + ii += 4u; + ShortToChar(strMsgSnd->strTrainInfo[chAtsIndex].wLgcId, &szCrcTmp[ii]); + ii += 2u; + } + strCfmSnd->dwCrc32 = Tioc_CommonCrc32(szCrcTmp, ii); + if (FLAG_UNSET == chFlag) + {/* ͨȷϳɹ */ + strCfmSnd->chOpStatus = CONFIRM_FIRST_SUCCESS; + + + SetTrainAtsScreenProc(); + } + else + { + ; + } + } + else + { + ; /** DZϢ */ + } + ClearAtsMsgFirst(); + ClearAtsMsgSecond(); +} + +/** +* @brief Զɸѡ +* @param +* @return +*/ +static void TrainAtsScreenProc(void) +{ + AtsScreenMsgFstStru * strMsgFst = NULL; + AtsScreenMsgSndStru * strMsgSnd = NULL; + UINT8 startLockFlag = 0U; + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsMsgFst(); + strMsgSnd = GetAtsMsgSnd(); + startLockFlag = GetStartLockFlag(); + + /*ϵŴԶɸѡ*/ + if (CI_START_LOCK_NO == startLockFlag) + { + if ((strMsgFst->chFlag != FLAG_SET) && (strMsgSnd->chFlag != FLAG_SET)) + { + ; /* ûϢʲôҲ */ + } + else if ((strMsgFst->chFlag == FLAG_SET) && (strMsgSnd->chFlag != FLAG_SET)) + {/* ԶɸѡһϢ */ + TrainAtsScreenFst(); + } + else + {/* ԶɸѡϢ */ + TrainAtsScreenSnd(); + } + } + else + { + ClearAtsMsgFirst(); + ClearAtsMsgSecond(); + } +} + +/** +* @brief Զɸѡ +* @param +* @return +*/ +static void TrainAtsScreenTidy(void) +{ + UINT8 chTrainIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chScreenApply = 0u; + UINT16 * pLgcId = NULL; + UINT16 wLinkId = 0u; + UINT16 wAcId = 0u; + + gAtsScreenNum = 0u; + (void)CommonMemSet((void*)gszAtsScreenInfo, (UINT32)sizeof(gszAtsScreenInfo), (UINT8)0U , (UINT32)sizeof(gszAtsScreenInfo)); + /* г */ + for (chTrainIndex = 0u; chTrainIndex < TRAIN_SUM_MAX; chTrainIndex++) + { + wTrainId = GetTrainId(chTrainIndex); + chScreenApply = GetTrainScreenApply(wTrainId); + if (TRAIN_SCREEN_ATS == chScreenApply) + { + wLinkId = GetTrainMaxHeadLink(wTrainId); + wAcId = GetLinkBelongAcId(wLinkId); + pLgcId = GetAxisSecLogSectionIdBuf(wAcId); + if (NULL != pLgcId) + { + gszAtsScreenInfo[gAtsScreenNum].wTrainId = wTrainId; + gszAtsScreenInfo[gAtsScreenNum].chScType = TRAIN_SCREEN_TYPE_LU; + gszAtsScreenInfo[gAtsScreenNum].wLgcId = pLgcId[0]; + + gAtsScreenNum++; + } + else + { + ; /**/ + } + } + else + { + ; + } + } +} + +/* +* гģ +* ˵ +* ֵ +* note +*/ +void TrainMainProc(void) +{ + /* ȫλü */ + CalTrainSafePosition(); + + /* г̬Դ */ + TrainDynProc(); + + /* гѴ */ + TrainWakeProc(); + + /* Զɸѡ */ + TrainAtsScreenTidy(); + + /* Զɸѡ */ + TrainAtsScreenProc(); + + /* ԭɸѡ */ + TrainScreenProc(); + + /* ɢ */ + EvacuationAreaProcess(); + +} + +/* +* жгǷڶ̬б +* ˵ const UINT16 wTrainId гID +* ֵ CI_ERROR:гڶ̬бڣCI_SUCCESS:гڶ̬б +*/ +static UINT8 IsTrainDyTesting(const UINT16 wTrainId) +{ + UINT8 chDyIndex = 0u; + UINT8 chRtn = CI_ERROR; + for (chDyIndex = 0u; chDyIndex < gDyTestNum; chDyIndex++) + { + if (wTrainId == gszDyTestInfo[chDyIndex].wTrainId) + { + chRtn = CI_SUCCESS; + break; + } + else + { + ; + } + } + return chRtn; +} + +/* +* гӽ̬б +* ˵ const UINT16 wTrainId гID +* ֵ +*/ +static void AddTrainDyTesting(const UINT16 wTrainId, const UINT16 wLinkId) +{ + UINT16 wSysParamDyMax = GetSystemParaValue(DYTEST_SUM_MAX_ID); + UINT8 chDyMax = (UINT8)(wSysParamDyMax & 0x00ffu); + + if ((chDyMax > gDyTestNum) + &&(TRAIN_DYN_TEST_SUM_MAX>gDyTestNum)) + { + gszDyTestInfo[gDyTestNum].wTrainId = wTrainId; + gszDyTestInfo[gDyTestNum].wLinkId = wLinkId; + gDyTestNum++; + } + else + { + ; + } +} + +/* +* гƳ̬б +* ˵ const UINT16 wTrainId гID +* ֵ +*/ +void DelTrainDyTesting(const UINT16 wTrainId) +{ + UINT8 chIndex = 0u; + UINT8 chDelIndex = 0u; + for (chIndex = 0u; chIndex < gDyTestNum; chIndex++) + { + if (gszDyTestInfo[chIndex].wTrainId == wTrainId) + { + break; + } + else + { + ; + } + } + + /* ҵӦг */ + if (chIndex < gDyTestNum) + { + for (chDelIndex = chIndex; chDelIndex < gDyTestNum - 1u; chDelIndex++) + { + gszDyTestInfo[chDelIndex].wTrainId = gszDyTestInfo[chDelIndex + 1u].wTrainId; + gszDyTestInfo[chDelIndex].wLinkId = gszDyTestInfo[chDelIndex + 1u].wLinkId; + } + gDyTestNum--; + } + else + { + ; + } +} + +/* +* жlinkǷгڶ̬ +* ˵ const UINT16 wLinkId linkID +* ֵ CI_ERROR:гڶ̬ԣCI_SUCCESS: +*/ +static UINT8 IsLinkTesting(UINT16 wLinkId) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + for (chIndex = 0u; chIndex < gDyTestNum; chIndex++) + { + if (wLinkId == gszDyTestInfo[chIndex].wLinkId) + { + break; + } + else + { + ; + } + } + + if (chIndex < gDyTestNum) + { + chRtn = CI_ERROR; + } + else + { + chRtn = CI_SUCCESS; + } + + return chRtn; +} + +/* +* ָгɸѡ״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chApply гɸѡ״̬ +* ֵ +*/ +void SetTrainScreenApply(const UINT16 wTrainId, const UINT8 chApply) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_SCREEN_DEFAULT == chApply) || (TRAIN_SCREEN_ATS == chApply) + || (TRAIN_HEAD_SCREEN_IVOC == chApply) || (TRAIN_TAIL_SCREEN_IVOC == chApply) + || (TRAIN_SCREEN_IVOC == chApply))) + { + gstTrainInfo[wBufIndex].chScreenApply = chApply; + } + else + { + ; + } +} + +/* +* ȡָгɸѡ״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ гɸѡ״̬ +*/ +UINT8 GetTrainScreenApply(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_CMD_DYM_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chScreenApply; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгǰɸȷ״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chReq гǰɸȷ״̬ +* ֵ +*/ +void SetTrainHeadScreenConfirm(const UINT16 wTrainId, const UINT8 chReq) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_HEAD_CONFIRM_YES == chReq) || (TRAIN_HEAD_CONFIRM_NO == chReq))) + { + gstTrainInfo[wBufIndex].chTrainHeadScreenConfirm = chReq; + } + else + { + ; + } +} + +/* +* ȡָгǰɸȷ״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ гǰɸȷ״̬ +*/ +UINT8 GetTrainHeadScreenConfirm(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_HEAD_CONFIRM_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainHeadScreenConfirm; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгɸȷ״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chReq гɸȷ״̬ +* ֵ +*/ +void SetTrainTailScreenConfirm(const UINT16 wTrainId, const UINT8 chReq) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_TAIL_CONFIRM_YES == chReq) || (TRAIN_TAIL_CONFIRM_NO == chReq))) + { + gstTrainInfo[wBufIndex].chTrainTailScreenConfirm = chReq; + } + else + { + ; + } +} + +/* +* ȡָгɸȷ״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ гɸȷ״̬ +*/ +UINT8 GetTrainTailScreenConfirm(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_TAIL_CONFIRM_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainTailScreenConfirm; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгԶɸѡȷ״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chReq гԶɸѡȷ״̬ +* ֵ +*/ +void SetTrainAtsScreenConfirm(const UINT16 wTrainId, const UINT8 chReq) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_ATS_CONFIRM_YES == chReq) || (TRAIN_ATS_CONFIRM_NO == chReq))) + { + gstTrainInfo[wBufIndex].chAtsScreenConfirm = chReq; + } + else + { + ; + } +} + +/* +* ȡָгԶɸѡȷ״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ гԶɸѡȷ״̬ +*/ +UINT8 GetTrainAtsScreenConfirm(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_ATS_CONFIRM_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chAtsScreenConfirm; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ȡҪԶɸѡг +* ˵ +* ֵ ҪԶɸѡг +*/ +UINT8 GetAtsScreenNum(void) +{ + return gAtsScreenNum; +} + +/* +* ȡҪԶɸѡгID +* ˵ +* ֵ ҪԶɸѡгID +*/ +UINT16 GetAtsScreenTrainIdByIndex(const UINT8 chIndex) +{ + return gszAtsScreenInfo[chIndex].wTrainId; +} + +/* +* ȡҪԶɸѡг߼ID +* ˵ +* ֵ ҪԶɸѡг߼ID +*/ +UINT16 GetAtsScreenLgcIdByIndex(const UINT8 chIndex) +{ + return gszAtsScreenInfo[chIndex].wLgcId; +} + +/* +* ȡҪԶɸѡ +* ˵ +* ֵ Զɸѡ +*/ +UINT8 GetAtsScreenTypeByIndex(const UINT8 chIndex) +{ + return gszAtsScreenInfo[chIndex].chScType; +} + +/* +* ָгͣ׼ͣ״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chState гͣ׼ͣ״̬ +* ֵ +*/ +void SetTrainStopSteadyState(const UINT16 wTrainId, const UINT8 chState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_SS_YES == chState) || (TRAIN_SS_NO == chState))) + { + gstTrainInfo[wBufIndex].chStopSteadyState = chState; + } + else + { + ; + } +} + +/* +* ȡָгͣ׼ͣ״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ гͣ׼ͣ״̬ +*/ +UINT8 GetTrainStopSteadyState(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_SS_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chStopSteadyState; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгܷ״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chState гܷ״̬ +* ֵ +*/ +void SetTrainSleepCancleFlag(const UINT16 wTrainId, const UINT8 chState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_SLEEP_CANCLE_YES == chState) || (TRAIN_SLEEP_CANCLE_NO == chState))) + { + gstTrainInfo[wBufIndex].chSleepCancleFlag = chState; + } + else + { + ; + } +} + +/* +* ȡָгܷ״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ гܷ״̬ +*/ +UINT8 GetTrainSleepCancleFlag(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_SLEEP_CANCLE_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chSleepCancleFlag; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ȡָгͨжں +* ˵ const UINT16 wTrainId, гID +* ֵ гͨжں +*/ +static UINT32 GetTrainTransBadCyc(const UINT16 wTrainId) +{ + UINT32 dwRetVal = 0u; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwTransBadCyc; + } + else + { + ; + } + + return dwRetVal; +} + +/* +* ȡָгɢ +* ˵ const UINT16 wTrainId, гID +* ֵ ɢ +*/ +UINT8 GetTrainEaNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = EA_MAX_NUM; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chEaNum; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ȡָгɢϢ +* ˵ const UINT16 wTrainId, гID +* ֵ ɢϢ +*/ +TrainEaStru * GetTrainEaInfo(const UINT16 wTrainId) +{ + TrainEaStru * pRtn = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + pRtn = gstTrainInfo[wBufIndex].strTrainEaInfo; + } + else + { + ; + } + + return pRtn; +} + +/* +* ȡָгɢ +* ˵ const UINT16 wTrainId, гID +* ֵ ɢ +*/ +UINT8 GetTrainEaCmd(const UINT16 wTrainId) +{ + UINT8 chRetVal = EA_PROTECT_BUILD; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chEaCmd; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгɢ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chCmd ɢ +* ֵ +*/ +void SetTrainEaCmd(const UINT16 wTrainId, const UINT8 chCmd) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((EA_PROTECT_BUILD == chCmd) || (EA_PROTECT_DEFAULT == chCmd))) + { + gstTrainInfo[wBufIndex].chEaCmd = chCmd; + } + else + { + ; + } +} + +/* +* ָгɢ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chEaNum ɢ +* ֵ +*/ +void SetTrainEaNum(const UINT16 wTrainId, const UINT8 chEaNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].chEaNum = chEaNum; + } + else + { + ; + } +} + +/* +* ָгɢϢ +* ˵ const UINT16 wTrainId, гID +* pEaInfo ɢϢ +* ֵ +*/ +void SetTrainEaInfo(const UINT16 wTrainId, const TrainEaStru * pEaInfo) +{ + UINT8 chIndex = 0u; + UINT16 wBufIndex = 0u; + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + for (chIndex = 0u; chIndex < EA_MAX_NUM; chIndex++) + { + gstTrainInfo[wBufIndex].strTrainEaInfo[chIndex].wEaTrainId = pEaInfo[chIndex].wEaTrainId; + gstTrainInfo[wBufIndex].strTrainEaInfo[chIndex].chAgreeState = pEaInfo[chIndex].chAgreeState; + gstTrainInfo[wBufIndex].strTrainEaInfo[chIndex].dwBuildCyc = pEaInfo[chIndex].dwBuildCyc; + } + } + else + { + ; + } +} + +/* +* ȡָгܷתΪUCT +* ˵ const UINT16 wTrainId, гID +* ֵ FLAG_UNSET:תΪUCTFLAG_SET:תΪUCT +* note߳粻תΪUCT +*/ +UINT8 GetTrainCanUct(const UINT16 wTrainId) +{ + UINT8 chRetVal = FLAG_SET; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainCanUct; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгܷתΪUCT +* ˵ const UINT16 wTrainId, гID + const UINT8 chFlag ־ +* ֵ +* note߳粻תΪUCT +*/ +static void SetTrainCanUct(const UINT16 wTrainId, const UINT8 chFlag) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && ((FLAG_SET == chFlag) || (FLAG_UNSET == chFlag))) + { + gstTrainInfo[wBufIndex].chTrainCanUct = chFlag; + } + else + { + ; + } +} + +/* +* гΪתΪUCT +* ˵ +* ֵ +* note߳粻תΪUCT +*/ +void ClearTrainCanUctFlag(void) +{ + UINT8 chTrainIndex = 0u; + UINT16 wTrainId = 0u; + + for (chTrainIndex = 0u; chTrainIndex < TRAIN_SUM_MAX; chTrainIndex++) + { + wTrainId = GetTrainId(chTrainIndex); + SetTrainCanUct(wTrainId, FLAG_UNSET); + } +} + +/* +* ָгǰ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chActive г +* ֵ +*/ +void SetTrainActive(const UINT16 wTrainId, const UINT8 chActive) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_ACTIVE_NONE == chActive) || (TRAIN_ACTIVE_ONE == chActive) + || (TRAIN_ACTIVE_TWO == chActive) || (TRAIN_ACTIVE_ALL == chActive))) + { + gstTrainInfo[wBufIndex].chActive = chActive; + } + else + { + ; + } +} + +/* +* ȡָгǰ +* ˵ const UINT16 wTrainId, гID +* ֵ гǰ +*/ +UINT8 GetTrainActive(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_ACTIVE_NONE; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chActive; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгRRM +* ˵ const UINT16 wTrainId, гID +* const UINT8 chRqst гRRM +* ֵ +*/ +void SetTrainRrmRqst(const UINT16 wTrainId, const UINT8 chRqst) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_RRM_RQST_YES == chRqst) || (TRAIN_RRM_RQST_NO == chRqst))) + { + gstTrainInfo[wBufIndex].chRrmRqst = chRqst; + } + else + { + ; + } +} + +/* +* ȡָгRRM +* ˵ const UINT16 wTrainId, гID +* ֵ гRRM +*/ +UINT8 GetTrainRrmRqst(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_RRM_RQST_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chRrmRqst; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгRRM״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chState гRRM״̬ +* ֵ +*/ +void SetTrainRrmState(const UINT16 wTrainId, const UINT8 chState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_RRM_YES == chState) || (TRAIN_RRM_NO == chState) || (TRAIN_RRM_DEFAULT == chState))) + { + gstTrainInfo[wBufIndex].chRrmState = chState; + } + else + { + ; + } +} + +/* +* ȡָгRRM״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ гRRM״̬ +*/ +UINT8 GetTrainRrmState(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_RRM_NO; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chRrmState; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгRRMԭ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chReson гRRMԭ +* ֵ +*/ +void SetTrainRrmReson(const UINT16 wTrainId, const UINT8 chReson) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && + ((TRAIN_RRM_RESON_02 == chReson) || (TRAIN_RRM_RESON_FF == chReson) + || ((TRAIN_RRM_RESON_05 <= chReson) && (TRAIN_RRM_RESON_0E >= chReson)) + || ((TRAIN_RRM_RESON_15 <= chReson) && (TRAIN_RRM_RESON_17 >= chReson)))) + { + gstTrainInfo[wBufIndex].chRrmReson = chReson; + } + else + { + ; + } +} + +/* +* ȡָгRRMԭ +* ˵ const UINT16 wTrainId, гID +* ֵ гRRMԭ +*/ +UINT8 GetTrainRrmReson(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_RRM_RESON_FF; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chRrmReson; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ȡָгһ߼վ̨ID +* ˵ const UINT16 wTrainId, гID +* ֵ гһ߼վ̨ID +*/ +UINT16 GetTrainAtsLgcStation(const UINT16 wTrainId) +{ + UINT16 wRetVal = 0u; + UINT16 wBufIndex = 0u; + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wAtsLgcStation; + } + else + { + ; + } + + return wRetVal; +} + +/* +* ָгһ߼վ̨ID +* ˵ const UINT16 wTrainId, гID +* const UINT16 wLgcStation гһ߼վ̨ID +* ֵ +*/ +void SetTrainAtsLgcStation(const UINT16 wTrainId, const UINT16 wLgcStation) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].wAtsLgcStation = wLgcStation; + } + else + { + ; + } +} + +/* +* ȡָгһID +* ˵ const UINT16 wTrainId, гID +* ֵ гһID +*/ +UINT16 GetTrainNextTioc(const UINT16 wTrainId) +{ + UINT16 wRetVal = 0u; + UINT16 wBufIndex = 0u; + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wNextTioc; + } + else + { + ; + } + + return wRetVal; +} + +/* +* ָгһID +* ˵ const UINT16 wTrainId, гID +* const UINT16 wNextTioc гһID(0x3c +* ֵ +*/ +void SetTrainNextTioc(const UINT16 wTrainId, const UINT16 wNextTioc) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].wNextTioc = wNextTioc; + } + else + { + ; + } +} + +/* +* ָгѹ״̬ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chState гѹ״̬ +* ֵ +*/ +void SetTrainDerailment(const UINT16 wTrainId, const UINT8 chState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) + && ((TRAIN_DERAIL_YES == chState) || (TRAIN_DERAIL_NO == chState))) + { + gstTrainInfo[wBufIndex].chDerailment = chState; + } + else + { + ; + } +} + +/* +* ȡָгѹ״̬ +* ˵ const UINT16 wTrainId, гID +* ֵ гѹ״̬ +*/ +UINT8 GetTrainDerailment(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_DERAIL_YES; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chDerailment; + } + else + { + ; + } + + return chRetVal; +} + + +/* +* жгλǷЧ +* ˵ const UINT16 wTrainId, гID +* ֵ CI_ERROR:гλЧCI_SUCCESS:гλЧ +*/ +UINT8 IsTrainPosValid(const UINT16 wTrainId) +{ + UINT16 wMaxHeadLink = 0u; + UINT32 dwMaxHeadOff = 0u; + UINT16 wMinHeadLink = 0u; + UINT32 dwMinHeadOff = 0u; + UINT16 wMaxTailLink = 0u; + UINT32 dwMaxTailOff = 0u; + UINT16 wMinTailLink = 0u; + UINT32 dwMinTailOff = 0u; + UINT8 chRtn = CI_ERROR; + + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); + dwMaxHeadOff = GetTrainMaxHeadOffset(wTrainId); + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + dwMinHeadOff = GetTrainMinHeadOffset(wTrainId); + wMaxTailLink = GetTrainMaxTailLink(wTrainId); + dwMaxTailOff = GetTrainMaxTailOffset(wTrainId); + wMinTailLink = GetTrainMinTailLink(wTrainId); + dwMinTailOff = GetTrainMinTailOffset(wTrainId); + + chRtn = CheckLinkValid(wMaxHeadLink, dwMaxHeadOff); + chRtn &= CheckLinkValid(wMinHeadLink, dwMinHeadOff); + chRtn &= CheckLinkValid(wMaxTailLink, dwMaxTailOff); + chRtn &= CheckLinkValid(wMinTailLink, dwMinTailOff); + + return chRtn; +} + +/* +* гǰ +*wTrainId гid wHeadAxis ǰid +*ֵ void +*Created: fan 2024.2.21 +*/ +void SetHeadAxisId(const UINT16 wTrainId, const UINT16 wHeadAxis) +{ + + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].wHeadAxisId = wHeadAxis; + } + else + { + ; + } +} + +/* +* гǰITEʶ +*wTrainId гid devState ǰITEʶ +*ֵ void +*Created: fan 2024.2.21 +*/ +void SetHeadITEResult(const UINT16 wTrainId, const UINT8 devState) +{ + + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && + ((TRAIN_ITE_RESULT_YES == devState) || (TRAIN_ITE_RESULT_NO == devState))) + { + gstTrainInfo[wBufIndex].wHeadITEResult = devState; + } + else + { + ; + } +} + +/* +* г󷽼 +*wTrainId гid wTailAxis 󷽼id +*ֵ void +*Created: fan 2024.2.21 +*/ +void SetTailAxisId(const UINT16 wTrainId, const UINT16 wTailAxis) +{ + + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].wTailAxisId = wTailAxis; + } + else + { + ; + } +} +/* +* гITEʶ +*wTrainId гid devState ITEʶ +*ֵ void +*Created: fan 2024.2.21 +*/ +void SetTailITEResult(const UINT16 wTrainId, const UINT8 devState) +{ + + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && + ((TRAIN_ITE_RESULT_YES == devState) || (TRAIN_ITE_RESULT_NO == devState))) + { + gstTrainInfo[wBufIndex].wTailITEResult = devState; + } + else + { + ; + } +} + +/* +* ȡIVOCṩRCǰźITEʶ +*wTrainId гid +*زUINT8 *devState 0x55г 0xAAг) +*ֵUINT16 AxisId ǰ +*Created: fan 2024.2.21 +*/ +UINT16 GetTrainHeadITEScreen(const UINT16 wTrainId, UINT8* devState) +{ + UINT16 AxisId = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) &&(NULL != devState)) + { + AxisId = gstTrainInfo[wBufIndex].wHeadAxisId ; + *devState = gstTrainInfo[wBufIndex].wHeadITEResult; + } + else + { + AxisId = 0xffff; /*Ƿֵ*/ + } + + return AxisId; +} + +/** +* ȡIVOCṩRCĺ󷽷źITEʶ +*wTrainID гid +*زUINT8 * devState 0x55г 0xAAг) +*ֵUINT16 AxisId +*Created: fan 2024.2.21 +*/ +UINT16 GetTrainTailITEScreen(const UINT16 wTrainId, UINT8* devState) +{ + UINT16 AxisId = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + AxisId = gstTrainInfo[wBufIndex].wTailAxisId; + *devState = gstTrainInfo[wBufIndex].wTailITEResult; + } + else + { + AxisId = 0xffff; /*Ƿֵ*/ + } + + return AxisId; +} + +/* +* гԴǷȫзǷATS·зƥ +* const UINT16 wTrainId гID +* const UINT8 cQueryDir ߼ζӦIJѯ߼ +* const UINT8 cLogSecSum ߼ +* const UINT16 pLogSecIdBuff[] ߼ID +* UINT8* pHalfRouteSwitchMoveFlag ؽ·ɶ־ +* UINT16 *pTrainOccLogSecSum г߼ +* UINT16 pTrainOccLogSecID[] г߼ID +* ֵ CI_SUCCESSͨ + CI_ERROR: 鲻ͨ +*/ +UINT8 TrainResAndDirCheck(const UINT16 wTrainId, const UINT8 cQueryDir, const UINT8 cLogSecSum, const UINT16 pLogSecIdBuff[], UINT8* pHalfRouteSwitchMoveFlag, UINT16* pTrainOccLogSecSum, UINT16 pTrainOccLogSecID[]) +{ + /*ֲʼ*/ + UINT8 retVal = CI_ERROR; + UINT8 cFuncResult = CI_ERROR; + UINT16 i = 0U; + UINT8 cTrainLevel = 0U; /*г*/ + UINT8 cTrainMaxTailDir = 0U; /*г*/ + UINT8 cLogSecQueryDir = 0U; /*߼βѯ*/ + struct_PathPoint strMaxTailPoint = { 0U }; /*гλ*/ + struct_PathPoint strMaxTailCrossPoint = { 0U }; /*г+ѹλ*/ + struct_PathPoint strMaxHeadPoint = { 0U }; /*гǰλ*/ + struct_PathPoint strMinTailPoint = { 0U }; /*гСλ*/ + UINT32 dwCrossDis = 0U; /*ݣжϿѹ*/ + UINT16 wSwitchId = 0U; /*Ҫı*/ + UINT16 wLogSecTrainId = 0U; /*߼ԴгID*/ + UINT8 cTrainInfoSum = 0U; /*߼Դг*/ + LogicTrainResStruct* pTrainResData = NULL; /*߼ԴгϢṹ*/ + UINT8 cHrSwitchMoveFlag = ROUTE_HALF_SWITCH_MOVE_INVALID; /*ؽ·ɶ־*/ + UINT16 wTrainMinTMaxHLogNum = 0U; /*гСǰ߼*/ + UINT16 szTrainMinTMaxHLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*гСǰ߼ID*/ + UINT16 wTrainMaxCMaxHLogNum = 0U; /*г´+ѹǰ߼*/ + UINT16 szTrainMaxCMaxHLogID[SIZE_MAX_SECTION_BT_TRAIN] = { 0U }; /*г´+ѹǰ߼ID*/ + UINT16 wMaxTailLinkId = 0U; /*гLink*/ + UINT8 cLogSecIncLinkNum = 0U; /*߼ΰlink*/ + UINT16* pLogSecIncLinkId = NULL; /*߼ΰlink ID*/ + LOD_STRU strCurPoint = { 0U }; + LOD_STRU strNxtPoint = { 0U }; + UINT8 cDirChangeNum = 0U; /*г߼μķ仯*/ + UINT8 cStartDir = 0u; /*гѯ߼*/ + UINT8 cErrStep = 0U; /*¼ʧܵı*/ + UINT8 cLocalCiId = 0U; + UINT8 cMaxHeadBelongCiId = 0U; /*гǰ*/ + UINT8 cMinTailBelongCiId = 0U; /*гС*/ + UINT8 cTrianAllInOtherRcFlag = FLAG_UNSET; /*г־*/ + UINT8 cCommStateWithTrain = CI_ERROR; /*복ͨ״̬*/ + UINT8 cLogSecLockState = LOG_SECTION_LOCK_NO; /*߼ν·״̬*/ + UINT8 cLogSecLogLockState = LOG_SECTION_LOGLOCK_NO; /*߼߼״̬*/ + UINT16 wOutLogSecNum = 0U; /*г*/ + + /*μ飨гIDݲ飩*/ + if (((DIR_SAME == cQueryDir) || (DIR_CONVERT == cQueryDir)) && (0U != cLogSecSum) && (NULL != pLogSecIdBuff)) + { + retVal = CI_SUCCESS; + cCommStateWithTrain = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_GOOD == cCommStateWithTrain) /*гIDϷж*/ + { + cTrainMaxTailDir = GetTrainDir_MaxTail(wTrainId); + + if ((DIR_SAME == cTrainMaxTailDir) || (DIR_CONVERT == cTrainMaxTailDir)) + { + /*ȡгλ*/ + strMaxHeadPoint.wLinkId = GetTrainMaxHeadLink(wTrainId); + strMaxHeadPoint.dwOffset = GetTrainMaxHeadOffset(wTrainId); + strMaxTailPoint.wLinkId = GetTrainMaxTailLink(wTrainId); + strMaxTailPoint.dwOffset = GetTrainMaxTailOffset(wTrainId); + strMinTailPoint.wLinkId = GetTrainMinTailLink(wTrainId); + strMinTailPoint.dwOffset = GetTrainMinTailOffset(wTrainId); + + dwCrossDis = (UINT32)GetSigCrossMaxLen(); + dwCrossDis = dwCrossDis * 100U; /*ѹתcm*/ + cFuncResult = dsuNewLocAndObsByOffsetDis(strMaxTailPoint, dwCrossDis, cTrainMaxTailDir, &strMaxTailCrossPoint, &wSwitchId); /*гλãͷһѹ*/ + + if ((1U == cFuncResult) || (3U == cFuncResult)) + { + /*гλóɹ*/ + } + else + { + cErrStep = 2U; + retVal = CI_ERROR; /*гλʧܣ0ʧ*/ + } + } + else + { + cErrStep = 2U; + retVal = CI_ERROR; /*쳣0ʧ*/ + } + + if (CI_SUCCESS == retVal) + { + cLocalCiId = GetSystemParaLocalCiId(); + cMaxHeadBelongCiId = (UINT8)GetLinkManageTiocById(strMaxHeadPoint.wLinkId); /*ȡгǰRC*/ + cMinTailBelongCiId = (UINT8)GetLinkManageTiocById(strMinTailPoint.wLinkId); /*ȡгǰRC*/ + + if ((0U != cLocalCiId) && ((cLocalCiId == cMaxHeadBelongCiId) || (cLocalCiId == cMinTailBelongCiId))) + { + /*ȡг߼/ID*/ + retVal = GetLogSecBtwTwoPoints(strMinTailPoint, strMaxHeadPoint, &wTrainMinTMaxHLogNum, szTrainMinTMaxHLogID); /*ȡгСǰ߼*/ + retVal &= GetLogSecBtwTwoPoints(strMaxTailCrossPoint, strMaxHeadPoint, &wTrainMaxCMaxHLogNum, szTrainMaxCMaxHLogID); /*ȡг+ѹǰ߼*/ + + if ((CI_SUCCESS == retVal) && (0U < wTrainMinTMaxHLogNum) && (SIZE_MAX_SECTION_BT_TRAIN > wTrainMinTMaxHLogNum) + && (0U < wTrainMaxCMaxHLogNum) && (SIZE_MAX_SECTION_BT_TRAIN > wTrainMaxCMaxHLogNum)) + { + /*ִ*/ + } + else + { + cErrStep = 3U; + retVal = CI_ERROR; /*г߼Ƿ0ʧ*/ + } + } + else if((0U != cLocalCiId) && (0U != cMaxHeadBelongCiId) && (0U != cMinTailBelongCiId) + && (cLocalCiId != cMaxHeadBelongCiId) && (cLocalCiId != cMinTailBelongCiId)) + { + cTrianAllInOtherRcFlag = FLAG_SET; /*гȫڱִ*/ + } + else + { + cErrStep = 3U; + retVal = CI_ERROR; /*ȡʧܣ0ʧ*/ + } + } + else + { + /**/ + } + + if ((CI_SUCCESS == retVal) && (FLAG_UNSET == cTrianAllInOtherRcFlag)) + { + /*ȷг߼εIJѯ*/ + cLogSecQueryDir = cQueryDir; + wMaxTailLinkId = GetTrainMaxTailLink(wTrainId); + cLogSecIncLinkNum = GetSecIntrudeLinkSum(pLogSecIdBuff[0]); + pLogSecIncLinkId = GetSecIntrudeLinkIdBuf(pLogSecIdBuff[0]); + + if ((CI_ERROR != wMaxTailLinkId) && (NULL != pLogSecIncLinkId) && (0U < cLogSecIncLinkNum) && (LOGSEC_INCLUDE_LINK_SUM_MAX >= cLogSecIncLinkNum)) + { + strCurPoint.Lnk = pLogSecIncLinkId[0U]; + strCurPoint.Off = 0U; + strNxtPoint.Lnk = wMaxTailLinkId; + strNxtPoint.Off = 0U; + cDirChangeNum = GetDirChangeNumBtwPoints(&strCurPoint, &strNxtPoint); /*ѯг׸߼μķ仯*/ + cStartDir = TransDirByChangeNum(cTrainMaxTailDir, cDirChangeNum); + } + else + { + cErrStep = 4U; + retVal = CI_ERROR; /*ȡlinkʧܣʧ*/ + } + + cTrainLevel = GetTrainLevel(wTrainId); + if ((TRAIN_LEVEL_VBTC == cTrainLevel) && (CI_SUCCESS == retVal)) /*VBTC*/ + { + /*жг+ѹǰ߼ԴǷΨһȫ*/ + for (i = 0U; i < wTrainMaxCMaxHLogNum; i++) + { + cTrainInfoSum = GetLogSecTrainInfoSum(szTrainMaxCMaxHLogID[i]); /*ȡ߼Դг*/ + pTrainResData = GetLogSecTrainInfo(szTrainMaxCMaxHLogID[i]); /*ȡ߼ԴгϢṹ*/ + if ((1U == cTrainInfoSum) && (NULL != pTrainResData)) + { + /*гԴΪ1*/ + wLogSecTrainId = pTrainResData[0U].wTrainId; + if (((wLogSecTrainId & 0xFFU) == (wTrainId & 0xFFU)) && (LOGIC_SECTION_RES_USABLE == pTrainResData[0U].chLogicResUsable)) + { + retVal = CI_SUCCESS; /*Դãسɹ*/ + } + else + { + retVal = CI_ERROR; /*Դֹͣ飬ʧ*/ + break; + } + } + else + { + retVal = CI_ERROR; + break; + } + } + + if (CI_SUCCESS == retVal) + { + cHrSwitchMoveFlag = ROUTE_HALF_SWITCH_MOVE_VALID; + retVal = CI_SUCCESS; + + } + else + { + /*VBTCԴȫòɶ־*/ + cHrSwitchMoveFlag = ROUTE_HALF_SWITCH_MOVE_INVALID; + + if (((DIR_SAME == cLogSecQueryDir) && (DIR_SAME == cStartDir)) + || ((DIR_CONVERT == cLogSecQueryDir) && (DIR_CONVERT == cStartDir))) + { + retVal = CI_SUCCESS; /*ATS·з뵱ǰгзͬ*/ + } + else + { + cErrStep = 5U; + retVal = CI_ERROR; /*ATS·з뵱ǰгз෴ֹͣ*/ + } + } + } + else if (CI_SUCCESS == retVal) /*VBTC*/ + { + /*VBTCòɶ־*/ + cHrSwitchMoveFlag = ROUTE_HALF_SWITCH_MOVE_INVALID; + + if (((DIR_CONVERT == cLogSecQueryDir) && (DIR_CONVERT == cStartDir)) + || ((DIR_SAME == cLogSecQueryDir) && (DIR_SAME == cStartDir))) + { + retVal = CI_SUCCESS; /*ATS·з뵱ǰгзͬ*/ + } + else + { + cErrStep = 5U; + retVal = CI_ERROR; /*ATS·з뵱ǰгз෴ֹͣ*/ + } + } + else + { + retVal = CI_ERROR; /*ʧ*/ + } + } + else if ((CI_SUCCESS == retVal) && (FLAG_SET == cTrianAllInOtherRcFlag)) + { + cHrSwitchMoveFlag = ROUTE_HALF_SWITCH_MOVE_INVALID; /*гȫڱ*/ + } + else + { + /*ʧ*/ + } + } + else if (CI_ERROR != cCommStateWithTrain) + { + cHrSwitchMoveFlag = ROUTE_HALF_SWITCH_MOVE_INVALID; /*δгͨ*/ + } + else + { + /*Чֱӷسɹ*/ + } + } + else + { + cErrStep = 1U; + retVal = CI_ERROR; /*Уʧ*/ + } + + if (CI_SUCCESS == retVal) + { + *pHalfRouteSwitchMoveFlag = cHrSwitchMoveFlag; + if (ROUTE_HALF_SWITCH_MOVE_VALID == cHrSwitchMoveFlag) + { + /*ɶ¼г߼*/ + debug_infor_printf((const)"Dynamic Route TrainOccLogSecID["); + for (i = 0U; i < wTrainMinTMaxHLogNum; i++) + { + cLogSecLockState = GetLogSecLockState(szTrainMinTMaxHLogID[i]); + cLogSecLogLockState = GetLogSecLogLockState(szTrainMinTMaxHLogID[i]); + if ((LOG_SECTION_LOCK_NORMAL == cLogSecLockState) || (LOG_SECTION_LOCK_DELAY == cLogSecLockState) || (LOG_SECTION_LOGLOCK_NORMAL == cLogSecLogLockState)) + { + pTrainOccLogSecID[wOutLogSecNum] = szTrainMinTMaxHLogID[i]; + debug_infor_printf((const)"%d,", szTrainMinTMaxHLogID[i]); + wOutLogSecNum++; + } + else + { + /*δգΪгδ*/ + } + } + debug_infor_printf((const)"]\n"); + + *pTrainOccLogSecSum = wOutLogSecNum; + } + else + { + /*ɶ¼г߼*/ + } + } + else + { + /*1-ηǷ2-гʧܣ3-ȡг߼ʧܣ4-ȡгlinkʧܣ5-߼згƥ*/ + debug_infor_printf((const)"Dynamic Route TrainResAndDirCheck ErrStep[%d]\n", cErrStep); + } + + return retVal; +} + +/* +* гԴ +* ˵ +* ֵ +* noteгȫʻ·󣬻гԴ +*/ +void TrainResRecycle(void) +{ + UINT16 ii = 0u; + UINT8 trainIndex = 0U; + UINT16 routeCurSum = 0u; /*·Ŀ*/ + UINT16 routeId = 0u; /*·ID*/ + UINT8 localCiId = 0U; /*ǰID*/ + UINT8 routeBelongCiId = 0U; /*·ID*/ + + UINT8 funcRetval = 0U; + UINT8 routeInTrainNum = 0U; + UINT8 trainOTStat = 0U; + UINT16 routeInTrainId[LOGIC_SECTION_RES_SUM_MAX] = { 0U }; + UINT8 chTrainSleepState = 0U;/*г״̬*/ + + localCiId = GetSystemParaLocalCiId(); + routeCurSum = GetRouteCurSum(); /*ȡ·*/ + /*·*/ + for (ii = 0u; ii < routeCurSum; ii++) + { + + routeId = GetRouteId(ii); /*ȡ·ID*/ + routeBelongCiId = GetRouteBelongCiId(routeId); /*ȡ·ID*/ + + if ((routeBelongCiId == localCiId) && (0U != routeBelongCiId)) + { + /*ý·*/ + funcRetval = RouteAllLockCheck(routeId); + /*ȡҪ·гϢ*/ + funcRetval &= GetRouteReadyEnterTrainInfo(routeId, &routeInTrainNum, routeInTrainId); + + if (CI_SUCCESS == funcRetval) + { + for (trainIndex = 0U; trainIndex < routeInTrainNum; trainIndex++) + { + trainOTStat=GetTrainResRecycleOTStat(routeInTrainId[trainIndex]); + chTrainSleepState = GetTrainSleepState(routeInTrainId[trainIndex]); + if ((CI_SUCCESS == trainOTStat) && (TRAIN_SLEEP_YES !=chTrainSleepState)) + { + /*ȡ·ӽǷпг*/ + funcRetval = GetRouteSuspiciousInNearSec(routeId); + if (CI_SUCCESS == funcRetval) + { + /*ԴȡʱʱҲΪ߳ŻԴ߳Դ*/ + RemoveRouteInCiRes(routeId, routeInTrainId[trainIndex]); /*ɾг·Դ*/ + } + else + { + ; + } + } + } + } + else + { + ; + } + + /*ɾгԴӽβѯ״̬Ϊйϳ*/ + SetRouteNearSecSearchState(routeId, ROUTE_NEAR_SEC_HAVE_UT); + } + else + { + ; /**/ + } + } +} + +/* +* ȡָгǷԴʱ +* ˵ const UINT16 wTrainId, гID +* ֵ CI_ERROR 㣨δʱ/δʱ CI_SUCCESS 㣨ʱ +*/ +UINT8 GetTrainResRecycleOTStat(const UINT16 wTrainId) +{ + UINT8 chRetVal = CI_ERROR; + UINT8 overtimeStat = CI_TIME_NO; + UINT8 trainTransimitStat = TRAIN_COMM_STATE_BAD; + UINT32 trainLoseCommCyc = 0U; + UINT16 wBufIndex = 0U; + UINT32 overtimeCycleCount = 0U; + + + overtimeCycleCount = GetSystemParaTrainReCycleCount(); + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + trainTransimitStat = GetTrainTransitmitStat(wTrainId); + trainLoseCommCyc = GetTrainTransBadCyc(wTrainId); + + /*гͨŲ*/ + if (TRAIN_COMM_STATE_BAD == trainTransimitStat) + { + + overtimeStat = SystemOverTimeCheck(trainLoseCommCyc, overtimeCycleCount); + + if (CI_TIME_OUT == overtimeStat) + { + /*ʱ*/ + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + + return chRetVal; +} + +/* +* гз +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTrainDir гзѻȡӪСָͷ +* ֵ CI_ERROR ʧ CI_SUCCESS óɹ +*/ +UINT8 SetTrainOtherPointDir(const UINT16 wTrainId, const UINT8 chTrainDir) +{ + UINT8 chRetVal = CI_ERROR; + UINT16 wTrainIndex = 0U; + UINT16 linknum_MaxHead = 0u; + UINT16 linknum_MinHead = 0u; + UINT16 linknum_MaxTail = 0u; + LOD_STRU pMaxHead = { 0u }; /*ȫǰλ*/ + LOD_STRU pMinHead = { 0u }; /*Сȫǰλ*/ + LOD_STRU pMaxTail = { 0u }; /*ȫλ*/ + LOD_STRU pMinTail = { 0u }; /*Сȫλ*/ + UINT8 changerPNumtoMaxHead = 0u;/*Сȫλõȫǰλþķ仯*/ + UINT8 changerPNumtoMinHead = 0u;/*СȫλõСȫǰλþķ仯*/ + UINT8 changerPNumtoMaxTail = 0u;/*Сȫλõȫλþķ仯*/ + UINT32 dwlen_tomaxhead = 0u; + UINT32 dwlen_tominhead = 0u; + UINT32 dwlen_tomaxtail = 0u; + UINT16 linkID_maxhead[AS_LINK_MAX] = { 0u }; + UINT16 linkID_minhead[AS_LINK_MAX] = { 0u }; + UINT16 linkID_maxtail[AS_LINK_MAX] = { 0u }; + UINT8 dirToMaxhead = 0u; + UINT8 dirToMinhead = 0u; + UINT8 dirToMaxTail = 0u; + + UINT8 dirLogic = 0u; + + dirLogic = ConvertDirectionToLogic(chTrainDir); + wTrainIndex = GetTrainBufIndex(wTrainId); + pMaxHead.Lnk = gstTrainInfo[wTrainIndex].wTrainMaxHeadLink; + pMaxHead.Off = gstTrainInfo[wTrainIndex].dwTrainMaxHeadOffset; + pMinHead.Lnk = gstTrainInfo[wTrainIndex].wTrainMinHeadLink; + pMinHead.Off = gstTrainInfo[wTrainIndex].dwTrainMinHeadOffset; + pMaxTail.Lnk = gstTrainInfo[wTrainIndex].wTrainMaxTailLink; + pMaxTail.Off = gstTrainInfo[wTrainIndex].dwTrainMaxTailOffset; + pMinTail.Lnk = gstTrainInfo[wTrainIndex].wTrainMinTailLink; + pMinTail.Off = gstTrainInfo[wTrainIndex].dwTrainMinTailOffset; + + if ((0u == pMinTail.Lnk) && (UINT32_MAX == pMinTail.Off)) + { + gstTrainInfo[wTrainIndex].chTrainDir_MaxHead = dirLogic; + gstTrainInfo[wTrainIndex].chTrainDir_MinHead = dirLogic; + gstTrainInfo[wTrainIndex].chTrainDir_MaxTail = dirLogic; + chRetVal = CI_SUCCESS; + } + else + { + /*鳵βȫǰ˵link*/ + dwlen_tomaxhead = dsuLenByPoint_GetDir(&pMinTail, &pMaxHead, &linknum_MaxHead, linkID_maxhead, &dirToMaxhead, &changerPNumtoMaxHead); + dwlen_tominhead = dsuLenByPoint_GetDir(&pMinTail, &pMinHead, &linknum_MinHead, linkID_minhead, &dirToMinhead, &changerPNumtoMinHead); + dwlen_tomaxtail = dsuLenByPoint_GetDir(&pMinTail, &pMaxTail, &linknum_MaxTail, linkID_maxtail, &dirToMaxTail, &changerPNumtoMaxTail); + + if ((TRAIN_SUM_MAX > wTrainIndex) + && (UINT32_MAX != dwlen_tomaxhead) && (UINT32_MAX != dwlen_tominhead) && (UINT32_MAX != dwlen_tomaxtail)) + { + + if ((0u != linknum_MaxHead) && (0u != linknum_MinHead) && (0u != linknum_MaxTail) + && (dirToMaxhead == dirLogic) && (dirToMinhead == dirLogic) && (dirToMaxTail == dirLogic)) + { + if (0u == changerPNumtoMaxHead % 2u) + {/*гβȫǰż仯*/ + gstTrainInfo[wTrainIndex].chTrainDir_MaxHead = dirLogic; + } + else + {/*гβȫǰ仯*/ + gstTrainInfo[wTrainIndex].chTrainDir_MaxHead = ConvertTrainDir(dirLogic); + } + + if (0u == changerPNumtoMinHead % 2u) + {/*гβСȫǰż仯*/ + gstTrainInfo[wTrainIndex].chTrainDir_MinHead = dirLogic; + } + else + {/*гβСȫǰ仯*/ + gstTrainInfo[wTrainIndex].chTrainDir_MinHead = ConvertTrainDir(dirLogic); + } + + if (0u == changerPNumtoMaxTail % 2u) + {/*гβȫż仯*/ + gstTrainInfo[wTrainIndex].chTrainDir_MaxTail = dirLogic; + } + else + {/*гβȫǰ仯*/ + gstTrainInfo[wTrainIndex].chTrainDir_MaxTail = ConvertTrainDir(dirLogic); + + } + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + return chRetVal; +} + + +/* +* УгСǷ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTrainDir гзѻȡģСָͷӪ +* ֵ CI_ERROR ʧ CI_SUCCESS óɹ +*/ +UINT8 CheckTrainDirToOtherPointDir(LOD_STRU pMaxHead,LOD_STRU pMinHead,LOD_STRU pMaxTail,LOD_STRU pMinTail, const UINT8 chTrainDir) +{ + UINT8 chRetVal = CI_ERROR; + + UINT16 linknum_MaxHead = 0u; + UINT16 linknum_MinHead = 0u; + UINT16 linknum_MaxTail = 0u; + + UINT8 changerPNumtoMaxHead = 0u;/*Сȫλõȫǰλþķ仯*/ + UINT8 changerPNumtoMinHead = 0u;/*СȫλõСȫǰλþķ仯*/ + UINT8 changerPNumtoMaxTail = 0u;/*Сȫλõȫλþķ仯*/ + UINT32 dwlen_tomaxhead = 0u; + UINT32 dwlen_tominhead = 0u; + UINT32 dwlen_tomaxtail = 0u; + UINT16 linkID_maxhead[AS_LINK_MAX] = { 0u }; + UINT16 linkID_minhead[AS_LINK_MAX] = { 0u }; + UINT16 linkID_maxtail[AS_LINK_MAX] = { 0u }; + + UINT8 dirToMaxhead = 0u; + UINT8 dirToMinhead = 0u; + UINT8 dirToMaxTail = 0u; + UINT8 dirLogic = 0u; + dirLogic = ConvertDirectionToLogic(chTrainDir); + + if ((0u == pMinTail.Lnk) && (UINT32_MAX == pMinTail.Off)) + { + chRetVal = CI_SUCCESS; + } + else + { + /*鳵βȫǰ˵link*/ + dwlen_tomaxhead = dsuLenByPoint_GetDir(&pMinTail, &pMaxHead, &linknum_MaxHead, linkID_maxhead, &dirToMaxhead, &changerPNumtoMaxHead); + dwlen_tominhead = dsuLenByPoint_GetDir(&pMinTail, &pMinHead, &linknum_MinHead, linkID_minhead, &dirToMinhead, &changerPNumtoMinHead); + dwlen_tomaxtail = dsuLenByPoint_GetDir(&pMinTail, &pMaxTail, &linknum_MaxTail, linkID_maxtail, &dirToMaxTail, &changerPNumtoMaxTail); + + if ((UINT32_MAX != dwlen_tomaxhead) && (UINT32_MAX != dwlen_tominhead) && (UINT32_MAX != dwlen_tomaxtail) + && (dwlen_tomaxhead > dwlen_tominhead) && (dwlen_tominhead > dwlen_tomaxtail)) + { + + if ((0u != linknum_MaxHead) && (0u != linknum_MinHead) && (0u != linknum_MaxTail) + && (dirToMaxhead == dirLogic) && (dirToMinhead == dirLogic) && (dirToMaxTail == dirLogic)) + { + /*гǰ Сǰ Сӳ*/ + chRetVal = CI_SUCCESS; + } + else + { + chRetVal = CI_ERROR; + } + } + else + { + chRetVal = CI_ERROR; + } + } + return chRetVal; +} + +/* +* ָгRCԶRMԭ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chReson гRCԶRMԭ +* ֵ +*/ +void SetTrainOtherRcRrmReson(const UINT16 wTrainId, const UINT8 chReson) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && + ((TRAIN_RRM_RESON_02 == chReson) || (TRAIN_RRM_RESON_FF == chReson) + || ((TRAIN_RRM_RESON_05 <= chReson) && (TRAIN_RRM_RESON_0E >= chReson)) + || ((TRAIN_RRM_RESON_15 <= chReson) && (TRAIN_RRM_RESON_17 >= chReson)))) + { + gstTrainInfo[wBufIndex].chRrmResonFromOtherRc = chReson; + } + else + { + ; + } +} + +/* +* ȡָгRRMԭ +* ˵ const UINT16 wTrainId, гID +* ֵ гRCԶRMԭ +*/ +UINT8 GetTrainOtherRcRrmReson(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_RRM_RESON_FF; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chRrmResonFromOtherRc; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгABLг߼ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelLogSecNum ABLг߼ +* ֵ +*/ +void SetTrainAblRelLogSecNum(const UINT16 wTrainId, const UINT8 chAblRelLogSecNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.chAblRelLogSecNum = chAblRelLogSecNum; + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLг߼ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLг߼ +*/ +UINT8 GetTrainAblRelLogSecNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.chAblRelLogSecNum; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ָгABLг߼Ϣ +* ˵ const UINT16 wTrainId, гID +* ABLTrainRelLogStru ablTrainRelLogData[TRAIN_ABL_LOGSEC_SUM] гABLг߼Ϣ +* ֵ void +*/ +void SetTrainAblRelLogSecData(const UINT16 wTrainId, ABLTrainRelLogStru ablTrainRelLogData[TRAIN_ABL_LOGSEC_SUM]) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + (void)CommonMemSet(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelLogData, + (UINT32)(sizeof(ABLTrainRelLogStru)*TRAIN_ABL_LOGSEC_SUM), + 0U, (UINT32)(sizeof(ABLTrainRelLogStru)*TRAIN_ABL_LOGSEC_SUM)); /*ȳ壬ֹ*/ + + (void)CommonMemCpy(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelLogData, /*ָгABLг߼Ϣ*/ + (UINT32)(sizeof(ABLTrainRelLogStru)*TRAIN_ABL_LOGSEC_SUM), + ablTrainRelLogData, (UINT32)(sizeof(ABLTrainRelLogStru)*TRAIN_ABL_LOGSEC_SUM)); + } + else + { + ; + } +} + +/* +* ȡָгABLг߼Ϣ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLг߼Ϣ +*/ +ABLTrainRelLogStru* GetTrainAblRelLogData(const UINT16 wTrainId) +{ + ABLTrainRelLogStru* chRetValablTrainRelLogData = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetValablTrainRelLogData = gstTrainInfo[wBufIndex].strAblTrainNeedData.ablTrainRelLogData; + } + else + { + chRetValablTrainRelLogData = NULL; + } + + return chRetValablTrainRelLogData; +} + + +/* +* ָгABLг۷߼ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelReturnLogNum ABLг۷߼ +* ֵ +*/ +void SetTrainAblRelReturnLogNum(const UINT16 wTrainId, const UINT8 chAblRelReturnLogNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelReturnLogNum = chAblRelReturnLogNum; + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLг۷߼ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLг۷߼ +*/ +UINT8 GetTrainAblRelReturnLogNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelReturnLogNum; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ָгABLг۷߼ID +* ˵ const UINT16 wTrainId, гID +* UINT16 ablTrainRelReturnLogIdBuf[TRAIN_ABL_RETURNLOGSEC_SUM] гABLг۷߼ID +* ֵ void +*/ +void SetTrainAblRelReturnLogId(const UINT16 wTrainId, UINT16 ablTrainRelReturnLogIdBuf[TRAIN_ABL_RETURNLOGSEC_SUM]) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + (void)CommonMemSet(gstTrainInfo[bufIndex].strAblTrainNeedData.wABLRelReturnLogBuf, + (UINT32)(sizeof(UINT16)*TRAIN_ABL_RETURNLOGSEC_SUM), + 0U, (UINT32)(sizeof(UINT16)*TRAIN_ABL_RETURNLOGSEC_SUM)); /*ȳ壬ֹ*/ + + (void)CommonMemCpy(gstTrainInfo[bufIndex].strAblTrainNeedData.wABLRelReturnLogBuf, /*ָгABLг۷߼ID*/ + (UINT32)(sizeof(UINT16)*TRAIN_ABL_RETURNLOGSEC_SUM), + ablTrainRelReturnLogIdBuf, (UINT32)(sizeof(UINT16)*TRAIN_ABL_RETURNLOGSEC_SUM)); + } + else + { + ; + } +} + +/* +* ȡָгABLг۷߼ID +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLг۷߼ID +*/ +UINT16* GetTrainAblRelReturnLogId(const UINT16 wTrainId) +{ + UINT16* chTrainAblRelReturnLogBuf = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chTrainAblRelReturnLogBuf = gstTrainInfo[wBufIndex].strAblTrainNeedData.wABLRelReturnLogBuf; + } + else + { + chTrainAblRelReturnLogBuf = NULL; + } + + return chTrainAblRelReturnLogBuf; +} + +/* +* ָгABLгѯΧPSD +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelPsdNum ABLгѯΧPSD +* ֵ +*/ +void SetTrainAblRelPsdNum(const UINT16 wTrainId, const UINT8 chAblRelPsdNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelPsdNum = chAblRelPsdNum; + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLгѯΧPSD +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧPSD +*/ +UINT8 GetTrainAblRelPsdNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelPsdNum; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ָгABLгѯΧPSDϢ +* ˵ const UINT16 wTrainId, гID +* ABLTrainRelPsdStru ablTrainRelPsdData[TRAIN_ABL_PSD_SUM] гABLгѯΧPSDϢ +* ֵ void +*/ +void SetTrainAblRelPsdData(const UINT16 wTrainId, ABLTrainRelPsdStru ablTrainRelPsdData[TRAIN_ABL_PSD_SUM]) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + (void)CommonMemSet(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelPsdData, + (UINT32)(sizeof(ABLTrainRelPsdStru)*TRAIN_ABL_PSD_SUM), + 0U, (UINT32)(sizeof(ABLTrainRelPsdStru)*TRAIN_ABL_PSD_SUM)); /*ȳ壬ֹ*/ + + (void)CommonMemCpy(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelPsdData, /*ָгABLгѯΧPSDϢ*/ + (UINT32)(sizeof(ABLTrainRelPsdStru)*TRAIN_ABL_PSD_SUM), + ablTrainRelPsdData, (UINT32)(sizeof(ABLTrainRelPsdStru)*TRAIN_ABL_PSD_SUM)); + } + else + { + ; + } +} + +/* +* ȡָгABLгѯΧPSDϢ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧPSDϢ +*/ +ABLTrainRelPsdStru* GetTrainAblRelPsdData(const UINT16 wTrainId) +{ + ABLTrainRelPsdStru* chRetValablTrainRelPsdData = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetValablTrainRelPsdData = gstTrainInfo[wBufIndex].strAblTrainNeedData.ablTrainRelPsdData; + } + else + { + chRetValablTrainRelPsdData = NULL; + } + + return chRetValablTrainRelPsdData; +} + +/* +* ָгABLгѯΧESB +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelEsbNum ABLгѯΧESB +* ֵ +*/ +void SetTrainAblRelEsbNum(const UINT16 wTrainId, const UINT8 chAblRelEsbNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelEsbNum = chAblRelEsbNum; + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLгѯΧESB +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧESB +*/ +UINT8 GetTrainAblRelEsbNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelEsbNum; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ָгABLгѯΧESBID +* ˵ const UINT16 wTrainId, гID +* UINT16 ablTrainRelEsbIdBuf[TRAIN_ABL_ESB_SUM] гABLгѯΧESBID +* ֵ void +*/ +void SetTrainAblRelEsbId(const UINT16 wTrainId, ABLTrainRelEsbStru ablTrainRelEsbIdBuf[TRAIN_ABL_ESB_SUM]) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + (void)CommonMemSet(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelEsbData, + (UINT32)(sizeof(ABLTrainRelEsbStru)*TRAIN_ABL_ESB_SUM), + 0U, (UINT32)(sizeof(ABLTrainRelEsbStru)*TRAIN_ABL_ESB_SUM)); /*ȳ壬ֹ*/ + + (void)CommonMemCpy(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelEsbData, /*ָгABLгѯΧESBID(Ѽ)*/ + (UINT32)(sizeof(ABLTrainRelEsbStru)*TRAIN_ABL_ESB_SUM), + ablTrainRelEsbIdBuf, (UINT32)(sizeof(ABLTrainRelEsbStru)*TRAIN_ABL_ESB_SUM)); + } + else + { + ; + } +} + +/* +* ȡָгABLгѯΧESBID(Ѽ) +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧESBI(Ѽ) +*/ +ABLTrainRelEsbStru* GetTrainAblRelEsbData(const UINT16 wTrainId) +{ + ABLTrainRelEsbStru* chTrainAblRelEsbIdBuf = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chTrainAblRelEsbIdBuf = gstTrainInfo[wBufIndex].strAblTrainNeedData.ablTrainRelEsbData; + } + else + { + chTrainAblRelEsbIdBuf = NULL; + } + + return chTrainAblRelEsbIdBuf; +} + +/* +* ָгABLгѯΧڵ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelSwitchNum ABLгѯΧڵ +* ֵ +*/ +void SetTrainAblRelSwitchNum(const UINT16 wTrainId, const UINT8 chAblRelSwitchNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelSwitchNum = chAblRelSwitchNum; + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLгѯΧڵ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧڵ +*/ +UINT8 GetTrainAblRelSwitchNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelSwitchNum; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ָгABLгѯΧڵϢ +* ˵ const UINT16 wTrainId, гID +* ABLTrainRelSwitchStru ablTrainRelSwitchData[TRAIN_ABL_SWITCH_SUM] гABLгѯΧڵϢ +* ֵ void +*/ +void SetTrainAblRelSwitchData(const UINT16 wTrainId, ABLTrainRelSwitchStru ablTrainRelSwitchData[TRAIN_ABL_SWITCH_SUM]) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + (void)CommonMemSet(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelSwitchData, + (UINT32)(sizeof(ABLTrainRelSwitchStru)*TRAIN_ABL_SWITCH_SUM), + 0U, (UINT32)(sizeof(ABLTrainRelSwitchStru)*TRAIN_ABL_SWITCH_SUM)); /*ȳ壬ֹ*/ + + (void)CommonMemCpy(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelSwitchData, /*ָгABLгѯΧڵϢ*/ + (UINT32)(sizeof(ABLTrainRelSwitchStru)*TRAIN_ABL_SWITCH_SUM), + ablTrainRelSwitchData, (UINT32)(sizeof(ABLTrainRelSwitchStru)*TRAIN_ABL_SWITCH_SUM)); + } + else + { + ; + } +} + +/* +* ȡָгABLгѯΧڵϢ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧڵϢ +*/ +ABLTrainRelSwitchStru* GetTrainAblRelSwitchData(const UINT16 wTrainId) +{ + ABLTrainRelSwitchStru* chRetValablTrainRelSwitchData = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetValablTrainRelSwitchData = gstTrainInfo[wBufIndex].strAblTrainNeedData.ablTrainRelSwitchData; + } + else + { + chRetValablTrainRelSwitchData = NULL; + } + + return chRetValablTrainRelSwitchData; +} + +/* +* ָгABLгѯΧڱ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelProSecNum ABLгѯΧڱ +* ֵ +*/ +void SetTrainAblRelProSecNum(const UINT16 wTrainId, const UINT8 chAblRelProSecNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelProSecNum = chAblRelProSecNum; + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLгѯΧڱ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧڱ +*/ +UINT8 GetTrainAblRelProSecNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelProSecNum; + } + else + { + chRetVal = 0U; + } + + return chRetVal; +} + +/* +* ָгABLгѯΧڱϢ +* ˵ const UINT16 wTrainId, гID +* ABLTrainRelProSecStru ablTrainRelProSecData[TRAIN_ABL_PROSEC_SUM] гABLгѯΧڱϢ +* ֵ void +*/ +void SetTrainAblRelProSecData(const UINT16 wTrainId, ABLTrainRelProSecStru ablTrainRelProSecData[TRAIN_ABL_PROSEC_SUM]) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + (void)CommonMemSet(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelProSecData, + (UINT32)(sizeof(ABLTrainRelProSecStru)*TRAIN_ABL_PROSEC_SUM), + 0U, (UINT32)(sizeof(ABLTrainRelProSecStru)*TRAIN_ABL_PROSEC_SUM)); /*ȳ壬ֹ*/ + + (void)CommonMemCpy(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelProSecData, /*ָгABLгѯΧڱϢ*/ + (UINT32)(sizeof(ABLTrainRelProSecStru)*TRAIN_ABL_PROSEC_SUM), + ablTrainRelProSecData, (UINT32)(sizeof(ABLTrainRelProSecStru)*TRAIN_ABL_PROSEC_SUM)); + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLгѯΧڱϢ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧڱϢ +*/ +ABLTrainRelProSecStru* GetTrainAblRelProSecData(const UINT16 wTrainId) +{ + ABLTrainRelProSecStru* chRetValablTrainRelProSecData = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetValablTrainRelProSecData = gstTrainInfo[wBufIndex].strAblTrainNeedData.ablTrainRelProSecData; + } + else + { + chRetValablTrainRelProSecData = NULL; + } + + return chRetValablTrainRelProSecData; +} + +/* +* ָгABLгѯΧ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelXianSuNum ABLгѯΧ +* ֵ +*/ +void SetTrainAblRelXianSuNum(const UINT16 wTrainId, const UINT8 chAblRelXianSuNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelXianSuNum = chAblRelXianSuNum; + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLгѯΧ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧ +*/ +UINT8 GetTrainAblRelXianSuNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.chABLRelXianSuNum; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ָгABLгѯΧϢ +* ˵ const UINT16 wTrainId, гID +* ABLTrainRelXianSuStru ablTrainRelXiansuData гABLгѯΧϢ +* ֵ void +*/ +void SetTrainAblRelXiansuData(const UINT16 wTrainId, ABLTrainRelXianSuStru ablTrainRelXiansuData) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 chXiansuPhySecNum = 0U;/*Ŀ*/ + + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + chXiansuPhySecNum = GetTrainAblRelXianSuNum(wTrainId); + if (TRAIN_ABL_XIANSUSEC_SUM > chXiansuPhySecNum) + { + gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelXiansuData[chXiansuPhySecNum] = ablTrainRelXiansuData; + gstTrainInfo[bufIndex].strAblTrainNeedData.chABLRelXianSuNum = chXiansuPhySecNum + 1U; + } + else + { + ; /*Ƿ洢*/ + } + } + else + { + + } +} + +/* +* ָгABLгѯΧϢ +* ˵ const UINT16 wTrainId, гID +* ֵ void +*/ +void ClearTrainAblRelXiansuData(const UINT16 wTrainId) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + (void)CommonMemSet(gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelXiansuData, + (UINT32)(sizeof(ABLTrainRelXianSuStru) * TRAIN_ABL_XIANSUSEC_SUM), + 0U, (UINT32)(sizeof(ABLTrainRelXianSuStru) * TRAIN_ABL_XIANSUSEC_SUM)); /**/ + + gstTrainInfo[bufIndex].strAblTrainNeedData.chABLRelXianSuNum = 0U; + } + else + { + ; /**/ + } +} + +/* +* ָгABLгָϢ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chIndex ָ +* ABLTrainRelXianSuStru ablTrainRelXiansuData гABLгѯΧϢ +* ֵ void +*/ +void SetTrainAblRelIndexXiansuData(const UINT16 wTrainId,const UINT8 chIndex,ABLTrainRelXianSuStru ablTrainRelXiansuData) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + if (TRAIN_ABL_XIANSUSEC_SUM > chIndex) + { + gstTrainInfo[bufIndex].strAblTrainNeedData.ablTrainRelXiansuData[chIndex] = ablTrainRelXiansuData; + } + else + { + ; /*Ƿ洢*/ + } + } + else + { + + } +} + +/* +* ȡָгABLгѯΧϢ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгѯΧϢ +*/ +ABLTrainRelXianSuStru* GetTrainAblRelXiansuData(const UINT16 wTrainId) +{ + ABLTrainRelXianSuStru* chRetValablTrainRelXiansuData = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetValablTrainRelXiansuData = gstTrainInfo[wBufIndex].strAblTrainNeedData.ablTrainRelXiansuData; + } + else + { + chRetValablTrainRelXiansuData = NULL; + } + + return chRetValablTrainRelXiansuData; +} + +/* +* ָгABLµǰн· +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblAllRouteNum ABLµǰн· +* ֵ +*/ +void SetTrainAblAllRouteNum(const UINT16 wTrainId, const UINT8 chAblAllRouteNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.chAblAllRouteNum = chAblAllRouteNum; + } + else + { + ; /**/ + } +} + +/* +* ȡָгABLµǰн· +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLµǰн· +*/ +UINT8 GetTrainAblAllRouteNum(const UINT16 wTrainId) +{ + UINT8 chRetVal = UINT8_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.chAblAllRouteNum; + } + else + { + chRetVal = UINT8_MAX; + } + + return chRetVal; +} + +/* +* ָгABLгµǰн·Ϣ +* ˵ const UINT16 wTrainId, гID +* ABLTrainRelAllRouteStru ablTrainRelAllRouteData[TRAIN_ABL_ALLROUTE_SUM] гABLгµǰн·Ϣ +* ֵ void +*/ +void SetTrainAblRelAllRouteData(const UINT16 wTrainId, ABLTrainRelAllRouteStru ablTrainRelAllRouteData[TRAIN_ABL_ALLROUTE_SUM]) +{ + UINT16 bufIndex = 0u; /*±*/ + bufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > bufIndex) + { + (void)CommonMemSet(gstTrainInfo[bufIndex].strAblTrainNeedData.wAblAllRouteData, + (UINT32)(sizeof(ABLTrainRelAllRouteStru)*TRAIN_ABL_ALLROUTE_SUM), + 0U, (UINT32)(sizeof(ABLTrainRelAllRouteStru)*TRAIN_ABL_ALLROUTE_SUM)); /*ȳ壬ֹ*/ + + (void)CommonMemCpy(gstTrainInfo[bufIndex].strAblTrainNeedData.wAblAllRouteData, /*ָгABLгµǰн·Ϣ*/ + (UINT32)(sizeof(ABLTrainRelAllRouteStru)*TRAIN_ABL_ALLROUTE_SUM), + ablTrainRelAllRouteData, (UINT32)(sizeof(ABLTrainRelAllRouteStru)*TRAIN_ABL_ALLROUTE_SUM)); + } + else + { + + } +} + +/* +* ȡָгABLгµǰн·Ϣ +* ˵ const UINT16 wTrainId, гID +* ֵ ָгABLгµǰн·Ϣ +*/ +ABLTrainRelAllRouteStru* GetTrainAblRelAllRouteData(const UINT16 wTrainId) +{ + ABLTrainRelAllRouteStru* chRetValablTrainRelAllRouteData = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetValablTrainRelAllRouteData = gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblAllRouteData; + } + else + { + chRetValablTrainRelAllRouteData = NULL; + } + + return chRetValablTrainRelAllRouteData; +} + +/* +* ָгNVRAMλñʶ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chState NVRAMλñʶ +* ֵ +* BY CGH 20240417 +*/ +void SetTrainNvramPosFlag(const UINT16 wTrainId, const UINT8 chState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wBufIndex) && ((TRAIN_NVRAM_POS_FLAG_YES == chState) || (TRAIN_NVRAM_POS_FLAG_NO == chState))) + { + gstTrainInfo[wBufIndex].chNvramPosFlag = chState; + } + else + { + ; + } +} + +/* +* ȡָгNVRAMλñʶ +* ˵ const UINT16 wTrainId, гID +* ֵ гNVRAMλñʶ +* BY CGH 20240417 +*/ +UINT8 GetTrainNvramPosFlag(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_NVRAM_POS_FLAG_YES; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chNvramPosFlag; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгǰλϢ +* ˵ const UINT16 wTrainId, гID +* HeadTrainLocStru strHeadTrainLocData ǰλϢ +* ֵ void +* by cgh 20240606 +*/ +void SetTrainHeadTrainLocData(const UINT16 wTrainId,HeadTrainLocStru strHeadTrainLocData) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetTrainBufIndex(wTrainId); + + if ((0U < bufIndex) && (TRAIN_SUM_MAX > bufIndex)) + { + (void)CommonMemCpy((void*)&gstTrainInfo[bufIndex].strHeadTrainLocData, (UINT32)sizeof(HeadTrainLocStru), (void*)&strHeadTrainLocData, (UINT32)sizeof(HeadTrainLocStru)); + } + else + { + ; /**/ + } +} + +/* +* ȡָгǰλϢ +* ˵ const UINT16 wTrainId, гID +* ֵ NULL ȡʧ +* NULL ǰλϢ +* by cgh 20240606 +*/ +HeadTrainLocStru GetTrainHeadTrainLocData(const UINT16 wTrainId) +{ + HeadTrainLocStru strRetVal = { 0U }; + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetTrainBufIndex(wTrainId); + + if ((0U < bufIndex) && (TRAIN_SUM_MAX > bufIndex)) + { + (void)CommonMemCpy((void*)&strRetVal, (UINT32)sizeof(HeadTrainLocStru), (void*)&gstTrainInfo[bufIndex].strHeadTrainLocData, (UINT32)sizeof(HeadTrainLocStru)); + } + else + { + ; /**/ + } + + return strRetVal; +} + +/* +* ȡгITE㱨 +* ˵ const UINT16 wTrainId, гID +* HeadTrainLocStru strHeadTrainLocData ITE㱨 +* ֵ void +* by cgh 20240606 +*/ +TrainIteDataStruct* GetTrainIteData(const UINT16 wTrainId) +{ + TrainIteDataStruct* tempTrainIteData = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + tempTrainIteData = gstTrainInfo[wBufIndex].szTrainIteData; + } + else + { + tempTrainIteData = NULL; + } + + return tempTrainIteData; +} + +/* +* гITEݡͷlinkID +* ˵const UINT16 wTrainId гID +* const UINT16 wIteLogId ITE߼ID +* const UINT16 wHeadLinkId гͷlinkID +* ֵ +* Created By LQ 2024.06.06 +*/ +void SetIteTrainHeadLinkId(const UINT16 wTrainId, const UINT16 wIteLogId, const UINT16 wHeadLinkId) +{ + UINT16 wTrainIndex = 0U; /*гID*/ + UINT16 wIteIndex = 0U; /*ITEID*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wTrainIndex) && (0U < wIteLogId) && (TRAIN_INC_ITE_SUM_MAX >= wIteLogId)) + { + wIteIndex = wIteLogId - 1U; + gstTrainInfo[wTrainIndex].szTrainIteData[wIteIndex].wTrainHeadLinkId = wHeadLinkId; + } + else + { + /*ηǷ*/ + } +} + +/* +* гITEݡͷlinkƫ +* ˵const UINT16 wTrainId гID +* const UINT16 wIteLogId ITE߼ID +* const UINT32 dwHeadLinkOffset гͷlinkƫ +* ֵ +* Created By LQ 2024.06.06 +*/ +void SetIteTrainHeadLinkOffset(const UINT16 wTrainId, const UINT16 wIteLogId, const UINT32 dwHeadLinkOffset) +{ + UINT16 wTrainIndex = 0U; /*гID*/ + UINT16 wIteIndex = 0U; /*ITEID*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wTrainIndex) && (0U < wIteLogId) && (TRAIN_INC_ITE_SUM_MAX >= wIteLogId)) + { + wIteIndex = wIteLogId - 1U; + gstTrainInfo[wTrainIndex].szTrainIteData[wIteIndex].dwTrainHeadLinkOffset = dwHeadLinkOffset; + } + else + { + /*ηǷ*/ + } +} + +/* +* гITEݡβlinkID +* ˵const UINT16 wTrainId гID +* const UINT16 wIteLogId ITE߼ID +* const UINT16 wTailLinkId гβlinkID +* ֵ +* Created By LQ 2024.06.06 +*/ +void SetIteTrainTailLinkId(const UINT16 wTrainId, const UINT16 wIteLogId, const UINT16 wTailLinkId) +{ + UINT16 wTrainIndex = 0U; /*гID*/ + UINT16 wIteIndex = 0U; /*ITEID*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wTrainIndex) && (0U < wIteLogId) && (TRAIN_INC_ITE_SUM_MAX >= wIteLogId)) + { + wIteIndex = wIteLogId - 1U; + gstTrainInfo[wTrainIndex].szTrainIteData[wIteIndex].wTrainTailLinkId = wTailLinkId; + } + else + { + /*ηǷ*/ + } +} + +/* +* гITEݡβlinkƫ +* ˵const UINT16 wTrainId гID +* const UINT16 wIteLogId ITE߼ID +* const UINT32 dwTailLinkOffset гβlinkƫ +* ֵ +* Created By LQ 2024.06.06 +*/ +void SetIteTrainTailLinkOffset(const UINT16 wTrainId, const UINT16 wIteLogId, const UINT32 dwTailLinkOffset) +{ + UINT16 wTrainIndex = 0U; /*гID*/ + UINT16 wIteIndex = 0U; /*ITEID*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wTrainIndex) && (0U < wIteLogId) && (TRAIN_INC_ITE_SUM_MAX >= wIteLogId)) + { + wIteIndex = wIteLogId - 1U; + gstTrainInfo[wTrainIndex].szTrainIteData[wIteIndex].dwTrainTailLinkOffset = dwTailLinkOffset; + } + else + { + /*ηǷ*/ + } +} + +/* +* гITEݡг +* ˵const UINT16 wTrainId гID +* const UINT16 wIteLogId ITE߼ID +* const UINT8 cTrainDir г +* ֵ +* Created By LQ 2024.06.06 +*/ +void SetIteTrainDir(const UINT16 wTrainId, const UINT16 wIteLogId, const UINT8 cTrainDir) +{ + UINT16 wTrainIndex = 0U; /*гID*/ + UINT16 wIteIndex = 0U; /*ITEID*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wTrainIndex) && (0U < wIteLogId) && (TRAIN_INC_ITE_SUM_MAX >= wIteLogId)) + { + wIteIndex = wIteLogId - 1U; + gstTrainInfo[wTrainIndex].szTrainIteData[wIteIndex].cTrainDir = cTrainDir; + } + else + { + /*ηǷ*/ + } +} + +/* +* гITEݡλǰ +* ˵const UINT16 wTrainId гID +* const UINT16 wIteLogId ITE߼ID +* const UINT16 wForWardOffset λǰ +* ֵ +* Created By LQ 2024.06.06 +*/ +void SetIteTrainForWardOffset(const UINT16 wTrainId, const UINT16 wIteLogId, const UINT16 wForWardOffset) +{ + UINT16 wTrainIndex = 0U; /*гID*/ + UINT16 wIteIndex = 0U; /*ITEID*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wTrainIndex) && (0U < wIteLogId) && (TRAIN_INC_ITE_SUM_MAX >= wIteLogId)) + { + wIteIndex = wIteLogId - 1U; + gstTrainInfo[wTrainIndex].szTrainIteData[wIteIndex].wForWardOffset = wForWardOffset; + } + else + { + /*ηǷ*/ + } +} + +/* +* гITEݡλ +* ˵const UINT16 wTrainId гID +* const UINT16 wIteLogId ITE߼ID +* const UINT16 wBackOffset λ +* ֵ +* Created By LQ 2024.06.06 +*/ +void SetIteTrainBackOffset(const UINT16 wTrainId, const UINT16 wIteLogId, const UINT16 wBackOffset) +{ + UINT16 wTrainIndex = 0U; /*гID*/ + UINT16 wIteIndex = 0U; /*ITEID*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wTrainIndex) && (0U < wIteLogId) && (TRAIN_INC_ITE_SUM_MAX >= wIteLogId)) + { + wIteIndex = wIteLogId - 1U; + gstTrainInfo[wTrainIndex].szTrainIteData[wIteIndex].wBackOffset = wBackOffset; + } + else + { + /*ηǷ*/ + } +} + +/* +* ָгǰźŻID +* ˵ const UINT16 wTrainId, гID +* const UINT16 wTrainSigId ǰźŻID +* ֵ +* BY CGH 20240710 +*/ +void SetTrainHeadSigId(const UINT16 wTrainId, const UINT16 wTrainSigId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].wTrainHeadSigId = wTrainSigId; + } + else + { + ; + } +} + +/* +* ȡָгǰźŻID +* ˵ const UINT16 wTrainId, гID +* ֵ гǰźŻID +* BY CGH 20240710 +*/ +UINT16 GetTrainHeadSigId(const UINT16 wTrainId) +{ + UINT16 wRetVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wTrainHeadSigId; + } + else + { + ; + } + + return wRetVal; +} + +/* +* ָгλ÷·־ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chFlag гλ÷·־ +* ֵ +* BY CGH 20240711 +*/ +void SetTrainLocReverseRouteFlag(const UINT16 wTrainId, const UINT8 chFlag) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wBufIndex) && ((TRAIN_LOC_REV_ROUTE_FLAG_NONE == chFlag) + || (TRAIN_LOC_REV_ROUTE_FLAG_NO == chFlag) || (TRAIN_LOC_REV_ROUTE_FLAG_YES == chFlag))) + { + gstTrainInfo[wBufIndex].chTrainLocReverseRouteFlag = chFlag; + } + else + { + ; + } +} + +/* +* ȡָгλ÷·־ +* ˵ const UINT16 wTrainId, гID +* ֵ гλ÷·־ +* BY CGH 20240711 +*/ +UINT8 GetTrainLocReverseRouteFlag(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_LOC_REV_ROUTE_FLAG_YES; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chTrainLocReverseRouteFlag; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָAblгСȫָͷз +* ˵ const UINT16 wTrainId, гID +* const UINT8 chTrainDir гз +* ֵ : +* by cgh 20240711 +*/ +void SetAblTrainDir(const UINT16 wTrainId, const UINT8 chTrainDir) +{ + UINT16 wBufIndex = 0U; + UINT8 chDir = 0u; + UINT8 chLinkLogicDirUpAndDown = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((TRAIN_DIR_UP == chTrainDir) || (TRAIN_DIR_DOWN == chTrainDir)) + { + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + + if (chLinkLogicDirUpAndDown == chTrainDir) + { + chDir = DIR_CONVERT; + } + else + { + chDir = DIR_SAME; + } + + /*гСȫ˵з*/ + gstTrainInfo[wBufIndex].chAblTrainDir = chDir; + } + else + { + ; + } + } + else + { + ; + } +} + +/* +* ָAblгȫǰLinkId +* ˵ const UINT16 wTrainId, гID +* const UINT8 wTrainHeadLinkId гȫǰLk +* ֵ : +* by cgh 20240711 +*/ +void SetAblTrainMaxHeadLink(const UINT16 wTrainId, const UINT16 wTrainHeadLinkId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (UINT16_MAX != wTrainHeadLinkId) + { + gstTrainInfo[wBufIndex].wAblTrainMaxHeadLink = wTrainHeadLinkId; + } + else + { + ; + } + } + else + { + ; + } +} + +/* +* ָAblгȫǰLinkId Off +* ˵ const UINT16 wTrainId, гID +* const UINT8 dwTrainHeadOff гȫǰOff +* ֵ : +* by cgh 20240711 +*/ +void SetAblTrainMaxHeadOffset(const UINT16 wTrainId, const UINT32 dwTrainHeadOff) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].dwAblTrainMaxHeadOffset = dwTrainHeadOff; + } + else + { + ; + } +} + +/* +* ָAblгСȫLinkId +* ˵ const UINT16 wTrainId, гID +* const UINT8 wTrainTailLinkId гȫLk +* ֵ : +* by cgh 20240711 +*/ +void SetAblTrainMinTailLink(const UINT16 wTrainId, const UINT16 wTrainTailLinkId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if (UINT16_MAX != wTrainTailLinkId) + { + gstTrainInfo[wBufIndex].wAblTrainMinTailLink = wTrainTailLinkId; + } + else + { + ; + } + } + else + { + ; + } +} + +/* +* ָAblгСȫLinkId Off +* ˵ const UINT16 wTrainId, гID +* const UINT8 dwTrainTailOff гȫOff +* ֵ : +* by cgh 20240711 +*/ +void SetAblTrainMinTailOffset(const UINT16 wTrainId, const UINT32 dwTrainTailOff) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].dwAblTrainMinTailOffset = dwTrainTailOff; + } + else + { + ; + } +} + +/* +* ȡָAblгзСȫˣ +* ˵ const UINT16 wTrainId, гID +* ֵ 0x55: ߼ͬ +* 0xAA: ߼ +* 0xFF: Ч +* by cgh 20240711 +*/ +UINT8 GetAblTrainDir(const UINT16 wTrainId) +{ + UINT8 chRetVal = DIR_INVALID; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chAblTrainDir; + } + else + { + chRetVal = DIR_INVALID; + } + + return chRetVal; +} + +/* +* ȡָAblгȫǰlinkId +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkID +* by cgh 20240711 +*/ +UINT16 GetAblTrainMaxHeadLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wAblTrainMaxHeadLink; + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ȡָAblгСȫlinkId +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkID +* by cgh 20240711 +*/ +UINT16 GetAblTrainMinTailLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wAblTrainMinTailLink; + } + else + { + wRetVal = CI_ERROR; + } + + return wRetVal; +} + +/* +* ȡָAblгȫǰƫ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkƫ +* by cgh 20240711 +*/ +UINT32 GetAblTrainMaxHeadOffset(const UINT16 wTrainId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwAblTrainMaxHeadOffset; + } + else + { + dwRetVal = UINT32_MAX; + } + + return dwRetVal; +} + +/* +* ȡָAblгСȫƫ +* ˵ const UINT16 wTrainId, гID +* ֵ 0: ȡʧ +* linkƫ +* by cgh 20240711 +*/ +UINT32 GetAblTrainMinTailOffset(const UINT16 wTrainId) +{ + UINT32 dwRetVal = UINT32_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwAblTrainMinTailOffset; + } + else + { + dwRetVal = UINT32_MAX; + } + + return dwRetVal; +} + +/* +* ָгǰID +* ˵ const UINT16 wTrainId, гID +* const UINT16 wHeadTrainId ǰID +* ֵ +* BY CGH 20240710 +*/ +void SetTrainHeadTrainId(const UINT16 wTrainId, const UINT16 wHeadTrainId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + gstTrainInfo[wBufIndex].wTrainHeadTrainId = wHeadTrainId; + } + else + { + ; + } +} + +/* +* ȡָгǰID +* ˵ const UINT16 wTrainId, гID +* ֵ гǰID +* BY CGH 20240710 +*/ +UINT16 GetTrainHeadTrainId(const UINT16 wTrainId) +{ + UINT16 wRetVal = TRAIN_ID_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wTrainHeadTrainId; + } + else + { + ; + } + + return wRetVal; +} + +/* +* гǷCT +* ˵const UINT16 wTrainId гID0x14 +* ֵCI_SUCCESS 1 CT +* CI_ERROR 0 CT +* Created By LQ 2024.07.25 +*/ +UINT8 CheckTrainRelCtEnvelope(const UINT16 wTrainId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wBufIndex = 0U; + UINT8 cEnvelopeNum = 0U; /*гİ*/ + UINT16 szEnvelopeId[TRAIN_REL_ENVELOPE_SUM_MAX] = { 0U }; /*гİID*/ + const EnvelopeStruct* pstrEnvelop = NULL; /*гİṹ*/ + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + cEnvelopeNum = elm_GetTrainRelELM(wTrainId, szEnvelopeId); + if (1U == cEnvelopeNum) + { + pstrEnvelop = elm_GetEnvelopeInfoByID(szEnvelopeId[0U]); + if (NULL != pstrEnvelop) + { + if (TYPE_CT_ENVELOPE == pstrEnvelop->envelopeType) + { + cRetVal = CI_SUCCESS; /*ΨһCT磬سɹ*/ + } + else + { + /*CT磬ʧ*/ + } + } + else + { + /*ȡʧܣʧ*/ + } + } + else + { + /*粻Ψһʧ*/ + } + } + else + { + /*гIDǷʧ*/ + } + + return cRetVal; +} + + +/* +* ָABLгͷ߼ +* ˵ const UINT16 wTrainId, гID +* const UINT16 logsecId ߼ID +* ֵ void +*/ +void SetTrainAblMaxHeadLogId(const UINT16 wTrainId, const UINT16 logsecId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && (0U != logsecId) && (LOGIC_SECTION_SUM_MAX > logsecId)) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblMaxHeadLogSecId = logsecId; + } + else + { + ; /**/ + } +} + +/* +* ȡָABLгͷ߼ +* ˵ const UINT16 wTrainId, гID +* ֵ 0ȡʧ +* >0߼ID +*/ +UINT16 GetTrainAblMaxHeadLogId(const UINT16 wTrainId) +{ + UINT16 retVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + retVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblMaxHeadLogSecId; + } + else + { + ; /**/ + } + return retVal; + +} + + + +/* +* ָгABLг߼ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelXianSuNum ABLг߼ +* const UINT16* chAblOcculogIdbuff ABLг߼ +* ֵ +*/ +void SetTrainAblOcculogData(const UINT16 wTrainId, const UINT8 chAblOcculogNum,const UINT16* chAblOcculogIdbuff) +{ + UINT16 wBufIndex = 0U; + UINT8 i = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wBufIndex) && (NULL != chAblOcculogIdbuff) && (TRAIN_ABL_LOGSEC_SUM > chAblOcculogNum)) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblOccuLogSeNum = chAblOcculogNum; + for (i = 0U; i < chAblOcculogNum; i++) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblOccuLogSecIdBuff[i] = chAblOcculogIdbuff[i]; + } + + } + else + { + ; /**/ + } +} + +/* +* ȡָABLг߼ +* ˵ const UINT16 wTrainId, гID +* ֵ 0ȡʧ +* >0߼ +*/ +UINT8 GetTrainAblOcculogIdSum(const UINT16 wTrainId) +{ + UINT8 retVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + retVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblOccuLogSeNum; + } + else + { + ; /**/ + } + return retVal; + +} + + +/* +* ȡָABLг߼ID +* ˵ const UINT16 wTrainId, гID +* ֵ NULLȡʧ +* !=NULL߼ID +*/ +UINT16* GetTrainAblOcculogIdBuff(const UINT16 wTrainId) +{ + UINT16* retVal = NULL; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + retVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblOccuLogSecIdBuff; + } + else + { + ; /**/ + } + return retVal; + +} + + +/* +* ָABLгԶ˿߼ +* ˵ const UINT16 wTrainId, гID +* const UINT16 logsecId ߼ID +* ֵ void +*/ +void SetTrainAblNoOccuFarLogId(const UINT16 wTrainId, const UINT16 logsecId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((0U != logsecId) && (LOGIC_SECTION_SUM_MAX > logsecId)) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblNoOccuFarLogId = logsecId; + } + else if (UINT16_MAX == logsecId) + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblNoOccuFarLogId = UINT16_MAX; + } + else + { + gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblNoOccuFarLogId = 0U; + } + + } + else + { + ; /**/ + } +} + +/* +* ȡָABLгԶ˿߼ +* ˵ const UINT16 wTrainId, гID +* ֵ 0ȡʧ +* >0߼ID +*/ +UINT16 GetTrainAblNoOccuFarLogId(const UINT16 wTrainId) +{ + UINT16 retVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + retVal = gstTrainInfo[wBufIndex].strAblTrainNeedData.wAblNoOccuFarLogId; + } + else + { + ; /**/ + } + return retVal; + +} + +/* +* ָгǰɸͨ־ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chFlag гǰɸͨ־ +* ֵ +* BY CGH 20240815 +*/ +void SetTrainVirHeadScreenPassFlag(const UINT16 wTrainId, const UINT8 chFlag) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wBufIndex) && ((TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chFlag) || (TRAIN_VIR_SCREEN_PASS_FLAG_INVALID == chFlag))) + { + gstTrainInfo[wBufIndex].chVirHeadScreenPassFlag = chFlag; + } + else + { + ; + } +} + +/* +* ȡָгǰɸͨ־ +* ˵ const UINT16 wTrainId, гID +* ֵ гǰɸͨ־ +* BY CGH 20240815 +*/ +UINT8 GetTrainVirHeadScreenPassFlag(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chVirHeadScreenPassFlag; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгɸͨ־ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chFlag гɸͨ־ +* ֵ +* BY CGH 20240815 +*/ +void SetTrainVirTailScreenPassFlag(const UINT16 wTrainId, const UINT8 chFlag) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if ((TRAIN_SUM_MAX > wBufIndex) && ((TRAIN_VIR_SCREEN_PASS_FLAG_VALID == chFlag) || (TRAIN_VIR_SCREEN_PASS_FLAG_INVALID == chFlag))) + { + gstTrainInfo[wBufIndex].chVirTailScreenPassFlag = chFlag; + } + else + { + ; + } +} + +/* +* ȡָгɸͨ־ +* ˵ const UINT16 wTrainId, гID +* ֵ гɸͨ־ +* BY CGH 20240815 +*/ +UINT8 GetTrainVirTailScreenPassFlag(const UINT16 wTrainId) +{ + UINT8 chRetVal = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].chVirTailScreenPassFlag; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгʻмLINK +* ˵ const UINT16 wTrainId, гID +* const UINT16 гʻмLINK +* ֵ +* BY CGH 20240815 +*/ +void SetTrainEnterLjkLinkId(const UINT16 wTrainId, const UINT16 wLinkId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + if (0U != wLinkId) + { + if (0U == gstTrainInfo[wBufIndex].wEnterLjkLinkId) + { + gstTrainInfo[wBufIndex].wEnterLjkLinkId = wLinkId; + } + else + { + ; /*Ѿвٸ*/ + } + } + else + { + gstTrainInfo[wBufIndex].wEnterLjkLinkId = 0U; + } + } + else + { + ; + } +} + +/* +* ȡָгʻмLINK +* ˵ const UINT16 wTrainId, гID +* ֵ гʻмLINK +* BY CGH 20240815 +*/ +UINT16 GetTrainEnterLjkLinkId(const UINT16 wTrainId) +{ + UINT16 chRetVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + chRetVal = gstTrainInfo[wBufIndex].wEnterLjkLinkId; + } + else + { + ; + } + + return chRetVal; +} + +/* +* ָгȫʻмں +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwCycNum гȫʻмں +* ֵ +* BY CGH 20240815 +*/ +void SetTrainFullEnterLjkCycNum(const UINT16 wTrainId, const UINT32 dwCycNum) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + if (0U != dwCycNum) + { + if (0U == gstTrainInfo[wBufIndex].dwTrainFullEnterLjkCycNum) + { + gstTrainInfo[wBufIndex].dwTrainFullEnterLjkCycNum = dwCycNum; + } + else + { + ; /*0˵Ѿù*/ + } + } + else + { + gstTrainInfo[wBufIndex].dwTrainFullEnterLjkCycNum = 0U; + } + } + else + { + ; + } +} + +/* +* ȡָгȫʻмں +* ˵ const UINT16 wTrainId, гID +* ֵ гȫʻмں +* BY CGH 20240815 +*/ +UINT32 GetTrainFullEnterLjkCycNum(const UINT16 wTrainId) +{ + UINT32 dwRetVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwTrainFullEnterLjkCycNum; + } + else + { + ; + } + + return dwRetVal; +} + +/* +* ָгλüල״̬ +* ˵const UINT16 wTrainId гID +* const UINT8 cMonitorState ල״̬ +* ֵ +* Created By LQ 2024.08.15 +*/ +void SetTrainPosMonitorState(const UINT16 wTrainId, const UINT8 cMonitorState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((TRAIN_POS_MONITOR_VALID == cMonitorState) || (TRAIN_POS_MONITOR_INVALID == cMonitorState) || (TRAIN_POS_MONITOR_DIFF == cMonitorState)) + { + gstTrainInfo[wBufIndex].chTrainPosMonitorState = cMonitorState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָгλüල״̬ +* ˵const UINT16 wTrainId гID +* ֵ0x55 λüලЧ +* 0xAA λüලЧ +* 0xCC λüලһ +* Created By LQ 2024.08.15 +*/ +UINT8 GetTrainPosMonitorState(const UINT16 wTrainId) +{ + UINT8 cRetVal = TRAIN_POS_MONITOR_INVALID; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + cRetVal = gstTrainInfo[wBufIndex].chTrainPosMonitorState; + } + else + { + /*Ĭֵ*/ + } + + return cRetVal; +} + +/* +* ָгλüලlink +* ˵const UINT16 wTrainId гID +* const UINT16 wLinkId link ID +* ֵ +* Created By LQ 2024.08.15 +*/ +void SetTrainPosMonitorInLink(const UINT16 wTrainId, const UINT16 wLinkId) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + if (LINK_SUM_MAX > wLinkId) + { + gstTrainInfo[wBufIndex].wTrainPosMonitorInLink = wLinkId; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָгλüලlink +* ˵const UINT16 wTrainId гID +* ֵ1300 ȡʧ +* λüලlink +* Created By LQ 2024.08.15 +*/ +UINT16 GetTrainPosMonitorInLink(const UINT16 wTrainId) +{ + UINT16 wRetVal = LINK_SUM_MAX; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + wRetVal = gstTrainInfo[wBufIndex].wTrainPosMonitorInLink; + } + else + { + /*Ĭֵ*/ + } + + return wRetVal; +} + +/* +* гλüල +* ˵ +* ֵ +* Created By LQ 2024.08.15 +*/ +void TrainPosMonitorProc(void) +{ + UINT8 cTrainIndex = 0U; + UINT16 wTrainId = 0U; + UINT8 cLocalCiType = 0U; + UINT16 wTrainPosMonitorInLink = 0U; /*гλüල״̬Чʱlink*/ + UINT8 cFuncRet = CI_ERROR; + UINT16 wLinkRelPhySecId = 0U; /*link*/ + UINT16* pPhySecIncAxleSecId = NULL; /*ΰļ*/ + UINT8 cPreMonitorState = TRAIN_POS_MONITOR_INVALID; /*һгλüල״̬*/ + UINT8 cMonitorFailState = TRAIN_POS_MONITOR_INVALID; /*ʧܺҪõļල״̬*/ + + for (cTrainIndex = 0U; cTrainIndex < TRAIN_SUM_MAX; cTrainIndex++) + { + wTrainId = GetTrainId(cTrainIndex); + + /*ݿͣгλüල*/ + cLocalCiType = GetLocalCiType(); + if ((CI_TYPE_ZX == cLocalCiType) || (CI_TYPE_SCX == cLocalCiType)) + { + /****** гλüල״̬ǷЧ *******/ + cFuncRet = ZXorSCXTrainPosMonitorCheck(wTrainId, &wTrainPosMonitorInLink, &cMonitorFailState); + } + else + { + /****** гλüල״̬ǷЧ *******/ + cFuncRet = CLDTrainPosMonitorCheck(wTrainId, &wTrainPosMonitorInLink, &cMonitorFailState); + } + + /****** ݼüල״̬ *******/ + if (CI_SUCCESS == cFuncRet) + { + /*1.üλüලЧгID*/ + wLinkRelPhySecId = GetLinkRelatedPhySec(wTrainPosMonitorInLink); + pPhySecIncAxleSecId = GetPAxisSectionIdBuf(wLinkRelPhySecId); + if (NULL != pPhySecIncAxleSecId) + { + SetAxisPosMonitorTrainId(pPhySecIncAxleSecId[0], wTrainId); /*߻ѹΪ޲Σȡ׸*/ + } + else + { + /*ȡʧܣ*/ + } + + /*2.гλüල־Ч*/ + SetTrainPosMonitorState(wTrainId, TRAIN_POS_MONITOR_VALID); + SetTrainPosMonitorInLink(wTrainId, wTrainPosMonitorInLink); + } + else + { + cPreMonitorState = GetTrainPosMonitorState(wTrainId); /*ȡһгλüල״̬*/ + + /*1.λüලЧгIDڸlinkǰȡʱλüලЧlink*/ + wTrainPosMonitorInLink = GetTrainPosMonitorInLink(wTrainId); /*ȡгλüල״̬Чʱlink*/ + wLinkRelPhySecId = GetLinkRelatedPhySec(wTrainPosMonitorInLink); + pPhySecIncAxleSecId = GetPAxisSectionIdBuf(wLinkRelPhySecId); + if (NULL != pPhySecIncAxleSecId) + { + SetAxisPosMonitorTrainId(pPhySecIncAxleSecId[0], 0U); /*߻ѹΪ޲Σȡ׸*/ + } + else + { + /*δгID*/ + } + + /*2.гλüල־*/ + if ((TRAIN_POS_MONITOR_DIFF == cMonitorFailState) || (TRAIN_POS_MONITOR_DIFF == cPreMonitorState)) + { + SetTrainPosMonitorState(wTrainId, TRAIN_POS_MONITOR_DIFF); /*гȫڼලlinkһڼල״̬λòһ£üලλòһ*/ + } + else + { + SetTrainPosMonitorState(wTrainId, TRAIN_POS_MONITOR_INVALID); /*гȫڼලlinküලЧ*/ + } + + SetTrainPosMonitorInLink(wTrainId, 0U); /*ලlink*/ + + /*3.гǰɸѡ־*/ + if (TRAIN_POS_MONITOR_VALID == cPreMonitorState) + { + /*гλüල״̬ЧЧгǰɸѡ־*/ + SetTrainVirHeadScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainVirTailScreenPassFlag(wTrainId, TRAIN_VIR_SCREEN_PASS_FLAG_INVALID); + SetTrainEnterLjkLinkId(wTrainId, 0U); + SetTrainFullEnterLjkCycNum(wTrainId, 0U); + } + else + { + /**/ + } + } + } +} + +/* +* гλüලͨ +* ˵const UINT16 wTrainId гID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.18 +*/ +UINT8 TrainPosMonitorCommonCheck(const UINT16 wTrainId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wTrainIndex = 0U; + UINT16 wTrainPosMonitorInLink = 0U; /*ලЧʱгlink*/ + UINT16 wMinHeadLink = 0U; /*гСǰlink*/ + UINT16 wMaxTailLink = 0U; /*гlink*/ + UINT8 cSleepWakeAttr = 0U; /*߻ѹ*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wTrainIndex) + { + wTrainPosMonitorInLink = GetTrainPosMonitorInLink(wTrainId); /*ȡгλüල״̬Чʱlink*/ + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + wMaxTailLink = GetTrainMaxTailLink(wTrainId); + cSleepWakeAttr = IsLinkSwTrack(wMinHeadLink); /*ȡгlink߻*/ + + if ((wTrainPosMonitorInLink == wMinHeadLink) && (wMinHeadLink == wMaxTailLink) && (CI_SUCCESS == cSleepWakeAttr)) + { + cRetVal = CI_SUCCESS; /*г߻ѹСǰʹδԽ߻ѹ죬سɹʱѱ֤гͨټǷͣ׼ͣȣ*/ + } + else + { + /*г߻ѹСǰ/Խ߻ѹ죬ʧ*/ + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* гλüලʼ +* ˵const UINT16 wTrainId гID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.21 +*/ +UINT8 TrainPosMonitorBeginCheck(const UINT16 wTrainId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wTrainIndex = 0U; + UINT16 wMaxHeadLink = 0U; /*гǰlink*/ + UINT16 wMinTailLink = 0U; /*гСlink*/ + UINT16 wMaxHeadBelongCiId = 0U; /*ǰlinkCI*/ + UINT16 wMinTailBelongCiId = 0U; /*СlinkCI*/ + UINT8 cLocalCiId = 0U; + UINT8 cSleepWakeAttr = 0U; /*߻ѹ*/ + UINT8 cStopSteadyState = TRAIN_SS_NO; /*ͣ׼ͣ״̬*/ + UINT8 cUseNvramFlag = TRAIN_NVRAM_POS_FLAG_YES; /*ǷʹNVRAM־*/ + UINT8 cVirHeadScreenState = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гǰɸ־*/ + UINT8 cVirTailScreenState = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гɸ־*/ + EnvelopeStruct* pTrainEnvelopeData = NULL; /*г*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wTrainIndex) + { + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); /*ȡгλ*/ + wMinTailLink = GetTrainMinTailLink(wTrainId); + + cLocalCiId = GetSystemParaLocalCiId(); + wMaxHeadBelongCiId = GetLinkManageTiocById(wMaxHeadLink); + wMinTailBelongCiId = GetLinkManageTiocById(wMinTailLink); + + if ((0U != cLocalCiId) && (cLocalCiId == (UINT8)wMaxHeadBelongCiId) && (cLocalCiId == (UINT8)wMinTailBelongCiId)) + { + cSleepWakeAttr = IsLinkSwTrack(wMaxHeadLink); /*ȡгlink߻*/ + + if ((wMaxHeadLink == wMinTailLink) && (CI_SUCCESS == cSleepWakeAttr)) + { + /*гȫ߻ѹ죬гͣ׼ͣδʹNVRAM*/ + cStopSteadyState = GetTrainStopSteadyState(wTrainId); /*ȡгͣ״̬*/ + cUseNvramFlag = GetTrainNvramPosFlag(wTrainId); /*ʹNVRAM־*/ + + if ((TRAIN_SS_YES == cStopSteadyState) && (TRAIN_NVRAM_POS_FLAG_NO == cUseNvramFlag)) + { + /*гͣ׼ͣ׼δʹNVRAMгǰɸͺɸ״̬*/ + pTrainEnvelopeData = elm_GetEnvelopeInfoByTrainID((wTrainId & 0xFFU)); /*ȡгڰ*/ + if (NULL != pTrainEnvelopeData) + { + cVirHeadScreenState = GetTrainVirHeadScreenPassFlag(wTrainId); + cVirTailScreenState = GetTrainVirTailScreenPassFlag(wTrainId); + + if (((0U == pTrainEnvelopeData->headTrainID) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == cVirHeadScreenState)) + && ((0U == pTrainEnvelopeData->tailTrainID) || (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == cVirTailScreenState))) + { + cRetVal = CI_SUCCESS; /*ǰɸͺɸЧسɹ*/ + } + else + { + /*ǰɸ/ɸЧʧ*/ + } + } + else + { + /*ȡʧܣʧ*/ + } + } + else + { + /*δͣ׼ͣ׼ʹNVRAMʧ*/ + } + } + else + { + /*гδȫ߻ѹ죬ʧ*/ + } + } + else + { + /*гδȫڱලʧ*/ + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* гλüල״̬飨߻Գߣ +* ˵const UINT16 wTrainId гID +* UINT16* pMonitorLinkId ලЧʱгlinkΣ +* UINT8* pMonitorFailState ලʧܺҪõ״̬Σ +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.21 +*/ +UINT8 ZXorSCXTrainPosMonitorCheck(const UINT16 wTrainId, UINT16* pMonitorLinkId, UINT8* pMonitorFailState) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wTrainIndex = 0U; + UINT8 cTransState = TRAIN_COMM_STATE_BAD; /*гͨ״̬*/ + UINT8 cFuncRet = CI_ERROR; + UINT8 cMonitorState = TRAIN_POS_MONITOR_INVALID; /*гλüල״̬*/ + UINT16 wMaxHeadLink = 0U; /*гǰlink*/ + UINT16 wMinHeadLink = 0U; /*гСǰlink*/ + UINT16 wMaxTailLink = 0U; /*гlink*/ + UINT16 wMinTailLink = 0U; /*гСlink*/ + UINT16 wMinHeadBelongCiId = 0U; /*СǰlinkCI*/ + UINT16 wMaxTailBelongCiId = 0U; /*linkCI*/ + UINT8 cLocalCiId = 0U; + UINT16 wTrainPosMonitorInLink = 0U; /*гλüල״̬Чʱlink*/ + UINT8 cOrgAxleSecOccState = AXIS_SECTION_OCCUPY_YES; /*ڼβɼռ״̬*/ + UINT8 cTmlAxleSecOccState = AXIS_SECTION_OCCUPY_YES; /*յڼβɼռ״̬*/ + UINT8 cStopSteadyState = TRAIN_SS_NO; /*ͣ׼ͣ״̬*/ + UINT8 cMonitorFailState = TRAIN_POS_MONITOR_INVALID; /*ʧʱгλüල״̬*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wTrainIndex) && (NULL != pMonitorLinkId) && (NULL != pMonitorFailState)) + { + /****** гλüල״̬ǷЧ *******/ + cMonitorState = GetTrainPosMonitorState(wTrainId); /*ȡгλüල״̬*/ + cTransState = GetTrainTransitmitStat(wTrainId); /*ȡгͨ״̬*/ + if (TRAIN_COMM_STATE_GOOD == cTransState) + { + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); /*ȡгλϢ*/ + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + wMaxTailLink = GetTrainMaxTailLink(wTrainId); + wMinTailLink = GetTrainMinTailLink(wTrainId); + wTrainPosMonitorInLink = GetTrainPosMonitorInLink(wTrainId); /*ȡгλüල״̬Чʱlink*/ + + if (TRAIN_POS_MONITOR_VALID == cMonitorState) + { + cLocalCiId = GetSystemParaLocalCiId(); + wMinHeadBelongCiId = GetLinkManageTiocById(wMinHeadLink); + wMaxTailBelongCiId = GetLinkManageTiocById(wMaxTailLink); + + if ((wMaxHeadLink != wTrainPosMonitorInLink) && (wMinHeadLink != wTrainPosMonitorInLink) && (wMaxTailLink != wTrainPosMonitorInLink) && (wMinTailLink != wTrainPosMonitorInLink)) + { + cMonitorFailState = TRAIN_POS_MONITOR_DIFF; /*гȫԭlinkලλòһ*/ + cFuncRet = CI_ERROR; + } + else if ((0U != cLocalCiId) && (cLocalCiId == (UINT8)wMinHeadBelongCiId) && (cLocalCiId == (UINT8)wMaxTailBelongCiId)) + { + cFuncRet = TrainPosMonitorCommonCheck(wTrainId); /*гڱʼලгλüලͨ*/ + } + else + { + cMonitorFailState = TRAIN_POS_MONITOR_INVALID; /*гڱලλЧ*/ + cFuncRet = CI_ERROR; + } + } + else + { + cFuncRet = TrainPosMonitorBeginCheck(wTrainId); /*гδʼලгλüලʼ*/ + } + + if (CI_SUCCESS == cFuncRet) + { + /****** ǰͨжβɼռ״̬ ******/ + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + cOrgAxleSecOccState = GetLinkOrgAxleSecOccSta(wMinHeadLink); /*ȡlinkļβɼռ״̬*/ + cTmlAxleSecOccState = GetLinkTmlAxleSecOccSta(wMinHeadLink); /*ȡlinkյļβɼռ״̬*/ + + if ((AXIS_SECTION_OCCUPY_NO == cOrgAxleSecOccState) && (AXIS_SECTION_OCCUPY_NO == cTmlAxleSecOccState)) + { + *pMonitorLinkId = wMinHeadLink; /*ලЧʱlink*/ + cRetVal = CI_SUCCESS; /*гǰξɼУͨ*/ + } + else + { + cRetVal = CI_ERROR; /*гǰδڲɼռãʧ*/ + } + } + else + { + cRetVal = CI_ERROR; /*гλüලǰʧ*/ + } + } + else + { + cStopSteadyState = GetTrainStopSteadyState(wTrainId); /*гͣ״̬*/ + if (TRAIN_SS_YES != cStopSteadyState) + { + cRetVal = CI_ERROR; /*гδͣ׼ͣͨжϣλüලЧ*/ + } + else + { + if (TRAIN_POS_MONITOR_VALID == cMonitorState) + { + /****** гǰλüල״̬Чжλüල״̬ ******/ + wTrainPosMonitorInLink = GetTrainPosMonitorInLink(wTrainId); /*ȡгλüල״̬Чʱlink*/ + cOrgAxleSecOccState = GetLinkOrgAxleSecOccSta(wTrainPosMonitorInLink); /*ȡlinkļβɼռ״̬*/ + cTmlAxleSecOccState = GetLinkTmlAxleSecOccSta(wTrainPosMonitorInLink); /*ȡlinkյļβɼռ״̬*/ + + if ((AXIS_SECTION_OCCUPY_NO == cOrgAxleSecOccState) && (AXIS_SECTION_OCCUPY_NO == cTmlAxleSecOccState)) + { + *pMonitorLinkId = wTrainPosMonitorInLink; /*ලЧʱlink*/ + cRetVal = CI_SUCCESS; /*гǰξɼУͨ*/ + } + else + { + cRetVal = CI_ERROR; /*гǰδڲɼռãʧ*/ + } + } + else + { + cRetVal = CI_ERROR; /*ͨжϺгλüලЧּලЧ*/ + } + } + } + + *pMonitorFailState = cMonitorFailState; + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* гλüල״̬ռü飨BG1 +* ˵const UINT16 wBGLinkId BG link ID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.18 +*/ +UINT8 BGTrainPosMonitorOccCheck(const UINT16 wBGLinkId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wLinkIndex = 0U; + UINT16 wBGRelAGLinkId = 0U; /*BGLinkAGlink*/ + UINT16 wBGRelOrgLinkId = 0U; /*BGlink*/ + UINT16 wBGRelTmlLinkId = 0U; /*BGյlink*/ + UINT16 wBGRelOrgLinkAttr = LINK_REL_PHYSEC_DEFAULT; /*BGlinkAG/BG*/ + UINT16 wBGRelTmlLinkAttr = LINK_REL_PHYSEC_DEFAULT; /*BGյlinkAG/BG*/ + UINT16 wAdjacentLinkId = 0U; /*BGڵķBG2link*/ + UINT16 wAxleSecId = 0U; + UINT8 cAxleSecOccState = AXIS_SECTION_OCCUPY_YES; /*ڼβɼռ״̬*/ + UINT16 wMonitorTrainId = 0U; /*ιļලЧгID*/ + UINT16 wAGRelOrgLinkId = 0U; /*AGlink*/ + UINT16 wAGRelTmlLinkId = 0U; /*AGյlink*/ + UINT16 wDGLinkId = 0U; /*DGlink*/ + + wLinkIndex = GetLinkIndexById(wBGLinkId); + if ((0U < wLinkIndex) && (LINK_SUM_MAX > wLinkIndex)) + { + wBGRelAGLinkId = GetBGLinkRelAGLinkId(wBGLinkId); /*ȡBGAGlink*/ + + wBGRelOrgLinkId = GetLinkOrgnJointMainLkIdById(wBGLinkId); + wBGRelOrgLinkAttr = GetLinkRelPhySecAGorBGAttr(wBGRelOrgLinkId); + if ((0U != wBGRelOrgLinkId) && (UINT16_MAX != wBGRelOrgLinkId) && (LINK_REL_PHYSEC_BG != wBGRelOrgLinkAttr)) + { + wAdjacentLinkId = wBGRelOrgLinkId; /*BGڵķBG2linkΪӵlink*/ + } + else + { + /*ͷ߻BG2*/ + } + + wBGRelTmlLinkId = GetLinkTmnlJointMainLkById(wBGLinkId); + wBGRelTmlLinkAttr = GetLinkRelPhySecAGorBGAttr(wBGRelTmlLinkId); + if ((0U != wBGRelTmlLinkId) && (UINT16_MAX != wBGRelTmlLinkId) && (LINK_REL_PHYSEC_BG != wBGRelTmlLinkAttr)) + { + wAdjacentLinkId = wBGRelTmlLinkId; /*BGڵķBG2linkΪӵlink*/ + } + else + { + /*ͷ߻BG2*/ + } + + if (wAdjacentLinkId == wBGRelAGLinkId) + { + /*CG*/ + wAxleSecId = GetLinkBelongAcId(wAdjacentLinkId); /*ȡAGID*/ + wMonitorTrainId = GetAxisPosMonitorTrainId(wAxleSecId); /*ȡAGļලЧгID*/ + if (0U != wMonitorTrainId) + { + /*AGгڼලУDGɼռ״̬*/ + wAGRelOrgLinkId = GetLinkOrgnJointMainLkIdById(wBGRelAGLinkId); + wAGRelTmlLinkId = GetLinkTmnlJointMainLkById(wBGRelAGLinkId); + if (wAGRelOrgLinkId != wBGLinkId) + { + /*linkΪDG*/ + wDGLinkId = wAGRelOrgLinkId; + } + else + { + /*յlinkΪDG*/ + wDGLinkId = wAGRelTmlLinkId; + } + + wAxleSecId = GetLinkBelongAcId(wDGLinkId); /*ȡDGID*/ + cAxleSecOccState = GetAxisOccupyState(wAxleSecId); /*ȡDGβɼռ״̬*/ + + if (AXIS_SECTION_OCCUPY_NO == cAxleSecOccState) + { + cRetVal = CI_SUCCESS; /*DG޲ɼռãسɹ*/ + } + else + { + cRetVal = CI_ERROR; /*DGɼռãʧ*/ + } + } + else + { + /*AGгڼලУAGгǰ/ɸѡ־*/ + cRetVal = CheckAGToBGTrainVirScreen(wAxleSecId, wBGRelAGLinkId, wBGLinkId); + } + } + else + { + /*CG*/ + wAxleSecId = GetLinkBelongAcId(wAdjacentLinkId); /*ȡCGID*/ + cAxleSecOccState = GetAxisOccupyState(wAxleSecId); /*ȡCGβɼռ״̬*/ + + if (AXIS_SECTION_OCCUPY_NO == cAxleSecOccState) + { + cRetVal = CI_SUCCESS; /*DG޲ɼռãسɹ*/ + } + else + { + cRetVal = CI_ERROR; /*DGɼռãʧ*/ + } + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* AGгBG˵ɸѡ־ǷЧ +* ˵const UINT16 wAGAxleSecId AGID +* const UINT16 wAGLinkId AG link ID +* const UINT16 wBGLinkId BG link ID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.18 +*/ +UINT8 CheckAGToBGTrainVirScreen(const UINT16 wAGAxleSecId, const UINT16 wAGLinkId, const UINT16 wBGLinkId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wACIndex = 0U; + UINT16 wAGLinkIndex = 0U; + UINT16 wBGLinkIndex = 0U; + UINT16 ii = 0U; + UINT16 wTrainId = 0U; + UINT16 wEnterLjkLinkId = 0U; /*гʻмlink*/ + UINT16 wAGRelOrgLinkId = 0U; /*AGlink*/ + UINT16 wAGRelTmlLinkId = 0U; /*AGյlink*/ + UINT16 cVirScreenFlag = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*гɸѡ־*/ + UINT8 cTrianDir = DIR_INVALID; /*г*/ + UINT8 cBGFrontAxleSecNum = 0U; + UINT16 szBGFrontAxleSecID[AC_MAXCNT_IN_SWITCH] = { 0U }; + UINT16 wBGAxleSecId = 0U; /*BGID*/ + UINT8 cAGTrainNearFlag = AAM_BAD_NEAR; /*AGгӽ־*/ + + wACIndex = GetAxisSecConfigBufIndex(wAGAxleSecId); + wAGLinkIndex = GetLinkIndexById(wAGLinkId); + wBGLinkIndex = GetLinkIndexById(wBGLinkId); + + if ((AXIS_SECTION_SUM_MAX > wACIndex) && (0U < wAGLinkIndex) && (LINK_SUM_MAX > wAGLinkIndex) && (0U < wBGLinkIndex) && (LINK_SUM_MAX > wBGLinkIndex)) + { + for (ii = 0U; ii < TRAIN_SUM_MAX; ii++) + { + wTrainId = GetTrainId(ii); + wEnterLjkLinkId = GetTrainEnterLjkLinkId(wTrainId); + + if (wEnterLjkLinkId == wAGLinkId) + { + break; /*ҵAGгֹͣ*/ + } + else + { + /*ʻAGг*/ + } + } + + wAGRelOrgLinkId = GetLinkOrgnJointMainLkIdById(wAGLinkId); + wAGRelTmlLinkId = GetLinkTmnlJointMainLkById(wAGLinkId); + if (ii != TRAIN_SUM_MAX) + { + /*гʻAGжгBG˵ɸѡ־*/ + cTrianDir = GetTrainDir(wTrainId); + + if (wAGRelOrgLinkId == wBGLinkId) + { + /*AGlinkΪBGlink*/ + if (DIR_SAME == cTrianDir) + { + cVirScreenFlag = GetTrainVirTailScreenPassFlag(wTrainId); + } + else + { + cVirScreenFlag = GetTrainVirHeadScreenPassFlag(wTrainId); + } + } + else if (wAGRelTmlLinkId == wBGLinkId) + { + /*AGlinkյBGlink*/ + if (DIR_SAME == cTrianDir) + { + cVirScreenFlag = GetTrainVirHeadScreenPassFlag(wTrainId); + } + else + { + cVirScreenFlag = GetTrainVirTailScreenPassFlag(wTrainId); + } + } + else + { + cVirScreenFlag = TRAIN_VIR_SCREEN_PASS_FLAG_INVALID; /*쳣ɸѡЧ*/ + } + + if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID == cVirScreenFlag) + { + cRetVal = CI_SUCCESS; /*ɸѡ־Чسɹ*/ + } + else + { + cRetVal = CI_ERROR; /*ɸѡ־Чʧ*/ + } + } + else + { + /*гʻAGжAGгӽ״̬*/ + cBGFrontAxleSecNum = 1U; + szBGFrontAxleSecID[0U] = wAGAxleSecId; + wBGAxleSecId = GetLinkBelongAcId(wBGLinkId); /*ȡBGID*/ + + if (wAGRelOrgLinkId == wBGLinkId) + { + cAGTrainNearFlag = aam_SearchNearbyTrainType(wBGAxleSecId, EMAP_SAME_DIR, cBGFrontAxleSecNum, szBGFrontAxleSecID); /*ڣ߼ѯ*/ + } + else if (wAGRelTmlLinkId == wBGLinkId) + { + cAGTrainNearFlag = aam_SearchNearbyTrainType(wBGAxleSecId, EMAP_CONVER_DIR, cBGFrontAxleSecNum, szBGFrontAxleSecID); /*յڣ߼ѯ*/ + } + else + { + cAGTrainNearFlag = AAM_BAD_NEAR; /*쳣ӽ*/ + } + + if ((AAM_BAD_NEAR != cAGTrainNearFlag) && (AAM_GOOD_OCC != cAGTrainNearFlag)) + { + cRetVal = CI_SUCCESS; /*ǻӽسɹ*/ + } + else + { + cRetVal = CI_ERROR; /*ӽʧ*/ + debug_infor_printf((const)"TrainScreen CheckAGToBGTrainVirScreen ERR.\n"); + } + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* гλüල״̬ռü飨AG +* ˵const UINT16 wAGLinkId AG link ID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.18 +*/ +UINT8 AGTrainPosMonitorOccCheck(const UINT16 wAGLinkId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wLinkIndex = 0U; + UINT16 wAGRelBGLinkId = 0U; /*AGLinkBGlink*/ + UINT16 wAGRelOrgLinkId = 0U; /*AGlink*/ + UINT16 wAGRelTmlLinkId = 0U; /*AGյlink*/ + UINT8 cOrgLinkAttr = LINK_REL_PHYSEC_DEFAULT; + UINT8 cTmlLinkAttr = LINK_REL_PHYSEC_DEFAULT; + UINT16 wOrgAxleSecId = 0U; + UINT8 cOrgAxleSecOccState = AXIS_SECTION_OCCUPY_YES; /*βɼռ״̬*/ + UINT16 wTmlAxleSecId = 0U; + UINT8 cTmlAxleSecOccState = AXIS_SECTION_OCCUPY_YES; /*յβɼռ״̬*/ + UINT16 wDGLinkId = 0U; /*DGlink*/ + UINT16 wDGAxleSecId = 0U; + UINT8 cDGAxleSecOccState = AXIS_SECTION_OCCUPY_YES; /*DGβɼռ״̬*/ + + wLinkIndex = GetLinkIndexById(wAGLinkId); + if ((0U < wLinkIndex) && (LINK_SUM_MAX > wLinkIndex)) + { + wAGRelOrgLinkId = GetLinkOrgnJointMainLkIdById(wAGLinkId); + wAGRelTmlLinkId = GetLinkTmnlJointMainLkById(wAGLinkId); + + cOrgLinkAttr = GetLinkRelPhySecAGorBGAttr(wAGRelOrgLinkId); + cTmlLinkAttr = GetLinkRelPhySecAGorBGAttr(wAGRelTmlLinkId); + + if (LINK_REL_PHYSEC_BG == cOrgLinkAttr) + { + wAGRelBGLinkId = wAGRelOrgLinkId; + wDGLinkId = wAGRelTmlLinkId; + } + else if (LINK_REL_PHYSEC_BG == cTmlLinkAttr) + { + wAGRelBGLinkId = wAGRelTmlLinkId; + wDGLinkId = wAGRelOrgLinkId; + } + else + { + /*AGBGδֱCG*/ + } + + if (0U == wAGRelBGLinkId) + { + /*CGCG+DGIJɼռ״̬*/ + wOrgAxleSecId = GetLinkBelongAcId(wAGRelOrgLinkId); + cOrgAxleSecOccState = GetAxisOccupyState(wOrgAxleSecId); /*ȡβɼռ״̬*/ + wTmlAxleSecId = GetLinkBelongAcId(wAGRelTmlLinkId); + cTmlAxleSecOccState = GetAxisOccupyState(wTmlAxleSecId); /*ȡյβɼռ״̬*/ + + if (((AXIS_SECTION_OCCUPY_NO == cOrgAxleSecOccState) || (0U == wAGRelOrgLinkId) || (UINT16_MAX == wAGRelOrgLinkId)) + && ((AXIS_SECTION_OCCUPY_NO == cTmlAxleSecOccState) || (0U == wAGRelTmlLinkId) || (UINT16_MAX == wAGRelTmlLinkId))) + { + cRetVal = CI_SUCCESS; /*CG+DG޲ɼռãͨʼlinkжǷΪλسɹ*/ + } + else + { + cRetVal = CI_ERROR; /*ڲɼռãʧ*/ + } + } + else + { + /*CGDGIJɼռ״̬*/ + wDGAxleSecId = GetLinkBelongAcId(wDGLinkId); + cDGAxleSecOccState = GetAxisOccupyState(wDGAxleSecId); /*ȡDGβɼռ״̬*/ + if (AXIS_SECTION_OCCUPY_NO == cDGAxleSecOccState) + { + cRetVal = CI_SUCCESS; /*DG޲ɼռãسɹ*/ + } + else + { + cRetVal = CI_ERROR; /*DGڲɼռãʧ*/ + } + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} + +/* +* гλüල״̬飨Σ +* ˵const UINT16 wTrainId гID +* UINT16* pMonitorLinkId ලЧʱгlinkΣ +* UINT8* pMonitorFailState ලʧܺҪõ״̬Σ +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.21 +*/ +UINT8 CLDTrainPosMonitorCheck(const UINT16 wTrainId, UINT16* pMonitorLinkId, UINT8* pMonitorFailState) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wTrainIndex = 0U; + UINT8 cTransState = TRAIN_COMM_STATE_BAD; /*гͨ״̬*/ + UINT8 cFuncRet = CI_ERROR; + UINT8 cMonitorState = TRAIN_POS_MONITOR_INVALID; /*гλüල״̬*/ + UINT16 wMaxHeadLink = 0U; /*гǰlink*/ + UINT16 wMinHeadLink = 0U; /*гСǰlink*/ + UINT16 wMaxTailLink = 0U; /*гlink*/ + UINT16 wMinTailLink = 0U; /*гСlink*/ + UINT16 wMinHeadBelongCiId = 0U; /*СǰlinkCI*/ + UINT16 wMaxTailBelongCiId = 0U; /*linkCI*/ + UINT8 cLocalCiId = 0U; + UINT16 wTrainPosMonitorInLink = 0U; /*гλüල״̬Чʱlink*/ + UINT8 cAGorBGAttr = LINK_REL_PHYSEC_DEFAULT; /*AG/BG*/ + UINT8 cStopSteadyState = TRAIN_SS_NO; /*ͣ׼ͣ״̬*/ + UINT8 cMonitorFailState = TRAIN_POS_MONITOR_INVALID; /*ʧʱгλüල״̬*/ + + wTrainIndex = GetTrainBufIndex(wTrainId); + if ((TRAIN_SUM_MAX > wTrainIndex) && (NULL != pMonitorLinkId) && (NULL != pMonitorFailState)) + { + /****** гλüල״̬ǷЧ *******/ + cMonitorState = GetTrainPosMonitorState(wTrainId); /*ȡгλüල״̬*/ + cTransState = GetTrainTransitmitStat(wTrainId); /*ȡгͨ״̬*/ + if (TRAIN_COMM_STATE_GOOD == cTransState) + { + wMaxHeadLink = GetTrainMaxHeadLink(wTrainId); /*ȡгλϢ*/ + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + wMaxTailLink = GetTrainMaxTailLink(wTrainId); + wMinTailLink = GetTrainMinTailLink(wTrainId); + wTrainPosMonitorInLink = GetTrainPosMonitorInLink(wTrainId); /*ȡгλüල״̬Чʱlink*/ + + if (TRAIN_POS_MONITOR_VALID == cMonitorState) + { + cLocalCiId = GetSystemParaLocalCiId(); + wMinHeadBelongCiId = GetLinkManageTiocById(wMinHeadLink); + wMaxTailBelongCiId = GetLinkManageTiocById(wMaxTailLink); + + if ((wMaxHeadLink != wTrainPosMonitorInLink) && (wMinHeadLink != wTrainPosMonitorInLink) && (wMaxTailLink != wTrainPosMonitorInLink) && (wMinTailLink != wTrainPosMonitorInLink)) + { + cMonitorFailState = TRAIN_POS_MONITOR_DIFF; /*гȫԭlinkලλòһ*/ + cFuncRet = CI_ERROR; + } + else if ((0U != cLocalCiId) && (cLocalCiId == (UINT8)wMinHeadBelongCiId) && (cLocalCiId == (UINT8)wMaxTailBelongCiId)) + { + cFuncRet = TrainPosMonitorCommonCheck(wTrainId); /*гڱʼලгλüලͨ*/ + } + else + { + cMonitorFailState = TRAIN_POS_MONITOR_INVALID; /*гڱලλЧ*/ + cFuncRet = CI_ERROR; + } + } + else + { + cFuncRet = TrainPosMonitorBeginCheck(wTrainId); /*гδʼලгλüලʼ*/ + } + + if (CI_SUCCESS == cFuncRet) + { + /****** ǰͨжβɼռ״̬ ******/ + wMinHeadLink = GetTrainMinHeadLink(wTrainId); + wTrainPosMonitorInLink = wMinHeadLink; /*¼´õlink*/ + cAGorBGAttr = GetLinkRelPhySecAGorBGAttr(wMinHeadLink); /*ȡAG/BG*/ + + switch (cAGorBGAttr) + { + case LINK_REL_PHYSEC_AG: + /*AGλüල*/ + cRetVal = AGTrainPosMonitorOccCheck(wTrainPosMonitorInLink); + break; + case LINK_REL_PHYSEC_BG: + /*BGλüල*/ + cRetVal = BGTrainPosMonitorOccCheck(wTrainPosMonitorInLink); + break; + default: + cRetVal = CI_ERROR; /*AGҷBGʧ*/ + break; + } + } + else + { + cRetVal = CI_ERROR; /*гλüලǰʧ*/ + } + } + else + { + cStopSteadyState = GetTrainStopSteadyState(wTrainId); /*гͣ״̬*/ + if (TRAIN_SS_YES != cStopSteadyState) + { + cRetVal = CI_ERROR; /*гδͣ׼ͣͨжϣλüලЧ*/ + } + else + { + if (TRAIN_POS_MONITOR_VALID == cMonitorState) + { + /****** гǰλüල״̬Чжλüල״̬ ******/ + wTrainPosMonitorInLink = GetTrainPosMonitorInLink(wTrainId); /*ȡгλüල״̬Чʱlink*/ + cAGorBGAttr = GetLinkRelPhySecAGorBGAttr(wTrainPosMonitorInLink); /*ȡAG/BG*/ + + switch (cAGorBGAttr) + { + case LINK_REL_PHYSEC_AG: + /*AGλüල*/ + cRetVal = AGTrainPosMonitorOccCheck(wTrainPosMonitorInLink); + break; + case LINK_REL_PHYSEC_BG: + /*BGλüල*/ + cRetVal = BGTrainPosMonitorOccCheck(wTrainPosMonitorInLink); + break; + default: + cRetVal = CI_ERROR; /*AGҷBGʧ*/ + break; + } + } + else + { + cRetVal = CI_ERROR; /*гλüලǰʧ*/ + } + } + } + + if (CI_SUCCESS == cRetVal) + { + *pMonitorLinkId = wTrainPosMonitorInLink; /*λüලЧʱlink*/ + } + else + { + *pMonitorFailState = cMonitorFailState; /*ʧʱгλüල״̬*/ + } + } + else + { + /*μʧܣ*/ + } + + return cRetVal; +} + +/* +* ߻ѹռü飨Σ +* ˵const UINT16 wSWLinkId ߻ѹlinkID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.19 +*/ +UINT8 CLDSWAdjacentSecOccCheck(const UINT16 wSWLinkId) +{ + UINT8 cRetVal = CI_ERROR; + UINT16 wLinkIndex = 0U; + UINT8 cAGorBGAttr = LINK_REL_PHYSEC_DEFAULT; /*AG/BG*/ + + wLinkIndex = GetLinkIndexById(wSWLinkId); + if ((0U < wLinkIndex) && (LINK_SUM_MAX > wLinkIndex)) + { + cAGorBGAttr = GetLinkRelPhySecAGorBGAttr(wSWLinkId); /*ȡAG/BG*/ + + if (LINK_REL_PHYSEC_AG == cAGorBGAttr) + { + cRetVal = AGTrainPosMonitorOccCheck(wSWLinkId); /*AGռü*/ + } + else if (LINK_REL_PHYSEC_BG == cAGorBGAttr) + { + cRetVal = BGTrainPosMonitorOccCheck(wSWLinkId); /*BGռü*/ + } + else + { + /*߻ѹ첻AGҲNG쳣ʧ*/ + } + } + else + { + /*μʧܣʧ*/ + } + + return cRetVal; +} +/* +* гǰСABL־ +* ˵ +* ֵ +* Created By fan 2024.08.20 +*/ +void TrainPhyAblTagUpdate(void) +{ + UINT8 cTrainIndex = 0U; + UINT8 ii = 0U; + UINT16 wTrainId = 0U; + UINT8 chTrainLevel = 0U; /*гм*/ + UINT16 wTrainMaxSafeHeadLink = 0U; /*ǰlink*/ + UINT16 wTrainMinSafeTailLink=0U; /*Сink*/ + UINT16 phySecCurSum = 0U; /**/ + UINT16 wPhySecId = 0U; + UINT8 belongCiId = 0u; + UINT8 localCiId = GetSystemParaLocalCiId(); + UINT8 chAblTag = PHYSICAL_SECTION_ABLOCCUPY_DEFAULT; + for (cTrainIndex = 0U; cTrainIndex < TRAIN_SUM_MAX; cTrainIndex++) + { + wTrainId = GetTrainId(cTrainIndex); + chTrainLevel = GetTrainLevel(wTrainId); + wTrainMaxSafeHeadLink = GetAblTrainMaxHeadLink(wTrainId); + wTrainMinSafeTailLink = GetAblTrainMinTailLink(wTrainId); + /*ͨųABLռѹ״̬*/ + if (TRAIN_LEVEL_ABL == chTrainLevel) + { + chAblTag = PHYSICAL_SECTION_ABLOCCUPY_YES; + } + else + { + chAblTag = PHYSICAL_SECTION_ABLOCCUPY_NO; + } + /*ǰABL־*/ + wPhySecId = GetLinkRelatedPhySec(wTrainMaxSafeHeadLink); + if (0U != wPhySecId) + { + belongCiId = GetPhySecBelongCiId(wPhySecId); + if (localCiId == belongCiId) + { + SetPhySecABLTrainFlag(wPhySecId, chAblTag); + } + else + { + ; /**/ + } + } + + /*СABL־*/ + wPhySecId = GetLinkRelatedPhySec(wTrainMinSafeTailLink); + if (0U != wPhySecId) + { + belongCiId = GetPhySecBelongCiId(wPhySecId); + if (localCiId == belongCiId) + { + SetPhySecABLTrainFlag(wPhySecId, chAblTag); + } + else + { + ; /**/ + } + } + } + + phySecCurSum = GetPhySecCurSum(); + /* δεı־ */ + for (ii = 0u; ii < phySecCurSum; ii++) + { + wPhySecId = GetPhySecId(ii); + belongCiId = GetPhySecBelongCiId(wPhySecId); + if (belongCiId == localCiId) + { + /*Ĭ Աδõθ*/ + SetPhySecABLTrainFlag(wPhySecId, PHYSICAL_SECTION_ABLOCCUPY_DEFAULT); + } + } +} + +/* +* BGԶɸѡAG UTռü +* ˵const UINT16 wLinkId BGlinkID +* ֵ0 ʧ +* 1 ɹ +* by cgh 20240903 +*/ +UINT8 BGAtsScreenAgUtCheck(const UINT16 wLinkId) +{ + UINT8 chReval = CI_ERROR; + UINT8 chLinkRelAbgFlag = 0U;/*LINKABG*/ + UINT16 wBGLinkRelAGLinkId = 0U;/*BGAGLINK ID*/ + UINT16 wAGRelAxisSecId = 0U;/*AGID*/ + UINT8 chAgLinkExistRelCgFlag = 0U;/*AGǷCG־*/ + + if ((0U < wLinkId) && (LINK_SUM_MAX > wLinkId)) + { + chLinkRelAbgFlag = GetLinkRelPhySecAGorBGAttr(wLinkId); + if (LINK_REL_PHYSEC_BG == chLinkRelAbgFlag) + { + wBGLinkRelAGLinkId = GetBGLinkRelAGLinkId(wLinkId); + chAgLinkExistRelCgFlag = GetAgLinkExistRelCgFlag(wBGLinkRelAGLinkId); + if (AGLINK_EXIST_REL_CG_NO == chAgLinkExistRelCgFlag) + { + wAGRelAxisSecId = GetLinkBelongAcId(wBGLinkRelAGLinkId); + chReval = CheckAGToBGTrainVirScreen(wAGRelAxisSecId, wBGLinkRelAGLinkId, wLinkId); + } + else + { + /*CGͨڼǷзͨ*/ + chReval = CI_SUCCESS; + } + + } + else + { + /*BG */ + chReval = CI_SUCCESS; + } + } + else + { + ; /*ݷǷ*/ + } + + return chReval; +} + +/* +* ָгʼɳʼ +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwCycNum гʼɳʼ +* ֵ +* BY fan 20241017 +*/ +void SetTrainStartFlyProtectCycNum(const UINT16 wTrainId, const UINT32 dwCycNum) +{ + UINT16 wBufIndex = 0U; + UINT32 dwSysFlyOverCyc = GetFlyProtectOverCyc(); + UINT32 dwFlyStartCyc = 0U; + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + dwFlyStartCyc = GetTrainStartFlyProtectCycNum(wTrainId); + + if (0U == dwFlyStartCyc) + { + gstTrainInfo[wBufIndex].dwStartFlyCycNum = dwCycNum; /*δ*/ + } + else if ((0U == dwSysFlyOverCyc) && (0U== dwCycNum)) + { + gstTrainInfo[wBufIndex].dwStartFlyCycNum = dwCycNum; /*δϵͳ崻־ */ + } + else + { + ; /*ѽ崻*/ + } + } + else + { + ; + } +} + +/* +* ָгʼɳʼ +* ˵ const UINT16 wTrainId, гID +* ֵ UINT32 гʼɳʼ +* BY fan 20241017 +*/ +UINT32 GetTrainStartFlyProtectCycNum(const UINT16 wTrainId) +{ + UINT32 dwRetVal = 0U; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + if (TRAIN_SUM_MAX > wBufIndex) + { + dwRetVal = gstTrainInfo[wBufIndex].dwStartFlyCycNum; + } + else + { + ; + } + + return dwRetVal; +} + + +/** +* ӷɳ +* ˵UINT16 wTrainID UINT16 envelopeIdid +* ֵ +* BY fan 20241018 +*/ +void elm_AddFlyingTrain(UINT16 wTrainID, UINT16 envelopeId) +{ + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 chSecNum = 0; + const EnvelopeStruct* pEnvelop = NULL; + if (SHUT_DOWN_TRAIN_NUMMAX > gFlyTrainCnt) + { + for (ii = 0U; ii < gFlyTrainCnt; ii++) + { + if (gFlyTrainData[ii].wTrainId == wTrainID) + { + break; /**/ + } + } + if (ii == gFlyTrainCnt) + { + gFlyTrainData[gFlyTrainCnt].wTrainId= wTrainID; + /** ȡϢַ */ + pEnvelop = elm_GetEnvelopeInfoPtr(envelopeId); + for (jj = 0U; jj < pEnvelop->ACCnt; jj++) + { + if (TRAIN_FLYALARM_SECNUM_MAX > chSecNum) + { + gFlyTrainData[gFlyTrainCnt].flyProtectSec[chSecNum] = pEnvelop->ACID[jj]; + chSecNum++; + } + else + { + break; + } + } + gFlyTrainData[gFlyTrainCnt].flyProtectSecCnt = chSecNum; + gFlyTrainCnt++; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ȡɳ +* ˵UINT8 chIndex +* ֵ TrainFlyProtectStru* gFlyTrainData +* BY fan 20241018 +*/ + +TrainFlyProtectStru * GetFlyProtectData(UINT8 chIndex) +{ + return &gFlyTrainData[chIndex]; +} + +/* +* ȡɳ +* ˵ +* ֵ UINT8 flyProtectTrainNum +* BY fan 20241018 +*/ +UINT8 GetFlyProtectNum(void) +{ + return gFlyTrainCnt; +} + +/** +* @brief ȡɳ崻 +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 GeFlyProtectTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = 0U; + UINT32 copyIndex = curIndex; + UINT8 chIndex = 0u; + UINT8 flyTrainCnt = 0u; + flyTrainCnt = GetFlyProtectNum(); + if (NULL != pDataBuff) + { + pDataBuff[copyIndex] = flyTrainCnt; + copyIndex++; + for (chIndex = 0u; chIndex < flyTrainCnt; chIndex++) + { + (void)CommonMemCpy(&pDataBuff[copyIndex], (UINT32)sizeof(TrainFlyProtectStru), &gFlyTrainData[chIndex], (UINT32)sizeof(TrainFlyProtectStru)); + copyIndex += (UINT32)sizeof(TrainFlyProtectStru); + } + ret = copyIndex; + } + return ret; +} + +/** +* @brief ȡɳ崻 +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 SeFlyProtectTransferData(IN UINT8 *pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex; + UINT8 chIndex = 0u; + + if (NULL != pDataBuff) + { + gFlyTrainCnt = pDataBuff[copyIndex++]; + for (chIndex = 0u; chIndex < SHUT_DOWN_TRAIN_NUMMAX; chIndex++) + { + (void)CommonMemSet(&gFlyTrainData[chIndex], (UINT32)sizeof(TrainFlyProtectStru), 0U, (UINT32)sizeof(TrainFlyProtectStru)); + } + if (SHUT_DOWN_TRAIN_NUMMAX >= gFlyTrainCnt) + { + for (chIndex = 0u; chIndex < gFlyTrainCnt; chIndex++) + { + (void)CommonMemCpy(&gFlyTrainData[chIndex], (UINT32)sizeof(TrainFlyProtectStru), &pDataBuff[copyIndex], (UINT32)sizeof(TrainFlyProtectStru)); + copyIndex += (UINT32)sizeof(TrainFlyProtectStru); + } + } + else + { + ; /**/ + } + ret = copyIndex; + } + return ret; +} + +/* +* ָгɳʼ +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwCycNum гʼɳʼ +* ֵ +* by cgh 20241028 +*/ +void SetTrainFlyProStartCycNum(const UINT16 wTrainId, const UINT32 dwCycNum) +{ + UINT16 wBufIndex = 0U; + UINT32 dwFlyStartCyc = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + if (0U == dwCycNum) + { + /*ҪõںΪ0ֱ*/ + gstTrainInfo[wBufIndex].dwStartFlyCycNum = 0U; + } + else + { + dwFlyStartCyc = GetTrainStartFlyProtectCycNum(wTrainId); + if (0U == dwFlyStartCyc) + { + gstTrainInfo[wBufIndex].dwStartFlyCycNum = dwCycNum; + } + else + { + ; /*ǰЧڲ*/ + } + } + } + else + { + ; + } +} + +/* +* ָгɢ״̬ +* ˵const UINT16 wTrainId гID +* const UINT8 chEaCmdState ɢ״̬ +* ֵ +* by cgh 20250310 +*/ +void SetTrainEaCmdState(const UINT16 wTrainId, const UINT8 chEaCmdState) +{ + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + if ((TRAIN_EA_CMD_STATE_VALID == chEaCmdState) || (TRAIN_EA_CMD_STATE_INVALID == chEaCmdState)) + { + gstTrainInfo[wBufIndex].chEaCmdState = chEaCmdState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָгɢ״̬ +* ˵const UINT16 wTrainId гID +* ֵ0x55 ɢ״̬Ч +* 0xAA ɢ״̬Ч +* by cgh 20250310 +*/ +UINT8 GetTrainEaCmdState(const UINT16 wTrainId) +{ + UINT8 cRetVal = TRAIN_EA_CMD_STATE_VALID; + UINT16 wBufIndex = 0U; + + wBufIndex = GetTrainBufIndex(wTrainId); + + if (TRAIN_SUM_MAX > wBufIndex) + { + cRetVal = gstTrainInfo[wBufIndex].chEaCmdState; + } + else + { + /*Ĭֵ*/ + } + + return cRetVal; +} diff --git a/TSCP/src/APP/ciapp/Train/TrainDataManage.h b/TSCP/src/APP/ciapp/Train/TrainDataManage.h new file mode 100644 index 0000000..bd74db8 --- /dev/null +++ b/TSCP/src/APP/ciapp/Train/TrainDataManage.h @@ -0,0 +1,2454 @@ +/**************************************************************************************************** +* ļ : APP_TrainDataManage.h +* Ȩ˵ : ؿƼɷ޹˾ +* 汾 : 1.0 +* ʱ : 2021.06.15 +* : OC +* : гģʵͷļ +* ʹע : +* +* ޸ļ¼ : +* +**************************************************************************************************/ +#ifndef TRAIN_DATA_MANAGE_H_ +#define TRAIN_DATA_MANAGE_H_ +#include "TrainDefine.h" +#include "../Section/LinkConfigDataManage.h" + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define FINDHEADSAFEFLAG 1U /*ѯгȫͷλ*/ +#define FINDTAILSAFEFLAG 2U /*ѯгȫβλ*/ +#define CALSAFEPOSFLAG 1U /*ѯȫλʱ*/ +#define CALOTHERFLAG 2U /*ѯʱ*/ + +#define TRAIN_ENTER_ROUTE_NO 1u /* гδʻ· */ +#define TRAIN_ENTER_ROUTE_HEAD 2u /* гʻ·δѹźŻ */ +#define TRAIN_ENTER_ROUTE_CROSS 3u /* гѹźŻ */ +#define TRAIN_ENTER_ROUTE_FULL 4u /* гȫʻ· */ +#define TRAIN_ENTER_ROUTE_TAIL 5u /* гͷʻ· */ + +/*гȫλýṹ*/ +typedef struct S_TrainSafeLoc +{ + UINT16 wHeadLink; /*ȫͷlink*/ + UINT32 dwHeadOffset; /*ȫͷlinkƫ*/ + UINT8 chHeadDir; /*ȫͷ*/ + UINT16 wTailLink; /*ȫβlink*/ + UINT32 dwTailOffset; /*ȫβlinkƫ*/ + UINT8 chTailDir; /*ȫβ*/ + UINT8 chHeadFlag; /*ȫͷͨռñ־*/ +}TrainSafeLocStru; + +typedef struct S_TrainMa +{ + UINT8 chMaDir; /*MA*/ + struct_PathPoint strMaStart; /*MA*/ + struct_PathPoint strMaEnd; /*MAյ*/ +}TrainMaStru; + +typedef struct +{ + UINT16 wEaTrainId; /*ɢгID*/ + UINT8 chAgreeState; /*״̬*/ + UINT32 dwBuildCyc; /*ں*/ +}TrainEaStru; + +/*ABLг߼Ϣṹ*/ +typedef struct S_ABLTrainRelLogStru +{ + UINT16 wAblRelLogSecId; /*ABLг߼ID*/ + UINT8 chAblRelLogSecDir; /*ABLг߼շ*/ +}ABLTrainRelLogStru; + +/*ABLгPSDϢṹ*/ +typedef struct S_ABLTrainRelPsdStru +{ + UINT16 wAblRelPsdId; /*ABLгѯΧڹPSDID*/ + UINT8 chAblRelPsdSta; /*ABLгѯΧڹPSD״̬*/ +}ABLTrainRelPsdStru; + +/*ABLгESBϢṹ*/ +typedef struct S_ABLTrainRelEsbStru +{ + UINT16 wAblRelEsbId; /*ABLгѯΧڹPSDID*/ + UINT8 chAblRelEsbSta; /*ABLгѯΧڹPSD״̬*/ +}ABLTrainRelEsbStru; + +/*ABLгϢṹ*/ +typedef struct S_ABLTrainRelSwitchStru +{ + UINT16 wAblRelSwitchId; /*ABLгѯΧڹID*/ + UINT8 chAblRelSwitchSta; /*ABLгѯΧڹ״̬*/ +}ABLTrainRelSwitchStru; + +/*ABLгϢṹ*/ +typedef struct S_ABLTrainRelProSecStru +{ + UINT16 wAblRelProSecId; /*ABLгѯΧڹID*/ + UINT8 chAblRelProSecDir; /*ABLгѯΧڹη*/ +}ABLTrainRelProSecStru; + +/*ABLгϢṹ*/ +typedef struct S_ABLTrainRelXianSuStru +{ + UINT16 wAblRelXianSuPhySecId; /*ABLгѯΧID*/ + UINT16 chAblRelXianSuValue; /*ABLгѯΧֵ*/ +}ABLTrainRelXianSuStru; + +/*ABLгн·Ϣṹ*/ +typedef struct S_ABLTrainRelAllRouteStru +{ + UINT16 wAblRelRouteId; /*ABLгԼǰ·ID*/ + UINT8 chAblRelTrainInFlag; /*ABLгн·ǷΪ½·־*/ +}ABLTrainRelAllRouteStru; + +/*ABLгϢṹ*/ +typedef struct S_ABLTrainInfoStru +{ + UINT8 chAblRelLogSecNum; /*ABLг߼*/ + ABLTrainRelLogStru ablTrainRelLogData[TRAIN_ABL_LOGSEC_SUM]; /*ABLг߼Ϣ*/ + + UINT8 chABLRelReturnLogNum; /*ABLг۷߼*/ + UINT16 wABLRelReturnLogBuf[TRAIN_ABL_RETURNLOGSEC_SUM]; /*ABLг۷߼ID*/ + + UINT8 chABLRelPsdNum; /*ABLгѯΧPSD*/ + ABLTrainRelPsdStru ablTrainRelPsdData[TRAIN_ABL_PSD_SUM]; /*ABLгѯΧPSDϢ*/ + + UINT8 chABLRelEsbNum; /*ABLгѯΧESB*/ + ABLTrainRelEsbStru ablTrainRelEsbData[TRAIN_ABL_ESB_SUM]; /*ABLгѯΧESBID(Ѽ)*/ + + UINT8 chABLRelSwitchNum; /*ABLгѯΧڵ*/ + ABLTrainRelSwitchStru ablTrainRelSwitchData[TRAIN_ABL_SWITCH_SUM]; /*ABLгѯΧڵϢ*/ + + UINT8 chABLRelProSecNum; /*ABLгѯΧڱ*/ + ABLTrainRelProSecStru ablTrainRelProSecData[TRAIN_ABL_PROSEC_SUM]; /*ABLгѯΧڱϢ*/ + + UINT8 chABLRelXianSuNum; /*ABLгѯΧ*/ + ABLTrainRelXianSuStru ablTrainRelXiansuData[TRAIN_ABL_XIANSUSEC_SUM]; /*ABLгѯΧϢ*/ + + UINT8 chAblAllRouteNum; /*ABLµǰн·*/ + ABLTrainRelAllRouteStru wAblAllRouteData[TRAIN_ABL_ALLROUTE_SUM]; /*ABLгµǰн·Ϣ*/ + + + UINT16 wAblMaxHeadLogSecId; /*гǰͷ߼ID*/ + UINT16 wAblOccuLogSecIdBuff[TRAIN_ABL_LOGSEC_SUM]; /*ABLг߼*/ + UINT8 wAblOccuLogSeNum; /*ABLг߼*/ + UINT16 wAblNoOccuFarLogId; /*ABLг½·Զδռ߼ID*/ + +}ABLTrainInfoStru; + +/*ǰATPλϢṹ*/ +typedef struct S_HeadTrainAtpLocStru +{ + UINT8 chTrainDir; /*гзСȫָͷ*/ + UINT16 wTrainMaxHeadLink; /*гȫǰLink*/ + UINT32 dwTrainMaxHeadOffset; /*гȫǰƫ*/ + UINT16 wTrainMinTailLink; /*гСȫlink*/ + UINT32 dwTrainMinTailOffset; /*гСȫƫ*/ +}HeadTrainAtpLocStru; + +/*ǰITEλϢṹ*/ +typedef struct S_HeadTrainIteLocStru +{ + UINT16 wTrainMaxHeadLink; /*гȫǰLink*/ + UINT32 dwTrainMaxHeadOffset; /*гȫǰƫ*/ + UINT16 wTrainMinTailLink; /*гСȫlink*/ + UINT32 dwTrainMinTailOffset; /*гСȫƫ*/ + UINT8 chTrainDir; /*гз*/ + UINT16 wLocHeadLoss; /*λǰ*/ + UINT16 wLocTailLoss; /*λ*/ +}HeadTrainIteLocStru; + +/*ǰλϢṹ*/ +typedef struct S_HeadTrainLocStru +{ + UINT32 wHeadVobcId; /*ǰID*/ + UINT8 chHeadTrainLocFlag; /*λñʶ*/ + HeadTrainAtpLocStru strHeadTrainAtpLoc; /*ATPλϢ*/ + HeadTrainIteLocStru strHeadTrainIteLoc; /*ITEλϢ*/ +}HeadTrainLocStru; + +typedef struct S_TrainIteDataStruct +{ + UINT16 wTrainHeadLinkId; /*гͷlink ID*/ + UINT32 dwTrainHeadLinkOffset; /*гͷlinkƫ*/ + UINT16 wTrainTailLinkId; /*гβlink ID*/ + UINT32 dwTrainTailLinkOffset; /*гβlinkƫ*/ + UINT8 cTrainDir; /*гз*/ + UINT16 wForWardOffset; /*λǰcm*/ + UINT16 wBackOffset; /*λcm*/ +} TrainIteDataStruct; + +/*гϢṹ*/ +typedef struct S_TrainInfoStru +{ + UINT16 wTrainId; /*гID*/ + UINT8 chTrainInZone; /*гǷڱ*/ + UINT8 chTrainLevel; /*гм*/ + UINT8 chTrainModel; /*гģʽ*/ + UINT32 dwIvocCycle; /*IVOCӦ */ + UINT8 chTrainDir; /*гзСȫָͷ*/ + UINT8 chTrainDir_MaxTail; /*гзȫˣ*/ + UINT8 chTrainDir_MinHead; /*гзСȫǰˣ*/ + UINT8 chTrainDir_MaxHead; /*гзȫǰˣ*/ + UINT16 wTrainMaxHeadLink; /*гȫǰLink*/ + UINT32 dwTrainMaxHeadOffset; /*гȫǰƫ*/ + UINT16 wTrainMinHeadLink; /*гСȫǰlink*/ + UINT32 dwTrainMinHeadOffset; /*гСȫǰƫ*/ + UINT16 wTrainMaxTailLink; /*гȫLink*/ + UINT32 dwTrainMaxTailOffset; /*гȫƫ*/ + UINT16 wTrainMinTailLink; /*гСȫlink*/ + UINT32 dwTrainMinTailOffset; /*гСȫƫ*/ + UINT8 chSpeedDir; /*ٶȷ*/ + UINT16 wTrainSpeed; /*ٶȷ*/ + UINT8 chTrainZeroState; /*г״̬*/ + UINT8 chTransmitStat; /*г״̬*/ + UINT8 chHeadScreenStat; /*гǰɸ־*/ + UINT8 chTailScreenStat; /*гɸ־*/ + TrainSafeLocStru strSafeLoc; /*гȫλ*/ + UINT32 dwDelayTime; /*Ϣӳʱ*/ + UINT16 wGroupOtherTrainId; /* һгID*/ + UINT8 chGroupRunState; /* г״̬: 1DZ 2齨 3 4۷ 5*/ + UINT8 chGroupTrainReat; /* ǰ󳵹ϵ: 0x55Ϊǰ 0xaa 0x5aDZ*/ + UINT8 chMsgFromTiocId; /*ͨųϢԴTIOC*/ + UINT8 chSwState; /*г״̬*/ + UINT16 wSleepLink; /*г߹link*/ + UINT8 chWakeState; /*г״̬*/ + UINT8 chTrainReportState; /*г㱨ʪ챨Ϣbit0гǷջ(1-ǣ0-)bit1гǷ(1-ǣ0-) + bit2гǷõʪģʽ(1-ǣ0-)bit3гǷMMIõʪģʽ(1-ǣ0-)*/ + UINT8 chDynCmd; /*̬*/ + UINT8 chDynRpl; /*̬Իظ*/ + UINT8 chScreenApply; /*ɸѡ*/ + UINT8 chTrainHeadScreenConfirm; /*˹ȷǰɸ*/ + UINT8 chTrainTailScreenConfirm; /*˹ȷβɸ*/ + UINT8 chAtsScreenConfirm; /*Զɸѡȷ*/ + UINT8 chStopSteadyState; /*гͣ׼ͣ״̬*/ + UINT8 chSleepCancleFlag; /*߳־*/ + UINT32 dwTransBadCyc; /*ͨж*/ + UINT8 chEaNum; /*ͨгظɢ*/ + TrainEaStru strTrainEaInfo[EA_MAX_NUM]; /*гָɢϢ*/ + UINT8 chEaCmd; /*ɢ*/ + UINT8 chTrainCanUct; /*гתΪUCT־״̬תΪδΪFLAG_SETʱΪFLAG_UNSET*/ + UINT8 chActive; /*г*/ + UINT8 chRrmRqst; /*RRM*/ + UINT8 chRrmState; /*RRMȨ״̬*/ + UINT8 chRrmReson; /*RRMԭ*/ + UINT8 chRrmResonFromOtherRc; /*RCRRMԭ*/ + UINT16 wAtsLgcStation; /*һ߼վ̨*/ + UINT16 wNextTioc; /*һTIOCţRRM*/ + UINT8 chDerailment; /*ѹ״̬*/ + + UINT16 wHeadAxisId; /*ǰ*/ + UINT8 wHeadITEResult; /*ǰITEʶ 0x55г 0xaaг*/ + UINT16 wTailAxisId; /*󷽼*/ + UINT8 wTailITEResult; /*ITEʶ 0x55г 0xaaг*/ + UINT8 chNvramPosFlag; /*NVNAMλñʶ 0x55гʹNVRAMλ 0xaaгδʹNVRAMλ*/ + ABLTrainInfoStru strAblTrainNeedData; /*ABLгҪ*/ + HeadTrainLocStru strHeadTrainLocData; /*ǰλϢ*/ + TrainIteDataStruct szTrainIteData[TRAIN_INC_ITE_SUM_MAX]; /*ITE㱨гλ*/ + UINT16 wTrainHeadSigId; /*ǰźŻID*/ + UINT16 wTrainHeadTrainId; /*ǰID*/ + UINT8 chTrainLocReverseRouteFlag; /*гλ÷·־*/ + UINT8 chAblTrainDir; /*ABLгзСȫָͷ*/ + UINT16 wAblTrainMaxHeadLink; /*ABLгȫǰLink*/ + UINT32 dwAblTrainMaxHeadOffset; /*ABLгȫǰƫ*/ + UINT16 wAblTrainMinTailLink; /*ABLгСȫlink*/ + UINT32 dwAblTrainMinTailOffset; /*ABLгСȫƫ*/ + UINT8 chVirHeadScreenPassFlag; /*ǰɸͨ־*/ + UINT8 chVirTailScreenPassFlag; /*ɸͨ־*/ + UINT16 wEnterLjkLinkId; /*гʻмLINK*/ + UINT32 dwTrainFullEnterLjkCycNum; /*гȫʻмں*/ + UINT8 chTrainPosMonitorState; /*гλüල״̬:0x55 Ч0xAA Ч0xCC λòһ*/ + UINT16 wTrainPosMonitorInLink; /*гλüලЧʱlink*/ + UINT32 dwStartFlyCycNum; /*гɳʼں*/ + UINT8 chEaCmdState; /*ɢ״̬*/ +}TrainInfoStru; + +/*̬Խṹ*/ +typedef struct +{ + UINT16 wTrainId; /*̬г*/ + UINT16 wLinkId; /*̬link*/ +}TrainDyInfoStru; + +/*Զɸѡṹ*/ +typedef struct +{ + UINT16 wTrainId; /*гID*/ + UINT8 chScType; /*ɸѡ*/ + UINT16 wLgcId; /*߼ID*/ +}TrainAtsScreenStru; + +typedef struct +{ + UINT16 wTrainId; /*гID*/ + UINT8 flyProtectSecCnt; /*Ŀ */ + UINT16 flyProtectSec[TRAIN_FLYALARM_SECNUM_MAX]; +}TrainFlyProtectStru; + +/*******************************ȫֱ*******************************/ +extern TrainInfoStru gstTrainInfo[TRAIN_SUM_MAX]; +extern UINT16 gszTrainId[TRAIN_SUM_MAX]; +extern UINT16 gTrainSum; +extern UINT8 gDyTestNum; +extern TrainDyInfoStru gszDyTestInfo[TRAIN_DYN_TEST_SUM_MAX]; +extern UINT8 gAtsScreenNum; +extern TrainAtsScreenStru gszAtsScreenInfo[TRAIN_SUM_MAX]; +extern UINT8 gFlyTrainCnt; +extern TrainFlyProtectStru gFlyTrainData[SHUT_DOWN_TRAIN_NUMMAX]; + +/*================================================================================== +*ܣʼгϢṹ塣 +*úʵгϢṹijʼ +*ڲ; +*ڲ; +*ֵ: +*ؼ +*ע +12021619 +=====================================================================================*/ +UINT8 TrainDataModuleInit(void); + +/* +* ȡгϢṹ +* ˵ void +* ֵ TrainInfoStru * гϢṹ +* : qw.liu 2022-02-24 +*/ +TrainInfoStru * GetTrainInfoData(void); + +/* +* ȡг +* ˵ void +* ֵ UINT16 ʼг +* : qw.liu 2022-02-25 +*/ +UINT16 GetTrainSum(void); + +/* +* ȡָ±ӦгID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: гID +*/ +UINT16 GetTrainId(const UINT16 bufIndex); + +/* +* ȡָг +* ˵ const UINT16 wTrainId, гID +* ֵ TRAIN_SUM_MAX: ȡʧ +* 0߼ID +*/ +UINT16 GetTrainAblMaxHeadLogId(const UINT16 wTrainId); + +/* +* ָгABLг߼ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chAblRelXianSuNum ABLг߼ +* const UINT16* chAblOcculogIdbuff ABLг߼ +* ֵ +*/ +void SetTrainAblOcculogData(const UINT16 wTrainId, const UINT8 chAblOcculogNum, const UINT16* chAblOcculogIdbuff); + + +/* +* ȡָABLг߼ +* ˵ const UINT16 wTrainId, гID +* ֵ 0ȡʧ +* >0߼ +*/ +UINT8 GetTrainAblOcculogIdSum(const UINT16 wTrainId); + +/* +* ȡָABLг߼ID +* ˵ const UINT16 wTrainId, гID +* ֵ NULLȡʧ +* !=NULL߼ID +*/ +UINT16* GetTrainAblOcculogIdBuff(const UINT16 wTrainId); + + +/* +* ָABLгԶ˿߼ +* ˵ const UINT16 wTrainId, гID +* const UINT16 logsecId ߼ID +* ֵ void +*/ +void SetTrainAblNoOccuFarLogId(const UINT16 wTrainId, const UINT16 logsecId); + +/* +* ȡָABLгԶ˿߼ +* ˵ const UINT16 wTrainId, гID +* ֵ 0ȡʧ +* >0߼ID +*/ +UINT16 GetTrainAblNoOccuFarLogId(const UINT16 wTrainId); + +/* +* ָгǰɸͨ־ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chFlag гǰɸͨ־ +* ֵ +* BY CGH 20240815 +*/ +void SetTrainVirHeadScreenPassFlag(const UINT16 wTrainId, const UINT8 chFlag); + +/* +* ȡָгǰɸͨ־ +* ˵ const UINT16 wTrainId, гID +* ֵ гǰɸͨ־ +* BY CGH 20240815 +*/ +UINT8 GetTrainVirHeadScreenPassFlag(const UINT16 wTrainId); + +/* +* ָгɸͨ־ +* ˵ const UINT16 wTrainId, гID +* const UINT8 chFlag гɸͨ־ +* ֵ +* BY CGH 20240815 +*/ +void SetTrainVirTailScreenPassFlag(const UINT16 wTrainId, const UINT8 chFlag); + +/* +* ȡָгɸͨ־ +* ˵ const UINT16 wTrainId, гID +* ֵ гɸͨ־ +* BY CGH 20240815 +*/ +UINT8 GetTrainVirTailScreenPassFlag(const UINT16 wTrainId); + +/* +* ָгʻмLINK +* ˵ const UINT16 wTrainId, гID +* const UINT16 гʻмLINK +* ֵ +* BY CGH 20240815 +*/ +void SetTrainEnterLjkLinkId(const UINT16 wTrainId, const UINT16 wLinkId); + +/* +* ȡָгʻмLINK +* ˵ const UINT16 wTrainId, гID +* ֵ гʻмLINK +* BY CGH 20240815 +*/ +UINT16 GetTrainEnterLjkLinkId(const UINT16 wTrainId); + +/* +* ָгȫʻмں +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwCycNum гȫʻмں +* ֵ +* BY CGH 20240815 +*/ +void SetTrainFullEnterLjkCycNum(const UINT16 wTrainId, const UINT32 dwCycNum); + +/* +* ȡָгȫʻмں +* ˵ const UINT16 wTrainId, гID +* ֵ гȫʻмں +* BY CGH 20240815 +*/ +UINT32 GetTrainFullEnterLjkCycNum(const UINT16 wTrainId); + +/* +* ָгλüල״̬ +* ˵const UINT16 wTrainId гID +* const UINT8 cMonitorState ල״̬ +* ֵ +* Created By LQ 2024.08.15 +*/ +void SetTrainPosMonitorState(const UINT16 wTrainId, const UINT8 cMonitorState); + +/* +* ȡָгλüල״̬ +* ˵const UINT16 wTrainId гID +* ֵ0x55 λüල״̬Ч +* 0xAA λüල״̬Ч +* 0xCC λüලһ +* Created By LQ 2024.08.15 +*/ +UINT8 GetTrainPosMonitorState(const UINT16 wTrainId); + +/* +* ָгλüලlink +* ˵const UINT16 wTrainId гID +* const UINT16 wLinkId link ID +* ֵ +* Created By LQ 2024.08.15 +*/ +void SetTrainPosMonitorInLink(const UINT16 wTrainId, const UINT16 wLinkId); + +/* +* ȡָгλüලlink +* ˵const UINT16 wTrainId гID +* ֵ1300 ȡʧ +* λüලlink +* Created By LQ 2024.08.15 +*/ +UINT16 GetTrainPosMonitorInLink(const UINT16 wTrainId); + +/* +* гλüල +* ˵ +* ֵ +* Created By LQ 2024.08.15 +*/ +void TrainPosMonitorProc(void); + +/* +* гλüලͨ +* ˵const UINT16 wTrainId гID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.18 +*/ +UINT8 TrainPosMonitorCommonCheck(const UINT16 wTrainId); + +/* +* гλüලʼ +* ˵const UINT16 wTrainId гID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.21 +*/ +UINT8 TrainPosMonitorBeginCheck(const UINT16 wTrainId); + +/* +* гλüල״̬飨߻Գߣ +* ˵const UINT16 wTrainId гID +* UINT16* pMonitorLinkId ලЧʱгlinkΣ +* UINT8* pMonitorFailState ලʧܺҪõ״̬Σ +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.21 +*/ +UINT8 ZXorSCXTrainPosMonitorCheck(const UINT16 wTrainId, UINT16* pMonitorLinkId, UINT8* pMonitorFailState); + +/* +* гλüල״̬ռü飨BG1 +* ˵const UINT16 wBGLinkId BG link ID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.18 +*/ +UINT8 BGTrainPosMonitorOccCheck(const UINT16 wBGLinkId); + +/* +* AGгBG˵ɸѡ־ǷЧ +* ˵const UINT16 wAGAxleSecId AGID +* const UINT16 wAGLinkId AG link ID +* const UINT16 wBGLinkId BG link ID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.18 +*/ +UINT8 CheckAGToBGTrainVirScreen(const UINT16 wAGAxleSecId, const UINT16 wAGLinkId, const UINT16 wBGLinkId); + +/* +* гλüල״̬ռü飨AG +* ˵const UINT16 wAGLinkId AG link ID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.18 +*/ +UINT8 AGTrainPosMonitorOccCheck(const UINT16 wAGLinkId); + +/* +* гλüල״̬飨Σ +* ˵const UINT16 wTrainId гID +* UINT16* pMonitorLinkId ලЧʱгlinkΣ +* UINT8* pMonitorFailState ලʧܺҪõ״̬Σ +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.21 +*/ +UINT8 CLDTrainPosMonitorCheck(const UINT16 wTrainId, UINT16* pMonitorLinkId, UINT8* pMonitorFailState); + +/* +* ߻ѹռü飨Σ +* ˵const UINT16 wSWLinkId ߻ѹlinkID +* ֵ0 ʧ +* 1 ɹ +* Created By LQ 2024.08.19 +*/ +UINT8 CLDSWAdjacentSecOccCheck(const UINT16 wSWLinkId); +/* +* гǰСABL־ +* ˵ +* ֵ +* Created By fan 2024.08.20 +*/ +void TrainPhyAblTagUpdate(void); + +/* +* BGԶɸѡAG UTռü +* ˵const UINT16 wLinkId BGlinkID +* ֵ0 ʧ +* 1 ɹ +* by cgh 20240903 +*/ +UINT8 BGAtsScreenAgUtCheck(const UINT16 wLinkId); + +/* +* ָгʼɳʼ +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwCycNum гʼɳʼ +* ֵ +* BY fan 20241017 +*/ +void SetTrainStartFlyProtectCycNum(const UINT16 wTrainId, const UINT32 dwCycNum); + +/* +* ָгʼɳʼ +* ˵ const UINT16 wTrainId, гID +* ֵ UINT32 гʼɳʼ +* BY fan 20241017 +*/ +UINT32 GetTrainStartFlyProtectCycNum(const UINT16 wTrainId); + +/** +* ӷɳ +* ˵UINT16 wTrainID UINT16 envelopeIdid +* ֵ +* BY fan 20241018 +*/ +void elm_AddFlyingTrain(UINT16 wTrainID, UINT16 envelopeId); + +/* +* ȡɳ +* ˵ +* ֵ UINT8 flyProtectTrainNum +* BY fan 20241018 +*/ +UINT8 GetFlyProtectNum(void); + +/* +* ȡɳ +* ˵UINT8 chIndex +* ֵ TrainFlyProtectStru* gFlyTrainData +* BY fan 20241018 +*/ +TrainFlyProtectStru * GetFlyProtectData(UINT8 chIndex); + +/** +* @brief ȡɳ崻 +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 GeFlyProtectTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex); + +/** +* @brief ÷ɳ崻 +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 SeFlyProtectTransferData(IN UINT8 *pDataBuff, IN UINT32 curIndex); + +/* +* ָгɳʼ +* ˵ const UINT16 wTrainId, гID +* const UINT32 dwCycNum гʼɳʼ +* ֵ +* by cgh 20241028 +*/ +void SetTrainFlyProStartCycNum(const UINT16 wTrainId, const UINT32 dwCycNum); + +/* +* ָгɢ״̬ +* ˵const UINT16 wTrainId гID +* const UINT8 chEaCmdState ɢ״̬ +* ֵ +* by cgh 20250310 +*/ +void SetTrainEaCmdState(const UINT16 wTrainId, const UINT8 chEaCmdState); + +/* +* ȡָгɢ״̬ +* ˵const UINT16 wTrainId гID +* ֵ0x55 ɢ״̬Ч +* 0xAA ɢ״̬Ч +* by cgh 20250310 +*/ +UINT8 GetTrainEaCmdState(const UINT16 wTrainId); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/APP/ciapp/Train/TrainDefine.h b/TSCP/src/APP/ciapp/Train/TrainDefine.h new file mode 100644 index 0000000..bdb35cb --- /dev/null +++ b/TSCP/src/APP/ciapp/Train/TrainDefine.h @@ -0,0 +1,245 @@ +/**************************************************************************************************** +* ļ : TrainDefine.h +* Ȩ˵ : ؿƼɷ޹˾ +* 汾 : 1.0 +* ʱ : 2021.06.15 +* : OC +* : гģ鶨ͷļ +* ʹע : +* +* ޸ļ¼ : +* +**************************************************************************************************/ +#ifndef TRAIN_DEFINE_H_ +#define TRAIN_DEFINE_H_ + +#ifdef __cplusplus + extern "C" +{ +#endif +#include "commontypes.h" + +#define TRAIN_SUM_MAX ((UINT8)255U) /*г*/ + +#define TRAIN_COMM_STATE_GOOD ((UINT8)0x55U) /*гͨ*/ +#define TRAIN_COMM_STATE_BAD ((UINT8)0xAAU) /*гͨв*/ +#define TRAIN_COMM_STATE_UNKNOWN ((UINT8)0xFFU) /*гͨ״̬δ֪*/ + +#define TRAIN_DIR_UP ((UINT8)0x55U) /*гзΪ*/ +#define TRAIN_DIR_DOWN ((UINT8)0xAAU) /*гзΪ*/ +#define TRAIN_DIR_DEF ((UINT8)0xffU) /*гзΪĬ*/ + +#define TRAIN_LEVEL_UR ((UINT8)0x03U) /*геȼUR*/ +#define TRAIN_LEVEL_ABL ((UINT8)0x04U) /*геȼABL*/ +#define TRAIN_LEVEL_VBTC ((UINT8)0x01U) /*геȼCBTC*/ +#define TRAIN_LEVEL_ITC ((UINT8)0x02U) /*геȼITC*/ + +#define TRAIN_LEVEL_BACKUP_LIANXU ((UINT8)0x01U) /*ʽгƼ*/ +#define TRAIN_LEVEL_BACKUP_BLOCK ((UINT8)0x02U) /*ʽгƼ*/ +#define TRAIN_LEVEL_BACKUP_CI ((UINT8)0x03U) /*Ƽ*/ +#define TRAIN_LEVEL_BACKUP_ABL ((UINT8)0x04U) /*ABLƼ*/ +#define TRAIN_LEVEL_BACKUP_UNKNOWN ((UINT8)0xFFU) /*ĬϿƼ*/ + +#define TRAIN_SPEED_DIR_FORWARD ((UINT8)0x55U) /*IVOCCIгٶȷǰ*/ +#define TRAIN_SPEED_DIR_BACKWARD ((UINT8)0xAAU) /*IVOCCIгٶȷ*/ + +#define TRAIN_ID_MIN ((UINT16)0x1400U) /*гIDСֵ*/ +#define TRAIN_ID_MAX ((UINT16)0x14FFU) /*гIDֵ*/ +#define TRAIN_ID_INVAL ((UINT16)0xFFFFU) /*гIDĬֵ*/ + +#define TRAIN_IN_CTRL_ZONE ((UINT8)0x55U) /*гڱ*/ +#define TRAIN_NOT_IN_CTRL_ZONE ((UINT8)0xAAU) /*гڱ*/ + +#define TRAIN_SPEED_BACK ((UINT8)0xAAu) /* г */ +#define TRAIN_SPEED_FRONT ((UINT8)0x55u) /* гǰ */ + +#define TRAIN_SPEED_ZERO_YES ((UINT8)0x55U) /*г*/ +#define TRAIN_SPEED_ZERO_NO ((UINT8)0xAAU) /*г*/ + +#define TRAIN_HEAD_FLAG_YES ((UINT8)0x55u) /*гȫͷڲͨҸòռ*/ +#define TRAIN_HEAD_FLAG_NO ((UINT8)0xAAu) /*гȫͷռҲͨIJ*/ + +#define CI_IVOC_HEAD_SCREEN_PASS ((UINT8)0x55U) /*гǰɸͨ*/ +#define CI_IVOC_HEAD_SCREEN_UNKNOW ((UINT8)0xAAU) /*гǰɸδͨ*/ + +#define CI_IVOC_TAIL_SCREEN_PASS ((UINT8)0x55U) /*гɸͨ*/ +#define CI_IVOC_TAIL_SCREEN_UNKNOW ((UINT8)0xAAU) /*гɸδͨ*/ + +#define VOBC_CI_GROUP_HEAD ((UINT8)0x55u) /*Ϊǰ*/ +#define VOBC_CI_GROUP_TAIL ((UINT8)0xAAu) /*Ϊ*/ +#define VOBC_CI_GROUP_INVAL ((UINT8)0x5Au) /*ΪDZ鳵*/ + +#define VOBC_CI_GROUP_NO (1u) /*DZ*/ +#define VOBC_CI_GROUP_SET (2u) /*齨*/ +#define VOBC_CI_GROUP_RUN (3u) /**/ +#define VOBC_CI_GROUP_REVERSE (4u) /*۷*/ +#define VOBC_CI_GROUP_EXIT (5u) /**/ + +#define MAX_TRAIN_ON_AC (10u) /* ռѹг */ +#define TOA_TYPE_CT (1u) /* CTг */ +#define TOA_TYPE_UT (2u) /* UTг */ +#define TOA_TYPE_INVALID (0u) /* гЧ */ +#define MAX_AC_IN_TRAIN (20u) /* гռѹ */ + +#define TRAIN_SLEEP_YES ((UINT8)0x55u) /* г״̬ */ +#define TRAIN_SLEEP_NO ((UINT8)0xaau) /* гδ״̬ */ + +#define TRAIN_MODE_DEFAULT ((UINT8)0) /*Ĭֵ*/ +#define TRAIN_MODE_RM ((UINT8)1) /*RMģʽ*/ +#define TRAIN_MODE_CM ((UINT8)2) /*CMģʽ*/ +#define TRAIN_MODE_AM ((UINT8)3) /*AMģʽ*/ +#define TRAIN_MODE_EUM ((UINT8)4) /*EUMģʽ*/ +#define TRAIN_MODE_RD ((UINT8)5) /*RDģʽ*/ +#define TRAIN_MODE_AR ((UINT8)6) /*ARģʽ*/ +#define TRAIN_MODE_FAM ((UINT8)7) /*FAMģʽ*/ +#define TRAIN_MODE_CAM ((UINT8)8) /*CAMģʽ*/ +#define TRAIN_MODE_RRM ((UINT8)9) /*RRMģʽ*/ +#define TRAIN_MODE_VCM ((UINT8)10) /*VCMģʽ*/ + +#define TRAIN_HEAD_CONFIRM_YES ((UINT8)0x55u) /*˹ǰɸȷ*/ +#define TRAIN_HEAD_CONFIRM_NO ((UINT8)0xffu) /*˹ǰɸδȷ(Ĭֵ)*/ + +#define TRAIN_TAIL_CONFIRM_YES ((UINT8)0x55u) /*˹ɸȷ*/ +#define TRAIN_TAIL_CONFIRM_NO ((UINT8)0xffu) /*˹ɸδȷ(Ĭֵ)*/ + +#define TRAIN_ATS_CONFIRM_YES ((UINT8)0x55u) /*Զɸѡȷ*/ +#define TRAIN_ATS_CONFIRM_NO ((UINT8)0xffu) /*Զɸѡδȷ(Ĭֵ)*/ + +#define TRAIN_WAKE_SUCCESS ((UINT8)1) /*гѳɹ*/ +#define TRAIN_WAKE_PROCESS ((UINT8)2) /*ѹ*/ +#define TRAIN_WAKE_FAILURE ((UINT8)3) /*ʧ*/ +#define TRAIN_WAKE_DEFAULT ((UINT8)255) /*Ĭֵ*/ + +#define TRAIN_CMD_DYM_YES ((UINT8)0x55u) /*ж̬*/ +#define TRAIN_CMD_DYM_NO ((UINT8)0xaau) /*޶̬*/ + +#define TRAIN_DYN_RPL_AGREE ((UINT8)0x55u) /*̬ͬ*/ +#define TRAIN_DYN_RPL_REFUSE ((UINT8)0xaau) /*̬Ծܾ*/ +#define TRAIN_DYN_RPL_FAILURE ((UINT8)0xccu) /*̬ʧ*/ +#define TRAIN_DYN_RPL_DEFAULT ((UINT8)0xffu) /*Ĭֵ*/ + +#define TRAIN_DYN_TEST_SUM_MAX ((UINT8)20u) /*̬ԿռС*/ + +#define TRAIN_SCREEN_DEFAULT ((UINT8)0x00u) /*ҪԶ/˹ɸѡ*/ +#define TRAIN_SCREEN_ATS ((UINT8)0x01u) /*Զɸѡ*/ +#define TRAIN_HEAD_SCREEN_IVOC ((UINT8)0x02u) /*˹ǰɸ*/ +#define TRAIN_TAIL_SCREEN_IVOC ((UINT8)0x03u) /*˹ɸ*/ +#define TRAIN_SCREEN_IVOC ((UINT8)0x04u) /*˹ɸѡ*/ + +#define TRAIN_SCREEN_TYPE_BK ((UINT8)1u) /*ؿɸѡ*/ +#define TRAIN_SCREEN_TYPE_LU ((UINT8)2u) /*ɸѡ*/ +#define TRAIN_SCREEN_TYPE_POSTION_LOST ((UINT8)3u) /*ලλЧɸѡ*/ + +#define TRAIN_SS_YES ((UINT8)0x55u) /*гͣ׼ͣ*/ +#define TRAIN_SS_NO ((UINT8)0xaau) /*гδͣ׼ͣ*/ + +#define TRAIN_SLEEP_CANCLE_YES ((UINT8)0x55u) /*߳*/ +#define TRAIN_SLEEP_CANCLE_NO ((UINT8)0xaau) /*߳*/ + +#define TRAIN_INCLUDE_RES_MAX_SUM ((UINT8)120U) /*г߼Դֵ*/ + +#define EA_SECTION_MAX_NUM ((UINT8)254u) /*ɢ*/ + +#define EA_PROTECT_BUILD 0x55U /* ɢ */ +#define EA_PROTECT_DEFAULT 0xFFU /* ɢЧ */ +#define EA_PROTECT_BUILD_Y 0x55U /* ͬ⽨ɢͣ */ +#define EA_PROTECT_BUILD_N 0xAAU /* ͬ⽨ɢͣ */ + +#define EA_IS_BUILDED 0x55u /* ɢѽ */ +#define EA_IS_NOT_BUILDED 0xAAu /* ɢδ */ + +#define EA_MAX_NUM 20u /* ɢ */ + +#define TRAIN_ABL_LOGSEC_SUM 100U /*ABLг°Ľ·ڵ߼*/ +#define TRAIN_ABL_RETURNLOGSEC_SUM 10U /*ABLгѯΧڵ۷߼*/ +#define TRAIN_ABL_SPKS_SUM 20U /*ABLгѯΧڵSPKS*/ +#define TRAIN_ABL_PSD_SUM 10U /*ABLгѯΧڵPSD*/ +#define TRAIN_ABL_ESB_SUM 10U /*ABLгѯΧڵESB*/ +#define TRAIN_ABL_SWITCH_SUM 100U /*ABLгѯΧڵĵ*/ +#define TRAIN_ABL_PROSEC_SUM 20U /*ABLгѯΧڵı*/ +#define TRAIN_ABL_XIANSUSEC_SUM 100U /*ABLгѯΧڵ*/ +#define TRAIN_ABL_FLOODGATE_SUM 10U /*ABLгѯΧڵķ*/ +#define TRAIN_ABL_ALLROUTE_SUM 10U /*ABLгǰӽԼµн·*/ + +#define TRAIN_ABL_ROUTE_FLAG_YES 0x55U /*ͺгĽ·Ϊ½·*/ +#define TRAIN_ABL_ROUTE_FLAG_NO 0xAAU /*ͺгĽ·Ϊ½·*/ + +#define TRAIN_ACTIVE_NONE 0u /* ޼ */ +#define TRAIN_ACTIVE_ONE 1u /* һ˼ */ +#define TRAIN_ACTIVE_TWO 2u /* ˼ */ +#define TRAIN_ACTIVE_ALL 3u /* ˫˼ */ + +#define TRAIN_RRM_RQST_YES 0x55u /* RRM */ +#define TRAIN_RRM_RQST_NO 0u /* */ + +#define TRAIN_RRM_YES 0x55u /* RRM */ +#define TRAIN_RRM_NO 0xaau /* RRM */ +#define TRAIN_RRM_DEFAULT 0xffu /* Ĭֵ */ + +/*510һ£ԭ˳*/ +#define TRAIN_RRM_RESON_02 0x02u /* ȫ߽ƶЧRRM */ +#define TRAIN_RRM_RESON_05 0x05u /* ڽ·δRRM */ +#define TRAIN_RRM_RESON_06 0x06u /* ״̬쳣RRM */ +#define TRAIN_RRM_RESON_07 0x07u /* SPKSRRM */ +#define TRAIN_RRM_RESON_08 0x08u /* EMP£RRM */ +#define TRAIN_RRM_RESON_09 0x09u /* վ̨״̬򿪣RRM */ +#define TRAIN_RRM_RESON_0A 0x0au /* 쳣RRM */ +#define TRAIN_RRM_RESON_0B 0x0bu /* յϢȷRRM */ +#define TRAIN_RRM_RESON_0C 0x0cu /* ڷŹرգRRM */ +#define TRAIN_RRM_RESON_0D 0x0du /* гǰѵվ̨RRM */ +#define TRAIN_RRM_RESON_0E 0x0eu /* гǰվ̨죬RRM */ +#define TRAIN_RRM_RESON_15 0x15u /* δTIOCRRMȨRRM */ +#define TRAIN_RRM_RESON_16 0x16u /* г\ǰ˿ɣRRM */ +#define TRAIN_RRM_RESON_17 0x17u /* гԤڲһ£RRM */ +#define TRAIN_RRM_RESON_FF 0xffu /* ĬֵʾRRMȨûв */ + +#define TRAIN_DERAIL_YES 0x55u /* гѹ */ +#define TRAIN_DERAIL_NO 0xaau /* гδѹ */ + + +#define TRAIN_RRM_OTHERCI_ALLOW 0x55u /* ԶRM-ĿTIOC*/ +#define TRAIN_RRM_OTHERCI_NOT_ALLOW 0xaau /* ԶRM-ĿTIOC*/ +#define TRAIN_RRM_LOCALCI_APPLY 0x55u /* ԶRM-ԴTIOC*/ +#define TRAIN_RRM_LOCALCI_NOT_APPLY 0xaau /* ԶRM-ԴTIOC*/ + +#define TRAIN_ITE_RESULT_YES 0xaau /* ITEʶΪг */ +#define TRAIN_ITE_RESULT_NO 0x55u /* ITEʶΪг */ + +#define TRAIN_NVRAM_POS_FLAG_YES 0x55u /* гʹNVRAMλ */ +#define TRAIN_NVRAM_POS_FLAG_NO 0xaau /* гδʹNVRAMλ */ + +#define HEAD_TRAIN_LOC_ATP 0x55u /*ǰλñʶ-ATP*/ +#define HEAD_TRAIN_LOC_ITE 0xaau /*ǰλñʶ-ITE*/ +#define HEAD_TRAIN_LOC_DEFAULT 0xffu /*ǰλñʶ-Ĭ*/ + +#define TRAIN_INC_ITE_SUM_MAX 2U /* гITEֵ */ + +#define TRAIN_LOC_REV_ROUTE_FLAG_NO 0x55u /*гλ÷·ʶ-гڷ·*/ +#define TRAIN_LOC_REV_ROUTE_FLAG_YES 0xaau /*гλ÷·ʶ-гڷ·*/ +#define TRAIN_LOC_REV_ROUTE_FLAG_NONE 0xffu /*гλ÷·ʶ-Ĭ*/ + +#define TRAIN_VIR_SCREEN_PASS_FLAG_VALID 0x55u /* гɸѡ־Ч */ +#define TRAIN_VIR_SCREEN_PASS_FLAG_INVALID 0xaau /* гɸѡ־Ч */ + +/*гλüල״̬*/ +#define TRAIN_POS_MONITOR_VALID (UINT8)0x55U /*гλüලЧ*/ +#define TRAIN_POS_MONITOR_INVALID (UINT8)0xAAU /*гλüලЧ*/ +#define TRAIN_POS_MONITOR_DIFF (UINT8)0xCCU /*гλüලһ*/ + +/*гɾ߳־*/ +#define TRAIN_DEL_SLEEP_ENV_VALID (UINT8)0x55U /*ɾ߳־Ч*/ +#define TRAIN_DEL_SLEEP_ENV_INVALID (UINT8)0xAAU /*ɾ߳־Ч*/ + + +#define TRAIN_FLYALARM_SECNUM_MAX (UINT8)5U /*гɳ*/ +#define SHUT_DOWN_TRAIN_NUMMAX (UINT8)253u /*ɳ崻гĿ*/ + +/*гɢ״̬*/ +#define TRAIN_EA_CMD_STATE_VALID (UINT8)0x55U /*гɢЧ*/ +#define TRAIN_EA_CMD_STATE_INVALID (UINT8)0xAAU /*гɢЧ*/ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Train/TrainOnAcManage.c b/TSCP/src/APP/ciapp/Train/TrainOnAcManage.c new file mode 100644 index 0000000..3a008e2 --- /dev/null +++ b/TSCP/src/APP/ciapp/Train/TrainOnAcManage.c @@ -0,0 +1,2922 @@ +#include "TrainOnAcManage.h" +#include "AxisSectionDataManage.h" +#include "ELMDataPrepare.h" +#include "AxisSort_api.h" +#include "ReverseCutDataManage.h" +#include "../IO/InputDataProcess.h" + +static AcMapStruct g_acMap[AXIS_SECTION_SUM_MAX] = { 0u }; /* ӳ */ +static UINT8 g_trainFlag[TRAIN_SUM_MAX] = { 0u }; +static UtTrainStruct g_utTrain[TRAIN_SUM_MAX] = { 0u }; +static UINT8 g_utTrainSum = 0u; +static UINT8 g_initStatus = TOA_INIT; +static ToaCmdStruct g_cmdStr[TOA_CMD_MAX] = { 0u }; +static UINT8 g_cmdNum = 0u; + +/** +* @brief ˢͨųռ +* @param +* @return +* @note +*/ +static void ToaRefreshCt(void); + +/** +* @brief ˢ·ͨųռ +* @param +* @return +* @note +*/ +static void ToaRefreshUt(void); + +/** +* @brief ɾԪ +* @param wAcIndex ӳ± +* @param wTrainId гID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaDeleteAcMapElm(UINT16 wAcIndex, UINT16 wTrainId); + +/** +* @brief Ԫ +* @param wAcIndex ӳ± +* @param wTrainId гID +* @param chType г +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaAddAcMapElm(UINT16 wAcIndex, UINT16 wTrainId, UINT8 chType); + +/** +* @brief ȡгռѹ +* @param wTrainId гID +* @param szAcId гռѹ +* @return гռѹ +* @note +*/ +static UINT8 ToaGetAcInTrain(UINT16 wTrainId, UINT16 szAcId[MAX_AC_IN_TRAIN]); + +/** +* @brief ȡгȫλ +* @param wTrainId гID +* @param szAcId гռѹ +* @return гռѹ +* @note +*/ +static UINT8 ToaGetTrainLoc(UINT16 wTrainId, TrainLocStruct * pLoc); + +/** +* @brief ӹϳ +* @param wTrainId гID +* @param chDir UTг +* @param szAcId гռѹ +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaAddUtTrain(UINT16 wTrainId, UINT8 chDir, UINT8 chAcNum, UINT16 szAcId[MAX_AC_IN_TRAIN]); + +/** +* @brief ɾϳ +* @param wTrainId гID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaDeleteUtTrain(UINT16 wTrainId); + +/** +* @brief ϳ۷ +* @param +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaUtReturnProc(void); + +/** +* @brief ϳ۷ִ +* @param wTrainIndex ϳ洢± +* @return +* @note +*/ +static void ToaReturnExc(UINT8 chTrainIndex); + +/** +* @brief ռ +* @param +* @return +* @note +*/ +static void ToaUtPathCal(void); + +/** +* @brief жUTռ·Ƿܽ +* @param[in] chTrainIndex UTг洢± +* @return CI_SUCCESS:ܽ㣻CI_ERROR:ܽ +* @note +*/ +static UINT8 IsUtPathCanExtend(UINT8 chTrainIndex); + +/** +* @brief Aǰ +* @param[in] const TrainLocStruct* pTrainA гA +* @param[in] const TrainLocStruct* pTrainB гB +* @param[in] chDir +* @return CI_SUCCESS:AǰCI_ERROR:Aδǰжϲ +* @note +*/ +static UINT8 ToaIsAFront(IN const TrainLocStruct* pTrainA, UINT8 chDir, IN const TrainLocStruct* pTrainB); + +/** +* @brief ȡUTгͨں +* @param wTrainId гID +* @return ں +* @note +*/ +static UINT32 ToaGetBreakCyc(UINT16 wTrainId); + +/** +* @brief UTгͷ׷ռѹ +* @param wTrainId гID +* @param wAcId ID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaAddUtTrainAc(UINT16 wTrainId, UINT16 wAcId); + +/** +* @brief  +* @note +*/ +static void ToaCmdProc(void); + +/* +* @brief ùгռѹ +* @param const UINT16 wPhySecId ID +* const UINT16 wTrainId г +* const UINT16 wTrainDir г +* @note lxc 20220617 +*/ +static void SetBreakPhySecWithTrainInfo(const UINT16 wPhySecId, const UINT16 wTrainId, const UINT8 chDir); +/* +* @brief ȡгռѹ +* @param const UINT16 wPhySecId ID +* const UINT16 wTrainId г +* const UINT16 wTrainDir г +* @note lxc 20220617 +*/ +static void UnLockBreakPhySecWithTrainInfo(const UINT16 wPhySecId, const UINT16 wTrainId, const UINT8 cTrainDir); + +/** +* @brief ˢUTռѹУATS˹ʱʹã +* @param wTrainId гID +* @param chDir UTг +* @param chAcNum +* @param szAcId ID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaRefreshUtTrainAc(UINT16 wTrainId, UINT8 chDir, UINT8 chAcNum, UINT16 szAcId[MAX_AC_IN_TRAIN]); + +/** +* @brief жϼǷ +* @param wTrainId гID +* @param cAcSum +* @param pAcIdBuf ID +* @return CI_ERROR:ռãCI_SUCCESS: +* @note +*/ +static UINT8 IsAcListFreeToSet(UINT16 wTrainId, UINT8 cAcSum, UINT16* pAcIdBuf); + +/** +* @brief ȡǰTIOCеͨųгID +* @param[out] szTrainId гID +* @return TIOCΧͨг +*/ +static UINT8 ToaGetCommTrainId(UINT16 szTrainId[TRAIN_SUM_MAX_IN_OC]); + +/** +* @brief ȡǰTIOCеĶʧͨųгID +* @param[out] szTrainId гID +* @return TIOCΧڷͨг +*/ +static UINT8 ToaGetLoseCommTrainId(UINT16 szTrainId[TRAIN_SUM_MAX_IN_OC]); + +/** +* @brief ޹ϳж +* @param wAcIndex δ洢± +* @return CI_ERROR:ڹϳCI_SUCCESS:ڹϳ +* @note +*/ +static UINT8 IsAcHaveNoBadTrain(UINT16 wAcIndex); + +/** +* @brief ȡUTг洢 +* @param wTrainId гID +* @return TRAIN_SUM_MAX_IN_OC:ʧܣ: +* @note +*/ +static UINT8 ToaGetUtIndex(UINT16 wTrainId); + +/** +* @brief ɾUTгβɼд +* @param +* @return +* @note +*/ +static void ToaDeleteUtTrainTailFreeAc(void); + +/** +* @brief UTгǷڼ +* @param wTrainId гID +* @param wAcId ID +* @return CI_SUCCESS:гڼϣCI_ERROR:гδڼ +* @note +*/ +static UINT8 IsUtTrainOnAc(UINT16 wTrainId, UINT16 wAcId); + +/** +* @brief Ϣӡ +* @param +* @return +*/ +static void ToaDebugInfo(void); + +/** +* @brief жϼǷܹ +* @param wTrainId гID +* @param wAcId +* @return CI_ERROR:ãCI_SUCCESS:ܹ +* @note +*/ +static UINT8 IsAcFreeToSet(UINT16 wTrainId, UINT16 wAcId); + +/** +* @brief ģʼ +* @param +* @return CI_SUCCESS:ʼɹCI_ERRORʼʧ +* @note +*/ +UINT8 ToaInit(void) +{ + UINT8 chRtn = CI_ERROR; + UINT16 * pAcId = NULL; + UINT16 wAcSum = 0u; + UINT16 wIndex = 0u; + + g_utTrainSum = 0u; + chRtn = CommonMemSet(g_trainFlag, TRAIN_SUM_MAX, FLAG_UNSET, TRAIN_SUM_MAX); + chRtn &= CommonMemSet(g_acMap, (UINT32)(sizeof(AcMapStruct) * AXIS_SECTION_SUM_MAX), 0u, (UINT32)(sizeof(AcMapStruct) * AXIS_SECTION_SUM_MAX)); + chRtn &= CommonMemSet(g_utTrain, (UINT32)(sizeof(UtTrainStruct) * TRAIN_SUM_MAX), 0u , (UINT32)(sizeof(UtTrainStruct) * TRAIN_SUM_MAX)); + chRtn &= CommonMemSet(g_cmdStr, (UINT32)(sizeof(ToaCmdStruct) * TOA_CMD_MAX), 0u , (UINT32)(sizeof(ToaCmdStruct) * TOA_CMD_MAX)); + g_cmdNum = 0u; + g_initStatus = TOA_INIT; + wAcSum = elm_PrepareACBuffIndexs(&pAcId); + /* мΪϳ255ռ */ + if ((CI_SUCCESS == chRtn) && (NULL != pAcId)) + { + for (wIndex = 0u; wIndex < wAcSum; wIndex++) + { + chRtn &= ToaAddAcMapElm(pAcId[wIndex], TRAIN_SUM_MAX, TOA_TYPE_UT); + } + } + else + { + chRtn = CI_ERROR; + } + return chRtn; +} + +/** +* @brief ģ +* @param +* @return +* @noteӳʼ״̬ת +*/ +void ToaUnlock(void) +{ + UINT16 * pAcId = NULL; + UINT16 wAcSum = 0u; + UINT16 wIndex = 0u; + + /* λִУ + 1255ռã + 2ģΪ״̬*/ + wAcSum = elm_PrepareACBuffIndexs(&pAcId); + if (NULL != pAcId) + { + for (wIndex = 0u; wIndex < wAcSum; wIndex++) + { + (void)ToaDeleteAcMapElm(pAcId[wIndex], TRAIN_SUM_MAX); + } + g_initStatus = TOA_NORMAL; + } + else + { + ; + } +} + +/** +* @brief ģ +* @param +* @return +* @note +*/ +void ToaMainProc(void) +{ + /* ˢCTռ */ + ToaRefreshCt(); + + /* ˢUTռ */ + ToaRefreshUt(); + + /* ά־ӡ */ + ToaDebugInfo(); +} + +/** +* @brief ˢͨųռ +* @param +* @return +* @note +*/ +static void ToaRefreshCt(void) +{ + UINT16 wAcIndex = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chCtTrainNum = 0u; + UINT16 szTrainId[TRAIN_SUM_MAX_IN_OC] = { 0u }; + UINT8 chAcNum = 0u; + UINT16 szAcId[MAX_AC_IN_TRAIN] = { 0u }; + UINT8 chAcIndex = 0u; + UINT16 wPhyId = 0u; + UINT8 chIndex = 0u; + + /* һͨųռ */ + for (wAcIndex = 0u; wAcIndex < AXIS_SECTION_SUM_MAX; wAcIndex++) + { + if (0u < g_acMap[wAcIndex].chTrainNum) + { + for (chTrainIndex = (g_acMap[wAcIndex].chTrainNum - 1u); 0u <= chTrainIndex; chTrainIndex--) /*0u <= chTrainIndexжж*/ + { + if ((TOA_TYPE_CT == g_acMap[wAcIndex].strTrain[chTrainIndex].chTrainType)) + { + (void)ToaDeleteAcMapElm(wAcIndex, g_acMap[wAcIndex].strTrain[chTrainIndex].wTrainId); + } + else + { + ; /* */ + } + if (0u == chTrainIndex) + { + break; + } + else + { + ; + } + } + } + else + { + ; + } + } + + /* ڶͨųͨų䵽 */ + chCtTrainNum = ToaGetCommTrainId(szTrainId); + for (chTrainIndex = 0u; chTrainIndex < chCtTrainNum; chTrainIndex++) + { + chIndex = (UINT8)(szTrainId[chTrainIndex] & 0x00ffu); + if (FLAG_SET == g_trainFlag[chIndex]) + { + (void)ToaDeleteUtTrain(szTrainId[chTrainIndex]); + } + else + { + ; + } + + chAcNum = ToaGetAcInTrain(szTrainId[chTrainIndex], szAcId); + for (chAcIndex = 0u; chAcIndex < chAcNum; chAcIndex++) + { + wPhyId = GetAxisSecRelativePhySecId(szAcId[chAcIndex]); + SetPhySecCurOccupyState(wPhyId, SECTION_OCCUPY_YES); + (void)ToaAddAcMapElm(szAcId[chAcIndex], szTrainId[chTrainIndex], TOA_TYPE_CT); + } + } +} + +/** +* @brief ˢ·ͨųռ +* @param +* @return +* @note +*/ +static void ToaRefreshUt(void) +{ + UINT8 chUtTrainNum = 0u; + UINT16 szTrainId[TRAIN_SUM_MAX_IN_OC] = { 0u }; + UINT8 chTrainIndex = 0u; + UINT8 chAcNum = 0u; + UINT16 szAcId[MAX_AC_IN_TRAIN] = { 0u }; + UINT8 chAcIndex = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT8 chDir = 0u; + UINT8 chIndex = 0u; + + /* һڶͨŵĽ䵽 */ + chUtTrainNum = ToaGetLoseCommTrainId(szTrainId); + for (chTrainIndex = 0u; chTrainIndex < chUtTrainNum; chTrainIndex++) + { + chIndex = (UINT8)(szTrainId[chTrainIndex] & 0x00ffu); + if (FLAG_UNSET == g_trainFlag[chIndex]) + { + chDir = GetTrainDir(szTrainId[chTrainIndex]); + chAcNum = ToaGetAcInTrain(szTrainId[chTrainIndex], szAcId); + if ((0u < chAcNum) && (MAX_AC_IN_TRAIN >= chAcNum)) + { + chFunRtn = ToaAddUtTrain(szTrainId[chTrainIndex], chDir, chAcNum, szAcId); + if (CI_SUCCESS == chFunRtn) + { + for (chAcIndex = 0u; chAcIndex < chAcNum; chAcIndex++) + { + (void)ToaAddAcMapElm(szAcId[chAcIndex], szTrainId[chTrainIndex], TOA_TYPE_UT); + } + } + else + { + ; + } + } + else + { + ; + } + } + else + { + ; /* Ϊгɳʼ */ + } + } + + /* ڶԶβɼ */ + ToaDeleteUtTrainTailFreeAc(); + + /*  */ + ToaCmdProc(); + + /* IJ۷ */ + (void)ToaUtReturnProc(); + + /* 岽 */ + ToaUtPathCal(); +} + +/** +* @brief ɾԪ +* @param wAcIndex ӳ± +* @param wTrainId гID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaDeleteAcMapElm(UINT16 wAcIndex, UINT16 wTrainId) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chTrainIndex = 0u; + UINT8 chIndex = 0u; + + if ((0u != wTrainId) && (AXIS_SECTION_SUM_MAX > wAcIndex)) + { + for (chTrainIndex = 0u; chTrainIndex < g_acMap[wAcIndex].chTrainNum; chTrainIndex++) + { + if (wTrainId == g_acMap[wAcIndex].strTrain[chTrainIndex].wTrainId) + { + g_acMap[wAcIndex].strTrain[chTrainIndex].wTrainId = 0u; + g_acMap[wAcIndex].strTrain[chTrainIndex].chTrainType = TOA_TYPE_INVALID; + break; + } + } + + if (chTrainIndex == g_acMap[wAcIndex].chTrainNum) + { + ; /* ޶Ӧг */ + } + else if (chTrainIndex == (g_acMap[wAcIndex].chTrainNum - 1u)) + { + /* ɾԪһԪ */ + g_acMap[wAcIndex].chTrainNum--; + chRtn = CI_SUCCESS; + } + else + { + for (chIndex = chTrainIndex; chIndex < (g_acMap[wAcIndex].chTrainNum - 1u); chIndex++) + { + g_acMap[wAcIndex].strTrain[chIndex].wTrainId = g_acMap[wAcIndex].strTrain[chIndex + 1u].wTrainId; + g_acMap[wAcIndex].strTrain[chIndex].chTrainType = g_acMap[wAcIndex].strTrain[chIndex + 1u].chTrainType; + } + g_acMap[wAcIndex].chTrainNum--; + chRtn = CI_SUCCESS; + } + } + else + { + ; /* βϷ */ + } + + debug_infor_printf((const)"Toa ac:%d delete train:%x\n", wAcIndex, wTrainId); + + return chRtn; +} + +/** +* @brief Ԫ +* @param wAcIndex ӳ± +* @param wTrainId гID +* @param chType г +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaAddAcMapElm(UINT16 wAcIndex, UINT16 wTrainId, UINT8 chType) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chTrainIndex = 0u; + + for (chTrainIndex = 0u; chTrainIndex < g_acMap[wAcIndex].chTrainNum; chTrainIndex++) + { + if (wTrainId == g_acMap[wAcIndex].strTrain[chTrainIndex].wTrainId) + { + /* гڸü */ + break; + } + } + + if ((chTrainIndex == g_acMap[wAcIndex].chTrainNum) && (MAX_TRAIN_ON_AC > g_acMap[wAcIndex].chTrainNum)) + { + /* Ԫ */ + g_acMap[wAcIndex].strTrain[chTrainIndex].wTrainId = wTrainId; + g_acMap[wAcIndex].strTrain[chTrainIndex].chTrainType = chType; + g_acMap[wAcIndex].chTrainNum++; + chRtn = CI_SUCCESS; + debug_infor_printf((const)"Toa ac:%d add train:%x type:%d\n", wAcIndex, wTrainId, chType); + } + else + { + ; /* гڸü */ + } + return chRtn; +} + +/** +* @brief ȡгռѹ +* @param wTrainId гID +* @param szAcId гռѹ +* @return гռѹ +* @noteڲŻ 20220808 μ +*/ +static UINT8 ToaGetAcInTrain(UINT16 wTrainId, UINT16 szAcId[MAX_AC_IN_TRAIN]) +{ + LOD_STRU strStart = { 0u }; + LOD_STRU strEnd = { 0u }; + UINT8 chRtn = 0u; + + /** μ*/ + if (NULL != szAcId) + { + strEnd.Lnk = GetTrainSafeHeadLink(wTrainId); + strEnd.Off = GetTrainSafeHeadOffset(wTrainId); + strEnd.Dir = GetTrainSafeHeadDir(wTrainId); + strStart.Lnk = GetTrainSafeTailLink(wTrainId); + strStart.Off = GetTrainSafeTailOffset(wTrainId); + strStart.Dir = GetTrainSafeTailDir(wTrainId); + + chRtn = elm_PrepareACBtwPoints(strStart, strEnd, szAcId); + } + else + { + chRtn = 0u; + } + + return chRtn; +} + +/** +* @brief ȡгȫλ +* @param wTrainId гID +* @param szAcId гռѹ +* @return гռѹ +* @note +*/ +static UINT8 ToaGetTrainLoc(UINT16 wTrainId, TrainLocStruct * pLoc) +{ + UINT8 chRtnVal = CI_ERROR; + UINT16 wTrainID = (UINT16)(0x1400u + (wTrainId & 0x00ffu)); + + if (NULL != pLoc) + { + pLoc->startPos.Lnk = GetTrainSafeTailLink(wTrainID); + pLoc->startPos.Off = GetTrainSafeTailOffset(wTrainID); + pLoc->startPos.Dir = GetTrainSafeTailDir(wTrainID); + pLoc->endPos.Lnk = GetTrainSafeHeadLink(wTrainID); + pLoc->endPos.Off = GetTrainSafeHeadOffset(wTrainID); + pLoc->endPos.Dir = GetTrainSafeHeadDir(wTrainID); + chRtnVal = CI_SUCCESS; + } + return chRtnVal; +} + +/** +* @brief ӹϳ +* @param wTrainId гID +* @param chDir UTг +* @param szAcId гռѹ +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @noteڲŻ 20220808 μ +*/ +static UINT8 ToaAddUtTrain(UINT16 wTrainId, UINT8 chDir, UINT8 chAcNum, UINT16 szAcId[MAX_AC_IN_TRAIN]) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + + /** μ*/ + if (NULL != szAcId) + { + if (((DIR_SAME == chDir) || (DIR_CONVERT == chDir)) && (0u != wTrainId) && (TRAIN_SUM_MAX > g_utTrainSum)) + { + g_utTrain[g_utTrainSum].wTrainId = wTrainId; + g_utTrain[g_utTrainSum].dwUtCyc = Get2oo2CurCycleNum(); + g_utTrain[g_utTrainSum].chDir = chDir; + g_utTrain[g_utTrainSum].chAcNum = chAcNum; + chRtn = CommonMemCpy(g_utTrain[g_utTrainSum].szAcId, (UINT32)(sizeof(UINT16) * chAcNum), szAcId, (UINT32)(sizeof(UINT16) * chAcNum)); + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + chIndex = (UINT8)(wTrainId & 0x00ffu); + if (TRAIN_SUM_MAX > chIndex) + { + g_trainFlag[chIndex] = FLAG_SET; + g_utTrainSum++; + debug_infor_printf((const)"Toa add ut train:%x\n", wTrainId); + } + else + { + chRtn = CI_ERROR; + } + } + else + { + ; + } + } + else + { + chRtn = CI_ERROR; + } + + return chRtn; +} + +/** +* @brief ɾϳ +* @param wTrainId гID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaDeleteUtTrain(UINT16 wTrainId) +{ + UINT8 chTrainIndex = 0u; + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + UINT16 wAcIndex = 0u; + UINT8 chCommState = 0u; + + if (0u != wTrainId) + { + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + if (wTrainId == g_utTrain[chTrainIndex].wTrainId) + { + break; + } + } + + if (chTrainIndex == g_utTrainSum) + { + ; /* ûҵý */ + } + else if (chTrainIndex == (g_utTrainSum - 1u)) + { + /* һԪֱɾ */ + g_utTrainSum--; + chRtn = CI_SUCCESS; + } + else + { + for (chIndex = chTrainIndex; chIndex < (g_utTrainSum - 1u); chIndex++) + { + g_utTrain[chIndex].wTrainId = g_utTrain[chIndex + 1u].wTrainId; + g_utTrain[chIndex].dwUtCyc = g_utTrain[chIndex + 1u].dwUtCyc; + g_utTrain[chIndex].chDir = g_utTrain[chIndex + 1u].chDir; + g_utTrain[chIndex].chAcNum = g_utTrain[chIndex + 1u].chAcNum; + (void)CommonMemCpy(g_utTrain[chIndex].szAcId, (UINT32)(sizeof(UINT16) * MAX_AC_IN_TRAIN), g_utTrain[chIndex + 1u].szAcId, (UINT32)(sizeof(UINT16) * MAX_AC_IN_TRAIN)); + } + g_utTrainSum--; + chRtn = CI_SUCCESS; + debug_infor_printf((const)"Toa delete ut train:%x\n", wTrainId); + } + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + /* ռѹϢ */ + for (wAcIndex = 0u; wAcIndex < AXIS_SECTION_SUM_MAX; wAcIndex++) + { + for (chTrainIndex = 0u; chTrainIndex < g_acMap[wAcIndex].chTrainNum; chTrainIndex++) + { + if (g_acMap[wAcIndex].strTrain[chTrainIndex].wTrainId == wTrainId) + { + (void)ToaDeleteAcMapElm(wAcIndex, g_acMap[wAcIndex].strTrain[chTrainIndex].wTrainId); + break; + } + } + } + chIndex = (UINT8)(wTrainId & 0x00ffu); + g_trainFlag[chIndex] = FLAG_UNSET; + chCommState = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_BAD == chCommState) + { + (void)SetTrainTransmitStat(wTrainId, TRAIN_COMM_STATE_UNKNOWN); + } + else + { + ; + } + } + else + { + ; + } + + return chRtn; +} + +/** +* @brief ϳ۷ +* @param +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaUtReturnProc(void) +{ + UINT8 chTrainIndex = 0u; + UINT16 wAcId = 0u; + UINT16 wRouteId = 0u; + UINT8 chRouteType = 0u; + UINT16 wPhyId = 0u; + UINT16 wLastPhyId = 0u; + UINT16 wReturnSignalSum = 0u; + UINT16 * pReturnSignalId = NULL; + UINT16 wIndex = 0u; + UINT8 chState = 0u; + UINT8 chNeedReturn = FLAG_UNSET; + UINT8 chRtn = CI_ERROR; + UINT8 chDir = 0u; + UINT8 SignalCurColor = 0u; /*ָIDźŻǰʾɫ*/ + + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + chNeedReturn = FLAG_UNSET; + wAcId = g_utTrain[chTrainIndex].szAcId[0]; + wPhyId = GetAxisSecRelativePhySecId(wAcId); + wRouteId = GetPhySecRLockBelongRouteId(wPhyId); + chRouteType = GetRouteType(wRouteId); + wLastPhyId = GetRouteLastPhySectionId(wRouteId); + if ((ROUTE_TYPE_RETURN == chRouteType) && (wPhyId == wLastPhyId)) + { + wReturnSignalSum = GetRouteReturnSignalSum(wRouteId); + pReturnSignalId = GetRouteReturnSignalIdBuf(wRouteId); + if (NULL != pReturnSignalId) + { + for (wIndex = 0u; wIndex < wReturnSignalSum; wIndex++) + { + SignalCurColor = GetSignalCurColor(pReturnSignalId[wIndex]); + chState = GetSignalOpenCloseState(SignalCurColor); + if (SIGNAL_OPEN == chState) + { + break; + } + else + { + ; + } + } + if (wIndex < wReturnSignalSum) + { + chDir = GetSignalDirection(pReturnSignalId[wIndex]); + if (chDir != g_utTrain[chTrainIndex].chDir) + { + chNeedReturn = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + } + else + { + break; + } + } + else + { + ; + } + + if (FLAG_SET == chNeedReturn) + { + ToaReturnExc(chTrainIndex); + } + else + { + ; /* */ + } + } + if (chTrainIndex < g_utTrainSum) + { + ; + } + else + { + chRtn = CI_SUCCESS; + } + + return chRtn; +} + +/** +* @brief ϳ۷ִ +* @param wTrainIndex ϳ洢± +* @return +* @note +*/ +static void ToaReturnExc(UINT8 chTrainIndex) +{ + UINT8 chAcNum = 0u; + UINT16 szTemp[MAX_AC_IN_TRAIN] = { 0u }; + UINT8 chIndex = 0u; + chAcNum = g_utTrain[chTrainIndex].chAcNum; + for (chIndex = 0u; chIndex < chAcNum; chIndex++) + { + szTemp[chIndex] = g_utTrain[chTrainIndex].szAcId[chAcNum - chIndex - 1u]; + } + debug_infor_printf((const)"ut train:%x return\n", g_utTrain[chTrainIndex].wTrainId); + g_utTrain[chTrainIndex].chDir = ~g_utTrain[chTrainIndex].chDir; + if (MAX_AC_IN_TRAIN > chAcNum) + { + (void)CommonMemCpy(g_utTrain[chTrainIndex].szAcId, (UINT32)(sizeof(UINT16) * chAcNum), szTemp, (UINT32)(sizeof(UINT16) * chAcNum)); + } + else + { + ; /*ϢڿĿռ䣬п*/ + } +} + +/** +* @brief ռ +* @param +* @return +* @note +*/ +static void ToaUtPathCal(void) +{ + UINT8 chTrainIndex = 0u; + UINT8 chFunRtn = CI_ERROR; + UINT16 wAcId = 0u; + UINT16 wNextAcId = 0u; + UINT16 wNextPhyId = 0u; + UINT16 wRLockRouteId = 0U; + UINT16 wPLockRouteId = 0U; + UINT8 chAcNum = 0u; + UINT8 chNextAcNum = 0u; + UINT16 szNextAcId[AC_MAXCNT_IN_SWITCH] = { 0u }; + UINT8 chDir = 0u; + UINT8 chLockDir = 0U; + UINT8 chLockState = 0u; + UINT8 chLogicNum = 0u; + UINT16 *pLogicId = NULL; + LogicTrainResStruct * pstLogicResTrainInfo = NULL; + UINT8 chResShareFlag = 0u; + UINT8 chLogIndex = 0u; + UINT8 chLinkLogicDirUpAndDown = 0U; + UINT16 wTrainId = 0u; + UINT8 cDirectionPointFlag = 0U; /*Ƿз仯־*/ + + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + do + { + /* гж */ + chFunRtn = IsUtPathCanExtend(chTrainIndex); + if (CI_SUCCESS == chFunRtn) + {/* UT죬ȡһ */ + wTrainId = g_utTrain[chTrainIndex].wTrainId; + chAcNum = g_utTrain[chTrainIndex].chAcNum; + wAcId = g_utTrain[chTrainIndex].szAcId[chAcNum - 1u]; + chDir = g_utTrain[chTrainIndex].chDir; + chNextAcNum = elm_PrepareAdjacentAC(wAcId, chDir, szNextAcId, &cDirectionPointFlag); + if ((0u == chNextAcNum) || (UINT8_MAX == chNextAcNum)) + { + chFunRtn = CI_ERROR; + } + else + { + + } + } + else + { + ;/* 죬һUT */ + } + + if (CI_SUCCESS == chFunRtn) + {/* һաշж */ + wNextAcId = szNextAcId[0]; + wNextPhyId = GetAxisSecRelativePhySecId(wNextAcId); + chLockState = GetPhySecLockState(wNextPhyId); + chLockDir = GetPhySecLockDirection(wNextPhyId); + + if (chLinkLogicDirUpAndDown == chLockDir) + { + chLockDir = DIR_CONVERT; + } + else + { + chLockDir = DIR_SAME; + } + + if ((PHYSICAL_SECTION_LOCK_NORMAL == chLockState) || (PHYSICAL_SECTION_LOCK_PROTECT == chLockState)) + { + if (chLockDir == chDir) + { + ; + } + else + { + chFunRtn = CI_ERROR; + } + } + else + { + chFunRtn = CI_ERROR; + } + } + else + { + ; + } + + /* ûгռ */ + if (CI_SUCCESS == chFunRtn) + { + chFunRtn = IsAcFree(wNextAcId); + } + else + { + ; + } + + if (CI_SUCCESS == chFunRtn) + {/* иóԴΪԴ */ + chLogicNum = GetAxisSecLogSectionSum(wNextAcId); + pLogicId = GetAxisSecLogSectionIdBuf(wNextAcId); + if ((0u != chLogicNum) && (NULL != pLogicId)) + { + for (chLogIndex = 0u; chLogIndex < chLogicNum; chLogIndex++) + { + pstLogicResTrainInfo = GetLogSecTrainInfoById(pLogicId[chLogIndex], wTrainId); + chResShareFlag = GetLogSecResShareFlag(pLogicId[chLogIndex]); + if ((NULL != pstLogicResTrainInfo) || + (LOGIC_SECTION_RES_SHARE_YES == chResShareFlag)) + { + break; + } + else + { + ; + } + } + + if (chLogIndex < chLogicNum) + { + chFunRtn = CI_SUCCESS; + } + else + { + chFunRtn = CI_ERROR; + } + } + else + { + chFunRtn = CI_ERROR; + } + } + else + { + ; + } + + /* ִ */ + if (CI_SUCCESS == chFunRtn) + { + if (MAX_AC_IN_TRAIN > chAcNum) + { + (void)ToaAddUtTrainAc(wTrainId, wNextAcId); + } + else + { + ; + } + } + else + { + ; + } + }while (CI_SUCCESS == chFunRtn); + } +} + +/** +* @brief жUTռ·Ƿܽ +* @param[in] chTrainIndex UTг洢± +* @return CI_SUCCESS:ܽ㣻CI_ERROR:ܽ +* @note +*/ +static UINT8 IsUtPathCanExtend(UINT8 chTrainIndex) +{ + UINT8 chRtn = CI_ERROR; + UINT16 wAcId = 0u; + UINT8 chIndex = 0u; + TrainLocStruct strBase = { 0u }; + TrainLocStruct strTemp = { 0u }; + UINT8 chCommState = 0u; + UINT32 dwCyc = 0u; + UINT32 dwSysCyc = 0u; + + wAcId = g_utTrain[chTrainIndex].szAcId[g_utTrain[chTrainIndex].chAcNum - 1u]; + + chRtn = IsAcFree(wAcId); + if(CI_SUCCESS == chRtn) + { + (void)ToaInit(); + } + else + { + if ((AXIS_SECTION_SUM_MAX > wAcId) && + (1u == g_acMap[wAcId].chTrainNum) && (g_utTrain[chTrainIndex].wTrainId == g_acMap[wAcId].strTrain[0].wTrainId)) + {/* νһг */ + chRtn = CI_SUCCESS; + } + else if (1u == g_acMap[wAcId].chTrainNum) + { + /* 쳣֧ */ + (void)ToaInit(); + } + else + { + dwSysCyc = Get2oo2CurCycleNum(); + if (dwSysCyc == g_utTrain[chTrainIndex].dwUtCyc) + { + chRtn = CI_SUCCESS; + } + else + { + chRtn = CI_ERROR; + } + + /* гȫλûȡ */ + chRtn &= ToaGetTrainLoc(g_utTrain[chTrainIndex].wTrainId, &strBase); + if (CI_SUCCESS == chRtn) + { + for (chIndex = 0u; chIndex < g_acMap[wAcId].chTrainNum; chIndex++) + { + if (g_acMap[wAcId].strTrain[chIndex].wTrainId == g_utTrain[chTrainIndex].wTrainId) + { + ; + } + else + { + chCommState = GetTrainTransitmitStat(g_acMap[wAcId].strTrain[chIndex].wTrainId); + if (TRAIN_COMM_STATE_BAD == chCommState) + { + dwCyc = ToaGetBreakCyc(g_acMap[wAcId].strTrain[chIndex].wTrainId); + } + else + { + ; + } + if ((TRAIN_COMM_STATE_GOOD == chCommState) || (dwSysCyc == dwCyc)) + { + chRtn = ToaGetTrainLoc(g_acMap[wAcId].strTrain[chIndex].wTrainId, &strTemp); + chRtn &= ToaIsAFront(&strBase, strBase.startPos.Dir, &strTemp); + } + else + { + chRtn = CI_ERROR; + } + if(CI_ERROR == chRtn) + { + break; + } + else + { + ; + } + } + } + } + else + { + ; + } + } + } + return chRtn; +} + +/** +* @brief Aǰ +* @param[in] const TrainLocStruct* pTrainA гA +* @param[in] const TrainLocStruct* pTrainB гB +* @param[in] chDir +* @return CI_SUCCESS:AǰCI_ERROR:Aδǰжϲ +* @note +*/ +static UINT8 ToaIsAFront(IN const TrainLocStruct* pTrainA, UINT8 chDir, IN const TrainLocStruct* pTrainB) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chFunRtn = 0u; + if ((NULL == pTrainA) || (NULL == pTrainB)) + { + /** ڲ*/ + } + else if ((EMAP_SAME_DIR != chDir) && (EMAP_CONVER_DIR != chDir)) + { + /** ڲ*/ + } + else + { + chFunRtn = as_CalcAreaOrder(pTrainA, pTrainB); + + if ((0x01u != chFunRtn) && (0x02u != chFunRtn)) + { + /** ѯ*/ + } + else if (EMAP_SAME_DIR == chDir) + { + chRtn = (0x01u == chFunRtn) ? CI_ERROR : CI_SUCCESS; + } + else + { + chRtn = (0x01u == chFunRtn) ? CI_SUCCESS : CI_ERROR; + } + } + return chRtn; +} + +/** +* @brief ȡUTгͨں +* @param wTrainId гID +* @return ں +* @note +*/ +static UINT32 ToaGetBreakCyc(UINT16 wTrainId) +{ + UINT8 chTrainIndex = 0u; + UINT32 dwCyc = 0u; + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + if (g_utTrain[chTrainIndex].wTrainId == wTrainId) + { + dwCyc = g_utTrain[chTrainIndex].dwUtCyc; + break; + } + else + { + ; + } + } + return dwCyc; +} + +/** +* @brief жϼǷ +* @param wAcIndex δ洢± +* @return CI_ERROR:ռãCI_SUCCESS: +* @note +*/ +UINT8 IsAcFree(UINT16 wAcIndex) +{ + UINT8 chRtn = CI_ERROR; + + if (AXIS_SECTION_SUM_MAX > wAcIndex) + { + if (0u == g_acMap[wAcIndex].chTrainNum) + { + chRtn = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; + } + return chRtn; +} + +/** +* @brief жϼǷ +* @param wTrainId гID +* @param cAcSum +* @param pAcIdBuf ID +* @return CI_ERROR:ռãCI_SUCCESS: +* @note +*/ +static UINT8 IsAcListFreeToSet(UINT16 wTrainId, UINT8 cAcSum, UINT16* pAcIdBuf) +{ + UINT8 chRtn = CI_ERROR; + UINT8 ii = 0u; + UINT16 wAcIndex = 0u; + UINT8 chIndex = 0u; + UINT8 chFunRtn = CI_ERROR; + + if ((0u != cAcSum) && (NULL != pAcIdBuf) && (MAX_AC_IN_TRAIN >= cAcSum)) + { + chRtn = CI_SUCCESS; + for (ii = 0u; ii < cAcSum;ii++) + { + /* жгǷڼ */ + chFunRtn = IsUtTrainOnAc(wTrainId, pAcIdBuf[ii]); + if (CI_ERROR == chFunRtn) + { + wAcIndex = pAcIdBuf[ii]; + if (AXIS_SECTION_SUM_MAX > wAcIndex) + { + if (0u == g_acMap[wAcIndex].chTrainNum) + { + ; /* ޳ */ + } + else + { + for (chIndex = 0u; chIndex < g_acMap[wAcIndex].chTrainNum; chIndex++) + {/* гҷ255г */ + if ((g_acMap[wAcIndex].strTrain[chIndex].wTrainId != wTrainId) && (TRAIN_SUM_MAX != g_acMap[wAcIndex].strTrain[chIndex].wTrainId)) + { + chRtn = CI_ERROR; + break; + } + } + } + } + else + { + chRtn = CI_ERROR; + } + + if (CI_ERROR == chRtn) + { + break; + } + else + { + ; + } + } + else + { + ; + } + } + } + + return chRtn; +} + +/** +* @brief ɾUTгβռѹ +* @param wTrainId гID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +UINT8 ToaDeleteUtTrainAc(UINT16 wTrainId) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chTrainIndex = 0u; + UINT8 chIndex = 0u; + + if (0u != wTrainId) + { + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + if (wTrainId == g_utTrain[chTrainIndex].wTrainId) + { + break; + } + else + { + ; + } + } + + if (chTrainIndex == g_utTrainSum) + { + ; /* ޸UT */ + } + else + { + /* ռһΣֱUTг */ + if ((1u == g_utTrain[chTrainIndex].chAcNum) || (0u == g_utTrain[chTrainIndex].chAcNum)) + { + (void)ToaDeleteUtTrain(g_utTrain[chTrainIndex].wTrainId); + } + else + { + (void)ToaDeleteAcMapElm(g_utTrain[chTrainIndex].szAcId[0], g_utTrain[chTrainIndex].wTrainId); + for (chIndex = 0u; chIndex < (g_utTrain[chTrainIndex].chAcNum - 1u); chIndex++) + { + g_utTrain[chTrainIndex].szAcId[chIndex] = g_utTrain[chTrainIndex].szAcId[chIndex + 1u]; + } + g_utTrain[chTrainIndex].chAcNum--; + } + chRtn = CI_SUCCESS; + } + } + else + { + ; /* βϷ */ + } + return chRtn; +} + +/** +* @brief UTгͷ׷ռѹ +* @param wTrainId гID +* @param wAcId ID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +static UINT8 ToaAddUtTrainAc(UINT16 wTrainId, UINT16 wAcId) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chTrainIndex = 0u; + UINT8 chIndex = 0u; + UINT8 chAcSwitchNum = 0u; + UINT8 chState = 0u; + + if ((TRAIN_SUM_MAX != wTrainId) && (0u != wTrainId) && (AXIS_SECTION_SUM_MAX > wAcId)) + { + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + if (wTrainId == g_utTrain[chTrainIndex].wTrainId) + {/* ҵг¼±꣬ */ + break; + } + else + { + ; + } + } + + if (chTrainIndex == g_utTrainSum) + {/* δҵӦUT */ + ; + } + else + { + if (MAX_AC_IN_TRAIN > g_utTrain[chTrainIndex].chAcNum) + {/* ׷ռ */ + chRtn = ToaAddAcMapElm(wAcId, wTrainId, TOA_TYPE_UT); + g_utTrain[chTrainIndex].szAcId[g_utTrain[chTrainIndex].chAcNum] = wAcId; + g_utTrain[chTrainIndex].chAcNum++; + } + else + { + ; + } + } + } + else + { + ; /* βϷ */ + } + return chRtn; +} + +/** +* @brief гIDȡгռѹ +* @param wTrainId гID +* @param szAcId ID +* @return гռѹ +* @note +*/ +UINT8 ToaGetUtTrainAc(UINT16 wTrainId, UINT16 szAcId[MAX_AC_IN_TRAIN]) +{ + UINT8 chAcNum = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chFunRtn = CI_ERROR; + + /** μ*/ + if (NULL != szAcId) + { + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + if (wTrainId == g_utTrain[chTrainIndex].wTrainId) + { + chAcNum = g_utTrain[chTrainIndex].chAcNum; + if (MAX_AC_IN_TRAIN > chAcNum) + { + chFunRtn = CommonMemCpy(szAcId, (UINT32)(sizeof(UINT16) * chAcNum), g_utTrain[chTrainIndex].szAcId, (UINT32)(sizeof(UINT16) * chAcNum)); + } + else + { + ; /*Ϣڿռ䣬п*/ + } + break; + } + else + { + ; + } + } + if (CI_ERROR == chFunRtn) + { + chAcNum = 0u; + } + else + { + ; + } + } + else + { + chAcNum = 0u; + } + return chAcNum; +} + +/** +* @brief ȡUTг +* @param wTrainId гID +* @return +* @note +*/ +UINT8 ToaGetUtTrainDir(UINT16 wTrainId) +{ + UINT8 chDir = 0u; + UINT8 chTrainIndex = 0u; + + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + if (wTrainId == g_utTrain[chTrainIndex].wTrainId) + { + chDir = g_utTrain[chTrainIndex].chDir; + break; + } + else + { + ; + } + } + + return chDir; +} + +/** +* @brief ˢUTռѹУATS˹ʱʹã +* @param wTrainId гID +* @param chDir UTг +* @param chAcNum +* @param szAcId ID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @noteڲŻ 20220808 μ +*/ +static UINT8 ToaRefreshUtTrainAc(UINT16 wTrainId, UINT8 chDir, UINT8 chAcNum, UINT16 szAcId[MAX_AC_IN_TRAIN]) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chTrainIndex = 0u; + UINT8 chIndex = 0u; + UINT8 chAcSwitchNum = 0u; + UINT8 chState = 0u; + + /** μ*/ + if (((DIR_SAME == chDir) || (DIR_CONVERT == chDir)) + && (TRAIN_SUM_MAX != wTrainId) && (0u != wTrainId) + && (MAX_AC_IN_TRAIN >= chAcNum) + && (NULL != szAcId)) + { + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + if (wTrainId == g_utTrain[chTrainIndex].wTrainId) + { + break; + } + else + { + ; + } + } + + if (chTrainIndex == g_utTrainSum) + { + chRtn = ToaAddUtTrain(wTrainId, chDir, chAcNum, szAcId); + } + else + { + g_utTrain[chTrainIndex].chAcNum = chAcNum; + chRtn = CommonMemCpy(g_utTrain[chTrainIndex].szAcId, (UINT32)(sizeof(UINT16) * chAcNum), szAcId, (UINT32)(sizeof(UINT16) * chAcNum)); + } + + if (CI_SUCCESS == chRtn) + { + for (chIndex = 0u; chIndex < chAcNum; chIndex++) + { + (void)ToaAddAcMapElm(szAcId[chIndex], wTrainId, TOA_TYPE_UT); + } + } + else + { + ; + } + } + else + { + ; /* βϷ */ + } + return chRtn; +} + +/** +* @brief +* @param chCmdType +* @param wTrainId гID +* @param dwCmdId ID +* @param wTerminalId նID +* @param chVirCi ID +* @param dwCmdParam +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +UINT8 ToaAddCmd(UINT8 chCmdType, UINT16 wTrainId, UINT32 dwCmdId, UINT16 wTerminalId, UINT8 chVirCi, UINT32 dwCmdParam) +{ + UINT8 chRtn = CI_ERROR; + if (((TOA_CMD_TYPE_SET == chCmdType) || (TOA_CMD_TYPE_CANCEL_FIRST == chCmdType) || (TOA_CMD_TYPE_CANCEL_SECOND == chCmdType) + || (TOA_CMD_TYPE_RESET_FIRST == chCmdType) || (TOA_CMD_TYPE_RESET_SECOND == chCmdType)) + && (TOA_CMD_MAX > g_cmdNum)) + { + chRtn = CI_SUCCESS; + } + else + { + ; + } + + if (CI_SUCCESS == chRtn) + { + g_cmdStr[g_cmdNum].chCmdType = chCmdType; + g_cmdStr[g_cmdNum].wTrainId = wTrainId; + g_cmdStr[g_cmdNum].dwCmdId = dwCmdId; + g_cmdStr[g_cmdNum].wTerminalId = wTerminalId; + g_cmdStr[g_cmdNum].chVirCi = chVirCi; + g_cmdStr[g_cmdNum].dwCmdParam = dwCmdParam; + + g_cmdNum++; + + debug_infor_printf((const)"Toa add cmd:%x tid:%x cid:%x terid:%x vid:%x param:%x\n", chCmdType, wTrainId, dwCmdId, wTerminalId, chVirCi, dwCmdParam); + } + else + { + ; + } + return chRtn; +} + +/** +* @brief  +* @note +*/ +static void ToaCmdProc(void) +{ + UINT8 chIndex = 0u; + UINT8 chCmdType = 0u; + UINT8 chDir = 0u; + UINT16 wTrainId = 0u; + UINT8 chFunRtn = CI_FALSE; + UINT8 chBelongVirCi = 0u; + UINT8 chVirCi = 0u; + UINT8 chOrderCheck = CI_ERROR; + UINT8 chCheckRtn = AFFIRM_FAIL; + UINT32 dwCmdId = 0u; + UINT16 wTerminalId = 0u; + UINT8 startFLockFlag = 0u; + UINT8 allSwitchYLockFlag = 0u; + UINT16 wCmdDeviceId = 0u; + UINT8 chCmdDeviceType = 0u; + UINT8 chTiocSysMode; + + allSwitchYLockFlag = GetAllSwitchYLockFlag(); + startFLockFlag = GetStartFLockFlag(); + chTiocSysMode = GetTiocSystemMode(); + if ((REVERSE_MODE_MAIN != chTiocSysMode) || (CI_START_FLOCK_YES == startFLockFlag) || (CI_ALL_SWITCH_YLOCK_YES == allSwitchYLockFlag)) + { + ; + } + else + { + for (chIndex = 0u; chIndex < g_cmdNum; chIndex++) + { + chCmdType = g_cmdStr[chIndex].chCmdType; + chDir = (UINT8)(g_cmdStr[chIndex].dwCmdParam & 0xffu); + chCmdDeviceType = (UINT8)(g_cmdStr[chIndex].dwCmdParam >> 8u); + wCmdDeviceId = (UINT16)(g_cmdStr[chIndex].dwCmdParam >> 16u); + wTrainId = g_cmdStr[chIndex].wTrainId; + chVirCi = g_cmdStr[chIndex].chVirCi; + dwCmdId = g_cmdStr[chIndex].dwCmdId; + wTerminalId = g_cmdStr[chIndex].wTerminalId; + + switch (chCmdType) + { + case TOA_CMD_TYPE_SET: + SetBreakPhySecWithTrainInfo(wCmdDeviceId, wTrainId, chDir); + break; + case TOA_CMD_TYPE_CANCEL_FIRST: + if (TOA_NORMAL == g_initStatus) + { + /* ȡгһ*/ + chFunRtn = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, wCmdDeviceId); + if (CI_TRUE == chFunRtn) + { + chBelongVirCi = GetPhySecBelongVirCiId(wCmdDeviceId); + chOrderCheck = CheckOrderWhetherDoing(chVirCi, chBelongVirCi, chCmdType, wCmdDeviceId); + if (CI_SUCCESS == chOrderCheck) + { + chCheckRtn = AFFIRM_SUCCESS; + } + else + { + chCheckRtn = AFFIRM_FAIL; + } + } + else + { + chCheckRtn = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, RESPONSE_FIRST, chCheckRtn, chVirCi); + } + else + { + ; + } + break; + case TOA_CMD_TYPE_CANCEL_SECOND: + if (TOA_NORMAL == g_initStatus) + { + chCheckRtn = CheckSecondOrderValid(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, chVirCi); + if (CI_SUCCESS == chCheckRtn) + { + chCheckRtn = CheckTheDevIsNotOfDiffLine(CI_DEVICE_TYPE_PHYSEC, wCmdDeviceId); + + if (CI_TRUE == chCheckRtn) + { + chBelongVirCi = GetPhySecBelongVirCiId(wCmdDeviceId); + chOrderCheck = CheckOrderWhetherDoing(chVirCi, chBelongVirCi, chCmdType, wCmdDeviceId); + if (CI_SUCCESS == chOrderCheck) + { + chCheckRtn = AFFIRM_SUCCESS; + /* ȡг */ + UnLockBreakPhySecWithTrainInfo(wCmdDeviceId, wTrainId, chDir); + } + else + { + chCheckRtn = AFFIRM_FAIL; + } + } + else + { + chCheckRtn = AFFIRM_FAIL; + } + } + else + { + chCheckRtn = AFFIRM_FAIL; + } + SetCiSendCmdBackData_OrderBack(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, RESPONSE_SECOND, chCheckRtn, chVirCi); + } + else + { + ; + } + break; + case TOA_CMD_TYPE_RESET_FIRST: + if (TOA_INIT == g_initStatus) + { + SetCiSendCmdBackData_OrderBack(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, RESPONSE_FIRST, AFFIRM_SUCCESS, chVirCi); + } + else + { + SetCiSendCmdBackData_OrderBack(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, RESPONSE_FIRST, AFFIRM_FAIL, chVirCi); + } + break; + case TOA_CMD_TYPE_RESET_SECOND: + if (TOA_INIT == g_initStatus) + { + chCheckRtn = CheckSecondOrderValid(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, chVirCi); + if (CI_SUCCESS == chCheckRtn) + { + ToaUnlock(); + + SetCiSendCmdBackData_OrderBack(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, RESPONSE_SECOND, AFFIRM_SUCCESS, chVirCi); + } + else + { + SetCiSendCmdBackData_OrderBack(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, RESPONSE_SECOND, AFFIRM_FAIL, chVirCi); + } + } + else + { + SetCiSendCmdBackData_OrderBack(dwCmdId, wCmdDeviceId, chCmdDeviceType, wTerminalId, chCmdType, RESPONSE_SECOND, AFFIRM_FAIL, chVirCi); + } + break; + default: + /*򲻿ɴ֧*/ + break; + } + } + } + /* ִ */ + ToaClearCmd(); +} + +/* +* @brief ùгռѹ +* @param const UINT16 wPhySecId ID +* const UINT16 wTrainId г +* const UINT16 wTrainDir г +* @note lxc 20220617 +*/ +static void SetBreakPhySecWithTrainInfo(const UINT16 wPhySecId, const UINT16 wTrainId, const UINT8 chDir) +{ + UINT16 wAxisSecId = 0u; + UINT8 cKeepWorkFlag = CI_ERROR; + + UINT8 cASASum = 0u; + UINT16 szASAIdBuf[MAX_AC_IN_TRAIN] = { 0u }; + UINT8 cTrainDir = 0U; + UINT8 cASBSum = 0u; + UINT16 szASBIdBuf[MAX_AC_IN_TRAIN] = { 0u }; + + UINT8 cAxisSecSum = 0u; + UINT16 szAxisSecIdBuf[MAX_AC_IN_TRAIN] = { 0u }; + UINT8 chLinkLogicDirUpAndDown = 0U; + UINT8 ii = 0u; + UINT16 wTmpPhySecId = 0u; + UINT8 cPhySecLockSatae = PHYSICAL_SECTION_LOCK_NO; + UINT8 cPhySecLockDir = CI_SYSTEM_DIRECTION_NONE; + UINT8 cPhySecLockLinkDir = DIR_INVALID; + UINT8 cTrainTrainSitmitStat = TRAIN_COMM_STATE_UNKNOWN; + UINT8 cLocalTrainDir = TRAIN_DIR_DEF; + UINT16 wRouteId = 0u; + + + chLinkLogicDirUpAndDown = GetLinkLogicDirUpAndDown(); + + if (((EMAP_SAME_DIR == chDir) || (EMAP_CONVER_DIR == chDir)) + &&((0x55u == chLinkLogicDirUpAndDown) || (0xAAu == chLinkLogicDirUpAndDown))) + { + cKeepWorkFlag = CI_SUCCESS; + if (chLinkLogicDirUpAndDown == chDir) + { + cTrainDir = DIR_CONVERT; + } + else + { + cTrainDir = DIR_SAME; + } + } + else + { + cKeepWorkFlag = CI_ERROR; + } + + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ȡгIDͣжǷڵͨų */ + cTrainTrainSitmitStat = GetTrainTransitmitStat(wTrainId); + if (TRAIN_COMM_STATE_GOOD != cTrainTrainSitmitStat) + { + /* ȡʧ */ + if (CI_ERROR == cTrainTrainSitmitStat) + { + + cKeepWorkFlag = CI_ERROR; + } + /* ͨŹ */ + else + { + cKeepWorkFlag = CI_SUCCESS; + } + } + else + { + /* ʧ */ + cKeepWorkFlag = CI_ERROR; + SetCiSendCmdBackInfoWithTrainId(CI_BACK_SPE_TRAIN_DIR_ERR, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + } + } + else + { + ; + } + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ͨΣȡ */ + wAxisSecId = GetAxisSecIdByPhySecIdAndSwSta(wPhySecId); + if (UINT16_MAX == wAxisSecId) + { + /* ˹ϵʧ*/ + cKeepWorkFlag = CI_ERROR; + SetCiSendCmdBackInfoWithTrainId(CI_BACK_SPE_DISCONTINUITY, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + + } + else + { + cKeepWorkFlag = CI_SUCCESS; + } + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWorkFlag) + { + cKeepWorkFlag = IsAcFreeToSet(wTrainId, wAxisSecId); + if (CI_ERROR == cKeepWorkFlag) + { + SetCiSendCmdBackInfoWithTrainId(CI_BACK_SPE_OTHER_CT, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + } + else + { + ; + } + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWorkFlag) + { + /* гڣжѴڵгǷһ */ + cLocalTrainDir = ToaGetUtTrainDir(wTrainId); + cASBSum = ToaGetUtTrainAc(wTrainId, szASBIdBuf); + + if ((DIR_SAME == cTrainDir) || (DIR_CONVERT == cTrainDir)) + { + if ((0u != cASBSum) && (cTrainDir != cLocalTrainDir)) + { + /* UTһ */ + cKeepWorkFlag = CI_ERROR; + } + else + { + ; + } + } + else + { + /* Уʧ */ + cKeepWorkFlag = CI_ERROR; + } + + if (CI_ERROR == cKeepWorkFlag) + { + SetCiSendCmdBackInfoWithTrainId(CI_BACK_SPE_TRAIN_DIR_ERR, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + } + else + { + } + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ȡ֮ͨļ,г */ + cASASum = 1u; + szASAIdBuf[0] = wAxisSecId; + + if (0u == cASBSum) + { + szAxisSecIdBuf[0] = wAxisSecId; + cAxisSecSum = 1u; + } + else + { + cAxisSecSum = GetAxisSecListByStartingAndEnd(cASASum, szASAIdBuf, cASBSum, szASBIdBuf, cTrainDir, szAxisSecIdBuf); + } + + if (0u == cAxisSecSum) + { + /* ˹ϵʧ */ + cKeepWorkFlag = CI_ERROR; + SetCiSendCmdBackInfoWithTrainId(CI_BACK_SPE_DISCONTINUITY, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + } + else + { + ; + } + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ͨǷг */ + cKeepWorkFlag = IsAcListFreeToSet(wTrainId, cAxisSecSum, szAxisSecIdBuf); + + if (CI_ERROR == cKeepWorkFlag) + { + cKeepWorkFlag = CI_ERROR; + SetCiSendCmdBackInfoWithTrainId(CI_BACK_SPE_OTHER_CT, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + } + else + { + ; + } + } + else + { + ; + } + + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ͨշǷгһ */ + for (ii = 0u; ii < cAxisSecSum; ii++) + { + /* ȡι */ + wTmpPhySecId = GetAxisSecRelativePhySecId(szAxisSecIdBuf[ii]); + cPhySecLockSatae = GetPhySecLockState(wTmpPhySecId); + cPhySecLockDir = GetPhySecLockDirection(wTmpPhySecId); + + if (chLinkLogicDirUpAndDown == cPhySecLockDir) + { + cPhySecLockLinkDir = DIR_CONVERT; + } + else + { + cPhySecLockLinkDir = DIR_SAME; + } + if ((0u != wTmpPhySecId) && (UINT16_MAX != wTmpPhySecId)) + { + if ((PHYSICAL_SECTION_LOCK_START == cPhySecLockSatae) + || (PHYSICAL_SECTION_LOCK_EXCEPT == cPhySecLockSatae)) + { + cKeepWorkFlag = CI_ERROR; + } + else if ((PHYSICAL_SECTION_LOCK_NO != cPhySecLockSatae) && (cPhySecLockLinkDir != cTrainDir)) + { + wRouteId = GetPhySecPLockBelongRouteId(wTmpPhySecId); + if (0u == wRouteId) + { + wRouteId = GetPhySecRLockBelongRouteId(wTmpPhySecId); + } + else + { + ; + } + /* շһ */ + cKeepWorkFlag = CI_ERROR; + } + else + { + /*޲*/ + } + } + else + { + ; + } + + if (CI_ERROR == cKeepWorkFlag) + { + SetCiSendCmdBackInfoWithTrainId(CI_BACK_SPE_LOOK_DIR_ERR, CI_DEVICE_TYPE_ROUTE, wRouteId, 0u, 0u, wTrainId); + + break; + } + else + { + ; + } + } + } + else + { + ; + } + + + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ùϳλ */ + cKeepWorkFlag = ToaRefreshUtTrainAc(wTrainId, cTrainDir, cAxisSecSum, szAxisSecIdBuf); + + if (CI_ERROR == cKeepWorkFlag) + { + SetCiSendCmdBackInfoWithTrainId(CI_BACK_SPE_DISCONTINUITY, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + } + else + { + ; + } + } + else + { + ; + } +} + +/* +* @brief ȡгռѹ +* @param const UINT16 wPhySecId ID +* const UINT16 wTrainId г +* const UINT16 wTrainDir г +* @note lxc 20220617 +*/ +static void UnLockBreakPhySecWithTrainInfo(const UINT16 wPhySecId, const UINT16 wTrainId, const UINT8 cTrainDir) +{ + UINT16 wAxisSecId = 0u; + UINT8 cKeepWorkFlag = CI_ERROR; + UINT8 sendLevel = ESEND_LEVEL_ATS; + UINT8 functionId = 0u; + + UINT8 cAxisSecSum = 0u; + UINT16 szAxisSecIdBuf[MAX_AC_IN_TRAIN] = { 0u }; + + UINT8 chIndex = 0u; + + UINT16 wPhyId = 0u; + UINT8 chOccState = 0u; + UINT8 chSwitchNum = 0u; + + /* ͨΣȡ */ + wAxisSecId = GetAxisSecIdByPhySecIdAndSwSta(wPhySecId); + if (UINT16_MAX == wAxisSecId) + { + /* ״̬ */ + cKeepWorkFlag = CI_ERROR; + SetCiSendCmdBackInfoWithTrainId(CI_BACK_CPE_PHYSEC_ID_ERR, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + + } + else + { + cKeepWorkFlag = CI_SUCCESS; + } + + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ȡгļ */ + cAxisSecSum = ToaGetUtTrainAc(wTrainId, szAxisSecIdBuf); + + if (0u == cAxisSecSum) + { + /* Ƿڸó */ + cKeepWorkFlag = CI_ERROR; + SetCiSendCmdBackInfoWithTrainId(CI_BACK_CPE_TRAIN_ID_ERR, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + + } + else if (wAxisSecId != szAxisSecIdBuf[0]) + { + /* жǷΪгβ */ + cKeepWorkFlag = CI_ERROR; + SetCiSendCmdBackInfoWithTrainId(CI_BACK_CPE_PHYSEC_ID_ERR, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + + } + else + { + ; /* ɹ */ + } + + } + +#if 0 + /* ռҽд˳ռãɽ */ + if (CI_SUCCESS == cKeepWorkFlag) + { + chSwitchNum = GetAxisSwitchSum(wAxisSecId); + chOccState = GetPhySecCurOccupyState(wPhySecId); + if ((0u != chSwitchNum) && (SECTION_OCCUPY_YES == chOccState) && (1u == g_acMap[wAxisSecId].chTrainNum)) + { + cKeepWorkFlag = CI_ERROR; + } + else + { + ; + } + } + else + { + ; + } +#endif + + if (CI_SUCCESS == cKeepWorkFlag) + { + /* ȡιгϢ */ + cKeepWorkFlag = ToaDeleteUtTrainAc(wTrainId); + if (CI_ERROR == cKeepWorkFlag) + { + SetCiSendCmdBackInfoWithTrainId(CI_BACK_CPE_PHYSEC_ID_ERR, CI_DEVICE_TYPE_PHYSEC, wPhySecId, 0u, 0u, wTrainId); + + } + else + { + chIndex = ToaGetUtIndex(wTrainId); + if (TRAIN_SUM_MAX_IN_OC != chIndex) + { + wPhyId = GetAxisSecRelativePhySecId(g_utTrain[chIndex].szAcId[0]); + (void)CancelOutFirstFaultOccUnlock(wPhyId); + } + else + { + ; + } + } + } +} + +/* +* @brief Ƿ +* @param wPhyId ID +* @return CI_ERROR:ռãCI_SUCCESS: +* @note +*/ +UINT8 IsPhyFree(UINT16 wPhyId) +{ + UINT8 chAcNum = 0u; + UINT16 * pAcId = NULL; + UINT8 chIndex = 0u; + UINT8 chRtn = CI_ERROR; + + chAcNum = GetPAxisSectionSum(wPhyId); + pAcId = GetPAxisSectionIdBuf(wPhyId); + + if (0u == chAcNum) + { + ; + } + else + { + for (chIndex = 0u; chIndex < chAcNum; chIndex++) + { + chRtn = IsAcHaveNoBadTrain(pAcId[chIndex]); + if (CI_ERROR == chRtn) + { + break; + } + else + { + ; + } + } + } + return chRtn; +} + +/* +* @brief ȡǰ +* @param +* @return ǰ +* @note +*/ +UINT8 ToaGetUtTrainNum(void) +{ + return g_utTrainSum; +} + +/* +* @brief ȡǰID +* @param szUtId ID +* @return CI_ERROR:ȡʧܣCI_SUCCESS:ȡɹ +* @note ڲŻ 20220808 μ +*/ +UINT8 ToaGetUtTrainIdBuf(UINT16 szUtId[TRAIN_SUM_MAX]) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + + /** μ*/ + if (NULL != szUtId) + { + if (TRAIN_SUM_MAX > g_utTrainSum) + { + for (chIndex = 0u; chIndex < g_utTrainSum; chIndex++) + { + if (0u != g_utTrain[chIndex].wTrainId) + { + szUtId[chIndex] = g_utTrain[chIndex].wTrainId; + } + else + { + break; + } + } + + if (chIndex == g_utTrainSum) + { + chRtn = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; + } + } + else + { + + } + return chRtn; +} + +/* +* @brief ȡָν +* @param wPhyId ID +* @return +TRAIN_SUM_MAXʧ +* @note +*/ +UINT8 ToaGetPhyUtNum(UINT16 wPhyId) +{ + UINT8 chAcNum = 0u; + UINT16 * pAcId = NULL; + UINT8 chRtn = TRAIN_SUM_MAX; + UINT8 chIndex = 0u; + UINT8 chTrainIndex = 0u; + chAcNum = GetPAxisSectionSum(wPhyId); + pAcId = GetPAxisSectionIdBuf(wPhyId); + if(0u == chAcNum) + { + ; + } + else + { + chRtn = 0u; + for (chIndex = 0u; chIndex < chAcNum; chIndex++) + { + for (chTrainIndex = 0u; chTrainIndex < g_acMap[pAcId[chIndex]].chTrainNum; chTrainIndex++) + { + if (TOA_TYPE_UT == g_acMap[pAcId[chIndex]].strTrain[chTrainIndex].chTrainType) + { + chRtn++; + } + else + { + ; + } + } + } + } + return chRtn; +} + +/* +* @brief ȡָνID +* @param wPhyId ID +* @param szUtId гID +* @return CI_SUCCESS:ȡɹCI_ERROR:ȡʧ +* @note ڲŻ 20220808 μ +*/ +UINT8 ToaGetPhyUtId(UINT16 wPhyId, UINT16 szUtId[TRAIN_SUM_MAX]) +{ + UINT8 chAcNum = 0u; + UINT16 * pAcId = NULL; + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chUtNum = 0u; + chAcNum = GetPAxisSectionSum(wPhyId); + pAcId = GetPAxisSectionIdBuf(wPhyId); + /** μ*/ + if ((0u == chAcNum) || (NULL == szUtId)) + { + ; + } + else + { + for (chIndex = 0u; chIndex < chAcNum; chIndex++) + { + for (chTrainIndex = 0u; chTrainIndex < g_acMap[pAcId[chIndex]].chTrainNum; chTrainIndex++) + { + if (TOA_TYPE_UT == g_acMap[pAcId[chIndex]].strTrain[chTrainIndex].chTrainType) + { + szUtId[chUtNum++] = g_acMap[pAcId[chIndex]].strTrain[chTrainIndex].wTrainId; + } + else + { + ; + } + } + } + chRtn = CI_SUCCESS; + } + return chRtn; +} + +/* +* @brief +* @param +* @return +* @note +*/ +void ToaClearCmd(void) +{ + g_cmdNum = 0u; + (void)CommonMemSet(g_cmdStr, (UINT32)(sizeof(ToaCmdStruct) * TOA_CMD_MAX), 0u, (UINT32)(sizeof(ToaCmdStruct) * TOA_CMD_MAX)); +} + +/** +* @brief ȡǰTIOCеͨųгID +* @param[out] szTrainId гID +* @return TIOCΧͨг +*/ +static UINT8 ToaGetCommTrainId(UINT16 szTrainId[TRAIN_SUM_MAX_IN_OC]) +{ + /*- ֲ */ + UINT8 chTrainNum = 0u; + UINT8 chIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chTransmitState = 0u; + + /** ڲУ*/ + if (NULL == szTrainId) + { + /** ڲ */ + ; + } + else + { + /** ȡͨг */ + for (chIndex = 0u; chIndex < TRAIN_SUM_MAX; chIndex++) + { + /** ȡг + ID*/ + wTrainId = GetTrainId(chIndex); + + /** ȡгͨ״̬*/ + chTransmitState = GetTrainTransitmitStat(wTrainId); + + /** жͨ״̬Ƿ*/ + if ((TRAIN_COMM_STATE_GOOD == chTransmitState) && (chTrainNum < TRAIN_SUM_MAX_IN_OC)) + { + szTrainId[chTrainNum++] = wTrainId; + } + else + { + /** ͨų */ + } + } + } + + /** */ + return chTrainNum; +} + +/** +* @brief ȡǰTIOCеĶʧͨųгID +* @param[out] szTrainId гID +* @return TIOCΧڶʧͨг +*/ +static UINT8 ToaGetLoseCommTrainId(UINT16 szTrainId[TRAIN_SUM_MAX_IN_OC]) +{ + /*- ֲ */ + UINT8 chTrainNum = 0u; + UINT8 chIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chTransmitState = 0u; + + /** ڲУ*/ + if (NULL == szTrainId) + { + /** ڲ */ + ; + } + else + { + /** ȡͨг */ + for (chIndex = 0u; chIndex < TRAIN_SUM_MAX; chIndex++) + { + /** ȡг + ID*/ + wTrainId = GetTrainId(chIndex); + + /** ȡгͨ״̬*/ + chTransmitState = GetTrainTransitmitStat(wTrainId); + + /** жͨ״̬Ƿ*/ + if ((TRAIN_COMM_STATE_BAD == chTransmitState) && (chTrainNum < TRAIN_SUM_MAX_IN_OC)) + { + szTrainId[chTrainNum++] = wTrainId; + } + else + { + /** ͨų */ + } + } + } + + /** */ + return chTrainNum; +} + +/** +* @brief ޹ϳж +* @param wAcIndex δ洢± +* @return CI_ERROR:ڹϳCI_SUCCESS:ڹϳ +* @note +*/ +static UINT8 IsAcHaveNoBadTrain(UINT16 wAcIndex) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + + if (AXIS_SECTION_SUM_MAX > wAcIndex) + { + chRtn = CI_SUCCESS; + for (chIndex = 0u; chIndex < g_acMap[wAcIndex].chTrainNum; chIndex++) + { + if (TOA_TYPE_UT == g_acMap[wAcIndex].strTrain[chIndex].chTrainType) + { + chRtn = CI_ERROR; + break; + } + else + { + ; + } + } + } + else + { + ; + } + return chRtn; +} + +/** +* @brief ȡUTг洢 +* @param wTrainId гID +* @return TRAIN_SUM_MAX_IN_OC:ʧܣ: +* @note +*/ +static UINT8 ToaGetUtIndex(UINT16 wTrainId) +{ + UINT8 chIndex = 0u; + for (chIndex = 0u; chIndex < g_utTrainSum; chIndex++) + { + if (g_utTrain[chIndex].wTrainId == wTrainId) + { + break; + } + else + { + ; + } + } + if (chIndex == g_utTrainSum) + { + chIndex = TRAIN_SUM_MAX_IN_OC; + } + else + { + ; + } + return chIndex; +} + +/** +* @brief ȡռѹг +* @param wPhyId ID +* @param szUtId гID +* @return MAX_AC_IN_TRAIN:ʧܣ:г +* @noteڲŻ 20220808 μ +*/ +UINT8 ToaGetPhyTrain(UINT16 wPhyId, UINT16 szTrainId[MAX_AC_IN_TRAIN]) +{ + UINT8 chAcNum = 0u; + UINT16 *pAcId = NULL; + UINT8 chAcIndex = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chTrainNum = 0u; + chAcNum = GetPAxisSectionSum(wPhyId); + pAcId = GetPAxisSectionIdBuf(wPhyId); + /** μ*/ + if ((NULL != pAcId) && (NULL != szTrainId)) + { + for (chAcIndex = 0u; chAcIndex < chAcNum; chAcIndex++) + { + for (chTrainIndex = 0u; chTrainIndex < g_acMap[pAcId[chAcIndex]].chTrainNum; chTrainIndex++) + { + szTrainId[chTrainNum++] = g_acMap[pAcId[chAcIndex]].strTrain[chTrainIndex].wTrainId; + } + } + } + else + { + chTrainNum = MAX_AC_IN_TRAIN; + } + return chTrainNum; +} + +/** +* @brief ɾUTгβɼд +* @param +* @return +* @note +*/ +static void ToaDeleteUtTrainTailFreeAc(void) +{ + UINT8 chTrainIndex = 0u; + UINT8 chIndex = 0u; + UINT8 chState = 0u; + UINT16 wPhyId = 0u; + UINT16 wGdRelayId = 0u; + + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + {/* жϳβǷвɼ */ + + wPhyId = GetAxisSecRelativePhySecId(g_utTrain[chTrainIndex].szAcId[0]); + wGdRelayId = GetPhySecGdRelayId(wPhyId); /*ȡι̵ID*/ + chState = GetPhySecCurOccupyState(wPhyId); + + /* ο */ + if ((0u != g_utTrain[chTrainIndex].chAcNum) && (UINT16_MAX != wGdRelayId) && (0u != wGdRelayId) && (SECTION_OCCUPY_NO == chState)) + { + (void)ToaDeleteAcMapElm(g_utTrain[chTrainIndex].szAcId[0], g_utTrain[chTrainIndex].wTrainId); + for (chIndex = 0u; chIndex < (g_utTrain[chTrainIndex].chAcNum - 1u); chIndex++) + { + g_utTrain[chTrainIndex].szAcId[chIndex] = g_utTrain[chTrainIndex].szAcId[chIndex + 1u]; + } + g_utTrain[chTrainIndex].chAcNum--; + } + else + { + ; + } + + if (0u == g_utTrain[chTrainIndex].chAcNum) + { + (void)ToaDeleteUtTrain(g_utTrain[chTrainIndex].wTrainId); + } + else + { + ; + } + } +} + +/** +* @brief UTгǷڼ +* @param wTrainId гID +* @param wAcId ID +* @return CI_SUCCESS:гڼϣCI_ERROR:гδڼ +* @note +*/ +static UINT8 IsUtTrainOnAc(UINT16 wTrainId, UINT16 wAcId) +{ + UINT8 chRtn = CI_ERROR; + UINT8 chIndex = 0u; + if (AXIS_SECTION_SUM_MAX <= wAcId) + { + ; + } + else + { + for (chIndex = 0u; chIndex < g_acMap[wAcId].chTrainNum; chIndex++) + { + if ((wTrainId == g_acMap[wAcId].strTrain[chIndex].wTrainId) && (TOA_TYPE_UT == g_acMap[wAcId].strTrain[chIndex].chTrainType)) + {/* UTгڸü */ + chRtn = CI_SUCCESS; + break; + } + else + { + ; + } + } + } + return chRtn; +} + +/** +* @brief ȡTOA +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 ToaGetTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex + 2u;/* λ */ + UINT16 wIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chTransmitStat = 0u; + UINT8 chTrainIndex = 0u; + UINT16 wAcNum = 0u; + UINT8 chTrainNum = 0u; + UINT8 chAcIndex = 0u; + UINT8 chCmdIndex = 0u; + if (NULL != pDataBuff) + { + for (wIndex = 0u; wIndex < AXIS_SECTION_SUM_MAX; wIndex++) + { + if (0u != g_acMap[wIndex].chTrainNum) + { + wAcNum++; /* гļҪд */ + ShortToChar(wIndex, &pDataBuff[copyIndex]); /* дID */ + copyIndex += 2u; + pDataBuff[copyIndex++] = g_acMap[wIndex].chTrainNum; + + for (chTrainIndex = 0u; chTrainIndex < g_acMap[wIndex].chTrainNum; chTrainIndex++) + { + ShortToChar(g_acMap[wIndex].strTrain[chTrainIndex].wTrainId, &pDataBuff[copyIndex]); + copyIndex += 2u; + pDataBuff[copyIndex++] = g_acMap[wIndex].strTrain[chTrainIndex].chTrainType; + } + } + else + { + ; + } + } + ShortToChar(wAcNum, &pDataBuff[curIndex]); /* дгռõļ */ + + pDataBuff[copyIndex++] = g_utTrainSum; + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + ShortToChar(g_utTrain[chTrainIndex].wTrainId, &pDataBuff[copyIndex]); + copyIndex += 2u; + + LongToChar(g_utTrain[chTrainIndex].dwUtCyc, &pDataBuff[copyIndex]); + copyIndex += 4u; + + pDataBuff[copyIndex++] = g_utTrain[chTrainIndex].chDir; + + pDataBuff[copyIndex++] = g_utTrain[chTrainIndex].chAcNum; + + for (chAcIndex = 0u; chAcIndex < g_utTrain[chTrainIndex].chAcNum; chAcIndex++) + { + ShortToChar(g_utTrain[chTrainIndex].szAcId[chAcIndex], &pDataBuff[copyIndex]); + copyIndex += 2u; + } + } + + (void)CommonMemCpy(&pDataBuff[copyIndex], TRAIN_SUM_MAX, g_trainFlag, TRAIN_SUM_MAX); + copyIndex += TRAIN_SUM_MAX; + + pDataBuff[copyIndex++] = g_initStatus; + + pDataBuff[copyIndex++] = g_cmdNum; + + for (chCmdIndex = 0u; chCmdIndex < g_cmdNum; chCmdIndex++) + { + pDataBuff[copyIndex++] = g_cmdStr[chCmdIndex].chCmdType; + + ShortToChar(g_cmdStr[chCmdIndex].wTrainId, &pDataBuff[copyIndex]); + copyIndex += 2u; + + LongToChar(g_cmdStr[chCmdIndex].dwCmdId, &pDataBuff[copyIndex]); + copyIndex += 4u; + + ShortToChar(g_cmdStr[chCmdIndex].wTerminalId, &pDataBuff[copyIndex]); + copyIndex += 2u; + + pDataBuff[copyIndex++] = g_cmdStr[chCmdIndex].chVirCi; + + LongToChar(g_cmdStr[chCmdIndex].dwCmdParam, &pDataBuff[copyIndex]); + copyIndex += 4u; + } + + ret = copyIndex; + + } + return ret; +} + +/** +* @brief TOA +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 ToaSetTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + UINT32 copyIndex = curIndex; + UINT16 wIndex = 0u; + UINT8 chAcIndex = 0u; + UINT16 wTrainId = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chTrainNum = 0u; + UINT16 wAcNum = 0u; + UINT16 wAcId = 0u; + UINT8 chCmdIndex = 0u; + + if (NULL != pDataBuff) + { + (void)CommonMemSet(g_acMap, (UINT32)(sizeof(AcMapStruct) * AXIS_SECTION_SUM_MAX), 0u, (UINT32)(sizeof(AcMapStruct) * AXIS_SECTION_SUM_MAX)); + (void)CommonMemSet(g_utTrain, (UINT32)(sizeof(UtTrainStruct) * TRAIN_SUM_MAX), 0u, (UINT32)(sizeof(UtTrainStruct) * TRAIN_SUM_MAX)); + (void)CommonMemSet(g_trainFlag, TRAIN_SUM_MAX, FLAG_UNSET, TRAIN_SUM_MAX); + (void)CommonMemSet(g_cmdStr, (UINT32)(sizeof(ToaCmdStruct) * TOA_CMD_MAX), 0u, (UINT32)(sizeof(ToaCmdStruct) * TOA_CMD_MAX)); + g_cmdNum = 0u; + g_utTrainSum = 0u; + wAcNum = ShortFromChar(&pDataBuff[copyIndex]); + copyIndex += 2u; + for (wIndex = 0u; wIndex < wAcNum; wIndex++) + { + wAcId = ShortFromChar(&pDataBuff[copyIndex]); + copyIndex += 2u; + g_acMap[wAcId].chTrainNum = pDataBuff[copyIndex]; + copyIndex++; + for (chTrainIndex = 0u; chTrainIndex < g_acMap[wAcId].chTrainNum; chTrainIndex++) + { + g_acMap[wAcId].strTrain[chTrainIndex].wTrainId = ShortFromChar(&pDataBuff[copyIndex]); + copyIndex += 2u; + g_acMap[wAcId].strTrain[chTrainIndex].chTrainType = pDataBuff[copyIndex]; + copyIndex++; + } + } + + g_utTrainSum = pDataBuff[copyIndex]; + copyIndex++; + + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + g_utTrain[chTrainIndex].wTrainId = ShortFromChar(&pDataBuff[copyIndex]); + copyIndex += 2u; + g_utTrain[chTrainIndex].dwUtCyc = LongFromChar(&pDataBuff[copyIndex]); + copyIndex += 4u; + g_utTrain[chTrainIndex].chDir = pDataBuff[copyIndex]; + copyIndex++; + g_utTrain[chTrainIndex].chAcNum = pDataBuff[copyIndex]; + copyIndex++; + for (chAcIndex = 0u; chAcIndex < g_utTrain[chTrainIndex].chAcNum; chAcIndex++) + { + g_utTrain[chTrainIndex].szAcId[chAcIndex] = ShortFromChar(&pDataBuff[copyIndex]); + copyIndex += 2u; + } + } + + (void)CommonMemCpy(g_trainFlag, TRAIN_SUM_MAX, &pDataBuff[copyIndex], TRAIN_SUM_MAX); + copyIndex += TRAIN_SUM_MAX; + + g_initStatus = pDataBuff[copyIndex]; + copyIndex++; + + g_cmdNum = pDataBuff[copyIndex]; + copyIndex++; + + for (chCmdIndex = 0u; chCmdIndex < g_cmdNum; chCmdIndex++) + { + g_cmdStr[chCmdIndex].chCmdType = pDataBuff[copyIndex]; + copyIndex++; + + g_cmdStr[chCmdIndex].wTrainId = ShortFromChar(&pDataBuff[copyIndex]); + copyIndex += 2u; + + g_cmdStr[chCmdIndex].dwCmdId = LongFromChar(&pDataBuff[copyIndex]); + copyIndex += 4u; + + g_cmdStr[chCmdIndex].wTerminalId = ShortFromChar(&pDataBuff[copyIndex]); + copyIndex += 2u; + + g_cmdStr[chCmdIndex].chVirCi = pDataBuff[copyIndex]; + copyIndex++; + + g_cmdStr[chCmdIndex].dwCmdParam = LongFromChar(&pDataBuff[copyIndex]); + copyIndex += 4u; + } + + ret = copyIndex; + } + return ret; +} + +/** +* @brief Ϣӡ +* @param +* @return +*/ +static void ToaDebugInfo(void) +{ + UINT16 wAcIndex = 0u; + UINT8 chTrainIndex = 0u; + UINT8 chAcIndex = 0u; + + debug_infor_printf((const)"Toa work status:%x\n", g_initStatus); + + for (wAcIndex = 0u; wAcIndex < AXIS_SECTION_SUM_MAX; wAcIndex++) + { + if (0u != g_acMap[wAcIndex].chTrainNum) + { + debug_infor_printf((const)"Toa Ac Id = %d ", wAcIndex); + debug_infor_printf((const)"Ac TrainNum = %d[", g_acMap[wAcIndex].chTrainNum); + for (chTrainIndex = 0u; chTrainIndex < g_acMap[wAcIndex].chTrainNum; chTrainIndex++) + { + debug_infor_printf((const)"%x-%d, ", g_acMap[wAcIndex].strTrain[chTrainIndex].wTrainId, g_acMap[wAcIndex].strTrain[chTrainIndex].chTrainType); + } + debug_infor_printf((const)"]\n"); + } + else + { + ; + } + } + + debug_infor_printf((const)"Lose comm seq:"); + for (chTrainIndex = 0u; chTrainIndex < TRAIN_SUM_MAX; chTrainIndex++) + { + if (FLAG_SET == g_trainFlag[chTrainIndex]) + { + debug_infor_printf((const)"%d, ", chTrainIndex); + } + } + debug_infor_printf((const)"\n"); + + for (chTrainIndex = 0u; chTrainIndex < g_utTrainSum; chTrainIndex++) + { + debug_infor_printf((const)"Lose comm train id:%x ", g_utTrain[chTrainIndex].wTrainId); + debug_infor_printf((const)"dir:%x ", g_utTrain[chTrainIndex].chDir); + debug_infor_printf((const)"cyc:%d ", g_utTrain[chTrainIndex].dwUtCyc); + debug_infor_printf((const)"ac num:%d[", g_utTrain[chTrainIndex].chAcNum); + for (chAcIndex = 0u; chAcIndex < g_utTrain[chTrainIndex].chAcNum; chAcIndex++) + { + debug_infor_printf((const)"%d,", g_utTrain[chTrainIndex].szAcId[chAcIndex]); + } + debug_infor_printf((const)"]\n"); + } +} + +/** +* @brief жϼǷܹ +* @param wTrainId гID +* @param wAcId +* @return CI_ERROR:ãCI_SUCCESS:ܹ +* @note +*/ +static UINT8 IsAcFreeToSet(UINT16 wTrainId, UINT16 wAcId) +{ + UINT8 chRtn = CI_ERROR; + + if (AXIS_SECTION_SUM_MAX > wAcId) + { + if ((0u == g_acMap[wAcId].chTrainNum) + || ((1u == g_acMap[wAcId].chTrainNum) && (TRAIN_SUM_MAX == g_acMap[wAcId].strTrain[0].wTrainId))) + { + chRtn = CI_SUCCESS; + } + else + { + ; + } + } + else + { + ; + } + + return chRtn; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/Train/TrainOnAcManage.h b/TSCP/src/APP/ciapp/Train/TrainOnAcManage.h new file mode 100644 index 0000000..bef6a35 --- /dev/null +++ b/TSCP/src/APP/ciapp/Train/TrainOnAcManage.h @@ -0,0 +1,202 @@ +#ifndef _TRAIN_ON_AC_MANAGE_H_ +#define _TRAIN_ON_AC_MANAGE_H_ + +#include "TrainDefine.h" +#include "dquVobcCommonStru.h" +#include "EvacuationAreaManage.h" + +#define TOA_INIT 0x55u /* ģʼ״̬ */ +#define TOA_NORMAL 0xaau /* ģ */ + +#define TOA_CMD_MAX 10u /* */ +#define TOA_CMD_TYPE_SET 0x98u /* */ +#define TOA_CMD_TYPE_CANCEL_FIRST 0x99u /* */ +#define TOA_CMD_TYPE_CANCEL_SECOND 0x9au /* */ +#define TOA_CMD_TYPE_RESET_FIRST 0x9bu /* λһ */ +#define TOA_CMD_TYPE_RESET_SECOND 0x9cu /* λ */ + +/* гϢ */ +typedef struct +{ + UINT16 wTrainId; /* гID */ + UINT8 chTrainType; /* г */ +}TrainStruct; + +/* ιռѹгṹ */ +typedef struct +{ + UINT8 chTrainNum; /* г */ + TrainStruct strTrain[MAX_TRAIN_ON_AC]; /* гID */ +}AcMapStruct; + +typedef struct +{ + UINT16 wTrainId; /* ϳID */ + UINT32 dwUtCyc; /* ͨں */ + UINT8 chDir; /* ϳ */ + UINT8 chAcNum; /* ռüĿ */ + UINT16 szAcId[MAX_AC_IN_TRAIN]; /* ռüID˳ */ +}UtTrainStruct; + +/* гλ */ +typedef struct +{ + LOD_STRU startPos; /*ʼλ*/ + LOD_STRU endPos; /*նλ*/ +}TrainLocStruct; + +typedef struct +{ + UINT8 chCmdType; /* */ + UINT16 wTrainId; /* гID */ + UINT32 dwCmdId; /* */ + UINT16 wTerminalId; /* ն˱ */ + UINT8 chVirCi; /* */ + UINT32 dwCmdParam; /* */ +}ToaCmdStruct; + +/** +* @brief ģʼ +* @param +* @return CI_SUCCESS:ʼɹCI_ERRORʼʧ +* @note +*/ +extern UINT8 ToaInit(void); + +/** +* @brief ģ +* @param +* @return +* @noteӳʼ״̬ת +*/ +extern void ToaUnlock(void); + +/** +* @brief ģ +* @param +* @return +* @note +*/ +extern void ToaMainProc(void); + +/** +* @brief гIDȡгռѹ +* @param wTrainId гID +* @param szAcId ID +* @return гռѹ +* @note +*/ +extern UINT8 ToaGetUtTrainAc(UINT16 wTrainId, UINT16 szAcId[MAX_AC_IN_TRAIN]); + +/** +* @brief ȡUTг +* @param wTrainId гID +* @return +* @note +*/ +extern UINT8 ToaGetUtTrainDir(UINT16 wTrainId); + +/** +* @brief +* @param chCmdType +* @param wTrainId гID +* @param dwCmdId ID +* @param wTerminalId նID +* @param chVirCi ID +* @param dwCmdParam +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +extern UINT8 ToaAddCmd(UINT8 chCmdType, UINT16 wTrainId, UINT32 dwCmdId, UINT16 wTerminalId, UINT8 chVirCi, UINT32 dwCmdParam); + +/** +* @brief ɾUTгβռѹ +* @param wTrainId гID +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +* @note +*/ +extern UINT8 ToaDeleteUtTrainAc(UINT16 wTrainId); + +/** +* @brief жϼǷ +* @param wAcIndex δ洢± +* @return CI_ERROR:ռãCI_SUCCESS: +* @note +*/ +extern UINT8 IsAcFree(UINT16 wAcIndex); + +/* +* @brief Ƿ +* @param wPhyId ID +* @return CI_ERROR:ռãCI_SUCCESS: +* @note +*/ +extern UINT8 IsPhyFree(UINT16 wPhyId); + +/* +* @brief ȡǰ +* @param +* @return ǰ +* @note +*/ +extern UINT8 ToaGetUtTrainNum(void); + +/* +* @brief ȡǰID +* @param szUtId ID +* @return CI_ERROR:ȡʧܣCI_SUCCESS:ȡɹ +* @note +*/ +extern UINT8 ToaGetUtTrainIdBuf(UINT16 szUtId[TRAIN_SUM_MAX]); + +/* +* @brief ȡָν +* @param wPhyId ID +* @return +TRAIN_SUM_MAXʧ +* @note +*/ +extern UINT8 ToaGetPhyUtNum(UINT16 wPhyId); + +/* +* @brief ȡָνID +* @param wPhyId ID +* @param szUtId гID +* @return CI_SUCCESS:ȡɹCI_ERROR:ȡʧ +* @note +*/ +extern UINT8 ToaGetPhyUtId(UINT16 wPhyId, UINT16 szUtId[TRAIN_SUM_MAX]); + +/* +* @brief +* @param +* @return +* @note +*/ +extern void ToaClearCmd(void); + +/** +* @brief ȡռѹг +* @param wPhyId ID +* @param szUtId гID +* @return MAX_AC_IN_TRAIN:ʧܣ:г +* @note +*/ +extern UINT8 ToaGetPhyTrain(UINT16 wPhyId, UINT16 szTrainId[MAX_AC_IN_TRAIN]); + +/** +* @brief ȡTOA +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +extern UINT32 ToaGetTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex); + +/** +* @brief TOA +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +extern UINT32 ToaSetTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex); +#endif diff --git a/TSCP/src/APP/ciapp/Transmit/TransmitDefine.h b/TSCP/src/APP/ciapp/Transmit/TransmitDefine.h new file mode 100644 index 0000000..7aa6ddc --- /dev/null +++ b/TSCP/src/APP/ciapp/Transmit/TransmitDefine.h @@ -0,0 +1,52 @@ +/******************************************************** +* +* TransmitDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-04-01 +* ߣ +* ͨŹöͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _TRANSMIT_DEFINE_H_ +#define _TRANSMIT_DEFINE_H_ + + +/*ϵͳͷļ*/ +#include "../System/SystemConfigDefine.h" + + + + +#define TRANSMIT_OBJECT_SUM_MAX ((UINT16)16) /*ͨŶֵ*/ +#define TRANSMIT_OBJECT_DEVICE_SUM_MAX ((UINT16)18) /*ͬͬ豸ͨŵ豸ֵ*/ + + + +/*ͨ״̬*/ +#define TRANSMIT_STATE_BAD ((UINT8)0x55) /*ͨж*/ +#define TRANSMIT_STATE_GOOD ((UINT8)0xaa) /*ͨ*/ +#define NOT_IN_TRAINSMIT_LIST ((UINT8)0x5a) /*ͨб*/ + +/*ͨ״̬*/ +#define TRANSMIT_2OO2_STATE_GOOD ((UINT8)0x01) /*ͨ*/ +#define TRANSMIT_2OO2_STATE_LINK ((UINT8)0x02) /*ά*/ +#define TRANSMIT_2OO2_STATE_BAD ((UINT8)0x03) /*ͨж*/ + +/*ͨŹж*/ +#define COM_ERROR_FSIO_MAXCYCLENUM ((UINT16)5) /*IOͨŹж*/ +#define COM_ERROR_LEU_MAXCYCLENUM ((UINT32)100) /*LEUͨŹж*/ + + +/*ͨ*/ +#define COM_CYCNUM_CI_TO_ATS ((UINT8)1) /*ATSÿڷһ*/ +#define COM_CYCNUM_CI_TO_XIANDI ((UINT8)1) /*ֵÿڷһ*/ + +#define TRANSMIT_NET_ATC_RED ((UINT8)0x55) /*ATCչ*/ +#define TRANSMIT_NET_ATC_BLUE ((UINT8)0xAA) /*ATCչ*/ +#endif + + diff --git a/TSCP/src/APP/ciapp/Transmit/TransmitStateDataManage.c b/TSCP/src/APP/ciapp/Transmit/TransmitStateDataManage.c new file mode 100644 index 0000000..f27b840 --- /dev/null +++ b/TSCP/src/APP/ciapp/Transmit/TransmitStateDataManage.c @@ -0,0 +1,1027 @@ +/******************************************************** +* +* TransmitStateDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-06-07 +* ߣ +* ͨ״̬ݹļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#include "TransmitStateDataManage.h" + + + + +TransmitRelationDataStruct TransmitRelaDataStru[TRANSMIT_OBJECT_SUM_MAX]; /*ͨŹϵݽṹ*/ +TransmitStateDataStruct TransmitStateDataStru[TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX]; /*ͨ״̬ṹ*/ + +UINT32 gRedTransmitObjRcvCyc[TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX] = { 0U }; +UINT32 gBlueTransmitObjRcvCyc[TRANSMIT_OBJECT_SUM_MAX * TRANSMIT_OBJECT_DEVICE_SUM_MAX] = { 0U }; + + +UINT16 TransmitRelaDataCurSum = 0u; /*ͨŹϵݵǰ*/ +UINT16 TransmitStateDataCurSum = 0u; /*ͨŹϵ״̬ݵǰ*/ + +/*ATSͨڼ¼*/ +UINT8 ComCycNumForCiToAts = 0u;/*ʼΪ0ñΪ0ʱݣΪCOM_CYCNUM_CI_TO_ATSݵڸֵݼ*/ +/*ֵͨڼ¼*/ +UINT8 ComCycNumForCiToXianDi = 0u;/*ʼΪ0ñΪ0ʱݣΪCOM_CYCNUM_CI_TO_XIANDIݵڸֵݼ*/ + +/* +* ȡָCIָ豸豸 +* ˵ const UINT8 systemType, ϵͳ +* ֵ 0: ȡʧ +* >0: ȡݳɹ +*/ +UINT8 GetCiTransmitSpecifySysDevSum(const UINT8 systemType) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 ii = 0u; + UINT8 retVal = 0u; + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if ((0u == localCiId) || (CI_SUM_MAX <=localCiId)) + { /*ID*/ + + retVal = 0u; + } + else + { + if ((CI_SYSTEM_TYPE_ATS != systemType) && + (CI_SYSTEM_TYPE_CI != systemType) && + (CI_SYSTEM_TYPE_ZC != systemType) && + (CI_SYSTEM_TYPE_LEU != systemType) && + (CI_SYSTEM_TYPE_XIANDI != systemType) && + (CI_SYSTEM_TYPE_PLATFORM !=systemType) && + (CI_SYSTEM_TYPE_PSC != systemType) && + (CI_SYSTEM_TYPE_OC != systemType) && + (CI_SYSTEM_TYPE_AXIS != systemType)&& + (CI_SYSTEM_TYPE_TMC != systemType)) + { /*ϵͳʹ*/ + + retVal = 0u; + } + else + { + for (ii = 0u ; ii < TransmitRelaDataCurSum; ii++) + { + if ((TransmitRelaDataStru[ii].CiId == localCiId) && + (TransmitRelaDataStru[ii].SystemType == systemType)) + { + retVal = TransmitRelaDataStru[ii].DeviceSum; + break; + } + else + { + ; + } + } + } + } + return retVal; +} + + +/* +* ȡָCIָ豸豸ID +* ˵ const UINT8 systemType, ϵͳ +* ֵ NULL: ȡʧ +* !NULL: ȡݳɹ +*/ +UINT8* GetCiTransmitSpecifySysDevBuf(const UINT8 systemType) +{ + UINT8 localCiId = 0u; /*ID*/ + UINT8 ii = 0u; + UINT8 * retVal = NULL; + + localCiId = GetSystemParaLocalCiId(); /*ȡID*/ + + if ((0u == localCiId) || (localCiId >= CI_SUM_MAX)) + { /*ID*/ + + retVal = NULL; + } + else + { + if ((CI_SYSTEM_TYPE_ATS != systemType) && + (CI_SYSTEM_TYPE_CI != systemType) && + (CI_SYSTEM_TYPE_ZC != systemType) && + (CI_SYSTEM_TYPE_LEU != systemType) && + (CI_SYSTEM_TYPE_XIANDI != systemType) && + (CI_SYSTEM_TYPE_PLATFORM != systemType) && + (CI_SYSTEM_TYPE_PSC != systemType) && + (CI_SYSTEM_TYPE_OC != systemType) && + (CI_SYSTEM_TYPE_TMC != systemType) && + (CI_SYSTEM_TYPE_AXIS != systemType)) + { /*ϵͳʹ*/ + + retVal = NULL; + } + else + { + for (ii = 0u ; ii < TransmitRelaDataCurSum; ii++) + { + if ((TransmitRelaDataStru[ii].CiId == localCiId) && + (TransmitRelaDataStru[ii].SystemType == systemType)) + { + retVal = TransmitRelaDataStru[ii].DeviceIdBuf; + break; + } + else + { + ; + } + } + } + } + return retVal; +} + + +/* +* ȡָCIָ豸IDĽں +* ˵ const UINT8 localCiId, վID +* const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* ֵ 0: ȡʧ +* >0: ں +*/ +UINT32 GetCiTransmitRecvDataCycNum(const UINT8 localCiId, const UINT8 DeviceType, const UINT8 DeviceId) +{ + UINT8 ii = 0u; + UINT32 retVal = CI_ERROR; + + if ((localCiId <= 0u) || (localCiId > CI_SUM_MAX)) + { + retVal = CI_ERROR; + } + else + { + if ((CI_SYSTEM_TYPE_ATS == DeviceType) || + (CI_SYSTEM_TYPE_ZC == DeviceType) || + (CI_SYSTEM_TYPE_XIANDI == DeviceType) + ) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType)) + { + retVal = TransmitStateDataStru[ii].RecvDataCycNum; + break; + } + } + } + else if ((CI_SYSTEM_TYPE_CI == DeviceType) || (CI_SYSTEM_TYPE_PLATFORM == DeviceType) + || (CI_SYSTEM_TYPE_PSC == DeviceType) || (CI_SYSTEM_TYPE_LEU == DeviceType) + || (CI_SYSTEM_TYPE_AXIS == DeviceType) || (CI_SYSTEM_TYPE_OC == DeviceType)) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + retVal = TransmitStateDataStru[ii].RecvDataCycNum; + break; + } + } + } + else + { + retVal = CI_ERROR; + } + } + + + + return retVal; + +} + +/* +* ָCIָ豸IDĽں +* ˵ const UINT8 localCiId, վID +* const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* const UINT32 recvDataCycNum, +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetCiTransmitRecvDataCycNum(const UINT8 localCiId, const UINT8 DeviceType, const UINT8 DeviceId, const UINT32 recvDataCycNum) +{ + UINT8 ii = 0u; + UINT8 retVal = CI_ERROR; + + if ((localCiId <= 0u) || (localCiId > CI_SUM_MAX)) + { + retVal = CI_ERROR; + } + else + { + if ((CI_SYSTEM_TYPE_ATS == DeviceType) + || (CI_SYSTEM_TYPE_ZC == DeviceType) + || (CI_SYSTEM_TYPE_XIANDI == DeviceType) + || (CI_SYSTEM_TYPE_TMC == DeviceType) + ) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType)) + { + TransmitStateDataStru[ii].RecvDataCycNum = recvDataCycNum; + retVal = CI_SUCCESS; + break; + + } + + } + } + else if ((CI_SYSTEM_TYPE_CI == DeviceType) || (CI_SYSTEM_TYPE_PLATFORM == DeviceType)|| + (CI_SYSTEM_TYPE_PSC == DeviceType) || (CI_SYSTEM_TYPE_LEU == DeviceType) || + (CI_SYSTEM_TYPE_OC == DeviceType) || (CI_SYSTEM_TYPE_AXIS == DeviceType)) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + TransmitStateDataStru[ii].RecvDataCycNum = recvDataCycNum; + retVal = CI_SUCCESS; + break; + } + } + } + else + { + retVal = CI_ERROR; + } + } + + + + return retVal; +} + +/* +* ȡָCIָ豸IDͨ״̬ +* ˵ const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* ֵ 0: ȡʧ +* >0: ͨ״̬ +*/ +UINT8 GetCiTransmitState(const UINT8 DeviceType, const UINT8 DeviceId) +{ + UINT8 ii = 0u; + UINT8 retVal = CI_ERROR; + + if ((CI_SYSTEM_TYPE_CI == DeviceType) || (CI_SYSTEM_TYPE_PLATFORM == DeviceType) || (CI_SYSTEM_TYPE_PSC == DeviceType) + || (CI_SYSTEM_TYPE_AXIS == DeviceType) || (CI_SYSTEM_TYPE_LEU == DeviceType) || (CI_SYSTEM_TYPE_OC == DeviceType) + || (CI_SYSTEM_TYPE_ATS == DeviceType) || (CI_SYSTEM_TYPE_XIANDI == DeviceType) || (CI_SYSTEM_TYPE_ZC == DeviceType) + || (CI_SYSTEM_TYPE_VOBC == DeviceType) || (CI_SYSTEM_TYPE_TMC == DeviceType)) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + retVal = TransmitStateDataStru[ii].transmitState; + break; + } + else + { + ; /**/ + } + + } + } + else + { + retVal = CI_ERROR; + } + + return retVal; + + +} + +/* +* ָCIָ豸IDͨ״̬ +* ˵ const UINT8 localCiId, վID +* const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* ֵ 0: ʧ +* 1: ³ɹ +* ޸ģ Ӻ״̬ +*/ +UINT8 UpdateCiTransmitState(const UINT8 localCiId, const UINT8 DeviceType, const UINT8 DeviceId) +{ + UINT8 ii = 0u; + UINT8 retVal = CI_ERROR; + UINT32 badComCycNum = 0u; + UINT32 dwRedBadComCycNum = 0U; + UINT32 dwBlueBadComCycNum = 0U; + UINT32 badEnsureCount = 0u; + if ((0u == localCiId) || (CI_SUM_MAX < localCiId)) + { + retVal = CI_ERROR; + } + else + { + if (CI_SYSTEM_TYPE_ZC == DeviceType) + { + for(ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + badEnsureCount = GetCiAndZcTransBadEnsureCnt(); + if (badComCycNum > badEnsureCount) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount)&&(dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + } + else if ((CI_SYSTEM_TYPE_ATS == DeviceType) || (CI_SYSTEM_TYPE_XIANDI == DeviceType)) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + /*CIATSͨжʼ510ݽṹ޴ãдΪ20*/ + badEnsureCount = 20U; + if (badComCycNum > badEnsureCount) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount) && (dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + } + else if(CI_SYSTEM_TYPE_CI == DeviceType) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + /*ͨ*/ + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + badEnsureCount = GetCiAndCiTransBadEnsureCnt(); + if ((badComCycNum > badEnsureCount) || (0u == TransmitStateDataStru[ii].RecvDataCycNum)) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount) && (dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + } + else if(CI_SYSTEM_TYPE_PLATFORM == DeviceType) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + /*ͨ*/ + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + badEnsureCount = GetCiAndPsdTransBadEnsureCnt(); + if (badComCycNum > badEnsureCount) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount) && (dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + } + else if(CI_SYSTEM_TYPE_PSC == DeviceType) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + /*ͨ*/ + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + badEnsureCount = GetCiAndPscTransBadEnsureCnt(); + if (badComCycNum > badEnsureCount) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount) && (dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + } + else if (CI_SYSTEM_TYPE_AXIS == DeviceType) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + /*ͨ*/ + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + badEnsureCount = GetCiAndAxleTransBadEnsureCnt(); + if (badComCycNum > badEnsureCount) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount) && (dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + } + else if (CI_SYSTEM_TYPE_OC == DeviceType) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + /*ͨ*/ + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + badEnsureCount = GetCiAndOcTransmitBadEnsureCnt(); + if (badComCycNum > badEnsureCount) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount) && (dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + } + else if(CI_SYSTEM_TYPE_LEU == DeviceType) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + /*ͨãļLEUͨжʱãʱʹZCͨж*/ + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + badEnsureCount = COM_ERROR_LEU_MAXCYCLENUM; + if (badComCycNum > badEnsureCount) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount) && (dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + + } + else if (CI_SYSTEM_TYPE_TMC == DeviceType) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + /*ͨ*/ + badComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataCycNum; + badEnsureCount = GetTiocAndTmcTransBadEnsureCnt(); + if ((badComCycNum > badEnsureCount) || (0u == TransmitStateDataStru[ii].RecvDataCycNum)) + { + /*ͨųʱ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + TransmitStateDataStru[ii].transmitState = TRANSMIT_STATE_GOOD; + } + + TransmitStateDataStru[ii].RecvDataRedCycNum = gRedTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataRedCycNum : gRedTransmitObjRcvCyc[ii]; + TransmitStateDataStru[ii].RecvDataBlueCycNum = gBlueTransmitObjRcvCyc[ii] == 0U ? TransmitStateDataStru[ii].RecvDataBlueCycNum : gBlueTransmitObjRcvCyc[ii]; + dwRedBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataRedCycNum; + dwBlueBadComCycNum = Get2oo2CurCycleNum() - TransmitStateDataStru[ii].RecvDataBlueCycNum; + if ((dwRedBadComCycNum <= badEnsureCount) && (dwBlueBadComCycNum <= badEnsureCount)) + { + /*˫*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_GOOD; + } + else if ((dwRedBadComCycNum <= badEnsureCount) || (dwBlueBadComCycNum <= badEnsureCount)) + { + /*ͨ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_LINK; + } + else + { + /*ͨŹ*/ + TransmitStateDataStru[ii].redundantTransmitState = TRANSMIT_2OO2_STATE_BAD; + } + retVal = CI_SUCCESS; + break; + } + } + + } + else + { + retVal = CI_ERROR; + } + } + + + + return retVal; + +} + +/* +* ȡͨڼ¼ +* ˵ const UINT8 DeviceType, 豸 +* ֵ ͨż¼ֵ +*/ +UINT8 GetComCycNumForCiToOtherSys(const UINT8 DeviceType) +{ + UINT8 comCycNum = 0u; + + if (CI_SYSTEM_TYPE_ATS == DeviceType) + { + comCycNum = ComCycNumForCiToAts; + } + else if (CI_SYSTEM_TYPE_XIANDI == DeviceType) + { + comCycNum = ComCycNumForCiToXianDi; + } + else + { + /**/ + } + + return comCycNum; +} + +/* +* ͨڼ¼ +* ˵ const UINT8 DeviceType, 豸 +* const UINT8 ComCycNumForCiToOtherSys, ͨڼ¼ +* ֵ ͨż¼ֵ +*/ +void SetComCycNumForCiToOtherSys(const UINT8 DeviceType, const UINT8 ComCycNum) +{ + + if (CI_SYSTEM_TYPE_ATS == DeviceType) + { + ComCycNumForCiToAts = ComCycNum; + } + else if (CI_SYSTEM_TYPE_XIANDI == DeviceType) + { + ComCycNumForCiToXianDi = ComCycNum; + } + else + { + /**/ + } +} + +/* +* ȡͨ״̬ +* ˵ const UINT8 otherCiId, ID +* ֵ TRANSMIT_STATE_GOODͨ + TRANSMIT_STATE_BADͨŹ + NOT_IN_TRAINSMIT_LISTͨбУ +*/ +UINT8 GetLocalCiAndOtherCiTransSta(const UINT8 otherCiId) +{ + UINT8 ii = 0u; + UINT8 retVal = CI_ERROR; + UINT8 localCi = GetSystemParaLocalCiId(); + UINT32 curCycle = Get2oo2CurCycleNum(); + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCi) + && (TransmitStateDataStru[ii].DeviceType == CI_SYSTEM_TYPE_CI) + && (TransmitStateDataStru[ii].DeviceId == otherCiId)) + { + /*ͨ*/ + if (curCycle - TransmitStateDataStru[ii].RecvDataCycNum > GetCiAndCiTransBadEnsureCnt()) + { + /*ͨųʱ*/ + retVal = TRANSMIT_STATE_BAD; + } + else + { + /*ͨ*/ + retVal = TRANSMIT_STATE_GOOD; + } + break; + } + } + if (CI_ERROR == retVal) + {/*ͨб*/ + retVal = NOT_IN_TRAINSMIT_LIST; + } + return retVal; +} + + +/* +* @func ȡָTiocͨATS豸ID +* @param void +* @return 0: ȡʧ +* >0: 豸ID +*/ +UINT16 GetTiocTrnsmtGtwyDevTypeId(void) +{ + UINT8 ii = 0u; + UINT16 retVal = CI_ERROR; + const UINT8 chLocalTiocId = GetSystemParaLocalCiId(); + + for (ii = 0u; ii < TransmitRelaDataCurSum; ii++) + { + if ((TransmitRelaDataStru[ii].CiId == chLocalTiocId) + &&(CI_SYSTEM_TYPE_ATS==TransmitRelaDataStru[ii].SystemType)) + { + retVal = TransmitRelaDataStru[ii].wGatewayComputerId; + break; + } + } + + return retVal; +} + +/* +* ָCIָ豸IDĽں +* ˵ const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* const UINT8 chNetType , +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetCiTrnsmitCycNumByNetType(const UINT8 DeviceType, const UINT8 DeviceId, const UINT8 chNetType) +{ + UINT8 ii = 0u; + UINT8 retVal = CI_ERROR; + UINT8 localCiId = 0U; + UINT32 recvDataCycNum = 0U; + recvDataCycNum = Get2oo2CurCycleNum(); + localCiId = GetSystemParaLocalCiId(); + if ((localCiId <= 0u) || (localCiId > CI_SUM_MAX)) + { + retVal = CI_ERROR; + }else if((TRANSMIT_NET_ATC_RED !=chNetType)&&(TRANSMIT_NET_ATC_BLUE!= chNetType)) + { + retVal = CI_ERROR; + } + else + { + if ((CI_SYSTEM_TYPE_CI == DeviceType) || (CI_SYSTEM_TYPE_PLATFORM == DeviceType) || + (CI_SYSTEM_TYPE_PSC == DeviceType) || (CI_SYSTEM_TYPE_LEU == DeviceType) || + (CI_SYSTEM_TYPE_OC == DeviceType) || (CI_SYSTEM_TYPE_AXIS == DeviceType) || + (CI_SYSTEM_TYPE_ATS == DeviceType) || (CI_SYSTEM_TYPE_ZC == DeviceType) || + (CI_SYSTEM_TYPE_XIANDI == DeviceType) || (CI_SYSTEM_TYPE_TMC == DeviceType)) + { + for (ii = 0u; ii < TransmitStateDataCurSum; ii++) + { + if ((TransmitStateDataStru[ii].chLocalCiId == localCiId) + && (TransmitStateDataStru[ii].DeviceType == DeviceType) + && (TransmitStateDataStru[ii].DeviceId == DeviceId)) + { + if (TRANSMIT_NET_ATC_RED == chNetType) + { + gRedTransmitObjRcvCyc[ii] = recvDataCycNum; + } + else + { + gBlueTransmitObjRcvCyc[ii] = recvDataCycNum; + } + retVal = CI_SUCCESS; + break; + } + } + } + else + { + retVal = CI_ERROR; + } + } + + + + return retVal; +} + +/* +* ȡCI豸ͨ״̬2002Ų +* ˵ const UINT8 systemType, ϵͳ +* const UINT8 index, ״̬± +* ֵ ͨ״̬ +*/ +UINT8 Get2oo2CiAndOtherSysCommState(const UINT8 DeviceType,const UINT8 chIndex) +{ + UINT16 ii = 0U; + UINT16 jj = 0U; + UINT8 retVal = CI_ERROR; + UINT8 DeviceId = 0U; + + for (ii = 0u; ii < TRANSMIT_OBJECT_SUM_MAX; ii++) + { + if (TransmitRelaDataStru[ii].SystemType == DeviceType) + { + if (TRANSMIT_OBJECT_DEVICE_SUM_MAX > chIndex) + { + DeviceId = TransmitRelaDataStru[ii].DeviceIdBuf[chIndex]; + if ((CI_SYSTEM_TYPE_CI == DeviceType) || (CI_SYSTEM_TYPE_PLATFORM == DeviceType) || (CI_SYSTEM_TYPE_PSC == DeviceType) + || (CI_SYSTEM_TYPE_AXIS == DeviceType) || (CI_SYSTEM_TYPE_LEU == DeviceType) || (CI_SYSTEM_TYPE_OC == DeviceType) + || (CI_SYSTEM_TYPE_ATS == DeviceType) || (CI_SYSTEM_TYPE_XIANDI == DeviceType) || (CI_SYSTEM_TYPE_ZC == DeviceType) + || (CI_SYSTEM_TYPE_VOBC == DeviceType) || (CI_SYSTEM_TYPE_TMC == DeviceType)) + { + for (jj = 0u; jj < TransmitStateDataCurSum; jj++) + { + if ((TransmitStateDataStru[jj].DeviceType == DeviceType) + && (TransmitStateDataStru[jj].DeviceId == DeviceId)) + { + retVal = TransmitStateDataStru[jj].redundantTransmitState; + break; + + } + else + { + ; /*ִ*/ + } + + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + ; /**/ + } + break; + } + else + { + ; /*ִ*/ + } + } +#ifdef WIN32 + return (TRANSMIT_STATE_GOOD ==GetCiTransmitState(DeviceType, DeviceId)?TRANSMIT_2OO2_STATE_GOOD: TRANSMIT_2OO2_STATE_BAD); +#else + return retVal; +#endif +} + + +/* +* @func ȡָTiocͨATSӿڻ豸ID +* @param void +* @return 0: ȡʧ +* >0: 豸ID +*/ +UINT16 GetATSInterfaceTypeId(void) +{ + UINT8 ii = 0u; + UINT16 retVal = CI_ERROR; + const UINT8 chLocalTiocId = GetSystemParaLocalCiId(); + + for (ii = 0u; ii < TransmitRelaDataCurSum; ii++) + { + if ((TransmitRelaDataStru[ii].CiId == chLocalTiocId) + && (CI_SYSTEM_TYPE_ATS_INTERFACE == TransmitRelaDataStru[ii].SystemType)) + { + retVal = (UINT16)((UINT16)CI_SYSTEM_TYPE_ATS_INTERFACE<<8)+ TransmitRelaDataStru[ii].DeviceIdBuf[0]; + break; + } + } + + return retVal; +} diff --git a/TSCP/src/APP/ciapp/Transmit/TransmitStateDataManage.h b/TSCP/src/APP/ciapp/Transmit/TransmitStateDataManage.h new file mode 100644 index 0000000..349d35c --- /dev/null +++ b/TSCP/src/APP/ciapp/Transmit/TransmitStateDataManage.h @@ -0,0 +1,177 @@ +/******************************************************** +* +* TransmitStateDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2012-06-07 +* ߣ +* ͨ״̬ݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _TRANSMIT_STATE_DATA_MANAGE_H_ +#define _TRANSMIT_STATE_DATA_MANAGE_H_ + + +#include "TransmitDefine.h" +#include "../System/CiSystemDefine.h" +#include "CommonTypes.h" +#include "Convert.h" +#include "../System/SystemParameterManage.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ͨŹϵṹ*/ +typedef struct S_TransmitRelationDataStruct +{ + UINT8 CiId; /*ID (ֶ)*/ + UINT8 SystemType; /*ϵͳ豸 (ֶ)*/ + UINT8 DeviceSum; /*豸*/ + UINT8 DeviceIdBuf[TRANSMIT_OBJECT_DEVICE_SUM_MAX]; /*ϵͳ豸ID (ֶ)*/ + UINT16 wGatewayComputerId; /*ӦATSص豸ID*/ +} TransmitRelationDataStruct; + + +/*ͨ״̬ṹ*/ +typedef struct S_TransmitStateDataStruct +{ + UINT8 chLocalCiId; /*ID (ʼֶ)*/ + UINT8 DeviceType; /*ϵͳ豸 (ʼֶ)*/ + UINT8 DeviceId; /*ϵͳ豸ID (ʼֶ)*/ + UINT8 transmitState; /*ͨ״̬ (ֶ̬) GOOD OR BAD*/ + UINT8 redundantTransmitState; /*ͨ״̬ (ֶ̬) OneGood TwoGood Bad*/ + UINT32 RecvDataCycNum; /*ں (ֶ̬)*/ + UINT32 RecvDataRedCycNum; /*ں (ֶ̬)*/ + UINT32 RecvDataBlueCycNum; /*ں (ֶ̬)*/ +} TransmitStateDataStruct; + + + +/* +* ȡָCIָ豸豸 +* ˵ const UINT8 systemType, ϵͳ +* ֵ 0: ȡʧ +* >0: ȡݳɹ +*/ +UINT8 GetCiTransmitSpecifySysDevSum(const UINT8 systemType); + +/* +* ȡָCIָ豸豸ID +* ˵ const UINT8 systemType, ϵͳ +* ֵ NULL: ȡʧ +* !NULL: ȡݳɹ +*/ +UINT8* GetCiTransmitSpecifySysDevBuf(const UINT8 systemType); + +/* +* ȡָCIָ豸IDĽں +* ˵ const UINT8 localCiId, վID +* const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* ֵ 0: ȡʧ +* >0: ں +*/ +UINT32 GetCiTransmitRecvDataCycNum(const UINT8 localCiId, const UINT8 DeviceType, const UINT8 DeviceId); + +/* +* ָCIָ豸IDĽں +* ˵ const UINT8 localCiId, վID +* const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* const UINT32 recvDataCycNum, +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetCiTransmitRecvDataCycNum(const UINT8 localCiId, const UINT8 DeviceType, const UINT8 DeviceId, const UINT32 recvDataCycNum); + +/* +* ȡָCIָ豸IDͨ״̬ +* ˵ const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* ֵ 0: ȡʧ +* >0: ͨ״̬ +*/ +UINT8 GetCiTransmitState(const UINT8 DeviceType, const UINT8 DeviceId); + +/* +* ָCIָ豸IDͨ״̬ +* ˵ const UINT8 localCiId, վID +* const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* ֵ 0: ʧ +* 1: ³ɹ +*/ +UINT8 UpdateCiTransmitState(const UINT8 localCiId, const UINT8 DeviceType, const UINT8 DeviceId); + +/* +* ȡͨڼ¼ +* ˵ const UINT8 DeviceType, 豸 +* ֵ ͨż¼ֵ +*/ +UINT8 GetComCycNumForCiToOtherSys(const UINT8 DeviceType); + +/* +* ͨڼ¼ +* ˵ const UINT8 DeviceType, 豸 +* const UINT8 ComCycNumForCiToOtherSys, ͨڼ¼ +* ֵ ͨż¼ֵ +*/ +void SetComCycNumForCiToOtherSys(const UINT8 DeviceType, const UINT8 ComCycNum); + +/* +* ȡͨ״̬ +* ˵ const UINT8 otherCiId, ID +* ֵ TRANSMIT_STATE_GOODͨ + TRANSMIT_STATE_BADͨŹ + NOT_IN_TRAINSMIT_LISTͨбУ +*/ +UINT8 GetLocalCiAndOtherCiTransSta(const UINT8 otherCiId); + +/* +* @func ȡָTiocͨATS豸ID +* @param void +* @return 0: ȡʧ +* >0: 豸ID +*/ +UINT16 GetTiocTrnsmtGtwyDevTypeId(void); + +/* +* ָCIָ豸IDĽں +* ˵ const UINT8 localCiId, վID +* const UINT8 DeviceType, 豸 +* const UINT8 DeviceId, 豸ID +* const UINT32 recvDataCycNum, +* const UINT8 chNetType , +* ֵ 0: ʧ +* 1: ݳɹ +*/ +UINT8 SetCiTrnsmitCycNumByNetType(const UINT8 DeviceType, const UINT8 DeviceId, const UINT8 chNetType); + +/* +* ȡCI豸ͨ״̬ +* ˵ const UINT8 systemType, ϵͳ +* const UINT8 index, ״̬± +* ֵ ͨ״̬ +*/ +UINT8 Get2oo2CiAndOtherSysCommState(const UINT8 DeviceType, const UINT8 chIndex); + +/* +* @func ȡָTiocͨATSӿڻ豸ID +* @param void +* @return 0: ȡʧ +* >0: 豸ID +*/ +UINT16 GetATSInterfaceTypeId(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDataManage.c b/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDataManage.c new file mode 100644 index 0000000..8cd084c --- /dev/null +++ b/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDataManage.c @@ -0,0 +1,1375 @@ +/******************************************************** +* +* VirtualDeviceDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-12-16 +* ߣ +* 豸̬ݹ +* ޸ļ¼ +* +********************************************************/ +#include "VirtualDevDefine.h" +#include "VirtualDevDataManage.h" + +VirtualZDZFAJDataStruct VirtualZDZFAJData; + +VirtualCIStruct g_VirtualCIStructData = {0u};/*洢*/ +/*ӿ*/ + +/* +* ȡ۷豸 +* ˵ +* ֵ ۷豸 +*/ +UINT8 GetVirtualZDZFDevType(void) +{ + return VirtualZDZFAJData.virtualDevType; +} + +#if 0 +/* +* ȡ۷Ӧ۷Ƶ״̬ +* ˵ +* ֵ ۷Ƶ״̬ +*/ +UINT8 GetVirtualZDZFFlashState(void) +{ + return VirtualZDZFAJData.flashState; +} + +/* +* ȡ۷Ӧ۷Ƶȵ״̬ +* ˵ +* ֵ ۷Ƶȵ״̬ +*/ +UINT8 GetVirtualZDZFSteadyState(void) +{ + return VirtualZDZFAJData.steadyState; +} + +#endif +/* +* ȡ۷Ӧ۷ƵID +* ˵ +* ֵ ۷ID +*/ +UINT8 GetVirtualZDZFBelongCiId(void) +{ + return VirtualZDZFAJData.belongCiId; +} + +/* +* ȡ۷״̬ +* ˵ +* ֵ ۷״̬ +*/ +UINT8 GetVirtualZDZFButtonState(void) +{ + return VirtualZDZFAJData.btnState; +} + +/* +* ָID ۷ť״̬ +* ˵ const UINT8 state, ť״̬ +* ֵ +*/ +void SetVirtualZDZFButtonState(const UINT8 state) +{ + if ((VIRTUAL_ZDZFAJ_BUTTON_YES == state) || (VIRTUAL_ZDZFAJ_BUTTON_NO == state)) + { + VirtualZDZFAJData.btnState = state;/*ðť״̬*/ + } +} + +/* +* ʼ۷ť豸״̬ +* ˵ +* ֵ +*/ +void InitVirtualZDZFData(void) +{ + VirtualZDZFAJData.belongCiId = 0u; + VirtualZDZFAJData.virtualDevType = 0u; + VirtualZDZFAJData.btnState = VIRTUAL_ZDZFAJ_BUTTON_NO;/*Զ۷ťδ*/ +} + +/* +* ȡָȫվ״̬ +* ˵ ID +* ֵ ȫվ״̬ +* +*/ +UINT8 GetVirCIAllSignalBrightState(UINT8 VirCIid) +{ + UINT8 i=0u; + UINT8 reVal = 0u; + for(i=0u;(i index) + { + reVal = g_VirtualCIStructData.virtualCi[index].virtualCiId; + } + return reVal; +} +/* +* ȡָ״̬ +* ˵ ID +* ֵ ȫվ״̬ +* +*/ +UINT8 GetVirCIAllSwitchYLockState(UINT8 VirCIid) +{ + UINT8 i=0u; + UINT8 reVal = 0u; + for(i=0u;(i indicatorId) + { + for(i=0u;(i indicatorId) + { + for(i=0u;(i indicatorId) + { + virNum = GetVirtualCINum(); + for(i=0u;(i indicatorId) + { + virNum = GetVirtualCINum(); + for(i=0u;(i indicatorId) + { + virNum = GetVirtualCINum(); + for(i=0u;(i= VIRTUAL_CI_INDICATOR_SUM_MAX)||(NULL == plocalCiIndicatorIdBuf)||(NULL == pIndicatorConfigData)) + {/**/ + + reVal = CI_ERROR; + break; + } + else + { + reVal = CI_SUCCESS; + for (ii = 0u; ii < VIRTUAL_CI_INDICATOR_SUM_MAX; ii++) + { + if (jj == indicatorConfigDataSum) + {/*Ч*/ + + break; + } + + if (0u != pIndicatorConfigData[ii].IndicatorId) + {/*òΪЧ*/ + + plocalCiIndicatorIdBuf[jj] = (UINT8)pIndicatorConfigData[ii].IndicatorId; + jj++; + } + } + } + } + + return reVal; +} + +/* +* ȡָָʾID +* ˵ +* const UINT8 virCIid ID +* UINT8 index +* +* ֵ ָʾID +*/ +UINT8 GetVirCIlocalCiIndicatorId(const UINT8 virCIid,UINT8 index) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + UINT8 reVal = 0u; + + if(VIRTUAL_CI_INDICATOR_SUM_MAX >index) + { + virNum = GetVirtualCINum(); + for(i=0u;i indicatorId) + { + virNum = GetVirtualCINum(); + for(i=0u;i g_VirtualCIStructData.LocalCIBaojingdengNum) + { + } + else + { + localCIBaojingdengNum = 0u; + } + return localCIBaojingdengNum; +} + +/* +* ȡָʾID +* ˵ UINT16 index +* ֵ void +*/ +UINT16 GetLocalCIBaojingdengWId(UINT16 index) +{ + UINT16 reVal = 0u; + + if(LOCAL_CI_INDICATOR_SUM_MAX > index) + { + reVal = g_VirtualCIStructData.LocalCIBaojingdeng[index].wId; + } + + return reVal; +} + +/* +* ȡָʾID +* ˵ UINT16 index +* ֵ ָʾID +*/ +UINT8 GetLocalCIIndicatorIDOrType(UINT16 index) +{ + UINT8 reVal = 0u; + + if(LOCAL_CI_INDICATOR_SUM_MAX > index) + { + reVal = (UINT8)g_VirtualCIStructData.LocalCIBaojingdeng[index].wBjdID;/*IDҲ*/ + } + + return reVal; +} + +/* +* ȡָʾ +* ˵ UINT16 index +* ֵ id +*/ +UINT16 GetLocalCIBaojingdengBelongVir(UINT16 index) +{ + UINT16 reVal = 0u; + + if(LOCAL_CI_INDICATOR_SUM_MAX > index) + { + reVal = g_VirtualCIStructData.LocalCIBaojingdeng[index].wBelongVirCIid; + } + + return reVal; +} +/* +* ָ۷״̬ +* ˵ UINT8 devId ָʾ豸IDUINT8 virCIid ID,UINT8 stateñ־ +* ֵ void +*/ +void SetVirCIautoRtnIndictFlashState(UINT8 devId, UINT8 virCIid, UINT8 state) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + UINT8 jj = 0U; + UINT8 breakfalg = 0U; + + if ((0U < devId) && (UINT8_MAX > devId)) + { + virNum = GetVirtualCINum(); + for (i = 0u; i < virNum; i++) + { + if (g_VirtualCIStructData.virtualCi[i].virtualCiId == virCIid) + { + for (jj = 0U; jj < RTNINDICATOR_SUM_MAX; jj++) + { + if (devId == g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[jj].VirCiIndicatorDevId) + { + if ((VOBCTOCIAUTORTN_INDICT_MASK_VALID == state) || (VOBCTOCIAUTORTN_INDICT_MASK_INVALID == state)) + { + g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[jj].VirCiFlashState = state; + breakfalg = 1U; + break; + } + else + { + ; + } + } + else + { + ; + } + } + } + else + { + ; + } + if (1U == breakfalg) + { + break; + } + else + { + ; + } + } + } + else + { + ; + } +} +/* +* ȡָ۷״̬ +* ˵UINT8 devId ָʾ豸ID +* UINT8 virCIid ID +* ֵ ۷״̬ +*/ +UINT8 GetVirCIautoRtnIndictFlashState(UINT8 devId, UINT8 virCIid) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + UINT8 reVal = VOBCTOCIAUTORTN_INDICT_MASK_INVALID; + UINT8 jj = 0U; + UINT8 breakfalg = 0U; + + if ((0U < devId) && (UINT8_MAX > devId)) + { + virNum = GetVirtualCINum(); + for (i = 0u; i < virNum; i++) + { + if (g_VirtualCIStructData.virtualCi[i].virtualCiId == virCIid) + { + for (jj = 0U; jj < RTNINDICATOR_SUM_MAX; jj++) + { + if (devId == g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[jj].VirCiIndicatorDevId) + { + reVal = g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[jj].VirCiFlashState; + breakfalg = 1U; + break; + } + else + { + ; + } + } + } + else + { + ; + } + if (1U == breakfalg) + { + break; + } + else + { + ; + } + } + } + else + { + ; + } + + return reVal; +} +/* +* ָ۷ȵ״̬ +* ˵ UINT8 devId ָʾ豸IDUINT8 virCIid ID,UINT8 stateñ־ +* ֵ void +*/ +void SetVirCIautoRtnIndictSteadyState(UINT8 devId, UINT8 virCIid, UINT8 state) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + UINT8 jj = 0U; + UINT8 breakfalg = 0U; + + if ((0U < devId) && (UINT8_MAX > devId)) + { + virNum = GetVirtualCINum(); + for (i = 0u; i < virNum; i++) + { + if (g_VirtualCIStructData.virtualCi[i].virtualCiId == virCIid) + { + for (jj = 0U; jj < RTNINDICATOR_SUM_MAX; jj++) + { + if (devId == g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[jj].VirCiIndicatorDevId) + { + if ((VOBCTOCIAUTORTN_INDICT_MASK_VALID == state) || (VOBCTOCIAUTORTN_INDICT_MASK_INVALID == state)) + { + g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[jj].VirCiSteadyState = state; + breakfalg = 1U; + break; + } + else + { + ; + } + } + else + { + ; + } + } + } + else + { + ; + } + if (1U == breakfalg) + { + break; + } + else + { + ; + } + } + } + else + { + ; + } +} +/* +* ȡָ۷ȵ״̬ +* ˵ UINT8 devId ָʾ豸ID +* UINT8 virCIid ID +* ֵ ۷ȵ״̬ +*/ +UINT8 GetVirCIautoRtnIndictSteadyState(UINT8 devId, UINT8 virCIid) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + UINT8 reVal = VOBCTOCIAUTORTN_INDICT_MASK_INVALID; + UINT8 jj = 0U; + UINT8 breakfalg = 0U; + + if ((0U < devId) && (UINT8_MAX > devId)) + { + virNum = GetVirtualCINum(); + for (i = 0u; i < virNum; i++) + { + if (g_VirtualCIStructData.virtualCi[i].virtualCiId == virCIid) + { + for (jj = 0U; jj < RTNINDICATOR_SUM_MAX; jj++) + { + if (devId == g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[jj].VirCiIndicatorDevId) + { + reVal = g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[jj].VirCiSteadyState; + breakfalg = 1U; + break; + } + } + } + if (1U == breakfalg) + { + break; + } + } + } + return reVal; +} +/* +* ָ߱־ +* ˵UINT8 virCIid ID,UINT8 setFlag ñ־ +* ֵ void +*/ +void SetVirCIZfwHunxianFlag(UINT8 virCIid,UINT8 setFlag) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + + virNum = GetVirtualCINum(); + for(i=0u;i indicatorId) + { + for (i = 0u; (i < virNum) && (i < VIRTUAL_CI_MAX); i++) + { + if (g_VirtualCIStructData.virtualCi[i].virtualCiId == virCIid) + { + reVal = g_VirtualCIStructData.virtualCi[i].IndicatorConfigData[indicatorId].BjdDeviceId; + break; + } + } + } + return reVal; +} + +/* +* ȡָǷڱʵϽ +* ˵ const UINT8 chVirCiId ID +* ֵ CI_ERROR ڱʵϽ +* CI_SUCCESS ڱʵϽ +*cgh-20230529-޸YF0083-808 +*/ +UINT8 GetVirCIBelongLocalCI(const UINT8 chVirCiId) +{ + UINT8 i = 0u; + UINT8 reVal = CI_ERROR; + UINT8 chVirCiIdTemp = 0U;/*IDʱ*/ + + for (i = 0u; (i < g_VirtualCIStructData.virtualCiNum) && (i < VIRTUAL_CI_MAX); i++) + { + chVirCiIdTemp = g_VirtualCIStructData.virtualCi[i].virtualCiId; + if (chVirCiId == chVirCiIdTemp) + { + reVal = CI_SUCCESS; + break; + } + } + return reVal; +} +/* +* ȡ۷ָʾ豸ID +* ˵ UINT8 virCIid ID +* UINT8 index +* ֵ >0 ָʾ豸ID +* 0 ֻһ۷ʱΪ1û۷ +*/ +UINT8 GetVirCiRtnIndictDeviceId(UINT8 virCIid, UINT8 index) +{ + UINT8 i = 0u; + UINT8 virNum = 0u; + UINT8 jj = 0U; + UINT8 breakfalg = 0U; + UINT8 retValue = 0U; + + if (RTNINDICATOR_SUM_MAX > index) + { + virNum = GetVirtualCINum(); + for (i = 0u; i < virNum; i++) + { + if (g_VirtualCIStructData.virtualCi[i].virtualCiId == virCIid) + { + /*ر۷ָʾ豸ID*/ + retValue = g_VirtualCIStructData.virtualCi[i].VirCIRtnIndicatorStaData[index].VirCiIndicatorDevId; + break; + } + } + } + return retValue; +} diff --git a/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDataManage.h b/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDataManage.h new file mode 100644 index 0000000..c9ab384 --- /dev/null +++ b/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDataManage.h @@ -0,0 +1,509 @@ +/******************************************************** +* +* VirtualDeviceDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-12-16 +* ߣ +* 豸̬ݹ +* ޸ļ¼ +* +********************************************************/ +#ifndef __VIRTUALDEV_CONFIG_DATA_MANAGE_H_ +#define __VIRTUALDEV_CONFIG_DATA_MANAGE_H_ + +#include "VirtualDevDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" +#include "../Indicator/IndicatorDataManage.h" +#include "../Signal/SignalDataManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*Զ۷ť豸ݽṹ*/ +typedef struct S_VirtualZDZFAJDataStruct +{ + UINT8 belongCiId; /*ID*/ + UINT8 virtualDevType; /*Զ۷豸*/ + UINT8 btnState; /*۷ť״̬*/ +}VirtualZDZFAJDataStruct; + +/*۷ָʾʹ*/ +typedef struct s_VirCIRtnIndicatorState_stru +{ + UINT8 VirCiIndicatorDevId;/*ָʾ豸ID*/ + UINT8 VirCiFlashState;/*״̬*/ + UINT8 VirCiSteadyState;/*ȵ״̬*/ +}VirCIRtnIndicatorState; + + +/**/ +typedef struct S_Virtual_CI_Attri_Struct +{ + UINT8 virtualCiId;/*ID*/ + UINT8 chAllSignalBrightFlag;/*ȫվƱ־*/ + UINT8 chAllSwitchYLockFlag;/*ȫվ־*/ + UINT8 chLabourCancelLinShiXianState;/*˹ȡʱ*/ + UINT8 cimode;/*ģʽ*/ + UINT8 autoTriggerflag;/*Զʶ*/ + UINT8 ZfwFlag; /*ܸλʶ*/ + UINT32 ZfwStartCycNum;/*ܸλʼ*/ + UINT32 ZfwValidCycNum; /*ZFWܸλ̵Ч*/ + UINT8 ZfwjHunXianFLag;/*ܸλ߱־*/ + UINT8 IncludeOCNum;/*OC*/ + UINT8 IncludeOCid[VIRTUAL_CI_INCLUDE_OC_MAX];/*OCID*/ + IndicatorDataStruct IndicatorData[VIRTUAL_CI_INDICATOR_SUM_MAX];/*ָʾ*/ + IndicatorConfigDataStruct IndicatorConfigData[VIRTUAL_CI_INDICATOR_SUM_MAX];/*ָʾ*/ + UINT16 localCiIndicatorIdBuf[VIRTUAL_CI_INDICATOR_SUM_MAX];/*ָʾIDӳ*/ + UINT8 IndicatorConfigDataNum;/*ָʾ*/ + VirCIRtnIndicatorState VirCIRtnIndicatorStaData[RTNINDICATOR_SUM_MAX];/*۷ָʾ*/ + +}VirtualCIAttriStruct; + +/*ʾƼ̵ṹ*/ +typedef struct S_LocalCIRelay_BaoJingDengStru +{ + UINT16 wId; /*ID*/ + UINT8 wBelongCiId; /**/ + UINT8 wBelongVirCIid; /**/ + UINT16 wBjdID; /*ID*/ + UINT8 wBjdDevID; /*豸ID*/ +} LocalCIRelay_BaoJingDengStr; +/**/ +typedef struct S_VirtualCIStruct +{ + UINT8 LocalCiID;/*ID*/ + VirtualCIAttriStruct virtualCi[VIRTUAL_CI_MAX];/*ID*/ + UINT8 virtualCiNum;/*Ŀ*/ + LocalCIRelay_BaoJingDengStr LocalCIBaojingdeng[LOCAL_CI_INDICATOR_SUM_MAX];/*ı*/ + UINT16 LocalCIBaojingdengNum; +}VirtualCIStruct; + + +extern VirtualZDZFAJDataStruct VirtualZDZFAJData; + +extern VirtualCIStruct g_VirtualCIStructData;/*洢*/ + +/* +* ȡ۷豸 +* ˵ +* ֵ ۷豸 +*/ +UINT8 GetVirtualZDZFDevType(void); + +#if 0 +/* +* ȡ۷Ӧ۷Ƶ״̬ +* ˵ +* ֵ ۷Ƶ״̬ +*/ +UINT8 GetVirtualZDZFFlashState(void); + +/* +* ȡ۷Ӧ۷Ƶȵ״̬ +* ˵ +* ֵ ۷Ƶȵ״̬ +*/ +UINT8 GetVirtualZDZFSteadyState(void); + +#endif +/* +* ȡ۷״̬ +* ˵ +* ֵ ۷״̬ +*/ +UINT8 GetVirtualZDZFButtonState(void); + +/* +* ȡ۷Ӧ۷ƵID +* ˵ +* ֵ ۷ID +*/ +UINT8 GetVirtualZDZFBelongCiId(void); + +/* +* ָID ۷ť״̬ +* ˵ const UINT8 state, ť״̬ +* ֵ +*/ +void SetVirtualZDZFButtonState(const UINT8 state); + +/* +* ʼ۷ť豸״̬ +* ˵ +* ֵ +*/ +void InitVirtualZDZFData(void); + +/* +* ȡָȫվ״̬ +* ˵ ID +* ֵ ȫվ״̬ +* +*/ +UINT8 GetVirCIAllSignalBrightState(UINT8 VirCIid); +/* +* ָȫվ״̬ +* ˵ ID,ȫվ״̬ +* ֵ +* +*/ +void SetVirCIAllSignalBrightState(UINT8 VirCIid, UINT8 state); +/* +* ȡ +* ˵ +* ֵ +* +*/ +UINT8 GetVirtualCINum(void); +/* +* ȡָID +* ˵ +* ֵ ָID +* +*/ +UINT8 GetVirtualCIid(UINT8 index); +/* +* ȡָ״̬ +* ˵ ID +* ֵ ȫվ״̬ +* +*/ +UINT8 GetVirCIAllSwitchYLockState(UINT8 VirCIid); +/* +* ָ״̬ +* ˵ ID,״̬ +* ֵ +* +*/ +void SetVirCIAllSwitchYLockState(UINT8 VirCIid, UINT8 state); +/* +* ȡָʱ״̬ +* ˵ ID +* ֵ ʱ״̬ +* +*/ +UINT8 GetVirCILabourCancelLSXianSta(UINT8 VirCIid); +/* +* ָʱ״̬ +* ˵ ID,ʱ״̬ +* ֵ +* +*/ +void SetVirCILabourCancelLSXianSta(UINT8 VirCIid, UINT8 state); + +/* +* ȡָOC +* ˵ ocid ocID +* ֵ ID +* +*/ +UINT8 GetOCBelongVirCIid(const UINT8 ocid); +/* +* ָIDָʾ״̬ +* ˵ const UINT8 virCIid ID +* const UINT8 indicatorId, ָʾID +* const UINT8 indicatorState, ָʾ״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +void SetVirCIIndicatorState(const UINT8 virCIid, UINT8 indicatorId, const UINT8 indicatorState); +/* +* ȡָIDָʾ״̬ +* ˵ const UINT8 virCIid ID +* const UINT8 indicatorId, ָʾID +* ֵ 0 : IDָʾ״̬ +* 0 : ʧ +*/ +UINT8 GetVirCIIndicatorState(const UINT8 virCIid, UINT8 indicatorId); +/* +* ȡָָʾ +* ˵ +* const UINT8 virCIid ID +* +* ֵ ָָʾ +*/ +IndicatorConfigDataStruct* GetVirCIIndicatorConfigDataBuff(const UINT8 virCIid); +/* +* ָָʾ +* ˵ +* const UINT8 virCIid ID +* const UINT8 indicatorNum ָʾ +* ֵ void +*/ +void SetVirCIIndicatorConfigDataNum(const UINT8 virCIid, const UINT8 indicatorNum); +/* +* ȡָָʾ +* ˵ +* const UINT8 virCIid ID +* +* ֵ ָʾ +*/ +UINT8 GetVirCIIndicatorConfigDataNum(const UINT8 virCIid); +/* +* ȡָָʾü̵ +* ˵ +* const UINT8 virCIid ID +* +* ֵ ü̵ +*/ +UINT8 GetVirCIIndicConfDataRelaySum(const UINT8 virCIid, const UINT8 indicatorId); +/* +* ȡָָʾü̵ +* ˵ +* const UINT8 virCIid ID +* const UINT8 indicatorId ָʾID +* ֵ ü̵ +*/ +UINT16* GetVirCIIndicConfDataRelayBuf(const UINT8 virCIid, const UINT8 indicatorId); + +/* +* ȡָָʾÿ +* ˵ +* const UINT8 virCIid ID +* const UINT8 indicatorId ָʾID +* +* ֵ ָʾÿ״̬ +*/ +UINT8 GetVirCIIndicConfDataAvalFlag(const UINT8 virCIid, const UINT8 indicatorId); + +/* +* ȡָָʾIDӳ +* ˵ +* const UINT8 virCIid ID +* +* ֵ ָʾIDӳ +*/ +UINT8* GetVirCIlocalCiIndicatorIdBuf(const UINT8 virCIid); + +/* +* ָʾIDӳ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 InitVirCIlocalCiIndicatorIdBuf(void); + +/* +* ȡָָʾID +* ˵ +* const UINT8 virCIid ID +* UINT8 index +* +* ֵ ָʾID +*/ +UINT8 GetVirCIlocalCiIndicatorId(const UINT8 virCIid, UINT8 index); + +/* +* ȡָָʾ +* ˵ +* const UINT8 virCIid ID +* const UINT8 indicatorId ָʾID +* +* ֵ ü̵ +*/ +UINT8 GetVirCIIndicatorType(const UINT8 virCIid, const UINT8 indicatorId); + +/* +* ָģʽ +* ˵ +* const UINT8 virCIid ID +* UINT8 mode ģʽ +* +* ֵ void +*/ +void SetVirCImode(UINT8 virCIid, UINT8 mode); + +/* +* ȡָģʽ +* ˵ +* const UINT8 virCIid ID +* +* +* ֵ ģʽ +*/ +UINT8 GetVirCImode(UINT8 virCIid); + +/* +* ָԶ־ +* ˵ +* const UINT8 virCIid ID +* UINT8 setFlag Զ־ +* +* ֵ void +*/ +void SetVirCIautoTriggerFlag(UINT8 virCIid, UINT8 setFlag); +/* +* ȡָԶ־ +* ˵ +* const UINT8 virCIid ID +* +* +* ֵ Զ־ +*/ +UINT8 GetVirCIautoTriggerFlag(UINT8 virCIid); + +/* +* ָܸλ־ +* ˵ +* const UINT8 virCIid ID +* UINT8 setFlag ܸλ־ +* +* ֵ void +*/ +void SetVirCIZfwFlag(UINT8 virCIid, UINT8 setFlag); +/* +* ָܸλ־ +* ˵ +* const UINT8 virCIid ID +* +* +* ֵ ܸλ־ +*/ +UINT8 GetVirCIZfwFlag(UINT8 virCIid); + +/* +* ָܸλʼ +* ˵ +* const UINT8 virCIid ID +* UINT32 cyc +* +* ֵ void +*/ +void SetVirCIZfwStartCycNum(UINT8 virCIid, UINT32 cyc); + +/* +* ȡָܸλʼ +* ˵ +* const UINT8 virCIid ID +* +* +* ֵ ܸλʼ +*/ +UINT32 GetVirCIZfwStartCycNum(UINT8 virCIid); + +/* +* ָܸλ̵Ч +* ˵ +* const UINT8 virCIid ID +* UINT32 cyc +* +* ֵ void +*/ +void SetVirCIZfwValidCycNum(UINT8 virCIid, UINT32 cyc); + +/* +* ȡָܸλ̵Ч +* ˵ +* const UINT8 virCIid ID +* +* +* ֵ ܸλʼ +*/ +UINT32 GetVirCIZfwValidCycNum(UINT8 virCIid); + +/* +* üܸλ־ +* ˵ UINT8 setFlagñ־ +* ֵ void +*/ +void SetPhySecZfwManage(UINT8 virCIid, UINT8 setFlag); + +/* +* ȡָʾĿ +* ˵ UINT8 setFlagñ־ +* ֵ void +*/ +UINT16 GetLocalCIBaojingdengNum(void); + +/* +* ȡָʾID +* ˵ UINT16 index +* ֵ void +*/ +UINT16 GetLocalCIBaojingdengWId(UINT16 index); + +/* +* ȡָʾID +* ˵ UINT16 index +* ֵ ָʾID +*/ +UINT8 GetLocalCIIndicatorIDOrType(UINT16 index); + +/* +* ȡָʾ +* ˵ UINT16 index +* ֵ id +*/ +UINT16 GetLocalCIBaojingdengBelongVir(UINT16 index); +/* +* ָ۷״̬ +* ˵ UINT8 devId ָʾ豸IDUINT8 virCIid ID,UINT8 stateñ־ +* ֵ void +*/ +void SetVirCIautoRtnIndictFlashState(UINT8 devId, UINT8 virCIid, UINT8 state); +/* +* ȡָ۷״̬ +* ˵UINT8 devId ָʾ豸ID +* UINT8 virCIid ID +* ֵ ۷״̬ +*/ +UINT8 GetVirCIautoRtnIndictFlashState(UINT8 devId, UINT8 virCIid); +/* +* ָ۷ȵ״̬ +* ˵ UINT8 devId ָʾ豸IDUINT8 virCIid ID,UINT8 stateñ־ +* ֵ void +*/ +void SetVirCIautoRtnIndictSteadyState(UINT8 devId, UINT8 virCIid, UINT8 state); +/* +* ȡָ۷ȵ״̬ +* ˵ UINT8 devId ָʾ豸ID +* UINT8 virCIid ID +* ֵ ۷ȵ״̬ +*/ +UINT8 GetVirCIautoRtnIndictSteadyState(UINT8 devId, UINT8 virCIid); +/* +* ָ߱־ +* ˵UINT8 virCIid ID,UINT8 setFlag ñ־ +* ֵ void +*/ +void SetVirCIZfwHunxianFlag(UINT8 virCIid, UINT8 setFlag); +/* +* ȡָ߱־ +* ˵UINT8 virCIid ID +* ֵ ߱־ +*/ +UINT8 GetVirCIZfwHunxianFlag(UINT8 virCIid); +/* +* ȡָIDı豸ID +* ˵ const UINT8 virCIid ID +* const UINT8 indicatorId ID +* ֵ 0 : IDı豸ID +* 0 : ʧ +*/ +UINT8 GetVirCIIndicatorDevId(const UINT8 virCIid, UINT8 indicatorId); + +/* +* ȡָǷڱʵϽ +* ˵ const UINT8 chVirCiId ID +* ֵ CI_ERROR ڱʵϽ +* CI_SUCCESS ڱʵϽ +*cgh-20230529-޸YF0083-808 +*/ +UINT8 GetVirCIBelongLocalCI(const UINT8 chVirCiId); +/* +* ȡ۷ָʾ豸ID +* ˵ UINT8 virCIid ID +* UINT8 index +* ֵ >0 ָʾ豸ID +* 0 ֻһ۷ʱΪ1û۷ +*/ +UINT8 GetVirCiRtnIndictDeviceId(UINT8 virCIid, UINT8 index); +#ifdef __cplusplus +} +#endif +#endif + + diff --git a/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDefine.h b/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDefine.h new file mode 100644 index 0000000..6f51ca4 --- /dev/null +++ b/TSCP/src/APP/ciapp/VirtualDevice/VirtualDevDefine.h @@ -0,0 +1,27 @@ +/******************************************************** +* +* VirtualDevDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2016-12-13 +* ߣ +* 豸ݹ +* ޸ļ¼ +* +********************************************************/ +#ifndef __VIRTUALDEV_DEFINE_H_ +#define __VIRTUALDEV_DEFINE_H_ + +/*ϵͳͷļ*/ +#include "../System/SystemConfigDefine.h" + + +#define VIRTUAL_DEVICE_SUM_MAX ((UINT16)100) /*豸*/ + +#define VIRTUAL_ZDZFAJ_BUTTON_YES ((UINT8)0x55) /*Զ۷ť*/ +#define VIRTUAL_ZDZFAJ_BUTTON_NO ((UINT8)0xAA) /*Զ۷ťδ*/ + +#define VIRTUAL_CI_MAX ((UINT8)15) /*һ*/ +#define VIRTUAL_CI_INCLUDE_OC_MAX ((UINT8)20) /*һOC*/ +#define VIRTUAL_CI_INDICATOR_SUM_MAX ((UINT8)255) /*һָʾ */ +#define LOCAL_CI_INDICATOR_SUM_MAX ((UINT16)1000) /*һָʾ */ +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WLBrake/WLBrakeDataManage.c b/TSCP/src/APP/ciapp/WLBrake/WLBrakeDataManage.c new file mode 100644 index 0000000..fb1b656 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLBrake/WLBrakeDataManage.c @@ -0,0 +1,456 @@ +#include "WLBrakeDataManage.h" +#include "ParsePackGateWayData.h" + +static UINT8 g_WlbState = 0u; /* ȫгƶ״̬ */ + +/** +* @brief ȫгƶ״ +* @param +* @return +*/ +static void WlbAtsCmdFst(void); + +/** +* @brief ȫгƶ +* @param +* @return +*/ +static void WlbAtsCmdSnd(void); + +/** +* @brief ȫгƶ״̬ +* @param const UINT8 chState ȫгƶ״̬ +* @return +* @note Ϸʱȫгƶ +*/ +static void WlbSetState(const UINT8 chState); + +/** +* @brief ȫгƶʼ +* @param +* @return +*/ +void WlbInit(void) +{ + g_WlbState = WLB_UNSET; +} + +/** +* @brief ȡȫгƶ״̬ +* @param +* @return WLB_SET:ȫгƶWLB_UNSET:ȫгƶδ +*/ +UINT8 WlbGetState(void) +{ + return g_WlbState; +} + +/** +* @brief ȫгƶ״̬ +* @param const UINT8 chState ȫгƶ״̬ +* @return +* @note Ϸʱȫгƶ +*/ +static void WlbSetState(const UINT8 chState) +{ + if (WLB_UNSET == chState) + { + g_WlbState = chState; + } + else + { + g_WlbState = WLB_SET; + } +} + +/** +* @brief ȫгƶ +* @param +* @return +*/ +void WlbAtsCmdProc(void) +{ + AtsWlbMsgStru * strMsgFst = NULL; + AtsWlbMsgStru * strMsgSnd = NULL; + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsWlbMsgFst(); + strMsgSnd = GetAtsWlbMsgSnd(); + + if ((strMsgFst->chFlag != FLAG_SET) && (strMsgSnd->chFlag != FLAG_SET)) + { + ; /* ûϢʲôҲ */ + } + else if ((strMsgFst->chFlag == FLAG_SET) && (strMsgSnd->chFlag != FLAG_SET)) + {/* һϢ */ + WlbAtsCmdFst(); + } + else + {/* Ϣ */ + WlbAtsCmdSnd(); + } +} + +/** +* @brief ȫгƶ״ +* @param +* @return +*/ +static void WlbAtsCmdFst(void) +{ + AtsWlbMsgStru * strMsgFst = NULL; + AtsMsgCfmStru * strCfmFst = NULL; + UINT32 dwCycle = 0u; + UINT8 chLocalId = 0u; + UINT8 szCrcTmp[1024] = { 0u }; + UINT32 ii = 0u; + UINT8 chFunRtn = CI_TIME_OUT; + UINT8 chState = 0U; /*ȫ߽ƶ״̬*/ + UINT8 cAreaUrgentState = 0U; /*ƶ״̬*/ + + chLocalId = GetSystemParaLocalCiId(); + dwCycle = Get2oo2CurCycleNum(); + /*Ϣȡ᷵NULL*/ + strMsgFst = GetAtsWlbMsgFst(); + strCfmFst = GetAtsWlbCfmFst(); + + if (strMsgFst->dwCycle == dwCycle) + { + strCfmFst->chFlag = FLAG_SET; + strCfmFst->chTiocId = chLocalId; + strCfmFst->chStation = strMsgFst->chStation; + strCfmFst->chIndex = strMsgFst->chIndex; + strCfmFst->dwTime = dwCycle; + + switch (strMsgFst->chBrakeType) + { + case WLB_TYPE_RC: + /* ȡǰȫгƶ */ + chState = WlbGetState(); + + if (MSG_TYPE_WLB_CANCEL == strMsgFst->chType) + {/* ȡȫгƶ */ + if (WLB_UNSET == chState) + {/* ǰδ */ + strCfmFst->chOpStatus = CONFIRM_WLB_FST_UNSET; + } + else + { + strCfmFst->chOpStatus = CONFIRM_WLB_FST_SUCCESS; + } + } + else + {/* ȫгƶ */ + if (WLB_SET == chState) + {/* ǰãظ */ + strCfmFst->chOpStatus = CONFIRM_WLB_FST_REPEAT; + } + else + { + strCfmFst->chOpStatus = CONFIRM_WLB_FST_SUCCESS; + WlbSetState(WLB_SET); + } + } + break; + case WLB_TYPE_PHYSEC: + /* νȡǰƶ״̬ */ + cAreaUrgentState = GetPhySecAreaUrgentState(strMsgFst->wBrakeIndex); + + if (MSG_TYPE_WLB_CANCEL == strMsgFst->chType) + { + if (PHYSEC_AREA_URGENT_NO == cAreaUrgentState) + { + strCfmFst->chOpStatus = CONFIRM_WLB_FST_UNSET; /* ǰδظδ */ + } + else + { + strCfmFst->chOpStatus = CONFIRM_WLB_FST_SUCCESS; + } + } + else + { + if (PHYSEC_AREA_URGENT_YES == cAreaUrgentState) + { + strCfmFst->chOpStatus = CONFIRM_WLB_FST_REPEAT;/* ǰظظ */ + } + else + { + strCfmFst->chOpStatus = CONFIRM_WLB_FST_SUCCESS; + SetPhySecAreaUrgentState(strMsgFst->wBrakeIndex, PHYSEC_AREA_URGENT_YES); + } + } + break; + default: + strCfmFst->chOpStatus = CONFIRM_WLB_FST_UNKNOWN; /*ʹ󣬷δ֪*/ + break; + } + + szCrcTmp[ii] = strMsgFst->chAtsId; + ii++; + szCrcTmp[ii] = strMsgFst->chStation; + ii++; + szCrcTmp[ii] = strMsgFst->chIndex; + ii++; + szCrcTmp[ii] = strMsgFst->chBrakeType; + ii++; + szCrcTmp[ii] = strMsgFst->chBrakeCount; + ii++; + ShortToChar(strMsgFst->wBrakeIndex, &szCrcTmp[ii]); + ii += 2u; + LongToChar(strMsgFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii] = strMsgFst->chType; + ii++; + strCfmFst->dwCrc32 = Tioc_CommonCrc32(szCrcTmp, ii); /* ATSšվšվš·ʱ䡢ͼCRC */ + + if ((MSG_TYPE_WLB_SET == strMsgFst->chType) || (CONFIRM_WLB_FST_SUCCESS != strCfmFst->chOpStatus)) + { + ClearAtsWlbMsgFirst(); /* Ϊһɹһ */ + } + else + { + ; + } + } + else + {/* յATSȡɢһϢDZڣʱж */ + chFunRtn = SystemOverTimeCheck(strMsgFst->dwCycle, CONFIRM_TIMEOUT_CC); + if (CI_TIME_OUT == chFunRtn) + { + ClearAtsWlbMsgFirst(); + } + else + { + ; + } + } +} + +/** +* @brief ȫгƶ +* @param +* @return +*/ +static void WlbAtsCmdSnd(void) +{ + AtsWlbMsgStru * strMsgFst = NULL; + AtsWlbMsgStru * strMsgSnd = NULL; + AtsMsgCfmStru * strCfmFst = NULL; + AtsMsgCfmStru * strCfmSnd = NULL; + UINT32 dwCycle = 0u; + UINT8 chLocalId = 0u; + UINT8 chFlag = FLAG_UNSET; + UINT8 szCrcTmp[1024] = { 0u }; + UINT32 ii = 0u; + UINT32 dwCrc = 0u; + + chLocalId = GetSystemParaLocalCiId(); + dwCycle = Get2oo2CurCycleNum(); + strMsgFst = GetAtsWlbMsgFst(); + strMsgSnd = GetAtsWlbMsgSnd(); + strCfmFst = GetAtsWlbCfmFst(); + strCfmSnd = GetAtsWlbCfmSnd(); + + if ((NULL != strMsgFst) + && (NULL != strMsgSnd) + && (NULL != strCfmFst) + && (NULL != strCfmSnd)) + { + if (strMsgSnd->dwCycle == dwCycle) + { + strCfmSnd->chFlag = FLAG_SET; + strCfmSnd->chTiocId = chLocalId; + strCfmSnd->chStation = strMsgSnd->chStation; + strCfmSnd->chIndex = strMsgSnd->chIndex; + strCfmSnd->dwTime = dwCycle; + + if (FLAG_SET != strMsgFst->chFlag) + { + strCfmSnd->chOpStatus = CONFIRM_WLB_SND_FIRST; /* һδִУδִ״ȡ */ + chFlag = FLAG_SET; + } + else if ((strMsgSnd->chAtsId != strMsgFst->chAtsId) + || (strMsgSnd->chStation != strMsgFst->chStation) + || (strMsgSnd->chIndex != strMsgFst->chIndex) + || (strMsgSnd->chBrakeType != strMsgFst->chBrakeType) + || (strMsgSnd->wBrakeIndex != strMsgFst->wBrakeIndex)) + { + strCfmSnd->chOpStatus = CONFIRM_WLB_SND_UNKNOWN; /* ATSһ벻һ£δ֪ */ + chFlag = FLAG_SET; + } + else + { + /**/ + ; + } + + if (FLAG_UNSET == chFlag) + { + szCrcTmp[ii] = strMsgSnd->chTiocId; + ii++; + szCrcTmp[ii] = strMsgSnd->chBrakeType; + ii++; + szCrcTmp[ii] = strMsgSnd->chBrakeCount; + ii++; + ShortToChar(strMsgSnd->wBrakeIndex, &szCrcTmp[ii]); + ii += 2u; + LongToChar(strCfmFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii] = strMsgSnd->chType; + ii++; + dwCrc = Tioc_CommonCrc32(szCrcTmp, ii); + + if (dwCrc != strMsgSnd->dwCrc32) + { + strCfmSnd->chOpStatus = CONFIRM_WLB_SND_CRC; /* CRC32ATSϢCRC32һ */ + chFlag = FLAG_SET; + } + else + { + ; + } + } + else + { + ; + } + + ii = 0u; + szCrcTmp[ii++] = strMsgSnd->chAtsId; + szCrcTmp[ii++] = strMsgSnd->chStation; + szCrcTmp[ii++] = strMsgSnd->chIndex; + szCrcTmp[ii] = strMsgSnd->chBrakeType; + ii++; + szCrcTmp[ii] = strMsgSnd->chBrakeCount; + ii++; + ShortToChar(strMsgSnd->wBrakeIndex, &szCrcTmp[ii]); + ii += 2u; + LongToChar(strMsgFst->dwTime, &szCrcTmp[ii]); + ii += 4u; + LongToChar(strMsgSnd->dwTime, &szCrcTmp[ii]); + ii += 4u; + szCrcTmp[ii++] = strMsgSnd->chType; + strCfmSnd->dwCrc32 = Tioc_CommonCrc32(szCrcTmp, ii); + + if (FLAG_UNSET == chFlag) + { + switch (strMsgSnd->chBrakeType) + { + case WLB_TYPE_RC: + strCfmSnd->chOpStatus = CONFIRM_WLB_SND_SUCCESS; /* ͨȷϳɹ */ + WlbSetState(WLB_UNSET); /*ȫ߽ƶЧ*/ + break; + case WLB_TYPE_PHYSEC: + strCfmSnd->chOpStatus = CONFIRM_WLB_SND_SUCCESS; /* ͨȷϳɹ */ + SetPhySecAreaUrgentState(strMsgSnd->wBrakeIndex, PHYSEC_AREA_URGENT_NO); /*ƶЧ*/ + break; + default: + strCfmSnd->chOpStatus = CONFIRM_WLB_SND_UNKNOWN; /* Ͳȷδ֪ */ + break; + } + } + else + { + ; + } + } + else + { + ; /** DZϢ */ + } + ClearAtsWlbMsgFirst(); + ClearAtsWlbMsgSecond(); + } + else + { + ; /**ܷ֧ */ + } +} + +/** +* @brief ȡȫгƶ +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 WlbGetTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + + if (NULL != pDataBuff) + { + pDataBuff[curIndex] = g_WlbState; + ret++; + } + else + { + ; + } + + return ret; +} + +/** +* @brief ȫгƶ +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +UINT32 WlbSetTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex) +{ + UINT32 ret = curIndex; + + if (NULL != pDataBuff) + { + g_WlbState = pDataBuff[curIndex]; + ret++; + } + else + { + ; + } + + return ret; +} + +/** +* @brief ZCͽƶ +* @param UINT8 wlbValidFlag; ȫ߽Ч־ aaЧ +* @param UINT8 secEbSum; ƶ +* @param UINT16* ebPhySecId ƶ +* @return +*/ +void WlbZcCmdProc(UINT8 wlbValidFlag, UINT8 secEbSum, UINT16* ebPhySecId) +{ + UINT8 ii = 0U; + UINT8 cTiocId = 0u; + UINT16 wPhySecSum = 0u; /**/ + UINT8 belongCiId = 0U; + UINT16 wPhySecId = 0U; + if (NULL != ebPhySecId) + { + if ((WLB_UNSET == wlbValidFlag) || (WLB_SET == wlbValidFlag)) + { + WlbSetState(wlbValidFlag); /*ȫ߽ƶ״̬*/ + } + /*ͨЧ ƶ*/ + cTiocId = GetSystemParaLocalCiId(); + wPhySecSum = GetPhySecCurSum(); /*ȡ*/ + for (ii = 0u; ii < wPhySecSum; ii++) + { + wPhySecId = GetPhySecId(ii); + belongCiId = GetPhySecBelongCiId(wPhySecId); + if ((0u != wPhySecId) && (UINT16_MAX != wPhySecId) && (belongCiId == cTiocId)) + { + (void)SetPhySecAreaUrgentState(wPhySecId, PHYSEC_AREA_URGENT_NO); /*ƶЧ*/ + } + } + /*ZCƶϢ*/ + if ((0U < secEbSum) && (ZC_TO_CI_EB_MAX >=secEbSum)) + { + for (ii = 0U; ii < secEbSum; ii++) + { + SetPhySecAreaUrgentState(ebPhySecId[ii], PHYSEC_AREA_URGENT_YES); + } + } + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WLBrake/WLBrakeDataManage.h b/TSCP/src/APP/ciapp/WLBrake/WLBrakeDataManage.h new file mode 100644 index 0000000..c8645e8 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLBrake/WLBrakeDataManage.h @@ -0,0 +1,51 @@ +#ifndef _WLB_DATA_MANAGE_H_ +#define _WLB_DATA_MANAGE_H_ + +#include "WLBrakeDefine.h" +#include "../QueryFiles/dquCIInterFace.h" +/** +* @brief ȫгƶʼ +* @param +* @return +*/ +extern void WlbInit(void); + +/** +* @brief ȡȫгƶ״̬ +* @param +* @return WLB_SET:ȫгƶWLB_UNSET:ȫгƶδ +*/ +extern UINT8 WlbGetState(void); + +/** +* @brief ȫгƶ +* @param +* @return +*/ +extern void WlbAtsCmdProc(void); + +/** +* @brief ȡȫгƶ +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +extern UINT32 WlbGetTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex); + +/** +* @brief ȫгƶ +* @param UINT8 *pDataBuff ݴ洢 +* @param UINT32 curIndex ǰ +* @return +*/ +extern UINT32 WlbSetTransferData(OUT UINT8 *pDataBuff, IN UINT32 curIndex); + +/** +* @brief ZCͽƶ +* @param UINT8 wlbValidFlag; ȫ߽Ч־ aaЧ +* @param UINT8 secEbSum; ƶ +* @param UINT16* ebPhySecId ƶ +* @return +*/ +extern void WlbZcCmdProc(UINT8 wlbValidFlag, UINT8 secEbSum, UINT16* ebPhySecId); +#endif diff --git a/TSCP/src/APP/ciapp/WLBrake/WLBrakeDefine.h b/TSCP/src/APP/ciapp/WLBrake/WLBrakeDefine.h new file mode 100644 index 0000000..2ace44a --- /dev/null +++ b/TSCP/src/APP/ciapp/WLBrake/WLBrakeDefine.h @@ -0,0 +1,9 @@ +#ifndef _WLB_DEFINE_H_ +#define _WLB_DEFINE_H_ + +#include "commontypes.h" + +#define WLB_SET ((UINT8)0xaau) /* ȫгƶ */ +#define WLB_UNSET ((UINT8)0x55u) /* ȫгƶδ */ + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WLScreen/WLScreenDataManage.c b/TSCP/src/APP/ciapp/WLScreen/WLScreenDataManage.c new file mode 100644 index 0000000..07f5722 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WLScreenDataManage.c @@ -0,0 +1,634 @@ +/****************************************************************************** +** ļ: WLScreenDataManage.c +** : ȫɸܾݹ +*******************************************************************************/ + +#include "WLScreenDataManage.h" + + +/** 徲̬ȫֱ */ +static WLSreenInfoStruct g_WLScreenStatus = {0u}; /** ȫɸ̬Ϣ */ + + +/** + * @brief ÷ɸк + * @param[in] UINT32 seq ɸк + * @param[out] + * @return + * @note + */ +void wls_SetSendSeq(UINT32 seq) +{ + g_WLScreenStatus.sendSeq = seq; +} + +/** + * @brief ȡɸк + * @param[in] + * @param[out] + * @return UINT32 ɸк + * @note + */ +UINT32 wls_GetSendSeq(void) +{ + return g_WLScreenStatus.sendSeq; +} + +/** + * @brief ýɸк + * @param[in] UINT32 seq ɸк + * @param[out] + * @return + * @note + */ +void wls_SetRecvSeq(UINT32 seq) +{ + g_WLScreenStatus.recvSeq = seq; +} + +/** + * @brief ȡɸк + * @param[in] + * @param[out] + * @return UINT32 ɸк + * @note + */ +UINT32 wls_GetRecvSeq(void) +{ + return g_WLScreenStatus.recvSeq; +} + +/** + * @brief ȫɸִб־ + * @param[in] UINT8 ȫɸִб־ + * @param[out] + * @return + * @note + */ +void wls_SetWLScreenProcessFlag(UINT8 flag) +{ + if ((WHOLE_LINE_SCREEN_VAILD == flag) || (WHOLE_LINE_SCREEN_UNVAILD == flag)) + { + g_WLScreenStatus.WLScreenProcessFlag = flag; + } + else + { + g_WLScreenStatus.WLScreenProcessFlag = WHOLE_LINE_SCREEN_UNVAILD; + } +} + +/** + * @brief ȡȫɸִб־ + * @param[in] + * @param[out] + * @return UINT8 ȫɸִб־ + * @note + */ +UINT8 wls_GetWLScreenProcessFlag(void) +{ + return g_WLScreenStatus.WLScreenProcessFlag; +} + + +/** + * @brief TMCȫɸ־ + * @param[in] UINT8 TMCȫɸ־ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetWLScreenVaildFlag(UINT8 flag) +{ + UINT8 ret = CI_ERROR; + if ((TMC_WLS_VALID == flag) || (TMC_WLS_UNVALID == flag)) + { + g_WLScreenStatus.WLScreenVaildFlag = flag; + ret = CI_SUCCESS; + } + else + { + g_WLScreenStatus.WLScreenVaildFlag = TMC_WLS_UNVALID; + } + return ret; +} + +/** + * @brief ȡTMCȫɸ־ + * @param[in] + * @param[out] + * @return UINT8 TMCȫɸ־ + * @note + */ +UINT8 wls_GetWLScreenVaildFlag(void) +{ + return g_WLScreenStatus.WLScreenVaildFlag; +} + +/** + * @brief Ƿس־ + * @param[in] UINT8 Ƿس־ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetUTFlag(UINT8 flag) +{ + UINT8 ret = CI_ERROR; + if ((UNKNOWN_TRAIN_UNEXIST == flag) || (UNKNOWN_TRAIN_EXIST == flag)) + { + g_WLScreenStatus.UTFlag = flag; + ret = CI_SUCCESS; + } + else + { + g_WLScreenStatus.UTFlag = UNKNOWN_TRAIN_EXIST; + } + return ret; +} + +/** + * @brief ȡǷس־ + * @param[in] + * @param[out] + * @return UINT8 Ƿس־ + * @note + */ +UINT8 wls_GetUTFlag(void) +{ + return g_WLScreenStatus.UTFlag; +} + +/** + * @brief ڼ־ + * @param[in] UINT8 ڼ־ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetEnterCheckFlag(UINT8 flag) +{ + UINT8 ret = CI_ERROR; + if ((ENTER_OK_FLAG == flag) || (ENTER_ERROR_FLAG == flag)) + { + g_WLScreenStatus.enterCheckFlag = flag; + ret = CI_SUCCESS; + } + else + { + g_WLScreenStatus.enterCheckFlag = ENTER_ERROR_FLAG; + } + return ret; +} + +/** + * @brief ȡڼ־ + * @param[in] + * @param[out] + * @return UINT8 ڼ־ + * @note + */ +UINT8 wls_GetEnterCheckFlag(void) +{ + return g_WLScreenStatus.enterCheckFlag; +} + +/** +* @brief UTϢͬ +* @param[in] UINT32 dwRedunTime ʱ, UINT8 chUTACCnt UTĿ, const UINT16 *arrayUTACId Id +* @param[out] +* @return CI_SUCCESS ɹCI_ERROR ʧ +* @note; +*/ +UINT8 wls_SetUTACInfo(UINT32 dwRedunTime, UINT8 chUTACCnt, const UINT16 *arrayUTACId) +{ + UINT8 ret = CI_ERROR; + UINT8 i = 0U; + if( (MAX_UT_AC_CNT > chUTACCnt)&&(NULL != arrayUTACId)) + { + g_WLScreenStatus.redunTime = dwRedunTime; + g_WLScreenStatus.UTACCnt = chUTACCnt; + (void)CommonMemSet(&g_WLScreenStatus.UTACId[0], (UINT32)sizeof(UINT16)*MAX_UT_AC_CNT, 0U, (UINT32)sizeof(UINT16)*MAX_UT_AC_CNT); + for (i = 0U; i < MAX_UT_AC_CNT; i++) + { + g_WLScreenStatus.UTACId[i] = arrayUTACId[i]; + } + ret = CI_SUCCESS; + } + else + { + g_WLScreenStatus.redunTime = 0U; + g_WLScreenStatus.UTACCnt = 0U; + (void)CommonMemSet(&g_WLScreenStatus.UTACId[0], (UINT32)sizeof(UINT16)*MAX_UT_AC_CNT, 0U, (UINT32)sizeof(UINT16)*MAX_UT_AC_CNT); + } + return ret; +} + +/** + * @brief г״̬Ϣ + * @param[in] const WLTrainStatusInfoStruct *pInfo г״̬Ϣ + * @param[out] WLTrainStatusInfoStruct *pOutInfo г״̬ + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +static UINT8 wls_SetTrainStatusInfo(const WLTrainStatusInfoStruct *pInfo,OUT WLTrainStatusInfoStruct *pOutInfo) +{ + UINT8 ret = CI_ERROR; + if ((NULL == pInfo) || (NULL == pOutInfo)) + { + /** ڲУʧ */ + } + else + { + ret = CI_SUCCESS; + if ((OUT_CONTROL_STATUS == pInfo->controlStatus) || (IN_CONTROL_STATUS == pInfo->controlStatus) || (OFFLINE_CONFIRM_STATUS == pInfo->controlStatus)) + { + ; /* ɹ */ + } + else + { + /** £ʧ */ + ret = CI_ERROR; + } + + if ((CI_SUCCESS == ret) && ((UNNEED_SCREEN == pInfo->headNeedScreen) || (NEED_SCREEN == pInfo->headNeedScreen))) + { + ; /* ɹ */ + } + else + { + /** */ + ret = CI_ERROR; + } + + if ((CI_SUCCESS == ret) && ((UNNEED_SCREEN == pInfo->tailNeedScreen) || (NEED_SCREEN == pInfo->tailNeedScreen))) + { + ; /* ɹ */ + } + else + { + /** */ + ret = CI_ERROR; + } + + if (CI_SUCCESS == ret) + { + pOutInfo->controlStatus = pInfo->controlStatus; + pOutInfo->headNeedScreen = pInfo->headNeedScreen; + pOutInfo->tailNeedScreen = pInfo->tailNeedScreen; + } + } + return ret; +} + + +/** + * @brief г״̬Ϣ + * @param[in] UINT16 trainID гID + * @param[in] const WLTrainStatusInfoStruct *pInfo г״̬Ϣ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetLastTrainStatusInfo(UINT16 trainID, const WLTrainStatusInfoStruct *pInfo) +{ + UINT8 ret = CI_ERROR; + if ((0u == trainID) || (LINE_MAX_TRAIN == trainID)) + { + /** ڲУʧ */ + } + else + { + ret = wls_SetTrainStatusInfo(pInfo,&g_WLScreenStatus.lastTrainStatusInfo[trainID]); + } + return ret; +} + +/** + * @brief ȡг״̬Ϣ + * @param[in] UINT16 trainID гID + * @param[out] + * @return const WLTrainStatusInfoStruct* г״̬Ϣָ + * @note + */ +const WLTrainStatusInfoStruct* wls_GetLastTrainStatusInfo(UINT16 trainID) +{ + const WLTrainStatusInfoStruct* ret = NULL; + if ((0u == trainID) || (LINE_MAX_TRAIN == trainID)) + { + /** ڲУʧ */ + } + else + { + ret = &g_WLScreenStatus.lastTrainStatusInfo[trainID]; + } + return ret; +} + + +/** + * @brief õǰг״̬Ϣ + * @param[in] UINT16 trainID гID + * @param[in] const WLTrainStatusInfoStruct *pInfo г״̬Ϣ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetCurTrainStatusInfo(UINT16 trainID, const WLTrainStatusInfoStruct *pInfo) +{ + UINT8 ret = CI_ERROR; + if ((0u == trainID) || (LINE_MAX_TRAIN == trainID)) + { + /** ڲУʧ */ + } + else + { + ret = wls_SetTrainStatusInfo(pInfo,&g_WLScreenStatus.curTrainStatusInfo[trainID]); + } + return ret; +} + + + +/** + * @brief ȡǰг״̬Ϣ + * @param[in] UINT16 trainID гID + * @param[out] + * @return const WLTrainStatusInfoStruct* г״̬Ϣָ + * @note + */ +const WLTrainStatusInfoStruct* wls_GetCurTrainStatusInfo(UINT16 trainID) +{ + const WLTrainStatusInfoStruct* ret = NULL; + if ((0u == trainID) || (LINE_MAX_TRAIN == trainID)) + { + /** ڲУʧ */ + } + else + { + ret = &g_WLScreenStatus.curTrainStatusInfo[trainID]; + } + return ret; +} + + + +/** + * @brief ȫɸϢ + * @param[in] const WLSreenInfoStruct* pInfo ȫɸϢ + * @param[out] + * @return CI_SUCCESS óɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetWholeLineScreeInfo(IN const WLSreenInfoStruct* pInfo) +{ + UINT8 ret = CI_ERROR; + UINT8 processValid = CI_ERROR; + UINT8 funRtn = CI_ERROR; + UINT16 cycle = 0u; + + if (NULL == pInfo) + { + /** ڲ */ + } + else + { + processValid = CI_SUCCESS; + + /** ÷͸TMCɸк */ + wls_SetSendSeq(pInfo->sendSeq); + + /** ýTMCɸк */ + wls_SetRecvSeq(pInfo->recvSeq); + + /** ȫɸ־ */ + funRtn = wls_SetWLScreenVaildFlag(pInfo->WLScreenVaildFlag); + if (CI_ERROR == funRtn) + { + processValid = CI_ERROR; + } + else + { + /** */ + } + + /** Ƿس־ */ + if (CI_SUCCESS == processValid) + { + funRtn = wls_SetUTFlag(pInfo->UTFlag); + if (CI_ERROR == funRtn) + { + processValid = CI_ERROR; + } + else + { + /** */ + } + } + else + { + /** */ + } + + /** ڼ־ */ + if (CI_SUCCESS == processValid) + { + funRtn = wls_SetEnterCheckFlag(pInfo->enterCheckFlag); + if (CI_ERROR == funRtn) + { + processValid = CI_ERROR; + } + else + { + /** */ + } + } + else + { + /** */ + } + + /** UTϢ */ + if (CI_SUCCESS == processValid) + { + processValid = wls_SetUTACInfo(pInfo->redunTime, pInfo->UTACCnt, &pInfo->UTACId); + } + + /** г״̬Ϣ */ + if (CI_SUCCESS == processValid) + { + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + funRtn = wls_SetCurTrainStatusInfo(cycle,&pInfo->curTrainStatusInfo[cycle]); + if (CI_ERROR == funRtn) + { + processValid = CI_ERROR; + } + else + { + /** */ + } + + funRtn = wls_SetLastTrainStatusInfo(cycle,&pInfo->lastTrainStatusInfo[cycle]); + if (CI_ERROR == funRtn) + { + processValid = CI_ERROR; + } + else + { + /** */ + } + } + } + else + { + /** */ + } + } + + if (CI_SUCCESS == processValid) + { + ret = CI_SUCCESS; + } + else + { + /** ʧ */ + } + + return ret; +} + +/** + * @brief ȡȫɸϢ + * @param[in] + * @param[out] + * @return ȫɸ̬Ϣṹָ + * @note + */ +const WLSreenInfoStruct* wls_GetWholeLineScreeInfo(void) +{ + return &g_WLScreenStatus; +} + + + +/** + * @brief UT + * @param[in] UINT8 cnt UT + * @param[out] + * @return CI_SUCCESS óɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetUTACCnt(UINT8 cnt) +{ + UINT8 ret = CI_ERROR; + if (cnt < MAX_UT_AC_CNT) + { + g_WLScreenStatus.UTACCnt = cnt; + ret = CI_SUCCESS; + } + else + { + /** */ + } + return ret; +} + + +/** + * @brief ȡUT + * @param[in] + * @param[out] + * @return 0~MAX_UT_AC_CNT-1 ϷֵMAX_UT_AC_CNT Ƿֵ + * @note + */ +UINT8 wls_GetUTACCnt(void) +{ + UINT8 ret = MAX_UT_AC_CNT; + ASSERT_SETRET(g_WLScreenStatus.UTACCnt < MAX_UT_AC_CNT,ret,g_WLScreenStatus.UTACCnt,MAX_UT_AC_CNT); + return ret; +} + + +/** + * @brief UTID洢 + * @param[in] UINT8 index ± + * @param[in] UINT16 acID ID + * @param[out] + * @return CI_SUCCESS óɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetUTACId(UINT8 index,UINT16 acID) +{ + UINT8 ret = CI_ERROR; + if (index < MAX_UT_AC_CNT) + { + g_WLScreenStatus.UTACId[index] = acID; + ret = CI_SUCCESS; + } + else + { + /** ʧ*/ + } + return ret; +} + + +/** + * @brief ȡ±ӦUT + * @param[in] UINT8 index ± + * @param[out] + * @return ID + * @note + */ +UINT16 wls_GetUTACId(UINT8 index) +{ + UINT16 ret = 0u; + if (index < MAX_UT_AC_CNT) + { + ret = g_WLScreenStatus.UTACId[index]; + } + else + { + /** ʧ*/ + } + return ret; +} + +/** + * @brief ۼʱ + * @param[in] UINT32 maxValue ʱֵ + * @param[out] + * @return + * @note + */ +void wls_AddRedunTime(UINT32 maxValue) +{ + if (g_WLScreenStatus.redunTime < maxValue) + { + g_WLScreenStatus.redunTime++; + } + else + { + /** 账 */ + } +} + +/** + * @brief ʱ + * @param[in] UINT32 mValue ʱֵ + * @param[in] UINT32 maxValue ʱֵ + * @param[out] + * @return + * @note + */ +void wls_SetRedunTime(UINT32 mValue,UINT32 maxValue) +{ + if (mValue < maxValue) + { + g_WLScreenStatus.redunTime = mValue; + } + else + { + /** 账 */ + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WLScreen/WLScreenDataManage.h b/TSCP/src/APP/ciapp/WLScreen/WLScreenDataManage.h new file mode 100644 index 0000000..de4a692 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WLScreenDataManage.h @@ -0,0 +1,257 @@ +/****************************************************************************** +** ļ: WLScreen\WLScreenDataManage.h +** : ȫɸܾݹ +*******************************************************************************/ +#ifndef WLS_SCREEN_DATA_MANAGE_H_ +#define WLS_SCREEN_DATA_MANAGE_H_ + +#include "WholeLineScreenDefine.h" + +/** + * @brief ÷ɸк + * @param[in] UINT32 seq ɸк + * @param[out] + * @return + * @note + */ +void wls_SetSendSeq(UINT32 seq); + +/** + * @brief ȡɸк + * @param[in] + * @param[out] + * @return UINT32 ɸк + * @note + */ +UINT32 wls_GetSendSeq(void); + +/** + * @brief ýɸк + * @param[in] UINT32 seq ɸк + * @param[out] + * @return + * @note + */ +void wls_SetRecvSeq(UINT32 seq); + +/** + * @brief ȡɸк + * @param[in] + * @param[out] + * @return UINT32 ɸк + * @note + */ +UINT32 wls_GetRecvSeq(void); + +/** + * @brief ȫɸִб־ + * @param[in] UINT8 ȫɸִб־ + * @param[out] + * @return + * @note + */ +void wls_SetWLScreenProcessFlag(UINT8 flag); + +/** + * @brief ȡȫɸִб־ + * @param[in] + * @param[out] + * @return UINT8 ȫɸִб־ + * @note + */ +UINT8 wls_GetWLScreenProcessFlag(void); + + +/** + * @brief TMCȫɸ־ + * @param[in] UINT8 TMCȫɸ־ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetWLScreenVaildFlag(UINT8 flag); + +/** + * @brief ȡTMCȫɸ־ + * @param[in] + * @param[out] + * @return UINT8 TMCȫɸ־ + * @note + */ +UINT8 wls_GetWLScreenVaildFlag(void); + +/** + * @brief Ƿس־ + * @param[in] UINT8 Ƿس־ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetUTFlag(UINT8 flag); + +/** + * @brief ȡǷس־ + * @param[in] + * @param[out] + * @return UINT8 Ƿس־ + * @note + */ +UINT8 wls_GetUTFlag(void); + +/** + * @brief ڼ־ + * @param[in] UINT8 ڼ־ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetEnterCheckFlag(UINT8 flag); + +/** + * @brief ȡڼ־ + * @param[in] + * @param[out] + * @return UINT8 ڼ־ + * @note + */ +UINT8 wls_GetEnterCheckFlag(void); + +/** +* @brief UTϢͬ +* @param[in] UINT32 dwRedunTime ʱ, UINT8 chUTACCnt UTĿ, const UINT16 *arrayUTACId Id +* @param[out] +* @return CI_SUCCESS ɹCI_ERROR ʧ +* @note; +*/ +UINT8 wls_SetUTACInfo(UINT32 dwRedunTime, UINT8 chUTACCnt, const UINT16 *arrayUTACId); +/** + * @brief г״̬Ϣ + * @param[in] UINT16 trainID гID + * @param[in] const WLTrainStatusInfoStruct *pInfo г״̬Ϣ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetLastTrainStatusInfo(UINT16 trainID, const WLTrainStatusInfoStruct *pInfo); + +/** + * @brief ȡг״̬Ϣ + * @param[in] UINT16 trainID гID + * @param[out] + * @return const WLTrainStatusInfoStruct* г״̬Ϣָ + * @note + */ +const WLTrainStatusInfoStruct* wls_GetLastTrainStatusInfo(UINT16 trainID); + +/** + * @brief õǰг״̬Ϣ + * @param[in] UINT16 trainID гID + * @param[in] const WLTrainStatusInfoStruct *pInfo г״̬Ϣ + * @param[out] + * @return CI_SUCCESS ɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetCurTrainStatusInfo(UINT16 trainID, const WLTrainStatusInfoStruct *pInfo); + +/** + * @brief ȡǰг״̬Ϣ + * @param[in] UINT16 trainID гID + * @param[out] + * @return const WLTrainStatusInfoStruct* г״̬Ϣָ + * @note + */ +const WLTrainStatusInfoStruct* wls_GetCurTrainStatusInfo(UINT16 trainID); + + +/** + * @brief ȫɸϢ + * @param[in] const WLSreenInfoStruct* pInfo ȫɸϢ + * @param[out] + * @return CI_SUCCESS óɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetWholeLineScreeInfo(IN const WLSreenInfoStruct* pInfo); + + +/** + * @brief ȡȫɸϢ + * @param[in] + * @param[out] + * @return ȫɸ̬Ϣṹָ + * @note + */ +const WLSreenInfoStruct* wls_GetWholeLineScreeInfo(void); + + +/** + * @brief UT + * @param[in] UINT8 cnt UT + * @param[out] + * @return CI_SUCCESS óɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetUTACCnt(UINT8 cnt); + + +/** + * @brief ȡUT + * @param[in] + * @param[out] + * @return 0~MAX_UT_AC_CNT-1 ϷֵMAX_UT_AC_CNT Ƿֵ + * @note + */ +UINT8 wls_GetUTACCnt(void); + + +/** + * @brief UTID洢 + * @param[in] UINT8 index ± + * @param[in] UINT16 acID ID + * @param[out] + * @return CI_SUCCESS óɹCI_ERROR ʧ + * @note + */ +UINT8 wls_SetUTACId(UINT8 index,UINT16 acID); + + +/** + * @brief ȡ±ӦUT + * @param[in] UINT8 index ± + * @param[out] + * @return ID + * @note + */ +UINT16 wls_GetUTACId(UINT8 index); + +/** + * @brief ۼʱ + * @param[in] UINT32 maxValue ʱֵ + * @param[out] + * @return + * @note + */ +void wls_AddRedunTime(UINT32 maxValue); + +/** + * @brief ʱ + * @param[in] UINT32 mValue ʱֵ + * @param[in] UINT32 maxValue ʱֵ + * @param[out] + * @return + * @note + */ +void wls_SetRedunTime(UINT32 mValue,UINT32 maxValue); + +#endif + + + + + + + + + + + + diff --git a/TSCP/src/APP/ciapp/WLScreen/WLScreenDataPrepare.c b/TSCP/src/APP/ciapp/WLScreen/WLScreenDataPrepare.c new file mode 100644 index 0000000..74561ff --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WLScreenDataPrepare.c @@ -0,0 +1,595 @@ +#include "WLScreenDataPrepare.h" +#include +#include "2oo2InterfaceDataManage.h" +#include "SystemParameterManage.h" +#include "DeviceDataManage.h" +#include "../Transmit/TransmitStateDataManage.h" +#include "EnvelopeManageAPI.h" +#include "AxisAssertManageAPI.h" +#include "ELMDataPrepare.h" +#include "AxisSectionConfigDataManage.h" + + +/* ================================̬=================================== */ +static UINT8 wls_JudgeAChasUT(UINT16 acid); /** жϼǷس */ + + +/** + * @brief ̬жϼǷس + * @param[in] UINT16 acid ID + * @param[out] + * @return CI_ERROR:س CI_SUCCESS:س + * @note + */ +static UINT8 wls_JudgeAChasUT(UINT16 acid) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 cycleELM = 0u; + UINT8 acRedunStatus = AAM_API_AC_UT; + const EnvelopeStruct* pELMInfo = NULL; + UINT8 envelopeCnt = CI_ERROR; + UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + + /** ȡİϢ */ + envelopeCnt = elm_GetEnvelopeIDsInAC(acid,envelopeIDs); + ASSER_ERROR(SECTION_REL_ENVELOPE_SUM_MAX <= envelopeCnt,errorCode,0x80000000u); + + /** ȡ״̬ */ + acRedunStatus = aam_GetACAssertStatus(acid); + + if ((0u == envelopeCnt) && ((AAM_API_AC_ARB == acRedunStatus) || (AAM_API_AC_REDUNARB == acRedunStatus))) + { + /** ް磬账 */ + } + else if (0u == envelopeCnt) + { + /** ΪARBARBռãȫ */ + errorCode += 0x40000000u; + } + else + { + for (cycleELM = 0u; cycleELM < envelopeCnt;cycleELM++) + { + pELMInfo = elm_GetEnvelopeInfoByID(envelopeIDs[cycleELM]); + + if ((NULL != pELMInfo) && + (TYPE_CT_ENVELOPE == pELMInfo->envelopeType) && + (0u == pELMInfo->headTrainID) && (0u == pELMInfo->tailTrainID)) + { + /** δس */ + } + else + { + break; + } + } + + /** ΪARBARBռãȫ */ + ASSER_ERROR(envelopeCnt != cycleELM,errorCode,0x10000000u); + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode,ret,CI_SUCCESS,CI_ERROR); + return ret; +} + +/** + * @brief ӡDebugϢ + * @param[in] UINT8 level ־ + * @param[in] const char *fmt ӡϢ + * @return + * @note ͨⲿӿڣʵֱģĴӡ + */ +void wls_PrintDebugInfo(UINT8 level,const char *fmt, ...) +{ + va_list para; + CHAR tmpPrintBuf[WLS_PRINT_LEN] = {'\0'}; + + if (WLS_LOG_LEVEL >= level) + { + va_start(para,fmt); + (void)vsnprintf(tmpPrintBuf,WLS_PRINT_LEN,fmt,para); + va_end(para); + + debug_infor_printf((const)"%s",tmpPrintBuf); + } + else + { + /** ־𲻹*/ + } +} + + +/** + * @brief ȡȫɸܿ + * @param[in] + * @param[out] + * @return CI_SUCCESS ܴ򿪣CI_ERROR ܹر + * @note + */ +UINT8 wls_PrepareWLSFunSwitch(void) +{ + UINT8 ret = CI_ERROR; + UINT8 funRtn = GetWLSFunSwitch(); + + if (0xaaU == funRtn) + { + ret = CI_SUCCESS; + } + else + { + /** ɸܹر */ + } + + return ret; +} + + +/** + * @brief жϱOCǷΪɸԵTIOC + * @param[in] + * @param[out] + * @return CI_SUCCESS ɸԣCI_ERROR ɸ + * @note + */ +UINT8 wls_PrepareisWLSTioc(void) +{ + /** ȡOCid */ + UINT8 localOCid = GetSystemParaLocalCiId(); + UINT8 flag = GetWLScreenTypeById(localOCid); + + return (TIOC_WLSCTEEN_VALID == flag) ? CI_SUCCESS : CI_ERROR; +} + +/** + * @brief ȡOCǷϵ + * @param[in] + * @param[out] + * @return CI_SUCCESS ϵCI_ERROR δϵ + * @note + */ +UINT8 wls_PrepareTIOCWorkStatus(void) +{ + UINT8 ret = CI_ERROR; + UINT8 flockFlag = CI_START_FLOCK_NO; + UINT8 lockFlag = CI_START_LOCK_NO; + + flockFlag = GetStartFLockFlag(); + lockFlag = GetStartLockFlag(); + + if ((CI_START_FLOCK_NO == flockFlag) && (CI_START_LOCK_NO == lockFlag)) + { + ret = CI_SUCCESS; + } + else + { + /** */ + } + + return ret; +} + + +/** + * @brief ȡڼ״̬ + * @param[in] + * @param[out] + * @return CI_SUCCESS ڼCI_ERROR ڼ쳣 + * @note + */ +UINT8 wls_PrepareEnterACStatus(void) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 isHaveUT = CI_ERROR; + UINT16* pACIdBuff = NULL; + UINT16 tempACCnt = 0u; + UINT16 cycle = 0u; + UINT8 localOCid = 0u; + UINT8 acBelongOcid = 0u; + UINT8 enterACFlag = 0u; + UINT8 acOCCStatus = ELM_AC_OCC; + + /** ȡ */ + tempACCnt = GetLocalCiAxisSectionIdBuf(&pACIdBuff); + + if ((0u == tempACCnt) || (AXIS_SECTION_SUM_MAX <= tempACCnt)) + { + /** ѯ */ + } + else + { + for (cycle = 0u; cycle < tempACCnt;cycle++) + { + /** ȡOCid */ + localOCid = GetSystemParaLocalCiId(); + + /** ȡOC id 255*/ + acBelongOcid = (UINT8)GetAxisBelongTioc(pACIdBuff[cycle]); + ASSERT_BREAK((0u == localOCid) || (0u == acBelongOcid),errorCode,0x80000000u); + + acOCCStatus = elm_PrepareACStatus(pACIdBuff[cycle]); + + /** ȡڼ*/ + enterACFlag = GetAxisSecEntranceFlag(pACIdBuff[cycle]); + + if ((localOCid == acBelongOcid) && (AXIS_SEC_ENTRANCE_YES == enterACFlag) && (ELM_AC_OCC == acOCCStatus)) + { + isHaveUT = wls_JudgeAChasUT(pACIdBuff[cycle]); + ASSERT_BREAK(CI_ERROR == isHaveUT,errorCode,0x40000000u); + } + else + { + /** 账 */ + } + } + + /** úֵ */ + ASSERT_SETRET(cycle == tempACCnt,ret,CI_SUCCESS,CI_ERROR); + } + + return ret; +} + +/** + * @brief ȡǰ + * @param[in] + * @param[out] + * @return ǰ + * @note + */ +UINT32 wls_PrePareCurCycle(void) +{ + return Get2oo2CurCycleNum(); +} + + +/** + * @brief ȡTMCͨ״̬ + * @param[in] + * @param[out] + * @return CI_SUCCESS ͨCI_ERROR ͨ쳣 + * @note + */ +UINT8 wls_PrepareCommStatusWithTMC(void) +{ + UINT8 ret = CI_ERROR; + UINT8 comstatus = TRANSMIT_STATE_BAD; + UINT8 deviceSum = 0u; + UINT8* deviceIdBuf = NULL; + + deviceSum = GetCiTransmitSpecifySysDevSum(CI_SYSTEM_TYPE_TMC); /*ȡͨTMC豸*/ + deviceIdBuf = GetCiTransmitSpecifySysDevBuf(CI_SYSTEM_TYPE_TMC); /*ȡͨTMC豸ID*/ + + if (1u == deviceSum) + { + comstatus = GetCiTransmitState(CI_SYSTEM_TYPE_TMC,deviceIdBuf[0u]); + + if (TRANSMIT_STATE_GOOD == comstatus) + { + ret = CI_SUCCESS; + } + else + { + /** ͨ쳣 */ + } + } + else + { + /** ֧TIOCӦTMC */ + } + + return ret; +} + +/** +* @brief ȡOCڵUTUT +* @param[in] +* @param[out] UINT16 acID[MAX_UT_AC_CNT] UTID +* @return 0~MAX_UT_AC_CNT-1 ϷֵMAX_UT_AC_CNT Ƿֵ +* @note +*/ +UINT8 wls_PrepareUTACInOCArea(UINT16 acID[MAX_UT_AC_CNT]) +{ + /*- ֲ */ + UINT8 ret = MAX_UT_AC_CNT; + UINT32 errorCode = 0u; /**/ + UINT8 UTACCnt = 0u; + UINT8 isHaveUT = CI_ERROR; + UINT16 cycle = 0u; + UINT16 acCnt = 0u; /*OCΧеļ*/ + UINT8 acStatus = ELM_AC_OCC; + const UINT16 *pACIdbuff = NULL; /** IDֵ */ + UINT8 localOCid = 0u; + UINT8 acBelongOcid = 0u; + UINT8 cycleELM = 0u; + UINT8 acRedunStatus = AAM_API_AC_UT; + const EnvelopeStruct* pELMInfo = NULL; + UINT8 envelopeCnt = CI_ERROR; + UINT8 AxisLinXian = 0U; + UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX] = {0u}; + UINT8 cStorageLineProperty = AXIS_SEC_STORAGE_LINE_NO; /*泵ԣʼΪǴ泵*/ + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == acID,ret,0x80000000u); + + /** ȡOCΧеļ */ + acCnt = elm_PrepareACBuffIndexs(&pACIdbuff); + + /** жǷѯɹ */ + if ((0u == acCnt) || (acCnt >= AXIS_SECTION_SUM_MAX) || (NULL == pACIdbuff)) + { + /** ѯ */ + } + else + { + + /** ȡOCid */ + localOCid = GetSystemParaLocalCiId(); + + /** OCеļ*/ + for (cycle = 0u; cycle < acCnt; cycle++) + { + /** жǷΪUTUTᣬTIOCжǷϴUKTߴδɸѡİ*/ + acStatus = elm_PrepareACStatus(pACIdbuff[cycle]); + AxisLinXian = GetAxisSecLinXianFlag(pACIdbuff[cycle]); /*Ƿ(DZ·)*/ + cStorageLineProperty = GetAxisSecStorageLineProperty(pACIdbuff[cycle]); /*Ƿд泵*/ + if ((ELM_AC_OCC == acStatus) && (AXIS_SEC_LINXIAN_NO == AxisLinXian) && (AXIS_SEC_STORAGE_LINE_YES != cStorageLineProperty)) /*·ռѹҪ*/ + { + /** ȡOC id 255*/ + acBelongOcid = (UINT8)GetAxisBelongTioc(pACIdbuff[cycle]); + ASSERT_BREAK((0u == localOCid) || (0u == acBelongOcid), errorCode, 0x80000000u); + + /** ȡİϢ */ + envelopeCnt = elm_GetEnvelopeIDsInAC(pACIdbuff[cycle], envelopeIDs); + ASSERT_BREAK(SECTION_REL_ENVELOPE_SUM_MAX <= envelopeCnt, errorCode, 0x40000000u); + + /** ȡ״̬ */ + acRedunStatus = aam_GetACAssertStatus(pACIdbuff[cycle]); + + if (localOCid == acBelongOcid) + { + if ((0u == envelopeCnt) && ((AAM_API_AC_ARB == acRedunStatus) || (AAM_API_AC_REDUNARB == acRedunStatus))) + { + /** ް磬账 */ + } + else if (0u == envelopeCnt) + { + /** ΪARBARBռãȫ */ + if (UTACCnt < (MAX_UT_AC_CNT - 1u)) + { + acID[UTACCnt++] = pACIdbuff[cycle]; + } + else + { + UTACCnt = MAX_UT_AC_CNT; + } + } + else + { + for (cycleELM = 0u; cycleELM < envelopeCnt; cycleELM++) + { + pELMInfo = elm_GetEnvelopeInfoByID(envelopeIDs[cycleELM]); + + if ((NULL != pELMInfo) && + (TYPE_UKT_ENVELOPE == pELMInfo->envelopeType)) + { + break; + } + else + { + /** 账 */ + } + } + + /** ڴUT */ + if (cycleELM != envelopeCnt) + { + /** ΪARBARBռãȫ */ + if (UTACCnt < (MAX_UT_AC_CNT - 1u)) + { + acID[UTACCnt++] = pACIdbuff[cycle]; + } + else + { + UTACCnt = MAX_UT_AC_CNT; + } + } + else + { + /** UTҪ */ + } + } + } + else + { + for (cycleELM = 0u; cycleELM < envelopeCnt; cycleELM++) + { + pELMInfo = elm_GetEnvelopeInfoByID(envelopeIDs[cycleELM]); + + if ((NULL != pELMInfo) && + (TYPE_UKT_ENVELOPE != pELMInfo->envelopeType) && + (0u == pELMInfo->headTrainID) && (0u == pELMInfo->tailTrainID)) + { + /** δس */ + } + else + { + break; + } + } + + /** ڹUT */ + if (cycleELM != envelopeCnt) + { + /** ΪARBARBռãȫ */ + if (UTACCnt < (MAX_UT_AC_CNT - 1u)) + { + acID[UTACCnt++] = pACIdbuff[cycle]; + } + else + { + UTACCnt = MAX_UT_AC_CNT; + } + } + else + { + /** UTҪ */ + } + } + } + else + { + /** 账 */ + } + } + + /** ÷ֵ */ + ret = UTACCnt; + } + + return ret; +} + +/** + * @brief ȡɸʱ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT32 wls_PrepareRedunTime(void) +{ + return GetTiocAndTmcTransBadEnsureCnt(); +} + +/** +* @brief ָгǷǰ˿ +* @param[in] UINT16 envelopeID ID +* @param[out] +* @return FLAG_SET ǰ˿ + FLAG_UNSET ǰ˿ +* edit cgh 20241009 +*/ +UINT8 elm_CheckTrainheadTrain(UINT16 axisId, UINT16 trainId) +{ + UINT8 flag = 0U; + UINT8 u8Ret = FLAG_UNSET; + UINT16 cycIndex = 0U; + UINT16 Val = 0U; + const EnvelopeStruct* pEnvelope = NULL; + UINT8 envelopeCnt = CI_ERROR; + UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX] = { 0u }; + UINT8 chVirHeadScreenPassFlag = 0U;/*ǰɸ־*/ + + /** ȡİϢ */ + envelopeCnt = elm_GetEnvelopeIDsInAC(axisId, envelopeIDs); + + for (cycIndex = 0U; cycIndex < envelopeCnt; cycIndex++) + { + /*ȡ*/ + pEnvelope = elm_GetEnvelopeInfoByID(envelopeIDs[cycIndex]); + if (NULL != pEnvelope) + { + /**аиIDCT**/ + if ((TYPE_CT_ENVELOPE == pEnvelope->envelopeType) && (trainId == pEnvelope->trainID[0])) + { + chVirHeadScreenPassFlag = GetTrainVirHeadScreenPassFlag(trainId); + + if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != chVirHeadScreenPassFlag) + { + /* ɸѡ־Чпʵʿ */ + Val = pEnvelope->headTrainID; + } + else + { + /* ɸѡ־Ч޿ */ + Val = 0U; + } + break; + } + else + { + ; + } + } + } + if (LINE_MAX_TRAIN != Val) + { + u8Ret = FLAG_SET; + } + else + { + u8Ret = FLAG_UNSET; + } + + /*- ͷɸ״̬*/ + return u8Ret; +} + +/** +* @brief ָгǷ˿ +* @param[in] UINT16 envelopeID ID +* @param[out] +* @return FLAG_SET ޺˿ + FLAG_UNSET к˿ +* edit cgh 20241009 +*/ +UINT8 elm_CheckTrainTailTrain(UINT16 axisId, UINT16 trainId) +{ + UINT8 flag = 0U; + UINT8 u8Ret = FLAG_UNSET; + UINT16 cycIndex = 0U; + UINT16 Val = 0U; + const EnvelopeStruct* pEnvelope = NULL; + UINT8 envelopeCnt = CI_ERROR; + UINT16 envelopeIDs[SECTION_REL_ENVELOPE_SUM_MAX] = { 0u }; + UINT8 chVirTailScreenPassFlag = 0U;/*ɸ־*/ + + /** ȡİϢ */ + envelopeCnt = elm_GetEnvelopeIDsInAC(axisId, envelopeIDs); + + for (cycIndex = 0U; cycIndex < envelopeCnt; cycIndex++) + { + /*ȡ*/ + pEnvelope = elm_GetEnvelopeInfoByID(envelopeIDs[cycIndex]); + if (NULL != pEnvelope) + { + /**аиIDCT**/ + if ((TYPE_CT_ENVELOPE == pEnvelope->envelopeType) && (trainId == pEnvelope->trainID[0])) + { + chVirTailScreenPassFlag = GetTrainVirTailScreenPassFlag(trainId); + + if (TRAIN_VIR_SCREEN_PASS_FLAG_VALID != chVirTailScreenPassFlag) + { + /* ɸѡ־Чпʵʿ */ + Val = pEnvelope->tailTrainID; + } + else + { + /* ɸѡ־Ч޿ */ + Val = 0U; + } + break; + } + else + { + ; + } + } + } + if (LINE_MAX_TRAIN != Val) + { + u8Ret = FLAG_SET; + } + else + { + u8Ret = FLAG_UNSET; + } + + /*- ״̬*/ + return u8Ret; +} + + diff --git a/TSCP/src/APP/ciapp/WLScreen/WLScreenDataPrepare.h b/TSCP/src/APP/ciapp/WLScreen/WLScreenDataPrepare.h new file mode 100644 index 0000000..6268d92 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WLScreenDataPrepare.h @@ -0,0 +1,136 @@ +/****************************************************************************** +** ļ: WLScreenDataPrepare.h +** : ȫɸģⲿ׼ +*******************************************************************************/ +#ifndef WLS_SCREEN_DATA_PREPARE_H_ +#define WLS_SCREEN_DATA_PREPARE_H_ + +#include "WholeLineScreenDefine.h" +#include "ELMDataPrepare.h" +#include "../QueryFiles/dquCIInterFace.h" + +#define WLS_LOG_FATAL 0u /** ά־--ά */ +#define WLS_LOG_ERROR 1u /*ά־--󼶱*/ +#define WLS_LOG_WARING 2u /*ά־--漶*/ +#define WLS_LOG_DEBUG 3u /*ά־--Լ*/ +#define WLS_LOG_LEVEL WLS_LOG_DEBUG /*ά־--ǰ־*/ +#define WLS_PRINT_LEN 1280u /* ά־ӡӡ 1024+256 */ + + +/** ־ӡ */ +#define WLS_LOG_LOC(level,fmt,...) wls_PrintDebugInfo(level,fmt" line:%d fun:%s.\n",##__VA_ARGS__,__LINE__,__FUNCTION__); + +#define WLS_LOG(level,fmt,...) wls_PrintDebugInfo(level,fmt,##__VA_ARGS__); + +#if (kPLATFORM==kWINDOWS) +#define WLS_LOG_TIME(level,fmt,...) { \ + SYSTEMTIME sys; \ + GetLocalTime(&sys); \ + wls_PrintDebugInfo(level,fmt" time:%02d:%02d:%02d.%03d.\n",##__VA_ARGS__,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds); \ +} +#else +#define WLS_LOG_TIME(level,fmt,...) wls_PrintDebugInfo(level,fmt" time:%08d.\n",##__VA_ARGS__,TimeStamp); +#endif + + +/** ӡDebugϢ */ +void wls_PrintDebugInfo(UINT8 level, const char *fmt, ...); + +/** + * @brief ȡȫɸܿ + * @param[in] + * @param[out] + * @return CI_SUCCESS ܴ򿪣CI_ERROR ܹر + * @note + */ +UINT8 wls_PrepareWLSFunSwitch(void); + + +/** + * @brief жϱOCǷΪɸԵTIOC + * @param[in] + * @param[out] + * @return CI_SUCCESS TIOCCI_ERROR TIOC + * @note + */ +UINT8 wls_PrepareisWLSTioc(void); + +/** + * @brief ȡOCǷϵ + * @param[in] + * @param[out] + * @return CI_SUCCESS ϵCI_ERROR δϵ + * @note + */ +UINT8 wls_PrepareTIOCWorkStatus(void); + + +/** + * @brief ȡڼ״̬ + * @param[in] + * @param[out] + * @return CI_SUCCESS ڼCI_ERROR ڼ쳣 + * @note + */ +UINT8 wls_PrepareEnterACStatus(void); + + +/** + * @brief ȡǰ + * @param[in] + * @param[out] + * @return ǰ + * @note + */ +UINT32 wls_PrePareCurCycle(void); + + +/** + * @brief ȡTMCͨ״̬ + * @param[in] + * @param[out] + * @return CI_SUCCESS ͨCI_ERROR ͨ쳣 + * @note + */ +UINT8 wls_PrepareCommStatusWithTMC(void); + +/** +* @brief ȡOCڵUTUT +* @param[in] +* @param[out] UINT16 acID[MAX_UT_AC_CNT] UTID +* @return 0~MAX_UT_AC_CNT-1 ϷֵMAX_UT_AC_CNT Ƿֵ +* @note +*/ +UINT8 wls_PrepareUTACInOCArea(UINT16 acID[MAX_UT_AC_CNT]); + + +/** + * @brief ȡɸʱ + * @param[in] + * @param[out] + * @return + * @note + */ +UINT32 wls_PrepareRedunTime(void); + +/** +* @brief ָгǷǰ˿ +* @param[in] UINT16 envelopeID ID +* @param[out] +* @return FLAG_SET ǰ˿ + FLAG_UNSET ǰ˿ +* edit cgh 20241009 +*/ +UINT8 elm_CheckTrainheadTrain(UINT16 axisId, UINT16 trainId); + +/** +* @brief ָгǷ˿ +* @param[in] UINT16 envelopeID ID +* @param[out] +* @return FLAG_SET ޺˿ + FLAG_UNSET к˿ +* edit cgh 20241009 +*/ +UINT8 elm_CheckTrainTailTrain(UINT16 axisId, UINT16 trainId); + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WLScreen/WLScreenLogicProcess.c b/TSCP/src/APP/ciapp/WLScreen/WLScreenLogicProcess.c new file mode 100644 index 0000000..91f4d51 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WLScreenLogicProcess.c @@ -0,0 +1,324 @@ +#include "WLScreenLogicProcess.h" +#include "WLScreenDataManage.h" +#include "WLScreenDataPrepare.h" + + +/* ================================̬==============================*/ +static UINT8 wls_JudgeStatusChangeAndSus(void); /* жг״̬ǷıҪˢк */ +static UINT8 wls_JudgeNewUTACExist(void); /* ж³UTҪˢк*/ + + +/** + * @brief жг״̬ǷıҪˢк + * @param[in] + * @param[out] + * @return UNNEED_REFRESH ˢкţNEED_REFRESH ҪˢкţNEED_REFRESH_NOW Ҫˢк + * @note + */ +static UINT8 wls_JudgeStatusChangeAndSus(void) +{ + UINT8 ret = NEED_REFRESH_NOW; /** ע⣺˴ֵóUNNEED_REFRESH*/ + UINT32 errorCode = 0u; + UINT16 cycle = 0u; + const WLSreenInfoStruct *pTemp = NULL; + const WLTrainStatusInfoStruct *pCurTrainInfo = NULL; + const WLTrainStatusInfoStruct *pLastTrainInfo = NULL; + + pTemp = wls_GetWholeLineScreeInfo(); + + /** ѭǰΪˢк */ + ret = UNNEED_REFRESH; + for (cycle = 1u; cycle < LINE_MAX_TRAIN;cycle++) + { + pCurTrainInfo = wls_GetCurTrainStatusInfo(cycle); + pLastTrainInfo = wls_GetLastTrainStatusInfo(cycle); + ASSERT_BREAK((NULL == pCurTrainInfo) || (NULL == pLastTrainInfo),errorCode,0x40000000u); + + /** ǰ״̬ */ + if (OUT_CONTROL_STATUS != pCurTrainInfo->controlStatus) + { + /** ǰ״̬ */ + if ((UNNEED_SCREEN == pLastTrainInfo->headNeedScreen) && (NEED_SCREEN == pCurTrainInfo->headNeedScreen)) + { + /** ״̬仯 */ + ret = NEED_REFRESH_NOW; + break; + } + else if (NEED_SCREEN == pCurTrainInfo->headNeedScreen) + { + ret = NEED_REFRESH; + } + else + { + /** Ҫɸѡ */ + } + + /** β״̬ */ + if ((UNNEED_SCREEN == pLastTrainInfo->tailNeedScreen) && (NEED_SCREEN == pCurTrainInfo->tailNeedScreen)) + { + /** ״̬仯 */ + ret = NEED_REFRESH_NOW; + break; + } + else if (NEED_SCREEN == pCurTrainInfo->tailNeedScreen) + { + ret = NEED_REFRESH; + } + else + { + /** Ҫɸѡ */ + } + + } + else + { + /** ǿг */ + } + + /** г״̬ */ + if (pLastTrainInfo->controlStatus != pCurTrainInfo->controlStatus) + { + ret = NEED_REFRESH_NOW; + break; + } + else + { + /** 账*/ + } + } + + return ret; +} + + +/** + * @brief ж³UTҪˢк + * @param[in] + * @param[out] + * @return UNNEED_REFRESH ˢкţNEED_REFRESH ҪˢкţNEED_REFRESH_NOW Ҫˢк + * @note + */ +static UINT8 wls_JudgeNewUTACExist(void) +{ + UINT8 ret = NEED_REFRESH_NOW; + UINT8 funRtn = CI_ERROR; + UINT8 lastUTACCnt = 0u; + UINT16 tmpACid = 0u; + UINT8 cyclelast = 0u; + UINT8 cyclecur = 0u; + UINT8 acCnt = 0u; + UINT16 acID[MAX_UT_AC_CNT] = {0u}; + + /** OCǷUTUT */ + acCnt = wls_PrepareUTACInOCArea(acID); + + if (MAX_UT_AC_CNT == acCnt) + { + ret = NEED_REFRESH_NOW; + } + else if (0u == acCnt) + { + funRtn = wls_SetUTACCnt(0u); + for (cyclecur = 0u; cyclecur < MAX_UT_AC_CNT; cyclecur++) + { + funRtn = wls_SetUTACId(cyclecur,0u); + } + ret = UNNEED_REFRESH; + } + else + { + /** ȡUT */ + lastUTACCnt = wls_GetUTACCnt(); + + if ((MAX_UT_AC_CNT == lastUTACCnt) || (0u == lastUTACCnt)) + { + ret = NEED_REFRESH_NOW; + } + else + { + /** жǷ²UT */ + for (cyclecur = 0u; cyclecur < acCnt;cyclecur++) + { + for (cyclelast = 0u; cyclelast < lastUTACCnt; cyclelast++) + { + tmpACid = wls_GetUTACId(cyclelast); + if (acID[cyclecur] == tmpACid) + { + break; + } + } + + /** жϵǰUTǷΪ²UT */ + if (cyclelast == lastUTACCnt) + { + ret = NEED_REFRESH_NOW; + break; + } + else + { + ret = NEED_REFRESH; + } + } + } + + /** UTϢ */ + funRtn = wls_SetUTACCnt(0u); + for (cyclecur = 0u; cyclecur < MAX_UT_AC_CNT; cyclecur++) + { + funRtn = wls_SetUTACId(cyclecur,0u); + } + funRtn = wls_SetUTACCnt(acCnt); + for (cyclecur = 0u; cyclecur < acCnt;cyclecur++) + { + funRtn = wls_SetUTACId(cyclecur,acID[cyclecur]); + } + } + + return ret; +} + + +/** + * @brief жϵǰǷҪˢк + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_JudgeWLScreenSeqChange(void) +{ + UINT32 tmpCycle = 0u; + UINT8 isNormalWork = CI_ERROR; + UINT8 isEnterCheck = CI_ERROR; + UINT8 isStatusChange = CI_ERROR; + UINT8 isHaveUT = CI_ERROR; + UINT8 reFreshSeq = CI_ERROR; + UINT8 cFunRetVal = CI_ERROR; + const WLSreenInfoStruct *pTemp = NULL; + + pTemp = wls_GetWholeLineScreeInfo(); + + /** TIOCδϵʱˢк */ + isNormalWork = wls_PrepareTIOCWorkStatus(); + if (CI_ERROR == isNormalWork) + { + reFreshSeq = CI_SUCCESS; + } + else + { + /** 账 */ + } + + /** кΪĬֵˢк */ + if ((NULL == pTemp) || ((NULL != pTemp) && (0u == pTemp->sendSeq))) + { + reFreshSeq = CI_SUCCESS; + } + else + { + /** 账 */ + } + + /** ȡڼ״̬*/ + isEnterCheck = wls_PrepareEnterACStatus(); + if (CI_ERROR == isEnterCheck) + { + reFreshSeq = CI_SUCCESS; + cFunRetVal = wls_SetEnterCheckFlag(ENTER_ERROR_FLAG); + } + else if ((NULL != pTemp) && (ENTER_ERROR_FLAG == pTemp->enterCheckFlag)) + { + reFreshSeq = CI_SUCCESS; + cFunRetVal = wls_SetEnterCheckFlag(ENTER_OK_FLAG); + } + else + { + /* ڼ״̬δ仯 */ + } + + + /** OCǷUTUT */ + isHaveUT = wls_JudgeNewUTACExist(); + + /** ȡг״̬Ƿı䣨гǰسޱСܿسӻ߼٣*/ + isStatusChange = wls_JudgeStatusChangeAndSus(); + + if ((NEED_REFRESH_NOW == isStatusChange) || (NEED_REFRESH_NOW == isHaveUT)) + { + reFreshSeq = CI_SUCCESS; + cFunRetVal = wls_SetUTFlag(UNKNOWN_TRAIN_EXIST); + } + else if (((NEED_REFRESH == isStatusChange) || (NEED_REFRESH == isHaveUT)) && + ((NULL != pTemp) && (UNKNOWN_TRAIN_EXIST != pTemp->UTFlag))) + { + /** ˷֧Ϊȫ֧ܳӦ޷ */ + reFreshSeq = CI_SUCCESS; + cFunRetVal = wls_SetUTFlag(UNKNOWN_TRAIN_EXIST); + } + else if ((UNNEED_REFRESH == isStatusChange) && (UNNEED_REFRESH == isHaveUT) && + (NULL != pTemp) && (UNKNOWN_TRAIN_EXIST == pTemp->UTFlag)) + { + cFunRetVal = wls_SetUTFlag(UNKNOWN_TRAIN_UNEXIST); + } + else + { + /** ά֮ǰ״̬ */ + } + + + /** ɸк */ + if (CI_SUCCESS == reFreshSeq) + { + tmpCycle = wls_PrePareCurCycle(); + wls_SetSendSeq(tmpCycle); + } + else + { + /** 账 */ + } +} + + +/** + * @brief жϵǰǷ߱ȫɸ + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_JudgeWLScreenPermit(void) +{ + const WLSreenInfoStruct *pTemp = NULL; + UINT8 cTiocWorkStatus = CI_ERROR; + UINT32 redunTime = 0u; + + pTemp = wls_GetWholeLineScreeInfo(); + + /* ȡϵ־ */ + cTiocWorkStatus = wls_PrepareTIOCWorkStatus(); + + /** ȡɸʱ */ + redunTime = wls_PrepareRedunTime(); + + /** TIOCϵ硢TMCظɸ*/ + if ((CI_SUCCESS == cTiocWorkStatus) && (NULL != pTemp) + && (0u != pTemp->sendSeq) + && (pTemp->sendSeq == pTemp->recvSeq) + && (TMC_WLS_VALID == pTemp->WLScreenVaildFlag)) + { + if (pTemp->redunTime < redunTime) + { + wls_AddRedunTime(redunTime); + } + else + { + wls_SetWLScreenProcessFlag(WHOLE_LINE_SCREEN_VAILD); + } + + } + else + { + wls_SetRedunTime(0u,redunTime); + wls_SetWLScreenProcessFlag(WHOLE_LINE_SCREEN_UNVAILD); + } +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WLScreen/WLScreenLogicProcess.h b/TSCP/src/APP/ciapp/WLScreen/WLScreenLogicProcess.h new file mode 100644 index 0000000..a50ed78 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WLScreenLogicProcess.h @@ -0,0 +1,35 @@ +/****************************************************************************** +** ļ: WLScreenLogicProcess.h +** : ȫɸģ߼ +*******************************************************************************/ +#ifndef WLS_SCREEN_LOGIC_PROCESS_H_ +#define WLS_SCREEN_LOGIC_PROCESS_H_ + +#include "WholeLineScreenDefine.h" + + +#define UNNEED_REFRESH 0x00u /* Ҫˢ */ +#define NEED_REFRESH 0x55u /* Ҫˢ */ +#define NEED_REFRESH_NOW 0xaau /* Ҫˢ */ + +/** + * @brief жϵǰǷҪˢк + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_JudgeWLScreenSeqChange(void); + + +/** + * @brief жϵǰǷ߱ȫɸ + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_JudgeWLScreenPermit(void); + + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenAPI.c b/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenAPI.c new file mode 100644 index 0000000..2ff80f0 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenAPI.c @@ -0,0 +1,525 @@ +/****************************************************************************** +** ļ: WholeLineScreenAPI.c +** : ȫɸģӿʵ +*******************************************************************************/ +#include "WholeLineScreenAPI.h" +#include "WLScreenDataManage.h" +#include "WLScreenDataPrepare.h" +#include "CommonMemory.h" +#include "WLScreenLogicProcess.h" +#include "SystemConfigDefine.h" + + + +/** + * @brief ӿڣӡȫɸϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_PrintfWLScreenInfo(void) +{ + UINT16 cycle = 0u; + UINT8 cycleAC = 0u; + UINT8 UTACCnt = 0u; + UINT16 tmpACID = 0u; + const WLSreenInfoStruct* pTemp = NULL; + const WLTrainStatusInfoStruct* pTrainInfo = NULL; + UINT16 outStringLength = 0u; + UINT8 outwlsString[MAX_WLS_LOG_NUM] = { 0U }; + UINT8 lastTrainNum = 0U; + UINT16 lastTrainDress = 0U; + UINT8 curTrainNum = 0U; + UINT16 curTrainDress = 0U; + + /** ȡȫɸϢĵַ ᷵NULL*/ + pTemp = wls_GetWholeLineScreeInfo(); + + LongToChar(pTemp->sendSeq, &outwlsString[outStringLength]); + outStringLength += 4U; + LongToChar(pTemp->recvSeq, &outwlsString[outStringLength]); + outStringLength += 4U; + outwlsString[outStringLength++] = pTemp->WLScreenProcessFlag; + outwlsString[outStringLength++] = pTemp->WLScreenVaildFlag; + outwlsString[outStringLength++] = pTemp->UTFlag; + outwlsString[outStringLength++] = pTemp->enterCheckFlag; + outwlsString[outStringLength++] = (UINT8)pTemp->redunTime; + lastTrainDress = outStringLength; + outStringLength++; /*lasttrain*/ + + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + pTrainInfo = wls_GetLastTrainStatusInfo(cycle); + + if ((NULL != pTrainInfo) && (OUT_CONTROL_STATUS != pTrainInfo->controlStatus)) + { + lastTrainNum++; + ShortToChar(cycle, &outwlsString[outStringLength]); + outStringLength += 2U; + outwlsString[outStringLength++] = pTrainInfo->controlStatus; + outwlsString[outStringLength++] = pTrainInfo->headNeedScreen; + outwlsString[outStringLength++] = pTrainInfo->tailNeedScreen; + } + else + { + /** ǿسӡ */ + } + } + outwlsString[lastTrainDress] = lastTrainNum; + + curTrainDress = outStringLength; + outStringLength++; /*curTrain*/ + + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + pTrainInfo = wls_GetCurTrainStatusInfo(cycle); + + if ((NULL != pTrainInfo) && (OUT_CONTROL_STATUS != pTrainInfo->controlStatus)) + { + curTrainNum++; + ShortToChar(cycle, &outwlsString[outStringLength]); + outStringLength += 2U; + outwlsString[outStringLength++] = pTrainInfo->controlStatus; + outwlsString[outStringLength++] = pTrainInfo->headNeedScreen; + outwlsString[outStringLength++] = pTrainInfo->tailNeedScreen; + } + else + { + /** ǿسӡ */ + } + } + outwlsString[curTrainDress] = curTrainNum; + + /* ӡUTID */ + UTACCnt = wls_GetUTACCnt(); + + outwlsString[outStringLength++] = UTACCnt; + + for (cycleAC = 0u; cycleAC < UTACCnt; cycleAC++) + { + tmpACID = wls_GetUTACId(cycleAC); + ShortToChar(tmpACID, &outwlsString[outStringLength]); + outStringLength += 2U; + } + + + if (outStringLength == 0u) + { + } + else + { +#ifdef PLATFORM_2OO2 + debug_infor_printf((const)"\nWLSScreeData:%d\nsendseq(4)-recvSeq(4)-WLScreenProcessFlag-WLScreenVaildFlag-UTFlag-enterCheckFlag-redunTime-lastTrainNum-cycle-controlStatus-headNeedScreen-tailNeedScreen-curTrainNum-cycle-controlStatus-headNeedScreen-tailNeedScreen-UTACCnt-tmpACID", outStringLength); + + debug_out_array(0xAA, outwlsString, outStringLength); +#endif + +#ifdef PLATFORM_LABVIEW_DEBUG + + Out_Array_Buffer(0, "\nWLSScreeData:%d", outStringLength); + Out_Array_Buffer(0, "nsendseq(4)-recvSeq(4)-WLScreenProcessFlag-WLScreenVaildFlag-UTFlag-enterCheckFlag-redunTime-lastTrainNum-cycle-controlStatus-headNeedScreen-tailNeedScreen-curTrainNum-cycle-controlStatus-headNeedScreen-tailNeedScreen-UTACCnt-tmpACID:%d", outStringLength); + Out_Array_Buffer(16, outwlsString, outStringLength); + +#endif + } +} + + +/** + * @brief ӿڣȫɸģʼ + * @param[in] + * @param[out] + * @return + * @note CI_ERROR,ʼʧܣCI_SUCCESS,ʼɹ + */ +UINT8 wls_Init(void) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT8 funRet = CI_ERROR; + UINT8 cycleAC = 0u; + UINT16 cycle = 0u; + UINT32 redunTime = 0u; + WLTrainStatusInfoStruct tmpTrainInfo = {0u}; + + wls_SetSendSeq(0u); + wls_SetRecvSeq(0u); + + wls_SetWLScreenProcessFlag(WHOLE_LINE_SCREEN_UNVAILD); + + funRet = wls_SetWLScreenVaildFlag(TMC_WLS_UNVALID); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x80000000u); + + funRet = wls_SetUTFlag(UNKNOWN_TRAIN_EXIST); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x40000000u); + + funRet = wls_SetEnterCheckFlag(ENTER_ERROR_FLAG); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x20000000u); + + /** ȡɸʱ */ + redunTime = wls_PrepareRedunTime(); + wls_SetRedunTime(0u,redunTime); + + funRet = wls_SetUTACCnt(0u); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x10000000u); + for (cycleAC =0u; cycleAC < MAX_UT_AC_CNT; cycleAC++) + { + funRet = wls_SetUTACId(cycleAC,0u); + ASSERT_BREAK(CI_ERROR == funRet,errorCode,0x08000000u); + } + + tmpTrainInfo.controlStatus = OUT_CONTROL_STATUS; + tmpTrainInfo.headNeedScreen = NEED_SCREEN; + tmpTrainInfo.tailNeedScreen = NEED_SCREEN; + + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + funRet = wls_SetCurTrainStatusInfo(cycle,&tmpTrainInfo); + ASSERT_BREAK(CI_ERROR == funRet,errorCode,0x04000000u); + + funRet = wls_SetLastTrainStatusInfo(cycle,&tmpTrainInfo); + ASSERT_BREAK(CI_ERROR == funRet,errorCode,0x02000000u); + } + + /** úֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + ASSER_DEBUG(0u != errorCode, WLS_LOG_LOC(WLS_LOG_ERROR, "errno:0x%08x info:WLS Init error.\n", errorCode)); + return ret; +} + + +/** + * @brief ӿڣȫɸ + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_MainProcess(void) +{ + UINT8 isWLSTiocFlag = CI_ERROR; + UINT8 isfunSwitch = CI_ERROR; + UINT8 tmcCommStatus = CI_ERROR; + + /** жϱOCǷΪɸԵTIOC */ + isWLSTiocFlag = wls_PrepareisWLSTioc(); + isfunSwitch = wls_PrepareWLSFunSwitch(); + + if ((CI_ERROR == isWLSTiocFlag) || (CI_ERROR == isfunSwitch)) + { + /** ǾɸTIOC߹ܿδ򿪣д */ + } + else + { + tmcCommStatus = wls_PrepareCommStatusWithTMC(); + + if (CI_ERROR == tmcCommStatus) + { + wls_ClearWLSInfoFromTMC(); + } + else + { + /** 账 */ + } + + /** ˢɸк */ + wls_JudgeWLScreenSeqChange(); + + /** жǷ߱ɸ */ + wls_JudgeWLScreenPermit(); + } +} + +/** + * @brief ӿڣȫɸģ + * @param[out] UINT8 *pDataBuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ݵij + * @note + */ +UINT32 wls_GetTransferData(OUT UINT8 *pDataBuff,UINT32 curIndex) +{ + /*- ֲ */ + UINT32 ret = curIndex; + UINT32 errorCode = 0u; + UINT32 copyIndex = curIndex; + const WLSreenInfoStruct *pTemp = NULL; + + /** ڲУ*/ + ASSERT_RET_VALUE(NULL == pDataBuff,ret,0x80000000u); + + /** ȡȫɸϢָ */ + pTemp = wls_GetWholeLineScreeInfo(); /*᷵NULL*/ + + /* ģ鿪ʼʶ */ + pDataBuff[copyIndex++] = (UINT8)'W'; + pDataBuff[copyIndex++] = (UINT8)'L'; + pDataBuff[copyIndex++] = (UINT8)'S'; + + /** ȫɸϢ */ + (void)CommonMemCpy((void*)&pDataBuff[copyIndex], (UINT32)sizeof(WLSreenInfoStruct), (const void *)pTemp, (UINT32)sizeof(WLSreenInfoStruct)); + copyIndex += (UINT32)sizeof(WLSreenInfoStruct); + + /** ȷ*/ + ret = copyIndex; + + /** */ + return ret; +} + + +/** + * @brief ӿڣȫɸģ + * @param[in] const UINT8 *pDatabuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @param[in] UINT32 len ݵij + * @return ȡ + * @note + */ +UINT32 wls_SetTransferData(IN const UINT8 *pDatabuff,UINT32 curIndex,UINT32 len) +{ + UINT32 ret = curIndex; + UINT32 errorCode = 0u; + UINT32 setIndex = curIndex; + UINT8 modelFlag[3u] = {0u}; + UINT8 funRtn = CI_ERROR; + WLSreenInfoStruct tmpWLScreenInfo = {0u}; /* ˴Ҫע⣬ԺWLSreenInfoStructʱҪǶջӰ */ + + /** ڲж */ + ASSERT_RET_VALUE(NULL == pDatabuff,ret,0x80000000u); + ASSERT_RET_VALUE(curIndex >= len,ret,0x40000000u); + + /** ȡģ鿪ʼʶ */ + modelFlag[0u] = pDatabuff[setIndex++]; + modelFlag[1u] = pDatabuff[setIndex++]; + modelFlag[2u] = pDatabuff[setIndex++]; + + /** жϸǷȷ */ + if (((UINT8)'W' != modelFlag[0u]) || ((UINT8)'L' != modelFlag[1u]) || ((UINT8)'S' != modelFlag[2u])) + { + errorCode = errorCode + 0x20000000u; + WLS_LOG_LOC(WLS_LOG_ERROR,"errno:0x%08x info:set WLS TransferData by head:%c%c%C error.",errorCode,modelFlag[0u],modelFlag[1u],modelFlag[2u]); + } + else + { + /** ȫɸϢ */ + (void)CommonMemCpy(&tmpWLScreenInfo, (UINT32)sizeof(WLSreenInfoStruct),&pDatabuff[setIndex], (UINT32)sizeof(WLSreenInfoStruct)); + setIndex += (UINT32)sizeof(WLSreenInfoStruct); + + /** øϢ */ + funRtn = wls_SetWholeLineScreeInfo(&tmpWLScreenInfo); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x20000000u); + + /** ÷ֵ */ + ASSERT_SETRET((0u == errorCode) && (setIndex <= len), ret, setIndex, ret); + ASSER_DEBUG(0u != errorCode, WLS_LOG_LOC(WLS_LOG_ERROR, "errno:0x%08x info:WLS Set dataIndex%d.dataLen:%d.\n", errorCode, setIndex, len)); + } + + return ret; +} + + +/** + * @brief ӿڣ׼ⷢ͵Ϣ + * @param[in] + * @param[out] WLScreenReportStruct *pOutInfo + * @return CI_ERROR CI_SUCCESS ɹ + * @note + */ +UINT8 wls_PrepareWLSInfoToTMC(OUT WLScreenReportStruct *pOutInfo) +{ + UINT8 ret = CI_ERROR; + UINT32 errorCode = 0u; + UINT16 cycle = 0u; + const WLSreenInfoStruct* pWLScreenInfo = NULL; + const WLTrainStatusInfoStruct *pTrainInfo = NULL; + + /** ڲУ */ + ASSERT_RET_VALUE(NULL == pOutInfo,ret,0x80000000u); + + /** ȡȫɸϢ */ + pWLScreenInfo = wls_GetWholeLineScreeInfo();/*᷵NULL*/ + + pOutInfo->sendSeq = pWLScreenInfo->sendSeq; + pOutInfo->UTFlag = pWLScreenInfo->UTFlag; + pOutInfo->enterCheckFlag = pWLScreenInfo->enterCheckFlag; + + pOutInfo->controlTrainCnt = 0u; + pOutInfo->offlineTrainCnt = 0u; + + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + pTrainInfo = wls_GetCurTrainStatusInfo(cycle); + ASSERT_BREAK(NULL == pTrainInfo, errorCode, 0x20000000u); + + if ((IN_CONTROL_STATUS == pTrainInfo->controlStatus) && (pOutInfo->controlTrainCnt < TRAIN_SUM_MAX_IN_OC)) + { + pOutInfo->controlTrainID[pOutInfo->controlTrainCnt] = cycle; + pOutInfo->controlTrainCnt++; + } + else if ((OFFLINE_CONFIRM_STATUS == pTrainInfo->controlStatus) && (pOutInfo->controlTrainCnt < TRAIN_SUM_MAX_IN_OC)) + { + pOutInfo->offlineTrainID[pOutInfo->offlineTrainCnt] = cycle; + pOutInfo->offlineTrainCnt++; + } + else + { + /** 账 */ + } + } + + + /** ÷ֵ */ + ASSERT_SETRET(0u == errorCode, ret, CI_SUCCESS, CI_ERROR); + ASSER_DEBUG(0u != errorCode, WLS_LOG_LOC(WLS_LOG_ERROR, "errno:0x%08x info:Prepare Train%d Info To TMC error.\n", errorCode, cycle)); + + return ret; +} + + +/** + * @brief ӿڣ׼ⷢ͵Ϣ + * @param[in] const WLScreenReciveStruct *pInInfo + * @param[out] + * @return + * @note + */ +void wls_RefreshWLSInfoFromTMC(IN const WLScreenReciveStruct *pInInfo) +{ + UINT32 errorCode = 0u; + UINT8 funRtn = CI_ERROR; + UINT16 cycle = 0u; + UINT16 cycleTrain = 0u; + const WLTrainStatusInfoStruct* pTrainInfo = NULL; + + /** ڲУ */ + if (NULL == pInInfo) + { + wls_ClearWLSInfoFromTMC(); + } + else + { + /** ýյк */ + wls_SetRecvSeq(pInInfo->recvSeq); + + /** ȫɸ־ */ + funRtn = wls_SetWLScreenVaildFlag(pInInfo->WLScreenVaildFlag); + ASSER_ERROR(CI_ERROR == funRtn,errorCode,0x40000000u); + + for (cycle = 1u; cycle < LINE_MAX_TRAIN; cycle++) + { + pTrainInfo = wls_GetCurTrainStatusInfo(cycle); + + if ((NULL != pTrainInfo) && (OFFLINE_CONFIRM_STATUS == pTrainInfo->controlStatus)) + { + /** ߳ȫܿسΧڣг״̬Ϊڿ״̬ */ + for (cycleTrain = 0u; cycleTrain < pInInfo->WLTrainCnt;cycleTrain++) + { + if (cycle == pInInfo->WLTrainID[cycleTrain]) + { + break; + } + } + + if (cycleTrain == pInInfo->WLTrainCnt) + { + wls_SetTrainControlStatus(cycle,OUT_CONTROL_STATUS,NEED_SCREEN,NEED_SCREEN); + } + else + { + /** 账 */ + } + } + } + } +} + +/** + * @brief ӿڣTMCյϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_ClearWLSInfoFromTMC(void) +{ + UINT8 funRet = CI_ERROR; + UINT32 errorCode = 0u; + + wls_SetRecvSeq(0u); + wls_SetWLScreenProcessFlag(WHOLE_LINE_SCREEN_UNVAILD); + + funRet = wls_SetWLScreenVaildFlag(TMC_WLS_UNVALID); + ASSER_ERROR(CI_ERROR == funRet,errorCode,0x80000000u); + + ASSER_DEBUG(0u != errorCode, WLS_LOG_LOC(WLS_LOG_ERROR, "errno:0x%08x info:Clear WLS Info From TMC error.\n", errorCode)); +} + +/** + * @brief ӿ:гĿ״̬ + * @param[in] UINT16 trainID гID + * @param[in] UINT8 ControlStatus г״̬ + * @param[in] UINT8 headFlag ǰس־ + * @param[in] UINT8 tailFlag س־ + * @param[out] + * @return + * @note + */ +void wls_SetTrainControlStatus(UINT16 trainID,UINT8 ControlStatus,UINT8 headFlag, UINT8 tailFlag) +{ + UINT8 funRtn = CI_ERROR; + WLTrainStatusInfoStruct temp = {0u}; + + temp.controlStatus = ControlStatus; + temp.headNeedScreen = headFlag; + temp.tailNeedScreen = tailFlag; + funRtn = wls_SetCurTrainStatusInfo(trainID,&temp); + + if (CI_ERROR == funRtn) + { + WLS_LOG_LOC(WLS_LOG_ERROR, "info:Set Train%d Control Status error.\n", trainID); + } + else + { + /** */ + } +} + +/** + * @brief ӿڣȡгĿ״̬ + * @param[in] UINT16 trainID гID + * @param[out] + * @return OUT_CONTROL_STATUS ڿ״̬ijIN_CONTROL_STATUS ڿ״̬ijOFFLINE_CONFIRM_STATUS ߴȷϵij + * @note ״̬ΪΪȫ + */ +UINT8 wls_GetTrainControlStatus(UINT16 trainID) +{ + UINT8 ret = OFFLINE_CONFIRM_STATUS; + const WLTrainStatusInfoStruct* pInfo = NULL; + + pInfo = wls_GetCurTrainStatusInfo(trainID); + + if (NULL != pInfo) + { + ret = pInfo->controlStatus; + } + else + { + /* */ + } + return ret; +} + +/** + * @brief ӿڣȡɸִб־ + * @param[in] + * @param[out] + * @return WHOLE_LINE_SCREEN_VAILD ȫɸWHOLE_LINE_SCREEN_UNVAILD ȫɸ + * @note + */ +UINT8 wls_GetWLScreenPermitFlag(void) +{ + return wls_GetWLScreenProcessFlag(); +} + diff --git a/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenAPI.h b/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenAPI.h new file mode 100644 index 0000000..9012723 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenAPI.h @@ -0,0 +1,123 @@ +/****************************************************************************** +** ļ: WholeLineScreenAPI.h +** : ȫɸģӿ +*******************************************************************************/ +#ifndef WHOLE_LINE_SCREEN_API_H_ +#define WHOLE_LINE_SCREEN_API_H_ +#include "WholeLineScreenDefine.h" + + +/** + * @brief ӿڣӡȫɸϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_PrintfWLScreenInfo(void); + + +/** + * @brief ӿڣȫɸģʼ + * @param[in] + * @param[out] + * @return + * @note CI_ERROR,ʼʧܣCI_SUCCESS,ʼɹ + */ +UINT8 wls_Init(void); + +/** + * @brief ӿڣȫɸ + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_MainProcess(void); + +/** + * @brief ӿڣȫɸģ + * @param[out] UINT8 *pDataBuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @return ݵij + * @note + */ +UINT32 wls_GetTransferData(OUT UINT8 *pDataBuff,UINT32 curIndex); + +/** + * @brief ӿڣȫɸģ + * @param[in] const UINT8 *pDatabuff ݵĴ洢ַָ + * @param[in] UINT32 curIndex ݵַ + * @param[in] UINT32 len ݵij + * @return ȡ + * @note + */ +UINT32 wls_SetTransferData(IN const UINT8 *pDatabuff,UINT32 curIndex,UINT32 len); + + +/** + * @brief ӿڣ׼ⷢ͵Ϣ + * @param[in] + * @param[out] WLScreenReportStruct *pOutInfo + * @return CI_ERROR CI_SUCCESS ɹ + * @note + */ +UINT8 wls_PrepareWLSInfoToTMC(OUT WLScreenReportStruct *pOutInfo); + + +/** + * @brief ӿڣˢϢ + * @param[in] const WLScreenReciveStruct *pInInfo + * @param[out] + * @return + * @note + */ +void wls_RefreshWLSInfoFromTMC(IN const WLScreenReciveStruct *pInInfo); + +/** + * @brief ӿڣTMCյϢ + * @param[in] + * @param[out] + * @return + * @note + */ +void wls_ClearWLSInfoFromTMC(void); + + +/** + * @brief ӿ:гĿ״̬ + * @param[in] UINT16 trainID гID + * @param[in] UINT8 ControlStatus г״̬ + * @param[in] UINT8 headFlag ǰس־ + * @param[in] UINT8 tailFlag س־ + * @param[out] + * @return + * @note гͷβڱOCʱ + */ +void wls_SetTrainControlStatus(UINT16 trainID,UINT8 ControlStatus,UINT8 headFlag, UINT8 tailFlag); + +/** + * @brief ӿڣȡгĿ״̬ + * @param[in] UINT16 trainID гID + * @param[out] + * @return OUT_CONTROL_STATUS ڿ״̬ijIN_CONTROL_STATUS ڿ״̬ijOFFLINE_CONFIRM_STATUS ߴȷϵij + * @note + */ +UINT8 wls_GetTrainControlStatus(UINT16 trainID); + + + +/** + * @brief ӿڣȡɸ־ + * @param[in] + * @param[out] + * @return WHOLE_LINE_SCREEN_VAILD ȫɸWHOLE_LINE_SCREEN_UNVAILD ȫɸ + * @note + */ +UINT8 wls_GetWLScreenPermitFlag(void); + + + + +#endif + diff --git a/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenDefine.h b/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenDefine.h new file mode 100644 index 0000000..cc476b3 --- /dev/null +++ b/TSCP/src/APP/ciapp/WLScreen/WholeLineScreenDefine.h @@ -0,0 +1,88 @@ +/****************************************************************************** +** ļ: WholeLineScreenDefine.h +** : ȫɸֵܺṹ嶨 +*******************************************************************************/ +#ifndef WHOLE_LINE_SCREEN_DEFINE_H_ +#define WHOLE_LINE_SCREEN_DEFINE_H_ + +#include "CommonTypes.h" +#include "EnvelopeDefine.h" + + +#define UNKNOWN_TRAIN_EXIST (0x55u) /* ڴس */ +#define UNKNOWN_TRAIN_UNEXIST (0xaau) /* ڲس */ + +#define ENTER_ERROR_FLAG (0x55u) /* ڼ쳣 */ +#define ENTER_OK_FLAG (0xaau) /* ڼ */ + + +#define WHOLE_LINE_SCREEN_VAILD (0x55u) /* ȫɸִ */ +#define WHOLE_LINE_SCREEN_UNVAILD (0xaau) /* ȫɸִ */ + +#define TMC_WLS_VALID (0x55u) /* TMCȫɸ */ +#define TMC_WLS_UNVALID (0xaau) /* TMCȫɸ */ + + +/** г״̬ */ +#define OUT_CONTROL_STATUS (0x00u) /* ڿ״̬ij */ +#define IN_CONTROL_STATUS (0x55u) /* ڿ״̬ijCTUCT */ +#define OFFLINE_CONFIRM_STATUS (0xaau) /* ߴȷϵij */ + +/** гɸѡ״̬ */ +#define UNNEED_SCREEN (0xaau) /** ǰδس*/ +#define NEED_SCREEN (0x55u) /** ǰس*/ + + +#define MAX_UT_AC_CNT 41U /** UT40 41ΪǷֵ*/ +#define MAX_WLS_LOG_NUM 10000U /*ȫɸ־*/ + +/* г״̬Ϣ */ +typedef struct +{ + UINT8 controlStatus; /** г״̬ */ + UINT8 headNeedScreen; /** ͷҪɸѡ */ + UINT8 tailNeedScreen; /** βҪɸѡ */ +}WLTrainStatusInfoStruct; + + +/** ȫɸ״̬Ϣṹ */ +typedef struct +{ + UINT32 sendSeq; /** ͸TMCɸк */ + UINT32 recvSeq; /** TMCɸк */ + UINT8 WLScreenProcessFlag; /** ȫɸ־ */ + UINT8 WLScreenVaildFlag; /** TMC͵ȫɸ־ */ + UINT8 UTFlag; /** Ƿس־ */ + UINT8 enterCheckFlag; /** ڼ־ */ + UINT32 redunTime; /** ʱ */ + UINT8 UTACCnt; /** UT */ + UINT16 UTACId[MAX_UT_AC_CNT]; + WLTrainStatusInfoStruct curTrainStatusInfo[LINE_MAX_TRAIN]; /** г״̬Ϣ */ + WLTrainStatusInfoStruct lastTrainStatusInfo[LINE_MAX_TRAIN]; /** г״̬Ϣ */ +}WLSreenInfoStruct; + + +/* ȫɸϢ㱨ṹ--ӿڹϢ׼ʹ */ +typedef struct +{ + UINT32 sendSeq; + UINT8 UTFlag; + UINT8 enterCheckFlag; + UINT8 controlTrainCnt; /* гϢ */ + UINT16 controlTrainID[TRAIN_SUM_MAX_IN_OC]; + UINT8 offlineTrainCnt; /* гϢ */ + UINT16 offlineTrainID[TRAIN_SUM_MAX_IN_OC]; +}WLScreenReportStruct; + + + +/* ȫɸϢսṹ--ӿڹϢʹ */ +typedef struct +{ + UINT32 recvSeq; + UINT8 WLScreenVaildFlag; + UINT8 WLTrainCnt; /** ȫܿгϢ */ + UINT16 WLTrainID[LINE_MAX_TRAIN]; +}WLScreenReciveStruct; + +#endif \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WashMachine/WashMachineConfigDataManage.c b/TSCP/src/APP/ciapp/WashMachine/WashMachineConfigDataManage.c new file mode 100644 index 0000000..f824746 --- /dev/null +++ b/TSCP/src/APP/ciapp/WashMachine/WashMachineConfigDataManage.c @@ -0,0 +1,718 @@ +/******************************************************** +* +* WashMachineDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-24 +* ߣ +* ϴݹ +* ޸ļ¼ +* +********************************************************/ + +#include "WashMachineConfigDataManage.h" + + + + +WashMachineConfigDataStruct WashMachineConfigDataStru[WASHMACHINE_SUM_MAX]; /*ϴýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +UINT16 LocalCiWashMachineIdBuf[WASHMACHINE_SUM_MAX] = {0u}; /*屾ϴӳ*/ +UINT16 WashMachineCurSum = 0u; /*ϴǰ*/ + + + + +/* +* ȡϴǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ϴǰ +*/ +UINT16 GetWashMachineSum(void) +{ + UINT16 retVal = 0u; + if (WashMachineCurSum >= WASHMACHINE_SUM_MAX) + { + retVal = 0U; + } + else + { + retVal = WashMachineCurSum; + } + return retVal; +} + +/* +* ȡָ±ӦϴID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ϴID +*/ +UINT16 GetWashMachineId(const UINT16 bufIndex) +{ + UINT16 retVal = 0u; + if (bufIndex < GetWashMachineSum()) + { + retVal = LocalCiWashMachineIdBuf[bufIndex]; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴ +* ˵ const UINT16 washMachineId, ϴID +* ֵ SWITCH_SUM_MAX: ȡʧ +* = 1u) && (washMachineId < WASHMACHINE_SUM_MAX)) + { + retVal = washMachineId; + } + else + { + retVal = WASHMACHINE_SUM_MAX; + } + return retVal; +} + +/* +* ȡָIDϴID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetWashMachineBelongCiId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].BelongCiId; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ȡָIDϴ̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetWashMachineReadyRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].WashMachineReadyRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDϴȷϼ̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ȷϼ̵ID +*/ +UINT16 GetWashMachineReqVerifyRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].WashMachineRequestVerifyRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + + + +/* +* ȡָIDϴг̵ͣ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: г̵ͣ +*/ +UINT16 GetTrainEmergencyStopRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].TrainEmergencyStopRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + + +/* +* ȡָIDϴͷϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͷϴ̵ +*/ +UINT16 GetHeadWashAllowRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].HeadWashAllowRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + + +/* +* ȡָIDϴβϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: βϴ̵ +*/ +UINT16 GetTailWashAllowRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].TailWashAllowRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ̵ +*/ +UINT16 GetTrainOutWashPortAllowRelay(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].TrainOutWashPortAllowRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + + + +/* +* ȡָIDϴϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ̵ +*/ +UINT16 GetWashTrainRequestRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].WashTrainRequestRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDϴͷͣȼ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͷͣȼ̵ +*/ +UINT16 GetTrainHeadStopSteadyRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].TrainHeadStopSteadyRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴβͣȼ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: βͣȼ̵ +*/ +UINT16 GetTrainTailStopSteadyRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].TrainTailStopSteadyRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ϴ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 WashMachineConfigDataManage(void) +{ + UINT16 ii = 0u; /*α*/ + UINT16 jj = 0u; /*α*/ + UINT16 washMachineConfigDataSum = 0u; /*ϴ豸*/ + UINT8 retVal = CI_ERROR; + + washMachineConfigDataSum = GetWashMachineSum(); /*ȡϴ ڵWASHMACHINE_SUM_MAX0*/ + + for (ii = 0u; ii < WASHMACHINE_SUM_MAX; ii++) + { + if (jj == washMachineConfigDataSum) + {/*Ч*/ + + break; + } + else + { + } + + if (WashMachineConfigDataStru[ii].BelongCiId == GetSystemParaLocalCiId()) + {/*òΪЧ*/ + + LocalCiWashMachineIdBuf[jj] = WashMachineConfigDataStru[ii].WashMachineId; + jj++; + } + else + { + } + } + return CI_SUCCESS; +} + +/* +* ȡָIDϴͣϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͣϴ̵ID +*/ +UINT16 GetPauseTrainWashRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].PauseTrainWashRequestRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴ̵ͨ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ̵ͨ +*/ +UINT16 GetPassRequestRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].TrainPassRequestRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDϴID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧܻ߱ϴ +* >0: ID +*/ +UINT8 GetWashMachineBelongVirCiId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (WASHMACHINE_SUM_MAX > bufIndex) + { + retVal = WashMachineConfigDataStru[bufIndex].BelongVirCiId; + } + + return retVal; + +} + +/* +* ȡָIDϴϴģʽ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴģʽ̵ +* by cgh 20231109 +*/ +UINT16 GetWashModeBackRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].WashModeBackRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴϴģʽ̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ȫԶԶϴģʽ̵ +* by cgh 20231109 +*/ +UINT16 GetWashModeRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].WashModeRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴͬⰴť̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴͬⰴť̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashAllowRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashAllowRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴָͬʾƼ̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴָͬʾƼ̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashAllowLightRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashAllowLightRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴͬͨť̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴͬͨť̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashAllowPassRelayId(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashAllowPassRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴ߿̨ʾ1·ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ1·ID +* by cgh 20231109 +*/ +UINT16 GetDownWashRelateRoute1Id(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashRelateRoute1Id; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴ߿̨ʾ1·״̬ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ1·״̬ +* by cgh 20231109 +*/ +UINT8 GetDownWashRelRoute1CheckType(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashRelateRoute1CheckType; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴ߿̨ʾ1̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ1̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashRelRoute1LightRelay(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashRelRoute1LightRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴ߿̨ʾ2·ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ2·ID +* by cgh 20231109 +*/ +UINT16 GetDownWashRelateRoute2Id(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashRelateRoute2Id; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴ߿̨ʾ2·״̬ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ2·״̬ +* by cgh 20231109 +*/ +UINT8 GetDownWashRelRoute2CheckType(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashRelateRoute2CheckType; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴģʽϴ߿̨ʾ2̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ2̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashRelRoute2LightRelay(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT16 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineConfigDataStru[bufIndex].wDownWashRelRoute2LightRelayId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/APP/ciapp/WashMachine/WashMachineConfigDataManage.h b/TSCP/src/APP/ciapp/WashMachine/WashMachineConfigDataManage.h new file mode 100644 index 0000000..949ca43 --- /dev/null +++ b/TSCP/src/APP/ciapp/WashMachine/WashMachineConfigDataManage.h @@ -0,0 +1,310 @@ +/******************************************************** +* +* WashMachineConfigDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-24 +* ߣ +* ȫԶϴݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _WASHMACHINE_CONFIG_DATA_MANAGE_H_ +#define _WASHMACHINE_CONFIG_DATA_MANAGE_H_ + + +#include "WashMachineDefine.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ϴݽṹ*/ +typedef struct S_WashMachineConfigDataStruct +{ + UINT16 WashMachineId; /*ϴID (ֶ)*/ + UINT8 BelongCiId; /*ID*/ + UINT8 BelongVirCiId; /*ID*/ + UINT16 WashMachineReadyRelayId; /*ϴ̵(ֶ:ɼ̵)*/ + UINT16 WashMachineRequestVerifyRelayId; /*ϴȷϼ̵ID (ֶ:ɼ̵)*/ + UINT16 TrainEmergencyStopRelayId; /*г̵ͣ(ֶ:ɼ̵)*/ + UINT16 HeadWashAllowRelayId; /*ͷϴ̵(ֶ:ɼ̵)*/ + UINT16 TailWashAllowRelayId; /*βϴ̵(ֶ:ɼ̵)*/ + UINT16 WashTrainRequestRelayId; /*ϴ̵(ֶ:̵)Ϸϴ̵ͬ*/ + UINT16 TrainHeadStopSteadyRelayId; /*ͷͣȼ̵(ֶ:̵)*/ + UINT16 TrainTailStopSteadyRelayId; /*βͣȼ̵(ֶ:̵)*/ + UINT16 TrainPassRequestRelayId; /*̵ͨ(ֶ:̵)*/ + UINT16 TrainOutWashPortAllowRelayId; /*г̵(ֶ:ɼ̵)*/ + UINT16 PauseTrainWashRequestRelayId; /*ͣϴ̵(ֶ:̵)*/ + UINT16 WashModeBackRelayId; /*ȫԶϴģʽ̵(ֶ:ɼ̵)*/ + UINT16 WashModeRelayId; /*ȫԶԶϴģʽ̵ֶ:̵)*/ + UINT16 wDownWashAllowRelayId; /*ģʽϴͬⰴť̵ID(ֶ:ɼ̵)*/ + UINT16 wDownWashAllowLightRelayId; /*ģʽϴָͬʾƼ̵IDֶ:̵)*/ + UINT16 wDownWashAllowPassRelayId; /*ģʽϴͬͨť̵ID(ֶ:ɼ̵)*/ + UINT16 wDownWashRelateRoute1Id; /*ģʽϴ߿̨ʾ1·ID*/ + UINT8 wDownWashRelateRoute1CheckType; /*ģʽϴ߿̨ʾ1·״̬*/ + UINT16 wDownWashRelRoute1LightRelayId; /*ģʽϴ߿̨ʾ1̵IDֶ:̵)*/ + UINT16 wDownWashRelateRoute2Id; /*ģʽϴ߿̨ʾ2·ID*/ + UINT8 wDownWashRelateRoute2CheckType; /*ģʽϴ߿̨ʾ2·״̬*/ + UINT16 wDownWashRelRoute2LightRelayId; /*ģʽϴ߿̨ʾ2̵IDֶ:̵)*/ +} WashMachineConfigDataStruct; + + +/*******************************ȫֱ*******************************/ +extern WashMachineConfigDataStruct WashMachineConfigDataStru[WASHMACHINE_SUM_MAX]; /*ϴýṹ,cgh-ϲCID-2539-1˴гʼͳһŵInitAllStaticDataStrнгʼΪں˹*/ +extern UINT16 LocalCiWashMachineIdBuf[WASHMACHINE_SUM_MAX]; /*屾ϴӳ*/ +extern UINT16 WashMachineCurSum; /*ϴǰ*/ +/* +* ȡϴǰ +* ˵ void +* ֵ 0: ȡʧ +* >0: ϴǰ +*/ +UINT16 GetWashMachineSum(void); + +/* +* ȡָ±ӦϴID +* ˵ const UINT16 bufIndex, ± +* ֵ 0: ȡʧ +* >0: ϴID +*/ +UINT16 GetWashMachineId(const UINT16 bufIndex); + +/* +* ȡָIDϴ +* ˵ const UINT16 washMachineId, ϴID +* ֵ SWITCH_SUM_MAX: ȡʧ +* 0: ID +*/ +UINT8 GetWashMachineBelongCiId(const UINT16 washMachineId); + +/* +* ȡָIDϴ̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ̵ID +*/ +UINT16 GetWashMachineReadyRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴȷϼ̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ȷϼ̵ID +*/ +UINT16 GetWashMachineReqVerifyRelayId(const UINT16 washMachineId); + + + +/* +* ȡָIDϴг̵ͣ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: г̵ͣ +*/ +UINT16 GetTrainEmergencyStopRelayId(const UINT16 washMachineId); + + +/* +* ȡָIDϴͷϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͷϴ̵ +*/ +UINT16 GetHeadWashAllowRelayId(const UINT16 washMachineId); + + +/* +* ȡָIDϴβϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: βϴ̵ +*/ +UINT16 GetTailWashAllowRelayId(const UINT16 washMachineId); + + +/* +* ȡָIDϴϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ̵ +*/ +UINT16 GetTrainOutWashPortAllowRelay(const UINT16 washMachineId); + + +/* +* ȡָIDϴϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ̵ +*/ +UINT16 GetWashTrainRequestRelayId(const UINT16 washMachineId); + + +/* +* ȡָIDϴͷͣȼ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͷͣȼ̵ +*/ +UINT16 GetTrainHeadStopSteadyRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴβͣȼ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: βͣȼ̵ +*/ +UINT16 GetTrainTailStopSteadyRelayId(const UINT16 washMachineId); + +/* +* ϴ +* ˵ +* ֵ CI_SUCCESS,ɹ +* CI_ERROR,ʧ +*/ +UINT8 WashMachineConfigDataManage(void); + +/* +* ȡָIDϴͣϴ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͣϴ̵ID +*/ +UINT16 GetPauseTrainWashRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴ̵ͨ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ̵ͨ +*/ +UINT16 GetPassRequestRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ID +*/ +UINT8 GetWashMachineBelongVirCiId(const UINT16 washMachineId); + +/* +* ȡָIDϴϴģʽ̵ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴģʽ̵ +* by cgh 20231109 +*/ +UINT16 GetWashModeBackRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴϴģʽ̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ȫԶԶϴģʽ̵ +* by cgh 20231109 +*/ +UINT16 GetWashModeRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴͬⰴť̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴͬⰴť̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashAllowRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴָͬʾƼ̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴָͬʾƼ̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashAllowLightRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴͬͨť̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴͬͨť̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashAllowPassRelayId(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴ߿̨ʾ1·ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ1·ID +* by cgh 20231109 +*/ +UINT16 GetDownWashRelateRoute1Id(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴ߿̨ʾ1·״̬ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ1·״̬ +* by cgh 20231109 +*/ +UINT8 GetDownWashRelRoute1CheckType(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴ߿̨ʾ1̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ1̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashRelRoute1LightRelay(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴ߿̨ʾ2·ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ2·ID +* by cgh 20231109 +*/ +UINT16 GetDownWashRelateRoute2Id(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴ߿̨ʾ2·״̬ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ2·״̬ +* by cgh 20231109 +*/ +UINT8 GetDownWashRelRoute2CheckType(const UINT16 washMachineId); + +/* +* ȡָIDϴģʽϴ߿̨ʾ2̵ID +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴ߿̨ʾ2̵ID +* by cgh 20231109 +*/ +UINT16 GetDownWashRelRoute2LightRelay(const UINT16 washMachineId); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/WashMachine/WashMachineDataManage.c b/TSCP/src/APP/ciapp/WashMachine/WashMachineDataManage.c new file mode 100644 index 0000000..0285f59 --- /dev/null +++ b/TSCP/src/APP/ciapp/WashMachine/WashMachineDataManage.c @@ -0,0 +1,1334 @@ +/******************************************************** +* +* WashMachineDataManage.c +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-24 +* ߣ +* ϴݹ +* ޸ļ¼ +* +********************************************************/ + +#include "WashMachineDataManage.h" + + + +WashMachineDataStruct WashMachineDataStru[WASHMACHINE_SUM_MAX]; /*ϴݽṹ*/ + + +/* +* ȡָIDϴ +* ˵ +* ֵ WashMachineDataStruct * +*/ +WashMachineDataStruct *GetWashMachineData(void) +{ + return WashMachineDataStru; +} + +/* +* ȡָIDϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ״̬ +*/ +UINT8 GetWashMachineReadyState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashMachineReadyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} +/* +* ָIDϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetWashMachineReadyState(const UINT16 WashMachineId,const UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_COL_READY_YES == state) || (WASHMACHINE_COL_READY_NO == state)) + { + WashMachineDataStru[bufIndex].WashMachineReadyState = state; /*ϴ״̬*/ + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴȷ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ȷ״̬ +*/ +UINT8 GetWashMachineRequestVerifySta(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashMachineRequestVerifyState; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} +/* +* ָIDϴȷ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetWashMachineRequestVerifySta(const UINT16 WashMachineId,const UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_COL_REQUEST_VALID == state) || (WASHMACHINE_COL_REQUEST_INVALID == state)) + { + WashMachineDataStru[bufIndex].WashMachineRequestVerifyState = state; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ȡָIDϴгͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: гͣ״̬ +*/ +UINT8 GetTrainEmergencyStopState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].TrainEmergencyStopState; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} +/* +* ָIDϴгͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetTrainEmergencyStopState(const UINT16 WashMachineId,const UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + UINT8 lineIdentity = 0u; /*CI-VOBCӿڱʶ*/ + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡCI-VOBCӿڱʶ*/ + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if (LINE_FAO == lineIdentity) + {/*FAO·*/ + if ((WASHMACHINE_COL_FALUT_YES == state) || (WASHMACHINE_COL_FALUT_NO == state)) + { + WashMachineDataStru[bufIndex].TrainEmergencyStopState = state; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) + || (LINE_CC == lineIdentity)) + {/*FAO+HLHT·*/ + if ((WASHMACHINE_COL_FALUT_YES_2 == state) || (WASHMACHINE_COL_FALUT_NO_2 == state)) + { + WashMachineDataStru[bufIndex].TrainEmergencyStopState = state; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDϴͷϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͷϴ״̬ +*/ +UINT8 GetHeadWashAllowState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].HeadWashAllowState; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} +/* +* ָIDϴͷϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetHeadWashAllowState(const UINT16 WashMachineId,const UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_COL_HEADWASH_YES== state) || (WASHMACHINE_COL_HEADWASH_NO == state)) + { + WashMachineDataStru[bufIndex].HeadWashAllowState = state; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴβϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: βϴ״̬ +*/ +UINT8 GetTailWashAllowState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].TailWashAllowState; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} +/* +* ָIDϴβϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetTailWashAllowState(const UINT16 WashMachineId,const UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_COL_TAILWASH_YES== state) || (WASHMACHINE_COL_TAILWASH_NO == state)) + { + WashMachineDataStru[bufIndex].TailWashAllowState = state; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDϴϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ״̬ +*/ +UINT8 GetTrainOutWashPortAllowSta(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].TrainOutWashTrainPortAllowState; + } + else + { + retVal = CI_ERROR; + } + return retVal; + +} + +/* +* ָIDϴϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetTrainOutWashPortAllowSta(const UINT16 WashMachineId,const UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + UINT8 lineIdentity = 0u; /*CI-VOBCӿڱʶ*/ + + lineIdentity = GetCiFunctionSwitchConfig(VOBC_INTERFACE_IDENTITY);/*ȡCI-VOBCӿڱʶ*/ + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if (LINE_FAO == lineIdentity) + {/*FAO·*/ + if ((WASHMACHINE_COL_OUT_YES== state) || (WASHMACHINE_COL_OUT_NO == state)) + { + WashMachineDataStru[bufIndex].TrainOutWashTrainPortAllowState = state; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else if ((LINE_FAOHLHT == lineIdentity) || (LINE_FAOHLHT_ONESELF == lineIdentity) || (LINE_FAOHLHT_ONESELFSECOND == lineIdentity) + || (LINE_CC == lineIdentity)) + {/*FAO+HLHT·*/ + if ((WASHMACHINE_COL_OUT_YES_2== state) || (WASHMACHINE_COL_OUT_NO_2 == state)) + { + WashMachineDataStru[bufIndex].TrainOutWashTrainPortAllowState = state; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDϴϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ״̬ +*/ +UINT8 GetWashTrainRequestDrvState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashTrainRequestDrvState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָIDϴϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +* +*/ +void SetWashTrainRequestDrvState(const UINT16 WashMachineId, const UINT8 drvState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_DRVSTATE_REQ_FALSE == drvState) || (WASHMACHINE_DRVSTATE_REQ_TRUE == drvState)) + { + WashMachineDataStru[bufIndex].WashTrainRequestDrvState = drvState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDϴͷͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͷͣ״̬ +*/ +UINT8 GetTrainHeadStopSteadyDrvState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].TrainHeadStopSteadyDrvState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָIDϴͷͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +* +*/ +void SetTrainHeadStopSteadyDrvState(const UINT16 WashMachineId, const UINT8 drvState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_HEAD_STEADY_YES == drvState) || (WASHMACHINE_HEAD_STEADY_NO == drvState)) + { + WashMachineDataStru[bufIndex].TrainHeadStopSteadyDrvState = drvState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDϴβͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: βͣ״̬ +*/ +UINT8 GetTrainTailStopSteadyDrvState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].TrainTailStopSteadyDrvState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָIDϴβͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +* +*/ +void SetTrainTailStopSteadyDrvState(const UINT16 WashMachineId, const UINT8 drvState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_TAIL_STEADY_YES == drvState) || (WASHMACHINE_TAIL_STEADY_NO == drvState)) + { + WashMachineDataStru[bufIndex].TrainTailStopSteadyDrvState = drvState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDϴĵǰϴVOBC ID +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ǰϴVOBC IDЧ +* >0: ǰϴVOBC IDЧ +*/ +UINT16 GetWashMachineCurVobcID(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT16 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].CurVobcId; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDϴĵǰϴVOBC ID +* ˵ const UINT16 WashMachineId, ϴID +* const UINT16 curVobcIdǰϴVOBC ID +* ֵ +* +*/ +void SetWashMachineCurVobcID(const UINT16 WashMachineId,const UINT16 curVobcId) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + WashMachineDataStru[bufIndex].CurVobcId = curVobcId; + } + else + { + /**/ + } +} + +#if 0 +/* +* ָIDϴгͣ״̬-ͨ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetTrainEmergencyStopStateHLHT(const UINT16 WashMachineId,const UINT8 state) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_COL_FALUT_NO_2 == state) || (WASHMACHINE_COL_FALUT_YES_2 == state)) + { + WashMachineDataStru[bufIndex].TrainEmergencyStopState = state; + + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +#endif + +/* +* ȡָIDϴͣϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͣϴ״̬ +*/ +UINT8 GetPauseTrainWashRequestDrvSta(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].PauseTrainWashRequestDrvState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDϴͣϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ void +*/ +void SetPauseTrainWashRequestDrvSta(const UINT16 WashMachineId, const UINT8 drvState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_PAUSE_DRVREQ_TRUE == drvState) || (WASHMACHINE_PAUSE_DRVREQ_FALSE == drvState)) + { + WashMachineDataStru[bufIndex].PauseTrainWashRequestDrvState = drvState; + } + else + { + ; /**/ + } + } + else + { + ; /**/ + } +} + +/* +* ȡָIDͨϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͨϴ״̬ +*/ +UINT8 GetPassWashMachineReqDrvSta(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = 0u; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].PaseWashMachineRequesDrvtState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDͨϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +* +*/ +void SetPassWashMachineReqtDrvSta(const UINT16 WashMachineId, const UINT8 drvState) +{ + UINT16 bufIndex = 0u; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((PASS_WASHMACHINE_DRVREQ_TRUE == drvState) || (PASS_WASHMACHINE_DRVREQ_FALSE == drvState)) + { + WashMachineDataStru[bufIndex].PaseWashMachineRequesDrvtState = drvState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ָIDϴģʽ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +*by cgh 20231108 +*/ +void SetWashMachineWorkModeDrvState(const UINT16 WashMachineId, const UINT8 drvState) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASHMACHINE_WORKMODE_INVALID_DRV == drvState) + || (WASHMACHINE_WORKMODE_ALL_DRV == drvState) + || (WASHMACHINE_WORKMODE_SIDE_DRV == drvState) + || (WASHMACHINE_WORKMODE_DEFAULT_DRV == drvState)) + { + WashMachineDataStru[bufIndex].WashMachineWorkModeDrvtState = drvState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDϴϴģʽ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0XFF: ȡʧ +* 0x01\0x02\0x00: ϴģʽ״̬ +* by cgh 20231108 +*/ +UINT8 GetWashMachineWorkModeDrvState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashMachineWorkModeDrvtState; + } + else + { + retVal = WASHMACHINE_WORKMODE_INVALID_DRV; + } + return retVal; +} + +/* +* ָIDϴģʽ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 chBackState, ״̬ +* ֵ +*by cgh 20231108 +*/ +void SetWashWorkModeBackState(const UINT16 WashMachineId, const UINT8 chBackState) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASH_WORKMODE_BACK_ALL_OK == chBackState) + || (WASH_WORKMODE_BACK_SIDE_OK == chBackState) + || (WASH_WORKMODE_BACK_ALL_NO == chBackState) + || (WASH_WORKMODE_BACK_SIDE_NO == chBackState) + || (WASH_WORKMODE_BACK_DEFAULT == chBackState)) + { + WashMachineDataStru[bufIndex].chSetWashWorkModeBack = chBackState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDϴϴģʽ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴģʽ״̬ +* by cgh 20231108 +*/ +UINT8 GetWashWorkModeBackState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].chSetWashWorkModeBack; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDϴģʽϴͬ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 chDownWashAllowState, ģʽϴͬ״̬ +* ֵ +*by cgh 20231113 +*/ +void SetDownWashAllowState(const UINT16 WashMachineId, const UINT8 chDownWashAllowState) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASH_COL_STATE_ALLOW_YES == chDownWashAllowState) + || (WASH_COL_STATE_ALLOW_NO == chDownWashAllowState)) + { + WashMachineDataStru[bufIndex].chDownWashAllowState = chDownWashAllowState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDϴģʽϴͬ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴͬ״̬ +* by cgh 20231108 +*/ +UINT8 GetDownWashAllowState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].chDownWashAllowState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDϴģʽϴͬͨ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 chBackState, ģʽϴͬͨ״̬ +* ֵ +*by cgh 20231113 +*/ +void SetDownWashAllowPassState(const UINT16 WashMachineId, const UINT8 chDownWashAllowPassState) +{ + UINT16 bufIndex = 0U; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((WASH_COL_STATE_ALLOW_PASS_YES == chDownWashAllowPassState) + || (WASH_COL_STATE_ALLOW_PASS_NO == chDownWashAllowPassState)) + { + WashMachineDataStru[bufIndex].chDownWashAllowPassState = chDownWashAllowPassState; + } + else + { + /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDϴģʽϴͬͨ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴͬͨ״̬ +* by cgh 20231108 +*/ +UINT8 GetDownWashAllowPassState(const UINT16 WashMachineId) +{ + UINT16 bufIndex = 0U; /*±*/ + UINT8 retVal = 0U; + + bufIndex = GetWashMachineIdConfigBufIndex(WashMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].chDownWashAllowPassState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/*********************************************************************************************************/ + + +/* +* ȡָIDϴϴͬⰴťǰ״̬ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 GetWashmachineXTACurState(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashmachineXTACurState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָIDϴϴͬⰴťǰ״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetWashmachineXTACurState(const UINT16 washMachineId, const UINT8 xtaState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((XTA_STATE_RAISE_UP == xtaState) || (XTA_STATE_PRESS_DOWN == xtaState)) + { + WashMachineDataStru[bufIndex].WashmachineXTACurState = xtaState; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴϴͬⰴť֮ǰ״̬ +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 GetWashmachineXTAPreState(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashmachineXTAPreState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָIDϴϴͬⰴť֮ǰ״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetWashmachineXTAPreState(const UINT16 washMachineId, const UINT8 xtaState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((XTA_STATE_RAISE_UP == xtaState) || (XTA_STATE_PRESS_DOWN == xtaState)) + { + WashMachineDataStru[bufIndex].WashmachineXTAPreState = xtaState; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ȡָIDϴϴͬⰴť߼״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 GetWashmachineXTALogicState(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashmachineXTALogicState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָIDϴϴͬⰴť߼״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetWashmachineXTALogicState(const UINT16 washMachineId, const UINT8 xtaState) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((XTA_STATE_RAISE_UP == xtaState) || (XTA_STATE_PRESS_DOWN == xtaState)) + { + WashMachineDataStru[bufIndex].WashmachineXTALogicState = xtaState; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ָIDϴϴͬⰴťʼں +* ˵ const UINT16 washMachineId, ϴID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetWashMachineXTAPressDownCyc(const UINT16 washMachineId, const UINT32 startCycNum) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + WashMachineDataStru[bufIndex].WashmachineXTAPressDownCycle = startCycNum; + retVal = CI_SUCCESS; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ȡָIDϴϴͬⰴťʼں +* ˵ const UINT16 doorIdϴID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetWashMachineXTAPressDownCyc(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0u; /*±*/ + UINT32 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashmachineXTAPressDownCycle; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} +/* +* ָIDϴϴģʽ߼״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 modeState, ϴģʽ״̬ +* cgh-ϲCID-3037-9 +* +*/ +void SetWashModeState(const UINT16 washMachineId, const UINT8 modeState) +{ + UINT16 bufIndex = 0; /*±*/ + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + if ((XTA_MODE_STATE_DOWN == modeState) + || (XTA_MODE_STATE_UP == modeState) + || (XTA_MODE_STATE_NO == modeState)) + { + WashMachineDataStru[bufIndex].WashModeState = modeState; + } + else + { + ; /**/ + } + } + else + { + /**/ + } +} + +/* +* ȡָIDϴϴģʽ߼״̬ +* ˵ const UINT16 washMachineId, ϴID +* +* ֵ 0: ȡʧ +* >0: ϴģʽ +* cgh-ϲCID-3037-9 +*/ +UINT8 GetWashModeState(const UINT16 washMachineId) +{ + UINT16 bufIndex = 0; /*±*/ + UINT8 retVal = CI_ERROR; + + bufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (bufIndex < WASHMACHINE_SUM_MAX) + { + retVal = WashMachineDataStru[bufIndex].WashModeState; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + +/* +* ȡָIDϴϴģʽ̵ʼں +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ʼں +* by cgh 20231208 +*/ +UINT32 GetWashWorkModeRelayDrvCycle(const UINT16 washMachineId) +{ + UINT32 retVal = CI_ERROR; + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (WASHMACHINE_SUM_MAX > wBufIndex) + { + retVal = WashMachineDataStru[wBufIndex].WashWorkModeRelayDrvCycle; + } + else + { + retVal = CI_ERROR; + } + return retVal; +} + + +/* +* ָIDϴϴģʽ̵ʼں +* ˵ const UINT16 washMachineId, ϴID +* const UINT32 CycNum, ̵ʼں +* ֵ +*by cgh 20231208 +*/ +void SetWashWorkModeRelayDrvCycle(const UINT16 washMachineId, const UINT32 CycNum) +{ + UINT16 wBufIndex = 0U; /*±*/ + + wBufIndex = GetWashMachineIdConfigBufIndex(washMachineId); /*ȡϴ±*/ + + if (WASHMACHINE_SUM_MAX > wBufIndex) + { + /*ָָIDϴϴģʽ̵ʼں*/ + WashMachineDataStru[wBufIndex].WashWorkModeRelayDrvCycle = CycNum; + } + else + { + /**/ + } +} + diff --git a/TSCP/src/APP/ciapp/WashMachine/WashMachineDataManage.h b/TSCP/src/APP/ciapp/WashMachine/WashMachineDataManage.h new file mode 100644 index 0000000..edc0fd4 --- /dev/null +++ b/TSCP/src/APP/ciapp/WashMachine/WashMachineDataManage.h @@ -0,0 +1,459 @@ +/******************************************************** +* +* WashMachineDataManage.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-24 +* ߣ +* ϴݹͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _WASHMACHINE_DATA_MANAGE_H_ +#define _WASHMACHINE_DATA_MANAGE_H_ + + +#include "WashMachineDefine.h" +#include "WashMachineConfigDataManage.h" +#include "CommonTypes.h" +#include "../System/CiSystemDefine.h" +#include "../System/SystemParameterManage.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*ϴݽṹ*/ +typedef struct S_WashMachineDataStruct +{ + UINT16 CurVobcId; /*ǰϴVOBC IDֶ̬Σ*/ + UINT16 WashMachineId; /*ϴID (ʼֶ)*/ + UINT8 WashMachineReadyState; /*ϴ״̬(ֶ̬:ɼ)ϴͬ־Ϸʸݰ³ʱ*/ + UINT8 WashMachineRequestVerifyState; /*ϴȷ״̬(ֶ̬:ɼ)*/ + UINT8 TrainEmergencyStopState; /*гͣ״̬(ֶ̬:ɼ)*/ + UINT8 HeadWashAllowState; /*ͷϴ״̬(ֶ̬:ɼ)*/ + UINT8 TailWashAllowState; /*βϴ״̬(ֶ̬:ɼ)*/ + UINT8 WashTrainRequestDrvState; /*ϴ״̬(ֶ̬:)*/ + UINT8 TrainHeadStopSteadyDrvState; /*ͷͣ״̬(ֶ̬:)*/ + UINT8 TrainTailStopSteadyDrvState; /*βͣ״̬(ֶ̬:)*/ + UINT8 TrainOutWashTrainPortAllowState; /*ϴ״̬(ֶ̬:ɼ)*/ + UINT8 PauseTrainWashRequestDrvState; /*ͣϴ״̬(ֶ̬:)*/ + UINT8 PaseWashMachineRequesDrvtState; /*ͨϴ״̬(ֶ̬:)*/ + UINT8 WashMachineWorkModeDrvtState; /*ϴģʽ״̬(ֶ̬:)*/ + UINT32 WashWorkModeRelayDrvCycle; /*ϴģʽ̵ʼں*/ + UINT8 WashmachineXTACurState; /*ϴͬⰴťǰ״̬ϴͬⰴť̵Ϊť££0xaa ̧0x55*/ + UINT8 WashmachineXTAPreState; /*ϴͬⰴť״̬£0xaa ̧0x55*/ + UINT8 WashmachineXTALogicState; /*ϴť߼״̬ £0xaa ̧0x55ֵֻͬظ£ͬһؽһ½߼״̬Ϊͬʱ*/ + UINT32 WashmachineXTAPressDownCycle;/*أϴϴͬⰴťʼڣǰ£̧𣬸[],ֻаť߼״̬Ϊͬʱżʱ*/ + UINT8 WashModeState; /*ϴģʽ(ֶ̬:ɼ)*/ + UINT8 chSetWashWorkModeBack; /*ϴģʽ(ֶ̬:ɼ)*/ + UINT8 chDownWashAllowState; /*ģʽϴͬ״̬(ֶ̬:ɼ)*/ + UINT8 chDownWashAllowPassState; /*ģʽϴͬͨ״̬(ֶ̬:ɼ)*/ +} WashMachineDataStruct; + + +extern WashMachineDataStruct WashMachineDataStru[WASHMACHINE_SUM_MAX]; /*ϴݽṹ*/ +/* +* ȡָIDϴ +* ˵ +* ֵ WashMachineDataStruct * +*/ +WashMachineDataStruct *GetWashMachineData(void); + +/* +* ȡָIDϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ״̬ +*/ +UINT8 GetWashMachineReadyState(const UINT16 WashMachineId); + +/* +* ָIDϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetWashMachineReadyState(const UINT16 WashMachineId,const UINT8 state); + + + + +/* +* ȡָIDϴȷ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ȷ״̬ +*/ +UINT8 GetWashMachineRequestVerifySta(const UINT16 WashMachineId); + +/* +* ָIDϴȷ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetWashMachineRequestVerifySta(const UINT16 WashMachineId,const UINT8 state); + + + +/* +* ȡָIDϴгͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: гͣ״̬ +*/ +UINT8 GetTrainEmergencyStopState(const UINT16 WashMachineId); +/* +* ָIDϴгͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetTrainEmergencyStopState(const UINT16 WashMachineId,const UINT8 state); + + + +/* +* ȡָIDϴͷϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͷϴ״̬ +*/ +UINT8 GetHeadWashAllowState(const UINT16 WashMachineId); +/* +* ָIDϴͷϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetHeadWashAllowState(const UINT16 WashMachineId,const UINT8 state); + + + +/* +* ȡָIDϴβϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: βϴ״̬ +*/ +UINT8 GetTailWashAllowState(const UINT16 WashMachineId); +/* +* ָIDϴβϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetTailWashAllowState(const UINT16 WashMachineId,const UINT8 state); + +/* +* ȡָIDϴϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ״̬ +*/ +UINT8 GetTrainOutWashPortAllowSta(const UINT16 WashMachineId); +/* +* ָIDϴϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID + const UINT8 state,״̬ +* ֵ 0: ʧ +* 1: óɹ +*/ +UINT8 SetTrainOutWashPortAllowSta(const UINT16 WashMachineId,const UINT8 state); + + + + +/* +* ȡָIDϴϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴ״̬ +*/ +UINT8 GetWashTrainRequestDrvState(const UINT16 WashMachineId); +/* +* ָIDϴϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +* +*/ +void SetWashTrainRequestDrvState(const UINT16 WashMachineId, const UINT8 drvState); + + + +/* +* ȡָIDϴͷͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͷͣ״̬ +*/ +UINT8 GetTrainHeadStopSteadyDrvState(const UINT16 WashMachineId); +/* +* ָIDϴͷͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +* +*/ +void SetTrainHeadStopSteadyDrvState(const UINT16 WashMachineId, const UINT8 drvState); + +/* +* ȡָIDϴβͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: βͣ״̬ +*/ +UINT8 GetTrainTailStopSteadyDrvState(const UINT16 WashMachineId); +/* +* ָIDϴβͣ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +* +*/ +void SetTrainTailStopSteadyDrvState(const UINT16 WashMachineId, const UINT8 drvState); + +/* +* ȡָIDϴĵǰϴVOBC ID +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ǰϴVOBC ID +*/ +UINT16 GetWashMachineCurVobcID(const UINT16 WashMachineId); + +/* +* ָIDϴĵǰϴVOBC ID +* ˵ const UINT16 WashMachineId, ϴID +* const UINT16 curVobcIdǰϴVOBC ID +* ֵ +* +*/ +void SetWashMachineCurVobcID(const UINT16 WashMachineId,const UINT16 curVobcId); + +/* +* ȡָIDϴͣϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͣϴ״̬ +*/ +UINT8 GetPauseTrainWashRequestDrvSta(const UINT16 WashMachineId); + +/* +* ָIDϴͣϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ void +*/ +void SetPauseTrainWashRequestDrvSta(const UINT16 WashMachineId, const UINT8 drvState); + +/* +* ȡָIDͨϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ͨϴ״̬ +*/ +UINT8 GetPassWashMachineReqDrvSta(const UINT16 WashMachineId); + +/* +* ָIDͨϴ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +* +*/ +void SetPassWashMachineReqtDrvSta(const UINT16 WashMachineId, const UINT8 drvState); + +/* +* ָIDϴģʽ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 drvState, ״̬ +* ֵ +*by cgh 20231108 +*/ +void SetWashMachineWorkModeDrvState(const UINT16 WashMachineId, const UINT8 drvState); + +/* +* ȡָIDϴϴģʽ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0XFF: ȡʧ +* 0x01\0x02\0x00: ϴģʽ״̬ +* by cgh 20231108 +*/ +UINT8 GetWashMachineWorkModeDrvState(const UINT16 WashMachineId); + +/* +* ָIDϴģʽ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 chBackState, ״̬ +* ֵ +*by cgh 20231108 +*/ +void SetWashWorkModeBackState(const UINT16 WashMachineId, const UINT8 chBackState); + +/* +* ȡָIDϴϴģʽ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ϴģʽ״̬ +* by cgh 20231108 +*/ +UINT8 GetWashWorkModeBackState(const UINT16 WashMachineId); + +/* +* ָIDϴģʽϴͬ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 chDownWashAllowState, ģʽϴͬ״̬ +* ֵ +*by cgh 20231113 +*/ +void SetDownWashAllowState(const UINT16 WashMachineId, const UINT8 chDownWashAllowState); + +/* +* ȡָIDϴģʽϴͬ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴͬ״̬ +* by cgh 20231108 +*/ +UINT8 GetDownWashAllowState(const UINT16 WashMachineId); + +/* +* ָIDϴģʽϴͬͨ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* const UINT8 chBackState, ģʽϴͬͨ״̬ +* ֵ +*by cgh 20231113 +*/ +void SetDownWashAllowPassState(const UINT16 WashMachineId, const UINT8 chDownWashAllowPassState); + +/* +* ȡָIDϴģʽϴͬͨ״̬ +* ˵ const UINT16 WashMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ģʽϴͬͨ״̬ +* by cgh 20231108 +*/ +UINT8 GetDownWashAllowPassState(const UINT16 WashMachineId); + + +/************************************************************************************************/ + +/* +* ȡָIDϴϴͬⰴťǰ״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 GetWashmachineXTACurState(const UINT16 washMachineId); +/* +* ָIDϴϴͬⰴťǰ״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetWashmachineXTACurState(const UINT16 washMachineId, const UINT8 xtaState); + +/* +* ȡָIDϴϴͬⰴť֮ǰ״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 GetWashmachineXTAPreState(const UINT16 washMachineId); +/* +* ָIDϴϴͬⰴť֮ǰ״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetWashmachineXTAPreState(const UINT16 washMachineId, const UINT8 xtaState); + + +/* +* ȡָIDϴϴͬⰴť߼״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 GetWashmachineXTALogicState(const UINT16 washMachineId); +/* +* ָIDϴϴͬⰴť߼״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 xtaState, ϴͬⰴť״̬ +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetWashmachineXTALogicState(const UINT16 washMachineId, const UINT8 xtaState); + +/* +* ָIDϴϴͬⰴťʼں +* ˵ const UINT16 washMachineId, ϴID +* const UINT32 startCycNum, ʼں +* ֵ 0: ʧ +* >0: ݳɹ +*/ +UINT8 SetWashMachineXTAPressDownCyc(const UINT16 washMachineId, const UINT32 startCycNum); +/* +* ȡָIDϴϴͬⰴťʼں +* ˵ const UINT16 doorIdϴID +* ֵ 0: ȡʧ +* >0: ʼں +*/ +UINT32 GetWashMachineXTAPressDownCyc(const UINT16 washMachineId); + +/* +* ָIDϴϴģʽ߼״̬ +* ˵ const UINT16 washMachineId, ϴID +* const UINT8 modeState, ϴģʽ״̬ +* cgh-ϲCID-3037-9 +* +*/ +void SetWashModeState(const UINT16 washMachineId, const UINT8 modeState); + +/* +* ȡָIDϴϴģʽ߼״̬ +* ˵ const UINT16 washMachineId, ϴID +* +* ֵ 0: ȡʧ +* >0: ϴģʽ +* cgh-ϲCID-3037-9 +*/ +UINT8 GetWashModeState(const UINT16 washMachineId); + +/* +* ȡָIDϴϴģʽ̵ʼں +* ˵ const UINT16 washMachineId, ϴID +* ֵ 0: ȡʧ +* >0: ʼں +* by cgh 20231208 +*/ +UINT32 GetWashWorkModeRelayDrvCycle(const UINT16 washMachineId); + +/* +* ָIDϴϴģʽ̵ʼں +* ˵ const UINT16 washMachineId, ϴID +* const UINT32 CycNum, ̵ʼں +* ֵ +*by cgh 20231208 +*/ +void SetWashWorkModeRelayDrvCycle(const UINT16 washMachineId, const UINT32 CycNum); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/APP/ciapp/WashMachine/WashMachineDefine.h b/TSCP/src/APP/ciapp/WashMachine/WashMachineDefine.h new file mode 100644 index 0000000..8142f4c --- /dev/null +++ b/TSCP/src/APP/ciapp/WashMachine/WashMachineDefine.h @@ -0,0 +1,112 @@ +/******************************************************** +* +* WashMachineConfigDefine.h +* Ȩ˵ ؿƼ޹˾ +* ʱ䣺 2014-12-24 +* ߣ +* ϴͷļ +* +* ʹע⣺ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _WASHMACHINE_DEFINE_H_ +#define _WASHMACHINE_DEFINE_H_ + + + + +#define WASHMACHINE_SUM_MAX ((UINT16)3) /*ϴֵ*/ + + +/*ϴ״̬*/ +#define WASHMACHINE_DRVSTATE_REQ_TRUE ((UINT8)0x55) /*ϴЧ״̬*/ +#define WASHMACHINE_DRVSTATE_REQ_FALSE ((UINT8)0xaa) /*ϴЧ״̬*/ + +#define WASHMACHINE_HEAD_STEADY_YES ((UINT8)0x55) /*ͷͣ״̬*/ +#define WASHMACHINE_HEAD_STEADY_NO ((UINT8)0xaa) /*ͷδͣ״̬*/ + +#define WASHMACHINE_TAIL_STEADY_YES ((UINT8)0x55) /*βͣ״̬*/ +#define WASHMACHINE_TAIL_STEADY_NO ((UINT8)0xaa) /*βδͣ״̬*/ + +#define WASHMACHINE_PAUSE_DRVREQ_TRUE ((UINT8)0x55) /*ͣϴЧ״̬*/ +#define WASHMACHINE_PAUSE_DRVREQ_FALSE ((UINT8)0xaa) /*ͣϴЧ״̬*/ + +#define PASS_WASHMACHINE_DRVREQ_TRUE ((UINT8)0x55) /*ͨϴЧ״̬*/ +#define PASS_WASHMACHINE_DRVREQ_FALSE ((UINT8)0xaa) /*ͨϴЧ״̬*/ + +#define WASHMACHINE_WORKMODE_ALL_DRV ((UINT8)0x01) /*ϴϴģʽȫϴ״̬*/ +#define WASHMACHINE_WORKMODE_SIDE_DRV ((UINT8)0x02) /*ϴϴģʽϴ״̬*/ +#define WASHMACHINE_WORKMODE_DEFAULT_DRV ((UINT8)0x00) /*ϴϴģʽĬ״̬*/ +#define WASHMACHINE_WORKMODE_INVALID_DRV ((UINT8)0xFF) /*ϴϴģʽЧ״̬*/ + + +/*ϴزɼ״̬*/ +#define WASHMACHINE_COL_REQUEST_VALID ((UINT8)0x55) /*ϴ*/ +#define WASHMACHINE_COL_REQUEST_INVALID ((UINT8)0xaa) /*ϴ*/ + +#define WASHMACHINE_COL_HEADWASH_YES ((UINT8)0x55) /*ͷϴ*/ +#define WASHMACHINE_COL_HEADWASH_NO ((UINT8)0xaa) /*ͷϴ*/ + +#define WASHMACHINE_COL_TAILWASH_YES ((UINT8)0x55) /*βϴ*/ +#define WASHMACHINE_COL_TAILWASH_NO ((UINT8)0xaa) /*βϴ*/ + +#define WASHMACHINE_COL_FALUT_YES ((UINT8)0x55) /*ϴ*/ +#define WASHMACHINE_COL_FALUT_NO ((UINT8)0xaa) /*ϴδ*/ + +#define WASHMACHINE_COL_READY_YES ((UINT8)0x55) /**/ +#define WASHMACHINE_COL_READY_NO ((UINT8)0xaa) /*δ*/ + +#define WASHMACHINE_COL_OUT_YES ((UINT8)0xaa) /**/ +#define WASHMACHINE_COL_OUT_NO ((UINT8)0x55) /**/ + +#define WASHMACHINE_COL_FALUT_NO_2 ((UINT8)0x55) /*ϴ޹ϣ»CI-VOBCӿĵԼֵ*/ +#define WASHMACHINE_COL_FALUT_YES_2 ((UINT8)0xaa) /*ϴϣ»CI-VOBCӿĵԼֵ*/ + +#define WASHMACHINE_COL_OUT_YES_2 ((UINT8)0x55) /*ͨϴ»CI-VOBCӿĵԼֵ*/ +#define WASHMACHINE_COL_OUT_NO_2 ((UINT8)0xaa) /*ͨϴ»CI-VOBCӿĵԼֵ*/ + +/*ͨϴϢ*/ +#define PASS_WASHMACHINE_REQUEST_VALID ((UINT8)0x55) /*ͨϴϢЧ*/ +#define PASS_WASHMACHINE_REQUEST_INVALID ((UINT8)0xaa) /*ͨϴϢЧ*/ + +/*ͣϴ*/ +#define PAUSE_TRAIN_WASH_REQUEST_VALID ((UINT8)0x55) /*ͣϴЧ*/ +#define PAUSE_TRAIN_WASH_REQUEST_INVALID ((UINT8)0xaa) /*ͣϴЧ*/ + +/*ȡϴñ־*/ +#define CANCEL_WASH_FLAG_SET_YES ((UINT8)0x55) /*ȡϴ*/ +#define CANCEL_WASH_FLAG_SET_NO ((UINT8)0xaa) /*ȡϴδ*/ + +/*ϴͬⰴť״̬*/ +#define XTA_STATE_PRESS_DOWN ((UINT8)0xaa) /*ϴͬⰴť*/ +#define XTA_STATE_RAISE_UP ((UINT8)0x55) /*ϴͬⰴţ̌*/ + +/*ϴģʽ*/ +#define XTA_MODE_STATE_DOWN (UINT8)0x01 /*ϴģʽͨϴ*/ +#define XTA_MODE_STATE_UP (UINT8)0x02 /*ϴģʽϴ*/ +#define XTA_MODE_STATE_NO (UINT8)0xff /*ϴģʽĬֵ*/ + +/*ϴͬⰴť³Сʱ*/ +#define PRESSING_TIME_MIN ((INT32)3) + +/*ϴģʽ״̬*/ +#define WASH_WORKMODE_BACK_ALL_OK ((UINT8)0x01) /*ϴȫϴģʽɹ*/ +#define WASH_WORKMODE_BACK_SIDE_OK ((UINT8)0x02) /*ϴϴģʽɹ*/ +#define WASH_WORKMODE_BACK_ALL_NO ((UINT8)0x04) /*ϴȫϴģʽʧ*/ +#define WASH_WORKMODE_BACK_SIDE_NO ((UINT8)0x08) /*ϴϴģʽʧ*/ +#define WASH_WORKMODE_BACK_DEFAULT ((UINT8)0x00) /*Ĭֵ-޴˹ܻRCȴϴùģʽʱʱ*/ + +/*ģʽϴزɼ״̬*/ +#define WASH_COL_STATE_ALLOW_YES ((UINT8)0x55) /*ģʽϴͬ-*/ +#define WASH_COL_STATE_ALLOW_NO ((UINT8)0xaa) /*ģʽϴͬ-*/ + +#define WASH_COL_STATE_ALLOW_PASS_YES ((UINT8)0x55) /*ģʽϴͬͨ-*/ +#define WASH_COL_STATE_ALLOW_PASS_NO ((UINT8)0xaa) /*ģʽϴͬͨ-*/ + +/*ģʽϴ߿̨ʾƹ·״̬*/ +#define WASH_REL_ROUTE_OPEN_STATE ((UINT8)0x55) /*ϴ·״̬*/ +#define WASH_REL_ROUTE_LOCK_STATE ((UINT8)0xaa) /*ϴ·״̬*/ + +#endif diff --git a/TSCP/src/DRV/imx8_drv_gpio.c b/TSCP/src/DRV/imx8_drv_gpio.c new file mode 100644 index 0000000..43cfcd7 --- /dev/null +++ b/TSCP/src/DRV/imx8_drv_gpio.c @@ -0,0 +1,862 @@ + +#include "imx8_drv_gpio.h" + +static volatile uintptr_t gpio_base_0; +static volatile uintptr_t gpio_base_1; +static volatile uintptr_t gpio_base_2; +static volatile uintptr_t gpio_base_3; +static volatile uintptr_t gpio_base_4; +static volatile uintptr_t gpio_base_5; + +static uintptr_t tbase; +static volatile unsigned int cnt; +static int val; +static pthread_t timer_thread; +static struct sigevent event; +static intrspin_t spinner; + +char drv_vsr[4] = {93u, 8u, 0u, 9u}; + +/*GPIO init*/ +int imx8_gpio_init(void) +{ + + int ret = 0; + gpio_base_0 = mmap_device_io((size_t)0x10, (uint64_t)IMX_GPIO0_BASE); + if(gpio_base_0 == MAP_DEVICE_FAILED) + { + perror("Can't map device base 0 I/O"); + ret = -1; + } + else + { + + } + + gpio_base_1 = mmap_device_io((size_t)0x10, (uint64_t)IMX_GPIO1_BASE); + if(gpio_base_1 == MAP_DEVICE_FAILED) + { + perror("Can't map device base 1 I/O"); + ret = -1; + } + else + { + + } + + gpio_base_2 = mmap_device_io((size_t)0x10, (uint64_t)IMX_GPIO2_BASE); + if(gpio_base_2 == MAP_DEVICE_FAILED) + { + perror("Can't map device base 2 I/O"); + ret = -1; + } + else + { + + } + + gpio_base_3 = mmap_device_io((size_t)0x10, (uint64_t)IMX_GPIO3_BASE); + if(gpio_base_3 == MAP_DEVICE_FAILED) + { + perror("Can't map device base 3 I/O"); + ret = -1; + } + else + { + + } + + gpio_base_4 = mmap_device_io((size_t)0x10, (uint64_t)IMX_GPIO4_BASE); + if(gpio_base_4 == MAP_DEVICE_FAILED) + { + perror("Can't map device base 4 I/O"); + ret = -1; + } + else + { + + } + + gpio_base_5 = mmap_device_io((size_t)0x10, (uint64_t)IMX_GPIO5_BASE); + if(gpio_base_5 == MAP_DEVICE_FAILED) + { + perror("Can't map device base 5 I/O"); + ret = -1; + } + else + { + + } + + /*input config*/ + out32(gpio_base_0 + IMX_GPIO_GDIR, (in32(gpio_base_0 + IMX_GPIO_GDIR) & ~(0x932000U))); + out32(gpio_base_3 + IMX_GPIO_GDIR, (in32(gpio_base_3 + IMX_GPIO_GDIR) & ~(0x17fc0000U))); + out32(gpio_base_4 + IMX_GPIO_GDIR, (in32(gpio_base_4 + IMX_GPIO_GDIR) & ~(0x100006U))); + + out32(gpio_base_4 + IMX_GPIO_GDIR, (in32(gpio_base_4 + IMX_GPIO_GDIR) | (1UL << 12))); + out32(gpio_base_4 + IMX_GPIO_DR, (in32(gpio_base_4 + IMX_GPIO_DR) | (1UL << 12))); + + + + /*output config*/ + out32(gpio_base_0 + IMX_GPIO_GDIR, (in32(gpio_base_0 + IMX_GPIO_GDIR) | (0xcc00cc0UL))); + + + printf("dirver version : %d,%d,%d,%d\n",drv_vsr[0],drv_vsr[1],drv_vsr[2],drv_vsr[3]); + + return ret; +} + + +/*This function for switch button*/ +int imx8_switch_button(void) +{ + + int ret = 0; + + out32(gpio_base_4 + IMX_GPIO_GDIR, (in32(gpio_base_4 + IMX_GPIO_GDIR) | (1UL << 22))); + out32(gpio_base_4 + IMX_GPIO_GDIR, (in32(gpio_base_4 + IMX_GPIO_GDIR) & ~(1UL << 20))); + + out32(gpio_base_4 + IMX_GPIO_DR, (in32(gpio_base_4 + IMX_GPIO_DR) | (1UL << 22))); + ret = (uint32_t)(in32(gpio_base_4 + IMX_GPIO_PSR) & (1UL << 20)) >> 20; + + return ret; + +} + +/*read boardid function*/ +unsigned char imx8_read_boardID(void) +{ + unsigned char id = 0U; + out32(gpio_base_3 + IMX_GPIO_GDIR, (uint32_t)(in32(gpio_base_3 + IMX_GPIO_GDIR) & ~((0xFFUL << 18)))); + + id |= (uint8_t)(((in32(gpio_base_3 + IMX_GPIO_PSR) & (1UL << 18)) >> 18) << 7); + id |= (uint8_t)(((in32(gpio_base_3 + IMX_GPIO_PSR) & (1UL << 19)) >> 19) << 6); + id |= (uint8_t)(((in32(gpio_base_3 + IMX_GPIO_PSR) & (1UL << 20)) >> 20) << 5); + id |= (uint8_t)(((in32(gpio_base_3 + IMX_GPIO_PSR) & (1UL << 21)) >> 21) << 4); + + id |= (uint8_t)(((in32(gpio_base_3 + IMX_GPIO_PSR) & (1UL << 22)) >> 22) << 3); + id |= (uint8_t)(((in32(gpio_base_3 + IMX_GPIO_PSR) & (1UL << 23)) >> 23) << 2); + id |= (uint8_t)(((in32(gpio_base_3 + IMX_GPIO_PSR) & (1UL << 24)) >> 24) << 1); + id |= (uint8_t)(((in32(gpio_base_3 + IMX_GPIO_PSR) & (1UL << 25)) >> 25)); + + return id; +} + +/*input collect*/ +int imx8_input_collect(int channel) +{ + ThreadCtl (_NTO_TCTL_IO, 0); + int value = 0; +#if 0 + out32(gpio_base_0 + IMX_GPIO_GDIR, (in32(gpio_base_0 + IMX_GPIO_GDIR) & ~(0x932000U))); + out32(gpio_base_3 + IMX_GPIO_GDIR, (in32(gpio_base_3 + IMX_GPIO_GDIR) & ~(0x17fc0000U))); + out32(gpio_base_4 + IMX_GPIO_GDIR, (in32(gpio_base_4 + IMX_GPIO_GDIR) & ~(0x100006U))); + + out32(gpio_base_4 + IMX_GPIO_GDIR, (in32(gpio_base_4 + IMX_GPIO_GDIR) | (1UL << 12))); + out32(gpio_base_4 + IMX_GPIO_DR, (in32(gpio_base_4 + IMX_GPIO_DR) | (1UL << 12))); +#endif + + InterruptLock( &spinner ); + + if(1 == channel) + { + value = (in32(gpio_base_0 + IMX_GPIO_PSR) & (uint32_t)(1UL << 8)) >> 8; + } + else if(2 == channel) + { + value = (in32(gpio_base_0 + IMX_GPIO_PSR) & (uint32_t)(1UL << 9)) >> 9; + } + else if(3 == channel) + { + value = (in32(gpio_base_0 + IMX_GPIO_PSR) & (uint32_t)(1UL << 12)) >> 12; + } + else if(4 == channel) + { + value = (in32(gpio_base_0 + IMX_GPIO_PSR) & (uint32_t)(1UL << 13)) >> 13; + } + else if(5 == channel) + { + value = (in32(gpio_base_4 + IMX_GPIO_PSR) & (uint32_t)(1UL << 1)) >> 1; + } + else if(6 == channel) + { + value = (in32(gpio_base_4 + IMX_GPIO_PSR) & (uint32_t)(1UL << 2)) >> 2; + } + else if(7 == channel) + { + value = (in32(gpio_base_3 + IMX_GPIO_PSR) & (uint32_t)(1UL << 26)) >> 26; + } + else if(8 == channel) + { + value = (in32(gpio_base_3 + IMX_GPIO_PSR) & (uint32_t)(1UL << 28)) >> 28; + } + else if(9 == channel) + { + value = (in32(gpio_base_0 + IMX_GPIO_PSR) & (uint32_t)(1UL << 19)) >> 19; + } + else if(10 == channel) + { + value = (in32(gpio_base_0 + IMX_GPIO_PSR) & (uint32_t)(1UL << 16)) >> 16; + } + else + { + perror("input error channel start 1 to 10"); + value = -1; + } + + InterruptUnlock( &spinner ); + return value; +} + + +int imx8_output(int channel, int level) +{ + +// out32(gpio_base_0 + IMX_GPIO_GDIR, (in32(gpio_base_0 + IMX_GPIO_GDIR) | (0xcc00cc0UL))); + + ThreadCtl (_NTO_TCTL_IO, 0); + + int ret = 0; + + InterruptLock( &spinner ); + + switch(channel) + { + case 1: + if(1 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 26))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 26)) >> 26; + } + else if(0 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 26))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 26)) >> 26; + } + else + { + perror("channel 1 input wrong para level must 1 or 0"); + ret = -1; + } + break; + + case 2: + if(1 == level) + { + + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 27))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 27)) >> 27; + + } + else if(0 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 27))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 27)) >> 27; + } + else + { + perror("channel 2 input wrong para level must 1 or 0"); + ret = -1; + } + break; + + case 3: + if(1 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 10))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 10)) >> 10; + } + else if(0 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 10))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 10)) >> 10; + } + else + { + perror("channel 3 input wrong para level must 1 or 0"); + ret = -1; + } + break; + + case 4: + if(1 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 7))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 7)) >> 7; + } + else if(0 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 7))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 7)) >> 7; + } + else + { + perror("channel 4 input wrong para level must 1 or 0"); + ret = -1; + } + break; + + case 5: + if(1 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 6))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 6)) >> 6; + } + else if(0 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 6))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 6)) >> 6; + } + else + { + perror("channel 5 input wrong para level must 1 or 0"); + ret = -1; + } + break; + + case 6: + if(1 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 11))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 11)) >> 11; + } + else if(0 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 11))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 11)) >> 11; + } + else + { + perror("channel 6 input wrong para level must 1 or 0"); + ret = -1; + } + break; + + case 7: + if(1 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 22))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 22)) >> 22; + } + else if(0 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 22))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 22)) >> 22; + } + else + { + perror("channel 7 input wrong para level must 1 or 0"); + ret = -1; + } + break; + + case 8: + if(1 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 23))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 23)) >> 23; + } + else if(0 == level) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 23))); + ret = (in32(gpio_base_0 + IMX_GPIO_DR) & (1UL << 23)) >> 23; + } + else + { + perror("channel 8 input wrong para level must 1 or 0"); + ret = -1; + } + break; + + default: + perror("channel must be 1 to 8\n"); + ret = -1; + break; + } + + InterruptUnlock( &spinner ); + + + return ret; +} + + +/*Input RED, GREEN or OFF,control by cpu1 and cpu2*/ +int imx8_led_REA_REB(int light) +{ + + int ret = 0; + + out32(gpio_base_5 + IMX_GPIO_GDIR, (in32(gpio_base_5 + IMX_GPIO_GDIR) | (1UL << 26) | (1UL << 27))); + + if(light == RED) + { + out32(gpio_base_5 + IMX_GPIO_DR, ((in32(gpio_base_5 + IMX_GPIO_DR) & ~(1UL << 26)) | (1UL << 27))); + } + else if(light == GREEN) + { + out32(gpio_base_5 + IMX_GPIO_DR, ((in32(gpio_base_5 + IMX_GPIO_DR) | (1UL << 26) )& ~(1UL << 27))); + } + else if(light == OFF) + { + out32(gpio_base_5 + IMX_GPIO_DR, (in32(gpio_base_5 + IMX_GPIO_DR) & ~(0x3UL << 26))); + } + else + { + perror("input wrong pare please input GREEN ,RED or OFF"); + ret = -1; + } + return ret; +} + +/*Input RED, GREEN or OFF, control by cpu1*/ +int imx8_led_R_E(int light) +{ + int ret = 0; + out32(gpio_base_5 + IMX_GPIO_GDIR, (in32(gpio_base_5 + IMX_GPIO_GDIR) | (1UL << 28) | (1UL << 29))); + + if(light == GREEN) + { + out32(gpio_base_5 + IMX_GPIO_DR, ((in32(gpio_base_5 + IMX_GPIO_DR) & ~(1UL << 28)) | (1UL << 29))); + } + else if(light == RED) + { + out32(gpio_base_5 + IMX_GPIO_DR, ((in32(gpio_base_5 + IMX_GPIO_DR) | (1UL << 28) )& ~(1UL << 29))); + } + else if(light == OFF) + { + out32(gpio_base_5 + IMX_GPIO_DR, (in32(gpio_base_5 + IMX_GPIO_DR) & ~(0x3UL << 28))); + } + else + { + perror("input wrong pare please input GREEN , RED or OFF\n"); + ret = -1; + } + + return ret; +} + +/*Input YELLOW, GREEN or OFF,control by cpu1*/ +int imx8_led_M_S(int light) +{ + + int ret = 0; + + out32(gpio_base_2 + IMX_GPIO_GDIR, (in32(gpio_base_2 + IMX_GPIO_GDIR) | (1UL << 14) | (1UL << 15))); + + if(light == YELLOW) + { + out32(gpio_base_2 + IMX_GPIO_DR, ((in32(gpio_base_2 + IMX_GPIO_DR) & ~(1UL << 14)) | (1UL << 15))); + } + else if(light == GREEN) + { + out32(gpio_base_2 + IMX_GPIO_DR, ((in32(gpio_base_2 + IMX_GPIO_DR) | (1UL << 14) )& ~(1UL << 15))); + } + else if(light == OFF) + { + out32(gpio_base_2 + IMX_GPIO_DR, (in32(gpio_base_2 + IMX_GPIO_DR) & ~(0x3UL << 14))); + } + else + { + perror("input wrong pare please input GREEN , YELLOW or OFF\n"); + ret = -1; + } + return ret; +} + + + +/*return 0 means cpu 0*/ +unsigned int imx8_read_cpuid(void) +{ + out32(gpio_base_5 + IMX_GPIO_GDIR, (in32(gpio_base_5 + IMX_GPIO_GDIR) & ~(1UL << 25))); + return (in32(gpio_base_5 + IMX_GPIO_PSR) & (uint32_t)(1UL << 25)) >> 25; +} + +/*input 1 : enable, input 0 : disable*/ +int imx8_dcdc_1_ctrl(int level) +{ + int ret = 0; + + out32(gpio_base_1 + IMX_GPIO_GDIR, (in32(gpio_base_1 + IMX_GPIO_GDIR) | (1UL << 10) )); + + if(0 == level) + { + out32(gpio_base_1 + IMX_GPIO_DR, (in32(gpio_base_1 + IMX_GPIO_DR) & ~(1UL << 10))); + } + else if(1 == level) + { + out32(gpio_base_1 + IMX_GPIO_DR, (in32(gpio_base_1 + IMX_GPIO_DR) | (1UL << 10))); + } + else + { + perror("input wrong level please input 1 or 0"); + ret = -1; + } + return ret; +} + +/*input 1 : enable, input 0 : disable*/ +int imx8_dcdc_2_ctrl(int level) +{ + int ret = 0; + + out32(gpio_base_5 + IMX_GPIO_GDIR, (in32(gpio_base_5 + IMX_GPIO_GDIR) | (1UL << 20) )); + + if(0 == level) + { + out32(gpio_base_5 + IMX_GPIO_DR, (in32(gpio_base_5 + IMX_GPIO_DR) & ~(1UL << 20))); + } + else if(1 == level) + { + out32(gpio_base_5 + IMX_GPIO_DR, (in32(gpio_base_5 + IMX_GPIO_DR) | (1UL << 20))); + } + else + { + perror("input wrong level please input 1 or 0"); + ret = -1; + } + return ret; +} + + +/*return 1 means normal, 0 means Overvoltage*/ +unsigned int imx8_Safe_gate_overvoltage_state_1(void) +{ + out32(gpio_base_1 + IMX_GPIO_GDIR, (in32(gpio_base_1 + IMX_GPIO_GDIR) & ~(1UL << 20))); + return (in32(gpio_base_1 + IMX_GPIO_PSR) & (uint32_t)(1UL << 20)) >> 20; +} + +/*return 1 means normal, 0 means Overvoltage*/ +unsigned int imx8_Safe_gate_undervoltage_state_1(void) +{ + out32(gpio_base_1 + IMX_GPIO_GDIR, (in32(gpio_base_1 + IMX_GPIO_GDIR) & ~(1UL << 6))); + return (in32(gpio_base_1 + IMX_GPIO_PSR) & (uint32_t)(1UL << 6)) >> 6; +} + +/*return 1 means normal, 0 means Overvoltage*/ +unsigned int imx8_Safe_gate_overvoltage_state_2(void) +{ + out32(gpio_base_2 + IMX_GPIO_GDIR, (in32(gpio_base_2 + IMX_GPIO_GDIR) & ~(1UL << 29))); + return (in32(gpio_base_2 + IMX_GPIO_PSR) & (uint32_t)(1UL << 29)) >> 29; +} + +/*return 1 means normal, 0 means Overvoltage*/ +unsigned int imx8_Safe_gate_undervoltage_state_2(void) +{ + out32(gpio_base_5 + IMX_GPIO_GDIR, (in32(gpio_base_5 + IMX_GPIO_GDIR) & ~(1UL << 19))); + return (in32(gpio_base_5 + IMX_GPIO_PSR) & (uint32_t)(1UL << 19)) >> 19; +} + + +/*return 1 means on, return 0 means off*/ +unsigned int imx8_ethernet_switch_state_1_1(void) +{ + out32(gpio_base_2 + IMX_GPIO_GDIR, (in32(gpio_base_2 + IMX_GPIO_GDIR) & ~(1UL << 22))); + return (in32(gpio_base_2 + IMX_GPIO_PSR) & (uint32_t)(1UL << 22)) >> 22; +} + +/*return 1 means on, return 0 means off*/ +unsigned int imx8_ethernet_switch_state_1_2(void) +{ + out32(gpio_base_2 + IMX_GPIO_GDIR, (in32(gpio_base_2 + IMX_GPIO_GDIR) & ~(1UL << 23))); + return (in32(gpio_base_2 + IMX_GPIO_PSR) & (uint32_t)(1UL << 23)) >> 23; +} + +/*return 1 means on, return 0 means off*/ +unsigned int imx8_ethernet_switch_state_2_1(void) +{ + out32(gpio_base_2 + IMX_GPIO_GDIR, (in32(gpio_base_2 + IMX_GPIO_GDIR) & ~(1UL << 25))); + return (in32(gpio_base_2 + IMX_GPIO_PSR) & (uint32_t)(1UL << 25)) >> 25; +} + +/*return 1 means on, return 0 means off*/ +unsigned int imx8_ethernet_switch_state_2_2(void) +{ + out32(gpio_base_2 + IMX_GPIO_GDIR, (in32(gpio_base_2 + IMX_GPIO_GDIR) & ~(1UL << 31))); + return (in32(gpio_base_2 + IMX_GPIO_PSR) & (uint32_t)(1UL << 31)) >> 31; +} + +/*------------------------------------------------------------*/ + + +/*return 1 means 24V normal*/ +unsigned int imx8_24V_voltage_state(void) +{ + out32(gpio_base_1 + IMX_GPIO_GDIR, (in32(gpio_base_1 + IMX_GPIO_GDIR) & ~(1UL << 7))); + return (in32(gpio_base_1 + IMX_GPIO_PSR) & (uint32_t)(1UL << 7)) >> 7; +} + + +/*------------------------------------------------------------*/ + +/*return 1 means 5V 3.3V normal*/ +unsigned int imx8_5V_overvoltage_state(void) +{ + out32(gpio_base_0 + IMX_GPIO_GDIR, (in32(gpio_base_0 + IMX_GPIO_GDIR) & ~(1UL << 2))); + return (in32(gpio_base_0 + IMX_GPIO_PSR) & (uint32_t)(1UL << 2)) >> 2; +} + +/*return 1 means 5V 3.3V normal*/ +unsigned int imx8_5V_undervoltage_state(void) +{ + out32(gpio_base_5 + IMX_GPIO_GDIR, (in32(gpio_base_5 + IMX_GPIO_GDIR) & ~(1UL << 23))); + return (in32(gpio_base_5 + IMX_GPIO_PSR) & (uint32_t)(1UL << 23)) >> 23; +} + +/*-------------------------- power-off ethernet----------------------------*/ + +int imx8_safty_ethernet_off(void) +{ + + int ret = 0; + + ret = imx8_dcdc_1_ctrl(0); + ret = imx8_dcdc_2_ctrl(0); + + + out32(gpio_base_0 + IMX_GPIO_GDIR, (in32(gpio_base_0 + IMX_GPIO_GDIR) & ~(1UL << 4))); + out32(gpio_base_3 + IMX_GPIO_GDIR, (in32(gpio_base_3 + IMX_GPIO_GDIR) & ~(1UL << 14))); + + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 4))); + out32(gpio_base_3 + IMX_GPIO_DR, (in32(gpio_base_3 + IMX_GPIO_DR) & ~(1UL << 14))); + + return ret; +} + + +/*timer irq function*/ +const struct sigevent *handler (void *not_used, int id) +{ + + cnt++; + + if((cnt%(uint32_t)2) == (uint32_t)0) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 4))); + out32(gpio_base_3 + IMX_GPIO_DR, (in32(gpio_base_3 + IMX_GPIO_DR) | (1UL << 14))); + } + else + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 4))); + out32(gpio_base_3 + IMX_GPIO_DR, (in32(gpio_base_3 + IMX_GPIO_DR) & ~(1UL << 14))); + } + + out32(tbase + GPT_SR, 0x1U); + return &event; + +} + + +/*timer pthread*/ +void* timer( void * arg) +{ + int ret = 0; + + ret = ThreadCtl (_NTO_TCTL_IO, 0); + SIGEV_INTR_INIT (&event); + + ret = imx8_dcdc_1_ctrl(1); + ret = imx8_dcdc_2_ctrl(1); + + out32(gpio_base_0 + IMX_GPIO_GDIR, (in32(gpio_base_0 + IMX_GPIO_GDIR) | (1UL << 4))); + out32(gpio_base_3 + IMX_GPIO_GDIR, (in32(gpio_base_3 + IMX_GPIO_GDIR) | (1UL << 14))); + + val = InterruptAttach(IMX_GPT0_IRQ, handler, NULL, 0,_NTO_INTR_FLAGS_TRK_MSK ); + + out32(tbase + GPT_CR, (uint32_t)0x20000142); + out32(tbase + GPT_PR, (uint32_t)0x7002); + out32(tbase + GPT_SR, (uint32_t)0x3f); + out32(tbase + GPT_IR, (uint32_t)0); + out32(tbase , (uint32_t)0x20000543); + out32(tbase + GPT_IR, (uint32_t)0x21); + out32(tbase + GPT_OCR1, (uint32_t)0x3e); + + + while(1) + { + ret = InterruptWait(0, 0); + ret = InterruptUnmask(IMX_GPT0_IRQ, val); + } +} + +/*create 8khz timer*/ +int imx8_create_timer_pthread(void) +{ + int ret = 0; + + tbase = mmap_device_io((size_t)0x1000, (uint64_t)IMX_GPT0_BASE); + if(tbase == MAP_DEVICE_FAILED) + { + perror("Can't map timer device I/O"); + ret = -1; + } + else + { + + } + + ret = pthread_create(&timer_thread, NULL, timer, NULL); + return ret; +} + + +/************************************************************************/ +/*25% timer irq function*/ +const struct sigevent *handler_25 (void *not_used, int id) +{ + + cnt++; + + InterruptLock( &spinner ); + + if((cnt%(uint32_t)4) == (uint32_t)0) + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) | (1UL << 4))); + out32(gpio_base_3 + IMX_GPIO_DR, (in32(gpio_base_3 + IMX_GPIO_DR) | (1UL << 14))); + } + else + { + out32(gpio_base_0 + IMX_GPIO_DR, (in32(gpio_base_0 + IMX_GPIO_DR) & ~(1UL << 4))); + out32(gpio_base_3 + IMX_GPIO_DR, (in32(gpio_base_3 + IMX_GPIO_DR) & ~(1UL << 14))); + } + + InterruptUnlock( &spinner ); + + out32(tbase + GPT_SR, 0x1U); + return &event; + +} + + +/*25% timer pthread*/ +void* timer_25( void * arg) +{ + int ret = 0; + + ret = ThreadCtl (_NTO_TCTL_IO, 0); + SIGEV_INTR_INIT (&event); + + ret = imx8_dcdc_1_ctrl(1); + ret = imx8_dcdc_2_ctrl(1); + + out32(gpio_base_0 + IMX_GPIO_GDIR, (in32(gpio_base_0 + IMX_GPIO_GDIR) | (1UL << 4))); + out32(gpio_base_3 + IMX_GPIO_GDIR, (in32(gpio_base_3 + IMX_GPIO_GDIR) | (1UL << 14))); + + val = InterruptAttach(IMX_GPT0_IRQ, handler_25, NULL, 0,_NTO_INTR_FLAGS_TRK_MSK ); + + out32(tbase + GPT_CR, (uint32_t)0x20000142); + + out32(tbase + GPT_PR, (uint32_t)0x3002); + + out32(tbase + GPT_SR, (uint32_t)0x3f); + out32(tbase + GPT_IR, (uint32_t)0); + out32(tbase , (uint32_t)0x20000543); + out32(tbase + GPT_IR, (uint32_t)0x21); + out32(tbase + GPT_OCR1, (uint32_t)0x3e); + + + while(1) + { + ret = InterruptWait(0, 0); + ret = InterruptUnmask(IMX_GPT0_IRQ, val); + } + + +} + +/*create 25% 8khz timer*/ +int imx8_create_timer_pthread_25(void) +{ + int ret = 0; + + tbase = mmap_device_io((size_t)0x1000, (uint64_t)IMX_GPT0_BASE); + if(tbase == MAP_DEVICE_FAILED) + { + perror("Can't map timer device I/O"); + ret = -1; + } + else + { + + } + + ret = pthread_create(&timer_thread, NULL, timer_25, NULL); + + return ret; +} +/************************************************************************/ + + +int imx8_gpio_release(void) +{ + int ret = 0; + ret = munmap_device_io(gpio_base_0, 0x10UL); + if(ret > 0) + { + ret = -1; + perror("munmap_device_io failed"); + } + else + { + + } + + ret = munmap_device_io(gpio_base_1, 0x10UL); + if(ret > 0) + { + ret = -1; + perror("munmap_device_io failed"); + } + else + { + + } + + ret = munmap_device_io(gpio_base_2, 0x10UL); + if(ret > 0) + { + ret = -1; + perror("munmap_device_io failed"); + } + else + { + + } + + ret = munmap_device_io(gpio_base_3, 0x10UL); + if(ret > 0) + { + ret = -1; + perror("munmap_device_io failed"); + } + else + { + + } + + ret = munmap_device_io(gpio_base_4, 0x10UL); + if(ret > 0) + { + ret = -1; + perror("munmap_device_io failed"); + } + else + { + + } + + ret = munmap_device_io(gpio_base_5, 0x10UL); + if(ret > 0) + { + ret = -1; + perror("munmap_device_io failed"); + } + else + { + + } + + return ret; +} diff --git a/TSCP/src/DRV/imx8_drv_gpio.h b/TSCP/src/DRV/imx8_drv_gpio.h new file mode 100644 index 0000000..a430781 --- /dev/null +++ b/TSCP/src/DRV/imx8_drv_gpio.h @@ -0,0 +1,85 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define IMX_GPIO0_BASE 0x5D080000 +#define IMX_GPIO1_BASE 0x5D090000 +#define IMX_GPIO2_BASE 0x5D0A0000 +#define IMX_GPIO3_BASE 0x5D0B0000 +#define IMX_GPIO4_BASE 0x5D0C0000 +#define IMX_GPIO5_BASE 0x5D0D0000 +#define IMX_GPIO6_BASE 0x5D0E0000 +#define IMX_GPIO7_BASE 0x5D0F0000 + +#define IMX_GPIO_DR 0x0U +#define IMX_GPIO_GDIR 0x4U +#define IMX_GPIO_PSR 0x8U + + +/*timer regisger */ +#define IMX_GPT0_BASE 0x5D140000 +#define IMX_GPT_SIZE 0x10000 +#define IMX_GPT0_IRQ 112 +#define GPT_CR 0x00U +#define GPT_PR 0x04U +#define GPT_SR 0x08U +#define GPT_IR 0x0cU +#define GPT_OCR1 0x10U +#define GPT_CNT 0x24U + +#define OFF 0 +#define GREEN 1 +#define RED 2 +#define YELLOW 3 + +extern char drv_vsr[4]; + +int imx8_gpio_init(void); +int imx8_input_collect(int channel); +int imx8_output(int channel, int level); +int imx8_gpio_release(void); +int imx8_led_REA_REB(int light); +int imx8_led_R_E(int light); +int imx8_led_M_S(int light); + +unsigned int imx8_read_cpuid(void); +int imx8_dcdc_1_ctrl(int level); +int imx8_dcdc_2_ctrl(int level); +unsigned int imx8_Safe_gate_overvoltage_state_1(void); +unsigned int imx8_Safe_gate_undervoltage_state_1(void); +unsigned int imx8_Safe_gate_overvoltage_state_2(void); +unsigned int imx8_Safe_gate_undervoltage_state_2(void); +unsigned int imx8_ethernet_switch_state_1_1(void); +unsigned int imx8_ethernet_switch_state_1_2(void); +unsigned int imx8_ethernet_switch_state_2_1(void); +unsigned int imx8_ethernet_switch_state_2_2(void); +unsigned int imx8_24V_voltage_state(void); +unsigned int imx8_5V_overvoltage_state(void); +unsigned int imx8_5V_undervoltage_state(void); +unsigned char imx8_read_boardID(void); +int imx8_switch_button(void); +int imx8_safty_ethernet_off(void); + + + +int imx8_create_timer_pthread_25(void); +int imx8_create_timer_pthread(void); +const struct sigevent *handler_25 (void *not_used, int id); +const struct sigevent *handler (void *not_used, int id); +void* timer_25( void * arg); +void* timer( void * arg); diff --git a/TSCP/src/DRV/imx8_drv_i2c.c b/TSCP/src/DRV/imx8_drv_i2c.c new file mode 100644 index 0000000..633374b --- /dev/null +++ b/TSCP/src/DRV/imx8_drv_i2c.c @@ -0,0 +1,772 @@ + +#include "imx8_drv_i2c.h" + +static int fd_i2c_1; +static int fd_i2c_8; +static int fd_sc; +static imx_dcmd_sc_misc_temp_t cpu_temp; + +int16_t temperature_read(int fd, uint8_t reg, uint8_t slave_addr) +{ + + uint8_t v1, v2; + uint16_t val = (uint16_t)0; + struct send_recv + { + i2c_sendrecv_t hdr; + uint8_t buf[2]; + } read; + + read.buf[0] = reg ; + read.hdr.send_len = (uint32_t)1; + read.hdr.recv_len = (uint32_t)2; + + read.hdr.slave.addr = slave_addr; + read.hdr.slave.fmt = (uint32_t)I2C_ADDRFMT_7BIT; + read.hdr.stop = (uint32_t)1; + + if((devctl(fd, DCMD_I2C_SENDRECV, (void *)&read, sizeof(read),(int *)NULL)) > 0) + { + perror("Failed to read to temp ! "); + } + else + { + + } + + v1 = read.buf[0]; + v2 = read.buf[1]; + + if(slave_addr == (uint8_t)0x48) + { + val = (v1 << 4) | (v2 >> 4); + } + else + { + + } + + if(slave_addr == (uint8_t)0x49) + { + val = v2 | (uint16_t)((uint16_t)v1 << 8); + } + else + { + + } + return val; +} + + +int eeprom_read_data(int fd, uint32_t regaddr, uint8_t rx_buf[],uint32_t len,uint8_t slave_addr) +{ + + int i = 0,ret = 0; + + struct send_recv + { + i2c_sendrecv_t hdr; + uint8_t buf[128]; + } eeprom_read; + + /* Read the Registers Current Value */ + eeprom_read.buf[0] = (uint8_t)((regaddr >> 8) & 0xFFUL); + eeprom_read.buf[1] = (uint8_t)(regaddr & 0xFFUL); + + eeprom_read.hdr.send_len = (uint32_t)2; + eeprom_read.hdr.recv_len = (uint32_t)len ; + + eeprom_read.hdr.slave.addr = slave_addr; + eeprom_read.hdr.slave.fmt = (uint32_t)I2C_ADDRFMT_7BIT; + eeprom_read.hdr.stop = (uint32_t)1; + + ret = devctl(fd, (uint32_t)DCMD_I2C_SENDRECV, (void*)&eeprom_read,sizeof(eeprom_read),(int *)NULL); + + if(ret > 0) + { + + } + else + { + + } + + for(i = 0; i < (int32_t)len; i++) + { + rx_buf[i] = eeprom_read.buf[i]; + } + + return ret; +} + +int eeprom_write_data(int fd, uint32_t regaddr, uint8_t tx_buf[],uint32_t len,uint8_t slave_addr) +{ + + int ret = 0,i = 0; + + struct send_recv + { + i2c_sendrecv_t hdr; + uint8_t buf[2 + 128]; + } eeprom_write; + + /*Read the Registers Current Value */ + eeprom_write.buf[0] = (uint8_t)((regaddr >> 8) & 0xFFUL); + eeprom_write.buf[1] = (uint8_t)(regaddr & 0xFFUL); + + for(i = 0; i < (int32_t)len; i++) + { + eeprom_write.buf[2 + i] = tx_buf[i]; + } + + eeprom_write.hdr.send_len = (uint32_t)2 + len; + eeprom_write.hdr.recv_len = (uint32_t)0; + + eeprom_write.hdr.slave.addr = slave_addr; + eeprom_write.hdr.slave.fmt = (uint32_t)I2C_ADDRFMT_7BIT; + eeprom_write.hdr.stop = (uint32_t)1; + + ret = devctl(fd, (uint32_t)DCMD_I2C_SENDRECV, &eeprom_write, sizeof(eeprom_write),NULL); + + if(ret > 0) + { + + } + else + { + + } + + return ret; +} + + +int imx8_i2c_init(void) +{ + + fd_i2c_1 = open(I2C_1, O_RDWR); + if(fd_i2c_1 == -1) + { + perror("can't open I2C1\n"); + } + else + { + + } + + fd_i2c_8 = open(I2C_8, O_RDWR); + if(fd_i2c_8 == -1) + { + perror("can't open I2C8\n"); + } + else + { + + } + + return 0; +} + + +int imx8_cpu_temp_init(void) +{ + int ret = 0; + + fd_sc = open(SC_TEMP, O_RDWR); + + if(fd_sc == -1) + { + ret = -1; + perror("can't open sc"); + } + else + { + + } + + return ret; +} + + +int imx8_read_cpu_temp(void) +{ + + devctl(fd_sc, 0xc00c0557U, &cpu_temp, sizeof(cpu_temp),0); + + return cpu_temp.celsius; +} + + + +/*There are 4 eeproms, one is in board,the other is out board,8R 12R switchboard + * the first parameter must write EEPROM_IN_BOARD,or EEPROM_OUT_BOARD,define in imx8_drv_i2c.h*/ + +int imx8_write_eeprom(int board,uint8_t tx_buf[], unsigned int len) +{ + + int division = 0,modular = 0,ret = 0; + int i; + if((len > (uint32_t)65536) || (len < (uint32_t)0) || (tx_buf == NULL)) + { + perror("wrong para"); + ret = -1; + } + else + { + switch(board) + { + case EEPROM_IN_BOARD: + + if(len <= (uint32_t)128) + { + ret = eeprom_write_data(fd_i2c_1,0x0U,tx_buf,len,(uint8_t)I2C_1_EEPROM_ADDR); + } + else + { + + } + + if(len > (uint32_t)128) + { + + division = (int)len/128; + modular = (int)len%128; + + for(i = 0; i < division; i++) + { + ret = eeprom_write_data(fd_i2c_1,i * 128,tx_buf + 128 * i,128U,(uint8_t)I2C_1_EEPROM_ADDR); + ret = (int)delay((uint32_t)5); + } + + ret = (int)delay((uint32_t)5); + + if(modular > 0) + { + ret = eeprom_write_data(fd_i2c_1,division * 128,tx_buf + 128 * division,(uint32_t)modular,(uint8_t)I2C_1_EEPROM_ADDR); + } + else + { + + } + } + else + { + + } + + break; + case EEPROM_OUT_BOARD: + + if(len <= (uint32_t)128) + { + ret = eeprom_write_data(fd_i2c_8,0x0U,tx_buf,len,(uint8_t)I2C_8_EEPROM_ADDR); + } + else + { + + } + + if(len > (uint32_t)128) + { + + division = (int)len/128; + modular = (int)len%128; + + for(i = 0; i < division; i++) + { + ret = eeprom_write_data(fd_i2c_8,i * 128,tx_buf + 128 * i,128U,(uint8_t)I2C_8_EEPROM_ADDR); + ret = (int)delay((uint32_t)5); + } + + ret = (int)delay((uint32_t)5); + + if(modular > 0) + { + ret = eeprom_write_data(fd_i2c_8,division * 128,tx_buf + 128 * division,(uint32_t)modular,(uint8_t)I2C_8_EEPROM_ADDR); + } + else + { + + } + } + else + { + + } + break; + + case EEPROM_8R: + + if(len <= (uint32_t)64) + { + ret = eeprom_write_data(fd_i2c_8,0x0U,tx_buf,len,(uint8_t)I2C_8_EEPROM_8R_ADDR); + } + else + { + + } + + if((len > (uint32_t)64) && (len < (uint32_t)32768)) + { + + division = (int)len/64; + modular = (int)len%64; + + for(i = 0; i < division; i++) + { + ret = eeprom_write_data(fd_i2c_8,i * 64,tx_buf + 64 * i,64U,(uint8_t)I2C_8_EEPROM_8R_ADDR); + ret = (int)delay((uint32_t)5); + } + + ret = (int)delay((uint32_t)5); + + if(modular > 0) + { + ret = eeprom_write_data(fd_i2c_8,division * 64,tx_buf + 64 * division,(uint32_t)modular,(uint8_t)I2C_8_EEPROM_8R_ADDR); + } + else + { + + } + } + else + { + ret = -1; + } + break; + + case EEPROM_12R: + + if(len <= (uint32_t)64) + { + ret = eeprom_write_data(fd_i2c_8,0x0U,tx_buf,len,(uint8_t)I2C_8_EEPROM_12R_ADDR); + } + else + { + + } + + if((len > (uint32_t)64) && (len < (uint32_t)32768)) + { + + division = (int)len/64; + modular = (int)len%64; + + for(i = 0; i < division; i++) + { + ret = eeprom_write_data(fd_i2c_8,i * 64,tx_buf + 64 * i,64U,(uint8_t)I2C_8_EEPROM_12R_ADDR); + ret = (int)delay((uint32_t)5); + } + + ret = (int)delay((uint32_t)5); + + if(modular > 0) + { + ret = eeprom_write_data(fd_i2c_8,division * 64,tx_buf + 64 * division,(uint32_t)modular,(uint8_t)I2C_8_EEPROM_12R_ADDR); + } + else + { + + } + } + else + { + ret = -1; + } + break; + + default: + perror("board must be EEPROM_IN_BOARD, EEPROM_IN_BOARD, EEPROM_8R, EEPROM_12R"); + ret = -1; + break; + } + } + + return ret; +} + +int imx8_read_eeprom(int board,uint8_t rx_buf[], unsigned int len) +{ + + int division = 0,modular = 0,ret = 0; + int i; + if((len > (uint32_t)65536) || (len < (uint32_t)0) || (rx_buf == NULL)) + { + perror("wrong para"); + ret = -1; + } + else + { + switch(board) + { + case EEPROM_IN_BOARD: + + if(len <= (uint32_t)128) + { + ret = eeprom_read_data(fd_i2c_1,0x0U,rx_buf,len,(uint8_t)I2C_1_EEPROM_ADDR); + } + else + { + + } + + if(len > (uint32_t)128) + { + + division = (int)len/128; + modular = (int)len%128; + + for(i = 0; i < division; i++) + { + ret = eeprom_read_data(fd_i2c_1,i * 128,rx_buf + 128 * i,128U,(uint8_t)I2C_1_EEPROM_ADDR); + } + + if(modular > 0) + { + ret = eeprom_read_data(fd_i2c_1,division * 128,rx_buf + 128 * division,(uint32_t)modular,(uint8_t)I2C_1_EEPROM_ADDR); + } + else + { + + } + } + else + { + + } + + break; + case EEPROM_OUT_BOARD: + + if(len <= (uint32_t)128) + { + ret = eeprom_read_data(fd_i2c_8,0x0U,rx_buf,len,(uint8_t)I2C_8_EEPROM_ADDR); + } + else + { + + } + + if(len > (uint32_t)128) + { + + division = (int)len/128; + modular = (int)len%128; + + for(i = 0; i < division; i++) + { + ret = eeprom_read_data(fd_i2c_8,i * 128,rx_buf + 128 * i,128U,(uint8_t)I2C_8_EEPROM_ADDR); + } + + if(modular > 0) + { + ret = eeprom_read_data(fd_i2c_8,division * 128,rx_buf + 128 * division,(uint32_t)modular,(uint8_t)I2C_8_EEPROM_ADDR); + } + else + { + + } + + } + else + { + + } + break; + + case EEPROM_8R: + + if(len <= (uint32_t)64) + { + ret = eeprom_read_data(fd_i2c_8,0x0U,rx_buf,len,(uint8_t)I2C_8_EEPROM_8R_ADDR); + } + else + { + + } + + if((len > (uint32_t)64) && (len < (uint32_t)32768)) + { + + division = (int)len/64; + modular = (int)len%64; + + for(i = 0; i < division; i++) + { + ret = eeprom_read_data(fd_i2c_8,i * 64,rx_buf + 64 * i,64U,(uint8_t)I2C_8_EEPROM_8R_ADDR); + } + + if(modular > 0) + { + ret = eeprom_read_data(fd_i2c_8,division * 64,rx_buf + 64 * division,(uint32_t)modular,(uint8_t)I2C_8_EEPROM_8R_ADDR); + } + else + { + + } + + } + else + { + ret = -1; + } + break; + + case EEPROM_12R: + + if(len <= (uint32_t)64) + { + ret = eeprom_read_data(fd_i2c_8,0x0U,rx_buf,len,(uint8_t)I2C_8_EEPROM_12R_ADDR); + } + else + { + + } + + if((len > (uint32_t)64) && (len < (uint32_t)32768)) + { + + division = (int)len/64; + modular = (int)len%64; + + for(i = 0; i < division; i++) + { + ret = eeprom_read_data(fd_i2c_8,i * 64,rx_buf + 64 * i,64U,(uint8_t)I2C_8_EEPROM_12R_ADDR); + } + + if(modular > 0) + { + ret = eeprom_read_data(fd_i2c_8,division * 64,rx_buf + 64 * division,(uint32_t)modular,(uint8_t)I2C_8_EEPROM_12R_ADDR); + } + else + { + + } + + } + else + { + ret = -1; + } + break; + + default: + perror("board must be EEPROM_IN_BOARD, EEPROM_IN_BOARD, EEPROM_8R, EEPROM_12R"); + ret = -1; + break; + } + } + + + return ret; +} + + + +int imx8_write_fram(uint8_t tx_buf[], unsigned int len) +{ + + int division = 0,modular = 0,ret = 0; + int i; + if(len > (uint32_t)32768) + { + perror("FRAM write than 32KB\n"); + ret = -1; + } + else + { + + } + + if(len <= (uint32_t)128) + { + ret = eeprom_write_data(fd_i2c_1,0x0U,tx_buf,len,(uint8_t)I2C_1_FRAM_ADDR); + } + else + { + + } + + if(len > (uint32_t)128) + { + + division = (int)len/128; + modular = (int)len%128; + + for(i = 0; i < division; i++) + { + ret = eeprom_write_data(fd_i2c_1,i * 128,tx_buf + 128 * i,128U,(uint8_t)I2C_1_FRAM_ADDR); + ret = (int)delay((uint32_t)5); + } + + ret = (int)delay((uint32_t)5); + + if(modular > 0) + { + ret = eeprom_write_data(fd_i2c_1,division * 128,tx_buf + 128 * division,(uint32_t)modular,(uint8_t)I2C_1_FRAM_ADDR); + } + else + { + + } + + } + + return ret; +} + + + +int imx8_read_fram(uint8_t rx_buf[], unsigned int len) +{ + + int division = 0,modular = 0,ret = 0; + int i; + if(len > (uint32_t)32768) + { + perror("FRAM read than 32KB\n"); + ret = -1; + } + else + { + + } + + if(len <= (uint32_t)128) + { + ret = eeprom_read_data(fd_i2c_1,0x0U,rx_buf,len,(uint8_t)I2C_1_FRAM_ADDR); + } + else + { + + } + + if(len > (uint32_t)128) + { + + division = (int)len/128; + modular = (int)len%128; + + for(i = 0; i < division; i++) + { + ret = eeprom_read_data(fd_i2c_1,i * 128,rx_buf + 128 * i,128U,(uint8_t)I2C_1_FRAM_ADDR); + } + + if(modular > 0) + { + ret = eeprom_read_data(fd_i2c_1,division * 128,rx_buf + 128 * division,(uint32_t)modular,(uint8_t)I2C_1_FRAM_ADDR); + } + else + { + + } + + } + else + { + + } + + return ret; +} + + +static uint16_t ina3321_read(int fd, uint8_t reg) +{ + + uint8_t v1, v2; + uint16_t result = 0; + struct send_recv + { + i2c_sendrecv_t hdr; + uint8_t buf[2]; + } ina3321_rd; + + + ina3321_rd.buf[0] = reg ; + ina3321_rd.hdr.send_len = (uint32_t)1; + ina3321_rd.hdr.recv_len = (uint32_t)2; + + ina3321_rd.hdr.slave.addr = (uint8_t)I2C_8_INA3321_ADDR; + ina3321_rd.hdr.slave.fmt = (uint32_t)I2C_ADDRFMT_7BIT; + ina3321_rd.hdr.stop = (uint32_t)1; + + + if (devctl(fd, DCMD_I2C_SENDRECV, &ina3321_rd, sizeof(ina3321_rd),NULL)) + { + perror("Failed to read to ina3321\n"); + result = -1; + } + else + { + + } + + v1 = ina3321_rd.buf[0]; + v2 = ina3321_rd.buf[1]; + result = v2 | (uint16_t)((uint16_t)v1 << 8); + + return result; +} + + +int imx8_read_ina3221(struct ina3221* ina3221) +{ + + int ret = 0; + if(ina3221 == NULL) + { + ret = -1; + } + else + { + ina3221->channel_1_shunt = (ina3321_read(fd_i2c_8,(uint8_t)0x1) >> 3) * 4; + ina3221->channel_2_shunt = (ina3321_read(fd_i2c_8,(uint8_t)0x3) >> 3) * 4; + ina3221->channel_3_shunt = (ina3321_read(fd_i2c_8,(uint8_t)0x5) >> 3) * 4; + ina3221->channel_1_bus = (float)(ina3321_read(fd_i2c_8,(uint8_t)0x2) >> 3) * 8 / 1000; + ina3221->channel_2_bus = (float)(ina3321_read(fd_i2c_8,(uint8_t)0x4) >> 3) * 8 / 1000; + ina3221->channel_3_bus = (float)(ina3321_read(fd_i2c_8,(uint8_t)0x6) >> 3) * 8 / 1000; + } + + return ret; +} + +double imx8_read_tmp117(void) +{ + return (double)temperature_read(fd_i2c_8,(uint8_t)0,(uint8_t)I2C_8_TMP117_ADDR) * 0.0078125; +} + +double imx8_read_tmp112(void) +{ + + uint16_t temp; + double value; + + temp = temperature_read(fd_i2c_1,(uint8_t)0,(uint8_t)I2C_1_TMP112_ADDR); + + if((temp & 0x800u) == 0x800u) + { + temp <<= 4; + value = (double)(((short int)temp * 0.0625) / 16); + } + else + { + value = (double)temp * 0.0625; + } + + + return value; +} + +/*i2c release*/ +int imx8_release_i2c(void) +{ + int ret = 0; + ret = close (fd_i2c_1); + ret = close (fd_i2c_8); + return ret; +} + + + + diff --git a/TSCP/src/DRV/imx8_drv_i2c.h b/TSCP/src/DRV/imx8_drv_i2c.h new file mode 100644 index 0000000..a6cf18d --- /dev/null +++ b/TSCP/src/DRV/imx8_drv_i2c.h @@ -0,0 +1,355 @@ +/* + * $QNXLicenseC: + * Copyright 2015, QNX Software Systems. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You + * may not reproduce, modify or distribute this software except in + * compliance with the License. You may obtain a copy of the License + * at: http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OF ANY KIND, either express or implied. + * + * This file may contain contributions from others, either as + * contributors under the License or as licensors under other terms. + * Please review this entire file for other proprietary rights or license + * notices, as well as the QNX Development Suite License Guide at + * http://licensing.qnx.com/license-guide/ for other information. + * $ + */ +#ifndef _I2C_LIB_H_INCLUDED +#define _I2C_LIB_H_INCLUDED + +#ifndef _PLATFORM_H_INCLUDED +#include +#endif + + +#include +#include +#include +#include +#include + +#define I2C_1 "/dev/i2c1" +#define I2C_8 "/dev/i2c8" +#define SC_TEMP "/dev/sc" + + +#define I2C_1_TMP112_ADDR 0X48 +#define I2C_1_EEPROM_ADDR 0X57 +#define I2C_1_FRAM_ADDR 0X50 + +#define I2C_8_EEPROM_ADDR 0X51 +#define I2C_8_TMP117_ADDR 0X49 +#define I2C_8_INA3321_ADDR 0X40 +#define I2C_8_EEPROM_8R_ADDR 0X52 +#define I2C_8_EEPROM_12R_ADDR 0X53 + +#define EEPROM_IN_BOARD 1 +#define EEPROM_OUT_BOARD 2 +#define EEPROM_8R 3 +#define EEPROM_12R 4 + + + +typedef int sci_mgr_rsrc_t; +typedef uint8_t sci_mgr_misc_temp_t; + +/** Structure for passing data with DCMD commands: + * - IMX_DCMD_SC_MISC_SET_TEMP + * - IMX_DCMD_SC_MISC_GET_TEMP + */ +typedef struct _imx_dcmd_sc_misc_temp_t { + sci_mgr_rsrc_t resource; /**< Resource with sensor */ + sci_mgr_misc_temp_t temp; /**< Alarm to set */ + int16_t celsius; /**< Whole part of temp to set */ + int8_t tenths; /**< Fractional part of temp to set */ +} imx_dcmd_sc_misc_temp_t; + + +int16_t temperature_read(int fd, uint8_t reg, uint8_t slave_addr); + +int eeprom_write_data(int fd, uint32_t regaddr, uint8_t tx_buf[],uint32_t len,uint8_t slave_addr); +int eeprom_read_data(int fd, uint32_t regaddr, uint8_t rx_buf[],uint32_t len,uint8_t slave_addr); + +int imx8_write_fram(uint8_t tx_buf[], unsigned int len); +int imx8_read_fram(uint8_t rx_buf[], unsigned int len); + +int imx8_read_eeprom(int board,uint8_t rx_buf[], unsigned int len); +int imx8_write_eeprom(int board,uint8_t tx_buf[], unsigned int len); + +int imx8_i2c_init(void); +int imx8_release_i2c(void); +double imx8_read_tmp112(void); +double imx8_read_tmp117(void); +int imx8_cpu_temp_init(void); +int imx8_read_cpu_temp(void); + +struct ina3221 { + int channel_1_shunt; /*channel 1 current*/ + float channel_1_bus; /*channel 1 voltage*/ + int channel_2_shunt; /*channel 2 current*/ + float channel_2_bus; /*channel 2 voltage*/ + int channel_3_shunt; /*channel 3 current*/ + float channel_3_bus; /*channel 3 voltage*/ +}; + + +int imx8_read_ina3221(struct ina3221* ina3221); + + + + +#define I2CLIB_VERSION_MAJOR 1 +#define I2CLIB_VERSION_MINOR 0 +#define I2CLIB_REVISION 0 + +#include <_pack1.h> + +typedef struct { + unsigned char major; + unsigned char minor; + unsigned char revision; +} i2c_libversion_t; + +/* + * These codes are returned by devctl DCMD_I2C_STATUS to provide the cause of + * of a failed I2C transaction. + */ +typedef enum { + I2C_STATUS_DONE = 0x0001, /* transaction completed (with or + without error) */ + I2C_STATUS_ERROR = 0x0002, /* timeout/unknown error */ + I2C_STATUS_NACK = 0x0010, /* slave no-acknowledge */ + I2C_STATUS_ARBL = 0x0020, /* lost arbitration */ + I2C_STATUS_BUSY = 0x0040, /* timed out */ + I2C_STATUS_ABORT = 0x0100, /* transaction aborted */ + I2C_STATUS_ADDR_NACK = 0x0200, /* I2C_STATUS_NACK is address NACK */ + I2C_STATUS_DATA_NACK = 0x0400 /* I2C_STATUS_NACK is data NACK */ +} i2c_status_t; + +#define MAX_I2C_ERROR I2C_STATUS_DATA_NACK + +typedef enum { + I2C_ADDRFMT_10BIT = 0x0001, + I2C_ADDRFMT_7BIT = 0x0002, +} i2c_addrfmt_t; + +typedef enum { + I2C_SPEED_STANDARD = 0x0001, /* up to 100 kbit/s */ + I2C_SPEED_FAST = 0x0002, /* up to 400 kbit/s */ + I2C_SPEED_HIGH = 0x0004 /* up to 3.4 Mbit/s */ +} i2c_speed_mode_t; + +typedef struct { + _Uint32t speed_mode; /* supported speeds: I2C_SPEED_* */ + _Uint32t addr_mode; /* supported address fmts: I2C_ADDRFMT_* */ + _Uint32t reserved[2]; +} i2c_driver_info_t; + +typedef struct { + _Uint32t addr; /* I2C address */ + _Uint32t fmt; /* 7- or 10-bit format */ +} i2c_addr_t; + +typedef struct { + i2c_addr_t slave; /* slave address */ + _Uint32t len; /* length of send data in bytes */ + _Uint32t stop; /* send stop when complete? (0=no, 1=yes) */ +} i2c_send_t; + +typedef struct { + i2c_addr_t slave; /* slave address */ + _Uint32t len; /* length of receive data in bytes */ + _Uint32t stop; /* send stop when complete? (0=no, 1=yes) */ +} i2c_recv_t; + +typedef struct { + i2c_addr_t slave; /* slave address */ + _Uint32t send_len; /* length of send data in bytes */ + _Uint32t recv_len; /* length of receive data in bytes */ + _Uint32t stop; /* set stop when complete? */ +} i2c_sendrecv_t; + +typedef struct { + _Uint32t len; /* length of data to send/recv, in bytes + (not including this header) */ + _Uint32t stop; /* send stop when complete? (0=no, 1=yes) */ +} i2c_masterhdr_t; + +#include <_packpop.h> + +/* + * Resource Manager Interface + */ + +/* + * The following devctls are used by a client application + * to control the I2C interface. + */ + +#include +#define _DCMD_I2C _DCMD_MISC + +#define DCMD_I2C_SET_SLAVE_ADDR __DIOT (_DCMD_I2C, 1, i2c_addr_t) +#define DCMD_I2C_SET_BUS_SPEED __DIOT (_DCMD_I2C, 2, _Uint32t) +#define DCMD_I2C_MASTER_SEND __DIOT (_DCMD_I2C, 3, i2c_masterhdr_t) +#define DCMD_I2C_MASTER_RECV __DIOTF(_DCMD_I2C, 4, i2c_masterhdr_t) +#define DCMD_I2C_SEND __DIOT (_DCMD_I2C, 5, i2c_send_t) +#define DCMD_I2C_RECV __DIOTF(_DCMD_I2C, 6, i2c_recv_t) +#define DCMD_I2C_SENDRECV __DIOTF(_DCMD_I2C, 7, i2c_sendrecv_t) +#define DCMD_I2C_LOCK __DION (_DCMD_I2C, 8) +#define DCMD_I2C_UNLOCK __DION (_DCMD_I2C, 9) +#define DCMD_I2C_DRIVER_INFO __DIOF (_DCMD_I2C, 10, i2c_driver_info_t) +#define DCMD_I2C_GET_BUS_SPEED __DIOF (_DCMD_I2C, 11, _Uint32t) +#define DCMD_I2C_BUS_RESET __DION (_DCMD_I2C, 12) +#define DCMD_I2C_STATUS __DIOF (_DCMD_I2C, 13, i2c_status_t) + +/* + * Hardware interface + */ +typedef struct { + /* size of this structure */ + size_t size; + + /* + * Return version information + * Returns: + * 0 success + * -1 failure + */ + int (*version_info)(i2c_libversion_t *version); + + /* + * Initialize master interface. + * Returns a handle that is passed to all other functions. + * Returns: + * !NULL success + * NULL failure + */ + void *(*init)(int argc, char *argv[]); + + /* + * Clean up driver. + * Frees memory associated with "hdl". + */ + void (*fini)(void *hdl); + + /* + * Master send. + * Parameters: + * (in) hdl Handle returned from init() + * (in) buf Buffer of data to send + * (in) len Length in bytes of buf + * (in) stop If !0, set stop condition when send completes + * Returns: + * bitmask of status bits + */ + i2c_status_t (*send)(void *hdl, void *buf, unsigned int len, + unsigned int stop); + /* + * Master receive. + * Parameters: + * (in) hdl Handle returned from init() + * (in) buf Buffer for received data + * (in) len Length in bytes of buf + * (in) stop If !0, set stop condition when recv completes + * Returns: + * bitmask of status bits + */ + i2c_status_t (*recv)(void *hdl, void *buf, unsigned int len, + unsigned int stop); + + /* + * Force the master to free the bus. + * Returns when the stop condition has been sent. + * Returns: + * 0 success + * -1 failure + */ + int (*abort)(void *hdl, int rcvid); + + /* + * Specify the target slave address. + * Returns: + * 0 success + * -1 failure + */ + int (*set_slave_addr)(void *hdl, unsigned int addr, i2c_addrfmt_t fmt); + + /* + * Specify the bus speed. + * If an invalid bus speed is requested, this function should return + * failure and leave the bus speed unchanged. + * Parameters: + * (in) speed Bus speed. Units are implementation-defined. + * (out) ospeed Actual bus speed (if NULL, this is ignored) + * Returns: + * 0 success + * -1 failure + */ + int (*set_bus_speed)(void *hdl, unsigned int speed, unsigned int *ospeed); + + /* + * Request info about the driver. + * Returns: + * 0 success + * -1 failure + */ + int (*driver_info)(void *hdl, i2c_driver_info_t *info); + + /* + * Handle a driver-specific devctl(). + * Parameters: + * (in) cmd Device command + * (i/o) msg Message buffer + * (in) msglen Length of message buffer in bytes + * (out) nbytes Bytes to return (<= msglen) + * (out) info Extra status information returned by devctl + * Returns: + * EOK success + * errno failure + */ + int (*ctl)(void *hdl, int cmd, void *msg, int msglen, + int *nbytes, int *info); + + /* + * Reset i2c bus module. + * Returns: + * EOK success + * EIO failure + */ + int (*bus_reset)(void *hdl); +} i2c_master_funcs_t; + +#define I2C_MASTER_GETFUNCS "i2c_master_getfuncs" + +/* + * Fills in the given table with the hardware-specific functions. + * If a function table entry is unimplemented, it should + * be left unchanged (and not set to NULL, etc.). + * "funcs->size" should be set by whomever has allocated the + * table. Don't change this. + * Parameters: + * (i/o) funcs Function table + * (in) tabsize size of "funcs" in bytes + * Returns: + * 0 success + * -1 failure + */ +typedef int (i2c_master_getfuncs_f)(i2c_master_funcs_t *funcs, int tabsize); +i2c_master_getfuncs_f i2c_master_getfuncs; + +#define I2C_ADD_FUNC(tabletype, table, entry, func, limit) \ + if (((size_t)&(((tabletype *)0)->entry)) + \ + sizeof (void (*)()) <= (limit)) \ + (table)->entry = (func); + +#endif + +#if defined(__QNXNTO__) && defined(__USESRCVERSION) +#include +__SRCVERSION("$URL: http://svn.ott.qnx.com/product/branches/6.5.0/trunk/lib/i2c/public/hw/i2c.h $ $Rev: 771780 $") +#endif diff --git a/TSCP/src/MSCP/CFM/CFM_Net.c b/TSCP/src/MSCP/CFM/CFM_Net.c new file mode 100644 index 0000000..a663b6c --- /dev/null +++ b/TSCP/src/MSCP/CFM/CFM_Net.c @@ -0,0 +1,4142 @@ +/** +* @file CFM_Net.c +* @brief Communication Function Module: 网络通信功能 +* @details +* 2oo2、2x2、内网、外网、校时、同步等的以太网通信实现 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "CFM_Net.h" +#include "CM_Convert.h" +#include "CM_Memory.h" +#include "CM_MQ.h" +#include "CM_UDP.h" +#include "CM_TCP.h" +#include "CM_MultiThread.h" +#include "CM_Mutex.h" +#include "CM_Atomic.h" +#include "CM_CRC32.h" +#include "CM_Time.h" +#include "DFM_Time.h" +#include "DFM_DRV.h" +#include "PFM_Cfg.h" +#include "PFM_Log.h" +#include "SFM_2x2.h" +#include "SFM_2oo2.h" +#include "CM_Com.h" +#include "CM_Sem.h" +#include "CM_Queue.h" +#include "MSCP_APP_Interface.h" +#include "PFM_RemoteUpdate.h" +#include "MSCP_Define.h" +#include + +#define CFM_2oo2_MSG_NUM_MAX (200u) +#define CFM_2X2_MSG_NUM_MAX (200u) +#define CFM_OUTNET_MSG_NUM_MAX (5000u) +#define CFM_OUTHEART_MSG_NUM_MAX (20u) +#define CFM_INNET_SAFE_MSG_NUM_MAX (40u) + + +#define CFM_INNET_SAFE_MSG_SIZE (5120u) +#define CFM_INNET_RAW_MSG_SIZE (2048u) +#define CFM_OUTNET_SAFE_MSG_SIZE (5120u) +#define CFM_OUTNET_RAW_MSG_SIZE (5120u) +#define CFM_OUTNET_HEART_MSG_SIZE (1000u) +#define CFM_SYN_MSG_SIZE (1000u) + +/*暗文临时日志大小 和 ctrl队列大小*/ +#define CFM_INNET_LOG_MSG_SIZE_DARK (1024u * 80u) /* 暗文日志大小,ZC要求是80000(78*1024)字节 */ +#define CFM_INNET_LOG_MSG_SIZE (5120u) /* 明文消息队列大小 */ +/*日志攒包发送 攒包大小*/ +#define LOG_MAX (5120u) + +/** 接收线程控制 */ +typedef struct +{ + CM_CHAR IP[32]; /**< 本机IP */ + CM_UINT16 port; /**< 本机端口 */ + CM_SOCKET* pSock; /**< socket */ + CM_UINT32 rmtIP; /**< 对端IP,0表示不指定 */ + CM_UINT32 rmtPort; /**< 对端端口*/ + CM_UINT8 cache_buf[NET_UDP_BUF_SIZE]; /**< udp接收缓冲区 */ + CM_MQ_Struct_T MsgQ; /**< 接收消息队列 */ + /*通过透传算法选配*/ + CM_INT32 ch; /**< 通道ID */ + CM_MQ_Struct_T InfoQ; /**< 埃弗瑞雷达报文用 */ + CM_MUTEX_T mutex; /**< 互斥信号量,用来保护MsgQ和InfoQ */ + CM_MUTEX_T clear_mutex; /**< 互斥信号量,用来清空保护MsgQ和InfoQ */ + RAW_ALGORITHM ALGORITHM_Fun; /** 时间戳解析算法注册指针*/ + /*通过tcp使能开关选配*/ + CM_UINT16 Tcpid; /**< TcpID */ + CM_INT32 Offset; /**< tcp接收缓冲区偏移量 */ + CM_UINT8 threadNumBer; /* 线程号 */ +}STRU_CFM_RECV_CTRL_T; +/** LOG线程结构体 */ +typedef struct +{ + CM_CHAR rmtIP[32]; /**< 对端IP,0表示不指定 */ + CM_UINT16 rmtPort; /**< 对端端口*/ + CM_SOCKET* pSock; /**< socket */ + CM_MQ_Struct_T MsgQ; /**< 接收消息队列 */ +}STRU_CFM_SEND_LOG; +/** 暗文LOG线程结构体 */ +typedef struct +{ + CM_CHAR rmtIP[32]; /**< 对端IP,0表示不指定 */ + CM_UINT16 rmtPort; /**< 对端端口*/ + CM_SOCKET* pSock; /**< socket */ + STRU_CM_QUEUE_T MsgQ; /**< 接收消息队列 */ +}STRU_CFM_SEND_DARKLOG; + +/** 2乘线程控制*/ +static STRU_CFM_RECV_CTRL_T s_CFM_Rx2x2; /**< 2x2数据通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_State2x2; /**< 2x2数据通信接收线程控制 */ +/** 2取线程控制*/ +static STRU_CFM_RECV_CTRL_T s_CFM_Rx2oo2; /**< 2oo2数据通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_Rx2oo2_App; /**< 应用2oo2数据通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_Rx2oo2Mainteance; /**< 2oo2维护数据通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_Rx2oo2_State; /**< 2oo2维护数据通信接收线程控制 */ +/** 其他通信线程控制*/ +static STRU_CFM_RECV_CTRL_T s_CFM_RxInnetSafe; /**< 内网安全通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_RxRemoteUpdate; /**< 内网远程部署安全通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_RxInnetRaw[INNET_RAW_DOUBLE_PASS_NUM]; /**< 内网透传通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_RxOutnetSafe; /**< 外网安全通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_RxOutnetRaw; /**< 外网透传通信接收线程控制 */ +static STRU_CFM_RECV_CTRL_T s_CFM_RxOutnetHeart; /**< 外网心跳通信接收线程控制 */ + +static STRU_CFM_SEND_LOG s_CFM_Send_LogStr; /**< 日志队列管理 */ +/* 暗文log管理信息 */ +STRU_LOG_CTRL_T ciphertextCtrl; +static STRU_CFM_SEND_DARKLOG s_Log_CtrlQ; + +/*注册透传算法函数指针数组*/ +RAW_ALGORITHM p_ALGORITHM_Fun[INNET_RAW_DOUBLE_PASS_NUM] = {NULL}; +/** 时钟同步控制 */ +typedef struct +{ + CM_CHAR IP[32]; /* 本机IP */ + CM_UINT16 port; /* 本机端口 */ + CM_SOCKET* pSock; /* 本地socket */ + + /* + * delay和offset受互斥信号量mutex保护, + * 读写delay和offset时需要先取得互斥信号量 + */ + CM_MUTEX_T mutex; /* 互斥信号量 */ + ENUM_CM_RETURN isOK; /* 校时成功标志 */ + CM_INT64 delay; /* 延迟时间 */ + CM_INT64 offset; /* 偏移时间 */ + +}STRU_CFM_TIME_CTRL_T; + +/** 周期同步控制 */ +typedef struct +{ + CM_CHAR IP[32]; /* 本机IP */ + CM_UINT16 port; /* 本机端口 */ + CM_SOCKET* pSock; /* 本地socket */ + + CM_MUTEX_T mutex; /* 互斥信号量 */ + /*以下变量受互斥信号量保护*/ + CM_INT32 rxLen; /* 接收报文长度 */ + CM_UINT8 rxBuf[CFM_SYN_MSG_SIZE]; /* 接收报文 */ + CM_UINT64 rxTick; /* 同步报文接收时刻 */ + /*以上变量受互斥信号量保护*/ +}STRU_CFM_SYN_CTRL_T; + +/** 通信层socket管理 */ +typedef struct +{ + CM_SOCKET Sock_2oo2_Time; /**< 2oo2校时socket */ + CM_SOCKET Sock_2oo2_Data; /**< 2oo2数据通信socket */ + CM_SOCKET Sock_2oo2_Data_App; /**< 应用2oo2数据通信socket */ + CM_SOCKET Sock_2oo2_Maintenance; /**< 2oo2维护模式socket */ + CM_SOCKET Sock_2oo2_2x2_State; /**< 2oo2上电同步socket */ + + CM_SOCKET Sock_2x2_Time; /**< 2x2校时socket */ + CM_SOCKET Sock_2x2_Data; /**< 2x2数据通信socket */ + CM_SOCKET Sock_2x2_Syn; /**< 2x2周期同步socket */ + CM_SOCKET Sock_2x2_State; /**< 2x2状态切换socket */ + + CM_SOCKET Sock_InnetSafe; /**< 内网安全通信socket */ + CM_SOCKET Sock_OutnetSafe; /**< 外网安全通信socket */ + CM_SOCKET Sock_OutnetRaw; /**< 外网透传通信socket */ + CM_SOCKET Sock_OutnetHeart; /**< 外网心跳通信socket */ + + CM_INT32 num_InnetRaw; /**< 内网透传端口数量 */ + CM_INT32 num_InnetRaw_Extend;/**< 内网透传扩展端口数量 */ + CM_SOCKET Sock_InnetRaw[INNET_RAW_DOUBLE_PASS_NUM]; /**< 内网透传通信socket */ + + CM_SOCKET Sock_LogBase; /**< 平台明文socket */ + CM_SOCKET Sock_LogCiphertext; /**< 平台应用暗文日志socket */ + + CM_SOCKET Sock_Remote_Update; /**< 远程部署socket */ +}STRU_CFM_SOCKS_T; + +static STRU_CFM_SOCKS_T s_CFM_Sock; /**< 通信层socket管理 */ + +static STRU_CFM_TIME_CTRL_T s_CFM_2oo2_Time; /**< 2oo2时钟同步控制 */ +static STRU_CFM_TIME_CTRL_T s_CFM_2x2_Time; /**< 2x2时钟同步控制 */ +static STRU_CFM_SYN_CTRL_T s_CFM_2x2_Syn; /**< 2x2周期同步控制 */ + +static CM_UINT8 s_CFM_UDP_Cache[65535]; /**< 临时缓冲区 */ + +static CM_UINT16 g_CFM_OSCache_ClearNum; +static CM_UINT32 g_CFM_OSCache_Len; +/*硬重启通信状态结构体*/ +STRU_HARDWARE_BOOT_COM_T g_Hardware_boot_com_state; +/** +* @brief 2oo2相关网络通信初始化 +*/ +static void s_NetInit_2oo2(void); +/** +* @brief 通用2oo2数据发送 +* @param pBuf 发送报文指针 取值范围:非空 +* @param BufLen 发送报文长度 取值范围:0~0x7FFFFFFF +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +static ENUM_CM_RETURN CFM_2oo2_Send_Currency(IN CM_SOCKET sock,IN const CM_UINT8* pBuf, IN CM_INT32 BufLen,IN CM_UINT16 nPortDest); + +/** +* @brief 2oo2重传请求与应答ACK发送 +* @param pBuf 发送报文指针 +* @param BufLen 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +static ENUM_CM_RETURN CFM_2oo2_SendARQ_Currency(STRU_2OO2_NET_NO_PACK_T *p_2oo2_Ctrl,ENUM_2oo2_NET_T msgType); + +/** +* @brief 2x2相关网络通信初始化 +*/ +static void s_NetInit_2x2(void); + +/** +* @brief 周期同步线程 +* @param arg 指向STRU_CFM_SYN_CTRL的指针 +* @return 线程函数返回值(实际永远不会返回) +* @details +* 创建本线程之前应先配置好STRU_CFM_SYN_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收周期同步报文、并记录收到报文的精确时间 +* @see :: CFM_2x2_SyncSend +* @see :: CFM_2x2_SyncRecv +*/ +static CM_THREAD_FUNC_T t_SyncThread(IN CM_Thread_Arg_Struct_T* arg); + +/*********************************内网通信相关*****************************************/ + +/** +* @brief 内网通信初始化 +*/ +static void s_NetInit_Innet(void); + +/** +* @brief UDP透传接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收UDP报文并写入线程接收队列 +*/ +static CM_THREAD_FUNC_T t_UdpRawRecvThread(IN CM_Thread_Arg_Struct_T* arg); + +/** +* @brief TCP接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以非阻塞方式接收TCP报文并写入线程接收队列 +*/ +static CM_THREAD_FUNC_T t_TcpRecvThread(IN CM_Thread_Arg_Struct_T* arg); + +/*********************************外网通信相关*****************************************/ + +/** +* @brief 外网通信初始化 +*/ +static void s_NetInit_Outnet(void); + +/* 维护网通信初始化 */ +static void s_NetInit_Maintain(void); + +/** +* @brief 日志发送线程 +* @param arg 指向STRU_CFM_TIME_CTRL的指针 +* @return 线程函数返回值(实际永远不会返回) +* @details +*/ +static CM_THREAD_FUNC_T t_LogSendThread(IN CM_Thread_Arg_Struct_T* arg); + +/* 远程部署通信初始化 */ +static void s_NetInit_RemoteUpdate(void); + +/** +* @brief UDP接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收UDP报文并写入线程接收队列 +*/ +static CM_THREAD_FUNC_T t_UdpRecvThread(IN CM_Thread_Arg_Struct_T* arg); +/** +* @brief 维护模式下UDP接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收UDP报文并写入线程接收队列 +*/ +static CM_THREAD_FUNC_T t_UdpRecvMaintenanceThread(IN CM_Thread_Arg_Struct_T* arg); + +/** +* @brief 时钟同步线程 +* @param arg 指向STRU_CFM_TIME_CTRL的指针 +* @return 线程函数返回值(实际永远不会返回) +* @details +* 创建本线程之前应先配置好STRU_CFM_TIME_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收时钟同步报文并作出应答 +* 收到请求报文时立即给出应答 +* 收到应答报文时记录并计算延迟时间、偏移时间 +* @see :: CFM_2oo2_TimeReq +* @see :: CFM_2oo2_TimeGet +*/ +static CM_THREAD_FUNC_T t_TimeThread(IN CM_Thread_Arg_Struct_T* arg); + +/** +* @brief 远程部署接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收远程部署命令UDP报文,然后进行相关处理 +*/ +static CM_THREAD_FUNC_T t_RemoteUpdateThread(IN CM_Thread_Arg_Struct_T* arg); + +static CM_THREAD_FUNC_T t_ClearArpThread(void); +/*********************************2取相关*****************************************/ +/** +* @brief 2oo2相关网络通信初始化 +*/ +static void s_NetInit_2oo2(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 临时变量 */ + CM_INT32 val = 0; /* 临时变量 */ + CM_BOOL rtCheck = CM_FALSE; /* 临时变量 */ + + /*- 创建时间同步socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2oo2_Time, CM_FALSE,(CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2oo2), g_PFM_Cfg.Local_Cfg.Port_2oo2_Time, 0u, (CM_UINT8)0u); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + /*- 创建平台数据2取socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2oo2_Data, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2oo2), g_PFM_Cfg.Local_Cfg.Port_2oo2_Data, 0u, (CM_UINT8)0u); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + /*- 创建应用数据2取socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2oo2_Data_App, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2oo2), g_PFM_Cfg.Local_Cfg.Port_2oo2_Data_App, 0u, (CM_UINT8)0u); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + /*- 创建2x状态2取socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2oo2_2x2_State, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2oo2), g_PFM_Cfg.Local_Cfg.Port_2oo2_2x2_State,0u, (CM_UINT8)0u); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_6); + + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /*- 创建维护模式下的2取socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2oo2_Maintenance, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2oo2), g_PFM_Cfg.Local_Cfg.Port_2oo2_Maintenance, 0u, (CM_UINT8)0u); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_18); + } + else + { + /*- 无处理 */ + } + + /*- 配置socket */ + val = (CM_INT32)NET_UDP_BUF_DOUBLESIZE; + (void)setsockopt(s_CFM_Sock.Sock_2oo2_Data, SOL_SOCKET, SO_RCVBUF, (void*)(&val), (unsigned int)sizeof(val)); + (void)setsockopt(s_CFM_Sock.Sock_2oo2_Data, SOL_SOCKET, SO_SNDBUF, (void*)(&val), (unsigned int)sizeof(val)); + (void)setsockopt(s_CFM_Sock.Sock_2oo2_Data_App, SOL_SOCKET, SO_RCVBUF, (void*)(&val), (unsigned int)sizeof(val)); + (void)setsockopt(s_CFM_Sock.Sock_2oo2_Data_App, SOL_SOCKET, SO_SNDBUF, (void*)(&val), (unsigned int)sizeof(val)); + /*- 初始化控制信息 */ + CM_NM_ASSERT(s_CFM_2oo2_Time.IP != NULL, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_7); + (void)sprintf(s_CFM_2oo2_Time.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2oo2); + s_CFM_2oo2_Time.port = g_PFM_Cfg.Local_Cfg.Port_2oo2_Time; + s_CFM_2oo2_Time.pSock = &s_CFM_Sock.Sock_2oo2_Time; + rt = CM_Mutex_Init(&s_CFM_2oo2_Time.mutex); + CM_NM_ASSERT(ENUM_CM_TRUE == rt,NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_8); + + /*- 启动2oo2时钟同步线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_TimeThread, "2oo2_T", 0, CM_TASK_PRIORITY_72, (CM_Thread_Arg_Struct_T*)&s_CFM_2oo2_Time); + CM_NM_ASSERT(CM_TRUE == rtCheck, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_11); + + /*- 配置接收线程 */ + CM_NM_ASSERT(s_CFM_Rx2oo2.IP != NULL, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_9); + (void)sprintf(s_CFM_Rx2oo2.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2oo2); + s_CFM_Rx2oo2.port = g_PFM_Cfg.Local_Cfg.Port_2oo2_Data; + s_CFM_Rx2oo2.pSock = &s_CFM_Sock.Sock_2oo2_Data; + s_CFM_Rx2oo2.rmtIP = inet_addr(g_PFM_Cfg.Peer_Cfg.IP_2oo2); + s_CFM_Rx2oo2.rmtPort = g_PFM_Cfg.Peer_Cfg.Port_2oo2_Data; + rt = CM_MQ_Init(&s_CFM_Rx2oo2.MsgQ, (CM_UINT16)CFM_2oo2_MSG_NUM_MAX, (CM_UINT16)NET_UDP_2OO2_BUF_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_10); + /*- 启动2oo2接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "2oo2_Rx", 0, CM_TASK_PRIORITY_73, (CM_Thread_Arg_Struct_T*)&s_CFM_Rx2oo2); + CM_NM_ASSERT(CM_TRUE == rtCheck, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_12); + + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + CM_NM_ASSERT(s_CFM_Rx2oo2Mainteance.IP != NULL, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_19); + (void)sprintf(s_CFM_Rx2oo2Mainteance.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2oo2); + s_CFM_Rx2oo2Mainteance.port = g_PFM_Cfg.Local_Cfg.Port_2oo2_Maintenance; + s_CFM_Rx2oo2Mainteance.pSock = &s_CFM_Sock.Sock_2oo2_Maintenance; + s_CFM_Rx2oo2Mainteance.rmtIP = inet_addr(g_PFM_Cfg.Peer_Cfg.IP_2oo2); + s_CFM_Rx2oo2Mainteance.rmtPort = g_PFM_Cfg.Peer_Cfg.Port_2oo2_Maintenance; + rt = CM_MQ_Init(&s_CFM_Rx2oo2Mainteance.MsgQ, (CM_UINT16)CFM_2oo2_MSG_NUM_MAX, (CM_UINT16)NET_UDP_MAINTENANCE_BUF_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_20); + /*- 启动2oo2维护接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvMaintenanceThread, "2oo2_Maintenance", 0, CM_TASK_PRIORITY_89, (CM_Thread_Arg_Struct_T*)&s_CFM_Rx2oo2Mainteance); + CM_NM_ASSERT(CM_TRUE == rtCheck, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_21); + } + else + { + /*- 无处理 */ + } + + /*- 配置接收线程 */ + CM_NM_ASSERT(s_CFM_Rx2oo2_App.IP != NULL, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_14); + (void)sprintf(s_CFM_Rx2oo2_App.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2oo2); + s_CFM_Rx2oo2_App.port = g_PFM_Cfg.Local_Cfg.Port_2oo2_Data_App; + s_CFM_Rx2oo2_App.pSock = &s_CFM_Sock.Sock_2oo2_Data_App; + s_CFM_Rx2oo2_App.rmtIP = inet_addr(g_PFM_Cfg.Peer_Cfg.IP_2oo2); + s_CFM_Rx2oo2_App.rmtPort = g_PFM_Cfg.Peer_Cfg.Port_2oo2_Data_App; + s_CFM_Rx2oo2_App.threadNumBer = (CM_UINT8)ENUM_THREAD_2oo2_AppRecv; + rt = CM_MQ_Init(&s_CFM_Rx2oo2_App.MsgQ, (CM_UINT16)CFM_2oo2_MSG_NUM_MAX, (CM_UINT16)NET_UDP_2OO2_BUF_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_15); + /*- 启动2oo2接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "2oo2_Rx_App", 0, CM_TASK_PRIORITY_73, (CM_Thread_Arg_Struct_T*)&s_CFM_Rx2oo2_App); + CM_NM_ASSERT(CM_TRUE == rtCheck, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_16); + + /*- 配置接收线程 */ + CM_NM_ASSERT(s_CFM_Rx2oo2_State.IP != NULL, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_22); + (void)sprintf(s_CFM_Rx2oo2_State.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2oo2); + s_CFM_Rx2oo2_State.port = g_PFM_Cfg.Local_Cfg.Port_2oo2_2x2_State; + s_CFM_Rx2oo2_State.pSock = &s_CFM_Sock.Sock_2oo2_2x2_State; + s_CFM_Rx2oo2_State.rmtIP = inet_addr(g_PFM_Cfg.Peer_Cfg.IP_2oo2); + s_CFM_Rx2oo2_State.rmtPort = g_PFM_Cfg.Peer_Cfg.Port_2oo2_2x2_State; + rt = CM_MQ_Init(&s_CFM_Rx2oo2_State.MsgQ, (CM_UINT16)CFM_2oo2_MSG_NUM_MAX, (CM_UINT16)CFM_INNET_RAW_MSG_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_23); + /*- 启动2oo2接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "2oo2_Rx", 0, CM_TASK_PRIORITY_73, (CM_Thread_Arg_Struct_T*)&s_CFM_Rx2oo2_State); + CM_NM_ASSERT(CM_TRUE == rtCheck, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_24); + CM_Sleep(100u);/* 延时等待线程启动 */ +} +/** +* @brief 2oo2上电同步 +* @details +*/ +ENUM_CM_RETURN CFM_2oo2_InitSync(void) +{ + /*- 变量初始化 */ + + + CM_UINT8 syn[10] = "SYN"; /* 同步报文 */ + CM_UINT8 rxBuf[1500]; /* 接收缓冲区 */ + CM_INT32 rxLen = 0; /* 接收长度 */ + ENUM_CM_RETURN SyncFlag = ENUM_CM_FALSE; /* 同步标记 */ + CM_UINT64 costStart = 0u; /* 60000*/ + CM_UINT64 costEnd = 0u; + CM_UINT64 timeResult = 0u; + /* + 为提高执行效率和精度,所有同步、校时报文都是短小的无保护报文, + 而周期逻辑中的同步校验报文是有充分安全保护的, + 从而确保程序执行的安全性 + */ + costStart = CM_GetTick(); + MSCP_LOG_MSG("costStart == %lld\n",costStart); + /*- 与邻机交换校验帧 */ + rxLen = SFM_2oo2_Exchange_Currency(syn, 3, rxBuf, (CM_UINT8)sizeof(rxBuf), NUM_2oo2_FIRSTSYNC); + /*- 校验帧长度是否相同 */ + costEnd = CM_GetTick(); + /*- 超过了1分钟未收到邻机数据 */ + if(costEnd - costStart > 60000000000u) + { + /*- 置为同步失败 */ + timeResult = (costEnd - costStart)/1000000000u; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_CFMNET_ININTSYNC_TIMEOUT, 8U, &timeResult); + MSCP_LOG_MSG("timeResult == %lld\n", timeResult); + CM_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_32, TSCP_DARK_ASSERT_1); + } + /*- 收到了正确的上电同步报文 */ + else if((3 == rxLen) && (0 == CM_Memcmp(rxBuf, syn, (CM_SIZE_T)3))) + { + /*- 置位同步成功 */ + SyncFlag = ENUM_CM_TRUE; + } + /*- 未收到正确数据 */ + else + { + /*- 接收数据错误宕机 */ + CM_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_32, TSCP_DARK_ASSERT_2); + } + /*- 返回同步结果 */ + return SyncFlag; +} + +/** +* @brief 发起一次2oo2时钟同步 +* @details +* 发送一个2oo2时钟同步请求报文 +* 由双方的时钟同步线程完成一次NTP校时操作 +* 操作完成后本方的时钟同步线程会记录到延迟时间和偏移时间 +* @see :: CFM_2oo2_TimeGet +* @see :: t_TimeThread +*/ +void CFM_2oo2_TimeReq(void) +{ + /*- 变量初始化 */ + CM_UINT8 buf[100]; + CM_INT32 len = 0; + CM_ATOMIC CM_UINT64 tick = 0u; + + /*- 生成时钟同步请求报文 */ + len = 9; + buf[0] = (CM_UINT8)ENUM_TIME_REQ; + + tick = DFM_GetCycTick(); + + CM_64ToChar(tick, buf + 1); + /*- 发送时钟同步请求报文 */ + (void)CM_UDP_Send_Msg(s_CFM_Sock.Sock_2oo2_Time, buf, len, inet_addr(g_PFM_Cfg.Peer_Cfg.IP_2oo2),g_PFM_Cfg.Peer_Cfg.Port_2oo2_Time); +} + +/** +* @brief 读取时钟同步结果 +* @param pDelay 延迟时间 +* @param pOffset 偏移时间 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2oo2_TimeGet(OUT CM_INT64* pDelay, OUT CM_INT64* pOffset) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 锁定互斥锁 */ + rt = CM_Mutex_Lock(s_CFM_2oo2_Time.mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_15, TSCP_DARK_ASSERT_1); + /*- 是否保存了时钟同步结果 */ + if (ENUM_CM_TRUE == s_CFM_2oo2_Time.isOK) + { + /*- 读取时钟同步结果 */ + *pDelay = s_CFM_2oo2_Time.delay; + *pOffset = s_CFM_2oo2_Time.offset; + /*- 清除时钟同步结果 */ + s_CFM_2oo2_Time.isOK = ENUM_CM_FALSE; + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 释放互斥锁 */ + rt = CM_Mutex_Unlock(s_CFM_2oo2_Time.mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_15, TSCP_DARK_ASSERT_2); + /*- 返回执行结果 */ + return rt; +} +/** +* @brief 通用2oo2数据发送 +* @param pBuf 发送报文指针 取值范围:非空 +* @param BufLen 发送报文长度 取值范围:0~0x7FFFFFFF +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +static ENUM_CM_RETURN CFM_2oo2_Send_Currency(IN CM_SOCKET sock,IN const CM_UINT8* pBuf, IN CM_INT32 BufLen,IN CM_UINT16 nPortDest) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入参指针防空 */ + if(NULL != pBuf) + { + /*- UDP方式通过2oo2数据通信通道向邻机发送 */ + rt = CM_UDP_Send_Msg(sock, pBuf, BufLen, inet_addr(g_PFM_Cfg.Peer_Cfg.IP_2oo2),nPortDest); + } + else + { + /*空指针返回失败*/ + } + /*- 返回发送结果 */ + return rt; +} +/** +* @brief 2oo2重传请求与应答ACK发送 +* @param pBuf 发送报文指针 +* @param BufLen 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +static ENUM_CM_RETURN CFM_2oo2_SendARQ_Currency(STRU_2OO2_NET_NO_PACK_T *p_2oo2_Ctrl,ENUM_2oo2_NET_T msgType) +{ + CM_UINT8 sendbuf[20] = {0}; + CM_UINT32 SysCyc = DFM_GetBirthCount(); /*平台周期号*/ + /* + 2oo2通信帧格式: + 4字节 长度(不含自身) + 4字节 周期号 + 4字节 序列号 + 1字节 类型 + */ + CM_LongToChar(9u, &sendbuf[0]); /* 长度(暂时填写满帧) */ + CM_LongToChar(SysCyc, &sendbuf[4]); /* 周期号 */ + CM_LongToChar(p_2oo2_Ctrl->SN, &sendbuf[8]); /* 序列号 */ + sendbuf[12] = (CM_UINT8)msgType; /* 类型 */ + + /*- 返回发送结果 */ + return p_2oo2_Ctrl->DataSend(sendbuf,13u); +} +/** +* @brief 2oo2数据发送 +* @param pBuf 发送报文指针 +* @param BufLen 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2oo2_DataSend(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen) +{ + /*- 指针防空*/ + CM_ASSERT(NULL != pBuf, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_31, TSCP_DARK_ASSERT_1); + /*- 返回发送结果 */ + return CFM_2oo2_Send_Currency(s_CFM_Sock.Sock_2oo2_Data,pBuf, BufLen,g_PFM_Cfg.Peer_Cfg.Port_2oo2_Data); +} + +/** +* @brief 2oo2数据接收 +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_2oo2_DataRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + /*- 指针防空*/ + /*- 变量初始化 */ + CM_UINT16 len = (CM_UINT16)((BufSize > 65535u) ? 65535u : BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 指针防空*/ + CM_ASSERT(NULL != pBuf, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_19, TSCP_DARK_ASSERT_1); + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_Rx2oo2.MsgQ, s_CFM_Rx2oo2.cache_buf, &len); + /*- 是否获取成功 */ + if ((ENUM_CM_TRUE == rt) && (6u < len)) + { + /*- 输出接收数据 */ + len -= 6u; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_Rx2oo2.cache_buf + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_19, TSCP_DARK_ASSERT_2); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} + +/** +* @brief 2oo2数据发送 +* @param pBuf 发送报文指针 取值范围:非空 +* @param BufLen 发送报文长度 取值范围:0~0x7FFFFFFF +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2oo2_DataSend_App(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen) +{ + /*- 入参指针防空 */ + CM_ASSERT(NULL != pBuf, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_34, TSCP_DARK_ASSERT_1); + /*- 返回发送结果 */ + return CFM_2oo2_Send_Currency(s_CFM_Sock.Sock_2oo2_Data_App,pBuf, BufLen,g_PFM_Cfg.Peer_Cfg.Port_2oo2_Data_App); +} + +/** +* @brief 2oo2数据接收 +* @param pBuf 接收报文指针 取值范围:非空 +* @param BufLen 接收报文缓冲区大小 取值范围:0~0xFFFFFFFF +* @return 接收报文长度 +* - 1~0xFFFFFFFF 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_2oo2_DataRecv_App(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + /*- 指针防空*/ + /*- 变量初始化 */ + CM_UINT16 len = (CM_UINT16)((BufSize > 65535u) ? 65535u : BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 指针防空*/ + CM_ASSERT(NULL != pBuf, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_33, TSCP_DARK_ASSERT_1); + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_Rx2oo2_App.MsgQ, s_CFM_Rx2oo2_App.cache_buf, &len); + /*- 是否获取成功 */ + if ((ENUM_CM_TRUE == rt) && (6u < len)) + { + /*- 输出接收数据 */ + len -= 6u; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_Rx2oo2_App.cache_buf + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_33, TSCP_DARK_ASSERT_2); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} +/** +* @brief 2oo2数据发送 +* @param pBuf 发送报文指针 +* @param BufLen 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2oo2_2xStateSend(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen) +{ + /*- 指针防空*/ + CM_ASSERT(NULL != pBuf, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_38, TSCP_DARK_ASSERT_1); + /*- 返回发送结果 */ + return CFM_2oo2_Send_Currency(s_CFM_Sock.Sock_2oo2_2x2_State,pBuf, BufLen,g_PFM_Cfg.Peer_Cfg.Port_2oo2_2x2_State); +} + +/** +* @brief 2oo2数据接收 +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_2oo2_2xStateRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + /*- 指针防空*/ + /*- 变量初始化 */ + CM_UINT16 len = (CM_UINT16)((BufSize > 65535u) ? 65535u : BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 指针防空*/ + CM_ASSERT(NULL != pBuf, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_39, TSCP_DARK_ASSERT_1); + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_Rx2oo2_State.MsgQ, s_CFM_Rx2oo2_State.cache_buf, &len); + /*- 是否获取成功 */ + if ((ENUM_CM_TRUE == rt) && (6u < len)) + { + /*- 输出接收数据 */ + len -= 6u; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_Rx2oo2_State.cache_buf + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_39, TSCP_DARK_ASSERT_2); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} +/** +* @brief 2oo2数据发送(维护模式) +* @param pBuf 发送报文指针 +* @param BufLen 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2oo2_DataSend_Crash(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen) +{ + /*- 返回发送结果 */ + return CFM_2oo2_Send_Currency(s_CFM_Sock.Sock_2oo2_Maintenance,pBuf, BufLen,g_PFM_Cfg.Peer_Cfg.Port_2oo2_Maintenance); +} + + +/** +* @brief 2oo2数据接收(维护模式) +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_2oo2_DataRecv_Crash(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_UINT16 len = (CM_UINT16)((BufSize > 65535u) ? 65535u : BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 指针防空*/ + CM_ASSERT_MAINTAIN(NULL != pBuf); + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_Rx2oo2Mainteance.MsgQ, s_CFM_Rx2oo2Mainteance.cache_buf, &len); + + /*- 是否获取成功 */ + if ((ENUM_CM_TRUE == rt) && (6u < len)) + { + /*- 输出接收数据 */ + len -= 6u; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_Rx2oo2Mainteance.cache_buf + 6), (CM_SIZE_T)len); + CM_ASSERT_MAINTAIN(ENUM_CM_TRUE == rt); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} +/** +* @brief 2oo2数据发送(宕机状态) +* @param pBuf 发送报文指针 +* @param BufLen 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2oo2_DataSend_ASSERT(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen) +{ + /*- 返回发送结果 */ + return CFM_2oo2_Send_Currency(s_CFM_Sock.Sock_2oo2_Data,pBuf, BufLen,g_PFM_Cfg.Peer_Cfg.Port_2oo2_Data); +} + +/** +* @brief 2oo2数据接收(宕机状态) +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_2oo2_DataRecv_ASSERT(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_UINT16 len = (CM_UINT16)((BufSize > 65535u) ? 65535u : BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 指针防空*/ + CM_ASSERT_MAINTAIN(NULL != pBuf); + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_Rx2oo2.MsgQ, s_CFM_Rx2oo2.cache_buf, &len); + /*- 是否获取成功 */ + if ((ENUM_CM_TRUE == rt) && (6u < len)) + { + /*- 输出接收数据 */ + len -= 6u; + (void)CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_Rx2oo2.cache_buf + 6), (CM_SIZE_T)len); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} + +/** +* @breif 全双工不分包2oo2数据交换,支持重传 +* @param pMyData 本机数据指针 +* @param DataLen 本剧数据长度 +* @param pPeerData 邻机数据指针 +* @param DataSize 邻机数据缓冲区大小 +* @param msgTye 2oo2交换数据类型 +* @return 收到的邻机数据长度 +*/ +CM_INT32 CFM_2oo2_Currency_NoSplit(STRU_2OO2_NET_NO_PACK_T *p_2oo2_Ctrl,IN const CM_UINT8 * pMyData, IN CM_INT32 DataLen, OUT CM_UINT8 * pPeerData, IN CM_UINT32 DataSize) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = -1; + CM_INT32 allLen = -1; /* 收到的报文总长度 */ + CM_UINT8 recvBuf[1500] = {0u}; + CM_UINT32 msgLen = 0u; + CM_UINT8 msgType = 0u; + CM_UINT32 msgSN = 0u; + CM_UINT32 msgCyc = 0u; + CM_BOOL mineRcvFlag = CM_FALSE;/*本机接收完成标志*/ + CM_BOOL peerRcvFlag = CM_FALSE;/*对系接收完成标志*/ + /*发送相关*/ + CM_UINT8 sendBuf[1500] = {0u}; + CM_UINT32 sysCyc = DFM_GetBirthCount(); /*平台周期号*/ + + CM_UINT64 curTick = 0u; /* 当前时刻 */ + CM_UINT64 sTick = 0u; /* 起始Tick */ + /*- 入口检查 */ + if((p_2oo2_Ctrl != NULL) && (pMyData != NULL) && (DataLen < 1490) && (pPeerData != NULL)) + { + /*- 更新2oo2通信序列号 */ + p_2oo2_Ctrl->SN++; + /* + 2oo2通信帧格式: + 4字节 长度(不含自身) + 4字节 周期号 + 4字节 序列号 + 1字节 类型 + */ + CM_LongToChar((CM_UINT32)DataLen + 9u, &sendBuf[0]); /* 长度(暂时填写满帧) */ + CM_LongToChar(sysCyc, &sendBuf[4]); /* 周期号 */ + CM_LongToChar(p_2oo2_Ctrl->SN, &sendBuf[8]); /* 序列号 */ + sendBuf[12] = (CM_UINT8)ENUM_2oo2_NET_DATA; /* 类型 */ + (void)CM_Memcpy((void*)(&sendBuf[13]),1490u,pMyData,(CM_SIZE_T)DataLen); + + /*- 发送2oo2数据 */ + (void)p_2oo2_Ctrl->DataSend(sendBuf, DataLen + 13); + /*- 记录起始时间*/ + sTick = CM_GetTick(); + while(1) + { + rxLen = p_2oo2_Ctrl->DataRecv(recvBuf,1500u); + if(rxLen >= 13) + { + msgLen = CM_LongFromChar(&recvBuf[0]); + msgCyc = CM_LongFromChar(&recvBuf[4]); + msgSN = CM_LongFromChar(&recvBuf[8]); + msgType = recvBuf[12]; + if(((msgLen + 4u) == (CM_UINT32)rxLen) + && (msgCyc == sysCyc) + && (msgSN == p_2oo2_Ctrl->SN)) + { + switch((ENUM_2oo2_NET_T)msgType) + { + case ENUM_2oo2_NET_ARQ: + /*- 发送2oo2数据 */ + (void)p_2oo2_Ctrl->DataSend(sendBuf, DataLen + 13); + if(CM_TRUE == mineRcvFlag) + { + (void)CFM_2oo2_SendARQ_Currency(p_2oo2_Ctrl,ENUM_2oo2_NET_RCV_SUCCESS); + } + break; + case ENUM_2oo2_NET_RCV_SUCCESS: + peerRcvFlag = CM_TRUE; + break; + case ENUM_2oo2_NET_DATA: + if(CM_FALSE == mineRcvFlag) + { + /*接收成功*/ + allLen = (CM_INT32)(msgLen - 9u); + (void)CM_Memcpy((void*)pPeerData,DataSize,&recvBuf[13],(CM_SIZE_T)allLen); + mineRcvFlag = CM_TRUE; + (void)CFM_2oo2_SendARQ_Currency(p_2oo2_Ctrl,ENUM_2oo2_NET_RCV_SUCCESS); + (void)CFM_2oo2_SendARQ_Currency(p_2oo2_Ctrl,ENUM_2oo2_NET_RCV_SUCCESS); + (void)CFM_2oo2_SendARQ_Currency(p_2oo2_Ctrl,ENUM_2oo2_NET_RCV_SUCCESS); + } + else + { + /*重复接收无处理*/ + } + break; + default: + /*- 类型错误*/ + break; + } + } + else + { + /*校验错误需要宕机-重传*/ + } + } + else + { + /*- 记录当前时间*/ + CM_Sleep(1); + curTick = CM_GetTick(); + /*- 超时重传,接收成功标志不响应*/ + if((CM_UNSIGNED_MILLION*10u) < (curTick-sTick)) + { + /*发送重传请求*/ + (void)CFM_2oo2_SendARQ_Currency(p_2oo2_Ctrl,ENUM_2oo2_NET_ARQ); + /*- 重置起始时间*/ + sTick = CM_GetTick(); + } + else + { + /*- 无处理 */ + } + } + if((CM_TRUE == mineRcvFlag) && (CM_TRUE == peerRcvFlag)) + { + /*- 结束接收 */ + rxLen = (CM_INT32)msgLen - 9; + break; + } + else + { + /*- 无处理 */ + } + }/*while*/ + } + else + { + rxLen = -1; + } + /*- 返回收到的报文长度 */ + return allLen; +} + + +/*********************************2X相关*****************************************/ + +/** +* @brief 2x2相关网络通信初始化 +*/ +static void s_NetInit_2x2(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 临时变量 */ + CM_INT32 val = 0; /* 临时变量 */ + CM_BOOL rtCheck = CM_FALSE; /* 临时变量 */ + /*- 创建socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2x2_Time, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2x2), g_PFM_Cfg.Local_Cfg.Port_2x2_Time, 0u, (CM_UINT8)0); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2x2_Data, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2x2), g_PFM_Cfg.Local_Cfg.Port_2x2_Data, 0u, (CM_UINT8)0); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2x2_Syn, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2x2), g_PFM_Cfg.Local_Cfg.Port_2x2_Syn, 0u, (CM_UINT8)0); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); + /*- 创建2x状态切换独立线程socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_2x2_State, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_2x2), g_PFM_Cfg.Local_Cfg.Port_2x2_State, 0u, (CM_UINT8)0); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_13); + + /*- 初始化控制信息 */ + CM_ASSERT(s_CFM_2x2_Time.IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_4); + (void)sprintf(s_CFM_2x2_Time.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2x2); + s_CFM_2x2_Time.port = g_PFM_Cfg.Local_Cfg.Port_2x2_Time; + s_CFM_2x2_Time.pSock = &s_CFM_Sock.Sock_2x2_Time; + rt = CM_Mutex_Init(&s_CFM_2x2_Time.mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_5); + + /*- 配置socket */ + val = (CM_INT32)(NET_UDP_BUF_DOUBLESIZE); + (void)setsockopt(s_CFM_Sock.Sock_2x2_Data, SOL_SOCKET, SO_RCVBUF, (void*)(&val), (unsigned int)sizeof(val)); + (void)setsockopt(s_CFM_Sock.Sock_2x2_Data, SOL_SOCKET, SO_SNDBUF, (void*)(&val), (unsigned int)sizeof(val)); + + CM_ASSERT(s_CFM_2x2_Syn.IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_6); + (void)sprintf(s_CFM_2x2_Syn.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2x2); + s_CFM_2x2_Syn.port = g_PFM_Cfg.Local_Cfg.Port_2x2_Syn; + s_CFM_2x2_Syn.pSock = &s_CFM_Sock.Sock_2x2_Syn; + rt = CM_Mutex_Init(&s_CFM_2x2_Syn.mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_7); + + /*- 配置接收线程 */ + CM_ASSERT(s_CFM_Rx2x2.IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_8); + (void)sprintf(s_CFM_Rx2x2.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2x2); + s_CFM_Rx2x2.port = g_PFM_Cfg.Local_Cfg.Port_2x2_Data; + s_CFM_Rx2x2.pSock = &s_CFM_Sock.Sock_2x2_Data; + s_CFM_Rx2x2.rmtIP = inet_addr(g_PFM_Cfg.Partner_Cfg.IP_2x2); + s_CFM_Rx2x2.rmtPort = g_PFM_Cfg.Partner_Cfg.Port_2x2_Data; + rt = CM_MQ_Init(&s_CFM_Rx2x2.MsgQ, (CM_UINT16)CFM_2X2_MSG_NUM_MAX, (CM_UINT16)NET_UDP_2X2_BUF_SIZE); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_9); + + /*-配置状态切换线程 */ + CM_ASSERT(s_CFM_State2x2.IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_14); + (void)sprintf(s_CFM_State2x2.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_2x2); + s_CFM_State2x2.port = g_PFM_Cfg.Local_Cfg.Port_2x2_State; + s_CFM_State2x2.pSock = &s_CFM_Sock.Sock_2x2_State; + s_CFM_State2x2.rmtIP = inet_addr(g_PFM_Cfg.Partner_Cfg.IP_2x2); + s_CFM_State2x2.rmtPort = g_PFM_Cfg.Partner_Cfg.Port_2x2_State; + s_CFM_State2x2.threadNumBer = (CM_UINT8)ENUM_THREAD_2x2_StateRecv; + rt = CM_MQ_Init(&s_CFM_State2x2.MsgQ, (CM_UINT16)CFM_2X2_MSG_NUM_MAX, (CM_UINT16)CFM_2X2_MSG_NUM_MAX); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_15); + + /*- 启动2x2时钟同步线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_TimeThread, "2x2_T", 0, CM_TASK_PRIORITY_76, (CM_Thread_Arg_Struct_T*)&s_CFM_2x2_Time); + CM_ASSERT(CM_TRUE == rtCheck,NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_10); + CM_Sleep(100u);/* 延时等待线程启动 */ + /*- 启动2x2周期同步线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_SyncThread, "2x2_Syn", 0, CM_TASK_PRIORITY_77, (CM_Thread_Arg_Struct_T*)&s_CFM_2x2_Syn); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_16); + CM_Sleep(100u);/* 延时等待线程启动 */ + + /*- 启动2x2平台数据接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "2x2_Rx", 0, CM_TASK_PRIORITY_77, (CM_Thread_Arg_Struct_T*)&s_CFM_Rx2x2); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_11); + /*- 启动2x2平台数据接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "2x2_RxState", 0, CM_TASK_PRIORITY_77, (CM_Thread_Arg_Struct_T*)&s_CFM_State2x2); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_12); + CM_Sleep(100u);/* 延时等待线程启动 */ + +} + +/** +* @brief 2x2状态数据发送 +* @param pBuf 发送报文指针 取值范围:非空 +* @param BufLen 发送报文长度 取值范围:0~0x7FFFFFFF +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2x2_StateChange_Send(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入参指针防空 */ + if(NULL != pBuf) + { + /*- 2x状态切换UDP通信通道向对系发送 */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_2x2_State, pBuf, BufLen, inet_addr(g_PFM_Cfg.Partner_Cfg.IP_2x2),g_PFM_Cfg.Partner_Cfg.Port_2x2_State); + } + else + { + /*空指针返回失败*/ + } + /*- 返回发送结果 */ + return rt; +} + +/** +* @brief 通用2x2状态数据接收 +* @param pBuf 接收报文指针 取值范围:非空 +* @param BufLen 接收报文缓冲区大小 取值范围:0~0xFFFFFFFF +* @return 接收报文长度 +* - 1~0xFFFFFFFF 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_2x2_StateChange_Recv(CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT8 tempBuf[200] = {0}; + CM_RE_ASSERT(NULL != pBuf, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_40, TSCP_DARK_ASSERT_1); + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_State2x2.MsgQ, tempBuf, &len); + /*- 是否获取成功 */ + if ((rt == ENUM_CM_TRUE) && (len > 6u)) + { + /*- 输出接收数据 */ + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(tempBuf), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_40, TSCP_DARK_ASSERT_2); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} +/** +* @brief 发起一次2x2时钟同步 +* @details +* 发送一个2x2时钟同步请求报文 +* 由双方的时钟同步线程完成一次NTP校时操作 +* 操作完成后本方的时钟同步线程会记录到延迟时间和偏移时间 +* @see :: CFM_2x2_TimeGet +* @see :: t_TimeThread +*/ +void CFM_2x2_TimeReq(void) +{ + /*- 变量初始化 */ + CM_UINT8 buf[100]; + CM_INT32 len = 0; + CM_ATOMIC CM_UINT64 tick = 0u; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 生成时钟同步请求报文 */ + len = 9; + buf[0] = (CM_UINT8)ENUM_TIME_REQ; + + tick = DFM_GetCycTick(); + + CM_64ToChar(tick, buf + 1); + /*- 发送时钟同步请求报文 */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_2x2_Time, buf, len, inet_addr(g_PFM_Cfg.Partner_Cfg.IP_2x2), g_PFM_Cfg.Partner_Cfg.Port_2x2_Time); + if(ENUM_CM_TRUE != rt) + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("CFM_2x2_TimeReq UDP_SEND Error!\n"); + } + else + { + /*- 不处理 */ + } +} +/** +* @brief 读取2x2时钟同步结果 +* @param pDelay 延迟时间 +* @param pOffset 偏移时间 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2x2_TimeGet(OUT CM_INT64* pDelay, OUT CM_INT64* pOffset) +{ + + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 指针不为空 */ + if((NULL != pDelay) && (NULL != pOffset)) + { + /*- 锁定互斥锁 */ + rt = CM_Mutex_Lock(s_CFM_2x2_Time.mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_16, TSCP_DARK_ASSERT_1); + /*- 是否保存了时钟同步结果 */ + if (ENUM_CM_TRUE == s_CFM_2x2_Time.isOK) + { + /*- 读取时钟同步结果 */ + *pDelay = s_CFM_2x2_Time.delay; + *pOffset = s_CFM_2x2_Time.offset; + /*- 清除时钟同步结果 */ + s_CFM_2x2_Time.isOK = ENUM_CM_FALSE; + rt = ENUM_CM_TRUE; + } + else + { + //TSCP_DARK_CFMNET_2x2TIMEGET_REDERROR + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("s_CFM_2x2_Time.isOK != ENUM_CM_TRUE\n"); + } + /*- 释放互斥锁 */ + rt = CM_Mutex_Unlock(s_CFM_2x2_Time.mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_16, TSCP_DARK_ASSERT_2); + } + else + { + //TSCP_DARK_CFMNET_2x2TIMEGET_REDNULL + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2)); + MSCP_LOG_MSG("pDelay == NULL || pOffset == NULL\n"); + } + /*- 返回执行结果 */ + return rt; +} +/** +* @brief 周期同步线程 +* @param arg 指向STRU_CFM_SYN_CTRL的指针 +* @return 线程函数返回值(实际永远不会返回) +* @details +* 创建本线程之前应先配置好STRU_CFM_SYN_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收周期同步报文、并记录收到报文的精确时间 +* @see :: CFM_2x2_SyncSend +* @see :: CFM_2x2_SyncRecv +*/ +static CM_THREAD_FUNC_T t_SyncThread(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + STRU_CFM_SYN_CTRL_T* pCtrl = (STRU_CFM_SYN_CTRL_T*)arg; /* 线程参数 */ + CM_UINT32 srcIP = 0u; /* 源IP */ + CM_UINT16 srcPort = 0u; /* 源端口 */ + CM_UINT8 buf[1000] = { 0u }; /* 接收缓冲区 */ + CM_INT32 len; /* 数据长度 */ + CM_UINT64 tick = 0u; /* 精确时间 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + MSCP_LOG_MSG("IP:%s:%d Sync Service Start\n", pCtrl->IP, (CM_INT32)pCtrl->port); + /*- 循环接收同步报文 */ + while (1) + { + /*- 阻塞接收周期同步报文 */ + len = CM_UDP_Recv_Msg(*(pCtrl->pSock), buf, (CM_INT32)sizeof(buf), &srcIP, &srcPort); + tick = CM_GetTick(); + /*- 是否收到有效报文 */ + if (len > 0) + { + /*- 记录报文内容和接收时刻 */ + rt = CM_Mutex_Lock(pCtrl->mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_1); + + pCtrl->rxLen = len; + rt = CM_Memcpy((void*)pCtrl->rxBuf, sizeof(pCtrl->rxBuf), (void*)buf, (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_2); + pCtrl->rxTick = tick; + + rt = CM_Mutex_Unlock(pCtrl->mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_3); + } + else + { + /*- 不处理 */ + } + } + return NULL; +} + +/** +* @brief 2x2同步发送 +* @param pBuf 发送报文指针 +* @param BufLen 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2x2_SyncSend(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /* UDP方式从2x2周期同步通道发送 */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_2x2_Syn, pBuf, BufLen, inet_addr(g_PFM_Cfg.Partner_Cfg.IP_2x2),g_PFM_Cfg.Partner_Cfg.Port_2x2_Syn); + /*- 返回发送结果 */ + return rt; +} + +/** +* @brief 2x2同步接收 +* @param pBuf 接收报文指针 +* @param bufSize 接收缓冲区大小 +* @param pRxTick 接收时刻 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0或负数 接收失败 +*/ +CM_INT32 CFM_2x2_SyncRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 bufSize, OUT CM_UINT64* pRxTick) +{ + /*- 变量初始化 */ + CM_INT32 len = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 锁定互斥信号量 */ + rt = CM_Mutex_Lock(s_CFM_2x2_Syn.mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_18, TSCP_DARK_ASSERT_1); + /*- 是否报文长度大于0且接收缓冲区足够大 */ + if ((s_CFM_2x2_Syn.rxLen > 0) && ((CM_UINT32)s_CFM_2x2_Syn.rxLen <= bufSize)) + { + /*- 输出接收报文 */ + len = s_CFM_2x2_Syn.rxLen; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)bufSize, (void*)s_CFM_2x2_Syn.rxBuf, (CM_SIZE_T)s_CFM_2x2_Syn.rxLen); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_18, TSCP_DARK_ASSERT_2); + *pRxTick = s_CFM_2x2_Syn.rxTick; + + /*- 清除报文长度 */ + s_CFM_2x2_Syn.rxLen = 0; + } + else + { + /*- 无处理 */ + } + /*- 释放互斥信号量 */ + rt = CM_Mutex_Unlock(s_CFM_2x2_Syn.mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_18, TSCP_DARK_ASSERT_3); + /*- 返回报文长度 */ + return len; +} + + + +/** +* @brief 2x2数据发送 +* @param pBuf 发送报文指针 +* @param BufLen 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2x2_DataSend(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- UDP方式从2x2数据通道发送报文 */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_2x2_Data, pBuf, BufLen, inet_addr(g_PFM_Cfg.Partner_Cfg.IP_2x2), g_PFM_Cfg.Partner_Cfg.Port_2x2_Data); + /*- 返回发送结果 */ + return rt; +} +/** +* @brief 2x2串口数据发送 +* @param pBuf 发送报文指针 取值范围(非空) +* @param BufLen 发送报文长度 取值范围(0~0xffffffff) +* @param msgType 发送报文类型 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_NULL 发送条件不满足 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_2x2_UartDataSend(IN CM_UINT8* pBuf, IN CM_UINT16 BufLen) +{ + ENUM_CM_RETURN rtnval = ENUM_CM_FALSE; +#ifdef QNX + /*- 返回发送结果 */ + rtnval = CM_Com_LocalDataSend((CM_UINT8*)pBuf, BufLen); +#else + rtnval = ENUM_CM_TRUE; +#endif + return rtnval; +} +/** +* @brief 2x2数据接收 +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0或负数 接收失败 +*/ +CM_INT32 CFM_2x2_DataRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_Rx2x2.MsgQ, s_CFM_UDP_Cache, &len); + /*- 是否获取成功 */ + if ((rt == ENUM_CM_TRUE) && (len > 6u)) + { + /*- 输出接收数据 */ + len -= 6u; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_20, TSCP_DARK_ASSERT_1); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} +/** +* @brief 2x2串口数据接收 +* @param pBuf 接收报文指针(非空) +* @param BufLen 接收报文缓冲区大小(0~0xffffffff) +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0或负数 接收失败 +*/ +CM_UINT16 CFM_2x2_UartDataRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ +#ifdef QNX + + /*- 返回发送结果 */ + return CM_Com_OtherDataRecv(pBuf, BufSize); +#else + return 0; +#endif +} + +/*********************************内网通信相关*****************************************/ + +/** +* @brief 内网通信初始化 +*/ +static void s_NetInit_Innet(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 临时变量 */ + CM_INT32 rcv_val = 0; /* 临时变量 */ + CM_INT32 send_val = 0; /* 临时变量 */ + CM_INT32 i = 0; /* 循环变量 */ + CM_INT32 bCast = 1; + CM_CHAR *p_tmpIPCom; + CM_BOOL rtCheck = CM_FALSE; + rcv_val = (CM_INT32)NET_UDP_BUF_SIZE; + send_val = (CM_INT32)(NET_UDP_BUF_SIZE); + STRU_PFM_INNET_CFG_T *pCom = NULL; + + /*- 创建安全通信socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_InnetSafe, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_Com), g_PFM_Cfg.Local_Cfg.Port_Innet_Safe, 0u, (CM_UINT8)0); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + (void)setsockopt(s_CFM_Sock.Sock_InnetSafe, SOL_SOCKET, SO_RCVBUF, (void*)(&rcv_val), (unsigned int)sizeof(rcv_val)); + (void)setsockopt(s_CFM_Sock.Sock_InnetSafe, SOL_SOCKET, SO_SNDBUF, (void*)(&send_val), (unsigned int)sizeof(send_val)); + + /*- 配置和启动内网安全通信接收线程 */ + CM_ASSERT(s_CFM_RxInnetSafe.IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + (void)sprintf(s_CFM_RxInnetSafe.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_Com); + s_CFM_RxInnetSafe.port = g_PFM_Cfg.Local_Cfg.Port_Innet_Safe; + s_CFM_RxInnetSafe.pSock = &s_CFM_Sock.Sock_InnetSafe; + s_CFM_RxInnetSafe.rmtIP = 0u; + rt = CM_MQ_Init(&s_CFM_RxInnetSafe.MsgQ, (CM_UINT16)CFM_INNET_SAFE_MSG_NUM_MAX, (CM_UINT16)(CFM_INNET_SAFE_MSG_SIZE)); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "InnetS_Rx", 0, CM_TASK_PRIORITY_77, (CM_Thread_Arg_Struct_T*)&s_CFM_RxInnetSafe); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_4); + CM_Sleep(100u);/* 延时等待线程启动 */ + + s_CFM_Sock.num_InnetRaw = g_PFM_Cfg.Local_Cfg.Port_Innet_Raw_Num; + s_CFM_Sock.num_InnetRaw_Extend = g_PFM_Cfg.Local_Cfg.Port_Innet_Raw_Extend_Num; + /*- @alias 创建透传通信socket */ + for (i = 1; i <= (s_CFM_Sock.num_InnetRaw + s_CFM_Sock.num_InnetRaw_Extend); i++) + { + if(i <= s_CFM_Sock.num_InnetRaw) + { + p_tmpIPCom = g_PFM_Cfg.Local_Cfg.IP_Com; + } + else + { + p_tmpIPCom = g_PFM_Cfg.Local_Cfg.IP_Com_Extend; + } + if(RAW_COM_DISENABLE == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Type_Enable) + { + /*未使能该通道*/ + } + /*是否使能TCP*/ + else if (RAW_COM_TCP == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Type_Enable) + { + /*- 查询服务端IP、端口 */ + pCom = PFM_INI_InnetID2Addr(g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Server_DevId); + CM_ASSERT(NULL != pCom, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_5); + /*- 创建tcp socket */ + if (1u == g_PFM_Cfg.CPU_ID) + { + rt = CM_TCP_Socket_Create(&s_CFM_Sock.Sock_InnetRaw[i], (CM_UINT32)inet_addr(p_tmpIPCom), + g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Innet_Raw, + g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Server_DevId,pCom->IP_G,pCom->Port_Raw_G); + } + else + { + rt = CM_TCP_Socket_Create(&s_CFM_Sock.Sock_InnetRaw[i], (CM_UINT32)inet_addr(p_tmpIPCom), + g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Innet_Raw, + g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Server_DevId,pCom->IP_P,pCom->Port_Raw_P); + } + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_6); + } + else + { + /*UDP通信*/ + if (RAW_COM_BROADCAST == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Type_Enable) + { + bCast = 1;/*广播模式*/ + } + else + { + bCast = 0;/*默认单播组播模式*/ + } + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_InnetRaw[i], + CM_FALSE, + (CM_UINT32)inet_addr(p_tmpIPCom), + g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Innet_Raw, + (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].IP_InnetRaw_maddr), (CM_UINT8)bCast); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_7); + rcv_val = (CM_INT32)NET_UDP_BUF_SIZE*60;/*此处必须开大,用于接收GIGE大数据*/ + (void)setsockopt(s_CFM_Sock.Sock_InnetRaw[i], SOL_SOCKET, SO_RCVBUF, (void*)(&rcv_val), (unsigned int)sizeof(rcv_val)); + (void)setsockopt(s_CFM_Sock.Sock_InnetRaw[i], SOL_SOCKET, SO_SNDBUF, (void*)(&send_val), (unsigned int)sizeof(send_val)); + } + } + + /*- @alias 配置和启动内网透传通信接收线程 */ + for (i = 1; i <= (s_CFM_Sock.num_InnetRaw + s_CFM_Sock.num_InnetRaw_Extend); i++) + { + if(i <= s_CFM_Sock.num_InnetRaw) + { + p_tmpIPCom = g_PFM_Cfg.Local_Cfg.IP_Com; + } + else + { + p_tmpIPCom = g_PFM_Cfg.Local_Cfg.IP_Com_Extend; + } + if(RAW_COM_DISENABLE == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Type_Enable) + { + /*未使能该通道-不开启线程*/ + } + /*是否使能TCP*/ + else if (RAW_COM_TCP == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Type_Enable) + { + /*- 配置接收线程 */ + CM_ASSERT(s_CFM_RxInnetRaw[i].IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_8); + (void)sprintf(s_CFM_RxInnetRaw[i].IP, "%s", p_tmpIPCom); + s_CFM_RxInnetRaw[i].port = g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Innet_Raw; + s_CFM_RxInnetRaw[i].pSock = &s_CFM_Sock.Sock_InnetRaw[i]; + s_CFM_RxInnetRaw[i].ch = i; + if (1u == g_PFM_Cfg.CPU_ID) + { + s_CFM_RxInnetRaw[i].rmtIP = pCom->IP_G; + s_CFM_RxInnetRaw[i].rmtPort = pCom->Port_Raw_G; + } + else + { + s_CFM_RxInnetRaw[i].rmtIP = pCom->IP_P; + s_CFM_RxInnetRaw[i].rmtPort = pCom->Port_Raw_P; + } + s_CFM_RxInnetRaw[i].Tcpid = g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Server_DevId; + s_CFM_RxInnetRaw[i].Offset = (CM_INT32)0; + /*2取使能时间戳队列和解析算法*/ + if((0x55u == (CM_UINT16)g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].INNET_2oo2_RAW) && (0x55u == (CM_UINT16)g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].TIME_STAMP_ENABLE)) + { + rt = CM_MQ_Init(&s_CFM_RxInnetRaw[i].InfoQ, (CM_UINT16)CFM_INNET_RAW_MSG_NUM_MAX, (CM_UINT16)(16)); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_9); + rt = CM_Mutex_Init(&s_CFM_RxInnetRaw[i].mutex); + rt &= CM_Mutex_Init(&s_CFM_RxInnetRaw[i].clear_mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_10); + s_CFM_RxInnetRaw[i].ALGORITHM_Fun = p_ALGORITHM_Fun[i];/*算法注册表*/ + } + else + { + s_CFM_RxInnetRaw[i].ALGORITHM_Fun = NULL;/*未注册空指针*/ + MSCP_LOG_MSG("TCP[%d]-ALGORITHM_Fun is NULL\n",i); + } + rt = CM_MQ_Init(&s_CFM_RxInnetRaw[i].MsgQ, (CM_UINT16)CFM_INNET_RAW_MSG_NUM_MAX, (CM_UINT16)(CFM_INNET_RAW_MSG_SIZE)); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_11); + + /*- 启动外网安全通信接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_TcpRecvThread, "InnetS_Rx_Tcp", 0, CM_TASK_PRIORITY_73, (CM_Thread_Arg_Struct_T*)&s_CFM_RxInnetRaw[i]); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_17); + CM_Sleep(100u);/* 延时等待线程启动 */ + } + else + { + /*UDP通信*/ + CM_ASSERT(s_CFM_RxInnetRaw[i].IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_12); + (void)sprintf(s_CFM_RxInnetRaw[i].IP, "%s", p_tmpIPCom); + s_CFM_RxInnetRaw[i].port = g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Innet_Raw; + s_CFM_RxInnetRaw[i].pSock = &s_CFM_Sock.Sock_InnetRaw[i]; + s_CFM_RxInnetRaw[i].rmtIP = 0u; + s_CFM_RxInnetRaw[i].ch = i; + + rt = CM_MQ_Init(&s_CFM_RxInnetRaw[i].MsgQ, (CM_UINT16)CFM_INNET_RAW_MSG_NUM_MAX, (CM_UINT16)(CFM_INNET_RAW_MSG_SIZE)); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_13); + /*2取使能时间戳队列和解析算法*/ + if((0x55u == (CM_UINT16)g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].INNET_2oo2_RAW) && (0x55u == (CM_UINT16)g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].TIME_STAMP_ENABLE)) + { + rt = CM_MQ_Init(&s_CFM_RxInnetRaw[i].InfoQ, (CM_UINT16)CFM_INNET_RAW_MSG_NUM_MAX, (CM_UINT16)(16)); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_14); + rt = CM_Mutex_Init(&s_CFM_RxInnetRaw[i].mutex); + rt &= CM_Mutex_Init(&s_CFM_RxInnetRaw[i].clear_mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_15); + s_CFM_RxInnetRaw[i].ALGORITHM_Fun = p_ALGORITHM_Fun[i];/*算法注册表*/ + MSCP_LOG_MSG("Init s_CFM_RxInnetRaw[%d]:addr:0x%x\n",i,p_ALGORITHM_Fun[i]); + } + else + { + MSCP_LOG_MSG("UDP[%d]-ALGORITHM_Fun is NULL\n",i); + s_CFM_RxInnetRaw[i].ALGORITHM_Fun = NULL;/*未注册空指针*/ + } + + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRawRecvThread, "InnetR_Rx", 0, CM_TASK_PRIORITY_73, (CM_Thread_Arg_Struct_T*)&s_CFM_RxInnetRaw[i]); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_16); + CM_Sleep(100u);/* 延时等待线程启动 */ + } + } +} +/** +* @brief UDP透传接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收UDP报文并写入线程接收队列 +*/ +static CM_THREAD_FUNC_T t_UdpRawRecvThread(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + STRU_CFM_RECV_CTRL_T* pCtrl = (STRU_CFM_RECV_CTRL_T*)arg; /* 线程控制信息 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT8* rcvBuf = NULL; + CM_INT32 len; /* 报文长度 */ + CM_UINT32 srcIP;/* 源IP */ + CM_UINT16 srcPort;/* 源端口 */ + + CM_UINT32 calccrc = 0u; /* 校验和 */ + + CM_UINT8 *info = NULL;/* 雷达特征信息 */ + CM_UINT8 CompareEnable = 0u;/* 平台比较雷达特征信息 */ +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); + +#endif + MSCP_LOG_MSG("IP:%s:%d UDP Raw recv Start\n", pCtrl->IP, pCtrl->port); + /*- 循环接收UDP数据 */ + while (1) + { + /*- UDP阻塞接收 */ + rcvBuf = CM_MQ_Get_BufAddr(&pCtrl->MsgQ); + if(NULL != rcvBuf) + { + len = CM_UDP_Recv_Msg(*(pCtrl->pSock), &rcvBuf[6u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(pCtrl->MsgQ.maxMsgSize - 6u), &srcIP, &srcPort); + if (len > 0) + { + /*- 源IP端口是否合法 */ + if ((pCtrl->rmtIP == 0u) + || ((srcIP == pCtrl->rmtIP) && (srcPort== pCtrl->rmtPort))) + { + /*- @alias 将收到的报文写入线程接收队列 */ + CM_LongToChar(srcIP, rcvBuf); + CM_ShortToChar(srcPort, &rcvBuf[4u]); + info = CM_MQ_Get_BufAddr(&pCtrl->InfoQ); + if((NULL != (RAW_ALGORITHM)(*pCtrl->ALGORITHM_Fun)) && (NULL != info)) + { + /*解析时间戳等二取数据*/ + rt = (*pCtrl->ALGORITHM_Fun)(&rcvBuf[6u],len,info,&CompareEnable); + if(ENUM_CM_TRUE == rt) + { + if(1u == CompareEnable) + { + /*写入CRC*/ + calccrc = CM_Crc32(&rcvBuf[6u], (CM_UINT32)len); + CM_LongToChar(calccrc, &info[8u]); + (void)CM_Mutex_Lock(pCtrl->mutex); + rt = CM_MQ_UpData(&pCtrl->InfoQ, (CM_UINT16)(12u)); + if (ENUM_CM_TRUE == rt) + { + /*- 保存通信数据 */ + rt = CM_MQ_UpData(&pCtrl->MsgQ,(CM_UINT16)(len + 6)); + if (ENUM_CM_TRUE == rt) + { + /*- 无处理*/ + } + else + { + /*- 防御性清空*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR1, 2, \ + sizeof(CM_UINT16),pCtrl->port, + sizeof(CM_INT32),len); + MSCP_LOG_MSG("port %d rx overflow(msgLen=%d)\n", pCtrl->port, len); + (void)CM_MQ_RollbackData(&pCtrl->InfoQ); + } + } + else + { + /*- 防御性清空*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR2, 2, \ + sizeof(CM_UINT16),pCtrl->port, + sizeof(CM_INT32),len); + MSCP_LOG_MSG("port %d rx overflow(msgLen=%d)\n", pCtrl->port, len); + } + (void)CM_Mutex_Unlock(pCtrl->mutex); + } + else + { + /*不写入CRC*/ + (void)CM_Mutex_Lock(pCtrl->mutex); + rt = CM_MQ_UpData(&pCtrl->InfoQ, (CM_UINT16)(10u)); + if (ENUM_CM_TRUE == rt) + { + rt = CM_MQ_UpData(&pCtrl->MsgQ,(CM_UINT16)(len + 6)); + if (ENUM_CM_TRUE == rt) + { + + } + else + { + /*- 防御性清空*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR3, 2, \ + sizeof(CM_UINT16),pCtrl->port, + sizeof(CM_INT32),len); + MSCP_LOG_MSG("port %d rx overflow(msgLen=%d)\n", pCtrl->port, len); + (void)CM_MQ_RollbackData(&pCtrl->InfoQ); + } + } + else + { + /*- 防御性清空*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR4, 2, \ + sizeof(CM_UINT16),pCtrl->port, + sizeof(CM_INT32),len); + MSCP_LOG_MSG("port %d rx overflow(msgLen=%d)\n", pCtrl->port, len); + } + (void)CM_Mutex_Unlock(pCtrl->mutex); + } + } + else + { + /*解析失败不写入-无操作*/ + } + } + else + { + /*解析指针为空*/ + /*- 保存通信数据 */ + rt = CM_MQ_UpData(&pCtrl->MsgQ,(CM_UINT16)(len + 6)); + if (ENUM_CM_TRUE == rt) + { + /*无操作*/ + } + else + { + /*- 防御性清空*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR5, 2, \ + sizeof(CM_UINT16),pCtrl->port, + sizeof(CM_INT32),len); + MSCP_LOG_MSG("port %d rx overflow(msgLen=%d)\n", pCtrl->port, len); + rt = CM_MQ_Clear(&pCtrl->MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_9); + } + } + } + else + { + /*- 来自非预期IP端口的数据*/ + MSCP_LOG_MSG("Raw port %d rx err [%s:%d]:%d \n", srcIP, srcPort, len); + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_10); + } + } + else + { + /*- 接收出错 */ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR6, 2, \ + sizeof(CM_UINT16),pCtrl->port, + sizeof(CM_INT32),len); + MSCP_LOG_MSG("Raw port %d rx err(len=%d)\n", pCtrl->port, len); + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_11); + } + } + else + { + + if(NULL != (RAW_ALGORITHM)(*pCtrl->ALGORITHM_Fun)) + { + MSCP_LOG_MSG("port %d rx overflow(msgLen=%d) MsgQ is full!\n", pCtrl->port, len); + (void)CM_Mutex_Lock(pCtrl->clear_mutex); + rt = CM_MQ_Clear(&pCtrl->MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_12); + rt = CM_MQ_Clear(&pCtrl->InfoQ); + (void)CM_Mutex_Unlock(pCtrl->clear_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_13); + + } + else + { + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR7, 2, \ + sizeof(CM_UINT16),pCtrl->port, + sizeof(CM_INT32),len); + MSCP_LOG_MSG("port %d rx overflow(msgLen=%d) MsgQ is full!\n", pCtrl->port, len); + rt = CM_MQ_Clear(&pCtrl->MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_14); + + } + } + } + return NULL; +} +/** +* @brief TCP接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以非阻塞方式接收TCP报文并写入线程接收队列 +*/ +static CM_THREAD_FUNC_T t_TcpRecvThread(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + STRU_CFM_RECV_CTRL_T* pCtrl = (STRU_CFM_RECV_CTRL_T*)arg; /* 线程控制信息 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_INT32 len; /* 报文长度 */ + CM_SOCKET tcpsock = -1; /* 临时变量 */ + CM_UINT16 tcpId = 0u; /* 临时变量 */ + CM_UINT32 ServeraddrIP = 0u; /* 临时变量 */ + CM_UINT16 ServerportNumber = 0u; /* 临时变量 */ + CM_UINT32 TcpState = 0u; /* 临时变量 */ + CM_UINT16 ConnectFlag = 0u; /* 临时变量 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 临时结果 */ + CM_INT32 FullFrameSize = 0; /* 临时变量 */ + CM_INT32 Count = 0; /* 临时变量 */ + struct in_addr serveraddr; + CM_UINT64 tick = 0u; /* 精确时间 */ +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); + +#endif + rt = CM_Memcpy((void*) &serveraddr, sizeof(serveraddr), (void*)(&pCtrl->rmtIP), (CM_SIZE_T)4); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_1); + + MSCP_LOG_MSG("Client: IP:%s, Port :%d, Server: IP:%s, Port :%d, Tcpid = %u, Tcp recv Start\n", pCtrl->IP, pCtrl->port,inet_ntoa(serveraddr), pCtrl->rmtPort,pCtrl->Tcpid); + tcpId = pCtrl->Tcpid; + /*- 循环接收TCP数据 */ + while (1) + { + /*- 每次轮询重置连接成功标志为0 */ + ConnectFlag = 0u; + + tick = CM_GetTick(); + tick = tick + (CM_UINT64)(100000000u); + + if(ENUM_2x2_MASTER == SFM_2x2_GetLocal2x2State()) + { + /*- 查询套接字状态 */ + ret = CM_TCP_Msgstate_Query(tcpId, &tcpsock, &TcpState, &ServeraddrIP, &ServerportNumber); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_2); + + if (((CM_UINT32)ENUM_CM_CLOSED == (CM_UINT32)TcpState) || ((CM_UINT32)ENUM_CM_CONNFAIL == (CM_UINT32)TcpState) ) + { + /*- 套接字状态为已断开连接,待创建 */ + /*- 重新创建socket */ + ret = CM_TCP_Socket_Create(&tcpsock,(CM_UINT32)inet_addr(pCtrl->IP), pCtrl->port,tcpId,ServeraddrIP, ServerportNumber); + if (ENUM_CM_TRUE != ret) + { + /*日志记录*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("Create Tcp Socket Fail.\n"); + } + else + { + /*- 建立连接,超时时间为20毫秒 */ + ret = CM_TCP_Socket_Connect(tcpId,(CM_UINT32)20); + if (ENUM_CM_TRUE != ret) + { + /*- 连接失败*/ + /*- 日志记录*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2)); + MSCP_LOG_MSG("Connect Server Fail.\n"); + } + else + { + /*- 连接成功,置连接成功标志为1 */ + ConnectFlag = 1u; + } + } + } + else if((CM_UINT32)ENUM_CM_NOCONN == (CM_UINT32)TcpState) + { + /*- 套接字状态为已创建,未连接 */ + /*- 建立连接,超时时间为20毫秒 */ + ret = CM_TCP_Socket_Connect(tcpId,(CM_UINT32)20); + if (ENUM_CM_TRUE != ret) + { + /*- 连接失败 */ + /*- 日志记录*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3)); + MSCP_LOG_MSG("Connect Server Fail.\n"); + } + else + { + /*- 连接成功,置连接成功标志为1 */ + ConnectFlag = 1u; + } + + } + else if((CM_UINT32)ENUM_CM_CONNECTED == (CM_UINT32)TcpState) + { + /*- 连接成功,置连接成功标志为1 */ + ConnectFlag = 1u; + } + else + { + /*- 无处理 */ + } + /*- 判断连接状态标志为1则接收 */ + if (1u == (CM_UINT16)ConnectFlag) + { + + /*- TCP非阻塞接收 */ + len = CM_TCP_Recv_Msg((CM_UINT16)tcpId, pCtrl->cache_buf + 6 + (CM_INT32)pCtrl->Offset, (CM_INT32)((CM_INT32)sizeof(pCtrl->cache_buf) - 6 - pCtrl->Offset)); + if (0 < len) + { + /*- 将未收到数据计数置为0 */ + Count = 0; + + /*- 拆分完整帧数据 */ + ret = CM_TCP_Find_Full_Frame(pCtrl->cache_buf + 6,len,&FullFrameSize); + if (ENUM_CM_TRUE == ret) + { + + /*- 有完整帧数据 */ + /*- @alias 将收到的完整帧写入线程接收队列 */ + CM_LongToChar(ServeraddrIP, pCtrl->cache_buf); + CM_ShortToChar(ServerportNumber, pCtrl->cache_buf + 4); + + + /*- 保存通信数据 */ + rt = CM_MQ_Write(&pCtrl->MsgQ, pCtrl->cache_buf, (CM_UINT16)CM_SIGNED_SHORT_EXP(FullFrameSize + 6)); + if (ENUM_CM_TRUE == rt) + { + + if (len > FullFrameSize) + { + /*- 保存剩余的数据,供下次使用 */ + (void)CM_Memmove((void*)(pCtrl->cache_buf + 6), (CM_SIZE_T)CM_SIGNED_INT_EXP(sizeof(pCtrl->cache_buf) - 6), (void*)(pCtrl->cache_buf + 6 + FullFrameSize), (CM_SIZE_T)CM_SIGNED_INT_EXP(len - FullFrameSize)); + + /*- 保存偏移量 */ + pCtrl->Offset = len - FullFrameSize; + } + else + { + /*- 正好是完整帧,将偏移量置为0 */ + + + pCtrl->Offset = 0; + } + } + else + { + /*- 防御性清空*/ + + (void)CM_MQ_Clear(&pCtrl->MsgQ); + + /*- 将偏移量置为0 */ + pCtrl->Offset = 0; + } + } + else + { + /*- 没有完整帧数据 */ + /*- 保存偏移量 */ + pCtrl->Offset = len; + } + } + else if(0 == len) + { + + /*- 本次处理未收到数据 */ + + /*- 计数连续3次处理未收到数据,关闭套接字重新创建并连接 */ + Count++; + if (10 == Count) + { + (void)CM_TCP_Socket_Close(tcpId, (CM_UINT32)ENUM_CM_CLOSED); + + /*- 将偏移量置为0 */ + pCtrl->Offset = 0; + + /*- 将未收到数据计数置为0 */ + Count = 0; + } + else + { + /*- 无处理,等待下次轮询处理 */ + } + } + else + { + + /*- 接收出现异常,将偏移量置为0,接收接口里已经关闭了套接字这里不需要关闭 */ + pCtrl->Offset = 0; + } + } + else + { + /*- 无处理,等待下次轮询处理 */ + } + } + else + { + /*非主系*/ + /*可能降为主,判断连接状态,释放连接*/ + /*- 查询套接字状态 */ + ret = CM_TCP_Msgstate_Query(tcpId, &tcpsock, &TcpState, &ServeraddrIP, &ServerportNumber); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_3); + + if ((CM_UINT32)ENUM_CM_CONNECTED == TcpState ) + { + /*释放连接*/ + (void)CM_TCP_Socket_Close(tcpId, (CM_UINT32)ENUM_CM_CLOSED); + + /*- 将偏移量置为0 */ + pCtrl->Offset = 0; + + /*- 将未收到数据计数置为0 */ + Count = 0; + } + else + { + /*无操作*/ + } + } + /* 线程轮询处理,每轮100毫秒 */ + + (void)DFM_WaitUntill(tick); + } + return NULL; +} + +/* @brief 内网透传TCP通信数据发送 +* @param ch 内网透传通道序号,[1...n]有效 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @param DstIP 目的IP +* @param DstPort 目的端口 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_InnetRaw_Tcp_Send(IN CM_UINT16 Tcpid, IN const CM_UINT8* Buf, IN CM_INT32 Len) +{ + /*- 返回内网透传TCP通信通道的发送结果 */ + return CM_TCP_Send_Msg(Tcpid, Buf, Len); +} + +/*读数据时禁止清空(即使写满)*/ +inline void CFM_InnetRawClear_Mutex_Lock(IN CM_INT32 ch) +{ + (void)CM_Mutex_Lock(s_CFM_RxInnetRaw[ch].clear_mutex); +} +inline void CFM_InnetRawClear_Mutex_UnLock(IN CM_INT32 ch) +{ + (void)CM_Mutex_Unlock(s_CFM_RxInnetRaw[ch].clear_mutex); +} +/** +* @brief 获取指定内网透传通道的全部报文特征信息(时间戳和序列号) +* @param ch 通道号 +* @param info 特征信息 +* @param infoSize 特征信息数组的长度 +* @return 特征信息长度 +*/ +CM_UINT32 CFM_InnetRaw_GetInfo(IN CM_INT32 ch, OUT CM_UINT8 info[], IN CM_UINT32 infoSize,OUT CM_UINT8 *CompareEnable) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; + CM_INT32 num = 0; + CM_UINT32 temp_size = 0u; + CM_UINT16 len = 0u; + CM_UINT32 offset = 0u; + num = CM_MQ_Get_Msg_Num(&s_CFM_RxInnetRaw[ch].InfoQ); + CM_RE_ASSERT((CM_UINT32)(num*12) <= infoSize, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_28, TSCP_DARK_ASSERT_1); + if(0 < num) + { + /*- @alias 获取全部特征信息 */ + for (i = 0; i < num; i++) + { + len = 12u; + (void)CM_MQ_Get(&s_CFM_RxInnetRaw[ch].InfoQ, (CM_UINT16)(i), &info[offset], &len); + offset += len; + } + /*如果长度等于时间戳+CRC 12个字节,需要比较*/ + if(12u == len) + { + *CompareEnable = 1u; + } + /*如果长度等于时间戳 10个字节,不需要比较*/ + else if(10u == len) + { + *CompareEnable = 0u; + } + else + { + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_28, TSCP_DARK_ASSERT_2); + } + temp_size = (CM_UINT32)num * len; + CM_RE_ASSERT(offset == temp_size, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_28, TSCP_DARK_ASSERT_3); + } + else + { + *CompareEnable = 1u; + } + /*- 返回读取的特征信息长度 */ + return offset; +} + +/** +* @brief 获取一帧带时间戳的透传数据 +* @param ch 通道号 +* @param bufFirst 帧头 +* @param bufFirstLen 帧头长度 +* @param bufSecond 有效数据 +* @param bufSecondLen 有效数据长度 +* @return 无 +* @details +*/ +ENUM_CM_RETURN CFM_InnetRaw_Rx_MsgInfoQueue(IN CM_INT32 ch, OUT CM_UINT8 bufFirst[], IN CM_UINT32 bufFirstLen, + OUT CM_UINT8 *bufSecond, IN CM_UINT32 *bufSecondLen) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT8* read_addr = NULL; + CM_UINT16 addrBuf_Size = 0u; + /*- 读取通信报文队列和特征信息队列 */ + read_addr = CM_MQ_Read_Addr(&s_CFM_RxInnetRaw[ch].MsgQ,&addrBuf_Size); + CM_ASSERT(NULL != read_addr, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_29, TSCP_DARK_ASSERT_1); + rt = CM_MQ_Read_Clear(&s_CFM_RxInnetRaw[ch].InfoQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_29, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT(addrBuf_Size > (bufFirstLen), NET_MODE, DARK_FAULT_CODE_FUN_ORDER_29, TSCP_DARK_ASSERT_3); + (void)CM_Memcpy(bufFirst,(CM_SIZE_T)bufFirstLen,read_addr,(CM_SIZE_T)bufFirstLen); + rt = CM_Memcpy(bufSecond,(CM_SIZE_T)*bufSecondLen,&read_addr[bufFirstLen],(CM_SIZE_T)CM_UNSIGNED_INT_EXP(addrBuf_Size - bufFirstLen)); + if(ENUM_CM_TRUE == rt) + { + *bufSecondLen = addrBuf_Size - bufFirstLen; + rt = CM_MQ_Read_UpData(&s_CFM_RxInnetRaw[ch].MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_29, TSCP_DARK_ASSERT_4); + } + else + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("Raw[%d]not enough space:%d<-%d!!!\n", ch, *bufSecondLen,addrBuf_Size - bufFirstLen); + *bufSecondLen = 0; + rt = ENUM_CM_FALSE; + } + return rt; +} +/** +* @brief 清除一帧带时间戳的透传数据 +* @param ch 通道号 +* @return 无 +* @details +*/ +void CFM_Clear_InnetRaw_Rx_Msg(IN CM_INT32 ch) +{ + ENUM_CM_RETURN rt1 = ENUM_CM_FALSE; + ENUM_CM_RETURN rt2 = ENUM_CM_FALSE; + /*- 读取通信报文队列和特征信息队列 */ + rt1 = CM_MQ_Read_Clear(&s_CFM_RxInnetRaw[ch].MsgQ); + rt2 = CM_MQ_Read_Clear(&s_CFM_RxInnetRaw[ch].InfoQ); + + CM_RE_ASSERT(ENUM_CM_TRUE == rt1, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_30, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT(ENUM_CM_TRUE == rt2, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_30, TSCP_DARK_ASSERT_2); +} + +/*********************************外网通信相关*****************************************/ + +/** +* @brief 外网通信初始化 +*/ +static void s_NetInit_Outnet(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 临时变量 */ + CM_INT32 val = 0; /* 临时变量 */ + CM_BOOL rtCheck; /* 临时变量 */ + + /*- 创建socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_OutnetSafe, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_Out), g_PFM_Cfg.Local_Cfg.Port_Outnet_Safe, 0u, (CM_UINT8)0); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + + /*- 配置socket */ + val = (CM_INT32)NET_UDP_BUF_SIZE; + (void)setsockopt(s_CFM_Sock.Sock_OutnetSafe, SOL_SOCKET, SO_RCVBUF, (void*)(&val), (unsigned int)sizeof(val)); + (void)setsockopt(s_CFM_Sock.Sock_OutnetSafe, SOL_SOCKET, SO_SNDBUF, (void*)(&val), (unsigned int)sizeof(val)); + + /*- 配置接收线程 */ + CM_ASSERT(s_CFM_RxOutnetSafe.IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + (void)sprintf(s_CFM_RxOutnetSafe.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_Out); + s_CFM_RxOutnetSafe.port = g_PFM_Cfg.Local_Cfg.Port_Outnet_Safe; + s_CFM_RxOutnetSafe.pSock = &s_CFM_Sock.Sock_OutnetSafe; + s_CFM_RxOutnetSafe.rmtIP = 0u; + s_CFM_RxOutnetSafe.threadNumBer = (CM_UINT8)ENUM_THREAD_OutnetS_Rx; + rt = CM_MQ_Init(&s_CFM_RxOutnetSafe.MsgQ, (CM_UINT16)CFM_OUTNET_MSG_NUM_MAX, (CM_UINT16)(CFM_OUTNET_SAFE_MSG_SIZE)); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_3); + /*- 启动外网安全通信接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "OutnetS_Rx", 0, CM_TASK_PRIORITY_74, (CM_Thread_Arg_Struct_T*)&s_CFM_RxOutnetSafe); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_4); + + /*- 创建外网心跳socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_OutnetHeart, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_Out), g_PFM_Cfg.Local_Cfg.Port_Outnet_Heart, 0u, (CM_UINT8)0); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_9); + + /*- 配置接收线程 */ + CM_ASSERT(s_CFM_RxOutnetHeart.IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_10); + (void)sprintf(s_CFM_RxOutnetHeart.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_Out); + s_CFM_RxOutnetHeart.port = g_PFM_Cfg.Local_Cfg.Port_Outnet_Heart; + s_CFM_RxOutnetHeart.pSock = &s_CFM_Sock.Sock_OutnetHeart; + s_CFM_RxOutnetHeart.rmtIP = 0u; + rt = CM_MQ_Init(&s_CFM_RxOutnetHeart.MsgQ, (CM_UINT16)CFM_OUTHEART_MSG_NUM_MAX, (CM_UINT16)(CFM_OUTNET_HEART_MSG_SIZE)); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_11); + /*- 启动外网心跳接收线程 */ + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "OutnetH_Rx", 0, CM_TASK_PRIORITY_82, (CM_Thread_Arg_Struct_T*)&s_CFM_RxOutnetHeart); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_12); + + /*判断外网透传使能开关*/ + if(0x55u == (CM_UINT32)g_PFM_Cfg.M_OutnetRaw_Enable) + { + /*- 创建socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_OutnetRaw, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_Out), g_PFM_Cfg.Local_Cfg.Port_Outnet_Raw, 0u, (CM_UINT8)0); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_5); + + + /*- 配置socket */ + val = (CM_INT32)NET_UDP_BUF_SIZE; + (void)setsockopt(s_CFM_Sock.Sock_OutnetRaw, SOL_SOCKET, SO_RCVBUF, (void*)(&val), (unsigned int)sizeof(val)); + (void)setsockopt(s_CFM_Sock.Sock_OutnetRaw, SOL_SOCKET, SO_SNDBUF, (void*)(&val), (unsigned int)sizeof(val)); + + /*- 配置接收线程 */ + CM_ASSERT(s_CFM_RxOutnetRaw.IP != NULL,NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_6); + (void)sprintf(s_CFM_RxOutnetRaw.IP, "%s", g_PFM_Cfg.Local_Cfg.IP_Out); + s_CFM_RxOutnetRaw.port = g_PFM_Cfg.Local_Cfg.Port_Outnet_Raw; + s_CFM_RxOutnetRaw.pSock = &s_CFM_Sock.Sock_OutnetRaw; + s_CFM_RxOutnetRaw.rmtIP = 0u; + rt = CM_MQ_Init(&s_CFM_RxOutnetRaw.MsgQ, (CM_UINT16)CFM_OUTNET_RAW_MSG_NUM_MAX, (CM_UINT16)(CFM_OUTNET_RAW_MSG_SIZE)); + CM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_7); + + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_UdpRecvThread, "OutnetR_Rx", 0, CM_TASK_PRIORITY_82, (CM_Thread_Arg_Struct_T*)&s_CFM_RxOutnetRaw); + CM_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_8); + CM_Sleep(100u);/* 延时等待线程启动 */ + } + else + { + /*外网透传未使能*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1)); + } + + rtCheck = CM_Thread_Create((CM_THREAD_T*) NULL, (CM_THREAD_FUNC_T) t_ClearArpThread,"Clear_Arp", 0, CM_TASK_PRIORITY_94, NULL); + CM_RE_ASSERT(CM_TRUE == rtCheck, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_13); + + CM_Sleep(100u);/* 延时等待线程启动 */ +} + +/** +* @brief 获取接收包数和接受长度并且清空 +*/ +void CFM_GetOSCache(void) +{ + MSCP_LOG_MSG("g_CFM_OSCache_ClearNum = %d, g_CFM_OSCache_Len = %d\n", g_CFM_OSCache_ClearNum, g_CFM_OSCache_Len); + g_CFM_OSCache_ClearNum = 0; + g_CFM_OSCache_Len = 0; +} + +/** +* @brief 清空外网安全数据队列长度 +*/ +void CFM_ClearCache(void) +{ + (void)CM_MQ_Clear(&s_CFM_RxOutnetSafe.MsgQ); +} +/*********************************维护网相关*****************************************/ + +/** +* @brief 维护网通信队列初始化 +*/ +void CFM_Maintain_Queue_Init(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 临时变量 */ + /*- 平台日志队列初始化 */ + rt = CM_MQ_Init((CM_MQ_Struct_T*)&s_CFM_Send_LogStr.MsgQ, (CM_UINT16)CFM_INNET_LOG_MSG_SIZE, (CM_UINT16)(CFM_INNET_LOG_SIZE)); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + + rt = CM_QueueInitial(&s_Log_CtrlQ.MsgQ, CFM_INNET_LOG_MSG_SIZE_DARK); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_2); + (void)CM_Mutex_Init(&ciphertextCtrl.mutex); +} +/** +* @brief 维护网通信UDP初始化 +*/ +void CFM_Maintain_Init(void) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 临时变量 */ + /*- UDP协议初始化 */ + rt = CM_UDP_Init(); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + + /*- 维护网通信初始化 */ + s_NetInit_Maintain(); /* 首先初始化维护网通信,以使以太网日志可用 */ + + CM_Sleep(1000u); + PFM_SendLastAssertLog(); + + DFM_Network_Check(); +} + + +/* 维护网通信初始化 */ +static void s_NetInit_Maintain(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 临时变量 */ + CM_INT32 val = 0; /* 临时变量 */ + /*- 创建socket */ + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_LogBase, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_Maintain), g_PFM_Cfg.Local_Cfg.Port_Log_Base, 0u, (CM_UINT8)0); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1); + s_CFM_Send_LogStr.pSock = &s_CFM_Sock.Sock_LogBase; + + rt = CM_UDP_Socket_Create(&s_CFM_Sock.Sock_LogCiphertext, CM_FALSE, (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_Maintain), g_PFM_Cfg.Local_Cfg.Port_Log_Ciphertext, 0u, (CM_UINT8)0); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_2); + s_Log_CtrlQ.pSock = &s_CFM_Sock.Sock_LogCiphertext; + + /*- 配置socket */ + val = (CM_INT32)NET_UDP_BUF_SIZE * 32; + (void)setsockopt(s_CFM_Sock.Sock_LogBase, SOL_SOCKET, SO_SNDBUF, (void*)(&val), (unsigned int)sizeof(val)); + (void)setsockopt(s_CFM_Sock.Sock_LogCiphertext, SOL_SOCKET, SO_SNDBUF, (void*)(&val), (unsigned int)sizeof(val)); + + /*初始化参数*/ + CM_NM_ASSERT(s_CFM_Send_LogStr.rmtIP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_3); + CM_NM_ASSERT(g_PFM_Cfg.Logger_IP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_4); + (void)sprintf(s_CFM_Send_LogStr.rmtIP, "%s", g_PFM_Cfg.Logger_IP); + s_CFM_Send_LogStr.rmtPort = g_PFM_Cfg.Local_Cfg.Port_Log_Base; + + CM_NM_ASSERT(s_Log_CtrlQ.rmtIP != NULL, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_5); + (void)sprintf(s_Log_CtrlQ.rmtIP, "%s", g_PFM_Cfg.Logger_IP); + s_Log_CtrlQ.rmtPort = g_PFM_Cfg.Local_Cfg.Port_Log_Ciphertext; + + /*创建发送线程*/ + /*- 启动明文日志发送线程 */ + (void)CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_LogSendThread, "LogSend", 0, CM_TASK_PRIORITY_90, (CM_Thread_Arg_Struct_T*)&s_CFM_Send_LogStr); + CM_Sleep(100u);/* 延时等待线程启动 */ +} + + +/** +* @brief 日志发送线程 +* @param arg 指向STRU_CFM_TIME_CTRL的指针 +* @return 线程函数返回值(实际永远不会返回) +* @details +*/ +static CM_THREAD_FUNC_T t_LogSendThread(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + STRU_CFM_SEND_LOG* pCtrl = (STRU_CFM_SEND_LOG*)arg; /* 线程参数 */ + ENUM_CM_RETURN rt1 = ENUM_CM_FALSE; /* 平台临时变量 */ + CM_UINT8 buf[CFM_INNET_LOG_SIZE * 2u] = { 0u }; /* 接收缓冲区 */ + CM_UINT16 len = 0u; /* 数据长度 */ + CM_UINT16 offset = 0u; + CM_UINT16 bufSize = 0u; +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + MSCP_LOG_MSG("IP:%s:%d LogSend Service Start\n", pCtrl->rmtIP, (CM_INT32)pCtrl->rmtPort); + /*- 循环执行接收线程 */ + while (1) + { + /*- 获取消息条数*/ + bufSize = CFM_INNET_LOG_SIZE * 2u; + offset = 0u; + len = bufSize; + + do + { + rt1 = CM_MQ_Read(&pCtrl->MsgQ, &buf[offset], &len); + if((ENUM_CM_TRUE == rt1) && (len > 0u)) + { + if(0x55u == PFM_LOG_GET_STOP_FLAG()) + { + /*- 判断宕机前是否有未发送的攒包数据*/ + if(offset > 0u) + { + /*- 有攒包数据 先把这部分数据发送出去*/ + (void)CM_UDP_Send_Msg((CM_SOCKET)*pCtrl->pSock, buf, (CM_INT32)offset, (CM_UINT32)inet_addr(pCtrl->rmtIP), pCtrl->rmtPort); + CM_Sleep(1u);//发送完延时1ms + } + else + { + ; + } + /*- 发送本次读到的数据*/ + (void)CM_UDP_Send_Msg((CM_SOCKET)*pCtrl->pSock, &buf[offset], (CM_INT32)len, (CM_UINT32)inet_addr(pCtrl->rmtIP), pCtrl->rmtPort); + (void)CM_Memset(buf, 0u, (CM_SIZE_T)(offset + len) ,sizeof(buf)); + bufSize = CFM_INNET_LOG_SIZE * 2u; + offset = 0u; + } + else if(buf[offset + 1u] == (CM_UINT8)'b') + { + /*- 是数字 直接发送*/ + (void)CM_UDP_Send_Msg((CM_SOCKET)*pCtrl->pSock, buf, (CM_INT32)offset, (CM_UINT32)inet_addr(pCtrl->rmtIP), pCtrl->rmtPort); + CM_Sleep(1u); + (void)CM_UDP_Send_Msg((CM_SOCKET)*pCtrl->pSock, &buf[offset], (CM_INT32)len, (CM_UINT32)inet_addr(pCtrl->rmtIP), pCtrl->rmtPort); + (void)CM_Memset(buf, 0u, (CM_SIZE_T)(offset + len) ,sizeof(buf)); + CM_Sleep(1u); + bufSize = CFM_INNET_LOG_SIZE * 2u; + offset = 0u; + } + else + { + offset += len; + bufSize -= len; + } + len = bufSize; + } + else + { + CM_delayUs((CM_UINT64)5000u); + } + }while(offset < LOG_MAX); + /*- UDP数据发送*/ + (void)CM_UDP_Send_Msg((CM_SOCKET)*pCtrl->pSock, buf, (CM_INT32)offset, (CM_UINT32)inet_addr(pCtrl->rmtIP), pCtrl->rmtPort); + (void)CM_Memset(buf, 0u, (CM_SIZE_T)offset, sizeof(buf)); + CM_Sleep(1u); + } + return NULL; +} + +/** +* @brief 暗文日志组包发送函数 +* @param 无 +* @return 无 +* @details +*/ +void CFM_LogCiphertextSend(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 临时变量 */ + CM_UINT8 sendBuf[CFM_INNET_LOG_MSG_SIZE_DARK + 20u] = { 0u }; /* 发送队列冲区 */ + CM_UINT32 sendOffset = 11u; /* 发送队列偏移量,包头占11字节 */ + CM_UINT32 dataLen = 0u; /* 信息包队列大小 */ + CM_UINT8 appType = 0u; /* 应用类型 */ + CM_UINT32 crc = 0u; + CM_UINT8 typeBoard = 1u; /* id = 1代表主机板 */ + + (void)CM_Mutex_Lock(ciphertextCtrl.mutex); + dataLen = CM_QueueStatus(&s_Log_CtrlQ.MsgQ); + /*- 应用内网发送缓冲是否非空 */ + if (dataLen > 0u) + { + /*- 从发送缓冲区读出数据 */ + rt = CM_QueueRead(dataLen, &sendBuf[sendOffset], &s_Log_CtrlQ.MsgQ); + (void)CM_Mutex_Unlock(ciphertextCtrl.mutex); + if(ENUM_CM_TRUE == rt) + { + /*- sendOffset偏移量增加 */ + sendOffset += dataLen; + /*- 组包头 包尾 长度不包含自身4字节 */ + CM_LongToChar(sendOffset, &sendBuf[0]); + /*- 源类型 */ + sendBuf[4] = typeBoard; + if(0 == strcmp(g_PFM_Cfg.APP_NAME, "ZC")) + { + appType = 1u; + } + else if(0 == strcmp(g_PFM_Cfg.APP_NAME, "RCOCI")) + { + appType = 2u; + } + else if(0 == strcmp(g_PFM_Cfg.APP_NAME, "CI")) + { + appType = 3u; + } + else if(0 == strcmp(g_PFM_Cfg.APP_NAME, "TMC")) + { + appType = 4u; + } + else if(0 == strcmp(g_PFM_Cfg.APP_NAME, "ITE")) + { + appType = 5u; + } + else if(0 == strcmp(g_PFM_Cfg.APP_NAME, "TSL")) + { + appType = 6u; + } + else if(0 == strcmp(g_PFM_Cfg.APP_NAME, "DSU")) + { + appType = 7u; + } + else + { + appType = 0u; + } + sendBuf[5] = appType; /*应用类型id=1 ZC*/ + sendBuf[6] = g_PFM_Cfg.CPU_ID; + /*- 序列号,主机板那周期号代替 */ + CM_LongToChar(SFM_2x2_GetSysCount(), &sendBuf[7]); + /*- crc */ + crc = CM_Crc32(&sendBuf[0], sendOffset); + CM_LongToChar(crc, &sendBuf[sendOffset]); + + /*- 发送一整包,后面可能都是0,由上位机解析 */ + (void)CM_UDP_Send_Msg((CM_SOCKET)*s_Log_CtrlQ.pSock, (CM_UINT8*)sendBuf, (CM_INT32)CM_UNSIGNED_INT_EXP(sendOffset+4u), (CM_UINT32)inet_addr(s_Log_CtrlQ.rmtIP), s_Log_CtrlQ.rmtPort); + } + else + { + MSCP_LOG_MSG("Ciphertext read queue fail \n"); + } + + } + else + { + (void)CM_Mutex_Unlock(ciphertextCtrl.mutex); + MSCP_LOG_MSG("dataLen = %d\n",dataLen); + } +} + +/** +* @brief 平台明文日志发送 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_BaseLog_Send(IN const CM_UINT8* Buf, IN CM_INT32 Len) +{ + /*- 返回日志通道的发送结果 */ + return CM_MQ_Write(&s_CFM_Send_LogStr.MsgQ, Buf, (CM_UINT16)Len); +} + +/** +* @brief 应用日志发送 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_AppLog_Send(IN const CM_UINT8* Buf, IN CM_INT32 Len) +{ + /*- 返回日志通道的发送结果 */ + return CM_MQ_Write(&s_CFM_Send_LogStr.MsgQ, Buf, (CM_UINT16)Len); +} +/** +* @brief 平台日志保存本地文件 +* @param FILE * fp_crash 文件指针 取值范围:非空 +* @return 无 +*/ +void CFM_BaseLog_SaveLocal(FILE * fp_crash) +{ + /*- 变量初始化 */ + CM_UINT16 i = 1u; + CM_UINT16 Len = 0; + CM_UINT8 Buf[CFM_INNET_LOG_MSG_SIZE] = {0u}; + ENUM_CM_RETURN rtnval = ENUM_CM_FALSE; + /*- 如果参数非空 */ + if(NULL != fp_crash) + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(s_CFM_Send_LogStr.MsgQ.mutex); + /*- @alias 读取消息队列写入本地文件中 */ + for(i = 1u;i <= CFM_INNET_LOG_SIZE;i++) + { + Len = CFM_INNET_LOG_MSG_SIZE; + rtnval = CM_MQ_Again_Read(&s_CFM_Send_LogStr.MsgQ, i,Buf, &Len); + if((ENUM_CM_TRUE == rtnval) && (Len > 0u) && (Buf[1] == (CM_UINT8)'s')) + { + (void)fwrite(Buf,(CM_SIZE_T)1u,Len,fp_crash); + } + } + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(s_CFM_Send_LogStr.MsgQ.mutex); + } + else + { + /*- 输出失败提示信息 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1)); + (void)printf("Unable to output log\n"); + } +} +/** +* @brief 应用/平台暗文日志存储 +* @param infoType 数据类型 +* 取值范围:0x55:info为字符串数据方式 +* 0xAA:info为十六进制数据方式 +* 0xFF:info为十进制数据方式 +* @param code 信息编码/信息类型 取值范围:0~0xffff +* @param infoLen 数据长度 取值范围:0~0xffff +* @param info 数据/信息 取值范围:任意类型指针 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_DarkLog_Storage(IN const CM_UINT8 infoType, IN const CM_UINT16 code, IN const CM_UINT32 infoLen, IN const void *info) +{ + /*- 变量初始化 */ + CM_UINT8 TempBuf[CFM_INNET_LOG_MSG_SIZE_DARK] = { 0u }; + CM_UINT32 TempBufLen = infoLen + 7u; + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + /*- 如果数据为空或者数据长度+包头大小大于队列大小,则返回失败*/ + if((NULL == info) || (CFM_INNET_LOG_MSG_SIZE_DARK < (infoLen + 7u)) || (ENUM_INIT_MAIN_QUEUE_NET > PFM_LOG_GET_INIT_STAGE())) + { + MSCP_LOG_MSG("If the data is empty or the data length + header size is greater than the queue size, failure is returned\n"); + ret = ENUM_CM_FALSE; + } + else + { + /*- 组包*/ + TempBuf[0] = infoType; + CM_ShortToChar(code, &TempBuf[1]); + CM_LongToChar(infoLen, &TempBuf[3]); + if((4u == infoLen) && (DARK_LOG_STRING != (CM_UINT8)infoType)) + { + CM_LongToChar(*(const CM_UINT32*)info,&TempBuf[7]); + ret = ENUM_CM_TRUE; + } + else if((2u == infoLen) && (DARK_LOG_STRING != (CM_UINT8)infoType)) + { + CM_ShortToChar(*(const CM_UINT16*)info,&TempBuf[7]); + ret = ENUM_CM_TRUE; + } + else if((8u == infoLen) && (DARK_LOG_STRING != (CM_UINT8)infoType)) + { + CM_64ToChar(*(const CM_UINT32*)info,&TempBuf[7]); + ret = ENUM_CM_TRUE; + } + else + { + ret = CM_Memcpy(&TempBuf[7], (CM_SIZE_T)CM_UNSIGNED_INT_EXP(CFM_INNET_LOG_MSG_SIZE_DARK-7u), info, (CM_SIZE_T)infoLen); + if(ENUM_CM_FALSE == ret) + { + MSCP_LOG_MSG("Memcpy Dark Write failed\n"); + } + else + { + /*-无处理 */ + } + } + /*- 如果组包没问题*/ + if(ENUM_CM_TRUE == ret) + { + /*- 直接将组好的信息包写到队列中*/ + /*- 在这加锁*/ + ret = CM_Mutex_Lock(ciphertextCtrl.mutex); + if(ENUM_CM_FALSE == ret) + { + MSCP_LOG_MSG("Dark Mutex Lock failed\n"); + } + else + { + ret= CM_QueueWrite(TempBufLen, TempBuf, &s_Log_CtrlQ.MsgQ);/*长度*/ + if(ENUM_CM_FALSE == ret) + { + MSCP_LOG_MSG("Dark Write faild(Maybe the queue is full)\n"); + } + else + { + /*- 无处理 */ + } + } + (void)CM_Mutex_Unlock(ciphertextCtrl.mutex); + } + else + { + MSCP_LOG_MSG("There is a packet grouping problem\n"); + /*- 无处理 */ + } + } + /*- 返回结果 */ + return ret; +} +/** +* @brief 应用/平台暗文日志多变量存储 +* @param infoType 数据类型 +* 取值范围:0x55:info为字符串数据方式 +* 0xAA:info为十六进制数据方式 +* 0xFF:info为十进制数据方式 +* @param code 信息编码/信息类型 取值范围:0~0xffff +* @param infoCut 数据个数 取值范围:0~0xff +* @param ... 可变参数/信息 取值范围:任意类型数据,但是需要与sizeof()成对使用。 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_DarkLog_Multiple(IN const CM_UINT8 infoType, IN const CM_UINT16 code, CM_UINT8 infoCut, ...) +{ + va_list argList; + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT8 i = 0u; + CM_UINT8 dataLen = 0u; + CM_UINT8 dataBuf[1024] = {0}; + CM_UINT16 totalLen = 0u; + /*判断是否为且大于0*/ + if(infoCut > 0u) + { + /*定位参数链表栈顶位置*/ + va_start(argList, (infoCut)); + /* @alias 循环读取数据*/ + for(i = 0u; ithreadNumBer) + { + pmask = (void*)(0x20u | 0x10u | 0x08u | 0x04u); + } + else + { + pmask = (void*)(0x01u|0x02u); + } + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + MSCP_LOG_MSG("IP:%s:%d UDP recv Start\n", pCtrl->IP, pCtrl->port); + /*- 循环接收UDP数据 */ + while (1) + { + /*- UDP阻塞接收 */ + rcvBuf = CM_MQ_Get_BufAddr(&pCtrl->MsgQ); + if(NULL != rcvBuf) + { + len = CM_UDP_Recv_Msg(*(pCtrl->pSock), &rcvBuf[6u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(pCtrl->MsgQ.maxMsgSize - 6u), &srcIP, &srcPort); + /*- 是否收到有效数据 */ + if (len > 0) + { + /*- 源IP端口是否合法 */ + if ((pCtrl->rmtIP == 0u) + || ((srcIP == pCtrl->rmtIP) && (srcPort== pCtrl->rmtPort))) + { + /*- @alias 将收到的报文写入线程接收队列 */ + if((CM_UINT8)ENUM_THREAD_2x2_StateRecv == pCtrl->threadNumBer) + { + /*接收数据时间戳ms数记录*/ + CM_LongToChar((CM_UINT32)(CM_GetTick()/CM_UNSIGNED_MILLION), rcvBuf); + } + else + { + CM_LongToChar(srcIP, rcvBuf); + CM_ShortToChar(srcPort, &rcvBuf[4u]); + } + /*- 保存通信数据 */ + rt = CM_MQ_UpData(&pCtrl->MsgQ,(CM_UINT16)CM_SIGNED_INT_EXP(len + 6)); + /*- 数据保存是否成功 */ + if (ENUM_CM_TRUE == rt) + { + /*成功无操作*/ + } + else + { + /*- 防御性清空*/ + MSCP_LOG_MSG("port %d rx overflow(msgLen=%d),threadNumBer = %d\n", pCtrl->port, len, pCtrl->threadNumBer); + rt = CM_MQ_Clear(&pCtrl->MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_1); + } + (ENUM_THREAD_OutnetS_Rx == (ENUM_THREAD_NUM_T)pCtrl->threadNumBer)?(g_CFM_OSCache_ClearNum++):g_CFM_OSCache_ClearNum; + (ENUM_THREAD_OutnetS_Rx == (ENUM_THREAD_NUM_T)pCtrl->threadNumBer)?(g_CFM_OSCache_Len += (CM_UINT32)len):g_CFM_OSCache_Len; + } + else + { + /*- 来自非预期IP端口的数据*/ + addr.sin_addr.s_addr = srcIP; + MSCP_LOG_MSG("rx err want port:%d src [%s:%d]:%d \n", pCtrl->rmtPort, inet_ntoa(addr.sin_addr), srcPort, len); + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_2); + } + } + else + { + /*- 接收出错 */ + MSCP_LOG_MSG("warning ASSERT1103: port %d rx err(len=%d)\n", pCtrl->port, len); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1)); + } + } + else + { + /*获取队列指针失败,清空队列*/ + rt = CM_MQ_Clear(&pCtrl->MsgQ); + MSCP_LOG_MSG("buf clear\n"); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_4); + } + } + return NULL; +} +/** +* @brief 维护模式下UDP接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收UDP报文并写入线程接收队列 +*/ +static CM_THREAD_FUNC_T t_UdpRecvMaintenanceThread(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + STRU_CFM_RECV_CTRL_T* pCtrl = (STRU_CFM_RECV_CTRL_T*)arg; /* 线程控制信息 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT8* rcvBuf = NULL; + CM_INT32 len; /* 报文长度 */ + CM_UINT32 srcIP;/* 源IP */ + CM_UINT16 srcPort;/* 源端口 */ + CM_SOCKADDR_T srcaddr;/* 地址转换*/ +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + MSCP_LOG_MSG("IP:%s:%d dpRecvMaintenance recv Start\n", pCtrl->IP, pCtrl->port); + /*- 循环接收UDP数据 */ + while (1) + { + /*- UDP阻塞接收 */ + rcvBuf = CM_MQ_Get_BufAddr(&pCtrl->MsgQ); + if(NULL != rcvBuf) + { + len = CM_UDP_Recv_Msg(*(pCtrl->pSock), &rcvBuf[6u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(pCtrl->MsgQ.maxMsgSize - 6u), &srcIP, &srcPort); + /*- 是否收到有效数据 */ + if (len > 0) + { + /*- 源IP端口是否合法 */ + if ((pCtrl->rmtIP == 0u) + || ((srcIP == pCtrl->rmtIP) && (srcPort== pCtrl->rmtPort))) + { + /*- @alias 将收到的报文写入线程接收队列 */ + CM_LongToChar(srcIP, rcvBuf); + CM_ShortToChar(srcPort, &rcvBuf[4u]); + /*- 保存通信数据 */ + rt = CM_MQ_UpData(&pCtrl->MsgQ,(CM_UINT16)CM_SIGNED_INT_EXP(len + 6)); + /*- 数据保存是否成功 */ + if (ENUM_CM_TRUE == rt) + { + /*成功无操作*/ + } + else + { + /*- 防御性清空*/ + /* MSCP_LOG_MSG("port %d rx overflow(msgLen=%d)\n", pCtrl->port, len);*/ + rt = CM_MQ_Clear(&pCtrl->MsgQ); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_38, TSCP_DARK_ASSERT_1); + + } + } + else + { + /*- 来自非预期IP端口的数据*/ + srcaddr.sin_addr.s_addr = srcIP; + MSCP_LOG_MSG("rx err want port:%d src [%s:%d]:%d \n", pCtrl->rmtPort, inet_ntoa(srcaddr.sin_addr), srcPort, len); + CM_NM_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_38, TSCP_DARK_ASSERT_2); + } + } + else + { + /*- 接收出错 */ + MSCP_LOG_MSG("port %d rx err(len=%d)\n", pCtrl->port, len); + CM_NM_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_38, TSCP_DARK_ASSERT_3); + } + } + else + { + /*获取队列指针失败,清空队列*/ + rt = CM_MQ_Clear(&pCtrl->MsgQ); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_38, TSCP_DARK_ASSERT_4); + } + } + return NULL; +} +/** +* @brief 时钟同步线程 +* @param arg 指向STRU_CFM_TIME_CTRL的指针 +* @return 线程函数返回值(实际永远不会返回) +* @details +* 创建本线程之前应先配置好STRU_CFM_TIME_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收时钟同步报文并作出应答 +* 收到请求报文时立即给出应答 +* 收到应答报文时记录并计算延迟时间、偏移时间 +* @see :: CFM_2oo2_TimeReq +* @see :: CFM_2oo2_TimeGet +*/ +static CM_THREAD_FUNC_T t_TimeThread(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + STRU_CFM_TIME_CTRL_T* pCtrl = (STRU_CFM_TIME_CTRL_T*)arg; /* 线程参数 */ + CM_UINT8 buf[100] = { 0u }; /* 接收缓冲区 */ + CM_INT32 len; /* 数据长度 */ + CM_UINT32 srcIP; /* 源IP */ + CM_UINT16 srcPort; /* 源端口 */ + CM_UINT64 tick = 0u; /* 精确时间 */ + CM_UINT64 T1 = 0u; /* 时钟同步参数 */ + CM_UINT64 T2 = 0u; /* 时钟同步参数 */ + CM_UINT64 T3 = 0u; /* 时钟同步参数 */ + CM_UINT64 T4 = 0u; /* 时钟同步参数 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + MSCP_LOG_MSG("IP:%s:%d Time Service Start\n", pCtrl->IP, (CM_INT32)pCtrl->port); + /*- 循环执行接收线程 */ + while (1) + { + /*- 阻塞接收时钟同步报文 */ + len = CM_UDP_Recv_Msg(*(pCtrl->pSock), buf, (CM_INT32)sizeof(buf), &srcIP, &srcPort); + tick = DFM_GetCycTick(); + /*- 是否收到有效报文 */ + if (len > 0) + { + /*- 报文类型 */ + switch ((ENUM_TIME_MSG_T)buf[0]) + { + case ENUM_TIME_REQ: /*-< 时钟同步请求 */ + /*- 长度是否合法 */ + if (9 == len) + { + /*- 解析请求报文 */ + T1 = CM_64FromChar(buf + 1); + /*- 生成应答报文 */ + T2 = tick; + buf[0] = (CM_UINT8)ENUM_TIME_ACK; + CM_64ToChar(T1, buf + 1); + CM_64ToChar(T2, buf + 9); + T3 = DFM_GetCycTick(); + CM_64ToChar(T3, buf + 17); + /*- 发送应答报文 */ + (void)CM_UDP_Send_Msg(*(pCtrl->pSock), buf, (CM_INT32)25, srcIP, srcPort); + } + else + { + /*- 无处理 */ + } + /*- 返回 */ + break; + case ENUM_TIME_ACK:/*-< 时钟同步应答 */ + /*- 长度是否合法 */ + if (25 == len) + { + /*- 解析应答报文 */ + T1 = CM_64FromChar(buf + 1); + T2 = CM_64FromChar(buf + 9); + T3 = CM_64FromChar(buf + 17); + T4 = tick; + /*- 记录延迟时间和偏移时间 */ + rt = CM_Mutex_Lock(pCtrl->mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_1); + pCtrl->isOK = ENUM_CM_TRUE; + pCtrl->delay = (CM_INT64)((T4 - T1) - (T3 - T2)) / 2; + pCtrl->offset = (CM_INT64)((T2 + T3) - (T4 + T1)) / 2; + rt = CM_Mutex_Unlock(pCtrl->mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_2); + + } + else + { + /*- 无处理 */ + } + /*- 返回 */ + break; + case ENUM_TIME_ERROR:/*-< 保留字 */ + /*- 宕机 */ + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_3); + /*- 返回 */ + break; + default: + /*- 返回 */ + break; + } + } + else + { + /*- 不处理 */ + } + } + return NULL; +} + +/** +* @brief 远程部署接收线程 +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +* 创建本线程之前应先配置好STRU_CFM_RECV_CTRL,包括创建阻塞通信的socket +* 本线程将以阻塞方式接收远程部署命令UDP报文,然后进行相关处理 +*/ +static CM_THREAD_FUNC_T t_RemoteUpdateThread(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + STRU_CFM_RECV_CTRL_T* pCtrl = (STRU_CFM_RECV_CTRL_T*)arg; /* 线程控制信息 */ + STRU_PFM_INNET_CFG_T *pCom = NULL; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT8 rcvBuf[1024] = { 0u }; /* 接收缓冲区 */ + CM_INT32 len; /* 报文长度 */ + CM_UINT32 srcIP;/* 源IP */ + CM_UINT16 srcPort;/* 源端口 */ + CM_UINT32 rmtIP;/* 对方IP */ + CM_UINT16 rmtPort_safe;/* 对方sfp端口 */ + CM_UINT16 rmtPort_raw;/* 对方透传端口 */ + struct in_addr serveraddr;/* 源ip */ + CM_UINT8 Result = 0x0u;/* 请求处理结果 */ +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + MSCP_LOG_MSG("IP:%s:%d UDP recv Start\n", pCtrl->IP, pCtrl->port); + /*- 获取目的IP端口 */ + pCom = PFM_INI_InnetID2Addr(g_Maintenance_Id); + if (NULL != pCom) + { + /*- 本机是否为CPU1 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + rmtIP = pCom->IP_G; + rmtPort_safe = pCom->Port_Safe_G; + rmtPort_raw = pCom->Port_Raw_G; + } + else + { + rmtIP = pCom->IP_P; + rmtPort_safe = pCom->Port_Safe_P; + rmtPort_raw = pCom->Port_Raw_P; + } + } + else + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("Map Value From g_Maintenance_Id Error!!!\n"); + } + + /*- 循环接收UDP数据 */ + while (1) + { + /* 请求处理结果重新置0 */ + Result = 0x0u; + /*- UDP阻塞接收 */ + len = CM_UDP_Recv_Msg(*(pCtrl->pSock), &rcvBuf[6u], (CM_INT32)sizeof(rcvBuf)-6, &srcIP, &srcPort); + /*- 是否收到有效数据 */ + if (len > 0) + { + MSCP_LOG_DATALEN(rcvBuf, len, "t_RemoteUpdateThread rcvBuflen"); + /*- 源IP端口是否合法 */ + if ((srcIP == rmtIP) && ((srcPort== rmtPort_safe) || (srcPort == rmtPort_raw))) + { + if (srcPort== rmtPort_safe) + { + /*- @alias 需要解sfp协议的远程部署命令 */ + /*- @alias 将收到的完整帧写入线程接收队列 */ + CM_LongToChar(srcIP, &rcvBuf[0]); + CM_ShortToChar(srcPort, &rcvBuf[4]); + /*- 保存通信数据 */ + rt = CM_MQ_Write(&pCtrl->MsgQ, rcvBuf, (CM_UINT16)CM_SIGNED_SHORT_EXP(len + 6)); + if (ENUM_CM_TRUE == rt) + { + MSCP_LOG_MSG("CM_MQ_Write success!!! len = %d\n",len); + /*成功无操作*/ + } + else + { + /*- 防御性清空*/ + (void)CM_MQ_Clear(&pCtrl->MsgQ); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("CM_MQ_Write error!!! \n"); + } + } + else + { + /*- @alias 不需要解sfp协议的远程部署透传命令 */ + /*- @alias 判断帧类型 */ + if (0xa3u == rcvBuf[8u]) + { + /*- 文件更新请求 */ + MSCP_LOG_MSG("recv 0xa3 pack g_RemoteUpdate_State = %d\n",g_RemoteUpdate_State); + rt = PFM_FileUpdate_Request(&rcvBuf[6u],(CM_UINT16)len,&Result); + if (ENUM_CM_TRUE != rt) + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_2)); + /*- 文件更新请求处理失败*/ + MSCP_LOG_MSG("Call PFM_FileUpdate_Request error!!! \n"); + /*- 置远程部署过程状态为0x00默认值,维护终端重新触发*/ + g_RemoteUpdate_State = 0x00u; + } + else + { + /*- 文件更新请求处理成功*/ + MSCP_LOG_MSG("Call PFM_FileUpdate_Request sucess!!! \n"); + if (0x01u == Result) + { + /*- 置远程部署过程状态为0x01已处理文件更新请求*/ + g_RemoteUpdate_State = 0x01u; + MSCP_LOG_MSG("recv 0xa3 pack success\n"); + } + else + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_2)); + MSCP_LOG_MSG("An error occurred in the file update request message!!! \n"); + } + } + } + else if(0xa4u == rcvBuf[8u]) + { + if (0x01u == g_RemoteUpdate_State) + { + /*- 当前远程部署过程为上传完成验证请求*/ + /*- 文件上传完成验证请求 */ + rt = PFM_FileVerity_Request(&rcvBuf[6u],(CM_UINT16)len); + if (ENUM_CM_TRUE != rt) + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_3)); + /*- 文件上传完成验证请求处理失败*/ + MSCP_LOG_MSG("Call PFM_FileVerity_Request error!!! \n"); + /*- 置远程部署过程状态为0x00默认值,维护终端重新触发*/ + g_RemoteUpdate_State = 0x00u; + } + else + { + /*- 置远程部署过程状态为0x02为成功,等待维护终端升级部署*/ + g_RemoteUpdate_State = 0x02u; + /*- 文件上传完成验证请求处理成功*/ + MSCP_LOG_MSG("Call PFM_FileVerity_Request sucess!!! \n"); + } + } + else + { + /*- 不是当前应该收到的过程报文丢弃不处理*/ + MSCP_LOG_MSG("0xa4u The packet should not be received in the current state!!! \n"); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_4)); } + } + else + { + /*- 来自非预期帧类型的数据*/ + (void)CM_Memcpy((void*) &serveraddr, sizeof(serveraddr), (void*) &srcIP, (CM_SIZE_T)4); + MSCP_LOG_MSG("frame type err [%s:%d]:%d:%x \n", inet_ntoa(serveraddr), srcPort, len, rcvBuf[8u]); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_5)); + } + } + } + else + { + /*- 来自非预期IP端口的数据*/ + (void)CM_Memcpy((void*) &serveraddr, sizeof(serveraddr), (void*) &srcIP, (CM_SIZE_T)4); + MSCP_LOG_MSG("rx err [%s:%d]:%d \n", inet_ntoa(serveraddr), srcPort, len); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_6)); + } + } + else + { + /*- 接收出错 */ + MSCP_LOG_MSG("port %d rx err(len=%d)\n", pCtrl->port, len); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_REMOTEUPDATETHREAD_LENEOR, 2, \ + sizeof(CM_UINT16),pCtrl->port, + sizeof(CM_INT32),len); + } + } + + return NULL; +} +/** +* @brief 清空接收缓冲区 +*/ +void CFM_Net2XFlush(void) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + /*- 2x2接收缓冲区清空 */ + rt = CM_MQ_Flush(&s_CFM_Rx2x2.MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_1); + } + else + { + /*- 无处理 */ + } +} +/** +* @brief 清空接收缓冲区 +*/ +void CFM_Net2X_State_Flush(void) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + rt = CM_MQ_Flush(&s_CFM_State2x2.MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_11); + rt = CM_Com_OtherDataClear(); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_9); + } + else + { + /*- 无处理 */ + } +} +/** +* @brief 清空接收缓冲区 +*/ +void CFM_NetFlush(void) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 2x2功能是否开启 */ + CFM_Net2XFlush(); + CFM_Net2X_State_Flush(); + + /*- 内网安全接收缓冲区清空 */ + rt = CM_MQ_Flush(&s_CFM_RxInnetSafe.MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_2); + + /*- 外网安全接收缓冲区清空 */ + rt = CM_MQ_Flush(&s_CFM_RxOutnetSafe.MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_3); + + /*判断外网透传使能开关*/ + if(0x55u == (CM_UINT32)g_PFM_Cfg.M_OutnetRaw_Enable) + { + /* 外网透传缓冲区清空 */ + rt = CM_MQ_Flush(&s_CFM_RxOutnetRaw.MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_7); + } + else + { + /*无处理 */ + } + if((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /*- 内网远程部署接收缓冲区清空 */ + rt = CM_MQ_Flush(&s_CFM_RxRemoteUpdate.MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_8); + } + else + { + /*无处理 */ + } + + rt = CM_MQ_Flush(&s_CFM_RxOutnetHeart.MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_10); + + /*- @alias 内网透传缓冲区清空 */ + for (i = 1; i <= (s_CFM_Sock.num_InnetRaw + s_CFM_Sock.num_InnetRaw_Extend); i++) + { + if (RAW_COM_DISENABLE != g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].Port_Type_Enable) + { + if((0x55u == (CM_UINT16)g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].INNET_2oo2_RAW) && (0x55u == (CM_UINT16)g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].TIME_STAMP_ENABLE)) + { + (void)CM_Mutex_Lock(s_CFM_RxInnetRaw[i].mutex); + rt = CM_MQ_Flush(&s_CFM_RxInnetRaw[i].MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_4); + rt = CM_MQ_Flush(&s_CFM_RxInnetRaw[i].InfoQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_5); + (void)CM_Mutex_Unlock(s_CFM_RxInnetRaw[i].mutex); + } + else + { + rt = CM_MQ_Flush(&s_CFM_RxInnetRaw[i].MsgQ); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_27, TSCP_DARK_ASSERT_6); + } + } + else + { + + } + } +} +/** +* @brief 内网安全通信数据接收 +* @param pBuf 接收报文指针 +* @param BufSize 接收报文缓冲区大小 +* @param pSrcIP 源IP +* @param pSrcPort 源端口 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_InnetSafe_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT CM_UINT32* pSrcIP, OUT CM_UINT16* pSrcPort) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_RxInnetSafe.MsgQ, s_CFM_UDP_Cache, &len); + /*- 是否收到有效报文 */ + if ((ENUM_CM_TRUE == rt) && (len > 6u)) + { + /*- 保存源IP、端口和收到的报文 */ + *pSrcIP = CM_LongFromChar(s_CFM_UDP_Cache); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + *pSrcPort = CM_ShortFromChar(s_CFM_UDP_Cache + 4); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + len -= 6u; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_21, TSCP_DARK_ASSERT_1); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} +/** +* @brief 内网安全通信数据接收 +* @param pBuf 接收报文指针 +* @param BufSize 接收报文缓冲区大小 +* @param pSrcIP 源IP +* @param pSrcPort 源端口 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_InnetSafeRm_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT CM_UINT32* pSrcIP, OUT CM_UINT16* pSrcPort) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_ASSERT(pBuf != NULL, NET_MODE,DARK_FAULT_CODE_FUN_ORDER_35, TSCP_DARK_ASSERT_2); + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_RxRemoteUpdate.MsgQ, s_CFM_UDP_Cache, &len); + /*- 是否收到有效报文 */ + if ((ENUM_CM_TRUE == rt) && (len > 6u)) + { + /*- 保存源IP、端口和收到的报文 */ + *pSrcIP = CM_LongFromChar(s_CFM_UDP_Cache); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + *pSrcPort = CM_ShortFromChar(s_CFM_UDP_Cache + 4); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + len -= 6u; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_35, TSCP_DARK_ASSERT_1); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} + +/** +* @brief 内网安全远程部署通信数据接收 +* @param pBuf 接收报文指针 +* @param BufSize 接收报文缓冲区大小 +* @param pSrcIP 源IP +* @param pSrcPort 源端口 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_INT32 CFM_InnetRemoteUpdate_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT CM_UINT32* pSrcIP, OUT CM_UINT16* pSrcPort) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_ASSERT_MAINTAIN(pBuf != NULL); + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_RxRemoteUpdate.MsgQ, s_CFM_UDP_Cache, &len); + /*- 是否收到有效报文 */ + if ((ENUM_CM_TRUE == rt) && (len > 6u)) + { + /*- 保存源IP、端口和收到的报文 */ + *pSrcIP = CM_LongFromChar(s_CFM_UDP_Cache); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + *pSrcPort = CM_ShortFromChar(s_CFM_UDP_Cache + 4); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + len -= 6u; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + if (ENUM_CM_TRUE != rt) + { + len = 0u; + MSCP_LOG_MSG("CFM_InnetRemoteUpdate_Recv CM_Memcpy error!!! \n"); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_1)); + } + else + { + /*成功无操作*/ + } + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} + +/** +* @brief 内网安全通信数据发送 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @param DstIP 目的IP +* @param DstPort 目的端口 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_InnetSafe_Send(IN const CM_UINT8* Buf, IN CM_INT32 Len, IN CM_UINT32 DstIP, IN CM_UINT16 DstPort) +{ + /*- 返回内网安全通信通道的发送结果 */ + return CM_UDP_Send_Msg(s_CFM_Sock.Sock_InnetSafe, Buf, Len, DstIP, DstPort); +} + +/** +* @brief 内网远程部署安全通信数据发送 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @param DstIP 目的IP +* @param DstPort 目的端口 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_InnetRemoteUpdate_Send(IN const CM_UINT8* Buf, IN CM_INT32 Len, IN CM_UINT32 DstIP, IN CM_UINT16 DstPort) +{ + /*- 返回内网安全通信通道的发送结果 */ + return CM_UDP_Send_Msg(s_CFM_Sock.Sock_Remote_Update, Buf, Len, DstIP, DstPort); +} + +/** +* @brief 内网透传通信数据接收 +* @param ch 内网透传通道序号,[1...n]有效 +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @param pSrcIP 源IP +* @param pSrcPort 源端口 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_UINT16 CFM_InnetRaw_Recv(IN CM_INT32 ch, OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT CM_UINT32* pSrcIP, OUT CM_UINT16* pSrcPort) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_RxInnetRaw[ch].MsgQ, s_CFM_UDP_Cache, &len); + /*- 是否收到有效报文 */ + if ((ENUM_CM_TRUE == rt) && (len > (CM_UINT16)(6u))) + { + /*- 保存源IP、端口和收到的报文 */ + len -= 6u; + *pSrcIP = CM_LongFromChar(s_CFM_UDP_Cache); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + *pSrcPort = CM_ShortFromChar(s_CFM_UDP_Cache + 4); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)(len)); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_22, TSCP_DARK_ASSERT_1); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return len; +} + +/** +* @brief 内网透传通信数据发送 +* @param ch 内网透传通道序号,[1...n]有效 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @param DstIP 目的IP +* @param DstPort 目的端口 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_InnetRaw_Send(IN CM_INT32 ch, IN const CM_UINT8* Buf, IN CM_INT32 Len, IN CM_UINT32 DstIP, IN CM_UINT16 DstPort) +{ + /*- 返回内网透传通信通道的发送结果 */ + return CM_UDP_Send_Msg(s_CFM_Sock.Sock_InnetRaw[ch], Buf, Len, DstIP, DstPort); +} + +/** +* @brief 外网安全通信数据接收 +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @param pChn 外网通道类型 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0或负数 接收失败 +*/ +CM_INT32 CFM_OutnetSafe_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT ENUM_OUTNET_CHN_T* pChn) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_UINT32 srcIP = 0u; + CM_UINT16 srcPort = 0u; + + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_RxOutnetSafe.MsgQ, s_CFM_UDP_Cache, &len); + /*- 是否收到有效报文 */ + if ((ENUM_CM_TRUE == rt) && (len > 6u)) + { + /*- 读取源IP和端口 */ + srcIP = CM_LongFromChar(s_CFM_UDP_Cache); + srcPort = CM_ShortFromChar(s_CFM_UDP_Cache + 4); + len -= 6u; + /*- 是否来自红网CC */ + if ((srcIP == inet_addr(g_PFM_Cfg.CC_R_IP)) && (g_PFM_Cfg.CC_R_OutnetSafe_Port == srcPort)) + { + /*- 来自外网红网 */ + *pChn = ENUM_OUTNET_RED; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_23, TSCP_DARK_ASSERT_1); + } + /*- 是否来自蓝网CC */ + else if ((srcIP == inet_addr(g_PFM_Cfg.CC_B_IP)) && (g_PFM_Cfg.CC_B_OutnetSafe_Port == srcPort)) + { + /*- 来自外网蓝网 */ + *pChn = ENUM_OUTNET_BLUE; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_23, TSCP_DARK_ASSERT_2); + } + else if ((srcIP == inet_addr(g_PFM_Cfg.EXTEND_R_IP)) && (g_PFM_Cfg.CC_R_OutnetSafe_Port == srcPort)) + { + *pChn = ENUM_OUTNET_EXTEND_RED; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_23, TSCP_DARK_ASSERT_3); + } + else if ((srcIP == inet_addr(g_PFM_Cfg.EXTEND_B_IP)) && (g_PFM_Cfg.CC_B_OutnetSafe_Port == srcPort)) + { + *pChn = ENUM_OUTNET_EXTEND_BLUE; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_23, TSCP_DARK_ASSERT_4); + } + else + { + /*- 异常,宕机*/ + MSCP_LOG_MSG("unkown msg rcv from %08x:%d,len=%d\n", srcIP, srcPort, len); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_OUTNETSAFE_RECVLENERO, 3, \ + sizeof(CM_UINT32),srcIP, + sizeof(CM_UINT16),srcPort, + sizeof(CM_UINT16),len); + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_23, TSCP_DARK_ASSERT_5); + } + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return (CM_INT32)len; +} + +/** +* @brief 外网安全数据发送 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @param Chn 外网通道类型 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_OutnetSafe_Send(IN const CM_UINT8* pBuf, IN CM_INT32 Len, IN ENUM_OUTNET_CHN_T Chn) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 是否是外网红网通道 */ + if (ENUM_OUTNET_RED == Chn) + { + /*- UDP方式以外网数据通道发送给红网CC */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetSafe, pBuf, Len, inet_addr(g_PFM_Cfg.CC_R_IP),g_PFM_Cfg.CC_R_OutnetSafe_Port); + } + /*- 是否是外网蓝网通道 */ + else if (ENUM_OUTNET_BLUE == Chn) + { + /*- UDP方式以外网数据通道发送给蓝网CC */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetSafe, pBuf, Len, inet_addr(g_PFM_Cfg.CC_B_IP), g_PFM_Cfg.CC_B_OutnetSafe_Port); + } + else if (ENUM_OUTNET_EXTEND_RED == Chn) + { + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetSafe, pBuf, Len, inet_addr(g_PFM_Cfg.EXTEND_R_IP), g_PFM_Cfg.CC_R_OutnetSafe_Port); + } + else if (ENUM_OUTNET_EXTEND_BLUE == Chn) + { + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetSafe, pBuf, Len, inet_addr(g_PFM_Cfg.EXTEND_B_IP), g_PFM_Cfg.CC_B_OutnetSafe_Port); + } + else + { + /*- 异常,宕机 */ + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_24, TSCP_DARK_ASSERT_1); + } + /*- 返回发送结果 */ + return rt; +} + +/** +* @brief 外网透传通信数据接收 +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @param pChn 外网通道类型 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0或负数 接收失败 +*/ +CM_UINT16 CFM_OutnetRaw_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT ENUM_OUTNET_CHN_T* pChn) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_UINT32 srcIP = 0u; + CM_UINT16 srcPort = 0u; + + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_RxOutnetRaw.MsgQ, s_CFM_UDP_Cache, &len); + /*- 是否收到有效报文 */ + if ((ENUM_CM_TRUE == rt) && (len > 6u)) + { + /*- 读取源IP和端口 */ + srcIP = CM_LongFromChar(s_CFM_UDP_Cache); + srcPort = CM_ShortFromChar(s_CFM_UDP_Cache + 4); + len -= 6u; + /*- 是否来自红网CC */ + if ((srcIP == inet_addr(g_PFM_Cfg.CC_R_IP)) && (g_PFM_Cfg.CC_R_OutnetRaw_Port == srcPort)) + { + /*- 来自外网红网 */ + *pChn = ENUM_OUTNET_RED; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_25, TSCP_DARK_ASSERT_1); + } + /*- 是否来自蓝网CC */ + else if ((srcIP == inet_addr(g_PFM_Cfg.CC_B_IP)) && (g_PFM_Cfg.CC_B_OutnetRaw_Port == srcPort)) + { + /*- 来自外网蓝网 */ + *pChn = ENUM_OUTNET_BLUE; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_25, TSCP_DARK_ASSERT_2); + } + else if ((srcIP == inet_addr(g_PFM_Cfg.EXTEND_R_IP)) && (g_PFM_Cfg.CC_R_OutnetRaw_Port == srcPort)) + { + *pChn = ENUM_OUTNET_EXTEND_RED; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_25, TSCP_DARK_ASSERT_3); + } + else if ((srcIP == inet_addr(g_PFM_Cfg.EXTEND_B_IP)) && (g_PFM_Cfg.CC_B_OutnetRaw_Port == srcPort)) + { + *pChn = ENUM_OUTNET_EXTEND_BLUE; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_25, TSCP_DARK_ASSERT_4); + } + else + { + /*- 异常,宕机*/ + MSCP_LOG_MSG("unkown msg rcv from %08x:%d,len=%d\n", srcIP, srcPort, len); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_OUTNETRAW_RECVLENERO, 3, \ + sizeof(CM_UINT32),srcIP, + sizeof(CM_UINT16),srcPort, + sizeof(CM_UINT16),len); + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_25, TSCP_DARK_ASSERT_5); + } + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return len; +} + +/** +* @brief 外网透传数据发送 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @param Chn 外网通道类型 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_OutnetRaw_Send(IN const CM_UINT8* pBuf, IN CM_INT32 Len, IN ENUM_OUTNET_CHN_T Chn) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 是否是外网红网通道 */ + if (ENUM_OUTNET_RED == Chn) + { + /*- UDP方式以外网数据通道发送给红网CC */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetRaw, pBuf, Len, inet_addr(g_PFM_Cfg.CC_R_IP),g_PFM_Cfg.CC_R_OutnetRaw_Port); + } + /*- 是否是外网蓝网通道 */ + else if (ENUM_OUTNET_BLUE == Chn) + { + /*- UDP方式以外网数据通道发送给蓝网CC */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetRaw, pBuf, Len, inet_addr(g_PFM_Cfg.CC_B_IP), g_PFM_Cfg.CC_B_OutnetRaw_Port); + } + else if (ENUM_OUTNET_EXTEND_RED == Chn) + { + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetRaw, pBuf, Len, inet_addr(g_PFM_Cfg.EXTEND_R_IP), g_PFM_Cfg.CC_R_OutnetRaw_Port); + } + else if (ENUM_OUTNET_EXTEND_BLUE == Chn) + { + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetRaw, pBuf, Len, inet_addr(g_PFM_Cfg.EXTEND_B_IP), g_PFM_Cfg.CC_B_OutnetRaw_Port); + } + else + { + /*- 异常,宕机 */ + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_26, TSCP_DARK_ASSERT_1); + } + /*- 返回发送结果 */ + return rt; +} + +/** +* @brief 外网心跳通信数据接收 +* @param pBuf 接收报文指针 +* @param BufLen 接收报文缓冲区大小 +* @param pChn 外网通道类型 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0或负数 接收失败 +*/ +CM_UINT16 CFM_OutnetHeart_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT ENUM_OUTNET_CHN_T* pChn) +{ + /*- 变量初始化 */ + CM_UINT16 len = (BufSize > 65535u) ? (CM_UINT16)(65535u) : (CM_UINT16)(BufSize); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_UINT32 srcIP = 0u; + CM_UINT16 srcPort = 0u; + /*- 参数非空检查 */ + if((NULL != pBuf) && (NULL != pChn)) + { + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&s_CFM_RxOutnetHeart.MsgQ, s_CFM_UDP_Cache, &len); + /*- 是否收到有效报文 */ + if ((ENUM_CM_TRUE == rt) && (len > 6u)) + { + /*- 读取源IP和端口 */ + srcIP = CM_LongFromChar(s_CFM_UDP_Cache); + srcPort = CM_ShortFromChar(s_CFM_UDP_Cache + 4); + len -= 6u; + /*- 是否来自红网CC */ + if ((srcIP == inet_addr(g_PFM_Cfg.CC_R_IP)) && (g_PFM_Cfg.CC_R_Heart_Port == srcPort)) + { + /*- 来自外网红网 */ + *pChn = ENUM_OUTNET_RED; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_37, TSCP_DARK_ASSERT_1); + } + /*- 是否来自蓝网CC */ + else if ((srcIP == inet_addr(g_PFM_Cfg.CC_B_IP)) && (g_PFM_Cfg.CC_B_Heart_Port == srcPort)) + { + /*- 来自外网蓝网 */ + *pChn = ENUM_OUTNET_BLUE; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_37, TSCP_DARK_ASSERT_2); + } + /*- 是否来自红网SEB */ + else if ((srcIP == inet_addr(g_PFM_Cfg.EXTEND_R_IP)) && (g_PFM_Cfg.CC_R_Heart_Port == srcPort)) + { + /*- 来自外网红网SEB */ + *pChn = ENUM_OUTNET_EXTEND_RED; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_37, TSCP_DARK_ASSERT_3); + } + /*- 是否来自蓝网SEB */ + else if ((srcIP == inet_addr(g_PFM_Cfg.EXTEND_B_IP)) && (g_PFM_Cfg.CC_B_Heart_Port == srcPort)) + { + /*- 来自外网蓝网SEB */ + *pChn = ENUM_OUTNET_EXTEND_BLUE; + rt = CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, (void*)(s_CFM_UDP_Cache + 6), (CM_SIZE_T)len); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_37, TSCP_DARK_ASSERT_4); + } + else + { + /*- 异常,宕机*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_OUTNETHEART_RECVLENERO, 3, \ + sizeof(CM_UINT32),srcIP, + sizeof(CM_UINT16),srcPort, + sizeof(CM_UINT16),len); + MSCP_LOG_MSG("unkown msg rcv from %08x:%d,len=%d\n", srcIP, srcPort, len); + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_37, TSCP_DARK_ASSERT_5); + } + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + } + else + { + /*- 空指针无处理*/ + } + /*- 返回接收长度 */ + return len; +} +/** +* @brief 外网心跳数据发送 +* @param pBuf 发送报文指针 +* @param Len 发送报文长度 +* @param Chn 外网通道类型 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CFM_OutnetHeart_Send(IN const CM_UINT8* pBuf, IN CM_INT32 Len, IN ENUM_OUTNET_CHN_T Chn) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 参数非空检查 */ + if(NULL != pBuf) + { + /*- 是否是外网红网通道 */ + if (ENUM_OUTNET_RED == Chn) + { + /*- UDP方式以外网数据通道发送给红网CC */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetHeart, pBuf, Len, inet_addr(g_PFM_Cfg.CC_R_IP),g_PFM_Cfg.CC_R_Heart_Port); + } + /*- 是否是外网蓝网通道 */ + else if (ENUM_OUTNET_BLUE == Chn) + { + /*- UDP方式以外网数据通道发送给蓝网CC */ + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetHeart, pBuf, Len, inet_addr(g_PFM_Cfg.CC_B_IP), g_PFM_Cfg.CC_B_Heart_Port); + } + /*- 是否是外网扩展红网通道 */ + else if (ENUM_OUTNET_EXTEND_RED == Chn) + { + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetHeart, pBuf, Len, inet_addr(g_PFM_Cfg.EXTEND_R_IP), g_PFM_Cfg.CC_R_Heart_Port); + } + /*- 是否是外网扩展蓝网通道 */ + else if (ENUM_OUTNET_EXTEND_BLUE == Chn) + { + rt = CM_UDP_Send_Msg(s_CFM_Sock.Sock_OutnetHeart, pBuf, Len, inet_addr(g_PFM_Cfg.EXTEND_B_IP), g_PFM_Cfg.CC_B_Heart_Port); + } + else + { + /*- 异常,宕机 */ + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_36, TSCP_DARK_ASSERT_1); + } + } + else + { + /*- 空指针无处理*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(NET_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_1)); + } + /*- 返回发送结果 */ + return rt; +} + + +static CM_THREAD_FUNC_T t_ClearArpThread(void) +{ + static STRU_HARDWARE_BOOT_COM_T lastComRecord; + CM_UINT32 cycle = DFM_GetBirthCount(); +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + while(1) + { + cycle = DFM_GetBirthCount(); + if((cycle > (g_Hardware_boot_com_state.CCU_A_Count + 100u))&&(lastComRecord.CCU_A_Count != g_Hardware_boot_com_state.CCU_A_Count)) + { + lastComRecord.CCU_A_Count = g_Hardware_boot_com_state.CCU_A_Count; + if(g_PFM_Cfg.CPU_ID == 1u) + { + (void)system("arp -d 192.168.1.60"); + } + else + { + (void)system("arp -d 192.168.2.60"); + } + MSCP_LOG_MSG("clear arp cycle = %d,g_Hardware_boot_com_state.CCU_A_Count=%d,lastComRecord.CCU_A_Count=%d\n",cycle,g_Hardware_boot_com_state.CCU_A_Count,lastComRecord.CCU_A_Count); + } + else + { + /* 无处理 */ + } + + if((cycle > (g_Hardware_boot_com_state.CCU_B_Count + 100u))&&(lastComRecord.CCU_B_Count != g_Hardware_boot_com_state.CCU_B_Count)) + { + lastComRecord.CCU_B_Count = g_Hardware_boot_com_state.CCU_B_Count; + if(g_PFM_Cfg.CPU_ID == 1u) + { + (void)system("arp -d 192.168.1.61"); + } + else + { + (void)system("arp -d 192.168.2.61"); + } + MSCP_LOG_MSG("clear arp cycle = %d,g_Hardware_boot_com_state.CCU_B_Count=%d,lastComRecord.CCU_B_Count=%d\n",cycle,g_Hardware_boot_com_state.CCU_B_Count,lastComRecord.CCU_B_Count); + } + else + { + /* 无处理 */ + } + + if(NULL == p_Serial_IN_VOBC_Func) + { + /* 无处理 */ + } + else + { + if((cycle > (g_Hardware_boot_com_state.SEB_A_Count + 100u))&&(lastComRecord.SEB_A_Count != g_Hardware_boot_com_state.SEB_A_Count)) + { + lastComRecord.SEB_A_Count = g_Hardware_boot_com_state.SEB_A_Count; + if(g_PFM_Cfg.CPU_ID == 1u) + { + (void)system("arp -d 192.168.1.70"); + } + else + { + (void)system("arp -d 192.168.2.70"); + } + MSCP_LOG_MSG("clear arp cycle = %d,g_Hardware_boot_com_state.SEB_A_Count=%d,lastComRecord.SEB_A_Count=%d\n",cycle,g_Hardware_boot_com_state.SEB_A_Count,lastComRecord.SEB_A_Count); + } + else + { + /* 无处理 */ + } + + if((cycle > (g_Hardware_boot_com_state.SEB_B_Count + 100u))&&(lastComRecord.SEB_B_Count != g_Hardware_boot_com_state.SEB_B_Count)) + { + lastComRecord.SEB_B_Count = g_Hardware_boot_com_state.SEB_B_Count; + if(g_PFM_Cfg.CPU_ID == 1u) + { + (void)system("arp -d 192.168.1.71"); + } + else + { + (void)system("arp -d 192.168.2.71"); + } + MSCP_LOG_MSG("clear arp cycle = %d,g_Hardware_boot_com_state.SEB_B_Count=%d,lastComRecord.SEB_B_Count=%d\n",cycle,g_Hardware_boot_com_state.SEB_B_Count,lastComRecord.SEB_B_Count); + } + else + { + /* 无处理 */ + } + } + + CM_Sleep(1000u); + } + return NULL; +} + + +/* +MAC层:14字节 +dst MAC [6] src MAC [6] type [2] +IP层:20字节 +head [12] src ip [4] dst ip [4] +UDP层:8字节 +src port [2] dst port [2] len [2] crc16 [2] +TCP层:20字节 +... +*/ diff --git a/TSCP/src/MSCP/CFM/CFM_Net.h b/TSCP/src/MSCP/CFM/CFM_Net.h new file mode 100644 index 0000000..72b6b64 --- /dev/null +++ b/TSCP/src/MSCP/CFM/CFM_Net.h @@ -0,0 +1,663 @@ +/** +* @file CFM_Net.h +* @brief Communication Function Module: 网络通信功能 +* @details +* 2oo2、2x2、内网、外网、校时、同步等的以太网通信实现 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CFM_NET_H +#define CFM_NET_H + +#include "CM_Types.h" +#include "CM_Sem.h" +#include "MSCP_APP_Interface.h" +#include "CM_Mutex.h" +#include "PFM_Cfg.h" +#if QNX +#include /* ThreadCtl BMP绑定CPU*/ +#endif +#ifdef __cplusplus +extern "C" +{ +#endif + + /*注意UDP协议栈单个UDP包最大65535字节(1024*64-1)*/ +#define NET_UDP_2OO2_BUF_SIZE ((1024*64)-(1)) /*2OO2UDP协议栈缓冲区大小(用于接收代码)*/ +#define NET_UDP_MAINTENANCE_BUF_SIZE ((1024*5)-(1)) /*2OO2UDP协议栈缓冲区大小(维护模式下用于接收代码)*/ +#define NET_UDP_2X2_BUF_SIZE ((1024*64)-(1)) /*2X2UDP协议栈缓冲区大小(用于接收代码)*/ +#define NET_UDP_BUF_SIZE ((1024*64)-(1)) /*UDPsocket消息队列缓冲区(用于接收代码)*/ +#define NET_UDP_BUF_DOUBLESIZE ((1024*256) - (1)) /*UDP协议栈缓冲区大小(用于接收代码)*/ + +#define NET_50K_SIZE (50000u) /*实际允许使用的应用帧大小(用于发送代码)*/ +#define NET_20K_SIZE (20000u) /*实际允许使用的应用帧大小(用于发送代码)*/ +#define CFM_INNET_RAW_MSG_NUM_MAX (7000u) +#define CFM_OUTNET_RAW_MSG_NUM_MAX (1000u) + + +/*暗文类型宏定义*/ +#define DARK_LOG_STRING (0x55u) +#define DARK_LOG_HEX (0xAAu) +#define DARK_LOG_DEC (0xFFu) + + /*- 时钟同步报文类型 */ + typedef enum + { + ENUM_TIME_ERROR = 0, /**< 保留 */ + ENUM_TIME_REQ, /**< 时钟同步请求 */ + ENUM_TIME_ACK /**< 时钟同步应答 */ + }ENUM_TIME_MSG_T; + + typedef struct + { + CM_SEM_T m_logStart; /* 自检开始信号量 */ + CM_SEM_T m_logStop; /* 自检结束信号量 */ + CM_MUTEX_T mutex; /**< 互斥信号量 */ + }STRU_LOG_CTRL_T; + + /*- 时钟同步报文类型 */ + typedef enum + { + ENUM_THREAD_ERROR = 0, /**< 保留 */ + ENUM_THREAD_OutnetS_Rx = 1, /**< 外网安全线程 */ + ENUM_THREAD_2oo2_AppRecv = 2, /**< 应用2取线程 */ + ENUM_THREAD_2x2_StateRecv = 3 /**< 状态2x线程 */ + }ENUM_THREAD_NUM_T; + + /* 暗文发送控制变量 */ + extern STRU_LOG_CTRL_T ciphertextCtrl; + /** 2oo2小数据量单包通信控制 */ + typedef struct + { + CM_UINT32 SN; /**< 通信序列号 */ + /*2取发送函数指针注册*/ + ENUM_CM_RETURN (*DataSend)(IN const CM_UINT8* , IN CM_INT32 ); + /*2取接收函数指针注册*/ + CM_INT32 (*DataRecv)(OUT CM_UINT8* , IN CM_UINT32 ); + }STRU_2OO2_NET_NO_PACK_T; + + /** 小数据量单包2oo2报文类型 */ + typedef enum + { + ENUM_2oo2_NET_ERROR = 0, /**< 保留 */ + ENUM_2oo2_NET_DATA, /**< 数据*/ + ENUM_2oo2_NET_ARQ, /*重传请求*/ + ENUM_2oo2_NET_RCV_SUCCESS, /*接收成功标志*/ + }ENUM_2oo2_NET_T; + + /*注册透传算法函数指针数组*/ + extern RAW_ALGORITHM p_ALGORITHM_Fun[INNET_RAW_DOUBLE_PASS_NUM]; + /*硬重启通信状态结构体*/ + typedef struct + { + CM_UINT32 SYS_Count; /*-系统周期 */ + CM_UINT32 CCU_A_Count;/*-通控A周期 */ + CM_UINT32 CCU_B_Count;/*-通控B周期 */ + CM_UINT32 SEB_A_Count;/*-串口板A周期 */ + CM_UINT32 SEB_B_Count;/*-串口板B周期 */ + }STRU_HARDWARE_BOOT_COM_T; + + extern STRU_HARDWARE_BOOT_COM_T g_Hardware_boot_com_state; + /** + * @brief 2oo2上电同步 + * @details + */ + ENUM_CM_RETURN CFM_2oo2_InitSync(void); + + /** + * @brief 发起一次2oo2时钟同步 + * @details + * 发送一个2oo2时钟同步请求报文 + * 由双方的时钟同步线程完成一次NTP校时操作 + * 操作完成后本方的时钟同步线程会记录到延迟时间和偏移时间 + * @see :: CFM_2oo2_TimeGet + * @see :: t_TimeThread + */ + void CFM_2oo2_TimeReq(void); + + /** + * @brief 读取时钟同步结果 + * @param pDelay 延迟时间 + * @param pOffset 偏移时间 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2oo2_TimeGet(OUT CM_INT64* pDelay, OUT CM_INT64* pOffset); + + /** + * @brief 2oo2数据发送 + * @param pBuf 发送报文指针 + * @param BufLen 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2oo2_DataSend(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen); + + /** + * @brief 2oo2数据接收 + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_2oo2_DataRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); + + /** + * @brief 2oo2数据发送 + * @param pBuf 发送报文指针 取值范围:非空 + * @param BufLen 发送报文长度 取值范围:0~0x7FFFFFFF + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2oo2_DataSend_App(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen); + + /** + * @brief 2oo2数据接收 + * @param pBuf 接收报文指针 取值范围:非空 + * @param BufLen 接收报文缓冲区大小 取值范围:0~0xFFFFFFFF + * @return 接收报文长度 + * - 1~0xFFFFFFFF 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_2oo2_DataRecv_App(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); + + /** + * @brief 2oo2数据发送 + * @param pBuf 发送报文指针 + * @param BufLen 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2oo2_2xStateSend(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen); + + /** + * @brief 2oo2数据接收 + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_2oo2_2xStateRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); + + /** + * @brief 2oo2数据发送(维护模式) + * @param pBuf 发送报文指针 + * @param BufLen 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2oo2_DataSend_Crash(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen); + + /** + * @brief 2oo2数据接收(维护模式) + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_2oo2_DataRecv_Crash(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); + + /** + * @brief 2oo2数据发送(宕机状态) + * @param pBuf 发送报文指针 + * @param BufLen 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2oo2_DataSend_ASSERT(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen); + + /** + * @brief 2oo2数据接收(宕机状态) + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_2oo2_DataRecv_ASSERT(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); + + /** + * @breif 全双工不分包2oo2数据交换,支持重传 + * @param pMyData 本机数据指针 + * @param DataLen 本剧数据长度 + * @param pPeerData 邻机数据指针 + * @param DataSize 邻机数据缓冲区大小 + * @param msgTye 2oo2交换数据类型 + * @return 收到的邻机数据长度 + */ + CM_INT32 CFM_2oo2_Currency_NoSplit(STRU_2OO2_NET_NO_PACK_T *p_2oo2_Ctrl,IN const CM_UINT8 * pMyData, IN CM_INT32 DataLen, OUT CM_UINT8 * pPeerData, IN CM_UINT32 DataSize); + + /** + * @brief 2x2状态数据发送 + * @param pBuf 发送报文指针 取值范围:非空 + * @param BufLen 发送报文长度 取值范围:0~0x7FFFFFFF + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2x2_StateChange_Send(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen); + + /** + * @brief 通用2oo2数据接收 + * @param pBuf 接收报文指针 取值范围:非空 + * @param BufLen 接收报文缓冲区大小 取值范围:0~0xFFFFFFFF + * @return 接收报文长度 + * - 1~0xFFFFFFFF 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_2x2_StateChange_Recv(CM_UINT8* pBuf, IN CM_UINT32 BufSize); + + /** + * @brief 发起一次2x2时钟同步 + * @details + * 发送一个2x2时钟同步请求报文 + * 由双方的时钟同步线程完成一次NTP校时操作 + * 操作完成后本方的时钟同步线程会记录到延迟时间和偏移时间 + * @see :: CFM_2x2_TimeGet + * @see :: t_TimeThread + */ + void CFM_2x2_TimeReq(void); + + /** + * @brief 读取2x2时钟同步结果 + * @param pDelay 延迟时间 + * @param pOffset 偏移时间 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2x2_TimeGet(OUT CM_INT64* pDelay, OUT CM_INT64* pOffset); + + /** + * @brief 2x2同步发送 + * @param pBuf 发送报文指针 + * @param BufLen 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2x2_SyncSend(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen); + + /** + * @brief 2x2同步接收 + * @param pBuf 接收报文指针 + * @param bufSize 接收缓冲区大小 + * @param pRxTick 接收时刻 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0或负数 接收失败 + */ + CM_INT32 CFM_2x2_SyncRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 bufSize, OUT CM_UINT64* pRxTick); + + /** + * @brief 2x2数据发送 + * @param pBuf 发送报文指针 + * @param BufLen 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2x2_DataSend(IN const CM_UINT8* pBuf, IN CM_INT32 BufLen); + + /** + * @brief 2x2串口数据发送 + * @param pBuf 发送报文指针 取值范围(非空) + * @param BufLen 发送报文长度 取值范围(0~0xffffffff) + * @param msgType 发送报文类型 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_NULL 发送条件不满足 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_2x2_UartDataSend(IN CM_UINT8* pBuf, IN CM_UINT16 BufLen); + + /** + * @brief 2x2数据接收 + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0或负数 接收失败 + */ + CM_INT32 CFM_2x2_DataRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); + + /** + * @brief 2x2串口数据接收 + * @param pBuf 接收报文指针(非空) + * @param BufLen 接收报文缓冲区大小(0~0xffffffff) + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0或负数 接收失败 + */ + CM_UINT16 CFM_2x2_UartDataRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); + + /* @brief 内网透传TCP通信数据发送 + * @param ch 内网透传通道序号,[1...n]有效 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @param DstIP 目的IP + * @param DstPort 目的端口 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_InnetRaw_Tcp_Send(IN CM_UINT16 Tcpid, IN const CM_UINT8* Buf, IN CM_INT32 Len); + + /*读数据时禁止清空(即使写满)*/ + void CFM_InnetRawClear_Mutex_Lock(IN CM_INT32 ch); + void CFM_InnetRawClear_Mutex_UnLock(IN CM_INT32 ch); + + /** + * @brief 获取指定内网透传通道的全部报文特征信息(时间戳和序列号) + * @param ch 通道号 + * @param info 特征信息 + * @param infoSize 特征信息数组的长度 + * @return 特征信息长度 + */ + CM_UINT32 CFM_InnetRaw_GetInfo(IN CM_INT32 ch, OUT CM_UINT8 info[], IN CM_UINT32 infoSize,OUT CM_UINT8 *CompareEnable); + + /** + * @brief 获取一帧带时间戳的透传数据 + * @param ch 通道号 + * @param bufFirst 帧头 + * @param bufFirstLen 帧头长度 + * @param bufSecond 有效数据 + * @param bufSecondLen 有效数据长度 + * @return 无 + * @details + */ + ENUM_CM_RETURN CFM_InnetRaw_Rx_MsgInfoQueue(IN CM_INT32 ch, OUT CM_UINT8 bufFirst[], IN CM_UINT32 bufFirstLen, + OUT CM_UINT8 *bufSecond, IN CM_UINT32 *bufSecondLen); + + /** + * @brief 清除一帧带时间戳的透传数据 + * @param ch 通道号 + * @return 无 + * @details + */ + void CFM_Clear_InnetRaw_Rx_Msg(IN CM_INT32 ch); + + /** + * @brief 获取接收包数和接受长度并且清空 + */ + void CFM_GetOSCache(void); + + /** + * @brief 清空外网安全数据队列长度 + */ + void CFM_ClearCache(void); + + /*********************************维护网相关*****************************************/ + + /** + * @brief 维护网通信队列初始化 + */ + void CFM_Maintain_Queue_Init(void); + + /** + * @brief 维护网通信UDP初始化 + */ + void CFM_Maintain_Init(void); + /** + * @brief 暗文日志组包发送函数 + * @param 无 + * @return 无 + * @details + */ + void CFM_LogCiphertextSend(void); + /** + * @brief 平台明文日志发送 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_BaseLog_Send(IN const CM_UINT8* Buf, IN CM_INT32 Len); + + /** + * @brief 应用日志发送 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_AppLog_Send(IN const CM_UINT8* Buf, IN CM_INT32 Len); + /** + * @brief 平台日志保存本地文件 + * @param FILE * fp_crash 文件指针 + * @return 无 + */ + void CFM_BaseLog_SaveLocal(FILE * fp_crash); + + /** + * @brief 应用/平台暗文日志存储 + * @param infoType 数据类型 + * 取值范围:0x55:info为字符串数据方式 + * 0xAA:info为十六进制数据方式 + * 0xFF:info为十进制数据方式 + * @param code 信息编码/信息类型 取值范围:0~0xffff + * @param infoLen 数据长度 取值范围:0~0xffff + * @param info 数据/信息 取值范围:任意类型指针 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_DarkLog_Storage(IN const CM_UINT8 infoType, IN const CM_UINT16 code, IN const CM_UINT32 infoLen, IN const void *info); + /** + * @brief 应用/平台暗文日志多变量存储 + * @param infoType 数据类型 + * 取值范围:0x55:info为字符串数据方式 + * 0xAA:info为十六进制数据方式 + * 0xFF:info为十进制数据方式 + * @param code 信息编码/信息类型 取值范围:0~0xffff + * @param infoCut 数据个数 取值范围:0~0xff + * @param ... 可变参数/信息 取值范围:任意类型数据,但是需要与sizeof()成对使用。 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_DarkLog_Multiple(IN const CM_UINT8 infoType, IN const CM_UINT16 code, CM_UINT8 infoCut, ...); + + /*********************************线程通用模块*****************************************/ + + /** + * @brief 2取、远程部署通信初始化 + */ + void CFM_UpdateAnd2oo2_Net_Init(void); + + /** + * @brief 网络通信模块初始化 + */ + void CFM_Net_Init(void); + + /** + * @brief 配置网卡ip + */ + void CFM_NetworkCard_Init(void); + /** + * @brief 清空接收缓冲区 + */ + void CFM_Net2XFlush(void); + /** + * @brief 清空接收缓冲区 + */ + void CFM_Net2X_State_Flush(void); + /** + * @brief 清空接收缓冲区 + */ + void CFM_NetFlush(void); + + /** + * @brief 内网安全通信数据接收 + * @param pBuf 接收报文指针 + * @param BufSize 接收报文缓冲区大小 + * @param pSrcIP 源IP + * @param pSrcPort 源端口 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_InnetSafe_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT CM_UINT32* pSrcIP, OUT CM_UINT16* pSrcPort); + + /** + * @brief 内网安全通信数据接收 + * @param pBuf 接收报文指针 + * @param BufSize 接收报文缓冲区大小 + * @param pSrcIP 源IP + * @param pSrcPort 源端口 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_InnetSafeRm_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT CM_UINT32* pSrcIP, OUT CM_UINT16* pSrcPort); + + /** + * @brief 内网安全远程部署通信数据接收 + * @param pBuf 接收报文指针 + * @param BufSize 接收报文缓冲区大小 + * @param pSrcIP 源IP + * @param pSrcPort 源端口 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0 接收失败 + */ + CM_INT32 CFM_InnetRemoteUpdate_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT CM_UINT32* pSrcIP, OUT CM_UINT16* pSrcPort); + + /** + * @brief 内网安全通信数据发送 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @param DstIP 目的IP + * @param DstPort 目的端口 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_InnetSafe_Send(IN const CM_UINT8* Buf, IN CM_INT32 Len, IN CM_UINT32 DstIP, IN CM_UINT16 DstPort); + + /** + * @brief 内网远程部署安全通信数据发送 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @param DstIP 目的IP + * @param DstPort 目的端口 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_InnetRemoteUpdate_Send(IN const CM_UINT8* Buf, IN CM_INT32 Len, IN CM_UINT32 DstIP, IN CM_UINT16 DstPort); + + /** + * @brief 内网透传通信数据接收 + * @param ch 内网透传通道序号,[1...n]有效 + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @param pSrcIP 源IP + * @param pSrcPort 源端口 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0 接收失败 + */ + CM_UINT16 CFM_InnetRaw_Recv(IN CM_INT32 ch, OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT CM_UINT32* pSrcIP, OUT CM_UINT16* pSrcPort); + + /** + * @brief 内网透传通信数据发送 + * @param ch 内网透传通道序号,[1...n]有效 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @param DstIP 目的IP + * @param DstPort 目的端口 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_InnetRaw_Send(IN CM_INT32 ch, IN const CM_UINT8* Buf, IN CM_INT32 Len, IN CM_UINT32 DstIP, IN CM_UINT16 DstPort); + + /** + * @brief 外网安全通信数据接收 + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @param pChn 外网通道类型 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0或负数 接收失败 + */ + CM_INT32 CFM_OutnetSafe_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT ENUM_OUTNET_CHN_T* pChn); + + /** + * @brief 外网安全数据发送 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @param Chn 外网通道类型 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_OutnetSafe_Send(IN const CM_UINT8* pBuf, IN CM_INT32 Len, IN ENUM_OUTNET_CHN_T Chn); + + /** + * @brief 外网透传通信数据接收 + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @param pChn 外网通道类型 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0或负数 接收失败 + */ + CM_UINT16 CFM_OutnetRaw_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT ENUM_OUTNET_CHN_T* pChn); + + /** + * @brief 外网透传数据发送 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @param Chn 外网通道类型 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_OutnetRaw_Send(IN const CM_UINT8* pBuf, IN CM_INT32 Len, IN ENUM_OUTNET_CHN_T Chn); + + /** + * @brief 外网心跳通信数据接收 + * @param pBuf 接收报文指针 + * @param BufLen 接收报文缓冲区大小 + * @param pChn 外网通道类型 + * @return 接收报文长度 + * - 正整数 接收报文长度 + * - 0或负数 接收失败 + */ + CM_UINT16 CFM_OutnetHeart_Recv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize, OUT ENUM_OUTNET_CHN_T* pChn); + + /** + * @brief 外网心跳数据发送 + * @param pBuf 发送报文指针 + * @param Len 发送报文长度 + * @param Chn 外网通道类型 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CFM_OutnetHeart_Send(IN const CM_UINT8* pBuf, IN CM_INT32 Len, IN ENUM_OUTNET_CHN_T Chn); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/CFM/CFM_Raw.c b/TSCP/src/MSCP/CFM/CFM_Raw.c new file mode 100644 index 0000000..82ed3dd --- /dev/null +++ b/TSCP/src/MSCP/CFM/CFM_Raw.c @@ -0,0 +1,947 @@ +/** +* @file CFM_Raw.c +* @brief Communication Function Module: 网络透传通信 +* @details +* 内网透传通信的实现 +* @author GT-BU +* @date 2021.03.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.03.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "CFM_Raw.h" +#include "CM_Convert.h" +#include "CFM_Net.h" +#include "PFM_Log.h" +#include "CM_Mutex.h" +#include "DFM_Time.h" +#include "SFM_2oo2.h" +#include "CM_Memory.h" +#include "PFM_Cfg.h" +#include "PFM_RemoteUpdate.h" +#include "CM_CRC32.h" +/** +* @brief 内网透传数据接收 +* @param ch 内网透传通道序号,[1...n]有效 +* @param Buf 接收内网透传数据指针 +* @param bufSize 接收内网透传数据缓冲区大小 +* @return 收到的内网透传数据帧长度 +* @details +* 从通信层获取本周期内网透传输入数据 +* 按内网透传接收帧打包后交给平台层 +*/ +static CM_UINT32 s_CFM_RawInfo_len = 0u; +static CM_UINT8 s_CFM_RawInfo[CFM_INNET_RAW_MSG_NUM_MAX * 12u]; +static CM_UINT32 s_CFM_RawInfo_peer_len = 0u; +static CM_UINT8 s_CFM_RawInfo_peer[CFM_INNET_RAW_MSG_NUM_MAX * 12u]; +/** +* @brief 内网透传接收(通用模式--原艾弗瑞模式) +* @param ch 透传通道号 +* @buf 接收数组 +* @bufSize 接收数组大小 +* @maininfobuf 本机辅助信息数组 +* @maininfolen 本机辅助信息数组长度 +* @peerinfobuf 邻机辅助信息数组 +* @peerinfolen 邻机辅助信息数组长度 +* @infobufSize +* @return 接收数据长度 +*/ +CM_UINT32 CFM_RxInnetRaw_COM(IN CM_INT32 ch, OUT CM_UINT8* buf, IN CM_UINT32 bufSize, + OUT CM_UINT8* maininfobuf,OUT CM_UINT32* maininfolen, + OUT CM_UINT8* peerinfobuf,OUT CM_UINT32* peerinfolen,IN CM_UINT32 infobufSize) +{ + /*- 变量初始化 */ + CM_UINT32 len = 0u; + CM_UINT8 CompareEnable = 0u; + if(RAW_COM_DISENABLE == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[ch].Port_Type_Enable) + { + /*禁用透传端口*/ + } + else + { + + /*- 是否开启2oo2功能 */ + if ((0x55u == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[ch].INNET_2oo2_RAW) && + (0x55u == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[ch].TIME_STAMP_ENABLE)) + { + CFM_InnetRawClear_Mutex_Lock(ch); + /*- 获取本机的内网透传通道特征信息 */ + s_CFM_RawInfo_len = CFM_InnetRaw_GetInfo(ch, s_CFM_RawInfo, (CM_UINT32)sizeof(s_CFM_RawInfo),&CompareEnable); + /*- 将特征信息进行2oo2交换 */ + if(0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + s_CFM_RawInfo_peer_len = (CM_UINT32)SFM_2oo2_Exchange_Currency(s_CFM_RawInfo, (CM_INT32)s_CFM_RawInfo_len, s_CFM_RawInfo_peer, (CM_UINT32)sizeof(s_CFM_RawInfo_peer), ENUM_2oo2_RAW_INFO); + } + else + { + /*二取开关未打开*/ + } + /*MSCP_LOG_MSG("[%d]info:%d,%d\n", ch, s_CFM_RawInfo_len, s_CFM_RawInfo_peer_len);*/ + if(1u == CompareEnable) + { + /*- 对双机的特征信息进行比较,提取2oo2比较一致的内网透传接收报文*/ + len = CFM_InnetRaw_Rx(ch, buf, bufSize); + MSCP_LOG_MSG("[%d]rx %u Info, %u bytes\n", ch, s_CFM_RawInfo_len/12u, len); + } + else + { + /*不比较数据,直接读取透传数据到缓冲区*/ + len = CFM_InnetRaw_Rx_Camera(ch, buf, bufSize,maininfobuf,maininfolen,peerinfobuf,peerinfolen,infobufSize); + MSCP_LOG_MSG("[%d]rx %d Info,%u Minfo,%u Pinfo, %u bytes\n", ch, s_CFM_RawInfo_len/10u,*maininfolen,*peerinfolen, len); + } + CFM_InnetRawClear_Mutex_UnLock(ch); + } + else + { + /*- 从内网透传通道读取接收信息 */ + len = CFM_RxInnetRaw(ch, buf, bufSize); + } + + } + /*- 返回接收数据长度 */ + return len; +} +/** +* @brief 内网透传接收 +* @param ch 内网透传通道号 +* @param buf 接收数组 +* @param bufSize 接收数组大小 +* @return 接收数据长度 +*/ +CM_UINT32 CFM_RxInnetRaw(IN CM_INT32 ch, OUT CM_UINT8 *buf, IN CM_UINT32 bufSize) +{ + /*- 变量初始化 */ + CM_UINT32 rxLen = 0u; /* 接收报文长度 */ + CM_UINT32 i = 0u; /* 循环变量 */ + CM_UINT32 srcIP = 0u; /* 源IP */ + CM_UINT16 srcPort = 0u; /* 源端口 */ + CM_UINT16 devID = 0u; /* 设备ID */ + STRU_PFM_INNET_CFG_T *pCom = NULL; /*通信配置信息*/ + + CM_INT32 count = 0; + + /*- 循环接收内网透传数据 */ + do + { + /*- 从通信层读取通信数据 */ + rxLen = (CM_UINT32)CFM_InnetRaw_Recv(ch, buf + i + PFM_RAW_HEADER_SIZE, bufSize - (CM_UINT32)i - PFM_RAW_HEADER_SIZE, &srcIP, &srcPort); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + /*- 是否读到了数据 */ + if (rxLen > 0u) + { + /*- 获取源ID */ + pCom = PFM_INI_InnetIP2Addr(srcIP, srcPort); + + if(NULL == pCom) + { + devID = (CM_UINT16)ch; + } + else + { + devID = pCom->InnetID; + } + + count++; + + /* + 内网透传帧格式: + 4字节 长度(不含自身) + 2字节 源ID + n字节 数据 + */ + /*- 填入接收队列 */ + CM_LongToChar((rxLen + PFM_RAW_DEVID_SIZE), buf + i); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + CM_ShortToChar(devID, buf + i + PFM_RAW_LEN_SIZE); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + /* i += (rxLen + 4); */ + i = i + (rxLen + PFM_RAW_HEADER_SIZE); + } + else + { + /*- 无处理 */ + } + } while (rxLen > 0u); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_CFMNET_INNETRAW_RECVLEN, 3U, + sizeof(CM_INT32),ch, + sizeof(CM_INT32),count, + sizeof(CM_UINT32),i); + /*- @alias 记录接收信息数量 */ + MSCP_LOG_MSG("[%d]rx %d pkts, %d bytes\n", ch, count, i); + + /*- 返回报文总长度 */ + return i; +} +/** +* @brief 雷达数据的2oo2比较接收 +* @param ch 通道号 +* @param peer_info 邻机特征信息数组 +* @param peer_len 邻机特征信息长度 +* @param buf 2oo2通过的接收信息数组 +* @param buf_size 接收信息数组大小 +* @return 2oo2通过的接收信息长度 +* @details +* 核心算法描述如下: +* while(!local.empty() && !peer.empty()) +* { +* info_local = local.front(); +* info_peer = peer.front(); +* if (info_local.ts == info_peer.ts) +* { +* if (info_local.crc == info_peer.crc) +* { +* app.push(info_local.msg); +* } +* local.pop(); +* peer.pop(); +* } +* else if (info_local.ts < info_peer.ts) +* { +* local.pop(); +* } +* else +* { +* peer.pop(); +* } +* } +*/ +CM_UINT32 CFM_InnetRaw_Rx(IN CM_INT32 ch, OUT CM_UINT8 buf[], IN CM_UINT32 buf_size) +{ + /*- 变量初始化 */ + CM_UINT32 rtnLen = 0u;/*返回数据长度*/ + CM_UINT32 local_info_len = 0u;/*本机信息长度*/ + CM_UINT32 peer_info_len = 0u;/*临机信息长度*/ + CM_UINT32 local_now_info_len = 0u;/*本机当前信息长度*/ + CM_UINT32 peer_now_info_len = 0u;/*临机当前信息长度*/ + CM_UINT64 ts_local = 0u; /* 本机时间戳 */ + CM_UINT64 ts_peer = 0u; /* 邻机时间戳 */ + CM_UINT32 crc_local = 0u;/* 本机CRC */ + CM_UINT32 crc_peer = 0u; /* 邻机CRC */ + CM_UINT8 temp_buf[16] = {0u};/* 临时信息缓冲 */ + CM_UINT32 temp_len = 0u; /*临时信息长度*/ + CM_UINT32 msg_len = 0u; /*本地信息长度*/ + CM_UINT32 src_ip = 0u; /* 源IP */ + CM_UINT16 src_port = 0u; /* 源端口 */ + + CM_UINT16 dev_id = 0u; /* 源设备ID */ + STRU_PFM_INNET_CFG_T* pCom = NULL; /* 临时变量 */ + + CM_INT32 drop_local = 0; /* 丢弃的本机包数 */ + CM_INT32 drop_peer = 0; /* 丢弃的邻机包数 */ + CM_INT32 drop_both = 0; /* 丢弃的双机包数(CRC不一致)*/ + CM_INT32 count = 0; /* 总包数 */ + CM_UINT64 stick = 0u; /* 开始时刻 */ + CM_UINT64 etick = 0u; /* 结束时刻 */ + + /*- 读取消息数量 */ + local_info_len = s_CFM_RawInfo_len / 12u; + peer_info_len = s_CFM_RawInfo_peer_len / 12u; + stick= CM_64FromChar(s_CFM_RawInfo); + if(0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*2取使能*/ + while(((local_info_len - local_now_info_len) > 0u) && ((peer_info_len - peer_now_info_len) > 0u)) + { + /*- 获取本机队列和邻机队列队首的特征信息 */ + ts_local = CM_64FromChar(&s_CFM_RawInfo[(local_now_info_len*12u)]); + crc_local = CM_LongFromChar(&s_CFM_RawInfo[(local_now_info_len*12u) + 8u]); + + ts_peer = CM_64FromChar(&s_CFM_RawInfo_peer[(peer_now_info_len*12u)]); + crc_peer = CM_LongFromChar(&s_CFM_RawInfo_peer[(peer_now_info_len * 12u) + 8u]); + /*- 两队队首报文的时间戳是否相同 */ + if (ts_local == ts_peer) + { + /*- 两队队首报文的crc是否相同 */ + if (crc_local == crc_peer) + { + temp_len = 6u; + msg_len = buf_size - (CM_UINT32)rtnLen; + (void)CFM_InnetRaw_Rx_MsgInfoQueue(ch,&temp_buf[0],temp_len,&buf[rtnLen + PFM_RAW_HEADER_SIZE],&msg_len); + src_ip = CM_LongFromChar(temp_buf); + src_port = CM_ShortFromChar(temp_buf + 4); + /*- 查找源设备ID */ + pCom = PFM_INI_InnetIP2Addr(src_ip, src_port); + + if(NULL == pCom) + { + dev_id = (CM_UINT16)ch; + } + else + { + dev_id = pCom->InnetID; + } + /*- 队首加入应用接收队列 */ + CM_RE_ASSERT(msg_len <= 65531u, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + CM_LongToChar((CM_UINT32)(msg_len+PFM_RAW_DEVID_SIZE),&buf[rtnLen]); + CM_ShortToChar(dev_id, &buf[rtnLen + PFM_RAW_LEN_SIZE]); + rtnLen = rtnLen + (msg_len + PFM_RAW_HEADER_SIZE); + count++; + } + else + { + /*crc比较失败-丢弃此条数据*/ + drop_local++; + CFM_Clear_InnetRaw_Rx_Msg(ch); + } + local_now_info_len++; + peer_now_info_len++; + } + /*- 本机队列队首的时间戳是否更小 */ + else if (ts_local < ts_peer) + { + /*- 本机队列队首出队 */ + CFM_Clear_InnetRaw_Rx_Msg(ch); + local_now_info_len++; + drop_both++; + } + else /* if ts_local > ts_peer */ + { + /*- 邻机队列队首出队 */ + peer_now_info_len++; + drop_peer++; + } + } + } + else + { + /*2取未使能*/ + while(((local_info_len - local_now_info_len) > 0u)) + { + ts_local = CM_64FromChar(&s_CFM_RawInfo[(local_now_info_len*12)]); + temp_len = 6u; + msg_len = (CM_UINT32)buf_size - (CM_UINT32)rtnLen; + (void)CFM_InnetRaw_Rx_MsgInfoQueue(ch,&temp_buf[0],temp_len,&buf[rtnLen + PFM_RAW_HEADER_SIZE],&msg_len); + src_ip = CM_LongFromChar(temp_buf); + src_port = CM_ShortFromChar(temp_buf + 4); + /*- 查找源设备ID */ + pCom = PFM_INI_InnetIP2Addr(src_ip, src_port); + + if(NULL == pCom) + { + dev_id = (CM_UINT16)ch; + } + else + { + dev_id = pCom->InnetID; + } + /*- 队首加入应用接收队列 */ + CM_RE_ASSERT(msg_len <= 65531u, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + CM_LongToChar((CM_UINT32)(msg_len+PFM_RAW_DEVID_SIZE),&buf[rtnLen]); + CM_ShortToChar(dev_id, &buf[rtnLen + PFM_RAW_LEN_SIZE]); + rtnLen = rtnLen + (msg_len + PFM_RAW_HEADER_SIZE); + count++; + local_now_info_len++; + } + } + /*- @alias 记录收到的报文数量 */ + if ((ch == 2) || (ch == 7) || (ch == 1)) + { + etick = ts_local; + MSCP_LOG_MSG("rx[%d]:%d pkts, %d bytes(%llx...%llx)\n", ch,count,rtnLen,stick,etick); + } + else + { + /* 不处理 */ + } + + /*- @alias 记录双机CRC不一致的报文数量 */ + if (drop_local > 0) + { + MSCP_LOG_MSG("[%d]drop local %d pkts\n",ch, drop_local); + } + else + { + /* 不处理 */ + } + + /*- @alias 记录丢弃的邻机报文数量 */ + if (drop_peer > 0) + { + MSCP_LOG_MSG("[%d]drop peer %d pkts\n",ch, drop_peer); + } + else + { + /* 不处理 */ + } + + /*- @alias 记录丢弃的本机报文数量 */ + if (drop_both > 0) + { + MSCP_LOG_MSG("[%d]drop both %d pkts\n",ch, drop_both); + } + else + { + /* 不处理 */ + } + /*判断缓冲区空间是否足够*/ + CM_RE_ASSERT(buf_size >= (CM_UINT32)rtnLen, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + /*- 返回2oo2通过的接收报文长度 */ + return rtnLen; +} +/** +* @brief 相机数据的2oo2比较接收 +* @param ch 通道号 取值范围:0~0xffff +* @param buf 接收数组 取值范围:非空 +* @param buf_size 接收数组大小 取值范围:0~0xffffffff +* @param maininfobuf 本机辅助信息数组 取值范围:非空 +* @param maininfolen 本机辅助信息数组长度 取值范围:非空 +* @param peerinfobuf 邻机辅助信息数组 取值范围:非空 +* @param peerinfolen 邻机辅助信息数组长度 取值范围:非空 +* @param infobufSize 辅助信息通道缓冲区大小 取值范围:0~0xffffffff +* @return 接收数据大小 取值范围:0~0xffffffff +* @details +*/ +CM_UINT32 CFM_InnetRaw_Rx_Camera(IN CM_INT32 ch, OUT CM_UINT8 buf[], IN CM_UINT32 buf_size, + OUT CM_UINT8 maininfobuf[],OUT CM_UINT32* maininfolen, + OUT CM_UINT8 peerinfobuf[],OUT CM_UINT32* peerinfolen,IN CM_UINT32 infobufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT8 RawFrontCache[256u] = { 0u }; /**< 临时缓冲区 */ + CM_UINT16 i = 0u; + CM_UINT16 j = 0u; + CM_UINT16 timeoffset = 0u; + CM_UINT32 tmpmsgLen = 0u; + CM_UINT32 retmsgLen = 0u; + CM_UINT32 msgBeginLen = 0u;/*记录每帧起始下标*/ + CM_UINT32 msgLen = 0u; + CM_UINT32 msgFrontLen = 0u; + CM_UINT32 myinfolen = 0u;/*辅助信息长度*/ + CM_UINT32 otherinfolen = 0u;/*辅助信息长度*/ + CM_UINT8 Complete_Flag = 0u;/*找到完整帧标志*/ + CM_UINT16 Complete_Size = 0u;/*完整帧数量*/ + CM_UINT16 InfoArea = 0u;/*时间戳辅助信息的位置*/ + CM_UINT32 srcIP = 0u; /* 源IP */ + CM_UINT16 srcPort = 0u; /* 源端口 */ + CM_UINT16 devID = 0u; /* 设备ID */ + CM_UINT8 DataType = 0u; /* 数据类型 */ + CM_UINT8 DataShift = 0u; /* 数据类型 */ + STRU_PFM_INNET_CFG_T *pCom = NULL; /*通信配置信息*/ + /*- 循环解析特征信息数据包 */ + CM_ASSERT(buf != NULL, RAW_MODE,DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); + for(i = 0u;i<(s_CFM_RawInfo_len/10u);++i) + { + /*- 获取数据类型 */ + DataType = s_CFM_RawInfo[i*10u]; + /*- 如果是起始帧*/ + if(0x01u == DataType) + { + /*记录找到时间戳*/ + if(1u == Complete_Flag) + { + /*丢弃多余时间戳*/ + + CFM_Clear_InnetRaw_Rx_Msg(ch); + /*丢弃不完整图像数据*/ + for(j = 0u;j < Complete_Size;++j) + { + CFM_Clear_InnetRaw_Rx_Msg(ch); + } + } + else + { + /*nothing to do*/ + } + /*- 如果获取偏移量大于0*/ + if(0u < s_CFM_RawInfo[i*10u+1u]) + { + /*- 偏移为真实偏移量*/ + DataShift = s_CFM_RawInfo[i*10u+1u]+6u; + } + else + { + /*- 偏移为默认兼容旧版本偏移量*/ + DataShift = 14u; + } + /*- 更新找到起始帧标志*/ + Complete_Flag = 1u; + /*- 完整帧包数清零*/ + Complete_Size = 0u; + /*- 更新时间戳偏移量*/ + timeoffset = i; + } + else + { + /*- 如果不是起始帧*/ + if(1u == Complete_Flag) + { + /*- 如果是结束帧*/ + if(0x02u == DataType) + { + /*此阶段日志过多会丢包*/ + /*- 起始帧标志清零*/ + Complete_Flag = 0u; + /*- 取出起始帧数据*/ + CFM_Clear_InnetRaw_Rx_Msg(ch); + /*- 记录起始帧时间戳*/ + (void)CM_Memcpy(&maininfobuf[myinfolen],(infobufSize-myinfolen),&s_CFM_RawInfo[timeoffset*10+2],8u); + myinfolen += 8u; + CM_RE_ASSERT(infobufSize >= myinfolen, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + /* + 内网透传帧格式: + 4字节 长度(不含自身) + 2字节 源ID + n字节 数据 + */ + /*- 拷贝图像数据第一包*/ + msgBeginLen = tmpmsgLen;/*记录起始下标,用来添加长度*/ + tmpmsgLen += PFM_RAW_HEADER_SIZE;/*4字节长度+2字节设备类型ID*/ + msgLen = buf_size - tmpmsgLen; + msgFrontLen = DataShift; + rt = CFM_InnetRaw_Rx_MsgInfoQueue(ch,RawFrontCache,msgFrontLen,&buf[tmpmsgLen],&msgLen); + /*- 如果拷贝图像数据第一包成功*/ + if(ENUM_CM_TRUE == rt) + { + srcIP = CM_LongFromChar(RawFrontCache); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + srcPort = CM_ShortFromChar(RawFrontCache + 4); /* parasoft-suppress BD-PB-CHECKRET "后续在查询对应内网ID时进行非法值防护" */ + /*- 获取设备类型ID*/ + pCom = PFM_INI_InnetIP2Addr(srcIP, srcPort); + /*- 如果设备类型ID为空*/ + if(NULL == pCom) + { + /*- 更新设备类型ID为通道号*/ + devID = (CM_UINT16)ch; + } + else + { + /*- 更新设备类型ID为内网设备ID*/ + devID = pCom->InnetID; + } + /*- 填写设备类型ID*/ + CM_ShortToChar(devID, &buf[msgBeginLen + PFM_RAW_LEN_SIZE]); + tmpmsgLen += msgLen; + /*- 连续拷贝剩余图像数据*/ + for(j = 1u;j < Complete_Size;++j) + { + msgLen = buf_size - tmpmsgLen; + msgFrontLen = DataShift; + rt = CFM_InnetRaw_Rx_MsgInfoQueue(ch,RawFrontCache,msgFrontLen,&buf[tmpmsgLen],&msgLen); + /*- 如果拷贝剩余图像错误*/ + if(ENUM_CM_FALSE == rt) + { + /*- 结束拷贝*/ + break; + } + tmpmsgLen += msgLen; + } + /*- 如果拷贝剩余图像正确*/ + if(ENUM_CM_TRUE == rt) + { + /*- 拷贝完成添加长度*/ + CM_LongToChar((tmpmsgLen - msgBeginLen - PFM_RAW_LEN_SIZE), &buf[msgBeginLen]); + /*- 拷贝完成更新长度*/ + retmsgLen = tmpmsgLen; + /*- 读出帧尾-丢弃*/ + CFM_Clear_InnetRaw_Rx_Msg(ch); + /*- 完整帧数量清零*/ + Complete_Size = 0u; + } + else + { + /*- 空间不足结束处理*/ + break; + } + } + else + { + /*- 空间不足结束处理*/ + break; + } + } + else + { + /*- 更新完整帧包数量*/ + Complete_Size++; + } + } + else + { + /*未找到时间戳也不是时间戳,删除此条消息*/ + CFM_Clear_InnetRaw_Rx_Msg(ch); + } + } + } + /*- 起始帧标志清零*/ + Complete_Flag = 0u; + /*- 完整帧数量清零*/ + Complete_Size = 0u; + /*- 循环解析邻机特征信息数据包 */ + for(i = 0u;i<(s_CFM_RawInfo_peer_len/10u);i++) + { + /*- 获取数据类型 */ + DataType = s_CFM_RawInfo_peer[i*10u]; + /*- 如果是起始帧*/ + if(0x01u == DataType) + { + /*记录找到时间戳*/ + InfoArea = i; + /*- 完整帧包数清零*/ + Complete_Size = 0u; + /*- 更新找到起始帧标志*/ + Complete_Flag = 1u; + } + else + { + /*- 如果不是起始帧*/ + if(1u == Complete_Flag) + { + /*- 如果是结束帧*/ + if(0x02u == DataType) + { + /*- 起始帧标志清零*/ + Complete_Flag = 0u; + /*- 记录起始帧时间戳*/ + (void)CM_Memcpy(&peerinfobuf[otherinfolen],(infobufSize-otherinfolen),&s_CFM_RawInfo_peer[10*InfoArea+2],8u); + otherinfolen += 8u; + } + else + { + /*- 更新完整帧包数量*/ + Complete_Size++; + } + CM_RE_ASSERT(infobufSize >= otherinfolen, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + } + else + { + /*无操作*/ + } + } + } + /*- 输出本机时间戳特征信息长度*/ + *maininfolen = myinfolen; + /*- 输出邻机时间戳特征信息长度*/ + *peerinfolen = otherinfolen; + /*- 输出有效数据长度*/ + return retmsgLen; +} +/** +* @brief 发送内网透传报文 +* @param ch 内网透传通道序号,[1...n]有效 +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +*/ +CM_UINT8 CFM_TxInnetRaw(IN CM_INT32 ch, IN const CM_UINT8 *Buf, IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT8 rt = 1u; + CM_UINT32 i = 0u; + CM_UINT16 msgLen = 0u; + CM_UINT16 dstID = 0u; + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + STRU_PFM_INNET_CFG_T *pCom = NULL; + + /*- 循环发送所有内网透传数据 */ + while ((i + 4u) < Len) + { + /* + 内网透传协议头: + 2字节 长度(不含自身) + 2字节 目的ID + n字节 数据 + */ + /*- 解析内网发送协议头 */ + msgLen = CM_ShortFromChar(Buf + i); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + dstID = CM_ShortFromChar(Buf + i + 2u); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + + CM_RE_ASSERT(msgLen > 2u, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT((i + msgLen + 2u) <= Len, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + + /*- 查询目的IP、端口 */ + pCom = PFM_INI_InnetID2Addr(dstID); + /*- 查询目的IP、端口是否成功 */ + if (NULL != pCom) + { + if(RAW_COM_DISENABLE == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[ch].Port_Type_Enable) + { + /*禁用透传端口*/ + } + else if (RAW_COM_TCP == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[ch].Port_Type_Enable) + { + CM_RE_ASSERT(pCom->InnetID == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[ch].Server_DevId, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + ret = CFM_InnetRaw_Tcp_Send(pCom->InnetID, Buf + i + 4u, (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 2u)); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + /*- @alias 记录发送异常信息 */ + if (ENUM_CM_TRUE != ret) + { + MSCP_LOG_MSG("innet raw tcp send to %04x fail\n", dstID); + rt = 0u; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- @alias 调用通信层发送 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + ret = CFM_InnetRaw_Send(ch, Buf + i + 4u, (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 2u), pCom->IP_G,pCom->Port_Raw_G); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + else + { + ret = CFM_InnetRaw_Send(ch, Buf + i + 4u, (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 2u), pCom->IP_P, pCom->Port_Raw_P); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + MSCP_LOG_MSG("CFM_InnetRaw_Send:ch:%d,dstID:0x%x,len:%d\n", ch,dstID,msgLen - 2u); + /*- @alias 记录发送异常信息 */ + if (ENUM_CM_TRUE != ret) + { + MSCP_LOG_MSG("innet raw send to %04x fail\n", dstID); + rt = 0u; + } + else + { + /*- 无处理 */ + } + } + } + else + { + /*- 报错 */ + MSCP_LOG_MSG("innet raw send err:wrong dstID = %04x\n",dstID); + CM_RE_ASSERT(0, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_4); + rt = 0u; + } + /*- 跳转到下一条待发送报文 */ + i = i + (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen + 2u); + } + /*- 返回执行结果 */ + return rt; +} + +/** +* @brief 外网透传接收 +* @param buf 接收数组 +* @param bufSize 接收数组大小 +* @return 接收数据长度 +*/ +CM_UINT32 CFM_RxOutnetRaw(OUT CM_UINT8 buf[], IN CM_UINT32 bufSize) +{ + /*- 变量初始化 */ + CM_UINT16 rxLen = 0u; /* 接收报文长度 */ + CM_UINT32 i = 0u; /* 循环变量 */ + ENUM_OUTNET_CHN_T Chn = ENUM_OUTNET_ERROR; + /*- 循环接收内网透传数据 */ + do + { + /*- 从通信层读取通信数据 */ + rxLen = CFM_OutnetRaw_Recv(&buf[i+4u], CM_UNSIGNED_INT_EXP(bufSize - i - 4u),&Chn); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + /*- 是否读到了数据 */ + if (rxLen > 0u) + { + CM_LongToChar((CM_UINT32)rxLen, &buf[i]); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + i = i + (CM_UINT32)CM_UNSIGNED_SHORT_EXP(rxLen + 4u); + } + else + { + /*- 无处理 */ + } + } while (rxLen > 0u); + + /*- 返回报文总长度 */ + return i; +} + +/** +* @brief 发送外网透传报文 +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +*/ +CM_UINT8 CFM_TxOutnetRaw(IN CM_UINT8 Buf[], IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT8 rt = 1u; + CM_UINT16 i = 0u; + CM_UINT16 msgLen = 0u; + CM_UINT32 tx_sn = 0u; + CM_UINT32 Crc = 0u; + + if ((0u < Len) && (0x55u == g_PFM_Cfg.M_OutnetRaw_Enable)) + { + while((CM_UINT16)(i + 19u) < Len) + { + /*CC外网输出帧 + 2字节 长度 + 1字节 协议版本 + 4字节 周期号 + 4字节帧序号 + 2字节 目的设备id + 2字节 目的逻辑id + 2字节 协议类型 + n字节 数据 + 4字节CRC + */ + /*- 解析透传发送头 */ + msgLen = CM_ShortFromChar(&Buf[i]); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + /*- 填写帧序号*/ + tx_sn = SFM_GetTxSn(); + CM_LongToChar(tx_sn, &Buf[i + 7u]); + if(msgLen > 2u) + { + Crc = CM_Crc32(&Buf[i], msgLen - 2u); + } + else + { + MSCP_LOG_MSG("Crc len error!!!\n"); + } + CM_LongToChar(Crc, &Buf[i + msgLen - 2u]); + CM_RE_ASSERT(msgLen > (CM_UINT16)(19u), RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT((i + msgLen + 2u) <= Len, RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- 向红网CC发送CC外网帧 */ + (void)CFM_OutnetRaw_Send(&Buf[i], (CM_INT32)(msgLen + 2u), ENUM_OUTNET_RED); + /*- 向蓝网CC发送CC外网帧 */ + (void)CFM_OutnetRaw_Send(&Buf[i], (CM_INT32)(msgLen + 2u), ENUM_OUTNET_BLUE); + + /*- 跳转到下一条待发送报文 */ + i = i + (msgLen + 2u); + } + } + else + { + rt = 0u; + } + + return rt; +} +/** +* @brief 外网心跳接收 +* @param buf 接收数组 取值范围:非空 +* @param bufSize 接收数组大小 取值范围:0~0xFFFFFFFF +* @return 接收数据长度 取值范围:0~0xFFFFFFFF +*/ +CM_UINT32 CFM_RxOutnetHeart(OUT CM_UINT8 buf[], IN CM_UINT32 bufSize) +{ + /*- 变量初始化 */ + CM_UINT16 rxLen = 0u; /*- 接收报文长度 */ + CM_UINT32 i = 0u; /*- 循环变量 */ + ENUM_OUTNET_CHN_T Chn = ENUM_OUTNET_ERROR; + CM_UINT8 send_2oo2_buf[16] = {0u}; + CM_UINT8 rcv_2oo2_buf[16] = {0u}; + CM_INT32 rcv_len = 0; + CM_UINT32 cycle = DFM_GetBirthCount(); + CM_UINT8 ccState[2] = {0,0}; + CM_UINT8 sebState[2] = {0,0}; + /*- 如果入参指针不为空 */ + if(NULL != buf) + { + /*- 循环接收内网透传数据 */ + do + { + /*- 从通信层读取通信数据 */ + rxLen = CFM_OutnetHeart_Recv(&buf[i+4u], CM_UNSIGNED_INT_EXP(bufSize - i - 4u),&Chn); /*- parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + /*- 是否读到了数据 */ + if (rxLen > 0u) + { + CM_LongToChar((CM_UINT32)rxLen, &buf[i]); /*- parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + i = i + (CM_UINT32)CM_UNSIGNED_SHORT_EXP(rxLen + 4u); + /*- 记录通信状态*/ + switch (Chn) + { + case ENUM_OUTNET_RED: + g_Hardware_boot_com_state.CCU_A_Count = cycle; + break; + case ENUM_OUTNET_BLUE: + g_Hardware_boot_com_state.CCU_B_Count = cycle; + break; + case ENUM_OUTNET_EXTEND_RED: + g_Hardware_boot_com_state.SEB_A_Count = cycle; + break; + case ENUM_OUTNET_EXTEND_BLUE: + g_Hardware_boot_com_state.SEB_B_Count = cycle; + break; + default: + break; + } + } + else + { + /*- 无处理 */ + } + } while (rxLen > 0u); + + g_Hardware_boot_com_state.SYS_Count = cycle; + /*- @alias 二取同步双cpu通信结果 */ + if(0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + CM_LongToChar(g_Hardware_boot_com_state.CCU_A_Count,&send_2oo2_buf[0u]); + CM_LongToChar(g_Hardware_boot_com_state.CCU_B_Count,&send_2oo2_buf[4u]); + CM_LongToChar(g_Hardware_boot_com_state.SEB_A_Count,&send_2oo2_buf[8u]); + CM_LongToChar(g_Hardware_boot_com_state.SEB_B_Count,&send_2oo2_buf[12u]); + rcv_len = SFM_2oo2_Exchange_Currency(send_2oo2_buf,16,rcv_2oo2_buf,16,ENUM_2oo2_RAW_INFO); + if(16 == rcv_len) + { + (g_Hardware_boot_com_state.CCU_A_Count >= CM_LongFromChar(&rcv_2oo2_buf[0])) ? (g_Hardware_boot_com_state.CCU_A_Count) : (g_Hardware_boot_com_state.CCU_A_Count = CM_LongFromChar(&rcv_2oo2_buf[0])); + (g_Hardware_boot_com_state.CCU_B_Count >= CM_LongFromChar(&rcv_2oo2_buf[4])) ? (g_Hardware_boot_com_state.CCU_B_Count) : (g_Hardware_boot_com_state.CCU_B_Count = CM_LongFromChar(&rcv_2oo2_buf[4])); + (g_Hardware_boot_com_state.SEB_A_Count >= CM_LongFromChar(&rcv_2oo2_buf[8])) ? (g_Hardware_boot_com_state.SEB_A_Count) : (g_Hardware_boot_com_state.SEB_A_Count = CM_LongFromChar(&rcv_2oo2_buf[8])); + (g_Hardware_boot_com_state.SEB_B_Count >= CM_LongFromChar(&rcv_2oo2_buf[12])) ? (g_Hardware_boot_com_state.SEB_B_Count) : (g_Hardware_boot_com_state.SEB_B_Count = CM_LongFromChar(&rcv_2oo2_buf[12])); + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + MSCP_LOG_MSG("CCU_A_Count = %d,CCU_B_Count = %d,SEB_A_Count = %d,SEB_B_Count = %d\n",g_Hardware_boot_com_state.CCU_A_Count,g_Hardware_boot_com_state.CCU_B_Count,g_Hardware_boot_com_state.SEB_A_Count,g_Hardware_boot_com_state.SEB_B_Count); + } + else + { + /*- 空指针无处理*/ + } + + /*- @alias 向aim汇报通信情况 */ + (1u == PFM_CCUSEB_Comstate(0))? (ccState[1] = 0xaau) : (ccState[1] = 0x55u); + (1u == PFM_CCUSEB_Comstate(1))? (ccState[0] = 0xaau) : (ccState[0] = 0x55u); + (1u == PFM_CCUSEB_Comstate(2))? (sebState[1] = 0xaau) : (sebState[1] = 0x55u); + (1u == PFM_CCUSEB_Comstate(3))? (sebState[0] = 0xaau) : (sebState[0] = 0x55u); + MSCP_LOG_MSG("rCC = %d, bCC = %d, rSEB = %d, bSEB = %d\n", ccState[1], ccState[0], sebState[1], sebState[0]); + + /*- 填写暗文日志 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_CCSTATE, 2U, &ccState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_SEBSTATE, 2U, &sebState); + + /*- 返回报文总长度 */ + return i; +} +/** +* @brief 发送外网心跳报文 +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +*/ +CM_UINT8 CFM_TxOutnetHeart(IN const CM_UINT8 Buf[], IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT8 rt = 0u; + + if ((0u < Len) && (NULL != Buf)) + { + /*- 向所有外设发送心跳请求 ,是否区分CPU*/ + (void)CFM_OutnetHeart_Send(Buf,Len,ENUM_OUTNET_RED); + (void)CFM_OutnetHeart_Send(Buf,Len,ENUM_OUTNET_BLUE); + if(NULL != p_Status_Communication_Func) + { + (void)CFM_OutnetHeart_Send(Buf,Len,ENUM_OUTNET_EXTEND_RED); + (void)CFM_OutnetHeart_Send(Buf,Len,ENUM_OUTNET_EXTEND_BLUE); + } + rt = 1u; + } + else + { + /*- 无处理*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(RAW_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1)); + } + + return rt; +} + diff --git a/TSCP/src/MSCP/CFM/CFM_Raw.h b/TSCP/src/MSCP/CFM/CFM_Raw.h new file mode 100644 index 0000000..3cd98df --- /dev/null +++ b/TSCP/src/MSCP/CFM/CFM_Raw.h @@ -0,0 +1,58 @@ +/** +* @file CFM_Raw.h +* @brief Communication Function Module: 网络透传通信 +* @details +* 内网透传通信的实现 +* @author GT-BU +* @date 2021.03.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.03.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CFM_RAW_H +#define CFM_RAW_H +#include "CM_Types.h" +#include "PFM_Cfg.h" +#include "PFM_InputOutput.h" +#ifdef __cplusplus +extern "C" +{ +#endif + + /* 内网透传数据接收 */ + CM_UINT32 CFM_RxInnetRaw(IN CM_INT32 ch, OUT CM_UINT8 *buf, IN CM_UINT32 bufSize); + + /* 内网透传数据发送 */ + CM_UINT8 CFM_TxInnetRaw(IN CM_INT32 ch, IN const CM_UINT8 *Buf, IN CM_UINT32 Len); + + + CM_UINT32 CFM_RxInnetRaw_COM(IN CM_INT32 ch, OUT CM_UINT8* buf, IN CM_UINT32 bufSize, + OUT CM_UINT8* maininfobuf,OUT CM_UINT32* maininfolen, + OUT CM_UINT8* peerinfobuf,OUT CM_UINT32* peerinfolen,IN CM_UINT32 infobufSize); + CM_UINT32 CFM_InnetRaw_Rx(IN CM_INT32 ch, OUT CM_UINT8 buf[], IN CM_UINT32 buf_size); + /** + * @brief 相机数据的2oo2比较接收 + * @details + */ + CM_UINT32 CFM_InnetRaw_Rx_Camera(IN CM_INT32 ch, OUT CM_UINT8 buf[], IN CM_UINT32 buf_size, + OUT CM_UINT8 maininfobuf[],OUT CM_UINT32* maininfolen, + OUT CM_UINT8 peerinfobuf[],OUT CM_UINT32* peerinfolen,IN CM_UINT32 infobufSize); + /** + * @brief 外网透传接收 + * @param buf 接收数组 + * @param bufSize 接收数组大小 + * @return 接收数据长度 + */ + CM_UINT32 CFM_RxOutnetRaw(OUT CM_UINT8 buf[], IN CM_UINT32 bufSize); + CM_UINT8 CFM_TxOutnetRaw(IN CM_UINT8 Buf[], IN CM_UINT32 Len); + + CM_UINT8 CFM_TxOutnetHeart(IN const CM_UINT8 Buf[], IN CM_UINT32 Len); + CM_UINT32 CFM_RxOutnetHeart(OUT CM_UINT8 buf[], IN CM_UINT32 bufSize); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/CM/CM_Atomic.h b/TSCP/src/MSCP/CM/CM_Atomic.h new file mode 100644 index 0000000..8b0ae93 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Atomic.h @@ -0,0 +1,58 @@ +/** +* @file CM_Atomic.h +* @brief 原子操作 +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CM_ATOMIC_H +#define CM_ATOMIC_H + +#ifdef QNX +#include +#endif + +#if QNX +#define CM_ATOMIC _Atomic +#else +#define CM_ATOMIC +#endif + +#if QNX +#define CM_ATOMIC_STORE(PTR,VAL) (atomic_store((PTR),(VAL))) +#define CM_ATOMIC_LOAD(PTR) (atomic_load(PTR)) +#define CM_ATOMIC_ADD(PTR,VAL) (atomic_fetch_add((PTR),(VAL))) +#define CM_ATOMIC_SUB(PTR,VAL) (atomic_fetch_sub((PTR),(VAL))) +#define CM_ATOMIC_AND(PTR,VAL) (atomic_fetch_and((PTR),(VAL))) +#define CM_ATOMIC_OR(PTR,VAL) (atomic_fetch_or((PTR),(VAL))) +#define CM_ATOMIC_XOR(PTR,VAL) (atomic_fetch_xor((PTR),(VAL))) +#define CM_ATOMIC_CLEAR(PTR) (atomic_flag_clear(PTR)) + +#else +#define CM_ATOMIC_STORE(PTR,VAL) (*(PTR) = (VAL)) +#define CM_ATOMIC_LOAD(PTR) (*(PTR)) +#define CM_ATOMIC_ADD(PTR,VAL) (*(PTR) += (VAL)) +#define CM_ATOMIC_SUB(PTR,VAL) (*(PTR) -= (VAL)) +#define CM_ATOMIC_AND(PTR,VAL) (*(PTR) = (*(PTR))&(VAL)) +#define CM_ATOMIC_OR(PTR,VAL) (*(PTR) = (*(PTR))|(VAL)) +#define CM_ATOMIC_XOR(PTR,VAL) (*(PTR) = (*(PTR))^(VAL)) +#define CM_ATOMIC_CLEAR(PTR) (*(PTR) = 0u) +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + +#endif /**< _CM_TYPES_H */ + diff --git a/TSCP/src/MSCP/CM/CM_CRC32.c b/TSCP/src/MSCP/CM/CM_CRC32.c new file mode 100644 index 0000000..ab74be7 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_CRC32.c @@ -0,0 +1,88 @@ +/** +* @file CM_CRC32.c +* @brief 计算32位CRC函数 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_CRC32.h" + +/** +* @brief CRC32函数 +* @param pData 数据指针 +* @param dataLen 数据长度 +* @return 为CRC值 +* @details +* 计算过程如下,注意:计算CRC是从输入数据第一个字节的最高BIT开始的 +* 采用的多项式0x4c11db7L,初始值为0x00000000,未镜像,结果异或系数为0x00000000 +* 如果dataLen=0,返回值也为0 +*/ +CM_UINT32 CM_Crc32(IN const CM_UINT8 pData[],IN CM_UINT32 dataLen) +{ + /*- 变量初始化 */ + /*- 生成多项式:0x4c11db7L; */ + static const CM_UINT32 s_CrcTable[256] = { + 0x00000000u,0x04c11db7u,0x09823b6eu,0x0d4326d9u,0x130476dcu,0x17c56b6bu, + 0x1a864db2u,0x1e475005u,0x2608edb8u,0x22c9f00fu,0x2f8ad6d6u,0x2b4bcb61u, + 0x350c9b64u,0x31cd86d3u,0x3c8ea00au,0x384fbdbdu,0x4c11db70u,0x48d0c6c7u, + 0x4593e01eu,0x4152fda9u,0x5f15adacu,0x5bd4b01bu,0x569796c2u,0x52568b75u, + 0x6a1936c8u,0x6ed82b7fu,0x639b0da6u,0x675a1011u,0x791d4014u,0x7ddc5da3u, + 0x709f7b7au,0x745e66cdu,0x9823b6e0u,0x9ce2ab57u,0x91a18d8eu,0x95609039u, + 0x8b27c03cu,0x8fe6dd8bu,0x82a5fb52u,0x8664e6e5u,0xbe2b5b58u,0xbaea46efu, + 0xb7a96036u,0xb3687d81u,0xad2f2d84u,0xa9ee3033u,0xa4ad16eau,0xa06c0b5du, + 0xd4326d90u,0xd0f37027u,0xddb056feu,0xd9714b49u,0xc7361b4cu,0xc3f706fbu, + 0xceb42022u,0xca753d95u,0xf23a8028u,0xf6fb9d9fu,0xfbb8bb46u,0xff79a6f1u, + 0xe13ef6f4u,0xe5ffeb43u,0xe8bccd9au,0xec7dd02du,0x34867077u,0x30476dc0u, + 0x3d044b19u,0x39c556aeu,0x278206abu,0x23431b1cu,0x2e003dc5u,0x2ac12072u, + 0x128e9dcfu,0x164f8078u,0x1b0ca6a1u,0x1fcdbb16u,0x018aeb13u,0x054bf6a4u, + 0x0808d07du,0x0cc9cdcau,0x7897ab07u,0x7c56b6b0u,0x71159069u,0x75d48ddeu, + 0x6b93dddbu,0x6f52c06cu,0x6211e6b5u,0x66d0fb02u,0x5e9f46bfu,0x5a5e5b08u, + 0x571d7dd1u,0x53dc6066u,0x4d9b3063u,0x495a2dd4u,0x44190b0du,0x40d816bau, + 0xaca5c697u,0xa864db20u,0xa527fdf9u,0xa1e6e04eu,0xbfa1b04bu,0xbb60adfcu, + 0xb6238b25u,0xb2e29692u,0x8aad2b2fu,0x8e6c3698u,0x832f1041u,0x87ee0df6u, + 0x99a95df3u,0x9d684044u,0x902b669du,0x94ea7b2au,0xe0b41de7u,0xe4750050u, + 0xe9362689u,0xedf73b3eu,0xf3b06b3bu,0xf771768cu,0xfa325055u,0xfef34de2u, + 0xc6bcf05fu,0xc27dede8u,0xcf3ecb31u,0xcbffd686u,0xd5b88683u,0xd1799b34u, + 0xdc3abdedu,0xd8fba05au,0x690ce0eeu,0x6dcdfd59u,0x608edb80u,0x644fc637u, + 0x7a089632u,0x7ec98b85u,0x738aad5cu,0x774bb0ebu,0x4f040d56u,0x4bc510e1u, + 0x46863638u,0x42472b8fu,0x5c007b8au,0x58c1663du,0x558240e4u,0x51435d53u, + 0x251d3b9eu,0x21dc2629u,0x2c9f00f0u,0x285e1d47u,0x36194d42u,0x32d850f5u, + 0x3f9b762cu,0x3b5a6b9bu,0x0315d626u,0x07d4cb91u,0x0a97ed48u,0x0e56f0ffu, + 0x1011a0fau,0x14d0bd4du,0x19939b94u,0x1d528623u,0xf12f560eu,0xf5ee4bb9u, + 0xf8ad6d60u,0xfc6c70d7u,0xe22b20d2u,0xe6ea3d65u,0xeba91bbcu,0xef68060bu, + 0xd727bbb6u,0xd3e6a601u,0xdea580d8u,0xda649d6fu,0xc423cd6au,0xc0e2d0ddu, + 0xcda1f604u,0xc960ebb3u,0xbd3e8d7eu,0xb9ff90c9u,0xb4bcb610u,0xb07daba7u, + 0xae3afba2u,0xaafbe615u,0xa7b8c0ccu,0xa379dd7bu,0x9b3660c6u,0x9ff77d71u, + 0x92b45ba8u,0x9675461fu,0x8832161au,0x8cf30badu,0x81b02d74u,0x857130c3u, + 0x5d8a9099u,0x594b8d2eu,0x5408abf7u,0x50c9b640u,0x4e8ee645u,0x4a4ffbf2u, + 0x470cdd2bu,0x43cdc09cu,0x7b827d21u,0x7f436096u,0x7200464fu,0x76c15bf8u, + 0x68860bfdu,0x6c47164au,0x61043093u,0x65c52d24u,0x119b4be9u,0x155a565eu, + 0x18197087u,0x1cd86d30u,0x029f3d35u,0x065e2082u,0x0b1d065bu,0x0fdc1becu, + 0x3793a651u,0x3352bbe6u,0x3e119d3fu,0x3ad08088u,0x2497d08du,0x2056cd3au, + 0x2d15ebe3u,0x29d4f654u,0xc5a92679u,0xc1683bceu,0xcc2b1d17u,0xc8ea00a0u, + 0xd6ad50a5u,0xd26c4d12u,0xdf2f6bcbu,0xdbee767cu,0xe3a1cbc1u,0xe760d676u, + 0xea23f0afu,0xeee2ed18u,0xf0a5bd1du,0xf464a0aau,0xf9278673u,0xfde69bc4u, + 0x89b8fd09u,0x8d79e0beu,0x803ac667u,0x84fbdbd0u,0x9abc8bd5u,0x9e7d9662u, + 0x933eb0bbu,0x97ffad0cu,0xafb010b1u,0xab710d06u,0xa6322bdfu,0xa2f33668u, + 0xbcb4666du,0xb8757bdau,0xb5365d03u,0xb1f740b4u + }; + CM_UINT32 crc = 0u; + CM_UINT32 i = 0u; + + /*- 遍历输入数据 */ + while (i < dataLen) + { + /*- 迭代计算CRC */ + crc = (crc << 8) ^ s_CrcTable[(crc >> 24) ^ *(&pData[i])]; /* parasoft-suppress MISRA2004-17_1 "为了提高代码效率,使用指针运算" */ + i++; + } + /*- 返回CRC结果 */ + return crc; +} diff --git a/TSCP/src/MSCP/CM/CM_CRC32.h b/TSCP/src/MSCP/CM/CM_CRC32.h new file mode 100644 index 0000000..9d673c8 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_CRC32.h @@ -0,0 +1,36 @@ +/** +* @file CM_CRC32.h +* @brief 计算32位CRC函数 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ + +#ifndef CM_CRC32_H_ +#define CM_CRC32_H_ + +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + + /* 计算CRC */ + CM_UINT32 CM_Crc32(IN const CM_UINT8 pData[],IN CM_UINT32 dataLen); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/MSCP/CM/CM_Com.c b/TSCP/src/MSCP/CM/CM_Com.c new file mode 100644 index 0000000..f85e908 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Com.c @@ -0,0 +1,536 @@ +#include "CM_Com.h" +#include "PFM_Log.h" +#include "CM_Memory.h" +#include "CM_Time.h" +#include "CM_Convert.h" + +#if QNX +#include /* ThreadCtl BMP绑定CPU*/ +#include +#include +#include +#endif +#define COM1 "/dev/ser1" +#define COM2 "/dev/ser2" +#define COM3 "/dev/ser3" +#define COM4 "/dev/ser4" + +#define COM485 "/dev/ser4" + +#define COMMAXNUM (2u) + +static STRUCT_QNX_FD g_COM[COMMAXNUM] = { {-1,COM3,},{-1,COM4,} }; +static CM_UINT16 CM_ComSend(CM_UINT8 comId, IN CM_UINT8* pbuf, CM_UINT16 len); +static CM_INT32 CM_ComRev(CM_UINT8 comId, CM_UINT8* pbuf, CM_UINT16 len); +static ENUM_CM_RETURN CM_ComSendFFFE(CM_UINT8 comId, IN CM_UINT8* pbuf, CM_UINT16 len); +static CM_UINT16 CM_Com_DataRecv(CM_UINT8 comId,OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); +/** +* @brief 串口数据清空 +*/ +static ENUM_CM_RETURN CM_Com_Clear(STRUCT_QNX_FD* pCtrl); + +/** +* @brief 串口初始化函数 +* @param nSpeed 波特率 +* @param nBits 数据位 +* @details 波特率一般为115200, 数据位一般为8 +* @return 返回成功或失败 +*/ +ENUM_CM_RETURN CM_COM_INIT(CM_UINT32 nSpeed, CM_UINT32 nBits) +{ +#if QNX + /*- 变量初始化 */ + ENUM_CM_RETURN rtnValue = ENUM_CM_FALSE; + ENUM_CM_RETURN rt_temp = ENUM_CM_FALSE;/*临时返回值*/ + CM_BOOL rv = 0; + CM_UINT8 rtnFlag = 0u; + CM_UINT8 i = 0u; + struct termios options; + for (i = 0u; i < COMMAXNUM; i++) + { + /*- 打开串口*/ + g_COM[i].fd = open(g_COM[i].addr, O_RDWR | O_NOCTTY);/*O_NONBLOCK 非阻塞式 O_NDELAY阻塞式*/ + /*- 如果打开成功,则*/ + if (-1 != g_COM[i].fd) + { + rtnFlag++; + rt_temp = CM_Memset(&options, 0u, sizeof(options), sizeof(options)); + CM_ASSERT(ENUM_CM_TRUE == rt_temp, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + /*- 获取原有的串口属性的配置*/ + rv = tcgetattr(g_COM[i].fd, &options); + if (0 != rv) + { + MSCP_LOG_MSG("tcgetattr() failed\n"); + } + + options.c_lflag &= ~(ICANON | ECHO | ECHOE); + /*- CREAD 开启串行数据接收,CLOCAL并打开本地连接模式*/ + options.c_cflag |= CLOCAL | CREAD; + /*- 先使用CSIZE做位屏蔽*/ + options.c_cflag &= ~CSIZE; + + /*- 传输据位参数*/ + switch (nBits) + { + case 5u: + options.c_cflag |= CS5; + /*- 跳出 */ + break; + case 6u: + options.c_cflag |= CS6; + /*- 跳出 */ + break; + case 7u: + options.c_cflag |= CS7; + /*- 跳出 */ + break; + case 8u: + options.c_cflag |= CS8; + /*- 跳出 */ + break; + default: + CM_ASSERT(0, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + /*- 跳出 */ + break; + } + /*- 无奇偶校验位*/ + options.c_cflag &= ~PARENB; + + /*- slove 0a -> 0d 0a*/ + options.c_iflag &= ~(INLCR | ICRNL | IGNCR); + options.c_oflag &= ~(ONLCR | OCRNL | ONOCR | ONLRET); + + /*- slove 0x11 0x13*/ + options.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + + /*- slove others*/ + options.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + options.c_oflag &= ~OPOST; + options.c_cflag |= CLOCAL | CREAD; + options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); + + /*- 设置波特率*/ + switch (nSpeed) + { + case 2400u: + (void)cfsetispeed(&options, B2400); + (void)cfsetospeed(&options, B2400); + /*- 跳出 */ + break; + case 4800u: + (void)cfsetispeed(&options, B4800); + (void)cfsetospeed(&options, B4800); + /*- 跳出 */ + break; + case 9600u: + (void)cfsetispeed(&options, B9600); + (void)cfsetospeed(&options, B9600); + /*- 跳出 */ + break; + case 115200u: + (void)cfsetispeed(&options, B115200); + (void)cfsetospeed(&options, B115200); + /*- 跳出 */ + break; + default: + CM_ASSERT(0, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + /*- 跳出 */ + break; + } + /*- 设置一位停止位 */ + options.c_cflag &= ~CSTOPB; + /*- 非规范模式读取时的超时时间 */ + options.c_cc[VTIME] = 0u; + /*- 非规范模式读取时的最小字符数 */ + options.c_cc[VMIN] = 0u; + + /*- tcflush清空终端未完成的输入/输出请求及数据;TCIFLUSH表示清空正收到的数据,且不读取出来 */ + (void)tcflush(g_COM[i].fd, TCIFLUSH); + if ((tcsetattr((int)g_COM[i].fd, (int)TCSANOW, &options)) != 0) + { + MSCP_LOG_MSG("com:%d tcsetattr failed\n", i); + CM_ASSERT(0, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_4); + } + /*初始化成功*/ + else + { + /*设置串口号*/ + g_COM[i].Num = i; + /*初始化FFFE解析结构体*/ + rt_temp = CM_FFFEInit(&g_COM[i].prtclFFFEStru, (COM_UART_BUF_SIZE*COM_UART_MSG_NUM_MAX)); + CM_ASSERT(ENUM_CM_TRUE == rt_temp, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_5); + } + } + else + { + /*- 无处理*/ + } + } + return rtnValue; +#else + return ENUM_CM_TRUE; +#endif +} +/** +* @brief 串口临机接收线程初始化函数 +* @return 无 +*/ +void CM_Com_RcvOtherThreadInit(void) +{ + ENUM_CM_RETURN rt_temp = ENUM_CM_FALSE;/*临时返回值*/ + CM_BOOL threadrtn = CM_FALSE; + /*初始化接收队列*/ + rt_temp = CM_MQ_Init(&g_COM[0].MsgQ, (CM_UINT16)COM_UART_MSG_NUM_MAX, (CM_UINT16)COM_UART_BUF_SIZE); + CM_ASSERT(ENUM_CM_TRUE == rt_temp, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + /*初始化接收线程*/ + threadrtn = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_ComUartRcvThread, "Uart_T", 0, CM_TASK_PRIORITY_80, (CM_Thread_Arg_Struct_T*)(&g_COM[0])); + MSCP_LOG_MSG("RcvOtherThreadInit:0x%x\r\n",threadrtn); + CM_ASSERT(CM_TRUE == threadrtn, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + rt_temp = CM_Com_Clear(&g_COM[0]); + CM_ASSERT(ENUM_CM_TRUE == rt_temp, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); +} +/** +* @brief 串口发送函数 +* @param comId +* @param pbuf 缓冲区 +* @param len 长度 +* @return 返回成功或失败 +*/ +static CM_UINT16 CM_ComSend(CM_UINT8 comId, IN CM_UINT8* pbuf, CM_UINT16 len) +{ + /*- 变量初始化*/ + CM_INT32 ret = 0; + CM_UINT16 rtnval = 0u; + if (NULL != pbuf) + { + /*TODO 判断返回值*/ + /*lseek(g_COM[comId].fd, 0 , SEEK_SET);*/ + /*如果返回成功-ret返回的是长度*/ + ret = write((int)g_COM[comId].fd, pbuf, (size_t)len); + if(0 == ret) + { + rtnval = 0u; + } + else + { + rtnval = 1u; + } + } + else + { + MSCP_LOG_MSG("com[%d] = %d add %s\r\n",comId,ret,g_COM[comId].addr); + } + return rtnval; +} + +/** +* @brief 串口接收函数 +* @param comId +* @param pbuf 缓冲区 +* @param len 长度 +* @return 返回成功或失败 +*/ +static CM_INT32 CM_ComRev(CM_UINT8 comId, CM_UINT8* pbuf, CM_UINT16 len) +{ + + CM_INT32 ret = 0; + fd_set rset; + int rv; + if (NULL != pbuf) + { + /*如果返回成功*/ + FD_ZERO(&rset); + FD_SET(g_COM[comId].fd, &rset); + rv = select(g_COM[comId].fd + 1, &rset, NULL, NULL, NULL); + if (rv < 0) + { + MSCP_LOG_MSG("select() failed\n"); + + } + else if (rv == 0) + { + MSCP_LOG_MSG("select() time out!\n"); + } + else + { + + ret = read((int)g_COM[comId].fd, pbuf, (size_t)len); + } + } + else + { + + } + return ret; +} +/** +* @brief 串口使用FFFE发送函数 +* @param comId +* @param pbuf 缓冲区 +* @param len 长度 +* @return 返回成功或失败 +*/ +static ENUM_CM_RETURN CM_ComSendFFFE(CM_UINT8 comId, IN CM_UINT8* pbuf, CM_UINT16 len) +{ + /*- 变量初始化*/ + ENUM_CM_RETURN rtnValue = ENUM_CM_FALSE; + CM_UINT16 ret = 0u; + CM_UINT16 fffeLen = 0u; + CM_UINT8 fffebuf[COM_UART_BUF_SIZE] = { 0u }; + if (NULL != pbuf) + { + /*添加FFFE*/ + rtnValue = CM_FFFECode(pbuf, (CM_UINT16)len, fffebuf, &fffeLen); + if(ENUM_CM_TRUE == rtnValue) + { + ret = CM_ComSend(comId,fffebuf,fffeLen); + if(1u == ret) + { + rtnValue = ENUM_CM_TRUE; + MSCP_LOG_MSG("COM:%d SendSuccess\n",comId); + } + else + { + rtnValue = ENUM_CM_FALSE; + MSCP_LOG_MSG("COM:%d SendFail(%d)!\n",comId,ret); + } + } + else + { + rtnValue = ENUM_CM_FALSE; + MSCP_LOG_MSG("COM:%d FFFECodeFail!\n",comId); + /* nothing to do */ + } + } + else + { + rtnValue = ENUM_CM_FALSE; + /* nothing to do */ + } +return rtnValue; +} +/** +* @brief 串口数据接收 +* @param comId 串口号 +* @param pBuf 接收报文指针 +* @param BufSize 接收报文缓冲区大小 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +static CM_UINT16 CM_Com_DataRecv(CM_UINT8 comId,OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_UINT16 len = (CM_UINT16)((BufSize > 65535u) ? (65535u) : (BufSize)); + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT8 buf[COM_UART_BUF_SIZE] = { 0u }; /* 接收缓冲区 */ + /*- 从接收线程获取输入报文 */ + rt = CM_MQ_Read(&g_COM[comId].MsgQ, buf, &len); + /*- 是否获取成功 */ + if (rt == ENUM_CM_TRUE) + { + /*- 输出接收数据 */ + (void)CM_Memcpy((void*)pBuf, (CM_SIZE_T)BufSize, buf, (CM_SIZE_T)len); + } + else + { + /*- 接收长度为0 */ + len = 0u; + } + /*- 返回接收长度 */ + return len; +} +/** +* @brief 串口数据清空 +* @param pCtrl 串口号 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +static ENUM_CM_RETURN CM_Com_Clear(STRUCT_QNX_FD* pCtrl) +{ + return CM_MQ_Clear(&pCtrl->MsgQ); +} + +/** +* @brief 串口本机数据发送 +* @param pBuf 接收报文指针 +* @param BufSize 接收报文缓冲区大小 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +ENUM_CM_RETURN CM_Com_LocalDataSend(OUT CM_UINT8* pBuf, IN CM_UINT16 BufSize) +{ + ENUM_CM_RETURN rtnval = ENUM_CM_FALSE; + CM_INT32 cmpval = 0xff; + CM_UINT8 RcvBuf[2000] = {0u}; + ENUM_CM_RETURN Rcvrtn = ENUM_CM_FALSE; + rtnval = CM_ComSendFFFE(0u,pBuf,BufSize); + /*发送成功进入回读自检*/ + if(ENUM_CM_TRUE == rtnval) + { + /*串口数据接收*/ + Rcvrtn = CM_Com_LocalDataRecv(RcvBuf,BufSize); + MSCP_LOG_MSG("CM_Com_LocalDataRecv 0x%x:%d,%d \r\n",Rcvrtn,RcvBuf[0],RcvBuf[1]); + /*本地串口数据回读比较*/ + cmpval = CM_Memcmp(RcvBuf,pBuf,(CM_SIZE_T)BufSize); + if((0 == cmpval) && (ENUM_CM_TRUE == Rcvrtn)) + { + rtnval = ENUM_CM_TRUE; + } + else + { + rtnval = ENUM_CM_FALSE; + MSCP_LOG_MSG("LocalDataSendCM_Memcmp fail!!! \r\n"); + } + } + else + { + rtnval = ENUM_CM_FALSE; + } + + return rtnval; +} +/** +* @brief 串口本机数据接收 +* @param pBuf 接收报文指针 +* @param BufSize 接收报文缓冲区大小 +* @return 接收报文长度 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_Com_LocalDataRecv(OUT CM_UINT8* pBuf, IN CM_UINT16 BufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rtnValue = ENUM_CM_FALSE; + CM_UINT8 buf[COM_UART_BUF_SIZE] = { 0u }; /* 接收缓冲区 */ + CM_INT32 ret = 0; + CM_UINT8 data = 0u; + CM_UINT32 len = 0u; /* 数据长度 */ + CM_UINT64 now_time = 0u; + CM_UINT64 start_time = CM_GetTick(); + /*- 循环执行接收线程 */ + do + { + /*从串口接收数据*/ + ret = CM_ComRev((CM_UINT8)g_COM[1u].Num,&data,(CM_UINT16)1u); + /*- 是否收到有效报文 */ + if(1 == ret) + { + rtnValue = CM_FFFEDecode(&g_COM[1u].prtclFFFEStru,data,buf,&len); + /*接收到完整包写入接收队列*/ + if(ENUM_CM_TRUE == rtnValue) + { + (void)CM_Memcpy(pBuf,(CM_SIZE_T)BufSize,buf,(CM_SIZE_T)len); + /*- 跳出 */ + break; + } + else + { + /* nothing to do */ + } + } + else + { + MSCP_LOG_MSG("COM:1 rx fail %d!!\n",ret); + /* nothing to do */ + } + now_time = CM_GetTick(); + }while((now_time - start_time) < (10u*1000u*1000u)); + + return rtnValue; +} +/** +* @brief 串口临机数据接收 +* @param pBuf 接收报文指针 +* @param BufSize 接收报文缓冲区大小 +* @return 接收报文长度 +* - 正整数 接收报文长度 +* - 0 接收失败 +*/ +CM_UINT16 CM_Com_OtherDataRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize) +{ + return (CM_UINT16)CM_Com_DataRecv(0u,pBuf,BufSize); +} +/** +* @brief 串口临机数据清空 +* @param 无 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_Com_OtherDataClear(void) +{ + return CM_Com_Clear(&g_COM[0]); +} +/** +* @brief 串口接收线程 +* @param arg 指向STRU_CFM_TIME_CTRL的指针 +* @return 线程函数返回值(实际永远不会返回) +* @details +* 创建本线程之前应先做好串口初始化,并输入串口号 +* 本线程将以非阻塞方式接收串口数据,并解析FFFE协议存入接收队列 +* @see :: +* @see :: +*/ +CM_THREAD_FUNC_T t_ComUartRcvThread(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + STRUCT_QNX_FD* pCtrl = (STRUCT_QNX_FD*)arg; /* 线程参数 */ + ENUM_CM_RETURN rtnValue = ENUM_CM_FALSE; + CM_UINT8 buf[COM_UART_BUF_SIZE] = { 0u }; /* 接收缓冲区 */ + CM_INT32 ret = 0; + CM_UINT8 data = 0u; + CM_UINT32 len = 0u; /* 数据长度 */ + MSCP_LOG_MSG("COM:%d Recv Service Start\n",pCtrl->Num); +#if QNX + void* pmask = NULL; + + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01u|0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); + +#endif + /*- 循环执行接收线程 */ + while (1) + { + CM_RE_ASSERT(1, COM_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + /*从串口接收数据*/ + ret = CM_ComRev((CM_UINT8)pCtrl->Num,&data,(CM_UINT16)1u); + /*- 是否收到有效报文 */ + if(1 == ret) + { + rtnValue = CM_FFFEDecode(&pCtrl->prtclFFFEStru,data,&buf[6u],&len); + /*接收到完整包写入接收队列*/ + if(ENUM_CM_TRUE == rtnValue) + { + /*- 保存通信数据 */ + CM_LongToChar((CM_UINT32)(CM_GetTick()/CM_UNSIGNED_MILLION), buf); + len += 6u; + rtnValue = CM_MQ_Write(&pCtrl->MsgQ, buf, (CM_UINT16)len); + /*- 数据保存是否成功 */ + if (ENUM_CM_TRUE == rtnValue) + { + ; + } + else + { + /*- 防御性清空*/ + MSCP_LOG_MSG("COM:%d rx overflow(msgLen=%d)\n", pCtrl->Num, len); + (void)CM_Com_Clear(pCtrl); + } + } + else + { + /* nothing to do */ + } + } + else + { + MSCP_LOG_MSG("COM:%d rx fail %d!!\n", pCtrl->Num,ret); + /* nothing to do */ + } + } + return NULL; +} diff --git a/TSCP/src/MSCP/CM/CM_Com.h b/TSCP/src/MSCP/CM/CM_Com.h new file mode 100644 index 0000000..4b9bb26 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Com.h @@ -0,0 +1,98 @@ +#ifndef CM_COM_ +#define CM_COM_ + +#include "CM_FFFE.h" +#include "CM_Types.h" +#include "CM_MQ.h" +#include "CM_Queue.h" +#include "CM_MultiThread.h" +#include + +#define COM_UART_MSG_NUM_MAX (200U)/*���ն���������*/ +#define COM_UART_BUF_SIZE (200U)/*���ն���������ݳ���*/ +typedef enum +{ + ENUM_COM_SelfCheck = 0x55u, /**< �Լ� */ + ENUM_COM_2x2_SHUTDOWN = 0x00u, /**< 崻� */ + ENUM_COM_2x2_OFFLINE = 0xFFu, /**< ���� */ + ENUM_COM_2x2_PRE_MASTER = 0x77u, /**< Ԥ���� */ + ENUM_COM_2x2_MASTER = 0x0Fu, /**< ��ϵ */ + ENUM_COM_2x2_SLAVE = 0x33u /**< ��ϵ */ + +}CM_COM_TYPE_ENUM; + +typedef struct qnx_fd +{ + CM_INT32 fd; + char addr[1000]; + CM_UINT8 Num; + STRU_CM_FFFE_STATE prtclFFFEStru; + CM_MQ_Struct_T MsgQ; /**< ������Ϣ���У�������FFFEЭ������� */ + CM_MUTEX_T mutex; /*串口读写队列互斥信号量*/ +}STRUCT_QNX_FD; + +/** +* @brief ���ڳ�ʼ������ +* @param nSpeed ������ +* @param nBits ����λ +* @details ������һ��Ϊ115200, ����λһ��Ϊ8 +* @return ���سɹ���ʧ�� +*/ + +ENUM_CM_RETURN CM_COM_INIT(CM_UINT32 nSpeed, CM_UINT32 nBits); +/** +* @brief �����ٻ������̳߳�ʼ������ +* @return ���سɹ���ʧ�� +*/ +void CM_Com_RcvOtherThreadInit(void); +/** +* @brief ���ڱ������ݷ��� +* @param pBuf ���ձ���ָ�� +* @param BufSize ���ձ��Ļ�������С +* @return ���ձ��ij��� +* - ������ ���ձ��ij��� +* - 0 ����ʧ�� +*/ +ENUM_CM_RETURN CM_Com_LocalDataSend(OUT CM_UINT8* pBuf, IN CM_UINT16 BufSize); + +/** +* @brief ���ڱ������ݽ��� +* @param pBuf ���ձ���ָ�� +* @param BufSize ���ձ��Ļ�������С +* @return ���ձ��ij��� +* - ENUM_CM_TRUE ִ�гɹ� +* - ENUM_CM_FALSE ִ��ʧ�� +*/ +ENUM_CM_RETURN CM_Com_LocalDataRecv(OUT CM_UINT8* pBuf, IN CM_UINT16 BufSize); + +/** +* @brief �����ٻ����ݽ��� +* @param pBuf ���ձ���ָ�� +* @param BufSize ���ձ��Ļ�������С +* @return ���ձ��ij��� +* - ������ ���ձ��ij��� +* - 0 ����ʧ�� +*/ +CM_UINT16 CM_Com_OtherDataRecv(OUT CM_UINT8* pBuf, IN CM_UINT32 BufSize); + +/** +* @brief ���ڽ����߳� +* @param arg ָ��STRU_CFM_TIME_CTRL��ָ�� +* @return �̺߳�������ֵ��ʵ����Զ���᷵�أ� +* @details +* �������߳�֮ǰӦ�����ô��ڳ�ʼ���������봮�ں� +* ���߳̽��Է�������ʽ���մ������ݣ�������FFFEЭ�������ն��� +* @see :: +* @see :: +*/ +CM_THREAD_FUNC_T t_ComUartRcvThread(IN CM_Thread_Arg_Struct_T* arg); +/** +* @brief �����ٻ�������� +* @param �� +* @return ִ�н�� +* - ENUM_CM_TRUE ִ�гɹ� +* - ENUM_CM_FALSE ִ��ʧ�� +*/ +ENUM_CM_RETURN CM_Com_OtherDataClear(void); + +#endif diff --git a/TSCP/src/MSCP/CM/CM_Convert.c b/TSCP/src/MSCP/CM/CM_Convert.c new file mode 100644 index 0000000..9ca5c04 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Convert.c @@ -0,0 +1,226 @@ +/** +* @file CM_Convert.c +* @brief 通用类型转换函数 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Convert.h" + +/** +* @brief 将2字节数据变为CM_UINT16,BIG endian +* @param pdata 输入数据 +* @return 变换后的CM_UINT16值 +*/ +CM_UINT16 CM_ShortFromChar(IN const CM_UINT8 data[]) +{ + CM_UINT16 tempshort = 0u; + /*- 各字节按大端序填入结果 */ + tempshort = data[0]; + tempshort = (CM_UINT16)(tempshort << 8) + data[1]; + /*- 返回结果*/ + return tempshort; +} + +/** +* @brief 将4字节数据变为CM_UINT32, BIG endian +* @param pdata 输入数据 +* @return 变换后的CM_UINT32值 +*/ +CM_UINT32 CM_LongFromChar(IN const CM_UINT8 data[]) +{ + CM_UINT32 templong = 0u; + /*- 各字节按大端序填入结果 */ + templong = data[0]; + templong = (templong << 8) + data[1]; + templong = (templong << 8) + data[2]; + templong = (templong << 8) + data[3]; + /*- 返回结果 */ + return templong; +} + +/** +* @brief 将8字节数据变为CM_UINT64, BIG endian +* @param pdata 输入数据 +* @return 变换后的CM_UINT64值 +*/ +CM_UINT64 CM_64FromChar(IN const CM_UINT8 data[]) +{ + CM_UINT64 temp = 0u; + /*- 各字节按顺序填入结果 */ + temp = (CM_UINT64)(data[0]); + temp = (temp * 256u) + data[1]; + temp = (temp * 256u) + data[2]; + temp = (temp * 256u) + data[3]; + temp = (temp * 256u) + data[4]; + temp = (temp * 256u) + data[5]; + temp = (temp * 256u) + data[6]; + temp = (temp * 256u) + data[7]; + /*- 返回结果 */ + return temp; +} + +/** +* @brief 将2字节的整型变为字节表示 BIG endian +* @param val 输入变量 +* @param *pOutput 输出数组 +*/ +void CM_ShortToChar(IN const CM_UINT16 val, OUT CM_UINT8 pOutput[]) +{ + /*- 将输入变量按大端序填入输出数组 */ + pOutput[0] = (CM_UINT8)((val >> 8u) & 0xffu); + pOutput[1] = (CM_UINT8)(val & 0xffu); +} + +/** +* @brief 将4字节的整型变为字节表示 BIG endian +* @param val 输入变量 +* @param *pOutput 输出数组 +*/ +void CM_LongToChar(IN const CM_UINT32 val, OUT CM_UINT8 pOutput[]) +{ + /*- 将输入变量按大端序填入输出数组 */ + pOutput[0] = (CM_UINT8)((val >> 24u) & 0xffu); + pOutput[1] = (CM_UINT8)((val >> 16u) & 0xffu); + pOutput[2] = (CM_UINT8)((val >> 8u) & 0xffu); + pOutput[3] = (CM_UINT8)(val & 0xffu); +} + +/** +* @brief 将8字节的整型变为字节表示 BIG endian +* @param val 输入变量 +* @param *pOutput 输出数组 +*/ +void CM_64ToChar(IN CM_UINT64 val,OUT CM_UINT8 pOutput[]) +{ + /*- 将输入变量按大端序填入输出数组 */ + pOutput[7] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[6] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[5] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[4] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[3] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[2] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[1] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[0] = (CM_UINT8)(val & 0xffu); +} + +/** +* @brief 将2字节数据变为CM_UINT16,LITTLE endian +* @param pdata 输入数据 +* @return 变换后的CM_UINT16值 +*/ +CM_UINT16 CM_ShortFromCharLE(IN const CM_UINT8 data[]) +{ + /*- 变量初始化 */ + CM_UINT16 tempshort = 0u; + /*- 各字节按小端序填入结果 */ + tempshort = data[1]; + tempshort = (CM_UINT16)(tempshort << 8) + data[0]; + /*- 返回结果*/ + return tempshort; +} + +/** +* @brief 将4字节数据变为CM_UINT32, LITTLE endian +* @param pdata 输入数据 +* @return 变换后的CM_UINT32值 +*/ +CM_UINT32 CM_LongFromCharLE(IN const CM_UINT8 data[]) +{ + /*- 变量初始化 */ + CM_UINT32 templong = 0u; + /*- 各字节按小端序填入结果 */ + templong = data[3]; + templong = (templong << 8) + data[2]; + templong = (templong << 8) + data[1]; + templong = (templong << 8) + data[0]; + /*- 返回结果 */ + return templong; +} + +/** +* @brief 将8字节数据变为CM_UINT64, LITTLE endian +* @param pdata 输入数据 +* @return 变换后的CM_UINT64值 +*/ +CM_UINT64 CM_64FromCharLE(IN const CM_UINT8 data[]) +{ + /*- 变量初始化 */ + CM_UINT64 temp = 0u; + /*- 各字节按顺序填入结果 */ + temp = data[7]; + temp = (temp * 256u) + data[6]; + temp = (temp * 256u) + data[5]; + temp = (temp * 256u) + data[4]; + temp = (temp * 256u) + data[3]; + temp = (temp * 256u) + data[2]; + temp = (temp * 256u) + data[1]; + temp = (temp * 256u) + data[0]; + /*- 返回结果 */ + return temp; +} + +/** +* @brief 将2字节的整型变为字节表示 LITTLE endian +* @param val 输入变量 +* @param *pOutput 输出数组 +*/ +void CM_ShortToCharLE(IN const CM_UINT16 val, OUT CM_UINT8 pOutput[]) +{ + /*- 将输入变量按小端序填入输出数组 */ + pOutput[1] = (CM_UINT8)((val >> 8u) & 0xffu); + pOutput[0] = (CM_UINT8)(val & 0xffu); +} + +/** +* @brief 将4字节的整型变为字节表示 LITTLE endian +* @param val 输入变量 +* @param *pOutput 输出数组 +*/ +void CM_LongToCharLE(IN const CM_UINT32 val, OUT CM_UINT8 pOutput[]) +{ + /*- 将输入变量按小端序填入输出数组 */ + pOutput[3] = (CM_UINT8)((val >> 24u) & 0xffu); + pOutput[2] = (CM_UINT8)((val >> 16u) & 0xffu); + pOutput[1] = (CM_UINT8)((val >> 8u) & 0xffu); + pOutput[0] = (CM_UINT8)(val & 0xffu); +} + +/** +* @brief 将8字节的整型变为字节表示 LITTLE endian +* @param val 输入变量 +* @param *pOutput 输出数组 +*/ +void CM_64ToCharLE(IN CM_UINT64 val, OUT CM_UINT8 pOutput[]) +{ + /*- 将输入变量按小端序填入输出数组 */ + pOutput[0] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[1] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[2] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[3] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[4] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[5] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[6] = (CM_UINT8)(val & 0xffu); + val /= 256u; + pOutput[7] = (CM_UINT8)(val & 0xffu); +} diff --git a/TSCP/src/MSCP/CM/CM_Convert.h b/TSCP/src/MSCP/CM/CM_Convert.h new file mode 100644 index 0000000..df82c4f --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Convert.h @@ -0,0 +1,61 @@ +/** +* @file CM_Convert.h +* @brief 通用类型转换函数 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#ifndef CM_CONVERT_H_ +#define CM_CONVERT_H_ + +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* 2字节变UINT16,大端*/ + CM_UINT16 CM_ShortFromChar(IN const CM_UINT8 data[]); + + /* 4字节变UINT32,大端*/ + CM_UINT32 CM_LongFromChar(IN const CM_UINT8 data[]); + + /* 8字节变UINT64,大端*/ + CM_UINT64 CM_64FromChar(IN const CM_UINT8 data[]); + + /* UINT16转字节,大端*/ + void CM_ShortToChar(IN const CM_UINT16 val, OUT CM_UINT8 pOutput[]); + + /* UINT32转字节,大端*/ + void CM_LongToChar(IN const CM_UINT32 val, OUT CM_UINT8 pOutput[]); + + /* UINT64转字节,大端*/ + void CM_64ToChar(IN CM_UINT64 val,OUT CM_UINT8 pOutput[]); + /* 2字节变UINT16,小端*/ + CM_UINT16 CM_ShortFromCharLE(IN const CM_UINT8 data[]); + + /* 4字节变UINT32,小端*/ + CM_UINT32 CM_LongFromCharLE(IN const CM_UINT8 data[]); + /* 8字节变UINT64,小端*/ + CM_UINT64 CM_64FromCharLE(IN const CM_UINT8 data[]); + /* UINT16转字节,小端*/ + void CM_ShortToCharLE(IN const CM_UINT16 val, OUT CM_UINT8 pOutput[]); + + /* UINT32转字节,小端*/ + void CM_LongToCharLE(IN const CM_UINT32 val, OUT CM_UINT8 pOutput[]); + + /* UINT64转字节,小端*/ + void CM_64ToCharLE(IN CM_UINT64 val, OUT CM_UINT8 pOutput[]); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/CM/CM_FFFE.c b/TSCP/src/MSCP/CM/CM_FFFE.c new file mode 100644 index 0000000..b63e18b --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_FFFE.c @@ -0,0 +1,169 @@ +/** +@file CM_FFFE.c +@brief FFFE协议转义及接收文件 +@author 小型化安全计算机平台开发小组 +@version 1.0.0.0 +@date 2017-12-20 +*/ +#include "CM_FFFE.h" +#include "PFM_log.h" +#define LEN_INPUTCMP_DATA (6000u*2u) + +/*FFFE解转义状态*/ +#define CM_WAIT_FF_C1 (WAIT_FF_C1) +#define CM_WAIT_FF_C2 (WAIT_FF_C2) +#define CM_WAIT_NO_FF (WAIT_NO_FF) +#define CM_WAIT_FF_POS (WAIT_FF_POS) +#define CM_ABNORMAL_STATE (ABNORMAL_STATE) + +/*FFFE数据接收状态*/ +#define CM_COM_WAIT_START_FF (COM_WAIT_START_FF) +#define CM_COM_WAIT_START_FE (COM_WAIT_START_FE) +#define CM_COM_WAIT_STOP_FF (COM_WAIT_STOP_FF) +#define CM_COM_WAIT_STOP_FD (COM_WAIT_STOP_FD) + +/* +* 功能描述: 将数据进行FFFE转义处理(不加头FFFE及尾FFFD)。 +* 输入参数: const CM_UINT8 *pSrc 数据(无FFFE转义) +* CM_UINT16 SrcLen 数据(无FFFE转义)的长度 +* 输出参数: CM_UINT8 *pTgt 数据(经过FFFE转义) +* 返回值: 转义后的长度 +*/ +CM_UINT16 CM_TranslateToFFFE(IN const CM_UINT8 *pSrc, OUT CM_UINT8 *pTgt,CM_UINT16 SrcLen) +{ + return TranslateToFFFE(pSrc, pTgt, SrcLen); +} + + +/* +* 功能描述: 将经过FFFE转义处理后的数据(已经去掉了头FFFE及尾FFFD)还原为原始数据 +* 输入参数: const CM_UINT8 *pSrc, 数据(FFFE转义) +* CM_UINT16 SrcLen, 数据(FFFE转义)的长度 +* 输出参数: CM_UINT8 *pTgt, 数据(去掉FFFE转义) +* 返回值: 大于0, 转义成功,返回转义后的数据长度 +* 0, 有不能转义的字符,转义失败。或者转义后的数据长度为0 +*/ +CM_UINT16 CM_TranslateFromFFFE(const CM_UINT8 *pSrc,CM_UINT8 *pTgt,CM_UINT16 SrcLen) +{ + return TranslateFromFFFE(pSrc,pTgt,SrcLen); +} + +/* +* 功能描述: FFFE结构体初始化函数 +* 输入参数: CM_UINT16 FFFEBufferSize, 用于接收一帧数据的缓冲区长度 +* STRU_CM_FFFE_STATE *pFFFEStatStru, FFFE状态结构体 +* 返回值: ENUM_CM_TRUE, 函数执行失败 +* ENUM_CM_FALSE, 函数执行成功 +*/ +ENUM_CM_RETURN CM_FFFEInit(STRU_CM_FFFE_STATE *pFFFEStatStru,CM_UINT16 FFFEBufferSize) +{ + ENUM_CM_RETURN rtnValue = ENUM_CM_FALSE; + if (1u == FFFEInit(pFFFEStatStru,(UINT16)FFFEBufferSize)) + { + rtnValue = ENUM_CM_TRUE; + } + else + { + rtnValue = ENUM_CM_FALSE; + } + return rtnValue; +} + +/* +* 功能描述: 按字符接收待解转义的数据,获得整帧FFFE报文(不含FFFE和FFFD)。 +* 输入参数: CM_UINT8 RcvChar, 当前接收的字符 -> character +* PORT_STATE_STRU *pFFFEStatStru, +* 输出参数: CM_UINT8 *pRawDataRcv, 数据接收缓冲区指针 +* 返回值: 大于0, 表示收到完整帧的数据长度,并将收到的完整帧拷贝到接收缓冲区; +* 0, 未收到整帧数据; +*/ + +CM_UINT16 CM_FFFERcv(STRU_CM_FFFE_STATE *pFFFEStatStru ,CM_UINT8 RcvChar, CM_UINT8 *pRawDataRcv) +{ + return FFFERcv(pFFFEStatStru,RcvChar,pRawDataRcv); +} + +/* +* 功能描述: FFFE状态清理函数 +* 输入参数: PORT_STATE_STRU *pFFFEStatStru, FFFE状态结构体 +* 返回值: +*/ +void CM_FFFEFree(STRU_CM_FFFE_STATE *pFFFEStatStru) +{ + FFFEFree(pFFFEStatStru); + +} + + +/* +* 功能描述: 将数据进行FFFE转义处理,加头FFFE及尾FFFD +* 输入参数: const CM_UINT8 *pSrc 数据(无FFFE转义) +* CM_UINT16 SrcLen 数据(无FFFE转义)的长度 +* 输出参数: CM_UINT8 *pTgt 数据(经过FFFE转义),并添加FFFE头及FFFD尾 +* 返回值: 转义后的长度 +*/ +CM_UINT16 CM_FFFEPack(const CM_UINT8 *pSrc, CM_UINT8 *pTgt,CM_UINT16 SrcLen) +{ + return FFFEPack(pSrc, pTgt, SrcLen); + +} + + +/*编码FFFE*/ +ENUM_CM_RETURN CM_FFFECode(IN const CM_UINT8 pInBuf[], CM_UINT16 inLen, OUT CM_UINT8 pOutBuf[], OUT CM_UINT16 *pOutLen) +{ + ENUM_CM_RETURN rtnValue = ENUM_CM_FALSE; + CM_UINT16 tempLen = 0u; + + if ((NULL != pInBuf) && (NULL != pOutBuf) && (NULL != pOutLen)) + { + tempLen = CM_TranslateToFFFE(&pInBuf[0], &pOutBuf[2], inLen); + pOutBuf[0u] = 0xffu; + pOutBuf[1u] = 0xfeu; + pOutBuf[tempLen + 2u] = 0xffu; + pOutBuf[tempLen + 3u] = 0xfdu; + *pOutLen = tempLen + 4u; + rtnValue = ENUM_CM_TRUE; + } + else + { + rtnValue = ENUM_CM_FALSE;/*指针防控*/ + } + return rtnValue; +} + +/*解码FFFE*/ +ENUM_CM_RETURN CM_FFFEDecode(FFFE_STATE_STRU *pFFFE_Struct, IN CM_UINT8 tempUint8, OUT CM_UINT8 *pOutBuf, OUT CM_UINT32 *pOutLen) +{ + ENUM_CM_RETURN rtnValue = ENUM_CM_FALSE; + CM_UINT8 RcvWholeFrmBuf[LEN_INPUTCMP_DATA] = {0u}; /*由于初始化时间较长,该初始化不影响安全*/ + CM_UINT16 RcvAftFffeLen = 0u; + CM_UINT16 FffeRcvLen = 0u; + if ((NULL != pFFFE_Struct) && (NULL != pOutBuf) && (NULL != pOutLen)) + { + FffeRcvLen = CM_FFFERcv(pFFFE_Struct, tempUint8, RcvWholeFrmBuf);/*通过FFFE协议接收一帧数据*/ + + if (0u != FffeRcvLen)/*如果接受到完整帧的数据*/ + { + RcvAftFffeLen = CM_TranslateFromFFFE(RcvWholeFrmBuf, pOutBuf, FffeRcvLen);/*从FFFE数据帧进行转义;源,目标,长度*/ + if (RcvAftFffeLen > 0u)/*转义成功*/ + { + *pOutLen = (CM_UINT32)RcvAftFffeLen; + rtnValue = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("TranslateFromFFFE fail\n"); /*转义失败输出*/ + } + } + else + { + rtnValue = ENUM_CM_FALSE; + } + } + else + { + rtnValue = ENUM_CM_FALSE; + } + return rtnValue; +} diff --git a/TSCP/src/MSCP/CM/CM_FFFE.h b/TSCP/src/MSCP/CM/CM_FFFE.h new file mode 100644 index 0000000..00b82cf --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_FFFE.h @@ -0,0 +1,84 @@ +/** +@file CM_FFFE.h +@brief FFFE协议转义及接收文件 +@author 小型化安全计算机平台开发小组 +@version 1.0.0.0 +@date 2017-12-20 +*/ +#ifndef CM_FFFE_H +#define CM_FFFE_H + +#include "CM_Types.h" +#include "FFFE.h" +#ifdef __cplusplus +extern "C" { +#endif +#define STRU_CM_FFFE_STATE FFFE_STATE_STRU + +/* +* 功能描述: 将数据进行FFFE转义处理(不加头FFFE及尾FFFD)。 +* 输入参数: const CM_UINT8 *pSrc 数据(无FFFE转义) +* CM_UINT16 SrcLen 数据(无FFFE转义)的长度 +* 输出参数: CM_UINT8 *pTgt 数据(经过FFFE转义) +* 返回值: 转义后的长度 +*/ +CM_UINT16 CM_TranslateToFFFE(const CM_UINT8 *pSrc, CM_UINT8 *pTgt, CM_UINT16 SrcLen); + + +/* +* 功能描述: 将经过FFFE转义处理后的数据(已经去掉了头FFFE及尾FFFD)还原为原始数据 +* 输入参数: const CM_UINT8 *pSrc, 数据(FFFE转义) +* CM_UINT16 SrcLen, 数据(FFFE转义)的长度 +* 输出参数: CM_UINT8 *pTgt, 数据(去掉FFFE转义) +* 返回值: 大于0, 转义成功,返回转义后的数据长度 +* 0, 有不能转义的字符,转义失败。或者转义后的数据长度为0 +*/ +CM_UINT16 CM_TranslateFromFFFE(const CM_UINT8 *pSrc, CM_UINT8 *pTgt, CM_UINT16 SrcLen); + +/* +* 功能描述: FFFE结构体初始化函数 +* 输入参数: CM_UINT16 FFFEBufferSize, 用于接收一帧数据的缓冲区长度 +* PORT_STATE_STRU *pFFFEStatStru, FFFE状态结构体 +* 返回值: 0,函数执行失败 +* 1,函数执行成功 +*/ +ENUM_CM_RETURN CM_FFFEInit(STRU_CM_FFFE_STATE *pFFFEStatStru, CM_UINT16 FFFEBufferSize); + +/* +* 功能描述: 按字符接收待解转义的数据,获得整帧FFFE报文(不含FFFE和FFFD)。 +* 输入参数: CM_UINT8 RcvChar, 当前接收的字符 +* PORT_STATE_STRU *pFFFEStatStru, +* 输出参数: CM_UINT8 *pRawDataRcv, 数据接收缓冲区指针 +* 返回值: 大于0, 表示收到完整帧的数据长度,并将收到的完整帧拷贝到接收缓冲区; +* 0, 未收到整帧数据; +*/ + +CM_UINT16 CM_FFFERcv(STRU_CM_FFFE_STATE *pFFFEStatStru, CM_UINT8 RcvChar, CM_UINT8 *pRawDataRcv); + +/* +* 功能描述: FFFE状态清理函数 +* 输入参数: PORT_STATE_STRU *pFFFEStatStru, FFFE状态结构体 +* 返回值: +*/ +void CM_FFFEFree(STRU_CM_FFFE_STATE *pFFFEStatStru); + +/* +* 功能描述: 将数据进行FFFE转义处理,加头FFFE及尾FFFD +* 输入参数: const CM_UINT8 *pSrc 数据(无FFFE转义) +* CM_UINT16 SrcLen 数据(无FFFE转义)的长度 +* 输出参数: CM_UINT8 *pTgt 数据(经过FFFE转义),并添加FFFE头及FFFD尾 +* 返回值: 转义后的长度 +*/ +CM_UINT16 CM_FFFEPack(const CM_UINT8 *pSrc, CM_UINT8 *pTgt, CM_UINT16 SrcLen); + + +/*编码FFFE*/ +ENUM_CM_RETURN CM_FFFECode(IN const CM_UINT8 pInBuf[], CM_UINT16 inLen, OUT CM_UINT8 pOutBuf[], OUT CM_UINT16 *pOutLen); +/*解码FFFE*/ +ENUM_CM_RETURN CM_FFFEDecode(FFFE_STATE_STRU *pFFFE_Struct, IN CM_UINT8 tempUint8, OUT CM_UINT8 *pOutBuf, OUT CM_UINT32 *pOutLen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/CM/CM_IniFile.c b/TSCP/src/MSCP/CM/CM_IniFile.c new file mode 100644 index 0000000..d0e4e32 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_IniFile.c @@ -0,0 +1,450 @@ +/** +* @file CM_IniFile.c +* @brief 读取ini配置文件 +* @author GT-BU +* @date 2021.02.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "CM_IniFile.h" +#include "PFM_Log.h" +#if QNX +#else +#include "cp_interface.h" +#endif + +#define KEYVALLEN 100 + +static CM_INT32 s_isspace(IN CM_CHAR c); + +/** +* @brief 判断字符是否为空格 +* @param c 输入字符 +* @return 判断结果 +* - 1 是空格 +* - 0 不是空格 +* @details +* ' ','\f','\n','\r','\t','\v' 都视作空格 +*/ +static CM_INT32 s_isspace(IN CM_CHAR c) +{ + CM_INT32 rt = 0; + /*- 初始化判断结果为0 */ + /*- 判断输入是否属于“空格”字符 */ + if ((' ' == c) || ('\f' == c) || ('\n' == c) || ('\r' == c) || ('\t' == c) || ('\v' == c)) + { + /*- 判断结果为1*/ + rt = 1; + } + else + { + /*- 无处理 */ + } + /*- 返回结果 */ + return rt; +} + +/** +* @brief 删除左边的空格 +* @param szInput 输入字符串 +* @param szOutput 输出字符串 +* @details +* 将输入字符串去除左端空格后的内容,复制到输出字符串 +*/ +void l_trim(OUT CM_CHAR *szOutput, IN const CM_CHAR *szInput) +{ + /*- 输入合法性检查 */ + CM_NM_ASSERT(szInput != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + CM_NM_ASSERT(szOutput != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + CM_NM_ASSERT(szOutput != szInput, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + /*- @alias 找到输入字符串左起第一个非空格 */ + while(1) + { + if((*szInput != '\0') && (s_isspace(*szInput))) + { + ++szInput; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "提高代码执行效率" */ + } + else + { + /*- 跳出 */ + break; + } + } + /*- 将第一个非空格及右边剩余的字符串复制到输出 */ + (void)strcpy(szOutput, szInput); +} + +/** +* @brief 删除左右两边的空格 +* @param szInput 输入字符串 +* @param szOutput 输出字符串 +* @details +* 将输入字符串去除左右端空格后的内容,复制到输出字符串 +*/ +void a_trim(OUT CM_CHAR *szOutput, IN const CM_CHAR *szInput) +{ + CM_CHAR *p = NULL; + /*- 输入合法性检查 */ + CM_NM_ASSERT(szInput != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + CM_NM_ASSERT(szOutput != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + /*- 去除左端的空格 */ + l_trim(szOutput, szInput); + /*- @alias 去除右端的空格 */ + for (p = (szOutput + strlen(szOutput)) - 1u; (p >= szOutput) && (s_isspace(*p)); --p) /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "提高代码执行效率" */ + { + ; + } + *(++p) = '\0'; /* parasoft-suppress MISRA2004-17_4 "提高代码执行效率" */ +} + +/** +* @brief 读取指定的字符串键值 +* @param profile 配置文件路径 +* @param appName 块名 +* @param keyName 键名 +* @param keyVal 键值 +* @return 返回值 +* - ENUM_CM_TRUE 找到了 +* - ENUM_CM_FALSE 没找到 +* @details +* 配置文件单行长度不超过100字节 +*/ +ENUM_CM_RETURN CM_GetProfileString(IN const CM_CHAR *profile, IN const CM_CHAR *appName, IN const CM_CHAR *keyName, OUT CM_CHAR *keyVal) +{ + /*- 变量初始化 */ + CM_CHAR appnamebuf[32] = { 0 }; /* 块名,带[] */ + CM_CHAR keynamebuf[32] = { 0 }; /* 缓存文件中读出的键名 */ + CM_CHAR *pBuf = NULL; /* 临时变量:字符指针 */ + CM_CHAR *pTmp = NULL; /* 临时变量:字符指针 */ + CM_CHAR buf_i[KEYVALLEN] = { 0 }; /* 临时变量:字符串缓冲区 */ + CM_CHAR buf_o[KEYVALLEN] = { 0 }; /* 临时变量:字符串缓冲区 */ + FILE *pfile = NULL; /* 文件指针 */ + CM_INT32 found = 0; /* 1 appName 2 keyName */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- 打开配置文件 */ + CM_NM_ASSERT(profile != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); +#if QNX + pfile = fopen(profile, "r"); +#else + CM_CHAR WIN32_profile[1024] = {0}; + strcat(&WIN32_profile, p_exe_path); + strcat(&WIN32_profile, profile); + pfile = fopen(WIN32_profile, "r"); +#endif + /*- 是否成功打开配置文件 */ + if (pfile != NULL) + { + /*- 准备块名 */ + (void)fseek(pfile, (long)0, SEEK_SET); + (void)CM_Memset(appnamebuf, 0u, sizeof(appnamebuf),sizeof(appnamebuf)); + CM_NM_ASSERT(appName != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + (void)sprintf(appnamebuf, "[%s]", appName); + + /*- 按行循环读出配置文件 */ + while ((!feof(pfile)) && (fgets(buf_i, KEYVALLEN, pfile) != NULL)) /* parasoft-suppress MISRAC2012-RULE_13_5-a MISRAC2012-RULE_15_4-a "提高代码效率,只在初始化阶段使用,无安全风险" */ + { + /*- 去除行左边的空格 */ + l_trim(buf_o, buf_i); + /*- 字符串长度是否大于0 */ + if (strlen(buf_o) > 0u) + { + /*- 检查去除左边空格后的字符串 */ + pBuf = buf_o; + /*- found标记是否为0 */ + if (found == 0) + { + /*- 是否不是'[' */ + if (pBuf[0] != '[') + { + /*- 继续读取下一行 */ + } + /*- 是否与块名一致 */ + else if (strncmp(pBuf, appnamebuf, strlen(appnamebuf)) == 0) + { + /*- found标记置1 */ + found = 1; + } + else + { + /*- 无处理 */ + } + } + /*- found标记是否为1 */ + else if (found == 1) + { + /*- 本行是否为注释 */ + if (pBuf[0] == '#') + { + /*- 继续读取下一行 */ + } + /*- 本行是否为新的块标志 */ + else if (pBuf[0] == '[') + { + /*- 没找到,退出循环 */ + break; + } + else + { + /*- 本行中是否有'=' */ + pTmp = (CM_CHAR*)strchr(pBuf, '='); + if (pTmp != NULL) + { + /*- 提取‘=’左边的字符串为键名 */ + (void)CM_Memset(keynamebuf, 0u, sizeof(keynamebuf), sizeof(keynamebuf)); + (void)sscanf(pBuf, "%[^=|^ |^\t]", keynamebuf); + /*- 提取到的键名是否与要查找的键名一致 */ + if (strcmp(keynamebuf, keyName) == 0) + { + /*- 提取'='右边的字符串,去除两侧空格后输出 */ + (void)sscanf(pTmp, "=%[^\n]", buf_i); + a_trim(keyVal, buf_i); + /*- found标记置2 */ + found = 2; + /*- 退出循环 */ + break; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + } + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + }/* end while */ + (void)fclose(pfile); + } + else + { + /*- 打开配置文件失败,宕机 */ + CM_NM_ASSERT(0, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + } + /*- found标记是否为2 */ + if (2 == found) + { + /*- 函数返回值置1 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 输出返回值 */ + return rt; +} + +/** +* @brief 读取指定的整型键值 +* @param profile 配置文件路径 +* @param appName 块名 +* @param keyName 键名 +* @return 键值 +* - 没找到时返回0 +* @details +* 配置文件单行长度不超过100字节 +*/ +CM_INT32 CM_GetProfileInt(IN const CM_CHAR *profile, IN const CM_CHAR *AppName, IN const CM_CHAR *KeyName) +{ + CM_CHAR s[KEYVALLEN] = { 0 }; /* 临时变量:字符串 */ + CM_INT32 rt = 0; /* 函数返回值 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + /*- 读取键值字符串 */ + CM_NM_ASSERT(profile != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_4,TSCP_DARK_ASSERT_1); + CM_NM_ASSERT(AppName != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_4,TSCP_DARK_ASSERT_2); + CM_NM_ASSERT(KeyName != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_4,TSCP_DARK_ASSERT_3); + ret = CM_GetProfileString(profile, AppName, KeyName, s); + /*- 是否找到了键值字符串 */ + if (ENUM_CM_TRUE == ret) + { + /*- 将键值字符串转为整型变量作为函数返回值 */ + rt = (CM_INT32)atoi(s); + } + else + { + /*- 无处理 */ + } + /*- 输出返回值 */ + return rt; +} + +/** +* @brief 读取指定的HEX键值 +* @param profile 配置文件路径 +* @param appName 块名 +* @param keyName 键名 +* @return 键值 +* - 没找到时返回0 +* @details +* 配置文件单行长度不超过100字节 +*/ +CM_UINT32 CM_GetProfileHex(IN const CM_CHAR *profile, OUT const CM_CHAR *AppName, IN const CM_CHAR *KeyName) +{ + CM_CHAR s[KEYVALLEN] = { 0 };/* 临时变量:字符串 */ + ENUM_CM_RETURN ret = 0; /* 临时变量 */ + CM_UINT32 val = 0u;/* 函数返回值 */ + /*- 读取键值字符串 */ + CM_NM_ASSERT(profile != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + CM_NM_ASSERT(AppName != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_2); + CM_NM_ASSERT(KeyName != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_3); + ret = CM_GetProfileString(profile, AppName, KeyName, s); + /*- 是否找到了键值字符串 */ + if (ENUM_CM_TRUE == ret) + { + /*- 将键值字符串按HEX格式转为整型变量作为函数返回值 */ + (void)sscanf(s, "%x", &val); + } + else + { + /*- 无处理 */ + } + /*- 输出返回值 */ + return val; +} + +/** +* @brief 读取指定文件 +* @param profile 文件名 +* @param offset 文件偏移量 +* @param len 要读取的内容长度 +* @param pFileBuf 读取文件的存放的buf +* @return 成功时返回1 +* - 失败时返回0 +* @details +*/ + +CM_INT32 CM_ReadFile(IN const CM_CHAR *profile, IN CM_UINT32 offset, IN CM_INT64 len, OUT CM_UINT8 *pFileBuf) +{ + FILE *pfile = NULL; /* 文件指针 */ + CM_UINT64 fileSize = 0u; + CM_INT32 rtn = 0; + /*- 打开文件 */ + CM_NM_ASSERT(profile != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + pfile = fopen(profile, "r"); + if((NULL != profile)&&(NULL != pFileBuf)&&(NULL != pfile)) + { + (void)fseek(pfile, (long int)0, SEEK_END); + /*- 获取文件长度*/ + fileSize = (CM_UINT64)ftell(pfile); + if(((CM_UINT64)len + (CM_UINT64)offset) <= fileSize) + { + (void)fseek(pfile, (CM_INT64)offset, SEEK_SET); + /*- 读取文件*/ + if(0 == fread(pFileBuf, (CM_UINT64)len, 1u, pfile)) + { + rtn = 0; + } + else + { + rtn = 1; + } + } + else + { + + } + + } + else + { + + } + + if(NULL == pfile) + { + /*- 无处理 */ + } + else + { + /*- 关闭文件 */ + (void)fclose(pfile); + } + return rtn; +} + +/** +* @brief 读取指定文件 +* @param pfile 文件描述符 +* @param pFileBuf 读取文件的存放的buf +* @param len 要读取的内容长度 +* @return 成功时返回1 +* - 失败时返回0 +* @details +*/ + +CM_INT32 CM_ReadOpenFile(IN FILE *pfile, OUT CM_UINT8 *pFileBuf ,IN CM_INT64 len ) +{ + CM_INT32 rtn = 0; + + if((NULL != pfile)&&(NULL != pFileBuf)) + { + /*- 读取文件*/ + if(0u == fread(pFileBuf, (CM_UINT64)len, 1u, pfile)) + { + rtn = 0; + } + else + { + rtn = 1; + } + } + else + { + + } + return rtn; +} + +/** +* @brief 获取文件大小 +* @param profile 文件名 +* @return 文件大小 +* - 没找到时返回0 +*/ +CM_INT64 CM_GetFileSize(IN const CM_CHAR *profile) +{ + FILE *pfile = NULL; /* 文件指针 */ + CM_INT64 fileSize = 0; + /*- 打开文件 */ + CM_NM_ASSERT(profile != NULL, INIFILE_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_1); + pfile = fopen(profile, "r"); + if((NULL != profile)&&(NULL != pfile)) + { + (void)fseek(pfile, (CM_INT64)0, SEEK_END); + /*- 获取文件长度*/ + fileSize = ftell(pfile); + /*- 如果获取文件长度失败,返回长度为0*/ + if(-1 == fileSize) + { + fileSize = 0; + } + else + { + + } + /*- 关闭文件 */ + (void)fclose(pfile); + } + else + { + + } + return fileSize; +} diff --git a/TSCP/src/MSCP/CM/CM_IniFile.h b/TSCP/src/MSCP/CM/CM_IniFile.h new file mode 100644 index 0000000..7b15dc7 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_IniFile.h @@ -0,0 +1,48 @@ +/** +* @file CM_IniFile.h +* @brief 读取ini配置文件 +* @author GT-BU +* @date 2021.02.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CM_INIFILE_H_ +#define CM_INIFILE_H_ + +#include "CM_Types.h" +#include "CM_Memory.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + + + /* 读取指定的字符串键值 */ + ENUM_CM_RETURN CM_GetProfileString(IN const CM_CHAR *profile, IN const CM_CHAR *appName, IN const CM_CHAR *keyName, OUT CM_CHAR *keyVal); + /* 读取指定的整型键值 */ + CM_INT32 CM_GetProfileInt(IN const CM_CHAR *profile,IN const CM_CHAR *AppName,IN const CM_CHAR *KeyName); + + /* 读取指定的HEX键值 */ + CM_UINT32 CM_GetProfileHex(IN const CM_CHAR *profile, OUT const CM_CHAR *AppName, IN const CM_CHAR *KeyName); + + CM_INT32 CM_ReadFile(IN const CM_CHAR *profile, IN CM_UINT32 offset, IN CM_INT64 len, OUT CM_UINT8 *pFileBuf); + + /* 获取文件大小*/ + CM_INT64 CM_GetFileSize(IN const CM_CHAR *profile); + CM_INT32 CM_ReadOpenFile(IN FILE *pfile, OUT CM_UINT8 *pFileBuf ,IN CM_INT64 len ); + void l_trim(OUT CM_CHAR *szOutput, IN const CM_CHAR *szInput); + void a_trim(OUT CM_CHAR *szOutput, IN const CM_CHAR *szInput); +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/MSCP/CM/CM_MD5.c b/TSCP/src/MSCP/CM/CM_MD5.c new file mode 100644 index 0000000..699eacd --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MD5.c @@ -0,0 +1,520 @@ +/** +* @file CM_MD5.c +* @brief MD5计算 +* @details 参照 RFC-1321 标准实现 +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "CM_MD5.h" +#include "CM_Memory.h" +#include "PFM_Log.h" +static CM_UINT8 s_PADDING[64u] = +{ + 0x80u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u +}; + +/* F, G, H and I are basic MD5 functions. */ +#define F(x, y, z) ((((x) & (y)) | (~(x) & (z)))) +#define G(x, y, z) ((((x) & (z)) | ((y) & ~(z)))) +#define H(x, y, z) (((x) ^ (y) ^ (z))) +#define I(x, y, z) (((y) ^ ((x) | ~(z)))) + +/* ROTATE_LEFT rotates x left n bits. */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> ((CM_UINT32)32U-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. + Rotation is separate from addition to prevent recomputation. + */ +#define FF(a, b, c, d, x, s, ac) \ + { \ + (a) += F((b), (c), (d)) + (x) + (CM_UINT32)(ac); \ + (a) = ROTATE_LEFT((a), (CM_UINT32)(s)); \ + (a) += (b); \ + } + +#define GG(a, b, c, d, x, s, ac) \ + { \ + (a) += G((b), (c), (d)) + (x) + (CM_UINT32)(ac); \ + (a) = ROTATE_LEFT((a), (CM_UINT32)(s)); \ + (a) += (b); \ + } + +#define HH(a, b, c, d, x, s, ac) \ + { \ + (a) += H((b), (c), (d)) + (x) + (CM_UINT32)(ac); \ + (a) = ROTATE_LEFT((a), (CM_UINT32)(s)); \ + (a) += (b); \ + } + +#define II(a, b, c, d, x, s, ac) \ + { \ + (a) += I((b), (c), (d)) + (x) + (CM_UINT32)(ac); \ + (a) = ROTATE_LEFT((a), (CM_UINT32)(s)); \ + (a) += (b); \ + } +static void s_MD5_Encode(OUT CM_UINT8 * output, IN const CM_UINT32 * input, IN CM_UINT32 len); +static void s_MD5_Decode(OUT CM_UINT32 output[], IN const CM_UINT8 input[], IN CM_UINT32 len); +static void s_MD5_Transform(INOUT CM_UINT32 state[4], IN const CM_UINT8 block[64]); +/** +* @brief 数据编码 +* @param output 输出指针 +* @param input 输入指针 +* @param len 输入长度 +* @details len必须是4的倍数 +*/ +static void s_MD5_Encode(OUT CM_UINT8 * output, IN const CM_UINT32 * input, IN CM_UINT32 len) +{ + /*- 变量初始化 */ + CM_UINT32 i = 0U; + CM_INT32 j = 0; + + /*- @alias 将U32编码到U8数组 */ + for (i = (CM_UINT32)0u; (CM_UINT32)j < len; ++i) + { + output[j] = (CM_UINT8)(input[i] & 0xffU); + output[j + 1] = (CM_UINT8)((input[i] >> 8U) & 0xffU); + output[j + 2] = (CM_UINT8)((input[i] >> 16U) & 0xffU); + output[j + 3] = (CM_UINT8)((input[i] >> 24U) & 0xffU); + j += 4; + } +} + +/** +* @brief 数据解码 +* @param output 输出指针 +* @param input 输入指针 +* @param len 输入长度 +* @details len必须是4的倍数 +*/ +static void s_MD5_Decode(OUT CM_UINT32 output[], IN const CM_UINT8 input[], IN CM_UINT32 len) +{ + CM_UINT32 i = 0U; + CM_INT32 j = 0; + + /*- @alias 从U8解码到U32数组 */ + for (i = (CM_UINT32)0u ; (CM_UINT32)j < len; ++i) + { + output[i] = ((CM_UINT32)input[j]) | + (((CM_UINT32)input[j + 1]) << 8U) | + (((CM_UINT32)input[j + 2]) << 16U) | + (((CM_UINT32)input[j + 3]) << 24U); + j += 4; + } +} + +/** +* @brief MD5变换 +* @param state Context状态字 +* @param block 数据块 +*/ +static void s_MD5_Transform(INOUT CM_UINT32 state[4], IN const CM_UINT8 block[64]) +{ + /* Constants for MD5Transform routine. */ + static const int S11 = 7; + static const int S12 = 12; + static const int S13 = 17; + static const int S14 = 22; + static const int S21 = 5; + static const int S22 = 9; + static const int S23 = 14; + static const int S24 = 20; + static const int S31 = 4; + static const int S32 = 11; + static const int S33 = 16; + static const int S34 = 23; + static const int S41 = 6; + static const int S42 = 10; + static const int S43 = 15; + static const int S44 = 21; + + CM_UINT32 a = 0U; + CM_UINT32 b = 0U; + CM_UINT32 c = 0U; + CM_UINT32 d = 0U; + CM_UINT32 x[16] = { 0u }; + + a = state[0]; + + b = state[1]; + c = state[2]; + d = state[3]; + + /*- 将数据块编码 */ + s_MD5_Decode(x, block, (CM_UINT32)64u); + + /*- MD5 Round 1 */ + FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */ + + FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */ + + FF(c, d, a, b, x[2], S13, 0x242070dbU); /* 3 */ + + FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */ + + FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */ + + FF(d, a, b, c, x[5], S12, 0x4787c62aU); /* 6 */ + + FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */ + + FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */ + + FF(a, b, c, d, x[8], S11, 0x698098d8U); /* 9 */ + + FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */ + + FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + + FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + + FF(a, b, c, d, x[12], S11, 0x6b901122U); /* 13 */ + + FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + + FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + + FF(b, c, d, a, x[15], S14, 0x49b40821U); /* 16 */ + + /*- MD5 Round 2 */ + GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */ + + GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */ + + GG(c, d, a, b, x[11], S23, 0x265e5a51U); /* 19 */ + + GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */ + + GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */ + + GG(d, a, b, c, x[10], S22, 0x2441453U); /* 22 */ + + GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + + GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */ + + GG(a, b, c, d, x[9], S21, 0x21e1cde6U); /* 25 */ + + GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + + GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */ + + GG(b, c, d, a, x[8], S24, 0x455a14edU); /* 28 */ + + GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + + GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */ + + GG(c, d, a, b, x[7], S23, 0x676f02d9U); /* 31 */ + + GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /*- MD5 Round 3 */ + + HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */ + + HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */ + + HH(c, d, a, b, x[11], S33, 0x6d9d6122U); /* 35 */ + + HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + + HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */ + + HH(d, a, b, c, x[4], S32, 0x4bdecfa9U); /* 38 */ + + HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */ + + HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + + HH(a, b, c, d, x[13], S31, 0x289b7ec6U); /* 41 */ + + HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */ + + HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */ + + HH(b, c, d, a, x[6], S34, 0x4881d05U); /* 44 */ + + HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */ + + HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + + HH(c, d, a, b, x[15], S33, 0x1fa27cf8U); /* 47 */ + + HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */ + + /*- MD5 Round 4 */ + II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */ + + II(d, a, b, c, x[7], S42, 0x432aff97U); /* 50 */ + + II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + + II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */ + + II(a, b, c, d, x[12], S41, 0x655b59c3U); /* 53 */ + + II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */ + + II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + + II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */ + + II(a, b, c, d, x[8], S41, 0x6fa87e4fU); /* 57 */ + + II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + + II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */ + + II(b, c, d, a, x[13], S44, 0x4e0811a1U); /* 60 */ + + II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */ + + II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + + II(c, d, a, b, x[2], S43, 0x2ad7d2bbU); /* 63 */ + + II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */ + + /*- 更新状态字 */ + state[0] += a; + + state[1] += b; + + state[2] += c; + + state[3] += d; + + /*CM_Memset((void *)x, (CM_UINT8)0u, sizeof(x)); 信息安全措施,可不处理*/ +} + +/** +* @brief MD5初始化 +* @param context Context结构体指针 +* @return 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* MD5 initialization. Begins an MD5 operation, writing a new context. + */ +ENUM_CM_RETURN CM_MD5_Init(INOUT MD5Context_T* context) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + /*- 输入是否合法 */ + if (NULL != context) + { + /*- 初始化context结构体 */ + context->count[0] = context->count[1] = 0U; + /* Load magic initialization constants.*/ + context->state[0] = 0x67452301U; + context->state[1] = 0xEFCDAB89U; + context->state[2] = 0x98BADCFEU; + context->state[3] = 0x10325476U; + ret = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回执行结果 */ + return ret; +} + +/** +* @brief MD5更新操作 +* @param context Context结构体指针 +* @param buf 输入字符首指针 +* @param len 输入字符数 +* @return 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* MD5 block update operation. Continues an MD5 message-digest +* operation, processing another message block, and updating the +* context. +*/ +ENUM_CM_RETURN CM_MD5_Update(INOUT MD5Context_T* context, IN const CM_UINT8 buf[], IN CM_UINT32 len) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT32 i = 0U; + CM_UINT32 index = 0U; + CM_UINT32 partLen = 0U; + + /*- 输入是否合法 */ + if ((NULL != context) && (NULL != buf)) + { + + /*- 计算长度对64的余数 */ + index = (CM_UINT32)((context->count[0] >> 3U) & 0x3FU); + + context->count[0] += (CM_UINT32)(len << 3U); + /*- @alias 计算位数 */ + if ((CM_UINT32)(context->count[0]) < (len << (CM_UINT32)3U)) + { + context->count[1]++; + } + else + { + /*- 无处理 */ + } + + context->count[1] += (CM_UINT32)(len >> 29U); + + /*- 计算尾数 */ + partLen = 64U - index; + + /*- 长度是否够长,需要Transfrom运算 */ + if (len >= partLen) + { + /*- 首块的Transfrom运算 */ + (void)CM_Memcpy(((void*)(&context->buffer[index])), (size_t)partLen, (const void*)buf, (size_t)partLen); + + s_MD5_Transform(context->state, (const CM_UINT8*)context->buffer); + /*- @alias 后续块的Transform运算 */ + for (i = partLen; (i + (CM_UINT32)63U) < (CM_UINT32)len; i += 64U) + { + s_MD5_Transform(context->state, &buf[i]); + } + + /*- 长度余数置零 */ + index = (CM_UINT32)0u; + } + else + { + /*- 用所有数据更新Context */ + i = (CM_UINT32)0u; + } + + /*- 更新Context,缓存遗留数据 */ + (void)CM_Memcpy(((void*)(&context->buffer[index])), (size_t)CM_UNSIGNED_INT_EXP(len - i), ((const void*)(&buf[i])), (size_t)CM_UNSIGNED_INT_EXP(len - i)); + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回执行结果 */ + return rt; +} + +/** +* @brief 确定最终的MD5数值 +* @param context Context结构体指针 +* @param digest MD5数值 +* @return 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* MD5 finalization. Ends an MD5 message-digest operation, writing the +* the message digest and zeroizing the context. +*/ +ENUM_CM_RETURN CM_MD5_Final(INOUT MD5Context_T* context, OUT CM_UINT8 digest[CM_MD5_SIZE_BYTE]) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT8 bits[8] = { 0u }; + CM_UINT32 index = 0U; + CM_UINT32 padLen = 0U; + + /*- 输入是否合法 */ + if ((NULL != context) && (NULL != digest)) + { + /*- 保存位数 */ + /* Save number of bits */ + s_MD5_Encode(bits, (CM_UINT32*)(context->count), (CM_UINT32)8u); + + /* Pad out to 56 mod 64.*/ + index = (CM_UINT32)((context->count[0] >> 3U) & 0x3fU); + + /*- @alias 确定尾数 */ + if (index < (CM_UINT32)56u) + { + padLen = 56U - index; + } + else + { + padLen = 120U - index; + } + + /*- 更新Context */ + (void)CM_MD5_Update(context, s_PADDING, padLen); + /* Append length (before padding) */ + (void)CM_MD5_Update(context, bits, (CM_UINT32)8u); + + /*- 计算输出结果 */ + /* Store state in digest */ + s_MD5_Encode(digest, (CM_UINT32*)(context->state), (CM_UINT32)16u); + + /*- 清理Context */ + /* Zeroize sensitive information.*/ + rt = CM_Memset((void*)context, (CM_UINT8)0u, sizeof(*context), sizeof(*context)); + } + else + { + /*- 无处理 */ + } + /*- 返回执行结果 */ + return rt; +} + +/** +* @brief MD5计算 +* @param inputString 输入字符串指针 +* @param len 输入字符串长度 +* @param pOutputMD5Buf MD5值 +* @return 函数执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_MD5_Calc(IN const CM_UINT8* inputString, IN CM_UINT32 len, OUT CM_UINT8 pOutMD5Buf[CM_MD5_SIZE_BYTE]) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + MD5Context_T context; + + /*- 输入是否合法 */ + if ((NULL != pOutMD5Buf) && (NULL != inputString)) + { + /*- 初始化Context */ + ret = CM_Memset((void*) &context, (CM_UINT8)0u, sizeof(MD5Context_T), sizeof(MD5Context_T)); + ret = CM_Memset((void*)pOutMD5Buf, (CM_UINT8)0u, (size_t)CM_MD5_SIZE_BYTE, (size_t)CM_MD5_SIZE_BYTE); + + rt = CM_MD5_Init(&context); + /*- 初始化Context是否成功 */ + if ((ENUM_CM_TRUE == rt) && (ENUM_CM_TRUE == ret)) + { + /*- 用输入数据更新Context */ + rt = CM_MD5_Update(&context, inputString, len); + /*- Context是否更新成功 */ + if (ENUM_CM_TRUE == rt) + { + /*- 计算最终的MD5值 */ + rt = CM_MD5_Final(&context, pOutMD5Buf); + } + else + { + /*- 无处理 */ + } + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + /*- 无处理 */ + } + /*- 返回执行结果 */ + return rt; +} diff --git a/TSCP/src/MSCP/CM/CM_MD5.h b/TSCP/src/MSCP/CM/CM_MD5.h new file mode 100644 index 0000000..1688b65 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MD5.h @@ -0,0 +1,77 @@ +/** +* @file CM_MD5.h +* @brief MD5计算 +* @details +* 两个不同文件具有相同MD5值的概率为1/2^64 +* 错误的文件能匹配特定MD5值的概率为1/2^128 +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CM_MD5_H +#define CM_MD5_H + +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + +#define CM_MD5_SIZE_BYTE (16U) + + /** MD5计算结构体 */ + typedef struct + { + CM_UINT32 state[4]; /* 状态 */ + CM_UINT32 count[2]; /* 计数 */ + unsigned char buffer[64]; /* 中间结果 */ + }MD5Context_T;/*MD5运算过程中缓存信息的结构体*/ + + /** + * @brief 计算MD5 + * @param[in] inputString + * @param[in] len + * @param[out] pOutMD5Buf + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_MD5_Calc(IN const CM_UINT8* inputString, IN CM_UINT32 len, OUT CM_UINT8 pOutMD5Buf[CM_MD5_SIZE_BYTE]); + + /** + * @brief 初始化Context结构,定义CM_MD5Context之后调用 + * @param[inout] context MD5Context_T结构指针 + * @return CM_BOOL + * @note 分步计算MD5用 + */ + ENUM_CM_RETURN CM_MD5_Init(INOUT MD5Context_T* context); + + /** + * @brief 将data信息,计算并入context中 + * @param[inout] context MD5Context_T结构指针 + * @param[in] buf 输入字符首指针 + * @param[in] len 输入字符数 + * @return CM_BOOL + * @note 分步计算MD5用 + */ + ENUM_CM_RETURN CM_MD5_Update(INOUT MD5Context_T* context, IN const CM_UINT8 buf[], IN CM_UINT32 len); + + /** + * @brief 计算context的MD5数值 + * @param[inout] context MD5Context_T结构指针 + * @param[out] digest MD5数值 + * @return CM_BOOL + * @note 分步计算MD5用 + */ + ENUM_CM_RETURN CM_MD5_Final(INOUT MD5Context_T* context, OUT CM_UINT8 digest[CM_MD5_SIZE_BYTE]); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _CM_MD5_H */ diff --git a/TSCP/src/MSCP/CM/CM_MQ.c b/TSCP/src/MSCP/CM/CM_MQ.c new file mode 100644 index 0000000..27999cb --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MQ.c @@ -0,0 +1,680 @@ +/** +* @file CM_MQ.c +* @brief 实现消息队列(线程安全)的封装 +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "CM_MQ.h" +#include "CM_Memory.h" + +#define CM_MQ_LIGHT_MSG_NUM_MAX (60000u) /**< 最大消息条数 */ +#define CM_MQ_LIGHT_MSG_SIZE_MAX (65535u) /**< 单条消息最大长度 */ + +/** +* @brief 消息队列读取 +* @param pMQ 要读的消息队列 +* @param pOutBuf 要输出消息的缓冲区 +* @param pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Read(INOUT CM_MQ_Struct_T* pMQ, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (NULL == pOutBuf) || (NULL == pBufSize) + || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 消息队列是否非空 */ + if (0u < pMQ->msgNum) + { + /*- 消息长度是否过长 */ + if (pMQ->pMQMsg[pMQ->front].msgSize > *pBufSize) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 从front位读出消息*/ + (void)CM_Memcpy((void*)pOutBuf, (CM_SIZE_T) *pBufSize, ((const void*)(pMQ->pMQMsg[pMQ->front].pMsgBuf)), ((CM_SIZE_T)(pMQ->pMQMsg[pMQ->front].msgSize))); + *pBufSize = pMQ->pMQMsg[pMQ->front].msgSize; + + /*- 清空已读消息内容的接口-此处清除大小,内容不清除*/ + + pMQ->pMQMsg[pMQ->front].msgSize = 0U; + + /*- 更新队列状态 */ + pMQ->front = (pMQ->front + 1) % (CM_INT32)pMQ->maxMsgNum;/*front前进一步*/ + + + /*- 消息数目减1 */ + --(pMQ->msgNum); + + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + } + else + { + /*- 无处理 */ + } + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + } + + /*- 返回函数执行结果 */ + return rt; +} +/** +* @brief 消息队列读取 +* @param pMQ 要读的消息队列指针 取值范围:非空 +* @param index 要输出消息队列的索引 取值范围:0~0xffff +* @param pOutBuf 要输出消息的缓冲区指针 取值范围:非空 +* @param pBufSize 作为输入参数时为输出的缓冲区消息大小指针,作为输出参数为读到的消息大小指针 取值范围:非空 +* @return 执行结果 +* - ENUM_CM_TRUE 0x55 执行成功 +* - ENUM_CM_FALSE 0xaa 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Again_Read(INOUT CM_MQ_Struct_T* pMQ, IN CM_UINT16 index, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT16 msgSize = 0u; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (NULL == pOutBuf) || (NULL == pBufSize) + || (CM_TRUE != pMQ->initialized) || (index == 0u)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 计算消息队列长度 */ + msgSize = pMQ->pMQMsg[(pMQ->rear + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].again_msgSize; + /*- 消息长度是否过长 */ + if ((msgSize > *pBufSize) || (msgSize == 0u)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 从rear+index位读出消息*/ + (void)CM_Memcpy((void*)pOutBuf, (CM_SIZE_T) *pBufSize, ((const void*)(pMQ->pMQMsg[(pMQ->rear + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].pMsgBuf)), ((CM_SIZE_T)msgSize)); + *pBufSize = pMQ->pMQMsg[(pMQ->rear + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].again_msgSize; + + /*- 清空已读消息内容的接口-此处清除大小,内容不清除*/ + pMQ->pMQMsg[(pMQ->rear + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].again_msgSize = 0U; + + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + } + + /*- 返回函数执行结果 */ + return rt; +} +/** +* @brief 消息队列清空(一条消息) +* @param pMQ 要清空的消息队列 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Read_Clear(INOUT CM_MQ_Struct_T* pMQ) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 消息队列是否非空 */ + if (0u < pMQ->msgNum) + { + /*- 清空已读消息内容的接口-此处清除大小,内容不清除*/ + pMQ->pMQMsg[pMQ->front].msgSize = 0U; + /*- 更新队列状态 */ + pMQ->front = (pMQ->front + 1) % (CM_INT32)pMQ->maxMsgNum;/*front前进一步*/ + /*- 消息数目减1 */ + --(pMQ->msgNum); + + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + (void)CM_Mutex_Unlock(pMQ->mutex); + } + + /*- 返回函数执行结果 */ + return rt; +} +/** +* @brief 读消息队列,获取数据首地址 +* @param pMQ 要读的消息队列 +* @param pBufSize 数据有效长度 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +CM_UINT8* CM_MQ_Read_Addr(INOUT CM_MQ_Struct_T* pMQ,INOUT CM_UINT16* pBufSize) +{ + /*- 变量初始化 */ + CM_UINT8* rt = NULL; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (NULL == pBufSize) + || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = NULL; + } + else + { + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 消息队列是否非空 */ + if (0u < pMQ->msgNum) + { + /*- 从front位读出消息*/ + rt = pMQ->pMQMsg[pMQ->front].pMsgBuf; + *pBufSize = pMQ->pMQMsg[pMQ->front].msgSize; + } + else + { + /*- 无处理 */ + rt = NULL; + } + (void)CM_Mutex_Unlock(pMQ->mutex); + } + /*- 返回函数执行结果 */ + return rt; +} +/** +* @brief 更新消息队列头指针 +* @param pMQ 要读的消息队列 +* @param pBufSize 数据有效长度 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Read_UpData(INOUT CM_MQ_Struct_T* pMQ) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ)|| (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 消息队列是否非空 */ + if (0u < pMQ->msgNum) + { + pMQ->pMQMsg[pMQ->front].msgSize = 0U; + /*- 更新队列状态 */ + pMQ->front = (pMQ->front + 1) % (CM_INT32)pMQ->maxMsgNum;/*front前进一步*/ + /*- 消息数目减1 */ + --(pMQ->msgNum); + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + rt = ENUM_CM_FALSE; + } + (void)CM_Mutex_Unlock(pMQ->mutex); + } + /*- 返回函数执行结果 */ + return rt; +} +/** +* @brief 消息队列查询(仅读取而不弹出) +* @param pMQ 要读的消息队列 +* @param index 要读取的消息序号 +* @param pOutBuf 要输出消息的缓冲区 +* @param pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Get(IN const CM_MQ_Struct_T* pMQ, IN CM_UINT16 index, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT8* pRcvBuf = NULL; + CM_UINT16 BufSize = 0u; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (NULL == pOutBuf) || (NULL == pBufSize) + || (index >= pMQ->msgNum) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 要读取的消息长度是否过长 */ + if (pMQ->pMQMsg[(pMQ->front + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].msgSize > *pBufSize) + { + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 输出要读取的临时消息信息 */ + pRcvBuf = pMQ->pMQMsg[(pMQ->front + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].pMsgBuf; + BufSize = pMQ->pMQMsg[(pMQ->front + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].msgSize; + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + (void)CM_Memcpy((void*)pOutBuf, (CM_SIZE_T) *pBufSize, (const void*)pRcvBuf,(CM_SIZE_T)BufSize); + *pBufSize = BufSize; + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 写消息队列 +* @param pMQ 要写的消息队列 +* @param pMsgBuf 要写的消息 +* @param BufSize 要写的消息大小 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Write(INOUT CM_MQ_Struct_T* pMQ, IN const CM_UINT8* pMsgBuf, IN CM_UINT16 BufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT16 temp = 0U; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (NULL == pMsgBuf) || (BufSize > pMQ->maxMsgSize) || (BufSize == 0U) + || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + + temp = pMQ->maxMsgNum - (CM_UINT16)1u;/*计算temp*/ + /*- 消息队列是否已满*/ + if (temp == pMQ->msgNum)/*如果当前消息数=max-1 表示满了*/ + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 在队尾写入消息 */ + (void)CM_Memcpy(((void*)(pMQ->pMQMsg[pMQ->rear].pMsgBuf)), (CM_SIZE_T)(pMQ->maxMsgSize), (const void*)pMsgBuf, (size_t)BufSize);/*复制消息进入rear位*/ + pMQ->pMQMsg[pMQ->rear].msgSize = BufSize; + pMQ->pMQMsg[pMQ->rear].again_msgSize = BufSize; + + /*- 更新队尾指针 */ + pMQ->rear = (pMQ->rear + 1) % (CM_INT32)pMQ->maxMsgNum;/*rear前进一步*/ + + + /*当前消息数++*/ + ++(pMQ->msgNum); + + + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 消息队列初始化 +* @param pMQ 要初始化的消息队列 +* @param maxMsgNum 消息队列大小 +* @param maxMsgSize 每条消息的大小 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Init(INOUT CM_MQ_Struct_T* pMQ, IN CM_UINT16 maxMsgNum, IN CM_UINT16 maxMsgSize) +{ + /*- 变量初始化 */ + CM_UINT16 i = 0U; + CM_INT16 j = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + ENUM_CM_RETURN errorFlag = ENUM_CM_TRUE; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (0U == maxMsgNum) || (0U == maxMsgSize) + || ((CM_UINT16)CM_MQ_LIGHT_MSG_NUM_MAX < maxMsgNum) || ((CM_UINT16)CM_MQ_LIGHT_MSG_SIZE_MAX < maxMsgSize)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + /*- 消息队列是否已经初始化过 */ + else if (CM_TRUE == pMQ->initialized) + { + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 初始化消息队列为空 */ + pMQ->pMQMsg = NULL; + + pMQ->msgNum = (CM_UINT16)0u; + pMQ->front = 0; + pMQ->rear = 0; + pMQ->maxMsgNum = maxMsgNum + 1U;/*改为maxMsgNum+1,使用户可以初始最大数与可放最大数相等*/ + pMQ->maxMsgSize = maxMsgSize; + /*- 为消息队列分配内存 */ + pMQ->pMQMsg = (CM_MQ_Msg_Struct_T*)CM_Malloc(sizeof(CM_MQ_Msg_Struct_T) * pMQ->maxMsgNum); + /*- 创建互斥器 */ + rt = CM_Mutex_Init(&pMQ->mutex); + + /*- 内存分配或创建互斥器是否失败 */ + if ((NULL == pMQ->pMQMsg) || (ENUM_CM_TRUE != rt)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + /*- @alias 逐条消息划分内存 */ + for (i = (CM_UINT16)0u; i < pMQ->maxMsgNum; ++i) + { + pMQ->pMQMsg[i].pMsgBuf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)(pMQ->maxMsgSize)); + + /** @brief 如果初始化失败,则释放之前分配的资源 */ + + if (NULL == pMQ->pMQMsg[i].pMsgBuf) + { + for (j = (CM_INT16)i - (CM_INT16)1; j >= (CM_INT16)0; --j) + { + CM_Free(((void*)(pMQ->pMQMsg[j].pMsgBuf))); + pMQ->pMQMsg[j].pMsgBuf = NULL; + } + + CM_Free((void*)(pMQ->pMQMsg)); + + pMQ->pMQMsg = NULL; /* parasoft-suppress BD-RES-LEAKS "误报" */ + rt = ENUM_CM_FALSE; + /*- 跳出 */ + break; + } + else + { + pMQ->pMQMsg[i].msgSize = (CM_UINT16)0u; + rt = CM_Memset(((void*)(pMQ->pMQMsg[i].pMsgBuf)), (CM_UINT8)0U, ((size_t)(pMQ->maxMsgSize)), ((size_t)(pMQ->maxMsgSize))); + if(ENUM_CM_FALSE == rt) + { + errorFlag = ENUM_CM_FALSE; + } + } + } + /*- 消息队列初始化成功 */ + pMQ->initialized = CM_TRUE; + if(ENUM_CM_FALSE == errorFlag) + { + rt = ENUM_CM_FALSE; + } + else + { + /*- 无处理 */ + } + } + } + /*- 返回执行结果 */ + return rt; +} + +/** +* @brief 清空消息队列 +* @param pMQ 要清空的消息队列 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Clear(INOUT CM_MQ_Struct_T* pMQ) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 消息队列置为空 */ + pMQ->msgNum = (CM_UINT16)0u; + pMQ->front = pMQ->rear; + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 获取消息队列中的消息条数 +* @param pMQ 要获得消息个数的消息队列 +* @return CM_INT32 若失败则返回-1,否则返回消息个数 +*/ +CM_INT32 CM_MQ_Get_Msg_Num(IN const CM_MQ_Struct_T* pMQ) +{ + /*- 变量初始化 */ + CM_INT32 rt = -1; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 返回-1 */ + rt = -1; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 返回消息条数 */ + rt = (CM_INT32)(pMQ->msgNum); + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + } + /*- 返回 */ + return rt; +} + +/** +* @brief 清零消息队列 +* @param pMQ 要清零的消息队列 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Flush(INOUT CM_MQ_Struct_T* pMQ) +{ + /*- 变量初始化 */ + CM_UINT16 msgIndex = 0U; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + + /*- @alias 将所有消息的消息内容清零 */ + for (msgIndex = 0u; msgIndex < (pMQ->maxMsgNum); ++msgIndex) + { + pMQ->pMQMsg[msgIndex].msgSize = 0u; + rt = ENUM_CM_TRUE; + } + + /*- 消息队列置为空 */ + pMQ->front = pMQ->rear; + pMQ->msgNum = (CM_UINT16)0u; + + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + + } + + /*- 返回执行结果 */ + return rt; +} + +CM_UINT8* CM_MQ_Get_BufAddr(INOUT CM_MQ_Struct_T* pMQ) +{ + /*- 变量初始化 */ + CM_UINT8* rt = NULL; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = NULL; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 消息队列是否已满*/ + if ((pMQ->maxMsgNum - 1u) == pMQ->msgNum)/*如果当前消息数=max-1 表示满了*/ + { + /*- 函数执行失败 */ + rt = NULL; + } + else + { + rt = pMQ->pMQMsg[pMQ->rear].pMsgBuf; + } + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + } + /*- 返回函数执行结果 */ + return rt; +} +ENUM_CM_RETURN CM_MQ_UpData(INOUT CM_MQ_Struct_T* pMQ,IN CM_UINT16 BufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + /*- 消息队列是否已满*/ + if ((pMQ->maxMsgNum - 1u) == pMQ->msgNum)/*如果当前消息数=max-1 表示满了*/ + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + pMQ->pMQMsg[pMQ->rear].msgSize = BufSize; + /*- 更新队尾指针 */ + pMQ->rear = (pMQ->rear + 1) % (CM_INT32)pMQ->maxMsgNum;/*rear前进一步*/ + /*当前消息数++*/ + ++(pMQ->msgNum); + rt = ENUM_CM_TRUE; + } + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + } + /*- 返回函数执行结果 */ + return rt; +} +/*消息队列回滚*/ +ENUM_CM_RETURN CM_MQ_RollbackData(INOUT CM_MQ_Struct_T* pMQ) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 锁定消息队列 */ + (void)CM_Mutex_Lock(pMQ->mutex); + if(0u == pMQ->msgNum) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + pMQ->rear = (pMQ->rear == 0)?(pMQ->maxMsgNum-1u):(pMQ->rear - 1) % (CM_INT32)pMQ->maxMsgNum;/*rear后退一步*/ + /*当前消息数--*/ + --(pMQ->msgNum); + pMQ->pMQMsg[pMQ->rear].msgSize = 0u; + rt = ENUM_CM_TRUE; + } + /*- 释放消息队列 */ + (void)CM_Mutex_Unlock(pMQ->mutex); + } + /*- 返回函数执行结果 */ + return rt; +} diff --git a/TSCP/src/MSCP/CM/CM_MQ.h b/TSCP/src/MSCP/CM/CM_MQ.h new file mode 100644 index 0000000..ffd5d6c --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MQ.h @@ -0,0 +1,156 @@ +/** +* @file CM_MQ.h +* @brief 实现消息队列的封装(线程安全) +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CM_MQ_H +#define CM_MQ_H + +#include "CM_Mutex.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /** 消息 */ + typedef struct + { + CM_UINT16 msgSize; /**< 消息长度 */ + CM_UINT16 again_msgSize; /**< 二次读取的消息长度 */ + CM_UINT8* pMsgBuf; /**< 消息数组 */ + }CM_MQ_Msg_Struct_T; + + /** 消息队列 */ + typedef struct + { + CM_BOOL initialized; /**< 是否初始化了 */ + CM_UINT16 maxMsgNum; /**< MQ中最大消息个数 */ + CM_UINT16 maxMsgSize; /**< 每条消息的最大字节数 */ + CM_INT32 front; /**< 头指针 */ + CM_INT32 rear; /**< 尾指针 */ + CM_UINT16 msgNum; /**< 消息队列中消息个数 */ + CM_MUTEX_T mutex; /**< 互斥信号量 */ + CM_MQ_Msg_Struct_T* pMQMsg; /**< 指向第一条消息 */ + }CM_MQ_Struct_T; + + /** + * @brief 消息队列初始化 + * @param[inout] pMQ 要初始化的消息队列 + * @param[in] maxMsgNum 消息队列大小 + * @param[in] maxMsgSize 每条消息的大小 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_MQ_Init(INOUT CM_MQ_Struct_T* pMQ, IN CM_UINT16 maxMsgNum, IN CM_UINT16 maxMsgSize); + + /** + * @brief 查看队列中消息总数 + * @param[in] pMQ 要获得消息个数的消息队列 + * @return CM_INT32 若失败则返回-1,否则返回消息个数 + */ + CM_INT32 CM_MQ_Get_Msg_Num(IN const CM_MQ_Struct_T* pMQ); + + /** + * @brief 写消息队列 + * @param[in] pMQ 要写的消息队列 + * @param[in] pMsgBuf 要写的消息 + * @param[in] size 要写的消息大小 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_MQ_Write(INOUT CM_MQ_Struct_T* pMQ, IN const CM_UINT8* pMsgBuf, IN CM_UINT16 BufSize); + + /** + * @brief 读消息队列 + * @param[in] pMQ 要读的消息队列 + * @param[out] pOutBuf 要输出消息的缓冲区 + * @param[inout] pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_MQ_Read(INOUT CM_MQ_Struct_T* pMQ, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize); + /** + * @brief 消息队列读取 + * @param pMQ 要读的消息队列 + * @param pOutBuf 要输出消息的缓冲区 + * @param pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 + * @return 执行结果 + * - ENUM_CM_TRUE 执行成功 + * - ENUM_CM_FALSE 执行失败 + */ + ENUM_CM_RETURN CM_MQ_Again_Read(INOUT CM_MQ_Struct_T* pMQ, IN CM_UINT16 index, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize); + /** + * @brief 消息队列清空(一条消息) + * @param pMQ 要清空的消息队列 + * @return 执行结果 + * - ENUM_CM_TRUE 执行成功 + * - ENUM_CM_FALSE 执行失败 + */ + ENUM_CM_RETURN CM_MQ_Read_Clear(INOUT CM_MQ_Struct_T* pMQ); + /** + * @brief 从指定位置读取消息队列(一条消息分别读到两个缓冲区) + * @param pMQ 要读的消息队列 + * @param pOutBuf 要输出消息的缓冲区 + * @param pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 + * @return 执行结果 + * - ENUM_CM_TRUE 执行成功 + * - ENUM_CM_FALSE 执行失败 + */ + CM_UINT8* CM_MQ_Read_Addr(INOUT CM_MQ_Struct_T* pMQ,INOUT CM_UINT16* pBufSize); + /** + * @brief 查看消息队列 + * + * 仅读取数据,而不弹出. + * @param[in] pMQ 要查看的消息队列 + * @param[in] index 要查看的消息索引(从0开始) + * @param[out] pOutBuf 要输出的消息缓冲区 + * @param[inout] pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_MQ_Get(IN const CM_MQ_Struct_T* pMQ, IN CM_UINT16 index, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize); + + /** + * @brief 清空消息队列 + * @param[inout] pMQ 要清空的消息队列 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + * @note 清空队列,但消息数据缓冲区不清零,执行速度较快 + */ + ENUM_CM_RETURN CM_MQ_Clear(INOUT CM_MQ_Struct_T* pMQ); + + /** + * @brief 清零消息队列 + * @param[inout] pMQ 要清零的消息队列 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + * @note 清空队列,消息数据缓冲区也置零,执行速度较慢 + */ + ENUM_CM_RETURN CM_MQ_Flush(INOUT CM_MQ_Struct_T* pMQ); + CM_UINT8* CM_MQ_Get_BufAddr(INOUT CM_MQ_Struct_T* pMQ); + ENUM_CM_RETURN CM_MQ_UpData(INOUT CM_MQ_Struct_T* pMQ,IN CM_UINT16 BufSize); + ENUM_CM_RETURN CM_MQ_Read_UpData(INOUT CM_MQ_Struct_T* pMQ); + /*消息队列回滚*/ + ENUM_CM_RETURN CM_MQ_RollbackData(INOUT CM_MQ_Struct_T* pMQ); +#ifdef __cplusplus +} + +#endif /* __cplusplus */ + +#endif /* _CM_MQ_LIGHT_H */ + diff --git a/TSCP/src/MSCP/CM/CM_MQ_Light.c b/TSCP/src/MSCP/CM/CM_MQ_Light.c new file mode 100644 index 0000000..0eb92be --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MQ_Light.c @@ -0,0 +1,365 @@ +/** +* @file CM_MQ_LIGHT.c +* @brief 实现轻型消息队列(非线程安全)的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "CM_MQ_Light.h" +#include "CM_Memory.h" + +#define CM_MQ_LIGHT_MSG_NUM_MAX (60000u) /**< 最大消息条数 */ +#define CM_MQ_LIGHT_MSG_SIZE_MAX (65535u) /**< 单条消息最大长度 */ + +/** +* @brief 消息队列读取 +* @param pMQ 要读的消息队列 +* @param pOutBuf 要输出消息的缓冲区 +* @param pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Light_Read(INOUT CM_MQ_Light_Struct_T* pMQ, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (NULL == pOutBuf) || (NULL == pBufSize) + || ((CM_UINT16)0u == pMQ->msgNum) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 消息长度是否过长 */ + if (pMQ->pMQMsg[pMQ->front].msgSize > *pBufSize) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 从front位读出消息*/ + (void)CM_Memcpy((void*)pOutBuf, (CM_SIZE_T) *pBufSize, ((const void*)(pMQ->pMQMsg[pMQ->front].pMsgBuf)), ((CM_SIZE_T)(pMQ->pMQMsg[pMQ->front].msgSize))); + *pBufSize = pMQ->pMQMsg[pMQ->front].msgSize; + + /*- 清空已读消息内容的接口*/ + rt = CM_Memset(((void*)(pMQ->pMQMsg[pMQ->front].pMsgBuf)), (CM_UINT8)0U, ((CM_SIZE_T)(pMQ->maxMsgSize)), ((CM_SIZE_T)(pMQ->maxMsgSize))); + pMQ->pMQMsg[pMQ->front].msgSize = 0U; + + /*- 更新队列状态 */ + pMQ->front = (pMQ->front + 1) % (CM_INT32)pMQ->maxMsgNum;/*front前进一步*/ + --(pMQ->msgNum); + } + } + + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 消息队列查询(仅读取而不弹出) +* @param pMQ 要读的消息队列 +* @param index 要读取的消息序号 +* @param pOutBuf 要输出消息的缓冲区 +* @param pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Light_Get(IN const CM_MQ_Light_Struct_T* pMQ, IN CM_UINT16 index, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (NULL == pOutBuf) || (NULL == pBufSize) + || (index >= pMQ->msgNum) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 要读取的消息长度是否过长 */ + if (pMQ->pMQMsg[(pMQ->front + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].msgSize > *pBufSize) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 输出要读取的消息 */ + (void)CM_Memcpy((void*)pOutBuf, (CM_SIZE_T) *pBufSize, ((const void*)(pMQ->pMQMsg[(pMQ->front + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].pMsgBuf)), + ((CM_SIZE_T)(pMQ->pMQMsg[(pMQ->front + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].msgSize))); + *pBufSize = pMQ->pMQMsg[(pMQ->front + (CM_INT32)index) % (CM_INT32)pMQ->maxMsgNum].msgSize; + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 写消息队列 +* @param pMQ 要写的消息队列 +* @param pMsgBuf 要写的消息 +* @param BufSize 要写的消息大小 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Light_Write(INOUT CM_MQ_Light_Struct_T* pMQ, IN const CM_UINT8* pMsgBuf, IN CM_UINT16 BufSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT16 temp = 0U; + + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (NULL == pMsgBuf) || (BufSize > pMQ->maxMsgSize) || (BufSize == 0U) + || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 找到待写入位置 */ + temp = pMQ->maxMsgNum - (CM_UINT16)1u;/*计算temp*/ + /*- 消息队列是否已满*/ + if (temp == pMQ->msgNum)/*如果当前消息数=max-1 表示满了*/ + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 在队尾写入消息 */ + (void)CM_Memcpy(((void*)(pMQ->pMQMsg[pMQ->rear].pMsgBuf)), (CM_SIZE_T)(pMQ->maxMsgSize), (const void*)pMsgBuf, (size_t)BufSize);/*复制消息进入rear位*/ + pMQ->pMQMsg[pMQ->rear].msgSize = BufSize; + + /*- 更新队尾指针和消息总数 */ + pMQ->rear = (pMQ->rear + 1) % (CM_INT32)pMQ->maxMsgNum;/*rear前进一步*/ + ++(pMQ->msgNum);/*当前消息数++*/ + + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 消息队列初始化 +* @param pMQ 要初始化的消息队列 +* @param maxMsgNum 消息队列大小 +* @param maxMsgSize 每条消息的大小 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Light_Init(INOUT CM_MQ_Light_Struct_T* pMQ, IN CM_UINT16 maxMsgNum, IN CM_UINT16 maxMsgSize) +{ + /*- 变量初始化 */ + CM_UINT16 i = 0U; + CM_INT16 j = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + ENUM_CM_RETURN errorFlag = ENUM_CM_TRUE; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (0U == maxMsgNum) || (0U == maxMsgSize) + || ((CM_UINT16)CM_MQ_LIGHT_MSG_NUM_MAX < maxMsgNum) || ((CM_UINT16)CM_MQ_LIGHT_MSG_SIZE_MAX < maxMsgSize)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + /*- 消息队列是否已经初始化过 */ + else if (CM_TRUE == pMQ->initialized) + { + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 初始化消息队列为空 */ + pMQ->pMQMsg = NULL; + + pMQ->msgNum = (CM_UINT16)0u; + pMQ->front = 0; + pMQ->rear = 0; + pMQ->maxMsgNum = maxMsgNum + 1U;/*改为maxMsgNum+1,使用户可以初始最大数与可放最大数相等*/ + pMQ->maxMsgSize = maxMsgSize; + /*- 为消息队列分配内存 */ + pMQ->pMQMsg = (CM_MQ_Light_Msg_Struct_T*)CM_Malloc(sizeof(CM_MQ_Light_Msg_Struct_T) * pMQ->maxMsgNum); + + /*- 内存分配是否失败 */ + if (NULL == pMQ->pMQMsg) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + /*- @alias 逐条消息划分内存 */ + for (i = (CM_UINT16)0u; i < pMQ->maxMsgNum; ++i) + { + pMQ->pMQMsg[i].pMsgBuf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)(pMQ->maxMsgSize)); + + /** @brief 如果初始化失败,则释放之前分配的资源 */ + + if (NULL == pMQ->pMQMsg[i].pMsgBuf) + { + for (j = (CM_INT16)i - (CM_INT16)1; j >= (CM_INT16)0; --j) + { + CM_Free(((void*)(pMQ->pMQMsg[j].pMsgBuf))); + pMQ->pMQMsg[j].pMsgBuf = NULL; + } + + CM_Free((void*)(pMQ->pMQMsg)); + + pMQ->pMQMsg = NULL; /* parasoft-suppress BD-RES-LEAKS "误报" */ + rt = ENUM_CM_FALSE; + /*- 跳出 */ + break; + } + else + { + pMQ->pMQMsg[i].msgSize = (CM_UINT16)0u; + rt = CM_Memset(((void*)(pMQ->pMQMsg[i].pMsgBuf)), (CM_UINT8)0U, ((size_t)(pMQ->maxMsgSize)), ((size_t)(pMQ->maxMsgSize))); + if(ENUM_CM_FALSE == rt) + { + errorFlag = ENUM_CM_FALSE; + } + } + } + /*- 消息队列初始化成功 */ + pMQ->initialized = CM_TRUE; + if(ENUM_CM_FALSE == errorFlag) + { + rt = ENUM_CM_FALSE; + } + else + { + /*- 无处理 */ + } + } + } + /*- 返回执行结果 */ + return rt; +} + +/** +* @brief 清空消息队列 +* @param pMQ 要清空的消息队列 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Light_Clear(INOUT CM_MQ_Light_Struct_T* pMQ) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 消息队列置为空 */ + pMQ->msgNum = (CM_UINT16)0u; + pMQ->front = 0; + pMQ->rear = 0; + /*- 函数执行成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 获取消息队列中的消息条数 +* @param pMQ 要获得消息个数的消息队列 +* @return CM_INT32 若失败则返回-1,否则返回消息个数 +*/ +CM_INT32 CM_MQ_Light_Get_Msg_Num(IN const CM_MQ_Light_Struct_T* pMQ) +{ + /*- 变量初始化 */ + CM_INT32 rt = -1; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 返回-1 */ + rt = -1; + } + else + { + /*- 返回消息条数 */ + rt = (CM_INT32)(pMQ->msgNum); + } + /*- 返回 */ + return rt; +} + +/** +* @brief 清零消息队列 +* @param pMQ 要清零的消息队列 +* @return 执行结果 +* - ENUM_CM_TRUE 执行成功 +* - ENUM_CM_FALSE 执行失败 +*/ +ENUM_CM_RETURN CM_MQ_Light_Flush(INOUT CM_MQ_Light_Struct_T* pMQ) +{ + /*- 变量初始化 */ + CM_UINT16 msgIndex = 0U; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + ENUM_CM_RETURN errorFlag = ENUM_CM_TRUE; + /*- 入口参数是否非法 */ + if ((NULL == pMQ) || (CM_TRUE != pMQ->initialized)) + { + /*- 函数执行失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- @alias 将所有消息的消息内容清零 */ + for (msgIndex = 0u; msgIndex < (pMQ->maxMsgNum); ++msgIndex) + { + pMQ->pMQMsg[msgIndex].msgSize = 0u; + rt = CM_Memset(((void*)(pMQ->pMQMsg[msgIndex].pMsgBuf)), (CM_UINT8)0u, (size_t)(pMQ->maxMsgSize), (size_t)(pMQ->maxMsgSize)); + if(ENUM_CM_FALSE == rt) + { + errorFlag = ENUM_CM_FALSE; + } + } + + /*- 消息队列置为空 */ + pMQ->front = 0; + pMQ->rear = 0; + pMQ->msgNum = (CM_UINT16)0u; + /*- 函数执行成功 */ + if(ENUM_CM_FALSE == errorFlag) + { + rt = ENUM_CM_FALSE; + } + else + { + rt = ENUM_CM_TRUE; + } + } + /*- 返回执行结果 */ + return rt; +} diff --git a/TSCP/src/MSCP/CM/CM_MQ_Light.h b/TSCP/src/MSCP/CM/CM_MQ_Light.h new file mode 100644 index 0000000..9b5f13a --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MQ_Light.h @@ -0,0 +1,122 @@ +/** +* @file CM_MQ_LIGHT.h +* @brief 实现轻型(非线程安全)消息队列的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CM_MQ_LIGHT_H +#define CM_MQ_LIGHT_H + +#include "CM_Memory.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + + /** 轻型消息 */ + typedef struct + { + CM_UINT16 msgSize; /**< 消息长度 */ + CM_UINT8* pMsgBuf; /**< 消息数组 */ + }CM_MQ_Light_Msg_Struct_T; + + /** 轻型消息队列 */ + typedef struct + { + CM_BOOL initialized; /**< 是否初始化了 */ + CM_UINT16 maxMsgNum; /**< MQ中最大消息个数 */ + CM_UINT16 maxMsgSize; /**< 每条消息的最大字节数 */ + CM_INT32 front; /**< 头指针 */ + CM_INT32 rear; /**< 尾指针 */ + CM_UINT16 msgNum; /**< 消息队列中消息个数 */ + CM_MQ_Light_Msg_Struct_T* pMQMsg; /**< 指向第一条消息 */ + }CM_MQ_Light_Struct_T; + + /** + * @brief CM_MQ_Light_Init + * + * Detailed description. + * @param[in] pMQ 要初始化的消息队列 + * @param[in] maxMsgNum 消息队列大小 + * @param[in] maxMsgSize 每条消息的大小 + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_MQ_Light_Init(INOUT CM_MQ_Light_Struct_T* pMQ, IN CM_UINT16 maxMsgNum, IN CM_UINT16 maxMsgSize); + + /** + * @brief CM_MQ_Light_Get_Msg_Num + * + * Detailed description. + * @param[in] pMQ 要获得消息个数的消息队列 + * @return CM_INT32 若失败则返回-1,否则返回消息个数 + */ + CM_INT32 CM_MQ_Light_Get_Msg_Num(IN const CM_MQ_Light_Struct_T* pMQ); + + /** + * @brief CM_MQ_Light_Write + * + * Detailed description. + * @param[in] pMQ 要写的消息队列 + * @param[in] pMsgBuf 要写的消息 + * @param[in] size 要写的消息大小 + * @return CM_MQ_Light_Write_Result_Enum + */ + ENUM_CM_RETURN CM_MQ_Light_Write(INOUT CM_MQ_Light_Struct_T* pMQ, IN const CM_UINT8* pMsgBuf, IN CM_UINT16 BufSize); + + /** + * @brief CM_MQ_Light_Read + * + * Detailed description. + * @param[in] pMQ 要读的消息队列 + * @param[in] pOutBuf 要输出消息的缓冲区 + * @param[in/out] pSize 作为输入参数时为输出的缓冲区消息大小,作为输出参数为读到的消息大小 + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_MQ_Light_Read(INOUT CM_MQ_Light_Struct_T* pMQ, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize); + + /** + * @brief CM_MQ_Light_Get + * + * 仅读取数据,而不弹出. + * @param[in] pMQ + * @param[in] index + * @param[in] pOutBuf + * @param[in] pSize + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_MQ_Light_Get(IN const CM_MQ_Light_Struct_T* pMQ, IN CM_UINT16 index, OUT CM_UINT8* pOutBuf, INOUT CM_UINT16* pBufSize); + + /** + * @brief CM_MQ_Light_Clear + * + * Detailed description. + * @param[in] pMQ 要清空的消息队列 + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_MQ_Light_Clear(INOUT CM_MQ_Light_Struct_T* pMQ); + + /** + * @brief CM_MQ_Flush + * + * Detailed description. + * @param[in] pMQ 要清零的消息队列 + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_MQ_Light_Flush(INOUT CM_MQ_Light_Struct_T* pMQ); + + +#ifdef __cplusplus +} + +#endif /**< __cplusplus */ + +#endif /**< _CM_MQ_LIGHT_H */ + diff --git a/TSCP/src/MSCP/CM/CM_Memory.c b/TSCP/src/MSCP/CM/CM_Memory.c new file mode 100644 index 0000000..f5e2ff9 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Memory.c @@ -0,0 +1,173 @@ +/** +* @file CM_Memory.c +* @brief 实现了内存操作的的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Memory.h" +#include "PFM_Log.h" +/** +* @brief 用指定值填充内存 +* @param destination 待填充的内存区 +* @param value 填充值 +* @param len 设置的字节数 +* @param destSize 内存区大小 +* @return 执行结果 +* ENUM_CM_TRUE 成功 +* ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Memset(OUT void * destination, IN CM_UINT8 value, IN CM_SIZE_T len, IN CM_SIZE_T destSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + + if((NULL != destination) && (len <= destSize)) + { + (void)memset(destination, (int)value, len); + ret = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("CM_Memset Failed Key Point!!! destSize=%lu,len=%lu\n",destSize,len); + ret = ENUM_CM_FALSE; + } + + return ret; +} + +/** +* @brief 动态分配内存 +* @param len 要分配的大小 +* @return 新分配内存的首地址 +*/ +void* CM_Malloc(IN CM_SIZE_T len) +{ + void* p = NULL; /*指针*/ + /*- 内存首地址初始化为空 */ + + /*- 要分配的空间是否为0 */ + if (len != (CM_SIZE_T)0) + { + /*- 分配内存空间 */ + p = malloc(len); + } + else + { + /*- 无处理 */ + } + /*- 返回内存首地址 */ + return p; +} + +/** +* @brief 动态释放内存 +* @param p 内存指针 +*/ +void CM_Free(INOUT void * p) +{ + /*- 指针是否为空 */ + if (NULL != p) + { + /*- 释放内存 */ + free(p); + } + else + { + /*- 无处理 */ + } +} + +/** +* @brief 内存复制 +* @param destination 目的地址 +* @param destSize 目的地址大小 +* @param source 源地址 +* @param count 复制数据大小 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details 源地址段和目的地址段不能有重叠 +*/ +ENUM_CM_RETURN CM_Memcpy(OUT void * destination, IN CM_SIZE_T destSize, IN const void * source, IN CM_SIZE_T count) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + if(destSize >= count) + { + (void)memcpy(destination, source, count); + ret = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("CM_Memcpy Failed Key Point!!! destSize=%lu,count=%lu\n",destSize,count); + ret = ENUM_CM_FALSE; + } + /*- 返回执行结果 */ + return ret; +} + +/** +* @brief 内存复制 +* @param destination 目的地址 +* @param destSize 目的地址大小 +* @param source 源地址 +* @param count 复制数据大小 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details 源地址段和目的地址段可以有重叠 +*/ +ENUM_CM_RETURN CM_Memmove(OUT void * destination, IN CM_SIZE_T destSize, IN const void * source, IN CM_SIZE_T count) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + if(destSize >= count) + { + (void)memmove(destination, source, count); + ret = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("CM_Memmove Failed Key Point!!! destSize=%lu,count=%lu\n",destSize,count); + ret = ENUM_CM_FALSE; + } + /*- 返回执行结果 */ + return ret; +} + +/** +* @brief 内存比较 +* @param pBufA 首地址A +* @param pBufB 首地址B +* @param len 比较长度 +* @return 执行结果 +* - 0 全部相同 +* - 非0 不全同 +*/ +CM_INT32 CM_Memcmp(IN const void * pBufA,IN const void * pBufB,IN CM_SIZE_T len) +{ + /*- 变量初始化 */ + CM_INT32 ret = 1; /* 函数返回值 */ + /*- 输入检查是否不通过 */ + if ((pBufA == NULL) || (pBufB == NULL)) + { + /*- 比较结果为不相同 */ + MSCP_LOG_MSG("CM_Memcmp Failed Key Point!!! \n"); + ret = (CM_INT32)1; + } + else + { + ret = memcmp(pBufA, pBufB, len); + } + /*- 输出返回值 */ + return ret; +} + diff --git a/TSCP/src/MSCP/CM/CM_Memory.h b/TSCP/src/MSCP/CM/CM_Memory.h new file mode 100644 index 0000000..ac4f152 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Memory.h @@ -0,0 +1,50 @@ +/** +* @file CM_Memory.h +* @brief 实现了内存操作的的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ + +#ifndef CM_MEMORY_H_ +#define CM_MEMORY_H_ + +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* 内存填充 */ + ENUM_CM_RETURN CM_Memset(OUT void * destination, IN CM_UINT8 value, IN CM_SIZE_T len, IN CM_SIZE_T destSize); + + /* 内存分配 */ + void* CM_Malloc(IN CM_SIZE_T len); + + /* 内存释放 */ + void CM_Free(INOUT void* p); + + /* 内存复制 */ + ENUM_CM_RETURN CM_Memcpy(OUT void * destination, IN CM_SIZE_T destSize, IN const void * source, IN CM_SIZE_T count); + + /* 内存复制,源地址段和目的地址段可以有重叠 */ + ENUM_CM_RETURN CM_Memmove(OUT void * destination, IN CM_SIZE_T destSize, IN const void * source, IN CM_SIZE_T count); + + /* 内存比较 */ + CM_INT32 CM_Memcmp(IN const void* pBufA, IN const void* pBufB, IN CM_SIZE_T len); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/MSCP/CM/CM_MultiThread.h b/TSCP/src/MSCP/CM/CM_MultiThread.h new file mode 100644 index 0000000..2927a56 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MultiThread.h @@ -0,0 +1,85 @@ +/** +* @file CM_MultiThread.h +* @brief 实现了线程操作的的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#ifndef CM_MULTITHREAD_H +#define CM_MULTITHREAD_H + +#include "CM_MultiThread_Priority.h" + +#ifdef WIN32 +#include +#endif + +#ifdef VXWORKS +#include +#endif + +#ifdef QNX +#include +#include +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + + + /** 线程函数原型定义 */ +#define CM_THREAD_RETRUN static CM_THREAD_FUNC_RETURN CM_THREAD_CALL + + + + /** 任务入口参数结构体 */ + typedef struct + { + int args0; /**< 参数0 */ + int args1; /**< 参数1 */ + int args2; /**< 参数2 */ + int args3; /**< 参数3 */ + int args4; /**< 参数4 */ + int args5; /**< 参数5 */ + int args6; /**< 参数6 */ + int args7; /**< 参数7 */ + int args8; /**< 参数8 */ + int args9; /**< 参数9 */ + }CM_Thread_Arg_Struct_T; + + /** + * @brief CM_Thread_Create + * @details 创建线程 + * @param[out] thread 线程句柄(若为NULL则不输出线程句柄) + * @param[in] myfunc 线程函数 + * @param[in] threadName 线程名(仅VxWorks用到) + * @param[in] stackSize 线程堆栈大小(VxWorks和Windows可用) + * @param[in] priority 优先级(VxWorks和Windows可用) CM_TASK_PRIORITY_0 到 CM_TASK_PRIORITY_99 + * @param[in] args 参数 + * @return CM_BOOL + */ + CM_BOOL CM_Thread_Create(OUT CM_THREAD_T* thread, IN CM_THREAD_FUNC_T myfunc, IN const CM_CHAR* threadName, IN CM_INT32 stackSize, IN CM_INT32 priority, IN CM_Thread_Arg_Struct_T* args); + + /** + * @brief CM_Thread_Self + * @details 返回当前线程ID + * @return CM_THREAD_T + */ + CM_THREAD_T CM_Thread_Self(void); + +#ifdef __cplusplus +} + +#endif /**< __cplusplus */ + +#endif /**< _CM_MULTITHREAD_H */ + diff --git a/TSCP/src/MSCP/CM/CM_MultiThread_Priority.h b/TSCP/src/MSCP/CM/CM_MultiThread_Priority.h new file mode 100644 index 0000000..5dfbda2 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MultiThread_Priority.h @@ -0,0 +1,341 @@ +/** +* @file CM_MultiThread_Priority.h +* @brief 实现了线程操作的的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#ifndef CM_MULTITHREAD_PRIORITY_H +#define CM_MULTITHREAD_PRIORITY_H + +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + + /** 线程优先级定义 */ +#ifdef WIN32 +#define CM_TASK_PRIORITY_0 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_1 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_2 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_3 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_4 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_5 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_6 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_7 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_8 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_9 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_10 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_11 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_12 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_13 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_14 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_15 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_16 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_17 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_18 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_19 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_20 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_21 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_22 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_23 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_24 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_25 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_26 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_27 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_28 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_29 (THREAD_PRIORITY_HIGHEST) +#define CM_TASK_PRIORITY_30 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_31 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_32 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_33 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_34 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_35 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_36 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_37 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_38 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_39 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_40 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_41 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_42 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_43 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_44 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_45 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_46 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_47 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_48 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_49 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_50 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_51 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_52 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_53 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_54 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_55 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_56 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_57 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_58 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_59 (THREAD_PRIORITY_ABOVE_NORMAL) +#define CM_TASK_PRIORITY_60 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_61 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_62 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_63 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_64 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_65 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_66 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_67 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_68 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_69 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_70 (THREAD_PRIORITY_NORMAL) +#define CM_TASK_PRIORITY_71 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_72 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_73 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_74 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_75 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_76 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_77 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_78 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_79 (THREAD_PRIORITY_BELOW_NORMAL) +#define CM_TASK_PRIORITY_80 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_81 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_82 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_83 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_84 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_85 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_86 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_87 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_88 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_89 (THREAD_PRIORITY_LOWEST) +#define CM_TASK_PRIORITY_90 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_91 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_92 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_93 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_94 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_95 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_96 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_97 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_98 (THREAD_PRIORITY_IDLE) +#define CM_TASK_PRIORITY_99 (THREAD_PRIORITY_IDLE) +#endif + +#ifdef QNX +#define CM_TASK_PRIORITY_0 63 +#define CM_TASK_PRIORITY_1 63 +#define CM_TASK_PRIORITY_2 63 +#define CM_TASK_PRIORITY_3 63 +#define CM_TASK_PRIORITY_4 63 +#define CM_TASK_PRIORITY_5 63 +#define CM_TASK_PRIORITY_6 63 +#define CM_TASK_PRIORITY_7 63 +#define CM_TASK_PRIORITY_8 63 +#define CM_TASK_PRIORITY_9 63 +#define CM_TASK_PRIORITY_10 63 +#define CM_TASK_PRIORITY_11 63 +#define CM_TASK_PRIORITY_12 63 +#define CM_TASK_PRIORITY_13 63 +#define CM_TASK_PRIORITY_14 63 +#define CM_TASK_PRIORITY_15 63 +#define CM_TASK_PRIORITY_16 63 +#define CM_TASK_PRIORITY_17 63 +#define CM_TASK_PRIORITY_18 63 +#define CM_TASK_PRIORITY_19 63 +#define CM_TASK_PRIORITY_20 63 +#define CM_TASK_PRIORITY_21 63 +#define CM_TASK_PRIORITY_22 63 +#define CM_TASK_PRIORITY_23 63 +#define CM_TASK_PRIORITY_24 63 +#define CM_TASK_PRIORITY_25 63 +#define CM_TASK_PRIORITY_26 63 +#define CM_TASK_PRIORITY_27 63 +#define CM_TASK_PRIORITY_28 63 +#define CM_TASK_PRIORITY_29 63 +#define CM_TASK_PRIORITY_30 63 +#define CM_TASK_PRIORITY_31 63 +#define CM_TASK_PRIORITY_32 63 +#define CM_TASK_PRIORITY_33 63 +#define CM_TASK_PRIORITY_34 63 +#define CM_TASK_PRIORITY_35 63 +#define CM_TASK_PRIORITY_36 63 +#define CM_TASK_PRIORITY_37 62 +#define CM_TASK_PRIORITY_38 61 +#define CM_TASK_PRIORITY_39 60 +#define CM_TASK_PRIORITY_40 59 +#define CM_TASK_PRIORITY_41 58 +#define CM_TASK_PRIORITY_42 57 +#define CM_TASK_PRIORITY_43 56 +#define CM_TASK_PRIORITY_44 55 +#define CM_TASK_PRIORITY_45 54 +#define CM_TASK_PRIORITY_46 53 +#define CM_TASK_PRIORITY_47 52 +#define CM_TASK_PRIORITY_48 51 +#define CM_TASK_PRIORITY_49 50 +#define CM_TASK_PRIORITY_50 49 +#define CM_TASK_PRIORITY_51 48 +#define CM_TASK_PRIORITY_52 47 +#define CM_TASK_PRIORITY_53 46 +#define CM_TASK_PRIORITY_54 45 +#define CM_TASK_PRIORITY_55 44 +#define CM_TASK_PRIORITY_56 43 +#define CM_TASK_PRIORITY_57 42 +#define CM_TASK_PRIORITY_58 41 +#define CM_TASK_PRIORITY_59 40 +#define CM_TASK_PRIORITY_60 39 +#define CM_TASK_PRIORITY_61 38 +#define CM_TASK_PRIORITY_62 37 +#define CM_TASK_PRIORITY_63 36 +#define CM_TASK_PRIORITY_64 35 +#define CM_TASK_PRIORITY_65 34 +#define CM_TASK_PRIORITY_66 33 +#define CM_TASK_PRIORITY_67 32 +#define CM_TASK_PRIORITY_68 31 +#define CM_TASK_PRIORITY_69 30 +#define CM_TASK_PRIORITY_70 29 +#define CM_TASK_PRIORITY_71 28 +#define CM_TASK_PRIORITY_72 27 +#define CM_TASK_PRIORITY_73 26 +#define CM_TASK_PRIORITY_74 25 +#define CM_TASK_PRIORITY_75 24 +#define CM_TASK_PRIORITY_76 23 +#define CM_TASK_PRIORITY_77 22 +#define CM_TASK_PRIORITY_78 21 +#define CM_TASK_PRIORITY_79 20 +#define CM_TASK_PRIORITY_80 19 +#define CM_TASK_PRIORITY_81 18 +#define CM_TASK_PRIORITY_82 17 +#define CM_TASK_PRIORITY_83 16 +#define CM_TASK_PRIORITY_84 15 +#define CM_TASK_PRIORITY_85 14 +#define CM_TASK_PRIORITY_86 13 +#define CM_TASK_PRIORITY_87 12 +#define CM_TASK_PRIORITY_88 11 +#define CM_TASK_PRIORITY_89 10 +#define CM_TASK_PRIORITY_90 9 +#define CM_TASK_PRIORITY_91 8 +#define CM_TASK_PRIORITY_92 7 +#define CM_TASK_PRIORITY_93 6 +#define CM_TASK_PRIORITY_94 5 +#define CM_TASK_PRIORITY_95 4 +#define CM_TASK_PRIORITY_96 3 +#define CM_TASK_PRIORITY_97 2 +#define CM_TASK_PRIORITY_98 1 +#define CM_TASK_PRIORITY_99 0 +#endif + +#ifdef VXWORKS +#define CM_TASK_PRIORITY_0 0 +#define CM_TASK_PRIORITY_1 1 +#define CM_TASK_PRIORITY_2 2 +#define CM_TASK_PRIORITY_3 3 +#define CM_TASK_PRIORITY_4 4 +#define CM_TASK_PRIORITY_5 5 +#define CM_TASK_PRIORITY_6 6 +#define CM_TASK_PRIORITY_7 7 +#define CM_TASK_PRIORITY_8 8 +#define CM_TASK_PRIORITY_9 9 +#define CM_TASK_PRIORITY_10 10 +#define CM_TASK_PRIORITY_11 11 +#define CM_TASK_PRIORITY_12 12 +#define CM_TASK_PRIORITY_13 13 +#define CM_TASK_PRIORITY_14 14 +#define CM_TASK_PRIORITY_15 15 +#define CM_TASK_PRIORITY_16 16 +#define CM_TASK_PRIORITY_17 17 +#define CM_TASK_PRIORITY_18 18 +#define CM_TASK_PRIORITY_19 19 +#define CM_TASK_PRIORITY_20 20 +#define CM_TASK_PRIORITY_21 21 +#define CM_TASK_PRIORITY_22 22 +#define CM_TASK_PRIORITY_23 23 +#define CM_TASK_PRIORITY_24 24 +#define CM_TASK_PRIORITY_25 25 +#define CM_TASK_PRIORITY_26 26 +#define CM_TASK_PRIORITY_27 27 +#define CM_TASK_PRIORITY_28 28 +#define CM_TASK_PRIORITY_29 29 +#define CM_TASK_PRIORITY_30 30 +#define CM_TASK_PRIORITY_31 31 +#define CM_TASK_PRIORITY_32 32 +#define CM_TASK_PRIORITY_33 33 +#define CM_TASK_PRIORITY_34 34 +#define CM_TASK_PRIORITY_35 35 +#define CM_TASK_PRIORITY_36 36 +#define CM_TASK_PRIORITY_37 37 +#define CM_TASK_PRIORITY_38 38 +#define CM_TASK_PRIORITY_39 39 +#define CM_TASK_PRIORITY_40 40 +#define CM_TASK_PRIORITY_41 41 +#define CM_TASK_PRIORITY_42 42 +#define CM_TASK_PRIORITY_43 43 +#define CM_TASK_PRIORITY_44 44 +#define CM_TASK_PRIORITY_45 45 +#define CM_TASK_PRIORITY_46 46 +#define CM_TASK_PRIORITY_47 47 +#define CM_TASK_PRIORITY_48 48 +#define CM_TASK_PRIORITY_49 49 +#define CM_TASK_PRIORITY_50 50 +#define CM_TASK_PRIORITY_51 51 +#define CM_TASK_PRIORITY_52 52 +#define CM_TASK_PRIORITY_53 53 +#define CM_TASK_PRIORITY_54 54 +#define CM_TASK_PRIORITY_55 55 +#define CM_TASK_PRIORITY_56 56 +#define CM_TASK_PRIORITY_57 57 +#define CM_TASK_PRIORITY_58 58 +#define CM_TASK_PRIORITY_59 59 +#define CM_TASK_PRIORITY_60 60 +#define CM_TASK_PRIORITY_61 61 +#define CM_TASK_PRIORITY_62 62 +#define CM_TASK_PRIORITY_63 63 +#define CM_TASK_PRIORITY_64 64 +#define CM_TASK_PRIORITY_65 65 +#define CM_TASK_PRIORITY_66 66 +#define CM_TASK_PRIORITY_67 67 +#define CM_TASK_PRIORITY_68 68 +#define CM_TASK_PRIORITY_69 69 +#define CM_TASK_PRIORITY_70 70 +#define CM_TASK_PRIORITY_71 71 +#define CM_TASK_PRIORITY_72 72 +#define CM_TASK_PRIORITY_73 73 +#define CM_TASK_PRIORITY_74 74 +#define CM_TASK_PRIORITY_75 75 +#define CM_TASK_PRIORITY_76 76 +#define CM_TASK_PRIORITY_77 77 +#define CM_TASK_PRIORITY_78 78 +#define CM_TASK_PRIORITY_79 79 +#define CM_TASK_PRIORITY_80 80 +#define CM_TASK_PRIORITY_81 81 +#define CM_TASK_PRIORITY_82 82 +#define CM_TASK_PRIORITY_83 83 +#define CM_TASK_PRIORITY_84 84 +#define CM_TASK_PRIORITY_85 85 +#define CM_TASK_PRIORITY_86 86 +#define CM_TASK_PRIORITY_87 87 +#define CM_TASK_PRIORITY_88 88 +#define CM_TASK_PRIORITY_89 89 +#define CM_TASK_PRIORITY_90 90 +#define CM_TASK_PRIORITY_91 91 +#define CM_TASK_PRIORITY_92 92 +#define CM_TASK_PRIORITY_93 93 +#define CM_TASK_PRIORITY_94 94 +#define CM_TASK_PRIORITY_95 95 +#define CM_TASK_PRIORITY_96 96 +#define CM_TASK_PRIORITY_97 97 +#define CM_TASK_PRIORITY_98 98 +#define CM_TASK_PRIORITY_99 99 +#endif + +#ifdef __cplusplus +} + +#endif /**< __cplusplus */ + +#endif /**< _CM_MULTITHREAD_PRIORITY_H */ + diff --git a/TSCP/src/MSCP/CM/CM_MultiThread_qnx.c b/TSCP/src/MSCP/CM/CM_MultiThread_qnx.c new file mode 100644 index 0000000..467f9d0 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MultiThread_qnx.c @@ -0,0 +1,123 @@ +/** +* @file CM_MultiThread.c +* @brief 实现了线程操作的的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_MultiThread.h" + +#ifdef QNX +/* +* @brief 创建线程 +* @param thread 线程ID +* @param myfunc 线程执行函数 +* @param threadName 线程名称 +* @param stackSize 线程堆栈大小 +* @param priority 线程优先级 +* @param pargs 线程输入参数 +* @return 执行结果 +* - CM_TRUE 成功 +* - CM_FALSE 失败 +*/ +CM_BOOL CM_Thread_Create(OUT CM_THREAD_T* thread, IN CM_THREAD_FUNC_T myfunc, IN const CM_CHAR* threadName, IN CM_INT32 stackSize, IN CM_INT32 priority, IN CM_Thread_Arg_Struct_T* args) +{ + /*- 变量初始化 */ + CM_THREAD_T tmpThread = 0; /* 线程ID */ + CM_THREAD_T rt = -1; /* 函数返回值 */ + pthread_attr_t attr = { 0 }; /* 线程属性 */ + struct sched_param params; /* 线程调度参数 */ + /*- 输入参数是否合法 */ + if ((priority <= CM_TASK_PRIORITY_1) && (priority >= CM_TASK_PRIORITY_99) && (stackSize >= 0)) + { + /*- 配置线程属性 */ + (void)pthread_attr_init(&attr); + rt = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + /*- 是否成功配置线程属性 */ + if (rt == 0) + { + /*- 设置线程优先级 */ + params.sched_priority = priority; + rt = pthread_attr_setschedparam(&attr, ¶ms); + /*- 是否成功设置线程优先级 */ + if (rt == 0) + { + /*- @alias 设置线程堆栈 */ + if (stackSize > 0) + { + rt = pthread_attr_setstacksize(&attr, (size_t)stackSize); + } + else + { + /* 无处理 */ + } + /*- 是否成功设置线程堆栈*/ + if (rt == 0) + { + /*- @alias 创建线程 */ + if (NULL == thread) + { + rt = pthread_create(&tmpThread, &attr, (CM_THREAD_FUNC_T)myfunc, args); + (void)pthread_setname_np(tmpThread, threadName); + } + else + { + rt = pthread_create(thread, &attr, (CM_THREAD_FUNC_T)myfunc, args); + (void)pthread_setname_np(*thread, threadName); + } + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + (void)pthread_attr_destroy(&attr); + } + else + { + /*- 无处理 */ + } + + /*- @alias 判断执行结果 */ + if (0 == rt) + { + rt = CM_TRUE; + } + else + { + rt = CM_FALSE; + } + /*- 返回执行结果 */ + return rt; +} +/* +* @brief 获取当前线程ID +* @return 线程ID +*/ +CM_THREAD_T CM_Thread_Self(void) +{ + /*- 获取当前线程ID */ + CM_THREAD_T rt = pthread_self(); + /*- 返回线程ID */ + return rt; +} +#endif + + + diff --git a/TSCP/src/MSCP/CM/CM_MultiThread_vxworks.c b/TSCP/src/MSCP/CM/CM_MultiThread_vxworks.c new file mode 100644 index 0000000..8567bd4 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MultiThread_vxworks.c @@ -0,0 +1,90 @@ +/** +* @file CM_MultiThread.c +* @brief 实现了线程操作的的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_MultiThread.h" + +#ifdef VXWORKS +/* +* @brief 创建线程 +* @param thread 线程ID +* @param myfunc 线程执行函数 +* @param threadName 线程名称 +* @param stackSize 线程堆栈大小 +* @param priority 线程优先级 +* @param pargs 线程输入参数 +* @return 执行结果 +* - CM_TRUE 成功 +* - CM_FALSE 失败 +*/ +CM_BOOL CM_Thread_Create(OUT CM_THREAD_T* thread, IN CM_THREAD_FUNC_T myfunc, IN const CM_CHAR* threadName, IN CM_INT32 stackSize, IN CM_INT32 priority, IN CM_Thread_Arg_Struct_T * pargs) +{/*传入的参数指针 不能赋值给局部变量*/ + CM_THREAD_T tmpThread = ERROR; /* 线程ID */ + CM_BOOL rt = CM_FALSE; /* 函数返回值 */ + + /*- 检查输入参数是否非法 */ + if ((priority > CM_TASK_PRIORITY_99) || (priority < CM_TASK_PRIORITY_0) || (stackSize <= 0)) + { + /*- 无操作 */ + } + else + { + + /*- 线程参数是否非空 */ + if (NULL != pargs) + { + /*- 带参数创建线程 */ + tmpThread = taskSpawn((char *)threadName, priority, VX_FP_TASK, stackSize, (FUNCPTR)myfunc, + pargs->args0, pargs->args1, pargs->args2, pargs->args3, pargs->args4, + pargs->args5, pargs->args6, pargs->args7, pargs->args8, pargs->args9); + } + else + { + /*- 按参数为0创建线程 */ + tmpThread = taskSpawn((char *)threadName, priority, VX_FP_TASK, stackSize, (FUNCPTR)myfunc, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + + /*- @alias 输出线程ID */ + if (thread != NULL) + {/*给指针赋值,修改0223bug,*/ + *thread = tmpThread; + } + } + + /*- @alias 判断执行结果 */ + if (ERROR == tmpThread) + { + rt = CM_FALSE; + } + else + { + rt = CM_TRUE; + } + /*- 返回执行结果 */ + return rt; +} +/* +* @brief 获取当前线程ID +* @return 线程ID +*/ +CM_THREAD_T CM_Thread_Self(void) +{ + /*- 获取当前线程ID */ + CM_THREAD_T td = taskIdSelf(); + /*- 返回线程ID */ + return td; +} +#endif + + diff --git a/TSCP/src/MSCP/CM/CM_MultiThread_windows.c b/TSCP/src/MSCP/CM/CM_MultiThread_windows.c new file mode 100644 index 0000000..89bb35c --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_MultiThread_windows.c @@ -0,0 +1,73 @@ +/** +* @file CM_MultiThread.c +* @brief 实现了线程操作的的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_MultiThread.h" + +#ifdef WIN32 +/** +* @brief 创建线程 +* @param thread 线程ID +* @param myfunc 线程执行函数 +* @param threadName 线程名称 +* @param stackSize 线程堆栈大小 +* @param priority 线程优先级 +* @param pargs 线程输入参数 +* @return 执行结果 +* - CM_TRUE 成功 +* - CM_FALSE 失败 +*/ +CM_BOOL CM_Thread_Create(OUT CM_THREAD_T* thread, IN CM_THREAD_FUNC_T myfunc,IN const CM_CHAR* threadName,IN CM_INT32 stackSize,IN CM_INT32 priority,IN CM_Thread_Arg_Struct_T* pargs) +{ + /*- 变量初始化 */ + CM_THREAD_T tmpThread = 0u; /*线程ID*/ + CM_BOOL rt = CM_FALSE; /*函数返回值*/ + CM_UINT32 ThrAddr = 0u; /*临时变量*/ + + /*- 检查入口参数是否合法 */ + if ((stackSize >= 0) + && ((priority == THREAD_PRIORITY_HIGHEST) || (priority == THREAD_PRIORITY_ABOVE_NORMAL) + || (priority == THREAD_PRIORITY_NORMAL) || (priority == THREAD_PRIORITY_BELOW_NORMAL) + || (priority == THREAD_PRIORITY_LOWEST) || (priority == THREAD_PRIORITY_IDLE))) + { + /*- 创建线程 */ + tmpThread = (CM_THREAD_T)_beginthreadex(NULL, (unsigned int)stackSize, myfunc, (void*)pargs, 0u, (unsigned int *)&ThrAddr); + /*- 线程是否创建成功 */ + if (tmpThread > 0u) + { + /*- 设置线程优先级 */ + rt = SetThreadPriority((HANDLE)tmpThread, (int)priority); + /*- 优先级是否设置成功 */ + if ((rt == CM_TRUE) && (thread != NULL)) + { + /*- 输出线程ID */ + *thread = tmpThread; + } + } + } + /*- 返回执行结果 */ + return rt; +} + +/** +* @brief 获取当前线程ID +* @return 线程ID +*/ +CM_THREAD_T CM_Thread_Self(void) +{ + /*- 获取当前线程ID */ + CM_THREAD_T td = GetCurrentThreadId(); + /*- 返回线程ID */ + return td; +} +#endif \ No newline at end of file diff --git a/TSCP/src/MSCP/CM/CM_Mutex.h b/TSCP/src/MSCP/CM/CM_Mutex.h new file mode 100644 index 0000000..95fa228 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Mutex.h @@ -0,0 +1,95 @@ +/** +* @file CM_Mutex.h +* @brief 实现了互斥信号量的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#ifndef CM_MUTEX_H +#define CM_MUTEX_H + +#include "CM_Types.h" + +#ifdef VXWORKS +#include +#endif + +#ifdef QNX +#include +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + +#ifdef WIN32 + typedef HANDLE CM_MUTEX_T; /**< 互斥信号量 */ +#endif +#ifdef QNX + typedef pthread_mutex_t* CM_MUTEX_T;/**< 互斥信号量 */ +#endif +#ifdef VXWORKS + typedef SEM_ID CM_MUTEX_T;/**< 互斥信号量 */ +#endif + + + /** + * @brief CM_Mutex_Init + * + * 初始化互斥器. + * @param[out] mutex + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Mutex_Init(INOUT CM_MUTEX_T* pMutex); + + /** + * @brief CM_Mutex_Destroy + * + * 销毁互斥器. + * @param[in] mutex + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Mutex_Destroy(IN CM_MUTEX_T mutex); + + /** + * @brief CM_Mutex_Lock + * + * 获得互斥器资源. + * @param[in] mutex + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Mutex_Lock(IN CM_MUTEX_T mutex); + + /** + * @brief CM_Mutex_Lock + * + * 计时获得互斥器资源 + * @param[in] mutex + * @param[in] dwWaitTime 锁定时间(毫秒) + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Mutex_Lock_Time(IN CM_MUTEX_T mutex, IN CM_UINT32 dwWaitTime); + + /** + * @brief CM_Mutex_Unlock + * + * 释放互斥器. + * @param[in] mutex + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Mutex_Unlock(IN CM_MUTEX_T mutex); + +#ifdef __cplusplus +} + +#endif /**< __cplusplus */ + +#endif /**< _CM_MUTEX_H */ diff --git a/TSCP/src/MSCP/CM/CM_Mutex_qnx.c b/TSCP/src/MSCP/CM/CM_Mutex_qnx.c new file mode 100644 index 0000000..46efb90 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Mutex_qnx.c @@ -0,0 +1,182 @@ +/** +* @file CM_Mutex.c +* @brief 实现了互斥信号量的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Mutex.h" + +#ifdef QNX +#include "time.h" +#include "CM_Memory.h" +/** +* @brief 互斥信号量初始化 +* @param pMutex 信号量指针 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Init(INOUT CM_MUTEX_T* pMutex) +{ + /*- 变量初始化 */ + CM_INT32 ret = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入参是否合法 */ + if (NULL != pMutex) + { + /*- 创建互斥信号量 */ + *pMutex = (pthread_mutex_t*)CM_Malloc(sizeof(pthread_mutex_t)); + if(*pMutex != NULL) + { + ret = pthread_mutex_init(*pMutex, NULL); + + /*- 创建是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 销毁互斥信号量 +* @param mutex 互斥信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Destroy(IN CM_MUTEX_T mutex) +{ + CM_INT32 ret = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 销毁互斥信号量 */ + ret = pthread_mutex_destroy(mutex); + + /*- 销毁是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 锁定信号量(指定等待时间) +* @param mutex 互斥信号量 +* @param dwWaitTime 等待时间(毫秒) +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Lock_Time(IN CM_MUTEX_T mutex, IN CM_UINT32 dwWaitTime) +{ + CM_INT32 ret = 0; + CM_TIMESPEC_T time_sruct; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + time_sruct.tv_sec = (CM_INT32)CM_UNSIGNED_INT_EXP(dwWaitTime / 1000u); + time_sruct.tv_nsec = (CM_INT32)CM_UNSIGNED_INT_EXP((dwWaitTime % 1000u) * CM_UNSIGNED_MILLION); + + /*- 执行锁定信号量操作 */ + ret = pthread_mutex_timedlock(mutex,&time_sruct); + + /*- 锁定是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 锁定信号量 +* @param mutex 互斥信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Lock(IN CM_MUTEX_T mutex) +{ + CM_INT32 ret = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 执行锁定信号量操作 */ + ret = pthread_mutex_lock(mutex); + /*- 锁定是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} +/** +* @brief 解锁信号量 +* @param mutex 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Unlock(IN CM_MUTEX_T mutex) +{ + CM_INT32 ret = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 解锁信号量 */ + ret = pthread_mutex_unlock(mutex); + /*- 解锁是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} + +#endif diff --git a/TSCP/src/MSCP/CM/CM_Mutex_vxworks.c b/TSCP/src/MSCP/CM/CM_Mutex_vxworks.c new file mode 100644 index 0000000..ef4289a --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Mutex_vxworks.c @@ -0,0 +1,130 @@ +/** +* @file CM_Mutex.c +* @brief 实现了互斥信号量的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Mutex.h" + +#ifdef VXWORKS +/** +* @brief 互斥信号量初始化 +* @param pMutex 信号量指针 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Init(INOUT CM_MUTEX_T* pMutex) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 输入参数是否合法 */ + if (NULL != pMutex) + { + /*- 创建互斥信号量 */ + *pMutex = semBCreate(SEM_Q_FIFO, SEM_FULL); + + /*- 创建是否成功 */ + if (NULL != (*pMutex)) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + } + return rt; +} + +/** +* @brief 销毁互斥信号量 +* @param mutex 互斥信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Destroy(IN CM_MUTEX_T mutex) +{ + STATUS ret = OK; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 锁定信号量 */ + ret = semTake(mutex, WAIT_FOREVER); + /*- 锁定是否成功 */ + if (OK == ret) + { + /*- 销毁信号量 */ + semDelete(mutex); + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 锁定信号量 +* @param mutex 互斥信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Lock(IN CM_MUTEX_T mutex) +{ + /*- 执行锁定信号量,等待无限长时间 */ + return CM_Mutex_Lock_Time(mutex, WAIT_FOREVER); +} + +/** +* @brief 锁定信号量(指定等待时间) +* @param mutex 互斥信号量 +* @param dwWaitTIme 等待时间 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Lock_Time(IN CM_MUTEX_T mutex, IN CM_UINT32 dwWaitTime) +{ + STATUS ret = OK; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 执行锁定信号量,等待给定时间*/ + ret = semTake(mutex, dwWaitTime); + /*- 锁定是否成功 */ + if (OK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + return rt; +} + +/** +* @brief 解锁信号量 +* @param mutex 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Unlock(IN CM_MUTEX_T mutex) +{ + STATUS ret = OK; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 释放信号量*/ + ret = semGive(mutex); + /*- 释放是否成功 */ + if (OK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} +#endif + + diff --git a/TSCP/src/MSCP/CM/CM_Mutex_windows.c b/TSCP/src/MSCP/CM/CM_Mutex_windows.c new file mode 100644 index 0000000..fc8a6a3 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Mutex_windows.c @@ -0,0 +1,138 @@ +/** +* @file CM_Mutex.c +* @brief 实现了互斥信号量的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Mutex.h" + +#ifdef WIN32 +/** +* @brief 互斥信号量初始化 +* @param pMutex 信号量指针 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Init(INOUT CM_MUTEX_T* pMutex) +{ + /*- 函数执行结果初始化为失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE;/*函数返回值*/ + /*- 输入参数是否合法 */ + if (NULL != pMutex) + { + /*- 创建互斥信号量 */ + *pMutex = CreateMutex(NULL, CM_FALSE, (CM_UINT16*)NULL); + /*- 信号量是否创建成功 */ + if (0 != (*pMutex)) + { + /*- 函数执行结果为成功 */ + rt = ENUM_CM_TRUE; + } + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 销毁互斥信号量 +* @param mutex 互斥信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Destroy(IN CM_MUTEX_T mutex) +{ + /*- 初始化函数执行结果为失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_INT32 ret = 0; /* 临时变量 */ + + /*- 关闭互斥信号量句柄 */ + ret = CloseHandle(mutex); + + /*- 是否关闭成功 */ + if (0 != ret) + { + /*- 函数执行结果为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 锁定信号量(指定等待时间) +* @param mutex 互斥信号量 +* @param dwWaitTIme 等待时间(毫秒) +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Lock_Time(IN CM_MUTEX_T mutex, IN CM_UINT32 dwWaitTime) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT32 ret = 0u; /* 临时变量 */ + + /*- 按输入时长等待信号量*/ + ret = (CM_UINT32)WaitForSingleObject(mutex, (unsigned long)dwWaitTime); + + /*- 是否等到了信号量 */ + if ((CM_UINT32)WAIT_OBJECT_0 == ret) /* parasoft-suppress MISRA2004-10_1_a-3 "WIN API的宏WAIT_OBJECT_0不符合编码规范" */ + { + /*- 执行结果为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 执行结果为失败 */ + rt = ENUM_CM_FALSE; + } + return rt; +} +/** +* @brief 锁定信号量 +* @param mutex 互斥信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Lock(IN CM_MUTEX_T mutex) +{ + /*- 锁定信号量(等待无限长时间)*/ + return CM_Mutex_Lock_Time(mutex, INFINITE); +} + +/** +* @brief 解锁信号量 +* @param mutex 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Mutex_Unlock(IN CM_MUTEX_T mutex) +{ + /*- 初始化为执行失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_INT32 ret = 0; /* 临时变量 */ + + /*- 释放信号量 */ + ret = ReleaseMutex(mutex); + + /*- 是否释放成功 */ + if (0 != ret) + { + /*- 执行结果为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回执行结果 */ + return rt; +} +#endif \ No newline at end of file diff --git a/TSCP/src/MSCP/CM/CM_Queue.c b/TSCP/src/MSCP/CM/CM_Queue.c new file mode 100644 index 0000000..a3e251b --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Queue.c @@ -0,0 +1,481 @@ +/** +* @file CM_Queue.c +* @brief 队列函数实现 +* @details +* 1.本队列适用的应用方式有(单任务应用),(两个并行任务),(一个应用+一个中断)。 +* 2 本队列支持的两任务或者中断函数必须是一读一写,不支持两个任务同时读或者两个任务同时写 +* 3 申请足够空间防止队列写满。 +* 4 请不要输入 0 qsize。 +* 5 如果多任务或者中断情况下,如果空间小于两帧数据的容量,会发生死锁:数据长度不够读,剩余空间又不够写,发生死锁 +* 6 本队列最大支持4G的数据,但是使用者应根据平台情况酌情申请空间。 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ + +#include "CM_Queue.h" +#include "CM_Memory.h" + +/** +* @brief 队列初始化 +* @param pQueue 队列指针 +* @param Qsize 队列需要的长度 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 用于初始化一个队列,与CM_QueueElementFree配对使用 +* 为队列结构体中的pQ分配空间,并将队列的size初始化 +*/ +ENUM_CM_RETURN CM_QueueInitial(INOUT STRU_CM_QUEUE_T *pQueue, IN CM_UINT32 QSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 输入值是否合法 */ + if ((NULL != pQueue) && (0u != QSize)) + { + /*- 队列初始化为空 */ + pQueue->in = 0u; + pQueue->out = 0u; + pQueue->qsize = QSize; + /*- 按照指定大小分配内存 */ + pQueue->pQ = (CM_QueueElement*)CM_Malloc((CM_SIZE_T)(sizeof(CM_QueueElement) * pQueue->qsize)); + /*- 内存分配是否成功 */ + if (pQueue->pQ != NULL) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 队列初始化,使用传入的静态空间 +* @param pQueue 队列指针 +* @param Qsize 队列需要的长度 +* @param pQueueElementSpace 队列需要的内存空间 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 1.确认pQueueElementSpace数组的大小大于等于QSize,以免异常。 +* 2.如果使用这个函数初始化,则不再调用CM_QueueElementFree进行空间释放。 +*/ +ENUM_CM_RETURN CM_StaticQueueInitial(INOUT STRU_CM_QUEUE_T *pQueue, IN CM_UINT32 QSize, IN CM_QueueElement pQueueElementSpace[]) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 输入参数是否合法 */ + if ((NULL != pQueue) && (0u != QSize)) + { + /*- 队列初始化为空 */ + pQueue->in = 0u; + pQueue->out = 0u; + pQueue->qsize = QSize; + /*- 使用输入的内存空间分配内存 */ + pQueue->pQ = pQueueElementSpace; /*%RELAX*/ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} + +/* +* 功能描述: 队列扫描函数, +* 参数说明: CM_UINT32 DataLen, 要读出的数据长度; +* CM_QueueElement *pData, 读出的数据要存放的数组; +* STRU_CM_QUEUE_T *pQueue, 要读出数据的队列 +* 返回值: 0x55,成功 +* 0xAA,失败,队列数据长度不够 +*/ + +/** +* @brief 队列扫描函数 +* @param DataLen 要读出的数据长度 +* @param pData 读出的数据要存放的数组 +* @param pQueue 要读出数据的队列 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 可以读出队列中的数据,但是对队列的读写指针都不产生影响,即读到的数据还在队列中 +*/ +ENUM_CM_RETURN CM_QueueScan(IN CM_UINT32 DataLen, OUT CM_QueueElement *pData, IN const STRU_CM_QUEUE_T *pQueue) +{ + /*- 变量初始化 */ + register CM_UINT32 i = 0u; /*临时变量*/ + register CM_UINT32 j = 0u;/*临时变量*/ + register CM_QueueElement *pOut = NULL;/*临时变量*/ + ENUM_CM_RETURN rt = ENUM_CM_FALSE;/*函数返回值*/ + + /*- 队列中的数据是否不够读 */ + if ((CM_QueueStatus(pQueue) < DataLen) || (DataLen == 0u)) + { + /*- 函数执行结果置为失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*到达此处必然能够保证读到必须的数据*/ + /*- 确定读指针位置 */ + pOut = &(pQueue->pQ[pQueue->out]); + j = pQueue->qsize - (pQueue->out); + + /*- 读指针后面是否有足够多的数据(不需要翻转)*/ + if (j >= DataLen) + { + /*- @alias 不翻转读完数据 */ + for (i = 0u; i < DataLen; i++) + { + *pData = *pOut; + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pOut++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + } + else + { + /*不翻转不能读完数据*/ + + /*- @alias 读到队列尾*/ + for (i = 0u; i < j; i++) + { + *pData = *pOut; + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pOut++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + + /*- 将读指针指向数组头*/ + pOut = &pQueue->pQ[0]; + + /*- @alias 从队列头开始读剩下的数*/ + for (; i < DataLen; i++) + { + *pData = *pOut; + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pOut++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + } + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} + + +/** +* @brief 读队列函数 +* @param DataLen 要读出的数据长度 +* @param pData 读出的数据要存放的数组 +* @param pQueue 要读出数据的队列 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 可以读出队列中的数据,并存放在一个数组中,数据读出后读指针发生变化,即读出的数据已不存在队列中 +*/ +ENUM_CM_RETURN CM_QueueRead(IN CM_UINT32 DataLen, OUT CM_QueueElement *pData, INOUT STRU_CM_QUEUE_T *pQueue) +{ + /*- 变量初始化 */ + register CM_UINT32 i = 0u; /* 临时变量 */ + register CM_UINT32 j = 0u;/* 临时变量 */ + register CM_QueueElement *pOut = NULL;/* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE;/* 函数返回值 */ + + /*- 队列中的数据是否不够读 */ + if ((CM_QueueStatus(pQueue) < DataLen) || (DataLen == 0u)) + { + /*- 函数返回值置为失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*到达此处必然能够保证读到必须的数据*/ + /*- 确定读指针位置 */ + pOut = &(pQueue->pQ[pQueue->out]); + j = pQueue->qsize - (pQueue->out); + + /*- 读指针后面是否有足够多的数据(不需要翻转)*/ + if (j > DataLen) + { + /*- @alias 不翻转读完数据 */ + for (i = 0u; i < DataLen; i++) + { + *pData = *pOut; + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pOut++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + /*- 更新读指针 */ + pQueue->out += DataLen; + } + else + { + /*j<=DataLen 不翻转不能读完数据*/ + + /*- @alias 读到队列尾*/ + for (i = 0u; i < j; i++) + { + *pData = *pOut; + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pOut++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + + /*- 将读指针指向数组头*/ + pOut = &pQueue->pQ[0]; + + /*- @alias 从队列头开始读剩下的数*/ + for (; i < DataLen; i++) + { + *pData = *pOut; + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pOut++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + /*- 更新读指针 */ + pQueue->out = DataLen - j; + } + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; /* 返回 */ +} + +/** +* @brief 清空队列函数 +* @param pQueue 需要清空的队列指针 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 把队列中的in,out值置0 +*/ +ENUM_CM_RETURN CM_QueueClear(INOUT STRU_CM_QUEUE_T *pQueue) +{ + /*- 复位读、写指针*/ + pQueue->in = 0u; + pQueue->out = 0u; + /*- 返回成功 */ + return ENUM_CM_TRUE; +} + +/** +* @brief 读出队列中可用数据长度 +* @param pQueue 要读出的数据长度的队列 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 返回队列中可用的数据长度,如果队列为空,返回0 +*/ +CM_UINT32 CM_QueueStatus(IN const STRU_CM_QUEUE_T *pQueue) +{ + /*- 变量初始化 */ + CM_UINT32 qStatus = 0u; + /*- 队列是否已经初始化 */ + if (pQueue->qsize != 0u) + { + /*- 计算数据长度 */ + qStatus = ((pQueue->in + pQueue->qsize) - pQueue->out) % pQueue->qsize; + } + else + { + /*- 数据长度置0 */ + qStatus = 0u; + } + /*- 返回数据长度 */ + return qStatus; +} + +/** +* @brief 写队列函数 +* @param DataLen 要写入的数据长度 +* @param pData 要写入的数据存放的数组 +* @param pQueue 要写入数据的队列 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 将一个数组中的数据写到一个队列中 +*/ +ENUM_CM_RETURN CM_QueueWrite(IN CM_UINT32 DataLen, IN const CM_QueueElement *pData, INOUT STRU_CM_QUEUE_T *pQueue) +{ + /*- 变量初始化 */ + register CM_UINT32 i = 0u; /* 临时变量 */ + register CM_UINT32 j = 0u;/* 临时变量 */ + register CM_QueueElement *pIn = NULL;/* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*先判断队列是否有能够的空间容纳写入的数据,如果队列要满了,就不允许写了 */ + /*- 队列剩余空间是否够写 */ + if ((pQueue == NULL) || (pData == NULL) || (DataLen >= (pQueue->qsize - CM_QueueStatus(pQueue)))) + { + /*- 函数返回值置为失败 */ + rt = ENUM_CM_FALSE; + } + else + { + + /*由于已经能够判定有足够的空间,不需要再对out值进行判断*/ + /*- 确定写指针位置 */ + j = pQueue->qsize - (pQueue->in); + pIn = &(pQueue->pQ[pQueue->in]); + + /*- 读指针后面是否有足够大的空间(不需要翻转)*/ + if (j > DataLen) + { + /*写入时可以不用翻转*/ + + /*用自加指令可以明显提高指令的执行速度*/ + /*- @alias 不翻转写完数据 */ + for (i = 0u; i < DataLen; i++) + { + *pIn = *pData; + pIn++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + + /*- 更新写指针 */ + pQueue->in += DataLen; + } + else /*j <= DataLen*/ + { + /*写入过程中必然翻转*/ + + /*将数据从当前指针到缓冲区尾部,写入的长度为j*/ + /*- @alias 写到数组末端 */ + for (i = 0u; i < j; i++) + { + *pIn = *pData; + pIn++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + + /*已经写到缓冲区尾部了,应该从缓冲区头开始写起*/ + /*- 更新写指针到数组头部 */ + pIn = &pQueue->pQ[0]; + + /*从队列头开始写,i的初始值为j——即为上次写到缓冲区尾的长度 */ + /*- @alias 从数组头开始写剩余的数据 */ + for (; i < DataLen; i++) + { + *pIn = *pData; + pIn++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + pData++; /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + } + + /*调整队列的in指针为写入的总长度减去写到缓冲区尾的数据长度*/ + /*- 更新写指针 */ + pQueue->in = DataLen - j; + } + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} + + +/** +* @brief 队列存储空间释放函数 +* @param pQueue 队列 +* @details +* 在不需要某个队列的时候,把队列的元素数组空间释放掉,与CM_QueueInitial配对使用 +*/ +void CM_QueueElementFree(INOUT STRU_CM_QUEUE_T *pQueue) +{ + /*- 队列指针归位*/ + pQueue->in = 0u; + pQueue->out = 0u; + pQueue->qsize = 0u; + + /*- @alias 释放队列空间*/ + if (pQueue->pQ != NULL) + { + free((void*)pQueue->pQ); + pQueue->pQ = NULL; + } + else + { + /*- 无处理 */ + } +} + +/** +* @brief 在队列中删除一定的元素 +* @param Length 要删除的元素个数 +* @param pQueue 队列 +*/ +void CM_QueueElementDiscard(IN CM_UINT16 Length, INOUT STRU_CM_QUEUE_T *pQueue) +{ + /*- 变量初始化 */ + CM_UINT32 qLen = 0u; + /*- 队列是否已经初始化 */ + if(pQueue->qsize > 0u) + { + /*- 获取队列长度 */ + qLen = CM_QueueStatus(pQueue); + /*- 要删除的元素个数是否大于队列中的有效数据总量 */ + if (qLen < Length) + { + /*- 清空队列 */ + (void)CM_QueueClear(pQueue); + } + else + { + /*- 移动读指针删除指定数量的队列元素 */ + pQueue->out = (pQueue->out + Length) % pQueue->qsize; + } + } + else + { + /*- 无处理 */ + } +} + +/** +* @brief 读出队列中可用空间大小 +* @param pQueue 队列 +* @return 可用空间大小 +* @details 由于队列不能写满,队列中有一个空间不能用 +*/ +CM_UINT32 CM_QueueGetSpace(IN const STRU_CM_QUEUE_T *pQueue) +{ + /*- 变量初始化 */ + CM_UINT32 qSpace = 0u; + /*- 队列是否已经初始化 */ + if (pQueue->qsize != 0u) + { + /*- 计算剩余可用空间大小 */ + qSpace = ((pQueue->out + pQueue->qsize) - pQueue->in - 1u) % pQueue->qsize; + } + else + { + /*- 无处理 */ + } + /*- 返回可用空间大小 */ + return qSpace; +} + diff --git a/TSCP/src/MSCP/CM/CM_Queue.h b/TSCP/src/MSCP/CM/CM_Queue.h new file mode 100644 index 0000000..ad339c5 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Queue.h @@ -0,0 +1,140 @@ +/** +* @file CM_Queue.h +* @brief 队列函数实现 +* @details +* 1.本队列适用的应用方式有(单任务应用),(两个并行任务),(一个应用+一个中断)。 +* 2 本队列支持的两任务或者中断函数必须是一读一写,不支持两个任务同时读或者两个任务同时写 +* 3 申请足够空间防止队列写满。 +* 4 请不要输入 0 qsize。 +* 5 如果多任务或者中断情况下,如果空间小于两帧数据的容量,会发生死锁:数据长度不够读,剩余空间又不够写,发生死锁 +* 6 本队列最大支持4G的数据,但是使用者应根据平台情况酌情申请空间。 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#ifndef CM_QUEUE_H_ +#define CM_QUEUE_H_ + +#include "CM_Types.h" +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef CM_UINT8 CM_QueueElement;/**< 队列元素 */ + /*- 队列数据结构 */ + typedef struct + { + CM_UINT32 in; /**< 写队列数据指针 */ + CM_UINT32 out; /**< 读队列数据指针 */ + CM_UINT32 qsize; /**< 队列容量 */ + CM_QueueElement *pQ; /**< 队列数据 */ + }STRU_CM_QUEUE_T; + /*以下部分为队列相关的定义*/ + + /* + * 功能描述: 队列初始化函数,用于初始化一个队列,与CM_QueueElementFree配对使用 + * 为队列结构体中的q分配空间,并将队列的size初始化 + * 参数说明: STRU_CM_QUEUE_T *pQueue, 待分配空间的队列 + * CM_UINT32 QSize, 队列需要的长度 + * 返回值 : 0x55,成功 + * 0xAA,失败 + */ + ENUM_CM_RETURN CM_QueueInitial(INOUT STRU_CM_QUEUE_T *pQueue, IN CM_UINT32 QSize); + + + /* + * 功能描述: 队列初始化函数,用于初始化一个队列 + * QSize初始化,与CM_QueueInitial相比,采用传入的空间作为队列元素的空间。 + * 参数说明: STRU_CM_QUEUE_T *pQueue, 待分配空间的队列 + * CM_UINT32 QSize, 队列需要的长度 + * CM_QueueElement pQueueElementSpace[], 队列需要的内存空间 + * 返回值 : 0x55,成功 + * 0xAA,失败 + * 使用注意: 1,确认pQueueElementSpace数组的大小大于等于QSize,以免异常。 + * 2,如果使用这个函数初始化,则不再调用CM_QueueElementFree进行空间释放。 + */ + ENUM_CM_RETURN CM_StaticQueueInitial(INOUT STRU_CM_QUEUE_T *pQueue, IN CM_UINT32 QSize, IN CM_QueueElement pQueueElementSpace[]); + + /* + * 功能描述: 队列扫描函数,可以读出队列中的数据,但是对队列的读写指针都不产生影响,即读到的数据还在队列中 + * 参数说明: CM_UINT32 DataLen, 要读出的数据长度; + * CM_QueueElement *pData, 读出的数据要存放的数组; + * STRU_CM_QUEUE_T *pQueue, 要读出数据的队列 + * 返回值: 1,成功 + * 0,失败,队列数据长度不够 + */ + ENUM_CM_RETURN CM_QueueScan(IN CM_UINT32 DataLen, OUT CM_QueueElement *pData, IN const STRU_CM_QUEUE_T *pQueue); + + + /* + * 功能描述: 读队列函数,可以读出队列中的数据,并存放在一个数组中,数据读出后读指针发生变化,即读出的数据已不存在队列中 + * 参数说明: CM_UINT32 DataLen, 要读出的数据长度; + * CM_QueueElement *pData, 读出的数据要存放的数组; + * STRU_CM_QUEUE_T *pQueue, 要读出数据的队列 + * 返回值 : 1,成功 + * 0,失败,队列数据长度不够 + */ + ENUM_CM_RETURN CM_QueueRead(IN CM_UINT32 DataLen, OUT CM_QueueElement *pData, INOUT STRU_CM_QUEUE_T *pQueue); + + /* + * 功能描述: 清队列函数,把队列中的in,out值置0 + * 参数说明: STRU_CM_QUEUE_T *pQueue, 需要清的队列指针 + * 返回值: 0x55,成功;0xAA,失败 + */ + ENUM_CM_RETURN CM_QueueClear(INOUT STRU_CM_QUEUE_T *pQueue); + + /* + * 功能描述: 读出队列中可用数据长度 + * 参数说明: STRU_CM_QUEUE_T *pQueue, 要读出的数据长度的队列; + * 返回值 : 返回队列中可用的数据长度,如果队列为空,返回0 + */ + CM_UINT32 CM_QueueStatus(IN const STRU_CM_QUEUE_T *pQueue); + + /* + * 功能描述: 写队列函数,将一个数组中的数据写到一个队列中 + * 对一个队列的操作不可以两个任务同时写入 + * 队列是不可以写满的,如果写不下函数返回0 + * 参数说明: CM_UINT32 DataLen, 要写入的数据长度; + * CM_QueueElement *pData, 要写入的数据存放的数组; + * STRU_CM_QUEUE_T *pQueue, 要写入数据的队列 + * 返回值 : 0x55,成功 + * 0xAA,失败,队列已满 + */ + ENUM_CM_RETURN CM_QueueWrite(IN CM_UINT32 DataLen, IN const CM_QueueElement *pData, INOUT STRU_CM_QUEUE_T *pQueue); + + /* + * 函数描述: 队列存储空间释放函数 + * 在不需要某个队列的时候,把队列的元素数组空间释放掉,与CM_QueueInitial配对使用 + * 参数说明: STRU_CM_QUEUE_T *pQueue, 队列 + * 返回值 : + */ + void CM_QueueElementFree(INOUT STRU_CM_QUEUE_T *pQueue); + + /* + * 功能描述: 在队列中删除一定的元素。 + * 参数说明: CM_UINT16 Length, 要删除的元素个数 + * STRU_CM_QUEUE_T *pQueue, 要删除元素的队列 + * 返回值 : + */ + void CM_QueueElementDiscard(IN CM_UINT16 Length, INOUT STRU_CM_QUEUE_T *pQueue); + + /* + * 功能描述: 读出队列中可用空间大小 + * 参数说明: STRU_CM_QUEUE_T *pQueue, 指定的队列 + * 返回值 : 返回队列中可用的空间大小,由于队列不能写满,最大可用空间为qsize-1 + */ + CM_UINT32 CM_QueueGetSpace(IN const STRU_CM_QUEUE_T *pQueue); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/CM/CM_RingBuf.c b/TSCP/src/MSCP/CM/CM_RingBuf.c new file mode 100644 index 0000000..fe41eec --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_RingBuf.c @@ -0,0 +1,139 @@ +/** +* @file CM_MQ.c +* @brief 实现环形数组的封装 +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "CM_RingBuf.h" +#include "CM_Memory.h" + +/** +* @brief 环形数组初始化 +* @param[inout] pRing 要初始化的环形数组 +* @param[in] maxSize 环形数组大小 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_RB_Init(INOUT STRU_CM_RING_T* pRing, IN CM_UINT32 maxSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + /*- 为环形数组分配内存 */ + pRing->pdata = (CM_INT64 *)CM_Malloc(maxSize * sizeof(CM_INT64)); + /*- 内存分配是否成功 */ + if (NULL != pRing->pdata) + { + ret = CM_Memset((void*)pRing->pdata, (CM_UINT8)0u, maxSize * sizeof(CM_INT64), maxSize * sizeof(CM_INT64)); + /*- 数据结构初始化 */ + pRing->size = maxSize; + pRing->i = 0u; + } + else + { + /*- 无处理 */ + } + /*- 返回执行结果 */ + return ret; +} + +/** +* @brief 写环形数组 +* @param[in] pRing 要写的环形数组 +* @param[in] val 要写的值 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_RB_Write(INOUT STRU_CM_RING_T* pRing, IN CM_INT64 val) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + /*- 指针是否合法 */ + if (NULL != pRing) + { + /*- 写入环形数组并更新写索引 */ + pRing->pdata[pRing->i] = val; + pRing->i = (pRing->i + 1u) % pRing->size; + ret = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回执行结果 */ + return ret; +} + +/** +* @brief 查看环形数组 +* +* 仅读取数据,而不弹出. +* @param[in] pMQ 要查看的环形数组 +* @param[in] index 要查看的数据索引(从1开始,1为最新数据,size为最老数据) +* @param[out] pVal 要输出的数据缓冲区 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details 本函数不检查环形数组中是否已经写入了足够的数据,需要用户自行检查 +*/ +ENUM_CM_RETURN CM_RB_Get(IN const STRU_CM_RING_T* pRing, IN CM_UINT16 index, OUT CM_INT64* pVal) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + /*- 输入是否合法 */ + if ((NULL != pRing) && (index <= pRing->size) && (NULL != pVal)) + { + /*- 获取指定位置的数据值 */ + *pVal = pRing->pdata[((pRing->i + pRing->size) - index) % pRing->size]; + ret = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回执行结果 */ + return ret; +} + +/** +* @brief 清零环形数组 +* @param[inout] pMQ 要清零的环形数组 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @note 清零环形数组,消息数据缓冲区清零 +*/ +ENUM_CM_RETURN CM_RB_Clear(INOUT STRU_CM_RING_T* pRing) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT32 i = 0u; + /*- 输入是否合法 */ + if (NULL != pRing) + { + /*- @alias 清零环形数组 */ + for (i = 0u; i < pRing->size; i++) + { + pRing->pdata[i] = 0; + } + /*- 写索引重置到0 */ + pRing->i = 0u; + ret = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + /*- 返回执行结果 */ + return ret; +} + + diff --git a/TSCP/src/MSCP/CM/CM_RingBuf.h b/TSCP/src/MSCP/CM/CM_RingBuf.h new file mode 100644 index 0000000..4587423 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_RingBuf.h @@ -0,0 +1,80 @@ +/** +* @file CM_RingBuf.h +* @brief 实现环形数组的封装 +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CM_RINGBUF_H +#define CM_RINGBUF_H + +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /** 64位环形数组数据结构 */ + typedef struct + { + CM_UINT32 i; /**< 写索引,指向待写入的输入*/ + CM_UINT32 size; /**< 缓冲区大小 */ + CM_INT64* pdata; /**< 环形数组缓冲区 */ + }STRU_CM_RING_T; + /** + * @brief 环形数组初始化(64位) + * @param[inout] pRing 要初始化的环形数组 + * @param[in] maxSize 环形数组大小 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_RB_Init(INOUT STRU_CM_RING_T* pRing, IN CM_UINT32 maxSize); + + /** + * @brief 写环形数组(64位) + * @param[in] pRing 要写的环形数组 + * @param[in] val 要写的值 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_RB_Write(INOUT STRU_CM_RING_T* pRing, IN CM_INT64 val); + + /** + * @brief 查看环形数组(64位) + * + * 仅读取数据,而不弹出. + * @param[in] pMQ 要查看的环形数组 + * @param[in] index 要查看的数据索引(从1开始,1为最新数据,size为最老数据) + * @param[out] pVal 要输出的数据缓冲区 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_RB_Get(IN const STRU_CM_RING_T* pRing, IN CM_UINT16 index, OUT CM_INT64* pVal); + + /** + * @brief 清零环形数组(64位) + * @param[inout] pMQ 要清零的环形数组 + * @return 执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + * @note 清零环形数组,消息数据缓冲区清零 + */ + ENUM_CM_RETURN CM_RB_Clear(INOUT STRU_CM_RING_T* pRing); + +#ifdef __cplusplus +} + +#endif /* __cplusplus */ + +#endif /* _CM_RINGBUF_H */ + diff --git a/TSCP/src/MSCP/CM/CM_Sem.h b/TSCP/src/MSCP/CM/CM_Sem.h new file mode 100644 index 0000000..3f5260a --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Sem.h @@ -0,0 +1,94 @@ +/** +* @file CM_Sem.h +* @brief 实现了信号量的封装 +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef CM_SEM_H +#define CM_SEM_H + +#include "CM_Types.h" + +#ifdef VXWORKS +#include +#endif + +#ifdef QNX +#include +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + +#ifdef WIN32 + typedef HANDLE CM_SEM_T;/**< 信号量 */ +#endif +#ifdef QNX + typedef sem_t* CM_SEM_T;/**< 信号量 */ +#endif +#ifdef VXWORKS + typedef SEM_ID CM_SEM_T;/**< 信号量 */ +#endif + + + /** + * @brief CM_Sem_Init + * + * 初始化信号量 + * @param[out] pSem + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Sem_Init(INOUT CM_SEM_T* pSem); + + /** + * @brief CM_Sem_Destroy + * + * 销毁信号量 + * @param[in] sem + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Sem_Destroy(IN CM_SEM_T sem); + + /** + * @brief CM_Sem_Wait + * + * 等待信号量 + * @param[in] sem + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Sem_Wait(IN CM_SEM_T sem); + + /** + * @brief CM_Sem_wait_Time + * + * 等待信号量一定时间 + * @param[in] sem + * @param[in] dwWaitTime 锁定时间(毫秒) + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Sem_Wait_Time(IN CM_SEM_T sem, IN CM_UINT32 dwWaitTime); + + /** + * @brief CM_Sem_Post + * + * 发出信号量 + * @param[in] sem + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_Sem_Post(IN CM_SEM_T sem); + +#ifdef __cplusplus +} + +#endif /**< __cplusplus */ + +#endif /**< _CM_SEM_H */ diff --git a/TSCP/src/MSCP/CM/CM_Sem_qnx.c b/TSCP/src/MSCP/CM/CM_Sem_qnx.c new file mode 100644 index 0000000..e9de895 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Sem_qnx.c @@ -0,0 +1,212 @@ +/** +* @file CM_Sem.c +* @brief 实现了信号量的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Sem.h" + +#ifdef QNX +#include "time.h" +#include "CM_Memory.h" +/** +* @brief 信号量初始化 +* @param pSem 信号量指针 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Init(INOUT CM_SEM_T* pSem) +{ + /*- 变量初始化 */ + CM_INT32 ret = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 入参是否合法 */ + if (NULL != pSem) + { + /*- 创建互斥信号量 */ + *pSem = (sem_t*)CM_Malloc(sizeof(sem_t)); + if(pSem != NULL) + { + ret = sem_init(*pSem, 0, 0u); + + /*- 创建是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 创建失败 */ + } + } + else + { + /*- 内存分配失败 */ + } + } + else + { + /*- 入参非法 */ + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 销毁信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Destroy(IN CM_SEM_T sem) +{ + CM_INT32 ret = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 销毁互斥信号量 */ + if(NULL != sem) + { + ret = sem_destroy(sem); + CM_Free((void *)sem); + /*- 销毁是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 等待信号量(指定等待时间) +* @param sem 信号量 +* @param dwWaitTIme 等待时间(毫秒) +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Wait_Time(IN CM_SEM_T sem, IN CM_UINT32 dwWaitTime) +{ + CM_INT32 ret = 0; + CM_TIMESPEC_T time_struct; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + time_struct.tv_sec = (CM_INT32)CM_UNSIGNED_INT_EXP(dwWaitTime / 1000u); + time_struct.tv_nsec = (CM_INT32)CM_UNSIGNED_INT_EXP((dwWaitTime % 1000u) * CM_UNSIGNED_MILLION); + + /*- 执行等待信号量操作 */ + if(NULL != sem) + { + ret = sem_timedwait(sem,&time_struct); + + /*- 等待是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 等待信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Wait(IN CM_SEM_T sem) +{ + CM_INT32 ret = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 执行等待信号量操作 */ + if(NULL != sem) + { + ret = sem_wait(sem); + /*- 等待是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} +/** +* @brief 发送信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Post(IN CM_SEM_T sem) +{ + CM_INT32 ret = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 发送信号量 */ + if(NULL != sem) + { + ret = sem_post(sem); + /*- 发送是否成功 */ + if (EOK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*- 返回函数执行结果 */ + return rt; +} +#endif + + + diff --git a/TSCP/src/MSCP/CM/CM_Sem_vxworks.c b/TSCP/src/MSCP/CM/CM_Sem_vxworks.c new file mode 100644 index 0000000..530ccb3 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Sem_vxworks.c @@ -0,0 +1,122 @@ +/** +* @file CM_Sem.c +* @brief 实现了信号量的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Sem.h" + +#ifdef VXWORKS +/** +* @brief 信号量初始化 +* @param pMutex 信号量指针 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Init(INOUT CM_SEM_T* pSem) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 输入参数是否合法 */ + if (NULL != pSem) + { + /*- 创建互斥信号量 */ + *pSem = semBCreate(SEM_Q_FIFO, SEM_EMPTY); + + /*- 创建是否成功 */ + if (0 != (*pSem)) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + } + return rt; +} + +/** +* @brief 销毁信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Destroy(IN CM_SEM_T sem) +{ + /*- 销毁信号量 */ + semDelete(sem); + + /*- 返回函数执行结果 */ + return ENUM_CM_TRUE; +} + +/** +* @brief 等待信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_wait(IN CM_SEM_T sem) +{ + /*- 执行锁定信号量,等待无限长时间 */ + return CM_Sem_Wait_Time(sem, WAIT_FOREVER); +} + +/** +* @brief 等待信号量(指定等待时间) +* @param sem 信号量 +* @param dwWaitTIme 等待时间 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Wait_Time(IN CM_SEM_T sem, IN CM_UINT32 dwWaitTime) +{ + STATUS ret = OK; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 执行锁定信号量,等待给定时间*/ + ret = semTake(sem, dwWaitTime); + /*- 锁定是否成功 */ + if (OK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + return rt; +} + +/** +* @brief 发送信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Post(IN CM_SEM_T sem) +{ + STATUS ret = OK; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 释放信号量*/ + ret = semGive(sem); + /*- 释放是否成功 */ + if (OK == ret) + { + /*- 函数执行结果置为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} +#endif + + diff --git a/TSCP/src/MSCP/CM/CM_Sem_windows.c b/TSCP/src/MSCP/CM/CM_Sem_windows.c new file mode 100644 index 0000000..bc231b5 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Sem_windows.c @@ -0,0 +1,143 @@ +/** +* @file CM_Sem.c +* @brief 实现了信号量的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Sem.h" + +#ifdef WIN32 +/** +* @brief 信号量初始化 +* @param pSem 信号量指针 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Init(INOUT CM_SEM_T* pSem) +{ + /*- 函数执行结果初始化为失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE;/*函数返回值*/ + /*- 输入参数是否合法 */ + if (NULL != pSem) + { + /*- 创建信号量 */ + *pSem = CreateEvent(NULL, CM_FALSE, CM_FALSE, NULL); + /*- 信号量是否创建成功 */ + if (0 != (*pSem)) + { + /*- 函数执行结果为成功 */ + rt = ENUM_CM_TRUE; + } + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 销毁信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Destroy(IN CM_SEM_T sem) +{ + /*- 初始化函数执行结果为失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_INT32 ret = 0; /* 临时变量 */ + + /*- 关闭信号量句柄 */ + ret = CloseHandle(sem); + + /*- 是否关闭成功 */ + if (0 != ret) + { + /*- 函数执行结果为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回函数执行结果 */ + return rt; +} + +/** +* @brief 等待信号量(指定等待时间) +* @param sem 信号量 +* @param dwWaitTIme 等待时间(毫秒) +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Wait_Time(IN CM_SEM_T sem, IN CM_UINT32 dwWaitTime) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT32 ret = 0u; /* 临时变量 */ + + /*- 按输入时长等待信号量*/ + ret = (CM_UINT32)WaitForSingleObject(sem, (unsigned long)dwWaitTime); + + /*- 是否等到了信号量 */ + if ((CM_UINT32)WAIT_OBJECT_0 == ret) /* parasoft-suppress MISRA2004-10_1_a-3 "WIN API的宏WAIT_OBJECT_0不符合编码规范" */ + { + /*- 执行结果为成功 */ + ResetEvent(sem); + rt = ENUM_CM_TRUE; + } + else + { + /*- 执行结果为失败 */ + rt = ENUM_CM_FALSE; + } + return rt; +} +/** +* @brief 等待信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Wait(IN CM_SEM_T sem) +{ + /*- 等待信号量(等待无限长时间)*/ + return CM_Sem_Wait_Time(sem, INFINITE); +} + +/** +* @brief 发送信号量 +* @param sem 信号量 +* @return 执行结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Sem_Post(IN CM_SEM_T sem) +{ + /*- 初始化为执行失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_INT32 ret = 0; /* 临时变量 */ + + /*- 发送信号量 */ + ret = SetEvent(sem); + + /*- 是否发送成功 */ + if (0 != ret) + { + /*- 执行结果为成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回执行结果 */ + return rt; +} +#endif + + + diff --git a/TSCP/src/MSCP/CM/CM_Socket.c b/TSCP/src/MSCP/CM/CM_Socket.c new file mode 100644 index 0000000..5af1472 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Socket.c @@ -0,0 +1,182 @@ +/** +* @file CM_Socket.c +* @brief socket操作的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Socket.h" +#include "CM_Memory.h" + +/** socket服务初始化标志 */ +static CM_BOOL s_Socket_Initialized = CM_FALSE; + +/** +* @brief socket初始化 +* @return 初始化结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Socket_Init(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE;/* 函数返回值 */ + /*- 是否已经初始化成功 */ + if (CM_TRUE == s_Socket_Initialized) + { + /*- 初始化结果置为成功 */ + rt = ENUM_CM_TRUE; + } + else + { +#ifdef WIN32 + WSADATA wsa; /* 临时变量 */ + CM_INT32 ret = 1; /* 临时变量 */ + /*- 启动socket库 */ + CM_Memset(((void*)(&wsa)), (CM_UINT8)0U, ((size_t)(sizeof(wsa))), ((size_t)(sizeof(wsa)))); + ret = WSAStartup(MAKEWORD(2, 2), &wsa); + /*- 是否启动成功 */ + if (0 == ret) + { + /*- 初始化成功 */ + s_Socket_Initialized = CM_TRUE; + rt = ENUM_CM_TRUE; + } + +#else/*Linux Vxworks常用PIOX标准*/ + /*- 忽略SIGPIPE信号 */ + (void)signal(SIGPIPE, SIG_IGN);/*sigaction*/ + /*- 初始化成功 */ + s_Socket_Initialized = CM_TRUE; + rt = ENUM_CM_TRUE; +#endif + } + /*- 返回初始化结果 */ + return rt; +} + +/** +* @brief 创建socket +* @param pSock socket指针 +* @param isUDP 是否是UDP socket +* - CM_TRUE 是UDP socket +* - CM_FALSE 是TCP socket +* @return 创建结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Socket_Create(INOUT CM_SOCKET* pSock, IN CM_BOOL isUDP) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE;/* 函数返回值 */ +#ifdef WIN32 + unsigned long dwBytesReturned = 0U;/* 临时变量 */ + CM_BOOL bNewBehavior = FALSE; /* 临时变量 */ + CM_INT32 status = 0; /* 临时变量 */ +#endif + /*- 是否尚未初始化socket或输入非法 */ + if ((CM_TRUE != s_Socket_Initialized) || (NULL == pSock)) + { + /*- 创建失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 是否是创建UDP socket */ + if (CM_TRUE == isUDP) + { + /*- 创建UDP socket */ + *pSock = socket(AF_INET, SOCK_DGRAM, 0); +#ifdef WIN32 + status = WSAIoctl(*pSock, _WSAIOW(IOC_VENDOR, 12), &bNewBehavior, sizeof(bNewBehavior), NULL, 0, &dwBytesReturned, NULL, NULL); + /*函数成功则返回0*/ + /*- @alias 检查是否创建成功 */ + if (0 != status) + { + *pSock = INVALID_SOCKET; + } +#endif + } + else + { + /*- 创建 TCP socket */ + *pSock = socket(AF_INET, SOCK_STREAM, 0); + } + +#ifdef WIN32 + /*- @alias 检查创建是否成功 */ + if (INVALID_SOCKET == *pSock) + { + rt = ENUM_CM_FALSE; + } + else + { + rt = ENUM_CM_TRUE; + } + +#else/*Linux Vxworks常用PIOX标准*/ + /*- @alias 检查创建是否成功 */ + if (0 >= *pSock) + { + rt = ENUM_CM_FALSE; + } + else + { + rt = ENUM_CM_TRUE; + } +#endif + } + /*- 返回socket创建结果 */ + return rt; +} + +/** +* @brief 关闭socket +* @param pSock socket指针 +* @return 关闭结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_Socket_Close(INOUT CM_SOCKET* pSock) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + /*- socket是否未初始化或输入非法 */ + if ((CM_TRUE != s_Socket_Initialized) || (NULL == pSock)) + { + /*- 关闭失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 关闭连接的读和写*/ + (void)shutdown(*pSock, 2); + + /*- @alias 关闭socket */ + if (0 != (CM_INT32)(*pSock)) + { +#ifdef WIN32 + closesocket(*pSock); +#else/*Linux Vxworks常用PIOX标准*/ + (void)close(*pSock); +#endif + *pSock = 0; + } + else + { + /* 无处理 */ + } + /*- 关闭成功 */ + rt = ENUM_CM_TRUE; + } + /*- 返回关闭结果 */ + return rt; +} + diff --git a/TSCP/src/MSCP/CM/CM_Socket.h b/TSCP/src/MSCP/CM/CM_Socket.h new file mode 100644 index 0000000..fe7f448 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Socket.h @@ -0,0 +1,98 @@ +/** +* @file CM_Socket.h +* @brief socket操作的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#ifndef CM_SOCKET_H +#define CM_SOCKET_H + +#include "CM_Types.h" + +#ifdef WIN32 +#pragma comment(lib, "Ws2_32.lib") /*预处理指令*/ +#endif +#ifdef VXWORKS +#include +#include +#include +#include +#include +#include +#endif + +#ifdef QNX +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +typedef struct sockaddr CM_SOCKADDR; /* socket地址结构体 */ + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + + typedef struct sockaddr_in CM_SOCKADDR_T; /* 地址类型 */ +#define CM_SOCKET_ERROR (-1) + +#ifdef WIN32 + typedef SOCKET CM_SOCKET; /* socket类型 */ +#endif + +#ifdef VXWORKS + typedef int CM_SOCKET; /* socket类型 */ +#endif + +#ifdef QNX + typedef int CM_SOCKET; /* socket类型 */ +#endif + + /** + * @brief CM_Socket_Init + * + * Socket初始化,仅需初始化一次. + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_Socket_Init(void); + + /** + * @brief CM_Socket_Create + * + * 创建Socket. + * @param[in] sock + * @param[in] isUDP + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_Socket_Create(INOUT CM_SOCKET* pSock, IN CM_BOOL isUDP); + + /** + * @brief CM_Socket_Close_Socket + * + * 关闭Socket. + * @param[in] sock + * @return CM_BOOL + */ + ENUM_CM_RETURN CM_Socket_Close(INOUT CM_SOCKET* pSock); + +#ifdef __cplusplus +} + +#endif /**< __cplusplus */ + +#endif /**< _CM_SOCKET_H */ + diff --git a/TSCP/src/MSCP/CM/CM_TCP.c b/TSCP/src/MSCP/CM/CM_TCP.c new file mode 100644 index 0000000..d936cbb --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_TCP.c @@ -0,0 +1,1183 @@ +/** +* @file CM_TCP.c +* @brief TCP通信的封装 +* @author GT-BU +* @date 2022.03.29 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_TCP.h" +#include "CM_Memory.h" +#include "PFM_Cfg.h" +#include "PFM_Log.h" + +#ifdef WIN32 +#include /* 组播 */ +#endif +/** TCP服务已初始化标志 */ +static CM_BOOL s_TCP_Initialized = CM_FALSE; + +/** TCP消息结构体,线程安全 */ +static STRU_TCP_MSG Tcp_Message[TCP_CONN_MAX]; + +static ENUM_CM_RETURN CM_TCP_Is_Read_Ready(IN CM_SOCKET sock); +static ENUM_CM_RETURN CM_TCP_Is_Write_Ready(IN CM_SOCKET sock); +/** +* @brief 初始化TCP服务 +* @details 仅需初始化一次 +*/ +ENUM_CM_RETURN CM_TCP_Init(void) +{ + /*- 变量初始化 */ + CM_UINT16 Idex = 0u; /* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- 初始化socket服务 */ + rt = CM_Socket_Init(); + + /*- 是否车初始化成功 */ + if (ENUM_CM_TRUE == rt) + { + /*- 初始化TCP消息结构体 */ + (void)CM_Memset((void*)(&Tcp_Message[0]), (CM_UINT8)0U, (size_t)(sizeof(Tcp_Message)), (size_t)(sizeof(Tcp_Message))); + for(Idex = 0u; Idex < TCP_CONN_MAX; Idex++) + { + rt = CM_Mutex_Init(&Tcp_Message[Idex].mutex); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, TCP_MODE,DARK_FAULT_CODE_FUN_ORDER_1,TSCP_DARK_ASSERT_1); + } + /*- TCP初始化成功 */ + s_TCP_Initialized = CM_TRUE; + } + else + { + /*- 无处理 */ + } + + /*- 返回初始化结果 */ + return rt; +} + +/** +* @brief TCP套接字相关信息插入或更新 +* @param tcpId tcpid用以映射,不能为0 +* @param TcpSock 套接字,不能为0 +* @param TcpState 套接字状态,不能为0 +* @param TcpServerIp 服务端IP地址,不能为0 +* @param TcpServerPort 服务端端口号,不能为0 +* @preturn 插入结果 +* - ENUM_CM_TRUE 查询成功 +* - ENUM_CM_FALSE 查询失败 +*/ +ENUM_CM_RETURN CM_TCP_MsgIstOrUpd(IN CM_UINT16 tcpId, IN CM_SOCKET TcpSock, IN CM_UINT32 TcpState, IN CM_UINT32 TcpServerIp, IN CM_UINT16 TcpServerPort) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT16 Idex = 0u; /* 临时变量 */ + + /*- 是否TCP消息结构初始化成功并且参数有效*/ + if ((CM_TRUE == s_TCP_Initialized) && (0u != tcpId) && (0u != TcpState) && (0 != TcpSock) && (0u != TcpServerIp) && (0u != TcpServerPort)) + { + for(Idex = 0u; Idex < TCP_CONN_MAX; Idex++) + { + /*- 上锁 */ + (void)CM_Mutex_Lock(Tcp_Message[Idex].mutex); + + /*- 第一次创建时判断TcpId为0就插入数据*/ + if(0u == Tcp_Message[Idex].TcpId) + { + Tcp_Message[Idex].TcpId = tcpId; + Tcp_Message[Idex].TcpSock = TcpSock; + Tcp_Message[Idex].TcpState = TcpState; + Tcp_Message[Idex].TcpServerIp= TcpServerIp; + Tcp_Message[Idex].TcpServerPort = TcpServerPort; + + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + rt = ENUM_CM_TRUE; + /*- 跳出 */ + break; + } + else if(tcpId == Tcp_Message[Idex].TcpId) + { + /*- 判断TcpId相等则更新数据,不需要更新TcpId、TcpServerIp、TcpServerPort*/ + Tcp_Message[Idex].TcpSock = TcpSock; + Tcp_Message[Idex].TcpState = TcpState; + + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + rt = ENUM_CM_TRUE; + /*- 跳出 */ + break; + } + else + { + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + + if (Idex == TCP_CONN_MAX - 1u) + { + /*日志记录*/ + MSCP_LOG_MSG("ERROR : Tcp_Message Is Full, More Than 9 Element.\n"); + } + else + { + + } + } + } + + } + else + { + /*- 无处理 */ + } + + /*- 返回初始化结果 */ + return rt; +} + +/** +* @brief TCP套接字相关信息更新 +* @param tcpId tcpid用以映射,不能为0 +* @param TcpState 套接字状态,不能为0 +* @preturn 插入结果 +* - ENUM_CM_TRUE 查询成功 +* - ENUM_CM_FALSE 查询失败 +*/ +ENUM_CM_RETURN CM_TCP_Msgstate_Update(IN CM_UINT16 tcpId, IN CM_UINT32 TcpState) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT16 Idex = 0u; /* 临时变量 */ + + /*- 是否TCP消息结构初始化成功并且参数有效*/ + if ((CM_TRUE == s_TCP_Initialized) && (0u != tcpId)) + { + for(Idex = 0u; Idex < TCP_CONN_MAX; Idex++) + { + /*- 上锁 */ + (void)CM_Mutex_Lock(Tcp_Message[Idex].mutex); + + /*- 判断TcpId相等则更新状态 */ + if(tcpId == Tcp_Message[Idex].TcpId) + { + Tcp_Message[Idex].TcpState = TcpState; + + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + rt = ENUM_CM_TRUE; + /*- 跳出 */ + break; + } + else + { + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + if (Idex == TCP_CONN_MAX - 1u) + { + /*日志记录*/ + MSCP_LOG_MSG("ERROR : TcpId =%d, Query Tcp_Message Failed, Not Found Tcpid.\n",tcpId); + } + else + { + + } + } + } + } + else + { + /*- 无处理 */ + } + + /*- 返回初始化结果 */ + return rt; +} + +/** +* @brief TCP套接字查询 +* @param tcpId tcpid用以映射,不能为0 +* @param pTcpState TCP状态 +* @preturn 查询结果 +* - ENUM_CM_TRUE 查询成功 +* - ENUM_CM_FALSE 查询失败 +*/ +ENUM_CM_RETURN CM_TCP_Msgstate_Query(IN CM_UINT16 tcpId, INOUT CM_SOCKET *pTcpSock,INOUT CM_UINT32 *pTcpState,INOUT CM_UINT32 *pTcpServerIp,INOUT CM_UINT16 *pTcpServerPort ) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT16 Idex = 0u; /* 临时变量 */ + + /*- 是否TCP消息结构初始化成功 */ + if ((CM_TRUE == s_TCP_Initialized) && (0u != tcpId)) + { + /*- 遍历Tcp消息结构体查询 */ + for(Idex = 0u; Idex < TCP_CONN_MAX; Idex++) + { + /*- 上锁 */ + (void)CM_Mutex_Lock(Tcp_Message[Idex].mutex); + if(tcpId == Tcp_Message[Idex].TcpId) + { + *pTcpSock = Tcp_Message[Idex].TcpSock; + (*pTcpState) = Tcp_Message[Idex].TcpState; + (*pTcpServerIp) = Tcp_Message[Idex].TcpServerIp; + (*pTcpServerPort )= Tcp_Message[Idex].TcpServerPort; + + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + rt = ENUM_CM_TRUE; + /*- 跳出 */ + break; + } + else + { + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + if (Idex == TCP_CONN_MAX - 1u ) + { + /*日志记录*/ + MSCP_LOG_MSG("ERROR : TcpId =%d, Query Tcp_Message Failed, Not Found Tcpid.\n",tcpId); + } + else + { + + } + } + } + + } + else + { + /*- 无处理 */ + } + + /*- 返回初始化结果 */ + return rt; +} + +/** +* @brief socket是否可读 +* @param sock soket +* @preturn 可读状态 +* - ENUM_CM_TRUE 可读 +* - ENUM_CM_FALSE 不可读 +*/ +static ENUM_CM_RETURN CM_TCP_Is_Read_Ready(IN CM_SOCKET sock) +{ + /*- 变量初始化 */ + CM_INT32 sFd = 0; /* 文件描述符 */ + CM_INT32 sFlag = 0; /* 临时变量 */ + struct timeval timeover1 = { 0, 0 }; /* 时间 */ + fd_set readok; /* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + /*- TCP服务是否已经初始化 */ + if (CM_TRUE == s_TCP_Initialized) + { + /*- select查询sock的读状态 */ + (void)CM_Memset((void*) &readok, (CM_UINT8)0U, (size_t)(sizeof(fd_set)), (size_t)(sizeof(fd_set))); + timeover1.tv_sec = 0; + + timeover1.tv_usec = 0; + + FD_ZERO(&readok); + FD_SET(sock, &readok); + + sFd = (CM_INT32)select((sock + 1), &readok, NULL, NULL, &timeover1); + + /*- @alias 判断sock是否可读*/ + if (sFd > 0) + { + sFlag = FD_ISSET(sock, &readok); + if (0 != sFlag) + { + rt = ENUM_CM_TRUE; + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + /*- 无处理 */ + } + /*- 返回sock的可读状态 */ + return rt; +} + +/** +* @brief socket是否可写 +* @param sock soket +* @preturn 可写状态 +* - ENUM_CM_TRUE 可写 +* - ENUM_CM_FALSE 不可写 +*/ +static ENUM_CM_RETURN CM_TCP_Is_Write_Ready(IN CM_SOCKET sock) +{ + /*- 变量初始化 */ + CM_INT32 sFd = 0; /* 文件描述符 */ + CM_INT32 sFlag = 0; /* 临时变量 */ + struct timeval timeover1 = { 0, 0 }; /* 时间 */ + fd_set writeok; /* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- TCP服务是否已经初始化 */ + if (CM_TRUE == s_TCP_Initialized) + { + /*- select查询sock的写状态 */ + (void)CM_Memset((void*) &writeok, (CM_UINT8)0U, (size_t)(sizeof(fd_set)), (size_t)(sizeof(fd_set))); + timeover1.tv_sec = 0; + timeover1.tv_usec = 0; + FD_ZERO(&writeok); + FD_SET(sock, &writeok); + + sFd = (CM_INT32)select((CM_INT32)(sock + 1), NULL, &writeok, NULL, &timeover1); + + /*- @alias 判断sock是否可写 */ + if (sFd > 0) + { + sFlag = FD_ISSET(sock, &writeok); + if (0 != sFlag) + { + rt = ENUM_CM_TRUE; + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + /*- 无处理 */ + } + /*- 返回sock的可写状态 */ + return rt; +} + +/** +* @brief TCP套接字选项设置 +* @param pSock TCP套接字 +* @preturn 设置结果 +* - ENUM_CM_TRUE 设置成功 +* - ENUM_CM_FALSE 设置失败 +*/ +ENUM_CM_RETURN CM_TCP_SetSockOpt(IN CM_SOCKET *pSock) +{ + CM_INT32 arg = 1; + struct linger linger_opt; + CM_INT32 ret = 0; /* 临时结果 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + if(0 > *pSock) + { + rt = ENUM_CM_FALSE; + } + else + { + /*- 设置非阻塞 */ + arg = 1; +#ifdef WIN32 + ret = ioctlsocket(*pSock, (long)FIONBIO, (unsigned long*)&arg); +#else/*Linux Vxworks常用PIOX标准*/ + ret = ioctl(*pSock, FIONBIO, &arg); +#endif + if (0 != ret) + { + /*- 设置非阻塞失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 关闭nagle算法,有数据立即发送 */ + arg = 1; + ret = setsockopt(*pSock, IPPROTO_TCP, TCP_NODELAY, (char *)&arg, sizeof(arg)); + if (0 != ret) + { + /*- 关闭nagle算法失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- set linger opt 在close时立即实施可靠关断,丢弃协议栈中未发出的数据 */ + linger_opt.l_onoff = 1; + linger_opt.l_linger = 0; + ret = setsockopt(*pSock, SOL_SOCKET, SO_LINGER, (char *)&linger_opt, sizeof(linger_opt)); + if (0 != ret) + { + /*- 设置失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 所有设置成功 */ + rt = ENUM_CM_TRUE; +#if 1 + /*- 允许socket地址重用 */ + arg = 1; + ret = setsockopt(*pSock, SOL_SOCKET , SO_REUSEADDR, (char *)&arg, sizeof(arg)); + if (0 != ret) + { + /*- 设置失败 */ + rt = ENUM_CM_FALSE; + } + else + { +#if QNX + /*- 允许socket端口重用 */ + arg = 1; + ret = setsockopt(*pSock, SOL_SOCKET , SO_REUSEPORT, (char *)&arg, sizeof(arg)); + if (0 != ret) + { + /*- 设置失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 所有设置成功 */ + rt = ENUM_CM_TRUE; + } +#endif + } + +#endif + } + } + } + } + return rt; +} + +/** +* @brief 宕机情况下,关闭所有TCP连接 +* @return 关闭结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_TCP_Socket_Close_shutdown(void) +{ + /*- 变量初始化 */ + CM_UINT16 Idex = 0u; /* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- 是否TCP服务未初始化 */ + if ((CM_TRUE != s_TCP_Initialized)) + { + /*- 关闭失败 */ + rt = ENUM_CM_FALSE; + } + else + { + + for(Idex = 0u; Idex < TCP_CONN_MAX; Idex++) + { + /*- 上锁 */ + (void)CM_Mutex_Lock(Tcp_Message[Idex].mutex); + + if(0u != Tcp_Message[Idex].TcpId) + { + /* 关闭连接的读和写 */ + (void)shutdown(Tcp_Message[Idex].TcpSock,2); + (void)close(Tcp_Message[Idex].TcpSock); + + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + + /*- 关闭成功同步Tcp消息结构体成功 */ + rt = ENUM_CM_TRUE; + /*- 跳出 */ + break; + } + else + { + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + } + } + + } + /*- 返回创建结果 */ + return rt; +} + +/** +* @brief 关闭TCP socket,并且更新Tcp_Message结构信息 +* @param tcpId tcpid用以映射,不能为0 +* @param TcpState Tcp状态标志 +* @return 关闭结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_TCP_Socket_Close(IN CM_UINT16 tcpId, IN CM_UINT32 TcpState) +{ + /*- 变量初始化 */ + CM_UINT16 Idex = 0u; /* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- 是否TCP服务未初始化或输入非法 */ + if ((CM_TRUE != s_TCP_Initialized) || (0u >= tcpId)) + { + /*- 关闭失败 */ + rt = ENUM_CM_FALSE; + } + else + { + + for(Idex = 0u; Idex < TCP_CONN_MAX; Idex++) + { + /*- 上锁 */ + (void)CM_Mutex_Lock(Tcp_Message[Idex].mutex); + + if(tcpId == Tcp_Message[Idex].TcpId) + { + /* 关闭连接的读和写 */ + (void)shutdown(Tcp_Message[Idex].TcpSock,2); + (void)close(Tcp_Message[Idex].TcpSock); + Tcp_Message[Idex].TcpSock=0; + Tcp_Message[Idex].TcpState = TcpState; + + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + + /*- 关闭成功同步Tcp消息结构体成功 */ + rt = ENUM_CM_TRUE; + /*- 跳出 */ + break; + } + else + { + /*- 释放锁 */ + (void)CM_Mutex_Unlock(Tcp_Message[Idex].mutex); + if (Idex == TCP_CONN_MAX -1u) + { + /*日志记录*/ + MSCP_LOG_MSG("ERROR : TcpId =%d, Query Tcp_Message Failed, Not Found Tcpid.\n",tcpId); + } + else + { + + } + } + } + + } + /*- 返回创建结果 */ + return rt; +} + +/** +* @brief 创建TCP socket +* @param pSock socket指针 +* @param ServeraddrIP 服务端IP地址 +* @param ServerPort 服务端端口号 +* @param tcpId tcpid用以映射,不能为0 +* @return 创建结果 +* - ENUM_CM_TRUE 创建成功 +* - ENUM_CM_FALSE 创建失败 +*/ +ENUM_CM_RETURN CM_TCP_Socket_Create(INOUT CM_SOCKET *pSock, IN CM_UINT32 ClientaddrIP, IN CM_UINT16 ClientPort,IN CM_UINT16 tcpId , IN CM_UINT32 ServeraddrIP, IN CM_UINT16 ServerPort) +{ + /*- 变量初始化 */ + CM_SOCKADDR_T addrHost; /* 主机地址 */ + CM_INT32 ret = 0; /* 临时结果 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- 是否TCP服务未初始化或输入非法 */ + if ((CM_TRUE != s_TCP_Initialized) || (NULL == pSock) || (0u == tcpId)) + { + /*- 创建失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 创建TCP socket*/ + (void)CM_Memset((void*) &addrHost, (CM_UINT8)0U, (size_t)(sizeof(CM_SOCKADDR_T)), (size_t)(sizeof(CM_SOCKADDR_T))); + rt = CM_Socket_Create(pSock, CM_FALSE); + /*- 创建socket是否成功 */ + if (ENUM_CM_TRUE == rt) + { + /*- 设置套接字选项 */ + ret = CM_TCP_SetSockOpt(pSock); + + /*- 设置socket的阻塞模式是否成功 */ + if (ENUM_CM_TRUE == ret) + { + /*- 绑定IP端口 */ + (void)CM_Memset((void*) &addrHost, (CM_UINT8)0U, (size_t)(sizeof(CM_SOCKADDR_T)), (size_t)(sizeof(CM_SOCKADDR_T))); + addrHost.sin_family = (CM_UINT16)AF_INET; + addrHost.sin_port = htons(ClientPort); + addrHost.sin_addr.s_addr = ClientaddrIP; + ret = (CM_INT32)bind(*pSock, (CM_SOCKADDR*) &addrHost, (unsigned int)sizeof(CM_SOCKADDR)); + if (-1 == ret) + { + (void)MSCP_LOG_MSG("Tcp bind errno = %d, %s\n", errno,strerror(errno)); + rt = ENUM_CM_FALSE; + } + else + { + ret = CM_TCP_MsgIstOrUpd(tcpId,(*pSock),ENUM_CM_NOCONN,ServeraddrIP,ServerPort); + if (ret == ENUM_CM_TRUE) + { + /*- 同步Tcp消息结构体成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 关闭套接字 */ + (void)close(*pSock); + + /*- 同步Tcp消息结构体失败 */ + rt = ENUM_CM_FALSE; + } + } + } + + else + { + /*- 关闭套接字 */ + (void)close(*pSock); + + /*- 创建失败 */ + rt = ENUM_CM_FALSE; + } + } + else + { + /*- 创建失败 */ + rt = ENUM_CM_FALSE; + } + } + /*- 返回创建结果 */ + return rt; +} + +/** +* @brief TCP建立连接 +* @param tcpId tcpid用以映射,不能为0 +* @param time_out 连接超时时间 +* @return 连接结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_TCP_Socket_Connect(IN CM_UINT16 tcpId, IN CM_UINT32 time_out) +{ + /*- 变量初始化 */ + CM_INT32 ret = 0; /* 临时结果 */ + CM_SOCKET tcpsock = -1; /* 临时变量 */ + CM_UINT32 ServeraddrIP = 0u; /* 临时变量 */ + CM_UINT16 ServerPort = 0u; /* 临时变量 */ + CM_UINT32 TcpState = 0u; /* 临时变量 */ + CM_SOCKADDR_T addrServer; /* 服务端地址信息 */ + CM_CHAR addrServerTmp[INET_ADDRSTRLEN];/*地址信息buff*/ + struct timeval select_Time_Out;/* 设置超时 */ + fd_set write_Set = {0};/* 写集合 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- 是否TCP服务未初始化或输入非法 */ + if ((CM_TRUE != s_TCP_Initialized) || (0u >= tcpId)) + { + /*- 关闭失败 */ + rt = ENUM_CM_FALSE; + } + else + { + + ret = CM_TCP_Msgstate_Query(tcpId, &tcpsock,&TcpState, &ServeraddrIP, &ServerPort); + if (ENUM_CM_TRUE == ret) + { + /*- 判断状态为已创建,未连接则连接 */ + if ((CM_UINT32)ENUM_CM_NOCONN == TcpState) + { + /* 填充服务端地址信息 */ + addrServer.sin_family = AF_INET; + addrServer.sin_addr.s_addr = ServeraddrIP; + addrServer.sin_port = htons(ServerPort); + + /* 建立连接 */ + if (0 == connect(tcpsock, (CM_SOCKADDR*) &addrServer, sizeof(CM_SOCKADDR_T))) + { + /* 建立连接立即成功 */ + /* 转换服务端ip地址 */ + if (NULL != inet_ntop(AF_INET, &addrServer.sin_addr, addrServerTmp, (CM_UINT32)INET_ADDRSTRLEN)) + { + /*日志记录*/ + MSCP_LOG_MSG("connect %s port %u succeed immediately.\n",addrServerTmp, ntohs(addrServer.sin_port)); + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("Couldn't convert Server address to string.\n"); + } + + /* 更新套接字状态为已创建并且连接成功 */ + ret = CM_TCP_Msgstate_Update(tcpId, ENUM_CM_CONNECTED); + + if (ENUM_CM_TRUE == ret) + { + /*- 连接成功 */ + rt = ENUM_CM_TRUE; + } + else + { + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CONNFAIL); + } + } + else if((errno == EWOULDBLOCK) || (errno == EINPROGRESS) || (errno == EINTR)) + { + /* 延时判断连接状态 */ + + /* 设置超时时间 */ + if (time_out >= 1000U) + { + select_Time_Out.tv_sec = time_out / 1000U; + select_Time_Out.tv_usec = (time_out % 1000U) * 1000U; + } + else + { + select_Time_Out.tv_sec = 0; + select_Time_Out.tv_usec = time_out * 1000U; + } + + FD_ZERO(&write_Set); + FD_SET(tcpsock, &write_Set); + ret = select(tcpsock + 1, NULL, &write_Set, NULL, &select_Time_Out); + if (-1==ret) + { + /*日志记录*/ + MSCP_LOG_MSG("select error!\n"); + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CONNFAIL); + } + else if(0==ret) + { + /*日志记录*/ + MSCP_LOG_MSG("connect time out! The network cable may not be connected or the service host may not be started!\n"); + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CONNFAIL); + } + else + { + if (0 != FD_ISSET(tcpsock, &write_Set)) + { + /* 再次连接,如果连接失败且错误码为EISCONN说明已经连接成功 */ + ret = connect(tcpsock, (CM_SOCKADDR*) &addrServer, sizeof(CM_SOCKADDR_T)); + if (-1 == ret) + { + if (errno == EISCONN) + { + /*日志记录*/ + MSCP_LOG_MSG("connect finished.\n"); + /* 转换服务端ip地址 */ + if (NULL != inet_ntop(AF_INET, &addrServer.sin_addr, addrServerTmp, INET_ADDRSTRLEN)) + { + /*日志记录*/ + MSCP_LOG_MSG("connect %s port %u succeed.\n",addrServerTmp, ntohs(addrServer.sin_port)); + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("Couldn't convert Server address to string.\n"); + } + + /* 更新套接字状态为已创建并且连接成功 */ + ret = CM_TCP_Msgstate_Update(tcpId, ENUM_CM_CONNECTED); + + if (ENUM_CM_TRUE == ret) + { + /*- 连接成功 */ + rt = ENUM_CM_TRUE; + } + else + { + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CONNFAIL); + } + + + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("connect failed. errno = %d, %s.\n",errno,strerror(errno)); + + /* 转换服务端ip地址 */ + if (NULL != inet_ntop(AF_INET, &addrServer.sin_addr, addrServerTmp, INET_ADDRSTRLEN)) + { + /*日志记录*/ + MSCP_LOG_MSG("connect %s port %u failed.the server process may not be started!\n",addrServerTmp, ntohs(addrServer.sin_port)); + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("Couldn't convert Server address to string.\n"); + } + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CONNFAIL); + } + } + else + { + /*-理论上不可达 */ + } + } + else + { + + } + } + } + else + { + /* 建立连接失败 */ + if (NULL != inet_ntop(AF_INET, &addrServer.sin_addr, addrServerTmp, INET_ADDRSTRLEN)) + { + /*日志记录*/ + MSCP_LOG_MSG("connect %s port %u failed.\n",addrServerTmp, ntohs(addrServer.sin_port)); + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("Couldn't convert Server address to string.\n"); + } + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CONNFAIL); + } + + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("ERROR : TcpState =%d, Not Equal ENUM_CM_NOCONN.\n",TcpState); + } + + } + else + { + /*- 无处理 */ + } + } + /*- 返回连接结果 */ + return rt; +} + +/** +* @brief TCP发送 +* @param tcpId tcpid用以映射,不能为0 +* @param pBuf 发送报文指针 +* @param bufSize 发送报文长度 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_TCP_Send_Msg(IN CM_UINT16 tcpId, IN const CM_UINT8 pBuf[], IN CM_INT32 bufSize) +{ +#if QNX + /*- 变量初始化 */ + CM_INT32 ret = 0; /* 函数返回值 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_SOCKET tcpsock = -1; /* 临时变量 */ + CM_UINT32 ServeraddrIP = 0u; /* 临时变量 */ + CM_UINT16 ServerPort = 0u; /* 临时变量 */ + CM_UINT32 TcpState = 0u; /* 临时变量 */ + CM_INT32 leftszie = 0; /* 临时变量 */ +#ifdef QNX + ssize_t sendszie = 0; /* 临时变量 */ +#else + CM_UINT32 sendszie = 0; +#endif + + const CM_UINT8* ptr = NULL; /* 临时变量 */ + + + /*- TCP协议是否已经初始化 */ + if ((CM_TRUE == s_TCP_Initialized) && (0u < tcpId) && (NULL != pBuf) && (0 < bufSize)) + { + ret = CM_TCP_Msgstate_Query(tcpId, &tcpsock, &TcpState, &ServeraddrIP, &ServerPort); + if (ENUM_CM_TRUE == ret) + { + if ((CM_UINT32)ENUM_CM_CONNECTED == TcpState) + { + ptr = pBuf; + leftszie = bufSize; + while(0 < leftszie) + { + /*- TCP发送 */ + sendszie = send(tcpsock,ptr,bufSize,MSG_NOSIGNAL); + if (((CM_SOCKET_ERROR) == sendszie) && (errno == EINTR)) + { + /*- 处理EINTR错误,系统调用被中断再次尝试发送 */ + sendszie = 0; + } + else if(CM_SOCKET_ERROR == sendszie) + { + /*- 发送失败,关闭套接字,置套接字状态为已断开连接,待创建 */ + if (errno == EPIPE) + { + /*日志记录*/ + MSCP_LOG_MSG("Server Process Down. errno = %d, %s.\n", errno,strerror(errno)); + } + else if ((errno == EWOULDBLOCK) ||(errno == EAGAIN)) + { + /*日志记录*/ + MSCP_LOG_MSG("The Tcp Send Buf Queue Is Full. errno = %d, %s.\n", errno,strerror(errno)); + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("send failed. errno = %d, %s.\n", errno,strerror(errno)); + } + + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CLOSED); + + /*- 跳出while循环 */ + break; + } + else + { + /*- 接着发送直到leftszie等于0 */ + leftszie = bufSize - (CM_INT32)sendszie; + ptr += sendszie; + } + } + + /*- 发送成功 */ + if (0 == leftszie) + { + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("ERROR : TcpState =%d, Not Equal ENUM_CM_CONNECTED.\n",TcpState); + } + } + else + { + + } + } + else + { + /*- 无处理 */ + } + /*- 返回发送结果 */ + return rt; +#else + return ENUM_CM_TRUE; +#endif +} + +/** +* @brief TCP接收消息查找完整帧 +* @param pBuf tcp消息Buf +* @param bufSize buf长度 +* @param pFullFrameSize 完整帧长度 +* @preturn 完整包结果 +* - ENUM_CM_TRUE 有完整帧 +* - ENUM_CM_FALSE 没有完整帧 +*/ +ENUM_CM_RETURN CM_TCP_Find_Full_Frame(IN CM_UINT8 pBuf[], IN CM_INT32 bufSize, INOUT CM_INT32 *pFullFrameSize) +{ + /*- 变量初始化 */ + CM_UINT16 Idex = 0u; /* 临时变量 */ + CM_UINT16 count_LBkt = 0u; /* 计数{ */ + CM_UINT16 count_LBkt_Fg = 0u; /* 计数{ 找到标志*/ + CM_UINT16 count_RBkt = 0u; /* 计数} */ + CM_UINT16 Flag = 0u; /* 找到完整帧标志 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- 遍历数据 */ + for(Idex = 0u; Idex < (CM_UINT32)bufSize; Idex++) + { + if ('{' == pBuf[Idex]) + { + count_LBkt++; + count_LBkt_Fg++; + } + else if('}' == pBuf[Idex]) + { + count_RBkt++; + } + else + { + /*- 无处理 */ + } + + /*- 如果左括号等于右括号并且值不为0,说明有完整帧 */ + if ((count_LBkt == count_RBkt) && (0u != count_LBkt)) + { + /*- 计数重新置0,接着遍历 */ + count_LBkt = 0u; + count_RBkt = 0u; + + /*- 完整帧长度等于索引下标加1 */ + (*pFullFrameSize) = Idex + 1U; + Flag = 1u; + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + + if (0u == Flag) + { + *pFullFrameSize = 0; + } + else + { + /*- 无处理 */ + } + + /*- 返回初始化结果 */ + return rt; +} + +/** +* @brief TCP接收 +* @param tcpId tcpid用以映射,不能为0 +* @param pBuf 接收报文指针 +* @param bufSize 接收报文长度 +* @return 收到报文长度 +* - 正整数 收到的报文长度 +* - 0 未收到报文 +* - -1 接收异常 +* - -2 参数检查不合法 +*/ +CM_INT32 CM_TCP_Recv_Msg(IN CM_UINT16 tcpId, INOUT CM_UINT8 pBuf[], IN CM_INT32 bufSize) +{ + /*- 变量初始化 */ +#ifdef QNX + ssize_t recvNum = 0; /* 接收长度 */ +#else + CM_UINT32 recvNum = 0; +#endif + + CM_INT32 recvNumFianl = 0; /* 最终接收长度 */ + CM_UINT8 recvBuftmp[CM_TCP_BUFERSIZE]; + CM_SOCKET tcpsock = -1; /* 临时变量 */ + CM_UINT32 ServeraddrIP = 0u; /* 临时变量 */ + CM_UINT16 ServerPort = 0u; /* 临时变量 */ + CM_UINT32 TcpState = 0u; /* 临时变量 */ + CM_INT32 bufSizetmp = 0; /* 临时变量 */ + CM_INT32 ret = 0; /* 函数返回值 */ + ENUM_CM_RETURN ret_m = ENUM_CM_FALSE; /* memcpy函数返回值 */ + + /*- 是否TCP协议未初始化或输入非法 */ + if ((CM_TRUE != s_TCP_Initialized) || (NULL == pBuf) || (0u >= tcpId)) + { + recvNumFianl = -2; + } + else + { + ret = CM_TCP_Msgstate_Query(tcpId, &tcpsock, &TcpState, &ServeraddrIP, &ServerPort); + if (ENUM_CM_TRUE == ret) + { + if ((CM_UINT32)ENUM_CM_CONNECTED == TcpState) + { + while( 1 ) + { + /*- TCP接收 */ + recvNum = recv(tcpsock, recvBuftmp, sizeof(recvBuftmp), 0); + if (0 == recvNum) + { + /*- 服务端断开连接 */ + /*日志记录*/ + MSCP_LOG_MSG("ERROR :Server Process Has DisConnected.\n"); + + /*- 本端断开连接,关闭套接字,置套接字状态为已断开连接,待创建 */ + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CLOSED); + + recvNumFianl = -1; + /*- 跳出 */ + break; + } + else if((CM_SOCKET_ERROR == recvNum) && (errno == EINTR)) + { + /*- 非阻塞的正常情况,系统调用被中断 */ + + /*- 再次尝试接收 */ + + } + else if((CM_SOCKET_ERROR == recvNum) && ((errno == EWOULDBLOCK) ||(errno == EAGAIN))) + { + /*- 非阻塞的正常情况,没有数据到来 */ + + recvNumFianl += 0; + + + /*- 跳出while循环,下次接收 */ + break; + } + else if(CM_SOCKET_ERROR == recvNum) + { + /*- 接收失败,关闭套接字,置套接字状态为已断开连接,待创建 */ + /*日志记录*/ + MSCP_LOG_MSG("recv failed. errno = %d, %s.\n", errno,strerror(errno)); + + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CLOSED); + + recvNumFianl = -1; + + /*- 跳出while循环 */ + break; + + } + else + { + /*- 接收成功,将数据拷贝到缓冲区中,可能有数据未收完继续接收 */ + ret_m = CM_Memcpy((void*)(pBuf +bufSizetmp), (CM_SIZE_T)(bufSize - bufSizetmp), (void*)(recvBuftmp), (CM_SIZE_T)recvNum); + if (ENUM_CM_TRUE == ret_m) + { + bufSizetmp += recvNum; + recvNumFianl = bufSizetmp; + } + else + { + /*需要防护*/ + /*服务端异常,*/ + MSCP_LOG_MSG("ERROR :Server Process Is Unusual.Too many message recv!\n"); + + /*- 本端断开连接,关闭套接字,置套接字状态为已断开连接,待创建 */ + (void)CM_TCP_Socket_Close(tcpId,ENUM_CM_CLOSED); + + recvNumFianl = -1; + /*- 跳出 */ + break; + } + + } + } + } + else + { + /*日志记录*/ + MSCP_LOG_MSG("ERROR : TcpState =%d, Not Equal ENUM_CM_CONNECTED.\n"); + } + } + else + { + /*- 无处理 */ + } + + } + + /*- 返回接收长度 */ + return recvNumFianl; +} diff --git a/TSCP/src/MSCP/CM/CM_TCP.h b/TSCP/src/MSCP/CM/CM_TCP.h new file mode 100644 index 0000000..52fad97 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_TCP.h @@ -0,0 +1,183 @@ +/** +* @file CM_TCP.h +* @brief TCP通信的封装 +* @author GT-BU +* @date 2022.03.29 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#ifndef CM_TCP_H +#define CM_TCP_H + +#include "CM_Socket.h" +#include "CM_Mutex.h" + +#ifdef VXWORKS +#include +#endif +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + +#define CM_TCP_BUFERSIZE (1024 * 8) + + /*定义TCP套接字状态*/ + typedef enum + { + ENUM_CM_NOCREATE = 0u, /**< 未创建 */ + ENUM_CM_NOCONN = 1u , /**< 已创建,未连接 */ + ENUM_CM_CONNFAIL = 2u , /**< 已创建,连接失败 */ + ENUM_CM_CONNECTED = 3u , /**< 已创建,连接成功 */ + ENUM_CM_CLOSED = 4u /**< 已断开连接,待创建 */ + }ENUM_CM_TCPSTATE; + + /*定义TCP套接字相关信息*/ + typedef struct + { + CM_UINT16 TcpId; /**< TcpId */ + CM_SOCKET TcpSock;/**< Tcp套接字 */ + CM_UINT32 TcpState;/**< Tcp状态 */ + CM_UINT32 TcpServerIp;/**< Tcp服务端ip */ + CM_UINT16 TcpServerPort; /**< Tcp服务端端口号 */ + CM_MUTEX_T mutex; /**< 互斥信号量,用来保护套接字相关信息 */ + }STRU_TCP_MSG; + + /** + * @brief CM_TCP_Init + * + * TCP初始化,仅需初始化一次. + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_TCP_Init(void); + + /** + * @brief TCP套接字相关信息插入或更新 + * @param tcpId tcpid用以映射,不能为0 + * @param TcpSock 套接字,不能为0 + * @param TcpState 套接字状态,不能为0 + * @param TcpServerIp 服务端IP地址,不能为0 + * @param TcpServerPort 服务端端口号,不能为0 + * @preturn 插入结果 + * - ENUM_CM_TRUE 查询成功 + * - ENUM_CM_FALSE 查询失败 + */ + ENUM_CM_RETURN CM_TCP_MsgIstOrUpd(IN CM_UINT16 tcpId, IN CM_SOCKET TcpSock, IN CM_UINT32 TcpState, IN CM_UINT32 TcpServerIp, IN CM_UINT16 TcpServerPort); + + /** + * @brief TCP套接字相关信息更新 + * @param tcpId tcpid用以映射,不能为0 + * @param TcpState 套接字状态,不能为0 + * @preturn 插入结果 + * - ENUM_CM_TRUE 查询成功 + * - ENUM_CM_FALSE 查询失败 + */ + ENUM_CM_RETURN CM_TCP_Msgstate_Update(IN CM_UINT16 tcpId, IN CM_UINT32 TcpState); + + + /** + * @brief TCP套接字查询 + * @param tcpId tcpid用以映射,不能为0 + * @param pTcpState TCP状态 + * @preturn 查询结果 + * - ENUM_CM_TRUE 查询成功 + * - ENUM_CM_FALSE 查询失败 + */ + ENUM_CM_RETURN CM_TCP_Msgstate_Query(IN CM_UINT16 tcpId, INOUT CM_SOCKET *pTcpSock,INOUT CM_UINT32 *pTcpState,INOUT CM_UINT32 *pTcpServerIp,INOUT CM_UINT16 *pTcpServerPort ); + + + /** + * @brief TCP套接字选项设置 + * @param pSock TCP套接字 + * @preturn 设置结果 + * - ENUM_CM_TRUE 设置成功 + * - ENUM_CM_FALSE 设置失败 + */ + ENUM_CM_RETURN CM_TCP_SetSockOpt(IN CM_SOCKET *pSock); + + /** + * @brief 宕机情况下,关闭所有TCP连接 + * @return 关闭结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_TCP_Socket_Close_shutdown(void); + + /** + * @brief 关闭TCP socket,并且更新Tcp_Message结构信息 + * @param tcpId tcpid用以映射,不能为0 + * @param TcpState Tcp状态标志 + * @return 关闭结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_TCP_Socket_Close(IN CM_UINT16 tcpId, IN CM_UINT32 TcpState); + + + /** + * @brief 创建TCP socket + * @param pSock socket指针 + * @param ServeraddrIP 服务端IP地址 + * @param ServerportNumber 服务端端口号 + * @param tcpId tcpid用以映射,不能为0 + * @return 创建结果 + * - ENUM_CM_TRUE 创建成功 + * - ENUM_CM_FALSE 创建失败 + */ + ENUM_CM_RETURN CM_TCP_Socket_Create(INOUT CM_SOCKET *pSock, IN CM_UINT32 ClientaddrIP, IN CM_UINT16 ClientPort,IN CM_UINT16 tcpId , IN CM_UINT32 ServeraddrIP, IN CM_UINT16 ServerPort); + /** + * @brief TCP建立连接 + * @param tcpId tcpid用以映射,不能为0 + * @param time_out 连接超时时间 + * @return 连接结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_TCP_Socket_Connect(IN CM_UINT16 tcpId, IN CM_UINT32 time_out); + + /** + * @brief TCP发送 + * @param tcpId tcpid用以映射,不能为0 + * @param pBuf 发送报文指针 + * @param bufSize 发送报文长度 + * @return 发送结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN CM_TCP_Send_Msg(IN CM_UINT16 tcpId, IN const CM_UINT8 pBuf[], IN CM_INT32 bufSize); + /** + * @brief TCP接收消息查找完整帧 + * @param pBuf tcp消息Buf + * @param bufSize buf长度 + * @param pFullFrameSize 完整帧长度 + * @preturn 完整包结果 + * - ENUM_CM_TRUE 有完整帧 + * - ENUM_CM_FALSE 没有完整帧 + */ + ENUM_CM_RETURN CM_TCP_Find_Full_Frame(IN CM_UINT8 pBuf[], IN CM_INT32 bufSize, INOUT CM_INT32 *pFullFrameSize); + + /** + * @brief TCP接收 + * @param tcpId tcpid用以映射,不能为0 + * @param pBuf 接收报文指针 + * @param bufSize 接收报文长度 + * @return 收到报文长度 + * - 正整数 收到的报文长度 + * - 0 未收到报文 + * - -1 接收异常 + * - -2 参数检查不合法 + */ + CM_INT32 CM_TCP_Recv_Msg(IN CM_UINT16 tcpId, INOUT CM_UINT8 pBuf[], IN CM_INT32 bufSize); +#ifdef __cplusplus +} + +#endif /**< __cplusplus */ + +#endif /**< _CM_UDP_H */ + diff --git a/TSCP/src/MSCP/CM/CM_Time.c b/TSCP/src/MSCP/CM/CM_Time.c new file mode 100644 index 0000000..0ef2e8f --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Time.c @@ -0,0 +1,128 @@ +/** +* @file CM_Time.c +* @brief 时钟相关处理 +* @author GT-BU +* @date 2021.08.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.08.01 V1.0 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_Time.h" +#include "PFM_Log.h" +#if QNX +#include "sys/select.h" +#include "sys/time.h" +#else +#include +#endif + +/** +* @brief 获取精确上电时间 +* @return 系统上电至调用时刻的ns数 +* @details 从系统上电开始计时,不受时钟同步等操作的影响。 +*/ +CM_UINT64 CM_GetTick(void) +{ + /*- 变量初始化 */ + CM_UINT64 tick = 0u; + CM_TIMESPEC_T ts = { 0 }; + CM_INT8 ret = 0u; + /*- 获取精确时间 */ + ret = clock_gettime(CLOCK_MONOTONIC, &ts); + if(ret == -1) + { + MSCP_LOG_MSG("pipe error. errno = %d. %s\n", errno,strerror(errno)); + } + + /*- 将时间格式转换为ns数 */ + tick = ((CM_UINT64)ts.tv_sec * 1000000000u) + (CM_UINT64)ts.tv_nsec; + /*- 返回精确时间 */ + return tick; +} + +/** +* @brief 获取精确上电时间 +* @return 系统上电至调用时刻的s数 +* @details 从系统上电开始计时,不受时钟同步等操作的影响。 +*/ +CM_UINT64 CM_GetSecTick(void) +{ + /*- 变量初始化 */ + CM_UINT64 tick = 0u; + CM_TIMESPEC_T ts = { 0 }; + CM_INT8 ret = 0u; + /*- 获取精确时间 */ +#ifdef WIN32 + (void)timespec_get(&ts, TIME_UTC); +#elif QNX + ret = clock_gettime(CLOCK_MONOTONIC, &ts); + if(ret == -1) + { + MSCP_LOG_MSG("pipe error. errno = %d. %s\n", errno,strerror(errno)); + } +#endif + /*- 将时间格式转换为s数 */ + tick = ts.tv_sec; + /*- 返回精确时间 */ + return tick; +} + +/** +* @brief 获取精确的UTC时间 +* @return 系统上电至调用时刻的us数 +* @details 从系统上电开始计时,不受时钟同步等操作的影响。 +*/ +CM_UINT64 CM_GetUTCTick(void) +{ + int ret = 0; + /*- 变量初始化 */ + CM_UINT64 timestamp = 0u; + /* 获取本地utc时间 */ + struct timeval tv = { 0 }; +#ifdef WIN32 + struct timespec ts = { 0 }; + ret = clock_gettime(CLOCK_MONOTONIC, &ts); + tv.tv_sec = (CM_UINT32)ts.tv_sec; + tv.tv_usec = ts.tv_nsec/ (1000 * 1000); +#elif QNX + ret = gettimeofday(&tv, NULL); +#endif + if(0 == ret) + { + /* utc时间 单位 微秒 */ + timestamp = (CM_UINT64)tv.tv_sec*1000u*1000u + (CM_UINT64)tv.tv_usec; + } + else + { + timestamp = 0u; + } + /*- 返回精确微妙时间 */ + return timestamp; +} +/** +* @brief sleep延时 +* @param ms 要延时的ms数 +* @details 实际延时偏差在1ms量级 +*/ +void CM_Sleep(CM_UINT32 ms) +{ + /*- 延时指定时间 */ +#ifdef WIN32 + Sleep((unsigned long)ms); +#else + + CM_delayUs(ms * 1000u); +#endif +} +/*精准延时函数*/ +void CM_delayUs(CM_UINT64 us) +{ + CM_TIMESPEC_T tv; + tv.tv_sec = (time_t)CM_UNSIGNED_LONG_INT_EXP(us / 1000000U); + tv.tv_nsec = (long)CM_UNSIGNED_LONG_INT_EXP(us % 1000000U); + (void)select(0, NULL, NULL, NULL, &tv); +} diff --git a/TSCP/src/MSCP/CM/CM_Time.h b/TSCP/src/MSCP/CM/CM_Time.h new file mode 100644 index 0000000..5f5dbf2 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Time.h @@ -0,0 +1,52 @@ +/** +* @file CM_Time.h +* @brief 时钟相关处理 +* @author GT-BU +* @date 2021.08.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.08.01 V1.0 GT-BU 创建初始版本 +*
+*/ + +#ifndef CM_TIME_H_ +#define CM_TIME_H_ + +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*注意CM_UINT64需要用%lld打印*/ + CM_UINT64 CM_GetTick(void); + /** + * @brief 获取精确上电时间 + * @return 系统上电至调用时刻的s数 + * @details 从系统上电开始计时,不受时钟同步等操作的影响。 + */ + CM_UINT64 CM_GetSecTick(void); + /** + * @brief 获取精确的UTC时间 + * @return 系统上电至调用时刻的us数 + * @details 从系统上电开始计时,不受时钟同步等操作的影响。 + */ + CM_UINT64 CM_GetUTCTick(void); + /* 延时给定时间长度 ms */ + void CM_Sleep(CM_UINT32 ms); + + void CM_delayUs(CM_UINT64 us); + + CM_UINT64 CM_GetSecTick(void); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/MSCP/CM/CM_Types.h b/TSCP/src/MSCP/CM/CM_Types.h new file mode 100644 index 0000000..826b1d6 --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_Types.h @@ -0,0 +1,178 @@ +/** +@file CM_Types.h +@brief 本文件定义公共模块的基本数据类型定义 +公共模块由平台或应用调用 +@author 小型化安全计算机平台开发小组 +@version 1.0.0.0 +@date 2017-12-20 +*/ +#ifndef CM_TYPES_H +#define CM_TYPES_H +#include "MSCP_Define.h" +#include +#include +#include +#include +#include +#include + +#ifdef WIN32 + #include +#endif + +#ifdef VXWORKS +#include +#ifdef VXWORKS6_6 +#include +#include +#endif + +#ifdef VXWORKS5_5 +#endif +#endif +#ifdef QNX +#include +#include +#ifndef EOK +#define EOK 0 +#endif +#endif + + +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + /** + * @BasicType + * @brief 基本类型定义 + * + * Detailed description. + * @{ + */ + +#ifdef WIN32 +#define CM_Get_Error_No() {GetLastError()} +#endif + +#ifdef VXWORKS +#define CM_Get_Error_No() (errno) +#endif + +#ifdef QNX +#define CM_Get_Error_No() (errno) +#endif + +#ifndef IN +#define IN +#endif + +#ifndef OUT +#define OUT +#endif + +#ifndef INOUT +#define INOUT +#endif + + +typedef signed char CM_INT8; /**< 1字节有符号数 */ +typedef unsigned char CM_UINT8; /**< 1字节无符号数 */ +typedef signed short CM_INT16; /**< 2字节有符号数 */ +typedef unsigned short CM_UINT16; /**< 2字节无符号数 */ +typedef signed int CM_INT32; /**< 4字节有符号数 */ +typedef unsigned int CM_UINT32; /**< 4字节无符号数 */ + +typedef unsigned char CM_UCHAR; /**< 无符号字符型 */ +typedef char CM_CHAR; /**< 字符型 */ +typedef float CM_FLOAT32;/**< 4字节浮点型 */ +typedef double CM_FLOAT64;/**< 8字节浮点型 */ + +typedef int CM_BOOL; /**< 布尔类型 */ +typedef size_t CM_SIZE_T; /**< size_t型 */ + + +#ifndef CM_TRUE +#define CM_TRUE ((CM_BOOL)(1)) +#endif + +#ifndef CM_FALSE +#define CM_FALSE ((CM_BOOL)(0)) +#endif + +#ifndef CM_ERROR +#define CM_ERROR ((CM_INT32)(-1)) +#endif + +#ifndef CM_OK +#define CM_OK ((CM_UINT8)(0)) +#endif + +#define CM_NULL ((void*)(0)) + +#define CM_ABS(x) (((x)>0)?(x):(-(x))) + +typedef struct timespec CM_TIMESPEC_T; /**< 精确时间结构体 */ + +/*定义枚举型函数返回值*/ +typedef enum +{ + ENUM_CM_TRUE = 0x55u, /**< 真 */ + ENUM_CM_FALSE = 0xAAu, /**< 假 */ + ENUM_CM_NULL = 0x00u /**< 未知 */ +}ENUM_CM_RETURN; + + +#ifdef WIN32 +#define CM_PACKED +#endif + +#ifdef WIN32 + typedef unsigned long long int CM_UINT64; /**< 8字节无符号数 */ + typedef long long int CM_INT64; /**< 8字节有符号数 */ +#else/*其它操作系统*/ + typedef unsigned long long CM_UINT64; /**< 8字节无符号数 */ + typedef long long CM_INT64; /**< 8字节有符号数 */ +#endif + +#ifdef WIN32 + typedef unsigned CM_THREAD_T; /**< 线程 */ + typedef unsigned int CM_THREAD_FUNC_RETURN; /**< 线程函数返回值 */ + typedef unsigned int (__stdcall* CM_THREAD_FUNC_T)(void* args); /**< 线程函数 */ +#define CM_THREAD_CALL __stdcall +#endif +#ifdef QNX + typedef pthread_t CM_THREAD_T; /**< 线程 */ + typedef void* CM_THREAD_FUNC_RETURN; /**< 线程函数返回值 */ + typedef void*(*CM_THREAD_FUNC_T)(void* args); /**< 线程函数 */ +#define CM_THREAD_CALL +#endif +#ifdef VXWORKS + typedef int CM_THREAD_T; /**< 线程 */ + typedef int CM_THREAD_FUNC_RETURN; /**< 线程函数返回值 */ + typedef FUNCPTR CM_THREAD_FUNC_T; /**< 线程函数 */ +#define CM_THREAD_CALL +#endif + + +#define CM_UINT64_MAX ((CM_UINT64)(0xFFFFFFFFFFFFFFFFu)) +#define CM_INT64_MAX ((CM_INT64)(0x7FFFFFFFFFFFFFFFu)) +#define CM_INT64_MIN ((CM_INT64)(0x8000000000000000u)) +#define CM_UINT32_MAX (4294967295U) /**< CM_UINT32最大值 */ +#define CM_UINT16_MAX (65535U) /**< CM_UINT16最大值 */ +#define CM_UINT8_MAX (255) /**< CM_UINT8最大值 */ +#define CM_INT16_MIN (-32768) /**< CM_INT16最小值 */ +#define CM_INT16_MAX (32767) /**< CM_INT16最大值 */ +#define CM_INT32_MIN (-2147483647L - 1) /**< CM_INT32最小值 */ +#define CM_INT32_MAX (2147483647L) /**< CM_INT32最大值 */ +#define CM_FLOAT32_MAX (3.402823466e+38F) /**< CM_FLOAT32最大值 */ +#define CM_FLOAT64_MAX (1.7976931348623158e+308) /**< CM_FLOAT64最大值 */ + +#define CM_MILLION (1000000) /**< 一百万 */ +#define CM_UNSIGNED_MILLION (1000000u) /**< 无符号 一百万 */ +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + +#endif /**< _CM_TYPES_H */ + diff --git a/TSCP/src/MSCP/CM/CM_UDP.c b/TSCP/src/MSCP/CM/CM_UDP.c new file mode 100644 index 0000000..6c1ef2a --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_UDP.c @@ -0,0 +1,445 @@ +/** +* @file CM_UDP.c +* @brief UDP通信的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#include "CM_UDP.h" +#include "CM_Memory.h" +#include "PFM_Log.h" +#ifdef WIN32 +#include /* 组播 */ +#endif + +/** UDP服务已初始化标志 */ +static CM_BOOL s_UDP_Initialized = CM_FALSE; + +/** +* @brief 初始化UDP服务 +* @details 仅需初始化一次 +*/ +ENUM_CM_RETURN CM_UDP_Init(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /*- 初始化socket服务 */ + rt = CM_Socket_Init(); + + /*- 是否车初始化成功 */ + if (ENUM_CM_TRUE == rt) + { + /*- UDP初始化成功 */ + s_UDP_Initialized = CM_TRUE; + } + else + { + /*- 无处理 */ + } + + /*- 返回初始化结果 */ + return rt; +} + +/** +* @brief socket是否可读 +* @param sock soket +* @preturn 可读状态 +* - ENUM_CM_TRUE 可读 +* - ENUM_CM_FALSE 不可读 +*/ +ENUM_CM_RETURN CM_UDP_Is_Read_Ready(IN CM_SOCKET sock) +{ + /*- 变量初始化 */ + CM_INT32 sFd = 0; /* 文件描述符 */ + CM_INT32 sFlag = 0; /* 临时变量 */ + struct timeval timeover1 = { 0, 0 }; /* 时间 */ + fd_set readok; /* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + /*- UDP服务是否已经初始化 */ + if (CM_TRUE == s_UDP_Initialized) + { + /*- select查询sock的读状态 */ + ret = CM_Memset((void*) &readok, (CM_UINT8)0U, (size_t)(sizeof(fd_set)), (size_t)(sizeof(fd_set))); + timeover1.tv_sec = 0; + + timeover1.tv_usec = 0; + + FD_ZERO(&readok); + FD_SET(sock, &readok); + + sFd = (CM_INT32)select((sock + 1), &readok, NULL, NULL, &timeover1); + + /*- @alias 判断sock是否可读*/ + if ((sFd > 0) && (ENUM_CM_TRUE == ret)) + { + sFlag = FD_ISSET(sock, &readok); + if (0 != sFlag) + { + rt = ENUM_CM_TRUE; + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + /*- 无处理 */ + } + /*- 返回sock的可读状态 */ + return rt; +} + +/** +* @brief socket是否可写 +* @param sock soket +* @preturn 可写状态 +* - ENUM_CM_TRUE 可写 +* - ENUM_CM_FALSE 不可写 +*/ +ENUM_CM_RETURN CM_UDP_Is_Write_Ready(IN CM_SOCKET sock) +{ + /*- 变量初始化 */ + CM_INT32 sFd = 0; /* 文件描述符 */ + CM_INT32 sFlag = 0; /* 临时变量 */ + struct timeval timeover1 = { 0, 0 }; /* 时间 */ + fd_set writeok; /* 临时变量 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + /*- UDP服务是否已经初始化 */ + if (CM_TRUE == s_UDP_Initialized) + { + /*- select查询sock的写状态 */ + ret = CM_Memset((void*) &writeok, (CM_UINT8)0U, (size_t)(sizeof(fd_set)), (size_t)(sizeof(fd_set))); + timeover1.tv_sec = 0; + timeover1.tv_usec = 0; + FD_ZERO(&writeok); + FD_SET(sock, &writeok); + + sFd = (CM_INT32)select((CM_INT32)(sock + 1), NULL, &writeok, NULL, &timeover1); + + /*- @alias 判断sock是否可写 */ + if ((sFd > 0) && (ENUM_CM_TRUE == ret)) + { + sFlag = FD_ISSET(sock, &writeok); + if (0 != sFlag) + { + rt = ENUM_CM_TRUE; + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + rt = ENUM_CM_FALSE; + } + } + else + { + /*- 无处理 */ + } + /*- 返回sock的可写状态 */ + return rt; +} + +/** +* @brief 创建UDP socket +* @param pSock socket指针 +* @param isNonBlockMode 是否是非阻塞模式 CM_TRUE:非阻塞,CM_FALSE:阻塞 +* @param addrIP IP地址 +* @param portNumber 端口号 +* @param maddr 所属组播地址,0为不加入组播 +* @return 创建结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_UDP_Socket_Create(OUT CM_SOCKET* pSock, IN CM_BOOL isNonBlockMode, IN CM_UINT32 addrIP, IN CM_UINT16 portNumber, IN CM_UINT32 maddr, IN CM_UINT8 broadFlag) +{ + /*- 变量初始化 */ + CM_SOCKADDR_T addrHost; /* 主机地址 */ + CM_INT32 ret = 0; /* 临时结果 */ + CM_CHAR* tmpstr = NULL; /* 临时结果 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + ENUM_CM_RETURN retError = ENUM_CM_FALSE; /* 临时返回值 */ + struct ip_mreq multiCast; /* 组播配置 */ + CM_INT32 bCast = 1; + /*- 是否UDP服务未初始化或输入非法 */ + if ((CM_TRUE != s_UDP_Initialized) || (NULL == pSock)) + { + /*- 创建失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 创建UDP socket*/ + retError = CM_Memset((void*) &addrHost, (CM_UINT8)0U, (size_t)(sizeof(CM_SOCKADDR_T)), (size_t)(sizeof(CM_SOCKADDR_T))); + rt = CM_Socket_Create(pSock, CM_TRUE); + /*- 创建socket是否成功 */ + if ((ENUM_CM_TRUE == rt) && (ENUM_CM_TRUE == retError)) + { + /*- 绑定IP端口 */ + retError = CM_Memset((void*) &addrHost, (CM_UINT8)0U, (size_t)(sizeof(CM_SOCKADDR_T)), (size_t)(sizeof(CM_SOCKADDR_T))); + addrHost.sin_family = (CM_INT16)AF_INET; + addrHost.sin_port = htons(portNumber); +#ifdef WIN32 + addrHost.sin_addr.s_addr = addrIP; + if(1 == broadFlag) + { + /*广播*/ + setsockopt(*pSock, SOL_SOCKET, SO_BROADCAST, (void*)(&bCast), (unsigned int)sizeof(bCast)); + } + else + { + /*单播-组播*/ + } +#else + if(1u == broadFlag) + { + /*广播*/ + addrHost.sin_addr.s_addr = INADDR_ANY; + (void)setsockopt(*pSock, SOL_SOCKET, SO_BROADCAST, (void*)(&bCast), (unsigned int)sizeof(bCast)); + } + else + { + if (0u != maddr) + { + /*组播*/ + addrHost.sin_addr.s_addr = INADDR_ANY; + /*设置端口复用*/ + (void)setsockopt(*pSock,SOL_SOCKET,SO_REUSEPORT ,(void*)(&bCast), (unsigned int)sizeof(bCast)); + /*- 配置组播地址 */ + multiCast.imr_interface.s_addr = addrIP; + multiCast.imr_multiaddr.s_addr = maddr; + ret = setsockopt(*pSock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void*)(&multiCast), (unsigned int)sizeof(multiCast)); + } + else + { + /*单播*/ + addrHost.sin_addr.s_addr = addrIP; + } + } +#endif + ret = (CM_INT32)bind(*pSock, (CM_SOCKADDR*) &addrHost, (unsigned int)sizeof(CM_SOCKADDR)); + /*- 绑定是否成功 */ + if ((ret != CM_SOCKET_ERROR) && (ENUM_CM_TRUE == retError)) + { + /*- 设置socket的阻塞模式 */ +#ifdef WIN32 + ret = ioctlsocket(*pSock, (long)FIONBIO, (unsigned long *)&isNonBlockMode); +#else/*Linux Vxworks常用PIOX标准*/ + ret = ioctl(*pSock, FIONBIO, &isNonBlockMode); +#endif + /*- 设置socket的阻塞模式是否失败 */ + if (CM_SOCKET_ERROR == ret) + { + /*- 创建失败 */ + rt = ENUM_CM_FALSE; + } + else + { + /*- 创建成功 */ + rt = ENUM_CM_TRUE; + } + } + else + { + /*- 创建失败 */ + tmpstr = inet_ntoa(addrHost.sin_addr); + CM_NM_ASSERT(NULL != tmpstr, UDP_MODE,DARK_FAULT_CODE_FUN_ORDER_1,TSCP_DARK_ASSERT_1); + MSCP_LOG_MSG("band IP:%s:%u fail\n", tmpstr, portNumber); /* parasoft-suppress BD-PB-NOTINIT "WIN API 导致的误报" */ + rt = ENUM_CM_FALSE; + } + } + else + { + /*- 无处理 */ + } + } + /*- 返回创建结果 */ + return rt; +} + +/** +* @brief UDP发送(指定IP端口) +* @param sock socket +* @param pBuf 发送报文指针 +* @param bufSize 发送报文长度 +* @param addrDest 目的IP +* @param nPortDest 目的端口 +* @return 发送结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN CM_UDP_Send_Msg(IN CM_SOCKET sock, IN const CM_UINT8* pBuf, IN CM_INT32 bufSize, IN CM_UINT32 addrDest, IN CM_UINT16 nPortDest) +{ + /*- 变量初始化 */ + CM_SOCKADDR_T addr; /* 目的地址 */ +#ifdef WIN32 + size_t ret = 0; /* 函数返回值 */ +#else + ssize_t ret = 0; /* 函数返回值 */ +#endif + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + ENUM_CM_RETURN retError = ENUM_CM_FALSE; /* 函数返回值 */ + ENUM_CM_RETURN isReady = ENUM_CM_FALSE; /* 可写标志 */ + struct in_addr addr1; + + /*- UDP协议是否已经初始化 */ + if (CM_TRUE == s_UDP_Initialized) + { + /*- 获取socket可写状态 */ + isReady = CM_UDP_Is_Write_Ready(sock); + /*- socket是否可写 */ + if (ENUM_CM_TRUE == isReady) + { + /*- 生成目的地址 */ + retError = CM_Memset((void *) &addr, (CM_UINT8)0U, (size_t)(sizeof(addr)), (size_t)(sizeof(addr))); + + addr.sin_family = (CM_INT16)AF_INET; + addr.sin_port = htons(nPortDest); + addr.sin_addr.s_addr = addrDest; + + /*- 向目的地址发送报文 */ + ret = sendto(sock, (const void *)pBuf, (size_t)bufSize, 0, (const struct sockaddr*) &addr, (unsigned int)sizeof(CM_SOCKADDR_T)); + + /*- @alias 判断报文是否发送成功 */ + if (ret == CM_SOCKET_ERROR) + { + rt = ENUM_CM_FALSE; + MSCP_LOG_MSG("Want to send dest ip = %s, port = %d, UDP send errno = %d,%s\n",inet_ntoa(addr.sin_addr),nPortDest,errno,strerror(errno)); + } + else if (ret != bufSize) + { + rt = ENUM_CM_FALSE; + MSCP_LOG_MSG("s_UDP_Initialized != CM_TRUE\n"); + } + else if(ENUM_CM_FALSE == retError) + { + rt = ENUM_CM_FALSE; + MSCP_LOG_MSG("CM_Memset Error\n"); + } + else + { + rt = ENUM_CM_TRUE; + } + } + else + { + /*- 发送失败 */ + rt = ENUM_CM_FALSE; + MSCP_LOG_MSG("ENUM_CM_TRUE != isReady\n"); + } + } + else + { + MSCP_LOG_MSG("s_UDP_Initialized != CM_TRUE\n"); + } + /*- 返回发送结果 */ + return rt; +} + +/** +* @brief UDP发送(源IP、端口) +* @param sock socket +* @param pBuf 接收报文指针 +* @param BufSize 接收报文缓冲区大小 +* @param pAddrSrc 源IP +* @param pPortSrc 源端口 +* @return 收到报文长度 +* - 正整数 收到的报文长度 +* - 0 未收到报文 +* - -1 接收异常 +*/ +CM_INT32 CM_UDP_Recv_Msg(IN CM_SOCKET sock, OUT CM_UINT8 pBuf[], IN CM_INT32 BufSize, OUT CM_UINT32* pAddrSrc, OUT CM_UINT16* pPortSrc) +{ + /*- 变量初始化 */ + CM_SOCKADDR_T addr; /* 临时变量 */ +#ifdef WIN32 + int nFromLen = (int)sizeof(CM_SOCKADDR_T); /* 临时变量 */ +#else + CM_UINT32 nFromLen = (CM_UINT32)sizeof(CM_SOCKADDR_T); /* 临时变量 */ +#endif + CM_INT32 recvNum = 0; /* 接收长度 */ + CM_CHAR addrTmp[INET_ADDRSTRLEN] = { 0 };/*地址信息buff*/ + ENUM_CM_RETURN retError = ENUM_CM_FALSE; /* 函数返回值 */ + /*- 是否UDP协议未初始化或输入非法 */ + if ((CM_TRUE != s_UDP_Initialized) || (NULL == pBuf) || (0 >= BufSize)) + { + /*- 接收异常 */ + recvNum = -1; + CM_RE_ASSERT(0, NET_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_3); + } + else + { + retError = CM_Memset((void*) &addr, (CM_UINT8)0U, (unsigned long)(sizeof(addr)), (unsigned long)(sizeof(addr))); + /*- UDP接收 */ + recvNum = (CM_INT32)recvfrom(sock, (void *)pBuf, (unsigned long)BufSize, 0, (struct sockaddr*) &addr, &nFromLen); + + /*- 接收长度是否大于0,并且小于缓冲区的长度*/ + if ((recvNum > 0) && (recvNum < BufSize)) + { + /*- @alias 输出源IP */ + if (NULL != pAddrSrc) + { + *pAddrSrc = addr.sin_addr.s_addr; + } + else + { + /* 无处理 */ + } + + /*- @alias 出书源端口 */ + if (NULL != pPortSrc) + { + *pPortSrc = ntohs(addr.sin_port); + } + else + { + /* 无处理 */ + } + } + else + { + if (recvNum > 0) + { + /* 转换服务端ip地址 */ + if (NULL != inet_ntop(AF_INET, &addr.sin_addr, addrTmp, (size_t)INET_ADDRSTRLEN)) + { + MSCP_LOG_MSG("errno: %d , Error: %s , recvNum : %d\n", errno, strerror(errno), recvNum); + MSCP_LOG_MSG("Warning:udp recv ip %s port %u !!! The packet length was too long.\nerrno: %d , Error: %s , recvNum : %d\n" \ + ,addrTmp, ntohs(addr.sin_port), errno, strerror(errno), recvNum); + } + else + { + MSCP_LOG_MSG("Warning: Couldn't convert address to string!!! The packet length was too long.\nerrno: %d , Error: %s , recvNum : %d\n" \ + , errno, strerror(errno), recvNum); + } + } + else + { + /* 无处理 */ + } + /*- 接收异常 */ + recvNum = -1; + } + } + /*- 返回接收长度 */ + return recvNum; +} diff --git a/TSCP/src/MSCP/CM/CM_UDP.h b/TSCP/src/MSCP/CM/CM_UDP.h new file mode 100644 index 0000000..3eae6ed --- /dev/null +++ b/TSCP/src/MSCP/CM/CM_UDP.h @@ -0,0 +1,104 @@ +/** +* @file CM_UDP.h +* @brief UDP通信的封装 +* @author GT-BU +* @date 2021.02.01 +* @version V1.1 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2017.12.20 V1.0 MSCP项目组 创建初始版本 +*
2021.02.01 V1.1 GT-BU TSCP项目集成、更新 +*
+*/ +#ifndef CM_UDP_H +#define CM_UDP_H + +#include "CM_Socket.h" + +#ifdef VXWORKS +#include +#endif +#ifdef __cplusplus +extern "C" +{ +#endif /**< __cplusplus */ + + /** @brief UDP传输时分包的大小 */ +#define CM_UDP_LAN_MSG_SIZE_MAX (1472) /**< 局域网下每条UDP消息大小 */ +#define CM_UDP_WAN_MSG_SIZE_MAX (548) /**< 广域网下每条UDP消息大小 */ + + /** + * @brief CM_UDP_Init + * + * UDP初始化,仅需初始化一次. + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_UDP_Init(void); + + /** + * @brief CM_UDP_Create_Socket + * + * Detailed description. + * @param[out] pSocket + * @param[in] isNonBlockMode + * @param[in] pAddrIP + * @param[in] portNumber + * @param[in] maddr + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_UDP_Socket_Create(OUT CM_SOCKET* pSock, IN CM_BOOL isNonBlockMode, IN CM_UINT32 addrIP, IN CM_UINT16 portNumber, IN CM_UINT32 maddr, IN CM_UINT8 broadFlag); + + /** + * @brief CM_UDP_Send_Msg + * + * Detailed description. + * @param[in] pSock + * @param[in] addrDest + * @param[in] nPortDest + * @param[in] pBuf + * @param[in] bufSize + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_UDP_Send_Msg(IN CM_SOCKET sock, IN const CM_UINT8* pBuf, IN CM_INT32 bufSize, IN CM_UINT32 addrDest, IN CM_UINT16 nPortDest); + + /** + * @brief CM_UDP_Recv_Msg + * + * Detailed description. + * @param[in] sock + * @param[in] pBuf + * @param[in] BufSize传入时:表示传入的消息buf大小 + * @param[in] pAddrSrc + * @param[in] pPortSrc + * @return CM_INT32 返回接收消息大小, 返回-1表示失败 + */ + CM_INT32 CM_UDP_Recv_Msg(IN CM_SOCKET sock, OUT CM_UINT8 pBuf[], IN CM_INT32 BufSize, OUT CM_UINT32* pAddrSrc, OUT CM_UINT16* pPortSrc); + + /** + * @brief CM_UDP_Is_Read_Ready + * + * Sokcet是否可读. + * @param[in] sock + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_UDP_Is_Read_Ready(IN CM_SOCKET sock); + + /** + * @brief CM_UDP_Is_Write_Ready + * + * Sokcet是否可写. + * @param[in] sock + * @return ENUM_CM_RETURN + */ + ENUM_CM_RETURN CM_UDP_Is_Write_Ready(IN CM_SOCKET sock); + + +#ifdef __cplusplus +} + +#endif /**< __cplusplus */ + +#endif /**< _CM_UDP_H */ + diff --git a/TSCP/src/MSCP/DFM/DFM_DRV.h b/TSCP/src/MSCP/DFM/DFM_DRV.h new file mode 100644 index 0000000..c82b049 --- /dev/null +++ b/TSCP/src/MSCP/DFM/DFM_DRV.h @@ -0,0 +1,88 @@ +/* + * DFM_DRV.h + * + * Created on: 2021年8月24日 + * Author: happy + */ + +#ifndef SRC_MSCP_DFM_DFM_DRV_H_ +#define SRC_MSCP_DFM_DFM_DRV_H_ +#include "CM_Types.h" +#define LEDON (1u) +#define LEDOFF (0u) +void DFM_drv_Init(void); + +CM_UINT8 getBoardID(void); + +void DFM_ledRun(void); + +void DFM_ledError(void); +/** +* @brief 看门狗指示灯 +* +*/ +void DFM_ledMonitor(CM_UINT8 light); + +void DFM_ledMS(CM_UINT8 light); + +void DFM_ethernetState(void); + +void DFM_voltageState(void); + +CM_FLOAT64 DFM_Get_Tmp112(void); + +CM_FLOAT64 DFM_Get_Tmp117(void); + +void DFM_saftyOff(void); +/** +* @brief 读取板卡id +* @return 板卡id +* +*/ +CM_UINT8 DFM_getBoardID(void); + +/*- 十路输入 */ +CM_INT32 DFM_input(CM_UINT8 channel); +/*- 八路输出 */ +CM_INT32 DFM_output(CM_UINT8 channel, CM_UINT8 level); +/*- 切系按钮 */ +CM_INT32 DFM_switchButton(void); + +/*- 看门狗指示灯 */ +void DFM_ledMonitor(CM_UINT8 light); + +/*-通道电流电压读取*/ +CM_INT32 DFM_Read_ina3321(INOUT CM_INT32* channel_1_shunt, INOUT CM_FLOAT32* channel_1_bus, INOUT CM_INT32* channel_2_shunt, INOUT CM_FLOAT32* channel_2_bus, INOUT CM_INT32* channel_3_shunt, INOUT CM_FLOAT32* channel_3_bus); + +/*- 将信息写入到eeprom中 */ +CM_INT32 DFM_Write_eeprom(IN CM_INT32 board, IN CM_UINT8 wBuf[], IN CM_UINT32 len); + +/*- 从eeprom中读取信息 */ +CM_INT32 DFM_Read_eeprom(IN CM_INT32 board, OUT CM_UINT8 rBuf[], IN CM_UINT32 len); +/*- 读取cpu温度 */ +CM_INT32 DFM_Read_cputemp(void); +/*- 驱动周期发送log */ +void DFM_Drv_CycLog(void); +/** +* @brief 检测输入通道的状态 +* @param outPutBuf 接收IO输入的buf指针 +* @param len 指针缓冲区长度 +* @return 返回输出通道状态 取值范围:成功0,失败-1 +*/ +CM_INT32 DFM_GetIO_InPut(CM_UINT8 *outPutBuf,CM_UINT8 len); +/** +* @brief 检测输出通道的状态 +* @param level 前4通道的高低电平 取值范围:0~0xff +* @return 返回输出通道状态 取值范围:成功0,失败-1 +*/ +CM_INT32 DFM_SetIO_OutPut(CM_UINT8 level); +/* + * 读取系统版本号 + */ +ENUM_CM_RETURN DFM_GetQNX_Verion(CM_UINT8 *buf); + +/* + * 用来检测fec0 fec1 up/down状态 + */ +void DFM_Network_Check(void); +#endif /* SRC_MSCP_DFM_DFM_DRV_H_ */ diff --git a/TSCP/src/MSCP/DFM/DFM_DRV_QNX.c b/TSCP/src/MSCP/DFM/DFM_DRV_QNX.c new file mode 100644 index 0000000..937124d --- /dev/null +++ b/TSCP/src/MSCP/DFM/DFM_DRV_QNX.c @@ -0,0 +1,636 @@ +/* + * DFM_DRV_QNX.c + * + * Created on: 2021�?8�?24�? + * Author: happy + */ +#include "DFM_DRV.h" +#ifdef QNX +#include "imx8_drv_gpio.h" +#include "imx8_drv_i2c.h" +#include "CFM_Net.h" +#include "CM_Time.h" +#include "CM_Memory.h" +#include "DFM_Time.h" +#include "PFM_Log.h" +#include "PFM_Cfg.h" +#include "PFM_SelfCheck.h" +extern char drv_vsr[4]; +extern CM_UINT8 MSCP_DRV_VERION[4]; +CM_UINT8 g_OutIoLog = 0; +CM_UINT16 g_InIoLog = 0; +/** +* @brief 驱动初始化 +* +*/ +void DFM_drv_Init(void) +{ + CM_INT32 rtn = 0; + rtn = imx8_gpio_init(); + CM_NM_ASSERT(0 == rtn, QNX_DRV_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + rtn = imx8_i2c_init(); + CM_NM_ASSERT(0 == rtn, QNX_DRV_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + rtn = imx8_create_timer_pthread_25(); + CM_NM_ASSERT(0 == rtn, QNX_DRV_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + rtn = imx8_cpu_temp_init(); + CM_NM_ASSERT(0 == rtn, QNX_DRV_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_4); + MSCP_DRV_VERION[0] = drv_vsr[0]; + MSCP_DRV_VERION[1] = drv_vsr[1]; + MSCP_DRV_VERION[2] = drv_vsr[2]; + MSCP_DRV_VERION[3] = drv_vsr[3]; + + PFM_CFG_IfconfigIp(); + /*- 注册信号处理函数以及设置标准输出和错误输出为无缓冲 */ + PFM_InitSignalFunc(); + /* 延时等待任务创建 */ + CM_Sleep(3000u); + +} + +/** +* @brief 读取插箱板卡id +* @return 板卡插箱id +* +*/ +CM_UINT8 DFM_getBoardID(void) +{ + CM_UINT8 boardId = 0u; + boardId = imx8_read_boardID(); + return boardId; +} + +/** +* @brief 检测输入通道的状态 +* @param channel 通道数 取值范围:1~10 +* @return 返回输入通道状态 取值范围:0或1 +*/ +CM_INT32 DFM_input(CM_UINT8 channel) +{ + CM_INT32 state = 0; + CM_UINT16 value = 0; + CM_INT32 ret = -1; + if((channel >= 1) && (channel <= 10)) + { + /*- 变量初始化 */ + state = imx8_input_collect(channel); + value = 1UL << (channel-1); + /*- 从左到右第channel-1位等于value*/ + if(1 == state) + { + g_InIoLog = g_InIoLog | value; + } + else if(0 == state) + { + g_InIoLog = g_InIoLog & (~value); + } + else + { + MSCP_LOG_MSG("DFM_input Waring It's neither 0 nor 1 \n"); + } + /*MSCP_LOG_MSG("g_InIoLog = %x\n",g_InIoLog);*/ + ret = state; + } + else + { + MSCP_LOG_MSG("Illegal channel \n"); + ret = -1; + } + + return ret; +} + +/** +* @brief 检测输出通道的状态 +* @param channel 通道数 +* @param level 高低电平 +* @return 返回输出通道状态 +*/ +CM_INT32 DFM_output(CM_UINT8 channel, CM_UINT8 level) +{ + if((channel >= 1) && (channel <= 8)) + { + /*- 变量初始化 */ + CM_UINT8 value = 1UL << (channel-1); + /*- 从左到右第channel-1位等于value*/ + if(1 == level) + { + g_OutIoLog = g_OutIoLog | value; + } + else if(0 == level) + { + g_OutIoLog = g_OutIoLog & (~value); + } + else + { + MSCP_LOG_MSG("DFM_output Waring It's neither 0 nor 1 \n"); + } + /*MSCP_LOG_MSG("g_OutIoLog = %x\n",g_OutIoLog);*/ + return imx8_output(channel, level); + } + else + { + MSCP_LOG_MSG("Illegal channel \n"); + return -1; + } +} +/** +* @brief 检测输入通道的状态 +* @param outPutBuf 接收IO输入的buf指针 +* @param len 指针缓冲区长度 +* @return 返回输出通道状态 取值范围:成功0,失败-1 +*/ +CM_INT32 DFM_GetIO_InPut(CM_UINT8 *outPutBuf,CM_UINT8 len) +{ + /*- 变量初始化 */ + CM_INT32 ret = -1; + CM_INT32 value = -1; + CM_UINT8 i = 0u; + if((outPutBuf != NULL) && (len >= 10u)) + { + for(i = 0u;i < 10u;i++) + { + value = DFM_input(i + 1u); + if(-1 == value) + { + (void)CM_Memset(outPutBuf,0u,10u,len); + break; + } + else + { + outPutBuf[i] = value; + } + } + ret = 0; + } + else + { + ret = -1; + } + /*- 获取通道状态 */ + return ret; +} +/** +* @brief 检测输出通道的状态 +* @param level 前4通道的高低电平 取值范围:0~0xff +* @return 返回输出通道状态 取值范围:成功0,失败-1 +*/ +CM_INT32 DFM_SetIO_OutPut(CM_UINT8 level) +{ + /*- 变量初始化 */ + CM_INT32 ret = -1; + ret |= DFM_output(4,level&0x01); + ret |= DFM_output(3,(level>>1)&0x01); + ret |= DFM_output(2,(level>>2)&0x01); + ret |= DFM_output(1,(level>>3)&0x01); + /*- 获取通道状态 */ + return ret; +} +/** +* @brief run闪灯 +* +*/ +void DFM_ledRun(void) +{ + static CM_INT8 sFlag = 0x55; + CM_UINT8 lightState = 0x55U; + CM_UINT8 lightPs = 0x55; + if(0x55==sFlag) + { + imx8_led_REA_REB(1); + } + else + { + imx8_led_REA_REB(0); + } + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_RUNLIGHT, 1U, &lightState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_PSLIGHT, 1U, &lightPs); + sFlag =~sFlag; +} + +/** +* @brief 看门狗指示灯(2取) +* +*/ +void DFM_ledMonitor(CM_UINT8 light) +{ + CM_UINT8 lightState = 0u; + if(1u == light) + { + lightState = 0x55U; + } + else + { + lightState = 0xAAU; + } + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_2OLIGHT, 1U, &lightState); + (void)imx8_led_R_E(light); +} + + +/** +* @brief 主备指示灯 +* +*/ +void DFM_ledMS(CM_UINT8 light) +{ + CM_UINT8 lightState = 0u; + if(3u == light) + { + lightState = 0xAAU; + } + else if(1u == light) + { + lightState = 0x55U; + } + else + { + lightState = 0xFFU; + } + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_2XLIGHT, 1U, &lightState); + (void)imx8_led_M_S(light); +} +/** +* @brief error灯点亮(run灯) +* +*/ +void DFM_ledError(void) +{ + CM_UINT8 lightState = 0xAAU; + (void)imx8_led_REA_REB(2); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_RUNLIGHT, 1U, &lightState); +} + +/** +* @brief 检查网卡1到网卡4状态 +* +*/ +void DFM_ethernetState(void) +{ + CM_UINT8 state = 0xAAu; + static CM_UINT8 err_cut[4u] = {0u}; + static unsigned int (*ethernet_switch_state[4u])(void) =\ + {imx8_ethernet_switch_state_1_1, + imx8_ethernet_switch_state_1_2, + imx8_ethernet_switch_state_2_1, + imx8_ethernet_switch_state_2_2}; + CM_UINT8 i = 0u; + CM_INT32 rtn = 0; + PFM_LOG_SET_STOPTIMER(TSCP_DARK_ETHERNET); + for(i = 0u;i < 4u;i++) + { + rtn = ethernet_switch_state[i](); + if(1 == rtn) + { + err_cut[i] = 0u; + state = 0x55u; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_ETHERNET, 1u, &state); + } + else + { + err_cut[i]++; + if(err_cut[i] >= 3u) + { + /*宕机*/ + MSCP_LOG_MSG("SelfCheck-eth1-1:%d,eth1-2:%d,eth2-1:%d,eth2-2:%d\n",err_cut[0],err_cut[1],err_cut[2],err_cut[3]); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_ETHERNET, 1u, &state); + CM_NM_ASSERT(0, QNX_DRV_MODE, DARK_FAULT_CODE_FUN_ORDER_2, i + 1u); + } + else + { + /*- 无处理*/ + MSCP_LOG_MSG("SelfCheck-eth1-1:%d,eth1-2:%d,eth2-1:%d,eth2-2:%d\n",err_cut[0],err_cut[1],err_cut[2],err_cut[3]); + } + } + } + PFM_LOG_SET_STOPTIMER(TSCP_DARK_NULL); +} + +/** +* @brief 检查12V,24V,5V,3.3V,电压状态 +* +*/ +void DFM_voltageState(void) +{ + CM_UINT8 state = 0xAAu; + static CM_UINT8 err_cut[7u] = {0u}; + static unsigned int (*voltage_state[7u])(void) =\ + {imx8_5V_overvoltage_state, /*- 5V过压自检*/ + imx8_5V_undervoltage_state, /*- 5V欠压自检*/ + imx8_24V_voltage_state, /*- 24V电压状态自检*/ + imx8_Safe_gate_overvoltage_state_1, /*- 安全电压过压自检_1*/ + imx8_Safe_gate_undervoltage_state_1, /*- 安全电压欠压自检_1*/ + imx8_Safe_gate_overvoltage_state_2, /*- 安全电压过压自检_2*/ + imx8_Safe_gate_undervoltage_state_2}; /*- 安全电压欠压自检_2*/ + CM_UINT8 i = 0u; + CM_INT32 rtn = 0; + PFM_LOG_SET_STOPTIMER(TSCP_DARK_VOLTAGE); + for(i = 0u;i < 7u;i++) + { + rtn = voltage_state[i](); + if(1u == rtn) + { + /*- 正常 */ + err_cut[i] = 0u; + state = 0x55u; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_VOLTAGE, 1u, &state); + } + else + { + err_cut[i]++; + if(err_cut[i] >= 3u) + { + /*- 宕机 */ + MSCP_LOG_MSG("SelfCheck-5V_over:%d,5V_under:%d,24V_voltage:%d,Safe_over_1:%d,Safe_under_1:%d,Safe_over_2:%d,Safe_under_2:%d\n",err_cut[0],err_cut[1],err_cut[2],err_cut[3],err_cut[4],err_cut[5],err_cut[6]); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_VOLTAGE, 1u, &state); + CM_NM_ASSERT(0, QNX_DRV_MODE, DARK_FAULT_CODE_FUN_ORDER_3, i + 1u); + } + else + { + /*- 无处理*/ + MSCP_LOG_MSG("SelfCheck-5V_over:%d,5V_under:%d,24V_voltage:%d,Safe_over_1:%d,Safe_under_1:%d,Safe_over_2:%d,Safe_under_2:%d\n",err_cut[0],err_cut[1],err_cut[2],err_cut[3],err_cut[4],err_cut[5],err_cut[6]); + } + } + } + + PFM_LOG_SET_STOPTIMER(TSCP_DARK_NULL); +} + + +/** +* @brief 获取主机板板卡表面温度 +* +*/ + +CM_FLOAT64 DFM_Get_Tmp112(void) +{ + CM_FLOAT64 tmp = (CM_FLOAT64)0; + tmp = imx8_read_tmp112(); + return tmp; +} + +/** +* @brief 获取IO板卡表面温度 +* +*/ + +CM_FLOAT64 DFM_Get_Tmp117(void) +{ + CM_FLOAT64 tmp = (CM_FLOAT64)0; + tmp = imx8_read_tmp117(); + return tmp; +} + +/** +* @brief 安全关断 +* +*/ +void DFM_saftyOff(void) +{ + /*- 停止反转gpio定时器+加个反馈打印 */ + (void)printf("---------------- Safty Off ----------------\n"); + (void)imx8_safty_ethernet_off(); +} + +/** +* @brief 采集按钮状态 +* @return 采集的按钮状态 取值范围:1为按下 0为未按下 +*/ +CM_INT32 DFM_switchButton(void) +{ + /*- 变量初始化 */ + static CM_UINT32 s_birthCount = 0u; + static CM_INT32 s_State = 0; + CM_UINT32 birthCount = DFM_GetBirthCount(); + CM_UINT8 switchState = 0u; + /*- 采集按钮状态 */ + CM_INT32 ret = imx8_switch_button(); + /*- 如果周期发生改变或切系按钮状态发生改变 */ + if((birthCount != s_birthCount) || (ret != s_State)) + { + /*- 将切系状态发送给维护机*/ + s_birthCount = birthCount; + s_State = ret; + switchState = (1 == ret)?0x55u:0xAAu; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_SWITCHBUTTON, 1U, &switchState); + } + /*- 返回切系状态 */ + return ret; +} +/** +* @brief 通道电流电压读取 +* @param channel_1_shunt 核心3.3V电流 取值范围:-16~16 +* @param channel_1_bus 核心3.3V电压 取值范围:0~26 +* @param channel_2_shunt IO3.3V电流 取值范围:-16~16 +* @param channel_2_bus IO3.3V电压 取值范围:0~26 +* @param channel_3_shunt 核心5v电流 取值范围:-16~16 +* @param channel_3_bus 核心5v电压 取值范围:0~26 +* @return 返回结果 取值范围:0成功,-1失败 +*/ +CM_INT32 DFM_Read_ina3321(INOUT CM_INT32* channel_1_shunt, INOUT CM_FLOAT32* channel_1_bus, INOUT CM_INT32* channel_2_shunt, INOUT CM_FLOAT32* channel_2_bus, INOUT CM_INT32* channel_3_shunt, INOUT CM_FLOAT32* channel_3_bus) +{ + /*- 变量初始化 */ + CM_INT32 ret = -1; + struct ina3221 ina332_value; + /*- 防空检查 */ + if((channel_1_shunt == NULL) || (channel_1_bus == NULL) || (channel_2_shunt == NULL) || + (channel_2_bus == NULL) || (channel_3_shunt == NULL) || (channel_3_bus == NULL)) + { + ret = -1; + } + else + { + + /*- 通道电流电压读取 */ + ret = imx8_read_ina3221(&ina332_value); + *channel_1_shunt = ina332_value.channel_1_shunt; + *channel_1_bus = ina332_value.channel_1_bus; + *channel_2_shunt = ina332_value.channel_2_shunt; + *channel_2_bus = ina332_value.channel_2_bus; + *channel_3_shunt = ina332_value.channel_3_shunt; + *channel_3_bus = ina332_value.channel_3_bus; + } + return ret; +} + +/** +* @brief 将信息写入到eeprom中 +* @param board 取值范围:EEPROM_IN_BOARD 1 本cpu信息 + EEPROM_OUT_BOARD 2 cpu1调用对应io板信息 + 3 cpu2调用12R交换机板信息 + 4 cpu2调用8R交换机板信息 +* @param tx_buf 写入的信息 取值范围:非空 +* @param len 写入信息的长度 取值范围:0~0xffffffff +* @return 返回结果 取值范围:0成功,-1失败 +*/ +CM_INT32 DFM_Write_eeprom(IN CM_INT32 board, IN CM_UINT8 wBuf[], IN CM_UINT32 len) +{ + CM_INT32 ret = 0; + if(NULL != wBuf) + { + ret = imx8_write_eeprom(board, wBuf, len); + } + else + { + MSCP_LOG_MSG("wBuf is NULL\n"); + } + return ret; +} + +/** +* @brief 从eeprom中读取信息 +* @param board 取值范围:EEPROM_IN_BOARD 1 本cpu信息 + EEPROM_OUT_BOARD 2 cpu1调用对应io板信息 + 3 cpu2调用8R交换机板信息 + 4 cpu2调用12R交换机板信息 +* @param rBuf 读出的信息 取值范围:非空 +* @param len 读出信息数组的大小 取值范围:0~0xffffffff +* @return 返回结果 取值范围:0成功,-1失败 +* @details +* len的长度是多长,函数就从eeprom读多大,里面的信息以及信息大小,需要在工装写的时候就定好 +*/ +CM_INT32 DFM_Read_eeprom(IN CM_INT32 board, OUT CM_UINT8 rBuf[], IN CM_UINT32 len) +{ + CM_INT32 ret = 0; + ret = imx8_read_eeprom(board, rBuf, len); + return ret; +} + +/** +* @brief 读取cpu温度 +* @return 返回cpu温度 取值范围:0~105 +*/ +CM_INT32 DFM_Read_cputemp(void) +{ + /*- 变量初始化 */ + CM_INT32 temp = 0; + /*- 获取cpu温度 */ + temp = imx8_read_cpu_temp(); + /*- 返回cpu温度 */ + return temp; +} + +#endif + +/** +* @brief 驱动周期发送log +*/ +void DFM_Drv_CycLog(void) +{ + /*- 周期发送驱动log */ + MSCP_LOG_MSG("drv verson:%d.%d.%d.%d\n",drv_vsr[0],drv_vsr[1],drv_vsr[2],drv_vsr[3]); + (void)CFM_DarkLog_Storage(DARK_LOG_STRING, TSCP_DARK_DRVVERION, 4U, drv_vsr); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_IOOUTPUT, 1U, &g_OutIoLog); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_IOINPUT, 2U, &g_InIoLog); +} +/* +* @brief 将读取到的字符串版本号转换为数字 +* @param str 要分割的字符串 取值范围:非空 +* @param numbers 输出转换完成的版本号空间:非空 +* @return 返回结果 取值范围:无 + */ +void QNX_Version_to_Numbers(CM_UINT8 *str, CM_UINT8 numbers[]) +{ + /*- 变量初始化*/ + CM_CHAR segment[3]; + CM_UINT8 i = 0; + const CM_CHAR *delim = "."; + CM_CHAR *token; + + /* 按 . 分割字符串。*/ + token = strtok((CM_CHAR *)str, delim); + while (token != NULL && i < 4u) + { + (void)strncpy(segment, token, 2); + segment[2] = '\0'; /*将每个分割得到的段(即数字)复制到 segment 数组中,并确保其以空字符结尾。*/ + + /*转换*/ + numbers[i] = (CM_UINT8)atoi(segment); + + /*下移*/ + token = strtok(NULL, delim); + i++; + } +} +/* + * 读取系统版本号 + */ +ENUM_CM_RETURN DFM_GetQNX_Verion(CM_UINT8 *buf) +{ + /*- 变量初始化*/ + ENUM_CM_RETURN rtn = ENUM_CM_FALSE; + CM_INT32 fd = 0; + CM_SIZE_T get_size = 0; + CM_UINT8 i = 0u; + CM_UINT8 tmpbuf[20] = {0u}; + + if(buf != NULL) + { + /* 以只读模式打开*/ + fd = open("/etc/version", O_RDONLY); + if(-1 == fd) + { + MSCP_LOG_MSG("can't open version because: %s \n", strerror(errno)); + } + else + { + get_size = read(fd, tmpbuf, (CM_SIZE_T)10); + if(0 < get_size) + { + for(i = 0u; i < 10u; i++) + { + if(tmpbuf[i] == '\n') + { + tmpbuf[i] = '\0'; + break; + } + else + { + ; + } + } + QNX_Version_to_Numbers(tmpbuf, buf); + /* 读取成功 */ + rtn = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("read version fail get size = %d\n",get_size); + } + (void)close(fd); + } + } + else + { + MSCP_LOG_MSG("buf is NULL !!!\n"); + } + + + return rtn; +} + +/* + * 用来检测fec0 fec1 up/down状态 + */ +void DFM_Network_Check(void) +{ + char pFileBuf[1000] = { 0u }; + const char *filename = "networkcheck.txt"; + (void)system("drvtools -linkfec0 3 > networkcheck.txt"); + (void)system("drvtools -link9131 3 >> networkcheck.txt"); + + FILE *file = fopen(filename, "r"); + while (NULL != fgets(pFileBuf, sizeof(pFileBuf), file)) { + if('w' != pFileBuf[0]) + { + MSCP_LOG_MSG("%s", pFileBuf); + (void)printf("%s", pFileBuf); + } + else + { + /* 不做处理,过滤无用数据 */ + } + } + /* 关闭文件 */ + (void)fclose(file); + return; +} diff --git a/TSCP/src/MSCP/DFM/DFM_DRV_WIN.c b/TSCP/src/MSCP/DFM/DFM_DRV_WIN.c new file mode 100644 index 0000000..84064c3 --- /dev/null +++ b/TSCP/src/MSCP/DFM/DFM_DRV_WIN.c @@ -0,0 +1,147 @@ +/* + * DFM_DRV_WIN.c + * + * Created on: 2021年8月24日 + * Author: happy + */ +#include "DFM_DRV.h" +#if defined(WIN32) +#include "cp_interface.h" +/** +* @brief 驱动初始化 +* @return +ENUM_CM_TRUE 返回成功 +ENUM_CM_TRUE 返回失败 +* +*/ +void DFM_drv_Init(void) +{ + +} + +/** +* @brief 读取板卡id +* @return 板卡id +* +*/ +CM_UINT8 getBoardID() +{ + CM_UINT8 boardId = 0; + + return boardId; +} +/*- 十路输入 */ +CM_INT32 DFM_input(CM_UINT8 channel) +{ + +} +/*- 八路输出 */ +CM_INT32 DFM_output(CM_UINT8 channel, CM_UINT8 level) +{ + +} +/** +* @brief run闪灯 +* +*/ +void DFM_ledRun(void) +{ + if(LED_run == 0) + { + LED_run = 2; + } + else + { + LED_run = 0; + } +} + +/** +* @brief error灯点亮 +* +*/ +void DFM_ledError(void) +{ + LED_err = 1; +} +void DFM_ledMS(CM_UINT8 light) +{ + if(light == 1) + { + LED_MS = 2; + } + else + { + LED_MS = light; + } +} +/** +* @brief 检查网卡1到网卡4状态 +* +*/ +void DFM_ethernetState(void) +{ + +} + +/** +* @brief 检查12V,24V,5V,3.3V,电压状态 +* +*/ +void DFM_voltageState() +{ + +} + +/** +* @brief 获取板卡温度 +* +*/ +CM_FLOAT64 DFM_Get_Tmp112(void) +{ + return 25; +} +/** +* @brief 安全关断 +* +*/ +void DFM_saftyOff(void) +{ + /*- 停止反转gpio定时器+加个反馈打印 */ +} + +/** +* @brief 切系按钮 +* return 1为按下 +*/ +CM_INT32 DFM_switchButton(void) +{ + +} +/** +* @brief 通道电流电压读取 +* @param channel_1_shunt 核心3.3V电流 取值范围:-16~16 +* @param channel_1_bus 核心3.3V电压 取值范围:0~26 +* @param channel_2_shunt IO3.3V电流 取值范围:-16~16 +* @param channel_2_bus IO3.3V电压 取值范围:0~26 +* @param channel_3_shunt 核心5v电流 取值范围:-16~16 +* @param channel_3_bus 核心5v电压 取值范围:0~26 +* @return 返回结果 取值范围:0成功,-1失败 +*/ +CM_INT32 DFM_Read_ina3321(INOUT CM_INT32* channel_1_shunt, INOUT CM_FLOAT32* channel_1_bus, INOUT CM_INT32* channel_2_shunt, INOUT CM_FLOAT32* channel_2_bus, INOUT CM_INT32* channel_3_shunt, INOUT CM_FLOAT32* channel_3_bus) +{ + /*- 变量初始化 */ + CM_INT32 ret = -1; + return ret; +} + +CM_FLOAT64 DFM_Get_Tmp117(void) +{ + +} +/*- 从eeprom中读取信息 */ +CM_INT32 DFM_Read_eeprom(IN CM_INT32 board, OUT CM_UINT8 rBuf[], IN CM_UINT32 len) +{ + +} +#endif diff --git a/TSCP/src/MSCP/DFM/DFM_Time.c b/TSCP/src/MSCP/DFM/DFM_Time.c new file mode 100644 index 0000000..f64c2e3 --- /dev/null +++ b/TSCP/src/MSCP/DFM/DFM_Time.c @@ -0,0 +1,123 @@ +/** +* @file DFM_Time.c +* @brief Driver Function Module: 时钟相关功能 +* @details +* 本机精确时钟、上电周期号管理 +* 延时功能的实现 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "DFM_Time.h" +#include "CM_Time.h" +#include "PFM_Log.h" +#include "CM_Atomic.h" +/** 系统上电周期号(从系统上电开始计时,不受时钟同步等操作的影响) */ +CM_UINT32 g_MSCP_BirthCount; + +CM_ATOMIC CM_UINT64 g_CycTick = 0u; /**< CPU精确时钟 */ +CM_ATOMIC CM_INT64 g_CycBaseTick = 0; /* 周期运行基准时间 */ +CM_ATOMIC CM_UINT64 g_UTCBaseTick = 0u; /* UTC基准时间 -us*/ + + +/** +* @brief 获取进入周期运行距今的时间 +* @return 从系统首次进入周期运行值调用时刻经过的时间,单位:100us +*/ +CM_UINT64 DFM_GetCycTick(void) +{ + CM_UINT64 tick = 0u; + CM_UINT64 currTick = CM_GetTick(); + /*- 获取进入周期运行距今的时间 */ + if(((CM_INT64)currTick - CM_ATOMIC_LOAD(&g_CycBaseTick)) >= 0) + { + tick = CM_GetTick() - CM_ATOMIC_LOAD(&g_CycBaseTick); + } + else + { + MSCP_LOG_MSG("CM_GetTick():%llu - CM_ATOMIC_LOAD(&g_CycBaseTick):%llu < 0\n",currTick,CM_ATOMIC_LOAD(&g_CycBaseTick)); + + } + + /*- 返回 */ + return tick; +} + +/** +* @brief 获取进入周期运行距今的时间 +* @return 从系统首次进入周期运行值调用时刻经过的时间,单位:100us +*/ +CM_UINT64 DFM_GetUTCRelativeTick(void) +{ + /*- 获取进入周期运行距今的时间 */ + CM_UINT64 tick = (CM_GetUTCTick() - CM_ATOMIC_LOAD(&g_UTCBaseTick))/100; + /*- 返回 */ + return tick; +} +/** +* @brief 获取进入周期运行距今的时间 +* @return 从系统首次进入周期运行值调用时刻经过的时间,单位:us +*/ +CM_UINT64 DFM_GetUTCBaseTick(void) +{ + return CM_ATOMIC_LOAD(&g_UTCBaseTick); +} +/** +* @brief 延时到指定时刻 +* @param tarTick 目标精确时刻(ns数) +* @return 实际设定的延时us数 +* @details 本函数先获取当前精确时刻,再根据与目标精确时刻的差值确定sleep时间 +*/ +CM_UINT64 DFM_WaitUntill(IN CM_UINT64 tarTick) +{ + /*- 变量初始化 */ + CM_UINT64 leftTime = 0u; /* 剩余时间 */ + CM_UINT64 curTick = CM_GetTick(); /* 当前时刻 */ + /*- 计算剩余时间 */ + if(tarTick >= curTick) + { + leftTime = (tarTick - curTick) / 1000u; + } + else + { + MSCP_LOG_MSG("tarTick = %lld, curTick = %lld, leftTime = %lld\n", tarTick, curTick, leftTime); + CM_RE_ASSERT(0, TIME_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + } +#ifdef WIN32 + /*- @alias sleep延时等待剩余时间 */ + if (leftTime > 0) + { + Sleep((unsigned long)(leftTime / 1000)); + } +#else + /*- @alias sleep延时等待剩余时间 */ + if (leftTime == (CM_UINT32)leftTime) + { + CM_Sleep((CM_UINT32)leftTime/1000U); + } + else + { + MSCP_LOG_MSG("leftTime = %lld, (CM_UINT32)leftTime = %d\n", leftTime, (CM_UINT32)leftTime); + CM_RE_ASSERT(0, TIME_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + } +#endif + /*- 返回剩余时间 */ + return leftTime; +} + +/** +* @brief 获取上电周期号 +* @return 上电完成至调用时刻的周期数 +* @details 从1开始,不受时钟同步等的影响 +*/ +CM_UINT32 DFM_GetBirthCount(void) +{ + /*- 返回上电周期号 */ + return g_MSCP_BirthCount; +} diff --git a/TSCP/src/MSCP/DFM/DFM_Time.h b/TSCP/src/MSCP/DFM/DFM_Time.h new file mode 100644 index 0000000..43271c7 --- /dev/null +++ b/TSCP/src/MSCP/DFM/DFM_Time.h @@ -0,0 +1,67 @@ +/** +* @file DFM_Time.h +* @brief Driver Function Module: 时钟相关功能 +* @details +* 本机精确时钟、上电周期号管理 +* 延时功能的实现 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef DFM_TIME_H +#define DFM_TIME_H +#include "CM_Types.h" +#include "CM_Atomic.h" +#ifdef __cplusplus +extern "C" +{ +#endif +#include "DFM_Time.h" +#include "CM_Time.h" +#define NOW_USED_TIME ((CM_GetTick()-g_CycTick)/1000u) + + + extern CM_ATOMIC CM_UINT64 g_CycTick; /**< CPU精确时钟 */ + extern CM_ATOMIC CM_INT64 g_CycBaseTick; /**< 周期运行基准时间 */ + extern CM_ATOMIC CM_UINT64 g_UTCBaseTick; /* UTC基准时间 -us*/ + extern CM_UINT32 g_MSCP_BirthCount; + /* 延时至给定时刻 ns */ + CM_UINT64 DFM_WaitUntill(IN CM_UINT64 tarTick); + + CM_UINT64 DFM_GetCycTick(void); + /** + * @brief 获取进入周期运行距今的时间 + * @return 从系统首次进入周期运行值调用时刻经过的时间,单位:100us + */ + CM_UINT64 DFM_GetUTCRelativeTick(void); + + /** + * @brief 获取上电周期号 + * @return 本板卡从上电至被调用时刻的周期号 + * @note 上电周期号只与本板卡上电时间有关,固定周期自增,不受其他任何影响。 + */ + CM_UINT32 DFM_GetBirthCount(void); + + /** + * @brief 获取精确上电时间 + * @return 系统上电至调用时刻的s数 + * @details 从系统上电开始计时,不受时钟同步等操作的影响。 + */ + CM_UINT64 CM_GetSecTick(void); + + /** + * @brief 获取上电周期号 + * @return 上电完成至调用时刻的周期数 + * @details 从1开始,不受时钟同步等的影响 + */ + CM_UINT32 DFM_GetBirthCount(void); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/MSCP_APP_API.c b/TSCP/src/MSCP/MSCP_APP_API.c new file mode 100644 index 0000000..0316222 --- /dev/null +++ b/TSCP/src/MSCP/MSCP_APP_API.c @@ -0,0 +1,893 @@ +#include "stdarg.h" +#include "DFM_DRV.h" +#include "PFM_CPUUsage.h" +#include "PFM_SelfCheck.h" +#include "PFM_MemoryCheck.h" /* 内存自检 */ +#include "PFM_InputOutput.h" /* 内网透传接收 */ +#include "PFM_Log.h" +#include "PFM_Cfg.h" /* 版本信息 */ +#include "SFM_2x2.h" +#include "SFM_2oo2.h" +#include "SFM_Prtcl.h" +#include "CM_Time.h" +#include "CM_Memory.h" +#include "CFM_Net.h" +#include "PFM_RemoteUpdate.h" +#include "MSCP_APP_API.h" +#ifdef QNX +#include +#include +#include +#endif + +SERIAL_ID_FUNC p_Serial_Id_Func = NULL; +STATUS_COMMUNICATION_FUNC p_Status_Communication_Func = NULL; +SERIAL_OUT_ATS_VOBC p_Serial_OUT_ATSVOBC_Func = NULL; +SERIAL_IN_VOBC_ATS p_Serial_IN_VOBC_Func = NULL; +pTempAppfunc g_APP_FUNC_SET; +CM_UINT8 *p_gSfpInnetPara; +CM_UINT32 inParamLen; +CM_UINT8* inParam; +CM_UINT8 gCpuUsageParaFlag; +CM_UINT8 gSetTempFlag; +CM_FLOAT32 gMinTemperature; +CM_FLOAT32 gMaxTemperature; +/** 需应用注册的版本号 */ +extern STRU_APP_VERSON g_App_Verson; + +/** +* @brief 接收应用报文 +* @param ch 指定接收通道 +* @param pSrcName 源设备ID +* @param pSrcLogicID 源逻辑ID +* @param pLifeTime 报文剩余有效期 +* @param rxBuf 收到的应用报文数组 +* @param pRxLen 收到的应用报文长度 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用获得一条完整的应用报文 +* 应用每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT8 MSCP_AppRecvMsg(IN ENUM_MSCP_MSG_CHN_T ch, + OUT CM_UINT16 *pSrcName, OUT CM_UINT16 *pSrcLogicID, OUT CM_UINT8 *pLifeTime, + OUT CM_UINT8 *rxBuf, OUT CM_UINT32 *pRxLen, IN CM_UINT32 rxSize) +{ + /*- 变量初始化 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + + if ((NULL != pSrcName) + && (NULL != pSrcLogicID) + && (NULL != pLifeTime) + && (NULL != rxBuf) + && (NULL != pRxLen)) + { + /*- 输出置零 */ + *pSrcName = 0u; + *pSrcLogicID = 0u; + *pLifeTime = 0u; + /*- 通道类型 */ + switch (ch) + { + case ENUM_MSG_OUTNET_SAFE: /*-< 外网安全通信 */ + /*- 从外网安全协议读取应用接收报文 */ + *pRxLen = Prtcl_OutnetSafe_AppRecv(pSrcName, pSrcLogicID, pLifeTime, rxBuf, rxSize); + rt = 1u; + /*- 返回 */ + break; + case ENUM_MSG_INNET_SAFE: /*-< 内网安全通信 */ + *pSrcLogicID = 0u; + /*- 从内网安全协议读取应用接收报文 */ + *pRxLen = Prtcl_InnetSafe_AppRecv(pSrcName, pLifeTime, rxBuf, rxSize); + rt = 1u; + /*- 返回 */ + break; + case ENUM_MSG_INNET_MAINTENANCE: /*-< 远程部署功能内网安全通信 */ + *pSrcLogicID = 0u; + /*- 从内网安全协议读取应用接收报文 */ + *pRxLen = Prtcl_InnetSafe_RmRecv(pSrcName, pLifeTime, rxBuf, rxSize); + MSCP_LOG_BIN(rxBuf,*pRxLen); + rt = 1u; + /*- 返回 */ + break; + case ENUM_MSG_ERROR: /*-< 保留字 */ + /*- 宕机 */ + CM_ASSERT(0, APP_API_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + /*- 返回 */ + break; + default: + /*- 宕机 */ + CM_ASSERT(0, APP_API_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + /*- 返回 */ + break; + } + + } + else + { + /*- 无处理 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(APP_API_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1)); + } + /*- 返回 */ + return rt; +} + +/** +* @brief 发送应用报文 +* @param ch 指定发送通道 +* @param dstName 目的设备ID +* @param dstLogicID 目的逻辑ID +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用发送一条完整的应用报文 +* 应用每周期可多次调用本函数从而发送多个应用报文, +* 注意总发送长度不要超过周期通信总量限制 +*/ +CM_UINT8 MSCP_AppSendMsg(IN ENUM_MSCP_MSG_CHN_T ch, IN CM_UINT16 dstName, + IN CM_UINT16 dstLogicID, IN const CM_UINT8 *txBuf, IN CM_UINT32 txLen) +{ + /*- 变量初始化 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + + /*- 入口检查 */ + CM_ASSERT(NULL != txBuf, APP_API_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + /*- 通道类型 */ + switch (ch) + { + case ENUM_MSG_OUTNET_SAFE:/*-< 外网安全通信 */ + /*- 外网安全发送 */ + rt = Prtcl_OutnetSafe_AppSend(dstName, dstLogicID, txBuf, txLen); + /*- 返回 */ + break; + case ENUM_MSG_INNET_SAFE: /*-< 内网安全通信 */ + rt = Prtcl_InnetSafe_AppSend(dstName, txBuf, txLen); + /*- 返回 */ + break; + case ENUM_MSG_INNET_MAINTENANCE: /*-< 远程部署内网安全通信 */ + rt = Prtcl_InnetSafe_AppRmSend(txBuf, txLen); + MSCP_LOG_MSG("MSCP_AppSendMsg txLen = %d \n",txLen); + MSCP_LOG_BIN(txBuf,txLen); + /*- 返回 */ + break; + case ENUM_MSG_ERROR: /*- 保留字 */ + /*- 宕机 */ + CM_ASSERT(0, APP_API_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + /*- 返回 */ + break; + default: + /*- 宕机 */ + CM_ASSERT(0, APP_API_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); + /*- 返回 */ + break; + } + /*- 返回 */ + return rt; +} + +/** +* @brief 断开指定的外网安全通信链接 +* @param devID 设备ID +* @param logicID 逻辑ID +* @return 执行结果 +* - 1 成功 +* - 0 失败 +*/ +CM_UINT8 MSCP_Outnet_Disconnect(CM_UINT16 devID, CM_UINT16 logicID) +{ + return SFM_OutnetDisconnect(devID, logicID); +} + +/** +* @brief 接收外网透传报文 +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 MSCP_OutnetRaw_AppRecv(OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + return PFM_OutnetRaw_AppRecv(rxBuf, rxSize); +} + +/** +* @brief 发送外网透传报文 +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @param dstName 目的设备ID +* @param dstLogicID 目的逻辑ID +* @param type 类型 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用发送一条完整的应用报文 +* 每周期可多次调用本函数从而发送多个应用报文, +* 注意总发送长度不要超过周期通信总量限制 +*/ +CM_UINT8 MSCP_OutnetRaw_AppSend(IN const CM_UINT8* txBuf, IN CM_UINT32 txLen, IN CM_UINT16 dstName, IN CM_UINT16 dstLogicID, CM_UINT16 type) +{ + return PFM_OutnetRaw_AppSend(txBuf, txLen, dstName, dstLogicID, type); +} +/** +* @brief 接收内网透传报文 +* @param ch 通道ID +* @param pSrcName 源设备ID +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 MSCP_InnetRaw_AppRecv(IN CM_INT32 ch, OUT CM_UINT16* pSrcName, OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + return PFM_InnetRaw_AppRecv(ch, pSrcName, rxBuf, rxSize); +} +/** +* @brief 快速接收内网透传报文 +* @param ch 通道ID +* @param pSrcName 源设备ID +* @param rxBuf 收到的应用报文数组二级指针 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 MSCP_InnetRaw_AppRecv_Fast(IN CM_INT32 ch, OUT CM_UINT16* pSrcName, const OUT CM_UINT8** rxBuf) +{ + return PFM_InnetRaw_AppRecv_Fast(ch, pSrcName, rxBuf); +} + +/** +* @brief 接收内网透传辅助信息 +* @param ch 通道ID +* @param MainInfoBuf 本机辅助信息数组指针 +* @param PeerInfoBuf 邻机辅助信息数组指针 +* @param rxSize 接收缓冲区长度 +* @param PeerInfoLen 邻机辅助信息报文长度 +* @return 收到的本机辅助信息报文长度 +* @details +* 每周期调用一次,可获得全部辅助信息,再根据对应长度(8字节或12字节)解析时间戳或序列号 +*/ +CM_UINT32 MSCP_InnetRawHelpInfo_AppRecv(IN CM_INT32 ch, OUT CM_UINT8* MainInfoBuf,OUT CM_UINT8* PeerInfoBuf,IN CM_INT16 rxSize,OUT CM_UINT16 *PeerInfoLen) +{ + return PFM_InnetRawHelpInfo_AppRecv(ch,MainInfoBuf,PeerInfoBuf,rxSize,PeerInfoLen); +} + +/** +* @brief 发送内网透传报文 +* @param ch 通道ID +* @param dstName 目的设备ID +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用发送一条完整的应用报文 +* 每周期可多次调用本函数从而发送多个应用报文, +* 注意总发送长度不要超过周期通信总量限制 +*/ +CM_UINT8 MSCP_InnetRaw_AppSend(IN CM_INT32 ch, IN CM_UINT16 dstName, IN const CM_UINT8* txBuf, IN CM_UINT32 txLen) +{ + return PFM_InnetRaw_AppSend(ch, dstName, txBuf, txLen); +} + +/* +* @brief 获取上一周期的本系热备状态 +* @return 本系热备状态 +* - ENUM_2x2_OFFLINE 离线 +* - ENUM_2x2_PRE_MASTER 预升主 +* - ENUM_2x2_MASTER 主系 +* - ENUM_2x2_SLAVE 备系 +* @note +* 宕机状态下应用逻辑不会被执行, +* 所以应用本函数不可能返回“宕机”。 +* 其它状态下周期应用逻辑都会被执行, +* 但只有“主系”状态下本机的输出才会被真实输出, +* 在“离线”和“备系”状态下且本周期收到有效跟随数据时, +* 将在周期应用逻辑执行之前进行跟随数据覆盖。 +*/ +ENUM_2x2_STATE_T MSCP_GetLastLocal2x2State(void) +{ + return SFM_2x2_GetLastLocal2x2State(); +} + +/** +* @brief 获取对系上一周期的热备状态 +* @return 对系热备状态 +* - ENUM_2x2_SHUTDOWN 宕机 +* - ENUM_2x2_OFFLINE 离线 +* - ENUM_2x2_PRE_MASTER 预升主 +* - ENUM_2x2_MASTER 主系 +* - ENUM_2x2_SLAVE 备系 +* @note +* 与对系通信中断时默认对系状态为“宕机” +*/ +ENUM_2x2_STATE_T MSCP_GetLastPartner2x2State(void) +{ + return SFM_2x2_GetLastPartner2x2State(); +} + +/** +* @brief 设置跟随数据 +* @param[in] Data[] 跟随数据数组 +* @param[in] Len 跟随数据长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @note +* 无论本系是否为主,应用都应当每周期设置一次跟随数据; +* 本系非主时平台不会发送该数据,但会用于双系一致性的校验。 +* 跟随数据量最大为1024*1000字节。 +* @see :: APP_API_FollowUp +*/ +CM_UINT8 MSCP_SetFollowData(IN const CM_UINT8 Data[], IN CM_UINT32 Len) +{ + return SFM_2x2_SetFollowData(Data, Len); +} + +/** +* @brief 获取系统周期号 +* @return 当前的系统周期号 +* @note +* 一个固定周期自增的周期号; +* 对于2x2系统,2x2双系的周期号会被自动同步到与主系一致。 +*/ +CM_UINT32 MSCP_GetSysCount(void) +{ + return SFM_2x2_GetSysCount(); +} + +/** +* @brief 获取本机外网ID +* @return 本机外网ID +* @note 1字节类型+1字节ID,大端格式,来自INI配置文件。 +*/ +CM_UINT16 MSCP_GetOutnetID(void) +{ + return PFM_CFG_GetOutnetID(); +} + +/** +* @brief 获取本机内网ID +* @return 本机内网ID +* @note 1字节类型+1字节ID,大端格式,来自INI配置文件。 +*/ +CM_UINT16 MSCP_GetInnetID(void) +{ + return PFM_CFG_GetInnetID(); +} + +/** +* @brief 获取板卡ID +* @return 本机的板卡ID +* @note 板卡ID的宏定义参见本文件头部 +*/ +CM_UINT8 MSCP_GetBoardID(void) +{ + return PFM_CFG_GetBoardID(); +} + +/** +* @brief 获取CPUID +* @return CPUID +* @details +* CPUID根据配置文件确定 +*/ +CM_UINT8 MSCP_GetCpuID(void) +{ + return PFM_CFG_GetCpuID(); +} + +/** +* @brief 获取平台软件版本号和MD5码 +* @param[out] version 软件版本号 v[0].v[1].v[2].v[3] +*/ +void MSCP_GetBaseWareVer(OUT CM_UINT8 version[4]) +{ + /*- 输出平台软件版本 */ + version[0] = MSCP_SW_VERION[0]; + version[1] = MSCP_SW_VERION[1]; + version[2] = MSCP_SW_VERION[2]; + version[3] = MSCP_SW_VERION[3]; +} + +/** +* @brief 获取精确上电时间 +* @return 系统上电至调用时刻的ns数 +* @details 从系统上电开始计时,不受时钟同步等操作的影响。 +*/ +CM_UINT64 MSCP_GetTick(void) +{ + /*- 返回精确时间 */ + return CM_GetTick(); +} +/** +* @brief 获取UTC基准时间 +* @return 初始化记录UTC时间的us数 +* @details 从周期开始初始化固定值,不受时钟同步等操作的影响。 +*/ +CM_UINT64 MSCP_GetUTCTick(void) +{ + /*- 返回精确时间 */ + return DFM_GetUTCBaseTick(); +} +/** +* @brief 重写pSerial函数指针(串口扩展版使用),二次开发手册限制初始化时设置。 +*/ +void MSCP_SetSerial(SERIAL_ID_FUNC p) +{ + p_Serial_Id_Func = p; +} + +/** +* @brief 重写设备id和红蓝网通信情况。 +* @param p 注册的函数指针 取值范围(如果无需获取可以为NULL,如果获取则非空) +*/ +void MSCP_SetSrcId(STATUS_COMMUNICATION_FUNC p) +{ + p_Status_Communication_Func = p; +} + +/** +* @brief 变量内存自检注册初始化 +* @param pMemAddr注册变量的首地址 +* dataLen 注册变量的大小 +*/ +void MSCP_MemCheck_Register(CM_UINT8 *pMemAddr,CM_UINT32 dataLen) +{ + PFM_MemCheck_Register(pMemAddr,dataLen); +} + +/** +* @brief 初始化协议参数 +* @param inParamLen 长度 +* inParam 指针 +*/ +void MSCP_ParamData(CM_UINT8* pParam,CM_UINT32 ParamLen) +{ + inParamLen = ParamLen; + inParam = pParam; +} + +/** +* @brief 应用记录格式化字符串日志 +* @param filename 文件路径 +* @param func 函数名 +* @param line 行号 +* @param fmt 格式化字符串 +*/ +void MSCP_APP_LOG_MSG(IN const CM_CHAR *filename, IN const CM_CHAR *func, IN CM_INT32 line, IN const CM_CHAR* fmt, ...) +{ + /*- 变量初始化 */ + va_list argList; + CM_CHAR msgBuf[4096+256]; + CM_INT32 headLen = 0; + CM_INT32 msgLen = 0; + /*- 记录文件名、函数名、行号 */ + headLen = snprintf(msgBuf, sizeof(msgBuf), "as:"); + va_start(argList, (fmt)); + /*- 记录日志内容 */ + msgLen += vsnprintf(msgBuf + headLen, sizeof(msgBuf) - (CM_SIZE_T)headLen, fmt, argList); + va_end(argList); + +#ifdef WIN32 + printf("%s", msgBuf + headLen); +#endif + + (void)CFM_AppLog_Send((CM_UINT8*)msgBuf, headLen + msgLen); + /*CFM_AppStrLog_Send((CM_UINT8*)msgBuf, msgLen);*/ +} + +/** +* @brief 应用记录二进制日志 +* @param filename 文件路径 +* @param func 函数名 +* @param line 行号 +* @param Buf 二进制数组指针 +* @param Len 二进制数组长度 +*/ +void MSCP_APP_LOG_BIN(IN const CM_CHAR *filename, IN const CM_CHAR *func, IN CM_INT32 line, IN const CM_UINT8 *Buf, IN CM_UINT32 Len) +{ + + /*- 变量初始化 */ + CM_UINT32 i = 0u; + CM_UINT32 cut = (Len/CFM_INNET_LOG_BIN_SIZE) + (((Len%CFM_INNET_LOG_BIN_SIZE) > 0U)?(1u):(0u)); + CM_CHAR tmepBuf[CFM_INNET_LOG_SIZE]; + CM_UINT32 msgLen = 0u; + for(i = 0u;i < cut;i++) + { + (void)snprintf(tmepBuf, sizeof(tmepBuf), "ab:"); + msgLen = (((cut-i)>1u)?CFM_INNET_LOG_BIN_SIZE:(Len%CFM_INNET_LOG_BIN_SIZE)); + (void)CM_Memcpy(&tmepBuf[3],CFM_INNET_LOG_BIN_SIZE,&Buf[i*CFM_INNET_LOG_BIN_SIZE],(CM_SIZE_T)msgLen); + /*- 输出日志信息 */ + (void)CFM_BaseLog_Send((CM_UINT8*)tmepBuf, msgLen+3u); + } +} + +/** +* @brief 设置内网协议p_gSfpInnetPara +* @param p_gSfpInnetPara 指针 +*/ +void MSCP_SetSfpInnetPara(CM_UINT8* pSfpInnetData) +{ + p_gSfpInnetPara = pSfpInnetData; +} + +/** +* @brief 初始化应用函数入口 +*/ +void MSCP_SetAppFunc(pSetAppfunc pApp1, pSetAppfunc pApp2, pSetAppfunc pApp3, pSetAppfunc pApp4, pSetAppfunc pApp5) +{ + g_APP_FUNC_SET.pApp1 = pApp1; + g_APP_FUNC_SET.pApp2 = pApp2; + g_APP_FUNC_SET.pApp3 = pApp3; + g_APP_FUNC_SET.pApp4 = pApp4; + g_APP_FUNC_SET.pApp5 = pApp5; +} + +/** +* @brief 获取CPU合计使用率 +* @return 返回CPU合计使用率,范围为0到100 +*/ +CM_FLOAT32 MSCP_GetCpuTotalUsage(void) +{ + return PFM_GetTotalCpuUsagePara(); +} + +/** +* @brief 获取指定CPU使用率 +* @param 获取指定CPU使用率,值的范围为0到5 +* @return 返回指定CPU使用率,范围为0到100 +*/ +CM_FLOAT32 MSCP_GetCpuAppointUsage(CM_UINT8 CpuIndex) +{ + return PFM_GetAppointCpuUsagePara(CpuIndex); +} + +/** +* @brief 获取板卡温度 +* @return 返回板卡温度 +*/ +CM_FLOAT64 MSCP_GetTemperature(void) +{ + return DFM_Get_Tmp112(); +} + +/** +* @brief 设置板卡温度范围 +* @param MinTemperature 最低温度 +* @param MaxTemperature 最高温度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败 +*/ +CM_UINT8 MSCP_SetTemperature(CM_FLOAT32 MinTemperature , CM_FLOAT32 MaxTemperature) +{ + return PFM_SetTemperature(MinTemperature,MaxTemperature); +} + +/** +* @brief 内网透传解析功能-注册函数 +* @param RAW_ALGORITHM *p_Fun 注册函数 +* @return 无 +* @details 注册数组,需要注册8个函数,如果不需要解析请注册NULL。 +* @details 此函数应尽快执行完毕(耗时可能会引起丢包),并且不允许加打印。 +*/ +void MSCP_InnetRaw_analysisFun(RAW_ALGORITHM *p_Fun) +{ + CM_UINT8 i = 0U; + CM_INT32 RawNum = g_PFM_Cfg.Local_Cfg.Port_Innet_Raw_Num + g_PFM_Cfg.Local_Cfg.Port_Innet_Raw_Extend_Num; + for(i = 1u;i <= (CM_UINT8)RawNum;i++) + { + p_ALGORITHM_Fun[i] = p_Fun[i-1U]; + } +} +/** +* @brief 获取本机通用IP地址 +* @param 无 +* @return IP地址 +* @details 此函数仅允许在初始化阶段使用 +*/ +CM_UINT32 MSCP_GetLocal_ComIp(void) +{ + return (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_Com); +} +/** +* @brief 获取本机通用扩展IP地址 +* @param 无 +* @return IP地址 +* @details 此函数仅允许在初始化阶段使用 +*/ +CM_UINT32 MSCP_GetLocal_ComExtendIp(void) +{ + return (CM_UINT32)inet_addr(g_PFM_Cfg.Local_Cfg.IP_Com_Extend); +} +/** +* @brief 应用2取交换 +* @param pMyData 本机数据指针 取值范围:非空 +* @param DataLen 本剧数据长度 取值范围:0~0x7FFFFFFF +* @param pPeerData 邻机数据指针 取值范围:非空 +* @param DataSize 邻机数据缓冲区大小 取值范围:0~0xFFFFFFFF +* @return 收到的邻机数据长度 取值范围:0~0x7FFFFFFF +* @details 入参变量均由调用函数检测是否合法,此函数作用只为接口 +*/ +CM_INT32 MSCP_APP_2oo2(IN const CM_UINT8 * pMyData, IN CM_INT32 DataLen, OUT CM_UINT8 * pPeerData, IN CM_UINT32 DataSize) +{ + /*- 执行2取应用交换并且返回结果 */ + return (0x55u == g_PFM_Cfg.M_2oo2_Enable) ? SFM_2oo2_Currency_App(pMyData, DataLen, pPeerData, DataSize) : 0; +} + +/** +* @brief 获取板卡运行状态 +* @return 板卡运行状态 +* - ENUM_BOARDSTATE_ERROR = 0, 未知状态 +* - ENUM_BOARDSTATE_RUN = 1, 运行状态 +* - ENUM_BOARDSTATE_EXIT = 2, 退出运营状态 +* - ENUM_BOARDSTATE_UPDATE = 3, 故障可更新文件状态 +* - ENUM_BOARDSTATE_DEFAULT = 4, 故障不可更新文件状态 +*/ +ENUM_BOARD_STATE_T MSCP_GetBoardState(void) +{ + return PFM_GetBoardState(); +} + +/** +* @brief 设置板卡运行状态 +* @param state 板卡运行状态 +* - ENUM_BOARDSTATE_ERROR = 0, 未知状态 +* - ENUM_BOARDSTATE_RUN = 1, 运行状态 +* - ENUM_BOARDSTATE_EXIT = 2, 退出运营状态 +* - ENUM_BOARDSTATE_UPDATE = 3, 故障可更新文件状态 +* - ENUM_BOARDSTATE_DEFAULT = 4, 故障不可更新文件状态 +*/ +void MSCP_SetBoardState(ENUM_BOARD_STATE_T state) +{ + PFM_SetBoardState_APP(state); +} + + +/** +* @brief 应用将应用版本号写入平台 +* @param APP_VERSION 版本号 取值范围:非空 +*/ +void MSCP_SetAppVersion(IN CM_UINT8 APP_VERSION[]) +{ + /*- 入参不为空 */ + if(NULL != APP_VERSION) + { + /*- @alias 应用将应用版本号写入平台 */ + if(g_App_Verson.registerVerson[0].flag == 0u) + { + g_App_Verson.registerVerson[0].flag = 1u; + g_App_Verson.versonNumber++; + } + else + { + /*- 无处理 */ + } + g_App_Verson.registerVerson[0].verson[0] = APP_VERSION[0]; + g_App_Verson.registerVerson[0].verson[1] = APP_VERSION[1]; + g_App_Verson.registerVerson[0].verson[2] = APP_VERSION[2]; + g_App_Verson.registerVerson[0].verson[3] = APP_VERSION[3]; + } + else + { + /*- 无处理 */ + MSCP_LOG_MSG("MSCP_SetAppVersion is NULL\n"); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(APP_API_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1)); + } + +} + +/** +* @brief 应用将FS版本号写入平台 +* @param FS_VERSION FS数据版本号 取值范围:非空 +*/ +void MSCP_SetFsVersion(IN CM_UINT8 FS_VERSION[]) +{ + /*- 入参不为空 */ + if(NULL != FS_VERSION) + { + /*- @alias 应用将FS版本号写入平台 */ + if(g_App_Verson.registerVerson[1].flag == 0u) + { + g_App_Verson.registerVerson[1].flag = 1u; + g_App_Verson.versonNumber++; + } + else + { + /*- 无处理 */ + } + g_App_Verson.registerVerson[1].verson[0] = FS_VERSION[0]; + g_App_Verson.registerVerson[1].verson[1] = FS_VERSION[1]; + g_App_Verson.registerVerson[1].verson[2] = FS_VERSION[2]; + g_App_Verson.registerVerson[1].verson[3] = FS_VERSION[3]; + } + else + { + /*- 无处理 */ + MSCP_LOG_MSG("MSCP_SetFsVersion is NULL\n"); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(APP_API_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1)); + } + +} + +/** +* @brief 应用将Scade版本号写入平台 +* @param SCADE_VERSION Scade数据版本号 取值范围:非空 +*/ +void MSCP_SetScadeVersion(IN CM_UINT8 SCADE_VERSION[]) +{ + /*- 入参不为空 */ + if(NULL != SCADE_VERSION) + { + /*- @alias 应用将Scade版本号写入平台 */ + if(g_App_Verson.registerVerson[2].flag == 0u) + { + g_App_Verson.registerVerson[2].flag = 1u; + g_App_Verson.versonNumber++; + } + else + { + /*- 无处理 */ + } + g_App_Verson.registerVerson[2].verson[0] = SCADE_VERSION[0]; + g_App_Verson.registerVerson[2].verson[1] = SCADE_VERSION[1]; + g_App_Verson.registerVerson[2].verson[2] = SCADE_VERSION[2]; + g_App_Verson.registerVerson[2].verson[3] = SCADE_VERSION[3]; + } + else + { + /*- 无处理 */ + MSCP_LOG_MSG("MSCP_SetScadeVersion is NULL\n"); + } + + +} + +/** +* @brief 获取平台暂存的红蓝网设备信息 +* @param RedBuf 红网缓冲区 取值范围:非空 +* @param BlueBuf 篮网缓冲区 取值范围:非空 +* @details RCI用于获取平台暂存的红蓝网设备信息,长度大于等于16*18 +*/ +void MSCP_GetRciTempBuf(OUT CM_UINT16* RedBuf, OUT CM_UINT16* BlueBuf) +{ + PFM_GetRciTempBuf(RedBuf,BlueBuf); +} + +/** +* @brief 获得是否为在因为切系后,主系降为离线的3周期内的标志。 +* @return 是否为切系后的5周期 +* - 0 不在切系后的5周期内 +* - 1 在切系后的5周期内 +* @details 此切系状态用于应用获取到离线时判断原因 +*/ +CM_UINT8 MSCP_2x2_GetSwitchFlag(void) +{ + /*- 获取是否切系标志位 */ + return 0;//SFM_2x2_GetSwitchFlag(); +} + +/** +* @brief 应用配置ip、端口、使能等可配置变量 +* @param app_data 应用配置结构体 取值范围:非空 +* @details 此配置用来代替main_base.ini +*/ +void MSCP_Set_APP_ConfigData(STRU_APP_CFG_T *app_data) +{ + /*- 应用配置ip、端口、使能等可配置变量 */ + PFM_Set_APP_ConfigData(app_data); +} + +/** +* @brief 查询链路状态 +* @param destType 对方设备类型 取值范围:0~0xff +* @param destId 对方设备ID 取值范围:0~0xff +* @param logId 逻辑id(若卡斯柯的CI与VOBC通信,需要填写VOBC的站台号。其他的系统填0。) 取值范围:0~0xff +* @return 安全通道链路状态 +* 0:不存在该条链路,返回错误 +* 0x17:链路在数据传输正常状态 +* 0x2b:链路在通信中断状态 +* 0x33:链路在准备建立链接状态 +* 0x4e:链路在等待建立链接状态 +* 0x01: 表示刷新无用的链路 +*/ +CM_UINT8 MSCP_GetLnkStatus(CM_UINT8 destType,CM_UINT8 destId,CM_UINT16 logId) +{ + /*- 获取安全通道链路状态 */ + return SFM_GetLnkStatus(destType, destId, logId); +} + +/** +* @brief 重写输出ats转车数据备用通道判断函数(串口扩展版)。 +* @param p 注册的函数指针 取值范围(如果无需获取可以为NULL,如果获取则非空) +* @details 此函数指针为一个返回值,三个参数。 +* 返回值ENUM_CM_RETURN 0x55或0xaa +* 参数1入参CM_UINT16 +* 参数2出参CM_UINT16* +* 参数3出参CM_UINT16* +*/ +void MSCP_SetOutAtsVobcFunc(SERIAL_OUT_ATS_VOBC p) +{ + /*- 重写输出ats转车数据备用通道判断函数 */ + p_Serial_OUT_ATSVOBC_Func = p; +} + +/** +* @brief 重写输入ats转车数据备用通道判断函数(串口扩展版)。 +* @param p 注册的函数指针 取值范围(如果无需获取可以为NULL,如果获取则非空) +* @details 此函数指针为一个返回值,三个参数。 +* 返回值ENUM_CM_RETURN 0x55或0xaa +* 参数1入参CM_UINT16 +*/ +void MSCP_SetInVobcAtsFunc(SERIAL_IN_VOBC_ATS p) +{ + /*- 重写输入ats转车数据备用通道判断函数 */ + p_Serial_IN_VOBC_Func = p; +} + +/** +* @brief 读取插箱板卡id(此id为交换机版的拨码) +* @return 返回插箱板卡id 取值范围:0~0xFF +* @details 其中高4位bits为插箱id 低四位bits为板卡id +*/ +CM_UINT8 MSCP_GetDrvBoardID(void) +{ + /*- 获取插箱板卡id */ + return DFM_getBoardID(); +} +/** +* @brief 接收外网心跳报文(自检信息) +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 MSCP_OutNetHeart_AppRecv(OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + return PFM_OutnetHeart_AppRecv(rxBuf, rxSize); +} + +/** +* @brief 获取两系输入io状态 +* @param ioInput 接收缓冲区 取值范围:非空 +* @param size 缓冲区大小 取值范围:大于40字节 +* @return ENUM_CM_TRUE 成功,ENUM_CM_FALSE 失败 +* @details 入参变量均由下层函数检测是否合法,此函数作用只为接口 +* 数据内容为:A1(10字节)+A2(10字节)+B1(10字节)+B2(10字节) +*/ +ENUM_CM_RETURN MSCP_2x2_GetLastIoInput(OUT CM_UINT8* ioInput,CM_UINT16 size) +{ + /*- 获取两系输入io状态并返回结果 */ + return SFM_2x2_GetLastIoInput(ioInput,size); +} + +/** +* @brief 设置捕获信号(初始化调用) +*/ +void MSCP_SetSignal(CM_INT32 SIGNAL) +{ + PFM_SetSignal(SIGNAL); +} + +/** +* @brief 设置应用运行步骤(周期中调用) +*/ +void MSCP_SetAppCheck(CM_INT32 appCheck) +{ + PFM_SetAppCheck(appCheck); +} diff --git a/TSCP/src/MSCP/MSCP_APP_API.h b/TSCP/src/MSCP/MSCP_APP_API.h new file mode 100644 index 0000000..a7a25eb --- /dev/null +++ b/TSCP/src/MSCP/MSCP_APP_API.h @@ -0,0 +1,475 @@ +/** +* @file MSCP_APP_API.h +* @brief 平台为应用提供的接口 +* @details 一些由平台实现,由应用调用的各种API +* @author GT-BU 平台软件组 +* @date 2021.3.1 +* @version V1.0 +* @copyright TCT +* @note 本文件采用doxygen格式编写,用于生成平台对外接口说明书 +*/ +#ifndef MSCP_APP_API_H +#define MSCP_APP_API_H +#include "CM_Types.h" +#include "MSCP_APP_Interface.h" +#include "PFM_Cfg.h" +#ifdef __cplusplus +extern "C" +{ +#endif + + + + /** + * @brief 接收应用报文 + * @param[in] ch 指定接收通道 \n + * @ref ENUM_MSG_OUTNET_SAFE 外网安全通信通道 \n + * @ref ENUM_MSG_INNET_SAFE 内网安全通信通道 \n + * @ref ENUM_MSG_INNET_RAW 内网透传通信通道 \n + * @ref 其它 预留 + * @param[out] *pSrcName 源设备ID + * @param[out] *pSrcLogicID 源逻辑ID \n + * @ref 0 默认值(源设备不适用逻辑ID时) \n + * @ref 其它 有效值 + * @param[out] *pLifeTime 报文剩余有效期 + * @param[out] rxBuf[] 收到的应用报文数组 + * @param[out] *pRxLen 收到的应用报文长度 + * @param[in] rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 + * @return 函数执行结果 + * - 1 成功 + * - 0 失败(输入非法) + * @note + * 每次调用获得一条完整的应用报文 + * 应用每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 + */ + CM_UINT8 MSCP_AppRecvMsg(IN ENUM_MSCP_MSG_CHN_T ch, + OUT CM_UINT16* pSrcName, OUT CM_UINT16* pSrcLogicID, OUT CM_UINT8* pLifeTime, + OUT CM_UINT8* rxBuf, OUT CM_UINT32* pRxLen, IN CM_UINT32 rxSize); + + /** + * @brief 发送应用报文 + * @param[in] ch 指定发送通道 \n + * @ref ENUM_MSG_OUTNET_SAFE 外网安全通信通道 \n + * @ref ENUM_MSG_INNET_SAFE 内网安全通信通道 \n + * @ref ENUM_MSG_INNET_RAW 内网透传通信通道 \n + * @ref 其它 预留 + * @param[in] dstName 目的设备ID + * @param[out] dstLogicID 目的逻辑ID \n + * @ref 0 默认值(源设备不适用逻辑ID时) \n + * @ref 其它 有效值 + * @param[out] txBuf[] 发送的应用报文数组 + * @param[out] txLen 发送的应用报文长度 + * @return 函数执行结果 + * - 1 成功 + * - 0 失败(输入非法) + * @note + * 每次调用发送一条完整的应用报文 + * 应用每周期可多次调用本函数从而发送多个应用报文, + * 注意总发送长度不要超过周期通信总量限制 + */ + CM_UINT8 MSCP_AppSendMsg(IN ENUM_MSCP_MSG_CHN_T ch, IN CM_UINT16 dstName, + IN CM_UINT16 dstLogicID, IN const CM_UINT8* txBuf, IN CM_UINT32 txLen); + + /** + * @brief 断开指定的外网安全通信链接 + * @param[in] devID 设备ID + * @param[in] logicID 逻辑ID + * @return 执行结果 + * - 1 成功 + * - 0 失败 + */ + CM_UINT8 MSCP_Outnet_Disconnect(CM_UINT16 devID, CM_UINT16 logicID); + + /** + * @brief 接收外网透传报文 + * @param rxBuf 收到的应用报文数组 + * @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 + * @return 收到的应用报文长度 + * @details + * 每次调用获得一条完整的应用报文 + * 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 + */ + CM_UINT32 MSCP_OutnetRaw_AppRecv(OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize); + + /** + * @brief 发送外网透传报文 + * @param txBuf 发送的应用报文数组 + * @param txLen 发送的应用报文长度 + * @param dstName 目的设备ID + * @param dstLogicID 目的逻辑ID + * @param type 类型 + * @return 函数执行结果 + * - 1 成功 + * - 0 失败(输入非法) + * @details + * 每次调用发送一条完整的应用报文 + * 每周期可多次调用本函数从而发送多个应用报文, + * 注意总发送长度不要超过周期通信总量限制*/ + CM_UINT8 MSCP_OutnetRaw_AppSend(IN const CM_UINT8* txBuf, IN CM_UINT32 txLen, IN CM_UINT16 dstName, IN CM_UINT16 dstLogicID, CM_UINT16 type); + /** + * @brief 接收内网透传报文 + * @param ch 通道ID + * @param pSrcName 源设备ID + * @param rxBuf 收到的应用报文数组 + * @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 + * @return 收到的应用报文长度 + * @details + * 每次调用获得一条完整的应用报文 + * 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 + */ + CM_UINT32 MSCP_InnetRaw_AppRecv(IN CM_INT32 ch, OUT CM_UINT16* pSrcName, OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize); + /** + * @brief 快速接收内网透传报文 + * @param ch 通道ID + * @param pSrcName 源设备ID + * @param rxBuf 收到的应用报文数组二级指针 + * @return 收到的应用报文长度 + * @details + * 每次调用获得一条完整的应用报文 + * 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 + */ + CM_UINT32 MSCP_InnetRaw_AppRecv_Fast(IN CM_INT32 ch, OUT CM_UINT16* pSrcName, const OUT CM_UINT8** rxBuf); + /** + * @brief 接收内网透传辅助信息 + * @param ch 通道ID + * @param MainInfoBuf 本机辅助信息数组指针 + * @param PeerInfoBuf 邻机辅助信息数组指针 + * @param rxSize 接收缓冲区长度 + * @param PeerInfoLen 邻机辅助信息报文长度 + * @return 收到的本机辅助信息报文长度 + * @details + * 每周期调用一次,可获得全部辅助信息,再根据对应长度(8字节或12字节)解析时间戳或序列号 + */ + CM_UINT32 MSCP_InnetRawHelpInfo_AppRecv(IN CM_INT32 ch, OUT CM_UINT8* MainInfoBuf,OUT CM_UINT8* PeerInfoBuf,IN CM_INT16 rxSize,OUT CM_UINT16 *PeerInfoLen); + /** + * @brief 发送内网透传报文 + * @param ch 通道ID + * @param dstName 目的设备ID + * @param txBuf 发送的应用报文数组 + * @param txLen 发送的应用报文长度 + * @return 函数执行结果 + * - 1 成功 + * - 0 失败(输入非法) + * @details + * 每次调用发送一条完整的应用报文 + * 每周期可多次调用本函数从而发送多个应用报文, + * 注意总发送长度不要超过周期通信总量限制 + */ + CM_UINT8 MSCP_InnetRaw_AppSend(IN CM_INT32 ch, IN CM_UINT16 dstName, IN const CM_UINT8* txBuf, IN CM_UINT32 txLen); + + /* + * @brief 获取上一周期的本系热备状态 + * @return 本系热备状态 + * - ENUM_2x2_OFFLINE 离线 + * - ENUM_2x2_PRE_MASTER 预升主 + * - ENUM_2x2_MASTER 主系 + * - ENUM_2x2_SLAVE 备系 + * @note + * 宕机状态下应用逻辑不会被执行, + * 所以应用本函数不可能返回“宕机”。 + * 其它状态下周期应用逻辑都会被执行, + * 但只有“主系”状态下本机的输出才会被真实输出, + * 在“离线”和“备系”状态下且本周期收到有效跟随数据时, + * 将在周期应用逻辑执行之前进行跟随数据覆盖。 + */ + ENUM_2x2_STATE_T MSCP_GetLastLocal2x2State(void); + + /** + * @brief 获取对系上一周期的热备状态 + * @return 对系热备状态 + * - ENUM_2x2_SHUTDOWN 宕机 + * - ENUM_2x2_OFFLINE 离线 + * - ENUM_2x2_PRE_MASTER 预升主 + * - ENUM_2x2_MASTER 主系 + * - ENUM_2x2_SLAVE 备系 + * @note + * 与对系通信中断时默认对系状态为“宕机” + */ + ENUM_2x2_STATE_T MSCP_GetLastPartner2x2State(void); + + /** + * @brief 设置跟随数据 + * @param[in] Data[] 跟随数据数组 + * @param[in] Len 跟随数据长度 + * @return 函数执行结果 + * - 1 成功 + * - 0 失败(输入非法) + * @note + * 无论本系是否为主,应用都应当每周期设置一次跟随数据; + * 本系非主时平台不会发送该数据,但会用于双系一致性的校验。 + * 跟随数据量最大为1024*1000字节。 + * @see :: APP_API_FollowUp + */ + CM_UINT8 MSCP_SetFollowData(IN const CM_UINT8 Data[], IN CM_UINT32 Len); + + /** + * @brief 获取系统周期号 + * @return 当前的系统周期号 + * @note + * 一个固定周期自增的周期号; + * 对于2x2系统,2x2双系的周期号会被自动同步到与主系一致。 + */ + CM_UINT32 MSCP_GetSysCount(void); + + /** + * @brief 获取本机外网ID + * @return 本机外网ID + * @note 1字节类型+1字节ID,大端格式,来自INI配置文件。 + */ + CM_UINT16 MSCP_GetOutnetID(void); + + /** + * @brief 获取本机内网ID + * @return 本机内网ID + * @note 1字节类型+1字节ID,大端格式,来自INI配置文件。 + */ + CM_UINT16 MSCP_GetInnetID(void); + + /** + * @brief 获取板卡ID + * @return 本机的板卡ID + * @note 板卡ID的宏定义参见本文件头部 + */ + CM_UINT8 MSCP_GetBoardID(void); + + /** + * @brief 获取CPUID + * @return CPUID + * @details + * CPUID根据配置文件确定 + */ + CM_UINT8 MSCP_GetCpuID(void); + + /** + * @brief 获取平台软件版本号和MD5码 + * @param[out] version 软件版本号 + * @param[out] md5 软件md5码 + */ + void MSCP_GetBaseWareVer(OUT CM_UINT8 version[4]); + + /*注意CM_UINT64需要用%lld打印*/ + CM_UINT64 MSCP_GetTick(void); + /** + * @brief 获取UTC基准时间 + * @return 初始化记录UTC时间的us数 + * @details 从周期开始初始化固定值,不受时钟同步等操作的影响。 + */ + CM_UINT64 MSCP_GetUTCTick(void); + /** + * @brief 重写pSerial函数指针(串口扩展版使用),二次开发手册限制初始化时设置。 + */ + void MSCP_SetSerial(SERIAL_ID_FUNC p); + /** + * @brief 重写设备id和红蓝网通信情况。 + * @param p 注册的函数指针 取值范围(如果无需获取可以为NULL,如果获取则非空) + */ + void MSCP_SetSrcId(STATUS_COMMUNICATION_FUNC p); + /** + * @brief 变量内存自检注册初始化 + * @param pMemAddr注册变量的首地址 + * dataLen 注册变量的大小 + */ + void MSCP_MemCheck_Register(CM_UINT8 *pMemAddr,CM_UINT32 dataLen); + + /** + * @brief 初始化协议参数 + * @param inParamLen 长度 + * inParam 指针 + */ + void MSCP_ParamData(CM_UINT8* pParam,CM_UINT32 ParamLen); + + /** + * @brief 设置内网协议p_gSfpInnetPara + * @param p_gSfpInnetPara 指针 + */ + void MSCP_SetSfpInnetPara(CM_UINT8* pSfpInnetData); + + /** + * @brief 初始化应用函数入口 + */ + void MSCP_SetAppFunc(pSetAppfunc pApp1, pSetAppfunc pApp2, pSetAppfunc pApp3, pSetAppfunc pApp4, pSetAppfunc pApp5); + + + /** + * @brief 获取CPU合计使用率 + * @return 返回CPU合计使用率,范围为0到100 + */ + CM_FLOAT32 MSCP_GetCpuTotalUsage(void); + + /** + * @brief 获取指定CPU使用率 + * @param 获取指定CPU使用率,值的范围为0到5 + * @return 返回指定CPU使用率,范围为0到100 + */ + CM_FLOAT32 MSCP_GetCpuAppointUsage(CM_UINT8 CpuIndex); + + /** + * @brief 获取板卡温度 + * @return 返回板卡温度 + */ + CM_FLOAT64 MSCP_GetTemperature(void); + + /** + * @brief 设置板卡温度范围 + * @param MinTemperature 最低温度 + * @param MinTemperature 最高温度 + * @return 函数执行结果 + * - 1 成功 + * - 0 失败 + */ + CM_UINT8 MSCP_SetTemperature(CM_FLOAT32 MinTemperature , CM_FLOAT32 MaxTemperature); + + /** + * @brief 记录日志(格式化字符串) + * @param[in] fmt... 按格式化字符串描述的记录日志 + * @note 单条字符串的最大长度不超过1000字节 + */ +#define MSCP_LogMsg(fmt, ...) MSCP_APP_LOG_MSG(__FILE__,__FUNCTION__,(CM_INT32)__LINE__,(fmt), ##__VA_ARGS__) + /* 函数实现 */ + void MSCP_APP_LOG_MSG(IN const CM_CHAR *filename, IN const CM_CHAR *func, IN CM_INT32 line, IN const CM_CHAR* fmt, ...); + + /** + * @brief 记录日志(二进制) + * @param[in] buf[] 二进制日志数组 + * @param[in] len 二进制日志长度 + * @note 单条二进制日志长度不超过1024*50字节 + */ +#define MSCP_LogBin(buf,len) MSCP_APP_LOG_BIN(__FILE__,__FUNCTION__,(CM_INT32)__LINE__,(buf),(len)) + /* 函数实现 */ + void MSCP_APP_LOG_BIN(IN const CM_CHAR* filename, IN const CM_CHAR* func, IN CM_INT32 line, IN const CM_UINT8* Buf, IN CM_UINT32 Len); + /** + * @brief 内网透传解析功能-注册函数 + * @param RAW_ALGORITHM *p_Fun 注册函数 + * @return 无 + * @details 注册数组,需要注册8个函数,如果不需要解析请注册NULL。 + * @details 此函数应尽快执行完毕(耗时可能会引起丢包),并且不允许加打印。 + */ + void MSCP_InnetRaw_analysisFun(RAW_ALGORITHM *p_Fun); + /** + * @brief 获取本机通用IP地址 + * @param 无 + * @return IP地址 inet_addr + * @details 此函数仅允许在初始化阶段使用 + */ + CM_UINT32 MSCP_GetLocal_ComIp(void); + /** + * @brief 获取本机通用扩展IP地址 + * @param 无 + * @return IP地址 + * @details 此函数仅允许在初始化阶段使用 + */ + CM_UINT32 MSCP_GetLocal_ComExtendIp(void); + /** + * @brief 应用2取交换 + * @param pMyData 本机数据指针 + * @param DataLen 本机数据长度 + * @param pPeerData 邻机数据指针 + * @param DataSize 邻机数据缓冲区大小 + * @return 收到的邻机数据长度 + */ + CM_INT32 MSCP_APP_2oo2(IN const CM_UINT8 * pMyData, IN CM_INT32 DataLen, OUT CM_UINT8 * pPeerData, IN CM_UINT32 DataSize); + /** + * @brief 获取板卡运行状态 + * @return 板卡运行状态 + * - ENUM_BOARDSTATE_ERROR = 0, 未知状态 + * - ENUM_BOARDSTATE_RUN = 1, 运行状态 + * - ENUM_BOARDSTATE_EXIT = 2, 退出运营状态 + * - ENUM_BOARDSTATE_UPDATE = 3, 故障可更新文件状态 + * - ENUM_BOARDSTATE_DEFAULT = 4, 故障不可更新文件状态 + */ + ENUM_BOARD_STATE_T MSCP_GetBoardState(void); + + /** + * @brief 设置板卡运行状态 + * @param state 板卡运行状态 + * - ENUM_BOARDSTATE_ERROR = 0, 未知状态 + * - ENUM_BOARDSTATE_RUN = 1, 运行状态 + * - ENUM_BOARDSTATE_EXIT = 2, 退出运营状态 + * - ENUM_BOARDSTATE_UPDATE = 3, 故障可更新文件状态 + * - ENUM_BOARDSTATE_DEFAULT = 4, 故障不可更新文件状态 + */ + void MSCP_SetBoardState(ENUM_BOARD_STATE_T state); + + /** + * @brief 应用将应用版本号写入平台 + * @param APP_VERSION 版本号 取值范围:非空 + */ + void MSCP_SetAppVersion(IN CM_UINT8 APP_VERSION[]); + + /** + * @brief 应用将FS版本号写入平台 + * @param FS_VERSION FS数据版本号 取值范围:非空 + */ + void MSCP_SetFsVersion(IN CM_UINT8 FS_VERSION[]); + + /** + * @brief 应用将Scade版本号写入平台 + * @param SCADE_VERSION Scade数据版本号 取值范围:非空 + */ + void MSCP_SetScadeVersion(IN CM_UINT8 SCADE_VERSION[]); + + /** + * @brief 获取平台暂存的红蓝网设备信息 + * @param RedBuf 红网缓冲区 取值范围:非空 + * @param BlueBuf 篮网缓冲区 取值范围:非空 + * @details RCI用于获取平台暂存的红蓝网设备信息,长度大于等于16*18 + */ + void MSCP_GetRciTempBuf(OUT CM_UINT16* RedBuf, OUT CM_UINT16* BlueBuf); + + /** + * @brief 获得是否为在因为切系后,主系降为离线的3周期内的标志。 + * @return 是否为切系后的5周期 + * - 0 不在切系后的5周期内 + * - 1 在切系后的5周期内 + * @details 此切系状态用于应用获取到离线时判断原因 + */ + CM_UINT8 MSCP_2x2_GetSwitchFlag(void); + + /** + * @brief 应用配置ip、端口、使能等可配置变量 + * @param app_data 应用配置结构体 取值范围:非空 + * @details 此配置用来代替main_base.ini + */ + void MSCP_Set_APP_ConfigData(STRU_APP_CFG_T *app_data); + + /** + * @brief 获取安全通道链路状态 + * @return 安全通道链路状态 + */ + CM_UINT8 MSCP_GetLnkStatus(CM_UINT8 destType,CM_UINT8 destId,CM_UINT16 logId); + + /** + * @brief 读取插箱板卡id + * @return 返回插箱板卡id 取值范围:0~0xFF + * @details 其中高4位bits为插箱id 低四位bits为板卡id + */ + CM_UINT8 MSCP_GetDrvBoardID(void); + + /** + * @brief 接收外网心跳报文(自检信息) + * @param rxBuf 收到的应用报文数组 + * @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 + * @return 收到的应用报文长度 + * @details + * 每次调用获得一条完整的应用报文 + * 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 + */ + CM_UINT32 MSCP_OutNetHeart_AppRecv(OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize); + + /** + * @brief 获取两系输入io状态 + * @return ENUM_CM_TRUE 成功,ENUM_CM_FALSE 失败 + */ + ENUM_CM_RETURN MSCP_2x2_GetLastIoInput(OUT CM_UINT8* ioInput,CM_UINT16 size); + /** + * @brief 设置捕获信号(初始化调用) + */ + void MSCP_SetSignal(CM_INT32 SIGNAL); + /** + * @brief 设置应用运行步骤(周期中调用) + */ + void MSCP_SetAppCheck(CM_INT32 appCheck); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/MSCP_APP_Interface.h b/TSCP/src/MSCP/MSCP_APP_Interface.h new file mode 100644 index 0000000..4e3cfec --- /dev/null +++ b/TSCP/src/MSCP/MSCP_APP_Interface.h @@ -0,0 +1,168 @@ +#ifndef APP_INTERFACE_H +#define APP_INTERFACE_H +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @name 板卡ID + * @{ */ +#define MSCP_MAIN_A (1u) /**< 主机板A系 */ +#define MSCP_MAIN_B (2u) /**< 主机板B系 */ +#define MSCP_CC_R (3u) /**< 红网通控 */ +#define MSCP_CC_B (4u) /**< 蓝网通控 */ + /** @} */ + + /** @name 通信总量限制 + * @{ */ +#define MSCP_INNET_BUFF_SIZE (1024*500) /**< 内网周期通信总量上限 */ +#define MSCP_OUTNET_BUFF_SIZE (1024*500) /**< 外网周期通信总量上限 */ +#define MSCP_FOLLOW_BUFF_SIZE (1024*1500) /**< 周期跟随数据上限 */ +#define CFM_INNET_LOG_SIZE (1024u * 5u) /* 明文日志大小 */ +#define CFM_INNET_LOG_BIN_SIZE (CFM_INNET_LOG_SIZE-3U) /* 明文二进制日志大小 */ +#define CFM_INNET_LOG_BIN_TEST_SIZE ((CFM_INNET_LOG_SIZE-10U)/5U) /* 明文日志大小 */ + /** @} */ +/** 2x2oo2的接收通道 */ +typedef ENUM_CM_RETURN(*pSetAppfunc)(void); /* 应用周期调用函数 */ + typedef struct + { + pSetAppfunc pApp1; + pSetAppfunc pApp2; + pSetAppfunc pApp3; + pSetAppfunc pApp4; + pSetAppfunc pApp5; + }pTempAppfunc; + extern pTempAppfunc g_APP_FUNC_SET; + extern CM_UINT8 *p_gSfpInnetPara; + extern CM_UINT8 gCpuUsageParaFlag; + /** 双机热备状态 */ + typedef enum { + ENUM_2x2_SHUTDOWN = 0, /**< 宕机 */ + ENUM_2x2_OFFLINE, /**< 离线 */ + ENUM_2x2_PRE_MASTER, /**< 预升主 */ + ENUM_2x2_MASTER, /**< 主系 */ + ENUM_2x2_SLAVE /**< 备系 */ + } ENUM_2x2_STATE_T; + + /** 应用通信通道 */ + typedef enum { + ENUM_MSG_ERROR = 0, /**< 保留值,禁止使用 */ + ENUM_MSG_OUTNET_SAFE, /**< 外网安全通信,协议适配层处理 */ + ENUM_MSG_OUTNET_RAW, /* 外网透传通信 */ + ENUM_MSG_INNET_SAFE, /**< 内网安全通信,SFP协议 */ + ENUM_MSG_INNET_RAW, /**< 内网透传通信 */ + ENUM_MSG_INNET_MAINTENANCE /**< 远程部署内网安全通信 */ + } ENUM_MSCP_MSG_CHN_T; + + /*- 外网通道类型 */ + typedef enum + { + ENUM_OUTNET_ERROR = 0, /**< 保留 */ + ENUM_OUTNET_RED = 3, /**< 红网 */ + ENUM_OUTNET_BLUE = 4, /**< 蓝网 */ + ENUM_OUTNET_EXTEND_RED = 5, /**< 扩展红网 */ + ENUM_OUTNET_EXTEND_BLUE = 6 /**< 扩展蓝网 */ + }ENUM_OUTNET_CHN_T; + + /*- 板卡状态类型 */ + typedef enum + { + ENUM_BOARDSTATE_ERROR = 0, /**< 未知状态 */ + ENUM_BOARDSTATE_RUN = 1, /**< 运行状态 */ + ENUM_BOARDSTATE_EXIT = 2, /**< 退出运营状态 */ + ENUM_BOARDSTATE_UPDATE = 3, /**< 故障可更新文件状态 */ + ENUM_BOARDSTATE_DEFAULT = 4, /**< 故障不可更新文件状态 */ + }ENUM_BOARD_STATE_T; + + /*外网数据发送目的设备,定义枚举型函数返回值*/ + typedef enum + { + ENUM_CM_CC = 0, /**< 通控板 */ + ENUM_CM_SEB = 1, /**< 串口板 */ + ENUM_CM_CCSEB = 2 /**< 通控和串口板 */ + }ENUM_CM_RECCUSEB; + + typedef ENUM_CM_RECCUSEB(*SERIAL_ID_FUNC) (CM_UINT16); + extern SERIAL_ID_FUNC p_Serial_Id_Func; + + typedef void(*STATUS_COMMUNICATION_FUNC) (CM_UINT8*, CM_UINT32, ENUM_OUTNET_CHN_T, CM_UINT16 *, CM_UINT16*); + extern STATUS_COMMUNICATION_FUNC p_Status_Communication_Func; + + /*- 输出ats转车数据备用通道判断 */ + typedef ENUM_CM_RETURN(*SERIAL_OUT_ATS_VOBC) (CM_UINT16, CM_UINT16 *, CM_UINT16*); + extern SERIAL_OUT_ATS_VOBC p_Serial_OUT_ATSVOBC_Func; + + /*- 输入ats转车数据备用通道判断 */ + typedef ENUM_CM_RETURN(*SERIAL_IN_VOBC_ATS) (CM_UINT16); + extern SERIAL_IN_VOBC_ATS p_Serial_IN_VOBC_Func; + + extern CM_UINT32 inParamLen; + extern CM_UINT8* inParam; + extern CM_UINT8 gSetTempFlag; + extern CM_FLOAT32 gMinTemperature; + extern CM_FLOAT32 gMaxTemperature; + extern ENUM_BOARD_STATE_T g_boardState; + /*透传算法函数指针*/ + typedef ENUM_CM_RETURN(*RAW_ALGORITHM)(IN CM_UINT8*,IN CM_INT32,OUT CM_UINT8*,OUT CM_UINT8*); + /** + * @brief 应用初始化 + * @param[out] VitalBuf[] 关键数据数组 + * @param[out] *pVitalLen 关键数据长度 + * @return ENUM_CM_RETURN 初始化结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败(平台立即宕机) + * @note + * 2oo2双机的关键数据内容不一致时,2oo2初始化将失败——平台宕机; + * 2x2双系的关键数据内容不一致时,非主系运行的设备将宕机; + * 关键数据应尽可能短(如几个版本号或MD5码)总长不得超过200字节。 + */ + extern ENUM_CM_RETURN APP_API_Init(OUT CM_UINT8 VitalBuf[200], OUT CM_UINT16 *pVitalLen); + + /** + * @brief 应用数据初始化 + * @details 用来初始化给到平台的数据(以下三点必须在此初始化) 注:逻辑处理不要放到这里初始化 + * @note + * 1、内网协议数组 + * 2、维护模式上位机设备id + * 3、版本号 + */ + extern void APP_API_Data_Init(void); + + /** + * @brief 备系跟随接口 + * @param[in] Data[] 跟随数据数组 + * @param[in] Len 跟随数据长度 + * @return ENUM_CM_RETURN 函数执行结果 + * - ENUM_CM_TRUE 成功 + * - ENUM_CM_FALSE 失败(平台立即宕机) + * @note + * 当本系热备状态为:ENUM_2x2_OFFLINE,ENUM_2x2_SLAVE,且收到了邻系正确的跟随数据时 + * 本函数将在APP_API_MainFunc()之前执行; + * 否则,本函数不执行。 + * 应用跟随数据的最大长度不得超过1024*1000字节 + * @see :: MSCP_SetFollowData + */ + ENUM_CM_RETURN APP_API_FollowUp(IN const CM_UINT8 Data[MSCP_FOLLOW_BUFF_SIZE], IN CM_UINT32 Len); +/** + * @brief 平台\应用记录暗文日志 + * @param infoType 数据类型 + * 取值范围:0x55:info为字符串数据方式 + * 0xAA:info为十六进制数据方式 + * 0xFF:info为十进制数据方式 + * @param code 信息编码/信息类型 取值范围:0~0xffff + * @param infoLen 数据长度 取值范围:0~0xffff + * @param info 数据/信息 取值范围:任意类型指针 + */ + void MSCP_PFM_LOG_DARK(IN const CM_UINT8 infoType, IN const CM_UINT16 code, IN const CM_UINT32 infoLen, IN const void *info); + /** + * @brief 获取进入周期运行距今的时间 + * @return 从系统首次进入周期运行值调用时刻经过的时间,单位:us + */ + CM_UINT64 DFM_GetUTCBaseTick(void); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/MSCP_Define.h b/TSCP/src/MSCP/MSCP_Define.h new file mode 100644 index 0000000..5bbd2e1 --- /dev/null +++ b/TSCP/src/MSCP/MSCP_Define.h @@ -0,0 +1,61 @@ +#ifndef MSCP_DEFINE_H +#define MSCP_DEFINE_H + +#ifndef WIN32 +#ifndef QNX +#define QNX (1) +#endif +#else +#endif + + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* C++ test 用宏 */ +#if 0 +#define snprintf (_snprintf) +#define __func__ (__FILE__) +#endif +/*ite项目485串口开关*/ +#define _ITE_485_ +/* #define CM_ASSERT assert */ +/* 将表达式转换为固定类型的值-注意:禁止嵌套使用*/ +/*无符号整型 u16 u32 u64*/ +#define CM_UNSIGNED_SHORT_EXP(x) ({unsigned short u16ret = 0u; u16ret = (unsigned short)(x); u16ret;}) +#define CM_UNSIGNED_INT_EXP(x) ({unsigned int u32ret = 0u; u32ret = (unsigned int)(x); u32ret;}) +#define CM_UNSIGNED_LONG_INT_EXP(x) ({unsigned long int u64ret = 0u; u64ret = (unsigned long int)(x); u64ret;}) +/*有符号整型 t16 t32 t64*/ +#define CM_SIGNED_SHORT_EXP(x) ({signed short t16ret = 0; t16ret = (signed short)(x); t16ret;}) +#define CM_SIGNED_INT_EXP(x) ({signed int t32ret = 0; t32ret = (signed int)(x); t32ret;}) +#define CM_SIGNED_LONG_INT_EXP(x) ({signed long int t64ret = 0; t64ret = (signed long int)(x); t64ret;}) +/* 将表达式或有符号类型转换为无符号BOOL型*/ +#define CM_INT_TO_UINT_BOOL(x) ((x)?(unsigned int)1u:(unsigned int)0u) +/* 使用平台的宕机函数 */ +#ifdef WIN32 +#define CM_ASSERT(x, Mode, faultCode, funNum) (MSCP_ASSERT((unsigned int)(CM_INT_TO_UINT_BOOL(x)),0x55,(unsigned short)Mode, (unsigned char)faultCode, (unsigned char)funNum,__FILE__,0, __LINE__)) +#else +/*禁止自重启-允许远程重启*/ +#define CM_ASSERT(x, Mode, faultCode, funNum) (MSCP_ASSERT((unsigned int)(CM_INT_TO_UINT_BOOL(x)),0x55,(unsigned short)Mode, (unsigned char)faultCode, (unsigned char)funNum,__FILE__,__func__, __LINE__)) +/*禁止自重启-禁止远程重启*/ +#define CM_NM_ASSERT(x, Mode, faultCode, funNum) (MSCP_ASSERT((unsigned int)(CM_INT_TO_UINT_BOOL(x)),0xAA,(unsigned short)Mode, (unsigned char)faultCode, (unsigned char)funNum,__FILE__,__func__, __LINE__)) +/*允许自重启-允许远程重启*/ +#define CM_RE_ASSERT(x, Mode, faultCode, funNum) (MSCP_REBOOT_ASSERT((unsigned int)(CM_INT_TO_UINT_BOOL(x)),0x55,(unsigned short)Mode, (unsigned char)faultCode, (unsigned char)funNum,__FILE__,__func__, __LINE__)) +#endif +/* 平台实现的宕机函数 */ +extern void MSCP_ASSERT(unsigned int x, unsigned int MaintenanceFlag, unsigned short Mode, unsigned char faultCode, unsigned char funNum, const char *filename, const char *func, int line); +/** +* @brief 自动重启断言 +*/ +extern void MSCP_REBOOT_ASSERT(unsigned int x, unsigned int MaintenanceFlag,unsigned short Mode, unsigned char faultCode, unsigned char funNum, const char *filename, const char *func, int line); +/* 维护模式下平台的宕机函数 */ +#define CM_ASSERT_MAINTAIN(x) (MSCP_ASSERT_MAINTAIN((unsigned int)(CM_INT_TO_UINT_BOOL(x)), __FILE__,__func__, __LINE__)) +/* 维护模式下平台实现的宕机函数 */ +extern void MSCP_ASSERT_MAINTAIN(unsigned int x, const char *filename, const char *func, int line); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/MSCP_main.c b/TSCP/src/MSCP/MSCP_main.c new file mode 100644 index 0000000..9b87c60 --- /dev/null +++ b/TSCP/src/MSCP/MSCP_main.c @@ -0,0 +1,917 @@ +/** +* @file MSCP_main.c +* @brief TSCP安全平台主程序入口 +* @details +* 上电初始化和周期应用、周期自检主逻辑入口 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "MSCP_main.h" +#include "CM_Types.h" +#include "CM_Atomic.h" +#include "CM_MultiThread.h" /* pthread */ +#include "CM_Sem.h" +#include "CM_Convert.h" +#include "CM_Memory.h" +#include "CM_Time.h" +#include "DFM_Time.h" +#include "CFM_Net.h" +#include "PFM_Log.h" +#include "PFM_Cfg.h" +#include "SFM_2oo2.h" +#include "SFM_2x2.h" +#include "SFM_Prtcl.h" +#include "PFM_InputOutput.h" +#include "PFM_ControlFlowCheck.h" +#include "PFM_CPUCheck.h" +#include "PFM_MemCheck.h" +#include "DFM_DRV.h" +#include "PFM_MemoryCheck.h" +#include "PFM_SelfCheck.h" +#include "CM_Com.h" +#include "PFM_CPUUsage.h" +#include "SFM_Prtcl.h" +#include "PFM_RemoteUpdate.h" +#if QNX +#include +#include +#include /* ThreadCtl BMP绑定CPU*/ +#endif +/* 应用任务管理信息 */ +typedef struct +{ + void* p_core_mask; /* 绑定的CPU内核 */ + ENUM_CM_RETURN(*pAppfunc)(void); /* 应用周期调用函数 */ + CM_SEM_T m_appStart; /* 应用开始信号量 */ + CM_SEM_T m_appStop; /* 应用结束信号量 */ + CM_UINT64 m_appStart_Time;/* 应用开始时间 */ + CM_UINT64 m_appStop_Time;/* 应用结束时间 */ +}STRU_APP_CTRL_T; + +/* 自检管理信息 */ +typedef struct +{ + CM_SEM_T m_selfCheckStart; /* 自检开始信号量 */ + CM_SEM_T m_selfCheckStop; /* 自检结束信号量 */ +}STRU_SELF_CHECK_CTRL_T; + +/* 自检管理信息 */ +typedef struct +{ + STRU_SELF_CHECK_CTRL_T selfCheck; /* 自检信号量 */ + void* p_core_mask; /* 绑定的CPU内核 */ +}STRU_CPU_SELF_CHECK_CTRL_T; + +/* 应用任务管理信息 */ +static STRU_APP_CTRL_T s_appCtrl[10]; + +/* CPU自检任务管理信息 */ +static STRU_CPU_SELF_CHECK_CTRL_T s_CpuCheckCtrl[10]; + +/* 自检管理管理信息 */ +static STRU_SELF_CHECK_CTRL_T s_selfCheck_Ctrl; + +extern CM_UINT32 g_MSCP_SysCount; /**< 系统周期号 */ +extern CM_UINT32 g_MSCP_BirthCount; /**< 上电周期号 */ +extern const CM_UINT8 MSCP_SW_VERION[4]; +extern CM_UINT16 TSCP_DOC_VERION[2]; +/** 热备状态字符串 */ +/*static const char s_2x2stat_str[][20] = { "SHUTDOWN","OFFLINE","PRE_MASTER","MASTER","SLAVE" };*/ + +/* 初始化 */ +static void MSCP_Init(void); + +/* 并行多任务平台 */ +static CM_THREAD_FUNC_T MSCP_CycBase(void); + +/* 并行多任务应用 */ +static CM_THREAD_FUNC_T MSCP_CycApp(IN CM_Thread_Arg_Struct_T* arg); + +/* 主自检线程 */ +static CM_THREAD_FUNC_T MSCP_CheckMain(IN CM_Thread_Arg_Struct_T* arg); +/* 从自检线程 */ +static CM_THREAD_FUNC_T MSCP_CheckPeer(IN CM_Thread_Arg_Struct_T* arg); + +/* 应用调度初始化 */ +static void s_appCtrlInit(void); + +/* 逻辑处理微周期 */ +static void s_LogicProc(ENUM_CM_RETURN (*pAppfunc)(void)); + +/* 自检初始化 */ +static void s_SelfCheckCtrlInit(void); + +/* cpu自检初始化 */ +static void s_CpuCheckCtrlInit(void); + +/* 自检初始化 */ +static void SelfCheckInit(void); + +static void selfCheckSemWait(void); + +static void selfCheckSemPost(void); +/** +* @brief 主程序入口 +* @details 调用初始化入口和周期循环入口 +*/ +#if WIN32 +int mscp_main(void) +#else +int main(void) +#endif +{ + CM_BOOL rt = CM_FALSE; +#if QNX + void* pmask = NULL; + struct sched_param params; /* 线程调度参数 */ + /*- 本线程锁定在 A53 core 0 */ + pmask = (void*)0x01; + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); + /*- 设置线程优先级 */ + params.sched_priority = CM_TASK_PRIORITY_89; + /*- 设置线程调度模式为轮询模式 */ + (void)sched_setscheduler(0,SCHED_RR,¶ms); +#endif + /*- 上电读取和删除本地日志文件*/ + MSCP_Read_Del_Logfile(); + /*- 初始化入口 */ + MSCP_Init(); + /*- 创建安全平台主线程 */ + rt = CM_Thread_Create((CM_THREAD_T*) NULL, (CM_THREAD_FUNC_T) MSCP_CycBase,"main", 0, CM_TASK_PRIORITY_73, NULL); + CM_RE_ASSERT(CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + CM_Sleep(100u); /* 延时等待任务创建 */ + + /*- 创建看门狗状态监督线程 */ + rt = CM_Thread_Create((CM_THREAD_T*) NULL, (CM_THREAD_FUNC_T) MSCP_WatchDog,"watchdog", 0, CM_TASK_PRIORITY_89, NULL); + CM_RE_ASSERT(CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_4); + CM_Sleep(100u); /* 延时等待任务创建 */ + + /*- 平台状态监督 */ + PFM_CFC_Monitor(); + /* 此后代码不可达 */ + /*- @alias 主函数循环休眠 */ + while (1) + { + CM_Sleep(CM_UINT32_MAX); + } + /* 此处不可达 */ + return 0; +} +/** +* @brief 上电初始化主入口 +* @details +* 调用各模块(包括应用)的上电初始化接口 +*/ +static void MSCP_Init(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT8 vitalBuf[200] = { 0u }; /* 关键变量数组 */ + CM_UINT16 vitalLen = 0u; /* 关键变量长度 */ + CM_UINT64 cycTick = 0u; /* 周期开始时间 */ + CM_UINT8 state = 0x55U; + + /*- 驱动初始化 */ + DFM_drv_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_DRV); + CM_Sleep(10u); + /*- 维护队列初始化,必须提前*/ + CFM_Maintain_Queue_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_MAIN_QUEUE_NET); + PFM_LOG_SET_STOPTIMER(TSCP_DARK_TSCPINIT); + /*- 应用版本号初始化,必须在应用软件初始化前 */ + PFM_CFG_RegisterVerson_Init(); + /*- 应用软件初始化内网安全协议参数-以及配置文件参数 */ + APP_API_Data_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_API_DATA); + /*- 平台配置文件管理初始化 */ + PFM_CFG_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_CFG); + /*- 网卡初始化 */ + CFM_NetworkCard_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_NETCARD); + /*- 维护网日志发送初始化 */ + CFM_Maintain_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_MAIN_NET); + /*- 控制流状态监督初始化 */ + PFM_CFC_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_CFC); + /*- 是否开启2x2功能 */ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { +#ifdef QNX + /*- 串口通信初始化*/ + (void)CM_COM_INIT(115200u, 8u); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_COM); +#endif /*QNX*/ + } + /*- 微周期控制初始化 */ + PFM_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_MICROCYCLE); + /*- 内网安全协议初始化 */ + SFM_PrtclInInit(p_gSfpInnetPara); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_PRTCL_SFP); + PFM_LOG_SET_STOPTIMER(TSCP_DARK_NULL); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_TSCPINIT, 1U, &state); + PFM_LOG_SET_STOPTIMER(TSCP_DARK_SOFTTNIT); + /*- CFM:网络通信初始化 */ + CFM_UpdateAnd2oo2_Net_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_UPDATE_NET); + /*- 2取数据初始化 */ + SFM_2oo2_DataInit(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_2OO2_DATA); + CFM_Net_Init(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_NET); + /*- 上电自检初始化 */ + SelfCheckInit(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_SELFCHECK); + /*- 应用软件初始化 */ + ret = APP_API_Init(vitalBuf, &vitalLen); + MSCP_LOG_MSG("APP init...%s\n", ((ENUM_CM_TRUE == ret) ? "success" : "fail")); + CM_ASSERT(ENUM_CM_TRUE == ret, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_APP); + /*- 外网安全协议初始化 */ + SFM_PrtclOutInit(); + + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_PRTCL_RSSP); + /*- 应用调度初始化(必须在应用软件初始化后) */ + s_appCtrlInit(); + + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_APP_CTRL); + /*- 是否开启2x2功能 */ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { +#ifdef QNX + + /*- 开启临机串口接收线程*/ + CM_Com_RcvOtherThreadInit(); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_2X2USART); +#endif + } + /*- 是否开启2oo2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 2oo2初始化、上电同步和上电比较 */ + PFM_LOG_SET_STOPTIMER(TSCP_DARK_2oo2INIT); + SFM_2oo2_Init(vitalBuf, vitalLen, &cycTick); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_2OO2); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_2oo2INIT, 1u, &state); + } + else + { + /*- 默认上电同步时刻为当前时刻 */ + cycTick = CM_GetTick(); + /*设置UTC基础时间*/ + CM_ATOMIC_STORE(&g_UTCBaseTick, CM_GetUTCTick()); + MSCP_LOG_MSG("g_UTCBaseTick:%lld us\n", g_UTCBaseTick); + MSCP_LOG_MSG("cycTick:%lld us\n", cycTick); + } + PFM_LOG_SET_STOPTIMER(TSCP_DARK_SOFTTNIT); + /* 至此确定了2oo2同步的完成时刻 */ + /*- 2x2上电比较和计算时钟修正量 */ + SFM_2x2_Init(vitalBuf, vitalLen, &cycTick); + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_2X2); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_SOFTTNIT, 1U, &state); + PFM_LOG_SET_STOPTIMER(TSCP_DARK_NULL); + /*- 保存周期基准时刻 */ + PFM_LOG_SET_INIT_STAGE(ENUM_INIT_OVER); + CM_ATOMIC_STORE(&g_CycBaseTick, cycTick); /* parasoft-suppress GJB8114-R_1_7_2 NAMING-22 "QNX宏不符合编码规范" */ + /*此处至周期开始延时不可以超过一个周期的时间,最好不要加延时*/ +} + +/** +* @brief 平台任务 +* @details +* 平台输入微周期处理和输出微周期处理 +*/ +static CM_THREAD_FUNC_T MSCP_CycBase(void) +{ + /*- 变量初始化 */ + CM_UINT64 costlog[20]; /* 耗时记录 */ + CM_INT32 delayTime = 0; /* 延迟时间 */ + CM_UINT64 leftTime = 0u; /* 剩余时间 */ + CM_INT64 offset_2oo2 = 0; /* 2oo2时钟修正量 */ + CM_INT64 offset_2x2 = 0; /* 2x2时钟修正量 */ + CM_INT32 i = 0; /* 循环变量 */ + ENUM_2x2_STATE_T localState = ENUM_2x2_SHUTDOWN; + ENUM_2x2_STATE_T peerState = ENUM_2x2_SHUTDOWN; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT32 darkInPutTime = 0u; + CM_UINT32 darkOutPutTime = 0u; + CM_UINT32 darkCycEndTime = 0u; + CM_UINT8 darkAppTimeBuf[20] = {0U}; + CM_UINT32 tempAppTimeBuf[5] = {0U}; + CM_UINT32 u_64temp = g_PFM_Cfg.CYC_TIME * CM_UNSIGNED_MILLION; /*uint64临时变量*/ + CM_UINT8 state = 0x55u; + CM_UINT8 drvBoard = DFM_getBoardID(); +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)0x02u; + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + /*- 获取周期开始时刻 */ + g_CycTick = CM_ATOMIC_LOAD(&g_CycBaseTick); /* parasoft-suppress GJB8114-R_1_7_2 NAMING-22 "QNX宏不符合编码规范" */ + /*- 等待周期开始*/ + leftTime = DFM_WaitUntill(g_CycTick); + PFM_SetBoardState(ENUM_BOARDSTATE_RUN); + /*周期号必须从1开始*/ + g_MSCP_BirthCount = 1u; + costlog[0] = CM_GetTick(); + costlog[1] = CM_GetTick(); + /*发送暗文日志*/ + CFM_LogCiphertextSend(); + /*- 喂狗 */ + PFM_CFC_WatchDog(); + /*- 清空通信缓冲区 */ + CFM_NetFlush(); + /*发送2x状态结束信号量*/ + SFM_2x2_SemPost(); + (void)DFM_SetIO_OutPut(0x00u); + /*- 循环执行周期逻辑 */ + while (1) + { + /*- 更新周期号*/ + g_MSCP_SysCount++; + localState = SFM_2x2_GetLocal2x2State(); + peerState = SFM_2x2_GetPartner2x2State(); + MSCP_LOG_MSG("time left:%lld us\n", leftTime); + MSCP_LOG_MSG("==========CPU:%d-%d=CYC=%d==M/S:0x%x==Partner:0x%x============\n",g_PFM_Cfg.BOARD_ID,g_PFM_Cfg.CPU_ID,g_MSCP_SysCount,localState,peerState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_CYC, 4U, &g_MSCP_SysCount); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_BOARDID, 1U, &drvBoard); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_CPUID, 1U, &g_PFM_Cfg.CPU_ID); + (void)CFM_DarkLog_Storage(DARK_LOG_STRING, TSCP_DARK_VERION, 4U, MSCP_SW_VERION); + (void)CFM_DarkLog_Storage(DARK_LOG_STRING, TSCP_DARK_QNXVERION, 4U, TSCP_QNX_VERION); + (void)CFM_DarkLog_Storage(DARK_LOG_STRING, TSCP_DARK_DOCVERION, 4U, TSCP_DOC_VERION); + PFM_CFG_SendDarkCfg(); + PFM_GetAllCpuUsageInterface();/*发送cpu使用率接口*/ +#if QNX + CM_RE_ASSERT(leftTime > 1000u, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); +#endif +/*- ***********APP周期开始阶段***************/ + /*- 发送设备类型 */ + (void)PFM_DevStateSend(1); + /*- 双缓冲区切换 */ + PFM_BufSwich(); + MSCP_LOG_MSG("timecurr 11 BufSwitch = %lld us\n", NOW_USED_TIME); +/*- ***********APP启动阶段*/ + /*#############应用启动#############*/ + MSCP_LOG_MSG("BASE_APP_RUN %lld us\n", NOW_USED_TIME); + /*- @alias 发送应用启动信号*/ + for (i = 1; i <= g_PFM_Cfg.app_num; i++) + { + if(NULL == s_appCtrl[i].pAppfunc) + { + /*- 无处理*/ + } + else + { + rt = CM_Sem_Post(s_appCtrl[i].m_appStart); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + } + } +#ifdef QNX + (void)trace_nlogf(122, 0, "app_start"); +#endif + /*#############LED运行电灯#############*/ + MSCP_LOG_MSG("timecurr 12 AppStart = %lld us\n", NOW_USED_TIME); + DFM_ledRun(); +/*- ***********输出数据处理阶段*/ + /*#############输出微周期#############*/ + /*- 输出微周期:协议层封装*/ + costlog[6] = CM_GetTick(); + SFM_EnPrtclProc(); + MSCP_LOG_MSG("timecurr 13 EnPrtclProc = %lld us\n", NOW_USED_TIME); +/*- ***********数据输出阶段*/ + /*- 输出微周期:输出数据处理*/ + PFM_OutputProc(); + costlog[7] = CM_GetTick(); + /*计算输出阶段耗时,并通过暗文日志发送*/ + darkOutPutTime = (CM_UINT32)CM_UNSIGNED_LONG_INT_EXP((costlog[7] - costlog[6]) / 1000u); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_OUTTIME, 4U, &darkOutPutTime); + MSCP_LOG_MSG("BASE_OUTPUT_SEND = %lld us\n", NOW_USED_TIME); +/*- ***********周期时间控制阶段-空闲微周期*/ + /*- 暗文标志位至为发送 */ + PFM_CFC_Check(22); + /*发送暗文日志*/ + CFM_LogCiphertextSend(); + PFM_CFC_Check(23); + MSCP_LOG_MSG("timecurr 18 Time = %lld us\n", NOW_USED_TIME); + /*重置自动重启次数*/ + SFM_2oo2_Reset_AutoRbootCut(); + MSCP_LOG_MSG("timecurr 19 Time = %lld us\n", NOW_USED_TIME); + /*- 空闲微周期:等待新周期开始 */ + if (0 != offset_2oo2) + { + CM_ATOMIC_ADD(&g_CycBaseTick, offset_2oo2); /* parasoft-suppress GJB8114-R_1_7_2 "QNX宏不符合编码规范" */ + MSCP_LOG_MSG("[%d]2oo2fix=%lld\n", g_MSCP_SysCount, offset_2oo2); + } + else + { + MSCP_LOG_MSG("0 == offset_2oo2\n"); + } + + if (0 != offset_2x2) + { + CM_ATOMIC_ADD(&g_CycBaseTick, offset_2x2); /* parasoft-suppress GJB8114-R_1_7_2 "QNX宏不符合编码规范" */ + MSCP_LOG_MSG("[%d]2x2fix=%lld\n", g_MSCP_SysCount, offset_2x2); + if ((CM_ABS(offset_2x2)) >= (CM_INT64)u_64temp) + { + offset_2x2 = 0; + } + else + { + /*- 无处理 */ + } + } + else + { + MSCP_LOG_MSG("0 == offset_2x2\n"); + } + MSCP_LOG_MSG("g_CycBaseTick = %lld\n",g_CycBaseTick); + g_CycTick += (CM_UINT64)CM_SIGNED_LONG_INT_EXP(u_64temp + offset_2oo2 + offset_2x2); + /*- 冗余喂狗,防止误判超时 */ + PFM_CFC_WatchDog(); +/**************↓↓↓↓↓↓禁止添加代码,包括打印!***************/ + leftTime = DFM_WaitUntill(g_CycTick); + /*- 喂狗 */ + PFM_CFC_WatchDog(); + g_MSCP_BirthCount++; + MSCP_LOG_MSG("-----MSCP_BirthCount:%d,M/S:0x%x--Partner:0x%x,N/D:%d/%d-err_cut:%d,err_cyc:%d,apperr_cut:%d,apperr_cyc:%d---version:%d.%d.%d.%d\n", + g_MSCP_BirthCount,SFM_2x2_GetLocal2x2State(),SFM_2x2_GetPartner2x2State(), + MSCP_Get_AutoRbootCut(),g_PFM_Cfg.M_AutoReboot_Count, + s_2oo2_Ctrl.FrameCtrl.err_cut,s_2oo2_Ctrl.FrameCtrl.err_cyc, + s_2oo2_Ctrl_App.FrameCtrl.err_cut,s_2oo2_Ctrl_App.FrameCtrl.err_cyc, + MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3]); + DFM_Drv_CycLog(); + /*TODO 发送2x状态起始信号量*/ + SFM_2x2_Thread_PostStart(); + PFM_CFC_Check(24); + /*- @alias 2oo2周期校时 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + MSCP_LOG_MSG("2oo2start time left:%lld us\n",leftTime); + costlog[0] = SFM_2oo2_Sync(&offset_2oo2); + } + else + { + costlog[0] = CM_GetTick(); + } + PFM_CFC_Check(25); + /*- @alias 2x2周期校时 */ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + MSCP_LOG_MSG("2x2start\n"); + SFM_2x2_Sync(g_CycTick, &offset_2x2); + } + else + { + /* 无处理 */ + } + costlog[1] = CM_GetTick(); +/**************↑↑↑↑↑禁止添加代码,包括打印!***************/ + delayTime = (CM_INT32)CM_UNSIGNED_LONG_INT_EXP((costlog[0] - g_CycTick) / 1000u); + MSCP_LOG_MSG("2oo2 sync delay = %d us\n", delayTime); + MSCP_LOG_MSG("2x2 sync delay = %lld us\n", (costlog[1] - costlog[0]) / 1000u); + MSCP_LOG_MSG("BASE_CYC_CTRL_SYNC = %lld us\n", NOW_USED_TIME); +/*- ***********数据输入阶段*/ + /*#############输入微周期#############*/ + /*- 输入微周期:输入数据处理 */ + costlog[2] = CM_GetTick(); + PFM_InputProc(); + MSCP_LOG_MSG("BASE_INPUT_RCV = %lld us\n", NOW_USED_TIME); +/*- ***********输入数据处理阶段*/ + /*- 处理微周期:协议层解析 */ + /*协议层解析*/ + SFM_UnPrtclProc(); + MSCP_LOG_MSG("timecurr 6 Input UnPrtclProc = %lld us\n", NOW_USED_TIME); + costlog[3] = CM_GetTick(); + /*计算输入阶段耗时,并通过暗文日志发送*/ + darkInPutTime = (CM_UINT32)CM_UNSIGNED_LONG_INT_EXP((costlog[3] - costlog[2]) / 1000u); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_INPUTTIME, 4U, &darkInPutTime); + MSCP_LOG_MSG("BASE_INPUT_PROCESS = %lld us\n", NOW_USED_TIME); + +/*- ***********等待APP结束阶段*/ + /*#############等待应用结束#############*/ + /*- @alias 等待应用完成信号 */ + PFM_CFC_Check(47); + for (i = 1; i <= g_PFM_Cfg.app_num; i++) + { + if(NULL == s_appCtrl[i].pAppfunc) + { + /*- 无处理 */ + } + else + { + rt = CM_Sem_Wait(s_appCtrl[i].m_appStop); + /*计算应用实际耗时,并通过暗文日志发送*/ + MSCP_LOG_MSG("app%d run time %lld us\n",i,(s_appCtrl[i].m_appStop_Time - s_appCtrl[i].m_appStart_Time)/1000u); + tempAppTimeBuf[i-1] = (CM_UINT32)CM_UNSIGNED_LONG_INT_EXP((s_appCtrl[i].m_appStop_Time - s_appCtrl[i].m_appStart_Time)/1000u); + CM_LongToChar(tempAppTimeBuf[i-1],darkAppTimeBuf+4*i-4); + CM_RE_ASSERT((s_appCtrl[i].m_appStop_Time - s_appCtrl[i].m_appStart_Time) <= u_64temp, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_4); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + } + } + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_APPTIME, 20U, &darkAppTimeBuf[0]); +#ifdef QNX + (void)trace_nlogf(123 , 0,"app_end"); +#endif + MSCP_LOG_MSG("timecurr 7 Wait AppEnd = %lld us\n", NOW_USED_TIME); + + /*- ***********自检阶段*/ + /*- 发送自检开始信号量 */ + selfCheckSemPost(); + /*- 等待自检结束信号量 */ + selfCheckSemWait(); + MSCP_LOG_MSG("timecurr 8 SelfCheck = %lld us\n", NOW_USED_TIME); + +/*- ***********APP数据跟随阶段*/ + costlog[4] = CM_GetTick(); + PFM_EndProc(); + costlog[5] = CM_GetTick(); + + /*计算周期末耗时,并通过暗文日志发送*/ + darkCycEndTime = (CM_UINT32)CM_UNSIGNED_LONG_INT_EXP((costlog[5] - costlog[4]) / 1000u); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_ENDTIME, 4U, &darkCycEndTime); + MSCP_LOG_MSG("timecurr 10 PFM_EndProc End = %lld us\n", NOW_USED_TIME); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_2OO2, 1U, &state); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_2x2, 1U, &state); + + SFM_LogOutPrtcl(); + } + return NULL; +} + +/** +* @brief 应用任务 +* @details +* 本任务阻塞等待来自平台任务的启动信号 +* 收到启动信号后执行一次应用任务 +* 应用任务执行完成后向平台任务反馈结束信号 +*/ +static CM_THREAD_FUNC_T MSCP_CycApp(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + STRU_APP_CTRL_T* pCtrl = (STRU_APP_CTRL_T*)arg; +#if QNX + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pCtrl->p_core_mask); +#endif + /*- 循环执行任务逻辑 */ + while (1) + { + /*- 等待来自平台任务的启动信号 */ + + rt = CM_Sem_Wait(pCtrl->m_appStart); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + pCtrl->m_appStop_Time = 0u; + pCtrl->m_appStart_Time = CM_GetTick(); + /*- 逻辑处理微周期 */ + s_LogicProc(pCtrl->pAppfunc); + pCtrl->m_appStop_Time = CM_GetTick(); + /*- 向平台任务反馈任务完成信号 */ + rt = CM_Sem_Post(pCtrl->m_appStop); + MSCP_LOG_MSG("app run time %d us\n",(pCtrl->m_appStop_Time - pCtrl->m_appStart_Time)/1000u); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + } + return NULL; +} + +/** +* @brief 应用调度初始化 +* @details +* 初始话应用调度的配置信息STRU_APP_CTRL_T, +* 含应用函数入口、启动停止信号量等。 +*/ +static void s_appCtrlInit(void) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_BOOL rtCheck = CM_FALSE; + CM_CHAR appName[32] = {0}; /* 主键值 */ + + /*- 初始化应用函数入口和绑定的CPU内核 前两个Main是大核A72*/ + s_appCtrl[1].pAppfunc = g_APP_FUNC_SET.pApp1; + s_appCtrl[1].p_core_mask = (void*)0x20; + + s_appCtrl[2].pAppfunc = g_APP_FUNC_SET.pApp2; + s_appCtrl[2].p_core_mask = (void*)0x10; + + s_appCtrl[3].pAppfunc = g_APP_FUNC_SET.pApp3; + s_appCtrl[3].p_core_mask = (void*)0x08; + + s_appCtrl[4].pAppfunc = g_APP_FUNC_SET.pApp4; + s_appCtrl[4].p_core_mask = (void*)0x04; + + s_appCtrl[5].pAppfunc = g_APP_FUNC_SET.pApp5; + s_appCtrl[5].p_core_mask = (void*)0x02; + + /*- 初始化应用启动、停止信号量 */ + for (i = 1; i <= g_PFM_Cfg.app_num; i++) + { + if(NULL == s_appCtrl[i].pAppfunc) + { + MSCP_LOG_MSG("s_appCtrl[%d].pAppfunc is NULL!\n", i); + } + else + { + rt = CM_Sem_Init(&s_appCtrl[i].m_appStart); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + + rt = CM_Sem_Init(&s_appCtrl[i].m_appStop); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_2); + } + } + + /*- 创建应用线程 */ + for (i = 1; i <= g_PFM_Cfg.app_num; i++) + { + if(s_appCtrl[i].pAppfunc== NULL ) + { + MSCP_LOG_MSG("s_appCtrl[%d].pAppfunc is NULL!\n", i); + } + else + { + CM_ASSERT(NULL != appName, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_3); + (void)snprintf(appName, sizeof(appName), "app%d", i); + rtCheck = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)MSCP_CycApp, appName, 0, CM_TASK_PRIORITY_73, (CM_Thread_Arg_Struct_T*)(&s_appCtrl[i])); + CM_ASSERT(CM_TRUE == rtCheck, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_4); + CM_Sleep(100u); /* 延时等待任务创建 */ + } + } +} + +/** +* @brief 自检初始化 +*/ +static void SelfCheckInit(void) +{ +#ifdef QNX + /*- 文件自检初始化 */ + PFM_FileInit(); + /*- 内存自检初始化*/ + PFM_MemCheck_Init(); + /*- CPU自检初始化*/ + s_CpuCheckCtrlInit(); +#endif/*QNX*/ + + /*- 自检主线程初始化*/ + s_SelfCheckCtrlInit(); + /*硬件自检*/ + PFM_BoardCheck_TolerateThreetimes(); + selfCheckSemPost(); + selfCheckSemWait(); + /*- 是否开启2x2功能 */ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + /*- 串口自检*/ + PFM_UartComCheck(); + } + else + { + ; + } + +} + +/** +* @brief 自检信号量等待 +*/ +static void selfCheckSemWait(void) +{ +#ifdef QNX + /*- 变量初始化 */ + CM_INT32 i = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 初始化应用启动、停止信号量 */ + for (i = 1; i <= 6; i++) + { + rt = CM_Sem_Wait(s_CpuCheckCtrl[i].selfCheck.m_selfCheckStop); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + } + rt = CM_Sem_Wait(s_selfCheck_Ctrl.m_selfCheckStop); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_2); +#endif +} + +/** +* @brief 自检信号量释放 +*/ +static void selfCheckSemPost(void) +{ +#ifdef QNX + /*- 变量初始化 */ + CM_INT32 i = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + /*- 初始化应用启动、停止信号量 */ + rt = CM_Sem_Post(s_selfCheck_Ctrl.m_selfCheckStart); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_1); + for (i = 1; i <= 6; i++) + { + rt = CM_Sem_Post(s_CpuCheckCtrl[i].selfCheck.m_selfCheckStart); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_2); + } + +#endif +} + +/** +* @brief CPU自检初始化 +*/ +static void s_CpuCheckCtrlInit(void) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_BOOL checkRt = CM_FALSE; + /*- 初始化应用启动、停止信号量 */ + for (i = 1; i <= 6; i++) + { + rt = CM_Sem_Init(&s_CpuCheckCtrl[i].selfCheck.m_selfCheckStart); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1); + rt = CM_Sem_Init(&s_CpuCheckCtrl[i].selfCheck.m_selfCheckStop); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_2); + } + + s_CpuCheckCtrl[1].p_core_mask = (void*)0x20; + + s_CpuCheckCtrl[2].p_core_mask = (void*)0x10; + + s_CpuCheckCtrl[3].p_core_mask = (void*)0x08; + + s_CpuCheckCtrl[4].p_core_mask = (void*)0x04; + + s_CpuCheckCtrl[5].p_core_mask = (void*)0x02; + + s_CpuCheckCtrl[6].p_core_mask = (void*)0x01; + /*- 创建应用线程 */ + for (i = 1; i <= 6; i++) + { + checkRt = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)MSCP_CheckPeer, "CpuCheck", 0, CM_TASK_PRIORITY_73, (CM_Thread_Arg_Struct_T*)(&s_CpuCheckCtrl[i])); + CM_ASSERT(CM_TRUE == checkRt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_3); + CM_Sleep(100u); /* 延时等待任务创建 */ + /*MSCP_LOG_MSG("cpu[%d]_Check_Thread_Create \r\n", i); */ + } +} + +/** +* @brief 自检线程初始化 +*/ +static void s_SelfCheckCtrlInit(void) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_BOOL checkRt = CM_FALSE; + + rt = CM_Sem_Init(&s_selfCheck_Ctrl.m_selfCheckStart); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_1); + rt = CM_Sem_Init(&s_selfCheck_Ctrl.m_selfCheckStop); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_2); + checkRt = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)MSCP_CheckMain, "selfcheck", 0, CM_TASK_PRIORITY_73, (CM_Thread_Arg_Struct_T*)(&s_selfCheck_Ctrl)); + CM_ASSERT(CM_TRUE == checkRt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_3); + CM_Sleep(100u); /* 延时等待任务创建 */ +} +/** +* @brief 主自检线程 +* @details 包括CPU周期自检和内存周期自检 +*/ +static CM_THREAD_FUNC_T MSCP_CheckMain(IN CM_Thread_Arg_Struct_T* arg) +{ + /*无需锁定内核,在app空闲时调用*/ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 变量初始化 */ + STRU_SELF_CHECK_CTRL_T* pCtrl = (STRU_SELF_CHECK_CTRL_T*)arg; + CM_UINT64 costlog[10] = {0u}; /* 记录耗时变量 */ + /*- 自检线程主循环 */ + while (1) + { + /*- 接收自检开始信号 */ + rt = CM_Sem_Wait(pCtrl->m_selfCheckStart); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_1); + /*- 内存自检 */ + costlog[0] = CM_GetTick(); + PFM_MemCheck(); + costlog[1] = CM_GetTick(); + MSCP_LOG_MSG("cyc MemCheck cost = %d us\n", (costlog[1] - costlog[0]) / 1000u); + /*- 板卡自检*/ + PFM_BoardCheck(); + costlog[2] = CM_GetTick(); + MSCP_LOG_MSG("PFM_BoardCheck cost = %d us\n", (costlog[2] - costlog[1]) / 1000u); + /*- 发送自检结束信号 */ + MSCP_LOG_MSG("Self_Check_End \r\n"); + rt = CM_Sem_Post(pCtrl->m_selfCheckStop); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_2); + } + + return NULL; +} + +/** +* @brief 从自检线程 +* @details 只包括CPU自检 +*/ +static CM_THREAD_FUNC_T MSCP_CheckPeer(IN CM_Thread_Arg_Struct_T* arg) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + STRU_CPU_SELF_CHECK_CTRL_T* pCtrl = (STRU_CPU_SELF_CHECK_CTRL_T*)arg; +#if QNX + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pCtrl->p_core_mask); +#endif + /*- 自检线程主循环 */ + while (1) + { + /*- 接收自检开始信号 */ + rt = CM_Sem_Wait(pCtrl->selfCheck.m_selfCheckStart); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_1); + /*- CPU自检 */ + PFM_CPUCheck(); + /*- 发送自检结束信号 */ + rt = CM_Sem_Post(pCtrl->selfCheck.m_selfCheckStop); + CM_ASSERT(ENUM_CM_TRUE == rt, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_2); + } + return NULL; +} + +/** +* @brief 逻辑层处理 +* @details 根据当前热备状态确定是否调用应用周期逻辑 +*/ +static void s_LogicProc(ENUM_CM_RETURN(*pAppfunc)(void)) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + ENUM_2x2_STATE_T localState = SFM_2x2_GetLocal2x2State(); + + + /*- 是否关闭了2x2功能 */ + if (0xAAu == g_PFM_Cfg.M_2x2_Enable) + { + /*- 本系默认为主 */ + localState = ENUM_2x2_MASTER; + } + else + { + /*- 无处理 */ + } + + /*MSCP_LOG_MSG("STAT:%s\n", s_2x2stat_str[localState]);*/ + /*- 本系热备状态 */ + switch (localState) + { + case ENUM_2x2_SHUTDOWN: /*-< 宕机 */ + /*- 什么都不做*/ + /*- 返回 */ + break; + case ENUM_2x2_OFFLINE: /*-< 离线 */ + /*- 执行周期逻辑(但不会被输出) */ + ret = (*pAppfunc)(); + /*- 返回 */ + break; + case ENUM_2x2_PRE_MASTER: /*-< 预升主 */ + /*- 执行周期逻辑(但不会被输出) */ + ret = (*pAppfunc)(); + /*- 返回 */ + break; + case ENUM_2x2_MASTER: /*-< 主系 */ + /*- 执行周期逻辑(会被输出) */ + ret = (*pAppfunc)(); + /*- 返回 */ + break; + case ENUM_2x2_SLAVE:/*-< 备系 */ + /*- 执行应用周期逻辑(但不会被输出) */ + ret = (*pAppfunc)(); + /*- 返回 */ + break; + default: + /*- 返回 */ + break; + } + + /*- 如果应用返回错误 */ + if(ENUM_CM_FALSE == ret) + { + /*- 宕机并执行自动重启 */ + CM_RE_ASSERT(0, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_1); + } + /*- 如果应用返回未知 */ + else if(ENUM_CM_NULL == ret) + { + /*- 宕机 */ + CM_ASSERT(0, MAIN_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_2); + } + else + { + /*- 无处理 */ + } +} diff --git a/TSCP/src/MSCP/MSCP_main.h b/TSCP/src/MSCP/MSCP_main.h new file mode 100644 index 0000000..4fb72a3 --- /dev/null +++ b/TSCP/src/MSCP/MSCP_main.h @@ -0,0 +1,16 @@ +#ifndef MAIN_H +#define MAIN_H +#ifdef __cplusplus +extern "C" +{ +#endif + +#if WIN32 +#define _TSCP_ +extern int mscp_main(void); +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_CPUCheck.c b/TSCP/src/MSCP/PFM/PFM_CPUCheck.c new file mode 100644 index 0000000..8964efb --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_CPUCheck.c @@ -0,0 +1,971 @@ +/* +* @filename PFM_CPUCheck.c +* @brief Platform Function Module:CPU自检 +* @details +* +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_CPUCheck.h" +#include "PFM_Log.h" + + +#ifdef WIN32 + + +void PFM_CPUCheck(void) +{ + +} + +#else + +/* 寄存器x读写 */ +static CM_UINT64 s_asm_x0(CM_UINT64 val); +static CM_UINT64 s_asm_x1(CM_UINT64 val); +static CM_UINT64 s_asm_x2(CM_UINT64 val); +static CM_UINT64 s_asm_x3(CM_UINT64 val); +static CM_UINT64 s_asm_x4(CM_UINT64 val); +static CM_UINT64 s_asm_x5(CM_UINT64 val); +static CM_UINT64 s_asm_x6(CM_UINT64 val); +static CM_UINT64 s_asm_x7(CM_UINT64 val); +static CM_UINT64 s_asm_x8(CM_UINT64 val); +static CM_UINT64 s_asm_x9(CM_UINT64 val); +static CM_UINT64 s_asm_x10(CM_UINT64 val); +static CM_UINT64 s_asm_x11(CM_UINT64 val); +static CM_UINT64 s_asm_x12(CM_UINT64 val); +static CM_UINT64 s_asm_x13(CM_UINT64 val); +static CM_UINT64 s_asm_x14(CM_UINT64 val); +static CM_UINT64 s_asm_x15(CM_UINT64 val); +static CM_UINT64 s_asm_x16(CM_UINT64 val); +static CM_UINT64 s_asm_x17(CM_UINT64 val); +static CM_UINT64 s_asm_x18(CM_UINT64 val); +static CM_UINT64 s_asm_x19(CM_UINT64 val); +static CM_UINT64 s_asm_x20(CM_UINT64 val); +static CM_UINT64 s_asm_x21(CM_UINT64 val); +static CM_UINT64 s_asm_x22(CM_UINT64 val); +static CM_UINT64 s_asm_x23(CM_UINT64 val); +static CM_UINT64 s_asm_x24(CM_UINT64 val); +static CM_UINT64 s_asm_x25(CM_UINT64 val); +static CM_UINT64 s_asm_x26(CM_UINT64 val); +static CM_UINT64 s_asm_x27(CM_UINT64 val); +static CM_UINT64 s_asm_x28(CM_UINT64 val); +static CM_UINT64 s_asm_x29(CM_UINT64 val); +static CM_UINT64 s_asm_x30(CM_UINT64 val); + +/* 寄存器读写 */ +#define REG_SET_AND_RETURN(val,reg) \ + {\ + register CM_UINT64 rn asm(reg) = (val); \ + CM_UINT64 rd = 0u;\ + __asm__ __volatile__\ + (\ + "mov %1,%0;"\ + :"=r"(rd)\ + :"r"(rn)\ + );\ + return rd;\ + } + + +/** + * @brief 寄存器x0自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x0(CM_UINT64 val) REG_SET_AND_RETURN(val,"x0") + +/** + * @brief 寄存器x1自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x1(CM_UINT64 val) REG_SET_AND_RETURN(val,"x1") +/** + * @brief 寄存器x2自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x2(CM_UINT64 val) REG_SET_AND_RETURN(val,"x2") +/** + * @brief 寄存器x3自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x3(CM_UINT64 val) REG_SET_AND_RETURN(val,"x3") +/** + * @brief 寄存器x4自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x4(CM_UINT64 val) REG_SET_AND_RETURN(val,"x4") +/** + * @brief 寄存器x5自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x5(CM_UINT64 val) REG_SET_AND_RETURN(val,"x5") +/** + * @brief 寄存器x6自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x6(CM_UINT64 val) REG_SET_AND_RETURN(val,"x6") +/** + * @brief 寄存器x7自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x7(CM_UINT64 val) REG_SET_AND_RETURN(val,"x7") +/** + * @brief 寄存器x8自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x8(CM_UINT64 val) REG_SET_AND_RETURN(val,"x8") +/** + * @brief 寄存器x9自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x9(CM_UINT64 val) REG_SET_AND_RETURN(val,"x9") +/** + * @brief 寄存器x10自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x10(CM_UINT64 val) REG_SET_AND_RETURN(val,"x10") +/** + * @brief 寄存器x11自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x11(CM_UINT64 val) REG_SET_AND_RETURN(val,"x11") +/** + * @brief 寄存器x12自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x12(CM_UINT64 val) REG_SET_AND_RETURN(val,"x12") +/** + * @brief 寄存器x13自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x13(CM_UINT64 val) REG_SET_AND_RETURN(val,"x13") +/** + * @brief 寄存器x14自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x14(CM_UINT64 val) REG_SET_AND_RETURN(val,"x14") +/** + * @brief 寄存器x15自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x15(CM_UINT64 val) REG_SET_AND_RETURN(val,"x15") +/** + * @brief 寄存器x16自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x16(CM_UINT64 val) REG_SET_AND_RETURN(val,"x16") +/** + * @brief 寄存器x17自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x17(CM_UINT64 val) REG_SET_AND_RETURN(val,"x17") +/** + * @brief 寄存器x18自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x18(CM_UINT64 val) REG_SET_AND_RETURN(val,"x18") +/** + * @brief 寄存器x19自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x19(CM_UINT64 val) REG_SET_AND_RETURN(val,"x19") +/** + * @brief 寄存器x20自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x20(CM_UINT64 val) REG_SET_AND_RETURN(val,"x20") +/** + * @brief 寄存器x21自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x21(CM_UINT64 val) REG_SET_AND_RETURN(val,"x21") +/** + * @brief 寄存器x22自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x22(CM_UINT64 val) REG_SET_AND_RETURN(val,"x22") +/** + * @brief 寄存器x23自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x23(CM_UINT64 val) REG_SET_AND_RETURN(val,"x23") +/** + * @brief 寄存器x24自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x24(CM_UINT64 val) REG_SET_AND_RETURN(val,"x24") +/** + * @brief 寄存器x25自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x25(CM_UINT64 val) REG_SET_AND_RETURN(val,"x25") +/** + * @brief 寄存器x26自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x26(CM_UINT64 val) REG_SET_AND_RETURN(val,"x26") +/** + * @brief 寄存器x27自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x27(CM_UINT64 val) REG_SET_AND_RETURN(val,"x27") +/** + * @brief 寄存器x28自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x28(CM_UINT64 val) REG_SET_AND_RETURN(val,"x28") +/** + * @brief 寄存器x28自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x29(CM_UINT64 val) REG_SET_AND_RETURN(val,"x29") +/* x29是栈帧寄存器,不可用作通用寄存器,不自检 */ + +/** + * @brief 寄存器x30自检 + * @param val 写入寄存器的数值 + * @return 从寄存器读出的数值 + * @details + * 将val写入寄存器再读出 + */ +static CM_UINT64 s_asm_x30(CM_UINT64 val) REG_SET_AND_RETURN(val,"x30") + +/* 算术运算 */ +/* rd = rn + op2 */ +static CM_INT64 s_asm_add(CM_INT64 rn, CM_INT64 op2); +/* rd = rn - op */ +static CM_INT64 s_asm_sub(CM_INT64 rn, CM_INT64 op2); +/* rd = ra + rn * rm */ +static CM_INT64 s_asm_madd(CM_INT64 ra, CM_INT64 rn, CM_INT64 rm); +/* rd = - rn * rm */ +static CM_INT64 s_asm_mneg(CM_INT64 rn, CM_INT64 rm); +/* rd = ra - rn * rm */ +static CM_INT64 s_asm_msub(CM_INT64 ra, CM_INT64 rn, CM_INT64 rm); +/* rd = rn * rm */ +static CM_INT64 s_asm_mul(CM_INT64 rn, CM_INT64 rm); +/* rd = - op2 */ +static CM_INT64 s_asm_neg(CM_INT64 op2); +/* rd = rn / rm (有符号数) */ +static CM_INT64 s_asm_sdiv(CM_INT64 rn, CM_INT64 rm); +/* rd = rn / rm (无符号数) */ +static CM_UINT64 s_asm_udiv(CM_UINT64 rn, CM_UINT64 rm); + +/* 逻辑运算 */ +/* rd = rn & op2 */ +static CM_UINT32 s_asm_and(CM_UINT32 rn, CM_UINT32 op2); +/* rd = rn & ~op2 */ +static CM_UINT32 s_asm_bic(CM_UINT32 rn,CM_UINT32 op2); +/* rd = rn ^ ~op2 */ +static CM_UINT32 s_asm_eon(CM_UINT32 rn,CM_UINT32 op2); +/* rd = rn ^ op2 */ +static CM_UINT32 s_asm_eor(CM_UINT32 rn,CM_UINT32 op2); +/* rd = rn */ +static CM_UINT32 s_asm_mov(CM_UINT32 rn); +/* rd = ~op2 */ +static CM_UINT32 s_asm_mvn(CM_UINT32 op2); +/* rd = rn | ~op2 */ +static CM_UINT32 s_asm_orn(CM_UINT32 rn, CM_UINT32 op2); +/* rd = rn | op2 */ +static CM_UINT32 s_asm_orr(CM_UINT32 rn, CM_UINT32 op2); + +/* 移位运算 */ +/* rd = rn << rm */ +static CM_UINT32 s_asm_lsl(CM_UINT32 rn, CM_UINT32 rm); +/* rd = rn >> rm */ +static CM_UINT32 s_asm_lsr(CM_UINT32 rn, CM_UINT32 rm); +/* rd = rn >>> rm */ +static CM_UINT64 s_asm_ror(CM_UINT64 rn, CM_UINT64 rm); + +/* 指令自检 */ +static void s_InstructionCheck(void); + +/* 寄存器自检 */ +static void s_RegCheck(void); + +/** + * @brief CPU自检 + */ +void PFM_CPUCheck(void) +{ + /*- 指令自检 */ + s_InstructionCheck(); + + /*- 寄存器自检 */ + s_RegCheck(); +} + +/** + * @brief 寄存器自检 + */ +static void s_RegCheck(void) +{ + /*- 变量初始化 */ + CM_UINT64 rslt[100] = {0u}; + + + rslt[0] = s_asm_x0((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[0] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[1] = s_asm_x0((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[1] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[2] = s_asm_x1((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[2] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[3] = s_asm_x1((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[3] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[4] = s_asm_x2((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[4] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[5] = s_asm_x2((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[5] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[6] = s_asm_x3((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[6] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[7] = s_asm_x3((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[7] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[8] = s_asm_x4((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[8] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[9] = s_asm_x4((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[9] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[10] = s_asm_x5((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[10] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[11] = s_asm_x5((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[11] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[12] = s_asm_x6((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[12] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[13] = s_asm_x6((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[13] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[14] = s_asm_x7((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[14] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[15] = s_asm_x7((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[15] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[16] = s_asm_x8((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[16] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[17] = s_asm_x8((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[17] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[18] = s_asm_x9((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[18] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[19] = s_asm_x9((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[19] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[20] = s_asm_x10((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[20] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[21] = s_asm_x10((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[21] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[22] = s_asm_x11((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[22] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[23] = s_asm_x11((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[23] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[24] = s_asm_x12((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[24] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[25] = s_asm_x12((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[25] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[26] = s_asm_x13((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[26] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[27] = s_asm_x13((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[27] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[28] = s_asm_x14((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[28] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[29] = s_asm_x14((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[29] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[30] = s_asm_x15((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[30] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[31] = s_asm_x15((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[31] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[32] = s_asm_x16((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[32] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[33] = s_asm_x16((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[33] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[34] = s_asm_x17((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[34] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[35] = s_asm_x17((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[35] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[36] = s_asm_x18((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[36] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[37] = s_asm_x18((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[37] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[38] = s_asm_x19((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[38] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[39] = s_asm_x19((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[39] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[40] = s_asm_x20((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[40] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[41] = s_asm_x20((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[41] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[42] = s_asm_x21((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[42] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[43] = s_asm_x21((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[43] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[44] = s_asm_x22((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[44] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[45] = s_asm_x22((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[45] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[46] = s_asm_x23((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[46] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[47] = s_asm_x23((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[47] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[48] = s_asm_x24((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[48] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[49] = s_asm_x24((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[49] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[50] = s_asm_x25((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[50] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[51] = s_asm_x25((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[51] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[52] = s_asm_x26((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[52] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[53] = s_asm_x26((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[53] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[54] = s_asm_x27((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[54] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[55] = s_asm_x27((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[55] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[56] = s_asm_x28((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[56] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[57] = s_asm_x28((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[57] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + /* x29是栈帧寄存器,不可用作通用寄存器,不自检 */ + + rslt[58] = s_asm_x30((CM_UINT64)0x55u); + CM_NM_ASSERT(rslt[58] == 0x55u, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + rslt[59] = s_asm_x30((CM_UINT64)0xaau); + CM_NM_ASSERT(rslt[59] == 0xaau, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); +} + +/** + * @brief 指令自检 + */ +static void s_InstructionCheck(void) +{ + /*- 变量初始化 */ + CM_INT64 rslt[100] = {0}; + /*- 算术运算自检 */ + rslt[0] = s_asm_add((CM_INT64)0x5500550000aa00aa, (CM_INT64)0x00aa00aa55005500); + CM_NM_ASSERT(rslt[0] == 0x55aa55aa55aa55aa, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rslt[1] = s_asm_sub((CM_INT64)0xaaccaaccaaccaaccU, (CM_INT64)0x33dd33dd33dd33dd); + CM_NM_ASSERT(rslt[1] == 0x76ef76ef76ef76ef, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rslt[2] = s_asm_madd((CM_INT64)0x33333333, (CM_INT64)0x5555, (CM_INT64)0xaaaa); + CM_NM_ASSERT(rslt[2] == 0x6c164fa5, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rslt[3] = s_asm_mneg((CM_INT64)0x5a5a,(CM_INT64)0x3c3c); + CM_NM_ASSERT(rslt[3] == -0x15424518, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rslt[4] = s_asm_msub((CM_INT64)0x7fffffff, (CM_INT64)0xa5a5, (CM_INT64)0x2b2b); + CM_NM_ASSERT(rslt[4] == 0x64117648, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rslt[5] = s_asm_mul((CM_INT64)0x4567,(CM_INT64)0xabcd); + CM_NM_ASSERT(rslt[5] == 0x2e93607b, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rslt[6] = s_asm_neg((CM_INT64)0x12345678); + CM_NM_ASSERT(rslt[6] == -0x12345678, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rslt[7] = s_asm_sdiv((CM_INT64)0x99999999U, (CM_INT64)0x33333333); + CM_NM_ASSERT(rslt[7] == 3, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + rslt[8] = (CM_INT64)s_asm_udiv((CM_UINT64)0xeeeeeeeeU, (CM_UINT64)0x22222222); + CM_NM_ASSERT(rslt[8] == 7, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + /*- 逻辑运算自检 */ + rslt[9] = (CM_INT64)s_asm_and((CM_UINT32)0x5c5c5c5c, (CM_UINT32)0xc5c5c5c5U); + CM_NM_ASSERT(rslt[9] == 0x44444444, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + rslt[10] = (CM_INT64)s_asm_bic((CM_UINT32)0x5c5c5c5c, (CM_UINT32)0xc5c5c5c5U); + CM_NM_ASSERT(rslt[10] == 0x18181818, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + rslt[11] = (CM_INT64)s_asm_eon((CM_UINT32)0x5c5c5c5c, (CM_UINT32)0xc5c5c5c5U); + CM_NM_ASSERT(rslt[11] == 0x66666666, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + rslt[12] = (CM_INT64)s_asm_eor((CM_UINT32)0x5c5c5c5c, (CM_UINT32)0xc5c5c5c5U); + CM_NM_ASSERT(rslt[12] == (CM_INT64)0x99999999U, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + rslt[13] = (CM_INT64)s_asm_mov((CM_UINT32)0x13579bdf); + CM_NM_ASSERT(rslt[13] == 0x13579bdf, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + rslt[14] = (CM_INT64)s_asm_mvn((CM_UINT32)0x13579bdf); + CM_NM_ASSERT(rslt[14] == (CM_INT64)0xeca86420U, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + rslt[15] = (CM_INT64)s_asm_orn((CM_UINT32)0x5c5c5c5c, (CM_UINT32)0xc5c5c5c5U); + CM_NM_ASSERT(rslt[15] == (CM_INT64)0x7e7e7e7e, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + rslt[16] = (CM_INT64)s_asm_orr((CM_UINT32)0x5c5c5c5c, (CM_UINT32)0xc5c5c5c5U); + CM_NM_ASSERT(rslt[16] == (CM_INT64)0xddddddddU, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + /*- 移位运算自检 */ + rslt[17] =(CM_INT64) s_asm_lsl((CM_UINT32)0x0055aa00,(CM_UINT32)4u); + CM_NM_ASSERT(rslt[17] == (CM_INT64)0x055aa000, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); + + rslt[18] = (CM_INT64)s_asm_lsr((CM_UINT32)0x0055aa00,(CM_UINT32)4u); + CM_NM_ASSERT(rslt[18] == (CM_INT64)0x00055aa0, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); + + rslt[19] = (CM_INT64)s_asm_ror((CM_UINT32)0x0055aa00,(CM_UINT32)4u); + CM_NM_ASSERT(rslt[19] == (CM_INT64)0x00055aa0, CPU_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); + +} + +/* 算术运算 */ +/* rd = rn + op2 */ +static CM_INT64 s_asm_add(CM_INT64 rn, CM_INT64 op2) +{ + CM_INT64 rd = 0; + + /* + * add rn,op2,rd + * rd = rn+op2 + */ + __asm__ __volatile__ + ( + "add %1,%2,%0;" + :"=r"(rd) + :"r"(rn),"r"(op2) + ); + + return rd; +} + +/* rd = rn - op */ +static CM_INT64 s_asm_sub(CM_INT64 rn, CM_INT64 op2) +{ + CM_INT64 rd = 0; + + __asm__ __volatile__ + ( + "sub %1,%2,%0;" + :"=r"(rd) + :"r"(op2),"r"(rn) + ); + + return rd; +} + +/* rd = ra + rn * rm */ +static CM_INT64 s_asm_madd(CM_INT64 ra, CM_INT64 rn, CM_INT64 rm) +{ + CM_INT64 rd = 0; + + __asm__ __volatile__ + ( + "madd %1,%2,%3,%0;" + :"=r"(rd) + :"r"(ra),"r"(rn),"r"(rm) + ); + + return rd; +} + +/* rd = - rn * rm */ +static CM_INT64 s_asm_mneg(CM_INT64 rn, CM_INT64 rm) +{ + CM_INT64 rd = 0; + + __asm__ __volatile__ + ( + "mneg %1,%2,%0;" + :"=r"(rd) + :"r"(rn),"r"(rm) + ); + + return rd; +} + +/* rd = ra - rn * rm */ +static CM_INT64 s_asm_msub(CM_INT64 ra, CM_INT64 rn, CM_INT64 rm) +{ + CM_INT64 rd = 0; + + __asm__ __volatile__ + ( + "msub %1,%2,%3,%0;" + :"=r"(rd) + :"r"(ra),"r"(rn),"r"(rm) + ); + + return rd; +} + +/* rd = rn * rm */ +static CM_INT64 s_asm_mul(CM_INT64 rn, CM_INT64 rm) +{ + CM_INT64 rd = 0; + + __asm__ __volatile__ + ( + "mul %1,%2,%0;" + :"=r"(rd) + :"r"(rn),"r"(rm) + ); + + return rd; +} + +/* rd = - op2 */ +static CM_INT64 s_asm_neg(CM_INT64 op2) +{ + CM_INT64 rd = 0; + + __asm__ __volatile__ + ( + "neg %1,%0;" + :"=r"(rd) + :"r"(op2) + ); + + return rd; +} + +/* rd = rn / rm (有符号数) */ +static CM_INT64 s_asm_sdiv(CM_INT64 rn, CM_INT64 rm) +{ + CM_INT64 rd = 0; + + __asm__ __volatile__ + ( + "sdiv %1,%2,%0;" + :"=r"(rd) + :"r"(rm),"r"(rn) + ); + + return rd; +} + +/* rd = rn / rm (无符号数) */ +static CM_UINT64 s_asm_udiv(CM_UINT64 rn, CM_UINT64 rm) +{ + CM_UINT64 rd = 0u; + + __asm__ __volatile__ + ( + "udiv %1,%2,%0;" + :"=r"(rd) + :"r"(rm),"r"(rn) + ); + + return rd; +} + +/* 逻辑运算 */ +/* rd = rn & op2 */ +static CM_UINT32 s_asm_and(CM_UINT32 rn, CM_UINT32 op2) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "and %1,%2,%0;" + :"=r"(rd) + :"r"(rn),"r"(op2) + ); + + return rd; +} + +/* rd = rn & ~op2 */ +static CM_UINT32 s_asm_bic(CM_UINT32 rn,CM_UINT32 op2) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "bic %1,%2,%0;" + :"=r"(rd) + :"r"(op2),"r"(rn) + ); + + return rd; +} + +/* rd = rn ^ ~op2 */ +static CM_UINT32 s_asm_eon(CM_UINT32 rn,CM_UINT32 op2) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "eon %1,%2,%0;" + :"=r"(rd) + :"r"(op2),"r"(rn) + ); + + return rd; +} + +/* rd = rn ^ op2 */ +static CM_UINT32 s_asm_eor(CM_UINT32 rn,CM_UINT32 op2) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "eor %1,%2,%0;" + :"=r"(rd) + :"r"(op2),"r"(rn) + ); + + return rd; +} + +/* rd = rn */ +static CM_UINT32 s_asm_mov(CM_UINT32 rn) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "mov %1,%0;" + :"=r"(rd) + :"r"(rn) + ); + + return rd; +} + +/* rd = ~op2 */ +static CM_UINT32 s_asm_mvn(CM_UINT32 op2) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "mvn %1,%0;" + :"=r"(rd) + :"r"(op2) + ); + + return rd; +} + +/* rd = rn | ~op2 */ +static CM_UINT32 s_asm_orn(CM_UINT32 rn, CM_UINT32 op2) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "orn %1,%2,%0;" + :"=r"(rd) + :"r"(op2),"r"(rn) + ); + + return rd; +} + +/* rd = rn | op2 */ +static CM_UINT32 s_asm_orr(CM_UINT32 rn, CM_UINT32 op2) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "orr %1,%2,%0;" + :"=r"(rd) + :"r"(op2),"r"(rn) + ); + + return rd; +} + +/* 移位运算 */ + +/* rd = rn << rm */ +static CM_UINT32 s_asm_lsl(CM_UINT32 rn, CM_UINT32 rm) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "lsl %1,%2,%0;" + :"=r"(rd) + :"r"(rm),"r"(rn) + ); + + return rd; +} + +/* rd = rn >> rm */ +static CM_UINT32 s_asm_lsr(CM_UINT32 rn, CM_UINT32 rm) +{ + CM_UINT32 rd = 0u; + + __asm__ __volatile__ + ( + "lsr %1,%2,%0;" + :"=r"(rd) + :"r"(rm),"r"(rn) + ); + + return rd; +} + +/* rd = rn >>> rm */ +static CM_UINT64 s_asm_ror(CM_UINT64 rn, CM_UINT64 rm) +{ + CM_UINT64 rd = 0u; + + __asm__ __volatile__ + ( + "ror %1,%2,%0;" + :"=r"(rd) + :"r"(rm),"r"(rn) + ); + + return rd; +} + + + +#endif + + + diff --git a/TSCP/src/MSCP/PFM/PFM_CPUCheck.h b/TSCP/src/MSCP/PFM/PFM_CPUCheck.h new file mode 100644 index 0000000..7f56dd5 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_CPUCheck.h @@ -0,0 +1,15 @@ +#ifndef PFM_CPUCHECK_H +#define PFM_CPUCHECK_H +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void PFM_CPUCheck(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_CPUUsage.c b/TSCP/src/MSCP/PFM/PFM_CPUUsage.c new file mode 100644 index 0000000..7fde8c0 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_CPUUsage.c @@ -0,0 +1,362 @@ +/* +* @filename PFM_CPUUsage.c +* @brief Platform Function Module:CPU使用率获取 +* @details +* +* @author GT-BU +* @date 2022.08.22 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2022.08.22 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_CPUUsage.h" +#include "PFM_Log.h" +#include "CM_Time.h" +#include "CM_Memory.h" +#include "DFM_Time.h" +#include "CFM_Net.h" +#ifdef WIN32 +static CM_INT32 pipe_fd[2]; + +CM_FLOAT32 g_CpuTotal_Usage = 0.0; +static CM_FLOAT32 g_Cpu_Usage[6] = {0.0}; +static ENUM_CM_RETURN CM_String_Split(IN CM_CHAR *src , IN const CM_CHAR *separator , INOUT CM_CHAR **dest , INOUT CM_INT32 *num); + +ENUM_CM_RETURN PFM_CPUUsage(void) +{ + +} + +/** +* @brief CPU使用率获取线程(子进程创建) +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +*/ +CM_THREAD_FUNC_T t_CpuUsage_GetC(IN CM_Thread_Arg_Struct_T* arg) +{ + return 0; +} + +/** +* @brief CPU使用率获取线程(父进程创建) +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +*/ +CM_THREAD_FUNC_T t_CpuUsage_GetP(IN CM_Thread_Arg_Struct_T* arg) +{ + return 0; +} + +/** +* @breif CPU使用率获取初始化 +* @param p_CpuUsageParaCPU使用率buf +* @details +*/ +void PFM_CpuUsage_Init(CM_UINT8 CpuUsageFlag) +{ + +} + +/** +* @brief 获取CPU合计使用率 +* @return CPU合计使用率,范围为0到100 +*/ +CM_FLOAT32 PFM_GetTotalCpuUsagePara(void) +{ + +} + +/** +* @brief 获取指定CPU使用率 +* @param 获取指定CPU使用率,值的范围为0到5 +* @return 指定CPU使用率,范围为0到100 +*/ +CM_FLOAT32 PFM_GetAppointCpuUsagePara(CM_UINT8 CpuIndex) +{ + +} + +/** +* @brief 字符串按指定分隔符分割子串 +* @param src 源字符串的首地址(buf的地址) +* @param separator 指定的分割字符 +* @param dest 接收子字符串的数组 +* @param num 分割后子字符串的个数 +* @return 连接结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +static ENUM_CM_RETURN CM_String_Split(IN CM_CHAR *src , IN const CM_CHAR *separator , INOUT CM_CHAR **dest , INOUT CM_INT32 *num) +{ + +} + +/** +* @brief 获取CPU使用率(子进程调用) +* @return +*/ +ENUM_CM_RETURN PFM_CPUUsageC(void) +{ + +} +/** +* @brief 获取CPU使用率(父进程调用) +* @return +*/ +ENUM_CM_RETURN PFM_CPUUsageP(void) +{ + +} +#else +typedef struct +{ + CM_UINT16 CpuTotalMem; + CM_UINT16 CpuAvailMem; + CM_FLOAT32 CpuTotal_Usage; + CM_FLOAT32 Cpu_Usage[6]; +}STRU_CPU_USAGE_T; +/*cpu使用率结构体*/ +static STRU_CPU_USAGE_T s_CpuUsage; + +static ENUM_CM_RETURN CM_String_Split(IN CM_CHAR *src , IN const CM_CHAR *separator , INOUT CM_CHAR **dest , INOUT CM_INT32 *num); +/** +* @brief CPU使用率获取线程(子进程创建) +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +*/ +CM_THREAD_FUNC_T t_CpuUsage_GetC(IN CM_Thread_Arg_Struct_T* arg) +{ +#ifdef QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)(0x01U | 0x02U); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + while(1) + { + rt = PFM_CPUUsageC(); + if (ENUM_CM_FALSE == rt) + { + MSCP_LOG_MSG("Warning:PFM_CPUUsageC error!!!\n"); + } + else + { + /* 无处理 */ + } + + /* 休眠1秒 */ + CM_Sleep(1000u); + } + return arg; +} + +/** +* @breif CPU使用率获取初始化 +* @param p_CpuUsageParaCPU使用率buf +* @details +*/ +void PFM_CpuUsage_Init(void) +{ + CM_BOOL threadrtn = CM_FALSE; + if (0x55u == g_PFM_Cfg.M_CpuUsageGet_Enable) + { + /*- 子进程,创建线程获取CPU使用率,并将数据通过管道发送给父进程 */ + threadrtn=CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)t_CpuUsage_GetC, "CpuUsage_C", 0, CM_TASK_PRIORITY_91, NULL); + CM_RE_ASSERT(CM_TRUE == threadrtn, CPU_USAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + } + else + { + /*应用没注册,不使用该功能*/ + } +} + +/** +* @brief 获取CPU合计使用率 +* @return CPU合计使用率,范围为0到100 +*/ +CM_FLOAT32 PFM_GetTotalCpuUsagePara(void) +{ + return s_CpuUsage.CpuTotal_Usage; +} + +/** +* @brief 获取指定CPU使用率 +* @param 获取指定CPU使用率,值的范围为0到5 +* @return 指定CPU使用率,范围为0到100 +*/ +CM_FLOAT32 PFM_GetAppointCpuUsagePara(CM_UINT8 CpuIndex) +{ + if (5u >= CpuIndex) + { + /* 无处理 */ + } + else + { + CM_RE_ASSERT(0, CPU_USAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + } + return s_CpuUsage.Cpu_Usage[CpuIndex]; +} +/** +* @brief CPU全部使用率暗文日志发送 +* @return 无 +*/ +void PFM_GetAllCpuUsageInterface(void) +{ + CM_UINT8 Cpu_UsageMem[11] = {0}; + Cpu_UsageMem[0] = (CM_UINT8)s_CpuUsage.CpuTotal_Usage; + /* 循环读取6行,每行内容为CPU从0到5的cpu空闲使用率 */ + for(int i=0;i<6;i++) + { + Cpu_UsageMem[i+1] = (CM_UINT8)s_CpuUsage.Cpu_Usage[i]; + } + CM_ShortToChar(s_CpuUsage.CpuTotalMem,&Cpu_UsageMem[7]); + CM_ShortToChar(s_CpuUsage.CpuAvailMem,&Cpu_UsageMem[9]); + MSCP_LOG_MSG("cpud usage Total:%d,C1:%d,C2:%d,C3:%d,C4:%d,C5:%d,C6:%d,MT:%dM,AM:%dM\n", + Cpu_UsageMem[0],Cpu_UsageMem[1],Cpu_UsageMem[2],Cpu_UsageMem[3],Cpu_UsageMem[4],Cpu_UsageMem[5],Cpu_UsageMem[6],s_CpuUsage.CpuTotalMem,s_CpuUsage.CpuAvailMem); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_CPUMEMUSAGE, 11U, Cpu_UsageMem); +} +/** +* @brief 字符串按指定分隔符分割子串 +* @param src 源字符串的首地址(buf的地址) +* @param separator 指定的分割字符 +* @param dest 接收子字符串的数组 +* @param num 分割后子字符串的个数 +* @return 连接结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +static ENUM_CM_RETURN CM_String_Split(IN CM_CHAR *src , IN const CM_CHAR *separator , INOUT CM_CHAR **dest , INOUT CM_INT32 *num) +{ + + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_CHAR *pNext; + CM_INT32 count = 0; + + if ((src == NULL) || (strlen(src) == 0U) || (separator == NULL) || (strlen(separator) == 0U)|| (dest == NULL) || (num == NULL)) + { + /*- 参数不合法 */ + rt = ENUM_CM_FALSE; + } + else + { + pNext = (CM_CHAR *)strtok(src,separator); /*必须使用(char *)进行强制类型转换(虽然不写有的编译器中不会出现指针错误)*/ + while(pNext != NULL) + { + *dest++ = pNext; + ++count; + pNext = (CM_CHAR *)strtok(NULL,separator); /*必须使用(char *)进行强制类型转换*/ + } + *num = count; + rt = ENUM_CM_TRUE; + } + /*- 返回结果 */ + return rt; +} +/** +* @brief 获取CPU使用率(子进程调用) +* @return +*/ +ENUM_CM_RETURN PFM_CPUUsageC(void) +{ + FILE *fp=NULL; + CM_CHAR StrLine[LINE_LEN] = {0}; /*每行最大读取的字符数*/ + CM_CHAR *unPackbuf[FIELD_LEN] = {0}; /*存放分割后的子字符串*/ + CM_INT32 num = 0; + CM_INT32 ret = -1; /*函数返回值*/ + CM_FLOAT32 percent=(CM_FLOAT32)0.0; + CM_FLOAT32 percenttmp=(CM_FLOAT32)0.0; + CM_FLOAT32 percentfull=(CM_FLOAT32)100.0; + CM_UINT16 TotalMem = 0u; + CM_UINT16 AvailMem = 0u; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + /* 通过popen函数,管道方式执行命令 */ + fp = popen("top -b -i 1","r"); + if(NULL != fp) + { + /* 读取一行,使文件读指针跳到第二行CPU信息行 */ + (void)fgets(StrLine,LINE_LEN,fp); + /* 读取一行,该行内容为CPU总计 */ + (void)CM_Memset(StrLine,0x00,sizeof(StrLine),sizeof(StrLine)); + (void)fgets(StrLine,LINE_LEN,fp); + /*将该行内容按照空格拆分,获取各字段值*/ + rt = CM_String_Split(&StrLine[0], " ", unPackbuf, &num); + if(ENUM_CM_TRUE == rt) + { + /*第三个字段为用户总计使用率,去掉该字段的百分号*/ + (void)sscanf(unPackbuf[2],"%f%%",&percenttmp); + /*第五个字段为内核总计使用率,去掉该字段的百分号*/ + (void)sscanf(unPackbuf[4],"%f%%",&percent); + percent += percenttmp; + s_CpuUsage.CpuTotal_Usage = percent; + } + else + { + /*无处理*/ + } + /* 循环读取6行,每行内容为CPU从0到5的cpu空闲使用率 */ + for(int i=0;i<6;i++) + { + /* 读取一行,该行内容为CPU空闲使用率 */ + (void)CM_Memset(StrLine,0x00,sizeof(StrLine),sizeof(StrLine)); + (void)fgets(StrLine,LINE_LEN,fp); + + /*将该行内容按照空格拆分,获取各字段值*/ + rt = CM_String_Split(&StrLine[0], " ", unPackbuf, &num); + if(ENUM_CM_TRUE == rt) + { + /*第四个字段为cpu空闲使用率,去掉该字段的百分号*/ + (void)sscanf(unPackbuf[3],"%f%%",&percent); + s_CpuUsage.Cpu_Usage[i] = percentfull-percent; + } + else + { + rt = ENUM_CM_FALSE; + } + } + /* 读取一行,该行内容为内存使用率 */ + (void)CM_Memset(StrLine,0x00,sizeof(StrLine),sizeof(StrLine)); + (void)fgets(StrLine,LINE_LEN,fp); + /*将该行内容按照空格拆分,获取各字段值*/ + rt = CM_String_Split(&StrLine[0], " ", unPackbuf, &num); + if(ENUM_CM_TRUE == rt) + { + (void)sscanf(unPackbuf[1],"%d%[A-Z]",&TotalMem); + (void)sscanf(unPackbuf[3],"%d%[A-Z]",&AvailMem); + /*赋值*/ + s_CpuUsage.CpuTotalMem = TotalMem; + s_CpuUsage.CpuAvailMem = AvailMem; + } + else + { + rt = ENUM_CM_FALSE; + } + + /* 关闭文件指针 */ + ret = pclose(fp); + if(-1 == ret) + { + perror("pclose failed"); + rt = ENUM_CM_FALSE; + } + else + { + + rt = ENUM_CM_TRUE; + } + } + else + { + perror("popen call failed"); + MSCP_LOG_MSG("popen call failed!!\n"); + MSCP_LOG_MSG("popen errno=%d,%s\n",errno,strerror(errno)); + rt = ENUM_CM_FALSE; + } + return rt; +} +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_CPUUsage.h b/TSCP/src/MSCP/PFM/PFM_CPUUsage.h new file mode 100644 index 0000000..58db863 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_CPUUsage.h @@ -0,0 +1,81 @@ +#ifndef PFM_CPUUSAGE_H +#define PFM_CPUUSAGE_H +#include "CM_Types.h" +#include "CM_Convert.h" +#include "CM_MultiThread.h" +#if QNX +#include +#endif +#ifdef __cplusplus +extern "C" +{ +#endif + +extern CM_FLOAT32 g_CpuTotal_Usage; +extern CM_FLOAT32 g_Cpu0_Usage[6]; +#define LINE_LEN (128u) +#define FIELD_LEN (30u) + +/** +* @brief CPU使用率获取函数(子进程调用) +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +*/ +ENUM_CM_RETURN PFM_CPUUsageCTest(void); + +/** +* @brief CPU使用率获取函数(子进程调用) +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +*/ +ENUM_CM_RETURN PFM_CPUUsageC(void); + +/** +* @brief CPU使用率获取函数(父进程调用) +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +*/ +ENUM_CM_RETURN PFM_CPUUsageP(void); + +/** +* @brief CPU使用率获取线程(子进程调用) +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +*/ +CM_THREAD_FUNC_T t_CpuUsage_GetC(IN CM_Thread_Arg_Struct_T* arg); + +/** +* @brief CPU使用率获取线程(父进程调用) +* @param arg 指向STRU_CFM_RECV_CTRL的指针 +* @details +*/ +CM_THREAD_FUNC_T t_CpuUsage_GetP(IN CM_Thread_Arg_Struct_T* arg); + +/** +* @breif CPU使用率获取初始化 +* @details +*/ +void PFM_CpuUsage_Init(void); + +/** +* @brief 获取CPU合计使用率 +* @return CPU合计使用率,范围为0到100 +*/ +CM_FLOAT32 PFM_GetTotalCpuUsagePara(void); + +/** +* @brief 获取指定CPU使用率 +* @param 获取指定CPU使用率,值的范围为0到5 +* @return 指定CPU使用率,范围为0到100 +*/ +CM_FLOAT32 PFM_GetAppointCpuUsagePara(CM_UINT8 CpuIndex); +/** +* @brief CPU全部使用率暗文日志发送 +* @return 无 +*/ +void PFM_GetAllCpuUsageInterface(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_Cfg.c b/TSCP/src/MSCP/PFM/PFM_Cfg.c new file mode 100644 index 0000000..4e76e68 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_Cfg.c @@ -0,0 +1,812 @@ +/** +* @file PFM_Cfg.c +* @brief Platform Function Module:配置文件管理 +* @details +* 读取平台配置信息 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_Cfg.h" +#include "CM_Memory.h" +#include "CM_IniFile.h" +#include "CM_Socket.h" /* inet_addr */ +#include "CM_MD5.h" /* inet_addr */ +#include "PFM_Log.h" +#include "PFM_CPUUsage.h" +#include "MSCP_APP_Interface.h" +#include "DFM_DRV.h" +#include "PFM_RemoteUpdate.h" +#include "CM_Time.h" +#include "CFM_Net.h" +#ifdef WIN32 +#include "conio.h" /* _getch() */ +#endif + + + +/** 平台配置ini */ +#define MAIN_BASE_INI "main_base.ini" +#define MAIN_ID_INI "main_id.ini" +#define MAIN_MD5_INI "main_md5.ini" + +/** 配置文件路径 */ +CM_CHAR FS_FILE_PATH[100]; + +/** 平台软件版本号 */ +const CM_UINT8 MSCP_SW_VERION[4] = { 93u, 1u, 1u, 51u }; +/** 驱动软件版本号 */ +CM_UINT8 MSCP_DRV_VERION[4] = {0}; +/** 与维护一体机接口文档版本号(接口文档发生改变时升级版本号) */ +CM_UINT16 TSCP_DOC_VERION[2] = {31u,0u}; +/** 操作系统版本号 */ +CM_UINT8 TSCP_QNX_VERION[10] = {0u}; + + + +/** 平台配置数据 */ +STRU_PFM_CFG_T g_PFM_Cfg; + +/** 维护模式远程部署功能配置数据 */ +STRU_RMUP_CFG_T g_RMUP_Cfg; + +/** 需应用注册的版本号 */ +STRU_APP_VERSON g_App_Verson; +/*应用基本参数配置结构体*/ +static STRU_APP_CFG_T g_AppCfgInterface; +static void s_str2md5(IN const CM_CHAR* str, OUT CM_UINT8 md5[16]); +static void PFM_CFG_Check_BoardID(void); +/** +* @brief 平台配置文件初始化 +*/ +void PFM_CFG_Init(void) +{ + /*- 变量初始化 */ + CM_INT32 cpuID = 0; /* CPU ID*/ + CM_INT32 i = 0; /* 循环变量 */ + ENUM_CM_RETURN rt = 0; /* 函数返回值 */ + CM_UINT64 tickstart = 0; /* 上电时间计时 */ + CM_CHAR buf[100]; /* 临时缓冲区 */ + /*- 保存软件版本信息 */ + MSCP_LOG_MSG("MSCP start version:%d.%d.%d.%d %s %s\n", + MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3], __DATE__, __TIME__); + (void)printf("MSCP start version:%d.%d.%d.%d \n", + MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3]); + /*- 读取ID信息 */ + g_PFM_Cfg.CPU_ID = (CM_UINT8)CM_GetProfileInt(MAIN_ID_INI,"ID","CPU_ID"); + CM_NM_ASSERT(0u != g_PFM_Cfg.CPU_ID, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + g_PFM_Cfg.BOARD_ID = (CM_UINT8)CM_GetProfileInt(MAIN_ID_INI, "ID", "BOARD_ID"); + CM_NM_ASSERT(0u != g_PFM_Cfg.BOARD_ID, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + + /*检查配置文件ID与硬件ID是否一致*/ + PFM_CFG_Check_BoardID(); + + g_PFM_Cfg.OUTNET_ID = (CM_UINT16)CM_GetProfileHex(MAIN_ID_INI, "ID", "OUTNET_ID"); + CM_NM_ASSERT(0u != g_PFM_Cfg.OUTNET_ID,CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + g_PFM_Cfg.INNET_ID = (CM_UINT16)CM_GetProfileHex(MAIN_ID_INI, "ID", "INNET_ID"); + CM_NM_ASSERT(0u != g_PFM_Cfg.INNET_ID,CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_4); + + g_PFM_Cfg.INNET_ID_RM = (CM_UINT16)CM_GetProfileHex(MAIN_ID_INI, "ID", "INNET_ID_RM"); + MSCP_LOG_MSG("Remote Update INNET_ID_RM = 0x%.2x",g_PFM_Cfg.INNET_ID_RM); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCFG_INIT1, 5, \ + sizeof(CM_UINT8),g_PFM_Cfg.CPU_ID, + sizeof(CM_UINT8),g_PFM_Cfg.BOARD_ID, + sizeof(CM_UINT16),g_PFM_Cfg.OUTNET_ID, + sizeof(CM_UINT16),g_PFM_Cfg.INNET_ID, + sizeof(CM_UINT16),g_PFM_Cfg.INNET_ID_RM); + (void)strcpy(FS_FILE_PATH,g_AppCfgInterface.FS_NAME); + (void)strcpy(g_PFM_Cfg.APP_NAME,g_AppCfgInterface.APP_NAME); + MSCP_LOG_MSG("FS_NAME:%s\n",FS_FILE_PATH); + MSCP_LOG_MSG("APP_NAME:%s\n",g_PFM_Cfg.APP_NAME); + + rt = CM_GetProfileString(MAIN_MD5_INI, "MD5_CONFIG", g_PFM_Cfg.APP_NAME, buf); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_5); + + rt = CM_MD5_Calc((CM_UINT8*)&g_AppCfgInterface,sizeof(STRU_APP_CFG_T),g_PFM_Cfg.CFG_MD5); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_6); + + s_str2md5(buf, g_PFM_Cfg.APP_MD5); + MSCP_LOG_MSG("BOARD_ID = %d\nCPU_ID = %d\nINNET_ID = %04X\nOUTNET_ID = %04X\nINNET_ID_RM\n", + g_PFM_Cfg.BOARD_ID, g_PFM_Cfg.CPU_ID, g_PFM_Cfg.INNET_ID, g_PFM_Cfg.OUTNET_ID, g_PFM_Cfg.INNET_ID_RM); + + /*- 读取平台功能配置 */ + g_PFM_Cfg.CYC_TIME = g_AppCfgInterface.CYC_TIME; + g_PFM_Cfg.OutnetSafePack_Len = (TSCP_CYC_DATAMAX_LEN * g_PFM_Cfg.CYC_TIME)/100u; + + g_PFM_Cfg.app_num = g_AppCfgInterface.app_num; + g_PFM_Cfg.CC_VER = 0u; + g_PFM_Cfg.M_2oo2_Enable = g_AppCfgInterface.M_2oo2_Enable; + g_PFM_Cfg.M_2x2_Enable = g_AppCfgInterface.M_2x2_Enable; + g_PFM_Cfg.M_InnetSafe_Enable = g_AppCfgInterface.M_InnetSafe_Enable; + g_PFM_Cfg.M_InnetRaw_Enable = g_AppCfgInterface.M_InnetRaw_Enable; + g_PFM_Cfg.M_OutnetSafe_Enable = g_AppCfgInterface.M_OutnetSafe_Enable; + g_PFM_Cfg.M_OutnetRaw_Enable = g_AppCfgInterface.M_OutnetRaw_Enable; + g_PFM_Cfg.M_CpuUsageGet_Enable = g_AppCfgInterface.M_CpuUsageGet_Enable; + g_PFM_Cfg.M_RemoteUpdate_Enable = g_AppCfgInterface.M_RemoteUpdate_Enable; + (void)strcpy(g_PFM_Cfg.Start_Path,g_AppCfgInterface.Start_Path); + g_PFM_Cfg.reboot_replycount = g_AppCfgInterface.reboot_replycount; + g_PFM_Cfg.M_AutoReboot_Count = g_AppCfgInterface.M_AutoReboot_Count; + g_PFM_Cfg.M_AutoClear_Days = g_AppCfgInterface.M_AutoClear_Days; + MSCP_LOG_MSG("CYC_TIME:%d\n",g_PFM_Cfg.CYC_TIME); + MSCP_LOG_MSG("app_num:%d\n",g_PFM_Cfg.app_num); + MSCP_LOG_MSG("CC_VER:%d\n",g_PFM_Cfg.CC_VER); + MSCP_LOG_MSG("M_2oo2_Enable:0x%x\n",g_PFM_Cfg.M_2oo2_Enable); + MSCP_LOG_MSG("M_2x2_Enable:0x%x\n",g_PFM_Cfg.M_2x2_Enable); + MSCP_LOG_MSG("M_InnetSafe_Enable:0x%x\n",g_PFM_Cfg.M_InnetSafe_Enable); + MSCP_LOG_MSG("M_InnetRaw_Enable:0x%x\n",g_PFM_Cfg.M_InnetRaw_Enable); + MSCP_LOG_MSG("M_OutnetSafe_Enable:0x%x\n",g_PFM_Cfg.M_OutnetSafe_Enable); + MSCP_LOG_MSG("M_OutnetRaw_Enable:0x%x\n",g_PFM_Cfg.M_OutnetRaw_Enable); + MSCP_LOG_MSG("M_CpuUsageGet_Enable:0x%x\n",g_PFM_Cfg.M_CpuUsageGet_Enable); + MSCP_LOG_MSG("M_RemoteUpdate_Enable:0x%x\n",g_PFM_Cfg.M_RemoteUpdate_Enable); + MSCP_LOG_MSG("Start_Path:%s\n",g_PFM_Cfg.Start_Path); + MSCP_LOG_MSG("reboot_replycount:%d\n",g_PFM_Cfg.reboot_replycount); + MSCP_LOG_MSG("M_AutoReboot_Count:%d\n",g_PFM_Cfg.M_AutoReboot_Count); + MSCP_LOG_MSG("M_AutoClear_Days:%d\n",g_PFM_Cfg.M_AutoClear_Days); + PFM_CFG_SendDarkCfg(); + if (0u != g_PFM_Cfg.M_AutoClear_Days) + { + tickstart = CM_GetSecTick(); /* 上电时间计时/秒 */ + MSCP_LOG_MSG("tickstart = %lld\n",tickstart); + g_PFM_Cfg.M_AutoClear_Second = tickstart + g_PFM_Cfg.M_AutoClear_Days*24u*60u*60u; /* 擦除历史宕机文件阈值单位秒 */ + MSCP_LOG_MSG("g_PFM_Cfg.M_Clear_Second = %llu\n",g_PFM_Cfg.M_AutoClear_Second); + } + else + { + + } + /*- @alias 读取2x2oo2平台各CPU的通信配置 */ + for (cpuID = 1; cpuID <= 4; cpuID++) + { + (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_2oo2,g_AppCfgInterface.CPU[cpuID-1].IP_2oo2); + g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Data = 51001; + g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Data_App = 51005; + g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_2x2_State = 51006; + + g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Time = 51002; + g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Maintenance = 51004; + + (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_2x2,g_AppCfgInterface.CPU[cpuID-1].IP_2x2); + g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Data = 52001; + g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Time = 52002; + g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Syn = 52003; + g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_State = 52004; + + (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_Maintain, g_AppCfgInterface.CPU[cpuID-1].IP_Maintain); + (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_Com, g_AppCfgInterface.CPU[cpuID-1].IP_Com); + (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_Out, g_AppCfgInterface.CPU[cpuID-1].IP_Out); + (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_Com_Extend, g_AppCfgInterface.CPU[cpuID-1].IP_Com_Extend); + + /*读取内网透传参数*/ + g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num = g_AppCfgInterface.Port_Innet_Raw_Num; + CM_NM_ASSERT(g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num <= 9, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_7); + /*读取内网透传扩展参数*/ + g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num = g_AppCfgInterface.Port_Innet_Raw_Extend_Num; + CM_NM_ASSERT(g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num <= 9, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_8); + MSCP_LOG_MSG("Port_Innet_Raw_Num:%d,%d\n",g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num,g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num); + for(i = 1u;i <= (g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num + + g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num); + i++) + { + (void)CM_Memcpy(&g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i],sizeof(STRU_PFM_INNET_RAW_T), + &g_AppCfgInterface.Innet_Raw_Parameter[i-1],sizeof(STRU_PFM_INNET_RAW_T)); + MSCP_LOG_MSG("[%d]Port_Type_Enable:%d\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].Port_Type_Enable); + MSCP_LOG_MSG("[%d]Port_Innet_Raw:%d\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].Port_Innet_Raw); + MSCP_LOG_MSG("[%d]Server_DevId:%d\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].Server_DevId); + MSCP_LOG_MSG("[%d]IP_InnetRaw_maddr:%s\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].IP_InnetRaw_maddr); + MSCP_LOG_MSG("[%d]TIME_STAMP_ENABLE:0x%x\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].TIME_STAMP_ENABLE); + MSCP_LOG_MSG("[%d]INNET_2oo2_RAW:0x%x\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].INNET_2oo2_RAW); + MSCP_LOG_MSG("[%d]INNET_2x2_RAW:0x%x\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].INNET_2x2_RAW); + } + g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Safe = g_AppCfgInterface.Port_Innet_Safe; + g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Safe = g_AppCfgInterface.Port_Outnet_Safe; + g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Raw = g_AppCfgInterface.Port_Outnet_Raw; + g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Heart = 53003; + g_PFM_Cfg.CPU_CFG[cpuID].Port_Log_Base = g_AppCfgInterface.CPU[cpuID-1].Logger_PortBase; + g_PFM_Cfg.CPU_CFG[cpuID].Port_Log_Ciphertext = g_AppCfgInterface.CPU[cpuID-1].Logger_PortCiphertext; + g_PFM_Cfg.CPU_CFG[cpuID].Port_Remote_Update = g_AppCfgInterface.Port_Remote_Update; + MSCP_LOG_MSG("CPU[%d]IP_2oo2:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_2oo2); + MSCP_LOG_MSG("CPU[%d]IP_2x2:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_2x2); + MSCP_LOG_MSG("CPU[%d]IP_Maintain:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_Maintain); + MSCP_LOG_MSG("CPU[%d]IP_Com:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_Com); + MSCP_LOG_MSG("CPU[%d]IP_Out:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_Out); + MSCP_LOG_MSG("CPU[%d]IP_Com_Extend:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_Com_Extend); + + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, (TSCP_DARK_PFMCFG_INIT2 + cpuID - 1), 18, \ + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Data, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Data_App, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_2x2_State, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Time, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Maintenance, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Data, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Time, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Syn, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_State, + sizeof(CM_INT32),g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num, + sizeof(CM_INT32),g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Safe, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Safe, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Raw, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Heart, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Log_Base, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Log_Ciphertext, + sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Remote_Update); + } + + /*- 确定本机通信配置 */ + cpuID = (CM_INT32)CM_UNSIGNED_INT_EXP((((CM_UINT32)g_PFM_Cfg.BOARD_ID - 1u) * 2u) + (CM_UINT32)g_PFM_Cfg.CPU_ID); + rt = CM_Memcpy(&g_PFM_Cfg.Local_Cfg, sizeof(STRU_PFM_CPU_CFG_T), &g_PFM_Cfg.CPU_CFG[cpuID], sizeof(STRU_PFM_CPU_CFG_T)); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_9); + + /*- 确定2oo2邻机通信配置 */ + cpuID = (CM_INT32)CM_UNSIGNED_INT_EXP((((CM_UINT32)g_PFM_Cfg.BOARD_ID - 1u) * 2u) + (3u - (CM_UINT32)g_PFM_Cfg.CPU_ID)); + rt = CM_Memcpy(&g_PFM_Cfg.Peer_Cfg, sizeof(STRU_PFM_CPU_CFG_T), &g_PFM_Cfg.CPU_CFG[cpuID], sizeof(STRU_PFM_CPU_CFG_T)); + CM_NM_ASSERT(ENUM_CM_TRUE == rt,CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_10); + + /*- 确定2x2对机(对系)通信配置 */ + cpuID = (CM_INT32)CM_UNSIGNED_INT_EXP(((2u - (CM_UINT32)g_PFM_Cfg.BOARD_ID) * 2u) + (CM_UINT32)g_PFM_Cfg.CPU_ID); + rt = CM_Memcpy(&g_PFM_Cfg.Partner_Cfg, sizeof(STRU_PFM_CPU_CFG_T), &g_PFM_Cfg.CPU_CFG[cpuID], sizeof(STRU_PFM_CPU_CFG_T)); + CM_NM_ASSERT(ENUM_CM_TRUE == rt, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_11); + + /*- @alias 读取通控(CC)的IP配置 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + (void)strcpy(g_PFM_Cfg.CC_R_IP,g_AppCfgInterface.OutNetRed.CC_G_IP); + (void)strcpy(g_PFM_Cfg.CC_B_IP,g_AppCfgInterface.OutNetBlue.CC_G_IP); + (void)strcpy(g_PFM_Cfg.EXTEND_R_IP,g_AppCfgInterface.OutNetRed.EXTEND_G_IP); + (void)strcpy(g_PFM_Cfg.EXTEND_B_IP,g_AppCfgInterface.OutNetBlue.EXTEND_G_IP); + } + else + { + (void)strcpy(g_PFM_Cfg.CC_R_IP,g_AppCfgInterface.OutNetRed.CC_P_IP); + (void)strcpy(g_PFM_Cfg.CC_B_IP,g_AppCfgInterface.OutNetBlue.CC_P_IP); + (void)strcpy(g_PFM_Cfg.EXTEND_R_IP,g_AppCfgInterface.OutNetRed.EXTEND_P_IP); + (void)strcpy(g_PFM_Cfg.EXTEND_B_IP,g_AppCfgInterface.OutNetBlue.EXTEND_P_IP); + } + /*- 读取通控的端口配置 */ + g_PFM_Cfg.CC_R_OutnetSafe_Port = g_AppCfgInterface.OutNetRed.OutnetSafe_Port; + g_PFM_Cfg.CC_R_OutnetRaw_Port = g_AppCfgInterface.OutNetRed.OutnetRaw_Port; + g_PFM_Cfg.CC_R_InnetRaw_Port = g_AppCfgInterface.OutNetRed.InnetRaw_Port; + g_PFM_Cfg.CC_R_Heart_Port = 53003; + + g_PFM_Cfg.CC_B_OutnetSafe_Port = g_AppCfgInterface.OutNetBlue.OutnetSafe_Port;; + g_PFM_Cfg.CC_B_OutnetRaw_Port = g_AppCfgInterface.OutNetBlue.OutnetRaw_Port; + g_PFM_Cfg.CC_B_InnetRaw_Port = g_AppCfgInterface.OutNetBlue.InnetRaw_Port; + g_PFM_Cfg.CC_B_Heart_Port = 53003; + MSCP_LOG_MSG("CC_R_IP:%s\n",g_PFM_Cfg.CC_R_IP); + MSCP_LOG_MSG("CC_B_IP:%s\n",g_PFM_Cfg.CC_B_IP); + MSCP_LOG_MSG("EXTEND_R_IP:%s\n",g_PFM_Cfg.EXTEND_R_IP); + MSCP_LOG_MSG("EXTEND_B_IP:%s\n",g_PFM_Cfg.EXTEND_B_IP); + MSCP_LOG_MSG("CC_R_OutnetSafe_Port:%d\n",g_PFM_Cfg.CC_R_OutnetSafe_Port); + MSCP_LOG_MSG("CC_R_OutnetRaw_Port:%d\n",g_PFM_Cfg.CC_R_OutnetRaw_Port); + MSCP_LOG_MSG("CC_R_InnetRaw_Port:%d\n",g_PFM_Cfg.CC_R_InnetRaw_Port); + MSCP_LOG_MSG("CC_B_OutnetSafe_Port:%d\n",g_PFM_Cfg.CC_B_OutnetSafe_Port); + MSCP_LOG_MSG("CC_B_OutnetRaw_Port:%d\n",g_PFM_Cfg.CC_B_OutnetRaw_Port); + MSCP_LOG_MSG("CC_B_InnetRaw_Port:%d\n",g_PFM_Cfg.CC_B_InnetRaw_Port); + + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCFG_INIT3, 8, \ + sizeof(CM_UINT16),g_PFM_Cfg.CC_R_OutnetSafe_Port, + sizeof(CM_UINT16),g_PFM_Cfg.CC_R_OutnetRaw_Port, + sizeof(CM_UINT16),g_PFM_Cfg.CC_R_InnetRaw_Port, + sizeof(CM_UINT16),g_PFM_Cfg.CC_R_Heart_Port, + sizeof(CM_UINT16),g_PFM_Cfg.CC_B_OutnetSafe_Port, + sizeof(CM_UINT16),g_PFM_Cfg.CC_B_OutnetRaw_Port, + sizeof(CM_UINT16),g_PFM_Cfg.CC_B_InnetRaw_Port, + sizeof(CM_UINT16),g_PFM_Cfg.CC_B_Heart_Port); + + /*- @alias 读取日志记录的IP配置 */ + if ((CM_UINT8)1u == g_PFM_Cfg.CPU_ID) + { + (void)strcpy(g_PFM_Cfg.Logger_IP,g_AppCfgInterface.Logger_G_IP); + } + else + { + (void)strcpy(g_PFM_Cfg.Logger_IP,g_AppCfgInterface.Logger_P_IP); + } + MSCP_LOG_MSG("Logger_IP:%s\n",g_PFM_Cfg.Logger_IP); + /*读取内网通信设备的通信配置*/ + /*- 读取内通信设备数量 */ + g_PFM_Cfg.INNET_COM_NUM = g_AppCfgInterface.INNET_COM_NUM; + MSCP_LOG_MSG("INNET_COM_NUM:%d\n",g_PFM_Cfg.INNET_COM_NUM); + CM_NM_ASSERT(g_PFM_Cfg.INNET_COM_NUM <= 255, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_12); + + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCFG_INIT4, 3, \ + sizeof(CM_UINT16),g_PFM_Cfg.Logger_PortBase, + sizeof(CM_UINT16),g_PFM_Cfg.Logger_PortCiphertext, + sizeof(CM_UINT16),g_PFM_Cfg.INNET_COM_NUM); + + /*- @alias 读取所有内网透传设备通信配置 */ + for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++) + { + (void)CM_Memcpy(&g_PFM_Cfg.INNET_COM_CFG[i],sizeof(STRU_PFM_INNET_CFG_T),&g_AppCfgInterface.INNET_COM_CFG[i-1],sizeof(STRU_PFM_INNET_CFG_T)); + MSCP_LOG_MSG("[%d]InnetID:0x%x\n",i,g_PFM_Cfg.INNET_COM_CFG[i].InnetID); + MSCP_LOG_MSG("[%d]IP_G:%d.%d.%d.%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].IP_G&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_G>>8)&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_G>>16)&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_G>>24)&0xFF); + MSCP_LOG_MSG("[%d]Port_Raw_G:%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_G); + MSCP_LOG_MSG("[%d]Port_Safe_G:%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].Port_Safe_G); + MSCP_LOG_MSG("[%d]IP_P:%d.%d.%d.%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].IP_P&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_P>>8)&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_P>>16)&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_P>>24)&0xFF); + MSCP_LOG_MSG("[%d]Port_Raw_P:%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_P); + MSCP_LOG_MSG("[%d]Port_Safe_P:%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].Port_Safe_P); + } + /*设置维护终端ID*/ + PFM_SetMaintenanceId(g_AppCfgInterface.ID_Maintenance); + + /*CPU使用率获取初始化*/ + PFM_CpuUsage_Init(); + /*大小端转换*/ + TSCP_DOC_VERION[0] = CM_ShortFromChar(&TSCP_DOC_VERION[0]); + TSCP_DOC_VERION[1] = CM_ShortFromChar(&TSCP_DOC_VERION[1]); + + (void)DFM_GetQNX_Verion(TSCP_QNX_VERION); + MSCP_LOG_MSG("TSCP_QNX_VERION : %d.%d.%d.%d\n",TSCP_QNX_VERION[0],TSCP_QNX_VERION[1],TSCP_QNX_VERION[2],TSCP_QNX_VERION[3]); + (void)printf("TSCP_QNX_VERION : %d.%d.%d.%d\n",TSCP_QNX_VERION[0],TSCP_QNX_VERION[1],TSCP_QNX_VERION[2],TSCP_QNX_VERION[3]); +} +/** +* @brief 字符串转MD5码 +* @param str 字符串 +* @param md5 字符串对应的md5码 +*/ +static void s_str2md5(IN const CM_CHAR* str, OUT CM_UINT8 md5[16]) +{ + /*- 变量初始化 */ + CM_UINT32 len = strlen(str); + CM_UINT32 i = 0u; + CM_UINT32 val = 0u; + CM_UINT32 offset = 0u; + /*- 入参检查 */ + CM_NM_ASSERT((CM_UINT32)((31u == len) || (32u == len)) && ((NULL != str) && (NULL != md5)), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + /*- MD5码长度是否为31字节(最高位是0)*/ + if (31u == len) + { + /*- 读取第1字节 */ + (void)sscanf(str, "%1x", &val); + offset = 1u; + } + /*- MD5码长度是否为32字节(最高位不是0)*/ + else if (32u == len) + { + /*- 读取前2字节 */ + (void)sscanf(str, "%2x", &val); + offset = 2u; + } + else + { + /*- 无效输入 */ + CM_NM_ASSERT(0u, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + } + + /*- 给MD5码第1位赋值 */ + md5[0u] = (CM_UINT8)val; + /*- @alias 循环读取后15位MD5码 */ + for (i = 0u; i < 15u; i++) + { + (void)sscanf(str + (offset + (i * 2u)), "%2x", &val); + md5[1u + i] = (CM_UINT8)val; + } +} + +/** +* @brief 获取板卡ID +* @return 板卡ID +* @details +* 板卡ID根据板卡所在槽位确定 +*/ +CM_UINT8 PFM_CFG_GetBoardID(void) +{ + /*- 返回板卡ID */ + return g_PFM_Cfg.BOARD_ID; +} + +/** +* @brief 获取CPUID +* @return CPUID +* @details +* CPUID根据配置文件确定 +*/ +CM_UINT8 PFM_CFG_GetCpuID(void) +{ + /*- 返回CPUID */ + return g_PFM_Cfg.CPU_ID; +} + +/** +* @brief 获取外网ID +* @return 外网ID +* @details +* 设备ID在配置文件中配置 +*/ +CM_UINT16 PFM_CFG_GetOutnetID(void) +{ + /*- 返回设备ID */ + return g_PFM_Cfg.OUTNET_ID; +} + +/** +* @brief 获取外网ID +* @return 外网ID +* @details +* 设备ID在配置文件中配置 +*/ +CM_UINT16 PFM_CFG_GetInnetID(void) +{ + /*- 返回设备ID */ + return g_PFM_Cfg.INNET_ID; +} + + +/** +* @brief 根据内网ID获取设备通信信息 +* @param InnetID 内网ID +* @return 查找结果 +* - 非NULL 指向设备通信信息的指针 +* - NULL 查找失败 +*/ +STRU_PFM_INNET_CFG_T *PFM_INI_InnetID2Addr(IN CM_UINT16 InnetID) +{ + /*- 变量初始化 */ + STRU_PFM_INNET_CFG_T *pCom = NULL; + CM_INT32 i = 0; + /*- 开始遍历内网通信配置:是否遍历完成:下一条配置 */ + for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++) + { + /*- 是否找到了目标内网ID */ + if (InnetID == g_PFM_Cfg.INNET_COM_CFG[i].InnetID) + { + /*- 输出通信配置信息 */ + pCom = &g_PFM_Cfg.INNET_COM_CFG[i]; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + /*- 返回查找结果 */ + return pCom; +} + +/** +* @brief 根据内网IP端口查找设备通信配置 +* @param InnetIP 内网IP +* @param InnetPort 内网端口 +* @return 查找结果 +* - 非NULL 指向设备通信信息的指针 +* - NULL 查找失败 +*/ +STRU_PFM_INNET_CFG_T *PFM_INI_InnetIP2Addr(IN CM_UINT32 InnetIP,IN CM_UINT16 InnetPort) +{ + /*- 变量初始化 */ + STRU_PFM_INNET_CFG_T *pCom = NULL; + CM_INT32 i = 0; + /*- 本机是否是CPU1 */ + if ((CM_UINT8)1u == g_PFM_Cfg.CPU_ID) + { + /*- 开始遍历通信配置:通信配置是否遍历完成:继续遍历通信配置 */ + for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++) + { + /*- 是否找到了一致的绿网地址 */ + if (( InnetIP == g_PFM_Cfg.INNET_COM_CFG[i].IP_G) + && ((CM_UINT16_MAX == g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_G) + ||(InnetPort == g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_G)||(InnetPort == g_PFM_Cfg.INNET_COM_CFG[i].Port_Safe_G))) + { + /*- 输出通信配置 */ + pCom = &g_PFM_Cfg.INNET_COM_CFG[i]; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + } + else + { + /*- 开始遍历通信配置:通信配置是否遍历完成:继续遍历通信配置 */ + for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++) + { + /*- 是否找到了一致的紫网地址 */ + if ((InnetIP == g_PFM_Cfg.INNET_COM_CFG[i].IP_P) + && ((CM_UINT16_MAX == g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_P) + ||(InnetPort == g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_P)||(InnetPort == g_PFM_Cfg.INNET_COM_CFG[i].Port_Safe_P))) + { + /*- 输出通信配置 */ + pCom = &g_PFM_Cfg.INNET_COM_CFG[i]; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + } + /*- 返回通信配置 */ + return pCom; +} + +/** +* @brief 根据内网ID获取设备通信信息(维护模式下使用) +* @param InnetID 内网ID +* @return 查找结果 +* - 非NULL 指向设备通信信息的指针 +* - NULL 查找失败 +*/ +STRU_PFM_INNET_CFG_T *PFM_INI_RmInnetID2Addr(IN CM_UINT16 InnetID) +{ + /*- 变量初始化 */ + STRU_PFM_INNET_CFG_T *pCom = NULL; + CM_INT32 i = 0; + /*- 开始遍历内网通信配置:是否遍历完成:下一条配置 */ + for (i = 1; i <= (CM_INT32)g_RMUP_Cfg.INNET_COM_NUM; i++) + { + /*- 是否找到了目标内网ID */ + if (InnetID == g_RMUP_Cfg.INNET_COM_CFG[i].InnetID) + { + /*- 输出通信配置信息 */ + pCom = &g_RMUP_Cfg.INNET_COM_CFG[i]; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + /*- 返回查找结果 */ + return pCom; +} + +/** +* @brief 根据内网IP端口查找设备通信配置(维护模式下使用) +* @param InnetIP 内网IP +* @param InnetPort 内网端口 +* @return 查找结果 +* - 非NULL 指向设备通信信息的指针 +* - NULL 查找失败 +*/ +STRU_PFM_INNET_CFG_T *PFM_INI_RmInnetIP2Addr(IN CM_UINT32 InnetIP,IN CM_UINT16 InnetPort) +{ + /*- 变量初始化 */ + STRU_PFM_INNET_CFG_T *pCom = NULL; + CM_INT32 i = 0; + /*- 本机是否是CPU1 */ + if ((CM_UINT8)1u == g_RMUP_Cfg.CPU_ID) + { + /*- 开始遍历通信配置:通信配置是否遍历完成:继续遍历通信配置 */ + for (i = 1; i <= (CM_INT32)g_RMUP_Cfg.INNET_COM_NUM; i++) + { + /*- 是否找到了一致的绿网地址 */ + if (( InnetIP == g_RMUP_Cfg.INNET_COM_CFG[i].IP_G) + && ((CM_UINT16_MAX == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Raw_G) + ||(InnetPort == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Raw_G)||(InnetPort == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Safe_G))) + { + /*- 输出通信配置 */ + pCom = &g_RMUP_Cfg.INNET_COM_CFG[i]; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + } + else + { + /*- 开始遍历通信配置:通信配置是否遍历完成:继续遍历通信配置 */ + for (i = 1; i <= (CM_INT32)g_RMUP_Cfg.INNET_COM_NUM; i++) + { + /*- 是否找到了一致的紫网地址 */ + if ((InnetIP == g_RMUP_Cfg.INNET_COM_CFG[i].IP_P) + && ((CM_UINT16_MAX == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Raw_P) + ||(InnetPort == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Raw_P)||(InnetPort == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Safe_P))) + { + /*- 输出通信配置 */ + pCom = &g_RMUP_Cfg.INNET_COM_CFG[i]; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + } + /*- 返回通信配置 */ + return pCom; +} + +/** +* @brief 板卡id自检 +*/ +void PFM_CFG_IfconfigIp(void) +{ +#ifdef QNX + /*- 变量初始化 */ + CM_UINT8 DrvBoard_ID = DFM_getBoardID(); /* 板卡ID */ + CM_CHAR str[1024] = {0}; + (void)memset(str, 0, sizeof(str)); + MSCP_LOG_MSG("drv_boardid:0x%x\r\n",DrvBoard_ID); + switch(DrvBoard_ID) + { + /*1-1*/ + case 0x53U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.144.101"); + /*- 跳出 */ + break; + case 0x33U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.146.101"); + /*- 跳出 */ + break; + case 0x63U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.145.101"); + /*- 跳出 */ + break; + /*1-2*/ + case 0x55U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.16.102"); + /*- 跳出 */ + break; + case 0x35U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.18.102"); + /*- 跳出 */ + break; + case 0x65U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.17.102"); + /*- 跳出 */ + break; + /*2-1*/ + case 0xA6U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.144.103"); + /*- 跳出 */ + break; + case 0xC6U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.146.103"); + /*- 跳出 */ + break; + case 0x96U: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.145.103"); + /*- 跳出 */ + break; + /*2-2*/ + case 0xAAU: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.16.104"); + /*- 跳出 */ + break; + case 0xCAU: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.18.104"); + /*- 跳出 */ + break; + case 0x9AU: + sprintf(str, "ifconfig %s %s", "wm0", "192.168.17.104"); + /*- 跳出 */ + break; + default: + MSCP_LOG_MSG("drv_boardidErr:0x%x,ini:0x%x,0x%x\r\n",DrvBoard_ID,g_PFM_Cfg.BOARD_ID,g_PFM_Cfg.CPU_ID); + /*- 跳出 */ + break; + } + (void)printf("%s\n",str); + (void)system(str); +#endif /*QNX*/ +} + +/** +* @brief 初始化应用版本号管理结构体 +*/ +void PFM_CFG_RegisterVerson_Init(void) +{ + /*- 变量初始化 */ + CM_UINT8 i = 0u; + CM_UINT8 j = 0u; + g_App_Verson.versonNumber = 0u; + + /*- @alias 初始化应用版本号管理结构体 */ + for(i = 0u; i < 3u; i++) + { + g_App_Verson.registerVerson[i].flag = 0u; + g_App_Verson.registerVerson[i].versonName = i + 1u; + for(j = 0u; j < 4u; j++) + { + g_App_Verson.registerVerson[i].verson[j] = 0u; + } + } + +} + +/** +* @brief 应用配置ip、端口、使能等可配置变量 +* @param app_data 应用配置结构体 取值范围:非空 +* @details 此配置用来代替main_base.ini +*/ +void PFM_Set_APP_ConfigData(STRU_APP_CFG_T *app_data) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + /*- 如果入参为空 */ + if(NULL == app_data) + { + /*- 无处理 */ + } + else + { + /*- 应用配置ip、端口、使能等可配置变量 */ + ret = CM_Memcpy(&g_AppCfgInterface,sizeof(STRU_APP_CFG_T),app_data,sizeof(STRU_APP_CFG_T)); + } + + /*- 判断是否配置成功 */ + CM_NM_ASSERT(ENUM_CM_TRUE == ret, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); +} + +/** +* @brief 板卡id自检 +*/ +static void PFM_CFG_Check_BoardID(void) +{ +#ifdef QNX + CM_UINT8 DrvBoard_ID = DFM_getBoardID(); /**< 板卡ID */ + MSCP_LOG_MSG("drv_boardid:0x%x\r\n",DrvBoard_ID); + switch(DrvBoard_ID) + { + /*1-1*/ + case 0x53U: + case 0x33U: + case 0x63U: + CM_NM_ASSERT(((CM_UINT8)1U == g_PFM_Cfg.BOARD_ID) && ((CM_UINT8)1U == g_PFM_Cfg.CPU_ID), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + /*- 跳出 */ + break; + /*1-2*/ + case 0x55U: + case 0x35U: + case 0x65U: + CM_NM_ASSERT(((CM_UINT8)1U == g_PFM_Cfg.BOARD_ID) && ((CM_UINT8)2U == g_PFM_Cfg.CPU_ID), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + /*- 跳出 */ + break; + /*2-1*/ + case 0xA6U: + case 0xC6U: + case 0x96U: + CM_NM_ASSERT(((CM_UINT8)2U == g_PFM_Cfg.BOARD_ID) && ((CM_UINT8)1U == g_PFM_Cfg.CPU_ID), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + /*- 跳出 */ + break; + /*2-2*/ + case 0xAAU: + case 0xCAU: + case 0x9AU: + CM_NM_ASSERT(((CM_UINT8)2U == g_PFM_Cfg.BOARD_ID) && ((CM_UINT8)2U == g_PFM_Cfg.CPU_ID), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + /*- 跳出 */ + break; + default: + MSCP_LOG_MSG("drv_boardidErr:0x%x,ini:0x%x,0x%x\r\n",DrvBoard_ID,g_PFM_Cfg.BOARD_ID,g_PFM_Cfg.CPU_ID); + CM_NM_ASSERT(0, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + /*- 跳出 */ + break; + } +#endif /*QNX*/ +} + +void PFM_CFG_SendDarkCfg(void) +{ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCFG_SENDDARKCFG, 14u, \ + sizeof(CM_UINT32),g_PFM_Cfg.CYC_TIME, + sizeof(CM_UINT32),g_PFM_Cfg.OutnetSafePack_Len, + sizeof(CM_INT32),g_PFM_Cfg.app_num, + sizeof(CM_UINT32),g_PFM_Cfg.M_2oo2_Enable, + sizeof(CM_UINT32),g_PFM_Cfg.M_2x2_Enable, + sizeof(CM_UINT32),g_PFM_Cfg.M_InnetSafe_Enable, + sizeof(CM_UINT32),g_PFM_Cfg.M_InnetRaw_Enable, + sizeof(CM_UINT32),g_PFM_Cfg.M_OutnetSafe_Enable, + sizeof(CM_UINT32),g_PFM_Cfg.M_OutnetRaw_Enable, + sizeof(CM_UINT8),g_PFM_Cfg.M_CpuUsageGet_Enable, + sizeof(CM_UINT32),g_PFM_Cfg.M_RemoteUpdate_Enable, + sizeof(CM_INT32),g_PFM_Cfg.reboot_replycount, + sizeof(CM_UINT8),g_PFM_Cfg.M_AutoReboot_Count, + sizeof(CM_UINT16),g_PFM_Cfg.M_AutoClear_Days); +} + diff --git a/TSCP/src/MSCP/PFM/PFM_Cfg.h b/TSCP/src/MSCP/PFM/PFM_Cfg.h new file mode 100644 index 0000000..d2b7f7a --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_Cfg.h @@ -0,0 +1,352 @@ +/** +* @file PFM_Cfg.h +* @brief Platform Function Module:配置文件管理 +* @details +* 读取平台配置信息 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef PFM_CFG_H +#define PFM_CFG_H + +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern const CM_UINT8 MSCP_SW_VERION[4]; /**< 平台软件版本 */ +extern CM_UINT8 MSCP_DRV_VERION[4]; /**< 驱动软件版本 */ +extern CM_UINT16 TSCP_DOC_VERION[2]; /** 与维护一体机接口文档版本号(接口文档发生改变时升级版本号) */ +extern CM_UINT8 TSCP_QNX_VERION[10]; /** 操作系统版本号 */ +#define MSCP_CPU_1 (1u) /**< CPU ID: CPU1 */ +#define MSCP_CPU_2 (2u) /**< CPU ID: CPU2 */ + +#define MSCP_CYC_TIME (g_PFM_Cfg.CYC_TIME) +#define TCP_CONN_MAX (9u) +/*内网透传双通道数量*/ +#define INNET_RAW_DOUBLE_PASS_NUM (20u) +/*所有双通道数量*/ +#define MSCP_DOUBLE_PASS_ALL_NUM (INNET_RAW_DOUBLE_PASS_NUM + 5u) + +#define TSCP_CYC_DATAMAX_LEN (40000u) + + /** 网络通信开关类型 */ + typedef enum + { + RAW_COM_DISENABLE = 0, /**< 网络通信禁用 */ + RAW_COM_UDP = 1, /**< 网络通信 UDP*/ + RAW_COM_BROADCAST = 2, /**< 网络通信 UDP广播*/ + RAW_COM_TCP = 3 /**< 网络通信 TCP*/ + }RAW_COM_TYPE; + /** 内网透传通信配置参数 */ + typedef struct + { + CM_UINT16 Port_Innet_Raw; /**< 内网透明传输端口 */ + RAW_COM_TYPE Port_Type_Enable; /**< 内网透明tcp传输模式 */ + CM_UINT16 Server_DevId; /**< 服务端设备类型和id */ + CM_UINT16 TIME_STAMP_ENABLE; /**< 2取2乘时间戳使能开关 */ + CM_UINT16 INNET_2oo2_RAW; /**< 透传通道2取开关 */ + CM_UINT16 INNET_2x2_RAW; /**< 透传通道2乘开关 */ + CM_CHAR IP_InnetRaw_maddr[32]; /**< 内网透传的组播IP */ + }STRU_PFM_INNET_RAW_T; + /**< CPU通信配置 */ + typedef struct + { + /*注意IP字段必须为32字节*/ + CM_CHAR IP_2oo2[32]; /**< 2oo2通信IP */ + CM_UINT16 Port_2oo2_Data; /**< 2oo2数据通信端口 */ + CM_UINT16 Port_2oo2_Data_App; /**< 应用2oo2数据通信端口 */ + CM_UINT16 Port_2oo2_Time; /**< 2oo2校时端口 */ + CM_UINT16 Port_2oo2_Maintenance; /**< 2oo2维护端口 */ + CM_UINT16 Port_2oo2_2x2_State; /**< 2oo2 2x状态交互端口 */ + + CM_CHAR IP_2x2[32]; /**< 2x2通信IP */ + CM_UINT16 Port_2x2_Data; /**< 2x2数据通信端口 */ + CM_UINT16 Port_2x2_Time; /**< 2x2校时端口 */ + CM_UINT16 Port_2x2_Syn; /**< 2x2同步端口 */ + CM_UINT16 Port_2x2_State; /**< 2x2状态交互端口 */ + + CM_CHAR IP_Com[32]; /**< 通用通信IP */ + CM_CHAR IP_Out[32]; /**< 外网通信IP */ + CM_CHAR IP_Com_Extend[32]; /**< 通用通信扩展IP */ + CM_CHAR IP_Maintain[32]; /**< 维护通信IP */ + CM_UINT16 Port_Outnet_Safe; /**< 外网安全通信端口 */ + CM_UINT16 Port_Innet_Safe; /**< 内网安全通信端口 */ + CM_UINT16 Port_Outnet_Raw; /**< 外网透明传输端口 */ + CM_UINT16 Port_Outnet_Heart; /**< 外网心跳传输端口 */ + CM_INT32 Port_Innet_Raw_Num; /**< 内网透传端口数量 */ + CM_INT32 Port_Innet_Raw_Extend_Num; /**< 内网透传扩展端口数量 */ + STRU_PFM_INNET_RAW_T Innet_Raw_Parameter[INNET_RAW_DOUBLE_PASS_NUM]; /*内网透传参数*/ + + CM_UINT16 Port_Log_Base; /**< 明文日志记录端口 */ + CM_UINT16 Port_Log_Ciphertext; /**< 暗文日志记录端口 */ + + CM_UINT16 Port_Remote_Update; /**< 远程部署通信端口 */ + }STRU_PFM_CPU_CFG_T; + + /** 内网通信配置 */ + typedef struct + { + CM_UINT16 InnetID; /**< 内网通信ID */ + CM_UINT32 IP_G; /**< 绿网IP */ + CM_UINT16 Port_Raw_G; /**< 绿网透传端口 */ + CM_UINT16 Port_Safe_G; /**< 绿网安全端口 */ + CM_UINT32 IP_P; /**< 紫网IP */ + CM_UINT16 Port_Raw_P; /**< 紫网透传端口 */ + CM_UINT16 Port_Safe_P; /**< 紫网安全端口 */ + }STRU_PFM_INNET_CFG_T; + + /** 平台配置数据 */ + typedef struct + { + CM_UINT8 CFG_MD5[16]; /**< 配置数据md5 */ + CM_CHAR APP_NAME[128]; /**< 应用文件名称 */ + CM_UINT8 APP_MD5[16]; /**< 应用文件md5 */ + + /*注意IP字段必须为32字节*/ + CM_UINT8 CPU_ID; /**< CPU ID */ + CM_UINT8 BOARD_ID; /**< 板卡ID */ + CM_UINT16 OUTNET_ID; /**< 外网通信ID */ + CM_UINT16 INNET_ID; /**< 内网通信ID */ + CM_UINT16 INNET_ID_RM; /**< 远程部署内网通信ID */ + + CM_UINT32 CYC_TIME; /**< 系统周期 */ + CM_INT32 app_num; /**< app任务数 */ + CM_UINT8 CC_VER; /**< 与CC通信协议版本 */ + CM_UINT32 OutnetSafePack_Len;/**< 外网安全通信最大数据长度(根据周期长度计算) */ + CM_UINT32 M_2oo2_Enable; /**< 2oo2功能开关 */ + CM_UINT32 M_2x2_Enable; /**< 2x2功能开关*/ + CM_UINT32 M_InnetSafe_Enable; /**< 内网安全通信功能开关 */ + CM_UINT32 M_InnetRaw_Enable; /**< 内网透传通信功能开关 */ + CM_UINT32 M_OutnetSafe_Enable;/**< 外网安全通信功能开关 */ + CM_UINT32 M_OutnetRaw_Enable;/**< 外网透传通信功能开关 */ + CM_UINT8 M_CpuUsageGet_Enable; /**< CPU使用率获取功能开关 */ + CM_UINT32 M_RemoteUpdate_Enable; /**< 远程部署内网安全通信功能开关 */ + CM_CHAR Start_Path[32]; /**< 程序启动路径 */ + CM_INT32 reboot_replycount; /**< 重启确认报文回复次数 */ + CM_UINT8 M_AutoReboot_Count; /**< 自动重启次数 */ + CM_UINT16 M_AutoClear_Days; /**< 连续运行多久清空宕机次数的天数 */ + CM_UINT64 M_AutoClear_Second; /**< 连续运行多久清空宕机次数的秒数 */ + STRU_PFM_CPU_CFG_T Local_Cfg; /*本机通信配置*/ + STRU_PFM_CPU_CFG_T Peer_Cfg; /*2oo2邻机通信配置*/ + STRU_PFM_CPU_CFG_T Partner_Cfg; /*2x2对机(对系)通信配置*/ + + CM_CHAR CC_R_IP[32]; /**< 红网通控的内网IP */ + CM_CHAR EXTEND_R_IP[32]; /**< 红网扩展板卡的内网IP */ + CM_UINT16 CC_R_OutnetSafe_Port; /**< 红网CC的外网安全通信端口 */ + CM_UINT16 CC_R_OutnetRaw_Port; /**< 红网CC的外网透传通信端口 */ + CM_UINT16 CC_R_InnetRaw_Port; /**< 红网CC的内网透传通信端口 */ + CM_UINT16 CC_R_Heart_Port; /**< 红网CC的内网透传通信端口 */ + + CM_CHAR CC_B_IP[32]; /**< 蓝网通控的内网IP */ + CM_CHAR EXTEND_B_IP[32]; /**< 蓝网扩展板卡的内网IP */ + CM_UINT16 CC_B_OutnetSafe_Port; /**< 蓝网CC的外网安全通信端口 */ + CM_UINT16 CC_B_OutnetRaw_Port; /**< 蓝网CC的外网透传通信端口 */ + CM_UINT16 CC_B_InnetRaw_Port; /**< 蓝网CC的内网透传通信端口 */ + CM_UINT16 CC_B_Heart_Port; /**< 蓝网CC的内网透传通信端口 */ + + CM_CHAR Logger_IP[32]; /**< 日志记录IP */ + CM_UINT16 Logger_PortBase; /**< 明文日志对端端口 */ + CM_UINT16 Logger_PortCiphertext; /**< 暗文日志对端端口 */ + + /*以下通常仅PFM_CFG内部使用*/ + STRU_PFM_CPU_CFG_T CPU_CFG[5]; /**< 各CPU的通信配置,数组1-4有效 */ + CM_UINT16 INNET_COM_NUM; /**< 内网通信设备数量 */ + STRU_PFM_INNET_CFG_T INNET_COM_CFG[256]; /**< 内网通信设备通信配置(数组1-INNET_COM_NUM有效) */ + }STRU_PFM_CFG_T; + + /** 维护模式远程部署功能配置数据 */ + typedef struct + { + CM_UINT8 CFG_MD5[16]; /**< 配置数据md5 */ + CM_UINT32 CYC_TIME; /**< 系统周期 */ + CM_CHAR APP_NAME[128]; /**< 应用文件名称 */ + CM_UINT8 APP_MD5[16]; /**< 应用文件md5 */ + CM_UINT8 CPU_ID; /**< CPU ID */ + CM_UINT8 BOARD_ID; /**< 板卡ID */ + CM_UINT16 INNET_ID_RM; /**< 远程部署内网通信设备ID */ + CM_UINT16 OUTNET_ID; /**< 外网通信设备ID */ + CM_UINT32 M_2oo2_Enable; /**< 2oo2功能开关 */ + CM_UINT32 M_RemoteUpdate_Enable; /**< 远程部署内网安全通信功能开关 */ + CM_CHAR Start_Path[32]; /**< 程序启动路径 */ + CM_INT32 reboot_replycount; /**< 重启确认报文回复次数 */ + CM_UINT16 INNET_COM_NUM; /**< 内网通信设备数量 */ + STRU_PFM_INNET_CFG_T INNET_COM_CFG[256]; /**< 内网通信设备通信配置(数组1-INNET_COM_NUM有效) */ + }STRU_RMUP_CFG_T; + + /** 应用IP配置数据 */ + typedef struct + { + /*注意IP字段必须为32字节*/ + CM_CHAR IP_2oo2[32]; /**< 2oo2通信IP */ + CM_CHAR IP_2x2[32]; /**< 2x2通信IP */ + CM_CHAR IP_Out[32]; /**< 外网通信IP */ + CM_CHAR IP_Maintain[32]; /**< 维护通信IP */ + /*适用透传通道-选配*/ + CM_CHAR IP_Com[32]; /**< 通用通信IP */ + CM_CHAR IP_Com_Extend[32];/**< 通用通信扩展IP */ + CM_UINT16 Logger_PortBase; /**< 明文日志记录端口 */ + CM_UINT16 Logger_PortCiphertext; /**< 暗文日志记录端口 */ + }STRU_APP_CPU_CFG_T; + /** 应用外网配置数据 */ + typedef struct + { + CM_CHAR CC_G_IP[32]; /**< 通控的内网IP */ + CM_CHAR CC_P_IP[32]; /**< 通控的内网IP */ + CM_CHAR EXTEND_G_IP[32]; /**< 扩展板卡的内网IP */ + CM_CHAR EXTEND_P_IP[32]; /**< 扩展板卡的内网IP */ + CM_UINT16 OutnetSafe_Port; /**< 外网安全通信端口 */ + CM_UINT16 OutnetRaw_Port; /**< 外网透传通信端口 */ + CM_UINT16 InnetRaw_Port; /**< 内网透传通信端口 */ + }STRU_APP_CC_CFG_T; + /** 应用配置数据 */ + typedef struct + { + /*文件配置*/ + CM_CHAR FS_NAME[128]; /**< FS文件名称 */ + CM_CHAR APP_NAME[128]; /**< 应用文件名称 */ + /*基本开关配置*/ + CM_UINT32 CYC_TIME; /**< 系统周期 */ + CM_INT32 app_num; /**< app任务数 */ + CM_UINT32 M_2oo2_Enable; /**< 2oo2功能开关 */ + CM_UINT32 M_2x2_Enable; /**< 2x2功能开关*/ + CM_UINT32 M_InnetSafe_Enable; /**< 内网安全通信功能开关 */ + CM_UINT32 M_InnetRaw_Enable; /**< 内网透传通信功能开关 */ + CM_UINT32 M_OutnetSafe_Enable; /**< 外网安全通信功能开关 */ + CM_UINT32 M_OutnetRaw_Enable; /**< 外网透传通信功能开关 */ + CM_UINT8 M_CpuUsageGet_Enable; /**< CPU使用率获取功能开关 */ + CM_UINT32 M_RemoteUpdate_Enable;/**< 远程部署内网安全通信功能开关 */ + CM_UINT16 ID_Maintenance; /*维护终端ID*/ + CM_CHAR Start_Path[32]; /**< 程序启动路径 */ + CM_INT32 reboot_replycount; /**< 重启确认报文回复次数 */ + CM_UINT8 M_AutoReboot_Count; /**< 自动重启次数 */ + CM_UINT16 M_AutoClear_Days; /**< 连续运行多久清空宕机次数的天数 */ + /*IP配置*/ + STRU_APP_CPU_CFG_T CPU[4]; /*每个CPU的IP配置*/ + /*通用端口配置*/ + CM_UINT16 Port_Outnet_Safe; /**< 外网安全通信端口 */ + CM_UINT16 Port_Innet_Safe; /**< 内网安全通信端口 */ + CM_UINT16 Port_Outnet_Raw; /**< 外网透明传输端口 */ + CM_UINT16 Port_Remote_Update; /**< 远程部署通信端口 */ + /*透传配置-选配*/ + CM_INT32 Port_Innet_Raw_Num; /**< 内网透传端口数量 */ + CM_INT32 Port_Innet_Raw_Extend_Num; /**< 内网透传扩展端口数量 */ + STRU_PFM_INNET_RAW_T Innet_Raw_Parameter[INNET_RAW_DOUBLE_PASS_NUM]; /*内网透传参数*/ + /*外网通信配置*/ + STRU_APP_CC_CFG_T OutNetRed; /*外网红网通信配置*/ + STRU_APP_CC_CFG_T OutNetBlue; /*外网蓝网通信配置*/ + /*日志记录目标设备IP配置*/ + CM_CHAR Logger_G_IP[32]; /**< 绿网日志记录IP */ + CM_CHAR Logger_P_IP[32]; /**< 紫网日志记录IP */ + /*内网通信设备注册最大支持0-254*/ + CM_UINT16 INNET_COM_NUM; /**< 内网通信设备数量 */ + STRU_PFM_INNET_CFG_T INNET_COM_CFG[255]; /**< 内网通信设备通信配置(数组0-254有效) */ + }STRU_APP_CFG_T; + + typedef struct + { + CM_UINT8 flag; /**< 应用是否注册该版本号 0代表未注册 1代表注册*/ + CM_UINT8 versonName; /**< 注册版本号类别 1代表应用版本号 2代表FS版本号 3代表Scade版本号 */ + CM_UINT8 verson[4]; /**< 版本号 */ + }STRU_APP_REGISTER_VERSON; + + typedef struct + { + CM_UINT8 versonNumber; /**< 已注册版本号数量 初始值为0 */ + STRU_APP_REGISTER_VERSON registerVerson[3]; /**< 版本号信息 */ + }STRU_APP_VERSON; + + /** 需应用注册的版本号 */ + extern STRU_APP_VERSON g_App_Verson; + + /** 平台配置数据 */ + extern STRU_PFM_CFG_T g_PFM_Cfg; + + /** 维护模式远程部署功能配置数据 */ + extern STRU_RMUP_CFG_T g_RMUP_Cfg; + /** 配置文件路径 */ + extern CM_CHAR FS_FILE_PATH[100]; + + /* 配置文件初始化 */ + void PFM_CFG_Init(void); + + /* 根据内网ID查内网通信配置 */ + STRU_PFM_INNET_CFG_T *PFM_INI_InnetID2Addr(IN CM_UINT16 InnetID); + + /* 根据内网IP端口查内网通信配置 */ + STRU_PFM_INNET_CFG_T *PFM_INI_InnetIP2Addr(IN CM_UINT32 InnetIP, IN CM_UINT16 InnetPort); + /** + * @brief 获取本机外网ID + * @return 本机外网ID + * @note 1字节类型+1字节ID,大端格式,来自INI配置文件。 + */ + CM_UINT16 PFM_CFG_GetOutnetID(void); + + /** + * @brief 获取本机内网ID + * @return 本机内网ID + * @note 1字节类型+1字节ID,大端格式,来自INI配置文件。 + */ + CM_UINT16 PFM_CFG_GetInnetID(void); + + /** + * @brief 获取板卡ID + * @return 本机的板卡ID + * @note 板卡ID的宏定义参见本文件头部 + */ + CM_UINT8 PFM_CFG_GetBoardID(void); + + /** + * @brief 获取CPUID + * @return CPUID + * @details + * CPUID根据配置文件确定 + */ + CM_UINT8 PFM_CFG_GetCpuID(void); + /** + * @brief 根据内网IP端口查找设备通信配置(维护模式下使用) + * @param InnetIP 内网IP + * @param InnetPort 内网端口 + * @return 查找结果 + * - 非NULL 指向设备通信信息的指针 + * - NULL 查找失败 + */ + STRU_PFM_INNET_CFG_T *PFM_INI_RmInnetIP2Addr(IN CM_UINT32 InnetIP,IN CM_UINT16 InnetPort); + /** + * @brief 根据内网ID获取设备通信信息(维护模式下使用) + * @param InnetID 内网ID + * @return 查找结果 + * - 非NULL 指向设备通信信息的指针 + * - NULL 查找失败 + */ + STRU_PFM_INNET_CFG_T *PFM_INI_RmInnetID2Addr(IN CM_UINT16 InnetID); + + /** + * @brief 应用配置ip、端口、使能等可配置变量 + * @param app_data 应用配置结构体 取值范围:非空 + * @details 此配置用来代替main_base.ini + */ + void PFM_Set_APP_ConfigData(STRU_APP_CFG_T *app_data); + + /** + * @brief 初始化应用版本号管理结构体 + */ + void PFM_CFG_RegisterVerson_Init(void); + + /* 根据板卡配置维护ip */ + void PFM_CFG_IfconfigIp(void); + + void PFM_CFG_SendDarkCfg(void); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.c b/TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.c new file mode 100644 index 0000000..6344855 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.c @@ -0,0 +1,372 @@ +/** +* @file PFM_ControlFlowCheck.c +* @brief Platform Function Module:控制流状态监督 +* @details +* 采用改进的CFCSS算法,静态签名为大质数,校验运算为大质数因式分解 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_ControlFlowCheck.h" +#include "CM_Time.h" +#include "DFM_Time.h" +#include "PFM_Log.h" +#include "CM_Atomic.h" +#include "PFM_Cfg.h" +#include "DFM_DRV.h" +#include "CFM_Net.h" + +#if QNX +#include +#include /* ThreadCtl BMP绑定CPU*/ + +#define CM_ATOMIC_CLR(loc,bits) (atomic_clr((loc),(bits))) +#define CM_ATOMIC_SET(loc,bits) (atomic_set((loc),(bits))) +#else +#define CM_ATOMIC_CLR(loc,bits) ((*(loc)) &= (~(bits))) +#define CM_ATOMIC_SET(loc,bits) ((*(loc)) |= (bits)) +#endif + +/* 记录控制流步骤 */ +CM_INT32 g_PFM_Check = 0; +/** 静态签名 */ +static const CM_INT32 s_key_S[61] = +{ 0, +10007,10039,10061,10067,10079,10091,10099,10103,10111,10133, +10139,10141,14151,10159,10163,10177,10181,10193,10211,10223, +10243,10247,10253,10267,10271,10289,10301,10313,10333,10337, +10343,10357,10369,10391,10399,10427,10429,10433,10453,10457, +10463,10477,10487,10499,10501,10513,10529,10531,10599,10567, +10589,10597,10601,10607,10613,10627,10631,10639,10651,10657 +}; + +/** 调整码 */ +static CM_INT32 s_key_d[61]; + +/** 监督码 */ +static CM_INT32 s_key_G; + +/** 运行标记 */ +static CM_ATOMIC CM_UINT32 s_RunFlag; + +/** 主看门狗运行标记 */ +static CM_ATOMIC CM_UINT32 s_RunFlag_MainDog; + +/** 备看门狗运行标记 */ +static CM_ATOMIC CM_UINT32 s_RunFlag_PrepareDog; + +/** +* @brief 控制流检查算法初始化 +*/ +void PFM_CFC_Init(void) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; /* 循环变量 */ + +#if (PFM_CFC_PROC_NUM >= 60) + CM_ASSERT(0u, CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); +#endif + + s_key_d[1] = s_key_S[PFM_CFC_PROC_NUM] * s_key_S[1]; + /*- @alias 初始化调整码*/ + for (i = 2; i <= PFM_CFC_PROC_NUM; i++) + { + s_key_d[i] = s_key_S[i - 1] * s_key_S[i]; + } + + /*- 监督码初值为循环最后一个代码块的静态签名*/ + s_key_G = s_key_S[PFM_CFC_PROC_NUM]; +} + +/** +* @brief 控制流校验 +* @param step 当前执行阶段 +*/ +void PFM_CFC_Check(CM_INT32 step) +{ + g_PFM_Check = step; + /*- 变量初始化 */ + CM_INT32 res = 0; /* 临时变量 */ + + /*- 入口检查 */ + CM_ASSERT((0 < step) && (step <= PFM_CFC_PROC_NUM), CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + + /*- 校验运算1 */ + res = s_key_d[step] % s_key_G; + CM_ASSERT(res == 0, CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + /*- 校验运算2,并更新监督码 */ + s_key_G = s_key_d[step] / s_key_G; + CM_ASSERT(s_key_G == s_key_S[step], CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); +} + +/** +* @brief 获取当前的执行阶段 +* @return 当前执行阶段 +*/ +CM_INT32 PFM_CFC_GetCurStep(void) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; /* 循环变量 */ + CM_INT32 keyG = s_key_G; /* 临时变量 */ + /*- @alias 遍历静态签名查找监督码对应执行阶段 */ + for (i = PFM_CFC_PROC_NUM; i > 0; i--) + { + if (s_key_S[i] == keyG) + { + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + /* 输出当前执行阶段 */ + return i; +} + +/** +* @brief 平台状态监督/主狗 +*/ +void PFM_CFC_Monitor(void) +{ + /*- 变量初始化 */ + CM_UINT64 startTimer = 0u; + CM_UINT64 nowTimer = 0u; + CM_UINT64 leftTimer = 0u; + + CM_UINT64 startTimer1 = 0u; + CM_UINT64 leftTimer1 = 0u; + + CM_INT32 step = 0; /* 程序步骤 */ + CM_UINT32 cycTime = g_PFM_Cfg.CYC_TIME + 21u; + CM_UINT32 cycTime1 = g_PFM_Cfg.CYC_TIME + 41u; + CM_UINT32 cycCount = g_PFM_Cfg.CYC_TIME/2u + 1u; + CM_UINT8 loop_count = 0u; + /*- @alias 等待主任务启动 */ + while (0u == CM_ATOMIC_LOAD(&s_RunFlag)) + { + /*- 休眠等待进入主周期并且以喂狗 */ + CM_Sleep(2u); + } + + /*- 主狗喂狗 */ + (void)PFM_CFC_WatchDog_Main(); + + /*- @alias 等待备看门狗启动 */ + while (0u == CM_ATOMIC_LOAD(&s_RunFlag_PrepareDog)) + { + /*- 休眠等待备狗以喂狗 */ + CM_Sleep(2u); + loop_count++; + if(cycCount < loop_count ) + { + /*- 如果轮询了周期时间/2次备狗还未启动 ,已经出现异常,宕机处理 */ + MSCP_LOG_MSG("prepare watchdog start timeout. \n"); +#ifdef QNX + (void)DFM_ledMonitor(2u); +#endif + CM_RE_ASSERT(0, CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + + } + else + { + /*- 无处理 */ + } + } + + /*- 循环等待软中断 */ + while (1) + { + /*- 主狗喂狗 */ + (void)PFM_CFC_WatchDog_Main(); + /*- 平台主线程以喂狗,并且备狗以喂狗,并且喂狗时间合法*/ + if(0x55u == CM_ATOMIC_LOAD(&s_RunFlag)) + { + /*- 清除运行标志 */ + (void)CM_ATOMIC_STORE(&s_RunFlag, 0x00u); + startTimer = CM_GetTick(); +#ifdef QNX + (void)DFM_ledMonitor(1u); +#endif + } + /*- 只要leftTimer大于等于cycTime就宕机*/ + else if(leftTimer >= cycTime) + { + /*- 宕机并输出平台所处步骤 */ + step = PFM_CFC_GetCurStep(); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCONTROFLOWCHECK_MONITOR1, 3u, \ + sizeof(CM_INT32),step, + sizeof(CM_UINT64),leftTimer, + sizeof(CM_UINT32),cycTime); + MSCP_LOG_MSG("timeout at step %d,s_RunFlag = 0x%.2x,leftTimer = %lu,cycTime = %lu\n",step,s_RunFlag,leftTimer,cycTime); + (void)printf("timeout at step %d,s_RunFlag = 0x%.2x,leftTimer = %lu,cycTime = %u\n",step,s_RunFlag,leftTimer,cycTime); +#ifdef QNX + (void)DFM_ledMonitor(2u); +#endif + CM_RE_ASSERT(0, CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + } + else + { + /*- 无处理 */ + } + + /*- 备狗以喂狗,并且喂狗时间合法*/ + if(0x55u == CM_ATOMIC_LOAD(&s_RunFlag_PrepareDog)) + { + /*- 清除运行标志 */ + (void)CM_ATOMIC_STORE(&s_RunFlag_PrepareDog, 0x00u); + startTimer1 = CM_GetTick(); + } + /*- 只要leftTimer1大于等于cycTime就宕机*/ + else if(leftTimer1 >= cycTime1) + { + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCONTROFLOWCHECK_MONITOR2, 2u, \ + sizeof(CM_UINT64),leftTimer1, + sizeof(CM_UINT32),cycTime1); + MSCP_LOG_MSG("prepare watchdog timeout,s_RunFlag_PrepareDog = 0x%.2x,leftTimer = %lu,leftTimer1 = %lu,cycTime1 = %lu\n",s_RunFlag_PrepareDog,leftTimer,leftTimer1,cycTime1); +#ifdef QNX + (void)DFM_ledMonitor(2u); +#endif + CM_RE_ASSERT(0, CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + } + else + { + /*- 无处理 */ + } + + /*- 计算喂狗至当前的时间 */ + CM_Sleep(WATCH_DOG_POLL_TIME); + nowTimer = CM_GetTick(); + leftTimer = (nowTimer - startTimer) / 1000000u; + leftTimer1 = (nowTimer - startTimer1) / 1000000u; + + } +} +/** +* @brief 主看门狗状态监督/备狗 +*/ +CM_THREAD_FUNC_T MSCP_WatchDog(void) +{ + /*- 变量初始化 */ + CM_UINT64 startTimer = 0u; + CM_UINT64 nowTimer = 0u; + CM_UINT64 leftTimer = 0u; + CM_UINT32 cycTime = g_PFM_Cfg.CYC_TIME/2u; + CM_UINT32 cycCount = g_PFM_Cfg.CYC_TIME/2u + 1u; + CM_UINT8 loop_count = 0u; +#if QNX + void* pmask = NULL; + + /*- 本线程锁定在 A53 core 1 */ + pmask = (void*)0x02u; + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); + +#endif + + /*- @alias 等待主任务启动 */ + while (0u == CM_ATOMIC_LOAD(&s_RunFlag)) + { + /*- 休眠等待进入主周期并且以喂狗 */ + CM_Sleep(2u); + } + + /*- 备狗喂狗 */ + (void)PFM_CFC_WatchDog_Prepare(); + + /*- @alias 等待主看门狗启动 */ + while (0u == CM_ATOMIC_LOAD(&s_RunFlag_MainDog)) + { + /*- 休眠等待主狗以喂狗 */ + CM_Sleep(2u); + loop_count++; + if(cycCount < loop_count ) + { + /*- 如果轮询了周期时间/2次主狗还未启动 ,已经出现异常,宕机处理 */ + MSCP_LOG_MSG("main watchdog start timeout. \n"); +#ifdef QNX + (void)DFM_ledMonitor(2u); +#endif + CM_RE_ASSERT(0, CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + + } + else + { + /*- 无处理 */ + } + } + + /*- 循环等待软中断 */ + while (1) + { + + /*- 备狗喂狗 */ + (void)PFM_CFC_WatchDog_Prepare(); + /*- 主狗以喂狗,并且喂狗时间合法*/ + if(0x55u == CM_ATOMIC_LOAD(&s_RunFlag_MainDog)) + { + /*- 清除运行标志 */ + (void)CM_ATOMIC_STORE(&s_RunFlag_MainDog, 0x00u); + startTimer = CM_GetTick(); + } + /*- 喂狗后,超过合法时间未进行喂狗操作*/ + else if(leftTimer >= cycTime) + { + /*- 宕机并输出平台所处步骤 */ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCONTROFLOWCHECK_WATCHDOG, 2, \ + sizeof(CM_UINT64),leftTimer, + sizeof(CM_UINT32),cycTime); + MSCP_LOG_MSG("main watchdog timeout,s_RunFlag_MainDog = 0x%.2x,leftTimer = %lu,cycTime = %lu\n",s_RunFlag_MainDog,leftTimer,cycTime); +#ifdef QNX + (void)DFM_ledMonitor(2u); +#endif + CM_RE_ASSERT(0, CONTROL_FLOW_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + } + else + { + /*- 无处理 */ + } + /*- 计算喂狗至当前的时间 */ + CM_Sleep(WATCH_DOG_POLL_TIME); + nowTimer = CM_GetTick(); + + leftTimer = (nowTimer - startTimer) / 1000000u; + + } + return NULL; +} + +/** +* @brief 喂狗 +*/ +void PFM_CFC_WatchDog(void) +{ + /*- 设置运行标记 */ + (void)CM_ATOMIC_STORE(&s_RunFlag, 0x55u); /* parasoft-suppress GJB8114-R_1_7_2 "QNX宏不符合编码规范" */ + MSCP_LOG_MSG("-- dog eat food ---\n"); +} +/** +* @brief 主狗喂狗 +*/ +void PFM_CFC_WatchDog_Main(void) +{ + /*- 设置运行标记 */ + (void)CM_ATOMIC_STORE(&s_RunFlag_MainDog, 0x55u); /* parasoft-suppress GJB8114-R_1_7_2 "QNX宏不符合编码规范" */ +} + +/** +* @brief 备狗喂狗 +*/ +void PFM_CFC_WatchDog_Prepare(void) +{ + /*- 设置运行标记 */ + (void)CM_ATOMIC_STORE(&s_RunFlag_PrepareDog, 0x55u); /* parasoft-suppress GJB8114-R_1_7_2 "QNX宏不符合编码规范" */ +} + + diff --git a/TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.h b/TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.h new file mode 100644 index 0000000..35fee1a --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_ControlFlowCheck.h @@ -0,0 +1,63 @@ +/** +* @file PFM_ControlFlowCheck.h +* @brief Platform Function Module:控制流状态监督 +* @details +* 采用改进的CFCSS算法,静态签名为大质数,校验运算为大质数因式分解 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef PFM_CONTROLFLOWCHECH_H +#define PFM_CONTROLFLOWCHECH_H +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define PFM_CFC_PROC_NUM (49) /*设置参与控制流检查的总步骤数*/ + +#define WATCH_DOG_POLL_TIME (10u) /*看门狗轮询时间*/ + +extern CM_INT32 g_PFM_Check; + /* 控制流检查算法初始化 */ + void PFM_CFC_Init(void); + + /* 控制流检查 */ + /* step:1,2,3 …… PFM_CFC_PROC_NUM */ + void PFM_CFC_Check(CM_INT32 step); + + /* 获取当前的执行阶段 */ + CM_INT32 PFM_CFC_GetCurStep(void); + + /* 平台状态监督 */ + void PFM_CFC_Monitor(void); + + /** + * @brief 喂狗 + */ + void PFM_CFC_WatchDog(void); + + /** + * @brief 主看门狗状态监督/备狗 + */ + CM_THREAD_FUNC_T MSCP_WatchDog(void); + /** + * @brief 主狗喂狗 + */ + void PFM_CFC_WatchDog_Main(void); + /** + * @brief 备狗喂狗 + */ + void PFM_CFC_WatchDog_Prepare(void); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_FS.c b/TSCP/src/MSCP/PFM/PFM_FS.c new file mode 100644 index 0000000..923f566 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_FS.c @@ -0,0 +1,158 @@ +/** +* @file PFM_FS.c +* @brief Platform Function Module:FS文件相关功能 +* @details +* 读取FS文件配置信息 +* @author GT-BU +* @date 2021.03.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.03.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "CM_Convert.h" +#include "CM_Memory.h" +#include "PFM_FS.h" +#include "PFM_Cfg.h" +#include "PFM_Log.h" +#include "dfsDataRead.h" +#include "dquDataTypeDefine.h" + + +#define FS_IPPORT_LINE_SIZE (30u) + +/** IP地址表 */ +typedef struct +{ + CM_UINT16 DEV_ID; /**< 设备ID */ + CM_UINT32 HLHT_ID; /**< 互联互通ID */ + CM_UINT32 Blue_IP; /**< 蓝网IP */ + CM_UINT32 Red_IP; /**< 红网IP */ + CM_UINT16 SFP_BluePort; /**< SFP蓝网端口 */ + CM_UINT16 SFP_RedPort; /**< SFP红网端口 */ + CM_UINT16 RP_BluePort; /**< RP蓝网端口 */ + CM_UINT16 RP_RedPort; /**< RP红网端口 */ + CM_UINT16 RSSP_BluePort; /**< RSSP蓝网湍口 */ + CM_UINT16 RSSP_RedPort; /**< RSSP红网端口 */ + CM_UINT16 Device_Source_BluePort; /**< 设备源蓝网端口 */ + CM_UINT16 Device_Source_RedPort; /**< 设备源红网端口 */ +}STRU_SHEET_IPPORT_T; + +/** 设备IP表 */ +typedef struct +{ + CM_INT32 IpPort_Num; /**< IP地址表行数 */ + STRU_SHEET_IPPORT_T *pIpPort_List; /**< IP地址表 */ +}STRU_FS_IPTABLE_T; + +/** 设备IP地址表 */ +static STRU_FS_IPTABLE_T s_ip_table; + +/** +* @brief FS文件初始化 +* @param file_path FS文件路径 +*/ +void fs_init(IN CM_CHAR* file_path) +{ + /*- 变量初始化 */ + CM_UINT8* pData = NULL; + CM_UINT32 dataLen = 0u; + CM_UINT32 i = 0u; + CM_UINT8 rt = 0u; + /*- 读取IP地址表-设备IP表 */ + rt = dquGetConfigData(file_path, (CM_UINT32)DSU_DEVICE_IP_CONFIG_TYPE, (CM_UINT32)DSU_DATA_IP_IP_ID, &pData, &dataLen); + CM_ASSERT(1u == rt, FS_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + + /*- 计算总行数 */ + CM_ASSERT((dataLen % FS_IPPORT_LINE_SIZE) == 0u, FS_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + s_ip_table.IpPort_Num = (CM_INT32)CM_UNSIGNED_INT_EXP(dataLen/ FS_IPPORT_LINE_SIZE); + + /*- 内存初始化 */ + s_ip_table.pIpPort_List = CM_Malloc((CM_SIZE_T)s_ip_table.IpPort_Num * sizeof(STRU_SHEET_IPPORT_T)); + CM_ASSERT(NULL != s_ip_table.pIpPort_List, FS_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + + /*- 读取首行|是否遍历完成|读取下一行 */ + for (i = 0u; i < (CM_UINT32)s_ip_table.IpPort_Num; i++) + { + s_ip_table.pIpPort_List[i].DEV_ID = CM_ShortFromChar(&pData[i * FS_IPPORT_LINE_SIZE]); + s_ip_table.pIpPort_List[i].HLHT_ID = CM_LongFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 2]); + s_ip_table.pIpPort_List[i].Blue_IP = CM_LongFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 6]); + s_ip_table.pIpPort_List[i].Red_IP = CM_LongFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 10]); + s_ip_table.pIpPort_List[i].SFP_BluePort = CM_ShortFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 14]); + s_ip_table.pIpPort_List[i].SFP_RedPort = CM_ShortFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 16]); + s_ip_table.pIpPort_List[i].RP_BluePort = CM_ShortFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 18]); + s_ip_table.pIpPort_List[i].RP_RedPort = CM_ShortFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 20]); + s_ip_table.pIpPort_List[i].RSSP_BluePort = CM_ShortFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) +22]); + s_ip_table.pIpPort_List[i].RSSP_RedPort = CM_ShortFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 24]); + s_ip_table.pIpPort_List[i].Device_Source_BluePort = CM_ShortFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 26]); + s_ip_table.pIpPort_List[i].Device_Source_RedPort = CM_ShortFromChar(&pData[(i * FS_IPPORT_LINE_SIZE) + 28]); + } +} + +/** +* @brief 获取互联互通ID +* @param dev_id 设备ID +* @return 互联互通ID +*/ +CM_UINT32 fs_get_hlht_id(IN CM_UINT16 dev_id) +{ + /*- 变量初始化 */ + CM_UINT32 hlht_id = 0u; + CM_INT32 i = 0; + /*- 从IP地址表头开始遍历| 是否遍历结束| 下一项 */ + for (i = 0; i < s_ip_table.IpPort_Num; i++) + { + /*- 是否找到了目标设备ID */ + if (s_ip_table.pIpPort_List[i].DEV_ID == dev_id) + { + /*- 找到对应的互联互通ID */ + hlht_id = s_ip_table.pIpPort_List[i].HLHT_ID; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + /*- 返回互联互通ID */ + return hlht_id; +} + +/** +* @brief 获取设备ID +* @param hlht_id 互联互通ID +* @return 设备ID +*/ +CM_UINT16 fs_get_dev_id(IN CM_UINT32 hlht_id) +{ + /*- 变量初始化 */ + CM_UINT16 dev_id = 0u; + CM_INT32 i = 0; + /*- 从IP地址表头开始遍历 | 是否遍历结束 | 下一行 */ + for (i = 0; i < s_ip_table.IpPort_Num; i++) + { + /*- 是否找到了目标互联互通ID */ + if (s_ip_table.pIpPort_List[i].HLHT_ID == hlht_id) + { + /*- 找到对应的设备ID */ + dev_id = s_ip_table.pIpPort_List[i].DEV_ID; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + /*- 返回设备ID */ + return dev_id; +} + + + + + diff --git a/TSCP/src/MSCP/PFM/PFM_FS.h b/TSCP/src/MSCP/PFM/PFM_FS.h new file mode 100644 index 0000000..cac2d4a --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_FS.h @@ -0,0 +1,32 @@ +/** +* @file PFM_FS.h +* @brief Platform Function Module:FS文件相关功能 +* @details +* 读取FS文件配置信息 +* @author GT-BU +* @date 2021.03.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.03.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef PFM_FS_H +#define PFM_FS_H +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + void fs_init(IN CM_CHAR* file_path); + CM_UINT32 fs_get_hlht_id(IN CM_UINT16 dev_id); + CM_UINT16 fs_get_dev_id(IN CM_UINT32 hlht_id); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_InputOutput.c b/TSCP/src/MSCP/PFM/PFM_InputOutput.c new file mode 100644 index 0000000..a6140f7 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_InputOutput.c @@ -0,0 +1,1816 @@ +/** +* @file PFM_InputOutput.c +* @brief Platform Function Module: 输入输出管理 +* @details +* 平台输入微周期和输出微周期的2oo2、2x2功能实现 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_InputOutput.h" +#include "CM_Convert.h" +#include "CM_CRC32.h" +#include "CM_Memory.h" +#include "CM_Time.h" +#include "CFM_Raw.h" +#include "SFM_2oo2.h" +#include "SFM_2x2.h" +#include "SFM_Prtcl.h" +#include "PFM_Cfg.h" +#include "PFM_Log.h" +#include "PFM_ControlFlowCheck.h" +#include "CM_MQ.h" +#include "CFM_Net.h" +#include "MSCP_APP_API.h" +#include "CM_Com.h" +#include "DFM_Time.h" +#include "PFM_RemoteUpdate.h" +/*平台通信容量*/ +#define PFM_INNETRAW_BUFF_SIZE (1024u*1024u*10u) /* 内网透传通信透传UDP缓冲区大小 1M*5,应用许用量为2M */ +#define PFM_OUTNETRAW_BUFF_SIZE (1024u*1024u*10u) /* 外网安全通信通道UDP缓冲区大小 1M*10,应用许用量为500k */ + +/* +* 通信通道涉及的内容: +* CFM建立通信层通道,通信报文的接收、发送 +* CFM SFM PFM +* 内网安全通信 | UDP通信端口,接收、发送 | 内网安全协议解析、封装 | 2oo2交换,2x2交换 | +* 内网透传通信 | UDP通信端口,接收、发送 | / | 2oo2交换,2x2交换 | +* 外网安全通信 | UDP通信端口,接收、发送 | 外网安全协议解析、封装 | 2oo2交换,2x2交换 | +* 外网透传通信 | UDP通信端口,接收、发送 | / | 2oo2交换,2x2交换 | +*/ + +static CM_INT32 s_2x2oo2_app = 1; /* app缓冲区索引 */ + +static const CM_INT32 s_2x2oo2_InnetSafe = 1; /* 内网安全通信的通道索引 */ +static const CM_INT32 s_2x2oo2_OutnetSafe = 2; /* 外网安全通信的通道索引 */ +static const CM_INT32 s_2x2oo2_OutnetRaw = 3; /* 外网透传通道的通道索引 */ +static const CM_INT32 s_2x2oo2_RemoteUpdate = 4; /* 远程部署通道的通道索引 */ +static const CM_INT32 s_2x2oo2_OutnetHeart = 5; /* 外网心跳通道的通道索引 */ +static CM_INT32 s_2x2oo2_InnetRaw_num = 0; /* 内网透传通道的数量 */ +static CM_INT32 s_2x2oo2_InnetRaw_Extend_num = 0;/* 内网透传通道的数量 */ +static CM_INT32 s_2x2oo2_InnetRaw[INNET_RAW_DOUBLE_PASS_NUM];/* 内网透传通道的通道索引们 */ +/*2x分帧接收临时缓冲区*/ +CM_UINT8 g_2x2oo2_Frame_TempBuf[SFM_OUTNETSAFE_BUFF_SIZE] = {0u}; +/* 透传收发通道的简化宏 */ +#define APP_RAW_TX(ch) (g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_InnetRaw[(ch)]]) +#define APP_RAW_RX(ch) (g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_InnetRaw[(ch)]]) +#define PFM_RAW_TX(ch) (g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_InnetRaw[(ch)]]) +#define PFM_RAW_RX(ch) (g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetRaw[(ch)]]) + +static CM_UINT32 s_InnetRaw_Mine_AppReadIndex[INNET_RAW_DOUBLE_PASS_NUM]; /**< 应用接收内网透传消息的指针 */ +static CM_UINT32 s_InnetRaw_Peer_AppReadIndex[INNET_RAW_DOUBLE_PASS_NUM]; /**< 应用接收内网透传消息的指针 */ +static CM_UINT32 s_OutnetRaw_Mine_AppReadIndex; /**< 应用接收外网透传消息的指针 */ +static CM_UINT32 s_OutnetRaw_Peer_AppReadIndex; /**< 应用接收外网透传消息的指针 */ +static CM_UINT32 s_OutnetHeart_Mine_AppReadIndex; /**< 应用接收外网心跳消息的指针 */ +static CM_UINT32 s_OutnetHeart_Peer_AppReadIndex; /**< 应用接收外网心跳消息的指针 */ + +/*记录红蓝网通信设备临时buf*/ +static CM_UINT16 s_rciRedTempBuf[16u * 18u] = {0u}; +static CM_UINT16 s_rciBlueTempBuf[16u * 18u] = {0u}; +static CM_UINT16 s_rciRedTempBufOffset = 0u; +static CM_UINT16 s_rciBlueTempBufOffset = 0u; + +extern CM_INT32 g_PFM_Check; +/* 输入阶段的2oo2交换*/ +static void s_input_2oo2sync(void); +/* 将收到的外网输入报文填写到安全协议层 */ +static void s_RxOutnetToSFM(IN const CM_UINT8 buf[], IN CM_UINT32 len); +/* 2取2生成输出校验报文 */ +static CM_INT32 s_2oo2OutputCheckFrame_Pack(OUT CM_UINT8 buf[], IN CM_UINT32 BufSize); +/* 2x2生成输出校验报文 */ +static CM_INT32 s_2x2OutputCheckFrame_Pack(OUT CM_UINT8 *buf, IN CM_UINT32 BufSize); +/* 输入阶段的2x2同步 */ +static void s_input_2x2sync(void); +/** +* @brief 输入阶段的2x2同步 +*/ +static void s_input_2x2sync(void) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; + ENUM_2x2_STATE_T state_2x2 = SFM_2x2_GetLocal2x2State(); /* 本系热备状态 */ + /*- 本机是否为主系 */ + if (ENUM_2x2_MASTER == state_2x2) + { + /*- 从第一个2x2oo2通信队列开始|是否遍历完成|下一个队列 */ + for (i = 1; i <= g_2x2oo2_data_num; i++) + { + /*- 本队列是否需要2x2同步 */ + if (CM_TRUE == (CM_BOOL)g_2x2oo2_rx[g_2x2oo2_base][i].b_2x2_Enable) + { + /*- 将整个通信队列发送到对系 */ + SFM_2x2_Send(g_2x2oo2_rx[g_2x2oo2_base][i].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][i].mine_len, (ENUM_2x2_MSG_T)(i)); + SFM_2x2_Send(g_2x2oo2_rx[g_2x2oo2_base][i].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][i].peer_len, (ENUM_2x2_MSG_T)(g_2x2oo2_data_num+i)); + } + else + { + MSCP_LOG_MSG("(CM_BOOL)g_2x2oo2_rx[g_2x2oo2_base][%d].b_2x2_Enable = %d\n", i,(CM_BOOL)g_2x2oo2_rx[g_2x2oo2_base][i].b_2x2_Enable); + } + } + } + else + { + /*- 无处理 */ + } +} + +/** +* @brief 输入阶段的2oo2交换 +*/ +static void s_input_2oo2sync(void) +{ + /*- 变量初始化 */ + CM_UINT64 templog[20]; + CM_INT32 i = 0; /* 循环变量 */ + CM_UINT8 ret = 0; + CM_UINT64 syn2oo2time = 0u; + /*- 从第一个2x2oo2通信队列开始|是否遍历完成|下一个队列 */ + for (i = 1; i <= g_2x2oo2_data_num; i++) + { + /*- 本队列是否需要2oo2同步 */ + if (CM_TRUE == (CM_BOOL)g_2x2oo2_rx[g_2x2oo2_base][i].b_2oo2_Enable) + { + /*- 同步本通信队列 */ + g_2x2oo2_rx[g_2x2oo2_base][i].peer_len = (CM_UINT32)SFM_2oo2_Exchange_Currency( + g_2x2oo2_rx[g_2x2oo2_base][i].p_mine_buf, (CM_INT32)g_2x2oo2_rx[g_2x2oo2_base][i].mine_len, + g_2x2oo2_rx[g_2x2oo2_base][i].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][i].buf_size, ENUM_2oo2_INPUT_EX); + } + else + { + /*- 无处理 */ + } + } + + templog[0] = CM_GetTick(); + /*- @alias 协议过滤2取重复数据 */ + if(1 == g_PFM_Cfg.CPU_ID) + { + ret = SFM_OutProtclTwoRepeat(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].mine_len, + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_peer_buf,&g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].peer_len); + } + else + { + ret = SFM_OutProtclTwoRepeat(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_peer_buf,g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].peer_len, + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_mine_buf, &g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].mine_len); + } + CM_ASSERT(ret == 1, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_1); + templog[1] = CM_GetTick(); + + syn2oo2time = (templog[1] - templog[0])/1000u; + MSCP_LOG_MSG("s_input_2oo2sync 2oo2syntime = %lld\n",syn2oo2time); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_PFMINPUTOUTPUT_INPUT2oo2SYNC, 8U, &syn2oo2time); +} + +/** +* @brief 微周期控制初始化 +*/ +void PFM_Init(void) +{ + /*- 变量初始化 */ + CM_INT32 base = 0; + CM_INT32 i = 0; + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + /*- 初始化双缓冲索引 */ + g_2x2oo2_base = 0; + s_2x2oo2_app = 1; + + /*- @alias 初始化内网安全通信和外网安全通信配置 */ + for (base = 0; base < 2; base++)/*- 遍历双缓冲区 */ + { + /*- 初始化内网安全接收配置 */ + g_2x2oo2_rx[base][s_2x2oo2_InnetSafe].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_InnetSafe].b_2x2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_InnetSafe].buf_size = (CM_UINT32)SFM_INNETSAFE_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_rx[base][s_2x2oo2_InnetSafe].app_mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + /*- 初始化外网安全接收配置 */ + g_2x2oo2_rx[base][s_2x2oo2_OutnetSafe].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_OutnetSafe].b_2x2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_OutnetSafe].buf_size = (CM_UINT32)SFM_OUTNETSAFE_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_rx[base][s_2x2oo2_OutnetSafe].app_mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + /*- 初始化外网透传接收配置 */ + g_2x2oo2_rx[base][s_2x2oo2_OutnetRaw].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_OutnetRaw].b_2x2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_OutnetRaw].buf_size = (CM_UINT32)PFM_OUTNETRAW_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_rx[base][s_2x2oo2_OutnetRaw].app_mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + /*- 初始化远程部署内网安全接收配置 */ + g_2x2oo2_rx[base][s_2x2oo2_RemoteUpdate].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_RemoteUpdate].b_2x2_Enable = (CM_UINT32)CM_FALSE; + g_2x2oo2_rx[base][s_2x2oo2_RemoteUpdate].buf_size = (CM_UINT32)SFM_INNETSAFE_RM_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_rx[base][s_2x2oo2_RemoteUpdate].app_mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_18); + /*- 初始化外网心跳信息接收配置 */ + g_2x2oo2_rx[base][s_2x2oo2_OutnetHeart].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_OutnetHeart].b_2x2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_OutnetHeart].buf_size = (CM_UINT32)SFM_INNETSAFE_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_rx[base][s_2x2oo2_OutnetHeart].app_mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_19); + + + /*- 初始化内网安全发送配置 */ + g_2x2oo2_tx[base][s_2x2oo2_InnetSafe].buf_size = (CM_UINT32)SFM_INNETSAFE_BUFF_SIZE; + g_2x2oo2_tx[base][s_2x2oo2_InnetSafe].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_tx[base][s_2x2oo2_InnetSafe].b_2x2_Enable = (CM_UINT32)CM_TRUE; + rt = CM_Mutex_Init(&g_2x2oo2_tx[base][s_2x2oo2_InnetSafe].mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_5); + /*- 初始化外网安全发送配置 */ + g_2x2oo2_tx[base][s_2x2oo2_OutnetSafe].buf_size = (CM_UINT32)SFM_OUTNETSAFE_BUFF_SIZE; + g_2x2oo2_tx[base][s_2x2oo2_OutnetSafe].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_tx[base][s_2x2oo2_OutnetSafe].b_2x2_Enable = (CM_UINT32)CM_TRUE; + rt = CM_Mutex_Init(&g_2x2oo2_tx[base][s_2x2oo2_OutnetSafe].mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_6); + /*- 初始化外网透传发送配置 */ + g_2x2oo2_tx[base][s_2x2oo2_OutnetRaw].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_tx[base][s_2x2oo2_OutnetRaw].b_2x2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_tx[base][s_2x2oo2_OutnetRaw].buf_size = (CM_UINT32)PFM_OUTNETRAW_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_tx[base][s_2x2oo2_OutnetRaw].mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_7); + /*- 初始化远程部署内网安全发送配置 */ + g_2x2oo2_tx[base][s_2x2oo2_RemoteUpdate].buf_size = (CM_UINT32)SFM_INNETSAFE_RM_BUFF_SIZE; + g_2x2oo2_tx[base][s_2x2oo2_RemoteUpdate].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_tx[base][s_2x2oo2_RemoteUpdate].b_2x2_Enable = (CM_UINT32)CM_FALSE; + rt = CM_Mutex_Init(&g_2x2oo2_tx[base][s_2x2oo2_RemoteUpdate].mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_17); + /*- 初始化外网心跳信息发送配置 */ + g_2x2oo2_tx[base][s_2x2oo2_OutnetHeart].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_tx[base][s_2x2oo2_OutnetHeart].b_2x2_Enable = (CM_UINT32)CM_FALSE; + g_2x2oo2_tx[base][s_2x2oo2_OutnetHeart].buf_size = (CM_UINT32)SFM_INNETSAFE_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_tx[base][s_2x2oo2_OutnetHeart].mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_20); + } + + /*- @alias 初始化内网透传通道配置 */ + s_2x2oo2_InnetRaw_num = g_PFM_Cfg.Local_Cfg.Port_Innet_Raw_Num; + s_2x2oo2_InnetRaw_Extend_num = g_PFM_Cfg.Local_Cfg.Port_Innet_Raw_Extend_Num; + for (base = 0; base < 2; base++)/* 遍历双缓冲区 */ + { + for (i = 1; i <= (s_2x2oo2_InnetRaw_num + s_2x2oo2_InnetRaw_Extend_num); i++)/* 遍历所有透传通道 */ + { + /* 初始化透传通道索引 */ + s_2x2oo2_InnetRaw[i] = s_2x2oo2_OutnetHeart + i; + /* 初始化接收通道配置 -只有全部数据需要二取,时间戳不需要2取*/ + if((CM_UINT16)0x55u == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].INNET_2oo2_RAW) + { + if((CM_UINT16)0xAAu == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].TIME_STAMP_ENABLE) + { + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].helpinfo_buf_size = (CM_UINT32)0u; + } + else + { + /*需要二取时间戳,不需要全部数据二取*/ + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].b_2oo2_Enable = (CM_UINT32)CM_FALSE; + /*辅助信息-缓冲区长度分配*/ + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].helpinfo_buf_size = (CM_UINT32)CFM_INNET_RAW_MSG_NUM_MAX * 12u; + } + g_2x2oo2_tx[base][s_2x2oo2_InnetRaw[(i)]].b_2oo2_Enable = (CM_UINT32)CM_TRUE; + } + else + { + /*该通道透传数据均不需要二取*/ + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].b_2oo2_Enable = (CM_UINT32)CM_FALSE; + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].helpinfo_buf_size = (CM_UINT32)0u; + g_2x2oo2_tx[base][s_2x2oo2_InnetRaw[(i)]].b_2oo2_Enable = (CM_UINT32)CM_FALSE; + } + + if((CM_UINT16)0x55u == g_PFM_Cfg.Local_Cfg.Innet_Raw_Parameter[i].INNET_2x2_RAW) + { + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].b_2x2_Enable = (CM_UINT32)CM_TRUE; + g_2x2oo2_tx[base][s_2x2oo2_InnetRaw[(i)]].b_2x2_Enable = (CM_UINT32)CM_TRUE; + } + else + { + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].b_2x2_Enable = (CM_UINT32)CM_FALSE; + g_2x2oo2_tx[base][s_2x2oo2_InnetRaw[(i)]].b_2x2_Enable = (CM_UINT32)CM_FALSE; + } + + g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].buf_size = (CM_UINT32)PFM_INNETRAW_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_rx[base][s_2x2oo2_InnetRaw[(i)]].app_mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_8); + /* 初始化发送通道配置 */ + g_2x2oo2_tx[base][s_2x2oo2_InnetRaw[(i)]].buf_size = (CM_UINT32)PFM_INNETRAW_BUFF_SIZE; + rt = CM_Mutex_Init(&g_2x2oo2_tx[base][s_2x2oo2_InnetRaw[(i)]].mutex); + CM_ASSERT(ENUM_CM_TRUE == rt, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_9); + } + } + /*- 确定通道总数 = 固定通道数 + 内网透传通道数 + 内网透传扩展通道数 */ + g_2x2oo2_data_num = s_2x2oo2_OutnetHeart + s_2x2oo2_InnetRaw_num + s_2x2oo2_InnetRaw_Extend_num; + + /*- @alias 缓冲区内存分配 */ + for (base = 0; base < 2; base++)/* 遍历双缓冲区 */ + { + for (i = 1; i <= g_2x2oo2_data_num; i++)/*遍历所有通道*/ + { + /* 为接收通道分配内存 */ + if(0u < g_2x2oo2_rx[base][i].buf_size) + { + g_2x2oo2_rx[base][i].p_mine_buf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)g_2x2oo2_rx[base][i].buf_size); + CM_ASSERT(NULL != g_2x2oo2_rx[base][i].p_mine_buf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_10); + } + else + { + /*- 无处理 */ + } + if (CM_TRUE == (CM_BOOL)g_2x2oo2_rx[base][i].b_2oo2_Enable) + { + g_2x2oo2_rx[base][i].p_peer_buf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)g_2x2oo2_rx[base][i].buf_size); + CM_ASSERT(NULL != g_2x2oo2_rx[base][i].p_peer_buf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_11); + } + else + { + /*- 无处理 */ + } + if (CM_TRUE == (CM_BOOL)g_2x2oo2_rx[base][i].b_2x2_Enable) + { + g_2x2RcvMaxNum[base] = g_2x2oo2_data_num*base + i;/*记录2x双缓冲区最大序号*/ + g_2x2oo2_rx[base][i].p_rmt_mine_buf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)g_2x2oo2_rx[base][i].buf_size); + CM_ASSERT(NULL != g_2x2oo2_rx[base][i].p_rmt_mine_buf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_12); + } + else + { + /*- 无处理 */ + } + if ((CM_TRUE == (CM_BOOL)g_2x2oo2_rx[base][i].b_2oo2_Enable) && (CM_TRUE == (CM_BOOL)g_2x2oo2_rx[base][i].b_2x2_Enable)) + { + g_2x2oo2_rx[base][i].p_rmt_peer_buf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)g_2x2oo2_rx[base][i].buf_size); + CM_ASSERT(NULL != g_2x2oo2_rx[base][i].p_rmt_peer_buf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_13); + } + else + { + /*- 无处理 */ + } + /*初始化辅助信息通道缓冲区*/ + if (0u < g_2x2oo2_rx[base][i].helpinfo_buf_size) + { + g_2x2oo2_rx[base][i].p_mine_helpinfo_buf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)g_2x2oo2_rx[base][i].helpinfo_buf_size); + CM_ASSERT(NULL != g_2x2oo2_rx[base][i].p_mine_helpinfo_buf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_14); + g_2x2oo2_rx[base][i].p_peer_helpinfo_buf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)g_2x2oo2_rx[base][i].helpinfo_buf_size); + CM_ASSERT(NULL != g_2x2oo2_rx[base][i].p_peer_helpinfo_buf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_15); + } + + else + { + /*- 无处理 */ + } + /* 为发送通道分配内存 */ + if(0u < g_2x2oo2_tx[base][i].buf_size) + { + g_2x2oo2_tx[base][i].p_buf = (CM_UINT8*)CM_Malloc((CM_SIZE_T)g_2x2oo2_tx[base][i].buf_size); + CM_ASSERT(NULL != g_2x2oo2_tx[base][i].p_buf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_16); + } + else + { + /*- 无处理 */ + } + } + } +} + +/** +* @brief 双缓冲切换 +*/ +void PFM_BufSwich(void) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; + + /*- 内外网安全协议对应用任务的缓冲区切换 */ + PFM_CFC_Check(1); + SFM_PrtclBufSwitch(); + + /*内网安全通道-缓冲区长度清零*/ + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_InnetSafe].mine_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_InnetSafe].peer_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_InnetSafe].rmt_mine_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_InnetSafe].rmt_peer_len = 0u; + /*外网安全通道-缓冲区长度清零*/ + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetSafe].mine_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetSafe].peer_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetSafe].rmt_mine_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetSafe].rmt_peer_len = 0u; + + /*外网透传通道-缓冲区长度清零*/ + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].peer_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].mine_len = 0u; + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].app_index_log = 0u;/*清空本周期平台及将记录的标志*/ + /*远程部署通道通道-缓冲区长度清零*/ + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_RemoteUpdate].mine_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_RemoteUpdate].peer_len = 0u; + + /*心跳通道-缓冲区长度清零*/ + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetHeart].mine_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetHeart].peer_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetHeart].rmt_mine_len = 0u; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetHeart].rmt_peer_len = 0u; + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetHeart].app_index_log = 0u; + /*- @alias 内网透传通道长度归0 */ + for (i = 1; i <= (s_2x2oo2_InnetRaw_num + s_2x2oo2_InnetRaw_Extend_num); i++) + { + APP_RAW_RX(i).mine_len = 0u; + APP_RAW_RX(i).mine_helpinfo_len = 0u; + APP_RAW_RX(i).peer_len = 0u; + APP_RAW_RX(i).peer_helpinfo_len = 0u; + PFM_RAW_RX(i).app_index_log = 0u; + + /*- @alias 内网透传通道的读索引归0 */ + s_InnetRaw_Mine_AppReadIndex[i] = 0u; + s_InnetRaw_Peer_AppReadIndex[i] = 0u; + } + + /*- 2x2oo2通信队列的缓冲区切换 */ + g_2x2oo2_base = 1 - g_2x2oo2_base; + s_2x2oo2_app = 1 - s_2x2oo2_app; + CM_RE_ASSERT((0 == g_2x2oo2_base) || (1 == g_2x2oo2_base), IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT((0 == s_2x2oo2_app) || (1 == s_2x2oo2_app), IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT(g_2x2oo2_base != s_2x2oo2_app, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); + + PFM_CFC_Check(2); + /*- @alias 外网透传通道的读索引归0 */ + s_OutnetRaw_Mine_AppReadIndex = 0u; + s_OutnetRaw_Peer_AppReadIndex = 0u; + + s_OutnetHeart_Mine_AppReadIndex = 0; + s_OutnetHeart_Peer_AppReadIndex = 0; +} + +/** +* @brief 输入微周期处理 +* @details +* 输入微周期的2oo2、2x2处理: +* 平台数据接收; +* 2x2发送; +* 本地输入数据2oo2交换和比较; +* 输入阶段2x2处理; +* 交付协议适配层处理。 +*/ +void PFM_InputProc(void) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; + ENUM_2x2_STATE_T p_state_2x2 = ENUM_2x2_SHUTDOWN; /* 对系热备状态 */ + + /************************平台数据接收*************************/ + /*- 外网安全数据接收 */ + PFM_CFC_Check(26); + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].mine_len = (CM_UINT32)SFM_RxOutnetSafe(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_mine_buf, (CM_UINT32)g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].buf_size); + MSCP_LOG_MSG("g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].mine_len = %d\n",g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].mine_len); + /*判断外网透传使能开关*/ + if((CM_UINT32)0x55u == g_PFM_Cfg.M_OutnetRaw_Enable) + { + /*- 外网透传数据接收 */ + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].mine_len = CFM_RxOutnetRaw(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_mine_buf, (CM_UINT32)g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].buf_size); + } + else + { + /*外网透传未使能*/ + } + /*- 外网心跳数据接收 */ + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetHeart].mine_len = CFM_RxOutnetHeart(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetHeart].p_mine_buf, (CM_UINT32)g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetHeart].buf_size); + /*- 内网安全数据接收 */ + PFM_CFC_Check(27); + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].mine_len = (CM_UINT32)SFM_RxInnetSafe(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_mine_buf, (CM_UINT32)g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].buf_size); + PFM_CFC_Check(28); + g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].mine_len = (CM_UINT32)SFM_RxInnetSafeRm(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].p_mine_buf, (CM_UINT32)g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].buf_size); + PFM_CFC_Check(29); + /*- @alias 内网透传数据接收 */ + for (i = 1; i <= s_2x2oo2_InnetRaw_num + s_2x2oo2_InnetRaw_Extend_num; i++) + { + PFM_RAW_RX(i).mine_len = CFM_RxInnetRaw_COM(i, PFM_RAW_RX(i).p_mine_buf, (CM_UINT32)PFM_RAW_RX(i).buf_size,/*透传数据*/ + PFM_RAW_RX(i).p_mine_helpinfo_buf,&PFM_RAW_RX(i).mine_helpinfo_len, /*透传数据本机辅助信息*/ + PFM_RAW_RX(i).p_peer_helpinfo_buf,&PFM_RAW_RX(i).peer_helpinfo_len, /*透传数据临机辅助信息*/ + (CM_UINT32)PFM_RAW_RX(i).helpinfo_buf_size);/*透传数据缓冲区长度*/ + MSCP_LOG_MSG("[%d]:APP_LastReadIndex:%d,T = %d us\n", i, PFM_RAW_RX(i).app_index_log,NOW_USED_TIME); + } + + PFM_CFC_Check(30); + /*- 外网心跳数据发送前组包*/ + g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetHeart].buf_len = PFM_OutnetHeart_Send(); + /*- 发送外网心跳数据*/ + (void)CFM_TxOutnetHeart(g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetHeart].p_buf, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetHeart].buf_len); + /*- 清空心跳数据得长度(主备都清空) */ + g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetHeart].buf_len = 0; + PFM_CFC_Check(31); /*预留*/ + /*************************本地输入数据2oo2交换和比较*************************/ + MSCP_LOG_MSG("timecurr 1 Input Recv = %lld us\n", NOW_USED_TIME); + /*- 是否开启2oo2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 执行输入阶段的2oo2交换 */ + s_input_2oo2sync(); + } + else + { + /*- 无处理 */ + } + + /*************************2x2发送*************************/ + MSCP_LOG_MSG("timecurr 2 Input 2oo2 = %lld us\n", NOW_USED_TIME); + PFM_CFC_Check(32); + /*- 是否开启2x2功能*/ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + /*- 执行输入阶段的2x2同步 */ + (void)s_input_2x2sync(); + } + else + { + /*- 无处理 */ + } + MSCP_LOG_MSG("timecurr 3 Input 2x2Send = %lld us\n", NOW_USED_TIME); + + /*************************输入阶段2x2处理*************************/ + /*接收对系输入数据,系内交换和比较,更新热备状态,发送状态信息*/ + /*- 是否开启2x2功能 */ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + /*- 输入阶段2x2处理 */ + SFM_2x2_InputProc(); + } + else + { + /*- 更新控制流状态 */ + PFM_CFC_Check(33); + PFM_CFC_Check(34); + PFM_CFC_Check(35); + PFM_CFC_Check(36); + PFM_CFC_Check(37); + PFM_CFC_Check(38); + PFM_CFC_Check(39); + } + MSCP_LOG_MSG("timecurr 4 Input 2x2Data = %lld us\n", NOW_USED_TIME); + /*************************交付协议适配层处理*************************/ + /*- 获取对系热备状态 */ + p_state_2x2 = SFM_2x2_GetPartner2x2State(); + MSCP_LOG_MSG("SFM_Write bef T = %d us\n",NOW_USED_TIME); + /*- @alias 将周期输入数据交付给协议适配层处理 */ + if (MSCP_CPU_1 == g_PFM_Cfg.CPU_ID) + { + SFM_WriteInnetSafeRmInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].mine_len, ENUM_INNET_PURPLE); + SFM_WriteInnetSafeRmInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].peer_len, ENUM_INNET_GREEN); + + + if (ENUM_2x2_MASTER == p_state_2x2) + { + /* 对系为主系,只使用主系输入 */ + PFM_CFC_Check(40); + SFM_WriteInnetSafeInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_rmt_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].rmt_mine_len, ENUM_INNET_GREEN); + + PFM_CFC_Check(41); + SFM_WriteInnetSafeInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_rmt_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].rmt_peer_len, ENUM_INNET_PURPLE); + + PFM_CFC_Check(42); + s_RxOutnetToSFM(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_rmt_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].rmt_mine_len); + PFM_CFC_Check(43); + s_RxOutnetToSFM(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_rmt_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].rmt_peer_len); + (void)CM_Memcpy(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].buf_size, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_rmt_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].rmt_mine_len); + (void)CM_Memcpy(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].buf_size, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_rmt_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].rmt_peer_len); + } + else + { + /* 对系不是主,使用自己的输入 */ + PFM_CFC_Check(40); + SFM_WriteInnetSafeInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].mine_len, ENUM_INNET_GREEN); + + PFM_CFC_Check(41); + SFM_WriteInnetSafeInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].peer_len, ENUM_INNET_PURPLE); + + PFM_CFC_Check(42); + s_RxOutnetToSFM(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].mine_len); + PFM_CFC_Check(43); + s_RxOutnetToSFM(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].peer_len); + } + } + else + { + SFM_WriteInnetSafeRmInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].peer_len, ENUM_INNET_GREEN); + SFM_WriteInnetSafeRmInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].mine_len, ENUM_INNET_PURPLE); + + + if (ENUM_2x2_MASTER == p_state_2x2) + { + /* 对系为主系,只使用主系输入 */ + PFM_CFC_Check(40); + SFM_WriteInnetSafeInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_rmt_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].rmt_peer_len, ENUM_INNET_GREEN); + PFM_CFC_Check(41); + SFM_WriteInnetSafeInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_rmt_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].rmt_mine_len, ENUM_INNET_PURPLE); + PFM_CFC_Check(42); + s_RxOutnetToSFM(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_rmt_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].rmt_peer_len); + PFM_CFC_Check(43); + s_RxOutnetToSFM(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_rmt_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].rmt_mine_len); + (void)CM_Memcpy(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].buf_size, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_rmt_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].rmt_mine_len); + (void)CM_Memcpy(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].buf_size, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_rmt_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].rmt_peer_len); + } + else + { + /* 对系不是主,使用自己的输入 */ + PFM_CFC_Check(40); + SFM_WriteInnetSafeInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].peer_len, ENUM_INNET_GREEN); + PFM_CFC_Check(41); + SFM_WriteInnetSafeInput(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_InnetSafe].mine_len, ENUM_INNET_PURPLE); + PFM_CFC_Check(42); + s_RxOutnetToSFM(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_peer_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].peer_len); + PFM_CFC_Check(43); + s_RxOutnetToSFM(g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_mine_buf, g_2x2oo2_rx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].mine_len); + } + } + + MSCP_LOG_MSG("timecurr 5 Input SetPro = %lld us\n", NOW_USED_TIME); +} + +/** +* @brief 输出微周期处理 +* @details +* 输出微周期的2oo2、2x2处理: +* 从协议适配层获取输出数据; +* 生成输出校验帧; +* 2oo2输出比较; +* 输出阶段2x2处理; +* 平台数据发送。 +*/ +void PFM_OutputProc(void) +{ + /*- 变量初始化 */ + CM_INT32 check_2oo2_Len = 0; /* 输出校验帧长度 */ + CM_UINT8 check_2oo2_Buf[500] = { 0u }; /* 输出校验帧数组 */ + CM_INT32 check_2x2_Len = 0; /* 输出校验帧长度 */ + CM_UINT8 check_2x2_Buf[500] = { 0u }; /* 输出校验帧数组 */ + CM_INT32 i = 0; /* 循环变量 */ + CM_UINT8 buf_peer[500] = { 0u }; /* 邻机接收缓冲区 */ + CM_INT32 ret = 0; /* 临时变量 */ + ENUM_2x2_STATE_T state_2x2 = ENUM_2x2_SHUTDOWN; /* 本系热备状态 */ + + + /*########################从协议适配层获取输出数据########################*/ + /*- 从协议适配层获取输出数据 */ + PFM_CFC_Check(5); + g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_InnetSafe].buf_len = (CM_INT32)SFM_ReadInnetCodedOutput(g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_buf, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_InnetSafe].buf_size); + g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].buf_len = (CM_INT32)SFM_ReadInnetRmCodedOutput(g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].p_buf, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].buf_size); + PFM_CFC_Check(6); + g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].buf_len = (CM_INT32)SFM_ReadOutnetCodedOutput(g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_buf, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].buf_size); + /*########################生成输出校验帧########################*/ + PFM_CFC_Check(7); + /*- 是否开启了2oo2功能或2x2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 生成输出校验帧 */ + check_2oo2_Len = s_2oo2OutputCheckFrame_Pack(check_2oo2_Buf, (CM_UINT32)sizeof(check_2oo2_Buf)); + } + else + { + /*- 无处理 */ + } + PFM_CFC_Check(8); + if(0x55u == g_PFM_Cfg.M_2x2_Enable) + { + /*- 生成输出校验帧 */ + check_2x2_Len = s_2x2OutputCheckFrame_Pack(check_2x2_Buf, (CM_UINT32)sizeof(check_2x2_Buf)); + } + else + { + /*- 无处理 */ + } + MSCP_LOG_MSG("timecurr 14 OutputCheckFrame_Pack = %lld us\n", NOW_USED_TIME); + /*########################2oo2输出比较########################*/ + PFM_CFC_Check(9); + /*- 是否开启了2oo2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 2oo2交换输出校验帧 */ + ret = SFM_2oo2_Exchange_Currency(check_2oo2_Buf, check_2oo2_Len, buf_peer, (CM_UINT32)check_2oo2_Len, ENUM_2oo2_OUTPUT_CHECK); + + /*- 检查2oo2双机的输出校验帧是否一致 */ + CM_RE_ASSERT(check_2oo2_Len == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + ret = CM_Memcmp(check_2oo2_Buf, buf_peer, (CM_SIZE_T)check_2oo2_Len); + if(0 != ret) + { + MSCP_LOG_DATALEN(check_2oo2_Buf,check_2oo2_Len,"Ouput check_2oo2_Buf"); + MSCP_LOG_DATALEN(buf_peer,check_2oo2_Len,"Ouput buf_peer"); + CM_RE_ASSERT(0, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + } + } + else + { + /*- 无处理 */ + } + + MSCP_LOG_MSG("timecurr 15 Output2oo2 = %lld us\n", NOW_USED_TIME); + + /*########################输出阶段2x2处理########################*/ + /*发送/接收输出校验,接收对系状态,系内交换,输出校验,更新热备状态,生成和发送跟随数据*/ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + /*- 输出阶段2x2处理 */ + SFM_2x2_OutputProc(check_2x2_Buf, check_2x2_Len); + } + else + { + /*- 更新控制流状态 */ + + PFM_CFC_Check(10); + PFM_CFC_Check(11); + PFM_CFC_Check(12); + PFM_CFC_Check(13); + PFM_CFC_Check(14); + } + MSCP_LOG_MSG("timecurr 16 Output2x2 = %lld us\n", NOW_USED_TIME); + + /*########################平台数据发送########################*/ + PFM_CFC_Check(15); + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + /*热备状态切换*/ + SFM_2x2_ChangeState(); + } + else + { + /*无处理 */ + } + PFM_CFC_Check(16); + /*- 获取当前热备状态 */ + state_2x2 = SFM_2x2_GetLocal2x2State(); + MSCP_LOG_MSG("SFM_2x2_GetSysCount() = %d, s_txSn = %d\n", SFM_2x2_GetSysCount(), SFM_GetTxSn()); + MSCP_LOG_MSG("timecurr 16.1 = %lld us\n", NOW_USED_TIME); + /*- 本系是否为主 */ + if (ENUM_2x2_MASTER == state_2x2) + { + MSCP_LOG_MSG("Out:innetSafe = %d, innetRaw = %d, outnetSafe = %d\n", (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_InnetSafe].buf_len, (CM_UINT32)PFM_RAW_TX(i).buf_len, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].buf_len); + /*- 发送内网安全输出数据 */ + PFM_CFC_Check(17); + SFM_TxInnetSafe(g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_InnetSafe].p_buf, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_InnetSafe].buf_len); + + PFM_CFC_Check(18); + /*- @alias 发送内网透传输出数据 */ + for (i = 1; i <= (s_2x2oo2_InnetRaw_num + s_2x2oo2_InnetRaw_Extend_num); i++) + { + (void)CFM_TxInnetRaw(i, PFM_RAW_TX(i).p_buf, (CM_UINT32)PFM_RAW_TX(i).buf_len); + } + + /*- 发送外网安全输出数据 */ + PFM_CFC_Check(19); + SFM_TxOutnetSafe(g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].p_buf, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetSafe].buf_len); + /*- 发送外网透传输出数据 */ + PFM_CFC_Check(20); + (void)CFM_TxOutnetRaw(g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].p_buf, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].buf_len); + } + else + { + /*- 直接更新控制流状态 */ + PFM_CFC_Check(17); + PFM_CFC_Check(18); + PFM_CFC_Check(19); + PFM_CFC_Check(20); + } + /*- 发送内网安全维护模式数据*/ + SFM_TxInnetSafeRm(g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].p_buf, (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].buf_len); + MSCP_LOG_MSG("SFM_TxInnetSafeRm = %d\n",g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_RemoteUpdate].buf_len); + /*- 清空外网透传数据得长度(主备都清空) */ + g_2x2oo2_tx[g_2x2oo2_base][s_2x2oo2_OutnetRaw].buf_len = 0; + /*- @alias 清空内网透传数据得长度(主备都清空) */ + for (i = 1; i <= (s_2x2oo2_InnetRaw_num + s_2x2oo2_InnetRaw_Extend_num); i++) + { + PFM_RAW_TX(i).buf_len = 0; + } + PFM_CFC_Check(21);/*预留控制流*/ + /*- 硬件重启输出*/ + MSCP_LOG_MSG("timecurr 16.2 = %lld us\n", NOW_USED_TIME); + PFM_HardWareBoot_OutPut(); + MSCP_LOG_MSG("timecurr 17 OutputSend = %lld us\n", NOW_USED_TIME); +} + +/** +* @brief 周期末处理 +* @details +* 生成和传输跟随数据 +*/ +void PFM_EndProc(void) +{ + /*- 变量初始化 */ + CM_UINT32 crc = 0u; /* crc值 */ + CM_UINT8 mybuf[8] = { 0u }; /* 本机2oo2缓冲区 */ + CM_UINT8 peerbuf[8] = { 0u };/* 邻机2oo2缓冲区 */ + CM_INT32 len = 0; /* 长度 */ + ENUM_BOARD_STATE_T remoteState; + static CM_UINT8 MaintenanceFlag = 0u; + /* 应用关键数据的2oo2比较 */ + /*80 * 10 * 1024 耗时20ms*/ + /*- 是否开启了2oo2功能 */ + PFM_CFC_Check(48); + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 生成跟随数据的特征信息 */ + crc = CM_Crc32(g_TxAppFollow, (CM_UINT32)g_TxAppFollow_len); + CM_LongToChar((CM_UINT32)g_TxAppFollow_len, mybuf); + CM_LongToChar(crc, mybuf + 4); + /*- 2oo2交换特征信息 */ + len = SFM_2oo2_Exchange_Currency(mybuf, 8, peerbuf, 8u, ENUM_2oo2_OUTPUT_CHECK); + /*- 2oo2严格比较特征信息 */ + CM_RE_ASSERT(8 == len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + if(0 == CM_Memcmp(mybuf, peerbuf, (CM_SIZE_T)8)) + { + /*- 无处理 */ + } + else + { + MSCP_LOG_DATALEN(g_TxAppFollow, g_TxAppFollow_len, "PFM_EndProc g_TxAppFollow_len"); + CM_RE_ASSERT(0, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + } + /*板卡状态与硬件重启IO更新*/ + PFM_HardWareBoot_UpData(); + /*- 周期末维护模式转换 */ + remoteState = PFM_GetBoardState(); + CM_LongToChar(remoteState,mybuf); + len = SFM_2oo2_Exchange_Currency(mybuf, 4, peerbuf, 4u, ENUM_2oo2_OUTPUT_CHECK); + CM_RE_ASSERT(0 == CM_Memcmp(mybuf, peerbuf, (CM_SIZE_T)4), IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_3); + if(1u == MaintenanceFlag) + { + (void)SFM_2oo2_Exchange_Currency(mybuf, 0, peerbuf, 0u, ENUM_2oo2_SHUTDOWNQUIT); + /*- 进入运营模式 */ + CM_ASSERT(0, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_4); + } + else if(ENUM_BOARDSTATE_EXIT == g_boardState) + { + MaintenanceFlag = 1u; + } + else + { + /*- 继续运行 */ + } + } + else + { + + /*- 无处理 */ + } + MSCP_LOG_MSG("timecurr 9 PFM_EndProc txCompare = %lld us\n", NOW_USED_TIME); + PFM_CFC_Check(49); + /* 应用关键数据跟随 */ + /*- 是否开启了2x2功能 */ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + /*- 周期末2x2处理 */ + SFM_2x2_EndProc(); + } + else + { + + /*- 无处理 */ + } + +} + +/** +* @brief 将收到的外网输入报文填写到安全协议层 +* @param Buf 外网输入报文指针 +* @param len 外网输入报文长度 +*/ +static void s_RxOutnetToSFM(IN const CM_UINT8 buf[], IN CM_UINT32 len) +{ + /*- 变量初始化 */ + CM_UINT8 i = 0u; + CM_UINT32 redLen = 0u; /* 红网报文长度 */ + CM_UINT32 blueLen = 0u; /* 蓝网报文长度 */ + CM_UINT32 offset = 0u; /* 蓝网报文长度 */ + CM_UINT32 tmpLen = len; /* 蓝网报文长度 */ + for(i = 0u;i < 2u; i++) + { + tmpLen = len - offset; + /*- 输入合法性检查是否通过 */ + if (tmpLen >= 8u) + { + /*- 将红、蓝网外网输入报文分别填入安全协议层 */ + redLen = CM_LongFromChar(&buf[offset]); + CM_RE_ASSERT(redLen <= (tmpLen - 8u),IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + SFM_WriteOutnetSafeInput(&buf[offset + 4u], redLen, ENUM_OUTNET_RED); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + /*- 注册函数是否为空 */ + if(NULL == p_Status_Communication_Func) + { + /*- 无处理 */ + } + else + { + /*- 将数据给到应用,应用解包判断通信情况 */ + (*p_Status_Communication_Func)(&buf[offset + 4u], redLen, ENUM_OUTNET_RED, s_rciRedTempBuf, &s_rciRedTempBufOffset); + } + blueLen = CM_LongFromChar(&buf[offset + 4u + redLen]); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + CM_RE_ASSERT(blueLen <= (tmpLen - 8u - redLen),IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_2); + SFM_WriteOutnetSafeInput(&buf[offset + 8u + redLen], blueLen, ENUM_OUTNET_BLUE);/* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + if(NULL == p_Status_Communication_Func) + { + /*- 无处理 */ + } + else + { + /*- 将数据给到应用,应用解包判断通信情况 */ + (*p_Status_Communication_Func)(&buf[offset + 8u + redLen], blueLen, ENUM_OUTNET_BLUE, s_rciBlueTempBuf, &s_rciBlueTempBufOffset); + } + offset = blueLen + 8u + redLen; + } + else + { + /*- 无处理 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_PFMINPUTOUTPUT_RXOUTNETTOSFM, 4U, &tmpLen); + } + } +} + +/** +* @brief 生成输出校验报文 +* @param Buf 输出校验报文指针 +* @param BufSize 输出校验报文缓冲区大小 +* @return 输出校验报文长度 +*/ +static CM_INT32 s_2oo2OutputCheckFrame_Pack(OUT CM_UINT8 buf[], IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; /* 循环变量 */ + CM_INT32 ch = 0; /* 循环变量 */ + CM_UINT32 len = 0u; /* 输出跟随报文长度 */ + CM_UINT32 crc = 0u; /* 输出跟随报文CRC */ + CM_UINT32 sysCyc = SFM_2x2_GetSysCount(); /* 系统周期号 */ + + /*- 入参检查*/ + CM_ASSERT(((6 + (g_2x2oo2_data_num * 8)) <= (CM_INT32)BufSize) && (NULL != buf), IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + + /*- 填写周期号 */ + CM_LongToChar(sysCyc, buf); + i += 4; + /*- @alias 填写输出报文的长度和crc */ + for (ch = 1; ch <= g_2x2oo2_data_num; ch++) + { + if ((CM_UINT32)CM_TRUE == g_2x2oo2_tx[g_2x2oo2_base][ch].b_2oo2_Enable) + { + len = (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][ch].buf_len; + crc = CM_Crc32(g_2x2oo2_tx[g_2x2oo2_base][ch].p_buf, len); + CM_LongToChar(len, &buf[i]); + i += 4; + CM_LongToChar(crc, &buf[i]); + i += 4; + } + else + { + /*二取标志未使能*/ + } + } + /*二取表决加入硬重启标志*/ + buf[i++] = PFM_GetBoardRebootState(); + MSCP_LOG_MSG("PFM_GetBoardState = %d, PFM_GetBoardRebootState = %d\n",PFM_GetBoardState(), PFM_GetBoardRebootState()); + /*- 返回输出校验报文长度 */ + return i; +} +/** +* @brief 生成输出校验报文 +* @param Buf 输出校验报文指针 +* @param BufSize 输出校验报文缓冲区大小 +* @return 输出校验报文长度 +*/ +static CM_INT32 s_2x2OutputCheckFrame_Pack(OUT CM_UINT8 *buf, IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; /* 循环变量 */ + CM_INT32 ch = 0; /* 循环变量 */ + CM_UINT32 len = 0u; /* 输出跟随报文长度 */ + CM_UINT32 crc = 0u; /* 输出跟随报文CRC */ + CM_UINT32 sysCyc = SFM_2x2_GetSysCount(); /* 系统周期号 */ + /*- 入参检查*/ + CM_ASSERT(((4 + (g_2x2oo2_data_num * 8)) <= (CM_INT32)BufSize) && (NULL != buf), IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_1); + + /*- 填写周期号 */ + CM_LongToChar(sysCyc, buf); + i += 4; + /*- @alias 填写输出报文的长度和crc */ + for (ch = 1; ch <= g_2x2oo2_data_num; ch++) + { + if ((CM_UINT32)CM_TRUE == g_2x2oo2_tx[g_2x2oo2_base][ch].b_2x2_Enable) + { + len = (CM_UINT32)g_2x2oo2_tx[g_2x2oo2_base][ch].buf_len; + crc = CM_Crc32(g_2x2oo2_tx[g_2x2oo2_base][ch].p_buf, len); + CM_LongToChar(len, &buf[i]); + i += 4; + CM_LongToChar(crc, &buf[i]); + i += 4; + } + else + { + /*二取标志未使能*/ + } + } + + /*- 返回输出校验报文长度 */ + return i; +} +/** +* @brief 接收外网透传报文 +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 PFM_OutnetRaw_AppRecv(OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + /*- 变量初始化 */ + CM_UINT32 msgLen = 0u; /* 消息长度 */ + CM_UINT32 rt = 0u; /* 函数返回值 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_index_log++;/*记录应用调用次数,每周期清零*/ + /*- 入参检查 */ + CM_ASSERT(NULL != rxBuf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_21); + /*- 自己是否是CPU1 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + /*- 本机通道是否有数据未取走 */ + if ((s_OutnetRaw_Mine_AppReadIndex + 4u) <= (CM_UINT32)(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].mine_len)) + { + msgLen = CM_LongFromChar(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_mine_buf + s_OutnetRaw_Mine_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT((s_OutnetRaw_Mine_AppReadIndex + 4u + msgLen) <= (CM_UINT32)g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_3); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_4); + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_mine_buf + s_OutnetRaw_Mine_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_5); + s_OutnetRaw_Mine_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + /*- 邻机通道是否有数据未取走 */ + else if ((s_OutnetRaw_Peer_AppReadIndex + 4u) < (CM_UINT32)g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].peer_len) + { + msgLen = CM_LongFromChar(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_peer_buf + s_OutnetRaw_Peer_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_6); + CM_RE_ASSERT((s_OutnetRaw_Peer_AppReadIndex + 4u + msgLen) <= (CM_UINT32)g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_7); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_8); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_9); + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_peer_buf + s_OutnetRaw_Peer_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_10); + s_OutnetRaw_Peer_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + else + { + /*- 双网都取完了,返回true */ + } + + } + else + { + + /*- 邻机通道是否有数据未取走 */ + if ((s_OutnetRaw_Peer_AppReadIndex + 4u) < (CM_UINT32)g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].peer_len) + { + msgLen = CM_LongFromChar(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_peer_buf + s_OutnetRaw_Peer_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_11); + CM_RE_ASSERT((s_OutnetRaw_Peer_AppReadIndex + 4u + msgLen) <= (CM_UINT32)g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_12); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_13); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_14); + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_peer_buf + s_OutnetRaw_Peer_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_15); + s_OutnetRaw_Peer_AppReadIndex += (CM_UINT32)msgLen + 4u; + + } + /*- 本机通道是否有数据未取走 */ + else if ((s_OutnetRaw_Mine_AppReadIndex + 4u) <= (CM_UINT32)(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].mine_len)) + { + msgLen = CM_LongFromChar(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_mine_buf + s_OutnetRaw_Mine_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_16); + CM_RE_ASSERT((s_OutnetRaw_Mine_AppReadIndex + 4u + msgLen) <= (CM_UINT32)g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_17); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_18); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_19); + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_mine_buf + s_OutnetRaw_Mine_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_20); + s_OutnetRaw_Mine_AppReadIndex += (CM_UINT32)msgLen + 4u; + + } + else + { + /*- 双网都取完了,返回true */ + } + + } + /*- 返回接收结果 */ + /* MSCP_LOG_MSG("PFM_OutnetRaw_AppRecv msgLen =%d\n",msgLen); */ + /* MSCP_LOG_MSG("PFM_OutnetRaw_AppRecv rt =%d\n",rt); */ + return rt; +} + + +/** +* @brief 发送外网透传报文 +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用发送一条完整的应用报文 +* 每周期可多次调用本函数从而发送多个应用报文, +* 注意总发送长度不要超过周期通信总量限制 +*/ +CM_UINT8 PFM_OutnetRaw_AppSend( IN const CM_UINT8* txBuf, IN CM_UINT32 txLen, IN CM_UINT16 dstName, IN CM_UINT16 dstLogicID, IN CM_UINT16 type) +{ + /*- 入口检查 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT32 sysCount = SFM_2x2_GetSysCount(); /* 周期号 */ + + CM_ASSERT(0x55u == g_PFM_Cfg.M_OutnetRaw_Enable, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_1); + CM_ASSERT(NULL != txBuf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_4); + CM_RE_ASSERT(txLen <= NET_20K_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_2); + /*- 写入外网透传数组 */ + /*CC外网输出帧 + 2字节 长度 + 1字节 协议版本 + 4字节 周期号 + 4字节帧序号 + 2字节 目的设备id + 2字节 目的逻辑id + 2字节 协议类型 + n字节 数据 + 4字节CRC + */ + CM_ShortToChar((CM_UINT16)(txLen + 19), g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len); + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf[g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len + 2] = 0u; /*协议版本 固定填0*/ + CM_LongToChar(sysCount, g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len + 3); /*填入周期号*/ + /* 此处空出4个字节的帧序号位置 ,发送的时候填充*/ + CM_LongToChar(0u, g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len + 7); + CM_ShortToChar(dstName, g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len + 11); /* 填入目的ID*/ + CM_ShortToChar(dstLogicID, g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len + 13); + CM_ShortToChar(type, g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len + 15); + + /*- 写入外网透传数组 */ + ret = CM_Memcpy((void*)(g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len + 17), + (CM_SIZE_T)CM_UNSIGNED_INT_EXP(g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_size - (CM_UINT32)g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len - 17u), + (const void*)(txBuf), (CM_SIZE_T)(txLen)); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_3); + CM_LongToChar(0u, g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].p_buf + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len + txLen + 17); + g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetRaw].buf_len += (CM_INT32)CM_UNSIGNED_INT_EXP(txLen+21u); + + /*- 返回执行结果 */ + + return (CM_UINT8)ret; +} +/** +* @brief 接收内网透传报文 +* @param ch 通道ID +* @param pSrcName 源设备ID +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 PFM_InnetRaw_AppRecv(IN CM_INT32 ch, OUT CM_UINT16* pSrcName, OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + /*- 变量初始化 */ + CM_UINT32 msgLen = 0u; /* 消息长度 */ + CM_UINT32 rt = 0u; /* 函数返回值 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + APP_RAW_RX(ch).app_index_log++;/*记录应用调用次数,每周期清零*/ + /*- 入参检查 */ + CM_ASSERT(NULL != rxBuf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_17); + /*- 自己是否是CPU1 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_1); + /*- 本机通道是否有数据未取走 */ + if ((s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE) <= (CM_UINT32)(APP_RAW_RX(ch).mine_len)) + { + msgLen = CM_LongFromChar(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch]); + CM_RE_ASSERT(msgLen >= PFM_RAW_DEVID_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT((s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_LEN_SIZE + msgLen) <= (CM_UINT32)APP_RAW_RX(ch).mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_3); + CM_RE_ASSERT((msgLen - PFM_RAW_DEVID_SIZE) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_4); + rt = msgLen - PFM_RAW_DEVID_SIZE; + *pSrcName = CM_ShortFromChar(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_LEN_SIZE); + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE), (CM_SIZE_T)CM_UNSIGNED_INT_EXP(msgLen - PFM_RAW_DEVID_SIZE)); + s_InnetRaw_Mine_AppReadIndex[ch] += (CM_UINT32)msgLen + PFM_RAW_LEN_SIZE; + } + /*- 邻机通道是否有数据未取走 */ + else if ((s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE) < (CM_UINT32)APP_RAW_RX(ch).peer_len) + { + msgLen = CM_LongFromChar(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch]); + CM_RE_ASSERT(msgLen >= PFM_RAW_DEVID_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_5); + CM_RE_ASSERT((s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_LEN_SIZE + msgLen) <= (CM_UINT32)APP_RAW_RX(ch).peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_6); + CM_RE_ASSERT((msgLen - PFM_RAW_DEVID_SIZE) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_7); + rt = msgLen - PFM_RAW_DEVID_SIZE; + *pSrcName = CM_ShortFromChar(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_LEN_SIZE); + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE), (CM_SIZE_T)CM_UNSIGNED_INT_EXP(msgLen - PFM_RAW_DEVID_SIZE)); + s_InnetRaw_Peer_AppReadIndex[ch] += (CM_UINT32)msgLen + PFM_RAW_LEN_SIZE; + } + else + { + /*- 双网都取完了,返回true */ + } + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_8); + } + else + { + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_9); + /*- 邻机通道是否有数据未取走 */ + if ((s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE) < (CM_UINT32)APP_RAW_RX(ch).peer_len) + { + msgLen = CM_LongFromChar(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch]); + CM_RE_ASSERT(msgLen >= PFM_RAW_DEVID_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_10); + CM_RE_ASSERT((s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_LEN_SIZE + msgLen) <= (CM_UINT32)APP_RAW_RX(ch).peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_11); + CM_RE_ASSERT((msgLen - PFM_RAW_DEVID_SIZE) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_12); + rt = msgLen - PFM_RAW_DEVID_SIZE; + *pSrcName = CM_ShortFromChar(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_LEN_SIZE); + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE), (CM_SIZE_T)CM_UNSIGNED_INT_EXP(msgLen - PFM_RAW_DEVID_SIZE)); + s_InnetRaw_Peer_AppReadIndex[ch] += (CM_UINT32)msgLen + PFM_RAW_LEN_SIZE; + } + /*- 本机通道是否有数据未取走 */ + else if ((s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE) <= (CM_UINT32)(APP_RAW_RX(ch).mine_len)) + { + msgLen = CM_LongFromChar(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch]); + CM_RE_ASSERT(msgLen >= PFM_RAW_DEVID_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_13); + CM_RE_ASSERT((s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_LEN_SIZE + msgLen) <= (CM_UINT32)APP_RAW_RX(ch).mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_14); + CM_RE_ASSERT((msgLen - PFM_RAW_DEVID_SIZE) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_15); + rt = msgLen - PFM_RAW_DEVID_SIZE; + *pSrcName = CM_ShortFromChar(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_LEN_SIZE); + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE), (CM_SIZE_T)CM_UNSIGNED_INT_EXP(msgLen - PFM_RAW_DEVID_SIZE)); + s_InnetRaw_Mine_AppReadIndex[ch] += (CM_UINT32)msgLen + PFM_RAW_LEN_SIZE; + } + else + { + /*- 双网都取完了,返回true */ + } + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_16); + } + + /*- 返回接收结果 */ + return rt; +} +/** +* @brief 快速接收内网透传报文 +* @param ch 通道ID +* @param pSrcName 源设备ID +* @param rxBuf 收到的应用报文数组二级指针 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 PFM_InnetRaw_AppRecv_Fast(IN CM_INT32 ch, OUT CM_UINT16* pSrcName, OUT const CM_UINT8** rxBuf) +{ + /*- 变量初始化 */ + CM_UINT32 msgLen = 0u; /* 消息长度 */ + CM_UINT32 rt = 0u; /* 函数返回值 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + APP_RAW_RX(ch).app_index_log++;/*记录应用调用次数,每周期清零*/ + /*- 入参检查 */ + CM_ASSERT(NULL != rxBuf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_13); + /*- 自己是否是CPU1 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_1); + /*- 本机通道是否有数据未取走 */ + if ((s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE) <= (CM_UINT32)(APP_RAW_RX(ch).mine_len)) + { + msgLen = CM_LongFromChar(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch]); + CM_RE_ASSERT(msgLen >= PFM_RAW_DEVID_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT((s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_LEN_SIZE + msgLen) <= (CM_UINT32)APP_RAW_RX(ch).mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_3); + rt = msgLen - PFM_RAW_DEVID_SIZE; + *pSrcName = CM_ShortFromChar(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_LEN_SIZE); + rxBuf[0] = APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE; + s_InnetRaw_Mine_AppReadIndex[ch] += (CM_UINT32)msgLen + PFM_RAW_LEN_SIZE; + } + /*- 邻机通道是否有数据未取走 */ + else if ((s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE) < (CM_UINT32)APP_RAW_RX(ch).peer_len) + { + msgLen = CM_LongFromChar(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch]); + CM_RE_ASSERT(msgLen >= PFM_RAW_DEVID_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_4); + CM_RE_ASSERT((s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_LEN_SIZE + msgLen) <= (CM_UINT32)APP_RAW_RX(ch).peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_5); + rt = msgLen - PFM_RAW_DEVID_SIZE; + *pSrcName = CM_ShortFromChar(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_LEN_SIZE); + rxBuf[0] = APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE; + s_InnetRaw_Peer_AppReadIndex[ch] += (CM_UINT32)msgLen + PFM_RAW_LEN_SIZE; + } + else + { + /*- 双网都取完了,返回true */ + } + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_6); + } + else + { + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_7); + /*- 邻机通道是否有数据未取走 */ + if ((s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE) < (CM_UINT32)APP_RAW_RX(ch).peer_len) + { + msgLen = CM_LongFromChar(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch]); + CM_RE_ASSERT(msgLen >= PFM_RAW_DEVID_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_8); + CM_RE_ASSERT((s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_LEN_SIZE + msgLen) <= (CM_UINT32)APP_RAW_RX(ch).peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_9); + rt = msgLen - PFM_RAW_DEVID_SIZE; + *pSrcName = CM_ShortFromChar(APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_LEN_SIZE); + rxBuf[0] = APP_RAW_RX(ch).p_peer_buf + s_InnetRaw_Peer_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE; + s_InnetRaw_Peer_AppReadIndex[ch] += (CM_UINT32)msgLen + PFM_RAW_LEN_SIZE; + } + /*- 本机通道是否有数据未取走 */ + else if ((s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE) <= (CM_UINT32)(APP_RAW_RX(ch).mine_len)) + { + msgLen = CM_LongFromChar(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch]); + CM_RE_ASSERT(msgLen >= PFM_RAW_DEVID_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_10); + CM_RE_ASSERT((s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_LEN_SIZE + msgLen) <= (CM_UINT32)APP_RAW_RX(ch).mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_11); + rt = msgLen - PFM_RAW_DEVID_SIZE; + *pSrcName = CM_ShortFromChar(APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_LEN_SIZE); + rxBuf[0] = APP_RAW_RX(ch).p_mine_buf + s_InnetRaw_Mine_AppReadIndex[ch] + PFM_RAW_HEADER_SIZE; + s_InnetRaw_Mine_AppReadIndex[ch] += (CM_UINT32)msgLen + PFM_RAW_LEN_SIZE; + } + else + { + /*- 双网都取完了,返回true */ + } + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_12); + } + + /*- 返回接收结果 */ + return rt; +} +/** +* @brief 接收内网透传辅助信息 +* @param ch 通道ID +* @param pSrcName 源设备ID +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 PFM_InnetRawHelpInfo_AppRecv(IN CM_INT32 ch, OUT CM_UINT8* MainInfoBuf,OUT CM_UINT8* PeerInfoBuf,IN CM_INT16 rxSize,OUT CM_UINT16 *PeerInfoLen) +{ + /*- 变量初始化 */ + CM_UINT32 msgLen = 0u; /* 消息长度 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + /*- 入参检查 */ + CM_ASSERT((NULL != MainInfoBuf) && (NULL != PeerInfoBuf) && (NULL != PeerInfoLen), IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_3); + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_1); + (void)CM_Memcpy(MainInfoBuf,(CM_SIZE_T)rxSize,APP_RAW_RX(ch).p_mine_helpinfo_buf,(CM_SIZE_T)APP_RAW_RX(ch).mine_helpinfo_len); + msgLen = APP_RAW_RX(ch).mine_helpinfo_len; + /*- 使能2取获取邻机数据,未使能2取获取本机数据*/ + if(0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + (void)CM_Memcpy(PeerInfoBuf,(CM_SIZE_T)rxSize,APP_RAW_RX(ch).p_peer_helpinfo_buf,(CM_SIZE_T)APP_RAW_RX(ch).peer_helpinfo_len); + *PeerInfoLen = (CM_UINT16)APP_RAW_RX(ch).peer_helpinfo_len; + } + else + { + (void)CM_Memcpy(PeerInfoBuf,(CM_SIZE_T)rxSize,APP_RAW_RX(ch).p_mine_helpinfo_buf,(CM_SIZE_T)APP_RAW_RX(ch).mine_helpinfo_len); + *PeerInfoLen = (CM_UINT16)APP_RAW_RX(ch).mine_helpinfo_len; + } + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(APP_RAW_RX(ch).app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_2); + return msgLen; +} +/** +* @brief 发送内网透传报文 +* @param ch 通道ID +* @param dstName 目的设备ID +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用发送一条完整的应用报文 +* 每周期可多次调用本函数从而发送多个应用报文, +* 注意总发送长度不要超过周期通信总量限制 +*/ +CM_UINT8 PFM_InnetRaw_AppSend(IN CM_INT32 ch, IN CM_UINT16 dstName, IN const CM_UINT8* txBuf, IN CM_UINT32 txLen) +{ + /*- 入口检查 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_RE_ASSERT(txLen <= NET_20K_SIZE, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT((txLen + 4u + (CM_UINT32)(APP_RAW_TX(ch).buf_len)) <= (CM_UINT32)(APP_RAW_TX(ch).buf_size), IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_2); + CM_ASSERT(NULL != txBuf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_4); + /*- 写入内网透传数组 */ + /* + 2字节 长度 + 2字节 目的ID + n字节 数据 + */ + CM_ShortToChar((CM_UINT16)(txLen + 2u), APP_RAW_TX(ch).p_buf + APP_RAW_TX(ch).buf_len); + CM_ShortToChar(dstName, APP_RAW_TX(ch).p_buf + APP_RAW_TX(ch).buf_len + 2); + ret = CM_Memcpy((void*)(APP_RAW_TX(ch).p_buf + APP_RAW_TX(ch).buf_len + 4), + (CM_SIZE_T)CM_UNSIGNED_INT_EXP(APP_RAW_TX(ch).buf_size - (CM_UINT32)APP_RAW_TX(ch).buf_len - 4u), + (const void*)(txBuf), (CM_SIZE_T)(txLen)); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_3); + APP_RAW_TX(ch).buf_len += (CM_INT32)CM_UNSIGNED_INT_EXP(txLen + 4u); + /*- 返回执行结果 */ + return (CM_UINT8)1u; +} + +/** +* @brief 发送外网心跳报文 +* @return 发送报文长度 取值范围:0~0x7FFFFFFF +* @details 仅限平台调用,不可对应用提供接口 +*/ +CM_INT32 PFM_OutnetHeart_Send(void) +{ + /*- 初始化变量 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT8 offset = 2u; + CM_UINT8 buf[20] = {0};/*- 临时数组*/ + CM_UINT32 crc = 0u; + STRU_2x2oo2_tx_T *p_2x2oo2_tx = &g_2x2oo2_tx[s_2x2oo2_app][s_2x2oo2_OutnetHeart]; + /* + 2字节 长度 + n字节 数据 + */ + /*- 写入外网心跳数组 */ + buf[offset++] = 0x06u;/* 请求类型*/ + buf[offset++] = SFM_2x2_GetLastLocal2x2State(); + CM_LongToChar(SFM_2x2_GetSysCount(), &buf[offset]); + offset += 4u; + crc = CM_Crc32(&buf[2u],offset-2u);/*- 此处不需防护,offset初始值就是2*/ + CM_LongToChar(crc, &buf[offset]); + offset += 4u; + /*- 填写数据长度*/ + CM_ShortToChar((CM_UINT16)(offset-2u), &buf[0u]); + /* 总长度*/ + ret = CM_Memcpy((void*)p_2x2oo2_tx->p_buf, + (CM_SIZE_T)CM_UNSIGNED_INT_EXP(p_2x2oo2_tx->buf_size), + (const void*)(buf), (CM_SIZE_T)(offset)); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_16, TSCP_DARK_ASSERT_1); + p_2x2oo2_tx->buf_len += (CM_INT32)CM_UNSIGNED_INT_EXP(offset); + /*- 返回发送报文长度*/ + return p_2x2oo2_tx->buf_len; +} + +/** +* @brief 接收外网心跳报文 +* @param rxBuf 收到的应用报文数组 取值范围:非空 +* @param rxSize 接收应用报文的缓冲区大小 取值范围:0~0xFFFFFFFF +* @return 收到的应用报文长度 取值范围:0~0xFFFFFFFF +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +* 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +*/ +CM_UINT32 PFM_OutnetHeart_AppRecv(OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + /*- 变量初始化 */ + CM_UINT32 msgLen = 0u; /*- 消息长度 */ + CM_UINT32 rt = 0u; /*- 函数返回值 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + STRU_2x2oo2_rx_T *p_2x2oo2_rx = &g_2x2oo2_rx[s_2x2oo2_app][s_2x2oo2_OutnetHeart]; + p_2x2oo2_rx->app_index_log++;/*-记录应用调用次数,每周期清零*/ + /*- 入参检查 */ + CM_ASSERT(NULL != rxBuf, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_1); + /*- 本系是否为主系 */ + if(ENUM_2x2_MASTER == SFM_2x2_GetLastLocal2x2State()) + { + /*- 自己是否是CPU1 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + /*- 本机通道是否有数据未取走 */ + if ((s_OutnetHeart_Mine_AppReadIndex + 4u) <= (CM_UINT32)(p_2x2oo2_rx->mine_len)) + { + msgLen = CM_LongFromChar(p_2x2oo2_rx->p_mine_buf + s_OutnetHeart_Mine_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT((s_OutnetHeart_Mine_AppReadIndex + 4u + msgLen) <= (CM_UINT32)p_2x2oo2_rx->mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_3); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_4); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_5); + /*- 拷贝数据到输出缓冲区 */ + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(p_2x2oo2_rx->p_mine_buf + s_OutnetHeart_Mine_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_6); + s_OutnetHeart_Mine_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + /*- 邻机通道是否有数据未取走 */ + else if ((s_OutnetHeart_Peer_AppReadIndex + 4u) < (CM_UINT32)p_2x2oo2_rx->peer_len) + { + msgLen = CM_LongFromChar(p_2x2oo2_rx->p_peer_buf + s_OutnetHeart_Peer_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_7); + CM_RE_ASSERT((s_OutnetHeart_Peer_AppReadIndex + 4u + msgLen) <= (CM_UINT32)p_2x2oo2_rx->peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_8); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_9); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_10); + /*- 拷贝数据到输出缓冲区 */ + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(p_2x2oo2_rx->p_peer_buf + s_OutnetHeart_Peer_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_11); + s_OutnetHeart_Peer_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + else + { + /*- 双网都取完了,返回true */ + MSCP_LOG_MSG("Heart_AppRecv_MM_cpu:%d M_len:%d,P_len:%d\n",g_PFM_Cfg.CPU_ID,s_OutnetHeart_Mine_AppReadIndex,s_OutnetHeart_Peer_AppReadIndex); + } + } + else + { + /*- 邻机通道是否有数据未取走 */ + if ((s_OutnetHeart_Peer_AppReadIndex + 4u) < (CM_UINT32)p_2x2oo2_rx->peer_len) + { + msgLen = CM_LongFromChar(p_2x2oo2_rx->p_peer_buf + s_OutnetHeart_Peer_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_12); + CM_RE_ASSERT((s_OutnetHeart_Peer_AppReadIndex + 4u + msgLen) <= (CM_UINT32)p_2x2oo2_rx->peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_13); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_14); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_15); + /*- 拷贝数据到输出缓冲区 */ + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(p_2x2oo2_rx->p_peer_buf + s_OutnetHeart_Peer_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_16); + s_OutnetHeart_Peer_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + /*- 本机通道是否有数据未取走 */ + else if ((s_OutnetHeart_Mine_AppReadIndex + 4u) <= (CM_UINT32)(p_2x2oo2_rx->mine_len)) + { + msgLen = CM_LongFromChar(p_2x2oo2_rx->p_mine_buf + s_OutnetHeart_Mine_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_17); + CM_RE_ASSERT((s_OutnetHeart_Mine_AppReadIndex + 4u + msgLen) <= (CM_UINT32)p_2x2oo2_rx->mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_18); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_19); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_20); + /*- 拷贝数据到输出缓冲区 */ + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(p_2x2oo2_rx->p_mine_buf + s_OutnetHeart_Mine_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_21); + s_OutnetHeart_Mine_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + else + { + /*- 双网都取完了,返回true */ + MSCP_LOG_MSG("Heart_AppRecv_MM_cpu:%d M_len:%d,P_len:%d\n",g_PFM_Cfg.CPU_ID,s_OutnetHeart_Mine_AppReadIndex,s_OutnetHeart_Peer_AppReadIndex); + } + } + } + /*- 对系是否是主系 */ + else if(ENUM_2x2_MASTER == SFM_2x2_GetLastPartner2x2State()) + { + /*- 自己是否是CPU1 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + /*- 本机通道是否有数据未取走 */ + if ((s_OutnetHeart_Mine_AppReadIndex + 4u) <= (CM_UINT32)(p_2x2oo2_rx->rmt_mine_len)) + { + msgLen = CM_LongFromChar(p_2x2oo2_rx->p_rmt_mine_buf + s_OutnetHeart_Mine_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_22); + CM_RE_ASSERT((s_OutnetHeart_Mine_AppReadIndex + 4u + msgLen) <= (CM_UINT32)p_2x2oo2_rx->rmt_mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_23); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_24); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_25); + /*- 拷贝数据到输出缓冲区 */ + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(p_2x2oo2_rx->p_rmt_mine_buf + s_OutnetHeart_Mine_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_26); + s_OutnetHeart_Mine_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + /*- 邻机通道是否有数据未取走 */ + else if ((s_OutnetHeart_Peer_AppReadIndex + 4u) < (CM_UINT32)p_2x2oo2_rx->rmt_peer_len) + { + msgLen = CM_LongFromChar(p_2x2oo2_rx->p_rmt_peer_buf + s_OutnetHeart_Peer_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_27); + CM_RE_ASSERT((s_OutnetHeart_Peer_AppReadIndex + 4u + msgLen) <= (CM_UINT32)p_2x2oo2_rx->rmt_peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_28); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_29); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_30); + /*- 拷贝数据到输出缓冲区 */ + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(p_2x2oo2_rx->p_rmt_peer_buf + s_OutnetHeart_Peer_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_31); + s_OutnetHeart_Peer_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + else + { + /*- 双网都取完了,返回true */ + MSCP_LOG_MSG("Heart_AppRecv_PM_cpu:%d M_len:%d,P_len:%d\n",g_PFM_Cfg.CPU_ID,s_OutnetHeart_Mine_AppReadIndex,s_OutnetHeart_Peer_AppReadIndex); + } + } + else + { + /*- 邻机通道是否有数据未取走 */ + if ((s_OutnetHeart_Peer_AppReadIndex + 4u) < (CM_UINT32)p_2x2oo2_rx->rmt_peer_len) + { + msgLen = CM_LongFromChar(p_2x2oo2_rx->p_rmt_peer_buf + s_OutnetHeart_Peer_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_32); + CM_RE_ASSERT((s_OutnetHeart_Peer_AppReadIndex + 4u + msgLen) <= (CM_UINT32)p_2x2oo2_rx->rmt_peer_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_33); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_34); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_35); + /*- 拷贝数据到输出缓冲区 */ + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(p_2x2oo2_rx->p_rmt_peer_buf + s_OutnetHeart_Peer_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_36); + s_OutnetHeart_Peer_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + /*- 本机通道是否有数据未取走 */ + else if ((s_OutnetHeart_Mine_AppReadIndex + 4u) <= (CM_UINT32)(p_2x2oo2_rx->rmt_mine_len)) + { + msgLen = CM_LongFromChar(p_2x2oo2_rx->p_rmt_mine_buf + s_OutnetHeart_Mine_AppReadIndex); + CM_RE_ASSERT(msgLen > 0u, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_37); + CM_RE_ASSERT((s_OutnetHeart_Mine_AppReadIndex + 4u + msgLen) <= (CM_UINT32)p_2x2oo2_rx->rmt_mine_len, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_38); + CM_RE_ASSERT((msgLen) <= rxSize, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_39); + rt = msgLen; + /*- 锁定接收通道 */ + ret = CM_Mutex_Lock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_40); + /*- 拷贝数据到输出缓冲区 */ + (void)CM_Memcpy((void*)rxBuf, (CM_SIZE_T)rxSize, (void*)(p_2x2oo2_rx->p_rmt_mine_buf + s_OutnetHeart_Mine_AppReadIndex + 4u), (CM_SIZE_T)(msgLen)); + /*- 解锁接收通道 */ + ret = CM_Mutex_Unlock(p_2x2oo2_rx->app_mutex); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_41); + s_OutnetHeart_Mine_AppReadIndex += (CM_UINT32)msgLen + 4u; + } + else + { + /*- 双网都取完了,返回true */ + MSCP_LOG_MSG("Heart_AppRecv_PM_cpu:%d M_len:%d,P_len:%d\n",g_PFM_Cfg.CPU_ID,s_OutnetHeart_Mine_AppReadIndex,s_OutnetHeart_Peer_AppReadIndex); + } + } + } + else/*< 如果无主系 */ + { + /*- 无处理 */ + MSCP_LOG_MSG("Heart_AppRecv Not Master\n"); + } + + /*- 返回接收结果 */ + return rt; +} +/** +* @brief 维护模式输入微周期处理(无宕机函数) +* @details +* 平台数据接收; +* 本地输入数据2oo2交换和比较; +* 交付协议适配层处理。 +*/ +void PFM_InputProc_Crash(void) +{ + CM_UINT8 data[1024*10] = {0u}; + CM_UINT8 pData[1024*10] = {0u}; + CM_UINT32 dataLen = 0u; + CM_INT32 ret = 0; + /************************平台数据接收*************************/ + g_PFM_Check = PFM_CFC_PROC_NUM + 2; + /*- 内网安全数据接收 */ + dataLen = (CM_UINT32)SFM_RxInnetRemoteUpdate(data, sizeof(data)); + + /*- 是否开启了2oo2功能 */ + if (0x55u == g_RMUP_Cfg.M_2oo2_Enable) + { + /*- 2oo2交换输出校验帧 */ + ret = SFM_2oo2_Exchange_FullDuplex_Crash(data, dataLen, pData, (CM_UINT32)1024u*10u, ENUM_2oo2_OUTPUT_EX); + } + else + { + /*- 无处理 */ + } + g_PFM_Check = PFM_CFC_PROC_NUM + 3; + MSCP_LOG_MSG("PFM_InputProc_Crash dataLen = %d\n",dataLen); + if(2u == g_RMUP_Cfg.CPU_ID) + { + SFM_WriteInnetSafeRmInput(pData, ret, ENUM_INNET_GREEN); + MSCP_LOG_DATALEN(pData, ret, "PFM_InputProc_Crash pData"); + SFM_WriteInnetSafeRmInput(data, dataLen, ENUM_INNET_PURPLE); + MSCP_LOG_DATALEN(data, dataLen, "PFM_InputProc_Crash data"); + } + else if(1u == g_RMUP_Cfg.CPU_ID) + { + SFM_WriteInnetSafeRmInput(data, dataLen, ENUM_INNET_GREEN); + MSCP_LOG_DATALEN(data, dataLen, "PFM_InputProc_Crash data"); + SFM_WriteInnetSafeRmInput(pData, ret, ENUM_INNET_PURPLE); + MSCP_LOG_DATALEN(pData, ret, "PFM_InputProc_Crash pData"); + } + else + { + MSCP_LOG_MSG("Channel exception\n"); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1)); + } + g_PFM_Check = PFM_CFC_PROC_NUM + 4; +} + +/** +* @brief 维护模式输出微周期处理(无宕机函数) +* @details +* 从协议适配层获取输出数据; +* 平台数据发送。 +*/ +void PFM_OutputProc_Crash(void) +{ + /*- 变量初始化 */ + CM_UINT8 data[1024*100] = {0u}; + CM_UINT32 dataLen = 0u; + CM_UINT8 pData[1024*100] = {0u}; + CM_UINT32 ret = 0u; + /*########################从协议适配层获取输出数据########################*/ + /*- 从协议适配层获取输出数据 */ + dataLen = SFM_ReadInnetCodedOutputCrash(data, sizeof(data)); + + /*- 是否开启了2oo2功能 */ + if (0x55u == g_RMUP_Cfg.M_2oo2_Enable) + { + /*- 2oo2交换输出校验帧 */ + ret = SFM_2oo2_Exchange_FullDuplex_Crash(data, dataLen, pData, (CM_UINT32)1024u*100u, ENUM_2oo2_OUTPUT_EX); + /*- 检查2oo2双机的输出校验帧是否一致 */ + CM_ASSERT_MAINTAIN(dataLen == ret); + ret = CM_Memcmp(data, pData, (CM_SIZE_T)dataLen); + + CM_ASSERT_MAINTAIN(0u == ret); + } + else + { + /*- 无处理 */ + } + + /*- 发送内网安全输出数据 */ + SFM_TxInnetSafeRemoteUpdate(data, dataLen); + MSCP_LOG_DATALEN(data, dataLen, "PFM_OutputProc_Crash data"); +} + + +/** +* @brief 获取平台暂存的红蓝网设备信息 +* @param RedBuf 红网缓冲区 取值范围:非空 +* @param BlueBuf 篮网缓冲区 取值范围:非空 +* @details RCI用于获取平台暂存的红蓝网设备信息 +*/ +void PFM_GetRciTempBuf(OUT CM_UINT16* RedBuf, OUT CM_UINT16* BlueBuf) +{ + /*- 入参是否非空 */ + if((RedBuf!=NULL) && (BlueBuf!=NULL)) + { + /*- 红蓝网通信源设备信息 */ + (void)CM_Memcpy((void*)RedBuf,sizeof(CM_UINT16)*288u,s_rciRedTempBuf,sizeof(CM_UINT16)*288u); + (void)CM_Memcpy((void*)BlueBuf,sizeof(CM_UINT16)*288u,s_rciBlueTempBuf,sizeof(CM_UINT16)*288u); + (void)CM_Memset(s_rciRedTempBuf, 0u, sizeof(CM_UINT16)*288u, sizeof(CM_UINT16)*288u); + (void)CM_Memset(s_rciBlueTempBuf, 0u, sizeof(CM_UINT16)*288u, sizeof(CM_UINT16)*288u); + s_rciRedTempBufOffset = 0u; + s_rciBlueTempBufOffset = 0u; + } + else + { + /*- 无处理 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(IN_OUT_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2)); + MSCP_LOG_MSG("RED or BLUE Buf is NULL\n"); + } +} + + diff --git a/TSCP/src/MSCP/PFM/PFM_InputOutput.h b/TSCP/src/MSCP/PFM/PFM_InputOutput.h new file mode 100644 index 0000000..2735779 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_InputOutput.h @@ -0,0 +1,70 @@ +/** +* @file PFM_InputOutput.h +* @brief Platform Function Module: 输入输出管理 +* @details +* 平台输入微周期和输出微周期的2oo2、2x2功能实现 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef PFM_INPUTOUTPUT_H +#define PFM_INPUTOUTPUT_H +#include "CM_Types.h" +#include "MSCP_APP_Interface.h" +#ifdef __cplusplus +extern "C" +{ +#endif + /*透传接收通道的长度定义*/ + #define PFM_RAW_LEN_SIZE (4u) + #define PFM_RAW_DEVID_SIZE (2u) + #define PFM_RAW_HEADER_SIZE (PFM_RAW_LEN_SIZE + PFM_RAW_DEVID_SIZE) + /* 微周期控制初始化 */ + void PFM_Init(void); + + /* 双缓冲切换 */ + void PFM_BufSwich(void); + + /* 输入微周期处理 */ + void PFM_InputProc(void); + + /* 输出微周期处理 */ + void PFM_OutputProc(void); + + /* 周期后处理 */ + void PFM_EndProc(void); + /**@brief 接收外网透传报文*/ + CM_UINT32 PFM_OutnetRaw_AppRecv(OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize); + /**@brief 发送外网透传报文*/ + CM_UINT8 PFM_OutnetRaw_AppSend( IN const CM_UINT8* txBuf, IN CM_UINT32 txLen, IN CM_UINT16 dstName, IN CM_UINT16 dstLogicID, IN CM_UINT16 type); + /* 内网透传数据接收 */ + CM_UINT32 PFM_InnetRaw_AppRecv(IN CM_INT32 ch, OUT CM_UINT16 *pSrcName, OUT CM_UINT8 *rxBuf, IN CM_UINT32 rxSize); + /* 快速接收内网透传报文*/ + CM_UINT32 PFM_InnetRaw_AppRecv_Fast(IN CM_INT32 ch, OUT CM_UINT16* pSrcName, OUT const CM_UINT8** rxBuf); + /** @brief 接收内网透传辅助信息*/ + CM_UINT32 PFM_InnetRawHelpInfo_AppRecv(IN CM_INT32 ch, OUT CM_UINT8* MainInfoBuf,OUT CM_UINT8* PeerInfoBuf,IN CM_INT16 rxSize,OUT CM_UINT16 *PeerInfoLen); + /* 内网透传数据发送 */ + CM_UINT8 PFM_InnetRaw_AppSend(IN CM_INT32 ch, IN CM_UINT16 dstName, IN const CM_UINT8 *txBuf, IN CM_UINT32 txLen); + /* 发送外网心跳报文 */ + CM_INT32 PFM_OutnetHeart_Send(void); + /** + * @brief 接收外网心跳报文 + */ + CM_UINT32 PFM_OutnetHeart_AppRecv(OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize); + + /* 维护模式输入微周期处理(无宕机函数) */ + void PFM_InputProc_Crash(void); + /* 维护模式输出微周期处理(无宕机函数) */ + void PFM_OutputProc_Crash(void); + + void PFM_GetRciTempBuf(OUT CM_UINT16* RedBuf, OUT CM_UINT16* BlueBuf); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_Log.c b/TSCP/src/MSCP/PFM/PFM_Log.c new file mode 100644 index 0000000..124f091 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_Log.c @@ -0,0 +1,957 @@ +/** +* @filename PFM_Log.c +* @brief Platform Function Module:日志相关功能 +* @details +* 平台和应用的日志记录功能 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_Log.h" +#include "PFM_RemoteUpdate.h" +#include "stdarg.h" +#include "CM_Time.h" +#include "CM_TCP.h" +#include "CM_Memory.h" +#include "CFM_Net.h" +#include "DFM_DRV.h" +#include "MSCP_APP_Interface.h" +#include "SFM_2x2.h" +#include "SFM_2oo2.h" +#include "CM_Convert.h" +#include +#include +#include "CM_IniFile.h" + +extern CM_UINT32 g_MSCP_SysCount; +ENUM_INIT_STAGE_FLAG g_InitUpdateFlag = ENUM_ERROR;/*- 初始化阶段标志*/ +static CM_UINT8 s_stopflag = 0xaau; /* 全局宕机标志 */ +static CM_UINT8 s_AutoRebootCut= 0u;/*自动重启次数*/ +CM_UINT8 g_AutoRebootVersion[4]= {0u};/*自动重启版本号*/ +static CM_UINT16 stopTimer = TSCP_DARK_NULL;/*暗文日志参数*/ +static CM_CHAR s_crashlogBuf[500] = { 0 }; + +static STRU_2OO2_NET_NO_PACK_T s_2oo2_AutoReboot = { + .SN = 0u, /*初始化SN码*/ + .DataSend = CFM_2oo2_DataSend_ASSERT, /*注册发送函数指针*/ + .DataRecv = CFM_2oo2_DataRecv_ASSERT}; /*注册接收函数指针*/ + +static CM_UINT8 PFM_LOG_SHUTDOWN(CM_UINT32 darkBuf, CM_UINT32 MaintenanceFlag, const CM_CHAR *filename, const CM_CHAR *func, CM_INT32 line); +static void PFM_LOG_MaintenanceMode(ENUM_BOARD_STATE_T boardState, CM_UINT32 MaintenanceFlag); +static void PFM_LOG_ManageCrashlog(void); +/** +* @brief 设置初始化阶段标志 +* @param ENUM_INIT_STAGE_FLAG stage 设置初始化阶段 +*/ +void PFM_LOG_SET_INIT_STAGE(ENUM_INIT_STAGE_FLAG stage) +{ + /*- 设置初始化阶段 */ + g_InitUpdateFlag = stage; +} +/** +* @brief 获取宕机标志位 +* @param 无 +* @return 宕机标志位状态 +*/ +CM_UINT8 PFM_LOG_GET_STOP_FLAG(void) +{ + /*- 返回宕机标志位的值 */ + return s_stopflag; +} +/** +* @brief 获取初始化阶段标志 +* @return ENUM_INIT_STAGE_FLAG stage 获取初始化阶段 +*/ +ENUM_INIT_STAGE_FLAG PFM_LOG_GET_INIT_STAGE(void) +{ + /*- 获取初始化阶段 */ + return g_InitUpdateFlag; +} +/** +* @brief 设置暗文日志阶段参数 +* @param value 设置暗文日志阶段参数 取值范围:0~0xffff +*/ +void PFM_LOG_SET_STOPTIMER(CM_UINT16 value) +{ + stopTimer = value; +} + +/** +* @brief 获取自动重启次数 +* @return 重启次数 取值范围:0~0xff +*/ +CM_UINT8 MSCP_Get_AutoRbootCut(void) +{ + return s_AutoRebootCut; +} + +/** +* @brief 重置自动重启次数 +* @param Cut 重启次数 +* @return 重启次数 取值范围:0~ff +*/ +CM_UINT8 MSCP_Reset_AutoRbootCut(CM_UINT8 Cut) +{ + /*- 设置重启参数 */ + s_AutoRebootCut = Cut; + /*- 返回结果 */ + return s_AutoRebootCut; +} +/** +* @brief 平台记录格式化字符串日志 +* @param filename 文件路径 +* @param func 函数名 +* @param line 行号 +* @param fmt 格式化字符串 +*/ +void MSCP_PFM_LOG_MSG(IN const CM_CHAR *filename, IN CM_INT32 line, IN const CM_CHAR* fmt, ...) +{ + /*- 变量初始化 */ + va_list argList; + CM_CHAR msgBuf[1024 + 256]; + CM_INT32 headLen = 0; + CM_INT32 msgLen = 0; + if(NULL == fmt) + { + /* 无处理 */ + } + else + { + /*- 记录文件名、函数名、行号 */ + headLen = snprintf(msgBuf, sizeof(msgBuf), "ps:%s:%d:", filename, line); + va_start(argList, (fmt)); + /*- 记录日志内容 */ + msgLen += vsnprintf(msgBuf + headLen, sizeof(msgBuf) - (CM_SIZE_T)headLen, fmt, argList); + va_end(argList); +#ifdef WIN32 + Bootprintf("%s", msgBuf + headLen); +#endif + /* printf("%s", msgBuf + headLen);*/ + /*- 输出日志信息 */ + (void)CFM_BaseLog_Send((CM_UINT8*)msgBuf, headLen + msgLen); + } +} +/** +* @brief 平台记录二进制日志 +* @param filename 文件路径 +* @param func 函数名 +* @param line 行号 +* @param Buf 二进制数组指针 +* @param Len 二进制数组长度 +*/ +void MSCP_PFM_LOG_BIN(IN const CM_CHAR *filename, IN const CM_CHAR *func, IN CM_INT32 line, IN const CM_UINT8 *Buf, IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT32 i = 0u; + CM_UINT32 cut = (Len/CFM_INNET_LOG_BIN_SIZE) + (((Len%CFM_INNET_LOG_BIN_SIZE) > 0u)?(1u):(0u)); + CM_CHAR tmepBuf[CFM_INNET_LOG_SIZE]; + CM_UINT32 msgLen = 0u; + if(NULL == Buf) + { + /* 无处理 */ + } + else + { + for(i = 0u;i < cut;i++) + { + (void)snprintf(tmepBuf, sizeof(tmepBuf), "pb:"); + msgLen = ((cut-i)>1u)?CFM_INNET_LOG_BIN_SIZE:(Len%CFM_INNET_LOG_BIN_SIZE); + (void)CM_Memcpy(&tmepBuf[3],CFM_INNET_LOG_BIN_SIZE,&Buf[i*CFM_INNET_LOG_BIN_SIZE],(CM_SIZE_T)msgLen); + /*- 输出日志信息 */ + (void)CFM_BaseLog_Send((CM_UINT8*)tmepBuf, msgLen+3u); + } + } +} + + +/** +* @brief 平台记录二进制日志/仅用于测试 +* @param filename 文件路径 +* @param func 函数名 +* @param line 行号 +* @param Buf 二进制数组指针 +* @param Len 二进制数组长度 +*/ +void MSCP_PFM_LOG_BIN_TEST(IN const CM_CHAR *filename, IN const CM_CHAR *func, IN CM_INT32 line, IN const CM_UINT8 *Buf, IN CM_UINT32 Len) +{ + + /*- 变量初始化 */ + CM_UINT32 i = 0u; + CM_UINT32 i_cut = 0u; + CM_UINT32 j = 0u; + CM_UINT32 cut = (Len/CFM_INNET_LOG_BIN_TEST_SIZE) + (((Len % CFM_INNET_LOG_BIN_TEST_SIZE) > 0u)?1:0); + CM_UINT8 tmepBuf[CFM_INNET_LOG_SIZE]; + CM_UINT8 str[10u] = {0u}; + CM_UINT32 msgLen = 0u; + for(j = 0u;j < cut;j++) + { + msgLen = snprintf(tmepBuf, sizeof(tmepBuf), "pb:%d:",j); + i_cut = ((cut-j) > 1u)?CFM_INNET_LOG_BIN_TEST_SIZE:(Len%CFM_INNET_LOG_BIN_TEST_SIZE); + for(i = 0u;i < i_cut;i++) + { + msgLen += sprintf(str,"0x%x.",Buf[j*CFM_INNET_LOG_BIN_TEST_SIZE+i]); + strcat(tmepBuf,str); + } + //printf("%s", tmepBuf); + /*- 输出日志信息 */ + (void)CFM_BaseLog_Send((CM_UINT8*)tmepBuf, msgLen); + } +} + +/** +* @brief 平台\应用记录暗文日志 +* @param infoType 数据类型 +* 取值范围:0x55:info为字符串数据方式 +* 0xAA:info为十六进制数据方式 +* 0xFF:info为十进制数据方式 +* @param code 信息编码/信息类型 取值范围:0~0xffff +* @param infoLen 数据长度 取值范围:0~0xffff +* @param info 数据/信息 取值范围:任意类型指针 +*/ +void MSCP_PFM_LOG_DARK(IN const CM_UINT8 infoType, IN const CM_UINT16 code, IN const CM_UINT32 infoLen, IN const void *info) +{ + (void)CFM_DarkLog_Storage(infoType, code, infoLen, info); +} + + +/** +* @brief 断言 +* @param x 断言结果 +* @param filename 文件路径 +* @param Mode 发生故障函数模块 +* @param faultCode 模块内函数顺序 +* @param funNum 函数内宕机顺序 +* @param func 函数名 +* @param line 行号 +*/ +void MSCP_ASSERT(unsigned int x, unsigned int MaintenanceFlag, unsigned short Mode, unsigned char faultCode, unsigned char funNum, const char *filename, const char *func, int line) +{ + /*- 变量初始化*/ + static CM_UINT8 state = 0xaaU; + static FILE * fp_crash; + static FILE * fp_historical; + static CM_CHAR str_crash[256] = {0}; + static CM_INT16 ret = -1; + + CM_UINT8 lightPs = 0x55; + CM_UINT8 i = 0u;/*循环计次*/ + CM_UINT8 mybuf[29] = {0}; + CM_UINT8 peerbuf[29] = {0}; + CM_INT32 rxLen = 0; + /*- 填充暗文故障码*/ + CM_UINT32 darkBuf = (Mode<<16u)|(faultCode<<8u)|funNum; + ENUM_2x2_STATE_T localState = ENUM_2x2_SHUTDOWN; + CM_UINT8 countFalse = 0xff; + CM_UINT8 tmepIndex = 0u; + /*- 全局宕机标志是否有效 */ + if(0x55u == s_stopflag) + { + /*- 宕机死循环 */ + while(1) + { + /*- 休眠500ms */ + CM_Sleep(500u); + } + } + else + { + /*- 无处理 */ + } + + /*- 断言是否失效 */ + if (0u == x) + { + /*- 置位全局宕机标志 */ + s_stopflag = 0x55u; + SFM_2x2_LOG_Transition(); + /*- 控制台输出断言失效信息 */ + MSCP_LOG_MSG("ASSERT: %s:%s:%d,version:%d.%d.%d.%d,Cyc = %d,DefaultNum:0x%x\n", filename, func, line,MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3],g_MSCP_SysCount,darkBuf); + (void)printf("ASSERT: %s:%s:%d,version:%d.%d.%d.%d,Cyc = %d,DefaultNum:0x%x\n", filename, func, line,MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3],g_MSCP_SysCount,darkBuf); + fp_crash = fopen("crashlog.txt", "w+"); + fp_historical = fopen("historicallog.txt", "a"); + for(i = 0; i < 3; i++) + { + (1 == g_App_Verson.registerVerson[i].versonName)?tmepIndex = i:tmepIndex; + } + (void)sprintf(str_crash,"0x%x\n0x%x\n0x%x\ncrash %u times Num[0x%x]: ASSERT: %s:%s:%d\n", + countFalse, + RM_Get_FaultRbootCut(), + CM_LongFromChar(g_App_Verson.registerVerson[tmepIndex].verson), + s_AutoRebootCut,darkBuf,filename, func, line); + ret=fwrite(str_crash,(CM_SIZE_T)1u,strlen(str_crash),fp_crash); + if (ret != strlen(str_crash)) + { + MSCP_LOG_MSG("fwrite crashlog.txt fail!\n"); + (void)printf("fwrite crashlog.txt fail!\n"); + } + else + { + /*- 无处理 */ + } + ret=fwrite(str_crash,(CM_SIZE_T)1u,strlen(str_crash),fp_historical); + if (ret != strlen(str_crash)) + { + MSCP_LOG_MSG("fwrite historicallog.txt fail!\n"); + (void)printf("fwrite historicallog.txt fail!\n"); + } + else + { + /*- 无处理 */ + } + CFM_BaseLog_SaveLocal(fp_crash); + (void)fclose(fp_crash); + (void)fclose(fp_historical); + /*- 关闭所有TCP连接 */ + (void)CM_TCP_Socket_Close_shutdown(); + CM_Sleep(500u); + /*- 安全关断*/ + DFM_saftyOff(); + + /*- 设置LED指示灯*/ + if(ENUM_INIT_DRV <= PFM_LOG_GET_INIT_STAGE()) + { + /*- 设置LED指示灯*/ + DFM_ledError(); + DFM_ledMS(0u); + DFM_ledMonitor(2); + /*IO输出导向安全*/ + CM_Sleep(10u); + (void)DFM_SetIO_OutPut(0x00); + } + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_PSLIGHT, 1U, &lightPs); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, stopTimer, 1u, &state); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_INFO_ERR_TYPE, 4u, &darkBuf);/*发送暗文故障编码*/ + /*- 更改热备状态为宕机,通过暗文再次发送热备状态帧(要保证这个帧是该暗文日志最后一个热备状态帧) */ + SFM_2x2_SetLocal2x2State(localState); + localState = SFM_2x2_GetLocal2x2State(); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_LOCAL, 1U, &localState); + /*- 暗文标志位至为发送 */ + if(ENUM_INIT_MAIN_NET <= PFM_LOG_GET_INIT_STAGE()) + { + CFM_LogCiphertextSend(); + } + + /*- 退出运营故障码*/ + if(darkBuf == 0x0D0404) + { + /*- 退出运营模式*/ + PFM_SetBoardState(ENUM_BOARDSTATE_EXIT); + } + else + { + /*- 设置故障模式*/ + if((ENUM_INIT_2OO2_DATA <= g_InitUpdateFlag) && (ENUM_INIT_2X2 >= g_InitUpdateFlag)) + { + PFM_SetBoardState(ENUM_BOARDSTATE_UPDATE); + } + else + { + PFM_SetBoardState(ENUM_BOARDSTATE_DEFAULT); + } + /*- 二取发送重启命令*/ + if((0x55u == g_PFM_Cfg.M_2oo2_Enable) && (ENUM_INIT_2OO2_DATA <= PFM_LOG_GET_INIT_STAGE())) + { + /*- 交互类型*/ + CM_LongToChar(6u,&mybuf[0]); + /*通信次数*/ + mybuf[4] = 0x01u; + /*禁止重启*/ + mybuf[5] = 0xFFu; + /*维护模式*/ + mybuf[6] = MaintenanceFlag; + /*2取-主线程2取数据最小为23字节*/ + rxLen = CFM_2oo2_Currency_NoSplit(&s_2oo2_AutoReboot,mybuf,13,peerbuf,29); + if(rxLen >= 13) + { + (void)printf("MSCP_ASSERT:rcv success Type:0x%x,ReBoot:0x%x,MF:0x%x\n",peerbuf[3],peerbuf[5],peerbuf[6]); + } + else + { + (void)printf("MSCP_ASSERT:rcv fail\n"); + } + } + } + /*- 维护模式*/ + PFM_LOG_MaintenanceMode(MaintenanceFlag, darkBuf); + } +} +/** +* @brief 自动重启断言 +* @param x 断言结果 +* @param filename 文件路径 +* @param Mode 发生故障函数模块 +* @param faultCode 模块内函数顺序 +* @param funNum 函数内宕机顺序 +* @param func 函数名 +* @param line 行号 +*/ +void MSCP_REBOOT_ASSERT(unsigned int x, unsigned int MaintenanceFlag,unsigned short Mode, unsigned char faultCode, unsigned char funNum, const char *filename, const char *func, int line) +{ + /*- 变量初始化*/ + static CM_UINT8 state = 0xaaU; + CM_UINT8 AutoReboot_Flag = 0u; + /*- 填充暗文故障码*/ + CM_UINT32 darkBuf = (Mode<<16u)|(faultCode<<8u)|funNum; + ENUM_2x2_STATE_T localState = ENUM_2x2_SHUTDOWN; + CM_UINT8 lightPs = 0x55; + /*- 全局宕机标志是否有效 */ + if(0x55u == s_stopflag) + { + /*- 宕机死循环 */ + while(1) + { + /*- 休眠500ms */ + CM_Sleep(500u); + } + } + else + { + /*- 无处理 */ + } + + /*- 断言是否失效 */ + if (0u == x) + { + /*- 置位全局宕机标志 */ + s_stopflag = 0x55u; + SFM_2x2_LOG_Transition(); + /*- 控制台输出断言失效信息 */ + MSCP_LOG_MSG("MSCP_REBOOT_ASSERT: %s:%s:%d,version:%d.%d.%d.%d,Cyc = %d,DefaultNum:0x%x\n", filename, func, line,MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3],g_MSCP_SysCount,darkBuf); + (void)printf("MSCP_REBOOT_ASSERT: %s:%s:%d,version:%d.%d.%d.%d,Cyc = %d,DefaultNum:0x%x\n", filename, func, line,MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3],g_MSCP_SysCount,darkBuf); + AutoReboot_Flag = PFM_LOG_SHUTDOWN(darkBuf, MaintenanceFlag, filename, func, line); + /*- 关闭所有TCP连接 */ + (void)CM_TCP_Socket_Close_shutdown(); + CM_Sleep(500u); + /*- 安全关断*/ + DFM_saftyOff(); + if(ENUM_INIT_DRV <= PFM_LOG_GET_INIT_STAGE()) + { + /*- 设置LED指示灯*/ + DFM_ledError(); + DFM_ledMS(0u); + DFM_ledMonitor(2); + /*IO输出导向安全*/ + CM_Sleep(10u); + (void)DFM_SetIO_OutPut(0x00); + } + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, stopTimer, 1u, &state); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_INFO_ERR_TYPE, 4u, &darkBuf);/*发送暗文故障编码*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_PSLIGHT, 1U, &lightPs); + /*- 更改热备状态为宕机,通过暗文再次发送热备状态帧(要保证这个帧是该暗文日志最后一个热备状态帧) */ + SFM_2x2_SetLocal2x2State(localState); + localState = SFM_2x2_GetLocal2x2State(); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_LOCAL, 1U, &localState); + /*- 暗文标志位至为发送 */ + if(ENUM_INIT_MAIN_NET <= PFM_LOG_GET_INIT_STAGE()) + { + CFM_LogCiphertextSend(); + } + /*- 是否执行重启命令*/ + if(AutoReboot_Flag == 0x55u) + { + (void)printf("See You Later!!!\n"); + (void)system("shutdown"); + /*- 休眠等待重启 */ + CM_Sleep(CM_UINT32_MAX); + } + else + { + (void)printf("Please check err!!!\n"); + } + + /*- 设置故障模式*/ + PFM_SetBoardState(ENUM_BOARDSTATE_DEFAULT); + + /*- 维护模式*/ + PFM_LOG_MaintenanceMode(MaintenanceFlag, darkBuf); + } +} +/** +* @brief 断言(维护模式下使用的断言函数) +* @param x 断言结果 +* @param filename 文件路径 +* @param func 函数名 +* @param line 行号 +*/ +void MSCP_ASSERT_MAINTAIN(unsigned int x, const char *filename, const char *func, int line) +{ + static CM_UINT8 count = 0; + if (0u == x) + { + MSCP_LOG_MSG("MSCP_ASSERT_MAINTAIN ASSERT(MAINTAIN): %s:%s:%d ,count = %u\n, Cyc = %u\n", filename, func, line, count, g_MSCP_SysCount); + count ++; + } +} +/** +* @brief 上电读取和删除本地日志文件 +* @return 无 +*/ +void MSCP_Read_Del_Logfile(void) +{ + /*- 变量初始化 */ + CM_CHAR buf_i[100] = { 0 }; /* 临时变量:字符串缓冲区 */ + CM_CHAR buf_o[100] = { 0 }; /* 临时变量:字符串缓冲区 */ + CM_CHAR historyBuf[2048]; + CM_CHAR tempBuf[2048]; + CM_UINT32 fileCurrentSize = 0; + CM_UINT32 i = 0; + CM_UINT8 tempdata = 0u; + CM_UINT32 tempversion = 0u; + FILE *fp_historical = fopen("historicallog.txt", "r+"); + FILE *pfile = fopen("crashlog.txt", "r");/* 文件指针 */ + FILE *p_rebootfile = fopen("rebootlog.txt", "r");/* 文件指针 */ + /*- 如果描述符不为空*/ + if (pfile != NULL) + { + /*- @alias 读取重启次数 */ + if(NULL != fgets(buf_i, 100, pfile)) + { + (void)printf("crashlog:%s",buf_i); + /*- 删除空格*/ + a_trim(buf_o, buf_i); + /*- 提取重启次数*/ + (void)sscanf(buf_o, "%x", &s_AutoRebootCut); + (void)printf("crashlog:s_AutoRebootCut = 0x%x\n",s_AutoRebootCut); + /*- 禁止重启后清零*/ + if(0xFF == s_AutoRebootCut) + { + /*- 清零*/ + s_AutoRebootCut = 0u; + (void)printf("crashlog:RebootCut = 0x%x\n",s_AutoRebootCut); + } + else + { + /*- nothing to do*/ + } + } + else + { + (void)printf("crashlog1:read fail!!!\n"); + } + /*- @alias 读取故障软重启次数 */ + if((!feof(pfile)) && (NULL != fgets(buf_i, 100, pfile))) + { + (void)printf("crashlog:%s",buf_i); + /*- 删除空格*/ + a_trim(buf_o, buf_i); + /*- 提取重启次数*/ + (void)sscanf(buf_o, "%x", &tempdata); + (void)printf("crashlog:FaultRebootCut = 0x%x\n",tempdata); + RM_Reset_FaultRbootCut(tempdata); + } + else + { + (void)printf("crashlog2:read fail!!!\n"); + } + /*- @alias 读取版本号 */ + if((!feof(pfile)) && (NULL != fgets(buf_i, 100, pfile))) + { + (void)printf("crashlog:%s",buf_i); + /*- 删除空格*/ + a_trim(buf_o, buf_i); + /*- 提取版本号*/ + (void)sscanf(buf_o, "%x", &tempversion); + CM_LongToChar(tempversion,g_AutoRebootVersion); + (void)printf("crashlog:Ver:%d,%d,%d,%d,\n",g_AutoRebootVersion[0],g_AutoRebootVersion[1],g_AutoRebootVersion[2],g_AutoRebootVersion[3]); + } + else + { + (void)printf("crashlog3:read fail!!!\n"); + } + /*- 读取上一次宕机原因写入缓冲区s_crashlogBuf */ + if((!feof(pfile)) && (NULL != fgets(s_crashlogBuf, 450, pfile))) + { + (void)printf("crashlog:%s",buf_i); + } + else + { + (void)printf("crashlog4:read fail!!!\n"); + } + /*- 关闭文件描述符 */ + (void)fclose(pfile); + PFM_LOG_ManageCrashlog(); + } + else + { + /*- 文件不存在空指针为正常情况*/ + } + + if(p_rebootfile != NULL) + { + /*- @alias 读取重启次数 */ + if(NULL != fgets(buf_i, 100, p_rebootfile)) + { + (void)printf("rebootlog:%s",buf_i); + /*- 删除空格*/ + a_trim(buf_o, buf_i); + /*- 提取重启次数*/ + (void)sscanf(buf_o, "%x", &tempdata); + (void)printf("rebootlog:FaultRebootCut = 0x%x\n",tempdata); + /*- 清零*/ + RM_Reset_FaultRbootCut(tempdata); + (void)printf("rebootlog:FaultRebootCut = 0x%x\n",RM_Get_FaultRbootCut()); + } + else + { + /*- 读取失败*/ + (void)printf("rebootlog:read fail!!!\n"); + } + /*- 关闭文件描述符 */ + (void)fclose(p_rebootfile); + } + else + { + /*- 无处理 */ + } + (void)remove("crashlog.txt"); + (void)remove("signallog.txt"); + (void)remove("RmUpSucess.txt"); + (void)remove("rebootlog.txt"); + + /*- @alias 更新historicallog.txt文件 */ + if (fp_historical != NULL) + { + fseek(fp_historical, 0, SEEK_END); + /*- 获取当前文件字节数 */ + fileCurrentSize = ftell(fp_historical); + printf("fileCurrentSize = %d\n",fileCurrentSize); + /*- 文件超过20kb,则更新historicallog.txt(大概能记录305条左右宕机信息) */ + if(fileCurrentSize >= 20480) + { + fseek(fp_historical, fileCurrentSize-1024, SEEK_SET); + fileCurrentSize = fread(historyBuf, 1024, 1, fp_historical); + (void)fclose(fp_historical); + /*- 处理字符串 */ + for(i = 0; i < 1024; i++) + { + if(('\n' == historyBuf[i]) && ('0' == historyBuf[i+1])) + { + (void)CM_Memcpy(tempBuf,1024,&historyBuf[i+1],1024-i); + break; + } + } + + fp_historical = fopen("historicallog.txt", "w"); + fileCurrentSize = fwrite(tempBuf, 1024-i, 1, fp_historical); + } + else + { + /*- 无处理 */ + } + (void)fclose(fp_historical); + } + else + { + /*- 文件不存在空指针为正常情况*/ + } +} + +/** +* @brief 打印数据和长度 +* @param Buf 存放数据缓冲区 取值范围:非空 +* @param Len 缓冲区大小 取值范围:0~0xffffffff +* @param Annotation 注释 取值范围:非空 +*/ +void MSCP_LOG_DATALEN(IN CM_UINT8 *Buf, IN CM_UINT32 Len, IN char *Annotation) +{ + /*- 入参不为空*/ + if((NULL != Annotation) && (NULL != Buf)) + { + /*- 发送数据和长度日志 */ + MSCP_LOG_MSG("%s , Len = %d\n", Annotation, Len); + MSCP_LOG_BIN(Buf, Len); + } + else + { + /*- 无处理 */ + MSCP_LOG_MSG("MSCP_LOG_DATALEN is NULL\n"); + } + +} + +/** +* @brief 宕机后自动重启判断 +* @param darkBuf 故障码 取值范围:0~0xffffffff +* @param MaintenanceFlag 是否允许远程重启 取值范围:0~0xffffffff +* @param filename 故障码 取值范围:非空 +* @param func 故障码 取值范围:非空 +* @param line 故障码 取值范围:0~0x7fffffff +* @return AutoReboot_Flag 取值范围:0x55允许重启,0xaa不允许重启 +*/ +static CM_UINT8 PFM_LOG_SHUTDOWN(CM_UINT32 darkBuf, CM_UINT32 MaintenanceFlag, const CM_CHAR *filename, const CM_CHAR *func, CM_INT32 line) +{ + /*- 变量初始化 */ + CM_UINT8 AutoReboot_Flag = 0u; + static FILE * fp_crash; + static FILE * fp_historical; + CM_UINT8 mybuf[29] = {0}; + CM_UINT8 peerbuf[29] = {0}; + CM_UINT8 i = 0u; + CM_INT32 rxLen = 0; + static CM_CHAR str_crash[256] = {0}; + static CM_INT16 ret = -1; + CM_UINT8 countFalse = 0xff; + CM_UINT8 tmepIndex = 0u; + + fp_crash = fopen("crashlog.txt", "w+"); + fp_historical = fopen("historicallog.txt", "a"); + /*- 二取是否全部允许重启*/ + if((0x55u == g_PFM_Cfg.M_2oo2_Enable) && (ENUM_INIT_2OO2_DATA <= PFM_LOG_GET_INIT_STAGE())) + { + /*- 交互类型*/ + CM_LongToChar(6u,&mybuf[0u]); + /*- 获取通信次数*/ + mybuf[4u] = 0x01u; + /*- 如果重启次数是否达到最大值 */ + if(g_PFM_Cfg.M_AutoReboot_Count > s_AutoRebootCut) + { + /*- 允许重启*/ + mybuf[5u] = s_AutoRebootCut + 1u; + } + else + { + /*- 禁止重启*/ + mybuf[5u] = 0xFFu; + } + /*维护模式*/ + mybuf[6u] = MaintenanceFlag; + /*2取-主线程2取数据最小为23字节*/ + rxLen = CFM_2oo2_Currency_NoSplit(&s_2oo2_AutoReboot,mybuf,13,peerbuf,29); + if(rxLen >= 13) + { + (void)printf("MSCP_REBOOT_ASSERT:rcv success Type:0x%x,ReBoot:0x%x,MF:0x%x\n",peerbuf[3],peerbuf[5],peerbuf[6]); + /*- 判断是否禁止重启 */ + if((0xFFu == mybuf[5u]) || (0xFFu == peerbuf[5u])) + { + (void)printf("MSCP_REBOOT_ASSERT:No reboot\n"); + /*- 禁止重启*/ + AutoReboot_Flag = 0xAAu; + } + else + { + /*- 允许重启*/ + (void)printf("MSCP_REBOOT_ASSERT:Ok reboot\n"); + AutoReboot_Flag = 0x55u; + } + } + else + { + (void)printf("MSCP_ASSERT:rcv fail\n"); + } + } + else + { + /*- 判断重启次数是否达到最大值 */ + if(g_PFM_Cfg.M_AutoReboot_Count > s_AutoRebootCut) + { + /*- 允许重启*/ + AutoReboot_Flag = 0x55u; + } + else + { + /*- 禁止重启*/ + AutoReboot_Flag = 0xAAu; + } + } + + for(i = 0; i < 3; i++) + { + (1 == g_App_Verson.registerVerson[i].versonName)?tmepIndex = i:tmepIndex; + } + + /*- 判断重启标志 */ + if(AutoReboot_Flag == 0x55u) + { + /*- 允许重启,根据重启条件判断写入文件次数*/ + /*- 1、记录自动重启次数 + * 2、记录故障软重启次数 + * 3、记录版本号 + * 4、记录宕机故障码信息等*/ + (void)sprintf(str_crash,"0x%x\n0x%x\n0x%lx\ncrash %u times Num[0x%x]: ASSERT: %s:%s:%d\n", \ + s_AutoRebootCut + 1, + RM_Get_FaultRbootCut(), + CM_LongFromChar(g_App_Verson.registerVerson[tmepIndex].verson), + s_AutoRebootCut,darkBuf,filename, func, line); + } + else + { + /*- 禁止重启,根据重启条件判断写入文件次数*/ + (void)sprintf(str_crash,"0x%x\n0x%x\n0x%lx\ncrash %u times Num[0x%x]: ASSERT: %s:%s:%d\n", \ + countFalse, + RM_Get_FaultRbootCut(), + CM_LongFromChar(g_App_Verson.registerVerson[tmepIndex].verson), + s_AutoRebootCut,darkBuf, filename, func, line); + } + ret=fwrite(str_crash,(CM_SIZE_T)1u,strlen(str_crash),fp_crash); + if (ret != strlen(str_crash)) + { + MSCP_LOG_MSG("fwrite crashlog.txt fail!\n"); + (void)printf("fwrite crashlog.txt fail!\n"); + } + else + { + /*- 无处理 */ + } + CFM_BaseLog_SaveLocal(fp_crash); + (void)fclose(fp_crash); + ret=fwrite(str_crash,(CM_SIZE_T)1u,strlen(str_crash),fp_historical); + if (ret != strlen(str_crash)) + { + MSCP_LOG_MSG("fwrite historicallog.txt fail!\n"); + (void)printf("fwrite historicallog.txt fail!\n"); + } + else + { + /*- 无处理 */ + } + (void)fclose(fp_historical); + return AutoReboot_Flag; +} + +/** +* @brief 维护模式主逻辑 +* @param MaintenanceFlag 是否允许远程重启 取值范围:0~0xffffffff +* @param darkBuf 故障码 取值范围:0~0xffffffff +* @return 无 +*/ +static void PFM_LOG_MaintenanceMode(CM_UINT32 MaintenanceFlag, CM_UINT32 darkBuf) +{ + /*- 变量初始化 */ + CM_UINT64 sMaintenanceTack = CM_GetTick()/CM_UNSIGNED_MILLION; + CM_UINT64 cMaintenanceTack = 0u; + CM_UINT64 eMaintenanceTack = 0u; + CM_UINT64 leftTime = 0u; /* 剩余时间 */ + CM_UINT64 u_64temp = g_PFM_Cfg.CYC_TIME; /*uint64临时变量*/ + CM_UINT64 s_count = 0; + ENUM_BOARD_STATE_T boardState = PFM_GetBoardState(); + CM_UINT8 lightPs = 0x55; + ENUM_2x2_STATE_T localState = SFM_2x2_GetLocal2x2State(); + CM_UINT64 costlog[2] = {0}; + /*- 清空2取缓冲区数据 */ + SFM_2oo2_CtrlInit(); + eMaintenanceTack = sMaintenanceTack + u_64temp; + while (1) + { + /*- 远程部署功能开关开启,并且维护id应用已设置不是初始值0 是否允许进入维护模式*/ + if ((0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) && (0x00u != g_Maintenance_Id) && (0x55 == MaintenanceFlag) && ((ENUM_BOARDSTATE_EXIT == boardState) || (ENUM_BOARDSTATE_UPDATE == boardState) || (ENUM_BOARDSTATE_DEFAULT == boardState))) + { + MSCP_LOG_MSG("----------Maintenance Mode count = %d----------\n",s_count); + + PFM_MaintenanceMode(); + boardState = PFM_GetBoardState(); + s_count ++; + cMaintenanceTack = CM_GetTick()/CM_UNSIGNED_MILLION; + if (eMaintenanceTack < cMaintenanceTack) + { + MSCP_LOG_MSG("eMaintenanceTack = %llu,cMaintenanceTack = %llu\n",eMaintenanceTack,cMaintenanceTack); + } + else + { + + } + costlog[0] = CM_GetTick(); + /*- 设置LED指示灯*/ + DFM_ledError(); + DFM_ledMS(0u); + DFM_ledMonitor(1u); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_PSLIGHT, 1U, &lightPs); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_LOCAL, 1U, &localState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_INFO_ERR_TYPE, 4u, &darkBuf); + /*发送暗文日志*/ + CFM_LogCiphertextSend(); + costlog[1] = CM_GetTick(); + MSCP_LOG_MSG("7 LedDark cost = %lld us\n", (costlog[1] - costlog[0]) / 1000u); + if(eMaintenanceTack < cMaintenanceTack) + { + leftTime = 0u; + sMaintenanceTack = cMaintenanceTack; + MSCP_LOG_MSG("Maintenance mode overtime\n"); + } + else + { + leftTime = eMaintenanceTack - cMaintenanceTack; + sMaintenanceTack = eMaintenanceTack; + } + eMaintenanceTack = eMaintenanceTack + u_64temp; + MSCP_LOG_MSG("Maintenance leftTime = %d\n",leftTime); + CM_Sleep((CM_UINT32)leftTime); + } + else + { + MSCP_LOG_MSG("MaintenanceFlag = %d, g_Maintenance_Id = %d, g_RMUP_Cfg.M_RemoteUpdate_Enable = %d, boardState = %d\n", \ + MaintenanceFlag,g_Maintenance_Id,g_RMUP_Cfg.M_RemoteUpdate_Enable,boardState); + CM_Sleep(CM_UINT32_MAX); + } + } +} + +void PFM_SendLastAssertLog(void) +{ + MSCP_LOG_MSG("Last crashlog:%s \n", s_crashlogBuf); +} + +/** +* @brief 宕机日志管理 +* @return 无 +*/ +static void PFM_LOG_ManageCrashlog(void) +{ + /*- 读宕机文件*/ + FILE *pcrash_num = NULL; + CM_CHAR str_crash_new_name[256] = {0}; + CM_CHAR str_crash_old_name[256] = {0}; + CM_UINT32 i = 0; + /*- 查找第一个不存在的文件名 */ + for(i = 0u;i<10u;i++) + { + /*- 通过打开文件成功检测文件是否存在 */ + sprintf(str_crash_new_name,"crashlog_%d.txt",i + 1u); + pcrash_num = fopen(str_crash_new_name,"r"); + /*- 找到第一个不存在的文件名 */ + if(NULL == pcrash_num) + { + /*- 跳出 */ + break; + } + else + { + /*- 关闭文件 */ + fclose(pcrash_num); + } + } + + /*- 如果所有文件名都存在,删除最旧的日志(crashlog_1.txt)*/ + if(10u == i) + { + (void)strcpy(str_crash_old_name,"crashlog_1.txt"); + (void)remove(str_crash_old_name); + for(i = 2u;i <= 10u; i++) + { + (void)sprintf(str_crash_new_name,"crashlog_%d.txt",i); + (void)rename(str_crash_new_name,str_crash_old_name); + (void)strcpy(str_crash_old_name,str_crash_new_name); + } + } + /*- 对文件重新命名 */ + (void)rename("crashlog.txt",str_crash_new_name); +} +/* + * @brief 暗文日志故障码生成指针函数 + * @param mode 模块(0-0xff) fault 故障码(0-0xff) num 故障位置序号(0-0xff) + * @return 故障码地址 + */ +CM_UINT32 *PFM_DarkLogGenerate(CM_UINT16 mode, CM_UINT16 fault, CM_UINT16 num) +{ + /* 变量初始化*/ + static CM_UINT32 lastcode = 0u; + /*拼接故障码*/ + lastcode = (mode<<16u)|(fault<<8u)|num; + /*返回故障码地址*/ + return &lastcode; +} diff --git a/TSCP/src/MSCP/PFM/PFM_Log.h b/TSCP/src/MSCP/PFM/PFM_Log.h new file mode 100644 index 0000000..90a9f06 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_Log.h @@ -0,0 +1,326 @@ +#ifndef PEM_LOG_H +#define PEM_LOG_H +#include "CM_Types.h" +#include + +#if WIN32 +#include "cp_interface.h" +#endif +#ifdef __cplusplus +extern "C" +{ +#endif + +#define TSCP_DARK_NULL (0x00u) +#define TSCP_DARK_CYC (0x01u) +#define TSCP_DARK_LOCAL (0x02u) +#define TSCP_DARK_PARTNER (0x03u) +#define TSCP_DARK_BOARDID (0x05u) +#define TSCP_DARK_CPUID (0x06u) +#define TSCP_DARK_DRVINIT (0x07u) +#define TSCP_DARK_TSCPINIT (0x08u) +#define TSCP_DARK_SOFTTNIT (0x09u) +#define TSCP_DARK_ETHERNET (0x0au) +#define TSCP_DARK_TMP (0x0bu) +#define TSCP_DARK_VOLTAGE (0x0cu) +#define TSCP_DARK_2oo2INIT (0x0du) +#define TSCP_DARK_INPUTTIME (0x0eu) +#define TSCP_DARK_APPTIME (0x0fu) +#define TSCP_DARK_OUTTIME (0x10u) +#define TSCP_DARK_2OO2 (0x11u) +#define TSCP_DARK_2x2 (0x12u) +#define TSCP_DARK_VERION (0x19u) +#define TSCP_DARK_EEPROMCPU (0x1au) +#define TSCP_DARK_EEPROMIO12S (0x1bu) +#define TSCP_DARK_EEPROM8S (0x1cu) +#define TSCP_DARK_CCSTATE (0x1du) +#define TSCP_DARK_SEBSTATE (0x1eu) +#define TSCP_DARK_PSLIGHT (0x1fu) +#define TSCP_DARK_RUNLIGHT (0x20u) +#define TSCP_DARK_2OLIGHT (0x21u) +#define TSCP_DARK_2XLIGHT (0x22u) +#define TSCP_DARK_CHANNEL_1_SHUNT (0x23u) +#define TSCP_DARK_CHANNEL_1_BUS (0x24u) +#define TSCP_DARK_CHANNEL_2_SHUNT (0x25u) +#define TSCP_DARK_CHANNEL_2_BUS (0x26u) +#define TSCP_DARK_CHANNEL_3_SHUNT (0x27u) +#define TSCP_DARK_CHANNEL_3_BUS (0x28u) +#define TSCP_DARK_SWITCHBUTTON (0x29u) +#define TSCP_DARK_IOTMP (0x2Au) +#define TSCP_DARK_BASEVERION (0x2Bu) +#define TSCP_DARK_IOOUTPUT (0x2Cu) +#define TSCP_DARK_IOINPUT (0x2Du) +#define TSCP_DARK_DRVVERION (0x2Eu) +#define TSCP_DARK_QNXVERION (0x2Fu) +#define TSCP_DARK_2OO2ETHSPI (0x30u) +#define TSCP_DARK_2X2ETH422 (0x31u) +#define TSCP_DARK_DOCVERION (0x32u) +#define TSCP_DARK_CPUMEMUSAGE (0x33u) +#define TSCP_DARK_ENDTIME (0x35u) +#define TSCP_DARK_CFMNET_ININTSYNC_TIMEOUT (0x36u) +#define TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR1 (0x37u) +#define TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR2 (0x38u) +#define TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR3 (0x39u) +#define TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR4 (0x3Au) +#define TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR5 (0x3Bu) +#define TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR6 (0x3Cu) +#define TSCP_DARK_CFMNET_UDPRAWRECVTHREAD_UPDATAEOR7 (0x3Du) +#define TSCP_DARK_CFMNET_REMOTEUPDATETHREAD_LENEOR (0x3Eu) +#define TSCP_DARK_CFMNET_INNETSAFE_RECVLEN (0x3Fu) +#define TSCP_DARK_CFMNET_INNETSAFERM_RECVLEN (0x40u) +#define TSCP_DARK_CFMNET_INNETREMOTEUPDATE_RECVLEN (0x41u) +#define TSCP_DARK_CFMNET_INNETRAW_RECVLEN (0x42u) +#define TSCP_DARK_CFMNET_OUTNETSAFE_RECVLENERO (0x43u) +#define TSCP_DARK_CFMNET_OUTNETRAW_RECVLENERO (0x44u) +#define TSCP_DARK_CFMNET_OUTNETHEART_RECVLENERO (0x45u) +#define TSCP_DARK_PFMCFG_INIT1 (0x46u) +#define TSCP_DARK_PFMCFG_INIT2 (0x47u) //47 48 49 4A +#define TSCP_DARK_PFMCFG_INIT3 (0x4Bu) +#define TSCP_DARK_PFMCFG_INIT4 (0x4Cu) +#define TSCP_DARK_PFMCFG_SENDDARKCFG (0x4Du) +#define TSCP_DARK_PFMCONTROFLOWCHECK_MONITOR1 (0x4Eu) +#define TSCP_DARK_PFMCONTROFLOWCHECK_MONITOR2 (0x4Fu) +#define TSCP_DARK_PFMCONTROFLOWCHECK_WATCHDOG (0x50u) +#define TSCP_DARK_PFMINPUTOUTPUT_INPUT2oo2SYNC (0x51u) +//#define TSCP_DARK_PFMINPUTOUTPUT_ENDPROC (0x52u) +#define TSCP_DARK_PFMINPUTOUTPUT_RXOUTNETTOSFM (0x53u) +#define TSCP_DARK_PFMREMOTEUPDATE_FILEUPDATEREQUEST1 (0x54u) +#define TSCP_DARK_PFMREMOTEUPDATE_FILEUPDATEREQUEST2 (0x55u) + +/*2取模块*/ +#define TSCP_DARK_2OO2_RCV_ERR (0x60u) +#define TSCP_DARK_2OO2_RCV_ARQ (0x61u) +#define TSCP_DARK_2OO2_SYNC_TIME (0x62u) +#define TSCP_DARK_2OO2_ALIGN_TIME (0x63u) +#define TSCP_DARK_2OO2_CRASH_RCVOK (0x64u) +#define TSCP_DARK_2OO2_CRASH_RCVERR (0x65u) +/*2x模块*/ +#define TSCP_DARK_2X2_ANALYSIS_DATA (0x70u) +#define TSCP_DARK_2X2_ANALYSIS_TIME (0x71u) +#define TSCP_DARK_2X2_COM_STATE (0x72u) +#define TSCP_DARK_2X2_FOLLOW_STATE (0x73u) +#define TSCP_DARK_2X2_THREAD_SHOWTIME (0x74u) +#define TSCP_DARK_2X2_SYNC_TIME (0x75u) +#define TSCP_DARK_2X2_RCV_BASE_STATE (0x76u) +#define TSCP_DARK_2X2_RCV_APP_STATE (0x77u) +#define TSCP_DARK_2X2_RCV_CHECK_STATE (0x78u) +#define TSCP_DARK_2X2_RCV_INPUT_STATE (0x79u) +#define TSCP_DARK_2X2_BASE_FOLLOW_HANDLE (0x7Au) +#define TSCP_DARK_2X2_OUT_CHECK_FAIL (0x7Bu) +#define TSCP_DARK_2X2_APP_FOLLOW_HANDLE (0x7Cu) +#define TSCP_DARK_2X2_INPUT_SYNC_SIZE (0x7Du) +#define TSCP_DARK_2X2_APPSET_FOLLOW (0x7Eu) +#define TSCP_DARK_2X2_RCV_APP_STATE_CRC (0x7Fu) +/*分帧接收*/ +#define TSCP_DARK_SFM_2OO2FRAME (0x80u) +#define TSCP_DARK_SFM_2X2FRAME (0x81u) +/*警告标志定义*/ +#define TSCP_DARK_WARNING (0x1FFEu) +/** 初始化阶段标志 */ +typedef enum { + ENUM_ERROR = 0 , /**< 保留值,禁止使用 */ + ENUM_INIT_DRV , /**< 初始化 硬件*/ + ENUM_INIT_MAIN_QUEUE_NET , /**< 初始化 维护网*/ + ENUM_INIT_API_DATA , /**< 初始化 应用数据*/ + ENUM_INIT_CFG , /**< 初始化 配置文件*/ + ENUM_INIT_NETCARD , /**< 初始化 网卡ip*/ + ENUM_INIT_MAIN_NET , /**< 初始化 维护网*/ + ENUM_INIT_CFC , /**< 初始化 控制流*/ + ENUM_INIT_COM , /**< 初始化 串口422*/ + ENUM_INIT_MICROCYCLE , /**< 初始化 微周期*/ + ENUM_INIT_PRTCL_SFP , /**< 初始化 SFP协议*/ + ENUM_INIT_UPDATE_NET, /**< 初始化 远程部署与2取网络通信*/ + ENUM_INIT_2OO2_DATA , /**< 初始化 2取数据*/ + ENUM_INIT_NET , /**< 初始化 网络通信*/ + ENUM_INIT_SELFCHECK , /**< 初始化 自检*/ + ENUM_INIT_APP , /**< 初始化 应用*/ + ENUM_INIT_PRTCL_RSSP , /**< 初始化 外网协议*/ + ENUM_INIT_APP_CTRL , /**< 初始化 应用调度*/ + ENUM_INIT_2X2USART , /**< 初始化 2X串口接收开关*/ + ENUM_INIT_2OO2 , /**< 初始化 2取*/ + ENUM_INIT_2X2 , /**< 初始化 2X*/ + ENUM_INIT_OVER , /**< 初始化 结束*/ +} ENUM_INIT_STAGE_FLAG; +extern ENUM_INIT_STAGE_FLAG g_InitUpdateFlag; + +#define TSCP_DARK_INFO_ERR_TYPE (0x1fffu) /*暗文故障码 错误信息 类型*/ + +extern CM_UINT8 g_AutoRebootVersion[4];/*自动重启版本号*/ +/** +* @brief 设置初始化阶段标志 +* @param ENUM_INIT_STAGE_FLAG stage 设置初始化阶段 +*/ +void PFM_LOG_SET_INIT_STAGE(ENUM_INIT_STAGE_FLAG stage); +ENUM_INIT_STAGE_FLAG PFM_LOG_GET_INIT_STAGE(void); +/** +* @brief 设置暗文日志阶段参数 +* @param value 设置暗文日志阶段参数 取值范围:0~0xffff +*/ +void PFM_LOG_SET_STOPTIMER(CM_UINT16 value); + +/* 记录格式化字符串日志 */ + +#define FILENAME(name) ((NULL != strrchr(name, (CM_INT32)'/')) ? (strrchr(name, (CM_INT32)'/') + 1) : name) + +#define MSCP_LOG_MSG(fmt, ...) (MSCP_PFM_LOG_MSG(FILENAME(__FILE__),(CM_INT32)__LINE__,(fmt), ##__VA_ARGS__)) +#define MSCP_LOG_MSG_UTC(fmt, ...) (MSCP_PFM_LOG_MSG_UTC(__FILE__,__FUNCTION__,(CM_INT32)__LINE__,(fmt), ##__VA_ARGS__)) +/* 函数实现 */ +void MSCP_PFM_LOG_MSG(IN const CM_CHAR *filename, IN CM_INT32 line, IN const CM_CHAR* fmt, ...); + +/* 记录二进制日志 */ +#define MSCP_LOG_BIN(buf,len) (MSCP_PFM_LOG_BIN(__FILE__,__FUNCTION__,(CM_INT32)__LINE__,(buf),(len))) +/* 函数实现 */ +void MSCP_PFM_LOG_BIN(IN const CM_CHAR *filename, IN const CM_CHAR *func, IN CM_INT32 line, IN const CM_UINT8 *Buf, IN CM_UINT32 Len); + +/*获取自动重启次数*/ +CM_UINT8 MSCP_Get_AutoRbootCut(void); +/*重置自动重启次数*/ +CM_UINT8 MSCP_Reset_AutoRbootCut(CM_UINT8 Cut); +/** +* @brief 获取自动重启次数 +* @return 重启次数 取值范围:0~0xff +*/ +CM_UINT8 RM_Get_FaultRbootCut(void); +/** +* @brief 重置自动重启次数 +* @param Cut 重启次数 +*/ +void RM_Reset_FaultRbootCut(CM_UINT8 Cut); +/** +* @brief 上电读取和删除本地日志文件 +* @return 无 +*/ +void MSCP_Read_Del_Logfile(void); + +/* 打印数据和长度 */ +void MSCP_LOG_DATALEN(IN CM_UINT8 *Buf, IN CM_UINT32 Len, IN char *Annotation); +/** +* @brief 获取宕机标志位 +* @param 无 +* @return 宕机标志位状态 +*/ +CM_UINT8 PFM_LOG_GET_STOP_FLAG(void); + +void PFM_SendLastAssertLog(void); +CM_UINT32 *PFM_DarkLogGenerate(CM_UINT16 mode, CM_UINT16 fault, CM_UINT16 num); +#define DARK_FAULT_CODE_MERGE(Mode,faultCode,funNum) (PFM_DarkLogGenerate(Mode,faultCode,funNum)) +/***************************暗文日志故障码信息编码表****************************/ + + +/*******************模块编码*****************/ +#define NET_MODE (0x01u) /*网络模块*/ +#define RAW_MODE (0x02u) /*透传模块*/ +#define COM_MODE (0x03u) /*串口模块*/ +#define INIFILE_MODE (0x04u) /*配置文件读取模块*/ +#define TCP_MODE (0x05u) /*TCP模块*/ +#define UDP_MODE (0x06u) /*UDP模块*/ +#define QNX_DRV_MODE (0x07u) /*QNX驱动模块*/ +#define CFG_MODE (0x08u) /*配置文件管理模块*/ +#define CONTROL_FLOW_CHECK_MODE (0x09u) /*控制流状态监督*/ +#define CPU_CHECK_MODE (0x0Au) /*CPU自检模块*/ +#define CPU_USAGE_MODE (0x0Bu) /*CPU使用率模块*/ +#define FS_MODE (0x0Cu) /*FS文件模块*/ +#define IN_OUT_MODE (0x0Du) /*输入输出管理模块*/ +#define MEMORY_CHECK_MODE (0x0Eu) /*内存自检模块*/ +#define SELF_CHECK_MODE (0x0Fu) /*自检模块*/ +#define SFM_2oo2_MODE (0x10u) /*2oo2模块*/ +#define SFM_2x2_MODE (0x11u) /*2x2模块*/ +#define PACKAGE_MODE (0x12u) /*分帧协议模块*/ +#define PRTCL_MODE (0x13u) /*安全协议模块*/ +#define APP_API_MODE (0x14u) /*应用接口模块*/ +#define MAIN_MODE (0x15u) /*平台主函数模块*/ +#define TIME_MODE (0x16u) /*时钟相关模块*/ +#define LOG_MODE (0x17u) /*日志相关模块*/ +#define REMOTE_UPDATE (0x18u) /*维护软件升级模块*/ + +/*************模块内函数顺序编码*************/ + +#define DARK_FAULT_CODE_FUN_ORDER_1 (0x01u) +#define DARK_FAULT_CODE_FUN_ORDER_2 (0x02u) +#define DARK_FAULT_CODE_FUN_ORDER_3 (0x03u) +#define DARK_FAULT_CODE_FUN_ORDER_4 (0x04u) +#define DARK_FAULT_CODE_FUN_ORDER_5 (0x05u) +#define DARK_FAULT_CODE_FUN_ORDER_6 (0x06u) +#define DARK_FAULT_CODE_FUN_ORDER_7 (0x07u) +#define DARK_FAULT_CODE_FUN_ORDER_8 (0x08u) +#define DARK_FAULT_CODE_FUN_ORDER_9 (0x09u) +#define DARK_FAULT_CODE_FUN_ORDER_10 (0x0Au) +#define DARK_FAULT_CODE_FUN_ORDER_11 (0x0Bu) +#define DARK_FAULT_CODE_FUN_ORDER_12 (0x0Cu) +#define DARK_FAULT_CODE_FUN_ORDER_13 (0x0Du) +#define DARK_FAULT_CODE_FUN_ORDER_14 (0x0Eu) +#define DARK_FAULT_CODE_FUN_ORDER_15 (0x0Fu) +#define DARK_FAULT_CODE_FUN_ORDER_16 (0x10u) +#define DARK_FAULT_CODE_FUN_ORDER_17 (0x11u) +#define DARK_FAULT_CODE_FUN_ORDER_18 (0x12u) +#define DARK_FAULT_CODE_FUN_ORDER_19 (0x13u) +#define DARK_FAULT_CODE_FUN_ORDER_20 (0x14u) +#define DARK_FAULT_CODE_FUN_ORDER_21 (0x15u) +#define DARK_FAULT_CODE_FUN_ORDER_22 (0x16u) +#define DARK_FAULT_CODE_FUN_ORDER_23 (0x17u) +#define DARK_FAULT_CODE_FUN_ORDER_24 (0x18u) +#define DARK_FAULT_CODE_FUN_ORDER_25 (0x19u) +#define DARK_FAULT_CODE_FUN_ORDER_26 (0x1Au) +#define DARK_FAULT_CODE_FUN_ORDER_27 (0x1Bu) +#define DARK_FAULT_CODE_FUN_ORDER_28 (0x1Cu) +#define DARK_FAULT_CODE_FUN_ORDER_29 (0x1Du) +#define DARK_FAULT_CODE_FUN_ORDER_30 (0x1Eu) +#define DARK_FAULT_CODE_FUN_ORDER_31 (0x1Fu) +#define DARK_FAULT_CODE_FUN_ORDER_32 (0x20u) +#define DARK_FAULT_CODE_FUN_ORDER_33 (0x21u) +#define DARK_FAULT_CODE_FUN_ORDER_34 (0x22u) +#define DARK_FAULT_CODE_FUN_ORDER_35 (0x23u) +#define DARK_FAULT_CODE_FUN_ORDER_36 (0x24u) +#define DARK_FAULT_CODE_FUN_ORDER_37 (0x25u) +#define DARK_FAULT_CODE_FUN_ORDER_38 (0x26u) +#define DARK_FAULT_CODE_FUN_ORDER_39 (0x27u) +#define DARK_FAULT_CODE_FUN_ORDER_40 (0x28u) + + +/**************具体宕机原因编码(函数内的宕机顺序)***************/ +#define TSCP_DARK_ASSERT_1 (0x01u) +#define TSCP_DARK_ASSERT_2 (0x02u) +#define TSCP_DARK_ASSERT_3 (0x03u) +#define TSCP_DARK_ASSERT_4 (0x04u) +#define TSCP_DARK_ASSERT_5 (0x05u) +#define TSCP_DARK_ASSERT_6 (0x06u) +#define TSCP_DARK_ASSERT_7 (0x07u) +#define TSCP_DARK_ASSERT_8 (0x08u) +#define TSCP_DARK_ASSERT_9 (0x09u) +#define TSCP_DARK_ASSERT_10 (0x0Au) +#define TSCP_DARK_ASSERT_11 (0x0Bu) +#define TSCP_DARK_ASSERT_12 (0x0Cu) +#define TSCP_DARK_ASSERT_13 (0x0Du) +#define TSCP_DARK_ASSERT_14 (0x0Eu) +#define TSCP_DARK_ASSERT_15 (0x0Fu) +#define TSCP_DARK_ASSERT_16 (0x10u) +#define TSCP_DARK_ASSERT_17 (0x11u) +#define TSCP_DARK_ASSERT_18 (0x12u) +#define TSCP_DARK_ASSERT_19 (0x13u) +#define TSCP_DARK_ASSERT_20 (0x14u) +#define TSCP_DARK_ASSERT_21 (0x15u) +#define TSCP_DARK_ASSERT_22 (0x16u) +#define TSCP_DARK_ASSERT_23 (0x17u) +#define TSCP_DARK_ASSERT_24 (0x18u) +#define TSCP_DARK_ASSERT_25 (0x19u) +#define TSCP_DARK_ASSERT_26 (0x1Au) +#define TSCP_DARK_ASSERT_27 (0x1Bu) +#define TSCP_DARK_ASSERT_28 (0x1Cu) +#define TSCP_DARK_ASSERT_29 (0x1Du) +#define TSCP_DARK_ASSERT_30 (0x1Eu) +#define TSCP_DARK_ASSERT_31 (0x1Fu) +#define TSCP_DARK_ASSERT_32 (0x20u) +#define TSCP_DARK_ASSERT_33 (0x21u) +#define TSCP_DARK_ASSERT_34 (0x22u) +#define TSCP_DARK_ASSERT_35 (0x23u) +#define TSCP_DARK_ASSERT_36 (0x24u) +#define TSCP_DARK_ASSERT_37 (0x25u) +#define TSCP_DARK_ASSERT_38 (0x26u) +#define TSCP_DARK_ASSERT_39 (0x27u) +#define TSCP_DARK_ASSERT_40 (0x28u) +#define TSCP_DARK_ASSERT_41 (0x29u) + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_MemCheck.c b/TSCP/src/MSCP/PFM/PFM_MemCheck.c new file mode 100644 index 0000000..af8c681 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_MemCheck.c @@ -0,0 +1,29 @@ +/** +* @filename PFM_MemCheck.c +* @brief Platform Function Module:内存自检 +* @details +* 平台和应用的日志记录功能 +* @author GT-BU +* @date 2021.05.01 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.05.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_MemCheck.h" + +#ifdef QNX + +void PFM_MemTestInit(void) +{ +} + +#else + +#endif + + + diff --git a/TSCP/src/MSCP/PFM/PFM_MemCheck.h b/TSCP/src/MSCP/PFM/PFM_MemCheck.h new file mode 100644 index 0000000..0b105cf --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_MemCheck.h @@ -0,0 +1,16 @@ +#ifndef PFM_MEMCHECK_H +#define PEM_MEMCHECK_H +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void PFM_MemTestInit(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_MemoryCheck.c b/TSCP/src/MSCP/PFM/PFM_MemoryCheck.c new file mode 100644 index 0000000..b69f9bd --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_MemoryCheck.c @@ -0,0 +1,637 @@ +/* + * PFM_MemotyCheck.c + * + * Created on: 2021年9月29日 + * Author: fengr + */ + + + +#include "PFM_MemoryCheck.h" +#include "CM_Memory.h" +#include "CM_MultiThread.h" +#include "CM_Mutex.h" +#include "CM_Time.h" +#include "DFM_Time.h" +#include "CM_MD5.h" +#include "PFM_Cfg.h" +#include "CM_CRC32.h" +#include "PFM_Log.h" +/* 内存自检结构体 */ +typedef struct +{ + CM_UINT64 memCheckAddr;/*- 存储内存数据地址*/ + CM_UINT32 memCheckLen;/*- 存储内存数据长度*/ + MD5Context_T md5Str;/*- 周期分片校验的MD5结构体*/ + CM_UINT8 md5[16];/*- 存储初始比较时的校验码*/ + CM_UINT32 blocklen;/*- 分块校验数据长度*/ + CM_UINT32 blockcnt;/*- 分块数*/ + CM_UINT32 offset;/*- 当前待校验块索引*/ +}STRU_MEM_CHECKT; + +/* 内存自检控制结构体 */ +typedef struct +{ + STRU_MEM_CHECKT memCheckCtrl[1024];/*- 内存自检控制*/ + CM_UINT16 memCheckNum;/*- 内存自检控制总数量*/ + CM_UINT16 memi;/*- 内存自检控制当前位*/ + CM_UINT8 memInitFlag;/*- 内存自检是否处于初始化阶段标志位*/ +}STRU_MEM_CHECK_CTRL_T; + +static STRU_MEM_CHECK_CTRL_T s_MemCheckCtrl; + +/*定义分块自检长度*/ +#define MEM_BLOCK_LEN (32u) + + +void static s_MemSegRWTest(CM_UINT8 *pBottom, CM_UINT8 *pTop); +static ENUM_CM_RETURN s_Abraham_inc(IN CM_UINT8* pStart, IN CM_UINT8* pEnd, CM_UINT8 flagPre, CM_UINT8 flagNew); +static ENUM_CM_RETURN s_Abraham_dec(IN CM_UINT8* pStart, IN CM_UINT8* pEnd, CM_UINT8 flagPre, CM_UINT8 flagNew); +static ENUM_CM_RETURN s_Abraham_inc2(IN CM_UINT8* pStart, IN CM_UINT8* pEnd, CM_UINT8 flagPre, CM_UINT8 flagNew); +static ENUM_CM_RETURN s_Abraham_dec2(IN CM_UINT8* pStart, IN CM_UINT8* pEnd, CM_UINT8 flagPre, CM_UINT8 flagNew); +static void PFM_Mem_BlockCheck(STRU_MEM_CHECKT *pManage); +/** +* @brief 内存自检初始化 +* @details 注册平台需自检的关键变量 +*/ +void PFM_MemCheck_Init(void) +{ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + ret = CM_Memset(&s_MemCheckCtrl, 0u, sizeof(s_MemCheckCtrl), sizeof(s_MemCheckCtrl)); + CM_NM_ASSERT(ENUM_CM_TRUE == ret, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + s_MemCheckCtrl.memi = 0u; + s_MemCheckCtrl.memInitFlag = 0u; + PFM_MemCheck_Register((CM_UINT8 *)&g_PFM_Cfg, (CM_UINT32)sizeof(g_PFM_Cfg)); +} + +/** +* @brief 变量内存自检注册初始化 +* @param pMemAddr注册变量的首地址 +* dataLen 注册变量的大小 +*/ +void PFM_MemCheck_Register(CM_UINT8* pMemAddr,CM_UINT32 dataLen) +{ + /*- 入参是否非空*/ + if(NULL != pMemAddr) + { + /*- 记录需要校验的地址*/ /*TODO 需要验证在QNX下地址是否为32字节,可能会存在问题*/ + s_MemCheckCtrl.memCheckCtrl[s_MemCheckCtrl.memCheckNum].memCheckAddr = (CM_UINT64)pMemAddr; + /*- 记录需要校验数据的长度*/ + s_MemCheckCtrl.memCheckCtrl[s_MemCheckCtrl.memCheckNum].memCheckLen = dataLen; + /*- 设置分块大小*/ + s_MemCheckCtrl.memCheckCtrl[s_MemCheckCtrl.memCheckNum].blocklen = MEM_BLOCK_LEN; + /*- 计算分块数量*/ + s_MemCheckCtrl.memCheckCtrl[s_MemCheckCtrl.memCheckNum].blockcnt \ + = (dataLen + MEM_BLOCK_LEN - 1u)/MEM_BLOCK_LEN; + /*- 文件偏移量初始化*/ + s_MemCheckCtrl.memCheckCtrl[s_MemCheckCtrl.memCheckNum].offset = 0u; + + /* printf("0x%p \r\n",pMemAddr); */ + /* printf("0x%p \r\n",s_MemCheckCtrl.memCheckCtrl[s_MemCheckCtrl.memCheckNum].memCheckAddr); */ + /*- 记录器加一*/ + s_MemCheckCtrl.memCheckNum++; + + } + else + { + /*- 宕机处理*/ + CM_NM_ASSERT(0, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + } +} + + +/** +* @brief 分块计算MD5自检接口 +* @param pManage 自检管理结构体 +* @details +*/ +static void PFM_Mem_BlockCheck(STRU_MEM_CHECKT *pManage) +{ + /*- 变量初始化 */ + CM_UINT8 tmpBuf[MEM_BLOCK_LEN * 2u] = {0u}; + CM_UINT8 *pStaddr = NULL; + CM_UINT8 *pEndaddr = NULL; + CM_UINT32 destcrc = 0u; + CM_UINT32 srcCrc = 0u; + /*- 入参指针是否非空 */ + if(NULL != pManage) + { + /*- 分块计算,是否计算到了最后一块 */ + if(((pManage->offset + 1u) * pManage->blocklen) <= pManage->memCheckLen) + { + /*- 自检起始地址 */ + pStaddr = (CM_UINT8 *)(pManage->memCheckAddr + (pManage->offset * pManage->blocklen)) ; + + /*- 自检结束地址 */ + pEndaddr = (CM_UINT8 *)(pManage->memCheckAddr + (pManage->offset * pManage->blocklen) + pManage->blocklen - 1u) ; + + /*- 计算拷贝前的数据crc */ + srcCrc = CM_Crc32(pStaddr,pManage->blocklen); + + /*- 在检测前先拷贝数据到缓冲区 */ + (void)CM_Memcpy(tmpBuf, (CM_SIZE_T)(MEM_BLOCK_LEN * 2u), pStaddr, (CM_SIZE_T)pManage->blocklen); + + /*- 计算拷贝后的缓存区数据crc */ + destcrc = CM_Crc32(tmpBuf,pManage->blocklen); + /*- 检测拷贝前后crc是否相同 */ + CM_NM_ASSERT(destcrc == srcCrc,MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + /*- 内存自检 */ + s_MemSegRWTest(pStaddr , pEndaddr); + + /*- 检测后恢复缓冲区数据 */ + (void)CM_Memcpy(pStaddr, (CM_SIZE_T)pManage->blocklen, tmpBuf, (CM_SIZE_T)pManage->blocklen); + + /*- 恢复后计算crc */ + srcCrc = CM_Crc32(pStaddr,pManage->blocklen); + + /*- 检测恢复后,crc是否一致 */ + CM_NM_ASSERT(destcrc == srcCrc, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + + pManage->offset++; + } + else + { + /*- 自检起始地址 */ + pStaddr = (CM_UINT8 *)(pManage->memCheckAddr + (pManage->offset * pManage->blocklen)); + + /*- 自检结束地址,地址 -1 为32个数据 */ + pEndaddr = (CM_UINT8 *)(pManage->memCheckAddr + (pManage->offset * pManage->blocklen) + (pManage->memCheckLen - (pManage->blocklen * pManage->offset) - 1u)); + + /*- 计算拷贝前的数据crc */ + if(pManage->memCheckLen > (pManage->blocklen * pManage->offset)) + { + srcCrc = CM_Crc32(pStaddr,(pManage->memCheckLen - (pManage->blocklen * pManage->offset))); + } + else + { + MSCP_LOG_MSG("crc32 enter len is err = %d\n",pManage->memCheckLen - (pManage->blocklen * pManage->offset)); + } + + /*- 在检测前先拷贝数据到缓冲区 */ + (void)CM_Memcpy(tmpBuf, MEM_BLOCK_LEN * 2u, pStaddr, (pManage->memCheckLen - (pManage->blocklen * pManage->offset))); + + if(pManage->memCheckLen > (pManage->blocklen * pManage->offset)) + { + /*- 计算拷贝后的缓存区数据crc */ + destcrc = CM_Crc32(tmpBuf,(pManage->memCheckLen - (pManage->blocklen * pManage->offset))); + } + else + { + MSCP_LOG_MSG("crc32 enter len is err = %d\n",pManage->memCheckLen - (pManage->blocklen * pManage->offset)); + } + + /*- 检测拷贝前后crc是否相同 */ + CM_NM_ASSERT(destcrc == srcCrc, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + /*- 内存自检 */ + s_MemSegRWTest(pStaddr, pEndaddr); + + /*- 检测后恢复缓冲区数据 */ + (void)CM_Memcpy(pStaddr, (pManage->memCheckLen - (pManage->blocklen * pManage->offset)), tmpBuf, (pManage->memCheckLen - (pManage->blocklen * pManage->offset))); + + if(pManage->memCheckLen > (pManage->blocklen * pManage->offset)) + { + /*- 恢复后计算crc */ + srcCrc = CM_Crc32(pStaddr,(pManage->memCheckLen - (pManage->blocklen * pManage->offset))); + } + else + { + MSCP_LOG_MSG("crc32 enter len is err = %d\n",pManage->memCheckLen - (pManage->blocklen * pManage->offset)); + } + + /*- 检测恢复后,crc是否一致 */ + CM_NM_ASSERT(destcrc == srcCrc, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_4); + + pManage->offset++; + } + + /*- 是否全部自检完成 */ + if(pManage->offset == pManage->blockcnt) + { + /*- 自检完成,当前待校验索引块归0 */ + pManage->offset = 0u; + /*- 自检完成,检查下一块关键变量 */ + s_MemCheckCtrl.memi++; + } + else + { + /*- 未自检完成,返回成功 */ + } + + } + else + { + /*- 无需处理 */ + } + +} + +/** +* @brief +* @param pManage 自检管理结构体 +* @details +*/ +void PFM_MemCheck(void) +{ + /*- 变量初始化 */ + CM_UINT16 i = 0u; + CM_UINT16 j = 0u; + /*- 如果内存自检处于初始化阶段 */ + if(0u == s_MemCheckCtrl.memInitFlag) + { + /*- 循环检查每一个注册进来的地址 */ + for(i = 0u; i < s_MemCheckCtrl.memCheckNum; i++) + { + for(j = 0u; j < s_MemCheckCtrl.memCheckCtrl[i].blockcnt; j++) + { + PFM_Mem_BlockCheck(&s_MemCheckCtrl.memCheckCtrl[i]); + } + } + /*- 内存自检标志位置于周期阶段 */ + s_MemCheckCtrl.memInitFlag = 1u; + } + else + { + /*- 是否全部自检完成 */ + if(s_MemCheckCtrl.memi >= s_MemCheckCtrl.memCheckNum) + { + /*- 重置自检索引*/ + s_MemCheckCtrl.memi = 0u; + } + + /*- 按自检顺序分块自检*/ + PFM_Mem_BlockCheck(&s_MemCheckCtrl.memCheckCtrl[s_MemCheckCtrl.memi]); + } +} + +/* +* @brief Abraham算法内存段自检 +* @param pStart 起始地址(低地址) +* @param pEnd 终止地址(高地址) +* @details +* 注意内存地址必须是4字节对齐的 +*/ +void static s_MemSegRWTest(CM_UINT8 *pBottom, CM_UINT8 *pTop) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_ASSERT(pBottom <= pTop, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + CM_ASSERT(NULL != pBottom, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + CM_ASSERT(NULL != pTop, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + /*- 内存段初始化为全0 */ + rt = CM_Memset((void*)pBottom, (CM_UINT8)0u, (CM_SIZE_T)((pTop - pBottom) + 1), (CM_SIZE_T)((pTop - pBottom) + 1)); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_2 "提高代码执行效率" */ + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- Abraham算法 步骤1 */ + rt = s_Abraham_inc(pBottom, pTop, 0x00u, 0xFFu); + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- Abraham算法 步骤2 */ + rt = s_Abraham_inc(pBottom, pTop, 0xFFu, 0x00u); + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- Abraham算法 步骤3 */ + rt = s_Abraham_dec(pTop, pBottom, 0x00u, 0xFFu); + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- Abraham算法 步骤4 */ + rt = s_Abraham_dec(pTop, pBottom, 0xFFu, 0x00u); + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- Abraham算法 步骤5 */ + rt = s_Abraham_inc2(pBottom, pTop, 0x00u, 0xFFu); + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- Abraham算法 步骤6 */ + rt = s_Abraham_dec2(pTop, pBottom, 0x00u, 0xFFu); + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- 内存段初始化为全1 */ + rt = CM_Memset((void*)pBottom, (CM_UINT8)0xffu, (CM_SIZE_T)((pTop - pBottom) + 1), (CM_SIZE_T)((pTop - pBottom) + 1)); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_2 "提高代码执行效率" */ + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- Abraham算法 步骤7 */ + rt = s_Abraham_inc2(pBottom, pTop, 0xFFu, 0x00u); + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- Abraham算法 步骤8 */ + rt = s_Abraham_dec2(pTop, pBottom, 0xFFu, 0x00u); + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + /*- 内存段初始化为全0 */ + rt = CM_Memset((void*)pBottom, (CM_UINT8)0u, (CM_SIZE_T)((pTop - pBottom) + 1), (CM_SIZE_T)((pTop - pBottom) + 1)); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_2 "提高代码执行效率" */ + CM_ASSERT(ENUM_CM_TRUE == rt, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); +} + +/* +* @brief Abraham算法步骤12 +* @param pStart 起始地址(低地址) +* @param pEnd 终止地址(高地址) +* @return 检查结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 自底向上:检查内存单元是否与flagPre相等,然后将内存单元更新乘flagNew +* 自顶向下:检查内存单元是否与flagNew相等 +*/ +static ENUM_CM_RETURN s_Abraham_inc(IN CM_UINT8 *pStart, IN CM_UINT8 *pEnd, CM_UINT8 flagPre, CM_UINT8 flagNew) +{ + volatile CM_UINT8 * p = NULL; + CM_UINT32 val = 0u; + /*- 初始化为自检失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_ASSERT(pStart <= pEnd,MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + CM_ASSERT((CM_UINT64)pStart > 0u, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + CM_ASSERT((CM_UINT64)pEnd < CM_UINT64_MAX, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + + /*- 从低地址开始 | 遍历至高地址 | 检查下一内存单元 */ + for (p = pStart; p <= pEnd; ++p) /* parasoft-suppress MISRA2004-17_1 "提高代码执行效率" */ + { + /*- 读取内存单元 */ + val = *p; + /*- 内存数值是否与预期一致 */ + if (val == flagPre) + { + /*- 更新内存数值 */ + *p = flagNew; + } + else + { + MSCP_LOG_MSG("val 0x%x flagPre 0x%x \r\n",val,flagPre); + + /*- 退出循环 */ + break; + } + + } + /*- 自底向上的遍历是否成功 */ + if (p > pEnd) + { + /*- 从高地址开始 | 遍历至低地址 | 检查下一内存单元 */ + for (p = pEnd; p >= pStart; --p) /* parasoft-suppress MISRA2004-17_1 "提高代码执行效率" */ + { + /*- 读取内存单元 */ + val = *p; + /*- 内存数值是否与预期不一致 */ + if (val != flagNew) + { + MSCP_LOG_MSG("val 0x%x flagNew 0x%x \r\n",val,flagNew); + /*- 退出循环 */ + break; + } + else + { + /*- 无处理 */ + } + } + /*- 自顶向下的遍历是否成功 */ + if (p < pStart) + { + /*- 自检成功 */ + rt = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("error \r\n"); + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*- 返回自检结果 */ + return rt; +} + +/* +* @brief Abraham算法步骤34 +* @param pStart 起始地址(高地址) +* @param pEnd 终止地址(低地址) +* @return 检查结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 自底向上:检查内存单元是否与flagPre相等,然后将内存单元更新乘flagNew +* 自顶向下:检查内存单元是否与flagNew相等 +*/ +static ENUM_CM_RETURN s_Abraham_dec(IN CM_UINT8* pStart, IN CM_UINT8 *pEnd, CM_UINT8 flagPre, CM_UINT8 flagNew) +{ + volatile CM_UINT8* p = NULL; + CM_UINT32 val = 0u; + /*- 初始化为自检失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_ASSERT(pStart >= pEnd, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + CM_ASSERT((CM_UINT64)pStart < CM_UINT64_MAX, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + CM_ASSERT((CM_UINT64)pEnd > 0u, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + + /*- 从高地址开始 | 遍历至低地址 | 检查下一内存单元 */ + for (p = pStart; p >= pEnd; --p) /* parasoft-suppress MISRA2004-17_1 "提高代码执行效率" */ + { + /*- 读取内存单元 */ + val = *p; + /*- 内存数值是否与预期一致 */ + if (val == flagPre) + { + /*- 更新内存数值 */ + *p = flagNew; + } + else + { + /*- 退出循环 */ + break; + } + + } + /*- 自顶向下的遍历是否成功 */ + if (p < pEnd) + { + /*- 从低地址开始 | 遍历至高地址 | 检查下一内存单元 */ + for (p = pEnd; p <= pStart; ++p) /* parasoft-suppress MISRA2004-17_1 "提高代码执行效率" */ + { + /*- 读取内存单元 */ + val = *p; + /*- 内存数值是否与预期不一致 */ + if (val != flagNew) + { + /*- 退出循环 */ + break; + } + else + { + /*- 无处理 */ + } + } + /*- 自顶向下的遍历是否成功 */ + if (p > pStart) + { + /*- 自检成功 */ + rt = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("error \r\n"); + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*- 返回自检结果 */ + return rt; +} + + +/* +* @brief Abraham算法步骤57 +* @param pStart 起始地址(低地址) +* @param pEnd 终止地址(高地址) +* @return 检查结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 自底向上:检查内存单元是否为flagPre,然后将内存单元更新为flagNewk后恢复至flagPre +* 自顶向下:检查内存单元是否为flagPre +*/ +static ENUM_CM_RETURN s_Abraham_inc2(IN CM_UINT8* pStart, IN CM_UINT8* pEnd, CM_UINT8 flagPre, CM_UINT8 flagNew) +{ + volatile CM_UINT8* p = NULL; + CM_UINT32 val = 0u; + /*- 初始化为自检失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_ASSERT(pStart <= pEnd, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_7, DARK_FAULT_CODE_FUN_ORDER_1); + CM_ASSERT((CM_UINT64)pStart > 0u, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_7, DARK_FAULT_CODE_FUN_ORDER_1); + CM_ASSERT((CM_UINT64)pEnd < CM_UINT64_MAX, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_7, DARK_FAULT_CODE_FUN_ORDER_1); + + /*- 从低地址开始 | 遍历至高地址 | 检查下一内存单元 */ + for (p = pStart; p <= pEnd; ++p) /* parasoft-suppress MISRA2004-17_1 "提高代码执行效率" */ + { + /*- 读取内存单元 */ + val = *p; + /*- 内存数值是否与预期一致 */ + if (val == flagPre) + { + /*- 更新内存数值 */ + *p = flagNew; + *p = flagPre; + } + else + { + MSCP_LOG_MSG("val 0x%x 0x%x\r\n",val,flagPre); + /*- 退出循环 */ + break; + } + + } + /*- 自底向上的遍历是否成功 */ + if (p > pEnd) + { + /*- 从高地址开始 | 遍历至低地址 | 检查下一内存单元 */ + for (p = pEnd; p >= pStart; --p) /* parasoft-suppress MISRA2004-17_1 "提高代码执行效率" */ + { + /*- 读取内存单元 */ + val = *p; + /*- 内存数值是否与预期不一致 */ + if (val != flagPre) + { + MSCP_LOG_MSG("val 0x%x 0x%x\r\n",val,flagPre); + /*- 退出循环 */ + break; + } + else + { + /*- 无处理 */ + } + } + /*- 自顶向下的遍历是否成功 */ + if (p < pStart) + { + /*- 自检成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + MSCP_LOG_MSG("error 3\r\n"); + /*- 无处理 */ + } + /*- 返回自检结果 */ + return rt; +} + +/* +* @brief Abraham算法步骤68 +* @param pStart 起始地址(高地址) +* @param pEnd 终止地址(低地址) +* @return 检查结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +* @details +* 自顶向下:检查内存单元是否为flagPre,然后将内存单元更新为flagNew后恢复至flagPre +* 自底向上:检查内存单元是否为flagPre +*/ +static ENUM_CM_RETURN s_Abraham_dec2(IN CM_UINT8* pStart, IN CM_UINT8* pEnd, CM_UINT8 flagPre, CM_UINT8 flagNew) +{ + volatile CM_UINT8* p = NULL; + CM_UINT32 val = 0u; + /*- 初始化为自检失败 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + + CM_ASSERT(pStart >= pEnd, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1); + CM_ASSERT((CM_UINT64)pStart < CM_UINT64_MAX, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1); + CM_ASSERT((CM_UINT64)pEnd > 0u, MEMORY_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1); + + /*- 从高地址开始 | 遍历至低地址 | 检查下一内存单元 */ + for (p = pStart; p>= pEnd; --p) /* parasoft-suppress MISRA2004-17_1 "提高代码执行效率" */ + { + /*- 读取内存单元 */ + val = *p; + /*- 内存数值是否与预期一致 */ + if (val == flagPre) + { + /*- 更新内存数值 */ + *p = flagNew; + *p = flagPre; + } + else + { + /*- 退出循环 */ + break; + } + + } + /*- 自顶向下的遍历是否成功 */ + if (p < pEnd) + { + /*- 从低地址开始 | 遍历至高地址 | 检查下一内存单元 */ + for (p = pEnd; p <= pStart; ++p) /* parasoft-suppress MISRA2004-17_1 "提高代码执行效率" */ + { + /*- 读取内存单元 */ + val = *p; + /*- 内存数值是否与预期不一致 */ + if (val != flagPre) + { + /*- 退出循环 */ + break; + } + else + { + /*- 无处理 */ + } + } + /*- 自顶向下的遍历是否成功 */ + if (p > pStart) + { + /*- 自检成功 */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*- 返回自检结果 */ + return rt; +} + diff --git a/TSCP/src/MSCP/PFM/PFM_MemoryCheck.h b/TSCP/src/MSCP/PFM/PFM_MemoryCheck.h new file mode 100644 index 0000000..3444b00 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_MemoryCheck.h @@ -0,0 +1,27 @@ +/* + * PFM_MemoryCheck.h + * + * Created on: 2021年9月29日 + * Author: fengr + */ + +#ifndef PFM_MEMORYCHECK_H +#define PFM_MEMORYCHECK_H +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*内存自检初始化*/ +void PFM_MemCheck_Init(void); +/*内存自检*/ +void PFM_MemCheck(void); +/*内存自检注册*/ +void PFM_MemCheck_Register(CM_UINT8 *pMemAddr,CM_UINT32 dataLen); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_RemoteUpdate.c b/TSCP/src/MSCP/PFM/PFM_RemoteUpdate.c new file mode 100644 index 0000000..8c50285 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_RemoteUpdate.c @@ -0,0 +1,3007 @@ +/* +* @filename PFM_RemoteUpdate.c +* @brief Platform Function Module:远程部署、重启 +* @details +* +* @author GT-BU +* @date 2023.02.07 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2023.02.07 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_RemoteUpdate.h" +#include "PFM_InputOutput.h" +#include "SFM_Prtcl.h" +#include "SFM_2x2.h" +#include "SFM_2oo2.h" +#include "CM_Memory.h" +#include "CM_CRC32.h" +#include "CM_MD5.h" +#include "CM_Time.h" +#include "CM_Convert.h" +#include "PFM_Cfg.h" +#include "PFM_Log.h" +#include "PFM_SelfCheck.h" +#include "DFM_DRV.h" +#include "MSCP_APP_API.h" +#include "PFM_ControlFlowCheck.h" +#include "DFM_Time.h" + +#define WAIT_TIME_2S (2000u/g_PFM_Cfg.CYC_TIME + 1u) +#define WAIT_TIME_10S (10000u/g_PFM_Cfg.CYC_TIME + 1u) +#define WAIT_TIME_120S (120000u/g_PFM_Cfg.CYC_TIME + 1u) +CM_UINT16 g_Maintenance_Id = 0x00u;/* 维护终端内网id */ +CM_UINT8 g_RemoteUpdate_State = 0x00u;/* 远程部署过程状态 */ + +ENUM_BOARD_STATE_T g_boardState = ENUM_BOARDSTATE_ERROR; +/*应用设置临时状态*/ +ENUM_BOARD_STATE_T g_AppSetboardState = ENUM_BOARDSTATE_ERROR; +static CM_UINT32 s_packTimer = 0u; /**< 请求命令时间戳 */ +static CM_UINT32 s_packFirstSendTimer = 0u; /**< 第一次回复重启确认的周期号 */ +static CM_UINT32 s_packFirstRecvTimer = 0u; /**< 收到aid第一次回复重启确认的周期号 */ +static CM_UINT8 reboottype = 0u;/**< 重启请求命令 0x55:未更新重启 0xaa:升级重启 0xd1~d7:硬重启 */ +extern CM_UINT32 g_MSCP_SysCount; /**< 系统周期号 */ +static CM_UINT8 s_countres = 0u;/**重启确认报文回复次数计数 */ +static CM_UINT8 packAccredit = 2u; /**授权状态 (当变量置为0或者1,则需要处理远程重启请求报文)*/ +static CM_UINT8 reasonAuthorization = 0u; /*授权原因*/ +static CM_UINT8 s_HardReboottype = 0u;/**<0xd1~d7:硬重启 */ +static CM_UINT8 s_packHardAccredit = 2u; /**硬重启授权状态 (当变量置为0或者1,则需要处理远程重启请求报文)*/ +static CM_UINT8 s_reasonHardAuthorization = 0u; /*硬重启授权原因*/ + +static CM_UINT8 s_packSwitchAccredit = 2u; /**硬重启授权状态 (当变量置为0或者1,则需要处理远程重启请求报文)*/ +static CM_UINT8 s_switchAuthorization = 0u; /*硬重启授权原因*/ + +static CM_UINT32 s_WaitTime = 0u; /* 继电器输出等待时间 */ +static CM_UINT8 s_FaultRebootCut= 0u;/*故障重启次数*/ + +static CM_UINT8 g_iostate = 0u; +static CM_UINT8 s_switchRmFlag = 0xaa; +CM_UINT8 s_switch2xFlag = 0xaa; + +extern CM_INT32 g_PFM_Check; +/** 需应用注册的版本号 */ +extern STRU_APP_VERSON g_App_Verson; +/** 识别AB系通信需要计算的板卡通信状态(对系) */ +CM_UINT8 PFM_HardWareBoot_CheckSelf_Com(ENUM_BOARD_TYPE_T type); +/** 文件更新信息结构 */ +typedef struct +{ + CM_UINT16 FileNameLen; /**< 文件名长度 */ + CM_UINT8 FileName[FILE_NAME_MAX_LEN]; /**< 文件名 */ + CM_UINT8 md5[CM_MD5_SIZE_BYTE];/*- 存储初始比较时的校验码*/ +}STRU_FILE_UPDATE_CTRL_T; + +static STRU_FILE_UPDATE_CTRL_T s_FileUpdateSucess[FILE_MAX_QUANTITY];/*- 升级成功的文件*/ +static CM_UINT8 Filesum_check = 0u; /**< 已验证文件数量总和 */ +static CM_UINT8 Filesum_check_cur = 0u; /**< 本次已验证文件数量 */ +/*- 文件更新请求命令确认处理 */ +ENUM_CM_RETURN PFM_FileUpdate_Response(IN CM_UINT32 TimeStamp,IN CM_UINT8 State,IN CM_UINT8 Reason); + +/*- 文件上传完成验证命令确认处理 */ +ENUM_CM_RETURN PFM_FileVerity_Response(IN CM_UINT32 TimeStamp,IN STRU_FILE_UPDATE_CTRL_T FileUpdateMsg[],IN CM_UINT8 Quantity); + +/*- 远程重启命令处理 */ +static void PFM_DataReastart(void); + +/*- 远程重启命令接收处理 */ +static CM_UINT8 PFM_DataReastart_Recv(void); + +/*- 远程重启命令发送处理 */ +static void PFM_DataReastart_Send(void); + +/*- 远程重启命令二次确认发送处理 */ +static void PFM_DataReastart_SendTwo(void); + +/*- 删除文件 */ +static void PFM_RM_File(IN CM_UINT8 pathname[]); + +/*- 远程硬件重启命令接收处理 */ +static void PFM_Data_HardWareReastart(CM_UINT8* mData,CM_UINT32 dataOffset,CM_UINT16 packLen,CM_UINT8 packType); + +/*- 远程切系命令接收处理 */ +static void PFM_Data_RemoteSwitch(CM_UINT8* mData,CM_UINT32 dataOffset,CM_UINT16 packLen,CM_UINT8 packType); + +/*- 远程切系确认帧组包发送 */ +static void PFM_RemoteSwitch_Send(CM_UINT8 type,CM_UINT32 rcv_packTime,CM_UINT8 accredit,CM_UINT8 reason); + +/*- 硬件重启确认帧组包发送 */ +static void PFM_HardWareReastart_Send(CM_UINT8 type,CM_UINT32 rcv_packTime,CM_UINT8 accredit,CM_UINT8 reason); + +/*- 继电器检测 */ +static ENUM_HARDWARE_BOOT_SELFCHECK_T PFM_Realy_Check(ENUM_HARDWARE_BOOT_SELFCHECK_T s_selfcheck_state,CM_UINT32 s_OutPutTime, CM_UINT8 comResult); +/** +* @brief 获取故障重启次数 +* @return 重启次数 取值范围:0~0xff +*/ +CM_UINT8 RM_Get_FaultRbootCut(void) +{ + return s_FaultRebootCut; +} + +/** +* @brief 重置故障重启次数 +* @param Cut 重启次数 取值范围:0~0xff +* @return 无 +*/ +void RM_Reset_FaultRbootCut(CM_UINT8 Cut) +{ + /*- 设置重启参数 */ + s_FaultRebootCut = Cut; +} +/** +* @brief 检测SFTP服务是否开启 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_SftpIsOk(void ) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + FILE *fp=NULL; + CM_CHAR StrLine[128u] = {0}; /*每行最大读取的字符数*/ + CM_INT32 ret = -1; /*函数返回值*/ + /* 通过popen函数,管道方式执行命令 */ + fp = popen("pidin | grep sftp","r"); + if (NULL != fp) + { + /* 读取一行, */ + (void)fgets(StrLine,128,fp); + if (0u != strlen(StrLine)) + { + rt = ENUM_CM_TRUE; + } + else + { + rt = ENUM_CM_FALSE; + } + + /* 关闭文件指针 */ + ret = pclose(fp); + if(-1 == ret) + { + perror("pclose failed"); + rt = ENUM_CM_FALSE; + } + else + { + + } + } + else + { + perror("PFM_SftpIsOk popen call failed"); + (void)printf("popen errno=%d,%s\n",errno,strerror(errno)); + rt = ENUM_CM_FALSE; + } + return rt; +} + +/** +* @brief 通过路径查找文件 +* @param pathname[] 查找的绝对路径文件名 +* @param len 查找的文件名长度 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_FindFileByPath(IN CM_UINT8 pathname[], IN CM_UINT8 len) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_INT8 ret = -1;/* 临时函数返回值 */ + CM_UINT8 pathnametmp[FILE_NAME_MAX_LEN]={0u}; + + (void)strcat(pathnametmp,g_RMUP_Cfg.Start_Path); + (void)strcat(pathnametmp,"/Backup/"); + (void)strcat(pathnametmp,pathname); + ret = access(pathnametmp, 0); + if (0 == ret) + { + rt = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("PFM_FindFileByPath filename %s error!!!\n",pathnametmp); + } + return rt; +} + +/** +* @brief 删除文件 +* @param pathname[] 查找的绝对路径文件名 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +static void PFM_RM_File(IN CM_UINT8 pathname[]) +{ + CM_UINT8 pathnametmp[FILE_NAME_MAX_LEN]={0u}; + /*- 入参防空*/ + CM_ASSERT_MAINTAIN(pathname != NULL); + (void)strcat(pathnametmp,g_RMUP_Cfg.Start_Path); + (void)strcat(pathnametmp,"/Backup/"); + (void)strcat(pathnametmp,pathname); + MSCP_LOG_MSG("%s\r\n",pathnametmp); + + (void)remove(pathnametmp); +} + +/** +* @brief 计算MD5值 +* @param pathname[] 查找的绝对路径文件名 +* @param len 查找的文件名长度 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_MD5_Calc(IN CM_UINT8 pathname[], IN CM_UINT16 len,OUT CM_UINT8 Md5buf[]) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + + FILE *pfile = NULL; /* 文件指针 */ + CM_UINT64 fileSize = 0u; + MSCP_LOG_MSG("%s\r\n",pathname); + pfile = fopen(pathname, "r"); + if (NULL != pfile) + { + (void)fseek(pfile, (long int)0, SEEK_END); + /*- 获取文件长度*/ + fileSize = (CM_UINT64)ftell(pfile); + (void)fseek(pfile, 0, SEEK_SET); + /*- 读取文件*/ + if(0u == fread(fileBuf, (size_t)fileSize, 1u, pfile)) + { + MSCP_LOG_MSG("PFM_MD5_Calc fread error!!!\n"); + } + else + { + /*- 计算文件MD5*/ + (void)CM_MD5_Calc(fileBuf, (CM_UINT32)fileSize, Md5buf); + rt = ENUM_CM_TRUE; + } + } + else + { + MSCP_LOG_MSG("PFM_MD5_Calc fopen %s error!!!\n",pathname); + } + return rt; +} + +/** +* @brief 远程部署透传报文发送 +* @param ResponseBuf 应答报文 +* @param ResponseBufLen 应答报文长度 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_InnetRemoteUpdate_Send(IN CM_UINT8 ResponseBuf[],IN CM_UINT16 ResponseBufLen) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + STRU_PFM_INNET_CFG_T* pCom = NULL;/* 通信配置 */ + + /*- 获取目的IP端口 */ + pCom = PFM_INI_InnetID2Addr(g_Maintenance_Id); + /*- 是否获取成功 */ + if ((NULL != ResponseBuf) && (NULL != pCom)) + { + /*- 本机是否为CPU1 */ + if (1u == g_RMUP_Cfg.CPU_ID) + { + /*- 从绿网通道发送 */ + (void)CFM_InnetRemoteUpdate_Send(ResponseBuf, (CM_INT32)CM_UNSIGNED_SHORT_EXP(ResponseBufLen), pCom->IP_G, pCom->Port_Raw_G); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + else + { + /*- 从紫网通道发送 */ + (void)CFM_InnetRemoteUpdate_Send(ResponseBuf, (CM_INT32)CM_UNSIGNED_SHORT_EXP(ResponseBufLen), pCom->IP_P, pCom->Port_Raw_P); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + rt = ENUM_CM_TRUE; + } + else + { + MSCP_LOG_MSG("PFM_InnetRemoteUpdate_Send PFM_INI_InnetID2Addr error!\n"); + } + + return rt; +} + +/** +* @brief 文件更新请求命令处理 +* @param RequestBuf[] 待处理数据帧 +* @param RequestLen 待处理数据帧长度 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_FileUpdate_Request(IN CM_UINT8 RequestBuf[],IN CM_UINT16 RequestLen,OUT CM_UINT8 *Result) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT16 framelen = 0u;/* 帧长度 */ + CM_UINT8 frametype = 0u; /* 帧类型 */ + CM_UINT8 updatetype = 0u; /* 部署方式 */ + CM_UINT8 s_Filesum = 0u; /**< 文件数量 */ + STRU_FILE_UPDATE_CTRL_T s_FileUpdateMsg[FILE_MAX_QUANTITY]; + CM_UINT32 timeStamp = 0u; /* 时间戳 */ + CM_UINT8 command = 0u; /* 文件更新请求命令 */ + CM_UINT32 crc = 0u; /* 文件更新请求报文CRC */ + CM_UINT32 crctmp = 0u; /* 计算文件更新请求报文CRC */ + CM_UINT16 index = 0u;/* 数组下标 */ + CM_UINT16 loop_index = 0u;/* 循环数组下标 */ + CM_UINT8 Authorization_Status = 0u; /* 授权状态 */ + CM_UINT8 Authorization_Reason = 0u; /* 授权原因 */ + + if (NULL != RequestBuf) + { + /*- 解析设备退出运营命令再次请求帧 */ + /* + 2字节 帧长度 + 1字节 帧类型 + 4字节 时间戳 + 1字节 部署方式 + 1字节 文件更新请求命令 + 1字节 文件数量 + 2字节 文件名长度 + n字节 文件名 + 16字节 文件md5值 + 4字节 CRC + */ + framelen = CM_ShortFromChar(&RequestBuf[index]); + index += 2u; + if (framelen != RequestLen - 2u) + { + MSCP_LOG_MSG("PFM_FileUpdate_Request framelen is error!!!\n"); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1)); + } + else + { + + } + frametype = RequestBuf[index]; + index += 1u; + timeStamp = CM_LongFromChar(&RequestBuf[index]); + index += 4u; + updatetype = RequestBuf[index]; + index += 1u; + command = RequestBuf[index]; + index += 1u; + s_Filesum = RequestBuf[index]; + index += 1u; + + if (s_Filesum > FILE_MAX_QUANTITY) + { + MSCP_LOG_MSG("File Quantity more than FILE_MAX_QUANTITY!\n"); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2)); + } + else + { + MSCP_LOG_MSG("Loop through parsing update file information\n"); + /*- 循环遍历解析更新文件信息 */ + for(loop_index = 0u; loop_index < s_Filesum ; loop_index++) + { + s_FileUpdateMsg[loop_index].FileNameLen = CM_ShortFromChar(&RequestBuf[index]); + index += 2u; + (void)CM_Memcpy(s_FileUpdateMsg[loop_index].FileName, FILE_NAME_MAX_LEN, &RequestBuf[index], s_FileUpdateMsg[loop_index].FileNameLen); + index += s_FileUpdateMsg[loop_index].FileNameLen; + + (void)CM_Memcpy(s_FileUpdateMsg[loop_index].md5, CM_MD5_SIZE_BYTE, &RequestBuf[index], CM_MD5_SIZE_BYTE); + index += CM_MD5_SIZE_BYTE; + } + } + + crc = CM_LongFromChar(&RequestBuf[index]); + index += 4u; + + if(framelen > 4u) + { + /*- 计算CRC */ + crctmp = CM_Crc32(&RequestBuf[2],framelen-4u); + } + else + { + MSCP_LOG_MSG("enter crc32 len is err = %d\n",framelen-4u); + } + + + /*- 判断sftp服务是否正常 */ + /*rt = PFM_SftpIsOk();*/ + rt = ENUM_CM_TRUE;/*默认开启-该功能预留*/ + /*- 文件更新请求命令CRC、命令、运行状态校验 */ + if ((ENUM_CM_TRUE !=rt ) || (crc != crctmp) || (0xaau != command)) + { + MSCP_LOG_MSG("p crc = %d,m crc = %d\n, rt = %d, command = %d\n", crc, crctmp, rt, command); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMREMOTEUPDATE_FILEUPDATEREQUEST1, 4, \ + sizeof(CM_UINT32),crc, + sizeof(CM_UINT32),crctmp, + sizeof(CM_UINT8),rt, + sizeof(CM_UINT8),command); + Authorization_Status = 0x01u;/* 禁止文件更新 */ + if(ENUM_CM_FALSE == rt) + { + Authorization_Reason = 0x02u;/* sftp未启动 */ + MSCP_LOG_MSG("Authorization_Reason = %x\n",Authorization_Reason); + } + else + { + Authorization_Reason = 0x01u;/* 合法性校验失败 */ + MSCP_LOG_MSG("Authorization_Reason = %x\n",Authorization_Reason); + } + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_PFMREMOTEUPDATE_FILEUPDATEREQUEST2, 1U, &Authorization_Reason); + MSCP_LOG_MSG("PFM_FileUpdate_Reponse Validity Check Error!!!\n"); + } + else + { + /*- 判断是否是可维护 */ + if ((ENUM_BOARDSTATE_EXIT == g_boardState) || (ENUM_BOARDSTATE_UPDATE == g_boardState)) + { + /*- 非运行状态 */ + Authorization_Status = 0x00u;/* 允许文件更新 */ + Authorization_Reason = 0x00u;/* 默认值 */ + *Result = 0x01u; + } + else + { + /*- 运行状态 */ + Authorization_Status =0x01u;/* 禁止文件更新 */ + Authorization_Reason = 0x03u;/* 原因:板卡状态异常 */ + } + } + /*- 文件更新请求命令确认处理 */ + rt = PFM_FileUpdate_Response(timeStamp,Authorization_Status,Authorization_Reason); + if (ENUM_CM_TRUE == rt) + { + /*- 成功无处理 */ + } + else + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("PFM_FileUpdate_Reponse fail!!!\n"); + } + } + else + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2)); + MSCP_LOG_MSG("RequestBuf is NULL!\n"); + } + return rt; +} + +/** +* @brief 文件更新请求命令确认处理 +* @param TimeStamp 请求报文时间戳 +* @param State 授权状态 +* @param Reason 授权原因 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_FileUpdate_Response(IN CM_UINT32 TimeStamp,IN CM_UINT8 State,IN CM_UINT8 Reason) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT32 crctmp = 0u; /* 计算文件更新请求报文CRC */ + CM_UINT8 ResponseBuf[1024] = { 0u }; /* 确认报文缓冲区 */ + CM_UINT16 index = 0u;/* 数组下标 */ + /*STRU_PFM_INNET_CFG_T* pCom = NULL;*//* 通信配置 */ + + /*- 打包文件更新请求确认帧 */ + /* + 2字节 帧长度 + 1字节 帧类型 + 4字节 时间戳 + 1字节 授权状态 + 1字节 授权原因 + 4字节 CRC + */ + CM_ShortToChar(11u, &ResponseBuf[index]); + index += 2u; + ResponseBuf[index] = 0x53u; + index += 1u; + CM_LongToChar(TimeStamp, &ResponseBuf[index]); + index +=4u; + ResponseBuf[index] = State; + index += 1u; + ResponseBuf[index] = Reason; + index += 1u; + + /*- 计算CRC */ + crctmp = CM_Crc32(&ResponseBuf[2],index-2u); + CM_LongToChar(crctmp, &ResponseBuf[index]); + index +=4u; + + /*- 文件更新请求确认帧发送 */ + rt = PFM_InnetRemoteUpdate_Send(ResponseBuf,index); + if (ENUM_CM_TRUE != rt) + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("PFM_FileUpdate_Response Call PFM_InnetRemoteUpdate_Send Error!!\n"); + } + else + { + /*- 成功无处理 */ + } + return rt; +} + +/** +* @brief 文件上传完成验证请求命令处理 +* @param RequestBuf[] 待处理数据帧 +* @param RequestLen 待处理数据帧长度 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_FileVerity_Request(IN CM_UINT8 RequestBuf[],IN CM_UINT16 RequestLen) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT16 framelen = 0u;/* 帧长度 */ + CM_UINT8 frametype = 0u; /* 帧类型 */ + CM_UINT8 updatetype = 0u; /* 部署方式 */ + CM_UINT8 s_Filesum = 0u; /**< 文件数量 */ + STRU_FILE_UPDATE_CTRL_T s_FileUpdateMsg[FILE_MAX_QUANTITY]; + CM_UINT32 timeStamp = 0u; /* 时间戳 */ + CM_UINT8 command = 0u; /* 文件更新请求命令 */ + CM_UINT32 crc = 0u; /* 文件更新请求报文CRC */ + CM_UINT32 crctmp = 0u; /* 计算文件更新请求报文CRC */ + CM_UINT16 index = 0u;/* 数组下标 */ + CM_UINT8 loop_index = 0u;/* 循环数组下标 */ + CM_UINT16 filemsg_index = 0u;/* 循环数组下标 */ + CM_UINT16 FileNameLen; /**< 文件名长度 */ + CM_UINT8 FileName[FILE_NAME_MAX_LEN]; /**< 文件名 */ + + if (NULL != RequestBuf) + { + /*- 解析文件上传完成验证请求帧 */ + /* + 2字节 帧长度 + 1字节 帧类型 + 4字节 时间戳 + 1字节 部署方式 + 1字节 上传完成验证请求命令 + 1字节 文件数量 + 2字节 文件名长度 + n字节 文件名 + 16字节 文件md5值 + 4字节 CRC + */ + framelen = CM_ShortFromChar(&RequestBuf[index]); + index += 2u; + frametype = RequestBuf[index]; + index += 1u; + timeStamp = CM_LongFromChar(&RequestBuf[index]); + index += 4u; + updatetype = RequestBuf[index]; + index += 1u; + command = RequestBuf[index]; + index += 1u; + s_Filesum = RequestBuf[index]; + index += 1u; + + if (s_Filesum > FILE_MAX_QUANTITY) + { + MSCP_LOG_MSG("File Quantity more than FILE_MAX_QUANTITY!\n"); + } + else + { + /*- 循环遍历解析更新文件信息 */ + for(filemsg_index = 0u; filemsg_index < s_Filesum ; filemsg_index++) + { + FileNameLen = CM_ShortFromChar(&RequestBuf[index]); + index += 2u; + (void)CM_Memcpy(FileName, FILE_NAME_MAX_LEN, &RequestBuf[index], FileNameLen); + index += FileNameLen; + + rt = PFM_FindFileByPath(FileName,FileNameLen); + if (ENUM_CM_TRUE != rt) + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("Find File %s error!\n",FileName); + } + else + { + s_FileUpdateMsg[loop_index].FileNameLen = FileNameLen; + (void)CM_Memcpy(s_FileUpdateMsg[loop_index].FileName, FILE_NAME_MAX_LEN, FileName, FileNameLen); + (void)CM_Memcpy(s_FileUpdateMsg[loop_index].md5, CM_MD5_SIZE_BYTE, &RequestBuf[index], CM_MD5_SIZE_BYTE); + loop_index++; + } + index += CM_MD5_SIZE_BYTE; + } + } + + crc = CM_LongFromChar(&RequestBuf[index]); + index += 4u; + + if(framelen > 4u) + { + /*- 计算CRC */ + crctmp = CM_Crc32(&RequestBuf[2],framelen-4u); + MSCP_LOG_MSG("crc = %u,crctmp=%u\n",crc,crctmp); + } + else + { + MSCP_LOG_MSG("crc32 len is err = %d\n", framelen-4u); + } + + + /*- 文件上传完成验证请求命令CRC、命令、运行状态、文件查找校验 */ + if ((crc != crctmp) || (0xaau != command)) + { + /* 合法性校验失败,丢弃处理 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2)); + MSCP_LOG_MSG("PFM_FileVerity_Request Validity check failure!!!\n"); + rt =ENUM_CM_FALSE; + } + else + { + /*- 文件上传完成验证命令确认处理 */ + rt = PFM_FileVerity_Response(timeStamp,s_FileUpdateMsg,loop_index); + if ((ENUM_CM_TRUE == rt) && (0u < Filesum_check_cur)) + { + /*- 成功无处理 */ + } + else + { + rt = ENUM_CM_FALSE; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_3)); + MSCP_LOG_MSG("PFM_FileVerity_Response fail!!!\n"); + } + } + } + else + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_4)); + MSCP_LOG_MSG("RequestBuf is NULL!\n"); + } + return rt; +} + +/** +* @brief 文件上传完成验证命令确认处理 +* @param FileUpdateMsg[] 文件验证信息数组 +* @param Quantity 文件验证信息数组元素数量 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_FileVerity_Response(IN CM_UINT32 TimeStamp,IN STRU_FILE_UPDATE_CTRL_T FileUpdateMsg[],IN CM_UINT8 Quantity) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + CM_UINT32 crctmp = 0u; /* 计算文件更新请求报文CRC */ + CM_UINT8 ResponseBuf[1024] = { 0u }; /* 确认报文缓冲区 */ + CM_UINT16 index = 0u;/* 发送数组下标 */ + CM_UINT8 loop_index = 0u;/* 循环数组下标 */ + CM_UINT8 md5buftmp[CM_MD5_SIZE_BYTE] = { 0u }; /* md5临时缓冲区 */ + CM_INT32 ret = 0; /* 返回值 */ + CM_UINT8 pathnametmp[FILE_NAME_MAX_LEN]={0u}; + CM_UINT8 i = 0u; + CM_UINT8 Filesum_index = 0u;/* 遍历结构体数组*/ + CM_UINT8 Filesum_flag = 0u;/*找到标志,找到相同文件名为1,没找到清0*/ + + /*- 文件上传验证确认帧 */ + /* + 2字节 帧长度 + 1字节 帧类型 + 4字节 时间戳 + 1字节 已验证文件数量 + 2字节 文件名长度 + n字节 文件名 + 16字节 文件md5值 + 4字节 CRC + */ + Filesum_check_cur = 0u; /**< 已验证文件数量 */ + + index += 2u; + ResponseBuf[index] = 0x54u; + index += 1u; + CM_LongToChar(TimeStamp, &ResponseBuf[index]); + index +=4u; + + index +=1u; + + /*- 计算md5 */ + for(loop_index = 0u;loop_index 写进协议 +* 注:此函数调用必须在周期主线程封装输出数据之前 +*/ +ENUM_CM_RETURN PFM_DevStateSend(CM_UINT8 ifCyc) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_INT32 rxLen = 0; + CM_UINT8 txBuf[1000] = {0u}; + CM_UINT8 rxBuf[1000] = {0u}; + CM_UINT16 dstName = 0u; + CM_UINT16 txLen = 0u; + CM_UINT8 m2x2State = 0u; + static CM_UINT32 DevStateSendIndex = 0u; + CM_UINT8 DrvBoardCpu_ID = 0U; /**< 板卡cpuID */ + CM_UINT32 crc; + CM_UINT16 offset = 0u; + CM_UINT16 fileNameLen = 20u; + CM_UINT16 fileMd5Len = 16u; + CM_UINT8 i = 0; + + MSCP_LOG_MSG("Maintenance Mode DevStateSendIndex = %d\n",DevStateSendIndex); + if((0x00u != g_Maintenance_Id) && (0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) && (0x55u == g_RMUP_Cfg.M_2oo2_Enable)) + { + /* 总长度(临时添加) */ + txLen = 0u; + CM_ShortToChar(txLen, &txBuf[offset]); + offset += 2u; + /* 帧类型 */ + txBuf[offset] = 0x50u; + offset += 1u; + /* 帧序号 */ + CM_LongToChar(DevStateSendIndex,&txBuf[offset]); + offset += 4u; + DevStateSendIndex++; + /* 设备类型、id */ + CM_ShortToChar(g_RMUP_Cfg.OUTNET_ID, &txBuf[offset]); + offset += 2u; + /* 本系热备状态 */ + m2x2State = SFM_2x2_GetLocal2x2State(); + txBuf[offset] = m2x2State; + offset += 1u; + /* 板卡类型(主机板\通控板\串口板) */ + txBuf[offset] = 1u; + offset += 1u; + /* cpuid */ + if(1u == g_RMUP_Cfg.BOARD_ID) + { + if(1u == g_RMUP_Cfg.CPU_ID) + { + DrvBoardCpu_ID = 0xA1u; + } + else + { + DrvBoardCpu_ID = 0xA2u; + } + } + else + { + if(1u == g_RMUP_Cfg.CPU_ID) + { + DrvBoardCpu_ID = 0xB1u; + } + else + { + DrvBoardCpu_ID = 0xB2u; + } + } + txBuf[offset] = DrvBoardCpu_ID; + offset += 1u; + /* 板卡状态 */ + txBuf[offset] = g_boardState; + offset += 1u; + /* 主机板版本数量 */ + txBuf[offset] = 3u + g_App_Verson.versonNumber; + offset += 1u; + /* 平台版本 */ + txBuf[offset] = 1u; + offset += 1u; + txBuf[offset] = MSCP_SW_VERION[0]; + offset += 1u; + txBuf[offset] = MSCP_SW_VERION[1]; + offset += 1u; + txBuf[offset] = MSCP_SW_VERION[2]; + offset += 1u; + txBuf[offset] = MSCP_SW_VERION[3]; + offset += 1u; + /* qnx版本 */ + txBuf[offset] = 2u; + offset += 1u; + txBuf[offset] = TSCP_QNX_VERION[0]; + offset += 1u; + txBuf[offset] = TSCP_QNX_VERION[1]; + offset += 1u; + txBuf[offset] = TSCP_QNX_VERION[2]; + offset += 1u; + txBuf[offset] = TSCP_QNX_VERION[3]; + offset += 1u; + /* 应用版本 数据版本 scard版本*/ + for(i = 0; i < 3; i++) + { + if(1 == g_App_Verson.registerVerson[i].flag) + { + txBuf[offset] = g_App_Verson.registerVerson[i].versonName + 2; + offset += 1u; + txBuf[offset] = g_App_Verson.registerVerson[i].verson[0]; + offset += 1u; + txBuf[offset] = g_App_Verson.registerVerson[i].verson[1]; + offset += 1u; + txBuf[offset] = g_App_Verson.registerVerson[i].verson[2]; + offset += 1u; + txBuf[offset] = g_App_Verson.registerVerson[i].verson[3]; + offset += 1u; + } + } + /* 驱动版本 */ + txBuf[offset] = 6u; + offset += 1u; + txBuf[offset] = MSCP_DRV_VERION[0]; + offset += 1u; + txBuf[offset] = MSCP_DRV_VERION[1]; + offset += 1u; + txBuf[offset] = MSCP_DRV_VERION[2]; + offset += 1u; + txBuf[offset] = MSCP_DRV_VERION[3]; + offset += 1u; + /* 主机板文件数量 app、main_base、fs */ + txBuf[offset] = 1u; + offset += 1u; + /* app文件 */ + CM_ShortToChar(fileNameLen, &txBuf[offset]); + offset += 2u; + (void)CM_Memcpy(&txBuf[offset],fileNameLen,g_RMUP_Cfg.APP_NAME,fileNameLen); + offset += fileNameLen; + (void)CM_Memcpy(&txBuf[offset],fileMd5Len,g_RMUP_Cfg.APP_MD5,fileMd5Len); + offset += fileMd5Len; + /* CRC(小crc从热备状态开始计算) */ + crc = CM_Crc32(&txBuf[9], offset-9u); + CM_LongToChar(crc, txBuf + offset); /*CRC*/ + offset += 4u; + /*- 2oo2交换输出校验帧 */ + if(1 == ifCyc) + { + rxLen = SFM_2oo2_Exchange_Currency(txBuf, offset, rxBuf, 1000u, ENUM_2oo2_OUTPUT_EX); + } + else + { + rxLen = SFM_2oo2_Exchange_FullDuplex_Crash(txBuf, offset, rxBuf, 1000u, ENUM_2oo2_OUTPUT_EX); + } + /*- 检查2oo2双机的输出校验帧是否一致 */ + CM_ASSERT_MAINTAIN(offset == rxLen); + /*- 设置设备id */ + dstName = g_Maintenance_Id; + if(1u == g_RMUP_Cfg.CPU_ID) + { + (void)CM_Memcpy(txBuf+offset,1000u-offset,rxBuf+3u,rxLen-3u); + /* 减去对方cpu的帧长度以及帧类型 */ + offset = offset*2u-3u; + /*- 计算整包数据crc(不包含长度) */ + crc = CM_Crc32(&txBuf[2], offset - 2u); + CM_LongToChar(crc, txBuf + offset); /*CRC*/ + offset += 4u; + /* 填入长度,总长是offset-自身2字节 */ + txLen = offset - 2u; + CM_ShortToChar(txLen, &txBuf[0]); + ret = Prtcl_InnetSafe_RmSend(dstName, txBuf, offset); + MSCP_LOG_MSG("offset = %d\n",offset); + } + else + { + (void)CM_Memcpy(rxBuf+rxLen,1000u-rxLen,txBuf+3u,offset-3u); + offset = offset*2u-3u; + /*- 计算整包数据crc(不包含长度) */ + crc = CM_Crc32(&rxBuf[2], offset - 2u); + CM_LongToChar(crc, rxBuf + offset); /*CRC*/ + offset += 4u; + /* 填入长度,总长是offset-自身2字节 */ + rxLen = offset - 2u; + CM_ShortToChar(rxLen, &rxBuf[0]); + ret = Prtcl_InnetSafe_RmSend(dstName, rxBuf, offset); + MSCP_LOG_MSG("offset = %d\n",offset); + } + } + else + { + /*- 无需处理*/ + MSCP_LOG_MSG("Unregistered application\n"); + } + + return ret; +} + +/** +* @brief 远程重启命令接收处理 +* @return 帧类型 +* - 0xa5首次重启请求 +* - 0xa6二次重启请求 +* - 0x00非法包 +*/ +static CM_UINT8 PFM_DataReastart_Recv(void) +{ + /*- 变量初始化 */ + CM_UINT8 mData[1000] = { 0u }; + CM_UINT8 pData[1000] = { 0u }; + CM_UINT32 dataLen = 0u; + CM_UINT16 pSrcLogicID = 0u; + CM_UINT8 pLifeTime = 0u; + CM_UINT32 dataOffset = 0u; + CM_UINT16 packLen = 0u; + CM_UINT8 packType = 0u; + CM_UINT32 packCrc = 0u; + CM_UINT32 calcCrc1 = 0u; + CM_UINT32 calcCrc2 = 0u; + CM_UINT8 packRestartMode = 0u; /*重启方式*/ + CM_UINT8 boardType = 0u; + CM_UINT8 boardId = 0u; + CM_UINT32 packRestartCrc = 0u; /*重启请求命令crc*/ + do + { + /*- 从内网安全协议读取应用接收报文 */ + dataLen = Prtcl_InnetSafe_PlatRmRecv(&pSrcLogicID, &pLifeTime, &mData[0], sizeof(mData)); + /*- 如果收到了数据 */ + if (0u < dataLen) + { + /*- 解包 */ + MSCP_LOG_MSG("PFM_DataProc_Crash dataLen = %d\n",dataLen); + MSCP_LOG_MSG("\n"); + for(int i = 0; i < dataLen; i++) + { + MSCP_LOG_MSG("0x%0.2x ",mData[i]); + } + MSCP_LOG_MSG("\n"); + packLen = CM_ShortFromChar(&mData[dataOffset]); + dataOffset += 2u; + packType = mData[dataOffset]; + dataOffset +=1u; + /*- 如果帧类型是一次请求确认 */ + if(0xa5 == packType) + { + /*- 按照一次请求确认帧继续解包 */ + boardType = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardType = %d\n",boardType); + boardId = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardId = %d\n",boardId); + s_packTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("s_packTimer = %d\n",s_packTimer); + packRestartMode = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("packRestartMode = %d\n",packRestartMode); + reboottype = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("reboottype = %d\n",reboottype); + packRestartCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc1 = CM_Crc32(&mData[3], 8u); + dataOffset+=4u; + packCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc2 = CM_Crc32(&mData[2], 13u); + dataOffset+=4u; + /*- crc以及重启方式是否正确 */ + if((packRestartCrc != calcCrc1) || (packCrc != calcCrc2)) + { + packAccredit = 1u; + reasonAuthorization = 1u; + MSCP_LOG_MSG("0xa5 illegality packRestartCrc=%d,calcCrc1=%d,packCrc=%d,calcCrc2=%d,reboottype=%d\n",packRestartCrc,calcCrc1,packCrc,calcCrc2,reboottype); + + } + else if((0x55u != reboottype) && (0xaau != reboottype)) + { + packAccredit = 1u; + reasonAuthorization = 6u; + MSCP_LOG_MSG("0xa5 illegality:6 reboottype=%d\n",reboottype); + } + else if((FAULT_REBOOT_CUT_MAX <= s_FaultRebootCut) && (0x55u == reboottype)) + { + /*- 远程-不更新重启-3次禁止故障重启*/ + packAccredit = 1u; + reasonAuthorization = 4u; + MSCP_LOG_MSG("0xa5 illegality:4 s_FaultRebootCut=%d\n",s_FaultRebootCut); + } + else + { + /*- 2oo2功能是否开启 */ + if (0x55u == g_RMUP_Cfg.M_2oo2_Enable) + { + /*- 2oo2 quit */ + (void)SFM_2oo2_Exchange_FullDuplex_Crash(&mData[0], 0, &pData[0], 0u, ENUM_2oo2_SHUTDOWNQUIT); + } + else + { + /*- 无处理 */ + } + packAccredit = 0u; + reasonAuthorization = 0u; + MSCP_LOG_MSG("0xa5 reboottype = %d\n",reboottype); + } + } + /*- 如果帧类型是二次请求确认 */ + else if(0xa6 == packType) + { + /*- 按照二次请求确认帧继续解包 */ + boardType = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardType = %d\n",boardType); + boardId = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardId = %d\n",boardId); + s_packTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("s_packTimer = %d\n",s_packTimer); + s_packFirstRecvTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("s_packFirstRecvTimer = %d\n",s_packFirstRecvTimer); + packRestartMode = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("packRestartMode = %d\n",packRestartMode); + reboottype = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("reboottype = %d\n",reboottype); + packRestartCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc1 = CM_Crc32(&mData[3], 12u); + dataOffset+=4u; + packCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc2 = CM_Crc32(&mData[2], 17); + dataOffset+=4u; + /*- crc以及重启方式是否正确并且一次回复到二次请求接收时间是否小于两分钟 */ + if((packRestartCrc != calcCrc1) || (packCrc != calcCrc2)) + { + /*- 非法包丢弃 */ + packAccredit = 1u; + reasonAuthorization = 1u; + MSCP_LOG_MSG("0xa6 error packRestartCrc=%d,calcCrc1=%d,packCrc=%d,calcCrc2=%d\n", \ + packRestartCrc,calcCrc1,packCrc,calcCrc2); + + } + else if((g_MSCP_SysCount - s_packFirstRecvTimer)*g_RMUP_Cfg.CYC_TIME >= 120000) + { + packAccredit = 1u; + reasonAuthorization = 7u; + MSCP_LOG_MSG("0xa6 error s_packFirstRecvTimer = %d, g_MSCP_SysCount = %d, cyctime = %d\n", \ + s_packFirstRecvTimer,g_MSCP_SysCount,g_RMUP_Cfg.CYC_TIME); + } + else if((0x55u != reboottype) && (0xaau != reboottype)) + { + packAccredit = 1u; + reasonAuthorization = 6u; + MSCP_LOG_MSG("0xa6 illegality:6 reboottype=%d\n",reboottype); + } + else if((FAULT_REBOOT_CUT_MAX <= s_FaultRebootCut) &&(0x55u == reboottype)) + { + /*- 远程-不更新重启-3次禁止故障重启*/ + packAccredit = 1u; + reasonAuthorization = 4u; + MSCP_LOG_MSG("0xa6 illegality:4 rebootcut=%d\n",s_FaultRebootCut); + } + else + { + /*- 2oo2功能是否开启 */ + if (0x55u == g_RMUP_Cfg.M_2oo2_Enable) + { + /*- 2oo2 quit */ + (void)SFM_2oo2_Exchange_FullDuplex_Crash(&mData[0], 0, &pData[0], 0u, ENUM_2oo2_SHUTDOWNQUIT); + } + else + { + /*- 无处理 */ + } + packAccredit = 0u; + reasonAuthorization = 0u; + MSCP_LOG_MSG("0xa6 reboottype = %d\n",reboottype); + } + } + else + { + /*- 非法包丢弃 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("error pack packType = %d\n",packType); + } + } + else + { + /*- 无处理 */ + } + }while(0u < dataLen); + + /*- 返回帧类型 */ + return packType; +} +/** +* @brief 远程重启一次确认帧组包发送 +*/ +static void PFM_DataReastart_Send(void) +{ + /*- 变量初始化 */ + CM_UINT8 mData[1000] = { 0u }; + CM_UINT32 dataOffset = 0u; + CM_UINT16 packLen = 0u; + CM_UINT32 calcCrc1 = 0u; + CM_UINT32 calcCrc2 = 0u; + CM_UINT8 boardType = 0u; + CM_UINT8 boardId = 0u; + /*- 是否允许重启,并且开启了2取功能 */ + if((0x55u == g_RMUP_Cfg.M_2oo2_Enable)&&(2u != packAccredit)) + { + + /*- 首次发送远程重启确认报文 */ + packAccredit = PFM_RmUp_Check(); + dataOffset = 0u; + /* 长度预留 */ + dataOffset += 2u; + mData[dataOffset] = 0x55u; + dataOffset += 1u; + + boardType = 1u; + mData[dataOffset] = boardType; + dataOffset += 1u; + if(1u == g_RMUP_Cfg.BOARD_ID) + { + boardId = 0xA0u; + } + else + { + boardId = 0x0Bu; + } + mData[dataOffset] = boardId; + dataOffset += 1u; + s_packFirstSendTimer = g_MSCP_SysCount; + CM_LongToChar(s_packFirstSendTimer, &mData[dataOffset]); + dataOffset += 4u; + CM_LongToChar(s_packTimer, &mData[dataOffset]); + dataOffset += 4u; + mData[dataOffset] = packAccredit; + dataOffset += 1u; + mData[dataOffset] = reasonAuthorization; + dataOffset += 1u; + calcCrc1 = CM_Crc32(&mData[3], dataOffset - 3u); + CM_LongToChar(calcCrc1, &mData[dataOffset]); + dataOffset += 4u; + + calcCrc2 = CM_Crc32(&mData[2], dataOffset - 2u); + CM_LongToChar(calcCrc2, &mData[dataOffset]); + dataOffset += 4u; + packLen = dataOffset - 2u; + CM_ShortToChar(packLen, &mData[0]); + /*- 发送远程重启确认报文 */ + MSCP_LOG_MSG("shut down dateOffset = %d, packLen = %d\n",dataOffset,packLen); + (void)Prtcl_InnetSafe_AppRmSend(mData, dataOffset); + } + else + { + /*- 无处理 */ + } +} + +/** +* @brief 远程重启二次确认帧组包发送 +*/ +static void PFM_DataReastart_SendTwo(void) +{ + /*- 变量初始化 */ + CM_UINT8 mData[1000] = { 0u }; + CM_UINT32 dataOffset = 0u; + CM_UINT16 packLen = 0u; + CM_UINT32 calcCrc1 = 0u; + CM_UINT32 calcCrc2 = 0u; + CM_UINT8 boardType = 0u; + CM_UINT8 boardId = 0u; + /*- 是否允许重启,并且开启了2取功能 */ + if((0x55u == g_RMUP_Cfg.M_2oo2_Enable)&&(2u != packAccredit)) + { + /*- @alias 首次发送远程重启确认报文 */ + if (0u == s_countres) + { + packAccredit = PFM_RmUp_Check(); + } + else + { + + } + + /*- 解包 */ + dataOffset = 0u; + /* 长度预留 */ + dataOffset += 2u; + mData[dataOffset] = 0x56u; + dataOffset += 1u; + boardType = 1u; + mData[dataOffset] = boardType; + dataOffset += 1u; + if(1u == g_RMUP_Cfg.BOARD_ID) + { + boardId = 0xA0u; + } + else + { + boardId = 0x0Bu; + } + mData[dataOffset] = boardId; + dataOffset += 1u; + CM_LongToChar(g_MSCP_SysCount, &mData[dataOffset]); + dataOffset += 4u; + CM_LongToChar(s_packTimer, &mData[dataOffset]); + dataOffset += 4u; + mData[dataOffset] = packAccredit; + dataOffset += 1u; + mData[dataOffset] = reasonAuthorization; + dataOffset += 1u; + calcCrc1 = CM_Crc32(&mData[3], dataOffset - 3u); + CM_LongToChar(calcCrc1, &mData[dataOffset]); + dataOffset += 4u; + /*- 用来记录远程重启时间 */ + s_countres++; + calcCrc2 = CM_Crc32(&mData[2], dataOffset - 2u); + CM_LongToChar(calcCrc2, &mData[dataOffset]); + dataOffset += 4u; + packLen = dataOffset - 2u; + CM_ShortToChar(packLen, &mData[0]); + /*- 发送远程重启确认报文 */ + MSCP_LOG_MSG("shut down dateOffset = %d, packLen = %d\n",dataOffset,packLen); + (void)Prtcl_InnetSafe_AppRmSend(mData, dataOffset); + } + else + { + /*- 无处理 */ + } +} + +/** +* @brief 远程重启处理 +*/ +static void PFM_DataReastart(void) +{ + /*- 变量初始化 */ + CM_UINT8 packType = 0u; + static CM_INT32 replycount = 0; + static CM_UINT8 flag = 0; + /*- 重启命令接收处理 */ + packType = PFM_DataReastart_Recv(); + /*- 一次重启命令发送处理 */ + if(0xa5 == packType) + { + PFM_DataReastart_Send(); + packType = 0u; + } + /*- 二次重启命令发送处理 */ + else if(0xa6 == packType) + { + PFM_DataReastart_SendTwo(); + replycount = 0; + flag = 1; + } + else + { + /*- 如果处理过一次二次重启确认,则在连续发送10次二次确认命令 */ + if((replycount < g_RMUP_Cfg.reboot_replycount) && (1 == flag)) + { + PFM_DataReastart_SendTwo(); + replycount++; + } + else + { + /*- 无处理 */ + flag = 0; + replycount = 0; + MSCP_LOG_MSG("No restart request was received\n"); + } + } +} + +/** +* @brief 输入数据处理(维护模式) +*/ +void PFM_DataProc_Crash(void) +{ + /*- 处理重启请求报文 */ + PFM_DataReastart(); + + /*- 发送设备信息报文(设备信息报文必须最后发送) */ + (void)PFM_DevStateSend(0); +} + +/** +* @brief 周期末处理(维护模式) +*/ +void PFM_EndProc_Crash(void) +{ + /*- 变量初始化 */ + CM_UINT8 mData[1024*100] = { 0u }; + CM_UINT8 pData[1024*100] = { 0u }; + + if (g_RMUP_Cfg.reboot_replycount == s_countres) + { + /*- 2oo2功能是否开启 */ + if (0x55u == g_RMUP_Cfg.M_2oo2_Enable) + { + /*- 2oo2 quit */ + (void)SFM_2oo2_Exchange_FullDuplex_Crash(&mData[0], 0, &pData[0], 0u, ENUM_2oo2_SHUTDOWNQUIT); + } + else + { + /*- 无处理 */ + } + PFM_RemoteUpdate_Reboot(); + } + else + { + /*- 无处理 */ + } + + SFM_LogRmInPrtcl(); +} + +/** +* @brief 退出运营模式,进入维护模式 +*/ +void PFM_MaintenanceMode(void) +{ + CM_UINT64 costlog[10] = {0}; + MSCP_LOG_MSG("g_MSCP_SysCount = %d\n",g_MSCP_SysCount); + /*- 系统周期号++,用来维持协议 */ + g_MSCP_SysCount++; + g_PFM_Check = PFM_CFC_PROC_NUM + 1; + /*- 输入 (进入运营模式,先输入在输出) */ + /*- 维护模式输入微周期处理 */ + costlog[0] = CM_GetTick(); + PFM_InputProc_Crash(); + costlog[1] = CM_GetTick(); + MSCP_LOG_MSG("1 PFM_InputProc_Crash cost = %lld us\n", (costlog[1] - costlog[0]) / 1000u); + g_PFM_Check = PFM_CFC_PROC_NUM + 5; + /*- 维护模式协议层解析 */ + SFM_UnPrtclProc_Crash(); + costlog[2] = CM_GetTick(); + MSCP_LOG_MSG("2 SFM_UnPrtclProc_Crash cost = %lld us\n", (costlog[2] - costlog[1]) / 1000u); + g_PFM_Check = PFM_CFC_PROC_NUM + 9; + /*- 数据处理 */ + PFM_DataProc_Crash(); + costlog[3] = CM_GetTick(); + MSCP_LOG_MSG("3 PFM_DataProc_Crash cost = %lld us\n", (costlog[3] - costlog[2]) / 1000u); + g_PFM_Check = PFM_CFC_PROC_NUM + 10; + /*- 维护模式协议层封装待发送数据 */ + SFM_EnPrtclProc_Crash(); + costlog[4] = CM_GetTick(); + MSCP_LOG_MSG("4 SFM_EnPrtclProc_Crash cost = %lld us\n", (costlog[4] - costlog[3]) / 1000u); + g_PFM_Check = PFM_CFC_PROC_NUM + 11; + /*- 维护模式输出微周期处理 */ + PFM_OutputProc_Crash(); + costlog[5] = CM_GetTick(); + MSCP_LOG_MSG("5 PFM_OutputProc_Crash cost = %lld us\n", (costlog[5] - costlog[4]) / 1000u); + g_PFM_Check = PFM_CFC_PROC_NUM + 12; + /*- 周期末处理*/ + PFM_EndProc_Crash(); + costlog[6] = CM_GetTick(); + MSCP_LOG_MSG("6 PFM_EndProc_Crash cost = %lld us\n", (costlog[6] - costlog[5]) / 1000u); + g_PFM_Check = PFM_CFC_PROC_NUM + 13; +} + +/** +* @brief 设置维护终端内网id +* @param dstName 维护终端内网id +*/ +void PFM_SetMaintenanceId(IN CM_UINT16 dstName ) +{ + /*- 变量初始化 */ + CM_INT32 i = 0; + CM_UINT8 FindFlag = 0u; + /*- 开始遍历内网通信配置:是否遍历完成:下一条配置 */ + for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++) + { + /*- 是否找到了目标内网ID */ + if (dstName == g_PFM_Cfg.INNET_COM_CFG[i].InnetID) + { + /*- 设置维护终端内网id */ + g_Maintenance_Id = dstName; + FindFlag = 1u; + /*- 返回 */ + break; + } + else + { + /*- 无处理 */ + } + } + + if (1u != FindFlag) + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("MSCP_SetMaintenanceId Error!!! dstName not find in INNET_COM_CFG InnetID\n",dstName); + } + else + { + + } +} +/** +* @brief 硬件重启确认帧组包发送 +* @param type 发送数据类型 取值范围:0x55或0x56 +* @param rcv_packTime 接收请求时间戳 取值范围:0~0xffffffff +* @param accredit 授权状态 取值范围:0~0xff +* @param reason 授权原因 取值范围:0~0xff +* @return 无 +*/ +static void PFM_HardWareReastart_Send(CM_UINT8 type,CM_UINT32 rcv_packTime,CM_UINT8 accredit,CM_UINT8 reason) +{ + /*- 变量初始化 */ + CM_UINT8 mData[1000] = { 0u }; + CM_UINT32 dataOffset = 0u; + CM_UINT16 packLen = 0u; + CM_UINT32 calcCrc1 = 0u; + CM_UINT32 calcCrc2 = 0u; + CM_UINT8 ret = 0u; + /*- 如果数据类型为0x55或0x56 */ + if(0x55u == type || 0x56u == type) + { + /* 长度预留 */ + dataOffset += 2u; + /*帧类型*/ + mData[dataOffset] = type; + dataOffset += 1u; + /*板卡类型主机板1*/ + mData[dataOffset] = 1u; + dataOffset += 1u; + /*通道ID*/ + if(1u == g_RMUP_Cfg.BOARD_ID) + { + mData[dataOffset] = 0xA0u; + } + else + { + mData[dataOffset] = 0x0Bu; + } + dataOffset += 1u; + /*重启请求命令首次确认时间*/ + s_packFirstSendTimer = g_MSCP_SysCount; + CM_LongToChar(s_packFirstSendTimer, &mData[dataOffset]); + dataOffset += 4u; + MSCP_LOG_MSG("s_packFirstSendTimer = %d\n",s_packFirstSendTimer); + /*收到的最近一次请求信息中的时间戳 */ + CM_LongToChar(rcv_packTime, &mData[dataOffset]); + dataOffset += 4u; + /*授权状态*/ + mData[dataOffset] = accredit; + dataOffset += 1u; + /*授权原因*/ + mData[dataOffset] = reason; + dataOffset += 1u; + /*CRC*/ + calcCrc1 = CM_Crc32(&mData[3], dataOffset - 3u); + CM_LongToChar(calcCrc1, &mData[dataOffset]); + dataOffset += 4u; + + calcCrc2 = CM_Crc32(&mData[2], dataOffset - 2u); + CM_LongToChar(calcCrc2, &mData[dataOffset]); + dataOffset += 4u; + packLen = dataOffset - 2u; + CM_ShortToChar(packLen, &mData[0]); + ret = Prtcl_InnetSafe_AppRmSend(mData,dataOffset); + if(ret == 0) + { + /*输出异常警告*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("IO OutPut Type 0x%x ERR!!!\n",type); + } + } + else + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_2)); + /*- 类型错误无处理*/ + } +} + +/** +* @brief 远程切系确认帧组包发送 +* @param type 发送数据类型 取值范围:0x55或0x56 +* @param rcv_packTime 接收请求时间戳 取值范围:0~0xffffffff +* @param accredit 授权状态 取值范围:0~0xff +* @param reason 授权原因 取值范围:0~0xff +* @return 无 +*/ +static void PFM_RemoteSwitch_Send(CM_UINT8 type,CM_UINT32 rcv_packTime,CM_UINT8 accredit,CM_UINT8 reason) +{ + /*- 变量初始化 */ + CM_UINT8 mData[1000] = { 0u }; + CM_UINT32 dataOffset = 0u; + CM_UINT16 packLen = 0u; + CM_UINT32 calcCrc1 = 0u; + CM_UINT32 calcCrc2 = 0u; + CM_UINT8 ret = 0u; + /*- 如果数据类型为0x57或0x58 */ + if(0x57u == type || 0x58u == type) + { + /* 长度预留 */ + dataOffset += 2u; + /*帧类型*/ + mData[dataOffset] = type; + dataOffset += 1u; + /*板卡类型主机板1*/ + mData[dataOffset] = 1u; + dataOffset += 1u; + /*通道ID*/ + if(1u == g_RMUP_Cfg.BOARD_ID) + { + mData[dataOffset] = 0xA0u; + } + else + { + mData[dataOffset] = 0x0Bu; + } + dataOffset += 1u; + /*重启请求命令首次确认时间*/ + s_packFirstSendTimer = g_MSCP_SysCount; + CM_LongToChar(s_packFirstSendTimer, &mData[dataOffset]); + dataOffset += 4u; + /*收到的最近一次请求信息中的时间戳 */ + CM_LongToChar(rcv_packTime, &mData[dataOffset]); + dataOffset += 4u; + /*授权状态*/ + mData[dataOffset] = accredit; + dataOffset += 1u; + /*授权原因*/ + mData[dataOffset] = reason; + dataOffset += 1u; + /*CRC*/ + calcCrc1 = CM_Crc32(&mData[3], dataOffset - 3u); + CM_LongToChar(calcCrc1, &mData[dataOffset]); + dataOffset += 4u; + + calcCrc2 = CM_Crc32(&mData[2], dataOffset - 2u); + CM_LongToChar(calcCrc2, &mData[dataOffset]); + dataOffset += 4u; + packLen = dataOffset - 2u; + CM_ShortToChar(packLen, &mData[0]); + ret = Prtcl_InnetSafe_AppRmSend(mData,dataOffset); + if(ret == 0) + { + /*输出异常警告*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("Switch OutPut Type 0x%x ERR!!!\n",type); + } + } + else + { + /*- 类型错误无处理*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_2)); + } +} + +/** +* @brief 远程硬件重启命令接收处理 +* @param *mData 接收原始数据 取值范围:非空 +* @param dataOffset 当前数据偏移量 取值范围:0~0xffffffff +* @param packLen 帧长度 取值范围:0~0xffff +* @param packType 帧类型 取值范围:0~0xff +*/ +static void PFM_Data_HardWareReastart(CM_UINT8* mData,CM_UINT32 dataOffset,CM_UINT16 packLen,CM_UINT8 packType) +{ + /*- 变量初始化 */ + CM_UINT32 packTimer = 0u; + CM_UINT32 packCrc = 0u; + CM_UINT32 calcCrc1 = 0u; + CM_UINT32 calcCrc2 = 0u; + CM_UINT8 packRestartMode = 0u; /*重启方式*/ + CM_UINT8 boardType = 0u; + CM_UINT8 boardId = 0u; + CM_UINT32 packRestartCrc = 0u; /*重启请求命令crc*/ + CM_UINT8 boottype = 0u;/**<临时 重启请求命令 0x55:未更新重启 0xaa:升级重启 0xd1~d7:硬重启 */ + static CM_UINT8 s_boottype = 0u;/**<静态 重启请求命令 0x55:未更新重启 0xaa:升级重启 ,0xd1~d7:硬重启 */ + CM_UINT8 recvType = 0u; + ENUM_2x2_STATE_T localState = SFM_2x2_GetLocal2x2State(); + /*- 如果帧类型是一次请求确认 */ + if(0xa5u == packType) + { + /*- 按照一次请求确认帧继续解包 */ + boardType = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardType = %d\n",boardType); + boardId = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardId = %d\n",boardId); + packTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("packTimer = %d\n",packTimer); + packRestartMode = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("packRestartMode = %d\n",packRestartMode); + boottype = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("boottype = %d\n",boottype); + packRestartCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc1 = CM_Crc32(&mData[3], 8u); + dataOffset+=4u; + packCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc2 = CM_Crc32(&mData[2], 13u); + dataOffset+=4u; + /*- crc以及重启方式是否正确 */ + if((packRestartCrc != calcCrc1) || (packCrc != calcCrc2)) + { + /*- 非法包丢弃 */ + s_boottype = 0u; + s_HardReboottype = 0u; + s_packHardAccredit = 1u; + s_reasonHardAuthorization = 1u; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_1)); + MSCP_LOG_MSG("error pack 0xa5 packRestartCrc=%d,calcCrc1=%d,packCrc=%d,calcCrc2=%d,reboottype=%d\n",packRestartCrc,calcCrc1,packCrc,calcCrc2,boottype); + } + else if((0x55 == s_switch2xFlag) || (0x55 == s_switchRmFlag) || (1 == g_iostate)) + { + /*- 非法包丢弃 */ + s_boottype = 0u; + /* s_HardReboottype = 0u; */ + s_packHardAccredit = 1u; + s_reasonHardAuthorization = 5u; + MSCP_LOG_MSG("error pack 0xa5,s_switch2xFlag=%d,s_switchRmFlag=%d,g_iostate=%d\n" \ + ,s_switch2xFlag,s_switchRmFlag,g_iostate); + } + else if(((boottype <= 0xd0u) || (boottype >= 0xd8u )) || \ + ((0xd3 == boottype) && (NULL == p_Serial_Id_Func))) + { + /*- 非法包丢弃 */ + s_boottype = 0u; + s_HardReboottype = 0u; + s_packHardAccredit = 1u; + s_reasonHardAuthorization = 6u; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_2)); + MSCP_LOG_MSG("error pack 0xa5 boottype=%d\n",boottype); + } + else if((ENUM_2x2_SLAVE == localState) && ((boottype == 0xd1) || (boottype == 0xd7))) + { + /*- 非法包丢弃 */ + s_boottype = 0u; + s_HardReboottype = 0u; + s_packHardAccredit = 1u; + s_reasonHardAuthorization = 7u; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_3)); + MSCP_LOG_MSG("error pack 0xa5 boottype=%d,localState=%d\n",boottype,localState); + } + else + { + s_boottype = boottype; + s_packHardAccredit = 0u; + s_reasonHardAuthorization = 0u; + MSCP_LOG_MSG("0xa5 boottype = %d\n",boottype); + } + /*首次应答*/ + recvType = 0x55u; + } + /*- 如果帧类型是二次请求确认 */ + else + { + /*- 按照二次请求确认帧继续解包 */ + boardType = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardType = %d\n",boardType); + boardId = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardId = %d\n",boardId); + packTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("packTimer = %d\n",packTimer); + s_packFirstRecvTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("s_packFirstRecvTimer = %d\n",s_packFirstRecvTimer); + packRestartMode = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("packRestartMode = %d\n",packRestartMode); + boottype = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("boottype = %d\n",boottype); + packRestartCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc1 = CM_Crc32(&mData[3], 12u); + dataOffset+=4u; + packCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc2 = CM_Crc32(&mData[2], 17u); + dataOffset+=4u; + /*- crc计算是否正确 */ + if((packRestartCrc != calcCrc1) || (packCrc != calcCrc2)) + { + /*- crc计算失败丢弃错误包 */ + s_boottype = 0u; + s_HardReboottype = 0u; + s_packHardAccredit = 1u; + s_reasonHardAuthorization = 1u; + MSCP_LOG_MSG("error pack 0xa6 packSwitchCrc=%d,calcCrc1=%d,packCrc=%d,calcCrc2=%d\n",packRestartCrc,calcCrc1,packCrc,calcCrc2); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_4)); + } + /*- 是否正在执行其它命令 */ + else if((0x55 == s_switch2xFlag) || (0x55 == s_switchRmFlag) || (1 == g_iostate)) + { + /*- 正在执行其它命令 */ + s_boottype = 0u; + /* s_HardReboottype = 0u; */ + s_packHardAccredit = 1u; + s_reasonHardAuthorization = 5u; + MSCP_LOG_MSG("error pack 0xa6,s_switch2xFlag=%d,s_switchRmFlag=%d,g_iostate=%d\n" \ + ,s_switch2xFlag,s_switchRmFlag,g_iostate); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_5)); + } + /*- 切系命令一次回复到二次请求接收时间是否小于两分钟 */ + else if(((g_MSCP_SysCount - s_packFirstRecvTimer)*g_RMUP_Cfg.CYC_TIME) >= 120000u) + { + s_boottype = 0u; + s_HardReboottype = 0u; + s_packHardAccredit = 1u; + s_reasonHardAuthorization = 7u; + MSCP_LOG_MSG("error pack 0xa6 g_MSCP_SysCount = %d s_packFirstRecvTimer = %d\n", g_MSCP_SysCount, s_packFirstRecvTimer); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_6)); + } + else if((boottype <= 0xd0u) || (boottype >= 0xd8u ) || (s_boottype != boottype)) + { + s_boottype = 0u; + s_HardReboottype = 0u; + s_packHardAccredit = 1u; + s_reasonHardAuthorization = 6u; + MSCP_LOG_MSG("error pack 0xa6 s_boottype = %d boottype = %d\n", s_boottype, boottype); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_7)); + } + else + { + s_HardReboottype = s_boottype; + s_packHardAccredit = 0u; + s_reasonHardAuthorization = 0u; + g_iostate = 0x1u; + MSCP_LOG_MSG("0xa6 boottype = %d, s_boottype = %d\n",boottype, s_boottype); + } + /*再次应答*/ + recvType = 0x56u; + } + + /*- 硬重启命令请求回复 */ + PFM_HardWareReastart_Send(recvType,packTimer,s_packHardAccredit,s_reasonHardAuthorization); +} + +/** +* @brief 远程切系命令接收处理 +* @param *mData 接收原始数据 取值范围:非空 +* @param dataOffset 当前数据偏移量 取值范围:0~0xffffffff +* @param packLen 帧长度 取值范围:0~0xffff +* @param packType 帧类型 取值范围:0~0xff +*/ +static void PFM_Data_RemoteSwitch(CM_UINT8* mData,CM_UINT32 dataOffset,CM_UINT16 packLen,CM_UINT8 packType) +{ + /*- 变量初始化 */ + CM_UINT32 packTimer = 0u; + CM_UINT32 packCrc = 0u; + CM_UINT32 calcCrc1 = 0u; + CM_UINT32 calcCrc2 = 0u; + CM_UINT8 packSwitchMode = 0u; /*切系方式*/ + CM_UINT8 boardType = 0u; + CM_UINT8 boardId = 0u; + CM_UINT32 packSwitchCrc = 0u; /*重启请求命令crc*/ + CM_UINT8 recvType = 0u; + ENUM_2x2_STATE_T localState = SFM_2x2_GetLocal2x2State(); + ENUM_2x2_STATE_T partnerState = SFM_2x2_GetPartner2x2State(); + static ENUM_2x2_STATE_T s_firstState = ENUM_2x2_SHUTDOWN; + + /*- 如果帧类型是一次请求确认 */ + if(0xa7u == packType) + { + /*- 按照一次请求确认帧继续解包 */ + boardType = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardType = %d\n",boardType); + boardId = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardId = %d\n",boardId); + packTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("packTimer = %d\n",packTimer); + packSwitchMode = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("packSwitchMode = %d\n",packSwitchMode); + /*- 预留1字节 */ + dataOffset+=1u; + packSwitchCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc1 = CM_Crc32(&mData[3], 8u); + dataOffset+=4u; + packCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc2 = CM_Crc32(&mData[2], 13u); + dataOffset+=4u; + /*- crc以及切换条件是否正确 */ + if((packSwitchCrc != calcCrc1) || (packCrc != calcCrc2)) + { + /*- crc计算失败丢弃错误包 */ + s_packSwitchAccredit = 1u; + s_switchAuthorization = 1u; + MSCP_LOG_MSG("error pack 0xa7 packSwitchCrc=%d,calcCrc1=%d,packCrc=%d,calcCrc2=%d\n",packSwitchCrc,calcCrc1,packCrc,calcCrc2); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_1)); + } + /*- 是否正在执行其它命令 */ + else if( (0x55 == s_switch2xFlag) || (0x55 == s_switchRmFlag) || (1 == g_iostate) || (1 == DFM_switchButton())) + { + /*- 正在执行其它命令 */ + s_packSwitchAccredit = 1u; + s_switchAuthorization = 3u; + MSCP_LOG_MSG("error pack 0xa7,s_switch2xFlag=%d,s_switchRmFlag=%d,g_iostate=%d\n" \ + ,s_switch2xFlag,s_switchRmFlag,g_iostate); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_2)); + } + else if(((localState + partnerState) != (ENUM_2x2_SLAVE + ENUM_2x2_MASTER)) || (1u == SFM_2x2_Get_LeastDoubleCom_State())) + { + /*- 切系状态未满足切系条件丢弃错误包 */ + s_packSwitchAccredit = 1u; + s_switchAuthorization = 2u; + MSCP_LOG_MSG("error pack 0xa7 localState = %d partnerState = %d\n", localState, partnerState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_3)); + } + else + { + s_packSwitchAccredit = 0u; + s_switchAuthorization = 0u; + s_firstState = SFM_2x2_GetLocal2x2State(); + } + /*首次应答*/ + recvType = 0x57u; + } + /*- 如果帧类型是二次请求确认 */ + else + { + /*- 按照二次请求确认帧继续解包 */ + boardType = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardType = %d\n",boardType); + boardId = mData[dataOffset]; + dataOffset +=1u; + MSCP_LOG_MSG("boardId = %d\n",boardId); + packTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("packTimer = %d\n",packTimer); + s_packFirstRecvTimer = CM_LongFromChar(&mData[dataOffset]); + dataOffset+=4u; + MSCP_LOG_MSG("s_packFirstRecvTimer = %d\n",s_packFirstRecvTimer); + packSwitchMode = mData[dataOffset]; + dataOffset+=1u; + MSCP_LOG_MSG("packSwitchMode = %d\n",packSwitchMode); + /*- 预留1字节 */ + dataOffset+=1u; + packSwitchCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc1 = CM_Crc32(&mData[3], 12u); + dataOffset+=4u; + packCrc = CM_LongFromChar(&mData[dataOffset]); + calcCrc2 = CM_Crc32(&mData[2], 17u); + dataOffset+=4u; + /*- crc计算是否正确 */ + if((packSwitchCrc != calcCrc1) || (packCrc != calcCrc2)) + { + /*- crc计算失败丢弃错误包 */ + s_packSwitchAccredit = 1u; + s_switchAuthorization = 1u; + MSCP_LOG_MSG("error pack 0xa8 packSwitchCrc=%d,calcCrc1=%d,packCrc=%d,calcCrc2=%d\n",packSwitchCrc,calcCrc1,packCrc,calcCrc2); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_4)); + } + /*- 是否正在执行其它命令 */ + else if((0x55 == s_switch2xFlag) || (0x55 == s_switchRmFlag) || (1 == g_iostate)|| (1 == DFM_switchButton())) + { + /*- 正在执行其它命令 */ + s_packSwitchAccredit = 1u; + s_switchAuthorization = 3u; + MSCP_LOG_MSG("error pack 0xa8,s_switch2xFlag=%d,s_switchRmFlag=%d,g_iostate=%d\n" \ + ,s_switch2xFlag,s_switchRmFlag,g_iostate); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_5)); + } + /*- 切系命令一次回复到二次请求接收时间是否小于两分钟 */ + else if(((g_MSCP_SysCount - s_packFirstRecvTimer)*g_RMUP_Cfg.CYC_TIME) >= 120000u) + { + /*- 切系状态未满足切系条件丢弃错误包 */ + s_packSwitchAccredit = 1u; + s_switchAuthorization = 4u; + MSCP_LOG_MSG("error pack 0xa8 g_MSCP_SysCount = %d s_packFirstRecvTimer = %d\n", g_MSCP_SysCount, s_packFirstRecvTimer); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_6)); + } + else if(s_firstState != localState) + { + /** + 一次请求 主备 同意 + 一次请求 主离线 主备状态不一致 返回失败 + 一次请求 刚切完系 离线 备 + 一次请求:无论如何 状态不一致不允许 + 二次请求 主备 因手动切系和一次请求时的主备状态不同。一次确认的时候主回失败,备回正确 (备回正确,兼容网络延迟导致的一次切系主先收到切系命令并且执行) + 二次请求 主离线 离线放,一次主回失败,一次时候得备回允许(兼容网络延迟 同上) + 二次请求 备离线 同上 + */ + if(ENUM_2x2_MASTER == s_firstState) + { + /*- 而此请求热备状态不一致 */ + s_packSwitchAccredit = 1u; + s_switchAuthorization = 5u; + MSCP_LOG_MSG("1error pack 0xa8 s_firstState = %d localState = %d\n", s_firstState, localState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_7)); + } + else + { + s_packSwitchAccredit = 0u; + s_switchAuthorization = 0u; + MSCP_LOG_MSG("2error pack 0xa8 s_firstState = %d localState = %d\n", s_firstState, localState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_8)); + } + } + /*- 切换条件是否正确 */ + else if(((localState + partnerState) != (ENUM_2x2_SLAVE + ENUM_2x2_MASTER)) || (1u == SFM_2x2_Get_LeastDoubleCom_State())) + { + /*- 切系状态未满足切系条件丢弃错误包 */ + s_packSwitchAccredit = 1u; + s_switchAuthorization = 2u; + MSCP_LOG_MSG("error pack 0xa8 localState = %d partnerState = %d\n", localState, partnerState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_9)); + } + else + { + /*- 二次至切系状态状态 */ + s_switchRmFlag = 0x55u; + s_packSwitchAccredit = 0u; + s_switchAuthorization = 0u; + } + /*再次应答*/ + recvType = 0x58u; + s_firstState = ENUM_2x2_SHUTDOWN; + } + /*- 切系命令请求回复 */ + PFM_RemoteSwitch_Send(recvType,packTimer,s_packSwitchAccredit,s_switchAuthorization); +} + + +/** +* @brief 远程硬件重启\切系命令接收处理 +* @param *mData 接收原始数据 取值范围:非空 +* @param dataLen 数据长度 取值范围:0~0xffffffff +* @return 帧类型 +* - 0xa5首次重启请求 +* - 0xa6二次重启请求 +* - 0xa7首次切系请求 +* - 0xa8二次切系请求 +*/ +CM_UINT8 PFM_RemoteRun_Data(CM_UINT8 *mData,CM_UINT32 dataLen) +{ + /*- 变量初始化 */ + CM_UINT32 dataOffset = 0u; + CM_UINT16 packLen = 0u; + CM_UINT8 packType = 0u; + /*- 如果收到了数据并且入参不为空 */ + if ((0u < dataLen) && (NULL != mData)) + { + /*- 解包 */ + MSCP_LOG_MSG("PFM_DataProc_Crash dataLen = %d\n",dataLen); + packLen = CM_ShortFromChar(&mData[0]); + dataOffset += 2u; + packType = mData[dataOffset]; + dataOffset +=1u; + /*- 如果在运行模式,进入硬件重启模式*/ + if(ENUM_BOARDSTATE_RUN == PFM_GetBoardState()) + { + if((0xA5u == packType) || (0xA6u == packType)) + { + PFM_Data_HardWareReastart(mData,dataOffset,packLen,packType); + } + else if((0xA7u == packType) || (0xA8u == packType)) + { + PFM_Data_RemoteSwitch(mData,dataOffset,packLen,packType); + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 非运行模式无处理 */ + } + } + else + { + /*- 无处理 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_15, TSCP_DARK_ASSERT_1)); + } + + /*- 返回帧类型 */ + return packType; +} + +/** +* @brief 硬件重启IO更新 +*/ +void PFM_HardWareBoot_UpData(void) +{ + /*- 更新板卡状态 */ + g_boardState = g_AppSetboardState; + /*- 更新硬重启模式 */ + reboottype = s_HardReboottype; + MSCP_LOG_MSG("reboottype = %d, s_HardReboottype = %d\n",reboottype,s_HardReboottype); + /*- 更新切系状态 */ + if(0x55 == s_switchRmFlag) + { + SFM_2x2_Enable_AIDSwitchStart(); + } + else + { + /*- 无处理 */ + } + s_switch2xFlag = SFM_2x2_Get_AIDSwitchStart(); + if(0u == s_HardReboottype) + { + g_iostate = 0u; + } + s_switchRmFlag = 0xaau; +} + +/** +* @brief 执行硬件重启IO输出 +* - 执行重启命令过程中禁止任何形式的切系 +*/ +void PFM_HardWareBoot_OutPut(void) +{ + /*- 变量初始化 */ + CM_INT32 ret = 0; + CM_UINT8 type = 0u; + static ENUM_HARDWARE_BOOT_SELFCHECK_T checkselfret = ENUM_RELAY_1ST_OUTPUT; + /*- 重启命令为硬重启命令 */ + if((0xd0u < reboottype) && (0xd8u > reboottype)) + { + type = reboottype; + /*- @alias 执行硬重启 */ + switch(type) + { + case 0xd1: + /*- 1100:PUB&IOB*/ + if(ENUM_2x2_MASTER == SFM_2x2_GetLocal2x2State()) + { + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 1\n"); + checkselfret = PFM_HardWareBoot_CheckSelf(0x0Cu,ENUM_TYPE_PUB,type); + } + else + { + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 2\n"); + checkselfret = ENUM_RELAY_1ST_OUTPUT; + MSCP_LOG_MSG("Is Not Master:0x%x,No Execute!!!\n",type); + } + break; + case 0xd2: + /*- 1010:CCU*/ + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 3\n"); + checkselfret = PFM_HardWareBoot_CheckSelf(0x0Au,ENUM_TYPE_CCU,type); + break; + case 0xd3: + /*- 0110:SEB*/ + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 4\n"); + checkselfret = PFM_HardWareBoot_CheckSelf(0x06u,ENUM_TYPE_SEB,type); + break; + case 0xd4: + /*- 1001:ESB*/ + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 5\n"); + checkselfret = PFM_HardWareBoot_CheckSelf(0x09u,ENUM_TYPE_ESB,type); + break; + case 0xd5: + /*- 0101:EEB*/ + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 6\n"); + checkselfret = PFM_HardWareBoot_CheckSelf(0x05u,ENUM_TYPE_OTHER,type); + break; + case 0xd6: + /*- 0011:OCIO预留,硬件不支持禁止打开*/ + /*ret = DFM_SetIO_OutPut(0x03);*/ + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 7\n"); + checkselfret = ENUM_RELAY_1ST_OUTPUT; + break; + case 0xd7: + /*- 1111:ALL*/ + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 8\n"); + if(ENUM_2x2_MASTER == SFM_2x2_GetLocal2x2State()) + { + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 9\n"); + checkselfret = PFM_HardWareBoot_CheckSelf(0x0Fu,ENUM_TYPE_ALL,type); + } + else + { + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 10\n"); + checkselfret = ENUM_RELAY_1ST_OUTPUT; + MSCP_LOG_MSG("Is Not Master:0x%x,No Execute!!!\n",type); + } + break; + default: + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 11\n"); + checkselfret = ENUM_RELAY_1ST_OUTPUT; + ret = -1; + break; + } + MSCP_LOG_MSG("IO OutPut Type 0x%x!!!\n",type); + if(ENUM_RELAY_1ST_OUTPUT == checkselfret) + { + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 12\n"); + /*- 恢复运营状态*/ + reboottype = 0u; + s_HardReboottype = 0u; + g_iostate = 0x0u; + } + } + else + { + MSCP_LOG_MSG("PFM_HardWareBoot_OutPut 13\n"); + } + if(ret != 0) + { + /*- 输出异常警告*/ + MSCP_LOG_MSG("IO OutPut Type 0x%x ERR!!!\n",type); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_16, TSCP_DARK_ASSERT_1)); + } +} + +/** +* @brief 硬重启自检状态机 +* @param level 待输出IO 取值范围:0x00~0x0F +* @param board_type 当前命令目标重启板卡类型 取值范围:1~5 +* @param reboottype 重启命令类型 取值范围:0xD1~0xD7 +* @return ENUM_HARDWARE_BOOT_SELFCHECK_T 当前检测步骤 取值范围:0~11 +*/ +ENUM_HARDWARE_BOOT_SELFCHECK_T PFM_HardWareBoot_CheckSelf(CM_UINT8 level,ENUM_BOARD_TYPE_T board_type,CM_UINT8 reboottype) +{ + /*- 变量初始化 */ + static ENUM_HARDWARE_BOOT_SELFCHECK_T s_selfcheck_state = ENUM_RELAY_1ST_OUTPUT; + static CM_UINT32 s_OutPutTime = 0u; /* 继电器输出时间 */ + static CM_UINT8 s_boot_result = 0xAAu;/* 重启结果 */ + static CM_UINT8 s_relay_default[4] = {0x55u,0x55u,0x55u,0x55u};/* 继电器故障记录 */ + static CM_UINT8 s_ComState[4] = {0u,0u,0u,0u};/* 继电器故障记录 */ + CM_UINT8 comResult = 0; + /*- 如果无需输出io */ + if(0u == level) + { + /*- 状态机恢复 */ + s_selfcheck_state = ENUM_RELAY_1ST_OUTPUT; + s_OutPutTime = 0u; + s_WaitTime = 0u; + s_boot_result = 0xAAu; + s_relay_default[0] = 0x55u; + s_relay_default[1] = 0x55u; + s_relay_default[2] = 0x55u; + s_relay_default[3] = 0x55u; + s_ComState[0] = 0u; + s_ComState[1] = 0u; + s_ComState[2] = 0u; + s_ComState[3] = 0u; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 1\n"); + } + else + { + /*- 根据执行步骤进行继电器自检 */ + switch (s_selfcheck_state) + { + /*- 判断第一个继电器是否需要检测 */ + case ENUM_RELAY_1ST_OUTPUT: + /*- 判断所有对系板卡通信状态并且记录*/ + s_ComState[0] = PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_PUB,s_ComState[0]); + s_ComState[1] = PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_CCU,s_ComState[1]); + s_ComState[2] = PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_SEB,s_ComState[2]); + s_ComState[3] = PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_ESB,s_ComState[3]); + /*- 如果第一个继电器需要自检 */ + if((1u == ((level>>3)&0x01))) + { + /*- 单步输出 */ + (void)DFM_SetIO_OutPut(0x08u); + /*- 记录输出时刻周期 */ + s_OutPutTime = DFM_GetBirthCount(); + /*- 记录等待时间*/ + s_WaitTime = WAIT_TIME_2S; + /*- 跳转第1继电器检测*/ + s_selfcheck_state = ENUM_RELAY_1ST_SELFCHECK; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 2\n"); + } + else + { + /*- 跳过检测-跳转第2继电器输出 */ + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 3\n"); + s_selfcheck_state = ENUM_RELAY_2ND_OUTPUT; + } + /*- 跳出 */ + break; + /*- 第1个继电器检测 */ + case ENUM_RELAY_1ST_SELFCHECK: + /*- @alias 通过与各板卡通信判断继电器故障(主机重启继电器2故障,CCU重启继电器3故障,交换机重启继电器4故障) */ + (1 == PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_PUB,s_ComState[0])) ? (s_relay_default[1] = 0xAA) : (s_relay_default[1] = 0x55); + (1 == PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_CCU,s_ComState[1])) ? (s_relay_default[2] = 0xAA) : (s_relay_default[2] = 0x55); + (1 == PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_ESB,s_ComState[3])) ? (s_relay_default[3] = 0xAA) : (s_relay_default[3] = 0x55); + comResult = s_relay_default[1] | s_relay_default[2] | s_relay_default[3]; + /*- 继电器检测 */ + s_selfcheck_state = PFM_Realy_Check(s_selfcheck_state, s_OutPutTime, comResult); + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 4\n"); + /*- 跳出 */ + break; + /*- 判断第二个继电器是否需要检测 */ + case ENUM_RELAY_2ND_OUTPUT: + /*- 如果第二个继电器需要自检 */ + if(1u == ((level>>2)&0x01)) + { + /*- 单步输出 */ + (void)DFM_SetIO_OutPut(0x04u); + /*- 记录输出时刻 */ + s_OutPutTime = DFM_GetBirthCount(); + /*- 记录等待时间 */ + s_WaitTime = WAIT_TIME_2S; + /*- 跳转第2继电器检测 */ + s_selfcheck_state = ENUM_RELAY_2ND_SELFCHECK; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 5\n"); + } + else + { + /*- 跳过检测-跳转第3继电器输出 */ + s_selfcheck_state = ENUM_RELAY_3RD_OUTPUT; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 6\n"); + } + /*- 跳出 */ + break; + /*- 第2个继电器检测 */ + case ENUM_RELAY_2ND_SELFCHECK: + /*- @alias 通过与各板卡通信判断继电器故障(主机重启继电器1故障,SEB重启继电器3故障) */ + (1 == PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_PUB,s_ComState[0])) ? (s_relay_default[0] = 0xAA) : (s_relay_default[0] = 0x55); + (1 == PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_SEB,s_ComState[2])) ? (s_relay_default[2] = 0xAA) : (s_relay_default[2] = 0x55); + comResult = s_relay_default[0] | s_relay_default[2]; + /*- 继电器检测 */ + s_selfcheck_state = PFM_Realy_Check(s_selfcheck_state, s_OutPutTime, comResult); + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 7\n"); + /*- 跳出 */ + break; + /*- 判断第三个继电器是否需要检测 */ + case ENUM_RELAY_3RD_OUTPUT: + /*- 如果第三个继电器需要自检 */ + if(1u == ((level>>1)&0x01)) + { + /*- 单步输出 */ + DFM_SetIO_OutPut(0x02u); + /*- 记录输出时刻s */ + s_OutPutTime = DFM_GetBirthCount(); + /*- 记录等待时间s */ + s_WaitTime = WAIT_TIME_2S; + /*- 跳转第3继电器检测 */ + s_selfcheck_state = ENUM_RELAY_3RD_SELFCHECK; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 8\n"); + } + else + { + /*- 跳过检测-跳转第3继电器输出 */ + s_selfcheck_state = ENUM_RELAY_4TH_OUTPUT; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 9\n"); + } + /*- 跳出 */ + break; + /*- 第3个继电器检测 */ + case ENUM_RELAY_3RD_SELFCHECK: + /*- @alias 通过与各板卡通信判断继电器故障(CCU重启继电器1故障,SEB重启继电器2故障) */ + (1 == PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_CCU,s_ComState[1])) ? (s_relay_default[0] = 0xAA) : (s_relay_default[0] = 0x55); + (1 == PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_SEB,s_ComState[2])) ? (s_relay_default[1] = 0xAA) : (s_relay_default[1] = 0x55); + comResult = s_relay_default[0] | s_relay_default[1]; + /*- 继电器检测 */ + s_selfcheck_state = PFM_Realy_Check(s_selfcheck_state, s_OutPutTime, comResult); + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 10\n"); + /*- 跳出 */ + break; + /*- 判断第四个继电器是否需要检测 */ + case ENUM_RELAY_4TH_OUTPUT: + /*- 如果第四个继电器需要自检 */ + if(1u == (level&0x01)) + { + /*- 单步输出 */ + (void)DFM_SetIO_OutPut(0x01u); + /*- 记录输出时刻s */ + s_OutPutTime = DFM_GetBirthCount(); + /*- 记录等待时间s */ + s_WaitTime = WAIT_TIME_2S; + /*- 跳转第4继电器检测 */ + s_selfcheck_state = ENUM_RELAY_4TH_SELFCHECK; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 11\n"); + } + else + { + /*- 跳过检测-跳转全部继电器输出 */ + s_selfcheck_state = ENUM_RELAY_ALL_OUTPUT; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 12\n"); + } + /*- 跳出 */ + break; + /*- 第4个继电器检测 */ + case ENUM_RELAY_4TH_SELFCHECK: + /*- 检测通信状态与2S检测时间,通信中断延长至10s */ + /*- 交换机重启-继电器1故障,EEB重启继电器2故障(无此板卡)*/ + (1 == PFM_HardWareBoot_CheckSelf_ComState(ENUM_TYPE_ESB,s_ComState[3])) ? (s_relay_default[0] = 0xAA) : (s_relay_default[0] = 0x55); + comResult = s_relay_default[0]; + /*- 继电器检测 */ + s_selfcheck_state = PFM_Realy_Check(s_selfcheck_state, s_OutPutTime, comResult); + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 13\n"); + /*- 跳出 */ + break; + /*- 执行硬重启 */ + case ENUM_RELAY_ALL_OUTPUT: + (void)DFM_SetIO_OutPut(level); + /*- 记录输出时刻s */ + s_OutPutTime = DFM_GetBirthCount(); + /*- 记录等待时间2s */ + s_WaitTime = WAIT_TIME_2S; + /*- 跳转硬重启检测 */ + s_selfcheck_state = ENUM_RELAY_BOOT_CHECK; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 14\n"); + /*- 跳出 */ + break; + /*- 检测硬重启结果,等待电源断开 */ + case ENUM_RELAY_BOOT_CHECK: + /*- 断电后没有通信 */ + comResult = PFM_HardWareBoot_CheckSelf_Com(board_type); + /*- 通信正常 */ + if((DFM_GetBirthCount()-s_OutPutTime) < s_WaitTime) + { + if(WAIT_TIME_2S == s_WaitTime) + { + /* continue */ + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 15\n"); + } + else + { + if(1u == comResult) + { + /*- 断开电源成功 */ + s_boot_result = 0x55u; + /*- 等待2min电源启动 */ + s_WaitTime = WAIT_TIME_120S; + s_selfcheck_state = ENUM_RELAY_BOOT_RESTART; + (void)DFM_SetIO_OutPut(0x00u); + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 16\n"); + } + else + { + /* continue */ + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 17\n"); + } + } + } + else + { + if(WAIT_TIME_2S == s_WaitTime) + { + s_WaitTime = WAIT_TIME_10S; + MSCP_LOG_MSG("PFM_Realy_Check 18\n"); + } + else + { + /*- 出现故障终止检测 */ + (1u == ((level>>3)&0x01)) ? (s_relay_default[0] = 0xAA) : (s_relay_default[0] = 0x55); + (1u == ((level>>2)&0x01)) ? (s_relay_default[1] = 0xAA) : (s_relay_default[1] = 0x55); + (1u == ((level>>1)&0x01)) ? (s_relay_default[2] = 0xAA) : (s_relay_default[2] = 0x55); + (1u == (level&0x01)) ? (s_relay_default[3] = 0xAA) : (s_relay_default[3] = 0x55); + s_boot_result = 0xAAu; + s_selfcheck_state = ENUM_OUTPUT_RESULT; + (void)DFM_SetIO_OutPut(0x00u); + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 19\n"); + } + } + + /*- 跳出 */ + break; + /*- 等待启动结果 */ + case ENUM_RELAY_BOOT_RESTART: + /*- 如果小于等待时间 */ + if((DFM_GetBirthCount()-s_OutPutTime) < s_WaitTime) + { + /*- 通信正常 */ + if(0u == PFM_HardWareBoot_CheckSelf_Com(board_type)) + { + /*- 发送重启结果组包数据 */ + s_boot_result = 0x55u; + s_selfcheck_state = ENUM_OUTPUT_RESULT; + } + else + { + /*- 无处理 */ + } + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 22\n"); + } + else + { + /*- 没有恢复通信失败 */ + s_boot_result = 0xAAu; + s_selfcheck_state = ENUM_OUTPUT_RESULT; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 23\n"); + } + /*- 跳出 */ + break; + /*- 反馈执行结果 */ + case ENUM_OUTPUT_RESULT: + /*- 发送结果至AID */ + MSCP_LOG_MSG("s_relay_default[0] = %d,s_relay_default[1] = %d,s_relay_default[2] = %d,s_relay_default[3] = %d\n",s_relay_default[0],s_relay_default[1],s_relay_default[2],s_relay_default[3]); + PFM_HardWareBoot_CheckSelf_Response(s_boot_result,s_relay_default,reboottype); + /*- 清空所有标志位 */ + s_selfcheck_state = ENUM_RELAY_1ST_OUTPUT; + s_OutPutTime = 0u; + s_WaitTime = 0u; + s_boot_result = 0xAAu; + s_relay_default[0] = 0x55u; + s_relay_default[1] = 0x55u; + s_relay_default[2] = 0x55u; + s_relay_default[3] = 0x55u; + s_ComState[0] = 0u; + s_ComState[1] = 0u; + s_ComState[2] = 0u; + s_ComState[3] = 0u; + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 24\n"); + break; + /*- 无 */ + default: + /*- 跳出 */ + break; + } + } + MSCP_LOG_MSG("PFM_HardWareBoot_CheckSelf 25\n"); + /*- 返回执行步骤 */ + return s_selfcheck_state; +} + +/** +* @brief 识别AB系通信需要计算的板卡通信状态(对系) +* @param type 当前判断板卡通信状态类型 取值范围:取值范围:1~5 +* @return 0是通信正常,1是通信中断 +*/ +CM_UINT8 PFM_HardWareBoot_CheckSelf_Com(ENUM_BOARD_TYPE_T type) +{ + /*- 变量初始化 */ + CM_UINT8 ret = 1u;/* 返回值 */ + CM_UINT8 RetState[4] = {0u,0u,0u,0u};/* 继电器故障记录 */ + /*- 判断板卡类型 */ + switch (type) + { + /*- 如果是主机板 */ + case ENUM_TYPE_PUB: + /*- 判断邻机主机是否通信中断 */ + ret = SFM_2x2_GetWithPeer_Com_State(); + /*- 跳出 */ + break; + /*- 如果是通控板 */ + case ENUM_TYPE_CCU: + /*- @alias 判断对系通控是否通信中断 */ + if(1u == g_RMUP_Cfg.BOARD_ID) + { + ret = ((g_Hardware_boot_com_state.SYS_Count - g_Hardware_boot_com_state.CCU_B_Count) > 0)?1u:0u; + } + else + { + ret = ((g_Hardware_boot_com_state.SYS_Count - g_Hardware_boot_com_state.CCU_A_Count) > 0)?1u:0u; + } + /*- 跳出 */ + break; + /*- 如果是串口板 */ + case ENUM_TYPE_SEB: + /*- @alias 判断对系串口板是否通信中断 */ + if(1u == g_RMUP_Cfg.BOARD_ID) + { + ret = ((g_Hardware_boot_com_state.SYS_Count - g_Hardware_boot_com_state.SEB_B_Count) > 0)?1u:0u; + } + else + { + ret = ((g_Hardware_boot_com_state.SYS_Count - g_Hardware_boot_com_state.SEB_A_Count) > 0)?1u:0u; + } + /*- 跳出 */ + break; + /*- 如果是交换机板 */ + case ENUM_TYPE_ESB: + /*- @alias 间接判断对系交换机是否通信中断 */ + if(1u == g_RMUP_Cfg.BOARD_ID) + { + /*- A系判断紫网B系交换机 */ + if(1u == g_RMUP_Cfg.CPU_ID) + { + ret = SFM_2x2_GetWithESB_Peer_Com_State(); + } + else + { + ret = SFM_2x2_GetWithESB_Mine_Com_State(); + } + } + else + { + if(1u == g_RMUP_Cfg.CPU_ID) + { + ret = SFM_2x2_GetWithESB_Mine_Com_State(); + } + else + { + ret = SFM_2x2_GetWithESB_Peer_Com_State(); + } + } + /*- 跳出 */ + break; + /*- 如果是所有板卡 */ + case ENUM_TYPE_ALL: + /*- @alias 判断所有板卡通信状态*/ + RetState[0] = PFM_HardWareBoot_CheckSelf_Com(ENUM_TYPE_PUB); + RetState[1] = PFM_HardWareBoot_CheckSelf_Com(ENUM_TYPE_CCU); + (NULL != p_Serial_Id_Func) ? (RetState[2] = PFM_HardWareBoot_CheckSelf_Com(ENUM_TYPE_SEB)) : (RetState[2] = 0); + RetState[3] = PFM_HardWareBoot_CheckSelf_Com(ENUM_TYPE_ESB); + MSCP_LOG_MSG("ENUM_TYPE_PUB = %d,ENUM_TYPE_CCU = %d,ENUM_TYPE_SEB = %d,ENUM_TYPE_ESB = %d\n"\ + ,RetState[0],RetState[1],RetState[2],RetState[3]); + if(RetState[0] || RetState[1] || RetState[2] || RetState[3]) + { + ret = 1u; + } + else + { + ret = 0u; + } + /*- 跳出 */ + + break; + default: + ret = 1u; + /*- 跳出 */ + break; + } + + /*- 返回检测结果 */ + return ret; +} + +/** +* @brief 识别AB系通信需要计算的板卡通信状态(对系) +* @param type 当前判断板卡通信状态类型 取值范围:1~5 +* @param s_ComState 0代表初始有通信,1代表初始没通信 +* @return 0是通信正常,1是通信中断 +*/ +CM_UINT8 PFM_HardWareBoot_CheckSelf_ComState(ENUM_BOARD_TYPE_T type, CM_UINT8 s_ComState) +{ + /*- 变量初始化 */ + CM_UINT8 ret = 1u; + /*- 如果初始有通信 */ + if(0 == s_ComState) + { + /*- 检测通信是否异常*/ + ret = PFM_HardWareBoot_CheckSelf_Com(type); + } + else + { + /*- 不检测 */ + ret = 0; + } + + /*- 返回通信结果 */ + return ret; +} +/** +* @brief 组包发送硬重启自检执行结果 +* @param boot_result 硬重启结果 取值范围:0x55成功,0xAA失败 +* @param *defaultbuf 继电器检测结果数组 取值范围:0x55成功,0xAA故障 +* @param reboottype 重启命令类型 取值范围:0xd1~0xd7 +* @return 无 +*/ +void PFM_HardWareBoot_CheckSelf_Response(CM_UINT8 boot_result,CM_UINT8 *defaultbuf,CM_UINT8 reboottype) +{ + /*- 变量初始化 */ + CM_UINT8 mData[1000] = { 0u }; + CM_UINT32 dataOffset = 2u;/*- 长度预留 */ + CM_UINT16 packLen = 0u; + CM_UINT32 calcCrc1 = 0u; + CM_UINT32 calcCrc2 = 0u; + CM_UINT8 ret = 0u; + /*- 入参指针是否不为空 */ + if(NULL != defaultbuf) + { + /*- @alias 组硬重启自检执行结果数据帧 */ + /* 帧类型 */ + mData[dataOffset++] = 0x59u; + /*- 板卡类型主机板1 */ + mData[dataOffset++] = 1u; + /* 通道ID */ + if(1u == g_RMUP_Cfg.BOARD_ID) + { + mData[dataOffset++] = 0xA0u; + } + else + { + mData[dataOffset++] = 0x0Bu; + } + /* 重启命令类型 */ + mData[dataOffset++] = reboottype; + /* 重启结果 */ + mData[dataOffset++] = boot_result; + /* 继电器检测状态 */ + mData[dataOffset++] = defaultbuf[0u]; + mData[dataOffset++] = defaultbuf[1u]; + mData[dataOffset++] = defaultbuf[2u]; + mData[dataOffset++] = defaultbuf[3u]; + /* 计算CRC*/ + calcCrc1 = CM_Crc32(&mData[3], dataOffset - 3u); + CM_LongToChar(calcCrc1, &mData[dataOffset]); + dataOffset += 4u; + + calcCrc2 = CM_Crc32(&mData[2], dataOffset - 2u); + CM_LongToChar(calcCrc2, &mData[dataOffset]); + dataOffset += 4u; + packLen = dataOffset - 2u; + CM_ShortToChar(packLen, &mData[0]); + ret = Prtcl_InnetSafe_AppRmSend(mData,dataOffset); + if(ret == 0) + { + /*- 输出异常警告 */ + MSCP_LOG_MSG("checkself_response 0x59 ERR!!!\n"); + } + } + else + { + /*- 类型错误无处理*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(REMOTE_UPDATE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_1)); + } +} + + +/** +* @brief 识别AB系通信需要计算的板卡通信状态 +* @param type 当前判断板卡通信状态类型 取值范围:0~3 0红通控 1蓝通控 2红串口 3蓝串口 +* @return 0是通信正常,1是通信中断 +*/ +CM_UINT8 PFM_CCUSEB_Comstate(CM_UINT8 type) +{ + CM_UINT8 ret = 1u;/*- 返回值 */ + switch (type) + { + case 0: + /*- 判断红通控是否通信中断 */ + ret = ((g_Hardware_boot_com_state.SYS_Count - g_Hardware_boot_com_state.CCU_A_Count) > 1)?1u:0u; + break; + case 1: + /*- 判断蓝通控是否通信中断 */ + ret = ((g_Hardware_boot_com_state.SYS_Count - g_Hardware_boot_com_state.CCU_B_Count) > 1)?1u:0u; + break; + case 2: + /*- 判断红串口是否通信中断 */ + ret = ((g_Hardware_boot_com_state.SYS_Count - g_Hardware_boot_com_state.SEB_A_Count) > 1)?1u:0u; + break; + case 3: + /*- 判断蓝串口是否通信中断 */ + ret = ((g_Hardware_boot_com_state.SYS_Count - g_Hardware_boot_com_state.SEB_B_Count) > 1)?1u:0u; + break; + default: + ret = 1u; + break; + } + + return ret; +} + +/** +* @brief 继电器检测 +* @param s_selfcheck_state 当前检测步骤 取值范围:0~11 +* @param s_OutPutTime 检测的开始时间 取值范围:0~0xffffffff +* @param comResult 板卡通信状况 取值范围:0x55,0xaa +* @return ENUM_HARDWARE_BOOT_SELFCHECK_T 当前检测步骤 取值范围:0~11 +*/ +static ENUM_HARDWARE_BOOT_SELFCHECK_T PFM_Realy_Check(ENUM_HARDWARE_BOOT_SELFCHECK_T s_selfcheck_state,CM_UINT32 s_OutPutTime, CM_UINT8 comResult) +{ + /*- 变量初始化 */ + CM_UINT32 birthCyc = DFM_GetBirthCount(); + /*- 通信正常 */ + if((birthCyc-s_OutPutTime) < s_WaitTime) + { + if(WAIT_TIME_2S == s_WaitTime) + { + /* continue */ + MSCP_LOG_MSG("PFM_Realy_Check 1\n"); + } + else + { + if(0x55u == comResult) + { + /*- 继续检测下一个继电器 */ + (void)DFM_SetIO_OutPut(0x00u); + s_selfcheck_state++; + MSCP_LOG_MSG("PFM_Realy_Check 2\n"); + } + else + { + /* continue */ + MSCP_LOG_MSG("PFM_Realy_Check 3\n"); + } + } + } + else + { + if(WAIT_TIME_2S == s_WaitTime) + { + s_WaitTime = WAIT_TIME_10S; + MSCP_LOG_MSG("PFM_Realy_Check 4\n"); + } + else + { + /*- 出现故障终止检测 */ + (void)DFM_SetIO_OutPut(0x00u); + s_selfcheck_state = ENUM_OUTPUT_RESULT; + MSCP_LOG_MSG("PFM_Realy_Check 5\n"); + } + } + + return s_selfcheck_state; +} diff --git a/TSCP/src/MSCP/PFM/PFM_RemoteUpdate.h b/TSCP/src/MSCP/PFM/PFM_RemoteUpdate.h new file mode 100644 index 0000000..e1c3446 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_RemoteUpdate.h @@ -0,0 +1,165 @@ +#ifndef PFM_REMOTEUPDATE_H +#define PFM_REMOTEUPDATE_H +#include "CM_Types.h" +#include "MSCP_APP_Interface.h" + +#ifdef __cplusplus +extern "C" +{ +#endif +#define FILE_NAME_MAX_LEN (128u) /*文件名最大长度*/ +#define FILE_MAX_QUANTITY (64u) /*文件最大数量*/ + +#define FAULT_REBOOT_CUT_MAX (3u) /*故障重启次数限制*/ + +extern CM_UINT16 g_Maintenance_Id;/* 维护终端内网id */ +extern CM_UINT8 g_RemoteUpdate_State;/* 远程部署过程状态 */ +extern CM_UINT8 s_switch2xFlag; + +typedef enum { + ENUM_TYPE_OTHER = 0,/*- 其他板卡 */ + ENUM_TYPE_PUB, /*- 主机板 */ + ENUM_TYPE_CCU, /*- 通控板 */ + ENUM_TYPE_SEB, /*- 串口板 */ + ENUM_TYPE_ESB, /*- 交换机 */ + ENUM_TYPE_ALL, /*- 全部板卡 */ +}ENUM_BOARD_TYPE_T; +/*- 硬重启自检状态机 */ +typedef enum { + ENUM_RELAY_1ST_OUTPUT = 0, /*- 第1个继电器输出 */ + ENUM_RELAY_1ST_SELFCHECK, /*- 第1个继电器检测 */ + ENUM_RELAY_2ND_OUTPUT, /*- 第2个继电器输出 */ + ENUM_RELAY_2ND_SELFCHECK, /*- 第2个继电器检测 */ + ENUM_RELAY_3RD_OUTPUT, /*- 第3个继电器输出 */ + ENUM_RELAY_3RD_SELFCHECK, /*- 第3个继电器检测 */ + ENUM_RELAY_4TH_OUTPUT, /*- 第4个继电器输出 */ + ENUM_RELAY_4TH_SELFCHECK, /*- 第4个继电器检测 */ + ENUM_RELAY_ALL_OUTPUT, /*- 全部待检测继电器输出 */ + ENUM_RELAY_BOOT_CHECK, /*- 检测硬重启结果 */ + ENUM_RELAY_BOOT_RESTART, /*- 硬重启恢复通信 */ + ENUM_OUTPUT_RESULT, /*- 反馈结果 */ +}ENUM_HARDWARE_BOOT_SELFCHECK_T; + + +/** +* @brief 文件更新请求命令处理 +* @param RequestBuf[] 待处理数据帧 +* @param RequestLen 待处理数据帧长度 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_FileUpdate_Request(IN CM_UINT8 RequestBuf[],IN CM_UINT16 RequestLen,OUT CM_UINT8 *Result); + +/** +* @brief 文件上传完成验证请求命令处理 +* @param RequestBuf[] 待处理数据帧 +* @param RequestLen 待处理数据帧长度 +* @return 处理结果 +* - ENUM_CM_TRUE 成功 +* - ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN PFM_FileVerity_Request(IN CM_UINT8 RequestBuf[],IN CM_UINT16 RequestLen); + +/** +* @brief 周期将设备状态信息发送给部署工具客户端 +* @return 函数执行结果 +* - 0x55u成功 +* - 0xAAu失败 +* @note +* 周期将设备状态信息发送给部署工具客户端 +* 组数据->写进协议 +* 注:此函数调用必须在周期主线程封装输出数据之前 +*/ +ENUM_CM_RETURN PFM_DevStateSend(CM_UINT8 ifCyc); + +/** +* @brief 获取板卡运行状态 +* @return 板卡运行状态 +* - ENUM_BOARDSTATE_ERROR = 0, 未知状态 +* - ENUM_BOARDSTATE_RUN = 1, 运行状态 +* - ENUM_BOARDSTATE_EXIT = 2, 退出运营状态 +* - ENUM_BOARDSTATE_UPDATE = 3, 故障可更新文件状态 +* - ENUM_BOARDSTATE_DEFAULT = 4, 故障不可更新文件状态 +*/ +ENUM_BOARD_STATE_T PFM_GetBoardState(void); + +/** +* @brief 设置板卡运行状态 +* @param state 板卡运行状态 +* - ENUM_BOARDSTATE_ERROR = 0, 未知状态 +* - ENUM_BOARDSTATE_RUN = 1, 运行状态 +* - ENUM_BOARDSTATE_EXIT = 2, 退出运营状态 +* - ENUM_BOARDSTATE_UPDATE = 3, 故障可更新文件状态 +* - ENUM_BOARDSTATE_DEFAULT = 4, 故障不可更新文件状态 +*/ +void PFM_SetBoardState(ENUM_BOARD_STATE_T state); +/** +* @brief 应用设置板卡临时运行状态 +* @param state 板卡运行状态 +* - ENUM_BOARDSTATE_ERROR = 0, 未知状态 +* - ENUM_BOARDSTATE_RUN = 1, 运行状态 +* - ENUM_BOARDSTATE_EXIT = 2, 退出运营状态 +* - ENUM_BOARDSTATE_UPDATE = 3, 故障可更新文件状态 +* - ENUM_BOARDSTATE_DEFAULT = 4, 故障不可更新文件状态 +*/ +void PFM_SetBoardState_APP(ENUM_BOARD_STATE_T state); + +/** +* @brief 退出运营模式,进入维护模式 +*/ +void PFM_MaintenanceMode(void); + + +/** +* @brief 设置维护终端内网id +* @param dstName 维护终端内网id +*/ +void PFM_SetMaintenanceId(IN CM_UINT16 dstName); + +/** +* @brief 远程硬件重启\切系命令接收处理 +*/ +CM_UINT8 PFM_RemoteRun_Data(CM_UINT8 *mData,CM_UINT32 dataLen); +/*硬件重启IO更新*/ +void PFM_HardWareBoot_UpData(void); +/*执行硬件重启IO输出*/ +void PFM_HardWareBoot_OutPut(void); + +CM_UINT8 PFM_GetBoardRebootState(void); + +/** +* @brief 硬重启自检状态机 +* @param level 待输出IO 取值范围:0x00~0x0F +* @param board_type 当前命令目标重启板卡类型 取值范围:ENUM_BOARD_TYPE_T +* @param reboottype 重启命令类型 取值范围:0xD1~0xD7 +* @return ENUM_HARDWARE_BOOT_SELFCHECK_T 当前检测步骤 +*/ +ENUM_HARDWARE_BOOT_SELFCHECK_T PFM_HardWareBoot_CheckSelf(CM_UINT8 level,ENUM_BOARD_TYPE_T board_type,CM_UINT8 reboottype); +/** +* @brief 识别AB系通信需要计算的板卡通信状态(对系) +* @param type 当前判断板卡通信状态类型 取值范围:ENUM_BOARD_TYPE_T +* @param s_ComState 0代表初始有通信,1代表初始没通信 +* @return 0是通信正常,1是通信中断 +*/ +CM_UINT8 PFM_HardWareBoot_CheckSelf_ComState(ENUM_BOARD_TYPE_T type, CM_UINT8 s_ComState); + +/** +* @brief 组包发送硬重启自检与执行结果 +* @param boot_result 硬重启结果 取值范围:0x55成功,0xAA失败 +* @param *defaultbuf 继电器检测结果数组 取值范围:0x55成功,0xAA故障 +* @param reboottype 重启命令类型 取值范围:0xd1~0xd7 +* @return 无 +*/ +void PFM_HardWareBoot_CheckSelf_Response(CM_UINT8 boot_result,CM_UINT8 *defaultbuf,CM_UINT8 reboottype); + +/** +* @brief 识别AB系通信需要计算的板卡通信状态 +* @param type 当前判断板卡通信状态类型 取值范围:0~5, ch 通信通道 0红 1蓝 +* @return 0是通信正常,1是通信中断 +*/ +CM_UINT8 PFM_CCUSEB_Comstate(CM_UINT8 type); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/PFM/PFM_SelfCheck.c b/TSCP/src/MSCP/PFM/PFM_SelfCheck.c new file mode 100644 index 0000000..2de7219 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_SelfCheck.c @@ -0,0 +1,412 @@ +/** +* @filename PFM_SelfCheck.c +* @brief Platform Function Module:自检 +* @details +* @author GT-BU +* @date 2021.09.24 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.09.24 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "PFM_SelfCheck.h" +#include "DFM_Time.h" +#include "DFM_DRV.h" +#include "CM_IniFile.h" +#include "CM_MD5.h" +#include "CM_Memory.h" +#include "PFM_Cfg.h" +#include "PFM_Log.h" +#include "CM_Com.h" +#include "CM_CRC32.h" +#include "CM_Convert.h" +#include "CM_Time.h" +#include "CFM_Net.h" +/*定义温度最低值,此宏应该放在文件配置*/ +#define DFM_LOW_TMP ((CM_FLOAT32)(-40)) +/*定义温度最大值,此宏应该放在文件配置*/ +#define DFM_MAX_TMP ((CM_FLOAT32)(85)) + + +/*定义读取文件的buf大小*/ +#define FILEB_MAX_LEN (1024*1024*100u) /*100M*/ + +/*定义分块自检长度*/ +#define BLOCK_LEN (1024U) +/* 文件管理结构体 */ +typedef struct +{ + CM_CHAR fileName[1024];/*- 文件名*/ + CM_INT64 fileSize;/*- 文件大小*/ + MD5Context_T md5Str;/*- 周期分片校验的MD5结构体*/ + CM_UINT8 md5[16];/*- 存储初始比较时的校验码*/ + CM_UINT32 blocklen;/*- 分块校验数据长度*/ + CM_UINT32 blockcnt;/*- 分块数*/ + CM_UINT32 offset;/*- 当前待校验块索引*/ + FILE *file;/*- 文件指针*/ + CM_UINT8 initFalg ;/*初始化标志位*/ +}STRU_FILE_CTRL_T; + +static struct sigaction act; +/* 记录步骤 */ +extern CM_INT32 g_PFM_Check; +static CM_INT32 s_PFM_AppCheck; + +/*APP自检管理结构体*/ +static STRU_FILE_CTRL_T s_FileCtrl_APP; +/*读取文件buf 100M*/ +CM_UINT8 fileBuf[1024*1024*100]; + +/* 信号抓捕函数 */ +static void signal_handler(void); +/*文件自检初始化*/ +static void PFM_FileCheckInit(IN STRU_FILE_CTRL_T *pManage, IN CM_CHAR *pFileName, IN CM_UINT8 *pMd5, IN CM_UINT16 blockLen); +/*温度自检*/ +static void PFM_BoardTmpCheck(void); + +/** +* @brief 平台自检文件初始化 +*/ +void PFM_FileInit(void) +{ + PFM_FileCheckInit(&s_FileCtrl_APP, g_PFM_Cfg.APP_NAME, g_PFM_Cfg.APP_MD5 ,BLOCK_LEN); +} +/** +* @brief 指定文件初始化接口 +* @param pManage 自检管理结构体 +* @param pFileName 文件名 +* @param pMd5 文件MD5值 +* @param blockLen 分块的大小 +* @details +*/ +static void PFM_FileCheckInit(IN STRU_FILE_CTRL_T *pManage, IN CM_CHAR *pFileName, IN CM_UINT8 *pMd5, IN CM_UINT16 blockLen) +{ + CM_INT32 rtn = 0; + CM_UINT8 md5Buf[16u] = {0u}; + /*- 指针防空*/ + if((NULL != pManage)&&(NULL != pManage->md5)&& + (NULL != pManage->fileName)&&(NULL != pFileName)&&(NULL != pMd5)) + { + /*- 初始化Md5管理结构体*/ + (void)CM_MD5_Init(&pManage->md5Str); + /*- 拷贝文件名*/ + (void)strcpy(pManage->fileName,pFileName); + /*- 记录原始文件MD5*/ + (void)CM_Memcpy(pManage->md5,16u, pMd5,16u); + /*获取文件大小*/ + pManage->fileSize = CM_GetFileSize(pManage->fileName); + CM_ASSERT(((CM_INT64)0 != pManage->fileSize) && (pManage->fileSize < (CM_INT64)FILEB_MAX_LEN), SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + /*- 设置块大小*/ + pManage->blocklen = blockLen; + /*- 计算分块数量*/ + pManage->blockcnt = CM_UNSIGNED_INT_EXP(((CM_UINT32)pManage->fileSize + blockLen - 1U)/blockLen); + /*- 文件偏移量初始化*/ + pManage->offset = 0u; + /*- 读取文件*/ + rtn = CM_ReadFile(pManage->fileName, 0u , pManage->fileSize, fileBuf); + CM_ASSERT(rtn, SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + /*- 计算文件MD5*/ + (void)CM_MD5_Calc(fileBuf, (CM_UINT32)pManage->fileSize, md5Buf); + /*- 比较读取文件的md5和存储的md5是否相同*/ + rtn = CM_Memcmp(md5Buf,pManage->md5,16u); + MSCP_LOG_MSG("file name %s \r\n",pManage->fileName); + CM_ASSERT((CM_INT32)0 == rtn, SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + /*- 初始化文件操作为NULL*/ + pManage->file = fopen(pManage->fileName, "r"); + CM_ASSERT(NULL != pManage->file, SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_4); + (void)fclose(pManage->file); + /*- 将初始化设置为已经初始化*/ + pManage->initFalg = 1u; + } + else + { + /*- 无操作*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1)); + } +} + +/** +* @brief 设置板卡温度范围 +* @param MinTemperature 最低温度 +* @param MinTemperature 最高温度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败 +*/ +CM_UINT8 PFM_SetTemperature(CM_FLOAT32 MinTemperature , CM_FLOAT32 MaxTemperature) +{ + CM_UINT8 rt = 0u; + + if ((DFM_LOW_TMP < MinTemperature) && (DFM_MAX_TMP > MinTemperature) && \ + (DFM_LOW_TMP < MaxTemperature) && (DFM_MAX_TMP > MaxTemperature) && \ + (MinTemperature < MaxTemperature) &&(0u == gSetTempFlag)) + { + gMinTemperature = MinTemperature; + gMaxTemperature = MaxTemperature; + gSetTempFlag++; + rt = 1u; + MSCP_LOG_MSG("SetTemperature sucessful!! MinTemperature = %.2f,MaxTemperature = %.2f\n",MinTemperature,MaxTemperature); + } + else + { + rt = 0u; + MSCP_LOG_MSG("SetTemperature fail!! MinTemperature = %.2f,MaxTemperature = %.2f,gSetTempFlag = %u\n",MinTemperature,MaxTemperature,gSetTempFlag); + } + + return rt; +} + +/** +* @brief 板卡温度自检 +*/ +static void PFM_BoardTmpCheck(void) +{ + /*- 变量初始化 */ + CM_UINT8 state = 0xAAu; + static CM_UINT8 s_err_cut = 0u; + CM_FLOAT32 tmp = (CM_FLOAT32)0.0; + CM_INT32 tmpsend = 0; + CM_FLOAT64 iotmp = (CM_FLOAT64)0.0; + /*- 读取主机板表面温度 */ + tmp = DFM_Get_Tmp112(); + tmpsend = tmp * 1000; + MSCP_LOG_MSG("tmp %lf \r\n",tmp); + MSCP_LOG_MSG("tmp %d \r\n",tmpsend); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_TMP, 4u, &tmpsend); + if(1u == gSetTempFlag) + { + if((tmp > gMinTemperature) && (tmp < gMaxTemperature)) + { + s_err_cut = 0u; + state = 0x55u; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_DRVINIT, 1u, &state); + } + else + { + s_err_cut++; + if(s_err_cut >= 3u) + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_DRVINIT, 1u, &state); + CM_ASSERT(0, SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_2); + } + else + { + MSCP_LOG_MSG("warning tmp1 %lf \r\n",tmp); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1)); + } + } + } + else + { + if((tmp > DFM_LOW_TMP) && (tmp < DFM_MAX_TMP)) + { + s_err_cut = 0u; + state = 0x55u; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_DRVINIT, 1u, &state); + } + else + { + s_err_cut++; + if(s_err_cut >= 3u) + { + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_DRVINIT, 1u, &state); + CM_ASSERT(0, SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_4); + } + else + { + MSCP_LOG_MSG("warning tmp2 %lf \r\n",tmp); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2)); + } + } + } + /*- 读取io板表面温度 (io板卡tmp只做读取操作,不做自检操作,只有cpu1能读出来) */ + if(1u == PFM_CFG_GetCpuID()) + { + iotmp = DFM_Get_Tmp117(); + MSCP_LOG_MSG("io tmp %lf \r\n",iotmp); + tmpsend = iotmp * 1000; + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_IOTMP, (CM_UINT32)4u, &tmpsend); + } + else + { + /*- 无处理 */ + } + + MSCP_LOG_MSG("cpu tmp %d \r\n",DFM_Read_cputemp()); +} +/** +* @brief 串口回环自检 +*/ +void PFM_UartComCheck(void) +{ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT16 len = 0u; + CM_UINT16 offset = 2u; + CM_UINT8 SendBuf[20u] = {0u}; + CM_UINT32 crc = 0u; + + /*自检发送组包 2字节长度+1字节类型+1字节板卡ID+1字节CPUID+4字节CRC*/ + SendBuf[offset] = (CM_UINT8)ENUM_COM_SelfCheck; + offset++; + SendBuf[offset] = g_PFM_Cfg.BOARD_ID; + offset++; + SendBuf[offset] = g_PFM_Cfg.CPU_ID; + offset++; + CM_ShortToChar((offset - (CM_UINT16)2u),&SendBuf[0u]); + crc = CM_Crc32(SendBuf,(CM_UINT32)offset); + CM_LongToChar(crc,&SendBuf[offset]); + len = offset + 4u; +#ifdef QNX + /*串口数据发送*/ + ret = CM_Com_LocalDataSend(SendBuf,len); + CM_NM_ASSERT(ENUM_CM_TRUE == ret, SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); +#endif +} + +/** +* @brief 板卡自检 +*/ +void PFM_BoardCheck(void) +{ + CM_INT32 ret; + CM_INT32 channel_1_shunt; + CM_INT32 channel_2_shunt; + CM_INT32 channel_3_shunt; + CM_FLOAT32 channel_1_bus; + CM_FLOAT32 channel_2_bus; + CM_FLOAT32 channel_3_bus; + CM_INT32 send_channel_1_bus; + CM_INT32 send_channel_2_bus; + CM_INT32 send_channel_3_bus; + CM_UINT8 rBuf[24]; + + /*- 读取三个通道的电流电压 */ + ret = DFM_Read_ina3321(&channel_1_shunt, &channel_1_bus, &channel_2_shunt, &channel_2_bus, &channel_3_shunt, &channel_3_bus); + if(0 == ret) + { + MSCP_LOG_MSG("%d, %f, %d, %f, %d, %f\n",channel_1_shunt,channel_1_bus,channel_2_shunt,channel_2_bus,channel_3_shunt,channel_3_bus); + send_channel_1_bus = channel_1_bus * 1000; + (void)CFM_DarkLog_Storage(DARK_LOG_DEC, TSCP_DARK_CHANNEL_1_SHUNT, 4u, &channel_1_shunt); + (void)CFM_DarkLog_Storage(DARK_LOG_DEC, TSCP_DARK_CHANNEL_1_BUS, 4u, &send_channel_1_bus); + send_channel_2_bus = channel_2_bus * 1000; + (void)CFM_DarkLog_Storage(DARK_LOG_DEC, TSCP_DARK_CHANNEL_2_SHUNT, 4u, &channel_2_shunt); + (void)CFM_DarkLog_Storage(DARK_LOG_DEC, TSCP_DARK_CHANNEL_2_BUS, 4u, &send_channel_2_bus); + send_channel_3_bus = channel_3_bus * 1000; + (void)CFM_DarkLog_Storage(DARK_LOG_DEC, TSCP_DARK_CHANNEL_3_SHUNT, 4u, &channel_3_shunt); + (void)CFM_DarkLog_Storage(DARK_LOG_DEC, TSCP_DARK_CHANNEL_3_BUS, 4u, &send_channel_3_bus); + } + else + { + MSCP_LOG_MSG("Read ina3321 fail.\n"); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1)); + } + /*- 读取eeprom信息 */ + ret = DFM_Read_eeprom(1, rBuf, 24); + MSCP_LOG_MSG("1:DFM_Read_eeprom ret = %d\n",ret); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_EEPROMCPU, 24u, rBuf); + if(g_PFM_Cfg.CPU_ID == 1) + { + ret = DFM_Read_eeprom(2, rBuf, 24); + MSCP_LOG_MSG("2:DFM_Read_eeprom ret = %d\n",ret); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_EEPROMIO12S, 24u, rBuf); + } + else + { + ret = DFM_Read_eeprom(3, rBuf, 24); + MSCP_LOG_MSG("3:DFM_Read_eeprom ret = %d\n",ret); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_EEPROM8S, 24u, rBuf); + ret = DFM_Read_eeprom(4, rBuf, 24); + MSCP_LOG_MSG("4:DFM_Read_eeprom ret = %d\n",ret); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_EEPROMIO12S, 24u, rBuf); + } +} +/* + * @brief板卡硬件自检 3次 + */ +void PFM_BoardCheck_TolerateThreetimes(void) +{ + /*- 网卡状态自检 */ + DFM_ethernetState(); + /* MSCP_LOG_MSG("ethernetState_CHECK_OK \r\n"); */ + /*- 电压状态自检 */ + DFM_voltageState(); + /* MSCP_LOG_MSG("voltageState_CHECK_OK \r\n"); */ + /*- 温度自检*/ + PFM_BoardTmpCheck(); + /* MSCP_LOG_MSG("BoardTmp_CHECK_OK \r\n"); */ +} +void PFM_InitSignalFunc(void) +{ +#ifdef QNX + /*注册信号处理函数*/ + act.sa_flags=0; /*表示使用act.sa_handler形式的信号处理函数 */ + act.sa_handler=signal_handler; + (void)sigemptyset(&act.sa_mask); /*清空sa_mask信号屏蔽集*/ + /*由应用注册*/ +#if 0 + (void)sigaction(SIGSEGV,&act,NULL); + (void)sigaction(SIGBUS,&act,NULL); + (void)sigaction(SIGABRT,&act,NULL); +#endif + /*设置标准输出和错误输出为无缓冲*/ + (void)setvbuf(stdout,NULL,_IONBF,0u); + (void)setvbuf(stderr,NULL,_IONBF,0u); +#endif +} + +/** +* @brief 设置捕获信号 +*/ +void PFM_SetSignal(CM_INT32 SIGNAL) +{ +#ifdef QNX + (void)sigaction(SIGNAL,&act,NULL); +#endif +} + +/** +* @brief 设置应用运行步骤 +*/ +void PFM_SetAppCheck(CM_INT32 appCheck) +{ + s_PFM_AppCheck = appCheck; +} +/** +* @brief 信号处理函数 +* @details 宕机捕获信号不让程序宕机,追踪宕机位置 +*/ +static void signal_handler(void) +{ + static FILE * fp_crash; + static CM_CHAR str_crash[256] = {0}; + static CM_UINT8 ret = 0u; + (void)printf("PFM_CFC_Check = %d\n", g_PFM_Check); + MSCP_LOG_MSG("PFM_CFC_Check = %d\n", g_PFM_Check); + + (void)printf("PFM_CFC_Check = %d\n", s_PFM_AppCheck); + MSCP_LOG_MSG("PFM_CFC_Check = %d\n", s_PFM_AppCheck); + + fp_crash = fopen("signallog.txt", "w+"); + (void)sprintf(str_crash,"PFM_CFC_Check = %d, s_PFM_AppCheck = %d\n", g_PFM_Check, s_PFM_AppCheck); + ret=fwrite(str_crash,(CM_SIZE_T)1u,strlen(str_crash),fp_crash); + if (ret != strlen(str_crash)) + { + MSCP_LOG_MSG("fwrite signallog.txt fail!\n"); + (void)printf("fwrite signallog.txt fail!\n"); + } + else + { + /*- 无处理 */ + } + (void)fclose(fp_crash); + + CM_NM_ASSERT(0, SELF_CHECK_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + while(1) + { + CM_Sleep(CM_UINT32_MAX); + } +} + diff --git a/TSCP/src/MSCP/PFM/PFM_SelfCheck.h b/TSCP/src/MSCP/PFM/PFM_SelfCheck.h new file mode 100644 index 0000000..36676c4 --- /dev/null +++ b/TSCP/src/MSCP/PFM/PFM_SelfCheck.h @@ -0,0 +1,54 @@ +/* + * PFM_SelfCheck.h + * + * Created on: 2021��9��24�� + * Author: fengr + */ +#ifndef PFM_SELFCHECK_H +#define PFM_SELFCHECK_H +#include "CM_Types.h" + +#ifdef __cplusplus +extern "C" +{ +#endif +extern CM_UINT8 fileBuf[1024*1024*100]; +/*�ļ���ʼ��*/ +void PFM_FileInit(void); +/*�忨�Լ�*/ +void PFM_BoardCheck(void); +void PFM_UartComCheck(void); + +/** +* @brief 设置板卡温度范围 +* @param MinTemperature 最低温度 +* @param MinTemperature 最高温度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败 +*/ +CM_UINT8 PFM_SetTemperature(CM_FLOAT32 MinTemperature , CM_FLOAT32 MaxTemperature); +/** +* @brief 设置捕获信号 +*/ +void PFM_SetSignal(CM_INT32 SIGNAL); + +/** +* @brief 设置应用运行步骤 +*/ +void PFM_SetAppCheck(CM_INT32 appCheck); +/** +* @brief 注册信号处理函数以及设置标准输出和错误输出为无缓冲 +* @details 宕机捕获信号不让程序宕机,追踪宕机位置 +*/ +void PFM_InitSignalFunc(void); +/* + * @brief板卡硬件自检 3次 + */ +void PFM_BoardCheck_TolerateThreetimes(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/SFM/SFM_2oo2.c b/TSCP/src/MSCP/SFM/SFM_2oo2.c new file mode 100644 index 0000000..0d70b3e --- /dev/null +++ b/TSCP/src/MSCP/SFM/SFM_2oo2.c @@ -0,0 +1,1017 @@ +/** +* @file SFM_2oo2.c +* @brief Safe Function Module:2oo2功能 +* @details +* 2oo2上电初始化:初始化、同步、校验 +* 2oo2周期同步和2oo2数据交换 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "SFM_2oo2.h" +#include "SFM_2x2.h" +#include "CM_Convert.h" +#include "CM_Memory.h" +#include "CM_CRC32.h" +#include "CM_RingBuf.h" +#include "CM_Time.h" +#include "CM_MD5.h" +#include "DFM_Time.h" +#include "CFM_Net.h" +#include "SFM_package.h" +#include "PFM_Cfg.h" +#include "PFM_Log.h" + +#define SFM_SYNC_CHECK_NUM (10u) /**<上电同步检查总次数 */ +#define SFM_SYNC_CHECK_MIN (10u) /**<上电同步检查通过的最少次数 */ + + +#define SFM_2oo2_TM_RING_SIZE (1000u / (3u * ((MSCP_CYC_TIME) / 100u)) * 2u) /**<400是周期时间,3是没晶振误差 */ +#define SFM_2oo2_TM_FIX_VAL (3) /**< 2oo2校时门限,单位:ms*/ + +static STRU_CM_RING_T s_2oo2_TmRing; + +STRU_2OO2_CTRL_T s_2oo2_Ctrl; /**< 平台通信控制 */ + +STRU_2OO2_CTRL_T s_2oo2_Ctrl_App; /**< 应用通信控制 */ + + +/* 2oo2发送 */ +static void s_2oo2_Send(IN const CM_UINT8 *Data, IN CM_INT32 DataLen, STRU_2OO2_CTRL_T *p_2oo2_Ctrl,IN ENUM_2oo2_MSG_T msgType,CM_UINT16 FrameStart); +/* 2oo2重传请求与接收ack发送*/ +static void s_2oo2_ARQ_Send(STRU_2OO2_CTRL_T *p_2oo2_Ctrl,IN ENUM_2oo2_MSG_T msgType,CM_UINT16 FrameIndex); +/* 2oo2数据接收,支持重传*/ +static CM_INT32 s_2oo2_ARQ_Recv(OUT CM_UINT8 *RxData, IN CM_UINT32 RxSize, OUT ENUM_2oo2_MSG_T *pMsgType, + IN const CM_UINT8 *Send_Data, IN CM_INT32 Send_DataLen, STRU_2OO2_CTRL_T *p_2oo2_Ctrl,IN ENUM_2oo2_MSG_T Send_msgType); + +/* 维护模式2oo2发送 */ +static void s_2oo2_Send_Crash(IN const CM_UINT8 *Data, IN CM_INT32 DataLen, STRU_2OO2_CTRL_T *p_2oo2_Ctrl,IN ENUM_2oo2_MSG_T msgType); +/* 维护模式2oo2接收 */ +static CM_INT32 s_2oo2_Recv_Crash(OUT CM_UINT8 *RxData, IN CM_UINT32 RxSize, OUT ENUM_2oo2_MSG_T *pMsgType,STRU_2OO2_CTRL_T *p_2oo2_Ctrl); +/** +* @brief 2oo2上电初始化 +* @param vitalBuf 关键数据数组 +* @param vitalLen 关键数据长度 +* @param p2oo2SyncTick 2oo2同步成功时的本机Tick +* @details +* 执行初始上电同步,成功后连续进行10次定期同步以校验延迟时间 +* 校验不通过时将重新执行初始上电同步... +* 完成2oo2同步后,进行2oo2上电关键数据比较,比较不一致时宕机。 +*/ +void SFM_2oo2_Init(IN const CM_UINT8 *vitalBuf, IN CM_UINT16 vitalLen, OUT CM_UINT64 *p2oo2SyncTick) +{ + /*- 变量初始化 */ + CM_UINT8 myData[1000] = "sync"; /* 临时缓冲区 */ + CM_UINT8 peerData[1000] = { 0u }; /* 临时缓冲区 */ + CM_INT32 len = 0; /* 临时变量 */ + CM_INT32 ret = 0; /* 临时变量 */ + CM_UINT32 i = 0u; /* 临时变量 */ + CM_INT32 delayTime = 0; /* 延迟时间 */ + CM_UINT8 myGoodCount = 0u; /* 本机校验通过次数 */ + CM_UINT64 cycTick = 0u; /* 周期Tick */ + CM_UINT64 curTick = 0u; /* 当前Tick */ + CM_INT32 checkCount = 0; /* 同步检查次数 */ + CM_UINT32 baseLen = 0u; /* 平台关键信息长度 */ + CM_UINT8 tmepIndex = 0u; + /*- 循环执行2oo2上电同步*/ + while (1) + { + /*- 2oo2初次同步*/ + MSCP_LOG_MSG("2oo2 sync start...\n"); + (void)CFM_2oo2_InitSync(); + cycTick = CM_GetTick(); + myGoodCount = 0u; + ++checkCount; + + /*- @alias 连续进行10次定期同步,校验延迟时间 */ + for (i = 0u; i < SFM_SYNC_CHECK_NUM; i++) + { + /*- 2oo2同步 */ + (void)SFM_2oo2_Exchange_Currency(myData, 4, peerData, 4u, ENUM_2oo2_SYNC); + curTick = CM_GetTick(); + delayTime = (CM_INT32)CM_UNSIGNED_LONG_INT_EXP((curTick - cycTick) / 1000u); + /*- @alias 检查同步结果(延迟时间) */ +#ifdef WIN32 + if (delayTime < 20000) +#else + if (delayTime <= 3000) +#endif + { + myGoodCount++; + MSCP_LOG_MSG("."); + } + else + { + MSCP_LOG_MSG("?"); + } + /*- 延时200ms */ + cycTick += (CM_UINT64)CM_UNSIGNED_INT_EXP(200u * CM_UNSIGNED_MILLION); + (void)DFM_WaitUntill(cycTick); + } + + /*- 2oo2交换校验结果 */ + myData[0u] = myGoodCount; + (void)SFM_2oo2_Exchange_Currency(myData, (CM_INT32)1, peerData, (CM_UINT32)1, ENUM_2oo2_SYNC); + + /*- 双机校验结果是否都通过 */ + if ((myGoodCount >= SFM_SYNC_CHECK_MIN) && (peerData[0u] >= SFM_SYNC_CHECK_MIN)) + { + /*- 退出循环 */ + break; + } + /*- 校验次数是否超过10次 */ + else if (checkCount >= 30) + { + /*- 宕机 */ + CM_ASSERT(0, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + } + else + { + /*- 记录延迟时间 */ + MSCP_LOG_MSG(" fail %d\n", delayTime); + /*- @alias 根据校验结果调整延迟时间 */ + if (myGoodCount < 3u) /*我的结果太差说明我周期开始时间过早*/ + { + if (delayTime > (1000 * 20)) + { + cycTick += (CM_UINT64)CM_UNSIGNED_INT_EXP(210u * CM_UNSIGNED_MILLION); + MSCP_LOG_MSG("_"); + } + else + { + cycTick += (CM_UINT64)CM_UNSIGNED_INT_EXP(201u * CM_UNSIGNED_MILLION); + MSCP_LOG_MSG("-"); + } + (void)DFM_WaitUntill(cycTick); + } + else + { + cycTick += (CM_UINT64)CM_UNSIGNED_INT_EXP(200u * CM_UNSIGNED_MILLION); + (void)DFM_WaitUntill(cycTick); + } + } + } + /*- 记录校验通过的时间 */ + *p2oo2SyncTick = cycTick; + MSCP_LOG_MSG(" success\n"); + + /*- 2oo2上电比较,组上电比较校验帧 */ + /* ID信息 */ + myData[baseLen++] = g_PFM_Cfg.CPU_ID; + myData[baseLen++] = g_PFM_Cfg.BOARD_ID; + /*交互自动重启次数*/ + myData[baseLen++] = MSCP_Get_AutoRbootCut(); + /*交互软重启次数*/ + myData[baseLen++] = RM_Get_FaultRbootCut(); + /* 平台软件版本 */ + myData[baseLen++] = MSCP_SW_VERION[0]; + myData[baseLen++] = MSCP_SW_VERION[1]; + myData[baseLen++] = MSCP_SW_VERION[2]; + myData[baseLen++] = MSCP_SW_VERION[3]; + /* 平台配置数据MD5 */ + (void)CM_Memcpy((void*)&myData[baseLen], (CM_SIZE_T)CM_MD5_SIZE_BYTE, (void*)g_PFM_Cfg.CFG_MD5, (CM_SIZE_T)CM_MD5_SIZE_BYTE); + baseLen += CM_MD5_SIZE_BYTE; + + CM_ASSERT(vitalLen <= 200u, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + (void)CM_Memcpy((void*)(myData + baseLen), (CM_SIZE_T)(sizeof(myData) - baseLen), (const void*)vitalBuf, (CM_SIZE_T)vitalLen); + len = (CM_INT32)CM_UNSIGNED_INT_EXP(baseLen + (CM_UINT32)vitalLen); + /*TODO 软件完整性,数据版本、完整性检查,应用一致性*/ + + /*- 与邻机交换校验帧 */ + ret = SFM_2oo2_Exchange_Currency(myData, len, peerData, (CM_UINT32)sizeof(peerData), ENUM_2oo2_INIT_CHECK); + /*- 校验帧长度是否相同 */ + if (ret == len) + { + /*- 检查收到的校验帧内容 */ + CM_ASSERT((myData[0] + peerData[0]) == 3u, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + ret = CM_Memcmp((void*)(myData + 1u), (void*)(peerData + 1u), (CM_SIZE_T)CM_SIGNED_INT_EXP(len - 1)); + CM_ASSERT(ret == 0, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_4); + MSCP_LOG_MSG("2oo2 Init Cmp Success\n"); + if(0u < MSCP_Get_AutoRbootCut()) + { + /*- 比较宕机日志与实际版本号*/ + for(i = 0u; i < 3u; i++) + { + (1u == g_App_Verson.registerVerson[i].versonName)?tmepIndex = i:tmepIndex; + } + ret = CM_Memcmp(g_AutoRebootVersion,g_App_Verson.registerVerson[tmepIndex].verson,4u); + CM_ASSERT(ret == 0, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_6); + MSCP_LOG_MSG("Init Version Cmp Success\n"); + } + else + { + /*- 不是自动重启*/ + } + } + else + { + /*- 宕机 */ + CM_ASSERT(0, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_5); + } +} +/** +* @brief 2oo2关键数据初始化 +*/ +void SFM_2oo2_DataInit(void) +{ + /*- 2取全局数据初始化 */ + SFM_2oo2_CtrlInit(); + + /*- 2取环形队列初始化 */ + (void)CM_RB_Init(&s_2oo2_TmRing, CM_UNSIGNED_INT_EXP(SFM_2oo2_TM_RING_SIZE)); + + /*- 2取初次同步 */ + (void)CFM_2oo2_InitSync(); +} + +/** +* @brief 2oo2发送 +* @param Data 发送报文指针 +* @param DataLen 发送报文长度 +* @param msgType 发送报文类型 +* @param p_2oo2_Ctrl 2取控制参数结构体 +* @param FrameStart 发送起始标志,用于重传,首次发送数据输入1 +*/ +static void s_2oo2_Send(IN const CM_UINT8 *Data, IN CM_INT32 DataLen, STRU_2OO2_CTRL_T *p_2oo2_Ctrl,IN ENUM_2oo2_MSG_T msgType,CM_UINT16 FrameStart) +{ + /*- 变量初始化 */ + CM_UINT16 FrameNum = 0u; /* 帧总数 */ + CM_UINT16 FrameIndex = 0u; /* 帧序号 */ + CM_UINT32 FrameLen = 0u; /* 帧长度 */ + CM_UINT32 SysCyc = SFM_2x2_GetSysCount(); /*系统周期号*/ + PFM_LOG_SET_STOPTIMER(TSCP_DARK_2OO2); + /*- 入口检查 */ + CM_ASSERT(((DataLen >= 0) && (NULL != Data) && (NULL != p_2oo2_Ctrl) && (NULL != p_2oo2_Ctrl->DataSend)), SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + /*- 计算帧数 */ + FrameNum = (CM_UINT16)(((CM_UINT32)DataLen <= NET_20K_SIZE) ? (1u) : (((CM_UINT32)DataLen + (NET_20K_SIZE - 1u)) / NET_20K_SIZE)); + if(FrameStart <= FrameNum) + { + + /* + 2oo2通信帧格式: + 4字节 长度(不含自身) + 4字节 源ID + 4字节 目的ID + 4字节 周期号 + 4字节 序列号 + 1字节 类型 + 2字节 帧总数 + 2字节 帧序号 + n字节 数据 + 4字节 CRC(含长度) + */ + /*- 填充报文头 */ + CM_LongToChar(NET_20K_SIZE + 21u, p_2oo2_Ctrl->UDP_Cache); /* 长度(暂时填写满帧) */ + CM_LongToChar(p_2oo2_Ctrl->LocalID, p_2oo2_Ctrl->UDP_Cache + 4); /* 源ID */ + CM_LongToChar(p_2oo2_Ctrl->PeerID, p_2oo2_Ctrl->UDP_Cache + 8); /* 目的ID */ + CM_LongToChar(SysCyc, p_2oo2_Ctrl->UDP_Cache + 12); /* 周期号 */ + CM_LongToChar(p_2oo2_Ctrl->SN, p_2oo2_Ctrl->UDP_Cache + 16); /* 序列号 */ + p_2oo2_Ctrl->UDP_Cache[20] = (CM_UINT8)msgType; /* 类型 */ + CM_ShortToChar(FrameNum, p_2oo2_Ctrl->UDP_Cache + 21); /* 帧总数 */ + /* p_2oo2_Ctrl->UDP_Cache + 23 */ /* 帧序号(后面填写) */ + + /*- @alias 循环发送完整帧 */ + for (FrameIndex = FrameStart; FrameIndex < FrameNum; FrameIndex++) + { + CM_ShortToChar(FrameIndex, p_2oo2_Ctrl->UDP_Cache + 23); /* 帧序号 */ + (void)CM_Memcpy((void*)(p_2oo2_Ctrl->UDP_Cache + 25),(CM_SIZE_T)NET_20K_SIZE, (const void*)(Data + ((FrameIndex - 1u)*NET_20K_SIZE)), (CM_SIZE_T)NET_20K_SIZE); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + + (void)p_2oo2_Ctrl->DataSend(p_2oo2_Ctrl->UDP_Cache, (CM_INT32)(25u + NET_20K_SIZE)); /* 交给通信层发送 */ + + } + + /*- 发送尾帧 */ + CM_ShortToChar(FrameIndex, p_2oo2_Ctrl->UDP_Cache + 23); /*帧序号*/ + FrameLen = (CM_UINT32)DataLen - ((FrameIndex - 1u)*NET_20K_SIZE); + (void)CM_Memcpy((void*)(p_2oo2_Ctrl->UDP_Cache + 25), (CM_SIZE_T)NET_20K_SIZE, (const void*)(Data + ((FrameIndex - 1u)*NET_20K_SIZE)), (CM_SIZE_T)FrameLen); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + CM_LongToChar(21u + FrameLen, p_2oo2_Ctrl->UDP_Cache); /*长度*/ + + (void)p_2oo2_Ctrl->DataSend(p_2oo2_Ctrl->UDP_Cache, (CM_INT32)CM_UNSIGNED_INT_EXP(25u + FrameLen)); /* 交给通信层发送 */ + PFM_LOG_SET_STOPTIMER(TSCP_DARK_NULL); + } + else + { + MSCP_LOG_MSG("s_2oo2_Send err!!!\n"); + /*设置警告日志*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_WARNING, 4U, DARK_FAULT_CODE_MERGE(SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1)); + } +} + +/** +* @brief 2oo2重传请求与ACK发送 +* @param p_2oo2_Ctrl 2取控制参数结构体 +* @param msgType 发送报文类型 +* @param FrameIndex 重传请求起始序号 +*/ +static void s_2oo2_ARQ_Send(STRU_2OO2_CTRL_T *p_2oo2_Ctrl,IN ENUM_2oo2_MSG_T msgType,CM_UINT16 FrameIndex) +{ + /*- 变量初始化 */ + CM_UINT32 SysCyc = SFM_2x2_GetSysCount(); /*系统周期号*/ + /*- 入口检查 */ + CM_ASSERT(((NULL != p_2oo2_Ctrl) && (NULL != p_2oo2_Ctrl->DataSend)), SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_1); + /* + 2oo2通信帧格式: + 4字节 长度(不含自身) + 4字节 源ID + 4字节 目的ID + 4字节 周期号 + 4字节 序列号 + 1字节 类型 + 2字节 需要重传的帧序号 + 4字节 CRC(含长度) + */ + /*- 填充报文头 */ + CM_LongToChar(19u, p_2oo2_Ctrl->UDP_Cache); /* 长度(暂时填写满帧) */ + CM_LongToChar(p_2oo2_Ctrl->LocalID, p_2oo2_Ctrl->UDP_Cache + 4); /* 源ID */ + CM_LongToChar(p_2oo2_Ctrl->PeerID, p_2oo2_Ctrl->UDP_Cache + 8); /* 目的ID */ + CM_LongToChar(SysCyc, p_2oo2_Ctrl->UDP_Cache + 12); /* 周期号 */ + CM_LongToChar(p_2oo2_Ctrl->SN, p_2oo2_Ctrl->UDP_Cache + 16); /* 序列号 */ + p_2oo2_Ctrl->UDP_Cache[20] = (CM_UINT8)msgType; /* 类型 */ + CM_ShortToChar(FrameIndex, p_2oo2_Ctrl->UDP_Cache + 21); /* 重传序号 */ + + (void)p_2oo2_Ctrl->DataSend(p_2oo2_Ctrl->UDP_Cache, (CM_INT32)23); /* 交给通信层发送 */ +} +/** +* @brief 2oo2接收支持重传 +* @param RxData 接收报文指针 +* @param RxSize 接收缓冲区大小 +* @param pMsgType 收到的报文类型 +* @param Send_Data 发送报文指针,用于重传 +* @param Send_DataLen 发送报文长度,用于重传 +* @param p_2oo2_Ctrl 2取控制参数结构体与临时缓冲区 +* @param Send_msgType 发送的数据类型,用于重传 +* @return 收到的报文长度 +* @details +*/ +static CM_INT32 s_2oo2_ARQ_Recv(OUT CM_UINT8 *RxData, IN CM_UINT32 RxSize, OUT ENUM_2oo2_MSG_T *pMsgType,\ + IN const CM_UINT8 *Send_Data, IN CM_INT32 Send_DataLen, STRU_2OO2_CTRL_T *p_2oo2_Ctrl,IN ENUM_2oo2_MSG_T Send_msgType) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = 0; /* 网络接收长度 */ + CM_UINT32 msgLen = 0u; /* 报文长度 */ + CM_UINT32 SrcID = 0u; /* 源ID */ + CM_UINT32 DstID = 0u; /* 目的ID */ + CM_UINT32 msgCyc = 0u; /* 报文周期号 */ + CM_UINT32 msgSN = 0u; /* 报文序列号 */ + CM_UINT16 FrameNum = 0u; /* 帧数目 */ + CM_UINT16 FrameIndex = 0u;/* 帧序号 */ + CM_UINT8 *pData = NULL; /* 指向帧数据的指针 */ + CM_INT32 DataLen = 0; /* 帧数据长度 */ + CM_INT32 allLen = 0; /* 收到的报文总长度 */ + CM_UINT8 type = 0u; /* 报文类型 */ + CM_UINT16 ARQ_Cut = 0u; /* 记录重传请求次数 */ + + CM_UINT16 ARQ_FrameStart = 0u;/* 重传帧序号 */ + CM_UINT8 MineRcvSuccessFlag = CM_FALSE;/*本机接收完成标志*/ + CM_UINT8 PeerRcvSuccessFlag = CM_FALSE;/*对系接收完成标志*/ + CM_UINT64 curTick = 0u; /* 当前时刻 */ + CM_UINT64 sTick = 0u; /* 起始Tick */ + CM_UINT32 sysCyc = SFM_2x2_GetSysCount(); /* 系统周期号 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 临时变量 */ + PFM_LOG_SET_STOPTIMER(TSCP_DARK_2OO2); + /*- 入参检查 */ + CM_ASSERT((NULL != RxData) && (NULL != pMsgType) && (NULL != Send_Data) && (NULL != p_2oo2_Ctrl) && (NULL != p_2oo2_Ctrl->DataRecv), SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + /*- 记录起始时间*/ + sTick = CM_GetTick(); + /*- 循环接收2oo2数据 */ + while(1) + { + /*- 从通信层接收2oo2报文 */ + rxLen = p_2oo2_Ctrl->DataRecv(p_2oo2_Ctrl->UDP_Cache, (CM_UINT32)sizeof(p_2oo2_Ctrl->UDP_Cache)); + /*- 收到的报文长度是否大于23 */ + if (23 <= rxLen) + { + + /*- 解析2oo2报文头 */ + /* + 2oo2通信帧格式: + 4字节 长度(不含自身) + 4字节 源ID + 4字节 目的ID + 4字节 周期号 + 4字节 序列号 + 1字节 类型 + 2字节 帧总数 + 2字节 帧序号 + n字节 数据 + 4字节 CRC(含长度) + */ + msgLen = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache); + SrcID = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache + 4); + DstID = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache + 8); + msgCyc = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache + 12); + msgSN = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache + 16); + type = p_2oo2_Ctrl->UDP_Cache[20]; + if (((msgLen + 4u) == (CM_UINT32)rxLen) + && (SrcID == p_2oo2_Ctrl->PeerID) + && (DstID == p_2oo2_Ctrl->LocalID) + && (msgCyc == sysCyc) + && (msgSN == p_2oo2_Ctrl->SN)) + { + switch(type) + { + case ENUM_2oo2_ARQ: + /*- 执行重新发送*/ + if(CM_FALSE == PeerRcvSuccessFlag) + { + ARQ_FrameStart = CM_ShortFromChar(p_2oo2_Ctrl->UDP_Cache + 21); + s_2oo2_Send(Send_Data,Send_DataLen,p_2oo2_Ctrl,Send_msgType,ARQ_FrameStart); + } + else + { + /*无处理*/ + } + if (CM_TRUE == MineRcvSuccessFlag) + { + s_2oo2_ARQ_Send(p_2oo2_Ctrl,ENUM_2oo2_RCV_SUCCESS,0); + } + break; + case ENUM_2oo2_RCV_SUCCESS: + /*- 记录接收完成标志,不响应重传请求*/ + PeerRcvSuccessFlag = CM_TRUE; + break; + default: + FrameNum = CM_ShortFromChar(p_2oo2_Ctrl->UDP_Cache + 21); + FrameIndex = CM_ShortFromChar(p_2oo2_Ctrl->UDP_Cache + 23); + + /*- 是否接收成功 */ + if (CM_FALSE == MineRcvSuccessFlag) + { + pData = p_2oo2_Ctrl->UDP_Cache + 25; + DataLen = (CM_INT32)msgLen - 21; + /*- 分帧接收2oo2报文 */ + ret = SFM_FrameSave(&p_2oo2_Ctrl->FrameCtrl, type, FrameNum, FrameIndex, pData, DataLen, RxData, &allLen, RxSize); + /*- 是否收齐了完整2oo2报文 */ + if (ENUM_CM_TRUE == ret) + { + /*- 输出报文类型,退出循环 */ + *pMsgType = (ENUM_2oo2_MSG_T)type; + /*- 接收成功发送成功标志,此处记录跳出标志 */ + MineRcvSuccessFlag = CM_TRUE; + s_2oo2_ARQ_Send(p_2oo2_Ctrl,ENUM_2oo2_RCV_SUCCESS,0); + s_2oo2_ARQ_Send(p_2oo2_Ctrl,ENUM_2oo2_RCV_SUCCESS,0); + s_2oo2_ARQ_Send(p_2oo2_Ctrl,ENUM_2oo2_RCV_SUCCESS,0); + } + else + { + /*- 无处理,为防止乱序错误,此处不发送重传请求 */ + } + sTick = CM_GetTick(); + } + else + { + /*- 接收成功,重复数据无处理 */ + } + break; + } + } + else if(type == ENUM_2oo2_RCV_SUCCESS) + { + /*是接收成功回复 不做处理*/; + } + else + { + MSCP_LOG_MSG("len=[%d,%d]src=[%d,%d]dst=[%d,%d]cyc=[%d,%d]sn=[%d,%d],type=%d\n", + rxLen, msgLen, SrcID, p_2oo2_Ctrl->PeerID, DstID, p_2oo2_Ctrl->LocalID, + msgCyc, sysCyc, msgSN, p_2oo2_Ctrl->SN,type); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2OO2_RCV_ERR,11u, + sizeof(CM_INT32),rxLen, + sizeof(CM_UINT32),msgLen, + sizeof(CM_UINT32),SrcID, + sizeof(CM_UINT32),p_2oo2_Ctrl->PeerID, + sizeof(CM_UINT32),DstID, + sizeof(CM_UINT32),p_2oo2_Ctrl->LocalID, + sizeof(CM_UINT32),msgCyc, + sizeof(CM_UINT32),sysCyc, + sizeof(CM_UINT32),msgSN, + sizeof(CM_UINT32),p_2oo2_Ctrl->SN, + sizeof(CM_UINT8),type); + } + + } + else + { + /*- 记录当前时间*/ + curTick = CM_GetTick(); + /*- 超时重传,接收成功标志不响应*/ + if((CM_UNSIGNED_MILLION*10u) < (curTick-sTick)) + { + /*- 超时发送请求*/ + s_2oo2_ARQ_Send(p_2oo2_Ctrl,ENUM_2oo2_ARQ,p_2oo2_Ctrl->FrameCtrl.FramIndex + 1u); + MSCP_LOG_MSG("[%d]s_2oo2_ARQ_Send:%d\n",p_2oo2_Ctrl->SN,p_2oo2_Ctrl->FrameCtrl.FramIndex + 1); + /*- 重置起始时间*/ + sTick = CM_GetTick(); + ARQ_Cut++; + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2OO2_RCV_ARQ,3u, + sizeof(CM_UINT32),p_2oo2_Ctrl->SN, + sizeof(CM_UINT16),(p_2oo2_Ctrl->FrameCtrl.FramIndex + 1u), + sizeof(CM_UINT16),ARQ_Cut); + } + else + { + /*- 无处理 */ + } + } + /*本机与邻机接收成功或重传次数超过1分钟(6000次)退出重传 */ + if(((CM_TRUE == MineRcvSuccessFlag) && (CM_TRUE == PeerRcvSuccessFlag)) || (ARQ_Cut >= 6000)) + { + /*- 结束接收 */ + /*- 结束接收 重传超过6000次日志记录 */ + if(ARQ_Cut >= 6000) + { + MSCP_LOG_MSG("2oo2 failed break ARQ_Cut = %d, MineRcvSuccessFlag = %d, PeerRcvSuccessFlag = %d\n", ARQ_Cut, MineRcvSuccessFlag, PeerRcvSuccessFlag); + CM_ASSERT(0,SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_2); + } + else + { + ; + } + break; + } + } + PFM_LOG_SET_STOPTIMER(TSCP_DARK_NULL); + /*- 返回报文总长度 */ + return allLen; +} +/** +* @breif 全双工通用2oo2数据交换,支持重传 +* @param pMyData 本机数据指针 +* @param DataLen 本剧数据长度 +* @param pPeerData 邻机数据指针 +* @param DataSize 邻机数据缓冲区大小 +* @param msgTye 2oo2交换数据类型 +* @return 收到的邻机数据长度 +*/ +CM_INT32 SFM_2oo2_Exchange_Currency(IN const CM_UINT8 * pMyData, IN CM_INT32 DataLen, OUT CM_UINT8 * pPeerData, IN CM_UINT32 DataSize, IN ENUM_2oo2_MSG_T msgType) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = -1; + ENUM_2oo2_MSG_T rxType = ENUM_2oo2_ERROR; + + /*- 入口检查 */ + CM_ASSERT(DataLen >= 0, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1); + + /*- 更新2oo2通信序列号 */ + s_2oo2_Ctrl.SN++; + + /*- 发送2oo2数据 */ + s_2oo2_Send(pMyData, DataLen,&s_2oo2_Ctrl, msgType,1u); + /*等待接收端应答*/ + rxLen = s_2oo2_ARQ_Recv(pPeerData, DataSize, &rxType,pMyData, DataLen, &s_2oo2_Ctrl,msgType); + + CM_RE_ASSERT(msgType == rxType, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_2); + + CM_RE_ASSERT(0 <= rxLen, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_3); + + /*- 返回收到的报文长度 */ + return rxLen; +} +/** +* @breif 应用全双工2oo2数据交换支持重传 +* @param pMyData 本机数据指针 取值范围:非空 +* @param DataLen 本剧数据长度 取值范围:0~0x7FFFFFFF +* @param pPeerData 邻机数据指针 取值范围:非空 +* @param DataSize 邻机数据缓冲区大小 取值范围:0~0xFFFFFFFF +* @return 收到的邻机数据长度 取值范围:0~0x7FFFFFFF +*/ +CM_INT32 SFM_2oo2_Currency_App(IN const CM_UINT8 pMyData[], IN CM_INT32 DataLen, OUT CM_UINT8 pPeerData[], IN CM_UINT32 DataSize) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = -1; + ENUM_2oo2_MSG_T rxType = ENUM_2oo2_ERROR; + + /*- 入口检查 */ + CM_ASSERT(DataLen >= 0, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_1); + CM_ASSERT((NULL != pMyData) && (NULL != pPeerData), SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_3); + + /*- 更新2oo2通信序列号 */ + s_2oo2_Ctrl_App.SN++; + + /*- 发送2oo2数据 */ + s_2oo2_Send(pMyData, DataLen,&s_2oo2_Ctrl_App, ENUM_2oo2_APP,1u); + /*等待接收端应答*/ + rxLen = s_2oo2_ARQ_Recv(pPeerData, DataSize, &rxType,pMyData, DataLen, &s_2oo2_Ctrl_App,ENUM_2oo2_APP); + + CM_ASSERT(0 <= rxLen, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_2); + + /*- 返回收到的报文长度 */ + return rxLen; +} + +/** +* @brief 2oo2同步 +* @param pOffset 本机时钟调整量 +* @return 2oo2同步完成的时刻 +* @details +* 通过互发时钟同步报文并检查接收的方式实现2oo2同步 +* 互发的同步报文同时交换了上一次时钟同步的结果 +* 每次2oo2同步之后都会发起一次新的时钟同步(由时钟同步线程接收、处理) +*/ +CM_UINT64 SFM_2oo2_Sync(OUT CM_INT64 *pOffset) +{ + /*- 变量初始化 */ + static CM_INT64 s_tm_mysum = 0; + static CM_INT64 s_tm_peersum = 0; + static CM_UINT32 s_tm_count = 0u; + static CM_UINT32 s_tm_nadd = 0u; + static CM_UINT32 s_tm_nsub = 0u; + CM_INT32 rxLen = 0; /* 接收数据长度 */ + CM_UINT8 myBuf[100] = { 0u }; /* 本机报文缓冲区 */ + CM_UINT8 peerBuf[100] = { 0u }; /* 邻机报文缓冲区 */ + CM_INT64 myDelay = 0; /* 本机延迟时间 */ + CM_INT64 myOffset = 0; /* 本机偏移时间 */ + CM_INT64 peerDelay = 0; + CM_INT64 peerOffset = 0; + CM_INT64 val = 0; + CM_INT64 aveOffset = 0; + CM_INT64 tempval = 0; /*临时变量*/ + CM_UINT64 rxTick = 0u; + CM_UINT64 costlog[20]; /* 耗时记录 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + if(NULL != pOffset) + { + costlog[0] = CM_GetTick(); + /*- 取得上一次校时结果 */ + ret = CFM_2oo2_TimeGet(&myDelay, &myOffset); + /*- 是否成功取得校时结果 */ + if (ENUM_CM_TRUE == ret) + { + /*- 无处理 */ + } + else + { + /*- 校时结果置为无效值 */ + myDelay = (CM_INT64)CM_SIGNED_INT_EXP(100 * CM_MILLION); + myOffset = (CM_INT64)CM_SIGNED_INT_EXP(100 * CM_MILLION); + } + + /*- 2oo2同步,并交换校时结果 */ + CM_64ToChar(myDelay, myBuf); + CM_64ToChar(myOffset, myBuf + 8); + costlog[1] = CM_GetTick(); + MSCP_LOG_MSG("SFM_2oo2_Sync1 = %d us\n", (costlog[1] - costlog[0]) / 1000u); + rxLen = SFM_2oo2_Exchange_Currency(myBuf, (CM_INT32)16, peerBuf, (CM_UINT32)16, ENUM_2oo2_SYNC); + costlog[2] = CM_GetTick(); + MSCP_LOG_MSG("SFM_2oo2_Sync2 = %d us\n", (costlog[2] - costlog[1]) / 1000u); + /*- 记录同步完成时间 */ + rxTick = CM_GetTick(); + + /*- 检查同步数据长度是否一致 */ + CM_ASSERT(16 == rxLen, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_1); + + /*- 发起下一次校时备用*/ + CFM_2oo2_TimeReq(); + costlog[3] = CM_GetTick(); + MSCP_LOG_MSG("SFM_2oo2_Sync3 = %d us\n", (costlog[3] - costlog[2]) / 1000u); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2OO2_SYNC_TIME,3u, + sizeof(CM_UINT64),(costlog[1] - costlog[0]) / 1000u, + sizeof(CM_UINT64),(costlog[2] - costlog[1]) / 1000u, + sizeof(CM_UINT64),(costlog[3] - costlog[2]) / 1000u); + peerDelay = (CM_INT64)CM_64FromChar(peerBuf); + peerOffset = (CM_INT64)CM_64FromChar(peerBuf + 8); + *pOffset = 0; + /*- 本次测得的偏移量是否在合理范围内 */ + if ((CM_ABS(myOffset) < (10 * CM_MILLION)) && (CM_ABS(peerOffset) < (10 * CM_MILLION))) + { + /*- 更新环形队列和累计数据 */ + (void)CM_RB_Get(&s_2oo2_TmRing, (CM_UINT16)SFM_2oo2_TM_RING_SIZE, &val); + s_tm_mysum -= val; + (void)CM_RB_Write(&s_2oo2_TmRing, myOffset); + s_tm_mysum += myOffset; + (void)CM_RB_Get(&s_2oo2_TmRing, (CM_UINT16)SFM_2oo2_TM_RING_SIZE, &val); + s_tm_peersum -= val; + (void)CM_RB_Write(&s_2oo2_TmRing, peerOffset); + s_tm_peersum += peerOffset; + /*- 累加同步次数 */ + s_tm_count += 2u; + /*- 是否累计了足够多的数据 */ + if (s_tm_count >= SFM_2oo2_TM_RING_SIZE) + { + /*- 计算平均偏移量 */ + aveOffset = (s_tm_mysum - s_tm_peersum) / (CM_INT64)CM_UNSIGNED_INT_EXP(SFM_2oo2_TM_RING_SIZE); + /*- 本机时钟是否过慢 */ + if (aveOffset > (SFM_2oo2_TM_FIX_VAL * CM_MILLION)) + { + /*- 缩短本周期时间1ms */ + *pOffset = -CM_MILLION; + s_tm_nsub++; + s_tm_count = 0u; + } + /*- 本机时钟是否过快 */ + else if (aveOffset < (-SFM_2oo2_TM_FIX_VAL * CM_MILLION)) + { + /*- 延长本周期时间 1ms */ + *pOffset = CM_MILLION; + s_tm_nadd++; + s_tm_count = 0u; + } + else + { + MSCP_LOG_MSG("aveOffset = %d\n", aveOffset); + } + } + else + { + MSCP_LOG_MSG("s_tm_count = %d\n", s_tm_count); + } + /*- 记录同步结果 */ + tempval = (CM_INT64)CM_UNSIGNED_INT_EXP(SFM_2oo2_TM_RING_SIZE / 2u); + MSCP_LOG_MSG("2oo2 sync:%lld,%lld,%lld,%lld(us)\n", myDelay / tempval, myOffset / tempval, peerDelay / tempval, peerOffset / tempval); + MSCP_LOG_MSG("2oo2 offset_sum:%lld,%lld(us),%d,%d\n", s_tm_mysum / tempval, s_tm_peersum / tempval ,s_tm_nadd,s_tm_nsub); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2OO2_ALIGN_TIME,8u, + sizeof(CM_INT64),myDelay / tempval, + sizeof(CM_INT64),myOffset / tempval, + sizeof(CM_INT64),peerDelay / tempval, + sizeof(CM_INT64),peerOffset / tempval, + sizeof(CM_INT64),s_tm_mysum / tempval, + sizeof(CM_INT64),s_tm_peersum / tempval, + sizeof(CM_UINT32),s_tm_nadd, + sizeof(CM_UINT32),s_tm_nsub); + } + else + { + /*- 无处理 */ + /* 上电初始化阶段尚未校准周期定时器,此时获取的offset无效 */ + MSCP_LOG_MSG("tm sync fail:%lld,%lld\n", myOffset,peerOffset); + } + } + else + { + MSCP_LOG_MSG("pOffset = NULL\n"); + } + /*- 返回同步完成时间 */ + return rxTick; +} + +/** +* @brief 2oo2发送(用于维护模式下的2取发送) +* @param Data 发送报文指针 +* @param DataLen 发送报文长度 +* @param msgType 发送报文类型 +* @details +* 维护模式下的2取数据量小,不分包,无周期号 +*/ +static void s_2oo2_Send_Crash(IN const CM_UINT8 *Data, IN CM_INT32 DataLen, STRU_2OO2_CTRL_T *p_2oo2_Ctrl,IN ENUM_2oo2_MSG_T msgType) +{ + /*- 变量初始化 */ + CM_UINT32 crc = 0u; /* CRC */ + /*- 入口检查 */ + CM_ASSERT_MAINTAIN((DataLen >= 0) && (NULL != Data)); + + /* + 维护模式下2oo2通信帧格式: + 4字节 长度(不含自身) + 4字节 源ID + 4字节 目的ID + 4字节 序列号 + 1字节 类型 + n字节 数据 + 4字节 CRC(含长度) + */ + /*- 填充报文头 */ + CM_LongToChar(17u + DataLen, p_2oo2_Ctrl->UDP_Cache); /* 长度 */ + CM_LongToChar(p_2oo2_Ctrl->LocalID, p_2oo2_Ctrl->UDP_Cache + 4); /* 源ID */ + CM_LongToChar(p_2oo2_Ctrl->PeerID, p_2oo2_Ctrl->UDP_Cache + 8); /* 目的ID */ + CM_LongToChar(p_2oo2_Ctrl->SN, p_2oo2_Ctrl->UDP_Cache + 12); /* 序列号 */ + p_2oo2_Ctrl->UDP_Cache[16] = (CM_UINT8)msgType; /* 类型 */ + + (void)CM_Memcpy((void*)(p_2oo2_Ctrl->UDP_Cache + 17), (CM_SIZE_T)NET_20K_SIZE, (const void*)Data, (CM_SIZE_T)DataLen); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + + crc = CM_Crc32(p_2oo2_Ctrl->UDP_Cache, 17u + DataLen); + CM_LongToChar(crc, p_2oo2_Ctrl->UDP_Cache + 17u + DataLen); /*CRC*/ + + (void)CFM_2oo2_DataSend_Crash(p_2oo2_Ctrl->UDP_Cache, (CM_INT32)CM_UNSIGNED_INT_EXP(21u + DataLen)); /* 交给通信层发送 */ +} + +/** +* @brief 2oo2接收(用于维护模式下的2取发送) +* @param RxData 接收报文指针 +* @param RxSize 接收缓冲区大小 +* @param pMsgType 收到的报文类型 +* @return 收到的报文长度 +* @details +* 2oo2报文是阻塞方式接收,也就是无报文时将阻塞在本函数内,有报文时立即接收并返回, +* 函数返回值0表示接收成功,但数据段长度为0 +*/ +static CM_INT32 s_2oo2_Recv_Crash(OUT CM_UINT8 *RxData, IN CM_UINT32 RxSize, OUT ENUM_2oo2_MSG_T *pMsgType,STRU_2OO2_CTRL_T *p_2oo2_Ctrl) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = 0; /* 网络接收长度 */ + CM_UINT32 msgLen = 0u; /* 报文长度 */ + CM_UINT32 SrcID = 0u; /* 源ID */ + CM_UINT32 DstID = 0u; /* 目的ID */ + CM_UINT32 msgSN = 0u; /* 报文序列号 */ + CM_UINT32 msgCrc = 0u; /* 报文CRC */ + CM_UINT32 calcCrc = 0u; /* 本地计算CRC */ + CM_INT32 allLen = 0; /* 收到的报文总长度 */ + CM_UINT8 type = 0u; /* 报文类型 */ + /*- 入参检查 */ + CM_ASSERT_MAINTAIN((NULL != RxData) && (NULL != pMsgType)); + /*- 循环接收2oo2数据 */ + while(1) + { + /*- 从通信层接收2oo2报文 */ + rxLen = CFM_2oo2_DataRecv_Crash(p_2oo2_Ctrl->UDP_Cache, (CM_UINT32)sizeof(p_2oo2_Ctrl->UDP_Cache)); + /*- 收到的报文长度是否大于0 */ + if (0 < rxLen) + { + /*- 解析2oo2报文头 */ + CM_ASSERT_MAINTAIN(21 <= rxLen); + /* + 2oo2通信帧格式: + 4字节 长度(不含自身) + 4字节 源ID + 4字节 目的ID + 4字节 序列号 + 1字节 类型 + n字节 数据 + 4字节 CRC(含长度) + */ + msgLen = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache); + SrcID = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache + 4); + DstID = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache + 8); + msgSN = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache + 12); + type = p_2oo2_Ctrl->UDP_Cache[16]; + CM_ASSERT_MAINTAIN((msgLen + 4u) == (CM_UINT32)rxLen); + + msgCrc = CM_LongFromChar(p_2oo2_Ctrl->UDP_Cache + msgLen); + calcCrc = CM_Crc32(p_2oo2_Ctrl->UDP_Cache, msgLen); + /*- 校验报文头是否合法 */ + if ((SrcID == p_2oo2_Ctrl->PeerID) + && (DstID == p_2oo2_Ctrl->LocalID) + && (msgSN == p_2oo2_Ctrl->SN) + && (msgCrc == calcCrc)) + { + /*RxData = p_2oo2_Ctrl->UDP_Cache + 17;*/ + allLen = (CM_INT32)msgLen - 17; + (void)CM_Memcpy(RxData,RxSize,&p_2oo2_Ctrl->UDP_Cache[17],allLen); + *pMsgType = (ENUM_2oo2_MSG_T)type; + + MSCP_LOG_MSG("msgLen = %d, SrcID = %d, DstID = %d, msgSN = %d, type = %d\n",msgLen,SrcID,DstID,msgSN,type); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2OO2_CRASH_RCVOK,5u, + sizeof(CM_UINT32),msgLen, + sizeof(CM_UINT32),SrcID, + sizeof(CM_UINT32),DstID, + sizeof(CM_UINT32),msgSN, + sizeof(CM_UINT8),type); + /*- 跳出 */ + break; + } + else + { + MSCP_LOG_MSG("len=[%d,%d]src=[%d,%d]dst=[%d,%d]cyc=[%d,%d]sn=[%d,%d],crc=[%d,%d]\n", + rxLen, msgLen, SrcID, p_2oo2_Ctrl->PeerID, DstID, p_2oo2_Ctrl->LocalID, + msgSN, p_2oo2_Ctrl->SN,msgCrc,calcCrc); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2OO2_CRASH_RCVERR,10u, + sizeof(CM_INT32),rxLen, + sizeof(CM_UINT32),msgLen, + sizeof(CM_UINT32),SrcID, + sizeof(CM_UINT32),p_2oo2_Ctrl->PeerID, + sizeof(CM_UINT32),DstID, + sizeof(CM_UINT32),p_2oo2_Ctrl->LocalID, + sizeof(CM_UINT32),msgSN, + sizeof(CM_UINT32),p_2oo2_Ctrl->SN, + sizeof(CM_UINT32),msgCrc, + sizeof(CM_UINT32),calcCrc); + } + } + else + { + /*- 无处理 */ + } + } + /* 返回报文总长度 */ + return allLen; +} + +/** +* @breif 全双工2oo2数据交换(进入运营模式后的2取交换,限制时间) +* @param pMyData 本机数据指针 +* @param DataLen 本剧数据长度 +* @param pPeerData 邻机数据指针 +* @param DataSize 邻机数据缓冲区大小 +* @param msgTye 2oo2交换数据类型 +* @return 收到的邻机数据长度 +* @details +* 全双工模式进行2oo2数据交换 +* 每一机均在同一时间向对方发送自己的交换数据 +* 然后立即接收来自邻机的交换数据 +*/ +CM_INT32 SFM_2oo2_Exchange_FullDuplex_Crash( + IN const CM_UINT8* pMyData, + IN CM_INT32 DataLen, + OUT CM_UINT8* pPeerData, + IN CM_UINT32 DataSize, + IN ENUM_2oo2_MSG_T msgType) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = -1; + ENUM_2oo2_MSG_T rxType = ENUM_2oo2_ERROR; + + /*- 入口检查 */ + CM_ASSERT_MAINTAIN((NULL != pMyData) && (NULL != pPeerData)); + CM_ASSERT_MAINTAIN(DataLen >= 0); + + /*- 更新2oo2通信序列号 */ + s_2oo2_Ctrl.SN++; + /*- 发送2oo2数据 */ + s_2oo2_Send_Crash(pMyData, DataLen,&s_2oo2_Ctrl ,msgType); + /*- 接收2oo2数据 */ + rxLen = s_2oo2_Recv_Crash(pPeerData, DataSize, &rxType,&s_2oo2_Ctrl); + CM_ASSERT_MAINTAIN(msgType == rxType); + CM_ASSERT_MAINTAIN(0 <= rxLen); + + /*- 返回接收长度 */ + return rxLen; +} + +/** + * @brief 二取判断是否重置自动重启次数 + * @details 每达到阈值,双机同时清零 + */ +void SFM_2oo2_Reset_AutoRbootCut(void) +{ + /*- 变量初始化 */ + CM_UINT64 tickcur = 0u; /* 当前时间 */ + CM_UINT8 mybuf[1] = {0}; + CM_UINT8 peerbuf[1] = {0}; + CM_INT32 peerlen = 0; + CM_UINT8 cut = 0xFFu; + /*- 获取当前时间 */ + if (0u != g_PFM_Cfg.M_AutoClear_Second) + { + /*- 获取上电时间 */ + tickcur = CM_GetSecTick(); + /*- 上电时间超过清零时间 */ + if (tickcur > g_PFM_Cfg.M_AutoClear_Second) + { + /*- 超过阈值*/ + mybuf[0] = 0x55; + } + else + { + /*- 没超阈值*/ + mybuf[0] = 0xAA; + } + /*- 是否开启2取2开关 */ + if(0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 二取交互状态*/ + peerlen = SFM_2oo2_Exchange_Currency(mybuf,1,peerbuf,1,ENUM_2oo2_RESET_AUTOREBOOT); + CM_RE_ASSERT(peerlen > 0, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_1); + } + /*- 判断双cpu是否同时清零 */ + if((0x55u == mybuf[0]) && (0x55u == peerbuf[0])) + { + /*- 清空自动重启次数*/ + cut = MSCP_Reset_AutoRbootCut(0); + /*- 清空故障远程重启次数*/ + RM_Reset_FaultRbootCut(0); + CM_RE_ASSERT(cut == 0u, SFM_2oo2_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_2); + /*- 同时修改时间阈值*/ + g_PFM_Cfg.M_AutoClear_Second += g_PFM_Cfg.M_AutoClear_Days*24u*60u*60u;; + } + else + { + /*- 无处理 */ + } + } +} + +/** + * @brief 初始化2取控制数据以及清空2取缓冲区 + * @details 初始化和退出运营开始时调用 + */ +void SFM_2oo2_CtrlInit(void) +{ + /*- 初始化2取控制数据 */ + s_2oo2_Ctrl.LocalID = (g_PFM_Cfg.BOARD_ID * 256u) + g_PFM_Cfg.CPU_ID; + s_2oo2_Ctrl.PeerID = CM_UNSIGNED_INT_EXP(((CM_UINT32)g_PFM_Cfg.BOARD_ID * 256u) + (3u - (CM_UINT32)g_PFM_Cfg.CPU_ID)); + s_2oo2_Ctrl.SN = 0u; + s_2oo2_Ctrl.FrameCtrl.FramIndex = 0u; + s_2oo2_Ctrl.FrameCtrl.FrameNum = 0u; + s_2oo2_Ctrl.FrameCtrl.RxLen = 0; + s_2oo2_Ctrl.FrameCtrl.type = 0u; + s_2oo2_Ctrl.DataRecv = CFM_2oo2_DataRecv; + s_2oo2_Ctrl.DataSend = CFM_2oo2_DataSend; + /*- 清空2取缓冲区 */ + (void)memset(s_2oo2_Ctrl.UDP_Cache, 0, sizeof(s_2oo2_Ctrl.UDP_Cache)); + /*- 初始化应用2取结构体参数*/ + s_2oo2_Ctrl_App.LocalID = s_2oo2_Ctrl.LocalID; + s_2oo2_Ctrl_App.PeerID = s_2oo2_Ctrl.PeerID; + s_2oo2_Ctrl_App.SN = 0u; + s_2oo2_Ctrl_App.FrameCtrl.FramIndex = 0u; + s_2oo2_Ctrl_App.FrameCtrl.FrameNum = 0u; + s_2oo2_Ctrl_App.FrameCtrl.RxLen = 0; + s_2oo2_Ctrl_App.FrameCtrl.type = 0u; + s_2oo2_Ctrl_App.DataRecv = CFM_2oo2_DataRecv_App; + s_2oo2_Ctrl_App.DataSend = CFM_2oo2_DataSend_App; + /*- 清空2取缓冲区 */ + (void)memset(s_2oo2_Ctrl_App.UDP_Cache, 0, sizeof(s_2oo2_Ctrl_App.UDP_Cache)); +} diff --git a/TSCP/src/MSCP/SFM/SFM_2oo2.h b/TSCP/src/MSCP/SFM/SFM_2oo2.h new file mode 100644 index 0000000..4efc030 --- /dev/null +++ b/TSCP/src/MSCP/SFM/SFM_2oo2.h @@ -0,0 +1,85 @@ +/** +* @file SFM_2oo2.h +* @brief Safe Function Module:2oo2功能 +* @details +* 2oo2上电初始化:初始化、同步、校验 +* 2oo2周期同步和2oo2数据交换 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef SFM_2oo2_H +#define SFM_2oo2_H +#include "CM_Types.h" +#include "SFM_package.h" +#ifdef __cplusplus +extern "C" +{ +#endif + + /** 2oo2报文类型 */ + typedef enum + { + ENUM_2oo2_ERROR = 0, /**< 保留 */ + ENUM_2oo2_SYNC, /**< 同步 */ + ENUM_2oo2_INIT_CHECK, /**< 上电比较 */ + ENUM_2oo2_INPUT_EX, /**< 输入交换 */ + ENUM_2oo2_INPUT_FULL_EX, /**< 输入全双工交换 */ + ENUM_2oo2_INPUT_MS, /**< 输入热备状态交换 */ + ENUM_2oo2_OUTPUT_EX, /**< 输出交换 */ + ENUM_2oo2_END_EX, /**< 周期末交换 */ + ENUM_2oo2_OUTPUT_CHECK, /**< 输出比较 */ + ENUM_2oo2_RAW_INFO, + ENUM_2oo2_SHUTDOWNQUIT, /**< 维护模式下的2取交换 */ + ENUM_2oo2_RESET_AUTOREBOOT,/*重置自动重启*/ + ENUM_2oo2_ARQ, /*重传请求*/ + ENUM_2oo2_RCV_SUCCESS, /*接收成功标志*/ + ENUM_2oo2_APP, /*应用二取类型*/ + NUM_2oo2_FIRSTSYNC, /**< 同步 */ + }ENUM_2oo2_MSG_T; + + /** 2oo2通信控制 */ + typedef struct + { + CM_UINT32 LocalID; /**< 本机设备ID */ + CM_UINT32 PeerID; /**< 邻机设备ID */ + CM_UINT32 SN; /**< 通信序列号 */ + STRU_FrameCtrl_T FrameCtrl; /**< 分帧接收控制 */ + /*2取发送函数指针注册*/ + ENUM_CM_RETURN (*DataSend)(IN const CM_UINT8* , IN CM_INT32 ); + /*2取接收函数指针注册*/ + CM_INT32 (*DataRecv)(OUT CM_UINT8* , IN CM_UINT32 ); + CM_UINT8 UDP_Cache[NET_UDP_BUF_SIZE]; /*2取分帧收发临时缓冲区*/ + }STRU_2OO2_CTRL_T; + + extern STRU_2OO2_CTRL_T s_2oo2_Ctrl; /**< 平台通信控制 */ + extern STRU_2OO2_CTRL_T s_2oo2_Ctrl_App; /**< 应用通信控制 */ + + /*2oo2上电初始化*/ + void SFM_2oo2_Init(IN const CM_UINT8 *vitalBuf, IN CM_UINT16 vitalLen, OUT CM_UINT64 *p2oo2SyncTick); + + /* 半双工2oo2数据交换 */ + CM_INT32 SFM_2oo2_Exchange_Currency(IN const CM_UINT8 * pMyData, IN CM_INT32 DataLen, OUT CM_UINT8 * pPeerData, IN CM_UINT32 DataSize, IN ENUM_2oo2_MSG_T msgType); + CM_INT32 SFM_2oo2_Currency_App(IN const CM_UINT8 pMyData[], IN CM_INT32 DataLen, OUT CM_UINT8 pPeerData[], IN CM_UINT32 DataSize); + /*2oo2同步*/ + CM_UINT64 SFM_2oo2_Sync(OUT CM_INT64* pOffset); + /* 2oo2关键数据初始化 */ + void SFM_2oo2_DataInit(void); + /* 应用半双工2oo2数据交换 */ + CM_INT32 SFM_2oo2_HalfDuplex_App(IN const CM_UINT8 pMyData[], IN CM_INT32 DataLen, OUT CM_UINT8 pPeerData[], IN CM_UINT32 DataSize); + /* 全双工2oo2数据交换(进入运营模式后的2取交换,限制时间) */ + CM_INT32 SFM_2oo2_Exchange_FullDuplex_Crash(IN const CM_UINT8* pMyData, IN CM_INT32 DataLen, OUT CM_UINT8* pPeerData, IN CM_UINT32 DataSize, IN ENUM_2oo2_MSG_T msgType); + /* 二取判断是否重置自动重启次数 */ + void SFM_2oo2_Reset_AutoRbootCut(void); + /* 初始化2取控制数据以及清空2取缓冲区 */ + void SFM_2oo2_CtrlInit(void); +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/MSCP/SFM/SFM_2x2.c b/TSCP/src/MSCP/SFM/SFM_2x2.c new file mode 100644 index 0000000..db6e776 --- /dev/null +++ b/TSCP/src/MSCP/SFM/SFM_2x2.c @@ -0,0 +1,3321 @@ +/** +* @file SFM_2oo2.c +* @brief Safe Function Module:2x2功能 +* @details +* 2x2上电初始化:初始化、上电同步、比较 +* 输入阶段和输出阶段的双机热备处理 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "SFM_2x2.h" +#include "CM_Convert.h" +#include "CM_Memory.h" +#include "CM_CRC32.h" +#include "CM_Time.h" +#include "CM_RingBuf.h" +#include "DFM_Time.h" +#include "CFM_Net.h" +#include "SFM_2oo2.h" +#include "SFM_Prtcl.h" +#include "SFM_package.h" +#include "PFM_Cfg.h" +#include "PFM_Log.h" +#include "PFM_ControlFlowCheck.h" +#include "DFM_DRV.h" +#include "PFM_SelfCheck.h" +#include "stdarg.h" + +/*通信中断时间和同步超时时间可以相同,此时优先执行通信中断切系*/ + +CM_INT32 g_2x2oo2_base = 0; /**< 2x2oo2双缓冲区的平台索引 */ +CM_INT32 g_2x2oo2_data_num = 0; /**< 2x2oo2的通道总数 */ +STRU_2x2oo2_rx_T g_2x2oo2_rx[2][24]; /**< 2x2oo2的接收双缓冲区 */ +STRU_2x2oo2_tx_T g_2x2oo2_tx[2][24]; /**< 2x2oo2的发送双缓冲区 */ +CM_UINT8 g_2x2RcvMaxNum[2] = {0}; /**< 2x2双缓冲区接收最大序号*/ + +/* +2x2通信帧格式: +4字节 长度(不含自身) +4字节 源ID +4字节 目的ID +4字节 周期号 +4字节 序列号 +1字节 类型 +2字节 帧总数 +2字节 帧序号 +n字节 数据 +4字节 CRC +*/ + +CM_UINT32 g_MSCP_SysCount; /**< 系统周期号 */ + +static CM_INT32 g_RxBaseFollow_len = 0; /**< 收到的平台跟随数据长度 */ +static CM_UINT8 g_RxBaseFollow[SFM_FOLLOW_BUFF_SIZE]; /**< 收到的平台跟随数据报文 */ +static CM_INT32 g_TxBaseFollow_len = 0; /**< 发送的平台跟随数据长度 */ +static CM_UINT8 g_TxBaseFollow[SFM_FOLLOW_BUFF_SIZE]; /**< 发送的平台跟随数据报文 */ +/*4字节长度+m字节协议同步数据+4字节长度+n字节平台跟随数据*/ + +static CM_INT32 g_RxAppFollow_len = 0; /**< 收到的应用跟随数据长度 */ +static CM_UINT8 g_RxAppFollow[MSCP_FOLLOW_BUFF_SIZE*2]; /**< 收到的应用跟随数据报文 */ +static CM_INT32 g_RxAppFollowCrc_len = 0; /**< 收到的应用跟随数据长度 */ +static CM_UINT8 g_RxAppFollowCrc[8]; /**< 收到的应用跟随数据报文 */ +CM_INT32 g_TxAppFollow_len = 0; /**< 发送的应用跟随数据长度 */ +CM_UINT8 g_TxAppFollow[MSCP_FOLLOW_BUFF_SIZE*2]; /**< 发送的应用跟随数据报文 */ + +#define SFM_2x2_TM_RING_SIZE (10) /**< 2x2时钟同步累计的周期数 */ +#define SFM_2x2_TM_FIX_VAL (10) /**< 最小调整偏差 */ +static STRU_CM_RING_T s_2x2_TmRing; /**< 2x2时钟同步数据 */ +static STRU_2X2_CTRL_T s_2x2_Ctrl; /**< 主线程2x2控制 */ +static STRU_2X2_STATE_CTRL_T s_2x2_state_Ctrl; /**< 子线程2x2状态控制 */ +STRU_2X2_STATE_THRRAD_T s_2x2_thread_Ctrl;/**< 子线程2x2参数 */ + +static CM_UINT8 s_2x2_Cache[NET_UDP_BUF_SIZE]; /**< 2x2通信缓冲区 */ +static CM_UINT8 s_2x2_InputIoState[40] = {0}; + +static CM_UINT32 s_2x2_TxSyncLen; /**< 发送2x2同步报文长度 */ +static CM_UINT8 s_2x2_TxSyncMsg[1000]; /**< 发送2x2同步报文 */ + +static CM_INT32 s_2x2_RxSyncLen; /**< 接收2x2同步报文长度 */ +static CM_UINT8 s_2x2_RxSyncMsg[1000]; /**< 接收2x2同步报文 */ +static CM_UINT64 s_2x2_RxSyncTick; /**< 接收2x2同步报文时刻 */ + +static void s_State_Switch(void); +/*2x交互前的系内热备状态同步*/ +static void s_State_2xBefore_2oo2Sync(STRU_2OO2_NET_NO_PACK_T *p_2oo2_Ctrl,OUT STRU_2X2_STATE_CTRL_T *p_peer_state); +/*2x交互后的系内热备状态同步*/ +static void s_State_2xAfter_2oo2Sync(STRU_2OO2_NET_NO_PACK_T *p_2oo2_Ctrl,OUT STRU_2X2_STATE_CTRL_T *p_peer_state); +/*2x通信解析*/ +static CM_BOOL s_State_2x2_Analysis(OUT STRU_2X2_STATE_CTRL_T *p_partner_state,CM_UINT8 *recvbuf,CM_INT32 len); +/*2x状态同步*/ +static ENUM_CM_RETURN s_State_2x2Sync(OUT STRU_2X2_STATE_CTRL_T *p_partner_state); +static void s_State_Transition(void); + +/** +* @brief 2X状态切换独立线程 +*/ +static CM_THREAD_FUNC_T SFM_2x2_StateChange_Thread(void); +/** +* @brief 平台记录格式化字符串日志 +* @param filename 文件路径 +* @param func 函数名 +* @param line 行号 +* @param fmt 格式化字符串 +*/ +static void SFM_2x2_LOG_MSG(IN const CM_CHAR *filename, IN CM_INT32 line, IN const CM_CHAR* fmt, ...); +#define SFM_LOG_MSG_2X(fmt, ...) (SFM_2x2_LOG_MSG(FILENAME(__FILE__),(CM_INT32)__LINE__,(fmt), ##__VA_ARGS__)) +/* 接收2x2报文 */ +static void s_2x2_Recv(void); +/* 系内同步2x2状态 */ +static void s_Ctrl_2oo2Sync(OUT STRU_2X2_CTRL_T *pPeerCtrl); +/* 系内同步2x2输入数据 */ +static void SFM_2x2_Input2oo2Exchange(STRU_2X2_CTRL_T *peerCtrl); +/* 判断2x422以及以太网的通信状况并且填写暗文日志 */ +static void SFM_2x2_Eth422StateDark(void); + +/** +* @brief 切系按钮监督 +* @return 无 +* @details +* 用于监督切系按钮是否被按下3s +*/ +static void s_State_Switch(void) +{ + /*- 变量初始化 */ + static CM_UINT64 s_timeFirst = 0u; + static CM_UINT64 s_timeSecond = 0u; + static CM_BOOL s_timeFlag = CM_FALSE; + static ENUM_2x2_STATE_T s_LocalState; /**< 本系热备状态,2oo2比较 */ + static ENUM_2x2_STATE_T s_PartnerState; /**< 收到的对系热备状态,2oo2交换 */ + CM_INT32 ret = 0; + + if((((ENUM_2x2_MASTER == s_2x2_state_Ctrl.LocalState) && (ENUM_2x2_SLAVE == s_2x2_state_Ctrl.PartnerState)) || + ((ENUM_2x2_SLAVE == s_2x2_state_Ctrl.LocalState) && (ENUM_2x2_MASTER == s_2x2_state_Ctrl.PartnerState))) && + ((ENUM_2x2_SWITCH_CLOSE == s_2x2_state_Ctrl.LocalSwitchState)) && (s_timeFlag == CM_FALSE)) + { + /*- 判断是否连续3s按住切系按钮*/ + ret = DFM_switchButton(); + if(1 == ret) + { + /*- 记录第一次按下的时间*/ + s_timeFirst = CM_GetTick(); + s_timeFlag = CM_TRUE; + /*更新切系参数*/ + s_LocalState = s_2x2_state_Ctrl.LocalState; + s_PartnerState = s_2x2_state_Ctrl.PartnerState; + } + else + { + s_timeFlag = CM_FALSE; + } + } + else + { + /*持续按钮检测*/ + if(s_timeFlag == CM_TRUE) + { + /*- 获取按钮按下结果*/ + ret = DFM_switchButton(); + /*- 如果按下记录档次按下时间,如果未按下跳出监督*/ + if(1 == ret) + { + s_timeSecond = CM_GetTick(); + /*- 当次按下时间距第一次按下时间相差3s,则判断是否需要切系 */ + if(s_timeSecond - s_timeFirst >= MSCP_2X2_SWITCH_3S) + { + /*- 如果未切系则准备切系,如果以切系则休眠后继续等待松开按钮,防止持续按压 */ + if((s_LocalState == s_2x2_state_Ctrl.LocalState) && (s_PartnerState == s_2x2_state_Ctrl.PartnerState)) + { + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_OPEN; + } + else + { + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + } + } + else + { + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + } + } + else + { + s_timeFlag = CM_FALSE; + /* 实际无需清空time变量,导向安全侧则清空 */ + s_timeFirst = 0u; + s_timeSecond = 0u; + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + } + } + else + { + (void)DFM_switchButton(); + } + } + +} +/** +* @brief 2x交互前的系内热备状态同步 +* @param pPeerCtrl 邻机热备信息 +* details +* 系内交换热备信息; +* 校验2oo2双机的热备状态是否一致; +* 系内同步对系连接状态; +* 系内同步收到的状态帧信息。 +*/ +static void s_State_2xBefore_2oo2Sync(STRU_2OO2_NET_NO_PACK_T *p_2oo2_Ctrl,OUT STRU_2X2_STATE_CTRL_T *p_peer_state) +{ + /*- 变量初始化 */ + CM_INT32 rcvlen = -1; + ENUM_CM_RETURN retError = ENUM_CM_FALSE; + /*- 入参检查 */ + CM_ASSERT(NULL != p_peer_state, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_1); + + /*- 系内交换热备状态信息 */ + retError = CM_Memset(p_peer_state, (CM_UINT8)0, sizeof(STRU_2X2_STATE_CTRL_T), sizeof(STRU_2X2_STATE_CTRL_T)); + CM_RE_ASSERT(ENUM_CM_TRUE == retError, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_2); + /*二取本机热备状态、按钮状态、通信状态等、确保双CPU数据一致*/ + rcvlen = CFM_2oo2_Currency_NoSplit(p_2oo2_Ctrl,(CM_UINT8*)&s_2x2_state_Ctrl,sizeof(STRU_2X2_STATE_CTRL_T),(CM_UINT8*)p_peer_state,sizeof(STRU_2X2_STATE_CTRL_T)); + + CM_RE_ASSERT(rcvlen == sizeof(STRU_2X2_STATE_CTRL_T), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_3); + + /*- 校验2oo2双机的热备状态是否一致 */ + /* 本地状态*/ + CM_RE_ASSERT(s_2x2_state_Ctrl.LocalState == p_peer_state->LocalState, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_4); + SFM_LOG_MSG_2X("2oo2:MyoffLineCut = %d, OtheroffLineCut = %d\n",s_2x2_state_Ctrl.offLineCounter,p_peer_state->offLineCounter); + CM_RE_ASSERT(s_2x2_state_Ctrl.offLineCounter == p_peer_state->offLineCounter, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_5); + CM_RE_ASSERT(s_2x2_state_Ctrl.preMasterCounter == p_peer_state->preMasterCounter, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_6); + /* 本地通信状态,主线程2取同步过*/ + CM_RE_ASSERT(s_2x2_state_Ctrl.LastRxInputSysCyc == p_peer_state->LastRxInputSysCyc, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_7); + CM_RE_ASSERT(s_2x2_state_Ctrl.LastFollowCyc == p_peer_state->LastFollowCyc, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_8); + CM_RE_ASSERT(s_2x2_state_Ctrl.LastCheckOKCount == p_peer_state->LastCheckOKCount, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_10); + CM_RE_ASSERT(s_2x2_state_Ctrl.LastLocalState == p_peer_state->LastLocalState, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_11); + CM_RE_ASSERT(s_2x2_state_Ctrl.LastPartnerState == p_peer_state->LastPartnerState, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_12); + CM_RE_ASSERT(s_2x2_state_Ctrl.OutPutCheckFailFlag == p_peer_state->OutPutCheckFailFlag, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_13); + CM_RE_ASSERT(s_2x2_state_Ctrl.AppFollowCmpFlag == p_peer_state->AppFollowCmpFlag,SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_14); + + /*同步按钮状态*/ + s_2x2_state_Ctrl.PeerSwitchState = p_peer_state->LocalSwitchState; + s_2x2_state_Ctrl.PeerAIDSwitchState = p_peer_state->LocalAIDSwitchState; + /*同步输入IO*/ + (void)CM_Memcpy(s_2x2_state_Ctrl.PeerInputIoState,10,p_peer_state->MineInputIoState,10); +} +/** +* @brief 系内热备状态同步 +* @param pPeerCtrl 邻机热备信息 +* details +* 系内交换热备信息; +* 校验2oo2双机的热备状态是否一致; +* 系内同步对系连接状态; +* 系内同步收到的状态帧信息。 +*/ +static void s_State_2xAfter_2oo2Sync(STRU_2OO2_NET_NO_PACK_T *p_2oo2_Ctrl,OUT STRU_2X2_STATE_CTRL_T *p_peer_state) +{ + /*- 变量初始化 */ + CM_INT32 rcvlen = -1; + CM_UINT8 i = 0u; + ENUM_CM_RETURN retError = ENUM_CM_FALSE; + /*- 入参检查 */ + CM_ASSERT(NULL != p_peer_state, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_18, TSCP_DARK_ASSERT_1); + + /*- 系内交换热备状态信息 */ + retError = CM_Memset(p_peer_state, (CM_UINT8)0, sizeof(STRU_2X2_STATE_CTRL_T), sizeof(STRU_2X2_STATE_CTRL_T)); + CM_RE_ASSERT(ENUM_CM_TRUE == retError, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_18, TSCP_DARK_ASSERT_2); + /*二取本机热备状态、按钮状态、通信状态等、确保双CPU数据一致*/ + rcvlen = CFM_2oo2_Currency_NoSplit(p_2oo2_Ctrl,(CM_UINT8*)&s_2x2_state_Ctrl,sizeof(STRU_2X2_STATE_CTRL_T),(CM_UINT8*)p_peer_state,sizeof(STRU_2X2_STATE_CTRL_T)); + CM_RE_ASSERT(rcvlen == sizeof(STRU_2X2_STATE_CTRL_T), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_18, TSCP_DARK_ASSERT_3); + + /*- 系内同步对系连接状态 */ + for(i = 0u;i <= MSCP_2X2_COM_THIS_STATE_NUM;i++) + { + s_2x2_state_Ctrl.PeerComOKCount[i] = p_peer_state->MineComOKCount[i]; + s_2x2_state_Ctrl.PeerUartOKCount[i] = p_peer_state->MineUartOKCount[i]; + } + + /*- @alias 系内同步收到的状态帧 */ + if((s_2x2_state_Ctrl.RxStateSysCyc < p_peer_state->RxStateSysCyc) || + ((s_2x2_state_Ctrl.RxStateSysCyc == p_peer_state->RxStateSysCyc) && (s_2x2_state_Ctrl.RxStateMicroCyc < p_peer_state->RxStateMicroCyc))) + { + /*更新周期号与对系状态*/ + s_2x2_state_Ctrl.RxStateMicroCyc = p_peer_state->RxStateMicroCyc; + s_2x2_state_Ctrl.RxStateSysCyc = p_peer_state->RxStateSysCyc; + s_2x2_state_Ctrl.PartnerState = p_peer_state->PartnerState; + s_2x2_state_Ctrl.LastPartnerState = p_peer_state->LastPartnerState; + /*更新对系所有切系状态*/ + s_2x2_state_Ctrl.PartnerSwitchState = p_peer_state->PartnerSwitchState; + s_2x2_state_Ctrl.PartPeerSwitchState = p_peer_state->PartPeerSwitchState; + s_2x2_state_Ctrl.PartnerAIDSwitchState = p_peer_state->PartnerAIDSwitchState; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = p_peer_state->PartPeerAIDSwitchState; + /*更新对系IO状态*/ + (void)CM_Memcpy(s_2x2_state_Ctrl.RmtMineInputIoState,10,p_peer_state->RmtMineInputIoState,10); + (void)CM_Memcpy(s_2x2_state_Ctrl.RmtPeerInputIoState,10,p_peer_state->RmtPeerInputIoState,10); + SFM_LOG_MSG_2X("2oo2:RxStateSysCyc is small!\n"); + s_2x2_state_Ctrl.RxSN = p_peer_state->RxSN; + } + else + { + /*- 无处理 */ + } + /*时间同步标志*/ + if(s_2x2_state_Ctrl.TimeSyncFlag != p_peer_state->TimeSyncFlag) + { + s_2x2_state_Ctrl.TimeSyncFlag = CM_FALSE; + SFM_LOG_MSG_2X("2oo2:TimeSyncFlag is not sync!\n"); + } + + /*判断切系状态*/ + if((ENUM_2x2_SWITCH_OPEN == s_2x2_state_Ctrl.LocalSwitchState) && + (ENUM_2x2_SWITCH_OPEN == s_2x2_state_Ctrl.PeerSwitchState) && + (ENUM_2x2_SWITCH_OPEN == s_2x2_state_Ctrl.PartnerSwitchState) && + (ENUM_2x2_SWITCH_OPEN == s_2x2_state_Ctrl.PartPeerSwitchState)) + { + s_2x2_state_Ctrl.ctrSwitchFlag = 1u; + SFM_LOG_MSG_2X("The switch button is effective\n"); + } + else if((ENUM_2x2_AIDSWITCH_ENABLE == s_2x2_state_Ctrl.LocalAIDSwitchState) && + (ENUM_2x2_AIDSWITCH_ENABLE == s_2x2_state_Ctrl.PeerAIDSwitchState) && + (ENUM_2x2_AIDSWITCH_ENABLE == s_2x2_state_Ctrl.PartnerAIDSwitchState) && + (ENUM_2x2_AIDSWITCH_ENABLE == s_2x2_state_Ctrl.PartPeerAIDSwitchState)) + { + s_2x2_state_Ctrl.aidSwitchFlag = 1u; + SFM_LOG_MSG_2X("The switch AID is effective\n"); + } + else + { + s_2x2_state_Ctrl.ctrSwitchFlag = 0u; + s_2x2_state_Ctrl.aidSwitchFlag = 0u; + } +} +/** +* @brief 2x热备状态解析 +* @param pPeerCtrl 邻机热备信息 +* details +* 系内交换热备信息; +* 校验2oo2双机的热备状态是否一致; +* 系内同步对系连接状态; +* 系内同步收到的状态帧信息。 +*/ +static CM_BOOL s_State_2x2_Analysis(OUT STRU_2X2_STATE_CTRL_T *p_partner_state,CM_UINT8 *recvbuf,CM_INT32 len) +{ + CM_BOOL rtn = CM_FALSE; + CM_UINT32 msglen = 0; + CM_UINT32 rcv_offset = 0u; + CM_UINT32 current_time = (CM_UINT32)(CM_GetTick()/CM_UNSIGNED_MILLION);/*当前时间戳ms*/ + CM_UINT32 time_stamp = CM_LongFromChar(&recvbuf[rcv_offset]);/*接收时间戳ms*/ + rcv_offset = 6; + msglen = CM_LongFromChar(&recvbuf[rcv_offset]); + rcv_offset += 4u; + p_partner_state->LocalID = CM_LongFromChar(&recvbuf[rcv_offset]); + rcv_offset += 4u; + p_partner_state->PartnerID = CM_LongFromChar(&recvbuf[rcv_offset]); + rcv_offset += 4u; + p_partner_state->TxSN = CM_LongFromChar(&recvbuf[rcv_offset]); + rcv_offset += 4u; + p_partner_state->SysCyc = CM_LongFromChar(&recvbuf[rcv_offset]); + rcv_offset += 4u; + p_partner_state->MicroCyc = recvbuf[rcv_offset]; + rcv_offset ++; + p_partner_state->LocalState = CM_LongFromChar(&recvbuf[rcv_offset]); + rcv_offset += 4u; + p_partner_state->LastLocalState = CM_LongFromChar(&recvbuf[rcv_offset]); + rcv_offset += 4u; + /*解析切系状态*/ + p_partner_state->LocalSwitchState = recvbuf[rcv_offset++]; + p_partner_state->PeerSwitchState = recvbuf[rcv_offset++]; + p_partner_state->LocalAIDSwitchState = recvbuf[rcv_offset++]; + p_partner_state->PeerAIDSwitchState = recvbuf[rcv_offset++]; + /*接收IO数据*/ + (void)CM_Memcpy(&p_partner_state->RmtMineInputIoState[0],10,&recvbuf[rcv_offset],10); + rcv_offset += 10u; + (void)CM_Memcpy(&p_partner_state->RmtPeerInputIoState[0],10,&recvbuf[rcv_offset],10); + rcv_offset += 10u; + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_ANALYSIS_DATA,17u, + sizeof(CM_UINT32),p_partner_state->LocalID, + sizeof(CM_UINT32),s_2x2_state_Ctrl.LocalID, + sizeof(CM_UINT32),p_partner_state->PartnerID, + sizeof(CM_UINT32),s_2x2_state_Ctrl.PartnerID, + sizeof(CM_UINT32),p_partner_state->SysCyc, + sizeof(CM_UINT32),s_2x2_state_Ctrl.RxStateSysCyc, + sizeof(CM_UINT8),p_partner_state->MicroCyc, + sizeof(CM_UINT8),s_2x2_state_Ctrl.MicroCyc, + sizeof(CM_UINT32),p_partner_state->TxSN, + sizeof(CM_UINT32),s_2x2_state_Ctrl.RxSN, + sizeof(CM_UINT32),s_2x2_state_Ctrl.LocalAIDSwitchState, + sizeof(CM_UINT32),s_2x2_state_Ctrl.PartnerAIDSwitchState, + sizeof(CM_UINT32),p_partner_state->LocalState, + sizeof(CM_UINT32),s_2x2_state_Ctrl.PartnerState, + sizeof(CM_UINT32),p_partner_state->LastLocalState, + sizeof(CM_UINT32),s_2x2_state_Ctrl.LastPartnerState, + sizeof(CM_UINT32),(current_time - time_stamp)); + if((msglen == (len - 4u - 6u)) && + (p_partner_state->LocalID == s_2x2_state_Ctrl.PartnerID) && + (p_partner_state->PartnerID == s_2x2_state_Ctrl.LocalID) && + (p_partner_state->SysCyc >= s_2x2_state_Ctrl.RxStateSysCyc) && + ((current_time - time_stamp) <= MSCP_2X2_STATE_OVER_TIME)) + { + if((p_partner_state->TxSN > s_2x2_state_Ctrl.RxSN)) + { + s_2x2_state_Ctrl.RxStateMicroCyc = p_partner_state->MicroCyc; + s_2x2_state_Ctrl.RxStateSysCyc = p_partner_state->SysCyc; + s_2x2_state_Ctrl.RxSN = p_partner_state->TxSN; + s_2x2_state_Ctrl.PartnerState = p_partner_state->LocalState; + s_2x2_state_Ctrl.LastPartnerState = p_partner_state->LastLocalState; + /*记录对系所有接收状态*/ + s_2x2_state_Ctrl.PartnerSwitchState = p_partner_state->LocalSwitchState; + s_2x2_state_Ctrl.PartPeerSwitchState = p_partner_state->PeerSwitchState; + s_2x2_state_Ctrl.PartnerAIDSwitchState = p_partner_state->LocalAIDSwitchState; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = p_partner_state->PeerAIDSwitchState; + /*记录对系IO状态*/ + (void)CM_Memcpy(s_2x2_state_Ctrl.RmtMineInputIoState,10,p_partner_state->RmtMineInputIoState,10); + (void)CM_Memcpy(s_2x2_state_Ctrl.RmtPeerInputIoState,10,p_partner_state->RmtPeerInputIoState,10); + SFM_LOG_MSG_2X("Analysis:OK[%d]2x2Sync-LID:0x%x-0x%x,PID:0x%x-0x%x,Scyc:%d-%d,Mcyc:%d-%d,SN:%d-%d,AID:%d-%d,State:%d-%d,LastState:%d-%d,TDv:%dms\n",s_2x2_state_Ctrl.MicroCyc, + p_partner_state->LocalID,s_2x2_state_Ctrl.LocalID,p_partner_state->PartnerID,s_2x2_state_Ctrl.PartnerID, + p_partner_state->SysCyc,s_2x2_state_Ctrl.RxStateSysCyc,p_partner_state->MicroCyc,s_2x2_state_Ctrl.MicroCyc, + p_partner_state->TxSN,s_2x2_state_Ctrl.RxSN,s_2x2_state_Ctrl.LocalAIDSwitchState,s_2x2_state_Ctrl.PartnerAIDSwitchState, + p_partner_state->LocalState,s_2x2_state_Ctrl.PartnerState,p_partner_state->LastLocalState,s_2x2_state_Ctrl.LastPartnerState, + (current_time - time_stamp)); + } + else + { + + } + rtn = CM_TRUE; + } + else + { + SFM_LOG_MSG_2X("Analysis:fail[%d]2x2Sync-LID:0x%x-0x%x,PID:0x%x-0x%x,Scyc:%d-%d,Mcyc:%d-%d,SN:%d-%d,AID:%d-%d,State:%d-%d,LastState:%d-%d,TDv:%dms\n",s_2x2_state_Ctrl.MicroCyc, + p_partner_state->LocalID,s_2x2_state_Ctrl.LocalID,p_partner_state->PartnerID,s_2x2_state_Ctrl.PartnerID, + p_partner_state->SysCyc,s_2x2_state_Ctrl.RxStateSysCyc,p_partner_state->MicroCyc,s_2x2_state_Ctrl.MicroCyc, + p_partner_state->TxSN,s_2x2_state_Ctrl.RxSN,s_2x2_state_Ctrl.LocalAIDSwitchState,s_2x2_state_Ctrl.PartnerAIDSwitchState, + p_partner_state->LocalState,s_2x2_state_Ctrl.PartnerState,p_partner_state->LastLocalState,s_2x2_state_Ctrl.LastPartnerState, + (current_time - time_stamp)); + rtn = CM_FALSE; + } + return rtn; +} +/** +* @brief 2x热备状态同步 +* @param pPeerCtrl 邻机热备信息 +* details +* 系内交换热备信息; +* 校验2oo2双机的热备状态是否一致; +* 系内同步对系连接状态; +* 系内同步收到的状态帧信息。 +*/ +static ENUM_CM_RETURN s_State_2x2Sync(OUT STRU_2X2_STATE_CTRL_T *p_partner_state) +{ + /*- 变量初始化 */ + CM_INT32 rcvlen = -1; + CM_UINT8 sendbuf[200] = {0u}; + CM_UINT8 recvbuf[200] = {0u}; + CM_UINT32 send_offset = 0u; + ENUM_CM_RETURN retError = ENUM_CM_FALSE; + CM_BOOL rtnCheck = CM_FALSE; + CM_UINT64 curTick1 = 0u; /* 当前时刻 */ + CM_UINT64 curTick2 = 0u; /* 当前时刻 */ + CM_UINT64 curTick3 = 0u; /* 当前时刻 */ + CM_UINT64 sTick = 0u; /* 起始Tick */ + /*- 入参检查 */ + CM_ASSERT(NULL != p_partner_state, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_16, TSCP_DARK_ASSERT_1); + + /*- 系内交换热备状态信息 */ + retError = CM_Memset(p_partner_state, (CM_UINT8)0, sizeof(STRU_2X2_STATE_CTRL_T), sizeof(STRU_2X2_STATE_CTRL_T)); + CM_RE_ASSERT(ENUM_CM_TRUE == retError, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_16, TSCP_DARK_ASSERT_2); + send_offset = 4u; + /*本机ID*/ + CM_LongToChar(s_2x2_state_Ctrl.LocalID, &sendbuf[send_offset]); + send_offset += 4u; + /*对系ID*/ + CM_LongToChar(s_2x2_state_Ctrl.PartnerID, &sendbuf[send_offset]); + send_offset += 4u; + /*累加SN码*/ + s_2x2_state_Ctrl.TxSN++; + CM_LongToChar(s_2x2_state_Ctrl.TxSN, &sendbuf[send_offset]); + send_offset += 4u; + /*系统周期号*/ + CM_LongToChar(s_2x2_state_Ctrl.SysCyc, &sendbuf[send_offset]); + send_offset += 4u; + /*微周期号*/ + sendbuf[send_offset++] = s_2x2_state_Ctrl.MicroCyc; + /*本机当前状态*/ + CM_LongToChar(s_2x2_state_Ctrl.LocalState, &sendbuf[send_offset]); + send_offset += 4u; + /*本机上周期状态*/ + CM_LongToChar(s_2x2_state_Ctrl.LastLocalState, &sendbuf[send_offset]); + send_offset += 4u; + /*切系按钮状态*/ + sendbuf[send_offset++] = s_2x2_state_Ctrl.LocalSwitchState; + sendbuf[send_offset++] = s_2x2_state_Ctrl.PeerSwitchState; + /*AID切系状态*/ + sendbuf[send_offset++] = s_2x2_state_Ctrl.LocalAIDSwitchState; + sendbuf[send_offset++] = s_2x2_state_Ctrl.PeerAIDSwitchState; + /*IO状态组包*/ + (void)CM_Memcpy(&sendbuf[send_offset],10,s_2x2_state_Ctrl.MineInputIoState,10); + send_offset += 10u; + (void)CM_Memcpy(&sendbuf[send_offset],10,s_2x2_state_Ctrl.PeerInputIoState,10); + send_offset += 10u; + + CM_LongToChar(send_offset - 4u, &sendbuf[0u]); /*长度*/ + + /*2x交互本机2取后的热备状态、按钮状态、通信状态等*/ + CFM_2x2_StateChange_Send(sendbuf,(CM_INT32)send_offset); + /*- 串口通信通道向对系发送 */ + CFM_2x2_UartDataSend(sendbuf,(CM_UINT16)send_offset); + + sTick = CM_GetTick(); + CM_Sleep(MSCP_2X2_STATE_RCV_WITETIME); + /*- 记录当前时间*/ + curTick1 = CM_GetTick(); + do + { + rcvlen = CFM_2x2_StateChange_Recv(recvbuf,200); + if(rcvlen > 0) + { + /*解析2x数据*/ + rtnCheck = s_State_2x2_Analysis(p_partner_state,recvbuf,rcvlen); + if(CM_TRUE == rtnCheck) + { + /*更新通信状态*/ + MSCP_UpData_2X_This_ComState(&s_2x2_state_Ctrl.MineComOKCount[0],s_2x2_state_Ctrl.SysCyc,s_2x2_state_Ctrl.MicroCyc); + if(p_partner_state->MicroCyc == s_2x2_state_Ctrl.MicroCyc) + { + break; + } + } + else + { + SFM_LOG_MSG_2X("2x2Sync:[%d]udp_2x2Sync-LID:0x%x-0x%x,PID:0x%x-0x%x,Scyc:%d-%d,Mcyc:%d-%d,SN:%d-%d\n",s_2x2_state_Ctrl.MicroCyc, + p_partner_state->LocalID,s_2x2_state_Ctrl.LocalID,p_partner_state->PartnerID,s_2x2_state_Ctrl.PartnerID, + p_partner_state->SysCyc,s_2x2_state_Ctrl.RxStateSysCyc,p_partner_state->MicroCyc,s_2x2_state_Ctrl.MicroCyc, + p_partner_state->TxSN,s_2x2_state_Ctrl.RxSN); + } + } + else + { + + } + }while(rcvlen > 0); + curTick2 = CM_GetTick(); + do + { + rcvlen = CFM_2x2_UartDataRecv(recvbuf,100); + if(rcvlen > 0) + { + /*解析2x数据*/ + rtnCheck = s_State_2x2_Analysis(p_partner_state,recvbuf,rcvlen); + if(CM_TRUE == rtnCheck) + { + /*更新通信状态*/ + MSCP_UpData_2X_This_ComState(&s_2x2_state_Ctrl.MineUartOKCount[0],s_2x2_state_Ctrl.SysCyc,s_2x2_state_Ctrl.MicroCyc); + if(p_partner_state->MicroCyc == s_2x2_state_Ctrl.MicroCyc) + { + break; + } + } + else + { + SFM_LOG_MSG_2X("2x2Sync:[%d]uart_2x2Sync-LID:0x%x-0x%x,PID:0x%x-0x%x,Scyc:%d-%d,Mcyc:%d-%d,SN:%d-%d\n",s_2x2_state_Ctrl.MicroCyc, + p_partner_state->LocalID,s_2x2_state_Ctrl.LocalID,p_partner_state->PartnerID,s_2x2_state_Ctrl.PartnerID, + p_partner_state->SysCyc,s_2x2_state_Ctrl.RxStateSysCyc,p_partner_state->MicroCyc,s_2x2_state_Ctrl.MicroCyc, + p_partner_state->TxSN,s_2x2_state_Ctrl.RxSN); + } + } + else + { + + } + }while(rcvlen > 0); + curTick3 = CM_GetTick(); + SFM_LOG_MSG_2X("2x2Sync:[%d]2x2Sync-recvTime:[%lldms][%lldms][%lldms]\n",s_2x2_state_Ctrl.MicroCyc,(curTick1 - sTick)/1000000,(curTick2 - sTick)/1000000,(curTick3 - sTick)/1000000); + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_ANALYSIS_TIME,4u, + sizeof(CM_UINT8),s_2x2_state_Ctrl.MicroCyc, + sizeof(CM_UINT32),(curTick1 - sTick)/1000000u, + sizeof(CM_UINT32),(curTick2 - sTick)/1000000u, + sizeof(CM_UINT32),(curTick3 - sTick)/1000000u); + return retError; +} +/** +* @brief 2x2状态机更新 +* @details +* 主系在输入微周期更新 +* 非主系在输出微周期更新 +*/ +static void s_State_Transition(void) +{ + /*- 变量初始化 */ + CM_UINT8 boardID = 0u; /* 板卡ID */ + static CM_UINT32 dropCount = 0u; + ENUM_CM_RETURN Flag_Sick_Down = ENUM_CM_FALSE; /* TODO:如果自己健康度不足以升主 */ + ENUM_2x2_STATE_T TempState = ENUM_2x2_SHUTDOWN; /*临时状态*/ + + boardID = g_PFM_Cfg.BOARD_ID; + SFM_LOG_MSG_2X("Transition:[%d]MineCom:%d-%d:%d-%d:%d-%d\r\n",s_2x2_state_Ctrl.MicroCyc,\ + s_2x2_state_Ctrl.MineComOKCount[0].SysCyc,s_2x2_state_Ctrl.MineComOKCount[0].MicroCyc,\ + s_2x2_state_Ctrl.MineComOKCount[1].SysCyc,s_2x2_state_Ctrl.MineComOKCount[1].MicroCyc,\ + s_2x2_state_Ctrl.MineComOKCount[2].SysCyc,s_2x2_state_Ctrl.MineComOKCount[2].MicroCyc); + SFM_LOG_MSG_2X("Transition:[%d]PeerCom:%d-%d:%d-%d:%d-%d\r\n",s_2x2_state_Ctrl.MicroCyc,\ + s_2x2_state_Ctrl.PeerComOKCount[0].SysCyc,s_2x2_state_Ctrl.PeerComOKCount[0].MicroCyc,\ + s_2x2_state_Ctrl.PeerComOKCount[1].SysCyc,s_2x2_state_Ctrl.PeerComOKCount[1].MicroCyc,\ + s_2x2_state_Ctrl.PeerComOKCount[2].SysCyc,s_2x2_state_Ctrl.PeerComOKCount[2].MicroCyc); + SFM_LOG_MSG_2X("Transition:[%d]MineUart:%d-%d:%d-%d:%d-%d\r\n",s_2x2_state_Ctrl.MicroCyc,\ + s_2x2_state_Ctrl.MineUartOKCount[0].SysCyc,s_2x2_state_Ctrl.MineUartOKCount[0].MicroCyc,\ + s_2x2_state_Ctrl.MineUartOKCount[1].SysCyc,s_2x2_state_Ctrl.MineUartOKCount[1].MicroCyc,\ + s_2x2_state_Ctrl.MineUartOKCount[2].SysCyc,s_2x2_state_Ctrl.MineUartOKCount[2].MicroCyc); + SFM_LOG_MSG_2X("Transition:[%d]PeerUart:%d-%d:%d-%d:%d-%d\r\n",s_2x2_state_Ctrl.MicroCyc,\ + s_2x2_state_Ctrl.PeerUartOKCount[0].SysCyc,s_2x2_state_Ctrl.PeerUartOKCount[0].MicroCyc,\ + s_2x2_state_Ctrl.PeerUartOKCount[1].SysCyc,s_2x2_state_Ctrl.PeerUartOKCount[1].MicroCyc,\ + s_2x2_state_Ctrl.PeerUartOKCount[2].SysCyc,s_2x2_state_Ctrl.PeerUartOKCount[2].MicroCyc); + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_COM_STATE,25u, + sizeof(CM_UINT8),s_2x2_state_Ctrl.MicroCyc, + sizeof(CM_UINT32),s_2x2_state_Ctrl.MineComOKCount[0].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.MineComOKCount[0].MicroCyc,\ + sizeof(CM_UINT32),s_2x2_state_Ctrl.MineComOKCount[1].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.MineComOKCount[1].MicroCyc,\ + sizeof(CM_UINT32),s_2x2_state_Ctrl.MineComOKCount[2].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.MineComOKCount[2].MicroCyc, + sizeof(CM_UINT32),s_2x2_state_Ctrl.PeerComOKCount[0].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.PeerComOKCount[0].MicroCyc,\ + sizeof(CM_UINT32),s_2x2_state_Ctrl.PeerComOKCount[1].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.PeerComOKCount[1].MicroCyc,\ + sizeof(CM_UINT32),s_2x2_state_Ctrl.PeerComOKCount[2].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.PeerComOKCount[2].MicroCyc, + sizeof(CM_UINT32),s_2x2_state_Ctrl.MineUartOKCount[0].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.MineUartOKCount[0].MicroCyc,\ + sizeof(CM_UINT32),s_2x2_state_Ctrl.MineUartOKCount[1].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.MineUartOKCount[1].MicroCyc,\ + sizeof(CM_UINT32),s_2x2_state_Ctrl.MineUartOKCount[2].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.MineUartOKCount[2].MicroCyc, + sizeof(CM_UINT32),s_2x2_state_Ctrl.PeerUartOKCount[0].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.PeerUartOKCount[0].MicroCyc,\ + sizeof(CM_UINT32),s_2x2_state_Ctrl.PeerUartOKCount[1].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.PeerUartOKCount[1].MicroCyc,\ + sizeof(CM_UINT32),s_2x2_state_Ctrl.PeerUartOKCount[2].SysCyc,sizeof(CM_UINT8),s_2x2_state_Ctrl.PeerUartOKCount[2].MicroCyc); + /*- 是否与对系通信中断 */ + if ((CM_FALSE == MSCP_Get_2X_VagueCom_State(&s_2x2_state_Ctrl.MineComOKCount[0])) && + (CM_FALSE == MSCP_Get_2X_VagueCom_State(&s_2x2_state_Ctrl.PeerComOKCount[0])) && + (CM_FALSE == MSCP_Get_2X_VagueCom_State(&s_2x2_state_Ctrl.MineUartOKCount[0])) && + (CM_FALSE == MSCP_Get_2X_VagueCom_State(&s_2x2_state_Ctrl.PeerUartOKCount[0])) && + ((s_2x2_thread_Ctrl.number_Cyc - 2) <= s_2x2_state_Ctrl.MicroCyc)) + { + /*- 当本系为离线状态,失去链接后对系最后的状态为主系或者备系,本系离线系宕机 */ + if((ENUM_2x2_SLAVE == s_2x2_state_Ctrl.PartnerState) || (ENUM_2x2_MASTER == s_2x2_state_Ctrl.PartnerState)) + { + if(ENUM_2x2_OFFLINE == s_2x2_state_Ctrl.LocalState) + { + CM_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + } + } + /*- 将对系状态置为宕机 */ + s_2x2_state_Ctrl.PartnerState = ENUM_2x2_SHUTDOWN; + /*通信SN号清空-防止对系重新上电后不接收新的SN号*/ + s_2x2_state_Ctrl.RxSN = 0u; + } + else + { + /*- 无处理 */ + } + /*- 热备状态 */ + switch (s_2x2_state_Ctrl.LocalState) + { + case ENUM_2x2_SHUTDOWN: /*-< 宕机 */ + /*- 停留在宕机状态 */ + CM_RE_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + /*- 返回 */ + break; + case ENUM_2x2_OFFLINE: /*-< 离线 */ + /*- 自己健康度是否不足 */ + if (ENUM_CM_TRUE == Flag_Sick_Down) + { + /*- 自己保持离线 */ + } + /*- 对系是否为主 */ + else if (ENUM_2x2_MASTER == s_2x2_state_Ctrl.PartnerState) + { + /*- 对方是主,尝试与对方同步 */ + /*- 是否与对系同步成功 */ + if ((s_2x2_state_Ctrl.SysCyc == (s_2x2_state_Ctrl.LastRxInputSysCyc + 1)) && + (s_2x2_state_Ctrl.SysCyc == (s_2x2_state_Ctrl.LastFollowCyc + 1)) && + (s_2x2_state_Ctrl.SysCyc == s_2x2_state_Ctrl.LastCheckOKCount) && + (0u == s_2x2_state_Ctrl.OutPutCheckFailFlag) && + (CM_TRUE == s_2x2_state_Ctrl.TimeSyncFlag) && + (0u == s_2x2_state_Ctrl.AppFollowCmpFlag)) + { + /*- 同步成功自己转为备系 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_SLAVE; + SFM_LOG_MSG_2X("Transition:2x2:OFFLINE>>>>>>>SLAVE\n"); + } + else + { + /*- 无处理 */ + SFM_LOG_MSG_2X("Transition:2x2:OFFLINE>SLAVE SysCyc:%d,BF:%d,AF:%d,COK:%d,OUT:%d,TS:%d,AFC:%d\n", + s_2x2_state_Ctrl.SysCyc,s_2x2_state_Ctrl.LastRxInputSysCyc, + s_2x2_state_Ctrl.LastCheckOKCount,s_2x2_state_Ctrl.OutPutCheckFailFlag, + s_2x2_state_Ctrl.TimeSyncFlag, + s_2x2_state_Ctrl.AppFollowCmpFlag); + } + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_FOLLOW_STATE,7u, + sizeof(CM_UINT32),s_2x2_state_Ctrl.SysCyc, + sizeof(CM_UINT32),s_2x2_state_Ctrl.LastRxInputSysCyc, + sizeof(CM_UINT32),s_2x2_state_Ctrl.LastFollowCyc, + sizeof(CM_UINT32),s_2x2_state_Ctrl.LastCheckOKCount, + sizeof(CM_UINT32),s_2x2_state_Ctrl.OutPutCheckFailFlag, + sizeof(CM_UINT8),s_2x2_state_Ctrl.TimeSyncFlag, + sizeof(CM_UINT8),s_2x2_state_Ctrl.AppFollowCmpFlag); + } + /*- 对系是否为预升主 */ + else if (ENUM_2x2_PRE_MASTER == s_2x2_state_Ctrl.PartnerState) + { + /*对方是预升主,等待对方升主*/ + } + /*- 本系的离线计时是否达到离线保持门限 */ + else if (s_2x2_state_Ctrl.offLineCounter >= (MSCP_2x2_OFFLINE_WAIT * (s_2x2_thread_Ctrl.number_Cyc - 1u))) + { + /*对系离线持续足够长时间,自己才可以转为预升主*/ + /*TODO:钥匙允许自己升主*/ + /*- 本系转为预升主 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_PRE_MASTER; + SFM_LOG_MSG_2X("Transition:2x2:OFFLINE>>>>>>>PRE_MASTER\n"); + } + else + { + /*- 保持离线 */ + } + + /*- @alias 更新离线计时器 */ + if (ENUM_2x2_OFFLINE != s_2x2_state_Ctrl.LocalState) + { + /*如果自己将离开离线状态,复位离线计时器*/ + s_2x2_state_Ctrl.offLineCounter = 0u; + } + else if ((ENUM_2x2_OFFLINE == s_2x2_state_Ctrl.PartnerState) || (ENUM_2x2_SHUTDOWN == s_2x2_state_Ctrl.PartnerState)) + { + /*如果对系宕机或离线,累积离线计时*/ + if (s_2x2_state_Ctrl.offLineCounter <= (MSCP_2x2_OFFLINE_WAIT * (s_2x2_thread_Ctrl.number_Cyc - 1u))) + { + s_2x2_state_Ctrl.offLineCounter++; + } + else + { + /*- 无处理 */ + } + } + else + { + /*不满足条件,复位离线计时*/ + s_2x2_state_Ctrl.offLineCounter = 0u; + } + /*- 返回 */ + break; + case ENUM_2x2_PRE_MASTER:/*-< 预升主 */ + /*- 自己是否健康度不足 */ + if (ENUM_CM_TRUE == Flag_Sick_Down) + { + /*- 本系转离线 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_OFFLINE; + SFM_LOG_MSG_2X("Transition:2x2:PRE_MASTER>>>>>>>OFFLINE(Unhealthy)\n"); + } + /*TODO:如果钥匙不允许自己升主,则自己离线*/ + /*- 对系是否为主或备 */ + else if ((ENUM_2x2_MASTER == s_2x2_state_Ctrl.PartnerState) || (ENUM_2x2_SLAVE == s_2x2_state_Ctrl.PartnerState)) + { + /*只要对方状态好,自己就不再预升主(走到这里其实对方不可能是备系,故障-安全措施)*/ + /*- 本系转离线 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_OFFLINE; + SFM_LOG_MSG_2X("Transition:2x2:PRE_MASTER>>>>>>>OFFLINE(Other Master)\n"); + } + /*- 是否是本系为B系且对系预升主 */ + else if ((ENUM_2x2_PRE_MASTER == s_2x2_state_Ctrl.PartnerState) && (MSCP_MAIN_B == boardID)) + { + /*如果对系是预升主,而自己是B系,则让给对系*/ + /*- 本系转离线 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_OFFLINE; + SFM_LOG_MSG_2X("Transition:2x2:PRE_MASTER>>>>>>>OFFLINE(Other A will Master)\n"); + } + /*- 预升主计时是否达到了预升主等待时间 */ + else if (s_2x2_state_Ctrl.preMasterCounter >= (MSCP_2x2_PREMASTER_WAIT * (s_2x2_thread_Ctrl.number_Cyc - 1u))) + { + /*如果自己预升主等待了足够长时间,则自己升主*/ + /*- 本系升主 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_MASTER; + SFM_LOG_MSG_2X("Transition:2x2:PRE_MASTER>>>>>>>MASTER!!!(Will Master Success)\n"); + } + else + { + /*- 保持预升主 */ + } + + /*- @alias 更新预升主计时器 */ + if (ENUM_2x2_PRE_MASTER != s_2x2_state_Ctrl.LocalState) + { + /*如果自己将离开预升主状态,复位离线计时器*/ + s_2x2_state_Ctrl.preMasterCounter = 0u; + } + else + { + if (s_2x2_state_Ctrl.preMasterCounter <= (MSCP_2x2_PREMASTER_WAIT * (s_2x2_thread_Ctrl.number_Cyc - 1u))) + { + s_2x2_state_Ctrl.preMasterCounter++; + } + else + { + /*- 无处理 */ + } + } + /*- 返回 */ + break; + case ENUM_2x2_MASTER:/*-< 主系 */ + /*如果健康度表示需要切系,则自己降离线*/ + /*- 自己是否健康度不足 */ + if (ENUM_CM_TRUE == Flag_Sick_Down) + { + /*- 本系降离线 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_OFFLINE; + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartnerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartPeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.LocalAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.ctrSwitchFlag = 0u; + s_2x2_state_Ctrl.aidSwitchFlag = 0u; +#if 0 + s_2x2_state_Ctrl.RxBaseFollowSysCyc = 0u; /**< 收到的对系跟随数据的周期号,2oo2交换 */ + s_2x2_state_Ctrl.RxAppFollowSysCyc = 0u; /**< 收到的对系应用跟随数据的周期号,2oo2交换 */ + s_2x2_state_Ctrl.LastFollowCyc = 0u; /**< 上次进行平台跟随的时间,2oo2比较,*/ + s_2x2_state_Ctrl.LastAppFollowCyc = 0u; /**< 上次进行应用跟随的时间,2oo2比较,*/ +#endif + SFM_LOG_MSG_2X("Transition:2x2:MASTER>>>>>>>OFFLINE(Unhealthy)\n"); + } + else if(((ENUM_2x2_MASTER == s_2x2_state_Ctrl.PartnerState) || (ENUM_2x2_SLAVE == s_2x2_state_Ctrl.PartnerState)) && /*对系为备系或主系*/ + ((ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineComOKCount[0],0u)) || + (ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerComOKCount[0],0u)) || + (ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineUartOKCount[0],0u)) || + (ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerUartOKCount[0],0u))) && /*本周期任一通道正常通信*/ + ((s_2x2_state_Ctrl.RxStateMicroCyc != s_2x2_state_Ctrl.MicroCyc) || (s_2x2_state_Ctrl.RxStateSysCyc != s_2x2_state_Ctrl.SysCyc)))/*接收对系周期号错误*/ + { + /*防护因旧数据导致的双主问题*/ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_OFFLINE; + SFM_LOG_MSG_2X("Transition:2x2:MASTER>>>>>>>OFFLINE!!!(Old Data)\n"); + /* CM_RE_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_4); */ + } + else if(ENUM_2x2_MASTER == s_2x2_state_Ctrl.PartnerState) + { + /*双主恢复上周期状态,如果上周期也全部为主则宕机*/ + if((ENUM_2x2_MASTER == s_2x2_state_Ctrl.LastLocalState) && (ENUM_2x2_MASTER == s_2x2_state_Ctrl.LastPartnerState)) + { + /*- 检测到对系是主系,本系宕机*/ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_SHUTDOWN; + SFM_LOG_MSG_2X("Transition:2x2:MASTER>>>>>>>Double MASTER!!!(Shut Down)\n"); + CM_RE_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_3); + } + else + { + /*恢复上周期状态*/ + SFM_LOG_MSG_2X("Transition:2x2:Double MASTER Recovery!!!(Last State)\n"); + s_2x2_state_Ctrl.LocalState = s_2x2_state_Ctrl.LastLocalState; + TempState = s_2x2_state_Ctrl.LastPartnerState; + s_2x2_state_Ctrl.LastPartnerState = s_2x2_state_Ctrl.PartnerState; + s_2x2_state_Ctrl.PartnerState = TempState; + } + + } + else if((ENUM_2x2_SLAVE == s_2x2_state_Ctrl.PartnerState) && (ENUM_2x2_SWITCH_OPEN == s_2x2_state_Ctrl.LocalSwitchState) && + (ENUM_2x2_SWITCH_OPEN == s_2x2_state_Ctrl.PartnerSwitchState) && (1u == s_2x2_state_Ctrl.ctrSwitchFlag) && (0u == s_2x2_state_Ctrl.MicroCyc)) + { + /*- 检测到对系是备系,且双系切系按钮状态为ENUM_2x2_SWITCH_OPEN,主系降为备系*/ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_SLAVE; + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartnerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartPeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.LocalAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.ctrSwitchFlag = 0u; + s_2x2_state_Ctrl.aidSwitchFlag = 0u; + SFM_LOG_MSG_2X("Transition:2x2:MASTER>>>>>>>SLAVE(SWITCH)\n"); + } + else if((ENUM_2x2_SLAVE == s_2x2_state_Ctrl.PartnerState) && (1u == s_2x2_state_Ctrl.aidSwitchFlag) && (0u == s_2x2_state_Ctrl.MicroCyc)) + { + /*- 检测到对系是备系,且允许AID切系, 主系降为备系*/ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_SLAVE; + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartnerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartPeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.LocalAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.ctrSwitchFlag = 0u; + s_2x2_state_Ctrl.aidSwitchFlag = 0u; + SFM_LOG_MSG_2X("Transition:2x2:MASTER>>>>>>>SLAVE(AID SWITCH)\n"); + } + else + { + /*- 无处理 */ + } + /*- 返回 */ + break; + case ENUM_2x2_SLAVE:/*-< 备系 */ + /*- 自己是否健康度不足 */ + if (ENUM_CM_TRUE == Flag_Sick_Down) + { + /*- 本系降离线 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_OFFLINE; + SFM_LOG_MSG_2X("Transition:2x2:SLAVE>>>>>>>OFFLINE(Unhealthy)\n"); + } + else + { + /*- 无处理 */ + } + + /*TODO:对系不是主而钥匙不允许自己升主,则自己离线*/ + /*- 本周期与对系的双通信通道是否全部中断 */ + if((ENUM_CM_FALSE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineComOKCount[0],0u)) && + (ENUM_CM_FALSE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerComOKCount[0],0u)) && + (ENUM_CM_FALSE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineUartOKCount[0],0u)) && + (ENUM_CM_FALSE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerUartOKCount[0],0u))) + { + /*前两个周期是否存在中断-本周期串口是否正常-并且对系不是主系则升主*/ + if( /*与当前周期差3-5认为正常,超过阈值认为不同时断线,通信故障*/ + (MSCP_Get_2X_DisCom_Count(&s_2x2_state_Ctrl.MineComOKCount[0],0u) <= MSCP_2X2_SYNC_TIMEOUT_CYC) && + (MSCP_Get_2X_DisCom_Count(&s_2x2_state_Ctrl.PeerComOKCount[0],0u) <= MSCP_2X2_SYNC_TIMEOUT_CYC) && + (MSCP_Get_2X_DisCom_Count(&s_2x2_state_Ctrl.MineUartOKCount[0],0u) <= MSCP_2X2_SYNC_TIMEOUT_CYC) && + (MSCP_Get_2X_DisCom_Count(&s_2x2_state_Ctrl.PeerUartOKCount[0],0u) <= MSCP_2X2_SYNC_TIMEOUT_CYC)) + { + /*不存在断线,判断为宕机或断电升主*/ + /*- 本系升主 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_MASTER; + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartnerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartPeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.LocalAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + /*- 将对系状态置为宕机 */ + s_2x2_state_Ctrl.PartnerState = ENUM_2x2_SHUTDOWN; + /*通信SN号清空-防止对系重新上电后不接收新的SN号*/ + s_2x2_state_Ctrl.RxSN = 0u; + SFM_LOG_MSG_2X("Transition:2x2:SLAVE>>>>>>>MASTER!!!(ALL interrupt)\n"); + } + else + { + /*- 存在断线-宕机 */ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_SHUTDOWN; + SFM_LOG_MSG_2X("Transition:2x2:SLAVE>>>>>>>HAVE ALL interrupt(%d)(%d)(%d)(%d)\n", + MSCP_Get_2X_DisCom_Count(&s_2x2_state_Ctrl.MineComOKCount[0],0u), + MSCP_Get_2X_DisCom_Count(&s_2x2_state_Ctrl.PeerComOKCount[0],0u), + MSCP_Get_2X_DisCom_Count(&s_2x2_state_Ctrl.MineUartOKCount[0],0u), + MSCP_Get_2X_DisCom_Count(&s_2x2_state_Ctrl.PeerUartOKCount[0],0u)); + CM_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_5); + } + } + else if((ENUM_2x2_OFFLINE == s_2x2_state_Ctrl.PartnerState) || + ((ENUM_2x2_MASTER != s_2x2_state_Ctrl.PartnerState) &&/*TODO 对系状态必须是最新的*/ + (ENUM_2x2_MASTER == s_2x2_state_Ctrl.LastLocalState))) + { + s_2x2_state_Ctrl.LocalState = ENUM_2x2_MASTER; + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartnerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartPeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.LocalAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.ctrSwitchFlag = 0u; + s_2x2_state_Ctrl.aidSwitchFlag = 0u; + SFM_LOG_MSG_2X("Transition:2x2:SLAVE>>>>>>>MASTER(ROLLBACK\n"); + } + /*- 与主系输出不一致 或应用跟随数据不一致*/ + else if((1u == s_2x2_state_Ctrl.OutPutCheckFailFlag) || (1u == s_2x2_state_Ctrl.AppFollowCmpFlag)) + { + s_2x2_state_Ctrl.LocalState = ENUM_2x2_OFFLINE; + SFM_LOG_MSG_2X("Transition:2x2:SLAVE>>>>>>>OFFLINE(OutPut failed)\n"); + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartnerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartPeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.LocalAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.ctrSwitchFlag = 0u; + s_2x2_state_Ctrl.aidSwitchFlag = 0u; + } + else if((ENUM_2x2_MASTER == s_2x2_state_Ctrl.PartnerState) && + ((1u == s_2x2_state_Ctrl.aidSwitchFlag)||(1u == s_2x2_state_Ctrl.ctrSwitchFlag)) && + (0u == s_2x2_state_Ctrl.MicroCyc)) + { + /*是否满足至少一个以太网和任一通道*/ + if(((ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineComOKCount[0],0u)) && + (ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerComOKCount[0],0u))) || + ((ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineComOKCount[0],0u)) && + (ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineUartOKCount[0],0u))) || + ((ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineComOKCount[0],0u)) && + (ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerUartOKCount[0],0u))) || + ((ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerComOKCount[0],0u)) && + (ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.MineUartOKCount[0],0u))) || + ((ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerComOKCount[0],0u)) && + (ENUM_CM_TRUE == MSCP_Get_2X_Com_State(&s_2x2_state_Ctrl.PeerUartOKCount[0],0u)))) + { + s_2x2_state_Ctrl.LocalState = ENUM_2x2_MASTER; + SFM_LOG_MSG_2X("Transition:2x2:SLAVE>>>>>>>MASTER(SWITCH BUTTON)\n"); + } + else + { + /*报警禁止切系*/ + SFM_LOG_MSG_2X("Transition:2x2:SLAVE>>>>>>>SLAVE(NOT MASTER)\n"); + } + s_2x2_state_Ctrl.LocalSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartnerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartPeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.LocalAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = ENUM_2x2_AIDSWITCH_OVER; + s_2x2_state_Ctrl.ctrSwitchFlag = 0u; + s_2x2_state_Ctrl.aidSwitchFlag = 0u; + } + /*- 与对系是否同步超时 */ + else if ((s_2x2_state_Ctrl.SysCyc - s_2x2_state_Ctrl.LastCheckOKCount) >= MSCP_2X2_SYNC_TIMEOUT_CYC) + { + /* + * 如果失去同步,则自己离线 + * 注意,为了在双网通信中断与失去同步同时发生时能优先执行通信中断切系,这个if必须放在最后 + */ + /*- 本系离线 */ + dropCount ++ ; + s_2x2_state_Ctrl.LocalState = ENUM_2x2_OFFLINE; + SFM_LOG_MSG_2X("Transition:2x2:SLAVE>>>>>>>OFFLINE(Lose Sync)\n"); + } + else + { + /* 无处理 */ + } + SFM_LOG_MSG_2X("Transition:SLAVE:live time:%d\n", s_2x2_state_Ctrl.SysCyc - s_2x2_state_Ctrl.LastCheckOKCount); + /*- 返回 */ + break; + default: + /*- 返回 */ + break; + } +} +/** +* @brief 2X状态切换独立线程 +*/ +static CM_THREAD_FUNC_T SFM_2x2_StateChange_Thread(void) +{ +#if QNX + void* pmask = NULL; + /*- 本线程锁定在 A53 core 1|2 */ + pmask = (void*)(0x01u | 0x02u); + (void)ThreadCtl(_NTO_TCTL_RUNMASK, pmask); +#endif + static CM_BOOL Run_First_Flag = CM_FALSE; + CM_UINT64 curTick[6] = {0u}; /* 当前时刻 */ + CM_UINT64 sTick = 0u; /* 起始Tick */ + STRU_2OO2_NET_NO_PACK_T ctrl_2oo2_2xstate = { + .SN = 0u, /*初始化SN码*/ + .DataSend = CFM_2oo2_2xStateSend, /*注册发送函数指针*/ + .DataRecv = CFM_2oo2_2xStateRecv}; /*注册接收函数指针*/ + STRU_2X2_STATE_CTRL_T peer_state; /**< 邻机子线程2x2状态控制 */ + STRU_2X2_STATE_CTRL_T partner_state; /**< 对系子线程2x2状态控制 */ + ENUM_2x2_STATE_T TempState = ENUM_2x2_SHUTDOWN;/*临时状态*/ + + /* TODO 清空2x缓冲区数据*/ + while(1) + { + /*等待起始信号量*/ + CM_Sem_Wait(s_2x2_thread_Ctrl.m_Start); + if(Run_First_Flag == CM_FALSE) + { /*- 首次运行清空缓冲区*/ + CFM_Net2X_State_Flush(); + Run_First_Flag = CM_TRUE; + } + else + { + /*- 无处理*/ + } + /*微小周期执行*/ + for(s_2x2_state_Ctrl.MicroCyc = 0;s_2x2_state_Ctrl.MicroCyc < s_2x2_thread_Ctrl.number_Cyc;s_2x2_state_Ctrl.MicroCyc++) + { + /*- 记录起始时间*/ + sTick = CM_GetTick(); + /*检查按钮状态*/ + s_State_Switch(); + curTick[0] = CM_GetTick(); + /*二取本机热备状态、按钮状态、通信状态等、确保双CPU数据一致*/ + s_State_2xBefore_2oo2Sync(&ctrl_2oo2_2xstate,&peer_state); + curTick[1] = CM_GetTick(); + /*2x交互本机2取后的热备状态、按钮状态、通信状态等*/ + s_State_2x2Sync(&partner_state); + curTick[2] = CM_GetTick(); + /*二取本机热备状态、按钮状态、通信状态等、确保双CPU数据一致*/ + s_State_2xAfter_2oo2Sync(&ctrl_2oo2_2xstate,&partner_state); + curTick[3] = CM_GetTick(); + /*带着双cpu一致的双系数据做状态机切换*/ + if(s_2x2_state_Ctrl.MicroCyc < (s_2x2_thread_Ctrl.number_Cyc - 1u)) + { + s_State_Transition(); + } + else + { + /*预防双主*/ + if(ENUM_2x2_MASTER == s_2x2_state_Ctrl.PartnerState && ENUM_2x2_MASTER == s_2x2_state_Ctrl.LocalState) + { + /*双主恢复上周期状态,如果上周期也全部为主则宕机*/ + if((ENUM_2x2_MASTER == s_2x2_state_Ctrl.LastLocalState) && (ENUM_2x2_MASTER == s_2x2_state_Ctrl.LastPartnerState)) + { + /*- 检测到对系是主系,本系宕机*/ + s_2x2_state_Ctrl.LocalState = ENUM_2x2_SHUTDOWN; + SFM_LOG_MSG_2X("Transition:2x2:MASTER>>>>>>>Double MASTER!!!(Shut Down)\n"); + CM_RE_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + } + else + { + /*恢复上周期状态*/ + SFM_LOG_MSG_2X("Transition:2x2:Double MASTER Recovery!!!(Last State)\n"); + s_2x2_state_Ctrl.LocalState = s_2x2_state_Ctrl.LastLocalState; + TempState = s_2x2_state_Ctrl.LastPartnerState; + s_2x2_state_Ctrl.LastPartnerState = s_2x2_state_Ctrl.PartnerState; + s_2x2_state_Ctrl.PartnerState = TempState; + } + } + } + curTick[4] = CM_GetTick(); + /*等待50ms周期*/ + do + { + /*- 记录当前时间*/ + CM_Sleep(1); + curTick[5] = CM_GetTick(); + }while(((curTick[5] - sTick) < MSCP_2X2_THREAD_TIME*CM_UNSIGNED_MILLION) && (s_2x2_state_Ctrl.MicroCyc < s_2x2_thread_Ctrl.number_Cyc-1u) /*ms*/); + SFM_LOG_MSG_2X("2x2_StateChange_Thread[%d],ST:%dms,2T1:%dms,XT:%dms,2T2:%dms,TT:%dms,OT:%dms,M:%d,S:%d\n",s_2x2_state_Ctrl.MicroCyc, + (curTick[0] - sTick)/CM_UNSIGNED_MILLION,(curTick[1] - sTick)/CM_UNSIGNED_MILLION, + (curTick[2] - sTick)/CM_UNSIGNED_MILLION,(curTick[3] - sTick)/CM_UNSIGNED_MILLION, + (curTick[4] - sTick)/CM_UNSIGNED_MILLION,(curTick[5] - sTick)/CM_UNSIGNED_MILLION, + s_2x2_state_Ctrl.LocalState,s_2x2_state_Ctrl.PartnerState); + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_THREAD_SHOWTIME,7u, + sizeof(CM_UINT8),s_2x2_state_Ctrl.MicroCyc, + sizeof(CM_UINT32),(curTick[0] - sTick)/CM_UNSIGNED_MILLION, + sizeof(CM_UINT32),(curTick[1] - sTick)/CM_UNSIGNED_MILLION, + sizeof(CM_UINT32),(curTick[2] - sTick)/CM_UNSIGNED_MILLION, + sizeof(CM_UINT32),(curTick[3] - sTick)/CM_UNSIGNED_MILLION, + sizeof(CM_UINT32),(curTick[4] - sTick)/CM_UNSIGNED_MILLION, + sizeof(CM_UINT32),(curTick[5] - sTick)/CM_UNSIGNED_MILLION); + /*- 板卡硬件自检 3次*/ + PFM_BoardCheck_TolerateThreetimes(); + } + + /*发送2x状态结束信号量*/ + CM_Sem_Post(s_2x2_thread_Ctrl.m_Stop); + } + + return NULL; +} +/** +* @brief 平台记录格式化字符串日志 +* @param filename 文件路径 +* @param func 函数名 +* @param line 行号 +* @param fmt 格式化字符串 +*/ +static void SFM_2x2_LOG_MSG(IN const CM_CHAR *filename, IN CM_INT32 line, IN const CM_CHAR* fmt, ...) +{ + /*- 变量初始化 */ + va_list argList; + CM_CHAR msgBuf[1024]; + CM_INT32 headLen = 0; + CM_INT32 msgLen = 0; + if(NULL == fmt) + { + /* 无处理 */ + } + else + { + /*- 记录文件名、函数名、行号 */ + headLen = snprintf(msgBuf, sizeof(msgBuf), "ps:%s:%d:", filename, line); + va_start(argList, (fmt)); + /*- 记录日志内容 */ + msgLen += vsnprintf(msgBuf + headLen, sizeof(msgBuf) - (CM_SIZE_T)headLen, fmt, argList); + va_end(argList); +#ifdef WIN32 + Bootprintf("%s", msgBuf + headLen); +#endif + /* printf("%s", msgBuf + headLen);*/ + /*- 输出日志信息 */ + CM_MQ_Write((CM_MQ_Struct_T*)&s_2x2_thread_Ctrl.LogMsgQ, (CM_UINT8*)msgBuf, (CM_UINT16)headLen + msgLen); + } +} +/*日志转换*/ +void SFM_2x2_LOG_Transition(void) +{ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; + CM_UINT8 buf[1024] = {0}; + CM_UINT16 len = 1024; + while(1) + { + len = 1024; + rt = CM_MQ_Read(&s_2x2_thread_Ctrl.LogMsgQ, buf, (CM_UINT16*)&len); + if(ENUM_CM_TRUE == rt) + { + /*- 输出日志信息 */ + (void)CFM_BaseLog_Send((CM_UINT8*)buf, len); + } + else + { + /*无处理*/ + break; + } + } +} +/*发送2x起始信号*/ +void SFM_2x2_Thread_PostStart(void) +{ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + CM_Sem_Post(s_2x2_thread_Ctrl.m_Start); + } + else + { + /* 无处理 */ + } +} +/*使能AID切系开关*/ +void SFM_2x2_Enable_AIDSwitchStart(void) +{ + s_2x2_Ctrl.AIDSwitchState = ENUM_2x2_AIDSWITCH_ENABLE; + MSCP_LOG_MSG("SFM_2x2_Enable_AIDSwitchStart:s_2x2_Ctrl.AIDSwitchState = ENUM_2x2_AIDSWITCH_ENABLE \n"); +} +/*获取AID切系状态*/ +ENUM_2x2_AID_SWITCH_STATE SFM_2x2_Get_AIDSwitchStart(void) +{ + return s_2x2_Ctrl.AIDSwitchState; +} +/*输出处理与发送阶段之前的等待2x逻辑结束的最后处理函数*/ +void SFM_2x2_ChangeState(void) +{ + static CM_UINT8 AIDEnable_Cut = 0u; + STRU_2X2_CTRL_T peerCtrl = { 0 }; /* 邻机热备状态 */ + /*- 等待结束信号量*/ + CM_Sem_Wait(s_2x2_thread_Ctrl.m_Stop); + MSCP_LOG_MSG("SFM_2x2_ChangeState start\n"); + /*- 执行最后的切系逻辑*/ + s_2x2_Ctrl.MineComState = MSCP_Get_2X_VagueCom_State(&s_2x2_state_Ctrl.MineComOKCount[0]); /**< 本机通信状态,2oo2交换 */ + s_2x2_Ctrl.PeerComState = MSCP_Get_2X_VagueCom_State(&s_2x2_state_Ctrl.PeerComOKCount[0]); /**< 邻机通信状态,2oo2交换 */ + s_2x2_Ctrl.MineUartState = MSCP_Get_2X_VagueCom_State(&s_2x2_state_Ctrl.MineUartOKCount[0]); /**< 本机串口通信状态,2oo2交换 */ + s_2x2_Ctrl.PeerUartState = MSCP_Get_2X_VagueCom_State(&s_2x2_state_Ctrl.PeerUartOKCount[0]); /**< 邻机串口通信状态,2oo2交换 */ + /*- 切系完成*/ + if(ENUM_2x2_AIDSWITCH_OVER == s_2x2_state_Ctrl.LocalAIDSwitchState) + { + s_2x2_Ctrl.AIDSwitchState = ENUM_2x2_AIDSWITCH_DISABLE; + MSCP_LOG_MSG("SFM_2x2_ChangeState:s_2x2_Ctrl.AIDSwitchState = ENUM_2x2_AIDSWITCH_DISABLE\n"); + } + /*- 主线程认为自己是主系*/ + if (ENUM_2x2_MASTER == s_2x2_Ctrl.LocalState) + { + /*- 主系一直更新输出比较状态,防止切系降离线 */ + s_2x2_Ctrl.RxInputSysCyc = SFM_2x2_GetSysCount() - 1u; + s_2x2_Ctrl.LastFollowCyc = SFM_2x2_GetSysCount() - 1u; + s_2x2_Ctrl.LastCheckOKCount = SFM_2x2_GetSysCount(); + s_2x2_Ctrl.OutPutCheckFailFlag = 0u; + s_2x2_Ctrl.AppFollowCmpFlag = 0u; + } + else + { + /*无处理*/ + } + MSCP_LOG_MSG("timecurr 16.0.0 = %lld us\n", NOW_USED_TIME); + /*- 记录上周期状态用于回滚*/ + s_2x2_state_Ctrl.LastLocalState = s_2x2_Ctrl.LocalState; + s_2x2_state_Ctrl.LastPartnerState = s_2x2_Ctrl.PartnerState; + /*- 2x线程->更新主线程热备状态*/ + s_2x2_Ctrl.LocalState = s_2x2_state_Ctrl.LocalState; + s_2x2_Ctrl.PartnerState = s_2x2_state_Ctrl.PartnerState; + /*- 2取双CPU同步标志与热备状态*/ + s_Ctrl_2oo2Sync(&peerCtrl); + MSCP_LOG_MSG("timecurr 16.0.1 = %lld us\n", NOW_USED_TIME); + /*- 主线程参数同步到2x独立线程*/ + s_2x2_state_Ctrl.LastCheckOKCount = s_2x2_Ctrl.LastCheckOKCount; + s_2x2_state_Ctrl.OutPutCheckFailFlag = s_2x2_Ctrl.OutPutCheckFailFlag; + s_2x2_state_Ctrl.TimeSyncFlag = s_2x2_Ctrl.TimeSyncFlag;/*更新时间同步标志*/ + s_2x2_state_Ctrl.LastRxInputSysCyc = s_2x2_Ctrl.RxInputSysCyc; + s_2x2_state_Ctrl.LastFollowCyc = s_2x2_Ctrl.LastFollowCyc; + s_2x2_state_Ctrl.AppFollowCmpFlag = s_2x2_Ctrl.AppFollowCmpFlag; + /*- AID切系标志*/ + if((ENUM_2x2_AIDSWITCH_ENABLE == s_2x2_Ctrl.AIDSwitchState) && (AIDEnable_Cut <= 10u)) + { + AIDEnable_Cut++; + } + else + { + AIDEnable_Cut = 0; + s_2x2_Ctrl.AIDSwitchState = ENUM_2x2_AIDSWITCH_DISABLE; + } + s_2x2_state_Ctrl.LocalAIDSwitchState = s_2x2_Ctrl.AIDSwitchState; /**< 自己的主动切系按钮状态 */ + /*- 初始对系切系状态*/ + s_2x2_state_Ctrl.PartnerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartPeerSwitchState = ENUM_2x2_SWITCH_CLOSE; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_DISABLE; + s_2x2_state_Ctrl.PartPeerAIDSwitchState = ENUM_2x2_AIDSWITCH_DISABLE; + /*- 如果对系宕机,清空本系接收标志*/ + if(ENUM_2x2_SHUTDOWN == s_2x2_Ctrl.PartnerState) + { + s_2x2_Ctrl.RxSN = 0; + } + MSCP_LOG_MSG("timecurr 16.0.2 = %lld us\n", NOW_USED_TIME); + /*- 拷贝全部IO数据*/ + (void)CM_Memcpy(s_2x2_Ctrl.MineInputIoState,10,s_2x2_state_Ctrl.MineInputIoState,10); + (void)CM_Memcpy(s_2x2_Ctrl.PeerInputIoState,10,s_2x2_state_Ctrl.PeerInputIoState,10); + (void)CM_Memcpy(s_2x2_Ctrl.RmtMineInputIoState,10,s_2x2_state_Ctrl.RmtMineInputIoState,10); + (void)CM_Memcpy(s_2x2_Ctrl.RmtPeerInputIoState,10,s_2x2_state_Ctrl.RmtPeerInputIoState,10); + /*- 清空缓冲区历史数据*/ + (void)CM_Memset(s_2x2_state_Ctrl.PeerInputIoState,0,10,10); + (void)CM_Memset(s_2x2_state_Ctrl.RmtMineInputIoState,0,10,10); + (void)CM_Memset(s_2x2_state_Ctrl.RmtPeerInputIoState,0,10,10); + (void)DFM_GetIO_InPut(s_2x2_state_Ctrl.MineInputIoState,10u);/*读取IO输入数据*/ + MSCP_LOG_MSG("timecurr 16.0.0 = %lld us\n", NOW_USED_TIME); + /*- 更新系统周期号*/ + s_2x2_state_Ctrl.SysCyc = SFM_2x2_GetSysCount(); /*系统周期号*/ + MSCP_LOG_MSG("timecurr 16.0.3 = %lld us\n", NOW_USED_TIME); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_LOCAL, 1U, &s_2x2_Ctrl.LocalState); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_PARTNER, 1U, &s_2x2_Ctrl.PartnerState); + + SFM_2x2_LOG_Transition(); + MSCP_LOG_MSG("timecurr 16.0.4 = %lld us\n", NOW_USED_TIME); + MSCP_LOG_MSG("SFM_2x2_ChangeState stop\n"); +} +/** +* @brief 2x2上电初始化 +* @param VitalBuf 初始化关键变量数组 +* @param VitalLen 初始化关键变量长度 +* @param pCycTick 上电开始时刻 +* @return 周期开始时间修正量 +* @details +* TODO 上电同步和上电比较 +*/ +void SFM_2x2_Init(IN const CM_UINT8 *VitalBuf, IN CM_UINT16 VitalLen, INOUT CM_UINT64 *pCycTick) +{ + /*- 变量初始化 */ + CM_UINT64 startTick = 0u; /* 周期开始时间 */ + CM_UINT64 offset = 0u; /* 最终时钟偏移量 */ + CM_UINT64 myOffset = 0u; /* 本机时钟偏移量 */ + CM_UINT64 peerOffset = 0u; /* 邻机时钟偏移量 */ + CM_INT32 len = 0; /* 报文长度 */ + CM_UINT8 myBuf[100] = { 0u }; /* 本机报文缓冲区 */ + CM_UINT8 peerBuf[100] = { 0u }; /* 邻机报文缓冲区 */ + ENUM_CM_RETURN checkRet = ENUM_CM_NULL; + CM_BOOL rtnThread = CM_FALSE; + /*- 入参检查 */ + CM_ASSERT((NULL != VitalBuf) && (NULL != pCycTick), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_7); + /*- 是否开启2x2功能 */ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + + /*- 配置参数一致性检查 */ +#if (MSCP_2X2_COM_FAIL_CYC > MSCP_2X2_SYNC_TIMEOUT_CYC) + CM_ASSERT(0u); +#endif + /*- 变量初始化 */ + s_2x2_Ctrl.LocalState = ENUM_2x2_OFFLINE; + s_2x2_Ctrl.PartnerState = ENUM_2x2_SHUTDOWN; + s_2x2_Ctrl.AppFollowCmpFlag = 1u; + + /*- 更新上一周期的主备状态为这周期的主备状态(给应用用) */ + s_2x2_Ctrl.LastLocalState = s_2x2_Ctrl.LocalState; + s_2x2_Ctrl.LastPartnerState = s_2x2_Ctrl.PartnerState; + + s_2x2_Ctrl.LocalID =(g_PFM_Cfg.BOARD_ID * 256u) + g_PFM_Cfg.CPU_ID; + s_2x2_Ctrl.PartnerID = ((3u - (CM_UINT32)g_PFM_Cfg.BOARD_ID) * 256u) + (CM_UINT32)g_PFM_Cfg.CPU_ID; + s_2x2_Ctrl.AIDSwitchState = 0xAA; + s_2x2_Ctrl.TimeSyncFlag = CM_FALSE; + /*独立线程状态结构体初始化*/ + s_2x2_state_Ctrl.LocalState = s_2x2_Ctrl.LocalState; + s_2x2_state_Ctrl.PartnerState = s_2x2_Ctrl.PartnerState; + /*- 更新上一周期的主备状态为这周期的主备状态(给应用用) */ + s_2x2_state_Ctrl.LastLocalState = s_2x2_Ctrl.LastLocalState; + s_2x2_state_Ctrl.LastPartnerState = s_2x2_Ctrl.LastPartnerState; + + s_2x2_state_Ctrl.LocalAIDSwitchState = ENUM_2x2_AIDSWITCH_DISABLE; + s_2x2_state_Ctrl.PartnerAIDSwitchState = ENUM_2x2_AIDSWITCH_DISABLE; + + s_2x2_state_Ctrl.LocalID =s_2x2_Ctrl.LocalID; + s_2x2_state_Ctrl.PartnerID = s_2x2_Ctrl.PartnerID; + s_2x2_state_Ctrl.TimeSyncFlag = s_2x2_Ctrl.TimeSyncFlag; + /*独立线程参数初始化*/ + s_2x2_thread_Ctrl.number_Cyc = (g_PFM_Cfg.CYC_TIME - 60U) / MSCP_2X2_THREAD_TIME;/*根据周期计算,预留60ms*/ + (s_2x2_thread_Ctrl.number_Cyc > 1u)?(s_2x2_thread_Ctrl.number_Cyc) : (s_2x2_thread_Ctrl.number_Cyc = 1u); + CM_Sem_Init(&s_2x2_thread_Ctrl.m_Start); + CM_Sem_Init(&s_2x2_thread_Ctrl.m_Stop); + + /*初始化应用跟随数据缓冲区*/ + g_TxAppFollow_len = 4; + CM_LongToChar(0u, g_TxAppFollow); + + checkRet = CM_RB_Init(&s_2x2_TmRing, (CM_UINT32)SFM_2x2_TM_RING_SIZE); + CM_ASSERT(ENUM_CM_TRUE == checkRet, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + /* 系间时钟同步 */ + /*- 生成系间同步报文 */ + /* + 1字节 板卡ID + 4字节 平台软件版本 + n字节 应用关键数据 + */ + s_2x2_TxSyncMsg[0] = g_PFM_Cfg.BOARD_ID; + s_2x2_TxSyncMsg[1] = MSCP_SW_VERION[0]; + s_2x2_TxSyncMsg[2] = MSCP_SW_VERION[1]; + s_2x2_TxSyncMsg[3] = MSCP_SW_VERION[2]; + s_2x2_TxSyncMsg[4] = MSCP_SW_VERION[3]; + checkRet = CM_Memcpy((void*)(s_2x2_TxSyncMsg + 5), (CM_SIZE_T)(sizeof(s_2x2_TxSyncMsg) - 5u), VitalBuf, (CM_SIZE_T)VitalLen); + CM_ASSERT(ENUM_CM_TRUE == checkRet, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + s_2x2_TxSyncLen = 5u + (CM_UINT32)VitalLen; + + /*- 尝试接收对系的同步报文*/ + s_2x2_RxSyncLen = CFM_2x2_SyncRecv(s_2x2_RxSyncMsg, (CM_UINT32)sizeof(s_2x2_RxSyncMsg), &s_2x2_RxSyncTick); + /*- 是否收到了同步报文 */ + if (s_2x2_RxSyncLen > 0) + { + /*- 检查双系同步报文是否一致,若不一致则宕机 */ + CM_ASSERT(s_2x2_RxSyncLen == (CM_INT32)s_2x2_TxSyncLen, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3); + CM_ASSERT((s_2x2_RxSyncMsg[0] + s_2x2_TxSyncMsg[0]) == 3u, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_4); + CM_ASSERT(0 == CM_Memcmp((void*)(s_2x2_RxSyncMsg + 1u), (void*)(s_2x2_TxSyncMsg + 1u), (CM_SIZE_T)s_2x2_TxSyncLen - 1u), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_5); + } + else + { + /*- 无处理 */ + } + + /*- 计算本机基于2oo2比较的预期周期开始时间 */ + startTick = *pCycTick; + startTick += (CM_UINT64)(MSCP_CYC_TIME * (CM_UINT64)CM_UNSIGNED_MILLION); + /*- 是否收到了有效的2x2同步报文且接收时间距预期周期开始时间小于2个系统周期 */ + if (((CM_UINT32)s_2x2_RxSyncLen == s_2x2_TxSyncLen) && ((startTick - s_2x2_RxSyncTick) <= (MSCP_CYC_TIME * (CM_UINT32)CM_UNSIGNED_MILLION * 2u))) + { + /* 基于以上四点可做逻辑推导 */ + /*- 计算本机的时钟修正量 */ + myOffset = ((s_2x2_RxSyncTick + ((CM_UINT64)(MSCP_CYC_TIME * (CM_UINT64)CM_UNSIGNED_MILLION) * (CM_UINT64)2u)) - startTick) % (CM_UINT64)(MSCP_CYC_TIME * (CM_UINT64)CM_MILLION); + } + else + { + /*- 本机偏移量为无效值 */ + myOffset = (CM_UINT64)(MSCP_CYC_TIME * (CM_UINT64)CM_UNSIGNED_MILLION); + MSCP_LOG_MSG("The native offset is invalid\n"); + } + /* @alias 2oo2交换时钟修正量、取平均 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + CM_64ToChar(myOffset, myBuf); + len = SFM_2oo2_Exchange_Currency(myBuf, 8, peerBuf, (CM_UINT32)sizeof(peerBuf), ENUM_2oo2_INPUT_FULL_EX); + CM_ASSERT(len == 8, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_6); + peerOffset = CM_64FromChar(peerBuf); + if ((myOffset < MSCP_CYC_TIME * CM_UNSIGNED_MILLION) && (peerOffset < (MSCP_CYC_TIME * CM_UNSIGNED_MILLION))) + { + offset = (myOffset + peerOffset) / 2u; + } + else if (myOffset < MSCP_CYC_TIME * CM_UNSIGNED_MILLION) + { + offset = myOffset; + } + else if (peerOffset < MSCP_CYC_TIME * CM_UNSIGNED_MILLION) + { + offset = peerOffset; + } + else + { + offset = (CM_UINT64)(MSCP_CYC_TIME * (CM_UINT64)CM_UNSIGNED_MILLION); + } + } + else + { + /*- 本机计算的时钟修正量作为最终修正量 */ + offset = myOffset; + } + /*- offset至少为一个周期 */ + offset += (CM_UINT64)(MSCP_CYC_TIME * (CM_UINT64)CM_UNSIGNED_MILLION); + MSCP_LOG_MSG("2x2 sync delay %lld\n", offset); + + /*- 日志队列初始化 */ + checkRet = CM_MQ_Init((CM_MQ_Struct_T*)&s_2x2_thread_Ctrl.LogMsgQ, (CM_UINT16)CFM_INNET_LOG_SIZE, (CM_UINT16)(CFM_INNET_LOG_SIZE)); + CM_ASSERT(ENUM_CM_TRUE == checkRet, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_8); + /*-启动2x2状态切换独立线程 */ + rtnThread = CM_Thread_Create((CM_THREAD_T*)NULL, (CM_THREAD_FUNC_T)SFM_2x2_StateChange_Thread, "2x2_Rx_state", 0, CM_TASK_PRIORITY_73, NULL); + CM_ASSERT(CM_TRUE == rtnThread, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_9); + } + else + { + /*- 默认本机为主 */ + s_2x2_Ctrl.LocalState = ENUM_2x2_MASTER; + s_2x2_Ctrl.LastLocalState = s_2x2_Ctrl.LocalState; + /*至少2个周期*/ + offset = (CM_UINT64)(MSCP_CYC_TIME * (CM_UINT64)CM_UNSIGNED_MILLION); + } + /*- 更新上电开始时刻 */ + *pCycTick += offset; + +} + +/** +* @brief 2x2发送 +* @param Data 发送报文指针 +* @param DataLen 发送报文长度 +* param msgType 报文类型 +* @details +* @see :: s_2x2_Recv +* @see :: SFM_FrameSave +*/ +void SFM_2x2_Send(IN const CM_UINT8 *Data, IN CM_UINT32 DataLen, IN ENUM_2x2_MSG_T msgType) +{ + + /*- 变量初始化 */ + CM_UINT16 FrameNum = 0u; /* 帧数 */ + CM_UINT16 FrameIndex = 0u; /* 帧序号 */ + CM_UINT32 FrameLen = 0u; /* 帧长度 */ + CM_UINT32 crc = 0u; /* CRC */ + CM_UINT32 SysCyc = SFM_2x2_GetSysCount(); /* 系统周期号 */ + ENUM_CM_RETURN checkRet = ENUM_CM_NULL; + PFM_LOG_SET_STOPTIMER(TSCP_DARK_2x2); + /*- 入口检查 */ + CM_ASSERT(NULL != Data, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + + /*- 计算帧数 */ + FrameNum = (CM_UINT16)(((CM_UINT32)DataLen <= NET_20K_SIZE) ? (1u) : ((((CM_UINT32)DataLen + NET_20K_SIZE) - 1u) / NET_20K_SIZE)); + /* + 2x2通信帧格式: + 4字节 长度(不含自身) + 4字节 源ID + 4字节 目的ID + 4字节 周期号 + 4字节 序列号 + 1字节 类型 + 2字节 帧总数 + 2字节 帧序号 + n字节 数据 + 4字节 CRC(含长度) + */ + /*- 填充报文头 */ + CM_LongToChar(NET_20K_SIZE + 25u, &s_2x2_Cache[0u]); /*长度(暂时填写满帧)*/ + CM_LongToChar(s_2x2_Ctrl.LocalID, &s_2x2_Cache[4u]); /*源ID*/ + CM_LongToChar(s_2x2_Ctrl.PartnerID, &s_2x2_Cache[8u]); /*目的ID*/ + CM_LongToChar(SysCyc, &s_2x2_Cache[12u]); /*周期号*/ + s_2x2_Ctrl.TxSN++; + CM_LongToChar(s_2x2_Ctrl.TxSN, &s_2x2_Cache[16u]); /*序列号*/ + s_2x2_Cache[20] = (CM_UINT8)msgType; /*类型*/ + CM_ShortToChar(FrameNum, &s_2x2_Cache[21u]); /*帧总数*/ + /* s_2x2_Cache + 23 */ /*帧序号(后面填写)*/ + + /*- @alias 循环发送完整帧 */ + for (FrameIndex = 1u; FrameIndex < FrameNum; FrameIndex++) + { + + CM_ShortToChar(FrameIndex, &s_2x2_Cache[23u]); /*帧序号*/ + checkRet = CM_Memcpy((void*)(&s_2x2_Cache[25u]), (CM_SIZE_T)NET_20K_SIZE, (const void*)(Data + ((FrameIndex - 1u)*NET_20K_SIZE)), (CM_SIZE_T)NET_20K_SIZE); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + CM_RE_ASSERT(checkRet == ENUM_CM_TRUE, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + crc = CM_Crc32(s_2x2_Cache, NET_20K_SIZE + 25u); + CM_LongToChar(crc, &s_2x2_Cache[25u + NET_20K_SIZE]); /*CRC*/ + + (void)CFM_2x2_DataSend(s_2x2_Cache, (CM_INT32)(29u + NET_20K_SIZE)); /*交给通信层发送*/ + } + + /*- 发送尾帧*/ + CM_ShortToChar(FrameIndex, &s_2x2_Cache[23u]); /*帧序号*/ + FrameLen = (CM_UINT32)DataLen - ((FrameIndex - 1u)*NET_20K_SIZE); + checkRet = CM_Memcpy((void*)(&s_2x2_Cache[25u]), (CM_SIZE_T)NET_20K_SIZE, (const void*)(Data + ((FrameIndex - 1u)*NET_20K_SIZE)), (CM_SIZE_T)FrameLen); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + CM_RE_ASSERT(checkRet == ENUM_CM_TRUE, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + CM_LongToChar(25u + FrameLen, s_2x2_Cache); /*长度*/ + crc = CM_Crc32(s_2x2_Cache, 25u + FrameLen); + CM_LongToChar(crc, &s_2x2_Cache[25u + FrameLen]); /*CRC*/ + (void)CFM_2x2_DataSend(s_2x2_Cache,(CM_INT32)CM_UNSIGNED_INT_EXP(29u + FrameLen)); /*交给通信层发送*/ + PFM_LOG_SET_STOPTIMER(TSCP_DARK_NULL); +} + +/** +* @brief 2x2周期同步 +* @param cycTick 周期开始时刻 +*/ +void SFM_2x2_Sync(IN CM_UINT64 cycTick, OUT CM_INT64 *pOffset) +{ + /*本周期同步标志*/ + static ENUM_CM_RETURN g_syncFlag = ENUM_CM_FALSE; + static CM_INT32 s_count = 0; + static CM_INT64 s_sum = 0; + static CM_INT32 s_nsub = 0; + static CM_INT32 s_nadd = 0; + if(NULL == pOffset) + { + MSCP_LOG_MSG("ERROR: NULL !!! \n"); + CM_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + /*- 无需操作 */ + } + else + { + /*- 变量初始化 */ + CM_INT64 myDelay = 0; /* 本机延迟 */ + CM_INT64 myOffset = 0; /* 本机偏移 */ + CM_INT64 peerOffset = 0;/* 邻机偏移 */ + CM_INT64 aveOffset = 0; /* 平均偏移量 */ + CM_INT64 offset = 0; /* 修正量 */ + CM_INT64 cyctime_ns = 0; /* 周期时间ns值 */ + CM_INT64 val = 0; /* 临时变量 */ + CM_UINT8 myBuf[32] = {0u}; /* 2oo2缓冲区 */ + CM_UINT8 peerBuf[32] = {0u}; /* 2oo2缓冲区 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + ENUM_2x2_STATE_T state_2x2 = ENUM_2x2_SHUTDOWN; /* 本系热备状态 */ + *pOffset = 0; + (void)CFM_2x2_SyncSend(s_2x2_TxSyncMsg, (CM_INT32)s_2x2_TxSyncLen); + s_2x2_RxSyncLen = CFM_2x2_SyncRecv(s_2x2_RxSyncMsg, (CM_UINT32)sizeof(s_2x2_RxSyncMsg), &s_2x2_RxSyncTick); + /*TODO 统计、调整*/ + /*- 是否收到对系的周期同步报文 */ + if (s_2x2_RxSyncLen > 0) + { + /*- 获取本系状态 */ + state_2x2 = SFM_2x2_GetLocal2x2State(); + MSCP_LOG_MSG("Obtain department status Obtain department status = %d\n",state_2x2); + /*- 本系是否非主 */ + if(ENUM_2x2_MASTER != state_2x2) + { + /*- 判断本系的关键数据是否与对系一致,若不一致,则本系宕机 */ + CM_RE_ASSERT(0 == CM_Memcmp((void*)(s_2x2_RxSyncMsg + 1), (void*)(s_2x2_TxSyncMsg + 1), (CM_SIZE_T)s_2x2_TxSyncLen - 1u), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_2); + } + else + { + /*- 无需操作 */ + } + } + else + { + /*- 无需操作 */ + } + myOffset = CM_INT64_MAX; + rt = CFM_2x2_TimeGet(&myDelay, &myOffset); + /*- 是不是修正完的下一周期,如果是则offset无效 */ + if(ENUM_CM_TRUE == g_syncFlag) + { + myOffset = CM_INT64_MAX; + g_syncFlag = ENUM_CM_FALSE; + } + else + { + /*- 无需操作 */ + } + + MSCP_LOG_MSG("myOffset = %lld\n",myOffset); + CFM_2x2_TimeReq(); + MSCP_LOG_MSG("CFM_2x2_TimeReq\n"); + if (g_PFM_Cfg.M_2oo2_Enable == 0x55u) + { + CM_64ToChar(myOffset, myBuf); + (void)SFM_2oo2_Exchange_Currency(myBuf, 8, peerBuf, 8u, (CM_UINT32)ENUM_2oo2_SYNC); + peerOffset = CM_64FromChar(peerBuf); + if ((myOffset < CM_INT64_MAX) && (peerOffset < CM_INT64_MAX) && (myOffset > CM_INT64_MIN) && (peerOffset > CM_INT64_MIN)) + { + myOffset = (myOffset + peerOffset) / 2; + MSCP_LOG_MSG("myOffset = %d,The calibration result is the average value of 2OO2 dual machines\n", myOffset); + rt = ENUM_CM_TRUE; + } + else if ((myOffset < CM_INT64_MAX) && (myOffset > CM_INT64_MIN)) + { + MSCP_LOG_MSG("The calibration result is the local calibration result\n"); + rt = ENUM_CM_TRUE; + } + else if ((peerOffset < CM_INT64_MAX) && (peerOffset > CM_INT64_MIN)) + { + MSCP_LOG_MSG("The calibration result is the calibration result of the neighboring machine\n"); + myOffset = peerOffset; + rt = ENUM_CM_TRUE; + } + else + { + rt = ENUM_CM_FALSE; + MSCP_LOG_MSG("Failed to calibrate this period\n"); + } + } + else + { + /*- 无需操作 */ + } + + if (ENUM_CM_TRUE == rt) + { + if((myOffset >= (20 * CM_MILLION)) || (myOffset <= -(20 * CM_MILLION))) + { + MSCP_LOG_MSG("WARING[%d][%lldms]:2X offset deviation is too large\n",SFM_2x2_GetSysCount(),myOffset/CM_MILLION); + s_2x2_Ctrl.TimeSyncFlag = CM_FALSE; + } + else + { + /*- 无需操作 */ + MSCP_LOG_MSG("WARING[%d][%lldms]:2X offset sync success\n",SFM_2x2_GetSysCount(),myOffset/CM_MILLION); + s_2x2_Ctrl.TimeSyncFlag = CM_TRUE; + } + if(ENUM_2x2_OFFLINE == s_2x2_Ctrl.LocalState) + { + aveOffset = myOffset; + g_syncFlag = ENUM_CM_TRUE; + } + else + { + (void)CM_RB_Get(&s_2x2_TmRing, (CM_UINT16)SFM_2x2_TM_RING_SIZE, &val); + s_sum -= val; + (void)CM_RB_Write(&s_2x2_TmRing, myOffset); + s_sum += myOffset; + s_count++; + MSCP_LOG_MSG("Whether effective calibration results have been achieved %lld(ns)\n",s_sum); + if (s_count >= SFM_2x2_TM_RING_SIZE) + { + aveOffset = (s_sum) / (CM_INT64)SFM_2x2_TM_RING_SIZE; + g_syncFlag = ENUM_CM_TRUE; + } + else + { + + } + } + if (ENUM_CM_TRUE == g_syncFlag) + { + if (aveOffset >= (SFM_2x2_TM_FIX_VAL * CM_MILLION)) + { + offset = -aveOffset; + MSCP_LOG_MSG("offset = %lld\n",offset); + s_nsub++; + s_count = 0; + } + else if (aveOffset <= (-SFM_2x2_TM_FIX_VAL * CM_MILLION)) + { + offset = -aveOffset; + MSCP_LOG_MSG("offset = %lld\n",offset); + s_nadd++; + s_count = 0; + } + else + { + /*- 无需操作 */ + } + } + else + { + /*- 无需操作 */ + } + } + else + { + /*- 无需操作 */ + } + /*- 是否对系为主系 */ + if (ENUM_2x2_MASTER == s_2x2_Ctrl.PartnerState) + { + cyctime_ns = (CM_INT64)(g_PFM_Cfg.CYC_TIME) * CM_MILLION; + /*- 是否需要调大时钟超过一周期 */ + if (offset >= cyctime_ns) + { + /*- 本次只做周期基准时间调整,不调整周期定时器 (将偏移量四舍五入到整周期)*/ + *pOffset = ((CM_INT64)(offset + cyctime_ns / 2) / cyctime_ns) * cyctime_ns; + MSCP_LOG_MSG("Increase the clock by more than one cycle *pOffset = %lld\n",*pOffset); + } + /*- 是否需要调小时钟超过一周期 */ + else if (offset <= -cyctime_ns) + { + /*- 本次只做周期基准时间调整,不调整周期定时器 (将偏移量四舍五入到整周期) */ + *pOffset = ((CM_INT64)(offset - cyctime_ns / 2) / cyctime_ns) * cyctime_ns; + MSCP_LOG_MSG("Set the clock more than one cycle*pOffset = %lld\n",*pOffset); + } + /*- 是否需要调大时钟不超过一周期 */ + else if (offset >= (CM_INT64)SFM_2x2_TM_FIX_VAL * CM_MILLION) + { + /*- 本周期定时器延长10ms */ + *pOffset = SFM_2x2_TM_FIX_VAL * CM_MILLION; + MSCP_LOG_MSG("The interval timer is extended by 10ms\n"); + } + /*- 是否需要调小时钟不超过一周期 */ + else if (offset <= -(CM_INT64)SFM_2x2_TM_FIX_VAL * CM_MILLION) + { + /*- 本周期定时器缩短10ms */ + *pOffset = -SFM_2x2_TM_FIX_VAL * CM_MILLION; + MSCP_LOG_MSG("The interval timer is shortened by 10ms\n"); + } + else + { + /*- 不需要调整时钟 */ + *pOffset = 0; + } + } + else + { + /*- 不需要调整时钟 */ + *pOffset = 0; + } + /*- 记录同步结果 */ + MSCP_LOG_MSG("2x2 sync:%lld,%lld,%lld(us)\n", myOffset / 1000, peerOffset / 1000, *pOffset/1000); + MSCP_LOG_MSG("2x2 offset_sum:%lld(us),%d,%d\n", s_sum / 1000, s_nadd, s_nsub); + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_SYNC_TIME,8u, + sizeof(CM_UINT8),s_2x2_Ctrl.TimeSyncFlag, + sizeof(CM_UINT32),SFM_2x2_GetSysCount(), + sizeof(CM_UINT32),myOffset / 1000, + sizeof(CM_UINT32),peerOffset / 1000, + sizeof(CM_UINT32),*pOffset / 1000, + sizeof(CM_UINT32),s_sum / 1000, + sizeof(CM_UINT32),s_nadd, + sizeof(CM_UINT32),s_nsub); + } +} + +/** +* @brief 2x2接收 +* @see :: SFM_2x2_Send +* @see :: s_2x2_SendState +*/ +static void s_2x2_Recv(void) +{ + /*- 变量初始化 */ + static STRU_FrameCtrl_T s_2x2_FrameCtrl; /**< 分帧接收控制 */ + CM_INT32 rxLen = 0; /* 网络接收长度 */ + CM_UINT32 msgLen = 0u; /* 报文长度 */ + CM_UINT32 SrcID = 0u; /* 源ID */ + CM_UINT32 DstID = 0u; /* 目的ID */ + CM_UINT32 msgCyc = 0u; /* 报文周期号 */ + CM_UINT32 msgSN = 0u; /* 报文序列号 */ + CM_UINT16 FrameNum = 0u; /* 帧数目 */ + CM_UINT16 FrameIndex = 0u;/* 帧序号 */ + CM_UINT32 msgCrc = 0u; /* 报文CRC */ + CM_UINT32 calcCrc = 0u; /* 本地计算CRC */ + CM_UINT8 *pData = NULL; /* 指向帧数据的指针 */ + CM_INT32 DataLen = 0; /* 帧数据长度 */ + ENUM_2x2_MSG_T type = ENUM_2x2_MSG_ERROR; /* 报文类型 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 临时变量 */ + PFM_LOG_SET_STOPTIMER(TSCP_DARK_2x2); + /*- 以太网循环接收2x2数据 */ + if(CM_TRUE == s_2x2_Ctrl.TimeSyncFlag) + { + do + { + /*- 从通信层接收2x2报文 */ + rxLen = CFM_2x2_DataRecv(s_2x2_Cache, (CM_UINT32)sizeof(s_2x2_Cache)); + /*- 收到的报文长度是否大于0 */ + if ((29 <= rxLen)) + { + /*- 解析2x2报文头 */ + /* + 2x2通信帧格式: + 4字节 长度(不含自身) + 4字节 源ID + 4字节 目的ID + 4字节 周期号 + 4字节 序列号 + 1字节 类型 + 2字节 帧总数 + 2字节 帧序号 + n字节 数据 + 4字节 CRC + */ + msgLen = CM_LongFromChar(s_2x2_Cache); + CM_RE_ASSERT((msgLen + 4u) == (CM_UINT32)rxLen, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + SrcID = CM_LongFromChar(s_2x2_Cache + 4); + DstID = CM_LongFromChar(s_2x2_Cache + 8); + msgCyc = CM_LongFromChar(s_2x2_Cache + 12); + msgSN = CM_LongFromChar(s_2x2_Cache + 16); + type = (ENUM_2x2_MSG_T)s_2x2_Cache[20]; + FrameNum = CM_ShortFromChar(s_2x2_Cache + 21); + FrameIndex = CM_ShortFromChar(s_2x2_Cache + 23); + msgCrc = CM_LongFromChar(s_2x2_Cache + msgLen); + calcCrc = CM_Crc32(s_2x2_Cache, msgLen); + /*- 校验报文头是否合法 */ + if ((SrcID == s_2x2_Ctrl.PartnerID) + && (DstID == s_2x2_Ctrl.LocalID) + /*&& msgCyc*/ + && (msgSN >= s_2x2_Ctrl.RxSN) + && (msgCrc == calcCrc)) + { + /*- 更新通信状态 */ + s_2x2_Ctrl.RxSN = msgSN; + pData = s_2x2_Cache + 25; + DataLen = (CM_INT32)CM_UNSIGNED_INT_EXP(msgLen - 25u); + /*- 报文类型 */ + switch (type) + { + case ENUM_2x2_MSG_BASE_FOLLOW:/*-< 平台跟随数据*/ + /*- @alias 分帧接收新跟随报文 */ + if (msgCyc > s_2x2_Ctrl.RxBaseFollowSysCyc) + { + /*- 分帧接收跟随报文 */ + CM_RE_ASSERT(FrameNum <= (SFM_FOLLOW_BUFF_SIZE / NET_20K_SIZE), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT(FrameIndex <= FrameNum, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_3); + ret = SFM_2X_FrameSave(&s_2x2_FrameCtrl, (CM_UINT8)ENUM_2x2_MSG_BASE_FOLLOW, FrameNum, FrameIndex, pData, DataLen, g_RxBaseFollow, &g_RxBaseFollow_len, (CM_UINT32)sizeof(g_RxBaseFollow)); + /*- 是否收齐了跟随报文 */ + if (ENUM_CM_TRUE == ret) + { + /*- 更新跟随报文状态 */ + CM_RE_ASSERT(8 <= g_RxBaseFollow_len, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_4); + s_2x2_Ctrl.RxBaseFollowSysCyc = msgCyc; + MSCP_LOG_MSG("2x2 RxBaseFollowCyc = %d,rcvlen = %d,Time:%d us\r\n", msgCyc,g_RxBaseFollow_len,NOW_USED_TIME); + } + else + { + MSCP_LOG_MSG("2x2 msgCyc = %d, SysCyc = %d,Time:%d us\r\n", msgCyc, s_2x2_Ctrl.RxBaseFollowSysCyc,NOW_USED_TIME); + } + } + else + { + MSCP_LOG_MSG("2x2 msgCyc = %d > SysCyc = %d,Time:%d us\r\n", msgCyc, s_2x2_Ctrl.RxBaseFollowSysCyc,NOW_USED_TIME); + } + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_RCV_BASE_STATE,5u, + sizeof(CM_UINT8),(msgCyc > s_2x2_Ctrl.RxBaseFollowSysCyc), + sizeof(CM_UINT32),msgCyc, + sizeof(CM_UINT32),s_2x2_Ctrl.RxBaseFollowSysCyc, + sizeof(CM_UINT32),g_RxBaseFollow_len, + sizeof(CM_UINT32),NOW_USED_TIME); + /*- 返回 */ + break; + case ENUM_2x2_MSG_APP_FOLLOW:/*-< 应用跟随报文 */ + /*- @alias 分帧接收新跟随报文 */ + if (msgCyc > s_2x2_Ctrl.RxAppFollowSysCyc) + { + /*- 分帧接收跟随报文 */ + CM_RE_ASSERT(FrameNum <= (SFM_FOLLOW_BUFF_SIZE / NET_20K_SIZE), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_5); + CM_RE_ASSERT(FrameIndex <= FrameNum, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_6); + ret = SFM_2X_FrameSave(&s_2x2_FrameCtrl, (CM_UINT8)ENUM_2x2_MSG_APP_FOLLOW, FrameNum, FrameIndex, pData, DataLen, g_RxAppFollow, &g_RxAppFollow_len, (CM_UINT32)sizeof(g_RxAppFollow)); + /*- 是否收齐了跟随报文 */ + if (ENUM_CM_TRUE == ret) + { + /*- 更新跟随报文状态 */ + CM_RE_ASSERT(4 <= g_RxAppFollow_len, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_7); + s_2x2_Ctrl.RxAppFollowSysCyc = msgCyc; + MSCP_LOG_MSG("2x2 RxAppFollowCyc = %d,rcvlen = %d,Time:%d us\r\n", msgCyc,g_RxAppFollow_len,NOW_USED_TIME); + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_RCV_APP_STATE,5u, + sizeof(CM_UINT8),(msgCyc > s_2x2_Ctrl.RxAppFollowSysCyc), + sizeof(CM_UINT32),msgCyc, + sizeof(CM_UINT32),s_2x2_Ctrl.RxAppFollowSysCyc, + sizeof(CM_UINT32),g_RxAppFollow_len, + sizeof(CM_UINT32),NOW_USED_TIME); + break; + case ENUM_2x2_MSG_APP_FOLLOW_CRC:/*-< 应用跟随报文 只比较CRC */ + /*- @alias 分帧接收新跟随报文 */ + if (msgCyc > s_2x2_Ctrl.RxAppFollowSysCyc) + { + /*- 分帧接收跟随报文 */ + CM_RE_ASSERT(FrameNum <= (SFM_FOLLOW_BUFF_SIZE / NET_20K_SIZE), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_17); + CM_RE_ASSERT(FrameIndex <= FrameNum, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_19); + ret = SFM_2X_FrameSave(&s_2x2_FrameCtrl, (CM_UINT8)ENUM_2x2_MSG_APP_FOLLOW_CRC, FrameNum, FrameIndex, pData, DataLen, g_RxAppFollowCrc, &g_RxAppFollowCrc_len, (CM_UINT32)sizeof(g_RxAppFollowCrc)); + /*- 是否收齐了跟随报文 */ + if (ENUM_CM_TRUE == ret) + { + /*- 更新跟随报文状态 */ + CM_RE_ASSERT(8 == g_RxAppFollowCrc_len, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_18); + s_2x2_Ctrl.RxAppFollowSysCyc = msgCyc; + MSCP_LOG_MSG("2x2 RxAppFollowCrcCyc = %d,rcvlen = %d,Time:%d us\r\n", msgCyc,g_RxAppFollowCrc_len,NOW_USED_TIME); + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_RCV_APP_STATE_CRC,5u, + sizeof(CM_UINT8),(msgCyc > s_2x2_Ctrl.RxAppFollowSysCyc), + sizeof(CM_UINT32),msgCyc, + sizeof(CM_UINT32),s_2x2_Ctrl.RxAppFollowSysCyc, + sizeof(CM_UINT32),g_RxAppFollowCrc_len, + sizeof(CM_UINT32),NOW_USED_TIME); + break; + case ENUM_2x2_MSG_OUTCHECK:/*-< 输出校验报文*/ + /*- @alias 接收新输出校验报文 */ + if (msgCyc > s_2x2_Ctrl.RxCheckSysCyc) + { + /*- 保存输出校验报文 */ + MSCP_LOG_MSG("2x2 Out RxCheckCyc = %d,Time:%d us\n", s_2x2_Ctrl.RxCheckSysCyc,NOW_USED_TIME); + s_2x2_Ctrl.RxCheckSysCyc = msgCyc; + s_2x2_Ctrl.RxCheckLen = DataLen; + ret = CM_Memset(s_2x2_Ctrl.RxCheckFrame, (CM_UINT8)0, sizeof(s_2x2_Ctrl.RxCheckFrame), sizeof(s_2x2_Ctrl.RxCheckFrame)); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_8); + ret = CM_Memcpy((void*)s_2x2_Ctrl.RxCheckFrame, sizeof(s_2x2_Ctrl.RxCheckFrame), (void*)pData, (CM_SIZE_T)DataLen); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_9); + } + else + { + /*- 无处理 */ + MSCP_LOG_MSG("2x2 Out msgCyc = %d,RxCheckCyc = %d,Time:%d us\n", msgCyc,s_2x2_Ctrl.RxCheckSysCyc,NOW_USED_TIME); + } + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_RCV_CHECK_STATE,5u, + sizeof(CM_UINT8),(msgCyc > s_2x2_Ctrl.RxCheckSysCyc), + sizeof(CM_UINT32),msgCyc, + sizeof(CM_UINT32),s_2x2_Ctrl.RxCheckSysCyc, + sizeof(CM_UINT32),DataLen, + sizeof(CM_UINT32),NOW_USED_TIME); + /*- 返回 */ + break; + case ENUM_2x2_MSG_ERROR:/*-< 保留字*/ + /*- 宕机 */ + CM_RE_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_10); + /*- 返回 */ + break; + default: + /*- 是否是对系本机输入数据同步报文 */ + if ((type >= 1) && (type <= g_2x2RcvMaxNum[0])) + { + /*- 是否收到新同步报文 */ + if (msgCyc >= s_2x2_Ctrl.RxInputSysCyc) + { + /*- 分帧接收数据同步报文 */ + CM_RE_ASSERT(FrameNum <= (SFM_OUTNETSAFE_BUFF_SIZE / NET_20K_SIZE), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_11); + CM_RE_ASSERT(FrameIndex <= FrameNum, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_12); + ret = SFM_2X_FrameSave(&s_2x2_FrameCtrl, (CM_UINT8)type, FrameNum, FrameIndex, pData, DataLen, + g_2x2oo2_rx[g_2x2oo2_base][type].p_rmt_mine_buf, + &g_2x2oo2_rx[g_2x2oo2_base][type].rmt_mine_len, + (CM_UINT32)g_2x2oo2_rx[g_2x2oo2_base][type].buf_size); + /*记录本机收到对系数据长度*/ + s_2x2_Ctrl.InPutDoublePassLen[type][0] = g_2x2oo2_rx[g_2x2oo2_base][type].rmt_mine_len; + /*- 是否收齐了全部数据同步报文 */ + if ((ENUM_CM_TRUE == ret) && (type == g_2x2RcvMaxNum[0])) + { + /*- 更新对系输入状态 */ + s_2x2_Ctrl.InputMineSysCyc = msgCyc; + MSCP_LOG_MSG("ret = %d, type = %d, 2x2RcvMaxNum = %d\r\n", ret, type, g_2x2RcvMaxNum[0]); + if((msgCyc == s_2x2_Ctrl.InputMineSysCyc) && (msgCyc == s_2x2_Ctrl.InputPeerSysCyc)) + { + /*- 更新对系本机输入数据同步报文周期号 */ + s_2x2_Ctrl.RxInputSysCyc = msgCyc; + MSCP_LOG_MSG("s_2x2_Ctrl.RxInputSysCyc = %d\r\n", s_2x2_Ctrl.RxInputSysCyc); + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + MSCP_LOG_MSG("msgCyc = %d, s_2x2_Ctrl.RxInputSysCyc = %d\r\n", msgCyc, s_2x2_Ctrl.RxInputSysCyc); + } + } + /*- 是否是对系邻机输入数据同步报文 */ + else if((type >= (g_2x2oo2_data_num+1) ) && (type <= g_2x2RcvMaxNum[1])) + { + /*- 是否收到新同步报文 */ + if (msgCyc >= s_2x2_Ctrl.RxInputSysCyc) + { + /*- 分帧接收数据同步报文 */ + CM_RE_ASSERT(FrameNum <= (SFM_OUTNETSAFE_BUFF_SIZE / NET_20K_SIZE), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_15); + CM_RE_ASSERT(FrameIndex <= FrameNum, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_16); + ret = SFM_2X_FrameSave(&s_2x2_FrameCtrl, (CM_UINT8)type, FrameNum, FrameIndex, pData, DataLen, + g_2x2oo2_rx[g_2x2oo2_base][type-g_2x2oo2_data_num].p_rmt_peer_buf, + &g_2x2oo2_rx[g_2x2oo2_base][type-g_2x2oo2_data_num].rmt_peer_len, + (CM_UINT32)g_2x2oo2_rx[g_2x2oo2_base][type-g_2x2oo2_data_num].buf_size); + /*记录对系邻机数据长度*/ + s_2x2_Ctrl.InPutDoublePassLen[type-g_2x2oo2_data_num][1] = g_2x2oo2_rx[g_2x2oo2_base][type-g_2x2oo2_data_num].rmt_peer_len; + /*- 是否收齐了全部数据同步报文 */ + if ((ENUM_CM_TRUE == ret) && (type == g_2x2RcvMaxNum[1])) + { + /*- 更新对系输入状态 */ + s_2x2_Ctrl.InputPeerSysCyc = msgCyc; + MSCP_LOG_MSG("p_rmt_peer_buf ret = %d, type = %d, 2x2RcvMaxNum = %d\r\n", ret, type, g_2x2RcvMaxNum[1]); + if((msgCyc == s_2x2_Ctrl.InputMineSysCyc) && (msgCyc == s_2x2_Ctrl.InputPeerSysCyc)) + { + /*- 更新对系邻机输入数据同步报文周期号 */ + s_2x2_Ctrl.RxInputSysCyc = msgCyc; + MSCP_LOG_MSG("s_2x2_Ctrl.RxInputSysCyc = %d\r\n", s_2x2_Ctrl.RxInputSysCyc); + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + MSCP_LOG_MSG("p_rmt_peer_buf msgCyc = %d, s_2x2_Ctrl.RxInputSysCyc = %d\r\n", msgCyc, s_2x2_Ctrl.RxInputSysCyc); + } + } + else + { + /*- 宕机 */ + CM_RE_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_13); + } + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_RCV_INPUT_STATE,5u, + sizeof(CM_UINT32),type, + sizeof(CM_UINT8),(msgCyc >= s_2x2_Ctrl.RxInputSysCyc), + sizeof(CM_UINT32),msgCyc, + sizeof(CM_UINT32),s_2x2_Ctrl.RxInputSysCyc, + sizeof(CM_UINT32),NOW_USED_TIME); + /*- 返回 */ + break; + }/* end switch */ + } + else + { + /*- 无处理 */ + } + }/* end if (0 < rxLen)*/ + else + { + /*- 无处理 */ + } + } while (0 < rxLen); + } + else + { + /*时间同步未完成,清空所有2x接收数据*/ + SFM_2x2_ClearRcvMsgQ(); + } + PFM_LOG_SET_STOPTIMER(TSCP_DARK_NULL); +} + +/** +* @brief 输入阶段2x2处理 +* @details +* 接收对系输入数据; +* 系内交换和比较; +* 更新热备状态并发送状态信息(主系)。 +*/ +void SFM_2x2_InputProc(void) +{ + /*- 变量初始化 */ + STRU_2X2_CTRL_T peerCtrl; /* 邻机热备状态 */ + CM_INT32 ret = 0; /* 临时变量 */ + CM_UINT32 sysCyc = SFM_2x2_GetSysCount(); /* 系统周期号 */ + CM_UINT32 len_prtcl = 0u; /* 协议跟随数据长度 */ + CM_UINT32 len_sfprtcl = 0u; /* 协议跟随数据长度 */ + CM_UINT32 len_pfm = 0u; /* 平台跟随数据长度 */ + CM_UINT64 sTick = 0u; /* 起始Tick */ + CM_UINT64 delta_Tick = 0u; /* Tickze增量 */ + CM_UINT64 curTick = 0u; /* 当前Tick */ + CM_UINT32 len = 0u; /* 临时变量 */ + /*######################## 发送跟随数据(主系)########################*/ + PFM_CFC_Check(33); + /*- 本系是否为主 */ + if ((ENUM_2x2_MASTER == s_2x2_Ctrl.LocalState)) + { + /*- 填写适配层(-1)跟随数据 */ + len = SFM_GetPrtclFollowData(g_TxBaseFollow + 4, (CM_UINT32)(sizeof(g_TxBaseFollow)) - 4u); + CM_LongToChar(len, g_TxBaseFollow); + g_TxBaseFollow_len = (CM_INT32)len + 4; + /*- 填写内网sfp跟随数据 */ + len = SFM_GetSfpPrtclFollowData(g_TxBaseFollow + g_TxBaseFollow_len, (CM_UINT32)(sizeof(g_TxBaseFollow)- g_TxBaseFollow_len - 4u)); + g_TxBaseFollow_len += len; + /*- 填写平台跟随数据 */ + /*- 填写平台跟随数据 */ + CM_RE_ASSERT(g_TxBaseFollow_len <= ((CM_INT32)sizeof(g_TxBaseFollow) - 12u), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_9);/*输出缓冲至少空闲8字节*/ + CM_LongToChar(8u, g_TxBaseFollow + g_TxBaseFollow_len); + CM_LongToChar(sysCyc, g_TxBaseFollow + g_TxBaseFollow_len + 4u); + CM_LongToChar(SFM_GetTxSn(), g_TxBaseFollow + g_TxBaseFollow_len + 8u); + g_TxBaseFollow_len += 12u; + /*- 发送 */ + SFM_2x2_Send(g_TxBaseFollow, (CM_UINT32)g_TxBaseFollow_len, ENUM_2x2_MSG_BASE_FOLLOW); + } + else + { + /*- 无处理 */ + } + MSCP_LOG_MSG("timecurr 3.1 Input 2x2Send = %lld us\n", NOW_USED_TIME); + /*########################2x2对系数据接收########################*/ + PFM_CFC_Check(34); + /*- 接收对系数据 */ + s_2x2_Recv(); + /*- 本系是否非主 */ + if (ENUM_2x2_MASTER != s_2x2_Ctrl.LocalState) + { + /*- 记录当前时刻 */ + sTick = CM_GetTick(); + CM_Sleep(2u); + curTick = CM_GetTick(); + delta_Tick = (CM_UINT64)CM_UNSIGNED_INT_EXP(g_PFM_Cfg.CYC_TIME * CM_UNSIGNED_MILLION / 10u); + /*- 持续接收对系输入同步数据,尝试(周期时间/5)ms */ + while (curTick < (sTick + delta_Tick)) + { + /*- 接收对系数据 */ + s_2x2_Recv(); + /*- 是否收到了预期的输入同步数据 */ + if ((s_2x2_Ctrl.RxInputSysCyc >= sysCyc) && + (s_2x2_Ctrl.RxBaseFollowSysCyc >= sysCyc) && + (s_2x2_Ctrl.RxBaseFollowSysCyc > 0u)) + { + /*- 退出循环 */ + break; + } + else + { + /*- 无处理 */ + } + /*- 延时等待 */ + CM_Sleep(2u); + curTick = CM_GetTick(); + } + } + else + { + /*- 无处理 */ + } + MSCP_LOG_MSG("timecurr 3.2 Input 2x2Send = %lld us\n", NOW_USED_TIME); + /*########################2x2对系数据交换和比较########################*/ + /*- 是否开启2oo2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 更新控制流状态 */ + PFM_CFC_Check(35); + /*- 系内同步(状态校验,对系状态报文同步)*/ + s_Ctrl_2oo2Sync(&peerCtrl); + + /*- @alias 系内交换输入数据 */ + PFM_CFC_Check(36); + + /*- 是否需要向邻机发送输入同步数据 */ + /* 如果需要交换对于cpu1的本机数据,相当于cpu2的邻机数据,cpu1的邻机数据,相当于cpu2的本机数据 */ + /*- @alias 系内同步Rx输入信息状态,用来过滤老的输入数据,并且将新的数据进行2oo2交换*/ + SFM_2x2_Input2oo2Exchange(&peerCtrl); + /*- 跟新输入同步周期号*/ + if(s_2x2_Ctrl.RxInputSysCyc > peerCtrl.RxInputSysCyc) + { + /*- 更新临机输入同步周期号*/ + peerCtrl.RxInputSysCyc = s_2x2_Ctrl.RxInputSysCyc; + } + else if(s_2x2_Ctrl.RxInputSysCyc < peerCtrl.RxInputSysCyc) + { + /*- 更新本机输入同步周期号*/ + s_2x2_Ctrl.RxInputSysCyc = peerCtrl.RxInputSysCyc; + } + else + { + /*- 周期号相同 不做修改*/; + } + + /*- 更新控制流状态 */ + PFM_CFC_Check(37); + /* (这个数据量很大,只在必要时同步) */ + /*- @alias 系内同步Rx跟随数据*/ + if (s_2x2_Ctrl.RxBaseFollowSysCyc > peerCtrl.RxBaseFollowSysCyc) + { + /*需要向邻机发送跟随数据*/ + ret = SFM_2oo2_Exchange_Currency(g_RxBaseFollow, g_RxBaseFollow_len, g_RxBaseFollow, (CM_UINT32)0, ENUM_2oo2_INPUT_EX);/*通过输入"0"防止g_RxFollow被修改*/ + CM_RE_ASSERT(0 == ret, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_1); + } + else if (s_2x2_Ctrl.RxBaseFollowSysCyc < peerCtrl.RxBaseFollowSysCyc) + { + /*需要从邻机接收跟随数据*/ + g_RxBaseFollow_len = SFM_2oo2_Exchange_Currency(g_RxBaseFollow, (CM_INT32)0, g_RxBaseFollow, (CM_UINT32)sizeof(g_RxBaseFollow), ENUM_2oo2_INPUT_EX);/*通过输入"0"实现只收不发*/ + s_2x2_Ctrl.RxBaseFollowSysCyc = peerCtrl.RxBaseFollowSysCyc; + } + else + { + /* 无需处理 */ + } + } + else + { + /*- 更新控制流状态 */ + PFM_CFC_Check(35); + PFM_CFC_Check(36); + PFM_CFC_Check(37); + } + /*########################状态机更新########################*/ + PFM_CFC_Check(38); + /*########################关键数据覆盖########################*/ + PFM_CFC_Check(39); + /*- 本系是否为离线或备 */ + if ((ENUM_2x2_OFFLINE == s_2x2_Ctrl.LocalState) + || (ENUM_2x2_SLAVE == s_2x2_Ctrl.LocalState)) + { + if ((g_RxBaseFollow_len >= 12u) && (s_2x2_Ctrl.RxBaseFollowSysCyc > 0u))/*通过数据长度判断是否有新数据*/ + { + /*- 适配层协议数据跟随*/ + len_prtcl = CM_LongFromChar(g_RxBaseFollow); + CM_RE_ASSERT(len_prtcl <= ((CM_UINT32)g_RxBaseFollow_len - 4u), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_3); + SFM_SetPrtclFollowData(g_RxBaseFollow + 4u); + + /*- sfp协议数据跟随*/ + len_sfprtcl = CM_LongFromChar(g_RxBaseFollow + 4u + len_prtcl); + CM_RE_ASSERT(len_prtcl + len_sfprtcl <= ((CM_UINT32)g_RxBaseFollow_len - 8u), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_10); + SFM_SetSfpPrtclFollowData(len_sfprtcl, g_RxBaseFollow + 4u + len_prtcl + 4u); + + /*- 平台数据跟随*/ + len_pfm = CM_LongFromChar(g_RxBaseFollow + 4u + len_prtcl + 4u); + CM_RE_ASSERT(len_pfm == ((CM_UINT32)g_RxBaseFollow_len - len_prtcl - len_sfprtcl - 12u), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_4); + CM_RE_ASSERT(len_pfm == 8u, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_5); + /*此处使用临时周期号接收,在周期末同步*/ + s_2x2_Ctrl.SysCycSync = CM_LongFromChar(g_RxBaseFollow + 12u + len_prtcl + len_sfprtcl); /* parasoft-suppress BD-PB-CHECKRET "此处无需检查CM_LongFromChar()的返回值" */ + SFM_SetTxSn(CM_LongFromChar(g_RxBaseFollow + 12u + len_prtcl + len_sfprtcl + 4u)); + + /*- 本周期是否跟随成功 */ + /*- 记录本次跟随时间 */ + s_2x2_Ctrl.LastFollowCyc = s_2x2_Ctrl.RxBaseFollowSysCyc; + MSCP_LOG_MSG("follow cyc = %d->%d\n",s_2x2_Ctrl.LastFollowCyc,sysCyc); + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_BASE_FOLLOW_HANDLE,4u, + sizeof(CM_UINT8),1u, + sizeof(CM_UINT32),sysCyc, + sizeof(CM_UINT32),s_2x2_Ctrl.LastFollowCyc, + sizeof(CM_UINT32),NOW_USED_TIME); + } + else + { + MSCP_LOG_MSG("err follow cyc = %d->%d\n",s_2x2_Ctrl.RxBaseFollowSysCyc,sysCyc); + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_BASE_FOLLOW_HANDLE,4u, + sizeof(CM_UINT8),0u, + sizeof(CM_UINT32),sysCyc, + sizeof(CM_UINT32),s_2x2_Ctrl.LastFollowCyc, + sizeof(CM_UINT32),NOW_USED_TIME); + } + } + else + { + /*- 无处理 */ + } + /*- 清除待发送的平台跟随数据 */ + g_TxBaseFollow_len = 4; + CM_LongToChar(0u, g_TxBaseFollow); + + g_RxBaseFollow_len = 0; + /* @see :: SFM_2x2_OutputProc */ +} + +/** +* @brief 输出阶段2x2处理 +* @param CheckBuf 输出校验报文数组 +* @param CheckLen 输出校验报文长度 +* @details +* 主系发送/备系接收输出校验报文; +* 接收对系状态; +* 系内交换; +* 输出校验(非主); +* 更新热备状态并发送状态数据(非主); +* 生成和发送跟随数据(主系)。 +*/ +void SFM_2x2_OutputProc(IN const CM_UINT8 *CheckBuf, CM_INT32 CheckLen) +{ + /*- 变量初始化 */ + STRU_2X2_CTRL_T peerCtrl = { 0 }; /* 邻机热备状态 */ + CM_UINT32 sysCyc = SFM_2x2_GetSysCount(); /* 系统周期号 */ + CM_INT32 ret = 0; /* 临时变量 */ + CM_UINT64 sTick = 0u; /* 起始Tick */ + CM_UINT64 delta_Tick = 0u; /* Tickze增量 */ + CM_UINT64 curTick = 0u; /* 当前Tick */ + ENUM_CM_RETURN retError = ENUM_CM_FALSE; + CM_UINT32 i = 0u; + /*- 入参检查 */ + CM_ASSERT(NULL != CheckBuf, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_1); + /*########################发送输出校验########################*/ + PFM_CFC_Check(10); + /*- 本系是否为主系 */ + if (ENUM_2x2_MASTER == s_2x2_Ctrl.LocalState) + { + /*- 发送输出校验帧*/ + SFM_2x2_Send(CheckBuf, (CM_UINT32)CheckLen, ENUM_2x2_MSG_OUTCHECK); + } + else + { + /*- 无处理 */ + } + + /*########################接收对系报文########################*/ + PFM_CFC_Check(11); + /*- 接收2x2数据(状态帧、输出校验帧)*/ + /*- 本系是否非主 */ + if (ENUM_2x2_MASTER != s_2x2_Ctrl.LocalState) + { + /*- 记录当前时刻 */ + sTick = CM_GetTick(); + curTick = CM_GetTick(); + delta_Tick = (CM_UINT64)CM_UNSIGNED_INT_EXP(g_PFM_Cfg.CYC_TIME * CM_UNSIGNED_MILLION / 10u); + /*- 持续接收对系输出校验帧 */ + while (curTick < (sTick + delta_Tick)) + { + /*- 接收对系数据 */ + s_2x2_Recv(); + /*- 是否收到了预期的输出校验帧 */ + if (s_2x2_Ctrl.RxCheckSysCyc >= sysCyc) + { + /*- 退出循环 */ + break; + } + else + { + /*- 无处理 */ + } + /*- 延时等待 */ + CM_Sleep(2u); + curTick = CM_GetTick(); + } + } + else + { + /*- 无处理 */ + } + + /*########################系内交换########################*/ + PFM_CFC_Check(12); + /*- @alias 系内同步(状态校验,对系状态报文同步) */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + s_Ctrl_2oo2Sync(&peerCtrl); + + /*- @alias 系内同步输出校验帧信息 */ + if (s_2x2_Ctrl.RxCheckSysCyc < peerCtrl.RxCheckSysCyc) + { + s_2x2_Ctrl.RxCheckSysCyc = peerCtrl.RxCheckSysCyc; + s_2x2_Ctrl.RxCheckLen = peerCtrl.RxCheckLen; + retError = CM_Memset((void*)s_2x2_Ctrl.RxCheckFrame, (CM_UINT8)0u, sizeof(s_2x2_Ctrl.RxCheckFrame), sizeof(s_2x2_Ctrl.RxCheckFrame)); + CM_RE_ASSERT(ENUM_CM_TRUE == retError, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_2); + (void)CM_Memcpy((void*)s_2x2_Ctrl.RxCheckFrame, sizeof(s_2x2_Ctrl.RxCheckFrame), (void*)peerCtrl.RxCheckFrame, (CM_SIZE_T)(peerCtrl.RxCheckLen)); + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + + + /*######################## 输出校验(非主)########################*/ + PFM_CFC_Check(13); + /*- 本系是否为备系或离线 */ + if ((ENUM_2x2_SLAVE == s_2x2_Ctrl.LocalState) || (ENUM_2x2_OFFLINE == s_2x2_Ctrl.LocalState)) + { + /*- 检查输出校验数据是否一致且为最新 */ + if ((sysCyc == s_2x2_Ctrl.RxCheckSysCyc) && (CheckLen == s_2x2_Ctrl.RxCheckLen)) + { + /*- 进行输出比较 */ + ret = CM_Memcmp((const void*)CheckBuf, (void*)s_2x2_Ctrl.RxCheckFrame, (CM_SIZE_T)CheckLen); + /*- 输出比较是否一致 */ + if (0 == ret) + { + /*- 更新输出比较状态 */ + s_2x2_Ctrl.LastCheckOKCount = SFM_2x2_GetSysCount(); + s_2x2_Ctrl.OutPutCheckFailFlag = 0u; + MSCP_LOG_MSG("Out Put Success!\n"); + } + else + { + /*- 更新OutPutCheckFailFlag则降级为离线,因为如果收到输出数据但是比较失败,则降为离线状态 */ + s_2x2_Ctrl.OutPutCheckFailFlag = 1u; + for(i = 0u;i < CheckLen;i++) + { + if(CheckBuf[i] == s_2x2_Ctrl.RxCheckFrame[i]) + { + + } + else + { + /*- 跳出 */ + break; + } + } + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_OUT_CHECK_FAIL,3u, + sizeof(CM_UINT8),s_2x2_Ctrl.OutPutCheckFailFlag, + sizeof(CM_UINT32),i, + sizeof(CM_UINT32),s_2x2_Ctrl.RxCheckSysCyc); + MSCP_LOG_MSG("Out Put failed_[%d]!\n",i); + MSCP_LOG_BIN(CheckBuf,CheckLen); + if(ENUM_2x2_SLAVE == s_2x2_Ctrl.LocalState) + { + CM_RE_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_8, TSCP_DARK_ASSERT_3); + } + else + { + /*- 无处理 */ + } + } + } + else + { + MSCP_LOG_MSG("2x2Follow:[%d,%d,%d,%d][%d,%d][%d,%d]\n", + sysCyc, s_2x2_Ctrl.RxInputSysCyc, s_2x2_Ctrl.LastFollowCyc, s_2x2_Ctrl.RxCheckSysCyc, + s_2x2_Ctrl.RxBaseFollowSysCyc,s_2x2_Ctrl.RxAppFollowSysCyc,CheckLen, s_2x2_Ctrl.RxCheckLen); + } + } + else + { + /*- 无处理 */ + } + PFM_CFC_Check(14); + /*######################## 更新热备状态并发送状态数据(非主)########################*/ + /*- 暗文记录二乘通信状态(输出微周期后平台周期结束) */ + SFM_2x2_Eth422StateDark(); +} + +/** +* @brief 应用跟随数据接收 +* @param sysCyc 系统周期号(0~0xFFFF) stat 本机热备状态(0~4) +* @details +* 接收主系发送的应用跟随数据 +*/ +static void SFM_2x2_RecvAppFollowData(CM_UINT32 sysCyc, ENUM_2x2_STATE_T stat) +{ + CM_UINT64 delta_Tick = 0u; + CM_UINT64 curTick = 0u; /* 当前时刻 */ + CM_UINT64 sTick[3] = {0u}; /* 起始Tick */ + CM_INT32 ret = 0; /* 返回值 */ + STRU_2X2_CTRL_T peerCtrl = { 0 }; /* 邻机2x2状态 */ + if(ENUM_2x2_SLAVE == stat) + { + delta_Tick = (CM_UINT64)CM_UNSIGNED_INT_EXP(g_PFM_Cfg.CYC_TIME * CM_UNSIGNED_MILLION/10u); + } + else + { + delta_Tick = (CM_UINT64)CM_UNSIGNED_INT_EXP(g_PFM_Cfg.CYC_TIME * CM_UNSIGNED_MILLION/5u); + } + + sTick[0] = CM_GetTick(); + /*- 持续接收对系输入同步数据,尝试(周期时间/10)ms */ + do + { + /*- 接收2x2数据 */ + /*- 是否收到了应用跟随数据 */ + s_2x2_Recv(); + if (s_2x2_Ctrl.RxAppFollowSysCyc >= sysCyc) + { + /*- 返回 */ + MSCP_LOG_MSG("rx app follow success\n"); + /*- 跳出 */ + break; + } + else + { + /*- 无处理 */ + } + CM_Sleep(2u); + curTick = CM_GetTick(); + } while (curTick < (sTick[0] + delta_Tick)); + sTick[1] = CM_GetTick(); + + if(0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 2oo2同步本系热备状态 */ + s_Ctrl_2oo2Sync(&peerCtrl); + /*- 是否需要向邻机发送应用同步数据 */ + if (s_2x2_Ctrl.RxAppFollowSysCyc > peerCtrl.RxAppFollowSysCyc) + { + /*- 自己是否是备系*/ + if(ENUM_2x2_SLAVE == stat) + { + /*- 发送跟随数据的CRC和长度*/ + MSCP_LOG_MSG("A-B:g_RxAppFollowCrc_len:%lld\n",g_RxAppFollowCrc_len); + ret = SFM_2oo2_Exchange_Currency(g_RxAppFollowCrc, g_RxAppFollowCrc_len, g_RxAppFollowCrc, 0u, ENUM_2oo2_END_EX); + } + else + { + /*- 发送全部应用跟随数据*/ + MSCP_LOG_MSG("A-B:g_RxAppFollow_len:%lld\n",g_RxAppFollow_len); + ret = SFM_2oo2_Exchange_Currency(g_RxAppFollow, g_RxAppFollow_len, g_RxAppFollow, 0u, ENUM_2oo2_END_EX); + } + + CM_RE_ASSERT(0 == ret, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_1); + } + /*- 是否需要从邻机接收应用同步数据 */ + else if (s_2x2_Ctrl.RxAppFollowSysCyc < peerCtrl.RxAppFollowSysCyc) + { + /*- 自己是否是备系*/ + if(ENUM_2x2_SLAVE == stat) + { + /*- 接收应用跟随数据的CRC和长度*/ + MSCP_LOG_MSG("B-A:g_RxAppFollowCrc_len:%lld\n",g_RxAppFollowCrc_len); + g_RxAppFollow_len = SFM_2oo2_Exchange_Currency(g_RxAppFollowCrc, 0, g_RxAppFollowCrc, sizeof(g_RxAppFollowCrc), ENUM_2oo2_END_EX); + } + else + { + /*- 接收全部应用跟随数据*/ + MSCP_LOG_MSG("B-A:g_RxAppFollow_len:%lld\n",g_RxAppFollow_len); + g_RxAppFollow_len = SFM_2oo2_Exchange_Currency(g_RxAppFollow, 0, g_RxAppFollow, sizeof(g_RxAppFollow), ENUM_2oo2_END_EX); + } + /*- 更新结接收应用跟随数据周期号*/ + s_2x2_Ctrl.RxAppFollowSysCyc = peerCtrl.RxAppFollowSysCyc; + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + } + sTick[2] = CM_GetTick(); + MSCP_LOG_MSG("2xRecv over time = %lld ,2oo2 time = %lld\n",(sTick[1] - sTick[0]) / 1000u, (sTick[2] - sTick[1]) / 1000u); +} + +/** +* @brief 周期末处理 +*/ +void SFM_2x2_EndProc(void) +{ + /*- 变量初始化 */ + CM_UINT32 sysCyc = SFM_2x2_GetSysCount(); /* 系统周期号 */ + ENUM_2x2_STATE_T stat = SFM_2x2_GetLocal2x2State(); /* 本机热备状态 */ + ENUM_CM_RETURN retFollowUp = ENUM_CM_FALSE; + CM_UINT64 curTickTest[10] = {0u}; /* 当前时刻 */ + CM_INT32 cmp_ret = 1; + + switch(stat) + { + case ENUM_2x2_MASTER: + curTickTest[0] = CM_GetTick(); + if(ENUM_2x2_SLAVE == SFM_2x2_GetPartner2x2State()) + { + /*- 发送跟随数据 */ + SFM_2x2_Send(g_TxAppFollow, (CM_UINT32)8, ENUM_2x2_MSG_APP_FOLLOW_CRC); + MSCP_LOG_MSG("Iam master partner is slave send appfollowcrc\n"); + } + else + { + SFM_2x2_Send(g_TxAppFollow + 4, (CM_UINT32)g_TxAppFollow_len, ENUM_2x2_MSG_APP_FOLLOW); + MSCP_LOG_MSG("Iam master partner is offline send appfollow\n"); + } + curTickTest[1] = CM_GetTick(); + break; + case ENUM_2x2_SLAVE: + SFM_2x2_RecvAppFollowData(sysCyc, stat); + curTickTest[0] = CM_GetTick(); + if (s_2x2_Ctrl.RxAppFollowSysCyc >= sysCyc) + { + cmp_ret = CM_Memcmp(g_TxAppFollow, g_RxAppFollowCrc, 8);//如果同步失败 备系降为离线 + if(0 == cmp_ret) + { + /*- 跟随数据和主系一致*/ + s_2x2_Ctrl.AppFollowCmpFlag = 0u; + MSCP_LOG_MSG("CRC cmp is OK\n"); + } + else + { + /*- 比较失败 降离线*/ + s_2x2_Ctrl.AppFollowCmpFlag = 1u; + MSCP_LOG_MSG("CRC cmp is fail\n"); + } + } + else + { + /*没有收到数据 将离线*/ + s_2x2_Ctrl.AppFollowCmpFlag = 1u; + } + curTickTest[1] = CM_GetTick(); + break; + case ENUM_2x2_OFFLINE: + case ENUM_2x2_PRE_MASTER: + SFM_2x2_RecvAppFollowData(sysCyc, stat); + curTickTest[0] = CM_GetTick(); + /* 应用跟随数据覆盖 */ + /*- 是否收到了最新的应用跟随数据 */ + if (s_2x2_Ctrl.RxAppFollowSysCyc >= sysCyc) + { + /*- 调用应用API覆盖应用关键数据 */ + retFollowUp = APP_API_FollowUp(g_RxAppFollow, (CM_UINT32)g_RxAppFollow_len); + CM_RE_ASSERT(ENUM_CM_TRUE == retFollowUp, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_2); + s_2x2_Ctrl.AppFollowCmpFlag = 0u; + } + else + { + s_2x2_Ctrl.AppFollowCmpFlag = 1u; + } + curTickTest[1] = CM_GetTick(); + break; + default: + break; + } + MSCP_LOG_MSG("slef stata is %d use time = %lld\n",stat,(curTickTest[1] - curTickTest[0]) / 1000u); + /*更新周期号*/ + if ((s_2x2_Ctrl.RxBaseFollowSysCyc >= sysCyc) && (ENUM_2x2_MASTER != stat)) + { + g_MSCP_SysCount = s_2x2_Ctrl.SysCycSync; + } + else + { + ; + } + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_APP_FOLLOW_HANDLE,2u, + sizeof(CM_UINT32),s_2x2_Ctrl.RxAppFollowSysCyc, + sizeof(CM_UINT32),(curTickTest[1] - curTickTest[0])/1000u); + /*主线程状态同步到应用*/ + s_2x2_Ctrl.LastLocalState = s_2x2_Ctrl.LocalState; + s_2x2_Ctrl.LastPartnerState = s_2x2_Ctrl.PartnerState; + (void)SFM_2x2_SyncIoInput(s_2x2_InputIoState,40u); + /*- 清空待发送的应用跟随数据,待应用下周期填写 */ + g_TxAppFollow_len = 4; + CM_LongToChar(0u, g_TxAppFollow); +} + +/** +* @brief 系内热备状态同步 +* @param pPeerCtrl 邻机热备信息 +* details +* 系内交换热备信息; +* 校验2oo2双机的热备状态是否一致; +* 系内同步对系连接状态; +* 系内同步收到的状态帧信息。 +*/ +static void s_Ctrl_2oo2Sync(OUT STRU_2X2_CTRL_T *pPeerCtrl) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = 0; + ENUM_CM_RETURN retError = ENUM_CM_FALSE; + /*- 入参检查 */ + CM_ASSERT(NULL != pPeerCtrl, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_10); + /* 本机自检状态也需要同步到邻机 */ + /*- 系内交换热备状态信息 */ + retError = CM_Memset(pPeerCtrl, (CM_UINT8)0, sizeof(STRU_2X2_CTRL_T), sizeof(STRU_2X2_CTRL_T)); + CM_RE_ASSERT(ENUM_CM_TRUE == retError, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_1); + rxLen = SFM_2oo2_Exchange_Currency((CM_UINT8*)&s_2x2_Ctrl, (CM_INT32)sizeof(s_2x2_Ctrl), (CM_UINT8*)pPeerCtrl, (CM_UINT32)sizeof(STRU_2X2_CTRL_T), ENUM_2oo2_INPUT_MS); + CM_RE_ASSERT(rxLen == (CM_INT32)sizeof(s_2x2_Ctrl), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_2); + /*- 校验2oo2双机的热备状态是否一致 */ + CM_RE_ASSERT(s_2x2_Ctrl.LocalState == pPeerCtrl->LocalState, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_3); + CM_RE_ASSERT(s_2x2_Ctrl.PartnerState == pPeerCtrl->PartnerState, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_4); + + CM_RE_ASSERT(s_2x2_Ctrl.LastFollowCyc == pPeerCtrl->LastFollowCyc, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_5); + CM_RE_ASSERT(s_2x2_Ctrl.LastCheckOKCount == pPeerCtrl->LastCheckOKCount, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_6); + CM_RE_ASSERT(s_2x2_Ctrl.LastLocalState == pPeerCtrl->LastLocalState, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_7); + CM_RE_ASSERT(s_2x2_Ctrl.LastPartnerState == pPeerCtrl->LastPartnerState, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_8); + CM_RE_ASSERT(s_2x2_Ctrl.OutPutCheckFailFlag == pPeerCtrl->OutPutCheckFailFlag, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_9); + CM_RE_ASSERT(s_2x2_Ctrl.AppFollowCmpFlag == pPeerCtrl->AppFollowCmpFlag, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_10, TSCP_DARK_ASSERT_12); +} + +/** +* @brief 获取本系热备状态 +* @return 本系热备状态 +* - ENUM_2x2_OFFLINE 离线 +* - ENUM_2x2_PRE_MASTER 预升主 +* - ENUM_2x2_MASTER 主系 +* - ENUM_2x2_SLAVE 备系 +* @details +* 所有状态下周期应用逻辑都会被执行 +* 只有“主系”状态下本机的输出才会被真实输出 +* 在“离线”和“备系”状态下且本周期收到有效跟随数据时, +* 将在周期应用逻辑执行之前进行跟随数据覆盖。 +* @see :: APP_API_FollowUp +*/ +ENUM_2x2_STATE_T SFM_2x2_GetLocal2x2State(void) +{ + /*每次查询控制主备指示灯*/ + if(ENUM_2x2_MASTER == s_2x2_Ctrl.LocalState) + { + DFM_ledMS(1u); + } + else if(ENUM_2x2_SLAVE == s_2x2_Ctrl.LocalState) + { + DFM_ledMS(3u); + } + else + { + DFM_ledMS(0u); + } + /*- 输出本系热备状态 */ + return CM_ATOMIC_LOAD(&s_2x2_Ctrl.LocalState); +} + +/** +* @brief 获取对系热备状态 +* @return 对系热备状态 +* - ENUM_2x2_SHUTDOWN 宕机 +* - ENUM_2x2_OFFLINE 离线 +* - ENUM_2x2_PRE_MASTER 预升主 +* - ENUM_2x2_MASTER 主系 +* - ENUM_2x2_SLAVE 备系 +* @details +* 与对系通信中断时默认对系状态为“宕机” +*/ +ENUM_2x2_STATE_T SFM_2x2_GetPartner2x2State(void) +{ + /*- 输出对系热备状态 */ + return CM_ATOMIC_LOAD(&s_2x2_Ctrl.PartnerState); +} + + +/* +* @brief 获取上一周期的本系热备状态 +* @return 本系热备状态 +* - ENUM_2x2_OFFLINE 离线 +* - ENUM_2x2_PRE_MASTER 预升主 +* - ENUM_2x2_MASTER 主系 +* - ENUM_2x2_SLAVE 备系 +* @note +* 宕机状态下应用逻辑不会被执行, +* 所以应用本函数不可能返回“宕机”。 +* 其它状态下周期应用逻辑都会被执行, +* 但只有“主系”状态下本机的输出才会被真实输出, +* 在“离线”和“备系”状态下且本周期收到有效跟随数据时, +* 将在周期应用逻辑执行之前进行跟随数据覆盖。 +*/ +ENUM_2x2_STATE_T SFM_2x2_GetLastLocal2x2State(void) +{ + return CM_ATOMIC_LOAD(&s_2x2_Ctrl.LastLocalState); +} + +/** +* @brief 获取对系上一周期的热备状态 +* @return 对系热备状态 +* - ENUM_2x2_SHUTDOWN 宕机 +* - ENUM_2x2_OFFLINE 离线 +* - ENUM_2x2_PRE_MASTER 预升主 +* - ENUM_2x2_MASTER 主系 +* - ENUM_2x2_SLAVE 备系 +* @note +* 与对系通信中断时默认对系状态为“宕机” +*/ +ENUM_2x2_STATE_T SFM_2x2_GetLastPartner2x2State(void) +{ + return CM_ATOMIC_LOAD(&s_2x2_Ctrl.LastPartnerState); +} + +/** +* @brief 设置跟随数据 +* @param Data 跟随数据数组 +* @param Len 跟随数据长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 本系为主系时,应用应当每周期设置一次跟随数据。 +* 跟随数据量最大为1024*1000字节。 +* (本系非主时的调用、单周期多次调用,都将被return 0) +* @see :: APP_API_FollowUp +*/ +CM_UINT8 SFM_2x2_SetFollowData(IN const CM_UINT8 Data[], IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + CM_UINT32 crc = 0u; + /*- 检查输入是否合法 */ + if ((NULL != Data) + && (Len < (CM_UINT32)(MSCP_FOLLOW_BUFF_SIZE)) + && (0u < Len)) + { + /*- 保存应用跟随数据 */ + g_TxAppFollow_len = (CM_INT32)CM_UNSIGNED_INT_EXP(Len + 4u); + crc = CM_Crc32(Data, Len); + CM_LongToChar(crc, g_TxAppFollow); + CM_LongToChar(Len, g_TxAppFollow + 4); + (void)CM_Memcpy((void*)(g_TxAppFollow + 8), sizeof(g_TxAppFollow) - 8u, Data, (CM_SIZE_T)Len); + rt = 1u; + } + else + { + /*- 无处理 */ + MSCP_LOG_MSG("App SetFollowData failed Len = %d\n",Len); + } + CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_2X2_APPSET_FOLLOW,4u,&Len); + /*- 返回执行结果 */ + return rt; +} + +/** +* @brief 获取系统周期号 +* @return 当前的系统周期号 +* @details +* 一个固定周期自增的周期号; +* 对于2x2系统,2x2双系的周期号会被自动同步到与主系一致 +*/ +CM_UINT32 SFM_2x2_GetSysCount(void) +{ + /*- 输出系统周期号 */ + return g_MSCP_SysCount; +} +/** +* @brief 更新本周期通信状态通用函数 +* @param ComOKCountBuf 更新状态通信ok次数数组 +* @param ComOKCount 通信OK次数 +* @return 无 +* @details +* 更新本周期通信状态,将历史状态信息移位保存 +*/ +void MSCP_UpData_2X_This_ComState(STRU_2X2_COM_STATE_RECORD_T *ComOKCount,CM_UINT32 SysCyc,CM_UINT8 MicroCyc) +{ + CM_UINT8 i = 0u; /* 循环次数 */ + if(NULL != ComOKCount) + { + /*向前滑动*/ + for(i = 0u; i < MSCP_2X2_COM_THIS_STATE_NUM;i++) + { + ComOKCount[i].SysCyc = ComOKCount[i+1].SysCyc; + ComOKCount[i].MicroCyc = ComOKCount[i+1].MicroCyc; + } + /*更新本周期次数*/ + ComOKCount[MSCP_2X2_COM_THIS_STATE_NUM].SysCyc = SysCyc; + ComOKCount[MSCP_2X2_COM_THIS_STATE_NUM].MicroCyc = MicroCyc; + } + else + { + CM_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_1); + } +} +/** +* @brief 获取通信断开次数通用函数 +* @param ComOKCountBuf 更新状态通信ok次数数组 +* @param BeforeCycNum 查询前几个周期序号,例如:0代表本周期, +* @return 通信断开的次数 +* @details +* 可向前查询通信正常次数周期号 +*/ +CM_UINT32 MSCP_Get_2X_DisCom_Count(STRU_2X2_COM_STATE_RECORD_T *ComOKCount,CM_UINT8 BeforeCycNum) +{ + CM_UINT32 val = 0u; + CM_INT32 SysCycDval = 0u; + CM_INT8 MicroCycDval = 0u; + if((NULL != ComOKCount) && (BeforeCycNum <= MSCP_2X2_COM_THIS_STATE_NUM)) + { + /*计算公式:B、A主周期号,b、a微周期号。|(B-A)xn-|(b-a)||*/ + SysCycDval = (s_2x2_state_Ctrl.SysCyc - ComOKCount[MSCP_2X2_COM_THIS_STATE_NUM - BeforeCycNum].SysCyc) * s_2x2_thread_Ctrl.number_Cyc; + MicroCycDval = CM_ABS(s_2x2_state_Ctrl.MicroCyc - ComOKCount[MSCP_2X2_COM_THIS_STATE_NUM - BeforeCycNum].MicroCyc); + val = CM_ABS(SysCycDval - MicroCycDval); + } + else + { + CM_ASSERT(0, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_1); + } + return val; +} +/** +* @brief 获取通信状态 +* @param ComOKCountBuf 更新状态通信ok次数数组 +* @param BeforeCycNum 查询前几个周期序号,例如:0代表本周期, +* @return ENUM_CM_TRUE = 0x55 成功 + ENUM_CM_FALSE = 0xAA 失败 +* @details +*可向前查询通信状态 +*/ +ENUM_CM_RETURN MSCP_Get_2X_Com_State(STRU_2X2_COM_STATE_RECORD_T *ComOKCount,CM_UINT8 BeforeCycNum) +{ + ENUM_CM_RETURN rtnval = ENUM_CM_FALSE; + CM_UINT32 Cycval = 0u; + CM_ASSERT(NULL != ComOKCount, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_1); + Cycval = MSCP_Get_2X_DisCom_Count(ComOKCount,BeforeCycNum); + /*周期通信成功的标志,预测差值,计算前几个周期的数据*/ + if(BeforeCycNum == Cycval) + { + rtnval = ENUM_CM_TRUE; + } + else + { + rtnval = ENUM_CM_FALSE; + } + return rtnval; +} +/** +* @brief 获取模糊通信状态 +* @param ComOKCountBuf 更新状态通信ok次数数组 +* @return CM_TRUE 成功 + CM_FALSE 失败 +*/ +CM_BOOL MSCP_Get_2X_VagueCom_State(STRU_2X2_COM_STATE_RECORD_T *ComOKCount) +{ + CM_UINT8 i = 0u; + CM_ASSERT(NULL != ComOKCount, SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_15, TSCP_DARK_ASSERT_1); + /*判断主周期号,本周期只要收到同步数据即返回成功*/ + for(i = 0;i <= MSCP_2X2_COM_THIS_STATE_NUM;i++) + { + if(s_2x2_state_Ctrl.SysCyc == ComOKCount[i].SysCyc) + { + return CM_TRUE; + } + } + return CM_FALSE; +} +/** +* @brief 和邻机交换从对系获得的输入数据 +* @param pPeerCtrl:邻机状态 取值范围:非空 +* @return 无 +*/ +static void SFM_2x2_Input2oo2Exchange(STRU_2X2_CTRL_T *peerCtrl) +{ + /*- 变量初始化 */ + CM_UINT32 i = 0u; + CM_INT32 len = 0; + + /*- @alias 系内交换输入数据 */ + for (i = 1u; i <= g_2x2oo2_data_num; i++) + { + if(CM_TRUE == g_2x2oo2_rx[g_2x2oo2_base][i].b_2x2_Enable) + { + MSCP_LOG_MSG("SFM_2x2_Input2oo2Exchange-CPU1[%d]:[M0:%d,P1:%d][M1:%d,P0:%d]\r\n",i,s_2x2_Ctrl.InPutDoublePassLen[i][0],peerCtrl->InPutDoublePassLen[i][1],s_2x2_Ctrl.InPutDoublePassLen[i][1],peerCtrl->InPutDoublePassLen[i][0]); + /*本机数据交互*/ + if(s_2x2_Ctrl.InPutDoublePassLen[i][0] < peerCtrl->InPutDoublePassLen[i][1]) + { + /*接收对方数据,自己发送长度为0*/ + g_2x2oo2_rx[g_2x2oo2_base][i].rmt_mine_len = SFM_2oo2_Exchange_Currency( + g_2x2oo2_rx[g_2x2oo2_base][i].p_rmt_mine_buf, + 0, + g_2x2oo2_rx[g_2x2oo2_base][i].p_rmt_mine_buf, + g_2x2oo2_rx[g_2x2oo2_base][i].buf_size, + ENUM_2oo2_INPUT_EX); + } + else if(s_2x2_Ctrl.InPutDoublePassLen[i][0] > peerCtrl->InPutDoublePassLen[i][1]) + { + /*- 向邻机发送数据,本机不接收,传入接收长度为0*/ + len = SFM_2oo2_Exchange_Currency( + g_2x2oo2_rx[g_2x2oo2_base][i].p_rmt_mine_buf, + g_2x2oo2_rx[g_2x2oo2_base][i].rmt_mine_len, + g_2x2oo2_rx[g_2x2oo2_base][i].p_rmt_mine_buf, + 0, + ENUM_2oo2_INPUT_EX); + CM_RE_ASSERT((0 == len), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_1); + } + else + { + /*等于不交互,包括0*/ + } + /*邻机数据交互*/ + if(s_2x2_Ctrl.InPutDoublePassLen[i][1] < peerCtrl->InPutDoublePassLen[i][0]) + { + /*接收对方数据,自己发送长度为0*/ + g_2x2oo2_rx[g_2x2oo2_base][i].rmt_peer_len = SFM_2oo2_Exchange_Currency( + g_2x2oo2_rx[g_2x2oo2_base][i].p_rmt_peer_buf, + 0, + g_2x2oo2_rx[g_2x2oo2_base][i].p_rmt_peer_buf, + g_2x2oo2_rx[g_2x2oo2_base][i].buf_size, + ENUM_2oo2_INPUT_EX); + } + else if(s_2x2_Ctrl.InPutDoublePassLen[i][1] > peerCtrl->InPutDoublePassLen[i][0]) + { + /*- 向邻机发送数据,本机不接收,传入接收长度为0*/ + len = SFM_2oo2_Exchange_Currency( + g_2x2oo2_rx[g_2x2oo2_base][i].p_rmt_peer_buf, + g_2x2oo2_rx[g_2x2oo2_base][i].rmt_peer_len, + g_2x2oo2_rx[g_2x2oo2_base][i].p_rmt_peer_buf, + 0, + ENUM_2oo2_INPUT_EX); + CM_RE_ASSERT((0 == len), SFM_2x2_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_1); + } + else + { + /*等于不交互,包括0*/ + } + } + else + { + + } + } + + /*- 清空所有通道长度记录*/ + (void)CM_Memset(s_2x2_Ctrl.InPutDoublePassLen,0,sizeof(s_2x2_Ctrl.InPutDoublePassLen),sizeof(s_2x2_Ctrl.InPutDoublePassLen)); + /*记录暗文日志*/ + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_2X2_INPUT_SYNC_SIZE,2u, + sizeof(CM_UINT32),g_2x2oo2_rx[g_2x2oo2_base][2].rmt_mine_len, + sizeof(CM_UINT32),g_2x2oo2_rx[g_2x2oo2_base][2].rmt_peer_len); +} +/** +* @brief 判断2x422以及以太网的通信状况并且填写暗文日志 +*/ +static void SFM_2x2_Eth422StateDark(void) +{ + /*- 变量初始化 */ + union union_state + { + CM_UINT8 state; + struct byte + { + CM_UINT8 bit1:1; + CM_UINT8 bit2:1; + CM_UINT8 bit3:1; + CM_UINT8 bit4:1; + CM_UINT8 bit5:4; + }stru_state; + }u_state; + CM_UINT8 state2oo2 = 0x01; + CM_UINT8 cpuId = PFM_CFG_GetCpuID(); + /*- 如果是cpu1*/ + if(1u == cpuId) + { + u_state.stru_state.bit1 = 0x01 & (s_2x2_Ctrl.MineComState); + u_state.stru_state.bit2 = 0x01 & (s_2x2_Ctrl.PeerComState); + u_state.stru_state.bit3 = 0x01 & (s_2x2_Ctrl.MineUartState); + u_state.stru_state.bit4 = 0x01 & (s_2x2_Ctrl.PeerUartState); + u_state.stru_state.bit5 = 0; + } + else + { + u_state.stru_state.bit1 = 0x01 & (s_2x2_Ctrl.PeerComState); + u_state.stru_state.bit2 = 0x01 & (s_2x2_Ctrl.MineComState); + u_state.stru_state.bit3 = 0x01 & (s_2x2_Ctrl.PeerUartState); + u_state.stru_state.bit4 = 0x01 & (s_2x2_Ctrl.MineUartState); + u_state.stru_state.bit5 = 0; + } + /*- 写入2乘的422eth通信状况至暗文队列 */ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_2X2ETH422, 1U, &u_state.state); + /*- 预留2取eth spi通信状况至暗文队列*/ + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_2OO2ETHSPI, 1U, &state2oo2); +} + +/** +* @brief 设置本系热备状态 +* @param localState 本系的热备状态 取值范围:0~4 +* @details +* 0, 宕机 +* 1, 离机 +* 2, 预升主 +* 3, 主系 +* 4, 备系 +*/ +void SFM_2x2_SetLocal2x2State(ENUM_2x2_STATE_T localState) +{ + /*- 设置本系热备状态 */ + s_2x2_Ctrl.LocalState = localState; +} +/** +* @brief 判断当前周期是否与对系主机通信中断 +* @return 中断返回1,正常返回0 +*/ +CM_UINT8 SFM_2x2_GetWithPeer_Com_State(void) +{ + CM_UINT8 ret = 0; + /**容忍一个周期判断通信中断*/ + if ((CM_FALSE == s_2x2_Ctrl.MineComState) && + (CM_FALSE == s_2x2_Ctrl.PeerComState) && + (CM_FALSE == s_2x2_Ctrl.MineUartState) && + (CM_FALSE == s_2x2_Ctrl.PeerUartState)) + { + ret = 1; + } + else + { + ret = 0; + } + return ret; +} + +/** +* @brief 判断当前周期本系cpu是否与对系交换机通信中断 +* @return 中断返回1,正常返回0 +*/ +CM_UINT8 SFM_2x2_GetWithESB_Mine_Com_State(void) +{ + CM_UINT8 ret = 0; + /**容忍一个周期判断通信中断,交换机重启,以太网断开*/ + if (CM_FALSE == s_2x2_Ctrl.MineComState) + { + ret = 1; + } + else + { + ret = 0; + } + return ret; +} + +/** +* @brief 判断当前周期邻系cpu是否与对系交换机通信中断 +* @return 中断返回1,正常返回0 +*/ +CM_UINT8 SFM_2x2_GetWithESB_Peer_Com_State(void) +{ + CM_UINT8 ret = 0; + /**容忍一个周期判断通信中断,交换机重启,以太网断开*/ + if (CM_FALSE == s_2x2_Ctrl.PeerComState) + { + ret = 1; + } + else + { + ret = 0; + } + return ret; +} +/** +* @brief 判断当前是否满足至少一个以太网和任一通道的条件 +* @return 中断返回1,正常返回0 +*/ +CM_UINT8 SFM_2x2_Get_LeastDoubleCom_State(void) +{ + CM_UINT8 ret = 0u; + /*是否满足至少一个以太网和任一通道*/ + if(((CM_TRUE == s_2x2_Ctrl.MineComState) && + (CM_TRUE == s_2x2_Ctrl.PeerComState)) || + ((CM_TRUE == s_2x2_Ctrl.MineComState) && + (CM_TRUE == s_2x2_Ctrl.MineUartState)) || + ((CM_TRUE == s_2x2_Ctrl.MineComState) && + (CM_TRUE == s_2x2_Ctrl.PeerUartState)) || + ((CM_TRUE == s_2x2_Ctrl.PeerComState) && + (CM_TRUE == s_2x2_Ctrl.MineUartState)) || + ((CM_TRUE == s_2x2_Ctrl.PeerComState) && + (CM_TRUE == s_2x2_Ctrl.PeerUartState))) + { + ret = 0u; + } + else + { + ret = 1u; + } + return ret; +} +/** +* @brief 主线程同步到应用的两系输入io状态 +* @param ioInput 接收缓冲区 取值范围:非空 +* @return ENUM_CM_TRUE 成功,ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN SFM_2x2_SyncIoInput(OUT CM_UINT8* ioInput,CM_UINT16 size) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT8 cpu_id = 0u; + /*- 入参如果为空 */ + if((NULL == ioInput) || (size < 40u)) + { + /*- 无处理 */ + } + else + { + /*- 获取两系2取后的输入io状态 */ + cpu_id = ((g_PFM_Cfg.BOARD_ID - 1u) * 2u) + g_PFM_Cfg.CPU_ID; + switch(cpu_id) + { + case 1: + (void)CM_Memcpy(&ioInput[0],10,s_2x2_Ctrl.MineInputIoState,10); + (void)CM_Memcpy(&ioInput[10],10,s_2x2_Ctrl.PeerInputIoState,10); + (void)CM_Memcpy(&ioInput[20],10,s_2x2_Ctrl.RmtMineInputIoState,10); + (void)CM_Memcpy(&ioInput[30],10,s_2x2_Ctrl.RmtPeerInputIoState,10); + ret = ENUM_CM_TRUE; + break; + case 2: + (void)CM_Memcpy(&ioInput[0],10,s_2x2_Ctrl.PeerInputIoState,10); + (void)CM_Memcpy(&ioInput[10],10,s_2x2_Ctrl.MineInputIoState,10); + (void)CM_Memcpy(&ioInput[20],10,s_2x2_Ctrl.RmtPeerInputIoState,10); + (void)CM_Memcpy(&ioInput[30],10,s_2x2_Ctrl.RmtMineInputIoState,10); + ret = ENUM_CM_TRUE; + break; + case 3: + (void)CM_Memcpy(&ioInput[0],10,s_2x2_Ctrl.RmtMineInputIoState,10); + (void)CM_Memcpy(&ioInput[10],10,s_2x2_Ctrl.RmtPeerInputIoState,10); + (void)CM_Memcpy(&ioInput[20],10,s_2x2_Ctrl.MineInputIoState,10); + (void)CM_Memcpy(&ioInput[30],10,s_2x2_Ctrl.PeerInputIoState,10); + ret = ENUM_CM_TRUE; + break; + case 4: + (void)CM_Memcpy(&ioInput[0],10,s_2x2_Ctrl.RmtPeerInputIoState,10); + (void)CM_Memcpy(&ioInput[10],10,s_2x2_Ctrl.RmtMineInputIoState,10); + (void)CM_Memcpy(&ioInput[20],10,s_2x2_Ctrl.PeerInputIoState,10); + (void)CM_Memcpy(&ioInput[30],10,s_2x2_Ctrl.MineInputIoState,10); + ret = ENUM_CM_TRUE; + break; + default: + ret = ENUM_CM_FALSE; + break; + } + } + /*- 返回获取结果 */ + return ret; +} +/** +* @brief 获取两系输入io状态 +* @param ioInput 接收缓冲区 取值范围:非空 +* @return ENUM_CM_TRUE 成功,ENUM_CM_FALSE 失败 +*/ +ENUM_CM_RETURN SFM_2x2_GetLastIoInput(OUT CM_UINT8* ioInput,CM_UINT16 size) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + /*- 入参如果为空 */ + if((NULL == ioInput) || (size < 40u)) + { + /*- 无处理 */ + } + else + { + ret = CM_Memcpy(&ioInput[0],size,s_2x2_InputIoState,40); + } + /*- 返回获取结果 */ + return ret; +} +/** +* @brief 时间同步失败清空消息队列 +* @param 无 +* @return 无 +*/ +void SFM_2x2_ClearRcvMsgQ(void) +{ + if(CM_FALSE == s_2x2_Ctrl.TimeSyncFlag) + { + /*误差过大,清空2x缓冲区*/ + CFM_Net2XFlush(); + } + else + { + /*无处理*/ + } +} + +void SFM_2x2_SemPost(void) +{ + if (0x55u == g_PFM_Cfg.M_2x2_Enable) + { + CM_Sem_Post(s_2x2_thread_Ctrl.m_Stop); + } + else + { + /* 无处理 */ + } +} + diff --git a/TSCP/src/MSCP/SFM/SFM_2x2.h b/TSCP/src/MSCP/SFM/SFM_2x2.h new file mode 100644 index 0000000..fb51f6a --- /dev/null +++ b/TSCP/src/MSCP/SFM/SFM_2x2.h @@ -0,0 +1,466 @@ +/** +* @file SFM_2x2.h +* @brief Safe Function Module:2x2功能 +* @details +* 2x2上电初始化:初始化、上电同步、比较 +* 输入阶段和输出阶段的双机热备处理 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef SFM_2x2_H +#define SFM_2x2_H +#include "CM_Mutex.h" +#include "MSCP_APP_Interface.h" +#include "CM_Sem.h" +#include "CM_MultiThread.h" +#include "CM_MQ.h" +#include "PFM_Cfg.h" +#ifdef __cplusplus +extern "C" +{ +#endif +extern CM_UINT32 g_MSCP_SysCount; +#define SFM_FOLLOW_BUFF_SIZE (1024u*1024u*2u) /* 主备系间通信通道UDP缓冲区大小 1024k*2,应用许用量为1500k */ + +/*双机热备参数*/ +#define MSCP_2x2_OFFLINE_WAIT (5) /**< 离线保持时间(单位:ms)在离线状态保持大于等该时间长度之后才会进入预升主状态*/ +#define MSCP_2x2_PREMASTER_WAIT (5) /**< 预升主等待时间(单位:ms)在预升主状态保持大于等于该时间长度之后才会进入主状态*/ + +#define MSCP_2X2_COM_FAIL_CYC (1u) /**< 主备通信中断的判断时间(单位:周期),双网均收不到对系数据的周期数大于等于该值时视为通信中断*/ +#define MSCP_2X2_COM_FAIL_DIFF (2u) /**< 判断双网同时中断的允许差异(单位:周期),如果双网通信中断的周期数差异小于等于该值,则认为是同时中断*/ +#define MSCP_2X2_SYNC_TIMEOUT_CYC (5u) /**< 同步超时阈值(单位:周期),备系连续未能完成主备同步的周期数大于等于该值时,备系转离线*/ + +#define MSCP_2X2_COM_THIS_STATE_NUM (2u) /*本周期状态序号*/ + +#define MSCP_2X2_SWITCH_3S (3000000000u) /*切系按钮持续时间*/ +#define MSCP_2X2_THREAD_TIME (40U) /*2x线程运行时间*/ +#define MSCP_2X2_STATE_OVER_TIME (MSCP_2X2_THREAD_TIME + 25U) /*2x线程判断数据超时时间*/ +#define MSCP_2X2_STATE_RCV_WITETIME (MSCP_2X2_THREAD_TIME - 20U) /*2x线程等待对系数据时间*/ + /** 2x2消息类型 */ + typedef enum + { + ENUM_2x2_MSG_ERROR = 0, /**< 保留 */ + ENUM_2x2_MSG_CH1 = 1, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH2 = 2, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH3 = 3, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH4 = 4, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH5 = 5, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH6 = 6, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH7 = 7, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH8 = 8, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH9 = 9, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH10 = 10, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH11 = 11, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH12 = 12, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH13 = 13, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH14 = 14, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH15 = 15, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH16 = 16, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH17 = 17, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH18 = 18, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH19 = 19, /**< 通信数据同步 */ + ENUM_2x2_MSG_CH20 = 20, /**< 通信数据同步 */ + ENUM_2x2_MSG_SYNC = 21, /**< 同步报文 */ + ENUM_2x2_MSG_STAT = 22, /**< 热备状态报文 */ + ENUM_2x2_MSG_BASE_FOLLOW = 23,/**< 平台跟随报文 */ + ENUM_2x2_MSG_APP_FOLLOW = 24, /**< 应用跟随报文 */ + ENUM_2x2_MSG_OUTCHECK = 25, /**< 输出校验报文 */ + ENUM_2x2_MSG_APP_FOLLOW_CRC = 26 /**< 应用跟随报文 CRC比较 */ + }ENUM_2x2_MSG_T; + + /** 2x2oo2的接收通道 */ + typedef struct + { + CM_UINT32 b_2oo2_Enable; /**< 2oo2功能开关 */ + CM_UINT32 b_2x2_Enable; /**< 2x2功能开关 */ + + CM_UINT32 buf_size; /**< 通道缓冲区大小 */ + CM_UINT32 helpinfo_buf_size;/**< 辅助信息通道缓冲区大小 */ + CM_MUTEX_T app_mutex; /**< app接口互斥器 */ + + CM_UINT32 mine_len; /**< 本机通道报文长度 */ + CM_UINT8* p_mine_buf; /**< 本机通道报文缓冲区 */ + CM_UINT32 mine_helpinfo_len; /**< 本机辅助信息通道报文长度 */ + CM_UINT8* p_mine_helpinfo_buf; /**< 本机辅助信息通道报文缓冲区 */ + + CM_UINT32 peer_len; /**< 邻机通道报文长度 */ + CM_UINT8* p_peer_buf; /**< 邻机通道报文缓冲区 */ + CM_UINT32 peer_helpinfo_len; /**< 邻机辅助信息通道报文长度 */ + CM_UINT8* p_peer_helpinfo_buf;/**< 邻机辅助信息通道报文缓冲区 */ + + CM_UINT32 rmt_mine_len; /**< 本机对系通道报文长度 */ + CM_UINT8* p_rmt_mine_buf; /**< 本机对系通道报文缓冲区 */ + CM_UINT32 rmt_mine_helpinfo_len; /**< 本机对系辅助信息通道报文长度 */ + CM_UINT8* p_rmt_mine_helpinfo_buf;/**< 本机对系辅助信息通道报文缓冲区 */ + + CM_UINT32 rmt_peer_len; /**< 邻机对系通道报文长度 */ + CM_UINT8* p_rmt_peer_buf; /**< 邻机对系通道报文缓冲区*/ + CM_UINT32 rmt_peer_helpinfo_len; /**< 邻机对系辅助信息通道报文长度 */ + CM_UINT8* p_rmt_peer_helpinfo_buf;/**< 邻机对系辅助信息通道报文缓冲区*/ + + CM_UINT32 app_index_log;/*应用调用次数*/ + }STRU_2x2oo2_rx_T; + + /** 2x2oo2的发送通道 */ + typedef struct + { + CM_UINT32 b_2oo2_Enable; /**< 2oo2功能开关 */ + CM_UINT32 b_2x2_Enable; /**< 2x2功能开关 */ + CM_MUTEX_T mutex; /* app接口互斥锁 */ + CM_UINT32 buf_size; /* 通道缓冲区大小 */ + CM_INT32 buf_len; /* 报文长度 */ + CM_UINT8 *p_buf; /* 报文缓冲区 */ + }STRU_2x2oo2_tx_T; + + /** 2x2消息类型 */ + typedef enum + { + ENUM_2x2_SWITCH_CLOSE = 0, /**< 切系状态为不需要主动切系 */ + ENUM_2x2_SWITCH_OPEN = 1 /**< 切系状态为需要主动切系 */ + }ENUM_2x2_SWITCH_STATE; + /** 2x2AID切系消息类型 */ + typedef enum + { + ENUM_2x2_AIDSWITCH_OVER = 0, /**< AID切系完成状态*/ + ENUM_2x2_AIDSWITCH_ENABLE = 1, /**< AID切系允许状态 */ + ENUM_2x2_AIDSWITCH_DISABLE = 2 /**< AID切系禁止状态 */ + }ENUM_2x2_AID_SWITCH_STATE; + /*记录通信状态*/ + typedef struct + { + CM_UINT8 MicroCyc; /**< 微周期号 */ + CM_UINT32 SysCyc; /**< 系统周期号 */ + }STRU_2X2_COM_STATE_RECORD_T; + /** 2x2控制 */ + typedef struct + { + /* + 2oo2双机的与对系通信通道互为冗余, + 所以对于通信数据,需要通过2oo2交换使双CPU取得全部一致的接收数据 + 但对于热备运算,所有运算结果需要通过2oo2比较以确保双机工作状态一致 + */ + CM_UINT32 LocalID; /**< 本系ID */ + CM_UINT32 PartnerID; /**< 对系ID */ + CM_UINT32 TxSN; /**< 发送序列号 */ + CM_UINT32 RxSN; /**< 接收序列号 */ + CM_UINT32 SysCycSync;/**< 系统周期号 */ + + ENUM_2x2_STATE_T LocalState; /**< 本系热备状态,2oo2比较 */ + ENUM_2x2_STATE_T PartnerState; /**< 收到的对系热备状态,2oo2交换 */ + ENUM_2x2_STATE_T LastLocalState; /**< 本系上一周期的热备状态,2oo2比较 */ + ENUM_2x2_STATE_T LastPartnerState; /**< 收到的对系上一周期热备状态,2oo2交换 */ + /*通信状态 */ + CM_BOOL MineComState; /**< 本机通信状态,2oo2交换 */ + CM_BOOL PeerComState; /**< 邻机通信状态,2oo2交换 */ + CM_BOOL MineUartState; /**< 本机串口通信状态,2oo2交换 */ + CM_BOOL PeerUartState; /**< 邻机串口通信状态,2oo2交换 */ + + /*输入数据*/ + CM_UINT32 RxInputSysCyc; /**< 收到的对系输入数据的周期号,2oo2交换 */ + CM_UINT32 InputMineSysCyc; /**< 当周期从对系收到的本cpu输入数据标志 */ + CM_UINT32 InputPeerSysCyc; /**< 当周期从对系收到的邻cpu输入数据标志 */ + CM_UINT32 InPutDoublePassLen[MSCP_DOUBLE_PASS_ALL_NUM][2]; /**< 当周期从对系收到同步数据长度 */ + + /*主备IO同步放在平台跟随阶段去做*/ + CM_UINT8 MineInputIoState[10]; /*IO数据同步*/ + CM_UINT8 PeerInputIoState[10]; /*IO数据同步*/ + CM_UINT8 RmtMineInputIoState[10]; /*IO数据同步*/ + CM_UINT8 RmtPeerInputIoState[10]; /*IO数据同步*/ + + /*跟随数据*/ + CM_UINT32 RxBaseFollowSysCyc; /**< 收到的对系跟随数据的周期号,2oo2交换 */ + CM_UINT32 RxAppFollowSysCyc; /**< 收到的对系应用跟随数据的周期号,2oo2交换 */ + CM_UINT32 LastFollowCyc; /**< 上次进行平台跟随的时间,2oo2比较,*/ + + /*输出比较信息*/ + CM_UINT32 LastCheckOKCount; /**< 上次输出比较成功(跟随成功)的本地时间,2oo2比较 (这个标志用来判断如果未收到主系的数据,则停止更新,后将为离线)*/ + CM_UINT32 OutPutCheckFailFlag; /**< 上次输出比较成功(跟随成功)的本地时间,2oo2比较 (这个标志用来判断收到输出数据后是否比较成功, 比较失败则降级)*/ + CM_UINT32 AppFollowCmpFlag; /**< 上次应用跟随数据比较结果,只有备系使用 (这个标志用来判断备系和主系应用跟随数据是否比较成功, 比较失败则降级)*/ + CM_UINT32 RxCheckSysCyc; /**< 收到的输出校验帧的周期号,2oo2交换 */ + CM_INT32 RxCheckLen; /**< 收到的输出校验帧长度,2oo2交换 */ + CM_UINT8 RxCheckFrame[100]; /**< 收到的输出校验帧报文,2oo2交换 */ + ENUM_2x2_AID_SWITCH_STATE AIDSwitchState;/**< aid切系控制标志 */ + CM_UINT8 TimeSyncFlag; /**< 时间同步完成标志 */ + }STRU_2X2_CTRL_T; + + /*2x状态切换线程参数*/ + typedef struct + { + CM_UINT32 LocalID; /**< 本系ID */ + CM_UINT32 PartnerID; /**< 对系ID */ + CM_UINT32 SysCyc; /**< 系统周期号 */ + CM_UINT8 MicroCyc; /**< 微周期号 */ + CM_UINT32 TxSN; /**< 发送序列号 */ + CM_UINT32 RxSN; /**< 接收序列号 */ + + /*双系热备状态*/ + ENUM_2x2_STATE_T LocalState; /**< 本系热备状态,2oo2比较 */ + ENUM_2x2_STATE_T PartnerState; /**< 收到的对系热备状态,2oo2交换 */ + ENUM_2x2_STATE_T LastLocalState; /**< 本系上一周期的热备状态,2oo2比较 */ + ENUM_2x2_STATE_T LastPartnerState; /**< 收到的对系上一周期热备状态,2oo2交换 */ + + CM_UINT32 offLineCounter; /**< 离线计时器,2oo2比较 */ + CM_UINT32 preMasterCounter; /**< 预升主计时器,2oo2比较 */ + /*通信状态 ABS((B-A)*5-ABS(b-a)),大小周期计算,考虑结构体数组*/ + STRU_2X2_COM_STATE_RECORD_T MineComOKCount[3u]; /**< 本机通信状态计数,2oo2交换 */ + STRU_2X2_COM_STATE_RECORD_T PeerComOKCount[3u]; /**< 邻机通信状态计数,2oo2交换 */ + STRU_2X2_COM_STATE_RECORD_T MineUartOKCount[3u]; /**< 本机串口通信状态计数,2oo2交换 */ + STRU_2X2_COM_STATE_RECORD_T PeerUartOKCount[3u]; /**< 邻机串口通信状态计数,2oo2交换 */ + + CM_UINT8 MineInputIoState[10]; /*IO数据同步*/ + CM_UINT8 PeerInputIoState[10]; /*IO数据同步*/ + CM_UINT8 RmtMineInputIoState[10]; /*IO数据同步*/ + CM_UINT8 RmtPeerInputIoState[10]; /*IO数据同步*/ + + /*状态信息*/ + CM_UINT32 LastStateCount; /**< 上次收到对系状态的时间,2oo2交换 */ + CM_UINT32 RxStateSysCyc; /**< 收到的状态帧的周期号,2oo2交换 */ + CM_UINT32 RxStateMicroCyc; /**< 收到的状态帧的周期号,2oo2交换 */ + + /*输入数据*/ + CM_UINT32 LastRxInputSysCyc; /**< 收到的对系输入数据的周期号,2oo2交换 */ + /*跟随数据*/ + CM_UINT32 LastFollowCyc; /**< 上次进行平台跟随的时间,2oo2比较,*/ + CM_UINT32 AppFollowCmpFlag; /**< 上次应用跟随数据比较结果,只有备系使用 (这个标志用来判断备系和主系应用跟随数据是否比较成功, 比较失败则降级)*/ + + /*输出比较信息*/ + CM_UINT32 LastCheckOKCount; /**< 上次输出比较成功(跟随成功)的本地时间,2oo2比较 (这个标志用来判断如果未收到主系的数据,则停止更新,后将为离线)*/ + CM_UINT32 OutPutCheckFailFlag; /**< 上次输出比较成功(跟随成功)的本地时间,2oo2比较 (这个标志用来判断收到输出数据后是否比较成功, 比较失败则降级)*/ + + /*时间同步完成标志*/ + CM_UINT8 TimeSyncFlag; + /*主动切系状态*/ + ENUM_2x2_SWITCH_STATE LocalSwitchState; /**< 自己的主动切系按钮状态 */ + ENUM_2x2_SWITCH_STATE PeerSwitchState; /**< 邻机的主动切系按钮状态 */ + ENUM_2x2_SWITCH_STATE PartnerSwitchState; /**< 对系的主动切系按钮状态 */ + ENUM_2x2_SWITCH_STATE PartPeerSwitchState; /**< 对系的邻机的主动切系按钮状态 */ + CM_UINT8 ctrSwitchFlag; /**< 按钮切系控制标志 */ + ENUM_2x2_AID_SWITCH_STATE LocalAIDSwitchState; /**< 自己的AID切系状态 */ + ENUM_2x2_AID_SWITCH_STATE PeerAIDSwitchState; /**< 邻机的AID切系状态 */ + ENUM_2x2_AID_SWITCH_STATE PartnerAIDSwitchState; /**< 对系的主动切系按钮状态 */ + ENUM_2x2_AID_SWITCH_STATE PartPeerAIDSwitchState; /**< 对系的邻机的主动切系按钮状态 */ + CM_UINT8 aidSwitchFlag; /**< aid切系控制标志 */ + }STRU_2X2_STATE_CTRL_T; + /*2x状态切换线程参数*/ + typedef struct + { + CM_SEM_T m_Start; /* 2x状态切换开始信号量 */ + CM_SEM_T m_Stop; /* 2x状态切换结束信号量 */ + CM_MUTEX_T mutex; /**< 互斥信号量 */ + CM_UINT8 number_Cyc;/*周期次数*/ + CM_MQ_Struct_T LogMsgQ; /**< 日志消息队列 */ + }STRU_2X2_STATE_THRRAD_T; + + + extern CM_INT32 g_2x2oo2_base; + extern CM_INT32 g_2x2oo2_data_num; + extern STRU_2x2oo2_rx_T g_2x2oo2_rx[2][24]; + extern STRU_2x2oo2_tx_T g_2x2oo2_tx[2][24]; + extern CM_UINT8 g_2x2RcvMaxNum[2]; /**< 2x2双缓冲区接收最大序号*/ + + extern CM_INT32 g_TxAppFollow_len; + extern CM_UINT8 g_TxAppFollow[MSCP_FOLLOW_BUFF_SIZE*2]; + + /*日志转换*/ + void SFM_2x2_LOG_Transition(void); + /* 2x2上电初始化 */ + void SFM_2x2_Init(IN const CM_UINT8* VitalBuf, IN CM_UINT16 VitalLen, INOUT CM_UINT64* pCycTick); + /* 输入阶段2x2处理 */ + void SFM_2x2_InputProc(void); + /* 输出阶段2x2处理 */ + void SFM_2x2_OutputProc(IN const CM_UINT8 *CheckBuf, CM_INT32 CheckLen); + /* 周期末2x2处理 */ + void SFM_2x2_EndProc(void); + /* 2x2数据发送 */ + void SFM_2x2_Send(IN const CM_UINT8 *Data, IN CM_UINT32 DataLen, IN ENUM_2x2_MSG_T msgType); + /** + * 2x2串口发送 + */ + void SFM_2x2_UartSend(IN const CM_UINT8 *Data, IN CM_UINT32 DataLen, IN ENUM_2x2_MSG_T msgType); + + /* 2x2周期同步 */ + void SFM_2x2_Sync(IN CM_UINT64 cycTick, OUT CM_INT64* pOffset); + /** + * @brief 获取本系热备状态 + * @return 本系热备状态 + * - ENUM_2x2_OFFLINE 离线 + * - ENUM_2x2_PRE_MASTER 预升主 + * - ENUM_2x2_MASTER 主系 + * - ENUM_2x2_SLAVE 备系 + * @note + * 宕机状态下应用逻辑不会被执行, + * 所以应用本函数不可能返回“宕机”。 + * 其它状态下周期应用逻辑都会被执行, + * 但只有“主系”状态下本机的输出才会被真实输出, + * 在“离线”和“备系”状态下且本周期收到有效跟随数据时, + * 将在周期应用逻辑执行之前进行跟随数据覆盖。 + */ + ENUM_2x2_STATE_T SFM_2x2_GetLocal2x2State(void); + /** + * @brief 获取对系热备状态 + * @return 对系热备状态 + * - ENUM_2x2_SHUTDOWN 宕机 + * - ENUM_2x2_OFFLINE 离线 + * - ENUM_2x2_PRE_MASTER 预升主 + * - ENUM_2x2_MASTER 主系 + * - ENUM_2x2_SLAVE 备系 + * @note + * 与对系通信中断时默认对系状态为“宕机” + */ + ENUM_2x2_STATE_T SFM_2x2_GetPartner2x2State(void); + + /* + * @brief 获取上一周期的本系热备状态 + * @return 本系热备状态 + * - ENUM_2x2_OFFLINE 离线 + * - ENUM_2x2_PRE_MASTER 预升主 + * - ENUM_2x2_MASTER 主系 + * - ENUM_2x2_SLAVE 备系 + * @note + * 宕机状态下应用逻辑不会被执行, + * 所以应用本函数不可能返回“宕机”。 + * 其它状态下周期应用逻辑都会被执行, + * 但只有“主系”状态下本机的输出才会被真实输出, + * 在“离线”和“备系”状态下且本周期收到有效跟随数据时, + * 将在周期应用逻辑执行之前进行跟随数据覆盖。 + */ + ENUM_2x2_STATE_T SFM_2x2_GetLastLocal2x2State(void); + /** + * @brief 获取对系上一周期的热备状态 + * @return 对系热备状态 + * - ENUM_2x2_SHUTDOWN 宕机 + * - ENUM_2x2_OFFLINE 离线 + * - ENUM_2x2_PRE_MASTER 预升主 + * - ENUM_2x2_MASTER 主系 + * - ENUM_2x2_SLAVE 备系 + * @note + * 与对系通信中断时默认对系状态为“宕机” + */ + ENUM_2x2_STATE_T SFM_2x2_GetLastPartner2x2State(void); + + /** + * @brief 设置跟随数据 + * @param[in] Data[] 跟随数据数组 + * @param[in] Len 跟随数据长度 + * @return 函数执行结果 + * - 1 成功 + * - 0 失败(输入非法) + * @note + * 无论本系是否为主,应用都应当每周期设置一次跟随数据; + * 本系非主时平台不会发送该数据,但会用于双系一致性的校验。 + * 跟随数据量最大为1024*1000字节。 + * @see :: APP_API_FollowUp + */ + CM_UINT8 SFM_2x2_SetFollowData(IN const CM_UINT8 Data[], IN CM_UINT32 Len); + /** + * @brief 获取系统周期号 + * @return 当前的系统周期号 + * @note + * 一个固定周期自增的周期号; + * 对于2x2系统,2x2双系的周期号会被自动同步到与主系一致。 + */ + CM_UINT32 SFM_2x2_GetSysCount(void); + /** + * @brief 获取通信断开次数通用函数 + * @param ComOKCountBuf 更新状态通信ok次数数组 + * @param BeforeCycNum 查询前几个周期序号,例如:0代表本周期, + * @return 通信断开的次数 + * @details + * 可向前查询通信正常次数周期号 + */ + CM_UINT32 MSCP_Get_2X_DisCom_Count(STRU_2X2_COM_STATE_RECORD_T *ComOKCount,CM_UINT8 BeforeCycNum); + /** + * @brief 获取通信状态 + * @param ComOKCountBuf 更新状态通信ok次数数组 + * @param BeforeCycNum 查询前几个周期序号,例如:0代表本周期, + * @return ENUM_CM_TRUE = 0x55 成功 + ENUM_CM_FALSE = 0xAA 失败 + * @details + *可向前查询通信状态 + */ + ENUM_CM_RETURN MSCP_Get_2X_Com_State(STRU_2X2_COM_STATE_RECORD_T *ComOKCount,CM_UINT8 BeforeCycNum); + /** + * @brief 获取模糊通信状态 + * @param ComOKCountBuf 更新状态通信ok次数数组 + * @return CM_TRUE 成功 + CM_FALSE 失败 + */ + CM_BOOL MSCP_Get_2X_VagueCom_State(STRU_2X2_COM_STATE_RECORD_T *ComOKCount); + /** + * @brief 更新本周期通信状态通用函数 + * @param ComOKCountBuf 更新状态通信ok次数数组 + * @param ComOKCount 通信OK次数 + * @return 无 + * @details + * 更新本周期通信状态,将历史状态信息移位保存 + */ + void MSCP_UpData_2X_This_ComState(STRU_2X2_COM_STATE_RECORD_T *ComOKCount,CM_UINT32 SysCyc,CM_UINT8 MicroCyc); + + /** + * @brief 获取本系切系按钮状态 + * @return 本系切系按钮状态 + * - ENUM_2x2_SWITCH_CLOSE = 0 未连续按下 + * - ENUM_2x2_SWITCH_OPEN = 1 连续按下 + */ + ENUM_2x2_SWITCH_STATE SFM_2x2_GetLocalSwitchState(void); + + /** + * @brief 设置本系切系按钮状态 + * @param switchState 设置的值 + * @return 无 + */ + void SFM_2x2_SettLocalSwitchState(ENUM_2x2_SWITCH_STATE switchState); + + /** + * @brief 获得是否为在因为切系后,主系降为离线的3周期内的标志。 + * @return 是否为切系后的3周期 + * - 0 不在切系后的3周期内 + * - 1 在切系后的3周期内 + */ + CM_UINT8 SFM_2x2_GetSwitchFlag(void); + + /* 设置本系热备状态 */ + void SFM_2x2_SetLocal2x2State(ENUM_2x2_STATE_T localState); + + /** + * @brief 获取2x切系标志位 + * @return s_2x2_Ctrl.ctrSwitchFlag 切系标志位 取值范围:1正在切系 0不在切系 + */ + CM_UINT8 SFM_2x2_GetCtrSwitchFlag(void); + + /*判断当前周期是否与对系通信中断,中断返回1,正常返回0*/ + CM_UINT8 SFM_2x2_GetWithPeer_Com_State(void); + /*判断当前周期是否与对系通信中断,间接判断交换机状态*/ + CM_UINT8 SFM_2x2_GetWithESB_Mine_Com_State(void); + /*判断当前周期是否与对系通信中断,间接判断交换机状态*/ + CM_UINT8 SFM_2x2_GetWithESB_Peer_Com_State(void); + /*判断当前是否满足至少一个以太网和任一通道的条件*/ + CM_UINT8 SFM_2x2_Get_LeastDoubleCom_State(void); + /*主线程同步到应用的两系输入io状态*/ + ENUM_CM_RETURN SFM_2x2_SyncIoInput(OUT CM_UINT8* ioInput,CM_UINT16 size); + /*获取两系输入io状态*/ + ENUM_CM_RETURN SFM_2x2_GetLastIoInput(OUT CM_UINT8* ioInput,CM_UINT16 size); + /*发送2x起始信号*/ + void SFM_2x2_Thread_PostStart(void); + /*使能AID切系开关*/ + void SFM_2x2_Enable_AIDSwitchStart(void); + /*获取AID切系状态*/ + ENUM_2x2_AID_SWITCH_STATE SFM_2x2_Get_AIDSwitchStart(void); + /*输出处理与发送阶段之前的等待2x逻辑结束的最后处理函数*/ + void SFM_2x2_ChangeState(void); + /*时间同步失败清空消息队列*/ + void SFM_2x2_ClearRcvMsgQ(void); + + void SFM_2x2_SemPost(void); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/SFM/SFM_Prtcl.c b/TSCP/src/MSCP/SFM/SFM_Prtcl.c new file mode 100644 index 0000000..153e256 --- /dev/null +++ b/TSCP/src/MSCP/SFM/SFM_Prtcl.c @@ -0,0 +1,2387 @@ +/** +* @file SFM_Prtcl.c +* @brief Safe Function Module: 安全协议处理 +* @details +* 从通信层获取输入数据交给平台层交换、比较 +* 从平台层获取输入数据交给协议层解析 +* 从协议层获取输入数据交给应用层使用 +* 从应用层获取输出数据交给协议层封装 +* 从协议层获取输出数据交给平台层比较 +* 从平台层获取输出数交给通信层发送 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ + +#include "SFM_Prtcl.h" +#include "CM_Convert.h" +#include "CM_Memory.h" +#include "CM_Queue.h" +#include "CM_CRC32.h" +#include "CM_Mutex.h" +#include "PFM_Cfg.h" +#include "PFM_FS.h" +#include "PFM_ControlFlowCheck.h" +#include "SFM_2oo2.h" +#include "SFM_2x2.h" +#include "PFM_Log.h" +#include "DFM_Time.h" +#include "MSCP_APP_API.h" +#if QNX +#else +#include "cp_interface.h" +#endif +#include "PFM_RemoteUpdate.h" +#include "CFM_Net.h" +#include "protclInterFun.h" +#include "sfpplatform.h" +#include "dsuProtclFun.h" +static CM_UINT8 s_Prtcl_UDP_Cache[NET_UDP_BUF_SIZE]; /**< UDP缓冲区 */ +static CM_UINT8 s_TmpCache[SFM_TMP_CACHE_SIZE]; /**< 外网通信临时缓冲区 */ + +static ProtclConfigInfoStru s_OutnetPrtcl; /**< 外网通信控制结构体 */ +static struc_Unify_Info s_InnetPrtcl; /**< 内网通信控制结构体 */ +static struc_Unify_Info s_InnetPrtcl_RM; /**< 远程部署内网通信控制结构体 */ + +static CM_MUTEX_T s_Outnet_AppSend_M; +static STRU_CM_QUEUE_T s_Outnet_AppSendQ; + +static CM_MUTEX_T s_Innet_AppSend_M; +static STRU_CM_QUEUE_T s_Innet_AppSendQ; + +static CM_MUTEX_T s_Innet_AppRmSend_M; +static STRU_CM_QUEUE_T s_Innet_AppRmSendQ; + +static CM_MUTEX_T s_Innet_RmSend_M; +static STRU_CM_QUEUE_T s_Innet_RmSendQ; + +static CM_MUTEX_T s_Outnet_AppRecv_M; +static STRU_CM_QUEUE_T s_Outnet_AppRecvQ; + +static CM_MUTEX_T s_Innet_AppRecv_M; +static STRU_CM_QUEUE_T s_Innet_AppRecvQ; + +static CM_MUTEX_T s_Innet_RmRecv_M; +static STRU_CM_QUEUE_T s_Innet_RmRecvQ; + +extern CM_UINT32 g_MSCP_SysCount; /**< 系统周期号 */ +extern CM_INT32 g_PFM_Check; + +static CM_UINT32 s_txSn = 1u; +/** +* @breif 外网安全协议初始化(-1) +* @details +* 外网安全协议的初始化 +* 初始化失败将宕机 +*/ +void SFM_PrtclOutInit(void) +{ + /*- 变量初始化 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + CM_UINT16 OutnetID = g_PFM_Cfg.OUTNET_ID; /* 外网ID */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + + /*- @alias 外网安全协议初始化*/ + if (0x55u == g_PFM_Cfg.M_OutnetSafe_Enable) + { + s_OutnetPrtcl.cpuId = g_PFM_Cfg.CPU_ID - 1u;/* cpuId和应用输出数据与svc有关 */ + s_OutnetPrtcl.LocalID = (CM_UINT8)(OutnetID % 256u); + s_OutnetPrtcl.LocalType = (CM_UINT8)(OutnetID / 256u); + s_OutnetPrtcl.CycleNum = &g_MSCP_SysCount; + s_OutnetPrtcl.InputSize = 6000u; + s_OutnetPrtcl.OutputSize = 6000u; + s_OutnetPrtcl.RecordArraySize = 30000u; + s_OutnetPrtcl.MaxNumPerCycle = 35u; /* 以zc举例:包数*4*2*2*2 */ +#if QNX + rt = ProtclInitFunc((CM_UINT8*)FS_FILE_PATH, (CM_UINT32)inParamLen, inParam, &s_OutnetPrtcl); +#else + CM_CHAR WIN32_profile[1024] = {0}; + strcat(&WIN32_profile, p_exe_path); + strcat(&WIN32_profile, FS_FILE_PATH); + rt = ProtclInitFunc((CM_UINT8*)&WIN32_profile, (CM_UINT32)inParamLen, inParam, &s_OutnetPrtcl); +#endif + /*- 检查外网安全协议初始化结果 */ + CM_ASSERT(1u == rt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_4); + + /*- 初始化应用外网接收、发送缓冲区 */ + (void)CM_Mutex_Init(&s_Outnet_AppSend_M); + (void)CM_Mutex_Init(&s_Outnet_AppRecv_M); + ret = CM_QueueInitial(&s_Outnet_AppSendQ, SFM_OUTNETSAFE_BUFF_SIZE); + CM_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_5); + ret = CM_QueueInitial(&s_Outnet_AppRecvQ, SFM_OUTNETSAFE_BUFF_SIZE); + CM_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_6); + + /*fs_init(FS_FILE_PATH);*/ + } + else + { + /*- 无处理*/ + } +} +/** +* @breif 内网安全协议初始化(sfp) +* @param p_SfpInnetPara内网协议buf +* @details +* 内网安全协议的初始化 +* 初始化失败将宕机 +*/ +void SFM_PrtclInInit(CM_UINT8* p_SfpInnetPara) +{ + /*- 变量初始化 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + CM_UINT16 InnetID = g_PFM_Cfg.INNET_ID_RM; /* 远程部署内网ID */ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT16 InnetID1 = g_PFM_Cfg.INNET_ID; /* 内网ID */ + /*- 入参是否为空 */ + if ((0x55u == g_PFM_Cfg.M_InnetSafe_Enable) && (NULL != p_SfpInnetPara)) + { + /*- 内网安全协议初始化*/ + CM_NM_ASSERT(0u != InnetID1, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_9); + s_InnetPrtcl.LocalID = (CM_UINT8)(InnetID1 % 256u); + s_InnetPrtcl.LocalType = (CM_UINT8)(InnetID1 / 256u); + s_InnetPrtcl.TimeCounter = &g_MSCP_SysCount; + s_InnetPrtcl.RedundTimeout = 0xFFFFu; + s_InnetPrtcl.OutputTimeout = 0xFFFFu; + s_InnetPrtcl.DataBase = p_SfpInnetPara; + s_InnetPrtcl.MaxNumLink = 10u; + s_InnetPrtcl.MaxNumPerCycle = 5u; + s_InnetPrtcl.InputSize = 5000u; + s_InnetPrtcl.OutputSize = 5000u; + s_InnetPrtcl.OutnetQueueSize = 65000u; + s_InnetPrtcl.RecordArraySize = 65000u; + s_InnetPrtcl.CycleNum = &g_MSCP_SysCount; + rt = ProtclInit(0u, (CM_UINT32)0u, NULL, &s_InnetPrtcl); + /*- 检查外网安全协议初始化结果 */ + CM_NM_ASSERT(1u == rt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_6); + + /*- 初始化应用内网接收、发送缓冲区*/ + (void)CM_Mutex_Init(&s_Innet_AppSend_M); + (void)CM_Mutex_Init(&s_Innet_AppRecv_M); + ret = CM_QueueInitial(&s_Innet_AppSendQ, SFM_INNETSAFE_BUFF_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_7); + ret = CM_QueueInitial(&s_Innet_AppRecvQ, SFM_INNETSAFE_BUFF_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_8); + } + else + { + /*- 无处理*/ + } + + /*- 入参是否为空 */ + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id) && (NULL != p_SfpInnetPara)) + { + /*- 远程部署内网安全协议初始化*/ + CM_NM_ASSERT(0u != InnetID, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_1); + s_InnetPrtcl_RM.LocalID = (CM_UINT8)(InnetID % 256u); + s_InnetPrtcl_RM.LocalType = (CM_UINT8)(InnetID / 256u); + s_InnetPrtcl_RM.TimeCounter = &g_MSCP_SysCount; + s_InnetPrtcl_RM.RedundTimeout = 0xFFFFu; + s_InnetPrtcl_RM.OutputTimeout = 0xFFFFu; + s_InnetPrtcl_RM.DataBase = p_SfpInnetPara; + s_InnetPrtcl_RM.MaxNumLink = 10u; + s_InnetPrtcl_RM.MaxNumPerCycle = 5u; + s_InnetPrtcl_RM.InputSize = 5000u; + s_InnetPrtcl_RM.OutputSize = 5000u; + s_InnetPrtcl_RM.OutnetQueueSize = 65000u; + s_InnetPrtcl_RM.RecordArraySize = 65000u; + s_InnetPrtcl_RM.CycleNum = &g_MSCP_SysCount; + rt = ProtclInit(0u, (CM_UINT32)0u, NULL, &s_InnetPrtcl_RM); + /*- 检查外网安全协议初始化结果 */ + CM_NM_ASSERT(1u == rt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_2); + + /*- 初始化应用内网接收、发送缓冲区*/ + (void)CM_Mutex_Init(&s_Innet_RmSend_M); + (void)CM_Mutex_Init(&s_Innet_AppRmSend_M); + (void)CM_Mutex_Init(&s_Innet_RmRecv_M); + ret = CM_QueueInitial(&s_Innet_RmSendQ, SFM_INNETSAFE_RM_BUFF_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == ret,PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_3); + ret = CM_QueueInitial(&s_Innet_AppRmSendQ, SFM_INNETSAFE_RM_BUFF_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == ret,PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_4); + ret = CM_QueueInitial(&s_Innet_RmRecvQ, SFM_INNETSAFE_RM_BUFF_SIZE); + CM_NM_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE,DARK_FAULT_CODE_FUN_ORDER_17, TSCP_DARK_ASSERT_5); + } + else + { + /*- 无处理*/ + } +} + +/** +* @brief 内网安全数据接收 +* @param Buf 接收内网安全数据指针 +* @param BufSize 接收内网安全数据缓冲区大小 +* @return 收到的内网安全数据总长度 +* @details +* 从通信层获取本周期内网安全输入数据 +* 按内网安全接收帧打包后交给平台层 +*/ +CM_INT32 SFM_RxInnetSafe(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = 0; /* 接收报文长度 */ + CM_INT32 i = 0; /* 循环变量 */ + CM_UINT32 srcIP = 0u; /* 源IP */ + CM_UINT16 srcPort = 0u; /* 源ID */ + STRU_PFM_INNET_CFG_T* pCom = NULL; /* 内网通信配置 */ + CM_ASSERT(NULL != Buf, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + /*- 循环接收内网通信数据 */ + do + { + /*- 从通信层接收内网通信数据 */ + rxLen = CFM_InnetSafe_Recv(&Buf[i + 2u], CM_UNSIGNED_INT_EXP(BufSize - (CM_UINT32)i - 2u), &srcIP, &srcPort); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /*- 收到的数据长度是否大于0 */ + if (0 < rxLen) + { + /*- 根据源IP、Port确定源ID */ + pCom = PFM_INI_InnetIP2Addr(srcIP, srcPort); + CM_ASSERT(NULL != pCom, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + + /*- 打包成内网输入帧 */ + CM_ShortToChar((CM_UINT16)(rxLen), &Buf[i]); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + + i += rxLen + 2; + } + else + { + /*- 无处理*/ + } + } while (0 < rxLen); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_CFMNET_INNETSAFE_RECVLEN, 4U, &i); + /*- 返回内网输入帧总长度 */ + return i; +} + +/** +* @brief 远程部署内网安全数据接收 +* @param Buf 接收内网安全数据指针 +* @param BufSize 接收内网安全数据缓冲区大小 +* @return 收到的内网安全数据总长度 +* @details +* 从通信层获取本周期内网安全输入数据 +* 按内网安全接收帧打包后交给平台层 +*/ +CM_INT32 SFM_RxInnetSafeRm(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = 0; /* 接收报文长度 */ + CM_INT32 i = 0; /* 循环变量 */ + CM_UINT32 srcIP = 0u; /* 源IP */ + CM_UINT16 srcPort = 0u; /* 源ID */ + STRU_PFM_INNET_CFG_T* pCom = NULL; /* 内网通信配置 */ + CM_NM_ASSERT(NULL != Buf, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_18, TSCP_DARK_ASSERT_1); + /*- 循环接收内网通信数据 */ + do + { + /*- 从通信层接收内网通信数据 */ + rxLen = CFM_InnetSafeRm_Recv(&Buf[i + 2u], CM_UNSIGNED_INT_EXP(BufSize - (CM_UINT32)i - 2u), &srcIP, &srcPort); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /*- 收到的数据长度是否大于0 */ + if (0 < rxLen) + { + /*- 根据源IP、Port确定源ID */ + pCom = PFM_INI_InnetIP2Addr(srcIP, srcPort); + CM_NM_ASSERT(NULL != pCom, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_18, TSCP_DARK_ASSERT_2); + + /*- 打包成内网输入帧 */ + CM_ShortToChar((CM_UINT16)(rxLen), &Buf[i]); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + + i = i + rxLen + 2; + } + else + { + /*- 无处理*/ + } + } while (0 < rxLen); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_CFMNET_INNETSAFERM_RECVLEN, 4U, &i); + /*- 返回内网输入帧总长度 */ + return i; +} + +/** +* @brief 内网远程部署安全数据接收 +* @param Buf 接收内网安全数据指针 +* @param BufSize 接收内网安全数据缓冲区大小 +* @return 收到的内网安全数据总长度 +* @details +* 从通信层获取本周期内网安全输入数据 +* 按内网安全接收帧打包后交给平台层 +*/ +CM_INT32 SFM_RxInnetRemoteUpdate(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize) +{ + /*- 变量初始化 */ + CM_INT32 rxLen = 0; /* 接收报文长度 */ + CM_INT32 i = 0; /* 循环变量 */ + CM_UINT32 srcIP = 0u; /* 源IP */ + CM_UINT16 srcPort = 0u; /* 源ID */ + STRU_PFM_INNET_CFG_T* pCom = NULL; /* 内网通信配置 */ + if (NULL != Buf) + { + /*- 循环接收内网通信数据 */ + do + { + /*- 从通信层接收内网通信数据 */ + rxLen = CFM_InnetRemoteUpdate_Recv(&Buf[i + 2u], CM_UNSIGNED_INT_EXP(BufSize - (CM_UINT32)i - 2u), &srcIP, &srcPort); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /*- 收到的数据长度是否大于0 */ + if (0 < rxLen) + { + /*- 根据源IP、Port确定源ID */ + pCom = PFM_INI_RmInnetIP2Addr(srcIP, srcPort); + if (NULL != pCom) + { + /*- 打包成内网输入帧 */ + CM_ShortToChar((CM_UINT16)(rxLen), &Buf[i]); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + MSCP_LOG_MSG("SFM_RxInnetRemoteUpdate yes recv \n"); + i = i + rxLen + 2; + } + else + { + MSCP_LOG_MSG("SFM_RxInnetRemoteUpdate PFM_INI_InnetIP2Addr Is Null!!! \n"); + } + } + else + { + MSCP_LOG_MSG("SFM_RxInnetRemoteUpdate no recv \n"); + /*- 无处理*/ + } + } while (0 < rxLen); + (void)CFM_DarkLog_Storage(DARK_LOG_HEX, TSCP_DARK_CFMNET_INNETREMOTEUPDATE_RECVLEN, 4U, &i); + } + else + { + MSCP_LOG_MSG("SFM_RxInnetRemoteUpdate Buf Is Null!!! \n"); + } + /*- 返回内网输入帧总长度 */ + return i; +} + +/** +* @brief 外网安全数据接收 +* @param Buf 接收外网安全数据指针 +* @param BufSize 接收外网安全数据缓冲区大小 +* @return 收到的外网安全数据帧长度 +* @details +* 从通信层获取本周期外网安全输入数据 +* 按外网接收帧打包后交给平台层 +*/ +CM_INT32 SFM_RxOutnetSafe(OUT CM_UINT8 buf[], IN CM_UINT32 bufSize) +{ + /*- 变量初始化 */ + ENUM_OUTNET_CHN_T ch = ENUM_OUTNET_ERROR; /* 通道类型 */ + CM_INT32 allLen = 0; /* 报文总长 */ + CM_INT32 rxLen = 0; /* 接收报文长度 */ + CM_UINT8 ccVer = 0u; /* CC版本 */ + /*CM_UINT32 hlhtID = 0u; 互联互通ID */ + CM_UINT16 srcID = 0u; /* 设备ID */ + CM_UINT16 logicID = 0u; /* 逻辑ID */ + CM_UINT16 msgLen = 0u; /* 报文长度 */ + CM_UINT16 appLen = 0u; /* 用户数据长度 */ + CM_UINT32 redLen = 0u; /* 红网报文总长 */ + CM_UINT32 blueLen = 0u; /* 蓝网报文总长 */ + /* 来在通控的非法数据test mod */ + CM_UINT16 potoType = 0u; + CM_UINT16 dataType = 0u; + CM_UINT16 potycrc = 0u; + CM_UINT16 potycrcdata = 0u; + ENUM_CM_RETURN isTransformInFrame = ENUM_CM_FALSE; /*是否需要改变帧格式*/ + CM_UINT64 rxCtrlLen = 0u; + /*- 对入参进行防空检查,如果为空则宕机 */ + CM_ASSERT(NULL != buf, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + /*- 循环接收外网数据 */ + do + { + /*- 从通信层接收外网数据 */ + rxLen = CFM_OutnetSafe_Recv(s_Prtcl_UDP_Cache, sizeof(s_Prtcl_UDP_Cache), &ch); + (rxLen > 0)?(rxCtrlLen += rxLen):rxCtrlLen; + if(rxCtrlLen > g_PFM_Cfg.OutnetSafePack_Len) + { + CFM_ClearCache(); + break; + } + + /*- 接收长度是否大于0 */ + if (0 < rxLen) + { + /* TSL星链 主机-底座 用通信协议 */ + /*- 根据外网帧报文头确定源ID */ + /* + CC外网输入帧 + 2字节 长度 + 1字节 协议版本 + 2字节 设备id + 2字节 逻辑id(预留) + 4字节 目的互联互通ID + 2字节 协议类型 4 -1 + n字节 (安全协议保护的)用户数据 + 4字节 CRC + */ + msgLen = CM_ShortFromChar(s_Prtcl_UDP_Cache); + + /*- 检查报文长度是否正确 */ + CM_RE_ASSERT((CM_INT32)msgLen == (rxLen - 2), PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + ccVer = s_Prtcl_UDP_Cache[2]; + + /*- 判断输入数据是否合法 */ + CM_RE_ASSERT(0u == ccVer, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + CM_RE_ASSERT(msgLen > 15u, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_4); + appLen = msgLen - 15u; + srcID = CM_ShortFromChar(s_Prtcl_UDP_Cache + 3); + + /*- 如果应用没有注册输入ats转车数据备用通道判断函数 */ + if(NULL == p_Serial_IN_VOBC_Func) + { + /*- 无处理 */ + } + else + { + /*- 判断该数据是否是ats转车数据 */ + isTransformInFrame = (*p_Serial_IN_VOBC_Func)(srcID); + } + logicID = CM_ShortFromChar(s_Prtcl_UDP_Cache + 5); + + /* 来在通控的非法数据test mod */ + potoType = CM_ShortFromChar(s_Prtcl_UDP_Cache + 11); + dataType = CM_ShortFromChar(s_Prtcl_UDP_Cache + 13); + if(potoType == 4u) + { + potycrc = ComputeMsgCRC16_WL(s_Prtcl_UDP_Cache + 13,appLen-2); + potycrcdata = CM_ShortFromCharLE(s_Prtcl_UDP_Cache + 13 + appLen - 2); + + if((!(dataType==0x0180U || dataType==0x0190U || dataType==0x0191U || dataType==0x0181U)) || (potycrc != potycrcdata)) + { + MSCP_LOG_MSG("appLen = %d, dataType = %x, potycrc = %x, potycrcdata = %x \n",appLen,dataType,potycrc,potycrcdata); + } + + } + + /*- @alias 打包到外网接收协议帧 */ + /* + 2字节 长度 + 2字节 设备ID + 2字节 逻辑ID + n字节 数据 + */ + /*- 如果是来自红网数据 */ + if ((ENUM_OUTNET_RED == ch) || (ENUM_OUTNET_EXTEND_RED == ch)) + { + /*- 是否来自ats转车的输入数据 */ + if(ENUM_CM_TRUE == isTransformInFrame) + { + /*- 根据ats的包格式解数据 */ + appLen = msgLen - 29u; + srcID = CM_ShortFromChar(s_Prtcl_UDP_Cache + 19); + logicID = CM_ShortFromChar(s_Prtcl_UDP_Cache + 21); + CM_ShortToChar((CM_UINT16)(appLen + 4u), &buf[redLen + 4u]);/* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + CM_ShortToChar(srcID, &buf[redLen + 6u]);/* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + CM_ShortToChar(logicID, &buf[redLen + 8u]);/* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + (void)CM_Memcpy((void*)(&buf[redLen + 10u]), (CM_SIZE_T)CM_UNSIGNED_INT_EXP(bufSize - redLen - 10u), (void*)(s_Prtcl_UDP_Cache + 27), (CM_SIZE_T)(appLen));/* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + else + { + /*- 解源设备逻辑id */ + CM_ShortToChar((CM_UINT16)(appLen + 4u), &buf[redLen + 4u]);/* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + CM_ShortToChar(srcID, &buf[redLen + 6u]);/* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + CM_ShortToChar(logicID, &buf[redLen + 8u]);/* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + (void)CM_Memcpy((void*)(&buf[redLen + 10u]), (CM_SIZE_T)CM_UNSIGNED_INT_EXP(bufSize - redLen - 10u), (void*)(s_Prtcl_UDP_Cache + 13), (CM_SIZE_T)(appLen));/* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + redLen += (CM_UINT32)appLen + 6u; + } + else + { + /*- 是否来自ats转车的输入数据 */ + if(ENUM_CM_TRUE == isTransformInFrame) + { + /*- 根据ats的包格式解数据 */ + appLen = msgLen - 29u; + srcID = CM_ShortFromChar(s_Prtcl_UDP_Cache + 19); + logicID = CM_ShortFromChar(s_Prtcl_UDP_Cache + 21); + CM_ShortToChar((CM_UINT16)(appLen + 4u), s_TmpCache + blueLen + 4u); + CM_ShortToChar(srcID, s_TmpCache + blueLen + 6u); + CM_ShortToChar(logicID, s_TmpCache + blueLen + 8u); + (void)CM_Memcpy((void*)(s_TmpCache + blueLen + 10u), sizeof(s_TmpCache) - blueLen - 10u, (void*)(s_Prtcl_UDP_Cache + 27u), (CM_SIZE_T)(appLen)); + MSCP_LOG_MSG("srcID = %d, appLen = %d\n", srcID, appLen); + } + else + { + /*- 解源设备逻辑id */ + CM_ShortToChar((CM_UINT16)(appLen + 4u), s_TmpCache + blueLen + 4u); + CM_ShortToChar(srcID, s_TmpCache + blueLen + 6u); + CM_ShortToChar(logicID, s_TmpCache + blueLen + 8u); + (void)CM_Memcpy((void*)(s_TmpCache + blueLen + 10u), sizeof(s_TmpCache) - blueLen - 10u, (void*)(s_Prtcl_UDP_Cache + 13u), (CM_SIZE_T)(appLen)); + } + blueLen += (CM_UINT32)appLen + 6u; + } + } + else + { + /* MSCP_LOG_MSG("No communication with the external network\n"); */ + } + } while (0 < rxLen); + CFM_GetOSCache(); + /* 打包成外网接收帧 + 4字节 红网报文总长 + n字节 p个外网协议帧 + 4字节 蓝网报文总长 + m字节 q个外网协议帧 + */ + /*- 输出红蓝网的外网接收帧 */ + CM_RE_ASSERT((redLen + blueLen + 8u) <= bufSize, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_6); + allLen = (CM_INT32)CM_UNSIGNED_INT_EXP(redLen + blueLen + 8u); + CM_LongToChar(redLen, buf); + CM_LongToChar(blueLen, &buf[4u + redLen]); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + (void)CM_Memcpy((void*)(&buf[8u + redLen]), (CM_SIZE_T)CM_UNSIGNED_INT_EXP(bufSize - 8u - redLen), (void*)(s_TmpCache + 4), (CM_SIZE_T)blueLen); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /*- 返回外网接收帧总长度 */ + return allLen; +} + +/*把协议内网帧格式的数据写入协议层*/ +void SFM_WriteInnetSafeInput(IN const CM_UINT8 buf[], IN CM_UINT32 len, IN ENUM_INNET_CHN_T ch) +{ + MSCP_LOG_MSG("SFM_WriteInnetSafeInput len = %d\n",len); + (void)QueueWrite((CM_UINT32)len, buf, &s_InnetPrtcl.OutnetQueueA); +} + +/*把远程部署协议内网帧格式的数据写入协议层*/ +void SFM_WriteInnetSafeRmInput(IN const CM_UINT8 buf[], IN CM_UINT32 len, IN ENUM_INNET_CHN_T ch) +{ + CM_ASSERT_MAINTAIN(buf != NULL); + MSCP_LOG_MSG("SFM_WriteInnetSafeRmInput len=%d\n",len); + (void)QueueWrite((CM_UINT32)len, buf, &s_InnetPrtcl_RM.OutnetQueueA); + +} + +/** +* @brief 把协议外网帧格式的数据写入协议层 +* @param Buf 协议外网接收报文指针 +* @param len 协议外网接收报文长度 +* @param ch 外网通道类型 +*/ +void SFM_WriteOutnetSafeInput(IN const CM_UINT8 buf[], IN CM_UINT32 len, IN ENUM_OUTNET_CHN_T ch) +{ + /*- 变量初始化 */ + CM_UINT32 surplusLen = 0u; //剩余数据 + CM_UINT32 currLenBef = 0u; //当前数据 + CM_UINT32 currLenAft = 0u; //当前数据 + /*- 是否为红网报文 */ + if (ENUM_OUTNET_RED == ch) + { + /*- 将输入写入协议的红网输入队列 */ + currLenBef = QueueStatus(&s_OutnetPrtcl.OutnetQueueA); + surplusLen = QueueGetSpace(&s_OutnetPrtcl.OutnetQueueA); + MSCP_LOG_MSG("Red QueueWrite before:currLen=%d,surplusLen=%d\n",currLenBef,surplusLen); + (void)QueueWrite(len, buf, &s_OutnetPrtcl.OutnetQueueA); + surplusLen = QueueGetSpace(&s_OutnetPrtcl.OutnetQueueA);//队列剩余多少空间 + currLenAft = QueueStatus(&s_OutnetPrtcl.OutnetQueueA);//里面多少数据 + MSCP_LOG_MSG("Red QueueWrite after:currLen=%d,surplusLen=%d\n",currLenAft,surplusLen); + } + /*- 是否为蓝网报文 */ + else if (ENUM_OUTNET_BLUE == ch) + { + /*- 将输入写入协议的蓝网输入队列 */ + currLenBef = QueueStatus(&s_OutnetPrtcl.OutnetQueueB); + surplusLen = QueueGetSpace(&s_OutnetPrtcl.OutnetQueueB); + MSCP_LOG_MSG("Blue QueueWrite before:currLen=%d,surplusLen=%d\n",currLenBef,surplusLen); + (void)QueueWrite(len, buf, &s_OutnetPrtcl.OutnetQueueB); + surplusLen = QueueGetSpace(&s_OutnetPrtcl.OutnetQueueB);//队列剩余多少空间 + currLenAft = QueueStatus(&s_OutnetPrtcl.OutnetQueueB);//里面多少数据 + MSCP_LOG_MSG("Blue QueueWrite after:currLen=%d,surplusLen=%d\n",currLenAft,surplusLen); + } + else + { + /*- 宕机 */ + CM_RE_ASSERT(0, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1); + } +} + +/** +* @brief 协议层解析收到的数据 +*/ +void SFM_UnPrtclProc(void) +{ + CM_UINT32 QueuelenDataToApp = 0; + /*- 变量初始化 */ + PFM_CFC_Check(44); + /*- @alias 外网安全通信协议解析 */ + if (0x55u == g_PFM_Cfg.M_OutnetSafe_Enable) + { + (void)QueueClear(&s_OutnetPrtcl.DataToApp); + (void)ProtclReceiveDataFunc(&s_OutnetPrtcl); + (void)QueueClear(&s_OutnetPrtcl.OutnetQueueA); + (void)QueueClear(&s_OutnetPrtcl.OutnetQueueB); + } + else + { + /*- 无处理*/ + } + + PFM_CFC_Check(45); + /*- @alias 内网安全通信协议解析 */ + if (0x55u == g_PFM_Cfg.M_InnetSafe_Enable) + { + (void)QueueClear(&s_InnetPrtcl.DataToApp); + s_InnetPrtcl.RadamSN = SFM_2x2_GetSysCount(); + (void)ProtclReceive(&s_InnetPrtcl); + (void)QueueClear(&s_InnetPrtcl.OutnetQueueA); + (void)QueueClear(&s_InnetPrtcl.OutnetQueueB); + } + else + { + /*- 无处理*/ + } + PFM_CFC_Check(46); + /*- @alias 远程部署内网安全通信协议解析 */ + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + (void)QueueClear(&s_InnetPrtcl_RM.DataToApp); + s_InnetPrtcl_RM.RadamSN = SFM_2x2_GetSysCount(); + (void)ProtclReceive(&s_InnetPrtcl_RM); + (void)QueueClear(&s_InnetPrtcl_RM.OutnetQueueA); + (void)QueueClear(&s_InnetPrtcl_RM.OutnetQueueB); + + QueuelenDataToApp = QueueStatus(&s_InnetPrtcl_RM.DataToApp); + MSCP_LOG_MSG("QueuelenDataToApp = %d\n",QueuelenDataToApp); + } + else + { + /*- 无处理*/ + } +} + +/** +* @brief 接收外网协议报文 +* @param pSrcName 源设备ID +* @param pSrcLogicID 源逻辑ID +* @param pLifeTime 报文剩余有效期 +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 Prtcl_OutnetSafe_AppRecv(OUT CM_UINT16* pSrcName, OUT CM_UINT16* pSrcLogicID, OUT CM_UINT8* pLifeTime, + OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + /*- 变量初始化 */ + CM_UINT8 tmpBuf[2] = { 0u }; /* 临时变量 */ + CM_UINT16 msgLen = 0u; /* 报文长度 */ + CM_UINT32 qStatus = 0u; /* 队列状态 */ + CM_UINT32 rt = 0u; /* 函数返回值 */ + + CM_ASSERT(0x55u == g_PFM_Cfg.M_OutnetSafe_Enable, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1); + + /*- 锁定接收队列 */ + (void)CM_Mutex_Lock(s_Outnet_AppRecv_M); + + qStatus = CM_QueueStatus(&s_Outnet_AppRecvQ); + /*- 队列中是否有足够长的数据 */ + if (7u < qStatus) + { + /* + * 协议适配层头: + * 2字节 长度(不含自身) + * 2字节 源ID + * 2字节 逻辑ID + * 1字节 生存时间 + * n字节 数据*/ + /*- 读取协议帧长度 */ + (void)CM_QueueRead(2u, tmpBuf, &s_Outnet_AppRecvQ);/*长度*/ + msgLen = CM_ShortFromChar(tmpBuf); + /*- 检查协议帧长度是否合法 */ + if ((msgLen <= (qStatus - 2u)) && (msgLen > 5u) && ((msgLen - 5u) < rxSize)) + { + /*- 读取和输出协议帧头 */ + (void)CM_QueueRead(2u, tmpBuf, &s_Outnet_AppRecvQ);/*源ID*/ + *pSrcName = CM_ShortFromChar(tmpBuf); + + (void)CM_QueueRead(2u, tmpBuf, &s_Outnet_AppRecvQ);/*逻辑ID*/ + *pSrcLogicID = CM_ShortFromChar(tmpBuf); + + (void)CM_QueueRead(1u, pLifeTime, &s_Outnet_AppRecvQ);/*生存时间*/ + + /*- 读取应用数据 */ + (void)CM_QueueRead(msgLen - 5u, rxBuf, &s_Outnet_AppRecvQ); + /*- 输出应用数据长度 */ + rt = (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } + + /*- 解锁接收队列 */ + (void)CM_Mutex_Unlock(s_Outnet_AppRecv_M); + + /*- 返回 */ + return rt; +} + +/** +* @brief 发送外网协议报文 +* @param dstName 目的设备ID +* @param dstLogicID 目的逻辑ID +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用发送一条完整的应用报文 +* 应用每周期可多次调用本函数从而发送多个应用报文, +* 注意总发送长度不要超过周期通信总量限制 +*/ +CM_UINT8 Prtcl_OutnetSafe_AppSend(IN CM_UINT16 dstName, IN CM_UINT16 dstLogicID, IN const CM_UINT8* txBuf, IN CM_UINT32 txLen) +{ + /*- 变量初始化 */ + CM_UINT16 len = 0u; /* 长度 */ + CM_UINT8 buf[2u] = { 0u }; /* 临时变量 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + ENUM_CM_RETURN temprt = ENUM_CM_TRUE; /* 临时返回值 */ + CM_ASSERT(0x55u == g_PFM_Cfg.M_OutnetSafe_Enable, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_1); + + /*- 输入长度检查 */ + CM_RE_ASSERT(txLen <= NET_20K_SIZE, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_6, TSCP_DARK_ASSERT_2); + /* + 2字节 长度(不含自身) + 2字节 目的ID + 2字节 目的逻辑ID + n字节 数据 + */ + + len = (CM_UINT16)(txLen + 4u); + CM_ShortToChar(len, buf); + + /*- 锁定发送队列 */ + (void)CM_Mutex_Lock(s_Outnet_AppSend_M); + + /*- 填写协议输出帧头 */ + temprt &= CM_QueueWrite(2u, buf, &s_Outnet_AppSendQ);/*长度*/ + CM_ShortToChar(dstName, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Outnet_AppSendQ);/*目的ID*/ + CM_ShortToChar(dstLogicID, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Outnet_AppSendQ);/*目的逻辑ID*/ + /*- 填写应用输出报文 */ + temprt &= CM_QueueWrite(txLen, txBuf, &s_Outnet_AppSendQ); + if(ENUM_CM_TRUE == temprt) + { + rt = 1u;/*成功*/ + } + else + { + rt = 0u;/*失败*/ + } + + /*- 解锁发送队列 */ + (void)CM_Mutex_Unlock(s_Outnet_AppSend_M); + + /*- 返回 */ + return rt; +} + +/** +* @brief 接收内网协议报文 +* @param pSrcName 源设备ID +* @param pLifeTime 报文剩余有效期 +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 Prtcl_InnetSafe_AppRecv(OUT CM_UINT16* pSrcName, OUT CM_UINT8* pLifeTime, OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + /*- 变量初始化 */ + CM_UINT8 headBuf[7u] = { 0u }; /* 临时变量 */ + CM_UINT16 msgLen = 0u; /* 报文长度 */ + CM_UINT32 qStatus = 0u; /* 队列状态 */ + CM_UINT32 rt = 0u; /* 函数返回值 */ + + CM_ASSERT(0x55u == g_PFM_Cfg.M_InnetSafe_Enable, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_7, TSCP_DARK_ASSERT_1); + + /*- 锁定接收队列 */ + (void)CM_Mutex_Lock(s_Innet_AppRecv_M); + + qStatus = CM_QueueStatus(&s_Innet_AppRecvQ); + /*- 队列中是否有足够长的数据 */ + if (7u < qStatus) + { + /*- 读取协议帧头 */ + /* + 2字节 长度(不含自身) + 2字节 预留 + 2字节 源ID(小端) + 1字节 剩余有效时间 + n字节 数据 + */ + (void)CM_QueueRead(7u, headBuf, &s_Innet_AppRecvQ);/*长度*/ + msgLen = CM_ShortFromChar(headBuf); + /*- 检查协议帧长度是否合法 */ + if ((msgLen <= (qStatus - 2u)) && (msgLen > 5u) && ((msgLen - 5u) < rxSize)) + { + *pSrcName = CM_ShortFromCharLE(headBuf + 4u); + *pLifeTime = headBuf[6]; + (void)CM_QueueRead(msgLen - 5u, rxBuf, &s_Innet_AppRecvQ); + rt = (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } + + /*- 解锁接收队列 */ + (void)CM_Mutex_Unlock(s_Innet_AppRecv_M); + + /*- 返回报文长度 */ + return rt; +} + +/** +* @brief 发送内网安全协议报文 +* @param dstName 目的设备ID +* @param dstLogicID 目的逻辑ID +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用发送一条完整的应用报文 +* 每周期可多次调用本函数从而发送多个应用报文, +* 注意总发送长度不要超过周期通信总量限制 +*/ +CM_UINT8 Prtcl_InnetSafe_AppSend(IN CM_UINT16 dstName, IN const CM_UINT8* txBuf, IN CM_UINT32 txLen) +{ + /*- 变量初始化 */ + CM_UINT16 len = 0u; /* 长度 */ + CM_UINT8 buf[2u] = { 0u }; /* 临时变量 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + ENUM_CM_RETURN temprt = ENUM_CM_TRUE; /* 临时返回值 */ + + /*- 输入长度检查 */ + if (0x55u == g_PFM_Cfg.M_InnetSafe_Enable && txLen <= NET_20K_SIZE) + { + /* + 2字节 长度(不含自身) + 2字节 目的ID(小端) + n字节 数据 + */ + /*- 锁定发送队列 */ + (void)CM_Mutex_Lock(s_Innet_AppSend_M); + + /*- 填写协议输出帧头 */ + len = (CM_UINT16)(txLen + 4u); + CM_ShortToChar(len, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Innet_AppSendQ);/*长度*/ + CM_ShortToCharLE(0u, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Innet_AppSendQ);/*2字节预留*/ + CM_ShortToCharLE(dstName, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Innet_AppSendQ);/*目的ID*/ + /*- 填写应用输出报文 */ + temprt &= CM_QueueWrite(txLen, txBuf, &s_Innet_AppSendQ); + if(ENUM_CM_TRUE == temprt) + { + rt = 1u;/*成功*/ + } + else + { + rt = 0u;/*失败*/ + } + + /*- 解锁发送队列 */ + (void)CM_Mutex_Unlock(s_Innet_AppSend_M); + } + else + { + /*无处理*/ + } + + /*- 返回 */ + return rt; +} + +/** +* @brief 接收远程部署内网协议报文(应用接收) +* @param pSrcName 源设备ID +* @param pLifeTime 报文剩余有效期 +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 Prtcl_InnetSafe_RmRecv(OUT CM_UINT16* pSrcName, OUT CM_UINT8* pLifeTime, OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + /*- 变量初始化 */ + CM_UINT8 headBuf[7u] = { 0u }; /* 临时变量 */ + CM_UINT16 msgLen = 0u; /* 报文长度 */ + CM_UINT32 qStatus = 0u; /* 队列状态 */ + CM_UINT32 rt_len = 0u; /* 函数返回长度值 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + + if ((0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /*- 锁定接收队列 */ + (void)CM_Mutex_Lock(s_Innet_RmRecv_M); + + qStatus = CM_QueueStatus(&s_Innet_RmRecvQ); + MSCP_LOG_MSG("Prtcl_InnetSafe_RmRecv len = %d\n", qStatus); + do + { + /*- 队列中是否有足够长的数据 */ + if (7u < qStatus) + { + + /*- 读取协议帧头 */ + /* + 2字节 长度(不含自身) + 2字节 预留 + 2字节 源ID(小端) + 1字节 剩余有效时间 + n字节 数据 + */ + (void)CM_QueueRead(7u, headBuf, &s_Innet_RmRecvQ);/*长度*/ + msgLen = CM_ShortFromChar(headBuf); + /*- 检查协议帧长度是否合法 */ + if ((msgLen <= (qStatus - 2u)) && (msgLen > 5u) && ((msgLen - 5u) < rxSize)) + { + *pSrcName = CM_ShortFromCharLE(headBuf + 4u); + *pLifeTime = headBuf[6]; + rt_len = (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u); + (void)CM_QueueRead(rt_len, rxBuf, &s_Innet_RmRecvQ); + + /*- 解析通信协议,如果是重启或切系命令,执行重启或切系逻辑*/ + rt = PFM_RemoteRun_Data(rxBuf,rt_len); + /*- 如果是重启命令*/ + if((0xA5 <= rt) && (0xA8 >= rt)) + { + /*- 平台过滤重启命令*/ + qStatus -= rt_len; + /*- 长度清零,不给到应用*/ + rt_len = 0u; + } + else + { + /*- 给到应用数据*/ + break; + } + } + else + { + /*- 无处理*/ + break; + } + } + else + { + /*- 无处理*/ + break; + } + }while(1); + /*- 解锁接收队列 */ + (void)CM_Mutex_Unlock(s_Innet_RmRecv_M); + } + else + { + /*- 无处理*/ + } + + /*- 返回报文长度 */ + return rt_len; +} + +/** +* @brief 接收远程部署内网协议报文(平台退出运营后接收) +* @param pSrcName 源设备ID +* @param pLifeTime 报文剩余有效期 +* @param rxBuf 收到的应用报文数组 +* @param rxSize 接收应用报文的缓冲区(rxBuf)大小,应不小于可能收到的最长应用报文长度 +* @return 收到的应用报文长度 +* @details +* 每次调用获得一条完整的应用报文 +* 每周期应持续调用本函数直到获得的报文长度 *pRxLen == 0 +*/ +CM_UINT32 Prtcl_InnetSafe_PlatRmRecv(OUT CM_UINT16* pSrcName, OUT CM_UINT8* pLifeTime, OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize) +{ + /*- 变量初始化 */ + CM_UINT8 headBuf[7u] = { 0u }; /* 临时变量 */ + CM_UINT16 msgLen = 0u; /* 报文长度 */ + CM_UINT32 qStatus = 0u; /* 队列状态 */ + CM_UINT32 rt_len = 0u; /* 函数返回长度值 */ + if ((0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /*- 锁定接收队列 */ + (void)CM_Mutex_Lock(s_Innet_RmRecv_M); + + qStatus = CM_QueueStatus(&s_Innet_RmRecvQ); + MSCP_LOG_MSG("Prtcl_InnetSafe_PlatRmRecv len = %d\n", qStatus); + + /*- 队列中是否有足够长的数据 */ + if (7u < qStatus) + { + + /*- 读取协议帧头 */ + /* + 2字节 长度(不含自身) + 2字节 预留 + 2字节 源ID(小端) + 1字节 剩余有效时间 + n字节 数据 + */ + (void)CM_QueueRead(7u, headBuf, &s_Innet_RmRecvQ);/*长度*/ + msgLen = CM_ShortFromChar(headBuf); + /*- 检查协议帧长度是否合法 */ + if ((msgLen <= (qStatus - 2u)) && (msgLen > 5u) && ((msgLen - 5u) < rxSize)) + { + *pSrcName = CM_ShortFromCharLE(headBuf + 4u); + *pLifeTime = headBuf[6]; + rt_len = (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u); + (void)CM_QueueRead(rt_len, rxBuf, &s_Innet_RmRecvQ); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } + /*- 解锁接收队列 */ + (void)CM_Mutex_Unlock(s_Innet_RmRecv_M); + } + else + { + /*- 无处理*/ + } + + /*- 返回报文长度 */ + return rt_len; +} + + +/** +* @brief 应用发送远程部署退出运营确认内网协议报文 +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +*/ +CM_UINT8 Prtcl_InnetSafe_AppRmSend(IN const CM_UINT8* txBuf, IN CM_UINT32 txLen) +{ + /*- 变量初始化 */ + CM_UINT8 buf[2u] = { 0u }; /* 临时变量 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + ENUM_CM_RETURN temprt = ENUM_CM_TRUE; /* 临时返回值 */ + CM_ASSERT_MAINTAIN(txBuf != NULL); + /*- 输入长度检查 */ + if ((0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /* + 2字节 长度(不含自身) + n字节 数据 + */ + /*- 锁定发送队列 */ + (void)CM_Mutex_Lock(s_Innet_AppRmSend_M); + + /*- 填写协议输出帧头 */ + CM_ShortToChar(txLen, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Innet_AppRmSendQ);/*长度*/ + /*- 填写应用输出报文 */ + temprt &= CM_QueueWrite(txLen, txBuf, &s_Innet_AppRmSendQ); + if(ENUM_CM_TRUE == temprt) + { + rt = 1u;/*成功*/ + } + else + { + rt = 0u;/*失败*/ + } + + /*- 解锁发送队列 */ + (void)CM_Mutex_Unlock(s_Innet_AppRmSend_M); + } + else + { + /*无处理*/ + } + /*- 返回 */ + return rt; +} + +/** +* @brief 发送远程部署内网协议报文 +* @param dstName 目的设备ID +* @param dstLogicID 目的逻辑ID +* @param txBuf 发送的应用报文数组 +* @param txLen 发送的应用报文长度 +* @return 函数执行结果 +* - 1 成功 +* - 0 失败(输入非法) +* @details +* 每次调用发送一条完整的应用报文 +* 平台每周期只能调用本函数一次发送一个远程部署报文, +* 注意总发送长度不要超过周期通信总量限制 +*/ +CM_UINT8 Prtcl_InnetSafe_RmSend(IN CM_UINT16 dstName, IN const CM_UINT8* txBuf, IN CM_UINT32 txLen) +{ + /*- 变量初始化 */ + CM_UINT16 len = 0u; /* 长度 */ + CM_UINT16 applen = 0u; /* 长度 */ + CM_UINT8 buf[2u] = { 0u }; /* 临时变量 */ + CM_UINT8 Buftmp[128] = { 0u }; /* 临时变量 */ + CM_UINT8 rt = 0u; /* 函数返回值 */ + ENUM_CM_RETURN temprt = ENUM_CM_TRUE; /* 临时返回值 */ + + /*- 输入长度检查 */ + if ((0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /*- 锁定发送队列 */ + (void)CM_Mutex_Lock(s_Innet_AppRmSend_M); + /*- 读取应用帧头 */ + /* + 2字节 长度(不含自身) + n字节 数据 + */ + (void)CM_QueueRead(2u, buf, &s_Innet_AppRmSendQ);/*长度*/ + applen = CM_ShortFromChar(buf); + + (void)CM_QueueRead(applen, Buftmp, &s_Innet_AppRmSendQ);/*长度*/ + + /*- 解锁发送队列 */ + (void)CM_Mutex_Unlock(s_Innet_AppRmSend_M); + + /* + 2字节 长度(不含自身) + 2字节 目的ID(小端) + n字节 数据 + */ + (void)CM_Mutex_Lock(s_Innet_RmSend_M); + + /*- 填写协议输出帧头 */ + len = (CM_UINT16)(txLen + 4u)+applen; + CM_ShortToChar(len, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Innet_RmSendQ);/*长度*/ + CM_ShortToCharLE(0u, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Innet_RmSendQ);/*2字节预留*/ + CM_ShortToCharLE(dstName, buf); + temprt &= CM_QueueWrite(2u, buf, &s_Innet_RmSendQ);/*目的ID*/ + /*- 填写应用输出报文 */ + temprt &= CM_QueueWrite(txLen, txBuf, &s_Innet_RmSendQ); + if(ENUM_CM_TRUE == temprt) + { + temprt &= CM_QueueWrite(applen, Buftmp, &s_Innet_RmSendQ); + if(ENUM_CM_TRUE == temprt) + { + rt = 1u;/*成功*/ + } + else + { + rt = 0u;/*失败*/ + } + } + else + { + rt = 0u;/*失败*/ + } + + /*- 解锁发送队列 */ + (void)CM_Mutex_Unlock(s_Innet_RmSend_M); + } + else + { + /*无处理*/ + } + + /*- 返回 */ + return rt; +} + +/** +* @brief 协议层封装待发送数据 +*/ +void SFM_EnPrtclProc(void) +{ + CM_UINT16 local_len = 0u; + CM_UINT8 local_buf[1500u] = {0u}; + CM_UINT16 peer_len = 0u; + CM_UINT8 p_peer_buf[1500u] = {0u}; + CM_UINT32 len1 = 0u; + CM_UINT32 len2 = 0u; + /*- 协议层封装待发送外网数据 */ + PFM_CFC_Check(3); + if (0x55u == g_PFM_Cfg.M_OutnetSafe_Enable) + { + CM_LongToChar(0u, s_OutnetPrtcl.AppArray); + CM_LongToChar(0u, s_OutnetPrtcl.RecordArray); + (void)ProtclSendDataFunc(&s_OutnetPrtcl); + (void)QueueClear(&s_OutnetPrtcl.OutputDataQueue); + /*- 是否开启2oo2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 双CPU交换SVC */ + (void)ProtclGetSwapData(local_buf,1500u,&s_OutnetPrtcl); + local_len = 2u + CM_ShortFromChar(local_buf); + CM_RE_ASSERT(local_len <= sizeof(local_buf), PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_1); + peer_len = (CM_UINT16)SFM_2oo2_Exchange_Currency(local_buf, (CM_INT32)local_len, p_peer_buf, sizeof(p_peer_buf), ENUM_2oo2_OUTPUT_EX); + (void)ProtclSetSwapData(p_peer_buf,&s_OutnetPrtcl); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } + + /*- 内网安全协议封装 */ + PFM_CFC_Check(4); + if (0x55u == g_PFM_Cfg.M_InnetSafe_Enable) + { + CM_LongToChar(0u, s_InnetPrtcl.PrtclSndBuff); + CM_LongToChar(0u, s_InnetPrtcl.RecordArray); + (void)ProtclOutput(&s_InnetPrtcl); + (void)QueueClear(&s_InnetPrtcl.OutputDataQueue); + /*- 是否开启2oo2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 双CPU交换SVC */ + (void)SfpGetSwapData(local_buf,1500u,&s_InnetPrtcl); + local_len = 2u + CM_ShortFromChar(local_buf); + CM_RE_ASSERT(local_len <= sizeof(local_buf), PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_2); + peer_len = (CM_UINT16)SFM_2oo2_Exchange_Currency(local_buf, (CM_INT32)local_len, p_peer_buf, sizeof(p_peer_buf), ENUM_2oo2_OUTPUT_EX); + (void)SfpSetSwapData(p_peer_buf,&s_InnetPrtcl); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } + + /*- 远程部署内网安全协议封装 */ + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + CM_LongToChar(0u, s_InnetPrtcl_RM.PrtclSndBuff); + CM_LongToChar(0u, s_InnetPrtcl_RM.RecordArray); + (void)ProtclOutput(&s_InnetPrtcl_RM); + (void)QueueClear(&s_InnetPrtcl_RM.OutputDataQueue); + + len1 = CM_LongFromChar(s_InnetPrtcl_RM.PrtclSndBuff); + len2 = CM_LongFromChar(s_InnetPrtcl_RM.RecordArray); + MSCP_LOG_MSG("s_InnetPrtcl_RM.PrtclSndBuff = %d, s_InnetPrtcl_RM.RecordArray = %d\n",len1,len2); + /*- 是否开启2oo2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 双CPU交换SVC */ + (void)SfpGetSwapData(local_buf,1500u,&s_InnetPrtcl_RM); + local_len = 2u + CM_ShortFromChar(local_buf); + CM_RE_ASSERT(local_len <= sizeof(local_buf), PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_9, TSCP_DARK_ASSERT_3); + peer_len = (CM_UINT16)SFM_2oo2_Exchange_Currency(local_buf, (CM_INT32)local_len, p_peer_buf, sizeof(p_peer_buf), ENUM_2oo2_OUTPUT_EX); + (void)SfpSetSwapData(p_peer_buf,&s_InnetPrtcl_RM); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } +} + +/** +* @brief 从协议适配层读取协议内网输出帧 +* @param Buf 输出报文缓冲区指针 +* @param BufSize 输出报文缓冲区大小 +* @return 输出报文总长度 +*/ +CM_UINT32 SFM_ReadInnetCodedOutput(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize) +{ + /* + * 格式: + * 4字节总长度 | 4字节内网输出报文长度 | 内网输出帧1 | 内网输出帧2 …… 内网输出帧n | 4字节日志报文长度 | n字节日志报文 | + * 内网输出帧: 2字节帧长度 + 1字节协议类型 + 2字节目的ID(大端) + 2字节预留 + n字节数据 + */ + /*- 获取输出报文总长度 */ + CM_UINT32 len = CM_LongFromChar(s_InnetPrtcl.PrtclSndBuff); + CM_RE_ASSERT(BufSize >= 4u, PRTCL_MODE,DARK_FAULT_CODE_FUN_ORDER_19, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT(len <= (BufSize - 4u), PRTCL_MODE,DARK_FAULT_CODE_FUN_ORDER_19, TSCP_DARK_ASSERT_2); + /*- 输出全部输出报文 */ + (void)CM_Memcpy((void*)Buf, (CM_SIZE_T)BufSize, (void*)s_InnetPrtcl.PrtclSndBuff, (CM_SIZE_T)CM_UNSIGNED_INT_EXP(len + 4u)); + + /*- 返回输出报文总长度 */ + return len + 4u ; +} + +/** +* @brief 从协议适配层读取协议内网远程部署输出帧 +* @param Buf 输出报文缓冲区指针 +* @param BufSize 输出报文缓冲区大小 +* @return 输出报文总长度 +*/ +CM_UINT32 SFM_ReadInnetRmCodedOutput(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize) +{ + /* + * 格式: + * 4字节总长度 | 4字节内网输出报文长度 | 内网输出帧1 | 内网输出帧2 …… 内网输出帧n | 4字节日志报文长度 | n字节日志报文 | + * 内网输出帧: 2字节帧长度 + 1字节协议类型 + 2字节目的ID(大端) + 2字节预留 + n字节数据 + */ + /*- 获取输出报文总长度 */ + CM_UINT32 len = 0u; + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + len = CM_LongFromChar(s_InnetPrtcl_RM.PrtclSndBuff); + CM_RE_ASSERT(BufSize >= 4u,PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_21, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT(len <= (BufSize - 4u), PRTCL_MODE,DARK_FAULT_CODE_FUN_ORDER_21, TSCP_DARK_ASSERT_2); + /*- 输出全部输出报文 */ + (void)CM_Memcpy((void*)Buf, (CM_SIZE_T)BufSize, (void*)s_InnetPrtcl_RM.PrtclSndBuff, (CM_SIZE_T)CM_UNSIGNED_INT_EXP(len + 4u)); + } + else + { + CM_Memset((void*)Buf,0u, 4u,(CM_SIZE_T)BufSize); + } + /*- 返回输出报文总长度 */ + return len + 4u ; +} + +/** +* @brief 从协议适配层读取协议内网输出帧(宕机情况调用) +* @param Buf 输出报文缓冲区指针 +* @param BufSize 输出报文缓冲区大小 +* @return 输出报文总长度 +*/ +CM_UINT32 SFM_ReadInnetCodedOutputCrash(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize) +{ + ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */ + /* + * 格式: + * 4字节总长度 | 4字节内网输出报文长度 | 内网输出帧1 | 内网输出帧2 …… 内网输出帧n | 4字节日志报文长度 | n字节日志报文 | + * 内网输出帧: 2字节帧长度 + 1字节协议类型 + 2字节目的ID(大端) + 2字节预留 + n字节数据 + */ + /*- 获取输出报文总长度 */ + CM_UINT32 len = CM_LongFromChar(s_InnetPrtcl_RM.PrtclSndBuff); + MSCP_LOG_MSG("SFM_ReadInnetCodedOutputCrash len3 = %d\n",len); + if (BufSize >= 4u && len <= (BufSize - 4u)) + { + /*- 输出全部输出报文 */ + ret = CM_Memcpy((void*)Buf, (CM_SIZE_T)BufSize, (void*)s_InnetPrtcl_RM.PrtclSndBuff, (CM_SIZE_T)CM_UNSIGNED_INT_EXP(len + 4u)); + CM_ASSERT_MAINTAIN(ret == ENUM_CM_TRUE); + } + else + { + MSCP_LOG_MSG("SFM_ReadInnetCodedOutputCrash BufSize is %u error!!! \n",BufSize); + } + /*- 返回输出报文总长度 */ + return len + 4u; +} + +/** +* @brief 从协议适配层读取协议外网输出帧 +* @param Buf 输出报文缓冲区指针 +* @param BufSize 输出报文缓冲区大小 +* @return 输出报文总长度 +*/ +CM_UINT32 SFM_ReadOutnetCodedOutput(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize) +{ + /* + * 格式: + * 4字节总长度 | 外网输出帧1 | 外网输出帧2 …… + * 外网输出帧:2字节长度 + 1字节协议类型 + 2字节目的ID + 2字节逻辑ID + n字节数据 + */ + /*- 获取输出报文总长度 */ + CM_UINT32 len = CM_LongFromChar(s_OutnetPrtcl.AppArray); + CM_RE_ASSERT(BufSize >= 4u, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_1); + CM_RE_ASSERT(len <= (BufSize - 4u), PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_11, TSCP_DARK_ASSERT_2); + /*- 输出全部输出报文 */ + (void)CM_Memcpy((void*)Buf, (CM_SIZE_T)BufSize, (void*)s_OutnetPrtcl.AppArray, (CM_SIZE_T)CM_UNSIGNED_INT_EXP(len + 4u)); + /*- 返回输出报文总长度 */ + return len + 4u; +} + +/** +* @brief 发送内网安全通信数据 +* @param buf 输出数据数组 +* @param Len 输出数据长度 +* @details 输出数据数组按照内网SFP协议输出报文结构组织 +*/ +void SFM_TxInnetSafe(IN CM_UINT8 Buf[], IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT32 allLen = CM_LongFromChar(Buf); /*外网输出帧报文总长度*/ + CM_UINT32 dataLen = 0u; + CM_UINT32 dataEnd = 0u; + CM_UINT32 i = 0u; /* 循环变量 */ + CM_UINT16 msgLen = 0u; /* 外网输出帧长度 */ + CM_UINT16 dstID = 0u; /* 目的设备ID */ + STRU_PFM_INNET_CFG_T* pCom = NULL;/* 通信配置 */ + + CM_RE_ASSERT((allLen + 4u) == Len, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_1); + + dataLen = CM_LongFromChar(&Buf[4u]); + dataEnd = dataLen + 8u; + + i = 8u; + /*- 遍历输出队列 */ + while ((i + 7u) < dataEnd) + { + /* + 协议外网输出帧头 + 2字节 长度 + 1字节 协议类型 + 2字节 目的ID + 2字节 预留 + n字节 数据 + */ + /*- 解析协议内网输出帧头 */ + msgLen = CM_ShortFromChar(&Buf[i]); /* 2字节 帧长度 */ /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /* Buf[i + 2u]; */ /* 1字节 协议类型 */ + dstID = CM_ShortFromChar(&Buf[i + 3u]); /* 2字节 目的ID */ /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + (void)CM_ShortFromChar(&Buf[i + 5u]); /* 2字节 (逻辑id) */ + + CM_RE_ASSERT(msgLen > 5u, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT(msgLen <= (Len - i - 2u), PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_3); + CM_RE_ASSERT(msgLen <= NET_20K_SIZE, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_12, TSCP_DARK_ASSERT_4); + + /*- 获取目的IP端口 */ + pCom = PFM_INI_InnetID2Addr(dstID); + /*- 是否获取成功 */ + if (NULL != pCom) + { + /*- 本机是否为CPU1 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + /*- 从绿网通道发送 */ + (void)CFM_InnetSafe_Send(&Buf[i + 7u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u), pCom->IP_G, pCom->Port_Safe_G); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + else + { + /*- 从紫网通道发送 */ + (void)CFM_InnetSafe_Send(&Buf[i + 7u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u), pCom->IP_P, pCom->Port_Safe_P); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + } + else + { + /*- 无处理*/ + } + i += (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen + 2u); + } +} +/** +* @brief 发送内网安全远程部署通信数据 +* @param buf 输出数据数组 +* @param Len 输出数据长度 +* @details 输出数据数组按照内网SFP协议输出报文结构组织 +*/ +void SFM_TxInnetSafeRm(IN CM_UINT8 Buf[], IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT32 allLen = 0u; /*外网输出帧报文总长度*/ + CM_UINT32 dataLen = 0u; + CM_UINT32 dataEnd = 0u; + CM_UINT32 i = 0u; /* 循环变量 */ + CM_UINT16 msgLen = 0u; /* 外网输出帧长度 */ + CM_UINT16 dstID = 0u; /* 目的设备ID */ + STRU_PFM_INNET_CFG_T* pCom = NULL;/* 通信配置 */ + + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + allLen = CM_LongFromChar(Buf); /*外网输出帧报文总长度*/ + CM_RE_ASSERT((allLen + 4u) == Len,PRTCL_MODE,DARK_FAULT_CODE_FUN_ORDER_20, TSCP_DARK_ASSERT_1); + + dataLen = CM_LongFromChar(&Buf[4u]); + dataEnd = dataLen + 8u; + + i = 8u; + /*- 遍历输出队列 */ + while ((i + 7u) < dataEnd) + { + /* + 协议外网输出帧头 + 2字节 长度 + 1字节 协议类型 + 2字节 目的ID + 2字节 预留 + n字节 数据 + */ + /*- 解析协议内网输出帧头 */ + msgLen = CM_ShortFromChar(&Buf[i]); /* 2字节 帧长度 */ /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /* Buf[i + 2u]; */ /* 1字节 协议类型 */ + dstID = CM_ShortFromChar(&Buf[i + 3u]); /* 2字节 目的ID */ /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + (void)CM_ShortFromChar(&Buf[i + 5u]); /* 2字节 (逻辑id) */ + + CM_RE_ASSERT(msgLen > 5u, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_20, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT(msgLen <= (Len - i - 2u),PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_20, TSCP_DARK_ASSERT_3); + CM_RE_ASSERT(msgLen <= NET_20K_SIZE,PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_20, TSCP_DARK_ASSERT_4); + + /*- 获取目的IP端口 */ + pCom = PFM_INI_InnetID2Addr(dstID); + /*- 是否获取成功 */ + if (NULL != pCom) + { + if (g_Maintenance_Id == dstID) + { + /*- 远程部署维护终端设备 */ + /*- 本机是否为CPU1 */ + if (1u == g_PFM_Cfg.CPU_ID) + { + /*- 从绿网通道发送 */ + (void)CFM_InnetRemoteUpdate_Send(&Buf[i + 7u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u), pCom->IP_G, pCom->Port_Safe_G); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + else + { + /*- 从紫网通道发送 */ + (void)CFM_InnetRemoteUpdate_Send(&Buf[i + 7u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u), pCom->IP_P, pCom->Port_Safe_P); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + } + else + { + MSCP_LOG_MSG("SFM_TxInnetSafeRm dstID = %x error!!! \n",dstID); + } + } + else + { + /*- 无处理*/ + } + i += (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen + 2u); + } + } + else + { + /*- 无处理 */ + } +} + +/** +* @brief 发送内网远程部署安全通信数据(宕机后使用) +* @param buf 输出数据数组 +* @param Len 输出数据长度 +* @details 输出数据数组按照内网SFP协议输出报文结构组织 +*/ +void SFM_TxInnetSafeRemoteUpdate(IN CM_UINT8 Buf[], IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT32 allLen = CM_LongFromChar(Buf); /*外网输出帧报文总长度*/ + CM_UINT32 dataLen = 0u; + CM_UINT32 dataEnd = 0u; + CM_UINT32 i = 0u; /* 循环变量 */ + CM_UINT16 msgLen = 0u; /* 外网输出帧长度 */ + CM_UINT16 dstID = 0u; /* 目的设备ID */ + STRU_PFM_INNET_CFG_T* pCom = NULL;/* 通信配置 */ + + if ((allLen + 4u) == Len) + { + MSCP_LOG_MSG("\nSFM_TxInnetSafeRemoteUpdate : allLen=%d,Len=%d\n",allLen,Len); + dataLen = CM_LongFromChar(&Buf[4u]); + dataEnd = dataLen + 8u; + + i = 8u; + + MSCP_LOG_MSG("\nSFM_TxInnetSafeRemoteUpdate : i=%d,dataEnd=%d\n",i,dataEnd); + /*- 遍历输出队列 */ + while ((i + 7u) < dataEnd) + { + /* + 协议外网输出帧头 + 2字节 长度 + 1字节 协议类型 + 2字节 目的ID + 2字节 预留 + n字节 数据 + */ + /*- 解析协议内网输出帧头 */ + msgLen = CM_ShortFromChar(&Buf[i]); /* 2字节 帧长度 */ /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /* Buf[i + 2u]; */ /* 1字节 协议类型 */ + dstID = CM_ShortFromChar(&Buf[i + 3u]); /* 2字节 目的ID */ /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + (void)CM_ShortFromChar(&Buf[i + 5u]); /* 2字节 (逻辑id) */ + MSCP_LOG_MSG("\nSFM_TxInnetSafeRemoteUpdate : msgLen=%d,dstID=%d\n",msgLen,dstID); + if (msgLen > 5u && msgLen <= (Len - i - 2u) && msgLen <= NET_20K_SIZE) + { + /*- 获取目的IP端口 */ + pCom = PFM_INI_RmInnetID2Addr(dstID); + /*- 是否获取成功 */ + if (NULL != pCom) + { + if (g_Maintenance_Id == dstID) + { + /*- 远程部署维护终端设备 */ + /*- 本机是否为CPU1 */ + if (1u == g_RMUP_Cfg.CPU_ID) + { + /*- 从绿网通道发送 */ + (void)CFM_InnetRemoteUpdate_Send(&Buf[i + 7u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u), pCom->IP_G, pCom->Port_Safe_G); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + else + { + /*- 从紫网通道发送 */ + (void)CFM_InnetRemoteUpdate_Send(&Buf[i + 7u], (CM_INT32)CM_UNSIGNED_SHORT_EXP(msgLen - 5u), pCom->IP_P, pCom->Port_Safe_P); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + } + } + else + { + MSCP_LOG_MSG("SFM_TxInnetSafeRemoteUpdate dstID = %x error!!! \n",dstID); + } + } + else + { + /*- 无处理*/ + } + i += (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen + 2u); + } + else + { + MSCP_LOG_MSG("SFM_TxInnetSafeRemoteUpdate msgLen = %u error!!! \n",msgLen); + } + } + } + else + { + MSCP_LOG_MSG("SFM_TxInnetSafeRemoteUpdate allLen = %u error!!! \n",allLen); + } +} + +/** +* @brief 发送外网安全通信数据 +* @param buf 输出数据数组 +* @param Len 输出数据长度 +* @details 输出数据数组按照协议适配层外网输出报文结构组织 +*/ +void SFM_TxOutnetSafe(IN CM_UINT8 buf[], IN CM_UINT32 Len) +{ + /*- 变量初始化 */ + CM_UINT32 allLen = CM_LongFromChar(buf); /*外网输出帧报文总长度*/ + CM_UINT32 i = 0u; /* 循环变量 */ + CM_UINT16 msgLen = 0u; /* 外网输出帧长度 */ + CM_UINT16 appLen = 0u; /* 应用通信数据长度 */ + CM_INT32 ccLen = 0; /* 输出给CC的报文长度 */ + CM_UINT16 dstID = 0u; /* 目的设备ID */ + CM_UINT16 logicID = 0u; /* 目的逻辑ID */ + /* CM_UINT32 srcHlhtId = 0u; */ /* 源互联互通ID */ + /* CM_UINT32 dstHlhtId = 0u; */ /* 目的互联互通ID */ + CM_UINT8 type = 0u; /* 协议类型 */ + CM_UINT32 crc = 0u; /* CRC */ + CM_UINT32 sysCount = SFM_2x2_GetSysCount(); /* 周期号 */ + ENUM_CM_RECCUSEB isSendExtendBoard = ENUM_CM_CC; /*是否发给扩展板*/ + ENUM_CM_RETURN isTransformOutFrame = ENUM_CM_FALSE; /*是否需要改变帧格式*/ + CM_UINT16 eAtsOutLen = 0; /* 改变后的真实长度 */ + CM_UINT16 eTrueSrcID = 0; /* 改变后的真实源设备类型ID */ + CM_UINT16 eTrueDstID = 0; /* 改变后的真实目的设备类型ID */ + CM_UINT32 tx_sn = 0u; + CM_RE_ASSERT((allLen + 4u) == Len, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_1); + i = 4u; + /*- 循环遍历输出队列 */ + while ((i + 7u) < Len) + { + /* + 协议外网输出帧头 + 2字节 长度 + 1字节 协议类型 + 2字节 目的ID + 2字节 逻辑ID + n字节 数据 + */ + /*- 解析协议外网输出帧头 */ + msgLen = CM_ShortFromChar(&buf[i]); /*2字节 帧长度*/ /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + type = buf[i + 2u]; /*1字节 协议类型*/ + dstID = CM_ShortFromChar(&buf[i + 3u]); /*2字节 目的设备ID*/ /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + logicID = CM_ShortFromChar(&buf[i + 5u]); /*2字节 逻辑ID*/ + appLen = msgLen - 5u; /* 外网通信数据长度为 msgLen - 5 */ + + CM_RE_ASSERT(msgLen > 5u, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_2); + CM_RE_ASSERT(msgLen <= (Len - i - 2u), PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_3); + CM_RE_ASSERT(msgLen <= NET_20K_SIZE, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_13, TSCP_DARK_ASSERT_4); + + + /* TSL星链 主机-底座 协议*/ + + /*- 组CC外网输出帧头 */ + /* + CC外网输出帧 + 2字节 长度 + 1字节 协议版本 + 4字节 周期号 + 2字节 目的设备id + 2字节 目的逻辑id + 2字节 协议类型 + n字节 数据 + 4字节 CRC + */ + CM_ShortToChar((CM_UINT16)(appLen + 19u), s_Prtcl_UDP_Cache); /* 长度 */ + s_Prtcl_UDP_Cache[2] = 0u; /* 协议版本固定为0 */ +#if 0 + CM_ShortToChar(0u, s_Prtcl_UDP_Cache + 3); /* 源目的设备ID */ + CM_ShortToChar(0u, s_Prtcl_UDP_Cache + 5); /* 源目的逻辑ID */ +#else + CM_LongToChar(sysCount, s_Prtcl_UDP_Cache + 3); /* 序列号 */ +#endif + tx_sn = SFM_GetTxSn(); /* 获取帧序号*/ + CM_LongToChar(tx_sn, s_Prtcl_UDP_Cache + 7); /* 帧序号 */ + CM_ShortToChar(dstID, s_Prtcl_UDP_Cache + 11); /* 目的设备ID */ + CM_ShortToChar(logicID, s_Prtcl_UDP_Cache + 13); /* 目的逻辑ID */ + + CM_ShortToChar((CM_UINT16)type, s_Prtcl_UDP_Cache + 15); /* 协议类型 */ + + /*- 应用是否注册ats转车输出函数 */ + if(NULL == p_Serial_OUT_ATSVOBC_Func) + { + /*- 无处理 */ + } + else + { + /*- 判断是否是ats转车输出数据 */ + isTransformOutFrame = (*p_Serial_OUT_ATSVOBC_Func)(dstID, &eTrueSrcID, &eTrueDstID); + } + + /*- 应用是否注册转串口扩展板数据函数 */ + if(NULL == p_Serial_Id_Func) + { + /*- 无处理 */ + isSendExtendBoard = ENUM_CM_CC; + } + else + { + /*- 判断该数据是否是发送给串口扩展板 */ + isSendExtendBoard = (*p_Serial_Id_Func)(dstID); + } + + if((ENUM_CM_FALSE == isTransformOutFrame)||/*无后备通道,发给通控或者串口板*/ + (ENUM_CM_CCSEB == isSendExtendBoard))/*主、备通道,发给通控*/ + { + /*- 填写通信数据 */ + (void)CM_Memcpy((void*)(s_Prtcl_UDP_Cache + 17u), (CM_SIZE_T)(sizeof(s_Prtcl_UDP_Cache) - 17u), (void*)(buf + i + 7u), (CM_SIZE_T)appLen); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /* CRC */ + crc = CM_Crc32(s_Prtcl_UDP_Cache, appLen + 17u);//总长度为17 = 头+长度 + CM_LongToChar(crc, s_Prtcl_UDP_Cache + appLen + 17u); + + ccLen = (CM_INT32)CM_UNSIGNED_SHORT_EXP(appLen + (CM_UINT16)21u);/*发给CC的UDP报文长度*/ + /*- 如果是发送给串口扩展板 */ + if (ENUM_CM_SEB == isSendExtendBoard) + { + /*- 向红网SE发送SE外网帧 */ + (void)CFM_OutnetSafe_Send(s_Prtcl_UDP_Cache, ccLen, ENUM_OUTNET_EXTEND_RED); + /*- 向红网SE发送SE外网帧 */ + (void)CFM_OutnetSafe_Send(s_Prtcl_UDP_Cache, ccLen, ENUM_OUTNET_EXTEND_BLUE); + } + else if((ENUM_CM_CC == isSendExtendBoard) || (ENUM_CM_CCSEB == isSendExtendBoard)) + { + /*- 向红网CC发送CC外网帧 */ + (void)CFM_OutnetSafe_Send(s_Prtcl_UDP_Cache, ccLen, ENUM_OUTNET_RED); + /*- 向蓝网CC发送CC外网帧 */ + (void)CFM_OutnetSafe_Send(s_Prtcl_UDP_Cache, ccLen, ENUM_OUTNET_BLUE); + } + else + { + /*无处理*/ + } + } + else + { + /*无处理*/ + } + /*- 如果是ats转车输出数据 */ + if(ENUM_CM_TRUE == isTransformOutFrame)/*后备通道,发给串口板*/ + { + /*- 按照ats转车输出数据帧格式进行组包 */ + CM_ShortToChar((CM_UINT16)(appLen + 33u), s_Prtcl_UDP_Cache); /* 长度 不包含自身2字节,但包含CRC */ + CM_ShortToChar(eTrueDstID, s_Prtcl_UDP_Cache + 11u); /* 目的设备ID */ + CM_ShortToChar(0u, s_Prtcl_UDP_Cache + 13u); /* 逻辑ID */ + eAtsOutLen = appLen + 12u; + CM_ShortToChar(eAtsOutLen, s_Prtcl_UDP_Cache + 17u); /* ats解析数据包长度 */ + CM_LongToChar(sysCount, s_Prtcl_UDP_Cache + 19u); /* 周期号,ats用来去冗余 */ + CM_ShortToChar(eTrueSrcID, s_Prtcl_UDP_Cache + 23u); /* 两字节真实源设备ID */ + CM_ShortToChar(0, s_Prtcl_UDP_Cache + 25u); /* 两字节0 */ + CM_ShortToChar(dstID, s_Prtcl_UDP_Cache + 27u); /* 两字节目的设备ID */ + CM_ShortToChar(logicID, s_Prtcl_UDP_Cache + 29u); /* 两字节目的逻辑id*/ + /*- 填写通信数据 */ + (void)CM_Memcpy((void*)(s_Prtcl_UDP_Cache + 31u), (CM_SIZE_T)(sizeof(s_Prtcl_UDP_Cache) - 31u), (void*)(buf + i + 7u), (CM_SIZE_T)appLen); /* parasoft-suppress MISRA2004-17_1 "指针运算提高代码执行效率" */ + /* CRC */ + crc = CM_Crc32(s_Prtcl_UDP_Cache, appLen + 31u); + CM_LongToChar(crc, s_Prtcl_UDP_Cache + appLen + 31u); + ccLen = (CM_INT32)CM_UNSIGNED_SHORT_EXP(appLen + (CM_UINT16)35u);/*发给CC/SEB的UDP报文长度*/ + /*- 如果是发送给串口扩展板 */ + if ((ENUM_CM_SEB == isSendExtendBoard) || (ENUM_CM_CCSEB == isSendExtendBoard)) + { + /*- 向红网SE发送SE外网帧 */ + (void)CFM_OutnetSafe_Send(s_Prtcl_UDP_Cache, ccLen, ENUM_OUTNET_EXTEND_RED); + /*- 向红网SE发送SE外网帧 */ + (void)CFM_OutnetSafe_Send(s_Prtcl_UDP_Cache, ccLen, ENUM_OUTNET_EXTEND_BLUE); + } + else + { + /*无处理*/ + } + } + else + { + /*- 无处理 */ + } + + /*- 索引偏移至下一输出报文 */ + i += (CM_UINT32)CM_UNSIGNED_SHORT_EXP(msgLen + 2u); + } +} + +void SFM_PrtclBufSwitch(void) +{ + /*- 变量初始化 */ + CM_UINT32 len = 0u; + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT8 rslt = 0u; + + /*- 是否开启外网安全通信 */ + if (0x55u == g_PFM_Cfg.M_OutnetSafe_Enable) + { + /*- 读取应用外网发送缓冲 */ + len = CM_QueueStatus(&s_Outnet_AppSendQ); + /*- 应用外网发送缓冲是否非空 */ + if (len > 0u) + { + /*- 从应用外网发送缓冲区读出数据,写入协议应用发送队列 */ + ret = CM_QueueRead(len, s_TmpCache, &s_Outnet_AppSendQ); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_1); + rslt = QueueWrite(len, s_TmpCache, &s_OutnetPrtcl.OutputDataQueue); + CM_RE_ASSERT(1u == rslt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_2); + } + else + { + /*- 无处理*/ + } + + /*- 清空应用外网发送缓冲区 */ + (void)CM_QueueClear(&s_Outnet_AppSendQ); + + /*- 清空应用外网接收缓冲区 */ + (void)CM_QueueClear(&s_Outnet_AppRecvQ); + + /*- 查询协议层外网接收队列 */ + len = QueueStatus(&s_OutnetPrtcl.DataToApp); + /*- 是否有应用接收数据 */ + if (len > 0u) + { + /*- 从协议层应用接收队列读出数据,写入应用接收缓冲区*/ + rslt = QueueRead(len, s_TmpCache, &s_OutnetPrtcl.DataToApp); + CM_RE_ASSERT(1u == rslt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_3); + ret = CM_QueueWrite(len, s_TmpCache, &s_Outnet_AppRecvQ); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_4); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } + + /*- 是否开启内网安全通信 */ + if (0x55u == g_PFM_Cfg.M_InnetSafe_Enable) + { + /*- 读取应用内网发送缓冲 */ + len = CM_QueueStatus(&s_Innet_AppSendQ); + /*- 应用内网发送缓冲是否非空 */ + if (len > 0u) + { + /*- 从应用发送缓冲区读出数据,写入协议应用发送队列 */ + ret = CM_QueueRead(len, s_TmpCache, &s_Innet_AppSendQ); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_5); + rslt = QueueWrite(len, s_TmpCache, &s_InnetPrtcl.OutputDataQueue); + CM_RE_ASSERT(1u == rslt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_6); + } + else + { + /*- 无处理*/ + } + + /*- 清空应用内网发送缓冲区 */ + (void)CM_QueueClear(&s_Innet_AppSendQ); + + /*- 清空应用内网接收缓冲区 */ + (void)CM_QueueClear(&s_Innet_AppRecvQ); + + /*- 查询协议层内网接收队列 */ + len = QueueStatus(&s_InnetPrtcl.DataToApp); + /*- 是否有应用接收数据 */ + if (len > 0u) + { + /*- 从协议层应用接收队列读出数据,写入应用接收缓冲区*/ + rslt = QueueRead(len, s_TmpCache, &s_InnetPrtcl.DataToApp); + CM_RE_ASSERT(1u == rslt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_7); + ret = CM_QueueWrite(len, s_TmpCache, &s_Innet_AppRecvQ); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_8); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } + + /*- 是否开启远程部署内网安全通信 */ + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /*- 读取远程部署内网发送缓冲 */ + len = CM_QueueStatus(&s_Innet_RmSendQ); + /*- 应用内网发送缓冲是否非空 */ + if (len > 0u) + { + /*- 从应用发送缓冲区读出数据,写入协议应用发送队列 */ + ret = CM_QueueRead(len, s_TmpCache, &s_Innet_RmSendQ); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_9); + MSCP_LOG_MSG("SFM_PrtclBufSwitch : %d\n",len); + rslt = QueueWrite(len, s_TmpCache, &s_InnetPrtcl_RM.OutputDataQueue); + + len = QueueStatus(&s_InnetPrtcl_RM.OutputDataQueue); + MSCP_LOG_MSG("&s_InnetPrtcl_RM.OutputDataQueue len = %d\n",len); + + CM_RE_ASSERT(1u == rslt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_10); + } + else + { + /*- 无处理*/ + } + + /*- 清空远程部署内网发送缓冲区 */ + (void)CM_QueueClear(&s_Innet_RmSendQ); + + /*- 清空远程部署内网发送缓冲区 */ + (void)CM_QueueClear(&s_Innet_AppRmSendQ); + + /*- 清空远程部署内网接收缓冲区 */ + (void)CM_QueueClear(&s_Innet_RmRecvQ); + + /*- 查询协议层内网接收队列 */ + len = QueueStatus(&s_InnetPrtcl_RM.DataToApp); + MSCP_LOG_MSG("&s_InnetPrtcl_RM.DataToApp len = %d\n",len); + /*- 是否远程部署内网接收数据 */ + if (len > 0u) + { + /*- 从协议层应用接收队列读出数据,写入远程部署内网接收缓冲区*/ + rslt = QueueRead(len, s_TmpCache, &s_InnetPrtcl_RM.DataToApp); + CM_RE_ASSERT(1u == rslt, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_11); + ret = CM_QueueWrite(len, s_TmpCache, &s_Innet_RmRecvQ); + CM_RE_ASSERT(ENUM_CM_TRUE == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_14, TSCP_DARK_ASSERT_12); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } +} + +/** +* @brief 获取适配层协议(-1)跟随数据 +* @param Buf 输出跟随数据数组指针 +* @param BufSize 输出数组空间大小 +* @return 输出跟随数据长度 +*/ +CM_UINT32 SFM_GetPrtclFollowData(OUT CM_UINT8* Buf, IN CM_UINT32 BufSize) +{ + /*- 获取协议跟随数据长度 */ + CM_UINT32 len = (CM_UINT32)CM_ShortFromChar(s_OutnetPrtcl.VarArray); + /*- 输出跟随数据 */ + CM_RE_ASSERT((BufSize >= 2u) && (len <= (BufSize - 2u)), PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_15, TSCP_DARK_ASSERT_1); + (void)CM_Memcpy((void*)Buf, (CM_SIZE_T)BufSize, (void*)s_OutnetPrtcl.VarArray, (CM_SIZE_T)CM_UNSIGNED_INT_EXP(len + 2u)); + + /*- 返回数据长度 */ + return len + 2u; +} + +/** +* @brief 获取sfp跟随数据 +* @param Buf 输出跟随数据数组指针 +* @param BufSize 输出数组空间大小 +* @return 输出跟随数据长度 +*/ +CM_UINT32 SFM_GetSfpPrtclFollowData(OUT CM_UINT8* Buf, IN CM_UINT32 BufSize) +{ + /*- 入参防空 */ + CM_ASSERT(NULL != Buf, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_22, TSCP_DARK_ASSERT_2); + /*- 获取协议跟随数据长度 */ + CM_UINT32 sfpTotalLen = CM_LongFromChar(&s_InnetPrtcl.PrtclSndBuff[0]); + CM_UINT32 sfpDataLen = CM_LongFromChar(&s_InnetPrtcl.PrtclSndBuff[4]); + CM_UINT32 sfpOffset = 4 + 4 + sfpDataLen; + CM_UINT32 sfpLinkLen = sfpTotalLen - sfpDataLen - 4; + + /*- 输出跟随数据 */ + CM_RE_ASSERT(sfpLinkLen <= BufSize - 4, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_22, TSCP_DARK_ASSERT_1); + + CM_LongToChar(sfpLinkLen, &Buf[0]); + (void)CM_Memcpy((void*)&Buf[4], (CM_SIZE_T)BufSize, (void*)(s_InnetPrtcl.PrtclSndBuff+sfpOffset), (CM_SIZE_T)sfpLinkLen); + + /*- 返回数据长度 */ + return sfpLinkLen + 4u; +} + +/** +* @brief 设置适配层协议(-1)跟随数据 +* @param Buf 跟随数据指针 取值范围:非空 +*/ +void SFM_SetPrtclFollowData(IN CM_UINT8* Buf) +{ + CM_UINT8 ret = 0u; + /*- 入参防空 */ + CM_ASSERT(NULL != Buf, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_16, TSCP_DARK_ASSERT_2); + /*- 设置跟随数据 */ + ret = ProtclReFreshFunc(Buf, &s_OutnetPrtcl); + CM_RE_ASSERT(1u == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_16, TSCP_DARK_ASSERT_1); +} + +/** +* @brief 设置sfp跟随数据 +* @param Len 跟随数据长度 取值范围:0~0xffffffff +* @param Buf 跟随数据指针 取值范围:非空 +*/ +void SFM_SetSfpPrtclFollowData(IN CM_UINT32 Len, IN CM_UINT8* Buf) +{ + CM_UINT8 ret = 0u; + /*- 入参防空 */ + CM_ASSERT(NULL != Buf, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_23, TSCP_DARK_ASSERT_2); + /*- 设置跟随数据 */ + ret = ProtclFreshLnkMngr(Len, Buf, &s_InnetPrtcl); + CM_RE_ASSERT(1u == ret, PRTCL_MODE, DARK_FAULT_CODE_FUN_ORDER_23, TSCP_DARK_ASSERT_1); +} + +/** +* @brief 断开指定的外网安全通信链接 +* @param devID 设备ID +* @param logicID 逻辑ID +* @return 执行结果 +* - 1 成功 +* - 0 失败 +*/ +CM_UINT8 SFM_OutnetDisconnect(IN CM_UINT16 devID, IN CM_UINT16 logicID) +{ + CM_UINT8 type = (CM_UINT8)(devID / 256u); + CM_UINT8 id = (CM_UINT8)(devID % 256u); + CM_UINT8 ret = 0u; + ret = ProtclDeleteLnkFunc(type, id, logicID, &s_OutnetPrtcl); + return ret; +} + +/** +* @brief -1安全协议日志打印 +*/ +void SFM_LogOutPrtcl(void) +{ + /*- -1安全协议日志打印 */ + CM_UINT16 len = CM_ShortFromChar(s_OutnetPrtcl.RecordArray); + MSCP_LOG_MSG("-1 SFM_LogOutPrtcl RecordArray len= %d\n",len); + MSCP_LOG_BIN(s_OutnetPrtcl.RecordArray, len); +} + +/** +* @brief 内网安全协议日志打印 +*/ +void SFM_LogInPrtcl(void) +{ + CM_UINT16 len = CM_ShortFromChar(s_InnetPrtcl.RecordArray); + MSCP_LOG_MSG("SFM_LogInPrtcl RecordArray len= %d\n",len); + MSCP_LOG_BIN(s_InnetPrtcl.RecordArray, len); +} + +/** +* @brief 远程内网安全协议日志打印 +*/ +void SFM_LogRmInPrtcl(void) +{ + CM_UINT16 len = CM_ShortFromChar(s_InnetPrtcl_RM.RecordArray); + MSCP_LOG_MSG("RM sfp SFM_LogInPrtcl RecordArray len= %d\n",len); + MSCP_LOG_BIN(s_InnetPrtcl_RM.RecordArray, len); +} + + +/** +* @brief 维护模式协议层解析收到的数据(无宕机函数) +*/ +void SFM_UnPrtclProc_Crash(void) +{ + CM_UINT8 ret = 0; + /*- @alias 内网安全通信协议解析 */ + if ((0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + g_PFM_Check = PFM_CFC_PROC_NUM + 6; + CM_UINT32 QueuelenA = QueueStatus(&s_InnetPrtcl_RM.OutnetQueueA); + CM_UINT32 QueuelenB = QueueStatus(&s_InnetPrtcl_RM.OutnetQueueB); + MSCP_LOG_MSG("QueuelenA = %d, QueuelenB = %d\n",QueuelenA,QueuelenB); + g_PFM_Check = PFM_CFC_PROC_NUM + 7; + (void)QueueClear(&s_InnetPrtcl_RM.DataToApp); + s_InnetPrtcl_RM.RadamSN = SFM_2x2_GetSysCount(); + ret = ProtclReceive(&s_InnetPrtcl_RM); + MSCP_LOG_MSG("ProtclReceive ret = %d\n",ret); + (void)QueueClear(&s_InnetPrtcl_RM.OutnetQueueA); + (void)QueueClear(&s_InnetPrtcl_RM.OutnetQueueB); + g_PFM_Check = PFM_CFC_PROC_NUM + 8; + CM_UINT32 QueuelenDataToApp = QueueStatus(&s_InnetPrtcl_RM.DataToApp); + MSCP_LOG_MSG("s_InnetPrtcl.DataToApp = %d\n",QueuelenDataToApp); + + MSCP_LOG_MSG("s_InnetPrtcl.LocalType = %d, s_InnetPrtcl.LocalID = %d\n",s_InnetPrtcl.LocalType,s_InnetPrtcl.LocalID); + + } + else + { + /*- 无处理*/ + } + /*- 过了sfp协议数据写入应用队列 */ + SFM_PrtclBufToApp_InnetSafeCrash(); +} + +/** +* @brief 维护模式协议层封装待发送数据(无宕机函数) +*/ +void SFM_EnPrtclProc_Crash(void) +{ + /*- 变量初始化 */ + CM_UINT16 local_len = 0u; + CM_UINT8 local_buf[1500u] = {0u}; + CM_UINT16 peer_len = 0u; + CM_UINT8 p_peer_buf[1500u] = {0u}; + /*- 应用将sfp协议数据写到协议队列 */ + SFM_AppToPrtclBuf_InnetSafeCrash(); + + /*- 内网安全协议封装 */ + if ((0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + MSCP_LOG_MSG("SFM_EnPrtclProc_Crash Queuelen1 = %d\n",QueueStatus(&s_InnetPrtcl_RM.OutputDataQueue)); + CM_LongToChar(0u, s_InnetPrtcl_RM.PrtclSndBuff); + CM_LongToChar(0u, s_InnetPrtcl_RM.RecordArray); + (void)ProtclOutput(&s_InnetPrtcl_RM); + (void)QueueClear(&s_InnetPrtcl_RM.OutputDataQueue); + MSCP_LOG_MSG("SFM_ReadInnetCodedOutputCrash len = %d, s_InnetPrtcl.LocalType = %d, s_InnetPrtcl.LocalID = %d\n",CM_LongFromChar(s_InnetPrtcl_RM.PrtclSndBuff),s_InnetPrtcl.LocalType,s_InnetPrtcl.LocalID); + /*- 是否开启2oo2功能 */ + if (0x55u == g_PFM_Cfg.M_2oo2_Enable) + { + /*- 双CPU交换SVC */ + (void)SfpGetSwapData(local_buf,1500u,&s_InnetPrtcl_RM); + local_len = 2u + CM_ShortFromChar(local_buf); + CM_ASSERT_MAINTAIN(local_len <= sizeof(local_buf)); + peer_len = (CM_UINT16)SFM_2oo2_Exchange_FullDuplex_Crash(local_buf, (CM_INT32)local_len, p_peer_buf, sizeof(p_peer_buf), ENUM_2oo2_SHUTDOWNQUIT); + (void)SfpSetSwapData(p_peer_buf,&s_InnetPrtcl_RM); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } +} + +/** +* @brief 维护模式下sfp协议数据写入应用队列(无宕机函数) +*/ +void SFM_PrtclBufToApp_InnetSafeCrash(void) +{ + /*- 变量初始化 */ + CM_UINT32 len = 0u; + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT8 rslt = 0u; + /*- 是否开启内网安全通信 */ + if ((0x55u == g_RMUP_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /*- 清空应用内网接收缓冲区 */ + (void)CM_QueueClear(&s_Innet_RmRecvQ); + + /*- 查询协议层内网接收队列 */ + len = QueueStatus(&s_InnetPrtcl_RM.DataToApp); + MSCP_LOG_MSG("SFM_PrtclBufToApp_InnetSafeCrash len = %d\n",len); + /*- 是否有应用接收数据 */ + if (len > 0u) + { + /*- 从协议层应用接收队列读出数据,写入应用接收缓冲区*/ + rslt = QueueRead(len, s_TmpCache, &s_InnetPrtcl_RM.DataToApp); + CM_ASSERT_MAINTAIN(1u == rslt); + ret = CM_QueueWrite(len, s_TmpCache, &s_Innet_RmRecvQ); + CM_ASSERT_MAINTAIN(ENUM_CM_TRUE == ret); + } + else + { + /*- 无处理*/ + } + } + else + { + /*- 无处理*/ + } +} +/** +* @brief 维护模式下应用将sfp协议数据写到协议队列(无宕机函数) +*/ +void SFM_AppToPrtclBuf_InnetSafeCrash(void) +{ + /*- 变量初始化 */ + CM_UINT32 len = 0u; + ENUM_CM_RETURN ret = ENUM_CM_FALSE; + CM_UINT8 rslt = 0u; + CM_UINT32 Queuelen = 0u; + /*- 是否开启内网安全通信 */ + if ((0x55u == g_PFM_Cfg.M_RemoteUpdate_Enable) &&(0x00u != g_Maintenance_Id)) + { + /*- 读取应用内网发送缓冲 */ + len = CM_QueueStatus(&s_Innet_RmSendQ); + MSCP_LOG_MSG("SFM_AppToPrtclBuf_InnetSafeCrash len1 = %d\n",len); + /*- 应用内网发送缓冲是否非空 */ + if (len > 0u) + { + /*- 从应用发送缓冲区读出数据,写入协议应用发送队列 */ + ret = CM_QueueRead(len, s_TmpCache, &s_Innet_RmSendQ); + CM_ASSERT_MAINTAIN(ENUM_CM_TRUE == ret); + MSCP_LOG_MSG("SFM_AppToPrtclBuf_InnetSafeCrash len2 = %d\n",len); + rslt = QueueWrite(len, s_TmpCache, &s_InnetPrtcl_RM.OutputDataQueue); + Queuelen = QueueStatus(&s_InnetPrtcl_RM.OutputDataQueue); + MSCP_LOG_MSG("Queuelen = %d\n",Queuelen); +#if 0 + for(int i = 0 ; i < len; i++) + { + (void)printf("0x%0.2x ",s_TmpCache[i]); + } + (void)printf("\n"); +#endif + CM_ASSERT_MAINTAIN(1u == rslt); + } + else + { + /*- 无处理*/ + } + + /*- 清空应用内网发送缓冲区 */ + (void)CM_QueueClear(&s_Innet_RmSendQ); + } + else + { + /*- 无处理*/ + } +} + + +/** +* @brief 去重-1协议数据 +* @param data1 去重队列a 取值范围:非空 +* @param data1Len 队列a长度 取值范围:0~0xffffffff +* @param data2 去重队列b 取值范围:非空 +* @param data2Len 队列b长度 取值范围:0~0xffffffff +* @return 执行结果 +* - 1 成功 +* - 0 失败 +* @details 将两个数组传入其中,每个数组的格式需要为总长度 红网数据长度 红网数据 篮网数据长度 篮网数据 +* 之后相同数据会将b数组中的数据去掉,保留a的数据. +*/ +CM_UINT8 SFM_OutProtclTwoRepeat(INOUT CM_UINT8* data1, IN CM_UINT32 data1Len,INOUT CM_UINT8* data2,INOUT CM_UINT32* data2Len) +{ + /*- 变量初始化 */ + CM_UINT8 TempBuf[1024 * 300] = {0}; + CM_UINT8 ret = 0; + /*- 如果入参不为空 */ + if((NULL != data1) && (NULL != data2) && (NULL != data2Len)) + { + MSCP_LOG_MSG("before data1Len = %d\n", data1Len); + MSCP_LOG_MSG("before data2Len = %d\n\n", *data2Len); + + /*- 去重-1协议数据 */ + ret = ProtclTwoRepeat(&s_OutnetPrtcl, data1, data1Len, data2, data2Len, TempBuf, 1024 * 300); + MSCP_LOG_MSG("after data1Len = %d\n", data1Len); + MSCP_LOG_MSG("after data2Len = %d\n\n", *data2Len); + + /*- 如果去重失败 */ + if(1 != ret) + { + /*- 将队列数据发送至维护机 */ + MSCP_LOG_MSG("SFM_OutProtclTwoRepeat error ret = %d\n",ret); + MSCP_LOG_DATALEN(data1,data1Len,"data1"); + MSCP_LOG_DATALEN(data2,*data2Len,"data2"); + } + else + { + /*- 无处理 */ + } + } + else + { + /*- 无处理 */ + ret = 0; + MSCP_LOG_MSG("SFM_OutProtclTwoRepeat param is NULL\n"); + } + + /*- 返回结果 */ + return ret; +} + + +/** +* @brief 查询链路状态 +* @param destType 对方设备类型 取值范围:0~0xff +* @param destId 对方设备ID 取值范围:0~0xff +* @param logId 逻辑id(若卡斯柯的CI与VOBC通信,需要填写VOBC的站台号。其他的系统填0。) 取值范围:0~0xff +* @return 安全通道链路状态 +* 0:不存在该条链路,返回错误 +* 0x17:链路在数据传输正常状态 +* 0x2b:链路在通信中断状态 +* 0x33:链路在准备建立链接状态 +* 0x4e:链路在等待建立链接状态 +* 0x01: 表示刷新无用的链路 +*/ +CM_UINT8 SFM_GetLnkStatus(CM_UINT8 destType,CM_UINT8 destId,CM_UINT16 logId) +{ + /*- 获取安全通道链路状态 */ + return ProtclGetLnkStatus(destType, destId, logId, &s_OutnetPrtcl); +} +/** +* @brief 设置外网数据的帧序号 +* @param sn 需要设置的序号:0~0xffff +* @return 无 +*/ +void SFM_SetTxSn(CM_UINT32 sn) +{ + s_txSn = sn; +} +/** +* @brief 获取外网数据发送序列号 +* @param 无 +* @return 获取到的外网数据序列号 +*/ +CM_UINT32 SFM_GetTxSn(void) +{ + /*- 变量初始化*/ + CM_UINT32 tmpsn = 0u; + /*-翻转防护*/ + (s_txSn == (CM_UINT32_MAX-1u))?(s_txSn = 1u):s_txSn; /* 预计跑149天会翻转一次,需要防护 */ + /*- 返回值赋值*/ + tmpsn = s_txSn; + /*- 更新sn号*/ + s_txSn++; + /*- 返回sn号*/ + return tmpsn; +} + diff --git a/TSCP/src/MSCP/SFM/SFM_Prtcl.h b/TSCP/src/MSCP/SFM/SFM_Prtcl.h new file mode 100644 index 0000000..58a2f6e --- /dev/null +++ b/TSCP/src/MSCP/SFM/SFM_Prtcl.h @@ -0,0 +1,221 @@ +/** +* @file SFM_Prtcl.c +* @brief Safe Function Module: 安全协议处理 +* @details +* 从通信层获取输入数据交给平台层交换、比较 +* 从平台层获取输入数据交给协议层解析 +* 从协议层获取输入数据交给应用层使用 +* 从应用层获取输出数据交给协议层封装 +* 从协议层获取输出数据交给平台层比较 +* 从平台层获取输出数交给通信层发送 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef SFM_PRTCL_H +#define SFM_PRTCL_H +#include "CM_Types.h" +#include "CFM_Net.h" +#include "MSCP_APP_Interface.h" +#ifdef __cplusplus +extern "C" +{ +#endif + +#define SFM_INNETSAFE_BUFF_SIZE (1024u*640u*2u) /* 内网安全通信通道UDP缓冲区大小 640k*2,应用许用量为500k */ +#define SFM_OUTNETSAFE_BUFF_SIZE (1024u*1024u*10u) /* 外网安全通信通道UDP缓冲区大小 512k*20,应用许用量为500k */ +#define SFM_COM485_RECV_SIZE (1024u*10u*10u) /*接收485串口通道空间*/ +#define SFM_INNETSAFE_RM_BUFF_SIZE (1024u*10u) /* 远程部署内网安全通信通道UDP缓冲区大小 10k */ + +#if SFM_OUTNETSAFE_BUFF_SIZE > SFM_INNETSAFE_BUFF_SIZE +#define SFM_TMP_CACHE_SIZE SFM_OUTNETSAFE_BUFF_SIZE +#else +#define SFM_TMP_CACHE_SIZE SFM_INNETSAFE_BUFF_SIZE +#endif + + /** 内网通道类型 */ + typedef enum + { + ENUM_INNET_ERROR = 0, /**< 保留 */ + ENUM_INNET_GREEN = 1, /**< 绿网 */ + ENUM_INNET_PURPLE = 2 /**< 紫网 */ + }ENUM_INNET_CHN_T; + + + /* 外网安全协议初始化(-1) */ + void SFM_PrtclOutInit(void); + /* 内网安全协议初始化(sfp) */ + void SFM_PrtclInInit(CM_UINT8* p_SfpInnetPara); + /* 获取协议适配层跟随数据 */ + CM_UINT32 SFM_GetPrtclFollowData(OUT CM_UINT8 *Buf, IN CM_UINT32 BufSize); + /* 设置协议适配层跟随数据 */ + void SFM_SetPrtclFollowData(IN CM_UINT8 *Buf); + + /*以下周期调用API按调用顺序描述:*/ + /* 缓冲区切换 */ + void SFM_PrtclBufSwitch(void); + + /* + * 1.从通信层获取原始输入数据并打包成协议帧 + */ + + /*从CFM接收通信数据,打包成协议内网帧*/ + CM_INT32 SFM_RxInnetSafe(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize); + /*从CFM接收通信数据,打包成协议外网帧*/ + CM_INT32 SFM_RxOutnetSafe(OUT CM_UINT8 buf[], IN CM_UINT32 bufSize); + + /* + * 2.进行2oo2交换和2x2交换 + */ + /*(在平台层PFM处理)*/ + + /* + * 3.将所有输入数据写入协议层 + */ + /*把协议内网帧格式的数据写入协议层*/ + void SFM_WriteInnetSafeInput(IN const CM_UINT8 buf[], IN CM_UINT32 len, IN ENUM_INNET_CHN_T ch); + + /*把协议外网帧格式的数据写入协议层*/ + void SFM_WriteOutnetSafeInput(IN const CM_UINT8 buf[], IN CM_UINT32 len, IN ENUM_OUTNET_CHN_T ch); + + /* + * 4.协议层解析收到的数据 + */ + /* 协议适配层接收处理 */ + void SFM_UnPrtclProc(void); + + /* + * 5.从协议层读取解析后的应用输入数据(交给应用) + */ + /* 应用收到的外网协议数据 */ + CM_UINT32 Prtcl_OutnetSafe_AppRecv(OUT CM_UINT16 *pSrcName, OUT CM_UINT16 *pSrcLogicID, OUT CM_UINT8 *pLifeTime, + OUT CM_UINT8 *rxBuf, IN CM_UINT32 rxSize); + /* 应用收到的内网协议数据 */ + CM_UINT32 Prtcl_InnetSafe_AppRecv(OUT CM_UINT16 *pSrcName, OUT CM_UINT8 *pLifeTime, OUT CM_UINT8 *rxBuf, IN CM_UINT32 rxSize); + + /* + * 6.执行应用周期逻辑 + */ + /*(在逻辑层处理)*/ + + /* + * 7.将应用输出写入协议层 + */ + /* 应用发送的外网协议数据 */ + CM_UINT8 Prtcl_OutnetSafe_AppSend(IN CM_UINT16 dstName, IN CM_UINT16 dstLogicID, IN const CM_UINT8 *txBuf, IN CM_UINT32 txLen); + /*应用发送的内网协议数据 */ + CM_UINT8 Prtcl_InnetSafe_AppSend(IN CM_UINT16 dstName, IN const CM_UINT8 *txBuf, IN CM_UINT32 txLen); + + /* + * 8.协议层封装待发送数据 + */ + /* 协议适配层发送处理 */ + void SFM_EnPrtclProc(void); + + /* + * 9.从协议层读取封装后的协议输出数据 + */ + /* 读取协议内网输出报文 */ + CM_UINT32 SFM_ReadInnetCodedOutput(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize); + /* 读取协议外网输出报文 */ + CM_UINT32 SFM_ReadOutnetCodedOutput(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize); + + /* + * 10.进行2oo2比较和2x2校验 + */ + /*(在平台层处理)*/ + + /* + * 11.交给通信层发送 + */ + /* 将内网输出报文交给CFM发送 */ + void SFM_TxInnetSafe(IN CM_UINT8 Buf[], IN CM_UINT32 Len); + /* 将外网输出报文交给CFM发送 */ + void SFM_TxOutnetSafe(IN CM_UINT8 buf[], IN CM_UINT32 Len); + + /* 断开外网安全链接 */ + CM_UINT8 SFM_OutnetDisconnect(IN CM_UINT16 devID, IN CM_UINT16 logicID); + /* -1安全协议日志打印 */ + void SFM_LogOutPrtcl(void); + + /* 内网安全协议日志打印 */ + void SFM_LogInPrtcl(void); + /* 维护模式协议层解析收到的数据(无宕机函数) */ + void SFM_UnPrtclProc_Crash(void); + + /* 维护模式协议层封装待发送数据(无宕机函数) */ + void SFM_EnPrtclProc_Crash(void); + + /* 维护模式下sfp协议数据写入应用队列(无宕机函数) */ + void SFM_PrtclBufToApp_InnetSafeCrash(void); + + /* 维护模式下应用将sfp协议数据写到协议队列(无宕机函数) */ + void SFM_AppToPrtclBuf_InnetSafeCrash(void); + + /* 维护模式下应用将sfp协议数据写到协议队列(无宕机函数) */ + void SFM_AppToPrtclBuf_InnetSafeCrash(void); + + /* 内网远程部署安全数据接收 */ + CM_INT32 SFM_RxInnetRemoteUpdate(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize); + + /* 从协议适配层读取协议内网输出帧 */ + CM_UINT32 SFM_ReadInnetCodedOutputCrash(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize); + + /* 发送内网远程部署安全通信数据 */ + void SFM_TxInnetSafeRemoteUpdate(IN CM_UINT8 Buf[], IN CM_UINT32 Len); + + CM_UINT8 Prtcl_InnetSafe_AppRmSend(IN const CM_UINT8* txBuf, IN CM_UINT32 txLen); + + CM_UINT32 Prtcl_InnetSafe_RmRecv(OUT CM_UINT16* pSrcName, OUT CM_UINT8* pLifeTime, OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize); + + CM_UINT32 Prtcl_InnetSafe_PlatRmRecv(OUT CM_UINT16* pSrcName, OUT CM_UINT8* pLifeTime, OUT CM_UINT8* rxBuf, IN CM_UINT32 rxSize); + + CM_UINT32 SFM_ReadInnetRmCodedOutput(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize); + + CM_INT32 SFM_RxInnetSafeRm(OUT CM_UINT8 Buf[], IN CM_UINT32 BufSize); + + void SFM_WriteInnetSafeRmInput(IN const CM_UINT8 buf[], IN CM_UINT32 len, IN ENUM_INNET_CHN_T ch); + + CM_UINT8 Prtcl_InnetSafe_RmSend(IN CM_UINT16 dstName, IN const CM_UINT8* txBuf, IN CM_UINT32 txLen); + + void SFM_TxInnetSafeRm(IN CM_UINT8 Buf[], IN CM_UINT32 Len); + + /* 去重-1协议数据 */ + CM_UINT8 SFM_OutProtclTwoRepeat(INOUT CM_UINT8* data1, IN CM_UINT32 data1Len,INOUT CM_UINT8* data2,INOUT CM_UINT32* data2Len); + + /** + * @brief 获取安全通道链路状态 + * @return 安全通道链路状态 + */ + CM_UINT8 SFM_GetLnkStatus(CM_UINT8 destType,CM_UINT8 destId,CM_UINT16 logId); + + /** + * @brief 远程内网安全协议日志打印 + */ + void SFM_LogRmInPrtcl(void); + CM_UINT32 SFM_GetSfpPrtclFollowData(OUT CM_UINT8* Buf, IN CM_UINT32 BufSize); + void SFM_SetSfpPrtclFollowData(IN CM_UINT32 Len, IN CM_UINT8* Buf); + + /** + * @brief 设置外网数据的帧序号 + * @param sn 需要设置的序号:0~0xffff + * @return 无 + */ + void SFM_SetTxSn(CM_UINT32 sn); + /** + * @brief 获取外网数据发送序列号 + * @param 无 + * @return 获取到的外网数据序列号 + */ + CM_UINT32 SFM_GetTxSn(void); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/MSCP/SFM/SFM_package.c b/TSCP/src/MSCP/SFM/SFM_package.c new file mode 100644 index 0000000..b89746c --- /dev/null +++ b/TSCP/src/MSCP/SFM/SFM_package.c @@ -0,0 +1,264 @@ +/** +* @file SFM_package.c +* @brief Safe Function Module:分帧协议实现 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#include "SFM_package.h" +#include "CM_Memory.h" +#include "PFM_Log.h" +#include "DFM_Time.h" +/** +* @brief 分帧接收 +* @param pCtrl 控制结构体 +* @param type 帧类型 +* @param FrameNum 帧数目 +* @param FrameIndex 帧序号 +* @param pFrameData 分帧数据报文指针 +* @param FrameDataLen 分帧数据报文长度 +* @param pRxBuf 接收缓冲区指针 +* @param pRxLen 接收报文总长度 +* @param RxSize 接收缓冲区大小 +* @return 处理结果 +* - ENUM_CM_FALSE 处理出错 +* - ENUM_CM_TRUE 处理完成(收齐完整报文) +* - ENUM_CM_NULL 处理中(接收有效,但尚未收齐完整报文) +* @details 收齐完整报文后才会置位接收报文总长度,否则为0 +*/ +ENUM_CM_RETURN SFM_FrameSave(INOUT STRU_FrameCtrl_T *pCtrl, IN CM_UINT8 type, + IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen, + INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + /*- 指针防空 */ + CM_ASSERT((NULL != pRxBuf) && (NULL != pFrameData) && (NULL != pCtrl), PACKAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_1); + /*- 是否收到新报文 */ + if (1u == FrameIndex) + { + /*- 初始化控制结构体 */ + pCtrl->type = type; + pCtrl->FrameNum = FrameNum; + pCtrl->FramIndex = 0u; + pCtrl->RxLen = 0; + /*- 接收报文总长度置0 */ + *pRxLen = 0; + } + else + { + /*- 无处理 */ + } + /*- 检查收到的分帧帧头信息是否合法 */ + if ((type == pCtrl->type) + && (FrameNum == pCtrl->FrameNum) + && (FrameIndex == (pCtrl->FramIndex + 1u))) + { + /*- 收到的帧序号累加 */ + pCtrl->FramIndex++; + + /*- 保存本帧数据 */ + rt = CM_Memcpy((void*)(pRxBuf + pCtrl->RxLen), (CM_SIZE_T)CM_SIGNED_INT_EXP((CM_INT32)RxSize - pCtrl->RxLen), (const void*)pFrameData, (CM_SIZE_T)FrameDataLen); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + CM_RE_ASSERT(ENUM_CM_TRUE == rt, PACKAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_2); + pCtrl->RxLen += FrameDataLen; + + /*- 是否是最后一帧 */ + if (FrameIndex == FrameNum) + { + /*- 初始化控制结构体 */ + pCtrl->type = 0; + pCtrl->FrameNum = 0; + pCtrl->FramIndex = 0u; + /*- 输出报文总长度 */ + *pRxLen = pCtrl->RxLen; + /*- 返回值置ENUM_CM_TRUE */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 返回值置ENUM_CM_NULL */ + rt = ENUM_CM_NULL; + } + } + else + { + /*- 记录丢包次数与周期*/ + pCtrl->err_cut++; + pCtrl->err_cyc = g_MSCP_BirthCount; + MSCP_LOG_MSG("SFM_FrameSave error:\n type = %d, pCtrl->type = %d, FrameNum = %d, pCtrl->FrameNum = %d, FrameIndex = %d, pCtrl->FramIndex = %d\n",type,pCtrl->type,FrameNum,pCtrl->FrameNum,FrameIndex,pCtrl->FramIndex); + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_SFM_2OO2FRAME,8u, + sizeof(CM_UINT16),pCtrl->err_cut, + sizeof(CM_UINT32),pCtrl->err_cyc, + sizeof(CM_UINT8),type, + sizeof(CM_UINT8),pCtrl->type, + sizeof(CM_UINT16),FrameNum, + sizeof(CM_UINT16),pCtrl->FrameNum, + sizeof(CM_UINT16),FrameIndex, + sizeof(CM_UINT16),pCtrl->FramIndex); + } + /*- 输出返回值*/ + return rt; +} +/** +* @brief 2X分帧接收 +* @param pCtrl 控制结构体 +* @param type 帧类型 +* @param FrameNum 帧数目 +* @param FrameIndex 帧序号 +* @param pFrameData 分帧数据报文指针 +* @param FrameDataLen 分帧数据报文长度 +* @param pRxBuf 接收缓冲区指针 +* @param pRxLen 接收报文总长度 +* @param RxSize 接收缓冲区大小 +* @return 处理结果 +* - ENUM_CM_FALSE 处理出错 +* - ENUM_CM_TRUE 处理完成(收齐完整报文) +* - ENUM_CM_NULL 处理中(接收有效,但尚未收齐完整报文) +* @details 收齐完整报文后才会置位接收报文总长度,否则为0 +*/ +ENUM_CM_RETURN SFM_2X_FrameSave(INOUT STRU_FrameCtrl_T *pCtrl, IN CM_UINT8 type, + IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen, + INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + /*- 指针防空 */ + CM_ASSERT((NULL != pRxBuf) && (NULL != pFrameData) && (NULL != pCtrl), PACKAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1); + /*- 是否收到新报文 */ + if (1u == FrameIndex) + { + /*- 初始化控制结构体 */ + pCtrl->type = type; + pCtrl->FrameNum = FrameNum; + pCtrl->FramIndex = 0u; + pCtrl->RxLen = 0; + /*- 接收报文总长度置0 */ + *pRxLen = 0; + } + else + { + /*- 无处理 */ + } + /*- 检查收到的分帧帧头信息是否合法 */ + if ((type == pCtrl->type) + && (FrameNum == pCtrl->FrameNum) + && (FrameIndex == (pCtrl->FramIndex + 1u))) + { + /*- 收到的帧序号累加 */ + pCtrl->FramIndex++; + + /*- 保存本帧数据 */ + rt = CM_Memcpy((void*)(g_2x2oo2_Frame_TempBuf + pCtrl->RxLen), (CM_SIZE_T)CM_SIGNED_INT_EXP((CM_INT32)RxSize - pCtrl->RxLen), (const void*)pFrameData, (CM_SIZE_T)FrameDataLen); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + CM_RE_ASSERT(ENUM_CM_TRUE == rt, PACKAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2); + pCtrl->RxLen += FrameDataLen; + + /*- 是否是最后一帧 */ + if (FrameIndex == FrameNum) + { + /*- 输出报文总长度 */ + *pRxLen = pCtrl->RxLen; + rt = CM_Memcpy(pRxBuf,RxSize,g_2x2oo2_Frame_TempBuf,pCtrl->RxLen); + CM_RE_ASSERT(ENUM_CM_TRUE == rt, PACKAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_3); + /*- 返回值置ENUM_CM_TRUE */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 返回值置ENUM_CM_NULL */ + rt = ENUM_CM_NULL; + } + } + else + { + MSCP_LOG_MSG("SFM_2X_FrameSave error:\n type = %d, pCtrl->type = %d, FrameNum = %d, pCtrl->FrameNum = %d, FrameIndex = %d, pCtrl->FramIndex = %d\n",type,pCtrl->type,FrameNum,pCtrl->FrameNum,FrameIndex,pCtrl->FramIndex); + /*- 出错后复位接收控制 */ + pCtrl->type = 0u; + (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_SFM_2X2FRAME,6u, + sizeof(CM_UINT8),type, + sizeof(CM_UINT8),pCtrl->type, + sizeof(CM_UINT16),FrameNum, + sizeof(CM_UINT16),pCtrl->FrameNum, + sizeof(CM_UINT16),FrameIndex, + sizeof(CM_UINT16),pCtrl->FramIndex); + } + /*- 输出返回值*/ + return rt; +} +/** +* @brief 应用分帧接收 +* @param pCtrl 控制结构体 取值范围:非空 +* @param FrameNum 帧数目 取值范围:0~0xFFFF +* @param FrameIndex 帧序号 取值范围:0~0xFFFF +* @param pFrameData 分帧数据报文指针 取值范围:非空 +* @param FrameDataLen 分帧数据报文长度 取值范围:0~0x7FFFFFFFF +* @param pRxBuf 接收缓冲区指针 取值范围:非空 +* @param pRxLen 接收报文总长度 取值范围:非空 +* @param RxSize 接收缓冲区大小 取值范围:0~0xFFFFFFFFF +* @return 处理结果 +* - ENUM_CM_FALSE 处理出错 +* - ENUM_CM_TRUE 处理完成(收齐完整报文) +* - ENUM_CM_NULL 处理中(接收有效,但尚未收齐完整报文) +* @details 收齐完整报文后才会置位接收报文总长度,否则为0 +*/ +ENUM_CM_RETURN SFM_FrameSave_App(INOUT STRU_FrameCtrl_T *pCtrl, + IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen, + INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize) +{ + /*- 变量初始化 */ + ENUM_CM_RETURN rt = ENUM_CM_FALSE; /* 函数返回值 */ + /*- 指针防空 */ + CM_ASSERT((NULL != pRxBuf) && (NULL != pFrameData) && (NULL != pCtrl), PACKAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1); + /*- 是否收到新报文 */ + if (1u == FrameIndex) + { + /*- 初始化控制结构体 */ + pCtrl->FrameNum = FrameNum; + pCtrl->FramIndex = 0u; + pCtrl->RxLen = 0; + /*- 接收报文总长度置0 */ + *pRxLen = 0; + } + else + { + /*- 无处理 */ + } + /*- 检查收到的分帧帧头信息是否合法 */ + if ((FrameNum == pCtrl->FrameNum) + && (FrameIndex == (pCtrl->FramIndex + 1u))) + { + /*- 收到的帧序号累加 */ + pCtrl->FramIndex++; + + /*- 保存本帧数据 */ + rt = CM_Memcpy((void*)(pRxBuf + pCtrl->RxLen), (CM_SIZE_T)CM_SIGNED_INT_EXP((CM_INT32)RxSize - pCtrl->RxLen), (const void*)pFrameData, (CM_SIZE_T)FrameDataLen); /* parasoft-suppress MISRA2004-17_1 MISRA2004-17_4 "指针运算提高代码执行效率" */ + CM_ASSERT(ENUM_CM_TRUE == rt, PACKAGE_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2); + pCtrl->RxLen += FrameDataLen; + + /*- 是否是最后一帧 */ + if (FrameIndex == FrameNum) + { + /*- 输出报文总长度 */ + *pRxLen = pCtrl->RxLen; + /*- 返回值置ENUM_CM_TRUE */ + rt = ENUM_CM_TRUE; + } + else + { + /*- 返回值置ENUM_CM_NULL */ + rt = ENUM_CM_NULL; + } + } + else + { + /*- 出错后复位接收控制 */ + pCtrl->type = 0u; + } + /*- 输出返回值*/ + return rt; +} diff --git a/TSCP/src/MSCP/SFM/SFM_package.h b/TSCP/src/MSCP/SFM/SFM_package.h new file mode 100644 index 0000000..7f8f32c --- /dev/null +++ b/TSCP/src/MSCP/SFM/SFM_package.h @@ -0,0 +1,47 @@ +/** +* @file SFM_package.h +* @brief Safe Function Module:分帧协议实现 +* @details +* 2x2上电初始化:初始化、上电同步、比较 +* 输入阶段和输出阶段的双机热备处理 +* @author GT-BU +* @date 2021.02.20 +* @version V1.0 +* @copyright TCT +* @par 修改日志 +* +*
Date Version Author Description +*
2021.02.01 V1.0 GT-BU 创建初始版本 +*
+*/ +#ifndef SFM_PACKAGE_H +#define SFM_PACKAGE_H +#include "CM_Types.h" +#include "SFM_Prtcl.h" + +/** 分帧接收控制 */ +typedef struct +{ + CM_UINT8 type; /**< 帧类型 */ + CM_UINT16 FrameNum; /**< 帧数目 */ + CM_UINT16 FramIndex; /**< 帧序号 */ + CM_INT32 RxLen; /**< 接收总长度 */ + CM_UINT16 err_cut; /** 丢包次数*/ + CM_UINT32 err_cyc; /** 丢包周期号*/ +}STRU_FrameCtrl_T; + +extern CM_UINT8 g_2x2oo2_Frame_TempBuf[SFM_OUTNETSAFE_BUFF_SIZE]; +/* 分帧接收 */ +ENUM_CM_RETURN SFM_FrameSave(INOUT STRU_FrameCtrl_T *pCtrl, IN CM_UINT8 type, + IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen, + INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize); +/* 2x分帧接收 */ +ENUM_CM_RETURN SFM_2X_FrameSave(INOUT STRU_FrameCtrl_T *pCtrl, IN CM_UINT8 type, + IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen, + INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize); +/* 应用分帧接收 */ +ENUM_CM_RETURN SFM_FrameSave_App(INOUT STRU_FrameCtrl_T *pCtrl, + IN CM_UINT16 FrameNum, IN CM_UINT16 FrameIndex, IN const CM_UINT8 *pFrameData, IN CM_INT32 FrameDataLen, + INOUT CM_UINT8 *pRxBuf, OUT CM_INT32 *pRxLen, IN CM_UINT32 RxSize); + +#endif diff --git a/TSCP/src/MSCP_CFG/MSCP_Cfg.h b/TSCP/src/MSCP_CFG/MSCP_Cfg.h new file mode 100644 index 0000000..2052f0f --- /dev/null +++ b/TSCP/src/MSCP_CFG/MSCP_Cfg.h @@ -0,0 +1,16 @@ +/* + * MSCP_Cfg.h + * + * Created on: 2021年9月16日 + * Author: + */ + +#pragma once + +//#ifndef SRC_MSCP_CFG_H_ +//#define SRC_MSCP_CFG_H_ + +/*此文件各个应用自己配置*/ +//#define _AIRFORAIL_ /* 艾弗瑞雷达用功能开关 */ + +//#endif /* SRC_MSCP_MSCP_CFG_H_ */ diff --git a/TSCP/src/commoncode/common/CRC16.c b/TSCP/src/commoncode/common/CRC16.c new file mode 100644 index 0000000..cf62826 --- /dev/null +++ b/TSCP/src/commoncode/common/CRC16.c @@ -0,0 +1,136 @@ + +/******************************************************** +* +* ļ CRC16.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2008.07.29 +* ؼЭ鲿 +* òеķٵļһݵ16λCRCУ +* POLY0x1021----ʹõɶʽ +* ޸ļ¼ +* +********************************************************/ + +#include "CRC16.h" + + +/* +* CRC16ע⣺CRCǴݵһֽڵBITʼ + õĶʽ0x1021ʼֵΪ0x0000,δ񣬽ϵΪ0x0000. + DataLen=0ֵҲΪ0. +* ˵ pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵΪCRCֵ;0ڲΪ +*/ + +UINT16 Crc16(const UINT8 *pData,UINT32 DataLen) +{ + UINT32 i = 0u; + UINT16 Crc = 0u; + + const static UINT16 CrcTable16[256u] = { + + 0x0u,0x1021u,0x2042u,0x3063u,0x4084u,0x50a5u, + + 0x60c6u,0x70e7u,0x8108u,0x9129u,0xa14au,0xb16bu, + + 0xc18cu,0xd1adu,0xe1ceu,0xf1efu,0x1231u,0x210u, + + 0x3273u,0x2252u,0x52b5u,0x4294u,0x72f7u,0x62d6u, + + 0x9339u,0x8318u,0xb37bu,0xa35au,0xd3bdu,0xc39cu, + + 0xf3ffu,0xe3deu,0x2462u,0x3443u,0x420u,0x1401u, + + 0x64e6u,0x74c7u,0x44a4u,0x5485u,0xa56au,0xb54bu, + + 0x8528u,0x9509u,0xe5eeu,0xf5cfu,0xc5acu,0xd58du, + + 0x3653u,0x2672u,0x1611u,0x630u,0x76d7u,0x66f6u, + + 0x5695u,0x46b4u,0xb75bu,0xa77au,0x9719u,0x8738u, + + 0xf7dfu,0xe7feu,0xd79du,0xc7bcu,0x48c4u,0x58e5u, + + 0x6886u,0x78a7u,0x840u,0x1861u,0x2802u,0x3823u, + + 0xc9ccu,0xd9edu,0xe98eu,0xf9afu,0x8948u,0x9969u, + + 0xa90au,0xb92bu,0x5af5u,0x4ad4u,0x7ab7u,0x6a96u, + + 0x1a71u,0xa50u,0x3a33u,0x2a12u,0xdbfdu,0xcbdcu, + + 0xfbbfu,0xeb9eu,0x9b79u,0x8b58u,0xbb3bu,0xab1au, + + 0x6ca6u,0x7c87u,0x4ce4u,0x5cc5u,0x2c22u,0x3c03u, + + 0xc60u,0x1c41u,0xedaeu,0xfd8fu,0xcdecu,0xddcdu, + + 0xad2au,0xbd0bu,0x8d68u,0x9d49u,0x7e97u,0x6eb6u, + + 0x5ed5u,0x4ef4u,0x3e13u,0x2e32u,0x1e51u,0xe70u, + + 0xff9fu,0xefbeu,0xdfddu,0xcffcu,0xbf1bu,0xaf3au, + + 0x9f59u,0x8f78u,0x9188u,0x81a9u,0xb1cau,0xa1ebu, + + 0xd10cu,0xc12du,0xf14eu,0xe16fu,0x1080u,0xa1u, + + 0x30c2u,0x20e3u,0x5004u,0x4025u,0x7046u,0x6067u, + + 0x83b9u,0x9398u,0xa3fbu,0xb3dau,0xc33du,0xd31cu, + + 0xe37fu,0xf35eu,0x2b1u,0x1290u,0x22f3u,0x32d2u, + + 0x4235u,0x5214u,0x6277u,0x7256u,0xb5eau,0xa5cbu, + + 0x95a8u,0x8589u,0xf56eu,0xe54fu,0xd52cu,0xc50du, + + 0x34e2u,0x24c3u,0x14a0u,0x481u,0x7466u,0x6447u, + + 0x5424u,0x4405u,0xa7dbu,0xb7fau,0x8799u,0x97b8u, + + 0xe75fu,0xf77eu,0xc71du,0xd73cu,0x26d3u,0x36f2u, + + 0x691u,0x16b0u,0x6657u,0x7676u,0x4615u,0x5634u, + + 0xd94cu,0xc96du,0xf90eu,0xe92fu,0x99c8u,0x89e9u, + + 0xb98au,0xa9abu,0x5844u,0x4865u,0x7806u,0x6827u, + + 0x18c0u,0x8e1u,0x3882u,0x28a3u,0xcb7du,0xdb5cu, + + 0xeb3fu,0xfb1eu,0x8bf9u,0x9bd8u,0xabbbu,0xbb9au, + + 0x4a75u,0x5a54u,0x6a37u,0x7a16u,0xaf1u,0x1ad0u, + + 0x2ab3u,0x3a92u,0xfd2eu,0xed0fu,0xdd6cu,0xcd4du, + + 0xbdaau,0xad8bu,0x9de8u,0x8dc9u,0x7c26u,0x6c07u, + + 0x5c64u,0x4c45u,0x3ca2u,0x2c83u,0x1ce0u,0xcc1u, + + 0xef1fu,0xff3eu,0xcf5du,0xdf7cu,0xaf9bu,0xbfbau, + + 0x8fd9u,0x9ff8u,0x6e17u,0x7e36u,0x4e55u,0x5e74u, + + 0x2e93u,0x3eb2u,0xed1u,0x1ef0u }; + + if (NULL == pData) + { + ; /*ڲΪ*/ + } + else + { + while (i < DataLen) + { + /*Crc8λCrc<<8ʵCrcǰŲһֽڣһֽ0 + Crc8λCrc>>8ʵֻȡCrcֽھͿˡ*/ + Crc = (UINT16)(Crc << 8u) ^ CrcTable16[(Crc >> 8u) ^ pData[i]]; + i++; + } + } + + return Crc; +} diff --git a/TSCP/src/commoncode/common/CRC16.h b/TSCP/src/commoncode/common/CRC16.h new file mode 100644 index 0000000..b84c28d --- /dev/null +++ b/TSCP/src/commoncode/common/CRC16.h @@ -0,0 +1,41 @@ + +/************************************************************************ +* +* ļ CRC16.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.08.21 +* ؼЭ鲿 +* CRC16У +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _CRC16_H_ +#define _CRC16_H_ + + + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +* CRC16ע⣺CRCǴݵһֽڵBITʼ +* ˵ +* pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵΪCRCֵ +*/ + +UINT16 Crc16(const UINT8 *pData,UINT32 DataLen); + +#ifdef __cplusplus +} +#endif + +#else +#endif diff --git a/TSCP/src/commoncode/common/CRC32.c b/TSCP/src/commoncode/common/CRC32.c new file mode 100644 index 0000000..42ca4ac --- /dev/null +++ b/TSCP/src/commoncode/common/CRC32.c @@ -0,0 +1,394 @@ + +/******************************************************** +* +* ļ CRC32.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2008.07.29 +* ؼЭ鲿 +* 32λCRC +* ޸ļ¼ +* +********************************************************/ + +#include "CRC32.h" + +/*CRC32ұcopy from RSSP(RsspCommon.c) by lmy 20170416*/ +const UINT32 CrcmTab[2][256u] = { +{ + 0x00000000u, 0x1942B361u, 0x328566C2u, 0x2BC7D5A3u, 0x650ACD84u, 0x7C487EE5u, 0x578FAB46u, 0x4ECD1827u, + 0xCA159B08u, 0xD3572869u, 0xF890FDCAu, 0xE1D24EABu, 0xAF1F568Cu, 0xB65DE5EDu, 0x9D9A304Eu, 0x84D8832Fu, + 0x18CE5601u, 0x018CE560u, 0x2A4B30C3u, 0x330983A2u, 0x7DC49B85u, 0x648628E4u, 0x4F41FD47u, 0x56034E26u, + 0xD2DBCD09u, 0xCB997E68u, 0xE05EABCBu, 0xF91C18AAu, 0xB7D1008Du, 0xAE93B3ECu, 0x8554664Fu, 0x9C16D52Eu, + 0x319CAC02u, 0x28DE1F63u, 0x0319CAC0u, 0x1A5B79A1u, 0x54966186u, 0x4DD4D2E7u, 0x66130744u, 0x7F51B425u, + 0xFB89370Au, 0xE2CB846Bu, 0xC90C51C8u, 0xD04EE2A9u, 0x9E83FA8Eu, 0x87C149EFu, 0xAC069C4Cu, 0xB5442F2Du, + 0x2952FA03u, 0x30104962u, 0x1BD79CC1u, 0x02952FA0u, 0x4C583787u, 0x551A84E6u, 0x7EDD5145u, 0x679FE224u, + 0xE347610Bu, 0xFA05D26Au, 0xD1C207C9u, 0xC880B4A8u, 0x864DAC8Fu, 0x9F0F1FEEu, 0xB4C8CA4Du, 0xAD8A792Cu, + 0x63395804u, 0x7A7BEB65u, 0x51BC3EC6u, 0x48FE8DA7u, 0x06339580u, 0x1F7126E1u, 0x34B6F342u, 0x2DF44023u, + 0xA92CC30Cu, 0xB06E706Du, 0x9BA9A5CEu, 0x82EB16AFu, 0xCC260E88u, 0xD564BDE9u, 0xFEA3684Au, 0xE7E1DB2Bu, + 0x7BF70E05u, 0x62B5BD64u, 0x497268C7u, 0x5030DBA6u, 0x1EFDC381u, 0x07BF70E0u, 0x2C78A543u, 0x353A1622u, + 0xB1E2950Du, 0xA8A0266Cu, 0x8367F3CFu, 0x9A2540AEu, 0xD4E85889u, 0xCDAAEBE8u, 0xE66D3E4Bu, 0xFF2F8D2Au, + 0x52A5F406u, 0x4BE74767u, 0x602092C4u, 0x796221A5u, 0x37AF3982u, 0x2EED8AE3u, 0x052A5F40u, 0x1C68EC21u, + 0x98B06F0Eu, 0x81F2DC6Fu, 0xAA3509CCu, 0xB377BAADu, 0xFDBAA28Au, 0xE4F811EBu, 0xCF3FC448u, 0xD67D7729u, + 0x4A6BA207u, 0x53291166u, 0x78EEC4C5u, 0x61AC77A4u, 0x2F616F83u, 0x3623DCE2u, 0x1DE40941u, 0x04A6BA20u, + 0x807E390Fu, 0x993C8A6Eu, 0xB2FB5FCDu, 0xABB9ECACu, 0xE574F48Bu, 0xFC3647EAu, 0xD7F19249u, 0xCEB32128u, + 0xC672B008u, 0xDF300369u, 0xF4F7D6CAu, 0xEDB565ABu, 0xA3787D8Cu, 0xBA3ACEEDu, 0x91FD1B4Eu, 0x88BFA82Fu, + 0x0C672B00u, 0x15259861u, 0x3EE24DC2u, 0x27A0FEA3u, 0x696DE684u, 0x702F55E5u, 0x5BE88046u, 0x42AA3327u, + 0xDEBCE609u, 0xC7FE5568u, 0xEC3980CBu, 0xF57B33AAu, 0xBBB62B8Du, 0xA2F498ECu, 0x89334D4Fu, 0x9071FE2Eu, + 0x14A97D01u, 0x0DEBCE60u, 0x262C1BC3u, 0x3F6EA8A2u, 0x71A3B085u, 0x68E103E4u, 0x4326D647u, 0x5A646526u, + 0xF7EE1C0Au, 0xEEACAF6Bu, 0xC56B7AC8u, 0xDC29C9A9u, 0x92E4D18Eu, 0x8BA662EFu, 0xA061B74Cu, 0xB923042Du, + 0x3DFB8702u, 0x24B93463u, 0x0F7EE1C0u, 0x163C52A1u, 0x58F14A86u, 0x41B3F9E7u, 0x6A742C44u, 0x73369F25u, + 0xEF204A0Bu, 0xF662F96Au, 0xDDA52CC9u, 0xC4E79FA8u, 0x8A2A878Fu, 0x936834EEu, 0xB8AFE14Du, 0xA1ED522Cu, + 0x2535D103u, 0x3C776262u, 0x17B0B7C1u, 0x0EF204A0u, 0x403F1C87u, 0x597DAFE6u, 0x72BA7A45u, 0x6BF8C924u, + 0xA54BE80Cu, 0xBC095B6Du, 0x97CE8ECEu, 0x8E8C3DAFu, 0xC0412588u, 0xD90396E9u, 0xF2C4434Au, 0xEB86F02Bu, + 0x6F5E7304u, 0x761CC065u, 0x5DDB15C6u, 0x4499A6A7u, 0x0A54BE80u, 0x13160DE1u, 0x38D1D842u, 0x21936B23u, + 0xBD85BE0Du, 0xA4C70D6Cu, 0x8F00D8CFu, 0x96426BAEu, 0xD88F7389u, 0xC1CDC0E8u, 0xEA0A154Bu, 0xF348A62Au, + 0x77902505u, 0x6ED29664u, 0x451543C7u, 0x5C57F0A6u, 0x129AE881u, 0x0BD85BE0u, 0x201F8E43u, 0x395D3D22u, + 0x94D7440Eu, 0x8D95F76Fu, 0xA65222CCu, 0xBF1091ADu, 0xF1DD898Au, 0xE89F3AEBu, 0xC358EF48u, 0xDA1A5C29u, + 0x5EC2DF06u, 0x47806C67u, 0x6C47B9C4u, 0x75050AA5u, 0x3BC81282u, 0x228AA1E3u, 0x094D7440u, 0x100FC721u, + 0x8C19120Fu, 0x955BA16Eu, 0xBE9C74CDu, 0xA7DEC7ACu, 0xE913DF8Bu, 0xF0516CEAu, 0xDB96B949u, 0xC2D40A28u, + 0x460C8907u, 0x5F4E3A66u, 0x7489EFC5u, 0x6DCB5CA4u, 0x23064483u, 0x3A44F7E2u, 0x11832241u, 0x08C19120u}, +{ + 0x00000000u, 0x1EF09C7Eu, 0x3DE138FCu, 0x2311A482u, 0x7BC271F8u, 0x6532ED86u, 0x46234904u, 0x58D3D57Au, + 0xF784E3F0u, 0xE9747F8Eu, 0xCA65DB0Cu, 0xD4954772u, 0x8C469208u, 0x92B60E76u, 0xB1A7AAF4u, 0xAF57368Au, + 0xFF048983u, 0xE1F415FDu, 0xC2E5B17Fu, 0xDC152D01u, 0x84C6F87Bu, 0x9A366405u, 0xB927C087u, 0xA7D75CF9u, + 0x08806A73u, 0x1670F60Du, 0x3561528Fu, 0x2B91CEF1u, 0x73421B8Bu, 0x6DB287F5u, 0x4EA32377u, 0x5053BF09u, + 0xEE045D65u, 0xF0F4C11Bu, 0xD3E56599u, 0xCD15F9E7u, 0x95C62C9Du, 0x8B36B0E3u, 0xA8271461u, 0xB6D7881Fu, + 0x1980BE95u, 0x077022EBu, 0x24618669u, 0x3A911A17u, 0x6242CF6Du, 0x7CB25313u, 0x5FA3F791u, 0x41536BEFu, + 0x1100D4E6u, 0x0FF04898u, 0x2CE1EC1Au, 0x32117064u, 0x6AC2A51Eu, 0x74323960u, 0x57239DE2u, 0x49D3019Cu, + 0xE6843716u, 0xF874AB68u, 0xDB650FEAu, 0xC5959394u, 0x9D4646EEu, 0x83B6DA90u, 0xA0A77E12u, 0xBE57E26Cu, + 0xCC05F4A9u, 0xD2F568D7u, 0xF1E4CC55u, 0xEF14502Bu, 0xB7C78551u, 0xA937192Fu, 0x8A26BDADu, 0x94D621D3u, + 0x3B811759u, 0x25718B27u, 0x06602FA5u, 0x1890B3DBu, 0x404366A1u, 0x5EB3FADFu, 0x7DA25E5Du, 0x6352C223u, + 0x33017D2Au, 0x2DF1E154u, 0x0EE045D6u, 0x1010D9A8u, 0x48C30CD2u, 0x563390ACu, 0x7522342Eu, 0x6BD2A850u, + 0xC4859EDAu, 0xDA7502A4u, 0xF964A626u, 0xE7943A58u, 0xBF47EF22u, 0xA1B7735Cu, 0x82A6D7DEu, 0x9C564BA0u, + 0x2201A9CCu, 0x3CF135B2u, 0x1FE09130u, 0x01100D4Eu, 0x59C3D834u, 0x4733444Au, 0x6422E0C8u, 0x7AD27CB6u, + 0xD5854A3Cu, 0xCB75D642u, 0xE86472C0u, 0xF694EEBEu, 0xAE473BC4u, 0xB0B7A7BAu, 0x93A60338u, 0x8D569F46u, + 0xDD05204Fu, 0xC3F5BC31u, 0xE0E418B3u, 0xFE1484CDu, 0xA6C751B7u, 0xB837CDC9u, 0x9B26694Bu, 0x85D6F535u, + 0x2A81C3BFu, 0x34715FC1u, 0x1760FB43u, 0x0990673Du, 0x5143B247u, 0x4FB32E39u, 0x6CA28ABBu, 0x725216C5u, + 0x8806A731u, 0x96F63B4Fu, 0xB5E79FCDu, 0xAB1703B3u, 0xF3C4D6C9u, 0xED344AB7u, 0xCE25EE35u, 0xD0D5724Bu, + 0x7F8244C1u, 0x6172D8BFu, 0x42637C3Du, 0x5C93E043u, 0x04403539u, 0x1AB0A947u, 0x39A10DC5u, 0x275191BBu, + 0x77022EB2u, 0x69F2B2CCu, 0x4AE3164Eu, 0x54138A30u, 0x0CC05F4Au, 0x1230C334u, 0x312167B6u, 0x2FD1FBC8u, + 0x8086CD42u, 0x9E76513Cu, 0xBD67F5BEu, 0xA39769C0u, 0xFB44BCBAu, 0xE5B420C4u, 0xC6A58446u, 0xD8551838u, + 0x6602FA54u, 0x78F2662Au, 0x5BE3C2A8u, 0x45135ED6u, 0x1DC08BACu, 0x033017D2u, 0x2021B350u, 0x3ED12F2Eu, + 0x918619A4u, 0x8F7685DAu, 0xAC672158u, 0xB297BD26u, 0xEA44685Cu, 0xF4B4F422u, 0xD7A550A0u, 0xC955CCDEu, + 0x990673D7u, 0x87F6EFA9u, 0xA4E74B2Bu, 0xBA17D755u, 0xE2C4022Fu, 0xFC349E51u, 0xDF253AD3u, 0xC1D5A6ADu, + 0x6E829027u, 0x70720C59u, 0x5363A8DBu, 0x4D9334A5u, 0x1540E1DFu, 0x0BB07DA1u, 0x28A1D923u, 0x3651455Du, + 0x44035398u, 0x5AF3CFE6u, 0x79E26B64u, 0x6712F71Au, 0x3FC12260u, 0x2131BE1Eu, 0x02201A9Cu, 0x1CD086E2u, + 0xB387B068u, 0xAD772C16u, 0x8E668894u, 0x909614EAu, 0xC845C190u, 0xD6B55DEEu, 0xF5A4F96Cu, 0xEB546512u, + 0xBB07DA1Bu, 0xA5F74665u, 0x86E6E2E7u, 0x98167E99u, 0xC0C5ABE3u, 0xDE35379Du, 0xFD24931Fu, 0xE3D40F61u, + 0x4C8339EBu, 0x5273A595u, 0x71620117u, 0x6F929D69u, 0x37414813u, 0x29B1D46Du, 0x0AA070EFu, 0x1450EC91u, + 0xAA070EFDu, 0xB4F79283u, 0x97E63601u, 0x8916AA7Fu, 0xD1C57F05u, 0xCF35E37Bu, 0xEC2447F9u, 0xF2D4DB87u, + 0x5D83ED0Du, 0x43737173u, 0x6062D5F1u, 0x7E92498Fu, 0x26419CF5u, 0x38B1008Bu, 0x1BA0A409u, 0x05503877u, + 0x5503877Eu, 0x4BF31B00u, 0x68E2BF82u, 0x761223FCu, 0x2EC1F686u, 0x30316AF8u, 0x1320CE7Au, 0x0DD05204u, + 0xA287648Eu, 0xBC77F8F0u, 0x9F665C72u, 0x8196C00Cu, 0xD9451576u, 0xC7B58908u, 0xE4A42D8Au, 0xFA54B1F4u } +}; + +/*תcopy from RSSP(RsspCommon.c) by lmy 20170416*/ +const UINT8 Reflected_Byte[256u] = { + 0x00u, 0x80u, 0x40u, 0xC0u, 0x20u, 0xA0u, 0x60u, 0xE0u, + 0x10u, 0x90u, 0x50u, 0xD0u, 0x30u, 0xB0u, 0x70u, 0xF0u, + 0x08u, 0x88u, 0x48u, 0xC8u, 0x28u, 0xA8u, 0x68u, 0xE8u, + 0x18u, 0x98u, 0x58u, 0xD8u, 0x38u, 0xB8u, 0x78u, 0xF8u, + 0x04u, 0x84u, 0x44u, 0xC4u, 0x24u, 0xA4u, 0x64u, 0xE4u, + 0x14u, 0x94u, 0x54u, 0xD4u, 0x34u, 0xB4u, 0x74u, 0xF4u, + 0x0Cu, 0x8Cu, 0x4Cu, 0xCCu, 0x2Cu, 0xACu, 0x6Cu, 0xECu, + 0x1Cu, 0x9Cu, 0x5Cu, 0xDCu, 0x3Cu, 0xBCu, 0x7Cu, 0xFCu, + 0x02u, 0x82u, 0x42u, 0xC2u, 0x22u, 0xA2u, 0x62u, 0xE2u, + 0x12u, 0x92u, 0x52u, 0xD2u, 0x32u, 0xB2u, 0x72u, 0xF2u, + 0x0Au, 0x8Au, 0x4Au, 0xCAu, 0x2Au, 0xAAu, 0x6Au, 0xEAu, + 0x1Au, 0x9Au, 0x5Au, 0xDAu, 0x3Au, 0xBAu, 0x7Au, 0xFAu, + 0x06u, 0x86u, 0x46u, 0xC6u, 0x26u, 0xA6u, 0x66u, 0xE6u, + 0x16u, 0x96u, 0x56u, 0xD6u, 0x36u, 0xB6u, 0x76u, 0xF6u, + 0x0Eu, 0x8Eu, 0x4Eu, 0xCEu, 0x2Eu, 0xAEu, 0x6Eu, 0xEEu, + 0x1Eu, 0x9Eu, 0x5Eu, 0xDEu, 0x3Eu, 0xBEu, 0x7Eu, 0xFEu, + 0x01u, 0x81u, 0x41u, 0xC1u, 0x21u, 0xA1u, 0x61u, 0xE1u, + 0x11u, 0x91u, 0x51u, 0xD1u, 0x31u, 0xB1u, 0x71u, 0xF1u, + 0x09u, 0x89u, 0x49u, 0xC9u, 0x29u, 0xA9u, 0x69u, 0xE9u, + 0x19u, 0x99u, 0x59u, 0xD9u, 0x39u, 0xB9u, 0x79u, 0xF9u, + 0x05u, 0x85u, 0x45u, 0xC5u, 0x25u, 0xA5u, 0x65u, 0xE5u, + 0x15u, 0x95u, 0x55u, 0xD5u, 0x35u, 0xB5u, 0x75u, 0xF5u, + 0x0Du, 0x8Du, 0x4Du, 0xCDu, 0x2Du, 0xADu, 0x6Du, 0xEDu, + 0x1Du, 0x9Du, 0x5Du, 0xDDu, 0x3Du, 0xBDu, 0x7Du, 0xFDu, + 0x03u, 0x83u, 0x43u, 0xC3u, 0x23u, 0xA3u, 0x63u, 0xE3u, + 0x13u, 0x93u, 0x53u, 0xD3u, 0x33u, 0xB3u, 0x73u, 0xF3u, + 0x0Bu, 0x8Bu, 0x4Bu, 0xCBu, 0x2Bu, 0xABu, 0x6Bu, 0xEBu, + 0x1Bu, 0x9Bu, 0x5Bu, 0xDBu, 0x3Bu, 0xBBu, 0x7Bu, 0xFBu, + 0x07u, 0x87u, 0x47u, 0xC7u, 0x27u, 0xA7u, 0x67u, 0xE7u, + 0x17u, 0x97u, 0x57u, 0xD7u, 0x37u, 0xB7u, 0x77u, 0xF7u, + 0x0Fu, 0x8Fu, 0x4Fu, 0xCFu, 0x2Fu, 0xAFu, 0x6Fu, 0xEFu, + 0x1Fu, 0x9Fu, 0x5Fu, 0xDFu, 0x3Fu, 0xBFu, 0x7Fu, 0xFFu +}; + +/* +* CRC32£ע⣺CRCǴݵһֽڵBITʼ +* õĶʽ0x4c11db7LʼֵΪ0x00000000,δ񣬽ϵΪ0x00000000 +* DataLen=0ֵҲΪ0. +* ˵ pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵΪCRCֵ0ڲ +*/ +UINT32 Crc32(const UINT8 *pData,UINT32 DataLen) +{ + UINT32 Crc = 0u; + UINT32 i = 0u; + + + /*ɶʽ0x4c11db7L; */ + const static UINT32 CrcTable[256u] = { + 0x00000000u,0x04c11db7u,0x09823b6eu,0x0d4326d9u,0x130476dcu,0x17c56b6bu, + 0x1a864db2u,0x1e475005u,0x2608edb8u,0x22c9f00fu,0x2f8ad6d6u,0x2b4bcb61u, + 0x350c9b64u,0x31cd86d3u,0x3c8ea00au,0x384fbdbdu,0x4c11db70u,0x48d0c6c7u, + 0x4593e01eu,0x4152fda9u,0x5f15adacu,0x5bd4b01bu,0x569796c2u,0x52568b75u, + 0x6a1936c8u,0x6ed82b7fu,0x639b0da6u,0x675a1011u,0x791d4014u,0x7ddc5da3u, + 0x709f7b7au,0x745e66cdu,0x9823b6e0u,0x9ce2ab57u,0x91a18d8eu,0x95609039u, + 0x8b27c03cu,0x8fe6dd8bu,0x82a5fb52u,0x8664e6e5u,0xbe2b5b58u,0xbaea46efu, + 0xb7a96036u,0xb3687d81u,0xad2f2d84u,0xa9ee3033u,0xa4ad16eau,0xa06c0b5du, + 0xd4326d90u,0xd0f37027u,0xddb056feu,0xd9714b49u,0xc7361b4cu,0xc3f706fbu, + 0xceb42022u,0xca753d95u,0xf23a8028u,0xf6fb9d9fu,0xfbb8bb46u,0xff79a6f1u, + 0xe13ef6f4u,0xe5ffeb43u,0xe8bccd9au,0xec7dd02du,0x34867077u,0x30476dc0u, + 0x3d044b19u,0x39c556aeu,0x278206abu,0x23431b1cu,0x2e003dc5u,0x2ac12072u, + 0x128e9dcfu,0x164f8078u,0x1b0ca6a1u,0x1fcdbb16u,0x018aeb13u,0x054bf6a4u, + 0x0808d07du,0x0cc9cdcau,0x7897ab07u,0x7c56b6b0u,0x71159069u,0x75d48ddeu, + 0x6b93dddbu,0x6f52c06cu,0x6211e6b5u,0x66d0fb02u,0x5e9f46bfu,0x5a5e5b08u, + 0x571d7dd1u,0x53dc6066u,0x4d9b3063u,0x495a2dd4u,0x44190b0du,0x40d816bau, + 0xaca5c697u,0xa864db20u,0xa527fdf9u,0xa1e6e04eu,0xbfa1b04bu,0xbb60adfcu, + 0xb6238b25u,0xb2e29692u,0x8aad2b2fu,0x8e6c3698u,0x832f1041u,0x87ee0df6u, + 0x99a95df3u,0x9d684044u,0x902b669du,0x94ea7b2au,0xe0b41de7u,0xe4750050u, + 0xe9362689u,0xedf73b3eu,0xf3b06b3bu,0xf771768cu,0xfa325055u,0xfef34de2u, + 0xc6bcf05fu,0xc27dede8u,0xcf3ecb31u,0xcbffd686u,0xd5b88683u,0xd1799b34u, + 0xdc3abdedu,0xd8fba05au,0x690ce0eeu,0x6dcdfd59u,0x608edb80u,0x644fc637u, + 0x7a089632u,0x7ec98b85u,0x738aad5cu,0x774bb0ebu,0x4f040d56u,0x4bc510e1u, + 0x46863638u,0x42472b8fu,0x5c007b8au,0x58c1663du,0x558240e4u,0x51435d53u, + 0x251d3b9eu,0x21dc2629u,0x2c9f00f0u,0x285e1d47u,0x36194d42u,0x32d850f5u, + 0x3f9b762cu,0x3b5a6b9bu,0x0315d626u,0x07d4cb91u,0x0a97ed48u,0x0e56f0ffu, + 0x1011a0fau,0x14d0bd4du,0x19939b94u,0x1d528623u,0xf12f560eu,0xf5ee4bb9u, + 0xf8ad6d60u,0xfc6c70d7u,0xe22b20d2u,0xe6ea3d65u,0xeba91bbcu,0xef68060bu, + 0xd727bbb6u,0xd3e6a601u,0xdea580d8u,0xda649d6fu,0xc423cd6au,0xc0e2d0ddu, + 0xcda1f604u,0xc960ebb3u,0xbd3e8d7eu,0xb9ff90c9u,0xb4bcb610u,0xb07daba7u, + 0xae3afba2u,0xaafbe615u,0xa7b8c0ccu,0xa379dd7bu,0x9b3660c6u,0x9ff77d71u, + 0x92b45ba8u,0x9675461fu,0x8832161au,0x8cf30badu,0x81b02d74u,0x857130c3u, + 0x5d8a9099u,0x594b8d2eu,0x5408abf7u,0x50c9b640u,0x4e8ee645u,0x4a4ffbf2u, + 0x470cdd2bu,0x43cdc09cu,0x7b827d21u,0x7f436096u,0x7200464fu,0x76c15bf8u, + 0x68860bfdu,0x6c47164au,0x61043093u,0x65c52d24u,0x119b4be9u,0x155a565eu, + 0x18197087u,0x1cd86d30u,0x029f3d35u,0x065e2082u,0x0b1d065bu,0x0fdc1becu, + 0x3793a651u,0x3352bbe6u,0x3e119d3fu,0x3ad08088u,0x2497d08du,0x2056cd3au, + 0x2d15ebe3u,0x29d4f654u,0xc5a92679u,0xc1683bceu,0xcc2b1d17u,0xc8ea00a0u, + 0xd6ad50a5u,0xd26c4d12u,0xdf2f6bcbu,0xdbee767cu,0xe3a1cbc1u,0xe760d676u, + 0xea23f0afu,0xeee2ed18u,0xf0a5bd1du,0xf464a0aau,0xf9278673u,0xfde69bc4u, + 0x89b8fd09u,0x8d79e0beu,0x803ac667u,0x84fbdbd0u,0x9abc8bd5u,0x9e7d9662u, + 0x933eb0bbu,0x97ffad0cu,0xafb010b1u,0xab710d06u,0xa6322bdfu,0xa2f33668u, + 0xbcb4666du,0xb8757bdau,0xb5365d03u,0xb1f740b4u + }; + if (NULL == pData) + { + ; /*ڲ*/ + } + else + { + while (i < DataLen) + { + Crc = (Crc << 8u) ^ CrcTable[(Crc >> 24u) ^ pData[i]]; + i++; + } + } + + return Crc; +} +/* +* BigFileCrc32ȽϴļCRC +* ˵ pData, ָ +* DataLen, ݳȣֽڣ +* CrcNum УĴ +* CrcFlagУǷɱ־ +* *CrcCodeõCRC +* ֵ 0x55У;0xffδУ:0xaaУ +* ޸ʱ:2016-03-14 :S +*ϲ˵ɻͨ add by qxt 20161210 +*/ +UINT8 BigFileCrc32(const UINT8 *pData,UINT32 DataLen,UINT8 CrcNum,UINT32 *CrcCode) +{ + static UINT32 i = 0u; + static UINT32 SplitLength = 0u; + static UINT8 CalculateNum = 0u; + UINT8 CrcFlag = 0xffu; + UINT8 M = 0u; + + + + /*ɶʽ0x4c11db7L; */ + const static UINT32 CrcTable[256u] = { + 0x00000000u,0x04c11db7u,0x09823b6eu,0x0d4326d9u,0x130476dcu,0x17c56b6bu, + 0x1a864db2u,0x1e475005u,0x2608edb8u,0x22c9f00fu,0x2f8ad6d6u,0x2b4bcb61u, + 0x350c9b64u,0x31cd86d3u,0x3c8ea00au,0x384fbdbdu,0x4c11db70u,0x48d0c6c7u, + 0x4593e01eu,0x4152fda9u,0x5f15adacu,0x5bd4b01bu,0x569796c2u,0x52568b75u, + 0x6a1936c8u,0x6ed82b7fu,0x639b0da6u,0x675a1011u,0x791d4014u,0x7ddc5da3u, + 0x709f7b7au,0x745e66cdu,0x9823b6e0u,0x9ce2ab57u,0x91a18d8eu,0x95609039u, + 0x8b27c03cu,0x8fe6dd8bu,0x82a5fb52u,0x8664e6e5u,0xbe2b5b58u,0xbaea46efu, + 0xb7a96036u,0xb3687d81u,0xad2f2d84u,0xa9ee3033u,0xa4ad16eau,0xa06c0b5du, + 0xd4326d90u,0xd0f37027u,0xddb056feu,0xd9714b49u,0xc7361b4cu,0xc3f706fbu, + 0xceb42022u,0xca753d95u,0xf23a8028u,0xf6fb9d9fu,0xfbb8bb46u,0xff79a6f1u, + 0xe13ef6f4u,0xe5ffeb43u,0xe8bccd9au,0xec7dd02du,0x34867077u,0x30476dc0u, + 0x3d044b19u,0x39c556aeu,0x278206abu,0x23431b1cu,0x2e003dc5u,0x2ac12072u, + 0x128e9dcfu,0x164f8078u,0x1b0ca6a1u,0x1fcdbb16u,0x018aeb13u,0x054bf6a4u, + 0x0808d07du,0x0cc9cdcau,0x7897ab07u,0x7c56b6b0u,0x71159069u,0x75d48ddeu, + 0x6b93dddbu,0x6f52c06cu,0x6211e6b5u,0x66d0fb02u,0x5e9f46bfu,0x5a5e5b08u, + 0x571d7dd1u,0x53dc6066u,0x4d9b3063u,0x495a2dd4u,0x44190b0du,0x40d816bau, + 0xaca5c697u,0xa864db20u,0xa527fdf9u,0xa1e6e04eu,0xbfa1b04bu,0xbb60adfcu, + 0xb6238b25u,0xb2e29692u,0x8aad2b2fu,0x8e6c3698u,0x832f1041u,0x87ee0df6u, + 0x99a95df3u,0x9d684044u,0x902b669du,0x94ea7b2au,0xe0b41de7u,0xe4750050u, + 0xe9362689u,0xedf73b3eu,0xf3b06b3bu,0xf771768cu,0xfa325055u,0xfef34de2u, + 0xc6bcf05fu,0xc27dede8u,0xcf3ecb31u,0xcbffd686u,0xd5b88683u,0xd1799b34u, + 0xdc3abdedu,0xd8fba05au,0x690ce0eeu,0x6dcdfd59u,0x608edb80u,0x644fc637u, + 0x7a089632u,0x7ec98b85u,0x738aad5cu,0x774bb0ebu,0x4f040d56u,0x4bc510e1u, + 0x46863638u,0x42472b8fu,0x5c007b8au,0x58c1663du,0x558240e4u,0x51435d53u, + 0x251d3b9eu,0x21dc2629u,0x2c9f00f0u,0x285e1d47u,0x36194d42u,0x32d850f5u, + 0x3f9b762cu,0x3b5a6b9bu,0x0315d626u,0x07d4cb91u,0x0a97ed48u,0x0e56f0ffu, + 0x1011a0fau,0x14d0bd4du,0x19939b94u,0x1d528623u,0xf12f560eu,0xf5ee4bb9u, + 0xf8ad6d60u,0xfc6c70d7u,0xe22b20d2u,0xe6ea3d65u,0xeba91bbcu,0xef68060bu, + 0xd727bbb6u,0xd3e6a601u,0xdea580d8u,0xda649d6fu,0xc423cd6au,0xc0e2d0ddu, + 0xcda1f604u,0xc960ebb3u,0xbd3e8d7eu,0xb9ff90c9u,0xb4bcb610u,0xb07daba7u, + 0xae3afba2u,0xaafbe615u,0xa7b8c0ccu,0xa379dd7bu,0x9b3660c6u,0x9ff77d71u, + 0x92b45ba8u,0x9675461fu,0x8832161au,0x8cf30badu,0x81b02d74u,0x857130c3u, + 0x5d8a9099u,0x594b8d2eu,0x5408abf7u,0x50c9b640u,0x4e8ee645u,0x4a4ffbf2u, + 0x470cdd2bu,0x43cdc09cu,0x7b827d21u,0x7f436096u,0x7200464fu,0x76c15bf8u, + 0x68860bfdu,0x6c47164au,0x61043093u,0x65c52d24u,0x119b4be9u,0x155a565eu, + 0x18197087u,0x1cd86d30u,0x029f3d35u,0x065e2082u,0x0b1d065bu,0x0fdc1becu, + 0x3793a651u,0x3352bbe6u,0x3e119d3fu,0x3ad08088u,0x2497d08du,0x2056cd3au, + 0x2d15ebe3u,0x29d4f654u,0xc5a92679u,0xc1683bceu,0xcc2b1d17u,0xc8ea00a0u, + 0xd6ad50a5u,0xd26c4d12u,0xdf2f6bcbu,0xdbee767cu,0xe3a1cbc1u,0xe760d676u, + 0xea23f0afu,0xeee2ed18u,0xf0a5bd1du,0xf464a0aau,0xf9278673u,0xfde69bc4u, + 0x89b8fd09u,0x8d79e0beu,0x803ac667u,0x84fbdbd0u,0x9abc8bd5u,0x9e7d9662u, + 0x933eb0bbu,0x97ffad0cu,0xafb010b1u,0xab710d06u,0xa6322bdfu,0xa2f33668u, + 0xbcb4666du,0xb8757bdau,0xb5365d03u,0xb1f740b4u + }; + + if((0u != DataLen) && (0u != CrcNum) && (0xffu == CrcFlag) && (NULL != pData) && (NULL != CrcCode)) + { + /*㱾ļУݳ*/ + SplitLength = DataLen/CrcNum; + + if(CalculateNum>24u) ^ pData[i]] ; + i++; + } + /*ۼУ*/ + CalculateNum = CalculateNum+1u; + } + else + { + while( i < DataLen) + { + *CrcCode = (*CrcCode<<8u) ^ CrcTable[(*CrcCode>>24u) ^ pData[i]] ; + i++; + } + } + /*Уվ̬*/ + if(i == DataLen) + { + i = 0u; + SplitLength = 0u; + CalculateNum = 0u; + CrcFlag = 0x55u; + } + } + else + { + CrcFlag = 0xaau; + } + + return CrcFlag; +} + +/************************************************************* +* Crc32㺯ʹCRC32ұ1 +* ˵ +* pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵcrc32ResultΪCRCֵ +* ˵ Ϊƽ̨СͻϵͳİȫӸCRC㷨 +* add by lmy 20180411 +**************************************************************/ +UINT32 Crc32_1(const UINT8 *pData, UINT32 DataLen) +{ + UINT32 crc32Result = 0u; + + /*ڲ*/ + if ((NULL != pData) && (0u < DataLen)) + { + crc32Result = Crc32_common(pData, DataLen, CrcmTab[0u]);/*ʹCRC32ұCRCֵ*/ + } + else + { + /*ڲϷ*/ + crc32Result = 0u; + } + + return crc32Result; +} + +/************************************************************* +* Crc32ʹCRC32ұ2 +* ˵ +* pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵcrc32ResultΪCRCֵ +* ˵ Ϊƽ̨СͻϵͳİȫӸCRC㷨 +* add by lmy 20180411 +**************************************************************/ +UINT32 Crc32_2(const UINT8 *pData, UINT32 DataLen) +{ + UINT32 crc32Result = 0u; + + /*ڲ*/ + if ((NULL != pData) && (0u < DataLen)) + { + crc32Result = Crc32_common(pData, DataLen, CrcmTab[1u]);/*ʹCRC32ұCRCֵ*/ + } + else + { + /*ڲϷ*/ + crc32Result = 0u; + } + + return crc32Result; +} + +/************************************************************* +* Crc32㺯 +* ˵ +* pData, ָ +* DataLen, ݳȣֽڣ +* CRC32Table, CRC32ұ +* ֵ ֵcrc32ResultΪCRCֵ +* ˵ Ϊƽ̨СͻϵͳİȫӸCRC㷨, +* úRSSP-IЭе(RsspCommon.c)CRC_Compute_Crcͬ +* DzһҪע⡣ +* add by lmy 20180411 +**************************************************************/ +UINT32 Crc32_common(const UINT8 *pData, UINT32 DataLen, const UINT32 *CRC32Table) +{ + UINT32 index = 0u; + UINT32 crc32Result = 0u; + + /*ڲ*/ + if ((NULL != pData) && (0u < DataLen) && (NULL != CRC32Table)) + { + /*ӦIJұCRC*/ + for(index = 0u; index < DataLen; index++) + { + crc32Result = (crc32Result >> 8u) ^ CRC32Table[(crc32Result ^ Reflected_Byte[*pData]) & UINT8_MAX]; + pData++; + } + } + else + { + /*ڲϷ*/ + crc32Result = 0u; + } + + return crc32Result; +} \ No newline at end of file diff --git a/TSCP/src/commoncode/common/CRC32.h b/TSCP/src/commoncode/common/CRC32.h new file mode 100644 index 0000000..2103c8e --- /dev/null +++ b/TSCP/src/commoncode/common/CRC32.h @@ -0,0 +1,88 @@ + +/************************************************************************ +* +* ļ CRC32.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.08.21 +* ؼЭ鲿 +* 32λCRC +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _CRC32_H_ +#define _CRC32_H_ + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +/* +* CRC32£ע⣺CRCǴݵһֽڵBITʼ +* ˵ +* pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵΪCRCֵ +*/ +UINT32 Crc32(const UINT8 *pData,UINT32 DataLen); + +/* +* CRC32£ע⣺CRCǴݵһֽڵBITʼ +* õĶʽ0x4c11db7LʼֵΪ0x00000000,δ񣬽ϵΪ0x00000000 +* DataLen=0ֵҲΪ0. +* ˵ pData, ָ +* DataLen, ݳȣֽڣ +* UINT8 CrcNum УĴ +* ֵ ֵ +*ϲ˵ɻͨ add by qxt 20161210 +*/ +UINT8 BigFileCrc32(const UINT8 *pData,UINT32 DataLen,UINT8 CrcNum,UINT32 *CrcCode); + +/************************************************************* +* Crc32㺯ʹCRC32ұ1 +* ˵ +* pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵcrc32ResultΪCRCֵ +* ˵ Ϊƽ̨СͻϵͳİȫӸCRC㷨 +* add by lmy 20180411 +**************************************************************/ +UINT32 Crc32_1(const UINT8 *pData, UINT32 DataLen); + +/************************************************************* +* Crc32ʹCRC32ұ2 +* ˵ +* pData, ָ +* DataLen, ݳȣֽڣ +* ֵ ֵcrc32ResultΪCRCֵ +* ˵ Ϊƽ̨СͻϵͳİȫӸCRC㷨 +* add by lmy 20180411 +**************************************************************/ +UINT32 Crc32_2(const UINT8 *pData, UINT32 DataLen); + +/************************************************************* +* Crc32㺯 +* ˵ +* pData, ָ +* DataLen, ݳȣֽڣ +* CRC32Table, CRC32ұ +* ֵ ֵcrc32ResultΪCRCֵ +* ˵ Ϊƽ̨СͻϵͳİȫӸCRC㷨, +* úRSSP-IЭе(RsspCommon.c)CRC_Compute_Crcͬ +* DzһҪע⡣ +* add by lmy 20180411 +**************************************************************/ +UINT32 Crc32_common(const UINT8 *pData, UINT32 DataLen, const UINT32 *CRC32Table); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/commoncode/common/CbtcVersion.c b/TSCP/src/commoncode/common/CbtcVersion.c new file mode 100644 index 0000000..0b130a6 --- /dev/null +++ b/TSCP/src/commoncode/common/CbtcVersion.c @@ -0,0 +1,187 @@ +/******************************************************** +* +* ļ CbtcVersion.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2012.07.23 +* з +* 汾Ÿʽת +* ޸ļ¼ +* +********************************************************/ + +#include "CbtcVersion.h" + + +/* +* ˵ : ģ汾ת +* ˵ : UINT16 productNo,Ʒ +* UINT16 moduleNo,ģ +* UINT16 mainVer,汾 +* UINT16 subVerӰ汾 +* ֵ: U32ʾİ汾 +*/ +UINT32 VerToU32SoftwareModule(UINT16 productNo,UINT16 moduleNo,UINT16 mainVer,UINT16 subVer) +{ + UINT32 U32Version = 0u; /* ؽ */ + + U32Version = (UINT32)subVer & (0xFFu); + U32Version|= ((UINT32)mainVer & (0x3Fu))<<(8u); + U32Version|= ((UINT32)moduleNo & (0x3FFu))<<(14u); + U32Version|= ((UINT32)productNo & (0xFFu))<<(24u); + return U32Version; +} + +/* +* ˵ : ģ汾ת +* ˵ : UINT16 *pProductNo,Ʒ +* UINT16 *pModuleNo,ģ +* UINT16 *pMainVer,汾 +* UINT16 *pSubVerӰ汾 +* UINT32 u32VerU32ʾİ汾 +*޸ļ¼: +*1޸ɲȱQC-1811,ת,Baix,2020-04-13; +*/ +void VerFromU32SoftwareModule(UINT16 *pProductNo,UINT16 *pModuleNo,UINT16 *pMainVer,UINT16 *pSubVer,UINT32 u32Ver) +{ + if((NULL != pProductNo) && (NULL != pModuleNo) && (NULL != pMainVer) && (NULL != pSubVer)) + { + *pProductNo = (UINT16)(u32Ver >> (24u)); + *pModuleNo = (UINT16)((u32Ver & (0x00FFC000u)) >> (14u)); + *pMainVer = (UINT16)((u32Ver & (0x00003F00u)) >> (8u)); + *pSubVer = (UINT16)(u32Ver & (0x000000FFu)); + } + else + { + ; /*ڲ޲*/ + } +} + +/* +* ˵ : ɰ汾ת +* ˵ : UINT16 projectNo,Ŀ +* UINT16 productNo,Ʒ +* UINT16 ocNo,ִļ +* UINT16 integrationNo,ɱ +* ֵ: U32ʾİ汾 +*/ +UINT32 VerToU32SoftwareInt(UINT16 projectNo,UINT16 productNo,UINT16 ocNo,UINT16 integrationNo) +{ + UINT32 U32Version = 0u; /* ؽ */ + + U32Version = (UINT32)integrationNo & (0x01FFu); + U32Version |= ((UINT32)ocNo & (0x7Fu)) << (9u); + U32Version |= ((UINT32)productNo & (0x3FFu)) << (16u); + U32Version |= ((UINT32)projectNo & (0xFFu)) << (24u); + return U32Version; +} + +/* +* ˵ : ɰ汾ת +* ˵ : UINT16* pProjectNo,Ŀ +* UINT16* pProductNo,Ʒ +* UINT16* pOcNo,ִļ +* UINT16* pIntegrationNoɱ +* UINT32 u32Ver,U32ʾİ汾 +*/ +void VerFromU32SoftwareInt(UINT16* pProjectNo,UINT16* pProductNo,UINT16* pOcNo,UINT16* pIntegrationNo,UINT32 u32Ver) +{ + + if ((NULL != pProjectNo) && (NULL != pProductNo) && (NULL != pOcNo) && (NULL != pIntegrationNo)) + { + *pProjectNo = (UINT16)(u32Ver >> (24u)); + *pProductNo = (UINT16)((u32Ver & (0x00FF0000u)) >> (16u)); + *pOcNo = (UINT16)((u32Ver & (0x0000FE00u)) >> (9u)); + *pIntegrationNo = (UINT16)(u32Ver & (0x000001FFu)); + } + else + { + ; /*ڲ޲*/ + } +} + +/* +* ˵ : ģ汾ת +* ˵ : UINT16 projectNo,Ŀ +* UINT16 dataTypeNo,ͱ +* UINT16 dataNo,ݰ汾 +* UINT16 reserved,ԤϢ +* ֵ: U32ʾİ汾 +*/ +UINT32 VerToU32DataModule(UINT16 projectNo,UINT16 dataTypeNo,UINT16 dataNo,UINT16 reserved) +{ + UINT32 U32Version = 0u; /* ؽ */ + + U32Version= (UINT32)reserved & (0x0Fu); + U32Version|=((UINT32)dataNo & (0xFFFu)) << (4u); + U32Version|=((UINT32)dataTypeNo & (0xFFu)) << (16u); + U32Version|=((UINT32)projectNo & (0xFFu)) << (24u); + return U32Version; +} + +/* +* ˵ : ģ汾ת +* ˵ : UINT16* pProjectNo,Ŀ +* UINT16* pDataTypeNo,ͱ +* UINT16* pDataNo,ݰ汾 +* UINT16* pReservedԤϢ +* UINT32 u32Ver,U32ʾİ汾 +*/ +void VerFromU32DataModule(UINT16* pProjectNo,UINT16* pDataTypeNo,UINT16* pDataNo,UINT16* pReserved,UINT32 u32Ver) +{ + if ((NULL != pProjectNo) && (NULL != pDataTypeNo) && (NULL != pDataNo) && (NULL != pReserved)) + { + *pProjectNo = (UINT16)(u32Ver >> (24u)); + *pDataTypeNo = (UINT16)((u32Ver & (0x00FF0000u)) >> (16u)); + *pDataNo = (UINT16)((u32Ver & (0x0000FFF0u)) >> (4u)); + *pReserved = (UINT16)(u32Ver & (0x0Fu)); + } + else + { + ; /*ڲ޲*/ + } +} + +/* +* ˵ : ݼɰ汾ת +* ˵ : UINT16 projectNo,Ŀ +* UINT16 dataFileNo,ļ +* UINT16 dataIntNo,ݼɰ汾 +* UINT16 reserved,ԤϢ +* ֵ: U32ʾİ汾 +*/ +UINT32 VerToU32DataInt(UINT16 projectNo,UINT16 dataFileNo,UINT16 dataIntNo,UINT16 reserved) +{ + UINT32 U32Version = 0u; /* ؽ */ + + U32Version = (UINT32)reserved & (0x0Fu); + U32Version |= ((UINT32)dataIntNo & (0xFFFu))<<(4u); + U32Version |= ((UINT32)dataFileNo & (0xFFu))<<(16u); + U32Version |= ((UINT32)projectNo & (0xFFu))<<(24u); + return U32Version; +} + +/* +* ˵ : ģ汾ת +* ˵ : UINT16* pProjectNo,Ŀ +* UINT16* pDataFileNo,ļ +* UINT16* pDataIntNo,ݼɰ汾 +* UINT16* pReservedԤϢ +* UINT32 u32Ver,U32ʾİ汾 +*/ +void VerFromU32DataInt(UINT16* pProjectNo,UINT16* pDataFileNo,UINT16* pDataIntNo,UINT16* pReserved,UINT32 u32Ver) +{ + if ((NULL!= pProjectNo) && (NULL != pDataFileNo) && (NULL != pDataIntNo) && (NULL != pReserved)) + { + *pProjectNo = (UINT16)(u32Ver >> (24u)); + *pDataFileNo = (UINT16)((u32Ver & (0x00FF0000u)) >> (16u)); + *pDataIntNo = (UINT16)((u32Ver & (0x0000FFF0u)) >> (4u)); + *pReserved = (UINT16)(u32Ver & (0x0Fu)); + } + else + { + ; /*ڲ޲*/ + } + +} + diff --git a/TSCP/src/commoncode/common/CbtcVersion.h b/TSCP/src/commoncode/common/CbtcVersion.h new file mode 100644 index 0000000..be9a03d --- /dev/null +++ b/TSCP/src/commoncode/common/CbtcVersion.h @@ -0,0 +1,115 @@ +/******************************************************** +* +* ļ CbtcVersion.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2012.07.23 +* з +* 汾Ÿʽת +* ޸ļ¼ +* +********************************************************/ + +#ifndef _CBTCVERSION_H_ +#define _CBTCVERSION_H_ + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*yt-2022-03-08ڲ汾*/ +#define VER_SOFT_PROJECT 209 +#define VER_SOFT_MODUAL 50 +#define VER_SOFT_MIANSOFT 1 +#define VER_SOFT_SUBSOFT 4 + + /* + * ˵ : ģ汾ת + * ˵ : UINT16 productNo,Ʒ + * UINT16 moduleNo,ģ + * UINT16 mainVer,汾 + * UINT16 subVerӰ汾 + * ֵ: U32ʾİ汾 + */ + UINT32 VerToU32SoftwareModule(UINT16 productNo,UINT16 moduleNo,UINT16 mainVer,UINT16 subVer); + + /* + * ˵ : ģ汾ת + * ˵ : UINT16 *pProductNo,Ʒ + * UINT16 *pModuleNo,ģ + * UINT16 *pMainVer,汾 + * UINT16 *pSubVer,Ӱ汾 + * UINT32 u32Ver,U32ʾİ汾 + */ + void VerFromU32SoftwareModule(UINT16 *pProductNo,UINT16 *pModuleNo,UINT16 *pMainVer,UINT16 *pSubVer,UINT32 u32Ver); + + /* + * ˵ : ɰ汾ת + * ˵ : UINT16 projectNo,Ŀ + * UINT16 productNo,Ʒ + * UINT16 ocNo,ִļ + * UINT16 integrationNo,ɱ + * ֵ: U32ʾİ汾 + */ + UINT32 VerToU32SoftwareInt(UINT16 projectNo,UINT16 productNo,UINT16 ocNo,UINT16 integrationNo); + + /* + * ˵ : ɰ汾ת + * ˵ : UINT16* pProjectNo,Ŀ + * UINT16* pProductNo,Ʒ + * UINT16* pOcNo,ִļ + * UINT16* pIntegrationNoɱ + * UINT32 u32Ver,U32ʾİ汾 + */ + void VerFromU32SoftwareInt(UINT16* pProjectNo,UINT16* pProductNo,UINT16* pOcNo,UINT16* pIntegrationNo,UINT32 u32Ver); + + /* + * ˵ : ģ汾ת + * ˵ : UINT16 projectNo,Ŀ + * UINT16 dataTypeNo,ͱ + * UINT16 dataNo,ݰ汾 + * UINT16 reserved,ԤϢ + * ֵ: U32ʾİ汾 + */ + UINT32 VerToU32DataModule(UINT16 projectNo,UINT16 dataTypeNo,UINT16 dataNo,UINT16 reserved); + + /* + * ˵ : ģ汾ת + * ˵ : UINT16* pProjectNo,Ŀ + * UINT16* pDataTypeNo,ͱ + * UINT16* pDataNo,ݰ汾 + * UINT16* pReservedԤϢ + * UINT32 u32Ver,U32ʾİ汾 + */ + void VerFromU32DataModule(UINT16* pProjectNo,UINT16* pDataTypeNo,UINT16* pDataNo,UINT16* pReserved,UINT32 u32Ver); + + /* + * ˵ : ݼɰ汾ת + * ˵ : UINT16 projectNo,Ŀ + * UINT16 dataFileNo,ļ + * UINT16 dataIntNo,ݼɰ汾 + * UINT16 reserved,ԤϢ + * ֵ: U32ʾİ汾 + */ + UINT32 VerToU32DataInt(UINT16 projectNo,UINT16 dataFileNo,UINT16 dataIntNo,UINT16 reserved); + + /* + * ˵ : ģ汾ת + * ˵ : UINT16* pProjectNo,Ŀ + * UINT16* pDataFileNo,ļ + * UINT16* pDataIntNo,ݼɰ汾 + * UINT16* pReservedԤϢ + * UINT32 u32Ver,U32ʾİ汾 + */ + void VerFromU32DataInt(UINT16* pProjectNo,UINT16* pDataFileNo,UINT16* pDataIntNo,UINT16* pReserved,UINT32 u32Ver); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/commoncode/common/CommonBit.c b/TSCP/src/commoncode/common/CommonBit.c new file mode 100644 index 0000000..aab9114 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonBit.c @@ -0,0 +1,88 @@ +/******************************************************** +* +* ļ CommonBit.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2012.07.20 +* з +* bit +* ޸ļ¼ +* +********************************************************/ + +#include "CommonBit.h" + +/* +* ˵ : bit-bitλΪضֵ +* ˵ : UINT32* pData, +* UINT32 bitIndex,bit31,30,...1,0 +* UINT8 bitValuebitλֵ10. +* ֵ: 0, δֵbit +* 1, 渳ֵ +*/ +UINT8 CommonBitSet32(UINT32* pData,UINT32 bitIndex,UINT8 bitValue) +{ + UINT8 Result = 0u; /* ؽ */ + + if (NULL == pData) + { + Result = 0u; + } + else + { + /*ֵĺϷ*/ + if (bitIndex<(sizeof(UINT32)*8u)) + { + if ((1u == bitValue)||(0u == bitValue)) + { + /*bitֵ*/ + *pData = *pData|(1u<>bitIndex); + Result = 1u; + } + else + { + Result = 0u; + } + } + return Result; +} + diff --git a/TSCP/src/commoncode/common/CommonBit.h b/TSCP/src/commoncode/common/CommonBit.h new file mode 100644 index 0000000..298dd94 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonBit.h @@ -0,0 +1,50 @@ + +/******************************************************** +* +* ļ CommonBit.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2012.07.20 +* з +* bit +* ޸ļ¼ +* +********************************************************/ + +#ifndef _COMMONBIT_H_ +#define _COMMONBIT_H_ + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * ˵ : bit-bitλΪضֵ + * ˵ : UINT32* pData, + * UINT32 bitIndex,bit31,30,...1,0 + * UINT8 bitValuebitλֵ10. + * ֵ: 0, δֵbit + * 1, 渳ֵ + */ + UINT8 CommonBitSet32(UINT32* pData,UINT32 bitIndex,UINT8 bitValue); + + /* + * ˵ : bit-ȡbitλ + * ˵ : UINT32 Data, + * UINT32 bitIndex,bit31,30,...1,0 + * UINT8 pBitValueȡbitλֵ10. + * ֵ: 0, δֵbit + * 1, 渳ֵ + */ + UINT8 CommonBitGet32(UINT32 Data,UINT32 bitIndex,UINT8* pBitValue); + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/commoncode/common/CommonCRC.c b/TSCP/src/commoncode/common/CommonCRC.c new file mode 100644 index 0000000..9aae652 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonCRC.c @@ -0,0 +1,232 @@ + +/******************************************************** +* +* ļ CommonCRC.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2010.03.10 +* ؼЭ鲿 +* ͨCRC㺯 +* ޸ļ¼ +* +********************************************************/ + +#include "CommonTypes.h" +#include "CommonCRC.h" + +static void generate_crc_table(COMMON_CRC_STRU* CommonCrcStru); +static UINT32 reflect (UINT32 src, UINT8 bitnum); + +/************************************************************************ +* :CommonCRCInit +* ;:ʼCRCṹ +* : +* CommonCrcStruCRCṹָ +* orderɶʽĽ:CRC16ĽΪ16,CRC32ĽΪ32. +* polyɶʽ +* crcinitĴʼֵ +* crcxorϵCRCǰ򣬵õյCRC +* refinֽڷת־,0-ת1-ת +* refoutڽǰCRCת־0-ת1-ת +* ֵ:ޡ +* ʹ˵: +* ʹö͵CRCʱҪֱCOMMON_CRC_STRUṹ岢ֱʼ +* ʹòο: +* CRC_CCITT: +* order = 16; poly=0x1021; crcinit = 0xFFFF; crcxor=0; refin =0; refout=0; +* CRC16: +* rder = 16; poly=0x8005; crcinit = 0x0; crcxor=0x0; refin =1; refout=1; +* CRC32: +* order = 32; poly=0x4c11db7; crcinit = 0xFFFFFFFF; crcxor=0xFFFFFFFF; refin =1; refout=1; +* ޸ļ¼ +************************************************************************/ +void CommonCRCInit(COMMON_CRC_STRU* CommonCrcStru, UINT8 order, UINT32 poly, UINT8 refin, UINT8 refout, UINT32 crcinit, UINT32 crcxor) +{ + if((NULL != CommonCrcStru) && ((32u == order) || (16u == order))) + { + CommonCrcStru->order = order; + CommonCrcStru->poly = poly; + CommonCrcStru->refin = refin; + CommonCrcStru->refout = refout; + CommonCrcStru->crcinit = crcinit; + CommonCrcStru->crcxor = crcxor; + CommonCrcStru->crcmask = ((((UINT32)1<<(order-1u))-1u)<<1u)|1u; + CommonCrcStru->crchighbit = (UINT32)1<<(order-1u); + + /*generate lookup table*/ + generate_crc_table(CommonCrcStru); + } + else + { + ; /*Ϊգ޲*/ + } +} + +/************************************************************************ +* :generate_crc_table +* ;:ͨCRCɺ +* : +* CommonCrcStruCRCṹָ +* ֵ:ޡ +* ʹ˵CommonCRCInit +* ޸ļ¼ +************************************************************************/ +static void generate_crc_table(COMMON_CRC_STRU* CommonCrcStru) +{ + /*ʱ*/ + UINT32 i = 0u; + UINT32 j = 0u; + UINT32 bit = 0u; + UINT32 crc = 0u; + if(NULL != CommonCrcStru) + { + for (i=0u; i<256u; i++) + { + crc=(UINT32)i; + if (0u != CommonCrcStru->refin) /*'refin' [0,1] specifies if a data byte is reflected before processing (UART) or not */ + { + crc=reflect(crc, 8u); + } + else + { + ; /*ִ*/ + } + + /*MISRA2004-12_8-3Υз*/ + if((40u >= CommonCrcStru->order) && (8u <= CommonCrcStru->order)) + { + crc<<= CommonCrcStru->order-8u; + + } + else + { + crc = 0u; + } + for (j=0u; j<8u; j++) + { + bit = crc & CommonCrcStru->crchighbit; + crc<<= 1; + + if (0u != bit) + { + crc^= CommonCrcStru->poly; + } + else + { + ; /*ִ*/ + } + } + + if (0u != CommonCrcStru->refin) + { + crc = reflect(crc, CommonCrcStru->order); + } + else + { + ; /*ִ*/ + } + crc&= CommonCrcStru->crcmask; + CommonCrcStru->crctab[i]= crc; + } + } + else + { + ; /*Ϊգ޲*/ + } +} + +/************************************************************************ +* :reflect +* ;:Դݺbitnumλзת +* : +* src Դ +* bitnum Ҫתλ +* ֵ:תĽ +* ʹ˵CommonCRCڲ +* ޸ļ¼ +************************************************************************/ +static UINT32 reflect (UINT32 src, UINT8 bitnum) +{ + UINT8 i = 0u; + UINT32 t = src; + UINT32 v = src; + for(i = 0u; i < bitnum; i++) + { + if (t & 1u) + { + v |= BITMASK((bitnum-1u)-i); + } + else + { + v &= ~BITMASK((bitnum-1u)-i); + } + t >>= 1u; + } + + return v; +} + +/************************************************************************ +* :CommonCRC +* ;:ͨCRC㺯 +* : +* p Դָ +* Length Ҫݳ +* CommonCrcStru CRCṹָ +* ֵ:CRC +* ʹ˵:ڵô˺ǰҪCommonCRCInitʼCommonCrcStru +* ޸ļ¼ +************************************************************************/ +UINT32 CommonCRC(UINT8 p[], UINT32 Length, COMMON_CRC_STRU * CommonCrcStru) +{ + /*fast lookup table algorithm without augmented zero bytes, e.g. used in pkzip. */ + /*only usable with polynom orders of 8, 16, 24 or 32. */ + UINT32 crc = 0u; + UINT32 i = 0u; + if((NULL != p) && (NULL != CommonCrcStru)) + { + crc = CommonCrcStru->crcinit; + + if (0u != CommonCrcStru->refin) + { + crc = reflect(crc, CommonCrcStru->order); + } + else + { + ; /*ִ*/ + } + + if (0u == CommonCrcStru->refin) + { + for (i = 0u; i < Length; i++ ) + { + crc = (crc << 8u) ^ CommonCrcStru->crctab[ ((crc >> (CommonCrcStru->order-8u)) & 0xffu) ^ p[i]]; + } + } + else + { + for (i = 0u; i < Length; i++ ) + { + crc = (crc >> 8u) ^ CommonCrcStru->crctab[ (crc & 0xffu) ^ p[i]]; + } + } + + if (0u != (CommonCrcStru->refout^CommonCrcStru->refin)) + { + crc = reflect(crc, CommonCrcStru->order); + } + else + { + ; /*ִ*/ + } + + crc^= CommonCrcStru->crcxor; + crc&= CommonCrcStru->crcmask; + } + else + { + ; /*ڲΪ*/ + } + return(crc); +} + diff --git a/TSCP/src/commoncode/common/CommonCRC.h b/TSCP/src/commoncode/common/CommonCRC.h new file mode 100644 index 0000000..b6d3ebb --- /dev/null +++ b/TSCP/src/commoncode/common/CommonCRC.h @@ -0,0 +1,49 @@ + +/************************************************************************ +* +* ļ CommonCRC.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2010.03.10 +* ؼЭ鲿 +* ͨCRC㺯 +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _COMMONCRC_H_ +#define _COMMONCRC_H_ + +#include "CommonTypes.h" + +#define BITMASK(X) ((UINT32)1 << (X)) + +#ifdef __cplusplus +extern "C" { +#endif + +/*CommonʹõĽṹ*/ +typedef struct { + UINT8 order; + UINT32 poly; + UINT32 crcinit; + UINT8 refin; + UINT8 refout; + UINT32 crcxor; + UINT32 crcmask; + UINT32 crchighbit; + UINT32 crctab[256]; +} COMMON_CRC_STRU; + +void CommonCRCInit(COMMON_CRC_STRU* CommonCrcStru, UINT8 order, UINT32 poly, UINT8 refin, UINT8 refout, UINT32 crcinit, UINT32 crcxor); + +UINT32 CommonCRC(UINT8* p, UINT32 Length, COMMON_CRC_STRU * CommonCrcStru); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/commoncode/common/CommonMemory.c b/TSCP/src/commoncode/common/CommonMemory.c new file mode 100644 index 0000000..92cce84 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonMemory.c @@ -0,0 +1,130 @@ +/******************************************************** +* +* ļ CommonMemory.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2012.07.17 +* з +* ڴ +* ޸ļ¼ +* +********************************************************/ + +#include "CommonMemory.h" + +#if defined LIB_MEM_PROCESS +#include "string.h" +#else +#endif + + + +/* +* ˵ : ڴ渳ֵ +* ˵ : void *pDest, Ŀĵַ +* UINT8 c,ֵ +* UINT32 count,ֵڴ泤 +* UINT32 destBuffSizeֵܳȡ +* ֵ: 0, δֵֵȴڱ +* 1, 渳ֵ +*/ +UINT8 CommonMemSet(void* pDest, UINT32 destBuffSize, UINT8 c, UINT32 count) +{ + UINT8 Result = 0u; /* ؽ */ + if(NULL != pDest) + { + if(count > destBuffSize) + { + Result = 0u; /* ֵ쳣ֵ*/ + } + else + { + /*ڴ渳ֵ*/ + +#if defined LIB_MEM_PROCESS + memset(pDest,c,count); +#else + MemSet(pDest,c,count); +#endif + Result = 1u; + } + } + else + { + ; /*ڲΪգڴ渳ֵ*/ + } + return Result; +} + +/* : ڴ濽 +* ˵ : void *pDest, Ŀĵַ +* UINT32 destBuffSize, ȣÿݳ +* const void *pSrc, Դַ +* UINT32 count, +* ֵ: 0, δȴڱ +* 1, ɹ +*/ +UINT8 CommonMemCpy(void *pDest, UINT32 destBuffSize, const void *pSrc, UINT32 count) +{ + UINT8 Result = 0u; /* ؽ */ + if((NULL != pDest) && (NULL != pSrc)) + { + if(count > destBuffSize) + { + Result = 0u; /* 쳣*/ + } + else + { + /*ڴ渴*/ + #if defined LIB_MEM_PROCESS + memcpy(pDest,pSrc,count); + Result = 1u; + #else + Result = MemCpy(pDest,pSrc,count); + #endif + } + } + else + { + ; /*ڲΪգڴ濽*/ + } + return Result; +} + +UINT8 MemCpy(void *pDest, const void *pSrc, UINT32 count) +{ + UINT8 Result = 0u; /* ؽ */ + UINT32 t_u32I = 0u ; + + if ((NULL == pDest) || (NULL == pSrc)) + { + ; /*ڲ󣬲ڴ濽*/ + } + else + { + /*ڴ渴*/ + for(t_u32I = 0u ; t_u32I < count ; t_u32I++) + { + *((UINT8*)pDest+t_u32I) = *((UINT8*)pSrc+t_u32I); + } + Result = 1u; + } + return Result; +} + +void MemSet(void *pdestination, UINT8 value, UINT32 size) +{ + UINT32 t_u32I = 0u ; + + if ((NULL != pdestination) && (size != (UINT32)0)) + { + for(t_u32I = 0u ; t_u32I < size ; t_u32I++) + { + *((UINT8*)pdestination+t_u32I) = value; + } + } + else + { + ; + } +} diff --git a/TSCP/src/commoncode/common/CommonMemory.h b/TSCP/src/commoncode/common/CommonMemory.h new file mode 100644 index 0000000..c202099 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonMemory.h @@ -0,0 +1,54 @@ + +/******************************************************** +* +* ļ CommonMemory.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2012.07.17 +* з +* ڴ +* ޸ļ¼ +* +********************************************************/ + +#ifndef _COMMONMEMORY_H_ +#define _COMMONMEMORY_H_ + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * ˵ : ڴ渳ֵ + * ˵ : void *pDest, Ŀĵַ + * UINT8 c,ֵ + * UINT32 count,ֵڴ泤 + * UINT32 destBuffSizeֵܳȡ + * ֵ: 0, δֵֵȴڱ + * 1, 渳ֵ + */ + UINT8 CommonMemSet(void* pDest, UINT32 destBuffSize, UINT8 c, UINT32 count); + + + /* : ڴ濽 + * ˵ : void *pDest, Ŀĵַ + * UINT32 destBuffSize, ȣÿݳ + * const void *pSrc, Դַ + * UINT32 count, + * ֵ: 0, δȴڱ + * 1, ɹ + */ + UINT8 CommonMemCpy(void *pDest, UINT32 destBuffSize, const void *pSrc, UINT32 count); + + UINT8 MemCpy(void *pDest, const void *pSrc, UINT32 count); + void MemSet(void * pdestination, UINT8 value, UINT32 size); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/commoncode/common/CommonQueue.c b/TSCP/src/commoncode/common/CommonQueue.c new file mode 100644 index 0000000..b364eb1 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonQueue.c @@ -0,0 +1,487 @@ +/******************************************************** +* +* CommonQueue.c +* Ȩ˵ ʱƼι˾ +* ţ 1.0 +* ʱ䣺 2008.07.29 +* ߣ ؼЭ鲿 +* кʵ +* ʹע⣺ 1.õӦ÷ʽ(ӦãУһӦ+һжϣ +* 2 ֵ֧жϺһһд֧ͬʱͬʱд +* 3 㹻ռֹд +* 4 벻Ҫ 0 qsize +* 5 ж£ռС֡ݵᷢݳȲʣռֲд +* 6 ֧4gݣʹӦƽ̨ռ䡣 +* ޸ļ¼ +* +********************************************************/ + +#include "CommonQueue.h" +#include "stdlib.h" + + +/* +* гʼڳʼһУQueueElementFreeʹ +* Ϊнṹеqռ䣬еsizeʼ +* ˵ QueueStruct *pQueue, ռĶ +* UINT32 QSize, Ҫij +* ֵ 1ɹ +* 0ʧ +*/ +UINT8 QueueInitial(QueueStruct *pQueue, UINT32 QSize) +{ + UINT8 bRet = 0u; + + /*ֵж*/ + if((NULL != pQueue)&&(0u!=QSize)) + { + /*ֵϷ*/ + + /* in=out=0 */ + pQueue->in = 0u; + pQueue->out = 0u; + pQueue->qsize = QSize; + pQueue->q = (QueueElement* ) malloc(sizeof(QueueElement) * pQueue->qsize); + if(pQueue->q != NULL) + { + /*ɹʼ*/ + + bRet = 1u ; + } + else + { + bRet = 0u ; + } + } + else + { + /*ֵϷ*/ + + bRet = 0u ; + } + + return bRet; + +} + + +/* +* гʼڳʼһ +* QSizeʼQueueInitialȣôĿռΪԪصĿռ䡣 +* ˵ QueueStruct *pQueue, ռĶ +* UINT32 QSize, Ҫij +* QueueElement pQueueElementSpace[], Ҫڴռ +* ֵ 1ɹ +* 0ʧ +* ʹע⣺ 1ȷpQueueElementSpaceĴСڵQSize쳣 +* 2ʹʼٵQueueElementFreeпռͷš +*/ +UINT8 StaticQueueInitial(QueueStruct *pQueue, UINT32 QSize,QueueElement pQueueElementSpace[]) +{ + UINT8 bRet = 0u; + + /*ֵж*/ + if((NULL != pQueue)&&(0u!=QSize)) + { + /*ֵϷ*/ + + /* in=out=0 */ + pQueue->in = 0u; + pQueue->out = 0u; + pQueue->qsize = QSize; + + pQueue->q = pQueueElementSpace; /*%RELAX*/ + bRet = 1u ; + + } + else + { + /*ֵϷ*/ + bRet = 0u ; + } + + return bRet; +} + +/* +* ɨ躯ԶеݣǶԶеĶдָ붼Ӱ죬ݻڶ +* ˵ UINT32 DataLen, Ҫݳ; +* QueueElement *pData, Ҫŵ; +* QueueStruct *pQueue, ҪݵĶ +* ֵ 1ɹ +* 0ʧܣݳȲ +*/ +UINT8 QueueScan(UINT32 DataLen,QueueElement *pData,const QueueStruct *pQueue) +{ + register UINT32 i = 0u; + register UINT32 j = 0u; + register QueueElement *pOut = NULL; + UINT8 bRet = 0u; + + if ((NULL == pData) || (NULL == pQueue)) + { + bRet = 0u; + } + else + { + /*еݲͷش,ֹ0*/ + if( (QueueStatus(pQueue)q[pQueue->out] ); + j = pQueue->qsize - (pQueue->out); + + /*Ѿܹж㹻ݣҪٶinֵж*/ + if( j >= DataLen ) + { + /*תԶ */ + for(i=0u;iq[0u]; + + /*Ӷͷʼʣµ*/ + for(;iq[pQueue->out] ); + j = pQueue->qsize - (pQueue->out); + + /*Ѿܹж㹻ݣҪٶinֵж*/ + if( j > DataLen ) + { + /*תԶ */ + + for(i=0u;iout += DataLen; + } + else + { + /*j<=DataLen תܶ*/ + + /*β*/ + for(i=0u;iq[0u]; + + /*Ӷͷʼʣµ*/ + for(;iout = DataLen - j; + } + bRet = 1u ; + } + } + return bRet; /* 1ݳɹ */ +} + +/* +* кѶеinoutֵ0 +* ˵ QueueStruct *pQueue ҪĶָ +* ֵ 1ɹ;0ʧ +*/ +UINT8 QueueClear(QueueStruct *pQueue) +{ + UINT8 bRet = 0u; + + if(NULL != pQueue) + { + /* in=out=0 */ + pQueue->in = 0u; + pQueue->out = 0u; + bRet = 1u; + } + else + { + bRet = 0u; + } + + return bRet; +} + +/* +* пݳ +* ˵ QueueStruct *pQueue, ҪݳȵĶ +* ֵ ضпõݳȣΪգ0 +*/ +UINT32 QueueStatus (const QueueStruct *pQueue) +{ + UINT32 qStatus = 0u; + if (NULL == pQueue) + { + qStatus = 0u; + } + else + { + if(0u != pQueue->qsize) + { + qStatus=(pQueue->in+pQueue->qsize-pQueue->out)%pQueue->qsize; + } + else + { + /*˴ִ󣬷0˴߼*/ + qStatus=0u; + } + } + return qStatus; +} + +/* +* дкһедһ +* һеIJͬʱд +* Dzдģдº0 +* ˵ UINT32 DataLen, Ҫдݳ; +* QueueElement *pData, Ҫдݴŵ; +* QueueStruct *pQueue, ҪдݵĶ +* ֵ 1ɹ +* 0ʧ, +*/ +UINT8 QueueWrite(UINT32 DataLen,const QueueElement *pData,QueueStruct *pQueue) +{ + register UINT32 i = 0u; + register UINT32 j = 0u; + register QueueElement *pIn = NULL; + UINT8 bRet = 0u; + + if((NULL != pData) && (NULL != pQueue)) + { + /*ж϶ǷܹĿռд,ҪˣͲд */ + if( DataLen >= (pQueue->qsize - QueueStatus(pQueue)) ) + { + bRet = 0u ; + } + else + { + + /*Ѿܹж㹻Ŀռ䣬Ҫٶoutֵж*/ + j = pQueue->qsize- (pQueue->in); + pIn = & ( pQueue->q[pQueue->in] ); + + if( j > DataLen ) + { + /*дʱԲ÷ת*/ + + /*Լִָָٶ*/ + for(i=0u;iin += DataLen; + } + else /*j <= DataLen*/ + { + /*дбȻת*/ + + /*ݴӵǰָ뵽βдijΪj*/ + for(i=0u;iq[0u]; + + /*ӶͷʼдiijʼֵΪjΪϴдβij */ + for(;iin = DataLen - j; + } + bRet= 1u ; + } + } + else + { + bRet= 0u ; + } + return bRet; +} + +/* +* д洢ռͷź +* ڲҪijеʱ򣬰ѶеԪռͷŵ,QueueInitialʹ +* ˵ QueueStruct *pQueue, +* ֵ 1ɹ;0,ʧܣ +*/ +UINT8 QueueElementFree(QueueStruct *pQueue) +{ + + UINT8 ret=0u; + + if(NULL != pQueue) + { + /*ָλ*/ + pQueue->in = 0u; + pQueue->out = 0u; + pQueue->qsize = 0u; + + /*ͷŶпռ*/ + if(NULL != pQueue->q) + { + free(pQueue->q); + pQueue->q = NULL; + } + else + { + ; /*ִ*/ + } + ret = 1u; + } + else + { + ret = 0u; + } + + return ret ; +} + +/* +* ڶɾһԪء +* ˵ UINT16 Length, ҪɾԪظ +* QueueStruct *pQueue, ҪɾԪصĶ +* ֵ 1ɹ;0ʧ +*/ +UINT8 QueueElementDiscard( UINT16 Length, QueueStruct *pQueue) +{ + UINT8 bRet =0u; + + if(NULL != pQueue) + { + + /* ֽԪظҪ*/ + if( QueueStatus(pQueue) < Length) + { + bRet = QueueClear(pQueue); + } + else + { + pQueue->out = (pQueue->out + Length) % pQueue->qsize; + bRet=1u; + } + } + else + { + bRet=0u; + } + return bRet; +} + +/* +* пÿռС +* ˵ QueueStruct *pQueue, ָĶ +* ֵ ضпõĿռС,ڶвдһռ䲻 +*/ +UINT32 QueueGetSpace (const QueueStruct *pQueue) +{ + UINT32 qSpace = 0u; + if(NULL != pQueue) + { + if(0u != pQueue->qsize) + { + qSpace=(pQueue->out+pQueue->qsize-pQueue->in-1u)%pQueue->qsize; + + } + else + { + /*˴ִ󣬷0˴߼*/ + qSpace=0u; + + } + } + else + { + qSpace=0u; + } + return qSpace; +} + diff --git a/TSCP/src/commoncode/common/CommonQueue.h b/TSCP/src/commoncode/common/CommonQueue.h new file mode 100644 index 0000000..cdeaa62 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonQueue.h @@ -0,0 +1,138 @@ +/******************************************************** +* +* ļ CommonQueue.h +* Ȩ˵ ʱƼι˾ +* ţ 1.0 +* ʱ䣺 2008.07.29 +* ߣ ؼЭ鲿 +* кʵ +* ʹע⣺ 1.õӦ÷ʽ(ӦãУһӦ+һжϣ +* 2 ֵ֧жϺһһд֧ͬʱͬʱд +* 3 㹻ռֹд +* 4 벻Ҫ 0 qsize +* 5 ж£ռС֡ݵᷢݳȲʣռֲд +* +* ޸ļ¼ +* +********************************************************/ +#ifndef _COMMONQUEUE_H_ +#define _COMMONQUEUE_H_ + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*²ΪصĶ*/ +typedef UINT8 QueueElement; +typedef struct S_QueueStruct +{ + UINT32 in; /* дָ */ + UINT32 out; /* ָ */ + UINT32 qsize; /**/ + QueueElement *q; /**/ +} QueueStruct; + + +/* +* гʼڳʼһУQueueElementFreeʹ +* Ϊнṹеqռ䣬еsizeʼ +* ˵ QueueStruct *pQueue, ռĶ +* UINT32 QSize, Ҫij +* ֵ 1ɹ +* 0ʧ +*/ +UINT8 QueueInitial(QueueStruct *pQueue, UINT32 QSize); + + +/* +* гʼڳʼһ +* QSizeʼQueueInitialȣôĿռΪԪصĿռ䡣 +* ˵ QueueStruct *pQueue, ռĶ +* UINT32 QSize, Ҫij +* QueueElement pQueueElementSpace[], Ҫڴռ +* ֵ 1ɹ +* 0ʧ +* ʹע⣺ 1ȷpQueueElementSpaceĴСڵQSize쳣 +* 2ʹʼٵQueueElementFreeпռͷš +*/ +UINT8 StaticQueueInitial(QueueStruct *pQueue, UINT32 QSize,QueueElement pQueueElementSpace[]); + +/* +* ɨ躯ԶеݣǶԶеĶдָ붼Ӱ죬ݻڶ +* ˵ UINT32 DataLen, Ҫݳ; +* QueueElement *pData, Ҫŵ; +* QueueStruct *pQueue, ҪݵĶ +* ֵ 1ɹ +* 0ʧܣݳȲ +*/ +UINT8 QueueScan(UINT32 DataLen,QueueElement *pData,const QueueStruct *pQueue); + + +/* +* кԶе,һУݶָ뷢仯Ѳڶ +* ˵ UINT32 DataLen, Ҫݳ; +* QueueElement *pData, Ҫŵ; +* QueueStruct *pQueue, ҪݵĶ +* ֵ 1ɹ +* 0ʧܣݳȲ +*/ +UINT8 QueueRead(UINT32 DataLen, QueueElement *pData,QueueStruct *pQueue); + +/* +* кѶеinoutֵ0 +* ˵ QueueStruct *pQueue ҪĶָ +* ֵ 1ɹ +*/ +UINT8 QueueClear(QueueStruct *pQueue); + +/* +* пݳ +* ˵ QueueStruct *pQueue, ҪݳȵĶ; +* ֵ ضпõݳȣΪգ0 +*/ +UINT32 QueueStatus (const QueueStruct *pQueue); + +/* +* дкһедһ +* һеIJͬʱд +* Dzдģдº0 +* ˵ UINT32 DataLen, Ҫдݳ; +* QueueElement *pData, Ҫдݴŵ; +* QueueStruct *pQueue, ҪдݵĶ +* ֵ 1ɹ +* 0ʧ, +*/ +UINT8 QueueWrite(UINT32 DataLen,const QueueElement *pData,QueueStruct *pQueue); + +/* +* д洢ռͷź +* ڲҪijеʱ򣬰ѶеԪռͷŵ,QueueInitialʹ +* ˵ QueueStruct *pQueue, +* ֵ 1ɹ +*/ +UINT8 QueueElementFree(QueueStruct *pQueue); + +/* +* ڶɾһԪء +* ˵ UINT16 Length, ҪɾԪظ +* QueueStruct *pQueue, ҪɾԪصĶ +* ֵ 1ɹ +* 0ʧ +*/ +UINT8 QueueElementDiscard( UINT16 Length, QueueStruct *pQueue); + +/* +* пÿռС +* ˵ QueueStruct *pQueue, ָĶ +* ֵ ضпõĿռС,ڶвдÿռΪqsize-1 +*/ +UINT32 QueueGetSpace (const QueueStruct *pQueue); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/commoncode/common/CommonRecord.c b/TSCP/src/commoncode/common/CommonRecord.c new file mode 100644 index 0000000..000e336 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonRecord.c @@ -0,0 +1,603 @@ + +/******************************************************************************* +* ļ CommonRecord.c +* Ȩ˵ +* 汾 1.0 +* ʱ 2009.11.12 +* ؼЭ鲿 +* ¼Դļɵøļеĺַͻ͵д¼ + ¼ǰλΪǰдֽӵֽڿʼΪҪд¼ +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + + +#include "CommonRecord.h" + + +static const CHAR HexTable[16] = {(UINT8)'0',(UINT8)'1',(UINT8)'2',(UINT8)'3', + (UINT8)'4',(UINT8)'5',(UINT8)'6',(UINT8)'7',(UINT8)'8',(UINT8)'9',(UINT8)'A',(UINT8)'B',(UINT8)'C',(UINT8)'D',(UINT8)'E',(UINT8)'F'}; + +/****************************************************************************************** +* : ַʽļ¼дһַʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {'a'}洢Ϊ{97,0x61} +* : UINT16 RecArraySize ¼С + UINT8 c Ҫдַ +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintFilec(UINT8 RecArray[], UINT16 RecArraySize, UINT8 c)/* %RELAX */ +{ + UINT16 ArrayIndex = 0u; + UINT8 ret = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + ArrayIndex = ShortFromChar(RecArray) + 2u; + if(10u > (RecArraySize - ArrayIndex)) + { + ret = 0u; + } + else + { + RecArray[ArrayIndex++] = c; + ShortToChar((UINT16) (ArrayIndex - 2u),RecArray); + ret = 1u; + } + + } + + return ret; +} + + +/****************************************************************************************** +* : ַʽļ¼дNHexʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {0x12,0x34}洢Ϊ{0x310x320x330x34} +* : UINT16 RecArraySize ¼С + UINT8 *HexSrc ҪдHexݵͷָ + UINT16 Length ҪдHexݵij +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintFileHex(UINT8 *RecArray, UINT16 RecArraySize, UINT8 *HexSrc, UINT16 Length)/* %RELAX */ +{ + UINT16 i = 0u; + UINT8 ret = 0u; + UINT8 PrintFilecRtn = 0u; + + if((NULL == RecArray) || (NULL == HexSrc)) + { + ret = 0u; + + } + else + { + for(i = 0u; i < Length; i++) + { + PrintFilecRtn = PrintFilec(RecArray, RecArraySize, (UINT8)HexTable[*HexSrc>>4u]); + if(0u == PrintFilecRtn) + { + ret = 0u; + } + else + { + /*дɹ*/ + ret = 1u; + } + + if(0u!= ret) + { + PrintFilecRtn = PrintFilec(RecArray, RecArraySize, (UINT8)HexTable[*HexSrc & 0x0fu]); + if(0u == PrintFilecRtn) + { + ret = 0u; + } + else + { + /*дɹ*/ + ret = 1u; + } + } + + if(0u!= ret) + { + PrintFilecRtn = PrintFilec(RecArray, RecArraySize,' '); + if(0u == PrintFilecRtn) + { + ret = 0u; + } + else + { + /*дɹ*/ + ret = 1u; + HexSrc++; + } + } + if(0u == ret) + { + break; + } + + } + + } + return ret; +} + + +/****************************************************************************************** +* : ַʽļ¼дһַʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + "1234"洢Ϊ{0x310x320x330x34}={"1234"} +* : UINT16 RecArraySize ¼С + CHAR *StringSrc Ҫдַͷָ +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintFiles(UINT8 *RecArray, UINT16 RecArraySize, CHAR *StringSrc)/* %RELAX */ +{ + UINT8 ret = 0u; + UINT8 PrintFilecRtn = 0u; + if((NULL == RecArray) || (NULL == StringSrc)) + { + ret = 0u; + } + else + { + while(0u != *StringSrc) + { + PrintFilecRtn = PrintFilec(RecArray, RecArraySize, (UINT8)*StringSrc); + if(0u == PrintFilecRtn) + { + ret = 0u; + break; + } + else + { + /*дɹ*/ + ret = 1u; + } + + StringSrc++; + } + } + return ret; +} + + + +/****************************************************************************************** +* : ַʽļ¼дһHex͵short(16bit)ʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {0x1234}洢Ϊ{0x310x320x330x34} +* : UINT16 RecArraySize ¼С + UINT16 HexSrc ҪдShort +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintFileU16Hex(UINT8 *RecArray, UINT16 RecArraySize, UINT16 HexSrc)/* %RELAX */ +{ + UINT16 j = 0u; + CHAR TempChar[7] ={0}; + UINT8 ret = 0u; + UINT8 PrintFilesRtn = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + + for(j = 4u; j > 0u; j--) + { + TempChar[j] = HexTable[HexSrc & 0x0fu]; + HexSrc = HexSrc >> 4u; + } + TempChar[0] = 'x'; + TempChar[5] = ' '; + TempChar[6] = '\0'; + + PrintFilesRtn = PrintFiles(RecArray, RecArraySize, TempChar); + if(0u == PrintFilesRtn) + { + ret = 0u; + } + else + { + /*дɹ*/ + ret = 1u; + } + + } + return ret; +} + + +/****************************************************************************************** +* : ַʽļ¼дһHex͵long(32bit)ʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {0x12345678}洢Ϊ{0x310x320x330x34,0x35,0x36,0x37,0x38} +* : UINT16 RecArraySize ¼С + UINT32 HexSrc Ҫдlong +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintFileU32Hex(UINT8 *RecArray, UINT16 RecArraySize, UINT32 HexSrc)/* %RELAX */ +{ + UINT16 j = 0u; + CHAR TempChar[11] = {0}; + UINT8 ret = 0u; + UINT8 PrintFilesRtn = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + + for(j = 8u; j > 0u; j--) + { + TempChar[j] = HexTable[HexSrc & 0x0fu]; + HexSrc = HexSrc >> 4u; + } + TempChar[0] = 'x'; + TempChar[9] = ' '; + TempChar[10] = '\0'; + + PrintFilesRtn = PrintFiles(RecArray, RecArraySize, TempChar); + if(0u == PrintFilesRtn) + { + ret = 0u; + } + else + { + /*޲*/ + ret = 1u; + } + } + return ret; +} + + + +/****************************************************************************************** +* : ַʽļ¼дһInt͵long(16bit)ʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {305397760ʮƱʾΪ0x12340000}洢Ϊ{0x310x320x330x34,0x30,0x30,0x30,0x30} +* : UINT16 RecArraySize ¼С + UINT32 IntSrc Ҫдint +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintFileU32Int(UINT8 *RecArray, UINT16 RecArraySize, UINT32 IntSrc)/* %RELAX */ +{ + INT16 i = 0; + CHAR char_temp[11]={0}; + UINT8 ret = 0u; + UINT8 PrintFilesRtn = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + for(i=9;i>=0;i--) + { + char_temp[i]='0'+ (UINT8)(IntSrc%10u); + IntSrc/=10u; + } + for(i=0;i<9;i++) + { + if('0' != char_temp[i]) + { + break; + } + else + { + /*޲*/ + } + } + char_temp[10u] = '\0'; + PrintFilesRtn = PrintFiles(RecArray, RecArraySize, &char_temp[i]); + if(0u == PrintFilesRtn) + { + ret = 0u; + } + else + { + /*޲*/ + ret = 1u; + } + + } + return ret; +} + + + +/****************************************************************************************** +* : Զʽļ¼дһֽ + ʽ{0x12}洢Ϊ{0x12} +* : UINT16 RecArraySize ¼С + UINT8 ByteData Ҫдֽ +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintRecArrayByte(UINT8 RecArray[], UINT16 RecArraySize, UINT8 ByteData)/* %RELAX */ +{ + register UINT16 RecLength = 0u; + UINT8 ret = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + RecLength = ShortFromChar(RecArray); + RecLength += 2u; + + if((RecLength + 1u) > RecArraySize) /*õ鳤ȣǰһ䳤+ 2Ǽ¼ݼӳռݵĿռټ1ֽд > RecArraySize ܼд*/ + { + ret = 0u; + } + else + { + RecArray[RecLength] = ByteData; + RecLength--; /*ȥֽ+1*/ + ShortToChar(RecLength,RecArray); + ret = 1u; + + } + } + return ret; +} + + + +/****************************************************************************************** +* : ԶʽС˷ʽļ¼дֽ + ʽ{0x1234}洢Ϊ{0x340x12} +* : UINT16 RecArraySize ¼С + UINT16 BytesData Ҫдֽ +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintRecArray2ByteL(UINT8 RecArray[], UINT16 RecArraySize, UINT16 BytesData)/* %RELAX */ +{ + register UINT16 RecLength = 0u; + UINT8 ret = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + + RecLength = ShortFromChar(RecArray); + RecLength += 2u; + + if(RecLength + 2u > RecArraySize) + { + ret = 0u; + } + else + { + RecArray[RecLength++] = (UINT8)(BytesData & 0xffu); + RecArray[RecLength] = (UINT8)((BytesData >> 8u) & 0xffu); + RecLength--; + ShortToChar(RecLength,RecArray); + ret = 1u; + + } + } + return ret; +} + + + +/****************************************************************************************** +* : Զʽ˷ʽļ¼дֽ + ʽ{0x1234}洢Ϊ{0x120x34} +* : UINT16 RecArraySize ¼С + UINT16 BytesData Ҫдֽ +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintRecArray2ByteB(UINT8 RecArray[], UINT16 RecArraySize, UINT16 BytesData)/* %RELAX */ +{ + register UINT16 RecLength; + UINT8 ret = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + + RecLength = ShortFromChar(RecArray); + RecLength += 2u; + + if(RecLength + 2u > RecArraySize) + { + ret = 0u; + } + else + { + RecArray[RecLength++] = (UINT8)((BytesData >> 8u) & 0xffu); + RecArray[RecLength] = (UINT8)(BytesData & 0xffu); + RecLength--; + ShortToChar(RecLength,RecArray); + ret = 1u; + } + } + return ret; +} + + + +/****************************************************************************************** +* : ԶʽС˷ʽļ¼дĸֽ + ʽ{0x12345678}洢Ϊ{0x780x560x340x12} +* : UINT16 RecArraySize ¼С + UINT32 BytesData Ҫдֽ +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintRecArray4ByteL(UINT8 RecArray[], UINT16 RecArraySize, UINT32 BytesData)/* %RELAX */ +{ + register UINT16 RecLength; + UINT8 ret = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + RecLength = ShortFromChar(RecArray); + RecLength += 2u; + + if(RecLength + 4u > RecArraySize) + { + ret = 0u; + } + else + { + RecArray[RecLength++] = (UINT8) (BytesData & 0xffu); + RecArray[RecLength++] = (UINT8) ((BytesData >> 8u) & 0xffu); + RecArray[RecLength++] = (UINT8) ((BytesData >> 16u) & 0xffu); + RecArray[RecLength] = (UINT8) ((BytesData >> 24u) & 0xffu); + RecLength--; + ShortToChar(RecLength,RecArray); + ret = 1u; + } + } + return ret; +} + + + +/****************************************************************************************** +* : Զʽ˷ʽļ¼дĸֽ + ʽ{0x12345678}洢Ϊ{0x120x34,0x56,0x78} +* : UINT16 RecArraySize ¼С + UINT32 BytesData Ҫдֽ +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintRecArray4ByteB(UINT8 RecArray[], UINT16 RecArraySize, UINT32 BytesData)/* %RELAX */ +{ + register UINT16 RecLength; + UINT8 ret = 0u; + + if(NULL == RecArray) + { + ret = 0u; + } + else + { + RecLength = ShortFromChar(RecArray); + RecLength += 2u; + + if(RecLength + 4u > RecArraySize) + { + ret = 0u; + } + else + { + RecArray[RecLength++] = (UINT8) ((BytesData >> 24u) & 0xffu); + RecArray[RecLength++] = (UINT8) ((BytesData >> 16u) & 0xffu); + RecArray[RecLength++] = (UINT8) ((BytesData >> 8u) & 0xffu); + RecArray[RecLength] = (UINT8) (BytesData & 0xffu); + RecLength--; + ShortToChar(RecLength,RecArray); + ret = 1u; + } + } + return ret; + +} + + + +/****************************************************************************************** +* : Զʽļ¼дNֽ + ʽ{0x12,0x34}洢Ϊ{0x120x34} +* : UINT16 RecArraySize ¼С + UINT8 *pBytesData Ҫдݵͷָ + UINT16 Length Ҫдֽ +* : UINT8 *RecArray ¼ͷָ +* : +* ȫֱ : +* ֵ : д1¼ռ䲻0 +*******************************************************************************************/ +UINT8 PrintRecArrayNByte(UINT8 *RecArray, UINT16 RecArraySize,UINT8 *pBytesData, UINT16 Length)/* %RELAX */ +{ + register UINT16 RecLength; + UINT16 i = 0u; + UINT8 ret = 0u; + + if((NULL == RecArray) || (NULL == pBytesData)) + { + ret = 0u; + } + else + { + RecLength = ShortFromChar(RecArray); + RecLength += 2u; + + if(RecLength + Length > RecArraySize) + { + ret = 0u; + } + else + { + for(i = 0u; i < Length; i++) + { + RecArray[RecLength++] = *(pBytesData++); + } + RecLength -= 2u; + ShortToChar(RecLength,RecArray); + ret = 1u; + } + } + return ret; +} + diff --git a/TSCP/src/commoncode/common/CommonRecord.h b/TSCP/src/commoncode/common/CommonRecord.h new file mode 100644 index 0000000..6baba98 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonRecord.h @@ -0,0 +1,201 @@ + +/******************************************************************************* +* ļ CommonRecord.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2009.11.12 +* ؼЭ鲿 +* ¼ͷļɵøļеĺַͻ͵д¼ +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + +#ifndef _COMMONRECORD_H_ +#define _COMMONRECORD_H_ + +#include "Convert.h" +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + /****************************************************************************************** + * : ַʽļ¼дһַʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {'a'}洢Ϊ{097,0x61} + * : UINT16 RecArraySize ¼С + UINT8 c Ҫдַ + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintFilec(UINT8 RecArray[], UINT16 RecArraySize, UINT8 c); + + + /****************************************************************************************** + * : ַʽļ¼дNHexʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {0x12,0x34}洢Ϊ{0x310x320x330x34} + * : UINT16 RecArraySize ¼С + UINT8 *HexSrc ҪдHexݵͷָ + UINT16 Length ҪдHexݵij + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintFileHex(UINT8 *RecArray, UINT16 RecArraySize, UINT8 *HexSrc, UINT16 Length); + + /****************************************************************************************** + * : ַʽļ¼дһַʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + "1234"洢Ϊ{0x310x320x330x34}={"1234"} + * : UINT16 RecArraySize ¼С + CHAR *StringSrc Ҫдַͷָ + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintFiles(UINT8 *RecArray, UINT16 RecArraySize, CHAR *StringSrc); + + + /****************************************************************************************** + * : ַʽļ¼дһHex͵short(16bit)ʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {0x1234}洢Ϊ{0x310x320x330x34} + * : UINT16 RecArraySize ¼С + UINT16 HexSrc ҪдShort + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintFileU16Hex(UINT8 *RecArray, UINT16 RecArraySize, UINT16 HexSrc); + + + /****************************************************************************************** + * : ַʽļ¼дһHex͵long(32bit)ʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {0x12345678}洢Ϊ{0x310x320x330x34,0x35,0x36,0x37,0x38} + * : UINT16 RecArraySize ¼С + UINT32 HexSrc Ҫдlong + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintFileU32Hex(UINT8 *RecArray, UINT16 RecArraySize, UINT32 HexSrc); + + + + /****************************************************************************************** + * : ַʽļ¼дһInt͵long(16bit)ʽļ¼ֱӲ鿴 + ¼д洢Ҫ¼ݵASCII롣 + {305397760ʮƱʾΪ0x12340000}洢Ϊ{0x310x320x330x34,0x30,0x30,0x30,0x30} + * : UINT16 RecArraySize ¼С + UINT32 IntSrc Ҫдint + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintFileU32Int(UINT8 *RecArray, UINT16 RecArraySize, UINT32 IntSrc); + + + + /****************************************************************************************** + * : Զʽļ¼дһֽ + ʽ{0x12}洢Ϊ{0x12} + * : UINT16 RecArraySize ¼С + UINT8 ByteData Ҫдֽ + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintRecArrayByte(UINT8 RecArray[], UINT16 RecArraySize, UINT8 ByteData); + + + + /****************************************************************************************** + * : ԶʽС˷ʽļ¼дֽ + ʽ{0x1234}洢Ϊ{0x340x12} + * : UINT16 RecArraySize ¼С + UINT16 BytesData Ҫдֽ + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintRecArray2ByteL(UINT8 RecArray[], UINT16 RecArraySize, UINT16 BytesData); + + + + /****************************************************************************************** + * : Զʽ˷ʽļ¼дֽ + ʽ{0x1234}洢Ϊ{0x120x34} + * : UINT16 RecArraySize ¼С + UINT16 BytesData Ҫдֽ + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintRecArray2ByteB(UINT8 RecArray[], UINT16 RecArraySize, UINT16 BytesData); + + + + /****************************************************************************************** + * : ԶʽС˷ʽļ¼дĸֽ + ʽ{0x12345678}洢Ϊ{0x780x560x340x12} + * : UINT16 RecArraySize ¼С + UINT32 BytesData Ҫдֽ + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintRecArray4ByteL(UINT8 RecArray[], UINT16 RecArraySize, UINT32 BytesData); + + + + /****************************************************************************************** + * : Զʽ˷ʽļ¼дĸֽ + ʽ{0x12345678}洢Ϊ{0x120x34,0x56,0x78} + * : UINT16 RecArraySize ¼С + UINT32 BytesData Ҫдֽ + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintRecArray4ByteB(UINT8 RecArray[], UINT16 RecArraySize, UINT32 BytesData); + + + + /****************************************************************************************** + * : Զʽļ¼дNֽ + ʽ{0x12,0x34}洢Ϊ{0x120x34} + * : UINT16 RecArraySize ¼С + UINT8 *pBytesData Ҫдݵͷָ + UINT16 Length Ҫдֽ + * : UINT8 *RecArray ¼ͷָ + * : + * ȫֱ : + * ֵ : д1¼ռ䲻0 + *******************************************************************************************/ + UINT8 PrintRecArrayNByte(UINT8 *RecArray, UINT16 RecArraySize,UINT8 *pBytesData, UINT16 Length); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/commoncode/common/CommonStack.c b/TSCP/src/commoncode/common/CommonStack.c new file mode 100644 index 0000000..e514fe9 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonStack.c @@ -0,0 +1,250 @@ +/******************************************************************************* +* +* ļ CommonStack.c +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.12 +* ؼЭ鲿 +* ջغԴļ +* ʹע⣺ +* ޸ļ¼ +* +*******************************************************************************/ + +#include "CommonStack.h" +#include "stdlib.h" + +/* +* ջʼڳʼһջStackFreeʹ +* ҪΪջռ䣬жջڲʼ +* ˵ CommonStack *pStack, ʼĵĶջ +* UINT32 TotalSize, ջС +* ֵ 1ɹ +* 0ʧ +*/ +UINT8 StackInitial(CommonStack *pStack, UINT16 TotalSize) +{ + UINT8 bRet = 0u;/*ں*/ + + /*ֵж*/ + if((NULL != pStack)&&(0u != TotalSize)) + { + /*ֵϷ*/ + + /*ջݳʼ */ + pStack->TotalSize=TotalSize; + pStack->Top=0u; + + /*ջռ*/ + pStack->pStackData = (STACK_DATA_TYPE* ) malloc(sizeof(STACK_DATA_TYPE) * (pStack->TotalSize)); + if(NULL != pStack->pStackData) + { + /*ɹʼ*/ + bRet = 1u ; + } + else + { + /*ջʼռʧܣʧ*/ + bRet = 0u ; + } + } + else + { + /*ֵϷʧ*/ + + bRet = 0u ; + } + + return bRet; + +} + +/****************************************************************************************** +* : ӶջеջԪأ +* : +* : CommonStack *pStack ջָ +* : STACK_DATA_TYPE* pData ջԪ +* ȫֱ : +* ֵ : ɹ1򷵻0 +*******************************************************************************************/ +UINT8 StackPop(CommonStack *pStack,STACK_DATA_TYPE* pData)/* %RELAX */ +{ + UINT8 ret = 0u;/*ں*/ + + if ((NULL == pStack) || (NULL == pData)) + { + ret = 0u; + } + else + { + if (0u < pStack->Top) + { + /*ջ*/ + + /*ջԪ*/ + pStack->Top--; + *pData = pStack->pStackData[pStack->Top]; + + /*ִгɹ*/ + ret = 1u; + } + else + { + /*ջݣʧ*/ + ret = 0u; + + } + + } + return ret; +} + +/****************************************************************************************** +* : ջѹһ +* : STACK_DATA_TYPE Data ջ +* : CommonStack *pStack ջָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 StackPush(CommonStack *pStack,STACK_DATA_TYPE Data)/* %RELAX */ +{ + UINT8 ret = 0u;/*ں*/ + + if (NULL == pStack) + { + ret = 0u; + } + else + { + if (pStack->Top < pStack->TotalSize) + { + /*ջССڶջֵʱѹջ*/ + + /*ѹջ*/ + pStack->pStackData[pStack->Top] = Data; + pStack->Top++; + + ret = 1u; + } + else + { + /*ջСڶջֵ,ѹջ.*/ + ret = 0u; + } + } + return ret; + +} + + +/* +* ջԪغ +* ˵ CommonStack *pStack ջָ +* ֵ 1ɹ;0ʧ +*/ +UINT8 StackClear(CommonStack *pStack) +{ + UINT8 ret = 0u;/*ں*/ + + if (NULL == pStack) + { + ret = 0u; + } + else + { + /*ջָλ*/ + pStack->Top = 0u; + ret = 1u; + } + + return ret; +} + +/* +* ջ洢ռͷź +* ڲҪijջʱ򣬰Ѷջݴ洢ռͷŵ,StackInitialʹ +* ˵ CommonStack *pStack, ջָ +* ֵ 1ɹ0ʧܣ +*/ +UINT8 StackFree(CommonStack *pStack) +{ + + UINT8 ret = 0u;/*ں*/ + + if (NULL == pStack) + { + ret = 0u; + } + else + { + /*ջָλ*/ + pStack->Top=0u; + pStack->TotalSize=0u; + + /*ͷŶջռ*/ + if(NULL != pStack->pStackData) + { + free(pStack->pStackData); + pStack->pStackData = NULL; + } + else + { + ; /*ִ*/ + } + ret = 1u; + } + return ret ; +} + + +/* +* ջ洢ռǷ +* ˵ CommonStack *pStack, ջָ +* ֵ 1 +* 0δ +*/ +UINT8 StackIsFull(CommonStack *pStack) +{ + + UINT8 ret=0u;/*ں*/ + + if (NULL == pStack) + { + ret = 0u; + } + else + { + if(pStack->Top==pStack->TotalSize) + { + /*ջ1*/ + ret=1u; + } + else + { + /*ջδ0*/ + ret = 0u; + } + } + return ret ; +} + +/* +* ջ洢ռԪظ +* ˵ CommonStack *pStack, ջָ +* ֵ ջԪظ +*/ +UINT16 StackStatus(CommonStack *pStack) +{ + UINT16 wTop = UINT16_MAX; + if (NULL != pStack) + { + wTop = pStack->Top; + } + else + { + ; /*ڲ*/ + } + return wTop; +} + diff --git a/TSCP/src/commoncode/common/CommonStack.h b/TSCP/src/commoncode/common/CommonStack.h new file mode 100644 index 0000000..2164086 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonStack.h @@ -0,0 +1,104 @@ +/******************************************************************************* +* +* ļ CommonStack.h +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.12 +* ؼЭ鲿 +* ջغԴļ +* ʹע⣺ +* ޸ļ¼ +* +*******************************************************************************/ +#ifndef _COMMONSTATCK_H +#define _COMMONSTATCK_H + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef UINT32 STACK_DATA_TYPE; + +/*ջṹ嶨*/ +typedef struct +{ + STACK_DATA_TYPE *pStackData; /*нڵֵʾǴ洢ݵĿռ*/ + UINT16 Top; /*ĿǰջĴС.ͬʱֵҲǰջ,дԪҪŵ±. + ڱջһ˳ջ,˳ջдֵӦdzʼΪ, + ֮,0STACK_MAXSIZE-1.*/ + UINT16 TotalSize; /*˶ջܹŽڵ*/ +} CommonStack; + + +/* +* ջʼڳʼһջStackFreeʹ +* ҪΪջռ䣬жջڲʼ +* ˵ CommonStack *pStack, ʼĵĶջ +* UINT32 TotalSize, ջС +* ֵ 1ɹ +* 0ʧ +*/ +UINT8 StackInitial(CommonStack *pStack, UINT16 TotalSize); + + +/****************************************************************************************** +* : ӶջеջԪأ +* : +* : CommonStack *pStack ջָ +* : STACK_DATA_TYPE* pData ջԪ +* ȫֱ : +* ֵ : ɹ1򷵻0 +*******************************************************************************************/ +UINT8 StackPop(CommonStack *pStack,STACK_DATA_TYPE* pData); + + +/****************************************************************************************** +* : ջѹһ +* : STACK_DATA_TYPE Data ջ +* : CommonStack *pStack ջָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 StackPush(CommonStack *pStack,STACK_DATA_TYPE Data); + + +/* +* ջԪغ +* ˵ CommonStack *pStack ջָ +* ֵ 1ɹ +*/ +UINT8 StackClear(CommonStack *pStack); + + +/* +* ջ洢ռͷź +* ڲҪijջʱ򣬰Ѷջݴ洢ռͷŵ,StackInitialʹ +* ˵ CommonStack *pStack, ջָ +* ֵ 1ɹ +*/ +UINT8 StackFree(CommonStack *pStack); + +/* +* ջ洢ռǷ +* ˵ CommonStack *pStack, ջָ +* ֵ 1 +* 0δ +*/ +UINT8 StackIsFull(CommonStack *pStack); + +/* +* ջ洢ռԪظ +* ˵ CommonStack *pStack, ջָ +* ֵ ջԪظ +*/ +UINT16 StackStatus(CommonStack *pStack); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/commoncode/common/CommonTypes.h b/TSCP/src/commoncode/common/CommonTypes.h new file mode 100644 index 0000000..db518c2 --- /dev/null +++ b/TSCP/src/commoncode/common/CommonTypes.h @@ -0,0 +1,137 @@ + +/************************************************************************ +* +* ļ CommonTypes.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.08.21 +* ؼЭ鲿 +* Ͷ. +* ʹע +* ޸ļ¼ +* +************************************************************************/ + + +#ifndef _COMMONTYPES_H_ +#define _COMMONTYPES_H_ + + +/*2015-03-17, 汾޸Ϊ21.15.0.1,޸ΪvXworksvxTypesOld.hжȱFLOAT32FLOAT64*/ +#define COMMONCODE_VER_PRODUCT_NO 21 +#define COMMONCODE_VER_MODULE_NO 15 +#define COMMONCODE_VER_MAIN_VER 0 +#define COMMONCODE_VER_SUB_VER 1 + + + +#include "CommonConfig.h" +#include +/**/ +#define IN +#define OUT +#define INOUT + + +#define CBTC_WINDOWS (kPLATFORM == kWINDOWS) +#define CBTC_MOTOROLA (kPLATFORM == kMOTOROLA) +#define CBTC_VXWORKS (kPLATFORM == kVXWORKS) +/***********************************************************/ +#if CBTC_MOTOROLA + +typedef signed char CHAR; +typedef signed char INT8; +typedef unsigned char UINT8; +typedef unsigned char UCHAR; +typedef short int INT16; +typedef unsigned short int UINT16; +typedef long INT32; +typedef unsigned long UINT32; +typedef float FLOAT32; +typedef double FLOAT64; +typedef unsigned long long int UINT64; +typedef long long int INT64; + + + + + + +/***********************************************************/ + +#elif CBTC_VXWORKS + +/*vxTypesOld.hļδ CHAR˴Ҫ塣 2012-1-13*/ +typedef signed char CHAR; +typedef float FLOAT32; +typedef double FLOAT64; + +/*Ϊ˱vxworksϵͳvxTypesOld.hеͶ巢ͻ,˴,ʹ +vxTypesOld.hеͶ,ʹô˴Ͷ*/ +#ifndef __INCvxTypesOldh +typedef signed char INT8; +typedef short INT16; +typedef int INT32; + +typedef unsigned char UINT8; +typedef unsigned short UINT16; +typedef unsigned int UINT32; +typedef unsigned char UCHAR; +#endif +/***********************************************************/ + + +/***********************************************************/ + +#elif CBTC_WINDOWS + +typedef char CHAR; +typedef signed char INT8; +typedef unsigned char UINT8; +typedef unsigned char UCHAR; +typedef short int INT16; +typedef unsigned short int UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef float FLOAT32; +typedef double FLOAT64; + +#elif LINUX + +typedef signed char CHAR; +typedef signed char INT8; +typedef unsigned char UINT8; +typedef unsigned char UCHAR; +typedef short int INT16; +typedef unsigned short int UINT16; +typedef int INT32; +typedef unsigned int UINT32; +typedef float FLOAT32; +typedef double FLOAT64; + +#else + +#endif + +/**************FOR CBTC ***************************************/ +#ifndef NULL +#define NULL 0 +#else +#endif + +/* Limits for fundamental types. */ +#define UINT8_MAX 0xffu +#define UINT16_MAX 0xffffu +#define UINT32_MAX 0xffffffffu + +#define INT8_MIN (-128) +#define INT8_MAX (127) +#define INT16_MIN (-32768) +#define INT16_MAX 32767 +#define INT32_MIN (-2147483647L - 1) +#define INT32_MAX 2147483647L + +#define FLOAT32_MAX 3.402823466e+38F +#define FLOAT64_MAX 1.7976931348623158e+308 + +#endif /* _COMMONTYPES_H_ */ diff --git a/TSCP/src/commoncode/common/Convert.c b/TSCP/src/commoncode/common/Convert.c new file mode 100644 index 0000000..ad6105d --- /dev/null +++ b/TSCP/src/commoncode/common/Convert.c @@ -0,0 +1,187 @@ +/******************************************************** +* +* ļ Convert.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2008.07.29 +* ؼЭ鲿 +* ͨת +* ޸ļ¼ +* +********************************************************/ + +#include "Convert.h" + +/* +* ڽ2ֽݱΪUINT16 BIG endian +* ˵ pInput, Ϊ +* ֵ 任UINT16ֵ;0 ڲΪ +*/ +UINT16 ShortFromChar(const UINT8 *pInput) +{ + UINT16 Tempshort = 0u; + if (NULL == pInput) + { + ; /*ڲΪ*/ + } + else + { + Tempshort = (UINT16)(*pInput); + Tempshort = (UINT16)((Tempshort << 8u) + *(pInput + 1u)); + } + + return Tempshort; +} + +/* +* ڽ4ֽݱΪUINT32 BIG endian +* ˵ pInput, Ϊ +* ֵ 任UINT32ֵ;0u ڲΪ +*/ +UINT32 LongFromChar(const UINT8 *pInput) +{ + UINT32 Templong = 0u; + if (NULL == pInput) + { + ; /*ڲΪ*/ + } + else + { + Templong = (UINT32)(*pInput); + Templong = (UINT32)((Templong << 8u) + *(pInput + 1u)); + Templong = (UINT32)((Templong << 8u) + *(pInput + 2u)); + Templong = (UINT32)((Templong << 8u) + *(pInput + 3u)); + } + + return Templong; +} + +/* +* 2ֽڳͱΪֽڱʾ BIG endian +* ˵ Input, Ϊ +* pOutput,Ϊ +* ֵ +*/ +void ShortToChar ( UINT16 Input, UINT8 *pOutput) +{ + if (NULL == pOutput) + { + ; /*ڲΪ*/ + } + else + { + *pOutput = (UINT8)((Input >> 8u) & 0xffu); + *(pOutput + 1u) = (UINT8)(Input & 0xffu); + } + +} + +/* +* 4ֽڳͱΪֽڱʾ BIG endian +* ˵ Input, Ϊ +* pOutput,Ϊ +* ֵ +*/ +void LongToChar(UINT32 Input, UINT8 *pOutput) +{ + if (NULL == pOutput) + { + ; /*ڲΪ*/ + } + else + { + *pOutput = (UINT8)((Input >> 24u) & 0xffu); + *(pOutput + 1u) = (UINT8)((Input >> 16u) & 0xffu); + *(pOutput + 2u) = (UINT8)((Input >> 8u) & 0xffu); + *(pOutput + 3u) = (UINT8)(Input & 0xffu); + } + +} + + + + +/* +* ڽUINT8ΪUINT16 LITTLE endian +* ˵ pInput, Ϊ +* ֵ 任UINT16ֵ0u ڲΪ +*/ +UINT16 ShortFromCharLE(const UINT8 *pInput) +{ + UINT16 Tempshort = 0u; + if (NULL == pInput) + { + ; /*ڲΪ*/ + } + else + { + Tempshort = *(pInput + 1); + Tempshort = (UINT16)((Tempshort << 8) + *(pInput)); + } + return Tempshort; +} + +/* +* ڽUINT8ΪUINT32 LITTLE endian +* ˵ pInput, Ϊ +* ֵ 任UINT32ֵ;0u ڲΪ +*/ +UINT32 LongFromCharLE(const UINT8 *pInput) +{ + UINT32 Templong = 0u; + if (NULL == pInput) + { + ; /*ڲΪ*/ + } + else + { + Templong = (UINT32)(*(pInput + 3u)); + Templong = (UINT32)((Templong << 8u) + *(pInput + 2u)); + Templong = (UINT32)((Templong << 8u) + *(pInput + 1u)); + Templong = (UINT32)((Templong << 8u) + *(pInput)); + } + + return Templong; +} + +/* +* 2ֽڵͱΪֽڱʾ LITTLE endian +* ˵ Input, Ϊ +* pOutput,Ϊ +* ֵ +*/ +void ShortToCharLE ( UINT16 Input, UINT8 *pOutput) +{ + if (NULL == pOutput) + { + ; /*޲*/ + } + else + { + *(pOutput + 1u) = (UINT8)((Input >> 8u) & 0xffu); + *pOutput = (UINT8)(Input & 0xffu); + } + +} + +/* +* 4ֽڵͱΪֽڱʾ LITTLE endian +* ˵ Input, Ϊ +* pOutput,Ϊ +* ֵ +*/ +void LongToCharLE(UINT32 Input, UINT8 *pOutput) +{ + if (NULL == pOutput) + { + ; /*޲*/ + } + else + { + *(pOutput + 3u) = (UINT8)((Input >> 24u) & 0xffu); + *(pOutput + 2u) = (UINT8)((Input >> 16u) & 0xffu); + *(pOutput + 1u) = (UINT8)((Input >> 8u) & 0xffu); + *pOutput = (UINT8)(Input & 0xffu); + } + +} diff --git a/TSCP/src/commoncode/common/Convert.h b/TSCP/src/commoncode/common/Convert.h new file mode 100644 index 0000000..038c9b0 --- /dev/null +++ b/TSCP/src/commoncode/common/Convert.h @@ -0,0 +1,94 @@ + +/************************************************************************ +* +* ļ Convert.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.08.21 +* ؼЭ鲿 +* ͨת +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _CONVERT_H_ +#define _CONVERT_H_ + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* +* ڽ2ֽݱΪUINT16 BIG endian +* ˵ pInput, Ϊ +* ֵ 任UINT16ֵ +*/ +UINT16 ShortFromChar(const UINT8 *pInput); + +/* +* ڽ4ֽݱΪUINT32 BIG endian +* ˵ pInput, Ϊ +* ֵ 任UINT32ֵ +*/ +UINT32 LongFromChar(const UINT8 *pInput); + + +/* +* 2ֽڳͱΪֽڱʾ BIG endian +* ˵ Input, Ϊ +* pOutput,Ϊ +* ֵ +*/ +void ShortToChar ( UINT16 Input, UINT8 *pOutput); + +/* +* 4ֽڳͱΪֽڱʾ BIG endian +* ˵ Input, Ϊ +* pOutput,Ϊ +* ֵ +*/ +void LongToChar(UINT32 Input, UINT8 *pOutput); + + + +/* +* ڽUINT8ΪUINT16 LITTLE endian +* ˵ pInput, Ϊ +* ֵ 任UINT16ֵ +*/ +UINT16 ShortFromCharLE(const UINT8 *pInput); + + +/* +* ڽUINT8ΪUINT32 LITTLE endian +* ˵ pInput, Ϊ +* ֵ 任UINT32ֵ +*/ +UINT32 LongFromCharLE(const UINT8 *pInput); + +/* +* 2ֽڵͱΪֽڱʾ LITTLE endian +* ˵ Input, Ϊ +* pOutput,Ϊ +* ֵ +*/ +void ShortToCharLE ( UINT16 Input, UINT8 *pOutput); + +/* +* 4ֽڵͱΪֽڱʾ LITTLE endian +* ˵ Input, Ϊ +* pOutput,Ϊ +* ֵ +*/ +void LongToCharLE(UINT32 Input, UINT8 *pOutput); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/commoncode/common/DataPackage.c b/TSCP/src/commoncode/common/DataPackage.c new file mode 100644 index 0000000..f8fe3f4 --- /dev/null +++ b/TSCP/src/commoncode/common/DataPackage.c @@ -0,0 +1,210 @@ +/************************************************************************ +* +* ļ DataPackage.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.02.23 +* +* ֡ͽ֡ +* ʹע +* ޸ļ¼ +************************************************************************/ +#include "DataPackage.h" +#include "CommonTypes.h" +#include "CommonMemory.h" +#include "stdlib.h" +#include "stdio.h" +#include "string.h" +#include "Convert.h" + + +/* + * ֡ݺϳһݷ + * + * + UINT8 msgCount ĸ + MsgStru msgList[] б + INT32 sndBuffLen ĴŵݻС + * + * UINT8 snddataBuff[] ϲ֡ + * ֵ + * >0ϲıij + * 0: ݳΪ + * -1: ûзռ + * -2: ռ䲻 + * -3:鿽ʧ + */ +INT32 PackageMsg2SndBuff(UINT8 msgCount,MsgStru msgList[], UINT16 sndBuffLen,UINT8 snddataBuff[]) +{ + UINT16 dataLen = 0u; + INT32 ret = 0; + UINT8 tmpRet =0u; + UINT8 i=0u; + UINT16 index = 0u; + UINT16 j=0u; + UINT8 chFlag = 0u; + + if ((NULL == msgList)||(NULL == snddataBuff)) + { + ret = -1; + } + else + { + + /* 1ֽ Ϣ͸ */ + snddataBuff[index++] = msgCount; + + for (i=0u;i=msgList[i].msgLen)&&(NULL != msgList[i].dataBuff)) + { + /* 1ֽ Ϣ */ + snddataBuff[index++] = msgList[i].msgType; + + /*2ֽ Ϣij */ + ShortToChar(msgList[i].msgLen,&snddataBuff[index]); + index = index+2u; + /* Ӧ */ + + tmpRet =CommonMemCpy(snddataBuff+index,(sndBuffLen-index),msgList[i].dataBuff,(UINT32)msgList[i].msgLen); + index = index+msgList[i].msgLen; + if(1u == tmpRet) + { + /* ɹ */ + ret = (INT32)index; + } + else + { + snddataBuff = NULL; + ret = -3; + chFlag = 1u; + } + } + else + { + + snddataBuff = NULL; + ret = -2; + chFlag = 1u; + } + if (1u == chFlag) + { + break; + } + else + { + ; /**/ + } + } + } + return ret; +} + + +/* + * ܣյһ֡ݷֽɶ֡ + * + * + * + UINT16 rcvDataLen ݳ + UINT8 rcvDataBuff[] + UINT8 msgListLen MSGС + MsgStru msgList[] MSG + * + MsgStru msgList[] б + * ֵ + * >0 : + * 0: ݳΪ + * -1: ûзռ + * -2: ռ䲻 + * -3:鿽ʧ + * -4:Ϣ͸һ + */ +INT16 UnPackageRcvBuff2MsgList (UINT16 rcvDataLen,UINT8 rcvDataBuff[],UINT8 msgListLen,MsgStru msgList[]) +{ + UINT8 i = 0u; + UINT16 j=0u; + UINT16 dataLen = 0u; + INT16 ret = 0; + UINT8 tmpRet =0u; + UINT8 msgCount = 0u; /* Ϣ͸*/ + UINT8 chFlag = 0u; + + if ((NULL == msgList)||(NULL == rcvDataBuff)) + { + ret = -1; + } + else + { + if(NULL != rcvDataBuff) + { + msgCount = rcvDataBuff[0u]; /* Ϣ͸*/ + if (msgCount <= msgListLen) + { + /* */ + dataLen = 1u; + ret = (INT16)msgCount; + for (i=0u;i0ϲıij + * 0: ݳΪ + * -1: ûзռ + * -2: ռ䲻 + * -3:鿽ʧ + */ +INT32 PackageMsg2SndBuff(UINT8 msgCount,MsgStru msgList[], UINT16 sndBuffLen,UINT8 snddataBuff[]); + + +/* + * ܣյһ֡ݷֽɶ֡ + * + * + * + UINT16 rcvDataLen ݳ + UINT8 rcvDataBuff[] + UINT8 msgListLen MSGС + MsgStru msgList[] MSG + * + MsgStru msgList[] б + * ֵ + * >0 : + 0:ʧܻû + */ +INT16 UnPackageRcvBuff2MsgList (UINT16 rcvDataLen,UINT8 rcvDataBuff[],UINT8 msgListLen,MsgStru msgList[]); + +#ifdef __cplusplus +} +#endif +#endif /* #ifdef */ \ No newline at end of file diff --git a/TSCP/src/commoncode/common/FFFE.c b/TSCP/src/commoncode/common/FFFE.c new file mode 100644 index 0000000..2eca17b --- /dev/null +++ b/TSCP/src/commoncode/common/FFFE.c @@ -0,0 +1,519 @@ +/************************************************************************ +* +* ļ FFFE.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.08.17 +* ؼЭ鲿 +* FFFEЭת弰ļ +* ʹע ܴijΪ65535ΪܳȵUINT16ơ +* ޸ļ¼ 20120706,FFFEPack +* +************************************************************************/ + +#include "FFFE.h" +#include "stdlib.h" + +/*FFFEת״̬*/ +#define WAIT_FF_C1 0x00u +#define WAIT_FF_C2 0x01u +#define WAIT_NO_FF 0x02u +#define WAIT_FF_POS 0x03u +#define ABNORMAL_STATE 0x04u + +/*FFFEݽ״̬*/ +#define COM_WAIT_START_FF 0x00u +#define COM_WAIT_START_FE 0x01u +#define COM_WAIT_STOP_FF 0x02u +#define COM_WAIT_STOP_FD 0x03u + +/* +* ݽFFFEת崦ͷFFFEβFFFD +* const UINT8 *pSrc (FFFEת) +* UINT16 SrcLen (FFFEת)ij +* UINT8 *pTgt (FFFEת) +* ֵ תij +*/ +UINT16 TranslateToFFFE(const UINT8 *pSrc, UINT8 *pTgt,UINT16 SrcLen) +{ + UINT16 SrcPos = 0u; + UINT16 TgtPos = 0u; + UINT16 Pos1 = 0u;/*ǰһFFλ*/ + UINT16 Pos2 = 0u;/*һFFλ*/ + UINT16 iii = 0u;/*ʱ*/ + UINT16 Gap = 0u;/*FFֽ֮*/ + UINT8 Got1stFF = 0u;/*1-ǰһFF0-δǰһFF*/ + UINT8 Got2ndFF = 0u;/*1-úһFF0-δúһFF*/ + + if ((NULL == pSrc) || (NULL == pTgt)) + { + ; /*ڲ*/ + } + else + { + + for(SrcPos=0u;SrcPos= NonFFCount) ) + { + /*252ַ֮ڴFFʧ*/ + State = ABNORMAL_STATE; + } + else + { + /*ܷFFַ*/ + pTgt[TgtPos]=Char; + TgtPos++; + + if(252u == NonFFCount) + { + NonFFCount=0u; + State = WAIT_FF_C1; + } + else + { + } + } + break; + case WAIT_FF_POS: + /*ȴFFַλ*/ + + if(0xFFu == Char) + { + /*ǰַFFַ*/ + + State = ABNORMAL_STATE; + } + else + { + /*ǰַFFַ*/ + + pTgt[TgtPos]=Char; + TgtPos++; + if(SrcPos == NextFFPos) + { + pTgt[TgtPos]=0xffu; + TgtPos++; + State = WAIT_FF_C1; + } + else + { + ; /*ִ*/ + } + } + break; + default: + State = ABNORMAL_STATE; + break; + } + if(ABNORMAL_STATE == State) + { + /*Ƿ״̬*/ + TgtPos=0u; + break; + } + else + { + } + } + + /*˳ʱ״̬ж*/ + if((WAIT_FF_C2 == State)||(WAIT_FF_POS == State)) + { + TgtPos = 0u; + } + else + { + ; /*ִ*/ + } + return TgtPos; +} + +/* +* FFFEṹʼ +* UINT16 FFFEBufferSize, ڽһ֡ݵĻ +* FFFE_STATE_STRU *pFFFEStatStru, FFFE״̬ṹ +* ֵ 0,ִʧ +* 1,ִгɹ +*/ +UINT8 FFFEInit(FFFE_STATE_STRU *pFFFEStatStru,UINT16 FFFEBufferSize) +{ + + UINT8 ret = 0u; + if (NULL == pFFFEStatStru) + { + ; /*ڲ*/ + } + else + { + /*FFFE״̬㸴λ*/ + pFFFEStatStru->RawDataRcvBufferSize = FFFEBufferSize; + pFFFEStatStru->pRawDataRcvBuf = (UINT8*)malloc(pFFFEStatStru->RawDataRcvBufferSize * sizeof(UINT8)); + if (pFFFEStatStru->pRawDataRcvBuf == NULL) + { + ret = 0u; + } + else + { + pFFFEStatStru->RcvState = COM_WAIT_START_FF; + pFFFEStatStru->GotFrame = 0u; + pFFFEStatStru->DataCount = 0u; + ret = 1u; + } + + } + + return ret; +} + +/* +* ַմתݣ֡FFFEģFFFEFFFD +* UINT8 RcvChar, ǰյַ +* PORT_STATE_STRU *pFFFEStatStru, +* UINT8 *pRawDataRcv, ݽջָ +* ֵ 0, ʾյ֡ݳȣյ֡ջ +* 0, δյ֡ݣ +*/ + +UINT16 FFFERcv(FFFE_STATE_STRU *pFFFEStatStru,UINT8 RcvChar, UINT8 *pRawDataRcv) +{ + + UINT16 ReturnVal = 0u; + UINT16 iii = 0u; + + if ((NULL == pFFFEStatStru) || (NULL == pRawDataRcv)) + { + ; /*Ϊ*/ + } + else + { + + /*н״̬*/ + switch(pFFFEStatStru->RcvState) + { + case COM_WAIT_START_FF: + + /*ȴտʼFF״̬*/ + if(0xFFu != RcvChar) + { + + } + else + { + pFFFEStatStru->RcvState = COM_WAIT_START_FE; + } + break; + case COM_WAIT_START_FE: + + /*ȴտʼFE״̬*/ + if(0xFEu != RcvChar) + { + pFFFEStatStru->RcvState = COM_WAIT_START_FF; + } + else + { + pFFFEStatStru->DataCount = 0u; + pFFFEStatStru->GotFrame = 0u; + pFFFEStatStru->RcvState = COM_WAIT_STOP_FF; + } + break; + case COM_WAIT_STOP_FF: + + /*ȴֹͣFF״̬*/ + if(0xFFu == RcvChar) + { + pFFFEStatStru->RcvState = COM_WAIT_STOP_FD; + } + else + { + + if(pFFFEStatStru->DataCount >= pFFFEStatStru->RawDataRcvBufferSize) + { + pFFFEStatStru->DataCount = 0u; + pFFFEStatStru->GotFrame = 0u; + pFFFEStatStru->RcvState = COM_WAIT_START_FF; + } + else + { + pFFFEStatStru->pRawDataRcvBuf[pFFFEStatStru->DataCount] = RcvChar; + pFFFEStatStru->DataCount++; + + } + } + break; + case COM_WAIT_STOP_FD: + + /*ȴֹͣFD״̬*/ + switch(RcvChar) + { + case 0xFFu: + pFFFEStatStru->DataCount = 0u; + pFFFEStatStru->GotFrame = 0u; + pFFFEStatStru->RcvState = COM_WAIT_START_FF; + break; + case 0xFEu: + pFFFEStatStru->DataCount = 0u; + pFFFEStatStru->GotFrame = 0u; + pFFFEStatStru->RcvState = COM_WAIT_STOP_FF; + break; + case 0xFDu: + pFFFEStatStru->GotFrame = 1u; + pFFFEStatStru->RcvState = COM_WAIT_START_FF; + break; + default: + + if(pFFFEStatStru->DataCount >= (pFFFEStatStru->RawDataRcvBufferSize-1u)) + { + pFFFEStatStru->DataCount = 0u; + pFFFEStatStru->GotFrame = 0u; + pFFFEStatStru->RcvState = COM_WAIT_START_FF; + } + else + { + pFFFEStatStru->pRawDataRcvBuf[pFFFEStatStru->DataCount] = 0xFFu; + pFFFEStatStru->DataCount++; + pFFFEStatStru->pRawDataRcvBuf[pFFFEStatStru->DataCount] = RcvChar; + pFFFEStatStru->DataCount++; + pFFFEStatStru->RcvState = COM_WAIT_STOP_FF; + } + break; + } + break; + default: + break; + } + + /*յ֡*/ + if(1u == pFFFEStatStru->GotFrame) + { + for(iii=0u; iiiDataCount; iii++) + { + pRawDataRcv[iii] = pFFFEStatStru->pRawDataRcvBuf[iii]; + } + + ReturnVal = pFFFEStatStru->DataCount; + pFFFEStatStru->DataCount = 0u; + pFFFEStatStru->GotFrame = 0u; + } + else + { + } + } + return ReturnVal; +} + +/* +* FFFE״̬ +* PORT_STATE_STRU *pFFFEStatStru, FFFE״̬ṹ +* ֵ +*/ +void FFFEFree(FFFE_STATE_STRU *pFFFEStatStru) +{ + if (NULL == pFFFEStatStru) + { + ; /*ڲ*/ + } + else + { + /*FFFE*/ + free(pFFFEStatStru->pRawDataRcvBuf); + pFFFEStatStru->pRawDataRcvBuf = NULL; + + } + +} + + +/* +* ݽFFFEת崦,ͷFFFEβFFFD +* const UINT8 *pSrc (FFFEת) +* UINT16 SrcLen (FFFEת)ij +* UINT8 *pTgt (FFFEת),FFFEͷFFFDβ +* ֵ תij +*/ +UINT16 FFFEPack(const UINT8 *pSrc, UINT8 *pTgt,UINT16 SrcLen) +{ + UINT16 PackDataLen=0u; + + if ((NULL == pSrc) || (NULL == pTgt)) + { + ; /*ڲ*/ + } + else + { + + /*FFFEͷ*/ + pTgt[PackDataLen] = 0xFFu; + PackDataLen++; + pTgt[PackDataLen] = 0xFEu; + PackDataLen++; + + /*ת*/ + PackDataLen += TranslateToFFFE(pSrc, pTgt + PackDataLen, SrcLen); + + /*FFFDβ*/ + pTgt[PackDataLen] = 0xFFu; + PackDataLen++; + pTgt[PackDataLen] = 0xFDu; + PackDataLen++; + + } + return PackDataLen; + + +} + diff --git a/TSCP/src/commoncode/common/FFFE.h b/TSCP/src/commoncode/common/FFFE.h new file mode 100644 index 0000000..1b7e59b --- /dev/null +++ b/TSCP/src/commoncode/common/FFFE.h @@ -0,0 +1,91 @@ +/************************************************************************ +* +* ļ FFFE.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.08.17 +* ؼЭ鲿 +* FFFEЭת弰ļ +* ʹע 1.ܴijΪ65535ΪܳȵUINT16ơ +* ޸ļ¼ +* +************************************************************************/ +#ifndef _FFFE_H +#define _FFFE_H + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + UINT8 *pRawDataRcvBuf;/*δתݽջ*/ + UINT16 RawDataRcvBufferSize;/*δתݽջС*/ + UINT8 RcvState ;/*FFFEݽ״̬*/ + UINT8 GotFrame ;/*FFFEǷյ֡*/ + UINT16 DataCount ;/* յ֮֡ǰյFFFEܳȣÿյ֡*/ +}FFFE_STATE_STRU; + +/* +* ݽFFFEת崦ͷFFFEβFFFD +* const UINT8 *pSrc (FFFEת) +* UINT16 SrcLen (FFFEת)ij +* UINT8 *pTgt (FFFEת) +* ֵ תij +*/ +UINT16 TranslateToFFFE(const UINT8 *pSrc, UINT8 *pTgt,UINT16 SrcLen); + + +/* +* FFFEת崦ݣѾȥͷFFFEβFFFDԭΪԭʼ +* const UINT8 *pSrc, (FFFEת) +* UINT16 SrcLen, (FFFEת)ij +* UINT8 *pTgt, (ȥFFFEת) +* ֵ 0, תɹ,תݳ +* 0, вתַתʧܡתݳΪ0 +*/ +UINT16 TranslateFromFFFE(const UINT8 *pSrc,UINT8 *pTgt,UINT16 SrcLen); + +/* +* FFFEṹʼ +* UINT16 FFFEBufferSize, ڽһ֡ݵĻ +* PORT_STATE_STRU *pFFFEStatStru, FFFE״̬ṹ +* ֵ 0,ִʧ +* 1,ִгɹ +*/ +UINT8 FFFEInit(FFFE_STATE_STRU *pFFFEStatStru,UINT16 FFFEBufferSize); + +/* +* ַմתݣ֡FFFEģFFFEFFFD +* UINT8 RcvChar, ǰյַ +* PORT_STATE_STRU *pFFFEStatStru, +* UINT8 *pRawDataRcv, ݽջָ +* ֵ 0, ʾյ֡ݳȣյ֡ջ +* 0, δյ֡ݣ +*/ + +UINT16 FFFERcv(FFFE_STATE_STRU *pFFFEStatStru,UINT8 RcvChar, UINT8 *pRawDataRcv); + +/* +* FFFE״̬ +* PORT_STATE_STRU *pFFFEStatStru, FFFE״̬ṹ +* ֵ +*/ +void FFFEFree(FFFE_STATE_STRU *pFFFEStatStru); + +/* +* ݽFFFEת崦,ͷFFFEβFFFD +* const UINT8 *pSrc (FFFEת) +* UINT16 SrcLen (FFFEת)ij +* UINT8 *pTgt (FFFEת),FFFEͷFFFDβ +* ֵ תij +*/ +UINT16 FFFEPack(const UINT8 *pSrc, UINT8 *pTgt,UINT16 SrcLen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/commoncode/common/Translate0203.c b/TSCP/src/commoncode/common/Translate0203.c new file mode 100644 index 0000000..5a9ce20 --- /dev/null +++ b/TSCP/src/commoncode/common/Translate0203.c @@ -0,0 +1,153 @@ +/******************************************************** +* +* ļ Translate0203.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2008.07.29 +* ؼЭ鲿 +* 0203ת崦 +* ޸ļ¼ +* +********************************************************/ + +#include "Translate0203.h" + +/*********************************************************** +* vobcTranslateTo0203 +* ; ݽ0203ת崦 +* ܴijΪ65535ΪܳȵUINT16ơ +* UINT8 *pSrc, ԭʼ; +* UINT8 *pTgt, ת; +* UINT16 SrcLen, ԭʼݳ +* ֵ תij +***********************************************************/ +UINT16 TranslateTo0203(const UINT8 *pSrc, UINT8 *pTgt,UINT16 SrcLen) +{ + UINT16 i = 0u;/*ѭ*/ + UINT16 j = 0u;/*תij*/ + + /* ӿͷ */ + *(pTgt+j) = (UINT8)0x02; + j++; + + /* ת */ + for(i=0u;i= SrcLen) + { + chFlag = 1u; + } + if ((UINT8)0x10 == *(pSrc + k)) + { + /* ҳ0x10жǷת壬ת */ + + /*Ųָ뵽һ*/ + k++; + + if (k == SrcLen) + { + /*0x10һַش*/ + j = 0u; + chFlag = 1u; + } + else + { + /*һַ0x10*/ + } + + if (((UINT8)0x82u != *(pSrc + k)) && ((UINT8)0x83u != *(pSrc + k)) && ((UINT8)0x90u != *(pSrc + k))) + { + /* 0x10Ƿ(0x82, 0x83, 0x90)ַ޷ת壬ת*/ + j = 0u; + chFlag = 1u; + } + else + { + } + + /*10828390Ҫֽڽת*/ + *(pTgt + j) = *(pSrc + k) - (UINT8)0x80u; + } + else + { + /*ת壬ֱӿ*/ + *(pTgt + j) = *(pSrc + k); + } + if (1u == chFlag) + { + break; + } + else + { + j++; + k++; + } + } + } + + + /*תݳȻ޷ת*/ + return j; +} diff --git a/TSCP/src/commoncode/common/Translate0203.h b/TSCP/src/commoncode/common/Translate0203.h new file mode 100644 index 0000000..a5218c2 --- /dev/null +++ b/TSCP/src/commoncode/common/Translate0203.h @@ -0,0 +1,55 @@ +/******************************************************** +* +* ļ Translate0203.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2008.07.29 +* ؼЭ鲿 +* 0203ת崦 +* ޸ļ¼ +* +********************************************************/ + +#ifndef _VOBC_TRANSLATE0203_H +#define _VOBC_TRANSLATE0203_H + + + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************** +* vobcTranslateTo0203 +* ; ݽ0203ת崦 +* ܴijΪ65535ΪܳȵUINT16ơ +* UINT8 *pSrc, ԭʼ; +* UINT8 *pTgt, ת; +* UINT16 SrcLen, ԭʼݳ +* ֵ תij +***********************************************************/ +UINT16 TranslateTo0203(const UINT8 *pSrc, UINT8 *pTgt,UINT16 SrcLen); + + +/*********************************************************** +* vobcTranslateFrom0203 +* ; 0203ת崦ݻԭΪԭʼ +* ܴijΪ65535ΪܳȵUINT16ơ +* UINT8 *pSrc, ת; +* UINT8 *pTgt, ԭʼ; +* UINT16 SrcLen, תݳ +* ֵ 0תɹ,ԭʼݳ +* 0вתַ(0x10ַ0x82, 0x83, 0x90)δת塣 +* ʹע⣺֡ģ飬0x02,0x03Ĵݡ +* ˴ǵЧ⣬δ0x02,0x03д +***********************************************************/ +UINT16 TranslateFrom0203(const UINT8 *pSrc, UINT8 *pTgt,UINT16 SrcLen); + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/commoncode/common/VobcNetPack.c b/TSCP/src/commoncode/common/VobcNetPack.c new file mode 100644 index 0000000..dbaf512 --- /dev/null +++ b/TSCP/src/commoncode/common/VobcNetPack.c @@ -0,0 +1,143 @@ +/******************************************************** +* +* ļ VobcNetPack.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2008.07.29 +* ؼЭ鲿 +* vobcϢЭ麯 +* ޸ļ¼ +* +********************************************************/ + +#include "VobcNetPack.h" +#include "Convert.h" +#include "CRC32.h" + +/* +* Ϣ +* ˵ IN UINT8 DataType +* IN UINT32 Seq, к +* IN const UINT8 *pData,Ӧ +* IN UINT16 DataLen, Ӧݳ +* OUT UINT8 *pPackData, ָ +* ֵ Ϣݳ +* ޸ļ¼ ޸Ʒ׺мɲȱBug-2012,hc,20200218 +*/ +UINT16 VobcNetPack(IN UINT8 DataType,IN UINT32 Seq,IN const UINT8 *pData, IN UINT16 DataLen,OUT UINT8 *pPackData) +{ + UINT16 PackDataLen= 0u; + UINT8 *pPack=pPackData; + UINT32 CRCValue = 0u; + UINT16 tempLen = 0u; + UINT16 i = 0u; + + if((NULL != pData) && (NULL != pPackData)) + { + /*ݸֵ*/ + PackDataLen = DataLen + 11u; + + /*ݳ2ֽ*/ + tempLen=PackDataLen-2u; + ShortToChar(tempLen,pPack); + pPack+=2u; + + /**/ + *pPack=DataType; + pPack+=1u; + + /*к,4ֽ*/ + LongToChar(Seq,pPack); + pPack+=4u; + + + /*Ӧ*/ + for(i=0u;i0, ݳ +* 0, ʾ,߽ݳΪ0 +* ޸ļ¼ ޸Ʒ׺мɲȱBug-2012,hc,20200218 +*/ +UINT16 VobcNetUnpack(IN const UINT8 *pPackData,IN const UINT16 PackDataLen,OUT UINT8 *pDataType,OUT UINT32 *pSeq,OUT UINT8 *pData) +{ + UINT16 DataLen=PackDataLen-11u; + UINT8 *pData1=pData; + const UINT8 *pPackData1=pPackData; + UINT32 PackCRCValue = 0u; + UINT32 CalcCRCValue = 0u; + UINT16 tempLen = 0u; + UINT16 i = 0u; + + + /*жݳǷȷ*/ + if ((NULL != pPackData) && (NULL != pDataType) && (NULL != pSeq) && (NULL != pData)) + { + tempLen = ShortFromChar(pPackData1); + pPackData1 += 2u; + if ((tempLen + 2u) == PackDataLen) + { + /*ԼõCRC32*/ + tempLen = PackDataLen - 4u; + CalcCRCValue = Crc32(pPackData, (UINT32)tempLen); + + /*ȡcrc32*/ + PackCRCValue = LongFromChar((const UINT8 *)(pPackData + PackDataLen - 4u)); + + if (CalcCRCValue == PackCRCValue) + { + /**/ + *pDataType = *pPackData1; + pPackData1 += 1u; + + /*к*/ + *pSeq = LongFromChar(pPackData1); + pPackData1 += 4u; + + /*Ӧ*/ + for (i = 0u; i < DataLen; i++) + { + *pData1 = *pPackData1; + pData1++; + pPackData1++; + } + } + else + { + /*ʧ,CRC*/ + DataLen = 0u; + } + } + else + { + DataLen = 0u; + } + + } + else + { + /*ڲδͨ0*/ + DataLen=0u; + } + + return DataLen; +} diff --git a/TSCP/src/commoncode/common/VobcNetPack.h b/TSCP/src/commoncode/common/VobcNetPack.h new file mode 100644 index 0000000..93bb93d --- /dev/null +++ b/TSCP/src/commoncode/common/VobcNetPack.h @@ -0,0 +1,53 @@ + +/************************************************************************ + +* ļ VobcNetPack.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.08.21 +* ؼЭ鲿 +* vobcϢЭ麯 +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _VOBCNETPACK_H_ +#define _VOBCNETPACK_H_ + +#include "CommonTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +* Ϣ +* ˵ IN UINT8 DataType +* IN UINT32 Seq, к +* IN const UINT8 *pData,Ӧ +* IN UINT16 DataLen, Ӧݳ +* OUT UINT8 *pPackData, ָ +* ֵ Ϣݳ +*/ +UINT16 VobcNetPack(IN UINT8 DataType,IN UINT32 Seq,IN const UINT8 *pData, IN UINT16 DataLen,OUT UINT8 *pPackData); + +/* +* Ϣ +* ˵ IN const UINT8 *pPackData, +* IN const UINT16 PackDataLen, ݳ +* OUT UINT8 *pDataType, +* OUT UINT32 *pSeq, к +* OUT UINT8 *pData, Ӧ +* ֵ >0, ݳ +* 0, ʾ,߽ݳΪ0 +*/ +UINT16 VobcNetUnpack(IN const UINT8 *pPackData,IN const UINT16 PackDataLen,OUT UINT8 *pDataType,OUT UINT32 *pSeq,OUT UINT8 *pData); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/commoncode/commoncode_config_vxworks/CommonConfig.h b/TSCP/src/commoncode/commoncode_config_vxworks/CommonConfig.h new file mode 100644 index 0000000..620413a --- /dev/null +++ b/TSCP/src/commoncode/commoncode_config_vxworks/CommonConfig.h @@ -0,0 +1,37 @@ + +/************************************************************************ +* +* 文件名 : CommonConfig.h +* 版权说明 : 北京瑞安时代科技有限责任公司 +* 版本号 : 1.0 +* 创建时间 : 2009.11.21 +* 作者 : 车载及协议部 +* 功能描述 : cbtc公共函数配置文件. +* 使用注意 : +* 修改记录 : +* +************************************************************************/ + + +#ifndef _COMMONCONFIG_H_ +#define _COMMONCONFIG_H_ + +/*测试平台宏定义*/ +#define CBTC_UNITTEST +#define CBTC_INTTEST + +/*CBTC系统平台定义*/ +#define kWINDOWS 0 +#define kMOTOROLA 1 +#define kVXWORKS 2 + +/*在这里定义应用平台*/ +/***********************************************************/ +#ifdef WIN32 +#define kPLATFORM kWINDOWS +#else +#define kPLATFORM kVXWORKS +#endif +/***********************************************************/ + +#endif /* _COMMONCONFIG_H_ */ diff --git a/TSCP/src/dqu_common/dqu_cbtc_common/dquCbtcConfigData.c b/TSCP/src/dqu_common/dqu_cbtc_common/dquCbtcConfigData.c new file mode 100644 index 0000000..e27d6f6 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_cbtc_common/dquCbtcConfigData.c @@ -0,0 +1,1343 @@ +/************************************************************************ +* +* ļ +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ϵͳݽṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "dquCbtcConfigData.h" +#include "dfsDataRead.h" +#include "CbtcVersion.h" +#include "dquCbtcType.h" + +static CBTC_CFG_DATA_STRU *qds_dsuCbtcConfigDataStru=NULL;/*CBTCϢòѯԴ*/ +static CBTC_CFG_DATA_STRU *g_pCbtcConfigDataStru=NULL; /*ָʼݿָ*/ + +static dfsDataHead g_DFsDH; /*FSļͷṹ*/ +static UINT8* g_pDataAddr; /*FSԪݵַ*/ +static UINT32 g_DataSize; /*FSԪݴСֽ*/ +static UINT16 g_RowCount; /**/ + +static UINT16 g_wCurInitStruProg=0U;/*ǰṹʼֲ̣ʱʹ*/ +static UINT16 g_wCurMainIndex=0U; /*ǰֲʱʹ*/ + +/*----------ڲʼ--------------*/ + +/*г1*/ +UINT8 dfsInitTrainModelConfigData(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); +/*гܲýṹ2*/ +UINT8 dfsInitTrainPerformConfigData(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); +/*ϵͳýṹ3-CPK*/ +UINT8 dfsInitSubSystemCommonConfigData_CPK(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); +/*ϵͳýṹ3-FAO*/ +UINT8 dfsInitSubSystemCommonConfigData_FAO(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); +/*ϵͳýṹ3-HLTݻͨݽṹV12.0.0޸ģmodify by lmy 20180314*/ +UINT8 dfsInitSubSystemCommonConfigData_HLT(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); +/*ϵͳýṹ3-DGݻͨݽṹV12.0.0޸ĺDGHLTʹͬijʼӴ˺add by lmy 20180312*/ +UINT8 dfsInitSubSystemCommonConfigData_DG(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); +/*ʼ[ϵͳ]-CC(Ҫҽ1)*/ +UINT8 dfsInitSubSystemCommonConfigData_CC(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); +/*ݽṹ4-FAO ͨ˰汾һ*/ +UINT8 dfsInitTrainDepotConfigData(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); +/* ߽ݽṹ */ +UINT8 dfsInitBoundaryAxleConfigData(UINT8* pDataAddr, UINT32 dataSize, UINT16 rowCount); +/*ݰ汾ݴ̺*/ +static UINT8 initConfigCbtcInfoTaskTab(void); + + +/*----------ڲ--------------*/ + +/*ʼǼDZ*/ +static INIT_TASK_TAB_STRU g_struInitTaskTab[]= +{ + {DQU_QFUN_TRUE, CBTC_TRAIN_TYPE_CONFIG_ID, dfsInitTrainModelConfigData, 5,1,0}, + {DQU_QFUN_TRUE, CBTC_TRAIN_INFO_ID, dfsInitTrainPerformConfigData, 5,1,0}, + {DQU_QFUN_TRUE, CBTC_CONFIG_DATA_ID, dfsInitSubSystemCommonConfigData_CPK,5,1,0}, + {DQU_QFUN_TRUE, CBTC_CONFIG_DATA_ID, dfsInitSubSystemCommonConfigData_FAO,5,1,0}, + {DQU_QFUN_TRUE, CBTC_CONFIG_DATA_ID, dfsInitSubSystemCommonConfigData_HLT,5,1,0}, + {DQU_QFUN_TRUE, CBTC_CONFIG_DATA_ID, dfsInitSubSystemCommonConfigData_DG, 5,1,0}, + {DQU_QFUN_TRUE, CBTC_CONFIG_DEPOT_ID, dfsInitTrainDepotConfigData, 5,1,0}, + {DQU_QFUN_TRUE, CBTC_CONFIG_DATA_ID, dfsInitSubSystemCommonConfigData_CC, 5,1,0}, + {DQU_QFUN_TRUE, CBTC_CONFIG_BOUNDARY_AXLE_ID,dfsInitBoundaryAxleConfigData, 5,1,0}, +}; +/*ʼǼDZĿ*/ +static const UINT16 MAX_INITTASK_COUNT=sizeof(g_struInitTaskTab)/sizeof(INIT_TASK_TAB_STRU); + +/********************************************* +*ܣϵͳݰ汾Żȡ +*˵ϵͳòѯ汾ţֹɴ +*ڲ +*ڲ +*ֵUINT32ʾİ汾 +*********************************************/ +UINT32 GetDquCbtcVersion(void) +{ + UINT32 dquCbtcVer=0U; + dquCbtcVer = VerToU32SoftwareModule(DQU_CBTC_VER1,DQU_CBTC_VER2,DQU_CBTC_VER3,DQU_CBTC_VER4); + return dquCbtcVer; +} + +/*CBTCϢ*/ +UINT8 dquSetInitCbtcConfigInfoRef(CBTC_CFG_DATA_STRU *pCbtcConfigDataStru) +{ + UINT8 bRetVal=0U; + if (NULL!=pCbtcConfigDataStru) + { + g_pCbtcConfigDataStru=pCbtcConfigDataStru; + bRetVal=1U; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + +/*ݰ汾ݴ̺*/ +/*עݻͨݽṹV12.0.0޸ģmodify by lmy 20180312*/ +static UINT8 initConfigCbtcInfoTaskTab(void) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + + cbtcVersionType = GetCbtcSysType(); + if (DQU_CBTC_CPK == cbtcVersionType)/*Ͽ⹦*/ + { + g_struInitTaskTab[3].bIsEffective=DQU_QFUN_FASLE;/*ϿĬϲִУϵͳýṹ3-FAO*/ + g_struInitTaskTab[4].bIsEffective=DQU_QFUN_FASLE;/*ϿĬϲִУϵͳýṹ3-HLT*/ + g_struInitTaskTab[5].bIsEffective=DQU_QFUN_FASLE;/*ϿĬϲִУϵͳýṹ3-DG*/ + g_struInitTaskTab[6].bIsEffective=DQU_QFUN_FASLE;/*ϿĬϲִУ*/ + g_struInitTaskTab[7].bIsEffective = DQU_QFUN_FASLE;/*ϿĬϲִУ*/ + g_struInitTaskTab[8].bIsEffective = DQU_QFUN_FASLE;/*ϿĬϲִУ߽*/ + rtnValue = 1; + } + else if (DQU_CBTC_FAO == cbtcVersionType) /*FAO*/ + { + g_struInitTaskTab[2].bIsEffective=DQU_QFUN_FASLE;/*FAOĬϲִУϵͳýṹ3-CPK*/ + g_struInitTaskTab[4].bIsEffective=DQU_QFUN_FASLE;/*FAOĬϲִУϵͳýṹ3-HLT*/ + g_struInitTaskTab[5].bIsEffective=DQU_QFUN_FASLE;/*FAOĬϲִУϵͳýṹ3-DG*/ + g_struInitTaskTab[7].bIsEffective = DQU_QFUN_FASLE;/*ϿĬϲִУ*/ + g_struInitTaskTab[8].bIsEffective = DQU_QFUN_FASLE;/*ϿĬϲִУ߽*/ + rtnValue = 1; + } + else if(DQU_CBTC_HLT == cbtcVersionType) /*ͨ*/ + { + g_struInitTaskTab[2].bIsEffective=DQU_QFUN_FASLE;/*ͨĬϲִУϵͳýṹ3-CPK*/ + g_struInitTaskTab[3].bIsEffective=DQU_QFUN_FASLE;/*ͨĬϲִУϵͳýṹ3-FAO*/ + g_struInitTaskTab[5].bIsEffective=DQU_QFUN_FASLE;/*ͨĬϲִУϵͳýṹ3-DG*/ + g_struInitTaskTab[7].bIsEffective = DQU_QFUN_FASLE;/*ϿĬϲִУ*/ + g_struInitTaskTab[8].bIsEffective = DQU_QFUN_FASLE;/*ϿĬϲִУ߽*/ + rtnValue = 1; + } + else if(DQU_CBTC_DG == cbtcVersionType)/*칦*/ + { + g_struInitTaskTab[2].bIsEffective=DQU_QFUN_FASLE;/*DGĬϲִУϵͳýṹ3-CPK*/ + g_struInitTaskTab[3].bIsEffective=DQU_QFUN_FASLE;/*DGĬϲִУϵͳýṹ3-FAO*/ + g_struInitTaskTab[4].bIsEffective=DQU_QFUN_FASLE;/*DGĬϲִУϵͳýṹ3-HLT*/ + g_struInitTaskTab[7].bIsEffective = DQU_QFUN_FASLE;/*ϿĬϲִУ*/ + g_struInitTaskTab[8].bIsEffective = DQU_QFUN_FASLE;/*ϿĬϲִУ߽*/ + rtnValue = 1; + } + else if (DQU_CBTC_CC == cbtcVersionType)/**/ + { + g_struInitTaskTab[2].bIsEffective = DQU_QFUN_FASLE;/*ĬϲִУϵͳýṹ3-CPK*/ + g_struInitTaskTab[3].bIsEffective = DQU_QFUN_FASLE;/*ĬϲִУϵͳýṹ3-FAO*/ + g_struInitTaskTab[4].bIsEffective = DQU_QFUN_FASLE;/*ĬϲִУϵͳýṹ3-HLT*/ + g_struInitTaskTab[5].bIsEffective = DQU_QFUN_FASLE;/*ĬϲִУϵͳýṹ3-DG*/ + rtnValue = 1; + } + else /*δֵð汾ֵδñ־λ*/ + { + rtnValue = 0U; + } + + return rtnValue; +} + +/*ϵͳݳʼ*/ +UINT8 dquCbtcConfigDataInit(CHAR* FSName) +{ + UINT16 wIndex=0U; + UINT8 funcRtn = 0U; + UINT8 rtnValue = 0U; + UINT32 DataID=0U;/*ͱʶ*/ + UINT8 *pDataAddr=NULL; + UINT32 DataSize=0U; + UINT16 rowCount = 0U; + + if((NULL!=g_pCbtcConfigDataStru) && (NULL!=FSName)) + { + rtnValue = 1U; + funcRtn = dataRead(FSName); + /*ȡFSļ,֤ļ*/ + if(1 != funcRtn) + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + else + { + /*ݰ汾ݴ̺*/ + funcRtn =initConfigCbtcInfoTaskTab(); + if (0U == funcRtn) + { + rtnValue = 0U; + } + } + if ( 1U == rtnValue) + { + /*ʼ*/ + wIndex = 0; + do /*ݵӦĽṹ*/ + { + if (DQU_QFUN_TRUE == g_struInitTaskTab[wIndex].bIsEffective)/*жʼǷִ*/ + { + /*ȡ*/ + DataID = g_struInitTaskTab[wIndex].DataTypeId; + funcRtn = dquGetConfigDataNew(FSName, CBTC_CONFIGDATA_TYPE, DataID, &pDataAddr, &DataSize, &rowCount); + if (1U != funcRtn) + { + /*ȡʧ*/ + rtnValue = 0U; + return rtnValue; + } + funcRtn = g_struInitTaskTab[wIndex].pExeFun(pDataAddr, DataSize, rowCount); + if (1U != funcRtn) + { + rtnValue = 0U; + return rtnValue; + } + else/*ִ*/ + { + /*no thing todo*/ + } + } + + wIndex++; + } while (wIndex < MAX_INITTASK_COUNT); + + /*Ĭϵô˽ӿԶѯԴ*/ + rtnValue = dquSetCurCbtcCfgInfoQueryDataSource(g_pCbtcConfigDataStru); + } + } + else + { + rtnValue = 0U; + } + + return rtnValue; + +} + +#if 0 +/*ŶձʼϣִбŶձڲ*/ +UINT8 dfsuCbtcConfigInitFinally(void) +{ + UINT16 wIndex=0U; + UINT8 bRetVal=0U; + + g_wCurInitStruProg=0x0;/*ǰṹʼֲ̣ʱʹ*/ + g_wCurMainIndex=0; /*ǰֲʱʹ*/ + + bRetVal=1; + return bRetVal; +} +#endif + +/*---------------ݽ-------------------------*/ + +/********************************************** +ܣʼ[гñ] +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:1ɹ,0ʧ +**********************************************/ +UINT8 dfsInitTrainModelConfigData(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + UINT32 i =0U; + static UINT32 rowDataLen = 0U; + UINT8 *pData = pDataAddr; + + g_pCbtcConfigDataStru->TrainTypeConfigLen = rowCount; + if (NULL != pDataAddr) + { + if (rowCount > 0) + { + rowDataLen = dataSize / rowCount; + + for (i = 0; icbtcTrainTypeConfig[i].TrainName = ShortFromChar(pData); + pData += 2; + + g_pCbtcConfigDataStru->cbtcTrainTypeConfig[i].TrainType = *pData; + pData += 1; + } + } + rtnValue = 1; + } + else + { + /*׵ַָΪ*/ + rtnValue = 0U; + } + return rtnValue; +} + +/********************************************** +ܣʼ[гܲ] +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:1ɹ,0ʧ +**********************************************/ +UINT8 dfsInitTrainPerformConfigData(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + UINT32 i =0U; + UINT32 rowDataLen=0U; + UINT8 *pData = pDataAddr; + + if (NULL != pDataAddr) + { + g_pCbtcConfigDataStru->TrainInfoLen = rowCount; + + if (rowCount > 0) + { + rowDataLen = dataSize / rowCount; + + for (i = 0; icbtcTrainInfo[i].TrainType = *pData; + pData += 1; + /*г*/ + g_pCbtcConfigDataStru->cbtcTrainInfo[i].TrainLength = ShortFromChar(pData); + pData += 2; + /*гǣٶ*/ + g_pCbtcConfigDataStru->cbtcTrainInfo[i].TrainMaxTracAcc = *pData; + pData += 1; + /*·¶*/ + g_pCbtcConfigDataStru->cbtcTrainInfo[i].WorstGrade = ShortFromChar(pData); + pData += 2; + } + } + + rtnValue = 1; + + } + else + { + /*׵ַָΪ*/ + rtnValue = 0U; + } + return rtnValue; +} + +/********************************************** +ܣʼ[ϵͳ]-CPK(Ҫҽ1) +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:1ɹ,0ʧ +**********************************************/ +UINT8 dfsInitSubSystemCommonConfigData_CPK(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + + if ((NULL != pDataAddr) && (1 == rowCount)) + { + /*ݽṹ*/ + /*·*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed = *pDataAddr; + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed=(UINT16)(27.77778*g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed+0.5); + pDataAddr += 1; + + /*ʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrSpeed = *pDataAddr; + pDataAddr += 1; + + /*NTPУʱʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.TimeZoneDifference = *pDataAddr; + pDataAddr += 1; + + /*ȫ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MABackDistance = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*VOBCZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*һʱٵ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrNum = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*һʱٱа߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxSectionOfTsr = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*DSUZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.DsuZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCCIͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcCiCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*DSUATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.DsuAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCCIͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcCiCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxOverlapLength = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ciciͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CICICommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-vobcͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiVobcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + g_pCbtcConfigDataStru->cbtcConfigData.CiZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*Ϊatsʾһֶ---Ϲѧ2012-12-17*/ + /*link߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.LinkLogicDirUpAndDown = *pDataAddr; + pDataAddr += 1; + + /*ATO׼ͣMAȣԺϿݽṹV16.0.0ϵͳݸϵͳֶΡATO׼ͣMAȡadd by my 20170220*/ + g_pCbtcConfigDataStru->cbtcConfigData.MALengthForATOParking = ShortFromChar(pDataAddr); + pDataAddr += 2; + + rtnValue = 1; + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ϵͳ]-FAO(Ҫҽ1) +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:1ɹ,0ʧ +**********************************************/ +UINT8 dfsInitSubSystemCommonConfigData_FAO(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + + if ((NULL != pDataAddr) && (1 == rowCount)) + { + /*ݽṹ*/ + /*·*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed = *pDataAddr; + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed=(UINT16)(27.77778*g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed+0.5); + pDataAddr += 1; + + /*ʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrSpeed = *pDataAddr; + pDataAddr += 1; + + /*NTPУʱʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.TimeZoneDifference = *pDataAddr; + pDataAddr += 1; + + /*ȫ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MABackDistance = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*VOBCZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*һʱٵ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrNum = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*һʱٱа߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxSectionOfTsr = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*DSUZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.DsuZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCCIͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcCiCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*DSUATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.DsuAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCCIͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcCiCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxOverlapLength = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ciciͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CICICommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-vobcͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiVobcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-zcͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-psdͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiPsdCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*link߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.LinkLogicDirUpAndDown = *pDataAddr; + pDataAddr += 1; + + rtnValue = 1; + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ϵͳ]-HLT(Ҫҽ1) +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:1ɹ,0ʧ +**********************************************/ +UINT8 dfsInitSubSystemCommonConfigData_HLT(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + UINT8 i = 0U; + + if ((NULL != pDataAddr) && (1 == rowCount)) + { + /*ݽṹ*/ + /*·*/ +#if 0 + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed = *pDataAddr; + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed=(UINT16)((27.77778) * g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed + (0.5)); + pDataAddr += 2; + + /*ʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrSpeed = *pDataAddr; + pDataAddr += 1; + + /*NTPУʱʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.TimeZoneDifference = *pDataAddr; + pDataAddr += 1; + + /*ȫ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MABackDistance = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*VOBCZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; +#endif + /*RC13.0ZCӿʹò*/ + /*һʱٵ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrNum = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*һʱٱа߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxSectionOfTsr = ShortFromChar(pDataAddr); + pDataAddr += 2; +#if 0 + /*DSUZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.DsuZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCCIͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcCiCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*DSUATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.DsuAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCCIͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcCiCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ϵͳ󱣻γ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxOverlapLength = ShortFromChar(pDataAddr); + pDataAddr += 2; +#endif + /*ciciͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CICICommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-vobcͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiVobcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-zcͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-psdͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiPsdCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*Ϊatsʾһֶ---Ϲѧ2012-12-17*/ + /*link߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.LinkLogicDirUpAndDown = *pDataAddr; + pDataAddr += 1; +#if 0 + g_pCbtcConfigDataStru->cbtcConfigData.SpanLineNum=ShortFromChar(pDataAddr); /*Ч·ͨ add by qxt 20160811*/ + pDataAddr += 2; + + for (i=0;i<4;i++ ) + { + g_pCbtcConfigDataStru->cbtcConfigData.LineID[i]=*pDataAddr; /*·ţͨ add by qxt 20160811*/ + pDataAddr += 1; + g_pCbtcConfigDataStru->cbtcConfigData.OverlapLineLogDirUpAndDown[i]=*pDataAddr; /*صڸ·ϵͳ߼зĹϵͨ add by qxt 20160811*/ + pDataAddr += 1; + } + + /*ж(cm/s)ݻͨݽṹV12.0.0ӣadd by lmy 20180314*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZeroSpeedThreshold = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ATO׼ͣMAȣݻͨݽṹV12.0.0ӣadd by lmy 20180314*/ + g_pCbtcConfigDataStru->cbtcConfigData.MALengthForATOParking = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ԤŸֵ MS=MagneticSteel NZ=NeutralZoneݻͨݽṹV13.0.0ӣadd by sds 20180614*/ + g_pCbtcConfigDataStru->cbtcConfigData.StartDistanceOfMSToNZ = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ͨFAOӿڼֶΣݻͨݽṹV13.0.0ӣadd by sds 20180614*/ + g_pCbtcConfigDataStru->cbtcConfigData.CompatibleOfHLHTFAO = *pDataAddr; + pDataAddr += 1; + + /*Ƿֶ̬ΣݻͨݽṹV13.0.0ӣadd by sds 20180625*/ + g_pCbtcConfigDataStru->cbtcConfigData.ValueOfLineDynamicTest = *pDataAddr; + pDataAddr += 1; + + /*ǷVOBCMAϰ,ݻͨݽṹV14.0.0ӣadd by qxt 20180719*/ + g_pCbtcConfigDataStru->cbtcConfigData.IsVOBCHandleObatacles = *pDataAddr; + pDataAddr += 1; + + /*ͬʱж̬()г,ݻͨݽṹV14.0.0ӣadd by qxt 20180719*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTrainNumOfAwake = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*Ŀʶ(ֹ̽ӿ),ݻͨݽṹV15.0.0ӣadd by sds 20181031*/ + g_pCbtcConfigDataStru->cbtcConfigData.TypeOfProject = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ZC-ZCӿЭ汾,ݻͨݽṹV16.0.0ӣadd by sds 2019-1-21*/ + g_pCbtcConfigDataStru->cbtcConfigData.VersionOfZCToZC = *pDataAddr; + pDataAddr += 1; + + /*ZC-VOBCӿЭ汾,ݻͨݽṹV16.0.0ӣadd by sds 2019-1-21*/ + g_pCbtcConfigDataStru->cbtcConfigData.VersionOfZCToVOBC = *pDataAddr; + pDataAddr += 1; + + /*ZC-DSUӿЭ汾,ݻͨݽṹV16.0.0ӣadd by sds 2019-1-21*/ + g_pCbtcConfigDataStru->cbtcConfigData.VersionOfZCToDSU = *pDataAddr; + pDataAddr += 1; +#endif + /*ZC-CIӿЭ汾,ݻͨݽṹV16.0.0ӣadd by sds 2019-1-21*/ + g_pCbtcConfigDataStru->cbtcConfigData.VersionOfZCToCI = *pDataAddr; + pDataAddr += 1; +#if 0 + /*ZC-ATSӿЭ汾,ݻͨݽṹV16.0.0ӣadd by sds 2019-1-21*/ + g_pCbtcConfigDataStru->cbtcConfigData.VersionOfZCToATS = *pDataAddr; + pDataAddr += 1; + + /*VOBC-ATSӿЭ汾,ݻͨݽṹV16.0.0ӣadd by sds 2019-1-21*/ + g_pCbtcConfigDataStru->cbtcConfigData.VersionOfVOBCToATS = *pDataAddr; + pDataAddr += 1; +#endif + /*VOBC-CIӿЭ汾,ݻͨݽṹV16.0.0ӣadd by sds 2019-1-21*/ + g_pCbtcConfigDataStru->cbtcConfigData.VersionOfVOBCToCI = *pDataAddr; + pDataAddr += 1; +#if 0 + /*ͨҴ"ͨ"š,ݻͨݽṹV18.0.0ӣadd by sds 2019-02-12*/ + g_pCbtcConfigDataStru->cbtcConfigData.FactoryCodeOfCRSC = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ͨҴ""š,ݻͨݽṹV18.0.0ӣadd by sds 2019-02-12*/ + g_pCbtcConfigDataStru->cbtcConfigData.FactoryCodeOfTCT = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ͨҴ""š,ݻͨݽṹV18.0.0ӣadd by sds 2019-02-12*/ + g_pCbtcConfigDataStru->cbtcConfigData.FactoryCodeOfTK = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ͨҴ"ں"š,ݻͨݽṹV18.0.0ӣadd by sds 2019-02-12*/ + g_pCbtcConfigDataStru->cbtcConfigData.FactoryCodeOfZH = ShortFromChar(pDataAddr); + pDataAddr += 2; +#endif + /*PSC-CIͨŹжʱ(ms) ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommFaultTimeOfPSC_CI = LongFromChar(pDataAddr); + pDataAddr += 4; +#if 0 + /*PSC-VOBCͨŹжʱ(ms) ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommFaultTimeOfPSC_VOBC = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*PSC-IMͨŹжʱ(ms) ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommFaultTimeOfPSC_IM = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBC-PSCӿЭ ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommProtocolTypeOfVOBC_PSC = *pDataAddr; + pDataAddr += 1; + + /*VOBC-PSCӿЭ汾 ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommProtocolVerOfVOBC_PSC = *pDataAddr; + pDataAddr += 1; + + /*VOBCMSSͨʱʹýӿЭ ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommProtocolTypeOfVOBC_MSS = *pDataAddr; + pDataAddr += 1; + + /*VOBCCIͨʱʹýӿЭ ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommProtocolTypeOfVOBC_CI = *pDataAddr; + pDataAddr += 1; + + /*VOBCZCͨʱʹýӿЭ ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommProtocolTypeOfVOBC_ZC = *pDataAddr; + pDataAddr += 1; + + /*VOBCATSͨʱʹýӿЭ ͨݽṹV20.0.0*/ + g_pCbtcConfigDataStru->cbtcConfigData.CommProtocolTypeOfVOBC_ATS = *pDataAddr; + pDataAddr += 1; +#endif + /*VOBC-CIͨŹжʱ(ms)add by lq 2023.11.16*/ + g_pCbtcConfigDataStru->cbtcConfigData.dwVobcCiackUpCommErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4U; + + /*CIϵͳУЭ汾ţadd by lq 2023.11.16*/ + g_pCbtcConfigDataStru->cbtcConfigData.ProtocolVersionOfAxisToCI = ShortFromChar(pDataAddr); + pDataAddr += 2U; + + /*շʽ*/ + g_pCbtcConfigDataStru->cbtcConfigData.chOverlapLockType = *pDataAddr; + pDataAddr += 1; + + /*ν·ռü*/ + g_pCbtcConfigDataStru->cbtcConfigData.chOccuCheckinCD = *pDataAddr; + pDataAddr += 1; + + rtnValue = 1; + } + else + { + rtnValue = 0U; + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ϵͳ]-DG(Ҫҽ1) +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:1ɹ,0ʧ +**********************************************/ +UINT8 dfsInitSubSystemCommonConfigData_DG(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + UINT8 i = 0U; + + if ((NULL != pDataAddr) && (1 == rowCount)) + { + /*ݽṹ*/ + /*·*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed = *pDataAddr; + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed=(UINT16)(27.77778*g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed+0.5); + pDataAddr += 1; + + /*ʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrSpeed = *pDataAddr; + pDataAddr += 1; + + /*NTPУʱʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.TimeZoneDifference = *pDataAddr; + pDataAddr += 1; + + /*ȫ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MABackDistance = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*VOBCZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*һʱٵ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrNum = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*һʱٱа߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxSectionOfTsr = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*DSUZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.DsuZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCZCͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCCIͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcCiCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*DSUATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.DsuAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ZCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.ZcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCCIͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcCiCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*VOBCATSͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxOverlapLength = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ciciͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CICICommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-vobcͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiVobcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-zcͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiZcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ci-psdͨŹжʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiPsdCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*Ϊatsʾһֶ---Ϲѧ2012-12-17*/ + /*link߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.LinkLogicDirUpAndDown = *pDataAddr; + pDataAddr += 1; + + g_pCbtcConfigDataStru->cbtcConfigData.SpanLineNum=ShortFromChar(pDataAddr); /*Ч·ͨ add by qxt 20160811*/ + pDataAddr += 2; + + for (i=0;i<4;i++ ) + { + g_pCbtcConfigDataStru->cbtcConfigData.LineID[i]=*pDataAddr; /*·ţͨ add by qxt 20160811*/ + pDataAddr += 1; + g_pCbtcConfigDataStru->cbtcConfigData.OverlapLineLogDirUpAndDown[i]=*pDataAddr; /*صڸ·ϵͳ߼зĹϵͨ add by qxt 20160811*/ + pDataAddr += 1; + } + + rtnValue = 1; + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ϵͳ]-CC(Ҫҽ1) +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:1ɹ,0ʧ +**********************************************/ +UINT8 dfsInitSubSystemCommonConfigData_CC(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + + if ((NULL != pDataAddr) && (1U == rowCount)) + { + /*ݽṹ*/ + /*·*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed = *pDataAddr; + g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed = (UINT16)(27.77778*g_pCbtcConfigDataStru->cbtcConfigData.MaxLineLimitSpeed + 0.5); + pDataAddr += 1; + + /*ʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrSpeed = *pDataAddr; + pDataAddr += 1; + + /*NTPУʱʱ*/ + g_pCbtcConfigDataStru->cbtcConfigData.TimeZoneDifference = *pDataAddr; + pDataAddr += 1; + +#if 0 + /*30.13 ݽṹɾ*/ + /*ͬʻ˫Сȫ(cm))*/ + g_pCbtcConfigDataStru->cbtcConfigData.MABackDistance = ShortFromChar(pDataAddr); + pDataAddr += 2; + +#endif + /*һʱٵ*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxTsrNum = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*һʱٱа߼*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxSectionOfTsr = ShortFromChar(pDataAddr); + pDataAddr += 2; +#if 0 + /*IVOC-IVOCŹжʱ䣨ms*/ + g_pCbtcConfigDataStru->cbtcConfigData.IvocIvocCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; +#endif + /*IVOC-TIOCͨŹжʱ(ms)*/ + g_pCbtcConfigDataStru->cbtcConfigData.CiVobcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; +#if 0 + /*VOBC-ITSͨŹжʱ(ms)*/ + g_pCbtcConfigDataStru->cbtcConfigData.VobcAtsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*TMC-ITSͨŹжʱ䣨ms*/ + g_pCbtcConfigDataStru->cbtcConfigData.TmcItsCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; +#endif + /*TMC-OCͨŹжʱ(ms)*/ + g_pCbtcConfigDataStru->cbtcConfigData.TmcOcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ITS-OCͨŹжʱ䣨ms*/ + g_pCbtcConfigDataStru->cbtcConfigData.ItsOcCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*OC-PSDͨŹжʱ䣨ms*/ + g_pCbtcConfigDataStru->cbtcConfigData.OcPsdCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; +#if 0 + /*IVOC-TSLͨŹжʱ䣨ms*/ + g_pCbtcConfigDataStru->cbtcConfigData.IvocTslCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; +#endif + /*OC-TSLͨŹжʱ䣨ms*/ + g_pCbtcConfigDataStru->cbtcConfigData.OcTslCommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*㾫׼ͣMA쳤*/ + g_pCbtcConfigDataStru->cbtcConfigData.MALengthForATOParking = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*ϵͳ߼зĹϵ*/ + g_pCbtcConfigDataStru->cbtcConfigData.LinkLogicDirUpAndDown = *pDataAddr; + pDataAddr += 1; + +#if 0 + /*ݽṹ30.13 ɾ*/ + /*ʻ˫Сȫ*/ + g_pCbtcConfigDataStru->cbtcConfigData.OppositeTrackDistance = ShortFromChar(pDataAddr); + pDataAddr += 2; + + /*վ̨׷ʱг*/ + g_pCbtcConfigDataStru->cbtcConfigData.StationTrackDistance = ShortFromChar(pDataAddr); + pDataAddr += 2; + +#endif + /*·½ƶ루λm*/ + g_pCbtcConfigDataStru->cbtcConfigData.MaxMALength = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*TIOC TIOCͨжʱ (λMS)*/ + g_pCbtcConfigDataStru->cbtcConfigData.CICICommunicationErrorTime = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*·С*/ + g_pCbtcConfigDataStru->cbtcConfigData.dwLineMinTrainLength = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*Ƿֶ֧̬Կ*/ + g_pCbtcConfigDataStru->cbtcConfigData.chZXDynamicTestSwitch = *pDataAddr; + pDataAddr += 1; + + /*̬Կ*/ + g_pCbtcConfigDataStru->cbtcConfigData.chDynamicTestSwitch = *pDataAddr; + pDataAddr += 1; + + /*ȫɸ*/ + g_pCbtcConfigDataStru->cbtcConfigData.chWLSFunSwitch = *pDataAddr; + pDataAddr += 1; + + /*ɢǰ*/ + g_pCbtcConfigDataStru->cbtcConfigData.dwEaFrontDis = LongFromChar(pDataAddr); + pDataAddr += 4; + + /*ɢ*/ + g_pCbtcConfigDataStru->cbtcConfigData.dwEaBehindDis = LongFromChar(pDataAddr); + pDataAddr += 4; + + pDataAddr += 1U; /*ԶRMܿ*/ + + pDataAddr += 4U; /*гԴյʱ*/ + + g_pCbtcConfigDataStru->cbtcConfigData.cAwakeCheckSpksSwitch = *pDataAddr; /*ѹмSPKS״̬*/ + pDataAddr += 1U; + + g_pCbtcConfigDataStru->cbtcConfigData.dwVobcCiackUpCommErrorTime = LongFromChar(pDataAddr); /*RCIVOCͨͨŹжʱ*/ + pDataAddr += 4U; + + g_pCbtcConfigDataStru->cbtcConfigData.ProtocolVersionOfAxisToCI = ShortFromChar(pDataAddr); /*CIϵͳУЭ汾ţadd by lq 2023.11.16*/ + pDataAddr += 2U; + + g_pCbtcConfigDataStru->cbtcConfigData.cHitSoftWallSwitch = *pDataAddr; /*ײǽܿ*/ + pDataAddr += 1U; + + g_pCbtcConfigDataStru->cbtcConfigData.chOverlapLockType= *pDataAddr; /*շʽ*/ + pDataAddr += 1U; + + g_pCbtcConfigDataStru->cbtcConfigData.chOccuCheckinCD = *pDataAddr; /*ν·ռü*/ + pDataAddr += 1U; + + g_pCbtcConfigDataStru->cbtcConfigData.chNoCGFollowUtSwitch = *pDataAddr; /*CվBUTǿ׷ٹܿ*/ + pDataAddr += 1U; + + rtnValue = 1; + } + + return rtnValue; +} + + +/********************************************** +ܣʼ[Ϣ] +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:1ɹ,0ʧ +**********************************************/ +UINT8 dfsInitTrainDepotConfigData(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + UINT32 i =0U; + UINT32 rowDataLen=0U; + UINT8 *pData = pDataAddr; + + + g_pCbtcConfigDataStru->DepotConfigLen = rowCount; + if (NULL != pDataAddr) + { + if (rowCount > 0) + { + rowDataLen = dataSize / rowCount; + + for (i = 0; i < rowCount; i++) + { + pData = pDataAddr + rowDataLen*i; + + /*α*/ + g_pCbtcConfigDataStru->cbtcDepotInfo[i].DepotID = *pData; + pData += 1; + /*ID*/ + g_pCbtcConfigDataStru->cbtcDepotInfo[i].DepotCIID = ShortFromChar(pData); + pData += 2; + /*γⷽ*/ + g_pCbtcConfigDataStru->cbtcDepotInfo[i].DepotDir = *pData; + pData += 1; + } + + } + rtnValue = 1U; + } + else + { + /*׵ַָΪ*/ + rtnValue = 0U; + } + return rtnValue; +} + +/*-----------------------------ݲѯӿں-----------------------*/ + +/*õǰѯԴ*/ +UINT8 dquSetCurCbtcCfgInfoQueryDataSource(CBTC_CFG_DATA_STRU *pCbtcConfigDataStru) +{ + UINT8 bRetVal=0U; + if (NULL != pCbtcConfigDataStru) + { + qds_dsuCbtcConfigDataStru=pCbtcConfigDataStru; + bRetVal=1U; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + +/*********************************************** +*ܣгƲѯг +*TrainNameг +*г +*ֵ0ʧ1ɹ +**********************************************/ +UINT8 dquGetTrainType(UINT16 TrainName,UINT8* pTrainType) +{ + UINT32 i=0U; + UINT8 rtnValue = 0U; + + if ((NULL != qds_dsuCbtcConfigDataStru) && (NULL != pTrainType)) + { + for(i=0;iTrainTypeConfigLen;i++) + { + if(qds_dsuCbtcConfigDataStru->cbtcTrainTypeConfig[i].TrainName == TrainName) + { + /*ҵ*/ + * pTrainType = qds_dsuCbtcConfigDataStru->cbtcTrainTypeConfig[i].TrainType; + rtnValue = 1; + return rtnValue; + } + } + /*ûҵѭ*/ + rtnValue = 0U; + } + else + { + rtnValue = 0U; + } + + return rtnValue; +} + +/******************************************* +*ܣгͻгϢ +*TrainTypeг +*pCbtcTrainInfoгϢṹ +*ֵ 0ʧ 1ɹ +*******************************************/ +UINT8 dquGetCbtcTrainInfo(UINT8 TrainType,CBTC_TRAIN_INFO_STRU *pCbtcTrainInfo) +{ + UINT32 i=0U; + UINT8 rtnValue = 0U; + + if ((NULL != qds_dsuCbtcConfigDataStru) && (NULL != pCbtcTrainInfo)) + { + for (i=0;iTrainInfoLen;i++) + { + if(TrainType==qds_dsuCbtcConfigDataStru->cbtcTrainInfo[i].TrainType) + { + *pCbtcTrainInfo = qds_dsuCbtcConfigDataStru->cbtcTrainInfo[i]; + rtnValue = 1; + return rtnValue; + } + /*ûҵѭ*/ + rtnValue = 0U; + } + } + else + { + + } + + return rtnValue; + +} + +/*ȡϵͳñ*/ +UINT8 dquGetCbtcConfigData (CBTC_CONFIG_DATA_STRU* pCbtcConfigDataStru) +{ + UINT8 rtnValue = 0U; + + if ((NULL != qds_dsuCbtcConfigDataStru) && (NULL != pCbtcConfigDataStru)) + { + *pCbtcConfigDataStru = qds_dsuCbtcConfigDataStru->cbtcConfigData; + rtnValue = 1U; + } + else + { + /*DO NOTHING*/ + } + return rtnValue; +} + +/********************************************* +*ܣóϢ +* +*pCbtcDepotInfoϢ +* LengthϢ +*ֵ 0ʧ 1ɹ +***********************************************/ +UINT8 dquGetCbtcDepotInfo(CBTC_DEPOT_INFO_STRU *pCbtcDepotInfo, UINT16 *Length) +{ + UINT32 i=0U; + UINT8 rtnValue = 0U; + + if ((NULL != qds_dsuCbtcConfigDataStru) && (NULL != pCbtcDepotInfo) && (NULL != Length)) + { + if((0 == qds_dsuCbtcConfigDataStru->DepotConfigLen) || (qds_dsuCbtcConfigDataStru->DepotConfigLen > 10)) + { + /*ûҵѭ*/ + rtnValue = 0U; + return rtnValue; + } + else + { + for (i=0;iDepotConfigLen;i++) + { + *(pCbtcDepotInfo+i) = qds_dsuCbtcConfigDataStru->cbtcDepotInfo[i]; + (*Length)++; + } + } + rtnValue = 1; + } + else + { + + } + + return rtnValue; +} + +/********************************************** +* ܣʼ[߽]-CC +* pDataAddr: ׵ַ +* dataSize: ֽڳ +* rowCount: +* +* ֵ:1: ɹ, +* 0: ʧ +* Created By LQ 2023.11.13 +**********************************************/ +UINT8 dfsInitBoundaryAxleConfigData(UINT8* pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + UINT16 i = 0U; + UINT32 rowDataLen = 0U; + UINT8* pData = pDataAddr; + + if (NULL != pDataAddr) + { + rtnValue = 1U; + + if ((0U < rowCount) && (100U >= rowCount) && (0U != dataSize)) + { + g_pCbtcConfigDataStru->BoundaryAxleInfoLen = rowCount; + rowDataLen = dataSize / rowCount; + + for (i = 0U; i < rowCount; i++) + { + pData = pDataAddr + rowDataLen * i; + + /*߽Ϣ*/ + g_pCbtcConfigDataStru->cbtcBoundaryAxleInfo[i].wIndex = ShortFromChar(pData); + pData += 2U; + + /*߽ϢID*/ + g_pCbtcConfigDataStru->cbtcBoundaryAxleInfo[i].wAxleSecId = ShortFromChar(pData); + pData += 2U; + + /*߽Ϣ*/ + g_pCbtcConfigDataStru->cbtcBoundaryAxleInfo[i].cLinkLineType = *pData; + pData += 1U; + + /*߽Ϣڼ*/ + g_pCbtcConfigDataStru->cbtcBoundaryAxleInfo[i].cEntranceType = *pData; + pData += 1U; + + /*߽Ϣ泵*/ + g_pCbtcConfigDataStru->cbtcBoundaryAxleInfo[i].cStorageLineType = *pData; + pData += 1U; + } + } + else if ((0U == rowCount) ||(0U == dataSize)) + { + g_pCbtcConfigDataStru->BoundaryAxleInfoLen = 0U; /*Ϊ0ȡ*/ + } + else + { + rtnValue = 0U; /*ޣ0*/ + } + } + else + { + rtnValue = 0U; /*׵ַָΪգ0*/ + } + + return rtnValue; +} \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_cbtc_common/dquCbtcConfigData.h b/TSCP/src/dqu_common/dqu_cbtc_common/dquCbtcConfigData.h new file mode 100644 index 0000000..fb05b52 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_cbtc_common/dquCbtcConfigData.h @@ -0,0 +1,214 @@ + +/************************************************************************ +* +* ļ +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ϵͳݽṹ嶨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef DQU_CBTC_CONFIG_DATA +#define DQU_CBTC_CONFIG_DATA + +#include "CommonTypes.h" +#include "dquDataTypeDefine.h" + +/*Ϊatsʾһֶ---Ϲѧ2012-12-17*/ +#define LINK_LOGIC_DIR_DOWN 0x55 /*(link߼Ϊ·з)*/ +#define LINK_LOGIC_DIR_UP 0xaa /*(link߼Ϊ·з)*/ + +#define DQU_CBTC_VER1 66 /*Ʒ*/ +#define DQU_CBTC_VER2 17 /*ģ*/ +#define DQU_CBTC_VER3 0U /*ģ汾*/ +#define DQU_CBTC_VER4 2U /*ģӰ汾*/ + +#ifdef __cplusplus +extern "C" { +#endif + /*гϢṹ*/ + typedef struct{ + UINT16 TrainName; /*г*/ + UINT8 TrainType; /*г*/ + } CBTC_TRAIN_TYPE_CONGIG_STRU; + + /*гܲýṹ*/ + typedef struct { + UINT8 TrainType; /*г*/ + UINT16 TrainLength; /*г*/ + UINT8 TrainMaxTracAcc; /*гǣٶ*/ + UINT16 WorstGrade; /*·¶*/ + } CBTC_TRAIN_INFO_STRU; + + + /*ϵͳýṹ*/ + typedef struct { + UINT16 MaxLineLimitSpeed;/*·,˴ݿдŵUINT8km/hݣҪתcmpsλ*/ + UINT8 MaxTsrSpeed;/*ʱ*/ + UINT8 TimeZoneDifference;/*NTPУʱʱ.ʱ뱾ʱʱλʱӦʹʱӦ3600תΪ롣*/ + UINT16 MABackDistance;/*ȫ.ǵ£DZо·¶ȵȣƶȨǵİȫ*/ + UINT16 MaxTsrNum;/*һʱٵ*/ + UINT16 MaxSectionOfTsr;/*һʱٱа߼*/ + UINT32 VobcZcCommunicationErrorTime;/*VOBCZCͨŹжʱ*/ + UINT32 DsuZcCommunicationErrorTime;/*DSUZCͨŹжʱ*/ + UINT32 ZcZcCommunicationErrorTime;/*ZCZCͨŹжʱ*/ + UINT32 ZcCiCommunicationErrorTime;/*ZCCIͨŹжʱ*/ + UINT32 DsuAtsCommunicationErrorTime;/*DSUATSͨŹжʱ*/ + UINT32 ZcAtsCommunicationErrorTime;/*ZCATSͨŹжʱ*/ + UINT32 VobcCiCommunicationErrorTime;/*VOBCCIͨŹжʱ*/ + UINT32 VobcAtsCommunicationErrorTime;/*VOBCATSͨŹжʱ*/ + UINT16 MaxOverlapLength;/*ϵͳ󱣻γȣcm*/ + UINT32 CICICommunicationErrorTime; /*CI-CIͨŹжʱ(ms)*/ + UINT32 CiVobcCommunicationErrorTime;/*CI-VOBCͨŹжʱ*/ + UINT32 CiZcCommunicationErrorTime; /*CI-ZCͨŹжʱ*/ + UINT32 CiPsdCommunicationErrorTime; /*CI-ZCͨŹжʱ*/ + UINT32 IvocIvocCommunicationErrorTime;/*IVOC-IVOCŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 IvocOcCommunicationErrorTime;/*IVOC-OCͨŹжʱ(ms),add by yt202231գ䳵ϵͳ*/ + UINT32 TmcItsCommunicationErrorTime;/*TMC-ITSͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 TmcOcCommunicationErrorTime;/*TMC-OCͨŹжʱ(ms),add by yt202231գ䳵ϵͳ*/ + UINT32 ItsOcCommunicationErrorTime;/*ITS-OCͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 OcPsdCommunicationErrorTime;/*OC-PSDͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 IvocTslCommunicationErrorTime;/*IVOC-TSLͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT32 OcTslCommunicationErrorTime;/*OC-TSLͨŹжʱ䣨ms,add by yt202231գ䳵ϵͳ*/ + UINT8 LinkLogicDirUpAndDown; /*ϵͳ߼зĹϵ,add by yt202231գ䳵ϵͳ*/ + UINT16 OppositeTrackDistance; /*ʻ˫Сȫ루cm,add by yt202231գ䳵ϵͳ*/ + UINT16 StationTrackDistance; /*վ̨׷ʱг(cm),add by yt202231գ䳵ϵͳ*/ + UINT32 MaxMALength; /*·½ƶ루λm,add by yt202231գ䳵ϵͳ*/ + UINT32 dwLineMinTrainLength; /*ϵͳݣ·С*/ + UINT8 chZXDynamicTestSwitch; /*Ƿֶ֧̬ aaر 55*/ + UINT8 chDynamicTestSwitch; /*Ƿֶ֧̬Կ aaر 55*/ + UINT8 chWLSFunSwitch; /* Ƿ֧ȫɸܣ0x55 ֧ 0xAA֧ */ + UINT32 dwEaFrontDis; /*ɢǰ*/ + UINT32 dwEaBehindDis; /*ɢ*/ + UINT8 cAwakeCheckSpksSwitch; /*ѹмSPKS״̬أ0xaa飬0x55*/ + UINT32 dwVobcCiackUpCommErrorTime; /*IVOC-RCVOBC-CIͨͨŹжʱ(ms)----䳵510Ŀ*/ + UINT8 cHitSoftWallSwitch; /*ײǽܿ 0x55ش 0xaaعر*/ + UINT8 chOverlapLockType; /*շʽ 0x01 ATS 0x02 CI*/ + UINT8 chOccuCheckinCD; /*ν·ռü 0x55 0xaa*/ + UINT8 chNoCGFollowUtSwitch; /*CվBUTǿ׷ٹܿ aa 55ر*/ + + /*Ϊatsʾһֶ---Ϲѧ2012-12-17*/ + /*UINT8 LinkLogicDirUpAndDown;*/ /*link߼*/ + + UINT16 SpanLineNum; /*Ч·ͨ add by qxt 20160811*/ + UINT8 LineID[4]; /*·ţͨ add by qxt 20160811*/ + UINT8 OverlapLineLogDirUpAndDown[4]; /*صڸ·ϵͳ߼зĹϵͨ add by qxt 20160811*/ + UINT16 MALengthForATOParking; /*ATO׼ͣMAȣԺϿݽṹV16.0.0ϵͳݸϵͳֶΡATO׼ͣMAȡadd by my 20170220*/ + UINT16 ZeroSpeedThreshold; /*ж(cm/s)ݻͨݽṹV12.0.0ӣadd by lmy 20180314*/ + UINT32 StartDistanceOfMSToNZ; /*ԤŸֵ MS=MagneticSteel NZ=NeutralZoneݻͨݽṹV13.0.0ӣadd by sds 20180614*/ + UINT8 CompatibleOfHLHTFAO; /*ͨFAOӿڼֶΣݻͨݽṹV13.0.0ӣadd by sds 20180614*/ + UINT8 ValueOfLineDynamicTest; /*Ƿֶ̬ΣݻͨݽṹV13.0.0ӣadd by sds 20180625*/ + UINT8 IsVOBCHandleObatacles; /*ǷVOBCMAϰ,ݻͨݽṹV14.0.0ӣadd by qxt 20180719*/ + UINT16 MaxTrainNumOfAwake; /*ͬʱж̬()г,ݻͨݽṹV14.0.0ӣadd by qxt 20180719*/ + UINT16 TypeOfProject; /*Ŀʶ(ֹ̽ӿ),ݻͨݽṹV15.0.0ӣadd by sds 20181031*/ + UINT8 VersionOfZCToZC; /*ZC-ZCӿЭ汾ţadd by sds 2019-1-21*/ + UINT8 VersionOfZCToVOBC; /*ZC-VOBCӿЭ汾ţadd by sds 2019-1-21*/ + UINT8 VersionOfZCToDSU; /*ZC-DSUӿЭ汾ţadd by sds 2019-1-21*/ + UINT8 VersionOfZCToCI; /*ZC-CIӿЭ汾ţadd by sds 2019-1-21*/ + UINT8 VersionOfZCToATS; /*ZC-ATSӿЭ汾ţadd by sds 2019-1-21*/ + UINT8 VersionOfVOBCToATS; /*VOBC-ATSӿЭ汾ţadd by sds 2019-1-21*/ + UINT8 VersionOfVOBCToCI; /*VOBC-CIӿЭ汾ţadd by sds 2019-1-21*/ + UINT16 FactoryCodeOfCRSC; /*ͨҴ"ͨ"ţadd by sds 2020-02-12*/ + UINT16 FactoryCodeOfTCT; /*ͨҴ"ؿƼ"šͣadd by sds 2020-02-12*/ + UINT16 FactoryCodeOfTK; /*ͨҴ""šͣadd by sds 2020-02-12*/ + UINT16 FactoryCodeOfZH; /*ͨҴ"ں"ţadd by sds 2020-02-12*/ + UINT32 CommFaultTimeOfPSC_CI; /*PSC-CIͨŹжʱ(ms) ͨݽṹV20.0.0*/ + UINT32 CommFaultTimeOfPSC_VOBC; /*PSC-VOBCͨŹжʱ(ms) ͨݽṹV20.0.0*/ + UINT32 CommFaultTimeOfPSC_IM; /*PSC-IMͨŹжʱ(ms) ͨݽṹV20.0.0*/ + UINT8 CommProtocolTypeOfVOBC_PSC; /*VOBC-PSCӿЭ ͨݽṹV20.0.0*/ + UINT8 CommProtocolVerOfVOBC_PSC; /*VOBC-PSCӿЭ汾 ͨݽṹV20.0.0*/ + UINT8 CommProtocolTypeOfVOBC_MSS; /*VOBCMSSͨʱʹýӿЭ ͨݽṹV20.0.0*/ + UINT8 CommProtocolTypeOfVOBC_CI; /*VOBCCIͨʱʹýӿЭ ͨݽṹV20.0.0*/ + UINT8 CommProtocolTypeOfVOBC_ZC; /*VOBCZCͨʱʹýӿЭ ͨݽṹV20.0.0*/ + UINT8 CommProtocolTypeOfVOBC_ATS; /*VOBCATSͨʱʹýӿЭ ͨݽṹV20.0.0*/ + UINT16 ProtocolVersionOfAxisToCI; /*Axis-CIӿЭ汾ţadd by lq 2023.11.16*/ + } CBTC_CONFIG_DATA_STRU; + + + /*Ϣṹ*/ + typedef struct { + UINT8 DepotID; /*α*/ + UINT16 DepotCIID; /*ID*/ + UINT8 DepotDir; /*γⷽ*/ + } CBTC_DEPOT_INFO_STRU; + + /*߽Ϣṹ*/ + typedef struct { + UINT16 wIndex; /**/ + UINT16 wAxleSecId; /*ID*/ + UINT8 cLinkLineType; /**/ + UINT8 cEntranceType; /*ڼ*/ + UINT8 cStorageLineType; /*泵*/ + } CBTC_BOUNDARY_AXLE_CONFIG_STRU; + + /*CBTCϢ*/ + typedef struct CBTC_ConfigDataStruct + { + CBTC_TRAIN_TYPE_CONGIG_STRU cbtcTrainTypeConfig[200]; /*гݽṹ飬ʼ*/ + UINT32 TrainTypeConfigLen; /*鳤*/ + + CBTC_TRAIN_INFO_STRU cbtcTrainInfo[10]; /*гܲýṹ飬ʼ*/ + UINT32 TrainInfoLen; /*鳤*/ + + CBTC_DEPOT_INFO_STRU cbtcDepotInfo[10]; /*Ϣṹ飬ʼ*/ + UINT32 DepotConfigLen; /*鳤*/ + + CBTC_CONFIG_DATA_STRU cbtcConfigData; /*ϵͳýṹ飬ʼ*/ + + CBTC_BOUNDARY_AXLE_CONFIG_STRU cbtcBoundaryAxleInfo[100]; /*߽Ϣṹ飬ʼ*/ + UINT16 BoundaryAxleInfoLen; /*鳤*/ + }CBTC_CFG_DATA_STRU; + + /********************************************* + *ܣϵͳݰ汾Żȡ + *˵ϵͳòѯ汾ţֹɴ + *ڲ + *ڲ + *ֵUINT32ʾİ汾 + *********************************************/ + UINT32 GetDquCbtcVersion(void); + + /*CBTCϢ*/ + UINT8 dquSetInitCbtcConfigInfoRef(CBTC_CFG_DATA_STRU *pCbtcConfigDataStru); + + /*ϵͳݳʼ*/ + UINT8 dquCbtcConfigDataInit(CHAR* FSName); + + /*ŶձʼϣִбŶձڲ*/ + UINT8 dfsuCbtcConfigInitFinally(void); + + + /*õǰѯԴ*/ + UINT8 dquSetCurCbtcCfgInfoQueryDataSource(CBTC_CFG_DATA_STRU *pCbtcConfigDataStru); + + /*гƲѯг*/ + UINT8 dquGetTrainType(UINT16 TrainName, UINT8 *pTrainType); + + + /*гͻгϢ*/ + UINT8 dquGetCbtcTrainInfo(UINT8 TrainType, CBTC_TRAIN_INFO_STRU *pCbtcTrainInfo); + + + /*ȡϵͳñ*/ + UINT8 dquGetCbtcConfigData (CBTC_CONFIG_DATA_STRU* pCbtcConfigDataStru); + + + /* + ܣóϢ + + pCbtcDepotInfoϢ + LengthϢ + ֵ 0ʧ 1ɹ */ + UINT8 dquGetCbtcDepotInfo(CBTC_DEPOT_INFO_STRU *pCbtcDepotInfo, UINT16 *Length); + + +#ifdef __cplusplus +} +#endif + +#else +#endif diff --git a/TSCP/src/dqu_common/dqu_dfs_common/dfsDataRead.c b/TSCP/src/dqu_common/dqu_dfs_common/dfsDataRead.c new file mode 100644 index 0000000..f4ae4f0 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_dfs_common/dfsDataRead.c @@ -0,0 +1,1596 @@ +/************************************************************************ +* +* ļ dfsDataRead.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.09.22 +* +* ļϵͳļԤ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include +#include "dfsDataRead.h" +#include "CbtcVersion.h" +#include "dquCbtcType.h" + +UINT16 fileErrNo = 0U ; /*ļ*/ +UINT16 dataTypeErrNo = 0U ; /*ʹ*/ + +UINT8 *g_pDataBuf=NULL; /*Ԥ.fsļڴռ*/ +UINT32 g_DataBufLen = 0U; /*ȡݵij*/ + +dfsDataHead *g_pDFsDH; /*ȫFSļͷṹ*/ + +UINT8 isDataRead = 0U; /*ʶǷѾļ*/ +UINT32 newSpaceNum = 0U; + + + +/********************************************* +*ܣдģ汾Żȡ +*˵ϵͳòѯ汾ţֹɴ +*ڲ +*ڲ +*ֵUINT32ʾİ汾 +*********************************************/ +UINT32 GetDquDfsVersion(void) +{ + UINT32 dquDfsVer=0U; + dquDfsVer = VerToU32SoftwareModule(DQU_DFS_VER1,DQU_DFS_VER2,DQU_DFS_VER3,DQU_DFS_VER4); + return dquDfsVer; +} + +/********************************************* +*ܣڴռ +*˵newSizeռ䳤 +*ֵ +*********************************************/ +void * MyNew(UINT32 newSize) +{ + newSpaceNum += newSize; + return malloc(newSize); +} + +/********************************************* +*ܣͷṹ +*˵pDHǴͷṹָ + pDataַ +*ֵ0ʧܣ 1ɹ +*********************************************/ +UINT8 DHFromByte(DH * pDH,UINT8 *pData) +{ + UINT8 rtnValue = 0U; + UINT8 i = 0U; + /*ָ*/ + if ((NULL != pDH) && (NULL != pData)) + { + + + pDH->crc = LongFromChar(pData); + pData += 4; + + for (i = 0U; i < DFS_VERSION_LENGTH; i++) + { + pDH->version[i] = *pData; + pData++; + } + + pDH->dataLength = LongFromChar(pData); + pData += 4; + + pDH->indexNumber = LongFromChar(pData); + pData += 4; + + for (i = 0; i < DFS_DH_SPARE_BYTE_LENGTH; i++) + { + pDH->spareByte[i] = *(pData); + pData++; + } + rtnValue = 1U; + } + return rtnValue; +} + +/********************************************* +*ܣṹ +*˵pDIǴṹָ + pDataַ +*ֵ +*********************************************/ +UINT8 DIFromByte(DI* pDI, UINT8 *pData) +{ + UINT8 rtnValue = 0U; + UINT8 i = 0U; + /*ָ*/ + if ((NULL != pDI) && (NULL != pData)) + { + + pDI->dataID = LongFromChar(pData); + pData += 4; + + pDI->dataLength = LongFromChar(pData); + pData += 4; + + pDI->dataAddress = LongFromChar(pData); + pData += 4; + + pDI->dataRowCount = ShortFromChar(pData); + pData += 2; + + pDI->dataColCount = ShortFromChar(pData); + pData += 2; + + for (i = 0; i < DFS_DI_SPARE_BYTE_LENGTH; i++) + { + pDI->spareByte[i] = *pData; + pData++; + } + rtnValue = 1U; + } + return rtnValue; +} + +/********************************************* +*ܣȡļڴdataBuf[]FSͷòѯİ汾 +*˵fileNameļ +*ֵ1ɹ0ʧ, +**********************************/ +UINT8 dataRead(CHAR * dataName) +{ + UINT32 CRCresult=0U; /*У*/ + UINT32 tempCRC = 0U; + UINT32 pDataOffset = DFS_DATA_HEAD_SIZE; + UINT8 *pData = NULL; + UINT32 i=0U; + UINT8 rtnValue = 0U; + UINT8 readFlag = 0U; + FILE * pfile=NULL; + DH dh={0U}; + volatile UINT8 * pDataAddr; + pDataAddr = (volatile UINT8 * )dataName; + + if (NULL == dataName) + { + /*ļַΪ*/ + rtnValue = 0U; + } + else if(0U== isDataRead ) + { + + if (NULL==g_pDataBuf) + { + /*̬ļȡڴռ*/ + g_pDataBuf = (UINT8*)MyNew(sizeof(UINT8) * DFS_MAX_FILE_LEN ); + /*̬ռʧ*/ + if (NULL == g_pDataBuf) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ʼΪFF*/ + memset(g_pDataBuf, 0xFF, sizeof(UINT8) * DFS_MAX_FILE_LEN ); + pData = g_pDataBuf; + } + } + +#if CBTC_WINDOWS + + /*ȡļ*/ + pfile = fopen(dataName,"rb"); + if (pfile==NULL) + { + /*ļʧܣҲļsjg*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + return rtnValue; + } + + g_DataBufLen = fread(g_pDataBuf,sizeof(UINT8),DFS_MAX_FILE_LEN,pfile); + if((g_DataBufLen==0) || (g_DataBufLen>= DFS_MAX_FILE_LEN)) + { + /*printf("ļʧܣ");*/ + fileErrNo |= ERR_FILE_LENTH; + fclose(pfile); + rtnValue = 0U; + return rtnValue; + } + else + { + /*ȡɹִ*/ + readFlag = DHFromByte(&dh,pData); + if (0U != readFlag) + { + g_DataBufLen = dh.dataLength; + } + else { + /*ָ*/ + fileErrNo |= ERR_PTR_NULL; + rtnValue = 0U; + return rtnValue; + } + } + fclose(pfile); + +#elif CBTC_VXWORKS + /*ȡļ*/ + pfile = fopen(dataName,"rb"); + if (pfile==0) + { + /*ȡļʧܣҲļsjg*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + return rtnValue; + } + + g_DataBufLen = fread(g_pDataBuf,sizeof(UINT8),DFS_MAX_FILE_LEN,pfile); + if(g_DataBufLen==0) + { + /*printf("ļʧܣ");*/ + fileErrNo |= ERR_FILE_LENTH; + fclose(pfile); + rtnValue = 0U; + return rtnValue; + } + else + { + /*ȡɹִ*/ + DHFromByte(&dh,pData); + g_DataBufLen = dh.dataLength; + } + fclose(pfile); + +#elif CBTC_MOTOROLA + + /*ȶȡһļͷȡļ*/ + for(i=0;i= DFS_MAX_FILE_LEN) + { + /*ļ̫*/ + fileErrNo |= ERR_FILE_LENTH; + rtnValue = 0U; + return rtnValue; + } + else + { + /*ȡ*/ + for(i=DFS_DATA_HEAD_SIZE;idataHead,pData); + if (0U != readFlag) + { + /**/ + for(i=0;idataHead.indexNumber;i++) + { + DIFromByte(&g_pDFsDH->dataIndex[i], pData + pDataOffset); + pDataOffset += DFS_DATA_INDEX_SIZE; + } + + /*òѯ汾*/ + SetCbtcSysType(g_pDFsDH->dataHead.spareByte[0]); + + /*ݶȡ־Ϊ1*/ + isDataRead = 1; + rtnValue = 1; + } + else { + /*DHFromByteָ*/ + rtnValue = 0u; + } + } + } + else + { + rtnValue = 1; + } + return rtnValue; +} + +/********************************************* +*ܣȡļFSͷòѯİ汾(ڴ) +*dataNameļ +* +* +*ؼ:ڲ +*ֵ1ɹ0ʧ +**********************************/ +UINT8 dataReadNoCopy(CHAR * dataName) +{ + UINT32 CRCresult = 0U; /*У*/ + UINT32 pDataOffset = DFS_DATA_HEAD_SIZE; + UINT8 *pData = NULL; + UINT32 i = 0U; + UINT32 tmpValue = 0U; + UINT8 rtnValue = 0U; + UINT8 readFlag = 0U; + FILE * pfile = NULL; + DH dh = {0U}; + UINT8 * pDataAddr = (UINT8 * )dataName; + + /**/ + if (NULL == dataName) + { + rtnValue = 0U; + } + /*жǷΪһμ,ֹظ*/ + else if((0U == isDataRead) && (NULL != pDataAddr)) + { + /*ǰ4ֽΪļȣ*/ + g_pDataBuf = (pDataAddr + 4); + pData = g_pDataBuf; + + /*ļͷ*/ + DHFromByte(&dh,pData); + + /*ļȴ*/ + if((4 > (dh.dataLength)) || (DFS_MAX_FILE_LEN <= (dh.dataLength))) + { + fileErrNo |= ERR_FILE_LENTH; + rtnValue = 0U; + } + else + { + /*ȡɹִ*/ + DHFromByte(&dh,pData); + g_DataBufLen = dh.dataLength; + + /*ļͷ*/ + DHFromByte(&dh,pData); + + /*CRC,ǰ4ֽCRCˣʱӵ4ֽڿʼ*/ + CRCresult = Crc32(&g_pDataBuf[4], (g_DataBufLen - 4)); + + /*ȡCRCϢ*/ + tmpValue = LongFromChar(g_pDataBuf); + + /*CRCУ*/ + if(CRCresult != tmpValue) + { + fileErrNo |= ERR_CRC_CHECK; + rtnValue = 0U; + } + else + { + + /*FSļͷSṹڴռ*/ + if (NULL == g_pDFsDH) + { + g_pDFsDH = (dfsDataHead*)MyNew(sizeof(dfsDataHead)); + + if(NULL == g_pDFsDH) + { + rtnValue = 0U; + } + else + { + /*FSļͷṹϢΪ0x00*/ + memset(g_pDFsDH,0x00,sizeof(dfsDataHead)); + + /*ͷ*/ + DHFromByte(&g_pDFsDH->dataHead,pData); + + /**/ + for(i = 0;i < (g_pDFsDH->dataHead.indexNumber);i++) + { + DIFromByte((&g_pDFsDH->dataIndex[i]), (pData + pDataOffset)); + pDataOffset += DFS_DATA_INDEX_SIZE; + } + + /*òѯ汾*/ + SetCbtcSysType(g_pDFsDH->dataHead.spareByte[0]); + + /*ݶȡ־Ϊ1*/ + isDataRead = 1; + rtnValue = 1; + } + } + else + { + /*nothing to do*/ + } + + } + } + } + else + { + rtnValue = 1; + } + + return rtnValue; + +} + + + +/************************************************************************* +*ܣȡļڴdataBuf[] +*˵dataNameļ洢FLASHַ +* Lengthsȡļܳ +* *pDataBufڴд洢ַ +* ReadLengthζȡݵij +* ReadModeȡʽ1:һԶȡļ;2:ֳɶζȡ +* dfsDH һļͷ,ͷ,Ϣ +* checkNumOfCRC ֲȼģʽµģCRCʱIJУĴ( +* FSֽ/ֵ㵥ֽ֤FS +* Ϊ1MƼֵΪ100) +*ֵ 0ʧܣ1ɹ,2֡ȡɹ; +**************************************************************************/ +UINT8 dataReadExp(CHAR *dataName, DQU_READ_DATA_STOR_STRU *FsStorStu,UINT8 checkNumOfCRC) +{ + UINT32 CRCresult=0U; /*У*/ + UINT32 pDataOffset = DFS_DATA_HEAD_SIZE; + UINT32 i = 0U; + FILE * pfile=NULL; + UINT8 rtnValue = 2U; /*ĬϷֵ,ֲ*/ + UINT8 readFlag = 0U; /*ֵ*/ + UINT8 *pData = FsStorStu->DataBuf; + + DH dh={0U}; + volatile UINT8 *pDataAddr=NULL; + static UINT8 MainIndex=0U; /**/ + static UINT32 loadCrcCode = 0U; /*ɵCRCЧ*/ + static UINT32 FileLengths=0U; /*ļij*/ + /*ָ*/ + if ((NULL == dataName) || (NULL == FsStorStu)) + { + rtnValue = 0U; + } + else + { + pDataAddr = (volatile UINT8 *)dataName; + +#if CBTC_MOTOROLA + if (0U == MainIndex) + { + /*ȶȡһļͷȡļ*/ + for (i = 0; i < DFS_DATA_HEAD_SIZE; i++) + { + FsStorStu->DataBuf[i] = *pDataAddr; + pDataAddr++; + } + + /*ļͷ*/ + DHFromByte(&dh,pData); + FileLengths = dh.dataLength; + + /*жļͷЧ*/ + if (FileLengths >= DFS_MAX_FILE_LEN) + { + /*ļ̫*/ + fileErrNo |= LOAD_FILE_LENGTH_ERR; + rtnValue = 0U; + MainIndex = 4; + } + else + { + MainIndex = 1; + } + + } +#endif + + /*һԶȡ*/ + if (READ_MODE_ONCE == FsStorStu->ReadMode) + { + +#if CBTC_VXWORKS + /*ȡļ*/ + pfile = fopen(dataName, "rb"); + if (pfile == 0) + { + /*ȡļʧܣҲļsjg*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + return rtnValue; + } + + g_DataBufLen = fread(FsStorStu->DataBuf, sizeof(UINT8), DFS_MAX_FILE_LEN, pfile); + if (g_DataBufLen == 0) + { + /*printf("ļʧܣ");*/ + fileErrNo |= ERR_FILE_LENTH; + fclose(pfile); + rtnValue = 0U; + return rtnValue; + } + else + { + /*ȡɹִ*/ + DHFromByte(&dh,pData); + FileLengths = dh.dataLength; + } + fclose(pfile); + + /*CRC,ǰ4ֽCRCˣʱӵ4ֽڿʼ*/ + CRCresult = Crc32(&FsStorStu->DataBuf[4], FileLengths - 4); + + /*CRCУ*/ + if (CRCresult != LongFromChar(&FsStorStu->DataBuf[0])) + { + /*printf("Уʧܣ汾Ųһ£");*/ + fileErrNo |= ERR_CRC_CHECK; + rtnValue = 0U; + } + else + { /*ݶȡУɹ*/ + + isDataRead = 1; + rtnValue = 1; + } + + /*ֵָ*/ + MainIndex = 4U; + +#elif CBTC_MOTOROLA + if (1 == MainIndex) + { + /*ȡ*/ + for (i = DFS_DATA_HEAD_SIZE; i < dh.dataLength; i++) + { + FsStorStu->DataBuf[i] = *pDataAddr; + pDataAddr++; + } + + /*CRC,ǰ4ֽCRCˣʱӵ4ֽڿʼ*/ + CRCresult = Crc32(&FsStorStu->DataBuf[4], FileLengths - 4); + + /*CRCУ*/ + if (CRCresult != LongFromChar(&FsStorStu->DataBuf[0])) + { + /*printf("Уʧܣ汾Ųһ£");*/ + fileErrNo |= ERR_CRC_CHECK; + rtnValue = 0U; + } + else + { + rtnValue = 1U; + isDataRead = 1U; + } + /*ֵָ*/ + MainIndex = 4U; + } +#endif + } + else if (READ_MODE_TIMES == FsStorStu->ReadMode) + { + +#if CBTC_MOTOROLA + if (1U == MainIndex) + { + /*ֲȡ*/ + funcRtn = ReadCycle(dataName, FsStorStu->DataBuf, FsStorStu->ReadLength, FsStorStu->ReadMode, FileLengths); + if (0x55U == funcRtn) + { + MainIndex = 2U; + } + else if (0xaaU == funcRtn) + { + /*ֵָ*/ + MainIndex = 4U; + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + else + { + /*ֲ*/ + } + } + else if (2U == MainIndex) + { + /*CRCЧ*/ + funcRtn = BigFileCrc32(&FsStorStu->DataBuf[4], FileLengths - 4, checkNumOfCRC, &loadCrcCode); + if (0x55U == funcRtn) + { + MainIndex = 3U; + } + else if (0xaaU == funcRtn) + { + /*ֵָ*/ + MainIndex = 4U; + rtnValue = 0U; + } + else + { + /*ֲ*/ + } + + } + else if (3U == MainIndex) + { + /*CRCУ*/ + if (loadCrcCode != LongFromChar(&FsStorStu->DataBuf[0])) + { + /*ʧ*/ + fileErrNo |= ERR_CRC_CHECK; + rtnValue = 0U; + } + else + { + isDataRead = 1U; + rtnValue = 1U; + } + + MainIndex = 4U; + } + else + { + /*ִд*/ + } +#endif + + } + else + { + rtnValue = 0U; + MainIndex = 4U; + } + + + /*ֵָ*/ + if (4 == MainIndex) + { + /*FSļɹFSļͷ*/ + if (1 == rtnValue) + { + readFlag = dquAnalyzeFsDataHead(pData, FsStorStu->DfsDH); + if (0U == readFlag) + { + rtnValue = 0U; + } + } + + loadCrcCode = 0U; + FileLengths = 0U; + + MainIndex = 0U; + } + } + return rtnValue; +} + +/*************************************************** +*ܣdataReaddataReadExpɹȡ־ +*˵ +* +*ֵ1ɹ0ʧ +***********************************************/ +UINT8 clearDataReadFlag(void) +{ + isDataRead = 0; + + return 1; +} + +/*FSļͷϢòѯİ汾*/ +UINT8 dquAnalyzeFsDataHead(UINT8 *pDataBuf,dfsDataHead *pDfsDH) +{ + + UINT32 pDataOffset = DFS_DATA_HEAD_SIZE; + UINT32 i=0U; + UINT8 rtnValue = 0U; + UINT8 readFlag = 0U; + + if ((NULL == pDataBuf) || (NULL == pDfsDH)) + { + rtnValue=0U; + } + else + { /*FSļͷṹϢΪЧֵ*/ + memset(pDfsDH,0x0,sizeof(dfsDataHead)); + rtnValue = 1U; + /*ͷ*/ + readFlag = DHFromByte(&(pDfsDH->dataHead),pDataBuf); + if (0U == readFlag) + { + /*DHFromByteȡʧ*/ + rtnValue = 0U; + } + } + if(1U == rtnValue) + { + /**/ + for(i=0;idataHead.indexNumber;i++) + { + DIFromByte(&(pDfsDH->dataIndex[i]), pDataBuf + pDataOffset); + pDataOffset += DFS_DATA_INDEX_SIZE; + } + + /*òѯ汾*/ + SetCbtcSysType(pDfsDH->dataHead.spareByte[0]); + rtnValue = 1U; + } + + return rtnValue; +} + + +/************************************** +*ܣȡFSļ汾 +*˵ +* FSName FSļ +* FSVersion[]8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*************************************/ +UINT8 dquGetFSVersion(CHAR *FSName ,UINT8 FSVersion[DFS_VERSION_LENGTH]) +{ + + UINT8 i=0U; + UINT8 rtnValue = 0U;//2ʾ + UINT8 readFlag = 0U; + + if((NULL!= FSName) && (NULL!= FSVersion)) + { + rtnValue = 1U; + readFlag = dataRead(FSName); + readFlag *= DHFromByte(&g_pDFsDH->dataHead,g_pDataBuf); + if (0U == readFlag) + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + else + { + for(i=0U;idataHead.version[i]; + } + + rtnValue = 1U; + } + } + else + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + return rtnValue; +} + + +/************************************** +*ܣȡݽṹ汾 +*˵ +* FSName FSļ +* publicFSVersion[]8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*************************************/ +UINT8 dquGetPublicFSVersion(CHAR* FSName, UINT8 publicFSVersion[DFS_VERSION_LENGTH]) +{ + + UINT8 i = 0U; + UINT8 rtnValue = 0U;//2ʾ + UINT8 readFlag = 0U; + + if ((NULL != FSName) && (NULL != publicFSVersion)) + { + rtnValue = 1U; + readFlag = dataRead(FSName); + readFlag *= DHFromByte(&g_pDFsDH->dataHead, g_pDataBuf); + if (0U == readFlag) + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + else + { + for (i = 0U; i < DFS_VERSION_LENGTH; i++) + { + publicFSVersion[i] = g_pDFsDH->dataHead.spareByte[5-i]; + } + + rtnValue = 1U; + } + } + else + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + return rtnValue; +} + + +/************************************** +*ܣȡ˽ݽṹ汾 +*˵ +* FSName FSļ +* ciFSVersion[]8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*************************************/ +UINT8 dquGetPrivateFSVersion(CHAR* FSName, UINT8 ciFSVersion[DFS_VERSION_LENGTH_PRIV]) +{ + + UINT8 i = 0U; + UINT8 rtnValue = 0U;//2ʾ + UINT8 readFlag = 0U; + + if ((NULL != FSName) && (NULL != ciFSVersion)) + { + rtnValue = 1U; + readFlag = dataRead(FSName); + readFlag *= DHFromByte(&g_pDFsDH->dataHead, g_pDataBuf); + if (0U == readFlag) + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + else + { + for (i = 0U; i < DFS_VERSION_LENGTH_PRIV; i++) + { + ciFSVersion[i] = g_pDFsDH->dataHead.spareByte[7-i]; + } + + rtnValue = 1U; + } + } + else + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + return rtnValue; +} + +/************************************** +*ܣȡOCݽṹ汾 +*˵ +* FSName FSļ +* ciFSVersion[]8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*************************************/ +UINT8 dquGetOcDataFSVersion(CHAR* FSName, UINT8 ciFSVersion[DFS_VERSION_LENGTH_PRIV]) +{ + + UINT8 i = 0U; + UINT8 rtnValue = 0U; + UINT8 readFlag = 0U; + + if ((NULL != FSName) && (NULL != ciFSVersion)) + { + rtnValue = 1U; + readFlag = dataRead(FSName); + readFlag *= DHFromByte(&g_pDFsDH->dataHead, g_pDataBuf); + if (0U == readFlag) + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + else + { + for (i = 0U; i < DFS_VERSION_LENGTH_PRIV; i++) + { + ciFSVersion[i] = g_pDFsDH->dataHead.spareByte[13 - i]; + } + + rtnValue = 1U; + } + } + else + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + return rtnValue; +} + +/* +*ܣȡĿ汾 +*˵ + FSName FSļ + dataType ͣӦĿID + dataVersion[] 8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*/ +UINT8 dquGetDataVersion(CHAR* FSName, UINT32 dataType,UINT8 dataVersion[DFS_VERSION_LENGTH]) +{ + UINT32 i=0U; + UINT32 j=0U; + DH tempDH={0U}; + UINT8 rtnValue = 0U; + UINT8 readFlag = 0U; + if((NULL!=FSName) && (NULL!= dataVersion)) + { + readFlag = dataRead(FSName); + if (1U == readFlag) + { + for (i = 0; i < g_pDFsDH->dataHead.indexNumber; i++) + { + /*ҵIDFSļͷ*/ + if (g_pDFsDH->dataIndex[i].dataID == dataType) + { + /*ͷ*/ + /*ڶͷа汾*/ + readFlag = DHFromByte(&tempDH, g_pDataBuf + g_pDFsDH->dataIndex[i].dataAddress); + if (0U == readFlag) + { + /*DHFromByteȡʧ*/ + rtnValue = 0U; + break; + } + for (j = 0; j < DFS_VERSION_LENGTH; j++) + { + dataVersion[j] = tempDH.version[j]; + } + rtnValue = 1; + } + } + if (0U == rtnValue) + { + /*ûҵdataType*/ + dataTypeErrNo |= ERR_DATA_TYPE; + } + } + else + { + rtnValue = 0U;//ļȡʧ + fileErrNo |= ERR_FILE_READ; + } + } + else + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + return rtnValue; +} + +/* +*ܣȡ(ֿ֧չܵı) +*ߣ smy 20190130 +*ԭFSпɶȡϢݴϢӿ +*˵ + FSName FSļ + dataType ɲѯ궨巽ʽ + tableID ID ɲѯ궨巽ʽ + + dataBuffer ݵַָ + dataLength ݳ + rowCount +*ֵ 0ʧܣ1ɹ +*/ +UINT8 dquGetConfigDataNew(CHAR *FSName, UINT32 dataType, UINT32 dataID, UINT8 **dataBuffer, UINT32 *dataLength, UINT16 *rowCount) +{ + dfsDataHead tempDfsDh={0U}; /*ʱ*/ + UINT32 i=0U; + UINT32 j=0U; + UINT32 pDataOffset=0U; + UINT8 *pData=NULL; + UINT8 rtnValue = 0U; + UINT8 readFlag = 0U; + + if ((NULL == FSName) || (NULL == dataBuffer) || (NULL == dataLength) || (NULL == rowCount)) + { + /*鲻ͨ*/ + fileErrNo |= ERR_PTR_NULL; + rtnValue = 0U; + } + else + { + readFlag = dataRead(FSName); + } + if((1 != readFlag)) + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + else + { + for(i=0;idataHead.indexNumber;i++) + { + /*ҵIDFSļͷ*/ + if(g_pDFsDH->dataIndex[i].dataID == dataType) + { + /*ַ׵ַ + еĵַƫ*/ + pData = g_pDataBuf + g_pDFsDH->dataIndex[i].dataAddress; + + /*ͷ*/ + DHFromByte(&tempDfsDh.dataHead,pData); + pDataOffset = DFS_DATA_HEAD_SIZE; + for(j=0;jdataHead.indexNumber;i++) + { + /*ҵIDFSļͷ*/ + if(pDfsDH->dataIndex[i].dataID == dataType) + { + /*ַ׵ַ + еĵַƫ*/ + pData = pDataBuf + pDfsDH->dataIndex[i].dataAddress; + + /*ͷ*/ + DHFromByte(&tempDfsDh.dataHead,pData); + pDataOffset = DFS_DATA_HEAD_SIZE; + for(j=0;jdataHead.indexNumber; i++) + { + /*ҵIDFSļͷ*/ + if (g_pDFsDH->dataIndex[i].dataID == dataType) + { + /*ַ׵ַ + еĵַƫ*/ + pData = g_pDataBuf + g_pDFsDH->dataIndex[i].dataAddress; + + /*ͷ*/ + readFlag = DHFromByte(&tempDfsDh.dataHead, pData); + if (0U == readFlag) + { + rtnValue = 0U; + } + + pDataOffset = DFS_DATA_HEAD_SIZE; + for (j = 0; jdataHead.indexNumber;i++) + { + /*ҵIDFSļͷ*/ + if(pDfsDH->dataIndex[i].dataID == dataType) + { + /*ַ׵ַ + еĵַƫ*/ + pData = pDataBuf + pDfsDH->dataIndex[i].dataAddress; + + /*ͷ*/ + DHFromByte(&tempDfsDh.dataHead,pData); + pDataOffset = DFS_DATA_HEAD_SIZE; + for(j=0;jdataHead.version[i]; + } + + rtnValue = 1U; + } + else + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + + return rtnValue; +} + + +/*************************************** +*ܣȡĿ汾 +*˵ +* FSName FSļ +* dataType ͣӦĿID +* dataVersion[] 8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +***************************************/ +UINT8 dquGetDataVersionExp (UINT8 *pDataBuf,dfsDataHead *pDfsDH, UINT32 dataType,UINT8 dataVersion[DFS_VERSION_LENGTH]) +{ + UINT32 i=0U; + UINT32 j=0U; + DH tempDH={0U}; + UINT8 rtnValue = 0U; + UINT8 Found=0U; + UINT8 readFlag = 0U; + + if((NULL != pDataBuf) && (NULL != pDfsDH) && (NULL!= dataVersion)) + { + for(i=0;idataHead.indexNumber;i++) + { + /*ҵIDFSļͷ*/ + if(pDfsDH->dataIndex[i].dataID == dataType) + { + /*ͷ*/ + /*ڶͷа汾*/ + DHFromByte(&tempDH,pDataBuf + pDfsDH->dataIndex[i].dataAddress); + for(j=0;jdataHead.version[0]; + bRetVal=1U; + } + else + { + } + + return bRetVal; +} + +/*ȡݵĹӦ̱*/ +UINT8 dquGetDataSupplierID(dfsDataHead *pDfsDH, UINT8 *pSupplierID) +{ + UINT8 bRetVal=0U; + if ((NULL != pDfsDH) && (NULL != pSupplierID)) + { + *pSupplierID=pDfsDH->dataHead.spareByte[1]; + bRetVal=1U; + } + else + { + } + + return bRetVal; +} + + + +/***************************************************************************** +*ܣѭڶȡϴļ +*˵ + dataName ļ洢FLASHַ + Lengthsȡļܳ + * *pDataBufڴд洢ַ + * ReadLengthζȡݵij + * ReadModeȡʽ1:һԶȡļ;2:ֳɶζȡ +*ֵ 0x55 ɹ,0xAA ʧ,0xFF Ĭֵ +********************************************************************************/ +UINT8 ReadCycle(CHAR *dataName,UINT8 *pDataBuf,UINT32 ReadLength,UINT8 ReadMode,UINT32 FileLengths) +{ + UINT8 rtnValue = 0xffU; + UINT32 dwTotalReadTimes = 0; /*ȡ*/ + + static UINT32 dwIndexRead = 0; + static UINT32 ReadCurrentTimes = 1; + volatile UINT8 * pDataAddr; + + pDataAddr = (volatile UINT8 * )dataName; + + + if (0U < ReadLength) + { + /*ļҪȡĴ*/ + dwTotalReadTimes = (FileLengths-DFS_DATA_HEAD_SIZE)/ReadLength; + } + else + { + rtnValue = 0xaa; + } + + /*ְȡ*/ + if((NULL!= dataName) && (NULL != pDataBuf) && (0 < dwTotalReadTimes)) + { + + /*һβҪд + ַָָÿӵһζȡλãpDataAddrΪֲ + ظõʱʹָ׵ַʼڴӸϢ*/ + if(1 != ReadCurrentTimes) + { + pDataAddr = pDataAddr+DFS_DATA_HEAD_SIZE + (ReadCurrentTimes-1) * ReadLength; + } + + /*ǰȡСܵĶȡ*/ + if(ReadCurrentTimes <= dwTotalReadTimes) + { + while(dwIndexRead < (DFS_DATA_HEAD_SIZE + ReadCurrentTimes * ReadLength)) + { + + pDataBuf[dwIndexRead] = *pDataAddr; + pDataAddr++; + dwIndexRead++; + } + ReadCurrentTimes = ReadCurrentTimes+1; + } + else + { + /*ʣȫȥ*/ + while(dwIndexReadDataBuf) + { + g_pDataBuf=pFsStorStu->DataBuf; + } + else + { + rtnValue = 0U; + } + + if (NULL!=pFsStorStu->DfsDH) + { + g_pDFsDH=pFsStorStu->DfsDH; + } + else + { + rtnValue = 0U; + } + } + else + { + } + + return rtnValue; +} + +/*ȡFSļ汾ź·*/ +UINT8 dquGetFsVersionAndLineNum(CHAR *dataName,UINT8 *LineNum,UINT8 *FsVersion) +{ + UINT8 bRetVal=0U; + volatile UINT8 * pDataAddr; + UINT8 i = 0U; + if ((NULL!=dataName) && (NULL!= LineNum) && (NULL!= FsVersion)) + { + pDataAddr = (volatile UINT8 * )dataName; + + *LineNum = *(pDataAddr+4); + /*ȡݰ汾*/ + pDataAddr = pDataAddr+4; + for(i=0;i<4;i++) + { + FsVersion[i] = *pDataAddr; + pDataAddr++; + } + bRetVal=1; + } + else + { + bRetVal=0U; + } + return bRetVal; +} diff --git a/TSCP/src/dqu_common/dqu_dfs_common/dfsDataRead.h b/TSCP/src/dqu_common/dqu_dfs_common/dfsDataRead.h new file mode 100644 index 0000000..1c7208a --- /dev/null +++ b/TSCP/src/dqu_common/dqu_dfs_common/dfsDataRead.h @@ -0,0 +1,350 @@ +/************************************************************************ +* +* ļ dfsDataRead.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.09.22 +* +* ļϵͳļԤ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DFS_DATA_READ_H +#define DFS_DATA_READ_H + +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ +#include +#include +#include "CommonTypes.h" +#include "Convert.h" +#include "CRC32.h" + +#define DQU_DFS_VER1 66 /*Ʒ*/ +#define DQU_DFS_VER2 19 /*ģ*/ +#define DQU_DFS_VER3 0u /*ģ汾*/ +#define DQU_DFS_VER4 2u /*ģӰ汾*/ + +#define DFS_DATA_INDEX_NUM 100u /*Ԥļͷĸ m by sds 2018-11-19*/ +#define DFS_MAX_FILE_LEN ((UINT32)(6*1024*1024)) /*ֵ֧ļȣ6M*/ + +#define DFS_DH_SPARE_BYTE_LENGTH 20u /*Ԥֽڳ*/ +#define DFS_DI_SPARE_BYTE_LENGTH 8u /*Ԥֽڳ*/ +#define DATA_CONTENT_MALLOC_SIZE (0x300000) /*FSݿٿռ*/ +/*ļȡʧܴ*/ +#define LOAD_FILE_READ_ERR 0X00000001 /*ļʧ*/ +#define LOAD_FILE_LENGTH_ERR 0X00000002 /*ļȡȴ*/ +#define DFS_VERSION_LENGTH 4u /*汾ų*/ +#define DFS_VERSION_LENGTH_PRIV 2u /*˽ݽṹ汾ų*/ + +#define DFS_DATA_HEAD_SIZE 40u /*ļͷС*/ +#define DFS_DATA_INDEX_SIZE 24u /*ļͷС*/ + +/*20160316ͨغ궨*/ +#define READ_LENGTH_ONCE 2236 /*һζȡݵij*/ + +#define LENGTH_OF_READ 3266 /*һζȡݵij*/ +#define LENGTH_OF_WRITE 3266 /*һдij*/ +#define READ_MODE_ONCE 1u /*һԶȡģʽ*/ +#define READ_MODE_TIMES 2u /*ֶζȡ*/ +/*****궨******/ + +#define ERR_FILE_READ 0x0001 /*ȡļʧ*/ +#define ERR_FILE_LENTH 0x0002 /*ļ*/ +#define ERR_CRC_CHECK 0x0004 /*CRCУʧ*/ + +#define ERR_DATA_TYPE 0x0001 /*ʹ*/ +#define ERR_DATA_ID 0x0002 /*ID*/ +#define ERR_PTR_NULL 0x0003 /*ָΪ*/ +/*****궨****/ + +/*ִд*/ +#define DSU_FUNC_SUCESS (0x00000000) +#define DSU_FUNC_CODE1 (0x00000001) +#define DSU_FUNC_CODE2 (0x00000002) +#define DSU_FUNC_CODE3 (0x00000004) +#define DSU_FUNC_CODE4 (0x00000008) +#define DSU_FUNC_CODE5 (0x00000010) +#define DSU_FUNC_CODE6 (0x00000020) +#define DSU_FUNC_CODE7 (0x00000040) +#define DSU_FUNC_CODE8 (0x00000080) +#define DSU_FUNC_CODE9 (0x00000100) +#define DSU_FUNC_CODE10 (0x00000200) +#define DSU_FUNC_CODE11 (0x00000400) +#define DSU_FUNC_CODE12 (0x00000800) +#define DSU_FUNC_CODE13 (0x00001000) +#define DSU_FUNC_CODE14 (0x00002000) +#define DSU_FUNC_CODE15 (0x00004000) +#define DSU_FUNC_CODE16 (0x00008000) + +#ifdef __cplusplus +extern "C" { +#endif + + +extern UINT16 fileErrNo ; +extern UINT16 dataTypeErrNo ; + +/*ļͷṹ*/ +struct DataHead +{ + UINT32 crc; /*ļCRC*/ + UINT8 version[8]; /*汾*/ + UINT32 dataLength; /*ݳ*/ + UINT32 indexNumber; /**/ + UCHAR spareByte[DFS_DH_SPARE_BYTE_LENGTH]; /*Ԥ20ֽ*/ +}; + +/*ļͷṹ*/ +struct DataIndex +{ + UINT32 dataID; /*ID*/ + UINT32 dataLength; /*ݿ鳤*/ + UINT32 dataAddress; /*ݵַ*/ + UINT16 dataRowCount; /*ݱʾݵ*/ + UINT16 dataColCount; /*ݱʾݵ*/ + UCHAR spareByte[DFS_DI_SPARE_BYTE_LENGTH]; /*Ԥ8ֽڣļͷļͷ*/ +}; + + +typedef struct DataHead DH; /*ͷ*/ +typedef struct DataIndex DI; /**/ + +/*һļͷ,ͷϢ*/ +typedef struct dfsDataHeadUnit +{ + DH dataHead; /*ͷ*/ + DI dataIndex[DFS_DATA_INDEX_NUM]; /**/ + +}dfsDataHead; + +typedef struct dquReadDataStorStru +{ + /*洢flashжȡļ*/ + UINT8 *DataBuf; + /*Ӧļͷ*/ + dfsDataHead *DfsDH; + /*ζȡݵij*/ + UINT32 ReadLength; + /*ȡݵģʽ*/ + UINT8 ReadMode; + +}DQU_READ_DATA_STOR_STRU; + +extern UINT8 *g_pDataBuf; /*Ԥ.fsļڴռ*/ +extern UINT32 g_DataBufLen;/*FSļڴ泤*/; +extern dfsDataHead *g_pDFsDH; /*洢FSļͷϢ,ͷϢ*/ + + +/********************************************* +*ܣдģ汾Żȡ +*˵ϵͳòѯ汾ţֹɴ +*ڲ +*ڲ +*ֵUINT32ʾİ汾 +*********************************************/ +UINT32 GetDquDfsVersion(void); + +/********************************************* +*ܣͷṹ +*˵pDHǴͷṹָ + pDataַ +*ֵ +*********************************************/ +UINT8 DHFromByte(DH * pDH,UINT8 *pData); + +/********************************************* +*ܣṹ +*˵pDIǴṹָ + pDataַ +*ֵ +*********************************************/ +UINT8 DIFromByte(DI* pDI,UINT8 *pData); + +/********************************************* +*ܣȡļڴdataBuf[] +*˵fileNameļ +*ֵ1ɹ0ʧ +**********************************/ +UINT8 dataRead(CHAR* dataName); + +/*ܣȡļFSͷòѯİ汾(ڴ)*/ +UINT8 dataReadNoCopy(CHAR* dataName); + +/*ܣȡļڴdataBuf[] +*˵dataNameļ洢FLASHַ +* Lengthsȡļܳ +* *pDataBufڴд洢ַ +* ReadLengthζȡݵij +* ReadModeȡʽ1:һԶȡļ; 2:ֳɶζȡ +* dfsDH һļͷ, ͷ, Ϣ +* checkNumOfCRC ֲȼģʽµģCRCʱIJУĴ( + * FSֽ / ֵ㵥ֽ֤FS + * Ϊ1MƼֵΪ100) + *ֵ 0ʧܣ1ɹ, 2֡ȡɹ; +**************************************************************************/ +UINT8 dataReadExp(CHAR *dataName, DQU_READ_DATA_STOR_STRU *FsStorStu, UINT8 checkNumOfCRC); + + +/*************************************************** +*ܣdquGetConfigDatadataReaddataReadExpɹȡ־ +*˵ +* +*ֵ1ɹ0ʧ +***********************************************/ +UINT8 clearDataReadFlag(void); + + +/********************************************* +*ܣFSļͷϢ +*˵ + pDataBuf ݵַ + pDfsDH ݵͷϢ +*ֵ1ɹ0ʧ +**********************************/ +UINT8 dquAnalyzeFsDataHead(UINT8 *pDataBuf,dfsDataHead *pDfsDH); + + +/* +*ܣȡFSļ汾 +*˵ + FSName FSļ + FSVersion[]8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*/ + +UINT8 dquGetFSVersion(CHAR * FSName,UINT8 FSVersion[DFS_VERSION_LENGTH]); + + +/*ܣȡݽṹ汾 +* ˵ +* FSName FSļ +* publicFSVersion[]8ֽڰ汾 +* ֵ 0ʧܣ1ɹ +* ************************************/ +UINT8 dquGetPublicFSVersion(CHAR * FSName, UINT8 publicFSVersion[DFS_VERSION_LENGTH]); + + +/************************************** +*ܣȡ˽ݽṹ汾 +*˵ +* FSName FSļ +* ciFSVersion[]8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*************************************/ +UINT8 dquGetPrivateFSVersion(CHAR* FSName, UINT8 ciFSVersion[DFS_VERSION_LENGTH_PRIV]); + +/************************************** +*ܣȡOCݽṹ汾 +*˵ +* FSName FSļ +* ciFSVersion[]8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*************************************/ +UINT8 dquGetOcDataFSVersion(CHAR* FSName, UINT8 ciFSVersion[DFS_VERSION_LENGTH_PRIV]); + +/* +*ܣȡ(ֿ֧չܵı) +*˵ + FSName FSļ + dataType ɲѯ궨巽ʽ + tableID ID ɲѯ궨巽ʽ + + dataBuffer ݵַָ + dataLength ݳ + rowCount +*ֵ 0ʧܣ1ɹ +*/ +UINT8 dquGetConfigDataNew(CHAR *FSName, UINT32 dataType, UINT32 dataID, UINT8 **dataBuffer, UINT32 *dataLength, UINT16 *rowCount); + +/*ȡչ(ֿ֧չܵı)*/ +UINT8 dquGetConfigDataExpNew(UINT8 *pDataBuf, dfsDataHead *pDfsDH, UINT32 dataType, UINT32 dataID, UINT8 **dataBuffer, UINT32 *dataLength, UINT16 *rowCount); + + +/* +*ܣȡ +*˵ + FSName FSļ + dataType ɲѯ궨巽ʽ + tableID ID ɲѯ궨巽ʽ + + dataBuffer ݵַָ + dataLength ݳ + rowCount +*ֵ 0ʧܣ1ɹ +*/ +UINT8 dquGetConfigData(CHAR *FSName, UINT32 dataType, UINT32 dataID, UINT8 **dataBuffer, UINT32 *dataLength); + +/*ȡչ*/ +UINT8 dquGetConfigDataExp(UINT8 *pDataBuf, dfsDataHead *pDfsDH, UINT32 dataType, UINT32 dataID, UINT8 **dataBuffer, UINT32 *dataLength); + +/* +*ܣȡݰ汾 +*˵ + FSName FSļ + dataType ͣɲѯ궨巽ʽ + dataVersion[] 8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*/ +UINT8 dquGetDataVersion (CHAR* FSName, UINT32 dataType, UINT8 dataVersion[DFS_VERSION_LENGTH]); + +/********************************************* +*ܣڴռ +*˵newSizeռ䳤 +*ֵ +*********************************************/ +void * MyNew(UINT32 newSize); + +/************************************** +*ܣȡFSļ汾չ +*˵ +* pDfsDH FSͷ +* FSVersion[]8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +*************************************/ +UINT8 dquGetFSVersionExp(dfsDataHead *pDfsDH ,UINT8 FSVersion[DFS_VERSION_LENGTH]); + +/*************************************** +*ܣȡĿ汾չ汾 +*˵ +* FSName FSļ +* dataType ͣӦĿID +* dataVersion[] 8ֽڰ汾 +*ֵ 0ʧܣ1ɹ +***************************************/ +UINT8 dquGetDataVersionExp (UINT8 *pDataBuf,dfsDataHead *pDfsDH, UINT32 dataType,UINT8 dataVersion[DFS_VERSION_LENGTH]); + +/*ȡݵ·*/ +UINT8 dquGetDataLineID(dfsDataHead *pDfsDH, UINT8 *pLineID); + +/*ȡݵĹӦ̱*/ +UINT8 dquGetDataSupplierID(dfsDataHead *pDfsDH, UINT8 *pSupplierID); + + +/***************************************************************************** +*ܣѭڶȡϴļ +*˵ + dataName ļ洢FLASHַ + Lengthsȡļܳ + * *pDataBufڴд洢ַ + * ReadLengthζȡݵij + * ReadModeȡʽ1:һԶȡļ;2:ֳɶζȡ +*ֵ 0ʧܣ1ɹ +********************************************************************************/ +UINT8 ReadCycle(CHAR *dataName,UINT8 *pDataBuf,UINT32 ReadLength,UINT8 ReadMode,UINT32 FileLengths); + + +/*FSȡṹ*/ +UINT8 dquSetFSReadStruParamRef(DQU_READ_DATA_STOR_STRU *pFsStorStu); + +/*ȡFSļ汾ź·*/ +UINT8 dquGetFsVersionAndLineNum(CHAR *dataName,UINT8 *LineNum,UINT8 *FsVersion); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/TSCP/src/dqu_common/dqu_dfs_common/dquCbtcType.c b/TSCP/src/dqu_common/dqu_dfs_common/dquCbtcType.c new file mode 100644 index 0000000..e1a622b --- /dev/null +++ b/TSCP/src/dqu_common/dqu_dfs_common/dquCbtcType.c @@ -0,0 +1,93 @@ +/************************************************************************ +* +* ļ dquCbtcType.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2016.03.14 +* +* ӵͼʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "dquCbtcType.h" + +UINT8 g_CbtcVersionType=0xff; + +static TIME_FUN_PTR g_timingFunction=NULL; + +/********************************************* +*ܣCBTCϵͳ +*˵ϵͳòѯϵͳ汾 +*ڲ +*ڲ +*ֵUINT8ʾϵͳ +*********************************************/ +void SetCbtcSysType(UINT8 sysType) +{ + if(0xff == g_CbtcVersionType) + { + g_CbtcVersionType=sysType; + } + else + { + + } +} + +/********************************************* +*ܣCBTCϵͳͻȡ +*˵ѯǰϵͳ汾͡ +*ڲ +*ڲ +*ֵUINT8ʾϵͳ +*********************************************/ +UINT8 GetCbtcSysType(void) +{ + return g_CbtcVersionType; +} + + +/********************************************** +*ܣCBTCϵͳ汾Ϣ +*˵ޡ +*ڲ +*ڲ +*ֵUINT8ʾϵͳ +*********************************************/ +void ResetCbtcVersionType(void) +{ + g_CbtcVersionType=0xff; +} + +/*õǰʱ*/ +UINT8 dquSetUsedTimeFunPtr(TIME_FUN_PTR pTimeFun) +{ + UINT8 bRetVal=0U; + + if (NULL!=pTimeFun) + { + g_timingFunction=pTimeFun; + bRetVal=1; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + +/*ȡǰʱ(λ:)*/ +UINT32 dquGetCurrentTimeByMS(void) +{ + if( NULL != g_timingFunction) + { + return g_timingFunction(); + } + else + { + return 0; + } + +} \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_dfs_common/dquCbtcType.h b/TSCP/src/dqu_common/dqu_dfs_common/dquCbtcType.h new file mode 100644 index 0000000..ccc55a6 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_dfs_common/dquCbtcType.h @@ -0,0 +1,105 @@ +/************************************************************************ +* +* ļ dquCbtcType.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2016.03.14 +* +* ӵͼʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_CBTC_TYPE_H +#define DQU_CBTC_TYPE_H + +#include "CommonTypes.h" + +#define DQU_CBTC_FAO 1U /*ȫԶʻϵͳ*/ +#define DQU_CBTC_CPK 2U /*Ͽϵͳ*/ +#define DQU_CBTC_HLT 3U /*ͨϵͳ*/ +#define DQU_CBTC_DG 4U /*ϵͳ add by qxt 20170621*/ +#define DQU_CBTC_CC 5U /*ϵͳ add by qw.liu 2022-2-22*/ + +#define DQU_QFUN_TRUE 0x55 /*Ϊ*/ +#define DQU_QFUN_FASLE 0xAA /*Ϊ*/ + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef UINT8 (*DQU_QFUN_DATA_INIT)(UINT8*, UINT32, UINT16);/*ݳʼͺ*/ +typedef UINT8 (*DQU_QFUN_DATA_CALC)(); /*ݼ㴦ͺ*/ + +/*ʼṹ*/ +typedef struct struInitTaskTab +{ + UINT8 bIsEffective; /*ǷЧDQU_QFUN_TRUEЧ,DQU_QFUN_FASLEЧ*/ + UINT8 DataTypeId; /**/ + DQU_QFUN_DATA_INIT pExeFun; /*ִк*/ + UINT16 wStepLen; /*趨ѭ*/ + + /*ʱ*/ + UINT16 wCurProcStage; /*¼ǰн׶*/ + UINT16 wCurInitPos; /*ǰѭλ*/ +}INIT_TASK_TAB_STRU; + +/*ṹ*/ +typedef struct struCalcTaskTab +{ + UINT8 bIsEffective; /*ǷЧDQU_QFUN_TRUEЧ,DQU_QFUN_FASLEЧ*/ + UINT8 ProcTypeId; /**/ + DQU_QFUN_DATA_CALC pExeFun; /*ִк*/ + UINT16 wStepLen; /*趨ѭ*/ + + /*ʱ*/ + UINT16 wCurProcStage; /*¼ǰн׶*/ + UINT16 wCurInitPos; /*ǰѭλ*/ + UINT8 bIsInTheLoop; /*ǷѭУ0ڣ1*/ +}CALC_TASK_TAB_STRU; + + +/********************************************* +*ܣCBTCϵͳ +*˵ϵͳòѯϵͳ汾 +*ڲ +*ڲ +*ֵUINT8ʾϵͳ +*********************************************/ +void SetCbtcSysType(UINT8 sysType); + +/********************************************* +*ܣCBTCϵͳͻȡ +*˵ѯǰϵͳ汾͡ +*ڲ +*ڲ +*ֵUINT8ʾϵͳ +*********************************************/ +UINT8 GetCbtcSysType(void); + + +/*ʱ亯ָ*/ +typedef UINT32 (*TIME_FUN_PTR)(); + +/*õǰʱ*/ +UINT8 dquSetUsedTimeFunPtr(TIME_FUN_PTR pTimeFun); + +/*ȡǰʱ(λ:)*/ +UINT32 dquGetCurrentTimeByMS(void); + +/********************************************** +*ܣCBTCϵͳ汾Ϣ +*˵ޡ +*ڲ +*ڲ +*ֵUINT8ʾϵͳ +*********************************************/ +void ResetCbtcVersionType(void); + +#ifdef __cplusplus +} +#endif + + +#endif \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_dfs_common/dquDataTypeDefine.h b/TSCP/src/dqu_common/dqu_dfs_common/dquDataTypeDefine.h new file mode 100644 index 0000000..ea3c7b4 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_dfs_common/dquDataTypeDefine.h @@ -0,0 +1,214 @@ +/************************************************************************ +* +* ļ dquDataTypeDefine.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.09.22 +* +* ļϵͳļԤ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + + +#ifndef DQU_DATA_TYPE_DEFINE_H +#define DQU_DATA_TYPE_DEFINE_H + + +#define EMAP_DATA_TYPE 0x10 /*ӵͼID*/ + +/*ӵͼID*/ +#define EMAP_NOP_0 0 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_LINK_ID 1 /*linkID*/ +#define EMAP_POINT_ID 2 /*ID*/ +#define EMAP_SIGNAL_ID 3 /*źŻID*/ +#define EMAP_BALISE_ID 4 /*ӦID*/ +#define EMAP_AXLE_ID 5 /*ID*/ +#define EMAP_SCREEN_ID 6 /*ȫID*/ +#define EMAP_EMERG_STOP_BUTTON_ID 7 /*ͣťID*/ +#define EMAP_STATION_ID 8 /*ͣID*/ +#define EMAP_STOPPOINT_ID 9 /*ͣID*/ +#define EMAP_AXLE_SGMT_ID 10 /*ID*/ +#define EMAP_LOGIC_SGMT_ID 11 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID qw.liu 2022-02-22*/ +#define EMAP_ROUTE_ID 12 /*·ID*/ +#define EMAP_PROTECT_LINK_ID 13 /*ID*/ +#define EMAP_BLOC_ACCESS_LINK_ID 14 /*ʽӽID*/ +#define EMAP_CBTC_ACCESS_LINK_ID 15 /*CBTCӽID*/ +#define EMAP_GRADE_ID 16 /*¶ID*/ +#define EMAP_STATIC_RES_SPEED_ID 17 /*̬ID*/ +#define EMAP_DEFAULT_ROUTE_ID 18 /*ĬгID*/ +#define EMAP_RUN_LEVEL_ID 19 /*վӪID*/ +#define EMAP_EXIT_ROUTE_ID 20 /*˳CBTCID*/ +#define EMAP_TRAIN_LINE_ID 21 /*CBTCID*/ +#define EMAP_AR_ID 22 /*Զ۷ID*/ +#define EMAP_ZC_DIVID_POINT_ID 23 /*ZCֽID*/ +#define EMAP_ZC_COM_ZONE_ID 24 /*ZCID*/ +#define EMAP_CI_ID 25 /*CIID*/ +#define EMAP_NOP_26 26 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID qw.liu 2022-02-22*/ +#define EMAP_CONRESSPEED_ID 27 /*ͳһID*/ +#define EMAP_CONGRADE_ID 28 /*ͳһ¶ID*/ +#define EMAP_PHYSICAL_SGMT_ID 29 /*ID*/ +#define EMAP_BLOC_TRG_AREA_ID 30 /*ʽID*/ +#define EMAP_CBTC_TRG_AREA_ID 31 /*CBTCID*/ +#define EMAP_PLAT_FORM_ID 32 /*վ̨ID*/ +#define EMAP_COME_GO_ID 33 /*·*/ +#define EMAP_FLOOD_GATE_ID 34 /*---20140718һ*/ +#define EMAP_SPKS_BUTTON_ID 35 /*SPKSť---20141217һ*/ +#define EMAP_DEPOT_GATE_ID 36 /*---20141217һ*/ +#define EMAP_TUNNEL_ID 37 /*--20160405*/ +#define EMAP_ZC_ID 38 /*ZCID*/ +#define EMAP_MULTI_POINT_ID 39 /*࿪ID add by qxt 20170621*/ +#define EMAP_NOP_40 40 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_POWERLESSZONE_ID 41 /*IDݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ +#define EMAP_NOP_42 42 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_43 43 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_44 44 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_45 45 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_ATS_ID 46 /*ATSУϢ*/ +#define EMAP_NOP_47 47 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_48 48 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_49 49 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_50 50 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_CARSTOP_ID 51 /*IDݻͨݽṹV15.0.0ӣadd by sds 20181031*/ +#define EMAP_ADJTSTATION_ID 52 /*ͣIDݻͨݽṹV15.1.2ӣadd by mbb 20190807*/ +#define EMAP_PSC_ID 53 /*PSCID*/ +#define EMAP_NOP_54 54 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_EA_ID 55 /**/ +#define EMAP_NOP_56 56 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_57 57 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_58 58 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_LOGSEC_SPKS_BUTTON_ID 59 /*߼SPKSر*/ +#define EMAP_NOP_60 60 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_61 61 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_62 62 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_63 63 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_64 64 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_65 65 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_66 66 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_67 67 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_68 68 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_69 69 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_70 70 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_71 71 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_72 72 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_73 73 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_74 74 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_75 75 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_76 76 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_77 77 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_78 78 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_79 79 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ +#define EMAP_NOP_80 80 /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID tqf*/ + +/*ϵͳ 궨*/ +#define CBTC_CONFIGDATA_TYPE 0x20 /*ϵͳ*/ +#define CBTC_TRAIN_TYPE_CONFIG_ID 1 /*гID*/ +#define CBTC_TRAIN_INFO_ID 2 /*ID*/ +#define CBTC_CONFIG_DATA_ID 3 /*ϵͳID*/ +#define CBTC_CONFIG_DEPOT_ID 4 /*ϢID*/ +#define CBTC_CONFIG_BOUNDARY_AXLE_ID 5 /*߽ñID*/ + +/*Э 궨*/ +#define DSU_DATA_PROTCL_TYPE 0x30 /*ЭbookId*/ +#define DSU_DATA_PROTCL_RSSP_LNK_ID 1 /*rssp lnk ϢtableId*/ +#define DSU_DATA_PROTCL_CI_PLATFORM_ID 2 /*ƽ̨ݽṹtableId*/ +#define DSU_DATA_PROTCL_COMM_INFO_ID 3 /*豸ͨԱtableId*/ +#define DSU_DATA_PROTCL_FSFB_LNK_ID 6 /*FSFBЭ·ϢtableId*/ + +/*豸IP 궨*/ +#define DSU_DEVICE_IP_CONFIG_TYPE 0x40 /*豸ipbookId*/ +#define DSU_DATA_IP_IP_ID 1 /*ipַtableId*/ +#define DSU_DATA_IP_COMM_PROTCL_ID 2 /*豸ͨЭϵtableId*/ +#define DSU_DATA_IP_CCOV_COMM_ID 3 /*CCOVͨŹϵñtableId*/ +#define DSU_DATA_IP_ZCDSU_COMM_ID 4 /*ZCDSUͨŹϵñtableId*/ +#define DSU_DATA_IP_GATEWAY_ID 5 /*hxq,豸رtableId*/ +#define DSU_CI_ATS_DEVICE_IP_ADDR 6 /*CI_ATS豸IPַ add by qxt 20160811 */ + +/*ATP/ATO 궨*/ +#define VOBC_CONFIGDATA_TYPE 0x50 /*ATP/ATOϵͳ*/ +#define VOBC_RAIL_INFO_ID 1 /*ATP/ATO·*/ +#define VOBC_TRAIN_INFO_ID 2 /*ATP/ATOó*/ +#define VOBC_ACC_TABLE_ID 3 /*ǣٶȷֶȡֵ*/ +#define VOBC_RATIO_ACC_TABLE_ID 4 /*ٶֵID ԵݽṹV3.0.0 add by lmy 20180305*/ +#define VOBC_AWAKEN_CONFIG_DATA 5 /* ԻͨݽṹV13.0.0 add by sds 20180625*/ +#define VOBC_FUNC_CONFIG_DATA 6 /*ATPATOùܱ ԻͨݽṹV18.0.0 add by sds 20200522*/ + +/*TMS 궨*/ +#define TMS_CONFIGDATA_TYPE 0x81 +#define TMS_PORT_INFO_ID 1 /*˿Ϣ*/ +#define TMS_VOBC_SEND_INFO_ID 2 /*˿ڶӦVOBC->TMSϢ*/ +#define TMS_VOBC_RECV_INFO_ID 3 /*˿ڶӦTMS->VOBCϢ*/ + +/*ATP 궨*/ +#define VOBC_ATP_CONFIGDATA_TYPE 0x60 /*ATP */ +#define VOBC_ATP_TRAIN_CONFIGDATA_ID 1 /*ATP*/ +#define VOBC_ATP_SECURITY_CONFIGDATA_ID 2 /*ATP̰ȫ*/ +#define VOBC_ATP_FUNC_CONFIGDATA_ID 3 /*ATPñ ԻͨݽṹV18.0.0 add by sds 20200522*/ +#define VOBC_ATP_PRODUCT_SECURITY_CONFIGDATA_ID 4 /*ATPƷȫ ԻͨݽṹV18.0.0 add by sds 20200522*/ + +/*ID궨*/ + +/*ɱӦ汾 궨*/ +#define DSU_BALISE_VER_DATA_TYPE 0x80 +#define DSU_BALISE_VER_DATA_ID 1 /*ɱӦ汾ID*/ + +/*ATO 궨*/ +#define VOBC_ATO_CONFIGDATA_TYPE 0x90 /*ATO */ +#define VOBC_ATO_PROJECT_CONFIGDATA_ID 1 /*ATO̲ñ*/ +#define VOBC_ATO_TRACTIONSAMPLE_ID 2 /*ǣ߱*/ +#define VOBC_ATO_BREAKSAMPLE_ID 3 /*ƶ߱*/ +#define VOBC_ATO_ESPECIALTRIPNUM_ID 4 /*⳵κŶ*/ +#define VOBC_ATO_PRODUCT_CONFIGDATA_ID 5 /*ATOƷñ*/ +#define VOBC_ATO_FUNC_CONFIGDATA_ID 6 /*ATOùܱ ԻͨݽṹV18.0.0 add by sds 20200522*/ + +/*ZCϵͳ*/ +#define ZC_CONFIGDATA_TYPE 0xA0 +#define ZC_CONFIGDATA_ID 1 /*ZC*/ +#define ZC_TESTSEGMENT_ID 2 /*̬ιϵ*/ +#define ZC_LOGIC_SEGMET_LOCAL 3 /*߼λùϵ*/ +#define ZC_FunctionConfig 4 /*ñݻͨݽṹV15.0.0ӣadd by sds 20181031*/ +#define ZC_ESBLINKAGESTATION_ID 5 /*ESBվűݻͨݽṹV12.0.0ӣadd by lmy 20180319*/ + +/*DSUϵͳ*/ +#define DSU_CONFIGDATA_TYPE 0xC0 +#define DSU_CONFIGDATA_ID 1 /*DSU*/ + +/*Ŷձ*/ +#define IDMAP_DATA_TYPE 0xF1 /*ŶձID*/ + +/*ŶձID*/ +#define IDMAP_ZC_ID 1 /*ZCID*/ +#define IDMAP_CI_ID 2 /*CIID*/ +#define IDMAP_ATS_ID 3 /*ATSID*/ +#define IDMAP_SIGNAL_ID 4 /*źŻID*/ +#define IDMAP_TRACKSEC_ID 5 /*αID*/ +#define IDMAP_SWITCH_ID 6 /*ID*/ +#define IDMAP_STATION_ID 7 /*վ̨ID*/ +#define IDMAP_EMERGBTN_ID 8 /*رհťID*/ +#define IDMAP_BALISE_ID 9 /*ӦID*/ +#define IDMAP_PSD_ID 10 /*űID*/ +#define IDMAP_VOBC_ID 11 /*VOBCID*/ +#define IDMAP_FPD_ID 12 /*űID*/ +#define IDMAP_DSU_ID 13 /*DSUID*/ +#define IDMAP_LOGICSEC_ID 14 /*߼αID add by qxt 20160811*/ +#define IDMAP_AOMSEC_ID 15 /*AOMID add by sds 2018-6-14*/ +#define IDMAP_SPKSSEC_ID 16 /*SPKSID add by sds 2018-6-14*/ +#define IDMAP_GODSEC_ID 17 /*űID add by sds 2018-6-14*/ +#define IDMAP_STASEC_ID 18 /*վID add by slm 2018-6-14*/ +#define IDMAP_PHYSEC_ID 19 /*αID add by slm 2018-6-14*/ +#define IDMAP_AXLE_ID 21 /*ϵͳID add by lq 2023-12-08*/ +#define IDMAP_ITE_ID 22 /*ITEID add by lq 2024-06-06*/ + +/*VOBCص ͨ add by qxt 20160811*/ +#define VOBC_OVERLAP_CONFIGDATA_TYPE 0xF3 /*VOBCصݱID*/ + +/*VOBCصݱID*/ +#define VOBC_OVERLAP_GROUNDDEV_ID 1 /*ӹܵĵ豸ϢID*/ +#define VOBC_OVERLAP_LINECONNECT_ID 2 /*·ӹϵID*/ + +/*NDSUϵͳ*/ +#define NDSU_CONFIGDATA_TYPE 0xF4 +#define NDSU_CONFIGDATA_ID 1 /*NDSU*/ + +#endif \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquEmapInit.c b/TSCP/src/dqu_common/dqu_emap_common/dquEmapInit.c new file mode 100644 index 0000000..35e6951 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquEmapInit.c @@ -0,0 +1,16862 @@ +/************************************************************************ +* +* ļ dquEmapInit.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.05 +* +* ӵͼʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include +#include "dquEmapInit.h" +#include "dsuStruct.h" +#include "CbtcVersion.h" +#include "dquCbtcType.h" +#include "dquQuery.h" + +UINT8 dfsEmapInitFlag = 0; +UINT8 initErrNo[INIT_ERR_NUM]; /*ݳʼʧܹϺ*/ + +static dfsDataHead g_DFsDH; /*FSļͷṹ*/ +static UINT8* g_pDataAddr; /*FSԪݵַ*/ +static UINT32 g_DataSize; /*FSԪݴСֽ*/ +static UINT16 g_RowCount; /**/ + +static UINT16 g_wCurInitStruProg=0U;/*ǰṹʼֲ̣ʱʹ*/ +static UINT16 g_wCurCalcStruProg=0U;/*ǰṹ㴦ֲ̣ʱʹ*/ +static UINT16 g_wCurMainIndex=0U; /*ǰֲʱʹ*/ +static UINT8 g_EmapInitMode=0x01; /*ӵͼʼģʽ*/ +static UINT8 g_IsEmapAllocMemory = 0x01; /*ļʽӿϵʼڴ*/ +static UINT32 g_FilterStopPointAttr = 0x0; /*ҪͣʱʹõͣԹֵϲӦ add by sds 2019-10-22*/ + +/*----------ڲʼ--------------*/ +/*wManageZCwManagePhysicalCIwManageLogicCIͨLINKȡ*/ +UINT8 CalcSwitchStruExpItem(); +/*źŻwManageZCwManagePhysicalCIwManageLogicCIͨLINKȡ*/ +UINT8 CalcSignalStruExpItem(); +/*ȫűwManageLogicCIͨLINKȡ*/ +UINT8 CalcPSDoorStruExpItem(); +/*ͣťwManageLogicCIͨLINKȡ*/ +UINT8 CalcEmergStopBtnStruExpItem(); +/*ͣdwStatTmnlLinkOfstwManagePhysicalCwManageLogicCIͨLINKȡ*/ +UINT8 CalcStopStationStruExpItem(); +/*۷ݴ*/ +UINT8 ARInStru(); +/*۷˳ݴ*/ +UINT8 AROutStru(); +/************************************************ +auther: qxt +ܣжǷijԪأ +ڼνṹС + +@inputArray: +@arrayLength:鳤 +@element:ҪҵԪ + +ֵ 0ش 1 2 +************************************************/ +UINT8 DetecteElementInArray(UINT16 inputArray[], UINT16 arrayLength, UINT16 element); +/************************************************************ +*ܣ +*˵ +*ֵ0ʧܣ1ɹ +* +νṹ + +UINT16 wOrgnRelatPointId; +UINT16 wOrgnMainAxleSgmtId; Ӷλα +UINT16 wOrgnSideAxleSgmtId; ӷλα +UINT16 wTmnlRelatPointId; յ +UINT16 wTmnlMainAxleSgmtId; յӶλα +UINT16 wTmnlSideAxleSgmtId; յӷλα +UINT16 wRelatAxleSgmtNum; Ŀ +UINT16 wRelatAxleSgmtId[3]; α +UINT16 wManageZC; ZC +UINT16 wManagePhysicalCI; CI +UINT32 dwOrgnLinkOfst; linkƫ +UINT32 dwTmnlLinkOfst; յlinkƫ +UINT16 wMiddleLinkId[MIDDLE_LINK_MAX_NUM]; мlink +************************************/ +static UINT8 AxleSgmtStru_CC(); + +/* +ܣɾظڲʹú +˵input 飻len С + :ȥغ +ֵȥغij +author: qxt 20180716 +*/ +static UINT8 RemoveRep(UINT16 input[],UINT8 len,UINT16 output[]); +/*----------ڲ--------------*/ + + +/*ʼΪȱ*/ +static INIT_TASK_TAB_STRU g_struInitTaskTab[]= +{ + {DQU_QFUN_TRUE, EMAP_NOP_0, initNop, 5,1,0}, /*Ϊʹݱݱռλͬȫ ID m by sds 2019-10-22*/ /*0*/ + {DQU_QFUN_TRUE, EMAP_LINK_ID, initLink, 5,1,0}, /*linkID*/ /*01*/ + {DQU_QFUN_TRUE, EMAP_POINT_ID, initPoint, 5,1,0}, /*ID*/ /*02*/ + {DQU_QFUN_TRUE, EMAP_SIGNAL_ID, initSignal, 5,1,0}, /*źŻID*/ /*03*/ + {DQU_QFUN_FASLE, EMAP_BALISE_ID, initBalise, 5,1,0}, /*ӦID*/ /*04*/ + {DQU_QFUN_TRUE, EMAP_AXLE_ID, initAxle, 5,1,0}, /*ID*/ /*05*/ + {DQU_QFUN_TRUE, EMAP_SCREEN_ID, initScreen, 5,1,0}, /*ȫID*/ /*06*/ + {DQU_QFUN_TRUE, EMAP_EMERG_STOP_BUTTON_ID, initEmergStop, 5,1,0}, /*ͣťID*/ /*07*/ + {DQU_QFUN_TRUE, EMAP_STATION_ID, initStation, 5,1,0}, /*ͣID*/ /*08*/ + {DQU_QFUN_TRUE, EMAP_STOPPOINT_ID, initStopPoint, 5,1,0}, /*ͣID*/ /*09*/ + {DQU_QFUN_TRUE, EMAP_AXLE_SGMT_ID, initAxleSgmt, 5,1,0}, /*ID*/ /*10*/ + {DQU_QFUN_TRUE, EMAP_LOGIC_SGMT_ID, initLogicSgmt, 5,1,0}, /*߼ ID */ /*11*/ + {DQU_QFUN_TRUE, EMAP_ROUTE_ID, initRoute, 5,1,0}, /*·ID*/ /*12*/ + {DQU_QFUN_TRUE, EMAP_PROTECT_LINK_ID, initProtectLink, 5,1,0}, /*ID*/ /*13*/ + {DQU_QFUN_TRUE, EMAP_BLOC_ACCESS_LINK_ID, initBLOCAccessLink, 5,1,0}, /*ʽӽID*/ /*14*/ + {DQU_QFUN_TRUE, EMAP_CBTC_ACCESS_LINK_ID, initCBTCAccessLink, 5,1,0}, /*CBTCӽID*/ /*15*/ + {DQU_QFUN_FASLE, EMAP_GRADE_ID, initGrade, 5,1,0}, /*¶ID*/ /*16*/ + { DQU_QFUN_FASLE, EMAP_STATIC_RES_SPEED_ID, initStaticResSpeed, 5,1,0}, /*̬ID*/ /*17*/ + {DQU_QFUN_FASLE, EMAP_DEFAULT_ROUTE_ID, initDefaultRout, 5,1,0}, /*ĬгID*/ /*18*/ + {DQU_QFUN_FASLE, EMAP_RUN_LEVEL_ID, initRunLevel, 5,1,0}, /*վӪID*/ /*19*/ + {DQU_QFUN_FASLE, EMAP_EXIT_ROUTE_ID, initExitRoute, 5,1,0}, /*˳CBTCID*/ /*20*/ + {DQU_QFUN_FASLE, EMAP_TRAIN_LINE_ID, initTrainLine, 5,1,0}, /*CBTCID*/ /*21*/ + {DQU_QFUN_TRUE, EMAP_AR_ID, initAR, 5,1,0}, /*Զ۷ID*/ /*22*/ + {DQU_QFUN_FASLE, EMAP_ZC_DIVID_POINT_ID, initZCDividPoint, 5,1,0}, /*ZCֽID*/ /*23*/ + {DQU_QFUN_FASLE, EMAP_ZC_COM_ZONE_ID, initZCComZone, 5,1,0}, /*ZCID*/ /*24*/ + {DQU_QFUN_TRUE, EMAP_CI_ID, initCI, 5,1,0}, /*CIID*/ /*25*/ + {DQU_QFUN_FASLE, EMAP_NOP_26, initNop, 5,1,0}, /*ATSID*/ /*26*/ + {DQU_QFUN_FASLE, EMAP_CONRESSPEED_ID, initConResSpeed, 5,1,0}, /*ͳһID*/ /*27*/ + {DQU_QFUN_FASLE, EMAP_CONGRADE_ID, initConGrade, 5,1,0}, /*ͳһ¶ID*/ /*28*/ + {DQU_QFUN_TRUE, EMAP_PHYSICAL_SGMT_ID, initPhysicalSgmt, 5,1,0}, /*ID*/ /*29*/ + {DQU_QFUN_TRUE, EMAP_BLOC_TRG_AREA_ID, initBlocTrgArea, 5,1,0}, /*ʽID*/ /*30*/ + {DQU_QFUN_TRUE, EMAP_CBTC_TRG_AREA_ID, initCbtcTrgArea, 5,1,0}, /*CBTCID*/ /*31*/ + {DQU_QFUN_FASLE, EMAP_PLAT_FORM_ID, initPlatForm, 5,1,0}, /*վ̨ID*/ /*32*/ + {DQU_QFUN_TRUE, EMAP_COME_GO_ID, initComeGoRoute, 5,1,0}, /*·*/ /*33*/ + {DQU_QFUN_TRUE, EMAP_FLOOD_GATE_ID, initFloodGate, 5,1,0}, /**/ /*34*/ + {DQU_QFUN_TRUE, EMAP_SPKS_BUTTON_ID, initSpksButton, 5,1,0}, /*SPKSť*/ /*35*/ + {DQU_QFUN_TRUE, EMAP_DEPOT_GATE_ID, initDepotGate, 5,1,0}, /**/ /*36*/ + {DQU_QFUN_FASLE, EMAP_TUNNEL_ID, initTunnel, 5,1,0}, /**/ /*37*/ + {DQU_QFUN_FASLE, EMAP_ZC_ID, initZC, 5,1,0}, /*ZCID*/ /*38*/ + {DQU_QFUN_TRUE, EMAP_MULTI_POINT_ID, initMultiPoint, 5,1,0}, /*࿪ID*/ /*39*/ + {DQU_QFUN_TRUE, EMAP_NOP_40, initNop, 5,1,0}, /*ȫ ID sds*/ /*40*/ + {DQU_QFUN_FASLE, EMAP_POWERLESSZONE_ID, initPowerlessZone, 5,1,0}, /*ݻͨݽṹV12.0.0*/ /*41*/ + {DQU_QFUN_FASLE, EMAP_LOGIC_SGMT_ID, initLogicSgmt, 5,1,0}, /*ȫ ID sds */ /*42*/ + {DQU_QFUN_TRUE, EMAP_NOP_43, initNop, 5,1,0}, /*ȫ ID sds */ /*43*/ + {DQU_QFUN_TRUE, EMAP_NOP_44, initNop, 5,1,0}, /*ȫ ID sds */ /*44*/ + {DQU_QFUN_TRUE, EMAP_NOP_45, initNop, 5,1,0}, /*ȫ ID sds */ /*45*/ + {DQU_QFUN_FASLE, EMAP_ATS_ID, initATS, 5,1,0}, /*ȫ ID sds */ /*46*/ + {DQU_QFUN_TRUE, EMAP_NOP_47, initNop, 5,1,0}, /*ȫ ID sds */ /*47*/ + {DQU_QFUN_TRUE, EMAP_NOP_48, initNop, 5,1,0}, /*ȫ ID sds */ /*48*/ + {DQU_QFUN_TRUE, EMAP_NOP_49, initNop, 5,1,0}, /*ȫ ID sds */ /*49*/ + {DQU_QFUN_TRUE, EMAP_NOP_50, initNop, 5,1,0}, /*ȫ ID sds */ /*50*/ + {DQU_QFUN_FASLE, EMAP_CARSTOP_ID, initCarStop, 5,1,0}, /*ݻͨݽṹV15.0.0*/ /*51*/ + {DQU_QFUN_FASLE, EMAP_ADJTSTATION_ID, initAdjtStation, 5,1,0}, /*ݻͨݽṹV18.0.0ӣadd by sds 20200211*/ /*52*/ + {DQU_QFUN_TRUE, EMAP_PSC_ID, initPSC, 5,1,0}, /*ȫ ID sds */ /*53*/ + {DQU_QFUN_TRUE, EMAP_NOP_54, initNop, 5,1,0}, /*ȫ ID sds */ /*54*/ + {DQU_QFUN_TRUE, EMAP_EA_ID, initEa, 5,1,0}, /* ñ */ /*55*/ + {DQU_QFUN_TRUE, EMAP_NOP_56, initNop, 5,1,0}, /*ȫ ID sds */ /*56*/ + {DQU_QFUN_TRUE, EMAP_NOP_57, initNop, 5,1,0}, /*ȫ ID sds */ /*57*/ + {DQU_QFUN_TRUE, EMAP_NOP_58, initNop, 5,1,0}, /*ȫ ID sds */ /*58*/ + {DQU_QFUN_TRUE, EMAP_LOGSEC_SPKS_BUTTON_ID, initLogSecSpksButton,5,1,0}, /*߼SPKSر*/ /*59*/ + {DQU_QFUN_TRUE, EMAP_NOP_60, initNop, 5,1,0}, /*ȫ ID sds */ /*60*/ + {DQU_QFUN_TRUE, EMAP_NOP_61, initNop, 5,1,0}, /*ȫ ID sds */ /*61*/ + {DQU_QFUN_TRUE, EMAP_NOP_62, initNop, 5,1,0}, /*ȫ ID sds */ /*62*/ + {DQU_QFUN_TRUE, EMAP_NOP_63, initNop, 5,1,0}, /*ȫ ID sds */ /*63*/ + {DQU_QFUN_TRUE, EMAP_NOP_64, initNop, 5,1,0}, /*ȫ ID sds */ /*64*/ + {DQU_QFUN_TRUE, EMAP_NOP_65, initNop, 5,1,0}, /*ȫ ID sds */ /*65*/ + {DQU_QFUN_TRUE, EMAP_NOP_66, initNop, 5,1,0}, /*ȫ ID sds */ /*66*/ + {DQU_QFUN_TRUE, EMAP_NOP_67, initNop, 5,1,0}, /*ȫ ID sds */ /*67*/ + {DQU_QFUN_TRUE, EMAP_NOP_68, initNop, 5,1,0}, /*ȫ ID sds */ /*68*/ + {DQU_QFUN_TRUE, EMAP_NOP_69, initNop, 5,1,0}, /*ȫ ID sds */ /*69*/ + {DQU_QFUN_TRUE, EMAP_NOP_70, initNop, 5,1,0}, /*ȫ ID sds */ /*70*/ + {DQU_QFUN_TRUE, EMAP_NOP_71, initNop, 5,1,0}, /*ȫ ID sds */ /*71*/ + {DQU_QFUN_TRUE, EMAP_NOP_72, initNop, 5,1,0}, /*ȫ ID sds */ /*72*/ + {DQU_QFUN_TRUE, EMAP_NOP_73, initNop, 5,1,0}, /*ȫ ID sds */ /*73*/ + {DQU_QFUN_TRUE, EMAP_NOP_74, initNop, 5,1,0}, /*ȫ ID sds */ /*74*/ + {DQU_QFUN_TRUE, EMAP_NOP_75, initNop, 5,1,0}, /*ȫ ID sds */ /*75*/ + {DQU_QFUN_TRUE, EMAP_NOP_76, initNop, 5,1,0}, /*ȫ ID sds */ /*76*/ + {DQU_QFUN_TRUE, EMAP_NOP_77, initNop, 5,1,0}, /*ȫ ID sds */ /*77*/ + {DQU_QFUN_TRUE, EMAP_NOP_78, initNop, 5,1,0}, /*ȫ ID sds */ /*78*/ + {DQU_QFUN_TRUE, EMAP_NOP_79, initNop, 5,1,0}, /*ȫ ID sds */ /*79*/ + {DQU_QFUN_TRUE, EMAP_NOP_80, initNop, 5,1,0} /*ȫ ID sds */ /*80*/ +}; +/*ʼǼDZĿ*/ +static const UINT16 MAX_INITTASK_COUNT=sizeof(g_struInitTaskTab)/sizeof(INIT_TASK_TAB_STRU); + + +/*Ϊȱ*/ +static CALC_TASK_TAB_STRU g_struCalcTaskTab[]= +{ + { DQU_QFUN_TRUE,1, CalcSwitchStruExpItem, 5,1,0,0}, + { DQU_QFUN_TRUE,2, CalcSignalStruExpItem, 5,1,0,0}, + { DQU_QFUN_TRUE,3, CalcPSDoorStruExpItem, 5,1,0,0}, + { DQU_QFUN_TRUE,4, CalcEmergStopBtnStruExpItem, 5,1,0,0}, + { DQU_QFUN_TRUE,5, CalcStopStationStruExpItem, 5,1,0,0}, + { DQU_QFUN_TRUE,6, AxleSgmtStru, 5,1,0,0}, + { DQU_QFUN_FASLE,7, CalculateStopPoint, 5,1,0,0}, + { DQU_QFUN_FASLE,8, ARInStru, 5,1,0,0}, + { DQU_QFUN_FASLE,9, AROutStru, 5,1,0,0}, + { DQU_QFUN_TRUE,10, LogicSgmtStru, 5,1,0,0}, + { DQU_QFUN_TRUE,11, RouteStru, 5,1,0,0}, + { DQU_QFUN_TRUE,12, ProtectLink, 5,1,0,0}, + { DQU_QFUN_FASLE,13, Grade, 5,1,0,0}, + { DQU_QFUN_FASLE,14, DefaultRouteStru, 5,1,0,0}, + { DQU_QFUN_TRUE,15, GetDeviceInfoInLink, 5,1,0,0}, + { DQU_QFUN_FASLE,16, GetGradeInfoCrossLink, 5,1,0,0}, + { DQU_QFUN_TRUE,17, CalcSPKSIncLinks, 5,1,0,0} + +}; +/*Ŀ*/ +static const UINT16 MAX_CALCTASK_COUNT=sizeof(g_struCalcTaskTab)/sizeof(CALC_TASK_TAB_STRU); + +/*ݰ汾ݴ̺ +**޸ļ¼ +**1ݻͨݽṹV18.0.0޸ģm by sds 20200211 +**2޸IJҪʼıϢ m by sds 2020-8-19 +**3ӳʼıϢ m by qw.liu 2022-2-22 +*/ +static UINT8 initConfigEmapTaskTab() +{ + UINT8 loopIndex = 0U; + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + + cbtcVersionType = GetCbtcSysType(); + + /*ΪʵݱʵʱֵһһӦԴ0ʼ ȫ ID Ϊǿձòжȡ add by sds 2019-10-22*/ + g_struInitTaskTab[EMAP_NOP_0].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ0*/ + + /* ҪĿݱ */ + g_struInitTaskTab[EMAP_NOP_42].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ40*/ + g_struInitTaskTab[EMAP_NOP_26].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ40*/ + g_struInitTaskTab[EMAP_NOP_40].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ40*/ + for (loopIndex = EMAP_NOP_43; loopIndex <= EMAP_NOP_45; loopIndex++) + { + g_struInitTaskTab[loopIndex].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ42~50*/ + } + for(loopIndex = EMAP_NOP_47; loopIndex <= EMAP_NOP_50; loopIndex++) + { + g_struInitTaskTab[loopIndex].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ42~50*/ + } + + g_struInitTaskTab[EMAP_NOP_54].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ54*/ + + for(loopIndex = EMAP_NOP_56; loopIndex <= EMAP_NOP_58; loopIndex++) + { + g_struInitTaskTab[loopIndex].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ56~58*/ + } + for (loopIndex = EMAP_NOP_60; loopIndex <= EMAP_NOP_80; loopIndex++) + { + g_struInitTaskTab[loopIndex].bIsEffective = DQU_QFUN_FASLE;/*ΪȫݱռλĿձ60~80*/ + } + + if (DQU_CBTC_CPK == cbtcVersionType)/*ǰ汾ϿⲻҪݱ*/ + { + g_struInitTaskTab[EMAP_SPKS_BUTTON_ID].bIsEffective = DQU_QFUN_FASLE;/*SPKS*/ + g_struInitTaskTab[EMAP_DEPOT_GATE_ID].bIsEffective = DQU_QFUN_FASLE;/*ű*/ + g_struInitTaskTab[EMAP_TUNNEL_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_ZC_ID].bIsEffective = DQU_QFUN_FASLE;/*ZC*/ + g_struInitTaskTab[EMAP_MULTI_POINT_ID].bIsEffective = DQU_QFUN_FASLE;/*࿪*/ + g_struInitTaskTab[EMAP_POWERLESSZONE_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_CARSTOP_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_ADJTSTATION_ID].bIsEffective = DQU_QFUN_FASLE;/*ͣID*/ + g_struInitTaskTab[EMAP_PSC_ID].bIsEffective = DQU_QFUN_FASLE;/*PSC*/ + + /*g_struCalcTaskTab[MAX_CALCTASK_COUNT-2].bIsEffective=DQU_QFUN_FASLE;*//*ҪLink豸ӳϵ*/ + g_struCalcTaskTab[MAX_CALCTASK_COUNT-1].bIsEffective=DQU_QFUN_FASLE;/*ҪSPKSLink*/ + + rtnValue = 1; + } + else if (DQU_CBTC_FAO == cbtcVersionType)/*FAOҪݱ*/ + { + g_struInitTaskTab[EMAP_TUNNEL_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_ZC_ID].bIsEffective = DQU_QFUN_FASLE;/*ZC*/ + g_struInitTaskTab[EMAP_MULTI_POINT_ID].bIsEffective = DQU_QFUN_FASLE;/*࿪*/ + g_struInitTaskTab[EMAP_POWERLESSZONE_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_CARSTOP_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_ADJTSTATION_ID].bIsEffective = DQU_QFUN_FASLE;/*ͣID*/ + g_struInitTaskTab[EMAP_PSC_ID].bIsEffective = DQU_QFUN_FASLE;/*PSC*/ + + g_struCalcTaskTab[MAX_CALCTASK_COUNT-3].bIsEffective=DQU_QFUN_FASLE;/*ҪLink豸ӳϵ*/ + g_struCalcTaskTab[MAX_CALCTASK_COUNT-2].bIsEffective=DQU_QFUN_FASLE;/*ҪLink¶ӳϵ*/ + g_struCalcTaskTab[MAX_CALCTASK_COUNT-1].bIsEffective=DQU_QFUN_FASLE;/*ҪSPKSLink*/ + rtnValue = 1; + } + else if (DQU_CBTC_HLT == cbtcVersionType) /*ͨҪݱ*/ + { + g_struInitTaskTab[EMAP_ZC_DIVID_POINT_ID].bIsEffective = DQU_QFUN_FASLE;/*ZCֽ*/ + g_struInitTaskTab[EMAP_ZC_COM_ZONE_ID].bIsEffective = DQU_QFUN_FASLE;/*ZC*/ + g_struInitTaskTab[EMAP_MULTI_POINT_ID].bIsEffective = DQU_QFUN_FASLE;/*࿪*/ + rtnValue = 1; + } + else if (DQU_CBTC_DG == cbtcVersionType)/*첻Ҫݱ*/ + { + /*g_struInitTaskTab[EMAP_ZC_DIVID_POINT_ID].bIsEffective= DQU_QFUN_FASLE;*//*ZCֽ*/ + g_struInitTaskTab[EMAP_POWERLESSZONE_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_CARSTOP_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_ADJTSTATION_ID].bIsEffective = DQU_QFUN_FASLE;/*ͣID*/ + g_struInitTaskTab[EMAP_PSC_ID].bIsEffective = DQU_QFUN_FASLE;/*PSC*/ + + /*g_struCalcTaskTab[MAX_CALCTASK_COUNT-1].bIsEffective = DQU_QFUN_FASLE;*//*ҪLink豸ӳϵ*/ + g_struCalcTaskTab[MAX_CALCTASK_COUNT-2].bIsEffective = DQU_QFUN_FASLE;/*ҪLink¶ӳϵ*/ + g_struCalcTaskTab[MAX_CALCTASK_COUNT-1].bIsEffective = DQU_QFUN_FASLE;/*ҪSPKSLink*/ + + rtnValue = 1; + } + else if (DQU_CBTC_CC == cbtcVersionType) /*ϵͳвҪݱ*/ + { + g_struInitTaskTab[EMAP_BALISE_ID].bIsEffective = DQU_QFUN_FASLE;/*Ӧ*/ + g_struInitTaskTab[EMAP_STOPPOINT_ID].bIsEffective = DQU_QFUN_FASLE;/*ͣ*/ +#if 0 + g_struInitTaskTab[EMAP_BLOC_ACCESS_LINK_ID].bIsEffective = DQU_QFUN_FASLE;/*ʽӽα*/ +#endif + g_struInitTaskTab[EMAP_GRADE_ID].bIsEffective = DQU_QFUN_FASLE;/*¶ȱ*/ + g_struInitTaskTab[EMAP_STATIC_RES_SPEED_ID].bIsEffective = DQU_QFUN_FASLE;/*̬ٱ*/ + g_struInitTaskTab[EMAP_DEFAULT_ROUTE_ID].bIsEffective = DQU_QFUN_FASLE;/*Ĭгб*/ + g_struInitTaskTab[EMAP_RUN_LEVEL_ID].bIsEffective = DQU_QFUN_FASLE;/*վӪ*/ + g_struInitTaskTab[EMAP_EXIT_ROUTE_ID].bIsEffective = DQU_QFUN_FASLE;/*˳CBTC*/ + g_struInitTaskTab[EMAP_TRAIN_LINE_ID].bIsEffective = DQU_QFUN_FASLE;/*CBTC*/ + g_struInitTaskTab[EMAP_ZC_DIVID_POINT_ID].bIsEffective = DQU_QFUN_FASLE;/*ZCֽ*/ + g_struInitTaskTab[EMAP_ZC_COM_ZONE_ID].bIsEffective = DQU_QFUN_FASLE;/*ZC*/ + g_struInitTaskTab[EMAP_CONRESSPEED_ID].bIsEffective = DQU_QFUN_FASLE;/*ͳһϢ*/ + g_struInitTaskTab[EMAP_CONGRADE_ID].bIsEffective = DQU_QFUN_FASLE;/*ͳһ¶Ϣ*/ + g_struInitTaskTab[EMAP_BLOC_TRG_AREA_ID].bIsEffective = DQU_QFUN_FASLE;/*ʽα*/ + g_struInitTaskTab[EMAP_PLAT_FORM_ID].bIsEffective = DQU_QFUN_FASLE;/*վ̨*/ + g_struInitTaskTab[EMAP_COME_GO_ID].bIsEffective = DQU_QFUN_FASLE;/*·*/ + g_struInitTaskTab[EMAP_TUNNEL_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_ZC_ID].bIsEffective = DQU_QFUN_FASLE;/*ZC*/ + g_struInitTaskTab[EMAP_MULTI_POINT_ID].bIsEffective = DQU_QFUN_FASLE;/*࿪*/ + g_struInitTaskTab[EMAP_POWERLESSZONE_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_ATS_ID].bIsEffective = DQU_QFUN_FASLE;/*ATS*/ + g_struInitTaskTab[EMAP_CARSTOP_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_ADJTSTATION_ID].bIsEffective = DQU_QFUN_FASLE;/**/ + g_struInitTaskTab[EMAP_PSC_ID].bIsEffective = DQU_QFUN_FASLE;/*PSC*/ +#if 0 + g_struInitTaskTab[EMAP_LOGIC_SGMT_ID].bIsEffective = DQU_QFUN_FASLE;/*߼α*/ + g_struInitTaskTab[EMAP_ROUTE_ID].bIsEffective = DQU_QFUN_FASLE;/*·*/ + g_struInitTaskTab[EMAP_PROTECT_LINK_ID].bIsEffective = DQU_QFUN_FASLE;/*α*/ + g_struInitTaskTab[EMAP_CBTC_ACCESS_LINK_ID].bIsEffective = DQU_QFUN_FASLE;/*CBTCӽα*/ + g_struInitTaskTab[EMAP_CI_ID].bIsEffective = DQU_QFUN_FASLE;/*TIOCݱ*/ + g_struInitTaskTab[EMAP_CBTC_TRG_AREA_ID].bIsEffective = DQU_QFUN_FASLE;/*CBTCݱ*/ +#endif + g_struCalcTaskTab[6].bIsEffective = DQU_QFUN_FASLE; + g_struCalcTaskTab[16].bIsEffective = DQU_QFUN_FASLE; /* SKPSlinkҪʼ */ + g_struCalcTaskTab[MAX_CALCTASK_COUNT - 2].bIsEffective = DQU_QFUN_FASLE;/*ҪLink¶ӳϵ*/ + g_struCalcTaskTab[MAX_CALCTASK_COUNT - 1].bIsEffective = DQU_QFUN_FASLE;/*ҪSPKSLink*/ + + rtnValue = 1; + + } + else /*δֵð汾ֵδñ־λ*/ + { + rtnValue = 0U; + } + + return rtnValue; + +} + +/********************************************* +*ܣӵͼģ汾Żȡ +*˵ϵͳòѯ汾ţֹɴ +*ڲ +*ڲ +*ֵUINT32ʾİ汾 +*********************************************/ +UINT32 GetDquEmapVersion() +{ + UINT32 dquEmapVer=0; + dquEmapVer = VerToU32SoftwareModule(DQU_EMAP_VER1,DQU_EMAP_VER2,DQU_EMAP_VER3,DQU_EMAP_VER4); + return dquEmapVer; +} + + +/********************************************* +*ܣӵͼʼ ϵһԼݴ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 dfsEmapInit(CHAR * FSName) +{ + UINT16 wIndex=0U; + UINT8 funcRtn = 0U; + UINT8 rtnValue = 1U; + UINT32 DataID=0U;/*ͱʶ*/ + UINT8 *pDataAddr=NULL; + UINT32 DataSize=0U; + UINT16 rowCount = 0U; + + /*ʼϢ¼*/ + memset(initErrNo, 0, INIT_ERR_NUM); + + /*ʼһξ*/ + if (1U==dfsEmapInitFlag) + { + rtnValue = 1; + } + else + { + g_EmapInitMode=0x01U;/*ϵģʽ*/ + + g_IsEmapAllocMemory=0x01U;/*Ĭϱӿڷڴ*/ + + /*ָǷΪ*/ + if( (NULL == g_dsuEmapStru) || (NULL == FSName)) + { + /*ָΪ˳*/ + rtnValue = 0U; + } + else + { + /*ȡFSļ,֤ļ*/ + funcRtn = dataRead(FSName); + if(1U != funcRtn) + { + /*ݶȡɹ*/ + fileErrNo |= ERR_FILE_READ; + rtnValue = 0U; + } + else + { + /*ݰ汾ݴ̺*/ + funcRtn =initConfigEmapTaskTab(); + if (0U == funcRtn) + { + rtnValue = 0U; + } + } + + /*ڴռ*/ + if ((1U == rtnValue) && (0x01U==g_IsEmapAllocMemory)) + { + g_dsuEmapStru->dsuDataLenStru=(DSU_DATA_LEN_STRU*)MyNew(sizeof(DSU_DATA_LEN_STRU)); + /*̬ռʧ*/ + if (NULL == g_dsuEmapStru->dsuDataLenStru ) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0x0*/ + memset(g_dsuEmapStru->dsuDataLenStru, 0x0, sizeof(DSU_DATA_LEN_STRU)); + } + + if(1U == rtnValue) + { + g_dsuEmapStru->dsuStaticHeadStru=(DSU_STATIC_HEAD_STRU *)MyNew(sizeof(DSU_STATIC_HEAD_STRU)); + /*̬ռʧ*/ + if (NULL == g_dsuEmapStru->dsuStaticHeadStru ) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0x0*/ + memset(g_dsuEmapStru->dsuStaticHeadStru, 0x0, sizeof(DSU_STATIC_HEAD_STRU)); + } + } + + if(1U == rtnValue) + { + g_dsuEmapStru->dsuEmapIndexStru=(DSU_EMAP_INDEX_STRU*)MyNew(sizeof(DSU_EMAP_INDEX_STRU)); + /*̬ռʧ*/ + if (NULL == g_dsuEmapStru->dsuEmapIndexStru) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0x0*/ + memset(g_dsuEmapStru->dsuEmapIndexStru, 0x0, sizeof(DSU_EMAP_INDEX_STRU)); + } + } + } + + if(1U == rtnValue) + { + /*ʼ*/ + wIndex=0; + do /*ݵӦĽṹ*/ + { + if (DQU_QFUN_TRUE == g_struInitTaskTab[wIndex].bIsEffective)/*жʼǷִ*/ + { + /*ȡ*/ + DataID=g_struInitTaskTab[wIndex].DataTypeId; + funcRtn=dquGetConfigDataNew( FSName, EMAP_DATA_TYPE, DataID, &pDataAddr, &DataSize, &rowCount); + if (1U != funcRtn ) + { + /*ʧ*/ + initErrNo[DataID] |= DEBUG_GET_DATA_FAIL; + rtnValue = 0U; + break; + } + + if(1U == rtnValue) + { + debug_infor_printf("g_struInitTaskTab wIndex=%d\n",wIndex); + funcRtn=g_struInitTaskTab[wIndex].pExeFun(pDataAddr,DataSize,rowCount); + if (0U == funcRtn) + { + rtnValue = 0U; + break; + } + } + } + + wIndex++; + } while (wIndex=MAX_INITTASK_COUNT) ״̬£нṹʼ׶*/ + { + g_wCurMainIndex=3U; + } + } + else if(2U == funcRtn)/*ڷֲδ*/ + { + g_struInitTaskTab[g_wCurInitStruProg].wCurProcStage++; + } + else/*쳣*/ + { + rtnValue = 0U; + } + + break; + case 3:/*㴦*/ + funcRtn=g_struCalcTaskTab[g_wCurCalcStruProg].pExeFun(); + if(1U==funcRtn)/*ɱĴ*/ + { + do{ + + /*ʼṹһ׶*/ + g_wCurCalcStruProg++; + + }while((g_wCurCalcStruProg < MAX_CALCTASK_COUNT) && (DQU_QFUN_FASLE==g_struCalcTaskTab[g_wCurCalcStruProg].bIsEffective)); + + /*еļ㴦δ*/ + if(g_wCurCalcStruProg=MAX_CALCTASK_COUNT) ״̬£нṹʼ׶*/ + { + g_wCurMainIndex=4U; + } + } + /*ǰȻڷֲ*/ + else if(2U == funcRtn) + { + /*ǰִн׶вForѭѭִн*/ + if( 0U == g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop) + { + g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos=0U;/*ѭʱǰһForѭΪһѭ׼ֵ*/ + g_struCalcTaskTab[g_wCurCalcStruProg].wCurProcStage++;/*леһδ*/ + } + else/*׶ѭִδ*/ + { + /*ʲôҲ*/ + } + } + else/*쳣*/ + { + rtnValue = 0U; + } + + break; + case 4:/*ִϲɹ*/ + rtnValue=1U; + break; + default: + rtnValue=0U; + break; + } + + /*쳣˳,дִ˳*/ + if(2U != rtnValue) + { + break; + } + + /*ʱͳƼ㴦*/ + if (0x02U == mode) + { + /*ȡǰʱ*/ + dwCurTimePoint=dquGetCurrentTimeByMS(); + + /*ʣʱ */ + dwUsedTime=dwCurTimePoint-dwBeginTimePoint; + /*㵥ִʱ */ + dwOnceTime=dwCurTimePoint-dwLastTimePoint; + /*ʷʱ */ + dwLastTimePoint=dwCurTimePoint; + + /*ʹõʱСʱƬ */ + if (dwUsedTime < timeSlice) + { + /*ʣµĴʱ乻ִһδ*/ + if ( dwOnceTime > 0 ) + { + wFreqTimes = (timeSlice-dwUsedTime)/dwOnceTime; + } + else /*ִʱС1msִ*/ + { + wFreqTimes = 1; + } + + /*ִб־*/ + if (wFreqTimes >= 1) + { + bExeState=DQU_QFUN_TRUE; + } + else /*ʣʱ䲻һִ*/ + { + bExeState=DQU_QFUN_FASLE; + } + } + else/*ʱ˳һδʱС1ĬҲ˳*/ + { /* ֹֽжС1봦ۻѾʱ*/ + + bExeState=DQU_QFUN_FASLE; + } + } + + /*ģʽΪϵʱһֱִ,ִ״̬Ϊ*/ + } while ((0x01 == mode) || (DQU_QFUN_TRUE == bExeState)); + + } + + return rtnValue; +} + +/*ӵͼʼϣִеӵͼڲ*/ +UINT8 dfsEmapInitFinally() +{ + UINT16 wIndex=0U; + UINT8 bRetVal=0U; + + g_wCurInitStruProg=0;/*ǰṹʼֲ̣ʱʹ*/ + g_wCurCalcStruProg=0;/*ǰṹ㴦ֲ̣ʱʹ*/ + g_wCurMainIndex=0; /*ǰֲʱʹ*/ + g_EmapInitMode=0x01; /*ӵͼʼģʽ*/ + + /*ݳʼ״̬*/ + for(wIndex=0;wIndex 0x03)) + { + bIsEffective=DQU_QFUN_TRUE; + } + else + { + bIsEffective=DQU_QFUN_FASLE; + } + } + + return bIsEffective; + +} + + +/*ӵͼʼѭֲи*/ +static UINT8 EmapInitLoopStepLenCtrl(UINT32 dwIndex) +{ + UINT8 bIsEffective=DQU_QFUN_FASLE; + + if (0x01 == g_EmapInitMode) /*ϵش*/ + { + bIsEffective=DQU_QFUN_FASLE; + } + else /*ֲ*/ + { + if (g_struInitTaskTab[g_wCurInitStruProg].wStepLen == dwIndex-g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos + 1) + { + g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos=dwIndex+1; + bIsEffective=DQU_QFUN_TRUE; + } + } + + return bIsEffective; +} + +/*ӵͼݼֲƺ*/ +static UINT8 EmapCalcFunStepCtrl(UINT16 wStep) +{ + UINT8 bIsEffective=DQU_QFUN_FASLE; + if (0x01 == g_EmapInitMode) /*ϵش*/ + { + bIsEffective=DQU_QFUN_TRUE; + } + else /*ֲ*/ + { + if (wStep == g_struCalcTaskTab[g_wCurCalcStruProg].wCurProcStage) + { + bIsEffective=DQU_QFUN_TRUE; + } + } + + return bIsEffective; +} + +/*ӵͼѭֲи*/ +static UINT8 EmapCalcLoopStepLenCtrl(UINT32 dwIndex) +{ + UINT8 bIsEffective=DQU_QFUN_FASLE; + + if (0x01 == g_EmapInitMode) /*ϵش*/ + { + bIsEffective=DQU_QFUN_FASLE; + } + else /*ֲ*/ + { + if (g_struCalcTaskTab[g_wCurCalcStruProg].wStepLen==dwIndex-g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos+1) + { + g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos=dwIndex+1; + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=1; + bIsEffective=DQU_QFUN_TRUE; + } + } + + return bIsEffective; +} + + + +/*-------------------------ӵͼṹ㺯--------------------------------------*/ + +/*wManageZCwManagePhysicalCIwManageLogicCIͨLINKȡ*/ +UINT8 CalcSwitchStruExpItem() +{ + UINT16 wIndex=0U; /*ѭ*/ + UINT8 rtnValue = 2U; + UINT8 ftnValue = 0U; + DSU_POINT_STRU* pTempPointStru=NULL; /*ݽṹʱָ*/ + DSU_LINK_STRU * pLinkStru=NULL; /*LINKṹʱָ,ڼõ*/ + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + if(NULL==dsuEmapIndexStru) + { + rtnValue = 0U; + return rtnValue; + } + dsuLinkIndex=dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + ftnValue = EmapCalcFunStepCtrl(0x02); + if(DQU_QFUN_TRUE==ftnValue) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndex < dsuDataLenStru->wPointLen; wIndex++) + { + pTempPointStru = dsuStaticHeadStru->pPointStru + wIndex; + /*ͨҵlinkϢ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempPointStru->wMainLkId]; + + /**/ + pTempPointStru->wManageZC = pLinkStru->wManageZC; + pTempPointStru->wManageLogicCI = pLinkStru->wManageLogicCI; + pTempPointStru->wManagePhysicalCI = pLinkStru->wManagePhysicalCI; + pTempPointStru->wBelongVirCI = pLinkStru->wBelongVirtualCI;/**/ + /*ѭֲи*/ + ftnValue = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==ftnValue) + { + rtnValue=2U; + break; + } + } + if (wIndex==dsuDataLenStru->wPointLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue=1U; + } + } + + return rtnValue; +} + +/*źŻwManageZCwManagePhysicalCIwManageLogicCIͨLINKȡ*/ +UINT8 CalcSignalStruExpItem() +{ + UINT16 wIndex=0U; /*ѭ*/ + UINT8 rtnValue = 2U; + UINT8 ftnValue = 0U; + DSU_SIGNAL_STRU * pTempSignalStru=NULL; /*źŻṹʱָ*/ + DSU_LINK_STRU * pLinkStru=NULL; /*LINKṹʱָ,ڼõ*/ + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + if(NULL==dsuEmapIndexStru) + { + rtnValue = 0U; + return rtnValue; + } + dsuLinkIndex=dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + ftnValue = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE== ftnValue) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndex < dsuDataLenStru->wSignalLen; wIndex++) + { + pTempSignalStru = dsuStaticHeadStru->pSignalStru + wIndex; + /*ͨҵlinkϢ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempSignalStru->wProtectLinkId]; + + /**/ + pTempSignalStru->wManageZC = pLinkStru->wManageZC; + pTempSignalStru->wManageLogicCI = pLinkStru->wManageLogicCI; + pTempSignalStru->wManagePhysicalCI = pLinkStru->wManagePhysicalCI; + pTempSignalStru->wBelongVirCI = pLinkStru->wBelongVirtualCI; + /*ѭֲи*/ + ftnValue = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==ftnValue) + { + rtnValue=2U; + break; + } + } + if (wIndex==dsuDataLenStru->wSignalLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue=1; + } + } + + return rtnValue; +} + +/*ȫűwManageLogicCIͨLINKȡ*/ +UINT8 CalcPSDoorStruExpItem() +{ + UINT16 wIndex=0U; /*ѭ*/ + UINT8 rtnValue = 2U; + UINT8 ftnValue = 0U; + DSU_SCREEN_STRU* pTempScreenStru=NULL; /*ȫű*/ + DSU_LINK_STRU * pLinkStru=NULL; /*LINKṹʱָ,ڼõ*/ + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + if(NULL==dsuEmapIndexStru) + { + rtnValue = 0U; + return rtnValue; + } + dsuLinkIndex=dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + ftnValue = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE== ftnValue) + { + + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndex < dsuDataLenStru->wScreenLen; wIndex++) + { + pTempScreenStru = dsuStaticHeadStru->pScreenStru + wIndex; + /*ͨҵlinkϢ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempScreenStru->wRelatLkId]; + /**/ + pTempScreenStru->wManageLogicCI = pLinkStru->wManageLogicCI; + /*ѭֲи*/ + ftnValue = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==ftnValue) + { + rtnValue=2U; + break; + } + } + if (wIndex==dsuDataLenStru->wScreenLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue=1U; + } + } + + return rtnValue; +} + +/*ͣťwManageLogicCIͨLINKȡ*/ +UINT8 CalcEmergStopBtnStruExpItem() +{ + UINT16 wIndex=0U; /*ѭ*/ + UINT8 rtnValue = 2U; + UINT8 ftnValue = 0U; + DSU_EMERG_STOP_STRU* pTempEmergStopStru=NULL; /*ͣť*/ + DSU_LINK_STRU * pLinkStru=NULL; /*LINKṹʱָ,ڼõ*/ + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + if(NULL==dsuEmapIndexStru) + { + rtnValue = 0U; + return rtnValue; + } + dsuLinkIndex=dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + ftnValue = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE==ftnValue) + { + + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndex < dsuDataLenStru->wEmergStopLen; wIndex++) + { + pTempEmergStopStru = dsuStaticHeadStru->pEmergStopStru + wIndex; + /*ͨҵlinkϢ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempEmergStopStru->wRelatLkId]; + /**/ + pTempEmergStopStru->wManageLogicCI = pLinkStru->wManageLogicCI; + /*ѭֲи*/ + ftnValue = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==ftnValue) + { + rtnValue=2U; + break; + } + } + if (wIndex==dsuDataLenStru->wEmergStopLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue=1U; + } + } + + return rtnValue; +} + +/*ͣdwStatTmnlLinkOfstwManagePhysicalCwManageLogicCIͨLINKȡ*/ +UINT8 CalcStopStationStruExpItem() +{ + UINT16 wIndex=0U; /*ѭ*/ + UINT8 rtnValue = 2U; + UINT8 ftnValue = 0U; + DSU_STATION_STRU* pTempStationStru=NULL; /*ͣϢṹ*/ /*ԭ---վ̨*/ + DSU_LINK_STRU * pLinkStru=NULL; /*LINKṹʱָ,ڼõ*/ + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + if(NULL==dsuEmapIndexStru) + { + rtnValue = 0U; + return rtnValue; + } + dsuLinkIndex=dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + ftnValue = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE==ftnValue) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndex < dsuDataLenStru->wStationLen; wIndex++) + { + pTempStationStru = dsuStaticHeadStru->pStationStru + wIndex; + /*ͨҵlinkϢ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempStationStru->wLinkId]; + + /**/ + pTempStationStru->dwStatTmnlLinkOfst = pLinkStru->dwLength; + pTempStationStru->wManageLogicCI = pLinkStru->wManageLogicCI; + pTempStationStru->wManagePhysicalCI = pLinkStru->wManagePhysicalCI; + /*ѭֲи*/ + ftnValue = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==ftnValue) + { + rtnValue=2U; + break; + } + } + if (wIndex==dsuDataLenStru->wStationLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue=1; + } + } + + return rtnValue; +} + +/*۷ݴ*/ +UINT8 ARInStru() +{ + UINT8 rtnValue = 2U; + UINT8 ftnValue = 0U; + UINT8 checkFlag = 0U; + UINT16 wIndex=0U; + DSU_AR_IN_STRU* pTempARInStru=NULL;/*۷*/ /*ϲ۷*/ + DSU_AR_STRU* pTempARStru=NULL;/*۷*/ /*۷۷˳ϲ*/ /*---Ϲѧ*/ + UINT16 wStruDataLen,wDataIndexLen = NULL; + UINT16 arInStopPointIndex = DSU_NULL_16; /*۷ͣ*/ + UINT16 revertStopPointIndex = DSU_NULL_16; /*۷ͣ*/ + + /*ӵͼ*/ + UINT16 *dsuStopPointIndex = NULL; + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + + /*ּ*/ + if (NULL != g_dsuEmapStru ) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStopPointIndex=dsuEmapIndexStru->dsuStopPointIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + if (0U != dsuDataLenStru->wARLen) + { + if(0U == dsuDataLenStru->wARInLen) + { + /*=Զ۷*/ + dsuDataLenStru->wARInLen = dsuDataLenStru->wARLen; + /*ΪԶ۷*/ + dsuEmapIndexStru->ARINNUM = dsuEmapIndexStru->ARNUM; + } + ftnValue = EmapCalcFunStepCtrl(0x01); + if (DQU_QFUN_TRUE==ftnValue) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuStaticHeadStru->pARInStru = (DSU_AR_IN_STRU *)MyNew(sizeof(DSU_AR_IN_STRU) * dsuDataLenStru->wARInLen); + if (NULL == dsuStaticHeadStru->pARInStru) + { + /*ռʧ*/ + rtnValue = 0U; + return rtnValue; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pARInStru, 0xFF, sizeof(DSU_AR_IN_STRU) * dsuDataLenStru->wARInLen); + } + + /*̬ռ*/ + dsuEmapIndexStru->dsuARInIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->ARINNUM + 2); + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuARInIndex) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuARInIndex, 0xFF, dsuEmapIndexStru->ARINNUM * 2 + 2); + } + rtnValue=2; + } + else/*ڴռⲿƷ*/ + { + rtnValue=2; + + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag= dquGetEmapDataStruArrayLen(EMAP_LINK_ID, &wStruDataLen); + + if(((0U != wStruDataLen) && (dsuDataLenStru->wARInLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U == checkFlag)) + { + rtnValue=0U; + return rtnValue; + } + + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_LINK_ID, &wDataIndexLen); + if (((0 != wDataIndexLen) && (dsuEmapIndexStru->ARINNUM >= wDataIndexLen))||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + return rtnValue; + } + } + + } + ftnValue = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE==ftnValue) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndex < dsuDataLenStru->wARInLen; wIndex++) + { + pTempARInStru = dsuStaticHeadStru->pARInStru + wIndex; + pTempARStru = dsuStaticHeadStru->pARStru + wIndex; + + /*Զ۷*/ + pTempARInStru->wId = pTempARStru->wId; + /*վ̨ID*/ + pTempARInStru->wPlatformId = pTempARStru->wStartPlartformId; + + /*ȡ۷ͻָͣ*/ + arInStopPointIndex = dsuStopPointIndex[pTempARStru->wARInStopPointId]; + revertStopPointIndex = dsuStopPointIndex[pTempARStru->wRevertPointId]; + + /*Ϊʵͣ˹ܣ˴˴Ҫеͣ޷鵽Чָ m by sds 2019-10-22*/ + if ((DSU_NULL_16 == arInStopPointIndex) || (DSU_NULL_16 == revertStopPointIndex)) + { + pTempARInStru->wStopPointLinkID = 0; + pTempARInStru->dwStopPointLinkOffset = 0; + pTempARInStru->wDir = 0; + pTempARInStru->dwParkArea = 0; + pTempARInStru->wRevertPointLinkID = 0; + pTempARInStru->dwRevertPointLinkOffset = 0; + pTempARInStru->dwRevertParkArea = 0; + pTempARInStru->wARLampID = 0; + pTempARInStru->wARButtonID = 0; + } + else + { + pTempARInStru->wStopPointLinkID = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wARInStopPointId])->wLinkId; + pTempARInStru->dwStopPointLinkOffset = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wARInStopPointId])->dwLinkOfst; + pTempARInStru->wDir = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wARInStopPointId])->wDir; + pTempARInStru->dwParkArea = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wARInStopPointId])->dwATPParkArea; + pTempARInStru->wRevertPointLinkID = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wRevertPointId])->wLinkId; + pTempARInStru->dwRevertPointLinkOffset = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wRevertPointId])->dwLinkOfst; + pTempARInStru->dwRevertParkArea = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wRevertPointId])->dwATPParkArea; + pTempARInStru->wARLampID = pTempARStru->wARLampID; + pTempARInStru->wARButtonID = pTempARStru->wARButtonId; + } + + + /*ʼ*/ + dsuEmapIndexStru->dsuARInIndex[pTempARInStru->wId] = wIndex; + /*ѭֲи*/ + ftnValue = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==ftnValue) + { + rtnValue=2; + break; + } + + } + if (wIndex==dsuDataLenStru->wARInLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue=1; + } + } + + } + else + { + rtnValue = 1; + /*=Զ۷*/ + dsuDataLenStru->wARInLen = 0; + /*ΪԶ۷*/ + dsuEmapIndexStru->ARINNUM = 0; + } + + return rtnValue; +} + +/*۷˳ݴ*/ +UINT8 AROutStru() +{ + UINT8 rtnValue = 2U; + UINT8 ftnValue = 0U; + UINT16 wIndex=0U; + UINT8 checkFlag = 0U; + DSU_AR_OUT_STRU* pTempAROutStru=NULL;/*۷˳*/ /*ϲ۷*/ + DSU_AR_STRU* pTempARStru=NULL;/*۷*/ /*۷۷˳ϲ*/ /*---Ϲѧ*/ + UINT16 wStruDataLen = 0U; + UINT16 wDataIndexLen = 0U; + UINT16 arOutStopPointIndex = DSU_NULL_16; /*۷˳ͣ*/ + + /*ӵͼ*/ + UINT16 *dsuStopPointIndex=NULL; + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + /*ּ*/ + if (NULL != g_dsuEmapStru) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStopPointIndex=dsuEmapIndexStru->dsuStopPointIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + if (0 != dsuDataLenStru->wARLen) + { + if (0U == dsuDataLenStru->wAROutLen) + { + + /*=Զ۷*/ + dsuDataLenStru->wAROutLen = dsuDataLenStru->wARLen; + /*ΪԶ۷*/ + dsuEmapIndexStru->AROUTNUM = dsuEmapIndexStru->ARNUM; + } + ftnValue = EmapCalcFunStepCtrl(0x01); + if (DQU_QFUN_TRUE==ftnValue) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + dsuStaticHeadStru->pAROutStru = (DSU_AR_OUT_STRU *)MyNew(sizeof(DSU_AR_OUT_STRU) * dsuDataLenStru->wAROutLen); + if (NULL == dsuStaticHeadStru->pAROutStru) + { + /*ռʧ*/ + rtnValue = 0U; + return rtnValue; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pAROutStru, 0xFF, sizeof(DSU_AR_OUT_STRU) * dsuDataLenStru->wAROutLen); + } + /*̬ռ*/ + dsuEmapIndexStru->dsuAROutIndex = (UINT16*)MyNew(sizeof(UINT16) * (dsuEmapIndexStru->AROUTNUM +1) ); + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuAROutIndex) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuAROutIndex, 0xFF, sizeof(UINT16) * (dsuEmapIndexStru->AROUTNUM +1) ); + } + rtnValue=2; + } + else/*ڴռⲿƷ*/ + { + rtnValue=2; + + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_LINK_ID, &wStruDataLen); + + if(((0U != wStruDataLen) && (dsuDataLenStru->wAROutLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + return rtnValue; + } + + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_LINK_ID, &wDataIndexLen); + if (((0 != wDataIndexLen) && (dsuEmapIndexStru->AROUTNUM >= wDataIndexLen))||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + return rtnValue; + } + } + } + + ftnValue = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE==ftnValue) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndex < dsuDataLenStru->wAROutLen; wIndex++) + { + pTempAROutStru = dsuStaticHeadStru->pAROutStru + wIndex; + pTempARStru = dsuStaticHeadStru->pARStru + wIndex; + + /*Զ۷˳*/ + pTempAROutStru->wId = pTempARStru->wId; + pTempAROutStru->wPlatformId = pTempARStru->wEndPlartformId; + + /*ȡ۷˳ָͣ*/ + arOutStopPointIndex = dsuStopPointIndex[pTempARStru->wAROutStopPointId]; + + /*Ϊʵͣ˹ܣ˴˴Ҫеͣ޷鵽Чָ m by sds 2019-10-22*/ + if (DSU_NULL_16 == arOutStopPointIndex) + { + pTempAROutStru->wStopPointLinkID = 0; + pTempAROutStru->dwStopPointLinkOffset = 0; + pTempAROutStru->dwParkArea = 0; + + } + else + { + + pTempAROutStru->wStopPointLinkID = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wAROutStopPointId])->wLinkId; + pTempAROutStru->dwStopPointLinkOffset = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wAROutStopPointId])->dwLinkOfst; + pTempAROutStru->dwParkArea = (dsuStaticHeadStru->pStopPointStru + dsuStopPointIndex[pTempARStru->wAROutStopPointId])->dwATPParkArea; + + } + + /*ʼ*/ + dsuEmapIndexStru->dsuAROutIndex[pTempAROutStru->wId] = wIndex; + + /*ѭֲи*/ + ftnValue = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==ftnValue) + { + rtnValue=2; + break; + } + } + + if (wIndex==dsuDataLenStru->wAROutLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue=1; + } + } + } + else + { + rtnValue = 1; + /*=Զ۷*/ + dsuDataLenStru->wAROutLen = 0; + /*ΪԶ۷*/ + dsuEmapIndexStru->AROUTNUM = 0; + } + + return rtnValue; +} + +/************************************************************ +*ܣ +*˵ +*ֵ0ʧܣ1ɹ +* +νṹ + +UINT16 wOrgnRelatPointId; +UINT16 wOrgnMainAxleSgmtId; Ӷλα +UINT16 wOrgnSideAxleSgmtId; ӷλα +UINT16 wTmnlRelatPointId; յ +UINT16 wTmnlMainAxleSgmtId; յӶλα +UINT16 wTmnlSideAxleSgmtId; յӷλα +UINT16 wRelatAxleSgmtNum; Ŀ +UINT16 wRelatAxleSgmtId[3]; α +UINT16 wManageZC; ZC +UINT16 wManagePhysicalCI; CI +UINT32 dwOrgnLinkOfst; linkƫ +UINT32 dwTmnlLinkOfst; յlinkƫ +UINT16 wMiddleLinkId[MIDDLE_LINK_MAX_NUM]; мlink +************************************/ +static UINT8 AxleSgmtStru_FAO() +{ + UINT16 linkId1 = 0U; /*μõʱ*/ + UINT16 linkId2 = 0U; + UINT16 linkId3 = 0U; + UINT16 linkId4 = 0U; + DQU_POINT_STATUS_STRU pointStatusStru[16]={0U}; /*״̬ṹ*/ + UINT16 i = 0U; + UINT16 j = 0U; + UINT16 k = 0U; /*ѭ*/ + DSU_AXLE_SGMT_STRU *pAxleSgmtStru[16]; /*θʱõ*/ + UINT8 funcCallResult = 0U; /*õĸķؽṹ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru = NULL, *pCurAxleSgmtStru = NULL; /*α*/ + DSU_LINK_STRU *pLinkStru = NULL; /*LINKṹʱָ,ڼʱõ*/ + UINT16 AxleSgmtCount = 0U; + UINT8 PointCount = 0U; + UINT8 rtnValue = 2U; + UINT8 ftnValue = 0U; + UINT8 chTempCount = 0U;/*ѯڼʱõжϱ־*/ + /*ӵͼ*/ + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuLinkIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + ftnValue = EmapCalcFunStepCtrl(0x02); + if ((DQU_QFUN_TRUE==ftnValue)&&(0U != rtnValue)) + { + for(i=0;iwAxleSgmtLen;i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + /*ͨҵlinkϢ(ȡյLINK)*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + + /*wManagePhysicalCI,wManageZC*/ + pTempAxleSgmtStru->wManageZC = pLinkStru->wManageZC; + pTempAxleSgmtStru->wManagePhysicalCI = pLinkStru->wManagePhysicalCI; + + /*dwOrgnLinkOfst,dwTmnlLinkOfst*/ + pTempAxleSgmtStru->dwOrgnLinkOfst = 0U; + pTempAxleSgmtStru->dwTmnlLinkOfst = pLinkStru->dwLength; + } + rtnValue = 2U; + } + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + + /**** + wMiddleLinkId + ****/ + ftnValue = EmapCalcFunStepCtrl(0x03); + if ((DQU_QFUN_TRUE==ftnValue) && (0U != rtnValue)) + { + for(i=0;iwAxleSgmtLen;i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + /*4,˳*/ + if(pTempAxleSgmtStru->wRelatPointNum>4U) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wOrgnLkId == pTempAxleSgmtStru->wTmnlLkId) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = 0xFFFFU; + } + else + { + /*ͬһlink*/ + for (j = 0U; jwRelatPointNum; j++) + { + /*ʼ״̬ṹ*/ + pointStatusStru[j].PointId = pTempAxleSgmtStru->wRelatPointId[j]; + pointStatusStru[j].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[j]; + } + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, pTempAxleSgmtStru->wOrgnLkId, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId1); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId1) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId1, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId2); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId2) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId2, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId3); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId3) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId3, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId4); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId4) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + pTempAxleSgmtStru->wMiddleLinkId[2] = linkId3; + } + else + { + /*γ5link,ܳ*/ + rtnValue = 0U; + } + } + + } + } + } + } + } + } + + } + } + if (0U == rtnValue) + { + break; + } + else + { + ; /*ִ*/ + } + } /*end forloop*/ + } + /**** + wMiddleLinkId + ****/ + + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[3]; α + ****/ + ftnValue = EmapCalcFunStepCtrl(0x04); + if ((DQU_QFUN_TRUE==ftnValue) && (0U != rtnValue)) + { + /*ȰѹĿΪ0*/ + for(k=0;kwAxleSgmtLen;k++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + k; + pTempAxleSgmtStru->wRelatAxleSgmtNum = 0U; + } + rtnValue = 2U; + } + ftnValue = EmapCalcFunStepCtrl(0x05); + if ((DQU_QFUN_TRUE==ftnValue) && (0U != rtnValue)) + { + for(i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;iwAxleSgmtLen;i++) + { + /*ǰ*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + for(j=0;jwAxleSgmtLen;j++) + { + /*ʱΣͬڵǰ*/ + if(j == i) + { + /*޲ѭ*/ + } + else + { + pCurAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + j; + /*ǰʼLinkͬʱʼLinkͬ + ǰιΪʱ*/ + if(pTempAxleSgmtStru->wOrgnLkId == pCurAxleSgmtStru->wOrgnLkId) + { + if(AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + /*ǰնLinkͬʱնLinkͬ + ǰιΪʱ*/ + else if(pTempAxleSgmtStru->wTmnlLkId == pCurAxleSgmtStru->wTmnlLkId) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + /*ǰмlinkмLinkͬʱмLinkͬ + ǰιΪʱ*/ + else if((pTempAxleSgmtStru->wMiddleLinkId[0] != UINT16_MAX)&& + (pTempAxleSgmtStru->wMiddleLinkId[0] == pCurAxleSgmtStru->wMiddleLinkId[0])) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + else + { + /*޲ѭ*/ + } + if (0U == rtnValue) + { + break; + } + } + + } + /*ѭзּ⴦*/ + ftnValue = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE==ftnValue) || (0U == rtnValue)) + { + break; + } + } + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0U; + rtnValue = 2U; + } + } + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[3]; α + ****/ + + + /*** + wOrgnRelatPointId + ******/ + ftnValue = EmapCalcFunStepCtrl(0x06); + if ((DQU_QFUN_TRUE==ftnValue) && (0U != rtnValue)) + { + for( i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;iwAxleSgmtLen;i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģʼᣩwOrgnAxleIdijεģյᣩwTmnlAxleId + ˵ǰǰй*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]; + if ((LINK_DIRCHANGE_NONE == pLinkStru->wLogicDirChanged) + || (LINK_DIRCHANGE_END == pLinkStru->wLogicDirChanged)) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰڼ---ǰLINK޷仯LINKյΪ仯㣬ѯʽͬ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*ָ룬*/ + /*һǰ15ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + else + { + ; /**/ + } + } + } + /*㵱ǰι*/ + if (0U != rtnValue) + { + /*Ӽα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*Ӽαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (j = 0U; j < AxleSgmtCount; j++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wTmnlLkId]; + /*նlinkڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + } + } + + /*жмlinkնڲLinkǷΪЧ*/ + for (k = 0U; k < MIDDLE_LINK_MAX_NUM; k++) + { + if (UINT16_MAX != pAxleSgmtStru[j]->wMiddleLinkId[k])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wMiddleLinkId[k]]; + + /*wMiddleLinkIdڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + } + } + } + + }/*ѭмlink end*/ + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + } + } + } + else if (LINK_DIRCHANGE_BEGIN == pLinkStru->wLogicDirChanged) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰڼ--ǰLINKʼΪ仯㣬һ뵱ǰαһ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*ʱβǵǰε*/ + chTempCount = 0U; + for (k = 0U; k < pTempAxleSgmtStru->wRelatAxleSgmtNum; k++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wId == pTempAxleSgmtStru->wRelatAxleSgmtId[k]) + { + chTempCount++; + break; + } + } + if (0U == chTempCount) + { + /*ָ룬*/ + /*һǰ15ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + } + else + { + ; /**/ + } + } + } + /*㵱ǰι*/ + if (0U != rtnValue) + { + /*Ӽα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*Ӽαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (j = 0U; j < AxleSgmtCount; j++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wOrgnLkId]; + /*ʼlinkյڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + } + } + } + if (0u != rtnValue) + { + /*жмlinkնڲLinkǷΪЧ*/ + for (k = 0U; k < MIDDLE_LINK_MAX_NUM; k++) + { + if (UINT16_MAX != pAxleSgmtStru[j]->wMiddleLinkId[k])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wMiddleLinkId[k]]; + + /*wMiddleLinkIdڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + + } + } + } + + }/*ѭмlink end*/ + } + + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + } + } + } + else + { + rtnValue = 0U;; /*LINK߼仯ֵǷ*/ + } + /*ѭзּ⴦*/ + ftnValue = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE == ftnValue) || (0U == rtnValue)) + { + break; + } + } + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0U; + rtnValue = 2U; + } + } + /*wTmnlRelatPointId*/ + ftnValue = EmapCalcFunStepCtrl(0x07); + if ((DQU_QFUN_TRUE==ftnValue) && (0U != rtnValue)) + { + for(i=g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;iwAxleSgmtLen;i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģյᣩwTmnlAxleIdijεģʼᣩwOrgnAxleId + ˵ǰκй*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + if ((LINK_DIRCHANGE_NONE == pLinkStru->wLogicDirChanged) + || (LINK_DIRCHANGE_BEGIN == pLinkStru->wLogicDirChanged)) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰյڼ---ǰյLINK޷仯LINKΪ仯㣬ѯʽͬ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + /*һκ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + break; + } + } + else + { + ; /**/ + } + } + } + + if (0U != rtnValue) + { + /*յӼα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*յӼαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (j = 0U; j < AxleSgmtCount; j++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wOrgnLkId]; + /*ʼlinkնڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + } + } + } + if (0U != rtnValue) + { + /*жмlinkնڲLinkǷΪЧ*/ + for (k = 0U; k < MIDDLE_LINK_MAX_NUM; k++) + { + if (UINT16_MAX != pAxleSgmtStru[j]->wMiddleLinkId[k])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wMiddleLinkId[k]]; + + /*wMiddleLinkIdնڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + + } + } + } + + }/*ѭмlink end*/ + } + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + } + else + { + /*޲ΪڷڴʱʼֵΪ0xFFFF*/ + } + /**** յ******/ + } + } + else if (LINK_DIRCHANGE_END == pLinkStru->wLogicDirChanged) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰյڼ---ǰյLINKնΪ仯㣬һյ뵱ǰյαһ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + /*ʱβǵǰε*/ + chTempCount = 0U; + for (k = 0U; k < pTempAxleSgmtStru->wRelatAxleSgmtNum; k++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wId == pTempAxleSgmtStru->wRelatAxleSgmtId[k]) + { + chTempCount++; + break; + } + } + if (0U == chTempCount) + { + /*ָ룬*/ + /*һκ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + } + else + { + ; /**/ + } + } + } + + if (0U != rtnValue) + { + /*յӼα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*յӼαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (j = 0U; j < AxleSgmtCount; j++) + { + /*жϸεնlinkڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wTmnlLkId]; + /*նlinkڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + } + } + } + if (0U != rtnValue) + { + /*жмlinkնڲLinkǷΪЧ*/ + for (k = 0U; k < MIDDLE_LINK_MAX_NUM; k++) + { + if (UINT16_MAX != pAxleSgmtStru[j]->wMiddleLinkId[k])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wMiddleLinkId[k]]; + + /*wMiddleLinkIdնڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + } + } + } + + }/*ѭмlink end*/ + } + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + } + else + { + /*޲ΪڷڴʱʼֵΪ0xFFFF*/ + } + /**** յ******/ + } + + } + else + { + rtnValue = 0U;; /*LINK߼仯ֵǷ*/ + } + + /*ѭзּ⴦*/ + ftnValue = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE == ftnValue) || (0U == rtnValue)) + { + break; + } + } + if(( i == dsuDataLenStru->wAxleSgmtLen) && (0U != rtnValue)) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1U; + } + else + { + rtnValue = 0U; + } + } + + return rtnValue; + +} +/************************************************************ +*ܣ +*˵ +*ֵ0ʧܣ1ɹ +* +νṹ + +UINT16 wOrgnRelatPointId; +UINT16 wOrgnMainAxleSgmtId; Ӷλα +UINT16 wOrgnSideAxleSgmtId; ӷλα +UINT16 wTmnlRelatPointId; յ +UINT16 wTmnlMainAxleSgmtId; յӶλα +UINT16 wTmnlSideAxleSgmtId; յӷλα +UINT16 wRelatAxleSgmtNum; Ŀ +UINT16 wRelatAxleSgmtId[3]; α +UINT16 wManageZC; ZC +UINT16 wManagePhysicalCI; CI +UINT32 dwOrgnLinkOfst; linkƫ +UINT32 dwTmnlLinkOfst; յlinkƫ +UINT16 wMiddleLinkId[MIDDLE_LINK_MAX_NUM]; мlink +************************************/ +static UINT8 AxleSgmtStru_CC() +{ + UINT16 linkId1 = 0U; /*μõʱ*/ + UINT16 linkId2 = 0U; + UINT16 linkId3 = 0U; + UINT16 linkId4 = 0U; + DQU_POINT_STATUS_STRU pointStatusStru[16] = {0U}; /*״̬ṹ*/ + UINT16 i = 0U; + UINT16 j = 0U; + UINT16 k = 0U; /*ѭ*/ + DSU_AXLE_SGMT_STRU *pAxleSgmtStru[16] = {NULL}; /*θʱõ*/ + UINT8 funcCallResult = 0U; /*õĸķؽṹ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru = NULL; + DSU_AXLE_SGMT_STRU *pCurAxleSgmtStru = NULL; /*α*/ + DSU_LINK_STRU *pLinkStru = NULL; /*LINKṹʱָ,ڼʱõ*/ + UINT16 AxleSgmtCount = 0U; + UINT8 rtnValue = 2U; + UINT8 chTempCount = 0U;/*ѯڼʱõжϱ־*/ + + /*ӵͼ*/ + UINT16 *dsuLinkIndex = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + UINT8 PointCount = 0U; + UINT8 chFlag = 0U; + UINT8 stepFlag = 0U; + UINT16 n = 0U; + UINT16 l = 0U; + if (NULL != g_dsuEmapStru) + { + dsuLinkIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + if (0U != rtnValue) + { + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE == stepFlag) + { + for (i = 0U; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + /*ͨҵlinkϢ(ȡյLINK)*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + + /*wManagePhysicalCI,wManageZC*/ + pTempAxleSgmtStru->wManageZC = pLinkStru->wManageZC; + pTempAxleSgmtStru->wManagePhysicalCI = pLinkStru->wManagePhysicalCI; + + pTempAxleSgmtStru->BelongVirCI = pLinkStru->wBelongVirtualCI; + /*dwOrgnLinkOfst,dwTmnlLinkOfst*/ + pTempAxleSgmtStru->dwOrgnLinkOfst = 0U; + pTempAxleSgmtStru->dwTmnlLinkOfst = pLinkStru->dwLength; + } + rtnValue = 2U; + } + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + + /**** + wMiddleLinkId + ****/ + stepFlag = EmapCalcFunStepCtrl(0x03); + if (DQU_QFUN_TRUE == stepFlag) + { + for (i = 0U; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + /*4,˳*/ + if (pTempAxleSgmtStru->wRelatPointNum > 4U) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + } + if (0U != rtnValue) + { + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wOrgnLkId == pTempAxleSgmtStru->wTmnlLkId) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = UINT16_MAX; + } + else + { + /*ͬһlink*/ + for (j = 0U; j < pTempAxleSgmtStru->wRelatPointNum; j++) + { + /*ʼ״̬ṹ*/ + pointStatusStru[j].PointId = pTempAxleSgmtStru->wRelatPointId[j]; + pointStatusStru[j].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[j]; + } + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, pTempAxleSgmtStru->wOrgnLkId, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId1); + + /*ʧܣ˳*/ + if (1U!=funcCallResult ) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + } + + if (0U != rtnValue) + { + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId1) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = UINT16_MAX; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId1, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId2); + + /*ʧܣ˳*/ + if (1U!=funcCallResult ) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + } + + if (0U != rtnValue) + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId2) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId2, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId3); + + /*ʧܣ˳*/ + if (1U!=funcCallResult) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + } + + if (0U != rtnValue) + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId3) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId3, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId4); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + } + + if (0U != rtnValue) + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId4) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + pTempAxleSgmtStru->wMiddleLinkId[2] = linkId3; + } + else + { + /*γ5link,ܳ*/ + rtnValue = 0U; + } + } + } + } + } + } + } + } + } + } + else + { + + } + + if (0U == rtnValue) + { + break; + } + else + { + ; /*ִ*/ + } + } /*end forloop*/ + } + /**** + wMiddleLinkId + ****/ + + } + + if (0U != rtnValue) + { + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[3]; α + ****/ + stepFlag = EmapCalcFunStepCtrl(0x04); + if (DQU_QFUN_TRUE == stepFlag) + { + /*ȰѹĿΪ0*/ + for (k = 0U; k < dsuDataLenStru->wAxleSgmtLen; k++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + k; + pTempAxleSgmtStru->wRelatAxleSgmtNum = 0U; + } + rtnValue = 2U; + } + + stepFlag = EmapCalcFunStepCtrl(0x05); + if (DQU_QFUN_TRUE == stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*ǰ*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + /*ʱΣͬڵǰ*/ + if (j == i) + { + /*޲ѭ*/ + } + else + { + pCurAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + j; + /*ǰʼLinkͬʱʼLinkͬ + ǰιΪʱ*/ + if (pTempAxleSgmtStru->wOrgnLkId == pCurAxleSgmtStru->wOrgnLkId) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + /*ǰնLinkͬʱնLinkͬ + ǰιΪʱ*/ + else if (pTempAxleSgmtStru->wTmnlLkId == pCurAxleSgmtStru->wTmnlLkId) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + /*ǰмlinkмLinkͬʱмLinkͬ + ǰιΪʱ*/ + else if ((pTempAxleSgmtStru->wMiddleLinkId[0] != UINT16_MAX) && + (pTempAxleSgmtStru->wMiddleLinkId[0] == pCurAxleSgmtStru->wMiddleLinkId[0])) + { + if(AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + else + { + /*޲ѭ*/ + } + if (0U == rtnValue) + { + break; + } + else + { + /*ִ*/ + } + } + + } + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE == stepFlag) || (0U == rtnValue)) + { + break; + } + } + if (i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 2U; + } + } + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[3]; α + ****/ + } + else + { + ; /*ִʧ*/ + } + + if (0U != rtnValue) + { + /*** + wOrgnRelatPointId + ******/ + stepFlag = EmapCalcFunStepCtrl(0x06); + if (DQU_QFUN_TRUE == stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģʼᣩwOrgnAxleIdijεģյᣩwTmnlAxleId + ˵ǰǰй*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]; + if ((LINK_DIRCHANGE_NONE == pLinkStru->wLogicDirChanged) + || (LINK_DIRCHANGE_END == pLinkStru->wLogicDirChanged)) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰڼ---ǰLINK޷仯LINKյΪ仯㣬ѯʽͬ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*һǰ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + else + { + ; /**/ + } + } + } + /*㵱ǰι*/ + if (0U != rtnValue) + { + /*Ӽα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*Ӽαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wTmnlLkId]; + /*նlinkڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + } + } + + /*жмlinkնڲLinkǷΪЧ*/ + for (l = 0U; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + break; + } + + } + } + } + + }/*ѭмlink end*/ + + }/*ѭend*/ + } + } + } + else if (LINK_DIRCHANGE_BEGIN == pLinkStru->wLogicDirChanged) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰڼ--ǰLINKʼΪ仯㣬һ뵱ǰαһ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*ʱβǵǰε*/ + chTempCount = 0U; + for (k = 0U; k < pTempAxleSgmtStru->wRelatAxleSgmtNum; k++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wId == pTempAxleSgmtStru->wRelatAxleSgmtId[k]) + { + chTempCount++; + break; + } + } + if (0U == chTempCount) + { + /*һǰ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + } + else + { + ; /**/ + } + } + } + /*㵱ǰι*/ + if (0U != rtnValue) + { + /*Ӽα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*Ӽαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wOrgnLkId]; + /*ʼlinkյڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + } + } + + /*жмlinkնڲLinkǷΪЧ*/ + for (l = 0U; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + break; + } + + } + } + } + + }/*ѭмlink end*/ + + }/*ѭend*/ + } + } + } + else + { + rtnValue = 0U;; /*LINK߼仯ֵǷ*/ + } + /**/ + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE == stepFlag) || (0U == rtnValue)) + { + break; + } + } + + } + if (i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 2U; + } + /*wTmnlRelatPointId*/ + } + else + { + ; /*ִʧ*/ + } + if (0U != rtnValue) + { + stepFlag = EmapCalcFunStepCtrl(0x07); + if (DQU_QFUN_TRUE == stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģյᣩwTmnlAxleIdijεģʼᣩwOrgnAxleId + ˵ǰκй*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + if ((LINK_DIRCHANGE_NONE == pLinkStru->wLogicDirChanged) + || (LINK_DIRCHANGE_BEGIN == pLinkStru->wLogicDirChanged)) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰյڼ---ǰյLINK޷仯LINKΪ仯㣬ѯʽͬ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + + /*һκ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + else + { + ; /**/ + } + } + } + if (0U != rtnValue) + { + /*յӼα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*յӼαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wOrgnLkId]; + /*ʼlinkնڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + } + } + + /*жмlinkնڲLinkǷΪЧ*/ + for (l = 0U; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdնڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + break; + } + + } + } + } + + }/*ѭмlink end*/ + + }/*ѭend*/ + } + else + { + /*޲ΪڷڴʱʼֵΪ0xFFFF*/ + } + /**** յ******/ + } + } + else if (LINK_DIRCHANGE_END == pLinkStru->wLogicDirChanged) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰյڼ---ǰյLINKնΪ仯㣬һյ뵱ǰյαһ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + /*ʱβǵǰε*/ + chTempCount = 0U; + for (k = 0U; k < pTempAxleSgmtStru->wRelatAxleSgmtNum; k++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wId == pTempAxleSgmtStru->wRelatAxleSgmtId[k]) + { + chTempCount++; + break; + } + } + if (0U == chTempCount) + { + /*һκ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + } + else + { + ; /**/ + } + } + } + if (0U != rtnValue) + { + /*յӼα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*յӼαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + /*жϸεնlinkڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wTmnlLkId]; + /*նlinkڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + } + } + + /*жмlinkնڲLinkǷΪЧ*/ + for (l = 0U; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdնڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + break; + } + + } + } + } + + }/*ѭмlink end*/ + + }/*ѭend*/ + } + else + { + /*޲ΪڷڴʱʼֵΪ0xFFFF*/ + } + /**** յ******/ + } + +} + else + { + rtnValue = 0U;; /*LINK߼仯ֵǷ*/ + } + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE == stepFlag) || (0U == rtnValue)) + { + break; + } + } + if (i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 1U; + } + else + { + rtnValue = 0U; + } + } + } + else + { + ; /*ִʧ*/ + } + return rtnValue; +} +static UINT8 AxleSgmtStru_CPK() +{ + UINT16 linkId1=0U; + UINT16 linkId2=0U; + UINT16 linkId3=0U; /*μõʱ 150608ʱlinkId3*/ + UINT16 linkId4 = 0U; + DQU_POINT_STATUS_STRU pointStatusStru[16]={0U}; /*״̬ṹ*/ + UINT16 i=0U; + UINT16 j=0U; + UINT16 k=0U; + UINT16 m=0U; + DSU_AXLE_SGMT_STRU *pAxleSgmtStru[16]={NULL}; /*θʱõ*/ + UINT8 funcCallResult = 0U; /*õĸķؽṹ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru=NULL; + DSU_AXLE_SGMT_STRU *pCurAxleSgmtStru=NULL; /*α*/ + DSU_LINK_STRU *pLinkStru=NULL; + UINT16 AxleSgmtCount = 0U; + UINT8 PointCount = 0U; + UINT8 chTempCount = 0U;/*ѯڼʱõжϱ־*/ + UINT8 rtnValue = 2U; + UINT8 stepFlag = 0U; + + /*ӵͼ*/ + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuLinkIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = 0U; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + /*ͨҵlinkϢ(ȡյLINK)*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + + /*wManagePhysicalCI,wManageZC*/ + pTempAxleSgmtStru->wManageZC = pLinkStru->wManageZC; + pTempAxleSgmtStru->wManagePhysicalCI = pLinkStru->wManagePhysicalCI; + + /*dwOrgnLinkOfst,dwTmnlLinkOfst*/ + pTempAxleSgmtStru->dwOrgnLinkOfst = 0U; + pTempAxleSgmtStru->dwTmnlLinkOfst = pLinkStru->dwLength; + } + rtnValue = 2U; + } + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + + /**** + wMiddleLinkId + ****/ + stepFlag = EmapCalcFunStepCtrl(0x03); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = 0U; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + + /*150608 ʼмLinkΪ0xFFFF*/ + for (m = 0U; m < MIDDLE_LINK_MAX_NUM; m++) + { + pTempAxleSgmtStru->wMiddleLinkId[m] = UINT16_MAX; + } + + /*4,˳*/ + if (pTempAxleSgmtStru->wRelatPointNum > 4U) + { + rtnValue = 0U; + } + else + { + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wOrgnLkId == pTempAxleSgmtStru->wTmnlLkId) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = UINT16_MAX;/*0xffff*/ + } + else + { + /*ͬһlink*/ + for (j = 0U; j < pTempAxleSgmtStru->wRelatPointNum; j++) + { + /*ʼ״̬ṹ*/ + pointStatusStru[j].PointId = pTempAxleSgmtStru->wRelatPointId[j]; + pointStatusStru[j].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[j]; + } + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, pTempAxleSgmtStru->wOrgnLkId, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId1); + + /*ʧܣ˳*/ + if (1U!= funcCallResult) + { + rtnValue = 0U; + } + else + { + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId1) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId1, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId2); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId2) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + /*linkId2ҲΪüεյLinkʱѰһLink*/ + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId2, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId3); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + if (pTempAxleSgmtStru->wTmnlLkId == linkId3) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId3, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId4); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId4) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + pTempAxleSgmtStru->wMiddleLinkId[2] = linkId3; + } + else + { + /*γ5link,ܳ*/ + rtnValue = 0U; + } + } + } + } + } + } + } + } + } + } + if (0U == rtnValue) + { + break; + } + else + { + ; /*ִ*/ + } + } /*end forloop*/ + } + /**** + wMiddleLinkId + ****/ + + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[4]; 150608 α + ****/ + stepFlag = EmapCalcFunStepCtrl(0x04); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + /*ȰѹĿΪ0*/ + for (k = 0U; k < dsuDataLenStru->wAxleSgmtLen; k++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + k; + pTempAxleSgmtStru->wRelatAxleSgmtNum = 0U; + } + rtnValue = 2U; + } + + stepFlag = EmapCalcFunStepCtrl(0x05); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*ǰ*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + /*ʱΣͬڵǰ*/ + if (j == i) + { + /*޲ѭ*/ + } + else + { + pCurAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + j; + /*ǰʼLinkͬʱʼLinkͬ + ǰιΪʱ*/ + if (pTempAxleSgmtStru->wOrgnLkId == pCurAxleSgmtStru->wOrgnLkId) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + /*ǰնLinkͬʱնLinkͬ + ǰιΪʱ*/ + else if (pTempAxleSgmtStru->wTmnlLkId == pCurAxleSgmtStru->wTmnlLkId) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + /*ǰмlinkмLinkͬʱмLinkͬ150608 wMiddleLinkId[0]ֵwMiddleLinkId[1]ûֵʱΪֻһмLink + ǰιΪʱ*/ + else if ((pTempAxleSgmtStru->wMiddleLinkId[0] != 0xFFFF) && + (pTempAxleSgmtStru->wMiddleLinkId[1] == 0xFFFF) && + (pTempAxleSgmtStru->wMiddleLinkId[0] == pCurAxleSgmtStru->wMiddleLinkId[0])) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + + /*150608 wMiddleLinkId[0]wMiddleLinkId[1]ֵʱMiddleLinkId[0]MiddleLinkId[1]ͬΪؼ*/ + else if ( + (pTempAxleSgmtStru->wMiddleLinkId[0] != 0xFFFF) && + (pTempAxleSgmtStru->wMiddleLinkId[1] != 0xFFFF) && + ((pTempAxleSgmtStru->wMiddleLinkId[0] == pCurAxleSgmtStru->wMiddleLinkId[0]) || + (pTempAxleSgmtStru->wMiddleLinkId[1] == pCurAxleSgmtStru->wMiddleLinkId[1]) || + (pTempAxleSgmtStru->wMiddleLinkId[1] == pCurAxleSgmtStru->wMiddleLinkId[0]) || + (pTempAxleSgmtStru->wMiddleLinkId[0] == pCurAxleSgmtStru->wMiddleLinkId[1])) + ) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + else + { + /*޲ѭ*/ + } + } + } + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE== stepFlag) || (0U == rtnValue)) + { + break; + } + } + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 2U; + } + } + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[4]; α + ****/ + + /*** + wOrgnRelatPointId + ******/ + stepFlag = EmapCalcFunStepCtrl(0x06); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģʼᣩwOrgnAxleIdijεģյᣩwTmnlAxleId + ˵ǰǰй pAxleSgmtStru[]Ϊй*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]; + if ((LINK_DIRCHANGE_NONE == pLinkStru->wLogicDirChanged) + || (LINK_DIRCHANGE_END == pLinkStru->wLogicDirChanged)) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰڼ---ǰLINK޷仯LINKյΪ仯㣬ѯʽͬ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*ָ룬*/ + /*һǰ15ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + else + { + ; /**/ + } + } + } + /*㵱ǰι*/ + if (0U != rtnValue) + { + /*Ӽα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*Ӽαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (j = 0U; j < AxleSgmtCount; j++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wTmnlLkId]; + /*նlinkڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + } + } + + /*жмlinkնڲLinkǷΪЧ*/ + for (k = 0U; k < MIDDLE_LINK_MAX_NUM; k++) + { + if (UINT16_MAX != pAxleSgmtStru[j]->wMiddleLinkId[k])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wMiddleLinkId[k]]; + + /*wMiddleLinkIdڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + } + } + } + + }/*ѭмlink end*/ + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + } + } + } + else if (LINK_DIRCHANGE_BEGIN == pLinkStru->wLogicDirChanged) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰڼ--ǰLINKʼΪ仯㣬һ뵱ǰαһ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*ʱβǵǰε*/ + chTempCount = 0U; + for (k = 0U; k < pTempAxleSgmtStru->wRelatAxleSgmtNum; k++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wId == pTempAxleSgmtStru->wRelatAxleSgmtId[k]) + { + chTempCount++; + break; + } + } + if (0U == chTempCount) + { + /*ָ룬*/ + /*һǰ15ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + } + else + { + ; /**/ + } + } + } + /*㵱ǰι*/ + if (0U != rtnValue) + { + /*Ӽα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*Ӽαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (j = 0U; j < AxleSgmtCount; j++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wOrgnLkId]; + /*ʼlinkյڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + } + } + } + if (0u != rtnValue) + { + /*жмlinkնڲLinkǷΪЧ*/ + for (k = 0U; k < MIDDLE_LINK_MAX_NUM; k++) + { + if (UINT16_MAX != pAxleSgmtStru[j]->wMiddleLinkId[k])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wMiddleLinkId[k]]; + + /*wMiddleLinkIdڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + + } + } + } + + }/*ѭмlink end*/ + } + + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + } + } + } + else + { + rtnValue = 0U;; /*LINK߼仯ֵǷ*/ + } + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE== stepFlag) || (0U == rtnValue)) + { + break; + } + } + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 2U; + } + } + + + stepFlag = EmapCalcFunStepCtrl(0x07); + /*ʼwTmnlRelatPointId 150608*/ + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģյᣩwTmnlAxleIdijεģʼᣩwOrgnAxleId + ˵ǰκй*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + if ((LINK_DIRCHANGE_NONE == pLinkStru->wLogicDirChanged) + || (LINK_DIRCHANGE_BEGIN == pLinkStru->wLogicDirChanged)) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰյڼ---ǰյLINK޷仯LINKΪ仯㣬ѯʽͬ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + /*һκ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + break; + } + } + else + { + ; /**/ + } + } + } + + if (0U != rtnValue) + { + /*յӼα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*յӼαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (j = 0U; j < AxleSgmtCount; j++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wOrgnLkId]; + /*ʼlinkնڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + } + } + } + if (0U != rtnValue) + { + /*жмlinkնڲLinkǷΪЧ*/ + for (k = 0U; k < MIDDLE_LINK_MAX_NUM; k++) + { + if (UINT16_MAX != pAxleSgmtStru[j]->wMiddleLinkId[k])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wMiddleLinkId[k]]; + + /*wMiddleLinkIdնڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + + } + } + } + + }/*ѭмlink end*/ + } + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + } + else + { + /*޲ΪڷڴʱʼֵΪ0xFFFF*/ + } + /**** յ******/ + } + } + else if (LINK_DIRCHANGE_END == pLinkStru->wLogicDirChanged) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if (i == j) + { + ; /*ǰ*/ + } + else + { + /*ҵǰյڼ---ǰյLINKնΪ仯㣬һյ뵱ǰյαһ*/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + /*ʱβǵǰε*/ + chTempCount = 0U; + for (k = 0U; k < pTempAxleSgmtStru->wRelatAxleSgmtNum; k++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wId == pTempAxleSgmtStru->wRelatAxleSgmtId[k]) + { + chTempCount++; + break; + } + } + if (0U == chTempCount) + { + /*ָ룬*/ + /*һκ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + } + } + } + else + { + ; /**/ + } + } + } + + if (0U != rtnValue) + { + /*յӼα*/ + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /*յӼαż*/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount = 0U;/*ĿʼΪ0---ѭ*/ + for (j = 0U; j < AxleSgmtCount; j++) + { + /*жϸεնlinkڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wTmnlLkId]; + /*նlinkڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + } + } + } + if (0U != rtnValue) + { + /*жмlinkնڲLinkǷΪЧ*/ + for (k = 0U; k < MIDDLE_LINK_MAX_NUM; k++) + { + if (UINT16_MAX != pAxleSgmtStru[j]->wMiddleLinkId[k])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[j]->wMiddleLinkId[k]]; + + /*wMiddleLinkIdնڲLinkΪЧ*/ + if (UINT16_MAX != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + break; + } + } + } + } + + }/*ѭмlink end*/ + } + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + } + else + { + /*޲ΪڷڴʱʼֵΪ0xFFFF*/ + } + /**** յ******/ + } + + } + else + { + rtnValue = 0U;; /*LINK߼仯ֵǷ*/ + } + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE== stepFlag) ||(0U == rtnValue)) + { + break; + } + } + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 1U; + } + else + { + rtnValue = 0U; + } + } + + return rtnValue; + +} + +/************************************************ +auther: qxt +ܣжǷijԪأ + ڼνṹС + +@inputArray: +@arrayLength:鳤 +@element:ҪҵԪ + +ֵ 0ش 1 2 +************************************************/ + UINT8 DetecteElementInArray(UINT16 inputArray[],UINT16 arrayLength,UINT16 element) +{ + UINT8 rtnValue=2; + UINT16 index; + + if (NULL != inputArray) + { + for (index = 0; index < arrayLength; index++) + { + if (inputArray[index] == element) + { + rtnValue = 1; + return rtnValue; + } + } + } + else + { + rtnValue = 0U; + } + return rtnValue; + +} + + /************************************************ +auther: qxt +ܣжǷͬԪأ + ڼνṹС + +@array1:1 +@arrayLength1:1 +@array2:2 +@arrayLength2:2 + +ֵ 0ش 1 2 +************************************************/ +UINT8 DetecteSameElemInTwoArray(UINT16 array1[],UINT8 arrayLength1,UINT16 array2[],UINT8 arrayLength2) +{ + UINT8 rtnValue=2; + UINT8 i,j; + if ((NULL != array1) && (NULL != array2)) + { + for (i = 0; i < arrayLength1; i++) + { + for (j = 0; j < arrayLength2; j++) + { + if ((array1[i] == array2[j]) && (array1[i] != 0xffff)) + { + rtnValue = 1; + return rtnValue; + } + + } + } + } + else + { + rtnValue = 0U; + } + return rtnValue; + +} + +/*Ϣ㣬ԭ㷨뻥ͨĿͬͨ߼仯Ĵ + Ŀ߼仯󣬿ɸ滥ͨĴ add by qxt 20170816*/ +/*ɾ*/ +#if 0 +static UINT8 AxleSgmtStru_DG() +{ + UINT16 linkId1=0U; + UINT16 linkId2=0U; + UINT16 linkId3=0U; /*μõʱ 150608ʱlinkId3*/ + UINT16 linkId4=0U; + DQU_POINT_STATUS_STRU pointStatusStru[4]={0U}; /*״̬ṹ*/ + UINT16 i=0U; + UINT16 j=0U; + UINT16 k=0U; + UINT16 m=0U; + UINT16 n=0U; + UINT16 l=0U; /*ѭ*/ + DSU_AXLE_SGMT_STRU *pAxleSgmtStru[16]={NULL}; /*θʱõ*/ + UINT8 funcCallResult = 0U; /*õĸķؽṹ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru=NULL; + DSU_AXLE_SGMT_STRU *pCurAxleSgmtStru=NULL; /*α*/ + DSU_LINK_STRU *pLinkStru=NULL; + UINT16 AxleSgmtCount = 0U; + + UINT8 rtnValue = 2U; + UINT8 stepFlag = 0U; + + + UINT8 PointCount=0U;/*Ŀ add by qxt 20161104*/ + + /*ӵͼ*/ + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuLinkIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = 0; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + /*ͨҵlinkϢ(ȡյLINK)*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + + /*wManagePhysicalCI,wManageZC*/ + pTempAxleSgmtStru->wManageZC = pLinkStru->wManageZC; + pTempAxleSgmtStru->wManagePhysicalCI = pLinkStru->wManagePhysicalCI; + + /*dwOrgnLinkOfst,dwTmnlLinkOfst*/ + pTempAxleSgmtStru->dwOrgnLinkOfst = 0; + pTempAxleSgmtStru->dwTmnlLinkOfst = pLinkStru->dwLength; + } + rtnValue = 2; + } + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + + /**** + wMiddleLinkId + ****/ + stepFlag = EmapCalcFunStepCtrl(0x03); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = 0; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + + /*150608 ʼмLinkΪ0xFFFF*/ + for (m = 0; m < MIDDLE_LINK_MAX_NUM; m++) + { + pTempAxleSgmtStru->wMiddleLinkId[m] = 0xFFFF; + } + + /*4,˳*//*3-->4 by qxt 20160915*/ + if (pTempAxleSgmtStru->wRelatPointNum>4) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wOrgnLkId == pTempAxleSgmtStru->wTmnlLkId) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = 0xFFFF;/*150608*/ + } + else + { + /*ͬһlink*/ + for (j = 0; j < pTempAxleSgmtStru->wRelatPointNum; j++) + { + /*ʼ״̬ṹ*/ + pointStatusStru[j].PointId = pTempAxleSgmtStru->wRelatPointId[j]; + pointStatusStru[j].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[j]; + } + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,pTempAxleSgmtStru->wOrgnLkId, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId1); + + /*ʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId1) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = 0xFFFF;/*150608*/ + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId1, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId2); + + /*ʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId2) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + /*150608 linkId2ҲΪüεյLinkʱѰһLink*/ + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId2, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId3); + + /*ʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + if (pTempAxleSgmtStru->wTmnlLkId == linkId3) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + } + else + { + /*ּ֧ΰĿΪ4 add by qxt 20160915*/ + /*linkId3ҲΪüεյLinkʱѰһLink*/ + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId3, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId4); + + /*ʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + if (pTempAxleSgmtStru->wTmnlLkId == linkId4) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + pTempAxleSgmtStru->wMiddleLinkId[2] = linkId3; + } + else + { + /*üγ5link,ѯ֧*/ + rtnValue = 0U; + return rtnValue; + } + + } + } + } + } + } /*end forloop*/ + rtnValue = 2; + } + /**** + wMiddleLinkId + ****/ + + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[4]; 150608 α + ****/ + stepFlag = EmapCalcFunStepCtrl(0x04); + if (DQU_QFUN_TRUE== stepFlag) + { + /*ȰѹĿΪ0*/ + for (k = 0; k < dsuDataLenStru->wAxleSgmtLen; k++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + k; + pTempAxleSgmtStru->wRelatAxleSgmtNum = 0; + } + rtnValue = 2; + } + + stepFlag = EmapCalcFunStepCtrl(0x05); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*ǰ*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + for (j = 0; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + /*ʱΣͬڵǰ*/ + if (j == i) + { + /*޲ѭ*/ + } + else + { + pCurAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + j; + /*ǰʼLinkͬʱʼLinkͬ + ǰιΪʱ*/ + if (pTempAxleSgmtStru->wOrgnLkId == pCurAxleSgmtStru->wOrgnLkId) + { + /*֧ĿΪ16*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + return rtnValue; + } + } + /*ǰնLinkͬʱնLinkͬ + ǰιΪʱ*/ + else if (pTempAxleSgmtStru->wTmnlLkId == pCurAxleSgmtStru->wTmnlLkId) + { + /*֧ĿΪ16*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + return rtnValue; + } + } + /*ǰмlinkмLinkͬʱмLinkͬģǰιΪʱ*/ + + else if (1==DetecteSameElemInTwoArray(pTempAxleSgmtStru->wMiddleLinkId,MIDDLE_LINK_MAX_NUM,pCurAxleSgmtStru->wMiddleLinkId,MIDDLE_LINK_MAX_NUM)) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + return rtnValue; + } + + } + + else + { + /*޲ѭ*/ + } + } + + } + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + } + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 2U; + } + } + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[4]; α + ****/ + + /*** + wOrgnRelatPointId + ******/ + stepFlag = EmapCalcFunStepCtrl(0x06); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģʼᣩwOrgnAxleIdεģյᣩwTmnlAxleId + ˵ǰǰй pAxleSgmtStru[]Ϊй*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + for (j = 0; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + + } + } + /*㵱ǰι*/ + /*һǰ16ϵļΣ*/ + if (AxleSgmtCount > 16) + { + rtnValue = 0U; + return rtnValue; + } + + + /* + Ӽα + */ + + for (k = 0; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + + /* Ӽαż*/ + + + /*****/ + + /*Ӽθʱй*/ + if (AxleSgmtCount>1) + { + PointCount = 0U;/*ĿʼΪ0*/ + /*ѭ*/ + for (n = 0; n < AxleSgmtCount; n++) + { + + /*жϸεնlinkʼڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wTmnlLkId]; + /*ʼlinkʼڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if(2==DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId,PointCount,pLinkStru->wOrgnPointId)) + { + + if (PointCount<15) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else/*15*/ + { + rtnValue = 0U; + return rtnValue; + } + } + } + + /*жмlinkʼڲlinkǷЧ*/ + for (l = 0U; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdʼڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if(2==DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId,PointCount,pLinkStru->wOrgnPointId)) + { + if(PointCount<15) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else/*15*/ + { + rtnValue = 0U; + return rtnValue; + } + + } + } + } + + }/*ѭмlink end*/ + + }/*ѭend*/ + + } + + + /** + + ***/ + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2U; + break; + } + }/*forѭend*/ + + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 2U; + } + + } + + + stepFlag = EmapCalcFunStepCtrl(0x07); + /*ʼwTmnlRelatPointId 150608*/ + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģյᣩwTmnlAxleIdεģʼᣩwOrgnAxleId + ˵ǰκй*/ + + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + + } + } + + + /*iiι*/ /*forѭ*/ + /*һκ16ϵļΣ*/ + if (AxleSgmtCount >16) + { + rtnValue = 0U; + return rtnValue; + } + + /* + յӼα + */ + + for (k = 0; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /**** + յӼα + + ***/ + + /****յ******/ + + /*Ӽθʱй*/ + if (AxleSgmtCount>1) + { + PointCount = 0U;/*ĿʼΪ0*/ + /*ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wOrgnLkId]; + /*ʼlinkնڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if(2==DetecteElementInArray(pTempAxleSgmtStru->wTmnlRelatPointId,PointCount,pLinkStru->wTmnlPointId)) + { + + if (PointCount<15) + { + pTempAxleSgmtStru->wTmnlRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else/*15*/ + { + rtnValue = 0U; + return rtnValue; + } + } + } + + /*жмlinkնڲlinkǷЧ*/ + for (l = 0U ; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdʼڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if(2==DetecteElementInArray(pTempAxleSgmtStru->wTmnlRelatPointId,PointCount,pLinkStru->wTmnlPointId)) + { + if (PointCount<15) + { + pTempAxleSgmtStru->wTmnlRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else/*15*/ + { + rtnValue = 0U; + return rtnValue; + } + } + } + } + + } + } + + } + + /**** յ******/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + } + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 1U; + } + } + + return rtnValue; +} +#endif +/*ͨĿʹ*/ +static UINT8 AxleSgmtStru_HLT() +{ + UINT16 linkId1=0U; + UINT16 linkId2=0U; + UINT16 linkId3=0U; /*μõʱ 150608ʱlinkId3*/ + UINT16 linkId4=0U; + DQU_POINT_STATUS_STRU pointStatusStru[4]={0U}; /*״̬ṹ*/ + UINT16 i=0U; + UINT16 j=0U; + UINT16 k=0U; + UINT16 m=0U; + UINT16 n=0U; + UINT16 l=0U; /*ѭ*/ + DSU_AXLE_SGMT_STRU *pAxleSgmtStru[16]={NULL}; /*θʱõ*/ + UINT8 funcCallResult = 0U; /*õĸķؽṹ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru=NULL; + DSU_AXLE_SGMT_STRU *pCurAxleSgmtStru=NULL; /*α*/ + DSU_LINK_STRU *pLinkStru=NULL; + UINT16 AxleSgmtCount = 0U; + + UINT8 rtnValue = 2U; + UINT8 stepFlag = 0U; + + UINT8 PointCount=0U;/*Ŀ add by qxt 20161104*/ + UINT8 chFlag=1U; /*ִʧܱ*/ + UINT8 chTempCount=0U; + + /*ӵͼ*/ + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuLinkIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = 0U; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + /*ͨҵlinkϢ(ȡյLINK)*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + + /*wManagePhysicalCI,wManageZC*/ + pTempAxleSgmtStru->wManageZC = pLinkStru->wManageZC; + pTempAxleSgmtStru->wManagePhysicalCI = pLinkStru->wManagePhysicalCI; + + pTempAxleSgmtStru->BelongVirCI = pLinkStru->wBelongVirtualCI; + /*dwOrgnLinkOfst,dwTmnlLinkOfst*/ + pTempAxleSgmtStru->dwOrgnLinkOfst = 0U; + pTempAxleSgmtStru->dwTmnlLinkOfst = pLinkStru->dwLength; + } + rtnValue = 2U; + } + /********** + wManagePhysicalCI,wManageZC,dwOrgnLinkOfst,dwTmnlLinkOfst + *****/ + + /**** + wMiddleLinkId + ****/ + stepFlag = EmapCalcFunStepCtrl(0x03); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = 0U; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + + /*150608 ʼмLinkΪ0xFFFF*/ + for (m = 0U; m < MIDDLE_LINK_MAX_NUM; m++) + { + pTempAxleSgmtStru->wMiddleLinkId[m] = UINT16_MAX; + } + + /*4,˳*//*3-->4 by qxt 20160915*/ + if (pTempAxleSgmtStru->wRelatPointNum>4U) + { + rtnValue = 0U; + } + else + { + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wOrgnLkId == pTempAxleSgmtStru->wTmnlLkId) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = 0xFFFF;/*150608*/ + } + else + { + /*ͬһlink*/ + for (j = 0U; j < pTempAxleSgmtStru->wRelatPointNum; j++) + { + /*ʼ״̬ṹ*/ + pointStatusStru[j].PointId = pTempAxleSgmtStru->wRelatPointId[j]; + pointStatusStru[j].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[j]; + } + + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, pTempAxleSgmtStru->wOrgnLkId, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId1); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId1) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = 0xFFFF;/*150608*/ + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId1, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId2); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + /*мlinkΪlinkId1*/ + if (pTempAxleSgmtStru->wTmnlLkId == linkId2) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + /*150608 linkId2ҲΪüεյLinkʱѰһLink*/ + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId2, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId3); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + if (pTempAxleSgmtStru->wTmnlLkId == linkId3) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId3, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId4); + + /*ʧܣ˳*/ + if (1U != funcCallResult) + { + rtnValue = 0U; + } + else + { + if (pTempAxleSgmtStru->wTmnlLkId == linkId4) + { + pTempAxleSgmtStru->wMiddleLinkId[0] = linkId1; + pTempAxleSgmtStru->wMiddleLinkId[1] = linkId2; + pTempAxleSgmtStru->wMiddleLinkId[2] = linkId3; + } + else + { + /*γ5link,ܳ*/ + rtnValue = 0U; + } + } + } + } + } + } + } + } + } + } + if (0U == rtnValue) + { + break; + } + else + { + ; /*ִ*/ + } + + } /*end forloop*/ + } + /**** + wMiddleLinkId + ****/ + + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[4]; 150608 α + ****/ + stepFlag = EmapCalcFunStepCtrl(0x04); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + /*ȰѹĿΪ0*/ + for (k = 0U; k < dsuDataLenStru->wAxleSgmtLen; k++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + k; + pTempAxleSgmtStru->wRelatAxleSgmtNum = 0U; + } + rtnValue = 2U; + } + stepFlag = EmapCalcFunStepCtrl(0x05); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*ǰ*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + for (j = 0; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + /*ʱΣͬڵǰ*/ + if (j == i) + { + /*޲ѭ*/ + } + else + { + pCurAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + j; + /*ǰʼLinkͬʱʼLinkͬ + ǰιΪʱ*/ + if (pTempAxleSgmtStru->wOrgnLkId == pCurAxleSgmtStru->wOrgnLkId) + { + /*֧ĿΪ16*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) /*wRelatAxleSgmtNum±*/ + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + /*ǰնLinkͬʱնLinkͬ + ǰιΪʱ*/ + else if (pTempAxleSgmtStru->wTmnlLkId == pCurAxleSgmtStru->wTmnlLkId) + { + /*֧ĿΪ16*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + /*ǰмlinkмLinkͬʱмLinkͬģǰιΪʱ*/ + else if (1==DetecteSameElemInTwoArray(pTempAxleSgmtStru->wMiddleLinkId,MIDDLE_LINK_MAX_NUM,pCurAxleSgmtStru->wMiddleLinkId,MIDDLE_LINK_MAX_NUM)) + { + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > pTempAxleSgmtStru->wRelatAxleSgmtNum) + { + pTempAxleSgmtStru->wRelatAxleSgmtId[pTempAxleSgmtStru->wRelatAxleSgmtNum] = pCurAxleSgmtStru->wId; + pTempAxleSgmtStru->wRelatAxleSgmtNum++; + } + else + { + /**/ + rtnValue = 0U; + } + } + else + { + /*޲ѭ*/ + } + if (0U == rtnValue) + { + break; + } + } + } + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE== stepFlag) || (0U == rtnValue)) + { + break; + } + } + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 2U; + } + } + /**** + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[4]; α + ****/ + + /*** + wOrgnRelatPointId + ******/ + stepFlag = EmapCalcFunStepCtrl(0x06); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģʼᣩwOrgnAxleIdεģյᣩwTmnlAxleId + ˵ǰǰй pAxleSgmtStru[]Ϊй*/ + + /*link߼仯㣺ǰʼlinkΪ߼仯㣬Ѱ*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + + /*жʼlinkǷ߼仯*/ + pLinkStru=dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]; + + if (LINK_DIRCHANGE_BEGIN == pLinkStru->wLogicDirChanged) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + /*ʱΣͬڵǰ*/ + if (j == i) + { + /*޲ѭ*/ + } + else + { + /**/ + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*ʱβǵǰε*/ + chTempCount=0U; + for (k = 0U; k < pTempAxleSgmtStru->wRelatAxleSgmtNum; k++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wId ==pTempAxleSgmtStru->wRelatAxleSgmtId[k]) + { + chTempCount++; + break; + } + } + if (0U == chTempCount) + { + /*һǰ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + } + + } + else + { + + } + } + } + /*㵱ǰι*/ + if(0U != rtnValue) + { + /* + Ӽα + */ + + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + + /* Ӽαż*/ + + + /*****/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount=0U;/*ĿʼΪ0*/ + /*ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wOrgnLkId]; + /*ʼlinkնڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if(2==DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId,PointCount,pLinkStru->wTmnlPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag=0U; + } + } + } + if (0U != rtnValue) + { /*жмlinkնڲLinkǷΪЧ*/ + for (l = 0U; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdնڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + + } + } + } + + }/*ѭмlink end*/ + } + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + + } + + } + + } + else/*߼仯*/ + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wOrgnAxleId) + { + /*ָ룬*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + } + else + { + + } + } + /*㵱ǰι*/ + /*һǰ16ϵļΣ*/ + + if(0U != rtnValue) + { + /* + Ӽα + */ + + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wOrgnAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + + /* Ӽαż*/ + + + /*****/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount=0U;/*ĿʼΪ0*/ + /*ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + + /*жϸεնlinkʼڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wTmnlLkId]; + /*ʼlinkʼڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if(2U == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId,PointCount,pLinkStru->wOrgnPointId)) + { + + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag=0U; + } + } + } + if (0U != rtnValue) + { + /*жмlinkʼڲlinkǷЧ*/ + for (l = 0U; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdʼڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if (2 == DetecteElementInArray(pTempAxleSgmtStru->wOrgnRelatPointId, PointCount, pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wOrgnRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + break; + + } + + } + } + } + + }/*ѭмlink end*/ + } + + if (0U == rtnValue) + { + break; + } + }/*ѭend*/ + + } + + } + + }/*else ߼仯 end*/ + + + /** + + ***/ + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE== stepFlag) || (0U == rtnValue)) + { + break; + } + }/*forѭend*/ + + if( i == dsuDataLenStru->wAxleSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0U; + rtnValue = 2U; + } + + } + + + + /*ʼwTmnlRelatPointId 150608*/ + stepFlag = EmapCalcFunStepCtrl(0x07); + if ((DQU_QFUN_TRUE== stepFlag) && (0U != rtnValue)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wAxleSgmtLen; i++) + { + /*Ϊ0*/ + AxleSgmtCount = 0U; + /*ǰεģյᣩwTmnlAxleIdεģʼᣩwOrgnAxleId + ˵ǰκй*/ + + + /*link߼仯㣺ǰյlinkյΪ߼仯㣬Ѱյ*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + i; + + + /*жնlinkյǷ߼仯*/ + pLinkStru=dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + if (LINK_DIRCHANGE_END == pLinkStru->wLogicDirChanged) + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + + /*ʱΣͬڵǰ*/ + if (j == i) + { + /*޲ѭ*/ + } + else + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wTmnlAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + /*ʱβǵǰε*/ + chTempCount=0U; + for (k = 0U ; k < pTempAxleSgmtStru->wRelatAxleSgmtNum; k++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wId ==pTempAxleSgmtStru->wRelatAxleSgmtId[k]) + { + chTempCount++; + break; + } + } + if (0U==chTempCount) + { + /*һκ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + } + + } + else + { + } + } + } + + + /*iiι*/ /*forѭ*/ + if(0U != rtnValue) + { + /* + յӼα + */ + + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /**** + յӼα + + ***/ + + /****յ******/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount=0U;/*Ϊ0*/ + /*ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + /*жϸεնlinkʼڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wTmnlLkId]; + /*նlinkʼڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if(2U == DetecteElementInArray(pTempAxleSgmtStru->wTmnlRelatPointId,PointCount,pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wTmnlRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag=0U; + } + } + } + + /*жмlinkʼڲlinkǷЧ*/ + for(l=0U;lwMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdʼڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wOrgnJointSideLkId) + { + /*ûб*/ + if(2U == DetecteElementInArray(pTempAxleSgmtStru->wTmnlRelatPointId,PointCount,pLinkStru->wOrgnPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wTmnlRelatPointId[PointCount] = pLinkStru->wOrgnPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag=0U; + break; + + } + + } + } + } + + } + } + + } + + } + } + else/*߼仯*/ + { + for (j = 0U; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + if ((dsuStaticHeadStru->pAxleSgmtStru + j)->wOrgnAxleId == pTempAxleSgmtStru->wTmnlAxleId) + { + /*һκ16ϵļΣ*/ + if (AXISSEC_NEXT_AXISSEC_MAX_NUM > AxleSgmtCount) + { + /*ָ룬*/ + pAxleSgmtStru[AxleSgmtCount] = dsuStaticHeadStru->pAxleSgmtStru + j; + AxleSgmtCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + } + } + else + { + + } + } + + /*iiι*/ /*forѭ*/ + if(0U != rtnValue) + { + /* + յӼα + */ + + for (k = 0U; k < AxleSgmtCount; k++) + { + pTempAxleSgmtStru->wTmnlAxleSgmtId[k] = pAxleSgmtStru[k]->wId; + } + /**** + յӼα + + ***/ + + /****յ******/ + + /*Ӽθʱй*/ + if (1U < AxleSgmtCount) + { + PointCount=0U;/*ĿʼΪ0*/ + /*ѭ*/ + for (n = 0U; n < AxleSgmtCount; n++) + { + /*жϸεʼlinkնڲlinkǷЧ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wOrgnLkId]; + /*ʼlinkնڲLinkΪЧ*/ + if ( 0xFFFF!=pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if(2U == DetecteElementInArray(pTempAxleSgmtStru->wTmnlRelatPointId,PointCount,pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wTmnlRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag=0U; + } + + } + } + if (0U != rtnValue) + { + /*жмlinkնڲlinkǷЧ*/ + for (l = 0U; l < MIDDLE_LINK_MAX_NUM; l++) + { + if (0xFFFF != pAxleSgmtStru[n]->wMiddleLinkId[l])/*мlink*/ + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pAxleSgmtStru[n]->wMiddleLinkId[l]]; + + /*wMiddleLinkIdʼڲLinkΪЧ*/ + if (0xFFFF != pLinkStru->wTmnlJointSideLkId) + { + /*ûб*/ + if (2U == DetecteElementInArray(pTempAxleSgmtStru->wTmnlRelatPointId, PointCount, pLinkStru->wTmnlPointId)) + { + if (AXIS_NEXT_AXIS_SWITCH_MAX_NUM > PointCount) + { + pTempAxleSgmtStru->wTmnlRelatPointId[PointCount] = pLinkStru->wTmnlPointId; + PointCount++; + } + else + { + rtnValue = 0U; + chFlag = 0U; + break; + } + + } + } + } + + } + } + if (0U == rtnValue) + { + break; + } + } + + } + + } + + }/*else end*/ + + + /**** յ******/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE== stepFlag) || (0U == rtnValue)) + { + break; + } + } + if( (i == dsuDataLenStru->wAxleSgmtLen)&&(0U != chFlag)) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0U; + rtnValue = 1U; + } + else + { + rtnValue = 0U; + } + } + return rtnValue; +} + + +/*ʽӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +UINT8 AxleSgmtStru() +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType)||(DQU_CBTC_CC == cbtcVersionType)||(DQU_CBTC_HLT == cbtcVersionType)|| (DQU_CBTC_CPK == cbtcVersionType)) + { + rtnValue = AxleSgmtStru_CC(); + } +#if 0 + else if (DQU_CBTC_CPK == cbtcVersionType ) + { + rtnValue = AxleSgmtStru_CPK(); + } + else if (DQU_CBTC_HLT == cbtcVersionType) + { + rtnValue = AxleSgmtStru_HLT(); + } + + else if (DQU_CBTC_DG == cbtcVersionType) + { + rtnValue = AxleSgmtStru_DG(); + } +#endif + else if (DQU_CBTC_CC == cbtcVersionType) + { + rtnValue = AxleSgmtStru_CC(); + } + else + { + rtnValue = 0U; + + } + return rtnValue; +} +#if 0 + +/************************************************************ +*ܣ߼ +*˵ +*ֵ0ʧܣ1ɹ +* UINT16 wMiddleLinkId; ߼мlink +UINT16 wMainOrgnLogicSgmtId; ǰ߼εı +UINT16 wMainTmnlLogicSgmtId; ں߼εı +************************************/ +static UINT8 LogicSgmtStru_FAO() +{ + UINT16 i=0U + UINT16 j=0U;/*ѭ*/ + UINT16 k=0U; + UINT16 LgcSgmtIdIndex = 0xFFFF; /*ѭ±*/ + DSU_LOGIC_SGMT_STRU * pTempLogicSgmtStru=NULL; /*ʱ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru=NULL; /*ʱ*/ + DQU_POINT_STATUS_STRU pointStatusStru[3]={0U}; /*״̬ṹ*/ + UINT16 linkId1=0U; + UINT16 linkId2=0U; /*μõʱ*/ + UINT8 funcCallResult = 0U; /*÷ֵ*/ + UINT8 rtnValue = 2U; + UINT8 stepFlag = 0U; + + /*ӵͼ*/ + UINT16 *dsuAxleSgmtIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuAxleSgmtIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuAxleSgmtIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + /** + wMiddleLinkId + **/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE== stepFlag) + { + for(i=g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;iwLogicSgmtLen;i++) + { + pTempLogicSgmtStru = dsuStaticHeadStru->pLogicSgmtStru + i; + + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + dsuAxleSgmtIndex[pTempLogicSgmtStru->wAxleSgmtId]; + + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if(pTempLogicSgmtStru->wOrgnLkId == pTempLogicSgmtStru->wTmnlLkId) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + /*ͬһlink*/ + for(j=0;jwRelatPointNum;j++) + { + pointStatusStru[j].PointId = pTempAxleSgmtStru->wRelatPointId[j]; + pointStatusStru[j].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[j]; + } + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,pTempLogicSgmtStru->wOrgnLkId, EMAP_SAME_DIR,(UCHAR)pTempAxleSgmtStru->wRelatPointNum ,pointStatusStru,&linkId1); + + /*ʧܣ˳*/ + if(funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if(pTempLogicSgmtStru->wTmnlLkId == linkId1) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId1, EMAP_SAME_DIR,(UCHAR)pTempAxleSgmtStru->wRelatPointNum ,pointStatusStru,&linkId2); + /*dsuGetAdjacentLinkIDִʧܣ˳*/ + if(funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + if(pTempLogicSgmtStru->wTmnlLkId == linkId2) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + /*γ3link,ܳ*/ + rtnValue = 0U; + return rtnValue; + } + } + } + + /* + wMainOrgnLogicSgmtId; ǰ߼εı + wMainTmnlLogicSgmtId; ں߼εı + */ + /*ΪЧ*/ + LgcSgmtIdIndex = 0xFFFF; + for(k=0;kwIncludeLogicSgmtNum;k++) + { + if(pTempLogicSgmtStru->wId == pTempAxleSgmtStru->wLogicSgmtId[k]) + { + LgcSgmtIdIndex=k; + } + } + + /*߼αڼûҵݳ*/ + if(LgcSgmtIdIndex == 0xFFFF) + { + rtnValue = 0U; + return rtnValue; + } + /*ֻһ߼ʱûǰ߼κͺ߼*/ + else if((LgcSgmtIdIndex == 0) && (LgcSgmtIdIndex == (pTempAxleSgmtStru->wIncludeLogicSgmtNum-1))) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = 0xFFFF; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = 0xFFFF; + } + /*ǰ߼δڼεĵһ߼ʱûǰ߼*/ + else if (LgcSgmtIdIndex == 0) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = 0xFFFF; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex+1]; + } + /*ǰ߼δڼεһ߼ʱûк߼*/ + else if(LgcSgmtIdIndex ==(pTempAxleSgmtStru->wIncludeLogicSgmtNum-1)) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex-1]; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = 0xFFFF; + } + /*ǰ߼δڼεм߼ʱ*/ + else + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex-1]; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex+1]; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + + } /*end forloop*/ + if(i == dsuDataLenStru->wLogicSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1; + } + } + + return rtnValue; +} + +static UINT8 LogicSgmtStru_CPK() +{ + UINT16 i=0U; + UINT16 j=0U; + UINT16 n=0U;/*ѭ*/ + UINT16 k=0U; + UINT16 LgcSgmtIdIndex = 0xFFFF; /*ѭ±*/ + DSU_LOGIC_SGMT_STRU * pTempLogicSgmtStru=NULL; /*ʱ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru=NULL; /*ʱ*/ + DQU_POINT_STATUS_STRU pointStatusStru[3]={0U}; /*״̬ṹ*/ + UINT16 linkId1=0U; + UINT16 linkId2=0U; + UINT16 linkId3=0U; /*μõʱ*/ + UINT8 funcCallResult = 0U; /*÷ֵ*/ + UINT8 rtnValue = 2U; + UINT8 stepFlag = 0U; + + /*ӵͼ*/ + UINT16 *dsuAxleSgmtIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuAxleSgmtIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuAxleSgmtIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + /** + wMiddleLinkId + **/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wLogicSgmtLen; i++) + { + pTempLogicSgmtStru = dsuStaticHeadStru->pLogicSgmtStru + i; + + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + dsuAxleSgmtIndex[pTempLogicSgmtStru->wAxleSgmtId]; + + /*150608 ʼмLinkΪ0xFFFF*/ + for (n = 0; n < MIDDLE_LINK_MAX_NUM; n++) + { + pTempLogicSgmtStru->wMiddleLinkId[n] = 0xFFFF; + } + + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if (pTempLogicSgmtStru->wOrgnLkId == pTempLogicSgmtStru->wTmnlLkId) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + /*ͬһlink*/ + for (j = 0; j < pTempAxleSgmtStru->wRelatPointNum; j++) + { + pointStatusStru[j].PointId = pTempAxleSgmtStru->wRelatPointId[j]; + pointStatusStru[j].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[j]; + } + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,pTempLogicSgmtStru->wOrgnLkId, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId1); + + /*ʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if (pTempLogicSgmtStru->wTmnlLkId == linkId1) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId1, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId2); + /*dsuGetAdjacentLinkIDִʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + if (pTempLogicSgmtStru->wTmnlLkId == linkId2) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId2, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId3); + /*dsuGetAdjacentLinkIDִʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + if (pTempLogicSgmtStru->wTmnlLkId == linkId3) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = linkId1; + pTempLogicSgmtStru->wMiddleLinkId[1] = linkId2; + } + else + { + /*߼γ4link,ܳ*/ + rtnValue = 0U; + return rtnValue; + } + } + } + } + + /* + wMainOrgnLogicSgmtId; ǰ߼εı + wMainTmnlLogicSgmtId; ں߼εı + */ + /*ΪЧ*/ + LgcSgmtIdIndex = 0xFFFF; + for (k = 0; k < pTempAxleSgmtStru->wIncludeLogicSgmtNum; k++) + { + if (pTempLogicSgmtStru->wId == pTempAxleSgmtStru->wLogicSgmtId[k]) + { + LgcSgmtIdIndex = k; + } + } + + /*߼αڼûҵݳ*/ + if (LgcSgmtIdIndex == 0xFFFF) + { + rtnValue = 0U; + return rtnValue; + } + /*ֻһ߼ʱûǰ߼κͺ߼*/ + else if ((LgcSgmtIdIndex == 0) && (LgcSgmtIdIndex == (pTempAxleSgmtStru->wIncludeLogicSgmtNum - 1))) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = 0xFFFF; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = 0xFFFF; + } + /*ǰ߼δڼεĵһ߼ʱûǰ߼*/ + else if (LgcSgmtIdIndex == 0) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = 0xFFFF; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex + 1]; + } + /*ǰ߼δڼεһ߼ʱûк߼*/ + else if (LgcSgmtIdIndex == (pTempAxleSgmtStru->wIncludeLogicSgmtNum - 1)) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex - 1]; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = 0xFFFF; + } + /*ǰ߼δڼεм߼ʱ*/ + else + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex - 1]; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex + 1]; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + + } /*end forloop*/ + if(i == dsuDataLenStru->wLogicSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1; + + } + } + + + return rtnValue; +} + +static UINT8 LogicSgmtStru_HLT() +{ + UINT16 i=0U; + UINT16 j=0U; + UINT16 n=0U;/*ѭ*/ + UINT16 k=0U; + UINT16 LgcSgmtIdIndex = 0xFFFF; /*ѭ±*/ + DSU_LOGIC_SGMT_STRU * pTempLogicSgmtStru=NULL; /*ʱ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru=NULL; /*ʱ*/ + DQU_POINT_STATUS_STRU pointStatusStru[3]={0U}; /*״̬ṹ*/ + UINT16 linkId1=0U; + UINT16 linkId2=0U; + UINT16 linkId3=0U; /*μõʱ*/ + UINT16 linkId4=0U; + UINT8 funcCallResult = 0U; /*÷ֵ*/ + UINT8 rtnValue = 2U; + UINT8 stepFlag = 0U; + /*ӵͼ*/ + UINT16 *dsuAxleSgmtIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuAxleSgmtIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuAxleSgmtIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + /** + wMiddleLinkId + **/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wLogicSgmtLen; i++) + { + pTempLogicSgmtStru = dsuStaticHeadStru->pLogicSgmtStru + i; + + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + dsuAxleSgmtIndex[pTempLogicSgmtStru->wAxleSgmtId]; + + /*150608 ʼмLinkΪ0xFFFF*/ + for (n = 0; n < MIDDLE_LINK_MAX_NUM; n++) + { + pTempLogicSgmtStru->wMiddleLinkId[n] = 0xFFFF; + } + + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if (pTempLogicSgmtStru->wOrgnLkId == pTempLogicSgmtStru->wTmnlLkId) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + /*ͬһlink*/ + for (j = 0; j < pTempAxleSgmtStru->wRelatPointNum; j++) + { + pointStatusStru[j].PointId = pTempAxleSgmtStru->wRelatPointId[j]; + pointStatusStru[j].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[j]; + } + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,pTempLogicSgmtStru->wOrgnLkId, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId1); + + /*ʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if (pTempLogicSgmtStru->wTmnlLkId == linkId1) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId1, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId2); + /*dsuGetAdjacentLinkIDִʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + if (pTempLogicSgmtStru->wTmnlLkId == linkId2) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId2, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId3); + /*dsuGetAdjacentLinkIDִʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + if (pTempLogicSgmtStru->wTmnlLkId == linkId3) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = linkId1; + pTempLogicSgmtStru->wMiddleLinkId[1] = linkId2; + } + else + { + /*ּ֧ΰĿΪ4 add by qxt 20160915*/ + /*linkId3ҲΪüεյLinkʱѰһLink*/ + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru,linkId3, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId4); + + /*ʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + if (pTempLogicSgmtStru->wTmnlLkId == linkId4) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = linkId1; + pTempLogicSgmtStru->wMiddleLinkId[1] = linkId2; + pTempLogicSgmtStru->wMiddleLinkId[2] = linkId3; + } + else + { + /*߼γ5link,ѯ֧*/ + rtnValue = 0U; + return rtnValue; + } + } + } + } + } + + /* + wMainOrgnLogicSgmtId; ǰ߼εı + wMainTmnlLogicSgmtId; ں߼εı + */ + /*ΪЧ*/ + LgcSgmtIdIndex = 0xFFFF; + for (k = 0; k < pTempAxleSgmtStru->wIncludeLogicSgmtNum; k++) + { + if (pTempLogicSgmtStru->wId == pTempAxleSgmtStru->wLogicSgmtId[k]) + { + LgcSgmtIdIndex = k; + } + } + + /*߼αڼûҵݳ*/ + if (LgcSgmtIdIndex == 0xFFFF) + { + rtnValue = 0U; + return rtnValue; + } + /*ֻһ߼ʱûǰ߼κͺ߼*/ + else if ((LgcSgmtIdIndex == 0) && (LgcSgmtIdIndex == (pTempAxleSgmtStru->wIncludeLogicSgmtNum - 1))) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = 0xFFFF; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = 0xFFFF; + } + /*ǰ߼δڼεĵһ߼ʱûǰ߼*/ + else if (LgcSgmtIdIndex == 0) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = 0xFFFF; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex + 1]; + } + /*ǰ߼δڼεһ߼ʱûк߼*/ + else if (LgcSgmtIdIndex == (pTempAxleSgmtStru->wIncludeLogicSgmtNum - 1)) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex - 1]; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = 0xFFFF; + } + /*ǰ߼δڼεм߼ʱ*/ + else + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex - 1]; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex + 1]; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + + } /*end forloop*/ + if(i == dsuDataLenStru->wLogicSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1; + + } + } + + + return rtnValue; +} + +#endif +/* +* ʹü߼ID +* ˵ void +* ֵ 0:ʧ +* 1:ɹ +* by qw.liu 2022-02-22 +*/ +static UINT8 LogicSgmtStru_CC(void) +{ + UINT16 ii = UINT16_MAX; /*ѭ*/ + UINT16 jj = UINT16_MAX; /*ѭ*/ + UINT16 nn = UINT16_MAX; /*ѭ*/ + UINT16 kk = UINT16_MAX; + DSU_LOGIC_SGMT_STRU * pTempLogicSgmtStru = NULL; /*ʱ*/ + DSU_AXLE_SGMT_STRU *pTempAxleSgmtStru = NULL; /*ʱ*/ + UINT16 wLogicId = 0U; + UINT8 rtnValue = 2U; + + /*ӵͼ*/ + UINT16 *dsuAxleSgmtIndex = NULL; + UINT16 *dsuLogicSgmtIndex = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + UINT8 hh = UINT8_MAX; + UINT8 mm = UINT8_MAX; + UINT8 pp = UINT8_MAX; + LOD_STRU LODAPointStru = { 0U }; + LOD_STRU LODBPointStru = { 0U }; + UINT16 wlinkNum = 0U; /*link*/ + UINT16 szLinkIdBuf[MAX_LOGSEC_INCLUDE_LINK_NUM] = { 0U }; /*link*/ + UINT8 cDir = EMAP_SAME_DIR; + UINT32 dwLen = UINT32_MAX; /*ʱ*/ + PATH_LINK_STRU linkInfo = { 0U }; /*ʱ*/ + LOGSEC_SWITCH_STRU swInfo = { 0U }; /*ʱ*/ + UINT8 funcRtn = 0U; + UINT8 stepFlag = 0U; + UINT8 keepWork = 0U; + UINT8 cLinkDirChangedNum = 0U; + + if (NULL != g_dsuEmapStru) + { + dsuAxleSgmtIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuAxleSgmtIndex; + dsuLogicSgmtIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuLogicSgmtIndex; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + if (0U != rtnValue) + { + /** + wMiddleLinkId + **/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE == stepFlag) + { + for (ii = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; ii < dsuDataLenStru->wLogicSgmtLen; ii++) + { + pTempLogicSgmtStru = dsuStaticHeadStru->pLogicSgmtStru + ii; + pTempLogicSgmtStru->chAxleSgmtSum = 0U; + } + + for (jj = 0U; jj < dsuDataLenStru->wAxleSgmtLen; jj++) + { + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + jj; + + if (MAX_ALEX_HAVE_LG_NUM > pTempAxleSgmtStru->wIncludeLogicSgmtNum) + { + for (kk = 0; kk < pTempAxleSgmtStru->wIncludeLogicSgmtNum; kk++) + { + wLogicId = pTempAxleSgmtStru->wLogicSgmtId[kk]; + pTempLogicSgmtStru = dsuStaticHeadStru->pLogicSgmtStru + dsuLogicSgmtIndex[wLogicId]; + /*modify 20220920 һ߼οܹ*/ + for (hh = 0u; hh < MAX_AXISSEC_SUM_IN_LOGSEC; hh++) + { + keepWork = 1U; + if ((0u != pTempLogicSgmtStru->wAxleSgmtId[hh]) + && (0xFFFF != pTempLogicSgmtStru->wAxleSgmtId[hh]) + && (pTempAxleSgmtStru->wId == pTempLogicSgmtStru->wAxleSgmtId[hh])) + { + /** ߼Ӹü*/ + keepWork = 0U; + } + else if((0u == pTempLogicSgmtStru->wAxleSgmtId[hh]) + || (0xFFFF == pTempLogicSgmtStru->wAxleSgmtId[hh])) + { + /** δ*/ + /** ĩβӸüΣ*/ + pTempLogicSgmtStru->wAxleSgmtId[hh] = pTempAxleSgmtStru->wId; + pTempLogicSgmtStru->chAxleSgmtSum = hh + 1; + keepWork = 0U; + } + else + { + /** δδҵλã*/ + } + + if (0u == keepWork) + { + break; + } + } + if (MAX_AXISSEC_SUM_IN_LOGSEC < pTempLogicSgmtStru->chAxleSgmtSum) + { + /*߼ιݴ*/ + rtnValue = 0U; + } + + } + } + else + { + /*ݴ*/ + rtnValue = 0U; + + } + + } + + for (ii = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; ii < dsuDataLenStru->wLogicSgmtLen; ii++) + { + pTempLogicSgmtStru = dsuStaticHeadStru->pLogicSgmtStru + ii; + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + dsuAxleSgmtIndex[pTempLogicSgmtStru->wAxleSgmtId[0]]; + pTempLogicSgmtStru->wRelatPhySecId = pTempAxleSgmtStru->wRelatePhysicalSgmtId; + + /*ʱ*/ + CommonMemSet(&LODAPointStru, sizeof(LOD_STRU), 0, sizeof(LOD_STRU)); + CommonMemSet(&LODBPointStru, sizeof(LOD_STRU), 0, sizeof(LOD_STRU)); + CommonMemSet(&linkInfo,sizeof(PATH_LINK_STRU),0,sizeof(PATH_LINK_STRU)); + + /* ߼ΰlink */ + if (pTempLogicSgmtStru->wOrgnLkId == pTempLogicSgmtStru->wTmnlLkId) + { + /*߼linkյlinkһ£һ,мLink*/ + linkInfo.cLinkCnt = 1u; + linkInfo.szLinkId[0u] = pTempLogicSgmtStru->wOrgnLkId; + pTempLogicSgmtStru->chSwitchNum = 0u; + pTempLogicSgmtStru->wMiddleLinkId[0u] = 0xFFFF; + } + else + { + LODAPointStru.Lnk = pTempLogicSgmtStru->wOrgnLkId; + LODAPointStru.Off = 0U; + LODAPointStru.Dir = EMAP_SAME_DIR; + LODBPointStru.Lnk = pTempLogicSgmtStru->wTmnlLkId; + LODBPointStru.Off = 0U; + LODBPointStru.Dir = EMAP_SAME_DIR; + dwLen = dsuLenByPointExp(g_dsuEmapStru, &LODAPointStru, &LODBPointStru, &wlinkNum, szLinkIdBuf, &cDir, &cLinkDirChangedNum); + + if ((UINT32_MAX != dwLen) && (MAX_LOGSEC_INCLUDE_LINK_NUM >= wlinkNum)) + { + linkInfo.cLinkCnt = wlinkNum; + + for (mm = 0U; mm < wlinkNum; mm++) + { + linkInfo.szLinkId[mm] = szLinkIdBuf[mm]; + } + /*߼linkյlinkһ£мlinkУסβLink*/ + if (wlinkNum < MIDDLE_LINK_MAX_NUM + 2) + { + for (pp = 0U; (pp + 2) < wlinkNum; pp++) + { + pTempLogicSgmtStru->wMiddleLinkId[pp] = szLinkIdBuf[pp + 1]; + } + } + else + { + /*ݴ*/ + funcRtn = 0U; + } + } + else + { + /*ݴ*/ + funcRtn = 0U; + } + + /**ͨ߼εlinkϢϢ*/ + funcRtn = dsuSwitInfoBtwLinkBaseLinkSeq(pTempLogicSgmtStru->wOrgnLkId, pTempLogicSgmtStru->wTmnlLkId, EMAP_SAME_DIR, &linkInfo, &swInfo); + if (1U == funcRtn) + { + if (MAX_LOGSEC_INCLUDE_SWITCH_NUM >= swInfo.SwitchNum) + { + pTempLogicSgmtStru->chSwitchNum = swInfo.SwitchNum; + for (hh = 0U; hh < swInfo.SwitchNum; hh++) + { + pTempLogicSgmtStru->wSwitchId[hh] = swInfo.SwitchId[hh]; + pTempLogicSgmtStru->chSwitchPosition[hh] = swInfo.SwitchPosition[hh]; + } + } + else + { + /*ݴ*/ + funcRtn = 0U; + } + } + else + { + /*ݴ*/ + funcRtn = 0U; + } + + if (0U == funcRtn) + { + rtnValue = 0U; + break; + } + } + + } /*end forloop*/ +#if 0 + for (ii = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; ii < dsuDataLenStru->wLogicSgmtLen; ii++) + { + pTempLogicSgmtStru = dsuStaticHeadStru->pLogicSgmtStru + ii; + + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + dsuAxleSgmtIndex[pTempLogicSgmtStru->wAxleSgmtId]; + + /*150608 ʼмLinkΪ0xFFFF*/ + for (nn = 0U; nn < MIDDLE_LINK_MAX_NUM; nn++) + { + pTempLogicSgmtStru->wMiddleLinkId[nn] = 0xFFFF; + } + + /*ʼlinkĩlinkΪͬһlinkwMiddleLinkIdΪ0xFFFF*/ + if (pTempLogicSgmtStru->wOrgnLkId == pTempLogicSgmtStru->wTmnlLkId) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + /*ͬһlink*/ + for (jj = 0U; jj < pTempAxleSgmtStru->wRelatPointNum; jj++) + { + pointStatusStru[jj].PointId = pTempAxleSgmtStru->wRelatPointId[jj]; + pointStatusStru[jj].PointStatus = (UCHAR)pTempAxleSgmtStru->wRelatPointStatus[jj]; + } + + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, pTempLogicSgmtStru->wOrgnLkId, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId1); + + /*ʧܣ˳*/ + if (funcCallResult != 1U) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + } + + if (0U == rtnValue) + { + /*ִ*/ + }else + { + /*ʼlinkĩlinkڣwMiddleLinkIdΪ0xFFFF*/ + if (pTempLogicSgmtStru->wTmnlLkId == linkId1) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = 0xFFFF; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId1, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId2); + /*dsuGetAdjacentLinkIDִʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + } + + if (0U == rtnValue) + { + /*ִ*/ + }else + { + if (pTempLogicSgmtStru->wTmnlLkId == linkId2) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = linkId1; + } + else + { + funcCallResult = dsuGetAdjacentLinkIDExp(g_dsuEmapStru, linkId2, EMAP_SAME_DIR, (UCHAR)pTempAxleSgmtStru->wRelatPointNum, pointStatusStru, &linkId3); + /*dsuGetAdjacentLinkIDִʧܣ˳*/ + if (funcCallResult != 1) + { + rtnValue = 0U; + } + else + { + /*ִ*/ + } + + if (0U == rtnValue) + { + } + else + { + if (pTempLogicSgmtStru->wTmnlLkId == linkId3) + { + pTempLogicSgmtStru->wMiddleLinkId[0] = linkId1; + pTempLogicSgmtStru->wMiddleLinkId[1] = linkId2; + } + else + { + /*߼γ4link,ܳ*/ + rtnValue = 0U; + } + } + } + } + } + } + } + + if (0U == rtnValue) + { + /**/ + } + else + { + /* + wMainOrgnLogicSgmtId; ǰ߼εı + wMainTmnlLogicSgmtId; ں߼εı + */ + /*ΪЧ*/ + LgcSgmtIdIndex = 0xFFFF; + for (kk = 0; kk < pTempAxleSgmtStru->wIncludeLogicSgmtNum; kk++) + { + if (pTempLogicSgmtStru->wId == pTempAxleSgmtStru->wLogicSgmtId[kk]) + { + LgcSgmtIdIndex = kk; + } + } + } + + if (0U == rtnValue) + { + } + else + { + /*߼αڼûҵݳ*/ + if (LgcSgmtIdIndex == 0xFFFF) + { + rtnValue = 0U; + } + /*ֻһ߼ʱûǰ߼κͺ߼*/ + else if ((LgcSgmtIdIndex == 0) && (LgcSgmtIdIndex == (pTempAxleSgmtStru->wIncludeLogicSgmtNum - 1))) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = 0xFFFF; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = 0xFFFF; + } + /*ǰ߼δڼεĵһ߼ʱûǰ߼*/ + else if (LgcSgmtIdIndex == 0) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = 0xFFFF; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex + 1]; + } + /*ǰ߼δڼεһ߼ʱûк߼*/ + else if (LgcSgmtIdIndex == (pTempAxleSgmtStru->wIncludeLogicSgmtNum - 1)) + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex - 1]; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = 0xFFFF; + } + /*ǰ߼δڼεм߼ʱ*/ + else + { + pTempLogicSgmtStru->wMainOrgnLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex - 1]; + pTempLogicSgmtStru->wMainTmnlLogicSgmtId = pTempAxleSgmtStru->wLogicSgmtId[LgcSgmtIdIndex + 1]; + } + } + if (0U == rtnValue) + { + /**/ + } + else + { + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(ii); + if (DQU_QFUN_TRUE == stepFlag) + { + rtnValue = 2; + + } + } + + if ((0U == rtnValue) || (2U == rtnValue)) + { + break; + } + + } /*end forloop*/ + +#endif + if (ii == dsuDataLenStru->wLogicSgmtLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0; + rtnValue = 1U; + + } + } + } + + return rtnValue; +} +/*ʽӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +UINT8 LogicSgmtStru() +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); +#if 0 + if (DQU_CBTC_FAO == cbtcVersionType) + { + rtnValue = LogicSgmtStru_FAO(); + + } + else if (DQU_CBTC_CPK == cbtcVersionType ) + { + rtnValue = LogicSgmtStru_CPK(); + + } + else if ((DQU_CBTC_HLT == cbtcVersionType)||(DQU_CBTC_DG == cbtcVersionType)) + { + rtnValue = LogicSgmtStru_HLT(); + } + else if (DQU_CBTC_CC == cbtcVersionType) + { + rtnValue = LogicSgmtStru_CC(); + + } + else + { + rtnValue = 0U; + } +#endif + rtnValue = LogicSgmtStru_CC(); + + return rtnValue; +} + +/********************************************* +*ܣ·ݽṹ +*˵ +*ֵ0ʧܣ1ɹ +UINT16 wIncludeAxleSgmtNum; ·ļĿ +UINT16 wIncludeAxleSgmtId[8]; ļα +UINT16 wAxleSgmtLockStatus[8]; ļ״̬ + +UINT16 wObsNum; ·ϰĿ +UINT16 wObsType[8]; ϰ +UINT16 wObsID[8]; ϰID +UINT16 wObsNeedLockStatus[8]; ϰҪ״̬ +עڲúϿ⡢෿ʹ +*********************************************/ +static UINT8 RouteStru_DFT() +{ + UINT16 i, j ,k; /*ѭ*/ + DSU_ROUTE_STRU* pRouteStru=NULL; /*ʱ*/ + UINT8 funcRtr = 0; /*÷ֵ*/ + DQU_POINT_STATUS_STRU PointStatus[16]; + UINT16 linkIndex = 0; /*link±*/ /*±*/ + UINT16 Dirction; /*·ΪźŻʱ*/ + UINT8 rtnValue = 2U; + UINT8 stepFlag = 0U; + LOD_STRU StartPoint, EndPoint; + UINT16 includeLinkId[50]; + + /*ӵͼ*/ + UINT16 *dsuSignalIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != g_dsuEmapStru)&&(NULL !=g_dsuEmapStru->dsuEmapIndexStru)) + { + dsuSignalIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + /************ + ӽΰϢ + ***********/ + stepFlag = EmapCalcFunStepCtrl(0x02); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wRouteLen; i++) + { + pRouteStru = dsuStaticHeadStru->pRouteStru + i; + Dirction = (dsuStaticHeadStru->pSignalStru + dsuSignalIndex[pRouteStru->wStartSignalId])->wProtectDir; /*20141114޸ģwEndSignalId޸ΪwStarSignalId*/ + + + /*CBTCӽ>5ݳ˳,ԺϿݽṹV16.0.0FAOHLTҲӽαӡ5by my 20170220*/ + if (pRouteStru->wCBTCAccessLinkNum>5) + { + rtnValue = 0U; + return rtnValue; + } + /*CBTCӽΪ0С5*/ + else if (pRouteStru->wCBTCAccessLinkNum >0) + { + for (k=0;kwCBTCAccessLinkNum;k++) + { + /**/ + funcRtr = GetPointInfoFromAccessLink(pRouteStru->wCBTCAccessLinkId[k], Dirction, &(pRouteStru->wCBTCAccessLinkRelatePointNum[k]), pRouteStru->wCBTCAccessLinkRelatePointId[k], pRouteStru->wCBTCAccessLinkRelatePointSta[k]); + /*ʧ*/ + if (0U == funcRtr) + { + rtnValue = 0U; + return rtnValue; + } + } + + } + /*CBTCӽΪ0*/ + else + { + /*ʲô*/ + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + + } + if(i == dsuDataLenStru->wRouteLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 2; + } + + } + /************** + ӽΰϢ + **************/ + + + /********* + linkм + **********/ + stepFlag = EmapCalcFunStepCtrl(0x03); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wRouteLen; i++) + { + + pRouteStru = dsuStaticHeadStru->pRouteStru + i; + StartPoint.Lnk = pRouteStru->wOrgnLkId; + StartPoint.Off = 0; + StartPoint.Dir = EMAP_SAME_DIR; + EndPoint.Lnk = pRouteStru->wTmnlLkId; + EndPoint.Off = 0; + EndPoint.Dir = EMAP_SAME_DIR; + + + for (j = 0; j < 16; j++) + { + PointStatus[j].PointId = pRouteStru->wPointId[j]; + PointStatus[j].PointStatus = (UCHAR)pRouteStru->wPointStatus[j]; + } + + + if (EndPoint.Lnk == StartPoint.Lnk) + { + pRouteStru->wIncludeLinkNum = 1; + pRouteStru->wLinkId[0] = pRouteStru->wOrgnLkId; + + Dirction = (dsuStaticHeadStru->pSignalStru + dsuSignalIndex[pRouteStru->wStartSignalId])->wProtectDir; /*20141114ӣֱӶȡʼźŻΪ·*/ + pRouteStru->wDir = Dirction; + + } + else + { + /*ʱֱӼlink*/ + funcRtr=dsuGetLinkBtwLocExp(g_dsuEmapStru,&StartPoint, &EndPoint,16, PointStatus,&pRouteStru->wLinkId[1], &linkIndex); + if (1U==funcRtr) + { + pRouteStru->wLinkId[0] = pRouteStru->wOrgnLkId; + pRouteStru->wLinkId[linkIndex + 1] = pRouteStru->wTmnlLkId; + pRouteStru->wIncludeLinkNum = linkIndex + 2; + pRouteStru->wDir = EMAP_SAME_DIR; + } + else + { + /*ʱ轫linkе*/ + funcRtr=dsuGetLinkBtwLocExp(g_dsuEmapStru,&EndPoint, &StartPoint,16,PointStatus,includeLinkId, &linkIndex); + if (1U==funcRtr) + { + pRouteStru->wLinkId[0] = pRouteStru->wOrgnLkId; + for (j = 0; j < linkIndex; j++) + { + pRouteStru->wLinkId[j + 1] = includeLinkId[linkIndex - j - 1]; + } + pRouteStru->wLinkId[linkIndex + 1] = pRouteStru->wTmnlLkId; + pRouteStru->wIncludeLinkNum = linkIndex + 2; + pRouteStru->wDir = EMAP_CONVER_DIR; + } + else + { + /*ó*/ + rtnValue = 0U; + return rtnValue; + } + + } + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + + } + if(i == dsuDataLenStru->wRouteLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 2; + } + + } + /********** + linkмȼ + *********/ + + /****** + С״̬ + ********/ + stepFlag = EmapCalcFunStepCtrl(0x04); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wRouteLen; i++) + { + pRouteStru = dsuStaticHeadStru->pRouteStru + i; + + funcRtr = GetAxleSemtIdFromLinkId(pRouteStru->wLinkId, pRouteStru->wIncludeLinkNum, pRouteStru->wIncludeAxleSgmtId, &pRouteStru->wIncludeAxleSgmtNum); + if (1U!=funcRtr) + { + /*ʧܣ˳*/ + rtnValue = 0U; + return rtnValue; + } + else + { + /*ִ*/ + } + + /*״̬ȫΪ*/ + for (j = 0; j < pRouteStru->wIncludeAxleSgmtNum; j++) + { + pRouteStru->wAxleSgmtLockStatus[j] = DSU_STATUS_AC_OCCUPIED; + } + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + } + if( i == dsuDataLenStru->wRouteLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 2; + } + } + /****** + С״̬ + ********/ + + /****** + ϰ͡ID״̬ + ********/ + stepFlag = EmapCalcFunStepCtrl(0x05); + if (DQU_QFUN_TRUE== stepFlag) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wRouteLen; i++) + { + pRouteStru = dsuStaticHeadStru->pRouteStru + i; + GetObstacleFromRoute(pRouteStru); + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + } + if( i == dsuDataLenStru->wRouteLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1; + } + } + /****** + ϰ͡ID״̬ + ********/ + + + return rtnValue; +} + + +/********************************************* +*ܣ·ݽṹ +*˵ +*ֵ0ʧܣ1ɹ +UINT16 wIncludeAxleSgmtNum; ·ļĿ +UINT16 wIncludeAxleSgmtId[8]; ļα +UINT16 wAxleSgmtLockStatus[8]; ļ״̬ + +UINT16 wObsNum; ·ϰĿ +UINT16 wObsType[8]; ϰ +UINT16 wObsID[8]; ϰID +UINT16 wObsNeedLockStatus[8]; ϰҪ״̬ +עڲúͨʹ +޸ļ¼: +1½·ΧCBTCӽεķΧж ʹúֵϢֹ,޸淶 m by sds 2020-8-21 +*********************************************/ +static UINT8 RouteStru_CC() +{ + UINT16 i=0U; + UINT16 j=0U; + UINT16 k=0U; /*ѭ*/ + DSU_ROUTE_STRU* pRouteStru = NULL; /*ʱ*/ + UINT8 funcRtr = 0U; /*÷ֵ*/ + DQU_POINT_STATUS_STRU PointStatus[16]={0U}; + UINT16 linkIndex = 0U; /*link±*/ /*±*/ + UINT16 Dirction=0U; /*·ΪźŻʱ*/ + UINT8 rtnValue = 2U; + UINT8 stepFlag = 0U; + LOD_STRU StartPointSameDir={0U}; + LOD_STRU StartPointConvertDir={0U}; + LOD_STRU EndPoint={0U}; + + UINT16 *dsuSignalIndex = NULL; + /*ӵͼ*/ + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + if ((NULL != g_dsuEmapStru) && (NULL != g_dsuEmapStru->dsuEmapIndexStru)) + { + dsuSignalIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuSignalIndex; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + if (0U != rtnValue) + { + /************ + ӽΰϢ + ***********/ + if (DQU_QFUN_TRUE == EmapCalcFunStepCtrl(0x02)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wRouteLen; i++) + { + pRouteStru = dsuStaticHeadStru->pRouteStru + i; + Dirction = (dsuStaticHeadStru->pSignalStru + dsuSignalIndex[pRouteStru->wStartSignalId])->wProtectDir; /*20141114޸ģwEndSignalId޸ΪwStarSignalId*/ + + + /*CBTCӽ>MAX_CBTC_ACCESS_LINK_NUMݳ˳*/ + if (MAX_CBTC_ACCESS_LINK_NUM < pRouteStru->wCBTCAccessLinkNum) + { + rtnValue = 0U; + } + /*CBTCӽΪ0С10*/ + else if (0 < pRouteStru->wCBTCAccessLinkNum) + { + for (k = 0; k < pRouteStru->wCBTCAccessLinkNum; k++) + { + /**/ + funcRtr = GetPointInfoFromAccessLink(pRouteStru->wCBTCAccessLinkId[k], Dirction, &(pRouteStru->wCBTCAccessLinkRelatePointNum[k]), pRouteStru->wCBTCAccessLinkRelatePointId[k], pRouteStru->wCBTCAccessLinkRelatePointSta[k]); + /*ʧ*/ + if (0U == funcRtr) + { + rtnValue = 0U; + } + } + + } + + /*CBTCӽΪ0*/ + else + { + /*ʲô*/ + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE == stepFlag)||(0U==rtnValue)) + { + break; + } + else + { + ; /*ִʧ*/ + } + + } + if (i == dsuDataLenStru->wRouteLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0; + rtnValue = 2; + } + + } + /************** + ӽΰϢ + **************/ + } + else + { + ; /*ִʧ*/ + } + + if (0U != rtnValue) + { + /********* + linkм + **********/ + if (DQU_QFUN_TRUE == EmapCalcFunStepCtrl(0x03)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wRouteLen; i++) + { + + pRouteStru = dsuStaticHeadStru->pRouteStru + i; + StartPointSameDir.Lnk = pRouteStru->wOrgnLkId; + StartPointSameDir.Off = 0; + StartPointSameDir.Dir = EMAP_SAME_DIR; + + StartPointConvertDir.Lnk = pRouteStru->wOrgnLkId; + StartPointConvertDir.Off = 0; + StartPointConvertDir.Dir = EMAP_CONVER_DIR; + EndPoint.Lnk = pRouteStru->wTmnlLkId; + EndPoint.Off = 0; + EndPoint.Dir = EMAP_SAME_DIR; + + + for (j = 0; j < 16; j++) + { + PointStatus[j].PointId = pRouteStru->wPointId[j]; + PointStatus[j].PointStatus = (UCHAR)pRouteStru->wPointStatus[j]; + } + + + if (EndPoint.Lnk == StartPointSameDir.Lnk) + { + pRouteStru->wIncludeLinkNum = 1; + pRouteStru->wLinkId[0] = pRouteStru->wOrgnLkId; + + Dirction = (dsuStaticHeadStru->pSignalStru + dsuSignalIndex[pRouteStru->wStartSignalId])->wProtectDir; /*20141114ӣֱӶȡʼźŻΪ·*/ + pRouteStru->wDir = Dirction; + + } + + /**/ + else if (dsuGetLinkBtwLocExp(g_dsuEmapStru, &StartPointSameDir, &EndPoint, + 16, PointStatus, + &pRouteStru->wLinkId[1], &linkIndex)) + { + pRouteStru->wLinkId[0] = pRouteStru->wOrgnLkId; + pRouteStru->wLinkId[linkIndex + 1] = pRouteStru->wTmnlLkId; + pRouteStru->wIncludeLinkNum = linkIndex + 2; + pRouteStru->wDir = EMAP_SAME_DIR; + } + /*ķ*/ + else if (dsuGetLinkBtwLocExp(g_dsuEmapStru, &StartPointConvertDir, &EndPoint, + 16, PointStatus, + &pRouteStru->wLinkId[1], &linkIndex)) + { + pRouteStru->wLinkId[0] = pRouteStru->wOrgnLkId; + pRouteStru->wLinkId[linkIndex + 1] = pRouteStru->wTmnlLkId; + pRouteStru->wIncludeLinkNum = linkIndex + 2; + pRouteStru->wDir = EMAP_CONVER_DIR; + } + + + else + { + /*ó*/ + rtnValue = 0U; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if ((DQU_QFUN_TRUE == stepFlag)||(0U==rtnValue)) + { + break; + } + + } + if (i == dsuDataLenStru->wRouteLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0; + rtnValue = 2; + } + + } + /********** + linkмȼ + *********/ + } + else + { + ; /*ִʧ*/ + } + + if (0U != rtnValue) + { + /****** + С״̬ + ********/ + if (DQU_QFUN_TRUE == EmapCalcFunStepCtrl(0x04)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wRouteLen; i++) + { + pRouteStru = dsuStaticHeadStru->pRouteStru + i; + + funcRtr = GetAxleSemtIdFromLinkId(pRouteStru->wLinkId, pRouteStru->wIncludeLinkNum, pRouteStru->wIncludeAxleSgmtId, &pRouteStru->wIncludeAxleSgmtNum); + if (funcRtr != 1) + { + /*ʧܣ˳*/ + rtnValue = 0U; + } + else + { + /*ִ*/ + } + + if (0U != rtnValue) + { + /*״̬ȫΪ*/ + for (j = 0; j < pRouteStru->wIncludeAxleSgmtNum; j++) + { + pRouteStru->wAxleSgmtLockStatus[j] = DSU_STATUS_AC_OCCUPIED; + } + } + else + { + ; /*ִʧ*/ + } + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if((DQU_QFUN_TRUE == stepFlag)||(0U==rtnValue)) + { + break; + } + } + if (i == dsuDataLenStru->wRouteLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0; + rtnValue = 2; + } + } + /****** + С״̬ + ********/ + } + else + { + ; /*ִʧ*/ + } + + if (0U != rtnValue) + { + /****** + ϰ͡ID״̬ + ********/ + if (DQU_QFUN_TRUE == EmapCalcFunStepCtrl(0x05)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wRouteLen; i++) + { + pRouteStru = dsuStaticHeadStru->pRouteStru + i; + GetObstacleFromRoute(pRouteStru); + + /*ѭзּ⴦*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE ==stepFlag) + { + rtnValue = 2; + break; + } + } + if (i == dsuDataLenStru->wRouteLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0; + rtnValue = 1; + } + } + /****** + ϰ͡ID״̬ + ********/ + } + else + { + ; /*ִʧ*/ + } + + return rtnValue; +} +/********************************************* +*ܣ·ݽṹ +*˵ +*ֵ0ʧܣ1ɹ +UINT16 wIncludeAxleSgmtNum; ·ļĿ +UINT16 wIncludeAxleSgmtId[8]; ļα +UINT16 wAxleSgmtLockStatus[8]; ļ״̬ + +UINT16 wObsNum; ·ϰĿ +UINT16 wObsType[8]; ϰ +UINT16 wObsID[8]; ϰID +UINT16 wObsNeedLockStatus[8]; ϰҪ״̬ + +עͨ߼仯㣬·link㷨Ľֱս·linkͷ + change by qxt,20171012 +*********************************************/ +UINT8 RouteStru() +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType)||(DQU_CBTC_CPK == cbtcVersionType )||(DQU_CBTC_DG == cbtcVersionType) ) + { + rtnValue = RouteStru_DFT(); + } + else if (DQU_CBTC_HLT == cbtcVersionType) + { + rtnValue = RouteStru_CC(); + /*rtnValue = RouteStru_HLT();*/ + } + else if (DQU_CBTC_CC == cbtcVersionType) + { + rtnValue = RouteStru_CC(); + } + else + { + rtnValue = 0U; + + } + return rtnValue; +} + +/********************************************* +*ܣɱ +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ProtectLink() +{ + UINT16 i, j, k; + UINT8 stepFlag = 0U; + DSU_PROTECT_LINK_STRU * pPretectLinkStru=NULL; + DSU_AXLE_SGMT_STRU * pAxleSgmtStru=NULL; + DSU_ROUTE_STRU * pRouteStru=NULL; + UINT8 rtnValue = 2U; + + /*ӵͼ*/ + UINT16 *dsuAxleSgmtIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuAxleSgmtIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuAxleSgmtIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + /*********** + · + ********/ + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x02)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wProtectLinkLen; i++) + { + pPretectLinkStru = dsuStaticHeadStru->pProtectLinkStru + i; + /*ΪЧֵ*/ + pPretectLinkStru->wRouteId = 0xFFFF; + for (j = 0; j < dsuDataLenStru->wRouteLen; j++) + { + pRouteStru = dsuStaticHeadStru->pRouteStru + j; + for (k = 0; k < pRouteStru->wProtectLinkNum; k++) + { + if (pRouteStru->wProtectLinkId[k] == pPretectLinkStru->wId) + { + pPretectLinkStru->wRouteId = pRouteStru->wId; + } + else + { + /*ʲô*/ + } + } + } + if (pPretectLinkStru->wRouteId == 0xFFFF) + { + /*ֵЧ˵ûҵӦĽ·,ʧ*/ + rtnValue = 0U; + return rtnValue; + } + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE==stepFlag) + { + rtnValue=2U; + break; + } + + } + if(i == dsuDataLenStru->wProtectLinkLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 2; + } + + } + /*********** + ·ż + ********/ + + + /*********** + ϰֻǵ + ********/ + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x03)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wProtectLinkLen; i++) + { + pPretectLinkStru = dsuStaticHeadStru->pProtectLinkStru + i; + pPretectLinkStru->wObsNum = 0; + for (j = 0; j < pPretectLinkStru->wIncludeAxleSgmtNum; j++) + { + /*ȡй*/ + pAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + dsuAxleSgmtIndex[pPretectLinkStru->wIncludeAxleSgmtId[j]]; + pPretectLinkStru->wObsNum += pAxleSgmtStru->wRelatPointNum; + } + /*Ϊ0*/ + if (pPretectLinkStru->wObsNum == 0) + { + /**/ + pPretectLinkStru->wObsType = 0xFFFF; + } + /*С4*/ + else if (pPretectLinkStru->wObsNum <= 4) + { + /*ϰΪ*/ + pPretectLinkStru->wObsType = OBSPOINT; + } + else + { + /*Ϊ4ϣݴ*/ + rtnValue = 0U; + return rtnValue; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE==stepFlag) + { + rtnValue=2U; + break; + } + + } + if(i == dsuDataLenStru->wProtectLinkLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1; + } + } + + /***** + ϰϢ + ****/ + return rtnValue; +} + + +/********************************************* +*ܣ¶ +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 Grade() +{ + UINT16 i, j; + UINT8 stepFlag = 0U; + DSU_GRADE_STRU * pGradeStru=NULL; /*㵱ǰ¶Ϣṹָ*/ + DSU_LINK_STRU* pLinkStur=NULL; /*linkϢṹָʱ*/ + UINT8 rtnValue = 2U; + + /*ӵͼ*/ + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuLinkIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + /*¶мlink*/ + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x02)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wGradeLen; i++) + { + pGradeStru = dsuStaticHeadStru->pGradeStru + i; + /*ʼlinkΪǰlink*/ + pLinkStur = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pGradeStru->wOrgnLinkId]; + /*ʼlink ĩlinkغ */ + for (j = 0; j < GRADE_INCLUDE_LINK_NUM; j++) + { + if ((pLinkStur->wTmnlJointMainLkId == pGradeStru->wTmnlLinkId) + || (pLinkStur->wId == pGradeStru->wTmnlLinkId)) + { + break; + } + else + { + /*ƶlink*/ + pLinkStur = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pLinkStur->wTmnlJointMainLkId]; + pGradeStru->wIncludeLinkId[j] = pLinkStur->wId; + } + /*ǰlinkΪնlink,˳*/ + if (pLinkStur->wTmnlJointMainLkId == pGradeStru->wTmnlLinkId) + { + break; + } + else + { + /*ѭ*/ + } + } + /*link10*/ + if (j >= GRADE_INCLUDE_LINK_NUM) + { + rtnValue = 0U; + return rtnValue; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE== stepFlag) + { + rtnValue=2; + break; + } + + } + if(i == dsuDataLenStru->wGradeLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 2; + } + + } + + /*¶ȳ*/ + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x03)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wGradeLen; i++) + { + pGradeStru = dsuStaticHeadStru->pGradeStru + i; + if (pGradeStru->dwOrgnLinkOfst == 0) + { + /*¶ȳȳʼΪ0*/ + pGradeStru->dwGradeLength = 0; + } + else + { + /*¶ȳȳʼΪ1*/ + pGradeStru->dwGradeLength = 1; + } + + if (pGradeStru->wOrgnLinkId == pGradeStru->wTmnlLinkId) + { + /*¶ȳ += link - ƫ*/ + pGradeStru->dwGradeLength += (pGradeStru->dwTmnlLinkOfst - pGradeStru->dwOrgnLinkOfst); + } + else + { + /*ʼlinkΪǰlink*/ + pLinkStur = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pGradeStru->wOrgnLinkId]; + /*ʼ¶ȳ = link - ƫ*/ + pGradeStru->dwGradeLength = pLinkStur->dwLength - pGradeStru->dwOrgnLinkOfst; + for (j = 0; j < GRADE_INCLUDE_LINK_NUM; j++) + { + + /*linkյlink*/ + if (pLinkStur->wTmnlJointMainLkId != pGradeStru->wTmnlLinkId) + { + /*ҵlink*/ + pGradeStru->wIncludeLinkId[j] = pLinkStur->wTmnlJointMainLkId; + /*ƶڵһlink*/ + pLinkStur = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pGradeStru->wIncludeLinkId[j]]; + /*¶ȳӸlink*/ + pGradeStru->dwGradeLength += pLinkStur->dwLength; + } + else + { + /*¶ȳĩ˵ƫ*/ + pGradeStru->dwGradeLength += pGradeStru->dwTmnlLinkOfst; + break; + } + } + + if (j >= GRADE_INCLUDE_LINK_NUM) + { + /*мlink10,*/ + rtnValue = 0U; + return rtnValue; + } + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE==stepFlag) + { + rtnValue=2; + break; + } + } + if(i == dsuDataLenStru->wGradeLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1; + } + } + + return rtnValue; +} + +/********************************************* +*ܣĬгб +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 DefaultRouteStru() +{ + UINT16 i, j; + UINT8 stepFlag = 0U; + DSU_STOPPOINT_STRU* pStopPointStru=NULL; + DSU_DEFAULTROUTE_STRU* pDefaultRouteStru=NULL; + UINT8 rtnValue = 2U; + + /*ӵͼ*/ + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL != g_dsuEmapStru) + { + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x02)) + { + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wDefaultRoutLen; i++) + { + pDefaultRouteStru = dsuStaticHeadStru->pDefaultRoutStru + i; + /*վ̨־Ϊ0*/ + pDefaultRouteStru->wCurrentPlatformFlag = 0; + for (j = 0; j < dsuDataLenStru->wStopPointLen; j++) + { + pStopPointStru = dsuStaticHeadStru->pStopPointStru + j; + /*ǰlinkId,ͣlinkId,һ£ͣΪվ̨Ӫͣ*/ + if ((pStopPointStru->wLinkId == pDefaultRouteStru->wLinkId) + && (pStopPointStru->wDir == pDefaultRouteStru->wLinkDir) + && ((EMAP_OPERAT_STOP_POINT & pStopPointStru->wAttribute) == EMAP_OPERAT_STOP_POINT)) + { + /*վ̨IDΪͣվ̨IDվ̨־Ϊ1*/ + pDefaultRouteStru->wCurrentPlatformId = pStopPointStru->wStationID; + pDefaultRouteStru->wCurrentPlatformFlag = 1; + } + else + { + /*ʲô*/ + } + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE==stepFlag) + { + rtnValue=2; + break; + } + } + if(i == dsuDataLenStru->wDefaultRoutLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1; + } + } + + return rtnValue; +} + +/********************************************* +*ܣݽ·linkУϰϢ +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GetObstacleFromRoute(DSU_ROUTE_STRU* pRouteStru) +{ + UINT16 i, j; + DSU_SCREEN_STRU* pScreenStru=NULL; /*ϰʱ*/ + DSU_EMERG_STOP_STRU* pEmergStopStru=NULL; /*ϰͣťʱ*/ + DSU_POINT_STRU* pPointStru=NULL; /*ϰʱ*/ + UINT8 rtnValue = 0U; + + /*ӵͼ*/ + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if (NULL == pRouteStru) + { + rtnValue = 0U; + } + else + { + if (NULL != g_dsuEmapStru) + { + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + return rtnValue; + } + + /*·ϰʼΪ0*/ + pRouteStru->wObsNum = 0; + + /*ϰźŻĸϢ*/ + pRouteStru->wObsID[pRouteStru->wObsNum] = pRouteStru->wStartSignalId; + pRouteStru->wObsType[pRouteStru->wObsNum] = OBSSIGNAL; + pRouteStru->wObsNeedLockStatus[pRouteStru->wObsNum] = DSU_STATUS_SIGNAL_PASS; + pRouteStru->wObsNum++; + + for (i = 0; i < pRouteStru->wIncludeLinkNum; i++) + { + /*ϰŵĸϢ*/ + for (j = 0; j < dsuDataLenStru->wScreenLen; j++) + { + pScreenStru = dsuStaticHeadStru->pScreenStru + j; + if (pScreenStru->wRelatLkId == pRouteStru->wLinkId[i]) + { + /*ϰIDͣ״̬*/ + pRouteStru->wObsID[pRouteStru->wObsNum] = pScreenStru->wId; + pRouteStru->wObsType[pRouteStru->wObsNum] = OBSSCREEN; + pRouteStru->wObsNeedLockStatus[pRouteStru->wObsNum] = DSU_STATUS_PSD_CLOSE; + pRouteStru->wObsNum++; + } + else + { + /*ʲô*/ + } + } + + /*ϰͣťĸϢ*/ + for (j = 0; j < dsuDataLenStru->wEmergStopLen; j++) + { + pEmergStopStru = dsuStaticHeadStru->pEmergStopStru + j; + if (pEmergStopStru->wRelatLkId == pRouteStru->wLinkId[i]) + { + /*ϰIDͣ״̬*/ + pRouteStru->wObsID[pRouteStru->wObsNum] = pEmergStopStru->wId; + pRouteStru->wObsType[pRouteStru->wObsNum] = OBSEMERAGESTOP; + pRouteStru->wObsNeedLockStatus[pRouteStru->wObsNum] = DSU_STATUS_ESP_UNACTIVITE; + pRouteStru->wObsNum++; + } + else + { + /*ʲô*/ + } + } + + /*ϰĸϢ*/ + for (j = 0; j < dsuDataLenStru->wPointLen; j++) + { + pPointStru = dsuStaticHeadStru->pPointStru + j; + if (pPointStru->wMainLkId == pRouteStru->wLinkId[i]) + { + /*ϰIDͣ״̬*/ + pRouteStru->wObsID[pRouteStru->wObsNum] = pPointStru->wId; + pRouteStru->wObsType[pRouteStru->wObsNum] = OBSPOINT; + pRouteStru->wObsNeedLockStatus[pRouteStru->wObsNum] = EMAP_POINT_STATUS_MAIN; + pRouteStru->wObsNum++; + } + else if (pPointStru->wSideLkId == pRouteStru->wLinkId[i]) + { + /*ϰIDͣ״̬*/ + pRouteStru->wObsID[pRouteStru->wObsNum] = pPointStru->wId; + pRouteStru->wObsType[pRouteStru->wObsNum] = OBSPOINT; + pRouteStru->wObsNeedLockStatus[pRouteStru->wObsNum] = EMAP_POINT_STATUS_SIDE; + pRouteStru->wObsNum++; + } + else + { + /*ʲô*/ + } + } + } + rtnValue = 1; + } + return rtnValue; +} + +/********************************************* +*ܣݽӽIDȡӽΰĵ״̬ +*˵ +AccessLinkId ӽID +RelatePointNum +RelatePointId[] ID +RelatePointSta[] ״̬ +*ֵ 0 ʧܣ1ɹ +*********************************************/ +UINT8 GetPointInfoFromAccessLink(UINT16 AccessLinkId, UINT16 Dirction, UINT16* RelatePointNum, UINT16 RelatePointId[], UINT16 RelatePointSta[]) +{ + DSU_CBTC_ACCESS_LINK_STRU* pCBTCAccessLinkStru=NULL; /*ʱ*/ + UINT16 i, j = 0; /*ѭ*/ + DSU_LOGIC_SGMT_STRU* pLogicSgmtStru=NULL; /*ʱ*/ + DSU_AXLE_SGMT_STRU* pAxleSgmtStru=NULL; /*ʱ--*/ + UINT8 rtnValue = 0U; + + /*ӵͼ*/ + UINT16 *dsuAxleSgmtIndex=NULL; + UINT16 *dsuCBTCAccessLinkIndex=NULL; + UINT16 *dsuLogicSgmtIndex=NULL; + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != RelatePointNum) + && (NULL != RelatePointId) && (NULL != RelatePointSta) + && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuAxleSgmtIndex=dsuEmapIndexStru->dsuAxleSgmtIndex; + dsuCBTCAccessLinkIndex=dsuEmapIndexStru->dsuCBTCAccessLinkIndex; + dsuLogicSgmtIndex=dsuEmapIndexStru->dsuLogicSgmtIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ӵͼָΪջָ*/ + rtnValue = 0U; + return rtnValue; + } + + + *RelatePointNum = 0; + + if ((AccessLinkId > dsuEmapIndexStru->CBTCACCESSLINKINDEXNUM) || (dsuCBTCAccessLinkIndex[AccessLinkId] == 0xFFFF)) + { + rtnValue = 0U; + return rtnValue; + } + pCBTCAccessLinkStru = dsuStaticHeadStru->pCBTCAccessLinkStru + dsuCBTCAccessLinkIndex[AccessLinkId]; + + /*߼ǰ˳еģ*/ + for (i = 0; i < pCBTCAccessLinkStru->wIncludeLogicSgmtNum; i++) + { + /*赱ǰ߼Ϊеii*/ + pLogicSgmtStru = dsuStaticHeadStru->pLogicSgmtStru + dsuLogicSgmtIndex[pCBTCAccessLinkStru->wIncludeLogicSgmtId[i]]; + /*ʼlinkͬĩlinkһ£һе*/ + if ((pLogicSgmtStru->wOrgnLkId) != (pLogicSgmtStru->wTmnlLkId)) + { + /*Ϣ*/ + for (j = 0; j < pLogicSgmtStru->chSwitchNum; j++) + { + if (*RelatePointNum >= ROUTE_ACCESS_LINK_POINT_NUM) + { + /*ӽΰROUTE_ACCESS_LINK_POINT_NUMݴ˳*/ + rtnValue = 0U; + return rtnValue; + } + RelatePointId[*RelatePointNum] = pLogicSgmtStru->wSwitchId[j]; + RelatePointSta[*RelatePointNum] = pLogicSgmtStru->chSwitchPosition[j]; + *RelatePointNum += 1; + } + } + else + { + /*ʼlinkյlinkͬһûе޲ִ*/ + } + } + + rtnValue = 1; + return rtnValue; +} + +/********************************************* +ܣlinkлüα +linkId ׵ַLinkNum link +AxleSgmtId αַ +AxleSgmtNum 鳤 +ֵ0ʧܣ1ɹ +**********************************************/ + +UINT8 GetAxleSemtIdFromLinkId(UINT16* linkId, UINT16 LinkNum, UINT16 *AxleSgmtId, UINT16 * AxleSgmtNum) +{ + UINT16 i=0U; + UINT16 j=0U; + UINT16 k=0U; + DSU_AXLE_SGMT_STRU * pAxleSgmt=NULL; + DSU_LINK_STRU * pLink=NULL; + UINT16 AxleCount = 0U; + UINT8 rtnValue = 0U; + + /*ӵͼ*/ + UINT16 *dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != linkId) && (NULL != AxleSgmtId) + && (NULL != AxleSgmtNum) && (NULL != g_dsuEmapStru)) + { + dsuLinkIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪջָ*/ + rtnValue = 0U; + return rtnValue; + } + + /*ȳʼΪ0*/ + for (i = 0; i < LinkNum; i++) + { + pLink = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[linkId[i]]; + + for (j = 0; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + pAxleSgmt = dsuStaticHeadStru->pAxleSgmtStru + j; + /*ǰlinkΪ ڼαܹҵ*/ + if ((pLink->wOrgnPointType == EMAP_AXLE_DOT) + && (pAxleSgmt->wOrgnAxleId == pLink->wOrgnPointId)&&(pAxleSgmt->wOrgnLkId == pLink->wId)) + { + /*ǰlinkն˵Ϊ*/ + if (EMAP_AXLE_DOT==pLink->wTmnlPointType) + { + /*¼ü +1*/ + AxleSgmtId[AxleCount] = pAxleSgmt->wId; + AxleCount++; + + } + /*ǰlinkն˵Ϊ*/ + else if ( EMAP_POINT_DOT== pLink->wTmnlPointType) + { + for (k = 0; k < LinkNum; k++) + { + /*նlinklinkУ¼*/ + if (pAxleSgmt->wTmnlLkId == linkId[k]) + { + /*¼ü +1*/ + AxleSgmtId[AxleCount] = pAxleSgmt->wId; + AxleCount++; + } + else + { + /*ʲô*/ + } + } + } + else/*ǰlinkն˵Ϊͣʹ·յ㣬Ҳ·յҲǵ*/ + { + rtnValue = 0U; + return rtnValue; + } + + } + else + { + } + } + } + + + + /*θΪ0ߴ8,ʧ*/ + if ((0U == AxleCount) || (AxleCount > MAX_AXLESGMT_NUM_IN_ROUTE)) + { + rtnValue = 0U; + return rtnValue; + } + else + { + /*¼*/ + *AxleSgmtNum = AxleCount; + rtnValue = 1; + return rtnValue; + } +} + +/********************************************* +*ܣͣϢ +* +* +* +*˵ +*ֵ0ʧܣ1ɹ +*޸ļ¼ +*1תݹССͣվʱʵϢתŻ淶ͽṹ m by sds 2020-12-3 +*********************************************/ +UINT8 CalculateStopPoint(void) +{ + UINT16 i = 0; + UINT16 j = 0; + UINT8 stepFlag = 0U; + UINT16 linkInAxleIndex = 0; + DSU_STOPPOINT_STRU * pCurrentStopPointStru = NULL; + DSU_LINK_STRU * pTempLinkStru = NULL; + DSU_LINK_STRU *pLinkStru = NULL; + DSU_PROTECT_LINK_STRU * pTempProtectLinkStru = NULL; + DSU_AXLE_SGMT_STRU * pTempAxleSgmtStru = NULL; + UINT8 rtnValue = 2U; + + /*ӵͼ*/ + UINT16 *dsuLinkIndex = NULL; + UINT16 *dsuStationIndex = NULL; + UINT16 *dsuAxleSgmtIndex = NULL; + UINT16 *dsuProtectLinkIndex = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + + /*ָ*/ + if(NULL != g_dsuEmapStru) + { + dsuLinkIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStationIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuStationIndex; + dsuAxleSgmtIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuAxleSgmtIndex; + dsuProtectLinkIndex = g_dsuEmapStru->dsuEmapIndexStru->dsuProtectLinkIndex; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + + if(DQU_QFUN_TRUE == EmapCalcFunStepCtrl(0x02)) + { + /*ͣwMinStopTimewMaxStopTimewStopTime,dwOverLapLength*/ + for(i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;i wStopPointLen ;i++) + { + /*ݽת*/ + pCurrentStopPointStru = dsuStaticHeadStru->pStopPointStru + i; + + /*վ̨ЧͣʱΪ0*/ + if(DSU_NULL_16 == pCurrentStopPointStru->wStationID) + { + /**/ + pCurrentStopPointStru->wStopTime = 0; + pCurrentStopPointStru->wMaxStopTime = 0; + pCurrentStopPointStru->wMinStopTime = 0; + } + else + { + /*ͣʱŵͣվ̨Уֱȡ*/ + pCurrentStopPointStru->wStopTime = (dsuStaticHeadStru->pStationStru + dsuStationIndex[pCurrentStopPointStru->wStationID])->wParkTime; + pCurrentStopPointStru->wMaxStopTime = (dsuStaticHeadStru->pStationStru + dsuStationIndex[pCurrentStopPointStru->wStationID])->wMaxParkTime; + pCurrentStopPointStru->wMinStopTime = (dsuStaticHeadStru->pStationStru + dsuStationIndex[pCurrentStopPointStru->wStationID])->wMinParkTime; + } + + + /*overLapIdΣ㳤*/ + pTempLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pCurrentStopPointStru->wLinkId]; + if(EMAP_CONVER_DIR == pCurrentStopPointStru->wDir) + { + pCurrentStopPointStru->dwOverLapLength = pCurrentStopPointStru->dwLinkOfst; + } + else + { + pCurrentStopPointStru->dwOverLapLength = pTempLinkStru->dwLength - pCurrentStopPointStru->dwLinkOfst; + } + /*ȡñ*/ + if(DSU_NULL_16 == pCurrentStopPointStru->wOverLapId) + { + /*ЧγҲΪЧ*/ + pCurrentStopPointStru->dwOverLapLength = DSU_NULL_32; + } + else + { + pTempProtectLinkStru = dsuStaticHeadStru->pProtectLinkStru + dsuProtectLinkIndex[pCurrentStopPointStru->wOverLapId]; + + /*overLapId = ΰlink֮*/ + for(j = 0;j < pTempProtectLinkStru->wIncludeAxleSgmtNum;j++) + { + /*ȡñаļ*/ + pTempAxleSgmtStru = dsuStaticHeadStru->pAxleSgmtStru + dsuAxleSgmtIndex[pTempProtectLinkStru->wIncludeAxleSgmtId[j]]; + + /*ֻ1link*/ + if(pTempAxleSgmtStru->wOrgnLkId == pTempAxleSgmtStru->wTmnlLkId) + { + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]; + pCurrentStopPointStru->dwOverLapLength += pLinkStru->dwLength; + } + /*Nlink,overLapId = ΰlink֮*/ + else + { + /*ڵ1link*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wOrgnLkId]; + pCurrentStopPointStru->dwOverLapLength += pLinkStru->dwLength; + + /*мlinkϢ,*/ + for(linkInAxleIndex = 0;linkInAxleIndex < MIDDLE_LINK_MAX_NUM;linkInAxleIndex++) + { + /*linkIDϢЧ*/ + if(DSU_NULL_16 != pTempAxleSgmtStru->wMiddleLinkId[linkInAxleIndex]) + { + /*׷ӸlinkϢij*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wMiddleLinkId[linkInAxleIndex]]; + pCurrentStopPointStru->dwOverLapLength += pLinkStru->dwLength; + } + else + { + /*linkIDЧ,ѭ*/ + break; + } + } + + /*1link*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pTempAxleSgmtStru->wTmnlLkId]; + pCurrentStopPointStru->dwOverLapLength += pLinkStru->dwLength; + } + } + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(i); + if (DQU_QFUN_TRUE==stepFlag) + { + rtnValue = 2; + break; + } + else + { + /*nothing to do*/ + } + } + + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = (i==dsuDataLenStru->wStopPointLen) ? (0) : (g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop); + rtnValue = (i==dsuDataLenStru->wStopPointLen) ? (1) : (rtnValue); + } + else + { + /*nothing to do*/ + } + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + return rtnValue; +} + +/********************************Ϊݳʼӿ*********************************/ + +/********************************************** +ܣʼ[ռλ]:ֻռλݱһ +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ: 1 ɹ +޸ļ¼add by sds 2019-10-22 +**********************************************/ +UINT8 initNop(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + return 1; +} + +/********************************************** +ܣʼ[link]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initLink(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 funcFlag = 0U; + UINT8 checkFlag = 0U; + DSU_LINK_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_LINK_STRU stru={0U}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != g_dsuEmapStru) && (NULL != pDataAddr)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪջָ*/ + rtnValue = 0U; + } + funcFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + dsuDataLenStru->wLinkLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + funcFlag = LINK_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != funcFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->LINKINDEXNUM = stru.wId; + } + else + { + /*ʼ쳣*/ + rtnValue = 0U; + } + } + } + + funcFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuLinkIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->LINKINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuLinkIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuLinkIndex, 0xFF, dsuEmapIndexStru->LINKINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pLinkStru = (DSU_LINK_STRU *)MyNew(sizeof(DSU_LINK_STRU) * dsuDataLenStru->wLinkLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pLinkStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pLinkStru, 0xFF, sizeof(DSU_LINK_STRU) * dsuDataLenStru->wLinkLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_LINK_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wLinkLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_LINK_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->LINKINDEXNUM >= wDataIndexLen))||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + funcFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wLinkLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pLinkStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + funcFlag = LINK_STRU_init(pData, pCurrentStru); + if (0U == funcFlag) { + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuLinkIndex[pCurrentStru->wId] = j; + funcFlag = EmapInitLoopStepLenCtrl(j); + /*ѭֲи*/ + } + if ((0U == rtnValue) || (DQU_QFUN_TRUE==funcFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wLinkLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPoint(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + DSU_POINT_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_POINT_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + UINT8 funcFlag = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָ׵ַΪ*/ + rtnValue = 0U; + } + funcFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + dsuDataLenStru->wPointLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + funcFlag = POINT_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0 != funcFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->POINTINDEXNUM = stru.wId; + } + else + { + /*intiָ*/ + rtnValue = 0U; + } + } + } + + funcFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuPointIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->POINTINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuPointIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuPointIndex, 0xFF, dsuEmapIndexStru->POINTINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pPointStru = (DSU_POINT_STRU *)MyNew(sizeof(DSU_POINT_STRU) * dsuDataLenStru->wPointLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pPointStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pPointStru, 0xFF, sizeof(DSU_POINT_STRU) * dsuDataLenStru->wPointLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag =dquGetEmapDataStruArrayLen(EMAP_POINT_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wPointLen >= wStruDataLen)) + ||((0U == wStruDataLen)) || (0U == checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_POINT_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->POINTINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + } + } + } + + funcFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wPointLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pPointStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + funcFlag = POINT_STRU_init(pData, pCurrentStru); + if (0U == funcFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuPointIndex[pCurrentStru->wId] = j; + funcFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE == funcFlag)) + { + break; + } + } + + if ((0U != rtnValue) &&( j==dsuDataLenStru->wPointLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[źŻ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSignal(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + DSU_SIGNAL_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_SIGNAL_STRU stru={0U}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + UINT8 funcFlag = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָ׵ַΪ*/ + rtnValue = 0U; + } + + funcFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + dsuDataLenStru->wSignalLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + funcFlag = SIGNAL_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (1U == funcFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->SIGNALINDEXNUM = stru.wId; + } + else { + /*initָ*/ + rtnValue = 0U; + } + } + } + + funcFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuSignalIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->SIGNALINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuSignalIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuSignalIndex, 0xFF, dsuEmapIndexStru->SIGNALINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pSignalStru = (DSU_SIGNAL_STRU *)MyNew(sizeof(DSU_SIGNAL_STRU) * dsuDataLenStru->wSignalLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pSignalStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pSignalStru, 0xFF, sizeof(DSU_SIGNAL_STRU) * dsuDataLenStru->wSignalLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_SIGNAL_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wSignalLen >= wStruDataLen)) + ||((0U == wStruDataLen))||0U==checkFlag) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataIndexArrayLen(EMAP_SIGNAL_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->SIGNALINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + } + } + } + + funcFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == funcFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wSignalLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pSignalStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + funcFlag = SIGNAL_STRU_init(pData, pCurrentStru); + if (0U == funcFlag) + { + /*initָ*/ + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuSignalIndex[pCurrentStru->wId] = j; + funcFlag = EmapInitLoopStepLenCtrl(j); + } + + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==funcFlag)) + { + break; + } + } + + if ((0U != rtnValue) &&(j==dsuDataLenStru->wSignalLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Ӧ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initBalise(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + DSU_BALISE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_BALISE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + UINT8 initFlag = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָ׵ַΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wBaliseLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = BALISE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if(0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->BALISEINDEXNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuBaliseIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->BALISEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuBaliseIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuBaliseIndex, 0xFF, dsuEmapIndexStru->BALISEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pBaliseStru = (DSU_BALISE_STRU *)MyNew(sizeof(DSU_BALISE_STRU) * dsuDataLenStru->wBaliseLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pBaliseStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pBaliseStru, 0xFF, sizeof(DSU_BALISE_STRU) * dsuDataLenStru->wBaliseLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag =dquGetEmapDataStruArrayLen(EMAP_BALISE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wBaliseLen >= wStruDataLen))||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_BALISE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->BALISEINDEXNUM >= wDataIndexLen))||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wBaliseLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pBaliseStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = BALISE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuBaliseIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wBaliseLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAxle(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_AXLE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_AXLE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָ׵ַΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wAxlecounterLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = AXLE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->AXLEINDEXNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuAxleIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->AXLEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuAxleIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuAxleIndex, 0xFF, dsuEmapIndexStru->AXLEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pAxleStru = (DSU_AXLE_STRU *)MyNew(sizeof(DSU_AXLE_STRU) * dsuDataLenStru->wAxlecounterLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pAxleStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pAxleStru, 0xFF, sizeof(DSU_AXLE_STRU) * dsuDataLenStru->wAxlecounterLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag =dquGetEmapDataStruArrayLen(EMAP_AXLE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wAxlecounterLen >= wStruDataLen)) + ||((0U == wStruDataLen)) || (0U == checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_AXLE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->AXLEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wAxlecounterLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pAxleStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = AXLE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuAxleIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if (j==dsuDataLenStru->wAxlecounterLen) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initScreen(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_SCREEN_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_SCREEN_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wScreenLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = SCREEN_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + + /*ΪID + 1*/ + dsuEmapIndexStru->SCREENINDEXNUM = stru.wId; + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuScreenIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->SCREENINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuScreenIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuScreenIndex, 0xFF, dsuEmapIndexStru->SCREENINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pScreenStru = (DSU_SCREEN_STRU *)MyNew(sizeof(DSU_SCREEN_STRU) * dsuDataLenStru->wScreenLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pScreenStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pScreenStru, 0xFF, sizeof(DSU_SCREEN_STRU) * dsuDataLenStru->wScreenLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_SCREEN_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wScreenLen >= wStruDataLen)) + ||((0U == wStruDataLen)) || (0U == checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_SCREEN_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->SCREENINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wScreenLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pScreenStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = SCREEN_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuScreenIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wScreenLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ͣť]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initEmergStop(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_EMERG_STOP_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_EMERG_STOP_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wEmergStopLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = EMERG_STOP_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->EMERGSTOPINDEXNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuEmergStopIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->EMERGSTOPINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuEmergStopIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuEmergStopIndex, 0xFF, dsuEmapIndexStru->EMERGSTOPINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pEmergStopStru = (DSU_EMERG_STOP_STRU *)MyNew(sizeof(DSU_EMERG_STOP_STRU) * dsuDataLenStru->wEmergStopLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pEmergStopStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pEmergStopStru, 0xFF, sizeof(DSU_EMERG_STOP_STRU) * dsuDataLenStru->wEmergStopLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_EMERG_STOP_BUTTON_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wEmergStopLen >= wStruDataLen)) + ||((0U == wStruDataLen)) || (0U == checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_EMERG_STOP_BUTTON_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->EMERGSTOPINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wEmergStopLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pEmergStopStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = EMERG_STOP_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuEmergStopIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wEmergStopLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ͣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStation(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_STATION_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_STATION_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wStationLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = STATION_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->STATIONINDEXNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuStationIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->STATIONINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuStationIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuStationIndex, 0xFF, dsuEmapIndexStru->STATIONINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pStationStru = (DSU_STATION_STRU *)MyNew(sizeof(DSU_STATION_STRU) * dsuDataLenStru->wStationLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pStationStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pStationStru, 0xFF, sizeof(DSU_STATION_STRU) * dsuDataLenStru->wStationLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_STATION_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wStationLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_STATION_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->STATIONINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wStationLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pStationStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = STATION_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuStationIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wStationLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ͣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +޸ļ¼ +1ʵֹߵȳظñʵʺϢ m by sds 2020-5-21 +**********************************************/ +UINT8 initStopPoint(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 ftnValue = 0U; + UINT8 checkFlag = 0U; + DSU_STOPPOINT_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_STOPPOINT_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + static UINT32 realLoadRowLen = 0; /*ʵʼص*/ + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + ftnValue = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE ==ftnValue)) + { + dsuDataLenStru->wStopPointLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize / rowCount; + + /*鳤ȼ㣬0ΪúڵĹ=TRUE*/ + ftnValue = STOPPOINT_STRU_init(pDataAddr + dataSize - rowDataLen, &stru, &realLoadRowLen ,0); + if (0U != ftnValue) + { + /*˲Ϊ˼IDҲrealLoadRowLen++ʱ++ᵼʵԼ*/ + realLoadRowLen = (1 <= realLoadRowLen) ? (realLoadRowLen - 1) : (realLoadRowLen); + + /*ΪID + 1*/ + dsuEmapIndexStru->STOPPOINTINDEXNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + + } + } + + ftnValue = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE ==ftnValue)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuStopPointIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->STOPPOINTINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuStopPointIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuStopPointIndex, 0xFF, dsuEmapIndexStru->STOPPOINTINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pStopPointStru = (DSU_STOPPOINT_STRU *)MyNew(sizeof(DSU_STOPPOINT_STRU) * dsuDataLenStru->wStopPointLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pStopPointStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pStopPointStru, 0xFF, sizeof(DSU_STOPPOINT_STRU) * dsuDataLenStru->wStopPointLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ΪĬֵʱжݷΧЧԣڵ3׶ι˺ж*/ + if (0x0 == g_FilterStopPointAttr) + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag =dquGetEmapDataStruArrayLen(EMAP_STOPPOINT_ID, &wStruDataLen); + + + if (((0U != wStruDataLen) && (dsuDataLenStru->wStopPointLen >= wStruDataLen)) + || (0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_STOPPOINT_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->STOPPOINTINDEXNUM >= wDataIndexLen))||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + } + + ftnValue = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == ftnValue)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wStopPointLen; j++) + { + /*ҪԣûδпܵԽ磬ҪÿνʱŲ߼*/ + if (0x0 != g_FilterStopPointAttr) + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_STOPPOINT_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (realLoadRowLen >= wStruDataLen)) + || (0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + break; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_STOPPOINT_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->STOPPOINTINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + break; + } + } + } + + pCurrentStru = dsuStaticHeadStru->pStopPointStru + realLoadRowLen; + + pData = pDataAddr + rowDataLen*j; + + /*ݽṹ*/ + ftnValue = STOPPOINT_STRU_init(pData, pCurrentStru,&realLoadRowLen,g_FilterStopPointAttr); + + /*ɹ*/ + if (1U == ftnValue) + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuStopPointIndex[pCurrentStru->wId] = (1 <= realLoadRowLen) ? (realLoadRowLen - 1) : (realLoadRowLen); + } + else if (0U == ftnValue ) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*do nothing*/ + } + ftnValue = EmapInitLoopStepLenCtrl(j); + /*ѭֲи*/ + if ((0U== rtnValue) || (DQU_QFUN_TRUE==ftnValue)) + { + break; + } + else + { + /*do nothing*/ + } + } + + /*ȷݶ*/ + if ((0U!= rtnValue) && (j == dsuDataLenStru->wStopPointLen)) + { + /*ʵʼصָڵ洢ֶ*/ + dsuDataLenStru->wStopPointLen = realLoadRowLen; + + /*ʵֹߵȳظñʵʺϢ*/ + realLoadRowLen = 0; + + rtnValue = 1; + + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAxleSgmt(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_AXLE_SGMT_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_AXLE_SGMT_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE ==initFlag)) + { + dsuDataLenStru->wAxleSgmtLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = AXLE_SGMT_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->AXLESGMTINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuAxleSgmtIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->AXLESGMTINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuAxleSgmtIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuAxleSgmtIndex, 0xFF, dsuEmapIndexStru->AXLESGMTINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pAxleSgmtStru = (DSU_AXLE_SGMT_STRU *)MyNew(sizeof(DSU_AXLE_SGMT_STRU) * dsuDataLenStru->wAxleSgmtLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pAxleSgmtStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pAxleSgmtStru, 0xFF, sizeof(DSU_AXLE_SGMT_STRU) * dsuDataLenStru->wAxleSgmtLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_AXLE_SGMT_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wAxleSgmtLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_AXLE_SGMT_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->AXLESGMTINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wAxleSgmtLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pAxleSgmtStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = AXLE_SGMT_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuAxleSgmtIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) &&( j==dsuDataLenStru->wAxleSgmtLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[߼]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initLogicSgmt(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_LOGIC_SGMT_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_LOGIC_SGMT_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wLogicSgmtLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = LOGIC_SGMT_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->LOGICSGMTINDEXNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuLogicSgmtIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->LOGICSGMTINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuLogicSgmtIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuLogicSgmtIndex, 0xFF, dsuEmapIndexStru->LOGICSGMTINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pLogicSgmtStru = (DSU_LOGIC_SGMT_STRU *)MyNew(sizeof(DSU_LOGIC_SGMT_STRU) * dsuDataLenStru->wLogicSgmtLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pLogicSgmtStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pLogicSgmtStru, 0xFF, sizeof(DSU_LOGIC_SGMT_STRU) * dsuDataLenStru->wLogicSgmtLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_LOGIC_SGMT_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wLogicSgmtLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_LOGIC_SGMT_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->LOGICSGMTINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wLogicSgmtLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pLogicSgmtStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = LOGIC_SGMT_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + rtnValue = 0U;/*initָ*/ + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuLogicSgmtIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wLogicSgmtLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[·]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initRoute(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + DSU_ROUTE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_ROUTE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + UINT8 chRouteInitCheck = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + chRouteInitCheck = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == chRouteInitCheck)) + { + dsuDataLenStru->wRouteLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + chRouteInitCheck = ROUTE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U == chRouteInitCheck) + { + rtnValue = 0U; + } + else + { + /*ΪID + 1*/ + dsuEmapIndexStru->ROUTEINDEXNUM = stru.wId; + } + } + } + + chRouteInitCheck = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == chRouteInitCheck)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuRouteIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->ROUTEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuRouteIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuRouteIndex, 0xFF, dsuEmapIndexStru->ROUTEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pRouteStru = (DSU_ROUTE_STRU *)MyNew(sizeof(DSU_ROUTE_STRU) * dsuDataLenStru->wRouteLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pRouteStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pRouteStru, 0xFF, sizeof(DSU_ROUTE_STRU) * dsuDataLenStru->wRouteLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_ROUTE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wRouteLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_ROUTE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->ROUTEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + chRouteInitCheck = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == chRouteInitCheck)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wRouteLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pRouteStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + chRouteInitCheck = ROUTE_STRU_init(pData, pCurrentStru); + if (0U == chRouteInitCheck) + { + rtnValue = 0U; + break; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuRouteIndex[pCurrentStru->wId] = j; + chRouteInitCheck = EmapInitLoopStepLenCtrl(j); + /*ѭֲи*/ + if (DQU_QFUN_TRUE == chRouteInitCheck) + { + break; + } + } + + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wRouteLen)) + { + rtnValue=1U; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initProtectLink(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_PROTECT_LINK_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_PROTECT_LINK_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wProtectLinkLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = PROTECT_LINK_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->PROTECTLINKINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuProtectLinkIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->PROTECTLINKINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuProtectLinkIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuProtectLinkIndex, 0xFF, dsuEmapIndexStru->PROTECTLINKINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pProtectLinkStru = (DSU_PROTECT_LINK_STRU *)MyNew(sizeof(DSU_PROTECT_LINK_STRU) * dsuDataLenStru->wProtectLinkLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pProtectLinkStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pProtectLinkStru, 0xFF, sizeof(DSU_PROTECT_LINK_STRU) * dsuDataLenStru->wProtectLinkLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_PROTECT_LINK_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wProtectLinkLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_PROTECT_LINK_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->PROTECTLINKINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wProtectLinkLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pProtectLinkStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = PROTECT_LINK_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuProtectLinkIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wProtectLinkLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ʽӽ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initBLOCAccessLink(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + DSU_BLOC_ACCESS_LINK_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_BLOC_ACCESS_LINK_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + UINT8 initFlag = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wBLOCAccessLinkLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = BLOC_ACCESS_LINK_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->BLOCACCESSLINKINDEXNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuBLOCAccessLinkIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->BLOCACCESSLINKINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuBLOCAccessLinkIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuBLOCAccessLinkIndex, 0xFF, dsuEmapIndexStru->BLOCACCESSLINKINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pBLOCAccessLinkStru = (DSU_BLOC_ACCESS_LINK_STRU *)MyNew(sizeof(DSU_BLOC_ACCESS_LINK_STRU) * dsuDataLenStru->wBLOCAccessLinkLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pBLOCAccessLinkStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pBLOCAccessLinkStru, 0xFF, sizeof(DSU_BLOC_ACCESS_LINK_STRU) * dsuDataLenStru->wBLOCAccessLinkLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_BLOC_ACCESS_LINK_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wBLOCAccessLinkLen >= wStruDataLen))||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_BLOC_ACCESS_LINK_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->BLOCACCESSLINKINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wBLOCAccessLinkLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pBLOCAccessLinkStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = BLOC_ACCESS_LINK_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuBLOCAccessLinkIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U!=rtnValue) && (j==dsuDataLenStru->wBLOCAccessLinkLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[CBTCӽ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCBTCAccessLink(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + DSU_CBTC_ACCESS_LINK_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_CBTC_ACCESS_LINK_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + UINT8 initFlag = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wCBTCAccessLinkLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = CBTC_ACCESS_LINK_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->CBTCACCESSLINKINDEXNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuCBTCAccessLinkIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->CBTCACCESSLINKINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuCBTCAccessLinkIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuCBTCAccessLinkIndex, 0xFF, dsuEmapIndexStru->CBTCACCESSLINKINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pCBTCAccessLinkStru = (DSU_CBTC_ACCESS_LINK_STRU *)MyNew(sizeof(DSU_CBTC_ACCESS_LINK_STRU) * dsuDataLenStru->wCBTCAccessLinkLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pCBTCAccessLinkStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pCBTCAccessLinkStru, 0xFF, sizeof(DSU_CBTC_ACCESS_LINK_STRU) * dsuDataLenStru->wCBTCAccessLinkLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_CBTC_ACCESS_LINK_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wCBTCAccessLinkLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_CBTC_ACCESS_LINK_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->CBTCACCESSLINKINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wCBTCAccessLinkLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pCBTCAccessLinkStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = CBTC_ACCESS_LINK_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuCBTCAccessLinkIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wCBTCAccessLinkLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[¶Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initGrade(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + DSU_GRADE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_GRADE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + UINT8 initFlag = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wGradeLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = GRADE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->GRADEINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuGradeIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->GRADEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuGradeIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuGradeIndex, 0xFF, dsuEmapIndexStru->GRADEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pGradeStru = (DSU_GRADE_STRU *)MyNew(sizeof(DSU_GRADE_STRU) * dsuDataLenStru->wGradeLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pGradeStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pGradeStru, 0xFF, sizeof(DSU_GRADE_STRU) * dsuDataLenStru->wGradeLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_GRADE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wGradeLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataIndexArrayLen(EMAP_GRADE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->GRADEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wGradeLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pGradeStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = GRADE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuGradeIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wGradeLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[̬Ϣ]:(ͨ) +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +static UINT8 initStaticResSpeed_FAO(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + DSU_STATIC_RES_SPEED_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_STATIC_RES_SPEED_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + UINT8 initFlag = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wStaticResSpeedLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = STATIC_RES_SPEED_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->STATICRESSPEEDNUM = stru.wId; + } + else + { + /*initָ*/ + rtnValue = 0U; + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuStaticResSpeedIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->STATICRESSPEEDNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuStaticResSpeedIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuStaticResSpeedIndex, 0xFF, dsuEmapIndexStru->STATICRESSPEEDNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pStaticResSpeedStru = (DSU_STATIC_RES_SPEED_STRU *)MyNew(sizeof(DSU_STATIC_RES_SPEED_STRU) * dsuDataLenStru->wStaticResSpeedLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pStaticResSpeedStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pStaticResSpeedStru, 0xFF, sizeof(DSU_STATIC_RES_SPEED_STRU) * dsuDataLenStru->wStaticResSpeedLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_STATIC_RES_SPEED_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wStaticResSpeedLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataIndexArrayLen(EMAP_STATIC_RES_SPEED_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->STATICRESSPEEDNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wStaticResSpeedLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pStaticResSpeedStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = STATIC_RES_SPEED_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuStaticResSpeedIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U!=rtnValue) && (j==dsuDataLenStru->wStaticResSpeedLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[̬Ϣ]:(Ӵ) +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +static UINT8 initStaticResSpeed_CPK(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 rtnValueOfLimitStc = 2; + UINT8 *pData=NULL; + UINT8 checkFlag = 0U; + UINT8 initFlag = 0U; + DSU_STATIC_RES_SPEED_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_STATIC_RES_SPEED_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wStaticResSpeedLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = STATIC_RES_SPEED_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if(0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->STATICRESSPEEDNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuStaticResSpeedIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->STATICRESSPEEDNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuStaticResSpeedIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuStaticResSpeedIndex, 0xFF, dsuEmapIndexStru->STATICRESSPEEDNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pStaticResSpeedStru = (DSU_STATIC_RES_SPEED_STRU *)MyNew(sizeof(DSU_STATIC_RES_SPEED_STRU) * dsuDataLenStru->wStaticResSpeedLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pStaticResSpeedStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pStaticResSpeedStru, 0xFF, sizeof(DSU_STATIC_RES_SPEED_STRU) * dsuDataLenStru->wStaticResSpeedLen); + + /* add by ywlou */ + /* ʼ̬ٲѯ˴LINKINDEXNUMûdsuDataLenStru->wLinkLen + ΪdsuLimitStcLinkIdxlinkIdΪ±IJӦΪlinkId*/ + *g_ppDsuLimitStcLinkIdx = (DSU_STC_LIMIT_LINKIDX_STRU*)MyNew(sizeof(DSU_STC_LIMIT_LINKIDX_STRU)*(dsuEmapIndexStru->LINKINDEXNUM+1)); + if(NULL == *g_ppDsuLimitStcLinkIdx) + { + rtnValue = 0U; + } + else + { + CommonMemSet(*g_ppDsuLimitStcLinkIdx, + sizeof(DSU_STC_LIMIT_LINKIDX_STRU)*(dsuEmapIndexStru->LINKINDEXNUM+1), + 0xff, + sizeof(DSU_STC_LIMIT_LINKIDX_STRU)*(dsuEmapIndexStru->LINKINDEXNUM+1)); + } + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_STATIC_RES_SPEED_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wStaticResSpeedLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_STATIC_RES_SPEED_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->STATICRESSPEEDNUM >= wDataIndexLen)) + ||(0U ==wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wStaticResSpeedLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pStaticResSpeedStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = STATIC_RES_SPEED_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuStaticResSpeedIndex[pCurrentStru->wId] = j; + + /*Link̬Ľ*/ + rtnValueOfLimitStc = InsertToLimitStcLinkIdx(pCurrentStru->wLinkId, pCurrentStru->wId); + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (0U == rtnValueOfLimitStc)|| (DQU_QFUN_TRUE == initFlag)) + { + break; + } + + } + + if (0U == rtnValueOfLimitStc) + { + rtnValue=0U; + } + else if ((0U !=rtnValue) && (j==dsuDataLenStru->wStaticResSpeedLen)) + { + rtnValue=1; + } + else + { + /*nothing to do */ + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[̬Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStaticResSpeed(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + + cbtcVersionType=GetCbtcSysType(); + if (DQU_CBTC_FAO == cbtcVersionType ) + { + rtnValue = initStaticResSpeed_FAO(pDataAddr,dataSize,rowCount); + } + else if ((DQU_CBTC_CPK == cbtcVersionType) || (DQU_CBTC_HLT == cbtcVersionType)||(DQU_CBTC_DG == cbtcVersionType) || (DQU_CBTC_CC == cbtcVersionType) )/*ͨϿ⴦һ*/ + { + /*̬Linkָ򿪱ڴ򣬲ִо̬ٳʼ*/ + if (0x01 == g_IsEmapAllocMemory) + { + if (NULL != g_ppDsuLimitStcLinkIdx) + { + rtnValue = initStaticResSpeed_CPK(pDataAddr,dataSize,rowCount); + } + } + else/*ⲿڴ*/ + { + if (NULL != *g_ppDsuLimitStcLinkIdx) + { + rtnValue = initStaticResSpeed_CPK(pDataAddr,dataSize,rowCount); + } + } + + } + else + { + /**/ + } + + return rtnValue; + +} + +/********************************************** +ܣʼ[Ĭг]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initDefaultRout(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_DEFAULTROUTE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_DEFAULTROUTE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wDefaultRoutLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize / rowCount; + + /*鳤ȼ*/ + initFlag = DEFAULTROUTE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->DEFAULTROUTEINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuDefaultRoutIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->DEFAULTROUTEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuDefaultRoutIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuDefaultRoutIndex, 0xFF, dsuEmapIndexStru->DEFAULTROUTEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pDefaultRoutStru = (DSU_DEFAULTROUTE_STRU *)MyNew(sizeof(DSU_DEFAULTROUTE_STRU) * dsuDataLenStru->wDefaultRoutLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pDefaultRoutStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pDefaultRoutStru, 0xFF, sizeof(DSU_DEFAULTROUTE_STRU) * dsuDataLenStru->wDefaultRoutLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_DEFAULT_ROUTE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wDefaultRoutLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_DEFAULT_ROUTE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->DEFAULTROUTEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wDefaultRoutLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pDefaultRoutStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = DEFAULTROUTE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuDefaultRoutIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wDefaultRoutLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[վӪ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initRunLevel(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_RUN_LEVEL_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_RUN_LEVEL_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wRunLevelLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = RUN_LEVEL_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->RUNLEVELINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*Initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuRunLevelIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->RUNLEVELINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuRunLevelIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuRunLevelIndex, 0xFF, dsuEmapIndexStru->RUNLEVELINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pRunLevelStru = (DSU_RUN_LEVEL_STRU *)MyNew(sizeof(DSU_RUN_LEVEL_STRU) * dsuDataLenStru->wRunLevelLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pRunLevelStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pRunLevelStru, 0xFF, sizeof(DSU_RUN_LEVEL_STRU) * dsuDataLenStru->wRunLevelLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_RUN_LEVEL_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wRunLevelLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag= dquGetEmapDataIndexArrayLen(EMAP_RUN_LEVEL_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->RUNLEVELINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wRunLevelLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pRunLevelStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = RUN_LEVEL_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuRunLevelIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wRunLevelLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[˳CBTC]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initExitRoute(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_EXIT_ROUTE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_EXIT_ROUTE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wExitRouteLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = EXIT_ROUTE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->EXITROUTEINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuExitRouteIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->EXITROUTEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuExitRouteIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuExitRouteIndex, 0xFF, dsuEmapIndexStru->EXITROUTEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pExitRouteStru = (DSU_EXIT_ROUTE_STRU *)MyNew(sizeof(DSU_EXIT_ROUTE_STRU) * dsuDataLenStru->wExitRouteLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pExitRouteStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pExitRouteStru, 0xFF, sizeof(DSU_EXIT_ROUTE_STRU) * dsuDataLenStru->wExitRouteLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_EXIT_ROUTE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wExitRouteLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag= dquGetEmapDataIndexArrayLen(EMAP_EXIT_ROUTE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->EXITROUTEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wExitRouteLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pExitRouteStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = EXIT_ROUTE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuExitRouteIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wExitRouteLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[CBTC]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initTrainLine(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_TRAIN_LINE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_TRAIN_LINE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָ׵ַΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wTrainLineLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = TRAIN_LINE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->TRAINLINEINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuTrainLineIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->TRAINLINEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuTrainLineIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuTrainLineIndex, 0xFF, dsuEmapIndexStru->TRAINLINEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pTrainLineStru = (DSU_TRAIN_LINE_STRU *)MyNew(sizeof(DSU_TRAIN_LINE_STRU) * dsuDataLenStru->wTrainLineLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pTrainLineStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pTrainLineStru, 0xFF, sizeof(DSU_TRAIN_LINE_STRU) * dsuDataLenStru->wTrainLineLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_TRAIN_LINE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wTrainLineLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_TRAIN_LINE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->TRAINLINEINDEXNUM >= wDataIndexLen))||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wTrainLineLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pTrainLineStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = TRAIN_LINE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuTrainLineIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) &&(j==dsuDataLenStru->wTrainLineLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Զ۷]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAR(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_AR_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_AR_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wARLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = AR_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->ARNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuARIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->ARNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuARIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuARIndex, 0xFF, dsuEmapIndexStru->ARNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pARStru = (DSU_AR_STRU *)MyNew(sizeof(DSU_AR_STRU) * dsuDataLenStru->wARLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pARStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pARStru, 0xFF, sizeof(DSU_AR_STRU) * dsuDataLenStru->wARLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_AR_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wARLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_AR_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->ARNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wARLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pARStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = AR_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuARIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE == initFlag)) + { + break; + } + } + + if ((0U != rtnValue) &&(j==dsuDataLenStru->wARLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ZCϢ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initZCComZone(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_ZC_COM_ZONE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_ZC_COM_ZONE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wZCComZoneLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag =ZC_COM_ZONE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->ZCCOMZONENUM = stru.wId; + } + else + { + rtnValue = 0U;/*Initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuZCComZoneIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->ZCCOMZONENUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuZCComZoneIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuZCComZoneIndex, 0xFF, dsuEmapIndexStru->ZCCOMZONENUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pZCComZoneStru = (DSU_ZC_COM_ZONE_STRU *)MyNew(sizeof(DSU_ZC_COM_ZONE_STRU) * dsuDataLenStru->wZCComZoneLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pZCComZoneStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pZCComZoneStru, 0xFF, sizeof(DSU_ZC_COM_ZONE_STRU) * dsuDataLenStru->wZCComZoneLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_ZC_COM_ZONE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wZCComZoneLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_ZC_COM_ZONE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->ZCCOMZONENUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wZCComZoneLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pZCComZoneStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = ZC_COM_ZONE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuZCComZoneIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if (j==dsuDataLenStru->wZCComZoneLen) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[CIϢ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCI(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_CI_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_CI_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wCILen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = CI_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->CIINDEXNUM = stru.wIndex; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuCIIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->CIINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuCIIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuCIIndex, 0xFF, dsuEmapIndexStru->CIINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pCIStruStru = (DSU_CI_STRU *)MyNew(sizeof(DSU_CI_STRU) * dsuDataLenStru->wCILen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pCIStruStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pCIStruStru, 0xFF, sizeof(DSU_CI_STRU) * dsuDataLenStru->wCILen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_CI_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wCILen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_CI_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->CIINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wCILen; j++) + { + pCurrentStru = dsuStaticHeadStru->pCIStruStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag =CI_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuCIIndex[pCurrentStru->wIndex] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U!= rtnValue) && (j==dsuDataLenStru->wCILen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ATSϢ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initATS(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_ATS_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_ATS_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wATSLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = ATS_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->ATSINDEXNUM = stru.wIndex; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuATSIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->ATSINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuATSIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuATSIndex, 0xFF, dsuEmapIndexStru->ATSINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pATSStruStru = (DSU_ATS_STRU *)MyNew(sizeof(DSU_ATS_STRU) * dsuDataLenStru->wATSLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pATSStruStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pATSStruStru, 0xFF, sizeof(DSU_ATS_STRU) * dsuDataLenStru->wATSLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_ATS_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wATSLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_ATS_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->ATSINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wATSLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pATSStruStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = ATS_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuATSIndex[pCurrentStru->wIndex] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if((0U!=rtnValue) && (j==dsuDataLenStru->wATSLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ͳһϢ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initConResSpeed(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_CONRESSPEED_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_CONRESSPEED_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wConResSpeedLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = CONRESSPEED_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->CONRESSPEEDINDEXNUM = stru.wIndex; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuConResSpeedIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->CONRESSPEEDINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuConResSpeedIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuConResSpeedIndex, 0xFF, dsuEmapIndexStru->CONRESSPEEDINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pConResSpeedStru = (DSU_CONRESSPEED_STRU *)MyNew(sizeof(DSU_CONRESSPEED_STRU) * dsuDataLenStru->wConResSpeedLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pConResSpeedStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pConResSpeedStru, 0xFF, sizeof(DSU_CONRESSPEED_STRU) * dsuDataLenStru->wConResSpeedLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_CONRESSPEED_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wConResSpeedLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_CONRESSPEED_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->CONRESSPEEDINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wConResSpeedLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pConResSpeedStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = CONRESSPEED_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuConResSpeedIndex[pCurrentStru->wIndex] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U!=rtnValue) && (j==dsuDataLenStru->wConResSpeedLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ͳһ¶Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initConGrade(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_CONGRADE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_CONGRADE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wConGradeLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag =CONGRADE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->CONGRADEINDEXNUM = stru.wIndex; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuConGradeIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->CONGRADEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuConGradeIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuConGradeIndex, 0xFF, dsuEmapIndexStru->CONGRADEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pConGradeStru = (DSU_CONGRADE_STRU *)MyNew(sizeof(DSU_CONGRADE_STRU) * dsuDataLenStru->wConGradeLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pConGradeStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pConGradeStru, 0xFF, sizeof(DSU_CONGRADE_STRU) * dsuDataLenStru->wConGradeLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_CONGRADE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wConGradeLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_CONGRADE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->CONGRADEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wConGradeLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pConGradeStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag= CONGRADE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuConGradeIndex[pCurrentStru->wIndex] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U!= rtnValue) && (j==dsuDataLenStru->wConGradeLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ZCֽϢ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initZCDividPoint(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_ZC_DIVID_POINT_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_ZC_DIVID_POINT_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wZCDividPointLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = ZC_DIVID_POINT_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->ZCDIVIDPOINTINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuZCDividPointIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->ZCDIVIDPOINTINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuZCDividPointIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuZCDividPointIndex, 0xFF, dsuEmapIndexStru->ZCDIVIDPOINTINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pZCDividPointStru = (DSU_ZC_DIVID_POINT_STRU *)MyNew(sizeof(DSU_ZC_DIVID_POINT_STRU) * dsuDataLenStru->wZCDividPointLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pZCDividPointStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pZCDividPointStru, 0xFF, sizeof(DSU_ZC_DIVID_POINT_STRU) * dsuDataLenStru->wZCDividPointLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_ZC_DIVID_POINT_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wZCDividPointLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_ZC_DIVID_POINT_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->ZCDIVIDPOINTINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wZCDividPointLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pZCDividPointStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = ZC_DIVID_POINT_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuZCDividPointIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wZCDividPointLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPhysicalSgmt(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_PHYSICAL_SGMT_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_PHYSICAL_SGMT_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wPhysicalSgmtLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = PHYSICAL_SGMT_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->PHYSICALSGMTINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuPhysicalSgmtIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->PHYSICALSGMTINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuPhysicalSgmtIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuPhysicalSgmtIndex, 0xFF, dsuEmapIndexStru->PHYSICALSGMTINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pPhysicalSgmtStru = (DSU_PHYSICAL_SGMT_STRU *)MyNew(sizeof(DSU_PHYSICAL_SGMT_STRU) * dsuDataLenStru->wPhysicalSgmtLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pPhysicalSgmtStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pPhysicalSgmtStru, 0xFF, sizeof(DSU_PHYSICAL_SGMT_STRU) * dsuDataLenStru->wPhysicalSgmtLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_PHYSICAL_SGMT_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wPhysicalSgmtLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_PHYSICAL_SGMT_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->PHYSICALSGMTINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wPhysicalSgmtLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pPhysicalSgmtStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag =PHYSICAL_SGMT_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuPhysicalSgmtIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wPhysicalSgmtLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ʽ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initBlocTrgArea(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_BLOC_TRG_AREA_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_BLOC_TRG_AREA_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wBlocTrgAreaLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = DSU_BLOC_TRG_AREA_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->BLOCTRGAREAINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuBlocTrgAreaIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->BLOCTRGAREAINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuBlocTrgAreaIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuBlocTrgAreaIndex, 0xFF, dsuEmapIndexStru->BLOCTRGAREAINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pBlocTrgAreaStru = (DSU_BLOC_TRG_AREA_STRU *)MyNew(sizeof(DSU_BLOC_TRG_AREA_STRU) * dsuDataLenStru->wBlocTrgAreaLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pBlocTrgAreaStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pBlocTrgAreaStru, 0xFF, sizeof(DSU_BLOC_TRG_AREA_STRU) * dsuDataLenStru->wBlocTrgAreaLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_BLOC_TRG_AREA_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wBlocTrgAreaLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_BLOC_TRG_AREA_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->BLOCTRGAREAINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wBlocTrgAreaLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pBlocTrgAreaStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag =DSU_BLOC_TRG_AREA_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuBlocTrgAreaIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wBlocTrgAreaLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[CBTC]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCbtcTrgArea(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_CBTC_TRG_AREA_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_CBTC_TRG_AREA_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wCbtcTrgAreaLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize / rowCount; + + /*鳤ȼ*/ + initFlag = DSU_CBTC_TRG_AREA_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->CBTCTRGAREAINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuCbtcTrgAreaIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->CBTCTRGAREAINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuCbtcTrgAreaIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuCbtcTrgAreaIndex, 0xFF, dsuEmapIndexStru->CBTCTRGAREAINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pCbtcTrgAreaStru = (DSU_CBTC_TRG_AREA_STRU *)MyNew(sizeof(DSU_CBTC_TRG_AREA_STRU) * dsuDataLenStru->wCbtcTrgAreaLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pCbtcTrgAreaStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pCbtcTrgAreaStru, 0xFF, sizeof(DSU_CBTC_TRG_AREA_STRU) * dsuDataLenStru->wCbtcTrgAreaLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_CBTC_TRG_AREA_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wCbtcTrgAreaLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataIndexArrayLen(EMAP_CBTC_TRG_AREA_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->CBTCTRGAREAINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wCbtcTrgAreaLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pCbtcTrgAreaStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = DSU_CBTC_TRG_AREA_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuCbtcTrgAreaIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wCbtcTrgAreaLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[վ̨]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPlatForm(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_PLAT_FORM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_PLAT_FORM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + static UINT16 logicSgmtSumCount = 0;/*վ̨ӦĴID*/ + + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wPlatFormLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize / rowCount; + + /*վ̨ӦĴ߼ID=(ֽ-ǴIDϢֽ)/IDֽ*/ + logicSgmtSumCount = ((UINT16)rowDataLen - STATION_NO_LOGICSGMT_SIZE) / 2; + + /*ֶ̬洢ݴ*/ + if (STATION_INCLUDE_LOGICSGMT_NUM < logicSgmtSumCount) + { + rtnValue = 0U; + } + else + { + /*鳤ȼ*/ + initFlag = DSU_PLAT_FORM_STRU_init(pDataAddr + dataSize - rowDataLen, &stru,logicSgmtSumCount); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->PLATFORMINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuPlatFormIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->PLATFORMINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuPlatFormIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuPlatFormIndex, 0xFF, dsuEmapIndexStru->PLATFORMINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pPlatFormStru = (DSU_PLAT_FORM_STRU *)MyNew(sizeof(DSU_PLAT_FORM_STRU) * dsuDataLenStru->wPlatFormLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pPlatFormStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pPlatFormStru, 0xFF, sizeof(DSU_PLAT_FORM_STRU) * dsuDataLenStru->wPlatFormLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_PLAT_FORM_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wPlatFormLen >= wStruDataLen))||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_PLAT_FORM_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->PLATFORMINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wPlatFormLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pPlatFormStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag =DSU_PLAT_FORM_STRU_init(pData, pCurrentStru,logicSgmtSumCount); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuPlatFormIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wPlatFormLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[·]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initComeGoRoute(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_COME_GO_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_COME_GO_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wComeGoRouteLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag =DSU_COME_GO_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->COMEGOINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuComeGoIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->COMEGOINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuComeGoIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuComeGoIndex, 0xFF, dsuEmapIndexStru->COMEGOINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pComeGoRouteStru = (DSU_COME_GO_STRU *)MyNew(sizeof(DSU_COME_GO_STRU) * dsuDataLenStru->wComeGoRouteLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pComeGoRouteStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pComeGoRouteStru, 0xFF, sizeof(DSU_COME_GO_STRU) * dsuDataLenStru->wComeGoRouteLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_COME_GO_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wComeGoRouteLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_COME_GO_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->COMEGOINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wComeGoRouteLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pComeGoRouteStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = DSU_COME_GO_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuComeGoIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) &&(j==dsuDataLenStru->wComeGoRouteLen)) + { + rtnValue= 1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initFloodGate(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 ftnValue = 0U; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_FLOOD_GATE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_FLOOD_GATE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + ftnValue = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == ftnValue)) + { + dsuDataLenStru->wFloodGateLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag=DSU_FLOOD_GATE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->FLOODGATEINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + ftnValue = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == ftnValue)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuFloodGateIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->FLOODGATEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuFloodGateIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuFloodGateIndex, 0xFF, dsuEmapIndexStru->FLOODGATEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pFloodGateStru = (DSU_FLOOD_GATE_STRU *)MyNew(sizeof(DSU_FLOOD_GATE_STRU) * dsuDataLenStru->wFloodGateLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pFloodGateStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pFloodGateStru, 0xFF, sizeof(DSU_FLOOD_GATE_STRU) * dsuDataLenStru->wFloodGateLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_FLOOD_GATE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wFloodGateLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_FLOOD_GATE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->FLOODGATEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + ftnValue = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == ftnValue)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wFloodGateLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pFloodGateStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag =DSU_FLOOD_GATE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuFloodGateIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE == initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wFloodGateLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[SPKSϢ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSpksButton(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_SPKS_BUTTON_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_SPKS_BUTTON_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wSpksButtonLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = DSU_SPKS_BUTTON_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->SPKSBUTTONINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuSpksButtonIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->SPKSBUTTONINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuSpksButtonIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuSpksButtonIndex, 0xFF, dsuEmapIndexStru->SPKSBUTTONINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pSpksButtonStru = (DSU_SPKS_BUTTON_STRU *)MyNew(sizeof(DSU_SPKS_BUTTON_STRU) * dsuDataLenStru->wSpksButtonLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pSpksButtonStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pSpksButtonStru, 0xFF, sizeof(DSU_SPKS_BUTTON_STRU) * dsuDataLenStru->wSpksButtonLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_SPKS_BUTTON_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wSpksButtonLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_SPKS_BUTTON_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->SPKSBUTTONINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wSpksButtonLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pSpksButtonStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = DSU_SPKS_BUTTON_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuSpksButtonIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wSpksButtonLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initDepotGate(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_DEPOT_GATE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_DEPOT_GATE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wDepotGateLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = DEPOT_GATE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if ((0U!= initFlag)) + { + /*ΪID + 1*/ + dsuEmapIndexStru->DEPOTGATEINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuDepotGateIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->DEPOTGATEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuDepotGateIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuDepotGateIndex, 0xFF, dsuEmapIndexStru->DEPOTGATEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pDepotGateStru = (DSU_DEPOT_GATE_STRU *)MyNew(sizeof(DSU_DEPOT_GATE_STRU) * dsuDataLenStru->wDepotGateLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pDepotGateStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pDepotGateStru, 0xFF, sizeof(DSU_DEPOT_GATE_STRU) * dsuDataLenStru->wDepotGateLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_DEPOT_GATE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wDepotGateLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_DEPOT_GATE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->DEPOTGATEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wDepotGateLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pDepotGateStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag=DEPOT_GATE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuDepotGateIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wDepotGateLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initTunnel(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_TUNNEL_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_TUNNEL_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wTunnelLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = TUNNEL_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->TUNNELINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuTunnelIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->TUNNELINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuTunnelIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuTunnelIndex, 0xFF, dsuEmapIndexStru->TUNNELINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pTunnelStru = (DSU_TUNNEL_STRU *)MyNew(sizeof(DSU_TUNNEL_STRU ) * dsuDataLenStru->wTunnelLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pTunnelStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pTunnelStru, 0xFF, sizeof(DSU_TUNNEL_STRU ) * dsuDataLenStru->wTunnelLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_TUNNEL_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wTunnelLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_TUNNEL_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->TUNNELINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wTunnelLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pTunnelStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = TUNNEL_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuTunnelIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wTunnelLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ZCϢ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initZC(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_ZC_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_ZC_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wZCLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = ZC_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if ((0U!= initFlag)) + { + /*ΪID + 1*/ + dsuEmapIndexStru->ZCINDEXNUM = stru.wIndex; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuZCIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->ZCINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuZCIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuZCIndex, 0xFF, dsuEmapIndexStru->ZCINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pZCStru = (DSU_ZC_STRU *)MyNew(sizeof(DSU_ZC_STRU) * dsuDataLenStru->wZCLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pZCStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pZCStru, 0xFF, sizeof(DSU_ZC_STRU) * dsuDataLenStru->wZCLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_ZC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wZCLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_ZC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->ZCINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wZCLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pZCStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = ZC_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuZCIndex[pCurrentStru->wIndex] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wZCLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[࿪Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initMultiPoint(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_MULTI_SWITCH_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_MULTI_SWITCH_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wMultiPointLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag =MULTI_POINT_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->MULTIPOINTINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuMultiPointIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->MULTIPOINTINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuMultiPointIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuMultiPointIndex, 0xFF, dsuEmapIndexStru->MULTIPOINTINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pMultiPointStru = (DSU_MULTI_SWITCH_STRU *)MyNew(sizeof(DSU_MULTI_SWITCH_STRU) * dsuDataLenStru->wMultiPointLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pMultiPointStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pMultiPointStru, 0xFF, sizeof(DSU_MULTI_SWITCH_STRU) * dsuDataLenStru->wMultiPointLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_MULTI_POINT_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wMultiPointLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_MULTI_POINT_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->MULTIPOINTINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wMultiPointLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pMultiPointStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = MULTI_POINT_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuMultiPointIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wMultiPointLen)) + { + /*ʼɹ󣬻ȡʵ*/ + rtnValue=GetPhyiscalSwitches(); + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPowerlessZone(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_POWERLESS_ZONE_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_POWERLESS_ZONE_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wPowerlessZoneLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = POWERLESS_ZONE_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->POWERLESSZONEINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuPowerlessZoneIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->POWERLESSZONEINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuPowerlessZoneIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuPowerlessZoneIndex, 0xFF, dsuEmapIndexStru->POWERLESSZONEINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pPowerlessZoneStru = (DSU_POWERLESS_ZONE_STRU *)MyNew(sizeof(DSU_POWERLESS_ZONE_STRU) * dsuDataLenStru->wPowerlessZoneLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pPowerlessZoneStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pPowerlessZoneStru, 0xFF, sizeof(DSU_POWERLESS_ZONE_STRU) * dsuDataLenStru->wPowerlessZoneLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_POWERLESSZONE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wPowerlessZoneLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_POWERLESSZONE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->POWERLESSZONEINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wPowerlessZoneLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pPowerlessZoneStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag =POWERLESS_ZONE_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuPowerlessZoneIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wPowerlessZoneLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCarStop(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_CARSTOP_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_CARSTOP_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen=0U; + UINT16 wDataIndexLen=0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (1U==initFlag)) + { + dsuDataLenStru->wCarStopLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = CARSTOP_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->CARSTOPINDEXNUM = stru.carsId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuCarStopIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->CARSTOPINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuCarStopIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuCarStopIndex, 0xFF, dsuEmapIndexStru->CARSTOPINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pCarStopStru = (DSU_CARSTOP_STRU *)MyNew(sizeof(DSU_CARSTOP_STRU) * dsuDataLenStru->wCarStopLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pCarStopStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pCarStopStru, 0xFF, sizeof(DSU_CARSTOP_STRU) * dsuDataLenStru->wCarStopLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_CARSTOP_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wCarStopLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_CARSTOP_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->CARSTOPINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wCarStopLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pCarStopStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = CARSTOP_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuCarStopIndex[pCurrentStru->carsId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuDataLenStru->wCarStopLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + + + +/********************************************* +ܣʼͣϢ +UINT8 *pDataAddr, ڴַ + UINT32 DataSize, ݱֽ + UINT16 rowCount, ݱ + +ֵ 2δ꣬1ɹ0ʧ +עݻͨݽṹV18.0.0ӣadd by sds 20200211 +*********************************************/ +UINT8 initAdjtStation(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + + UINT8 rtnValue = 2U; /*ֵ*/ + UINT8 *pData = NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_AdjtStation_STRU stru ={0}; /*ͣṹʱ*/ + DSU_AdjtStation_STRU *pCurrentStru = NULL; /*ͣṹʱָ*/ + + UINT16 j = 0; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + + /*ǿշ*/ + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru = g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (1U==initFlag)) + { + dsuDataLenStru->wAdjtStationLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize / rowCount; + + /*鳤ȼ*/ + initFlag = ADJTSTATION_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if ((0U!= initFlag)) + { + /*ΪID + 1*/ + dsuEmapIndexStru->ADJTSTATIONINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE ==initFlag)) + { + if ( 0x01==g_IsEmapAllocMemory ) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuAdjtStationIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->ADJTSTATIONINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuAdjtStationIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuAdjtStationIndex, 0xFF, dsuEmapIndexStru->ADJTSTATIONINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pAdjtStationStru = (DSU_AdjtStation_STRU *)MyNew(sizeof(DSU_AdjtStation_STRU) * dsuDataLenStru->wAdjtStationLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pAdjtStationStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pAdjtStationStru, 0xFF, sizeof(DSU_AdjtStation_STRU) * dsuDataLenStru->wAdjtStationLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_ADJTSTATION_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wAdjtStationLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_ADJTSTATION_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->ADJTSTATIONINDEXNUM >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wAdjtStationLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pAdjtStationStru + j; + + pData = pDataAddr + (rowDataLen * j); + + /*ݽṹ*/ + initFlag = ADJTSTATION_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuAdjtStationIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j == dsuDataLenStru->wAdjtStationLen)) + { + rtnValue = 1; + } + } + + return rtnValue; +} + + +/************************************************************************** +* : ʼPSC +* : UINT8 *pDataAddr, ڴַ + UINT32 DataSize, ݱֽ + UINT16 rowCount, ݱ +* : +* : +* ȫֱ: +* ֵ: 2δ꣬1ɹ0ʧ +8 ޸ļ¼: +* 1ݻͨݽṹV20.0.0ӣadd by sds 2020-8-18 +**************************************************************************/ +UINT8 initPSC(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + + UINT8 rtnValue = 2U; /*ֵ*/ + UINT8 *pData = NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_PSC_STRU stru ={0}; /*PSCṹʱ*/ + DSU_PSC_STRU *pCurrentStru = NULL; /*PSCṹʱָ*/ + UINT16 j = 0; + static UINT32 rowDataLen=0U; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + UINT32 funErrCode = DSU_FUNC_SUCESS; + + /*ָ*/ + if(NULL != pDataAddr) + { + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + + /*ǿշ*/ + if (NULL != g_dsuEmapStru) + { + dsuEmapIndexStru = g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + + initFlag = EmapInitFunStepCtrl(0x01); + /*δ&ǰڵ1׶*/ + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + + dsuDataLenStru->wPSCLen = rowCount; + + /*Ϊ0ֱΪʼɹ*/ + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize / ((UINT32)rowCount); + + /*鳤ȼ*/ + initFlag = PSC_STRU_init((pDataAddr + dataSize - rowDataLen), &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->PSCINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + else + { + /*nothing to do*/ + } + + initFlag = EmapInitFunStepCtrl(0x02); + /*δ&ǰڵ2׶*/ + if (((2U == rtnValue)) && (DQU_QFUN_TRUE == initFlag)) + { + if (0x01 == g_IsEmapAllocMemory) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuPSCIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->PSCINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuPSCIndex) + { + rtnValue = 0U; + funErrCode = DSU_FUNC_CODE3; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuPSCIndex, 0xFF, dsuEmapIndexStru->PSCINDEXNUM * 2 + 2); + + /*̬ռ*/ + dsuStaticHeadStru->pPSCStru = (DSU_PSC_STRU *)MyNew(sizeof(DSU_PSC_STRU) * dsuDataLenStru->wPSCLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pPSCStru) + { + rtnValue = 0U; + funErrCode = DSU_FUNC_CODE4; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pPSCStru, 0xFF, sizeof(DSU_PSC_STRU) * dsuDataLenStru->wPSCLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag =dquGetEmapDataStruArrayLen(EMAP_PSC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wPSCLen >= wStruDataLen)) || (0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue = 0U; + funErrCode = DSU_FUNC_CODE5; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_PSC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuEmapIndexStru->PSCINDEXNUM >= wDataIndexLen)) + || (0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue = 0U; + funErrCode = DSU_FUNC_CODE6; + } + else + { + /*nothing to do*/ + } + } + } + } + else + { + /*nothing to do*/ + } + + initFlag = EmapInitFunStepCtrl(0x03); + /*δ&ǰڵ3׶*/ + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wPSCLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pPSCStru + j; + + pData = pDataAddr + (rowDataLen * j); + + /*ݽṹ*/ + initFlag = PSC_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuPSCIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + else + { + /*nothing to do*/ + } + } + if (0U != rtnValue) + { + rtnValue = (j == dsuDataLenStru->wPSCLen) ? (1) : (rtnValue); + } + } + else + { + /*nothing to do*/ + } + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + funErrCode = DSU_FUNC_CODE2; + } + } + else + { + /*ָ,ֱӷʧ*/ + rtnValue = 0U; + funErrCode = DSU_FUNC_CODE1; + } + + /*ϢΪɹ,ӡ*/ + if (DSU_FUNC_SUCESS != funErrCode) + { + printf("initPSC Err:0x%x",funErrCode); + } + else + { + /*nothing to do*/ + } + + return rtnValue; +} + +/************************************************ +ܣȡ + +errRecord飬errRecordLen鳤 +ֵ1ɹ +************************************************/ +UINT8 dquGetErrNo(UINT8* errRecord, UINT32 * errRecordLen) +{ + UINT32 Ofst = 0; + UINT32 i = 0; + UINT8 rtnValue = 0U; + + if ((NULL != errRecord) && (NULL!=errRecordLen)) + { + ShortToChar(fileErrNo, &errRecord[Ofst]); + Ofst += 2; + + ShortToChar(dataTypeErrNo, &errRecord[Ofst]); + Ofst += 2; + + for (i = 0; i < INIT_ERR_NUM; i++) + { + errRecord[Ofst] = initErrNo[i]; + Ofst++; + } + + *errRecordLen = Ofst; + rtnValue = 1; + } + return rtnValue; +} + +/************************************************ +ܣ̬ϢӦIJLinkΪıУ + ŻѯǰLINKʹá + +@linkId:ǰ̬ٱŶӦLINKţpCurrentStaticResSpeedStru->wLinkId +@limitStcSpdId:ǰ̬ٱţpCurrentStaticResSpeedStru->wId + +ֵ1ɹ 0ʧ +************************************************/ +UINT8 InsertToLimitStcLinkIdx(UINT16 linkId,UINT16 limitStcSpdId) +{ + UINT8 ret = 0; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + DSU_STC_LIMIT_LINKIDX_STRU *dsuLimitStcLinkIdx=NULL; + if ((NULL != g_dsuEmapStru) && (NULL != g_ppDsuLimitStcLinkIdx)) + { + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuLimitStcLinkIdx=*g_ppDsuLimitStcLinkIdx; + if (NULL==dsuLimitStcLinkIdx) + { + ret = 0; + return ret; + } + } + else + { + /*ӵͼָΪ*/ + ret = 0; + return ret; + } + + if(linkId <= dsuEmapIndexStru->LINKINDEXNUM)/*linkIdڵӵͼlinkIdΧʱ´*/ + { + /*жϵǰlinkIdǷѾֵ + dzʼֵʾǰlinkIdûнйֵ + dzʼֵʾǰlinkIdѾй̬*/ + if(dsuLimitStcLinkIdx[linkId].linkId == UINT16_MAX) + { + dsuLimitStcLinkIdx[linkId].linkId = linkId; + dsuLimitStcLinkIdx[linkId].limitStcSpdInfoCount = 0; + } + + if (dsuLimitStcLinkIdx[linkId].limitStcSpdInfoCountdsuEmapIndexStru)&&(NULL!=g_dsuEmapExtendStru)) + { + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + + /*࿪*/ + for (m=0;mwMultiPointLen;m++) + { + pMultiPointStru=dsuStaticHeadStru->pMultiPointStru+m; + wVirtualPointNum+=pMultiPointStru->wType-1; /*=࿪-1*/ + + } + /*ʵ=࿪+-*/ + wPhysicalPointNum=dsuDataLenStru->wMultiPointLen+dsuDataLenStru->wPointLen-wVirtualPointNum; + + /*̬ռ*/ + g_dsuEmapExtendStru->pDsuPhysicalSwitchIdx = (DSU_PHYSICAL_SWITCH_STRU*)MyNew(sizeof(DSU_PHYSICAL_SWITCH_STRU) * (wPhysicalPointNum+1)); + + pVirtualPointIdx=(UINT16*)MyNew(sizeof(UINT16)*wVirtualPointNum+ 2); + + /*̬ռɹ*/ + if((NULL != g_dsuEmapExtendStru->pDsuPhysicalSwitchIdx)&&(NULL!=pVirtualPointIdx)) + { + /*ڴΪЧ*/ + CommonMemSet(g_dsuEmapExtendStru->pDsuPhysicalSwitchIdx, sizeof(DSU_PHYSICAL_SWITCH_STRU)*(wPhysicalPointNum+1), 0xff, sizeof(DSU_PHYSICAL_SWITCH_STRU)*(wPhysicalPointNum+1)); + + memset(pVirtualPointIdx, 0xFF, wVirtualPointNum + 2); + + pTempPhysicalPointStru=g_dsuEmapExtendStru->pDsuPhysicalSwitchIdx; + /*࿪,࿪ʵ洢*/ + for (i=0;iwMultiPointLen;i++) + { + pMultiPointStru=dsuStaticHeadStru->pMultiPointStru+i; + /*࿪ʵ*/ + pTempPhysicalPointStru[chFindPhyPointNum].Id=pMultiPointStru->wId; + pTempPhysicalPointStru[chFindPhyPointNum].type=pMultiPointStru->wType; + chFindPhyPointNum++; + + /*洢,NλR1λΪͬһ1ʼ*/ + for(k=1;kwType;k++) + { + pVirtualPointIdx[wVirPointIndex]=pMultiPointStru->wSwitchIds[k]; + wVirPointIndex++; + + } + } + + /*浥ʵ*/ + for(j=0;jwPointLen;j++) + { + bVirtualPoint=0; + pPointStru=dsuStaticHeadStru->pPointStru+j; + tempPointId=pPointStru->wId; + /*е*/ + for (m=0;mPHYSICALSWITCHNUM=chFindPhyPointNum; + chReturnValue=1; + } + + /*ͷָ*/ + free(pVirtualPointIdx); + + pVirtualPointIdx = NULL; + + } + else/*ڴʧ*/ + { + chReturnValue=0U; + } + + } + return chReturnValue; +} + +/* +ܣLink豸ӳϵ +˵ +ֵ1ɹ 0ʧ +author: qxt 20170816 +*/ +UINT8 GetDeviceInfoInLink() +{ + UINT8 chReturnValue = 2; /*ֵ*/ + UINT8 chFlag=1; /*ʶλ*/ + UINT8 stepFlag = 0U; + UINT16 wIndex=0U; /*ѭñ*/ + + + DSU_LINK_STRU *pLinkStru=NULL; /*Linkʱṹ*/ + DSU_SIGNAL_STRU *pSignalStru=NULL; /*źŻʱṹ*/ + DSU_BALISE_STRU *pBaliseStru=NULL; /*Ӧʱṹ*/ + DSU_SCREEN_STRU *pScreenStru=NULL; /*ȫʱṹ*/ + DSU_EMERG_STOP_STRU *pESBStru=NULL;/*ͣťʱṹ*/ + DSU_STATION_STRU *pStationStru=NULL;/*ͣʱṹ*/ + DSU_STOPPOINT_STRU *pStopPointStru=NULL;/*ͣʱṹ*/ + DSU_PLAT_FORM_STRU *pPlatformStru=NULL;/*վ̨ʱṹ*/ + + DSU_DEVICE_IN_LINK_STRU *pTempDeviceStru=NULL; + + /*ȫֱĴε漰ȫֱ*/ + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru=NULL; + UINT16 *dsuLinkIndex=NULL; + UINT16 *dsuStationIndex=NULL; + + if ((NULL != g_dsuEmapStru)&&(NULL!=g_dsuEmapStru->dsuEmapIndexStru)&&(NULL!=g_dsuEmapExtendStru)) + { + dsuDataLenStru=g_dsuEmapStru->dsuDataLenStru; + dsuStaticHeadStru=g_dsuEmapStru->dsuStaticHeadStru; + dsuEmapIndexStru=g_dsuEmapStru->dsuEmapIndexStru; + dsuLinkIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStationIndex=g_dsuEmapStru->dsuEmapIndexStru->dsuStationIndex; + + /*ļڴռ*/ + if (0x01==g_IsEmapAllocMemory) + { + g_dsuEmapExtendStru->pDsuDeviceInLinkIdx = (DSU_DEVICE_IN_LINK_STRU*)MyNew(sizeof(DSU_DEVICE_IN_LINK_STRU) * (dsuEmapIndexStru->LINKINDEXNUM+1)); + + } + + if(NULL != g_dsuEmapExtendStru->pDsuDeviceInLinkIdx) + { + + /*һ׶ڴĬֵ*/ + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x01)) + { + /*ڴΪЧ*/ + CommonMemSet(g_dsuEmapExtendStru->pDsuDeviceInLinkIdx, sizeof(DSU_DEVICE_IN_LINK_STRU)*(dsuEmapIndexStru->LINKINDEXNUM+1), 0x0, sizeof(DSU_DEVICE_IN_LINK_STRU)*(dsuEmapIndexStru->LINKINDEXNUM+1)); + + } + + /*linkȲlinkId*/ + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x02)) + { + + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;wIndexwLinkLen;wIndex++) + { + pLinkStru=dsuStaticHeadStru->pLinkStru+wIndex; + pTempDeviceStru=g_dsuEmapExtendStru->pDsuDeviceInLinkIdx; + pTempDeviceStru=pTempDeviceStru+pLinkStru->wId; + pTempDeviceStru->wLinkId=pLinkStru->wId; + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==stepFlag) + { + chReturnValue=2; + break; + } + } + if (wIndex==dsuDataLenStru->wLinkLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=2; + } + } + /*ٱźŻ*/ + if(DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x03)) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;wIndexwSignalLen;wIndex++) + { + pSignalStru=dsuStaticHeadStru->pSignalStru+wIndex; + pTempDeviceStru=g_dsuEmapExtendStru->pDsuDeviceInLinkIdx; + pTempDeviceStru=pTempDeviceStru+pSignalStru->wProtectLinkId; + + if (pTempDeviceStru->struSigalDev.wDevCountstruSigalDev.wDevSetId[pTempDeviceStru->struSigalDev.wDevCount++]=pSignalStru->wId; + } + else + { + chFlag=0U; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==stepFlag) + { + chReturnValue=2; + break; + } + } + if (wIndex==dsuDataLenStru->wSignalLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=2; + } + } +#if 0 + /*ڱӦ*/ + if(DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x04)) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;wIndexwBaliseLen;wIndex++) + { + pBaliseStru=dsuStaticHeadStru->pBaliseStru+wIndex; + pTempDeviceStru=g_dsuEmapExtendStru->pDsuDeviceInLinkIdx; + pTempDeviceStru=pTempDeviceStru+pBaliseStru->wLkId; + + + if (pTempDeviceStru->struBaliseDev.wDevCountstruBaliseDev.wDevSetId[pTempDeviceStru->struBaliseDev.wDevCount++]=pBaliseStru->wId; + } + else + { + chFlag=0U; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==stepFlag) + { + chReturnValue=2; + break; + } + } + if (wIndex==dsuDataLenStru->wBaliseLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=2; + } + } +#endif + + + /*۱ȫű*/ + stepFlag = EmapCalcFunStepCtrl(0x05); + if(DQU_QFUN_TRUE==stepFlag) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;wIndexwScreenLen;wIndex++) + { + pScreenStru=dsuStaticHeadStru->pScreenStru+wIndex; + pTempDeviceStru=g_dsuEmapExtendStru->pDsuDeviceInLinkIdx; + pTempDeviceStru=pTempDeviceStru+pScreenStru->wRelatLkId; + + if (pTempDeviceStru->struScreenDev.wDevCountstruScreenDev.wDevSetId[pTempDeviceStru->struScreenDev.wDevCount++]=pScreenStru->wId; + } + else + { + chFlag=0U; + } + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==stepFlag) + { + chReturnValue=2; + break; + } + } + if (wIndex==dsuDataLenStru->wScreenLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=2; + } + } + + /*ܱͣť*/ + if(DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x06)) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;wIndexwEmergStopLen;wIndex++) + { + pESBStru=dsuStaticHeadStru->pEmergStopStru+wIndex; + pTempDeviceStru=g_dsuEmapExtendStru->pDsuDeviceInLinkIdx; + pTempDeviceStru=pTempDeviceStru+pESBStru->wRelatLkId; + + if (pTempDeviceStru->struESBDev.wDevCountstruESBDev.wDevSetId[pTempDeviceStru->struESBDev.wDevCount++]=pESBStru->wId; + } + else + { + chFlag=0U; + } + + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==stepFlag) + { + chReturnValue=2; + break; + } + } + if (wIndex==dsuDataLenStru->wEmergStopLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=2; + } + } + + + /*ݱͣ*/ + stepFlag = EmapCalcFunStepCtrl(0x07); + if(DQU_QFUN_TRUE==stepFlag) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;wIndexwStationLen;wIndex++) + { + pStationStru=dsuStaticHeadStru->pStationStru+wIndex; + pTempDeviceStru=g_dsuEmapExtendStru->pDsuDeviceInLinkIdx; + pTempDeviceStru=pTempDeviceStru+pStationStru->wLinkId; + + if (pTempDeviceStru->struStationDev.wDevCountstruStationDev.wDevSetId[pTempDeviceStru->struStationDev.wDevCount++]=pStationStru->wId; + } + else + { + chFlag=0U; + } + + + /*ѭֲи*/ + stepFlag = EmapCalcLoopStepLenCtrl(wIndex); + if (DQU_QFUN_TRUE==stepFlag) + { + chReturnValue=2; + break; + } + } + if (wIndex==dsuDataLenStru->wStationLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=2; + } + } + +#if 0 + /*ޱͣ*/ + stepFlag = EmapCalcFunStepCtrl(0x08); + if(DQU_QFUN_TRUE==stepFlag) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;wIndexwStopPointLen;wIndex++) + { + pStopPointStru=dsuStaticHeadStru->pStopPointStru+wIndex; + pTempDeviceStru=g_dsuEmapExtendStru->pDsuDeviceInLinkIdx; + pTempDeviceStru=pTempDeviceStru+pStopPointStru->wLinkId; + + if (pTempDeviceStru->struStopPointDev.wDevCountstruStopPointDev.wDevSetId[pTempDeviceStru->struStopPointDev.wDevCount++]=pStopPointStru->wId; + } + else + { + chFlag=0U; + } + + + /*ѭֲи*/ + if (DQU_QFUN_TRUE==EmapCalcLoopStepLenCtrl(wIndex)) + { + chReturnValue=2; + break; + } + } + if (wIndex==dsuDataLenStru->wStopPointLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=2; + } + } +#endif +#if 0 + /*߱վ̨*/ + if(DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x09)) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos;wIndexwPlatFormLen;wIndex++) + { + pPlatformStru=dsuStaticHeadStru->pPlatFormStru+wIndex; + pStationStru=dsuStaticHeadStru->pStationStru+dsuStationIndex[pPlatformStru->wStationId]; + pTempDeviceStru=g_dsuEmapExtendStru->pDsuDeviceInLinkIdx; + pTempDeviceStru=pTempDeviceStru+pStationStru->wLinkId; + + if (pTempDeviceStru->struPlatformDev.wDevCountstruPlatformDev.wDevSetId[pTempDeviceStru->struPlatformDev.wDevCount++]=pPlatformStru->wId; + } + else + { + chFlag=0U; + } + + + /*ѭֲи*/ + if (DQU_QFUN_TRUE==EmapCalcLoopStepLenCtrl(wIndex)) + { + chReturnValue=2; + break; + } + } + if (wIndex==dsuDataLenStru->wPlatFormLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=1; + } + } +#endif + /*豸*/ + + if ( 0U== chFlag) + { + /*ʧ*/ + chReturnValue=0U; + } + + } + else + { + chReturnValue=0U; + } + } + else + { + /*ӵͼȫָΪ*/ + chReturnValue=0U; + } + return chReturnValue; +} + +/************************************************* +ܣLink¶ȼӳϵ + ¶ID¶ӦIJLinkΪıУ + ŻѯǰLINK¶ +˵ +ֵ2ʾǰûд꣬Ҫٴεô˺ 1ʾɹ 0ʾʧ +author: lmy 20180122 +*************************************************/ +UINT8 GetGradeInfoCrossLink() +{ + UINT8 chReturnValue = 2; /*ֵ*/ + UINT8 chFlag = 1; /*ʶλ*/ + UINT16 wIndex = 0; /*ѭñ*/ + UINT8 i = 0, j = 0; /*ѭñ*/ + + DSU_LINK_STRU *pLinkStru = NULL; /*Linkʱṹ*/ + DSU_GRADE_STRU *pGradeStru = NULL; /*¶ʱṹ*/ + + DSU_GRADE_LINKIDX_STRU *pTempGradeLinkIdexStru = NULL; + + /*ȫֱĴε漰ȫֱ*/ + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru = NULL; + + if ((NULL != g_dsuEmapStru) && (NULL != g_dsuEmapStru->dsuEmapIndexStru) && (NULL != g_dsuEmapExtendStru)) + { + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuEmapIndexStru = g_dsuEmapStru->dsuEmapIndexStru; + + /*ļڴռ*/ + if (0x01 == g_IsEmapAllocMemory) + { + g_dsuEmapExtendStru->pDsuGradeInLinkIdx = (DSU_GRADE_LINKIDX_STRU*)MyNew(sizeof(DSU_GRADE_LINKIDX_STRU) * (dsuEmapIndexStru->LINKINDEXNUM + 1)); + + } + + if(NULL != g_dsuEmapExtendStru->pDsuGradeInLinkIdx) + { + + /*һ׶ڴĬֵ*/ + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x01)) + { + /*ڴΪЧ*/ + CommonMemSet(g_dsuEmapExtendStru->pDsuGradeInLinkIdx, sizeof(DSU_GRADE_LINKIDX_STRU)*(dsuEmapIndexStru->LINKINDEXNUM + 1), 0x0, sizeof(DSU_GRADE_LINKIDX_STRU)*(dsuEmapIndexStru->LINKINDEXNUM + 1)); + } + + /*ٱlinkȲlinkId*/ + if (DQU_QFUN_TRUE == EmapCalcFunStepCtrl(0x02)) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndexwLinkLen; wIndex++) + { + pLinkStru = dsuStaticHeadStru->pLinkStru + wIndex; + pTempGradeLinkIdexStru = g_dsuEmapExtendStru->pDsuGradeInLinkIdx; + pTempGradeLinkIdexStru = pTempGradeLinkIdexStru + pLinkStru->wId; + pTempGradeLinkIdexStru->wLinkId = pLinkStru->wId; + + /*ѭֲи*/ + if (DQU_QFUN_TRUE == EmapCalcLoopStepLenCtrl(wIndex)) + { + chReturnValue = 2; + break; + } + } + if (wIndex == dsuDataLenStru->wLinkLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0; + chReturnValue = 2; + } + } + /*pTempGradeLinkIdexStru¶ȱwGradeIdΪЧֵ0xffff*/ + if(DQU_QFUN_TRUE == EmapCalcFunStepCtrl(0x03)) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndexwLinkLen; wIndex++) + { + pLinkStru = dsuStaticHeadStru->pLinkStru + wIndex; + pTempGradeLinkIdexStru = g_dsuEmapExtendStru->pDsuGradeInLinkIdx; + pTempGradeLinkIdexStru = pTempGradeLinkIdexStru + pLinkStru->wId; + + for (i = 0; i < LINK_MAX_GRADE_NUM; i++) + { + pTempGradeLinkIdexStru->wGradeId[i] = DSU_NULL_16; + } + + /*ѭֲи*/ + if (DQU_QFUN_TRUE==EmapCalcLoopStepLenCtrl(wIndex)) + { + chReturnValue = 2; + break; + } + } + if (wIndex==dsuDataLenStru->wLinkLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + chReturnValue=2; + } + } + /*۱¶ȣlinkź¶ȱŵӳϵ*/ + if(DQU_QFUN_TRUE == EmapCalcFunStepCtrl(0x04)) + { + for (wIndex = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; wIndexwGradeLen; wIndex++) + { + pGradeStru = dsuStaticHeadStru->pGradeStru+wIndex; + + if (pGradeStru->wOrgnLinkId == pGradeStru->wTmnlLinkId) + { + pTempGradeLinkIdexStru = g_dsuEmapExtendStru->pDsuGradeInLinkIdx; + pTempGradeLinkIdexStru = pTempGradeLinkIdexStru+pGradeStru->wOrgnLinkId; + if (pTempGradeLinkIdexStru->wGradeCount < LINK_MAX_GRADE_NUM) + { + pTempGradeLinkIdexStru->wGradeId[pTempGradeLinkIdexStru->wGradeCount++] = pGradeStru->wId; + } + else + { + chFlag = 0U; + } + } + else + { + pTempGradeLinkIdexStru = g_dsuEmapExtendStru->pDsuGradeInLinkIdx; + pTempGradeLinkIdexStru = pTempGradeLinkIdexStru+pGradeStru->wOrgnLinkId; + if (pTempGradeLinkIdexStru->wGradeCount < LINK_MAX_GRADE_NUM) + { + pTempGradeLinkIdexStru->wGradeId[pTempGradeLinkIdexStru->wGradeCount++] = pGradeStru->wId; + } + else + { + chFlag = 0U; + } + + j = 0; + while(0xffff != (pGradeStru->wIncludeLinkId[j])) + { + pTempGradeLinkIdexStru = g_dsuEmapExtendStru->pDsuGradeInLinkIdx; + pTempGradeLinkIdexStru = pTempGradeLinkIdexStru+pGradeStru->wIncludeLinkId[j]; + if (pTempGradeLinkIdexStru->wGradeCount < LINK_MAX_GRADE_NUM) + { + pTempGradeLinkIdexStru->wGradeId[pTempGradeLinkIdexStru->wGradeCount++] = pGradeStru->wId; + } + else + { + chFlag = 0U; + } + j++; + } + + pTempGradeLinkIdexStru = g_dsuEmapExtendStru->pDsuGradeInLinkIdx; + pTempGradeLinkIdexStru = pTempGradeLinkIdexStru+pGradeStru->wTmnlLinkId; + if (pTempGradeLinkIdexStru->wGradeCount < LINK_MAX_GRADE_NUM) + { + pTempGradeLinkIdexStru->wGradeId[pTempGradeLinkIdexStru->wGradeCount++] = pGradeStru->wId; + } + else + { + chFlag = 0U; + } + } + + /*ѭֲи*/ + if (DQU_QFUN_TRUE == EmapCalcLoopStepLenCtrl(wIndex)) + { + chReturnValue = 2; + break; + } + } + if (wIndex == dsuDataLenStru->wGradeLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop = 0; + chReturnValue = 1; + } + } + + if ( 0U== chFlag) + { + /*ʧ*/ + chReturnValue = 0; + } + } + else + { + /*ڴռʧ*/ + chReturnValue = 0; + } + } + else + { + /*ӵͼȫָΪգʧ*/ + chReturnValue = 0; + } + return chReturnValue; +} + +/* +ܣɾظڲʹú +˵input 飻len С + :ȥغ +ֵȥغij +author: qxt 20180716 +*/ +static UINT8 RemoveRep(UINT16 input[],UINT8 len,UINT16 output[]) +{ + UINT8 i=0U , j=0U; + UINT8 flag=1;/*ظǣ1ظ0ظ*/ + UINT8 count=0U;/*ֵ*/ + + /**/ + if (len>0) + { + output[count++]=input[0];/*ȸĵһֵֵ*/ + for (i=1;idsuDataLenStru) && (NULL != g_dsuEmapStru->dsuStaticHeadStru)&&(NULL != g_dsuEmapStru->dsuEmapIndexStru)) + { + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuEmapIndexStru = g_dsuEmapStru->dsuEmapIndexStru; + + if (DQU_QFUN_TRUE==EmapCalcFunStepCtrl(0x02)) + { + /*SPKS*/ + for (i = g_struCalcTaskTab[g_wCurCalcStruProg].wCurInitPos; i < dsuDataLenStru->wSpksButtonLen; i++) + { + + pSPKSStru = dsuStaticHeadStru->pSpksButtonStru + i; + iTempIndex=0; + /**/ + for(j=0;jwPhysicalSgmtNum;j++) + { + /*αѰ뵱ǰӦļΣ㵱ǰLINK*/ + for(k=0;kwAxleSgmtLen;k++) + { + if(SPKS_INCLUDE_LINK_NUM > iTempIndex) + { + pAxleSgmtStru=dsuStaticHeadStru->pAxleSgmtStru+k; + if(pAxleSgmtStru->wRelatePhysicalSgmtId == pSPKSStru->wRelatePhysicalSgmtId[j]) + { + /*洢LINK*/ + arTempLink[iTempIndex++]=pAxleSgmtStru->wOrgnLkId; + /*洢мLINK*/ + for(n=0;n iTempIndex) + { + if(DSU_NULL_16!=pAxleSgmtStru->wMiddleLinkId[n]) + { + arTempLink[iTempIndex++]=pAxleSgmtStru->wMiddleLinkId[n]; + } + } + } + /*洢յLINK*/ + arTempLink[iTempIndex++]=pAxleSgmtStru->wTmnlLkId; + } + } + } + + } + if(0U==iTempIndex)/*ԽδҵӦlink*/ + { + rtnValue=0U; + break; + } + else + { + /*ȥظLink*/ + pSPKSStru->wLinkNum=RemoveRep(arTempLink,iTempIndex,pSPKSStru->wIncLinkId); + + } + + /*ѭֲи*/ + if (DQU_QFUN_TRUE==EmapCalcLoopStepLenCtrl(i)) + { + rtnValue=2; + break; + } + } + if(i == dsuDataLenStru->wSpksButtonLen) + { + g_struCalcTaskTab[g_wCurCalcStruProg].bIsInTheLoop=0; + rtnValue = 1; + } + } + else + { + /**/ + } + } + else + { + /*ӵͼȫָΪգʧ*/ + rtnValue = 0U; + } + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initEa(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData = NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_EMAP_EA_STRU *pCurrentStru = NULL; /*ṹʱָ*/ + DSU_EMAP_EA_STRU stru = { 0 }; /*ṹʱָ*/ + UINT16 j = 0; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru = NULL; + + + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru = g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wEaLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize / rowCount; + + /*鳤ȼ*/ + initFlag=EA_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->EAINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if (0x01 == g_IsEmapAllocMemory) + { + /*̬ռ*/ + dsuEmapIndexStru->dsuEaIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->EAINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsuEaIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsuEaIndex, 0xFF, dsuEmapIndexStru->EAINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pEaStru = (DSU_LINK_STRU *)MyNew(sizeof(DSU_LINK_STRU) * dsuDataLenStru->wEaLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pEaStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pEaStru, 0xFF, sizeof(DSU_LINK_STRU) * dsuDataLenStru->wEaLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataStruArrayLen(EMAP_EA_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wEaLen >= wStruDataLen)) + || (0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue = 0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetEmapDataIndexArrayLen(EMAP_EA_ID, &wDataIndexLen); + if (((0 != wDataIndexLen) && (dsuEmapIndexStru->EAINDEXNUM >= wDataIndexLen)) + || (0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue = 0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ Զ۷ ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wEaLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pEaStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag =EA_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsuEaIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE == initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j == dsuDataLenStru->wEaLen)) + { + rtnValue = 1U; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[߼SPKSر]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initLogSecSpksButton(UINT8* pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8* pData = NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_LOGSEC_SPKS_BUTTON_STRU* pCurrentStru = NULL; /*ṹʱָ*/ + DSU_LOGSEC_SPKS_BUTTON_STRU stru = { 0 }; /*ṹʱָ*/ + UINT16 j = 0U; + static UINT32 rowDataLen = 0U; + UINT16 wStruDataLen = 0U; + UINT16 wDataIndexLen = 0U; + + /*ӵͼ*/ + DSU_EMAP_INDEX_STRU* dsuEmapIndexStru = NULL; + DSU_STATIC_HEAD_STRU* dsuStaticHeadStru = NULL; + DSU_DATA_LEN_STRU* dsuDataLenStru = NULL; + + if ((0U != rowCount) && (0U != g_dsuEmapStru->dsuDataLenStru->wSpksButtonLen)) + { + debug_infor_printf("InitLogSecSpksButton fail,Reason:PhySecSpks is not 0 rowCount"); + rtnValue = 0U; + } + else + { + if ((NULL != pDataAddr) && (NULL != g_dsuEmapStru)) + { + dsuEmapIndexStru = g_dsuEmapStru->dsuEmapIndexStru; + dsuStaticHeadStru = g_dsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru = g_dsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + rtnValue = 0U; + } + } + initFlag = EmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuDataLenStru->wLogSecSpksLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1; + } + else + { + rowDataLen = dataSize / rowCount; + + /*鳤ȼ*/ + initFlag = DSU_LOGSEC_SPKS_BUTTON_STRU_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuEmapIndexStru->LOGSECSPKSINDEXNUM = stru.wId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = EmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if (0x01 == g_IsEmapAllocMemory) + { + /*̬ռ*/ + dsuEmapIndexStru->dsulogSecSpksIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuEmapIndexStru->LOGSECSPKSINDEXNUM + 2); + + /*̬ռʧ*/ + if (NULL == dsuEmapIndexStru->dsulogSecSpksIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuEmapIndexStru->dsulogSecSpksIndex, 0xFF, dsuEmapIndexStru->LOGSECSPKSINDEXNUM * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticHeadStru->pLogSecSpksButtonStru = (DSU_LOGSEC_SPKS_BUTTON_STRU*)MyNew(sizeof(DSU_LOGSEC_SPKS_BUTTON_STRU) * dsuDataLenStru->wLogSecSpksLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticHeadStru->pLogSecSpksButtonStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticHeadStru->pLogSecSpksButtonStru, 0xFF, sizeof(DSU_LOGSEC_SPKS_BUTTON_STRU) * dsuDataLenStru->wLogSecSpksLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӵͼӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataStruArrayLen(EMAP_LOGSEC_SPKS_BUTTON_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuDataLenStru->wLogSecSpksLen >= wStruDataLen)) + || (0U == wStruDataLen) || (0U == checkFlag)) + { + rtnValue = 0U; + } + else + { + /*ӵͼжӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetEmapDataIndexArrayLen(EMAP_LOGSEC_SPKS_BUTTON_ID, &wDataIndexLen); + if (((0U != wDataIndexLen) && (dsuEmapIndexStru->LOGSECSPKSINDEXNUM >= wDataIndexLen)) + || (0U == wDataIndexLen) || (0U == checkFlag)) + { + rtnValue = 0U; + } + } + } + } + + initFlag = EmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵ ߼SPKS ṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuDataLenStru->wLogSecSpksLen; j++) + { + pCurrentStru = dsuStaticHeadStru->pLogSecSpksButtonStru + j; + + pData = pDataAddr + rowDataLen * j; + /*ݽṹ*/ + initFlag = DSU_LOGSEC_SPKS_BUTTON_STRU_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U; + } + else + { + /*ɶӦ*/ + dsuEmapIndexStru->dsulogSecSpksIndex[pCurrentStru->wId] = j; + initFlag = EmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE == initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j == dsuDataLenStru->wLogSecSpksLen)) + { + rtnValue = 1; + } + } + return rtnValue; +} \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquEmapInit.h b/TSCP/src/dqu_common/dqu_emap_common/dquEmapInit.h new file mode 100644 index 0000000..7bb7540 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquEmapInit.h @@ -0,0 +1,702 @@ +/************************************************************************ +* +* ļ dquEmapInit.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ +* +* ӵͼʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_EMAP_INIT_H +#define DQU_EMAP_INIT_H + +#include "string.h" +#include "Convert.h" +#include "dfsDataRead.h" +#include "dsuVar.h" +#include "dquStructInit.h" +#include "dquQueryExp.h" +#include "dquDataTypeDefine.h" +#include "CommonMemory.h" + +#define INIT_ERR_NUM 100 /*ݻͨݽṹV15.0.0ӱҪֵ50Ϊ100ںչmodify by sds 20181116*/ + +extern UINT8 initErrNo[INIT_ERR_NUM]; /*ݳʼʧܹϺ*/ +#define DEBUG_GET_DATA_FAIL 0x01 /*ȡʧ*/ +#define DEBUG_DATA_LENTH_FAIL 0x02 /*ݳ*/ +#define DEBUG_CALC_FAIL 0x04 /*̴*/ + +#define DQU_EMAP_VER1 66 /*Ʒ*/ +#define DQU_EMAP_VER2 17 /*ģ*/ +#define DQU_EMAP_VER3 0 /*ģ汾*/ +#define DQU_EMAP_VER4 0 /*ģӰ汾*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/********************************************* +*ܣӵͼģ汾Żȡ +*˵ϵͳòѯ汾ţֹɴ +*ڲ +*ڲ +*ֵUINT32ʾİ汾 +*********************************************/ +UINT32 GetDquEmapVersion(); + +/*ʼӵͼ*/ +UINT8 dfsEmapInit (CHAR * FSName); + +/************************************************************ +*ܣùͣԵĹϢ򲻽й +*˵ +* filterAttr:Ϣ +*ֵ +*޸ļ¼add by sds 2019-10-22 +*************************************************************/ +void SetFilterStopPointAttr(UINT32 filterAttr); + +/**************************************** +*ܣʼӵͼչӿ +*˵pDataBuf,ݿ飬 +* dsuEmapStru,ⲿʵӵͼ洢ṹָ룬 +* dsuLimitStcLinkIdx,ⲿʵ徲̬linkṹָ룬 +* mode,ģʽ1ϵһμأ2ʱδ +* timeSliceִеʱƬλ룩 +*ֵ 0ʧܣ1ɹ2ֲδ +*****************************************/ +UINT8 dfsEmapInitExp(UINT8 * pDataBuf,DSU_EMAP_STRU *dsuEmapStru,DSU_STC_LIMIT_LINKIDX_STRU *dsuLimitStcLinkIdx,UINT8 mode,UINT16 timeSlice); + + +/*ӵͼʼϣִеӵͼڲ*/ +UINT8 dfsEmapInitFinally(); + +/************************************************************ +*ܣ +*˵ +*ֵ0ʧܣ1ɹ +* + νṹ + + UINT16 wOrgnRelatPointId; + UINT16 wOrgnMainAxleSgmtId; Ӷλα + UINT16 wOrgnSideAxleSgmtId; ӷλα + UINT16 wTmnlRelatPointId; յ + UINT16 wTmnlMainAxleSgmtId; յӶλα + UINT16 wTmnlSideAxleSgmtId; յӷλα + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[3]; α + UINT16 wManageZC; ZC + UINT16 wManagePhysicalCI; CI + UINT32 dwOrgnLinkOfst; linkƫ + UINT32 dwTmnlLinkOfst; յlinkƫ + UINT16 wMiddleLinkId; мlink +************************************/ +UINT8 AxleSgmtStru(); + +/************************************************************ +*ܣ߼ +*˵ +*ֵ0ʧܣ1ɹ +* UINT16 wMiddleLinkId; ߼мlink + UINT16 wMainOrgnLogicSgmtId; ǰ߼εı + UINT16 wMainTmnlLogicSgmtId; ں߼εı +************************************/ +UINT8 LogicSgmtStru(); + +/********************************************* +*ܣ·ݽṹ +*˵ +*ֵ0ʧܣ1ɹ + UINT16 wIncludeAxleSgmtNum; ·ļĿ + UINT16 wIncludeAxleSgmtId[8]; ļα + UINT16 wAxleSgmtLockStatus[8]; ļ״̬ + + UINT16 wObsNum; ·ϰĿ + UINT16 wObsType[8]; ϰ + UINT16 wObsID[8]; ϰID + UINT16 wObsNeedLockStatus[8]; ϰҪ״̬ +*********************************************/ +UINT8 RouteStru(); + +/********************************************* +*ܣɱ +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 ProtectLink(); + +/********************************************* +*ܣ¶ +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 Grade(); + +/********************************************* +*ܣĬгб +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 DefaultRouteStru(); + +/********************************************* +*ܣݽӽIDȡӽΰĵ״̬ +*˵ + AccessLinkId ӽID + RelatePointNum + RelatePointId[] ID + RelatePointSta[] ״̬ +*ֵ 0 ʧܣ1ɹ +*********************************************/ +UINT8 GetPointInfoFromAccessLink(UINT16 AccessLinkId,UINT16 Dirction,UINT16 * RelatePointNum,UINT16 RelatePointId[],UINT16 RelatePointSta[]); + +/************************************** +ܣlinkлüα +linkId ׵ַLinkNum link +AxleSgmtId αַ + AxleSgmtNum 鳤 +ֵ0ʧܣ1ɹ +***************************************/ +UINT8 GetAxleSemtIdFromLinkId(UINT16* linkId,UINT16 LinkNum,UINT16 *AxleSgmtId,UINT16 * AxleSgmtNum); + +/********************************************* +*ܣݽ·linkУϰϢ +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 GetObstacleFromRoute(DSU_ROUTE_STRU* pRouteStru); + +/********************************************* +*ܣͣϢ +*˵ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 CalculateStopPoint(void); + +/********************************************** +ܣʼ[ռλ]:ֻռλݱһ +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ: 1 ɹ +޸ļ¼add by sds 2019-10-22 +**********************************************/ +UINT8 initNop(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[link]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initLink(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPoint(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[źŻ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSignal(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ӧ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initBalise(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAxle(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initScreen(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ͣť]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initEmergStop(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ͣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStation(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ͣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStopPoint(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAxleSgmt(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[߼]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initLogicSgmt(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[·]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initRoute(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initProtectLink(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ʽӽ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initBLOCAccessLink(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[CBTCӽ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCBTCAccessLink(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[¶Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initGrade(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[̬Ϣ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStaticResSpeed(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ĭг]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initDefaultRout(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[վӪ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initRunLevel(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[˳CBTC]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initExitRoute(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[CBTC]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initTrainLine(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Զ۷]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAR(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ZCϢ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initZCComZone(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[CIϢ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCI(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ATSϢ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initATS(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ͳһϢ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initConResSpeed(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ͳһ¶Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initConGrade(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ZCֽϢ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initZCDividPoint(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPhysicalSgmt(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ʽ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initBlocTrgArea(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[CBTC]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCbtcTrgArea(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[վ̨]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPlatForm(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[·]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initComeGoRoute(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initFloodGate(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[SPKSϢ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSpksButton(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initDepotGate(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initTunnel(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ZCϢ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initZC(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[࿪Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initMultiPoint(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPowerlessZone(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ϣ]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCarStop(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************* +ܣʼͣϢ +UINT8 *pDataAddr, ڴַ + UINT32 DataSize, ݱֽ + UINT16 rowCount, ݱ + +ֵ 2δ꣬1ɹ0ʧ +עݻͨݽṹV18.0.0ӣadd by sds 20200211 +*********************************************/ +UINT8 initAdjtStation(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/************************************************************************** +* : ʼPSC +* : UINT8 *pDataAddr, ڴַ + UINT32 DataSize, ݱֽ + UINT16 rowCount, ݱ +* : +* : +* ȫֱ: +* ֵ: 2δ꣬1ɹ0ʧ +8 ޸ļ¼: +* 1ݻͨݽṹV20.0.0ӣadd by sds 2020-8-18 +**************************************************************************/ +UINT8 initPSC(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/*** +ܣȡ + +errRecord飬errRecordLen鳤 +ֵ1ɹ +***/ +UINT8 dquGetErrNo(UINT8* errRecord,UINT32 * errRecordLen); + +/************************************************ +ܣ̬ϢӦIJLinkΪıУ + ŻѯǰLINKʹá + +@linkId:ǰ̬ٱŶӦLINKţpCurrentStaticResSpeedStru->wLinkId +@limitStcSpdId:ǰ̬ٱţpCurrentStaticResSpeedStru->wId + +ֵ1ɹ 0ʧ +************************************************/ +UINT8 InsertToLimitStcLinkIdx(UINT16 linkId,UINT16 limitStcSpdId); + +/* +ܣݵͶ࿪ȡʵ +˵ +ֵ1ɹ 0ʧ +author:Ŀ qxt 20170626 +*/ +UINT8 GetPhyiscalSwitches(); + +/* +ܣLink豸ӳϵ +˵ +ֵ1ɹ 0ʧ +author: qxt 20170816 +*/ +UINT8 GetDeviceInfoInLink(); + +/************************************************* +ܣLink¶ȼӳϵ + ¶ID¶ӦIJLinkΪıУ + ŻѯǰLINK¶ +˵ +ֵ2ʾǰûд꣬Ҫٴεô˺ 1ʾɹ 0ʾʧ +author: lmy 20180122 +*************************************************/ +UINT8 GetGradeInfoCrossLink(); + +/* +ܣSPKSLink +˵ +ֵ2ʾǰûд꣬Ҫٴεô˺ 1ʾɹ 0ʾʧ +author: qxt 20180716 +*/ +UINT8 CalcSPKSIncLinks(); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ +dataSize:ֽڳ +rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initEa(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[߼SPKSر]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initLogSecSpksButton(UINT8* pDataAddr, UINT32 dataSize, UINT16 rowCount); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquQuery.c b/TSCP/src/dqu_common/dqu_emap_common/dquQuery.c new file mode 100644 index 0000000..837276b --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquQuery.c @@ -0,0 +1,1007 @@ +/************************************************************************ +* ļ dsuQuery.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2009.09.26 +* +* dsuѯļ +* ʹע +* ޸ļ¼ +************************************************************************/ +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "dquQuery.h" +#include "dquQueryExp.h" +#include "dquCbtcType.h" + +static DSU_EMAP_STRU *qds_dsuEmapStru=NULL; +static DSU_STC_LIMIT_LINKIDX_STRU *qds_dsuLimitStcLinkIdx=NULL; + +/*õǰԴ*/ +UINT8 dquSetCurrentQueryDataSource(DSU_EMAP_STRU *pDsuEmapStru,DSU_STC_LIMIT_LINKIDX_STRU *pDsuLimitStcLinkIdx) +{ + UINT8 chReturnValue=0U; /*ںֵ*/ + UINT8 CbtcVersionType=0U; + + CbtcVersionType = GetCbtcSysType(); + + if ((DQU_CBTC_FAO == CbtcVersionType)||(DQU_CBTC_HLT == CbtcVersionType)) + { + if (NULL!=pDsuEmapStru) + { + qds_dsuEmapStru=pDsuEmapStru; + chReturnValue=1; + } + else + { + chReturnValue=0U; + } + } + else + { + if ((NULL!=pDsuEmapStru) && (NULL!=pDsuLimitStcLinkIdx)) + { + qds_dsuEmapStru=pDsuEmapStru; + qds_dsuLimitStcLinkIdx=pDsuLimitStcLinkIdx; + chReturnValue=1; + } + else if((NULL != pDsuEmapStru) && (DQU_CBTC_CC == CbtcVersionType)) + { + qds_dsuEmapStru = pDsuEmapStru; + chReturnValue = 1; + } + else + { + chReturnValue=0U; + } + } + return chReturnValue; +} +/* +* зϢԼ״̬Ϣѯõǰlinkзlink +* UINT16 LinkId, ǰLink +* UCHAR Direction, ǰ +* UCHAR PointNum, Ϣ +* const POINT_STRU *pPointStru, Ϣ +* UINT16 *pLinkIdǰLinkLink +* ֵ 1,ѯɹ +* 0,ѯʧ,Чʧ +* 0xFF,·յ㣬δҵ +* +*/ +UINT8 dsuGetAdjacentLinkID(UINT16 LinkId, UCHAR Direction, UCHAR PointNum,const DQU_POINT_STATUS_STRU *pPointStru,UINT16 *pLinkId) +{ + return dsuGetAdjacentLinkIDExp(qds_dsuEmapStru,LinkId,Direction,PointNum,pPointStru,pLinkId); +} + + +/* +* ܺݵǰλãλԼĵϢõλ. +һ㼴ǰLnk㣬һLinkյ㣬뵱ǰpLODStruLink Id +* const LOD_STRU * pLODStru, ǰλ +* INT32 Displacement, λƣзţΪʾȡ +* UCHAR PointNum, +* const POINT_STRU * pPointStru, Ϣ +* LOD_STRU *pNewLODStru λ +* ֵ 1,ɹ +* 0,ʧ +*/ +UCHAR dsuLODCalcu(const LOD_STRU *pLODStru, INT32 Displacement, UCHAR PointNum, const DQU_POINT_STATUS_STRU *pPointStru, LOD_STRU *pNewLODStru) +{ + return dsuLODCalcuExp(qds_dsuEmapStru,pLODStru,Displacement, PointNum,pPointStru,pNewLODStru); +} + +/* +*ʽӿ +* ABλõõλơ +* const LOD_STRU * pLODAStru, Aλ +* const LOD_STRU * pLODBStru, Bλ +* UINT8 PointNum, +* const POINT_STRU * pPointStru, Ϣṹ +* INT32 *Displacement ABλƣзűʾ +* ֵ 1,ɹ +* 0,ʧ +* ʹע⣺Ͽ෿Ŀ:BķңABλLinkBΪգ + ͨĿ߼仯㣬㷨ΪAķңABλLinkAΪա +* author:qxt 20170811 +*/ +UINT8 dsuDispCalcuByLOC(const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, INT32 *Displacement) +{ + return dsuDispCalcuByLOCExp(qds_dsuEmapStru, pLODAStru, pLODBStru,PointNum,pPointStru,Displacement); +} + + +/* +* ܣ ˺ĹDzѯλülinkС +* **************************************************************************************************** +* 1 2 3 4 5 6 +* --------------*-------------------------------------------*----------------- +* S E +* ͼ Link˵㡣*ѯλá123...Linkʾ +* ͼʾLink34Ϊ +* ˴pLODEndStruң +* SpLODEndStru->DirңҵE򷵻سɹҲ򷵻ʧܡ +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru նλ +* const UINT8 PointNum Ŀ +* const POINT_STRU * pPointStru Ϣ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* ֵ 0, ѯʧ +* 1, ѯɹ +* ʹע⣺ Ŀǰûа˵Link Id +* Ҫ֮γ򣬷򷵻0 +*/ + +UINT8 dsuGetLinkBtwLoc(const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum,const DQU_POINT_STATUS_STRU *pPointStru, + UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], UINT16 *wLinkNumber) +{ + return dsuGetLinkBtwLocExp(qds_dsuEmapStru,pLODStartStru,pLODEndStru,PointNum,pPointStru,wLinkID,wLinkNumber); +} + + +/* +* ܣ ˺ĹǽжϵǰλǷָΧڡ +* **************************************************************************************************** +* +* --------------*--------------------*---------------------*----------------- +* S C E +* Ͽ෿Ŀ 㷨ΪλDisplacementSCDisplacementCEλƷͬ˵CSE +* ͨĿ߼仯㣩 㷨ΪλDisplacementCSDisplacementCEλƷŲͬ˵CSE +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* const UINT8 PointNum, Ŀ +* const POINT_STRU * pPointStru, Ϣ +* const LOD_STRU * pCurrentLODStru,ǰλ +* ڲ UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +* ʹע⣺1.ڵǰλ˵λʱʱ¹жϣ +* 1) ǰλ㣬Ϊõڱ +* 2) ǰλյ㣬Ϊõ㲻ڱ +* 3) 3غϷڡ +* 2.ҵյ㶼ڣԵαʼնλãֻҪεһڣ˵ڵʼնγɵı +* 3.SE򲻴ڣ0ʧܡSC,SEڣ1ɹǵC +* 4.෿ͺϿĿʼλúնλôķ豣֤һ +* ֤ͨʼλõķȷɡ +*/ +UINT8 dsuCheckLocInArea(const LOD_STRU * pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, + const LOD_STRU *pCurrentLODStru,UINT8 *pLocInArea) +{ + return dsuCheckLocInAreaExp(qds_dsuEmapStru,pLODStartStru,pLODEndStru,PointNum,pPointStru,pCurrentLODStru,pLocInArea); +} + +/************************************************************************ + +ܣ ˺ĹlinkIDϢѯlinkijϢ +ڲ const UINT16 wLinkID linkID +ڲ +ֵ UINT32 dwLinkLength ѯʧ: 0xffffffff; ѯɹ: زҵlink +************************************************************************/ +/*ܺѯlink*/ +UINT32 LinkLength(UINT16 wLinkID) +{ + return LinkLengthExp(qds_dsuEmapStru,wLinkID); +} + +/* +* ܣ ˺ĹǽжϵǰλǷָΧڡ +˺ĹCheckLocInAreaġCheckLocInAreaԷûҪ󣬼漰ķȷġ +CheckLocInAreaQuickҪStartLODܹEndLOD +* **************************************************************************************************** +* +* --------------*--------------------*---------------------*----------------- +* S C E +* 㷨ΪжϵǰλSEǷͬһLinkϣ +* ͬһLinkϣݷλжǷڣͬһLinkжCLinkIdǷSE֮ijһLinkIdͬ +* ֮LinkԱԶڶεñѯǷڵĺЧʺа +* +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* const LOD_STRU * pCurrentLODStru,ǰλ +* ڲ UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +* ʹע⣺1.ڵǰλ˵λʱʱ¹жϣ +* 1) ǰλ㣬Ϊõڱ +* 2) ǰλյ㣬Ϊõ㲻ڱ +* 3) 3غϷڡ +* 2.ҵյ㶼ڣԵαʼնλãֻҪεһڣ˵ڵʼնγɵı +* 3.SE򲻴ڣ0ʧܡSC,SEڣ1ɹǵC +*/ +UINT8 dsuCheckLocInAreaQuick(const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT16 wLinkNumber,UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea) +{ + return dsuCheckLocInAreaQuickExp(qds_dsuEmapStru,pLODStartStru,pLODEndStru,wLinkNumber,wLinkID,pCurrentLODStru,pLocInArea); +} + +/* +* ܣ ˺ĹжϵǰλǷָΧڣ˺ǶdsuCheckLocInAreaQuick +һ䡣ڽǰȡټǷڡ +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* const LOD_STRU * pCurrentLODStru,ǰλ +* UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +*/ +UINT8 dsuCheckLocInAreaQuick2(const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT16 wLinkNumber,UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea) +{ + return dsuCheckLocInAreaQuickExp2( qds_dsuEmapStru,pLODStartStru,pLODEndStru,wLinkNumber,wLinkID,pCurrentLODStru,pLocInArea); +} + +/*****************************Ϊ¶ƽҪõĺ**************************/ +/************************************************************************ + +ܣ ˺ĹDzѯǰGardeGrade +ڲ const UINT16 wCurrentGradeID ǰ¶ȱ +const UCHAR chDirection з +const UCHAR PointNum MAΧڵĿ +const DQU_POINT_STATUS_STRU * pPointStru MAΧڵϢ +ڲ +ֵ UINT16 wFindGradeID ѯʧ: 0xffff; ѯɹ: ڵ¶ID +************************************************************************/ +/*ܺ,ѯǰGardeGrade*/ +UINT16 FindAdjacentGradeID(const UINT16 wCurrentGradeID, const UCHAR chDirection, const UCHAR PointNum, + const DQU_POINT_STATUS_STRU * pPointStru) +{ + return FindAdjacentGradeIDExp(qds_dsuEmapStru,wCurrentGradeID,chDirection,PointNum,pPointStru); +} +/* +*ܣѯij¶ID +*UINT16 linkId,UINT32 offset +*UINT16 GradeID¶ID +*ֵ 0ִʧܣ1ɹ +*/ +UINT8 dsuGetGradeIdbyLoc(const UINT16 linkId,const UINT32 offset,UINT16* GradeID) +{ + return dsuGetGradeIdbyLocExp(qds_dsuEmapStru,linkId,offset,GradeID); +} +/************* +*ܣij¶ƽ¶ֵ +*Point ¶ȵ +* +*ֵ 0ִʧ 1 ¶ȵһ 2 ¶ȵ2 3 ¶ȵ3 +****************/ +UINT8 dsuCalculateGradeValue(UINT16 LinkId,UINT32 ofst,FLOAT32* GradeVal) +{ + return dsuCalculateGradeValueExp(qds_dsuEmapStru,LinkId,ofst,GradeVal); +} + +/************* +*ܣij¶ƽ󣬷ֳɵļֵķֽľ +*gradeId ¶ID +*UINT32* endPointDistance UINT32* startPointDistance +*ֵ 0ִʧ 1ɹ +ע Ҫƽĵ㣬ΪЧֵffffffff ֵΪ1 +****************/ +UINT8 dsuDividPointDistanceFromOrigin(UINT16 GradeId,UINT16 linkId,UINT32* endPointDistance,UINT32* startPointDistance) +{ + return dsuDividPointDistanceFromOriginExp(qds_dsuEmapStru,GradeId,linkId,endPointDistance,startPointDistance); +} + +/************* +*ܣ¶ijһ㼰¶idõ¶ľ +*gradeId ¶ID +UINT16 linkId UINT32 Ofst +*UINT32 *length + +*ֵ 0ִʧ 1ɹ +****************/ +UINT8 dsuGetDistanceFromOrigin(UINT16 GradeId,UINT16 linkId,UINT32 Ofst,UINT32* length) +{ + return dsuGetDistanceFromOriginExp(qds_dsuEmapStru,GradeId,linkId,Ofst,length); +} + +/************************************************************************ + +ܣ ˺ĹDzѯλü¶ȡѯ +յ㷶Χе·¶ȣ¶ȣ£涨 +ΪΪĹܼΪΧ¶ȵСֵ +¶ȵǧ + +ڲ const LOD_STRU * pLODStartStru ѯλúͷʵΪгβλúͷ +const LOD_STRU * pLODEndStru ѯյλúͷ +const UCHAR PointNum MAеĵ +const POINT_STRU * pPointStru Ϣṹ +ڲ FLOAT64 * Gradient гβMAյ㷶Χ¶ȵǧΪΪ +ֵ UCHAR bReturnValue +0ѯʧܣ +1ѯȷ +עڼĹУõֵֵǰ/10IJ˷ +¶ֵΪǧֵ +************************************************************************/ +/*14 λü¶Ȳѯ*/ +UCHAR dsuGradientGet(const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + const UCHAR PointNum, const DQU_POINT_STATUS_STRU * pPointStru, FLOAT32 * Gradient) +{ + return dsuGradientGetExp(qds_dsuEmapStru,pLODStartStru,pLODEndStru,PointNum,pPointStru,Gradient); +} + +/* +ܣжϺһ¶ȵ¶ֵǰһ¶ȵ¶ֵӣ仯Ǽ +UINT16 fistGradeID,UINT16 secondGradeID +GradeTrend ¶ +1 +2 +0 仯 +ֵ0ʧ 1ɹ +*/ +UINT8 dquGradeTrend(UINT16 fistGradeID,UINT16 secondGradeID,UINT8 *GradeTrend) +{ + return dquGradeTrendExp(qds_dsuEmapStru,fistGradeID,secondGradeID,GradeTrend); +} + +/* +ܣȡǰ¶ +UINT16 linkId,ǰlink +gradeFrnt ¶ +Null ·յǰ¶Ϊͳһ¶ +Nullǰ¶¶ȱпɲ +ֵ0ʧ 1ɹ 2·յ +*/ +UINT8 dsuGetGradeFrnt(UINT16 linkId, DSU_GRADE_STRU** gradeFrnt) +{ + return dsuGetGradeFrntExp(qds_dsuEmapStru,linkId,gradeFrnt); +} + +/* +ܣȡ¶ +UINT16 linkId,ǰlink +gradeRear ¶ +Null ·յ¶Ϊͳһ¶ +Null¶¶ȱпɲ +ֵ0ʧ 1ɹ 2·յ +*/ +UINT8 dsuGetGradeRear(UINT16 linkId, DSU_GRADE_STRU** gradeRear) +{ + return dsuGetGradeRearExp(qds_dsuEmapStru,linkId,gradeRear); +} + +/** +ܣȡǰLINKľ̬ٸ + +@linkIdǰlink + +ֵ̬ٸ +*/ +UINT8 GetStcLmtSpdCntByLnkId(const UINT16 linkId) +{ + return GetStcLmtSpdCntByLnkIdExp(qds_dsuEmapStru,qds_dsuLimitStcLinkIdx,linkId); +} + +/** +ܣȡƶLINKĵָ±ľ̬ʱٵĶָ + +@linkIdǰLink +@idxӦLinkĵڼ٣±ȡֵΧ0-9 +ֵ +@NULLȡʧ +@ǿգӦٽṹָ +*/ +DSU_STATIC_RES_SPEED_STRU *GetStcLmtSpdInfoByLnkId(const UINT16 linkId,const UINT8 idx) +{ + return GetStcLmtSpdInfoByLnkIdExp(qds_dsuEmapStru,qds_dsuLimitStcLinkIdx,linkId,idx); +} + + +/* +ܣ࿪תΪ +multiPointId ࿪ + multiPointState ࿪״̬ + +wVirtualPointIds ֺ + wVirtualPointStates ֺ״̬ +ֵֵֺ, 0ʧ + +㷨࿪ NλR1λL1λR2λL2λ + Ӧе 0 1 2 3 4 + ӦĶ࿪״̬ 1 2 3 4 5 + ˵ =࿪״̬multiPointState-1 ʱӦԭֵ״̬ȡλ<=>λ + +עwVirtualPointIds״̬wVirtualPointStatesЧ״̬Ϊ3 + + / L / L + / / + / / 101 + -|------------------------ === ---|------/----------------- N + 1 \ N 102 \ + \ \ + \ \ + R R + ͼ1.ʵ ͼ2.ⵥ + + ͼ1ʵ1״̬Ϊ3ʱƳͼ2ⵥΪLλʱ101ΪЧ״̬Ϊ3ֵΪ2 + wVirtualPointIds[0]=102; + wVirtualPointStates[0]=2; + wVirtualPointIds[1]=101; + wVirtualPointStates[1]=3; +author:Ŀ add by qxt 20170622 +*/ +UINT8 ConvertToVirtualSwitches(const UINT16 multiPointId,const UINT8 multiPointState,UINT16 wVirtualPointIds[MAX_VIRTUAL_SWITCH_NUM],UINT8 wVirtualPointStates[MAX_VIRTUAL_SWITCH_NUM]) +{ + return ConvertToVirtualSwitchesExp(qds_dsuEmapStru,multiPointId,multiPointState,wVirtualPointIds, wVirtualPointStates); +} + +/* +ܣתΪ࿪ +wVirtualPointIds[] + wVirtualPointStates[] ״̬ + wVirtualPointNum +multiPointId Ӧ࿪ + multiPointState Ӧ࿪״̬ +ֵ0ʧ 1ɹ + +עwVirtualPointIds״̬wVirtualPointStatesЧҪ롣 + + /L L + / / + / / + / / + ---|------/-----------\------ N =====> ------------------ N + 1 2 \ \ + \ \ + R R + ͼ1.ⵥ ͼ2.ʵ + + ͼ11״̬Ϊ2ʱƳͼ2࿪״̬ΪLλʱͼһ2ΪЧģΪ£ + wVirtualPointIds[0]=1; + wVirtualPointStates[0]=2; + wVirtualPointNum=1; +author:Ŀ add by qxt 20170622 +*/ +UINT8 ConvertToMultiSwitch(const UINT16 wVirtualPointIds[MAX_VIRTUAL_SWITCH_NUM],const UINT8 wVirtualPointStates[MAX_VIRTUAL_SWITCH_NUM],const UINT8 wVirtualPointNum,UINT16 *multiPointId,UINT8 *multiPointState) +{ + return ConvertToMultiSwitchExp(qds_dsuEmapStru,wVirtualPointIds, wVirtualPointStates, wVirtualPointNum,multiPointId,multiPointState); +} + +/************************************************ +*:ѯAB֮ľ +*: pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2021-2-28 +************************************************/ +UINT32 dsuLenByPoint(const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8* pDir) +{ + UINT8 cLinkDirChangedNum = 0U; + + return dsuLenByPointExp(qds_dsuEmapStru, pLODAStru, pLODBStru, pLinkNum, szLinkId, pDir, &cLinkDirChangedNum); +} + +/************************************************ +*:ѯAB֮ľ루ݵλã +*: pLODAStru A +* pLODBStru B +* cSwitchSum +* pSwitchInfo Ϣ +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2022-6-17 +************************************************/ +UINT32 dsuLenByPointAndSwitch(const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, const UINT8 cSwitchSum, const DQU_POINT_STATUS_STRU *pSwitchInfo ,UINT16* pLinkNum, UINT16 szLinkId[100], UINT8* pDir) +{ + return dsuLenByPointBySwitchStateExp(qds_dsuEmapStru, pLODAStru, pLODBStru, cSwitchSum, pSwitchInfo,pLinkNum, szLinkId, pDir); +} + +/************************************************ +*ܣѯAB֮Link仯 +*const LOD_STRU* pLODAStru A +* const LOD_STRU* pLODBStru B +* +*ֵʧܣUINT8_MAX +* ɹ仯 +************************************************/ +UINT8 GetDirChangeNumBtwPoints(const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru) +{ + UINT8 cDirChangedNum = UINT8_MAX; + UINT16 cLinkNum = 0U; + UINT16 szLinkId[100] = { 0U }; + UINT8 cDir = 0U; + UINT32 dwLen = 0U; + + if ((NULL != pLODAStru) && (NULL != pLODBStru)) + { + dwLen = dsuLenByPointExp(qds_dsuEmapStru, pLODAStru, pLODBStru, &cLinkNum, szLinkId, &cDir, &cDirChangedNum); + } + else + { + /*δ󣬲*/ + } + + return cDirChangedNum; +} + +/************************************************ +*:ѯAB֮ľ루طͷ仯 +*: pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2021-2-28 +************************************************/ +UINT32 dsuLenByPoint_GetDir(const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8* pDir, UINT8* pLinkDirChangedNum) +{ + + return dsuLenByPointExp(qds_dsuEmapStru, pLODAStru, pLODBStru, pLinkNum, szLinkId, pDir, pLinkDirChangedNum); +} + +/************************************************ +*:֮·ѯ +*: pDsuEmapStru ӵͼ +* pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +*ֵ:CI_ERRORʧ +* CI_SUCCESSɹ: +* by cgh 20250310 +************************************************/ +UINT8 TwoPointPathExp(DSU_EMAP_STRU* pDsuEmapStru, const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100]) +{ + UINT8 chReval = 0U; + /* ϵ· */ + UINT16 szSameDirPathA[25][50] = { 0U }; /*߼·*/ + UINT16 szPathASameDirLinkNum[25] = { 0U };/*߼·ӦLINKĿ*/ + UINT8 chSameDirPathANum = 0U;/*߼·Ӧ·Ŀ*/ + UINT8 szASameQueryDir[25] = { 0U }; /*Aͬѯ·ķ*/ + UINT8 chSearchNum = 0U;/*ѯ*/ + UINT8 chKeepSearchPathFlag = 0U;/*ѯ·־*/ + UINT8 chSameSearchFinishFlag = 0U;/*ͬɱ־*/ + UINT8 ii = 0U; + UINT16 jj = 0U; + UINT16 wAllPathLinkSum = 0U;/*·LINKĿ*/ + UINT16 szTempLinkId[100] = { 0U };/*·LINK*/ + UINT16 wSzLinkIndex = 0U;/*LINK*/ + + if ((NULL != pDsuEmapStru) && (NULL != pLODAStru) && (NULL != pLODBStru) && (NULL != pLinkNum) && (NULL != szLinkId)) + { + (void)CommonMemSet(szASameQueryDir, (UINT32)(sizeof(UINT8) * 25U), pLODAStru->Dir, (UINT32)(sizeof(UINT8) * 25U)); + + szSameDirPathA[0][0] = pLODAStru->Lnk; + szPathASameDirLinkNum[0] = 1U; + chSameDirPathANum = 1U; + + /*ѯʼֵΪҳɹ*/ + chKeepSearchPathFlag = 1U; + chSameSearchFinishFlag = 1U; + + chSearchNum = 1U; + while (1U == chKeepSearchPathFlag) + { + chKeepSearchPathFlag = 0U; + + if (2U != chSameSearchFinishFlag) + { + chSameSearchFinishFlag = PointBeginEndPathExp(pDsuEmapStru, pLODBStru, szASameQueryDir, &chSameDirPathANum, szSameDirPathA, szPathASameDirLinkNum); + } + else + { + ; + } + + if (2U == chSameSearchFinishFlag) + { + /* ѯյ˳ѭ */ + chKeepSearchPathFlag = 0U; + } + else + { + /* µ··δյ */ + chKeepSearchPathFlag = 1U; + } + + if (49U <= chSearchNum) + { + break; + } + else + { + ; /**/ + } + chSearchNum++; + } + + + wAllPathLinkSum = 0U; + chReval = 1U; + for (ii = 0U; ii < chSameDirPathANum; ii++) + { + if (pLODBStru->Lnk == szSameDirPathA[ii][szPathASameDirLinkNum[ii] - 1U]) + { + /*鵱ǰ·صǷõյ*/ + for (jj = 0; jj < szPathASameDirLinkNum[ii]; jj++) + { + for (wSzLinkIndex == 0U; wSzLinkIndex < wAllPathLinkSum; wSzLinkIndex++) + { + if (szSameDirPathA[ii][jj] == szTempLinkId[wSzLinkIndex]) + { + /*ѴڸLINK*/ + break; + } + else + { + ; + } + } + + if (wSzLinkIndex == wAllPathLinkSum) + { + /*ǰڸLINK*/ + if (100U > wAllPathLinkSum) + { + szTempLinkId[wAllPathLinkSum] = szSameDirPathA[ii][jj]; + wAllPathLinkSum++; + } + else + { + chReval = 0U; + break; + } + } + else + { + ; + } + + } + + if (0U == chReval) + { + break; + } + else + { + ; + } + } + else + { + ; /*ǣʼ*/ + } + } + + + if (1U == chReval) + { +#if 0 + if (0U == wAllPathLinkSum) + { + /*·ûҵյLINK*/ + chReval = 0U; + } + else + { + *pLinkNum = wAllPathLinkSum; + (void)CommonMemCpy((void*)szLinkId, (UINT32)(sizeof(UINT16) * 100U), (const void*)szTempLinkId, (UINT32)(sizeof(UINT16) * 100U)); + } +#endif + * pLinkNum = wAllPathLinkSum; + (void)CommonMemCpy((void*)szLinkId, (UINT32)(sizeof(UINT16) * 100U), (const void*)szTempLinkId, (UINT32)(sizeof(UINT16) * 100U)); + + } + else + { + ; + } + + } + else + { + ; /*ʧ*/ + } + + return chReval; +} + +/************************************************ +*:յ·ѯ +*: pDsuEmapStru +* pLODBStru B +* szLinkQueryDir linkѯ +* pPathNum · +* szPath · +* szLinkNum ÿ·ij +*: pPathNum · +* szPath · +* szLinkNum ÿ·ij +*ֵ:0:ʧ 1:ѯɹҸ·δյ 2ѯɹҸ·յ +* by cgh 20250310 +************************************************/ +UINT8 PointBeginEndPathExp(DSU_EMAP_STRU* pDsuEmapStru, const LOD_STRU* pLODBStru, UINT8 szLinkQueryDir[25], UINT8* pPathNum, UINT16 szPath[25][50], UINT16 szLinkNum[25]) +{ + UINT8 chReval = 0U; + UINT8 ii = 0U; + UINT8 jj = 0U; + UINT8 chPathNum = 0U;/*·Ŀ*/ + /*ε漰ȫֱ*/ + UINT16 LINKINDEXNUM = 0; + UINT16* pdsuLinkIndex = NULL; + DSU_STATIC_HEAD_STRU* pdsuStaticHeadStru = NULL; + UINT8 chTmpPathNum = 0U;/*ʱ·Ŀ*/ + UINT16 wTmpEndLinkId = 0U;/*ǰ·յLINK ID*/ + UINT8 chMainQueryDir = 0U; /*·IJѯ*/ + UINT8 chSideQueryDir = 0U; /*·IJѯ*/ + UINT8 chTmpEndPathNum = 0U; /*ҵյʱ鵽·Ŀ*/ + UINT8 chCurLinkDirChanged = LINK_DIRCHANGE_NONE; /*ǰLink仯*/ + UINT8 chNxtLinkDirChanged = LINK_DIRCHANGE_NONE; /*һLink仯*/ + UINT16 wTmpEndLinkIndex = 0U;/*ǰ·յLINK */ + DSU_LINK_STRU* pTmpEndLinkStru = NULL; /*ǰLink,ȡʹ*/ + UINT16 wTmpNextMainLinkId = 0U; /* һlink */ + UINT16 wTmpNextSideLinkId = 0U; /* һβlink */ + UINT8 chFunFlag = 0U; /* Ϊ0ʱ굱ǰ·Ϊ1ʱ굱ǰ·· */ + UINT16 wAddLinkId = 0U;/*ǰ·ҪӵLINK ID*/ + UINT16 wNewLinkId = 0U;/*Ҫ·LINK ID*/ + UINT16 wTmpPathLinkNum = 0U; /*ʱ·LINK Ŀ*/ + UINT8 chTempPathIndex = 0U;/*ʱ·*/ + UINT16 szTmpAddLinkNum[12] = { 0U };/*·LINKĿ*/ + UINT16 szTmpAddPath[12][50] = { 0U };/*·LINKϢ*/ + + if ((NULL != pDsuEmapStru) && (NULL != pLODBStru) && (NULL != szLinkQueryDir) && (NULL != pPathNum) && ((25U > *pPathNum)) && (NULL != szPath) && (NULL != szLinkNum)) + { + for (ii = 0U; ii < 25U; ii++) + { + /**/ + if ((EMAP_SAME_DIR == szLinkQueryDir[ii]) || (EMAP_CONVER_DIR == szLinkQueryDir[ii])) + { + chReval = 1U; + } + else + { + chReval = 0U; + break; + } + } + + /* γн */ + chPathNum = *pPathNum; + /* ȫֱ͸ */ + LINKINDEXNUM = pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + pdsuLinkIndex = pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + pdsuStaticHeadStru = pDsuEmapStru->dsuStaticHeadStru; + + if (1U == chReval) + { + chTmpPathNum = 0U; + + for (ii = 0U; ii < chPathNum; ii++) + { + wTmpEndLinkId = szPath[ii][(szLinkNum[ii] - 1U)]; + chMainQueryDir = szLinkQueryDir[ii]; + chSideQueryDir = szLinkQueryDir[ii]; + + /*һ һLINK->ҵյѾѯ50LINK*/ + if ((pLODBStru->Lnk != wTmpEndLinkId) && (DSU_NULL_16 != wTmpEndLinkId)) + { + /*˵ûҵյ*/ + chCurLinkDirChanged = pdsuStaticHeadStru->pLinkStru[pdsuLinkIndex[wTmpEndLinkId]].wLogicDirChanged; /*ȡǰlinkķ仯*/ + /*LinkIDȡǰlinkṹ*/ + wTmpEndLinkIndex = pdsuLinkIndex[wTmpEndLinkId]; + pTmpEndLinkStru = pdsuStaticHeadStru->pLinkStru + wTmpEndLinkIndex; + + /* ȡѯϵĶ˵,ѯϵһlink */ + if (EMAP_SAME_DIR == chMainQueryDir) + { + wTmpNextMainLinkId = pTmpEndLinkStru->wTmnlJointMainLkId; + wTmpNextSideLinkId = pTmpEndLinkStru->wTmnlJointSideLkId; + } + else + { + wTmpNextMainLinkId = pTmpEndLinkStru->wOrgnJointMainLkId; + wTmpNextSideLinkId = pTmpEndLinkStru->wOrgnJointSideLkId; + } + + /*ڶж·ǷҪ*/ + wAddLinkId = wTmpNextMainLinkId; + wNewLinkId = wTmpNextSideLinkId; + + if (DSU_NULL_16 != wNewLinkId) + { + /* Ҫ½· */ + chFunFlag = 1u; + } + else + { + chFunFlag = 0U; + } + + /*·*/ + wTmpPathLinkNum = szLinkNum[ii]; + + /* 굱ǰ·,жϵǰ·linkǷﵽ */ + if (49U == szLinkNum[ii]) + { + /* δޣһlinkֻܴΪյ */ + szPath[ii][wTmpPathLinkNum] = DSU_NULL_16; + szLinkNum[ii]++; + } + else + { + /* */ + szPath[ii][wTmpPathLinkNum] = wAddLinkId; + szLinkNum[ii]++; + + if (DSU_NULL_16 != wAddLinkId) + { + /*жǷڷ仯*/ + chNxtLinkDirChanged = pdsuStaticHeadStru->pLinkStru[pdsuLinkIndex[wAddLinkId]].wLogicDirChanged; + if (((LINK_DIRCHANGE_BEGIN == chNxtLinkDirChanged) || (LINK_DIRCHANGE_END == chNxtLinkDirChanged)) + && (chNxtLinkDirChanged == chCurLinkDirChanged)) + { + /*ڷ仯*/ + chMainQueryDir = ~chMainQueryDir; + } + else + { + /*ڷ仯㣬*/ + } + + szLinkQueryDir[ii] = chMainQueryDir; /*洢·µIJѯ*/ + } + else + { + ; /*˳ѯ*/ + } + } + + /*IJ·촦*/ + if (1U == chFunFlag) + { + /* һ· */ + /* 1.жϵǰ·linkǷﵽ */ + if (49U == wTmpPathLinkNum) + { + /* δޣһlinkֻܴΪյ㣬¿·Ҳû */ + } + else + { + /* 2.ж·Ƿﵽ */ + if ((12U > chTmpPathNum) && (DSU_NULL_16 != wNewLinkId)) + { + /*Ϊ·Ӳѯ*/ + chTempPathIndex = chTmpPathNum + chPathNum; /*ǰ··*/ + if (25U > chTempPathIndex) + { + /*жǷڷ仯*/ + chNxtLinkDirChanged = pdsuStaticHeadStru->pLinkStru[pdsuLinkIndex[wNewLinkId]].wLogicDirChanged; + if (((LINK_DIRCHANGE_BEGIN == chNxtLinkDirChanged) || (LINK_DIRCHANGE_END == chNxtLinkDirChanged)) + && (chNxtLinkDirChanged == chCurLinkDirChanged)) + { + /*ڷ仯*/ + chSideQueryDir = ~chSideQueryDir; + } + else + { + /*ڷ仯㣬*/ + } + szLinkQueryDir[chTempPathIndex] = chSideQueryDir; /*洢·µIJѯ*/ + } + else + { + /*·ﵽޣ*/ + } + + /* һ· */ + szTmpAddLinkNum[chTmpPathNum] = wTmpPathLinkNum; + for (jj = 0U; jj < wTmpPathLinkNum; jj++) + { + /*ԭ·LINK*/ + szTmpAddPath[chTmpPathNum][jj] = szPath[ii][jj]; + } + szTmpAddPath[chTmpPathNum][wTmpPathLinkNum] = wNewLinkId; + szTmpAddLinkNum[chTmpPathNum]++; + chTmpPathNum++; + } + } + } + } + else + { + /*Ѿҵյ*/ + chTmpEndPathNum++; + } + + } + + /*岽·*/ + for (ii = 0U; ii < chTmpPathNum; ii++) + { + if (25U <= chPathNum) + { + /* жǷ񳬳· */ + break; + } + else + { + for (jj = 0u; jj < szTmpAddLinkNum[ii]; jj++) + { + szPath[chPathNum][jj] = szTmpAddPath[ii][jj]; + } + + szLinkNum[chPathNum] = szTmpAddLinkNum[ii]; + chPathNum++; + } + + } + + *pPathNum = chPathNum; + + } + else + { + ; + } + } + else + { + + } + + if ((1U == chReval) && (chPathNum == chTmpEndPathNum)) + { + chReval = 2U; + } + else + { + ; + } + + return chReval; +} + +/************************************************ +*:֮·ѯ(ӵͼȫֱ) +*: pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +*ֵ:CI_ERRORʧ +* CI_SUCCESSɹ: +* by cgh 20250310 +************************************************/ +UINT8 TwoPointPathSearch(const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100]) +{ + return TwoPointPathExp(qds_dsuEmapStru, pLODAStru,pLODBStru, pLinkNum, szLinkId); +} + + + + + + + + + + + + + + diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquQuery.h b/TSCP/src/dqu_common/dqu_emap_common/dquQuery.h new file mode 100644 index 0000000..7a96502 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquQuery.h @@ -0,0 +1,403 @@ +/************************************************************************ +* +* ļ dsuQuery.h +* Ȩ˵ ؿƼƼ޹˾ +* 汾 1.0 +* ʱ 2009.11.21 +* +* dsuѯͷļ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _DSU_QUERY_H +#define _DSU_QUERY_H + +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "CommonTypes.h" +#include "dsuStruct.h" +#include "dquVobcCommonStru.h" + + +#define DSU_MAX_LINK_BETWEEN 400 + + +#ifdef __cplusplus +extern "C" { +#endif + +/*ATO*/ + +/*õǰԴ*/ +UINT8 dquSetCurrentQueryDataSource(DSU_EMAP_STRU *pDsuEmapStru,DSU_STC_LIMIT_LINKIDX_STRU *pDsuLimitStcLinkIdx); + + +/*2.Ծѯ*/ +/* +*ʽӿ +* ABλõõλơ +* const LOD_STRU * pLODAStru, Aλ +* const LOD_STRU * pLODBStru, Bλ +* UINT8 PointNum, +* const POINT_STRU * pPointStru, Ϣṹ +* INT32 *Displacement ABλƣзűʾ +* ֵ 1,ɹ +* 0,ʧ +* ʹע⣺Ͽ෿Ŀ:BķңABλLinkBΪգ + ͨĿ߼仯㣬㷨ΪAķңABλLinkAΪա +* author:qxt 20170811 +*/ +UINT8 dsuDispCalcuByLOC(const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, INT32 *Displacement); + +/*ܺݵ״̬ȡǰLinkLink*/ +UINT8 dsuGetAdjacentLinkID(UINT16 LinkId, UCHAR Direction, UCHAR PointNum,const DQU_POINT_STATUS_STRU *pPointStru, UINT16 *pLinkId); + +/*ܺλ+λ=λ*/ +/* +* ܺݵǰλãλԼĵϢõλ. +һ㼴ǰLnk㣬һLinkյ㣬뵱ǰpLODStruLink Id +* const LOD_STRU * pLODStru, ǰλ +* INT32 Displacement, λƣзţΪʾȡ +* UCHAR PointNum, +* const POINT_STRU * pPointStru, Ϣ +* LOD_STRU *pNewLODStru λ +* ֵ 1,ɹ +* 0,ʧ +*/ +UCHAR dsuLODCalcu(const LOD_STRU *pLODStru, INT32 Displacement, UCHAR PointNum, const DQU_POINT_STATUS_STRU *pPointStru, LOD_STRU *pNewLODStru); + + +/* +* ܣ ˺ĹDzѯλülinkС +* **************************************************************************************************** +* 1 2 3 4 5 6 +* --------------*-------------------------------------------*----------------- +* S E +* ͼ Link˵㡣*ѯλá123...Linkʾ +* ͼʾLink34Ϊ +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru նλ +* const UINT8 PointNum Ŀ +* const POINT_STRU * pPointStru Ϣ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* ֵ 0, ѯʧ +* 1, ѯɹ +* ʹע⣺ Ŀǰûа˵Link Id +* Ҫ֮γ򣬷򷵻0 +* + Ͽ෿Ŀ SpLODEndStru->DirңҵE򷵻سɹҲ򷵻ʧܡ +* ͨĿ SpLODStartStru->DirңҵE򷵻سɹҲ򷵻ʧܡ +* author: qxt 20170814 +*/ +UINT8 dsuGetLinkBtwLoc(const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, + UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], UINT16 *wLinkNumber); + + +/* +* ܣ ˺ĹǽжϵǰλǷָΧڡ +* **************************************************************************************************** +* +* --------------*--------------------*---------------------*----------------- +* S C E +* Ͽ෿Ŀ 㷨ΪλDisplacementSCDisplacementCEλƷͬ˵CSE +* ͨĿ߼仯㣩 㷨ΪλDisplacementCSDisplacementCEλƷŲͬ˵CSE +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* const UINT8 PointNum, Ŀ +* const POINT_STRU * pPointStru, Ϣ +* const LOD_STRU * pCurrentLODStru,ǰλ +* ڲ UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +* ʹע⣺1.ڵǰλ˵λʱʱ¹жϣ +* 1) ǰλ㣬Ϊõڱ +* 2) ǰλյ㣬Ϊõ㲻ڱ +* 3) 3غϷڡ +* 2.ҵյ㶼ڣԵαʼնλãֻҪεһڣ˵ڵʼնγɵı +* 3.SE򲻴ڣ0ʧܡSC,SEڣ1ɹǵC +* 4.෿ͺϿĿʼλúնλôķ豣֤һ +* ֤ͨʼλõķȷɡ +*/ +UINT8 dsuCheckLocInArea(const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, + const LOD_STRU *pCurrentLODStru,UINT8 *pLocInArea); + +/*ܺȡlink*/ +UINT32 LinkLength(UINT16 wLinkID); + +/* +* ܣ ˺ĹжϵǰλǷָΧڣ˺ǶdsuCheckLocInAreaQuick + һ䡣ڽǰȡټǷڡ +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* const LOD_STRU * pCurrentLODStru,ǰλ +* UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +*/ +UINT8 dsuCheckLocInAreaQuick2(const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT16 wLinkNumber,UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea); +/* +* ܣ ˺ĹǽжϵǰλǷָΧڡ + ˺ĹCheckLocInAreaġCheckLocInAreaԷûҪ󣬼漰ķȷġ + CheckLocInAreaQuickҪStartLODܹEndLOD +* **************************************************************************************************** +* +* --------------*--------------------*---------------------*----------------- +* S C E +* 㷨ΪжϵǰλSEǷͬһLinkϣ +* ͬһLinkϣݷλжǷڣͬһLinkжCLinkIdǷSE֮ijһLinkIdͬ +* ֮LinkԱԶڶεñѯǷڵĺЧʺа +* +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* const LOD_STRU * pCurrentLODStru,ǰλ +* ڲ UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +* ʹע⣺1.ڵǰλ˵λʱʱ¹жϣ +* 1) ǰλ㣬Ϊõڱ +* 2) ǰλյ㣬Ϊõ㲻ڱ +* 3) 3غϷڡ +* 2.ҵյ㶼ڣԵαʼնλãֻҪεһڣ˵ڵʼնγɵı +* 3.SE򲻴ڣ0ʧܡSC,SEڣ1ɹǵC +*/ +UINT8 dsuCheckLocInAreaQuick(const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT16 wLinkNumber,UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea); +/*ܺ,ѯǰGardeGrade*/ +UINT16 FindAdjacentGradeID(const UINT16 wCurrentGradeID, const UCHAR chDirection, const UCHAR PointNum, const DQU_POINT_STATUS_STRU * pPointStru); + +/*¶*/ +UINT8 dsuGetGradeIdbyLoc(const UINT16 linkId,const UINT32 offset,UINT16* GradeID); +/*㵽¶ľ*/ +UINT8 dsuGetDistanceFromOrigin(UINT16 GradeId,UINT16 linkId,UINT32 Ofst,UINT32* length); +/*¶ȱµ¶ľ*/ +UINT8 dsuDividPointDistanceFromOrigin(UINT16 GradeId,UINT16 linkId,UINT32* endPointDistance,UINT32* startPointDistance); +/*¶ֵ*/ +UINT8 dsuCalculateGradeValue(UINT16 LinkId,UINT32 ofst, FLOAT32* GradeVal); +/*¶*/ +UCHAR dsuGradientGet(const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + const UCHAR PointNum, const DQU_POINT_STATUS_STRU * pPointStru, FLOAT32 * Gradient); +/*жϺһ¶ȵ¶ֵǰһ¶ȵ¶ֵӣ仯Ǽ */ +UINT8 dquGradeTrend(UINT16 fistGradeID,UINT16 secondGradeID,UINT8 *GradeTrend); + +/* +ܣȡǰ¶ +UINT16 linkId,ǰlink +gradeFrnt ¶ + Null ·յǰ¶Ϊͳһ¶ + Nullǰ¶¶ȱпɲ + ֵ0ʧ 1ɹ +*/ +UINT8 dsuGetGradeFrnt(UINT16 linkId, DSU_GRADE_STRU** gradeFrnt) ; + +/* +ܣȡ¶ +UINT16 linkId,ǰlink +gradeRear ¶ + Null ·յ¶Ϊͳһ¶ + Null¶¶ȱпɲ + ֵ0ʧ 1ɹ +*/ +UINT8 dsuGetGradeRear(UINT16 linkId, DSU_GRADE_STRU** gradeRear) ; + +/** +ܣȡǰLINKľ̬ٸ + +@linkIdǰlink + +ֵ̬ٸ +*/ +UINT8 GetStcLmtSpdCntByLnkId(const UINT16 linkId); + +/** +ܣȡƶLINKĵָ±ľ̬ʱٵĶָ + +@linkIdǰLink +@lmtSpdIdxӦLinkĵڼ٣ȡֵΧ1-10 +ֵ +@NULLȡʧ +@ǿգӦٽṹָ +*/ +DSU_STATIC_RES_SPEED_STRU *GetStcLmtSpdInfoByLnkId(const UINT16 linkId,const UINT8 idx); + +/* +ܣ࿪תΪ +multiPointId ࿪ + multiPointState ࿪״̬ + +wVirtualPointIds ֺ + wVirtualPointStates ֺ״̬ +ֵֵֺ, 0ʧ + +㷨࿪ NλR1λL1λR2λL2λ + Ӧе 0 1 2 3 4 + ӦĶ࿪״̬ 1 2 3 4 5 + ˵ =࿪״̬multiPointState-1 ʱӦԭֵ״̬ȡλ<=>λ + +עwVirtualPointIds״̬wVirtualPointStatesЧ״̬Ϊ3 + + / L / L + / / + / / 101 + -|------------------------ === ---|------/----------------- N + 1 \ N 102 \ + \ \ + \ \ + R R + ͼ1.ʵ ͼ2.ⵥ + + ͼ1ʵ1״̬Ϊ3ʱƳͼ2ⵥΪLλʱ101ΪЧ״̬Ϊ3ֵΪ2 + wVirtualPointIds[0]=102; + wVirtualPointStates[0]=2; + wVirtualPointIds[1]=101; + wVirtualPointStates[1]=3; +author:Ŀ add by qxt 20170622 +*/ +UINT8 ConvertToVirtualSwitches(const UINT16 multiPointId,const UINT8 multiPointState,UINT16 wVirtualPointIds[MAX_VIRTUAL_SWITCH_NUM],UINT8 wVirtualPointStates[MAX_VIRTUAL_SWITCH_NUM]); + +/* +ܣתΪ࿪ +wVirtualPointIds[] + wVirtualPointStates[] ״̬ + wVirtualPointNum +multiPointId Ӧ࿪ + multiPointState Ӧ࿪״̬ +ֵ0ʧ 1ɹ + +עwVirtualPointIds״̬wVirtualPointStatesЧҪ롣 + + /L L + / / + / / + / / + ---|------/-----------\------ N =====> ------------------ N + 1 2 \ \ + \ \ + R R + ͼ1.ⵥ ͼ2.ʵ + + ͼ11״̬Ϊ2ʱƳͼ2࿪״̬ΪLλʱͼһ2ΪЧģΪ£ + wVirtualPointIds[0]=1; + wVirtualPointStates[0]=2; + wVirtualPointNum=1; +author:Ŀ add by qxt 20170622 +*/ +UINT8 ConvertToMultiSwitch(const UINT16 wVirtualPointIds[MAX_VIRTUAL_SWITCH_NUM],const UINT8 wVirtualPointStates[MAX_VIRTUAL_SWITCH_NUM],const UINT8 wVirtualPointNum,UINT16 *multiPointId,UINT8 *multiPointState); + +/************************************************ +*:ѯAB֮ľ +*: pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2021-2-28 +************************************************/ +UINT32 dsuLenByPoint(const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8* pDir); + +/************************************************ +*:ѯAB֮ľ루ݵλã +*: pLODAStru A +* pLODBStru B +* cSwitchSum +* pSwitchInfo Ϣ +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2022-6-17 +************************************************/ +UINT32 dsuLenByPointAndSwitch(const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, const UINT8 cSwitchSum, const DQU_POINT_STATUS_STRU *pSwitchInfo, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8* pDir); + +/************************************************ +*ܣѯAB֮Link仯 +*const LOD_STRU* pLODAStru A +* const LOD_STRU* pLODBStru B +* +*ֵʧܣUINT8_MAX +* ɹ仯 +************************************************/ +UINT8 GetDirChangeNumBtwPoints(const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru); + +/************************************************ +*:ѯAB֮ľ루طͷ仯 +*: pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2021-2-28 +************************************************/ +UINT32 dsuLenByPoint_GetDir(const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8* pDir, UINT8* pLinkDirChangedNum); + +/************************************************ +*:֮·ѯ +*: pDsuEmapStru ӵͼ +* pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +*ֵ:CI_ERRORʧ +* CI_SUCCESSɹ: +* by cgh 20250310 +************************************************/ +UINT8 TwoPointPathExp(DSU_EMAP_STRU* pDsuEmapStru, const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100]); + +/************************************************ +*:յ·ѯ +*: pDsuEmapStru +* pLODBStru B +* szLinkQueryDir linkѯ +* pPathNum · +* szPath · +* szLinkNum ÿ·ij +*: pPathNum · +* szPath · +* szLinkNum ÿ·ij +*ֵ:0:ʧ 1:ѯɹҸ·δյ 2ѯɹҸ·յ +* by cgh 20250310 +************************************************/ +UINT8 PointBeginEndPathExp(DSU_EMAP_STRU* pDsuEmapStru, const LOD_STRU* pLODBStru, UINT8 szLinkQueryDir[25], UINT8* pPathNum, UINT16 szPath[25][50], UINT16 szLinkNum[25]); + +/************************************************ +*:֮·ѯ(ӵͼȫֱ) +*: pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +*ֵ:CI_ERRORʧ +* CI_SUCCESSɹ: +* by cgh 20250310 +************************************************/ +UINT8 TwoPointPathSearch(const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100]); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquQueryExp.c b/TSCP/src/dqu_common/dqu_emap_common/dquQueryExp.c new file mode 100644 index 0000000..f8588ff --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquQueryExp.c @@ -0,0 +1,7647 @@ +/************************************************************************ +* ļ dsuQuery.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2009.09.26 +* +* dsuѯļ +* ʹע +* ޸ļ¼ +************************************************************************/ +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "dquQueryExp.h" +#include "dsuVar.h" +#include "stdlib.h" +#include "string.h" +#include "math.h" +#include "dquCbtcType.h" +#include "LinkConfigDataManage.h" + +/* +* зϢԼ״̬Ϣѯõǰlinkзlink +* UINT16 LinkId, ǰLink +* UCHAR Direction, ǰ +* UCHAR PointNum, Ϣ +* const POINT_STRU *pPointStru, Ϣ +* UINT16 *pLinkIdǰLinkLink +* ֵ 1,ѯɹ +* 0,ѯʧ,Чʧ +* 0xFF,·յ㣬δҵ +* +*/ +UINT8 dsuGetAdjacentLinkIDExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 LinkId, UCHAR Direction, UCHAR PointNum,const DQU_POINT_STATUS_STRU *pPointStru, UINT16 *pLinkId) +{ + UINT8 chReturnValue=0; /*ںֵ*/ + UINT16 CurrentLinkIndex; /*ǰLink Index*/ + DSU_LINK_STRU *pCurrentLinkStru=NULL; /*ǰLink,ȡʹ*/ + UINT16 AdjancentLinkIndex; /*ǰLink Index*/ + DSU_LINK_STRU *pAdjancentLinkStru=NULL; /*ǰLink,ȡʹ*/ + UINT8 FindFlag = 0; /*ұǣڼ¼Ƿɹ*/ + UINT8 i; /*ѭ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if (NULL != pDsuEmapStru) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ӵͼָΪ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*жLinkIDЧ*/ + if((LinkId>LINKINDEXNUM)||(dsuLinkIndex[LinkId] == 0xFFFF)) + { + /*LinkIdЧѯʧܣ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*ж뷽Ч*/ + if((Direction!=EMAP_SAME_DIR)&&(Direction!=EMAP_CONVER_DIR)) + { + /*뷽Чѯʧܣ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*˱ʾЧ*/ + + /*LinkIDȡǰlinkṹ*/ + CurrentLinkIndex=dsuLinkIndex[LinkId]; + pCurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + + /*뷽*/ + if(Direction==EMAP_CONVER_DIR) + { + /*LinkңյǰLinkʼ˶˵*/ + if(pCurrentLinkStru->wOrgnJointMainLkId==DSU_NULL_16) + { + /*·յ㣬ǰlinklink*/ + chReturnValue = 0xff; + return chReturnValue; + + }else if(pCurrentLinkStru->wOrgnPointType==EMAP_AXLE_DOT) + { + /**/ + /*LinkΪ*/ + *pLinkId = pCurrentLinkStru->wOrgnJointMainLkId; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + + }else if(pCurrentLinkStru->wOrgnPointType==EMAP_POINT_DOT) + { + /*ǰʼ˶˵ǵ*/ + /*жϵǰlinkǷΪĻLink*/ + if(pCurrentLinkStru->wOrgnJointSideLkId==DSU_NULL_16) + { + /*ǰlinkǻLinkǻlinkLinkֻһ״̬Ҳȷ֤״̬Ƿȷ*/ + + /*Ϣҵǰ״̬Ϣ*/ + FindFlag=0; + for(i=0;iwOrgnPointId) + { + /*˵ϢвҵǰLinkն˴ĵ*/ + + /*òλΪTRUR*/ + FindFlag=1; + break; + } + } + + if(FindFlag==0) + { + /*ûҵǰϢǰLinkLinkܴMAΧ֮⣬ʧ*/ + chReturnValue=0xff; + return chReturnValue; + } + + /*ȡLinkϢ,ҲǻȡڻLinkϢ*/ + AdjancentLinkIndex=dsuLinkIndex[pCurrentLinkStru->wOrgnJointMainLkId]; + pAdjancentLinkStru=dsuStaticHeadStru->pLinkStru+AdjancentLinkIndex; + + if(((pPointStru[i].PointStatus == EMAP_POINT_STATUS_MAIN)&&(LinkId==pAdjancentLinkStru->wTmnlJointMainLkId)) + ||((pPointStru[i].PointStatus == EMAP_POINT_STATUS_SIDE)&&(LinkId==pAdjancentLinkStru->wTmnlJointSideLkId))) + { + /*״̬ȷ1.ڵΪλǰLinkLinkIink + 2.ڵΪλǰLinkLinkIJIink + */ + *pLinkId=pCurrentLinkStru->wOrgnJointMainLkId; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*ҵڵڵĵ״̬Իߵ״̬ʧش󣬺ʧ*/ + chReturnValue=0; + return chReturnValue; + } + + } + else + { + /*ǰlinkΪĻLink*/ + /*Ϣҵǰ״̬Ϣ*/ + FindFlag=0; + for(i=0;iwOrgnPointId) + { + /*˵ϢвҵǰLinkն˴ĵ*/ + + /*òλΪTRUR*/ + FindFlag=1; + break; + } + } + + if(FindFlag==0) + { + /*ûҵǰϢǰLinkLinkܴMAΧ֮⣬ʧ*/ + chReturnValue=0xff; + return chReturnValue; + } + else + { + /*ݵʵʱ״̬Ϣ*/ + if (pPointStru[i].PointStatus == EMAP_POINT_STATUS_MAIN) + { + /*״̬λڶλ*/ + /*LinkΪ*/ + *pLinkId=pCurrentLinkStru->wOrgnJointMainLkId; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + } + else if(pPointStru[i].PointStatus == EMAP_POINT_STATUS_SIDE) + { + /*״̬λڷλ*/ + /*ڲLinkΪ*/ + *pLinkId=pCurrentLinkStru->wOrgnJointSideLkId; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*ʧ POINTLOSESTATUS ʧֵĴ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + } + + } + else + { + /*Link˵ͲϷ*/ + chReturnValue=0U; + return chReturnValue; + } + + } + else /*if(Direction==SAMEDIR)*/ + { + /*Link*/ + + /*LinkңյǰLinkն˶˵*/ + if(pCurrentLinkStru->wTmnlJointMainLkId==DSU_NULL_16) + { + /*˵Ϊ·յ㣬زѯ*/ + chReturnValue = 0xff; + return chReturnValue; + + }else if(pCurrentLinkStru->wTmnlPointType==EMAP_AXLE_DOT) + { + /*ǰLinkն˶˵*/ + /*LinkΪ*/ + + *pLinkId=pCurrentLinkStru->wTmnlJointMainLkId; + chReturnValue=1; + return chReturnValue; + + }else if (pCurrentLinkStru->wTmnlPointType == EMAP_POINT_DOT) + { + /*ǰLinkն˶˵*/ + + /*жϵǰlinkǷΪĻLink*/ + if(pCurrentLinkStru->wTmnlJointSideLkId==DSU_NULL_16) + { + /*ǰlinkǻLinkǻlinkLinkֻһ״̬Ҳȷ֤״̬Ƿȷ*/ + + /*Ϣҵǰ״̬Ϣ*/ + FindFlag=0; + for(i=0;iwTmnlPointId) + { + /*˵ϢвҵǰLinkն˴ĵ*/ + + /*òλΪTRUR*/ + FindFlag=1; + break; + } + } + + if(FindFlag==0) + { + /*ûҵǰϢǰLinkLinkܴMAΧ֮⣬ʧ*/ + chReturnValue=0xff; + return chReturnValue; + } + + /*ȡLinkϢ,ҲǻȡڻLinkϢ*/ + AdjancentLinkIndex=dsuLinkIndex[pCurrentLinkStru->wTmnlJointMainLkId]; + pAdjancentLinkStru=dsuStaticHeadStru->pLinkStru+AdjancentLinkIndex; + + if(((pPointStru[i].PointStatus == EMAP_POINT_STATUS_MAIN)&&(LinkId==pAdjancentLinkStru->wOrgnJointMainLkId)) + ||((pPointStru[i].PointStatus == EMAP_POINT_STATUS_SIDE)&&(LinkId==pAdjancentLinkStru->wOrgnJointSideLkId))) + { + /*״̬ȷ1.ڵΪλǰLinkLinkIink + 2.ڵΪλǰLinkLinkIJIink + */ + *pLinkId=pCurrentLinkStru->wTmnlJointMainLkId; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*ҵڵڵĵ״̬Իߵ״̬ʧش󣬺ʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + else + { + /*ǰLinkյʵʱ״̬ദ*/ + + /*ҵǰϢ*/ + FindFlag=0; + for(i=0;iwTmnlPointId) + { + /*˵ϢвҵǰLinkն˴ĵ*/ + FindFlag=1; + break; + } + } + + if(FindFlag==0) + { + /*ûҵǰϢǰLinkLinkܴMAΧ֮⣬ʧ*/ + chReturnValue=0xff; + return chReturnValue; + } + else + { + /*ݵʵʱ״̬*/ + if(pPointStru[i].PointStatus==EMAP_POINT_STATUS_MAIN) + { + /*ǰLinkǻLinkλյLinkΪ*/ + + *pLinkId=pCurrentLinkStru->wTmnlJointMainLkId; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + } + else if (pPointStru[i].PointStatus == EMAP_POINT_STATUS_SIDE) + { + /*ǰLinkǻLinkλյڲLinkΪ*/ + + *pLinkId=pCurrentLinkStru->wTmnlJointSideLkId; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰLinkǻLinkʧ POINTLOSESTATUSʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + } + + } + else + { + /*Link˵ͲϷʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + /*˴ɴ*/ + +} + + +/* +* ܺݵǰλãλԼĵϢõλ. + һ㼴ǰLnk㣬һLinkյ㣬뵱ǰpLODStruLink Id +* const LOD_STRU * pLODStru, ǰλ +* INT32 Displacement, λƣзţΪʾȡ +* UCHAR PointNum, +* const POINT_STRU * pPointStru, Ϣ +* LOD_STRU *pNewLODStru λ +* ֵ 1,ɹ +* 0,ʧ +*ע⣺Ͽ෿ʹ +*/ +static UCHAR dsuLODCalcuExp_DFT(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStru, INT32 Displacement, UCHAR PointNum, const DQU_POINT_STATUS_STRU *pPointStru, LOD_STRU *pNewLODStru) +{ + UINT8 chReturnValue=0U; /*ںֵ*/ + UINT16 CurrentLinkId = 0U; /*ڲҹʱ浱ǰLinkID*/ + UINT16 CurrentLinkIndex = 0U; /*ǰLink Index*/ + DSU_LINK_STRU *pCurrentLinkStru=NULL;/*ѭҹʱ浱ǰLinkṹ*/ + UINT8 FindDir = 0U; /*ڼ¼ʵʲеIJҷ*/ + INT32 FindDisplacement = 0; /*ʱƫ*/ + INT32 FindDisplacementSum = 0; /*ۼλƫ*/ + UINT16 k; /*ѭñ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != pLODStru) + && (NULL != pPointStru) && (NULL != pNewLODStru)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ָΪ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*жLinkIDЧ*/ + if((pLODStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODStru->Lnk] == 0xFFFF)) + { + /*LinkIdЧѯʧܣ*/ + chReturnValue=0U; + return chReturnValue; + } + + /*жƫЧ*/ + if (pLODStru->Off > LinkLengthExp(pDsuEmapStru,pLODStru->Lnk)) + { + /*Чѯʧܣ*/ + chReturnValue=0U; + return chReturnValue; + } + /*ж뷽Ч*/ + if((pLODStru->Dir!=EMAP_SAME_DIR)&&(pLODStru->Dir!=EMAP_CONVER_DIR)) + { + /*뷽Чѯʧܣ*/ + chReturnValue=0U; + return chReturnValue; + } + + /*ƫDisplacementΪ0*/ + if (Displacement == 0) + { + /*displacementΪ0صǰλΪ*/ + pNewLODStru->Lnk=pLODStru->Lnk; + pNewLODStru->Off=pLODStru->Off; + pNewLODStru->Dir=pLODStru->Dir; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + } + + /*displacementС0displacementֵλãȡ*/ + if((pLODStru->Dir==EMAP_SAME_DIR)&&(Displacement>0)) + { + /**/ + FindDir=EMAP_SAME_DIR; + FindDisplacement=Displacement; + } + else if((pLODStru->Dir==EMAP_CONVER_DIR)&&(Displacement<0)) + { + /**/ + FindDir=EMAP_SAME_DIR; + FindDisplacement=-Displacement; + } + else if((pLODStru->Dir==EMAP_SAME_DIR)&&(Displacement<0)) + { + /**/ + FindDir=EMAP_CONVER_DIR; + FindDisplacement=-Displacement; + } + else if((pLODStru->Dir==EMAP_CONVER_DIR)&&(Displacement>0)) + { + /**/ + FindDir=EMAP_CONVER_DIR; + FindDisplacement=Displacement; + } + else + { + /*ɴ֧*/ + } + + /*LinkIDݿвҵǰlinkϢ*/ + CurrentLinkIndex=dsuLinkIndex[pLODStru->Lnk]; + pCurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + if(FindDir==EMAP_SAME_DIR) + { + /**/ + + /*ݵǰλۼƫ*/ + FindDisplacementSum=pCurrentLinkStru->dwLength-pLODStru->Off; + + /*λжλǷͬһLink*/ + if(FindDisplacementSum>=FindDisplacement) + { + /*˵ͬһlinkϣۼλƵõλ*/ + pNewLODStru->Lnk=pCurrentLinkStru->wId; + pNewLODStru->Off=pLODStru->Off+FindDisplacement; + pNewLODStru->Dir=pLODStru->Dir; + chReturnValue=1; + return chReturnValue; + } + else + { + for (k=0;kwId, FindDir, PointNum, pPointStru,&CurrentLinkId) ) + { + /*pCurrentLinkStruָLink,LinkΪǰLink*/ + CurrentLinkIndex=dsuLinkIndex[CurrentLinkId]; + pCurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + + FindDisplacementSum+=pCurrentLinkStru->dwLength; + if(FindDisplacementSum>=FindDisplacement) + { + /*ۼӵλֵϵǰLinkȴƫ˵Ŀλõǰlink*/ + pNewLODStru->Lnk=pCurrentLinkStru->wId; + pNewLODStru->Off=FindDisplacement-(FindDisplacementSum-pCurrentLinkStru->dwLength); + pNewLODStru->Dir=pLODStru->Dir; + chReturnValue=1; + return chReturnValue; + } + else + { + /*ۼӵλֵϵǰLinkСƫ˵ĿλòڵǰlinkϣѭǰһLink*/ + } + } + else + { + /*ȡһlinkʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + /*ѭΪk==LINKINDEXNUM˵ҴLINKINDEXNUM󲻿ܷ*/ + chReturnValue=0U; + return chReturnValue; + } + } + else + { + /**/ + + /*ۼƫ0*/ + FindDisplacementSum=0; + + /*ݵǰλ÷ۼƫ*/ + FindDisplacementSum=pLODStru->Off; + + if(FindDisplacementSum>=FindDisplacement) + { + /*˵ͬһlink*/ + pNewLODStru->Lnk=pCurrentLinkStru->wId; + pNewLODStru->Off=pLODStru->Off-FindDisplacement; + pNewLODStru->Dir=pLODStru->Dir; + + /*ѯɹزѯ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + for (k=0;kwId, FindDir, PointNum, pPointStru,&CurrentLinkId) ) + { + /*pCurrentLinkStruָLink*/ + CurrentLinkIndex=dsuLinkIndex[CurrentLinkId]; + pCurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + + FindDisplacementSum+=pCurrentLinkStru->dwLength; + if(FindDisplacementSum>=FindDisplacement) + { + /*ۼӵλֵϵǰLinkȴƫ˵Ŀλõǰlink*/ + pNewLODStru->Lnk=pCurrentLinkStru->wId; + pNewLODStru->Off=(FindDisplacementSum-FindDisplacement); + pNewLODStru->Dir=pLODStru->Dir; + /*ѯɹѯ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*ۼӵλֵϵǰLinkСƫ˵ĿλòڵǰlinkϣѭǰһLink*/ + } + } + else + { + /*ȡһlinkʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + /*ѭΪk==LINKINDEXNUM˵ҴLINKINDEXNUM󲻿ܷ*/ + chReturnValue=0U; + return chReturnValue; + } + } +} + +/* +* ܺݵǰλãλԼĵϢõλ. + һ㼴ǰLnk㣬һLinkյ㣬뵱ǰpLODStruLink Id +* const LOD_STRU * pLODStru, ǰλ +* INT32 Displacement, λƣзţΪʾȡ +* UCHAR PointNum, +* const POINT_STRU * pPointStru, Ϣ +* LOD_STRU *pNewLODStru λ +* ֵ 1,ɹ +* 0,ʧ +*author:qxt 20170811 ͨlink߼仯 +*/ +static UCHAR dsuLODCalcuExp_HLT(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStru, INT32 Displacement, UCHAR PointNum, const DQU_POINT_STATUS_STRU *pPointStru, LOD_STRU *pNewLODStru) +{ + UINT8 chReturnValue=0U; /*ںֵ*/ + UINT8 chFlag=1u; /*ִʧܱ*/ + UINT16 wCurrentLinkId = 0U; /*ڲҹʱ浱ǰLinkID*/ + UINT16 wCurrentLinkIndex = 0U; /*ǰLink Index*/ + DSU_LINK_STRU *pCurrentLinkStru=NULL;/*ѭҹʱ浱ǰLinkṹ*/ + UINT8 wFindDir = 0U; /*ڼ¼ʵʲеIJҷ*/ + INT32 dwFindDisplacement = 0; /*ʱƫ*/ + INT32 dwFindDisplacementSum = 0; /*ۼλƫ*/ + UINT16 k=0U; /*ѭñ*/ + UINT8 tmpLODDir = 0xff; /*ʱ,ڷϢ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL == pLODStru) || (NULL == pPointStru) || (NULL == pNewLODStru)) + { + /*λòָΪ*/ + chFlag = 0U; + } + else if ((NULL != pDsuEmapStru)&&(NULL != pDsuEmapStru->dsuEmapIndexStru)&&(NULL!=pDsuEmapStru->dsuStaticHeadStru)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + + /*жLinkIDЧ*/ + if((pLODStru->Lnk>LINKINDEXNUM)||(DSU_NULL_16 == dsuLinkIndex[pLODStru->Lnk])) + { + /*LinkIdЧѯʧܣ*/ + chFlag=0U; + } + + /*жƫЧ*/ + if (pLODStru->Off > LinkLengthExp(pDsuEmapStru,pLODStru->Lnk)) + { + /*Чѯʧܣ*/ + chFlag=0U; + } + /*ж뷽Ч*/ + if((EMAP_SAME_DIR!=pLODStru->Dir)&&(EMAP_CONVER_DIR!=pLODStru->Dir)) + { + /*뷽Чѯʧܣ*/ + chFlag=0U; + } + } + else + { + /*ӵͼָΪ*/ + chFlag = 0U; + + } + + if (0U!=chFlag) + { + /*ƫDisplacementΪ0*/ + if (0U==Displacement) + { + /*displacementΪ0صǰλΪ*/ + pNewLODStru->Lnk=pLODStru->Lnk; + pNewLODStru->Off=pLODStru->Off; + pNewLODStru->Dir=pLODStru->Dir; + + /*ѯɹزѯ*/ + chReturnValue=1; + } + else/*0!=Displacement*/ + { + tmpLODDir = pLODStru->Dir; + + /*displacementС0displacementֵλãȡ*/ + if((EMAP_SAME_DIR==pLODStru->Dir)&&(Displacement>0)) + { + /**/ + wFindDir=EMAP_SAME_DIR; + dwFindDisplacement=Displacement; + } + else if((EMAP_CONVER_DIR==pLODStru->Dir)&&(Displacement<0)) + { + /**/ + wFindDir=EMAP_SAME_DIR; + dwFindDisplacement=-Displacement; + } + else if((EMAP_SAME_DIR==pLODStru->Dir)&&(Displacement<0)) + { + /**/ + wFindDir=EMAP_CONVER_DIR; + dwFindDisplacement=-Displacement; + } + else if((EMAP_CONVER_DIR==pLODStru->Dir)&&(Displacement>0)) + { + /**/ + wFindDir=EMAP_CONVER_DIR; + dwFindDisplacement=Displacement; + } + else + { + /*ɴ֧*/ + } + + /*LinkIDݿвҵǰlinkϢ*/ + wCurrentLinkIndex=dsuLinkIndex[pLODStru->Lnk]; + pCurrentLinkStru=dsuStaticHeadStru->pLinkStru+wCurrentLinkIndex; + + /*ѯλڲѯڵLink*/ + if(EMAP_SAME_DIR==wFindDir) + { + /**/ + + /*ݵǰλۼƫ*/ + dwFindDisplacementSum=pCurrentLinkStru->dwLength-pLODStru->Off; + + /*λжλǷͬһLink*/ + if(dwFindDisplacementSum>=dwFindDisplacement) + { + /*˵ͬһlinkϣۼλƵõλ*/ + pNewLODStru->Lnk=pCurrentLinkStru->wId; + pNewLODStru->Off=pLODStru->Off+dwFindDisplacement; + pNewLODStru->Dir=pLODStru->Dir; + chReturnValue=1; + } + else + { + /**/ + } + } + else/*FindDir=EMAP_CONVER_DIR*/ + { + /**/ + + /*ۼƫ0*/ + dwFindDisplacementSum=0; + + /*ݵǰλ÷ۼƫ*/ + dwFindDisplacementSum=pLODStru->Off; + + if(dwFindDisplacementSum>=dwFindDisplacement) + { + /*˵ͬһlink*/ + pNewLODStru->Lnk=pCurrentLinkStru->wId; + pNewLODStru->Off=pLODStru->Off-dwFindDisplacement; + pNewLODStru->Dir=pLODStru->Dir; + + /*ѯɹزѯ*/ + chReturnValue=1; + } + else + { + /**/ + } + } + + /*ѯλѯ㲻ͬһLink*/ + if (1!=chReturnValue) + { + /*˴ѭΪҪÿһLinkǶѭܳLINKINDEXNUM*/ + for (k=0;kwId, wFindDir, PointNum, pPointStru,&wCurrentLinkId) ) + { + + /*жLinkǷΪ߼仯(ѯΪҸlinkյΪ߼仯 ѯҸlinkΪ߼仯)*/ + if(((EMAP_SAME_DIR==wFindDir)&&(0x55==pCurrentLinkStru->wLogicDirChanged))|| + ((EMAP_CONVER_DIR==wFindDir)&&(0xaa==pCurrentLinkStru->wLogicDirChanged))) + { + wFindDir =~ wFindDir;/*б仯㣬ıҷ*/ + tmpLODDir =~ tmpLODDir;/*б仯,ıλ߼*/ + } + + /*pCurrentLinkStruָLink,LinkΪǰLink*/ + wCurrentLinkIndex=dsuLinkIndex[wCurrentLinkId]; + pCurrentLinkStru=dsuStaticHeadStru->pLinkStru+wCurrentLinkIndex; + + dwFindDisplacementSum+=pCurrentLinkStru->dwLength; + if(dwFindDisplacementSum>=dwFindDisplacement)/*ۼӵλֵϵǰLinkȴƫ˵Ŀλõǰlink*/ + { + + /*յλΪҷ*/ + if (EMAP_CONVER_DIR==wFindDir) + { + pNewLODStru->Lnk=pCurrentLinkStru->wId; + pNewLODStru->Off=dwFindDisplacementSum-dwFindDisplacement; + pNewLODStru->Dir=tmpLODDir; + } + /*յλΪҷ */ + else + { + + pNewLODStru->Lnk=pCurrentLinkStru->wId; + pNewLODStru->Off=dwFindDisplacement-(dwFindDisplacementSum-pCurrentLinkStru->dwLength); + pNewLODStru->Dir=tmpLODDir; + } + chReturnValue=1; + break; + } + else + { + /*ۼӵλֵϵǰLinkСƫ˵ĿλòڵǰlinkϣѭǰһLink*/ + } + } + else + { + /*ȡһlinkʧ*/ + chReturnValue=0U; + break; + } + }/*ѭΪk==LINKINDEXNUM˵ҴLINKINDEXNUM󲻿ܷ*/ + } + + }/*(0!=Displacement) end*/ + + }/*if (0!=chFlag) end */ + + return chReturnValue; + +} + +/*ʽӿ*/ +UINT8 dsuLODCalcuExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStru, INT32 Displacement, UCHAR PointNum, const DQU_POINT_STATUS_STRU *pPointStru, LOD_STRU *pNewLODStru) +{ + UINT8 rtnValue = 0U;/*ֵ*/ + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if (DQU_CBTC_HLT == cbtcVersionType) + { + rtnValue =dsuLODCalcuExp_HLT(pDsuEmapStru,pLODStru,Displacement, PointNum,pPointStru,pNewLODStru); + } + else if ((DQU_CBTC_CPK == cbtcVersionType) || (DQU_CBTC_FAO == cbtcVersionType) ||(DQU_CBTC_DG == cbtcVersionType) ) + { + rtnValue =dsuLODCalcuExp_DFT(pDsuEmapStru,pLODStru,Displacement, PointNum,pPointStru,pNewLODStru); + } + else + { + rtnValue = 0U; + + } + return rtnValue; +} + +/* +* ABλúB㷽õλơ +* const LOD_STRU * pLODAStru, Aλ +* const LOD_STRU * pLODBStru, Bλ +* UINT8 PointNum, +* const POINT_STRU * pPointStru, Ϣṹ +* INT32 *Displacement ABλƣзűʾ + ABλLinkBΪաABLinkBͬλֵȡλֵȡ +* ֵ 1,ɹ +* 0,ʧ +* ʹע⣺ע˴ֻBķвңδעAķ򡣣Ͽ෿Ŀʹã +*/ +static UINT8 dsuDispCalcuByLOCExp_DFT(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, INT32 *Displacement) +{ + UINT8 chReturnValue = 0; /*ںֵ*/ + UINT8 chFunRtn=0U; /*úֵ*/ + UINT16 CurrentLinkId = 0U; /*ڲҹʱ浱ǰLinkID*/ + UINT16 CurrentLinkIndex; /*ҹм¼Link Indexʱ*/ + + UINT8 AFindFlag=2U;/*0ʧܡ1ҳɹ2,ҡ*/ + UINT8 BFindFlag=2U;/*0ʧܡ1ҳɹ2,ҡ*/ + INT32 AFindDisplacementSum=0; /*ABеλۼֵ*/ + INT32 BFindDisplacementSum=0; /*BAλۼֵ*/ + DSU_LINK_STRU *pACurrentLinkStru=NULL; /*AǰLink*/ + DSU_LINK_STRU *pBCurrentLinkStru=NULL; /*BǰLink*/ + UINT16 k; /*ѭñ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != pDsuEmapStru) + && (NULL!= pLODAStru) && (NULL!= pLODBStru) + && (NULL != pPointStru) && (NULL != Displacement)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ָΪ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*ԤúֵΪ0*/ + *Displacement=0U; + + /*жA LinkIDЧ*/ + if((pLODAStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODAStru->Lnk] == 0xFFFF)) + { + /*LinkIdЧ,ѯʧܣ*/ + chReturnValue=0U; + return chReturnValue; + } + + /*жB LinkIDЧ*/ + if((pLODBStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODBStru->Lnk] == 0xFFFF)) + { + /*LinkIdЧ,ѯʧܣ*/ + chReturnValue=0U; + return chReturnValue; + } + + /*жlinkAƫЧ*/ + if (pLODAStru->Off > LinkLengthExp(pDsuEmapStru,pLODAStru->Lnk)) + { + /*쳣ѯʧ*/ + chReturnValue=0U; + return chReturnValue; + } + + /*жlinkBƫЧ*/ + if (pLODBStru->Off > LinkLengthExp(pDsuEmapStru,pLODBStru->Lnk)) + { + /*쳣ѯʧ*/ + chReturnValue=0U; + return chReturnValue; + } + + /*жlinkBзȷ*/ + if ((EMAP_SAME_DIR != pLODBStru->Dir) && (EMAP_CONVER_DIR != pLODBStru->Dir)) + { + /*쳣ѯʧ*/ + chReturnValue=0U; + return chReturnValue; + } + + /*LinkALinkBͬһLink*/ + if(pLODAStru->Lnk == pLODBStru->Lnk) + { + /*A,BλͬһlinkϢ*/ + *Displacement = pLODBStru->Off-pLODAStru->Off; + + if (EMAP_SAME_DIR == pLODBStru->Dir) + { + /**/ + } + else + { + /*෴תλƷ*/ + *Displacement=-(*Displacement); + } + + /*ѯɹ*/ + chReturnValue=1; + return 1; + } + + + /*LinkIDȡǰlink*/ + CurrentLinkIndex=dsuLinkIndex[pLODAStru->Lnk]; + pACurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + CurrentLinkIndex=dsuLinkIndex[pLODBStru->Lnk]; + pBCurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + + /*Bķͬз*/ + /*һΪAB԰BķǰңҵԷ¼ҵλƣؽ*/ + if (pLODBStru->Dir==EMAP_SAME_DIR) + { + /**/ + /*ۼλֵ*/ + AFindDisplacementSum=pACurrentLinkStru->dwLength-pLODAStru->Off; + BFindDisplacementSum=pBCurrentLinkStru->dwLength-pLODBStru->Off; + for (k=0;kwId, EMAP_SAME_DIR, PointNum, pPointStru,&CurrentLinkId); + if( 1==chFunRtn ) + { + /*pACurrentLinkStruָLink*/ + CurrentLinkIndex=dsuLinkIndex[CurrentLinkId]; + pACurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + + if(pACurrentLinkStru->wId==pLODBStru->Lnk) + { + /*AҵB*/ + + /*ҳɹ*/ + AFindFlag=1; + /*ۼƫֵ*/ + AFindDisplacementSum+=(pLODBStru->Off); + /*ʱAҵBƫΪ*/ + *Displacement=AFindDisplacementSum; + + /*ҳɹؽ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*AûҵBۼƫ*/ + AFindDisplacementSum+=pACurrentLinkStru->dwLength; + } + } + else if( 0xff==chFunRtn ) + { + /*·յߵδҵAֹͣ*/ + AFindFlag=0U; + } + else + { + /*Aȡһlinkʧ,Linkʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + /*Bǰһlink*/ + if(BFindFlag==2){ + chFunRtn=dsuGetAdjacentLinkIDExp(pDsuEmapStru,pBCurrentLinkStru->wId,EMAP_SAME_DIR, PointNum, pPointStru,&CurrentLinkId); + if( 1== chFunRtn) + { + /*pBCurrentLinkStruָLink*/ + CurrentLinkIndex=dsuLinkIndex[CurrentLinkId]; + pBCurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + + if(pBCurrentLinkStru->wId==pLODAStru->Lnk) + { + /*BҵA*/ + BFindFlag=1; + + /*ۼƫֵ*/ + BFindDisplacementSum+=(pLODAStru->Off); + + /*ʱBҵAƫΪ*/ + *Displacement=-BFindDisplacementSum; + + /*ҳɹؽ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*BûҵAۼƫ*/ + BFindDisplacementSum+=pBCurrentLinkStru->dwLength; + } + } + else if( 0xff==chFunRtn ) + { + /*·յߵδҵֹͣ*/ + BFindFlag=0U; + } + else + { + /*Bȡһlinkʧ,Linkʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + if((AFindFlag==0)&&(BFindFlag==0)) + { + /*ABҲûҵԷʧ*/ + chReturnValue=0U; + return chReturnValue; + } + else + { + /*ʱAFindFlagBFindFlagһΪ2*/ + } + + } + + /*ѭΪk==LINKINDEXNUM˵ҴLINKINDEXNUM󲻿ܷ*/ + chReturnValue=0U; + return chReturnValue; + + } + else /*if (pLODBStru->Dir==CONVERDIR)*/ + { + /*A,Bط*/ + AFindDisplacementSum=pLODAStru->Off; + BFindDisplacementSum=pLODBStru->Off; + for (k=0;kwId, EMAP_CONVER_DIR, PointNum, pPointStru,&CurrentLinkId); + if( 1==chFunRtn ) + { + /*pACurrentLinkStruָLink*/ + CurrentLinkIndex=dsuLinkIndex[CurrentLinkId]; + pACurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + + if(pACurrentLinkStru->wId==pLODBStru->Lnk) + { + /*AҵB*/ + + /*ҳɹ*/ + AFindFlag=1; + AFindDisplacementSum+=(pACurrentLinkStru->dwLength-pLODBStru->Off); + + /*ʱAطҵBƫΪ*/ + *Displacement=AFindDisplacementSum; + + /*ҳɹؽ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*AûҵBۼƫ*/ + AFindDisplacementSum+=pACurrentLinkStru->dwLength; + } + } + else if( 0xff==chFunRtn ) + { + /*·յߵδҵֹͣ*/ + AFindFlag=0; + } + else/*( 0==chReturnValue )*/ + { + /*Aȡһlinkʧ,Linkʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + /*Bǰһlink*/ + if(BFindFlag==2){ + chFunRtn=dsuGetAdjacentLinkIDExp(pDsuEmapStru,pBCurrentLinkStru->wId, EMAP_CONVER_DIR, PointNum, pPointStru,&CurrentLinkId); + if( 1== chFunRtn) + { + /*pACurrentLinkStruָLink*/ + CurrentLinkIndex=dsuLinkIndex[CurrentLinkId]; + pBCurrentLinkStru=dsuStaticHeadStru->pLinkStru+CurrentLinkIndex; + + if(pBCurrentLinkStru->wId==pLODAStru->Lnk) + { + /*BҵA*/ + + /*ҳɹ*/ + BFindFlag=1; + BFindDisplacementSum+=(pBCurrentLinkStru->dwLength-pLODAStru->Off); + + /*ʱBطҵAƫΪ*/ + *Displacement=-BFindDisplacementSum; + + /*ҳɹؽ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*BûҵAۼƫ*/ + BFindDisplacementSum+=pBCurrentLinkStru->dwLength; + } + } + else if( 0xff==chFunRtn ) + { + /*·յߵδҵֹͣ*/ + BFindFlag=0; + } + else /*( 0==chReturnValue )*/ + { + /*Bȡһlinkʧ,Linkʧ*/ + chReturnValue=0U; + return chReturnValue; + } + } + + if((AFindFlag==0)&&(BFindFlag==0)) + { + /*ABҲûҵԷʧ*/ + chReturnValue=0U; + return chReturnValue; + } + else + { + /*ʱAFindFlagBFindFlagһΪ2*/ + } + + } + + /*ѭΪk==LINKINDEXNUM˵ҴLINKINDEXNUM󲻿ܷ*/ + chReturnValue=0U; + return chReturnValue; + + } +} + +/* +* ABλúA㷽õλơ +* const LOD_STRU * pLODAStru, Aλ +* const LOD_STRU * pLODBStru, Bλ +* UINT8 PointNum, +* const POINT_STRU * pPointStru, Ϣṹ +* INT32 *Displacement ABλƣзűʾ + ABλLinkAΪաABLinkAͬλֵȡλֵȡ +* ֵ 1,ɹ +* 0,ʧ +* ʹע⣺ע˴ֻAķвңδעBķ򡣣ͨĿʹã +* author:qxt 20170811 +*/ +static UINT8 dsuDispCalcuByLOCExp_HLT(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, INT32 *Displacement) +{ + UINT8 chReturnValue =0U; /*ںֵ*/ + UINT8 chFunRtn=0U; /*úֵ*/ + UINT8 chFlag=1; /*ִʧܱ*/ + UINT16 wCurrentLinkId = 0U; /*ڲҹʱ浱ǰLinkID*/ + UINT16 wCurrentLinkIndex=0U; /*ҹм¼Link Indexʱ*/ + + UINT8 wAFindFlag=2;/*0ʧܡ1ҳɹ2,ҡ*/ + UINT8 wBFindFlag=2;/*0ʧܡ1ҳɹ2,ҡ*/ + INT32 dwAFindDisplacementSum=0; /*ABеλۼֵ*/ + INT32 dwBFindDisplacementSum=0; /*BAλۼֵ*/ + DSU_LINK_STRU *pACurrentLinkStru=NULL; /*AǰLink*/ + DSU_LINK_STRU *pBCurrentLinkStru=NULL; /*BǰLink*/ + UINT16 k=0U; /*ѭñ*/ + UINT8 wAFindDir = 0; /*ڼ¼ʵʲABеIJҷ,ʼֵΪAķ */ + UINT8 wBFindDir = 0; /*ڼ¼ʵʲBAеIJҷ,ʼֵΪAķ */ + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + + if ((NULL == pLODAStru) || (NULL == pLODBStru) || (NULL == pPointStru) || (NULL == Displacement)) + { + /*ָ,ѯʧ*/ + chFlag = 0U; + } + else if ((NULL != pDsuEmapStru)&&(NULL!=pDsuEmapStru->dsuEmapIndexStru)&&(NULL!=pDsuEmapStru->dsuStaticHeadStru)) + { + /*ԤúֵΪ0*/ + *Displacement = 0; + + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + + /*жA LinkIDЧ*/ + if((pLODAStru->Lnk>LINKINDEXNUM)||(DSU_NULL_16 == dsuLinkIndex[pLODAStru->Lnk])) + { + /*LinkIdЧ,ѯʧ*/ + chFlag=0U; + } + + /*жB LinkIDЧ*/ + if((pLODBStru->Lnk>LINKINDEXNUM)||(DSU_NULL_16 == dsuLinkIndex[pLODBStru->Lnk])) + { + /*LinkIdЧ,ѯʧ*/ + chFlag=0U; + } + + /*жlinkAƫЧ*/ + if (pLODAStru->Off > LinkLengthExp(pDsuEmapStru,pLODAStru->Lnk)) + { + /*쳣ѯʧ*/ + chFlag=0U; + } + + /*жlinkBƫЧ*/ + if (pLODBStru->Off > LinkLengthExp(pDsuEmapStru,pLODBStru->Lnk)) + { + /*쳣ѯʧ*/ + chFlag=0U; + } + + /*жlinkAзȷ*/ + if ((EMAP_SAME_DIR != pLODAStru->Dir) && (EMAP_CONVER_DIR != pLODAStru->Dir)) + { + /*쳣ѯʧ*/ + chFlag=0U; + } + } + else + { + /*ӵͼָΪ*/ + chFlag = 0U; + } + + + if (0U!=chFlag) + { + /*LinkALinkBͬһLink*/ + if(pLODAStru->Lnk == pLODBStru->Lnk) + { + /*A,BλͬһlinkϢ*/ + *Displacement = pLODBStru->Off-pLODAStru->Off; + + if (EMAP_SAME_DIR == pLODAStru->Dir) + { + /*账*/ + } + else + { + /*෴תλƷ*/ + *Displacement=-(*Displacement); + } + + /*ѯɹ*/ + chReturnValue = 1; + + } + else/*ABͬһlink*/ + { + /*LinkIDȡǰlink*/ + wCurrentLinkIndex=dsuLinkIndex[pLODAStru->Lnk]; + pACurrentLinkStru=dsuStaticHeadStru->pLinkStru+wCurrentLinkIndex; + wCurrentLinkIndex=dsuLinkIndex[pLODBStru->Lnk]; + pBCurrentLinkStru=dsuStaticHeadStru->pLinkStru+wCurrentLinkIndex; + + /*ʼҷ*/ + wAFindDir=pLODAStru->Dir; + wBFindDir=pLODAStru->Dir; + /*Aķͬз*/ + if (EMAP_SAME_DIR==pLODAStru->Dir) + { + /**/ + /*ۼλֵ*/ + dwAFindDisplacementSum=pACurrentLinkStru->dwLength-pLODAStru->Off; + dwBFindDisplacementSum=pBCurrentLinkStru->dwLength-pLODBStru->Off; + } + else /*if (pLODAStru->Dir==CONVERDIR)*/ + { + /*A,Bط*/ + dwAFindDisplacementSum=pLODAStru->Off; + dwBFindDisplacementSum=pLODBStru->Off; + } + + /*һΪAB԰AķǰңҵԷ¼ҵλƣؽ*/ + for (k=0U;kwId, wAFindDir, PointNum, pPointStru,&wCurrentLinkId); + if( 1==chFunRtn ) + { + /*LinkΪ߼仯(ѯΪҸlinkյΪ߼仯 ѯҸlinkΪ߼仯)*/ + /* 0x55ʾlinkյΪ߼仯㣬0xaaʾlinkΪ߼仯*/ + if(((EMAP_SAME_DIR==wAFindDir)&&(0x55==pACurrentLinkStru->wLogicDirChanged))|| + ((EMAP_CONVER_DIR==wAFindDir)&&(0xaa==pACurrentLinkStru->wLogicDirChanged))) + { + wAFindDir=~wAFindDir;/*б仯㣬ıҷ*/ + } + + /*pACurrentLinkStruָLink*/ + wCurrentLinkIndex=dsuLinkIndex[wCurrentLinkId]; + pACurrentLinkStru=dsuStaticHeadStru->pLinkStru+wCurrentLinkIndex; + + if(pACurrentLinkStru->wId==pLODBStru->Lnk) + { + /*AҵB*/ + + /*ҳɹ*/ + wAFindFlag=1; + /*ۼƫֵ*/ + if (EMAP_SAME_DIR==wAFindDir)/*ҵBʱIJѯΪʱ*/ + { + dwAFindDisplacementSum+=(pLODBStru->Off); + } + else/*ҵBʱIJѯΪʱ*/ + { + dwAFindDisplacementSum+=(pACurrentLinkStru->dwLength-pLODBStru->Off); + } + /*ʱAAķҵBƫΪ*/ + *Displacement=dwAFindDisplacementSum; + chReturnValue = 1; + /*ҳɹ˳*/ + break; + + } + else + { + /*AûҵBۼƫ*/ + dwAFindDisplacementSum+=pACurrentLinkStru->dwLength; + } + } + else if( 0xff==chFunRtn ) + { + /*·յߵδҵAֹͣ*/ + wAFindFlag=0U; + } + else + { + /*Aȡһlinkʧ,Linkʧ*/ + chReturnValue=0U; + break; + } + } + + /*Bǰһlink*/ + if(2==wBFindFlag){ + chFunRtn=dsuGetAdjacentLinkIDExp(pDsuEmapStru,pBCurrentLinkStru->wId,wBFindDir, PointNum, pPointStru,&wCurrentLinkId); + if( 1== chFunRtn) + { + /*LinkΪ߼仯(ѯΪҸlinkյΪ߼仯 ѯҸlinkΪ߼仯)*/ + /* 0x55ʾlinkյΪ߼仯㣬0xaaʾlinkΪ߼仯*/ + if(((EMAP_SAME_DIR==wBFindDir)&&(0x55==pBCurrentLinkStru->wLogicDirChanged))|| + ((EMAP_CONVER_DIR==wBFindDir)&&(0xaa==pBCurrentLinkStru->wLogicDirChanged))) + { + wBFindDir=~wBFindDir;/*б仯㣬ıҷ*/ + } + /*pBCurrentLinkStruָLink*/ + wCurrentLinkIndex=dsuLinkIndex[wCurrentLinkId]; + pBCurrentLinkStru=dsuStaticHeadStru->pLinkStru+wCurrentLinkIndex; + + if(pBCurrentLinkStru->wId==pLODAStru->Lnk) + { + /*BҵA*/ + wBFindFlag=1; + + /*ۼƫֵ*/ + if (EMAP_SAME_DIR==wBFindDir)/*ҵBʱIJѯΪʱ*/ + { + dwBFindDisplacementSum+=(pLODAStru->Off); + } + else/*ҵBʱIJѯΪʱ*/ + { + dwBFindDisplacementSum+=(pBCurrentLinkStru->dwLength-pLODAStru->Off); + } + + /*ʱBAķҵAƫΪ*/ + *Displacement=-dwBFindDisplacementSum; + chReturnValue = 1; + /*ҳɹ˳*/ + break; + } + else + { + /*BûҵAۼƫ*/ + dwBFindDisplacementSum+=pBCurrentLinkStru->dwLength; + } + } + else if( 0xff==chFunRtn ) + { + /*·յߵδҵֹͣ*/ + wBFindFlag=0U; + } + else + { + /*Bȡһlinkʧ,Linkʧ*/ + chReturnValue=0U; + break; + } + } + + if((0U==wAFindFlag)&&(0U==wBFindFlag)) + { + /*ABҲûҵԷʧ*/ + chReturnValue=0U; + break; + } + else + { + /*ʱAFindFlagBFindFlagһΪ2*/ + } + + }/*forѭend*/ + + /*ѭΪk==LINKINDEXNUM˵ҴLINKINDEXNUM󲻿ܷ*/ + /*ûҵʱchReturnValue=0*/ + } + }/*0!=chReturnValueend*/ + + return chReturnValue; +} + + +/* +*ʽӿ +* ABλõõλơ +* const LOD_STRU * pLODAStru, Aλ +* const LOD_STRU * pLODBStru, Bλ +* UINT8 PointNum, +* const POINT_STRU * pPointStru, Ϣṹ +* INT32 *Displacement ABλƣзűʾ +* ֵ 1,ɹ +* 0,ʧ +* ʹע⣺Ͽ෿Ŀ㷨ǰBķңABλLinkBΪգ + ͨĿ߼仯㣬㷨ΪAķңABλLinkAΪա +* author:qxt 20170811 +*/ +UINT8 dsuDispCalcuByLOCExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, INT32 *Displacement) +{ + UINT8 rtnValue = 0U;/*ֵ*/ + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if (DQU_CBTC_HLT == cbtcVersionType) + { + rtnValue=dsuDispCalcuByLOCExp_HLT(pDsuEmapStru, pLODAStru, pLODBStru,PointNum,pPointStru,Displacement); + } + else if ((DQU_CBTC_CPK == cbtcVersionType) || (DQU_CBTC_FAO == cbtcVersionType) ||(DQU_CBTC_DG == cbtcVersionType)) + { + rtnValue=dsuDispCalcuByLOCExp_DFT(pDsuEmapStru, pLODAStru, pLODBStru,PointNum,pPointStru,Displacement); + } + else + { + rtnValue = 0U; + } + return rtnValue; +} + + +/* +* ܣ ˺ĹDzѯλülinkС +* **************************************************************************************************** +* 1 2 3 4 5 6 +* --------------*-------------------------------------------*----------------- +* S E +* ͼ Link˵㡣*ѯλá123...Linkʾ +* ͼʾLink34Ϊ +* ˴pLODEndStruң +* SpLODEndStru->DirңҵE򷵻سɹҲ򷵻ʧܡ +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru նλ +* const UINT8 PointNum Ŀ +* const POINT_STRU * pPointStru Ϣ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* ֵ 0, ѯʧ +* 1, ѯɹ +* ʹע⣺ Ŀǰûа˵Link Id +* Ҫ֮γ򣬷򷵻0 +* Ͽ෿Ŀʹ +*/ +static UINT8 dsuGetLinkBtwLocExp_DFT(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, + UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], UINT16 *wLinkNumber) +{ + UINT16 chFindLinkNum = 0; /*ҵlinkĿ*/ + UINT16 wCurrentLinkID = 0; /*ǰlink*/ + UINT16 wNextLinkID = 0; /*link*/ + UINT16 wFindLink[DSU_MAX_LINK_BETWEEN];/*ҵlink*/ + UINT16 i = 0; /*ѭñ*/ + UINT8 chReturnValue = 0;/*ֵ*/ + UINT16 k; /*ѭñ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + if ((NULL != pDsuEmapStru) && (NULL != pLODStartStru) && (NULL != pLODEndStru) + && (NULL != pPointStru) && (NULL != wLinkNumber)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + } + else + { + /*ָΪ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*LinkֵԤ0*/ + *wLinkNumber=0; + + /*жLinkЧ*/ + if((pLODStartStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODStartStru->Lnk] == 0xFFFF) + ||(pLODEndStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODEndStru->Lnk] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + chReturnValue = 0; + return chReturnValue; + } + + /*жݷȷ*/ + if ((pLODEndStru->Dir != EMAP_SAME_DIR) && (pLODEndStru->Dir != EMAP_CONVER_DIR)) + { + /*Ч쳣ѯʧܣش*/ + chReturnValue = 0; + return chReturnValue; + } + + if(pLODStartStru->Lnk==pLODEndStru->Lnk) + { + /*ʼնͬһLinkϣ*/ + + /*linkΪ0*/ + *wLinkNumber=0; + + + if (((pLODEndStru->Dir==EMAP_SAME_DIR)&&(pLODEndStru->Off>=pLODStartStru->Off)) + ||((pLODEndStru->Dir==EMAP_CONVER_DIR)&&(pLODEndStru->Off<=pLODStartStru->Off))) + { + /*ѯȷܹյ*/ + /*زѯɹ˳*/ + chReturnValue = 1; + return chReturnValue; + } + else + { + /*زѯɹ˳*/ + chReturnValue = 0; + return chReturnValue; + } + + } + + /*ʼlinkΪǰlink*/ + wCurrentLinkID = pLODStartStru->Lnk; + + /*ҵĵǰlinkնlinkʱwhileѭ*/ + for (k=0;kDir, PointNum, pPointStru,&wNextLinkID); + + /*ֵͨжǷȷ*/ + if (chReturnValue!=1) + { + /*ѯʧܣزѯ*/ + chFindLinkNum=0; + chReturnValue = 0; + return chReturnValue; + } + + /*ҵlinkΪµĵǰlink*/ + wCurrentLinkID=wNextLinkID; + + if(wCurrentLinkID != pLODEndStru->Lnk) + { + if (chFindLinkNum>=DSU_MAX_LINK_BETWEEN) + { + /*ʧܣʵִʱӦó*/ + chFindLinkNum=0; + chReturnValue = 0; + return chReturnValue; + } + else + { + /*ǰLinkڽLink¾ֲ飬ͬʱҵlinkĿһ*/ + wFindLink[chFindLinkNum] = wCurrentLinkID; + chFindLinkNum++; + } + + } + else + { + /*ǰLinkǽLinkǰLinkдУҵնlink˳ѭ*/ + break; + } + + + } + + if(k==LINKINDEXNUM) + { + /*ѭΪk==LINKINDEXNUM˵ҴLINKINDEXNUM󲻿ܷ*/ + chReturnValue=0U; + return chReturnValue; + } + + /*˳ѭҵնlink,ҵlink*/ + for (i=0; iDirңҵE򷵻سɹҲ򷵻ʧܡ +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru նλ +* const UINT8 PointNum Ŀ +* const POINT_STRU * pPointStru Ϣ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* ֵ 0, ѯʧ +* 1, ѯɹ +* ʹע⣺ Ŀǰûа˵Link Id +* Ҫ֮γ򣬷򷵻0 +* ڲúͨĿʹ +* author: qxt 20170814 +*/ +static UINT8 dsuGetLinkBtwLocExp_HLT(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, + UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], UINT16 *wLinkNumber) +{ + UINT16 chFindLinkNum = 0; /*ҵlinkĿ*/ + UINT16 wCurrentLinkID = 0; /*ǰlink*/ + UINT16 wNextLinkID = 0; /*link*/ + UINT16 wFindLink[DSU_MAX_LINK_BETWEEN];/*ҵlink*/ + UINT16 i = 0; /*ѭñ*/ + UINT8 chReturnValue = 0;/*ֵ*/ + UINT16 k=0U; /*ѭñ*/ + UINT16 wCurrentLinkIndex = 0; /*ǰLink Index */ + DSU_LINK_STRU *pCurrentLinkStru=NULL;/*ѭҹʱ浱ǰLinkṹ*/ + UINT8 wFindDir = 0; /*ڼ¼ʵʲеIJҷ*/ + UINT8 chFlag=1; /*ִʧܱʶλ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL;/*add by qxt 20161029*/ + + if ((NULL == pLODStartStru) || (NULL == pLODEndStru) || (NULL == pPointStru) || (NULL == wLinkNumber)) + { + /*ָ,ѯʧ*/ + chFlag = 0U; + } + else if ((NULL != pDsuEmapStru)&&(NULL !=pDsuEmapStru->dsuEmapIndexStru)&&(NULL!=pDsuEmapStru->dsuStaticHeadStru)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru;/*add by qxt 20161029*/ + + /*LinkֵԤ0*/ + *wLinkNumber = 0; + + /*жLinkЧ*/ + if((pLODStartStru->Lnk>LINKINDEXNUM)||(DSU_NULL_16==dsuLinkIndex[pLODStartStru->Lnk]) + ||(pLODEndStru->Lnk>LINKINDEXNUM)||(DSU_NULL_16==dsuLinkIndex[pLODEndStru->Lnk])) + { + /*Ч쳣ѯʧܣش*/ + chFlag = 0U; + } + + /*жݷȷ*/ + if ((EMAP_SAME_DIR!=pLODStartStru->Dir) && (EMAP_CONVER_DIR!=pLODStartStru->Dir)) + { + /*Ч쳣ѯʧܣش*/ + chFlag = 0U; + } + } + else + { + /*ӵͼָΪ*/ + chFlag = 0U; + } + + + + if (0U!=chFlag) + { + /*ʼնͬһLinkϣ*/ + if(pLODStartStru->Lnk==pLODEndStru->Lnk) + { + /*linkΪ0*/ + *wLinkNumber=0; + if (((EMAP_SAME_DIR==pLODStartStru->Dir)&&(pLODEndStru->Off>=pLODStartStru->Off)) + ||((EMAP_CONVER_DIR==pLODStartStru->Dir)&&(pLODEndStru->Off<=pLODStartStru->Off))) + { + /*ѯȷܹյ*/ + /*زѯɹ˳*/ + chReturnValue = 1; + } + else + { + /*زѯɹ˳*/ + chReturnValue = 0; + } + + } + else/*ʼն˲ͬһLink start*/ + { + /*ʼlinkΪǰlink*/ + wCurrentLinkID = pLODStartStru->Lnk; + + /*LinkIDݿвҵǰlinkϢ*/ + wCurrentLinkIndex=dsuLinkIndex[wCurrentLinkID]; + pCurrentLinkStru=dsuStaticHeadStru->pLinkStru+wCurrentLinkIndex; + /*ʼѯΪķ */ + wFindDir=pLODStartStru->Dir; + + /*ҵĵǰlinkնlinkʱwhileѭ*//*˴ѭΪ˼ѭܳLINKINDEXNUM*/ + for (k=0;kwLogicDirChanged))|| + ((EMAP_CONVER_DIR==wFindDir)&&(0xaa==pCurrentLinkStru->wLogicDirChanged))) + { + wFindDir=~wFindDir;/*б仯㣬ıҷ*/ + } + + /*ҵlinkΪµĵǰlink*/ + wCurrentLinkID=wNextLinkID; + + /*pCurrentLinkStruָLink,LinkΪǰLink*/ + wCurrentLinkIndex=dsuLinkIndex[wCurrentLinkID]; + pCurrentLinkStru=dsuStaticHeadStru->pLinkStru+wCurrentLinkIndex; + + if(wCurrentLinkID != pLODEndStru->Lnk) + { + if (chFindLinkNum>=DSU_MAX_LINK_BETWEEN) + { + /*ʧܣʵִʱӦó*/ + chFindLinkNum=0; + chReturnValue = 0; + break; + } + else + { + /*ǰLinkڽLink¾ֲ飬ͬʱҵlinkĿһ*/ + wFindLink[chFindLinkNum] = wCurrentLinkID; + chFindLinkNum++; + } + + } + else + { + /*ǰLinkǽLinkǰLinkдУҵնlink˳ѭ*/ + break; + } + + }/*forѭ*/ + + /*ҴLINKINDEXNUM*/ + if((k!=LINKINDEXNUM)&&(0!=chReturnValue)) + { + /*˳ѭҵնlink,ҵlink*/ + for (i=0; i current λ*/ + INT32 DisplacementCE; /*current -> end λ */ + INT32 DisplacementSE; /*start -> end λ */ + LOD_STRU CurrentLODStru; /*һ洢ǰLODȡpLODEndStruڼλʱ + ͳһķλ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + if ((NULL != pDsuEmapStru) && (NULL != pLODStartStru) && (NULL != pLODEndStru) + && (NULL != pPointStru) && (NULL != pLocInArea)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + } + else + { + /*ָΪ*/ + chReturnValue = 0; + return chReturnValue; + } + + + /*Ĭò*/ + *pLocInArea=0; + + /*жݵǰλlinkЧ*/ + if((pCurrentLODStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pCurrentLODStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + /*жݵǰλƫЧ*/ + if (pCurrentLODStru->Off > LinkLengthExp(pDsuEmapStru,pCurrentLODStru->Lnk)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + /*жݵǰλ÷Ч*/ + if ((EMAP_SAME_DIR != pCurrentLODStru->Dir) && (EMAP_CONVER_DIR != pCurrentLODStru->Dir)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*жλlinkЧ*/ + if((pLODStartStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODStartStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + /*жλlinkƫЧ*/ + if (pLODStartStru->Off > LinkLengthExp(pDsuEmapStru,pLODStartStru->Lnk)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + /*ж㷽Ч*/ + if ((EMAP_SAME_DIR != pLODStartStru->Dir) && (EMAP_CONVER_DIR != pLODStartStru->Dir)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*жյλlinkŵЧ*/ + if((pLODEndStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODEndStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + /*жյλlinkƫЧ*/ + if (pLODEndStru->Off > LinkLengthExp(pDsuEmapStru,pLODEndStru->Lnk)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + /*жյ㷽Ч*/ + if ((EMAP_SAME_DIR != pLODEndStru->Dir) && (EMAP_CONVER_DIR != pLODEndStru->Dir)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + + + CurrentLODStru.Lnk=pCurrentLODStru->Lnk; + CurrentLODStru.Off=pCurrentLODStru->Off; + CurrentLODStru.Dir=pLODEndStru->Dir; + + /*λж3ϵ*/ + + /*ѯDisplacementSE*/ + chReturnValue= dsuDispCalcuByLOCExp(pDsuEmapStru,pLODStartStru, pLODEndStru, PointNum, pPointStru, &DisplacementSE); + if(chReturnValue!=1) + { + /*λƲѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + else + { + /*SEڣֵΪ1*/ + chReturnValue=1; + } + + /*ѯDisplacementSC*/ + chReturnValue= dsuDispCalcuByLOCExp(pDsuEmapStru,pLODStartStru, &CurrentLODStru, PointNum, pPointStru, &DisplacementSC); + if(chReturnValue!=1) + { + /*λƲѯʧ*/ + *pLocInArea=0; + chReturnValue=0; + return chReturnValue; + } + + /*ѯDisplacementCE*/ + chReturnValue= dsuDispCalcuByLOCExp(pDsuEmapStru,&CurrentLODStru, pLODEndStru, PointNum, pPointStru, &DisplacementCE); + if(chReturnValue!=1) + { + /*λƲѯʧ*/ + *pLocInArea=0; + chReturnValue=0; + return chReturnValue; + } + + if((DisplacementSC==0)&&(DisplacementCE==0)) + { + /*غ*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + + if(DisplacementSC==0) + { + /*ֻغ*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + + if(DisplacementCE==0) + { + /*ǰλյ*/ + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + } + + /*жDisplacementSCDisplacementCEǷͬ*/ + if( ((DisplacementSC>0)&&(DisplacementCE>0))||((DisplacementSC<0)&&(DisplacementCE<0))) + { + /*DisplacementSCDisplacementCEͬ*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + else + { + /*DisplacementSCDisplacementCEŲͬǰλò*/ + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + } + +} + +/* +* ܣ ˺ĹǽжϵǰλǷָΧڡ +* **************************************************************************************************** +* +* --------------*--------------------*---------------------*----------------- +* S C E +* Link߼仯㣬㷨ΪλDisplacementCSDisplacementCEλƷ죬˵CSE +* +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* const UINT8 PointNum, Ŀ +* const POINT_STRU * pPointStru, Ϣ +* const LOD_STRU * pCurrentLODStru,ǰλ +* ڲ UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +* ʹע⣺1.ڵǰλ˵λʱʱ¹жϣ +* 1) ǰλ㣬Ϊõڱ +* 2) ǰλյ㣬Ϊõ㲻ڱ +* 3) 3غϷڡ +* 2.ҵյ㶼ڣԵαʼնλãֻҪεһڣ˵ڵʼնγɵı +* 3.SE򲻴ڣ0ʧܡSC,SEڣ1ɹǵC +*author:qxt 20170811 +*/ +static UINT8 dsuCheckLocInAreaExp_HLT(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, + const LOD_STRU *pCurrentLODStru,UINT8 *pLocInArea) +{ + UINT8 chReturnValue = 0;/*ֵ*/ + UINT8 chFlag=1; /*ִʧܱʶλ*/ + UINT8 chRtnCS = 0;/*λCSֵ*/ + UINT8 chRtnCE = 0;/*λCEֵ*/ + INT32 dwDisplacementCS=0; /*current -> start λ*/ + INT32 dwDisplacementCE=0; /*current -> end λ */ + INT32 dwDisplacementSE=0; /*start -> end λ */ + LOD_STRU struCurrentLOD; /*һ洢ǰLODȡpLODStartStruڼλʱ + ͳһķλ*/ + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + + if ((NULL == pLODStartStru) || (NULL == pLODEndStru) + || (NULL == pPointStru) || (NULL == pLocInArea) || (NULL == pCurrentLODStru)) + { + /*ָ,ѯʧ*/ + chFlag = 0U; + } + + if ((0U!= chFlag) && (NULL != pDsuEmapStru)&&(NULL !=pDsuEmapStru->dsuEmapIndexStru)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + + /*Ĭò*/ + *pLocInArea = 0; + + /*жݵǰλlinkЧ*/ + if((pCurrentLODStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pCurrentLODStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + /*жݵǰλƫЧ*/ + if (pCurrentLODStru->Off > LinkLengthExp(pDsuEmapStru,pCurrentLODStru->Lnk)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + /*жݵǰλ÷Ч*/ + if ((EMAP_SAME_DIR != pCurrentLODStru->Dir) && (EMAP_CONVER_DIR != pCurrentLODStru->Dir)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + + /*жλlinkЧ*/ + if((pLODStartStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODStartStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + /*жλlinkƫЧ*/ + if (pLODStartStru->Off > LinkLengthExp(pDsuEmapStru,pLODStartStru->Lnk)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + /*ж㷽Ч*/ + if ((EMAP_SAME_DIR != pLODStartStru->Dir) && (EMAP_CONVER_DIR != pLODStartStru->Dir)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + + /*жյλlinkŵЧ*/ + if((pLODEndStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODEndStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + /*жյλlinkƫЧ*/ + if (pLODEndStru->Off > LinkLengthExp(pDsuEmapStru,pLODEndStru->Lnk)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + /*жյ㷽Ч*/ + if ((EMAP_SAME_DIR != pLODEndStru->Dir) && (EMAP_CONVER_DIR != pLODEndStru->Dir)) + { + /*ڲ쳣ѯʧ*/ + chFlag = 0U; + } + } + else + { + /*ӵͼָΪ*/ + chFlag = 0U; + } + + + if (0U!=chFlag) + { + /*λж3ϵ*/ + struCurrentLOD.Lnk=pCurrentLODStru->Lnk; + struCurrentLOD.Off=pCurrentLODStru->Off; + struCurrentLOD.Dir=pLODStartStru->Dir; + /*ѯDisplacementSE*/ + chReturnValue= dsuDispCalcuByLOCExp(pDsuEmapStru,pLODStartStru, pLODEndStru, PointNum, pPointStru, &dwDisplacementSE); + if(1U != chReturnValue) + { + /*λƲѯʧ*/ + chReturnValue = 0; + } + else/*SE*/ + { + + /*ѯDisplacementCS*/ + chRtnCS= dsuDispCalcuByLOCExp(pDsuEmapStru,&struCurrentLOD,pLODStartStru,PointNum, pPointStru, &dwDisplacementCS); + + /*ѯDisplacementCE*/ + chRtnCE= dsuDispCalcuByLOCExp(pDsuEmapStru,&struCurrentLOD,pLODEndStru,PointNum, pPointStru, &dwDisplacementCE); + + if((1!=chRtnCS)||(1!=chRtnCE)) + { + /*λƲѯʧ*/ + *pLocInArea=0; + chReturnValue=0; + } + + else + { + /*غ*/ + if((0==dwDisplacementCS)&&(0==dwDisplacementCE)) + { + *pLocInArea=1; + chReturnValue = 1; + } + /*ֻغ*/ + else if(0==dwDisplacementCS) + { + + *pLocInArea=1; + chReturnValue = 1; + } + + /*ǰλյ*/ + else if(0==dwDisplacementCE) + { + + *pLocInArea=0; + chReturnValue = 1; + } + + /*жDisplacementCSDisplacementCSǷͬ changed by qxt*/ + else if( ((dwDisplacementCS>0)&&(dwDisplacementCE<0))||((dwDisplacementCS<0)&&(dwDisplacementCE>0))) + { + /*DisplacementCSDisplacementCEŲͬ*/ + *pLocInArea=1; + chReturnValue = 1; + } + else + { + /*DisplacementCSDisplacementCEͬǰλò*/ + *pLocInArea=0; + chReturnValue = 1; + } + + } + }/*SE end*/ + } + + return chReturnValue; +} + +/*ʽӿ*/ +UINT8 dsuCheckLocInAreaExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU * pPointStru, + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea) +{ + UINT8 rtnValue = 0U;/*ֵ*/ + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if (DQU_CBTC_HLT == cbtcVersionType) + { + rtnValue =dsuCheckLocInAreaExp_HLT(pDsuEmapStru,pLODStartStru,pLODEndStru,PointNum,pPointStru,pCurrentLODStru,pLocInArea); + } + else if ((DQU_CBTC_CPK == cbtcVersionType) || (DQU_CBTC_FAO == cbtcVersionType)|| (DQU_CBTC_DG == cbtcVersionType)) + { + rtnValue =dsuCheckLocInAreaExp_DFT(pDsuEmapStru,pLODStartStru,pLODEndStru,PointNum,pPointStru,pCurrentLODStru,pLocInArea); + } + else + { + rtnValue = 0U; + + } + return rtnValue; +} + +/************************************************************************ + +ܣ ˺ĹlinkIDϢѯlinkijϢ +ڲ const UINT16 wLinkID linkID +ڲ +ֵ UINT32 dwLinkLength ѯʧ: 0xffffffff; ѯɹ: زҵlink +************************************************************************/ +/*ܺѯlink*/ +UINT32 LinkLengthExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 wLinkID) +{ + UINT32 dwLinkLength = 0;/*ֵ*/ + DSU_LINK_STRU *pstLinK;/*ָlinkϢĽṹָ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + + if (NULL != pDsuEmapStru) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ӵͼָΪ*/ + dwLinkLength = 0xffffffff; + return dwLinkLength; + } + + /*жЧ*/ + if((wLinkID>LINKINDEXNUM)||(dsuLinkIndex[wLinkID] == 0xFFFF)) + { + /*Ч룬ѯʧܣĬֵ*/ + dwLinkLength = 0xffffffff; + return dwLinkLength; + } + /*ùҵlinkϢ*/ + pstLinK = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[wLinkID]; + dwLinkLength = pstLinK->dwLength; + return dwLinkLength; +} + +/* +* ܣ ˺ĹǽжϵǰλǷָΧڡ + ˺ĹCheckLocInAreaġCheckLocInAreaԷûҪ󣬼漰ķȷġ + CheckLocInAreaQuickҪStartLODܹEndLOD +* **************************************************************************************************** +* +* --------------*--------------------*---------------------*----------------- +* S C E +* 㷨ΪжϵǰλSEǷͬһLinkϣ +* ͬһLinkϣݷλжǷڣͬһLinkжCLinkIdǷSE֮ijһLinkIdͬ +* ֮LinkԱԶڶεñѯǷڵĺЧʺа +* +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* const LOD_STRU * pCurrentLODStru,ǰλ +* ڲ UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +* ʹע⣺1.ڵǰλ˵λʱʱ¹жϣ +* 1) ǰλ㣬Ϊõڱ +* 2) ǰλյ㣬Ϊõ㲻ڱ +* 3) 3غϷڡ +* 2.ҵյ㶼ڣԵαʼնλãֻҪεһڣ˵ڵʼնγɵı +* 3.SE򲻴ڣ0ʧܡSC,SEڣ1ɹǵC +*/ +UINT8 dsuCheckLocInAreaQuickExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT16 wLinkNumber,UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea) +{ + UINT8 chReturnValue = 0;/*ֵ*/ + UINT16 i = 0; /*ѭñ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + if ((NULL != pDsuEmapStru) && (NULL != pLODStartStru) && (NULL != pLODEndStru) && (NULL != wLinkID) + && (NULL!= pCurrentLODStru) && (NULL!= pLocInArea)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + } + else + { + /*ָΪ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*Ĭò*/ + *pLocInArea=0; + + /*жЧ*/ + if((pCurrentLODStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pCurrentLODStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + /*жЧ*/ + if((pLODStartStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODStartStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + /*жЧ*/ + if((pLODEndStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODEndStru->Lnk] == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*غϣ*/ + if((pCurrentLODStru->Off==pLODStartStru->Off)&&(pCurrentLODStru->Off==pLODEndStru->Off)&& + (pCurrentLODStru->Lnk==pLODStartStru->Lnk)&&(pCurrentLODStru->Lnk==pLODEndStru->Lnk)) + { + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + + /*жCǷSELnkϣSE*/ + + if(pLODEndStru->Dir==EMAP_SAME_DIR) + { + /*ǰΪ*/ + + if ((pCurrentLODStru->Lnk==pLODStartStru->Lnk)&&(pCurrentLODStru->Lnk==pLODEndStru->Lnk)) + { + /*S,C,ELinkͬ*/ + if ((pCurrentLODStru->Off>=pLODStartStru->Off)&&(pCurrentLODStru->OffOff)) + { + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + else + { + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + } + } + + else if(pCurrentLODStru->Lnk==pLODStartStru->Lnk) + { + if (pCurrentLODStru->Off>=pLODStartStru->Off) + { + /*ǰCLnkSͬҵǰCOffڵSOff*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + else + { + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + } + + } + else if(pCurrentLODStru->Lnk==pLODEndStru->Lnk) + { + if (pCurrentLODStru->OffOff) + { + /*ǰCLnkEͬҵǰCOffСEof*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + else + { + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + } + + } + else + { + /*㣬CSE㲻ͬLnk*/ + } + } + else if(pLODEndStru->Dir==EMAP_CONVER_DIR) + { + /*ǰΪ*/ + + if ((pCurrentLODStru->Lnk==pLODStartStru->Lnk)&&(pCurrentLODStru->Lnk==pLODEndStru->Lnk)) + { + if ((pCurrentLODStru->Off<=pLODStartStru->Off)&&(pCurrentLODStru->Off>pLODEndStru->Off)) + { + /*ǰCLnkSͬ*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + + else + { + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + } + } + else if(pCurrentLODStru->Lnk==pLODStartStru->Lnk) + { + if (pCurrentLODStru->Off<=pLODStartStru->Off) + { + /*ǰCLnkSͬ*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + else + { + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + } + } + else if(pCurrentLODStru->Lnk==pLODEndStru->Lnk) + { + if (pCurrentLODStru->Off>pLODEndStru->Off) + { + /*ǰCLnkEͬ*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + else + { + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + } + } + else + { + + /*㣬CSE㲻ͬ*/ + } + } + else + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + return chReturnValue; + } + + /*жC㲻SELnkϣѭCLnkǷSEмijһLnk*/ + for(i=0;iLnk==wLinkID[i]) + { + /*ǰCLnkSEڵijһLnkIdͬ*/ + *pLocInArea=1; + chReturnValue = 1; + return chReturnValue; + } + } + + /*ǰCSEһLnkͬز*/ + *pLocInArea=0; + chReturnValue = 1; + return chReturnValue; + +} + +/* +* ܣ ˺ĹжϵǰλǷָΧڣ˺ǶdsuCheckLocInAreaQuick + һ䡣ڽǰȡټǷڡ +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* const LOD_STRU * pCurrentLODStru,ǰλ +* UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +*/ +UINT8 dsuCheckLocInAreaQuickExp2(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT16 wLinkNumber,UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea) +{ + LOD_STRU TempLODStartStru; + LOD_STRU TempLODEndStru; + LOD_STRU TempCurrentLODStru; + + + memcpy(&TempLODStartStru,pLODStartStru,sizeof(LOD_STRU)); + memcpy(&TempLODEndStru,pLODEndStru,sizeof(LOD_STRU)); + memcpy(&TempCurrentLODStru,pCurrentLODStru,sizeof(LOD_STRU)); + + /*LODķȡ*/ + if (pLODEndStru->Dir==EMAP_SAME_DIR) + { + TempLODStartStru.Dir=EMAP_CONVER_DIR; + TempLODEndStru.Dir=EMAP_CONVER_DIR; + TempCurrentLODStru.Dir=EMAP_CONVER_DIR; + } + else + { + TempLODStartStru.Dir=EMAP_SAME_DIR; + TempLODEndStru.Dir=EMAP_SAME_DIR; + TempCurrentLODStru.Dir=EMAP_SAME_DIR; + } + + return dsuCheckLocInAreaQuickExp(pDsuEmapStru,&TempLODStartStru,&TempLODEndStru,wLinkNumber,wLinkID,&TempCurrentLODStru,pLocInArea); +} + +/*****************************Ϊ¶ƽҪõĺ**************************/ +/************************************************************************ + + ܣ ˺ĹDzѯǰGardeGrade + ڲ const UINT16 wCurrentGradeID ǰ¶ȱ + const UCHAR chDirection з + const UCHAR PointNum MAΧڵĿ + const DQU_POINT_STATUS_STRU * pPointStru MAΧڵϢ + ڲ + ֵ UINT16 wFindGradeID ѯʧ: 0xffff; ѯɹ: ڵ¶ID +************************************************************************/ +/*ܺ,ѯǰGardeGrade*/ +UINT16 FindAdjacentGradeIDExp(DSU_EMAP_STRU *pDsuEmapStru,const UINT16 wCurrentGradeID, const UCHAR chDirection, + const UCHAR PointNum, const DQU_POINT_STATUS_STRU * pPointStru) +{ + UINT16 wFindGradeID = 0;/*ֵ*/ + DSU_GRADE_STRU *pstGrade=NULL;/*ָ¶ϢĽṹָ*/ + const DQU_POINT_STATUS_STRU * pstPointStrut=NULL;/*洢Ϣľֲ*/ + UINT16 wPointId = 0;/*洢¶ȹID*/ + UCHAR i = 0;/*ѭñ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 GRADEINDEXNUM = 0; + UINT16* dsuGradeIndex = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + if ((NULL != pDsuEmapStru) && (NULL != pPointStru)) + { + GRADEINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->GRADEINDEXNUM; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*Чزѯʧ*/ + wFindGradeID = 0xffff; + return wFindGradeID; + } + + /*жЧ*/ + if((wCurrentGradeID>GRADEINDEXNUM)||(dsuGradeIndex[wCurrentGradeID] == 0xFFFF)) + { + /*Чزѯʧ*/ + wFindGradeID = 0xffff; + return wFindGradeID; + } + + /*жݷЧ*/ + if ((EMAP_SAME_DIR != chDirection) && (EMAP_CONVER_DIR != chDirection)) + { + /*Чزѯʧ*/ + wFindGradeID = 0xffff; + return wFindGradeID; + } + + /*зlink߼ͬʱǰ¶ȵĩ¶Ƚвѯ*/ + if (EMAP_SAME_DIR == chDirection) + { + + /*ùֱҵǰ¶ȵϢ*/ + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[wCurrentGradeID]; + + if ((0xffff == pstGrade->wTmnlJointSideGradeId)&&(0xffff == pstGrade->wTmnlJointMainGradeId)) + { + /*ǰ¶Ѿû¶ȣ0*/ + wFindGradeID = 0xffff; + return wFindGradeID; + } + /*ڵǰ¶ȵĩڲ¶Ϊʱĩ¶ȼΪ*/ + if (0xffff == pstGrade->wTmnlJointSideGradeId) + { + /*ѯɹϢ*/ + wFindGradeID = pstGrade->wTmnlJointMainGradeId; + return wFindGradeID; + } + else + { + /*ڵǰ¶ȵĩڲ¶ȲΪʱʵʱĵ״̬ж¶*/ + + /*Ϣ*/ + pstPointStrut = pPointStru; + + /*Ϣ*/ + wPointId = pstGrade->wTmnlRelatePointId; + + for (i=0; iPointId) + { + /*ʧȥʾ,쳣ѯʧܣĬֵ˳*/ + if (EMAP_POINT_STATUS_LOSE == pstPointStrut->PointStatus) + { + wFindGradeID = 0xffff; + return wFindGradeID; + } + else + { + /*ڶλ,ĩ¶ȼΪ*/ + if (EMAP_POINT_STATUS_MAIN == pstPointStrut->PointStatus) + { + wFindGradeID = pstGrade->wTmnlJointMainGradeId; + return wFindGradeID; + } + else + { + /*ڷλ,ĩڲ¶ȼΪ*/ + wFindGradeID = pstGrade->wTmnlJointSideGradeId; + return wFindGradeID; + } + } + } + pstPointStrut++; + } + + /*ûҵصĵϢ,ѯʧ,Ĭֵ*/ + wFindGradeID = 0xffff; + return wFindGradeID; + } + }/*end of if (SAMEDIR == chDirection)*/ + else + { + /*зlink߼෴ʱǰ¶ȵʼ˶¶Ƚвѯ*/ + + + + /*ùֱҵǰ¶ȵϢ*/ + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[wCurrentGradeID]; + + if ((0xffff == pstGrade->wOrgnJointSideGradeId)&&(0xffff == pstGrade->wOrgnJointMainGradeId)) + { + /*ǰ¶Ѿû¶ȣ0*/ + wFindGradeID = 0xffff; + return wFindGradeID; + } + /*ڵǰ¶ȵʼڲ¶Ϊʱʼ¶ȼΪ*/ + if (0xffff == pstGrade->wOrgnJointSideGradeId) + { + /*ѯɹ¶ID*/ + wFindGradeID = pstGrade->wOrgnJointMainGradeId; + return wFindGradeID; + } + else + { + /*ڵǰ¶ȵʼڲ¶ȲΪʱʵʱĵ״̬ж¶*/ + + /*Ϣ*/ + pstPointStrut = pPointStru; + + /*Ϣ*/ + wPointId = pstGrade->wOrgnRelatePointId; + + for (i=0; iPointId) + { + /*ʧȥʾ,쳣ѯʧܣĬֵ˳*/ + if (EMAP_POINT_STATUS_LOSE == pstPointStrut->PointStatus) + { + wFindGradeID = 0xffff; + return wFindGradeID; + } + else + { + /*ڶλ,ʼ¶ȼΪ*/ + if(EMAP_POINT_STATUS_MAIN == pstPointStrut->PointStatus) + { + wFindGradeID = pstGrade->wOrgnJointMainGradeId; + return wFindGradeID; + } + else + { + /*ڷλ,ʼڲ¶ȼΪ*/ + wFindGradeID = pstGrade->wOrgnJointSideGradeId; + return wFindGradeID; + } + } + } + pstPointStrut++; + } + + /*ûҵصĵϢ,ѯʧ,Ĭֵ*/ + wFindGradeID = 0xffff; + return wFindGradeID; + } + } +} +/* +*ܣѯij¶ID +*UINT16 linkId,UINT32 offset +*UINT16 GradeID¶ID +*ֵ 0ִʧܣ1ɹ +*/ +static UINT8 dsuGetGradeIdbyLocExp_DFT(DSU_EMAP_STRU *pDsuEmapStru, const UINT16 linkId, const UINT32 offset, UINT16 *GradeID) +{ + UINT16 i=0,j=0; /*ѭ*/ + DSU_GRADE_STRU* curGrade=NULL; /*ǰ¶ʱ*/ + UINT8 bReturnValue; /*ֵ*/ + DSU_LINK_STRU *pLinkStru=NULL; /*LinkϢṹָ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != GradeID)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=pDsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + if((linkId>LINKINDEXNUM)||((dsuLinkIndex[linkId]) == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*ȡǰλõlinkӦλϢ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[linkId]; + + /*ǰlinkġLink¶ϢԡΪͳһ¶*/ + if(0 == pLinkStru->wGrade) + { + for(i=0;iwGradeLen;i++) + { + /*ʼǰ¶*/ + curGrade = dsuStaticHeadStru->pGradeStru + i; + /*ʼlinklinkͬ*/ + if(linkId == curGrade->wOrgnLinkId) + { + /*ƫ>=ǰ¶ƫ*/ + if((offset>=curGrade->dwOrgnLinkOfst) && ((offset - curGrade->dwOrgnLinkOfst)<= curGrade->dwGradeLength)) + { + /*뵱ǰ¶ID*/ + *GradeID = curGrade->wId; + bReturnValue = 1; + return bReturnValue; + } + else + { + /*ִ*/ + } + } + /*նlinklinkͬ*/ + else if(linkId == curGrade->wTmnlLinkId) + { + /*ƫ<=ǰ¶յƫ*/ + if(offset <= curGrade->dwTmnlLinkOfst) + { + /*뵱ǰ¶ID*/ + *GradeID = curGrade->wId; + bReturnValue = 1; + return bReturnValue; + } + else + { + /*ִ*/ + } + } + /*мlinkͬ*/ + else + { + j=0; + while(0xffff !=(curGrade->wIncludeLinkId[j])) + { + if(linkId == (curGrade->wIncludeLinkId[j])) + { + *GradeID = curGrade->wId; + bReturnValue = 1; + return bReturnValue; + } + else + { + j++; + } + } + } + } + /*¶ȣûҵõ*/ + bReturnValue = 0; + return bReturnValue; + } + else + /*ǰlinkġLink¶ϢԡΪͳһ¶*/ + { + /*ͳһ¶ȲҪʹ¶IDϢ,ΪЧ*/ + *GradeID = 0xffff; + bReturnValue = 1; + return bReturnValue; + } +} + +/* +*ܣѯij¶ID +*UINT16 linkId,UINT32 offset +*UINT16 GradeID¶ID +*ֵ 0ִʧܣ1ɹ +*/ +static UINT8 dsuGetGradeIdbyLocExp_CPK(DSU_EMAP_STRU *pDsuEmapStru, const UINT16 linkId, const UINT32 offset, UINT16 *GradeID) +{ + UINT16 i = 0; /*ѭ*/ + UINT8 bReturnValue = 0; /*ֵ*/ + DSU_LINK_STRU *pLinkStru = NULL; /*LinkϢṹָ*/ + DSU_GRADE_STRU *pGradeStru = NULL; /*¶Ϣṹָ*/ + + DSU_GRADE_LINKIDX_STRU *pTempGradeLinkIdxStru = NULL; + UINT16 tempGradeID = 0; + + UINT16 LINKINDEXNUM = 0; + UINT16 *dsuLinkIndex = NULL; + UINT16 *dsuGradeIndex = NULL; /*¶Ϣ*/ + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + + if ((NULL != pDsuEmapStru) && (NULL != pDsuEmapStru->dsuEmapIndexStru) && (NULL != pDsuEmapStru->dsuStaticHeadStru) && (NULL != GradeID)) + { + /*ȫֱĴε漰ȫֱ*/ + LINKINDEXNUM = pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex = pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuGradeIndex = pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru = pDsuEmapStru->dsuStaticHeadStru; + + if ((linkId <= LINKINDEXNUM) && (DSU_NULL_16 != dsuLinkIndex[linkId])) + { + /*ȡǰλõlinkӦλϢ*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[linkId]; + + if((offset >= 0) && (offset <= pLinkStru->dwLength)) + { + pTempGradeLinkIdxStru = g_dsuEmapExtendStru->pDsuGradeInLinkIdx; + pTempGradeLinkIdxStru = pTempGradeLinkIdxStru + pLinkStru->wId; + + if (0 != pLinkStru->wGrade)/*ǰlinkġLink¶ϢԡΪͳһ¶*/ + { + if (0 == pTempGradeLinkIdxStru->wGradeCount) + { + *GradeID = DSU_NULL_16;/*ͳһ¶ȲҪʹ¶IDϢ,ΪЧ*/ + bReturnValue = 1; + } + else + { + /*֧*/ + bReturnValue = 0; + } + } + else/*ǰlinkġLink¶ϢԡΪͳһ¶*/ + { + if (1 == pTempGradeLinkIdxStru->wGradeCount) + { + tempGradeID = pTempGradeLinkIdxStru->wGradeId[0]; + *GradeID = tempGradeID; + bReturnValue = 1; + } + else if (1 < pTempGradeLinkIdxStru->wGradeCount) + { + for (i = 0; i < pTempGradeLinkIdxStru->wGradeCount; i++) + { + tempGradeID = pTempGradeLinkIdxStru->wGradeId[i]; + + /*ȡǰ¶ȶӦϢ*/ + pGradeStru = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[tempGradeID]; + + /*һlinkж¶ʱڸlinkмijε¶ȱزмlinkֻжϸlinkÿ¶ȵסβlinkIJlinkIdǷͬɡ*/ + if ((linkId == pGradeStru->wOrgnLinkId) && (linkId == pGradeStru->wTmnlLinkId))/*һlinkӦ¶ȣ¶λlinkмij*/ + { + if ((offset >= pGradeStru->dwOrgnLinkOfst) && ((offset - pGradeStru->dwOrgnLinkOfst) <= pGradeStru->dwGradeLength)) + { + *GradeID = tempGradeID; + bReturnValue = 1; + break; + } + } + else if ((linkId != pGradeStru->wOrgnLinkId) && (linkId == pGradeStru->wTmnlLinkId))/*һlinkӦ¶ȣ¶λlinkʼ*/ + { + if (offset <= pGradeStru->dwTmnlLinkOfst) + { + *GradeID = tempGradeID; + bReturnValue = 1; + break; + } + } + else if ((linkId == pGradeStru->wOrgnLinkId) && (linkId != pGradeStru->wTmnlLinkId))/*һlinkӦ¶ȣ¶λlinkն*/ + { + if (offset >= pGradeStru->dwOrgnLinkOfst) + { + *GradeID = tempGradeID; + bReturnValue = 1; + break; + } + } + else + { + /*֧*/ + bReturnValue = 0; + } + + } + /*linkûҵӦ¶*/ + if(i == pTempGradeLinkIdxStru->wGradeCount) + { + bReturnValue = 0; + } + } + else + { + /*֧*/ + bReturnValue = 0; + } + } + } + else + { + /*ƫϷѯʧ*/ + bReturnValue = 0; + } + } + else + { + /*link쳣ѯʧ*/ + bReturnValue = 0; + } + } + else + { + /*ӵͼָΪ*/ + bReturnValue = 0; + } + return bReturnValue; +} + +/* +*ܣѯij¶ID +*UINT16 linkId,UINT32 offset +*UINT16 GradeID¶ID +*ֵ 0ִʧܣ1ɹ +*޸˵CPK/HLTѯij¶ID㷨ŻͬʹdsuGetGradeIdbyLocExp_CPK +* FAO/DGʹԭ㷨 +* modify by lmy 20171221 +*/ +UINT8 dsuGetGradeIdbyLocExp(DSU_EMAP_STRU *pDsuEmapStru, const UINT16 linkId, const UINT32 offset, UINT16 *GradeID) +{ + UINT8 rtnValue = 0U;/*ֵ*/ + UINT8 cbtcVersionType = 0; + cbtcVersionType = GetCbtcSysType(); + + if((DQU_CBTC_CPK == cbtcVersionType) || (DQU_CBTC_HLT == cbtcVersionType)) + { + rtnValue = dsuGetGradeIdbyLocExp_CPK(pDsuEmapStru, linkId, offset, GradeID); + } + else if((DQU_CBTC_FAO == cbtcVersionType) ||(DQU_CBTC_DG == cbtcVersionType)) + { + rtnValue = dsuGetGradeIdbyLocExp_DFT(pDsuEmapStru, linkId, offset, GradeID); + } + else + { + rtnValue = 0U; + } + return rtnValue; +} + +/************* +*ܣij¶ƽ¶ֵ +*Point ¶ȵ +* +*ֵ 0ִʧ 1 ¶ȵһ 2 ¶ȵ2 3 ¶ȵ3 +****************/ +UINT8 dsuCalculateGradeValueExp_FAO(DSU_EMAP_STRU *pDsuEmapStru,UINT16 LinkId,UINT32 ofst,FLOAT32* GradeVal) +{ + UINT8 funcRtn; + UINT16 gradeId; /*¶ID*/ + UINT8 bReturnValue = 0; /*ֵ*/ + UINT32 arcEndOfst = 0; /*¶ȵһֽλ*/ + UINT32 arcStartOfst = 0; /*¶ȵڶֽλ*/ + UINT32 relLocation = 0; /*ǰλ*/ + FLOAT64 angleValue = 0; /*Ƕȱ仯ֵ*/ + FLOAT64 tempAngleValue = 0; /*ʱֵ*/ + DSU_GRADE_STRU* curGrade=NULL; /*ǰ¶ʱ*/ + DSU_GRADE_STRU curGradeTmp; /*ǰ¶ʱ*/ + DSU_GRADE_STRU* frontGrade=NULL; /*ǰ¶ǰ¶ʱ*/ + DSU_GRADE_STRU* rearGrade=NULL; /*ǰ¶Ⱥ¶ʱ*/ + FLOAT32 curGradeVal; + FLOAT64 tempValue; /*ʱʽֵ*/ + UINT8 GradeTrend = 0; + UINT8 RtnGetGradFrnt = 0; + UINT8 RtnGetGradNxt = 0; + + UINT16* dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != GradeVal)) + { + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ӵͼָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*¶*/ + funcRtn = dsuGetGradeIdbyLocExp(pDsuEmapStru,LinkId,ofst,&gradeId); + if(0 == funcRtn) + { + bReturnValue = 0; + return bReturnValue; + } + /*¶ֽλ*/ + funcRtn = dsuDividPointDistanceFromOriginExp(pDsuEmapStru,gradeId,LinkId,&arcEndOfst,&arcStartOfst); + if(0 == funcRtn) + { + bReturnValue = 0; + return bReturnValue; + } + /*¶ֽλ*/ + funcRtn = dsuGetDistanceFromOriginExp(pDsuEmapStru,gradeId,LinkId,ofst,&relLocation); + if(0 == funcRtn) + { + bReturnValue = 0; + return bReturnValue; + } + + /*Ϊ˷㣬ԷֽԾ´*/ + if(0xFFFFFFFF == arcEndOfst) + { + arcEndOfst = 0; + } + + if(0xffff != gradeId) + { + /*ʼǰ¶*/ + curGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[gradeId]; + /*Ϊ¶ֵΪ*/ + if(0x55 == curGrade->wInclineDir) + { + curGradeVal = (FLOAT32)(1.0*curGrade->wGradValue)/10000; + } + else + /*򷴣¶ֵΪ*/ + { + curGradeVal = (FLOAT32)(-1.0*curGrade->wGradValue)/10000; + } + + /*ȡǰ¶*/ + if(0xffff != curGrade->wOrgnJointMainGradeId) + { + frontGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[curGrade->wOrgnJointMainGradeId]; + } + else + { + /*·յͳһ¶,ٽ¶ƽ*/ + * GradeVal = (FLOAT32)(10000*curGradeVal); + /*سɹ*/ + bReturnValue = 2; + return bReturnValue; + } + + /*ȡ¶*/ + if(0xffff != curGrade->wTmnlJointMainGradeId) + { + rearGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[curGrade->wTmnlJointMainGradeId]; + } + else + { + /*·յͳһ¶,ٽ¶ƽ*/ + * GradeVal = (FLOAT32)(10000*curGradeVal); + /*سɹ*/ + bReturnValue = 2; + return bReturnValue; + } + } + else + { + /*ȡǰͳһ¶ֵ,Ϊ0ٽͷж*/ + curGradeVal = dsuStaticHeadStru->pConGradeStru->wGrade; + + /*ǰΪͳһ¶ʱ,Ϊ,ڸôֵ*/ + curGradeTmp.wId = 0xFFFF; + curGradeTmp.dwRadius = 0; + curGradeTmp.wInclineDir = 0x55; + curGradeTmp.wGradValue = curGradeVal; + curGrade = &curGradeTmp; + + + /*ʹǰijʼ*/ + frontGrade = NULL; + rearGrade = NULL; + + /*ȡǰ¶*/ + RtnGetGradFrnt = dsuGetGradeFrntExp(pDsuEmapStru,LinkId, &frontGrade); + + /*ȡ¶*/ + RtnGetGradNxt = dsuGetGradeRearExp(pDsuEmapStru,LinkId, &rearGrade); + + /*ǰ¶Ȳѯʧ*/ + if((0U==RtnGetGradFrnt)||(0U==RtnGetGradNxt)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*20141122ӣѯǰͺ¶ʱ,ֵǰ¶·յ,ٽƽ*/ + if((2==RtnGetGradFrnt)||(2==RtnGetGradNxt)) + { + * GradeVal = (FLOAT32)(10000*curGradeVal); + /*سɹ*/ + bReturnValue = 2; + return bReturnValue; + } + } + + /* + 1 ûзֽʱ򣬼¶뵱ǰ¶ȲСǧ֮20 + 2 ǰ㴦ڷֽʾĻ + */ + if((relLocation >= arcEndOfst) && (relLocation <= arcStartOfst)) + { + + * GradeVal = (FLOAT32)(10000*curGradeVal); + /*سɹ*/ + bReturnValue = 2; + return bReturnValue; + } + /*ǰڵһֽ㻡*/ + else if(relLocation < arcEndOfst) + { + if(NULL != frontGrade) + { + /*Ƕȱ仯ֵ*/ + if(0 == frontGrade->dwRadius) + { + /*ʰ뾶Ϊ0Ƕȱ仯ֵΪ0*/ + angleValue = 0; + } + else + { + /*Ƕȱ仯ֵ*/ + angleValue = (FLOAT32)((arcEndOfst + relLocation)/(1.0*frontGrade->dwRadius)); + } + /*¶£ȡֵ*/ + if(0x55 == frontGrade->wInclineDir) + { + tempValue = (1.0*frontGrade->wGradValue)/10000; + } + /*ȡֵ*/ + else + { + tempValue = (-1.0*frontGrade->wGradValue)/10000; + } + /*ifжϽǶȱ仯ֵֵǼֵ*/ + if(dquGradeTrendExp(pDsuEmapStru,frontGrade->wId,curGrade->wId,&GradeTrend)) + { + /*¶ȼ*/ + if(1 == GradeTrend) + { + /*ƽ¶ֵ*/ + tempAngleValue = tempValue - angleValue; + } + /*¶*/ + else if(2 == GradeTrend) + { + /*ƽ¶ֵ*/ + tempAngleValue = tempValue + angleValue; + } + /*¶Ȳ仯*/ + else + { + tempAngleValue = tempValue ; + } + + /*תΪFLOAT32*/ + * GradeVal = (FLOAT32)(tempAngleValue*10000); + /*سɹ*/ + bReturnValue = 1; + return bReturnValue; + } + else + { + /*ɴ*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + /*תΪFLOAT32*/ + * GradeVal = (FLOAT32)(curGradeVal); + /*سɹ*/ + bReturnValue = 1; + return bReturnValue; + } + } + /*ڵֽ*/ + else + { + if(NULL != rearGrade) + { + /*Ƕȱ仯ֵ*/ + if(0 == curGrade->dwRadius) + { + /*ʰ뾶Ϊ0Ƕȱ仯ֵΪ0*/ + angleValue = 0; + } + else + { + /*Ƕȱ仯ֵ*/ + angleValue = (FLOAT32)((relLocation - arcStartOfst)/(1.0*curGrade->dwRadius)); + } + + if(0x55 == curGrade->wInclineDir) + { + tempValue = (1.0*curGrade->wGradValue)/10000; + } + else + { + tempValue = (-1.0*curGrade->wGradValue)/10000; + } + + /*ifжϽǶȱ仯ֵֵǼֵ*/ + if(dquGradeTrendExp(pDsuEmapStru,curGrade->wId,rearGrade->wId,&GradeTrend)) + { + /*¶ֵ*/ + if(1 == GradeTrend) + { + /*ƽ¶ֵ*/ + tempAngleValue = tempValue - angleValue; + } + /*¶ֵ*/ + else if(2 == GradeTrend) + { + /*ƽ¶ֵ*/ + tempAngleValue = tempValue + angleValue; + } + /*¶ֵ仯*/ + else + { + tempAngleValue = tempValue; + } + + /*תΪFLOAT32*/ + * GradeVal = (FLOAT32)(tempAngleValue*10000); + /*سɹ*/ + bReturnValue = 3; + return bReturnValue; + } + else + { + /*ɴ*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + /*תΪFLOAT32*/ + * GradeVal = (FLOAT32)(curGradeVal); + /*سɹ*/ + bReturnValue = 3; + return bReturnValue; + } + } +} + +UINT8 dsuCalculateGradeValueExp_CPK(DSU_EMAP_STRU *pDsuEmapStru,UINT16 LinkId,UINT32 ofst,FLOAT32* GradeVal) +{ + UINT8 funcRtn; + UINT16 gradeId; /*¶ID*/ + UINT8 bReturnValue = 0; /*ֵ*/ + UINT32 arcEndOfst = 0; /*¶ȵһֽλ*/ + UINT32 arcStartOfst = 0; /*¶ȵڶֽλ*/ + UINT32 relLocation = 0; /*ǰλ*/ + FLOAT64 angleValue = 0; /*Ƕȱ仯ֵ*/ + FLOAT64 tempAngleValue = 0; /*ʱֵ*/ + DSU_GRADE_STRU* curGrade=NULL; /*ǰ¶ʱ*/ + DSU_GRADE_STRU curGradeTmp; /*ǰ¶ʱ*/ + DSU_GRADE_STRU* frontGrade=NULL; /*ǰ¶ǰ¶ʱ*/ + DSU_GRADE_STRU* rearGrade=NULL; /*ǰ¶Ⱥ¶ʱ*/ + FLOAT32 curGradeVal; + FLOAT64 tempValue; /*ʱʽֵ*/ + UINT8 GradeTrend = 0; + UINT8 RtnGetGradFrnt = 0; + UINT8 RtnGetGradNxt = 0; + + /*ȫֱĴε漰ȫֱ*/ + UINT16* dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != GradeVal)) + { + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*¶*/ + funcRtn = dsuGetGradeIdbyLocExp(pDsuEmapStru,LinkId,ofst,&gradeId); + if(0 == funcRtn) + { + bReturnValue = 0; + return bReturnValue; + } + /*¶ֽλ*/ + funcRtn = dsuDividPointDistanceFromOriginExp(pDsuEmapStru,gradeId,LinkId,&arcEndOfst,&arcStartOfst); + if(0 == funcRtn) + { + bReturnValue = 0; + return bReturnValue; + } + /*¶ֽλ*/ + funcRtn = dsuGetDistanceFromOriginExp(pDsuEmapStru,gradeId,LinkId,ofst,&relLocation); + if(0 == funcRtn) + { + bReturnValue = 0; + return bReturnValue; + } + + /*Ϊ˷㣬ԷֽԾ´*/ + if(0xFFFFFFFF == arcEndOfst) + { + arcEndOfst = 0; + } + + if(0xffff != gradeId) + { + /*ʼǰ¶*/ + curGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[gradeId]; + /*Ϊ¶ֵΪ*/ + if(0x55 == curGrade->wInclineDir) + { + curGradeVal = (FLOAT32)(1.0*curGrade->wGradValue)/10000; + } + else + /*򷴣¶ֵΪ*/ + { + curGradeVal = (FLOAT32)(-1.0*curGrade->wGradValue)/10000; + } + + /*ȡǰ¶*/ + if(0xffff != curGrade->wOrgnJointMainGradeId) + { + frontGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[curGrade->wOrgnJointMainGradeId]; + } + /*else + { + *GradeVal = (FLOAT32)(10000*curGradeVal); + bReturnValue = 2; + return bReturnValue; + }*/ + + /*ȡ¶*/ + if(0xffff != curGrade->wTmnlJointMainGradeId) + { + rearGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[curGrade->wTmnlJointMainGradeId]; + } + /*else + { + *GradeVal = (FLOAT32)(10000*curGradeVal); + bReturnValue = 2; + return bReturnValue; + }*/ + } + else + { + /*ȡǰͳһ¶ֵ,Ϊ0ٽͷж*/ + curGradeVal = dsuStaticHeadStru->pConGradeStru->wGrade; + + /*ǰΪͳһ¶ʱ,Ϊ,ڸôֵ*/ + curGradeTmp.wId = 0xFFFF; + curGradeTmp.dwRadius = 0; + curGradeTmp.wInclineDir = 0x55; + curGradeTmp.wGradValue = (UINT16)curGradeVal; + curGrade = &curGradeTmp; + + + /*ʹǰijʼ*/ + frontGrade = NULL; + rearGrade = NULL; + + /*ȡǰ¶*/ + RtnGetGradFrnt = dsuGetGradeFrntExp(pDsuEmapStru,LinkId, &frontGrade); + + /*ȡ¶*/ + RtnGetGradNxt = dsuGetGradeRearExp(pDsuEmapStru,LinkId, &rearGrade); + + /*ǰ¶Ȳѯʧ*/ + if((0==RtnGetGradFrnt)||(0==RtnGetGradNxt)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*20141122ӣѯǰͺ¶ʱ,ֵǰ¶·յ,ٽƽ*/ + if((2==RtnGetGradFrnt)||(2==RtnGetGradNxt)) + { + * GradeVal = (FLOAT32)(10000*curGradeVal); + /*سɹ*/ + bReturnValue = 2; + return bReturnValue; + } + } + + /* + 1 ûзֽʱ򣬼¶뵱ǰ¶ȲСǧ֮20 + 2 ǰ㴦ڷֽʾĻ + */ + if((relLocation >= arcEndOfst) && (relLocation <= arcStartOfst)) + { + + * GradeVal = (FLOAT32)(10000*curGradeVal); + /*سɹ*/ + bReturnValue = 2; + return bReturnValue; + } + /*ǰڵһֽ㻡*/ + else if(relLocation < arcEndOfst) + { + if(NULL != frontGrade) + { + /*Ƕȱ仯ֵ*/ + if(0 == frontGrade->dwRadius) + { + /*ʰ뾶Ϊ0Ƕȱ仯ֵΪ0*/ + angleValue = 0; + } + else + { + /*Ƕȱ仯ֵ*/ + angleValue = (FLOAT32)((arcEndOfst + relLocation)/(1.0*frontGrade->dwRadius)); + } + /*¶£ȡֵ*/ + if(0x55 == frontGrade->wInclineDir) + { + tempValue = (1.0*frontGrade->wGradValue)/10000; + } + /*ȡֵ*/ + else + { + tempValue = (-1.0*frontGrade->wGradValue)/10000; + } + /*ifжϽǶȱ仯ֵֵǼֵ*/ + if(dquGradeTrendExp(pDsuEmapStru,frontGrade->wId,curGrade->wId,&GradeTrend)) + { + /*¶ȼ*/ + if(1 == GradeTrend) + { + /*ƽ¶ֵ*/ + tempAngleValue = tempValue - angleValue; + } + /*¶*/ + else if(2 == GradeTrend) + { + /*ƽ¶ֵ*/ + tempAngleValue = tempValue + angleValue; + } + /*¶Ȳ仯*/ + else + { + tempAngleValue = tempValue ; + } + + /*תΪFLOAT32*/ + * GradeVal = (FLOAT32)(tempAngleValue*10000); + /*سɹ*/ + bReturnValue = 1; + return bReturnValue; + } + else + { + /*ɴ*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + /*תΪFLOAT32*/ + * GradeVal = (FLOAT32)(curGradeVal); + /*سɹ*/ + bReturnValue = 1; + return bReturnValue; + } + } + /*ڵֽ*/ + else + { + if(NULL != rearGrade) + { + /*Ƕȱ仯ֵ*/ + if(0 == curGrade->dwRadius) + { + /*ʰ뾶Ϊ0Ƕȱ仯ֵΪ0*/ + angleValue = 0; + } + else + { + /*Ƕȱ仯ֵ*/ + angleValue = (FLOAT32)((relLocation - arcStartOfst)/(1.0*curGrade->dwRadius)); + } + + if(0x55 == curGrade->wInclineDir) + { + tempValue = (1.0*curGrade->wGradValue)/10000; + } + else + { + tempValue = (-1.0*curGrade->wGradValue)/10000; + } + + /*ifжϽǶȱ仯ֵֵǼֵ*/ + if(dquGradeTrendExp(pDsuEmapStru,curGrade->wId,rearGrade->wId,&GradeTrend)) + { + /*¶ֵ*/ + if(1 == GradeTrend) + { + /*ƽ¶ֵ*/ + tempAngleValue = tempValue - angleValue; + } + /*¶ֵ*/ + else if(2 == GradeTrend) + { + /*ƽ¶ֵ*/ + tempAngleValue = tempValue + angleValue; + } + /*¶ֵ仯*/ + else + { + tempAngleValue = tempValue; + } + + /*תΪFLOAT32*/ + * GradeVal = (FLOAT32)(tempAngleValue*10000); + /*سɹ*/ + bReturnValue = 3; + return bReturnValue; + } + else + { + /*ɴ*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + /*תΪFLOAT32*/ + * GradeVal = (FLOAT32)(curGradeVal); + /*سɹ*/ + bReturnValue = 3; + return bReturnValue; + } + } +} + +/************* +*ʽӿ +*ܣij¶ƽ¶ֵ +*Point ¶ȵ +* +*ֵ 0ִʧ 1 ¶ȵһ 2 ¶ȵ2 3 ¶ȵ3 +*עӶԵĿʶĴmodify by qxt 20170726 +****************/ +UINT8 dsuCalculateGradeValueExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 LinkId,UINT32 ofst,FLOAT32 *GradeVal) +{ + UINT8 rtnValue = 0U;/*ֵ*/ + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if (DQU_CBTC_FAO == cbtcVersionType) + { + rtnValue=dsuCalculateGradeValueExp_FAO(pDsuEmapStru,LinkId,ofst, GradeVal); + } + else if ((DQU_CBTC_CPK == cbtcVersionType) || (DQU_CBTC_HLT == cbtcVersionType)||(DQU_CBTC_DG == cbtcVersionType) ) + { + rtnValue=dsuCalculateGradeValueExp_CPK(pDsuEmapStru,LinkId,ofst, GradeVal); + } + else + { + rtnValue = 0U; + } + return rtnValue; +} + +/************* +*ܣij¶ƽ󣬷ֳɵļֵķֽľ +*gradeId ¶ID +*UINT32* endPointDistance UINT32* startPointDistance +*ֵ 0ִʧ 1ɹ +ע Ҫƽĵ㣬ΪЧֵffffffff ֵΪ1 +****************/ +UINT8 dsuDividPointDistanceFromOriginExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 GradeId,UINT16 linkId,UINT32* endPointDistance,UINT32* startPointDistance) +{ + DSU_GRADE_STRU* curGrade=NULL; /*ǰ¶ʱ*/ + DSU_GRADE_STRU* frontGrade=NULL; /*ǰ¶*/ + DSU_GRADE_STRU* rearGrade=NULL; /*¶*/ + UINT16 gradeValue = 0; /*¶Ȳֵ*/ + UINT32 arcLength = 0; /**/ + UINT8 bReturnValue = 0; /*ֵ*/ + UINT8 RtnGetGradFrnt = 0; /*ȡǰ¶Ƚ*/ + UINT8 RtnGetGradNxt = 0; /*ȡ¶Ƚ*/ + + DSU_GRADE_STRU curGradeTmp; /*ǰ¶ʱ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 GRADEINDEXNUM=0U; + UINT16* dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != endPointDistance) && (NULL != startPointDistance)) + { + GRADEINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->GRADEINDEXNUM; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*¶ȱŲΪ,¶ȱд*/ + if(0xffff != GradeId) + { + if((GradeId>GRADEINDEXNUM)||((dsuGradeIndex[GradeId]) == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*ʼǰ¶*/ + curGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[GradeId]; + + /*ǰ¶*/ + if(curGrade->wOrgnJointMainGradeId != 0xFFFF) + { + /*ʼǰ¶*/ + frontGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[curGrade->wOrgnJointMainGradeId]; + } + /*ǰû¶*/ + else + { + /*յΪЧֵ*/ + * endPointDistance = 0xFFFFFFFF; + frontGrade = NULL; + } + + /*¶*/ + if(curGrade->wTmnlJointMainGradeId != 0xFFFF) + { + /*ʼ¶*/ + rearGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[curGrade->wTmnlJointMainGradeId]; + } + /*û¶*/ + else + { + /*ΪЧֵ*/ + * startPointDistance = 0xFFFFFFFF; + rearGrade = NULL; + } + } + else + /*ǰ¶Ϊͳһ¶*/ + { + memset(&curGradeTmp, 0, sizeof(curGradeTmp)); + + /*Ϣ,дǰ¶Ϣ*/ + curGradeTmp.wInclineDir = EMAP_SAME_DIR; + curGradeTmp.wGradValue = dsuStaticHeadStru->pConGradeStru->wGrade; + curGradeTmp.dwRadius = 0; + + curGrade = &curGradeTmp; + + /*ʹǰijʼ*/ + frontGrade = NULL; + rearGrade = NULL; + + /*ȡǰ¶*/ + RtnGetGradFrnt = dsuGetGradeFrntExp(pDsuEmapStru,linkId, &frontGrade); + + /*ȡ¶*/ + RtnGetGradNxt = dsuGetGradeRearExp(pDsuEmapStru,linkId, &rearGrade); + + /*ǰ¶Ȳѯʧ*/ + if((0==RtnGetGradFrnt)||(0==RtnGetGradNxt)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + } + + /**************linkEndId endOfst******************/ + /*ǰ¶*/ + if(NULL != frontGrade) + { + /*߰뾶Ч*/ + if(frontGrade->dwRadius == 0xFFFFFFFF) + { + /*յΪЧֵ*/ + * endPointDistance = 0xFFFFFFFF; + } + else + { + /*¶Ȳֵ»*/ + if((frontGrade->wInclineDir) == (curGrade->wInclineDir)) + { + gradeValue = abs((INT16)curGrade->wGradValue - (INT16)frontGrade->wGradValue); + } + else + { + /*һ£һ*/ + gradeValue = curGrade->wGradValue + frontGrade->wGradValue; + } + /*㻡*/ + arcLength = gradeValue*((frontGrade->dwRadius)/20000); + * endPointDistance = arcLength; + } + } + else + { + /*յΪЧֵ*/ + * endPointDistance = 0xFFFFFFFF; + } + /**************linkEndId endOfst******************/ + + + /**************linkStartId startOfst******************/ + /*¶*/ + if(NULL != rearGrade) + { + /*߰뾶Ч*/ + if(rearGrade->dwRadius == 0xFFFFFFFF) + { + /*յΪЧֵ*/ + * startPointDistance = 0xFFFFFFFF; + } + else + { + /*¶Ȳֵ»*/ + if((rearGrade->wInclineDir) == (curGrade->wInclineDir)) + { + gradeValue = abs((INT16)curGrade->wGradValue - (INT16)rearGrade->wGradValue); + } + else + { + /*һ£һ*/ + gradeValue = curGrade->wGradValue + rearGrade->wGradValue; + } + /*㻡*/ + arcLength = gradeValue*((curGrade->dwRadius)/20000); + * startPointDistance = curGrade->dwGradeLength - arcLength; + } + } + else + { + /*ΪЧֵ*/ + * startPointDistance = 0xFFFFFFFF; + } + /**************linkStartId startOfst******************/ + + bReturnValue = 1; + return bReturnValue; +} + +/************* +*ܣ¶ijһ㼰¶idõ¶ľ +*gradeId ¶ID + UINT16 linkId UINT32 Ofst +*UINT32 *length + +*ֵ 0ִʧ 1ɹ +****************/ +UINT8 dsuGetDistanceFromOriginExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 GradeId,UINT16 linkId,UINT32 Ofst,UINT32* length) +{ + UINT16 j=0U; /*ѭ*/ + DSU_GRADE_STRU* curGrade=NULL; /*¶Ƚṹʱ*/ + DSU_LINK_STRU * plink=NULL; /*linkṹָʱ*/ + UINT8 bReturnValue; /*ֵ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 GRADEINDEXNUM=0U; + UINT16 *dsuLinkIndex=NULL; + UINT16 *dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != length)) + { + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + GRADEINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->GRADEINDEXNUM; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + if(0xffff != GradeId) + { + if((GradeId>GRADEINDEXNUM)||((dsuGradeIndex[GradeId]) == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + curGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[GradeId]; + if(0 == curGrade->dwOrgnLinkOfst) + { + * length = 0; + } + else + { + * length = 1; + } + /*ʼlink*/ + if((linkId == curGrade->wOrgnLinkId) && (Ofst >= curGrade->dwOrgnLinkOfst)) + { + * length += Ofst - curGrade->dwOrgnLinkOfst; + bReturnValue = 1; + return bReturnValue; + } + else + { + plink = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[curGrade->wOrgnLinkId]; + * length += plink->dwLength - curGrade->dwOrgnLinkOfst; + j=0U; + /*ȴмlink*/ + while(0xFFFF != curGrade->wIncludeLinkId[j]) + { + if(j>=GRADE_INCLUDE_LINK_NUM) + { + /*ݴ˳ ôlink*/ + bReturnValue = 0; + return bReturnValue; + } + plink = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[curGrade->wIncludeLinkId[j]]; + /*мijlink*/ + if((linkId == curGrade->wIncludeLinkId[j]) && (Ofst <= plink->dwLength)) + { + * length += Ofst; + bReturnValue = 1; + return bReturnValue; + } + else + { + /*мlinkijۼ*/ + * length += plink->dwLength; + j++; + } + } + /*мlinkûҵĩlink*/ + if((linkId == curGrade->wTmnlLinkId) && (Ofst <= curGrade->dwTmnlLinkOfst)) + { + * length += Ofst; + bReturnValue = 1; + return bReturnValue; + } + else + { + bReturnValue = 0; + return bReturnValue; + } + } + } + else + { + * length = Ofst; + bReturnValue = 1; + return bReturnValue; + } +} + +/************************************************************************ + + ܣ ˺ĹDzѯλü¶ȡѯ + յ㷶Χе·¶ȣ¶ȣ£涨 + ΪΪĹܼΪΧ¶ȵСֵ + ¶ȵǧ + + ڲ const LOD_STRU * pLODStartStru ѯλúͷʵΪгβλúͷ + const LOD_STRU * pLODEndStru ѯյλúͷ + const UCHAR PointNum MAеĵ + const POINT_STRU * pPointStru Ϣṹ + ڲ FLOAT64 * Gradient гβMAյ㷶Χ¶ȵǧΪΪ + ֵ UCHAR bReturnValue + 0ѯʧܣ + 1ѯȷ + עڼĹУõֵֵǰ/10IJ˷ + ¶ֵΪǧֵ +************************************************************************/ +/*14 λü¶Ȳѯ*/ +static UCHAR dsuGradientGetExp_FAO(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + const UCHAR PointNum, const DQU_POINT_STATUS_STRU * pPointStru, FLOAT32 * Gradient) +{ + UINT16 wCurrentGradeID = 0;/*ǰ¶ȱ*/ + UINT16 wNextGradeID = 0;/*ǰ¶ȵ¶ȱ*/ + UCHAR bReturnValue = 0;/*ֵ*/ + UINT8 bLocGradeReturn = 0;/*ȡǰλõ¶Ϣֵ*/ + UCHAR rstGradeNxt = 0; /*ȡlink¶ȵķֵ*/ + UCHAR rstGetIdNxt = 0; /*ȡlinkķֵ*/ + DSU_GRADE_STRU *pstGrade=NULL;/*ָ¶ϢĽṹָ*/ + DSU_GRADE_STRU stGrade; /*ָ¶ϢĽṹ*/ + UINT16 i=0U; + UINT16 wCurrentLinkId; /*ǰ¶ȵlinkID*/ + + FLOAT32 StartPointGradeVal; + FLOAT32 EndPointGradeVal; + UINT16 StartGradeId; + UINT16 EndGradeId; + UINT8 StartPointGradeRtn; + UINT8 EndPointGradeRtn; + FLOAT32 Coefficient = 1; /*¶ϵΪ1 Ϊ-1*/ + FLOAT32 CurGradeVal; + FLOAT32 minGradeVal; + FLOAT32 maxGradeVal; + + UINT16 StartLinkId; + UINT32 StartOfst; + UINT16 EndLinkId; + UINT32 EndOfst; + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16 *dsuLinkIndex=NULL; + UINT16 *dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL!=pLODStartStru) && (NULL!=pLODEndStru) + && (NULL!=pPointStru) && (NULL!= Gradient)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=pDsuEmapStru->dsuDataLenStru; + } + else + { + /*ڲָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*жLinkЧ*/ + if((pLODStartStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODStartStru->Lnk] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + /*жlinkƫЧ*/ + if (pLODStartStru->Off > LinkLengthExp(pDsuEmapStru,pLODStartStru->Lnk)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + /*ж㷽Ч*/ + if ((EMAP_SAME_DIR != pLODStartStru->Dir) && (EMAP_CONVER_DIR != pLODStartStru->Dir)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + + /*жLinkЧ*/ + if((pLODEndStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODEndStru->Lnk] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + /*жյlinkƫЧ*/ + if (pLODEndStru->Off > LinkLengthExp(pDsuEmapStru,pLODEndStru->Lnk)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + /*жյ㷽Ч*/ + if ((EMAP_SAME_DIR != pLODEndStru->Dir) && (EMAP_CONVER_DIR != pLODEndStru->Dir)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + + + /*Ϊϵȡ1*/ + if(0x55 == pLODStartStru->Dir) + { + Coefficient = 1; + StartLinkId = pLODStartStru->Lnk; + StartOfst = pLODStartStru->Off; + EndLinkId = pLODEndStru->Lnk; + EndOfst = pLODEndStru->Off; + } + /*Ϊϵȡ-1 յλ*/ + else + { + Coefficient = -1; + StartLinkId = pLODEndStru->Lnk; + StartOfst = pLODEndStru->Off; + EndLinkId = pLODStartStru->Lnk; + EndOfst = pLODStartStru->Off; + } + + /*****************¼յ¶ֵ*********************/ + bLocGradeReturn = dsuGetGradeIdbyLocExp(pDsuEmapStru,StartLinkId,StartOfst,&StartGradeId); + /*ʧܣش*/ + if (0 == bLocGradeReturn) + { + bReturnValue = 0; + return bReturnValue; + } + StartPointGradeRtn = dsuCalculateGradeValueExp(pDsuEmapStru,StartLinkId,StartOfst,&StartPointGradeVal); + /*ʧܣش*/ + if (0 == StartPointGradeRtn) + { + bReturnValue = 0; + return bReturnValue; + } + /*յ¶ֵ*/ + bLocGradeReturn = dsuGetGradeIdbyLocExp(pDsuEmapStru,EndLinkId,EndOfst,&EndGradeId); + /*ʧܣش*/ + if (0 == bLocGradeReturn) + { + bReturnValue = 0; + return bReturnValue; + } + EndPointGradeRtn = dsuCalculateGradeValueExp(pDsuEmapStru,EndLinkId,EndOfst,&EndPointGradeVal); + /*ʧܣش*/ + if (0 == EndPointGradeRtn) + { + bReturnValue = 0; + return bReturnValue; + } + /*****************յ¶ֵ*********************/ + + + /****ͬһ¶****/ + if((StartGradeId == EndGradeId)&& + (0xffff != StartGradeId)&&(0xffff != EndGradeId)) + { + /*ͬһֽ*/ + if(StartPointGradeRtn == EndPointGradeRtn) + { + /*СǸ*/ + if(EndPointGradeVal < StartPointGradeVal) + { + minGradeVal = EndPointGradeVal; + maxGradeVal = StartPointGradeVal; + } + else + { + minGradeVal = StartPointGradeVal; + maxGradeVal = EndPointGradeVal; + } + } + /*ͬһֽڣ迼мֽ¶ֵ*/ + else + { + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[StartGradeId]; + /*ǰ¶ֵΪΪ*/ + if(0x55 == pstGrade->wInclineDir) + { + CurGradeVal = (FLOAT32)(1.0 * pstGrade->wGradValue); + } + else + { + CurGradeVal = (FLOAT32)(-1.0 * pstGrade->wGradValue); + } + + /*ȡСֵ*/ + if((EndPointGradeVal<=CurGradeVal)&& (EndPointGradeVal<=StartPointGradeVal)) + { + minGradeVal = EndPointGradeVal; + } + else if((StartPointGradeVal<=CurGradeVal)&& (StartPointGradeVal<=EndPointGradeVal)) + { + minGradeVal = StartPointGradeVal; + } + else + { + minGradeVal = CurGradeVal; + } + /*ȡֵ*/ + if((EndPointGradeVal>=CurGradeVal)&& (EndPointGradeVal>=StartPointGradeVal)) + { + maxGradeVal = EndPointGradeVal; + } + else if((StartPointGradeVal>=CurGradeVal)&& (StartPointGradeVal>=EndPointGradeVal)) + { + maxGradeVal = StartPointGradeVal; + } + else + { + maxGradeVal = CurGradeVal; + } + + } + } + /*****ͬһ¶*****/ + else + { + if(0xffff != StartGradeId) + { + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[StartGradeId]; + /*ǰ¶ֵΪΪ*/ + if(0x55 == pstGrade->wInclineDir) + { + CurGradeVal = (FLOAT32)(1.0 * pstGrade->wGradValue); + } + else + { + CurGradeVal = (FLOAT32)(-1.0 * pstGrade->wGradValue); + } + /*ȡõǰ¶ȶǰС¶ֵ*/ + if(1 == StartPointGradeRtn) + { + if(CurGradeVal>StartPointGradeVal) + { + minGradeVal = StartPointGradeVal; + maxGradeVal = CurGradeVal; + } + else + { + minGradeVal = CurGradeVal; + maxGradeVal = StartPointGradeVal; + } + } + else if(2 == StartPointGradeRtn) + { + minGradeVal = CurGradeVal; + maxGradeVal = StartPointGradeVal; + } + else + { + minGradeVal = StartPointGradeVal; + maxGradeVal = StartPointGradeVal; + } + } + else + { + /*ʼ¶Ϊͳһ¶,Сֵгʼֵ*/ + minGradeVal = StartPointGradeVal; + maxGradeVal = StartPointGradeVal; + } + + if(0xffff != EndGradeId) + { + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[EndGradeId]; + /*ն¶ֵΪΪ*/ + if(0x55 == pstGrade->wInclineDir) + { + CurGradeVal = (FLOAT32)(1.0 * pstGrade->wGradValue); + } + else + { + CurGradeVal = (FLOAT32)(-1.0 * pstGrade->wGradValue); + } + /*ȡõǰ¶ȶǰС¶ֵ*/ + if(1 == EndPointGradeRtn) + { + /*ĩ˵ҵС¶ֵ*/ + if(maxGradeValEndPointGradeVal) + { + minGradeVal = EndPointGradeVal; + } + else + { + /*ִ*/ + } + } + else if(2 == EndPointGradeRtn) + { + /*ĩ˵ҵС¶ֵ*/ + if(maxGradeValEndPointGradeVal) + { + minGradeVal = EndPointGradeVal; + } + else + { + /*ִ*/ + } + } + else + { + /*ֵ*/ + if((EndPointGradeVal>= maxGradeVal)&&(EndPointGradeVal>= CurGradeVal)) + { + maxGradeVal = EndPointGradeVal; + } + else if((CurGradeVal>= maxGradeVal)&&(CurGradeVal>= EndPointGradeVal)) + { + maxGradeVal = CurGradeVal; + } + else + { + /*ִ*/ + } + + /*Сֵ*/ + if((EndPointGradeVal<= minGradeVal)&&(EndPointGradeVal<= CurGradeVal)) + { + minGradeVal = EndPointGradeVal; + } + else if((CurGradeVal<= minGradeVal)&&(CurGradeVal<=EndPointGradeVal )) + { + minGradeVal = CurGradeVal; + } + else + { + /*ִ*/ + } + } + } + else + { + /*յ¶Ϊͳһ¶*/ + /*ĩ˵ҵС¶ֵ*/ + if(maxGradeValEndPointGradeVal) + { + minGradeVal = EndPointGradeVal; + } + else + { + /*ִ*/ + } + } + + + /*赱ǰ¶idΪʼ¶id*/ + wCurrentGradeID = StartGradeId; + /*¼ǰlinkidϢ*/ + wCurrentLinkId = StartLinkId; + + /*ѭȡյ¶ϢȶԵõ,Сֵ*/ + for(i=0U;iwGradeLen;i++) + { + if(0xffff != wCurrentGradeID) + { + /*¶ȱвѯǰ¶ȵǰ¶*/ + wNextGradeID = FindAdjacentGradeIDExp(pDsuEmapStru,wCurrentGradeID, 0x55, PointNum, pPointStru); + + /*ȡǰ¶*/ + if (0xffff != wNextGradeID) + { + /*ѯõ¶ȹIDΪ,ùҵǰ¶Ϣ*/ + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[wNextGradeID]; + /*ȡǰ¶ȵյlinkϢ*/ + wCurrentLinkId = pstGrade->wTmnlLinkId; + } + else + { + /*¶ȱлȡյ¶ΪЧ,Ϊ·յ,ͳһ¶ȱеϢ*/ + + + + /*linkвѯǰ¶Ƿͳһ¶ȱ,*/ + rstGradeNxt = dsuGetGradeRearExp(pDsuEmapStru,wCurrentLinkId, &pstGrade); + + if((1 == rstGradeNxt)&&(NULL == pstGrade)) + { + /*ǰ¶ͳһ¶ȱ,ȡͳһ¶ȱϢ,¶ȱȽ*/ + stGrade.wInclineDir = EMAP_SAME_DIR; + stGrade.wGradValue = dsuStaticHeadStru->pConGradeStru->wGrade; + pstGrade = &stGrade; + + /*¶Ϊͳһ¶,ΪЧ*/ + wNextGradeID = 0xffff; + } + else + { + /*ǰ¶δͳһ¶ȱ,ǰѯӦΪ·յ*/ + /*·յ(ҵ·յҲδҵյ¶ID)*/ + bReturnValue = 0; + return bReturnValue; + } + /*µǰlinkIDϢԱͳһ¶ȱϵIJѯ*/ + rstGetIdNxt = dsuGetAdjacentLinkIDExp(pDsuEmapStru,wCurrentLinkId, 0x55, PointNum, pPointStru, &wCurrentLinkId); + + if(1 != rstGetIdNxt) + { + /*ѯ·linkʧ*/ + bReturnValue = 0; + return bReturnValue; + } + } + } + else + { + /*ѯǰlinkʼ¶*/ + rstGradeNxt = dsuGetGradeRearExp(pDsuEmapStru,wCurrentLinkId, &pstGrade); + + if(1 == rstGradeNxt) + { + if(NULL == pstGrade) + { + /*ǰ¶ͳһ¶ȱ,ȡͳһ¶ȱϢ,¶ȱȽ*/ + stGrade.wInclineDir = EMAP_SAME_DIR; + stGrade.wGradValue = dsuStaticHeadStru->pConGradeStru->wGrade; + pstGrade = &stGrade; + + /*¶Ϊͳһ¶,ΪЧ*/ + wNextGradeID = 0xffff; + } + else + { + /*ʵʲѯõpstGrade¶ȱе¶ֵд*/ + /*¼ǰlink¶ID*/ + wNextGradeID = pstGrade->wId; + } + + /*Ϊ¶ȱеIJѯȫ,ͳһ¶ȱеĴѭ*/ + if(i>=1) + { + i--; + } + } + else + { + /*·յ(ҵ·յҲδҵյ¶ID)*/ + bReturnValue = 0; + return bReturnValue; + } + + if (wCurrentLinkId == EndLinkId) + { + /*鵽ն¶*/ + break; + } + + /*20141122ӣµǰlinkIDϢԱͳһ¶ȱϵIJѯ*/ + rstGetIdNxt = dsuGetAdjacentLinkIDExp(pDsuEmapStru,wCurrentLinkId, 0x55, PointNum, pPointStru, &wCurrentLinkId); + + if(1 != rstGetIdNxt) + { + /*ѯ·linkʧ*/ + bReturnValue = 0; + return bReturnValue; + } + } + + /*µǰ¶IDϢԱ¶ȱϵIJѯ*/ + wCurrentGradeID = wNextGradeID; + + if( ((wNextGradeID == EndGradeId) && ((0xffff != wNextGradeID) && (0xffff != EndGradeId))) || + ((wCurrentLinkId == EndLinkId) && (0xffff == wNextGradeID)) ) + { + /*鵽ն¶*/ + break; + } + + if(0x55 == pstGrade->wInclineDir) + { + /*и¶ȻС¶ȣ滻ǰֵ*/ + if(minGradeVal>=pstGrade->wGradValue) + { + minGradeVal = pstGrade->wGradValue; + } + if(maxGradeVal<=pstGrade->wGradValue) + { + maxGradeVal = pstGrade->wGradValue; + } + } + else + { + /*и¶ȻС¶ȣ滻ǰֵ*/ + if(minGradeVal>=-1.0*pstGrade->wGradValue) + { + minGradeVal = (FLOAT32)(-1.0*pstGrade->wGradValue); + } + if(maxGradeVal<=-1.0*pstGrade->wGradValue) + { + maxGradeVal = (FLOAT32)(-1.0*pstGrade->wGradValue); + } + } + } + + if(i>=dsuDataLenStru->wGradeLen) + { + /*ûҵĩ¶*/ + bReturnValue = 0; + return bReturnValue; + } + } + + /*зȷ¶ֵ*/ + if(0x55 == pLODStartStru->Dir) + { + * Gradient = minGradeVal/10; + bReturnValue = 1; + return bReturnValue; + } + else + { + * Gradient = (FLOAT32)(-1.0 * maxGradeVal/10); + bReturnValue = 1; + return bReturnValue; + } + +} + +/************************************************************************ + + ܣ ˺ĹDzѯλü¶ȡѯ + յ㷶Χе·¶ȣ¶ȣ£涨 + ΪΪĹܼΪΧ¶ȵСֵ + ¶ȵǧ + + ڲ const LOD_STRU * pLODStartStru ѯλúͷʵΪгβλúͷ + const LOD_STRU * pLODEndStru ѯյλúͷ + const UCHAR PointNum MAеĵ + const POINT_STRU * pPointStru Ϣṹ + ڲ FLOAT64 * Gradient гβMAյ㷶Χ¶ȵǧΪΪ + ֵ UCHAR bReturnValue + 0ѯʧܣ + 1ѯȷ + עڼĹУõֵֵǰ/10IJ˷ + ¶ֵΪǧֵ +************************************************************************/ +static UCHAR dsuGradientGetExp_CPK(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + const UCHAR PointNum, const DQU_POINT_STATUS_STRU * pPointStru, FLOAT32 * Gradient) +{ + UINT16 wCurrentGradeID = 0;/*ǰ¶ȱ*/ + UINT16 wNextGradeID = 0;/*ǰ¶ȵ¶ȱ*/ + UCHAR bReturnValue = 0;/*ֵ*/ + UINT8 bLocGradeReturn = 0;/*ȡǰλõ¶Ϣֵ*/ + UCHAR rstGradeNxt = 0; /*ȡlink¶ȵķֵ*/ + UCHAR rstGetIdNxt = 0; /*ȡlinkķֵ*/ + DSU_GRADE_STRU *pstGrade=NULL;/*ָ¶ϢĽṹָ*/ + DSU_GRADE_STRU stGrade; /*ָ¶ϢĽṹ*/ + UINT16 i=0U; + UINT16 wCurrentLinkId; /*ǰ¶ȵlinkID*/ + + FLOAT32 StartPointGradeVal; + FLOAT32 EndPointGradeVal; + UINT16 StartGradeId; + UINT16 EndGradeId; + UINT8 StartPointGradeRtn; + UINT8 EndPointGradeRtn; + FLOAT32 Coefficient = 1; /*¶ϵΪ1 Ϊ-1*/ + FLOAT32 CurGradeVal; + FLOAT32 minGradeVal; + FLOAT32 maxGradeVal; + + UINT16 StartLinkId; + UINT32 StartOfst; + UINT16 EndLinkId; + UINT32 EndOfst; + + DSU_LINK_STRU *pLinkStru=NULL; /*LinkϢṹָ*/ + DSU_LINK_STRU *pLinkStruEnd=NULL; /*LinkϢṹָ add by zlj 20161024*/ + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16 *dsuLinkIndex=NULL; + UINT16 *dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != pLODStartStru) && (NULL != pLODEndStru) + && (NULL != pPointStru) && (NULL != Gradient)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=pDsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*жLinkЧ*/ + if((pLODStartStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODStartStru->Lnk] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + /*жlinkƫЧ*/ + if (pLODStartStru->Off > LinkLengthExp(pDsuEmapStru,pLODStartStru->Lnk)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + /*ж㷽Ч*/ + if ((EMAP_SAME_DIR != pLODStartStru->Dir) && (EMAP_CONVER_DIR != pLODStartStru->Dir)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + + /*жLinkЧ*/ + if((pLODEndStru->Lnk>LINKINDEXNUM)||(dsuLinkIndex[pLODEndStru->Lnk] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + /*жյlinkƫЧ*/ + if (pLODEndStru->Off > LinkLengthExp(pDsuEmapStru,pLODEndStru->Lnk)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + /*жյ㷽Ч*/ + if ((EMAP_SAME_DIR != pLODEndStru->Dir) && (EMAP_CONVER_DIR != pLODEndStru->Dir)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + + + /*Ϊϵȡ1*/ + if(0x55 == pLODStartStru->Dir) + { + Coefficient = 1; + StartLinkId = pLODStartStru->Lnk; + StartOfst = pLODStartStru->Off; + EndLinkId = pLODEndStru->Lnk; + EndOfst = pLODEndStru->Off; + } + /*Ϊϵȡ-1 յλ*/ + else + { + Coefficient = -1; + StartLinkId = pLODEndStru->Lnk; + StartOfst = pLODEndStru->Off; + EndLinkId = pLODStartStru->Lnk; + EndOfst = pLODStartStru->Off; + } + + /*****************¼յ¶ֵ*********************/ + bLocGradeReturn = dsuGetGradeIdbyLocExp(pDsuEmapStru,StartLinkId,StartOfst,&StartGradeId); + /*ʧܣش*/ + if (0 == bLocGradeReturn) + { + bReturnValue = 0; + return bReturnValue; + } + StartPointGradeRtn = dsuCalculateGradeValueExp(pDsuEmapStru,StartLinkId,StartOfst,&StartPointGradeVal); + /*ʧܣش*/ + if (0 == StartPointGradeRtn) + { + bReturnValue = 0; + return bReturnValue; + } + /*յ¶ֵ*/ + bLocGradeReturn = dsuGetGradeIdbyLocExp(pDsuEmapStru,EndLinkId,EndOfst,&EndGradeId); + /*ʧܣش*/ + if (0 == bLocGradeReturn) + { + bReturnValue = 0; + return bReturnValue; + } + EndPointGradeRtn = dsuCalculateGradeValueExp(pDsuEmapStru,EndLinkId,EndOfst,&EndPointGradeVal); + /*ʧܣش*/ + if (0 == EndPointGradeRtn) + { + bReturnValue = 0; + return bReturnValue; + } + /*****************յ¶ֵ*********************/ + + + /****ͬһ¶****/ + if((StartGradeId == EndGradeId)&& + (0xffff != StartGradeId) && (0xffff != EndGradeId)) + { + /*ͬһֽ*/ + if(StartPointGradeRtn == EndPointGradeRtn) + { + /*СǸ*/ + if(EndPointGradeVal < StartPointGradeVal) + { + minGradeVal = EndPointGradeVal; + maxGradeVal = StartPointGradeVal; + } + else + { + minGradeVal = StartPointGradeVal; + maxGradeVal = EndPointGradeVal; + } + } + /*ͬһֽڣ迼мֽ¶ֵ*/ + else + { + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[StartGradeId]; + /*ǰ¶ֵΪΪ*/ + if(0x55 == pstGrade->wInclineDir) + { + CurGradeVal = (FLOAT32)(1.0 * pstGrade->wGradValue); + } + else + { + CurGradeVal = (FLOAT32)(-1.0 * pstGrade->wGradValue); + } + + /*ȡСֵ*/ + if((EndPointGradeVal<=CurGradeVal)&& (EndPointGradeVal<=StartPointGradeVal)) + { + minGradeVal = EndPointGradeVal; + } + else if((StartPointGradeVal<=CurGradeVal)&& (StartPointGradeVal<=EndPointGradeVal)) + { + minGradeVal = StartPointGradeVal; + } + else + { + minGradeVal = CurGradeVal; + } + /*ȡֵ*/ + if((EndPointGradeVal>=CurGradeVal)&& (EndPointGradeVal>=StartPointGradeVal)) + { + maxGradeVal = EndPointGradeVal; + } + else if((StartPointGradeVal>=CurGradeVal)&& (StartPointGradeVal>=EndPointGradeVal)) + { + maxGradeVal = StartPointGradeVal; + } + else + { + maxGradeVal = CurGradeVal; + } + + } + } + /*****ͬһ¶*****/ + else + { + if(0xffff != StartGradeId) + { + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[StartGradeId]; + /*ǰ¶ֵΪΪ*/ + if(0x55 == pstGrade->wInclineDir) + { + CurGradeVal = (FLOAT32)(1.0 * pstGrade->wGradValue); + } + else + { + CurGradeVal = (FLOAT32)(-1.0 * pstGrade->wGradValue); + } + /*ȡõǰ¶ȶǰС¶ֵ*/ + if(1 == StartPointGradeRtn) + { + if(CurGradeVal>StartPointGradeVal) + { + minGradeVal = StartPointGradeVal; + maxGradeVal = CurGradeVal; + } + else + { + minGradeVal = CurGradeVal; + maxGradeVal = StartPointGradeVal; + } + } + else if(2 == StartPointGradeRtn) + { + minGradeVal = CurGradeVal; + maxGradeVal = StartPointGradeVal; + } + else + { + minGradeVal = StartPointGradeVal; + maxGradeVal = StartPointGradeVal; + } + } + else + { + /*ʼ¶Ϊͳһ¶,Сֵгʼֵ*/ + minGradeVal = StartPointGradeVal; + maxGradeVal = StartPointGradeVal; + } + + if(0xffff != EndGradeId) + { + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[EndGradeId]; + /*ն¶ֵΪΪ*/ + if(0x55 == pstGrade->wInclineDir) + { + CurGradeVal = (FLOAT32)(1.0 * pstGrade->wGradValue); + } + else + { + CurGradeVal = (FLOAT32)(-1.0 * pstGrade->wGradValue); + } + /*ȡõǰ¶ȶǰС¶ֵ*/ + if(1 == EndPointGradeRtn) + { + /*ĩ˵ҵС¶ֵ*/ + if(maxGradeValEndPointGradeVal) + { + minGradeVal = EndPointGradeVal; + } + else + { + /*ִ*/ + } + } + else if(2 == EndPointGradeRtn) + { + /*ĩ˵ҵС¶ֵ*/ + if(maxGradeValEndPointGradeVal) + { + minGradeVal = EndPointGradeVal; + } + else + { + /*ִ*/ + } + } + else + { + /*ֵ*/ + if((EndPointGradeVal>= maxGradeVal)&&(EndPointGradeVal>= CurGradeVal)) + { + maxGradeVal = EndPointGradeVal; + } + else if((CurGradeVal>= maxGradeVal)&&(CurGradeVal>= EndPointGradeVal)) + { + maxGradeVal = CurGradeVal; + } + else + { + /*ִ*/ + } + + /*Сֵ*/ + if((EndPointGradeVal<= minGradeVal)&&(EndPointGradeVal<= CurGradeVal)) + { + minGradeVal = EndPointGradeVal; + } + else if((CurGradeVal<= minGradeVal)&&(CurGradeVal<=EndPointGradeVal )) + { + minGradeVal = CurGradeVal; + } + else + { + /*ִ*/ + } + } + } + else + { + /*յ¶Ϊͳһ¶*/ + /*ĩ˵ҵС¶ֵ*/ + if(maxGradeValEndPointGradeVal) + { + minGradeVal = EndPointGradeVal; + } + else + { + /*ִ*/ + } + } + + + /*赱ǰ¶idΪʼ¶id*/ + wCurrentGradeID = StartGradeId; + /*¼ǰlinkidϢ*/ + wCurrentLinkId = StartLinkId; + + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[wCurrentLinkId]; + + pLinkStruEnd = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[EndLinkId];/*add by zlj 20161024*/ + /*ǰlinkġLink¶ϢԡΪͳһ¶*/ + /*if(0 == pLinkStru->wGrade)*//*changed by zlj 20161024*/ + if((0 == pLinkStru->wGrade)||(0 == pLinkStruEnd->wGrade)) + { + + /*ѭȡյ¶ϢȶԵõ,Сֵ*/ + for(i=0;iwGradeLen;i++) + { + if(0xffff != wCurrentGradeID) + { + /*¶ȱвѯǰ¶ȵǰ¶*/ + wNextGradeID = FindAdjacentGradeIDExp(pDsuEmapStru,wCurrentGradeID, 0x55, PointNum, pPointStru); + + /*ȡǰ¶*/ + if (0xffff != wNextGradeID) + { + /*ѯõ¶ȹIDΪ,ùҵǰ¶Ϣ*/ + pstGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[wNextGradeID]; + /*ȡǰ¶ȵյlinkϢ*/ + wCurrentLinkId = pstGrade->wTmnlLinkId; + } + else + { + /*¶ȱлȡյ¶ΪЧ,Ϊ·յ,ͳһ¶ȱеϢ*/ + + /*linkвѯǰ¶Ƿͳһ¶ȱ,*/ + rstGradeNxt = dsuGetGradeRearExp(pDsuEmapStru,wCurrentLinkId, &pstGrade); + + if((1 == rstGradeNxt)&&(NULL == pstGrade)) + { + /*ǰ¶ͳһ¶ȱ,ȡͳһ¶ȱϢ,¶ȱȽ*/ + stGrade.wInclineDir = EMAP_SAME_DIR; + stGrade.wGradValue = dsuStaticHeadStru->pConGradeStru->wGrade; + pstGrade = &stGrade; + + /*¶Ϊͳһ¶,ΪЧ*/ + wNextGradeID = 0xffff; + } + else + { + /*ǰ¶δͳһ¶ȱ,ǰѯӦΪ·յ*/ + /*·յ(ҵ·յҲδҵյ¶ID)*/ + bReturnValue = 0; + return bReturnValue; + } + /*µǰlinkIDϢԱͳһ¶ȱϵIJѯ*/ + rstGetIdNxt = dsuGetAdjacentLinkIDExp(pDsuEmapStru,wCurrentLinkId, 0x55, PointNum, pPointStru, &wCurrentLinkId); + + if(1 != rstGetIdNxt) + { + /*ѯ·linkʧ*/ + bReturnValue = 0; + return bReturnValue; + } + } + } + else + { + /*ѯǰlinkʼ¶*/ + rstGradeNxt = dsuGetGradeRearExp(pDsuEmapStru,wCurrentLinkId, &pstGrade); + + if(1 == rstGradeNxt) + { + if(NULL == pstGrade) + { + /*ǰ¶ͳһ¶ȱ,ȡͳһ¶ȱϢ,¶ȱȽ*/ + stGrade.wInclineDir = EMAP_SAME_DIR; + stGrade.wGradValue = dsuStaticHeadStru->pConGradeStru->wGrade; + pstGrade = &stGrade; + + /*¶Ϊͳһ¶,ΪЧ*/ + wNextGradeID = 0xffff; + } + else + { + /*ʵʲѯõpstGrade¶ȱе¶ֵд*/ + /*¼ǰlink¶ID*/ + wNextGradeID = pstGrade->wId; + } + + /*Ϊ¶ȱеIJѯȫ,ͳһ¶ȱеĴѭ*/ + if(i>=1) + { + i--; + } + } + else + { + /*·յ(ҵ·յҲδҵյ¶ID)*/ + bReturnValue = 0; + return bReturnValue; + } + + if (wCurrentLinkId == EndLinkId) + { + /*鵽ն¶*/ + break; + } + /*20141122ӣµǰlinkIDϢԱͳһ¶ȱϵIJѯ*/ + rstGetIdNxt = dsuGetAdjacentLinkIDExp(pDsuEmapStru,wCurrentLinkId, 0x55, PointNum, pPointStru, &wCurrentLinkId); + + if(1 != rstGetIdNxt) + { + /*ѯ·linkʧ*/ + bReturnValue = 0; + return bReturnValue; + } + } + + /*µǰ¶IDϢԱ¶ȱϵIJѯ*/ + wCurrentGradeID = wNextGradeID; + + if( ((wNextGradeID == EndGradeId)&&((0xffff != wNextGradeID)&&(0xffff != EndGradeId)))|| + ((wCurrentLinkId == EndLinkId)&&(0xffff == wNextGradeID)) ) + { + /*鵽ն¶*/ + break; + } + + if(0x55 == pstGrade->wInclineDir) + { + /*и¶ȻС¶ȣ滻ǰֵ*/ + if(minGradeVal>=pstGrade->wGradValue) + { + minGradeVal = pstGrade->wGradValue; + } + if(maxGradeVal<=pstGrade->wGradValue) + { + maxGradeVal = pstGrade->wGradValue; + } + } + else + { + /*и¶ȻС¶ȣ滻ǰֵ*/ + if(minGradeVal>=-1.0*pstGrade->wGradValue) + { + minGradeVal = (FLOAT32)(-1.0*pstGrade->wGradValue); + } + if(maxGradeVal<=-1.0*pstGrade->wGradValue) + { + maxGradeVal = (FLOAT32)(-1.0*pstGrade->wGradValue); + } + } + } + } + else + { + *Gradient = minGradeVal/10; + bReturnValue = 1; + return bReturnValue; + } + + if(i>=dsuDataLenStru->wGradeLen) + { + /*ûҵĩ¶*/ + bReturnValue = 0; + return bReturnValue; + } + } + + /*зȷ¶ֵ*/ + if(0x55 == pLODStartStru->Dir) + { + *Gradient = minGradeVal/10; + bReturnValue = 1; + return bReturnValue; + } + else + { + *Gradient = (FLOAT32)(-1.0 * maxGradeVal/10); + bReturnValue = 1; + return bReturnValue; + } + +} + + +/*ʽӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +UCHAR dsuGradientGetExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + const UCHAR PointNum, const DQU_POINT_STATUS_STRU *pPointStru, FLOAT32 *Gradient) +{ + UINT8 cbtcVersionType=0U; + UCHAR bReturnValue = 0;/*ֵ*/ + cbtcVersionType=GetCbtcSysType(); + + if (DQU_CBTC_FAO == cbtcVersionType) + { + bReturnValue=dsuGradientGetExp_FAO(pDsuEmapStru,pLODStartStru, pLODEndStru, PointNum,pPointStru,Gradient); + } + else if ((DQU_CBTC_CPK == cbtcVersionType)||(DQU_CBTC_HLT == cbtcVersionType)||(DQU_CBTC_DG == cbtcVersionType) ) + { + bReturnValue=dsuGradientGetExp_CPK(pDsuEmapStru,pLODStartStru, pLODEndStru, PointNum,pPointStru,Gradient); + } + + else + { + bReturnValue = 0; + } + return bReturnValue; +} + + +/* +ܣжϺһ¶ȵ¶ֵǰһ¶ȵ¶ֵӣ仯Ǽ +UINT16 fistGradeID,UINT16 secondGradeID +GradeTrend ¶ + 1 + 2 + 0 仯 + ֵ0ʧ 1ɹ +*/ +UINT8 dquGradeTrendExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 fistGradeID,UINT16 secondGradeID,UINT8 *GradeTrend) +{ + UINT8 bReturnValue = 0; + INT32 signedFirstGrade=0;/*зŵ¶ֵ--ǰһ¶*/ + INT32 signedSecondGrade=0;/*зŵ¶ֵ--һ¶*/ + DSU_GRADE_STRU *fistGrade=NULL;/*ָ¶ϢĽṹָ*/ + DSU_GRADE_STRU *secondGrade=NULL;/*ָ¶ϢĽṹָ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 GRADEINDEXNUM=0U; + UINT16* dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != GradeTrend)) + { + GRADEINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->GRADEINDEXNUM; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + + if(0xffff != fistGradeID) + { + if((fistGradeID>GRADEINDEXNUM)||((dsuGradeIndex[fistGradeID]) == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*ʼ¶*/ + fistGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[fistGradeID]; + + /*0x55=EMAP_SAME_INC_LINEʾ,¶ֵΪ + 0xaa=EMAP_CONVER_INC_LINEʾ£¶ֵΪ*/ + + /*ǰһ¶*/ + if (fistGrade->wInclineDir == EMAP_SAME_INC_LINE) + { + signedFirstGrade=(INT32)fistGrade->wGradValue; + } + else if (fistGrade->wInclineDir == EMAP_CONVER_INC_LINE) + { + signedFirstGrade=(-1)*((INT32)(fistGrade->wGradValue)); + } + else + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + signedFirstGrade = dsuStaticHeadStru->pConGradeStru->wGrade; + } + + if(0xffff != secondGradeID) + { + if((secondGradeID>GRADEINDEXNUM)||((dsuGradeIndex[secondGradeID]) == 0xFFFF)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*ʼ¶*/ + secondGrade = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[secondGradeID]; + + /*һ¶*/ + if (secondGrade->wInclineDir == EMAP_SAME_INC_LINE) + { + signedSecondGrade=(INT32)secondGrade->wGradValue; + } + else if (secondGrade->wInclineDir == EMAP_CONVER_INC_LINE) + { + signedSecondGrade=(-1)*((INT32)(secondGrade->wGradValue)); + } + else + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + signedSecondGrade = dsuStaticHeadStru->pConGradeStru->wGrade; + } + + if((0xffff != fistGradeID)&&(0xffff != secondGradeID)&& + (secondGradeID != fistGrade->wTmnlJointMainGradeId)&&(secondGradeID != fistGrade->wTmnlJointSideGradeId)) + { + /*ڲ쳣ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /* + úһ¶ȵ¶ֵȥǰһ¶ȵ¶ֵ + Ϊ¶ֵ + Ϊ¶ֵ + Ϊ㣺¶ֵ仯 + */ + + if (signedSecondGrade-signedFirstGrade > 0) + { + *GradeTrend = 2; + bReturnValue = 1; + return bReturnValue; + } + else if (signedSecondGrade-signedFirstGrade < 0) + { + *GradeTrend = 1; + bReturnValue = 1; + return bReturnValue; + } + else + { + *GradeTrend = 0; + bReturnValue = 1; + return bReturnValue; + } + +} + +/* +ܣȡǰ¶ +UINT16 linkId,ǰlink +gradeFrnt ¶ + Null ·յǰ¶Ϊͳһ¶ + Nullǰ¶¶ȱпɲ + ֵ0ʧ 1ɹ 2·յ +*/ +UINT8 dsuGetGradeFrntExp_FAO(DSU_EMAP_STRU *pDsuEmapStru,UINT16 linkId, DSU_GRADE_STRU** gradeFrnt) +{ + UINT16 GradeIDOrg = 0; /*¼ǰ¶ȵID*/ + UINT16 GradeID = 0; /*¼ǰ¶ȵID*/ + UINT8 bReturnValue = 0; /*ֵ*/ + DSU_LINK_STRU *pLinkStru=NULL; /*LinkϢṹָ*/ + DSU_LINK_STRU *pLinkStruOrg=NULL; /*linkʱ*/ + DSU_GRADE_STRU* gradeFrntTmp=NULL; /*ʱ¶ȱ*/ + UINT16 i = 0; /*ѭ*/ + UINT8 RstGetOrg = 0; /*ѯǰ¶Idֵ*/ + UINT8 RstGetCur = 0; /*ѯǰ¶Idֵ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + UINT16* dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != gradeFrnt)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=pDsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + bReturnValue = 0; + } + + /*жLinkЧ*/ + if(( 0 != bReturnValue) && (linkId>LINKINDEXNUM)||(dsuLinkIndex[linkId] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + + /*ǰlinkλڵlink¶ȱпԲѯ,ȡӦ;*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[linkId]; + + for(i=0;iwLinkLen;i++) + { + if(0xffff != pLinkStru->wOrgnJointMainLkId) + { + pLinkStruOrg = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pLinkStru->wOrgnJointMainLkId]; + + /*link¶ȲΪͳһ¶*/ + if(0 == pLinkStruOrg->wGrade) + { + /*ѯlinkӦ¶ID*/ + RstGetOrg = dsuGetGradeIdbyLocExp(pDsuEmapStru,pLinkStruOrg->wId, pLinkStruOrg->dwLength, &GradeIDOrg); + + /*ѯǰlinkӦ¶ID*/ + RstGetCur = dsuGetGradeIdbyLocExp(pDsuEmapStru,pLinkStru->wId, 0, &GradeID); + + if((0 == RstGetOrg)||(0 == RstGetCur)) + { + /*ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*link뵱ǰlink¶IDͬ*/ + if(GradeIDOrg != GradeID) + { + if(0xffff != GradeIDOrg) + { + /*ʼǰ¶*/ + gradeFrntTmp = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[GradeIDOrg]; + *gradeFrnt = gradeFrntTmp; + bReturnValue = 1; + return bReturnValue; + } + else + { + /*ݳ(linkвΪͳһ¶,ѯõΪͳһ¶)*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + pLinkStru = pLinkStruOrg; + } + } + else + { + /*link¶Ϊͳһ¶*/ + *gradeFrnt = NULL; + bReturnValue = 1; + return bReturnValue; + } + } + else + { + /*ǰlinklinkΪ·յ,ΪЧֵ*/ + *gradeFrnt = NULL; + bReturnValue = 2; + return bReturnValue; + } + } + + /*ѭδҵӦ¶ID*/ + if(i == dsuDataLenStru->wLinkLen) + { + *gradeFrnt = NULL; + bReturnValue = 0; + return bReturnValue; + } +} + +UINT8 dsuGetGradeFrntExp_CPK(DSU_EMAP_STRU *pDsuEmapStru,UINT16 linkId, DSU_GRADE_STRU** gradeFrnt) +{ + UINT16 GradeIDOrg = 0; /*¼ǰ¶ȵID*/ + UINT16 GradeID = 0; /*¼ǰ¶ȵID*/ + UINT8 bReturnValue = 0; /*ֵ*/ + DSU_LINK_STRU *pLinkStru=NULL; /*LinkϢṹָ*/ + DSU_LINK_STRU *pLinkStruOrg=NULL; /*linkʱ*/ + DSU_GRADE_STRU* gradeFrntTmp=NULL; /*ʱ¶ȱ*/ + UINT16 i = 0; /*ѭ*/ + UINT8 RstGetOrg = 0; /*ѯǰ¶Idֵ*/ + UINT8 RstGetCur = 0; /*ѯǰ¶Idֵ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + UINT16* dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != gradeFrnt)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=pDsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*жLinkЧ*/ + if((linkId>LINKINDEXNUM)||(dsuLinkIndex[linkId] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + + /*ǰlinkλڵlink¶ȱпԲѯ,ȡӦ;*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[linkId]; + + for(i=0;iwLinkLen;i++) + { + if(0xffff != pLinkStru->wOrgnJointMainLkId) + { + pLinkStruOrg = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pLinkStru->wOrgnJointMainLkId]; + + /*link¶ȲΪͳһ¶*/ + if(0 == pLinkStruOrg->wGrade) + { + /*ѯlinkӦ¶ID*/ + RstGetOrg = dsuGetGradeIdbyLocExp(pDsuEmapStru,pLinkStruOrg->wId, pLinkStruOrg->dwLength, &GradeIDOrg); + + /*ѯǰlinkӦ¶ID*/ + RstGetCur = dsuGetGradeIdbyLocExp(pDsuEmapStru,pLinkStru->wId, 0, &GradeID); + + if((0 == RstGetOrg)||(0 == RstGetCur)) + { + /*ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*link뵱ǰlink¶IDͬ*/ + if(GradeIDOrg != GradeID) + { + if(0xffff != GradeIDOrg) + { + /*ʼǰ¶*/ + gradeFrntTmp = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[GradeIDOrg]; + *gradeFrnt = gradeFrntTmp; + bReturnValue = 1; + return bReturnValue; + } + else + { + /*ݳ(linkвΪͳһ¶,ѯõΪͳһ¶)*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + pLinkStru = pLinkStruOrg; + } + } + else + { + /*link¶Ϊͳһ¶*/ + *gradeFrnt = NULL; + bReturnValue = 1; + return bReturnValue; + } + } + else + { + /*ǰlinklinkΪ·յ,ΪЧֵ*/ + *gradeFrnt = NULL; + bReturnValue = 2; + return bReturnValue; + } + } + + /*ѭδҵӦ¶ID*/ + if(i == dsuDataLenStru->wLinkLen) + { + *gradeFrnt = NULL; + bReturnValue = 0; + return bReturnValue; + } + else + { + /*ɴ֧*/ + bReturnValue=0U; + return bReturnValue; + } +} +/*ʽӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +UINT8 dsuGetGradeFrntExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 linkId, DSU_GRADE_STRU **gradeFrnt) +{ + UINT8 rtnValue = 0U;/*ֵ*/ + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if (DQU_CBTC_FAO == cbtcVersionType) + { + rtnValue=dsuGetGradeFrntExp_FAO(pDsuEmapStru,linkId, gradeFrnt); + } + else if ((DQU_CBTC_CPK == cbtcVersionType) || ( DQU_CBTC_HLT == cbtcVersionType) ||(DQU_CBTC_DG == cbtcVersionType)) + { + rtnValue=dsuGetGradeFrntExp_CPK(pDsuEmapStru,linkId, gradeFrnt); + } + else + { + rtnValue = 0U; + } + return rtnValue; +} + +/* +ܣȡ¶ +UINT16 linkId,ǰlink +gradeRear ¶ + Null ·յ¶Ϊͳһ¶ + Null¶¶ȱпɲ + ֵ0ʧ 1ɹ 2·յ +*/ +UINT8 dsuGetGradeRearExp_FAO(DSU_EMAP_STRU *pDsuEmapStru,UINT16 linkId, DSU_GRADE_STRU** gradeRear) +{ + UINT16 GradeIDNxt = 0; /*¼¶ȵID*/ + UINT16 GradeID = 0; /*¼ǰ¶ȵID*/ + UINT8 bReturnValue = 0; /*ֵ*/ + DSU_LINK_STRU* pLinkStru=NULL; /*LinkϢṹָ*/ + DSU_LINK_STRU* pLinkStruNxt=NULL; /*linkʱ*/ + DSU_GRADE_STRU* gradeRearTmp=NULL; /*¶ʱ*/ + UINT16 i = 0; /*ѭ*/ + UINT8 RstGetNxt = 0; /*ѯǰ¶Idֵ*/ + UINT8 RstGetCur = 0; /*ѯǰ¶Idֵ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + UINT16* dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != gradeRear)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=pDsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*жLinkЧ*/ + if((linkId>LINKINDEXNUM)||(dsuLinkIndex[linkId] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + + /*ǰlinkλڵlink¶ȱпԲѯ,ȡӦ;*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[linkId]; + + for(i=0;iwLinkLen;i++) + { + if(0xffff != pLinkStru->wTmnlJointMainLkId) + { + pLinkStruNxt = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pLinkStru->wTmnlJointMainLkId]; + + /*link¶ȲΪͳһ¶*/ + if(0 == pLinkStruNxt->wGrade) + { + /*ѯlinkӦ¶ID*/ + RstGetNxt = dsuGetGradeIdbyLocExp(pDsuEmapStru,pLinkStruNxt->wId, 0, &GradeIDNxt); + + /*ѯǰlinkӦ¶ID*/ + RstGetCur = dsuGetGradeIdbyLocExp(pDsuEmapStru,pLinkStru->wId, pLinkStru->dwLength, &GradeID); + + if((0 == RstGetNxt)||(0 == RstGetCur)) + { + /*ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*link뵱ǰlink¶IDͬ*/ + if(GradeIDNxt != GradeID) + { + if(0xffff != GradeIDNxt) + { + /*ʼ¶*/ + gradeRearTmp = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[GradeIDNxt]; + *gradeRear = gradeRearTmp; + bReturnValue = 1; + return bReturnValue; + } + else + { + /*ݳ(linkвΪͳһ¶,ѯõΪͳһ¶)*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + pLinkStru = pLinkStruNxt; + } + } + else + { + /*link¶Ϊͳһ¶*/ + *gradeRear = NULL; + bReturnValue = 1; + return bReturnValue; + } + } + else + { + /*ǰlinklinkΪ·յ*/ + *gradeRear = NULL; + bReturnValue = 2; + return bReturnValue; + } + } + + /*ѭδҵӦ¶ID*/ + if(i == dsuDataLenStru->wLinkLen) + { + *gradeRear = NULL; + bReturnValue = 0; + } + return bReturnValue; +} + +UINT8 dsuGetGradeRearExp_CPK(DSU_EMAP_STRU *pDsuEmapStru,UINT16 linkId, DSU_GRADE_STRU** gradeRear) +{ + UINT16 GradeIDNxt = 0; /*¼¶ȵID*/ + UINT16 GradeID = 0; /*¼ǰ¶ȵID*/ + UINT8 bReturnValue = 0; /*ֵ*/ + DSU_LINK_STRU* pLinkStru=NULL; /*LinkϢṹָ*/ + DSU_LINK_STRU* pLinkStruNxt=NULL; /*linkʱ*/ + DSU_GRADE_STRU* gradeRearTmp=NULL; /*¶ʱ*/ + UINT16 i = 0; /*ѭ*/ + UINT8 RstGetNxt = 0; /*ѯǰ¶Idֵ*/ + UINT8 RstGetCur = 0; /*ѯǰ¶Idֵ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + UINT16* dsuLinkIndex=NULL; + UINT16* dsuGradeIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + if ((NULL != pDsuEmapStru) && (NULL != gradeRear)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex=pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuGradeIndex=pDsuEmapStru->dsuEmapIndexStru->dsuGradeIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + dsuDataLenStru=pDsuEmapStru->dsuDataLenStru; + } + else + { + /*ӵͼָΪ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*жLinkЧ*/ + if((linkId>LINKINDEXNUM)||(dsuLinkIndex[linkId] == 0xFFFF)) + { + /*Ч쳣ѯʧܣش*/ + bReturnValue = 0; + return bReturnValue; + } + + /*ǰlinkλڵlink¶ȱпԲѯ,ȡӦ;*/ + pLinkStru = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[linkId]; + + for(i=0;iwLinkLen;i++) + { + if(0xffff != pLinkStru->wTmnlJointMainLkId) + { + pLinkStruNxt = dsuStaticHeadStru->pLinkStru + dsuLinkIndex[pLinkStru->wTmnlJointMainLkId]; + + /*link¶ȲΪͳһ¶*/ + if(0 == pLinkStruNxt->wGrade) + { + /*ѯlinkӦ¶ID*/ + RstGetNxt = dsuGetGradeIdbyLocExp(pDsuEmapStru,pLinkStruNxt->wId, 0, &GradeIDNxt); + + /*ѯǰlinkӦ¶ID*/ + RstGetCur = dsuGetGradeIdbyLocExp(pDsuEmapStru,pLinkStru->wId, pLinkStru->dwLength, &GradeID); + + if((0 == RstGetNxt)||(0 == RstGetCur)) + { + /*ѯʧ*/ + bReturnValue = 0; + return bReturnValue; + } + + /*link뵱ǰlink¶IDͬ*/ + if(GradeIDNxt != GradeID) + { + if(0xffff != GradeIDNxt) + { + /*ʼ¶*/ + gradeRearTmp = dsuStaticHeadStru->pGradeStru + dsuGradeIndex[GradeIDNxt]; + *gradeRear = gradeRearTmp; + bReturnValue = 1; + return bReturnValue; + } + else + { + /*ݳ(linkвΪͳһ¶,ѯõΪͳһ¶)*/ + bReturnValue = 0; + return bReturnValue; + } + } + else + { + pLinkStru = pLinkStruNxt; + } + } + else + { + /*link¶Ϊͳһ¶*/ + *gradeRear = NULL; + bReturnValue = 1; + return bReturnValue; + } + } + else + { + /*ǰlinklinkΪ·յ*/ + *gradeRear = NULL; + bReturnValue = 2; + return bReturnValue; + } + } + + /*ѭδҵӦ¶ID*/ + if(i == dsuDataLenStru->wLinkLen) + { + *gradeRear = NULL; + bReturnValue = 0; + return bReturnValue; + } + else + { + /*ɴ֧*/ + bReturnValue=0U; + return bReturnValue; + } +} +/*ʽӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +UINT8 dsuGetGradeRearExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 linkId, DSU_GRADE_STRU **gradeRear) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if (DQU_CBTC_FAO == cbtcVersionType) + { + rtnValue=dsuGetGradeRearExp_FAO(pDsuEmapStru,linkId, gradeRear); + } + else if ((DQU_CBTC_CPK == cbtcVersionType)||(DQU_CBTC_HLT == cbtcVersionType)||(DQU_CBTC_DG == cbtcVersionType) ) + { + rtnValue=dsuGetGradeRearExp_CPK(pDsuEmapStru,linkId, gradeRear); + } + else + { + rtnValue = 0U; + } + return rtnValue; +} + +/** +ܣȡǰLINKľ̬ٸ + +@linkIdǰlink + +ֵ̬ٸ +*/ +UINT8 GetStcLmtSpdCntByLnkIdExp(DSU_EMAP_STRU *pDsuEmapStru,DSU_STC_LIMIT_LINKIDX_STRU *pDsuLimitStcLinkIdx,const UINT16 linkId) +{ + UINT8 ret = 0; + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM=0U; + if ((NULL != pDsuEmapStru) && (NULL !=pDsuLimitStcLinkIdx)) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + } + else + { + /*ӵͼָΪ*/ + ret = 0; + } + + if(linkId <= LINKINDEXNUM) + { + if (pDsuLimitStcLinkIdx[linkId].linkId == linkId) + { + /*linkIdӦ̬ٱٸ*/ + ret = pDsuLimitStcLinkIdx[linkId].limitStcSpdInfoCount; + } + else + { + ret = 0; + } + + } + else + { + ret = 0; + } + + return ret; +} + +/** +ܣȡƶLINKĵָ±ľ̬ʱٵĶָ + +@linkIdǰLink +@idxӦLinkĵڼ٣±ȡֵΧ0-9 +ֵ +@NULLȡʧ +@ǿգӦٽṹָ +*/ +DSU_STATIC_RES_SPEED_STRU *GetStcLmtSpdInfoByLnkIdExp(DSU_EMAP_STRU *pDsuEmapStru,DSU_STC_LIMIT_LINKIDX_STRU *pDsuLimitStcLinkIdx,const UINT16 linkId,const UINT8 idx) +{ + DSU_STATIC_RES_SPEED_STRU *pStcLmtSpdInfo = NULL; + + UINT16 LINKINDEXNUM=0U; + UINT16* dsuStaticResSpeedIndex=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ( (NULL != pDsuEmapStru) && (NULL != pDsuLimitStcLinkIdx) ) + { + LINKINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuStaticResSpeedIndex=pDsuEmapStru->dsuEmapIndexStru->dsuStaticResSpeedIndex; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + } + else + { + /*ӵͼָΪ*/ + pStcLmtSpdInfo = NULL; + } + + if ((idx >= LINK_MAX_LIMIT_SPD) || (idx < 0)) + { + return pStcLmtSpdInfo; + } + if(linkId <= LINKINDEXNUM) + { + if(idx < pDsuLimitStcLinkIdx[linkId].limitStcSpdInfoCount) + { + /*linkIdӦ̬ٱĵidx̬ȡ*/ + pStcLmtSpdInfo = dsuStaticHeadStru->pStaticResSpeedStru + dsuStaticResSpeedIndex[pDsuLimitStcLinkIdx[linkId].limitStcSpdInfoIdBuf[idx]]; + } + } + else + { + pStcLmtSpdInfo = NULL; + } + + return pStcLmtSpdInfo; +} + +/* +ܣ࿪תΪ +multiPointId ࿪ + multiPointState ࿪״̬ + +wVirtualPointIds ֺ + wVirtualPointStates ֺ״̬ +ֵֵֺ, 0ʧ + +㷨࿪ NλR1λL1λR2λL2λ + Ӧе 0 1 2 3 4 + ӦĶ࿪״̬ 1 2 3 4 5 + ˵ =࿪״̬multiPointState-1 ʱӦԭֵ״̬ȡλ<=>λ + +עwVirtualPointIds״̬wVirtualPointStatesЧ״̬Ϊ3 + + / L / L + / / + / / 101 + -|------------------------ === ---|------/----------------- N + 1 \ N 102 \ + \ \ + \ \ + R R + ͼ1.ʵ ͼ2.ⵥ + + ͼ1ʵ1״̬Ϊ3ʱƳͼ2ⵥΪLλʱ101ΪЧ״̬Ϊ3ֵΪ2 + wVirtualPointIds[0]=102; + wVirtualPointStates[0]=2; + wVirtualPointIds[1]=101; + wVirtualPointStates[1]=3; +author:Ŀ add by qxt 20170622 +*/ +UINT8 ConvertToVirtualSwitchesExp(DSU_EMAP_STRU *pDsuEmapStru,const UINT16 multiPointId,const UINT8 multiPointState,UINT16 wVirtualPointIds[MAX_VIRTUAL_SWITCH_NUM],UINT8 wVirtualPointStates[MAX_VIRTUAL_SWITCH_NUM]) +{ + UINT8 chReturnValue = 0;/*ֵ*/ + UINT16 i = 0,j=0,k=0; /*ѭñ*/ + DSU_MULTI_SWITCH_STRU* pMultiPointStru=NULL; /*࿪ʱṹ*/ + + /*ȫֱĴε漰ȫֱ*/ + UINT16 MULTIPOINTINDEXNUM=0U; + UINT16 *dsuMultiPointIndex=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + if ((NULL != wVirtualPointIds) && (NULL != wVirtualPointStates)) + { + /*ʼΪЧֵ65535*/ + for (i = 0; i < MAX_VIRTUAL_SWITCH_NUM; i++) + { + wVirtualPointIds[i] = DSU_NULL_16; + wVirtualPointStates[i] = DSU_NULL_8; + } + + if ((NULL != pDsuEmapStru)&&(NULL!=pDsuEmapStru->dsuEmapIndexStru)) + { + MULTIPOINTINDEXNUM=pDsuEmapStru->dsuEmapIndexStru->MULTIPOINTINDEXNUM; + dsuMultiPointIndex=pDsuEmapStru->dsuEmapIndexStru->dsuMultiPointIndex; + dsuDataLenStru=pDsuEmapStru->dsuDataLenStru; + dsuStaticHeadStru=pDsuEmapStru->dsuStaticHeadStru; + + /*жЧ*/ + if ((multiPointId <= MULTIPOINTINDEXNUM) && (dsuMultiPointIndex[multiPointId] != DSU_NULL_16) && (multiPointState <= MAX_VIRTUAL_SWITCH_NUM) && (multiPointState >= 1)) + { + /*࿪*/ + for (j = 0; j < dsuDataLenStru->wMultiPointLen; j++) + { + pMultiPointStru = dsuStaticHeadStru->pMultiPointStru + j; + if ((pMultiPointStru->wId == multiPointId) && (multiPointState <= pMultiPointStru->wType)) + { + /*࿪״̬1ʱ赥ΪNλR1λͬһ,ΪֹͬʱӦ1ʼ*/ + if (1 == multiPointState) + { + for (k = 1; k < pMultiPointStru->wType; k++) + { + /*Ÿֵ*/ + wVirtualPointIds[k - 1] = pMultiPointStru->wSwitchIds[k]; + /*״ֵ̬״ֻ̬Nλͬλ״̬ȡ(2=>1;1=>2*/ + wVirtualPointStates[k - 1] = 0x03 & ~pMultiPointStru->wSwitchStates[k]; + } + } + else + { + + for (k = 1; k < pMultiPointStru->wType; k++) + { + /*Ÿֵ*/ + wVirtualPointIds[k - 1] = pMultiPointStru->wSwitchIds[k]; + /*״ֵ̬*/ + if (k == (multiPointState - 1)) + { + wVirtualPointStates[k - 1] = pMultiPointStru->wSwitchStates[k]; + } + /*multiPointState-1֮ǰΪЧ*/ + else if (k < (multiPointState - 1)) + { + wVirtualPointStates[k - 1] = EMAP_POINT_STATUS_LOSE; + } + /*multiPointState-1֮״̬÷*/ + else + { + /*״̬ȡ(2=>1;1=>2)*/ + wVirtualPointStates[k - 1] = 0x03 & ~pMultiPointStru->wSwitchStates[k]; + + } + + } + + } + + chReturnValue = pMultiPointStru->wType - 1; + } + } + } + else + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + + } + } + else + { + /*ӵͼָΪ*/ + chReturnValue = 0; + } + } + else + { + /*ָΪ*/ + chReturnValue = 0; + } + return chReturnValue; + +} + +/* +ܣתΪ࿪ +wVirtualPointIds[] + wVirtualPointStates[] ״̬ + wVirtualPointNum +multiPointId Ӧ࿪ + multiPointState Ӧ࿪״̬ +ֵ0ʧ 1ɹ + +עwVirtualPointIds״̬wVirtualPointStatesЧҪ롣 + + /L L + / / + / / + / / + ---|------/-----------\------ N =====> ------------------ N + 1 2 \ \ + \ \ + R R + ͼ1.ⵥ ͼ2.ʵ + + ͼ11״̬Ϊ2ʱƳͼ2࿪״̬ΪLλʱͼһ2ΪЧģΪ£ + wVirtualPointIds[0]=1; + wVirtualPointStates[0]=2; + wVirtualPointNum=1; +author:Ŀ add by qxt 20170622 +*/ +UINT8 ConvertToMultiSwitchExp(DSU_EMAP_STRU *pDsuEmapStru,const UINT16 wVirtualPointIds[MAX_VIRTUAL_SWITCH_NUM],const UINT8 wVirtualPointStates[MAX_VIRTUAL_SWITCH_NUM],const UINT8 wVirtualPointNum,UINT16 *multiPointId,UINT8 *multiPointState) +{ + UINT8 chReturnValue = 0; /*ֵ*/ + UINT16 i= 0,j=0,k=0; /*ѭñ*/ + UINT8 IdCount=0U; /* ڼеȵĸ*/ + UINT8 StateCount=0U; /*״̬ȵĸֻһ*/ + UINT8 tempPointState=0U; /*࿪״̬*/ + DSU_MULTI_SWITCH_STRU *pMultiPointStru=NULL; /*࿪ʱṹ*/ + /*ȫֱĴε漰ȫֱ*/ + UINT16 *dsuMultiPointIndex=NULL; + DSU_DATA_LEN_STRU *dsuDataLenStru=NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru=NULL; + + if ((NULL == multiPointId) || (NULL == multiPointState) + || (NULL == wVirtualPointIds) || (NULL == wVirtualPointStates)) + { + /*࿪ָΪջָΪ*/ + chReturnValue = 0; + } + else + { + /*ʼΪЧֵ*/ + *multiPointId = DSU_NULL_16; + *multiPointState = DSU_NULL_8; + + if ((NULL != pDsuEmapStru) && (NULL != pDsuEmapStru->dsuEmapIndexStru)) + { + dsuMultiPointIndex = pDsuEmapStru->dsuEmapIndexStru->dsuMultiPointIndex; + dsuDataLenStru = pDsuEmapStru->dsuDataLenStru; + dsuStaticHeadStru = pDsuEmapStru->dsuStaticHeadStru; + + /*жЧ*/ + if (wVirtualPointNum <= MAX_VIRTUAL_SWITCH_NUM) + { + /*࿪*/ + for (i = 0; i < dsuDataLenStru->wMultiPointLen; i++) + { + IdCount = 0; + StateCount = 0; + pMultiPointStru = dsuStaticHeadStru->pMultiPointStru + i; + + for (k = 0; k < wVirtualPointNum; k++) + { + for (j = 0; j < pMultiPointStru->wType; j++) + { + if (wVirtualPointIds[k] == pMultiPointStru->wSwitchIds[j]) + { + IdCount++; + if (wVirtualPointStates[k] == pMultiPointStru->wSwitchStates[j]) + { + tempPointState = j; /*࿪״̬=ֵ+1*/ + + StateCount++; /*״̬ȵĸֻһ*/ + } + } + } + + } + /*ҵӦĶ࿪ + ٵĵNλҲR1λĵʱҵȵIdCountwVirtualPointNum+1ΪNλRλͬţʱһΣ + ĵûNλҲR1λĵʱҵȵIdCountwVirtualPointNum + ״̬ͱ״̬ȵĸֻһStateCount=1 + */ + if (((wVirtualPointNum == IdCount) || (wVirtualPointNum + 1 == IdCount)) && (1 == StateCount)) + { + *multiPointId = pMultiPointStru->wId; /*࿪*/ + *multiPointState = tempPointState + 1; /*࿪״̬(ֵ+1)*/ + chReturnValue = 1; + break; + } + } + + } + else + { + /*ڲ쳣ѯʧ*/ + chReturnValue = 0; + } + } + else + { + /*ӵͼָΪ*/ + chReturnValue = 0; + } + } + return chReturnValue; + + +} + +/********************************************************************************************** +*:ݼе·յlinkһlink֧Ϊ·(ӿ) +*: pDsuEmapStru +* szLinkQueryDir linkѯ +* pPathNum · +* szPath · +* szLinkNum ÿ·ij +*: pPathNum · +* szPath · +* szLinkNum ÿ·ij +* cLinkDirChangedNum link仯 +*ֵ:0:ʧ 1:ѯɹҸ·δյ 2ѯɹҸ·յ +*ע add by lxc 2021-2-28 +*޸ģby yt 2021911 ɾ +**********************************************************************************************/ +UINT8 dsuPathEndNextLinkExp(DSU_EMAP_STRU *pDsuEmapStru, UINT8 szLinkQueryDir[50], UINT8* pPathNum, UINT16 szPath[50][50], UINT16 szLinkNum[50]) +{ + UINT8 cRetVal = 0U; + + /* ڳн */ + UINT8 cPathNum = 0U; + + /* ʱ */ + UINT8 i = 0U; + UINT16 j = 0U; + UINT8 cTmpPathNum = 0U; + UINT16 wTmpEndLinkId = 0U; + UINT16 wTmpEndLinkIndex = 0U; + DSU_LINK_STRU *pTmpEndLinkStru = NULL; /*ǰLink,ȡʹ*/ + UINT8 cFunFlag = 0U; /* Ϊ0ʱ굱ǰ·Ϊ1ʱ굱ǰ·· */ + UINT16 wTmpNextMainLinkId = 0U; /* һlink */ + UINT16 wTmpNextSideLinkId = 0U; /* һβlink */ + UINT16 wAddLinkId = 0U; + UINT16 wNewLinkId = 0U; + UINT16 wTmpPathLinkNum = 0U; + UINT16 szTmpAddPath[25][50] = { 0U }; + UINT16 szTmpAddLinkNum[25] = { 0U }; + UINT16 wTmpEndPathNum = 0U; + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM = 0; + UINT16* pdsuLinkIndex = NULL; + DSU_STATIC_HEAD_STRU *pdsuStaticHeadStru = NULL; + + UINT8 cMainQueryDir = 0U; /*·IJѯ*/ + UINT8 cSideQueryDir = 0U; /*·IJѯ*/ + UINT8 cCurLinkDirChanged = LINK_DIRCHANGE_NONE; /*ǰLink仯*/ + UINT8 cNxtLinkDirChanged = LINK_DIRCHANGE_NONE; /*һLink仯*/ + UINT8 cTempPathIndex = 0U; + + /* 1.μ */ + if ((NULL != pDsuEmapStru) && (NULL != szLinkQueryDir) + && (NULL != pPathNum) && (50U > *pPathNum) && (0U != *pPathNum) + && (NULL != szPath) && (NULL != szLinkNum)) + { + for (i = 0U; i < 50U; i++) + { + /**/ + if ((EMAP_SAME_DIR == szLinkQueryDir[i]) || (EMAP_CONVER_DIR == szLinkQueryDir[i])) + { + cRetVal = 1U; + } + else + { + cRetVal = 0U; + break; + } + } + + /* γн */ + cPathNum = *pPathNum; + + /* ȫֱ͸ */ + LINKINDEXNUM = pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + pdsuLinkIndex = pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + pdsuStaticHeadStru = pDsuEmapStru->dsuStaticHeadStru; + } + + /* 2.ѯ·һlink + * 1ֵΪ0xff֤·ѵ·յ㣬洢ݿռ䲻·ѯһ· + * 2زѯϻȡ˵ͣ + * aΪյ¼յΪ0xFF + * bΪȡһlink· + * cΪұlinkΪlink·ֲ棬ݶλlink뷴λlink· + * dΪұlinkΪǻlinkȡlink· + */ + if (1u == cRetVal) + { + cTmpPathNum = 0u; + for (i = 0u; i < cPathNum; i++) + { + wTmpEndLinkId = szPath[i][(szLinkNum[i] - 1U)]; + cMainQueryDir = szLinkQueryDir[i]; + cSideQueryDir = szLinkQueryDir[i]; + + /* 1 */ + if (DSU_NULL_16 != wTmpEndLinkId) + { + cCurLinkDirChanged = pdsuStaticHeadStru->pLinkStru[pdsuLinkIndex[wTmpEndLinkId]].wLogicDirChanged; /*ȡǰlinkķ仯*/ + /*LinkIDȡǰlinkṹ*/ + wTmpEndLinkIndex = pdsuLinkIndex[wTmpEndLinkId]; + pTmpEndLinkStru = pdsuStaticHeadStru->pLinkStru + wTmpEndLinkIndex; + + wTmpNextMainLinkId = DSU_NULL_16; + wTmpNextSideLinkId = DSU_NULL_16; + + /* ȡѯϵĶ˵,ѯϵһlink */ + if (EMAP_SAME_DIR == cMainQueryDir) + { + wTmpNextMainLinkId = pTmpEndLinkStru->wTmnlJointMainLkId; + wTmpNextSideLinkId = pTmpEndLinkStru->wTmnlJointSideLkId; + } + else + { + wTmpNextMainLinkId = pTmpEndLinkStru->wOrgnJointMainLkId; + wTmpNextSideLinkId = pTmpEndLinkStru->wOrgnJointSideLkId; + } + + /* 2 */ + cFunFlag = 0U;/* ·Ҫ */ + wAddLinkId = wTmpNextMainLinkId; + wNewLinkId = wTmpNextSideLinkId; + + if (DSU_NULL_16 != wNewLinkId) + { + cFunFlag = 1u;/* Ҫ½· */ + } + + /*жǷڷ仯*/ + + + /* · */ + wTmpPathLinkNum = szLinkNum[i]; + + /* 굱ǰ·,жϵǰ·linkǷﵽ */ + if (49u == szLinkNum[i]) + { + /* δޣһlinkֻܴΪյ */ + szPath[i][wTmpPathLinkNum] = DSU_NULL_16; + szLinkNum[i]++; + } + else + { + + /* */ + szPath[i][wTmpPathLinkNum] = wAddLinkId; + szLinkNum[i]++; + + if (DSU_NULL_16 != wAddLinkId) + { + /*жǷڷ仯*/ + cNxtLinkDirChanged = pdsuStaticHeadStru->pLinkStru[pdsuLinkIndex[wAddLinkId]].wLogicDirChanged; + if (((LINK_DIRCHANGE_BEGIN == cNxtLinkDirChanged) || (LINK_DIRCHANGE_END == cNxtLinkDirChanged)) + && (cNxtLinkDirChanged == cCurLinkDirChanged)) + { + /*ڷ仯*/ + cMainQueryDir = ~cMainQueryDir; + } + else + { + /*ڷ仯㣬*/ + } + + szLinkQueryDir[i] = cMainQueryDir; /*洢·µIJѯ*/ + } + } + + if (1u == cFunFlag) + { + /* һ· */ + /* 1.жϵǰ·linkǷﵽ */ + if (49u == wTmpPathLinkNum) + { + /* δޣһlinkֻܴΪյ㣬¿·Ҳû */ + } + else + { + /* 2.ж·Ƿﵽ */ + if ((25u > cTmpPathNum) && (DSU_NULL_16 != wNewLinkId)) + { + /*Ϊ·Ӳѯ*/ + cTempPathIndex = cTmpPathNum + cPathNum; /*ǰ··*/ + if (50U > cTempPathIndex) + { + /*жǷڷ仯*/ + cNxtLinkDirChanged = pdsuStaticHeadStru->pLinkStru[pdsuLinkIndex[wNewLinkId]].wLogicDirChanged; + if (((LINK_DIRCHANGE_BEGIN == cNxtLinkDirChanged) || (LINK_DIRCHANGE_END == cNxtLinkDirChanged)) + && (cNxtLinkDirChanged == cCurLinkDirChanged)) + { + /*ڷ仯*/ + cSideQueryDir = ~cSideQueryDir; + } + else + { + /*ڷ仯㣬*/ + } + szLinkQueryDir[cTempPathIndex] = cSideQueryDir; /*洢·µIJѯ*/ + } + else + { + /*·ﵽޣ*/ + } + + /* һ· */ + szTmpAddLinkNum[cTmpPathNum] = wTmpPathLinkNum; + for (j = 0u; j < wTmpPathLinkNum; j++) + { + szTmpAddPath[cTmpPathNum][j] = szPath[i][j]; + } + szTmpAddPath[cTmpPathNum][wTmpPathLinkNum] = wNewLinkId; + szTmpAddLinkNum[cTmpPathNum]++; + cTmpPathNum++; + } + } + } + } + else + { + /* ¼鵽յ·жÿ·Ƿ񶼲鵽յ */ + wTmpEndPathNum++; + } + } + + /* · */ + for (i = 0u; i < cTmpPathNum; i++) + { + if (cPathNum >= 50U) + { + /* жǷ񳬳· */ + break; + } + + for (j = 0u; j < szTmpAddLinkNum[i]; j++) + { + szPath[cPathNum][j] = szTmpAddPath[i][j]; + } + + szLinkNum[cPathNum] = szTmpAddLinkNum[i]; + cPathNum++; + } + + *pPathNum = cPathNum; + } + + if ((1u == cRetVal) && (cPathNum == wTmpEndPathNum)) + { + cRetVal = 2U; + } + + return cRetVal; +} + +/********************************************************************************************* +*:ж·յǷΪͬһlinkΪͬһlink·(ͨӿ) +*: cPathANum A· + szPathA A· + szLinkANum A·link + cPathBNum B· + szPathB B· + szLinkBNum B·link + cABPathDir A/B·IJѯ +*: szPath ҵ· + pPathLinkNum ҵ· + pLinkDirChangedNum linkеķ仯 +*ֵ:յͬlink:0 +յͬlink:1 +*ע add by lxc 2021-2-28 +*********************************************************************************************/ +UINT8 dsuPathSameEndLinkExp(UINT8 cPathANum, UINT16 szPathA[50][50], UINT16 szLinkANum[50], UINT8 cPathBNum + , UINT16 szPathB[50][50], UINT16 szLinkBNum[50], UINT16 szPath[100], UINT16* pPathLinkNum, UINT8* pLinkDirChangedNum, UINT8 cABPathDir, DSU_EMAP_STRU *pDsuEmapStru) +{ + UINT8 retVal = 0U; + UINT8 cKeepWorkFlag = 0U; + UINT8 cFunCreatPathFlag = 0U; + UINT8 i = 0U; + UINT8 j = 0U; + UINT16 x = 0U; + + UINT16 wTmpPathA1LinkNum = 0U; + UINT16 wTmpPathB1LinkNum = 0U; + UINT16 wTmpPathA2LinkNum = 0U; + UINT16 wTmpPathB2LinkNum = 0U; + + UINT16 wTmpPathALinkNum = 0U; + UINT16 wTmpPathBLinkNum = 0U; + + /* һlink */ + UINT16 wTmpPathAEnd1LinkId = 0U; + UINT16 wTmpPathBEnd1LinkId = 0U; + + /* ڶlink */ + UINT16 wTmpPathAEnd2LinkId = 0U; + UINT16 wTmpPathBEnd2LinkId = 0U; + + UINT16 wTmpPathLinkNum = 0U; + UINT16 wTmpLinkIndex = 0U; + + UINT8 cCurLinkDirChanged = LINK_DIRCHANGE_NONE; /*ǰLink仯*/ + UINT8 cNxtLinkDirChanged = LINK_DIRCHANGE_NONE; /*һLink仯*/ + UINT8 cLinkDirChangedNum = 0U; /*linkз仯*/ + UINT8 cResiDue = 0U; + + if ((NULL == szPathA) || (NULL == szLinkANum) || (NULL == szPathB) || (NULL == szLinkBNum) + || (NULL == szPath) || (NULL == pPathLinkNum) || (NULL == pLinkDirChangedNum) + || ((EMAP_PATH_SAME_DIR != cABPathDir) && (EMAP_PATH_CONVER_DIR != cABPathDir))) + { + ; + } + else + { + cKeepWorkFlag = 1u; + } + + if (1u == cKeepWorkFlag) + { + for (i = 0U; i < cPathANum; i++) + { + for (j = 0U; j < cPathBNum; j++) + { + wTmpPathA1LinkNum = szLinkANum[i] - 1u; + wTmpPathA2LinkNum = szLinkANum[i] - 2U; + + wTmpPathB1LinkNum = szLinkBNum[j] - 1u; + wTmpPathB2LinkNum = szLinkBNum[j] - 2U; + + wTmpPathAEnd1LinkId = szPathA[i][wTmpPathA1LinkNum]; + wTmpPathAEnd2LinkId = szPathA[i][wTmpPathA2LinkNum]; + + wTmpPathBEnd1LinkId = szPathB[j][wTmpPathB1LinkNum]; + wTmpPathBEnd2LinkId = szPathB[j][wTmpPathB2LinkNum]; + + /* Ϊѯཻ·Ҫ */ + if ((wTmpPathAEnd1LinkId == wTmpPathBEnd1LinkId) && (DSU_NULL_16 != wTmpPathAEnd1LinkId)) + { + wTmpPathALinkNum = wTmpPathA1LinkNum; + wTmpPathBLinkNum = wTmpPathB1LinkNum; + cFunCreatPathFlag = 1u; + } + else if (wTmpPathAEnd2LinkId == wTmpPathBEnd1LinkId) + { + wTmpPathALinkNum = wTmpPathA2LinkNum; + wTmpPathBLinkNum = wTmpPathB1LinkNum; + cFunCreatPathFlag = 1u; + } + else if (wTmpPathAEnd2LinkId == wTmpPathBEnd2LinkId) + { + wTmpPathALinkNum = wTmpPathA2LinkNum; + wTmpPathBLinkNum = wTmpPathB2LinkNum; + cFunCreatPathFlag = 1u; + } + else if (wTmpPathAEnd1LinkId == wTmpPathBEnd2LinkId) + { + wTmpPathALinkNum = wTmpPathA1LinkNum; + wTmpPathBLinkNum = wTmpPathB2LinkNum; + cFunCreatPathFlag = 1u; + } + else + { + /*do nothing*/ + } + + + if (1u == cFunCreatPathFlag) + { + break; + } + } + if (1u == cFunCreatPathFlag) + { + break; + } + } + + wTmpPathALinkNum++; + wTmpPathBLinkNum++; + if ((1u == cFunCreatPathFlag) && (100U >= (wTmpPathALinkNum + wTmpPathBLinkNum))) + { + + /* 洢ǰ·,洢һlink */ + wTmpPathALinkNum--; + for (x = 0U; x < wTmpPathALinkNum; x++) + { + szPath[wTmpPathLinkNum] = szPathA[i][x]; + wTmpPathLinkNum++; + } + + /* 洢·,洢˵ */ + for (x = 0U; x < wTmpPathBLinkNum; x++) + { + wTmpLinkIndex = wTmpPathBLinkNum - x; + wTmpLinkIndex--; + szPath[wTmpPathLinkNum] = szPathB[j][wTmpLinkIndex]; + wTmpPathLinkNum++; + } + + /*linkеķ仯*/ + for (x = 0U; x < (wTmpPathLinkNum - 1U); x++) + { + if ((UINT16_MAX != szPath[x]) && (UINT16_MAX != szPath[x + 1U])) + { + cCurLinkDirChanged = pDsuEmapStru->dsuStaticHeadStru->pLinkStru[pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[szPath[x]]].wLogicDirChanged; + cNxtLinkDirChanged = pDsuEmapStru->dsuStaticHeadStru->pLinkStru[pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[szPath[x + 1U]]].wLogicDirChanged; + if (((LINK_DIRCHANGE_BEGIN == cNxtLinkDirChanged) || (LINK_DIRCHANGE_END == cNxtLinkDirChanged)) + && (cNxtLinkDirChanged == cCurLinkDirChanged)) + { + /*ڷ仯*/ + cLinkDirChangedNum++; + } + else + { + /*ڷ仯㣬*/ + } + } + } + + cResiDue = cLinkDirChangedNum % 2U; + + if (((0U == cResiDue) && (EMAP_PATH_CONVER_DIR == cABPathDir)) || ((0U != cResiDue) && (EMAP_PATH_SAME_DIR == cABPathDir))) + { + *pPathLinkNum = wTmpPathLinkNum; + *pLinkDirChangedNum = cLinkDirChangedNum; + retVal = 1; + } + else + { + /*ѯʧܣʧ*/ + } + } + } + + return retVal; +} + +/************************************************ +*:ѯAB֮ľ +*: pDsuEmapStru ӵͼ +* pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +* pLinkDirChangedNum 仯 +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2021-2-28 +************************************************/ +UINT32 dsuLenByPointExp(DSU_EMAP_STRU *pDsuEmapStru, const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8 *pDir, UINT8* pLinkDirChangedNum) +{ + UINT32 reLen = DSU_NULL_32; + UINT8 cFunRetVal = 0U; + UINT8 cFun1RetVal = 0U; + UINT8 cFun2RetVal = 0U; + UINT8 cFun3RetVal = 0U; + UINT8 cFun4RetVal = 0U; + UINT8 cFun5RetVal = 0U; + UINT8 cKeepWorkFlag = 0U; + UINT16 dwCycle = 0U; + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM = 0; + UINT16* dsuLinkIndex = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + + /* ϵ· */ + UINT16 szSameDirPathA[50][50] = { 0U }; + UINT16 szPathASameDirLinkNum[50] = { 0U }; + UINT8 wPathASameDirNum = 0U; + + UINT16 szConverDirPathA[50][50] = { 0U }; + UINT16 szPathAConverDirLinkNum[50] = { 0U }; + UINT8 wPathAConverDirNum = 0U; + + UINT16 szSameDirPathB[50][50] = { 0U }; + UINT16 szPathBSameDirLinkNum[50] = { 0U }; + UINT8 wPathBSameDirNum = 0U; + + UINT16 szConverDirPathB[50][50] = { 0U }; + UINT16 szPathBConverDirLinkNum[50] = { 0U }; + UINT8 wPathBConverDirNum = 0U; + + /* ʱ */ + UINT16 i = 0U; + UINT16 wTmpLinkId = 0U; + UINT16 wTmpLinkIndex = 0U; + DSU_LINK_STRU *pTmpLinkStru = NULL; + UINT16 szOutputPath[100] = { 0U }; + UINT16 wOutputLinkNum = 0U; + UINT32 wTmpLen = 0U; + UINT8 cQueryADir = EMAP_SAME_DIR; + UINT8 cQueryBDir = EMAP_SAME_DIR; + + UINT8 szASameQueryDir[50] = { 0U }; /*Aͬѯ·ķ*/ + UINT8 szAConvertQueryDir[50] = { 0U }; /*Aѯ·ķ*/ + UINT8 szBSameQueryDir[50] = { 0U }; /*Bͬѯ·ķ*/ + UINT8 szBConvertQueryDir[50] = { 0U }; /*Bѯ·ķ*/ + UINT8 cTmepDirChangedNum = 0U; /*·ķ仯*/ + + memset(szASameQueryDir, EMAP_SAME_DIR, sizeof(UINT8) * 50); + memset(szAConvertQueryDir, EMAP_CONVER_DIR, sizeof(UINT8) * 50); + memset(szBSameQueryDir, EMAP_SAME_DIR, sizeof(UINT8) * 50); + memset(szBConvertQueryDir, EMAP_CONVER_DIR, sizeof(UINT8) * 50); + + if ((NULL != pLODAStru) && (NULL != pLODBStru) && (NULL != pDsuEmapStru) && (NULL != szLinkId) + && (NULL != pLinkNum) && (NULL != pDir) && (NULL != szLinkId) && (NULL != pDir) + && (0U != pLODAStru->Lnk) && (0U != pLODBStru->Lnk) && (NULL != pLinkDirChangedNum)) + { + cKeepWorkFlag = 1u; + *pLinkNum = 0U; + *pDir = EMAP_SAME_DIR; + + /* ȫֱ͸ */ + LINKINDEXNUM = pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex = pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru = pDsuEmapStru->dsuStaticHeadStru; + } + + if (1u == cKeepWorkFlag) + { + if ((LINKINDEXNUM < pLODAStru->Lnk) || (LINKINDEXNUM < pLODBStru->Lnk)) + { + cKeepWorkFlag = 0U; + } + else + { + /* ƫ */ + wTmpLinkId = pLODAStru->Lnk; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + if (pTmpLinkStru->dwLength < pLODAStru->Off) + { + cKeepWorkFlag = 0U; + } + + wTmpLinkId = pLODBStru->Lnk; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + if (pTmpLinkStru->dwLength < pLODBStru->Off) + { + cKeepWorkFlag = 0U; + } + } + } + + + if (1u == cKeepWorkFlag) + { + if (pLODAStru->Lnk == pLODBStru->Lnk) + { + /* ͬһlink */ + if (pLODAStru->Off > pLODBStru->Off) + { + cQueryADir = EMAP_CONVER_DIR; + reLen = pLODAStru->Off - pLODBStru->Off; + } + else + { + cQueryADir = EMAP_SAME_DIR; + reLen = pLODBStru->Off - pLODAStru->Off; + } + + szLinkId[wOutputLinkNum] = pLODAStru->Lnk; + wOutputLinkNum++; + *pLinkDirChangedNum = 0U; + *pLinkNum = wOutputLinkNum; + } + else + { + /* 㲻ͬһlink */ + /* ʼ· */ + szSameDirPathA[0][0] = pLODAStru->Lnk; + szPathASameDirLinkNum[0] = 1u; + wPathASameDirNum = 1u; + + szConverDirPathA[0][0] = pLODAStru->Lnk; + szPathAConverDirLinkNum[0] = 1u; + wPathAConverDirNum = 1u; + + szSameDirPathB[0][0] = pLODBStru->Lnk; + szPathBSameDirLinkNum[0] = 1u; + wPathBSameDirNum = 1u; + + szConverDirPathB[0][0] = pLODBStru->Lnk; + szPathBConverDirLinkNum[0] = 1u; + wPathBConverDirNum = 1u; + + cFunRetVal = 1u; + cFun1RetVal = 1u; + cFun2RetVal = 1u; + cFun3RetVal = 1u; + cFun4RetVal = 1u; + + dwCycle = 1u; + while (1u == cFunRetVal) + { + cFunRetVal = 0U; + + /* 1.úֱѯһlinkµ· */ + if (2U != cFun1RetVal) + { + cFun1RetVal = dsuPathEndNextLinkExp(pDsuEmapStru, szASameQueryDir, &wPathASameDirNum, szSameDirPathA, szPathASameDirLinkNum); + } + + if (2U != cFun2RetVal) + { + cFun2RetVal = dsuPathEndNextLinkExp(pDsuEmapStru, szAConvertQueryDir, &wPathAConverDirNum, szConverDirPathA, szPathAConverDirLinkNum); + } + + if (2U != cFun3RetVal) + { + cFun3RetVal = dsuPathEndNextLinkExp(pDsuEmapStru, szBSameQueryDir, &wPathBSameDirNum, szSameDirPathB, szPathBSameDirLinkNum); + } + + if (2U != cFun4RetVal) + { + cFun4RetVal = dsuPathEndNextLinkExp(pDsuEmapStru, szBConvertQueryDir, &wPathBConverDirNum, szConverDirPathB, szPathBConverDirLinkNum); + } + + if (((2U == cFun1RetVal) && (cFun1RetVal == cFun2RetVal) && (cFun2RetVal == cFun3RetVal) && (cFun3RetVal == cFun4RetVal)) + || ((cFun1RetVal == 0U) || (cFun2RetVal == 0U) || (cFun3RetVal == 0U) || (cFun4RetVal == 0U))) + { + /* ѯյ㣬ѯʧܣ˳ѭ */ + cFunRetVal = 0U; + } + else + { + /* µ··δյ */ + cFunRetVal = 1u; + } + + cFun5RetVal = 0U; + /* 2.жķɢ·linkǷཻlink,· */ + if (1u == cFunRetVal) + { + cQueryADir = EMAP_SAME_DIR; + cQueryBDir = EMAP_CONVER_DIR; + cFun5RetVal = dsuPathSameEndLinkExp(wPathASameDirNum, szSameDirPathA, szPathASameDirLinkNum + , wPathBConverDirNum, szConverDirPathB, szPathBConverDirLinkNum, szOutputPath, &wOutputLinkNum, &cTmepDirChangedNum, EMAP_PATH_CONVER_DIR, pDsuEmapStru); + + if (0U == cFun5RetVal) + { + cQueryADir = EMAP_CONVER_DIR; + cQueryBDir = EMAP_SAME_DIR; + cFun5RetVal = dsuPathSameEndLinkExp(wPathAConverDirNum, szConverDirPathA, szPathAConverDirLinkNum + , wPathBSameDirNum, szSameDirPathB, szPathBSameDirLinkNum, szOutputPath, &wOutputLinkNum, &cTmepDirChangedNum, EMAP_PATH_CONVER_DIR, pDsuEmapStru); + } + if (0U == cFun5RetVal) + { + cQueryADir = EMAP_SAME_DIR; + cQueryBDir = EMAP_SAME_DIR; + cFun5RetVal = dsuPathSameEndLinkExp(wPathASameDirNum, szSameDirPathA, szPathASameDirLinkNum + , wPathBSameDirNum, szSameDirPathB, szPathBSameDirLinkNum, szOutputPath, &wOutputLinkNum, &cTmepDirChangedNum, EMAP_PATH_SAME_DIR, pDsuEmapStru); + } + if (0U == cFun5RetVal) + { + cQueryADir = EMAP_CONVER_DIR; + cQueryBDir = EMAP_CONVER_DIR; + cFun5RetVal = dsuPathSameEndLinkExp(wPathAConverDirNum, szConverDirPathA, szPathAConverDirLinkNum + , wPathBConverDirNum, szConverDirPathB, szPathBConverDirLinkNum, szOutputPath, &wOutputLinkNum, &cTmepDirChangedNum, EMAP_PATH_SAME_DIR, pDsuEmapStru); + } + } + + if ((1u == cFunRetVal) && (1u == cFun5RetVal)) + { + /* 4. */ + /* ѯһ··,ֹѯ */ + cFunRetVal = 0U; + *pLinkNum = wOutputLinkNum; + for (i = 0U; i < wOutputLinkNum; i++) + { + szLinkId[i] = szOutputPath[i]; + + wTmpLinkId = szLinkId[i]; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + + if ((wTmpLinkId != pLODAStru->Lnk) && (wTmpLinkId != pLODBStru->Lnk)) + { + /* ۼӾ */ + wTmpLen += pTmpLinkStru->dwLength; + } + } + + wTmpLinkId = pLODAStru->Lnk; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + if (EMAP_SAME_DIR == cQueryADir) + { + wTmpLen += (pTmpLinkStru->dwLength - pLODAStru->Off); + } + else + { + wTmpLen += pLODAStru->Off; + } + + wTmpLinkId = pLODBStru->Lnk; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + if (EMAP_SAME_DIR == cQueryBDir) + { + wTmpLen += (pTmpLinkStru->dwLength - pLODBStru->Off); + } + else + { + wTmpLen += pLODBStru->Off; + } + + *pLinkDirChangedNum = cTmepDirChangedNum; /*linkаķ仯*/ + reLen = wTmpLen; + } + + /* ֻѯ49 */ + if (dwCycle >= 49u) + { + break; + } + dwCycle++; + } + } + + /* */ + *pDir = cQueryADir; + } + + return reLen; +} + + +/********************************************************************************************** +*:ݼе·յλlinkһlink(ӿ) +*: pDsuEmapStru +* cDir ѯ +* szPath · +* pLinkNum ·ij +* wSwitchSum +* pSwitchInfo ״̬ +*: szPath · +* pLinkNum ·ij +*ֵ:0:ʧ 1:ѯɹҸ·δյ 2ѯɹҸ·յ +*ע add by lxc 2022-6-17 +**********************************************************************************************/ +UINT8 dsuPathEndNextLinkBySwitchStateExp(DSU_EMAP_STRU *pDsuEmapStru, UINT8 cDir, UINT16 szPath[50],UINT16 *pLinkNum, const UINT8 cSwitchSum, const DQU_POINT_STATUS_STRU *pSwitchInfo) +{ + UINT8 cRetVal = 0U; + + /* ʱ */ + UINT16 j = 0U; + UINT16 wTmpEndLinkId = 0U; + UINT8 cFunRetVal = 0U; /* Ϊ0ʱ굱ǰ·Ϊ1ʱ굱ǰ·· */ + UINT16 wTmpNextLinkId = 0U; /* һlink */ + UINT16 wTmpLinkNum = 0U; + UINT16 szTmpAddPath[50] = { 0U }; + UINT16 szTmpAddLinkNum = 0U; + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM = 0; + UINT16* dsuLinkIndex = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + + /* 1.μ */ + if ((NULL != pDsuEmapStru) + && (NULL != szPath) && (NULL != pLinkNum) && (0U != *pLinkNum) + && ((EMAP_SAME_DIR == cDir) || (EMAP_CONVER_DIR == cDir))) + { + cRetVal = 1u; + + /* ȫֱ͸ */ + LINKINDEXNUM = pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex = pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru = pDsuEmapStru->dsuStaticHeadStru; + wTmpLinkNum = *pLinkNum; + wTmpEndLinkId = szPath[(wTmpLinkNum - 1u)]; + } + + /* 2.ѯ·һlink + * 1ֵΪ0xff֤·ѵ·յ㣬洢ݿռ䲻·ѯһ· + * 2زѯϻȡ˵ͣ + * aΪյ¼յΪ0xFF + * bΪȡһlink· + * cΪұlinkΪlink·ֲ棬ݶλlink뷴λlink· + * dΪұlinkΪǻlinkȡlink· + */ + if (1u == cRetVal) + { + + /* 1 */ + if (DSU_NULL_16 != wTmpEndLinkId) + { + wTmpNextLinkId = DSU_NULL_16; + /* ȡѯϵĶ˵,ѯϵһlink */ + cFunRetVal = dsuGetAdjacentLinkIDExp(pDsuEmapStru,wTmpEndLinkId,cDir,(UCHAR)cSwitchSum, pSwitchInfo,&wTmpNextLinkId); + + /* жǷѯɹ */ + if ((0U == wTmpNextLinkId) || (0U == cFunRetVal) || (49u <= wTmpLinkNum)) + { + /* ѯʧܻߵ */ + wTmpNextLinkId = DSU_NULL_16; + + } + + szPath[wTmpLinkNum] = wTmpNextLinkId; + wTmpLinkNum++; + + /* ֵ */ + *pLinkNum = wTmpLinkNum; + + if (DSU_NULL_16 == wTmpNextLinkId) + { + cRetVal = 2U; + } + } + else + { + /* ·Ѿѯյ */ + cRetVal = 2U; + } + + } + + return cRetVal; +} + +/********************************************************************************************* +*:ж·յǷΪͬһlinkΪͬһlink·(ͨӿ) +*: +*szPathA A· +*szLinkANum A·link +*szPathB B· +*szLinkBNum B·link +*: szPath ҵ· +*pPathLinkNum ҵ· +*ֵ:յͬlink:0 +*յͬlink:1 +*ע add by lxc 2022-6-17 +*********************************************************************************************/ +UINT8 dsuLinkBufSameEndLinkExp(UINT16 szPathA[50], UINT16 wLinkANum,UINT16 szPathB[50], UINT16 wLinkBNum, UINT16 szPath[100], UINT16* pPathLinkNum) +{ + UINT8 retVal = 0U; + UINT8 cKeepWorkFlag = 0U; + UINT8 cFunCreatPathFlag = 0U; + UINT16 i = 0U; + + UINT16 wTmpPathA1LinkNum = 0U; + UINT16 wTmpPathB1LinkNum = 0U; + UINT16 wTmpPathA2LinkNum = 0U; + UINT16 wTmpPathB2LinkNum = 0U; + + UINT16 wTmpPathALinkNum = 0U; + UINT16 wTmpPathBLinkNum = 0U; + + /* һlink */ + UINT16 wTmpPathAEnd1LinkId = 0U; + UINT16 wTmpPathBEnd1LinkId = 0U; + + /* ڶlink */ + UINT16 wTmpPathAEnd2LinkId = 0U; + UINT16 wTmpPathBEnd2LinkId = 0U; + + UINT16 wTmpPathLinkNum = 0U; + UINT16 wTmpLinkIndex = 0U; + + if ((NULL == szPathA) || (NULL == szPathB) || (NULL == szPath) || (NULL == pPathLinkNum)) + { + ; + } + else + { + cKeepWorkFlag = 1u; + } + + if (1u == cKeepWorkFlag) + { + wTmpPathA1LinkNum = wLinkANum - 1u; + wTmpPathA2LinkNum = wLinkANum - 2U; + + wTmpPathB1LinkNum = wLinkBNum - 1u; + wTmpPathB2LinkNum = wLinkBNum - 2U; + + wTmpPathAEnd1LinkId = szPathA[wTmpPathA1LinkNum]; + wTmpPathAEnd2LinkId = szPathA[wTmpPathA2LinkNum]; + + wTmpPathBEnd1LinkId = szPathB[wTmpPathB1LinkNum]; + wTmpPathBEnd2LinkId = szPathB[wTmpPathB2LinkNum]; + + /* Ϊѯཻ·Ҫ */ + if ((wTmpPathAEnd1LinkId == wTmpPathBEnd1LinkId) && (DSU_NULL_16 != wTmpPathAEnd1LinkId)) + { + wTmpPathALinkNum = wTmpPathA1LinkNum; + wTmpPathBLinkNum = wTmpPathB1LinkNum; + cFunCreatPathFlag = 1u; + } + else if (wTmpPathAEnd2LinkId == wTmpPathBEnd1LinkId) + { + wTmpPathALinkNum = wTmpPathA2LinkNum; + wTmpPathBLinkNum = wTmpPathB1LinkNum; + cFunCreatPathFlag = 1u; + } + else if (wTmpPathAEnd2LinkId == wTmpPathBEnd2LinkId) + { + wTmpPathALinkNum = wTmpPathA2LinkNum; + wTmpPathBLinkNum = wTmpPathB2LinkNum; + cFunCreatPathFlag = 1u; + } + else if (wTmpPathAEnd1LinkId == wTmpPathBEnd2LinkId) + { + wTmpPathALinkNum = wTmpPathA1LinkNum; + wTmpPathBLinkNum = wTmpPathB2LinkNum; + cFunCreatPathFlag = 1u; + } + else + { + /*do nothing*/ + } + + wTmpPathALinkNum++; + wTmpPathBLinkNum++; + if ((1U == cFunCreatPathFlag) && (100U >= (wTmpPathALinkNum + wTmpPathBLinkNum))) + { + + /* 洢ǰ·,洢һlink */ + wTmpPathALinkNum--; + for (i = 0U; i < wTmpPathALinkNum; i++) + { + szPath[wTmpPathLinkNum] = szPathA[i]; + wTmpPathLinkNum++; + } + + /* 洢·,洢˵ */ + for (i = 0U; i < wTmpPathBLinkNum; i++) + { + wTmpLinkIndex = wTmpPathBLinkNum - i; + wTmpLinkIndex--; + szPath[wTmpPathLinkNum] = szPathB[wTmpLinkIndex]; + wTmpPathLinkNum++; + } + + *pPathLinkNum = wTmpPathLinkNum; + retVal = 1; + } + } + + return retVal; +} + + +/************************************************ +*:ѯAB֮ľ룬ݵʵλò +*: pDsuEmapStru ӵͼ +* pLODAStru A +* pLODBStru B +* cSwitchSum +* pSwitchInfo Ϣ +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2022-6-17 +************************************************/ +UINT32 dsuLenByPointBySwitchStateExp(DSU_EMAP_STRU *pDsuEmapStru, const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, const UINT8 cSwitchSum, const DQU_POINT_STATUS_STRU *pSwitchInfo, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8 *pDir) +{ + UINT32 reLen = DSU_NULL_32; + UINT8 cFunRetVal = 0U; + UINT8 cFun1RetVal = 0U; + UINT8 cFun2RetVal = 0U; + UINT8 cFun3RetVal = 0U; + UINT8 cFun4RetVal = 0U; + UINT8 cFun5RetVal = 0U; + UINT8 cKeepWorkFlag = 0U; + UINT16 dwCycle = 0U; + + /*ȫֱĴε漰ȫֱ*/ + UINT16 LINKINDEXNUM = 0; + UINT16* dsuLinkIndex = NULL; + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru = NULL; + + /* ϵ· */ + UINT16 szSameDirPathA[50] = { 0U }; + UINT16 wPathASameDirLinkNum = 0U; + + UINT16 szConverDirPathA[50] = { 0U }; + UINT16 wPathAConverDirLinkNum = 0U; + + UINT16 szSameDirPathB[50] = { 0U }; + UINT16 wPathBSameDirLinkNum = 0U; + + UINT16 szConverDirPathB[50] = { 0U }; + UINT16 wPathBConverDirLinkNum = 0U; + + /* ʱ */ + UINT16 i = 0U; + UINT16 wTmpLinkId = 0U; + UINT16 wTmpLinkIndex = 0U; + DSU_LINK_STRU *pTmpLinkStru = NULL; + UINT16 szOutputPath[100] = { 0U }; + UINT16 wOutputLinkNum = 0U; + UINT32 wTmpLen = 0U; + UINT8 cQueryADir = EMAP_SAME_DIR; + UINT8 cQueryBDir = EMAP_SAME_DIR; + + if ((NULL != pLODAStru) && (NULL != pLODBStru) && (NULL != pDsuEmapStru) && (NULL != szLinkId) + && (NULL != pLinkNum) && (NULL != pDir) && (NULL != szLinkId) && (NULL != pDir) && (NULL != pSwitchInfo) + && (0U != pLODAStru->Lnk) && (0U != pLODBStru->Lnk)) + { + cKeepWorkFlag = 1u; + *pLinkNum = 0U; + *pDir = EMAP_SAME_DIR; + + /* ȫֱ͸ */ + LINKINDEXNUM = pDsuEmapStru->dsuEmapIndexStru->LINKINDEXNUM; + dsuLinkIndex = pDsuEmapStru->dsuEmapIndexStru->dsuLinkIndex; + dsuStaticHeadStru = pDsuEmapStru->dsuStaticHeadStru; + } + + if (1u == cKeepWorkFlag) + { + if ((LINKINDEXNUM < pLODAStru->Lnk) || (LINKINDEXNUM < pLODBStru->Lnk)) + { + cKeepWorkFlag = 0U; + } + else + { + /* ƫ */ + wTmpLinkId = pLODAStru->Lnk; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + if (pTmpLinkStru->dwLength < pLODAStru->Off) + { + cKeepWorkFlag = 0U; + } + + wTmpLinkId = pLODBStru->Lnk; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + if (pTmpLinkStru->dwLength < pLODBStru->Off) + { + cKeepWorkFlag = 0U; + } + } + } + + + if (1u == cKeepWorkFlag) + { + if (pLODAStru->Lnk == pLODBStru->Lnk) + { + /* ͬһlink */ + if (pLODAStru->Off > pLODBStru->Off) + { + cQueryADir = EMAP_CONVER_DIR; + reLen = pLODAStru->Off - pLODBStru->Off; + } + else + { + cQueryADir = EMAP_SAME_DIR; + reLen = pLODBStru->Off - pLODAStru->Off; + } + + szLinkId[wOutputLinkNum] = pLODAStru->Lnk; + wOutputLinkNum++; + *pLinkNum = wOutputLinkNum; + } + else + { + /* 㲻ͬһlink */ + /* ʼ· */ + szSameDirPathA[0] = pLODAStru->Lnk; + wPathASameDirLinkNum= 1u; + + szConverDirPathA[0] = pLODAStru->Lnk; + wPathAConverDirLinkNum = 1u; + + szSameDirPathB[0] = pLODBStru->Lnk; + wPathBSameDirLinkNum = 1u; + + szConverDirPathB[0] = pLODBStru->Lnk; + wPathBConverDirLinkNum = 1u; + + cFunRetVal = 1u; + cFun1RetVal = 1u; + cFun2RetVal = 1u; + cFun3RetVal = 1u; + cFun4RetVal = 1u; + + dwCycle = 1u; + while (1u == cFunRetVal) + { + + cFunRetVal = 0U; + + /* 1.úֱѯһlinkµ· */ + if (2U != cFun1RetVal) + { + cFun1RetVal = dsuPathEndNextLinkBySwitchStateExp(pDsuEmapStru, EMAP_SAME_DIR, szSameDirPathA, &wPathASameDirLinkNum,cSwitchSum, pSwitchInfo); + } + + if (2U != cFun2RetVal) + { + cFun2RetVal = dsuPathEndNextLinkBySwitchStateExp(pDsuEmapStru, EMAP_CONVER_DIR, szConverDirPathA, &wPathAConverDirLinkNum,cSwitchSum, pSwitchInfo); + } + + if (2U != cFun3RetVal) + { + cFun3RetVal = dsuPathEndNextLinkBySwitchStateExp(pDsuEmapStru, EMAP_SAME_DIR, szSameDirPathB, &wPathBSameDirLinkNum,cSwitchSum, pSwitchInfo); + } + + if (2U != cFun4RetVal) + { + cFun4RetVal = dsuPathEndNextLinkBySwitchStateExp(pDsuEmapStru, EMAP_CONVER_DIR, szConverDirPathB, &wPathBConverDirLinkNum, cSwitchSum, pSwitchInfo); + } + + if (((2U == cFun1RetVal) && (cFun1RetVal == cFun2RetVal) && (cFun2RetVal == cFun3RetVal) && (cFun3RetVal == cFun4RetVal)) + || ((cFun1RetVal == 0U) || (cFun2RetVal == 0U) || (cFun3RetVal == 0U) || (cFun4RetVal == 0U))) + { + /* ѯյ㣬ѯʧܣ˳ѭ */ + cFunRetVal = 0U; + } + else + { + /* µ··δյ */ + cFunRetVal = 1u; + } + + cFun5RetVal = 0U; + /* 2.жķɢ·linkǷཻlink,· */ + if (1u == cFunRetVal) + { + + cQueryADir = EMAP_SAME_DIR; + cQueryBDir = EMAP_CONVER_DIR; + cFun5RetVal = dsuLinkBufSameEndLinkExp(szSameDirPathA, wPathASameDirLinkNum,szConverDirPathB, wPathBConverDirLinkNum, szOutputPath, &wOutputLinkNum); + + if (0U == cFun5RetVal) + { + cQueryADir = EMAP_CONVER_DIR; + cQueryBDir = EMAP_SAME_DIR; + cFun5RetVal = dsuLinkBufSameEndLinkExp(szConverDirPathA, wPathAConverDirLinkNum,szSameDirPathB, wPathBSameDirLinkNum, szOutputPath, &wOutputLinkNum); + } + + } + + if ((1u == cFunRetVal) && (1u == cFun5RetVal)) + { + /* 4. */ + /* ѯһ··,ֹѯ */ + cFunRetVal = 0U; + *pLinkNum = wOutputLinkNum; + for (i = 0U; i < wOutputLinkNum; i++) + { + szLinkId[i] = szOutputPath[i]; + + wTmpLinkId = szLinkId[i]; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + + if ((wTmpLinkId != pLODAStru->Lnk) && (wTmpLinkId != pLODBStru->Lnk)) + { + /* ۼӾ */ + wTmpLen += pTmpLinkStru->dwLength; + } + } + + wTmpLinkId = pLODAStru->Lnk; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + if (EMAP_SAME_DIR == cQueryADir) + { + wTmpLen += (pTmpLinkStru->dwLength - pLODAStru->Off); + } + else + { + wTmpLen += pLODAStru->Off; + } + + wTmpLinkId = pLODBStru->Lnk; + wTmpLinkIndex = dsuLinkIndex[wTmpLinkId]; + pTmpLinkStru = dsuStaticHeadStru->pLinkStru + wTmpLinkIndex; + if (EMAP_SAME_DIR == cQueryBDir) + { + wTmpLen += (pTmpLinkStru->dwLength - pLODBStru->Off); + } + else + { + wTmpLen += pLODBStru->Off; + } + + reLen = wTmpLen; + } + + /* ֻѯ49 */ + if (dwCycle >= 49u) + { + break; + } + dwCycle++; + } + } + + /* */ + *pDir = cQueryADir; + } + + + return reLen; +} + +/** +* @brief ȡLINK˵Ϣ +* @param chDir +* @param wLinkId LINK +* @param pLinkPoint ˵Ϣ +* @return CI_SUCCESS:ɹCI_ERROR:ʧ +*/ +UINT8 dsuLinkPointInfo(UINT8 chDir, UINT16 wLinkId, LINK_POINT_DATA_STRU *pLinkPoint) +{ + UINT8 rtnValue = 0U; + DSU_LINK_STRU * pLinkDataTemp = NULL; + + pLinkDataTemp = g_dsuEmapStru->dsuStaticHeadStru->pLinkStru + g_dsuEmapStru->dsuEmapIndexStru->dsuLinkIndex[wLinkId]; + + if ((NULL == pLinkPoint) || (NULL == pLinkDataTemp)) + { + /* ָΪջlink */ + } + else if ((EMAP_SAME_DIR != chDir) && (EMAP_CONVER_DIR != chDir)) + { + /* 򲻺Ϸ */ + } + else + { + pLinkPoint->wLinkId = pLinkDataTemp->wId; + pLinkPoint->wPointType = UINT16_MAX; + pLinkPoint->wPointId = UINT16_MAX; + pLinkPoint->wMainLinkId = UINT16_MAX; + pLinkPoint->wSideLinkId = UINT16_MAX; + + /* ߼ͬ */ + if (EMAP_SAME_DIR == chDir) + { + pLinkPoint->wPointType = pLinkDataTemp->wTmnlPointType; /* ȡյ˵ */ + pLinkPoint->wPointId = pLinkDataTemp->wTmnlPointId; /* ȡյ˵ */ + pLinkPoint->wMainLinkId = pLinkDataTemp->wTmnlJointMainLkId;/* ȡյLINK */ + pLinkPoint->wSideLinkId = pLinkDataTemp->wTmnlJointSideLkId;/* ȡյڲLINK */ + } + else + { + /* ߼෴ */ + pLinkPoint->wPointType = pLinkDataTemp->wOrgnPointType; /* ȡ˵ */ + pLinkPoint->wPointId = pLinkDataTemp->wOrgnPointId; /* ȡ˵ */ + pLinkPoint->wMainLinkId = pLinkDataTemp->wOrgnJointMainLkId;/* ȡLINK */ + pLinkPoint->wSideLinkId = pLinkDataTemp->wOrgnJointSideLkId;/* ȡڲLINK */ + } + + rtnValue = 1U; + } + return rtnValue; +} + +/** +* @brief ѯlinkڵλá +* @param UINT16 wLinkID +* @param UINT16 wSwitchId +* @param UINT8 *p_LinkInSW +* @return CI_ERROR:ѯʧܣCI_SUCCESS:ѯɹ +*/ +UINT8 dsuLinkofSwitPos(UINT16 wLinkID, UINT16 wSwitchId, UINT8 *p_LinkInSW) +{ + UINT8 chRtn = 0U; /*ֵ*/ + DSU_POINT_STRU * pSwitchTemp = NULL; + + if (NULL != p_LinkInSW) + { + pSwitchTemp = g_dsuEmapStru->dsuStaticHeadStru->pPointStru + g_dsuEmapStru->dsuEmapIndexStru->dsuPointIndex[wSwitchId]; + + if (NULL != pSwitchTemp) + { + if (wLinkID == pSwitchTemp->wConfluentLkId) + { + /*linkΪĻlink*/ + *p_LinkInSW = SW_LINK_CON; + } + else if (wLinkID == pSwitchTemp->wMainLkId) + { + /*linkΪĶλlink*/ + *p_LinkInSW = SW_LINK_MAIN; + } + else if (wLinkID == pSwitchTemp->wSideLkId) + { + /*linkΪķλlink*/ + *p_LinkInSW = SW_LINK_SIDE; + } + else + { + *p_LinkInSW = SW_LINK_DEFAUT; + } + chRtn = 1U; + } + else + { + ; /*ѯ󣬷*/ + } + } + else + { + ; /* ʧ */ + } + + return chRtn; +} + +/** +* @brief ȡLinkʱĵ״̬ +* @param UINT16 wSwitchID +* @param UINT16 wlinkA +* @param UINT16 wlinkB +* @param UINT8 *exSwitchStatus +* @return ʧܣCI_ERRORɹCI_SUCCESS +*/ +UINT8 dsuSwitStatusBtwLink(UINT16 wSwitchID, UINT16 wlinkA, UINT16 wlinkB, UINT8 *exSwitchStatus) +{ + UINT8 chRtn = 0U; + UINT8 linkAInSwType = SW_LINK_DEFAUT; + UINT8 linkBInSwType = SW_LINK_DEFAUT; + UINT8 chFunRtnA = 0U; + UINT8 chFunRtnB = 0U; + + /*ȡlinkڵ*/ + chFunRtnA = dsuLinkofSwitPos(wlinkA, wSwitchID, &linkAInSwType); + chFunRtnB = dsuLinkofSwitPos(wlinkB, wSwitchID, &linkBInSwType); + + if ((1U == chFunRtnA) && (1U == chFunRtnB) && (NULL != exSwitchStatus )) + { + if (((SW_LINK_CON == linkAInSwType) && (SW_LINK_MAIN == linkBInSwType)) || + ((SW_LINK_CON == linkBInSwType) && (SW_LINK_MAIN == linkAInSwType))) + { + /*õΪλ*/ + (*exSwitchStatus) = EMAP_POINT_STATUS_MAIN; + chRtn = 1U; + } + else if (((SW_LINK_CON == linkAInSwType) && (SW_LINK_SIDE == linkBInSwType)) || + ((SW_LINK_CON == linkBInSwType) && (SW_LINK_SIDE == linkAInSwType))) + { + /*õΪλ*/ + (*exSwitchStatus) = EMAP_POINT_STATUS_SIDE; + chRtn = 1U; + } + else + { + ;/*ѯ*/ + } + } + else + { + /*ѯ*/ + ; + } + return chRtn; +} + +/** +* @brief ͨյlinklinklinkϢѯlinkĵϢ +* @param UINT16 linkA +* @param UINT16 linkB +* @param UINT8 chDir +* @param IN p_StrPathLinkInfo pLinkSeq +* @param OUT p_strPointInArea pSwInfo +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +*/ +UINT8 dsuSwitInfoBtwLinkBaseLinkSeq(UINT16 linkA, UINT16 linkB, UINT8 chDir, IN PATH_LINK_STRU *pLinkSeq, OUT LOGSEC_SWITCH_STRU *pSwInfo) +{ + UINT8 chRtn = 0U; /*طֵ*/ + UINT8 chFunRtn = 0U; /*ѯֵ*/ + UINT8 chCycle = 0U; /*link*/ + UINT16 currentLinkID = UINT16_MAX; /*ǰlink*/ + UINT16 nextLinkID = UINT16_MAX; /*next link*/ + UINT8 exStatus = 0U; /*link֮ĵ״̬*/ + LINK_POINT_DATA_STRU pathTree = { 0U }; /*link˵Ϣ*/ + UINT8 chBreakRtn = 0xaau; + UINT8 cTmpIndex = 0U; + + /*ڲ*/ + if ((NULL == pLinkSeq) || (NULL == pSwInfo)) + { + /*ںǷʧ*/ + } + else if ((EMAP_SAME_DIR != chDir) && (EMAP_CONVER_DIR != chDir)) + { + /*ںǷʧ*/ + } + else if ((0U == pLinkSeq->cLinkCnt) || + (linkA != pLinkSeq->szLinkId[0]) || + (linkB != pLinkSeq->szLinkId[pLinkSeq->cLinkCnt - 1])) + { + /*linkIDյlinkIDƻյ㲻ϣںǷʧ*/ + ; + } + else + { + /*ʼϢ*/ + CommonMemSet(pSwInfo, sizeof(LOGSEC_SWITCH_STRU), 0U, sizeof(LOGSEC_SWITCH_STRU)); + + + cTmpIndex = pLinkSeq->cLinkCnt - 1u; + + + /*αеlink*/ + for (chCycle = 0U; chCycle < pLinkSeq->cLinkCnt; chCycle++) + { + /*÷ֵΪʧ*/ + chRtn = 0U; + + /*˵link*/ + currentLinkID = pLinkSeq->szLinkId[chCycle]; + /* ȡǰlink˵Ϣ */ + chFunRtn = dsuLinkPointInfo(chDir, pLinkSeq->szLinkId[chCycle], &pathTree); + + if ((chCycle == cTmpIndex) && (1U == chFunRtn)) + { + /*òѯɹ*/ + chRtn = 1U; + } + else if ((chCycle != cTmpIndex) && (1U == chFunRtn)) + { + if (EMAP_POINT_DOT == pathTree.wPointType) + { + nextLinkID = pLinkSeq->szLinkId[chCycle + 1]; + chFunRtn = dsuSwitStatusBtwLink(pathTree.wPointId, currentLinkID, nextLinkID, &exStatus); + + if (0U == chFunRtn) + { + /*ѯ󣬷*/ + chBreakRtn = 0x55u; + } + else + { + pSwInfo->SwitchId[pSwInfo->SwitchNum] = pathTree.wPointId; + pSwInfo->SwitchPosition[pSwInfo->SwitchNum] = exStatus; + pSwInfo->SwitchNum++; + } + + } + else + { + /*ѯ*/ + } + + /*òѯɹ*/ + chRtn = 1U; + } + else + { + /*ѯʧܣ*/ + chBreakRtn = 0x55u; + } + + if (0x55u == chBreakRtn) + { + chRtn = 0U; + break; + } + else + { + } + } + + if (1U == chRtn) + { + /*ѯɹ*/ + } + else + { + /*ѯɹ*/ + CommonMemSet(pSwInfo, sizeof(LOGSEC_SWITCH_STRU), 0U, sizeof(LOGSEC_SWITCH_STRU)); + } + } + + return chRtn; +} \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquQueryExp.h b/TSCP/src/dqu_common/dqu_emap_common/dquQueryExp.h new file mode 100644 index 0000000..8e19cba --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquQueryExp.h @@ -0,0 +1,364 @@ +/************************************************************************ +* +* ļ dsuQuery.h +* Ȩ˵ ؿƼƼ޹˾ +* 汾 1.0 +* ʱ 2009.11.21 +* +* dsuѯͷļ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _DSU_QUERYEXP_H +#define _DSU_QUERYEXP_H + +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "CommonTypes.h" +#include "dsuStruct.h" +#include "dquVobcCommonStru.h" + + +#define DSU_MAX_LINK_BETWEEN 400 + + +#ifdef __cplusplus +extern "C" { +#endif + +/*ATO*/ + +/*2.Ծѯ*/ +UINT8 dsuDispCalcuByLOCExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, INT32 *Displacement); + +/*ܺݵ״̬ȡǰLinkLink*/ +UINT8 dsuGetAdjacentLinkIDExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 LinkId, UCHAR Direction, UCHAR PointNum,const DQU_POINT_STATUS_STRU *pPointStru, UINT16 *pLinkId); + +/*ܺλ+λ=λ*/ +UCHAR dsuLODCalcuExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStru, INT32 Displacement, UCHAR PointNum, const DQU_POINT_STATUS_STRU *pPointStru, LOD_STRU *pNewLODStru); + +/*ܺȡ֮link*/ +UINT8 dsuGetLinkBtwLocExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, + UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], UINT16 *wLinkNumber); + +/*ܺжһǷΧ*/ +UINT8 dsuCheckLocInAreaExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU *pLODStartStru, const LOD_STRU *pLODEndStru, + UINT8 PointNum, const DQU_POINT_STATUS_STRU *pPointStru, + const LOD_STRU *pCurrentLODStru,UINT8 *pLocInArea); + +/*ܺȡlink*/ +UINT32 LinkLengthExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 wLinkID); + +/* +* ܣ ˺ĹжϵǰλǷָΧڣ˺ǶdsuCheckLocInAreaQuick + һ䡣ڽǰȡټǷڡ +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* const LOD_STRU * pCurrentLODStru,ǰλ +* UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +*/ +UINT8 dsuCheckLocInAreaQuickExp2(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT16 wLinkNumber,UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea); +/* +* ܣ ˺ĹǽжϵǰλǷָΧڡ + ˺ĹCheckLocInAreaġCheckLocInAreaԷûҪ󣬼漰ķȷġ + CheckLocInAreaQuickҪStartLODܹEndLOD +* **************************************************************************************************** +* +* --------------*--------------------*---------------------*----------------- +* S C E +* 㷨ΪжϵǰλSEǷͬһLinkϣ +* ͬһLinkϣݷλжǷڣͬһLinkжCLinkIdǷSE֮ijһLinkIdͬ +* ֮LinkԱԶڶεñѯǷڵĺЧʺа +* +* **************************************************************************************************** +* ڲ const LOD_STRU * pLODStartStru, ʼλ +* const LOD_STRU * pLODEndStru, նλ +* ڲ UINT16 wLinkID[DSU_MAX_LINK_BETWEEN] Link +* UINT16 *wLinkNumber Link +* const LOD_STRU * pCurrentLODStru,ǰλ +* ڲ UINT8 *pLocInArea 1,ָ +* 0,ָ +* ֵ 0ѯʧ +* 1ѯɹ +* ʹע⣺1.ڵǰλ˵λʱʱ¹жϣ +* 1) ǰλ㣬Ϊõڱ +* 2) ǰλյ㣬Ϊõ㲻ڱ +* 3) 3غϷڡ +* 2.ҵյ㶼ڣԵαʼնλãֻҪεһڣ˵ڵʼնγɵı +* 3.SE򲻴ڣ0ʧܡSC,SEڣ1ɹǵC +*/ +UINT8 dsuCheckLocInAreaQuickExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + UINT16 wLinkNumber,UINT16 wLinkID[DSU_MAX_LINK_BETWEEN], + const LOD_STRU * pCurrentLODStru,UINT8 *pLocInArea); +/*ܺ,ѯǰGardeGrade*/ +UINT16 FindAdjacentGradeIDExp(DSU_EMAP_STRU *pDsuEmapStru,const UINT16 wCurrentGradeID, const UCHAR chDirection, const UCHAR PointNum, const DQU_POINT_STATUS_STRU * pPointStru); + +/*¶*/ +UINT8 dsuGetGradeIdbyLocExp(DSU_EMAP_STRU *pDsuEmapStru,const UINT16 linkId,const UINT32 offset,UINT16* GradeID); +/*㵽¶ľ*/ +UINT8 dsuGetDistanceFromOriginExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 GradeId,UINT16 linkId,UINT32 Ofst,UINT32* length); +/*¶ȱµ¶ľ*/ +UINT8 dsuDividPointDistanceFromOriginExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 GradeId,UINT16 linkId,UINT32* endPointDistance,UINT32* startPointDistance); +/*¶ֵ*/ +UINT8 dsuCalculateGradeValueExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 LinkId,UINT32 ofst, FLOAT32* GradeVal); +/*¶*/ +UCHAR dsuGradientGetExp(DSU_EMAP_STRU *pDsuEmapStru,const LOD_STRU * pLODStartStru, const LOD_STRU * pLODEndStru, + const UCHAR PointNum, const DQU_POINT_STATUS_STRU * pPointStru, FLOAT32 * Gradient); +/*жϺһ¶ȵ¶ֵǰһ¶ȵ¶ֵӣ仯Ǽ */ +UINT8 dquGradeTrendExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 fistGradeID,UINT16 secondGradeID,UINT8 *GradeTrend); + +/* +ܣȡǰ¶ +UINT16 linkId,ǰlink +gradeFrnt ¶ + Null ·յǰ¶Ϊͳһ¶ + Nullǰ¶¶ȱпɲ + ֵ0ʧ 1ɹ +*/ +UINT8 dsuGetGradeFrntExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 linkId, DSU_GRADE_STRU** gradeFrnt); +/* +ܣȡ¶ +UINT16 linkId,ǰlink +gradeRear ¶ + Null ·յ¶Ϊͳһ¶ + Null¶¶ȱпɲ + ֵ0ʧ 1ɹ +*/ +UINT8 dsuGetGradeRearExp(DSU_EMAP_STRU *pDsuEmapStru,UINT16 linkId, DSU_GRADE_STRU** gradeRear); +/** +ܣȡǰLINKľ̬ٸ + +@linkIdǰlink + +ֵ̬ٸ +*/ +UINT8 GetStcLmtSpdCntByLnkIdExp(DSU_EMAP_STRU *pDsuEmapStru,DSU_STC_LIMIT_LINKIDX_STRU *pDsuLimitStcLinkIdx,const UINT16 linkId); + +/** +ܣȡƶLINKĵָ±ľ̬ʱٵĶָ + +@linkIdǰLink +@lmtSpdIdxӦLinkĵڼ٣ȡֵΧ1-10 +ֵ +@NULLȡʧ +@ǿգӦٽṹָ +*/ +DSU_STATIC_RES_SPEED_STRU *GetStcLmtSpdInfoByLnkIdExp(DSU_EMAP_STRU *pDsuEmapStru,DSU_STC_LIMIT_LINKIDX_STRU *pDsuLimitStcLinkIdx,const UINT16 linkId,const UINT8 idx); + +/* +ܣ࿪תΪ +multiPointId ࿪ + multiPointState ࿪״̬ + +wVirtualPointIds ֺ + wVirtualPointStates ֺ״̬ +ֵֵֺ, 0ʧ + +㷨࿪ NλR1λL1λR2λL2λ + Ӧе 0 1 2 3 4 + ӦĶ࿪״̬ 1 2 3 4 5 + ˵ =࿪״̬multiPointState-1 ʱӦԭֵ״̬ȡλ<=>λ + +עwVirtualPointIds״̬wVirtualPointStatesЧ״̬Ϊ3 + + / L / L + / / + / / 101 + -|------------------------ === ---|------/----------------- N + 1 \ N 102 \ + \ \ + \ \ + R R + ͼ1.ʵ ͼ2.ⵥ + + ͼ1ʵ1״̬Ϊ3ʱƳͼ2ⵥΪLλʱ101ΪЧ״̬Ϊ3ֵΪ2 + wVirtualPointIds[0]=102; + wVirtualPointStates[0]=2; + wVirtualPointIds[1]=101; + wVirtualPointStates[1]=3; +author:Ŀ add by qxt 20170622 +*/ +UINT8 ConvertToVirtualSwitchesExp(DSU_EMAP_STRU *pDsuEmapStru,const UINT16 multiPointId,const UINT8 multiPointState,UINT16 wVirtualPointIds[MAX_VIRTUAL_SWITCH_NUM],UINT8 wVirtualPointStates[MAX_VIRTUAL_SWITCH_NUM]); + +/* +ܣתΪ࿪ +wVirtualPointIds[] + wVirtualPointStates[] ״̬ + wVirtualPointNum +multiPointId Ӧ࿪ + multiPointState Ӧ࿪״̬ +ֵ0ʧ 1ɹ + +עwVirtualPointIds״̬wVirtualPointStatesЧҪ롣 + + /L L + / / + / / + / / + ---|------/-----------\------ N =====> ------------------ N + 1 2 \ \ + \ \ + R R + ͼ1.ⵥ ͼ2.ʵ + + ͼ11״̬Ϊ2ʱƳͼ2࿪״̬ΪLλʱͼһ2ΪЧģΪ£ + wVirtualPointIds[0]=1; + wVirtualPointStates[0]=2; + wVirtualPointNum=1; +author:Ŀ add by qxt 20170622 +*/ +UINT8 ConvertToMultiSwitchExp(DSU_EMAP_STRU *pDsuEmapStru,const UINT16 wVirtualPointIds[MAX_VIRTUAL_SWITCH_NUM],const UINT8 wVirtualPointStates[MAX_VIRTUAL_SWITCH_NUM],const UINT8 wVirtualPointNum,UINT16 *multiPointId,UINT8 *multiPointState); + +/********************************************************************************************** +/********************************************************************************************** +*:ݼе·յlinkһlink֧Ϊ·(ӿ) +*: pDsuEmapStru +* szLinkQueryDir linkѯ +* pPathNum · +* szPath · +* szLinkNum ÿ·ij +*: pPathNum · +* szPath · +* szLinkNum ÿ·ij +*ֵ:0:ʧ 1:ѯɹҸ·δյ 2ѯɹҸ·յ +*ע add by lxc 2021-2-28 +*޸ģby yt 2021911 ɾ +**********************************************************************************************/ +UINT8 dsuPathEndNextLinkExp(DSU_EMAP_STRU* pDsuEmapStru, UINT8 szLinkQueryDir[50], UINT8* pPathNum, UINT16 szPath[50][50], UINT16 szLinkNum[50]); + +/********************************************************************************************* +*:ж·յǷΪͬһlinkΪͬһlink·(ͨӿ) +*: cPathANum A· + szPathA A· + szLinkANum A·link + cPathBNum B· + szPathB B· + szLinkBNum B·link + cABPathDir A/B·IJѯ +*: szPath ҵ· + pPathLinkNum ҵ· + pLinkDirChangedNum linkеķ仯 +*ֵ:յͬlink:0 +յͬlink:1 +*ע add by lxc 2021-2-28 +*********************************************************************************************/ +UINT8 dsuPathSameEndLinkExp(UINT8 cPathANum, UINT16 szPathA[50][50], UINT16 szLinkANum[50], UINT8 cPathBNum + , UINT16 szPathB[50][50], UINT16 szLinkBNum[50], UINT16 szPath[100], UINT16* pPathLinkNum, UINT8* pLinkDirChangedNum, UINT8 cABPathDir, DSU_EMAP_STRU *pDsuEmapStru); + +/************************************************ +*:ѯAB֮ľ +*: pDsuEmapStru ӵͼ +* pLODAStru A +* pLODBStru B +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +* pLinkDirChangedNum 仯 +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2021-2-28 +************************************************/ +UINT32 dsuLenByPointExp(DSU_EMAP_STRU* pDsuEmapStru, const LOD_STRU* pLODAStru, const LOD_STRU* pLODBStru, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8* pDir, UINT8* pLinkDirChangedNum); + +/********************************************************************************************** +*:ݼе·յλlinkһlink(ӿ) +*: pDsuEmapStru +* cDir ѯ +* szPath · +* pLinkNum ·ij +* wSwitchSum +* pSwitchInfo ״̬ +*: szPath · +* pLinkNum ·ij +*ֵ:0:ʧ 1:ѯɹҸ·δյ 2ѯɹҸ·յ +*ע add by lxc 2022-6-17 +**********************************************************************************************/ +UINT8 dsuPathEndNextLinkBySwitchStateExp(DSU_EMAP_STRU *pDsuEmapStru, UINT8 cDir, UINT16 szPath[50], UINT16 *pLinkNum, const UINT8 cSwitchSum, const DQU_POINT_STATUS_STRU *pSwitchInfo); + +/********************************************************************************************* +*:ж·յǷΪͬһlinkΪͬһlink·(ͨӿ) +*: +*szPathA A· +*szLinkANum A·link +*szPathB B· +*szLinkBNum B·link +*: szPath ҵ· +*pPathLinkNum ҵ· +*ֵ:յͬlink:0 +*յͬlink:1 +*ע add by lxc 2022-6-17 +*********************************************************************************************/ +UINT8 dsuLinkBufSameEndLinkExp(UINT16 szPathA[50], UINT16 wLinkANum, UINT16 szPathB[50], UINT16 wLinkBNum, UINT16 szPath[100], UINT16* pPathLinkNum); + +/************************************************ +*:ѯAB֮ľ룬ݵʵλò +*: pDsuEmapStru ӵͼ +* pLODAStru A +* pLODBStru B +* cSwitchSum +* pSwitchInfo Ϣ +*: pLinkNum ·link +* szLinkId ·linkId +* pDir A->Bķ +*ֵ:ʧ:DSU_NULL_32 +* ɹ: +*ע add by lxc 2022-6-17 +************************************************/ +UINT32 dsuLenByPointBySwitchStateExp(DSU_EMAP_STRU *pDsuEmapStru, const LOD_STRU *pLODAStru, const LOD_STRU *pLODBStru, const UINT8 cSwitchSum, const DQU_POINT_STATUS_STRU *pSwitchInfo, UINT16* pLinkNum, UINT16 szLinkId[100], UINT8 *pDir); + +/** +* @brief ȡLINK˵Ϣ +* @param chDir +* @param wLinkId LINK +* @param pLinkPoint ˵Ϣ +* @return CI_SUCCESS:ɹCI_ERROR:ʧ +*/ +UINT8 dsuLinkPointInfo(UINT8 chDir, UINT16 wLinkId, LINK_POINT_DATA_STRU *pLinkPoint); + +/** +* @brief ѯlinkڵλá +* @param UINT16 wLinkID +* @param UINT16 wSwitchId +* @param UINT8 *p_LinkInSW +* @return CI_ERROR:ѯʧܣCI_SUCCESS:ѯɹ +*/ +UINT8 dsuLinkofSwitPos(UINT16 wLinkID, UINT16 wSwitchId, UINT8 *p_LinkInSW); + +/** +* @brief ȡLinkʱĵ״̬ +* @param UINT16 wSwitchID +* @param UINT16 wlinkA +* @param UINT16 wlinkB +* @param UINT8 *exSwitchStatus +* @return ʧܣCI_ERRORɹCI_SUCCESS +*/ +UINT8 dsuSwitStatusBtwLink(UINT16 wSwitchID, UINT16 wlinkA, UINT16 wlinkB, UINT8 *exSwitchStatus); + +/** +* @brief ͨյlinklinklinkϢѯlinkĵϢ +* @param UINT16 linkA +* @param UINT16 linkB +* @param UINT8 chDir +* @param IN p_StrPathLinkInfo pLinkSeq +* @param OUT p_strPointInArea pSwInfo +* @return CI_ERROR:ʧܣCI_SUCCESS:ɹ +*/ +UINT8 dsuSwitInfoBtwLinkBaseLinkSeq(UINT16 linkA, UINT16 linkB, UINT8 chDir, IN PATH_LINK_STRU *pLinkSeq, OUT LOGSEC_SWITCH_STRU *pSwInfo); +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquStructInit.c b/TSCP/src/dqu_common/dqu_emap_common/dquStructInit.c new file mode 100644 index 0000000..8baba03 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquStructInit.c @@ -0,0 +1,4567 @@ +/************************************************************************ +* +* ļ dquStructInit.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2009.11.21 +* +* ݲѯṹ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#include +#include "dquStructInit.h" +#include "dquCbtcType.h" + + +static UINT8 ROUTE_STRU_init_HLT(UINT8 * pDataAdd,DSU_ROUTE_STRU * pRouteStru); + +/************************************** +ܣlinkṹʼ +˵[in] pData ݵַļ + [out] pLinkStrc ʼĽṹָ +ֵ0ʧܣ 1ɹ +עṹѾ +***************************/ +static UINT8 LINK_STRU_init_DFT(UINT8 * pDataAdd,DSU_LINK_STRU* pLinkStrc) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pLinkStrc)) { + UINT8 * pData = pDataAdd; + /*link*/ + pLinkStrc->wId = ShortFromChar(pData); + pData += 2; + + /*linkȣcm*/ + pLinkStrc->dwLength = LongFromChar(pData); + pData += 4; + + /*Link·Ϣ*/ /*---Ϲѧ*/ + pLinkStrc->wLinkLine = ShortFromChar(pData); + pData += 2; + + /*link˵*/ + pLinkStrc->wOrgnPointType = ShortFromChar(pData); + pData += 2; + + /*link˵*/ + pLinkStrc->wOrgnPointId = ShortFromChar(pData); + pData += 2; + + /*linkӵlink*/ + pLinkStrc->wOrgnJointMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkӵڲlink*/ + pLinkStrc->wOrgnJointSideLkId = ShortFromChar(pData); + pData += 2; + + /*linkյ˵*/ + pLinkStrc->wTmnlPointType = ShortFromChar(pData); + pData += 2; + + /*linkյ˵*/ + pLinkStrc->wTmnlPointId = ShortFromChar(pData); + pData += 2; + + /*linkյӵlink*/ + pLinkStrc->wTmnlJointMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkյӵڲlink*/ + pLinkStrc->wTmnlJointSideLkId = ShortFromChar(pData); + pData += 2; + + /*ZC*/ + pLinkStrc->wManageZC = ShortFromChar(pData); + pData += 2; + + /*ATS*/ + pLinkStrc->wManageATS = ShortFromChar(pData); + pData += 2; + + /*߼CI*/ + pLinkStrc->wManageLogicCI = ShortFromChar(pData); + pData += 2; + + /*CI*/ /*----ȷΪ2ֽ---*/ + pLinkStrc->wManagePhysicalCI = ShortFromChar(pData); + pData += 2; + + /*LinkϢ*/ + pLinkStrc->wLinkResSpeed = ShortFromChar(pData); + pData += 2; + + /*Link¶Ϣ*/ + pLinkStrc->wGrade = ShortFromChar(pData); + pData += 2; + + /*LinkվID:2013813,ɳɾ; + pLinkStrc->wStationArea = ShortFromChar(pData); + pData += 2;*/ + + pLinkStrc->wLogicDir = pLinkStrc->wLinkLine; + rtnValue = 1; + } + return rtnValue; +} + + +/************************************************************************** +* : Linkݽṹʼ(ͨ) +* : UINT8 *pDataAdd link׵ַ +* : +* : DSU_LINK_STRU *pLinkStrc linkϢ +* ȫֱ: ޡ +* ֵ: 0ʧܣ1ɹ +* ޸ļ¼: +* 1linkPSCϢʼ(ͨݽṹV20.0.0) m by sds 2020-8-18 +**************************************************************************/ +static UINT8 LINK_STRU_init_HLT(UINT8 *pDataAdd, DSU_LINK_STRU *pLinkStrc) +{ + UINT8 rtnValue = 0U; + UINT8 *pData = NULL; + /*ָ*/ + if((NULL != pDataAdd) && (NULL != pLinkStrc)) + { + + pData = pDataAdd; + + /*link*/ + pLinkStrc->wId = ShortFromChar(pData); + pData += 2; + + /*linkȣcm*/ + pLinkStrc->dwLength = LongFromChar(pData); + pData += 4; + + /*Link·Ϣ*/ /*---Ϲѧ*/ + pLinkStrc->wLinkLine = ShortFromChar(pData); + pData += 2; + + /*link˵*/ + pLinkStrc->wOrgnPointType = ShortFromChar(pData); + pData += 2; + + /*link˵*/ + pLinkStrc->wOrgnPointId = ShortFromChar(pData); + pData += 2; + + /*linkӵlink*/ + pLinkStrc->wOrgnJointMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkӵڲlink*/ + pLinkStrc->wOrgnJointSideLkId = ShortFromChar(pData); + pData += 2; + + /*linkյ˵*/ + pLinkStrc->wTmnlPointType = ShortFromChar(pData); + pData += 2; + + /*linkյ˵*/ + pLinkStrc->wTmnlPointId = ShortFromChar(pData); + pData += 2; + + /*linkյӵlink*/ + pLinkStrc->wTmnlJointMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkյӵڲlink*/ + pLinkStrc->wTmnlJointSideLkId = ShortFromChar(pData); + pData += 2; + + /*ZC*/ + pLinkStrc->wManageZC = ShortFromChar(pData); + pData += 2; + + /*ATS*/ + pLinkStrc->wManageStation = ShortFromChar(pData); + pData += 2; + + /*߼CI*/ + pLinkStrc->wManageLogicCI = ShortFromChar(pData); + pData += 2; + + /*CI*/ /*----ȷΪ2ֽ---*/ + pLinkStrc->wManagePhysicalCI = ShortFromChar(pData); + pData += 2; + + /*LinkϢ*/ + pLinkStrc->wLinkResSpeed = ShortFromChar(pData); + pData += 2; + + /*Link¶Ϣ*/ + pLinkStrc->wGrade = ShortFromChar(pData); + pData += 2; + + pLinkStrc->wLogicDir = pLinkStrc->wLinkLine; + + pLinkStrc->wManageATS = ShortFromChar(pData); + pData += 2; + + pLinkStrc->wLinkLogicDirUpAndDown = *pData; /*ͨϵͳ߼зĹϵ add by qxt 20160811*/ + pData++; + + pLinkStrc->wLogicDirChanged = *pData; /*߼仯㣬⣬ add by qxt 20170816*/ + pData++; + + pLinkStrc->wTunAttribute = *pData; /*LinkԣݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + pData++; + + pLinkStrc->wManagePSCID = ShortFromChar(pData); /*PSC*/ + pData += 2; + + pLinkStrc->wBelongVirtualCI = ShortFromChar(pData); /**/ + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +static UINT8 LINK_STRU_init_DG(UINT8 * pDataAdd,DSU_LINK_STRU* pLinkStrc) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pLinkStrc)) + { + UINT8 * pData = pDataAdd; + /*link*/ + pLinkStrc->wId = ShortFromChar(pData); + pData += 2; + + /*linkȣcm*/ + pLinkStrc->dwLength = LongFromChar(pData); + pData += 4; + + /*Link·Ϣ*/ /*---Ϲѧ*/ + pLinkStrc->wLinkLine = ShortFromChar(pData); + pData += 2; + + /*link˵*/ + pLinkStrc->wOrgnPointType = ShortFromChar(pData); + pData += 2; + + /*link˵*/ + pLinkStrc->wOrgnPointId = ShortFromChar(pData); + pData += 2; + + /*linkӵlink*/ + pLinkStrc->wOrgnJointMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkӵڲlink*/ + pLinkStrc->wOrgnJointSideLkId = ShortFromChar(pData); + pData += 2; + + /*linkյ˵*/ + pLinkStrc->wTmnlPointType = ShortFromChar(pData); + pData += 2; + + /*linkյ˵*/ + pLinkStrc->wTmnlPointId = ShortFromChar(pData); + pData += 2; + + /*linkյӵlink*/ + pLinkStrc->wTmnlJointMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkյӵڲlink*/ + pLinkStrc->wTmnlJointSideLkId = ShortFromChar(pData); + pData += 2; + + /*ZC*/ + pLinkStrc->wManageZC = ShortFromChar(pData); + pData += 2; + + /*ATS*/ + pLinkStrc->wManageStation = ShortFromChar(pData); + pData += 2; + + /*߼CI*/ + pLinkStrc->wManageLogicCI = ShortFromChar(pData); + pData += 2; + + /*CI*/ /*----ȷΪ2ֽ---*/ + pLinkStrc->wManagePhysicalCI = ShortFromChar(pData); + pData += 2; + + /*LinkϢ*/ + pLinkStrc->wLinkResSpeed = ShortFromChar(pData); + pData += 2; + + /*Link¶Ϣ*/ + pLinkStrc->wGrade = ShortFromChar(pData); + pData += 2; + + /*LinkվID:2013813,ɳɾ; + pLinkStrc->wStationArea = ShortFromChar(pData); + pData += 2;*/ + + pLinkStrc->wLogicDir = pLinkStrc->wLinkLine; + + + pLinkStrc->wManageATS = ShortFromChar(pData); + pData += 2; + + pLinkStrc->wLinkLogicDirUpAndDown = *pData; /*ͨϵͳ߼зĹϵ add by qxt 20160811*/ + pData++; + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣlinkṹʼ- add by sds 2019-6-13 +˵[in] pData ݵַļ +[out] pLinkStrc ʼĽṹָ +ֵ0ʧܣ1ɹ +עṹѾ +***************************/ +static UINT8 LINK_STRU_init_CC(UINT8 * pDataAdd, DSU_LINK_STRU* pLinkStrc) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pLinkStrc)) + { + UINT8 * pData = pDataAdd; + /*link*/ + pLinkStrc->wId = ShortFromChar(pData); + pData += 2; + + /*linkȣcm*/ + pLinkStrc->dwLength = LongFromChar(pData); + pData += 4; + + /*Link·Ϣ*/ + pLinkStrc->wLinkLine = ShortFromChar(pData); + pData += 2; + + /*link˵*/ + pLinkStrc->wOrgnPointType = ShortFromChar(pData); + pData += 2; + + /*link˵*/ + pLinkStrc->wOrgnPointId = ShortFromChar(pData); + pData += 2; + + /*linkӵlink*/ + pLinkStrc->wOrgnJointMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkӵڲlink*/ + pLinkStrc->wOrgnJointSideLkId = ShortFromChar(pData); + pData += 2; + + /*linkյ˵*/ + pLinkStrc->wTmnlPointType = ShortFromChar(pData); + pData += 2; + + /*linkյ˵*/ + pLinkStrc->wTmnlPointId = ShortFromChar(pData); + pData += 2; + + /*linkյӵlink*/ + pLinkStrc->wTmnlJointMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkյӵڲlink*/ + pLinkStrc->wTmnlJointSideLkId = ShortFromChar(pData); + pData += 2; + + /*ZC*/ + pLinkStrc->wManageZC = ShortFromChar(pData); + pData += 2; + +#if 0 + /*ATS*/ + pLinkStrc->wManageStation = ShortFromChar(pData); + pData += 2; + + /*߼CI*/ + pLinkStrc->wManageLogicCI = ShortFromChar(pData); + pData += 2; +#endif + + /*RCI*/ + pLinkStrc->wManagePhysicalCI = ShortFromChar(pData); + pData += 2; +#if 0 + /*LinkϢ*/ + pLinkStrc->wLinkResSpeed = ShortFromChar(pData); + pData += 2; + + /*Link¶Ϣ*/ + pLinkStrc->wGrade = ShortFromChar(pData); + pData += 2; +#endif + + /*ATS*/ + pLinkStrc->wManageATS = ShortFromChar(pData); + pData += 2; + + /*ϵͳ߼зĹϵ*/ + pLinkStrc->wLinkLogicDirUpAndDown = *pData; + pData += 1; + + /*Link߼仯*/ + pLinkStrc->wLogicDirChanged = *pData; + pData += 1; + + /*Link*/ + pLinkStrc->wTunAttribute = *pData; + pData += 1; + + /*PSC*/ + pLinkStrc->wManagePSCID = ShortFromChar(pData); /*PSC*/ + pData += 2; + +#if 0 + /*Žŷʽ*/ + pLinkStrc->wKsDoorUnlock = *pData; + pData += 1; +#endif + + pLinkStrc->wBelongVirtualCI = ShortFromChar(pData); /**/ + pData += 2; + + + /*Link*/ + pLinkStrc->wLinxian = *pData; + pData += 1; + + + /*ѹ켰ɢ·*/ + pLinkStrc->wLinkTG_EvacuateDir = *pData; + pData += 1; + + /*CBTC*/ + pLinkStrc->cCbtcProperty = *pData; + pData += 1; + + rtnValue = 1; + } + return rtnValue; +} + +/*ýӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +/*޸ķֵΪUINT8 ʵָֿ*/ +/*ֵ0ʧܣ1ɹ*/ +UINT8 LINK_STRU_init(UINT8 *pDataAdd, DSU_LINK_STRU *pLinkStrc) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType) || (DQU_CBTC_CPK == cbtcVersionType) ) + { + rtnValue = LINK_STRU_init_DFT(pDataAdd, pLinkStrc); + } + /*cgh 202212.21޸ģĿ־3Ŀ־5ʹóѯ*/ + else if ((DQU_CBTC_HLT == cbtcVersionType) || (DQU_CBTC_CC == cbtcVersionType)) + { + rtnValue = LINK_STRU_init_CC(pDataAdd, pLinkStrc); + /*rtnValue = LINK_STRU_init_HLT(pDataAdd, pLinkStrc);*/ + } + else if(DQU_CBTC_DG == cbtcVersionType) + { + rtnValue = LINK_STRU_init_DG(pDataAdd, pLinkStrc); + } +#if 0 + else if (DQU_CBTC_CC == cbtcVersionType) + { + rtnValue = LINK_STRU_init_CC(pDataAdd, pLinkStrc); + } +#endif + else + { + /*ɴ֧*/ + } + return rtnValue; +} + +/************************************** +ܣݽṹʼ +˵[in] pData ݵַļ + [out]pPointStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wManageZC; ZC + UINT16 wManagePhysicalCI; CI + UINT16 wManageLogicCI; ߼CI +޸˵ݺϿݽṹV19.0.0޸ģ20180208 lmy +mod by qw.liu 䳵ݽṹ +***************************/ +UINT8 POINT_STRU_init(UINT8 *pDataAdd,DSU_POINT_STRU *pPointStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPointStru)) + { + UINT8 *pData = pDataAdd; + UINT8 i = 0; + /**/ + pPointStru->wId = ShortFromChar(pData); + pData += 2; + + /**/ + for (i = 0; i<16; i++) + { + pPointStru->szCaption[i] = *pData; + pData++; + } + + /**/ + pPointStru->DPointOtherId = ShortFromChar(pData); + pData += 2; + + /*㹫*/ + pPointStru->dwPointKilo = LongFromChar(pData); + pData += 4; + + /*link*/ + pPointStru->wMainLkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ(cm)*/ + pPointStru->dwMainLkOfst = LongFromChar(pData); + pData += 4; + + /*link*/ + pPointStru->wSideLkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ(cm)*/ + pPointStru->dwSideLkOfst = LongFromChar(pData); + pData += 4; + + /*link*/ + pPointStru->wConfluentLkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ(cm)*/ + pPointStru->dwConfluentLkOfst = LongFromChar(pData); + pData += 4; +#if 0 + /*λ̬ٶ(cm/s)*/ + pPointStru->wSideResSpeed = ShortFromChar(pData); + pData += 2; +#endif + + /*ű*/ + pPointStru->dwPointKiloPlueMinusSign = *pData; + pData += 1; + + rtnValue = 1; + + } + return rtnValue; +} + +/************************************** +ܣźŻݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pSignalStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עĿ + UINT16 wManageZC; ZC + UINT16 wManagePhysicalCI; CI + UINT16 wManageLogicCI; ߼CI +** ݳݽṹ޸ +1.ɾźŻ +2.ӹźŻID +3.ɾźŻڱ־ +4.ɾźŻжϴźŹܱ־ +mod by qw.liu 2022-02-22 +***************************/ +UINT8 SIGNAL_STRU_init(UINT8 * pDataAdd,DSU_SIGNAL_STRU * pSignalStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pSignalStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + /**/ + pSignalStru->wId = ShortFromChar(pData); + pData += 2; + + /*źŻ*/ + + for (i = 0; i < 12; i++) + { + pSignalStru->szCaption[i] = *pData; + pData += 1; + } +#if 0 + /*źŻ*/ + pSignalStru->wType = ShortFromChar(pData); + pData += 2; +#endif + + /*źŻ*/ + pSignalStru->wAttribute = ShortFromChar(pData); + pData += 2; + + /**/ + pSignalStru->wProtectDir = ShortFromChar(pData); + pData += 2; + + /*źŻlink*/ + pSignalStru->wProtectLinkId = ShortFromChar(pData); + pData += 2; + + /*źŻlinkƫ(cm)*/ + pSignalStru->dwProtectLinkOfst = LongFromChar(pData); + pData += 4; + + +#if 0 + /*źŻ־*/ + + pSignalStru->wPassSignal = ShortFromChar(pData); + pData += 2; + + /*źŻжϴźŹܱ־*/ + pSignalStru->wEnableSignal = ShortFromChar(pData); + pData += 2; +#endif + + /*źŻܱ־*/ + pSignalStru->wShineSignal = ShortFromChar(pData); + pData += 2; + + /*źŻ*/ + pSignalStru->dwSignalDengLie = LongFromChar(pData); + pData += 4; + + /*źŻλ*/ + pSignalStru->sDengWeiFengBi = *pData; + pData++; + + pSignalStru->wRelatedMainSignalId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣӦݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pBaliseStru ʼĽṹָ +ֵ0ʧܣ1ɹ +עýṹĶ +***************************/ +/*Ĭϰ汾ӦΪ10*/ +static UINT8 BALISE_STRU_init_DFT(UINT8 * pDataAdd,DSU_BALISE_STRU * pBaliseStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pBaliseStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + + /**/ + pBaliseStru->wId = ShortFromChar(pData); + pData += 2; + + /*ӦID*/ + pBaliseStru->dwBaliseId = LongFromChar(pData); + pData += 4; + + /*Ӧ*/ + for (i = 0; i < 8; i++) + { + pBaliseStru->szCaption[i] = *pData; + pData += 1; + } + + /*Ӧlink*/ + pBaliseStru->wLkId = ShortFromChar(pData); + pData += 2; + + /*Ӧlinkƫ(cm)*/ + pBaliseStru->dwLkOfst = LongFromChar(pData); + pData += 4; + + /*ӦźŻ*/ + pBaliseStru->wRelateSignalID = ShortFromChar(pData); + pData += 2; + + /*Ӧ÷()*/ + pBaliseStru->wBaliseDir = ShortFromChar(pData); + pData += 2; + + /*Ӧ*/ + pBaliseStru->wBaliseType = ShortFromChar(pData); + pData += 2; + + /*link߼ڵӦ*/ + pBaliseStru->wOrgnBaliseNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i < 10; i++) + { + /*link߼ڵӦı*/ + pBaliseStru->dwOrgnBaliseId[i] = LongFromChar(pData); + pData += 4; + + /*·㷽뱾ӦҶгЧֱӵӦ·ϣгӦپӦʱķ*/ + pBaliseStru->wPassOrgnBaliseDir[i] = ShortFromChar(pData); + pData += 2; + + /*link߼ڵӦľ*/ + pBaliseStru->dwDistanceToOrgnBalise[i] = LongFromChar(pData); + pData += 4; + + /*Ӧ*/ + pBaliseStru->wOrgnRelatePointID[i] = ShortFromChar(pData); + pData += 2; + + /*Ӧ״̬*/ + pBaliseStru->wOrgnRelatePointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*link߼յڵӦ*/ + pBaliseStru->wTmnlBaliseNum = ShortFromChar(pData); + pData += 2; + + /*link߼յڵӦı*/ + for (i = 0; i < 10; i++) + { + pBaliseStru->dwTmnlBaliseId[i] = LongFromChar(pData); + pData += 4; + + /*·յ㷽뱾ӦҶгЧֱӵӦ·ϣгӦپӦʱķ*/ + pBaliseStru->wPassTmnlBaliseDir[i] = ShortFromChar(pData); + pData += 2; + + /*link߼յڵӦľ*/ + pBaliseStru->dwDistanceToTmnlBalise[i] = LongFromChar(pData); + pData += 4; + + /*յӦ*/ + pBaliseStru->wTmnlRelatePointID[i] = ShortFromChar(pData); + pData += 2; + + /*յӦ״̬*/ + + pBaliseStru->wTmnlRelatePointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*LEU*/ + pBaliseStru->wLeuId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} +/*ͨ汾Ӧӵ16*/ +static UINT8 BALISE_STRU_init_HLT(UINT8 * pDataAdd,DSU_BALISE_STRU * pBaliseStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pBaliseStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + + /**/ + pBaliseStru->wId = ShortFromChar(pData); + pData += 2; + + /*ӦID*/ + pBaliseStru->dwBaliseId = LongFromChar(pData); + pData += 4; + + /*Ӧ*/ + for (i = 0; i < 8; i++) + { + pBaliseStru->szCaption[i] = *pData; + pData += 1; + } + + /*Ӧlink*/ + pBaliseStru->wLkId = ShortFromChar(pData); + pData += 2; + + /*Ӧlinkƫ(cm)*/ + pBaliseStru->dwLkOfst = LongFromChar(pData); + pData += 4; + + /*ӦźŻ*/ + pBaliseStru->wRelateSignalID = ShortFromChar(pData); + pData += 2; + + /*Ӧ÷()*/ + pBaliseStru->wBaliseDir = ShortFromChar(pData); + pData += 2; + + /*Ӧ*/ + pBaliseStru->wBaliseType = ShortFromChar(pData); + pData += 2; + + /*link߼ڵӦ*/ + pBaliseStru->wOrgnBaliseNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i < 16; i++) + { + /*link߼ڵӦı*/ + pBaliseStru->dwOrgnBaliseId[i] = LongFromChar(pData); + pData += 4; + + /*·㷽뱾ӦҶгЧֱӵӦ·ϣгӦپӦʱķ*/ + pBaliseStru->wPassOrgnBaliseDir[i] = ShortFromChar(pData); + pData += 2; + + /*link߼ڵӦľ*/ + pBaliseStru->dwDistanceToOrgnBalise[i] = LongFromChar(pData); + pData += 4; + + /*Ӧ*/ + pBaliseStru->wOrgnRelatePointID[i] = ShortFromChar(pData); + pData += 2; + + /*Ӧ״̬*/ + pBaliseStru->wOrgnRelatePointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*link߼յڵӦ*/ + pBaliseStru->wTmnlBaliseNum = ShortFromChar(pData); + pData += 2; + + /*link߼յڵӦı*/ + for (i = 0; i < 16; i++) + { + pBaliseStru->dwTmnlBaliseId[i] = LongFromChar(pData); + pData += 4; + + /*·յ㷽뱾ӦҶгЧֱӵӦ·ϣгӦپӦʱķ*/ + pBaliseStru->wPassTmnlBaliseDir[i] = ShortFromChar(pData); + pData += 2; + + /*link߼յڵӦľ*/ + pBaliseStru->dwDistanceToTmnlBalise[i] = LongFromChar(pData); + pData += 4; + + /*յӦ*/ + pBaliseStru->wTmnlRelatePointID[i] = ShortFromChar(pData); + pData += 2; + + /*յӦ״̬*/ + + pBaliseStru->wTmnlRelatePointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*LEU*/ + pBaliseStru->wLeuId = ShortFromChar(pData); + pData += 2; + + /*ӵͼ汾Ϣ---ݻͨ by hgj 20150507*/ + pBaliseStru->wEmapVersion = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +/*ýӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +/*޸ķֵΪUINT8 ʵָֿ*/ +/*ֵ0ʧܣ1ɹ*/ +UINT8 BALISE_STRU_init(UINT8 *pDataAdd,DSU_BALISE_STRU *pBaliseStru) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType)||(DQU_CBTC_CPK == cbtcVersionType) ) + { + rtnValue = BALISE_STRU_init_DFT(pDataAdd, pBaliseStru);/*FAOͺϿ⹲õĴ*/ + } + else if ((DQU_CBTC_HLT == cbtcVersionType)||(DQU_CBTC_DG == cbtcVersionType)) + { + rtnValue = BALISE_STRU_init_HLT(pDataAdd, pBaliseStru);/*ͨĴ*/ + } + else + { + /*ɴ֧*/ + } + return rtnValue; +} + +/************************************** +ܣݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pAxleStru ʼĽṹָ +ֵ0ʧܣ1ɹ +עýṹĶ +޸˵ݺϿݽṹV19.0.0޸ģ20180208 lmy +***************************/ +UINT8 AXLE_STRU_init(UINT8 *pDataAdd,DSU_AXLE_STRU *pAxleStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pAxleStru)) + { + UINT8 *pData = pDataAdd; + UINT8 i = 0; + + /**/ + pAxleStru->wId = ShortFromChar(pData); + pData += 2; + + /**/ + for (i = 0; i<16; i++) + { + pAxleStru->szCaption[i] = *pData; + pData += 1; + } + + /*Ϣ*/ + pAxleStru->wType = ShortFromChar(pData); + pData += 2; + + /**/ + pAxleStru->dwAxleKilo = LongFromChar(pData); + pData += 4; + + /*link*/ + pAxleStru->wLkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ(cm)*/ + pAxleStru->dwLkOfst = LongFromChar(pData); + pData += 4; + + /*ű־*/ + pAxleStru->dwAxleKiloPlueMinusSign = *pData; + pData += 1; + + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣȫݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pScreenStru ʼĽṹָ +ֵ0ʧܣ1ɹ +עṹ + UINT16 wManageLogicCI; ߼CI +**ݽṹ ɾͣ mod by qw.liu 2022-02-22 +***************************/ +UINT8 SCREEN_STRU_init(UINT8 * pDataAdd,DSU_SCREEN_STRU * pScreenStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pScreenStru)) + { + UINT8 * pData = pDataAdd; + pScreenStru->wId = ShortFromChar(pData); + pData += 2; + +#if 0 + pScreenStru->wLocalPlatformId = ShortFromChar(pData); + pData += 2; +#endif + pScreenStru->wRelatLkId = ShortFromChar(pData); + pData += 2; + + pScreenStru->wwRelatLkOrient = ShortFromChar(pData); + pData += 2; + + pScreenStru->wVobcCiID = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣͣťݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pEmergStopStru ʼĽṹָ +ֵ0ʧܣ1ɹ +עṹ + UINT16 wManageLogicCI; ߼CI +**ݽṹ ɾͣ mode by qw.liu 2022-02-22 +***************************/ +UINT8 EMERG_STOP_STRU_init(UINT8 * pDataAdd,DSU_EMERG_STOP_STRU * pEmergStopStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pEmergStopStru)) + { + UINT8 * pData = pDataAdd; + pEmergStopStru->wId = ShortFromChar(pData); + pData += 2; + +#if 0 + pEmergStopStru->wLocalPlatformId = ShortFromChar(pData); + pData += 2; +#endif + + pEmergStopStru->wRelatLkId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣͣϢݽṹʼ(ԭվ̨) +˵[in] pDataAdd ݵַļ + [out] pStationStru ʼĽṹָ +ֵ0ʧܣ1ɹ +עṹ + UINT32 dwStatTmnlLinkOfst; վ̨Χֹlinkƫ + UINT16 wManagePhysicalCI CI + UINT16 wManageLogicCI; ߼CI +***************************/ +static UINT8 STATION_STRU_init_DFT(UINT8 * pDataAdd,DSU_STATION_STRU * pStationStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if((NULL != pDataAdd) && (NULL != pStationStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0U; + pStationStru->wId = ShortFromChar(pData); + pData += 2U; + + for (i = 0U; i<20U; i++) + { + pStationStru->szCaption[i] = *pData; + pData += 1U; + } + /*Ŀĵر*/ + for (i = 0U; i<4U; i++) + { + pStationStru->bDesId[i] = *pData; + pData += 1U; + } + + pStationStru->wLinkId = ShortFromChar(pData); + pData += 2U; + + pStationStru->dwAttribute = LongFromChar(pData); + pData += 4U; + + pStationStru->wMinParkTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wMaxParkTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wParkTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wScreenNum = ShortFromChar(pData); + pData += 2U; + + for (i = 0U; i<2U; i++) + { + pStationStru->wScreenId[i] = ShortFromChar(pData); + pData += 2U; + } + + pStationStru->wEmergStopNum = ShortFromChar(pData); + pData += 2U; + + for (i = 0U; i<2U; i++) + { + pStationStru->wEmergStopId[i] = ShortFromChar(pData); + pData += 2U; + } + + pStationStru->wStopPointNum = ShortFromChar(pData); + pData += 2U; + + for (i = 0U; i<3U; i++) + { + pStationStru->wStopPointID[i] = ShortFromChar(pData); + pData += 2U; + } + + pStationStru->wDoorOpenMode = ShortFromChar(pData); + pData += 2U; + + pStationStru->wDoorOpenTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wDoorCloseMode = ShortFromChar(pData); + pData += 2U; + + pStationStru->wDoorCloseTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wParkSteadyTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wStationID = ShortFromChar(pData); /*2013813,ɳ*/ + pData += 2U; + + rtnValue = 1; + } + return rtnValue; +} + +static UINT8 STATION_STRU_init_HLT(UINT8 * pDataAdd, DSU_STATION_STRU * pStationStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pStationStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0U; + pStationStru->wId = ShortFromChar(pData); + pData += 2U; + + for (i = 0U; i<20U; i++) + { + pStationStru->szCaption[i] = *pData; + pData += 1U; + } + /*Ŀĵر*/ + for (i = 0U; i<4U; i++) + { + pStationStru->bDesId[i] = *pData; + pData += 1U; + } + + pStationStru->wLinkId = ShortFromChar(pData); + pData += 2U; + + pStationStru->dwAttribute = LongFromChar(pData); + pData += 4U; + + pStationStru->wMinParkTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wMaxParkTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wParkTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wScreenNum = ShortFromChar(pData); + pData += 2U; + + for (i = 0U; i<2U; i++) + { + pStationStru->wScreenId[i] = ShortFromChar(pData); + pData += 2U; + } + + pStationStru->wEmergStopNum = ShortFromChar(pData); + pData += 2U; + + for (i = 0U; i<2U; i++) + { + pStationStru->wEmergStopId[i] = ShortFromChar(pData); + pData += 2U; + } + + pStationStru->wStopPointNum = ShortFromChar(pData); + pData += 2U; + /*ͣ,ͨΪĸ*/ + for (i = 0U; i<4U; i++) + { + pStationStru->wStopPointID[i] = ShortFromChar(pData); + pData += 2U; + } + + pStationStru->wDoorOpenMode = ShortFromChar(pData); + pData += 2U; + + pStationStru->wDoorOpenTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wDoorCloseMode = ShortFromChar(pData); + pData += 2U; + + pStationStru->wDoorCloseTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wParkSteadyTime = ShortFromChar(pData); + pData += 2U; + + pStationStru->wStationID = ShortFromChar(pData); /*2013813,ɳ*/ + pData += 2U; + + pStationStru->wLuggageOpenMode = ShortFromChar(pData); /*ŷʽݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + pData += 2U; + + pStationStru->wLuggageCloseMode = ShortFromChar(pData); /*ŷʽݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + pData += 2U; + + pStationStru->wCrashResSpeed = ShortFromChar(pData); /*ײֵݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + pData += 2U; + + pStationStru->wATSStationId = ShortFromChar(pData); /*ATSͣID*/ + pData += 2U; + + pStationStru->wTimeOfAdvanceRoute = ShortFromChar(pData); /*ǰ·ʱ*/ + pData += 2U; + + rtnValue = 1; + } + return rtnValue; +} + +/*********************************************************************************** +ܣͣϢݽṹʼ(ԭվ̨) +˵[in] pDataAdd ݵַļ + [out] pStationStru ʼĽṹָ +ֵ0ʧܣ1ɹ +עݻͨݽṹV12.0.0޸ĺ + DGHLTʹͬijʼӴ˺add by lmy 20180312 +***********************************************************************************/ +static UINT8 STATION_STRU_init_DG(UINT8 *pDataAdd, DSU_STATION_STRU *pStationStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pStationStru)) + + { + UINT8 *pData = pDataAdd; + UINT8 i = 0U; + /**/ + pStationStru->wId = ShortFromChar(pData); + pData += 2U; + /*վ*/ + for (i = 0U; i<20U; i++) + { + pStationStru->szCaption[i] = *pData; + pData += 1U; + } + /*Ŀĵر*/ + for (i = 0U; i<4U; i++) + { + pStationStru->bDesId[i] = *pData; + pData += 1U; + } + /*ͣLink*/ + pStationStru->wLinkId = ShortFromChar(pData); + pData += 2U; + /*ͣ*/ + pStationStru->dwAttribute = LongFromChar(pData); + pData += 4U; + /*վ̨Сͣվʱ*/ + pStationStru->wMinParkTime = ShortFromChar(pData); + pData += 2U; + /*վ̨ͣվʱ*/ + pStationStru->wMaxParkTime = ShortFromChar(pData); + pData += 2U; + /*վ̨Ĭͣվʱ*/ + pStationStru->wParkTime = ShortFromChar(pData); + pData += 2U; + /**/ + pStationStru->wScreenNum = ShortFromChar(pData); + pData += 2U; + /*ű*/ + for (i = 0U; i<2U; i++) + { + pStationStru->wScreenId[i] = ShortFromChar(pData); + pData += 2U; + } + /*ͣť*/ + pStationStru->wEmergStopNum = ShortFromChar(pData); + pData += 2U; + /*ͣť*/ + for (i = 0U; i < 2U; i++) + { + pStationStru->wEmergStopId[i] = ShortFromChar(pData); + pData += 2U; + } + /*ͣĿ*/ + pStationStru->wStopPointNum = ShortFromChar(pData); + pData += 2U; + /*ͣ*/ + for (i = 0U; i < 4U; i++) + { + pStationStru->wStopPointID[i] = ShortFromChar(pData); + pData += 2U; + } + /*վ̨ŷʽ*/ + pStationStru->wDoorOpenMode = ShortFromChar(pData); + pData += 2U; + /*վ̨ʱ*/ + pStationStru->wDoorOpenTime = ShortFromChar(pData); + pData += 2U; + /*վ̨ŷʽ*/ + pStationStru->wDoorCloseMode = ShortFromChar(pData); + pData += 2U; + /*վ̨ʱ*/ + pStationStru->wDoorCloseTime = ShortFromChar(pData); + pData += 2U; + /*Ĭͣʱ*/ + pStationStru->wParkSteadyTime = ShortFromChar(pData); + pData += 2U; + /*վ̨վ*/ + pStationStru->wStationID = ShortFromChar(pData); + pData += 2U; + + rtnValue = 1; + } + return rtnValue; +} +/*********************************************************************************** +ܣͣϢݽṹʼ-ϵͳʹ add by sds 2019-6-13 +˵[in] pDataAdd ݵַļ +[out] pStationStru ʼĽṹָ +ֵ0ʧܣ1ɹ +עadd by qw.liu 2022-02-22 +***********************************************************************************/ +static UINT8 STATION_STRU_init_CC(UINT8 *pDataAdd, DSU_STATION_STRU *pStationStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pStationStru)) + { + UINT8 *pData = pDataAdd; + UINT8 i = 0U; + /**/ + pStationStru->wId = ShortFromChar(pData); + pData += 2U; + + /*Ŀĵر*/ + for (i = 0U; i<4U; i++) + { + pStationStru->bDesId[i] = *pData; + pData += 1U; + } + + /*ͣLink*/ + pStationStru->wLinkId = ShortFromChar(pData); + pData += 2U; + + /*ͣ*/ + pStationStru->dwAttribute = LongFromChar(pData); + pData += 4U; + +#if 0 + /*վ̨Ĭͣվʱ*/ + pStationStru->wParkTime = ShortFromChar(pData); + pData += 2U; +#endif + + /**/ + pStationStru->wScreenNum = ShortFromChar(pData); + pData += 2U; + + /*ű*/ + for (i = 0U; i<2U; i++) + { + pStationStru->wScreenId[i] = ShortFromChar(pData); + pData += 2U; + } + + /*ͣť*/ + pStationStru->wEmergStopNum = ShortFromChar(pData); + pData += 2U; + + /*ͣť*/ + for (i = 0U; i < 2U; i++) + { + pStationStru->wEmergStopId[i] = ShortFromChar(pData); + pData += 2U; + } +#if 0 + /*վ̨ͣĿ*/ + pStationStru->wStopPointNum = ShortFromChar(pData); + pData += 2U; + /*ͣ,ͨΪĸ*/ + for (i = 0U; i < 4U; i++) + { + pStationStru->wStopPointID[i] = ShortFromChar(pData); + pData += 2U; + } +#endif + /*վ̨ŷʽ*/ + pStationStru->wDoorOpenMode = ShortFromChar(pData); + pData += 2U; + + /*վ̨ʱ*/ + pStationStru->wDoorOpenTime = ShortFromChar(pData); + pData += 2U; + + /*վ̨ŷʽ*/ + pStationStru->wDoorCloseMode = ShortFromChar(pData); + pData += 2U; + + /*վ̨ʱ*/ + pStationStru->wDoorCloseTime = ShortFromChar(pData); + pData += 2U; + +#if 0 + /*Ĭͣʱ*/ + pStationStru->wParkSteadyTime = ShortFromChar(pData); + pData += 2U; + + /*վ̨վ*/ + pStationStru->wStationID = ShortFromChar(pData); /*2013813,ɳ*/ + pData += 2U; +#endif + + pStationStru->wLuggageOpenMode = ShortFromChar(pData); + pData += 2U; + + + pStationStru->wLuggageCloseMode = ShortFromChar(pData); + pData += 2U; + + + pStationStru->wCrashResSpeed = ShortFromChar(pData); /*ײֵݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + pData += 2U; + + /*ATSͣ*/ + pStationStru->wATSStationId = ShortFromChar(pData); + pData += 2U; + + rtnValue = 1; + } + return rtnValue; +} +/*ýӿ*/ +/*עݻͨݽṹV12.0.0޸ģmodify by lmy 20180312*/ +/*עӳݽṹV1.0.0޸ mod by qw.liu 2022-02-22*/ +/*ע޸ķֵΪUINT8*/ +UINT8 STATION_STRU_init(UINT8 *pDataAdd,DSU_STATION_STRU *pStationStru) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType) || (DQU_CBTC_CPK == cbtcVersionType) ) + { + rtnValue = STATION_STRU_init_DFT(pDataAdd, pStationStru); + } + /*cgh 202212.21޸ģĿ־3Ŀ־5ʹóѯ*/ + else if ((DQU_CBTC_HLT == cbtcVersionType) || (DQU_CBTC_CC == cbtcVersionType)) + { + /*rtnValue = STATION_STRU_init_HLT(pDataAdd, pStationStru);*/ + rtnValue = STATION_STRU_init_CC(pDataAdd, pStationStru); + } + else if (DQU_CBTC_DG == cbtcVersionType) + { + rtnValue = STATION_STRU_init_DG(pDataAdd, pStationStru); + } +#if 0 + else if (DQU_CBTC_CC == cbtcVersionType) + { + rtnValue = STATION_STRU_init_CC(pDataAdd, pStationStru); + } +#endif + else + { + /*ɴ֧*/ + } + return rtnValue; +} + +/************************************** +ܣͣݽṹʼ +˵[in ] pDataAdd ݵַļ + [out] pStoppointStru ʼĽṹָ + [out] realLoadRowLen ʵʼصͣϢ + [in ] stopPointAttr ʹõͣϢ +ֵ0=ָ 1=ɹ 2=ָǿյ +עṹ + UINT16 wMinStopTime; Сͣվʱ + UINT16 wMaxStopTime; ͣվʱ + UINT16 wStopTime; Ĭͣվʱ +޸ļ¼m by sds 2019-10-22 VOBCV15.0ͣݹˣֻͣԵ +***************************/ +UINT8 STOPPOINT_STRU_init(UINT8 * pDataAdd,DSU_STOPPOINT_STRU * pStoppointStru,UINT32 *realLoadRowLen,UINT32 stopPointAttr) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pStoppointStru) && (NULL != realLoadRowLen)) + { + UINT8 * pData = pDataAdd; + + pStoppointStru->wId = ShortFromChar(pData); + pData += 2; + + pStoppointStru->wAttribute = LongFromChar(pData); + pData += 4; + + /*Ŀ ͣԽݹˣֻ*/ + if (stopPointAttr == (stopPointAttr & pStoppointStru->wAttribute)) + { + pStoppointStru->wDir = ShortFromChar(pData); + pData += 2; + + pStoppointStru->wLinkId = ShortFromChar(pData); + pData += 2; + + pStoppointStru->dwLinkOfst = LongFromChar(pData); + pData += 4; + + pStoppointStru->wOverLapId = ShortFromChar(pData); + pData += 2; + + pStoppointStru->dwATOParkArea = LongFromChar(pData); + pData += 4; + + pStoppointStru->dwATPParkArea = LongFromChar(pData); + pData += 4; + + pStoppointStru->wStationID = ShortFromChar(pData); + pData += 2; + + pStoppointStru->wStationDoorID = *pData; + pData += 1; + + /*Ϲ ʵЧ+1*/ + (*realLoadRowLen) += 1; + + rtnValue = 1; + } + else + { + /*ѾݻָΪĬֵ*/ + pStoppointStru->wId = DSU_NULL_16; + + pStoppointStru->wAttribute = DSU_NULL_32; + + rtnValue = 2; + } + } + return rtnValue; + +} + +/************************************** +ܣݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pAxleSgmtStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wMiddleLinkId; мlink + UINT32 dwOrgnLinkOfst; linkƫ + UINT32 dwTmnlLinkOfst; յlinkƫ + UINT16 wOrgnRelatPointId; + UINT16 wOrgnMainAxleSgmtId; Ӷλα + UINT16 wOrgnSideAxleSgmtId; ӷλα + UINT16 wTmnlRelatPointId; յ + UINT16 wTmnlMainAxleSgmtId; յӶλα + UINT16 wTmnlSideAxleSgmtId; յӷλα + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[3]; α + UINT16 wManageZC; ZC + UINT16 wManagePhysicalCI; CI + +***************************/ +UINT8 AXLE_SGMT_STRU_init(UINT8 * pDataAdd, DSU_AXLE_SGMT_STRU * pAxleSgmtStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pAxleSgmtStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + /**/ + pAxleSgmtStru->wId = ShortFromChar(pData); + pData += 2; + + /**/ + for (i = 0; i<16; i++) + { + pAxleSgmtStru->szCaption[i] = *pData; + pData += 1; + } + + /**/ + pAxleSgmtStru->wOrgnAxleId = ShortFromChar(pData); + pData += 2; + + /*յ*/ + pAxleSgmtStru->wTmnlAxleId = ShortFromChar(pData); + pData += 2; + + /*link*/ + pAxleSgmtStru->wOrgnLkId = ShortFromChar(pData); + pData += 2; + + /*յlink*/ + pAxleSgmtStru->wTmnlLkId = ShortFromChar(pData); + pData += 2; + + /*ΰ߼εĸ*/ + pAxleSgmtStru->wIncludeLogicSgmtNum = ShortFromChar(pData); + pData += 2; + + /*ΰ߼εı*/ + for (i = 0; i<50; i++) + { + pAxleSgmtStru->wLogicSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + + /*Ŀ*/ + pAxleSgmtStru->wRelatPointNum = ShortFromChar(pData); + pData += 2; + + for (i = 0; i<4; i++) + { + /**/ + pAxleSgmtStru->wRelatPointId[i] = ShortFromChar(pData); + pData += 2; + /*״̬*/ + pAxleSgmtStru->wRelatPointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*Id*/ + pAxleSgmtStru->wRelatePhysicalSgmtId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + + +/************************************** +ܣ·ݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pRouteStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wCBTCAccessLink1RelatePointNum; CBTCӽ1Ŀ + UINT16 wCBTCAccessLink1RelatePointId[]; CBTCӽ1 + UINT16 wCBTCAccessLink1RelatePointSta[]; CBTCӽ1״̬ + UINT16 wCBTCAccessLink2RelatePointNum; CBTCӽ2Ŀ + UINT16 wCBTCAccessLink2RelatePointId[]; CBTCӽ2 + UINT16 wCBTCAccessLink2RelatePointSta[]; CBTCӽ2״̬ + UINT16 wCBTCAccessLink3RelatePointNum; CBTCӽ3Ŀ + UINT16 wCBTCAccessLink3RelatePointId[]; CBTCӽ3 + UINT16 wCBTCAccessLink3RelatePointSta[]; CBTCӽ3״̬ + UINT16 wCBTCAccessLink4RelatePointNum; CBTCӽ4Ŀ + UINT16 wCBTCAccessLink4RelatePointId[]; CBTCӽ4 + UINT16 wCBTCAccessLink4RelatePointSta[]; CBTCӽ4״̬ + UINT16 wIncludeAxleSgmtNum; ·ļĿ + UINT16 wIncludeAxleSgmtId[8]; ļα + UINT16 wAxleSgmtLockStatus[8]; ļ״̬ + UINT16 wIncludeLinkNum; linkĿ + UINT16 wLinkId[14]; link + UINT16 wObsNum; ·ϰ + UINT16 wObsType[8]; ϰ + UINT16 wObsID[8]; ϰID + UINT16 wObsNeedLockStatus[8]; ϰҪ״̬ +***************************/ +static UINT8 ROUTE_STRU_init_FAO(UINT8 * pDataAdd, DSU_ROUTE_STRU * pRouteStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pRouteStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + pRouteStru->wId = ShortFromChar(pData); + pData += 2; + + /*·*/ + for (i = 0; i<24; i++) + { + pRouteStru->szCaption[i] = *pData; + pData += 1; + } + + /*·*/ + pRouteStru->wRouteType = ShortFromChar(pData); + pData += 2; + + /*ʼźŻ*/ + pRouteStru->wStartSignalId = ShortFromChar(pData); + pData += 2; + + /*ֹźŻ*/ + pRouteStru->wEndSignalId = ShortFromChar(pData); + pData += 2; + + /*link*/ /*---Ϲѧ*/ + pRouteStru->wOrgnLkId = ShortFromChar(pData); + pData += 2; + + /*յlink*/ /*---Ϲѧ*/ + pRouteStru->wTmnlLkId = ShortFromChar(pData); + pData += 2; + + /*Ŀ*/ + pRouteStru->wIncludePointNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i<16; i++) + { + /**/ + pRouteStru->wPointId[i] = ShortFromChar(pData); + pData += 2; + + /*״̬*/ + pRouteStru->wPointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*Ŀ*/ + pRouteStru->wProtectLinkNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i<4; i++) + { + /*α*/ + pRouteStru->wProtectLinkId[i] = ShortFromChar(pData); + pData += 2; + + /*ι*/ + pRouteStru->wProtectLinkRelatePointId[i] = ShortFromChar(pData); + pData += 2; + + /*ι״̬*/ + pRouteStru->wProtectLinkRelatePointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*ʽӽĿ*/ + pRouteStru->wBlogAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /*ʽӽα,ԺϿݽṹV16.0.0FAOHLTҲӽαӡ5by my 20170220*/ + for (i = 0; i<5; i++) + { + pRouteStru->wBlogAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CBTCӽĿ*/ + pRouteStru->wCBTCAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /*CBTCӽα,ԺϿݽṹV16.0.0FAOHLTҲӽαӡ5by my 20170220*/ + for (i = 0; i<5; i++) + { + pRouteStru->wCBTCAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CI*/ + pRouteStru->wManageCI = ShortFromChar(pData); + pData += 2; + /*·*/ + pRouteStru->wAttribute = ShortFromChar(pData); + pData += 2; + + /*ʽ */ + pRouteStru->wBlocTrgAreaNum = ShortFromChar(pData); + pData += 2; + + /*ʽID*/ + for (i = 0; i<13; i++) + { + pRouteStru->wBlocTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + /*cbtc */ + pRouteStru->wCbtcTrgAreaNum = ShortFromChar(pData); + pData += 2; + + /*cbtcID*/ + for (i = 0; i<13; i++) + { + pRouteStru->wCbtcTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣ·ݽṹʼ-ͨ +˵[in] pDataAdd ݵַļ + [out] pRouteStru ʼĽṹָ +ֵ0ʧܣ1ɹ +޸˵ +ݽṹ仯·ĵʽӽΡCBTCӽΡʽΡCBTCΪ0-30Ķ̬Χ by sds 2019-5-15 +***************************/ +static UINT8 ROUTE_STRU_init_HLT(UINT8 * pDataAdd, DSU_ROUTE_STRU * pRouteStru) +{ + UINT8 rtnValue = 0U; + if((NULL != pDataAdd) && (NULL != pRouteStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i=0U; + static UINT8 runCount=0U;/*ִиúĴ жǷΪһν*/ + static UINT8 maxBlocAccessLinkNum=MAX_BLOC_ACCESS_LINK_NUM;/*·ʵʵʽӽ*/ + static UINT8 maxCBTCAccessLinkNum=MAX_BLOC_ACCESS_LINK_NUM;/*·ʵCBTCӽ*/ + static UINT8 maxBlocTRGAreLinkNum=MAX_BLOC_ACCESS_LINK_NUM;/*·ʵʵʽ*/ + + /*·ID*/ + pRouteStru->wId = ShortFromChar(pData); + pData += 2; + + /*·*/ + for (i = 0; i<24; i++) + { + pRouteStru->szCaption[i] = *pData; + pData += 1; + } + + /*·*/ + pRouteStru->wRouteType = ShortFromChar(pData); + pData += 2; + + /*ʼźŻ*/ + pRouteStru->wStartSignalId = ShortFromChar(pData); + pData += 2; + + /*ֹźŻ*/ + pRouteStru->wEndSignalId = ShortFromChar(pData); + pData += 2; + + /*link*/ /*---Ϲѧ*/ + pRouteStru->wOrgnLkId = ShortFromChar(pData); + pData += 2; + + /*յlink*/ /*---Ϲѧ*/ + pRouteStru->wTmnlLkId = ShortFromChar(pData); + pData += 2; + + /*Ŀ*/ + pRouteStru->wIncludePointNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i<16; i++) + { + /**/ + pRouteStru->wPointId[i] = ShortFromChar(pData); + pData += 2; + + /*״̬*/ + pRouteStru->wPointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*Ŀ*/ + pRouteStru->wProtectLinkNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i<4; i++) + { + /*α*/ + pRouteStru->wProtectLinkId[i] = ShortFromChar(pData); + pData += 2; + + /*ι*/ + pRouteStru->wProtectLinkRelatePointId[i] = ShortFromChar(pData); + pData += 2; + + /*ι״̬*/ + pRouteStru->wProtectLinkRelatePointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + + /* "ʽӽĿ""CBTCӽĿ""ʽ""cbtc" Ϊ̶ֵ, + һݱӾҪ޸Ĵ,ΪŻ޸Ľṹ߼, by sds 2019-5-16 */ + + /*жǷһִ һִʱ ʱõһμijɹ*/ + if (0U == runCount) + { + /* ȡʽӽĿ */ + pRouteStru->wBlogAccessLinkNum = ShortFromChar(pData); + maxBlocAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /* ݻȡĵʽӽĿ */ + for (i = 0; iwBlogAccessLinkNum; i++) + { + pRouteStru->wBlogAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*ȡCBTCӽĿ*/ + for (i = 0; iwCBTCAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /* ϶ȡݣЧֱֵȡȷֵʱ˳ */ + if ((pRouteStru->wCBTCAccessLinkNum != DSU_NULL_16) + && (pRouteStru->wCBTCAccessLinkNum <= MAX_CBTC_ACCESS_LINK_NUM)) + { + /*·CBTCӽЧֵ*/ + maxCBTCAccessLinkNum = pRouteStru->wCBTCAccessLinkNum; + break; + } + else + { + /*·ĵʽӽ+1*/ + maxBlocAccessLinkNum++; + } + } + + /* ݻȡCBTCӽĿ */ + for (i = 0; iwCBTCAccessLinkNum; i++) + { + pRouteStru->wCBTCAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CI*/ + for (i = 0; iwManageCI = ShortFromChar(pData); + pData += 2; + + /* ϶ȡݣЧֱֵȡȷֵʱ˳ */ + if (pRouteStru->wManageCI != DSU_NULL_16) + { + break; + } + else + { + /*·CBTCӽ+1*/ + maxCBTCAccessLinkNum++; + } + } + + /*·*/ + pRouteStru->wAttribute = ShortFromChar(pData); + pData += 2; + + + /*ʽ */ + pRouteStru->wBlocTrgAreaNum = ShortFromChar(pData); + maxBlocTRGAreLinkNum = ShortFromChar(pData); + pData += 2; + + /*ʽID*/ + for (i = 0; iwBlocTrgAreaNum; i++) + { + pRouteStru->wBlocTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + + /*cbtc */ + for (i = 0; iwCbtcTrgAreaNum = ShortFromChar(pData); + pData += 2; + + /* ϶ȡݣЧֱֵȡȷֵʱ˳ */ + if ((pRouteStru->wCbtcTrgAreaNum != DSU_NULL_16) + && (pRouteStru->wCbtcTrgAreaNum <= MAX_CBTC_TRG_AREA_NUM)) + { + break; + } + else + { + /*·ĵʽ+1*/ + maxBlocTRGAreLinkNum++; + } + } + + /*cbtcID*/ + for (i = 0; iwCbtcTrgAreaNum; i++) + { + pRouteStru->wCbtcTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + + /*ִд+1*/ + runCount++; + } + else + { + + /* ȡʽӽĿ */ + pRouteStru->wBlogAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /* ݻȡĵʽӽĿ */ + for (i = 0; iwBlogAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*ȡCBTCӽĿ*/ + pRouteStru->wCBTCAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /* ݻȡCBTCӽĿ */ + for (i = 0; iwCBTCAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CI*/ + pRouteStru->wManageCI = ShortFromChar(pData); + pData += 2; + + /*·*/ + pRouteStru->wAttribute = ShortFromChar(pData); + pData += 2; + + + /*ʽ */ + pRouteStru->wBlocTrgAreaNum = ShortFromChar(pData); + pData += 2; + + /*ʽID*/ + for (i = 0; iwBlocTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + + /*cbtc */ + pRouteStru->wCbtcTrgAreaNum = ShortFromChar(pData); + pData += 2; + + /*cbtcID-ʵݻȡ*/ + for (i = 0; iwCbtcTrgAreaNum; i++) + { + pRouteStru->wCbtcTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + } + rtnValue = 1; + } + return rtnValue; +} + +static UINT8 ROUTE_STRU_init_CPK(UINT8 * pDataAdd, DSU_ROUTE_STRU * pRouteStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pRouteStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + pRouteStru->wId = ShortFromChar(pData); + pData += 2; + + /*·*/ + for (i = 0; i<24; i++) + { + pRouteStru->szCaption[i] = *pData; + pData += 1; + } + + /*·*/ + pRouteStru->wRouteType = ShortFromChar(pData); + pData += 2; + + /*ʼźŻ*/ + pRouteStru->wStartSignalId = ShortFromChar(pData); + pData += 2; + + /*ֹźŻ*/ + pRouteStru->wEndSignalId = ShortFromChar(pData); + pData += 2; + + /*link*/ /*---Ϲѧ*/ + pRouteStru->wOrgnLkId = ShortFromChar(pData); + pData += 2; + + /*յlink*/ /*---Ϲѧ*/ + pRouteStru->wTmnlLkId = ShortFromChar(pData); + pData += 2; + + /*Ŀ*/ + pRouteStru->wIncludePointNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i<16; i++) + { + /**/ + pRouteStru->wPointId[i] = ShortFromChar(pData); + pData += 2; + + /*״̬*/ + pRouteStru->wPointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*Ŀ*/ + pRouteStru->wProtectLinkNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i<4; i++) + { + /*α*/ + pRouteStru->wProtectLinkId[i] = ShortFromChar(pData); + pData += 2; + + /*ι*/ + pRouteStru->wProtectLinkRelatePointId[i] = ShortFromChar(pData); + pData += 2; + + /*ι״̬*/ + pRouteStru->wProtectLinkRelatePointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*ʽӽĿ*/ + pRouteStru->wBlogAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /*ʽӽα,ԺϿݽṹV16.0.0FAOHLTҲӽαӡ5by my 20170220*/ + for (i = 0; i<5; i++) + { + pRouteStru->wBlogAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CBTCӽĿ*/ + pRouteStru->wCBTCAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /*CBTCӽα,ԺϿݽṹV16.0.0FAOHLTҲӽαӡ5by my 20170220*/ + for (i = 0; i<5; i++) + { + pRouteStru->wCBTCAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CI*/ + pRouteStru->wManageCI = ShortFromChar(pData); + pData += 2; + /*·*/ + pRouteStru->wAttribute = ShortFromChar(pData); + pData += 2; + + /*ʽ */ + pRouteStru->wBlocTrgAreaNum = ShortFromChar(pData); + pData += 2; + + /*ʽID*/ + for (i = 0; i<4; i++) + { + pRouteStru->wBlocTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + /*cbtc */ + pRouteStru->wCbtcTrgAreaNum = ShortFromChar(pData); + pData += 2; + + /*cbtcID*/ + for (i = 0; i<4; i++) + { + pRouteStru->wCbtcTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣ·ݽṹʼ- +˵[in] pDataAdd ݵַļ +[out] pRouteStru ʼĽṹָ +ֵ0 ʧ 1 ɹ +޸˵ +ݽṹ +***************************/ +static UINT8 ROUTE_STRU_init_CC(UINT8 * pDataAdd, DSU_ROUTE_STRU * pRouteStru) +{ + UINT8 * pData = pDataAdd; + UINT8 i = 0; + static UINT8 runCount = 0;/*ִиúĴ жǷΪһν*/ + static UINT8 maxCBTCAccessLinkNum = MAX_CBTC_ACCESS_LINK_NUM;/*·ʵCBTCӽ*/ + static UINT8 maxBLOCAccessLinkNum = MAX_BLOC_ACCESS_LINK_NUM;/*·ʵʵʽӽ*/ + UINT8 reval = 0U;/*ʼֵΪʧ*/ + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pRouteStru)) + { + pRouteStru->wId = ShortFromChar(pData); + pData += 2; + + /*·*/ + for (i = 0; i < 24; i++) + { + pRouteStru->szCaption[i] = *pData; + pData += 1; + } + + /*·*/ + pRouteStru->wRouteType = ShortFromChar(pData); + pData += 2; + + /*ʼźŻ*/ + pRouteStru->wStartSignalId = ShortFromChar(pData); + pData += 2; + + /*ֹźŻ*/ + pRouteStru->wEndSignalId = ShortFromChar(pData); + pData += 2; + + /*link*/ /*---Ϲѧ*/ + pRouteStru->wOrgnLkId = ShortFromChar(pData); + pData += 2; + + /*յlink*/ /*---Ϲѧ*/ + pRouteStru->wTmnlLkId = ShortFromChar(pData); + pData += 2; + + /*Ŀ*/ + pRouteStru->wIncludePointNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i < 16; i++) + { + /**/ + pRouteStru->wPointId[i] = ShortFromChar(pData); + pData += 2; + + /*״̬*/ + pRouteStru->wPointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /*Ŀ*/ + pRouteStru->wProtectLinkNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i < 4; i++) + { + /*α*/ + pRouteStru->wProtectLinkId[i] = ShortFromChar(pData); + pData += 2; + + /*ι*/ + pRouteStru->wProtectLinkRelatePointId[i] = ShortFromChar(pData); + pData += 2; + + /*ι״̬*/ + pRouteStru->wProtectLinkRelatePointStatus[i] = ShortFromChar(pData); + pData += 2; + } + + /* "CBTCӽĿ"Ϊ̶ֵ,һݱӾҪ޸Ĵ,ΪŻ޸Ľṹ߼, by cgh 2023-4-14 */ + /*жǷһִ һִʱ ʱõһμijɹ*/ + if (0U == runCount) + { + /*ʽӽĿ*/ + pRouteStru->wBlogAccessLinkNum = ShortFromChar(pData); + pData += 2; + + if (MAX_BLOC_ACCESS_LINK_NUM >= pRouteStru->wBlogAccessLinkNum) + { + /*ʽӽϷȡ*/ + maxBLOCAccessLinkNum = pRouteStru->wBlogAccessLinkNum; + + /*ʽӽα*/ + for (i = 0; i < pRouteStru->wBlogAccessLinkNum; i++) + { + pRouteStru->wBlogAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*ȡCBTCӽĿ*/ + for (i = 0; i < MAX_BLOC_ACCESS_LINK_NUM; i++) + { + pRouteStru->wCBTCAccessLinkNum = ShortFromChar(pData); + pData += 2; + + /* ϶ȡݣЧֱֵȡȷֵʱ˳ */ + if (pRouteStru->wCBTCAccessLinkNum != DSU_NULL_16) + { + break; + } + else + { + /*·ĵʽӽ+1*/ + maxBLOCAccessLinkNum++; + } + } + + if (MAX_CBTC_ACCESS_LINK_NUM >= pRouteStru->wCBTCAccessLinkNum) + { + /*CBTCӽϷȡ*/ + maxCBTCAccessLinkNum = pRouteStru->wCBTCAccessLinkNum; + + /* ݻȡCBTCӽĿ */ + for (i = 0; i < pRouteStru->wCBTCAccessLinkNum; i++) + { + pRouteStru->wCBTCAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CI*/ + for (i = 0; i < MAX_CBTC_ACCESS_LINK_NUM; i++) + { + pRouteStru->wManageCI = ShortFromChar(pData); + pData += 2; + + /* ϶ȡݣЧֱֵȡȷֵʱ˳ */ + if (pRouteStru->wManageCI != DSU_NULL_16) + { + break; + } + else + { + /*·CBTCӽ+1*/ + maxCBTCAccessLinkNum++; + } + } + /*·*/ + pRouteStru->wAttribute = ShortFromChar(pData); + pData += 2; + + /*cbtc */ + pRouteStru->wCbtcTrgAreaNum = ShortFromChar(pData); + pData += 2; + + if (MAX_CBTC_TRG_AREA_NUM >= pRouteStru->wCbtcTrgAreaNum) + { + /*CBTCϷȡ*/ + for (i = 0; i < pRouteStru->wCbtcTrgAreaNum; i++) + { + /*cbtcID*/ + pRouteStru->wCbtcTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + + reval = 1U; /*ݾϷسɹ*/ + } + } + } + + /*ִд+1*/ + runCount++; + } + else + { + if ((MAX_CBTC_ACCESS_LINK_NUM < maxCBTCAccessLinkNum) || (MAX_BLOC_ACCESS_LINK_NUM < maxBLOCAccessLinkNum)) + { + /*CBTCӽĿ/ʽӽĿ30ʱݣسʼʧ*/ + reval = 0U; + } + else + { + /*ʽӽĿ*/ + pRouteStru->wBlogAccessLinkNum = ShortFromChar(pData); + pData += 2; + + if (MAX_BLOC_ACCESS_LINK_NUM >= pRouteStru->wBlogAccessLinkNum) + { + /*ʽӽϷȡ*/ + for (i = 0; i < maxBLOCAccessLinkNum; i++) + { + /*ʽӽα*/ + pRouteStru->wBlogAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CBTCӽĿ*/ + pRouteStru->wCBTCAccessLinkNum = ShortFromChar(pData); + pData += 2; + + if (MAX_CBTC_ACCESS_LINK_NUM >= pRouteStru->wCBTCAccessLinkNum) + { + /*CBTCӽϷȡ*/ + for (i = 0; i < maxCBTCAccessLinkNum; i++) + { + /*CBTCӽα*/ + pRouteStru->wCBTCAccessLinkId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CI*/ + pRouteStru->wManageCI = ShortFromChar(pData); + pData += 2; + /*·*/ + pRouteStru->wAttribute = ShortFromChar(pData); + pData += 2; + +#if 0 + /*ʽ */ + pRouteStru->wBlocTrgAreaNum = ShortFromChar(pData); + pData += 2; + + /*ʽID*/ + for (i = 0; i < 13; i++) + { + pRouteStru->wBlocTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } +#endif + + /*cbtc */ + pRouteStru->wCbtcTrgAreaNum = ShortFromChar(pData); + pData += 2; + + if (MAX_CBTC_TRG_AREA_NUM < pRouteStru->wCbtcTrgAreaNum) + { + /*CBTCĿ30ʱݣسʼʧ*/ + reval = 0U; + } + else + { + /*cbtcID*/ + for (i = 0; i < pRouteStru->wCbtcTrgAreaNum; i++) + { + pRouteStru->wCbtcTrgAreaId[i] = ShortFromChar(pData); + pData += 2; + } + + reval = 1U; /*ݾϷسɹ*/ + } + } + } + } + } + } + + return reval; +} +/*ýӿ +ע +ӶԵĿʶĴmodify by qxt 20170726 +޸ĻͨĿݽṹ·߼ݶԽ·ڰĵʽ/CBTCӽΣʽ/CBTCζ̬Ĵm by sds 2019-5-16*/ +UINT8 ROUTE_STRU_init(UINT8 *pDataAdd,DSU_ROUTE_STRU *pRouteStru) +{ + UINT8 cbtcVersionType=0U; + UINT8 reval = 0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType) || (DQU_CBTC_DG == cbtcVersionType) ) + { + reval = ROUTE_STRU_init_FAO(pDataAdd, pRouteStru); + } + else if (DQU_CBTC_CPK == cbtcVersionType) + { + reval = ROUTE_STRU_init_CPK(pDataAdd, pRouteStru); + } + /*cgh 202212.21޸ģĿ־3Ŀ־5ʹóѯ*/ + else if ((DQU_CBTC_HLT == cbtcVersionType) || (DQU_CBTC_CC == cbtcVersionType)) + { + reval = ROUTE_STRU_init_CC(pDataAdd, pRouteStru); + } + else + { + /*ɴ֧*/ + } + return reval; +} + +/************************************** +ܣ߼ݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pProtectLinkStruʼĽṹָ +ֵ +עṹ + UINT16 wRouteId; · + UINT16 wIncludeAxleSgmtId; ļα + UINT16 wObsNum; ϰĿ + UINT16 wObsType; ϰ + +*ɾα qw.liu 2022-02-22 +***************************/ +UINT8 LOGIC_SGMT_STRU_init(UINT8 * pDataAdd, DSU_LOGIC_SGMT_STRU * pLogicSgmtStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pLogicSgmtStru)) + { + UINT8 * pData = pDataAdd; + UINT32 i = 0; + /**/ + pLogicSgmtStru->wId = ShortFromChar(pData); + pData += 2; + + for (i = 0; i<16; i++) + { + /*߼*/ + pLogicSgmtStru->szCaption[i] = *pData; + pData++; + } + + /*link*/ + pLogicSgmtStru->wOrgnLkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ(cm)*/ + pLogicSgmtStru->dwOrgnLkOfst = LongFromChar(pData); + pData += 4; + + /*յlink*/ + pLogicSgmtStru->wTmnlLkId = ShortFromChar(pData); + pData += 2; + + /*յlinkƫ(cm)*/ + pLogicSgmtStru->dwTmnlLkOfst = LongFromChar(pData); + pData += 4; + + + /*ZC-CI߼ռ״̬λ + pLogicSgmtStru->wZcCiLogicStatusId = ShortFromChar(pData); + pData += 2;*/ + + /*ZC-CI߼CTгռ״̬λԤ + pLogicSgmtStru->wZcCiCTLogicStatusId = ShortFromChar(pData); + pData += 2;*/ + + /*ZC-CI߼UTгռ״̬λԤ + pLogicSgmtStru->wZcCiUTLogicStatusId = ShortFromChar(pData); + pData += 2;*/ + + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣʽӽϢݽṹʼ(ԭBLOCģʽӽα) +˵[in] pDataAdd ݵַļ + [out] pBlocAccessLinkStruʼĽṹָ +ֵ0=ʧܣ 1=ɹ +עṹ + +***************************/ +UINT8 BLOC_ACCESS_LINK_STRU_init(UINT8 * pDataAdd, DSU_BLOC_ACCESS_LINK_STRU * pBlocAccessLinkStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pBlocAccessLinkStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + + /**/ + pBlocAccessLinkStru->wId = ShortFromChar(pData); + pData += 2; + + /*ļĿ*/ + pBlocAccessLinkStru->wIncludeAxleSgmtNum = ShortFromChar(pData); + pData += 2; + + /*Ϣ*/ + for (i = 0; i<(pBlocAccessLinkStru->wIncludeAxleSgmtNum); i++) + { + pBlocAccessLinkStru->wIncludeAxleSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣCBTCӽϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pCBTCAccessLinkStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + +***************************/ +UINT8 CBTC_ACCESS_LINK_STRU_init(UINT8 *pDataAdd, DSU_CBTC_ACCESS_LINK_STRU *pCBTCAccessLinkStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pCBTCAccessLinkStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + + /**/ + pCBTCAccessLinkStru->wId = ShortFromChar(pData); + pData += 2; + + /*ļĿ*/ + pCBTCAccessLinkStru->wIncludeLogicSgmtNum = ShortFromChar(pData); + pData += 2; + + /*ļα*/ + for (i = 0; i<(pCBTCAccessLinkStru->wIncludeLogicSgmtNum); i++) + { + pCBTCAccessLinkStru->wIncludeLogicSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣ¶ݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pGradeStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹӣ +UINT32 dwGradeLength; ¶ȳ +UINT16 wIncludeLinkId[3]; ¶·мlink +***************************/ +UINT8 GRADE_STRU_init(UINT8 * pDataAdd,DSU_GRADE_STRU * pGradeStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pGradeStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pGradeStru->wId = ShortFromChar(pData); + pData += 2; + + /*¶link*/ + pGradeStru->wOrgnLinkId = ShortFromChar(pData); + pData += 2; + + /*¶linkƫ*/ + pGradeStru->dwOrgnLinkOfst = LongFromChar(pData); + pData += 4; + + /*¶յlink*/ + pGradeStru->wTmnlLinkId = ShortFromChar(pData); + pData += 2; + + /*¶յlinkƫ*/ + pGradeStru->dwTmnlLinkOfst = LongFromChar(pData); + pData += 4; + + /**/ + pGradeStru->wOrgnRelatePointId = ShortFromChar(pData); + pData += 2; + + /*¶ȱ*/ + pGradeStru->wOrgnJointMainGradeId = ShortFromChar(pData); + pData += 2; + + /*¶ȱ*/ + pGradeStru->wOrgnJointSideGradeId = ShortFromChar(pData); + pData += 2; + + /*յ*/ + pGradeStru->wTmnlRelatePointId = ShortFromChar(pData); + pData += 2; + + /*յ¶ȱ*/ + pGradeStru->wTmnlJointMainGradeId = ShortFromChar(pData); + pData += 2; + + /*յ¶ȱ*/ + pGradeStru->wTmnlJointSideGradeId = ShortFromChar(pData); + pData += 2; + + /*¶ֵ*/ + pGradeStru->wGradValue = ShortFromChar(pData); + pData += 2; + + /*¶·߼б*/ + pGradeStru->wInclineDir = ShortFromChar(pData); + pData += 2; + + /*߰뾶*/ /*---Ϲѧ*/ + pGradeStru->dwRadius = LongFromChar(pData); + pData += 4; + + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣ·̬ݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pStaticResSpeedStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ޸ + +***************************/ +UINT8 STATIC_RES_SPEED_STRU_init(UINT8 * pDataAdd,DSU_STATIC_RES_SPEED_STRU * pStaticResSpeedStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pStaticResSpeedStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pStaticResSpeedStru->wId = ShortFromChar(pData); + pData += 2; + + /*link*/ + pStaticResSpeedStru->wLinkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ(cm)*/ + pStaticResSpeedStru->dwOrgnLinkOfst = LongFromChar(pData); + pData += 4; + + /*յlinkƫ(cm)*/ + pStaticResSpeedStru->dwTmnlLinkOfst = LongFromChar(pData); + pData += 4; + + /**/ + pStaticResSpeedStru->wRelatePointId = ShortFromChar(pData); + pData += 2; + + /*ֵ̬*/ + pStaticResSpeedStru->wResSpeed = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣĬгݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pDefaultrouteStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wCurrentPlatformId; ǰվ̨ + UINT16 wCurrentPlatformFlag; ǰվ̨־λ + +***************************/ +UINT8 DEFAULTROUTE_STRU_init(UINT8 * pDataAdd, DSU_DEFAULTROUTE_STRU * pDefaultrouteStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pDefaultrouteStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pDefaultrouteStru->wId = ShortFromChar(pData); + pData += 2; + + /*link*/ + pDefaultrouteStru->wLinkId = ShortFromChar(pData); + pData += 2; + + /*з*/ + pDefaultrouteStru->wLinkDir = ShortFromChar(pData); + pData += 2; + + /*ǰվ̨*/ + pDefaultrouteStru->wNextPlatformId = ShortFromChar(pData); + pData += 2; + + /*Ŀվ̨*/ + pDefaultrouteStru->wDestinationId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣվӪݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pRunLevelStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + +***************************/ +static UINT8 RUN_LEVEL_STRU_init_CPK(UINT8 * pDataAdd, DSU_RUN_LEVEL_STRU * pRunLevelStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pRunLevelStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + /**/ + pRunLevelStru->wId = ShortFromChar(pData); + pData += 2; + + /*Ŀĵر*/ + pRunLevelStru->wOrgnDesId = ShortFromChar(pData); + pData += 2; + + /*յĿĵر*/ + pRunLevelStru->wTmnlDesId = ShortFromChar(pData); + pData += 2; + + /*мּĿ*/ /*---Ϲѧ*/ + pRunLevelStru->wRunLevelNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i<10; i++) + { + /*Ӫ*/ + pRunLevelStru->wRunLevelID[i] = ShortFromChar(pData); + pData += 2; + + /*Ӫʱ*/ + pRunLevelStru->wRunTime[i] = ShortFromChar(pData); + pData += 2; + + /*Ӫٶ*/ + pRunLevelStru->wRunSpeed[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣվӪݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pRunLevelStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עFAOHLT +***************************/ +static UINT8 RUN_LEVEL_STRU_init_DFT(UINT8 *pDataAdd, DSU_RUN_LEVEL_STRU *pRunLevelStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pRunLevelStru)) + { + UINT8 *pData = pDataAdd; + UINT8 i = 0; + + /**/ + pRunLevelStru->wId = ShortFromChar(pData); + pData += 2; + + /*Ŀĵر*/ + pRunLevelStru->wOrgnDesId = ShortFromChar(pData); + pData += 2; + + /*յĿĵر*/ + pRunLevelStru->wTmnlDesId = ShortFromChar(pData); + pData += 2; + + /*мּĿ*/ /*---Ϲѧ*/ + pRunLevelStru->wRunLevelNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; i<5; i++) + { + /*Ӫ*/ + pRunLevelStru->wRunLevelID[i] = ShortFromChar(pData); + pData += 2; + + /*Ӫʱ*/ + pRunLevelStru->wRunTime[i] = ShortFromChar(pData); + pData += 2; + + /*Ӫٶ*/ + pRunLevelStru->wRunSpeed[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣվӪݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pRunLevelStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עýӿ +ӶԵĿʶĴmodify by qxt 20170726 +***************************/ +UINT8 RUN_LEVEL_STRU_init(UINT8 *pDataAdd,DSU_RUN_LEVEL_STRU *pRunLevelStru) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType) || (DQU_CBTC_HLT == cbtcVersionType) ||(DQU_CBTC_DG == cbtcVersionType) ) + { + rtnValue = RUN_LEVEL_STRU_init_DFT(pDataAdd, pRunLevelStru); + } + else if (DQU_CBTC_CPK == cbtcVersionType ) + { + rtnValue = RUN_LEVEL_STRU_init_CPK(pDataAdd, pRunLevelStru); + } + else + { + /*ɴ֧*/ + } + return rtnValue; +} + +/************************************** +ܣ˳CBTCݽṹʼ(ԭ˳·) +˵[in] pDataAdd ݵַļ + [out]pExitRouteStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + +***************************/ +UINT8 EXIT_ROUTE_STRU_init(UINT8 * pDataAdd, DSU_EXIT_ROUTE_STRU * pExitRouteStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pExitRouteStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + /**/ + pExitRouteStru->wId = ShortFromChar(pData); + pData += 2; + + /*link*/ + pExitRouteStru->wOrgnLinkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ(cm)*/ + pExitRouteStru->dwOrgnLinkOfst = LongFromChar(pData); + pData += 4; + + /*յlink*/ + pExitRouteStru->wTmnlLinkId = ShortFromChar(pData); + pData += 2; + + /*յlinkƫ(cm)*/ + pExitRouteStru->dwTmnlLinkOfst = LongFromChar(pData); + pData += 4; + + /*˳CBTCʱгз*/ + pExitRouteStru->wDIR = ShortFromChar(pData); + pData += 2; + + /*˳CBTCʱгз*/ + pExitRouteStru->wType = ShortFromChar(pData); + pData += 2; + + /**/ + pExitRouteStru->wIncludePointNum = ShortFromChar(pData); + pData += 2; + + for (i = 0; i<10; i++) + { + /*id*/ + pExitRouteStru->wPointId[i] = ShortFromChar(pData); + pData += 2; + + /*״̬*/ + pExitRouteStru->wPointStatus[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣCBTCݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pTrainLineStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + +***************************/ +UINT8 TRAIN_LINE_STRU_init(UINT8 * pDataAdd, DSU_TRAIN_LINE_STRU * pTrainLineStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pTrainLineStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pTrainLineStru->wId = ShortFromChar(pData); + pData += 2; + + /*link*/ + pTrainLineStru->wOrgnLinkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ(cm)*/ + pTrainLineStru->dwOrgnLinkOfst = LongFromChar(pData); + pData += 4; + + /*յlink*/ + pTrainLineStru->wTmnlLinkId = ShortFromChar(pData); + pData += 2; + + /*յlinkƫ(cm)*/ + pTrainLineStru->dwTmnlLinkOfst = LongFromChar(pData); + pData += 4; + + /*CBTCгз*/ + pTrainLineStru->wDir = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣ۷ݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pARStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹԭ۷۷˳ϲ + +***************************/ +UINT8 AR_STRU_init(UINT8 * pDataAdd, DSU_AR_STRU * pARStru) +{ + UINT8 rtnValue = 0U; + if ((NULL != pDataAdd) && (NULL != pARStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pARStru->wId = ShortFromChar(pData); + pData += 2; + + /*۷վ̨*/ + pARStru->wStartPlartformId = ShortFromChar(pData); + pData += 2; + + /*۷*/ + pARStru->wARInStopPointId = ShortFromChar(pData); + pData += 2; + + + /*۷˵*/ + pARStru->wRevertPointId = ShortFromChar(pData); + pData += 2; + + /*۷˳վ̨*/ + pARStru->wEndPlartformId = ShortFromChar(pData); + pData += 2; + + /*۷˳*/ + pARStru->wAROutStopPointId = ShortFromChar(pData); + pData += 2; + + + /*۷ID*/ + pARStru->wARLampID = ShortFromChar(pData); + pData += 2; + + /*۷ťD*/ + pARStru->wARButtonId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣZCݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pZCComZoneStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עZC ǰzcֽ + +***************************/ +UINT8 ZC_COM_ZONE_STRU_init(UINT8 * pDataAdd, DSU_ZC_COM_ZONE_STRU * pZCComZoneStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pZCComZoneStru)) + { + UINT8 * pData = pDataAdd; + UINT8 i = 0; + + /**/ + pZCComZoneStru->wId = ShortFromChar(pData); + pData += 2; + + /*link*/ + pZCComZoneStru->wOrgnLinkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ*/ + pZCComZoneStru->dwOrgnLinkOfst = LongFromChar(pData); + pData += 4; + + /*յlink*/ + pZCComZoneStru->wTmnlLinkId = ShortFromChar(pData); + pData += 2; + + /*յlinkƫ*/ + pZCComZoneStru->dwTmnlLinkOfst = LongFromChar(pData); + pData += 4; + + /*лؽ·*/ + pZCComZoneStru->wRelateRouteID = ShortFromChar(pData); + pData += 2; + + + /*ڰĵĿ*/ + pZCComZoneStru->wIncludePointNum = ShortFromChar(pData); + pData += 2; + + + for (i = 0; iwPointId[i] = ShortFromChar(pData); + pData += 2; + + /*ڰĵ״̬*/ + pZCComZoneStru->wPointStatus[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣZCֽϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pZCDividPointStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ޸ + +***************************/ +UINT8 ZC_DIVID_POINT_STRU_init(UINT8 * pDataAdd, DSU_ZC_DIVID_POINT_STRU * pZCDividPointStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pZCDividPointStru)) + { + UINT16 j = 0; + UINT8 * pData = pDataAdd; + /**/ + pZCDividPointStru->wId = ShortFromChar(pData); + pData += 2; + + /*صķֽ*/ + pZCDividPointStru->wIdconnection = ShortFromChar(pData); + pData += 2; + + /*ֽ*/ + pZCDividPointStru->wType = ShortFromChar(pData); + pData += 2; + + /*ƽZC豸*/ + pZCDividPointStru->wOutputZcIndex = ShortFromChar(pData); + pData += 2; + + /*ƽZC豸ID*/ + pZCDividPointStru->wOutputZcId = ShortFromChar(pData); + pData += 2; + + /*ӹZC豸*/ + pZCDividPointStru->wInputZcIndex = ShortFromChar(pData); + pData += 2; + + /*ӹZC豸ID*/ + pZCDividPointStru->wInputZcId = ShortFromChar(pData); + pData += 2; + + /*ZCֽlink*/ + pZCDividPointStru->wDividPointLinkId = ShortFromChar(pData); + pData += 2; + + /*ZCֽlinkƫ*/ + pZCDividPointStru->dwDividPointLinkOfst = LongFromChar(pData); + pData += 4; + + /*глʱз*/ + pZCDividPointStru->wDir = ShortFromChar(pData); + pData += 2; + + /*ֽصĹĿ*/ + pZCDividPointStru->wRelateZCAreaNum = ShortFromChar(pData); + pData += 2; + + for (j = 0; jwRelateZCAreaId[j] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} +/************************************** +ܣCIϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pCIStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ޸ + +***************************/ +UINT8 CI_STRU_init_DFT(UINT8 * pDataAdd,DSU_CI_STRU * pCIStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pCIStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pCIStru->wIndex = ShortFromChar(pData); + pData += 2; + + /*CI豸ID*/ + pCIStru->wID = ShortFromChar(pData); + pData += 2; + + /**/ + pCIStru->wType = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +UINT8 CI_STRU_init_HLT(UINT8 * pDataAdd, DSU_CI_STRU * pCIStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pCIStru)) + { + UINT8 * pData = pDataAdd; + UINT16 i = 0; + + /**/ + pCIStru->wIndex = ShortFromChar(pData); + pData += 2; + + /*CI豸ID*/ + pCIStru->wID = ShortFromChar(pData); + pData += 2; + + /**/ + pCIStru->wType = ShortFromChar(pData); + pData += 2; + + /*CI-VOBCУϢ*/ + pCIStru->dwVersionOfCIToVOBC = LongFromChar(pData); + pData += 4; + + /*CI-ZCУϢ*/ + pCIStru->dwVersionOfCIToZC = LongFromChar(pData); + pData += 4; + + /*CI-ATSУϢ*/ + pCIStru->dwVersionOfCIToATS = LongFromChar(pData); + pData += 4; + + /*CI*/ + pCIStru->dwAdjoinCICount = *pData; + pData += 1; + + for (i = 0; i<6; i++) + { + /*CI[1-6]ID*/ + pCIStru->dwAdjoinCIId[i] = ShortFromChar(pData); + pData += 2; + + /*CI[1-6]ĹУϢ*/ + pCIStru->dwAdjoinCIShareCheckData[i] = LongFromChar(pData); + pData += 4; + + } + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣCIϢݽṹʼ +˵[in] pDataAdd ݵַļ +[out]pCIStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ +UINT32 dwVersionOfCIToTMC + +***************************/ +static UINT8 CI_STRU_init_CC(UINT8 * pDataAdd, DSU_CI_STRU * pCIStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pCIStru)) + { + UINT8 * pData = pDataAdd; + UINT16 i = 0; + + /**/ + pCIStru->wIndex = ShortFromChar(pData); + pData += 2; + + /*RCI豸ID*/ + pCIStru->wID = ShortFromChar(pData); + pData += 2; + + /**/ + pCIStru->wType = ShortFromChar(pData); + pData += 2; + + /*RCI-VOBCУϢ*/ + pCIStru->dwVersionOfCIToVOBC = LongFromChar(pData); + pData += 4; + + /*RCI-TMCУϢ*/ + pCIStru->dwVersionOfCIToTMC = LongFromChar(pData); + pData += 4; + + /*RCI-ZCУϢ*/ + pCIStru->dwVersionOfCIToZC = LongFromChar(pData); + pData += 4; + + /*RCI-ATSУϢ*/ + pCIStru->dwVersionOfCIToATS = LongFromChar(pData); + pData += 4; + + /*CI*/ + pCIStru->dwAdjoinCICount = *pData; + pData += 1; + + for (i = 0; i<6; i++) + { + /*CI[1-6]ID*/ + pCIStru->dwAdjoinCIId[i] = ShortFromChar(pData); + pData += 2; + + /*CI[1-6]ĹУϢ*/ + pCIStru->dwAdjoinCIShareCheckData[i] = LongFromChar(pData); + pData += 4; + + } + + for (i = 0; i < 3; i++) + { + /*CIͨżϵͳ[1-3]ID*/ + pCIStru->dwCIToAxleID[i] = ShortFromChar(pData); + pData += 2; + + /*ϵͳ[1-3]ĹУϢ*/ + pCIStru->dwCIToAxleShareCheckData[i] = LongFromChar(pData); + pData += 4; + + } + + pCIStru->chAdjoinOcCount = *pData; + pData += 1U; + + for (i = 0U; i < 10U; i++) + { + /*OC[1-10]ID*/ + pCIStru->wAdjoinOcId[i] = ShortFromChar(pData); + pData += 2U; + + /*ͨŵOC[1-10]ĹУϢ*/ + pCIStru->dwAdjoinOcShareCheckData[i] = LongFromChar(pData); + pData += 4u; + } + +#if 0 + /*RCI*/ + pCIStru->RCIEntraceType = *pData; + pData += 1; +#endif + + /*ȫɸ*/ + pCIStru->cWLScreenType = *pData; + pData += 1; + + rtnValue = 1; + } + return rtnValue; +} +/*ýӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +/*޸ķֵΪUINT8 0=ʧܣ1=ɹ*/ +UINT8 CI_STRU_init(UINT8 *pDataAdd,DSU_CI_STRU *pCIStru) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType) || (DQU_CBTC_CPK == cbtcVersionType) ) + { + rtnValue = CI_STRU_init_DFT(pDataAdd, pCIStru); + } + else if (DQU_CBTC_DG == cbtcVersionType) + { + rtnValue = CI_STRU_init_HLT(pDataAdd, pCIStru); + } + else if ((DQU_CBTC_CC == cbtcVersionType) || (DQU_CBTC_HLT == cbtcVersionType)) + { + rtnValue = CI_STRU_init_CC(pDataAdd, pCIStru); + } + else + { + /*ɴ֧*/ + } + return rtnValue; +} + + +/************************************** +ܣATSϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pATSStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ޸ + +***************************/ +UINT8 ATS_STRU_init_DFT(UINT8 * pDataAdd,DSU_ATS_STRU * pATSStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pATSStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pATSStru->wIndex = ShortFromChar(pData); + pData += 2; + + /*ATS豸ID*/ + pATSStru->wID = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +UINT8 ATS_STRU_init_HLT(UINT8 * pDataAdd, DSU_ATS_STRU * pATSStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pATSStru)) + { + UINT8 * pData = pDataAdd; + UINT16 i = 0; + + /**/ + pATSStru->wIndex = ShortFromChar(pData); + pData += 2; + + /*ATS豸ID*/ + pATSStru->wID = ShortFromChar(pData); + pData += 2; + + /*ATS-VOBCУϢ*/ + pATSStru->dwVersionOfATSToVOBC = LongFromChar(pData); + pData += 4; + + /*ATS-DSUУϢ*/ + pATSStru->dwVersionOfATSToDSU = LongFromChar(pData); + pData += 4; + + /*ATS*/ + pATSStru->dwAdjoinATSCount = *pData; + pData += 1; + + for (i = 0; i<6; i++) + { + /*ATS[1-6]ID*/ + pATSStru->dwAdjoinATSId[i] = ShortFromChar(pData); + pData += 2; + + /*ATS[1-6]ĹУϢ*/ + pATSStru->dwAdjoinATSShareCheckData[i] = LongFromChar(pData); + pData += 4; + + } + rtnValue = 1; + } + return rtnValue; +} + + +/*ýӿ*/ +/*עӶԵĿʶĴmodify by qxt 20170726*/ +/*޸ķֵΪUINT8 ʵָֿ,0=ʧܣ1=ɹ*/ +UINT8 ATS_STRU_init(UINT8 * pDataAdd,DSU_ATS_STRU * pATSStru) +{ + UINT8 cbtcVersionType=0U; + UINT8 rtnValue = 0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType) || (DQU_CBTC_CPK == cbtcVersionType) ) + { + rtnValue = ATS_STRU_init_DFT(pDataAdd, pATSStru); + } + else if ((DQU_CBTC_HLT == cbtcVersionType)||(DQU_CBTC_DG == cbtcVersionType) ) + { + rtnValue = ATS_STRU_init_HLT(pDataAdd, pATSStru); + } + else + { + /*ɴ֧*/ + } + return rtnValue; +} + + +/************************************** +ܣϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pProtectLinkStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עṹӣ + UINT16 wRouteId; · + UINT16 wIncludeAxleSgmtId; ļαţΪ飩 + UINT16 wObsNum; ϰĿ + UINT16 wObsType; ϰ + +***************************/ +UINT8 PROTECT_LINK_STRU_init(UINT8 * pDataAdd,DSU_PROTECT_LINK_STRU * pProtectLinkStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pProtectLinkStru)) + { + UINT8 * pData = pDataAdd; + UINT32 i = 0; + /**/ + pProtectLinkStru->wId = ShortFromChar(pData); + pData += 2; + + /*ļĿ*/ /*---Ϲѧ*/ + pProtectLinkStru->wIncludeAxleSgmtNum = ShortFromChar(pData); + pData += 2; + + for (i = 0; i<4; i++) + { + /*ļα*/ /*---Ϲѧ*/ /*ֶԭ*/ + pProtectLinkStru->wIncludeAxleSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +/*·ͳһϢ*/ +UINT8 CONRESSPEED_STRU_init(UINT8 * pDataAdd, DSU_CONRESSPEED_STRU * pConRESSpeedStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pConRESSpeedStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pConRESSpeedStru->wIndex = ShortFromChar(pData); + pData += 2; + + /*ATS豸ID*/ + pConRESSpeedStru->wSpeed = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +/*·ͳһ¶Ϣ*/ +UINT8 CONGRADE_STRU_init(UINT8 * pDataAdd, DSU_CONGRADE_STRU * pConGradeStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pConGradeStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pConGradeStru->wIndex = ShortFromChar(pData); + pData += 2; + + /*ATS豸ID*/ + pConGradeStru->wGrade = ShortFromChar(pData); + pData += 2; + rtnValue = 1; + } + return rtnValue; +} + + + +/*Ϣ*/ +UINT8 PHYSICAL_SGMT_STRU_init(UINT8 * pDataAdd, DSU_PHYSICAL_SGMT_STRU * pPhysicalSgmtStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPhysicalSgmtStru)) + { + UINT8 * pData = pDataAdd; + UINT16 i = 0; + /*ID*/ + pPhysicalSgmtStru->wId = ShortFromChar(pData); + pData += 2; + + /**/ + for (i = 0; i<16; i++) + { + pPhysicalSgmtStru->szName[i] = *pData; + pData++; + } + + pPhysicalSgmtStru->Type = *pData; + pData++; + + pPhysicalSgmtStru->LjkFlag = *pData; + pData++; + + /*ϵͳID*/ + pPhysicalSgmtStru->BelongAxleSysID = ShortFromChar(pData); + pData += 2; + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣʽα-ʼ +˵[in] pDataAdd ݵַļ + [in] pBlocTrgAreaStru ʼĽṹָ +ֵ0=ʧ 1=ɹ +***************************/ +UINT8 DSU_BLOC_TRG_AREA_STRU_init(UINT8 * pDataAdd, DSU_BLOC_TRG_AREA_STRU * pBlocTrgAreaStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pBlocTrgAreaStru)) + { + UINT8 *pData = pDataAdd; + UINT16 i = 0; + + /*ID*/ + pBlocTrgAreaStru->wId = ShortFromChar(pData); + pData += 2; + + pBlocTrgAreaStru->wAxleSgmtNum = ShortFromChar(pData); + pData += 2; + + /*Ϣ*/ + for (i = 0; i<(pBlocTrgAreaStru->wAxleSgmtNum); i++) + { + pBlocTrgAreaStru->wAxleSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + + +/************************************** +ܣCBTCα-ʼ +˵[in] pDataAdd ݵַļ + [in] pCbtcTrgAreaStru ʼĽṹָ +ֵ0=ʧ 1=ɹ +***************************/ +UINT8 DSU_CBTC_TRG_AREA_STRU_init(UINT8 * pDataAdd, DSU_CBTC_TRG_AREA_STRU * pCbtcTrgAreaStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pCbtcTrgAreaStru)) + { + UINT8 * pData = pDataAdd; + UINT16 i = 0; + + /*ID*/ + pCbtcTrgAreaStru->wId = ShortFromChar(pData); + pData += 2; + + pCbtcTrgAreaStru->wLogicSgmtNum = ShortFromChar(pData); + pData += 2; + + /*Ϣ*/ + for (i = 0; i<(pCbtcTrgAreaStru->wLogicSgmtNum); i++) + { + pCbtcTrgAreaStru->wLogicSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +/*վ̨α*/ +static UINT8 DSU_PLAT_FORM_STRU_init_FAO(UINT8 * pDataAdd, DSU_PLAT_FORM_STRU * pPlatFormStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPlatFormStru)) + { + UINT8 * pData = pDataAdd; + UINT16 i = 0; + /*ID*/ + pPlatFormStru->wId = ShortFromChar(pData); + pData += 2; + + + /*Ĺ*/ + for (i = 0; i<16; i++) + { + pPlatFormStru->szGongLiBiao[i] = *pData; + pData++; + } + pPlatFormStru->wStationId = ShortFromChar(pData); + pData += 2; + + pPlatFormStru->wDir = *pData; + pData++; + + pPlatFormStru->wLogicSgmtNum = ShortFromChar(pData); + pData += 2; + + for (i = 0; i<10; i++) + { + pPlatFormStru->wLogicSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +static UINT8 DSU_PLAT_FORM_STRU_init_CPK(UINT8 * pDataAdd, DSU_PLAT_FORM_STRU * pPlatFormStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPlatFormStru)) + { + UINT8 * pData = pDataAdd; + UINT16 i = 0; + /*ID*/ + pPlatFormStru->wId = ShortFromChar(pData); + pData += 2; + + + /**/ + for (i = 0; i<16; i++) + { + pPlatFormStru->szGongLiBiao[i] = *pData; + pData++; + } + pPlatFormStru->wStationId = ShortFromChar(pData); + pData += 2; + /**/ + pPlatFormStru->wDir = *pData; + pData++; + + /*߼θ*/ + pPlatFormStru->wLogicSgmtNum = ShortFromChar(pData); + pData += 2; + + for (i = 0; i<10; i++) + { + pPlatFormStru->wLogicSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + + /*վ̨*/ + for (i = 0; i<48; i++) + { + pPlatFormStru->szStationName[i] = *pData; + pData++; + } + rtnValue = 1; + } + return rtnValue; +} + +/********************************************** +ܣʼ[վ̨]:ṹ +pDataAddr:׵ַ + +pPlatFormStru:ڴַӦ1 +ֵ:0=ʧܣ1=ɹ +**********************************************/ +static UINT8 DSU_PLAT_FORM_STRU_init_HLT(UINT8 * pDataAdd, DSU_PLAT_FORM_STRU * pPlatFormStru, UINT16 logSgmtIDSumCount) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPlatFormStru)) + { + UINT8 * pData = pDataAdd;/*ֲʱָ*/ + UINT16 i = 0;/*ںִѭı*/ + + /*ID*/ + pPlatFormStru->wId = ShortFromChar(pData); + pData += 2; + + /**/ + for (i = 0; i < 16; i++) + { + pPlatFormStru->szGongLiBiao[i] = *pData; + pData++; + } + + /*վ̨ID*/ + pPlatFormStru->wStationId = ShortFromChar(pData); + pData += 2; + + /**/ + pPlatFormStru->wDir = *pData; + pData++; + + /*߼θ*/ + pPlatFormStru->wLogicSgmtNum = ShortFromChar(pData); + pData += 2; + + /*߼IDϢ*/ + for (i = 0; i < logSgmtIDSumCount; i++) + { + pPlatFormStru->wLogicSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + + /*վ̨*/ + for (i = 0; i < 48; i++) + { + pPlatFormStru->szStationName[i] = *pData; + pData++; + } + rtnValue = 1; + } + return rtnValue; +} + +/*ʽӿ +**޸ļ¼ +**1.ݻͨݽṹV11.0.0޸ģmodify by lmy 20180208 +**2.ݻͨݽṹV18.0.0޸ģm by sds 20200211 +*/ +/*޸ΪUINT8,0=ʧܣ1=ɹ*/ +UINT8 DSU_PLAT_FORM_STRU_init(UINT8 *pDataAdd, DSU_PLAT_FORM_STRU *pPlatFormStru,UINT16 logSgmtIDSumCount) +{ + UINT8 rtnValue = 0U; + UINT8 cbtcVersionType=0U; + cbtcVersionType=GetCbtcSysType(); + + if ((DQU_CBTC_FAO == cbtcVersionType) || (DQU_CBTC_DG == cbtcVersionType)) + { + rtnValue = DSU_PLAT_FORM_STRU_init_FAO(pDataAdd, pPlatFormStru); + } + else if (DQU_CBTC_CPK == cbtcVersionType) + { + rtnValue = DSU_PLAT_FORM_STRU_init_CPK(pDataAdd, pPlatFormStru); + } + else if (DQU_CBTC_HLT == cbtcVersionType) + { + rtnValue = DSU_PLAT_FORM_STRU_init_HLT(pDataAdd, pPlatFormStru,logSgmtIDSumCount); + } + else + { + /*ɴ֧*/ + } + return rtnValue; +} + +/*·,2013.10.23*/ +UINT8 DSU_COME_GO_STRU_init(UINT8 * pDataAdd, DSU_COME_GO_STRU * pComeGoStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pComeGoStru)) + { + UINT8 * pData = pDataAdd; + + /**/ + pComeGoStru->wId = ShortFromChar(pData); + pData += 2; + + /*·1*/ + pComeGoStru->route1Id = ShortFromChar(pData); + pData += 2; + + /*·2*/ + pComeGoStru->route2Id = ShortFromChar(pData); + pData += 2; + + /*·3*/ + pComeGoStru->route3Id = ShortFromChar(pData); + pData += 2; + + /*·4*/ + pComeGoStru->route4Id = ShortFromChar(pData); + pData += 2; + + /*ӦͣID*/ + pComeGoStru->stationId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +/*ű,2014.7.18*/ +UINT8 DSU_FLOOD_GATE_STRU_init(UINT8 * pDataAdd, DSU_FLOOD_GATE_STRU * pFloodGateStru) +{ + UINT8 rtnValue = 0U; + static UINT8 runCount = 0U;/*ִиúĴ жǷΪһν*/ + static UINT8 maxProtectAxisNum = MAX_PROTECT_AXIS_NUM;/*·ʵʵʽӽ*/ + UINT8 i = 0; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pFloodGateStru)) + { + UINT8 * pData = pDataAdd; + + /**/ + pFloodGateStru->wId = ShortFromChar(pData); + pData += 2U; + + /*Link*/ + pFloodGateStru->wFloodGateLinkID = ShortFromChar(pData); + pData += 2U; + + /*ƫ*/ + pFloodGateStru->dwFloodGateLinkoffset = LongFromChar(pData); + pData += 4U; + /**/ + pFloodGateStru->wDir = *pData; + pData += 1U; + + /*жǷһִ һִʱ ʱõһμijɹ*/ + if (0U == runCount) + { + /*ŷ*/ + pFloodGateStru->wProtectAxisNum = ShortFromChar(pData); + pData += 2U; + + if (MAX_PROTECT_AXIS_NUM >= pFloodGateStru->wProtectAxisNum) + { + /*ŷϷȡ*/ + maxProtectAxisNum = pFloodGateStru->wProtectAxisNum; + + for (i = 0U; i < pFloodGateStru->wProtectAxisNum; i++) + { + /*ŷID*/ + pFloodGateStru->wProtectAxisId[i] = ShortFromChar(pData); + pData += 2U; + } + + for (i = 0U; i < MAX_PROTECT_AXIS_NUM; i++) + { + /*Žӽ*/ + pFloodGateStru->wAccessAxisNum = ShortFromChar(pData); + pData += 2U; + /* ϶ȡݣЧֱֵȡȷֵʱ˳ */ + if (DSU_NULL_16 != pFloodGateStru->wAccessAxisNum) + { + break; + } + else + { + /*ŷ+1*/ + maxProtectAxisNum++; + } + } + if (MAX_ACCESS_AXIS_NUM >= pFloodGateStru->wAccessAxisNum) + { + for (i = 0U; i < pFloodGateStru->wAccessAxisNum; i++) + { + /*ŽӽID*/ + pFloodGateStru->wAccessAxisId[i] = ShortFromChar(pData); + pData += 2U; + + /*Žӽνӽ*/ + pFloodGateStru->wAccessAxisDir[i] = *pData; + pData += 1U; + } + + rtnValue = 1; /*ݾϷسɹ*/ + } + } + + /*ִд+1*/ + runCount++; + } + else + { + if (MAX_PROTECT_AXIS_NUM < maxProtectAxisNum) + { + /*òϷ*/ + rtnValue = 0; + } + else + { + /*ŷ*/ + pFloodGateStru->wProtectAxisNum = ShortFromChar(pData); + pData += 2U; + + if (MAX_PROTECT_AXIS_NUM >= pFloodGateStru->wProtectAxisNum) + { + for (i = 0U; i < maxProtectAxisNum; i++) + { + /*ŷϷȡ*/ + /*ŷID*/ + pFloodGateStru->wProtectAxisId[i] = ShortFromChar(pData); + pData += 2U; + } + /*Žӽ*/ + pFloodGateStru->wAccessAxisNum = ShortFromChar(pData); + pData += 2U; + + if (MAX_ACCESS_AXIS_NUM >= pFloodGateStru->wAccessAxisNum) + { + for (i = 0U; i < pFloodGateStru->wAccessAxisNum; i++) + { + /*ŽӽID*/ + pFloodGateStru->wAccessAxisId[i] = ShortFromChar(pData); + pData += 2U; + + /*Žӽνӽ*/ + pFloodGateStru->wAccessAxisDir[i] = *pData; + pData += 1U; + } + + rtnValue = 1; /*ݾϷسɹ*/ + } + } + } + } + + if ((0U == pFloodGateStru->wProtectAxisNum) || (0U == pFloodGateStru->wAccessAxisNum)) + { + rtnValue = 0U; /*λӽΪ00*/ + } + else + { + /*ԭֵ*/ + } + } + return rtnValue; +} + +/*SPKSر*/ +UINT8 DSU_SPKS_BUTTON_STRU_init(UINT8 *pDataAdd, DSU_SPKS_BUTTON_STRU *pSpksButtonStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pSpksButtonStru)) + { + UINT8 *pData = pDataAdd; + UINT16 i = 0; + + /**/ + pSpksButtonStru->wId = ShortFromChar(pData); + pData += 2; + + pSpksButtonStru->wPhysicalSgmtNum = ShortFromChar(pData); + pData += 2; + + /*ID*/ + for (i = 0; iwRelatePhysicalSgmtId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CI*/ + pSpksButtonStru->wManageCI = ShortFromChar(pData); + pData += 2; + /*CI*/ + pSpksButtonStru->wManageVirCI = ShortFromChar(pData); + pData += 2; + + /*ѩվ̨ID*/ + pSpksButtonStru->wPlatFormId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +/*ű*/ +UINT8 DEPOT_GATE_STRU_init(UINT8 *pDataAdd, DSU_DEPOT_GATE_STRU *pDepotGateStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pDepotGateStru)) + { + UINT8 *pData = pDataAdd; + UINT16 i = 0; + + /*ű*/ + pDepotGateStru->wId = ShortFromChar(pData); + pData += 2; + + /*Link*/ + pDepotGateStru->wDepotGateLinkID = ShortFromChar(pData); + pData += 2; + + /*Linkƫ*/ + pDepotGateStru->dwDepotGateLinkoffset = LongFromChar(pData); + pData += 4; + + /*ŶӦAα*/ + pDepotGateStru->wAPhysicalSgmtId = ShortFromChar(pData); + pData += 2; + + /*ŶӦBα*/ + pDepotGateStru->wBPhysicalSgmtId = ShortFromChar(pData); + pData += 2; + + /**/ + pDepotGateStru->sDepotAttribute = ShortFromChar(pData); + pData += 2; + + /*·*/ + pDepotGateStru->wRouteInsideNum = ShortFromChar(pData); + pData += 2; + + /*·*/ + for (i = 0; i<10; i++) + { + pDepotGateStru->wRouteInsideId[i] = ShortFromChar(pData); + pData += 2; + } + + /*·*/ + pDepotGateStru->wRouteOutsideNum = ShortFromChar(pData); + pData += 2; + + /*·*/ + for (i = 0; i<8; i++) + { + pDepotGateStru->wRouteOutsideId[i] = ShortFromChar(pData); + pData += 2; + } + + /*ŶӦSPKS*/ + pDepotGateStru->wSpksNum = ShortFromChar(pData); + pData += 2; + + /*SPKS*/ + for (i = 0; i<4; i++) + { + pDepotGateStru->wSpksId[i] = ShortFromChar(pData); + pData += 2; + } + + /*ӦźŻ*/ + pDepotGateStru->wProectSignalNum = ShortFromChar(pData); + pData += 2; + + /*ӦźŻ*/ + for (i = 0; i<6; i++) + { + pDepotGateStru->wProtectSignalId[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + +/**/ +UINT8 TUNNEL_STRU_init(UINT8 *pDataAdd, DSU_TUNNEL_STRU *pTunnelStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pTunnelStru)) + { + UINT8 *pData = pDataAdd; + + /**/ + pTunnelStru->wId = ShortFromChar(pData); + pData += 2; + + /*link*/ + pTunnelStru->wTunLinkId = ShortFromChar(pData); + pData += 2; + + /*linkƫ*/ + pTunnelStru->dwBeginTunLinkOffset = LongFromChar(pData); + pData += 4; + + /*linkƫ*/ + pTunnelStru->dwEndTunLinkOffset = LongFromChar(pData); + pData += 4; + + rtnValue = 1; + } + return rtnValue; +} + + +/************************************** +ܣZCϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pZCStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עṹ޸ + +***************************/ +UINT8 ZC_STRU_init(UINT8 * pDataAdd, DSU_ZC_STRU * pZCStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pZCStru)) + { + UINT8 * pData = pDataAdd; + UINT16 i = 0; + + /**/ + pZCStru->wIndex = ShortFromChar(pData); + pData += 2; + + /*ZC豸ID*/ + pZCStru->wZCId = ShortFromChar(pData); + pData += 2; + + /*ZC-VOBCУϢ*/ + pZCStru->dwVersionOfZCToVOBC = LongFromChar(pData); + pData += 4; + + /*ZC-DSUУϢ*/ + pZCStru->dwVersionOfZCToDSU = LongFromChar(pData); + pData += 4; + + /*ZC-ATSУϢ*/ + pZCStru->dwVersionOfZCToATS = LongFromChar(pData); + pData += 4; + + /*ZC*/ + pZCStru->dwAdjoinZCCount = *pData; + pData += 1; + + for (i = 0; i<6; i++) + { + /*ZC[1-6]ID*/ + pZCStru->dwAdjoinZCId[i] = ShortFromChar(pData); + pData += 2; + + /*ZC[1-6]ĹУϢ*/ + pZCStru->dwAdjoinZCShareCheckData[i] = LongFromChar(pData); + pData += 4; + + } + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣ࿪Ϣݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pMultiPointStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עĿ add by qxt 20170622 + +***************************/ +UINT8 MULTI_POINT_STRU_init(UINT8 *pDataAdd,DSU_MULTI_SWITCH_STRU *pMultiPointStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pMultiPointStru)) + { + UINT8 *pData = pDataAdd; + UINT16 i = 0; + /**/ + pMultiPointStru->wId = ShortFromChar(pData); + pData += 2; + /**/ + pMultiPointStru->wType = *pData; + pData += 1; + for (i = 0; iwSwitchIds[i] = ShortFromChar(pData); + pData += 2; + /*״̬*/ + pMultiPointStru->wSwitchStates[i] = ShortFromChar(pData); + pData += 2; + } + rtnValue = 1; + } + return rtnValue; +} + + +/********************************************************** +ܣϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pPowerlessZoneStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עݻͨݽṹV12.0.0ӣadd by lmy 20180312 +***********************************************************/ +UINT8 POWERLESS_ZONE_STRU_init(UINT8 *pDataAdd, DSU_POWERLESS_ZONE_STRU *pPowerlessZoneStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPowerlessZoneStru)) + { + UINT8 *pData = pDataAdd; + + /**/ + pPowerlessZoneStru->wId = ShortFromChar(pData); + pData += 2; + /*Link*/ + pPowerlessZoneStru->wOrgnLinkId = ShortFromChar(pData); + pData += 2; + /*Linkƫ*/ + pPowerlessZoneStru->dwOrgnLinkOfst = LongFromChar(pData); + pData += 4; + /*յLink*/ + pPowerlessZoneStru->wTmnlLinkId = ShortFromChar(pData); + pData += 2; + /*յLinkƫ*/ + pPowerlessZoneStru->dwTmnlLinkOfst = LongFromChar(pData); + pData += 4; + /**/ + pPowerlessZoneStru->wProtectDir = *pData; + pData++; + /*ͨٶȣkm/h*/ + pPowerlessZoneStru->wEntrySpeed = ShortFromChar(pData); + pData += 2; + rtnValue = 1; + } + return rtnValue; +} + +/********************************************************** +ܣϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pCarStopStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עݻͨݽṹV15.0.0ӣadd by sds 20181031 +***********************************************************/ +UINT8 CARSTOP_STRU_init(UINT8 *pDataAdd, DSU_CARSTOP_STRU *pCarStopStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pCarStopStru)) + { + UINT8 *pData = pDataAdd; + + /**/ + pCarStopStru->carsId = ShortFromChar(pData); + pData += 2; + + /*Link*/ + pCarStopStru->carsLinkId = ShortFromChar(pData); + pData += 2; + + /*Linkƫ*/ + pCarStopStru->carsLinkOfst = LongFromChar(pData); + pData += 4; + rtnValue = 1; + } + return rtnValue; +} + +/********************************************************** +ܣͣϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pAdjtStationStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עݻͨݽṹV18.0.0ӣadd by sds 20200211 +***********************************************************/ +UINT8 ADJTSTATION_STRU_init(UINT8 *pDataAdd, DSU_AdjtStation_STRU *pAdjtStationStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pAdjtStationStru)) + { + UINT8 *pData = pDataAdd; + UINT16 i = 0; + + /**/ + pAdjtStationStru->wId = ShortFromChar(pData); + pData += 2; + + /*·*/ + pAdjtStationStru->wLineId = ShortFromChar(pData); + pData += 2; + + /*߼վ̨*/ + pAdjtStationStru->wLogicStaId = LongFromChar(pData); + pData += 4; + + for (i = 0; i < 4; i++) + { + pAdjtStationStru->destID[i] = *pData; + pData++; + } + + for (i = 0; i < 16; i++) + { + pAdjtStationStru->trackID[i] = *pData; + pData++; + } + + for (i = 0; i < 20; i++) + { + pAdjtStationStru->stationID[i] = *pData; + pData++; + } + + pAdjtStationStru->adjtLineStaId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + + } + return rtnValue; +} + +/************************************************************************** +* : PSCϢݽṹʼ +* : UINT8 *pDataAdd ݵַļ +* : +* : DSU_PSC_STRU *pPSCStru ʼĽṹָ +* ȫֱ: +* ֵ: 0=ʧ 1=ɹ +* ޸ļ¼: +* 1PSCṹʼ m by sds 2020-8-18 +**************************************************************************/ +UINT8 PSC_STRU_init(UINT8 *pDataAdd, DSU_PSC_STRU *pPSCStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPSCStru)) + { + UINT8 *pData = NULL; + UINT16 loopIndex = 0; + pData = pDataAdd; + + /**/ + pPSCStru->wId = ShortFromChar(pData); + pData += 2; + + /*PSCID*/ + pPSCStru->wDevID = ShortFromChar(pData); + pData += 2; + + /*PSD ID*/ + for (loopIndex = 0; loopIndex < 4; loopIndex++) + { + pPSCStru->wContainPSDID[loopIndex] = ShortFromChar(pData); + pData += 2; + } + + /*CI ID*/ + pPSCStru->wManagerCIID = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣṹʼ +˵[in] pData ݵַļ +[out] pLinkStrc ʼĽṹָ +ֵ0=ʧ 1=ɹ +עṹѾ +***************************/ +UINT8 EA_STRU_init(UINT8 * pDataAdd, DSU_EMAP_EA_STRU* pEaStrc) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pEaStrc)) + { + UINT8 * pData = pDataAdd; + UINT8 chIndex = 0U; + + /**/ + pEaStrc->wId = ShortFromChar(pData); + pData += 2U; + + /*߽*/ + pEaStrc->chStartLinkNum = *pData; + pData++; + + for (chIndex = 0U; chIndex < 5u; chIndex++) + { + /* ߽link */ + pEaStrc->szStartLinkId[chIndex] = ShortFromChar(pData); + pData += 2U; + + /* ߽ѯյ߽߼ */ + pEaStrc->szStartLinkDir[chIndex] = *pData; + pData++; + } + + /*յ߽*/ + pEaStrc->chEndLinkNum = *pData; + pData++; + + for (chIndex = 0U; chIndex < 5u; chIndex++) + { + /* յ߽link */ + pEaStrc->szEndLinkId[chIndex] = ShortFromChar(pData); + pData += 2U; + + /* յ߽ѯ߽߼ */ + pEaStrc->szEndLinkDir[chIndex] = *pData; + pData++; + } + rtnValue = 1; + } + return rtnValue; +} + +/************************************** +ܣ߼SPKSṹʼ +˵[in] pData ݵַļ +[out] pLinkStrc ʼĽṹָ +ֵ0=ʧ 1=ɹ +עby cgh 20230919 ߼SPKSʼ +***************************/ +UINT8 DSU_LOGSEC_SPKS_BUTTON_STRU_init(UINT8* pDataAdd, DSU_LOGSEC_SPKS_BUTTON_STRU* pSpksButtonStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pSpksButtonStru)) + { + UINT8* pData = pDataAdd; + UINT16 i = 0; + + /**/ + pSpksButtonStru->wId = ShortFromChar(pData); + pData += 2; + + pSpksButtonStru->wLogSecNum = ShortFromChar(pData); + pData += 2; + + /*߼ID*/ + for (i = 0; i < DSU_SPKS_STRU_LOGSECID; i++) + { + pSpksButtonStru->wRelateLogSecId[i] = ShortFromChar(pData); + pData += 2; + } + + /*CI*/ + pSpksButtonStru->wManageCI = ShortFromChar(pData); + pData += 2; + /*CI*/ + pSpksButtonStru->wManageVirCI = ShortFromChar(pData); + pData += 2; + + /*ѩվ̨ID*/ + pSpksButtonStru->wPlatFormId = ShortFromChar(pData); + pData += 2; + + rtnValue = 1; + } + return rtnValue; +} diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquStructInit.h b/TSCP/src/dqu_common/dqu_emap_common/dquStructInit.h new file mode 100644 index 0000000..a89686e --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquStructInit.h @@ -0,0 +1,476 @@ +/************************************************************************ +* +* ļ dquStructInit.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2009.11.21 +* +* ݲѯṹͷļ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#include "Convert.h" +#include "dsuStruct.h" + +#ifndef DQU_STRUCT_INIT_H +#define DQU_STRUCT_INIT_H + + +#ifdef __cplusplus +extern "C" { +#endif +/************************************** +ܣlinkṹʼ +˵[in] pDataAdd ݵַļ + [out] pLinkStrc ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ + +UINT8 LINK_STRU_init(UINT8 *pDataAdd,DSU_LINK_STRU*pLinkStrc); + + + +/************************************** +ܣݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pPointStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wManageZC; ZC + UINT16 wManagePhysicalCI; CI + UINT16 wManageLogicCI; ߼CI +***************************/ +UINT8 POINT_STRU_init(UINT8 *pDataAdd,DSU_POINT_STRU *pPointStru); + +/************************************** +ܣźŻݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pSignalStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עĿ + UINT16 wManageZC; ZC + UINT16 wManagePhysicalCI; CI + UINT16 wManageLogicCI; ߼CI +***************************/ +UINT8 SIGNAL_STRU_init(UINT8 *pDataAdd,DSU_SIGNAL_STRU *pSignalStru); + + +/************************************** +ܣӦݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pBaliseStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עýṹĶ +***************************/ +UINT8 BALISE_STRU_init(UINT8 *pDataAdd,DSU_BALISE_STRU *pBaliseStru); + + +/************************************** +ܣݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pAxleStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עýṹĶ +***************************/ +UINT8 AXLE_STRU_init(UINT8 *pDataAdd,DSU_AXLE_STRU *pAxleStru); + + +/************************************** +ܣȫݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pScreenStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wManageLogicCI; ߼CI +***************************/ +UINT8 SCREEN_STRU_init(UINT8 *pDataAdd,DSU_SCREEN_STRU *pScreenStru); + + +/************************************** +ܣͣťݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pEmergStopStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wManageLogicCI; ߼CI +***************************/ +UINT8 EMERG_STOP_STRU_init(UINT8 *pDataAdd,DSU_EMERG_STOP_STRU *pEmergStopStru); + + +/************************************** +ܣͣϢݽṹʼ(ԭվ̨) +˵[in] pDataAdd ݵַļ + [out] pStationStru ʼĽṹָ +ֵ0=ʧ 1=ɹ +עṹ + UINT32 dwStatTmnlLinkOfst; վ̨Χֹlinkƫ + UINT16 wManagePhysicalCI CI + UINT16 wManageLogicCI; ߼CI +***************************/ +UINT8 STATION_STRU_init(UINT8 *pDataAdd,DSU_STATION_STRU *pStationStru); + +/************************************** +ܣͣݽṹʼ +˵[in ] pDataAdd ݵַļ + [out] pStoppointStru ʼĽṹָ + [out] realLoadRowLen ʵʼصͣϢ + [in ] stopPointAttr ʹõͣϢ +ֵ0=ʧ 1= 2=㵫ָǿ +עṹ + UINT16 wMinStopTime; Сͣվʱ + UINT16 wMaxStopTime; ͣվʱ + UINT16 wStopTime; Ĭͣվʱ +޸ļ¼m by sds 2019-10-22 VOBCV15.0ͣݹˣֻͣԵ +***************************/ +UINT8 STOPPOINT_STRU_init(UINT8 *pDataAdd,DSU_STOPPOINT_STRU *pStoppointStru,UINT32 *realLoadRowLen,UINT32 stopPointAttr); + +/************************************** +ܣݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pAxleSgmtStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wMiddleLinkId; мlink + UINT32 dwOrgnLinkOfst; linkƫ + UINT32 dwTmnlLinkOfst; յlinkƫ + UINT16 wOrgnRelatPointId; + UINT16 wOrgnMainAxleSgmtId; Ӷλα + UINT16 wOrgnSideAxleSgmtId; ӷλα + UINT16 wTmnlRelatPointId; յ + UINT16 wTmnlMainAxleSgmtId; յӶλα + UINT16 wTmnlSideAxleSgmtId; յӷλα + UINT16 wRelatAxleSgmtNum; Ŀ + UINT16 wRelatAxleSgmtId[3]; α + UINT16 wManageZC; ZC + UINT16 wManagePhysicalCI; CI + +***************************/ +UINT8 AXLE_SGMT_STRU_init(UINT8 *pDataAdd,DSU_AXLE_SGMT_STRU *pAxleSgmtStru); + +/************************************** +ܣ߼ݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pLogicSgmtStru ʼĽṹָ +ֵ0ʧܣ1ɹ +עṹ + UINT16 wMiddleLinkId; ߼мlink + UINT16 wMainOrgnLogicSgmtId; ǰ߼εı + UINT16 wMainTmnlLogicSgmtId; ں߼εı +***************************/ +UINT8 LOGIC_SGMT_STRU_init(UINT8 *pDataAdd,DSU_LOGIC_SGMT_STRU *pLogicSgmtStru); + +/************************************** +ܣ·ݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pRouteStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wCBTCAccessLink1RelatePointNum; CBTCӽ1Ŀ + UINT16 wCBTCAccessLink1RelatePointId[]; CBTCӽ1 + UINT16 wCBTCAccessLink1RelatePointSta[]; CBTCӽ1״̬ + UINT16 wCBTCAccessLink2RelatePointNum; CBTCӽ2Ŀ + UINT16 wCBTCAccessLink2RelatePointId[]; CBTCӽ2 + UINT16 wCBTCAccessLink2RelatePointSta[]; CBTCӽ2״̬ + UINT16 wCBTCAccessLink3RelatePointNum; CBTCӽ3Ŀ + UINT16 wCBTCAccessLink3RelatePointId[]; CBTCӽ3 + UINT16 wCBTCAccessLink3RelatePointSta[]; CBTCӽ3״̬ + UINT16 wCBTCAccessLink4RelatePointNum; CBTCӽ4Ŀ + UINT16 wCBTCAccessLink4RelatePointId[]; CBTCӽ4 + UINT16 wCBTCAccessLink4RelatePointSta[]; CBTCӽ4״̬ + UINT16 wIncludeAxleSgmtNum; ·ļĿ + UINT16 wIncludeAxleSgmtId[8]; ļα + UINT16 wAxleSgmtLockStatus[8]; ļ״̬ + UINT16 wIncludeLinkNum; linkĿ + UINT16 wLinkId[14]; link + UINT16 wObsNum; ·ϰ + UINT16 wObsType[8]; ϰ + UINT16 wObsID[8]; ϰID + UINT16 wObsNeedLockStatus[8]; ϰҪ״̬ +***************************/ +UINT8 ROUTE_STRU_init(UINT8 *pDataAdd,DSU_ROUTE_STRU *pRouteStru); + +/************************************** +ܣ߼ݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pProtectLinkStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + UINT16 wRouteId; · + UINT16 wIncludeAxleSgmtId; ļα + UINT16 wObsNum; ϰĿ + UINT16 wObsType; ϰ +***************************/ + +UINT8 LOGIC_SGMT_STRU_init(UINT8 *pDataAdd,DSU_LOGIC_SGMT_STRU *pLogicSgmtStru); + +/************************************** +ܣʽӽϢݽṹʼ(ԭBLOCģʽӽα) +˵[in] pDataAdd ݵַļ + [out] pBlocAccessLinkStruʼĽṹָ +ֵ0=ʧܣ 1=ɹ +עṹ + +***************************/ +UINT8 BLOC_ACCESS_LINK_STRU_init(UINT8 *pDataAdd, DSU_BLOC_ACCESS_LINK_STRU *pBlocAccessLinkStru); + + +/************************************** +ܣCBTCģʽӽϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out] pCBTCAccessLinkStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + +***************************/ +UINT8 CBTC_ACCESS_LINK_STRU_init(UINT8 *pDataAdd, DSU_CBTC_ACCESS_LINK_STRU *pCBTCAccessLinkStru); + +/************************************** +ܣ¶ݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pGradeStruʼĽṹָ +ֵ0=ʧܣ0=ɹ +עṹӣ +UINT32 dwGradeLength; ¶ȳ +UINT16 wIncludeLinkId[3]; ¶·мlink + +***************************/ +UINT8 GRADE_STRU_init(UINT8 *pDataAdd,DSU_GRADE_STRU *pGradeStru); +/************************************** +ܣ·̬ݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pStaticResSpeedStruʼĽṹָ +ֵ0ʧ 1ɹ +עṹ޸ + +***************************/ +UINT8 STATIC_RES_SPEED_STRU_init(UINT8 *pDataAdd,DSU_STATIC_RES_SPEED_STRU *pStaticResSpeedStru); + + +/************************************** +ܣĬгݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pDefaultrouteStruʼĽṹָ +ֵ0ʧ 1=ɹ +עṹ + UINT16 wCurrentPlatformId; ǰվ̨ + UINT16 wCurrentPlatformFlag; ǰվ̨־λ + +***************************/ +UINT8 DEFAULTROUTE_STRU_init(UINT8 *pDataAdd,DSU_DEFAULTROUTE_STRU *pDefaultrouteStru); +/************************************** +ܣվӪݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pRunLevelStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + + +***************************/ +UINT8 RUN_LEVEL_STRU_init(UINT8 *pDataAdd,DSU_RUN_LEVEL_STRU *pRunLevelStru); + +/************************************** +ܣ˳CBTCݽṹʼ(ԭ˳·) +˵[in] pDataAdd ݵַļ + [out]pExitRouteStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ + +***************************/ +UINT8 EXIT_ROUTE_STRU_init(UINT8 *pDataAdd,DSU_EXIT_ROUTE_STRU *pExitRouteStru); +/************************************** +ܣCBTCݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pTrainLineStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עṹ + +***************************/ +UINT8 TRAIN_LINE_STRU_init(UINT8 *pDataAdd,DSU_TRAIN_LINE_STRU *pTrainLineStru); +/************************************** +ܣ۷ݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pARStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹԭ۷۷˳ϲ + +***************************/ +UINT8 AR_STRU_init(UINT8 *pDataAdd,DSU_AR_STRU *pARStru); +/************************************** +ܣZCݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pZCComZoneStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹԭ۷۷˳ϲ + +***************************/ +UINT8 ZC_COM_ZONE_STRU_init(UINT8 *pDataAdd,DSU_ZC_COM_ZONE_STRU *pZCComZoneStru); + +/************************************** +ܣCIϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pCIStruʼĽṹָ +ֵ +עṹ޸ + +***************************/ +UINT8 CI_STRU_init(UINT8 *pDataAdd,DSU_CI_STRU *pCIStru); + +/************************************** +ܣATSϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pATSStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹ޸ + +***************************/ +UINT8 ATS_STRU_init(UINT8 *pDataAdd,DSU_ATS_STRU *pATSStru); + +/************************************** +ܣϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pProtectLinkStruʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹӣ + UINT16 wRouteId; · + UINT16 wIncludeAxleSgmtId; ļαţΪ飩 + UINT16 wObsNum; ϰĿ + UINT16 wObsType; ϰ + +***************************/ +UINT8 PROTECT_LINK_STRU_init(UINT8 *pDataAdd,DSU_PROTECT_LINK_STRU *pProtectLinkStru); + +/*·ͳһϢ*/ +UINT8 CONRESSPEED_STRU_init(UINT8 *pDataAdd, DSU_CONRESSPEED_STRU *pConRESSpeedStru); + +/*·ͳһ¶Ϣ*/ +UINT8 CONGRADE_STRU_init(UINT8 *pDataAdd, DSU_CONGRADE_STRU *pConGradeStru); + +UINT8 ZC_DIVID_POINT_STRU_init(UINT8 *pDataAdd,DSU_ZC_DIVID_POINT_STRU *pZCDividPointStru); + +/*Ϣ*/ +UINT8 PHYSICAL_SGMT_STRU_init(UINT8 *pDataAdd, DSU_PHYSICAL_SGMT_STRU *pPhysicalSgmtStru); + +/************************************** +ܣʽα-ʼ +˵[in] pDataAdd ݵַļ + [in] pBlocTrgAreaStru ʼĽṹָ +ֵ0=ʧ 1=ɹ +***************************/ +UINT8 DSU_BLOC_TRG_AREA_STRU_init(UINT8 *pDataAdd, DSU_BLOC_TRG_AREA_STRU *pBlocTrgAreaStru); + +/************************************** +ܣCBTCα-ʼ +˵[in] pDataAdd ݵַļ + [in] pCbtcTrgAreaStru ʼĽṹָ +ֵ0=ʧ 1=ɹ +***************************/ +UINT8 DSU_CBTC_TRG_AREA_STRU_init(UINT8 *pDataAdd, DSU_CBTC_TRG_AREA_STRU *pCbtcTrgAreaStru); + +/*վ̨α*/ +UINT8 DSU_PLAT_FORM_STRU_init(UINT8 *pDataAdd, DSU_PLAT_FORM_STRU *pPlatFormStru,UINT16 logSgmtIDSumCount); + +/*·*/ +UINT8 DSU_COME_GO_STRU_init(UINT8 *pDataAdd, DSU_COME_GO_STRU *pComeGoStru); + +/*ű,2014.7.18*/ +UINT8 DSU_FLOOD_GATE_STRU_init(UINT8 *pDataAdd, DSU_FLOOD_GATE_STRU *pFloodGateStru); + +/*SPKSر*/ +UINT8 DSU_SPKS_BUTTON_STRU_init(UINT8 *pDataAdd, DSU_SPKS_BUTTON_STRU *pSpksButtonStru); + +/*ű*/ +UINT8 DEPOT_GATE_STRU_init(UINT8 *pDataAdd, DSU_DEPOT_GATE_STRU *pDepotGateStru); + +/**/ +UINT8 TUNNEL_STRU_init(UINT8 *pDataAdd, DSU_TUNNEL_STRU *pTunnelStru); + +/*ZCϢݽṹʼ*/ +UINT8 ZC_STRU_init(UINT8 *pDataAdd,DSU_ZC_STRU *pZCStru); + +/************************************** +ܣ࿪Ϣݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pMultiPointStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עĿ add by qxt 20170622 + +***************************/ +UINT8 MULTI_POINT_STRU_init(UINT8 *pDataAdd,DSU_MULTI_SWITCH_STRU *pMultiPointStru); + + + +/********************************************************** +ܣϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pMultiPointStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עݻͨݽṹV12.0.0ӣadd by lmy 20180312 +***********************************************************/ +UINT8 POWERLESS_ZONE_STRU_init(UINT8 *pDataAdd, DSU_POWERLESS_ZONE_STRU *pPowerlessZoneStru); + +/********************************************************** +ܣϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pCarStopStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עݻͨݽṹV15.0.0ӣadd by sds 20181031 +***********************************************************/ +UINT8 CARSTOP_STRU_init(UINT8 *pDataAdd, DSU_CARSTOP_STRU *pCarStopStru); + +/********************************************************** +ܣͣϢݽṹʼ +˵[in] pDataAdd ݵַļ + [out]pAdjtStationStruʼĽṹָ +ֵ0=ʧ 1=ɹ +עݻͨݽṹV18.0.0ӣadd by sds 20200211 +***********************************************************/ +UINT8 ADJTSTATION_STRU_init(UINT8 *pDataAdd, DSU_AdjtStation_STRU *pAdjtStationStru); + +/************************************************************************** +* : PSCϢݽṹʼ +* : UINT8 *pDataAdd ݵַļ +* : +* : DSU_PSC_STRU *pPSCStru ʼĽṹָ +* ȫֱ: +* ֵ: 0=ʧ 1=ɹ +* ޸ļ¼: +* 1PSCṹʼ m by sds 2020-8-18 +**************************************************************************/ +UINT8 PSC_STRU_init(UINT8 *pDataAdd, DSU_PSC_STRU *pPSCStru); + +/************************************** +ܣṹʼ +˵[in] pData ݵַļ +[out] pLinkStrc ʼĽṹָ +ֵ0=ʧ 1=ɹ +עṹѾ +***************************/ +UINT8 EA_STRU_init(UINT8 * pDataAdd, DSU_EMAP_EA_STRU* pEaStrc); + +/************************************** +ܣ·ݽṹʼ- +˵[in] pDataAdd ݵַļ +[out] pRouteStru ʼĽṹָ +ֵ0 ʧ 1 ɹ +޸˵ +ݽṹ +***************************/ +static UINT8 ROUTE_STRU_init_CC(UINT8* pDataAdd, DSU_ROUTE_STRU* pRouteStru); + +/************************************** +ܣ߼SPKSṹʼ +˵[in] pData ݵַļ +[out] pLinkStrc ʼĽṹָ +ֵ0=ʧ 1=ɹ +עby cgh 20230919 ߼SPKSʼ +***************************/ +UINT8 DSU_LOGSEC_SPKS_BUTTON_STRU_init(UINT8* pDataAdd, DSU_LOGSEC_SPKS_BUTTON_STRU* pSpksButtonStru); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/dqu_common/dqu_emap_common/dquVobcCommonStru.h b/TSCP/src/dqu_common/dqu_emap_common/dquVobcCommonStru.h new file mode 100644 index 0000000..3b55cc4 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dquVobcCommonStru.h @@ -0,0 +1,93 @@ + +/************************************************************************ +* +* ļ dquVobcCommonStru.h +* Ȩ˵ ؿƼƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.08 +* +* VOBCӦùýṹļ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef DQU_VOBC_COMMON_STRUCT_H +#define DQU_VOBC_COMMON_STRUCT_H + + +#include "CommonTypes.h" + + +#define MAX_AXISSEC_SUM_IN_LOGSEC ((UINT8)8) /*߼ιļε*//*add 20220920 TIOC5.0*/ +#define MAX_LOGSEC_INCLUDE_SWITCH_NUM ((UINT16)9) /*߼ΰĵֵ*//* add 20220922 TIOC5.0*/ +#define MAX_LOGSEC_INCLUDE_LINK_NUM ((UINT16)8) /*߼ΰLINKֵ*//* add 20220922 TIOC5.0*/ +#define SW_LINK_DEFAUT ((UINT8)0) /*ǵlink*//* add 20220922 TIOC5.0*/ +#define SW_LINK_CON ((UINT8)1) /*link*//* add 20220922 TIOC5.0*/ +#define SW_LINK_MAIN ((UINT8)2) /*λlink*//* add 20220922 TIOC5.0*/ +#define SW_LINK_SIDE ((UINT8)3) /*λlink*//* add 20220922 TIOC5.0*/ + +#ifdef __cplusplus +extern "C" { +#endif + + +/*λýṹ*/ +typedef struct +{ + UINT16 Lnk;/*Link*/ + UINT32 Off;/*Offset*/ + UINT8 Dir;/**/ +}LOD_STRU; + + +/*ϢID״̬*/ +typedef struct{ + UCHAR PointType; /*ͣԿDz*/ + UINT16 PointId; /*ID*/ + UINT16 Lnk; /*ϰκţD_ OBSTACLEL*/ + UINT32 Off; /*ϰƫD_ OBSTACLEO*/ + UCHAR PointStatus; /*״̬*/ + UCHAR PointExpectedStatus; /*Ӧõ״̬*/ +}DQU_POINT_STATUS_STRU; + + +/*ʱٽṹ*/ +typedef struct +{ + UINT16 TsrSpd;/*ֵ*/ + UINT16 TsrHeadLnk;/*TSRLink*/ + UINT32 TsrHeadOff;/*TSROffset*/ + UINT16 TsrTailLnk;/*TSRյLink*/ + UINT32 TsrTailOff;/*TSRյOffset*/ +}TSR_STRU; + +/* ·Ϣ */ +typedef struct +{ + UINT8 cLinkCnt; /*link*/ + UINT16 szLinkId[MAX_LOGSEC_INCLUDE_LINK_NUM]; /*·ID*/ +}PATH_LINK_STRU; + +/*߼ΰṹ*/ +typedef struct +{ + UINT8 SwitchNum; + UINT16 SwitchId[MAX_LOGSEC_INCLUDE_SWITCH_NUM]; /*ID*/ + UINT8 SwitchPosition[MAX_LOGSEC_INCLUDE_SWITCH_NUM]; /*λ*/ +} LOGSEC_SWITCH_STRU; + +typedef struct +{ + UINT16 wLinkId; /* LINK */ + UINT16 wPointType; /* ˵ */ + UINT16 wPointId; /* ˵ */ + UINT16 wMainLinkId; /* link */ + UINT16 wSideLinkId; /* ڲlink */ +}LINK_POINT_DATA_STRU,*pLinkPoint; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/dqu_common/dqu_emap_common/dsuEmapDefine.h b/TSCP/src/dqu_common/dqu_emap_common/dsuEmapDefine.h new file mode 100644 index 0000000..6d2ebd2 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dsuEmapDefine.h @@ -0,0 +1,328 @@ +/************************************************************************ +* +* ļ dsuEmapDefine.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* ӵͼصĺ궨 +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef DSU_EMAP_DEFINE +#define DSU_EMAP_DEFINE + +#include "CommonTypes.h" + +/*linkϢṹ ---- 3(һԤ)*/ +/*link߼ */ +#define EMAP_SAME_DIR 0x55U /*link߼ͬ*/ +#define EMAP_CONVER_DIR 0xaaU /*link߼෴*/ + +/*·ѯ */ +#define EMAP_PATH_SAME_DIR 0x55 /*·ѯͬ*/ +#define EMAP_PATH_CONVER_DIR 0xaa /*·ѯ෴*/ + +/*Link·Ϣ*/ +#define EMAP_LINK_LINE_UP 0x55 /*·*/ +#define EMAP_LINK_LINE_DOWN 0xaa /*·*/ +/*linkյ˵*/ +#define EMAP_END_DOT 1U /*·յ*/ +#define EMAP_AXLE_DOT 2U /**/ +#define EMAP_POINT_DOT 3U /**/ + /*״̬*/ +#define EMAP_POINT_STATUS_MAIN 1 /*λ״̬*/ +#define EMAP_POINT_STATUS_SIDE 2 /*λ״̬*/ +#define EMAP_POINT_STATUS_LOSE 3 /*ʧ״̬*/ + + +/*źŻϢṹ --- 4+3*/ +/*źŻϢ*/ +#define EMAP_SIGNAL_TYPE_TWO_SHOT 1 /*ʾźŻ*/ +#define EMAP_SIGNAL_TYPE_TWO_TALL 2 /*ʾźŻ*/ +#define EMAP_SIGNAL_TYPE_THREE_SHOT 3 /*ʾźŻ*/ +#define EMAP_SIGNAL_TYPE_THREE_TALL 4 /*ʾźŻ*/ +/*źŻϢ*/ +#define EMAP_SIGNAL_TYPE_CZ 1 /*վźŻ*/ +#define EMAP_SIGNAL_TYPE_FH 2 /*źŻ*/ +#define EMAP_SIGNAL_TYPE_ZD 3 /*赲źŻ*/ +#define EMAP_SIGNAL_TYPE_QJ 4 /*ָźŻ*/ +#define EMAP_SIGNAL_TYPE_JD 5 /*źŻ*/ +#define EMAP_SIGNAL_TYPE_CD 6 /*źŻ*/ +#define EMAP_SIGNAL_TYPE_DC 7 /*źŻ*/ +#define EMAP_SIGNAL_TYPE_JK 8 /*źŻ*/ +#define EMAP_SIGNAL_TYPE_CK 9 /*źŻ*/ +/*źŻ*/ /*---link߼ */ +/*źŻ־λ*/ +#define EMAP_SIGNAL_PASS_CLOSE 0x55 /*ǿźŻ־*/ +#define EMAP_SIGNAL_PASS_OPEN 0xaa /*źŻ־*/ +/*źŻǷҪжϴ*/ +#define EMAP_SIGNAL_ENABLE_TRUE 0x55 /*źŻҪжϴź*/ +#define EMAP_SIGNAL_ENABLE_FALSE 0xAA /*źŻҪжϴź*/ +/*źŻ̬״̬*/ +#define EMAP_SIGNAL_SHINE_DEFAULT_TRUE 0x01 /*źŻ̬*/ +#define EMAP_SIGNAL_SHINE_DEFAULT_FALSE 0x00 /*źŻ̬*/ +/*CBTCгӽʱźŻ*/ +#define EMAP_SIGNAL_SHINE_CBTC_TRUE 0x01 /*CBTCгӽʱ*/ +#define EMAP_SIGNAL_SHINE_CBTC_FALSE 0x00 /*CBTCгӽʱ*/ + + +/*ӦϢṹ --- 7*/ /*Ԥ*/ + /*ӦID*/ +#define EMAP_BALISE_ID_LOOP (UINT32)0x00000001 /*Ӧ*/ +#define EMAP_BALISE_ID_FB (UINT32)0x00000002 /*̶Ӧ*/ +#define EMAP_BALISE_ID_VB (UINT32)0x00000004 /*ɱӦ*/ +#define EMAP_BALISE_ID_IB (UINT32)0x00000008 /*Ӧ*/ + /*Ӧ÷*/ /*---link߼ */ + /*ӦϢ*/ +#define EMAP_WHEEL_CALI_BALI (UINT16)0x0001 /*УӦ*/ +#define EMAP_FIXED_BALI (UINT16)0x0002 /*̶Ӧ*/ +#define EMAP_VARIABLE_DATA_BALI (UINT16)0x0004 /*ɱӦ*/ +#define EMAP_INFILLED_BALI (UINT16)0x0008 /*Ӧ*/ +#define EMAP_LOOP_BALI (UINT16)0x0010 /**/ +#define EMAP_ATO_BALI (UINT16)0x0020 /*ATOӦ*/ +#define EMAP_LOC_CALI_BALI (UINT16)0x0040 /*λУӦ*/ +#define EMAP_SLEEP_AWAKE_BALI (UINT16)0x0080 /*ӦݺϿӣ20180208 lmy*/ + /*ӦӦ*/ /*---link߼ */ + /*Ӧ״̬*/ /*---״̬ */ + /*յӦ*/ /*---link߼ */ + /*յӦ״̬*/ /*---״̬ */ + + + + +/*Ϣṹ --- 1Ԥ*/ + /**/ +#define EMAP_AXLE_PUTONG 1 /*ͨ*/ +#define EMAP_AXLE_CHAOXIANJUEYUAN 2 /*޾Ե*/ +#define EMAP_AXLE_FANGZHENG 3 /**/ +#define EMAP_AXLE_JUEYUANJIE 4 /*Ե*/ + +/*ȫϢṹ --- 1*/ /*Ԥ*/ + /*Թlink߼ķλң*/ +#define EMAP_PSD_LOGIC_LEFT 0x55 /*λڹlink߼*/ +#define EMAP_PSD_LOGIC_RIGHT 0xaa /*λڹlink߼Ҳ*/ + +/*ͣϢṹ --- 3*/ +/*ͣԶ*/ +#define EMAP_STATION_AREA 0x01 /*վ̨*/ +#define EMAP_REVERT_AREA 0x02 /*۷*/ +#define EMAP_TRANSFORM_AREA 0x04 /*ת*/ +#define EMAP_DEPOT_AREA 0x08 /*ͣ*/ +#define EMAP_SLEEP_AREA 0x10 /*߹*/ +#define EMAP_GARAGEA_B_AREA 0x20 /*AB߱ʶ*/ +#define EMAP_CLEAR_AREA 0x40 /*վ̨*/ +#define EMAP_SINGLE_DOUBLE_GARAGE_AREA 0x100 /*/˫λʶλȡ0˫λȡ1*/ +#define EMAP_GARAGEB1B2_AREA 0x200 /*B1/B2߱ʶB1ȡ0B2ȡ1*/ +#define EMAP_ALLOW_COLLISION_AREA 0x400 /*Ƿײʶ*/ + +#define EMAP_VC_STATION_AREA 0x00080000u /* վ̨ */ + +/*ͣſŲʽ*/ +#define EMAP_DOOR_NO_OPEN 0 /*Ҿ*/ +#define EMAP_DOOR_LEFT_OPEN 1 /*ŷ*/ +#define EMAP_DOOR_RIGHT_OPEN 2 /*ŷ*/ +#define EMAP_DOOR_LEFT_RIGHT_OPEN 3 /*ŷź*/ +#define EMAP_DOOR_RIGHT_LEFT_OPEN 4 /*ŷҺ*/ +#define EMAP_DOOR_BOTH_OPEN 5 /*ͬʱ*/ +/*ͣŹŲʽ*/ +#define EMAP_DOOR_NO_CLOSE 0 /*Ҿ*/ +#define EMAP_DOOR_LEFT_CLOSE 1 /*ŷ*/ +#define EMAP_DOOR_RIGHT_CLOSE 2 /*ŷ*/ +#define EMAP_DOOR_LEFT_RIGHT_CLOSE 3 /*ŷź*/ +#define EMAP_DOOR_RIGHT_LEFT_CLOSE 4 /*ŷҺ*/ +#define EMAP_DOOR_BOTH_CLOSE 5 /*ͬʱ*/ + +/*ͣϢṹ --- 4*/ +/*ͣԶ add by sds 2019-10-22 2顢7顢ззϴͣ˳ϴͣ*/ +#define EMAP_OPERAT_STOP_POINT 0x01 /*վ̨Ӫͣ*/ +#define EMAP_EXITROUTE_STOP_POINT 0x02 /*˳ͣ㣨CBTCCBTC)*/ +#define EMAP_REVERT_STOP_POINT 0x04 /*۷ͣ*/ +#define EMAP_SIGNAL_STOP_POINT 0x08 /*վźŻͣ(۷)*/ /*ͨͣ*/ +#define EMAP_REVERTEND_STOP_POINT 0x10 /*۷ͣ*/ +#define EMAP_SWITCH_STOP_POINT 0x20 /*ת(Сվ̨)ͣ㣨CBTCCBTC*/ +#define EMAP_SLEEP_AWAKE_STOP_POINT 0x0040 /*߻ͣ*/ +#define EMAP_CLEAN_REQ_STOP_POINT 0x0080 /*ϴͣ*/ +#define EMAP_CLEAN_FRONT_STOP_POINT 0x0100 /*ǰϴͣ*/ +#define EMAP_CLEAN_END_STOP_POINT 0x0200 /*ϴͣ*/ +#define EMAP_PASS_REQ_STOP_POINT 0x0400 /*ͨͣ*/ +#define EMAP_4GROUP_STOP_POINT 0x0800 /*4ͣ*/ +#define EMAP_6GROUP_STOP_POINT 0x1000 /*6ͣ*/ +#define EMAP_8GROUP_STOP_POINT 0x8000 /*8ͣ*/ +#define EMAP_2GROUP_STOP_POINT 0x100000 /*2ͣ*/ +#define EMAP_7GROUP_STOP_POINT 0x200000 /*7ͣ*/ +#define EMAP_UPDIRECTION_STOP_POINT 0x2000 /*зͣ*/ +#define EMAP_DOWNDIRECTION_STOP_POINT 0x4000 /*зͣ*/ +#define EMAP_CLEANPAUSE_STOP_POINT 0x10000 /*ϴͣͣ*/ +#define EMAP_EXITCLEAN_STOP_POINT 0x80000 /*˳ϴͣ*/ + + + + + /*ͣ÷*/ /*---link߼ */ + /*ͣӦATOôΧ*/ +#define EMAP_ATP_OPERAT_STOP_POINT_AREA 100 /*ATPӪͣΧ*/ +#define EMAP_ATO_OPERAT_STOP_POINT_AREA 50 /*ATOӪͣΧ*/ +#define EMAP_REVERT_STOP_POINT_AREA 200 /*۷ͣΧ*/ +#define EMAP_SIGNAL_STOP_POINT_AREA 200 /*źŻǰͣΧ*/ +#define EMAP_MINPLART_STOP_POINT_AREA 200 /*Сվ̨ͣΧ*/ + /*ͣӦATPôΧ*/ /*ϲATOͣ÷Χ*/ + + +/*Ϣṹ --- 1*/ + /*״̬*/ + +/*·Ϣṹ --- 3*/ + /*·*/ +#define EMAP_TRAIN_ROUTE 0x01 /*г·*/ +#define EMAP_REVERSE_ROUTE 0x02 /*۷·*/ +#define EMAP_IN_SGMT_ROUTE 0x04 /*ضν·*/ +#define EMAP_OUT_SGMT_ROUTE 0x08 /*ν·*/ +#define EMAP_IN_DEPOT_ROUTE 0x10 /*ؿ·*/ +#define EMAP_OUT_DEPOT_ROUTE 0x20 /*·*/ +#define EMAP_EXIT_CBTC_ROUTE 0x40 /*CBTC˳·*/ +#define EMAP_EXIT_BLOC_ROUTE 0x80 /*ʽ˳·*/ + /*״̬*/ /*---״̬ */ + /*ι״̬*/ /*---״̬ */ + +/*¶ȱ --- 1*/ + /*¶·߼б*/ +#define EMAP_SAME_INC_LINE 0x55 /*¶link߼б*/ +#define EMAP_CONVER_INC_LINE 0xaa /*¶link߼б*/ + +/*Ĭгб --- 1*/ + /*з*/ /*---link߼ */ + +/*ƳCBTC --- 1*/ + /*˳CBTCʱгз*/ /*---link߼ */ + +/*CBTC --- 1*/ + /*CBTCʱгз*/ /*---link߼ */ + +/*ZC --- 3*/ + /**/ +#define EMAP_COM_ZC_CHANGE_MAIN 0x55 /*лϢ*/ +#define EMAP_COM_ZC_CHANGE_BACK 0xaa /*лϢ*/ + /*глʱз*/ /*---link߼ */ + /*״̬*/ /*---״̬ */ + +/* --- 1*/ +/*CI豸*/ +#define EMAP_CI_CBCT_AREA 0x01 /**/ +#define EMAP_CI_TRAIN_TEST_AREA 0x02 /*Գ*/ +#define EMAP_CI_PARK_AREA 0x03 /*ͣ*/ +#define EMAP_CI_CHELIANGDUAN_AREA 0x04 /**/ + +/*ԭʹõĺ궨*/ +/*ϰ궨*/ +#define OBSSIGNAL 0x01 /*źŻ*/ +#define OBSSCREEN 0x02 /**/ +#define OBSEMERAGESTOP 0x03 /*վ̨ͣť*/ +#define OBSPOINT 0x04 /**/ +#define OBSPLATFORM 0x05 /*վ̨*/ +#define OBSEXIT 0x06 /**/ +#define OBSZCDVIDE 0x07 /*ZC߽*/ +#define OBSRES 0x08 /**/ +#define OBSTRAIN_TAIL 0x09 /*ǰгβ*/ +#define OBSTRAIN_HEAD 0x0a /*ǰгͷ*/ +#define OBSAC 0x0b /**/ +#define OBSUT 0x0c /*Σͨųռõʹüʼ˵*/ +#define OBSOVERLAP 0x0d /*Overlap*/ +#define OBSDRA 0x0e /*۷ť*/ +#define OBSDRL 0x0f /*۷*/ +#define OBSROUTE 0x10 /*·*/ +#define OBSLS 0x11 /*߼*/ +#define OBSSWAY 0x12 /*ҡڰť--ɼ*/ +#define OBSFG 0x13 /*--ɼ*/ +#define OBSSPKS 0x14/*SPKS-ɼ*/ +#define OBSDG 0x15/*-ɼ*/ + + +/*ϰ״̬궨*/ +#define DSU_STATUS_SIGNAL_STOP 0x55 /*źŻֹź*/ +#define DSU_STATUS_SIGNAL_PASS 0xAA /*źŻź*/ +#define DSU_STATUS_PSD_OPEN 0x55 /*״̬Ϊ*/ +#define DSU_STATUS_PSD_CLOSE 0xAA /*״̬Ϊر*/ +#define DSU_STATUS_ESP_ACTIVITE 0x55 /*վ̨ͣť*/ +#define DSU_STATUS_ESP_UNACTIVITE 0xAA /*վ̨ͣťͷ*/ +#define DSU_STATUS_AC_OCCUPIED 0x55 /*ռ*/ +#define DSU_STATUS_AC_FREE 0xAA /*ο*/ +#define DSU_STATUS_OVERLAP_SET 0x55 /*overlapλ*/ +#define DSU_STATUS_OVERLAP_UNSET 0xAA /*overlapδλ*/ +#define DSU_STATUS_AR_BUTTON_SET 0x55 /*۷ťѰ */ +#define DSU_STATUS_AR_BUTTON_UNSET 0xAA /*۷ťδ*/ +#define DSU_STATUS_AR_LIGHT_SET 0x55 /*۷*/ +#define DSU_STATUS_AR_LIGHT_UNSET 0xAA /*۷δ*/ +#define DSU_STATUS_ROUTE_SET 0x55 /*·Ѱ*/ +#define DSU_STATUS_ROUTE_UNSET 0xAA /*·δ*/ +#define DSU_STATUS_FG_OPEN 0x55 /*Ŵ--ɼ*/ +#define DSU_STATUS_FG_CLOSE 0xAA /*Źر--ɼ*/ + + +/*ATOվ̨ȡֵ궨*/ +#define ATO_DOOR_NO_OPEN 0 /*Ҿ*/ +#define ATO_DOOR_LEFT_OPEN 1 /*ŷ*/ +#define ATO_DOOR_RIGHT_OPEN 2 /*ŷ*/ +#define ATO_DOOR_LEFT_RIGHT_OPEN 3 /*ŷź*/ +#define ATO_DOOR_RIGHT_LEFT_OPEN 4 /*ŷҺ*/ + + +/*ATOվ̨ȡֵ궨*/ +#define ATO_DOOR_LEFT_CLOSE 1 /*ŷ*/ +#define ATO_DOOR_RIGHT_CLOSE 2 /*ŷ*/ +#define ATO_DOOR_LEFT_RIGHT_CLOSE 3 /*ŷź*/ +#define ATO_DOOR_RIGHT_LEFT_CLOSE 4 /*ŷҺ*/ + +/*ATPſƷʽ궨*/ +#define ATP_DOOR_LEFT_OPEN 1 /**/ +#define ATP_DOOR_RIGHT_OPEN 2 /**/ +#define ATP_DOOR_BOTH_OPEN 3 /*ͬʱ*/ +#define ATP_DOOR_LEFT_RIGHT_OPEN 4 /*ȿٿҲ*/ +#define ATP_DOOR_RIGHT_LEFT_OPEN 5 /*ȿҲٿ*/ +#define ATP_DOOR_NO_OPEN 6 /**/ + + +/*PSDʽ궨*/ +#define PSD_DOOR_OPEN 0x55 /* PSD */ +#define PSD_DOOR_CLOSED 0xAA /* PSD */ + +#define CBTC_LEFT_DOOR (UCHAR)0x01 /* PSDжӦṹŲΪ */ +#define CBTC_RIGHT_DOOR (UCHAR)0x02 /* PSDжӦṹŲΪҲ */ + +/*MAյ궨*/ +#define MA_CBTC_END 1 /*˳CBTCյ*/ +#define MA_REVERT_END 2 /*۷*/ +#define MA_OTHER_END 3 /*յ*/ + +#define DEVTYPE_CI 0x3c /*CIͺ*/ +#define DEVTYPE_ZC 0x1e /*ZCݺ*/ +#define DEVTYPE_ATS 0x03 /*ATSݺ*/ +#define DEVTYPE_VOBC 0x14U /*VOBCݺ*/ +#define DEVTYPE_NDSU 0x2a /*NDSUݺ*/ +#define DEVTYPE_DSU 0x2b /*DSUݺ*/ +#define DEVTYPE_NTP 0x33 /*NTPݺ*/ +#define DEVTYPE_LEU 0x5e /*LEUݺ*/ +#define DEVTYPE_PSD 0x9f /*PSDݺ*/ +#define DEVTYPE_AOM 0x15U /*AOMݺ*/ +#define DEVTYPE_AXLE 0xa0 /*ϵͳݺ*/ +#define DEVTYPE_ITE 0x2FU /*ITEݺ*/ + +/*˳CBTC*/ +#define EMAP_BLOC_EXIT_ROUTE_AREA 0x01/*ʽ˳*/ +#define EMAP_CBTC_EXIT_ROUTE_AREA 0x02/*CBTC˳*/ +#define EMAP_IN_SGMT_AREA 0x04/*ض*/ +#define EMAP_IN_DEPOT_AREA 0x08/*ؿ*/ + +/*Ŀӵͺ궨壬add by qxt 20170726*/ +#define DSU_SINGLE_POINT_TYPE 2 /**/ +#define DSU_THREE_POINT_TYPE 3 /**/ +#define DSU_FIVE_POINT_TYPE 5 /*忪*/ + +/*by cgh 20230724 LINK߼仯 */ +#define LINK_DIRCHANGE_BEGIN 0xAAU /*ԸlinkΪ߼仯*/ +#define LINK_DIRCHANGE_END 0x55U /*ԸlinkյΪ߼仯*/ +#define LINK_DIRCHANGE_NONE 0xFFU /*linkû߼仯*/ + +#endif diff --git a/TSCP/src/dqu_common/dqu_emap_common/dsuStruct.h b/TSCP/src/dqu_common/dqu_emap_common/dsuStruct.h new file mode 100644 index 0000000..d8c0393 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dsuStruct.h @@ -0,0 +1,1308 @@ + /************************************************************************ +* ļ dsuStruct.h +* 汾 1.0 +* ʱ 2009.09.26 +* +* dsuṹ嶨ͷļ +* ʹע +* ޸ļ¼ 2016.3.10 ϲFAOͺϿĽṹ壬ӣ޸ĵȡȥġ +************************************************************************/ + +#ifndef _QUERY_STRUCT_H +#define _QUERY_STRUCT_H + +#include "CommonTypes.h" +#include "dsuEmapDefine.h" +#include "dquVobcCommonStru.h" + +#define LEN_WORD sizeof(UINT16) +#define LEN_DWORD sizeof(UINT32) + +/*¼ṹ峤*/ +#define LEN_VSTA sizeof(DSU_STATIC_VERSION_STRU) +#define LEN_VCFG sizeof(DSU_CONFIG_VERSION_STRU) +#define LEN_VDYM sizeof(DSU_DYNAMIC_VERSION_STRU) +#define LEN_VBAL sizeof(DSU_BALISE_VERSION_STRU) +#define LEN_VERHEAD sizeof(DSU_VERSION_HEAD_STRU) + +#define MAX_VIRTUAL_SWITCH_NUM 5 /* ࿪*/ + +/********¶Ȱlink¶Ƚṹר*******/ +#define GRADE_INCLUDE_LINK_NUM 10 /*¶мlinkֵ*/ +#define ROUTE_ACCESS_LINK_POINT_NUM 10 /*·ӽεֵ*/ +#define MAX_AXLESGMT_NUM_IN_ROUTE 20 /*·*/ + +#define COLSE_BALISE_MAX_NUM 16 /*ӦӦ*/ /*ݻͨӦΪ1620160315by guojian.hou*/ + +/********мlinkκ߼νṹר*******/ +#define MIDDLE_LINK_MAX_NUM 5 /*150608 мLink*/ /*2-->3 ΰΪ4мLinkΪ3 by qxt 20160915 */ +#define SPKS_INCLUDE_LINK_NUM 1000 /*SPKS linkֵ 100ӵ200 m by sds 2019-5-17*/ + +/********2ֶվ̨ж̬վ̨Ӧ*******/ +#define STATION_INCLUDE_LOGICSGMT_NUM ((UINT16)(100)) /*վ̨󴥷߼ ͨݽṹV18.0.0 add by sds 2020-02-11*/ +#define STATION_NO_LOGICSGMT_SIZE ((UINT16)(71)) /*վ̨ųIDֶεֽ ͨݽṹV18.0.0 add by sds 2020-02-11*/ + +#define DSU_TRUE 0x55 +#define DSU_FALSE 0xaa + +#define DSU_NULL_8 0xff /*Ч*/ +#define DSU_NULL_16 0xffff /*Ч*/ +#define DSU_NULL_32 0xffffffff /*Ч*/ + +/*LinkĿ궨*/ +#define MAX_LINK_NUM0 200 + +/*ZCֽعĸ*/ +#define RELATE_ZC_AREA_NUM 8 /*2013.8.22ZCӦZCֽ󹲹*/ +#define RELATE_ZC_AREA_INIT_NUM 25 /*2020.02.11 add by sdsZCӦZCֽ󹲹,С,ʵʳʼʱʹRELATE_ZC_AREA_NUM + **ZC»人5ߵĿУʹ˸úӦĽṹݴ洢,ĿǰС޷ʵʹã˴СʵʳʼʱȻʹеʵʴСгʼ + */ + +/*ZCаĵ*/ +#define ZC_DIVID_SWITCH_NUM 8 /*2020.02.11 add by sdsZCӦ*/ +#define ZC_DIVID_SWITCH_INIT_NUM 20 /*2020.02.11 add by sdsZCӦZCڵ,С,ʵʳʼʱʹZC_DIVID_SWITCH_NUM + **ZC»人5ߵĿУʹ˸úӦĽṹݴ洢,ĿǰС޷ʵʹã˴СʵʳʼʱȻʹеʵʴСгʼ + */ + +/*link̬С*/ +#define LINK_MAX_LIMIT_SPD 32 /*10-->32 qxt 20170821*/ + +/*link豸Ӧ豸ĿǰLinkӦΪֵ add by qxt 20170815*/ +#define LINK_MAX_DEVICE_NUM 20 + +/*linkϰ¶ȵ*/ +#define LINK_MAX_GRADE_NUM 14 /*add by lmy 20171221*/ + +/* "ʽӽĿ""CBTCӽĿ""ʽ""cbtc" Ϊ̶ֵ, + һݱӾҪ޸Ĵ,ΪŻ޸Ľṹ߼, by sds 2019-5-16 */ +#define MAX_BLOC_ACCESS_LINK_NUM 30U /*ʽӽ*/ +#define MAX_CBTC_ACCESS_LINK_NUM 30U /*CBTCӽ*/ +#define MAX_BLOC_TRG_AREA_NUM 30U /*ʽ*/ +#define MAX_CBTC_TRG_AREA_NUM 30U /*CBTC*/ +#define MAX_ALEX_HAVE_LG_NUM 50U /*߼*/ + + +#define DSU_ROUTE_STRU_SWITCH ((UINT8)16) +#define DSU_ROUTE_STRU_wLinkId ((UINT8)50) /*·linkֵ*/ +#define DSU_ROUTE_STRU_AxleSgmtId ((UINT8)30) +#define DSU_SPKS_STRU_PHYID ((UINT8)100) /*SPKSӰ*/ +#define DSU_SPKS_STRU_LOGSECID ((UINT8)200) /*SPKSӰ߼*/ + +#define AXISSEC_NEXT_AXISSEC_MAX_NUM 16 /*by cgh 20230724 ڼĿ*/ +#define AXIS_NEXT_AXIS_SWITCH_MAX_NUM 15 /*by cgh 20230724 ڼιĿ*/ + +#define MAX_PROTECT_AXIS_NUM ((UINT8)100U) /*Ź*/ +#define MAX_ACCESS_AXIS_NUM ((UINT8)100U) /*Źӽ*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*̬ݿ汾Žṹ*/ +typedef struct DSU_StaticVersion +{ + UINT32 dwVersion; /*̬ݿк*/ + UINT16 wVersionType; /*̬ݿ·*/ + UINT16 wVersionCrc; /*̬ݿCRC-16У*/ +}DSU_STATIC_VERSION_STRU; + +/*ݿ汾Žṹ*/ +typedef struct DSU_ConfigVersion +{ + UINT32 dwVersion; /*ݿ汾*/ + UINT16 wVersionType; /*ݿ·*/ + UINT16 wVersionCrc; /*ݿCRC-16У*/ +}DSU_CONFIG_VERSION_STRU; + +/*̬ݿ汾Žṹ*/ +typedef struct DSU_DynamicVersion +{ + UINT32 dwVersion; /*̬ݿ汾*/ + UINT16 wVersionType; /*̬ݿ·*/ + UINT16 wVersionCrc; /*̬ݿCRC-16У*/ +}DSU_DYNAMIC_VERSION_STRU; + +/*Ӧݿ汾Žṹ*/ +typedef struct DSU_BaliseVersion +{ + UINT32 dwVersion; /*̬ݿ汾*/ + UINT16 wVersionType; /*̬ݿ·*/ + UINT16 wVersionCrc; /*̬ݿCRC-16У*/ +}DSU_BALISE_VERSION_STRU; + + +typedef struct DSU_VersioncHead/*Ÿݽṹͷָ*/ +{ + DSU_STATIC_VERSION_STRU *pStaticVersionStru; + DSU_CONFIG_VERSION_STRU *pConfigVersionStru; + DSU_DYNAMIC_VERSION_STRU *pDynamicVersionStru; +}DSU_VERSION_HEAD_STRU; + +/* ̬ݳϢṹ*/ +typedef struct DSU_Data_Len +{ + UINT16 wLinkLen; /*ݿlinkĽṹ*/ + UINT16 wPointLen; /*ݿеĽṹ*/ + UINT16 wSignalLen; /*ݿźŻĽṹ*/ + UINT16 wBaliseLen; /*ݿӦĽṹ*/ + UINT16 wAxlecounterLen; /*ݿмĽṹ*/ + UINT16 wScreenLen; /*ݿаȫŵĽṹ*/ + UINT16 wStationLen; /*ݿͣĽṹ*/ + UINT16 wEmergStopLen; /*ݿнͣťĽṹ*/ + UINT16 wAxleSgmtLen; /*ݿмεĽṹ*/ + UINT16 wStopPointLen; /*ݿͣĽṹ*/ + UINT16 wTrainLineLen; /*ݿгεĽṹ*/ + UINT16 wExitRouteLen; /*ݿйεĽṹ*/ + UINT16 wStaticResSpeedLen; /*ݿо̬Ľṹ*/ + UINT16 wGradeLen; /*ݿ¶Ľṹ*/ + UINT16 wLogicSgmtLen; /*ݿ߼εĽṹ*/ + UINT16 wRouteLen; /*ݿн·Ľṹ*/ + UINT16 wProtectLinkLen; /*ݿн·εĽṹ*/ + UINT16 wCBTCAccessLinkLen; /*ݿн·CBTCӽεĽṹ*/ + UINT16 wBLOCAccessLinkLen; /*ݿн·BLOCӽεĽṹ*/ + UINT16 wDefaultRoutLen; /*ݿĬϽ·Ľṹ*/ + + UINT16 wATSLen; /*ݿATSĽṹ*/ + UINT16 wCILen; /*ݿCIĽṹ*/ + UINT16 wRunLevelLen; /*ݿмṹ*/ + UINT16 wARInLen; /*ݿ۷ṹ*/ + UINT16 wAROutLen; /*ݿ۷˳ṹ*/ + + UINT16 wARLen; /*ݿ۷ṹ*/ /*ӦṹDSU_AR_STRU*/ + UINT16 wZCComZoneLen; /*ZC*/ + UINT16 wZCDividPointLen; /*ZCֽ*/ + UINT16 wConResSpeedLen; + UINT16 wConGradeLen; + UINT16 wPhysicalSgmtLen; + UINT16 wBlocTrgAreaLen; + UINT16 wCbtcTrgAreaLen; + UINT16 wPlatFormLen; + UINT16 wComeGoRouteLen; /*·*/ + UINT16 wFloodGateLen; /*ű*/ + UINT16 wSpksButtonLen; /*SPKSť*/ + UINT16 wDepotGateLen; /*ű*/ + UINT16 wTunnelLen; /**/ + UINT16 wZCLen; /*ݿZCĽṹ*/ + UINT16 wMultiPointLen; /*࿪,ԵĿӣadd by qxt 20170621*/ + UINT16 wPowerlessZoneLen; /*ȣݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + UINT16 wCarStopLen; /*ȣݻͨݽṹV15.0.0ӣadd by sds 20181031*/ + UINT16 wAdjtStationLen; /*ͣȣݻͨݽṹV18.0.0ӣadd by sds 20200211*/ + UINT16 wPSCLen; /*PSCȣݻͨݽṹV20.0.0ӣadd by sds 2020-8-18*/ + UINT16 wEaLen; /**/ + UINT16 wLogSecSpksLen; /*߼SPKS*/ +}DSU_DATA_LEN_STRU; + +/*̬ݿṹ*/ + +/*ǵӵͼݽṹ壬ĵе˳һһӦ*/ + +/*linkݽṹ*/ /*4*1+8*1+14*2=40*/ /*40*200=8000*/ +typedef struct DSU_LinkStruct +{ + UINT16 wId; /*link*/ + UINT32 dwLength; /*linkȣcm*/ + UINT16 wLinkLine; /*Link·Ϣ*/ /*---Ϲѧ*/ + UINT16 wOrgnPointType; /*link˵*/ + UINT16 wOrgnPointId; /*link˵*/ + UINT16 wOrgnJointMainLkId; /*linkӵlink*/ + UINT16 wOrgnJointSideLkId; /*linkӵڲlink*/ + UINT16 wTmnlPointType; /*linkյ˵*/ + UINT16 wTmnlPointId; /*linkյ˵*/ + UINT16 wTmnlJointMainLkId; /*linkյӵlink*/ + UINT16 wTmnlJointSideLkId; /*linkյӵڲlink*/ + UINT16 wManageZC; /*ZC*/ + UINT16 wManageATS; /*ATS*/ /*Ͽ⡢෿ñΪվš ͨиñĺΪ ATS add by qxt 20160811*/ + UINT16 wManageLogicCI; /*߼CI*/ + UINT16 wManagePhysicalCI; /*CI*/ /*----ȷΪ2ֽ---*/ + + UINT16 wLinkResSpeed; /*LinkϢ*/ + UINT16 wGrade; /*Link¶Ϣ*/ + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT16 wLogicDir; /*link߼16ƣԤ(滻ΪwLinkLine)*/ + + UINT16 wManageStation; /*ͨñĺΪ վ add by qxt 20160811*/ + UINT8 wLinkLogicDirUpAndDown; /*ͨϵͳ߼зĹϵ add by qxt 20160811*/ + + UINT8 wLogicDirChanged; + UINT8 wTunAttribute; /*LinkԣݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + UINT16 wManagePSCID; /*PSC*/ + UINT8 wKsDoorUnlock; /*Žŷʽ*/ + UINT16 wBelongVirtualCI; /*CI*/ + UINT8 wLinxian; /*Link*/ + UINT8 wLinkTG_EvacuateDir; /*ѹ켰ɢ·*/ + UINT8 cCbtcProperty; /*link CBTCԣ0x55CBTC0xAACBTC*/ +}DSU_LINK_STRU; + + + +/*ݽṹ*/ +typedef struct DSU_PointStruct/*6*4+8*1+10*2 = 52*/ /*52*32=1664*/ +{ + UINT16 wId; /**/ + CHAR szCaption [16]; /**/ + UINT16 DPointOtherId; /**/ + UINT32 dwPointKilo; /*㹫*/ + UINT16 wMainLkId; /*link*/ + UINT32 dwMainLkOfst; /*linkƫ(cm)*/ + UINT16 wSideLkId; /*link*/ + UINT32 dwSideLkOfst; /*linkƫ(cm)*/ + UINT16 wConfluentLkId; /*link*/ + UINT32 dwConfluentLkOfst; /*linkƫ(cm)*/ + UINT16 wSideResSpeed; /*λ̬ٶ(cm/s)*/ + UINT8 dwPointKiloPlueMinusSign;/*ű*/ + + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT16 wManageZC; /*ZC*/ + UINT16 wManagePhysicalCI; /*CI*/ + UINT16 wManageLogicCI; /*߼CI*/ + UINT16 wBelongVirCI;/**/ + +}DSU_POINT_STRU; + + + +/*źŻ*/ +typedef struct DSU_SignalStruct +{ + UINT16 wId; /**/ + CHAR szCaption [12]; /*źŻ*/ + UINT16 wType; /*źŻ*/ + UINT16 wAttribute; /*źŻ*/ + UINT16 wLkId; /*źŻlink*/ + UINT32 dwLkOfst; /*źŻlinkƫ(cm)*/ + UINT16 wProtectDir; /*źŻ(16)*/ + UINT16 wProtectLinkId; /*źŻlink*/ + UINT32 dwProtectLinkOfst; /*źŻlinkƫ(cm)*/ + UINT16 wPassSignal; /*źŻ־*/ + + UINT16 wEnableSignal; /*źŻжϴźŹܱ־*/ + UINT16 wShineSignal; /*źŻܱ־*/ + UINT32 dwSignalDengLie; /*źŻ*/ + UINT8 sDengWeiFengBi; /*λϢ*/ + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT16 wManageZC; /*ZC*/ + UINT16 wManagePhysicalCI; /*CI*/ + UINT16 wManageLogicCI; /*߼CI*/ + UINT16 wBelongVirCI;/**/ + UINT16 wRelatedMainSignalId; +}DSU_SIGNAL_STRU; + + +/*Ӧ*/ +typedef struct DSU_BaliseStruct +{ + UINT16 wId; /**/ + UINT32 dwBaliseId; /*ӦID*/ + CHAR szCaption [8]; /*Ӧ*/ + UINT16 wLkId; /*Ӧlink*/ + UINT32 dwLkOfst; /*Ӧlinkƫ(cm)*/ + UINT16 wRelateSignalID; /*ӦźŻ*/ + UINT16 wBaliseDir; /*Ӧ÷()*/ + UINT16 wBaliseType; /*Ӧ*/ + UINT16 wOrgnBaliseNum; /*link߼ڵӦ*/ + UINT32 dwOrgnBaliseId[COLSE_BALISE_MAX_NUM]; /*link߼ڵӦı*/ + UINT32 dwDistanceToOrgnBalise[COLSE_BALISE_MAX_NUM]; /*link߼ڵӦľ*/ + UINT16 wPassOrgnBaliseDir[COLSE_BALISE_MAX_NUM]; /*·㷽뱾ӦҶгЧֱӵӦ·ϣгӦپӦʱķ*/ + UINT16 wOrgnRelatePointID[COLSE_BALISE_MAX_NUM]; /*Ӧ*/ + UINT16 wOrgnRelatePointStatus[COLSE_BALISE_MAX_NUM]; /*Ӧ״̬*/ + UINT16 wTmnlBaliseNum; /*link߼յڵӦ*/ + UINT32 dwTmnlBaliseId[COLSE_BALISE_MAX_NUM]; /*link߼յڵӦı*/ + UINT32 dwDistanceToTmnlBalise[COLSE_BALISE_MAX_NUM]; /*link߼յڵӦľ*/ + UINT16 wPassTmnlBaliseDir[COLSE_BALISE_MAX_NUM]; /*·յ㷽뱾ӦҶгЧֱӵӦ·ϣгӦپӦʱķ*/ + UINT16 wTmnlRelatePointID[COLSE_BALISE_MAX_NUM]; /*յӦ*/ + UINT16 wTmnlRelatePointStatus[COLSE_BALISE_MAX_NUM]; /*յӦ״̬*/ + UINT16 wLeuId; /*LEU*/ + UINT16 wEmapVersion; /*ӵͼ汾Ϣ---ݻͨ,by hgj 20150507*/ +}DSU_BALISE_STRU; + + +/**/ +typedef struct DSU_AxleStruct +{ + UINT16 wId; /**/ + CHAR szCaption [16]; /**/ + UINT16 wType; /*Ϣ*/ + UINT32 dwAxleKilo; /**/ + UINT16 wLkId; /*link*/ + UINT32 dwLkOfst; /*linkƫ(cm)*/ + UINT8 dwAxleKiloPlueMinusSign; /*ű־*/ + + +}DSU_AXLE_STRU; + + +/*ȫű*/ +typedef struct DSU_ScreenStruct +{ + UINT16 wId; /**/ + UINT16 wLocalPlatformId; /*վ̨*/ + UINT16 wRelatLkId; /*Źlink*/ + UINT16 wwRelatLkOrient; /*Թlink߼ķλ()*/ + UINT16 wVobcCiID; /*VOBC-CIλ*/ + + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT16 wManageLogicCI; /*߼CI*/ + +}DSU_SCREEN_STRU; + + +/*ͣť*/ +typedef struct DSU_EmergStopStruct +{ + UINT16 wId; /**/ + UINT16 wLocalPlatformId; /*վ̨*/ + UINT16 wRelatLkId; /*ͣťlink*/ + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT16 wManageLogicCI; /*߼CI*/ + +}DSU_EMERG_STOP_STRU; + + +/*ͣϢṹ*/ +typedef struct DSU_StationStruct +{ + + UINT16 wId; /**/ + CHAR szCaption [20]; /*վ*/ + CHAR bDesId[4]; /*Ŀĵر*/ /*---Ϲѧ*/ /*˴ĵǵֽ*/ + UINT16 wLinkId; /*վ̨Χlink*/ + UINT32 dwAttribute; /*ͣ 6.5ݽṹ޸Ϊ4ֽ*/ + UINT16 wMinParkTime; /*վ̨Сͣվʱ*/ + UINT16 wMaxParkTime; /*վ̨ͣվʱ*/ + UINT16 wParkTime; /*վ̨Ĭͣվʱ*/ + UINT16 wScreenNum; /*վ̨*/ + UINT16 wScreenId[2]; /*ȫű*/ + UINT16 wEmergStopNum; /*վ̨нͣť*/ + UINT16 wEmergStopId[2]; /*ͣť*/ + UINT16 wStopPointNum; /*վ̨ͣĿ*/ + UINT16 wStopPointID[4]; /*վ̨ͣ*/ /*20160314 ݻͨ޸ by guojian.hou*/ + UINT16 wDoorOpenMode; /*վ̨ŷʽ*/ + UINT16 wDoorOpenTime; /*վ̨ʱ*/ + UINT16 wDoorCloseMode; /*վ̨ŷʽ*/ + UINT16 wDoorCloseTime; /*վ̨ʱ*/ + UINT16 wParkSteadyTime; /*վ̨Ĭͣʱ*/ + UINT16 wStationID; /*վ̨վ*/ + UINT16 wLuggageOpenMode; /*ŷʽݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + UINT16 wLuggageCloseMode; /*ŷʽݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + UINT16 wCrashResSpeed; /*ײֵݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + UINT16 wATSStationId; /*"ATSͣIDݻͨݽṹV14.0.0ӣadd by qxt 20180719*/ + UINT16 wTimeOfAdvanceRoute; /*"ǰ·ʱ䣬ݻͨݽṹV18.1.0ӣadd by sds 20200522*/ + + /*ݴĿУļɾֵҪ̬---Ϲѧ*/ + UINT32 dwStatTmnlLinkOfst; /*վ̨Χֹlinkƫ*/ + UINT16 wManagePhysicalCI; /*CI*/ + UINT16 wManageLogicCI; /*߼CI*/ + +}DSU_STATION_STRU; + + +/*ͣ*/ +typedef struct DSU_StopPointStruct +{ + UINT16 wId; /**/ + UINT32 wAttribute; /*ͣ*/ + UINT16 wDir; /*ͣ÷(16)*/ + UINT16 wLinkId; /*ͣ·link*/ + UINT32 dwLinkOfst; /*ͣlinkƫ(cm)*/ + UINT16 wOverLapId; /*ͣӦα*/ + UINT32 dwATOParkArea; /*ͣӦATOôΧ*/ + UINT32 dwATPParkArea; /*ͣӦATPôΧ*/ + UINT16 wStationID; /*ͣӦվ̨ID*/ + UINT8 wStationDoorID; /*ͣӦվ̨ID*/ + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT16 wMinStopTime; /*Сͣվʱ*/ + UINT16 wMaxStopTime; /*ͣվʱ*/ + UINT16 wStopTime; /*Ĭͣվʱ*/ + UINT32 dwOverLapLength; /* ԭoverlapLengthΪoverlapIdҪ¼*/ + +}DSU_STOPPOINT_STRU; + + +/*α*/ +typedef struct DSU_AxleSgmtStruct +{ + + UINT16 wId; /**/ + CHAR szCaption [16]; /**/ + UINT16 wOrgnAxleId; /**/ + UINT16 wTmnlAxleId; /*յ*/ + UINT16 wOrgnLkId; /*link*/ + UINT16 wTmnlLkId; /*յlink*/ + UINT16 wIncludeLogicSgmtNum; /*ΰ߼εĸ*/ + UINT16 wLogicSgmtId[MAX_ALEX_HAVE_LG_NUM]; /*ΰ߼εı*/ + UINT16 wRelatPointNum; /*Ŀ*/ + UINT16 wRelatPointId[4]; /**/ + UINT16 wRelatPointStatus[4]; /*״̬*/ + + /*α*/ + UINT16 wRelatePhysicalSgmtId; /*Ӧ*/ + + /* ݴĿУļɾֵҪ̬---Ϲѧ*/ + UINT16 wMiddleLinkId[MIDDLE_LINK_MAX_NUM]; /*150608 мlink*/ + UINT32 dwOrgnLinkOfst; /*linkƫ*/ + UINT32 dwTmnlLinkOfst; /*յlinkƫ*/ + UINT16 wOrgnRelatPointId[15]; /**/ + UINT16 wOrgnAxleSgmtId[16]; /*Ӽα*//*4-->15,ĿΪ4ΪΪ152024.10.09*/ + UINT16 wTmnlRelatPointId[15]; /*յ*/ + UINT16 wTmnlAxleSgmtId[16]; /*յӼα*//*4-->15,ĿΪ4ΪΪ152024.10.09*/ + UINT16 wRelatAxleSgmtNum; /*Ŀ*/ + UINT16 wRelatAxleSgmtId[16]; /*1500608 α*//*4-->15,ĿΪ4ΪΪ15ΪĿ±Ǵ1ʼһڴ棬2024.10.09*/ + UINT16 wManageZC; /*ZC*/ + UINT16 wManagePhysicalCI; /*CI*/ + + UINT16 BelongVirCI; /**/ +}DSU_AXLE_SGMT_STRU; + + +/*߼α*/ +typedef struct DSU_LogicSgmtStruct +{ + UINT16 wId; /**/ + CHAR szCaption [16]; /*߼*/ + UINT16 wOrgnLkId; /*link*/ + UINT32 dwOrgnLkOfst; /*linkƫ(cm)*/ + UINT16 wTmnlLkId; /*յlink*/ + UINT32 dwTmnlLkOfst; /*յlinkƫ(cm)*/ + UINT8 chAxleSgmtSum; /**/ /* add 20220920 TIOC5.0*/ + UINT16 wAxleSgmtId[MAX_AXISSEC_SUM_IN_LOGSEC]; /*α*/ /* modify 20220920 TIOC5.0*/ + /*UINT16 wZcCiLogicStatusId; ZC-CI߼ռ״̬λ*/ + /*UINT16 wZcCiCTLogicStatusId; ZC-CI߼CTгռ״̬λԤ*/ + /*UINT16 wZcCiUTLogicStatusId; ZC-CI߼UTгռ״̬λԤ*/ + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT16 wMiddleLinkId[MIDDLE_LINK_MAX_NUM]; /*150608 ߼мlink*/ + UINT16 wMainOrgnLogicSgmtId; /*ǰ߼εı*/ + UINT16 wMainTmnlLogicSgmtId; /*ں߼εı*/ + /*߼ΰϢҪ*//*add 20220922 TIOC5.0*/ + UINT8 chSwitchNum; + UINT16 wSwitchId[MAX_LOGSEC_INCLUDE_SWITCH_NUM]; /*ID*/ + UINT8 chSwitchPosition[MAX_LOGSEC_INCLUDE_SWITCH_NUM]; /*λ*/ + UINT16 wRelatPhySecId; /* ID*/ + +}DSU_LOGIC_SGMT_STRU; + + +/*·*/ +typedef struct DSU_RouteStruct +{ + UINT16 wId; /**/ + CHAR szCaption [24]; /*·*/ + UINT16 wRouteType; /*·*/ + UINT16 wStartSignalId; /*ʼźŻ*/ + UINT16 wEndSignalId; /*ֹźŻ*/ + UINT16 wOrgnLkId; /*link*/ /*---Ϲѧ*/ + UINT16 wTmnlLkId; /*յlink*/ /*---Ϲѧ*/ + UINT16 wIncludePointNum; /*Ŀ*/ + UINT16 wPointId[DSU_ROUTE_STRU_SWITCH]; /**/ + UINT16 wPointStatus[16]; /*״̬*/ + UINT16 wProtectLinkNum; /*Ŀ*/ + UINT16 wProtectLinkId[4]; /*α*/ + UINT16 wProtectLinkRelatePointId[4]; /*ι*/ + UINT16 wProtectLinkRelatePointStatus[4]; /*ι״̬*/ + UINT16 wBlogAccessLinkNum; /*ʽӽĿ*/ + UINT16 wBlogAccessLinkId[MAX_BLOC_ACCESS_LINK_NUM]; /*ʽӽα,ṹռ,ӿչ,޸Ľṹ߼,Żÿݽṹ仯Ҫ޸Ĵ by tianqf 20190507*/ + UINT16 wCBTCAccessLinkNum; /*CBTCӽĿ*/ + UINT16 wCBTCAccessLinkId[MAX_CBTC_ACCESS_LINK_NUM]; /*CBTCӽα,ṹռ,ӿչ,޸Ľṹ߼,Żÿݽṹ仯Ҫ޸Ĵ by tianqf 20190507*/ + UINT16 wManageCI; /*CI*/ + UINT16 wAttribute; /*·*/ + UINT16 wBlocTrgAreaNum; /*ʽ*/ + UINT16 wBlocTrgAreaId[MAX_BLOC_TRG_AREA_NUM]; /*ʽID,ṹռ,ӿչ,޸Ľṹ߼,Żÿݽṹ仯Ҫ޸Ĵ by tianqf 20190507*/ + UINT16 wCbtcTrgAreaNum; /*CBTC*/ + UINT16 wCbtcTrgAreaId[MAX_CBTC_TRG_AREA_NUM]; /*CBTCID,ṹռ,ӿչ,޸Ľṹ߼,Żÿݽṹ仯Ҫ޸Ĵ by tianqf 20190507*/ + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + /*2013.8.27 CBTCӽιĴС"3"޸Ϊ "ROUTE_ACCESS_LINK_POINT_NUM"*/ + UINT16 wCBTCAccessLinkRelatePointNum[10]; /*CBTCӽιĿ,СCBTCӽĿ*/ + UINT16 wCBTCAccessLinkRelatePointId[10][ROUTE_ACCESS_LINK_POINT_NUM]; /*CBTCӽι*/ + UINT16 wCBTCAccessLinkRelatePointSta[10][ROUTE_ACCESS_LINK_POINT_NUM]; /*CBTCӽ1״̬*/ + + + UINT16 wIncludeAxleSgmtNum; /*·ļĿ*/ + UINT16 wIncludeAxleSgmtId[DSU_ROUTE_STRU_AxleSgmtId]; /*ļα*/ + UINT16 wAxleSgmtLockStatus[30]; /*ļ״̬*/ + UINT16 wIncludeLinkNum; /*linkĿ*/ + UINT16 wLinkId[DSU_ROUTE_STRU_wLinkId]; /*link*/ + UINT16 wObsNum; /*·ϰĿ*/ + UINT16 wObsType[24]; /*ϰ*/ + UINT16 wObsID[24]; /*ϰID*/ + UINT16 wObsNeedLockStatus[24]; /*ϰҪ״̬*/ + UINT16 wDir; /*(16)*/ + +}DSU_ROUTE_STRU; + + +/*α*/ +typedef struct DSU_ProtectLinkStruct +{ + UINT16 wId; /**/ + UINT16 wIncludeAxleSgmtNum; /*ļĿ*/ /*---Ϲѧ*/ + UINT16 wIncludeAxleSgmtId[4]; /*ļα*/ /*---Ϲѧ*/ /*ֶԭ*/ + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT16 wRouteId; /*·*/ + UINT16 wObsNum; /*ϰĿ*/ + UINT16 wObsType; /*ϰ*/ + +}DSU_PROTECT_LINK_STRU; + + +/*ʽӽϢ*/ /*ԭBLOCģʽӽα*/ +typedef struct DSU_BLOCAccessLinkStruct +{ + UINT16 wId; /**/ + UINT16 wIncludeAxleSgmtNum; /*ļĿ*/ + UINT16 wIncludeAxleSgmtId[40]; /*ļα 40̬ ݻͨݽṹV13.0.0 by sds 2018-6-7*/ + +}DSU_BLOC_ACCESS_LINK_STRU; + + +/*CBTCģʽӽα*/ +typedef struct DSU_CBTCAccessLinkStruct +{ + UINT16 wId; /**/ + UINT16 wIncludeLogicSgmtNum; /*߼Ŀ*/ + UINT16 wIncludeLogicSgmtId[50]; /*߼α 50̬ ݻͨݽṹV13.0.0 by sds 2018-6-7*/ + +}DSU_CBTC_ACCESS_LINK_STRU; + + +/*¶ݽṹ*/ +typedef struct DSU_GradeStruct +{ + UINT16 wId; /**/ + UINT16 wOrgnLinkId; /*¶link*/ + UINT32 dwOrgnLinkOfst; /*¶linkƫ*/ + UINT16 wTmnlLinkId; /*¶յlink*/ + UINT32 dwTmnlLinkOfst; /*¶յlinkƫ*/ + UINT16 wOrgnRelatePointId; /**/ + UINT16 wOrgnJointMainGradeId; /*¶ȱ*/ + UINT16 wOrgnJointSideGradeId; /*¶ȱ*/ + UINT16 wTmnlRelatePointId; /*յ*/ + UINT16 wTmnlJointMainGradeId; /*յ¶ȱ*/ + UINT16 wTmnlJointSideGradeId; /*յ¶ȱ*/ + UINT16 wGradValue; /*¶ֵ*/ + UINT16 wInclineDir; /*¶·߼б*/ + UINT32 dwRadius; /*߰뾶*/ /*---Ϲѧ*/ + + /* ݴĿУļɾֵҪ̬---Ϲѧ */ + UINT32 dwGradeLength; /*¶ȳ*/ + UINT16 wIncludeLinkId[GRADE_INCLUDE_LINK_NUM+1]; /*¶·мlink*/ + /*[GRADE_INCLUDE_LINK_NUM]==>[GRADE_INCLUDE_LINK_NUM+1] changed by qxt 20170509*/ + /*¶мlinkʱʹwhileмlink!=0xffĸʽʵlinkűʱͲ0xffʱѭмlinkݽдԽ磬1Ҫ֤һ0xff*/ + +}DSU_GRADE_STRU; + + + +/*·̬ٱ*/ +typedef struct DSU_StaticResSpeedStruct +{ + UINT16 wId; /**/ + UINT16 wLinkId; /*link*/ + UINT32 dwOrgnLinkOfst; /*linkƫ(cm)*/ + UINT32 dwTmnlLinkOfst; /*յlinkƫ(cm)*/ + UINT16 wRelatePointId; /**/ + UINT16 wResSpeed; /*ֵ̬*/ +}DSU_STATIC_RES_SPEED_STRU; + + +/*Ĭгб*/ +typedef struct DSU_DefaultRoutStruct +{ + UINT16 wId; /**/ + UINT16 wLinkId; /*վ--δ*/ + UINT16 wLinkDir; /*з*/ + UINT16 wNextPlatformId; /*ǰվ̨*/ + UINT16 wDestinationId; /*Ŀվ̨*/ + + /*ݴĿУļɾֵҪ̬---Ϲѧ*/ + UINT16 wCurrentPlatformId; /*ǰվ̨*/ + UINT16 wCurrentPlatformFlag; /*ǰվ̨־λ*/ + +}DSU_DEFAULTROUTE_STRU; + + +/*վӪ*/ +typedef struct DSU_RunLevelStruct +{ + UINT16 wId; /**/ + UINT16 wOrgnDesId; /*Ŀĵر*/ + UINT16 wTmnlDesId; /*յĿĵر*/ + UINT16 wRunLevelNum; /*мּĿ*/ /*---Ϲѧ*/ + UINT16 wRunLevelID[10]; /*Ӫ*/ + UINT16 wRunTime[10]; /*Ӫʱ*/ + UINT16 wRunSpeed[10]; /*Ӫٶ*/ +}DSU_RUN_LEVEL_STRU; + + +/*˳CBTC*/ /*ԭ--˳·*/ +typedef struct DSU_ExitRouteStruct +{ + UINT16 wId; /**/ + UINT16 wOrgnLinkId; /*link*/ + UINT32 dwOrgnLinkOfst; /*linkƫ(cm)*/ + UINT16 wTmnlLinkId; /*յlink*/ + UINT32 dwTmnlLinkOfst; /*յlinkƫ(cm)*/ + UINT16 wDIR; /*˳CBTCʱгз*/ + UINT16 wType; /*˳CBTCϢ*/ + + /*Ϣ--Ϲѧ-20121109*/ + UINT16 wIncludePointNum; /**/ + UINT16 wPointId[10]; /*id*/ + UINT16 wPointStatus[10]; /*״̬*/ +}DSU_EXIT_ROUTE_STRU; + + + +/*CBTC*/ /*ԭ--·*/ +typedef struct DSU_TrainLineStruct +{ + UINT16 wId; /**/ + UINT16 wOrgnLinkId; /*link*/ + UINT32 dwOrgnLinkOfst; /*linkƫ(cm)*/ + UINT16 wTmnlLinkId; /*յlink*/ + UINT32 dwTmnlLinkOfst; /*յlinkƫ(cm)*/ + UINT16 wDir; /*CBTCгз*/ +}DSU_TRAIN_LINE_STRU; + + +/*۷*/ /*۷۷˳ϲ*/ /*---Ϲѧ*/ +typedef struct DSU_ARStru +{ + UINT16 wId; /**/ + UINT16 wStartPlartformId; /*۷վ̨*/ + UINT16 wARInStopPointId; /*۷*/ + UINT16 wRevertPointId; /*۷˵*/ + UINT16 wEndPlartformId; /*۷˳վ̨*/ + UINT16 wAROutStopPointId; /*۷˳*/ + UINT16 wARLampID; /*۷ID*/ + UINT16 wARButtonId; /*۷ťID*/ + +}DSU_AR_STRU; + + +/*ZC*/ /*ǰzcֽ*/ /*---Ϲѧ*/ +typedef struct DSU_ZCComZone +{ + UINT16 wId; /**/ + UINT16 wOrgnLinkId; /*link*/ + UINT32 dwOrgnLinkOfst; /*linkƫ*/ + UINT16 wTmnlLinkId; /*յlink*/ + UINT32 dwTmnlLinkOfst; /*յlinkƫ*/ + UINT16 wRelateRouteID; /*Ľ·*/ + UINT16 wIncludePointNum; /*ڰĵĿ*/ + UINT16 wPointId[ZC_DIVID_SWITCH_INIT_NUM]; /*ڰĵ*/ + UINT16 wPointStatus[ZC_DIVID_SWITCH_INIT_NUM]; /*ڰĵ״̬*/ + +}DSU_ZC_COM_ZONE_STRU; + +/*ZCϢ*/ +typedef struct DSU_ZCDividPointStruct +{ + UINT16 wId; /**/ + UINT16 wIdconnection; /*صķֽ*/ + UINT16 wType; /*ֽ*/ + UINT16 wOutputZcIndex; /*ƽZC豸*/ + UINT16 wOutputZcId; /*ƽZC豸ID*/ + UINT16 wInputZcIndex; /*ӹZC豸*/ + UINT16 wInputZcId; /*ӹZC豸ID*/ + UINT16 wDividPointLinkId; /*ZCֽlink*/ + UINT32 dwDividPointLinkOfst; /*ZCֽlinkƫ*/ + UINT16 wDir; /*глʱз*/ + UINT16 wRelateZCAreaNum; /*ֽصĹĿ*/ + UINT16 wRelateZCAreaId[RELATE_ZC_AREA_INIT_NUM]; /*ֽصĹ*/ + +}DSU_ZC_DIVID_POINT_STRU; + + +/*CIϢ*/ +typedef struct DSU_CIStruct +{ + UINT16 wIndex; /**/ + UINT16 wID; /*RCI豸ID*/ + UINT16 wType; /**/ + UINT32 dwVersionOfCIToVOBC; /*RCI-VOBCУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT32 dwVersionOfCIToZC; /*RCI-ZCУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT32 dwVersionOfCIToTMC; /*RCI-TMCУϢ---ݳݽṹ by qw.liu 2022-02-22*/ + UINT32 dwVersionOfCIToATS; /*RCI-ATSУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT8 dwAdjoinCICount; /*CI----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT16 dwAdjoinCIId[6]; /*CI[1-6]ID----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT32 dwAdjoinCIShareCheckData[6]; /*CI[1-6]ĹУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT16 dwCIToAxleID[3]; /*CIͨżϵͳ[1-3]ID*/ + UINT32 dwCIToAxleShareCheckData[3]; /*ϵͳ[1-3]ĹУϢ*/ + UINT8 chAdjoinOcCount; /*CIͨŵocby cgh OCݰ汾УϢ 20221222*/ + UINT16 wAdjoinOcId[10]; /*Oc[1-10]ID----by cgh OCݰ汾УϢ 20221222*/ + UINT32 dwAdjoinOcShareCheckData[10]; /*OC[1-10]ĹУϢ----by cgh OCݰ汾УϢ 20221222*/ + UINT8 RCIEntraceType; /*RCI*/ + UINT8 cWLScreenType; /* ȫɸЧ 0x55Ч 0xAAЧ */ +}DSU_CI_STRU; + + +/*ATSϢ*/ +typedef struct DSU_ATSStruct +{ + UINT16 wIndex; /**/ + UINT16 wID; /*ATS豸ID*/ + UINT32 dwVersionOfATSToVOBC; /*ATS-VOBCУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT32 dwVersionOfATSToDSU; /*ATS-DSUУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT8 dwAdjoinATSCount; /*ATS----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT16 dwAdjoinATSId[6]; /*ATS[1-6]ID----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT32 dwAdjoinATSShareCheckData[6]; /*ATS[1-6]ĹУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ +}DSU_ATS_STRU; + + + +/*ݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ +typedef struct DSU_PowerlessZoneStruct +{ + UINT16 wId; /**/ + UINT16 wOrgnLinkId; /*link*/ + UINT32 dwOrgnLinkOfst; /*linkƫ*/ + UINT16 wTmnlLinkId; /*յlink*/ + UINT32 dwTmnlLinkOfst; /*յlinkƫ*/ + UINT8 wProtectDir; /**/ + UINT16 wEntrySpeed; /*ͨٶȣkm/h*/ + +}DSU_POWERLESS_ZONE_STRU; + +/*ݻͨݽṹV15.0.0ӣadd by sds 20181031*/ +typedef struct DSU_CarStopStruct +{ + UINT16 carsId; /**/ + UINT16 carsLinkId; /*link*/ + UINT32 carsLinkOfst; /*linkƫ*/ + +}DSU_CARSTOP_STRU; + +/*ߴͣڲţݻͨݽṹV18.0.0ӣadd by sds 20200211*/ +typedef struct DSU_AdjtStationStruct +{ + UINT16 wId; /**/ + UINT16 wLineId; /*·*/ + UINT32 wLogicStaId; /*߼վ̨*/ + CHAR destID[4]; /*Ŀĵر*/ + CHAR trackID[16]; /**/ + CHAR stationID[20]; /*վ*/ + UINT16 adjtLineStaId; /*ߴͣڲ*/ + +}DSU_AdjtStation_STRU; + +/*PSCṹ*/ +typedef struct DSU_PSCStruct +{ + UINT16 wId; /**/ + UINT16 wDevID; /*PSCID*/ + UINT16 wContainPSDID[4]; /*PSD IDϢ*/ + UINT16 wManagerCIID; /*CI IDϢ*/ +}DSU_PSC_STRU; + +/*ǵӵͼݽṹ*/ + + + +/*۷*/ /*ϲ۷*/ +typedef struct DSU_ARInStruct +{ + UINT16 wId; /**/ + UINT16 wPlatformId; /*վ̨ID*/ + UINT16 wStopPointLinkID; /*ͣLink*/ + UINT32 dwStopPointLinkOffset; /*ͣLinkƫ*/ + UINT32 dwParkArea; /*ͣӦôΧ*/ + UINT16 wRevertPointLinkID; /*˵Link*/ + UINT32 dwRevertPointLinkOffset; /*˵Linkƫ*/ + UINT32 dwRevertParkArea; /*˵ӦôΧ*/ + UINT16 wARLampID; /*۷Ʊ*/ + UINT16 wARButtonID; /*۷ť*/ + UINT16 wDir; /*۷㷽 */ +}DSU_AR_IN_STRU; + + +/*۷˳*/ /*ϲ۷*/ +typedef struct DSU_AROutStruct/**/ +{ + UINT32 dwStopPointLinkOffset; /*ͣLinkƫ*/ + UINT32 dwParkArea; /*ͣӦôΧ*/ + UINT16 wId; /**/ + UINT16 wPlatformId; /*վ̨ID*/ + UINT16 wStopPointLinkID; /*ͣLink*/ +}DSU_AR_OUT_STRU; + + +typedef struct DSU_ConResSpeed/**/ +{ + UINT16 wIndex; /**/ + UINT16 wSpeed; /*ֵcm/s*/ +}DSU_CONRESSPEED_STRU; + + + +typedef struct DSU_ConGrade/**/ +{ + UINT16 wIndex; /**/ + UINT16 wGrade; /*¶ֵ*/ +}DSU_CONGRADE_STRU; + + +/*νṹ----2013-1-21*/ +typedef struct DSU_PhysicalSgmt/**/ +{ + UINT16 wId; /**/ + CHAR szName[16]; /**/ + UINT8 Type; /**/ + UINT8 LjkFlag; /*м־*/ + UINT16 BelongAxleSysID; /*ϵͳID*/ +}DSU_PHYSICAL_SGMT_STRU; + +typedef struct DSU_BlocTrgAera/*ʽ*/ +{ + UINT16 wId; /**/ + UINT16 wAxleSgmtNum; /*θ*/ + UINT16 wAxleSgmtId[40]; /* 40̬ ݻͨݽṹV13.0.0 by sds 2018-6-7*/ +}DSU_BLOC_TRG_AREA_STRU; + +typedef struct DSU_CbtcTrgAera/*CBTC*/ +{ + UINT16 wId; /**/ + UINT16 wLogicSgmtNum; /*߼θ*/ + UINT16 wLogicSgmtId[40]; /*߼ 40̬ ݻͨݽṹV13.0.0 by sds 2018-6-7*/ +}DSU_CBTC_TRG_AREA_STRU; + +/*վ̨*/ +typedef struct DSU_PlatFormStruct +{ + UINT16 wId; /**/ + CHAR szGongLiBiao[16]; /*Ĺ*/ + UINT16 wStationId; /*Ӧͣ*/ + UINT8 wDir; /**/ + UINT16 wLogicSgmtNum; /*վ̨Ӧ߼θ*/ + UINT16 wLogicSgmtId[STATION_INCLUDE_LOGICSGMT_NUM]; /*վ̨Ӧ߼ID*/ + CHAR szStationName[48]; /*վ̨*/ +}DSU_PLAT_FORM_STRU; + +/*·*/ +typedef struct DSU_ComeGoStruct +{ + UINT16 wId; /**/ + UINT16 route1Id; /*·1*/ + UINT16 route2Id; /*·2*/ + UINT16 route3Id; /*·3*/ + UINT16 route4Id; /*·4*/ + UINT16 stationId; /*ӦͣID*/ +}DSU_COME_GO_STRU; + +typedef struct DSU_FloodGate /*---20140718һ*/ +{ + UINT16 wId; /**/ + UINT16 wFloodGateLinkID; /*Link*/ + UINT32 dwFloodGateLinkoffset; /*Linkƫ*/ + UINT8 wDir; /**/ + + UINT16 wProtectAxisNum; /*ŷ*/ + UINT16 wProtectAxisId[MAX_PROTECT_AXIS_NUM]; /*ŷID*/ + UINT16 wAccessAxisNum; /*Žӽ*/ + UINT16 wAccessAxisId[MAX_ACCESS_AXIS_NUM]; /*ŽӽID*/ + UINT8 wAccessAxisDir[MAX_ACCESS_AXIS_NUM]; /*Žӽνӽ*/ + +}DSU_FLOOD_GATE_STRU; + /*SPKS*/ +typedef struct DSU_SpksButton +{ + UINT16 wId; /**/ + UINT16 wPhysicalSgmtNum; /*θ*/ + UINT16 wRelatePhysicalSgmtId[DSU_SPKS_STRU_PHYID]; /*ID*/ + UINT16 wManageCI; /*CI*/ + UINT16 wManageVirCI; /*CI*/ + /* ݴĿУļɾֵҪ̬--- */ + UINT8 wLinkNum;/*LINK*/ + UINT16 wIncLinkId[SPKS_INCLUDE_LINK_NUM];/*LINK*/ + UINT16 wPlatFormId; /*վ̨ID*/ +}DSU_SPKS_BUTTON_STRU; + +/*߼SPKSر*/ +typedef struct DSU_LogSecSpksButton +{ + UINT16 wId; /*SPKS*/ + UINT16 wLogSecNum; /*߼θ*/ + UINT16 wRelateLogSecId[DSU_SPKS_STRU_LOGSECID]; /*߼ID*/ + UINT16 wManageCI; /*CI*/ + UINT16 wManageVirCI; /*CI*/ + UINT16 wPlatFormId; /*վ̨ID*/ +}DSU_LOGSEC_SPKS_BUTTON_STRU; + + /**/ +typedef struct DSU_DepotGate +{ + UINT16 wId; /**/ + UINT16 wDepotGateLinkID; /*Link*/ + UINT32 dwDepotGateLinkoffset; /*Linkƫ*/ + UINT16 wAPhysicalSgmtId; /*ŶӦAID*/ + UINT16 wBPhysicalSgmtId; /*ŶӦAID*/ + UINT16 sDepotAttribute; /**/ + UINT16 wRouteInsideNum; /*·*/ + UINT16 wRouteInsideId[10]; /*·*/ + UINT16 wRouteOutsideNum; /*·*/ + UINT16 wRouteOutsideId[8]; /*·*/ + UINT16 wSpksNum; /*ŶӦSPKS*/ + UINT16 wSpksId[4]; /*SPKSر*/ + UINT16 wProectSignalNum; /*ӦźŻ*/ + UINT16 wProtectSignalId[6]; /*źŻ*/ +}DSU_DEPOT_GATE_STRU; + + /* ----ݻͨӣ20160405*/ +typedef struct DSU_TunnelStruct +{ + UINT16 wId; /**/ + UINT16 wTunLinkId; /*link*/ + UINT32 dwBeginTunLinkOffset; /*linkƫ*/ + UINT32 dwEndTunLinkOffset; /*յlinkƫ*/ +} DSU_TUNNEL_STRU; + +/*ZCϢ ----ݻͨӣ20160507*/ +typedef struct DSU_ZCStruct +{ + UINT16 wIndex; /**/ + UINT16 wZCId; /*ZCID*/ + UINT32 dwVersionOfZCToVOBC; /*ZC-VOBCУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT32 dwVersionOfZCToDSU; /*ZC-DSUУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT32 dwVersionOfZCToATS; /*ZC-ATSУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT8 dwAdjoinZCCount; /*ZC----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT16 dwAdjoinZCId[6]; /*ZC[1-6]ID----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + UINT32 dwAdjoinZCShareCheckData[6]; /*ZC[1-6]ĹУϢ----ݻͨݽṹV16.0.0 by sds 2019-1-21*/ + +} DSU_ZC_STRU; + +/*࿪ݵĿ by qxt 20170621*/ +typedef struct DSU_MultiSwitchStruct +{ + UINT16 wId; /**/ + UINT8 wType; /**/ + UINT16 wSwitchIds[MAX_VIRTUAL_SWITCH_NUM]; /**/ + UINT16 wSwitchStates[MAX_VIRTUAL_SWITCH_NUM];/*״̬*/ + +}DSU_MULTI_SWITCH_STRU; + +typedef struct DSU_EmapEa +{ + UINT16 wId; /* ӵͼñ */ + UINT8 chStartLinkNum; /* ߽ */ + UINT16 szStartLinkId[5]; /* ߽link */ + UINT8 szStartLinkDir[5]; /* ߽ѯյ߼ */ + UINT8 chEndLinkNum; /* յ߽ */ + UINT16 szEndLinkId[5]; /* յ߽link */ + UINT8 szEndLinkDir[5]; /* յ߽ѯ߼ */ +}DSU_EMAP_EA_STRU; + +typedef struct DSU_StaticHead/*ž̬ݸݽṹͷָ*/ +{ + const UINT8 *dsuStaticDataVersion; /*̬ݿ汾*/ + DSU_LINK_STRU *pLinkStru;/*LinkϢṹָ*/ + DSU_POINT_STRU *pPointStru;/*Ϣṹָ*/ + DSU_STATIC_RES_SPEED_STRU *pStaticResSpeedStru;/*̬Ϣṹָ*/ + DSU_SIGNAL_STRU *pSignalStru;/*źŻϢṹָ*/ + DSU_BALISE_STRU *pBaliseStru;/*ӦϢṹָ*/ + DSU_AXLE_STRU *pAxleStru;/*Ϣṹָ*/ + DSU_SCREEN_STRU *pScreenStru;/*ȫϢṹָ*/ + DSU_STATION_STRU *pStationStru;/*ͣϢṹָ*/ + DSU_EMERG_STOP_STRU *pEmergStopStru;/*ͣťϢṹָ*/ + DSU_STOPPOINT_STRU *pStopPointStru;/*ͣϢṹָ*/ + DSU_RUN_LEVEL_STRU *pRunLevelStru;/*վӪṹָ*/ + DSU_GRADE_STRU *pGradeStru;/*¶Ϣṹָ*/ + DSU_EXIT_ROUTE_STRU *pExitRouteStru;/*Ϣṹָ*/ + DSU_TRAIN_LINE_STRU *pTrainLineStru;/*Ϣṹָ*/ + DSU_AXLE_SGMT_STRU *pAxleSgmtStru;/*Ϣṹָ*/ + DSU_LOGIC_SGMT_STRU *pLogicSgmtStru;/*߼Ϣṹָ*/ + DSU_ROUTE_STRU *pRouteStru;/*·Ϣṹָ*/ + DSU_PROTECT_LINK_STRU *pProtectLinkStru;/*Ϣṹָ*/ + DSU_CBTC_ACCESS_LINK_STRU *pCBTCAccessLinkStru;/*CBTCӽϢṹָ*/ + DSU_BLOC_ACCESS_LINK_STRU *pBLOCAccessLinkStru;/*ʽӽϢṹָ*/ + DSU_DEFAULTROUTE_STRU *pDefaultRoutStru;/*Ĭг·Ϣṹָ*/ + DSU_AR_IN_STRU *pARInStru;/*۷Ϣṹָ*/ + DSU_AR_OUT_STRU *pAROutStru;/*۷˳Ϣṹָ*/ + DSU_ZC_DIVID_POINT_STRU *pZCDividPointStru;/*ZCֽϢṹָ*/ + DSU_ATS_STRU *pATSStruStru;/*ATSϢṹָ*/ + DSU_CI_STRU *pCIStruStru;/*CIϢṹָ*/ + + + DSU_AR_STRU *pARStru; /*۷Ϣṹָ*/ /*Ӧṹ*/ + DSU_ZC_COM_ZONE_STRU *pZCComZoneStru;/*ZC*/ /*ǰzcֽ*/ + + DSU_CONRESSPEED_STRU *pConResSpeedStru; + DSU_CONGRADE_STRU * pConGradeStru; + DSU_PHYSICAL_SGMT_STRU* pPhysicalSgmtStru; + DSU_BLOC_TRG_AREA_STRU* pBlocTrgAreaStru; + DSU_CBTC_TRG_AREA_STRU* pCbtcTrgAreaStru; + DSU_PLAT_FORM_STRU * pPlatFormStru; + DSU_COME_GO_STRU *pComeGoRouteStru; /*·*/ + DSU_FLOOD_GATE_STRU *pFloodGateStru; /*ű*/ + DSU_SPKS_BUTTON_STRU *pSpksButtonStru; /*SPKSر*/ + DSU_DEPOT_GATE_STRU *pDepotGateStru; /*ű*/ + DSU_TUNNEL_STRU *pTunnelStru; /**/ + DSU_ZC_STRU *pZCStru; /*ZCϢṹָ*/ + DSU_MULTI_SWITCH_STRU *pMultiPointStru; /*࿪Ϣṹָ룬ݵĿ by qxt 20170621*/ + + DSU_POWERLESS_ZONE_STRU *pPowerlessZoneStru;/*Ϣṹָ룬ݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + DSU_CARSTOP_STRU *pCarStopStru;/*Ϣṹָ룬ݻͨݽṹV15.0.0ӣadd by sds 20181031*/ + DSU_AdjtStation_STRU *pAdjtStationStru;/*ͣϢṹָ룬ݻͨݽṹV18.0.0ӣadd by sds 20200211*/ + DSU_PSC_STRU *pPSCStru; /*PSCϢṹָ*/ + DSU_EMAP_EA_STRU *pEaStru; /*ṹָ*/ + DSU_LOGSEC_SPKS_BUTTON_STRU* pLogSecSpksButtonStru; /*߼SPKSرṹָ*/ +}DSU_STATIC_HEAD_STRU; + + + + +/*̬ݿṹ*/ +/*ʱٱ*/ +typedef struct DSU_TempResSpeedStruct /*3*4 + 8*2= 28*/ +{ + UINT32 dwOrgnLinkOfst; + UINT32 dwTmnlLinkOfst; + UINT32 dwResSpeed; + UINT16 wId; + UINT16 wOrgnLinkId; + UINT16 wTmnlLinkId; + UINT16 wIncludeLinkNum; + UINT16 wIncludeLinkId[4]; + +}DSU_TEMP_RES_SPEED_STRU; + +typedef struct DSU_DyncHead/*Ŷ̬ݿݽṹͷָ*/ +{ + DSU_TEMP_RES_SPEED_STRU *pTempResSpeedStru; +}DSU_DYNC_HEAD_STRU; + +/* ̬LINKѯʼ */ +typedef struct +{ + UINT16 linkId; + UINT16 limitStcSpdInfoIdBuf[LINK_MAX_LIMIT_SPD]; + UINT8 limitStcSpdInfoCount; +}DSU_STC_LIMIT_LINKIDX_STRU; + +/*ʵṹ*/ +typedef struct +{ + UINT16 Id; /**/ + UINT8 type; /**/ +}DSU_PHYSICAL_SWITCH_STRU; + +/*豸ṹ*/ +typedef struct +{ + UINT16 wDevSetId[LINK_MAX_DEVICE_NUM]; /*豸*/ + UINT8 wDevCount; /*豸*/ +}DSU_DEVICE_STRU; + +/*LinkϹ豸ṹ*/ +typedef struct +{ + UINT16 wLinkId; /*link*/ + DSU_DEVICE_STRU struSigalDev;/* źŻ豸*/ + DSU_DEVICE_STRU struBaliseDev; /*Ӧ豸*/ + DSU_DEVICE_STRU struScreenDev; /*ȫ豸*/ + DSU_DEVICE_STRU struESBDev;/*ͣť豸*/ + DSU_DEVICE_STRU struStationDev;/*ͣ豸*/ + DSU_DEVICE_STRU struStopPointDev;/*ͣ豸*/ + DSU_DEVICE_STRU struPlatformDev;/*վ̨豸*/ +}DSU_DEVICE_IN_LINK_STRU; + +/*Linkϰ¶Ϣadd by lmy 20171221*/ +typedef struct +{ + UINT16 wLinkId; /*link*/ + UINT16 wGradeId[LINK_MAX_GRADE_NUM];/*¶ȱ*/ + UINT8 wGradeCount; /*¶*/ +}DSU_GRADE_LINKIDX_STRU; + +/*Ϊȫ飬 + ̬Сṹ嶨*/ +typedef struct DSU_EmapIndexStruct +{ + UINT16 LINKINDEXNUM; /*ռС*/ + UINT16 *dsuLinkIndex; /*linkϢ*/ + + UINT16 POINTINDEXNUM; /*ռС*/ + UINT16 *dsuPointIndex; /*Ϣ*/ + + UINT16 BALISEINDEXNUM; /*ӦռС*/ + UINT16 *dsuBaliseIndex; /*ӦϢ*/ + + UINT16 SIGNALINDEXNUM; /*źŻռС*/ + UINT16 *dsuSignalIndex; /*źŻϢ*/ + + UINT16 AXLEINDEXNUM; /*ռС*/ + UINT16 *dsuAxleIndex; /*Ϣ*/ + + UINT16 SCREENINDEXNUM; /*ȫռС*/ + UINT16 *dsuScreenIndex; /*ȫϢ*/ + + UINT16 STATIONINDEXNUM; /*վռС*/ + UINT16 *dsuStationIndex; /*վ̨Ϣ*/ + + UINT16 EMERGSTOPINDEXNUM; /*ͣťռС*/ + UINT16 *dsuEmergStopIndex; /*ͣťϢ*/ + + UINT16 AXLESGMTINDEXNUM ; /*ռС*/ + UINT16 *dsuAxleSgmtIndex; /*Ϣ*/ + + UINT16 STOPPOINTINDEXNUM; /*ͣռС*/ + UINT16 *dsuStopPointIndex; /*ͣϢ*/ + + UINT16 TRAINLINEINDEXNUM; /*ռС*/ + UINT16 *dsuTrainLineIndex; /*Ϣ*/ + + UINT16 EXITROUTEINDEXNUM; /*˳CBTCռС*/ + UINT16 *dsuExitRouteIndex; /*˳CBTCϢ*/ + + UINT16 RUNLEVELINDEXNUM ; /*վмС*/ + UINT16 *dsuRunLevelIndex; /*վӪϢ*/ + + UINT16 STATICRESSPEEDNUM; /*·̬ռС*/ + UINT16 *dsuStaticResSpeedIndex; /*̬ϢϢ*/ + + UINT16 GRADEINDEXNUM; /*¶ռС*/ + UINT16 *dsuGradeIndex; /*¶Ϣ*/ + + UINT16 LOGICSGMTINDEXNUM; /*߼ռС*/ + UINT16 *dsuLogicSgmtIndex; /*߼Ϣ*/ + + UINT16 ROUTEINDEXNUM ; /*·ռС*/ + UINT16 *dsuRouteIndex; /*·Ϣ*/ + + UINT16 PROTECTLINKINDEXNUM ; /*ռС*/ + UINT16 *dsuProtectLinkIndex; /*·Ϣ*/ + + UINT16 CBTCACCESSLINKINDEXNUM ; /*CBTCӽռС*/ + UINT16 *dsuCBTCAccessLinkIndex; /*CBTC·ӽϢ*/ + + UINT16 BLOCACCESSLINKINDEXNUM ; /*BLOCӽռС*/ + UINT16 *dsuBLOCAccessLinkIndex; /*BLOC·ӽϢ*/ + + UINT16 DEFAULTROUTEINDEXNUM ; /*ĬгռС*/ + UINT16 *dsuDefaultRoutIndex; /*ĬгϢ*/ + + UINT16 ARINNUM; /*۷ռС*/ + UINT16 *dsuARInIndex; /*۷Ϣ*/ + + UINT16 AROUTNUM; /*۷˳ռС*/ + UINT16 *dsuAROutIndex; /*۷˳Ϣ*/ + + UINT16 ATSINDEXNUM ; /*ATSռС*/ + UINT16 *dsuATSIndex; /*ATSϢ*/ + + UINT16 CIINDEXNUM ; /*CIռС*/ + UINT16 *dsuCIIndex; /*CIϢ*/ + + UINT16 ARNUM ; /*۷С*/ + UINT16 *dsuARIndex; /*ӵĽṹԶ۷Ӧ*/ + + UINT16 ZCCOMZONENUM; /*ZCС*/ + UINT16 *dsuZCComZoneIndex; /*ӵZC򣬶Ӧ 2012.1.5*/ + + UINT16 CONRESSPEEDINDEXNUM; /*ͳһС*/ + UINT16 *dsuConResSpeedIndex; + + UINT16 CONGRADEINDEXNUM; /*ͳһ¶С*/ + UINT16 *dsuConGradeIndex; + + UINT16 ZCDIVIDPOINTINDEXNUM; /*ZCֽС*/ + UINT16 *dsuZCDividPointIndex; + + UINT16 PHYSICALSGMTINDEXNUM; /*С*/ + UINT16 *dsuPhysicalSgmtIndex; /**/ + + UINT16 BLOCTRGAREAINDEXNUM; /*ʽС*/ + UINT16 *dsuBlocTrgAreaIndex; /*ʽ*/ + + UINT16 CBTCTRGAREAINDEXNUM; /*CBTCС*/ + UINT16 *dsuCbtcTrgAreaIndex; /*CBTC*/ + + UINT16 PLATFORMINDEXNUM; /*վ̨С*/ + UINT16 *dsuPlatFormIndex; /*վ̨*/ + + UINT16 COMEGOINDEXNUM; /*·С,2013.10.23*/ + UINT16 *dsuComeGoIndex; /*·*/ + + UINT16 FLOODGATEINDEXNUM; /*С2014.7.17*/ + UINT16 *dsuFloodGateIndex; /**/ + + UINT16 SPKSBUTTONINDEXNUM; /*SPKSС*/ + UINT16 *dsuSpksButtonIndex; /*SPKSť*/ + + UINT16 DEPOTGATEINDEXNUM; /*С*/ + UINT16 *dsuDepotGateIndex; /**/ + + UINT16 TUNNELINDEXNUM; /*С*/ + UINT16 *dsuTunnelIndex; /**/ + + UINT16 ZCINDEXNUM; /*ZCС*/ + UINT16 *dsuZCIndex; /*ZC*/ + + UINT16 MULTIPOINTINDEXNUM; /*࿪С by qxt 20170621*/ + UINT16 *dsuMultiPointIndex; /*࿪*/ + + UINT16 POWERLESSZONEINDEXNUM; /*СݻͨݽṹV12.0.0ӣadd by lmy 20180312*/ + UINT16 *dsuPowerlessZoneIndex; /**/ + + UINT16 CARSTOPINDEXNUM; /*СݻͨݽṹV15.0.0ӣadd by sds 20181031*/ + UINT16 *dsuCarStopIndex; /**/ + + UINT16 ADJTSTATIONINDEXNUM; /*ͣСݻͨݽṹV18.0.0ӣadd by sds 20200211*/ + UINT16 *dsuAdjtStationIndex; /*ͣ*/ + + UINT16 PSCINDEXNUM; /*PSCС*/ + UINT16 *dsuPSCIndex; /*PSC*/ + + UINT16 EAINDEXNUM; /*С*/ + UINT16 *dsuEaIndex; /**/ + + UINT16 LOGSECSPKSINDEXNUM; /*߼SPKSС*/ + UINT16* dsulogSecSpksIndex; /*߼SPKS*/ +}DSU_EMAP_INDEX_STRU; + +/*ӵͼȫṹܽṹ*/ +typedef struct DSU_EmapStruct +{ + UINT8 wLineNum; /*ǰָָ·,ͨadd by qxt 20190904*/ + DSU_EMAP_INDEX_STRU *dsuEmapIndexStru; /*ŵӵͼṹ*/ + + DSU_DATA_LEN_STRU *dsuDataLenStru; /*ȫֱ¼ȡDSUеĸݵ*/ + + DSU_STATIC_HEAD_STRU *dsuStaticHeadStru; /*ݿÿֽṹͷָ*/ + +}DSU_EMAP_STRU; + +/*ӵͼչݽṹ*/ +typedef struct DSU_EmapExtend +{ + DSU_PHYSICAL_SWITCH_STRU *pDsuPhysicalSwitchIdx; /*ʵ*/ + UINT16 PHYSICALSWITCHNUM; /*ʵ*/ + + /*Link豸ӳϵ add by qxt 20170816*/ + /*ʹע⣺ΪLINKռСLINKINDEXNUM,LinkһеıֵʹʱֱLinkλϢ + ٶLINKINDEXNUMڵЧLinkpDsuDeviceInLinkIdx->wLinkId=0; + ڶӦ豸ӦLinkpDsuDeviceInLinkIdx->wLinkId=0*/ + DSU_DEVICE_IN_LINK_STRU *pDsuDeviceInLinkIdx; /*Link豸ӳϵ*/ + + DSU_GRADE_LINKIDX_STRU *pDsuGradeInLinkIdx;/*Linkϰ¶Ϣṹ壬add by lmy 20180122*/ +}DSU_EMAP_EXTEND_STRU; + +/*ݿṹ*/ +extern DSU_EMAP_STRU *g_dsuEmapStru; +extern DSU_STC_LIMIT_LINKIDX_STRU **g_ppDsuLimitStcLinkIdx; + +/*ԵĿӣadd by qxt 20170621*/ +extern DSU_EMAP_EXTEND_STRU *g_dsuEmapExtendStru; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/dqu_common/dqu_emap_common/dsuVar.c b/TSCP/src/dqu_common/dqu_emap_common/dsuVar.c new file mode 100644 index 0000000..768e4d8 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dsuVar.c @@ -0,0 +1,144 @@ +/************************************************************************ +* +* ļ dsuVar.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* dsu +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#define DSUVAR_DEFINE + +#include "dsuVar.h" +#include "dsuStruct.h" +#include "dfsDataRead.h" + +/*̬*/ +DSU_EMAP_STRU *g_dsuEmapStru=NULL; +DSU_STC_LIMIT_LINKIDX_STRU **g_ppDsuLimitStcLinkIdx=NULL; + +/*ԵĿӣadd by qxt 20170726*/ +DSU_EMAP_EXTEND_STRU *g_dsuEmapExtendStru=NULL; + +static UINT16 g_dsuEmapDataArrayLen[DFS_DATA_INDEX_NUM] = {0};/*ڴ洢ӵͼиĸ*/ +static UINT16 g_dsuEmapIndexArrayLen[DFS_DATA_INDEX_NUM] = {0};/*ڴ洢ӵͼиĸ*/ + +/* þ̬Linkٲѯ */ +UINT8 dquSetInitStaticLimitLinkRef(DSU_STC_LIMIT_LINKIDX_STRU **ppDsuLimitStcLinkIdx) +{ + UINT8 bRetVal=0U; + if (NULL!=ppDsuLimitStcLinkIdx) + { + g_ppDsuLimitStcLinkIdx=ppDsuLimitStcLinkIdx; + bRetVal=1; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + +/*õӵͼ̬ṹ*/ +UINT8 dquSetInitEmapRef(DSU_EMAP_STRU *pDsuEmapStru) +{ + UINT8 bRetVal=0U; + if (NULL!=pDsuEmapStru) + { + g_dsuEmapStru=pDsuEmapStru; + bRetVal=1; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + +/*õӵͼӦĸ*/ +UINT8 dquSetEmapDataStruArrayLen(UINT16 wDataID, UINT16 wStruDataLen ) +{ + UINT8 bRetVal=0U; + if (wDataID < DFS_DATA_INDEX_NUM) + { + g_dsuEmapDataArrayLen[wDataID]=wStruDataLen; + bRetVal=1; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + +/*õӵͼжӦĸ*/ +UINT8 dquSetEmapDataIndexArrayLen(UINT16 wDataID, UINT16 wDataIndexLen) +{ + UINT8 bRetVal=0U; + if (wDataID < DFS_DATA_INDEX_NUM) + { + g_dsuEmapIndexArrayLen[wDataID]=wDataIndexLen; + bRetVal=1; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + +/*ȡӵͼӦĸ*/ +UINT8 dquGetEmapDataStruArrayLen(UINT16 wDataID, UINT16 *pStruDataLen ) +{ + UINT8 bRetVal=0U; + if ((wDataID < DFS_DATA_INDEX_NUM) && (NULL != pStruDataLen)) + { + *pStruDataLen=g_dsuEmapDataArrayLen[wDataID]; + bRetVal=1; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + + /*õӵͼжӦĸ*/ +UINT8 dquGetEmapDataIndexArrayLen(UINT16 wDataID, UINT16 *pDataIndexLen) +{ + UINT8 bRetVal=0U; + if ((wDataID < DFS_DATA_INDEX_NUM) && (NULL!= pDataIndexLen)) + { + *pDataIndexLen=g_dsuEmapIndexArrayLen[wDataID]; + bRetVal=1; + } + else + { + bRetVal=0U; + } + + return bRetVal; +} + +UINT8 dquSetInitEmapExtendRef(DSU_EMAP_EXTEND_STRU *pEmapExtendStru) +{ + UINT8 rtnValue=0U; + if (NULL!=pEmapExtendStru) + { + g_dsuEmapExtendStru=pEmapExtendStru; + rtnValue=1; + } + else + { + /**/ + } + return rtnValue; +} diff --git a/TSCP/src/dqu_common/dqu_emap_common/dsuVar.h b/TSCP/src/dqu_common/dqu_emap_common/dsuVar.h new file mode 100644 index 0000000..dc13998 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_emap_common/dsuVar.h @@ -0,0 +1,60 @@ +/************************************************************************ +* +* ļ dsuVar.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.27 +* з +* dsuͷļ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef _DSU_VAR_H_ +#define _DSU_VAR_H_ + +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "dsuStruct.h" +#include "dquDataTypeDefine.h" + +#ifdef DSUVAR_DEFINE +#define EXTERN +#else +#define EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /* þ̬Linkٲѯ */ + UINT8 dquSetInitStaticLimitLinkRef(DSU_STC_LIMIT_LINKIDX_STRU **ppDsuLimitStcLinkIdx); + + /*õӵͼ̬ṹ*/ + UINT8 dquSetInitEmapRef(DSU_EMAP_STRU *pDsuEmapStru); + +/*½ӿںṩVOBCȼʹõڼԤڴǷ㹻FSļеӵͼ*/ + + /*õӵͼӦĸ*/ + UINT8 dquSetEmapDataStruArrayLen(UINT16 wDataID, UINT16 wStruDataLen); + + /*õӵͼжӦĸ*/ + UINT8 dquSetEmapDataIndexArrayLen(UINT16 wDataID, UINT16 wDataIndexLen); + + /*ȡӵͼӦĸ*/ + UINT8 dquGetEmapDataStruArrayLen(UINT16 wDataID, UINT16 *pStruDataLen); + + /*õӵͼжӦĸ*/ + UINT8 dquGetEmapDataIndexArrayLen(UINT16 wDataID, UINT16 *pDataIndexLen); + + /*õӵͼչݽṹ add by qxt 20170726*/ + UINT8 dquSetInitEmapExtendRef(DSU_EMAP_EXTEND_STRU *pEmapExtendStru); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapInit.c b/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapInit.c new file mode 100644 index 0000000..530a3e9 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapInit.c @@ -0,0 +1,4532 @@ +/************************************************************************ +* +* ļ dquIdmapInit.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2016.03.21 +* +* Ŷձʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include +#include "dquIdmapInit.h" +#include "dsuIdmapStruct.h" +#include "dquCbtcType.h" + +UINT8 dfsIdmapInitFlag = 0; +UINT8 initIdMapErrNo[INIT_IDMAP_ERR_NUM]; /*ݳʼʧܹϺ*/ + +static dfsDataHead g_DFsDH; /*FSļͷṹ*/ +static UINT8* g_pDataAddr; /*FSԪݵַ*/ +static UINT32 g_DataSize; /*FSԪݴСֽ*/ +static UINT16 g_RowCount; /**/ + +static UINT16 g_wCurInitStruProg=0U;/*ǰṹʼֲ̣ʱʹ*/ +static UINT16 g_wCurMainIndex=0U; /*ǰֲʱʹ*/ +static UINT8 g_IdmapInitMode=0x01; /*Ŷձʼģʽ*/ +static UINT8 g_IsIdmapAllocMemory = 0x01; /*ļʽӿϵʼڴ*/ +static UINT8 IdmapInitFunStepCtrl(UINT16 wStep);/*ӵͼʼֲƺ*/ + +/*ʼǼDZ*/ +static INIT_TASK_TAB_STRU g_struInitTaskTab[]= +{ + {DQU_QFUN_TRUE, IDMAP_ZC_ID, initZCNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_CI_ID, initCINum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_ATS_ID, initATSNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_SIGNAL_ID, initSignalNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_TRACKSEC_ID, initTrackSecNum,5,1,0}, + {DQU_QFUN_TRUE, IDMAP_SWITCH_ID, initSwitchNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_STATION_ID, initStationNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_EMERGBTN_ID, initEmergBtnNum,5,1,0}, + {DQU_QFUN_TRUE, IDMAP_BALISE_ID, initBaliseNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_PSD_ID, initPSDoorNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_VOBC_ID, initVobcNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_FPD_ID, initFPDoorNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_DSU_ID, initDsuNum, 5,1,0}, + {DQU_QFUN_TRUE, IDMAP_LOGICSEC_ID, initLogicSecNum,5,1,0}, + {DQU_QFUN_TRUE, IDMAP_AOMSEC_ID, initAomSecNum,5,1,0}, + {DQU_QFUN_TRUE, IDMAP_SPKSSEC_ID, initSpksSecNum,5,1,0}, + {DQU_QFUN_TRUE, IDMAP_GODSEC_ID, initGodSecNum,5,1,0}, + {DQU_QFUN_TRUE, IDMAP_STASEC_ID, initStaSecNum,5,1,0}, + {DQU_QFUN_TRUE, IDMAP_PHYSEC_ID, initPhySecNum,5,1,0 }, + {DQU_QFUN_TRUE, IDMAP_AXLE_ID, initAxleNum, 5,1,0 }, + {DQU_QFUN_TRUE, IDMAP_ITE_ID, initIteNum, 5,1,0 }, +}; +/*ʼǼDZĿ*/ +static const UINT16 MAX_INITTASK_COUNT=sizeof(g_struInitTaskTab)/sizeof(INIT_TASK_TAB_STRU); + + + +/********************************************* +*ܣŶձʼ +*˵FSNameļָ +*ֵ0ʧܣ1ɹ +*********************************************/ +UINT8 dfsIdmapInit(CHAR * FSName) +{ + UINT16 wIndex=0U; + UINT8 funcRtn = 0; + UINT8 rtnValue = 0U; + UINT32 DataID=0U;/*ͱʶ*/ + UINT8 *pDataAddr=NULL; + UINT32 DataSize=0U; + UINT16 rowCount = 0; + + /*ʼϢ¼*/ + memset(initIdMapErrNo, 0, INIT_IDMAP_ERR_NUM); + + if (NULL!=g_dsuIdmapStru) + { + /*ʼһξ*/ + if (dfsIdmapInitFlag == 1) + { + rtnValue = 1U; + return rtnValue; + } + + g_IdmapInitMode=0x01;/*ϵģʽ*/ + + g_IsIdmapAllocMemory=0x01;/*Ĭϱӿڷڴ*/ + + /*̬ռ*/ + g_dsuIdmapStru->dsuIdmapLenStru=(DSU_IDMAP_LEN_STRU*)MyNew(sizeof(DSU_IDMAP_LEN_STRU)); + + /*̬ռʧ*/ + if (NULL != g_dsuIdmapStru->dsuIdmapLenStru) + { + /*ʼΪ0xFF*/ + memset(g_dsuIdmapStru->dsuIdmapLenStru, 0x0, sizeof(DSU_IDMAP_LEN_STRU)); + } + else + { + rtnValue = 0U;; + + } + + /*̬ռ*/ + g_dsuIdmapStru->dsuStaticIdmapStru=(DSU_STATIC_IDMAP_STRU*)MyNew(sizeof(DSU_STATIC_IDMAP_STRU)); + + /*̬ռʧ*/ + if (NULL != g_dsuIdmapStru->dsuStaticIdmapStru) + { + /*ʼΪ0xFF*/ + memset(g_dsuIdmapStru->dsuStaticIdmapStru, 0x0, sizeof(DSU_STATIC_IDMAP_STRU)); + } + else + { + rtnValue = 0U;; + + } + + /*̬ռ*/ + g_dsuIdmapStru->dsuIdmapIndexStru=(DSU_IDMAP_INDEX_STRU*)MyNew(sizeof(DSU_IDMAP_INDEX_STRU)); + + /*̬ռʧ*/ + if (NULL != g_dsuIdmapStru->dsuIdmapIndexStru) + { + /*ʼΪ0xFF*/ + memset(g_dsuIdmapStru->dsuIdmapIndexStru, 0x0, sizeof(DSU_IDMAP_INDEX_STRU)); + } + else + { + rtnValue = 0U;; + + } + + /*ʼ*/ + wIndex=0U; + do /*ݵӦĽṹ*/ + { + if (DQU_QFUN_TRUE == g_struInitTaskTab[wIndex].bIsEffective)/*жʼǷִ*/ + { + /*ȡ*/ + DataID=g_struInitTaskTab[wIndex].DataTypeId; + funcRtn=dquGetConfigDataNew( FSName, IDMAP_DATA_TYPE, DataID, &pDataAddr, &DataSize, &rowCount); + if (funcRtn != 1) + { + /*ʧ*/ + initIdMapErrNo[DataID] |= DEBUG_GET_DATA_FAIL; + rtnValue = 0U;; + return rtnValue; + } + funcRtn=g_struInitTaskTab[wIndex].pExeFun(pDataAddr,DataSize,rowCount); + if (0U == funcRtn) + { + rtnValue = 0U;; + return rtnValue; + } + else/*ִ*/ + { + } + } + + wIndex++; + } while (wIndex=MAX_INITTASK_COUNT) ״̬£нṹʼ*/ + { + g_wCurMainIndex=3; + } + rtnValue = 2; + } + else if(2 == funcRtn)/*ֲδ*/ + { + g_struInitTaskTab[g_wCurInitStruProg].wCurProcStage++; + rtnValue = 2; + + } + else/*쳣*/ + { + rtnValue = 0U; + } + + break; + case 3: + rtnValue=1; + + break; + default: + rtnValue = 0U; + break; + + } + + /*쳣˳*/ + if(2 != rtnValue) + { + break; + } + + /*ʱͳƼ㴦*/ + if (0x02 == mode) + { + /*ȡǰʱ*/ + dwCurTimePoint=dquGetCurrentTimeByMS(); + + /*ʣʱ */ + dwUsedTime=dwCurTimePoint-dwBeginTimePoint; + /*㵥ִʱ */ + dwOnceTime=dwCurTimePoint-dwLastTimePoint; + /*ʷʱ */ + dwLastTimePoint=dwCurTimePoint; + + /*ʹõʱСʱƬ */ + if (dwUsedTime < timeSlice) + { + /*ʣµĴʱ乻ִһδ*/ + if ( dwOnceTime > 0 ) + { + wFreqTimes = (timeSlice-dwUsedTime)/dwOnceTime; + } + else /*ִʱС1msִ*/ + { + wFreqTimes = 1; + } + + /*ִб־*/ + if (wFreqTimes >= 1) + { + bExeState=DQU_QFUN_TRUE; + } + else /*ʣʱ䲻һִ*/ + { + bExeState=DQU_QFUN_FASLE; + } + } + else/*ʱ˳һδʱС1ĬҲ˳*/ + { /* ֹֽжС1봦ۻѾʱ*/ + + bExeState=DQU_QFUN_FASLE; + } + } + + /*ģʽΪϵʱһֱִ,ִ״̬Ϊ*/ + } while ((0x01 == mode) ||(DQU_QFUN_TRUE == bExeState) ); + + return rtnValue; +} + + +/*ŶձʼϣִбŶձڲ*/ +UINT8 dfsIdmapInitFinally() +{ + UINT16 wIndex=0U; + UINT8 bRetVal=0U; + + g_wCurInitStruProg=0U;/*ǰṹʼֲ̣ʱʹ*/ + g_wCurMainIndex=0U; /*ǰֲʱʹ*/ + g_IdmapInitMode=0x01; /*ӵͼʼģʽ*/ + + /*ݳʼ״̬*/ + for(wIndex=0;wIndex 0x03)) + { + bIsEffective=DQU_QFUN_TRUE; + } + else + { + /*do nothing*/ + } + } + + return bIsEffective; + +} + +/*Ŷձʼѭֲи*/ +static UINT8 IdmapInitLoopStepLenCtrl(UINT32 dwIndex) +{ + UINT8 bIsEffective=DQU_QFUN_FASLE; + + if (0x01 == g_IdmapInitMode) /*ϵش*/ + { + bIsEffective=DQU_QFUN_FASLE; + } + else /*ֲ*/ + { + if (g_struInitTaskTab[g_wCurInitStruProg].wStepLen==dwIndex-g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos + 1) + { + g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos=dwIndex+1; + bIsEffective=DQU_QFUN_TRUE; + } + } + + return bIsEffective; +} + + +/********************************************** +ܣʼ[ZC]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initZCNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_ZC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_ZC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wZCNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = ZCNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->ZCNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuZCNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->ZCNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuZCNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuZCNumIndex, 0xFF, dsuIdmapIndexStru->ZCNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pZCNumStru = (DSU_ZC_NUM_STRU *)MyNew(sizeof(DSU_ZC_NUM_STRU) * dsuIdmapLenStru->wZCNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pZCNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pZCNumStru, 0xFF, sizeof(DSU_ZC_NUM_STRU) * dsuIdmapLenStru->wZCNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_ZC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wZCNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_ZC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->ZCNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wZCNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pZCNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = ZCNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuZCNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + + } + /*ѭֲи*/ + if ((0U==rtnValue) || (DQU_QFUN_TRUE == initFlag)) + { + break; + } + + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wZCNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[CI]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCINum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_CI_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_CI_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wCINumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = CINumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->CINUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE ==initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuCINumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->CINUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuCINumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuCINumIndex, 0xFF, dsuIdmapIndexStru->CINUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pCINumStru = (DSU_CI_NUM_STRU *)MyNew(sizeof(DSU_CI_NUM_STRU) * dsuIdmapLenStru->wCINumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pCINumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pCINumStru, 0xFF, sizeof(DSU_CI_NUM_STRU) * dsuIdmapLenStru->wCINumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_CI_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wCINumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_CI_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->CINUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wCINumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pCINumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = CINumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuCINumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == initFlag) || (DQU_QFUN_TRUE == initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wCINumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[ATS]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initATSNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_ATS_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_ATS_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wATSNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = ATSNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->ATSNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuATSNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->ATSNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuATSNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuATSNumIndex, 0xFF, dsuIdmapIndexStru->ATSNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pATSNumStru = (DSU_ATS_NUM_STRU *)MyNew(sizeof(DSU_ATS_NUM_STRU) * dsuIdmapLenStru->wATSNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pATSNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pATSNumStru, 0xFF, sizeof(DSU_ATS_NUM_STRU) * dsuIdmapLenStru->wATSNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_ATS_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wATSNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_ATS_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->ATSNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wATSNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pATSNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = ATSNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuATSNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wATSNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[źŻ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSignalNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_SIGNAL_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_SIGNAL_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wSignalNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag =SignalNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->SIGNALNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuSignalNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->SIGNALNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuSignalNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuSignalNumIndex, 0xFF, dsuIdmapIndexStru->SIGNALNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pSignalNumStru = (DSU_SIGNAL_NUM_STRU *)MyNew(sizeof(DSU_SIGNAL_NUM_STRU) * dsuIdmapLenStru->wSignalNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pSignalNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pSignalNumStru, 0xFF, sizeof(DSU_SIGNAL_NUM_STRU) * dsuIdmapLenStru->wSignalNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_SIGNAL_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wSignalNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_SIGNAL_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->SIGNALNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wSignalNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pSignalNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = SignalNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuSignalNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U== rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wSignalNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initTrackSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_TRACKSEC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_TRACKSEC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wTrackSecNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = TrackSecNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if(0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->TRACKSECNUMINDEXSIZE = stru.wLinkId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuTrackSecNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->TRACKSECNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuTrackSecNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuTrackSecNumIndex, 0xFF, dsuIdmapIndexStru->TRACKSECNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pTrackSecNumStru = (DSU_TRACKSEC_NUM_STRU *)MyNew(sizeof(DSU_TRACKSEC_NUM_STRU) * dsuIdmapLenStru->wTrackSecNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pTrackSecNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pTrackSecNumStru, 0xFF, sizeof(DSU_TRACKSEC_NUM_STRU) * dsuIdmapLenStru->wTrackSecNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_TRACKSEC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wTrackSecNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_TRACKSEC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->TRACKSECNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wTrackSecNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pTrackSecNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = TrackSecNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuTrackSecNumIndex[pCurrentStru->wLinkId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wTrackSecNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSwitchNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_SWITCH_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_SWITCH_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wSwitchNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = SwitchNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->SWITCHNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuSwitchNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->SWITCHNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuSwitchNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuSwitchNumIndex, 0xFF, dsuIdmapIndexStru->SWITCHNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pSwitchNumStru = (DSU_SWITCH_NUM_STRU *)MyNew(sizeof(DSU_SWITCH_NUM_STRU) * dsuIdmapLenStru->wSwitchNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pSwitchNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pSwitchNumStru, 0xFF, sizeof(DSU_SWITCH_NUM_STRU) * dsuIdmapLenStru->wSwitchNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_SWITCH_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wSwitchNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_SWITCH_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->SWITCHNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wSwitchNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pSwitchNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = SwitchNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuSwitchNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wSwitchNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[߼վ̨]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStationNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_STATION_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_STATION_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wStationNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = StationNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if((0U!= initFlag)) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->STATIONNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuStationNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->STATIONNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuStationNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuStationNumIndex, 0xFF, dsuIdmapIndexStru->STATIONNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pStationNumStru = (DSU_STATION_NUM_STRU *)MyNew(sizeof(DSU_STATION_NUM_STRU) * dsuIdmapLenStru->wStationNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pStationNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pStationNumStru, 0xFF, sizeof(DSU_STATION_NUM_STRU) * dsuIdmapLenStru->wStationNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetIdmapDataStruArrayLen(IDMAP_STATION_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wStationNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_STATION_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->STATIONNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wStationNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pStationNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = StationNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuStationNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U==rtnValue )|| (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) &&( j==dsuIdmapLenStru->wStationNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[رհť]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initEmergBtnNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_EMERGBTN_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_EMERGBTN_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wEmergBtnNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = EmergBtnNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->EMERGBTNNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuEmergBtnIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->EMERGBTNNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuEmergBtnIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuEmergBtnIndex, 0xFF, dsuIdmapIndexStru->EMERGBTNNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pEmergBtnNumStru = (DSU_EMERGBTN_NUM_STRU *)MyNew(sizeof(DSU_EMERGBTN_NUM_STRU) * dsuIdmapLenStru->wEmergBtnNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pEmergBtnNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pEmergBtnNumStru, 0xFF, sizeof(DSU_EMERGBTN_NUM_STRU) * dsuIdmapLenStru->wEmergBtnNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_EMERGBTN_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wEmergBtnNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_EMERGBTN_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->EMERGBTNNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wEmergBtnNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pEmergBtnNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = EmergBtnNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuEmergBtnIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wEmergBtnNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[Ӧ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initBaliseNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_BALISE_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_BALISE_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wBaliseNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = BaliseNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if((0U!= initFlag)) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->BALISENUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuBaliseNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->BALISENUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuBaliseNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuBaliseNumIndex, 0xFF, dsuIdmapIndexStru->BALISENUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pBaliseNumStru = (DSU_BALISE_NUM_STRU *)MyNew(sizeof(DSU_BALISE_NUM_STRU) * dsuIdmapLenStru->wBaliseNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pBaliseNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pBaliseNumStru, 0xFF, sizeof(DSU_BALISE_NUM_STRU) * dsuIdmapLenStru->wBaliseNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_BALISE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wBaliseNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_BALISE_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->BALISENUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wBaliseNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pBaliseNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = BaliseNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuBaliseNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wBaliseNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPSDoorNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_PSD_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_PSD_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wPSDoorNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = PSDoorNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U!= initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->PSDNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuPSDoorNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->PSDNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuPSDoorNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuPSDoorNumIndex, 0xFF, dsuIdmapIndexStru->PSDNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pPSDNumStru = (DSU_PSD_NUM_STRU *)MyNew(sizeof(DSU_PSD_NUM_STRU) * dsuIdmapLenStru->wPSDoorNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pPSDNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pPSDNumStru, 0xFF, sizeof(DSU_PSD_NUM_STRU) * dsuIdmapLenStru->wPSDoorNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_PSD_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wPSDoorNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_PSD_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->PSDNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wPSDoorNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pPSDNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = PSDoorNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuPSDoorNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wPSDoorNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[VOBC]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initVobcNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_VOBC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_VOBC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wVobcNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = VOBCNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->VOBCNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuVobcNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->VOBCNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuVobcNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuVobcNumIndex, 0xFF, dsuIdmapIndexStru->VOBCNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pVobcNumStru = (DSU_VOBC_NUM_STRU *)MyNew(sizeof(DSU_VOBC_NUM_STRU) * dsuIdmapLenStru->wVobcNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pVobcNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pVobcNumStru, 0xFF, sizeof(DSU_VOBC_NUM_STRU) * dsuIdmapLenStru->wVobcNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_VOBC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wVobcNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetIdmapDataIndexArrayLen(IDMAP_VOBC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->VOBCNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wVobcNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pVobcNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = VOBCNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuVobcNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wVobcNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initFPDoorNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_FPD_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_FPD_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wFPDoorNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = FPDoorNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->FPDNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuFPDoorNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->FPDNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuFPDoorNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuFPDoorNumIndex, 0xFF, dsuIdmapIndexStru->FPDNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pFPDoorNumStru = (DSU_FPD_NUM_STRU *)MyNew(sizeof(DSU_FPD_NUM_STRU) * dsuIdmapLenStru->wFPDoorNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pFPDoorNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pFPDoorNumStru, 0xFF, sizeof(DSU_FPD_NUM_STRU) * dsuIdmapLenStru->wFPDoorNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_FPD_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wFPDoorNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_FPD_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->FPDNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wFPDoorNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pFPDoorNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = FPDoorNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuFPDoorNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wFPDoorNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[DSU]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initDsuNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_DSU_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_DSU_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wDsuNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = DsuNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->DSUNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuDsuNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->DSUNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuDsuNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuDsuNumIndex, 0xFF, dsuIdmapIndexStru->DSUNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pDsuNumStru = (DSU_DSU_NUM_STRU *)MyNew(sizeof(DSU_DSU_NUM_STRU) * dsuIdmapLenStru->wDsuNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pDsuNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pDsuNumStru, 0xFF, sizeof(DSU_DSU_NUM_STRU) * dsuIdmapLenStru->wDsuNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_DSU_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wDsuNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_DSU_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->DSUNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wDsuNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pDsuNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = DsuNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuDsuNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE== initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wDsuNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[߼]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initLogicSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_LOGICSEC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_LOGICSEC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wLogicSecNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = LogicSecNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->LOGICSECNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuLogicSecNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->LOGICSECNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuLogicSecNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuLogicSecNumIndex, 0xFF, dsuIdmapIndexStru->LOGICSECNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pLogicSecNumStru = (DSU_LOGICSEC_NUM_STRU *)MyNew(sizeof(DSU_LOGICSEC_NUM_STRU) * dsuIdmapLenStru->wLogicSecNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pLogicSecNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pLogicSecNumStru, 0xFF, sizeof(DSU_LOGICSEC_NUM_STRU) * dsuIdmapLenStru->wLogicSecNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag= dquGetIdmapDataStruArrayLen(IDMAP_LOGICSEC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wLogicSecNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetIdmapDataIndexArrayLen(IDMAP_LOGICSEC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->LOGICSECNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wLogicSecNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pLogicSecNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = LogicSecNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuLogicSecNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wLogicSecNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[AOM]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAomSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_AOMSEC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_AOMSEC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wAomSecNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = AomSecNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->AOMSECNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuAomSecNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->AOMSECNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuAomSecNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuAomSecNumIndex, 0xFF, dsuIdmapIndexStru->AOMSECNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pAomSecNumStru = (DSU_AOMSEC_NUM_STRU *)MyNew(sizeof(DSU_AOMSEC_NUM_STRU) * dsuIdmapLenStru->wAomSecNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pAomSecNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pAomSecNumStru, 0xFF, sizeof(DSU_AOMSEC_NUM_STRU) * dsuIdmapLenStru->wAomSecNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_AOMSEC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wAomSecNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_AOMSEC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->AOMSECNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wAomSecNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pAomSecNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = AomSecNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuAomSecNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wAomSecNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[SPKS]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSpksSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_SPKSSEC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_SPKSSEC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wSpksSecNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = SpksSecNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->SPKSSECNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuSpksSecNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->SPKSSECNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuSpksSecNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuSpksSecNumIndex, 0xFF, dsuIdmapIndexStru->SPKSSECNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pSpksSecNumStru = (DSU_SPKSSEC_NUM_STRU *)MyNew(sizeof(DSU_SPKSSEC_NUM_STRU) * dsuIdmapLenStru->wSpksSecNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pSpksSecNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pSpksSecNumStru, 0xFF, sizeof(DSU_SPKSSEC_NUM_STRU) * dsuIdmapLenStru->wSpksSecNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_SPKSSEC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wSpksSecNumLen >= wStruDataLen))||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_SPKSSEC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->SPKSSECNUMINDEXSIZE >= wDataIndexLen))||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wSpksSecNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pSpksSecNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = SpksSecNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuSpksSecNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wSpksSecNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initGodSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_GODSEC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_GODSEC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wGodSecNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = GodSecNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->GODSECNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuGodSecNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->GODSECNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuGodSecNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuGodSecNumIndex, 0xFF, dsuIdmapIndexStru->GODSECNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pGodSecNumStru = (DSU_GODSEC_NUM_STRU *)MyNew(sizeof(DSU_GODSEC_NUM_STRU) * dsuIdmapLenStru->wGodSecNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pGodSecNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pGodSecNumStru, 0xFF, sizeof(DSU_GODSEC_NUM_STRU) * dsuIdmapLenStru->wGodSecNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_GODSEC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wGodSecNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_GODSEC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->GODSECNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wGodSecNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pGodSecNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = GodSecNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuGodSecNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) &&( j==dsuIdmapLenStru->wGodSecNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[վ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStaSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_STASEC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_STASEC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wStaSecNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = StaSecNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->STASECNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuStaSecNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->STASECNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuStaSecNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuStaSecNumIndex, 0xFF, dsuIdmapIndexStru->STASECNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pStaSecNumStru = (DSU_STASEC_NUM_STRU *)MyNew(sizeof(DSU_STASEC_NUM_STRU) * dsuIdmapLenStru->wStaSecNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pStaSecNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pStaSecNumStru, 0xFF, sizeof(DSU_STASEC_NUM_STRU) * dsuIdmapLenStru->wStaSecNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_STASEC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wStaSecNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_STASEC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->STASECNUMINDEXSIZE >= wDataIndexLen)) + ||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wStaSecNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pStaSecNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = StaSecNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuStaSecNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wStaSecNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPhySecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 *pData=NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_PHYSEC_NUM_STRU *pCurrentStru=NULL; /*ṹʱָ*/ + DSU_PHYSEC_NUM_STRU stru={0}; /*ṹʱָ*/ + UINT16 j=0U; + static UINT32 rowDataLen = 0; + UINT16 wStruDataLen = 0; + UINT16 wDataIndexLen = 0; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru=NULL; + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru=NULL; + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru=NULL; + + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru=g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru=g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru=g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U;; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wPhySecNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize/rowCount; + + /*鳤ȼ*/ + initFlag = PhySecNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->PHYSECNUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if ( 0x01==g_IsIdmapAllocMemory ) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuPhySecNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->PHYSECNUMINDEXSIZE + 2); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuPhySecNumIndex) + { + rtnValue = 0U;; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuPhySecNumIndex, 0xFF, dsuIdmapIndexStru->PHYSECNUMINDEXSIZE * 2 + 2); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pPhySecNumStru = (DSU_PHYSEC_NUM_STRU *)MyNew(sizeof(DSU_PHYSEC_NUM_STRU) * dsuIdmapLenStru->wPhySecNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pPhySecNumStru) + { + rtnValue = 0U;; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pPhySecNumStru, 0xFF, sizeof(DSU_PHYSEC_NUM_STRU) * dsuIdmapLenStru->wPhySecNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataStruArrayLen(IDMAP_PHYSEC_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wPhySecNumLen >= wStruDataLen)) + ||(0U == wStruDataLen)||(0U==checkFlag)) + { + rtnValue=0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag=dquGetIdmapDataIndexArrayLen(IDMAP_PHYSEC_ID, &wDataIndexLen); + if (((0U !=wDataIndexLen) && (dsuIdmapIndexStru->PHYSECNUMINDEXSIZE >= wDataIndexLen))||(0U== wDataIndexLen) || (0U == checkFlag)) + { + rtnValue=0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + for (j = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; j < dsuIdmapLenStru->wPhySecNumLen; j++) + { + pCurrentStru = dsuStaticIdmapStru->pPhySecNumStru + j; + + pData = pDataAddr + rowDataLen*j; + /*ݽṹ*/ + initFlag = PhySecNumStru_init(pData, pCurrentStru); + if (0U == initFlag) + { + /*initָ*/ + rtnValue = 0U;; + } + else + { + /*ɶӦ*/ + dsuIdmapIndexStru->dsuPhySecNumIndex[pCurrentStru->wIndexId] = j; + initFlag = IdmapInitLoopStepLenCtrl(j); + } + /*ѭֲи*/ + if ((0U == rtnValue) || (DQU_QFUN_TRUE==initFlag)) + { + break; + } + } + + if ((0U != rtnValue) && (j==dsuIdmapLenStru->wPhySecNumLen)) + { + rtnValue=1; + } + } + + return rtnValue; +} + + +/*-----------------------------------------------ṹ------------------------------------------------*/ + +/************************************** +ܣZCűṹʼ +˵[in] pDataAdd ݵַļ + [out] pZCNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 ZCNumStru_init(UINT8 * pDataAdd,DSU_ZC_NUM_STRU* pZCNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pZCNumStru)) + { + UINT8 * pData = pDataAdd; + + pZCNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pZCNumStru->dwZCDevId = LongFromChar(pData); /*ZC豸*/ + + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣCIűṹʼ +˵[in] pDataAdd ݵַļ + [out] pCINumStru ʼĽṹָ +ֵ0=ʧ 1=ɹ +עṹѾ +***************************/ +UINT8 CINumStru_init(UINT8 * pDataAdd,DSU_CI_NUM_STRU* pCINumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pCINumStru)) + { + UINT8 * pData = pDataAdd; + /**/ + pCINumStru->wIndexId = ShortFromChar(pData); + pData += 2; + + /*CI豸*/ + pCINumStru->dwCIDevId = LongFromChar(pData); + rtnValue = 1U; + } + return rtnValue; + +} + + +/************************************** +ܣATSűṹʼ +˵[in] pDataAdd ݵַļ + [out] pATSNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 ATSNumStru_init(UINT8 * pDataAdd,DSU_ATS_NUM_STRU* pATSNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pATSNumStru)) + { + UINT8 * pData = pDataAdd; + + pATSNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pATSNumStru->dwATSDevId = LongFromChar(pData); /*ATS豸*/ + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣźŻűṹʼ +˵[in] pDataAdd ݵַļ + [out] pSignalNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +******************************************/ +UINT8 SignalNumStru_init(UINT8 * pDataAdd,DSU_SIGNAL_NUM_STRU* pSignalNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pSignalNumStru)) + { + UINT8 * pData = pDataAdd; + + pSignalNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pSignalNumStru->dwSigDevId = LongFromChar(pData); /*źŻ豸*/ + + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣαṹʼ +˵[in] pDataAdd ݵַļ + [out] pAxleSecNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 TrackSecNumStru_init(UINT8 * pDataAdd, DSU_TRACKSEC_NUM_STRU* pAxleSecNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pAxleSecNumStru)) + { + UINT8 * pData = pDataAdd; + UINT8 index = 0; + +#if 0 + pAxleSecNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pAxleSecNumStru->dwTrackDevId = LongFromChar(pData); /*豸*/ + pData += 4; + + pAxleSecNumStru->wIncLinkCount = ShortFromChar(pData); / *link* / + pData += 2; + + / *link1~5 * / + for (index = 0; index<5; index++) + { + pAxleSecNumStru->wIncLinkId[index] = ShortFromChar(pData); + pData += 2; + } + +#endif + + pAxleSecNumStru->wLinkId = ShortFromChar(pData); /*LINK*/ + pData += 2; + + pAxleSecNumStru->wTrackNum = ShortFromChar(pData); /**/ + pData += 2; + + for (index = 0; index<15; index++) + { + pAxleSecNumStru->dwTrackSecId[index] = LongFromChar(pData); /*α*/ + pData += 4; + + pAxleSecNumStru->dwTrackSecLen[index] = LongFromChar(pData); /*γ*/ + pData += 4; + } + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣűṹʼ +˵[in] pDataAdd ݵַļ + [out] pSwitchNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 SwitchNumStru_init(UINT8 * pDataAdd,DSU_SWITCH_NUM_STRU* pSwitchNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pSwitchNumStru)) + { + UINT8 * pData = pDataAdd; + + pSwitchNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pSwitchNumStru->dwSwiDevId = LongFromChar(pData); /*豸*/ + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣվ̨űṹʼ +˵[in] pDataAdd ݵַļ + [out] pStationNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 StationNumStru_init(UINT8 * pDataAdd,DSU_STATION_NUM_STRU* pStationNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pStationNumStru)) + { + UINT8 * pData = pDataAdd; + + pStationNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pStationNumStru->dwStationId = LongFromChar(pData); /*վ̨*/ + + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣرհťűṹʼ +˵[in] pDataAdd ݵַļ + [out] pEmergBtnNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 EmergBtnNumStru_init(UINT8 * pDataAdd,DSU_EMERGBTN_NUM_STRU* pEmergBtnNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pEmergBtnNumStru)) + { + UINT8 * pData = pDataAdd; + + pEmergBtnNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pEmergBtnNumStru->dwEmergBtnId = LongFromChar(pData); /*رհť*/ + + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣӦűṹʼ +˵[in] pDataAdd ݵַļ + [out] pBaliseNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 BaliseNumStru_init(UINT8 * pDataAdd,DSU_BALISE_NUM_STRU* pBaliseNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pBaliseNumStru)) + { + UINT8 * pData = pDataAdd; + + pBaliseNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pBaliseNumStru->wBaliseId = ShortFromChar(pData); /*Ӧ*/ + pData += 2; + + pBaliseNumStru->wLindId = ShortFromChar(pData); /*·*/ + pData += 2; + + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣűűṹʼ +˵[in] pDataAdd ݵַļ + [out] pPSDoorNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 PSDoorNumStru_init(UINT8 * pDataAdd,DSU_PSD_NUM_STRU* pPSDoorNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPSDoorNumStru)) + { + UINT8 * pData = pDataAdd; + + pPSDoorNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pPSDoorNumStru->dwPSDoorId = LongFromChar(pData); /*ű*/ + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣ VOBCűṹʼ +˵[in] pDataAdd ݵַļ + [out] pVOBCNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 VOBCNumStru_init(UINT8 * pDataAdd,DSU_VOBC_NUM_STRU* pVOBCNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pVOBCNumStru)) + { + UINT8 * pData = pDataAdd; + + pVOBCNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pVOBCNumStru->dwVobcId[0] = LongFromChar(pData); /*VOBC1*/ + pData += 4; + + pVOBCNumStru->dwVobcId[1] = LongFromChar(pData); /*VOBC2*/ + pData += 4; + + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣűűṹʼ +˵[in] pDataAdd ݵַļ + [out] pFPDoorNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 FPDoorNumStru_init(UINT8 * pDataAdd,DSU_FPD_NUM_STRU* pFPDoorNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pFPDoorNumStru)) + { + UINT8 * pData = pDataAdd; + + pFPDoorNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pFPDoorNumStru->dwFPDoorId = LongFromChar(pData); /*ű*/ + + rtnValue = 1U; + } + return rtnValue; +} + +/************************************** +ܣDSUűṹʼ +˵[in] pDataAdd ݵַļ +[out] pDSUNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 DsuNumStru_init(UINT8 * pDataAdd, DSU_DSU_NUM_STRU* pDSUNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pDSUNumStru)) + { + UINT8 * pData = pDataAdd; + + pDSUNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pDSUNumStru->dwDsuId = LongFromChar(pData); /*DSU*/ + + rtnValue = 1U; + } + return rtnValue; +} + + +/************************************** +ܣ߼αűṹʼ +˵[in] pDataAdd ݵַļ + [out] pLogicSecNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 LogicSecNumStru_init(UINT8 * pDataAdd,DSU_LOGICSEC_NUM_STRU* pLogicSecNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pLogicSecNumStru)) + { + UINT8 * pData = pDataAdd; + + pLogicSecNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pLogicSecNumStru->dwLogicSecId = LongFromChar(pData); /*߼α */ + + rtnValue = 1U; + } + return rtnValue; +} + +/************************************** +ܣAOMűṹʼ +˵[in] pDataAdd ݵַļ + [out] pAomSecNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 AomSecNumStru_init(UINT8 * pDataAdd,DSU_AOMSEC_NUM_STRU* pAomSecNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pAomSecNumStru)) + { + UINT8 * pData = pDataAdd; + + pAomSecNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pAomSecNumStru->dwAomSecId[0] = LongFromChar(pData); /*AOM1 */ + pData += 4; + + pAomSecNumStru->dwAomSecId[1] = LongFromChar(pData); /*AOM2 */ + pData += 4; + + rtnValue = 1U; + } + return rtnValue; +} + +/************************************** +ܣSPKSűṹʼ +˵[in] pDataAdd ݵַļ + [out] pSpksSecNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 SpksSecNumStru_init(UINT8 * pDataAdd,DSU_SPKSSEC_NUM_STRU* pSpksSecNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pSpksSecNumStru)) + { + UINT8 * pData = pDataAdd; + + pSpksSecNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pSpksSecNumStru->dwSpksSecId = LongFromChar(pData); /*SPKS */ + rtnValue = 1U; + } + return rtnValue; +} + +/************************************** +ܣűűṹʼ +˵[in] pDataAdd ݵַļ + [out] pGodSecNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 GodSecNumStru_init(UINT8 * pDataAdd,DSU_GODSEC_NUM_STRU* pGodSecNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pGodSecNumStru)) + { + UINT8 * pData = pDataAdd; + + pGodSecNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pGodSecNumStru->dwGodSecId = LongFromChar(pData); /*ű */ + rtnValue = 1U; + } + return rtnValue; +} + +/************************************** +ܣվűṹʼ by slm 2019-1-15 +˵[in] pDataAdd ݵַļ +[out] pStaSecNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 StaSecNumStru_init(UINT8 * pDataAdd, DSU_STASEC_NUM_STRU* pStaSecNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pStaSecNumStru)) + { + UINT8 * pData = pDataAdd; + + pStaSecNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pStaSecNumStru->dwStaSecId = LongFromChar(pData); /*վ */ + rtnValue = 1U; + } + return rtnValue; +} + +/************************************** +ܣαűṹʼ by slm 2019-1-16 +˵[in] pDataAdd ݵַļ +[out] pStaSecNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 PhySecNumStru_init(UINT8 * pDataAdd, DSU_PHYSEC_NUM_STRU* pPhySecNumStru) +{ + UINT8 rtnValue = 0U;; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pPhySecNumStru)) + { + UINT8 * pData = pDataAdd; + + pPhySecNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2; + + pPhySecNumStru->dwPhySecId = LongFromChar(pData); /*α */ + rtnValue = 1U; + } + return rtnValue; +} + +/************************************************ +ܣȡ + +errRecord飬errRecordLen鳤 +ֵ0=ʧܣ1=ɹ +************************************************/ +UINT8 dquGetIdMapErrNo(UINT8* errRecord, UINT32 * errRecordLen) +{ + UINT32 Ofst = 0; + UINT32 i = 0; + UINT8 rtnValue = 0U;; + if((NULL != errRecord) && (NULL != errRecordLen)) + { + ShortToChar(fileErrNo, &errRecord[Ofst]); + Ofst += 2; + + ShortToChar(dataTypeErrNo, &errRecord[Ofst]); + Ofst += 2; + + for (i = 0; i < INIT_IDMAP_ERR_NUM; i++) + { + errRecord[Ofst] = initIdMapErrNo[i]; + Ofst++; + } + + *errRecordLen = Ofst; + rtnValue = 1U; + } + return rtnValue; +} + +/********************************************** +ܣʼ[ϵͳ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAxleNum(UINT8* pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_AXLE_NUM_STRU stru = { 0U }; /*ṹʱָ*/ + static UINT32 rowDataLen = 0U; + UINT16 wStruDataLen = 0U; + UINT16 wDataIndexLen = 0U; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU* dsuIdmapIndexStru = NULL; + DSU_STATIC_IDMAP_STRU* dsuStaticIdmapStru = NULL; + DSU_IDMAP_LEN_STRU* dsuIdmapLenStru = NULL; + + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru = g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru = g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru = g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U; + } + + initFlag = IdmapInitFunStepCtrl(0x01); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wAxleNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize / rowCount; + + /*鳤ȼ*/ + initFlag = AxleNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ΪID + 1*/ + dsuIdmapIndexStru->AXLENUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U;/*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if (0x01U == g_IsIdmapAllocMemory) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuAxleNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->AXLENUMINDEXSIZE + 2U); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuAxleNumIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + memset(dsuIdmapIndexStru->dsuAxleNumIndex, 0xFFU, dsuIdmapIndexStru->AXLENUMINDEXSIZE * 2U + 2U); + } + + if (2U == rtnValue) + { + /*̬ռ*/ + dsuStaticIdmapStru->pAxleNumStru = (DSU_AXLE_NUM_STRU*)MyNew(sizeof(DSU_AXLE_NUM_STRU) * dsuIdmapLenStru->wAxleNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pAxleNumStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + memset(dsuStaticIdmapStru->pAxleNumStru, 0xFFU, sizeof(DSU_AXLE_NUM_STRU) * dsuIdmapLenStru->wAxleNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetIdmapDataStruArrayLen(IDMAP_AXLE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wAxleNumLen >= wStruDataLen)) + || (0U == wStruDataLen) || (0U == checkFlag)) + { + rtnValue = 0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetIdmapDataIndexArrayLen(IDMAP_AXLE_ID, &wDataIndexLen); + if (((0U != wDataIndexLen) && (dsuIdmapIndexStru->AXLENUMINDEXSIZE >= wDataIndexLen)) + || (0U == wDataIndexLen) || (0U == checkFlag)) + { + rtnValue = 0U; + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + rtnValue = ReadDataToAxleNumStru(pDataAddr, rowDataLen, dsuIdmapLenStru->wAxleNumLen, dsuStaticIdmapStru->pAxleNumStru, dsuIdmapIndexStru->dsuAxleNumIndex); + } + + return rtnValue; +} + +/************************************** +ܣϵͳűṹʼ +˵[in] pDataAdd ݵַļ + [out] pAxleNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 AxleNumStru_init(UINT8* pDataAdd, DSU_AXLE_NUM_STRU* pAxleNumStru) +{ + UINT8 rtnValue = 0U; + /*ָ*/ + if ((NULL != pDataAdd) && (NULL != pAxleNumStru)) + { + UINT8* pData = pDataAdd; + + pAxleNumStru->wIndexId = ShortFromChar(pData); /**/ + pData += 2U; + + pAxleNumStru->dwAxleId = LongFromChar(pData); /*ϵͳ1*/ + pData += 4U; + + pData += 4U; /*TMCõļϵͳ2ͨID*/ + + rtnValue = 1U; + } + + return rtnValue; +} + +/************************************** +ܣȡϵͳűݵṹ +˵UINT8* pDataAddr ݵַ + UINT32 rowDataLen һеݳ + UINT16 wAxleNumLen ϵͳ + DSU_AXLE_NUM_STRU* pAxleNumStru ϵͳͨIDṹ + UINT16* pDsuAxleNumIndex ϵͳ +ֵ0ʧܣ1ɹ +***************************/ +UINT8 ReadDataToAxleNumStru(UINT8* pDataAddr, UINT32 dwRowDataLen,UINT16 wAxleNumLen, DSU_AXLE_NUM_STRU* pAxleNumStru, UINT16* pDsuAxleNumIndex) +{ + UINT8 retVal = 0U; + UINT16 i = 0U; + UINT8* pData = NULL; + UINT8 initFlag = 0U; + DSU_AXLE_NUM_STRU* pCurrentStru = NULL; + + if ((NULL != pDataAddr) && (0U != dwRowDataLen) && (0U != wAxleNumLen) && (NULL != pAxleNumStru) && (NULL != pDsuAxleNumIndex)) + { + for (i = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; i < wAxleNumLen; i++) + { + pCurrentStru = pAxleNumStru + i; + pData = pDataAddr + dwRowDataLen * i; + + retVal = AxleNumStru_init(pData, pCurrentStru); /*ݽṹ*/ + if (1U == retVal) + { + /*ɶӦ*/ + pDsuAxleNumIndex[pCurrentStru->wIndexId] = i; + initFlag = IdmapInitLoopStepLenCtrl(i); + } + else + { + retVal = 0U; + } + + if ((0U == retVal) || (DQU_QFUN_TRUE == initFlag)) + { + break; + } + else + { + /**/ + } + } + + if ((1U == retVal) && (i == wAxleNumLen)) + { + retVal = 1U; /*ɹ1*/ + } + else + { + retVal = 0U; /*ʧܣ0*/ + } + } + else + { + /*ηǷ0*/ + } + + return retVal; +} + +/********************************************** +* ܣʼ[ITE]: +* UINT8* pDataAddr ׵ַ +* UINT32 dataSize ֽڳ +* UINT16 rowCount +* +* ֵ0 ʧ +* 1 ɹ +* 2 +**********************************************/ +UINT8 initIteNum(UINT8* pDataAddr, UINT32 dataSize, UINT16 rowCount) +{ + UINT8 rtnValue = 2U; + UINT8* pData = NULL; + UINT8 initFlag = 0U; + UINT8 checkFlag = 0U; + DSU_ITE_NUM_STRU* pCurrentStru = NULL; /*ṹʱָ*/ + DSU_ITE_NUM_STRU stru = { 0U }; /*ṹʱָ*/ + UINT16 j = 0U; + static UINT32 rowDataLen = 0U; + UINT16 wStruDataLen = 0U; + UINT16 wDataIndexLen = 0U; + + /*Ŷձ*/ + DSU_IDMAP_INDEX_STRU* dsuIdmapIndexStru = NULL; + DSU_STATIC_IDMAP_STRU* dsuStaticIdmapStru = NULL; + DSU_IDMAP_LEN_STRU* dsuIdmapLenStru = NULL; + + if ((NULL != g_dsuIdmapStru) && (NULL != pDataAddr)) + { + dsuIdmapIndexStru = g_dsuIdmapStru->dsuIdmapIndexStru; + dsuStaticIdmapStru = g_dsuIdmapStru->dsuStaticIdmapStru; + dsuIdmapLenStru = g_dsuIdmapStru->dsuIdmapLenStru; + } + else + { + /*ָΪ*/ + rtnValue = 0U; + } + + initFlag = IdmapInitFunStepCtrl(0x01U); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + dsuIdmapLenStru->wIteNumLen = rowCount; + + if (0U == rowCount) + { + rtnValue = 1U; + } + else + { + rowDataLen = dataSize / rowCount; + + /*鳤ȼ*/ + initFlag = IteNumStru_init(pDataAddr + dataSize - rowDataLen, &stru); + if (0U != initFlag) + { + /*ȷֵ*/ + dsuIdmapIndexStru->ITENUMINDEXSIZE = stru.wIndexId; + } + else + { + rtnValue = 0U; /*initָ*/ + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x02U); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + if (0x01U == g_IsIdmapAllocMemory) + { + /*̬ռ*/ + dsuIdmapIndexStru->dsuIteNumIndex = (UINT16*)MyNew(sizeof(UINT16) * dsuIdmapIndexStru->ITENUMINDEXSIZE + 2U); + + /*̬ռʧ*/ + if (NULL == dsuIdmapIndexStru->dsuIteNumIndex) + { + rtnValue = 0U; + } + else + { + /*ʼΪ0xFF*/ + (void)CommonMemSet(dsuIdmapIndexStru->dsuIteNumIndex, dsuIdmapIndexStru->ITENUMINDEXSIZE * 2U + 2U, 0xFFU, dsuIdmapIndexStru->ITENUMINDEXSIZE * 2U + 2U); + + /*̬ռ*/ + dsuStaticIdmapStru->pIteNumStru = (DSU_ITE_NUM_STRU*)MyNew(sizeof(DSU_ITE_NUM_STRU) * dsuIdmapLenStru->wIteNumLen); + + /*̬ռʧ*/ + if (NULL == dsuStaticIdmapStru->pIteNumStru) + { + rtnValue = 0U; + } + else + { + /*ڴΪЧ*/ + (void)CommonMemSet(dsuStaticIdmapStru->pIteNumStru, sizeof(DSU_ITE_NUM_STRU) * dsuIdmapLenStru->wIteNumLen, 0xFFU, sizeof(DSU_ITE_NUM_STRU) * dsuIdmapLenStru->wIteNumLen); + } + } + } + else/*ڴռⲿƷ*/ + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetIdmapDataStruArrayLen(IDMAP_ITE_ID, &wStruDataLen); + + if (((0U != wStruDataLen) && (dsuIdmapLenStru->wIteNumLen >= wStruDataLen)) + || (0U == wStruDataLen) || (0U == checkFlag)) + { + rtnValue = 0U; + } + else + { + /*ӦĸǷ񳬳ڴ䷶Χ*/ + checkFlag = dquGetIdmapDataIndexArrayLen(IDMAP_ITE_ID, &wDataIndexLen); + if (((0U != wDataIndexLen) && (dsuIdmapIndexStru->ITENUMINDEXSIZE >= wDataIndexLen)) + || (0U == wDataIndexLen) || (0U == checkFlag)) + { + rtnValue = 0U; + } + else + { + /**/ + } + } + } + } + + initFlag = IdmapInitFunStepCtrl(0x03U); + if ((2U == rtnValue) && (DQU_QFUN_TRUE == initFlag)) + { + /*ݵṹ */ + rtnValue = ReadDataToIteNumStru(pDataAddr, rowDataLen, dsuIdmapLenStru->wIteNumLen, dsuStaticIdmapStru->pIteNumStru, dsuIdmapIndexStru->dsuIteNumIndex); + } + + return rtnValue; +} + +/************************************** +* ܣITEűṹʼ +* ˵UINT8* pDataAdd ݵַļ +* DSU_ITE_NUM_STRU* pIteNumStru ʼĽṹָ루Σ +* ֵ0 ʧ +* 1 ɹ +**************************************/ +UINT8 IteNumStru_init(UINT8* pDataAdd, DSU_ITE_NUM_STRU* pIteNumStru) +{ + UINT8 cRtnVal = 0U;; + + if ((NULL != pDataAdd) && (NULL != pIteNumStru)) + { + UINT8* pData = pDataAdd; + + pIteNumStru->wIndexId = ShortFromChar(pData); /*ITE*/ + pData += 2U; + + pIteNumStru->dwIteId[0] = LongFromChar(pData); /*ITE1*/ + pData += 4U; + + pIteNumStru->dwIteId[1] = LongFromChar(pData); /*ITE2*/ + pData += 4U; + + cRtnVal = 1U; + } + else + { + /*ηǷ0ʧ*/ + } + + return cRtnVal; +} + +/************************************** +* ܣȡITEűݵṹ +* ˵UINT8* pDataAddr ݵַ +* UINT32 rowDataLen һеݳ +* UINT16 wIteNumLen ITE +* DSU_ITE_NUM_STRU* pIteNumStru ITEͨIDṹ +* UINT16* pDsuIteNumIndex ITE +* ֵ0 ʧ +* 1 ɹ +**************************************/ +UINT8 ReadDataToIteNumStru(UINT8* pDataAddr, UINT32 dwRowDataLen, UINT16 wIteNumLen, DSU_ITE_NUM_STRU* pIteNumStru, UINT16* pDsuIteNumIndex) +{ + UINT8 retVal = 0U; + UINT16 i = 0U; + UINT8* pData = NULL; + UINT8 initFlag = 0U; + DSU_ITE_NUM_STRU* pCurrentStru = NULL; + + if ((NULL != pDataAddr) && (0U != dwRowDataLen) && (0U != wIteNumLen) && (NULL != pIteNumStru) && (NULL != pDsuIteNumIndex)) + { + for (i = g_struInitTaskTab[g_wCurInitStruProg].wCurInitPos; i < wIteNumLen; i++) + { + pCurrentStru = pIteNumStru + i; + pData = pDataAddr + dwRowDataLen * i; + + retVal = IteNumStru_init(pData, pCurrentStru); /*ݽṹ*/ + if (1U == retVal) + { + /*ɶӦ*/ + pDsuIteNumIndex[pCurrentStru->wIndexId] = i; + initFlag = IdmapInitLoopStepLenCtrl(i); + } + else + { + retVal = 0U; + } + + if ((0U == retVal) || (DQU_QFUN_TRUE == initFlag)) + { + break; + } + else + { + /**/ + } + } + + if ((1U == retVal) && (i == wIteNumLen)) + { + retVal = 1U; /*ɹ1*/ + } + else + { + retVal = 0U; /*ʧܣ0*/ + } + } + else + { + /*ηǷ0*/ + } + + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapInit.h b/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapInit.h new file mode 100644 index 0000000..5c95b61 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapInit.h @@ -0,0 +1,379 @@ +/************************************************************************ +* +* ļ dquIdmapInit.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ +* +* Ŷձʼ +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#ifndef DQU_IDMAP_INIT_H +#define DQU_IDMAP_INIT_H + + +#include "Convert.h" +#include "dfsDataRead.h" +#include "dsuIdmapVar.h" +#include "dsuIdmapStruct.h" +#include "dquIdmapQuery.h" +#include "dquDataTypeDefine.h" +#include "CommonMemory.h" + +#define INIT_IDMAP_ERR_NUM 20/*޸by slm 2019.1.16*/ + +extern UINT8 initIdMapErrNo[INIT_IDMAP_ERR_NUM]; /*ݳʼʧܹϺ*/ +#define DEBUG_GET_DATA_FAIL 0x01 /*ȡʧ*/ +#define DEBUG_DATA_LENTH_FAIL 0x02 /*ݳ*/ +#define DEBUG_CALC_FAIL 0x04 /*̴*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*ʼŶձ*/ +UINT8 dfsIdmapInit (CHAR * FSName); + +/**************************************** +*ܣʼŶձչӿ +*˵ pDataBuf,ݿ飬 +* dsuIdmapStru,ⲿʵӵͼ洢ṹָ +* mode,ģʽ1ϵһμأ2ʱδ +* timeSliceִеʱƬλ룩 +*ֵ 0ʧܣ1ɹ2ֲδ +*****************************************/ +UINT8 dfsIdmapInitExp(UINT8 * pDataBuf,DSU_IDMAP_STRU *dsuIdmapStru,UINT8 mode,UINT16 timeSlice); + + +/*ŶձʼϣִбŶձڲ*/ +UINT8 dfsIdmapInitFinally(); + + +/********************************************** +ܣʼ[ZC]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initZCNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[CI]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initCINum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[ATS]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initATSNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[źŻ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSignalNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initTrackSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSwitchNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[߼վ̨]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStationNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[رհť]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initEmergBtnNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[Ӧ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initBaliseNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPSDoorNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[VOBC]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initVobcNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initFPDoorNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[DSU]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initDsuNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[߼]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initLogicSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[AOM]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAomSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[SPKS]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initSpksSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initGodSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[վ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initStaSecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/********************************************** +ܣʼ[]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initPhySecNum(UINT8 *pDataAddr, UINT32 dataSize, UINT16 rowCount); + + +/*ZCݽṹʼ*/ +UINT8 ZCNumStru_init(UINT8 * pDataAdd,DSU_ZC_NUM_STRU* pZCNumStru); + +/*CIݽṹʼ*/ +UINT8 CINumStru_init(UINT8 * pDataAdd,DSU_CI_NUM_STRU* pCINumStru); + +/*ATSݽṹʼ*/ +UINT8 ATSNumStru_init(UINT8 * pDataAdd,DSU_ATS_NUM_STRU* pATSNumStru); + +/*źŻݽṹʼ*/ +UINT8 SignalNumStru_init(UINT8 * pDataAdd,DSU_SIGNAL_NUM_STRU* pSignalNumStru); + +/*ݽṹʼ*/ +UINT8 TrackSecNumStru_init(UINT8 * pDataAdd,DSU_TRACKSEC_NUM_STRU* pAxleSecNumStru); + +/*ݽṹʼ*/ +UINT8 SwitchNumStru_init(UINT8 * pDataAdd,DSU_SWITCH_NUM_STRU* pSwitchNumStru); + +/*վ̨ݽṹʼ*/ +UINT8 StationNumStru_init(UINT8 * pDataAdd,DSU_STATION_NUM_STRU* pStationNumStru); + +/*رհťݽṹʼ*/ +UINT8 EmergBtnNumStru_init(UINT8 * pDataAdd,DSU_EMERGBTN_NUM_STRU* pEmergBtnNumStru); + +/*Ӧݽṹʼ*/ +UINT8 BaliseNumStru_init(UINT8 * pDataAdd,DSU_BALISE_NUM_STRU* pBaliseNumStru); + +/*űݽṹʼ*/ +UINT8 PSDoorNumStru_init(UINT8 * pDataAdd,DSU_PSD_NUM_STRU* pPSDoorNumStru); + +/*VOBCݽṹʼ*/ +UINT8 VOBCNumStru_init(UINT8 * pDataAdd,DSU_VOBC_NUM_STRU* pVOBCNumStru); + +/*űݽṹʼ*/ +UINT8 FPDoorNumStru_init(UINT8 * pDataAdd,DSU_FPD_NUM_STRU* pFPDoorNumStru); + +/*DSUűṹʼ*/ +UINT8 DsuNumStru_init(UINT8 * pDataAdd, DSU_DSU_NUM_STRU* pDSUNumStru); + +/*߼αűṹʼ*/ +UINT8 LogicSecNumStru_init(UINT8 * pDataAdd,DSU_LOGICSEC_NUM_STRU* pLogicSecNumStru); + +/*AOMűṹʼ*/ +UINT8 AomSecNumStru_init(UINT8 * pDataAdd,DSU_AOMSEC_NUM_STRU* pAomSecNumStru); + +/*SPKSűṹʼ*/ +UINT8 SpksSecNumStru_init(UINT8 * pDataAdd,DSU_SPKSSEC_NUM_STRU* pSpksSecNumStru); + +/*űűṹʼ*/ +UINT8 GodSecNumStru_init(UINT8 * pDataAdd,DSU_GODSEC_NUM_STRU* pGodSecNumStru); + +/*վűṹʼ add by slm 2019-1-15*/ +UINT8 StaSecNumStru_init(UINT8 * pDataAdd, DSU_STASEC_NUM_STRU* pStaSecNumStru); + +/*αűṹʼ add by slm 2019-1-16*/ +UINT8 PhySecNumStru_init(UINT8 * pDataAdd, DSU_PHYSEC_NUM_STRU* pPhySecNumStru); + +/*** +ܣȡ + +errRecord飬errRecordLen鳤 +ֵ1ɹ +***/ +UINT8 dquGetIdMapErrNo(UINT8* errRecord,UINT32 * errRecordLen); + +/********************************************** +ܣʼ[ϵͳ]: +pDataAddr:׵ַ + dataSize:ֽڳ + rowCount: + +ֵ:2,1ɹ,0ʧ +**********************************************/ +UINT8 initAxleNum(UINT8* pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/************************************** +ܣϵͳűṹʼ +˵[in] pDataAdd ݵַļ + [out] pAxleNumStru ʼĽṹָ +ֵ0=ʧܣ1=ɹ +עṹѾ +***************************/ +UINT8 AxleNumStru_init(UINT8* pDataAdd, DSU_AXLE_NUM_STRU* pAxleNumStru); + +/************************************** +ܣȡϵͳűݵṹ +˵UINT8* pDataAddr ݵַ + UINT32 rowDataLen һеݳ + UINT16 wAxleNumLen ϵͳ + DSU_AXLE_NUM_STRU* pAxleNumStru ϵͳͨIDṹ + UINT16* pDsuAxleNumIndex ϵͳ +ֵ0ʧܣ1ɹ +***************************/ +UINT8 ReadDataToAxleNumStru(UINT8* pDataAddr, UINT32 dwRowDataLen, UINT16 wAxleNumLen, DSU_AXLE_NUM_STRU* pAxleNumStru, UINT16* pDsuAxleNumIndex); + +/********************************************** +* ܣʼ[ITE]: +* UINT8* pDataAddr ׵ַ +* UINT32 dataSize ֽڳ +* UINT16 rowCount +* +* ֵ0 ʧ +* 1 ɹ +* 2 +**********************************************/ +UINT8 initIteNum(UINT8* pDataAddr, UINT32 dataSize, UINT16 rowCount); + +/************************************** +* ܣITEűṹʼ +* ˵UINT8* pDataAdd ݵַļ +* DSU_ITE_NUM_STRU* pIteNumStru ʼĽṹָ루Σ +* ֵ0 ʧ +* 1 ɹ +**************************************/ +UINT8 IteNumStru_init(UINT8* pDataAdd, DSU_ITE_NUM_STRU* pIteNumStru); + +/************************************** +* ܣȡITEűݵṹ +* ˵UINT8* pDataAddr ݵַ +* UINT32 rowDataLen һеݳ +* UINT16 wIteNumLen ITE +* DSU_ITE_NUM_STRU* pIteNumStru ITEͨIDṹ +* UINT16* pDsuIteNumIndex ITE +* ֵ0 ʧ +* 1 ɹ +**************************************/ +UINT8 ReadDataToIteNumStru(UINT8* pDataAddr, UINT32 dwRowDataLen, UINT16 wIteNumLen, DSU_ITE_NUM_STRU* pIteNumStru, UINT16* pDsuIteNumIndex); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapQuery.c b/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapQuery.c new file mode 100644 index 0000000..dc80c43 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapQuery.c @@ -0,0 +1,1804 @@ +/************************************************************************ +* ļ dsuIdmapQuery.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2016.04.12 +* +* dsuѯļ +* ʹע +* ޸ļ¼ +************************************************************************/ +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "dquIdmapQuery.h" +#include "dsuIdmapVar.h" +#include "dquQuery.h" +#include "math.h" + +#define QFUN_IDMAP_TRACKSEC_ID 5 +#define QFUN_IDMAP_VOBC_ID 11 +#define QFUN_IDMAP_AOM_ID 15 /*AOMID*/ + +#define DQU_IDMAP_INIT_TRUE 0x55 +#define DQU_IDMAP_INIT_FALSE 0xAA + +static UINT8 qds_IsInitIdMapStruPtr=DQU_IDMAP_INIT_FALSE; +static DSU_IDMAP_LEN_STRU *qds_dsuIdmapLenStru=NULL; /*ȫֱ¼ȡDSUеĸݵ*/ +static DSU_STATIC_IDMAP_STRU *qds_dsuStaticIdmapStru=NULL; /*ݿÿֽṹͷָ*/ +static DSU_IDMAP_INDEX_STRU *qds_dsuIdmapIndexStru=NULL; /*豸ṹ*/ + + +typedef UINT16 (*DQU_GETFUN_LIST_VDrW[])(void); +typedef UINT32 (*DQU_GETFUN_LIST_WrWD[])(UINT16); +typedef UINT16 (*DQU_GETFUN_LIST_WrW[])(UINT16); +typedef UINT16 (*DQU_GETFUN_LIST_IxWtW[])(DSU_IDMAP_INDEX_STRU*,UINT16); + +UINT16 dquGetAomSecNumLen(void); +UINT16 dquGetSpksSecNumLen(void); +UINT16 dquGetGodSecNumLen(void); +UINT16 dquGetStaSecNumLen(void);/*add by slm 2019.1.17*/ +UINT16 dquGetPhySecNumLen(void);/*add by slm 2019.1.17*/ + +UINT32 dquGetSpksSecDevId(UINT16 dataPos); +UINT32 dquGetGodSecDevId(UINT16 dataPos); +UINT32 dquGetStaSecDevId(UINT16 dataPos); +UINT32 dquGetPhySecDevId(UINT16 dataPos); +UINT16 dquGetAomSecIndex(UINT16 dataPos); +UINT16 dquGetSpksSecIndex(UINT16 dataPos); +UINT16 dquGetGodSecIndex(UINT16 dataPos); +UINT16 dquGetStaSecIndex(UINT16 dataPos);/*add by slm 2019.1.17*/ +UINT16 dquGetPhySecIndex(UINT16 dataPos);/*add by slm 2019.1.17*/ + +UINT16 dquGetAomSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex); +UINT16 dquGetSpksSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex); +UINT16 dquGetGodSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex); +UINT16 dquGetStaSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru, UINT16 devIndex);/*add by slm 2019.1.17*/ +UINT16 dquGetPhySecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru, UINT16 devIndex);/*add by slm 2019.1.17*/ + +static UINT16 dquBaliseLineId(UINT16 dataPos); + +/*-------------------------------ºڲݽṹӿں--------------------------------------*/ +/*ȡ豸ṹij*/ +UINT16 dquGetZCNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wZCNumLen); +} +UINT16 dquGetCINumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wCINumLen); +} +UINT16 dquGetATSNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wATSNumLen); +} +UINT16 dquGetSignalNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wSignalNumLen); +} +UINT16 dquGetTrackSecNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wTrackSecNumLen); +} +UINT16 dquGetSwitchNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wSwitchNumLen); +} +UINT16 dquGetStationNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wStationNumLen); +} +UINT16 dquGetEmergBtnNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wEmergBtnNumLen); +} +UINT16 dquGetBaliseNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wBaliseNumLen); +} +UINT16 dquGetPSDoorNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wPSDoorNumLen); +} +UINT16 dquGetVobcNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wVobcNumLen); +} +UINT16 dquGetFPDoorNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wFPDoorNumLen); +} +UINT16 dquGetDsuNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wDsuNumLen); +} +UINT16 dquGetLogicSecNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wLogicSecNumLen); +} + +/************************************************** +*ܣȡAOM豸ųϢ +* +* +* +* +*ֵAOM豸ųϢ +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT16 dquGetAomSecNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wAomSecNumLen); +} + +/************************************************** +*ܣȡSPKS豸ųϢ +* +* +* +* +*ֵSPKS豸ųϢ +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT16 dquGetSpksSecNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wSpksSecNumLen); +} + +/************************************************** +*ܣȡ豸ųϢ +* +* +* +* +*ֵ豸ųϢ +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT16 dquGetGodSecNumLen(void) +{ + return ((NULL==qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wGodSecNumLen); +} + +/************************************************** +*ܣȡվͨ豸ųϢ +* +* +* +* +*ֵվͨ豸ųϢ +* עڲʹú add by slm 2019-1-17 +***************************************************/ +UINT16 dquGetStaSecNumLen(void) +{ + return ((NULL == qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wStaSecNumLen); +} + +/************************************************** +*ܣȡλͨųϢ +* +* +* +* +*ֵλͨųϢ +* עڲʹú add by slm 2019-1-17 +***************************************************/ +UINT16 dquGetPhySecNumLen(void) +{ + return ((NULL == qds_dsuIdmapLenStru) ? 0 : qds_dsuIdmapLenStru->wPhySecNumLen); +} +/*עб*/ +const DQU_GETFUN_LIST_VDrW dquGetDataLen={NULL,dquGetZCNumLen,dquGetCINumLen,dquGetATSNumLen,dquGetSignalNumLen,dquGetTrackSecNumLen,dquGetSwitchNumLen, + dquGetStationNumLen,dquGetEmergBtnNumLen,dquGetBaliseNumLen,dquGetPSDoorNumLen,dquGetVobcNumLen,dquGetFPDoorNumLen,dquGetDsuNumLen,dquGetLogicSecNumLen, + dquGetAomSecNumLen,dquGetSpksSecNumLen,dquGetGodSecNumLen,dquGetStaSecNumLen,dquGetPhySecNumLen, NULL, dquGetAxleNumLen, dquGetIteNumLen }; +/*豸λãȡ豸*/ +UINT32 dquGetZCDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospZCNumStru[dataPos].dwZCDevId; + } + return dwRetVal; +} +UINT32 dquGetCIDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospCINumStru[dataPos].dwCIDevId; + } + return dwRetVal; +} +UINT32 dquGetATSDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospATSNumStru[dataPos].dwATSDevId; + } + return dwRetVal; +} +UINT32 dquGetSigDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospSignalNumStru[dataPos].dwSigDevId; + } + return dwRetVal; +} +UINT32 dquGetTrackDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospTrackSecNumStru[dataPos].dwTrackDevId;*/ + } + return dwRetVal; +} +UINT32 dquGetSwiDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospSwitchNumStru[dataPos].dwSwiDevId; + } + return dwRetVal; +} +UINT32 dquGetStationDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospStationNumStru[dataPos].dwStationId; + } + return dwRetVal; +} +UINT32 dquGetEmergBtnDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospEmergBtnNumStru[dataPos].dwEmergBtnId; + } + return dwRetVal; +} +UINT32 dquGetBaliseDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospBaliseNumStru[dataPos].wBaliseId; + } + return dwRetVal; +} +UINT32 dquGetPSDoorDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospPSDNumStru[dataPos].dwPSDoorId; + } + return dwRetVal; +} +UINT32 dquGetVobcDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospVobcNumStru[dataPos].dwVobcId;*/ + } + return dwRetVal; +} +UINT32 dquGetFPDoorDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospFPDoorNumStru[dataPos].dwFPDoorId; + } + return dwRetVal; +} +UINT32 dquGetDsuDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospDsuNumStru[dataPos].dwDsuId; + } + return dwRetVal; +} +UINT32 dquGetLogicSecDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospLogicSecNumStru[dataPos].dwLogicSecId; + } + return dwRetVal; +} + +/************************************************** +*ܣ豸λãȡSPKS +* +* dataPos豸ṹλ +* +* +*ֵSPKS豸 +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT32 dquGetSpksSecDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospSpksSecNumStru[dataPos].dwSpksSecId; + } + return dwRetVal; +} + +/************************************************** +*ܣ豸λãȡű +* +* dataPos豸ṹλ +* +* +*ֵ豸 +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT32 dquGetGodSecDevId(UINT16 dataPos) +{ + UINT32 dwRetVal=0U; + if(dataPospGodSecNumStru[dataPos].dwGodSecId; + } + return dwRetVal; +} + +/************************************************** +*ܣ豸λãȡվͨ豸 +* +* dataPos豸ṹλ +* +* +*ֵվͨ豸 +* עڲʹú add by slm 2019-1-17 +***************************************************/ +UINT32 dquGetStaSecDevId(UINT16 dataPos) +{ + UINT32 dwRetVal = 0; + if (dataPospStaSecNumStru[dataPos].dwStaSecId; + } + return dwRetVal; +} + +/************************************************** +*ܣ豸λãȡλͨ +* +* dataPos豸ṹλ +* +* +*ֵλͨ +* עڲʹú add by slm 2019-1-17 +***************************************************/ +UINT32 dquGetPhySecDevId(UINT16 dataPos) +{ + UINT32 dwRetVal = 0; + if (dataPospPhySecNumStru[dataPos].dwPhySecId; + } + return dwRetVal; +} + +/*עб*/ +const DQU_GETFUN_LIST_WrWD dquGetDevId={NULL,dquGetZCDevId,dquGetCIDevId,dquGetATSDevId,dquGetSigDevId,dquGetTrackDevId,dquGetSwiDevId,dquGetStationDevId, + dquGetEmergBtnDevId,dquGetBaliseDevId,dquGetPSDoorDevId,dquGetVobcDevId,dquGetFPDoorDevId,dquGetDsuDevId,dquGetLogicSecDevId,NULL, + dquGetSpksSecDevId,dquGetGodSecDevId,dquGetStaSecDevId,dquGetPhySecDevId, NULL, dquGetAxleDevId }; + +/*ݴĽṹλãȡ豸ֵ*/ +UINT16 dquGetZCIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospZCNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetCIIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospCINumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetATSIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospATSNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetSigIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospSignalNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetLinkIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospTrackSecNumStru[dataPos].wLinkId; + } + return wRetVal; +} +UINT16 dquGetSwiIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospSwitchNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetStationIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospStationNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetEmergBtnIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospEmergBtnNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetBaliseIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospBaliseNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetPSDoorIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospPSDNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetVobcIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospVobcNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetFPDoorIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospFPDoorNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetDsuIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospDsuNumStru[dataPos].wIndexId; + } + return wRetVal; +} +UINT16 dquGetLogicSecIndex(UINT16 dataPos) +{ + UINT16 wRetVal=0U; + if(dataPospLogicSecNumStru[dataPos].wIndexId; + } + return wRetVal; +} + +/************************************************** +*ܣ豸λãȡAOM +* +* dataPos豸ṹλ +* +* +*ֵAOM +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT16 dquGetAomSecIndex(UINT16 dataPos) +{ + UINT16 dwRetVal=0U; + if ((NULL!=qds_dsuStaticIdmapStru)&&(NULL!=qds_dsuStaticIdmapStru->pAomSecNumStru)) + { + if(dataPospAomSecNumStru[dataPos].wIndexId; + } + } + return dwRetVal; +} + +/************************************************** +*ܣ豸λãȡSPKS +* +* dataPos豸ṹλ +* +* +*ֵSPKS +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT16 dquGetSpksSecIndex(UINT16 dataPos) +{ + UINT16 dwRetVal=0U; + if ((NULL!=qds_dsuStaticIdmapStru)&&(NULL!=qds_dsuStaticIdmapStru->pSpksSecNumStru)) + { + if(dataPospSpksSecNumStru[dataPos].wIndexId; + } + } + return dwRetVal; +} + +/************************************************** +*ܣ豸λãȡ +* +* dataPos豸ṹλ +* +* +*ֵ +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT16 dquGetGodSecIndex(UINT16 dataPos) +{ + UINT16 dwRetVal=0U; + if ((NULL!=qds_dsuStaticIdmapStru)&&(NULL!=qds_dsuStaticIdmapStru->pGodSecNumStru)) + { + if(dataPospGodSecNumStru[dataPos].wIndexId; + } + } + + return dwRetVal; +} + +/************************************************** +*ܣ豸λãȡվ +* +* dataPos豸ṹλ +* +* +*ֵվ +* עڲʹú add by slm 2019-1-17 +***************************************************/ +UINT16 dquGetStaSecIndex(UINT16 dataPos) +{ + UINT16 dwRetVal = 0; + if ((NULL != qds_dsuStaticIdmapStru) && (NULL != qds_dsuStaticIdmapStru->pStaSecNumStru)) + { + if (dataPospStaSecNumStru[dataPos].wIndexId; + } + } + + return dwRetVal; +} + +/************************************************** +*ܣ豸λãȡ +* +* dataPos豸ṹλ +* +* +*ֵ +* עڲʹú add by slm 2019-1-17 +***************************************************/ +UINT16 dquGetPhySecIndex(UINT16 dataPos) +{ + UINT16 dwRetVal = 0; + if ((NULL != qds_dsuStaticIdmapStru) && (NULL != qds_dsuStaticIdmapStru->pPhySecNumStru)) + { + if (dataPospPhySecNumStru[dataPos].wIndexId; + } + } + + return dwRetVal; +} + + + +/*עб*/ +const DQU_GETFUN_LIST_WrW dquGetDevIndex={NULL,dquGetZCIndex,dquGetCIIndex,dquGetATSIndex,dquGetSigIndex,dquGetLinkIndex,dquGetSwiIndex,dquGetStationIndex, + dquGetEmergBtnIndex,dquGetBaliseIndex,dquGetPSDoorIndex,dquGetVobcIndex,dquGetFPDoorIndex,dquGetDsuIndex,dquGetLogicSecIndex,dquGetAomSecIndex, + dquGetSpksSecIndex,dquGetGodSecIndex,dquGetStaSecIndex,dquGetPhySecIndex, NULL, dquGetAxleIndex }; + + +/*ṩ豸ָ豸ֵȡ豸ṹ豸λֵ*/ +UINT16 dquGetZCNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->ZCNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuZCNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetCINumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->CINUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuCINumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetATSNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->ATSNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuATSNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetSignalNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->SIGNALNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuSignalNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetTrackSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->TRACKSECNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuTrackSecNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetSwitchNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->SWITCHNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuSwitchNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetStationNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->STATIONNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuStationNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetEmergBtnStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->EMERGBTNNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuEmergBtnIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetBaliseNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->BALISENUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuBaliseNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetPSDoorNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->PSDNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuPSDoorNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetVobcNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->VOBCNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuVobcNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetFPDoorNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->FPDNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuFPDoorNumIndex[devIndex]; + } + } + return dataPos; +} +UINT16 dquGetDsuNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->DSUNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuDsuNumIndex[devIndex]; + } + } + return dataPos; +} + +UINT16 dquGetLogicSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->LOGICSECNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuLogicSecNumIndex[devIndex]; + } + } + return dataPos; +} + +/************************************************** +*ܣѯAOM豸ŶӦ +* +* pDsuIdmapIndexStruŶձȫ +* devIndex豸 +* +* +*ֵ豸ŶӦ +* עڲʹú add by sds 2018-6-29 +***************************************************/ +UINT16 dquGetAomSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->AOMSECNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuAomSecNumIndex[devIndex]; + } + } + return dataPos; +} + +/************************************************** +*ܣѯSPKS豸ŶӦ +* +* pDsuIdmapIndexStruŶձȫ +* devIndex豸 +* +* +*ֵ豸ŶӦ +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT16 dquGetSpksSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->SPKSSECNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuSpksSecNumIndex[devIndex]; + } + } + return dataPos; +} + +/************************************************** +*ܣѯ豸ŶӦ +* +* pDsuIdmapIndexStruŶձȫ +* devIndex豸 +* +* +*ֵ豸ŶӦ +* עڲʹú add by sds 2018-6-29 +***************************************************/ +UINT16 dquGetGodSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru,UINT16 devIndex) +{ + UINT16 dataPos=0xffff; + if(NULL!=pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->GODSECNUMINDEXSIZE) + { + dataPos=pDsuIdmapIndexStru->dsuGodSecNumIndex[devIndex]; + } + } + return dataPos; +} + +/************************************************** +*ܣѯվͨ豸ŶӦ +* +* pDsuIdmapIndexStruŶձȫ +* devIndex豸 +* +* +*ֵ豸ŶӦ +* עڲʹú add by slm 2019-1-17 +***************************************************/ +UINT16 dquGetStaSecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru, UINT16 devIndex) +{ + UINT16 dataPos = 0xffff; + if (NULL != pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->STASECNUMINDEXSIZE) + { + dataPos = pDsuIdmapIndexStru->dsuStaSecNumIndex[devIndex]; + } + } + return dataPos; +} + +/************************************************** +*ܣѯλͨŶӦ +* +* pDsuIdmapIndexStruŶձȫ +* devIndex豸 +* +* +*ֵ豸ŶӦ +* עڲʹú add by slm 2019-1-17 +***************************************************/ +UINT16 dquGetPhySecNumStruPos(DSU_IDMAP_INDEX_STRU *pDsuIdmapIndexStru, UINT16 devIndex) +{ + UINT16 dataPos = 0xffff; + if (NULL != pDsuIdmapIndexStru) + { + if (devIndex <= pDsuIdmapIndexStru->PHYSECNUMINDEXSIZE) + { + dataPos = pDsuIdmapIndexStru->dsuPhySecNumIndex[devIndex]; + } + } + return dataPos; +} + +/*עб*/ +const DQU_GETFUN_LIST_IxWtW dquGetDevNumStruPos={NULL,dquGetZCNumStruPos,dquGetCINumStruPos,dquGetATSNumStruPos,dquGetSignalNumStruPos,dquGetTrackSecNumStruPos,dquGetSwitchNumStruPos, +dquGetStationNumStruPos,dquGetEmergBtnStruPos,dquGetBaliseNumStruPos,dquGetPSDoorNumStruPos,dquGetVobcNumStruPos,dquGetFPDoorNumStruPos,dquGetDsuNumStruPos,dquGetLogicSecNumStruPos, +dquGetAomSecNumStruPos,dquGetSpksSecNumStruPos,dquGetGodSecNumStruPos,dquGetStaSecNumStruPos ,dquGetPhySecNumStruPos, NULL, dquGetAxleNumStruPos, dquGetIteNumStruPos }; + + +/*---------------------------------------ⲿõĽӿںʹ㷨ʵ--------------------------------------------*/ + +/*õǰԴ*/ +UINT8 dquSetCurIdMapQueryDataSource(DSU_IDMAP_STRU *pDsuIdmapStru) +{ + UINT8 chReturnValue=0U; /*ںֵ*/ + if ( NULL != pDsuIdmapStru ) + { + qds_dsuIdmapIndexStru=pDsuIdmapStru->dsuIdmapIndexStru; /*豸ṹ*/ + qds_dsuIdmapLenStru=pDsuIdmapStru->dsuIdmapLenStru; /*ȫֱ¼ȡDSUеĸݵ*/ + qds_dsuStaticIdmapStru=pDsuIdmapStru->dsuStaticIdmapStru; /*ݿÿֽṹͷָ*/ + + if ((NULL != qds_dsuIdmapIndexStru) && + (NULL != qds_dsuIdmapLenStru) && + (NULL != qds_dsuStaticIdmapStru)) + { + chReturnValue=1; + qds_IsInitIdMapStruPtr=DQU_IDMAP_INIT_TRUE; + } + else + { + chReturnValue=0U; + qds_IsInitIdMapStruPtr=DQU_IDMAP_INIT_FALSE; + } + + } + else + { + chReturnValue=0U; + } + + return chReturnValue; +} + +/*ṩ豸Ųѯѯ豸ֵ*/ +UINT8 dquQueryInDevIndex(UINT8 struType,UINT32 devId, UINT16 *pInDevIndex) +{ + UINT8 bRetVal=0U; + UINT16 index=0U; + UINT16 DataCount=0U; + + if ((DQU_IDMAP_INIT_TRUE==qds_IsInitIdMapStruPtr) && (NULL != pInDevIndex)) + { + DataCount=dquGetDataLen[struType](); + for (index=0;indexTRACKSECNUMINDEXSIZE)) + { + /*ȡlinkƫ*/ + trackStepIndex=qds_dsuIdmapIndexStru->dsuTrackSecNumIndex[linkId]; + + /*ѯϢΪЧֵ*/ + if (0xFFFF != trackStepIndex) + { + /*ȡlinkӦĹνṹָλ*/ + pTrackSecStru=qds_dsuStaticIdmapStru->pTrackSecNumStru+trackStepIndex; + + /*νṹָ벻Ϊգмƫ*/ + if ((NULL != pTrackSecStru) && (linkId == pTrackSecStru->wLinkId) + && (NULL != pTrackSecId) && (NULL != pTrackOffset)) + { + /*LinkӦĹϢ ѯƫϢ*/ + for(wPos=0U;wPos< pTrackSecStru->wTrackNum;wPos++) + { + dwCurTrackId=pTrackSecStru->dwTrackSecId[wPos]; + dwCurTrackLen=pTrackSecStru->dwTrackSecLen[wPos]; + if(linkOffset <= (dwTrackSumLen+dwCurTrackLen)) + { + *pTrackSecId=dwCurTrackId; + + *pTrackOffset=linkOffset-dwTrackSumLen; + bRetVal=1; + break; + } + else + { + dwTrackSumLen+=dwCurTrackLen; + } + } + } + else + { + failCode=0x03; + } + } + else + { + failCode=0x02; + } + } + else + { + failCode=0x01; + } + + } + + if (0 != failCode) + { + printf("QueryTrackId Error:%d \n",failCode); + } + + return bRetVal; +} + + +/************************************************** +*ܣ֪εıźƫѯLinkıźƫ +* +* trackIdα +* trackOffsetƫ +* +* pLinkIdȡLINK +* pLinkOffsetȡLINKƫ +*ֵ1ɹ0ʧ +******************************************************/ +UINT8 dquQueryLinkIdOffset(UINT32 trackId, UINT32 trackOffset, UINT16 *pLinkId, UINT32 *pLinkOffset) +{ + UINT16 wTrackIndex,wPos=0U; + UINT8 bRetVal=0U; + UINT8 bFound=0U; + DSU_TRACKSEC_NUM_STRU *pTrackSecStru=NULL; + UINT32 dwCurTrackId=0,dwCurTrackLen=0,dwTrackSumLen=0U; + if ((NULL != pLinkId) && (NULL != pLinkOffset)) + { + if (DQU_IDMAP_INIT_TRUE == qds_IsInitIdMapStruPtr) + { + /*ҵ*/ + for (wPos = 0; wPoswTrackSecNumLen; wPos++) + { + pTrackSecStru = qds_dsuStaticIdmapStru->pTrackSecNumStru + wPos; + for (wTrackIndex = 0; wTrackIndex < pTrackSecStru->wTrackNum; wTrackIndex++) + { + if (trackId == pTrackSecStru->dwTrackSecId[wTrackIndex]) + { + *pLinkId = pTrackSecStru->wLinkId; + dwCurTrackLen = pTrackSecStru->dwTrackSecLen[wTrackIndex]; + if (trackOffset <= dwCurTrackLen)/*ҵĹ*/ + { + bFound = 1; + } + else/*ҵĹαСڲƫ*/ + { + bRetVal = 0; + bFound = 0; + } + + break; + } + } + if (1 == bFound) + { + break; + } + } + + /*ҵβҲҵļṹָ벻Ϊգƫ*/ + if ((1 == bFound) && (NULL != pTrackSecStru)) + { + for (wPos = 0; wPos< pTrackSecStru->wTrackNum; wPos++) + { + + dwCurTrackId = pTrackSecStru->dwTrackSecId[wPos]; + dwCurTrackLen = pTrackSecStru->dwTrackSecLen[wPos]; + if (trackId == dwCurTrackId) + { + *pLinkOffset = dwTrackSumLen + trackOffset; + bRetVal = 1; + break; + } + else + { + dwTrackSumLen += dwCurTrackLen; + } + } + } + } + + } + return bRetVal; +} + +/************************************************** +*ܣ豸λãȡvobc +* +* dataPos豸ṹλ +* +* +*ֵvobcָ +* עڲʹú add by qxt 20170117 +***************************************************/ +UINT32* dquGetVobcDevIdArray(UINT16 dataPos) +{ + UINT32 *pwRetVal=NULL; + if(dataPospVobcNumStru[dataPos].dwVobcId; + } + return pwRetVal; +} + +/************************************************** +*ܣ豸λãȡAOM +* +* dataPos豸ṹλ +* +* +*ֵAOMָ +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT32* dquGetAOMDevIdArray(UINT16 dataPos) +{ + UINT32 *pwRetVal=NULL; + if ((NULL!=qds_dsuStaticIdmapStru)&&(NULL!=qds_dsuStaticIdmapStru->pAomSecNumStru)) + { + if(dataPospAomSecNumStru[dataPos].dwAomSecId; + } + } + + return pwRetVal; +} + +/************************************************** +*ܣѯvobc +* +* devId豸 +* +* pInDevIndex,صֵ +*ֵ1ɹ0ʧ +*עvobcֶΡvobc2赥 add by qxt 20170117 +***************************************************/ +UINT8 dquQueryInVobcDevIndex(UINT32 devId, UINT16 *pInDevIndex) +{ + UINT8 bRetVal=0U; + UINT16 index=0U; + UINT16 DataCount=0U; + UINT32 *pwVobcDevId=NULL; + + /*ָ*/ + if (NULL != pInDevIndex) + { + *pInDevIndex = 0; /*ӶijʼֹδԸñֵʱֵ*/ + if (DQU_IDMAP_INIT_TRUE == qds_IsInitIdMapStruPtr) + { + DataCount = dquGetDataLen[QFUN_IDMAP_VOBC_ID](); + for (index = 0; index= IDMAP_TYPE_MIN) && (struType <= IDMAP_TYPE_MAX) && (QFUN_IDMAP_AOM_ID != struType))/*豸ȡֵ m by sds 2018-6-29*/ + { + if (DQU_IDMAP_INIT_TRUE == qds_IsInitIdMapStruPtr) + { + DataCount = dquGetDataLen[struType](); + for (index = 0; index < DataCount; index++) + { + tempDevId = dquGetDevId[struType](index); + if ((devId&bitMask) == (tempDevId&bitMask)) + { + *pInDevIndex = dquGetDevIndex[struType](index); + tempCount++; + + } + } + if (1 == tempCount) + { + bRetVal = 1; + } + } + } + } + else + { + bRetVal = 0; + } + return bRetVal; +} + +/************************************************** +*ܣȡVOBC豸Ӧλѯvobc +***************************************************/ +UINT8 dquQueryVobcDevBits2Index(UINT32 devId,UINT32 bitMask,UINT16 *pInDevIndex) +{ + UINT8 bRetVal=0U; + UINT16 index=0U; + UINT16 DataCount=0U; + UINT32 *pwVobcDevId=NULL; + UINT16 tempCount=0U;/*ҵ豸ֵҵĸӦΪ1ʧ*/ + + /*ָ*/ + if (NULL != pInDevIndex) + { + if (DQU_IDMAP_INIT_TRUE == qds_IsInitIdMapStruPtr) + { + DataCount = dquGetDataLen[QFUN_IDMAP_VOBC_ID](); + for (index = 0; index < DataCount; index++) + { + pwVobcDevId = dquGetVobcDevIdArray(index); + if (((devId&bitMask) == (pwVobcDevId[0] & bitMask)) || ((devId&bitMask) == (pwVobcDevId[1] & bitMask))) + { + *pInDevIndex = dquGetDevIndex[QFUN_IDMAP_VOBC_ID](index); + tempCount++; + } + } + if (1 == tempCount) + { + bRetVal = 1; + } + } + } + return bRetVal; + +} + +/************************************************** +*ܣȡAOM豸ӦλѯAOM +* +*devId AOM豸 +*bitMask 豸ŵЧλ +* +* pInDevIndex豸 +*ֵ1ɹ0ʧ add by sds 2018-6-25 +***************************************************/ +UINT8 dquQueryAOMDevBits2Index(UINT32 devId,UINT32 bitMask,UINT16 *pInDevIndex) +{ + UINT8 bRetVal=0U; + UINT16 index=0U; + UINT16 DataCount=0U; + UINT32 *pwAOMDevId=NULL; + UINT16 tempCount=0U;/*ҵ豸ֵҵĸӦΪ1ʧ*/ + + /*ָ*/ + if (NULL != pInDevIndex) + { + if (DQU_IDMAP_INIT_TRUE == qds_IsInitIdMapStruPtr) + { + DataCount = dquGetDataLen[QFUN_IDMAP_AOM_ID](); + for (index = 0; index < DataCount; index++) + { + pwAOMDevId = dquGetAOMDevIdArray(index); + if (((devId&bitMask) == (pwAOMDevId[0] & bitMask)) || ((devId&bitMask) == (pwAOMDevId[1] & bitMask))) + { + *pInDevIndex = dquGetDevIndex[QFUN_IDMAP_AOM_ID](index); + tempCount++; + } + } + if (1 == tempCount) + { + bRetVal = 1; + } + } + } + return bRetVal; +} + +/************************************************** +*ܣӦУλòѯӦ· +* +* dataPos:λ +* +* +*ֵ· +*עڲʹúadd by qxt 2018-7-25 RDGG47 +***************************************************/ +static UINT16 dquBaliseLineId(UINT16 dataPos) +{ + UINT16 dwRetVal=0U; + if ((NULL!=qds_dsuStaticIdmapStru)&&(NULL!=qds_dsuStaticIdmapStru->pBaliseNumStru)) + { + if(dataPospBaliseNumStru[dataPos].wLindId; + } + } + + return dwRetVal; +} + +/************************************************** +*ܣѯӦ豸 +* +* lineId· +* devId豸 +* +* pInDevIndex,صֵ +*ֵ1ɹ0ʧ +*עѯӦ豸ʱʹøúӿڡ·ź豸ȷֵadd by qxt 2018-7-25 RDGG47 +***************************************************/ +UINT8 dquQueryInBaliseDevIndex(UINT16 lineId,UINT32 devId, UINT16 *pInDevIndex) +{ + UINT8 bRetVal=0U; + UINT16 index=0U; + UINT16 DataCount=0U; + + if ((DQU_IDMAP_INIT_TRUE==qds_IsInitIdMapStruPtr) && (NULL != pInDevIndex)) + { + DataCount=dquGetDataLen[QFUN_IDMAP_BALISE_ID](); + for (index=0;indexpAxleNumStru[dataPos].dwAxleId; + } + else + { + /*ηǷNULL*/ + } + return pwRetVal; +} + +/************************************************** +*ܣ豸λãȡϵͳID +*dataPos豸ṹλ +* +*ֵ0 ȡʧ +* ϵͳID +*Created by LQ 20231211 +***************************************************/ +UINT16 dquGetAxleIndex(UINT16 dataPos) +{ + UINT16 wRetVal = 0U; + + if (dataPos < dquGetDataLen[QFUN_IDMAP_AXLE_ID]()) + { + wRetVal = qds_dsuStaticIdmapStru->pAxleNumStru[dataPos].wIndexId; + } + else + { + /*ηǷ0*/ + } + + return wRetVal; +} + +/************************************************** +*ܣȡϵͳṹ峤 +* +* +*ֵ0 ȡʧ +* ϵͳṹ峤 +*Created by LQ 20231211 +***************************************************/ +UINT16 dquGetAxleNumLen(void) +{ + UINT16 retVal = 0U; + + if (NULL != qds_dsuIdmapLenStru) + { + retVal = qds_dsuIdmapLenStru->wAxleNumLen; + } + else + { + /*ȽṹΪգ0*/ + } + + return retVal; +} + +/************************************************** +*ܣȡϵͳ +*DSU_IDMAP_INDEX_STRU* pDsuIdmapIndexStru Ŷձṹ +* UINT16 devIndex +* +*ֵ0xFFFF ȡʧ +* ϵͳ +*Created by LQ 20231211 +***************************************************/ +UINT16 dquGetAxleNumStruPos(DSU_IDMAP_INDEX_STRU* pDsuIdmapIndexStru, UINT16 devIndex) +{ + UINT16 retVal = 0xFFFFU; + + if ((NULL != pDsuIdmapIndexStru) && (devIndex <= pDsuIdmapIndexStru->AXLENUMINDEXSIZE)) + { + retVal = pDsuIdmapIndexStru->dsuAxleNumIndex[devIndex]; + } + else + { + /*ηǷNULL*/ + } + + return retVal; +} + +/************************************************** +*ܣȡITEṹ峤 +* +* +* ֵ0 ȡʧ +* ITEṹ峤 +***************************************************/ +UINT16 dquGetIteNumLen(void) +{ + UINT16 retVal = 0U; + + if (NULL != qds_dsuIdmapLenStru) + { + retVal = qds_dsuIdmapLenStru->wIteNumLen; + } + else + { + /*ȽṹΪգ0*/ + } + + return retVal; +} + +/************************************************** +* ܣȡITE +* DSU_IDMAP_INDEX_STRU* pDsuIdmapIndexStru Ŷձṹ +* UINT16 devIndex +* +* ֵ0xFFFF ȡʧ +* ITE +***************************************************/ +UINT16 dquGetIteNumStruPos(DSU_IDMAP_INDEX_STRU* pDsuIdmapIndexStru, UINT16 devIndex) +{ + UINT16 wRetVal = 0xFFFFU; + + if ((NULL != pDsuIdmapIndexStru) && (devIndex <= pDsuIdmapIndexStru->ITENUMINDEXSIZE)) + { + wRetVal = pDsuIdmapIndexStru->dsuIteNumIndex[devIndex]; + } + else + { + /*ηǷ*/ + } + + return wRetVal; +} + +/************************************************** +* ܣ豸λãȡITEͨ +* dataPos豸ṹλ +* +* ֵNULL ȡʧ +* NULL ITEͨ +***************************************************/ +UINT32* dquGetIteDevIdArray(UINT16 dataPos) +{ + UINT32* pRetVal = NULL; + + if (dataPos < dquGetDataLen[QFUN_IDMAP_ITE_ID]()) + { + pRetVal = qds_dsuStaticIdmapStru->pIteNumStru[dataPos].dwIteId; + } + else + { + /*ηǷNULLʧ*/ + } + + return pRetVal; +} + +/************************************************** +*ܣѯITE豸 +*UINT16 devIndex 豸ֵ +*UINT32 szOutDevId[2U] ITEͨ豸 +* ֵ0 ʧ +* 1 ɹ +***************************************************/ +UINT8 dquQueryOutIteDevId(UINT16 devIndex, UINT32 szOutDevId[2U]) +{ + UINT8 cRetVal = 0U; + UINT16 wDataPos = 0xFFFFU; + UINT32* dquIteDevIdArrayData = NULL; + + if ((DQU_IDMAP_INIT_TRUE == qds_IsInitIdMapStruPtr) && (NULL != szOutDevId)) + { + wDataPos = dquGetDevNumStruPos[QFUN_IDMAP_ITE_ID](qds_dsuIdmapIndexStru, devIndex); /*ȡĿITEڱŶձе*/ + if (0xFFFFU != wDataPos) + { + dquIteDevIdArrayData = dquGetIteDevIdArray(wDataPos); /*ȡITEͨID*/ + if (NULL != dquIteDevIdArrayData) + { + (void)CommonMemCpy(szOutDevId, sizeof(UINT32) * 2U, dquIteDevIdArrayData, sizeof(UINT32) * 2U); /*ITEͨID鿽*/ + + if ((0U != szOutDevId[0U]) && (0U != szOutDevId[1U])) + { + cRetVal = 1U; + } + else + { + cRetVal = 0U; /*ʧܣ0ʧ*/ + } + } + else + { + cRetVal = 0U; + } + } + else + { + /*ȡλʧܣ0ʧ*/ + } + } + else + { + /*0ʧ*/ + } + + return cRetVal; +} \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapQuery.h b/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapQuery.h new file mode 100644 index 0000000..1eca888 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_idmap_common/dquIdmapQuery.h @@ -0,0 +1,310 @@ +/************************************************************************ +* +* ļ dsuIdmapQuery.h +* Ȩ˵ ؿƼƼ޹˾ +* 汾 1.0 +* ʱ 2016.04.12 +* +* dsuѯͷļ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _DSU_IDMAP_QUERY_H +#define _DSU_IDMAP_QUERY_H + +#ifdef ZCAPP_VXWORKS_CODECONTROL +#include +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "CommonTypes.h" +#include "dsuIdmapStruct.h" +#include "dquVobcCommonStru.h" +#include "CommonMemory.h" + + +#define QFUN_IDMAP_ZC_ID 1 /*ZCID*/ +#define QFUN_IDMAP_CI_ID 2 /*CIID*/ +#define QFUN_IDMAP_ATS_ID 3 /*ATSID*/ +#define QFUN_IDMAP_SIGNAL_ID 4 /*źŻID*/ +/*#define QFUN_IDMAP_TRACKSEC_ID αID --by hgj ˽ӿݽṹ汾4.0Ѿ */ +#define QFUN_IDMAP_SWITCH_ID 6 /*ID*/ +#define QFUN_IDMAP_STATION_ID 7 /*վ̨ID*/ +#define QFUN_IDMAP_EMERGBTN_ID 8 /*رհťID*/ +#define QFUN_IDMAP_BALISE_ID 9 /*ӦID*/ +#define QFUN_IDMAP_PSD_ID 10 /*űID*/ +/*#define QFUN_IDMAP_VOBC_ID VOBCID --by qxt ˽ӿݽṹ汾7.0Ѿ*/ +#define QFUN_IDMAP_FPD_ID 12 /*űID*/ +#define QFUN_IDMAP_DSU_ID 13 /*DSUID*/ +#define QFUN_IDMAP_LOGICSEC_ID 14 /*߼αID*/ + +#define QFUN_IDMAP_SPKS_ID 16 /*SPKSID*/ +#define QFUN_IDMAP_GOD_ID 17 /*űID*/ +#define QFUN_IDMAP_STA_ID 18 /*վID*/ +#define QFUN_IDMAP_PHY_ID 19 /*αID*/ +#define QFUN_IDMAP_AXLE_ID 21 /*ϵͳID*/ +#define QFUN_IDMAP_ITE_ID 22 /*ITEID*/ + +#define IDMAP_TYPE_MIN 1 /*ѯṹСֵ add by qxt 20170509*/ +#define IDMAP_TYPE_MAX 21 /*ѯṹֵڷѯstruTypeķΧ*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*Ŷձѯʽӿ*/ + +/*õǰԴ*/ +UINT8 dquSetCurIdMapQueryDataSource(DSU_IDMAP_STRU *pDsuIdmapStru); + +/************************************************** +*ܣѯ豸 +* +* struTypeѯĽṹ +* devId豸 +* +* pInDevIndex,صֵ +*ֵ1ɹ0ʧ +***************************************************/ +UINT8 dquQueryInDevIndex(UINT8 struType,UINT32 devId, UINT16 *pInDevIndex); + + +/************************************************** +*ܣѯ豸 +* +* struTypeѯĽṹ +* devId豸ֵ +* +* pOutDevIdȡĻͨ豸 +*ֵ1ɹ0ʧ +***************************************************/ +UINT8 dquQueryOutDevId(UINT8 struType,UINT16 devIndex, UINT32 *pOutDevId); + + +/************************************************** +*ܣ֪εıźƫѯLinkıźƫ +* +* trackIdα +* trackOffsetƫ +* +* pLinkIdȡLINK +* pLinkOffsetȡLINKƫ +*ֵ1ɹ0ʧ +******************************************************/ +UINT8 dquQueryLinkIdOffset(UINT32 trackId, UINT32 trackOffset, UINT16 *pLinkId, UINT32 *pLinkOffset); + +/***************************************************** +*ܣ֪Linkıźƫѯεıźƫ +* +* linkIdlink +* linkOffsetlinkƫ +* +* pTrackSecIdα +* pTrackOffsetƫ +*ֵ1ɹʧ +******************************************************/ +UINT8 dquQueryTrackIdOffset(UINT16 linkId, UINT32 linkOffset, UINT32 *pTrackSecId, UINT32 *pTrackOffset); + + +/************************************************** +*ܣ豸λãȡvobc +* +* dataPos豸ṹλ +* +* +*ֵvobcָ +* עڲʹú add by qxt 20170117 +***************************************************/ +UINT32* dquGetVobcDevIdArray(UINT16 dataPos); + +/************************************************** +*ܣ豸λãȡAOM +* +* dataPos豸ṹλ +* +* +*ֵAOMָ +* עڲʹú add by sds 2018-6-14 +***************************************************/ +UINT32* dquGetAOMDevIdArray(UINT16 dataPos); + +/************************************************** +*ܣѯvobc +* +* devId豸 +* +* pInDevIndex,صֵ +*ֵ1ɹ0ʧ +*עvobcֶΡvobc2赥 add by qxt 20170117 +***************************************************/ +UINT8 dquQueryInVobcDevIndex(UINT32 devId, UINT16 *pInDevIndex); + +/************************************************** +*ܣѯvobc豸 +* +* devId豸ֵ +* +* arOutDevIdsȡĻͨ豸 +*ֵ1ɹ0ʧ +*עvobcֶΡvobc2赥 add by qxt 20170117 +***************************************************/ +UINT8 dquQueryOutVobcDevId(UINT16 devIndex, UINT32 arOutDevIds[]); + +/************************************************** +*ܣѯAOM +* +* devId豸 +* +* pInDevIndex,صֵ +*ֵ1ɹ0ʧ add by sds 2018-6-14 +***************************************************/ +UINT8 dquQueryInAOMDevIndex(UINT32 devId, UINT16 *pInDevIndex); + +/************************************************** +*ܣѯAOM豸 +* +* devId豸ֵ +* +* arOutDevIdsȡĻͨ豸 +*ֵ1ɹ0ʧ add by sds 2018-6-14 +***************************************************/ +UINT8 dquQueryOutAOMDevId(UINT16 devIndex, UINT32 arOutDevIds[]); + + +/************************************************** +*ܣȡ豸Ӧλѯ豸ֵ +* +* struTypeѯĽṹ +* devId豸 +* bitMask,豸Чλ +* +* pInDevIndexȡĻͨ豸ֵ +*ֵ1ɹ0ʧ +*ʹ1devId 豣֤ȷ(ڱдΨһ) + 2bitMaskΪȡdevIdЧbitMaskλٲѯӦ磺ȥdevIdĸ5λʱɽBits0x7FFFFFF; +* øúҪ֤ȡdevIdЧλӦֵΨһģ +*add by qxt 20170421 +***************************************************/ +UINT8 dquQueryDevBits2Index(UINT8 struType,UINT32 devId, UINT32 bitMask,UINT16 *pInDevIndex); + +/************************************************** +*ܣȡVOBC豸Ӧλѯvobcֵ +* +* devIdvobc豸 +* bitMask,豸ŵЧλ +* +* pInDevIndexȡvobc豸ֵ +*ֵ1ɹ0ʧ +*עvobc豸ID赥 add by qxt 20170421 +***************************************************/ +UINT8 dquQueryVobcDevBits2Index(UINT32 devId,UINT32 bitMask,UINT16 *pInDevIndex); + +/************************************************** +*ܣȡAOM豸ӦλѯAOM +* +*devId AOM豸 +*bitMask 豸ŵЧλ +* +* pInDevIndex豸 +*ֵ1ɹ0ʧ add by sds 2018-6-25 +***************************************************/ +UINT8 dquQueryAOMDevBits2Index(UINT32 devId,UINT32 bitMask,UINT16 *pInDevIndex); + +/************************************************** +*ܣѯӦ豸 +* +* lineId· +* devId豸 +* +* pInDevIndex,صֵ +*ֵ1ɹ0ʧ +*עѯӦ豸ʱʹøúӿڡ·ź豸ȷֵadd by qxt 2018-7-25 RDGG47 +***************************************************/ +UINT8 dquQueryInBaliseDevIndex(UINT16 lineId,UINT32 devId, UINT16 *pInDevIndex); + +/************************************************** +*ܣ豸λãȡϵͳͨ +*dataPos 豸ṹλ +* +*ֵ0U ȡʧ +* ϵͳͨ +*Created by LQ 20231211 +***************************************************/ +UINT32 dquGetAxleDevId(UINT16 dataPos); + +/************************************************** +*ܣ豸λãȡϵͳID +*dataPos豸ṹλ +* +*ֵ0 ȡʧ +* ϵͳID +*Created by LQ 20231211 +***************************************************/ +UINT16 dquGetAxleIndex(UINT16 dataPos); + +/************************************************** +*ܣȡϵͳṹ峤 +* +* +*ֵ0 ȡʧ +* ϵͳṹ峤 +*Created by LQ 20231211 +***************************************************/ +UINT16 dquGetAxleNumLen(void); + +/************************************************** +*ܣȡϵͳ +*DSU_IDMAP_INDEX_STRU* pDsuIdmapIndexStru Ŷձṹ +* UINT16 devIndex +* +*ֵ0xFFFF ȡʧ +* ϵͳ +*Created by LQ 20231211 +***************************************************/ +UINT16 dquGetAxleNumStruPos(DSU_IDMAP_INDEX_STRU* pDsuIdmapIndexStru, UINT16 devIndex); + +UINT16 dquGetVobcIndex(UINT16 dataPos); + +/************************************************** +*ܣȡITEṹ峤 +* +* +* ֵ0 ȡʧ +* ITEṹ峤 +***************************************************/ +UINT16 dquGetIteNumLen(void); + +/************************************************** +* ܣȡITE +* DSU_IDMAP_INDEX_STRU* pDsuIdmapIndexStru Ŷձṹ +* UINT16 devIndex +* +* ֵ0xFFFF ȡʧ +* ITE +***************************************************/ +UINT16 dquGetIteNumStruPos(DSU_IDMAP_INDEX_STRU* pDsuIdmapIndexStru, UINT16 devIndex); + +/************************************************** +* ܣ豸λãȡITEͨ +* dataPos豸ṹλ +* +* ֵNULL ȡʧ +* NULL ITEͨ +***************************************************/ +UINT32* dquGetIteDevIdArray(UINT16 dataPos); + +/************************************************** +*ܣѯITE豸 +*UINT16 devIndex 豸ֵ +*UINT32 szOutDevId[2U] ITEͨ豸 +* ֵ0 ʧ +* 1 ɹ +***************************************************/ +UINT8 dquQueryOutIteDevId(UINT16 devIndex, UINT32 szOutDevId[2U]); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapStruct.h b/TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapStruct.h new file mode 100644 index 0000000..374dd64 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapStruct.h @@ -0,0 +1,316 @@ + /************************************************************************ +* ļ dsuIdmapStruct.h +* 汾 1.0 +* ʱ 2016.03.20 +* +* dsuṹ嶨ͷļ +* ʹע +* ޸ļ¼ ޡ +************************************************************************/ + +#ifndef _IDMAP_STRUCT_H +#define _IDMAP_STRUCT_H + +#include "CommonTypes.h" + + +#define LEN_WORD sizeof(UINT16) +#define LEN_DWORD sizeof(UINT32) + +#ifdef __cplusplus +extern "C" { +#endif + + + + + +/* ̬ݳϢṹ*/ +typedef struct DSU_NumMap_Len +{ + UINT16 wZCNumLen; /*ݿZCűĽṹ*/ + UINT16 wCINumLen; /*ݿ/CIűĽṹ*/ + UINT16 wATSNumLen; /*ݿATSűĽṹ*/ + UINT16 wSignalNumLen; /*ݿźŻűĽṹ*/ + UINT16 wTrackSecNumLen; /*ݿйαĽṹ*/ + UINT16 wSwitchNumLen; /*ݿеűĽṹ*/ + UINT16 wStationNumLen; /*ݿվ̨űĽṹ*/ + UINT16 wEmergBtnNumLen; /*ݿ/رհťűĽṹ*/ + UINT16 wBaliseNumLen; /*ݿӦűĽṹ*/ + UINT16 wPSDoorNumLen; /*ݿűűĽṹ*/ + UINT16 wVobcNumLen; /*ݿVOBCűĽṹ*/ + UINT16 wFPDoorNumLen; /*ݿзűűĽṹ*/ + UINT16 wDsuNumLen; /*ݿDSUűĽṹ*/ + UINT16 wLogicSecNumLen; /*ݿ߼αűĽṹ*/ + UINT16 wAomSecNumLen; /*ݿAOMűĽṹ*/ + UINT16 wSpksSecNumLen; /*ݿSPKSűĽṹ*/ + UINT16 wGodSecNumLen; /*ݿгűűĽṹ*/ + UINT16 wStaSecNumLen; /*ݿгվűṹ add by slm 2019-1-15 */ + UINT16 wPhySecNumLen; /*ݿαűṹ add by slm 2019-1-15 */ + UINT16 wAxleNumLen; /*ݿмϵͳűṹ add by lq 2023-12-08 */ + UINT16 wIteNumLen; /*ݿITEűṹ add by lq 2024-06-06 */ +}DSU_IDMAP_LEN_STRU; + +/*̬ݿṹ*/ +/*ZCű*/ +typedef struct DSU_ZCIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwZCDevId; /*ZC豸*/ +} DSU_ZC_NUM_STRU; + +/*CIű*/ +typedef struct DSU_CIIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwCIDevId; /*CI豸*/ +} DSU_CI_NUM_STRU; + +/*ATSű*/ +typedef struct DSU_ATSIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwATSDevId; /*ATS豸*/ +} DSU_ATS_NUM_STRU; + +/*źŻű*/ +typedef struct DSU_SignalIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwSigDevId; /*źŻ豸*/ +} DSU_SIGNAL_NUM_STRU; + +/*α*/ +typedef struct DSU_TrackSecIdStruct +{ + UINT16 wLinkId; /*LINK*/ + UINT16 wTrackNum; + UINT32 dwTrackSecId[15]; /*α*/ + UINT32 dwTrackSecLen[15]; /*γ*/ +}DSU_TRACKSEC_NUM_STRU; + +/*ű*/ +typedef struct DSU_SwitchIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwSwiDevId; /*豸*/ +}DSU_SWITCH_NUM_STRU; + +/*վ̨ű*/ +typedef struct DSU_StationIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwStationId; /*վ̨*/ +}DSU_STATION_NUM_STRU; + +/*رհťű*/ +typedef struct DSU_EmergButtonIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwEmergBtnId; /*رհť*/ +}DSU_EMERGBTN_NUM_STRU; + +/*Ӧű*/ +typedef struct DSU_BaliseIdStruct +{ + UINT16 wIndexId; /**/ + UINT16 wBaliseId; /*Ӧ*/ + UINT16 wLindId; /*·*/ +}DSU_BALISE_NUM_STRU; + +/*űű*/ +typedef struct DSU_PSDoorIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwPSDoorId; /*ű*/ +}DSU_PSD_NUM_STRU; + +/*VOBCű*/ +typedef struct DSU_VOBCIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwVobcId[2]; /*VOBC*//*change by qxt 20170117*/ +}DSU_VOBC_NUM_STRU; + +/*űű*/ +typedef struct DSU_FPDoorIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwFPDoorId; /*ű */ +}DSU_FPD_NUM_STRU; + +/*DSUű*/ +typedef struct DSU_DSUIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwDsuId; /*Dsu */ +}DSU_DSU_NUM_STRU; + +/*߼αű------add qxt 20160811*/ +typedef struct DSU_LogicSecIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwLogicSecId; /*߼α */ +}DSU_LOGICSEC_NUM_STRU; + +/*AOMű------add by sds 2018-6-14 */ +typedef struct DSU_AOMSecIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwAomSecId[2]; /*AOM豸 */ +}DSU_AOMSEC_NUM_STRU; + +/*SPKSű------add by sds 2018-6-14 */ +typedef struct DSU_SPKSSecIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwSpksSecId; /*SPKS豸 */ +}DSU_SPKSSEC_NUM_STRU; + +/*űű------add by sds 2018-6-14 */ +typedef struct DSU_GODSecIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwGodSecId; /*豸 */ +}DSU_GODSEC_NUM_STRU; + +/*վű-------add by slm 2019-1-15 */ +typedef struct DSU_STASecIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwStaSecId; /*վͨ豸 */ +}DSU_STASEC_NUM_STRU; + +/*αű-------add by slm 2019-1-16 */ +typedef struct DSU_PHYSecIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwPhySecId; /*λͨ豸 */ +}DSU_PHYSEC_NUM_STRU; + +/*ϵͳű-------add by lq 2023-12-08 */ +typedef struct DSU_AxleIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwAxleId; /*ϵͳͨ豸 */ +}DSU_AXLE_NUM_STRU; + +/*ITEű*/ +typedef struct DSU_ITEIdStruct +{ + UINT16 wIndexId; /**/ + UINT32 dwIteId[2]; /*ITE*//*Added By LQ 20240606*/ +}DSU_ITE_NUM_STRU; + +/*ž̬ݸݽṹͷָ*/ +typedef struct DSU_StaticIDMap +{ + DSU_ZC_NUM_STRU *pZCNumStru; /*ZCűṹָ*/ + DSU_CI_NUM_STRU *pCINumStru; /*CIűṹָ*/ + DSU_ATS_NUM_STRU *pATSNumStru; /*ATSűṹָ*/ + DSU_SIGNAL_NUM_STRU *pSignalNumStru; /*źŻűṹָ*/ + DSU_TRACKSEC_NUM_STRU *pTrackSecNumStru; /*αṹָ*/ + DSU_SWITCH_NUM_STRU *pSwitchNumStru; /*űṹָ*/ + DSU_STATION_NUM_STRU *pStationNumStru; /*վ̨űṹָ*/ + DSU_EMERGBTN_NUM_STRU *pEmergBtnNumStru; /*رհťűṹָ*/ + DSU_BALISE_NUM_STRU *pBaliseNumStru; /*Ӧűṹָ*/ + DSU_PSD_NUM_STRU *pPSDNumStru; /*űűṹָ*/ + DSU_VOBC_NUM_STRU *pVobcNumStru; /*VOBCűṹָ*/ + DSU_FPD_NUM_STRU *pFPDoorNumStru; /*űűṹָ*/ + DSU_DSU_NUM_STRU *pDsuNumStru; /*DSUűṹָ*/ + DSU_LOGICSEC_NUM_STRU *pLogicSecNumStru; /*߼αűṹָ*/ + DSU_AOMSEC_NUM_STRU *pAomSecNumStru; /*AOMűṹָ*/ + DSU_SPKSSEC_NUM_STRU *pSpksSecNumStru; /*SPKSűṹָ*/ + DSU_GODSEC_NUM_STRU *pGodSecNumStru; /*űűṹָ*/ + DSU_STASEC_NUM_STRU *pStaSecNumStru; /*վűṹָ add by slm 2019-1-15 */ + DSU_PHYSEC_NUM_STRU *pPhySecNumStru; /*αűṹָ add by slm 2019-1-16 */ + DSU_AXLE_NUM_STRU *pAxleNumStru; /*ϵͳűṹָ add by lq 2023-12-08 */ + DSU_ITE_NUM_STRU *pIteNumStru; /*ITEűṹָ add by lq 2024-06-06*/ +}DSU_STATIC_IDMAP_STRU; + +/*Ϊȫ*/ +typedef struct DSU_IdmapIndexStruct +{ + UINT16 ZCNUMINDEXSIZE; /*ZCűռС*/ + UINT16* dsuZCNumIndex; /*linkϢ*/ + + UINT16 CINUMINDEXSIZE; /*CIűռС*/ + UINT16* dsuCINumIndex; /*Ϣ*/ + + UINT16 ATSNUMINDEXSIZE; /*ATSűռС*/ + UINT16* dsuATSNumIndex; /*ӦϢ*/ + + UINT16 SIGNALNUMINDEXSIZE; /*źŻűռС*/ + UINT16* dsuSignalNumIndex; /*źŻϢ*/ + + UINT16 TRACKSECNUMINDEXSIZE; /*αռС*/ + UINT16* dsuTrackSecNumIndex; /*Ϣ*/ + + UINT16 SWITCHNUMINDEXSIZE; /*űռС*/ + UINT16* dsuSwitchNumIndex; /*ȫϢ*/ + + UINT16 STATIONNUMINDEXSIZE; /*վ̨űռС*/ + UINT16* dsuStationNumIndex; /*վ̨Ϣ*/ + + UINT16 EMERGBTNNUMINDEXSIZE; /*رհťűռС*/ + UINT16* dsuEmergBtnIndex; /*ͣťϢ*/ + + UINT16 BALISENUMINDEXSIZE; /*ӦűռС*/ + UINT16* dsuBaliseNumIndex; /*Ϣ*/ + + UINT16 PSDNUMINDEXSIZE; /*űűռС*/ + UINT16* dsuPSDoorNumIndex; /*ͣϢ*/ + + UINT16 VOBCNUMINDEXSIZE; /*VOBCűռС*/ + UINT16* dsuVobcNumIndex; /*Ϣ*/ + + UINT16 FPDNUMINDEXSIZE; /*űűռС*/ + UINT16* dsuFPDoorNumIndex; /*˳CBTCϢ*/ + + UINT16 DSUNUMINDEXSIZE; /*DSUűռС*/ + UINT16* dsuDsuNumIndex; /*DSUϢ*/ + + UINT16 LOGICSECNUMINDEXSIZE; /*߼αűռС*/ + UINT16* dsuLogicSecNumIndex; /*߼Ϣ*/ + + UINT16 AOMSECNUMINDEXSIZE; /*AOMűռС*/ + UINT16* dsuAomSecNumIndex; /*AOMϢ*/ + + UINT16 SPKSSECNUMINDEXSIZE; /*SPKSűռС*/ + UINT16* dsuSpksSecNumIndex; /*SPKSϢ*/ + + UINT16 GODSECNUMINDEXSIZE; /*űűռС*/ + UINT16* dsuGodSecNumIndex; /*Ϣ*/ + + UINT16 STASECNUMINDEXSIZE; /*վűռС add by slm 2019-1-15 */ + UINT16 *dsuStaSecNumIndex; /*վϢ*/ + + UINT16 PHYSECNUMINDEXSIZE; /*αűռС add by slm 2019-1-16*/ + UINT16 *dsuPhySecNumIndex; /*Ϣ*/ + + UINT16 AXLENUMINDEXSIZE; /*ϵͳűռС add by lq 2023-12-08*/ + UINT16* dsuAxleNumIndex; /*ϵͳϢ*/ + + UINT16 ITENUMINDEXSIZE; /*ITEűռС add by lq 2024-06-06*/ + UINT16* dsuIteNumIndex; /*ITEϢ*/ + +}DSU_IDMAP_INDEX_STRU; + +/*Ŷձܽṹ*/ +typedef struct DSU_IdmapStruct +{ + DSU_IDMAP_INDEX_STRU *dsuIdmapIndexStru; + + DSU_IDMAP_LEN_STRU *dsuIdmapLenStru; /*ȫֱ¼ȡDSUеĸݵ*/ + + DSU_STATIC_IDMAP_STRU *dsuStaticIdmapStru; /*ݿÿֽṹͷָ*/ +} DSU_IDMAP_STRU; + +/*ݿṹ*/ +extern DSU_IDMAP_STRU *g_dsuIdmapStru; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapVar.c b/TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapVar.c new file mode 100644 index 0000000..8443866 --- /dev/null +++ b/TSCP/src/dqu_common/dqu_idmap_common/dsuIdmapVar.c @@ -0,0 +1,107 @@ +/************************************************************************ +* +* ļ dsuIdmapVar.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2016.03.20 +* з +* dsu +* ʹע +* ޸ļ¼ +* +************************************************************************/ +#define IDMAP_VAR_DEFINE + +#include "dsuIdmapVar.h" +#include "dfsDataRead.h" + +DSU_IDMAP_STRU *g_dsuIdmapStru=NULL; + +static UINT16 g_dsuIdmapDataArrayLen[DFS_DATA_INDEX_NUM]={0};/*ڴ洢Ŷձиĸ*/ +static UINT16 g_dsuIdmapIndexArrayLen[DFS_DATA_INDEX_NUM]={0};/*ڴ洢Ŷձиĸ*/ + +/*ñŶձṹָ*/ +UINT8 dquSetInitIdmapRef(DSU_IDMAP_STRU *pDsuIdmapStru) +{ + UINT8 bRetVal=0U; + if (NULL!=pDsuIdmapStru) + { + g_dsuIdmapStru=pDsuIdmapStru; + bRetVal=1; + } + else + { + bRetVal=0U; + } + return bRetVal; +} + + + +/*ñŶձӦĸ*/ +UINT8 dquSetIdmapDataStruArrayLen(UINT16 wDataID, UINT16 wStruDataLen ) +{ + UINT8 bRetVal=0U; + if (wDataID +#endif /*End of ZCAPP_VXWORKS_CODECONTROL*/ + +#include "dsuIdmapStruct.h" + + +#ifdef IDMAP_VAR_DEFINE +#define EXTERN +#else +#define EXTERN extern +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /*ñŶձṹָ*/ + UINT8 dquSetInitIdmapRef(DSU_IDMAP_STRU *pDsuIdmapStru); + +/*½ӿںṩVOBCȼʹõڼԤڴǷ㹻FSļбŶձ*/ + + /*ñŶձӦĸ*/ + UINT8 dquSetIdmapDataStruArrayLen(UINT16 wDataID, UINT16 wStruDataLen); + + /*ñŶձжӦĸ*/ + UINT8 dquSetIdmapDataIndexArrayLen(UINT16 wDataID, UINT16 wDataIndexLen); + + /*ȡŶձӦĸ*/ + UINT8 dquGetIdmapDataStruArrayLen(UINT16 wDataID, UINT16 *pStruDataLen); + + /*ñŶձжӦĸ*/ + UINT8 dquGetIdmapDataIndexArrayLen(UINT16 wDataID, UINT16 *pDataIndexLen); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/main/2oo2/processor.h b/TSCP/src/main/2oo2/processor.h new file mode 100644 index 0000000..8c5b1e5 --- /dev/null +++ b/TSCP/src/main/2oo2/processor.h @@ -0,0 +1,844 @@ +/*************************************************************************************** +* 汾ţһV1.0 +* +* Ȩ (C) 2008 ͨѧ CBTCĿ 22ȡ2ȫ +* +* ߣϤ +* +* ļprocessor.h +* +* CBTCĿ22ȡ2ȫƽ̨ͷļ +* +* οĵ + ȫƽ̨ϸƣģӿڣ.doc + 22ȡ2ȫƽ̨ⲿӿĵ.doc + 22ȡ2ȫƽ̨Ҫơ.vsd + +* ʱ䣺2008-7-22 +* +* ޸ʷ +* 2008-07-22 Ϥ + ĵ + 2009-03-09 Ϥ + Э齫ӦݵijȸΪ4ֽڣݱȽϡʷݺ״̬ݵijȸΪ4ֽڡ + 2009-09-29 Ϥ + ׯߵض + 2009-10-27 Ϥ + NTPЭصĶ + 2009-10-27 Ϥ + άϢȺ궨M_PU_LEN + 2009-12-31 Ϥ + SFP_PROTOĺ궨 + 2010-01-05 ϣ + Input_processIJ޸ģɾRPRSRṹ + 2010-04-12 Ϥ + ˴ӡĺ + 2010-07-15 Ϥ + ޸˸άϵͳ֡ṹ + 2010-07-16 Ϥ + LEN_HIS60000Ϊ200000 + 2010-07-16 Ϥ + άάϢĺ + 2010-09-15 Խ + ˰汾ϢĺVERSION + 2014-01-20 + δ޸ǰLEUǴRSSPͨŵ + ޸֮󣺼FSFB2Э飬LEUǴFSFB2Эͨŵ + 2014-04-18 + δ޸ǰ1CIͨŶZCLEUȣͨ״̬ǷֿĵCIӦƽ̨Ĺȫֱ϶ + 2жϴڴ + ޸ĺ1CIͨŶZCLEUȣͨ״̬һͳһĽṹ + 2ٷͨ豸IDС + + 2014-04-22 + δ޸ǰLEUͨ״̬жϴڴ󣬲ӦóֻƵ + ޸ĺ: LEUͨ״ֻ̬Ƶƣ̵ֻƺͺ + +****************************************************************************************/ + +#ifndef _PROCESSOR_H_ +#define _PROCESSOR_H_ + +#include "sfpplatform.h" +#include "RsspWl.h" +#include "FsfbProtcl.h" +#include "protclInterFun.h" + +/*ͷļ*/ +#include "CommonQueue.h" +#include "RelayConfigDataManage.h" +/*#include "../comcontorler/serial/serialProcess.h"*/ + +#define LOCAL + +/*================= =========================================================*/ +/*#define ERROR_DEBUG*/ /*ӱԣdefine enable*/ + +/*ӡϢغ궨*/ + #undef DEBUG_PRINTF /*ӡ䣬define enable define ֮󲻴ӡ*/ + #define DEBUG_INFOR /*¼Ϣ */ + #define MAINTAIN_INFOR /*άϢ */ + #undef MAINTAIN_INFOR + #undef DEBUG_CODE /*ӡ */ + #define DEBUG_TEMP /*ʱԴӡ*/ + #undef DEBUG_TEMP + + +/*ǷҪ¼ʱ*/ + #undef ANALYS_TIME /*ʱϢ¼ֺʱdefine enable*/ + +/*ǷӦãö峬һ*/ + #undef ZC_APP /*ʵZCӦãdefine enable*/ + #undef ZC_SCADE /*ʵZCscade룬define enable*/ + #undef DSU_APP /*ʵDSUӦãdefine enable*/ + #undef SIM_DATA /*ģ⴦ݣdefine enable*/ + #define CI_SUPPORT /* ʵCIӦá*/ + +/*嶯̬źŷת*/ + #define PERIOD_REVERSE /*ÿŹڷת̬ź*/ + +/*Ƿftsmһ*/ + #define WITH_FTSM /*ftsmһԣdefine enable*/ + #undef SIM_FTSM /*ģftsm,ֻͨdefine enable*/ + #undef SIM_FTSM_ALL /*ģftsm,ͨdefine enable*/ + + +/*ǷЭһ*/ + #undef SIM_PROTO /*ģͨЭ*/ +/*ǷSFPЭһ*/ + #define SFP_PROTO /*SFPͨЭ*/ +/*ǷRSSPЭһ*/ + #define RSSP_PROTO /*RSSPͨЭ*/ +/*ǷFSFBЭһ*/ + #define FSFB_PROTO /* FSFB2ͨЭ*/ +/*ǷЭһ*/ + #undef RP_PROTO /*ͨЭ*/ +/*ǷNTPЭһ*/ + #undef NTP_PROTO /*NTPͨЭ*/ +/*ǷRSRЭһ*/ + #undef RSR_PROTO /*RSRͨЭ*/ + + + #define M_RESET_CC1 telecom_mode = telecom_mode & 0xAF;telecom_mode = telecom_mode | 0xA0 + #define M_RESET_CC2 telecom_mode = telecom_mode & 0xFA;telecom_mode = telecom_mode | 0x0A + +/*Эͷļ*/ + +#ifdef SFP_PROTO +#include "sfpplatform.h" /*ǰ棬*/ +#endif /*end #ifdef SFP_PROTO*/ + +#ifdef RP_PROTO +#include "APP/Prtcl/redun_cbtc/RpPlatform.h" +#endif /*end #ifdef RP_PROTO*/ + +#ifdef RSR_PROTO +#include "APP/Prtcl/rsr_cbtc/Rsr.h" +#endif /*end #ifdef RSR_PROTO*/ + +#ifdef RSSP_PROTO +#include "RsspWl.h" +#endif/*end #ifdef RSSP_PROTO*/ + +#ifdef FSFB_PROTO +/*#include "APP/Prtcl/PrtclFSFB/fsfb/FsfbProtcl.h"*/ +#endif/*end #ifdef FSFB_PROTO*/ +/*=====================궨==========================================================*/ + +/*汾غ*/ + #define VERSION 0x1000D915 + + #ifdef PERIOD_REVERSE + #define P_REV_TIME 60 /*תʱ*/ + #endif /*end #ifdef PERIOD_REVERSE*/ + + #define SEND_LEUQUERYFRAMES_INTERVAL 50 /*LEUѯ֡*/ + +/*崮غ*/ + #define TY_BOUNDRATE 38400 /*ڲ*/ + +/*ʱ*/ + #define CLKRATE 1024 + +/*ջ*/ + #define TASK_STACK_SIZE 8000000 + +/*غ궨*/ + #define D_PERIOD 0.05*sysClkRateGet() /*ڽڿʼʱֵޣ50*/ + + +/*ݻغ궨*/ + /*ƽ̨غ궨*/ + #define LEN_HIS 200000 /*ʷݳȽ5000Ϊ60000 edit by wx 09-3-9 */ + #define LEN_INPUT 60000 /*ݳȽ5000Ϊ60000 edit by wx 09-3-9 */ + #define LEN_OUTPUT 60000 /*ݳȽ5000Ϊ60000 edit by wx 09-3-9 */ + #define LEN_FTSMDATA 9 /*ftsmݳ*/ + #define LEN_DATAREQ 18 /*֡*/ + #define MAINTANCE 5 /*ά֡*/ + #define LEN_NTP 150 /*NTP֡*/ + + + /*ͨűͺ궨*/ + #define INPUT_CMP 0x4b /* ݱȽϱ */ + #define OUTPUT_CMP 0x8e /* ݱȽϱ */ + #define HISDATA 0x9c /* ʷݱ */ + #define DATAREQ 0xAA /* */ + #define DATAREQ_CAN_ZHENG 0xBB /* CAN */ + #define DATAREQ_CAN_FAN 0xDD /* CAN */ + #define OUTNETSEND 0x11 /* ݱ */ + #define FOLLOWDATA 0x33 /* ״̬ݱ */ + #define OUTNETSEND_CAN 0x22 /* CANݱ */ + #define COMSTART 0x17 /* ʼȡָ */ + + #define OUTNETRCV 0x17 /* ݱģǶݵͨ */ + #define SFPDATA 0x55 /* SFPͨЭ */ + #define REDUNDENTTA 0x05 /* ͨЭ */ + #define RSSPDATA 0x50 /* RSSPͨЭ */ + #define NTPDATA 0x09 /* NTPͨЭ */ + + #define IP_DATA 0x2b /*ͨظ͵IP ͡*/ + #define TYCO_DATA 0x44 /*ͨظ͵Ĵ ״̬͡*/ + #define SERIAL_DATA 0x20 /*ͨظ͵Ĵ */ + #define CAN_RCV 0x28 /*нCANݱ*/ + +/*ȼ*/ + #define PRI_APP 120 /*Ӧô*/ + +/*ͨģʽ*/ + + #define USINGMODE 0xA /*ģʽ*/ + #define PREPARINGMODE 0x5 /*ģʽ*/ + #define FOLLOWMODE 0x3 /*״̬ģʽ*/ + #define MAINTENANCE 0xC /*άģʽ*/ + #define POWERUPMODE 0x1 /*ϵģʽ*/ + #define POWEROFF 0xB /*ϵģʽ*/ + + /*FTSM͵궨*/ + + #define POWERUP_SYN 0x0D /*ʼͬɹ*/ + #define DATA_READ 0x19 /*ͨſȡݿʼ*/ + #define APPLY_START 0x07 /*Ӧôʼ*/ + #define OUT_CMP 0x15 /*ݱȽϿʼ*/ + + + /*ͨſģʽ*/ + + #define CC_POWER_UP 0x1 /*ϵģʽ*/ + #define CC_POWER_OFF 0xb /*ϵģʽ*/ + #define CC_MAINTENANCE 0xc /*άģʽ*/ + #define CC_INUSE 0x5 /*ģʽ 0x05->0x04*/ + #define CC_NOSTART 0x0 /*δʼ*/ + + /*ػ͵궨*/ + + #define SELFTEST_OK 0xFDAD /*Լɹ*/ + #define DATA_READ_END 0xFED6 /*ͨſȡݽ*/ + #define APPLY_END 0xFF5A /* ZC*/ + #define OUTCMP_END 0xFF9C /*ݽ*/ + + + /*ȴʱ*/ + #define INPUT_TIME 10 /* ͨſݵʱ */ + #define HISTORY_TIME 20 /* ͨȴʷݵʱ */ + + + /*ǷȵϢʷݱ־λ*/ + #define RECEIVED 0x55 /*Ѿյ*/ + #define UNRECVD 0xAA /*ûе*/ + + #define TWO 2 + #define FOUR 4 + +#ifdef CI_SUPPORT +#define MAX_IO_DEV_NUM (BOARD_SUM_MAX/2) + +typedef struct One_Can_Broad_Received_Data +{ + unsigned char data[5]; /*һcanܵ*/ +}struc_One_Can_Broad_Received_Data; + +typedef struct Can_Broad_Received_Last_Right_Data +{ + struc_One_Can_Broad_Received_Data data; /*һcanܵ*/ + unsigned long lastRightCycleNum; /*һθȷں*/ +}struc_Can_Broad_Received_Last_Right_Data; +#endif + +/* +*.ͨ豸״̬ +*/ + +#define ZC_STATUS_INDEX 0 +#define CI_STATUS_INDEX ZC_STATUS_INDEX + 1 +#define LEU_STATUS_INDEX CI_STATUS_INDEX + 1 + + +/* + * ֡ṹ壺ݱȽһ֡еĸ궨 + */ +#define INCMP_LEN 0 /*ݱȽһ֡ݳ*/ +#define INCMP_TYPE (INCMP_LEN + 2) /*ݱȽһ֡*/ +#define INCMP_TIME (INCMP_TYPE + 1) /*ݱȽһ֡еʱ*/ +#define INCMP_RANDAM (INCMP_TIME + 4) /*ݱȽһ֡е漴*/ +#define INCMP_CYCLE (INCMP_RANDAM + 4) /*ݱȽһ֡еں*/ +#define INCMP_DATA (INCMP_CYCLE + 4) /*ݱȽһ֡е*/ + + /* + * ֡ṹ壺->ͨſһ֡еĸ궨 + */ +#define DATAREQ_LEN 0 /*͵֡ݵֵ*/ +#define DATAREQ_TYPE (DATAREQ_LEN + 4) /*֡*/ +#define DATAREQ_ID (DATAREQ_TYPE + 1) /*֡ID*/ +#define DATAREQ_CYCLE (DATAREQ_ID + 1) /*֡еں*/ +#define DATAREQ_RED_IP (DATAREQ_CYCLE + 4) /*ͨſIPַ*/ +#define DATAREQ_BLUE_IP (DATAREQ_RED_IP + 4) /*ͨſIPַ*/ +#define DATAREQ_IP_TABLE_VERSION (DATAREQ_BLUE_IP + 4) /*汾*/ + +/* + * ֡ṹ壺ݱȽһ֡еĸ궨 + */ +#define OUTCMP_LEN 0 /*ݱȽһ֡ݳ*/ +#define OUTCMP_TYPE (OUTCMP_LEN + 4) /*ݱȽһ֡*/ +#define OUTCMP_DATA (OUTCMP_TYPE + 1) /*ݱȽһ֡е*/ + +/* + * ֡ṹ壺һ֡еĸ궨 + */ +#define OUTPUT_LEN 0 /*һ֡ݳ*/ +#define OUTPUT_TYPE (OUTPUT_LEN + 4) /*һ֡*/ +#define OUTPUT_DATA (OUTPUT_TYPE + 1) /*һ֡е*/ + + +/* + * ֡ṹ壺ʷһ֡еĸ궨 + */ +#define HIS_LEN 0 /*ʷһ֡ݳ*/ +#define HIS_TYPE (HIS_LEN + 4) /*ʷһ֡*/ +#define HIS_RANDAM (HIS_TYPE + 1) /*ʷһ֡е漴*/ +#define HIS_CYCLE (HIS_RANDAM + 4) /*ʷһ֡еں*/ +#define HIS_DATA (HIS_CYCLE + 4) /*ʷһ֡е*/ + + +/* + * ֡ṹ壺״̬һ֡еĸ궨 + */ +#define FOLLOW_LEN 0 /*״̬һ֡ݳ*/ +#define FOLLOW_TYPE (FOLLOW_LEN + 4) /*״̬һ֡*/ +#define FOLLOW_CYCLE (FOLLOW_TYPE + 1) /*״̬һ֡еں*/ +#define FOLLOW_CAN_REQ_CYCLE (FOLLOW_CYCLE + 4) /*״̬һ֡еcanں*/ +#define FOLLOW_RANDAM (FOLLOW_CAN_REQ_CYCLE + 4) /*״̬һ֡е漴*/ +#define FOLLOW_TIME (FOLLOW_RANDAM + 4) /*״̬ݱȽһ֡еʱ*/ + +/* +*ͨŹϢ +*/ +#define FOLLOW_ZC_RED_ERROR_COUNT ( FOLLOW_TIME+4) +#define FOLLOW_ZC_BLUE_ERROR_COUNT ( FOLLOW_ZC_RED_ERROR_COUNT+ZC_DEV_MAX*4) +#define FOLLOW_NEIGHBOURCI_RED_ERROR_COUNT (FOLLOW_ZC_BLUE_ERROR_COUNT + ZC_DEV_MAX*4) +#define FOLLOW_NEIGHBOURCI_BLUE_ERROR_COUNT (FOLLOW_NEIGHBOURCI_RED_ERROR_COUNT + NEIGHBOURCI_DEV_MAX * 4) +#define FOLLOW_LEU_ERROR_COUNT (FOLLOW_NEIGHBOURCI_BLUE_ERROR_COUNT+ NEIGHBOURCI_DEV_MAX * 4) + + + +#ifdef CI_SUPPORT +#define FOLLOW_CAN_SEND_SN (FOLLOW_LEU_ERROR_COUNT + LEU_TYCO_NUM*4) +#define FOLLOW_LAST_RIGHT_CAN_DATA (FOLLOW_CAN_SEND_SN + 1) +#define FOLLOW_DATA (FOLLOW_LAST_RIGHT_CAN_DATA + sizeof(struc_Can_Broad_Received_Last_Right_Data)*MAX_IO_DEV_NUM) /*״̬һ֡е*/ +#else +#define FOLLOW_DATA (FOLLOW_TIME + 4) /*״̬һ֡е*/ +#endif + + +/* + * ֡ṹ壺άһ֡еĸ궨 + */ +#define M_CYCLE 0 /*ں*/ +#define M_TIMESTAMP (M_CYCLE + 4) /*ʱ*/ +#define M_ERRORCODE (M_TIMESTAMP + 4) /**/ +#define M_P_MODE (M_ERRORCODE + 4) /*̿*/ +#define M_A_W_MODE (M_P_MODE + 1) /*ͨģʽ*/ +#define M_B_W_MODE (M_A_W_MODE + 1) /*һͨģʽ*/ +#define M_CC1_MODE (M_B_W_MODE + 1) /*ͨſ1ģʽ*/ +#define M_CC2_MODE (M_CC1_MODE + 1) /*ͨſ2ģʽ*/ +#define M_DATA_LEN (M_CC2_MODE + 1) /*άϢԭʼݳ*/ +#define M_DATA (M_DATA_LEN + 4) /*άϢԭʼݳ*/ + + + +/* + * ֡ṹ壺NTPеĸ궨 + */ +#define NTPOUT_LEN 0 /*NTPһ֡ݳ*/ +#define NTPOUT_DATA (NTPOUT_LEN + 2) /*NTpһ֡е*/ + +/* + * ֡ṹ壺ͨſ͸canݵ֡ṹ + */ +#define SENDTO_PU_CAN_LEN 0 /*canһ֡ݳ*/ +#define SENDTO_CAN_REAL_DRVDATA_LEN (SENDTO_PU_CAN_LEN + 2) /*屾͵CANݵij*/ +#define SENDTO_PU_CAN_FEEDBACK_LEN (SENDTO_CAN_REAL_DRVDATA_LEN + 2) /*زݳ*/ +#define SENDTO_PU_CAN_RECEIVE_LEN (SENDTO_PU_CAN_FEEDBACK_LEN + 2) /*ɼݳ*/ +#define SENDTO_PU_CAN_DATA (SENDTO_PU_CAN_RECEIVE_LEN + 2) /*can֡*/ + +/*Э*/ +#define PRTO_ONE_SUIT_DEST 0x55 /*1Ŀַ1ԴַЭ*/ +#define PRTO_MUTI_SUIT_DEST 0xaa /*nĿַnԴַЭ*/ +#define PRTO_TYCOM_SUIT_DEST 0x5a /*ݱ־*/ + +/*CIͨŵ豸غ궨*/ +#define ZC_DEV_MAX 1 /*ͨŵZCĿ*/ +#define NEIGHBOURCI_DEV_MAX 5 /*Ŀ*/ +#define LEU_DEV_MAX 16 /*ͨŵLEUĿ*/ +#define COM_DEV_MAX 18 /*ͨŵĵһ豸*/ +#define COM_DEV_TYPE_SUM 16 /*ͨŵ豸*/ +#define INIT_DEV_TYPE 0 /*豸ͨ״̬ṹͳԱֵΪ0*/ +#define BOARD_SUM_MAX 240 /*һվɼĿֵ*/ +/*==========================ݽṹ==============================================*/ + + +/*뵱ǰ豸ͨŵ豸ṹ*/ +typedef struct CommunicationDevInfo +{ + UINT8 DeviceID; /*豸ID*/ + UINT8 DeviceType; /*豸*/ + UINT32 DeviceRedIP; /*豸IP*/ + UINT32 DeviceBlueIP; /*豸IP*/ +}CommunicationDevInfoStruct; + + +/*뵱ǰCI豸ͨŵ豸ͨ״̬ṹ*/ +typedef struct CommunicationDevStatus +{ + UINT8 DeviceIdCiLocal; /*ID*/ + UINT8 DeviceTypeOther; /*Է豸*/ + UINT8 ComDevSum; /*豸*/ + UINT8 ComDevIdBuf[COM_DEV_MAX]; /*豸*/ + UINT8 ComDevIdComStatusBuf[COM_DEV_MAX]; /*豸ͨ״̬*/ +}CommunicationDevStatusStruct; + +/*=============================================================================*/ + +#if 0 + +/* ܣݴftsmյģʽ±ͨģʽ + mode_manage + ڲ յģʽͷָ unsigned char* mode_rcv + ֵ unsigned char result 0x55³ɹ0xAAʧ + ʹõȫֱ ޸ processor_mode ģʽ + ޸ telemode_mode ͨſģʽ + ޸ ftsm_rcv յftsmݵк + ޸ soft_code */ +unsigned char mode_manage( unsigned char* mode_rcv ); + + +/* ܣɳʼϵͨ״̬ + state_follow + ڲ void + ֵ void + ʹõȫֱ + ޸ TimeStamp ʱ + ޸ CycleNum ں + ޸ Proto_Info.RadamSN */ +void state_follow( void ); + + +/* ܣ ˫ݽб + DataCompare + ڲ unsigned char *DataLocalunsigned char *DataOther + ֵ unsigned char result + 0x55ɹ + 0xAAʧ + 0x5A(CC1)ɹݱʧ + 0xA5(CC2)ɹݱʧ + ʹõȫֱ + ޸ TimeStamp ʱ + ޸ CycleNum ں + ޸ RadamSN + ִдFOREVER + ִϢerrorMsgQIdϢ + ˵Ӧȫɲϵͳ*/ +unsigned char DataCompare( unsigned char *DataLocal,unsigned char *DataOther ); + + +/* ܣӦعģ飬 + apply + ڲ void + ֵ void + ʹõȫֱ in mode_current ǰģʽ + in TimeStamp ʱ + in wd_period_timing ڶʱŹID + in,out CycleNum ں + in,out RadamSN + ִдFOREVER + ִյftsmͬϢ󣬿ʼִС*/ +void apply( void ); /*task of apply*/ + + +/* ܣά + maintenance + ڲ void + ֵ void + ʹõȫֱ + ˵Ӧάapplyá δʵ*/ +void maintenance( void ); + + +/* ܣ롣ĴϢ֡õݴԪʶĽṹ͡ + make_mode + ڲ Ҫ͵ unsigned short soft_code, + Ҫ͵Ϣ֡ͷָ unsigned char * msg + ֵ void + ʹõȫֱ + ޸ Ftsm_snd ftsm͵к + ִдÿεִһ + ߣ processor + maintenance ά + state_follow ״̬溯 + apply Ӧô + work */ +void make_mode ( unsigned short soft_code, unsigned char * msg ); + + +/* ܣݱȽϵĽȽϳɹдЭ֮С + Input_process + ڲ Ƚϳɹͷָ unsgined char *cmpdata, + ݱȽϵ״̬ unsgined char cmp_status + ֵ unsigned char result + 0x55ɹ0xAAʧ + ʹõȫֱ + ޸ Proto_Info ͨЭȫֽṹ + ִдÿεִһ + ߣ + work */ + +unsigned char Input_process(unsigned char * cmpdata, unsigned char cmp_status, struc_Unify_Info* struc_Unify, unsigned char* NTP_Input); + + + + +/* ܣʱ + InterISR + ڲ void + ֵ void + ʹõȫֱ ޸ TimeStamp ʱ + ִдÿθʱжִһ + ߣ ʱӶʱж + ú */ +void InterISR( void ); + + +/* ܣӦô + work + ڲ void + ֵ void + ʹõȫֱ + ޸ TimeStamp ͨʱ + ޸ CycleNum ں + ޸ Proto_Info ͨЭṹ + ޸ soft_code + ޸ Ftsm_snd ftsm͵к + ޸ ftsm_rcv յftsmݵк + ִдÿεִһ + ߣ apply Ӧô*/ +void work(unsigned char com_status); + + + +/* + : history_handler() + : ݵǰͨ״̬ʷݽд + : + Эͷָ unsigned char* out_data + Ӧõȫͷָ unsigned char* app_data ûмЭʱԼ + : + unsigned char result 0x55ʷݴɹ0xAAʷݷʧܻûյʷݣ + 0xFFͨʷϢͨһ + ʹõȫֱ + οTimeStamp + CycleNum*/ +unsigned char history_handler( unsigned char* out_data,unsigned char* app_data ); + + +/************************************************************************************ +* : Innet_Read() +* : ĶжӦ͵ +* : +* ݵĶͷָ QueueStruct *innet_queue +* Ŷݵͷָ UCHAR* out_data +* Ҫȡ UCHAR data_type +* Դ UCHAR source_type 0ftsm, 1ͨŶ +* ֵ: +* 0x55ɹ +* 0xAAʧ +*************************************************************************************/ +unsigned char Innet_Read( QueueStruct *innet_queue,unsigned char* out_data, unsigned char data_type, unsigned char source_type); + + +/* ܣת̬ź + dynamic_reverse + ڲ void + ֵ void + ʹõȫֱ + ִдÿεִһ + ߣ apply Ӧô + period_reverse ̬źڷת + ú */ +void dynamic_reverse( void ); + +/* ܣʼ + Serial_initialize + ڲ void + ֵ OK or ERROR + ʹõȫֱ + ִдÿεִһ + ߣ processor ʼ + ú */ +STATUS Serial_initialize (void); + +/* ܣȡBIOSʱ + biostime + ڲ void + ֵ time_t BIOSϵͳʱ + ʹõȫֱ + ִдÿϵִһ + ߣ processor ʼ + ú */ +time_t biostime(void); + +/* ܣԵĵö̬źŷת + biostime + ڲ void + ֵ time_t BIOSϵͳʱ + ʹõȫֱ + ִдÿζʱжִһ + ߣ ʱжʱϵͳ ʼ + ú dynamic_reverse*/ +#ifdef PERIOD_REVERSE +void period_reverse( void ); +#endif + +#ifdef MAINTAIN_INFOR +void send_MU( unsigned long error_code,unsigned char p_mode,unsigned long data_len,unsigned char* MU_data ); +#endif + +#ifdef SIM_FTSM_ALL +void sim_mode( unsigned char soft_code, unsigned char pro_mode, unsigned char tel_mode,QueueStruct *queue); +#endif + + +#ifdef CI_SUPPORT +/************************************************************************************ + * setSpecialBitToZero + * ܣ4unsigned charԪأбȽϣһ£򽫲һ + * bitΪ0 + * unsigned char *pRedNetCanBuf; źcanݵ顣 + * unsigned char *pBlueNetCanBuf; canݵ顣 + * + * ֵ void + * + * **********************************************************************************/ +void setSpecialBitToZero(unsigned char *pRedNetCanBuf, unsigned char *pBlueNetCanBuf); + +/************************************************************************************ + * getFsioIndexOfCollFsioIDs + * ܣõsystemOneCollFsioIDssystemTwoCollFsioIDsжӦ忨id± + * unsigned char fsioCardId; Ҫҵİ忨id + * + * ֵ int systemOneCollFsioIDssystemTwoCollFsioIDsжӦ忨id± + * + * **********************************************************************************/ + +int getFsioIndexOfCollFsioIDs (unsigned char fsioCardId); + +/************************************************************************************ + * getSystemNumOfDriveFsio + * ܣfsio忨idõfsio忨һϵFISO + * unsigned char fsioCardId; Ҫҵİ忨id + * + * ֵ int 忨ڵϵ + * + * **********************************************************************************/ + +int getSystemNumOfDriveFsio (unsigned char fsioCardId); + +/************************************************************************************ + * verifyCanData + * ܣ֤canǷûгģΪȷݣģΪ㡣 + * unsigned char *pCanBuf; źcanݵ顣 + * unsigned short canDataLen;canBufijȡ + * ֵ Уݵijȡ + * + * **********************************************************************************/ +unsigned short verifyCanData(unsigned char *pCanBuf, unsigned short canDataLen); + +/************************************************************************************ + * mergeCanData + * ܣϲȽϺݡ + * unsigned char *pRedNetCanBuf; źcanݵ顣 + * unsigned short redNetCanLen; canݵʵʳȡ + * unsigned char *pBlueNetCanBuf; canݵ顣 + * unsigned short blueNetCanLen; canݵʵʳȡ + * + * unsigned char *pMergeBuf; ϲcanݵ顣 + * ֵ unsigned short; ϲݵʵʳȡ + * + * **********************************************************************************/ +unsigned short mergeCanData(unsigned char *pRedNetCanBuf, unsigned short redNetCanLen, unsigned char *pBlueNetCanBuf, unsigned short blueNetCanLen, unsigned char *pMergeBuf); + +/************************************************************************************ + * packFsioDriveData + * ܣFsioݽд + * + * ֵ + * + ************************************************************************************/ +void packFsioDriveData(void); + + +/************************************************************************************ + * checkIsCanDataReachMaxErrorTimes + * ܣ鿴忨ݴǷ񵽴 + * unsigned char fsioIndexOfFsioIDs systemOneCollFsioIDssystemTwoCollFsioIDsжӦ忨id± + * + * ֵ int 忨ݴǷ񵽴 1Ϊﵽ0Ϊûдﵽ + * + * **********************************************************************************/ +unsigned int checkIsCanDataReachMaxErrorTimes(unsigned int fsioIndexOfFsioIDs ); +/*void displayLastRightCanData(void);*/ + + +#endif +/************************************************************************** +* : checkCycleTime +* : ͨڵƽ̨ʱ +* ڲ: void +* ֵ: 0x55Уͨ0xAAУʧ +***************************************************************************/ +LOCAL unsigned char checkCycleTime(void); + +/************************************************************************** +* : checkCycleTimeOfChannel +* : жʵǷʱ +* ڲ: unsigned char loaclOverTimeFlag , Ƿʱʶ + unsigned char otherOverTimeFlagͨһǷʱʶ +* ֵ: 0x55Уͨ0xAAУʧ +***************************************************************************/ +LOCAL unsigned char checkCycleTimeOfChannel(unsigned char loaclOverTimeFlag ,unsigned char otherOverTimeFlag ); +LOCAL void checkLightLoopIDFault(unsigned char lightLoopID); + +/************************************************************************** +* : checkZCStatus +* : CIZCͨ״̬ +* ڲ: void +* ֵ: void +***************************************************************************/ +LOCAL void checkZCStatus(void); + +/************************************************************************** +* : checkLeuStatus +* : CIleuͨ״̬ +* ڲ: void +* ֵ: void +***************************************************************************/ +LOCAL void checkLeuStatus(void); + + +/************************************************************************** +* : checkCIStatus +* : CIͨ״̬ +* ڲ: void +* ֵ: void +***************************************************************************/ +LOCAL void checkCIStatus(void); + +/************************************************************************** +* : checkFsioStatus +* : CIFSIOͨ״̬ +* ڲ: void +* ֵ: void +***************************************************************************/ +LOCAL void checkFsioStatus(void); + +/**============================================================================= + + protoTypeProcess + ܣЭеЭƬνЭ + ڲ unsigned char* pDest Эŵַ + unsigned char* pFrom ԭʼЭ飨жЭƬ + unsigned long protoSize ԭʼЭ鳤 + unsigned char protoType ЭͣPRTO_MUTI_SUIT_DESTPRTO_ONE_SUIT_DEST + ֵ unsigned long result Э鳤 +==============================================================================*/ + +unsigned long protoTypeProcess(unsigned char* pDest,unsigned char* pFrom,unsigned long protoSize , unsigned char protoType); + +/**============================================================================== + deviceIDToLogicalID + ܣ豸IDӳ߼ID + ڲ appArray:LEUݻ + ֵ STATUS :ɹOK,ʧܷERROR +===============================================================================*/ +STATUS deviceIDToLogicalID(UINT8 * appArray); + + + +/**============================================================================== + logicalIDToDeviceID + ܣ߼ID ӳ豸ID + ڲ outputQueueA :ݶ(:յCC1ӵLEUݶ) + outputQueueB :ݶ(:յCC2ӵLEUݶ) + ֵ STATUS :ɹOK,ʧܷERROR +===============================================================================*/ +STATUS logicalIDToDeviceID(QueueStruct * outputQueueA,QueueStruct * outputQueueB); + +/**============================================================================== + combineLeuQueryFrames + ܣLEUѯ֡ + ڲ outputQueue :豸м:LEUݶ) + ֵ STATUS :ɹOK,ʧܷERROR +===============================================================================*/ +STATUS combineLeuQueryFrames(QueueStruct * outputQueue); + + +/**============================================================================== + sortDevID + ܣ豸ID + ڲ 豸ID + ֵ +===============================================================================*/ +void sortDevID(UINT8 devSum,UINT8 * devIdBuf); + +/*=============================== ⲿ ===========================================*/ +#endif + + +#ifdef __cplusplus +extern "C" { +#endif +#if 0 +extern struc_Unify_Info Proto_Info; /*SFP */ +extern RSSP_INFO_STRU Rssp_Info; /*RSSPͨЭṹ*/ +#else +extern ProtclConfigInfoStru gCbtcData; +#endif +extern FSFB_INFO_STRU Fsfb_Info; /*FSFBͨЭṹ*/ +extern QueueStruct canQueueRecv; /*IOCIݶ */ +extern QueueStruct canQueueSend; /*CIIOݶ */ +extern UINT32 CycleNum; /*ƽ̨ں*/ +extern UINT8 Computer_Id_Local_File; /*ƽ̨ID*/ +extern UINT8 processor_mode; /*ƽ̨ģʽ*/ +extern UINT8 FSIOLinkStatusInfo; /*FSIO֮״̬*/ +extern UINT8 LEULinkStatusInfo; /*LEUͨ״̬*/ +extern UINT8 ZCLinkStatusInfo; /*ZCͨ״̬*/ +extern CommunicationDevStatusStruct ComDevStatusInfo[COM_DEV_TYPE_SUM]; /*ͨ״̬ṹ*/ +extern UINT8 gSheBeiType; /*豸*/ +extern UINT8 gSheBeiID; /*豸ID*/ +extern UINT8 LocalCiId; /*ϵͳļжID*/ +extern QueueStruct logPrintfQue; /*־ݶ */ + +void InitCommDevStatus(); +#ifdef __cplusplus +}; +#endif + +#endif /*ifndef _PROCESSOR_H_*/ diff --git a/TSCP/src/main/2oo2/simulation2oo2.c b/TSCP/src/main/2oo2/simulation2oo2.c new file mode 100644 index 0000000..b75ef27 --- /dev/null +++ b/TSCP/src/main/2oo2/simulation2oo2.c @@ -0,0 +1,59 @@ +#include "protclInterFun.h" +#include "FsfbProtcl.h" +#include ".\processor.h" + +#if 0 +struc_Unify_Info Proto_Info; /*SFP */ +RSSP_INFO_STRU Rssp_Info; /*RSSPͨЭṹ*/ +#else +ProtclConfigInfoStru gCbtcData; +#endif + +FSFB_INFO_STRU Fsfb_Info; /*FSFBͨЭṹ*/ +QueueStruct canQueueRecv; /*IOCIݶ */ +QueueStruct canQueueSend; /*CIIOݶ */ +UINT32 CycleNum; /*ƽ̨ں*/ +UINT8 Computer_Id_Local_File; /*ƽ̨ID*/ +UINT8 processor_mode; /*ƽ̨ģʽ*/ +UINT8 FSIOLinkStatusInfo; /*FSIO֮״̬*/ +UINT8 LEULinkStatusInfo; /*LEUͨ״̬*/ +UINT8 ZCLinkStatusInfo; /*ZCͨ״̬*/ +CommunicationDevStatusStruct ComDevStatusInfo[COM_DEV_TYPE_SUM]; /*ͨ״̬ṹ*/ +UINT8 gSheBeiType; /*豸*/ +UINT8 gSheBeiID; /*豸ID*/ +UINT8 LocalCiId; /*ϵͳļжID*/ +QueueStruct logPrintfQue; /*־ݶ */ + + +/* + * ʼͨ״̬ĬΪOK + */ +void InitCommDevStatus() +{ + extern TransmitRelationDataStruct TransmitRelaDataStru[TRANSMIT_OBJECT_SUM_MAX]; + extern UINT16 TransmitRelaDataCurSum; + UINT16 ii =0,jj =0; + + FSIOLinkStatusInfo = TRANSMIT_2OO2_STATE_GOOD; + /*LEUZCCIȵͨ״̬*/ + if (TransmitRelaDataCurSum < TRANSMIT_OBJECT_SUM_MAX) + { + for (ii = 0; ii < TRANSMIT_OBJECT_SUM_MAX; ii++) + { + ComDevStatusInfo[ii].DeviceTypeOther = TransmitRelaDataStru[ii].SystemType; + ComDevStatusInfo[ii].ComDevSum = TransmitRelaDataStru[ii].DeviceSum; + for (jj = 0; jj < TransmitRelaDataStru[ii].DeviceSum; jj++) + { + ComDevStatusInfo[ii].ComDevIdBuf[jj] = TransmitRelaDataStru[ii].DeviceIdBuf[jj]; + ComDevStatusInfo[ii].ComDevIdComStatusBuf[jj] = TRANSMIT_2OO2_STATE_GOOD; + } + } + + } + else + { + + } +} + + diff --git a/TSCP/src/main/2oo2/vxWorks.h b/TSCP/src/main/2oo2/vxWorks.h new file mode 100644 index 0000000..bb735fc --- /dev/null +++ b/TSCP/src/main/2oo2/vxWorks.h @@ -0,0 +1,16 @@ + +#ifndef _VXWORKS_H_ +#define _VXWORKS_H_ + +#undef STATUS +#define STATUS int + +#undef OK +#define OK 0 + +#undef ERROR +#define ERROR 1 + +#endif + + diff --git a/TSCP/src/main/CiSimulation.cpp b/TSCP/src/main/CiSimulation.cpp new file mode 100644 index 0000000..00936a2 --- /dev/null +++ b/TSCP/src/main/CiSimulation.cpp @@ -0,0 +1,5319 @@ + +#include +#include ".\\ccov\\ccov.h" +#include ".\\ini\\ReadCcovConfigInfo.h" +#include ".\\2oo2\\processor.h" +#include +#include "stdio.h" +#include "RecordClass.h" +#include "dquCIInterFace.h" +#include ".\\DeviceInfoManager\\readxmltodata.h" +#include "dsuProtclFun.h" +#include "dsuFsfbFunc.h" +#include +#include "dquCIInit.h" +#include "SystemParameterManage.h" +#include "MMSystem.h" +#include "malloc.h" + + + +#include "2oo2DataTransferManage.h"/*SetCiAppDataҲʶ*/ +#include "CiSimulation.h" +#include ".\\SimDef\SimDef.h" +#include ".\\ccov\Ccov_RsspII.h" +#include "2oo2\vxWorks.h" + +extern DeviceIpInfoStru gDeviceIpInfoArray[500]; +extern DeviceIpInfoStru gDeviceIpInfoArrayATS[200]; +extern UINT16 gDeviceNum ;//豸Ŀ +extern UINT16 gDeviceNumAts;//ATSCIļ豸Ŀ +#pragma comment(lib,"winmm.lib") +#pragma comment(lib,"ws2_32.lib") + + +/*xmlļһ豸UDPЭ飬Ӧͨſ +*blueCcov[0] sfp;blueCcov[1] rp;blueCcov[2] rssp/rsr +*/ +typedef struct +{ + UINT16 deviceName; + CbtcCcomm blueCcov[PRTL_UDP_CNT]; + CbtcCcomm redCcov[PRTL_UDP_CNT]; + Ccov_RsspII rssp2BlueCcov; + Ccov_RsspII rssp2RedCcov; + LeuCcomm blueCCov; + LeuCcomm redCCov; + UINT8 ciInAts;/*ciATSͨŶ󣬱ʶCIǷATS*/ + UINT8 xdInAts;/*ʶCIֵصͨŷʽΪ1ͨASTIPͨţԭʼʽͨš˱־CIATSʱЧ*/ + UINT8 OcInCi;/* CIOCǷ */ + CbtcCcomm atsBlueCcov[PRTL_UDP_CNT]; + CbtcCcomm atsRedCcov[PRTL_UDP_CNT]; + CbtcCcomm ocBlueCcov; + CbtcCcomm ocRedCcov; + +}LocalDevInfoCcov; + +typedef struct +{ + UINT16 deviceName; + +}LocalDevInfoCcov_TcpSer; + +/*ȫͨŰַϵṹ*/ +typedef struct S_Safe_CommBoard_AddrStruct +{ + UINT16 belongCiId; /* ID */ + UINT16 safeCommBoardCount; /* ȫͨŵԪĿ */ + +} Safe_CommBoard_AddrStruct; + + /*ȫͨŰͨŹϵṹ*/ +Safe_CommBoard_AddrStruct safeCommBord[CI_SUM_MAX]; +LocalDevInfoCcov localCcov; +const UINT8 protclTypeList[] = {DSU_PROTCL_SFP,DSU_PROTCL_RP,DSU_PROTCL_RSSP}; /* blueCcov redCcov ±һ*/ +CComm ioCcov; +CComm logCcov; +CComm fsfbCcov; +CComm extenACcov; +CComm extenBCcov; +CComm extenCCcov; +CComm wxCcov; +stdext::hash_map ccovList; +UINT8 tmpIoBuff[1024]; +UINT8 tmpSnd2WxBuff[1024*4]; +UINT16 tmpSnd2WxLen = 0; +UINT16 tmpIoLen = 0; +QueueStruct extenARcvQue; +QueueStruct extenBRcvQue; +QueueStruct extenCRcvQue; +QueueStruct extenASndQue; +QueueStruct extenBSndQue; +QueueStruct extenCSndQue; + +extern "C" QueueStruct* ZcToCiDataQueue; /*ZCCIݶ*/ +extern "C" QueueStruct* CiToZcDataQueue; /*CIZcݶ*/ + +extern "C" QueueStruct* VobcToCiDataQueue; /*VobcCIݶ*/ +extern "C" QueueStruct* CiToVobcDataQueue; /*CIVobcݶ*/ +extern "C" QueueStruct* CiRecvFromCiDataQueue; /*CICIݶ*/ +extern "C" QueueStruct* CiSendToCiDataQueue; /*CI͵CIݶ*/ +IpConfigInfoStru *wxIpconfigInfo = NULL; +IpConfigInfoStru *ioIpconfigInfo = NULL; +IpConfigInfoStru *extenAIpconfigInfo = NULL; +IpConfigInfoStru *extenBIpconfigInfo = NULL; +IpConfigInfoStru *extenCIpconfigInfo = NULL; +extern UINT8 LocalCiId; +UINT8 qjLogSaveTime = 0U;/*־ɾʱ*/ +RecordLogClass *CiLog = new RecordLogClass(1); +unsigned long gPeriodThreadFlg; +HANDLE gPeriodThread; +/*-----------------------------* +private method +*-----------------------------*/ +UINT8 InitCcov(const CHAR * fileName); +UINT8 InitCcovNew(UINT16 DevName,const CHAR * fileName); +UINT8 InitCiAtsCom(UINT16 DevName,const CHAR * fileName); +UINT8 InitPrtcl(UINT8 * fileName); +/*UINT8 ReadLocalCiId(void);*/ +void PeriodProcess(void); +void HandleCiApp(void); +UINT8 RcvDataFromSignalNet(QueueStruct *pQue,CComm *ccov); +UINT8 RcvDataFromSignalNetNoLen(QueueStruct *pQue,CComm *ccov); +static void RcvDataFromRssp2Ccov(QueueStruct *pQue,Ccov_RsspII *rssp2Ccov); +UINT8 SndData2SignalNet(UINT32 ip,UINT16 port,const UINT8 *pData,UINT16 len,CComm *ccov); +void SndRsspOrFsfbData(UINT8 *spfbSndDataBuff); +void SndIoData(void); +void SndExtenCData(QueueStruct *pSndQue,CComm *pSndCcov,IpConfigInfoStru *pIpConfig); +void SndSfpData(UINT8 *sfpSndDataBuff); +UINT16 RedSndUnPack(UINT8 *sfpBuff,UINT8 *sndBuff,UINT32 *index,UINT32 totalLen, + UINT32 *redIpA,UINT16 *redPortA, + UINT32 *redIpB,UINT16 *redPortB); +void SndCbtcPrtcl(UINT8 *spfbSndDataBuff); + +UINT16 RedSndUnPack(UINT8 *sfpBuff,UINT8 *sndBuff,UINT32 *index,UINT32 totalLen, + UINT32 *redIpA,UINT16 *redPortA, + UINT32 *redIpB,UINT16 *redPortB,CComm **pCcov); + +void SndCbtcPrtclByDevName(UINT8 *spfbSndDataBuff); +void SndFsfbPrtclByDevName(UINT8 *fsfbSndDataBuff); +UINT16 RedSndUnPackNew(UINT8 *sfpBuff,UINT8 *sndBuff,UINT32 *index,UINT32 totalLen,UINT16 *DevName, UINT16 *LogicId, UINT8 *prtclType); +UINT16 RedSndUnPackNewFSFB(UINT8 *fsfbBuff,UINT8 *sndBuff,UINT32 *index,UINT32 totalLen,UINT16 *DevName); +UINT8 GetOtherStepFlag();/*ȡԷ־*/ +void ConvertUit32Ip2IpStrFormat(UINT32 ip,CHAR *ipStr);/**/ +void __stdcall TimePeriod(HWND, UINT, UINT_PTR, DWORD); +extern "C" void SndData2Wx(UINT8 msgType,const UINT8 * dataBuff,UINT32 dataLen); +extern "C" void debug_out_array(UINT8 mode, UINT8* debug_array, UINT16 len); +extern "C" void DarkInfoPack(UINT16 mode, UINT8* debug_array, UINT16 len); +extern "C" INT8 debug_out_array_for_lw_and_ats(char mode, char* debug_array, short len); +extern "C" void debug_infor_printf( + char* debug_string, /*ʵCеprintfĹ,ƽ̨ĵӡ*/ + ...); + +UINT8 GetOtherLiveFlag();/*ȡԷ־*/ +UINT8 GetLiveFlag(UINT8 machiId);/*ȡԷ־*/ +void WaitStep(UINT8 step); +UINT8 IoCompare(); +UINT8 AppCompare(); +UINT8 InitCiOcCom(UINT16 DevName, const CHAR * fileName); + +/*-----------------------------* +CONST define +*-----------------------------*/ +//#define SCADE_MODE +#ifdef SCADE_MODE +UINT8 LOCAL_IDX = 1; +UINT8 OTHER_IDX = 0; +#else +UINT8 LOCAL_IDX = 0; +UINT8 OTHER_IDX = 1; +#endif +UINT8 localMainStandBy = 0xFF; /* 0x55״̬ 0xAA: ״̬:δ֪*/ +#define MAIN_FLAG 0x55 +#define STAND_BY_FLAG 0xAA +#define LIVE_ON 0x55 +#define FOLLOW_STATUS 0xAA + +#define STEP_START 0 +#define STEP_INPUT 1 +#define STEP_APP 2 +#define STEP_OUTPUT 3 +#define STEP_END 0xff/*Ƚʧ쳣־*/ + +#define BUF_SIZE (1024*50) /*1024*50*/ +#define MSG_STATUS_LEN BUF_SIZE*40 /* 20ֽڣCIӦ״̬泤*/ + +#define CI_NONE_SEND_APP_DATA_WL 4 /* RSSPЭ޷Ӧ */ + +const CHAR IP_CONFIG_PATH[] = ".\\Config\\IPConfig.ini"; +const UINT8 FS_CONFIG_PATH[] = ".\\RCI.FS"; +char DQU_FS_CONFIG_PATH_CI[] = ".\\RCI.FS"; +/*xmlļ·*/ +const UINT8 DEVICE_IP_INFO_PATH[] = ".\\Config\\DevIpConfig.xml"; +const CHAR LEU_DEVICE_IP_INFO_PATH[] = ".\\Config\\LEUCICFG.xml"; +const UINT8 CI_ATS_CFG_PATH[] = ".\\Config\\ciAtsCfg.xml"; +const UINT8 CI_OC_CFG_PATA[] = ".\\Config\\CiOcLocalIdCfg.xml"; +const UINT32 PERIOND_TIME = 300; +UINT32 Snd2WxDataLen = 0; +UINT8 Snd2WxDataBuff[5000]; +UINT8 sndBuff[1024*20]; /* ݻ */ + +UINT16 deviceName = 0; +UINT8 protocolType = 0; +IpInfo pIpInfo[]; +UINT8 num = 0; +UINT16 gSheBeiName; /*豸ƣ+ID,20150427*/ +UINT8 tmpStatusBuff[MSG_STATUS_LEN-20] = {0}; +UINT8 tmpMemoryBuff[BUF_SIZE]; + +UINT8 distributedIOEnable = DISTRIBUTED_IO_NO; /*Ƿ÷ֲʽIOʶ*/ +UINT16 gSafeCommUnitCount = 0; /*ȫͨŰ*/ + +int systemOneDriverFsioCount =0; /*1ϵFSIOĿ*/ +int systemOneCollFsioCount =0; /*1ϵɼFSIOĿ*/ +int systemTwoDriverFsioCount =0; /*2ϵFSIOĿ*/ +int systemTwoCollFsioCount =0; /*2ϵɼFSIOĿ*/ + +unsigned char systemOneDriverFsioIDs[MAX_IO_DEV_NUM] = {0}; /*1ϵFSIOIDб*/ +unsigned char systemOneCollFsioIDs[MAX_IO_DEV_NUM] = {0}; /*1ϵɼFSIOIDб*/ +unsigned char systemTwoDriverFsioIDs[MAX_IO_DEV_NUM] = {0}; /*2ϵFSIOIDб*/ +unsigned char systemTwoCollFsioIDs[MAX_IO_DEV_NUM] = {0}; /*2ϵɼFSIOIDб*/ + +/*IpַͶ˿ںϢݳȺ*/ +UINT32 ipInfoStruLen; + +DSU_FSFB_IP_INFO_STRU *ipInfoStru = NULL; + /*===============================================*/ +DSU_ATS_NET_IP_INFO_STRU DsuAtsNetIpInfoStru; +DSU_GATEWAY_INFO_STRU_COPY * pDsuGateWayInfoStru; +UINT32 GatewayInfoLen=0; /*ƫ*/ + + +IpInfoStr * ReadIpInfoFromIni(char *strTree,const CHAR *iniFileName); + +/*====================================================*/ +extern "C" +{ + LARGE_INTEGER Time_StartPoint; /*ʱ,¼Э鿪ʱ*/ +} + + +#define MAX_MAIN_STANDBY_NUM 101 + +typedef struct +{ + /**/ + HANDLE SHareMemoryMsgOutput[MAX_MAIN_STANDBY_NUM]; /* Э,Ԥ */ + void *AddressMemoryMsgOutput[MAX_MAIN_STANDBY_NUM]; /* ڴ湲*/ + + HANDLE SHareMemoryIoOutputLen[MAX_MAIN_STANDBY_NUM]; /* IO */ + void *AddressMemoryIoOutputMsg[MAX_MAIN_STANDBY_NUM]; /* IO */ + + HANDLE SHareMemoryPrtclOutputMsgLen[MAX_MAIN_STANDBY_NUM]; /* Э */ + void *AddressMemoryPrtclOutputMsg[MAX_MAIN_STANDBY_NUM]; /* Э */ + + HANDLE SHareMemoryExtendAMsgLen[MAX_MAIN_STANDBY_NUM]; /* Ϣ Ԥ */ + void *AddressMemoryExtendAMsgLenFlag[MAX_MAIN_STANDBY_NUM]; /* Ϣȱ־λ Ԥ */ + + HANDLE SHareMemoryExtendBMsgLen[MAX_MAIN_STANDBY_NUM]; /* Ϣ Ԥ*/ + void *AddressMemoryExtendBMsgLenFlag[MAX_MAIN_STANDBY_NUM]; /* Ϣȱ־λ Ԥ*/ + + HANDLE SHareMemoryExtendCMsgLen[MAX_MAIN_STANDBY_NUM]; /* Ϣ Ԥ*/ + void *AddressMemoryExtendCMsgLenFlag[MAX_MAIN_STANDBY_NUM]; /* Ϣȱ־λ Ԥ */ + + /* CI״̬ */ + HANDLE SHareMemoryStatusMsgLen[MAX_MAIN_STANDBY_NUM]; /* ״̬Ϣ */ + void *AddressMemoryStatusMsg[MAX_MAIN_STANDBY_NUM]; /* ״̬(GetCiAppData )*/ + + /*ϵͬ־λڴ*/ + HANDLE SHareMemorySystemStep[MAX_MAIN_STANDBY_NUM]; /* ϵͬ־λڴ,Step */ + void *AddressMemorySystemStepFlag[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + /*ϵڼڴ*/ + HANDLE SHareMemoryCiCycle[MAX_MAIN_STANDBY_NUM]; /* ڼڴ */ + void *AddressMemoryCiCycleFlag[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + /*ϵ־λ 0xAA:ϵ 0x55ϵ*/ + HANDLE SHareMemoryMainStandByFlag[MAX_MAIN_STANDBY_NUM]; /* ϵ־λڴ */ + void *AddressMemoryMainStandByFlag[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + /* */ + HANDLE SHareMemoryPrtclInputMsg[MAX_MAIN_STANDBY_NUM]; /* Э */ + void *AddressMemoryPrtclInputMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + HANDLE SHareMemoryIoInputMsg[MAX_MAIN_STANDBY_NUM]; /* IO */ + void *AddressMemoryIoInputMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + HANDLE SHareMemoryLiveOrNotMsg[MAX_MAIN_STANDBY_NUM]; /* ־,0x55 */ + void *AddressMemoryLiveOrNotMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + HANDLE SHareMemoryExtendAInMsg[MAX_MAIN_STANDBY_NUM]; /* ExtendA */ + void *AddressMemoryExtendAInMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + HANDLE SHareMemoryExtendBInMsg[MAX_MAIN_STANDBY_NUM]; /* ExtendB */ + void *AddressMemoryExtendBInMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + HANDLE SHareMemoryExtendCInMsg[MAX_MAIN_STANDBY_NUM]; /* ExtendC */ + void *AddressMemoryExtendCInMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + HANDLE SHareMemoryExtendAOutMsg[MAX_MAIN_STANDBY_NUM]; /* ExtendA */ + void *AddressMemoryExtendAOutMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + HANDLE SHareMemoryExtendBOutMsg[MAX_MAIN_STANDBY_NUM]; /* ExtendB */ + void *AddressMemoryExtendBOutMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + HANDLE SHareMemoryExtendCOutMsg[MAX_MAIN_STANDBY_NUM]; /* ExtendC */ + void *AddressMemoryExtendCOutMsg[MAX_MAIN_STANDBY_NUM]; /* ڴ湲 */ + + +}SHareMemoryStruct; + +SHareMemoryStruct CISHareMemoryStruct; +/* +*ȡչABCIPϢ +*/ +void ReadExtendIpInfo(const CHAR* fileIpConfig) +{ + /* exten A */ + extenAIpconfigInfo = ReadConfigInfoByKey("չӿA",fileIpConfig); + + /* exten B */ + extenBIpconfigInfo = ReadConfigInfoByKey("չӿB",fileIpConfig); + + + /* exten C */ + extenCIpconfigInfo = ReadConfigInfoByKey("չӿC",fileIpConfig); + +} + +/*ʼڴ*/ +void InitSHareMemory() +{ + UINT i =0; + CHAR temp[3]; + + CHAR MemNameCiCycle[50] = "MemNameCiCycle"; + + CHAR MemNameIoOut[50] = "MemNameIoOut"; + CHAR MemNamePrtclOut[50] = "MemNamePrtclOut"; + CHAR MemNameStatus[50] = "MemNameStatus"; + CHAR MemNameSystemStep[50] = "MemNameSystemStep"; + CHAR MemNameMainStandByFlag[50] = "MemNameMainStandByFlag"; + CHAR MemNamePrtclInput[50] = "MemNamePrtclInput"; + CHAR MemNameIoInput[50] = "MemNameIoInput"; + CHAR MemNameLiveOrNot[50] = "MemNameLiveOrNot"; + CHAR MemNameExtendAIn[50] = "MemNameExtendAIn"; + CHAR MemNameExtendBIn[50] = "MemNameExtendBIn"; + CHAR MemNameExtendCIn[50] = "MemNameExtendCIn"; + CHAR MemNameExtendAOut[50] = "MemNameExtendAOut"; + CHAR MemNameExtendBOut[50] = "MemNameExtendBOut"; + CHAR MemNameExtendCOut[50] = "MemNameExtendCOut"; + CHAR tempName[50]; + memset(temp,0,sizeof(temp)); + memset(tempName,0,sizeof(tempName)); + + /*ڼڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameCiCycle); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryCiCycle[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,4,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryCiCycleFlag[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryCiCycle[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + /*IOڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameIoOut); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryIoOutputLen[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryIoOutputMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryIoOutputLen[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*Эڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNamePrtclOut); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryPrtclOutputMsgLen[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryPrtclOutputMsgLen[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*״̬ڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameStatus); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryStatusMsgLen[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,MSG_STATUS_LEN,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryStatusMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryStatusMsgLen[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*ϵ־λڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameSystemStep); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemorySystemStep[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,1,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemorySystemStepFlag[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemorySystemStep[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*ϵ־λڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameMainStandByFlag); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryMainStandByFlag[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,1,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryMainStandByFlag[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryMainStandByFlag[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*Э빲ڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNamePrtclInput); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryPrtclInputMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryPrtclInputMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryPrtclInputMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*IO빲ڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameIoInput); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryIoInputMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryIoInputMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryIoInputMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*ԷǷ־ڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameLiveOrNot); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryLiveOrNotMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,1,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryLiveOrNotMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryLiveOrNotMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*ExtendA빲ڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameExtendAIn); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryExtendAInMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryExtendAInMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryExtendAInMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + /*ExtendB빲ڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameExtendBIn); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryExtendBInMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryExtendBInMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryExtendBInMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + /*ExtendC빲ڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameExtendCIn); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryExtendCInMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryExtendCInMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryExtendCInMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + + /*ExtendAڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameExtendAOut); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryExtendAOutMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryExtendAOutMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryExtendAOutMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + /*ExtendBڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameExtendBOut); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryExtendBOutMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryExtendBOutMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryExtendBOutMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } + /*ExtendCڴʼ*/ + for(i = 0;i < MAX_MAIN_STANDBY_NUM;i++) + { + if ((i == LOCAL_IDX) || (i== OTHER_IDX)) + { + + + memset(tempName,0,sizeof(tempName)); + strcpy(tempName,MemNameExtendCOut); + strcat(tempName,itoa(i,temp,10)); + CISHareMemoryStruct.SHareMemoryExtendCOutMsg[i] = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,BUF_SIZE,(LPCWSTR)tempName); + CISHareMemoryStruct.AddressMemoryExtendCOutMsg[i] = MapViewOfFile(CISHareMemoryStruct.SHareMemoryExtendCOutMsg[i],FILE_MAP_READ | FILE_MAP_WRITE,0,0,0); + } + } +} + +/* +* жϣʼ״̬жϣжԭ:ȡڴռ״̬ȡѾ򱾻Ϊ״̬ +*/ +void MainStandByProcess() +{ + UINT8 otherStatus = 0xff; + + otherStatus = *((UINT8 *) CISHareMemoryStruct.AddressMemoryMainStandByFlag[OTHER_IDX]); + if (MAIN_FLAG == otherStatus)/*Ѿ*/ + { + localMainStandBy = STAND_BY_FLAG;/*Ϊ״̬*/ + *(UINT8 *)CISHareMemoryStruct.AddressMemoryLiveOrNotMsg[LOCAL_IDX] = FOLLOW_STATUS;/*ñΪ״̬*/ + } + else + { + localMainStandBy = MAIN_FLAG; + *((UINT8 *) CISHareMemoryStruct.AddressMemoryLiveOrNotMsg[LOCAL_IDX]) = LIVE_ON; + } + + /* ѱ״̬д뵽ڴ */ + memset((UINT8 *)CISHareMemoryStruct.AddressMemoryMainStandByFlag[LOCAL_IDX],localMainStandBy,sizeof(UINT8)); + +} + +UINT8 CiSimulationInit() +{ + UINT8 ret = 0; + extern UINT8 Computer_Id_Local_File; /*ƽ̨ID*/ + extern UINT8 processor_mode; /*ƽ̨ģʽ*/ + + /* ƽ̨ID Ҫ޸£˫ȽϵĻ */ + /*Computer_Id_Local_File =peiZhi_innerNet(); + if( 0 != Computer_Id_Local_File) + { + + } + else + { + CiLog->Log("Warning:pz.txt or pz1.txt read error \n"); + Computer_Id_Local_File='1'; + }*/ + Computer_Id_Local_File=1; + processor_mode = 0xA5; + /*ret = ReadCI_CFG(&gSheBeiType,&gSheBeiID); + if( ret) + { + + } + else + { + CiLog->Log("Warning:CI.cfg read error \n"); + + } + */ + + gSheBeiID = ReadLocalCiId(); + gSheBeiType = 0x3c; + + + /*豸ƣ+ID*/ + gSheBeiName = (gSheBeiType<<8) + gSheBeiID; + + /*ʼڴ*/ + LOCAL_IDX = LOCAL_IDX + gSheBeiID*2+2; + OTHER_IDX = OTHER_IDX + gSheBeiID*2+2; + + /*ʼڴ*/ + InitSHareMemory(); + + /*жϱ״̬*/ + MainStandByProcess(); + + ReadExtendIpInfo((const CHAR*)IP_CONFIG_PATH); + + /*ͨŶձʼ*/ + if (0 == ret) + { + if (HLHTCiIdMapInitial() != 1) + { + CiLog->Log("HLHT CI id map init error \n"); + ret = 2; + } + + } + + if (MAIN_FLAG == localMainStandBy) + { + /* ȡIPַϢʼͨſxmlļIPConfig.iniжȡ*/ + if(0 != InitCcovNew(gSheBeiName,(const CHAR*)DEVICE_IP_INFO_PATH)) + { + ret = 1; + } + + /*ʼCIATS*/ + if(SUC_DEF!=InitCiAtsCom(gSheBeiName,(const CHAR*)CI_ATS_CFG_PATH)) + { + ret=1; + } + if (SUC_DEF != InitCiOcCom(gSheBeiName, (const CHAR*)CI_OC_CFG_PATA)) + { + ret = 1; + } + + } + + + + + + /* Эʼ */ + if(0 == ret ) + { + if (0 != InitPrtcl((UINT8 *)FS_CONFIG_PATH)) + { + CiLog->Log("CI prtcl init error"); + ret = 3; + } + } + + /*Ӧóʼ*/ + if (0 == ret ) + { + if (CiAppInitial() != 1) + { + CiLog->Log("CI app init error \n"); + ret = 4; + } + + } + + + /* FSIOʼ */ + if(0 == ret) + { + if (0 != InitialCompareSysFsioCount()) + { + CiLog->Log("CI FSIO CHECK init error"); + ret = 5; + } + + } + + /* Check IPʼ */ + if( 0 == ret ) + { + if (0 != InitCheckIPMask()) + { + CiLog->Log("CI FSIO CHECK init error"); + ret = 6; + } + + } + /*ʼ¼,Ҫʼ*/ + if (extenAIpconfigInfo != NULL && extenAIpconfigInfo->localIpIno->port >0) + { + CiRecvFromCiDataQueue = &extenARcvQue; /*ʼCICIݶ*/ + CiSendToCiDataQueue = &extenASndQue; /*ʼCICIݶ*/ + } + + + + if (extenBIpconfigInfo != NULL && extenBIpconfigInfo->localIpIno->port >0) + { + VobcToCiDataQueue = &extenBRcvQue; /*ʼVOBCCIݶ*/ + CiToVobcDataQueue = &extenBSndQue; /*ʼCIVOBCݶ*/ + } + + + + if (extenCIpconfigInfo != NULL && extenCIpconfigInfo->localIpIno->port >0) + { + ZcToCiDataQueue = &extenCRcvQue; /*ʼZCCIݶ*/ + CiToZcDataQueue = &extenCSndQue; /*ʼCIZCݶ*/ + } + + /* ʼͨ״̬ */ + InitCommDevStatus(); + + /* ΪñΪ״̬ȡڴжԷ״̬ˢ±״̬ */ + if(STAND_BY_FLAG == localMainStandBy) + { + CycleNum = *((UINT32 *)CISHareMemoryStruct.AddressMemoryCiCycleFlag[OTHER_IDX]);/*ȡںŷ뱾*/ + + memcpy(tmpStatusBuff,(UINT8 *)CISHareMemoryStruct.AddressMemoryStatusMsg[OTHER_IDX],sizeof(tmpStatusBuff)); + /* ˢ±CI״̬ */ + SetCiAppData(tmpStatusBuff,0);/**/ + } + + return ret; +} + +UINT8 CiSimulationStart() +{ + UINT8 ret = 0; + gPeriodThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)PeriodProcess,NULL,0,&gPeriodThreadFlg); + SetThreadPriority(gPeriodThread,THREAD_PRIORITY_BELOW_NORMAL); + return ret; + + + /*SetTimer(NULL,0,300,TimePeriod);*/ + //return 0; +} + +UINT8 CiSimulationRelease() +{ + UINT8 ret = 0; + if(gPeriodThreadFlg !=0 ) + { + TerminateThread(gPeriodThread,gPeriodThreadFlg); + gPeriodThreadFlg = 0; + } + if (ioIpconfigInfo != NULL) + { + ReleaseConfigInfo(ioIpconfigInfo); + ioIpconfigInfo = NULL; + } + + if (wxIpconfigInfo != NULL) + { + ReleaseConfigInfo(wxIpconfigInfo); + wxIpconfigInfo = NULL; + } + return ret; +} + +/* +* ʼͨģ +*/ +#if 0 +UINT8 InitCcov(const CHAR * fileName) +{ + UINT8 ret = 0; + + /* ʼSfp */ + IpConfigInfoStru *ipConfig = ReadConfigInfoByKey("SFP",fileName); + + if (0 != sfpCcov.Init_Comm()) + { + CiLog->Log("sfp ccov Init error\n"); + return 1; + } + + if(0 != sfpCcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("sfp ccov Bind error\n"); + return 2; + } + sfpCcov.StartRcv(); + ccovList.insert(stdext::hash_map :: value_type(ipConfig->localIpIno->port,&sfpCcov)); + ReleaseConfigInfo(ipConfig); + ipConfig = NULL; + + /* ʼRSSP */ + ipConfig = ReadConfigInfoByKey("RSR",fileName); + if (0 != rsspCcov.Init_Comm()) + { + CiLog->Log("rssp ccov Init error\n"); + return 1; + } + + if(0 != rsspCcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("rssp ccov Bind error\n"); + return 2; + } + rsspCcov.StartRcv(); + ccovList.insert(stdext::hash_map :: value_type(ipConfig->localIpIno->port,&rsspCcov)); + ReleaseConfigInfo(ipConfig); + ipConfig = NULL; + + /* ʼIO */ + ipConfig = ReadConfigInfoByKey("IO",fileName); + + if (0 != ioCcov.Init_Comm()) + { + CiLog->Log("io ccov Init error\n"); + return 1; + } + + if(0 != ioCcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("io ccov Bind error\n"); + return 2; + } + ioCcov.StartRcv(); + + ioIpconfigInfo = ipConfig; /* ʱ IOӿ */ + //ReleaseConfigInfo(ipConfig); + ipConfig = NULL; + + + /* exten A */ + ipConfig = ReadConfigInfoByKey("չӿA",fileName); + if (ipConfig->localIpIno->port >0) + { + if (0 != extenACcov.Init_Comm()) + { + CiLog->Log("extenACcov ccov Init error\n"); + return 1; + } + + if(0 != extenACcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("extenACcov ccov Bind error\n"); + return 2; + } + extenACcov.StartRcv(); + } + extenAIpconfigInfo = ipConfig; /* ʱ IOӿ */ + /* exten B */ + ipConfig = ReadConfigInfoByKey("չӿB",fileName); + + if (ipConfig->localIpIno->port >0) + { + if (0 != extenBCcov.Init_Comm()) + { + CiLog->Log("extenBCcov ccov Init error\n"); + return 1; + } + + if(0 != extenBCcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("extenBCcov ccov Bind error\n"); + return 2; + } + extenBCcov.StartRcv(); + + } + extenBIpconfigInfo = ipConfig; /* ʱ IOӿ */ + + /* exten C */ + ipConfig = ReadConfigInfoByKey("չӿC",fileName); + if (ipConfig->localIpIno->port >0) + { + if (0 != extenCCcov.Init_Comm()) + { + CiLog->Log("extenCCcov ccov Init error\n"); + return 1; + } + + if(0 != extenCCcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("extenCCcov ccov Bind error\n"); + return 2; + } + extenCCcov.StartRcv(); + } + extenCIpconfigInfo = ipConfig; /* ʱ IOӿ */ + //ReleaseConfigInfo(ipConfig); + + // ά + wxIpconfigInfo = ReadConfigInfoByKey("ά޻",fileName); + wxCcov.Init_Comm(); + // ڲҪݣ˲󶨶˿ + ipConfig = NULL; + + return ret; +} + +#else +/* +*ʼͨģ +*/ +UINT8 InitCcovNew(UINT16 DevName,const CHAR * fileName) +{ + UINT8 ret = 0; + IpInfo pIpInfo[4]; + IpInfo pIpInfoLeuCI[4]; + UINT8 numLeuCI = 0; + UINT8 num = 0; + UINT8 prtclType = 1; + UINT8 index = 0; + IpConfigInfoStru *ipConfig = NULL; + UINT8 tempIp[4]; + CHAR ipStr[20]; + UINT8 prtlIdxs[]={SFP_IDX,RP_IDX,RSSP1_IDX}; + UINT8 tempPrtlIdx; + const CHAR *fileIpConfig = IP_CONFIG_PATH; + const CHAR *LEUCIComCfg = LEU_DEVICE_IP_INFO_PATH; + unsigned char rssp2StartFlag = 0; + + /*滻IPConfigļIOǰ沿*/ + +#if 1 + + ReadCIFsDevIpTable((const CHAR*)FS_CONFIG_PATH); +#else + /*ȡxmlļ*/ + ReadXml(fileName); +#endif + + + /*ȡLEUCICFG.xmlļ*/ + ReadXmlLeuCICfg((const CHAR *)LEUCIComCfg); + + /*ʼ־ɾʱ*/ + qjLogSaveTime = ReadLogConfig(); + + debug_infor_printf("־ɾʱΪ%d\n", qjLogSaveTime); + + /* 豸ƺЭͳʼͨſ*/ + + /* ʼSFPRPRSSPͨſ */ + for(index = 0;index < sizeof(prtlIdxs);index++) + { + tempPrtlIdx=prtlIdxs[index]; + + GetNetEndPoint(DevName, 0, tempPrtlIdx, pIpInfo, &num); + + /*жͨſʼͰǷɹ*/ + if (num == 1) + { + if (0 != localCcov.blueCcov[tempPrtlIdx].Init_Comm()) + { + CiLog->Log("localCcov.blueCcov[%d] Init error\n",tempPrtlIdx); + return 1; + } + ConvertUit32Ip2IpStrFormat(pIpInfo[num-1].blueIp,ipStr); + if (0 != localCcov.blueCcov[tempPrtlIdx].Bind(pIpInfo[num-1].bluePort,ipStr)) + { + CiLog->Log("localCcov.blueCcov[%d][%s] Bind error\n",tempPrtlIdx,ipStr); + return 2; + } + localCcov.blueCcov[tempPrtlIdx].StartRcv(); + if (0 != localCcov.redCcov[tempPrtlIdx].Init_Comm()) + { + CiLog->Log("localCcov.redCcov[%d] Init error\n",tempPrtlIdx); + return 1; + } + ConvertUit32Ip2IpStrFormat(pIpInfo[num-1].redIp,ipStr); + if (0 != localCcov.redCcov[tempPrtlIdx].Bind(pIpInfo[num-1].redPort,ipStr)) + { + CiLog->Log("localCcov.redCcov[%d][%s] Bind error\n",tempPrtlIdx,ipStr); + return 2; + } + localCcov.redCcov[tempPrtlIdx].StartRcv(); + } + + } + + /*ʼRSSP2ͨſ*/ + GetNetEndPoint(DevName, 0, RSSP2_IDX, pIpInfo, &num);/*ұ豸IPRSSP2Э˿*/ + localCcov.rssp2BlueCcov.SetNetEndPoint(pIpInfo[num-1].blueIp,pIpInfo[num-1].bluePort,BLUE_NET);//RSSPͨسʼ + if(0==localCcov.rssp2BlueCcov.Start()) + { + rssp2StartFlag=1;//ֻҪһͨɹΪɹ + } + + localCcov.rssp2RedCcov.SetNetEndPoint(pIpInfo[num-1].redIp,pIpInfo[num-1].redPort,RED_NET);//RSSPͨسʼ + if(0==localCcov.rssp2RedCcov.Start()) + { + rssp2StartFlag=1;//ֻҪһͨɹΪɹ + } + + if(1!=rssp2StartFlag) + { + CiLog->Log("localCcov.rssp2Ccov Init error\n"); + return 2; + } + + GetIpAndPortByDeviceNameLEUCI(DevName,pIpInfoLeuCI,&numLeuCI);/*ʼLEUͨŵͨſ*/ + /*жLEU-CIͨſʼͰǷɹ*/ + if (numLeuCI == 1) + { + if (0 != localCcov.blueCCov.Init_Comm()) + { + CiLog->Log("localCcov.blueCCov LEU Init error\n"); + return 1; + } + ConvertUit32Ip2IpStrFormat(pIpInfoLeuCI[numLeuCI-1].blueIp,ipStr); + if (0 != localCcov.blueCCov.Bind(pIpInfoLeuCI[numLeuCI-1].bluePort,ipStr)) + { + CiLog->Log("localCcov.blueCCov LEU Bind error\n"); + return 2; + } + localCcov.blueCCov.StartRcv(); + if (0 != localCcov.redCCov.Init_Comm()) + { + CiLog->Log("localCcov.redCCov LEU Init error\n"); + return 1; + } + ConvertUit32Ip2IpStrFormat(pIpInfoLeuCI[numLeuCI-1].redIp,ipStr); + if (0 != localCcov.redCCov.Bind(pIpInfoLeuCI[numLeuCI-1].redPort,ipStr)) + { + CiLog->Log("localCcov.redCCov LEU Bind error\n"); + return 2; + } + localCcov.redCCov.StartRcv(); + } +#if 1 + + /* ȡLocalInfoConfig.iniļ */ + CHAR strTree[50],strLeaf[50]; + CHAR tmpBuff[100]; + INT32 iReadLen = 0; + ipConfig = new IpConfigInfoStru(); + + strcpy(ipConfig->name,"IO"); + /* ȡ */ + sprintf(strTree, "%s","IO"); + IpInfoStr *ipInfo = new IpInfoStr(); + + ConvertUit32Ip2IpStrFormat(pIpInfo[num-1].redIp,ipStr); + strcpy(ipInfo->ip,ipStr); + + sprintf(strLeaf,"PORT"); + iReadLen = GetPrivateProfileStringA(strTree,strLeaf,NULL,tmpBuff,50,fileIpConfig); + tmpBuff[iReadLen] = 0; + ipInfo->port = atoi(tmpBuff); + ipConfig->localIpIno = ipInfo; + /* ȡ */ + sprintf(strTree, "%s","IO"); + ipConfig->dstIpInfo = ReadIpInfoFromIni(strTree,fileIpConfig); + +#else + /* ʼIO */ + ipConfig = ReadConfigInfoByKey("IO",fileIpConfig); +#endif + + + if (0 != ioCcov.Init_Comm()) + { + CiLog->Log("io ccov Init error\n"); + return 1; + } + + if(0 != ioCcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("io ccov Bind error\n"); + return 2; + } + ioCcov.StartRcv(); + + ioIpconfigInfo = ipConfig; /* ʱ IOӿ */ + //ReleaseConfigInfo(ipConfig); + ipConfig = NULL; + + + /* exten A */ + ipConfig = extenAIpconfigInfo; + if (ipConfig->localIpIno->port >0) + { + if (0 != extenACcov.Init_Comm()) + { + CiLog->Log("extenACcov ccov Init error\n"); + return 1; + } + + if(0 != extenACcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("extenACcov ccov Bind error\n"); + return 2; + } + extenACcov.StartRcv(); + } + + /* exten B */ + ipConfig = extenBIpconfigInfo; + + if (ipConfig->localIpIno->port >0) + { + if (0 != extenBCcov.Init_Comm()) + { + CiLog->Log("extenBCcov ccov Init error\n"); + return 1; + } + + if(0 != extenBCcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("extenBCcov ccov Bind error\n"); + return 2; + } + extenBCcov.StartRcv(); + + } + + + /* exten C */ + ipConfig = extenCIpconfigInfo; + if (ipConfig->localIpIno->port >0) + { + if (0 != extenCCcov.Init_Comm()) + { + CiLog->Log("extenCCcov ccov Init error\n"); + return 1; + } + + if(0 != extenCCcov.Bind(ipConfig->localIpIno->port,ipConfig->localIpIno->ip)) + { + CiLog->Log("extenCCcov ccov Bind error\n"); + return 2; + } + extenCCcov.StartRcv(); + } + + //ReleaseConfigInfo(ipConfig); + + // ά + wxIpconfigInfo = ReadConfigInfoByKey("ά޻",fileIpConfig); + wxCcov.Init_Comm(); + // ڲҪݣ˲󶨶˿ + ipConfig = NULL; + + return ret; + +} + +UINT8 InitCiAtsCom(UINT16 DevName,const CHAR * fileName) +{ + UINT8 retResult=ERR_DEF; + UINT8 redInitRet=ERR_DEF; + UINT8 blueInitRet=ERR_DEF; + UINT8 ii = 0U; + UINT8 ccovIdx = 0U; + CiAtsIpInfo ipInfo; + char ipArr[15]; + + localCcov.ciInAts=0; + localCcov.xdInAts=0; + +#if 1 + + ReadCIATSFsDevIpTable((const CHAR*)FS_CONFIG_PATH); +#else + + retResult=ReadCiAtsCfg(fileName); + +#endif + for (ii = 0; ii < PRTL_UDP_CNT; ii++) + { + switch(ii) + { + case 0U: + ccovIdx = SFP_IDX; + break; + case 1U: + ccovIdx = RP_IDX; + break; + case 2U: + ccovIdx = RSSP1_IDX; + break; + default: + break; + } + retResult = ReadCiAtsIpInfo(DevName,ccovIdx, &ipInfo); + if (SUC_DEF == retResult) + { + localCcov.ciInAts = ReadCiInAtsFlag(); + localCcov.xdInAts = ReadXdInAtsFlag(); + /*ʼATSͨſ*/ + if (0 == localCcov.atsRedCcov[ccovIdx].Init_Comm()) + { + ConvertUit32Ip2IpStrFormat(ipInfo.RedIp, ipArr); + if ((65535 != ipInfo.RedPort) && (0 == localCcov.atsRedCcov[ccovIdx].Bind(ipInfo.RedPort, ipArr))) + {/*˿ЧҰ󶨳ɹ*/ + localCcov.atsRedCcov[ccovIdx].StartRcv();/*ʼɹ*/ + redInitRet = SUC_DEF; + } + else + { + CiLog->Log("localCcov.atsRedCcov Bind error\n"); + redInitRet = ERR_DEF; + } + } + else + { + CiLog->Log("localCcov.atsRedCcov Init error\n"); + redInitRet = ERR_DEF; + } + /*ʼATSͨſ*/ + if (0 == localCcov.atsBlueCcov[ccovIdx].Init_Comm()) + { + ConvertUit32Ip2IpStrFormat(ipInfo.BlueIp, ipArr); + if ((65535 != ipInfo.BluePort) && (0 == localCcov.atsBlueCcov[ccovIdx].Bind(ipInfo.BluePort, ipArr))) + {/*˿ЧҰ󶨳ɹ*/ + localCcov.atsBlueCcov[ccovIdx].StartRcv();/*ʼɹ*/ + blueInitRet = SUC_DEF; + } + else + { + CiLog->Log("localCcov.atsBlueCcov Bind error\n"); + blueInitRet = ERR_DEF; + } + } + else + { + CiLog->Log("localCcov.atsBlueCcov Init error\n"); + blueInitRet = ERR_DEF; + } + + if ((SUC_DEF == redInitRet) || (SUC_DEF == blueInitRet)) + {/*һʼɹΪɹ*/ + retResult = SUC_DEF; + } + else + { + retResult = ERR_DEF; + } + } + } + return retResult; +} + +UINT8 InitCiOcCom(UINT16 DevName, const CHAR * fileName) +{ + UINT8 retResult = ERR_DEF; + UINT8 redInitRet = ERR_DEF; + UINT8 blueInitRet = ERR_DEF; + CiOcIpInfo ipInfo; + char ipArr[15]; + + + localCcov.OcInCi = ReadCiOcCfg(fileName, DevName, &ipInfo); + + if (1u == localCcov.OcInCi) + { + /*ʼocͨſ*/ + if (0 == localCcov.ocRedCcov.Init_Comm()) + { + ConvertUit32Ip2IpStrFormat(ipInfo.RedIp, ipArr); + if ((65535 != ipInfo.RedPort) && (0 == localCcov.ocRedCcov.Bind(ipInfo.RedPort, ipArr))) + {/*˿ЧҰ󶨳ɹ*/ + localCcov.ocRedCcov.StartRcv();/*ʼɹ*/ + redInitRet = SUC_DEF; + } + else + { + CiLog->Log("localCcov.ocRedCcov Bind error\n"); + redInitRet = ERR_DEF; + } +} + else + { + CiLog->Log("localCcov.ocRedCcov Init error\n"); + redInitRet = ERR_DEF; + } + /*ʼocͨſ*/ + if (0 == localCcov.ocBlueCcov.Init_Comm()) + { + ConvertUit32Ip2IpStrFormat(ipInfo.BlueIp, ipArr); + if ((65535 != ipInfo.BluePort) && (0 == localCcov.ocBlueCcov.Bind(ipInfo.BluePort, ipArr))) + {/*˿ЧҰ󶨳ɹ*/ + localCcov.ocBlueCcov.StartRcv();/*ʼɹ*/ + blueInitRet = SUC_DEF; + } + else + { + CiLog->Log("localCcov.ocBlueCcov Bind error\n"); + blueInitRet = ERR_DEF; + } + } + else + { + CiLog->Log("localCcov.ocBlueCcov Init error\n"); + blueInitRet = ERR_DEF; + } + + if ((SUC_DEF == redInitRet) && (SUC_DEF == blueInitRet)) + {/*˫ʼɹ*/ + retResult = SUC_DEF; + } + else + { + retResult = ERR_DEF; + } + } + else + { + retResult = SUC_DEF; + } + + return retResult; +} +#endif +UINT8 InitPrtcl(UINT8 * fileName) +{ +#if 0 + /* SFP */ + Proto_Info.RadamSN = 0; + /*SFPЭṹеıгʼ*/ + Proto_Info.CycleNum = &CycleNum; /*edit by wx 09-03-09*/ + Proto_Info.OutnetQueueSize = 30000; /*նг*/ + Proto_Info.TimeCounter = &CycleNum; + Proto_Info.RedundTimeout = 30; + Proto_Info.OutputTimeout = 30; + Proto_Info.RecordArraySize = 1000; + Proto_Info.DataBase = 0; + Proto_Info.LocalID = gSheBeiID; + Proto_Info.LocalType = 0x3C; /* 0x03 ATS;0x3C CI */ + Proto_Info.InputSize = 1024*3; + Proto_Info.OutputSize = 1024*3; + Proto_Info.MaxNumLink = 50; + Proto_Info.MaxNumPerCycle = 5; + if(1 != ProtclInit(fileName,&Proto_Info)) + { + CiLog->Log("sfpInit error \n"); + return 1; + } + /* RSSP */ + Rssp_Info.LocalID = gSheBeiID; /* ID */ + Rssp_Info.LocalType = 0x3C; /* */ + Rssp_Info.MaxNumLink = 12; + Rssp_Info.InputSize = 300; + Rssp_Info.OutputSize = 300; + Rssp_Info.MaxNumPerCycle = 5; + Rssp_Info.CycleNum = &CycleNum; + Rssp_Info.RecordArraySize = 1000; + if(1 != Rssp2Init(fileName,&Rssp_Info)) + { + CiLog->Log("Rssp2Init error \n"); + return 2; + } +#endif + gCbtcData.LocalID =gSheBeiID; + gCbtcData.LocalType =gSheBeiType; + gCbtcData.CycleNum =&CycleNum; + gCbtcData.InputSize =6000; + gCbtcData.OutputSize =6000; + gCbtcData.RecordArraySize =9000; + gCbtcData.MaxNumPerCycle = 5; + if (1u == localCcov.OcInCi) + { + if (1 != ProtclInitFunc(fileName, gInnetProtclParamLen, gInnetProtclParam, &gCbtcData)) + { + CiLog->Log("Protocol Init error \n"); + return 1; + } + } + else + { + if (1 != ProtclInitFunc(fileName, 0u, NULL, &gCbtcData)) + { + CiLog->Log("Protocol Init error \n"); + return 1; + } + } + + /*SetRsspNoSendAppData(CI_NONE_SEND_APP_DATA_WL); /*RSSP޷Ӧ*/ + SetRsspConfigData(CI_NONE_SEND_APP_DATA_WL,&gCbtcData); + + /* FSFB 治ʹЭIOͨ */ + Fsfb_Info.CycleNum = &CycleNum; + Fsfb_Info.LocalType = 0x3c; + Fsfb_Info.LocalID = gSheBeiID; + Fsfb_Info.MaxNumLink = 20; + Fsfb_Info.MaxNumPerCycle = 5; + Fsfb_Info.InputSize = 1024; + Fsfb_Info.OutputSize = 1024; + Fsfb_Info.RecordArraySize = 2000; + +#if 0 + if(1 != FsfbProtclInit(fileName,&Fsfb_Info)) + { + CiLog->Log("FsfbProtclInit error \n"); + return 3; + } +#endif + /* can */ + if (1 != QueueInitial(&canQueueRecv,3000)) + { + CiLog->Log("canQueueRecv init error \n"); + return 4; + } + if (1 != QueueInitial(&canQueueSend,3000)) + { + CiLog->Log("canQueueRecv init error \n"); + return 5; + } + + /* exten C */ + if (1 != QueueInitial(&extenCSndQue,3000)) + { + CiLog->Log("extenCSndQue init error \n"); + return 4; + } + if (1 != QueueInitial(&extenCRcvQue,3000)) + { + CiLog->Log("extenCRcvQue init error \n"); + return 7; + } + + /* exten B */ + if (1 != QueueInitial(&extenBSndQue,3000)) + { + CiLog->Log("extenBSndQue init error \n"); + return 4; + } + if (1 != QueueInitial(&extenBRcvQue,3000)) + { + CiLog->Log("extenBRcvQue init error \n"); + return 5; + } + + /* exten A */ + if (1 != QueueInitial(&extenASndQue,3000)) + { + CiLog->Log("extenASndQue init error \n"); + return 4; + } + if (1 != QueueInitial(&extenARcvQue,3000)) + { + CiLog->Log("extenARcvQue init error \n"); + return 6; + } + + + return 0; +} + + +/************************************************************************************ +* : ReadPeiZhiId +* : ļȡID +* ڲ: char* filePath ļ· +* ֵ: unsigned char ID +*************************************************************************************/ +unsigned char ReadPeiZhiId( const char* filePath) +{ + FILE *fpPeiZhiFime= NULL; /*ļ*/ + int byteCount = 3; /*1ֽID 2ֽڵCRC*/ + unsigned char peizhiData[3]; /*ļ*/ + unsigned char read_localID; /*ID*/ + unsigned short localIdCRC; /*IDCRC*/ + unsigned short peizhiCRC; /*ļIDCRC*/ + + + /*ļ*/ + fpPeiZhiFime = fopen(filePath,"r+"); + + if ( NULL == fpPeiZhiFime ) /*ļ*/ + { + CiLog->Log("fopen peizhi error\n"); + printf("fopen peizhi error\n"); + return (unsigned char)0xAA; /*ش*/ + } + + /*ȡļ*/ + if ( 0 == ( fread( peizhiData, sizeof(unsigned char), byteCount, fpPeiZhiFime) ) ) + { + CiLog->Log("read peizhi error\n"); + printf("read peizhi error\n"); + return (unsigned char)0xAA; /*ش*/ + } + + /*رļ*/ + if ( 0 != fclose( fpPeiZhiFime ) ) + { + CiLog->Log("fclose fpPeiZhiFime error\n"); + printf("fclose fpPeiZhiFime error\n"); + return (unsigned char)0xAA; + } + + /*crcУ*/ + localIdCRC= Crc16(peizhiData , 1); + peizhiCRC = ShortFromChar(peizhiData+1); + + /*Уʧ*/ + if(localIdCRC != peizhiCRC) + { + CiLog->Log("peizhi crc fail\n"); + printf("peizhi crc fail\n"); + return (unsigned char)0xAA; /*ش*/ + } + else + { + /*ID*/ + read_localID = peizhiData[0]; + CiLog->Log("read_localID = %c, %d\n", read_localID, read_localID); + printf("read_localID = %c, %d\n", read_localID, read_localID); + return read_localID; + } + +} + +/* +* 뱾ID +* ˵ +* ֵ 0,ʧ +* >0,ID +*/ +UINT8 peiZhi_innerNet(void) +{ + unsigned char read_localID = (unsigned char)'0'; /*һļID*/ + unsigned char read_localID1 = (unsigned char)'0'; /*ڶļID*/ + unsigned char DiffNum = 0x64; /*һIDΪ1ڶļΪ101 100*/ + const CHAR PeiZhiFileRoad[]= ".\\Config\\pz.txt"; /*IDļ*/ + const CHAR PeiZhiFileRoad1[]= ".\\Config\\pz1.txt"; /*IDļ*/ + + read_localID = ReadPeiZhiId(PeiZhiFileRoad); + read_localID1 = ReadPeiZhiId(PeiZhiFileRoad1); + /*ID ȡʧ*/ + if((0xAA == read_localID) || (0xAA == read_localID1) ) + { + printf("ERROR:Peizhi ID read fail\n"); + return 0; + } + + /*УIDǷһ*/ + if(DiffNum != read_localID1 - read_localID ) + { + printf("ERROR:Peizhi ID check fail\n"); + return 0; + } + + /*תΪasicII,ַʽ*/ + read_localID = read_localID +48; + Computer_Id_Local_File = read_localID; /*߼ֵַ*/ + + return Computer_Id_Local_File; +} + + +/* +* 뱾ID +* ˵ +* ֵ 0,ʧ +* >0,ID +*/ +UINT8 ReadLocalCiId(void) +{ + FILE *fp = NULL; + CHAR str[30] = {0}; + CHAR labelString[] = "localCiId ="; + UINT8 ii = 0; + UINT8 digitalIndex = 0; + const CHAR LocalCiIdPath[]= ".\\Config\\LocalCiId.ini"; /*IDļ*/ + + fp = fopen(LocalCiIdPath,"rb"); + if (NULL == fp) + { + printf("ȡļ\n"); + return 0; + } + + if (fgets(str, 30, fp) == NULL) + { + printf("ȡļ\n"); + return 0; + } + + if (strstr(str, labelString) == NULL) + { + printf("%sδҵ\"localCiId =\"ַ\n", LocalCiIdPath); + return 0; + } + + for (ii = 0; ii < 30; ii++) + { + if ((str[ii] >= '0') && (str[ii] <= '9')) + { + digitalIndex = ii; + break; + } + } + + LocalCiId = (UINT8 ) atoi(&str[digitalIndex]); + if (LocalCiId == 0) + { + return 0; + } + fclose(fp); + return LocalCiId; +} + + +/************************************************************************/ +/*ȡԷ־λ */ +/************************************************************************/ +UINT8 GetOtherStepFlag() +{ + return *((UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[OTHER_IDX]); +} +/************************************************************************/ +/*ȡ־λʱδʹã */ +/************************************************************************/ +UINT8 GetLocalStepFlag() +{ + return *((UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX]); +} + +/* +* ڴ +*/ +void PeriodProcess(void) +{ + UINT32 lastTime = 0; + UINT32 crrntTime = 0; + UINT32 spdTime =0; + UINT32 tmpTime = 0; + INT32 slepTime = 0; + UINT8 otherLiveFlag = 0; + UINT8 otherStepFlag = 0; + + while (1) + { + crrntTime = timeGetTime(); + UINT32 dataLen = 0u; + if (MAIN_FLAG != localMainStandBy) + { + CiLog->Log("ȴ\n"); + /* һνҪȴ뵽ڿʼ */ + if(*((UINT8 *) CISHareMemoryStruct.AddressMemoryLiveOrNotMsg[LOCAL_IDX]) == FOLLOW_STATUS) + { + do + { + otherStepFlag = GetOtherStepFlag(); + } while (otherStepFlag != STEP_OUTPUT); + + CiLog->Log("ʼˢ·.\n"); + *((UINT8 *) CISHareMemoryStruct.AddressMemoryLiveOrNotMsg[LOCAL_IDX]) = LIVE_ON; + CycleNum = *((UINT32 *)CISHareMemoryStruct.AddressMemoryCiCycleFlag[OTHER_IDX]);/*ȡںŷ뱾*/ + + memcpy(tmpStatusBuff,(UINT8 *)CISHareMemoryStruct.AddressMemoryStatusMsg[OTHER_IDX],sizeof(tmpStatusBuff)); + /* ˢ±CI״̬ */ + SetCiAppData(tmpStatusBuff,0);/*ע⣬0ʱӵ*/ + *(UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX] = STEP_START; + } + } + + if ((crrntTime - lastTime) >= PERIOND_TIME) + { + if (MAIN_FLAG == localMainStandBy) + { + CiLog->Log("ȴڿʼ \n"); + do + { + /* 1ʱȴԷڿʼ */ + otherStepFlag = GetOtherStepFlag(); + otherLiveFlag = GetOtherLiveFlag(); + Sleep(1); + } while (((otherLiveFlag == LIVE_ON) && (otherStepFlag != STEP_START))||(otherLiveFlag == FOLLOW_STATUS)); + } + else + { + + } + *(UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX] = STEP_START; + lastTime = crrntTime; + CiLog->Log("\n------------------------------------- CycleNum Start%x %x ------------------------\n",CycleNum,crrntTime); + CiLog->Log("1ȴԷڿʼ...\n"); + WaitStep(STEP_START); + CiLog->Log("Էڿʼ...\n"); + HandleCiApp(); + tmpTime = timeGetTime(); + CiLog->Log("\n------------------------------------- CycleNum End%x %x------------------------\n",CycleNum,tmpTime); + CycleNum = CycleNum + 1; + if (MAIN_FLAG == localMainStandBy)/**/ + { + memcpy((UINT32 *)CISHareMemoryStruct.AddressMemoryCiCycleFlag[LOCAL_IDX],&CycleNum,sizeof(UINT32));/*ƽ̨ںдڼڴ*/ + dataLen = GetCiAppData(&tmpStatusBuff[4]); + + LongToChar(dataLen, tmpStatusBuff); + /*dataLen += 4; + SetCiAppData(tmpStatusBuff, dataLen);*/ + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryStatusMsg[LOCAL_IDX],tmpStatusBuff,sizeof(tmpStatusBuff)); + } + if(*(UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX] == STEP_END) + { + CiLog->Log("\n=================Ƚʧ===================\n"); + break; + } + memset((UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX],STEP_OUTPUT,sizeof(UINT8));/*ϣñͬ־λ3*/ + WaitStep(STEP_OUTPUT); + } + Sleep(10); + + } + +} + +void HandleCiApp(void) +{ + /*ͨͬ־λж + *ϲд뱾ڴ棬1ϲд뱾ڴ棬2ȡԷڴ뱾ȽϣȽϣ3 + *ӶԷڴȡϣ1ϲд뱾ڴ棬2ȡԷڴ뱾ȽϣȽϣ3 + */ + + UINT8 tmpOtherStep = 0; + UINT8 otherLieFlag = GetOtherLiveFlag(); + UINT8 ioCmpFlag = 1;/*Ƚϱ־1һ£0һ,Ϊֱ*/ + UINT8 appCmpFlag = 1;/*Ƚϱ־1һ£0һ*/ + INT32 rssp2BlueClientCnt; + UINT32 rssp2BlueClients[1024] = {0}; + INT32 rssp2RedClientCnt; + UINT32 rssp2RedClients[1024] = {0}; + UINT8 tcpBuf[1024] = {0}; + UINT16 tcpBufLen; + UINT32 etcsId; + int i; + UINT16 ii = 0u; + + UINT64 startCount = 0; + UINT64 endCount = 0; + + debug_infor_printf("HandleCiApp start is %lu\n",GetTickCount()); + map *mapDevTcpSta = new map();/**/ + unsigned char tTcpSta = 0x20;/**/ + map::iterator tDevItem; + + /*printf("aaaaaaaaaa\n");*/ + + if(MAIN_FLAG == localMainStandBy) + { + /*һ,ô־λΪSTEP_INPUT*/ + QueueClear(&gCbtcData.OutnetQueueA); + QueueClear(&gCbtcData.OutnetQueueB); + /*ݣζȡ6ͨſݣοԭ*/ + UINT8 idx = 0; + for (idx = 0;idx < PRTL_UDP_CNT;idx++) + { + /*ָн*/ + RcvDataFromSignalNet(&gCbtcData.OutnetQueueA,&(localCcov.blueCcov[idx]));/*Эͨſյдն*/ + RcvDataFromSignalNet(&gCbtcData.OutnetQueueB,&(localCcov.redCcov[idx])); + } + /*RSSP2 tcp״̬*/ + localCcov.rssp2BlueCcov.GetClientDevs(rssp2BlueClients, &rssp2BlueClientCnt);/*ȡTCPͻ豸Ϣ*/ + localCcov.rssp2RedCcov.GetClientDevs(rssp2RedClients, &rssp2RedClientCnt); + + for (i = 0;iinsert(pair(rssp2RedClients[i], tTcpSta));/*Ϣ뵽б*/ + } + + for(i = 0; i < rssp2BlueClientCnt; i++) + { + tDevItem = mapDevTcpSta->find(rssp2BlueClients[i]);/*ָͨŽڵ*/ + if(tDevItem!=mapDevTcpSta->end()) + {/*ͨŽڵѾбУϲ·״̬*/ + tDevItem->second=(tDevItem->second|0x02); + } + else + {/*ͨŽڵ㲻бУбвµĽڵ*/ + mapDevTcpSta->insert(pair(rssp2BlueClients[i],0x02)); + } + } + + i=2;/*ȣ·״̬Ϣֽֽڣ*/ + for(tDevItem=mapDevTcpSta->begin();tDevItem!=mapDevTcpSta->end();tDevItem++) + { + tcpBuf[i++]=(UINT8)(tDevItem->first>>(8*3)); /*ETCS ID*/ + tcpBuf[i++]=(UINT8)(tDevItem->first>>(8*2)); /*ETCS ID*/ + tcpBuf[i++]=(UINT8)(tDevItem->first>>(8*1)); /*ETCS ID*/ + tcpBuf[i++]=(UINT8)(tDevItem->first>>(8*0)); /*ETCS ID*/ + + tcpBuf[i++]=tDevItem->second;/*TCP·״̬*/ + } + tcpBuf[0]=(UINT8)((i-2)>>8);/*䳤*/ + tcpBuf[1]=(UINT8)(i-2); + + ProtclReceiveTcpStateFunc(i, tcpBuf,&gCbtcData);/*Э㱨TCP·״̬·״ֽ̬·״̬ģ*/ + + /*RSSP2 Ccovȡ*/ + RcvDataFromRssp2Ccov(&gCbtcData.OutnetQueueA,&(localCcov.rssp2BlueCcov)); + RcvDataFromRssp2Ccov(&gCbtcData.OutnetQueueB,&(localCcov.rssp2RedCcov)); + + /*ATS*/ + if(1==localCcov.ciInAts) + {/*˵CIATS*/ + /*ָн*/ + RcvDataFromSignalNet(&gCbtcData.OutnetQueueA,&(localCcov.atsBlueCcov[SFP_IDX])); /*SFPн*/ + RcvDataFromSignalNet(&gCbtcData.OutnetQueueB,&(localCcov.atsRedCcov[SFP_IDX])); + + RcvDataFromSignalNet(&gCbtcData.OutnetQueueA, &(localCcov.atsBlueCcov[RSSP1_IDX])); /*RSSP-1н*/ + RcvDataFromSignalNet(&gCbtcData.OutnetQueueB, &(localCcov.atsRedCcov[RSSP1_IDX])); + } + if (0 == (CycleNum % 2))/*FSFB2ЭΪ600ms,CIӦڵ2:1357....ڵFSFB2Э鴦*/ + { + RcvDataFromSignalNet(&gCbtcData.OutnetQueueA, &(localCcov.redCCov)); + } + /*ATS*/ + if (1 == localCcov.OcInCi) + {/*˵OCCI*/ + /*ָн*/ + RcvDataFromSignalNet(&gCbtcData.OutnetQueueA, &(localCcov.ocBlueCcov)); + RcvDataFromSignalNet(&gCbtcData.OutnetQueueB, &(localCcov.ocRedCcov)); + } + + /* ӿת,ȡCAN */ + QueueClear(&canQueueRecv); + RcvDataFromSignalNetNoLen(&canQueueRecv,&ioCcov); + + CiLog->Log("IO rcv len:%d\n",QueueStatus(&canQueueRecv)); + /* ʵʻIOÿ ƽ̨Ӧݣûнܵʹϴνܵ */ + if (QueueStatus(&canQueueRecv) > 0) + { + tmpIoLen = QueueStatus(&canQueueRecv); + if (tmpIoLen < sizeof(tmpIoBuff)/sizeof(UINT8)) + { + QueueScan(tmpIoLen,tmpIoBuff,&canQueueRecv); + debug_out_array(0,(UINT8 *)tmpIoBuff,tmpIoLen); + CiLog->Log("\n"); + } + else + { + tmpIoLen = sizeof(tmpIoBuff)/sizeof(UINT8); + QueueScan(tmpIoLen,tmpIoBuff,&canQueueRecv); + } + } + else + { + if (tmpIoLen > 0) + { + QueueWrite(tmpIoLen,tmpIoBuff,&canQueueRecv); + } + } + if (tmpIoLen > 0) + { + INT16 ii = 0,jj = 0; + static UINT8 ioSeq = 0; + tmpSnd2WxLen = 0; + ioSeq ++; + if (tmpIoLen%5 != 0) + { + tmpIoLen = tmpIoLen - (tmpIoLen%5); + } + while (ii < tmpIoLen) + { + tmpSnd2WxBuff[jj++] = tmpIoBuff[ii++]; + tmpSnd2WxBuff[jj++] = 0xc8; /* */ + tmpSnd2WxBuff[jj++] = ioSeq; + tmpSnd2WxBuff[jj++] = 0x0; /* */ + tmpSnd2WxBuff[jj++] = tmpIoBuff[ii++]; + tmpSnd2WxBuff[jj++] = tmpIoBuff[ii++]; + tmpSnd2WxBuff[jj++] = tmpIoBuff[ii++]; + tmpSnd2WxBuff[jj++] = tmpIoBuff[ii++]; + jj += 2; /* CRC */ + } + tmpSnd2WxLen = jj; + SndData2Wx(0xBA,tmpSnd2WxBuff,tmpSnd2WxLen); + wxCcov.Send((CHAR*)Snd2WxDataBuff,Snd2WxDataLen,wxIpconfigInfo->dstIpInfo->ip,wxIpconfigInfo->dstIpInfo->port); + } + + /* Э봦 */ + ProtclReceiveDataFunc(&gCbtcData); + + if (0 == (CycleNum % 2))/*FSFB2ЭΪ600ms,CIӦڵ2:1357....ڵFSFB2Э鴦*/ + { +#if 0 + /* LEU */ + QueueClear(&Fsfb_Info.OutnetQueueB); + QueueClear(&Fsfb_Info.OutnetQueueR); + QueueClear(&Fsfb_Info.DataToApp); + RcvDataFromSignalNet(&Fsfb_Info.OutnetQueueR,&(localCcov.redCCov)); + + + FsfbProtclReceiveData(&Fsfb_Info); +#endif + } + + + /* exten A */ + QueueClear(&extenARcvQue); + RcvDataFromSignalNetNoLen(&extenARcvQue,&extenACcov); + CiLog->Log("extend A rcv len:%d\n",QueueStatus(&extenARcvQue)); + + /* exten B */ + QueueClear(&extenBRcvQue); + RcvDataFromSignalNetNoLen(&extenBRcvQue,&extenBCcov); + CiLog->Log("extend B rcv len:%d\n",QueueStatus(&extenBRcvQue)); + + + /* exten c */ + QueueClear(&extenCRcvQue); + RcvDataFromSignalNetNoLen(&extenCRcvQue,&extenCCcov); + CiLog->Log("extend c rcv len:%d\n",QueueStatus(&extenCRcvQue)); + + /* յд빲ڴ */ + /* gCbtcData.DataToApp,Э鴦 */ + /* canQueueRecv,extenARcvQue,extenBRcvQue,extenCRcvQue */ + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenDataToApp = QueueStatus(&gCbtcData.DataToApp); + LongToChar(LenDataToApp,tmpMemoryBuff); + QueueScan(LenDataToApp,tmpMemoryBuff+4,&gCbtcData.DataToApp); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclInputMsg[LOCAL_IDX],tmpMemoryBuff,LenDataToApp+4); + CiLog->Log("ӦõݳΪ%d\n",LenDataToApp); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenCanRecv = QueueStatus(&canQueueRecv); + LongToChar(LenCanRecv,tmpMemoryBuff); + QueueScan(LenCanRecv,tmpMemoryBuff+4,&canQueueRecv); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryIoInputMsg[LOCAL_IDX],tmpMemoryBuff,LenCanRecv+4); + CiLog->Log("յIOݳΪ%d\n",LenCanRecv); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExARecv = QueueStatus(&extenARcvQue); + LongToChar(LenExARecv,tmpMemoryBuff); + QueueScan(LenExARecv,tmpMemoryBuff+4,&extenARcvQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendAInMsg[LOCAL_IDX],tmpMemoryBuff,LenExARecv+4); + CiLog->Log("չAյݳΪ%d\n",LenExARecv); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExBRecv = QueueStatus(&extenBRcvQue); + LongToChar(LenExBRecv,tmpMemoryBuff); + QueueScan(LenExBRecv,tmpMemoryBuff+4,&extenBRcvQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendBInMsg[LOCAL_IDX],tmpMemoryBuff,LenExBRecv+4); + CiLog->Log("չBյݳΪ%d\n",LenExBRecv); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExCRecv = QueueStatus(&extenCRcvQue); + LongToChar(LenExCRecv,tmpMemoryBuff); + QueueScan(LenExCRecv,tmpMemoryBuff+4,&extenCRcvQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendCInMsg[LOCAL_IDX],tmpMemoryBuff,LenExCRecv+4); + CiLog->Log("չCյݳΪ%d\n",LenExCRecv); + + + memset((UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX],STEP_INPUT,sizeof(UINT8));/*ϲд뱾ڴ棬ͬ־λ1*/ + + + CiLog->Log("״̬ȴԷһ̴...\n"); + /*ԷţȴԷһ̴ϡԷδִ*/ + WaitStep(STEP_INPUT); + + } + else /* */ + { + CiLog->Log("ȴ...\n"); + WaitStep(STEP_INPUT); + + /* ȴݲд乲ڴ洦Ϻ󣬲Ž洦 */ + /* ڴжȡдӦ */ + /* gCbtcData.DataToApp */ + /* canQueueRecv,extenARcvQue,extenBRcvQue,extenCRcvQue*/ + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 lenDataOfAppFromMain = 0; + lenDataOfAppFromMain = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclInputMsg[OTHER_IDX]); + memcpy(tmpMemoryBuff,(UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclInputMsg[OTHER_IDX],lenDataOfAppFromMain+4); + QueueClear(&gCbtcData.DataToApp); + QueueWrite(lenDataOfAppFromMain,&tmpMemoryBuff[4],&gCbtcData.DataToApp); + CiLog->Log("ڴȡӦݳΪ%d\n",lenDataOfAppFromMain); + + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 lenDataOfIoFromMain = 0; + lenDataOfIoFromMain = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryIoInputMsg[OTHER_IDX]); + memcpy(tmpMemoryBuff,(UINT8 *)CISHareMemoryStruct.AddressMemoryIoInputMsg[OTHER_IDX],lenDataOfIoFromMain+4); + QueueClear(&canQueueRecv); + QueueWrite(lenDataOfIoFromMain,&tmpMemoryBuff[4],&canQueueRecv); + CiLog->Log("ڴȡIOݳΪ%d\n",lenDataOfIoFromMain); + + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 lenDataOfExAFromMain = 0; + lenDataOfExAFromMain = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendAInMsg[OTHER_IDX]); + memcpy(tmpMemoryBuff,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendAInMsg[OTHER_IDX],lenDataOfExAFromMain+4); + QueueClear(&extenARcvQue); + QueueWrite(lenDataOfExAFromMain,&tmpMemoryBuff[4],&extenARcvQue); + CiLog->Log("ڴȡչAݳΪ%d\n",lenDataOfExAFromMain); + + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 lenDataOfExBFromMain = 0; + lenDataOfExBFromMain = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendBInMsg[OTHER_IDX]); + memcpy(tmpMemoryBuff,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendBInMsg[OTHER_IDX],lenDataOfExBFromMain+4); + QueueClear(&extenBRcvQue); + QueueWrite(lenDataOfExBFromMain,&tmpMemoryBuff[4],&extenBRcvQue); + CiLog->Log("ڴȡչBݳΪ%d\n",lenDataOfExBFromMain); + + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 lenDataOfExCFromMain = 0; + lenDataOfExCFromMain = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendCInMsg[OTHER_IDX]); + memcpy(tmpMemoryBuff,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendCInMsg[OTHER_IDX],lenDataOfExCFromMain+4); + QueueClear(&extenCRcvQue); + QueueWrite(lenDataOfExCFromMain,&tmpMemoryBuff[4],&extenCRcvQue); + CiLog->Log("ڴȡչCݳΪ%d\n",lenDataOfExCFromMain); + + + memset((UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX],STEP_INPUT,sizeof(UINT8));/*ӶԷڴȡϣͬ־λ1*/ + + } + CiLog->Log("ʼӦô...\n"); + startCount = GetTickCount(); + /*־ʱӡ*/ + PrintfNowTime(); + UINT8 mainRet = MainProcess(); + endCount = GetTickCount(); + + debug_infor_printf("MainProcess consume %d ms",endCount - startCount); + if (MAIN_FLAG == localMainStandBy) + { + /*д뱾ڴ*/ + /* gCbtcData.OutputDataQueue */ + /* canQueueSend,extenASndQue,extenBSndQue,extenCSndQue */ + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenDataToAppOver = QueueStatus(&gCbtcData.OutputDataQueue);/*AppArray飬Ƕ*/ + LongToChar(LenDataToAppOver,tmpMemoryBuff); + QueueScan(LenDataToAppOver,tmpMemoryBuff+4,&gCbtcData.OutputDataQueue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[LOCAL_IDX],tmpMemoryBuff,LenDataToAppOver+4); + CiLog->Log("ӦݳΪ%d\n",LenDataToAppOver); + CiLog->Log("Ӧݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[LOCAL_IDX],LenDataToAppOver); + + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenIoOver = QueueStatus(&canQueueSend); + LongToChar(LenIoOver,tmpMemoryBuff); + QueueScan(LenIoOver,tmpMemoryBuff+4,&canQueueSend); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryIoOutputMsg[LOCAL_IDX],tmpMemoryBuff,LenIoOver+4); + CiLog->Log("IOݳΪ%d\n",LenIoOver); + CiLog->Log("IOݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryIoOutputMsg[LOCAL_IDX],LenIoOver); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExAOver = QueueStatus(&extenASndQue); + LongToChar(LenExAOver,tmpMemoryBuff); + QueueScan(LenExAOver,tmpMemoryBuff+4,&extenASndQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendAOutMsg[LOCAL_IDX],tmpMemoryBuff,LenExAOver+4); + CiLog->Log("չAݳΪ%d\n",LenExAOver); + CiLog->Log("չAݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendAOutMsg[LOCAL_IDX],LenExAOver); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExBOver = QueueStatus(&extenBSndQue); + LongToChar(LenExBOver,tmpMemoryBuff); + QueueScan(LenExBOver,tmpMemoryBuff+4,&extenBSndQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendBOutMsg[LOCAL_IDX],tmpMemoryBuff,LenExBOver+4); + CiLog->Log("չBݳΪ%d\n",LenExBOver); + CiLog->Log("չBݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendBOutMsg[LOCAL_IDX],LenExBOver); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExCOver = QueueStatus(&extenCSndQue); + LongToChar(LenExCOver,tmpMemoryBuff); + QueueScan(LenExCOver,tmpMemoryBuff+4,&extenCSndQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendCOutMsg[LOCAL_IDX],tmpMemoryBuff,LenExCOver+4); + CiLog->Log("չCݳΪ%d\n",LenExCOver); + CiLog->Log("չCݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendCOutMsg[LOCAL_IDX],LenExCOver); + + memset((UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX],STEP_APP,sizeof(UINT8));/*Ӧôϣñͬ־λ2*/ + + CiLog->Log("״̬ȴԷӦô...\n"); + /*ȴԷڶ̴*/ + + } + else/**/ + { + /*д뱾ڴ*/ + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenDataToAppOver = QueueStatus(&gCbtcData.OutputDataQueue);/*AppArray飬Ƕ*/ + LongToChar(LenDataToAppOver,tmpMemoryBuff); + QueueScan(LenDataToAppOver,tmpMemoryBuff+4,&gCbtcData.OutputDataQueue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[LOCAL_IDX],tmpMemoryBuff,LenDataToAppOver+4); + CiLog->Log("ӦݳΪ%d\n",LenDataToAppOver); + CiLog->Log("Ӧݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[LOCAL_IDX],LenDataToAppOver); + + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenIoOver = QueueStatus(&canQueueSend); + LongToChar(LenIoOver,tmpMemoryBuff); + QueueScan(LenIoOver,tmpMemoryBuff+4,&canQueueSend); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryIoOutputMsg[LOCAL_IDX],tmpMemoryBuff,LenIoOver+4); + CiLog->Log("IOݳΪ%d\n",LenIoOver); + CiLog->Log("IOݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryIoOutputMsg[LOCAL_IDX],LenIoOver); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExAOver = QueueStatus(&extenASndQue); + LongToChar(LenExAOver,tmpMemoryBuff); + QueueScan(LenExAOver,tmpMemoryBuff+4,&extenASndQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendAOutMsg[LOCAL_IDX],tmpMemoryBuff,LenExAOver+4); + CiLog->Log("չAݳΪ%d\n",LenExAOver); + CiLog->Log("չAݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendAOutMsg[LOCAL_IDX],LenExAOver); + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExBOver = QueueStatus(&extenBSndQue); + LongToChar(LenExBOver,tmpMemoryBuff); + QueueScan(LenExBOver,tmpMemoryBuff+4,&extenBSndQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendBOutMsg[LOCAL_IDX],tmpMemoryBuff,LenExBOver+4); + CiLog->Log("չBݳΪ%d\n",LenExBOver); + CiLog->Log("չBݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendBOutMsg[LOCAL_IDX],LenExBOver); + + + memset(tmpMemoryBuff,(UINT8)0,BUF_SIZE); + UINT32 LenExCOver = QueueStatus(&extenCSndQue); + LongToChar(LenExCOver,tmpMemoryBuff); + QueueScan(LenExCOver,tmpMemoryBuff+4,&extenCSndQue); + memcpy((UINT8 *)CISHareMemoryStruct.AddressMemoryExtendCOutMsg[LOCAL_IDX],tmpMemoryBuff,LenExCOver+4); + CiLog->Log("չCݳΪ%d\n",LenExCOver); + CiLog->Log("չCݣ\n"); + debug_out_array(0,(UINT8 *)CISHareMemoryStruct.AddressMemoryExtendCOutMsg[LOCAL_IDX],LenExCOver); + + memset((UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX],STEP_APP,sizeof(UINT8));/*Ӧôϣñͬ־λ2*/ + + CiLog->Log("ȴԷӦô...\n"); + /*ȴԷڶ̴*/ + + + } + WaitStep(STEP_APP); + + /* Ƚϴ */ + if (MAIN_FLAG == localMainStandBy) + { + tmpOtherStep = GetOtherStepFlag(); + otherLieFlag = GetOtherLiveFlag(); + if(otherLieFlag == LIVE_ON)/*ȽǰжǷ񵥻ģʽLIVE_ON == otherLieFlag*/ + { + /*ȡĹڴݣ뱾Ƚ*/ + /*ֱȽϵIOӦǷһ*/ + + ioCmpFlag = IoCompare(); + + appCmpFlag = AppCompare(); + + + } + + + } + else if(STAND_BY_FLAG == localMainStandBy) + { + /*д뱾ڴ*/ + + if (otherLieFlag == LIVE_ON) + { + /*ӶԷڴȡݱȽϣȽһ*/ + /*ȡԷĹڴݣ뱾Ƚ*/ + /*ֱȽϵIOӦǷһ*/ + + ioCmpFlag = IoCompare(); + + appCmpFlag = AppCompare(); + + } + + } + else + { + + } + + /* + *Ƚһ£Ϊͣ + */ + /* */ + + if(MAIN_FLAG == localMainStandBy) + { + PackOcToCloudData(); + UINT16 recLen=0; + + LongToChar(0,gCbtcData.AppArray);/*AppArrayǰ4ֽdzȣ*/ + ProtclSendDataFunc(&gCbtcData);/*Э鷢ݣõAppArray*/ + + recLen=2+ShortFromChar(gCbtcData.RecordArray); + + CiLog->Log(" \nProtocolData :"); + debug_out_array(0xAA,(UINT8*)gCbtcData.RecordArray,recLen);/*ӡЭ*/ + + if (0 == (CycleNum % 2))/*FSFB2ЭΪ600ms,CIӦڵ2:1357....ڵFSFB2Э鴦*/ + { +#if 0 + /*ʹSFP*/ + LongToChar(0,Fsfb_Info.AppArray); + FsfbProtclOutPut(&Fsfb_Info);/*FSFBЭĹ,Ӧô֡*/ +#endif + } + + if (ioCmpFlag)/*IOȽһ¶*/ + { + CiLog->Log(" \nͿʼ :\n"); + SndIoData(); + + /* exten c */ + SndExtenCData(&extenASndQue,&extenACcov,extenAIpconfigInfo); + SndExtenCData(&extenBSndQue,&extenBCcov,extenBIpconfigInfo); + SndExtenCData(&extenCSndQue,&extenCCcov,extenCIpconfigInfo); + } + if (appCmpFlag)/*ӦݱȽһ¶*/ + { + /*Э֣TCP״̬TCP·ƱֽTCP·Ʊģ*/ + ProtclSendTcpCtrlFunc(&tcpBufLen,tcpBuf,&gCbtcData);/*ȡЭTCP·ϢϿָ03*/ + + /*Դ룬ΪЭ޷RSSP2Э*/ + tcpBufLen=0; + + for (i = 2; i < tcpBufLen; i = i + 5) + { + etcsId = (tcpBuf[i + 0] >> (8*3)) + (tcpBuf[i + 1] >> (8*2)) + (tcpBuf[i + 2] >> (8*1)) + (tcpBuf[i + 3] >> (8*0));/*ͨŽڵƣ+ID*/ + tTcpSta = tcpBuf[i + 4];/*TCP·0Ч1ӣ2ӣ3Ͽ*/ + if ((tTcpSta & 0x0f) == 0x03) + { + localCcov.rssp2BlueCcov.DeleteConnection(etcsId); + } + if ((tTcpSta & 0xf0) == 0x30) + {/*Ͽ*/ + localCcov.rssp2RedCcov.DeleteConnection(etcsId); + } + } + + SndCbtcPrtclByDevName(gCbtcData.AppArray);/*ͨſsendָ豸*/ + + if (0 == (CycleNum % 2))/*FSFB2ЭΪ600ms,CIӦڵ2:1357....ڵFSFB2Э鴦*/ + { + + SndFsfbPrtclByDevName(gCbtcData.AppArray);/*ָLEU*/ + + } + debug_infor_printf("HandleCiApp sended is %lu\n",GetTickCount()); + } + } + else + { + QueueClear(&extenASndQue); + QueueClear(&extenBSndQue); + QueueClear(&extenCSndQue); + } + + if ((ioCmpFlag == 0) || (appCmpFlag == 0) )/*Ƚʧ*/ + { + *(UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX] = STEP_END; + } + if (CI_ERROR == mainRet) + { + CiLog->Log("Ӧôʧ\n"); + *(UINT8 *)CISHareMemoryStruct.AddressMemorySystemStepFlag[LOCAL_IDX] = STEP_END; + } + + /*ͷԴ*/ + delete mapDevTcpSta; +} + +/* +* IOݷ +*/ +void SndIoData() +{ + UINT32 totalLen = 0; + UINT8 ret = 0; + totalLen = QueueStatus(&canQueueSend); + ret = QueueRead(totalLen,sndBuff,&canQueueSend); + if (totalLen > 0 && ret == 1) + { + ioCcov.Send((CHAR *)sndBuff,totalLen,ioIpconfigInfo->dstIpInfo->ip,ioIpconfigInfo->dstIpInfo->port); + INT16 ii = 0,jj =0; + UINT8 sndSeq = 0; + tmpSnd2WxLen = 0; + sndSeq++; + while (ii < totalLen) + { + tmpSnd2WxBuff[jj++] = sndBuff[ii++]; + tmpSnd2WxBuff[jj++] = 0xc8; + tmpSnd2WxBuff[jj++] = sndSeq; + tmpSnd2WxBuff[jj++] = sndBuff[ii++]; + tmpSnd2WxBuff[jj++] = sndBuff[ii++]; + tmpSnd2WxBuff[jj++] = 0; + tmpSnd2WxBuff[jj++] = 0; + tmpSnd2WxBuff[jj++] = 0; + jj += 2; + } + tmpSnd2WxLen = jj; + SndData2Wx(0xCA,tmpSnd2WxBuff,tmpSnd2WxLen); + wxCcov.Send((CHAR*)Snd2WxDataBuff,Snd2WxDataLen,wxIpconfigInfo->dstIpInfo->ip,wxIpconfigInfo->dstIpInfo->port); + } + else + { + + } + CiLog->Log("IO snd Len:%d \n",totalLen); + + +} + +/* +* ExtenCݷ +*/ +void SndExtenCData(QueueStruct *pSndQue,CComm *pSndCcov,IpConfigInfoStru *pIpConfig) +{ + UINT32 totalLen = 0; + UINT8 ret = 0; + totalLen = QueueStatus(pSndQue); + ret = QueueRead(totalLen,sndBuff,pSndQue); + if (totalLen > 0 && ret == 1) + { + pSndCcov->Send((CHAR *)sndBuff,totalLen,pIpConfig->dstIpInfo->ip,pIpConfig->dstIpInfo->port); + } + else + { + + } + CiLog->Log("exten %s snd Len:%d\n",pIpConfig->name,totalLen); + +} +/* +* +*/ +#if 0 +void SndSfpData(UINT8 *sfpSndDataBuff) +{ + UINT32 index = 0; + UINT32 redIpA = 0,redIpB =0; + UINT16 redPortA=0,redPortB = 0; + UINT16 sndDataLen = 0; + UINT32 totalLen = 0; + UINT8 *pData = sfpSndDataBuff +4; + index += 4; + totalLen = LongFromChar(pData); + index += 4; + debug_out_array(0,(CHAR*)sfpSndDataBuff,totalLen+8); + do + { + /* ǰĸֽΪܳȰ·״̬Ϣ,ĸֽڲʵ */ + sndDataLen = RedSndUnPack(sfpSndDataBuff,sndBuff,&index,totalLen,&redIpA,&redPortA,&redIpB,&redPortB); + if (sndDataLen > 0) + { + if (redIpA > 0 && redPortA > 0 ) + { + CiLog->Log("sfp A:"); + SndData2SignalNet(redIpA,redPortA,sndBuff,sndDataLen,&sfpCcov); + } + + if (redIpB > 0 && redPortB > 0 ) + { + CiLog->Log("sfp B:"); + SndData2SignalNet(redIpB,redPortB,sndBuff,sndDataLen,&sfpCcov); + } + } + } while (sndDataLen > 0); + +} +#endif +/* +* ЭӦ +* +*/ +void SndCbtcPrtcl(UINT8 *spfbSndDataBuff) +{ + UINT32 index = 0; + UINT32 redIpA = 0,redIpB =0; + UINT16 redPortA=0,redPortB = 0; + UINT16 sndDataLen = 0; + UINT32 totalLen = 0; + UINT8 *pData = spfbSndDataBuff; + CComm *pTmpCcov = NULL; + totalLen = LongFromChar(pData); + index +=4; + do + { + /* 2ֽܳȣ */ + sndDataLen = RedSndUnPack(spfbSndDataBuff,sndBuff,&index,totalLen,&redIpA,&redPortA,&redIpB,&redPortB,&pTmpCcov); + if (sndDataLen > 0 && pTmpCcov != NULL) + { + if (redIpA > 0 && redPortA > 0 ) + { + SndData2SignalNet(redIpA,redPortA,sndBuff,sndDataLen,pTmpCcov); + } + + if (redIpB > 0 && redPortB > 0 ) + { + SndData2SignalNet(redIpB,redPortB,sndBuff,sndDataLen,pTmpCcov); + } + } + } while (sndDataLen > 0); + +} + + + +/* +ýRedSndUnPackNew()ȡЭͺĿ +1 ЭͻȡӦͨſֻSFPRSSPЭ飩:1:sfpCcov,1:rsspCcov +2 ĿͣIDȡԷIPͶ˿ڣȲ +3 ʹͨſsendݡsendSndData2SignalNet +*/ +void SndCbtcPrtclByDevName(UINT8 *spfbSndDataBuff) +{ + UINT32 index = 0; + UINT16 sndDataLen = 0; + UINT32 totalLen = 0; + UINT8 *pData = spfbSndDataBuff; + CComm *pRedCcov = NULL; + CComm *pBlueCcov = NULL; + CComm *pAtsRedCcov = NULL; + CComm *pAtsBlueCcov = NULL; + UINT16 DeviceName = 0; + UINT8 cDstType = 0u; + UINT8 cDstId = 0u; + UINT16 LogicId = 0; + UINT8 protocalType = 0; + IpInfo ipInfoList[8]; + IpInfo atsBackUpIpInfoList[8]; + UINT8 dstNum;/*ĿIPĿ*/ + UINT8 findFlag = 1; + UINT8 i_dstNum = 0; + UINT8 ccovIdx = 0; + unsigned char udpCcovFlag = 0; + unsigned char rssp2CcovFlag = 0; + UINT64 startTickCount = 0; + UINT64 endTickCount = 0; + UINT8 temSendBuf[4096] = { 0U }; + UINT32 t_OffSet = 0U; + UINT32 t_LenPos = 0U; + UINT16 wGatewayId = 0U; + UINT16 wBackUpVobcId = 0U; + UINT8 chIteNum = 0U; + UINT8 chAtsBackUpNum = 0U; + struct timeval curTimeStamp; + memset(ipInfoList,DEFAULT_ZERO,sizeof(ipInfoList)); + + totalLen = LongFromChar(pData);/*Ϊ4ֽڣ²װ󴫸ϲ*/ + index += 4; + /*ýȡЭͺĿ*/ + do + { + sndDataLen = RedSndUnPackNew(spfbSndDataBuff, sndBuff, &index, totalLen, &DeviceName, &LogicId, &protocalType); + if (sndDataLen > 0) + { + /* ЭͻȡӦͨſ*/ + udpCcovFlag = 0; + rssp2CcovFlag = 0; + /*#include "..\\Prtcl\protocol_cbtc\dqu_protocol_cbtc_cpk\dsuProtclFun.h"*/ + if (protocalType == DSU_PROTCL_SFP) + { + /*pRedCcov = &sfpCcov;*/ + ccovIdx = SFP_IDX; + udpCcovFlag=1; + } + else if (protocalType == DSU_PROTCL_RP ) + { + ccovIdx = RP_IDX; + udpCcovFlag=1; + } + else if ((protocalType == DSU_PROTCL_RSSP) || (protocalType == DSU_PROTCL_RSR)) + { + ccovIdx = RSSP1_IDX; + udpCcovFlag=1; + } + else if(protocalType == DSU_PROTCL_RSSP2)/*ijɺ*/ + { + rssp2CcovFlag = 1; + } + else + { + /*ֵ˵ͨſڣ*/ + break; + } + + if (1 == udpCcovFlag) + { + cDstId = (UINT8)(DeviceName & 0x00FF); + cDstType = (UINT8)((DeviceName & 0xFF00) >> 8); + wGatewayId = GetTiocTrnsmtGtwyDevTypeId(); + wBackUpVobcId = GetATSInterfaceTypeId(); + if (DeviceName == wGatewayId) + { + pRedCcov = &(localCcov.redCcov[ccovIdx]); + pBlueCcov = &(localCcov.blueCcov[ccovIdx]); + } + else if ((1 == localCcov.ciInAts) && (0x03u == cDstType)) + { + pRedCcov = &(localCcov.atsRedCcov[ccovIdx]); + pBlueCcov = &(localCcov.atsBlueCcov[ccovIdx]); + + } + else if ((1 == localCcov.xdInAts) && (0x4du == cDstType)) + { + pRedCcov = &(localCcov.atsRedCcov[ccovIdx]); + pBlueCcov = &(localCcov.atsBlueCcov[ccovIdx]); + } + else if ((1 == localCcov.OcInCi) && (0x64 == cDstType)) + { + /* OCݣOCip */ + pRedCcov = &(localCcov.ocRedCcov); + pBlueCcov = &(localCcov.ocBlueCcov); + } + else if (CI_SYSTEM_TYPE_VOBC_BACKUP == cDstType) + { + pRedCcov = &(localCcov.atsRedCcov[ccovIdx]); + pBlueCcov = &(localCcov.atsBlueCcov[ccovIdx]); + DeviceName = wBackUpVobcId; + } + else if (CI_SYSTEM_TYPE_ITE == cDstType) + { + if (1U == LogicId) + { + pRedCcov = &(localCcov.redCcov[ccovIdx]); + pBlueCcov =&(localCcov.atsRedCcov[ccovIdx]); + } + else + { + pRedCcov = &(localCcov.atsBlueCcov[ccovIdx]); + pBlueCcov = &(localCcov.blueCcov[ccovIdx]); + } + pAtsRedCcov = &(localCcov.atsRedCcov[ccovIdx]); + pAtsBlueCcov = &(localCcov.atsBlueCcov[ccovIdx]); + } + else + { + pRedCcov = &(localCcov.redCcov[ccovIdx]); + pBlueCcov = &(localCcov.blueCcov[ccovIdx]); + } + + /* ĿͺIDȡԷIPͶ˿*/ + /*GetIpAndPortByDeviceName()ͺIPͶ˿ڶ*/ + if (CI_SYSTEM_TYPE_ITE == cDstType) + { + GetNetEndPoint(DeviceName, LogicId, ccovIdx, ipInfoList, &chIteNum); + GetNetEndPoint(wBackUpVobcId, 0, ccovIdx, atsBackUpIpInfoList, &chAtsBackUpNum); + findFlag = 3; + } + else + { + findFlag = GetNetEndPoint(DeviceName, LogicId, ccovIdx, ipInfoList, &dstNum); + } + if (findFlag == 0) + { + /*find fail,do nothing*/ + } + else if (findFlag == 1) + { + /* Ŀͨͨſݷͳȥ,ݷͺ */ + for (i_dstNum = 0; i_dstNum < dstNum; i_dstNum++) + { + startTickCount = GetTickCount(); + SndData2SignalNet(ipInfoList[i_dstNum].redIp, ipInfoList[i_dstNum].redPort, sndBuff, sndDataLen, pRedCcov); + SndData2SignalNet(ipInfoList[i_dstNum].blueIp, ipInfoList[i_dstNum].bluePort, sndBuff, sndDataLen, pBlueCcov); + endTickCount = GetTickCount(); + debug_infor_printf("Snd to %04x,consume %d ms.\r\n", DeviceName, endTickCount - startTickCount); + } + } + else if (2 == findFlag)/* Ʋҵǰdz豸ʱ */ + { + gettimeofday(&curTimeStamp, NULL); + + /* */ + t_OffSet = 0; + memset(&temSendBuf[0], 0, 1024 * 2); + + temSendBuf[t_OffSet] = 0xAA;/* ֡ʼ־ */ + t_OffSet += 1; + t_LenPos = t_OffSet;/* ¼λ֡ */ + t_OffSet += 2; + temSendBuf[t_OffSet] = 2;/* ҵݰ */ + t_OffSet += 1; + LongToChar(curTimeStamp.tv_sec, &temSendBuf[t_OffSet]);/* ʱǰֽ */ + t_OffSet += 4; + LongToChar(curTimeStamp.tv_usec, &temSendBuf[t_OffSet]);/* ʱֽ */ + t_OffSet += 4; + LongToChar(ipInfoList[1].redIp, &temSendBuf[t_OffSet]);/* ͶԭʼIP */ + t_OffSet += 4; + ShortToChar(ipInfoList[1].redPort, &temSendBuf[t_OffSet]);/* Ͷԭʼ˿ں */ + t_OffSet += 2; + LongToChar(ipInfoList[2].redIp, &temSendBuf[t_OffSet]);/* նԭʼIP */ + t_OffSet += 4; + ShortToChar(ipInfoList[2].redPort, &temSendBuf[t_OffSet]);/* նԭʼ˿ں */ + t_OffSet += 2; + memcpy(&temSendBuf[t_OffSet], &sndBuff[0], sndDataLen); + t_OffSet += sndDataLen; + temSendBuf[t_OffSet] = 0x55;/* ֡Ľʶ */ + t_OffSet += 1; + ShortToChar((t_OffSet - 3), &temSendBuf[t_LenPos]);/* ֡ */ + + SndData2SignalNet(ipInfoList[0].redIp, ipInfoList[0].redPort, &temSendBuf[0], t_OffSet, pRedCcov); + + + /* */ + t_OffSet = 0; + memset(&temSendBuf[0], 0, 1024 * 2); + + temSendBuf[t_OffSet] = 0xAA;/* ֡ʼ־ */ + t_OffSet += 1; + t_LenPos = t_OffSet;/* ¼λ֡ */ + t_OffSet += 2; + temSendBuf[t_OffSet] = 2;/* ҵݰ */ + t_OffSet += 1; + LongToChar(curTimeStamp.tv_sec, &temSendBuf[t_OffSet]);/* ʱǰֽ */ + t_OffSet += 4; + LongToChar(curTimeStamp.tv_usec, &temSendBuf[t_OffSet]);/* ʱֽ */ + t_OffSet += 4; + LongToChar(ipInfoList[1].blueIp, &temSendBuf[t_OffSet]);/* ͶԭʼIP */ + t_OffSet += 4; + ShortToChar(ipInfoList[1].bluePort, &temSendBuf[t_OffSet]);/* Ͷԭʼ˿ں */ + t_OffSet += 2; + LongToChar(ipInfoList[2].blueIp, &temSendBuf[t_OffSet]);/* նԭʼIP */ + t_OffSet += 4; + ShortToChar(ipInfoList[2].bluePort, &temSendBuf[t_OffSet]);/* նԭʼ˿ں */ + t_OffSet += 2; + memcpy(&temSendBuf[t_OffSet], &sndBuff[0], sndDataLen); + t_OffSet += sndDataLen; + temSendBuf[t_OffSet] = 0x55;/* ֡Ľʶ */ + t_OffSet += 1; + ShortToChar((t_OffSet - 3), &temSendBuf[t_LenPos]);/* ֡ */ + + SndData2SignalNet(ipInfoList[0].blueIp, ipInfoList[0].bluePort, &temSendBuf[0], t_OffSet, pBlueCcov); + } + else if(3==findFlag) + { + /*ͨҪȥ14 ͨЭͷ*/ + CommonMemCpy(temSendBuf, sizeof(temSendBuf), &sndBuff[14], sndDataLen - 14); + for (i_dstNum = 0; i_dstNum < chIteNum; i_dstNum++) + { + startTickCount = GetTickCount(); + if (1 == LogicId) + { + SndData2SignalNet(ipInfoList[i_dstNum].redIp, ipInfoList[i_dstNum].redPort, temSendBuf, sndDataLen-14, pRedCcov); + } + else if(2 == LogicId) + { + SndData2SignalNet(ipInfoList[i_dstNum].blueIp, ipInfoList[i_dstNum].bluePort, temSendBuf, sndDataLen - 14, pBlueCcov); + } + else + { + ; + } + endTickCount = GetTickCount(); + debug_infor_printf("Snd to %04x,consume %d ms.\r\n", DeviceName, endTickCount - startTickCount); + } + for (i_dstNum = 0; i_dstNum < chAtsBackUpNum; i_dstNum++) + { + startTickCount = GetTickCount(); + + SndData2SignalNet(atsBackUpIpInfoList[i_dstNum].blueIp, atsBackUpIpInfoList[i_dstNum].bluePort, sndBuff, sndDataLen, pAtsBlueCcov); + + SndData2SignalNet(atsBackUpIpInfoList[i_dstNum].redIp, atsBackUpIpInfoList[i_dstNum].redPort, sndBuff, sndDataLen, pAtsRedCcov); + + endTickCount = GetTickCount(); + debug_infor_printf("Snd to %04x,consume %d ms.\r\n", DeviceName, endTickCount - startTickCount); + } + } + else + { + + } + + + } + + if(1 == rssp2CcovFlag) + { + debug_infor_printf("rssp2 data send is %lu\n",GetTickCount()); + /*ͨRSSP2Э*/ + localCcov.rssp2BlueCcov.Send(DeviceName, LogicId, sndBuff, sndDataLen); + localCcov.rssp2RedCcov.Send(DeviceName,LogicId, sndBuff, sndDataLen); + } + } + } while (sndDataLen >0); +} + +/* +* @ ֡лȡһ֡ +* +* in sfpbuff 鱨ݣIPַ +* out sdnBuff ݻ +* inout index ǰ± ʼַ +* in totalLen ܳ +* out redIpA IPַ +* out redPortA ˿ں +* out redIpB ַB +* out redPortB ַ˿B +* return: 0 :޷ 0ݳ +*/ +UINT16 RedSndUnPack(UINT8 *sfpBuff,UINT8 *sndBuff,UINT32 *index,UINT32 totalLen, + UINT32 *redIpA,UINT16 *redPortA, + UINT32 *redIpB,UINT16 *redPortB) +{ + UINT32 tempIndex = 0; /* Ѱַ */ + UINT16 dataLen = 0; /* ֡ݳ */ + UINT16 sndLen = 0; /* ݳ */ + UINT16 iLen = 0; + UINT16 indexStart = 0; /* ¼ ʼ±꣬ */ + + + UINT8 sendIpCount = 0; + + + /*totalLen = LongFromChar(&sfpBuff[4]);*/ + tempIndex = *index; + + *redIpA = 0; + *redIpB = 0; + *redPortA = 0; + *redPortB = 0; + /* Ѱַ򳤶Ч */ + if ((totalLen <= tempIndex) || (totalLen<28)) + { + /* ݽ */ + sndLen = 0; + return sndLen; + } + else + { + + /* */ + /* ֽڳ */ + dataLen = ShortFromChar(&sfpBuff[tempIndex]); + if (dataLen > 28) + { + /* Ѱַ+2ֽ */ + tempIndex = tempIndex+2; + + indexStart = tempIndex; /* ¼Ⱥindexdatalen - (tmpIndex - indexStart)*/ + /* Ŀַ */ + /*Ͷ*/ + sendIpCount = sfpBuff[tempIndex]; + tempIndex = tempIndex+1; + + + /*A˿*/ + *redPortA = ShortFromChar(&sfpBuff[tempIndex]); + /* Ѱַ+˿2ֽ */ + tempIndex = tempIndex+2; + + /*Aַ*/ + *redIpA = LongFromChar(&sfpBuff[tempIndex]); + /* Ѱַ+˿4ֽ */ + tempIndex = tempIndex+4; + + /* ѰַIP+˿6ֽ */ + tempIndex = tempIndex+6; + + + if (sendIpCount == 2) + { + /*B˿*/ + *redPortB = ShortFromChar(&sfpBuff[tempIndex]); + /* Ѱַ+˿2ֽ */ + tempIndex = tempIndex+2; + + /*Bַ*/ + *redIpB = LongFromChar(&sfpBuff[tempIndex]); + /* Ѱַ+˿4ֽ */ + tempIndex = tempIndex+4; + + /* ѰַIP+˿6ֽ */ + tempIndex = tempIndex+6; + } + else if (sendIpCount > 2) + { + tempIndex = tempIndex + (sendIpCount-1)*12; + } + else + { + /*tempIndex*/ + } + + + /* Դַ */ + + /*Ͷ*/ + sendIpCount = sfpBuff[tempIndex]; + tempIndex = tempIndex+1; + + + /* Ѱַ+˫˿ڵַ12ֽ */ + tempIndex = tempIndex+12; + + + if (sendIpCount > 1) + { + tempIndex = tempIndex + (sendIpCount-1)*12; + } + + + /* */ + /*sndLen = ShortFromChar(&sfpBuff[tempIndex]) + 2;*/ + sndLen = dataLen - (tempIndex - indexStart); + + for(iLen = 0; iLen < sndLen; iLen++) + { + sndBuff[iLen] = sfpBuff[tempIndex++]; + } + /*Ѱַ*/ + *index = tempIndex; + /*ȷ*/ + return sndLen; + } + else + { + /**/ + return 0; + } + } +} + +UINT16 RedSndUnPack(UINT8 *sfpBuff,UINT8 *sndBuff,UINT32 *index,UINT32 totalLen, + UINT32 *redIpA,UINT16 *redPortA, + UINT32 *redIpB,UINT16 *redPortB,CComm **pCcov) +{ + UINT32 tempIndex = 0; /* Ѱַ */ + UINT16 dataLen = 0; /* ֡ݳ */ + UINT16 sndLen = 0; /* ݳ */ + UINT16 iLen = 0; + UINT16 indexStart = 0; /* ¼ ʼ±꣬ */ + UINT16 localPortARed = 0; + UINT16 localPortBRed = 0; + + UINT8 sendIpCount = 0; + + + /*totalLen = LongFromChar(&sfpBuff[4]);*/ + tempIndex = *index; + + *redIpA = 0; + *redIpB = 0; + *redPortA = 0; + *redPortB = 0; + + sndLen = RedSndUnPack(sfpBuff,sndBuff,index,totalLen,redIpA,redPortA,redIpB,redPortB); + /* Ѱַ򳤶Ч */ + if (sndLen <= 0) + { + /* ݽ */ + sndLen = 0; + return sndLen; + } + + else + { + + /* */ + /* ֽڳ */ + + /* Ѱַ+2ֽ */ + tempIndex = tempIndex+2; + + indexStart = tempIndex; /* ¼Ⱥindexdatalen - (tmpIndex - indexStart)*/ + /* Ŀַ */ + /*Ͷ*/ + sendIpCount = sfpBuff[tempIndex]; + tempIndex = tempIndex+1; + + + /*A˿*/ + + /* Ѱַ+˿2ֽ */ + tempIndex = tempIndex+12; + + + if (sendIpCount == 2) + { + /*B˿*/ + + /* Ѱַ+˿2ֽ */ + tempIndex = tempIndex+2; + + /*Bַ*/ + + /* Ѱַ+˿4ֽ */ + tempIndex = tempIndex+4; + + /* ѰַIP+˿6ֽ */ + tempIndex = tempIndex+6; + } + else if (sendIpCount > 2) + { + tempIndex = tempIndex + (sendIpCount-1)*12; + } + else + { + /*tempIndex*/ + } + + + /* Դַ */ + + /*Ͷ*/ + sendIpCount = sfpBuff[tempIndex]; + tempIndex = tempIndex+1; + + + /* Ѱַ+˫˿ڵַ12ֽ */ + /* Ѱַ+˿2ֽ */ + localPortARed = ShortFromChar(&sfpBuff[tempIndex]); + + tempIndex = tempIndex+12; + + if (sendIpCount > 1) + { + localPortBRed = ShortFromChar(&sfpBuff[tempIndex]); + tempIndex = tempIndex + (sendIpCount-1)*12; + } + stdext::hash_map :: const_iterator ccovIter = ccovList.find(localPortARed); + if (ccovIter != ccovList.end()) + { + *pCcov = ccovIter->second; + } + else + { + ccovIter = ccovList.find(localPortBRed); + if (ccovIter != ccovList.end()) + { + *pCcov = ccovIter->second; + } + else + { + *pCcov = NULL; + } + } + + /*ȷ*/ + return sndLen; + } +} + + + +/* +*sfpBuff in ЭݸʽĿͺID豸ƣ +* totalLen in ܳ +*sndBuff out ʵ緢ݣͨ˺ +* DevName out 豸ͺIDҪݴ˻ȡĿIPͶ˿ +* prtclType out ЭͣҪЭͻȡͨſ,ԭֻSFPRSSP +*index inout ǰ±꣬ʼַ +*ڿЭ飺SFP,RP,RSSP 20150428 +*ֵΪݵijȣϲ㷢 +*/ + +UINT16 RedSndUnPackNew(UINT8 *sfpBuff,UINT8 *sndBuff,UINT32 *index,UINT32 totalLen,UINT16 *DevName, UINT16 *LogicId, UINT8 *prtclType) +{ + UINT16 dataLen = 0;/*֡ݳ*/ + UINT32 tempIndex = 0;/*洢indexֵ*/ + UINT16 sendLen = 0;/*ݳ,ֵ*/ + UINT16 i_sendLen = 0; + UINT32 indexStart = 0; + UINT16 send_backupindex = 0U; + UINT16 ats_sendLen = 0U; + UINT16 ats_sendLendress = 0U; + UINT32 curCycleNum = 0U; + UINT8 localCiId = 0U; /*ID*/ + UINT16 srcId = 0U; + + tempIndex = *index; + + /*οԭнݺѰַ򳤶Ч2Э1ĿͺID2Ԥ2n*/ + if ((totalLen <= tempIndex)||(totalLen < 7)) + { + sendLen = 0; + return sendLen; + } + else + { + /**/ + + /*Эݰʽǰֽڴ*/ + dataLen = ShortFromChar(&sfpBuff[tempIndex]); + if (dataLen > 7) + { + /*Ѱַ+ֽ*/ + tempIndex = tempIndex+2; + indexStart = tempIndex;/*¼Ⱥindex,ݳsendLen=dataLen-(tempIndex-indexStart)*/ + + /*Эͣ1ֽ*/ + *prtclType = sfpBuff[tempIndex]; + tempIndex = tempIndex+1; + + /*豸ƣ+ID),2ֽ*/ + *DevName = ShortFromChar(&sfpBuff[tempIndex]); + tempIndex = tempIndex+2; + + /*߼ID,2ֽ*/ + *LogicId = ShortFromChar(&sfpBuff[tempIndex]); + tempIndex = tempIndex+2; + + if ((CI_SYSTEM_TYPE_VOBC_BACKUP *256U) == (*DevName & 0xff00)||(CI_SYSTEM_TYPE_ITE * 256U) == (*DevName & 0xff00)) + { + ats_sendLendress = send_backupindex; /*ȵַ*/ + send_backupindex += 2U; + + curCycleNum = Get2oo2CurCycleNum(); + LongToChar(curCycleNum, &sndBuff[send_backupindex]); + send_backupindex += 4U; + ats_sendLen += 4U; + + localCiId = GetSystemParaLocalCiId(); /*ԴID*/ + srcId = (UINT16)((CI_SYSTEM_TYPE_CI * 256) + localCiId); + ShortToChar(srcId, &sndBuff[send_backupindex]); + send_backupindex += 2U; + ShortToChar(0U, &sndBuff[send_backupindex]); + send_backupindex += 2U; + ats_sendLen += 4U; + + ShortToChar(*DevName, &sndBuff[send_backupindex]); /*ĿID*/ + send_backupindex += 2U; + ats_sendLen += 2U; + ShortToChar(*LogicId, &sndBuff[send_backupindex]); /*ĿID*/ + send_backupindex += 2U; + ats_sendLen += 2U; + + } + + sendLen = dataLen-(tempIndex-indexStart); + + if ((CI_SYSTEM_TYPE_VOBC_BACKUP * 256U) == (*DevName & 0xff00) || (CI_SYSTEM_TYPE_ITE * 256U) == (*DevName & 0xff00)) + { + sendLen += ats_sendLen; /*سǰһǷҪӸATSݳ*/ + ShortToChar(sendLen, &sndBuff[ats_sendLendress]);/*¼*/ + sendLen += 2U; /*ϳȵֽ*/ + } + + /*ݵݻ*/ + for (i_sendLen = send_backupindex;i_sendLen < sendLen; i_sendLen++) + { + sndBuff[i_sendLen] = sfpBuff[tempIndex++]; + } + + /*indexѭԶڽһ֡*/ + *index = tempIndex; + /*Ҫ͵ݳ*/ + return sendLen; + } + else + { + return 0; + } + + } + +} + +static void RcvDataFromRssp2Ccov(QueueStruct *pQue,Ccov_RsspII *rssp2Ccov) +{ + unsigned char rcvBuf[1024*10];//ʱ + int rLen; + rLen = rssp2Ccov->ReadData(rcvBuf,sizeof(rcvBuf)); + + QueueWrite(rLen,rcvBuf,pQue); +} + +/* +* ָжȡΧ +*/ +UINT8 RcvDataFromSignalNet(QueueStruct *pQue,CComm *ccov) +{ + UINT8 ret = 1; + UINT8 ret_rcv = 0,len_byte[2]={0}; + UINT16 len = 0; + UINT8 rcv_buff[1024*10]; + if(ccov == NULL||pQue ==NULL) + { + return ret; + } + do + { + len =0; + /* ȡһ֡*/ + ret_rcv = ccov->ReadData(&len,rcv_buff); + if(ret_rcv>0) + { + ret = QueueWrite(len,rcv_buff,pQue); + if(ret != 1) + { + ret = 0; + break; + } + } + + } while(ret_rcv !=0); + + return ret; +} + +/* +* ָжȡΧݣݳ +*/ +UINT8 RcvDataFromSignalNetNoLen(QueueStruct *pQue,CComm *ccov) +{ + UINT8 ret = 1; + UINT8 ret_rcv = 0,len_byte[2]={0}; + UINT16 len = 0; + UINT8 rcv_buff[1024*10]; + if(ccov == NULL||pQue ==NULL) + { + return ret; + } + do + { + len =0; + /* ȡһ֡*/ + ret_rcv = ccov->ReadData(&len,rcv_buff); + if(ret_rcv>0) + { + ret = QueueWrite(len-2,rcv_buff+2,pQue); + if(ret != 1) + { + ret = 0; + break; + } + } + + } while(ret_rcv !=0); + + return ret; +} + + +UINT8 SndData2SignalNet(UINT32 ip,UINT16 port,const UINT8 *pData,UINT16 len,CComm *ccov) +{ + UINT8 ret =0; + CHAR host_str[20]; + UINT8 ipAddr[4]; + + LongToChar(ip,ipAddr); + + sprintf(host_str,"%d.%d.%d.%d", + ipAddr[0], + ipAddr[1], + ipAddr[2], + ipAddr[3]); + CiLog->Log(" snd %s port:%u ",host_str,port); + debug_out_array(0,(UINT8 *)pData,len); + CiLog->Log("\n"); + ret = ccov->Send((CHAR *)pData,len,host_str,port); + + if(ret != 1) + { + return ret; + } + return ret; +} +CHAR tmpPrintBuf[4*1024]; +/*غ*/ +extern "C" void debug_infor_printf( + char* debug_string, /*ʵCеprintfĹ,ƽ̨ĵӡ*/ + ...) +{ + va_list para; + UINT8 ret= 0; + UINT32 len = 0; + + va_start(para,debug_string); + len = vsprintf(tmpPrintBuf,debug_string,para); + tmpPrintBuf[len] = 0; + CiLog->Log((char*)tmpPrintBuf); + +} + +extern "C" void DarkInfoPack(UINT16 mode, UINT8* debug_array, UINT16 len) +{ + ; +} +extern "C" void debug_out_array(UINT8 mode, UINT8* debug_array, UINT16 len) +{ + char msgBuf[1024 * 1024] = { '\0' }; + UINT16 indexChar = 0U; + + if(mode != 0x10 ) + { + INT32 ii = 0; + if (mode != 0) + { + CiLog->Log("\n"); + + } + + for (ii = 0U; ii < len; ii++) + { + /*ֽ(16)תΪַ飬ٴ*/ + /*ֽڲλ'0'*/ + if (ii == len - 1) + { + indexChar += sprintf(msgBuf + indexChar, "%02x", debug_array[ii]); + } + else + { + indexChar += sprintf(msgBuf + indexChar, "%02x-", debug_array[ii]); + } + } + CiLog->Log(msgBuf); + CiLog->Log("\n"); + } + else + { + if (len > 0) + { + SndData2Wx(mode,(const UINT8 *)debug_array,len); + CiLog->Log("snd 2 wx len: %d %d \n",Snd2WxDataLen,len); + if(MAIN_FLAG == localMainStandBy) + { + wxCcov.Send((CHAR*)Snd2WxDataBuff,Snd2WxDataLen,wxIpconfigInfo->dstIpInfo->ip,wxIpconfigInfo->dstIpInfo->port); + } + } + + } + + if ( + (mode==(char)0xaa) && (*(debug_array)==(char)0xab) && (*(debug_array+1)==(char)0xcd ) || + (mode ==(char)0x10) || (mode ==(char)0x20) || (mode ==(char)0x21) + ) + { + /*ͨ緢ȥ*/ + if (len > 0) + { + SndData2Wx(mode,(const UINT8 *)debug_array,len); + CiLog->Log("snd 2 wx len: %d %d \n",Snd2WxDataLen,len); + if(MAIN_FLAG == localMainStandBy) + { + wxCcov.Send((CHAR*)Snd2WxDataBuff,Snd2WxDataLen,wxIpconfigInfo->dstIpInfo->ip,wxIpconfigInfo->dstIpInfo->port); + } + } + } + + if ( + (mode ==(char)0x10) + ) + { + /*ͨ緢ȥ*/ + if (len > 0) + { + SndData2Wx(mode,(const UINT8 *)debug_array,len); + CiLog->Log("snd 2 wx len: %d %d \n",Snd2WxDataLen,len); + if(MAIN_FLAG == localMainStandBy) + { + wxCcov.Send((CHAR*)Snd2WxDataBuff,Snd2WxDataLen,wxIpconfigInfo->dstIpInfo->ip,5001);/*վ״̬͵5001˿*/ + } + } + } + + return ; +} + +extern "C" INT8 debug_out_array_for_lw_and_ats(char mode, char* debug_array, short len) +{ + + char timeArr[34]; + + SYSTEMTIME sys_T; + GetSystemTime(&sys_T); + sprintf_s(timeArr,"%04d-%02d-%02dT%02d:%02d:%02d.%07d+08:00",sys_T.wYear,sys_T.wMonth,sys_T.wDay,sys_T.wHour,sys_T.wMinute,sys_T.wSecond,sys_T.wMilliseconds); + + if(mode != 0x10) + { + INT32 ii = 0; + if (mode != 0) + { + CiLog->Log("\n"); + CiLog->Log(timeArr); + } + + for (ii =0;ii < len;ii++) + { + if (ii >0) + { + CiLog->Log("-"); + } + CiLog->Log("%02x",(UINT8)debug_array[ii]); + } + CiLog->Log("\n"); + } + else + { + if (len > 0) + { + SndData2Wx(mode,(const UINT8 *)debug_array,len); + CiLog->Log("snd 2 wx len: %d %d \n",Snd2WxDataLen,len); + if(MAIN_FLAG == localMainStandBy) + { + wxCcov.Send((CHAR*)Snd2WxDataBuff,Snd2WxDataLen,wxIpconfigInfo->dstIpInfo->ip,wxIpconfigInfo->dstIpInfo->port); + } + } + + } + + if(mode == 0x11) + {/*ֵػats*/ + if (len > 0) + { + SndData2Wx(mode,(const UINT8 *)debug_array,len); + CiLog->Log("snd 2 wx len: %d %d \n",Snd2WxDataLen,len); + if(MAIN_FLAG == localMainStandBy) + { + wxCcov.Send((CHAR*)Snd2WxDataBuff,Snd2WxDataLen,wxIpconfigInfo->dstIpInfo->ip,5001);/*ĿĶ˿Ϊ5001*/ + } + } + + } + + return 0; +} + + +void SndData2Wx(UINT8 msgType,const UINT8 * dataBuff,UINT32 dataLen) +{ + + static UINT32 SequenceNoArr = 0; + UINT16 index = 0; + UINT32 dataCrc32 = 0; + + if ( ((dataLen +17) > sizeof(Snd2WxDataBuff)/sizeof(UINT8))) + { + return; + } + + Snd2WxDataBuff[index++] = 0xa0; /* ֡ͷ*/ + Snd2WxDataBuff[index++] = 0x50; /* Э*/ + Snd2WxDataBuff[index++] = 0x01; /* Э汾*/ + Snd2WxDataBuff[index++] = 0xa1; /* ֡*/ + Snd2WxDataBuff[index++] = msgType; /* */ + + LongToChar(SequenceNoArr,&Snd2WxDataBuff[index]); /*Ӧк 4ֽ ֽ*/ + index += 4; + Snd2WxDataBuff[index++] = 0x00; + Snd2WxDataBuff[index++] = 0x3c; /* ԴID*/ + Snd2WxDataBuff[index++] = 0x00; + Snd2WxDataBuff[index++] = 0x01; /* Ŀ*/ + Snd2WxDataBuff[index++] = 0x00; + Snd2WxDataBuff[index++] = 0x03; /* ĿID*/ + + ShortToChar(dataLen,Snd2WxDataBuff+index); /* */ + index += 2; + memcpy(Snd2WxDataBuff+index,dataBuff,dataLen); + index += dataLen; +#define MSG_HEAD_LEN 17 /* ֡ͷ */ + dataCrc32 = Crc32(Snd2WxDataBuff,dataLen + MSG_HEAD_LEN); + LongToChar(dataCrc32,Snd2WxDataBuff+index); + index += 4; + Snd2WxDataLen = index; + + SequenceNoArr++; +} + +void __stdcall TimePeriod(HWND hwnd, UINT eventID, UINT_PTR ptrPara, DWORD dwR) +{ + UINT32 tmpTime =0; + tmpTime = timeGetTime(); + /**/ + CiLog->Log("\n------------------------------------- CycleNum Start%x %x ------------------------\n",CycleNum,tmpTime); + /* 1Ҫȴڿʼ״̬ */ + HandleCiApp(); + GetCiAppData((UINT8 *)CISHareMemoryStruct.AddressMemoryStatusMsg[LOCAL_IDX]);/*ȡCIӦ*/ + tmpTime = timeGetTime(); + CiLog->Log("\n------------------------------------- CycleNum End%x %x------------------------\n",CycleNum,tmpTime); + CycleNum = CycleNum + 1; + if (MAIN_FLAG == localMainStandBy) + { + memcpy(CISHareMemoryStruct.AddressMemoryCiCycleFlag[LOCAL_IDX],&CycleNum,sizeof(UINT32)); + } +} + +void ConvertUit32Ip2IpStrFormat(UINT32 ip,CHAR *ipStr) +{ + UINT8 ipAddr[4]; + + if (ipStr != NULL) + { + LongToChar(ip,ipAddr); + + sprintf(ipStr,"%d.%d.%d.%d", + ipAddr[0], + ipAddr[1], + ipAddr[2], + ipAddr[3]); + } + +} + +/* +* ȡԷ +*/ +UINT8 GetOtherLiveFlag() +{ + return GetLiveFlag(OTHER_IDX); +} +UINT8 GetLiveFlag(UINT8 machiId)/*ȡԷ־*/ +{ + return *((UINT8 *)CISHareMemoryStruct.AddressMemoryLiveOrNotMsg[machiId]); +} +/* + * + */ +UINT8 cmpStep(UINT8 step,UINT8 waitStep) +{ + UINT8 ret = 0; /* ʱδҪȴ */ + switch (waitStep) + { + case STEP_START: + if (step == waitStep || STEP_INPUT == step) + { + ret = 1; + } + break; + case STEP_INPUT: + if (step == waitStep || STEP_APP == step) + { + ret = 1; + } + break; + case STEP_APP: + if (step == waitStep || STEP_OUTPUT == step) + { + ret = 1; + } + case STEP_OUTPUT: + if (step == waitStep || STEP_START == step) + { + ret = 1; + } + default: + break; + } + return ret; +} +/* ȴָ*/ +void WaitStep(UINT8 step) +{ + UINT8 otherLiveFlag = GetOtherLiveFlag(); + UINT8 otherStep = GetOtherStepFlag(); + + if (otherLiveFlag != LIVE_ON) + { + return; + } + + while (cmpStep(otherStep,step) != 1) + { + /* 1ʱȴԷڿʼ */ + otherStep = GetOtherStepFlag(); + otherLiveFlag = GetOtherLiveFlag(); + } + +} +/* +*IOȽϺ +*1Ƚһ£0Ƚʧ +*/ +UINT8 IoCompare() +{ + UINT8 ret = 1; + UINT8 bufLocalIoOut[BUF_SIZE]; + UINT32 lenLocalIoOut; + + UINT8 bufOtherIoOut[BUF_SIZE]; + UINT32 lenOtherIoOut; + + memset(bufLocalIoOut,0,BUF_SIZE); + memset(bufOtherIoOut,0,BUF_SIZE); + + lenLocalIoOut = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryIoOutputMsg[LOCAL_IDX]); + lenOtherIoOut = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryIoOutputMsg[OTHER_IDX]); + + memcpy(bufLocalIoOut,(UINT8 *)CISHareMemoryStruct.AddressMemoryIoOutputMsg[LOCAL_IDX],lenLocalIoOut+4); + memcpy(bufOtherIoOut,(UINT8 *)CISHareMemoryStruct.AddressMemoryIoOutputMsg[OTHER_IDX],lenOtherIoOut+4); + + if (lenLocalIoOut == lenOtherIoOut) + { + if (0 == memcmp(bufLocalIoOut,bufOtherIoOut,lenLocalIoOut)) + { + /*ϵIOһ*/ + CiLog->Log("Io comp ok. \n "); + } + else + { + /*Ƚϲһ£ӡ*/ + ret = 0; + CiLog->Log("Io comp error. \n "); + debug_infor_printf("Local:"); + debug_out_array(0,bufLocalIoOut,lenLocalIoOut); + debug_infor_printf("Other:"); + debug_out_array(0,bufOtherIoOut,lenOtherIoOut); + } + } + else + { + /*ȽϳϵIOݲһ*/ + ret = 0; + CiLog->Log("Io comp error.Lens are not the same.\n"); + } + return ret; +} +/* +*ӦȽϺ +*1Ƚһ£0Ƚʧ +*/ +UINT8 AppCompare() +{ + + UINT8 ret = 1; + UINT8 bufLocalAppOut[BUF_SIZE]; + UINT32 lenLocalAppOut; + UINT8 bufOtherAppOut[BUF_SIZE]; + UINT32 lenOtherAppOut; + + memset(bufLocalAppOut,0,BUF_SIZE); + memset(bufOtherAppOut,0,BUF_SIZE); + + lenLocalAppOut = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[LOCAL_IDX]); + lenOtherAppOut = LongFromChar((UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[OTHER_IDX]); + + memcpy(bufLocalAppOut,(UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[LOCAL_IDX],lenLocalAppOut+4); + memcpy(bufOtherAppOut,(UINT8 *)CISHareMemoryStruct.AddressMemoryPrtclOutputMsg[OTHER_IDX],lenOtherAppOut+4); + + if (lenLocalAppOut == lenOtherAppOut) + { + if (0 == memcmp(bufLocalAppOut,bufOtherAppOut,lenLocalAppOut)) + { + /*ϵӦһ*/ + CiLog->Log("App comp ok. \n "); + } + else + { + /*Ƚϲһ£ӡݣforѭ*/ + ret = 0; + CiLog->Log("App comp error. \n "); + debug_infor_printf("Local:"); + debug_out_array(0,bufLocalAppOut,lenLocalAppOut); + debug_infor_printf("Other:"); + debug_out_array(0,bufOtherAppOut,lenOtherAppOut); + } + } + else + { + /*ȽϳϵӦݲһ*/ + ret = 0; + CiLog->Log("App comp error.Lens are not the same.\n"); + + debug_infor_printf("Local len:%d\r\n",lenLocalAppOut); + debug_out_array(0,bufLocalAppOut,lenLocalAppOut); + debug_infor_printf("Other len:%d\r\n",lenOtherAppOut); + debug_out_array(0,bufOtherAppOut,lenOtherAppOut); + } + return ret; +} + +/* +*fsfbBuff in ЭݸʽĿͺID豸ƣ +* totalLen in ܳ +*fsfbBuff out ʵ緢ݣͨ˺ +* DevName out 豸ͺIDҪݴ˻ȡĿIPͶ˿ +*index inout ǰ±꣬ʼַ +*ֵΪݵijȣϲ㷢 +*/ + +UINT16 RedSndUnPackNewFSFB(UINT8 *fsfbBuff,UINT8 *sndBuff,UINT32 *index,UINT32 totalLen,UINT16 *DevName) +{ + UINT16 dataLen = 0;/*֡ݳ*/ + UINT32 tempIndex = 0;/*洢indexֵ*/ + UINT16 sendLen = 0;/*ݳ,ֵ*/ + UINT16 i_sendLen = 0; + UINT32 indexStart = 0; + + tempIndex = *index; + + /*οԭнݺѰַ򳤶Ч2Э1ĿͺID2Ԥ2n*/ + if ((totalLen <= tempIndex)||(totalLen < 4)) + { + sendLen = 0; + return sendLen; + } + else + { + /**/ + + /*Эݰʽǰֽڴ*/ + dataLen = ShortFromChar(&fsfbBuff[tempIndex]); + if (dataLen > 7) + { + /*Ѱַ+ֽ*/ + tempIndex = tempIndex + 2; + indexStart = tempIndex;/*¼Ⱥindex,ݳsendLen=dataLen-(tempIndex-indexStart)*/ + + + tempIndex = tempIndex + 1; + + /*豸ƣ+ID),2ֽ*/ + *DevName = ShortFromChar(&fsfbBuff[tempIndex]); + tempIndex = tempIndex + 2; + + tempIndex = tempIndex + 2; + + sendLen = dataLen - (tempIndex - indexStart); + + /*ݵݻ*/ + for (i_sendLen = 0; i_sendLen < sendLen; i_sendLen++) + { + sndBuff[i_sendLen] = fsfbBuff[tempIndex++]; + } + + /*indexѭԶڽһ֡*/ + *index = tempIndex; + /*Ҫ͵ݳ*/ + return sendLen; + } + else + { + return 0; + } + + } + +} + +/* +ýRedSndUnPackNewFSFB()ȡĿ豸 +1 Ŀ豸ƣ+IDȡԷIPͶ˿ +2 ʹͨſsendݡsendSndData2SignalNet +*/ +void SndFsfbPrtclByDevName(UINT8 *fsfbSndDataBuff) +{ + UINT32 index = 0; + UINT16 sndDataLen = 0; + UINT32 totalLen = 0; + UINT8 *pData = fsfbSndDataBuff; + CComm *pRedCcov = NULL; + CComm *pBlueCcov = NULL; + UINT16 DeviceName = 0; + IpInfo ipInfoList[8]; + UINT8 dstNum;/*ĿIPĿ*/ + UINT8 findFlag = 1; + UINT8 i_dstNum = 0; + UINT32 endTickCount = 0U; + UINT32 startTickCount = 0U; + memset(ipInfoList,DEFAULT_ZERO,sizeof(ipInfoList)); + + totalLen = LongFromChar(pData);/*Ϊ4ֽڣ²װ󴫸ϲ*/ + index += 4; + /*ýȡЭͺĿ*/ + do + { + sndDataLen = RedSndUnPackNewFSFB(fsfbSndDataBuff,sndBuff,&index,totalLen,&DeviceName); + if (sndDataLen > 0) + { + pRedCcov = &(localCcov.redCCov); + pBlueCcov = &(localCcov.blueCCov); + + /* ĿͺIDȡԷIPͶ˿*/ + + /*findFlag = GetIpAndPortByDeviceName(DeviceName,protocalType,ipInfoList,&dstNum);*/ + /*findFlag = GetNetEndPoint(DeviceName,ccovIdx,ipInfoList,&dstNum);*/ + + /*ȡLEUļȡĿLEUIPͶ˿*/ + findFlag = GetIpAndPortByDeviceNameLEUCI(DeviceName,ipInfoList,&dstNum); + if (findFlag == 1) + { + /*find fail,do nothing*/ + } + else + { + /* Ŀͨͨſݷͳȥ,ݷͺ */ + for (i_dstNum = 0;i_dstNum < dstNum; i_dstNum++) + { + startTickCount = GetTickCount(); + SndData2SignalNet(ipInfoList[i_dstNum].redIp,ipInfoList[i_dstNum].redPort,sndBuff,sndDataLen,pRedCcov); + SndData2SignalNet(ipInfoList[i_dstNum].blueIp,ipInfoList[i_dstNum].bluePort,sndBuff,sndDataLen,pBlueCcov); + endTickCount = GetTickCount(); + debug_infor_printf("Snd to %04x,consume %d ms.\r\n", DeviceName, endTickCount - startTickCount); + } + } + } + + } while (sndDataLen >0); +} + +/************************************************************************** +* : fpCI_CFG +* : ȡCI.CFGļõ豸͡͡豸IDCI.CFGCRCУ +* ڲ: sheBeiType豸 + sheBeiID 豸ID +* ֵ: 1 ȡɹ ;0 , ȡʧ +* +****************************************************************************/ +UINT16 ReadCI_CFG(unsigned char * sheBeiType , unsigned char * sheBeiID) +{ + + unsigned char tempDataFromCfg[PU_CFG_FILE_LENGTH] ={0} ; /*ʱ洢cfgļ*/ + unsigned long crcCalculate = 0; /*У*/ + unsigned long crcFromFile = 0; /*У*/ + FILE *fpCI_CFG = NULL; + const CHAR PeiZhiFileRoad[]= ".\\Config\\CI.CFG"; /*IDļ*/ + int retFlag = 1; /*̱־1 0error*/ + int ret =0; /*ֵ*/ + + /**/ + fpCI_CFG = fopen(PeiZhiFileRoad,"rb+"); + if ( NULL == fpCI_CFG ) + { + /*CI.CFGʧܣӡ*/ + CiLog->Log("ERROR:fopen():open CI.cfg error\n"); + retFlag = 0; + } + else + { + /*ղ*/ + retFlag = 1; + } + /*ж̱־*/ + if( 1 == retFlag) + { + /*ļ*/ + ret =( fread(tempDataFromCfg, sizeof(unsigned char),PU_CFG_FILE_LENGTH , fpCI_CFG) ); + if ( 0 ==ret ) + { + /*ļʧܣӡ־*/ + CiLog->Log("ERROR:fread():read CI.cfg error\n"); + retFlag = 0; + } + } + else + { + /*ղ*/ + retFlag = 0; + } + /*ж̱־*/ + if(1 == retFlag) + { + /*رļ*/ + if (0 != fclose( fpCI_CFG ) ) + { + /*رļʧܣӡ־*/ + CiLog->Log("ERROR:fclose():close CI.cfg error\n"); + retFlag = 0; + } + } + else + { + /*ղ*/ + retFlag = 0; + } + + /*ж̱־*/ + if(1 == retFlag) + { + /*CRCУֵ*/ + crcCalculate = Crc32long((unsigned char *)&tempDataFromCfg[0] , PU_CFG_FILE_DATA_LENGTH); + /*ȡļCRCУֵ*/ + crcFromFile = LongFromChar((tempDataFromCfg + PU_CFG_FILE_DATA_LENGTH)); + + /*ȽCRCУֵ*/ + if(crcCalculate == crcFromFile) + { + /*ȡ豸ͺ豸ID*/ + *sheBeiType = tempDataFromCfg[1] ; + *sheBeiID = tempDataFromCfg[2]; + retFlag = 1; + } + else + { + /*CRCУʧܣӡ־*/ + CiLog->Log("ERROR:fpCI_CFG():crc error"); + retFlag = 0; + } + } + else + { + /*ղ*/ + retFlag = 0; + } + return retFlag; +} + +/************************************************************************** +* : DistributeIOFlag +* : ȡֲʽܿأжǷǷֲʽ +* ڲ: void +* ֵ:void +* +****************************************************************************/ +void DistributeIOFlag( void) +{ + UINT8 distributeIOFlag = 0; /**/ + /* ʼܿ */ + /* CiFunctionSwitchStructInit(DQU_FS_CONFIG_PATH_CI); */ + + /*жǷ÷ֲʽIO*/ + distributeIOFlag = GetCiFunctionSwitchConfig(DISTRIBUTED_IO_ENABLE_INDEX); + if(0x55 == distributeIOFlag) + { + /*÷ֲʽIO*/ + distributedIOEnable = DISTRIBUTED_IO_NO; + CiLog->Log(" distributedIOEnable =0x%02x \n",distributedIOEnable); + } + else if(0xAA == distributeIOFlag) + { + /*÷ֲʽIO*/ + distributedIOEnable = DISTRIBUTED_IO_YES; + CiLog->Log(" distributedIOEnable =0x%02x \n",distributedIOEnable); + } + else + { /*Ƿֵ*/ + CiLog->Log(" Distribute IO Flag illegal or error!\n"); + } +} + +/************************************************************************** +* : GetSafeCommUnitCount +* : ȡȫͨŰ +* ڲ:void +* ֵ:int 0-ʧ 1-ɹ +* +****************************************************************************/ +int GetSafeCommUnitCount(void) +{ + /*ر*/ + int ret = 0; + /*ѭ*/ + int count = 0; + /*ȡIOǷǷֲʽ*/ + DistributeIOFlag(); + /*жIOǷǷֲʽ*/ + if(DISTRIBUTED_IO_NO == distributedIOEnable) + { + /*÷ֲʽIO*/ + ret = 1; + } + else if(DISTRIBUTED_IO_YES == distributedIOEnable) + { + /*÷ֲʽIO*/ + /*ȡȫͨŵԪĿ*/ + if(1 == dsuCISafeComBrdAddr(DQU_FS_CONFIG_PATH_CI)) + { + /*ȡɹ*/ + for(count = 0;count < CI_SUM_MAX;count++) + { + /*ұİȫͨŵԪĿ*/ + if(gSheBeiID== safeCommBord[count].belongCiId) + { + gSafeCommUnitCount = safeCommBord[count].safeCommBoardCount; + ret = 1; + break; + } + } + } + else + { + /*ȡʧ*/ + CiLog->Log("ERROR:dsuCISafeComBrdAddr() error!\n"); + ret = 0; + } + } + else + { + /*Ƿֵ*/ + CiLog->Log(" Distribute IO Flag illegal or error!\n"); + ret = 0; + } + /*жϰȫͨŰǷ񳬹ֵ*/ + if (SCB_BOARD_MAX_NUM < gSafeCommUnitCount) + { + CiLog->Log("ERROR:gSafeCommUnitCount too big!\n"); + ret = 0; + } + CiLog->Log("gSafeCommUnitCount=%d, distributedIOEnable is 0x%02x\n", gSafeCommUnitCount, distributedIOEnable); + + return ret; +} + +/************************************************************************** +* : GetSYSCollFsioCount +* : ȡɼ忨忨ַ +* ڲ:void +* ֵ:void +* +****************************************************************************/ +void GetSYSCollFsioCount(void ) +{ + int fsioSystemFlag = 1; + /*ѭ*/ + int count = 0; + /*ȡ1ϵ2ϵFSIOIDбĿ*/ + /*ȡɼĵַ,ÿFSIO忨Ϊ10*2(֡*һһ),ÿȫͨŰӦõIJɼݳ*/ + for(count=0;countLog("systemOneCollFsioCount=%d, systemTwoCollFsioCount =%d\n", systemOneCollFsioCount, systemTwoCollFsioCount); + +} +/************************************************************************** +* : GetSYSDriverFsioCount +* : ȡ忨忨ַ +* ڲ:void +* ֵ:void +* +****************************************************************************/ +void GetSYSDriverFsioCount(void) +{ + /*ѭ*/ + int count = 0; + int fsioSystemFlag = 1; + /*ȡĵַ*/ + fsioSystemFlag = 1; + for(count=0;countLog("systemOneDriverFsioCount=%d, systemTwoDriverFsioCount =%d\n", systemOneDriverFsioCount, systemTwoDriverFsioCount); +} + +/************************************************************************** +* : GetSysOneFSIOcount +* : ȡһϵɼظİ忨ȥظ忨 +* ڲ:void +* ֵ:int +* +****************************************************************************/ +int GetSysOneFSIOcount(void) +{ + int count =0; /*ѭ*/ + int count2 =0; /*ѭ*/ + INT32 tmpTotalOneFsioCount = 0; /*һϵ忨*/ + tmpTotalOneFsioCount = systemOneCollFsioCount + systemOneDriverFsioCount; /*һϵɼظİ忨(ͬһ忨вɼ)*/ + + /*һϵIJɼд: + :κһɼֻܵ˰ӵݣŻظɼ, + Ҳ˵ɼDZȡ + ״:ЩֻΪɼ壬ӦûݸΪ˻ô˰ӵ + ɼݡҪ䷢Ͱȫݣô˰ӵIJɼݡ + ʩ:вɼûİӣҪȫòɼ + + */ + /*һϵɼ忨*/ + for(count =0;count Log("tmpTotalOneFsioCount=%d, tmpTotalTwoFsioCount =%d\n", tmpTotalOneFsioCount, tmpTotalTwoFsioCount); + return ret; +} + + + +/************************************************************************************ +* : dsuCISafeComBrdAddr +* :жȡȫͨŰַϵ +* ڲ: CHAR* FSName +* ֵ: UINT8 chReturnValue 1ȡݳɹ0ȡ쳣 +*************************************************************************************/ + int dsuCISafeComBrdAddr( CHAR* FSName) +{ + UINT8 chReturnValue =0 ; /*ֵ*/ + UINT8 TempRet; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 i; + UINT32 tmplenth = 0; + + /*ʼȫͨŰַṹ*/ + /*ȡ*/ + TempRet=dquGetConfigData(FSName, CI_DATA_TYPE, SAFE_COMM_BOARD_ADDR_ID, &pData, &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + tmplenth= dataLen/LEN_SAFE_COMM_BOARD_ADDR; /*ݵĸ*/ + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for(i =0; i < tmplenth;i++) + { + safeCommBord[i].belongCiId = ShortFromChar(pData+dataOff); + dataOff += 2; + safeCommBord[i].safeCommBoardCount = ShortFromChar(pData+dataOff); + dataOff +=2; + } + + + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + /*ִ*/ + chReturnValue=1; + + return chReturnValue; +} + + + + +/* +* ˵ : ڴ渳ֵ +* ˵ : void *pDest, Ŀĵַ +* UINT8 c,ֵ +* UINT32 count,ֵڴ泤 +* UINT32 destBuffSizeֵܳȡ +* ֵ: 0, δֵֵȴڱ +* 1, 渳ֵ +*/ +UINT8 CommonMemSetCopy(void* pDest, UINT32 destBuffSize, UINT8 c, UINT32 count) +{ + UINT8 Result = 0; /* ؽ */ + + if(count > destBuffSize) + { + /* ֵ쳣ֵ*/ + Result = 0; + } + else + { + /*ڴ渳ֵ*/ + memset(pDest,c,count); + Result = 1; + } + + return Result; +} +/******************************************************************************************************************* +: + ATSIPϢѯݳʼ. +: + UINT8* FSName ļ +: + . +ֵ: + OK ʼɹ. + ERROR ʼʧ. +*******************************************************************************************************************/ +int dsuAtsNetIp_Init(UINT8* FSName) +{ + UINT8 chReturnValue =0 ; /*ֵ*/ + UINT8 TempRet =0 ; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 i =0 ; + + /*ʼATSIPַṹ*/ + /*ȡļ*/ + TempRet=dquGetConfigData((CHAR*)FSName, DSU_IP_CONFIG_TYPE, DSU_DATA_ATS_NET_IP_ID, &pData , &dataLen); + + if (TempRet != 1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + ;/*ִ*/ + } + + DsuAtsNetIpInfoStru.AtsNetIpInfoStruLen=(UINT16)(dataLen/DSU_ATS_NET_IP_INFO_STRU_SIZE); /*ݵĸ*/ + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru=(DSU_IP_INFO_STRU*)malloc(sizeof(DSU_IP_INFO_STRU)*(DsuAtsNetIpInfoStru.AtsNetIpInfoStruLen)); /*Ϊṹռ*/ + + if (DsuAtsNetIpInfoStru.pAtsNetIpInfoStru==NULL) + { + /*ռʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + CommonMemSetCopy( + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru, + sizeof(DSU_IP_INFO_STRU)*(DsuAtsNetIpInfoStru.AtsNetIpInfoStruLen), + 0, + sizeof(DSU_IP_INFO_STRU)*(DsuAtsNetIpInfoStru.AtsNetIpInfoStruLen)); + } + + dataOff = 0; + + /*ͨѭļݽѯݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0; i < DsuAtsNetIpInfoStru.AtsNetIpInfoStruLen; i++) + { + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].DevName = ShortFromChar(pData + dataOff); + dataOff+=2; + + memcpy(DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].IpAddrBlue, pData + dataOff, DSU_LEN_IP4_ADDR); + dataOff+=DSU_LEN_IP4_ADDR; + + memcpy(DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].MaskBlue, pData + dataOff, DSU_LEN_IP4_ADDR); + dataOff+=DSU_LEN_IP4_ADDR; + + memcpy(DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].IpAddrRed, pData + dataOff, DSU_LEN_IP4_ADDR); + dataOff+=DSU_LEN_IP4_ADDR; + + memcpy(DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].MaskRed, pData + dataOff, DSU_LEN_IP4_ADDR); + dataOff+=DSU_LEN_IP4_ADDR; + + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].SfpBluePort=ShortFromChar(pData+dataOff); + dataOff+=2; + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].SfpRedPort=ShortFromChar(pData+dataOff); + dataOff+=2; + + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].RpBluePort=ShortFromChar(pData+dataOff); + dataOff+=2; + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].RpRedPort=ShortFromChar(pData+dataOff); + dataOff+=2; + + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].RsspBluePort=ShortFromChar(pData+dataOff); + dataOff+=2; + DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].RsspRedPort=ShortFromChar(pData+dataOff); + dataOff+=2; + } + + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + /*ִ*/ + chReturnValue=1; + return chReturnValue; +} + + + +/* +* 豸ƲѯATSIPַ +* UINT16 devName 豸 +* ATS_NET_IP_AND_MASK_STRU * pIpAndMaskInfo 豸IPϢ +* ֵ1:ѯɹ 0 ѯʧ +*/ +int CC_GetAtsNetIpInfoByDevName(UINT16 devName, ATS_NET_IP_AND_MASK_STRU1 * pIpAndMaskInfo) +{ + int retVal = 0; + UINT16 i; + + if(NULL != pIpAndMaskInfo) + { + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0; i < DsuAtsNetIpInfoStru.AtsNetIpInfoStruLen; i++) + { + if(devName == DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].DevName) + {/*豸ƥ*/ + memcpy(pIpAndMaskInfo->BlueIp, DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].IpAddrBlue, DSU_LEN_IP4_ADDR); + + memcpy(pIpAndMaskInfo->BlueMask, DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].MaskBlue, DSU_LEN_IP4_ADDR); + + memcpy(pIpAndMaskInfo->RedIp, DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].IpAddrRed, DSU_LEN_IP4_ADDR); + + memcpy(pIpAndMaskInfo->RedMask, DsuAtsNetIpInfoStru.pAtsNetIpInfoStru[i].MaskRed, DSU_LEN_IP4_ADDR); + + retVal = 1; + + break; + } + else + { + ; + } + } + } + else + { + retVal = 0; + } + + return retVal; +} +/**============================================================================= + : UINT8 CheckLocalGatewayInfo + : ѯCCӦĺ + : 豸ͺͺѯõӦ + UINT16 localTypeId豸ID + UINT8 computerLocalId豸 + زUINT8 localGateWayBuff[DSURP_LEN_IP_ADDR] IP + UINT8 subnetMaskBuff[DSURP_LEN_IP_ADDR] + ֵ: UINT8 rtnValue 0x00 豸ʧܣ + 0x01 豸سɹ +==============================================================================*/ +UINT8 CheckLocalGatewayInfoCopy(UINT16 localTypeId, UINT32 * localRedGateWayBuff, UINT32 *localBlueGateWayBuff, UINT32 * subnetMaskBuff) +{ + UINT32 i = 0U; /*ѭƱ*/ + UINT8 rtnValue = 0; /*ֵ*/ + UINT8 rtnFlag = 0; + + + if( (NULL == localRedGateWayBuff) || (NULL == localBlueGateWayBuff) ||(NULL == subnetMaskBuff) ) + { + rtnValue = 0; + } + else + { + /*ѭ豸*/ + for (i = 0U; i < GatewayInfoLen; i++) + { + if (pDsuGateWayInfoStru[i].DeviceTypeId == localTypeId) + { + /*豸*/ + * localBlueGateWayBuff = LongFromChar(pDsuGateWayInfoStru[i].IpAddrGatewayBlue); + CiLog->Log("0x%04x%d.%d.%d.%d\n",localTypeId,pDsuGateWayInfoStru[i].IpAddrGatewayBlue[0],pDsuGateWayInfoStru[i].IpAddrGatewayBlue[1],pDsuGateWayInfoStru[i].IpAddrGatewayBlue[2],pDsuGateWayInfoStru[i].IpAddrGatewayBlue[3]); + /*豸*/ + * localRedGateWayBuff = LongFromChar(pDsuGateWayInfoStru[i].IpAddrGatewayRed); + CiLog->Log("0x%04x%d.%d.%d.%d\n",localTypeId,pDsuGateWayInfoStru[i].IpAddrGatewayRed[0],pDsuGateWayInfoStru[i].IpAddrGatewayRed[1],pDsuGateWayInfoStru[i].IpAddrGatewayRed[2],pDsuGateWayInfoStru[i].IpAddrGatewayRed[3]); + + /*豸*/ + * subnetMaskBuff = LongFromChar(pDsuGateWayInfoStru[i].IpAddrSubnetMask); + CiLog->Log("0x%04x%d.%d.%d.%d\n",localTypeId,pDsuGateWayInfoStru[i].IpAddrSubnetMask[0],pDsuGateWayInfoStru[i].IpAddrSubnetMask[1],pDsuGateWayInfoStru[i].IpAddrSubnetMask[2],pDsuGateWayInfoStru[i].IpAddrSubnetMask[3]); + + /*ҵ豸سɹ*/ + rtnValue = 0x01 ; + + /*ѭ*/ + break; + } + } + } + + + return rtnValue; +} +/*===================================================================== + : UINT8 dsuLocalIpGatewayInfoInit + : ѯ豸رϢ + : ʼ豸رϢ + UINT8* FSName ļ + ز + ֵ: UINT8 rtnValue 0x00 豸ʧܣ + 0x01 豸سɹ +====================================================================*/ +UINT8 dsuLocalIpGatewayInfoInit(UINT8* FSName) +{ + UINT8 chReturnValue=0; + UINT8 TempRet=0; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 i = 0; + UINT8 TempFlag = 0; + + /*ʼ豸رϢ*/ + /*ȡ*/ + TempRet=dquGetConfigData((CHAR*)FSName, DSU_DEVICE_IP_CONFIG_TYPE_COPY, DSU_DATA_IP_GATEWAY_ID_COPY, &pData , &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + TempFlag=0; + + } + else + { + GatewayInfoLen=(UINT16)(dataLen/DSU_GATEWAY_INFO_STRU_SIZE_COPY); /*ݵĸ*/ + /*Ϊṹռ*/ + pDsuGateWayInfoStru=(DSU_GATEWAY_INFO_STRU_COPY *)malloc(sizeof(DSU_GATEWAY_INFO_STRU_COPY)*(GatewayInfoLen)); + if (pDsuGateWayInfoStru==NULL) + { + /*ռʧ*/ + TempFlag=0; + } + else + { + /*ִ*/ + CommonMemSetCopy(pDsuGateWayInfoStru,sizeof(DSU_GATEWAY_INFO_STRU_COPY)*(GatewayInfoLen),0,sizeof(DSU_GATEWAY_INFO_STRU_COPY)*(GatewayInfoLen)); + TempFlag=1; + } + } + + if(1 ==TempFlag ) + { + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i=0U;iLog("0x%04xATS%d.%d.%d.%d\n",gSheBeiName,ipAndMaskInfo.BlueIp[0],ipAndMaskInfo.BlueIp[1],ipAndMaskInfo.BlueIp[2],ipAndMaskInfo.BlueIp[3]); + /*ȡATS */ + * maskBlue = LongFromChar(ipAndMaskInfo.BlueMask); + CiLog->Log("0x%04xATS%d.%d.%d.%d\n",gSheBeiName,ipAndMaskInfo.BlueMask[0],ipAndMaskInfo.BlueMask[1],ipAndMaskInfo.BlueMask[2],ipAndMaskInfo.BlueMask[3]); + /*ȡATSIP*/ + * ipRed = LongFromChar(ipAndMaskInfo.RedIp); + CiLog->Log("0x%04xATS%d.%d.%d.%d\n",gSheBeiName,ipAndMaskInfo.RedIp[0],ipAndMaskInfo.RedIp[1],ipAndMaskInfo.RedIp[2],ipAndMaskInfo.RedIp[3]); + /*ȡATS*/ + * maskRed = LongFromChar(ipAndMaskInfo.RedMask); + CiLog->Log("0x%04xATS%d.%d.%d.%d\n",gSheBeiName,ipAndMaskInfo.RedMask[0],ipAndMaskInfo.RedMask[1],ipAndMaskInfo.RedMask[2],ipAndMaskInfo.RedMask[3]); + retVal = 1; + } + else + { + /*ӡ־*/ + CiLog->Log("ѯ0x%04xATSϢIPʧ\n",gSheBeiName); + + retVal = 0; + } + + return retVal; +} +/* +: + ʼϢ +: + +: + +ֵ: + 1 ʼɹ. + 0 ʼʧ. +*/ +UINT8 dsuAllIpInit(CHAR* FSName) +{ + UINT8 chReturnValue =0 ; /*ֵ*/ + UINT8 TempRet; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 i; + + /*ʼipַṹ*/ + /*ȡ*/ + TempRet=dquGetConfigData(FSName, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_IP_ID, &pData, &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + ipInfoStruLen= dataLen/DSU_IP_INFO_STRU_SIZE; /*ݵĸ*/ + ipInfoStru = (DSU_FSFB_IP_INFO_STRU *)MyNew(ipInfoStruLen * sizeof(DSU_FSFB_IP_INFO_STRU)); + if( NULL == ipInfoStru) + { + ipInfoStruLen =0; + } + else + { + /*ڴΪЧ*/ + memset(ipInfoStru, 0x00,ipInfoStruLen * sizeof(DSU_FSFB_IP_INFO_STRU)); + } + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0; i < ipInfoStruLen; i++) + { + ipInfoStru[i].devName=ShortFromChar(pData+dataOff); + dataOff += 2; + + ipInfoStru[i].HlhtId = LongFromChar(pData + dataOff); + dataOff += 4; + + memcpy(ipInfoStru[i].IPAddrBlue, pData+dataOff, DSU_IPADDR_LEN); + dataOff += DSU_IPADDR_LEN; + + memcpy(ipInfoStru[i].IPAddrRed, pData+dataOff, DSU_IPADDR_LEN); + dataOff += DSU_IPADDR_LEN; + + ipInfoStru[i].SfpBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + ipInfoStru[i].SfpRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + + ipInfoStru[i].RpBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + ipInfoStru[i].RpRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + + ipInfoStru[i].RsrAndRsspBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + ipInfoStru[i].RsrAndRsspRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + + ipInfoStru[i].SourceBluePort = ShortFromChar(pData + dataOff); + dataOff += 2; + ipInfoStru[i].SourceRedPort = ShortFromChar(pData + dataOff); + dataOff += 2; + } + + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + + } + else + { + /*ִ*/ + chReturnValue=1; /*ִ*/ + } + + + + return chReturnValue; +} + +UINT8 checkMultIPInfoOfObject(UINT8 localID, UINT8 localType, UINT32 *pDevIpSum, UINT32 RedIPInfo[], UINT32 BlueIPInfo[]) +{ + UINT8 chReturnValue;/*ֵ*/ + + UINT32 i;/*ѭ*/ + UINT16 tempDevName; /*ʱdevName*/ + + UINT32 devIpSum = 0; + UINT32 devIpIdx = 0; + + /*dev*/ + tempDevName=(UINT16)(((localType<<8) + localID) & 0xffff); + + /*ѭ豸ipַ*/ + for (i = 0; i < ipInfoStruLen; i++) + { + if (ipInfoStru[i].devName == tempDevName) + { + /*ҵǰ豸*/ + RedIPInfo[devIpIdx] = LongFromChar(ipInfoStru[i].IPAddrRed); + BlueIPInfo[devIpIdx] = LongFromChar(ipInfoStru[i].IPAddrBlue); + devIpIdx++; + devIpSum++; + + if(SIN_DEV_IP_SUM_MAX > devIpSum) + { + ; + } + else + { + break; + } + } + else + { + /**/ + } + } + + if(0 != devIpSum) + { + /*ҵ豸*/ + chReturnValue = 1; + } + else + { + /*δҵ豸*/ + chReturnValue = 0; + } + + *pDevIpSum = devIpSum; + + return chReturnValue; +} + +/*======================================================================================== + InitCheckIPMask(void) +: + ѯ豸ATSǷͬһΣͬһλᵼ°ʧ +: + +: + +ֵ: + 0 ʼɹ. + 1 ʼʧ. +=========================================================================================*/ +int InitCheckIPMask(void) +{ + int ret =0; /*ֵ*/ + UINT8 gSBeiType; /*豸*/ + UINT8 gSBeiID; /*豸ID*/ + UINT16 localDevName; /*豸ͺID*/ + UINT32 localRedGateWay = 0; /*豸*/ + UINT32 localBlueGateWay = 0; /*豸*/ + UINT32 subnetMask = 0; /**/ + UINT32 RedSubnetAddress = 0; /**/ + UINT32 BlueSubnetAddress = 0; /**/ + UINT32 RedBroadcastAddress = 0; /*㲥ֵ*/ + UINT32 BlueBroadcastAddress = 0; /*㲥ֵ*/ + + UINT32 ATSRedip = 0; /*CI_ATSIP*/ + UINT32 ATSBlueip = 0; /*CI_ATSIP*/ + UINT32 ATSRedmask = 0; /*CI_ATS*/ + UINT32 ATSBluemask = 0; /*CI_ATS*/ + UINT32 ATSRedSubnetAddress = 0; /**/ + UINT32 ATSBlueSubnetAddress = 0; /**/ + UINT32 ATSRedBroadcastAddress = 0; /*㲥ֵ*/ + UINT32 ATSBlueBroadcastAddress = 0; /*㲥ֵ*/ + + UINT32 localRedIPCopy = 0; /*ŴFSļȡĺIP*/ + UINT32 localBlueIPCopy = 0; /*ŴFSļȡIP*/ + + UINT32 pDevIpSum =0; + /*ʼIPϢ*/ + dsuAllIpInit(DQU_FS_CONFIG_PATH_CI); + /*ʼCI_ATS豸*/ + dsuLocalIpGatewayInfoInit((UINT8*)DQU_FS_CONFIG_PATH_CI); + + gSBeiID = ReadLocalCiId(); + gSBeiType = 0x3c; + /*ReadCI_CFG(&gSBeiType , &gSBeiID);*/ + /*ѯ豸IP*/ + checkMultIPInfoOfObject(gSBeiID , gSBeiType ,&pDevIpSum, &localRedIPCopy , &localBlueIPCopy); + /*ӡIP*/ + CiLog->Log("0x%02x%02x%d.%d.%d.%d\n",gSBeiType,gSBeiID,(localRedIPCopy>>24) & 0x000000FF ,(localRedIPCopy>>16)& 0x000000FF,(localRedIPCopy>>8)& 0x000000FF ,localRedIPCopy & 0x000000FF ); + CiLog->Log("0x%02x%02x%d.%d.%d.%d\n",gSBeiType,gSBeiID,(localBlueIPCopy>>24) & 0x000000FF ,(localBlueIPCopy>>16)& 0x000000FF,(localBlueIPCopy>>8)& 0x000000FF ,localBlueIPCopy & 0x000000FF ); + /*ȡ豸غ*/ + CheckLocalGatewayInfoCopy(gSheBeiName,&localRedGateWay, &localBlueGateWay,&subnetMask); + /*ַΧRedSubnetAddress RedBroadcastAddress*/ + RedSubnetAddress = (localRedIPCopy & subnetMask) + 1; + RedBroadcastAddress = (localRedIPCopy ^ subnetMask) -1; + /*ַΧ BlueSubnetAddress BlueBroadcastAddress*/ + BlueSubnetAddress = (localBlueIPCopy & subnetMask) + 1; + BlueBroadcastAddress = (localBlueIPCopy ^ subnetMask) - 1; + /*ȡATSϢ*/ + AtsNet_Initial(&ATSBlueip,&ATSBluemask,&ATSRedip,&ATSRedmask); + /*ַΧ*/ + ATSRedSubnetAddress = (ATSRedip & ATSRedmask)+1 ; + ATSRedBroadcastAddress = (ATSRedip ^ ATSRedmask) -1; + /*ַΧ*/ + ATSBlueSubnetAddress = (ATSBlueip & ATSBluemask) +1; + ATSBlueBroadcastAddress = (ATSBlueip ^ ATSBluemask) -1; + /*Χغϻᵼʧ*/ + if( (RedSubnetAddress > ATSRedBroadcastAddress) || (RedBroadcastAddress < ATSRedSubnetAddress) ) + { + CiLog->Log("%04xATS豸غϣᵼʧ",gSheBeiName); + ret = 1; + } + else + { + /*Χغϻᵼʧ*/ + if( (BlueSubnetAddress > ATSBlueBroadcastAddress) || (BlueBroadcastAddress < ATSBlueSubnetAddress) ) + { + CiLog->Log("%04xATS豸غϣᵼʧ",gSheBeiName); + ret = 1; + } + else + { + ret = 0; /*ɹ*/ + } + } + + return 0; +} + +/* +: + ȡ豸IPñ +: + +: + +ֵ: + . +*/ +void ReadCIFsDevIpTable(const char * pCiFsPath) +{ + FILE *pFile = NULL; + char ch; + char chDataBuff[200]; + UINT16 wIndex = DEFAULT_ZERO; + + UINT8 funcRtn = 0; + UINT8 rtnValue = 1; + UINT32 DataID=0;/*ͱʶ*/ + UINT8 *pDataAddr=NULL; + UINT32 DataSize=0; + UINT16 rowCount = 0; + UINT8 cVobcSum = 0u; + UINT16 wDevName = 0u; + UINT16 wLogicId = 0u; + UINT8 cDevType = 0u; + + memset(gDeviceIpInfoArray, DEFAULT_ZERO, sizeof(gDeviceIpInfoArray)); + memset(chDataBuff, DEFAULT_ZERO, sizeof(char) * 200); + if(gDeviceNum == 0 ) + { /*0x40,1Ϊ豸IPñ*/ + funcRtn=dquGetConfigDataNew( ( char *)pCiFsPath, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_IP_ID, &pDataAddr, &DataSize, &rowCount); + + if (funcRtn != 1) + { + debug_infor_printf("\n Read ci.fs fail.\n"); + rtnValue = 0; + + } + + if(1 == rtnValue) + { + gDeviceIpInfoArray[wIndex].logicId = 0; + gDeviceIpInfoArray[wIndex].deviceName = ShortFromChar(pDataAddr); + pDataAddr+=2; + } + + } + + + UINT8 chReturnValue =0 ; /*ֵ*/ + UINT8 TempRet; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 i; + UINT32 j; + UINT32 dwCurDevNum = 0U; + UINT16 wAxleId = 0U; /*ϵͳID*/ + UINT32 dwAxleHlhtId = 0U; /*ϵͳͨID*/ + + /*ʼipַṹ*/ + /*ȡ*/ + TempRet=dquGetConfigData(( char *)pCiFsPath, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_IP_ID, &pData, &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return ; + } + else + { + /*ִ*/ + } + ipInfoStruLen= dataLen/DSU_IP_INFO_STRU_SIZE; /*ݵĸ*/ + ipInfoStru = (DSU_FSFB_IP_INFO_STRU *)MyNew(ipInfoStruLen * sizeof(DSU_FSFB_IP_INFO_STRU)); + if( NULL == ipInfoStru) + { + ipInfoStruLen =0; + } + else + { + /*ڴΪЧ*/ + memset(ipInfoStru, 0x00,ipInfoStruLen * sizeof(DSU_FSFB_IP_INFO_STRU)); + } + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0; i < ipInfoStruLen; i++) + { + ipInfoStru[i].devName=ShortFromChar(pData+dataOff); + dataOff += 2; + ipInfoStru[i].HlhtId = LongFromChar(pData + dataOff); + dataOff += 4; + + memcpy(ipInfoStru[i].IPAddrBlue, pData+dataOff, DSU_IPADDR_LEN); + dataOff += DSU_IPADDR_LEN; + + memcpy(ipInfoStru[i].IPAddrRed, pData+dataOff, DSU_IPADDR_LEN); + dataOff += DSU_IPADDR_LEN; + + ipInfoStru[i].SfpBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + ipInfoStru[i].SfpRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + + ipInfoStru[i].RpBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + ipInfoStru[i].RpRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + + ipInfoStru[i].RsrAndRsspBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + ipInfoStru[i].RsrAndRsspRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + + ipInfoStru[i].SourceBluePort = ShortFromChar(pData + dataOff); + dataOff += 2; + ipInfoStru[i].SourceRedPort = ShortFromChar(pData + dataOff); + dataOff += 2; + + if (0xa000U == (ipInfoStru[i].devName & 0xFF00U)) + { + wAxleId = ipInfoStru[i].devName & 0x00FFU; + funcRtn = dquQueryOutDevId(IDMAP_AXLE_ID, wAxleId, &dwAxleHlhtId); /*ȡָϵͳĻͨID*/ + + if (0U == funcRtn) + { + debug_infor_printf("Get Axle[%d] HlhtId Fail!\n", wAxleId); /*ӡ־*/ + } + } + else + { + /*Ǽϵͳ*/ + } + + if ((0xa000U != (ipInfoStru[i].devName & 0xFF00U)) || (dwAxleHlhtId == ipInfoStru[i].HlhtId)) + { + gDeviceIpInfoArray[dwCurDevNum].deviceName = ipInfoStru[i].devName; + gDeviceIpInfoArray[dwCurDevNum].estId = ipInfoStru[i].HlhtId; + memcpy(gDeviceIpInfoArray[dwCurDevNum].blueIp, ipInfoStru[i].IPAddrBlue, DSU_IPADDR_LEN); + memcpy(gDeviceIpInfoArray[dwCurDevNum].redIp, ipInfoStru[i].IPAddrRed, DSU_IPADDR_LEN); + + gDeviceIpInfoArray[dwCurDevNum].bluePort[SFP_IDX] = ipInfoStru[i].SfpBluePort; + gDeviceIpInfoArray[dwCurDevNum].redPort[SFP_IDX] = ipInfoStru[i].SfpRedPort; + + gDeviceIpInfoArray[dwCurDevNum].bluePort[RP_IDX] = ipInfoStru[i].RpBluePort; + gDeviceIpInfoArray[dwCurDevNum].redPort[RP_IDX] = ipInfoStru[i].RpRedPort; + + gDeviceIpInfoArray[dwCurDevNum].bluePort[RSSP1_IDX] = ipInfoStru[i].RsrAndRsspBluePort; + gDeviceIpInfoArray[dwCurDevNum].redPort[RSSP1_IDX] = ipInfoStru[i].RsrAndRsspRedPort; + + gDeviceIpInfoArray[dwCurDevNum].bluePort[RSSP2_IDX] = 50009; + gDeviceIpInfoArray[dwCurDevNum].redPort[RSSP2_IDX] = 50009; + + cDevType = (UINT8)((gDeviceIpInfoArray[dwCurDevNum].deviceName & (UINT16)0xFF00) >> 8u); + if (0x14u == cDevType) + { + dquHlhtId2VobcName(gDeviceIpInfoArray[dwCurDevNum].estId, &wDevName, &wLogicId); + gDeviceIpInfoArray[dwCurDevNum].logicId = wLogicId; + } + else if (DEVTYPE_ITE == cDevType) + { + gDeviceIpInfoArray[dwCurDevNum].logicId = gDeviceIpInfoArray[dwCurDevNum].estId&0x03; + } + else + { + ; + } + + dwCurDevNum++; /*ÿɹ洢һIPһ*/ + } + else + { + /*TMC-IPȡ*/ + } + } + gDeviceNum = (UINT16)dwCurDevNum; + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + + } + else + { + /*ִ*/ + chReturnValue=1; /*ִ*/ + } + + return ; +} + +/* +: + ȡCI_ATS豸IPַ +: + +: + +ֵ: + . +*/ +void ReadCIATSFsDevIpTable(const char * pCiFsPath) +{ + FILE *pFile = NULL; + char ch; + char chDataBuff[200]; + UINT16 wIndex = DEFAULT_ZERO; + + UINT8 funcRtn = 0; + UINT8 rtnValue = 1; + UINT32 DataID=0;/*ͱʶ*/ + UINT8 *pDataAddr=NULL; + UINT32 DataSize=0; + UINT16 rowCount = 0; + UINT16 realRowCount = 0; + UINT16 index = 0; + + memset(gDeviceIpInfoArrayATS, DEFAULT_ZERO, sizeof(gDeviceIpInfoArrayATS)); + memset(chDataBuff, DEFAULT_ZERO, sizeof(char) * 200); + if(gDeviceNumAts == 0 ) + { /*0x40,1Ϊ豸IPñ*/ + funcRtn=dquGetConfigDataNew( ( char *)pCiFsPath, DSU_DEVICE_IP_CONFIG_TYPE, DSU_CI_ATS_DEVICE_IP_ADDR, &pDataAddr, &DataSize, &rowCount); + + if (funcRtn != 1) + { + debug_infor_printf("\n Read ci.fs fail.\n"); + rtnValue = 0; + + } + + if(1 == rtnValue) + { + gDeviceIpInfoArrayATS[wIndex].logicId = 0; + gDeviceIpInfoArrayATS[wIndex].deviceName = ShortFromChar(pDataAddr); + pDataAddr+=2; + } + + } + + + UINT8 chReturnValue =0 ; /*ֵ*/ + UINT8 TempRet; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 i; + + /*ʼipַṹ*/ + /*ȡ*/ + TempRet=dquGetConfigDataNew(( char *)pCiFsPath, DSU_DEVICE_IP_CONFIG_TYPE, DSU_CI_ATS_DEVICE_IP_ADDR, &pData, &dataLen,&realRowCount); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return ; + } + else + { + /*ִ*/ + } + if((0 != dataLen) && (0 != realRowCount)) + { + ipInfoStruLen= dataLen/realRowCount; /*ݵĸ*/ + ipInfoStru = (DSU_FSFB_IP_INFO_STRU *)MyNew(realRowCount * sizeof(DSU_FSFB_IP_INFO_STRU)); + if( NULL == ipInfoStru) + { + ipInfoStruLen =0; + } + else + { + /*ڴΪЧ*/ + memset(ipInfoStru, 0x00,realRowCount * sizeof(DSU_FSFB_IP_INFO_STRU)); + } + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0; i < realRowCount; i++) + { + /*ʼΪ0*/ + index = 0; + ipInfoStru[i].devName=ShortFromChar(pData+dataOff); + dataOff += 2; + index = index + 2; + + memcpy(ipInfoStru[i].IPAddrBlue, pData+dataOff, DSU_IPADDR_LEN); + dataOff += DSU_IPADDR_LEN; + index = index + DSU_IPADDR_LEN; + + dataOff += 4; + index = index + 4; + + memcpy(ipInfoStru[i].IPAddrRed, pData+dataOff, DSU_IPADDR_LEN); + dataOff += DSU_IPADDR_LEN; + index = index + DSU_IPADDR_LEN; + + dataOff += 4; + index = index + 4; + + ipInfoStru[i].SfpBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + index = index + 2; + + ipInfoStru[i].SfpRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + index = index + 2; + + ipInfoStru[i].RpBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + index = index + 2; + + ipInfoStru[i].RpRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + index = index + 2; + + ipInfoStru[i].RsrAndRsspBluePort=ShortFromChar(pData + dataOff); + dataOff+=2; + index = index + 2; + + ipInfoStru[i].RsrAndRsspRedPort=ShortFromChar(pData + dataOff); + dataOff+=2; + index = index + 2; + + if((index + 16) <= ipInfoStruLen) + { + dataOff+=16; + index = index + 16; + } + + gDeviceIpInfoArrayATS[i].deviceName = ipInfoStru[i].devName; + memcpy(gDeviceIpInfoArrayATS[i].blueIp,ipInfoStru[i].IPAddrBlue, DSU_IPADDR_LEN); + memcpy(gDeviceIpInfoArrayATS[i].redIp,ipInfoStru[i].IPAddrRed, DSU_IPADDR_LEN); + + gDeviceIpInfoArrayATS[i].bluePort[SFP_IDX] = ipInfoStru[i].SfpBluePort; + gDeviceIpInfoArrayATS[i].redPort[SFP_IDX] = ipInfoStru[i].SfpRedPort; + + gDeviceIpInfoArrayATS[i].bluePort[RP_IDX] = ipInfoStru[i].RpBluePort; + gDeviceIpInfoArrayATS[i].redPort[RP_IDX] = ipInfoStru[i].RpRedPort; + + gDeviceIpInfoArrayATS[i].bluePort[RSSP1_IDX] = ipInfoStru[i].RsrAndRsspBluePort; + gDeviceIpInfoArrayATS[i].redPort[RSSP1_IDX] = ipInfoStru[i].RsrAndRsspRedPort; + + gDeviceIpInfoArrayATS[i].bluePort[RSSP2_IDX] = 50009; + gDeviceIpInfoArrayATS[i].redPort[RSSP2_IDX] = 50009; + + + } + gDeviceNumAts = realRowCount; + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + + } + else + { + /*ִ*/ + chReturnValue=1; /*ִ*/ + } + } + + return ; +} + +void PackOcToCloudData(void) +{ + UINT16 ii = 0; + UINT8 dstNum; + UINT8 findFlag = 0; + UINT32 tmpTime = 0; + IpInfo ipInfoList[8]; + UINT16 DeviceName = 0; + UINT16 LogicId = 0; + UINT16 t_MsgLenPos = 0; + UINT8 rtnValue = CI_ERROR; + CComm *pRedCcov = NULL; + CComm *pBlueCcov = NULL; + struct timeval curTimeStamp; + UINT8 OcToCloudDataBuffer[200] = { 0 };/*CICloud֡*/ + + DeviceName = 0x1801; + findFlag = GetNetEndPoint(DeviceName, LogicId, RSSP1_IDX, ipInfoList, &dstNum); + + if (0 != findFlag) + { + gettimeofday(&curTimeStamp, NULL); + pRedCcov = &(localCcov.redCcov[2]); + pBlueCcov = &(localCcov.blueCcov[2]); + + /* ͺ */ + ii = 0; + OcToCloudDataBuffer[ii++] = 0xAA;/* ֡Ŀʼʶ */ + t_MsgLenPos = ii;/* ¼ݳȸλ */ + ii += 2; + OcToCloudDataBuffer[ii++] = 0x01;/* ֡ */ + LongToChar(curTimeStamp.tv_sec, &OcToCloudDataBuffer[ii]);/* ʱǰֽ */ + ii += 4; + LongToChar(curTimeStamp.tv_usec, &OcToCloudDataBuffer[ii]);/* ʱֽ */ + ii += 4; + LongToChar(ipInfoList[1].redIp, &OcToCloudDataBuffer[ii]);/* ͶԭʼIP */ + ii += 4; + ShortToChar(ipInfoList[1].redPort, &OcToCloudDataBuffer[ii]);/* Ͷԭʼ˿ں */ + ii += 2; + LongToChar(ipInfoList[0].redIp, &OcToCloudDataBuffer[ii]);/* նԭʼIP */ + ii += 4; + ShortToChar(ipInfoList[0].redPort, &OcToCloudDataBuffer[ii]);/* նԭʼ˿ں */ + ii += 2; + OcToCloudDataBuffer[ii++] = 0x55;/* ֡Ľʶ */ + ShortToChar((ii - t_MsgLenPos - 2), &OcToCloudDataBuffer[t_MsgLenPos]);/* ֡ */ + + SndData2SignalNet(ipInfoList[0].redIp, ipInfoList[0].redPort, OcToCloudDataBuffer, ii, pRedCcov); + + /* */ + ii = 0; + OcToCloudDataBuffer[ii++] = 0xAA;/* ֡Ŀʼʶ */ + t_MsgLenPos = ii;/* ¼ݳȸλ */ + ii += 2; + OcToCloudDataBuffer[ii++] = 0x01;/* ֡ */ + LongToChar(curTimeStamp.tv_sec, &OcToCloudDataBuffer[ii]);/* ʱǰֽ */ + ii += 4; + LongToChar(curTimeStamp.tv_usec, &OcToCloudDataBuffer[ii]);/* ʱֽ */ + ii += 4; + LongToChar(ipInfoList[1].blueIp, &OcToCloudDataBuffer[ii]);/* ͶԭʼIP */ + ii += 4; + ShortToChar(ipInfoList[1].bluePort, &OcToCloudDataBuffer[ii]);/* Ͷԭʼ˿ں */ + ii += 2; + LongToChar(ipInfoList[0].blueIp, &OcToCloudDataBuffer[ii]);/* նԭʼIP */ + ii += 4; + ShortToChar(ipInfoList[0].bluePort, &OcToCloudDataBuffer[ii]);/* նԭʼ˿ں */ + ii += 2; + OcToCloudDataBuffer[ii++] = 0x55;/* ֡Ľʶ */ + ShortToChar((ii - t_MsgLenPos - 2), &OcToCloudDataBuffer[t_MsgLenPos]);/* ֡ */ + + SndData2SignalNet(ipInfoList[0].blueIp, ipInfoList[0].bluePort, OcToCloudDataBuffer, ii, pBlueCcov); + } + +} + +int gettimeofday(struct timeval *tp, void *tzp) +{ + time_t clock; + struct tm tm; + SYSTEMTIME wtm; + GetLocalTime(&wtm); + tm.tm_year = wtm.wYear - 1900; + tm.tm_mon = wtm.wMonth - 1; + tm.tm_mday = wtm.wDay; + tm.tm_hour = wtm.wHour; + tm.tm_min = wtm.wMinute; + tm.tm_sec = wtm.wSecond; + tm.tm_isdst = -1; + clock = mktime(&tm); + tp->tv_sec = clock; + tp->tv_usec = wtm.wMilliseconds; + return (0); +} + +/* +* ȡ־ӡļ +* ˵ void +* ֵ ־ɾʱ +* by cgh 20231122 +*/ +UINT8 ReadLogConfig(void) +{ + UINT8 chReval = 0U; + FILE* fp = NULL; + const char chLogConfigPath[] = ".\\config\\LogConfig.ini"; + char szStr[50] = {0};/*ļжȡַ*/ + const char chKeyStr[] = "LogSaveTime=";/*־ɾʱؼַ*/ + UINT8 ii = 0U; + UINT8 jj = 0U; + char chConfigTimStr[3] = { 0 };/*ļе־ɾʱ-ַʽ*/ + UINT16 chConfigTime = 0U;/*ļе־ɾʱ*/ + + fp = fopen(chLogConfigPath,"rb"); + + if (NULL == fp) + { + debug_infor_printf("־ɾļĬϱ30죡\n"); + /*ļĬ30ɾ*/ + chReval = MIN_DAY; + } + else + { + if (fgets(szStr, 50, fp) == NULL) + { + debug_infor_printf("־ɾļΪգĬϱ30죡\n"); + /*ļݣĬ30ɾ*/ + chReval = MIN_DAY; + } + else + { + if (strstr(szStr, chKeyStr) == NULL) + { + debug_infor_printf("־ɾļδҵLogSaveTimeؼ֣Ĭϱ30죡\n"); + /*־ûйؼ֣Ĭϱ30*/ + chReval = MIN_DAY; + } + else + { + for (ii = 0U;ii < 50U;ii++) + { + if ('=' == szStr[ii]) + { + /*־ɾļҵȺźʱΪָʽ*/ + for (jj = 0U; jj < 3U; jj++) + { + ii++; + chConfigTimStr[jj] = szStr[ii]; + } + chConfigTime = atoi(chConfigTimStr); + break; + } + } + } + + if ((0U == chConfigTime) || (255U < chConfigTime)) + { + /*ֵ255ߵ0ɾ־*/ + chReval = MAX_DAY; + } + else + { + chReval = (UINT8)chConfigTime; + } + } + } + return chReval; +} + + +/* +* ӡǰϵͳʱ +* ˵ +* ֵ +*/ +void PrintfNowTime(void) +{ + SYSTEMTIME sys_T; + + /*ӡʱ*/ + GetLocalTime(&sys_T); + debug_infor_printf("SystemsCycletime=[%04d-%02d-%02d %02d:%02d:%02d,%03d]\n", sys_T.wYear, sys_T.wMonth, sys_T.wDay, sys_T.wHour, sys_T.wMinute, sys_T.wSecond, sys_T.wMilliseconds); + +} diff --git a/TSCP/src/main/CiSimulation.h b/TSCP/src/main/CiSimulation.h new file mode 100644 index 0000000..d867013 --- /dev/null +++ b/TSCP/src/main/CiSimulation.h @@ -0,0 +1,211 @@ +#ifndef _CISIMULATION_H_ +#define _CISIMULATION_H_ + +#define WIN32_LEAN_AND_MEAN + +#ifdef __cplusplus +extern "C" { +#endif + +#include "CommonTypes.h" +#include "dfsDataRead.h" +#include "ProtclManage.h" +#include "Convert.h" + +#include "CRC16.h" +#include "CRC32long.h" + +#include "RelayConfigDataManage.h" + + + + +#define DISTRIBUTED_IO_YES (0xAA) /*÷ֲʽIO*/ +#define DISTRIBUTED_IO_NO (0x55) /*÷ֲʽIO*/ +#define PU_CFG_FILE_LENGTH 7 /*ļij*/ +#define PU_CFG_FILE_DATA_LENGTH 3 /*ļݵij*/ +#define SCB_CABINET_MAX_NUM (4) /*IOԪĿ*/ +#define SCB_BOARD_MAX_NUM (SCB_CABINET_MAX_NUM * 2) /*ȫͨŰĿ*/ +#define BOARD_SUM_MAX 240 /*һվɼĿֵ*/ +#define MAX_IO_DEV_NUM (BOARD_SUM_MAX/2) +/*ȫͨŰַϵ*/ +#define SAFE_COMM_BOARD_ADDR_ID (0x10) +#define LEN_SAFE_COMM_BOARD_ADDR (4) /*޸ļ¼2018.05.03»߷ֲʽIO*/ +#define CI_DATA_TYPE 0x71 +/*=====================================================================*/ +#define ERROR (0) +#define OK (1) + +#define DSU_LEN_IP4_ADDR 4 +#define DSU_IP_CONFIG_TYPE 0x40 /*豸ipbookId*/ +#define DSU_DATA_ATS_NET_IP_ID 6 /*ATSIPtableId*/ +#define DSU_ATS_NET_IP_INFO_STRU_SIZE 30 +#define DSU_GATEWAY_INFO_STRU_SIZE_COPY 16 + +/*豸IP 궨*/ +#define DSU_DEVICE_IP_CONFIG_TYPE_COPY 0x40 /*豸ipbookId*/ +#define DSU_DATA_IP_GATEWAY_ID_COPY 5 /*hxq,豸رtableId*/ + +#define SIN_DEV_IP_SUM_MAX (8) /*嵥豸IPĿֵ*/ +#define ALL_DEV_IP_SUM_MAX (256) /*豸IPĿֵ*/ + + +#define ZHUJI_5 '5' /*߼ַͨſ1*/ +#define ZHUJI_6 '6' /*߼ַͨſ2*/ + + +/*=====================================================================*/ + + +extern UINT16 CiDrvBoardCurSum; /*CIվ嵱ǰ*/ +extern UINT16 CiCollBoardCurSum; /*CIվɼ嵱ǰ*/ +extern BoardDataStruct CiDrvBoardDataStru[]; /*ݽṹ*/ +extern BoardDataStruct CiCollBoardDataStru[]; /*ɼݽṹ*/ +/*=======================================================================*/ + + + + +/*ipַṹ*/ +typedef struct +{ + UINT16 DevName; /*豸ʶ*/ + + UINT8 IpAddrBlue[DSU_LEN_IP4_ADDR]; /*ipַ*/ + UINT8 MaskBlue[DSU_LEN_IP4_ADDR]; /*Mask*/ + UINT8 IpAddrRed[DSU_LEN_IP4_ADDR]; /*ipַ*/ + UINT8 MaskRed[DSU_LEN_IP4_ADDR]; /*Mask*/ + + UINT16 SfpBluePort; /*Sfp˿ں*/ + UINT16 SfpRedPort; /*Sfpغ˿ں*/ + + UINT16 RpBluePort; /*Rp˿ں*/ + UINT16 RpRedPort; /*Rpغ˿ں*/ + + UINT16 RsspBluePort; /*Rssp˿ں*/ + UINT16 RsspRedPort; /*Rsspغ˿ں*/ +}DSU_IP_INFO_STRU; + +typedef struct +{ + /*ATSIpַͶ˿ںϢݳȺ*/ + UINT16 AtsNetIpInfoStruLen; + DSU_IP_INFO_STRU *pAtsNetIpInfoStru; +}DSU_ATS_NET_IP_INFO_STRU; + +typedef struct +{ + UINT8 RedIp[DSU_LEN_IP4_ADDR]; /*IPַ*/ + UINT8 RedMask[DSU_LEN_IP4_ADDR]; /*IPַ*/ + UINT8 BlueIp[DSU_LEN_IP4_ADDR]; /*IPַ*/ + UINT8 BlueMask[DSU_LEN_IP4_ADDR]; /*IPַ*/ +} ATS_NET_IP_AND_MASK_STRU1; + + +/*hxq,豸رϢ*/ +typedef struct +{ + UINT16 Index; /*2 */ + UINT16 DeviceTypeId; /*2 豸ID*/ + UINT8 IpAddrGatewayBlue[DSU_LEN_IP4_ADDR]; /*4 豸*/ + UINT8 IpAddrGatewayRed[DSU_LEN_IP4_ADDR]; /*4 豸*/ + UINT8 IpAddrSubnetMask[DSU_LEN_IP4_ADDR]; /*4 */ + +}DSU_GATEWAY_INFO_STRU_COPY; +/*=======================================================================*/ +static UINT32 gInnetProtclParamLen = 17444; +static UINT8 gInnetProtclParam[17444] = { 0xe4,0xe1,0x02,0x13,0x81,0xfe,0x40,0x40,0x00,0x00,0x44,0x24,0x00,0x00,0x00,0x02,0x05,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x30,0x00,0x00,0x2f,0x1a,0x00,0x00,0x00,0x58,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x40,0x00,0x00,0x14,0xb2,0x00,0x00,0x2f,0x72,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x92,0x17,0x35,0x54,0x81,0x30,0x41,0x20,0x00,0x00,0x2f,0x1a,0x00,0x00,0x00,0x04,0x05,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x01,0x00,0x00,0x2e,0x7c,0x00,0x00,0x00,0x88,0x00,0x64,0x00,0x23,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x16,0x00,0x00,0x2f,0x04,0x00,0x02,0x00,0x09,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x1a,0x00,0x00,0x00,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x1a,0x00,0x00,0x00,0x0b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x01,0x00,0x00,0x64,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x16,0xa4,0xf0,0x1c,0x7d,0x54,0xf0,0x18,0x01,0x72,0xc4,0xf0,0x14,0x4f,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x64,0x01,0x00,0x00,0x00,0x01,0x00,0x02,0x6a,0x64,0xf0,0x1e,0x01,0x94,0xf0,0x1a,0x01,0x0e,0x04,0xf0,0x16,0x4f,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x64,0x02,0x00,0x00,0x00,0x01,0x00,0x01,0x11,0x24,0xf0,0x2c,0x7a,0xd4,0xf0,0x28,0x01,0x75,0x44,0xf0,0x24,0x4f,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x64,0x02,0x00,0x00,0x00,0x01,0x00,0x02,0x6d,0xe4,0xf0,0x2e,0x06,0x14,0xf0,0x2a,0x01,0x09,0x84,0xf0,0x26,0x4f,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x64,0x03,0x00,0x00,0x00,0x01,0x00,0x01,0x10,0xd4,0xf0,0x3c,0x7b,0x24,0xf0,0x38,0x01,0x74,0xb4,0xf0,0x34,0x4f,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x64,0x03,0x00,0x00,0x00,0x01,0x00,0x02,0x6c,0x14,0xf0,0x3e,0x07,0xe4,0xf0,0x3a,0x01,0x08,0x74,0xf0,0x36,0x4f,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x64,0x04,0x00,0x00,0x00,0x01,0x00,0x01,0x1d,0xe4,0xf0,0x4c,0x76,0x14,0xf0,0x48,0x01,0x79,0x84,0xf0,0x44,0x4f,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x64,0x04,0x00,0x00,0x00,0x01,0x00,0x02,0x61,0x24,0xf0,0x4e,0x0a,0xd4,0xf0,0x4a,0x01,0x05,0x44,0xf0,0x46,0x4f,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x64,0x05,0x00,0x00,0x00,0x01,0x00,0x01,0x1c,0x14,0xf0,0x5c,0x77,0xe4,0xf0,0x58,0x01,0x78,0x74,0xf0,0x54,0x4f,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x64,0x05,0x00,0x00,0x00,0x01,0x00,0x02,0x60,0xd4,0xf0,0x5e,0x0b,0x24,0xf0,0x5a,0x01,0x04,0xb4,0xf0,0x56,0x4f,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x64,0x06,0x00,0x00,0x00,0x01,0x00,0x01,0x1b,0x94,0xf0,0x6c,0x70,0x64,0xf0,0x68,0x01,0x7f,0xf4,0xf0,0x64,0x4f,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x64,0x06,0x00,0x00,0x00,0x01,0x00,0x02,0x67,0x54,0xf0,0x6e,0x0c,0xa4,0xf0,0x6a,0x01,0x03,0x34,0xf0,0x66,0x4f,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x00,0x00,0x64,0x07,0x00,0x00,0x00,0x01,0x00,0x01,0x1a,0x64,0xf0,0x7c,0x71,0x94,0xf0,0x78,0x01,0x7e,0x04,0xf0,0x74,0x4f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x64,0x07,0x00,0x00,0x00,0x01,0x00,0x02,0x66,0xa4,0xf0,0x7e,0x0d,0x54,0xf0,0x7a,0x01,0x02,0xc4,0xf0,0x76,0x4f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x64,0x08,0x00,0x00,0x00,0x01,0x00,0x01,0x1a,0x04,0xf0,0x8c,0x71,0xf4,0xf0,0x88,0x01,0x7e,0x64,0xf0,0x84,0x4f,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x64,0x08,0x00,0x00,0x00,0x01,0x00,0x02,0x66,0xc4,0xf0,0x8e,0x0d,0x34,0xf0,0x8a,0x01,0x02,0xa4,0xf0,0x86,0x4f,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x64,0x09,0x00,0x00,0x00,0x01,0x00,0x01,0x1b,0xf4,0xf0,0x9c,0x70,0x04,0xf0,0x98,0x01,0x7f,0x94,0xf0,0x94,0x4f,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x64,0x09,0x00,0x00,0x00,0x01,0x00,0x02,0x67,0x34,0xf0,0x9e,0x0c,0xc4,0xf0,0x9a,0x01,0x03,0x54,0xf0,0x96,0x4f,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x64,0x0a,0x00,0x00,0x00,0x01,0x00,0x01,0x1c,0x74,0xf0,0xac,0x77,0x84,0xf0,0xa8,0x01,0x78,0x14,0xf0,0xa4,0x4f,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x64,0x0a,0x00,0x00,0x00,0x01,0x00,0x02,0x60,0xb4,0xf0,0xae,0x0b,0x44,0xf0,0xaa,0x01,0x04,0xd4,0xf0,0xa6,0x4f,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x64,0x0b,0x00,0x00,0x00,0x01,0x00,0x01,0x1d,0x84,0xf0,0xbc,0x76,0x74,0xf0,0xb8,0x01,0x79,0xe4,0xf0,0xb4,0x4f,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x64,0x0b,0x00,0x00,0x00,0x01,0x00,0x02,0x61,0x44,0xf0,0xbe,0x0a,0xb4,0xf0,0xba,0x01,0x05,0x24,0xf0,0xb6,0x4f,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x17,0x00,0x00,0x64,0x0c,0x00,0x00,0x00,0x01,0x00,0x01,0x10,0xb4,0xf0,0xcc,0x7b,0x44,0xf0,0xc8,0x01,0x74,0xd4,0xf0,0xc4,0x4f,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x64,0x0c,0x00,0x00,0x00,0x01,0x00,0x02,0x6c,0x74,0xf0,0xce,0x07,0x84,0xf0,0xca,0x01,0x08,0x14,0xf0,0xc6,0x4f,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x64,0x0d,0x00,0x00,0x00,0x01,0x00,0x01,0x11,0x44,0xf0,0xdc,0x7a,0xb4,0xf0,0xd8,0x01,0x75,0x24,0xf0,0xd4,0x4f,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1a,0x00,0x00,0x64,0x0d,0x00,0x00,0x00,0x01,0x00,0x02,0x6d,0x84,0xf0,0xde,0x06,0x74,0xf0,0xda,0x01,0x09,0xe4,0xf0,0xd6,0x4f,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x64,0x0e,0x00,0x00,0x00,0x01,0x00,0x01,0x16,0xc4,0xf0,0xec,0x7d,0x34,0xf0,0xe8,0x01,0x72,0xa4,0xf0,0xe4,0x4f,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,0x64,0x0e,0x00,0x00,0x00,0x01,0x00,0x02,0x6a,0x04,0xf0,0xee,0x01,0xf4,0xf0,0xea,0x01,0x0e,0x64,0xf0,0xe6,0x4f,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1d,0x00,0x00,0x64,0x0f,0x00,0x00,0x00,0x01,0x00,0x01,0x17,0x34,0xf0,0xfc,0x7c,0xc4,0xf0,0xf8,0x01,0x73,0x54,0xf0,0xf4,0x4f,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x00,0x64,0x0f,0x00,0x00,0x00,0x01,0x00,0x02,0x6b,0xf4,0xf0,0xfe,0x00,0x04,0xf0,0xfa,0x01,0x0f,0x94,0xf0,0xf6,0x4f,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x00,0x00,0x64,0x10,0x00,0x00,0x00,0x01,0x00,0x01,0x05,0x84,0xf1,0x0c,0x6e,0x74,0xf1,0x08,0x01,0x61,0xe4,0xf1,0x04,0x4f,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x64,0x10,0x00,0x00,0x00,0x01,0x00,0x02,0x79,0x44,0xf1,0x0e,0x12,0xb4,0xf1,0x0a,0x01,0x1d,0x24,0xf1,0x06,0x4f,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x00,0x00,0x64,0x11,0x00,0x00,0x00,0x01,0x00,0x01,0x04,0x74,0xf1,0x1c,0x6f,0x84,0xf1,0x18,0x01,0x60,0x14,0xf1,0x14,0x4f,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x22,0x00,0x00,0x64,0x11,0x00,0x00,0x00,0x01,0x00,0x02,0x78,0xb4,0xf1,0x1e,0x13,0x44,0xf1,0x1a,0x01,0x1c,0xd4,0xf1,0x16,0x4f,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x64,0x12,0x00,0x00,0x00,0x01,0x00,0x01,0x03,0xf4,0xf1,0x2c,0x68,0x04,0xf1,0x28,0x01,0x67,0x94,0xf1,0x24,0x4f,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x64,0x12,0x00,0x00,0x00,0x01,0x00,0x02,0x7f,0x34,0xf1,0x2e,0x14,0xc4,0xf1,0x2a,0x01,0x1b,0x54,0xf1,0x26,0x4f,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x00,0x00,0x64,0x13,0x00,0x00,0x00,0x01,0x00,0x01,0x02,0x04,0xf1,0x3c,0x69,0xf4,0xf1,0x38,0x01,0x66,0x64,0xf1,0x34,0x4f,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0x00,0x00,0x64,0x13,0x00,0x00,0x00,0x01,0x00,0x02,0x7e,0xc4,0xf1,0x3e,0x15,0x34,0xf1,0x3a,0x01,0x1a,0xa4,0xf1,0x36,0x4f,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x27,0x00,0x00,0x64,0x14,0x00,0x00,0x00,0x01,0x00,0x01,0x0f,0x34,0xf1,0x4c,0x64,0xc4,0xf1,0x48,0x01,0x6b,0x54,0xf1,0x44,0x4f,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x00,0x00,0x64,0x14,0x00,0x00,0x00,0x01,0x00,0x02,0x73,0xf4,0xf1,0x4e,0x18,0x04,0xf1,0x4a,0x01,0x17,0x94,0xf1,0x46,0x4f,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0x00,0x00,0x64,0x15,0x00,0x00,0x00,0x01,0x00,0x01,0x0e,0xc4,0xf1,0x5c,0x65,0x34,0xf1,0x58,0x01,0x6a,0xa4,0xf1,0x54,0x4f,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2a,0x00,0x00,0x64,0x15,0x00,0x00,0x00,0x01,0x00,0x02,0x72,0x04,0xf1,0x5e,0x19,0xf4,0xf1,0x5a,0x01,0x16,0x64,0xf1,0x56,0x4f,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2b,0x00,0x00,0x64,0x16,0x00,0x00,0x00,0x01,0x00,0x01,0x09,0x44,0xf1,0x6c,0x62,0xb4,0xf1,0x68,0x01,0x6d,0x24,0xf1,0x64,0x4f,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x64,0x16,0x00,0x00,0x00,0x01,0x00,0x02,0x75,0x84,0xf1,0x6e,0x1e,0x74,0xf1,0x6a,0x01,0x11,0xe4,0xf1,0x66,0x4f,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x64,0x17,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0xb4,0xf1,0x7c,0x63,0x44,0xf1,0x78,0x01,0x6c,0xd4,0xf1,0x74,0x4f,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2e,0x00,0x00,0x64,0x17,0x00,0x00,0x00,0x01,0x00,0x02,0x74,0x74,0xf1,0x7e,0x1f,0x84,0xf1,0x7a,0x01,0x10,0x14,0xf1,0x76,0x4f,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x00,0x00,0x64,0x18,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0xd4,0xf1,0x8c,0x63,0x24,0xf1,0x88,0x01,0x6c,0xb4,0xf1,0x84,0x4f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x64,0x18,0x00,0x00,0x00,0x01,0x00,0x02,0x74,0x14,0xf1,0x8e,0x1f,0xe4,0xf1,0x8a,0x01,0x10,0x74,0xf1,0x86,0x4f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x00,0x00,0x64,0x19,0x00,0x00,0x00,0x01,0x00,0x01,0x09,0x24,0xf1,0x9c,0x62,0xd4,0xf1,0x98,0x01,0x6d,0x44,0xf1,0x94,0x4f,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x64,0x19,0x00,0x00,0x00,0x01,0x00,0x02,0x75,0xe4,0xf1,0x9e,0x1e,0x14,0xf1,0x9a,0x01,0x11,0x84,0xf1,0x96,0x4f,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x64,0x1a,0x00,0x00,0x00,0x01,0x00,0x01,0x0e,0xa4,0xf1,0xac,0x65,0x54,0xf1,0xa8,0x01,0x6a,0xc4,0xf1,0xa4,0x4f,0x1a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x00,0x00,0x64,0x1a,0x00,0x00,0x00,0x01,0x00,0x02,0x72,0x64,0xf1,0xae,0x19,0x94,0xf1,0xaa,0x01,0x16,0x04,0xf1,0xa6,0x4f,0x1a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x00,0x00,0x64,0x1b,0x00,0x00,0x00,0x01,0x00,0x01,0x0f,0x54,0xf1,0xbc,0x64,0xa4,0xf1,0xb8,0x01,0x6b,0x34,0xf1,0xb4,0x4f,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x64,0x1b,0x00,0x00,0x00,0x01,0x00,0x02,0x73,0x94,0xf1,0xbe,0x18,0x64,0xf1,0xba,0x01,0x17,0xf4,0xf1,0xb6,0x4f,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x00,0x00,0x64,0x1c,0x00,0x00,0x00,0x01,0x00,0x01,0x02,0x64,0xf1,0xcc,0x69,0x94,0xf1,0xc8,0x01,0x66,0x04,0xf1,0xc4,0x4f,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x64,0x1c,0x00,0x00,0x00,0x01,0x00,0x02,0x7e,0xa4,0xf1,0xce,0x15,0x54,0xf1,0xca,0x01,0x1a,0xc4,0xf1,0xc6,0x4f,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x39,0x00,0x00,0x64,0x1d,0x00,0x00,0x00,0x01,0x00,0x01,0x03,0x94,0xf1,0xdc,0x68,0x64,0xf1,0xd8,0x01,0x67,0xf4,0xf1,0xd4,0x4f,0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3a,0x00,0x00,0x64,0x1d,0x00,0x00,0x00,0x01,0x00,0x02,0x7f,0x54,0xf1,0xde,0x14,0xa4,0xf1,0xda,0x01,0x1b,0x34,0xf1,0xd6,0x4f,0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3b,0x00,0x00,0x64,0x1e,0x00,0x00,0x00,0x01,0x00,0x01,0x04,0x14,0xf1,0xec,0x6f,0xe4,0xf1,0xe8,0x01,0x60,0x74,0xf1,0xe4,0x4f,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x64,0x1e,0x00,0x00,0x00,0x01,0x00,0x02,0x78,0xd4,0xf1,0xee,0x13,0x24,0xf1,0xea,0x01,0x1c,0xb4,0xf1,0xe6,0x4f,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3d,0x00,0x00,0x64,0x1f,0x00,0x00,0x00,0x01,0x00,0x01,0x05,0xe4,0xf1,0xfc,0x6e,0x14,0xf1,0xf8,0x01,0x61,0x84,0xf1,0xf4,0x4f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x64,0x1f,0x00,0x00,0x00,0x01,0x00,0x02,0x79,0x24,0xf1,0xfe,0x12,0xd4,0xf1,0xfa,0x01,0x1d,0x44,0xf1,0xf6,0x4f,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0x00,0x64,0x20,0x00,0x00,0x00,0x01,0x00,0x01,0x02,0x34,0xf2,0x0c,0x69,0xc4,0xf2,0x08,0x01,0x66,0x54,0xf2,0x04,0x4f,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x64,0x20,0x00,0x00,0x00,0x01,0x00,0x02,0x7e,0xf4,0xf2,0x0e,0x15,0x04,0xf2,0x0a,0x01,0x1a,0x94,0xf2,0x06,0x4f,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x00,0x64,0x21,0x00,0x00,0x00,0x01,0x00,0x01,0x03,0xc4,0xf2,0x1c,0x68,0x34,0xf2,0x18,0x01,0x67,0xa4,0xf2,0x14,0x4f,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x00,0x00,0x64,0x21,0x00,0x00,0x00,0x01,0x00,0x02,0x7f,0x04,0xf2,0x1e,0x14,0xf4,0xf2,0x1a,0x01,0x1b,0x64,0xf2,0x16,0x4f,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x00,0x00,0x64,0x22,0x00,0x00,0x00,0x01,0x00,0x01,0x04,0x44,0xf2,0x2c,0x6f,0xb4,0xf2,0x28,0x01,0x60,0x24,0xf2,0x24,0x4f,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x64,0x22,0x00,0x00,0x00,0x01,0x00,0x02,0x78,0x84,0xf2,0x2e,0x13,0x74,0xf2,0x2a,0x01,0x1c,0xe4,0xf2,0x26,0x4f,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x64,0x23,0x00,0x00,0x00,0x01,0x00,0x01,0x05,0xb4,0xf2,0x3c,0x6e,0x44,0xf2,0x38,0x01,0x61,0xd4,0xf2,0x34,0x4f,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x00,0x00,0x64,0x23,0x00,0x00,0x00,0x01,0x00,0x02,0x79,0x74,0xf2,0x3e,0x12,0x84,0xf2,0x3a,0x01,0x1d,0x14,0xf2,0x36,0x4f,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x47,0x00,0x00,0x64,0x24,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x84,0xf2,0x4c,0x63,0x74,0xf2,0x48,0x01,0x6c,0xe4,0xf2,0x44,0x4f,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x64,0x24,0x00,0x00,0x00,0x01,0x00,0x02,0x74,0x44,0xf2,0x4e,0x1f,0xb4,0xf2,0x4a,0x01,0x10,0x24,0xf2,0x46,0x4f,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x49,0x00,0x00,0x64,0x25,0x00,0x00,0x00,0x01,0x00,0x01,0x09,0x74,0xf2,0x5c,0x62,0x84,0xf2,0x58,0x01,0x6d,0x14,0xf2,0x54,0x4f,0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x00,0x00,0x64,0x25,0x00,0x00,0x00,0x01,0x00,0x02,0x75,0xb4,0xf2,0x5e,0x1e,0x44,0xf2,0x5a,0x01,0x11,0xd4,0xf2,0x56,0x4f,0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4b,0x00,0x00,0x64,0x26,0x00,0x00,0x00,0x01,0x00,0x01,0x0e,0xf4,0xf2,0x6c,0x65,0x04,0xf2,0x68,0x01,0x6a,0x94,0xf2,0x64,0x4f,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4c,0x00,0x00,0x64,0x26,0x00,0x00,0x00,0x01,0x00,0x02,0x72,0x34,0xf2,0x6e,0x19,0xc4,0xf2,0x6a,0x01,0x16,0x54,0xf2,0x66,0x4f,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4d,0x00,0x00,0x64,0x27,0x00,0x00,0x00,0x01,0x00,0x01,0x0f,0x04,0xf2,0x7c,0x64,0xf4,0xf2,0x78,0x01,0x6b,0x64,0xf2,0x74,0x4f,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4e,0x00,0x00,0x64,0x27,0x00,0x00,0x00,0x01,0x00,0x02,0x73,0xc4,0xf2,0x7e,0x18,0x34,0xf2,0x7a,0x01,0x17,0xa4,0xf2,0x76,0x4f,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4f,0x00,0x00,0x64,0x28,0x00,0x00,0x00,0x01,0x00,0x01,0x0f,0x64,0xf2,0x8c,0x64,0x94,0xf2,0x88,0x01,0x6b,0x04,0xf2,0x84,0x4f,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x64,0x28,0x00,0x00,0x00,0x01,0x00,0x02,0x73,0xa4,0xf2,0x8e,0x18,0x54,0xf2,0x8a,0x01,0x17,0xc4,0xf2,0x86,0x4f,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x51,0x00,0x00,0x64,0x29,0x00,0x00,0x00,0x01,0x00,0x01,0x0e,0x94,0xf2,0x9c,0x65,0x64,0xf2,0x98,0x01,0x6a,0xf4,0xf2,0x94,0x4f,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x00,0x00,0x64,0x29,0x00,0x00,0x00,0x01,0x00,0x02,0x72,0x54,0xf2,0x9e,0x19,0xa4,0xf2,0x9a,0x01,0x16,0x34,0xf2,0x96,0x4f,0x29,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x53,0x00,0x00,0x64,0x2a,0x00,0x00,0x00,0x01,0x00,0x01,0x09,0x14,0xf2,0xac,0x62,0xe4,0xf2,0xa8,0x01,0x6d,0x74,0xf2,0xa4,0x4f,0x2a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x64,0x2a,0x00,0x00,0x00,0x01,0x00,0x02,0x75,0xd4,0xf2,0xae,0x1e,0x24,0xf2,0xaa,0x01,0x11,0xb4,0xf2,0xa6,0x4f,0x2a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0x00,0x00,0x64,0x2b,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0xe4,0xf2,0xbc,0x63,0x14,0xf2,0xb8,0x01,0x6c,0x84,0xf2,0xb4,0x4f,0x2b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x56,0x00,0x00,0x64,0x2b,0x00,0x00,0x00,0x01,0x00,0x02,0x74,0x24,0xf2,0xbe,0x1f,0xd4,0xf2,0xba,0x01,0x10,0x44,0xf2,0xb6,0x4f,0x2b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x00,0x00,0x64,0x2c,0x00,0x00,0x00,0x01,0x00,0x01,0x05,0xd4,0xf2,0xcc,0x6e,0x24,0xf2,0xc8,0x01,0x61,0xb4,0xf2,0xc4,0x4f,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x64,0x2c,0x00,0x00,0x00,0x01,0x00,0x02,0x79,0x14,0xf2,0xce,0x12,0xe4,0xf2,0xca,0x01,0x1d,0x74,0xf2,0xc6,0x4f,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x00,0x00,0x64,0x2d,0x00,0x00,0x00,0x01,0x00,0x01,0x04,0x24,0xf2,0xdc,0x6f,0xd4,0xf2,0xd8,0x01,0x60,0x44,0xf2,0xd4,0x4f,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5a,0x00,0x00,0x64,0x2d,0x00,0x00,0x00,0x01,0x00,0x02,0x78,0xe4,0xf2,0xde,0x13,0x14,0xf2,0xda,0x01,0x1c,0x84,0xf2,0xd6,0x4f,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5b,0x00,0x00,0x64,0x2e,0x00,0x00,0x00,0x01,0x00,0x01,0x03,0xa4,0xf2,0xec,0x68,0x54,0xf2,0xe8,0x01,0x67,0xc4,0xf2,0xe4,0x4f,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x00,0x00,0x64,0x2e,0x00,0x00,0x00,0x01,0x00,0x02,0x7f,0x64,0xf2,0xee,0x14,0x94,0xf2,0xea,0x01,0x1b,0x04,0xf2,0xe6,0x4f,0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5d,0x00,0x00,0x64,0x2f,0x00,0x00,0x00,0x01,0x00,0x01,0x02,0x54,0xf2,0xfc,0x69,0xa4,0xf2,0xf8,0x01,0x66,0x34,0xf2,0xf4,0x4f,0x2f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5e,0x00,0x00,0x64,0x2f,0x00,0x00,0x00,0x01,0x00,0x02,0x7e,0x94,0xf2,0xfe,0x15,0x64,0xf2,0xfa,0x01,0x1a,0xf4,0xf2,0xf6,0x4f,0x2f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x64,0x30,0x00,0x00,0x00,0x01,0x00,0x01,0x10,0xe4,0xf3,0x0c,0x7b,0x14,0xf3,0x08,0x01,0x74,0x84,0xf3,0x04,0x4f,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x64,0x30,0x00,0x00,0x00,0x01,0x00,0x02,0x6c,0x24,0xf3,0x0e,0x07,0xd4,0xf3,0x0a,0x01,0x08,0x44,0xf3,0x06,0x4f,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x00,0x00,0x64,0x31,0x00,0x00,0x00,0x01,0x00,0x01,0x11,0x14,0xf3,0x1c,0x7a,0xe4,0xf3,0x18,0x01,0x75,0x74,0xf3,0x14,0x4f,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x00,0x00,0x64,0x31,0x00,0x00,0x00,0x01,0x00,0x02,0x6d,0xd4,0xf3,0x1e,0x06,0x24,0xf3,0x1a,0x01,0x09,0xb4,0xf3,0x16,0x4f,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x00,0x64,0x32,0x00,0x00,0x00,0x01,0x00,0x01,0x16,0x94,0xf3,0x2c,0x7d,0x64,0xf3,0x28,0x01,0x72,0xf4,0xf3,0x24,0x4f,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x00,0x00,0x64,0x32,0x00,0x00,0x00,0x01,0x00,0x02,0x6a,0x54,0xf3,0x2e,0x01,0xa4,0xf3,0x2a,0x01,0x0e,0x34,0xf3,0x26,0x4f,0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x64,0x03,0x04,0x04,0x64,0x04,0x01,0x03,0x00,0x64,0x00,0x3c,0x03,0x03,0x03,0x50,0x03,0x65,0x03,0x00,0x4c,0xcd,0x41,0x81,0x40,0x44,0x60,0x00,0x00,0x14,0xb2,0x00,0x00,0x00,0x03,0x05,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x01,0x00,0x00,0x0f,0x3c,0x00,0x00,0x00,0x70,0x00,0x82,0x00,0x0d,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x0f,0xac,0x00,0x02,0x00,0x04,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x05,0x00,0x00,0x05,0x00,0x00,0x00,0x0f,0xb2,0x00,0x50,0x00,0x05,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x64,0x01,0x00,0x00,0x64,0x01,0xc0,0xa8,0x02,0x65,0xc0,0xa8,0x01,0x65,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x01,0x00,0x00,0x64,0x01,0xc0,0xa8,0x02,0x66,0xc0,0xa8,0x01,0x66,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x02,0x00,0x00,0x64,0x02,0xc0,0xa8,0x02,0x67,0xc0,0xa8,0x01,0x67,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x02,0x00,0x00,0x64,0x02,0xc0,0xa8,0x02,0x68,0xc0,0xa8,0x01,0x68,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x03,0x00,0x00,0x64,0x03,0xc0,0xa8,0x02,0x69,0xc0,0xa8,0x01,0x69,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x03,0x00,0x00,0x64,0x03,0xc0,0xa8,0x02,0x6a,0xc0,0xa8,0x01,0x6a,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x04,0x00,0x00,0x64,0x04,0xc0,0xa8,0x02,0x6b,0xc0,0xa8,0x01,0x6b,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x04,0x00,0x00,0x64,0x04,0xc0,0xa8,0x02,0x6c,0xc0,0xa8,0x01,0x6c,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x05,0x00,0x00,0x64,0x05,0xc0,0xa8,0x02,0x6d,0xc0,0xa8,0x01,0x6d,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x05,0x00,0x00,0x64,0x05,0xc0,0xa8,0x02,0x6e,0xc0,0xa8,0x01,0x6e,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x06,0x00,0x00,0x64,0x06,0xc0,0xa8,0x02,0x6f,0xc0,0xa8,0x01,0x6f,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x06,0x00,0x00,0x64,0x06,0xc0,0xa8,0x02,0x70,0xc0,0xa8,0x01,0x70,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x07,0x00,0x00,0x64,0x07,0xc0,0xa8,0x02,0x71,0xc0,0xa8,0x01,0x71,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x07,0x00,0x00,0x64,0x07,0xc0,0xa8,0x02,0x72,0xc0,0xa8,0x01,0x72,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x08,0x00,0x00,0x64,0x08,0xc0,0xa8,0x02,0x73,0xc0,0xa8,0x01,0x73,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x08,0x00,0x00,0x64,0x08,0xc0,0xa8,0x02,0x74,0xc0,0xa8,0x01,0x74,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x09,0x00,0x00,0x64,0x09,0xc0,0xa8,0x02,0x75,0xc0,0xa8,0x01,0x75,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x09,0x00,0x00,0x64,0x09,0xc0,0xa8,0x02,0x76,0xc0,0xa8,0x01,0x76,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0a,0x00,0x00,0x64,0x0a,0xc0,0xa8,0x02,0x77,0xc0,0xa8,0x01,0x77,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0a,0x00,0x00,0x64,0x0a,0xc0,0xa8,0x02,0x78,0xc0,0xa8,0x01,0x78,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0b,0x00,0x00,0x64,0x0b,0xc0,0xa8,0x02,0x79,0xc0,0xa8,0x01,0x79,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0b,0x00,0x00,0x64,0x0b,0xc0,0xa8,0x02,0x7a,0xc0,0xa8,0x01,0x7a,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0c,0x00,0x00,0x64,0x0c,0xc0,0xa8,0x02,0x7b,0xc0,0xa8,0x01,0x7b,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0c,0x00,0x00,0x64,0x0c,0xc0,0xa8,0x02,0x7c,0xc0,0xa8,0x01,0x7c,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0d,0x00,0x00,0x64,0x0d,0xc0,0xa8,0x02,0x7d,0xc0,0xa8,0x01,0x7d,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0d,0x00,0x00,0x64,0x0d,0xc0,0xa8,0x02,0x7e,0xc0,0xa8,0x01,0x7e,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0e,0x00,0x00,0x64,0x0e,0xc0,0xa8,0x02,0x7f,0xc0,0xa8,0x01,0x7f,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0e,0x00,0x00,0x64,0x0e,0xc0,0xa8,0x02,0x80,0xc0,0xa8,0x01,0x80,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0f,0x00,0x00,0x64,0x0f,0xc0,0xa8,0x02,0x81,0xc0,0xa8,0x01,0x81,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x0f,0x00,0x00,0x64,0x0f,0xc0,0xa8,0x02,0x82,0xc0,0xa8,0x01,0x82,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x10,0x00,0x00,0x64,0x10,0xc0,0xa8,0x02,0x83,0xc0,0xa8,0x01,0x83,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x10,0x00,0x00,0x64,0x10,0xc0,0xa8,0x02,0x84,0xc0,0xa8,0x01,0x84,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x11,0x00,0x00,0x64,0x11,0xc0,0xa8,0x02,0x85,0xc0,0xa8,0x01,0x85,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x11,0x00,0x00,0x64,0x11,0xc0,0xa8,0x02,0x86,0xc0,0xa8,0x01,0x86,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x12,0x00,0x00,0x64,0x12,0xc0,0xa8,0x02,0x87,0xc0,0xa8,0x01,0x87,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x12,0x00,0x00,0x64,0x12,0xc0,0xa8,0x02,0x88,0xc0,0xa8,0x01,0x88,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x13,0x00,0x00,0x64,0x13,0xc0,0xa8,0x02,0x89,0xc0,0xa8,0x01,0x89,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x13,0x00,0x00,0x64,0x13,0xc0,0xa8,0x02,0x8a,0xc0,0xa8,0x01,0x8a,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x14,0x00,0x00,0x64,0x14,0xc0,0xa8,0x02,0x8b,0xc0,0xa8,0x01,0x8b,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x14,0x00,0x00,0x64,0x14,0xc0,0xa8,0x02,0x8c,0xc0,0xa8,0x01,0x8c,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x15,0x00,0x00,0x64,0x15,0xc0,0xa8,0x02,0x8d,0xc0,0xa8,0x01,0x8d,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x15,0x00,0x00,0x64,0x15,0xc0,0xa8,0x02,0x8e,0xc0,0xa8,0x01,0x8e,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x16,0x00,0x00,0x64,0x16,0xc0,0xa8,0x02,0x8f,0xc0,0xa8,0x01,0x8f,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x16,0x00,0x00,0x64,0x16,0xc0,0xa8,0x02,0x90,0xc0,0xa8,0x01,0x90,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x17,0x00,0x00,0x64,0x17,0xc0,0xa8,0x02,0x91,0xc0,0xa8,0x01,0x91,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x17,0x00,0x00,0x64,0x17,0xc0,0xa8,0x02,0x92,0xc0,0xa8,0x01,0x92,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x18,0x00,0x00,0x64,0x18,0xc0,0xa8,0x02,0x93,0xc0,0xa8,0x01,0x93,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x18,0x00,0x00,0x64,0x18,0xc0,0xa8,0x02,0x94,0xc0,0xa8,0x01,0x94,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x19,0x00,0x00,0x64,0x19,0xc0,0xa8,0x02,0x95,0xc0,0xa8,0x01,0x95,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x19,0x00,0x00,0x64,0x19,0xc0,0xa8,0x02,0x96,0xc0,0xa8,0x01,0x96,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1a,0x00,0x00,0x64,0x1a,0xc0,0xa8,0x02,0x97,0xc0,0xa8,0x01,0x97,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1a,0x00,0x00,0x64,0x1a,0xc0,0xa8,0x02,0x98,0xc0,0xa8,0x01,0x98,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1b,0x00,0x00,0x64,0x1b,0xc0,0xa8,0x02,0x99,0xc0,0xa8,0x01,0x99,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1b,0x00,0x00,0x64,0x1b,0xc0,0xa8,0x02,0x9a,0xc0,0xa8,0x01,0x9a,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1c,0x00,0x00,0x64,0x1c,0xc0,0xa8,0x02,0x9b,0xc0,0xa8,0x01,0x9b,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1c,0x00,0x00,0x64,0x1c,0xc0,0xa8,0x02,0x9c,0xc0,0xa8,0x01,0x9c,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1d,0x00,0x00,0x64,0x1d,0xc0,0xa8,0x02,0x9d,0xc0,0xa8,0x01,0x9d,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1d,0x00,0x00,0x64,0x1d,0xc0,0xa8,0x02,0x9e,0xc0,0xa8,0x01,0x9e,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1e,0x00,0x00,0x64,0x1e,0xc0,0xa8,0x02,0x9f,0xc0,0xa8,0x01,0x9f,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1e,0x00,0x00,0x64,0x1e,0xc0,0xa8,0x02,0xa0,0xc0,0xa8,0x01,0xa0,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1f,0x00,0x00,0x64,0x1f,0xc0,0xa8,0x02,0xa1,0xc0,0xa8,0x01,0xa1,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x1f,0x00,0x00,0x64,0x1f,0xc0,0xa8,0x02,0xa2,0xc0,0xa8,0x01,0xa2,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x20,0x00,0x00,0x64,0x20,0xc0,0xa8,0x02,0xa3,0xc0,0xa8,0x01,0xa3,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x20,0x00,0x00,0x64,0x20,0xc0,0xa8,0x02,0xa4,0xc0,0xa8,0x01,0xa4,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x21,0x00,0x00,0x64,0x21,0xc0,0xa8,0x02,0xa5,0xc0,0xa8,0x01,0xa5,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x21,0x00,0x00,0x64,0x21,0xc0,0xa8,0x02,0xa6,0xc0,0xa8,0x01,0xa6,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x22,0x00,0x00,0x64,0x22,0xc0,0xa8,0x02,0xa7,0xc0,0xa8,0x01,0xa7,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x22,0x00,0x00,0x64,0x22,0xc0,0xa8,0x02,0xa8,0xc0,0xa8,0x01,0xa8,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x23,0x00,0x00,0x64,0x23,0xc0,0xa8,0x02,0xa9,0xc0,0xa8,0x01,0xa9,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x23,0x00,0x00,0x64,0x23,0xc0,0xa8,0x02,0xaa,0xc0,0xa8,0x01,0xaa,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x24,0x00,0x00,0x64,0x24,0xc0,0xa8,0x02,0xab,0xc0,0xa8,0x01,0xab,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x24,0x00,0x00,0x64,0x24,0xc0,0xa8,0x02,0xac,0xc0,0xa8,0x01,0xac,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x25,0x00,0x00,0x64,0x25,0xc0,0xa8,0x02,0xad,0xc0,0xa8,0x01,0xad,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x25,0x00,0x00,0x64,0x25,0xc0,0xa8,0x02,0xae,0xc0,0xa8,0x01,0xae,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x26,0x00,0x00,0x64,0x26,0xc0,0xa8,0x02,0xaf,0xc0,0xa8,0x01,0xaf,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x26,0x00,0x00,0x64,0x26,0xc0,0xa8,0x02,0xb0,0xc0,0xa8,0x01,0xb0,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x27,0x00,0x00,0x64,0x27,0xc0,0xa8,0x02,0xb1,0xc0,0xa8,0x01,0xb1,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x27,0x00,0x00,0x64,0x27,0xc0,0xa8,0x02,0xb2,0xc0,0xa8,0x01,0xb2,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x28,0x00,0x00,0x64,0x28,0xc0,0xa8,0x02,0xb3,0xc0,0xa8,0x01,0xb3,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x28,0x00,0x00,0x64,0x28,0xc0,0xa8,0x02,0xb4,0xc0,0xa8,0x01,0xb4,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x29,0x00,0x00,0x64,0x29,0xc0,0xa8,0x02,0xb5,0xc0,0xa8,0x01,0xb5,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x29,0x00,0x00,0x64,0x29,0xc0,0xa8,0x02,0xb6,0xc0,0xa8,0x01,0xb6,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2a,0x00,0x00,0x64,0x2a,0xc0,0xa8,0x02,0xb7,0xc0,0xa8,0x01,0xb7,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2a,0x00,0x00,0x64,0x2a,0xc0,0xa8,0x02,0xb8,0xc0,0xa8,0x01,0xb8,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2b,0x00,0x00,0x64,0x2b,0xc0,0xa8,0x02,0xb9,0xc0,0xa8,0x01,0xb9,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2b,0x00,0x00,0x64,0x2b,0xc0,0xa8,0x02,0xba,0xc0,0xa8,0x01,0xba,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2c,0x00,0x00,0x64,0x2c,0xc0,0xa8,0x02,0xbb,0xc0,0xa8,0x01,0xbb,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2c,0x00,0x00,0x64,0x2c,0xc0,0xa8,0x02,0xbc,0xc0,0xa8,0x01,0xbc,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2d,0x00,0x00,0x64,0x2d,0xc0,0xa8,0x02,0xbd,0xc0,0xa8,0x01,0xbd,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2d,0x00,0x00,0x64,0x2d,0xc0,0xa8,0x02,0xbe,0xc0,0xa8,0x01,0xbe,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2e,0x00,0x00,0x64,0x2e,0xc0,0xa8,0x02,0xbf,0xc0,0xa8,0x01,0xbf,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2e,0x00,0x00,0x64,0x2e,0xc0,0xa8,0x02,0xc0,0xc0,0xa8,0x01,0xc0,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2f,0x00,0x00,0x64,0x2f,0xc0,0xa8,0x02,0xc1,0xc0,0xa8,0x01,0xc1,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x2f,0x00,0x00,0x64,0x2f,0xc0,0xa8,0x02,0xc2,0xc0,0xa8,0x01,0xc2,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x30,0x00,0x00,0x64,0x30,0xc0,0xa8,0x02,0xc3,0xc0,0xa8,0x01,0xc3,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x30,0x00,0x00,0x64,0x30,0xc0,0xa8,0x02,0xc4,0xc0,0xa8,0x01,0xc4,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x31,0x00,0x00,0x64,0x31,0xc0,0xa8,0x02,0xc5,0xc0,0xa8,0x01,0xc5,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x31,0x00,0x00,0x64,0x31,0xc0,0xa8,0x02,0xc6,0xc0,0xa8,0x01,0xc6,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x32,0x00,0x00,0x64,0x32,0xc0,0xa8,0x02,0xc7,0xc0,0xa8,0x01,0xc7,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x64,0x32,0x00,0x00,0x64,0x32,0xc0,0xa8,0x02,0xc8,0xc0,0xa8,0x01,0xc8,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x01,0x00,0x00,0x3c,0x01,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x02,0x00,0x00,0x3c,0x02,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x03,0x00,0x00,0x3c,0x03,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x04,0x00,0x00,0x3c,0x04,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x05,0x00,0x00,0x3c,0x05,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x06,0x00,0x00,0x3c,0x06,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x07,0x00,0x00,0x3c,0x07,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x08,0x00,0x00,0x3c,0x08,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x09,0x00,0x00,0x3c,0x09,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0a,0x00,0x00,0x3c,0x0a,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0b,0x00,0x00,0x3c,0x0b,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0c,0x00,0x00,0x3c,0x0c,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0d,0x00,0x00,0x3c,0x0d,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0e,0x00,0x00,0x3c,0x0e,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x0f,0x00,0x00,0x3c,0x0f,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x10,0x00,0x00,0x3c,0x10,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x11,0x00,0x00,0x3c,0x11,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x12,0x00,0x00,0x3c,0x12,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x13,0x00,0x00,0x3c,0x13,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x14,0x00,0x00,0x3c,0x14,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x15,0x00,0x00,0x3c,0x15,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x16,0x00,0x00,0x3c,0x16,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x17,0x00,0x00,0x3c,0x17,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x18,0x00,0x00,0x3c,0x18,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x19,0x00,0x00,0x3c,0x19,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1a,0x00,0x00,0x3c,0x1a,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1b,0x00,0x00,0x3c,0x1b,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1c,0x00,0x00,0x3c,0x1c,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1d,0x00,0x00,0x3c,0x1d,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x1e,0x00,0x00,0x3c,0x1e,0xc0,0xa8,0x02,0x64,0xc0,0xa8,0x01,0x64,0xc3,0x53,0xc3,0x53,0xc3,0x51,0xc3,0x51,0xc3,0x52,0xc3,0x52,0xff,0xff,0xff,0xff,0x3c,0x64,0x04,0x64,0x3c,0x04,0x00,0x01,0x64,0x01,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x02,0x64,0x02,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x03,0x64,0x03,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x04,0x64,0x04,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x05,0x64,0x05,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x06,0x64,0x06,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x07,0x64,0x07,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x08,0x64,0x08,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x09,0x64,0x09,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0a,0x64,0x0a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0b,0x64,0x0b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0c,0x64,0x0c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0d,0x64,0x0d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0e,0x64,0x0e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x0f,0x64,0x0f,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x10,0x64,0x10,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x11,0x64,0x11,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x12,0x64,0x12,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x13,0x64,0x13,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x14,0x64,0x14,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x15,0x64,0x15,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x16,0x64,0x16,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x17,0x64,0x17,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x18,0x64,0x18,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x19,0x64,0x19,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1a,0x64,0x1a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1b,0x64,0x1b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1c,0x64,0x1c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1d,0x64,0x1d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1e,0x64,0x1e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x1f,0x64,0x1f,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x20,0x64,0x20,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x21,0x64,0x21,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x22,0x64,0x22,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x23,0x64,0x23,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x24,0x64,0x24,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x25,0x64,0x25,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x26,0x64,0x26,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x27,0x64,0x27,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x28,0x64,0x28,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x29,0x64,0x29,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2a,0x64,0x2a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2b,0x64,0x2b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2c,0x64,0x2c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2d,0x64,0x2d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2e,0x64,0x2e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x2f,0x64,0x2f,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x30,0x64,0x30,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x31,0x64,0x31,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x32,0x64,0x32,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x33,0x3c,0x01,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x34,0x3c,0x02,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x35,0x3c,0x03,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x36,0x3c,0x04,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x37,0x3c,0x05,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x38,0x3c,0x06,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x39,0x3c,0x07,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3a,0x3c,0x08,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3b,0x3c,0x09,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3c,0x3c,0x0a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3d,0x3c,0x0b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3e,0x3c,0x0c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x3f,0x3c,0x0d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x40,0x3c,0x0e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x41,0x3c,0x0f,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x42,0x3c,0x10,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x43,0x3c,0x11,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x44,0x3c,0x12,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x45,0x3c,0x13,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x46,0x3c,0x14,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x47,0x3c,0x15,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x48,0x3c,0x16,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x49,0x3c,0x17,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4a,0x3c,0x18,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4b,0x3c,0x19,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4c,0x3c,0x1a,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4d,0x3c,0x1b,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4e,0x3c,0x1c,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x4f,0x3c,0x1d,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00,0x00,0x50,0x3c,0x1e,0xc0,0xa8,0x01,0xfe,0xc0,0xa8,0x02,0xfe,0xff,0xff,0xff,0x00 }; + +UINT8 CiSimulationInit(); + +UINT8 CiSimulationStart(); + +UINT8 CiSimulationRelease(); + +UINT8 ReadLocalCiId(); +/*뱾ID*/ +UINT8 peiZhi_innerNet(void); +/*ļȡID*/ +unsigned char ReadPeiZhiId( const char* filePath); +/* ȡCI.CFGļõ豸͡͡豸IDCI.CFGCRCУ*/ +UINT16 ReadCI_CFG(unsigned char * sheBeiType , unsigned char * sheBeiID); +/*ȡֲʽܿأжǷǷֲʽ*/ +void DistributeIOFlag( void); +/*ȡȫͨŰ*/ +int GetSafeCommUnitCount(void); +/*ȡɼ忨忨ַ*/ +void GetSYSCollFsioCount(void); +/*ȡ忨忨ַ*/ +void GetSYSDriverFsioCount(void); +/*ȡһϵɼظİ忨ȥظ忨*/ +int GetSysOneFSIOcount(void) ; +/*ȡϵɼظİ忨ȥظ忨*/ +int GetSysTwoFSIOcount(void) ; +/*ʼȽһϵϵ忨Ƿһ£һ崻*/ +int InitialCompareSysFsioCount(void); + /*жȡȫͨŰַϵ*/ +int dsuCISafeComBrdAddr( CHAR* FSName); +/*=========================== */ +/*: ڴ渳ֵ*/ + UINT8 CommonMemSetCopy(void* pDest, UINT32 destBuffSize, UINT8 c, UINT32 count); + /*ATSIPϢѯݳʼ.*/ +int dsuAtsNetIp_Init(UINT8* FSName); +/*豸ƲѯATSIPַ*/ +int CC_GetAtsNetIpInfoByDevName(UINT16 devName, ATS_NET_IP_AND_MASK_STRU1 * pIpAndMaskInfo); +/*ATSͨſóʼ.*/ +int AtsNet_Initial(UINT32* ipBlue,UINT32* maskBlue,UINT32* ipRed,UINT32* maskRed); +/*ѯCCӦĺ*/ +UINT8 CheckLocalGatewayInfoCopy(UINT16 localTypeId, UINT32 * localRedGateWayBuff, UINT32 *localBlueGateWayBuff, UINT32 * subnetMaskBuff); +/* : ѯ豸رϢ */ +UINT8 dsuLocalIpGatewayInfoInit(UINT8* FSName); +/*ѯ豸ATSǷͬһΣͬһλᵼ°ʧ*/ +int InitCheckIPMask(void); +/* +: + ȡ豸IPñ +: + +: + +ֵ: + . +*/ +void ReadCIFsDevIpTable(const char * pCiFsPath); +/* +: + ȡCI_ATS豸IPַ +: + +: + +ֵ: + . +*/ +void ReadCIATSFsDevIpTable(const char * pCiFsPath); + +void PackOcToCloudData(void); +int gettimeofday(struct timeval *tp, void *tzp); +/*=============================*/ + +/* +* ȡ־ӡļ +* ˵ void +* ֵ ־ɾʱ +* by cgh 20231122 +*/ +UINT8 ReadLogConfig(void); + + + +/* +* ȡ־ӡļ +* ˵ void +* ֵ ־ɾʱ +* by cgh 20231122 +*/ +UINT8 ReadLogConfig(void); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/TSCP/src/main/DeviceInfoManager/readxmltodata.cpp b/TSCP/src/main/DeviceInfoManager/readxmltodata.cpp new file mode 100644 index 0000000..ca51850 --- /dev/null +++ b/TSCP/src/main/DeviceInfoManager/readxmltodata.cpp @@ -0,0 +1,1723 @@ +#include +#include +#include +#include +#include "readxmltodata.h" +#include ".\\tinyxml\\tinyxml.h"/*ȡXMLĵ*/ +#include "Convert.h" +#include "dsuRssp2Func.h" +#include "dquIdmapQuery.h" +#include "SystemParameterManage.h" + + +#define PATH_IPCONFIG "ini\\ZC.xml" /*ŵIPñ·*/ + +static CiAtsCfg ciAtsCfgInfo; +static CiOcCfg ciOcCfgInfo; +DeviceIpInfoStru gDeviceIpInfoArray[1000]; +DeviceIpInfoStru gDeviceIpInfoArrayATS[200]; +DeviceIpInfoStru gDeviceIpInfoArrayLeu[100]; + + +UINT16 gDeviceNum = 0;//豸Ŀ +UINT16 gDeviceNumLeu = 0;//LEUCIļ豸Ŀ +UINT16 gDeviceNumAts = 0;//ATSCIļ豸Ŀ +UINT16 gDeviceNumOc = 0;//OCļ豸Ŀ +static IpInfo pCiIpInfo[4]; +static IpInfo pAtsIpInfo[4]; + +UINT16 gPortDataLen = 0u;/*˿ڱЧ*/ +PORT_DATA_STRUCT *gpPortData = NULL;/*˿ڱָ룬ȫֱ*/ + +UINT16 StrToIntData(char chTempData[20],UINT16 wDataLen) +{ + UINT16 wTempID = DEFAULT_ZERO; + UINT16 wCycle = DEFAULT_ZERO; + UINT8 wOneData = DEFAULT_ZERO; + UINT16 wDataMultiple = 1; + + for (wCycle = wDataLen - 1;wCycle >= (UINT8)DEFAULT_ZERO;wCycle--) + { + switch (chTempData[wCycle]) + { + case '0': + wOneData = 0; + break; + case '1': + wOneData = 1; + break; + case '2': + wOneData = 2; + break; + case '3': + wOneData = 3; + break; + case '4': + wOneData = 4; + break; + case '5': + wOneData = 5; + break; + case '6': + wOneData = 6; + break; + case '7': + wOneData =7; + break; + case '8': + wOneData = 8; + break; + case '9': + wOneData = 9; + break; + case 'a': + wOneData = 10; + break; + case 'b': + wOneData = 11; + break; + case 'c': + wOneData = 12; + break; + case 'd': + wOneData = 13; + break; + case 'e': + wOneData = 14; + break; + case 'f': + wOneData = 15; + break; + } + + if (wCycle == (wDataLen - 1)) + { + wDataMultiple = 1; + } + else + { + wDataMultiple = wDataMultiple * 16; + } + + wTempID = wOneData * wDataMultiple + wTempID; + + if (wCycle == 0) + { + break; + } + else + { + } + } + + return wTempID; +} + +void SetDataOfConfig(char chTempData[20],char chTempName[200],UINT16 wDataLen) +{ + static int wConfigCycle = DEFAULT_ZERO; + char chChangeData[20]; + int wTempID = DEFAULT_ZERO; + + memset(chChangeData,DEFAULT_ZERO,sizeof(char) * 20); + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + if (('0' == chTempData[0]) && ('x' == chTempData[1])) + { + memset(chChangeData,DEFAULT_ZERO,sizeof(char) * 20); + memcpy(chChangeData,&chTempData[2],4); + + gDeviceIpInfoArray[wConfigCycle].deviceName = StrToIntData(chChangeData,4); + } + else + { + printf("Id and Tpye error!\n"); + } + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].logicId = atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + sscanf(chTempData,"%d.%d.%d.%d",&gDeviceIpInfoArray[wConfigCycle].redIp[0],&gDeviceIpInfoArray[wConfigCycle].redIp[1],&gDeviceIpInfoArray[wConfigCycle].redIp[2],&gDeviceIpInfoArray[wConfigCycle].redIp[3]); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + sscanf(chTempData,"%d.%d.%d.%d",&gDeviceIpInfoArray[wConfigCycle].blueIp[0],&gDeviceIpInfoArray[wConfigCycle].blueIp[1],&gDeviceIpInfoArray[wConfigCycle].blueIp[2],&gDeviceIpInfoArray[wConfigCycle].blueIp[3]); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].bluePort[SFP_IDX] = (UINT16)atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].redPort[SFP_IDX] = atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].bluePort[RP_IDX] = atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].redPort[RP_IDX] = atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].bluePort[RSSP1_IDX] = atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].redPort[RSSP1_IDX] = atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].bluePort[RSSP2_IDX] = atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + gDeviceIpInfoArray[wConfigCycle].redPort[RSSP2_IDX] = atoi(chTempData); + + wConfigCycle++; + gDeviceNum = wConfigCycle; + } + else + { + } +} + +void GetOneData(char chDataBuff[200],const UINT16 strLen) +{ + int wCycle = DEFAULT_ZERO; + + UINT8 chStartFlag = DEFAULT_ZERO; + UINT8 chEndFlag = DEFAULT_ZERO; + char chTempData[20]; + char chTempName[200]; + UINT8 chDataIndex = DEFAULT_ZERO; + UINT8 chNameIndex = DEFAULT_ZERO; + UINT8 chNameFlag = DEFAULT_ZERO; + + memset(chTempData,DEFAULT_ZERO,sizeof(char) * 20); + memset(chTempName,DEFAULT_ZERO,sizeof(char) * 200); + + for (wCycle = (UINT16)DEFAULT_ZERO;wCycle < strLen;wCycle++) + { + if ((chDataBuff[wCycle] == '<') && ((UINT8)FLAG_SET != chStartFlag)) + { + chNameFlag = (UINT8)FLAG_SET; + } + else + { + if ((UINT8)FLAG_SET == chStartFlag) + { + chNameFlag = (UINT8)FLAG_UNSET; + } + else + { + } + } + + if (FLAG_SET == chNameFlag) + { + chTempName[chNameIndex] = chDataBuff[wCycle]; + chNameIndex++; + } + else + { + } + + if (chDataBuff[wCycle] == '>') + { + if (wCycle == strLen - 1) + { + break; + } + else + { + chStartFlag = FLAG_SET; + continue; + } + } + else + { + } + + if ((UINT8)FLAG_SET == chStartFlag) + { + if ((chDataBuff[wCycle] == '<') && (chDataBuff[wCycle + 1] == '/')) + { + break; + } + else + { + chTempData[chDataIndex] = chDataBuff[wCycle]; + chDataIndex++; + } + } + else + { + } + } + + if ((chDataIndex > 0) && (chNameIndex > 0)) + { + SetDataOfConfig(chTempData,chTempName,chDataIndex); + } + else + { + } +} + +void ReadXml(const char * pPath) +{ + FILE *pFile = NULL; + char ch; + char chDataBuff[200]; + UINT16 wIndex = DEFAULT_ZERO; + + memset(gDeviceIpInfoArray, DEFAULT_ZERO, sizeof(gDeviceIpInfoArray)); + memset(chDataBuff, DEFAULT_ZERO, sizeof(char) * 200); + + if(gDeviceNum == 0 ) + { + if (NULL == (pFile = fopen(pPath,"rt"))) + { + printf("Open File error!\n"); + + return; + } + else + { + } + + while (EOF != (ch=fgetc(pFile))) + { + if (ch != '\n') + { + if (ch != ' ') + { + chDataBuff[wIndex] = ch; + wIndex++; + } + else + { + } + } + else + { + GetOneData(chDataBuff,wIndex); + memset(chDataBuff,0,sizeof(char) * 200); + wIndex = 0; + } + } + + + fclose(pFile); + + } +} + +/********************************************* +*ܣ豸ID+IDָЭŵEndPointϢ +*˵ +*ڲ + devId豸ID + prtlIdxЭ +*ڲ + pIpInfosҵEndPointϢ + ipCntEndPoint +*ֵʧܻɹ +*********************************************/ + +UINT8 GetNetEndPoint(UINT16 devId, UINT16 logicId, UINT8 prtlIdx, IpInfo pIpInfos[], UINT8 *ipCnt) +{ + UINT16 idx = 0; + UINT8 retVal = ERR_DEF; + UINT8 tempIpCnt = 0; + *ipCnt=0; + int flag=0; + int i=0; + UINT16 index = 0; + UINT32 hlhtId = 0u; + + UINT8 getHlhtRet = 0u; + UINT8 isFind = 0u; + UINT8 devType = 0u; + UINT8 id = 0u; + UINT32 vobcId[2] = { 0,0 }; + UINT32 iteId[2] = { 0,0 }; + UINT8 tempDevType = 0; + UINT16 tempDevId = 0; + UINT8 chFuncRtn = 0U; + UINT8 chDsnSwitch = GetCiFunctionSwitchConfig(FUNC_DSN_LINE_SWITCH); + + if(prtlIdx> 8; + if (0x18 == tempDevType) + { + chFuncRtn = 1; + break; + } + else + { + chFuncRtn = 0; + } + } + } + else + { + ; /* ƽӿڻ */ + } + + tempDevType = devId >> 8; + if ((1 == chFuncRtn) && ((0x14 == tempDevType) || (0x18 == tempDevType)))/* Ƶ ǰdz ҪIPΪƵIP */ + { + tempDevId = 0x3c00 | GetSystemParaLocalCiId(); + for (idx = 0; idx < gDeviceNum; idx++) + { + if (0x1801 == gDeviceIpInfoArray[idx].deviceName) + { + /* ƵIP */ + pIpInfos[0].blueIp = LongFromChar(gDeviceIpInfoArray[idx].blueIp); + pIpInfos[0].redIp = LongFromChar(gDeviceIpInfoArray[idx].redIp); + pIpInfos[0].bluePort = gDeviceIpInfoArray[idx].bluePort[prtlIdx]; + pIpInfos[0].redPort = gDeviceIpInfoArray[idx].redPort[prtlIdx]; + } + if (tempDevId == gDeviceIpInfoArray[idx].deviceName) + { + /* OCIP */ + pIpInfos[1].blueIp = LongFromChar(gDeviceIpInfoArray[idx].blueIp); + pIpInfos[1].redIp = LongFromChar(gDeviceIpInfoArray[idx].redIp); + pIpInfos[1].bluePort = gDeviceIpInfoArray[idx].bluePort[prtlIdx]; + pIpInfos[1].redPort = gDeviceIpInfoArray[idx].redPort[prtlIdx]; + } + if (devId == gDeviceIpInfoArray[idx].deviceName && logicId == gDeviceIpInfoArray[idx].logicId) + { + /* 泵IP */ + pIpInfos[2].blueIp = LongFromChar(gDeviceIpInfoArray[idx].blueIp); + pIpInfos[2].redIp = LongFromChar(gDeviceIpInfoArray[idx].redIp); + pIpInfos[2].bluePort = gDeviceIpInfoArray[idx].bluePort[prtlIdx]; + pIpInfos[2].redPort = gDeviceIpInfoArray[idx].redPort[prtlIdx]; + } + retVal = 2; + } + } + else + { + /*idx豸ipñ*/ + for (idx = 0; idx < gDeviceNum; idx++) + { + isFind = 0u; + if ((1u == getHlhtRet) && (0u != hlhtId)) /*лͨ*/ + { + if (hlhtId == gDeviceIpInfoArray[idx].estId) + { + isFind = 1u; + } + } + else + { + if (devId == gDeviceIpInfoArray[idx].deviceName) + { + isFind = 1u; + } + } + + if (1u == isFind) + { + pIpInfos[tempIpCnt].blueIp = LongFromChar(gDeviceIpInfoArray[idx].blueIp); + pIpInfos[tempIpCnt].redIp = LongFromChar(gDeviceIpInfoArray[idx].redIp); + pIpInfos[tempIpCnt].bluePort = gDeviceIpInfoArray[idx].bluePort[prtlIdx];/*˿ڣҪ޸*/ + pIpInfos[tempIpCnt].redPort = gDeviceIpInfoArray[idx].redPort[prtlIdx];/*˿ڣҪ޸*/ + if (0x14 == (devId >> 8) && ((0xFFFF == pIpInfos[tempIpCnt].bluePort) || (0xFFFF == pIpInfos[tempIpCnt].redPort))) + { + flag = 1; + } + index = tempIpCnt; + tempIpCnt++; + } + + if (1 == flag) + { + for (i = 0; i < gPortDataLen; i++) + { + if ((SYSTEM_TYPE_CI == (gpPortData[i].SrcDeviceType & 0xFF)) + && (SYSTEM_TYPE_VOBC == (gpPortData[i].DstDeviceType & 0xFF)) + && (FACTORY_NO_TCT == gpPortData[i].SrcFactoryNo) /*س̺2*/ + && (gpPortData[i].DstFactoryNo == ((gDeviceIpInfoArray[idx].estId >> 29) & 0x07)) + )/*Դ豸dz,hlhtId3bitԴ̺*/ + { + if (0x1 == logicId) + { + pIpInfos[index].bluePort = gpPortData[i].Tc1BlueRecvPort;/*˿ڣҪ޸*/ + pIpInfos[index].redPort = gpPortData[i].Tc1RedRecvPort;/*˿ڣҪ޸*/ + } + else if (0x2 == logicId) + { + pIpInfos[index].bluePort = gpPortData[i].Tc2BlueRecvPort;/*˿ڣҪ޸*/ + pIpInfos[index].redPort = gpPortData[i].Tc2RedRecvPort;/*˿ڣҪ޸*/ + } + break; + } + } + flag = 0; + } + + } + } + + + } + if(tempIpCnt>0) + { + retVal = SUC_DEF; + } + + *ipCnt=tempIpCnt; + + return retVal; +} + +/********************************************* +*ܣ豸ID+IDָЭŵATSEndPointϢ + *˵ + *ڲ + devId豸ID + prtlIdxЭ + *ڲ + pIpInfosҵEndPointϢ + ipCntEndPoint + *ֵʧܻɹ + *********************************************/ +UINT8 GetNetATSEndPoint(UINT16 devId, UINT16 logicId, UINT8 prtlIdx, IpInfo pIpInfos[], UINT8 *ipCnt) +{ + UINT16 idx = 0; + UINT8 retVal = ERR_DEF; + UINT8 tempIpCnt = 0; + *ipCnt=0; + + if(prtlIdx0) + { + retVal = SUC_DEF; + } + + *ipCnt=tempIpCnt; + + return retVal; +} + + +/* 豸ƺЭͲIPͶ˿ڣ +*ҳɹ0ʧܷ ֵ +*һ豸жIPnumΪҵIP +*/ +UINT8 GetIpAndPortByDeviceName(UINT16 deviceName,UINT8 protocolType,IpInfo pIpInfo[],UINT8 *num) +{ + UINT16 index = 0;/*ҷΧĿ*/ + UINT8 idxPrtcl = 0;/*ЭӦĶ˿*/ + UINT8 retVal = 1;/*ֵҳɹ㣬ʼΪ1*/ + UINT8 ipIndex = 0;/*ҵIPĿ*/ + + UINT8 flag = 0;/*ҪҵЭǷ*/ + switch (protocolType) + { + case 1: /* sfp Э */ + idxPrtcl = 0; + flag = 1; + break; + case 2: /* rp */ + idxPrtcl = 1; + flag = 1; + break; + case 3: /* rsr */ + idxPrtcl = 2; + flag = 1; + break; + case 4: /* rssp */ + idxPrtcl = 2; + flag = 1; + break; + case 5: /* rssp */ + idxPrtcl = 3; + flag = 1; + break; + default: + flag = 0;/*ûҪҵЭ*/ + break; /* Ĭ sfp */ + } + + if (0 == gDeviceNum) + { + /*printf("ȡXMLļʧܣ\n");*/ + retVal = 2;/*ȡXMLļʧ*/ + } + for (index = 0; index < gDeviceNum; index++) + { + /* 豸ƺЭǷ */ + if ((flag == 1)&&(deviceName == gDeviceIpInfoArray[index].deviceName)) + { + /*pIpInfo[ipIndex].blueIp ֵ */ + pIpInfo[ipIndex].blueIp = LongFromChar(gDeviceIpInfoArray[index].blueIp); + pIpInfo[ipIndex].redIp = LongFromChar(gDeviceIpInfoArray[index].redIp); + pIpInfo[ipIndex].bluePort = gDeviceIpInfoArray[index].bluePort[idxPrtcl]; + pIpInfo[ipIndex].redPort = gDeviceIpInfoArray[index].redPort[idxPrtcl]; + ipIndex++; + } + + } + *num = ipIndex; + if (ipIndex == 0) + { + retVal = 1;/*ûвҵ*/ + } + else + { + retVal = 0; + } + return retVal; +} + +/*IPͶ˿ڲ豸ƣ +ҳɹ㣬ʧֵܷ*/ +UINT8 GetDeviceNameByIpAndPort1(UINT16 port, UINT32 ip, UINT16* deviceName, UINT16* pLogId, UINT32* pEtcid) +{ + UINT8 retVal = 0;/*ҳɹ0ʼΪ1*/ + UINT16 index = 0; + UINT8 flag = 0; + UINT16 i = 1; + + if (0 == gDeviceNum) + { + retVal = 0;/*ȡXMLļʧ*/ + } + for (index = 0; index < gDeviceNum; index++) + { + if ((ip == LongFromChar(gDeviceIpInfoArray[index].blueIp)) || (ip == LongFromChar(gDeviceIpInfoArray[index].redIp))) + { + flag = 1; + *deviceName = gDeviceIpInfoArray[index].deviceName; + /*VOBC*/ + if (DEVTYPE_VOBC == (UINT8)(gDeviceIpInfoArray[index].deviceName >> 8)) + { + *pLogId = dquGetVobcNumForEstId(gDeviceIpInfoArray[index].estId); + *pEtcid = gDeviceIpInfoArray[index].estId; + } + retVal = 1; + break; + } + else + { + flag = 0; + } + } + if ((flag == 1) && ((port == gDeviceIpInfoArray[index].bluePort[0]) || (port == gDeviceIpInfoArray[index].bluePort[1]) + || (port == gDeviceIpInfoArray[index].bluePort[2]) || (port == gDeviceIpInfoArray[index].bluePort[3]) || (port == gDeviceIpInfoArray[index].redPort[0]) || (port == gDeviceIpInfoArray[index].redPort[1]) + || (port == gDeviceIpInfoArray[index].redPort[2]) || (port == gDeviceIpInfoArray[index].redPort[3]))) + { + retVal = 1; + } + else if ((flag == 1) && ((65535 == gDeviceIpInfoArray[index].bluePort[2]) + && (65535 == gDeviceIpInfoArray[index].redPort[2])) + && (DEVTYPE_VOBC == (UINT8)(gDeviceIpInfoArray[index].deviceName >> 8))) + { + retVal = 0u; + + for (i = 0; i < gPortDataLen; i++) + { + if ((SYSTEM_TYPE_VOBC == (gpPortData[i].SrcDeviceType & 0xFF)) + && (SYSTEM_TYPE_CI == (gpPortData[i].DstDeviceType & 0xFF)) + && (gpPortData[i].SrcFactoryNo == ((gDeviceIpInfoArray[index].estId >> 29) & 0x07)) + && (FACTORY_NO_TCT == (gpPortData[i].DstFactoryNo)) + )/*Դ豸dz,hlhtId3bitԴ̺*/ + { + if (0x1 == ((*pLogId) & 0x3) && ((port == gpPortData[i].Tc1BlueSendPort) || (port == gpPortData[i].Tc1RedSendPort))) + { + *pLogId = 0x1; + retVal = 1; + break; + } + else if (0x2 == ((*pLogId) & 0x3) && ((port == gpPortData[i].Tc2BlueSendPort) || (port == gpPortData[i].Tc2RedSendPort))) + { + *pLogId = 0x2; + retVal = 1; + break; + } + else + { + retVal = 0; + } + + } + } + + } + else + { + retVal = 0; + } + return retVal; +} + +/*IPͶ˿ڲ豸ƣ +ҳɹ㣬ʧֵܷ*/ +UINT8 GetDeviceNameByIpAndPort(UINT16 port,UINT32 ip,UINT16 *deviceName,UINT16 *pLogId) +{ + UINT8 retVal = 1;/*ҳɹ0ʼΪ1*/ + UINT16 index = 0; + UINT8 flag = 0; + + if (0 == gDeviceNum) + { + retVal = 2;/*ȡXMLļʧ*/ + } + for (index = 0;index < gDeviceNum;index++) + { + if ((ip == LongFromChar(gDeviceIpInfoArray[index].blueIp))||(ip == LongFromChar(gDeviceIpInfoArray[index].redIp))) + { + flag = 1; + } + else + { + flag = 0; + } + if ((flag == 1)&&((port == gDeviceIpInfoArray[index].bluePort[0])||(port == gDeviceIpInfoArray[index].bluePort[1]) + ||(port == gDeviceIpInfoArray[index].bluePort[2])||(port == gDeviceIpInfoArray[index].bluePort[3])||(port == gDeviceIpInfoArray[index].redPort[0])||(port == gDeviceIpInfoArray[index].redPort[1]) + ||(port == gDeviceIpInfoArray[index].redPort[2])||(port == gDeviceIpInfoArray[index].redPort[3]))) + { + *deviceName = gDeviceIpInfoArray[index].deviceName; + /*VOBC*/ + if((DEVTYPE_VOBC == (UINT8)(gDeviceIpInfoArray[index].deviceName >> 8))|| (DEVTYPE_ITE == (UINT8)(gDeviceIpInfoArray[index].deviceName >> 8))) + { + *pLogId = gDeviceIpInfoArray[index].logicId; + } + retVal = 0; + break; + } + else + { + retVal = 1; + } + } + return retVal; +} + +/*IPͶ˿ڲ豸ƣ +ҳɹ㣬ʧֵܷ*/ +UINT8 GetEtcsIdByIp(UINT8 ip[4], UINT32 *etcsId,UINT16 *pDevName) +{ + UINT8 retVal = 1;/*ҳɹ0ʼΪ1*/ + UINT16 index = 0; + UINT8 flag = 0; + UINT16 logicId = 0; + + + if (0 == gDeviceNum) + { + retVal = 2;/*ȡXMLļʧ*/ + } + for (index = 0;index < gDeviceNum;index++) + { + if ((LongFromChar(ip) == LongFromChar(gDeviceIpInfoArray[index].blueIp))||(LongFromChar(ip) == LongFromChar(gDeviceIpInfoArray[index].redIp))) + { + flag = 1; + } + else + { + flag = 0; + } + if (1 == flag) + { + *pDevName = gDeviceIpInfoArray[index].deviceName; + logicId = gDeviceIpInfoArray[index].logicId; + *etcsId = gDeviceIpInfoArray[index].estId; + retVal = 1; + } + /*if ((flag == 1)&&((port == gDeviceIpInfoArray[index].bluePort[0])||(port == gDeviceIpInfoArray[index].bluePort[1]) + ||(port == gDeviceIpInfoArray[index].bluePort[2])||(port == gDeviceIpInfoArray[index].bluePort[3])||(port == gDeviceIpInfoArray[index].redPort[0])||(port == gDeviceIpInfoArray[index].redPort[1]) + ||(port == gDeviceIpInfoArray[index].redPort[2])||(port == gDeviceIpInfoArray[index].redPort[3]))) + { + devName = gDeviceIpInfoArray[index].deviceName; + logicId = gDeviceIpInfoArray[index].logicId; + + dquDevName2EtcsId(devName, logicId, etcsId); + + retVal = 0; + + break; + } + else + { + retVal = 1; + }*/ + } + return retVal; +} + +/*IPͶ˿ڲ豸ƣ +ҳɹ㣬ʧֵܷ*/ +UINT8 GetEtcsIdByIpAndPort(UINT16 port, UINT32 ip, UINT32 *etcsId) +{ + UINT8 retVal = 1;/*ҳɹ0ʼΪ1*/ + UINT16 index = 0; + UINT8 flag = 0; + UINT16 devName = 0; + UINT16 logicId = 0; + + + if (0 == gDeviceNum) + { + retVal = 2;/*ȡXMLļʧ*/ + } + for (index = 0;index < gDeviceNum;index++) + { + if ((ip == LongFromChar(gDeviceIpInfoArray[index].blueIp))||(ip == LongFromChar(gDeviceIpInfoArray[index].redIp))) + { + flag = 1; + } + else + { + flag = 0; + } + if ((flag == 1)&&((port == gDeviceIpInfoArray[index].bluePort[0])||(port == gDeviceIpInfoArray[index].bluePort[1]) + ||(port == gDeviceIpInfoArray[index].bluePort[2])||(port == gDeviceIpInfoArray[index].bluePort[3])||(port == gDeviceIpInfoArray[index].redPort[0])||(port == gDeviceIpInfoArray[index].redPort[1]) + ||(port == gDeviceIpInfoArray[index].redPort[2])||(port == gDeviceIpInfoArray[index].redPort[3]))) + { + devName = gDeviceIpInfoArray[index].deviceName; + logicId = gDeviceIpInfoArray[index].logicId; + + dquDevName2EtcsId(devName, logicId, etcsId); + + retVal = 0; + + break; + } + else + { + retVal = 1; + } + } + return retVal; +} + +void SetDataOfConfigLeu(char chTempData[20],char chTempName[200],UINT16 wDataLen) +{ + static int wConfigCycle = DEFAULT_ZERO; + char chChangeData[20]; + int wTempID = DEFAULT_ZERO; + + memset(chChangeData,DEFAULT_ZERO,sizeof(char) * 20); + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + if (('0' == chTempData[0]) && ('x' == chTempData[1])) + { + memset(chChangeData,DEFAULT_ZERO,sizeof(char) * 20); + memcpy(chChangeData,&chTempData[2],4); + + //str_NativeIpConfig.strNativeIPConfig[wConfigCycle].wDevicdTpye = StrToIntData(chChangeData,2); + + gDeviceIpInfoArrayLeu[wConfigCycle].deviceName = StrToIntData(chChangeData,4); + } + + /*if(('0' == chTempData[0]) && ('x' == chTempData[1])) + { + memset(chChangeData,DEFAULT_ZERO,sizeof(char) * 20); + memcpy(chChangeData,&chTempData[2],4); + gDeviceIpInfoArray[wConfigCycle].deviceName = StrToIntData(chChangeData,4); + }*/ + else + { + printf("Id and Tpye error!\n"); + } + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + //memcpy(str_NativeIpConfig.strNativeIPConfig[wConfigCycle].chRedIP,chTempData,wDataLen); + sscanf(chTempData,"%d.%d.%d.%d",&gDeviceIpInfoArrayLeu[wConfigCycle].redIp[0],&gDeviceIpInfoArrayLeu[wConfigCycle].redIp[1],&gDeviceIpInfoArrayLeu[wConfigCycle].redIp[2],&gDeviceIpInfoArrayLeu[wConfigCycle].redIp[3]); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + //memcpy(str_NativeIpConfig.strNativeIPConfig[wConfigCycle].chBlueIP,chTempData,wDataLen); + sscanf(chTempData,"%d.%d.%d.%d",&gDeviceIpInfoArrayLeu[wConfigCycle].blueIp[0],&gDeviceIpInfoArrayLeu[wConfigCycle].blueIp[1],&gDeviceIpInfoArrayLeu[wConfigCycle].blueIp[2],&gDeviceIpInfoArrayLeu[wConfigCycle].blueIp[3]); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + //str_NativeIpConfig.strNativeIPConfig[wConfigCycle].wSFPRedPort = atoi(chTempData); + gDeviceIpInfoArrayLeu[wConfigCycle].bluePort[0] = atoi(chTempData); + } + else + { + } + + if ((UINT8)DEFAULT_ZERO == strcmp(chTempName,"")) + { + // str_NativeIpConfig.strNativeIPConfig[wConfigCycle].wSFPBluePort = atoi(chTempData); + gDeviceIpInfoArrayLeu[wConfigCycle].redPort[0] = (UINT16)atoi(chTempData); + wConfigCycle++; + gDeviceNumLeu = wConfigCycle; + } + else + { + } +} + +void GetOneDataLeu(char chDataBuff[200],const UINT16 strLen) +{ + int wCycle = DEFAULT_ZERO; + + UINT8 chStartFlag = DEFAULT_ZERO; + UINT8 chEndFlag = DEFAULT_ZERO; + char chTempData[20]; + char chTempName[200]; + UINT8 chDataIndex = DEFAULT_ZERO; + UINT8 chNameIndex = DEFAULT_ZERO; + UINT8 chNameFlag = DEFAULT_ZERO; + + memset(chTempData,DEFAULT_ZERO,sizeof(char) * 20); + memset(chTempName,DEFAULT_ZERO,sizeof(char) * 200); + + for (wCycle = (UINT16)DEFAULT_ZERO;wCycle < strLen;wCycle++) + { + if ((chDataBuff[wCycle] == '<') && ((UINT8)FLAG_SET != chStartFlag)) + { + chNameFlag = (UINT8)FLAG_SET; + } + else + { + if ((UINT8)FLAG_SET == chStartFlag) + { + chNameFlag = (UINT8)FLAG_UNSET; + } + else + { + } + } + + if (FLAG_SET == chNameFlag) + { + chTempName[chNameIndex] = chDataBuff[wCycle]; + chNameIndex++; + } + else + { + } + + if (chDataBuff[wCycle] == '>') + { + if (wCycle == strLen - 1) + { + break; + } + else + { + chStartFlag = FLAG_SET; + continue; + } + } + else + { + } + + if ((UINT8)FLAG_SET == chStartFlag) + { + if ((chDataBuff[wCycle] == '<') && (chDataBuff[wCycle + 1] == '/')) + { + break; + } + else + { + chTempData[chDataIndex] = chDataBuff[wCycle]; + chDataIndex++; + } + } + else + { + } + } + + if ((chDataIndex > 0) && (chNameIndex > 0)) + { + SetDataOfConfigLeu(chTempData,chTempName,chDataIndex); + } + else + { + } +} +void ReadXmlLeuCICfg(const char * pPath) +{ + FILE *pFile = NULL; + char ch; + char chDataBuff[200]; + UINT16 wIndex = DEFAULT_ZERO; + + memset(gDeviceIpInfoArrayLeu,DEFAULT_ZERO,sizeof(gDeviceIpInfoArrayLeu)); + memset(chDataBuff,DEFAULT_ZERO,sizeof(char) * 200); + + if(gDeviceNumLeu == 0 ) + { + if (NULL == (pFile = fopen(pPath,"rt"))) + { + printf("Open File error!\n"); + + return; + } + else + { + } + + while (EOF != (ch=fgetc(pFile))) + { + if (ch != '\n') + { + if (ch != ' ') + { + chDataBuff[wIndex] = ch; + wIndex++; + } + else + { + } + } + else + { + GetOneDataLeu(chDataBuff,wIndex); + memset(chDataBuff,0,sizeof(char) * 200); + wIndex = 0; + } + } + + + fclose(pFile); + + } +} + +/* 豸ƲIPͶ˿ڣ +*ҳɹ0ʧܷ ֵ +*һ豸жIPnumΪҵIP +*/ +UINT8 GetIpAndPortByDeviceNameLEUCI(UINT16 deviceName,IpInfo pIpInfo[],UINT8 *num) +{ + UINT16 index = 0;/*ҷΧĿ*/ + UINT8 retVal = 1;/*ֵҳɹ㣬ʼΪ1*/ + UINT8 ipIndex = 0;/*ҵIPĿ*/ + + if (0 == gDeviceNumLeu) + { + /*printf("ȡXMLļʧܣ\n");*/ + retVal = 2;/*ȡXMLļʧ*/ + } + for (index = 0; index < gDeviceNumLeu; index++) + { + /* 豸ƺЭǷ */ + if (deviceName == gDeviceIpInfoArrayLeu[index].deviceName) + { + /*pIpInfo[ipIndex].blueIp ֵ */ + pIpInfo[ipIndex].blueIp = LongFromChar(gDeviceIpInfoArrayLeu[index].blueIp); + pIpInfo[ipIndex].redIp = LongFromChar(gDeviceIpInfoArrayLeu[index].redIp); + pIpInfo[ipIndex].bluePort = gDeviceIpInfoArrayLeu[index].bluePort[0]; + pIpInfo[ipIndex].redPort = gDeviceIpInfoArrayLeu[index].redPort[0]; + ipIndex++; + } + + } + *num = ipIndex; + if (ipIndex == 0) + { + retVal = 1;/*ûвҵ*/ + } + else + { + retVal = 0; + } + return retVal; +} + +/*IPͶ˿ڲ豸ƣ +ҳɹ㣬ʧֵܷ*/ +UINT8 GetDeviceNameByIpAndPortLEU(UINT16 port,UINT32 ip,UINT16 *deviceName) +{ + UINT8 retVal = 1;/*ҳɹ0ʼΪ1*/ + UINT16 index = 0; + UINT8 flag = 0; + + if (0 == gDeviceNumLeu) + { + retVal = 2;/*ȡXMLļʧ*/ + } + for (index = 0;index < gDeviceNumLeu;index++) + { + if ((ip == LongFromChar(gDeviceIpInfoArrayLeu[index].blueIp))||(ip == LongFromChar(gDeviceIpInfoArrayLeu[index].redIp))) + { + flag = 1; + } + else + { + flag = 0; + } + if ((flag == 1)&&((port == gDeviceIpInfoArrayLeu[index].bluePort[0])||(port == gDeviceIpInfoArrayLeu[index].redPort[0]))) + { + *deviceName = gDeviceIpInfoArrayLeu[index].deviceName; + retVal = 0; + break; + } + else + { + retVal = 1; + } + } + return retVal; +} + +/********************************************* +*ܣȡCIATS +*˵ +*ڲ + pPathļ· +*ڲ + +*ֵʧܻɹ 0:ɹ 1ʧ +*********************************************/ +UINT8 ReadCiAtsCfg(const char *pPath) +{ + UINT8 retResult=ERR_DEF; + + TiXmlNode* rootNode; + TiXmlNode* tNode; + TiXmlNode* tNode1; + const char* pChar; + char charArr[100]; + int nodeType; + UINT8 ciCnt=0; + + TiXmlDocument doc(pPath); + if(doc.LoadFile()) + { + rootNode=doc.RootElement(); + + tNode=rootNode->FirstChild("InAts"); + pChar=tNode->FirstChild()->Value(); + ciAtsCfgInfo.InAts=(UINT8)atoi(pChar); + + tNode=rootNode->FirstChild("XdInAts"); + pChar=tNode->FirstChild()->Value(); + ciAtsCfgInfo.XdInAts=(UINT8)atoi(pChar); + + tNode = rootNode->FirstChild("IpS"); + for( tNode = tNode->FirstChild();tNode;tNode = tNode->NextSibling() ) + { + nodeType = tNode->Type();/*ýڵ*/ + switch(nodeType) + { + case TiXmlNode::TINYXML_ELEMENT: + tNode1=tNode->FirstChild("DevId"); + pChar=tNode1->FirstChild()->Value(); + memcpy(charArr,&(pChar[2]),4); + ciAtsCfgInfo.IpS[ciCnt].DevId=(UINT16)StrToIntData(charArr,4); + + tNode1=tNode->FirstChild("RedIp"); + pChar=tNode1->FirstChild()->Value(); + sscanf(pChar,"%d.%d.%d.%d",&(charArr[0]),&(charArr[1]),&(charArr[2]),&(charArr[3])); + ciAtsCfgInfo.IpS[ciCnt].RedIp=LongFromChar((UINT8 *)charArr); + + tNode1=tNode->FirstChild("BlueIp"); + pChar=tNode1->FirstChild()->Value(); + sscanf(pChar,"%d.%d.%d.%d",&(charArr[0]),&(charArr[1]),&(charArr[2]),&(charArr[3])); + ciAtsCfgInfo.IpS[ciCnt].BlueIp=LongFromChar((UINT8 *)charArr); + + tNode1=tNode->FirstChild("RedPort"); + pChar=tNode1->FirstChild()->Value(); + ciAtsCfgInfo.IpS[ciCnt].RedPort=(UINT16)atoi(pChar); + + tNode1=tNode->FirstChild("BluePort"); + pChar=tNode1->FirstChild()->Value(); + ciAtsCfgInfo.IpS[ciCnt].BluePort=(UINT16)atoi(pChar); + + ciCnt++;/*ci*/ + break; + default: + break; + } + } + retResult=SUC_DEF;/*쳣жϣΪɹŻ*/ + } + + ciAtsCfgInfo.CiCount=ciCnt; + + return retResult; +} + +/********************************************* +*ܣȡCIOC +*˵ +*ڲ +pPathļ· +*ڲ + +*ֵʧܻɹ 0:ɹ 1ʧ +*********************************************/ +UINT8 ReadCiOcCfg(const char *pPath,UINT16 wDevName, CiOcIpInfo* pIpInfo) +{ + UINT8 retResult = 0u; + + TiXmlNode* rootNode = NULL; + TiXmlNode* tNode = NULL; + TiXmlNode* tNode1 = NULL; + const char* pChar; + char charArr[100]; + int nodeType = 0; + UINT8 ciCnt = 0u; + UINT16 wTmpDevName = 0u; + UINT16 wTmpDevSum = gDeviceNum; + + TiXmlDocument doc(pPath); + if ((doc.LoadFile()) && (NULL != pIpInfo)) + { + rootNode = doc.RootElement(); + + tNode = rootNode->FirstChild("InCI"); + pChar = tNode->FirstChild()->Value(); + ciOcCfgInfo.InCi = (UINT8)atoi(pChar); + + tNode = rootNode->FirstChild("IpS"); + for (tNode = tNode->FirstChild(); tNode; tNode = tNode->NextSibling()) + { + nodeType = tNode->Type();/*ýڵ*/ + switch (nodeType) + { + case TiXmlNode::TINYXML_ELEMENT: + tNode1 = tNode->FirstChild("DevId"); + pChar = tNode1->FirstChild()->Value(); + memcpy(charArr, &(pChar[2]), 4); + wTmpDevName = (UINT16)StrToIntData(charArr, 4); + + /* ȡ豸 */ + ciOcCfgInfo.IpS[ciCnt].DevId = (UINT8)(wTmpDevName & 0x00FF); + ciOcCfgInfo.IpS[ciCnt].DevType = (UINT8)((wTmpDevName & 0xFF00) >> 8); + + tNode1 = tNode->FirstChild("RedIp"); + pChar = tNode1->FirstChild()->Value(); + sscanf(pChar, "%d.%d.%d.%d", &(charArr[0]), &(charArr[1]), &(charArr[2]), &(charArr[3])); + ciOcCfgInfo.IpS[ciCnt].RedIp = LongFromChar((UINT8 *)charArr); + + tNode1 = tNode->FirstChild("BlueIp"); + pChar = tNode1->FirstChild()->Value(); + sscanf(pChar, "%d.%d.%d.%d", &(charArr[0]), &(charArr[1]), &(charArr[2]), &(charArr[3])); + ciOcCfgInfo.IpS[ciCnt].BlueIp = LongFromChar((UINT8 *)charArr); + + tNode1 = tNode->FirstChild("RedPort"); + pChar = tNode1->FirstChild()->Value(); + ciOcCfgInfo.IpS[ciCnt].RedPort = (UINT16)atoi(pChar); + + tNode1 = tNode->FirstChild("BluePort"); + pChar = tNode1->FirstChild()->Value(); + ciOcCfgInfo.IpS[ciCnt].BluePort = (UINT16)atoi(pChar); + + /* ȡip˿ڶдѯ */ + gDeviceIpInfoArray[wTmpDevSum].deviceName = wTmpDevName; + gDeviceIpInfoArray[wTmpDevSum].estId = 0u; + + LongToChar(ciOcCfgInfo.IpS[ciCnt].BlueIp, gDeviceIpInfoArray[wTmpDevSum].blueIp); + LongToChar(ciOcCfgInfo.IpS[ciCnt].RedIp, gDeviceIpInfoArray[wTmpDevSum].redIp); + + gDeviceIpInfoArray[wTmpDevSum].bluePort[SFP_IDX] = UINT16_MAX; + gDeviceIpInfoArray[wTmpDevSum].redPort[SFP_IDX] = UINT16_MAX; + + gDeviceIpInfoArray[wTmpDevSum].bluePort[RP_IDX] = UINT16_MAX; + gDeviceIpInfoArray[wTmpDevSum].redPort[RP_IDX] = UINT16_MAX; + + gDeviceIpInfoArray[wTmpDevSum].bluePort[RSSP1_IDX] = ciOcCfgInfo.IpS[ciCnt].BluePort; + gDeviceIpInfoArray[wTmpDevSum].redPort[RSSP1_IDX] = ciOcCfgInfo.IpS[ciCnt].RedPort; + + gDeviceIpInfoArray[wTmpDevSum].bluePort[RSSP2_IDX] = UINT16_MAX; + gDeviceIpInfoArray[wTmpDevSum].redPort[RSSP2_IDX] = UINT16_MAX; + + /* CIյIP˿ڴȥ */ + if (wTmpDevName == wDevName) + { + pIpInfo->DevId = ciOcCfgInfo.IpS[ciCnt].DevId; + pIpInfo->DevType = ciOcCfgInfo.IpS[ciCnt].DevType; + pIpInfo->BlueIp = ciOcCfgInfo.IpS[ciCnt].BlueIp; + pIpInfo->BluePort = ciOcCfgInfo.IpS[ciCnt].BluePort; + pIpInfo->RedIp = ciOcCfgInfo.IpS[ciCnt].RedIp; + pIpInfo->RedPort = ciOcCfgInfo.IpS[ciCnt].RedPort; + } + + wTmpDevSum++; + ciCnt++;/*ci*/ + break; + default: + break; + } + } + retResult = ciOcCfgInfo.InCi; + ciOcCfgInfo.CiCount = ciCnt; + } + else + { + ; + } + + if ((1u == retResult) && (wTmpDevSum > gDeviceNum)) + { + gDeviceNum = wTmpDevSum; + } + + return retResult; +} + +/********************************************* +*ܣȡָCIATSеڵϢ +*˵ +*ڲ + devIdCI豸ID + UINT8 ccovIdx:Э +*ڲ + pIpInfoCIATSеڵϢ +*ֵʧܻɹ 0:ɹ 1ʧ +*********************************************/ +UINT8 ReadCiAtsIpInfo(UINT16 devId,UINT8 ccovIdx,CiAtsIpInfo *pIpInfo) +{ + UINT8 retResult=ERR_DEF; + UINT8 ciCnt=0; + UINT8 numAts = 0; + UINT8 ipAddrAts[4]; + + UINT8 i; + ciAtsCfgInfo.InAts = 1u; + ciAtsCfgInfo.XdInAts = 1u; + ciAtsCfgInfo.IpS[ciCnt].DevId = devId; + + GetNetATSEndPoint(devId, 0, ccovIdx, pAtsIpInfo, &numAts); + if (numAts > 0) + { + LongToChar(pAtsIpInfo[numAts-1].redIp,ipAddrAts); + + ciAtsCfgInfo.IpS[ciCnt].RedIp=LongFromChar((UINT8 *)ipAddrAts); + + LongToChar(pAtsIpInfo[numAts-1].blueIp,ipAddrAts); + + ciAtsCfgInfo.IpS[ciCnt].BlueIp=LongFromChar((UINT8 *)ipAddrAts); + + ciAtsCfgInfo.IpS[ciCnt].RedPort=pAtsIpInfo[numAts-1].redPort; + + ciAtsCfgInfo.IpS[ciCnt].BluePort=pAtsIpInfo[numAts-1].bluePort; + + ciCnt++;/*ci*/ + retResult=SUC_DEF;/*쳣жϣΪɹŻ*/ + ciAtsCfgInfo.CiCount = ciCnt; + + for(i=0;iDevId=devId; + pIpInfo->RedIp=ciAtsCfgInfo.IpS[i].RedIp; + pIpInfo->BlueIp=ciAtsCfgInfo.IpS[i].BlueIp; + pIpInfo->RedPort=ciAtsCfgInfo.IpS[i].RedPort; + pIpInfo->BluePort=ciAtsCfgInfo.IpS[i].BluePort; + + retResult=SUC_DEF; + break; + } + } + + } + else + { + printf("\n Read ci.fs CI_ATS fail.\n"); + } + + return retResult; +} + +/********************************************* +*ܣȡCIǷATS־ +*˵ +*ڲ + +*ڲ + +*ֵCIǷATS־ +*********************************************/ +UINT8 ReadCiInAtsFlag(void) +{ + return ciAtsCfgInfo.InAts; +} + +/********************************************* +*ܣȡCIֵͨŷʽ־ +*˵ +*ڲ + +*ڲ + +*ֵCIֵͨŷʽ־ +*********************************************/ +UINT8 ReadXdInAtsFlag(void) +{ + return ciAtsCfgInfo.XdInAts; +} + +/********************************************* +*ܣͨͨIDȡVOBC +*˵ +*ڲ + EtcsId VOBCͨID +*ڲ + +*ֵVOBC +*********************************************/ +UINT16 dquGetVobcNumForEstId(UINT32 EtcsId) +{ + /*ʼ*/ + UINT8 endId = 0u; + UINT16 ret = 0u; + + endId = GET_VOBC_END_ID(EtcsId); + switch (endId) + { + case 1: + ret = VOBC_ENDID_TC1; + break; + case 2: + ret = VOBC_ENDID_TC2; + break; + case 3: + ret = VOBC_ENDID_REDUN; + break; + default: + ret = 0; + break; + } + return(ret); +} + + +/* +* ʼ˿ڱݡ +* UINT8* FSName ļַָ +* ֵ1ɹ +* 0ʧܣд +*/ +UINT8 InitPortTableData(UINT8* FSName) +{ + UINT8 rtVal = 0u; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT8 tempRet = 0u; + UINT32 i = 0u; + UINT32 j = 0u; + UINT16 rowCount = 0u; + UINT32 dataSize = 0u; /*ݴСֽ*/ + UINT16 oneRowLen = 0u; + + /*ʼ˿ڱṹ*/ + /*ȡ*/ + tempRet=dquGetConfigDataNew((CHAR*)FSName, DSU_DEVICE_IP_CONFIG_TYPE, DUS_PORT_TABLE_ID, &pData ,&dataSize, &rowCount); + if (tempRet!=1u) + { + /*ݶȡʧ*/ + rtVal = 0u; + } + else + { + rtVal = 1u; + /*Ϊ0*/ + if((0u != dataSize) && (0u != rowCount)) + { + /*ִ*/ + if (0u == (dataSize%rowCount)) + { + oneRowLen = dataSize/rowCount;/*һеij*/ + gPortDataLen = rowCount; /*ݵĸ*/ + /*Ϊṹռ*/ + gpPortData = (PORT_DATA_STRUCT*)malloc(sizeof(PORT_DATA_STRUCT)*(gPortDataLen)); + + if (NULL == gpPortData) + { + /*ռʧ*/ + rtVal=0; + } + else + { + rtVal = 1; + /*ִ*/ + CommonMemSet(gpPortData,sizeof(PORT_DATA_STRUCT)*(gPortDataLen),0,sizeof(PORT_DATA_STRUCT)*(gPortDataLen)); + } + if (1u == rtVal) + { + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i=0;i>29) & MASK_HLHLNO_FACTORY;/*ݻͨIDȡID,λ*/ + + if (tc1Ortc2 > 0) + {/*ͷβЧ*/ + for (iPortDataIndex = 0u;iPortDataIndex(-1); + + +// Null rep. +TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; + + +void TiXmlString::reserve (size_type cap) +{ + if (cap > capacity()) + { + TiXmlString tmp; + tmp.init(length(), cap); + memcpy(tmp.start(), data(), length()); + swap(tmp); + } +} + + +TiXmlString& TiXmlString::assign(const char* str, size_type len) +{ + size_type cap = capacity(); + if (len > cap || cap > 3*(len + 8)) + { + TiXmlString tmp; + tmp.init(len); + memcpy(tmp.start(), str, len); + swap(tmp); + } + else + { + memmove(start(), str, len); + set_size(len); + } + return *this; +} + + +TiXmlString& TiXmlString::append(const char* str, size_type len) +{ + size_type newsize = length() + len; + if (newsize > capacity()) + { + reserve (newsize + capacity()); + } + memmove(finish(), str, len); + set_size(newsize); + return *this; +} + + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) +{ + TiXmlString tmp; + tmp.reserve(a.length() + b.length()); + tmp += a; + tmp += b; + return tmp; +} + +TiXmlString operator + (const TiXmlString & a, const char* b) +{ + TiXmlString tmp; + TiXmlString::size_type b_len = static_cast( strlen(b) ); + tmp.reserve(a.length() + b_len); + tmp += a; + tmp.append(b, b_len); + return tmp; +} + +TiXmlString operator + (const char* a, const TiXmlString & b) +{ + TiXmlString tmp; + TiXmlString::size_type a_len = static_cast( strlen(a) ); + tmp.reserve(a_len + b.length()); + tmp.append(a, a_len); + tmp += b; + return tmp; +} + + +#endif // TIXML_USE_STL diff --git a/TSCP/src/main/DeviceInfoManager/tinyxml/tinystr.h b/TSCP/src/main/DeviceInfoManager/tinyxml/tinystr.h new file mode 100644 index 0000000..89cca33 --- /dev/null +++ b/TSCP/src/main/DeviceInfoManager/tinyxml/tinystr.h @@ -0,0 +1,305 @@ +/* +www.sourceforge.net/projects/tinyxml + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#ifndef TIXML_USE_STL + +#ifndef TIXML_STRING_INCLUDED +#define TIXML_STRING_INCLUDED + +#include +#include + +/* The support for explicit isn't that universal, and it isn't really + required - it is used to check that the TiXmlString class isn't incorrectly + used. Be nice to old compilers and macro it here: +*/ +#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + #define TIXML_EXPLICIT explicit +#elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + #define TIXML_EXPLICIT explicit +#else + #define TIXML_EXPLICIT +#endif + + +/* + TiXmlString is an emulation of a subset of the std::string template. + Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. + Only the member functions relevant to the TinyXML project have been implemented. + The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase + a string and there's no more room, we allocate a buffer twice as big as we need. +*/ +class TiXmlString +{ + public : + // The size type used + typedef size_t size_type; + + // Error value for find primitive + static const size_type npos; // = -1; + + + // TiXmlString empty constructor + TiXmlString () : rep_(&nullrep_) + { + } + + // TiXmlString copy constructor + TiXmlString ( const TiXmlString & copy) : rep_(0) + { + init(copy.length()); + memcpy(start(), copy.data(), length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) + { + init( static_cast( strlen(copy) )); + memcpy(start(), copy, length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) + { + init(len); + memcpy(start(), str, len); + } + + // TiXmlString destructor + ~TiXmlString () + { + quit(); + } + + TiXmlString& operator = (const char * copy) + { + return assign( copy, (size_type)strlen(copy)); + } + + TiXmlString& operator = (const TiXmlString & copy) + { + return assign(copy.start(), copy.length()); + } + + + // += operator. Maps to append + TiXmlString& operator += (const char * suffix) + { + return append(suffix, static_cast( strlen(suffix) )); + } + + // += operator. Maps to append + TiXmlString& operator += (char single) + { + return append(&single, 1); + } + + // += operator. Maps to append + TiXmlString& operator += (const TiXmlString & suffix) + { + return append(suffix.data(), suffix.length()); + } + + + // Convert a TiXmlString into a null-terminated char * + const char * c_str () const { return rep_->str; } + + // Convert a TiXmlString into a char * (need not be null terminated). + const char * data () const { return rep_->str; } + + // Return the length of a TiXmlString + size_type length () const { return rep_->size; } + + // Alias for length() + size_type size () const { return rep_->size; } + + // Checks if a TiXmlString is empty + bool empty () const { return rep_->size == 0; } + + // Return capacity of string + size_type capacity () const { return rep_->capacity; } + + + // single char extraction + const char& at (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // [] operator + char& operator [] (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // find a char in a string. Return TiXmlString::npos if not found + size_type find (char lookup) const + { + return find(lookup, 0); + } + + // find a char in a string from an offset. Return TiXmlString::npos if not found + size_type find (char tofind, size_type offset) const + { + if (offset >= length()) return npos; + + for (const char* p = c_str() + offset; *p != '\0'; ++p) + { + if (*p == tofind) return static_cast< size_type >( p - c_str() ); + } + return npos; + } + + void clear () + { + //Lee: + //The original was just too strange, though correct: + // TiXmlString().swap(*this); + //Instead use the quit & re-init: + quit(); + init(0,0); + } + + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function DOES NOT clear the content of the TiXmlString if any exists. + */ + void reserve (size_type cap); + + TiXmlString& assign (const char* str, size_type len); + + TiXmlString& append (const char* str, size_type len); + + void swap (TiXmlString& other) + { + Rep* r = rep_; + rep_ = other.rep_; + other.rep_ = r; + } + + private: + + void init(size_type sz) { init(sz, sz); } + void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } + char* start() const { return rep_->str; } + char* finish() const { return rep_->str + rep_->size; } + + struct Rep + { + size_type size, capacity; + char str[1]; + }; + + void init(size_type sz, size_type cap) + { + if (cap) + { + // Lee: the original form: + // rep_ = static_cast(operator new(sizeof(Rep) + cap)); + // doesn't work in some cases of new being overloaded. Switching + // to the normal allocation, although use an 'int' for systems + // that are overly picky about structure alignment. + const size_type bytesNeeded = sizeof(Rep) + cap; + const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); + rep_ = reinterpret_cast( new int[ intsNeeded ] ); + + rep_->str[ rep_->size = sz ] = '\0'; + rep_->capacity = cap; + } + else + { + rep_ = &nullrep_; + } + } + + void quit() + { + if (rep_ != &nullrep_) + { + // The rep_ is really an array of ints. (see the allocator, above). + // Cast it back before delete, so the compiler won't incorrectly call destructors. + delete [] ( reinterpret_cast( rep_ ) ); + } + } + + Rep * rep_; + static Rep nullrep_; + +} ; + + +inline bool operator == (const TiXmlString & a, const TiXmlString & b) +{ + return ( a.length() == b.length() ) // optimization on some platforms + && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare +} +inline bool operator < (const TiXmlString & a, const TiXmlString & b) +{ + return strcmp(a.c_str(), b.c_str()) < 0; +} + +inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } +inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } +inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } +inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } + +inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } +inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } +inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } +inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); +TiXmlString operator + (const TiXmlString & a, const char* b); +TiXmlString operator + (const char* a, const TiXmlString & b); + + +/* + TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. + Only the operators that we need for TinyXML have been developped. +*/ +class TiXmlOutStream : public TiXmlString +{ +public : + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const TiXmlString & in) + { + *this += in; + return *this; + } + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const char * in) + { + *this += in; + return *this; + } + +} ; + +#endif // TIXML_STRING_INCLUDED +#endif // TIXML_USE_STL diff --git a/TSCP/src/main/DeviceInfoManager/tinyxml/tinyxml.cpp b/TSCP/src/main/DeviceInfoManager/tinyxml/tinyxml.cpp new file mode 100644 index 0000000..9c161df --- /dev/null +++ b/TSCP/src/main/DeviceInfoManager/tinyxml/tinyxml.cpp @@ -0,0 +1,1886 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code by Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include + +#ifdef TIXML_USE_STL +#include +#include +#endif + +#include "tinyxml.h" + +FILE* TiXmlFOpen( const char* filename, const char* mode ); + +bool TiXmlBase::condenseWhiteSpace = true; + +// Microsoft compiler security +FILE* TiXmlFOpen( const char* filename, const char* mode ) +{ + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + FILE* fp = 0; + errno_t err = fopen_s( &fp, filename, mode ); + if ( !err && fp ) + return fp; + return 0; + #else + return fopen( filename, mode ); + #endif +} + +void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) +{ + int i=0; + + while( i<(int)str.length() ) + { + unsigned char c = (unsigned char) str[i]; + + if ( c == '&' + && i < ( (int)str.length() - 2 ) + && str[i+1] == '#' + && str[i+2] == 'x' ) + { + // Hexadecimal character reference. + // Pass through unchanged. + // © -- copyright symbol, for example. + // + // The -1 is a bug fix from Rob Laveaux. It keeps + // an overflow from happening if there is no ';'. + // There are actually 2 ways to exit this loop - + // while fails (error case) and break (semicolon found). + // However, there is no mechanism (currently) for + // this function to return an error. + while ( i<(int)str.length()-1 ) + { + outString->append( str.c_str() + i, 1 ); + ++i; + if ( str[i] == ';' ) + break; + } + } + else if ( c == '&' ) + { + outString->append( entity[0].str, entity[0].strLength ); + ++i; + } + else if ( c == '<' ) + { + outString->append( entity[1].str, entity[1].strLength ); + ++i; + } + else if ( c == '>' ) + { + outString->append( entity[2].str, entity[2].strLength ); + ++i; + } + else if ( c == '\"' ) + { + outString->append( entity[3].str, entity[3].strLength ); + ++i; + } + else if ( c == '\'' ) + { + outString->append( entity[4].str, entity[4].strLength ); + ++i; + } + else if ( c < 32 ) + { + // Easy pass at non-alpha/numeric/symbol + // Below 32 is symbolic. + char buf[ 32 ]; + + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); + #else + sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); + #endif + + //*ME: warning C4267: convert 'size_t' to 'int' + //*ME: Int-Cast to make compiler happy ... + outString->append( buf, (int)strlen( buf ) ); + ++i; + } + else + { + //char realc = (char) c; + //outString->append( &realc, 1 ); + *outString += (char) c; // somewhat more efficient function call. + ++i; + } + } +} + + +TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() +{ + parent = 0; + type = _type; + firstChild = 0; + lastChild = 0; + prev = 0; + next = 0; +} + + +TiXmlNode::~TiXmlNode() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } +} + + +void TiXmlNode::CopyTo( TiXmlNode* target ) const +{ + target->SetValue (value.c_str() ); + target->userData = userData; + target->location = location; +} + + +void TiXmlNode::Clear() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } + + firstChild = 0; + lastChild = 0; +} + + +TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) +{ + assert( node->parent == 0 || node->parent == this ); + assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + + if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) + { + delete node; + if ( GetDocument() ) + GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + node->parent = this; + + node->prev = lastChild; + node->next = 0; + + if ( lastChild ) + lastChild->next = node; + else + firstChild = node; // it was an empty list. + + lastChild = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) +{ + if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) + { + if ( GetDocument() ) + GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + + return LinkEndChild( node ); +} + + +TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) +{ + if ( !beforeThis || beforeThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) + { + if ( GetDocument() ) + GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->next = beforeThis; + node->prev = beforeThis->prev; + if ( beforeThis->prev ) + { + beforeThis->prev->next = node; + } + else + { + assert( firstChild == beforeThis ); + firstChild = node; + } + beforeThis->prev = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) +{ + if ( !afterThis || afterThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) + { + if ( GetDocument() ) + GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->prev = afterThis; + node->next = afterThis->next; + if ( afterThis->next ) + { + afterThis->next->prev = node; + } + else + { + assert( lastChild == afterThis ); + lastChild = node; + } + afterThis->next = node; + return node; +} + + +TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) +{ + if ( !replaceThis ) + return 0; + + if ( replaceThis->parent != this ) + return 0; + + if ( withThis.ToDocument() ) { + // A document can never be a child. Thanks to Noam. + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = withThis.Clone(); + if ( !node ) + return 0; + + node->next = replaceThis->next; + node->prev = replaceThis->prev; + + if ( replaceThis->next ) + replaceThis->next->prev = node; + else + lastChild = node; + + if ( replaceThis->prev ) + replaceThis->prev->next = node; + else + firstChild = node; + + delete replaceThis; + node->parent = this; + return node; +} + + +bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) +{ + if ( !removeThis ) { + return false; + } + + if ( removeThis->parent != this ) + { + assert( 0 ); + return false; + } + + if ( removeThis->next ) + removeThis->next->prev = removeThis->prev; + else + lastChild = removeThis->prev; + + if ( removeThis->prev ) + removeThis->prev->next = removeThis->next; + else + firstChild = removeThis->next; + + delete removeThis; + return true; +} + +const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = firstChild; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = lastChild; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild(); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling(); + } +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild( val ); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling( val ); + } +} + + +const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = next; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = prev; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +void TiXmlElement::RemoveAttribute( const char * name ) +{ + #ifdef TIXML_USE_STL + TIXML_STRING str( name ); + TiXmlAttribute* node = attributeSet.Find( str ); + #else + TiXmlAttribute* node = attributeSet.Find( name ); + #endif + if ( node ) + { + attributeSet.Remove( node ); + delete node; + } +} + +const TiXmlElement* TiXmlNode::FirstChildElement() const +{ + const TiXmlNode* node; + + for ( node = FirstChild(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = FirstChild( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement() const +{ + const TiXmlNode* node; + + for ( node = NextSibling(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = NextSibling( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlDocument* TiXmlNode::GetDocument() const +{ + const TiXmlNode* node; + + for( node = this; node; node = node->parent ) + { + if ( node->ToDocument() ) + return node->ToDocument(); + } + return 0; +} + + +TiXmlElement::TiXmlElement (const char * _value) + : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} + + +#ifdef TIXML_USE_STL +TiXmlElement::TiXmlElement( const std::string& _value ) + : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} +#endif + + +TiXmlElement::TiXmlElement( const TiXmlElement& copy) + : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) +{ + firstChild = lastChild = 0; + copy.CopyTo( this ); +} + + +TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base ) +{ + ClearThis(); + base.CopyTo( this ); + return *this; +} + + +TiXmlElement::~TiXmlElement() +{ + ClearThis(); +} + + +void TiXmlElement::ClearThis() +{ + Clear(); + while( attributeSet.First() ) + { + TiXmlAttribute* node = attributeSet.First(); + attributeSet.Remove( node ); + delete node; + } +} + + +const char* TiXmlElement::Attribute( const char* name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return node->Value(); + return 0; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( attrib ) + return &attrib->ValueStr(); + return 0; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, int* i ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + const char* result = 0; + + if ( attrib ) { + result = attrib->Value(); + if ( i ) { + attrib->QueryIntValue( i ); + } + } + return result; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + const std::string* result = 0; + + if ( attrib ) { + result = &attrib->ValueStr(); + if ( i ) { + attrib->QueryIntValue( i ); + } + } + return result; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, double* d ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + const char* result = 0; + + if ( attrib ) { + result = attrib->Value(); + if ( d ) { + attrib->QueryDoubleValue( d ); + } + } + return result; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + const std::string* result = 0; + + if ( attrib ) { + result = &attrib->ValueStr(); + if ( d ) { + attrib->QueryDoubleValue( d ); + } + } + return result; +} +#endif + + +int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( !attrib ) + return TIXML_NO_ATTRIBUTE; + return attrib->QueryIntValue( ival ); +} + + +int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + int ival = 0; + int result = node->QueryIntValue( &ival ); + *value = (unsigned)ival; + return result; +} + + +int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + int result = TIXML_WRONG_TYPE; + if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN ) + || StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN ) + || StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) ) + { + *bval = true; + result = TIXML_SUCCESS; + } + else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN ) + || StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN ) + || StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) ) + { + *bval = false; + result = TIXML_SUCCESS; + } + return result; +} + + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( !attrib ) + return TIXML_NO_ATTRIBUTE; + return attrib->QueryIntValue( ival ); +} +#endif + + +int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( !attrib ) + return TIXML_NO_ATTRIBUTE; + return attrib->QueryDoubleValue( dval ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const +{ + const TiXmlAttribute* attrib = attributeSet.Find( name ); + if ( !attrib ) + return TIXML_NO_ATTRIBUTE; + return attrib->QueryDoubleValue( dval ); +} +#endif + + +void TiXmlElement::SetAttribute( const char * name, int val ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); + if ( attrib ) { + attrib->SetIntValue( val ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, int val ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); + if ( attrib ) { + attrib->SetIntValue( val ); + } +} +#endif + + +void TiXmlElement::SetDoubleAttribute( const char * name, double val ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); + if ( attrib ) { + attrib->SetDoubleValue( val ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetDoubleAttribute( const std::string& name, double val ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); + if ( attrib ) { + attrib->SetDoubleValue( val ); + } +} +#endif + + +void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname ); + if ( attrib ) { + attrib->SetValue( cvalue ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value ) +{ + TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name ); + if ( attrib ) { + attrib->SetValue( _value ); + } +} +#endif + + +void TiXmlElement::Print( FILE* cfile, int depth ) const +{ + int i; + assert( cfile ); + for ( i=0; iNext() ) + { + fprintf( cfile, " " ); + attrib->Print( cfile, depth ); + } + + // There are 3 different formatting approaches: + // 1) An element without children is printed as a node + // 2) An element with only a text child is printed as text + // 3) An element with children is printed on multiple lines. + TiXmlNode* node; + if ( !firstChild ) + { + fprintf( cfile, " />" ); + } + else if ( firstChild == lastChild && firstChild->ToText() ) + { + fprintf( cfile, ">" ); + firstChild->Print( cfile, depth + 1 ); + fprintf( cfile, "", value.c_str() ); + } + else + { + fprintf( cfile, ">" ); + + for ( node = firstChild; node; node=node->NextSibling() ) + { + if ( !node->ToText() ) + { + fprintf( cfile, "\n" ); + } + node->Print( cfile, depth+1 ); + } + fprintf( cfile, "\n" ); + for( i=0; i", value.c_str() ); + } +} + + +void TiXmlElement::CopyTo( TiXmlElement* target ) const +{ + // superclass: + TiXmlNode::CopyTo( target ); + + // Element class: + // Clone the attributes, then clone the children. + const TiXmlAttribute* attribute = 0; + for( attribute = attributeSet.First(); + attribute; + attribute = attribute->Next() ) + { + target->SetAttribute( attribute->Name(), attribute->Value() ); + } + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + +bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this, attributeSet.First() ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +TiXmlNode* TiXmlElement::Clone() const +{ + TiXmlElement* clone = new TiXmlElement( Value() ); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +const char* TiXmlElement::GetText() const +{ + const TiXmlNode* child = this->FirstChild(); + if ( child ) { + const TiXmlText* childText = child->ToText(); + if ( childText ) { + return childText->Value(); + } + } + return 0; +} + + +TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + ClearError(); +} + +TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} + + +#ifdef TIXML_USE_STL +TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} +#endif + + +TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) +{ + copy.CopyTo( this ); +} + + +TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy ) +{ + Clear(); + copy.CopyTo( this ); + return *this; +} + + +bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) +{ + return LoadFile( Value(), encoding ); +} + + +bool TiXmlDocument::SaveFile() const +{ + return SaveFile( Value() ); +} + +bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) +{ + TIXML_STRING filename( _filename ); + value = filename; + + // reading in binary mode so that tinyxml can normalize the EOL + FILE* file = TiXmlFOpen( value.c_str (), "rb" ); + + if ( file ) + { + bool result = LoadFile( file, encoding ); + fclose( file ); + return result; + } + else + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } +} + +bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) +{ + if ( !file ) + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Delete the existing data: + Clear(); + location.Clear(); + + // Get the file size, so we can pre-allocate the string. HUGE speed impact. + long length = 0; + fseek( file, 0, SEEK_END ); + length = ftell( file ); + fseek( file, 0, SEEK_SET ); + + // Strange case, but good to handle up front. + if ( length <= 0 ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Subtle bug here. TinyXml did use fgets. But from the XML spec: + // 2.11 End-of-Line Handling + // + // + // ...the XML processor MUST behave as if it normalized all line breaks in external + // parsed entities (including the document entity) on input, before parsing, by translating + // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to + // a single #xA character. + // + // + // It is not clear fgets does that, and certainly isn't clear it works cross platform. + // Generally, you expect fgets to translate from the convention of the OS to the c/unix + // convention, and not work generally. + + /* + while( fgets( buf, sizeof(buf), file ) ) + { + data += buf; + } + */ + + char* buf = new char[ length+1 ]; + buf[0] = 0; + + if ( fread( buf, length, 1, file ) != 1 ) { + delete [] buf; + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Process the buffer in place to normalize new lines. (See comment above.) + // Copies from the 'p' to 'q' pointer, where p can advance faster if + // a newline-carriage return is hit. + // + // Wikipedia: + // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or + // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)... + // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others + // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS + // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9 + + const char* p = buf; // the read head + char* q = buf; // the write head + const char CR = 0x0d; + const char LF = 0x0a; + + buf[length] = 0; + while( *p ) { + assert( p < (buf+length) ); + assert( q <= (buf+length) ); + assert( q <= p ); + + if ( *p == CR ) { + *q++ = LF; + p++; + if ( *p == LF ) { // check for CR+LF (and skip LF) + p++; + } + } + else { + *q++ = *p++; + } + } + assert( q <= (buf+length) ); + *q = 0; + + Parse( buf, 0, encoding ); + + delete [] buf; + return !Error(); +} + + +bool TiXmlDocument::SaveFile( const char * filename ) const +{ + // The old c stuff lives on... + FILE* fp = TiXmlFOpen( filename, "w" ); + if ( fp ) + { + bool result = SaveFile( fp ); + fclose( fp ); + return result; + } + return false; +} + + +bool TiXmlDocument::SaveFile( FILE* fp ) const +{ + if ( useMicrosoftBOM ) + { + const unsigned char TIXML_UTF_LEAD_0 = 0xefU; + const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; + const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + + fputc( TIXML_UTF_LEAD_0, fp ); + fputc( TIXML_UTF_LEAD_1, fp ); + fputc( TIXML_UTF_LEAD_2, fp ); + } + Print( fp, 0 ); + return (ferror(fp) == 0); +} + + +void TiXmlDocument::CopyTo( TiXmlDocument* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->error = error; + target->errorId = errorId; + target->errorDesc = errorDesc; + target->tabsize = tabsize; + target->errorLocation = errorLocation; + target->useMicrosoftBOM = useMicrosoftBOM; + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + + +TiXmlNode* TiXmlDocument::Clone() const +{ + TiXmlDocument* clone = new TiXmlDocument(); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlDocument::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + node->Print( cfile, depth ); + fprintf( cfile, "\n" ); + } +} + + +bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +const TiXmlAttribute* TiXmlAttribute::Next() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} + +/* +TiXmlAttribute* TiXmlAttribute::Next() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} +*/ + +const TiXmlAttribute* TiXmlAttribute::Previous() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} + +/* +TiXmlAttribute* TiXmlAttribute::Previous() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} +*/ + +void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + TIXML_STRING n, v; + + EncodeString( name, &n ); + EncodeString( value, &v ); + + if (value.find ('\"') == TIXML_STRING::npos) { + if ( cfile ) { + fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; + } + } + else { + if ( cfile ) { + fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; + } + } +} + + +int TiXmlAttribute::QueryIntValue( int* ival ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +int TiXmlAttribute::QueryDoubleValue( double* dval ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +void TiXmlAttribute::SetIntValue( int _value ) +{ + char buf [64]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); + #else + sprintf (buf, "%d", _value); + #endif + SetValue (buf); +} + +void TiXmlAttribute::SetDoubleValue( double _value ) +{ + char buf [256]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value); + #else + sprintf (buf, "%g", _value); + #endif + SetValue (buf); +} + +int TiXmlAttribute::IntValue() const +{ + return atoi (value.c_str ()); +} + +double TiXmlAttribute::DoubleValue() const +{ + return atof (value.c_str ()); +} + + +TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) +{ + copy.CopyTo( this ); +} + + +TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base ) +{ + Clear(); + base.CopyTo( this ); + return *this; +} + + +void TiXmlComment::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( int i=0; i", value.c_str() ); +} + + +void TiXmlComment::CopyTo( TiXmlComment* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlComment::Clone() const +{ + TiXmlComment* clone = new TiXmlComment(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlText::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + if ( cdata ) + { + int i; + fprintf( cfile, "\n" ); + for ( i=0; i\n", value.c_str() ); // unformatted output + } + else + { + TIXML_STRING buffer; + EncodeString( value, &buffer ); + fprintf( cfile, "%s", buffer.c_str() ); + } +} + + +void TiXmlText::CopyTo( TiXmlText* target ) const +{ + TiXmlNode::CopyTo( target ); + target->cdata = cdata; +} + + +bool TiXmlText::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlText::Clone() const +{ + TiXmlText* clone = 0; + clone = new TiXmlText( "" ); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlDeclaration::TiXmlDeclaration( const char * _version, + const char * _encoding, + const char * _standalone ) + : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} + + +#ifdef TIXML_USE_STL +TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ) + : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} +#endif + + +TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) + : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) +{ + copy.CopyTo( this ); +} + + +TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) +{ + Clear(); + copy.CopyTo( this ); + return *this; +} + + +void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + if ( cfile ) fprintf( cfile, "" ); + if ( str ) (*str) += "?>"; +} + + +void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->version = version; + target->encoding = encoding; + target->standalone = standalone; +} + + +bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlDeclaration::Clone() const +{ + TiXmlDeclaration* clone = new TiXmlDeclaration(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlUnknown::Print( FILE* cfile, int depth ) const +{ + for ( int i=0; i", value.c_str() ); +} + + +void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlUnknown::Clone() const +{ + TiXmlUnknown* clone = new TiXmlUnknown(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlAttributeSet::TiXmlAttributeSet() +{ + sentinel.next = &sentinel; + sentinel.prev = &sentinel; +} + + +TiXmlAttributeSet::~TiXmlAttributeSet() +{ + assert( sentinel.next == &sentinel ); + assert( sentinel.prev == &sentinel ); +} + + +void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) +{ + #ifdef TIXML_USE_STL + assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. + #else + assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. + #endif + + addMe->next = &sentinel; + addMe->prev = sentinel.prev; + + sentinel.prev->next = addMe; + sentinel.prev = addMe; +} + +void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) +{ + TiXmlAttribute* node; + + for( node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node == removeMe ) + { + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = 0; + node->prev = 0; + return; + } + } + assert( 0 ); // we tried to remove a non-linked attribute. +} + + +#ifdef TIXML_USE_STL +TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} + +TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) +{ + TiXmlAttribute* attrib = Find( _name ); + if ( !attrib ) { + attrib = new TiXmlAttribute(); + Add( attrib ); + attrib->SetName( _name ); + } + return attrib; +} +#endif + + +TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} + + +TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name ) +{ + TiXmlAttribute* attrib = Find( _name ); + if ( !attrib ) { + attrib = new TiXmlAttribute(); + Add( attrib ); + attrib->SetName( _name ); + } + return attrib; +} + + +#ifdef TIXML_USE_STL +std::istream& operator>> (std::istream & in, TiXmlNode & base) +{ + TIXML_STRING tag; + tag.reserve( 8 * 1000 ); + base.StreamIn( &in, &tag ); + + base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); + return in; +} +#endif + + +#ifdef TIXML_USE_STL +std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out << printer.Str(); + + return out; +} + + +std::string& operator<< (std::string& out, const TiXmlNode& base ) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out.append( printer.Str() ); + + return out; +} +#endif + + +TiXmlHandle TiXmlHandle::FirstChild() const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement() const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild(); + for ( i=0; + child && iNextSibling(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild( value ); + for ( i=0; + child && iNextSibling( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement(); + for ( i=0; + child && iNextSiblingElement(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement( value ); + for ( i=0; + child && iNextSiblingElement( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) +{ + DoIndent(); + buffer += "<"; + buffer += element.Value(); + + for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) + { + buffer += " "; + attrib->Print( 0, 0, &buffer ); + } + + if ( !element.FirstChild() ) + { + buffer += " />"; + DoLineBreak(); + } + else + { + buffer += ">"; + if ( element.FirstChild()->ToText() + && element.LastChild() == element.FirstChild() + && element.FirstChild()->ToText()->CDATA() == false ) + { + simpleTextPrint = true; + // no DoLineBreak()! + } + else + { + DoLineBreak(); + } + } + ++depth; + return true; +} + + +bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) +{ + --depth; + if ( !element.FirstChild() ) + { + // nothing. + } + else + { + if ( simpleTextPrint ) + { + simpleTextPrint = false; + } + else + { + DoIndent(); + } + buffer += ""; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlText& text ) +{ + if ( text.CDATA() ) + { + DoIndent(); + buffer += ""; + DoLineBreak(); + } + else if ( simpleTextPrint ) + { + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + } + else + { + DoIndent(); + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) +{ + DoIndent(); + declaration.Print( 0, 0, &buffer ); + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlComment& comment ) +{ + DoIndent(); + buffer += ""; + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) +{ + DoIndent(); + buffer += "<"; + buffer += unknown.Value(); + buffer += ">"; + DoLineBreak(); + return true; +} + diff --git a/TSCP/src/main/DeviceInfoManager/tinyxml/tinyxml.h b/TSCP/src/main/DeviceInfoManager/tinyxml/tinyxml.h new file mode 100644 index 0000000..a3589e5 --- /dev/null +++ b/TSCP/src/main/DeviceInfoManager/tinyxml/tinyxml.h @@ -0,0 +1,1805 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code by Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#ifndef TINYXML_INCLUDED +#define TINYXML_INCLUDED + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4530 ) +#pragma warning( disable : 4786 ) +#endif + +#include +#include +#include +#include +#include + +// Help out windows: +#if defined( _DEBUG ) && !defined( DEBUG ) +#define DEBUG +#endif + +#ifdef TIXML_USE_STL + #include + #include + #include + #define TIXML_STRING std::string +#else + #include "tinystr.h" + #define TIXML_STRING TiXmlString +#endif + +// Deprecated library function hell. Compilers want to use the +// new safe versions. This probably doesn't fully address the problem, +// but it gets closer. There are too many compilers for me to fully +// test. If you get compilation troubles, undefine TIXML_SAFE +#define TIXML_SAFE + +#ifdef TIXML_SAFE + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + // Microsoft visual studio, version 2005 and higher. + #define TIXML_SNPRINTF _snprintf_s + #define TIXML_SSCANF sscanf_s + #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + //#pragma message( "Using _sn* functions." ) + #define TIXML_SNPRINTF _snprintf + #define TIXML_SSCANF sscanf + #elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + //#warning( "Using sn* functions." ) + #define TIXML_SNPRINTF snprintf + #define TIXML_SSCANF sscanf + #else + #define TIXML_SNPRINTF snprintf + #define TIXML_SSCANF sscanf + #endif +#endif + +class TiXmlDocument; +class TiXmlElement; +class TiXmlComment; +class TiXmlUnknown; +class TiXmlAttribute; +class TiXmlText; +class TiXmlDeclaration; +class TiXmlParsingData; + +const int TIXML_MAJOR_VERSION = 2; +const int TIXML_MINOR_VERSION = 6; +const int TIXML_PATCH_VERSION = 2; + +/* Internal structure for tracking location of items + in the XML file. +*/ +struct TiXmlCursor +{ + TiXmlCursor() { Clear(); } + void Clear() { row = col = -1; } + + int row; // 0 based. + int col; // 0 based. +}; + + +/** + Implements the interface to the "Visitor pattern" (see the Accept() method.) + If you call the Accept() method, it requires being passed a TiXmlVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves + are simply called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, no children of this node or its sibilings will be Visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. + + You should never change the document from a callback. + + @sa TiXmlNode::Accept() +*/ +class TiXmlVisitor +{ +public: + virtual ~TiXmlVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } + /// Visit a document. + virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } + + /// Visit an element. + virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } + /// Visit an element. + virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } + + /// Visit a declaration + virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } + /// Visit a text node + virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } + /// Visit a comment node + virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } + /// Visit an unknown node + virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } +}; + +// Only used by Attribute::Query functions +enum +{ + TIXML_SUCCESS, + TIXML_NO_ATTRIBUTE, + TIXML_WRONG_TYPE +}; + + +// Used by the parsing routines. +enum TiXmlEncoding +{ + TIXML_ENCODING_UNKNOWN, + TIXML_ENCODING_UTF8, + TIXML_ENCODING_LEGACY +}; + +const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; + +/** TiXmlBase is a base class for every class in TinyXml. + It does little except to establish that TinyXml classes + can be printed and provide some utility functions. + + In XML, the document and elements can contain + other elements and other types of nodes. + + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) + + A Decleration contains: Attributes (not on tree) + @endverbatim +*/ +class TiXmlBase +{ + friend class TiXmlNode; + friend class TiXmlElement; + friend class TiXmlDocument; + +public: + TiXmlBase() : userData(0) {} + virtual ~TiXmlBase() {} + + /** All TinyXml classes can print themselves to a filestream + or the string class (TiXmlString in non-STL mode, std::string + in STL mode.) Either or both cfile and str can be null. + + This is a formatted print, and will insert + tabs and newlines. + + (For an unformatted stream, use the << operator.) + */ + virtual void Print( FILE* cfile, int depth ) const = 0; + + /** The world does not agree on whether white space should be kept or + not. In order to make everyone happy, these global, static functions + are provided to set whether or not TinyXml will condense all white space + into a single space or not. The default is to condense. Note changing this + value is not thread safe. + */ + static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } + + /// Return the current white space setting. + static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } + + /** Return the position, in the original source file, of this node or attribute. + The row and column are 1-based. (That is the first row and first column is + 1,1). If the returns values are 0 or less, then the parser does not have + a row and column value. + + Generally, the row and column value will be set when the TiXmlDocument::Load(), + TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set + when the DOM was created from operator>>. + + The values reflect the initial load. Once the DOM is modified programmatically + (by adding or changing nodes and attributes) the new values will NOT update to + reflect changes in the document. + + There is a minor performance cost to computing the row and column. Computation + can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. + + @sa TiXmlDocument::SetTabSize() + */ + int Row() const { return location.row + 1; } + int Column() const { return location.col + 1; } ///< See Row() + + void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. + void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. + const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. + + // Table that returs, for a given lead byte, the total number of bytes + // in the UTF-8 sequence. + static const int utf8ByteTable[256]; + + virtual const char* Parse( const char* p, + TiXmlParsingData* data, + TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; + + /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, + or they will be transformed into entities! + */ + static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); + + enum + { + TIXML_NO_ERROR = 0, + TIXML_ERROR, + TIXML_ERROR_OPENING_FILE, + TIXML_ERROR_PARSING_ELEMENT, + TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, + TIXML_ERROR_READING_ELEMENT_VALUE, + TIXML_ERROR_READING_ATTRIBUTES, + TIXML_ERROR_PARSING_EMPTY, + TIXML_ERROR_READING_END_TAG, + TIXML_ERROR_PARSING_UNKNOWN, + TIXML_ERROR_PARSING_COMMENT, + TIXML_ERROR_PARSING_DECLARATION, + TIXML_ERROR_DOCUMENT_EMPTY, + TIXML_ERROR_EMBEDDED_NULL, + TIXML_ERROR_PARSING_CDATA, + TIXML_ERROR_DOCUMENT_TOP_ONLY, + + TIXML_ERROR_STRING_COUNT + }; + +protected: + + static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); + + inline static bool IsWhiteSpace( char c ) + { + return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); + } + inline static bool IsWhiteSpace( int c ) + { + if ( c < 256 ) + return IsWhiteSpace( (char) c ); + return false; // Again, only truly correct for English/Latin...but usually works. + } + + #ifdef TIXML_USE_STL + static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); + static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); + #endif + + /* Reads an XML name into the string provided. Returns + a pointer just past the last character of the name, + or 0 if the function has an error. + */ + static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); + + /* Reads text. Returns a pointer past the given end tag. + Wickedly complex options, but it keeps the (sensitive) code in one place. + */ + static const char* ReadText( const char* in, // where to start + TIXML_STRING* text, // the string read + bool ignoreWhiteSpace, // whether to keep the white space + const char* endTag, // what ends this text + bool ignoreCase, // whether to ignore case in the end tag + TiXmlEncoding encoding ); // the current encoding + + // If an entity has been found, transform it into a character. + static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); + + // Get a character, while interpreting entities. + // The length can be from 0 to 4 bytes. + inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) + { + assert( p ); + if ( encoding == TIXML_ENCODING_UTF8 ) + { + *length = utf8ByteTable[ *((const unsigned char*)p) ]; + assert( *length >= 0 && *length < 5 ); + } + else + { + *length = 1; + } + + if ( *length == 1 ) + { + if ( *p == '&' ) + return GetEntity( p, _value, length, encoding ); + *_value = *p; + return p+1; + } + else if ( *length ) + { + //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), + // and the null terminator isn't needed + for( int i=0; p[i] && i<*length; ++i ) { + _value[i] = p[i]; + } + return p + (*length); + } + else + { + // Not valid text. + return 0; + } + } + + // Return true if the next characters in the stream are any of the endTag sequences. + // Ignore case only works for english, and should only be relied on when comparing + // to English words: StringEqual( p, "version", true ) is fine. + static bool StringEqual( const char* p, + const char* endTag, + bool ignoreCase, + TiXmlEncoding encoding ); + + static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; + + TiXmlCursor location; + + /// Field containing a generic user pointer + void* userData; + + // None of these methods are reliable for any language except English. + // Good for approximation, not great for accuracy. + static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); + static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); + inline static int ToLower( int v, TiXmlEncoding encoding ) + { + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( v < 128 ) return tolower( v ); + return v; + } + else + { + return tolower( v ); + } + } + static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + +private: + TiXmlBase( const TiXmlBase& ); // not implemented. + void operator=( const TiXmlBase& base ); // not allowed. + + struct Entity + { + const char* str; + unsigned int strLength; + char chr; + }; + enum + { + NUM_ENTITY = 5, + MAX_ENTITY_LENGTH = 6 + + }; + static Entity entity[ NUM_ENTITY ]; + static bool condenseWhiteSpace; +}; + + +/** The parent class for everything in the Document Object Model. + (Except for attributes). + Nodes have siblings, a parent, and children. A node can be + in a document, or stand on its own. The type of a TiXmlNode + can be queried, and it can be cast to its more defined type. +*/ +class TiXmlNode : public TiXmlBase +{ + friend class TiXmlDocument; + friend class TiXmlElement; + +public: + #ifdef TIXML_USE_STL + + /** An input stream operator, for every class. Tolerant of newlines and + formatting, but doesn't expect them. + */ + friend std::istream& operator >> (std::istream& in, TiXmlNode& base); + + /** An output stream operator, for every class. Note that this outputs + without any newlines or formatting, as opposed to Print(), which + includes tabs and new lines. + + The operator<< and operator>> are not completely symmetric. Writing + a node to a stream is very well defined. You'll get a nice stream + of output, without any extra whitespace or newlines. + + But reading is not as well defined. (As it always is.) If you create + a TiXmlElement (for example) and read that from an input stream, + the text needs to define an element or junk will result. This is + true of all input streams, but it's worth keeping in mind. + + A TiXmlDocument will read nodes until it reads a root element, and + all the children of that root element. + */ + friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); + + /// Appends the XML node or attribute to a std::string. + friend std::string& operator<< (std::string& out, const TiXmlNode& base ); + + #endif + + /** The types of XML nodes supported by TinyXml. (All the + unsupported types are picked up by UNKNOWN.) + */ + enum NodeType + { + TINYXML_DOCUMENT, + TINYXML_ELEMENT, + TINYXML_COMMENT, + TINYXML_UNKNOWN, + TINYXML_TEXT, + TINYXML_DECLARATION, + TINYXML_TYPECOUNT + }; + + virtual ~TiXmlNode(); + + /** The meaning of 'value' changes for the specific type of + TiXmlNode. + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + + The subclasses will wrap this function. + */ + const char *Value() const { return value.c_str (); } + + #ifdef TIXML_USE_STL + /** Return Value() as a std::string. If you only use STL, + this is more efficient than calling Value(). + Only available in STL mode. + */ + const std::string& ValueStr() const { return value; } + #endif + + const TIXML_STRING& ValueTStr() const { return value; } + + /** Changes the value of the node. Defined as: + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ + void SetValue(const char * _value) { value = _value;} + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Delete all the children of this node. Does not affect 'this'. + void Clear(); + + /// One step up the DOM. + TiXmlNode* Parent() { return parent; } + const TiXmlNode* Parent() const { return parent; } + + const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. + TiXmlNode* FirstChild() { return firstChild; } + const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + /// The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const char * _value ) { + // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) + // call the method, cast the return back to non-const. + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); + } + const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. + TiXmlNode* LastChild() { return lastChild; } + + const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const char * _value ) { + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. + #endif + + /** An alternate way to walk the children of a node. + One way to iterate over nodes is: + @verbatim + for( child = parent->FirstChild(); child; child = child->NextSibling() ) + @endverbatim + + IterateChildren does the same thing with the syntax: + @verbatim + child = 0; + while( child = parent->IterateChildren( child ) ) + @endverbatim + + IterateChildren takes the previous child as input and finds + the next one. If the previous child is null, it returns the + first. IterateChildren will return null when done. + */ + const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); + } + + /// This flavor of IterateChildren searches for children with a particular 'value' + const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + #endif + + /** Add a new node related to this. Adds a child past the LastChild. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); + + + /** Add a new node related to this. Adds a child past the LastChild. + + NOTE: the node to be added is passed by pointer, and will be + henceforth owned (and deleted) by tinyXml. This method is efficient + and avoids an extra copy, but should be used with care as it + uses a different memory model than the other insert functions. + + @sa InsertEndChild + */ + TiXmlNode* LinkEndChild( TiXmlNode* addThis ); + + /** Add a new node related to this. Adds a child before the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); + + /** Add a new node related to this. Adds a child after the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); + + /** Replace a child of this node. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); + + /// Delete a child of this node. + bool RemoveChild( TiXmlNode* removeThis ); + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling() const { return prev; } + TiXmlNode* PreviousSibling() { return prev; } + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling( const char * ) const; + TiXmlNode* PreviousSibling( const char *_prev ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Navigate to a sibling node. + const TiXmlNode* NextSibling() const { return next; } + TiXmlNode* NextSibling() { return next; } + + /// Navigate to a sibling node with the given 'value'. + const TiXmlNode* NextSibling( const char * ) const; + TiXmlNode* NextSibling( const char* _next ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement() const; + TiXmlElement* NextSiblingElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlElement* NextSiblingElement( const char *_next ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement() const; + TiXmlElement* FirstChildElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); + } + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement( const char * _value ) const; + TiXmlElement* FirstChildElement( const char * _value ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /** Query the type (as an enumerated value, above) of this node. + The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, + TINYXML_UNKNOWN, TINYXML_TEXT, and TINYXML_DECLARATION. + */ + int Type() const { return type; } + + /** Return a pointer to the Document this node lives in. + Returns null if not in a document. + */ + const TiXmlDocument* GetDocument() const; + TiXmlDocument* GetDocument() { + return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); + } + + /// Returns true if this node has no children. + bool NoChildren() const { return !firstChild; } + + virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + /** Create an exact duplicate of this node and return it. The memory must be deleted + by the caller. + */ + virtual TiXmlNode* Clone() const = 0; + + /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. + + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( TiXmlVisitor* visitor ) const = 0; + +protected: + TiXmlNode( NodeType _type ); + + // Copy to the allocated object. Shared functionality between Clone, Copy constructor, + // and the assignment operator. + void CopyTo( TiXmlNode* target ) const; + + #ifdef TIXML_USE_STL + // The real work of the input operator. + virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; + #endif + + // Figure out what is at *p, and parse it. Returns null if it is not an xml node. + TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); + + TiXmlNode* parent; + NodeType type; + + TiXmlNode* firstChild; + TiXmlNode* lastChild; + + TIXML_STRING value; + + TiXmlNode* prev; + TiXmlNode* next; + +private: + TiXmlNode( const TiXmlNode& ); // not implemented. + void operator=( const TiXmlNode& base ); // not allowed. +}; + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not TiXmlNodes, since they are not + part of the tinyXML document object model. There are other + suggested ways to look at this problem. +*/ +class TiXmlAttribute : public TiXmlBase +{ + friend class TiXmlAttributeSet; + +public: + /// Construct an empty attribute. + TiXmlAttribute() : TiXmlBase() + { + document = 0; + prev = next = 0; + } + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlAttribute( const std::string& _name, const std::string& _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + #endif + + /// Construct an attribute with a name and value. + TiXmlAttribute( const char * _name, const char * _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + + const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. + const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. + #ifdef TIXML_USE_STL + const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. + #endif + int IntValue() const; ///< Return the value of this attribute, converted to an integer. + double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + + // Get the tinyxml string representation + const TIXML_STRING& NameTStr() const { return name; } + + /** QueryIntValue examines the value string. It is an alternative to the + IntValue() method with richer error checking. + If the value is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. + + A specialized but useful call. Note that for success it returns 0, + which is the opposite of almost all other TinyXml calls. + */ + int QueryIntValue( int* _value ) const; + /// QueryDoubleValue examines the value string. See QueryIntValue(). + int QueryDoubleValue( double* _value ) const; + + void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const char* _value ) { value = _value; } ///< Set the value. + + void SetIntValue( int _value ); ///< Set the value from an integer. + void SetDoubleValue( double _value ); ///< Set the value from a double. + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetName( const std::string& _name ) { name = _name; } + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Get the next sibling attribute in the DOM. Returns null at end. + const TiXmlAttribute* Next() const; + TiXmlAttribute* Next() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); + } + + /// Get the previous sibling attribute in the DOM. Returns null at beginning. + const TiXmlAttribute* Previous() const; + TiXmlAttribute* Previous() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); + } + + bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } + bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } + bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } + + /* Attribute parsing starts: first letter of the name + returns: the next char after the value end quote + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + // Prints this Attribute to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + + // [internal use] + // Set the document pointer so the attribute can report errors. + void SetDocument( TiXmlDocument* doc ) { document = doc; } + +private: + TiXmlAttribute( const TiXmlAttribute& ); // not implemented. + void operator=( const TiXmlAttribute& base ); // not allowed. + + TiXmlDocument* document; // A pointer back to a document, for error reporting. + TIXML_STRING name; + TIXML_STRING value; + TiXmlAttribute* prev; + TiXmlAttribute* next; +}; + + +/* A class used to manage a group of attributes. + It is only used internally, both by the ELEMENT and the DECLARATION. + + The set can be changed transparent to the Element and Declaration + classes that use it, but NOT transparent to the Attribute + which has to implement a next() and previous() method. Which makes + it a bit problematic and prevents the use of STL. + + This version is implemented with circular lists because: + - I like circular lists + - it demonstrates some independence from the (typical) doubly linked list. +*/ +class TiXmlAttributeSet +{ +public: + TiXmlAttributeSet(); + ~TiXmlAttributeSet(); + + void Add( TiXmlAttribute* attribute ); + void Remove( TiXmlAttribute* attribute ); + + const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + + TiXmlAttribute* Find( const char* _name ) const; + TiXmlAttribute* FindOrCreate( const char* _name ); + +# ifdef TIXML_USE_STL + TiXmlAttribute* Find( const std::string& _name ) const; + TiXmlAttribute* FindOrCreate( const std::string& _name ); +# endif + + +private: + //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), + //*ME: this class must be also use a hidden/disabled copy-constructor !!! + TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed + void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) + + TiXmlAttribute sentinel; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class TiXmlElement : public TiXmlNode +{ +public: + /// Construct an element. + TiXmlElement (const char * in_value); + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlElement( const std::string& _value ); + #endif + + TiXmlElement( const TiXmlElement& ); + + TiXmlElement& operator=( const TiXmlElement& base ); + + virtual ~TiXmlElement(); + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + */ + const char* Attribute( const char* name ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an integer, + the integer value will be put in the return 'i', if 'i' + is non-null. + */ + const char* Attribute( const char* name, int* i ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an double, + the double value will be put in the return 'd', if 'd' + is non-null. + */ + const char* Attribute( const char* name, double* d ) const; + + /** QueryIntAttribute examines the attribute - it is an alternative to the + Attribute() method with richer error checking. + If the attribute is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. If the attribute + does not exist, then TIXML_NO_ATTRIBUTE is returned. + */ + int QueryIntAttribute( const char* name, int* _value ) const; + /// QueryUnsignedAttribute examines the attribute - see QueryIntAttribute(). + int QueryUnsignedAttribute( const char* name, unsigned* _value ) const; + /** QueryBoolAttribute examines the attribute - see QueryIntAttribute(). + Note that '1', 'true', or 'yes' are considered true, while '0', 'false' + and 'no' are considered false. + */ + int QueryBoolAttribute( const char* name, bool* _value ) const; + /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). + int QueryDoubleAttribute( const char* name, double* _value ) const; + /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). + int QueryFloatAttribute( const char* name, float* _value ) const { + double d; + int result = QueryDoubleAttribute( name, &d ); + if ( result == TIXML_SUCCESS ) { + *_value = (float)d; + } + return result; + } + + #ifdef TIXML_USE_STL + /// QueryStringAttribute examines the attribute - see QueryIntAttribute(). + int QueryStringAttribute( const char* name, std::string* _value ) const { + const char* cstr = Attribute( name ); + if ( cstr ) { + *_value = std::string( cstr ); + return TIXML_SUCCESS; + } + return TIXML_NO_ATTRIBUTE; + } + + /** Template form of the attribute query which will try to read the + attribute into the specified type. Very easy, very powerful, but + be careful to make sure to call this with the correct type. + + NOTE: This method doesn't work correctly for 'string' types that contain spaces. + + @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE + */ + template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + std::stringstream sstream( node->ValueStr() ); + sstream >> *outValue; + if ( !sstream.fail() ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; + } + + int QueryValueAttribute( const std::string& name, std::string* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + *outValue = node->ValueStr(); + return TIXML_SUCCESS; + } + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char* name, const char * _value ); + + #ifdef TIXML_USE_STL + const std::string* Attribute( const std::string& name ) const; + const std::string* Attribute( const std::string& name, int* i ) const; + const std::string* Attribute( const std::string& name, double* d ) const; + int QueryIntAttribute( const std::string& name, int* _value ) const; + int QueryDoubleAttribute( const std::string& name, double* _value ) const; + + /// STL std::string form. + void SetAttribute( const std::string& name, const std::string& _value ); + ///< STL std::string form. + void SetAttribute( const std::string& name, int _value ); + ///< STL std::string form. + void SetDoubleAttribute( const std::string& name, double value ); + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char * name, int value ); + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetDoubleAttribute( const char * name, double value ); + + /** Deletes an attribute with the given name. + */ + void RemoveAttribute( const char * name ); + #ifdef TIXML_USE_STL + void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. + #endif + + const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. + TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } + const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. + TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the TiXmlText child + and accessing it directly. + + If the first child of 'this' is a TiXmlText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + This is text + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + This is text + @endverbatim + GetText() will return "This is ". + + WARNING: GetText() accesses a child node - don't become confused with the + similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are + safe type casts on the referenced node. + */ + const char* GetText() const; + + /// Creates a new Element and returns it - the returned element is a copy. + virtual TiXmlNode* Clone() const; + // Print the Element to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: next char past '<' + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + + void CopyTo( TiXmlElement* target ) const; + void ClearThis(); // like clear, but initializes 'this' object as well + + // Used to be public [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + /* [internal use] + Reads the "value" of the element -- another element, or text. + This should terminate with the current end tag. + */ + const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + +private: + TiXmlAttributeSet attributeSet; +}; + + +/** An XML comment. +*/ +class TiXmlComment : public TiXmlNode +{ +public: + /// Constructs an empty comment. + TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {} + /// Construct a comment from text. + TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { + SetValue( _value ); + } + TiXmlComment( const TiXmlComment& ); + TiXmlComment& operator=( const TiXmlComment& base ); + + virtual ~TiXmlComment() {} + + /// Returns a copy of this Comment. + virtual TiXmlNode* Clone() const; + // Write this Comment to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: at the ! of the !-- + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlComment* target ) const; + + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif +// virtual void StreamOut( TIXML_OSTREAM * out ) const; + +private: + +}; + + +/** XML text. A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCDATA() and query it with CDATA(). +*/ +class TiXmlText : public TiXmlNode +{ + friend class TiXmlElement; +public: + /** Constructor for text element. By default, it is treated as + normal, encoded text. If you want it be output as a CDATA text + element, set the parameter _cdata to 'true' + */ + TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) + { + SetValue( initValue ); + cdata = false; + } + virtual ~TiXmlText() {} + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) + { + SetValue( initValue ); + cdata = false; + } + #endif + + TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); } + TiXmlText& operator=( const TiXmlText& base ) { base.CopyTo( this ); return *this; } + + // Write this text object to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /// Queries whether this represents text using a CDATA section. + bool CDATA() const { return cdata; } + /// Turns on or off a CDATA representation of text. + void SetCDATA( bool _cdata ) { cdata = _cdata; } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + /// [internal use] Creates a new Element and returns it. + virtual TiXmlNode* Clone() const; + void CopyTo( TiXmlText* target ) const; + + bool Blank() const; // returns true if all white space and new lines + // [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + bool cdata; // true if this should be input and output as a CDATA style text element +}; + + +/** In correct XML the declaration is the first entry in the file. + @verbatim + + @endverbatim + + TinyXml will happily read or write files without a declaration, + however. There are 3 possible attributes to the declaration: + version, encoding, and standalone. + + Note: In this version of the code, the attributes are + handled as special cases, not generic attributes, simply + because there can only be at most 3 and they are always the same. +*/ +class TiXmlDeclaration : public TiXmlNode +{ +public: + /// Construct an empty declaration. + TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {} + +#ifdef TIXML_USE_STL + /// Constructor. + TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ); +#endif + + /// Construct. + TiXmlDeclaration( const char* _version, + const char* _encoding, + const char* _standalone ); + + TiXmlDeclaration( const TiXmlDeclaration& copy ); + TiXmlDeclaration& operator=( const TiXmlDeclaration& copy ); + + virtual ~TiXmlDeclaration() {} + + /// Version. Will return an empty string if none was found. + const char *Version() const { return version.c_str (); } + /// Encoding. Will return an empty string if none was found. + const char *Encoding() const { return encoding.c_str (); } + /// Is this a standalone document? + const char *Standalone() const { return standalone.c_str (); } + + /// Creates a copy of this Declaration and returns it. + virtual TiXmlNode* Clone() const; + // Print this declaration to a FILE stream. + virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlDeclaration* target ) const; + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + + TIXML_STRING version; + TIXML_STRING encoding; + TIXML_STRING standalone; +}; + + +/** Any tag that tinyXml doesn't recognize is saved as an + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. + + DTD tags get thrown into TiXmlUnknowns. +*/ +class TiXmlUnknown : public TiXmlNode +{ +public: + TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} + virtual ~TiXmlUnknown() {} + + TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); } + TiXmlUnknown& operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); return *this; } + + /// Creates a copy of this Unknown and returns it. + virtual TiXmlNode* Clone() const; + // Print this Unknown to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected: + void CopyTo( TiXmlUnknown* target ) const; + + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + +}; + + +/** Always the top level node. A document binds together all the + XML pieces. It can be saved, loaded, and printed to the screen. + The 'value' of a document node is the xml file name. +*/ +class TiXmlDocument : public TiXmlNode +{ +public: + /// Create an empty document, that has no name. + TiXmlDocument(); + /// Create a document with a name. The name of the document is also the filename of the xml. + TiXmlDocument( const char * documentName ); + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlDocument( const std::string& documentName ); + #endif + + TiXmlDocument( const TiXmlDocument& copy ); + TiXmlDocument& operator=( const TiXmlDocument& copy ); + + virtual ~TiXmlDocument() {} + + /** Load a file using the current document value. + Returns true if successful. Will delete any existing + document data before loading. + */ + bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the current document value. Returns true if successful. + bool SaveFile() const; + /// Load a file using the given filename. Returns true if successful. + bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given filename. Returns true if successful. + bool SaveFile( const char * filename ) const; + /** Load a file using the given FILE*. Returns true if successful. Note that this method + doesn't stream - the entire object pointed at by the FILE* + will be interpreted as an XML file. TinyXML doesn't stream in XML from the current + file location. Streaming may be added in the future. + */ + bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given FILE*. Returns true if successful. + bool SaveFile( FILE* ) const; + + #ifdef TIXML_USE_STL + bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. + { + return LoadFile( filename.c_str(), encoding ); + } + bool SaveFile( const std::string& filename ) const ///< STL std::string version. + { + return SaveFile( filename.c_str() ); + } + #endif + + /** Parse the given null terminated block of xml data. Passing in an encoding to this + method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml + to use that encoding, regardless of what TinyXml might otherwise try to detect. + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + + /** Get the root element -- the only top level element -- of the document. + In well formed XML, there should only be one. TinyXml is tolerant of + multiple elements at the document level. + */ + const TiXmlElement* RootElement() const { return FirstChildElement(); } + TiXmlElement* RootElement() { return FirstChildElement(); } + + /** If an error occurs, Error will be set to true. Also, + - The ErrorId() will contain the integer identifier of the error (not generally useful) + - The ErrorDesc() method will return the name of the error. (very useful) + - The ErrorRow() and ErrorCol() will return the location of the error (if known) + */ + bool Error() const { return error; } + + /// Contains a textual (english) description of the error if one occurs. + const char * ErrorDesc() const { return errorDesc.c_str (); } + + /** Generally, you probably want the error string ( ErrorDesc() ). But if you + prefer the ErrorId, this function will fetch it. + */ + int ErrorId() const { return errorId; } + + /** Returns the location (if known) of the error. The first column is column 1, + and the first row is row 1. A value of 0 means the row and column wasn't applicable + (memory errors, for example, have no row/column) or the parser lost the error. (An + error in the error reporting, in that case.) + + @sa SetTabSize, Row, Column + */ + int ErrorRow() const { return errorLocation.row+1; } + int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() + + /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) + to report the correct values for row and column. It does not change the output + or input in any way. + + By calling this method, with a tab size + greater than 0, the row and column of each node and attribute is stored + when the file is loaded. Very useful for tracking the DOM back in to + the source file. + + The tab size is required for calculating the location of nodes. If not + set, the default of 4 is used. The tabsize is set per document. Setting + the tabsize to 0 disables row/column tracking. + + Note that row and column tracking is not supported when using operator>>. + + The tab size needs to be enabled before the parse or load. Correct usage: + @verbatim + TiXmlDocument doc; + doc.SetTabSize( 8 ); + doc.Load( "myfile.xml" ); + @endverbatim + + @sa Row, Column + */ + void SetTabSize( int _tabsize ) { tabsize = _tabsize; } + + int TabSize() const { return tabsize; } + + /** If you have handled the error, it can be reset with this call. The error + state is automatically cleared if you Parse a new XML block. + */ + void ClearError() { error = false; + errorId = 0; + errorDesc = ""; + errorLocation.row = errorLocation.col = 0; + //errorLocation.last = 0; + } + + /** Write the document to standard out using formatted printing ("pretty print"). */ + void Print() const { Print( stdout, 0 ); } + + /* Write the document to a string using formatted printing ("pretty print"). This + will allocate a character array (new char[]) and return it as a pointer. The + calling code pust call delete[] on the return char* to avoid a memory leak. + */ + //char* PrintToMemory() const; + + /// Print this Document to a FILE stream. + virtual void Print( FILE* cfile, int depth = 0 ) const; + // [internal use] + void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + + virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + // [internal use] + virtual TiXmlNode* Clone() const; + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + void CopyTo( TiXmlDocument* target ) const; + + bool error; + int errorId; + TIXML_STRING errorDesc; + int tabsize; + TiXmlCursor errorLocation; + bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. +}; + + +/** + A TiXmlHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + + + + + + + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + TiXmlElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + TiXmlElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + TiXmlElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + TiXmlElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity + of such code. A TiXmlHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + TiXmlHandle docHandle( &document ); + TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + TiXmlHandle handleCopy = handle; + @endverbatim + + What they should not be used for is iteration: + + @verbatim + int i=0; + while ( true ) + { + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); + if ( !child ) + break; + // do something + ++i; + } + @endverbatim + + It seems reasonable, but it is in fact two embedded while loops. The Child method is + a linear walk to find the element, so this code would iterate much more than it needs + to. Instead, prefer: + + @verbatim + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); + + for( child; child; child=child->NextSiblingElement() ) + { + // do something + } + @endverbatim +*/ +class TiXmlHandle +{ +public: + /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. + TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } + /// Copy constructor + TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } + TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; } + + /// Return a handle to the first child node. + TiXmlHandle FirstChild() const; + /// Return a handle to the first child node with the given name. + TiXmlHandle FirstChild( const char * value ) const; + /// Return a handle to the first child element. + TiXmlHandle FirstChildElement() const; + /// Return a handle to the first child element with the given name. + TiXmlHandle FirstChildElement( const char * value ) const; + + /** Return a handle to the "index" child with the given name. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( const char* value, int index ) const; + /** Return a handle to the "index" child. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( int index ) const; + /** Return a handle to the "index" child element with the given name. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( const char* value, int index ) const; + /** Return a handle to the "index" child element. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( int index ) const; + + #ifdef TIXML_USE_STL + TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } + TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } + + TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } + TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } + #endif + + /** Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* ToNode() const { return node; } + /** Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } + /** Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } + /** Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } + + /** @deprecated use ToNode. + Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* Node() const { return ToNode(); } + /** @deprecated use ToElement. + Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* Element() const { return ToElement(); } + /** @deprecated use ToText() + Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* Text() const { return ToText(); } + /** @deprecated use ToUnknown() + Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* Unknown() const { return ToUnknown(); } + +private: + TiXmlNode* node; +}; + + +/** Print to memory functionality. The TiXmlPrinter is useful when you need to: + + -# Print to memory (especially in non-STL mode) + -# Control formatting (line endings, etc.) + + When constructed, the TiXmlPrinter is in its default "pretty printing" mode. + Before calling Accept() you can call methods to control the printing + of the XML document. After TiXmlNode::Accept() is called, the printed document can + be accessed via the CStr(), Str(), and Size() methods. + + TiXmlPrinter uses the Visitor API. + @verbatim + TiXmlPrinter printer; + printer.SetIndent( "\t" ); + + doc.Accept( &printer ); + fprintf( stdout, "%s", printer.CStr() ); + @endverbatim +*/ +class TiXmlPrinter : public TiXmlVisitor +{ +public: + TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), + buffer(), indent( " " ), lineBreak( "\n" ) {} + + virtual bool VisitEnter( const TiXmlDocument& doc ); + virtual bool VisitExit( const TiXmlDocument& doc ); + + virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); + virtual bool VisitExit( const TiXmlElement& element ); + + virtual bool Visit( const TiXmlDeclaration& declaration ); + virtual bool Visit( const TiXmlText& text ); + virtual bool Visit( const TiXmlComment& comment ); + virtual bool Visit( const TiXmlUnknown& unknown ); + + /** Set the indent characters for printing. By default 4 spaces + but tab (\t) is also useful, or null/empty string for no indentation. + */ + void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } + /// Query the indention string. + const char* Indent() { return indent.c_str(); } + /** Set the line breaking string. By default set to newline (\n). + Some operating systems prefer other characters, or can be + set to the null/empty string for no indenation. + */ + void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } + /// Query the current line breaking string. + const char* LineBreak() { return lineBreak.c_str(); } + + /** Switch over to "stream printing" which is the most dense formatting without + linebreaks. Common when the XML is needed for network transmission. + */ + void SetStreamPrinting() { indent = ""; + lineBreak = ""; + } + /// Return the result. + const char* CStr() { return buffer.c_str(); } + /// Return the length of the result string. + size_t Size() { return buffer.size(); } + + #ifdef TIXML_USE_STL + /// Return the result. + const std::string& Str() { return buffer; } + #endif + +private: + void DoIndent() { + for( int i=0; i +#include + +#include "tinyxml.h" + +//#define DEBUG_PARSER +#if defined( DEBUG_PARSER ) +# if defined( DEBUG ) && defined( _MSC_VER ) +# include +# define TIXML_LOG OutputDebugString +# else +# define TIXML_LOG printf +# endif +#endif + +// Note tha "PutString" hardcodes the same list. This +// is less flexible than it appears. Changing the entries +// or order will break putstring. +TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] = +{ + { "&", 5, '&' }, + { "<", 4, '<' }, + { ">", 4, '>' }, + { """, 6, '\"' }, + { "'", 6, '\'' } +}; + +// Bunch of unicode info at: +// http://www.unicode.org/faq/utf_bom.html +// Including the basic of this table, which determines the #bytes in the +// sequence from the lead byte. 1 placed for invalid sequences -- +// although the result will be junk, pass it through as much as possible. +// Beware of the non-characters in UTF-8: +// ef bb bf (Microsoft "lead bytes") +// ef bf be +// ef bf bf + +const unsigned char TIXML_UTF_LEAD_0 = 0xefU; +const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; +const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + +const int TiXmlBase::utf8ByteTable[256] = +{ + // 0 1 2 3 4 5 6 7 8 9 a b c d e f + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte + 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid +}; + + +void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) +{ + const unsigned long BYTE_MASK = 0xBF; + const unsigned long BYTE_MARK = 0x80; + const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + if (input < 0x80) + *length = 1; + else if ( input < 0x800 ) + *length = 2; + else if ( input < 0x10000 ) + *length = 3; + else if ( input < 0x200000 ) + *length = 4; + else + { *length = 0; return; } // This code won't covert this correctly anyway. + + output += *length; + + // Scary scary fall throughs. + switch (*length) + { + case 4: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 3: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 2: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 1: + --output; + *output = (char)(input | FIRST_BYTE_MARK[*length]); + } +} + + +/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalpha( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalpha( anyByte ); +// } +} + + +/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalnum( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalnum( anyByte ); +// } +} + + +class TiXmlParsingData +{ + friend class TiXmlDocument; + public: + void Stamp( const char* now, TiXmlEncoding encoding ); + + const TiXmlCursor& Cursor() const { return cursor; } + + private: + // Only used by the document! + TiXmlParsingData( const char* start, int _tabsize, int row, int col ) + { + assert( start ); + stamp = start; + tabsize = _tabsize; + cursor.row = row; + cursor.col = col; + } + + TiXmlCursor cursor; + const char* stamp; + int tabsize; +}; + + +void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) +{ + assert( now ); + + // Do nothing if the tabsize is 0. + if ( tabsize < 1 ) + { + return; + } + + // Get the current row, column. + int row = cursor.row; + int col = cursor.col; + const char* p = stamp; + assert( p ); + + while ( p < now ) + { + // Treat p as unsigned, so we have a happy compiler. + const unsigned char* pU = (const unsigned char*)p; + + // Code contributed by Fletcher Dunn: (modified by lee) + switch (*pU) { + case 0: + // We *should* never get here, but in case we do, don't + // advance past the terminating null character, ever + return; + + case '\r': + // bump down to the next line + ++row; + col = 0; + // Eat the character + ++p; + + // Check for \r\n sequence, and treat this as a single character + if (*p == '\n') { + ++p; + } + break; + + case '\n': + // bump down to the next line + ++row; + col = 0; + + // Eat the character + ++p; + + // Check for \n\r sequence, and treat this as a single + // character. (Yes, this bizarre thing does occur still + // on some arcane platforms...) + if (*p == '\r') { + ++p; + } + break; + + case '\t': + // Eat the character + ++p; + + // Skip to next tab stop + col = (col / tabsize + 1) * tabsize; + break; + + case TIXML_UTF_LEAD_0: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( *(p+1) && *(p+2) ) + { + // In these cases, don't advance the column. These are + // 0-width spaces. + if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) + p += 3; + else + { p +=3; ++col; } // A normal character. + } + } + else + { + ++p; + ++col; + } + break; + + default: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // Eat the 1 to 4 byte utf8 character. + int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; + if ( step == 0 ) + step = 1; // Error case from bad encoding, but handle gracefully. + p += step; + + // Just advance one column, of course. + ++col; + } + else + { + ++p; + ++col; + } + break; + } + } + cursor.row = row; + cursor.col = col; + assert( cursor.row >= -1 ); + assert( cursor.col >= -1 ); + stamp = p; + assert( stamp ); +} + + +const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) +{ + if ( !p || !*p ) + { + return 0; + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + while ( *p ) + { + const unsigned char* pU = (const unsigned char*)p; + + // Skip the stupid Microsoft UTF-8 Byte order marks + if ( *(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==TIXML_UTF_LEAD_1 + && *(pU+2)==TIXML_UTF_LEAD_2 ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbeU ) + { + p += 3; + continue; + } + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbfU ) + { + p += 3; + continue; + } + + if ( IsWhiteSpace( *p ) ) // Still using old rules for white space. + ++p; + else + break; + } + } + else + { + while ( *p && IsWhiteSpace( *p ) ) + ++p; + } + + return p; +} + +#ifdef TIXML_USE_STL +/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) +{ + for( ;; ) + { + if ( !in->good() ) return false; + + int c = in->peek(); + // At this scope, we can't get to a document. So fail silently. + if ( !IsWhiteSpace( c ) || c <= 0 ) + return true; + + *tag += (char) in->get(); + } +} + +/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) +{ + //assert( character > 0 && character < 128 ); // else it won't work in utf-8 + while ( in->good() ) + { + int c = in->peek(); + if ( c == character ) + return true; + if ( c <= 0 ) // Silent failure: can't get document at this scope + return false; + + in->get(); + *tag += (char) c; + } + return false; +} +#endif + +// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The +// "assign" optimization removes over 10% of the execution time. +// +const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) +{ + // Oddly, not supported on some comilers, + //name->clear(); + // So use this: + *name = ""; + assert( p ); + + // Names start with letters or underscores. + // Of course, in unicode, tinyxml has no idea what a letter *is*. The + // algorithm is generous. + // + // After that, they can be letters, underscores, numbers, + // hyphens, or colons. (Colons are valid ony for namespaces, + // but tinyxml can't tell namespaces from names.) + if ( p && *p + && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) + { + const char* start = p; + while( p && *p + && ( IsAlphaNum( (unsigned char ) *p, encoding ) + || *p == '_' + || *p == '-' + || *p == '.' + || *p == ':' ) ) + { + //(*name) += *p; // expensive + ++p; + } + if ( p-start > 0 ) { + name->assign( start, p-start ); + } + return p; + } + return 0; +} + +const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) +{ + // Presume an entity, and pull it out. + TIXML_STRING ent; + int i; + *length = 0; + + if ( *(p+1) && *(p+1) == '#' && *(p+2) ) + { + unsigned long ucs = 0; + ptrdiff_t delta = 0; + unsigned mult = 1; + + if ( *(p+2) == 'x' ) + { + // Hexadecimal. + if ( !*(p+3) ) return 0; + + const char* q = p+3; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != 'x' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else if ( *q >= 'a' && *q <= 'f' ) + ucs += mult * (*q - 'a' + 10); + else if ( *q >= 'A' && *q <= 'F' ) + ucs += mult * (*q - 'A' + 10 ); + else + return 0; + mult *= 16; + --q; + } + } + else + { + // Decimal. + if ( !*(p+2) ) return 0; + + const char* q = p+2; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != '#' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else + return 0; + mult *= 10; + --q; + } + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // convert the UCS to UTF-8 + ConvertUTF32ToUTF8( ucs, value, length ); + } + else + { + *value = (char)ucs; + *length = 1; + } + return p + delta + 1; + } + + // Now try to match it. + for( i=0; iappend( cArr, len ); + } + } + else + { + bool whitespace = false; + + // Remove leading white space: + p = SkipWhiteSpace( p, encoding ); + while ( p && *p + && !StringEqual( p, endTag, caseInsensitive, encoding ) ) + { + if ( *p == '\r' || *p == '\n' ) + { + whitespace = true; + ++p; + } + else if ( IsWhiteSpace( *p ) ) + { + whitespace = true; + ++p; + } + else + { + // If we've found whitespace, add it before the + // new character. Any whitespace just becomes a space. + if ( whitespace ) + { + (*text) += ' '; + whitespace = false; + } + int len; + char cArr[4] = { 0, 0, 0, 0 }; + p = GetChar( p, cArr, &len, encoding ); + if ( len == 1 ) + (*text) += cArr[0]; // more efficient + else + text->append( cArr, len ); + } + } + } + if ( p && *p ) + p += strlen( endTag ); + return ( p && *p ) ? p : 0; +} + +#ifdef TIXML_USE_STL + +void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + // The basic issue with a document is that we don't know what we're + // streaming. Read something presumed to be a tag (and hope), then + // identify it, and call the appropriate stream method on the tag. + // + // This "pre-streaming" will never read the closing ">" so the + // sub-tag can orient itself. + + if ( !StreamTo( in, '<', tag ) ) + { + SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + while ( in->good() ) + { + int tagIndex = (int) tag->length(); + while ( in->good() && in->peek() != '>' ) + { + int c = in->get(); + if ( c <= 0 ) + { + SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + break; + } + (*tag) += (char) c; + } + + if ( in->good() ) + { + // We now have something we presume to be a node of + // some sort. Identify it, and call the node to + // continue streaming. + TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); + + if ( node ) + { + node->StreamIn( in, tag ); + bool isElement = node->ToElement() != 0; + delete node; + node = 0; + + // If this is the root element, we're done. Parsing will be + // done by the >> operator. + if ( isElement ) + { + return; + } + } + else + { + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + } + } + // We should have returned sooner. + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); +} + +#endif + +const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) +{ + ClearError(); + + // Parse away, at the document level. Since a document + // contains nothing but other tags, most of what happens + // here is skipping white space. + if ( !p || !*p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + // Note that, for a document, this needs to come + // before the while space skip, so that parsing + // starts from the pointer we are given. + location.Clear(); + if ( prevData ) + { + location.row = prevData->cursor.row; + location.col = prevData->cursor.col; + } + else + { + location.row = 0; + location.col = 0; + } + TiXmlParsingData data( p, TabSize(), location.row, location.col ); + location = data.Cursor(); + + if ( encoding == TIXML_ENCODING_UNKNOWN ) + { + // Check for the Microsoft UTF-8 lead bytes. + const unsigned char* pU = (const unsigned char*)p; + if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 + && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 + && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) + { + encoding = TIXML_ENCODING_UTF8; + useMicrosoftBOM = true; + } + } + + p = SkipWhiteSpace( p, encoding ); + if ( !p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + while ( p && *p ) + { + TiXmlNode* node = Identify( p, encoding ); + if ( node ) + { + p = node->Parse( p, &data, encoding ); + LinkEndChild( node ); + } + else + { + break; + } + + // Did we get encoding info? + if ( encoding == TIXML_ENCODING_UNKNOWN + && node->ToDeclaration() ) + { + TiXmlDeclaration* dec = node->ToDeclaration(); + const char* enc = dec->Encoding(); + assert( enc ); + + if ( *enc == 0 ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice + else + encoding = TIXML_ENCODING_LEGACY; + } + + p = SkipWhiteSpace( p, encoding ); + } + + // Was this empty? + if ( !firstChild ) { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); + return 0; + } + + // All is well. + return p; +} + +void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + // The first error in a chain is more accurate - don't set again! + if ( error ) + return; + + assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); + error = true; + errorId = err; + errorDesc = errorString[ errorId ]; + + errorLocation.Clear(); + if ( pError && data ) + { + data->Stamp( pError, encoding ); + errorLocation = data->Cursor(); + } +} + + +TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) +{ + TiXmlNode* returnNode = 0; + + p = SkipWhiteSpace( p, encoding ); + if( !p || !*p || *p != '<' ) + { + return 0; + } + + p = SkipWhiteSpace( p, encoding ); + + if ( !p || !*p ) + { + return 0; + } + + // What is this thing? + // - Elements start with a letter or underscore, but xml is reserved. + // - Comments: "; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + if ( document ) + document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // [ 1475201 ] TinyXML parses entities in comments + // Oops - ReadText doesn't work, because we don't want to parse the entities. + // p = ReadText( p, &value, false, endTag, false, encoding ); + // + // from the XML spec: + /* + [Definition: Comments may appear anywhere in a document outside other markup; in addition, + they may appear within the document type declaration at places allowed by the grammar. + They are not part of the document's character data; an XML processor MAY, but need not, + make it possible for an application to retrieve the text of comments. For compatibility, + the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity + references MUST NOT be recognized within comments. + + An example of a comment: + + + */ + + value = ""; + // Keep all the white space. + while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) + { + value.append( p, 1 ); + ++p; + } + if ( p && *p ) + p += strlen( endTag ); + + return p; +} + + +const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) return 0; + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + // Read the name, the '=' and the value. + const char* pErr = p; + p = ReadName( p, &name, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); + return 0; + } + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p || *p != '=' ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + ++p; // skip '=' + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + const char* end; + const char SINGLE_QUOTE = '\''; + const char DOUBLE_QUOTE = '\"'; + + if ( *p == SINGLE_QUOTE ) + { + ++p; + end = "\'"; // single quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else if ( *p == DOUBLE_QUOTE ) + { + ++p; + end = "\""; // double quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else + { + // All attribute values should be in single or double quotes. + // But this is such a common error that the parser will try + // its best, even without them. + value = ""; + while ( p && *p // existence + && !IsWhiteSpace( *p ) // whitespace + && *p != '/' && *p != '>' ) // tag end + { + if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { + // [ 1451649 ] Attribute values with trailing quotes not handled correctly + // We did not have an opening quote but seem to have a + // closing one. Give up and throw an error. + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + value += *p; + ++p; + } + } + return p; +} + +#ifdef TIXML_USE_STL +void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->peek(); + if ( !cdata && (c == '<' ) ) + { + return; + } + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + (*tag) += (char) c; + in->get(); // "commits" the peek made above + + if ( cdata && c == '>' && tag->size() >= 3 ) { + size_t len = tag->size(); + if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { + // terminator of cdata. + return; + } + } + } +} +#endif + +const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + value = ""; + TiXmlDocument* document = GetDocument(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + + const char* const startTag = ""; + + if ( cdata || StringEqual( p, startTag, false, encoding ) ) + { + cdata = true; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + if ( document ) + document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // Keep all the white space, ignore the encoding, etc. + while ( p && *p + && !StringEqual( p, endTag, false, encoding ) + ) + { + value += *p; + ++p; + } + + TIXML_STRING dummy; + p = ReadText( p, &dummy, false, endTag, false, encoding ); + return p; + } + else + { + bool ignoreWhite = true; + + const char* end = "<"; + p = ReadText( p, &value, ignoreWhite, end, false, encoding ); + if ( p && *p ) + return p-1; // don't truncate the '<' + return 0; + } +} + +#ifdef TIXML_USE_STL +void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c; + + if ( c == '>' ) + { + // All is well. + return; + } + } +} +#endif + +const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) +{ + p = SkipWhiteSpace( p, _encoding ); + // Find the beginning, find the end, and look for + // the stuff in-between. + TiXmlDocument* document = GetDocument(); + if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); + return 0; + } + if ( data ) + { + data->Stamp( p, _encoding ); + location = data->Cursor(); + } + p += 5; + + version = ""; + encoding = ""; + standalone = ""; + + while ( p && *p ) + { + if ( *p == '>' ) + { + ++p; + return p; + } + + p = SkipWhiteSpace( p, _encoding ); + if ( StringEqual( p, "version", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + version = attrib.Value(); + } + else if ( StringEqual( p, "encoding", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + encoding = attrib.Value(); + } + else if ( StringEqual( p, "standalone", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + standalone = attrib.Value(); + } + else + { + // Read over whatever it is. + while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) + ++p; + } + } + return 0; +} + +bool TiXmlText::Blank() const +{ + for ( unsigned i=0; i +#include "CommonTypes.h" +#include "CommonQueue.h" +#include +#include "malloc.h" +#include "stdlib.h" + +FILE * openlogfile(CHAR *dirName); +INT32 WriteData(LPVOID pParam); +void WinRardirByhour( CHAR *dirName ); +extern UINT8 qjLogSaveTime; + +RecordLogClass::RecordLogClass(UINT8 recodFlag,CHAR *folderName) +{ + filecounter = 0; + fp = NULL; + logFlg = 0; + if(recodFlag != 0) + { + if (!CreateDirectoryA(".\\PrtclLog", NULL)) + { + /* ɹ˵Ŀ¼,˲Ҫ */ + } + else + { + /* */ + } + + logFlg = 1; + if(folderName != NULL) + { + sprintf(dirName,".\\PrtclLog\\%s",folderName); + } + else + { + sprintf(dirName,"%s",".\\PrtclLog"); + } + _log_buff = (CHAR*)malloc(sizeof(CHAR)*1024*100); + fp = openlogfile(dirName); + _pwriteque = (QueueStruct *)malloc(sizeof(QueueStruct)); + QueueInitial(_pwriteque,1024*1024); + _dwWriteThread = NULL; + hWritedataSemaphore = CreateSemaphore(NULL,1,1,NULL); + } +} +RecordLogClass::~RecordLogClass() +{ + if(logFlg != 0) + { + Release(); + } + if(fp != NULL) + { + fclose(fp); + } +} +UINT8 RecordLogClass::Release() +{ + logFlg = 0; + if(_dwWriteThread != NULL) /* ߳ر*/ + { + TerminateThread(_hWriteThread,_dwWriteThread); + _dwWriteThread =0; + } + + if(_pwriteque != NULL) + { + QueueElementFree(_pwriteque); + free(_pwriteque); + _pwriteque = NULL; + } + + if(fp != NULL) + { + fclose(fp); + fp = NULL; + } + + return 1; +} + +/* + * + */ +UINT8 RecordLogClass::StartWrite() +{ + _hWriteThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)WriteData,(LPVOID)this,0,&_dwWriteThread); + SetThreadPriority(_hWriteThread,THREAD_PRIORITY_BELOW_NORMAL); + return 1; +} + +UINT8 RecordLogClass::Log(CHAR* fmt,...) +{ + va_list para; + UINT8 ret= 0; + UINT32 len = 0; + if(logFlg == 0) + { + return 1; + } + if(_dwWriteThread == NULL) + { + StartWrite(); + } + else + { + } + + if(fp == NULL) + { + return 1; + } + + va_start(para,fmt); + len = vsprintf(_log_buff,fmt,para); + + /**/ +#if 1 + WaitForSingleObject(hWritedataSemaphore,INFINITE); + + if(len >0) + { + ret = QueueWrite(len,(UINT8 *)_log_buff,_pwriteque);/*ед*/ + } + + /* */ + ReleaseSemaphore(hWritedataSemaphore,1,NULL); +#else + if(len>0) + { + fwrite(_log_buff,len,1,fp); + fflush(fp); + filecounter +=len; + if(filecounter > 1024*1024*20) + { + fclose(fp); + filecounter = 0; + fp = openlogfile(dirName); + } + } +#endif + return 1; +} + + +/*ɾָļ*/ +void DeldirByday( CHAR *dirName ) +{ + time_t CurSeconds; /*ʱ*/ + time_t PreSeconds; /*ʱ*/ + struct tm *dellocaltime=NULL; /*ʱ*/ + CHAR fileName[400]; /*Ŀ¼*/ + CHAR rarfileName[400]; /*Ŀ¼*/ + char DelCmd1[400]={0}; /*ʱ*/ + char DelCmd2[400]={0}; /*ʱ*/ + int i; /*ѭ*/ + int ret=0; + int ret1=0; + WCHAR szDest[800]; + memset(szDest, '\0', sizeof(WCHAR) * 800); + memset(fileName,'\0',sizeof(CHAR) * 400); /*ʼ*/ + memset(rarfileName,'\0',sizeof(CHAR) * 400); /*ʼ*/ + time(&CurSeconds); /*ȡʱ*/ + SHELLEXECUTEINFO ShExecInfo = { 0 }; + ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); + ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; + ShExecInfo.hwnd = NULL; + ShExecInfo.lpVerb = NULL; + ShExecInfo.lpDirectory = NULL; + ShExecInfo.nShow = SW_HIDE; + + ShExecInfo.hInstApp = NULL; + for(i=MAX_DAY;i> qjLogSaveTime;i--) + { + PreSeconds =0; + PreSeconds = CurSeconds-(i*3600*24);/*ȡҪɾʱ*/ + dellocaltime =localtime(&PreSeconds); + /*ƴдҪɾļ*/ + sprintf(fileName,"%s\\%04d%02d%02d",(CHAR *)dirName,dellocaltime->tm_year+1900,dellocaltime->tm_mon+1,dellocaltime->tm_mday); + /*ƴдҪɾļ*/ + sprintf(rarfileName,"%s\\%04d%02d%02d.rar",(CHAR *)dirName,dellocaltime->tm_year+1900,dellocaltime->tm_mon+1,dellocaltime->tm_mday); + + + /*ret0 Ŀ¼Ŀ¼*/ + /*ֻжĿ¼Ƿ*/ + ret1 = access(rarfileName,0); + if( !ret1) + { + /*Ŀ¼ɾļ*/ + /*sprintf(DelCmd2, "del /q /f /s %s",rarfileName); + system(DelCmd2);*/ + + /*Ŀ¼ɾļ*/ + sprintf(DelCmd2, " cmd.exe /c del /q /s %s", rarfileName); + /* system(DelCmd2);*/ + ShExecInfo.lpFile = L"cmd.exe"; + memset(szDest, '\0', sizeof(WCHAR) * 800); + long lLen = MultiByteToWideChar(CP_ACP, 0, DelCmd2, strlen(DelCmd2), szDest, sizeof(szDest)); + ShExecInfo.lpParameters = szDest; + ShellExecuteEx(&ShExecInfo); + WaitForSingleObject(ShExecInfo.hProcess, INFINITE); + + } + /*ֻжĿ¼Ƿ*/ + ret = access(fileName,0); + /*ret0 Ŀ¼Ŀ¼*/ + if( !ret ) + { + /*Ŀ¼ɾļ*/ + /*sprintf(DelCmd2, "rmdir /s/q %s",fileName); + system(DelCmd2);*/ + /*Ŀ¼ɾļ*/ + sprintf(DelCmd2, " cmd.exe /c rmdir /s /q %s", fileName); + /* system(DelCmd2);*/ + ShExecInfo.lpFile = L"cmd.exe"; + memset(szDest, '\0', sizeof(WCHAR) * 800); + long lLen = MultiByteToWideChar(CP_ACP, 0, DelCmd2, strlen(DelCmd2), szDest, sizeof(szDest)); + ShExecInfo.lpParameters = szDest; + ShellExecuteEx(&ShExecInfo); + WaitForSingleObject(ShExecInfo.hProcess, INFINITE); + + } + + + + } + +} + +/*ѹָļ*/ +void WinRardirByhour( CHAR *dirName ) +{ + time_t CurSeconds=0; /*ʱ*/ + time_t PreSeconds =0; /*ʱ*/ + struct tm *dellocaltime=NULL; /*ʱ*/ + CHAR fileName[400]={0}; /*Ŀ¼*/ + CHAR Name[400]={0}; /*Ŀ¼*/ + CHAR DirName[400]={0}; /*Ŀ¼*/ + CHAR fileNameRar[400]={0}; /*Ŀ¼*/ + + char WinrarCmd[400]={0}; /*ʱ*/ + char DelCmd2[400]={0}; /*ʱ*/ + int i=0; /*ѭ*/ + int j=0; /*ѭ*/ + int ret=0; + + WCHAR szDest[800]; + + memset(fileName,'\0',sizeof(CHAR) * 400); /*ʼ*/ + memset(Name,'\0',sizeof(CHAR) * 400); /*ʼ*/ + memset(DirName,'\0',sizeof(CHAR) * 400); /*ʼ*/ + memset(fileNameRar,'\0',sizeof(CHAR) * 400); /*ʼ*/ + memset(szDest, '\0', sizeof(WCHAR) * 800); + time(&CurSeconds); /*ȡʱ*/ + SHELLEXECUTEINFO ShExecInfo = { 0 }; + ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); + ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; + ShExecInfo.hwnd = NULL; + ShExecInfo.lpVerb = NULL; + ShExecInfo.lpDirectory= NULL; + ShExecInfo.nShow = SW_HIDE; + + ShExecInfo.hInstApp = NULL; + + + + for(i=MIN_DAY;i>=0;i--) + { + for(j=0;j< 24; j++) + { + PreSeconds = CurSeconds-((i*24-j )*3600); + if( PreSeconds <= (CurSeconds - 3600)) + { + /*ȡѹʱ*/ + dellocaltime =localtime(&PreSeconds); + /*ƴдҪѹļ*/ + sprintf(DirName,"%s\\%04d%02d%02d",(CHAR *)dirName,dellocaltime->tm_year+1900,dellocaltime->tm_mon+1,dellocaltime->tm_mday); + /*ƴдҪѹļ*/ + sprintf(fileNameRar,"%04d%02d%02d_%02d",dellocaltime->tm_year+1900,dellocaltime->tm_mon+1,dellocaltime->tm_mday,dellocaltime-> tm_hour); + /*ƴдҪѹļ*/ + sprintf(fileName,"%s\\%02d",(CHAR *)DirName,dellocaltime-> tm_hour); + /*ƴдҪѹļ*/ + sprintf(Name,"%s\\%s",DirName,fileNameRar); + + + /*ֻжĿ¼Ƿ*/ + ret = access(fileName,0); + /*ret0 Ŀ¼Ŀ¼*/ + if( !ret) + { + /*Ŀ¼ѹļ*/ + sprintf(WinrarCmd, "a -ep1 %s -ap %s.rar %s",Name,Name,fileName); + /* int ret =system(WinrarCmd);*/ + /*ɾļ*/ + + ShExecInfo.lpFile = L"rar.exe"; + memset(szDest, '\0', sizeof(WCHAR) * 800); + long lLen = MultiByteToWideChar(CP_ACP, 0, WinrarCmd, strlen(WinrarCmd), szDest, sizeof(szDest)); + ShExecInfo.lpParameters = szDest; + /* ShExecInfo.lpParameters = L"a -ep1 .\\PrtclLog\\20210902\\16.rar .\\PrtclLog\\20210902";*/ + bool ret = ShellExecuteEx(&ShExecInfo); + WaitForSingleObject(ShExecInfo.hProcess,INFINITE); + /*ret0 Ŀ¼Ŀ¼*/ + /*ֻжĿ¼Ƿ*/ + ret = access(fileName,0); + if( !ret) + { + /*Ŀ¼ɾļ*/ + sprintf(DelCmd2, " cmd.exe /c del /q /s %s",fileName); + /* system(DelCmd2);*/ + ShExecInfo.lpFile = L"cmd.exe"; + memset(szDest, '\0', sizeof(WCHAR) * 800); + long lLen = MultiByteToWideChar(CP_ACP, 0, DelCmd2, strlen(DelCmd2), szDest, sizeof(szDest)); + ShExecInfo.lpParameters = szDest; + ShellExecuteEx(&ShExecInfo); + WaitForSingleObject(ShExecInfo.hProcess, INFINITE); + + } + /*ֻжĿ¼Ƿ*/ + ret = access(fileName,0); + /*ret0 Ŀ¼Ŀ¼*/ + if( !ret ) + { + /*Ŀ¼ɾļ*/ + sprintf(DelCmd2, " cmd.exe /c rmdir /s /q %s",fileName); + /* system(DelCmd2);*/ + ShExecInfo.lpFile = L"cmd.exe"; + memset(szDest, '\0', sizeof(WCHAR) * 800); + long lLen = MultiByteToWideChar(CP_ACP, 0, DelCmd2, strlen(DelCmd2), szDest, sizeof(szDest)); + ShExecInfo.lpParameters = szDest; + ShellExecuteEx(&ShExecInfo); + WaitForSingleObject(ShExecInfo.hProcess, INFINITE); + + } + + } + } + else + { + break; + } + + } + + if( i != 0) + { + PreSeconds = CurSeconds-((i*24)*3600); + /*ȡҪɾʱ*/ + dellocaltime =localtime(&PreSeconds); + /*ƴдҪɾļ,dellocaltime->tm_hour*/ + sprintf(DirName,"%s\\%04d%02d%02d",(CHAR *)dirName,dellocaltime->tm_year+1900,dellocaltime->tm_mon+1,dellocaltime->tm_mday); + /*ƴдҪɾļ,dellocaltime->tm_hour*/ + //sprintf(Name,"%04d%02d%02d",dellocaltime->tm_year+1900,dellocaltime->tm_mon+1,dellocaltime->tm_mday); + + /*ֻжĿ¼Ƿ*/ + ret = access(DirName,0); + /*ret0 Ŀ¼Ŀ¼*/ + if( !ret) + { + /*Ŀ¼ѹļ*/ + sprintf(WinrarCmd, "a -ep1 %s -ap %s.rar %s",DirName,DirName,DirName); + /* system(WinrarCmd);*/ + /*ɾļ*/ + ShExecInfo.lpFile = L"rar.exe"; + memset(szDest, '\0', sizeof(WCHAR) * 800); + long lLen = MultiByteToWideChar(CP_ACP, 0, WinrarCmd, strlen(WinrarCmd), szDest, sizeof(szDest)); + ShExecInfo.lpParameters = szDest; + /* ShExecInfo.lpParameters = L"a -ep1 .\\PrtclLog\\20210902\\16.rar .\\PrtclLog\\20210902";*/ + bool ret = ShellExecuteEx(&ShExecInfo); + WaitForSingleObject(ShExecInfo.hProcess, INFINITE); + + /*ret0 Ŀ¼Ŀ¼*/ + /*ֻжĿ¼Ƿ*/ + ret = access(DirName,0); + if( !ret) + { + /*Ŀ¼ɾļ*/ + sprintf(DelCmd2, " cmd.exe /c del /q /s %s",DirName); + /*system(DelCmd2);*/ + ShExecInfo.lpFile = L"cmd.exe"; + memset(szDest, '\0', sizeof(WCHAR) * 400); + long lLen = MultiByteToWideChar(CP_ACP, 0, DelCmd2, strlen(DelCmd2), szDest, sizeof(szDest)); + ShExecInfo.lpParameters = szDest; + ShellExecuteEx(&ShExecInfo); + WaitForSingleObject(ShExecInfo.hProcess, INFINITE); + + } + /*ֻжĿ¼Ƿ*/ + ret = access(DirName,0); + /*ret0 Ŀ¼Ŀ¼*/ + if( !ret ) + { + /*Ŀ¼ɾļ*/ + sprintf(DelCmd2, " cmd.exe /c rmdir /s /q %s",DirName); + /*system(DelCmd2);*/ + ShExecInfo.lpFile = L"cmd.exe"; + memset(szDest, '\0', sizeof(WCHAR) * 400); + long lLen = MultiByteToWideChar(CP_ACP, 0, DelCmd2, strlen(DelCmd2), szDest, sizeof(szDest)); + ShExecInfo.lpParameters = szDest; + ShellExecuteEx(&ShExecInfo); + WaitForSingleObject(ShExecInfo.hProcess, INFINITE); + + } + + } + } + + + + } + + +} +FILE * openlogfile(CHAR *dirName) +{ + + FILE *fp = NULL; + CHAR fileName[400]; + CHAR fileName1[200]; + CHAR RemirfileName[200]; + static bool flag = false; + SYSTEMTIME tm; + GetLocalTime(&tm); + + memset(fileName,'\0',sizeof(CHAR) * 400); + memset(fileName1,'\0',sizeof(CHAR) * 200); + memset(RemirfileName,'\0',sizeof(CHAR) * 200); + sprintf(RemirfileName,"%s\\%04d%02d%02d",dirName,tm.wYear,tm.wMonth,tm.wDay); + sprintf(fileName1,"%s\\%02d",RemirfileName,tm.wHour); + + + if (!CreateDirectoryA((CHAR *)RemirfileName, NULL)) + { + /* ɹ˵Ŀ¼,˲Ҫ */ + + } + else + { + + } + + if (!CreateDirectoryA((CHAR *)fileName1, NULL)) + { + /* ɹ˵Ŀ¼,˲Ҫ */ + + } + else + { + if( false== flag) + { + flag = true; + } + else + { + /*ǰĿ¼ͬʱɾ־ */ + WinRardirByhour(dirName ); + DeldirByday(dirName); + } + + } + sprintf(fileName,"%s\\%04d_%02d_%02d_%02d_%02d_%02d.log",(CHAR *)fileName1,tm.wYear,tm.wMonth,tm.wDay,tm.wHour,tm.wMinute,tm.wSecond); + fp = fopen(fileName,"a+"); + return fp; +} + +UINT8 RecordLogClass::WriteThead() +{ + UINT8 buff[2048]; + UINT8 ret = 0; + + while(1) + { + UINT32 len = 0; + if(logFlg == 0) + { + break; + } +#if 0 + /* */ + WaitForSingleObject(hWritedataSemaphore,INFINITE); + len = QueueStatus(_pwriteque); + if( len >0) + { + /* ȡݵBuff*/ + ret = QueueRead(len,buff,_pwriteque); + /*¼ݳ*/ + } + /* */ + ReleaseSemaphore(hWritedataSemaphore,1,NULL); +#else + len = GetLogData(buff); +#endif + if(len >0) + { + fwrite(buff,len,1,fp); + fflush(fp); + filecounter +=len; + if(filecounter > 1024*1024*20) + { + fclose(fp); + filecounter = 0; + fp = openlogfile(dirName); + } + } + else + { + Sleep(1); + } + } + return ret; +} +/* + * ̴ + */ +INT32 WriteData(LPVOID pParam) +{ + UINT8 ret = 0; + UINT32 len = 0; + //UINT8 buff[2048]; + RecordLogClass *pRecordLogClass = (RecordLogClass*)pParam; + pRecordLogClass->WriteThead(); +#if 0 + while(1) + { + len = pRecordLogClass->GetLogData(buff); + + if(len>0) + { + pRecordLogClass->WriteFile(buff,len); + } + + Sleep(0); + + } +#endif + return ret; +} + +UINT32 RecordLogClass::GetLogData(UINT8 *buff) +{ + UINT32 len = 0; + UINT8 ret =0; + /* */ + WaitForSingleObject(hWritedataSemaphore,INFINITE); + len = QueueStatus(_pwriteque); + if( len < 2048) + { + /* ȡݵBuff*/ + ret = QueueRead(len,buff,_pwriteque); + /*¼ݳ*/ + } + else + { + /* ȡݵBuff*/ + ret = QueueRead(2048,buff,_pwriteque); + /*¼ݳ*/ + len = 2048; + } + + /* */ + ReleaseSemaphore(hWritedataSemaphore,1,NULL); + + return len; +} + +UINT8 RecordLogClass::WriteFile(UINT8 *buff,UINT32 len) +{ + fwrite(buff,len,1,fp); + fflush(fp); + filecounter +=len; + if(filecounter > 1024*1024*20) + { + fclose(fp); + filecounter = 0; + fp = openlogfile(dirName); + } + return 0; +} \ No newline at end of file diff --git a/TSCP/src/main/RecordClass/RecordClass.h b/TSCP/src/main/RecordClass/RecordClass.h new file mode 100644 index 0000000..9b4c20b --- /dev/null +++ b/TSCP/src/main/RecordClass/RecordClass.h @@ -0,0 +1,68 @@ +/* +* +* ļ RecordClass.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.06.3 +* ¥Ϊ +* ¼ +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +* 1 2011/06/03 ¥ΰ Э +*/ +#ifndef _RECORD_CLASS_H_ +#define _RECORD_CLASS_H_ + +#include +#include +#include +#include "CommonTypes.h" +#include "CommonQueue.h" + + +typedef void* HANDLE; + + +#define MAX_DAY 255 +#define MIN_DAY 29 + +/*typedef enum +{ + LOG = 0x0, + LOG_WARN=0x01, + LOG_ERROR = 0x02, + LOG_FAULT = 0x03 +} LOG_LEVEL;*/ +class RecordLogClass +{ + private: + FILE *fp; + CHAR dirName[100]; + UINT32 filecounter; + CHAR *_log_buff; + HANDLE _hWriteThread; /* д̾ */ + + HANDLE hWritedataSemaphore; + UINT8 logFlg; + QueueStruct *_pwriteque; + unsigned long _dwWriteThread; /* ̿ʼ־ */ + + public: + RecordLogClass(UINT8 recodFlag,CHAR *folderName = NULL); + ~RecordLogClass(); + UINT8 Release(); + UINT8 StartWrite(); + UINT8 WriteThead(); + UINT32 GetLogData(UINT8 *); + UINT8 WriteFile(UINT8 *buff,UINT32 Len); + public: + UINT8 Log(CHAR* fmt,...); +}; +extern RecordLogClass *CiLog; + +void DeldirByday( CHAR *dirName ); +void SearchFile(CHAR *dirName, CHAR *CompareFileName); +#endif + diff --git a/TSCP/src/main/SimDef/SimDef.h b/TSCP/src/main/SimDef/SimDef.h new file mode 100644 index 0000000..9f41ac7 --- /dev/null +++ b/TSCP/src/main/SimDef/SimDef.h @@ -0,0 +1,21 @@ +#ifndef _SIMDEF_H_ +#define _SIMDEF_H_ + +#include "CommonTypes.h" + +#define PRTL_CNT 7 +#define PRTL_UDP_CNT 3//ʹUDPΪЭЭ +#define PRTL_TCP_SER_CNT 1//ʹTCPΪЭ飬ΪTCP˵Э +#define SFP_IDX 0//SFPЭ +#define RP_IDX 1//RPЭ +#define RSSP1_IDX 2//RSSP1Э +#define RSSP2_IDX 3//RSSP2Э +#define FSFB_IDX 6//RSSP2Э + +#define ERR_DEF 0 +#define SUC_DEF 1 + +#define RED_NET 0 +#define BLUE_NET 1 + +#endif diff --git a/TSCP/src/main/ccov/Ccov_RSSPII_Parser.cpp b/TSCP/src/main/ccov/Ccov_RSSPII_Parser.cpp new file mode 100644 index 0000000..b10e7a0 --- /dev/null +++ b/TSCP/src/main/ccov/Ccov_RSSPII_Parser.cpp @@ -0,0 +1,148 @@ +#include "Ccov_RSSPII_Parser.h" + + +Ccov_RSSPII_Parser::Ccov_RSSPII_Parser(void) +{ + this->m_byteBufQ = new deque(); + this->m_tempBufQ = new deque(); + this->m_frameBufQ = new deque(); + + this->m_rBytesMutex = CreateMutex(NULL,FALSE,NULL); + this->m_framesMutex = CreateMutex(NULL,FALSE,NULL); + this->m_toRun = 0; + this->m_parsing=0; + this->m_parseThr = NULL; +} + + +Ccov_RSSPII_Parser::~Ccov_RSSPII_Parser(void) +{ + delete this->m_byteBufQ; + delete this->m_tempBufQ; + delete this->m_frameBufQ; + + CloseHandle(this->m_rBytesMutex); + CloseHandle(this->m_framesMutex); +} + +void Ccov_RSSPII_Parser::ImportBytes(unsigned char* bytes,int startIdx,int byteLen) +{ + WaitForSingleObject(this->m_rBytesMutex,INFINITE); + // + for(int i=startIdx;im_byteBufQ->push_back(bytes[i]); + } + ReleaseMutex(this->m_rBytesMutex); +} + +void Ccov_RSSPII_Parser::Start(void) +{ + this->m_toRun = 1; + + this->m_parsing=1; + this->m_parseThr = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)(Ccov_RSSPII_Parser::CycleParse),this,0,&this->m_parseThrId); +} + +void Ccov_RSSPII_Parser::Stop(void) +{ + this->m_toRun = 0; + if (m_parseThr!=NULL) + { + while(this->m_parsing) + { + /*ȴ߳̽*/ + } + CloseHandle(this->m_parseThr); + } +} + +void Ccov_RSSPII_Parser::CycleParse(LPVOID pPara) +{ + Ccov_RSSPII_Parser *thisObj=(Ccov_RSSPII_Parser *)pPara; + unsigned char tByte,tByte1; + int tSize; + int tFrameLen; + while(thisObj->m_toRun) + { + //ݿ + WaitForSingleObject(thisObj->m_rBytesMutex,INFINITE); + /*WaitForSingleObject(thisObj->m_framesMutex,INFINITE);*/ + while(!thisObj->m_byteBufQ->empty()) + { + tByte = thisObj->m_byteBufQ->front(); + thisObj->m_byteBufQ->pop_front(); + thisObj->m_tempBufQ->push_back(tByte); + } + + ReleaseMutex(thisObj->m_rBytesMutex); + + //ݽ + tSize = thisObj->m_tempBufQ->size(); + while(tSize>=2) + { + tByte = thisObj->m_tempBufQ->at(0); + tByte1 = thisObj->m_tempBufQ->at(1); + tFrameLen = tByte*256+tByte1+2;//˱;+2:ֽ + if(tSize>=tFrameLen) + { + WaitForSingleObject(thisObj->m_framesMutex,INFINITE); + for(int i=0;im_tempBufQ->front(); + thisObj->m_tempBufQ->pop_front(); + thisObj->m_frameBufQ->push_back(tByte); + } + ReleaseMutex(thisObj->m_framesMutex); + + tSize = thisObj->m_tempBufQ->size(); + } + else + { + break; + } + } + Sleep(15); + } + thisObj->m_parsing = 0; +} + +int Ccov_RSSPII_Parser::GetFrames(unsigned char *outBuf,int maxLen) +{ + unsigned char tByte,tByte1; + int tSize; + int tFrameLen; + int idx,idx1; + idx1=0; + WaitForSingleObject(this->m_framesMutex,INFINITE); + //ݽ + tSize = this->m_frameBufQ->size(); + while(tSize>=2) + { + tByte = this->m_frameBufQ->at(0); + tByte1 = this->m_frameBufQ->at(1); + tFrameLen = tByte*256+tByte1+2;//˱;+2:ֽ + if((idx1+tFrameLen)>maxLen) + { + break; + } + if(tSize>=tFrameLen) + { + for(idx=0;idxm_frameBufQ->front(); + this->m_frameBufQ->pop_front(); + outBuf[idx1++]=tByte; + } + tSize = this->m_frameBufQ->size(); + } + else + { + break; + } + } + + ReleaseMutex(this->m_framesMutex); + + return idx1; +} \ No newline at end of file diff --git a/TSCP/src/main/ccov/Ccov_RSSPII_Parser.h b/TSCP/src/main/ccov/Ccov_RSSPII_Parser.h new file mode 100644 index 0000000..ad23593 --- /dev/null +++ b/TSCP/src/main/ccov/Ccov_RSSPII_Parser.h @@ -0,0 +1,28 @@ +#pragma once +#include +#include "windows.h" +using namespace std; +class Ccov_RSSPII_Parser +{ +public: + Ccov_RSSPII_Parser(void); + ~Ccov_RSSPII_Parser(void); + void ImportBytes(unsigned char* bytes,int startIdx,int byteLen); + void ReadRsspIIFrame(unsigned char* frameBuf,int frameBufLen); + void Start(void); + void Stop(void); + int GetFrames(unsigned char* outBuf,int maxLen); +private: + deque *m_byteBufQ; + deque *m_tempBufQ; + deque *m_frameBufQ; + + HANDLE m_parseThr;//ݽ߳̾ + DWORD m_parseThrId; + HANDLE m_rBytesMutex; + HANDLE m_framesMutex; + unsigned char m_toRun; + unsigned char m_parsing; + static void CycleParse(LPVOID pPara); +}; + diff --git a/TSCP/src/main/ccov/Ccov_RsspII.cpp b/TSCP/src/main/ccov/Ccov_RsspII.cpp new file mode 100644 index 0000000..128eb54 --- /dev/null +++ b/TSCP/src/main/ccov/Ccov_RsspII.cpp @@ -0,0 +1,313 @@ +#include "Convert.h" +#include "Ccov_RsspII.h" +#include "windows.h" +#include "dsuRssp2DataStru.h" +#include "dsuRssp2Func.h" +#include "..\\DeviceInfoManager\\readxmltodata.h" + + + +extern "C" INT8 debug_infor_printf( + char* debug_string, /*ʵCеprintfĹ,ƽ̨ĵӡ*/ + ...); + +Ccov_RsspII::Ccov_RsspII(void) +{ + this->m_parsersMutex = CreateMutex(NULL,FALSE,NULL); +} + + +Ccov_RsspII::~Ccov_RsspII(void) +{ +} + +unsigned char Ccov_RsspII::SetNetEndPoint(unsigned int ip,unsigned short port,unsigned char redOrBlue) +{ + this->m_ipBytes[0]=(unsigned char)(ip>>24); + this->m_ipBytes[1]=(unsigned char)(ip>>16); + this->m_ipBytes[2]=(unsigned char)(ip>>8); + this->m_ipBytes[3]=(unsigned char)ip; + + this->m_port = port; + this->m_redOrBlue = redOrBlue; + return 0; +} + +unsigned char Ccov_RsspII::Start(void) +{ + unsigned char sucFlag = 0; + this->m_tcpSer = new Ccov_TcpSer(this->m_ipBytes,this->m_port); + this->m_tcpSer->RegisterRecvCallBack((TcpConnectionRecvHandler)(Ccov_RsspII::RecvManage),this); + this->m_tcpSer->RegisterDelCallBack((ClientDelHandler)(Ccov_RsspII::DelClientManage),this); + sucFlag = this->m_tcpSer->Start(); + + return sucFlag; +} +void Ccov_RsspII::DelClientManage(unsigned int clientIp,unsigned short clientPort,LPVOID pDelHandler) +{ + unsigned char qRet; + unsigned int etcsId; + + DSU_IP_PORT ipPort; + + ipPort.Ip[0] = ((clientIp >> (8*3)) & 0x000000FF); + ipPort.Ip[1] = ((clientIp >> (8*2)) & 0x000000FF); + ipPort.Ip[2] = ((clientIp >> (8*1)) & 0x000000FF); + ipPort.Ip[3] = ((clientIp >> (8*0)) & 0x000000FF); + + ipPort.Port = clientPort; + + qRet = dquGetEtcsIdByIpPort(ipPort, &etcsId); + + if(1 == qRet) + { + return; + } + + Ccov_RsspII *thisObj = (Ccov_RsspII *)pDelHandler; + + WaitForSingleObject(thisObj->m_parsersMutex,INFINITE); + + map::iterator item = thisObj->m_mapParsers.find(etcsId); + + if(item!=thisObj->m_mapParsers.end()) + { + item->second->Stop(); + delete item->second; + thisObj->m_mapParsers.erase(etcsId); + } + + ReleaseMutex(thisObj->m_parsersMutex); +} +void Ccov_RsspII::RecvManage(unsigned char *rBuf,int rLen,unsigned int srcIp,unsigned short srcPort,LPVOID pRcvHandler) +{ + unsigned char qRet; + unsigned int etcsId; + + DSU_IP_PORT ipPort; + + ipPort.Ip[0] = ((srcIp >> (8*3)) & 0x000000FF); + ipPort.Ip[1] = ((srcIp >> (8*2)) & 0x000000FF); + ipPort.Ip[2] = ((srcIp >> (8*1)) & 0x000000FF); + ipPort.Ip[3] = ((srcIp >> (8*0)) & 0x000000FF); + + ipPort.Port = srcPort; + + qRet = dquGetEtcsIdByIpPort(ipPort, &etcsId); + + if(1 != qRet) + { + return; + } + + Ccov_RsspII *thisObj = (Ccov_RsspII *)pRcvHandler; + + Ccov_RSSPII_Parser * tParser; + WaitForSingleObject(thisObj->m_parsersMutex, INFINITE); + map::iterator item = thisObj->m_mapParsers.find(etcsId); + + if(item!=thisObj->m_mapParsers.end()) + {//˵Դ豸ݽѾ + tParser = item->second; + } + else + { + tParser = new Ccov_RSSPII_Parser(); + thisObj->m_mapParsers.insert(pair(etcsId, tParser));//ӹmap + tParser->Start(); + } + + tParser->ImportBytes(rBuf,0,rLen); + ReleaseMutex(thisObj->m_parsersMutex); +} + +int Ccov_RsspII::ReadData(unsigned char *outBuf,int maxLen) +{ + int tLen1=0; + int tLen2=0; + int tLen3=0; + int k=0; + unsigned char spaceOut=0; + UINT32 etcsId = 0; + UINT16 logId = 0; + UINT16 devName = 0; + + WaitForSingleObject(this->m_parsersMutex,INFINITE); + //ӵĽ + map::iterator it; + for(it=this->m_mapParsers.begin();it!=this->m_mapParsers.end();it++) + { + k=0; + + tLen2 = it->second->GetFrames(this->m_rssp2FraBuf,sizeof(this->m_rssp2FraBuf)); + + if(tLen2>0) + { + for(int i=0;im_rssp2FraBuf[i]*256+this->m_rssp2FraBuf[i+1]+2;//˱룻+2ȱ2ֽ + if(tLen1 + 2 + 2 + 2 + tLen3 <= maxLen) + {//˵пռ洢 + devName = 0; + logId = 0; + + dquEtcsId2DevName(it->first, &devName, &logId); + + outBuf[tLen1++]=(unsigned char)((tLen3+4)>>8); + outBuf[tLen1++]=(unsigned char)((tLen3+4)>>0);//Ч֡+2ֽڣ豸+ID) + outBuf[tLen1++]=(unsigned char)(devName>>8);//豸 + outBuf[tLen1++]=(unsigned char)(devName>>0);//豸ID + outBuf[tLen1++]=(unsigned char)(logId>>8);//߼ID + outBuf[tLen1++]=(unsigned char)(logId>>0);//߼ID + + for(int j = 0; j < tLen3; j++)//Ч֡ + { + outBuf[tLen1++]=this->m_rssp2FraBuf[k++]; + } + } + else + { + spaceOut=1; + break; + } + } + } + if(spaceOut) + { + break; + } + } + ReleaseMutex(this->m_parsersMutex); + if(tLen1>0) + { + debug_infor_printf("ccov data arrive time is %lu,data len is%d\n",GetTickCount(),tLen1); + } + return tLen1; +} + +unsigned char Ccov_RsspII::Send(unsigned short dstDevId, unsigned short logicId, const unsigned char *sBuf, int sLen) +{ + unsigned retVal = 1; + IpInfo pIpInfos[4]; + unsigned char ipCnt = 0; + unsigned int etcsId = 0; + DSU_IP_PORT pRedIpPort[8]; + DSU_IP_PORT pBlueIpPort[8]; + unsigned int i=0; +#if 0 + GetNetEndPoint(dstDevId, logicId, RSSP2_IDX, pIpInfos, &ipCnt); +#else + retVal = dquDevName2EtcsId(dstDevId,logicId,&etcsId); + retVal &= dquGetIpPortByEtcsId(etcsId,&ipCnt,pRedIpPort,pBlueIpPort); + ipCnt=(ipCnt>4)?4:ipCnt; + if(1 == retVal) + { + for(i=0;im_redOrBlue==RED_NET) + { + retVal = this->m_tcpSer->Send(sBuf,sLen,pIpInfos[idx].redIp); + } + else if(this->m_redOrBlue==BLUE_NET) + { + retVal = this->m_tcpSer->Send(sBuf,sLen,pIpInfos[idx].blueIp); + } + } + + return retVal; +} + +unsigned char Ccov_RsspII::GetClientDevs(unsigned int* devs,int *devCnt) +{ + unsigned char retVal = 0; + int tempCnt; + int tempDevCnt = 0; + unsigned int devName; + EndPointConStatus_Stru tempEps[1024]; + DSU_IP_PORT tmpIpPort; + if (this->m_tcpSer!=NULL) + { + retVal = this->m_tcpSer->GetClientConInfo(tempEps,sizeof(tempEps)/sizeof(EndPointConStatus_Stru),&tempCnt); + if(0==retVal) + { + for (int i=0;im_tcpSer!=NULL) + { + dquEtcsId2DevName(etcsId, &devName, &logicId); + + GetNetEndPoint(devName, logicId, RSSP2_IDX, pIpInfos, &ipCnt); + for(int i=0;im_redOrBlue==BLUE_NET) + { + this->m_tcpSer->DeleteConnection(pIpInfos[i].blueIp); + } + else if(this->m_redOrBlue==RED_NET) + { + this->m_tcpSer->DeleteConnection(pIpInfos[i].redIp); + } + } + + WaitForSingleObject(this->m_parsersMutex,INFINITE); + + map::iterator item = this->m_mapParsers.find(etcsId); + + if(item!=this->m_mapParsers.end()) + {//˵Դ豸ݽѾ + item->second->Stop(); + delete item->second; + this->m_mapParsers.erase(etcsId); + } + + ReleaseMutex(this->m_parsersMutex); + } + else + { + retVal = 1; + } + return retVal; +} diff --git a/TSCP/src/main/ccov/Ccov_RsspII.h b/TSCP/src/main/ccov/Ccov_RsspII.h new file mode 100644 index 0000000..f3891d4 --- /dev/null +++ b/TSCP/src/main/ccov/Ccov_RsspII.h @@ -0,0 +1,31 @@ +#pragma once +#include +#include "Ccov_TcpSer.h" +#include "Ccov_RSSPII_Parser.h" +#include "..\\SimDef\SimDef.h" +#include +using namespace std; + +class Ccov_RsspII +{ +public: + Ccov_RsspII(void); + ~Ccov_RsspII(void); + unsigned char SetNetEndPoint(unsigned int ip, unsigned short port, unsigned char redOrBlue); + unsigned char Start(void); + int ReadData(unsigned char *outBuf, int maxRLen); + unsigned char Send(unsigned short dstDevId, unsigned short logicId, const unsigned char *sBuf, int sLen); + unsigned char DeleteConnection(unsigned int etcsId); + unsigned char GetClientDevs(unsigned int* devs, int *devCnt); +private: + unsigned char m_redOrBlue; + Ccov_TcpSer *m_tcpSer; + map m_mapParsers; + HANDLE m_parsersMutex; + unsigned char m_ipBytes[4]; + unsigned short m_port; + unsigned char m_rssp2FraBuf[10240]; + static void RecvManage(unsigned char *rBuf,int rLen,unsigned int srcIp,unsigned short srcPort,LPVOID pRcvHandler); + static void DelClientManage(unsigned int clientIp,unsigned short clientPort,LPVOID pRcvHandler); +}; + diff --git a/TSCP/src/main/ccov/Ccov_TcpCallBackDef.h b/TSCP/src/main/ccov/Ccov_TcpCallBackDef.h new file mode 100644 index 0000000..44c03c8 --- /dev/null +++ b/TSCP/src/main/ccov/Ccov_TcpCallBackDef.h @@ -0,0 +1,6 @@ +#pragma once + +//tcpյݴָ +typedef void (*TcpConnectionRecvHandler) (unsigned char *rBuf,int rLen,unsigned int srcIp,unsigned short srcPort,LPVOID pRcvHandler); +//tcpɾָ +typedef void (*ClientDelHandler) (unsigned int clientIp,unsigned short clientPort,LPVOID pRcvHandler); \ No newline at end of file diff --git a/TSCP/src/main/ccov/Ccov_TcpSer.cpp b/TSCP/src/main/ccov/Ccov_TcpSer.cpp new file mode 100644 index 0000000..157a092 --- /dev/null +++ b/TSCP/src/main/ccov/Ccov_TcpSer.cpp @@ -0,0 +1,197 @@ +#include "Ccov_TcpSer.h" + +#pragma comment(lib, "ws2_32.lib") + +void Ccov_TcpSer::Accept(LPVOID pParam) +{ + Ccov_TcpSer *pTcpSer = (Ccov_TcpSer *)pParam; + unsigned int ipUInt32; + unsigned short clientPort; + SOCKADDR_IN addrClient; + TcpConnection_Ser *pTcpCon; + TcpConnection_Ser *pExistTcpCon; + int len=sizeof(SOCKADDR); + SOCKET sockSrv = pTcpSer->m_sockSrv; + + while(1) + { + SOCKET sockConn=accept(sockSrv,(SOCKADDR*)&addrClient,&len); + + ipUInt32= addrClient.sin_addr.S_un.S_un_b.s_b1*256*256*256 + +addrClient.sin_addr.S_un.S_un_b.s_b2*256*256 + +addrClient.sin_addr.S_un.S_un_b.s_b3*256 + +addrClient.sin_addr.S_un.S_un_b.s_b4; + + WaitForSingleObject(pTcpSer->m_clientMapMutex,INFINITE); + pTcpSer->m_conId++; + clientPort = ntohs(addrClient.sin_port); + pTcpCon = new TcpConnection_Ser(sockConn,ipUInt32,clientPort,pTcpSer->m_conId); + map::iterator item = pTcpSer->m_mapClients.find(ipUInt32); + if(item!=pTcpSer->m_mapClients.end()) + {//˵ѾIPĿͻѾ + pExistTcpCon = item->second; + pExistTcpCon->Stop(); + delete pExistTcpCon; + + pTcpSer->m_mapClients.erase(ipUInt32); + printf_s("client con is removed,client ip is %lu\n",ipUInt32); + + /*ص֪ͨɾϲӦ*/ + if (pTcpSer->m_clientDelEvt!=NULL) + { + pTcpSer->m_clientDelEvt(ipUInt32,clientPort,pTcpSer->m_pClientDelHandler); + } + } + + pTcpSer->m_mapClients.insert(pair(ipUInt32, pTcpCon));//ӹmap + + pTcpCon->RegisterRecvCallBack(pTcpSer->m_recvEvt,pTcpSer->m_pRcvHandler); + pTcpCon->Start(); + + ReleaseMutex(pTcpSer->m_clientMapMutex); + } +} + +Ccov_TcpSer::Ccov_TcpSer(unsigned char *ipBuf,unsigned short serPort) +{ + int idx; + for(idx=0;idxm_ipBuf);idx++) + { + this->m_ipBuf[idx]=ipBuf[idx]; + } + + this->m_serPort = serPort; + this->m_clientMapMutex = CreateMutex(NULL,FALSE,NULL); + this->m_conId = 0; + this->m_recvEvt=NULL; + this->m_clientDelEvt=NULL; +} + + +Ccov_TcpSer::~Ccov_TcpSer(void) +{ +} + +void Ccov_TcpSer::RegisterRecvCallBack(TcpConnectionRecvHandler recvCallBack,LPVOID pRcvHandler) +{ + this->m_recvEvt = recvCallBack; + this->m_pRcvHandler=pRcvHandler; +} + +void Ccov_TcpSer::RegisterDelCallBack(ClientDelHandler delCallBack,LPVOID pRcvHandler) +{ + this->m_clientDelEvt = delCallBack; + this->m_pClientDelHandler = pRcvHandler; +} + +unsigned char Ccov_TcpSer::Start(void) +{ + WORD wVersionRequested; + WSADATA wsaData; + int err; + char ipStr[16];//IPַ + + wVersionRequested = MAKEWORD( 2, 2 ); + + err = WSAStartup( wVersionRequested, &wsaData ); + if ( err != 0 ) { + return 1; + } + + + if ( LOBYTE( wsaData.wVersion ) != 2 || + HIBYTE( wsaData.wVersion ) != 2 ) { + WSACleanup( ); + return 1; + } + SOCKET sockSrv=socket(AF_INET,SOCK_STREAM,0); + + sprintf_s(ipStr,"%d.%d.%d.%d",this->m_ipBuf[0],this->m_ipBuf[1],this->m_ipBuf[2],this->m_ipBuf[3]); + SOCKADDR_IN addrSrv; + addrSrv.sin_addr.S_un.S_addr=inet_addr(ipStr); + addrSrv.sin_family=AF_INET; + addrSrv.sin_port=htons(this->m_serPort); + + //õַãֹTIME_WAITʱ޷bind + BOOL bReuseaddr=TRUE; + setsockopt(sockSrv,SOL_SOCKET ,SO_REUSEADDR,(const char*)&bReuseaddr,sizeof(BOOL)); + + err=bind(sockSrv,(SOCKADDR*)&addrSrv,sizeof(SOCKADDR)); + if(0!=err) + { + return 1; + } + + err = listen(sockSrv,2147483647);//ɽ + if(0!=err) + { + return 1; + } + this->m_sockSrv=sockSrv; + //Accept߳ + this->m_acceptThr = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)(Ccov_TcpSer::Accept),this,0,&this->m_acceptThrId); + + return 0; +} + +unsigned char Ccov_TcpSer::Send(const unsigned char *sBuf,int sLen,unsigned int dstIp) +{ + unsigned char retVal =1; + WaitForSingleObject(this->m_clientMapMutex,INFINITE); + map::iterator item = this->m_mapClients.find(dstIp); + if(item!=this->m_mapClients.end()) + {//˵ѾIPĿͻѾ + retVal = item->second->Send(sBuf,sLen); + } + ReleaseMutex(this->m_clientMapMutex); + + return retVal; +} + +unsigned char Ccov_TcpSer::DeleteConnection(unsigned int clientIp) +{ + unsigned retVal = 0; + + WaitForSingleObject(this->m_clientMapMutex,INFINITE); + + map::iterator item = this->m_mapClients.find(clientIp); + if(item!=this->m_mapClients.end()) + {//˵ѾIPĿͻѾ + item->second->Stop(); + delete item->second; + this->m_mapClients.erase(clientIp); + } + + ReleaseMutex(this->m_clientMapMutex); + + return retVal; +} + +unsigned char Ccov_TcpSer::GetClientConInfo(EndPointConStatus_Stru *epConStaInfos,int maxClientCnt,int *epCnt) +{ + unsigned char retVal = 0; + int tempCnt = 0; + WaitForSingleObject(this->m_clientMapMutex,INFINITE); + map::iterator it; + for(it=this->m_mapClients.begin();it!=this->m_mapClients.end();it++) + { + if (1!=it->second->m_err) + { + if(tempCntsecond->m_clientIp; + epConStaInfos[tempCnt].port = it->second->m_clientPort; + epConStaInfos[tempCnt].status = CON_STA; + tempCnt++; + } + else + { + retVal = 1; + break; + } + } + } + ReleaseMutex(this->m_clientMapMutex); + *epCnt = tempCnt; + return retVal; +} \ No newline at end of file diff --git a/TSCP/src/main/ccov/Ccov_TcpSer.h b/TSCP/src/main/ccov/Ccov_TcpSer.h new file mode 100644 index 0000000..e5b269e --- /dev/null +++ b/TSCP/src/main/ccov/Ccov_TcpSer.h @@ -0,0 +1,39 @@ +#pragma once +#include "TcpConnection_Ser.h" +#include +#define WIN32_LEAN_AND_MEAN +#include +#include +#include "Ccov_TcpCallBackDef.h" +#include "EndPointConStatus.h" + +using namespace std; + +class Ccov_TcpSer +{ +public: + void RegisterRecvCallBack(TcpConnectionRecvHandler rcvCallBack,LPVOID pRcvHandler); + void RegisterDelCallBack(ClientDelHandler delCallBack,LPVOID pRcvHandler); + unsigned char Start(void); + unsigned char Send(const unsigned char *sBuf,int sLen,unsigned int dstIp); + unsigned char DeleteConnection(unsigned int clientIp); + unsigned char GetClientConInfo(EndPointConStatus_Stru *epConStaInfos,int maxClientCnt,int *epCnt); + + Ccov_TcpSer(unsigned char *ipBuf,unsigned short serPort); + ~Ccov_TcpSer(void); +private: + unsigned short m_serPort; + unsigned char m_ipBuf[4]; + SOCKET m_sockSrv; + map m_mapClients; + static void Accept(LPVOID pParam); + HANDLE m_acceptThr;//Accept߳̾ + DWORD m_acceptThrId; + HANDLE m_clientMapMutex; + TcpConnectionRecvHandler m_recvEvt; + ClientDelHandler m_clientDelEvt; + LPVOID m_pClientDelHandler; + LPVOID m_pRcvHandler; + unsigned int m_conId; +}; + diff --git a/TSCP/src/main/ccov/EndPointConStatus.h b/TSCP/src/main/ccov/EndPointConStatus.h new file mode 100644 index 0000000..18895f4 --- /dev/null +++ b/TSCP/src/main/ccov/EndPointConStatus.h @@ -0,0 +1,14 @@ +#ifndef EndPointConStatus_H +#define EndPointConStatus_H + +#define CON_STA 1 +#define NO_CON_STA 0 + +typedef struct +{ + unsigned int ip; + unsigned short port; + unsigned char status; +}EndPointConStatus_Stru; + +#endif \ No newline at end of file diff --git a/TSCP/src/main/ccov/TcpConnection_Ser.cpp b/TSCP/src/main/ccov/TcpConnection_Ser.cpp new file mode 100644 index 0000000..e1a7476 --- /dev/null +++ b/TSCP/src/main/ccov/TcpConnection_Ser.cpp @@ -0,0 +1,119 @@ +#include "TcpConnection_Ser.h" +#include "stdio.h" +#include "windows.h" + +extern "C" INT8 debug_infor_printf( + char* debug_string, /*ʵCеprintfĹ,ƽ̨ĵӡ*/ + ...); + +TcpConnection_Ser::TcpConnection_Ser(SOCKET connectionSocket,unsigned int clientIp,unsigned short clientPort,unsigned int conId) +{ + this->m_socket = connectionSocket; + this->m_clientIp = clientIp; + this->m_clientPort = clientPort; + this->ConnectionId = conId; + this->m_toRun=0; + this->m_recvEvt=NULL; + this->m_recvThr=NULL; + this->m_err = 0; + this->m_rcving=0; +} + + +TcpConnection_Ser::~TcpConnection_Ser(void) +{ + +} + +void TcpConnection_Ser::BlockRecv(LPVOID pParam) +{ + TcpConnection_Ser *tcpCon = (TcpConnection_Ser *)pParam; + unsigned char recvBuf[1024]; + int recvLen; + + while (tcpCon->m_toRun) + { + recvLen = recv(tcpCon->m_socket,(char*)recvBuf,sizeof(recvBuf),0); + if(recvLen<=0) + {//˵һѾرTCP + closesocket(tcpCon->m_socket); + tcpCon->m_err = 1; + printf_s("con recv err,to exit,client ip is %lu,client port is %lu\n",tcpCon->m_clientIp,tcpCon->m_clientPort); + break; + } + else + { + debug_infor_printf("con data arrive time is %lu\n",GetTickCount()); + if(tcpCon->m_recvEvt!=NULL) + { + tcpCon->m_recvEvt(recvBuf,recvLen,tcpCon->m_clientIp,tcpCon->m_clientPort,tcpCon->m_pRcvHandler); + } + printf_s("recvLen is %d\n",recvLen); + } + Sleep(0); + } + + tcpCon->m_rcving=0; +} + +void TcpConnection_Ser::Start(void) +{ + this->m_toRun = 1; + //Accept߳ + this->m_rcving = 1; + this->m_recvThr = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)(TcpConnection_Ser::BlockRecv),this,0,&this->m_recvThrId); +} + +unsigned char TcpConnection_Ser::GetConnectionErr(void) +{ + return this->m_err; +} + +void TcpConnection_Ser::Stop(void) +{ + this->m_toRun = 0; + closesocket(this->m_socket); + + if(this->m_recvThr!=NULL) + { + while(this->m_rcving) + { + /*ȴ߳̽*/ + } + CloseHandle(this->m_recvThr); + printf_s("rcv thread ended,thread id is %lu\n",this->m_recvThrId); + } +} + +unsigned char TcpConnection_Ser::Send(const unsigned char* sBuf,int sLen) +{ + if(0==sLen) + { + return 0;//ûҪͣΪͳɹ + } + else + { + debug_infor_printf("send time is %lu\n",GetTickCount()); + } + int tempSLen = send(this->m_socket,(char*)sBuf,sLen,0); + + if(tempSLen<=0) + { + closesocket(this->m_socket); + this->m_err = 1; + printf_s("con send err,client ip is %lu,client port is %lu\n",this->m_clientIp,this->m_clientPort); + + return 1;//ݷͣʵûݱͻΪʧ + } + else + { + + } + return 0; +} + +void TcpConnection_Ser::RegisterRecvCallBack(TcpConnectionRecvHandler rcvCallBack,LPVOID pRcvHandler) +{ + this->m_recvEvt = rcvCallBack; + this->m_pRcvHandler = pRcvHandler; +} diff --git a/TSCP/src/main/ccov/TcpConnection_Ser.h b/TSCP/src/main/ccov/TcpConnection_Ser.h new file mode 100644 index 0000000..85600f9 --- /dev/null +++ b/TSCP/src/main/ccov/TcpConnection_Ser.h @@ -0,0 +1,34 @@ +#pragma once + +#include +#include "Ccov_TcpCallBackDef.h" +#include "windows.h" + +class TcpConnection_Ser +{ +public: + void RegisterRecvCallBack(TcpConnectionRecvHandler rcvCallBack,LPVOID pRcvHandler); + void Start(void); + void Stop(void); + unsigned char Send(const unsigned char* sBuf,int sLen); + TcpConnection_Ser(SOCKET connectionSocket,UINT32 clientIp,UINT16 clientPort,UINT32 conId); + ~TcpConnection_Ser(void); + + unsigned int ConnectionId; + unsigned char GetConnectionErr(void); + unsigned int m_clientIp; + unsigned short m_clientPort; + unsigned char m_err; +private: + SOCKET m_socket;//ӶӦSOCKET + + TcpConnectionRecvHandler m_recvEvt;//ݽ¼ + LPVOID m_pRcvHandler; + LPVOID m_pExpHandler;//쳣ʵ + HANDLE m_recvThr; + DWORD m_recvThrId; + static void BlockRecv(LPVOID pParam); + unsigned char m_toRun; + unsigned char m_rcving; +}; + diff --git a/TSCP/src/main/ccov/ccov.cpp b/TSCP/src/main/ccov/ccov.cpp new file mode 100644 index 0000000..e2a9a56 --- /dev/null +++ b/TSCP/src/main/ccov/ccov.cpp @@ -0,0 +1,420 @@ +// Comm.cpp: implementation of the CComm class. +// +////////////////////////////////////////////////////////////////////// + +//#include "SimManagerDlg.h" +#include "ccov.h" +#include "Convert.h" +#include "CommonMemory.h" +#include "dsuProtclFun.h" +#include "dsuRssp2DataStru.h" +#include "dsuRssp2Func.h" +#include "..\\DeviceInfoManager\\readxmltodata.h"/**/ +#pragma comment (lib,"ws2_32.lib") + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +INT32 RcvData(LPVOID pParam); + +CComm::CComm() +{ + QueueInitial(&_rcvDataQueue,RCV_BUFF_SIZE*sizeof(UINT8)*1); + _dwRcvThread = NULL; + //_prcvDataBuff = (CHAR*)malloc(RCV_BUFF_SIZE*sizeof(INT8)); + hSemaphore = CreateSemaphore(NULL,1,1,NULL); +} + +CComm::~CComm() +{ + +} + + +UINT8 CComm::Send(CHAR *Msg, INT32 Len, CHAR *host, UINT16 port) +{ + signed int Sent; + + sockaddr_in dest; // Ŀַ + dest.sin_family = PF_INET; + dest.sin_addr.S_un.S_addr = inet_addr( host ); + dest.sin_port = htons( port ); +// TRACE("ϢѾ͵ %s ˿Ϊ %i\n", inet_ntoa(dest.sin_addr), ntohs(dest.sin_port)); + //ݷ + Sent = sendto(ListenSocket, Msg, Len, 0, (sockaddr *)&dest, sizeof(sockaddr_in)); + if ( Sent != Len ) + { +// TRACE("UDPϢ\n"); +// fflush(0); + return 0; + } + + return 1; + +} + +UINT8 CComm::Bind(UINT16 Port,CHAR *ServerIP) +{ + if ( ListenSocket == INVALID_SOCKET ) + { +// TRACE("Error: socketʧ\n"); +// fflush(0); + return 1; + } + + srv.sin_family = PF_INET; + srv.sin_addr.s_addr = inet_addr(ServerIP);//htonl( INADDR_ANY ); // κεַ + srv.sin_port = htons( Port ); + + if ( bind( ListenSocket, (struct sockaddr *)&srv, sizeof(srv)) != 0 ) + { +// TRACE("%d\n",WSAGetLastError()); +// TRACE("Error: ʧ\n"); +// fflush(0); + closesocket( ListenSocket ); + ListenSocket = INVALID_SOCKET; + return 2; + } + return 0; +} + +UINT8 CComm::Init_Comm() +{ + WSADATA wsaData; + unsigned long dwFlag = 0; /* */ + //캯 + ListenSocket = INVALID_SOCKET; // ʼΪINVALID_SOCKET + +#ifdef _WIN32 // win32ϵͳ + if( WSAStartup( MAKEWORD(2,2),&wsaData) != 0 ) + { +// TRACE("WSAStartup() failed\n"); + return 1; + } + if((ListenSocket=WSASocket(AF_INET,SOCK_DGRAM,0,NULL,0, + WSA_FLAG_MULTIPOINT_C_LEAF|WSA_FLAG_MULTIPOINT_D_LEAF| + WSA_FLAG_OVERLAPPED)) == INVALID_SOCKET) + { +// TRACE("socket failed with:%d\n",WSAGetLastError()); + WSACleanup(); + return 2; + } + + if(ioctlsocket(ListenSocket,FIONBIO,&dwFlag) == SOCKET_ERROR) + { + return 3; + } +#endif + return 0; +} + +UINT8 CComm::Release() +{ + if(_dwRcvThread != NULL) /* ߳ر*/ + { + TerminateThread(_hRcvThread,_dwRcvThread); + _dwRcvThread =0; + } + + if ( ListenSocket != INVALID_SOCKET ) + { + closesocket( ListenSocket ); // Ѿر + ListenSocket= INVALID_SOCKET; + } + + QueueElementFree(&_rcvDataQueue); + + return 1; +} + +/* + * ܽ + */ +UINT8 CComm::StartRcv() +{ + _hRcvThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)RcvData,(LPVOID)this,0,&_dwRcvThread); + SetThreadPriority(_hRcvThread,THREAD_PRIORITY_HIGHEST); + return 0; +} + +/* + * ȡһ֡ + * + * dataLen ݳ + * data ݣ+ + * ֵ + * 0 + * 1 + */ +UINT8 CComm::ReadData(UINT16 *dataLen,UINT8 *data) +{ + UINT8 ret =0; + UINT8 data_len_byte[2] ={0}; + QueueStruct *pQue = &_rcvDataQueue; + WaitForSingleObject(hSemaphore,INFINITE); /* дź */ + if(QueueStatus(pQue)>2) + { + ret = QueueScan(2,data_len_byte,pQue); + *dataLen = ShortFromChar(data_len_byte)+2; + + ret = QueueRead(*dataLen,data,pQue); + if(ret == 0) + { + QueueClear(pQue); + } + + } + ReleaseSemaphore(hSemaphore,1,NULL); /* ͷдź */ + return ret; +} + + +UINT8 CComm::RcvThread() +{ + INT32 len_of_socket = 0; /* socket*/ + INT32 rcv_data_len = 0; /* ݳ */ + UINT8 len_byte[2] = {0}; + len_of_socket = sizeof(client); + + while(1) /* */ + { + rcv_data_len = recvfrom(ListenSocket,_prcvDataBuff, RCV_BUFF_SIZE,0,(sockaddr *)&client,(int *)&len_of_socket); + if(rcv_data_len>0) /* ܵ */ + { + ShortToChar(rcv_data_len,len_byte); + WaitForSingleObject(hSemaphore,INFINITE); /* дź */ + QueueWrite(2,len_byte,&_rcvDataQueue); + QueueWrite(rcv_data_len,(UINT8 *)_prcvDataBuff,&_rcvDataQueue); + ReleaseSemaphore(hSemaphore,1,NULL); /* ͷдź */ + } + /*Sleep(1);*/ + } + + return 1; +} + +/* + * ̴ܽ + */ +INT32 RcvData(LPVOID pParam) +{ + UINT8 ret = 0; + CComm *pCCov = (CComm*)pParam; + + ret = pCCov->RcvThread(); + return ret; +} + +/* +* д̴ܽ +*/ +UINT8 CbtcCcomm::RcvThread() +{ + INT32 len_of_socket = 0; /* socket*/ + INT32 rcv_data_len = 0; /* ݳ */ + UINT8 len_byte[2] = {0}; + len_of_socket = sizeof(client); + UINT16 devName = 0; + UINT8 tempframeBuf[10000] = {0};/*ʱ*/ + UINT8 ip[4] = {0}; + UINT16 port = {0}; + UINT8 ret = 0; + DSU_IP_PORT ipPort; + UINT16 logId = 0; + UINT32 etcsId = 0; + UINT8 devType = 0; + UINT16 t_OffSet = 0; + UINT32 t_Ip = 0; + UINT16 t_Port = 0; + UINT16 t_Len = 0; + UINT16 sourceID = 0u; + UINT16 dstID = 0u; + + while(1) /* */ + { + t_OffSet = 0U; + CommonMemSet(tempframeBuf,10000,0,10000);/*0*/ + rcv_data_len = recvfrom(ListenSocket,_prcvDataBuff, RCV_BUFF_SIZE,0,(sockaddr *)&client,(int *)&len_of_socket); + + if(rcv_data_len>0) /* ܵ */ + { + LongToCharLE(client.sin_addr.S_un.S_addr,ip); + port = ShortFromChar((UINT8 *)&client.sin_port); + + ipPort.Ip[0] = ip[0]; + ipPort.Ip[1] = ip[1]; + ipPort.Ip[2] = ip[2]; + ipPort.Ip[3] = ip[3]; + + ipPort.Port = port; + + etcsId = 0; + + ret = dquGetEtcsIdByIpPort(ipPort, &etcsId); + + logId = 0; + devName = 0; + + if(1 == ret) + { + ret = dquEtcsId2DevName(etcsId, &devName, &logId); + + if(1 == ret) + { + ret = 1; + } + else + { + ret = 0; + } + } + else + { + ret = GetDeviceNameByIpAndPort(port, LongFromChar(ip), &devName,&logId); + + if(0 == ret) + { + ret = 1; + } + else + { + ret = 0; + } + } + + if(1 == ret) + { + devType = (devName >> 8); + + if (0x18 == devType)/* */ + { + t_OffSet += 1; /* ʼʶ */ + t_Len = ShortFromChar((const UINT8*)&_prcvDataBuff[t_OffSet]);/* */ + t_OffSet += 2; + t_OffSet += 1; /* */ + t_OffSet += 8; /* ʱ */ + + t_Ip = LongFromChar((const UINT8*)&_prcvDataBuff[t_OffSet]); /* Ip */ + t_OffSet += 4; + + t_Port = ShortFromChar((const UINT8*)&_prcvDataBuff[t_OffSet]);/* Port */ + t_OffSet += 2; + + t_OffSet += 4; /* OCIp */ + t_OffSet += 2; /* OCPort */ + + ret = GetDeviceNameByIpAndPort(t_Port, t_Ip, &devName, &logId);/* ȡIDͷβ */ + + if (0 == ret)/* ɹ */ + { + ShortToChar((rcv_data_len - (t_OffSet + 1) + 4), &tempframeBuf[0]);/**/ + ShortToChar(devName, &tempframeBuf[2]);/*+ID*/ + ShortToChar(logId, &tempframeBuf[4]);/*߼ID*/ + + CommonMemCpy(&tempframeBuf[6], 9994, (UINT8 *)&_prcvDataBuff[t_OffSet], (rcv_data_len - (t_OffSet + 1))); + + WaitForSingleObject(hSemaphore, INFINITE); /* дź */ + QueueWrite((rcv_data_len - (t_OffSet + 1) + 6), (UINT8 *)tempframeBuf, &_rcvDataQueue); + ReleaseSemaphore(hSemaphore, 1, NULL); /* ͷдź */ + } + else/* ʧ */ + { + ret = 0; + } + } + else if (0x7d == devType) + { + /* CI_SYSTEM_TYPE_ATS_INTERFACE = 0x7d ATSͺģʽ*/ + t_Len = ShortFromChar((const UINT8*)&_prcvDataBuff[t_OffSet]);/* */ + t_OffSet += 2u; + + t_OffSet += 4u; /* к */ + + sourceID = ShortFromChar((const UINT8*)&_prcvDataBuff[t_OffSet]); /* ԴID */ + t_OffSet += 2u; /*ģʽʵϵVOBCID*/ + logId = ShortFromChar((const UINT8*)&_prcvDataBuff[t_OffSet]); /* ԴID */ + t_OffSet += 2u; /*ģʽʵϵ߼*/ + dstID = ShortFromChar((const UINT8*)&_prcvDataBuff[t_OffSet]);/* ĿID */ + t_OffSet += 2u; + t_OffSet += 2u; + + + ShortToChar((rcv_data_len - t_OffSet + 4u), &tempframeBuf[0]);/**/ + ShortToChar(sourceID, &tempframeBuf[2]);/*+ID*/ + ShortToChar(logId, &tempframeBuf[4]);/*߼ID*/ + + CommonMemCpy(&tempframeBuf[6], 9994, (UINT8 *)&_prcvDataBuff[t_OffSet], (rcv_data_len - t_OffSet )); + + WaitForSingleObject(hSemaphore, INFINITE); /* дź */ + QueueWrite((rcv_data_len - t_OffSet + 6u), (UINT8 *)tempframeBuf, &_rcvDataQueue); + ReleaseSemaphore(hSemaphore, 1, NULL); /* ͷдź */ + } + else + { + ShortToChar(rcv_data_len + 4, &tempframeBuf[0]);/**/ + ShortToChar(devName, &tempframeBuf[2]);/*+ID*/ + ShortToChar(logId, &tempframeBuf[4]);/*߼ID*/ + + CommonMemCpy(&tempframeBuf[6], 10000 - 6, (UINT8 *)_prcvDataBuff, rcv_data_len); + + WaitForSingleObject(hSemaphore, INFINITE); /* дź */ + QueueWrite(rcv_data_len + 6, (UINT8 *)tempframeBuf, &_rcvDataQueue); + ReleaseSemaphore(hSemaphore, 1, NULL); /* ͷдź */ + } + } + } + /*Sleep(1);*/ + } + + return 1; +} + +/* +* д̴ܽ +*/ +UINT8 LeuCcomm::RcvThread() +{ + INT32 len_of_socket = 0; /* socket*/ + INT32 rcv_data_len = 0; /* ݳ */ + UINT8 len_byte[2] = {0}; + len_of_socket = sizeof(client); + UINT16 devName=0; + UINT8 tempframeBuf[10000]={0};/*ʱ*/ + UINT8 ip[4] = {0}; + UINT16 port = {0}; + UINT8 ret = 0; + + while(1) /* */ + { + CommonMemSet(tempframeBuf, 10000, 0, 10000);/*0*/ + rcv_data_len = recvfrom(ListenSocket,_prcvDataBuff, RCV_BUFF_SIZE,0,(sockaddr *)&client,(int *)&len_of_socket); + + if(rcv_data_len>0) /* ܵ */ + { + LongToCharLE(client.sin_addr.S_un.S_addr,ip); + port = ShortFromChar((UINT8 *)&client.sin_port); + ret = GetDeviceNameByIpAndPortLEU(port,LongFromChar(ip),&devName);/*20160523޸*/ + if( ret == 0) + { + ShortToChar(rcv_data_len+4,&tempframeBuf[0]);/**/ + ShortToChar(devName,&tempframeBuf[2]);/*+ID*/ + CommonMemCpy(&tempframeBuf[6],(10000-6),(UINT8 *)_prcvDataBuff,rcv_data_len); + + WaitForSingleObject(hSemaphore,INFINITE); /* дź */ + QueueWrite(rcv_data_len+6,(UINT8 *)tempframeBuf,&_rcvDataQueue); + ReleaseSemaphore(hSemaphore,1,NULL); /* ͷдź */ + } + } + /*Sleep(1);*/ + } + + return 1; +} diff --git a/TSCP/src/main/ccov/ccov.h b/TSCP/src/main/ccov/ccov.h new file mode 100644 index 0000000..0b91c39 --- /dev/null +++ b/TSCP/src/main/ccov/ccov.h @@ -0,0 +1,58 @@ +/* +* +* ļ SfpPrtcl.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.06.1 +* ¥Ϊ +* ͨЭԼͨſ +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +* 1 2009/11/03 ¥ΰ װSFPЭԼͨſ +* +*/ +#ifndef __CCOV_H_ +#define __CCOV_H_ +#include "CommonTypes.h" +#include "CommonQueue.h" +#include +#include + +const INT32 RCV_BUFF_SIZE = (INT32)1024*1024; + +class CComm +{ +public: + UINT8 Release(); + UINT8 Init_Comm(); + UINT8 Send(CHAR *Msg, INT32 Len, CHAR *host, UINT16 port); + UINT8 Bind(UINT16 Port,CHAR *ServerIP); + UINT8 StartRcv(); + UINT8 ReadData(UINT16 *dataLen,UINT8 *data); + virtual UINT8 RcvThread(); + CComm(); + virtual ~CComm(); + +protected: + + sockaddr_in client; /* ܵsockaddr_in */ + sockaddr_in srv; /* */ + SOCKET ListenSocket; + QueueStruct _rcvDataQueue; + HANDLE _hRcvThread; /* ܽ̾ */ + unsigned long _dwRcvThread; /* ̿ʼ־ */ + CHAR _prcvDataBuff[RCV_BUFF_SIZE]; + HANDLE hSemaphore; +}; + +class CbtcCcomm:public CComm +{ + virtual UINT8 RcvThread(); +}; +class LeuCcomm:public CComm +{ + virtual UINT8 RcvThread(); +}; +#endif \ No newline at end of file diff --git a/TSCP/src/main/commLib/CRC32long.c b/TSCP/src/main/commLib/CRC32long.c new file mode 100644 index 0000000..af82405 --- /dev/null +++ b/TSCP/src/main/commLib/CRC32long.c @@ -0,0 +1,71 @@ + +/************************************************************************ +* ļCRC32.c +* ļ32λCRC +* ʱ䣺2008.07.29 +************************************************************************/ +#include "CRC32long.h" +/*CRCغ*/ +/*ɶʽ*/ +/*POLY:0x4c11db7L; */ +const unsigned long crcTablelong[256] = { +0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,0x130476dc,0x17c56b6b, +0x1a864db2,0x1e475005,0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61, +0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd,0x4c11db70,0x48d0c6c7, +0x4593e01e,0x4152fda9,0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, +0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,0x791d4014,0x7ddc5da3, +0x709f7b7a,0x745e66cd,0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039, +0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5,0xbe2b5b58,0xbaea46ef, +0xb7a96036,0xb3687d81,0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, +0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,0xc7361b4c,0xc3f706fb, +0xceb42022,0xca753d95,0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1, +0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d,0x34867077,0x30476dc0, +0x3d044b19,0x39c556ae,0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, +0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,0x018aeb13,0x054bf6a4, +0x0808d07d,0x0cc9cdca,0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde, +0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02,0x5e9f46bf,0x5a5e5b08, +0x571d7dd1,0x53dc6066,0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, +0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,0xbfa1b04b,0xbb60adfc, +0xb6238b25,0xb2e29692,0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6, +0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a,0xe0b41de7,0xe4750050, +0xe9362689,0xedf73b3e,0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, +0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,0xd5b88683,0xd1799b34, +0xdc3abded,0xd8fba05a,0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637, +0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb,0x4f040d56,0x4bc510e1, +0x46863638,0x42472b8f,0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, +0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,0x36194d42,0x32d850f5, +0x3f9b762c,0x3b5a6b9b,0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff, +0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623,0xf12f560e,0xf5ee4bb9, +0xf8ad6d60,0xfc6c70d7,0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, +0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,0xc423cd6a,0xc0e2d0dd, +0xcda1f604,0xc960ebb3,0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7, +0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b,0x9b3660c6,0x9ff77d71, +0x92b45ba8,0x9675461f,0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, +0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,0x4e8ee645,0x4a4ffbf2, +0x470cdd2b,0x43cdc09c,0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8, +0x68860bfd,0x6c47164a,0x61043093,0x65c52d24,0x119b4be9,0x155a565e, +0x18197087,0x1cd86d30,0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, +0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,0x2497d08d,0x2056cd3a, +0x2d15ebe3,0x29d4f654,0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0, +0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c,0xe3a1cbc1,0xe760d676, +0xea23f0af,0xeee2ed18,0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, +0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,0x9abc8bd5,0x9e7d9662, +0x933eb0bb,0x97ffad0c,0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668, +0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4 +}; + +/*£ע⣺CRCǴݵһֽڵBITʼ*/ +/* data ָ*/ +/*length ݳȣֽڣ*/ +/* ֵΪCRCֵ*/ +unsigned long Crc32long(unsigned char * data,unsigned long length) +{ + unsigned long i; + unsigned long crc ; + i = 0; + crc = 0; + while( i < length ) + { crc = (crc<<8) ^ crcTablelong[ (crc>>24) ^ data[i++] ] ; } + return crc; +} + diff --git a/TSCP/src/main/commLib/CRC32long.h b/TSCP/src/main/commLib/CRC32long.h new file mode 100644 index 0000000..5e2ae20 --- /dev/null +++ b/TSCP/src/main/commLib/CRC32long.h @@ -0,0 +1,18 @@ + +/************************************************************************ +* ļCRC32.h +* ļ32λCRCͷļ +* ʱ䣺2008.07.29 +************************************************************************/ +#ifndef _CRC32long_H_ +#define _CRC32long_H_ + +/*#define Crc Crc32long*/ +/*£ע⣺CRCǴݵһֽڵBITʼ*/ +/* data ָ*/ +/*length ݳȣֽڣ*/ +/* ֵΪCRCֵ*/ +unsigned long Crc32long(unsigned char * data,unsigned long length); + +#endif + diff --git a/TSCP/src/main/ini/ReadCcovConfigInfo.cpp b/TSCP/src/main/ini/ReadCcovConfigInfo.cpp new file mode 100644 index 0000000..f42b2e7 --- /dev/null +++ b/TSCP/src/main/ini/ReadCcovConfigInfo.cpp @@ -0,0 +1,71 @@ +#include "ReadCcovConfigInfo.h" +#include +#include +#include "stdlib.h" + +IpInfoStr * ReadIpInfoFromIni(char *strTree,const CHAR *iniFileName); + + +IpConfigInfoStru *ReadConfigInfoByKey(char *key,const CHAR *iniFileName) +{ + /* ȡLocalInfoConfig.iniļ */ + CHAR strTree[50],strLeaf[50]; + CHAR tmpBuff[100]; + INT32 iReadLen = 0; + IpConfigInfoStru *ipConfigInfo = new IpConfigInfoStru(); + + strcpy(ipConfigInfo->name,key); + /* ȡ */ + sprintf(strTree, "%s",key); + ipConfigInfo->localIpIno = ReadIpInfoFromIni(strTree,iniFileName); + + /* ȡ */ + sprintf(strTree, "%s",key); + ipConfigInfo->dstIpInfo = ReadIpInfoFromIni(strTree,iniFileName); + + return ipConfigInfo; +} + +IpInfoStr * ReadIpInfoFromIni(char *strTree,const CHAR *iniFileName) +{ + + /* ȡLocalInfoConfig.iniļ */ + CHAR strLeaf[50]; + CHAR tmpBuff[100]; + INT32 iReadLen = 0; + + /* ҶΪ */ + sprintf(strLeaf,"IP"); + iReadLen = GetPrivateProfileStringA(strTree,strLeaf,NULL,tmpBuff,50,iniFileName); + tmpBuff[iReadLen] = 0; + IpInfoStr *ipInfo = new IpInfoStr(); + strcpy(ipInfo->ip,tmpBuff); + + sprintf(strLeaf,"PORT"); + iReadLen = GetPrivateProfileStringA(strTree,strLeaf,NULL,tmpBuff,50,iniFileName); + tmpBuff[iReadLen] = 0; + ipInfo->port = atoi(tmpBuff); + + return ipInfo; +} + +void ReleaseConfigInfo(IpConfigInfoStru *pIpInfo) +{ + if (NULL != pIpInfo) + { + if (NULL != pIpInfo->dstIpInfo) + { + delete pIpInfo->dstIpInfo; + pIpInfo->dstIpInfo = NULL; + } + + if (NULL != pIpInfo->localIpIno) + { + delete pIpInfo->localIpIno; + pIpInfo->localIpIno = NULL; + } + + delete pIpInfo; + } + +} \ No newline at end of file diff --git a/TSCP/src/main/ini/ReadCcovConfigInfo.h b/TSCP/src/main/ini/ReadCcovConfigInfo.h new file mode 100644 index 0000000..6f3495d --- /dev/null +++ b/TSCP/src/main/ini/ReadCcovConfigInfo.h @@ -0,0 +1,31 @@ +#ifndef _READCCOVCONFIGINFO_H_ +#define _READCCOVCONFIGINFO_H_ +#include "CommonTypes.h" + +typedef struct +{ + CHAR ip[20]; + UINT16 port; +}IpInfoStr; + +typedef struct +{ + CHAR name[50]; + IpInfoStr *localIpIno; + IpInfoStr *dstIpInfo; +}IpConfigInfoStru; + +#ifdef __cplusplus +extern "C" { +#endif + +IpConfigInfoStru *ReadConfigInfoByKey(char *key,const CHAR *iniFileName); + + +void ReleaseConfigInfo(IpConfigInfoStru *pIpInfo); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbDataStru.h b/TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbDataStru.h new file mode 100644 index 0000000..893e677 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbDataStru.h @@ -0,0 +1,124 @@ +/******************************************************************************* +* +* ļ dsuFsfbDataStru.h +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* FSFBЭصdsuѯṹ嶨壬ڲʹ +* ʹע⣺ +* ޸ļ¼ +** 2013.02.15 ɾDSU_FSFB_LNK_INFO_STRUDSU_FSFB_LNK_INFO_STRU +** 2013.02.15 ɾDSU_FSFB_INFO_STRUDSU_FSFB_INFO_STRU +*******************************************************************************/ +#ifndef _DSU_FSFB_DATA_STRU_H +#define _DSU_FSFB_DATA_STRU_H + +#include "CommonTypes.h" + + +/*󳤶ڴ洢ݿ*/ +#define DSUFSFB_MAX_FSFB_INFO_NUM 250 /*ݿ ֵ*/ +#define DSUFSFB_MAX_K_NUM 31 /*ݿɢֵ*/ +#define MAX_PLATFORM_PER_CI 7 /*CIplatform*/ + +#define DSU_FSFB_LNK_INFO_STRU_SIZE (DSUFSFB_MAX_K_NUM*8+34) /*FSFB lnk Ϣṹ峤*/ +#define DSU_CI_PLATFORM_INFO_STRU_SIZE (MAX_PLATFORM_PER_CI+2) /*ƽ̨ݽṹ峤*/ +#define DSU_DEVICE_COMM_INFO_STRU_SIZE 11 +#define DSU_IPADDR_LEN 4 /* IPַ */ +#define DSU_IP_INFO_STRU_SIZE 30 +#define DSU_COM_PROTCL_STRU_SIZE 3 + +#ifdef __cplusplus +extern "C" { +#endif +/*½ṹ嶨dsuݿеݴ洢ⷢ*/ +typedef struct +{ + UINT16 devName; /* 豸 */ + UINT32 HlhtId; /*ͨID*/ + UINT8 IPAddrBlue[DSU_IPADDR_LEN]; /* IP */ + UINT8 IPAddrRed[DSU_IPADDR_LEN]; /* IP */ + UINT16 SfpBluePort; /* SFP˿ں*/ + UINT16 SfpRedPort; /* SFP˿ں*/ + UINT16 RpBluePort; /* Rp˿ں*/ + UINT16 RpRedPort; /* Rp˿ں*/ + UINT16 RsrAndRsspBluePort; /* RSRRSSP˿ں*/ + UINT16 RsrAndRsspRedPort; /* RSRRSSP˿ں*/ + /*UINT16 FsfbBluePort; /* FSFB˿ں*/ + /*UINT16 FsfbRedPort; /* FSFB˿ں*/ + UINT16 SourceBluePort; /*Դ˿ں*/ + UINT16 SourceRedPort; /*Դ˿ں*/ +}DSU_FSFB_IP_INFO_STRU; + +/*豸ͨŹϵ*/ +typedef struct +{ + UINT8 EmitterType; /* */ + UINT8 ReceptorType;/* շ */ + UINT8 CommType; /* ͨЭ SFP1 RP 2 RSR 3 RSSP 4 FSFB 5 */ +}DSU_COM_PROTCL_STRU; + +/*FSFB lnk Ϣṹ*/ +typedef struct +{ + UINT16 Id; + UINT16 EmitterName; /*豸ʶ */ + UINT16 ReceptorName; /*豸ʶ */ + UINT8 ApplyCat; /* Ϣ */ + UINT16 ChannelNumber; /*ͨ*/ + UINT32 SID_NUMBER_E; /* ݿ⣬ֵΪͷSID*/ + UINT32 SINIT_NUMBER; /* ݿ*/ + UINT8 DATANUM; /*ݿ*/ + UINT32 DATAVER_1_Number; /*ݿ*/ + UINT16 srcAddr; /*FSFB_Source_Address*/ + UINT16 destAddr; /*BSD_Destination_Address*/ + UINT32 SID_NUMBER_R; /* ݿ⣬ֵΪܷSID*/ + UINT32 PREC_FIRSTSINIT ; /*ʾ׸SINIT*/ + UINT32 PREC_SINIT_K[DSUFSFB_MAX_K_NUM]; /*ʾSINITֵ*/ + UINT32 POST_RXDADA_K[DSUFSFB_MAX_K_NUM];/*ʾBSD̶ֵ*/ + +}DSU_FSFB_LNK_INFO_STRU; + + +/*豸ͨԱ*/ +typedef struct +{ + UINT16 EmitterType; /*豸*/ + UINT16 ReceptorType; /*豸*/ + UINT8 MaxLost; /*LOST*/ + UINT8 DLost; /*ʱ*/ + UINT8 WSsrOut; /*ȴSSRʱ*/ + UINT8 AntiDelayCount; /*ͬ*/ + UINT8 TOut; /*ijʱ*/ + UINT8 MsgId; /*ʾϢID뱨ķء*/ + UINT8 IftVer; /*ʾӿڰ汾ţ뱨ķ*/ +}DSU_DEVICE_COMM_INFO_STRU; + +typedef struct +{ + /* IPַͶ˿ںϢݳȺ */ + UINT16 IpInfoStruLen; + DSU_FSFB_IP_INFO_STRU* pIpInfoStru; + + /* 豸ͨŹϵ*/ + UINT16 ComProtclStruLen; + DSU_COM_PROTCL_STRU* pComProtclStr; + + /*FSFBLnkϢݳȺ*/ + UINT16 fsfbInfoStruLen; + DSU_FSFB_LNK_INFO_STRU *pfsfbLnkInfoStru; + + /*ͨŹϵṹ*/ + UINT16 DeviceCommStruLen; + DSU_DEVICE_COMM_INFO_STRU* pDevCommInfoStru; + +}DSU_FSFB_INFO_STRU; + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbFunc.c b/TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbFunc.c new file mode 100644 index 0000000..6fcd4d3 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_dqu_fsfb/dsuFsfbFunc.c @@ -0,0 +1,865 @@ +/******************************************************************************* +* +* ļ dsuFsfbFunc.c +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* FSFBЭصdsuѯ +* ʹע⣺ +* ޸ļ¼ +*******************************************************************************/ +#include "string.h" +#include "dsuFsfbFunc.h" +#include "dsuFsfbDataStru.h" +#include "dfsDataRead.h" +#include "dquDataTypeDefine.h" +#include "Convert.h" + + +#define DSU_SSTY_INDEX 0 +#define DSU_SSID_INDEX 1 + +DSU_FSFB_INFO_STRU dsuFsfbInfoStru; /*ڱFsfbϢĽṹ*/ +DSU_FSFB_INFO_STRU* pDsuFsfbInfoStru; /*ǰڲݿ.*/ + +/* +* 豸ͲѯͨϢ +* UINT8 localType, 豸 +* UINT8 DestType, Ŀ豸 +* DSU_FSFB_LINK_RINFO_STRU* pFSFBLnkRInfo,UINT8 localType, UINT8 DestType +* ֵ1ɹ0ʧ +*/ +UINT8 dsuFsfbSetCommInfo(DSU_FSFB_LINK_RINFO_STRU* pFSFBLnkRInfo,UINT8 localType, UINT8 DestType) +{ + UINT16 i;/*ѭ*/ + DSU_DEVICE_COMM_INFO_STRU* pTempDevCommInfoStru; + UINT8 chReturnValue; + + pTempDevCommInfoStru=pDsuFsfbInfoStru->pDevCommInfoStru; + for (i=0;iDeviceCommStruLen;i++) + { + if ((localType==pTempDevCommInfoStru->EmitterType) + &&(DestType==pTempDevCommInfoStru->ReceptorType)) + { + /*SSTyҵڵ*/ + pFSFBLnkRInfo->MaxLost=pTempDevCommInfoStru->MaxLost; + pFSFBLnkRInfo->DLost=pTempDevCommInfoStru->DLost; + pFSFBLnkRInfo->WSsrOut=pTempDevCommInfoStru->WSsrOut; + pFSFBLnkRInfo->AntiDelayCount=pTempDevCommInfoStru->AntiDelayCount; + pFSFBLnkRInfo->TOut=pTempDevCommInfoStru->TOut; + + chReturnValue=1; + return chReturnValue; + } + else + { + /*вҪҵݣ*/ + } + pTempDevCommInfoStru++; + } + + /*δҵӦͨŹϵݣϵϷ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +* ȡ豸 +* UINT16 DevName 豸 +* +* ֵ豸 +*/ +UINT8 dsuFsfbGetDevType(UINT16 DevName) +{ + UINT8 devType; + devType=(UINT8)(DevName>>8); + + return devType; +} + +/* +* úڲѯFSFB·ϢսڵϢӳݡ +* UINT16 FSFBAddr, FSFBַ +* UINT16 BSDAddr, bsdַ +* DSU_FSFB_LINK_RINFO_STRU* pFSFBLnkInfoϢ +* ṹ帳ֵ£ +* UINT8 ROLE;ʾĿǷΪƶ豸 +* UINT8 LocalLogId; ʾԴ̬ID +* UINT16 DestNameʾĿʶ +* UINT8 DestLogId; ʾĵĿ궯̬ID +* LocalLogId 0xFF +* DestName = ݿ +* DestLogId 0xFF +* +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuFsfbRGetLnkInfo(UINT16 locDevName,UINT16 destDevName,UINT8 applyCat, DSU_FSFB_LINK_RINFO_STRU* pFsfbLnkRInfo) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_FSFB_LNK_INFO_STRU* pTempFsfbLnkInfoStru; + UINT16 pTempFsfbLnkInfoStruLen; + UINT8 ChannelCount; + UINT16 CurrentChannel; + UINT8 LocalDevType; + UINT8 DestDevType; + + pTempFsfbLnkInfoStru=pDsuFsfbInfoStru->pfsfbLnkInfoStru; + pTempFsfbLnkInfoStruLen=pDsuFsfbInfoStru->fsfbInfoStruLen; + + /*ҵChannelΪ0*/ + ChannelCount=0; + + /*ѭ*/ + for (i=0;iReceptorName ==locDevName) + &&(pTempFsfbLnkInfoStru->EmitterName==destDevName) + && (pTempFsfbLnkInfoStru->ApplyCat == applyCat)) + { + /*ѾҵĿ*/ + CurrentChannel=pTempFsfbLnkInfoStru->ChannelNumber-1; + ChannelCount++; + pFsfbLnkRInfo->DestName = pTempFsfbLnkInfoStru->ReceptorName; + pFsfbLnkRInfo->srcAdd = pTempFsfbLnkInfoStru->srcAddr; + pFsfbLnkRInfo->destAdd = pTempFsfbLnkInfoStru->destAddr; + pFsfbLnkRInfo->SID_NUMBER_E[CurrentChannel]=pTempFsfbLnkInfoStru->SID_NUMBER_E; + pFsfbLnkRInfo->SID_NUMBER_R[CurrentChannel]=pTempFsfbLnkInfoStru->SID_NUMBER_R; + pFsfbLnkRInfo->SINIT_NUMBER[CurrentChannel]=pTempFsfbLnkInfoStru->SINIT_NUMBER; + pFsfbLnkRInfo->PREC_FIRSTSINIT[CurrentChannel]=pTempFsfbLnkInfoStru->PREC_FIRSTSINIT; + memcpy(pFsfbLnkRInfo->POST_RXDADA_K[CurrentChannel],pTempFsfbLnkInfoStru->POST_RXDADA_K,sizeof(pFsfbLnkRInfo->POST_RXDADA_K[CurrentChannel])); + memcpy(pFsfbLnkRInfo->PREC_SINIT_K[CurrentChannel],pTempFsfbLnkInfoStru->PREC_SINIT_K,sizeof(pFsfbLnkRInfo->PREC_SINIT_K[CurrentChannel])); + + LocalDevType=dsuFsfbGetDevType(pTempFsfbLnkInfoStru->EmitterName); + DestDevType=dsuFsfbGetDevType(pTempFsfbLnkInfoStru->ReceptorName); + chReturnValue=dsuFsfbSetCommInfo(pFsfbLnkRInfo,LocalDevType,DestDevType); + if (chReturnValue==0) + { + /*ͨŹϵʧܣʧ*/ + chReturnValue=0; + return chReturnValue; + } + + if (ChannelCount>=2) + { + /*ͨϢҵ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*δҵͨ*/ + } + } + else + { + /*ǰĿ*/ + } + pTempFsfbLnkInfoStru++; + } + + + /*δҵ豸ʧ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +* úڲѯFSFB·ϢͽڵϢӳݡ +* UINT16 LocalDevName, 豸 +* UINT16 destName, Է豸 +* UINT8 applyCat Application Cat +* DSU_FSFB_LINK_SINFO_STRU* pFsfbLnkSInfoϢ +* +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuFsfbSGetLnkInfo(UINT16 LocalDevName, UINT16 destName,UINT8 applyCat,DSU_FSFB_LINK_SINFO_STRU* pFsfbLnkSInfo) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_FSFB_LNK_INFO_STRU* pTempFsfbLnkInfoStru; + UINT16 pTempFsfbLnkInfoStruLen; + UINT8 ChannelCount; + UINT16 CurrentChannel; + + pTempFsfbLnkInfoStru=pDsuFsfbInfoStru->pfsfbLnkInfoStru; + pTempFsfbLnkInfoStruLen=pDsuFsfbInfoStru->fsfbInfoStruLen; + + /*ҵChannelΪ0*/ + ChannelCount=0; + + /*ѭ*/ + for (i=0;iReceptorName==destName) + &&(pTempFsfbLnkInfoStru->EmitterName==LocalDevName) + &&(pTempFsfbLnkInfoStru->ApplyCat == applyCat)) + { + /*ѾҵĿ*/ + CurrentChannel=pTempFsfbLnkInfoStru->ChannelNumber-1; + ChannelCount++; + pFsfbLnkSInfo->DestName=pTempFsfbLnkInfoStru->ReceptorName; + pFsfbLnkSInfo->srcAdd = pTempFsfbLnkInfoStru->srcAddr; + pFsfbLnkSInfo->destAdd = pTempFsfbLnkInfoStru->destAddr; + pFsfbLnkSInfo->SID_NUMBER_E[CurrentChannel]=pTempFsfbLnkInfoStru->SID_NUMBER_E; + pFsfbLnkSInfo->SID_NUMBER_R[CurrentChannel]=pTempFsfbLnkInfoStru->SID_NUMBER_R; + pFsfbLnkSInfo->SINIT_NUMBER[CurrentChannel]=pTempFsfbLnkInfoStru->SINIT_NUMBER; + pFsfbLnkSInfo->DATANUM[CurrentChannel]=pTempFsfbLnkInfoStru->DATANUM; + pFsfbLnkSInfo->DATAVER_1_Number[CurrentChannel]=pTempFsfbLnkInfoStru->DATAVER_1_Number; + pFsfbLnkSInfo->DATANUM[CurrentChannel]=pTempFsfbLnkInfoStru->DATANUM; + + if (ChannelCount>=2) + { + chReturnValue=1; + return chReturnValue; + } + else + { + /*δҵͨ*/ + } + } + else + { + /*ǰĿ*/ + } + pTempFsfbLnkInfoStru++; + } + + + /*δҵ豸ʧ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +* ȫͨЭFSFBʼڼȷԣݽṹ +* +FSName ļݵַ +pDsuFsfbInfoStru ֽͷָ +* pDsuFsfbInfoStru ʼ +* ֵ1ɹ +* 0ʧܣд +*/ +UINT8 dsuFsFbInit(UINT8* FSName) +{ + UINT8 chReturnValue =0 ; /*ֵ*/ + UINT8 TempRet; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 i; + UINT32 j; + pDsuFsfbInfoStru=&dsuFsfbInfoStru; + + /* ʼIP ַṹ */ + /* ȡ */ + TempRet = dquGetConfigData((char*)FSName,DSU_DEVICE_IP_CONFIG_TYPE,DSU_DATA_IP_IP_ID,&pData,&dataLen); + + if (TempRet != 1) + { + /* ݶȡʧ */ + chReturnValue =0; + return chReturnValue; + } + else + { + /* */ + } + pDsuFsfbInfoStru->IpInfoStruLen = (UINT16)(dataLen/DSU_IP_INFO_STRU_SIZE); + pDsuFsfbInfoStru->pIpInfoStru = (DSU_FSFB_IP_INFO_STRU*)malloc(sizeof(DSU_FSFB_IP_INFO_STRU)*pDsuFsfbInfoStru->IpInfoStruLen); + if (pDsuFsfbInfoStru->pIpInfoStru == NULL) + { + chReturnValue = 0; + return chReturnValue; + } + else + { + /* ִ */ + } + + dataOff = 0; + + for (i=0;iIpInfoStruLen;i++) + { + pDsuFsfbInfoStru->pIpInfoStru[i].devName = ShortFromChar(pData+dataOff); + + dataOff+=2; + pDsuFsfbInfoStru->pIpInfoStru[i].HlhtId = LongFromChar(pData + dataOff); + dataOff += 4; + + memcpy(pDsuFsfbInfoStru->pIpInfoStru[i].IPAddrBlue,pData+dataOff,DSU_IPADDR_LEN); + dataOff+=DSU_IPADDR_LEN; + + memcpy(pDsuFsfbInfoStru->pIpInfoStru[i].IPAddrRed,pData+dataOff,DSU_IPADDR_LEN); + dataOff+=DSU_IPADDR_LEN; + + pDsuFsfbInfoStru->pIpInfoStru[i].SfpBluePort = ShortFromChar(pData+dataOff); + dataOff+=2; + pDsuFsfbInfoStru->pIpInfoStru[i].SfpRedPort = ShortFromChar(pData+dataOff); + dataOff+=2; + pDsuFsfbInfoStru->pIpInfoStru[i].RpBluePort = ShortFromChar(pData+dataOff); + dataOff+=2; + pDsuFsfbInfoStru->pIpInfoStru[i].RpRedPort = ShortFromChar(pData+dataOff); + dataOff+=2; + pDsuFsfbInfoStru->pIpInfoStru[i].RsrAndRsspBluePort = ShortFromChar(pData+dataOff); + dataOff+=2; + pDsuFsfbInfoStru->pIpInfoStru[i].RsrAndRsspRedPort = ShortFromChar(pData+dataOff); + dataOff+=2; + /*pDsuFsfbInfoStru->pIpInfoStru[i].FsfbBluePort = ShortFromChar(pData+dataOff); + dataOff+=2; + pDsuFsfbInfoStru->pIpInfoStru[i].FsfbRedPort = ShortFromChar(pData+dataOff); + dataOff+=2;*/ + + pDsuFsfbInfoStru->pIpInfoStru[i].SourceBluePort = ShortFromChar(pData + dataOff); + dataOff += 2; + pDsuFsfbInfoStru->pIpInfoStru[i].SourceRedPort = ShortFromChar(pData + dataOff); + dataOff += 2; + } + + if (dataOff != dataLen) + { + /* ݳȲǽݵ˵쳣 */ + chReturnValue =0; + return chReturnValue; + } + else + { + /* ִ */ + } + /* ʼ豸ͨЭϵ */ + TempRet = dquGetConfigData((char*)FSName,DSU_DEVICE_IP_CONFIG_TYPE,DSU_DATA_IP_COMM_PROTCL_ID,&pData,&dataLen); + if (TempRet !=1) + { + chReturnValue = 0; + return chReturnValue; + } + else + { + /* ִ */ + } + + pDsuFsfbInfoStru->ComProtclStruLen =(UINT16)(dataLen/DSU_COM_PROTCL_STRU_SIZE); + pDsuFsfbInfoStru->pComProtclStr = (DSU_COM_PROTCL_STRU*)malloc(sizeof(DSU_COM_PROTCL_STRU)*pDsuFsfbInfoStru->ComProtclStruLen); + if (pDsuFsfbInfoStru->pComProtclStr ==NULL) + { + chReturnValue = 0; + return chReturnValue; + } + else + { + /*ִ */ + } + + dataOff =0; + for (i=0;iComProtclStruLen;i++) + { + pDsuFsfbInfoStru->pComProtclStr[i].EmitterType=pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pComProtclStr[i].ReceptorType = pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pComProtclStr[i].CommType = pData[dataOff]; + dataOff++; + } + + if (dataOff != dataLen) + { + /* ݳȲǽݵ˵쳣 */ + chReturnValue =0; + return chReturnValue; + } + else + { + /* ִ */ + } + + /*ʼFSFB lnk Ϣ */ + /*ȡ*/ + TempRet=dquGetConfigData((char*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_FSFB_LNK_ID, &pData , &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + pDsuFsfbInfoStru->fsfbInfoStruLen=(UINT16)(dataLen/DSU_FSFB_LNK_INFO_STRU_SIZE); /*ݵĸ*/ + pDsuFsfbInfoStru->pfsfbLnkInfoStru=(DSU_FSFB_LNK_INFO_STRU*)malloc(sizeof(DSU_FSFB_LNK_INFO_STRU)*(pDsuFsfbInfoStru->fsfbInfoStruLen)); /*Ϊṹռ*/ + if (pDsuFsfbInfoStru->pfsfbLnkInfoStru==NULL) + { + /*ռʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i=0;ifsfbInfoStruLen;i++) + { + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].Id=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].ApplyCat=pData[dataOff]; + dataOff+=1; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].EmitterName=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].ReceptorName=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].ChannelNumber=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].SID_NUMBER_E=LongFromChar(pData+dataOff); + dataOff+=4; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].SINIT_NUMBER=LongFromChar(pData+dataOff); + dataOff+=4; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].DATANUM=pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].DATAVER_1_Number=LongFromChar(pData+dataOff); + dataOff+=4; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].srcAddr=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].destAddr=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].SID_NUMBER_R=LongFromChar(pData+dataOff); + dataOff+=4; + + pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].PREC_FIRSTSINIT=LongFromChar(pData+dataOff); + dataOff+=4; + + for (j=0;jpfsfbLnkInfoStru[i].PREC_SINIT_K[j]=LongFromChar(pData+dataOff); + dataOff+=4; + + } + + for (j=0;jpfsfbLnkInfoStru[i].POST_RXDADA_K[j]=LongFromChar(pData+dataOff); + dataOff+=4; + } + } + + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + /*ʼƽ̨ݽṹ*/ + /*ȡ*/ + TempRet=dquGetConfigData((char*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_CI_PLATFORM_ID, &pData , &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + /*ʼ豸ͨԱ*/ + /*ȡ*/ + TempRet=dquGetConfigData((char*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_COMM_INFO_ID, &pData , &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + pDsuFsfbInfoStru->DeviceCommStruLen=(UINT16)(dataLen/DSU_DEVICE_COMM_INFO_STRU_SIZE); /*ݵĸ*/ + pDsuFsfbInfoStru->pDevCommInfoStru =(DSU_DEVICE_COMM_INFO_STRU*)malloc(sizeof(DSU_DEVICE_COMM_INFO_STRU)*(pDsuFsfbInfoStru->DeviceCommStruLen)); /*Ϊṹռ*/ + if (pDsuFsfbInfoStru->pDevCommInfoStru==NULL) + { + /*ռʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i=0;iDeviceCommStruLen;i++) + { + + pDsuFsfbInfoStru->pDevCommInfoStru[i].EmitterType=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuFsfbInfoStru->pDevCommInfoStru[i].ReceptorType=ShortFromChar(pData+dataOff); + dataOff+=2; + + + pDsuFsfbInfoStru->pDevCommInfoStru[i].MaxLost=pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pDevCommInfoStru[i].DLost=pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pDevCommInfoStru[i].WSsrOut=pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pDevCommInfoStru[i].AntiDelayCount=pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pDevCommInfoStru[i].TOut=pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pDevCommInfoStru[i].MsgId=pData[dataOff]; + dataOff++; + + pDsuFsfbInfoStru->pDevCommInfoStru[i].IftVer=pData[dataOff]; + dataOff++; + + } + + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + chReturnValue=1; + return chReturnValue; +} + + +/* +*ܣݱ豸ƺͶԷ豸ƣѯFSFB·ȡԴַĿַ +*UINT16 destDevName Էʶ +UINT16 locDevName ʶ +UINT16* FSFBSrcAddr Դַ +UINT16* FSFBDestAddr Ŀַ +*ֵ1ɹʧ +*/ +UINT8 dsuFsfbRGetAddr(UINT16 destDevName,UINT16 locDevName,UINT8 applyCat,UINT16* srcAddr,UINT16* destAddr) +{ + UINT8 ret = 0; + UINT16 i; /*ѭ*/ + + for (i = 0;i < pDsuFsfbInfoStru->fsfbInfoStruLen;i++) + { + if ((pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].EmitterName == locDevName) + && (pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].ReceptorName == destDevName) + &&(pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].ApplyCat == applyCat)) + { + *srcAddr = pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].srcAddr; + *destAddr = pDsuFsfbInfoStru->pfsfbLnkInfoStru[i].destAddr; + break; + } + else + { + } + } + + if (i == pDsuFsfbInfoStru->fsfbInfoStruLen) + { + return ret; + } + ret = 1; + return ret; +} + +/* +*ܣݱ豸ƺͶԷ豸ƣѯ豸ͨŹϵIPñȡIpϢ +*UINT16 destDevName Էʶ +UINT16 locDevName ʶ +DSU_FSFB_LNK_INFO_STRU* pLnkInfo IPϢ +UINT16* FSFBDestAddr Ŀַ +*ֵ1ɹʧ +*/ +UINT8 dsuFsfbGetLnkInfo(UINT16 locDevName,UINT16 destDevName,DSU_FSFB_IP_LNK_INFO_STRU* pLnkInfo) +{ + UINT8 retVal =0; + UINT16 i=0;/* ѭʹ */ + + UINT8 tempEmitterType = 0; + UINT8 tempReceptorType = 0; + UINT8 commType =0; + + DSU_COM_PROTCL_STRU* pTempComProtclStru = NULL; /* ͨЭʱ */ + DSU_FSFB_IP_INFO_STRU *pTempIpInfoStru = NULL; + UINT16 tempComProtclStruLen=0; + UINT16 tempIpInfoStruLen =0; + + /* ȡ豸 */ + tempEmitterType =dsuFsfbGetDevType(locDevName); + tempReceptorType = dsuFsfbGetDevType(destDevName); + + pTempComProtclStru=pDsuFsfbInfoStru->pComProtclStr; + tempComProtclStruLen=pDsuFsfbInfoStru->ComProtclStruLen; + + for(i=0;iEmitterType == tempEmitterType) + &&(pTempComProtclStru->ReceptorType == tempReceptorType)) + { + commType=pTempComProtclStru->CommType; + break; + } + pTempComProtclStru++; + } + + if (i== tempComProtclStruLen) + { + retVal = 0; + return retVal; + } + + pLnkInfo->srcNum =0; + pLnkInfo->destNum =0; + + pTempIpInfoStru = pDsuFsfbInfoStru->pIpInfoStru; + tempIpInfoStruLen = pDsuFsfbInfoStru->IpInfoStruLen; + + for(i=0;idevName == locDevName) + { + /* ֵIPַ */ + memcpy(pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].BlueIp,pTempIpInfoStru->IPAddrBlue,DSU_IPADDR_LEN); + memcpy(pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].RedIp,pTempIpInfoStru->IPAddrRed,DSU_IPADDR_LEN); + + /* ͨЭѾҵ */ + /* Э͵IJͬȡͬĶ˿ں */ + if(commType == DSU_PROTCL_SFP) + { + pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].PortBlue = pTempIpInfoStru->SfpBluePort; + pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].PortRed = pTempIpInfoStru->SfpRedPort; + } + else if(commType == DSU_PROTCL_RP) + { + pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].PortBlue = pTempIpInfoStru->RpBluePort; + pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].PortRed = pTempIpInfoStru->RpRedPort; + } + else if((commType == DSU_PROTCL_RSR)||(commType == DSU_PROTCL_RSSP)) + { + pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].PortBlue = pTempIpInfoStru->RsrAndRsspBluePort; + pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].PortRed = pTempIpInfoStru->RsrAndRsspRedPort; + } + /*else if(commType == DSU_PROTCL_FSFB) + { + pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].PortBlue = pTempIpInfoStru->FsfbBluePort; + pLnkInfo->SrcIpInfo[pLnkInfo->srcNum].PortRed = pTempIpInfoStru->FsfbRedPort; + }*/ + else + { + /* ݴ */ + retVal =0; + return retVal; + } + /* IPַ+1*/ + pLnkInfo->srcNum++; + } + else + { + /* */ + } + + if (pTempIpInfoStru->devName == destDevName) + { + /* ֵIPַ */ + memcpy(pLnkInfo->DestIpInfo[pLnkInfo->destNum].BlueIp,pTempIpInfoStru->IPAddrBlue,DSU_IPADDR_LEN); + memcpy(pLnkInfo->DestIpInfo[pLnkInfo->destNum].RedIp,pTempIpInfoStru->IPAddrRed,DSU_IPADDR_LEN); + + /* ͨЭѾҵ */ + /* Э͵IJͬȡͬĶ˿ں */ + if(commType == DSU_PROTCL_SFP) + { + pLnkInfo->DestIpInfo[pLnkInfo->destNum].PortBlue = pTempIpInfoStru->SfpBluePort; + pLnkInfo->DestIpInfo[pLnkInfo->destNum].PortRed = pTempIpInfoStru->SfpRedPort; + } + else if(commType == DSU_PROTCL_RP) + { + pLnkInfo->DestIpInfo[pLnkInfo->destNum].PortBlue = pTempIpInfoStru->RpBluePort; + pLnkInfo->DestIpInfo[pLnkInfo->destNum].PortRed = pTempIpInfoStru->RpRedPort; + } + else if((commType == DSU_PROTCL_RSR)||(commType == DSU_PROTCL_RSSP)) + { + pLnkInfo->DestIpInfo[pLnkInfo->destNum].PortBlue = pTempIpInfoStru->RsrAndRsspBluePort; + pLnkInfo->DestIpInfo[pLnkInfo->destNum].PortRed = pTempIpInfoStru->RsrAndRsspRedPort; + } + /*else if(commType == DSU_PROTCL_FSFB) + { + pLnkInfo->DestIpInfo[pLnkInfo->destNum].PortBlue = pTempIpInfoStru->FsfbBluePort; + pLnkInfo->DestIpInfo[pLnkInfo->destNum].PortRed = pTempIpInfoStru->FsfbRedPort; + }*/ + else + { + /* ݴ */ + retVal =0; + return retVal; + } + /* IPַ+1*/ + pLnkInfo->destNum++; + } + else + { + /* */ + } + + pTempIpInfoStru++; + } + + if ((pLnkInfo->srcNum == 0)||(pLnkInfo->destNum == 0)) + { + retVal = 0; + return retVal; + } + else + { + /* */ + } + + retVal =1; + return retVal; +} + + +UINT8 AccordDevNameGetIpAddr(UINT16 devName,UINT8* pIpaddr) +{ + UINT8 retVal =0; + UINT16 dataLen =0; + UINT16 i=0; + DSU_FSFB_IP_INFO_STRU* pTempIpStru =NULL; + pTempIpStru =pDsuFsfbInfoStru->pIpInfoStru; + dataLen =pDsuFsfbInfoStru->IpInfoStruLen; + + for(i=0;ipIpInfoStru; + dataLen =pDsuFsfbInfoStru->IpInfoStruLen; + + for(i=0;ipIpInfoStru; + dataLen =pDsuFsfbInfoStru->IpInfoStruLen; + + for(i=0;iSendLinkStatus = Fsfb_Halt; +* ͱ־Ϊ0 +* ޸ɣյSSRʱһ״̬ΪSSEABT֡״̬ΪΪ +* 2014.05.22 +* ޸ݣFsfbUptLnkNodeInfoByAbtУڵĽ״̬ΪBTCABTʱ״̬Ϊ +* ޸ɣֹӳʱƵBTC֡ +* 2014.08.14 +* ޸ݣFsfbRecvLnkStatusMngУ֡Ҳʱ飬ʱ·SBTBTMỰ +* ޸ɣ֮ǰֻSBTABT˳ʱ飬֡δʱ +* ------------ ------ --------------- +********************************************************/ +#include +#include "Convert.h" +#include "dsuFsfbFunc.h" +#include "CommonStack.h" +#include "FsfbLnkNodeMgr.h" +#include "FsfbConfig.h" +#include "CommonRecord.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------- + * ·ģڲ Start + *--------------------------------------------------------------------*/ +static UINT8 InitFSFBLnkInfo(UINT16 devName,const DSU_FSFB_LINK_RINFO_STRU* pRecvDsuLnkInf, + const DSU_FSFB_LINK_SINFO_STRU* pOutputDsuLnkInf, + UINT8 applyCat,FSFB_INFO_STRU* pFsfbStruct,FsfbLinkInfoStru* pFsfbLnkStruct); +static void SearchTdmFrameStamp(UINT16 devName,UINT8 applyCat,FSFB_INFO_STRU* pFsfbStruct,UINT32* stampTime); +static UINT8 FsfbCheckOutputDsuLnkInfo(UINT16 srcAddr,UINT16 destAddr, + const DSU_FSFB_LINK_SINFO_STRU *pOutputLnkInfo); +static UINT8 FsfbSetNodeParam(const DSU_FSFB_LINK_RINFO_STRU* pRecvDsuLnkInf, + const DSU_FSFB_LINK_SINFO_STRU* pOutputDsuLnkInf, + FsfbNodeParamInfoStru *pNodeParam); +static UINT8 FsfbCheckRecvDsuLnkInfo(UINT16 srcAddr,UINT16 destAddr, + const DSU_FSFB_LINK_RINFO_STRU *pRecvLnkInfo); +static UINT8 FsfbCheckInputAddr(UINT16 LocalDevName,UINT16 destName,const DSU_FSFB_LINK_RINFO_STRU *pRecvLnkInfo); +static void FsfbLnkNodeInfo2VarArray(const Fsfb_Lnk_Info_Node_Stru* pNode, UINT8* VarArray); +/*-------------------------------------------------------------------- + * ·ģڲ End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * ·ģⲿӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** +* : SearchNodeByName +* : ָĶԷ豸ʶͱͲѯӦͨŽڵǷڡ +* 򷵻ضӦͨŽڵָ룬򷵻NULL +* : +* +* -------------------------------------------------------------------------- +* destName UINT16 IN Է豸ʶ +* applyCat UINT8 IN application categy +* pFsfbStruct FSFB_INFO_STRU * Эͳһṹ +* ֵ : Fsfb_Lnk_Info_Node_Stru* ͨŽڵָ룬 NULL: +***********************************************************************/ +Fsfb_Lnk_Info_Node_Stru* FsfbSearchNodeByName(UINT16 destName,UINT8 applyCat,FSFB_INFO_STRU *pFsfbStruct) +{ + UINT8 flag = 1; + Fsfb_Lnk_Info_Node_Stru *pCurIndex; + Fsfb_Lnk_Info_Node_Stru *pret; + pCurIndex=pFsfbStruct->LnkHead; + + while(flag) + { + if (pCurIndex != NULL) + { + if ((destName == pCurIndex->DestDevName)&&(applyCat == pCurIndex->Applcat)) + { + return pCurIndex; + } + else + { + pCurIndex=pCurIndex->NextNode; + } + } + else + { + pret = NULL; + return pret; + } + } + + pret = NULL; + return pret; +} + +/*********************************************************************** +* : FsfbOutputReplaceLnkNode +* : ݱ豸ͺͶԷ豸ԼͣȡöӦڵϢ +* ͨŽڵϢʼ +* : +* +* ------------------------------------------------------------- +* locName UINT16 IN 豸 +* destName UINT16 IN Է豸 +* applyCat UINT8 IN +* pPLnkNodeInfo Lnk_Info_Node_Stru** OUT ͨŽڵ +* pFsfbStruct FSFB_INFO_STRU * INOUT ͳһṹ +* ֵ : UINT8 1 0󷵻 +* ʹ Ϊģ飬ַָͨŽڵ㲻ʱ +* +***********************************************************************/ +UINT8 FsfbOutputReplaceLnkNode(UINT16 locName,UINT16 destName,UINT8 applyCat,Fsfb_Lnk_Info_Node_Stru **pPLnkNodeInfo, + FSFB_INFO_STRU *pFsfbStruct) +{ + UINT8 ret = 0,chcRet = 0; + DSU_FSFB_LINK_RINFO_STRU rcvLnkInfo; /* ΪܽڵϢ */ + DSU_FSFB_LINK_SINFO_STRU outLnkInfo; /* ΪͽڵϢ*/ + Fsfb_Lnk_Info_Node_Stru *pLnkNodeInfo = NULL; + /* + * ݱ豸ƺͶԷ豸ƻȡΪܽڵϢ + */ + ret = dsuFsfbRGetLnkInfo(locName,destName,applyCat,&rcvLnkInfo); + + /* ϢǷһ */ + chcRet = FsfbCheckInputAddr(locName,destName,&rcvLnkInfo); + if( (ret == 1)&&(1 == chcRet)) + { + /* ݱ豸ƺͶԷ豸ƻȡΪͽڵϢ*/ + ret = dsuFsfbSGetLnkInfo(locName,destName,applyCat,&outLnkInfo); + if(ret == 0) + { + return ret; + } + + /*Ҫ޸ 豸ƺͶԷ豸ƻȡڵ㣬ڵΪգ˽ڵ*/ + pLnkNodeInfo = FsfbInsertLnkNode(pFsfbStruct,destName,applyCat); + if(NULL == pLnkNodeInfo) + { + /* ɸǽڵȡʧ 󷵻 */ + ret = 0; + return ret; + } + else + { + /* ȡõĸǽڵָ 淵pPLnkNodeInfo */ + *pPLnkNodeInfo = pLnkNodeInfo; + } + + /* FSFB·Ϣṹʼ */ + ret=InitFSFBLnkInfo(destName,&rcvLnkInfo, &outLnkInfo,applyCat,pFsfbStruct,&pLnkNodeInfo->FsfbLinInfo); + + if (ret == 0) + { + return ret; + } + } + else + { + /* Ϣȡʧ ͨŹϵʽ CICC ַϵ */ + ret = 0; + return ret; + } + + ret = 1; + return ret; +} + +/*********************************************************************** +* : FsfbInsertLnkNode +* : ͨɸǵĽڵ㡣 +* : +* +* -------------------------------------------------------------- +* pFsfbStruct FSFB_INFO_STRU * IN Эͳһṹ +* devName UINT16 IN 豸 +* applyCat UINT8 IN +* ֵ : Fsfb_Lnk_Info_Node_Stru* NULL쳣 NULLͨŽڵ +***********************************************************************/ +Fsfb_Lnk_Info_Node_Stru* FsfbInsertLnkNode(FSFB_INFO_STRU *pFsfbStruct,UINT16 devName,UINT8 applyCat) +{ + Fsfb_Lnk_Info_Node_Stru* retNodePtr = NULL; + Fsfb_Lnk_Info_Node_Stru* LastIndex; + Fsfb_Lnk_Info_Node_Stru* CurIndex; + + + /*ǰָͷָ뿪ʼ*/ + CurIndex = pFsfbStruct->LnkHead; + retNodePtr = NULL; + LastIndex = NULL; + + /* һڵ */ + retNodePtr =(Fsfb_Lnk_Info_Node_Stru*)ComPopStack(&pFsfbStruct->LnkStack); + if(0 == retNodePtr) + { + retNodePtr =NULL; /*ûпõڴڵ*/ + } + else + { + /*ĿNameֵ*/ + retNodePtr->DestDevName = devName; + retNodePtr->Applcat = applyCat; + + while (CurIndex != NULL) + { + if ((CurIndex->DestDevName < devName)||((CurIndex->DestDevName ==devName) &&(CurIndex->ApplcatNextNode; + } + } + + if(LastIndex != NULL) + { + LastIndex->NextNode = retNodePtr; + retNodePtr->NextNode = CurIndex; + } + else + { + retNodePtr->NextNode = CurIndex; + pFsfbStruct->LnkHead = retNodePtr; + } + } + + return retNodePtr; +} +/*********************************************************************** +* : FsfbCheckInfoAddr +* : ԴַĿĵַж·еǷһ¡ +* : +* +* ------------------------------------------------------------------------ +* srcAddr UINT16 IN Դַ +* DestAddr UINT16 IN Ŀַ +* pLnkNodeStru const Fsfb_Lnk_Info_Node_Stru* IN ·Ϣ +* +* ֵ : UINT8 1һ 0һ +***********************************************************************/ +UINT8 FsfbCheckInfoAddr(UINT16 srcAddr,UINT16 DestAddr,Fsfb_Lnk_Info_Node_Stru* pLnkNodeStru) +{ + UINT8 retVal =0; + if ((srcAddr == pLnkNodeStru->FsfbLinInfo.rcvSrcAdd)&&(DestAddr == pLnkNodeStru->FsfbLinInfo.rcvDestAdd)) + { + retVal =1; + } + else + { + retVal =0; + } + + return retVal; +} + +/*********************************************************************** + * : FsfbUptLnkNodeInfoBySSE + * : SSEϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pAppData UINT8* IN һ֡ĸʽ + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * + + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbUptLnkNodeInfoBySSE(UINT8* pAppData,Fsfb_Lnk_Info_Node_Stru *pLnkNode) +{ + FsfbLinkInfoStru *pFsfbLnkInfo = NULL; + + pFsfbLnkInfo = &pLnkNode->FsfbLinInfo; + + /* ·ͽڵ״̬Ϊ SSR */ + pFsfbLnkInfo->SendLinkStatus = Fsfb_SendSSR; + + /* 趨յSSEʱ */ + pFsfbLnkInfo->TimeStmp.RecvSseTCe = + LongFromCharLE(&pAppData[FSFB_TC_POS]); + + /* SEQENQ_1ȡ 趨 */ + pFsfbLnkInfo->TimeStmp.SeqEng[0] = LongFromCharLE(&pAppData[FSFB_SSE_ENQ_1_POS]); + + /* SEQENQ_2ȡ 趨 */ + pFsfbLnkInfo->TimeStmp.SeqEng[1] = LongFromCharLE(&pAppData[FSFB_SSE_ENQ_2_POS]); + + pFsfbLnkInfo->NoRecvDataCycleNum =0; + pLnkNode->IsSendFlag =1; + + return (UINT8)1; +} + + +/*********************************************************************** + * : FsfbUptLnkNodeInfoBySsr + * : SSRϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pAppData UINT8* IN һ֡ĸʽ + * applyCat UINT8 IN applycation cate + * pFsfbStrut FSFB_INFO_STRU* IN FSFBЭͳһṹ + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 FsfbUptLnkNodeInfoBySsr(UINT8* pAppData,UINT8 applyCat,FSFB_INFO_STRU* pFsfbStrut,Fsfb_Lnk_Info_Node_Stru *pLnkNode) +{ + UINT8 retVal =0; + UINT32 SseTCe = 0; /* SSR SSETC */ + UINT32 SeqIni[2] = {0}; /* SSRĵSEQ_INI ֵ */ + FsfbLinkInfoStru *pFsfbLnkInfo = NULL; + ComTimeStampStru *pTmStmp = NULL; /* ʱṹָ */ + + pFsfbLnkInfo = &pLnkNode->FsfbLinInfo; + pTmStmp = &pFsfbLnkInfo->TimeStmp; + + if (applyCat == APPLCAT_BTM) + { + /* ͨ·Ľ״̬Ϊ ȴSSR */ + if(Fsfb_WaitSSR == pFsfbLnkInfo->RecvLinkStatus ) + { + SseTCe = LongFromCharLE(&pAppData[FSFB_SSR_TCENQ_POS]); /* SSRĵ SSE */ + + /* жǷΪӦ SSR */ + if( pTmStmp->SseTC == SseTCe) + { + /* ǶӦSSRģ·鱨Ϣ */ + + pTmStmp->SsrTc = *pFsfbStrut->CycleNum; /* ϴͬںŸ ǰں */ + + SeqIni[0] = LongFromCharLE(&pAppData[FSFB_SSR_ENQ_1_POS]); /* źŵ SEQINI_1 ֵ */ + SeqIni[1] = LongFromCharLE(&pAppData[FSFB_SSR_ENQ_2_POS]); /* źŵ SEQINI_2 ֵ */ + + /* ʼSINITr AND [SIDr ^ Tr(n)]浽pTmStmp->NowSINIT_ADD_SID_XOR_Tn */ + retVal = ComCalcFirstSinitAndSidXorTn(pFsfbLnkInfo->LocalNode.PREC_FIRSTSINIT,SeqIni, + pTmStmp->SseTn,pTmStmp->NowSINIT_ADD_SID_XOR_Tn); + + pTmStmp->NumSendSse = 0; /* SSE 趨Ϊ 0 */ + pTmStmp->LastLocalRecTC = *pFsfbStrut->CycleNum; /* ϴյĵıʱ */ + pTmStmp->LastRecvTCr = pTmStmp->NowRecvTCr; /* ϴνܱʱΪ ǰյʱ Ԥ */ + pTmStmp->NowRecvTCr = LongFromCharLE(&pAppData[FSFB_TC_POS]); /* ǰյʱ = ļ */ + + pFsfbLnkInfo->RecvLinkStatus = Fsfb_WaitBtm_Sseabt; /* ·״̬ */ + pFsfbLnkInfo->SendLinkStatus = Fsfb_Halt; + pFsfbLnkInfo->NoRecvDataCycleNum = 0; /* */ + pLnkNode->IsSendFlag =0; + } + else /* ǶӦSSR */ + { + /* 󷵻 */ + retVal = 0; + } + } + else + { + /* 󷵻 0 */ + retVal = 0; + } + } + else + { + /* 󷵻 */ + retVal =0; + } + + return retVal; +} + + + +/*********************************************************************** + * : FsfbUptLnkNodeInfoByAbt + * : ABTϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pAppData UINT8* IN һ֡ĸʽ + * pFsfbStrut FSFB_INFO_STRU* IN FSFBЭͳһṹ + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * + + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 FsfbUptLnkNodeInfoByAbt(UINT8* pAppData, FSFB_INFO_STRU* pFsfbStrut, Fsfb_Lnk_Info_Node_Stru* pLnkNode) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + FsfbLinkInfoStru* lnkInfo = NULL; /*·Ϣ*/ + ComTimeStampStru* timeStamp = NULL; /*ʱ*/ + UINT32 tc = 0u; /**/ + INT32 delayTc = 0; /**/ + UINT8 funSidXorTnRtn = 0u; /*ûȡSidXorTnֵ*/ + UINT8 funSvcRtn = 0u; /*SVCУ麯ֵ*/ + UINT8 procRst = 0u; /**/ + UINT32 sidXorTn[2] = { 0u }; /*SID XOR TN BSDļ*/ + UINT8* recordArray = NULL; /*־*/ + UINT16 recordArraySize = 0u; /*־鳤*/ + + if ((NULL != pAppData) && (NULL != pFsfbStrut) && (NULL != pLnkNode) && (NULL != pFsfbStrut->RecordArray)) /**/ + { + lnkInfo = &pLnkNode->FsfbLinInfo; + timeStamp = &lnkInfo->TimeStmp; + recordArray = pFsfbStrut->RecordArray; + recordArraySize = pFsfbStrut->RecordArraySize; + + if ((Fsfb_WaitBtm_Sseabt == lnkInfo->RecvLinkStatus) || (Fsfb_WaitBtm_Btcabt == lnkInfo->RecvLinkStatus) || (Fsfb_WaitBtm_AbtOrSse == lnkInfo->RecvLinkStatus)) /*ȴBTMSSEABT֡ ȴBTMBTCABT֡ ȴBTMABT֡SSE֡*/ + { + tc = LongFromCharLE(&pAppData[FSFB_TC_POS]); + delayTc = tc - timeStamp->NowRecvTCr - 1; + if ((0 <= delayTc) && (COM_MAX_K > delayTc)) /**/ + { + funSidXorTnRtn = ComGetSidXorTn(pAppData, sidXorTn); /*ȡSidXorTn*/ + funSvcRtn = ComCheckCRCM(sidXorTn, timeStamp->NowSINIT_ADD_SID_XOR_Tn, delayTc, lnkInfo->LocalNode.TSD_POST_RXDADA_K); /*SVC*/ + if ((1u == funSidXorTnRtn) && (1u == funSvcRtn)) /*ɹ*/ + { + procRst = ComUpdtTmStmpStru(sidXorTn, tc, delayTc, lnkInfo->LocalNode.PREC_SINIT_K, timeStamp); /*ʱ*/ + } + else /*ʧ*/ + { +#ifdef FSFB_RECORD_ERR_ASCII + PrintFiles(recordArray, recordArraySize, "W:ABT SVC Error.\n"); + PrintFileU16Hex(recordArray, recordArraySize, pLnkNode->DestDevName); /*DestDevName*/ + PrintFileU32Hex(recordArray, recordArraySize, sidXorTn[0]); /*sidXorTn[0]*/ + PrintFileU32Hex(recordArray, recordArraySize, sidXorTn[1]); /*sidXorTn[1]*/ + PrintFileU32Hex(recordArray, recordArraySize, timeStamp->NowSINIT_ADD_SID_XOR_Tn[0]); /*NowSINIT_ADD_SID_XOR_Tn[0]*/ + PrintFileU32Hex(recordArray, recordArraySize, timeStamp->NowSINIT_ADD_SID_XOR_Tn[1]); /*NowSINIT_ADD_SID_XOR_Tn[1]*/ + PrintFileU32Hex(recordArray, recordArraySize, delayTc); /*delayTc*/ +#endif + procRst = 0u; + } + + } + else /**/ + { +#ifdef FSFB_RECORD_ERR_ASCII + PrintFiles(pFsfbStrut->RecordArray, pFsfbStrut->RecordArraySize, "W:ABT old tc\n"); + PrintFileU16Hex(recordArray, recordArraySize, pLnkNode->DestDevName); /*DestDevName*/ + PrintFileU32Hex(recordArray, recordArraySize, timeStamp->NowRecvTCr); /*NowRecvTCr*/ + PrintFileU32Hex(recordArray, recordArraySize, tc); /*tc*/ +#endif + procRst = 0u; + } + + if (1u == procRst) /**/ + { + if (Fsfb_WaitBtm_Sseabt == lnkInfo->RecvLinkStatus) /*ͨ·Ľ״̬Ϊ ȴSSR*/ + { + lnkInfo->SendLinkStatus = Fsfb_SendBtm_Btc; /*·״̬Ϊbtc*/ + } + else /*BTC ȴABT ȴBTMABT֡SSE֡*/ + { + lnkInfo->RecvLinkStatus = Fsfb_RecvData; /*··״̬Ϊ*/ + lnkInfo->SendLinkStatus = Fsfb_Halt; + timeStamp->NowRecvTCr = LongFromCharLE(&pAppData[FSFB_TC_POS]); /*ǰյʱ=ļ*/ + } + } + } + else if (Fsfb_WaitBtm_SbtAbt == lnkInfo->RecvLinkStatus) /*ȴBTMsbtAbt֡*/ + { + tc = LongFromCharLE(&pAppData[FSFB_TC_POS]); + delayTc = ComCheckTimeStamp(tc, timeStamp->NowRecvTCr, lnkInfo->LocalNode.MaxLost); + if (delayTc < 0) + { + lnkInfo->SendLinkStatus = Fsfb_SendSSE; /*·״̬ΪSSE*/ + } + else + { + lnkInfo->SendLinkStatus = Fsfb_SendBtm_Btc; /*·״̬ΪBtc*/ + } + timeStamp->NowRecvTCr = LongFromCharLE(&pAppData[FSFB_TC_POS]); /*ǰյʱ=ļ*/ + + procRst = 1u; + } + else /*Ƿ״̬*/ + { + lnkInfo->SendLinkStatus = Fsfb_Halt; + } + + if (1u == procRst) /**/ + { + timeStamp->LastLocalRecTC = *pFsfbStrut->CycleNum; /* ϴյĵıʱ */ + timeStamp->LastRecvTCr = timeStamp->NowRecvTCr; /* ϴνܱʱΪ ǰյʱ Ԥ */ + lnkInfo->NoRecvDataCycleNum = 0u; /* */ + pLnkNode->IsSendFlag = 1u; + rtnVal = 1u; + } + + return rtnVal; + } +} + + + + +/*********************************************************************** + * : FsfbUptLnkNodeInfoByEbt + * : EBTϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * devName UINT16 IN 豸 + * pAppData UINT8* IN һ֡ĸʽ + * pFsfbStrut FSFB_INFO_STRU* IN FSFBЭͳһṹ + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbUptLnkNodeInfoByEbt(UINT16 devName,UINT8* pAppData,FSFB_INFO_STRU* pFsfbStrut,Fsfb_Lnk_Info_Node_Stru *pLnkNode) +{ + UINT8 retVal =0; + FsfbLinkInfoStru *pFsfbLnkInfo = NULL; + Fsfb_Lnk_Info_Node_Stru *pFsfbTdmLnkInfo = NULL; + ComTimeStampStru *pTmStmp = NULL; /* ʱṹָ */ + + pFsfbLnkInfo = &pLnkNode->FsfbLinInfo; + pTmStmp = &pFsfbLnkInfo->TimeStmp; + + pLnkNode->FsfbLinInfo.RecvLinkStatus = Fsfb_Halt; /* ״̬仯Ϊж */ + pLnkNode->FsfbLinInfo.SendLinkStatus = Fsfb_SendBtm_Ebt; /* ·EBT֡ */ + pTmStmp->LastLocalRecTC = *pFsfbStrut->CycleNum; /* ϴյĵıʱ */ + pTmStmp->LastRecvTCr = pTmStmp->NowRecvTCr; /* ϴνܱʱΪ ǰյʱ Ԥ */ + pTmStmp->NowRecvTCr = LongFromCharLE(&pAppData[FSFB_TC_POS]); /* ǰյʱ = ļ */ + pFsfbLnkInfo->NoRecvDataCycleNum = 0; /* */ + /* ѯӦTDM·Ҹ·״̬ */ + pFsfbTdmLnkInfo=FsfbSearchNodeByName(devName,APPLCAT_TDM,pFsfbStrut); + if(pFsfbTdmLnkInfo == NULL) + { + /* */ + } + else + { + /* Ӧ·Ϣ*/ + pFsfbTdmLnkInfo->FsfbLinInfo.RecvLinkStatus = Fsfb_Halt; /* ״̬仯Ϊж */ + pFsfbTdmLnkInfo->FsfbLinInfo.SendLinkStatus = Fsfb_Halt; /* ·Ϊж*/ + pFsfbTdmLnkInfo->FsfbLinInfo.TimeStmp.LastLocalRecTC = *pFsfbStrut->CycleNum; /* ϴյĵıʱ */ + pFsfbTdmLnkInfo->FsfbLinInfo.TimeStmp.LastRecvTCr = pTmStmp->NowRecvTCr; /* ϴνܱʱΪ ǰյʱ Ԥ */ + pFsfbTdmLnkInfo->FsfbLinInfo.TimeStmp.NowRecvTCr = LongFromCharLE(&pAppData[FSFB_TC_POS]); /* ǰյʱ = ļ */ + pFsfbTdmLnkInfo->FsfbLinInfo.NoRecvDataCycleNum = 0; /* */ + + pLnkNode->IsSendFlag =1; + } + retVal =1; + return retVal; +} + + +/*********************************************************************** + * : FsfbRecvLnkStatusMng + * : ͨŽڵϢ״̬仯 + * : + * + * -------------------------------------------------------------- + * pFsfbStruct FSFB_INFO_STRU* INOUT FSFBЭͳһṹ + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbRecvLnkStatusMng(FSFB_INFO_STRU* pFsfbStruct) +{ + UINT8 retVal =0; + UINT8 RecvStatus = 0; /* ״̬ */ + UINT32 NowCycleNum = 0, LastLocalRecTC; /* ϴյıں */ + UINT32 NoRecDataTc = 0; + Fsfb_Lnk_Info_Node_Stru* pCurFillLnk;/*嵱ǰָ*/ + + NowCycleNum = *pFsfbStruct->CycleNum; + pCurFillLnk = pFsfbStruct->LnkHead; /*λ·ͷָ*/ + /* ȡȫͨŽڵ */ + while(pCurFillLnk != NULL) + { + /* ǰ·״̬ */ + RecvStatus = pCurFillLnk->FsfbLinInfo.RecvLinkStatus; + if((Fsfb_WaitSSR == RecvStatus) || (Fsfb_RecvData == RecvStatus) + ||(Fsfb_WaitBtm_SbtAbt == RecvStatus)||(Fsfb_WaitBtm_Btcabt == RecvStatus)) + { + LastLocalRecTC = pCurFillLnk->FsfbLinInfo.TimeStmp.LastLocalRecTC; + /* ûյж */ + if(NowCycleNum != LastLocalRecTC) + { + /* ûյ+1 */ + pCurFillLnk->FsfbLinInfo.NoRecvDataCycleNum += 1; + NoRecDataTc = pCurFillLnk->FsfbLinInfo.NoRecvDataCycleNum; + + /* жǷ񳬹涨ʱδյյ֡:磬ȴSSR涨ʱûյ */ + if(pCurFillLnk->FsfbLinInfo.LocalNode.SSDelay < NoRecDataTc) + {/*涨ʱδյյ֡,·SBT֡ؽBTMỰ*/ + + if(pCurFillLnk->FsfbLinInfo.TimeStmp.NumSendSse >= FSFB_SEND_SBT_NUM) + {/* SBTʱ */ + + + pCurFillLnk->FsfbLinInfo.RecvLinkStatus = Fsfb_Halt;/* ״̬ΪHALT */ + pCurFillLnk->FsfbLinInfo.TimeStmp.NumSendSse = 0; /*SBT */ + } + else + {/* SBTʱ SBT */ + pCurFillLnk->FsfbLinInfo.RecvLinkStatus = Fsfb_SendBtm_Sbt;/* ״̬ΪSBT֡ */ + pCurFillLnk->FsfbLinInfo.TimeStmp.NumSendSse++; + } + } + else + { + /* ʲô */ + } + + + } + else /* жӦ */ + { + /* ʲô */ + } + } + else + { + /* ʲô */ + } + pCurFillLnk = pCurFillLnk->NextNode; + } + + retVal =1; + return retVal; +} +/*********************************************************************** + * : FsfbWriteToVarArray + * : ͨŽڵдм + * : + * + * -------------------------------------------------------------- + * VarArray UINT8* OUT SSR + * pFsfbStruct FSFB_INFO_STRU * INOUT Эͳһṹ + * ֵ : мݳ + ***********************************************************************/ +UINT16 FsfbWriteToVarArray(UINT8 *VarArray,FSFB_INFO_STRU *pFsfbStruct) +{ + UINT16 index=0; + UINT16 varArrayLen = 0;/*мݳ*/ + Fsfb_Lnk_Info_Node_Stru* CurFillLnk;/*嵱ǰָ;*/ + + index =2; + /* ·ڵ */ + /*·Ϣ*/ + CurFillLnk = pFsfbStruct->LnkHead;/*λ·ͷָ*/ + /* ҪӼ¼ıͷ */ + while (CurFillLnk != NULL) + { + if((pFsfbStruct->VarArraySize - index) >= FSFB_VAR_NODE_LEN) + { + /*ض·м*/ + FsfbLnkNodeInfo2VarArray(CurFillLnk,&VarArray[index]); + index +=FSFB_VAR_NODE_LEN; + /*¼¼,·״̬Ϣ*/ + /*ǰ·Ľڵһڵ*/ + CurFillLnk = CurFillLnk->NextNode; + } + else + { + break; + } + + } + /* д볤 2ֽ */ + ShortToChar((UINT16)(index-2),VarArray); + + varArrayLen = index; + return varArrayLen; +} + + /*********************************************************************** + * : FsfbVarArray2LnkNodeInfo + * : мһĽڵϢдָͨŽڵϢ + * : + * + * ----------------------------------------------------------------------------- + * VarArray const UINT8* IN м + * pNode Fsfb_Lnk_Info_Node_Stru* OUT ͨŽڵָ + * + * ʹƣӦָĿռɵ÷֤ + * ֵ : + ***********************************************************************/ +void FsfbVarArray2LnkNodeInfo(const UINT8* VarArray, Fsfb_Lnk_Info_Node_Stru* pNode) + { + UINT16 index = 0; + FsfbLinkInfoStru *pFsfbLnkInfo = &pNode->FsfbLinInfo; + ComTimeStampStru *pTmStmp = &pNode->FsfbLinInfo.TimeStmp; + FsfbNodeParamInfoStru *pFsfbNodeParmInfo = &pNode->FsfbLinInfo.LocalNode; + UINT8 i = 0,j = 0; + /* -------- Lnk_Info_Node_Stru_WL ------ */ + /* Էʶ 2ֽ */ + pNode->DestDevName = ShortFromChar(&VarArray[index]); + index +=2; + + /* application Type */ + pNode->Applcat =VarArray[index++]; + /* Ƿ͵ı 1ֽ */ + pNode->IsSendFlag=VarArray[index++]; + + /* -------- FsfbLinkInfoStru ---------- */ + /* սڵԴַ 2ֽ */ + pFsfbLnkInfo->rcvSrcAdd=ShortFromChar(&VarArray[index]); + index +=2; + /* ͽڵԴַ 2ֽ */ + pFsfbLnkInfo->sendSrcAdd=ShortFromChar(&VarArray[index]); + index +=2; + /* սڵĿַ 2ֽ */ + pFsfbLnkInfo->rcvDestAdd=ShortFromChar(&VarArray[index]); + index +=2; + /* ͽڵĿַ 2ֽ */ + pFsfbLnkInfo->sendDestAdd=ShortFromChar(&VarArray[index]); + index +=2; + /* ·״̬ 1ֽ */ + pFsfbLnkInfo->RecvLinkStatus = VarArray[index++]; + /* ·״̬ 1ֽ */ + pFsfbLnkInfo->SendLinkStatus = VarArray[index++]; + /* 1ֽ */ + pFsfbLnkInfo->NoRecvDataCycleNum = VarArray[index++]; + /* ޷Ӧ 1ֽ */ + pFsfbLnkInfo->NoAppDataCycleNum = VarArray[index++]; + + /* -------------- ʱϢ ----------- */ + /* ǰʱ 4ֽ*/ + pTmStmp->TC = LongFromChar(&VarArray[index]); + index += 4; + + /* ϴյıʱ 4ֽ */ + pTmStmp->LastLocalRecTC = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰڶӦʱ[0] 4ֽ */ + pTmStmp->NowTn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰڶӦʱ[1] 4ֽ */ + pTmStmp->NowTn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϸڶӦʱ[0] 4ֽ */ + pTmStmp->LastTn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϸڶӦʱ[1] 4ֽ */ + pTmStmp->LastTn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϴνյͷʱ 4ֽ */ + pTmStmp->LastRecvTCr = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰյͷʱ 4ֽ */ + pTmStmp->NowRecvTCr = LongFromChar(&VarArray[index]); + index += 4; + + /* SSEʱں 4ֽ */ + pTmStmp->SseTC = LongFromChar(&VarArray[index]); + index += 4; + + /* SSEʱڶӦʱ[0] 4ֽ */ + pTmStmp->SseTn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* SSEʱڶӦʱ[1] 4ֽ */ + pTmStmp->SseTn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* SSEĵĶԷʱ 4ֽ */ + pTmStmp->RecvSseTCe = LongFromChar(&VarArray[index]); + index += 4; + + /* յSSEʱSEQENQ[0] 4ֽ */ + pTmStmp->SeqEng[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* յSSEʱSEQENQ[1] 4ֽ */ + pTmStmp->SeqEng[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* SSE 1ֽ */ + pTmStmp->NumSendSse = VarArray[index++]; + + /* ϴͬ 4ֽ */ + pTmStmp->SsrTc = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] [0] 4ֽ */ + pTmStmp->NowSINIT_ADD_SID_XOR_Tn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] [1] 4ֽ */ + pTmStmp->NowSINIT_ADD_SID_XOR_Tn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϴյʱSINITr AND [SIDr ^ Tr(n)] [0] 4ֽ */ + pTmStmp->LastSINIT_ADD_SID_XOR_Tn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϴյʱSINITr AND [SIDr ^ Tr(n)] [1] 4ֽ */ + pTmStmp->LastSINIT_ADD_SID_XOR_Tn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* --------------------豸ڵϢ------------------------------ */ + /* SID[0] */ + pFsfbNodeParmInfo->SIDe[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* SID[1] */ + pFsfbNodeParmInfo->SIDe[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* SID[0] */ + pFsfbNodeParmInfo->SIDr[0] = LongFromChar( &VarArray[index]); + index += 4; + + /* SID[1] */ + pFsfbNodeParmInfo->SIDr[1] = LongFromChar( &VarArray[index]); + index += 4; + + /* SINIT[0] */ + pFsfbNodeParmInfo->SINITr[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* SINIT[1] */ + pFsfbNodeParmInfo->SINITr[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* SINIT[0] */ + pFsfbNodeParmInfo->SINITe[0] = LongFromChar( &VarArray[index]); + index += 4; + /* SINIT[1] */ + pFsfbNodeParmInfo->SINITe[1] = LongFromChar( &VarArray[index]); + index += 4; + + /* DATAVER[0]*/ + pFsfbNodeParmInfo->DATAVER[0] = LongFromChar( &VarArray[index]); + index += 4; + + /* DATAVER[1]*/ + pFsfbNodeParmInfo->DATAVER[1] = LongFromChar( &VarArray[index]); + index += 4; + + /* Data [0]汾 */ + pFsfbNodeParmInfo->NumDataVer[0] = VarArray[index++]; + + /* Data [1]汾 */ + pFsfbNodeParmInfo->NumDataVer[1] = VarArray[index++]; + + /* */ + pFsfbNodeParmInfo->DLost = VarArray[index++]; + + /* 涨ʱ䣨SSDelay */ + pFsfbNodeParmInfo->SSDelay = VarArray[index++]; + + /* ͬ */ + pFsfbNodeParmInfo->AntiDelayCount = VarArray[index++]; + + /* BSDijʱ */ + pFsfbNodeParmInfo->Tout = VarArray[index++]; + + /* ʧ */ + pFsfbNodeParmInfo->MaxLost = VarArray[index++]; + + /* ߲PREC_SINIT? */ + for(i = 0;i < 2;i++) + { + for(j = 0;j < 5;j++) + { + pFsfbNodeParmInfo->PREC_SINIT_K[i][j] = LongFromChar(&VarArray[index]); + index += 4; + } + + } + + /* ߲PREC_FIRSTSINIT[0] */ + pFsfbNodeParmInfo->PREC_FIRSTSINIT[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ߲PREC_FIRSTSINIT[1] */ + pFsfbNodeParmInfo->PREC_FIRSTSINIT[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* ߲ BSD̶ֵ */ + for(i = 0;i < 2;i++) + { + for(j = 0;j < 5;j++) + { + pFsfbNodeParmInfo->TSD_POST_RXDADA_K[i][j] = LongFromChar(&VarArray[index]); + index += 4; + } + + } + + + + + } +/*-------------------------------------------------------------------- + * ·ģⲿӿں End + *--------------------------------------------------------------------*/ + + +/*-------------------------------------------------------------------- + * ·ģڲ Start + *--------------------------------------------------------------------*/ + /*********************************************************************** + * : InitFSFBLnkInfo + * : ݷϢԼϢ·Ϣгʼ + * : + * + * -------------------------------------------------------------------------- + * devName UINT16 IN 豸 + * pRecvDsuLnkInf const DSU_FSFB_LINK_RINFO_STRU* IN Ϣ + * pOutputDsuLnkInf const DSU_FSFB_LINK_SINFO_STRU* IN Ϣ + * applyCat UINT8 IN + * pFsfbLnkStruct FsfbLinkInfoStru* INOUT ·Ϣṹ + * pFsfbStruct FSFB_INFO_STRU* INOUT Эͳһṹ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ + static UINT8 InitFSFBLnkInfo(UINT16 devName,const DSU_FSFB_LINK_RINFO_STRU* pRecvDsuLnkInf, + const DSU_FSFB_LINK_SINFO_STRU* pOutputDsuLnkInf, + UINT8 applyCat,FSFB_INFO_STRU* pFsfbStruct,FsfbLinkInfoStru* pFsfbLnkStruct) + { + UINT8 retVal = 0; + + if(pOutputDsuLnkInf == NULL) + { + retVal = 0; + } + else + { + /* */ + ComMemSet((UINT8 *)pFsfbLnkStruct,sizeof(FsfbLinkInfoStru),0); + + /* 趨ͨŽڵĻϢ */ + FsfbSetNodeParam(pRecvDsuLnkInf, pOutputDsuLnkInf, &pFsfbLnkStruct->LocalNode); + + pFsfbLnkStruct->rcvSrcAdd =pRecvDsuLnkInf->srcAdd; + pFsfbLnkStruct->rcvDestAdd =pRecvDsuLnkInf->destAdd; + pFsfbLnkStruct->sendSrcAdd = pOutputDsuLnkInf->srcAdd; + pFsfbLnkStruct->sendDestAdd = pOutputDsuLnkInf->destAdd; + if(applyCat == APPLCAT_BTM) + { + pFsfbLnkStruct->RecvLinkStatus =Fsfb_WaitBtm_SbtAbt; /* ·״̬趨ΪȴABT */ + pFsfbLnkStruct->SendLinkStatus = Fsfb_Halt; /* ·״̬趨Ϊж״̬ */ + + /* ѯӦTDM֡ʱϢ */ + SearchTdmFrameStamp(devName,APPLCAT_TDM,pFsfbStruct,&pFsfbLnkStruct->TimeStmp.TC); + + } + else if (applyCat == APPLCAT_TDM) + { + pFsfbLnkStruct->RecvLinkStatus = Fsfb_WaitSse; + pFsfbLnkStruct->SendLinkStatus=Fsfb_Halt; + pFsfbLnkStruct->TimeStmp.TC = 0; /* ǰʱΪ0 */ + } + else + { + retVal =1; + return retVal; + } + + pFsfbLnkStruct->NoRecvDataCycleNum = 0; /* ʼΪ0 */ + pFsfbLnkStruct->NoAppDataCycleNum = 0; /* ޷ӦʼΪ0 */ + + /* ǰڶӦʱͨŵķͷSIDʼ */ + pFsfbLnkStruct->TimeStmp.NowTn[0] = pFsfbLnkStruct->LocalNode.SIDr[0]; + pFsfbLnkStruct->TimeStmp.NowTn[1] = pFsfbLnkStruct->LocalNode.SIDr[1]; + retVal = 1; + } + return retVal; /* ̶1 */ + } + + + /*********************************************************************** + * : SearchTdmFrameStamp + * : 豸ƺApplycation Cateory,ȡǰ·ʱϢ + * : + * + * -------------------------------------------------------------------------- + * devName UINT16 IN 豸 + * applyCat UINT8 IN + * pFsfbStruct FSFB_INFO_STRU* INOUT Эͳһṹ + * stampTime UINT32* OUT ʱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static void SearchTdmFrameStamp(UINT16 devName,UINT8 applyCat,FSFB_INFO_STRU* pFsfbStruct,UINT32* stampTime) + { + Fsfb_Lnk_Info_Node_Stru* pTempLnkInfoNode = NULL; + /* ѯ·ڵ */ + pTempLnkInfoNode=FsfbSearchNodeByName(devName,applyCat,pFsfbStruct); + + if (pTempLnkInfoNode != NULL) + { + *stampTime = pTempLnkInfoNode->FsfbLinInfo.TimeStmp.TC; + } + else + { + *stampTime =0; + } + } + +/*********************************************************************** + * : FsfbCheckOutputDsuLnkInfo + * : DSUȡ÷ͷϢԴĿַǷһ¡ + * : + * + * -------------------------------------------------------------------------- + * srcAddr UINT16 IN Դַ + * destAddr UINT16 IN Ŀַ + * pOutputLnkInfo const DSU_FSFB_LINK_SINFO_STRU IN ͷϢ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 FsfbCheckOutputDsuLnkInfo(UINT16 srcAddr,UINT16 destAddr, + const DSU_FSFB_LINK_SINFO_STRU *pOutputLnkInfo) +{ + UINT8 ret = 0; + + if(pOutputLnkInfo ==NULL) + { + ret = 0; + } + else + { + if((pOutputLnkInfo->srcAdd == srcAddr)&&(pOutputLnkInfo->destAdd == destAddr)) + { + ret = 1; + } + else + { + /* ش */ + ret = 0; + } + } + return ret; +} + +/*********************************************************************** +* : FsfbSetNodeParam +* : ÿȡͨŽڵϢõָ豸ڵϢṹ档 +* : +* +* -------------------------------------------------------------------------- +* pRecvDsuLnkInf const DSU_FSFB_LINK_RINFO_STRU* IN Ϣ +* pOutputDsuLnkInf const DSU_FSFB_LINK_SINFO_STRU* IN Ϣ +* pNodeParam FsfbNodeParamInfoStru* +* +* ֵ : UINT8 1 0:󷵻 +***********************************************************************/ +static UINT8 FsfbSetNodeParam(const DSU_FSFB_LINK_RINFO_STRU* pRecvDsuLnkInf, + const DSU_FSFB_LINK_SINFO_STRU* pOutputDsuLnkInf, + FsfbNodeParamInfoStru *pNodeParam) +{ + UINT8 chan = 0; /* źŵ */ + UINT8 index = 0; + UINT8 retVal = 0; + + if((pRecvDsuLnkInf == NULL)||(pOutputDsuLnkInf== NULL)) + { + retVal = 0; + } + else + { + for(chan = 0; chan < 2; chan++) + { + /* ͽڵϢ */ + pNodeParam->SIDe[chan] = pOutputDsuLnkInf->SID_NUMBER_R[chan]; /* շSID */ + pNodeParam->SIDr[chan] = pOutputDsuLnkInf->SID_NUMBER_E[chan]; /* ͷSID */ + pNodeParam->SINITr[chan] = pOutputDsuLnkInf->SINIT_NUMBER[chan]; /* ͷSINIT */ + pNodeParam->SINITe[chan] = pRecvDsuLnkInf->SINIT_NUMBER[chan]; /* SINIT */ + pNodeParam->DATAVER[chan] = pOutputDsuLnkInf->DATAVER_1_Number[chan]; /* DATAVER */ + pNodeParam->NumDataVer[chan] = pOutputDsuLnkInf->DATANUM[chan]; /* Data 汾 */ + + /* ֵ߲ */ + pNodeParam->PREC_FIRSTSINIT[chan] = pRecvDsuLnkInf->PREC_FIRSTSINIT[chan]; /* ߲PREC_FIRSTSINIT */ + for( index = 0; index <5; index++) + { + pNodeParam->PREC_SINIT_K[chan][index] = pRecvDsuLnkInf->PREC_SINIT_K[chan][index]; /* ߲PREC_SINIT */ + pNodeParam->TSD_POST_RXDADA_K[chan][index] = pRecvDsuLnkInf->POST_RXDADA_K[chan][index]; /* ߲ BSD̶ֵ */ + } + } + + /* շϢ */ + pNodeParam->DLost = pRecvDsuLnkInf->DLost; /* */ + pNodeParam->SSDelay = pRecvDsuLnkInf->WSsrOut; /* 涨ʱ䣨SSDelay */ + pNodeParam->AntiDelayCount = pRecvDsuLnkInf->AntiDelayCount; /* ͬ */ + pNodeParam->Tout = pRecvDsuLnkInf->TOut ; /* BSDijʱ */ + pNodeParam->MaxLost = pRecvDsuLnkInf->MaxLost; /* ʧ */ + retVal = 1; + + } + return retVal; +} + +/*********************************************************************** + * : FsfbCheckRecvDsuLnkInfo + * : DSUȡýշϢеԴĿַԴĿĵַǷһ¡ + * : + * + * -------------------------------------------------------------------------- + * srcAddr UINT16 IN Դַ + * destAddr UINT16 IN Ŀĵַ + * pRecvLnkInfo const DSU_FSFB_LINK_RINFO_STRU IN Ϣ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 FsfbCheckRecvDsuLnkInfo(UINT16 srcAddr,UINT16 destAddr, + const DSU_FSFB_LINK_RINFO_STRU *pRecvLnkInfo) +{ + UINT8 retVal = 0; + + /* ԴַĿĵַǷһ */ + if((srcAddr == pRecvLnkInfo->srcAdd)&&(destAddr == pRecvLnkInfo->destAdd)) + { + retVal = 1; + } + else + { + /* ش */ + retVal = 0; + } + return retVal; +} + +/*********************************************************************** +* : FsfbCheckInputAddr +* : ݱ豸ԼԷ豸ʶ ȡõıΪϢǷȷ +* : +* +* ------------------------------------------------------------------------ +* LocalDevName UINT16 IN ʶ +* destName UINT16 IN Էʶ +* pRecvLnkInfo const DSU_FSFB_LINK_RINFO_STRU* IN Ϣ +* +* ֵ : UINT8 1 0󷵻 +***********************************************************************/ +static UINT8 FsfbCheckInputAddr(UINT16 LocalDevName,UINT16 destName,const DSU_FSFB_LINK_RINFO_STRU *pRecvLnkInfo) +{ + UINT8 ret = 0; + UINT8 locType =0; + UINT8 destType = 0; + UINT8 id =0; + + if (pRecvLnkInfo== NULL) + { + return ret; + } + + if (pRecvLnkInfo->DestName != LocalDevName) + { + return ret; + } + ComDevName2TypeId(LocalDevName,&locType,&id); + ComDevName2TypeId(destName,&destType,&id); + /* + * Էʶͱıʶ Ӧøַ + */ + if(((locType ==FSFB_CI_DEV)&&(destType==FSFB_LEU_DEV))||((locType ==FSFB_LEU_DEV)&&(destType==FSFB_CI_DEV))) + { + ret = 1; + } + else + { + ret=0; + } + return ret; +} + + + + +/*********************************************************************** + * : FsfbLnkNodeInfo2VarArray + * : ͨŽڵϢд뵽м档 + * : + * + * ----------------------------------------------------------------------------- + * pNode const Fsfb_Lnk_Info_Node_Stru* IN ͨŽڵָ + * VarArray UINT8* OUT м + * + * ֵ : + ***********************************************************************/ +static void FsfbLnkNodeInfo2VarArray(const Fsfb_Lnk_Info_Node_Stru* pNode, UINT8* VarArray) + { + UINT16 index = 0; + const FsfbLinkInfoStru *pFsfbLnkInfo = &pNode->FsfbLinInfo; + const ComTimeStampStru *pTmStmp = &pNode->FsfbLinInfo.TimeStmp; + const FsfbNodeParamInfoStru *pFsfbNodeParmInfo = &pNode->FsfbLinInfo.LocalNode; + UINT8 i = 0,j = 0; + + /* -------- Fsfb_Lnk_Info_Node_Stru ------ */ + /* Էʶ 2ֽ */ + ShortToChar(pNode->DestDevName, &VarArray[index]); + index +=2; + + /* application cat 1ֽ */ + VarArray[index] = pNode->Applcat; + index +=1; + + /* Ƿ͵ı 1ֽ */ + VarArray[index] = pNode->IsSendFlag; + index +=1; + + /* -------- FsfbLinkInfoStru ---------- */ + /* սڵԴַ 2ֽ */ + ShortToChar(pFsfbLnkInfo->rcvSrcAdd,&VarArray[index]); + index +=2; + /* ͽڵԴַ 2ֽ */ + ShortToChar(pFsfbLnkInfo->sendSrcAdd,&VarArray[index]); + index +=2; + /* սڵĿַ 2ֽ */ + ShortToChar(pFsfbLnkInfo->rcvDestAdd,&VarArray[index]); + index +=2; + /* ͽڵĿַ 2ֽ */ + ShortToChar(pFsfbLnkInfo->sendDestAdd,&VarArray[index]); + index +=2; + + /* ·״̬ 1ֽ */ + VarArray[index++] = pFsfbLnkInfo->RecvLinkStatus; + /* ·״̬ 1ֽ */ + VarArray[index++] = pFsfbLnkInfo->SendLinkStatus; + /* 1ֽ */ + VarArray[index++] = pFsfbLnkInfo->NoRecvDataCycleNum; + /* ޷Ӧ 1ֽ */ + VarArray[index++] = pFsfbLnkInfo->NoAppDataCycleNum; + + /* -------------- ʱϢ ----------- */ + /* ǰʱ 4ֽ*/ + LongToChar(pTmStmp->TC, &VarArray[index]); + index += 4; + + /* ϴյıʱ 4ֽ */ + LongToChar(pTmStmp->LastLocalRecTC, &VarArray[index]); + index += 4; + + /* ǰڶӦʱ[0] 4ֽ */ + LongToChar(pTmStmp->NowTn[0], &VarArray[index]); + index += 4; + + /* ǰڶӦʱ[1] 4ֽ */ + LongToChar(pTmStmp->NowTn[1], &VarArray[index]); + index += 4; + + /* ϸڶӦʱ[0] 4ֽ */ + LongToChar(pTmStmp->LastTn[0], &VarArray[index]); + index += 4; + + /* ϸڶӦʱ[1] 4ֽ */ + LongToChar(pTmStmp->LastTn[1], &VarArray[index]); + index += 4; + + /* ϴνյͷʱ 4ֽ */ + LongToChar(pTmStmp->LastRecvTCr, &VarArray[index]); + index += 4; + + /* ǰյͷʱ 4ֽ */ + LongToChar(pTmStmp->NowRecvTCr, &VarArray[index]); + index += 4; + + /* SSEʱں 4ֽ */ + LongToChar(pTmStmp->SseTC, &VarArray[index]); + index += 4; + + /* SSEʱڶӦʱ[0] 4ֽ */ + LongToChar(pTmStmp->SseTn[0], &VarArray[index]); + index += 4; + + /* SSEʱڶӦʱ[1] 4ֽ */ + LongToChar(pTmStmp->SseTn[1], &VarArray[index]); + index += 4; + + /* SSEĵĶԷʱ 4ֽ */ + LongToChar(pTmStmp->RecvSseTCe, &VarArray[index]); + index += 4; + + /* յSSEʱSEQENQ[0] 4ֽ */ + LongToChar(pTmStmp->SeqEng[0], &VarArray[index]); + index += 4; + + /* յSSEʱSEQENQ[1] 4ֽ */ + LongToChar(pTmStmp->SeqEng[1], &VarArray[index]); + index += 4; + + /* SSE 1ֽ */ + VarArray[index++] = pTmStmp->NumSendSse; + + /* ϴͬ 4ֽ */ + LongToChar(pTmStmp->SsrTc, &VarArray[index]); + index += 4; + + /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] [0] 4ֽ */ + LongToChar(pTmStmp->NowSINIT_ADD_SID_XOR_Tn[0], &VarArray[index]); + index += 4; + + /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] [1] 4ֽ */ + LongToChar(pTmStmp->NowSINIT_ADD_SID_XOR_Tn[1], &VarArray[index]); + index += 4; + + /* ϴյʱSINITr AND [SIDr ^ Tr(n)] [0] 4ֽ */ + LongToChar(pTmStmp->LastSINIT_ADD_SID_XOR_Tn[0], &VarArray[index]); + index += 4; + + /* ϴյʱSINITr AND [SIDr ^ Tr(n)] [1] 4ֽ */ + LongToChar(pTmStmp->LastSINIT_ADD_SID_XOR_Tn[1], &VarArray[index]); + index += 4; + + /* --------------------豸ڵϢ------------------------------ */ + /* SID[0] */ + LongToChar(pFsfbNodeParmInfo->SIDe[0], &VarArray[index]); + index += 4; + + /* SID[1] */ + LongToChar(pFsfbNodeParmInfo->SIDe[1], &VarArray[index]); + index += 4; + + /* SID[0] */ + LongToChar(pFsfbNodeParmInfo->SIDr[0], &VarArray[index]); + index += 4; + + /* SID[1] */ + LongToChar(pFsfbNodeParmInfo->SIDr[1], &VarArray[index]); + index += 4; + + /* SINIT[0] */ + LongToChar(pFsfbNodeParmInfo->SINITr[0], &VarArray[index]); + index += 4; + + /* SINIT[1] */ + LongToChar(pFsfbNodeParmInfo->SINITr[1], &VarArray[index]); + index += 4; + + /* SINIT[0] */ + LongToChar(pFsfbNodeParmInfo->SINITe[0], &VarArray[index]); + index += 4; + /* SINIT[1] */ + LongToChar(pFsfbNodeParmInfo->SINITe[1], &VarArray[index]); + index += 4; + + /* DATAVER[0]*/ + LongToChar(pFsfbNodeParmInfo->DATAVER[0], &VarArray[index]); + index += 4; + + /* DATAVER[1]*/ + LongToChar(pFsfbNodeParmInfo->DATAVER[1],&VarArray[index]); + index += 4; + + /* Data [0]汾 */ + VarArray[index++] = pFsfbNodeParmInfo->NumDataVer[0]; + + /* Data [1]汾 */ + VarArray[index++] = pFsfbNodeParmInfo->NumDataVer[1]; + + /* */ + VarArray[index++] = pFsfbNodeParmInfo->DLost; + + /* 涨ʱ䣨SSDelay */ + VarArray[index++] = pFsfbNodeParmInfo->SSDelay; + + /* ͬ */ + VarArray[index++] = pFsfbNodeParmInfo->AntiDelayCount; + + /* BSDijʱ */ + VarArray[index++] = pFsfbNodeParmInfo->Tout; + + /* ʧ */ + VarArray[index++] = pFsfbNodeParmInfo->MaxLost; + + /* ߲PREC_SINIT_K */ + for(i = 0;i < 2;i++) + { + for(j = 0;j < 5;j++) + { + LongToChar(pFsfbNodeParmInfo->PREC_SINIT_K[i][j], &VarArray[index]); + index += 4; + } + + } + + /* ߲PREC_FIRSTSINIT[0] */ + LongToChar(pFsfbNodeParmInfo->PREC_FIRSTSINIT[0], &VarArray[index]); + index += 4; + + /* ߲PREC_FIRSTSINIT[1] */ + LongToChar(pFsfbNodeParmInfo->PREC_FIRSTSINIT[1], &VarArray[index]); + index += 4; + + /* ߲ BSD̶ֵ */ + for(i = 0;i < 2;i++) + { + for(j = 0;j < 5;j++) + { + LongToChar(pFsfbNodeParmInfo->TSD_POST_RXDADA_K[i][j], &VarArray[index]); + index += 4; + } + + } + + } + + + /*-------------------------------------------------------------------- + * ·ģڲ End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + + diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbLnkNodeMgr.h b/TSCP/src/protocol/fsfb/common_fsfb/FsfbLnkNodeMgr.h new file mode 100644 index 0000000..bf8e437 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbLnkNodeMgr.h @@ -0,0 +1,189 @@ +/******************************************************** +* +* ļ FsfbLnkNodeMgr.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ䣺 2013.11.25 +* VOBC +* FSFBЭͨŽڵصĺ +* ʹע⣺ +* +* ޸ļ¼ +* 2013.11.25 +* 2014.5.22 +* ޸ݣмڵijFSFB_VAR_NODE_LEN88 Ϊ228 +* ޸ɣˢϢ +* ------------ ------ --------------- + +* +********************************************************/ + +#ifndef _FSFB_LNK_NODE_MGR_H_ +#define _FSFB_LNK_NODE_MGR_H_ + +#include "FsfbProtclConfigMessage.h" +#include "fsfbProtclStruct.h" + +#define FSFB_VAR_NODE_LEN 228 /* мһڵij todo */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------- + * FSFBڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** +* : SearchNodeByName +* : ָĶԷ豸ʶͱͲѯӦͨŽڵǷڡ +* 򷵻ضӦͨŽڵָ룬򷵻NULL +* : +* +* -------------------------------------------------------------------------- +* destName UINT16 IN Է豸ʶ +* applyCat UINT8 IN application categy +* pFsfbStruct FSFB_INFO_STRU * Эͳһṹ +* ֵ : Fsfb_Lnk_Info_Node_Stru* ͨŽڵָ룬 NULL: +***********************************************************************/ +Fsfb_Lnk_Info_Node_Stru* FsfbSearchNodeByName(UINT16 destName,UINT8 applyCat,FSFB_INFO_STRU *pFsfbStruct); + +/*********************************************************************** +* : FsfbOutputReplaceLnkNode +* : ݱ豸ͺͶԷ豸ԼͣȡöӦڵϢ +* ͨŽڵϢʼ +* : +* +* ------------------------------------------------------------- +* locName UINT16 IN 豸 +* destName UINT16 IN Է豸 +* applyCat UINT8 IN +* pPLnkNodeInfo Lnk_Info_Node_Stru** OUT ͨŽڵ +* pFsfbStruct FSFB_INFO_STRU * INOUT ͳһṹ +* ֵ : UINT8 1 0󷵻 +* ʹ Ϊģ飬ַָͨŽڵ㲻ʱ +* +***********************************************************************/ +UINT8 FsfbOutputReplaceLnkNode(UINT16 locName,UINT16 destName,UINT8 applyCat,Fsfb_Lnk_Info_Node_Stru **pPLnkNodeInfo, + FSFB_INFO_STRU *pFsfbStruct); +/*********************************************************************** +* : FsfbInsertLnkNode +* : ͨɸǵĽڵ㡣 +* : +* +* -------------------------------------------------------------- +* pFsfbStruct FSFB_INFO_STRU * IN Эͳһṹ +* devName UINT16 IN 豸 +* applyCat UINT8 IN +* ֵ : Fsfb_Lnk_Info_Node_Stru* NULL쳣 NULLͨŽڵ +***********************************************************************/ +Fsfb_Lnk_Info_Node_Stru* FsfbInsertLnkNode(FSFB_INFO_STRU *pFsfbStruct,UINT16 devName,UINT8 applyCat); +/*********************************************************************** +* : FsfbCheckInfoAddr +* : ԴַĿĵַж·еǷһ¡ +* : +* +* ------------------------------------------------------------------------ +* srcAddr UINT16 IN Դַ +* DestAddr UINT16 IN Ŀַ +* pLnkNodeStru const Fsfb_Lnk_Info_Node_Stru* IN ·Ϣ +* +* ֵ : UINT8 1һ 0һ +***********************************************************************/ +UINT8 FsfbCheckInfoAddr(UINT16 srcAddr,UINT16 DestAddr,Fsfb_Lnk_Info_Node_Stru* pLnkNodeStru); +/*********************************************************************** + * : FsfbUptLnkNodeInfoBySSE + * : SSEϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pAppData UINT8* IN һ֡ĸʽ + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * + + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbUptLnkNodeInfoBySSE(UINT8* pAppData,Fsfb_Lnk_Info_Node_Stru *pLnkNode); +/*********************************************************************** + * : FsfbUptLnkNodeInfoBySsr + * : SSRϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pAppData UINT8* IN һ֡ĸʽ + * applyCat UINT8 IN applycation cate + * pFsfbStrut FSFB_INFO_STRU* IN FSFBЭͳһṹ + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 FsfbUptLnkNodeInfoBySsr(UINT8* pAppData,UINT8 applyCat,FSFB_INFO_STRU* pFsfbStrut,Fsfb_Lnk_Info_Node_Stru *pLnkNode); +/*********************************************************************** + * : FsfbUptLnkNodeInfoByAbt + * : ABTϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pAppData UINT8* IN һ֡ĸʽ + * pFsfbStrut FSFB_INFO_STRU* IN FSFBЭͳһṹ + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 FsfbUptLnkNodeInfoByAbt(UINT8* pAppData,FSFB_INFO_STRU* pFsfbStrut,Fsfb_Lnk_Info_Node_Stru *pLnkNode); +/*********************************************************************** + * : FsfbUptLnkNodeInfoByEbt + * : EBTϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * devName UINT16 IN 豸 + * pAppData UINT8* IN һ֡ĸʽ + * pFsfbStrut FSFB_INFO_STRU* IN FSFBЭͳһṹ + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbUptLnkNodeInfoByEbt(UINT16 devName,UINT8* pAppData,FSFB_INFO_STRU* pFsfbStrut,Fsfb_Lnk_Info_Node_Stru *pLnkNode); +/*********************************************************************** + * : FsfbRecvLnkStatusMng + * : ͨŽڵϢ״̬仯 + * : + * + * -------------------------------------------------------------- + * pFsfbStruct FSFB_INFO_STRU* INOUT FSFBЭͳһṹ + * ֵ : 1 + ***********************************************************************/ +UINT8 FsfbRecvLnkStatusMng(FSFB_INFO_STRU* pFsfbStruct); +/*********************************************************************** + * : FsfbWriteToVarArray + * : ͨŽڵдм + * : + * + * -------------------------------------------------------------- + * VarArray UINT8* OUT SSR + * pFsfbStruct FSFB_INFO_STRU * INOUT Эͳһṹ + * ֵ :FSFBЭм + ***********************************************************************/ +UINT16 FsfbWriteToVarArray(UINT8 *VarArray,FSFB_INFO_STRU *pFsfbStruct); + +/*********************************************************************** + * : FsfbVarArray2LnkNodeInfo + * : мһĽڵϢдָͨŽڵϢ + * : + * + * ----------------------------------------------------------------------------- + * VarArray const UINT8* IN м + * pNode Fsfb_Lnk_Info_Node_Stru* OUT ͨŽڵָ + * + * ʹƣӦָĿռɵ÷֤ + * ֵ : + ***********************************************************************/ +void FsfbVarArray2LnkNodeInfo(const UINT8* VarArray, Fsfb_Lnk_Info_Node_Stru* pNode); +/*-------------------------------------------------------------------- + * FSFBڲӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbMessageInfo.c b/TSCP/src/protocol/fsfb/common_fsfb/FsfbMessageInfo.c new file mode 100644 index 0000000..bd26383 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbMessageInfo.c @@ -0,0 +1,1431 @@ +/************************************************************************ +* +* ļ FsfbMessageInfo.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.05 +* +* FSFB/2Э֡ʽԼϢĺ궨 +* ʹע +* ޸ļ¼ +* 2014.05.14 +* ޸ݣ ArrordLnkInfoCreateFrameм˷BTD֡ABT֡ķ֧case Fsfb_SendBtm_BtdAbt: + ޸ɣ CIյBTD֡ʱӦLEUȷ֡ABT֡ +* 2014.05.14 +* ޸ݣ FsfbAnalysisBtdMsgڽյBTDϷ󣬽״̬Ϊ retLnkNodePtr->FsfbLinInfo.SendLinkStatus = Fsfb_SendBtm_BtdAbt; +* ޸ɣ CIյBTD֡ʱӦLEUȷ֡ABT֡ +* 2014.05.14 +* ޸ݣ CreateBtmMsgڴSBT֡ʱȡԷ״̬ͽ״̬ĸֵ +* ޸ɣ ڴ˺ֻ𴴽BTMģʽµ֡·״̬ά +* 2014.05.22 +* ޸ݣ ArrordLnkInfoCreateFrame()У״̬ΪFsfb_SendBtm_Btcʱ +* SSRBTCʱ״̬ΪFsfb_WaitBtm_BtcabtBTCABT +* ֻBTCʱ״̬ΪFsfb_WaitBtm_AbtOrSseLEUSSEBTCABT +* ·״̬ȫΪֹͣ +* ޸ɣ SSRBTCʱ״̬ΪԭΪFsfb_WaitBtm_SseabtǴ +* 2014.05.22 +* ޸ݣ FsfbAnalysisBtdMsgУ֤BTD֡ϷҪͱ־Ϊ1 +* ΪABT֡׼ +* ޸ɣ ֮ǰû÷ͱ־ +* 2014.05.22 +* ޸: CreateTsdOrSbtMsgУڷTSD֡ʱ״̬ӦΪȴSSE +* ޸ɣ ֮ǰΪ +* 2014.05.22 +* ޸ݣ CreateSseMsgУSSE֡ʱ״̬ΪȴSSR״̬Ϊ +* ޸ɣ ֮ǰû÷״ֹ̬ƵSSE +* 2014.05.22 +* ޸ݣ CreateSsrMsgУSSRΪBTMģʽµģ״̬ΪBTC״̬Ϊ1 +* ޸ɣ ֮ǰûнͱ־Ϊ1 +* 2014.08.05 +* ޸: FsfbAnalysisSseMsg()УCRCУ +* ޸: ֮ǰ©һCRC +* 2014.08.05 +* ޸: BTDзʱʧܵķ֧޸ķֵΪ0 +* ޸: ΪϲúУʧܵĻӦýݽӦá +* 2014.08.14 +* ޸ݣ AccordInfoCreateFrameDataж֡ӦݲֵijȽзС0򷵻ʧ +* ޸ɣ ֮ǰûжԴ˳Ƚз +* + +************************************************************************/ +#include "Convert.h" +#include "CRC32.h" +#include "CommonRecord.h" +#include "dsuFsfbFunc.h" +#include "FsfbConfig.h" +#include "FsfbRecordDelare.h" +#include "FsfbMessageInfo.h" +#include "FsfbLnkNodeMgr.h" +/*-------------------------------------------------------------------- + * Ĵģڲ Start + *--------------------------------------------------------------------*/ +static UINT8 CreateTsdOrSbtMsg(const UINT8 *pAppData,UINT16 DataLen,UINT8 applyCat, + UINT8 *OutTsdOrSbtMsg,UINT16* outPutDataLen, Fsfb_Lnk_Info_Node_Stru* pPNode); +static UINT8 CreateSseMsg(UINT8 applyCate,Fsfb_Lnk_Info_Node_Stru *pLnkNodeInfo,UINT8* outSseMsg); +static UINT8 CreateSsrMsg(UINT8 applyCate,Fsfb_Lnk_Info_Node_Stru *pLnkNodeInfo,UINT8* outSsrMsg); +static UINT8 CreateBtmMsg(const UINT8 *pAppData,UINT16 DataLen,UINT16 userDataLen,UINT8 messType, + UINT8 *OutBtmMsg, Fsfb_Lnk_Info_Node_Stru* pPNode); +static void SetFsfbMsgHead(UINT8 applCat,UINT8 MsgType, UINT16 SrcAddr, UINT16 DestAddr, UINT8 *OutFsfbMsg); +static UINT8 FsfbCheckBtdMsg(const UINT8 *pBtdMsg,Fsfb_Lnk_Info_Node_Stru *pLnkNode, FSFB_INFO_STRU *pFsfbStruct); +/* test todo */ +void BuildSbtFrameDf(Fsfb_Lnk_Info_Node_Stru* pNode,UINT8* pMsgDataBuff); +/*-------------------------------------------------------------------- + * Ĵģڲ End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * Ĵģⲿӿ Start + *--------------------------------------------------------------------*/ +/*********************************************************************** +* : AccordInfoCreateFrameData +* : ӦȷSBTTSD +* : +* +* -------------------------------------------------------------------------- +* pAppData UINT8* IN Ӧ +* DataLen UINT816 IN ݳ +* OutMsg UINT8* OUT ı +* outPutDataLen UINT16* OUT ij +* pPNode Fsfb_Lnk_Info_Node_Stru** OUT ·Ϣ +* pFsfbStru FSFB_INFO_STRU * INOUT Эͳһṹ +* ֵ : UINT8* :1: 1:󷵻 +***********************************************************************/ +UINT8 AccordInfoCreateFrameData(const UINT8 *pAppData,UINT16 DataLen, + UINT8 *OutMsg,UINT16* outPutDataLen,Fsfb_Lnk_Info_Node_Stru** pPNode,FSFB_INFO_STRU *pFsfbStru) +{ + UINT8 retVal =0; + UINT16 destDevName = 0;/* Է豸 */ + UINT16 localDevName =0; /* 豸 */ + UINT8 applycat =0; + UINT16 index=0; + UINT16 msgLen =0; + UINT8 *RecordArray = pFsfbStru->RecordArray; /* ¼ */ + UINT16 RecordSize = pFsfbStru->RecordArraySize; /* ¼С */ + Fsfb_Lnk_Info_Node_Stru *pTmpNode = NULL; /* ͨŽڵָ */ + const UINT8 DEST_TYPE_APP_QUE_POS = 2; /* ӦòбԷ͵λ */ + const UINT8 DEST_ID_APP_QUE_POS = DEST_TYPE_APP_QUE_POS+1; /* ӦòбԷIDλ */ + const UINT8 DEST_APP_COMMAND_POS = DEST_ID_APP_QUE_POS+1; /* ӦòбԷIDλ */ + const UINT8 DATA_APP_QUE_POS = DEST_APP_COMMAND_POS+1; /* ӦòбӦݵλ */ + + ComTypeId2DevName(pFsfbStru->LocalType, pFsfbStru->LocalID, &localDevName); + /* + * ------------------------------------------------------------ + * ݳ | DestType | DestID | CommandType |Ӧ | + * 2ֽ | 1ֽ | 1ֽ | 1ֽ | n | + * ------------------------------------------------------------ + */ + + /*Է豸 */ + ComTypeId2DevName(pAppData[DEST_TYPE_APP_QUE_POS], pAppData[DEST_ID_APP_QUE_POS], &destDevName); + msgLen = DataLen-DATA_APP_QUE_POS; + +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"IN:\n"); + PrintFiles(RecordArray,RecordSize,"LocalName:"); + PrintFileU16Hex(RecordArray,RecordSize,localDevName); /* 豸 */ + PrintFiles(RecordArray,RecordSize,"\tDestName:"); + PrintFileU16Hex(RecordArray,RecordSize,destDevName); /* Է豸 */ + PrintFiles(RecordArray,RecordSize,"\tDataLen:"); + PrintFileU16Hex(RecordArray,RecordSize,msgLen); /* Ӧݳ */ + PrintFiles(RecordArray,RecordSize,"\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray,RecordSize,FSFB_MSG_IN_TAG); /* һϢ֡ʼʶ */ + PrintRecArray2ByteB(RecordArray,RecordSize,localDevName); /* 豸 */ + PrintRecArray2ByteB(RecordArray,RecordSize,destDevName); /* Է豸 */ + PrintRecArray2ByteB(RecordArray,RecordSize,msgLen); /* Ӧݳ */ +#endif + + if(msgLen < 0) + {/*֡ݳȲϷ*/ + retVal = 0; + } + else + { + /* */ + applycat =pAppData[DEST_APP_COMMAND_POS]; + if((applycat== APPLCAT_TDM)||(applycat==APPLCAT_BTM)) + { + /* ѯӦͨŽڵǷ */ + pTmpNode = FsfbSearchNodeByName(destDevName,applycat,pFsfbStru); + if(NULL == pTmpNode) /* ͨŽڵ㲻 */ + { + /* ݵַĸǽڵ㣬ڵ㸲 */ + retVal =FsfbOutputReplaceLnkNode(localDevName,destDevName,applycat,&pTmpNode,pFsfbStru); + } + else /* ͨŽڵ */ + { + /* */ + retVal =1; + } + if (retVal != 0) + { + (*pPNode) = pTmpNode; /* ͨŽڵָ뱣浽ָ */ + /* ֽڵij */ + /*ShortToChar(msgLen+2,&OutMsg[index]);*/ + index = index+2; + /* 1ֽڵ豸*/ + OutMsg[index++]=pAppData[DEST_TYPE_APP_QUE_POS]; + + /* 1ֽڵ豸ID */ + OutMsg[index++]=pAppData[DEST_ID_APP_QUE_POS]; + /* ֡TSDSBT֡ */ + retVal=CreateTsdOrSbtMsg(&pAppData[DATA_APP_QUE_POS],msgLen,applycat,&OutMsg[index],outPutDataLen,pTmpNode); + index+=(*outPutDataLen); + *outPutDataLen +=4; + + /* ֽڵij */ + ShortToChar(index-2,OutMsg); + } + else + { + retVal =0; + } + } + else + { + retVal = 0; + } + } + /* Ϣ֡ */ + return retVal; +} + +/*********************************************************************** +* : ArrordLnkInfoCreateFrame +* : ·зͽڵ״̬齨֡ʽ +* : +* +* ------------------------------------------------------------------------------- +* pFsfbStruct FSFB_INFO_STRU* IN ͳһṹ +* outMsg UINT8* OUT FSFDϢ֡ +* datalen UINT16* OUT Ϣ + +* ֵ : UINT8 1 0󷵻 +***********************************************************************/ +/* todo */ +UINT8 ArrordLnkInfoCreateFrame(FSFB_INFO_STRU* pFsfbStruct,UINT8* outMsg,UINT16* datalen) +{ + UINT8 retVal =0; + UINT16 index = 0; + UINT16 msgLen =0; + UINT8 startFlag = 0; + Fsfb_Lnk_Info_Node_Stru* CurFillLnk;/*嵱ǰָ;*/ + CurFillLnk=pFsfbStruct->LnkHead; + + while(CurFillLnk != NULL) + { + + switch(CurFillLnk->Applcat) + { + case APPLCAT_TDM: + if (CurFillLnk->FsfbLinInfo.SendLinkStatus == Fsfb_SendSSR) + { + LnkInfoBuildFrame(CurFillLnk->DestDevName,SSR_SIZE+2,&outMsg[index]); + index+=4; + /* SSR ֡ */ + retVal=CreateSsrMsg(APPLCAT_TDM,CurFillLnk,&outMsg[index]); + index+=SSR_SIZE; + } + else + { + retVal =1; + } + break; + case APPLCAT_BTM: + if (CurFillLnk->IsSendFlag ) + { + switch(CurFillLnk->FsfbLinInfo.SendLinkStatus) + { + case Fsfb_SendSSR: + /* SSR ֡ */ + LnkInfoBuildFrame(CurFillLnk->DestDevName,SSR_SIZE+2,&outMsg[index]); + index+=4; + retVal = CreateSsrMsg(APPLCAT_BTM,CurFillLnk,&outMsg[index]); + index +=SSR_SIZE; + + startFlag = 1; + case Fsfb_SendBtm_Btc: + if (startFlag == 1) + { + CurFillLnk->FsfbLinInfo.RecvLinkStatus = Fsfb_WaitBtm_Btcabt; + CurFillLnk->FsfbLinInfo.SendLinkStatus = Fsfb_Halt; + CurFillLnk->IsSendFlag = 0; + } + else + { + CurFillLnk->FsfbLinInfo.RecvLinkStatus = Fsfb_WaitBtm_AbtOrSse; + CurFillLnk->FsfbLinInfo.SendLinkStatus = Fsfb_Halt; + CurFillLnk->IsSendFlag = 0; + } + LnkInfoBuildFrame(CurFillLnk->DestDevName,BTC_SIZE+2,&outMsg[index]); + index+=4; + /* 齨Ӧ */ + BuildBtcBody(pFsfbStruct->TmpDataBuff,&msgLen); + retVal = CreateBtmMsg(pFsfbStruct->TmpDataBuff,msgLen,BTC_DF_SIZE,FSFB_BTC_MSG,&outMsg[index],CurFillLnk); + index +=BTC_SIZE; + break; + case Fsfb_SendBtm_Abt: + msgLen =0; + LnkInfoBuildFrame(CurFillLnk->DestDevName,ABT_SIZE+2,&outMsg[index]); + index+=4; + retVal = CreateBtmMsg(pFsfbStruct->TmpDataBuff,msgLen,ABT_DF_SIZE,FSFB_ABT_MSG,&outMsg[index],CurFillLnk); + index +=ABT_SIZE; + break; + case Fsfb_SendBtm_BtdAbt: + msgLen =0; + LnkInfoBuildFrame(CurFillLnk->DestDevName,ABT_SIZE+2,&outMsg[index]); + index+=4; + retVal = CreateBtmMsg(pFsfbStruct->TmpDataBuff,msgLen,ABT_DF_SIZE,FSFB_ABT_MSG,&outMsg[index],CurFillLnk); + CurFillLnk->FsfbLinInfo.SendLinkStatus = Fsfb_SendBtm_Sbt; + index +=ABT_SIZE; + case Fsfb_SendBtm_Ebt: + msgLen =0; + LnkInfoBuildFrame(CurFillLnk->DestDevName,EBT_SIZE+2,&outMsg[index]); + index+=4; + retVal = CreateBtmMsg(pFsfbStruct->TmpDataBuff,msgLen,EBT_DF_SIZE,FSFB_EBT_MSG,&outMsg[index],CurFillLnk); + index +=EBT_SIZE; + break; + case Fsfb_SendSSE: + /* ֡ͷ */ + LnkInfoBuildFrame(CurFillLnk->DestDevName,SSE_SIZE+2,&outMsg[index]); + index+=4; + retVal = CreateSseMsg(APPLCAT_BTM,CurFillLnk,&outMsg[index]); + index +=SSE_SIZE; + break; + default: + retVal =1; + break; + } + } + else + { + retVal =1; + } +#if 0 + if (CurFillLnk->FsfbLinInfo.RecvLinkStatus == Fsfb_SendBtm_Sbt) + { + /* SBT֡ */ + LnkInfoBuildFrame(CurFillLnk->DestDevName,SBT_SIZE+2,&outMsg[index]); + index+=4; + retVal = CreateTsdOrSbtMsg(NULL,0,APPLCAT_BTM,&outMsg[index],&msgLen,CurFillLnk); + index +=SBT_SIZE; + } +#endif + break; + default: + retVal =1; + break; + } + + if(retVal == 0) + { + *datalen =0; + return retVal; + } + CurFillLnk = CurFillLnk->NextNode; + } + + *datalen = index; + return retVal; +} + +/*********************************************************************** +* : BuildBtcBody +* :齨BTC֡Body֡ +* : +* +* ------------------------------------------------------------------------------- +* pOutDataBuff UINT8* OUT +* outDataLen UINT16* OUT ݳ +* ֵ : +***********************************************************************/ +void BuildBtcBody(UINT8* pOutDataBuff,UINT16* outDataLen) +{ + UINT8 index=0; +#if 0 + /* ֽڵOperation Type */ + ShortToChar(0x0000,&pOutDataBuff[index]); + index+=2; + /* 2ֽڵBuffer Type */ + ShortToChar(0x000A,&pOutDataBuff[index]); + index+=2; + /* 2ֽڵSub_bufer Number Start */ + ShortToChar(0x0001,&pOutDataBuff[index]); + index+=2; + /* 2ֽڵNumber of Sub-buffer to Transmit */ + ShortToChar(0xFFFF,&pOutDataBuff[index]); + index+=2; +#else + /* ֽڵOperation Type */ + ShortToChar(0x0000,&pOutDataBuff[index]); + index+=2; + /* 2ֽڵBuffer Type */ + ShortToChar(0x0000,&pOutDataBuff[index]); + index+=2; + /* 2ֽڵSub_bufer Number Start */ + ShortToChar(0,&pOutDataBuff[index]); + index+=2; + /* 2ֽڵNumber of Sub-buffer to Transmit */ + ShortToChar(0,&pOutDataBuff[index]); + index+=2; +#endif + *outDataLen = index; +} + +/*********************************************************************** +* : LnkInfoBuildFrame +* :齨Ӧݵ֡ͷ +* : +* +* ------------------------------------------------------------------------------- +* devName UINT16 IN 豸 +* msgLen UINT16 IN ݳ +* pOutDataBuff UINT8* OUT +* ֵ : +***********************************************************************/ +void LnkInfoBuildFrame(UINT16 devName,UINT16 msgLen,UINT8* pOutDataBuff) +{ + /* ֽڵ֡ͷ */ + ShortToChar(msgLen,pOutDataBuff); + /* 1ֽڵ豸, 1ֽڵ豸ID */ + ComDevName2TypeId(devName,&pOutDataBuff[2],&pOutDataBuff[3]); +} + +/*********************************************************************** + * : FsfbAnalysisSseMsg + * : յSSEϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * devName UINT16* IN 豸 + * applyCat UINT8 IN application catory + * pAppData UINT8* IN Ӧ + * FSFB_INFO_STRU *pFsfbStruct FSFBͳһṹ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * ֵ : UINT8 1 0:󷵻 + ***********************************************************************/ +UINT8 FsfbAnalysisSseMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize) +{ + UINT8 retVal = 0; + + UINT16 calcCrc16=0; + UINT16 crc16 =0; + + UINT16 desAddr = 0; + UINT16 srcAddr =0; + Fsfb_Lnk_Info_Node_Stru *retLnkNodePtr = NULL; + + /* CRC 趨 */ + calcCrc16 = ComComputeMsgCRC16(pAppData,SSE_SIZE-FSFB_CRC_16_LEN); + crc16 = ShortFromCharLE(&pAppData[SSE_SIZE-FSFB_CRC_16_LEN]); + if(calcCrc16 == crc16) + { + srcAddr = ShortFromCharLE(&pAppData[FSFB_SRC_ADD_POS]); + desAddr = ShortFromCharLE(&pAppData[FSFB_DEST_ADD_POS]); + retLnkNodePtr = FsfbSearchNodeByName(devName,applyCat, pFsfbStruct); + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + retVal = FsfbCheckInfoAddr(srcAddr,desAddr,retLnkNodePtr); + if(0 == retVal) + { + /* һ ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + } + else /* ͨ */ + { + /* ·Ϣṹ */ + retVal = FsfbUptLnkNodeInfoBySSE(pAppData,retLnkNodePtr); + } + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Node Not Exist.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + } + } + else + { + /* ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_LEN_ERR|FSFB_ERROR_NULL); +#endif + } + retVal = 1; + return retVal; +} + + +/*********************************************************************** + * : FsfbAnalysisSsrMsg + * : յSSRϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * devName UINT16* IN 豸 + * applyCat UINT8 IN application catory + * pAppData UINT8* IN Ӧ + * pFsfbStruct FSFB_INFO_STRU* FSFBͳһṹ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbAnalysisSsrMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize) +{ + UINT8 retVal = 0; + UINT16 calcCrc16=0; + UINT16 crc16 =0; + Fsfb_Lnk_Info_Node_Stru *retLnkNodePtr = NULL; + UINT16 SrcAddr = 0; + UINT16 DesAddr = 0; + + /* CRC 趨 */ + calcCrc16 = ComComputeMsgCRC16(pAppData,SSR_SIZE-FSFB_CRC_16_LEN); + crc16 =ShortFromCharLE(&pAppData[SSR_SIZE-FSFB_CRC_16_LEN]); + /* ֤CRCǷϷ */ + if(crc16 == calcCrc16) + { + SrcAddr = ShortFromCharLE(&pAppData[FSFB_SRC_ADD_POS]); + DesAddr = ShortFromCharLE(&pAppData[FSFB_DEST_ADD_POS]); + retLnkNodePtr = FsfbSearchNodeByName(devName,applyCat,pFsfbStruct); + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + retVal = FsfbCheckInfoAddr(SrcAddr,DesAddr,retLnkNodePtr); + if(0 == retVal) + { + /* һ ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + } + else /* ͨ */ + { + /* ·Ϣṹ */ + retVal = FsfbUptLnkNodeInfoBySsr(pAppData,applyCat,pFsfbStruct,retLnkNodePtr); + if( 0 == retVal) + { + /* ³˵ǶӦSSR ô¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:SSR Msg Err.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_SSR_NOT_ILLEGAL|FSFB_ERROR_NULL); +#endif + } + else + { + /* ʲô */ + } + } + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + } + } + else /* Ȳ */ + { + /* ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_LEN_ERR|FSFB_ERROR_NULL); +#endif + } + + retVal = 1; + return retVal; +} + + + + + +/*********************************************************************** + * : FsfbAnalysisAbtMsg + * : յABTϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * devName UINT16* IN 豸 + * applyCat UINT8 IN application catory + * pAppData UINT8* IN Ӧ + * pFsfbStruct FSFB_INFO_STRU* FSFBͳһṹ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbAnalysisAbtMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize) +{ + UINT8 retVal = 0; + UINT16 calcCrc16=0; + UINT16 crc16 =0; + Fsfb_Lnk_Info_Node_Stru *retLnkNodePtr = NULL; + UINT16 SrcAddr = 0; + UINT16 DesAddr = 0; + UINT16 tmpSds =0; + + /* CRC 趨 */ + calcCrc16 = ComComputeMsgCRC16(pAppData,ABT_SIZE-FSFB_CRC_16_LEN); + crc16 =ShortFromCharLE(&pAppData[ABT_SIZE-FSFB_CRC_16_LEN]); + /* ֤CRCǷϷ */ + if(crc16 == calcCrc16) + { + /* ȫݴС */ + tmpSds = ShortFromCharLE(&pAppData[FSFB_DATA_SIZE_POS]); + if ((tmpSds != ABT_SDS)||(applyCat != APPLCAT_BTM)) + { + retVal = 0; + return retVal; + } + SrcAddr = ShortFromCharLE(&pAppData[FSFB_SRC_ADD_POS]); + DesAddr = ShortFromCharLE(&pAppData[FSFB_DEST_ADD_POS]); + retLnkNodePtr = FsfbSearchNodeByName(devName,applyCat,pFsfbStruct); + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + retVal = FsfbCheckInfoAddr(SrcAddr,DesAddr,retLnkNodePtr); + if(0 == retVal) + { + /* һ ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + + } + else /* ͨ */ + { + /* ·Ϣṹ */ + retVal = FsfbUptLnkNodeInfoByAbt(pAppData,pFsfbStruct,retLnkNodePtr); + if( 0 == retVal) + { + /* ³˵ǶӦSSR ô¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:SSR Msg Err.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_SSR_NOT_ILLEGAL|FSFB_ERROR_NULL); +#endif + + } + else + { + /* ʲô */ + } + } + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + + } + } + else /* Ȳ */ + { + /* ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_LEN_ERR|FSFB_ERROR_NULL); +#endif + } + + retVal = 1; + return retVal; +} + +/*********************************************************************** + * : FsfbAnalysisEbtMsg + * : յEBTϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * devName const UINT16 IN 豸 + * applyCat UINT8 IN application Catory + * pAppData UINT8* IN յ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * pFsfbStruct FSFB_INFO_STRU * IN FSFBЭͳһṹ + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbAnalysisEbtMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize) +{ + UINT8 retVal = 0; + UINT16 calcCrc16=0; + UINT16 crc16 =0; + Fsfb_Lnk_Info_Node_Stru *retLnkNodePtr = NULL; + UINT16 SrcAddr = 0; + UINT16 DesAddr = 0; + UINT16 tmpSds =0; + + /* CRC 趨 */ + calcCrc16 = ComComputeMsgCRC16(pAppData,EBT_SIZE-FSFB_CRC_16_LEN); + crc16 =ShortFromCharLE(&pAppData[EBT_SIZE-FSFB_CRC_16_LEN]); + /* ֤CRCǷϷ */ + if(crc16 == calcCrc16) + { + /* ȫݴС */ + tmpSds = ShortFromCharLE(&pAppData[FSFB_DATA_SIZE_POS]); + if ((tmpSds != EBT_SDS)||(applyCat != APPLCAT_BTM)) + { + retVal = 0; + return retVal; + } + SrcAddr = ShortFromCharLE(&pAppData[FSFB_SRC_ADD_POS]); + DesAddr = ShortFromCharLE(&pAppData[FSFB_DEST_ADD_POS]); + retLnkNodePtr = FsfbSearchNodeByName(devName,applyCat,pFsfbStruct); + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + retVal = FsfbCheckInfoAddr(SrcAddr,DesAddr,retLnkNodePtr); + if(0 == retVal) + { + /* һ ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + } + else /* ͨ */ + { + /* ·Ϣṹ */ + retVal = FsfbUptLnkNodeInfoByEbt(devName,pAppData,pFsfbStruct,retLnkNodePtr); + if( 0 == retVal) + { + /* ³˵ǶӦSSR ô¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:SSR Msg Err.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_SSR_NOT_ILLEGAL|FSFB_ERROR_NULL); +#endif + } + else + { + /* ʲô */ + } + } + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + } + } + else /* Ȳ */ + { + /* ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_LEN_ERR|FSFB_ERROR_NULL); +#endif + } + + retVal = 1; + return retVal; +} + +/*********************************************************************** + * : FsfbAnalysisBtdMsg + * : յBTDϢн֡ȡϢ, + Լݰһĸʽ + * : + * + * -------------------------------------------------------------- + * devName const UINT16 IN 豸 + * applyCat UINT8 IN application Catory + * pAppData UINT8* IN յ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * pFsfbStruct FSFB_INFO_STRU * IN FSFBЭͳһṹ + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbAnalysisBtdMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize) +{ + UINT8 retVal = 0; + UINT16 calcCrc16=0; /* żCRCֵ */ + UINT16 crc16 =0; /* еCRCֵ */ + Fsfb_Lnk_Info_Node_Stru *retLnkNodePtr = NULL; + UINT16 SrcAddr = 0; + UINT16 DesAddr = 0; + UINT16 localDevName =0; + UINT16 tmpSds =0; + + ComTypeId2DevName(pFsfbStruct->LocalType,pFsfbStruct->LocalID,&localDevName); + + /* CRC 趨 */ + calcCrc16 = ComComputeMsgCRC16(pAppData,BTD_SIZE-FSFB_CRC_16_LEN); + crc16 =ShortFromCharLE(&pAppData[BTD_SIZE-FSFB_CRC_16_LEN]); + /* ֤CRCǷϷ */ + if(crc16 == calcCrc16) + { + /* ȫݴС */ + tmpSds = ShortFromCharLE(&pAppData[FSFB_DATA_SIZE_POS]); + if ((tmpSds != BTD_SDS)||(applyCat != APPLCAT_BTM)) + { + retVal = 0; + return retVal; + } + SrcAddr = ShortFromCharLE(&pAppData[FSFB_SRC_ADD_POS]); + DesAddr = ShortFromCharLE(&pAppData[FSFB_DEST_ADD_POS]); + retLnkNodePtr = FsfbSearchNodeByName(devName,applyCat,pFsfbStruct); + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + retVal = FsfbCheckInfoAddr(SrcAddr,DesAddr,retLnkNodePtr); + if(0 == retVal) + { + /* һ ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NOT_NODE_ERR|FSFB_ERROR_NULL); +#endif + } + else /* ͨ */ + { + /* BTDϢǷϷ */ + retVal=FsfbCheckBtdMsg(pAppData,retLnkNodePtr,pFsfbStruct); + if (retVal == 1) + { + /* ϴνյıʱΪǰں */ + retLnkNodePtr->FsfbLinInfo.TimeStmp.LastLocalRecTC =*pFsfbStruct->CycleNum; + /* 趨Ϊ0 */ + retLnkNodePtr->FsfbLinInfo.NoRecvDataCycleNum = 0; + retLnkNodePtr->FsfbLinInfo.SendLinkStatus = Fsfb_SendBtm_BtdAbt; + retLnkNodePtr->IsSendFlag = 1; + /* ɹ */ + retVal =1; + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:BTD InVaild.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_NO_INVALID|FSFB_ERROR_NULL); +#endif + /* ֤ʧ */ + retVal =0; + } + } + } + else + { + retVal = 0; + /* ¼ͨŽڵ㲻Ϸ */ + } + } + else /* Ȳ */ + { + retVal = 0; + /* ¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Tsd CRC Err.\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,FSFB_WARN|FSFB_RECEIVE|FSFB_MSG_CRC_ERR|FSFB_ERROR_NULL); +#endif + } + return retVal; +} +/*-------------------------------------------------------------------- + * Ĵģⲿӿں End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * Ĵģڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** +* : CreateTsdOrSbtMsg +* : Ӧ TSDSBTġ +* : +* +* ------------------------------------------------------------------------------- +* pAppData const UINT8* IN Ӧò㵽Rsspжнڵ +* DataLen UINT8 IN pAppDataݳ +* OutTsdOrSbtMsg UINT8* OUT FSFDϢ֡ +* outPutDataLen UINT16* OUT ij +* pPNode Lnk_Info_Node_Stru_WL** OUT ¶Ӧڵڷ -1 + +* ֵ : UINT8 1 0󷵻 +***********************************************************************/ +static UINT8 CreateTsdOrSbtMsg(const UINT8 *pAppData,UINT16 DataLen,UINT8 applyCat, + UINT8 *OutTsdOrSbtMsg,UINT16* outPutDataLen, Fsfb_Lnk_Info_Node_Stru* pPNode) +{ + UINT8 ret = 0; + + UINT16 CRC16 = 0; /* FSFBϢCRC */ + UINT32 CRCM[2] ={0}; /* CRCM */ + pPNode->Applcat = applyCat; + switch(applyCat) + { + case APPLCAT_BTM: + *outPutDataLen = SBT_SIZE; + /* ·״̬ */ + pPNode->FsfbLinInfo.RecvLinkStatus = Fsfb_WaitBtm_SbtAbt; + /* 趨SBT֡ͷ */ + SetFsfbMsgHead(applyCat,FSFB_SBT_MSG, pPNode->FsfbLinInfo.sendSrcAdd,pPNode->FsfbLinInfo.sendDestAdd,OutTsdOrSbtMsg); + ret=1; + break; + case APPLCAT_TDM: + *outPutDataLen = TSD_SIZE; + /*·״̬*/ + pPNode->FsfbLinInfo.RecvLinkStatus = Fsfb_WaitSse; + /* TSD֡ͷ */ + SetFsfbMsgHead(applyCat,FSFB_TSD_MSG, pPNode->FsfbLinInfo.sendSrcAdd,pPNode->FsfbLinInfo.sendDestAdd,OutTsdOrSbtMsg); + /*жݳǷΪTSD ݳ */ + if(DataLen != TSD_DF_SIZE) + { + ret =0; + } + else + { + ret =1; + } + break; + default: + *outPutDataLen =0; + ret = 0; + break; + } + /* Body 趨 + * ------------------------------------------------------------------ + * | SDS | ȫݳ | CRCM_1 | CRCM_2 | Ӧ | + * 4ֽ | 2ֽ | 2ֽ | 4ֽ | 4ֽ | 36ֽ | + * ------------------------------------------------------------------ + */ + /* Ӧ */ + /* pAppDataʼ MsgLenӦݵ */ + if(ret != 0) + { + if(DataLen ==0) + { + /* 齨SBT֡body */ + DataLen = SBT_DF_SIZE; + BuildSbtFrameDf(pPNode,&OutTsdOrSbtMsg[FSFB_DATA_POS]); + } + else + { + ComMemCopy(pAppData, & + OutTsdOrSbtMsg[FSFB_DATA_POS],DataLen); + } + /* CRCMֵ,(϶1 ) */ + + + ret = ComCalcCRCM(&OutTsdOrSbtMsg[FSFB_DATA_POS],DataLen, + pPNode->FsfbLinInfo.LocalNode.SIDr, + pPNode->FsfbLinInfo.TimeStmp.NowTn, + CRCM); + + /* 趨 4ֽ */ + LongToCharLE(pPNode->FsfbLinInfo.TimeStmp.TC, &OutTsdOrSbtMsg[FSFB_TC_POS]); + + /* ȫݳ Ӧ+ 2CRCM 2ֽ */ + ShortToCharLE((UINT16)(DataLen+2*FSFB_CRCM_LEN), &OutTsdOrSbtMsg[FSFB_DATA_SIZE_POS]); + + /* CRCM[0] CRCM[1] 趨 4 ֽ */ + LongToCharLE(CRCM[0],&OutTsdOrSbtMsg[FSFB_CRCM_1_POS]); + LongToCharLE(CRCM[1],&OutTsdOrSbtMsg[FSFB_CRCM_2_POS]); + + /* 16λ CRC 趨 2 ֽ */ + CRC16 = ComComputeMsgCRC16(OutTsdOrSbtMsg,(UINT16)((*outPutDataLen)-FSFB_CRC_16_LEN)); + ShortToCharLE(CRC16,&OutTsdOrSbtMsg[(UINT16)((*outPutDataLen)-FSFB_CRC_16_LEN)]); + + /* ޷ӦΪ 0 */ + pPNode->FsfbLinInfo.NoAppDataCycleNum = 0; + ret = 1; + } + + return ret; +} + +/*Test todo */ +void BuildSbtFrameDf(Fsfb_Lnk_Info_Node_Stru* pNode,UINT8* pMsgDataBuff) +{ + UINT16 index =0; + UINT32 crcValue =0; + + /* ʼΪ 0 */ + ComMemSet(pMsgDataBuff,SBT_DF_SIZE,0); + /* 2ֽڵԴַ */ + ShortToCharLE(pNode->FsfbLinInfo.sendSrcAdd,pMsgDataBuff+index); + index +=2; + /* 1ֽڵ record Flag 1޼¼ 0м¼ */ + pMsgDataBuff[index]=0x01; + index+=1; + /* 1ֽڵԤ */ + index+=1; + /* 8ֽڵChannel1&2 SID */ + LongToCharLE(pNode->FsfbLinInfo.LocalNode.SIDr[0],pMsgDataBuff+index); + index +=4; + LongToCharLE(pNode->FsfbLinInfo.LocalNode.SIDr[1],pMsgDataBuff+index); + index +=4; + /* 8ֽڵChannel1&2 SINIT */ + LongToCharLE(pNode->FsfbLinInfo.LocalNode.SINITr[0],pMsgDataBuff+index); + index +=4; + LongToCharLE(pNode->FsfbLinInfo.LocalNode.SINITr[1],pMsgDataBuff+index); + index +=4; + /* 1ֽڵ */ + pMsgDataBuff[index++]=MAX_BTM_LOST; + /* 1ֽڵDelta Time Counter max */ + pMsgDataBuff[index++]=Delta_Time_Counter_max; + /* 2ֽԤ */ + index +=2; + /* 8ֽڵChannel1&2 DATAVER */ + LongToCharLE(pNode->FsfbLinInfo.LocalNode.DATAVER[0],pMsgDataBuff+index); + index +=4; + LongToCharLE(pNode->FsfbLinInfo.LocalNode.DATAVER[1],pMsgDataBuff+index); + index +=4; + /* 28ֽڵԤ */ + index +=28; + /* 1ֽڵ NUM_DATAVER */ + pMsgDataBuff[index++]=pNode->FsfbLinInfo.LocalNode.NumDataVer[0]; + /* 3ֽԤ */ + index +=3; + /* 1ֽڵWorldFip Periodic variable Address */ + pMsgDataBuff[index++]=0x01; + /* 1ֽ Segment */ + index+=1; + /* 2ֽ FSFB2Դַ */ + ShortToCharLE(pNode->FsfbLinInfo.sendDestAdd,pMsgDataBuff+index); + index +=2; + /* 8ֽڵChannel1&2 SID */ + LongToCharLE(pNode->FsfbLinInfo.LocalNode.SIDe[0],pMsgDataBuff+index); + index +=4; + LongToCharLE(pNode->FsfbLinInfo.LocalNode.SIDe[1],pMsgDataBuff+index); + index +=4; + /* 8ֽڵChannel1&2 SINIT */ + LongToCharLE(pNode->FsfbLinInfo.LocalNode.SINITe[0],pMsgDataBuff+index); + index +=4; + LongToCharLE(pNode->FsfbLinInfo.LocalNode.SINITe[1],pMsgDataBuff+index); + index +=4; + /* 1ֽԤ */ + pMsgDataBuff[index++]=MAX_BTM_LOST; + /* 1ֽڵDelta Time Counter max */ + pMsgDataBuff[index++]=Delta_Time_Counter_max; + /* 2ֽԤ */ + index +=2; + /* 8ֽڵChannel1&2 DATAVER */ + LongToCharLE(pNode->FsfbLinInfo.LocalNode.DATAVER[0],pMsgDataBuff+index); + index +=4; + LongToCharLE(pNode->FsfbLinInfo.LocalNode.DATAVER[1],pMsgDataBuff+index); + index +=4; + /* 1ֽڵ NUM_DATAVER */ + pMsgDataBuff[index++]=pNode->FsfbLinInfo.LocalNode.NumDataVer[0]; + /* 3ֽԤ */ + index +=3; + /* 8ֽڵSYSCKW + + D channel 1&2 */ + LongToCharLE(COM_SYS_CHK_WD_1,pMsgDataBuff+index); + index +=4; + LongToCharLE(COM_SYS_CHK_WD_2,pMsgDataBuff+index); + index +=4; + /* 4ֽڵCRC_1 */ + crcValue =Crc32(pMsgDataBuff,index); + LongToCharLE(crcValue^0xFFFFFFFF,pMsgDataBuff+index); + index +=4; + /* 4ֽڵCRC_2 */ + LongToCharLE(crcValue^0xFFFFFFFF,pMsgDataBuff+index); + index +=4; + if (index != SBT_DF_SIZE) + { + printf("DATA Error "); + } + else + { + } +} + +/*********************************************************************** +* : CreateSseMsg +* : Ӧ SSEġ +* : +* +* ------------------------------------------------------------------------------- +* applyCate UINT8 IN application cate +* pLnkNodeInfo Fsfb_Lnk_Info_Node_Stru** OUT ¶Ӧڵڷ -1 +* outSseMsg UINT8* OUT FSFDϢ֡ +* ֵ : UINT8 1 0󷵻 +***********************************************************************/ +static UINT8 CreateSseMsg(UINT8 applyCate,Fsfb_Lnk_Info_Node_Stru *pLnkNodeInfo,UINT8* outSseMsg) +{ + UINT8 ret =0; + UINT16 crc16 =0; + UINT32 tmpSeqEng=0;/* ʱSEQENQ */ + /* ͨ״̬Ϣ */ + /* Applicationcat */ + pLnkNodeInfo->Applcat = applyCate; + + /* 趨սڵΪȴSSR*/ + + pLnkNodeInfo->FsfbLinInfo.RecvLinkStatus = Fsfb_WaitSSR; + pLnkNodeInfo->FsfbLinInfo.SendLinkStatus = Fsfb_Halt; + /* ͨŽڵδΪ0 */ + pLnkNodeInfo->FsfbLinInfo.NoRecvDataCycleNum =0; + + + pLnkNodeInfo->IsSendFlag=0; + + /* SSE ʱںͶӦʱ */ + pLnkNodeInfo->FsfbLinInfo.TimeStmp.SseTC = pLnkNodeInfo->FsfbLinInfo.TimeStmp.TC;/* Ӧֵ֤SSRļֵ */ + pLnkNodeInfo->FsfbLinInfo.TimeStmp.SseTn[0] = pLnkNodeInfo->FsfbLinInfo.TimeStmp.NowTn[0]; /* ӦʱյSSRʱʼSINITֵ */ + pLnkNodeInfo->FsfbLinInfo.TimeStmp.SseTn[1]=pLnkNodeInfo->FsfbLinInfo.TimeStmp.NowTn[1]; + + + /* ֡ͷϢ趨 */ + SetFsfbMsgHead(applyCate,FSFB_SSE_MSG,pLnkNodeInfo->FsfbLinInfo.sendSrcAdd,pLnkNodeInfo->FsfbLinInfo.sendDestAdd,outSseMsg); + + /* Boby 趨 */ + /* 4*/ + LongToCharLE(pLnkNodeInfo->FsfbLinInfo.TimeStmp.SseTC,&outSseMsg[FSFB_TC_POS]); + + /* SEQENQ_1 4*/ + tmpSeqEng = pLnkNodeInfo->FsfbLinInfo.LocalNode.SIDr[0]^pLnkNodeInfo->FsfbLinInfo.TimeStmp.SseTn[0]; + LongToCharLE(tmpSeqEng,&outSseMsg[FSFB_SSE_ENQ_1_POS]); + + /* SEQENQ_2 4*/ + tmpSeqEng = pLnkNodeInfo->FsfbLinInfo.LocalNode.SIDr[1]^pLnkNodeInfo->FsfbLinInfo.TimeStmp.SseTn[1]; + LongToCharLE(tmpSeqEng,&outSseMsg[FSFB_SSE_ENQ_2_POS]); + + /* CRC 趨 */ + crc16 = ComComputeMsgCRC16(outSseMsg,SSE_SIZE-FSFB_CRC_16_LEN); + ShortToCharLE(crc16,&outSseMsg[SSE_SIZE-FSFB_CRC_16_LEN]); + + ret = 1; + return ret; + +} + +/*********************************************************************** +* : CreateSsrMsg +* : Ӧ SSRġ +* : +* +* ------------------------------------------------------------------------------- +* applyCate UINT8 IN application cate +* pLnkNodeInfo Fsfb_Lnk_Info_Node_Stru** OUT ¶Ӧڵڷ -1 +* OutSsrMsg UINT8* OUT FSFDϢ֡ +* ֵ : UINT8 1 0󷵻 +***********************************************************************/ +static UINT8 CreateSsrMsg(UINT8 applyCate,Fsfb_Lnk_Info_Node_Stru *pLnkNodeInfo,UINT8* outSsrMsg) +{ + UINT8 ret =0; + UINT16 crc16 =0; + UINT32 tmpSeqIni=0;/* ʱSEQIni */ + /* ͨ״̬Ϣ */ + /* Applicationcat */ + pLnkNodeInfo->Applcat = applyCate; + /* 趨սڵΪȴSSR*/ + if (applyCate == APPLCAT_TDM) + { + pLnkNodeInfo->FsfbLinInfo.SendLinkStatus = Fsfb_Halt; + pLnkNodeInfo->IsSendFlag=0; + } + else + { + pLnkNodeInfo->FsfbLinInfo.SendLinkStatus = Fsfb_SendBtm_Btc; + pLnkNodeInfo->IsSendFlag=1; + } + + /* ֡ͷϢ趨 */ + SetFsfbMsgHead(applyCate,FSFB_SSR_MSG,pLnkNodeInfo->FsfbLinInfo.rcvDestAdd,pLnkNodeInfo->FsfbLinInfo.rcvSrcAdd,outSsrMsg); + + /* Boby 趨 */ + /* replier 4*/ + LongToCharLE(pLnkNodeInfo->FsfbLinInfo.TimeStmp.TC,&outSsrMsg[FSFB_TC_POS]); + + /* enqurier 4*/ + LongToCharLE(pLnkNodeInfo->FsfbLinInfo.TimeStmp.RecvSseTCe,&outSsrMsg[FSFB_SSR_TCENQ_POS]); + + /* SEQENQ_1 4*/ + tmpSeqIni = pLnkNodeInfo->FsfbLinInfo.TimeStmp.SeqEng[0]^pLnkNodeInfo->FsfbLinInfo.LocalNode.SIDr[0] + ^pLnkNodeInfo->FsfbLinInfo.LocalNode.DATAVER[0]^pLnkNodeInfo->FsfbLinInfo.TimeStmp.NowTn[0]; + LongToCharLE(tmpSeqIni,&outSsrMsg[FSFB_SSR_ENQ_1_POS]); + + /* SEQENQ_2 4*/ + tmpSeqIni = pLnkNodeInfo->FsfbLinInfo.TimeStmp.SeqEng[1]^pLnkNodeInfo->FsfbLinInfo.LocalNode.SIDr[1] + ^pLnkNodeInfo->FsfbLinInfo.LocalNode.DATAVER[1]^pLnkNodeInfo->FsfbLinInfo.TimeStmp.NowTn[1]; + LongToCharLE(tmpSeqIni,&outSsrMsg[FSFB_SSR_ENQ_2_POS]); + + /* NUM_DATAVER 趨 ŵһ */ + outSsrMsg[FSFB_SSR_NUM_POS]=pLnkNodeInfo->FsfbLinInfo.LocalNode.NumDataVer[0]; + + /* CRC 趨 */ + crc16 = ComComputeMsgCRC16(outSsrMsg,SSR_SIZE-FSFB_CRC_16_LEN); + ShortToCharLE(crc16,&outSsrMsg[SSR_SIZE-FSFB_CRC_16_LEN]); + + ret = 1; + return ret; + +} + +/*********************************************************************** +* : CreateBtmMsg +* : BTMSBTʽɱġ +* : +* +* ------------------------------------------------------------------------------- +* applyCate UINT8 IN application cate +* DataLen UINT16 IN ݳ +* userDataLen UINT16 IN ݲִС +* OutBtmMsg UINT8* OUT FSFDϢ֡ +* pPNode Fsfb_Lnk_Info_Node_Stru** OUT ¶Ӧڵڷ -1 + +* ڽڵҪпǣTodo +* ֵ : UINT8 1 0󷵻 +***********************************************************************/ +static UINT8 CreateBtmMsg(const UINT8 *pAppData,UINT16 DataLen,UINT16 userDataLen,UINT8 messType, + UINT8 *OutBtmMsg, Fsfb_Lnk_Info_Node_Stru* pPNode) +{ + UINT8 ret = 0; + UINT16 CRC16 = 0; /* FSFBϢCRC */ + UINT32 CRCM[2] ={0}; /* CRCM */ /* Ӧݳ */ + + if (pPNode != NULL) + { + /* ֡ͷ趨 */ + SetFsfbMsgHead(APPLCAT_BTM,messType, pPNode->FsfbLinInfo.sendSrcAdd,pPNode->FsfbLinInfo.sendDestAdd,OutBtmMsg); + + /* Body 趨 + * ------------------------------------------------------------------ + * | SDS | ȫݳ | CRCM_1 | CRCM_2 | Ӧ | + * 4ֽ | 2ֽ | 2ֽ | 4ֽ | 4ֽ | 36ֽ | + * ------------------------------------------------------------------ + */ + /* Ӧ */ + /* pAppDataʼ MsgLenӦݵ */ + if(userDataLen == DataLen) + { + ComMemCopy(pAppData, &OutBtmMsg[FSFB_DATA_POS],DataLen); + + /* CRCMֵ,(϶1 ) */ + if((messType == FSFB_BTC_MSG)||(messType == FSFB_EBT_MSG)) + { + ComAddTimeStamp(&pPNode->FsfbLinInfo.TimeStmp); + } + + ret = ComCalcCRCM(&OutBtmMsg[FSFB_DATA_POS],DataLen, + pPNode->FsfbLinInfo.LocalNode.SIDr, + pPNode->FsfbLinInfo.TimeStmp.NowTn, + CRCM); + + /* 趨 4ֽ */ + LongToCharLE(pPNode->FsfbLinInfo.TimeStmp.TC, &OutBtmMsg[FSFB_TC_POS]); + + /* ȫݳ Ӧ+ 2CRCM 2ֽ */ + ShortToCharLE((UINT16)(DataLen+2*FSFB_CRCM_LEN), &OutBtmMsg[FSFB_DATA_SIZE_POS]); + + /* CRCM[0] CRCM[1] 趨 4 ֽ */ + LongToCharLE(CRCM[0],&OutBtmMsg[FSFB_CRCM_1_POS]); + LongToCharLE(CRCM[1],&OutBtmMsg[FSFB_CRCM_2_POS]); + + /* 16λ CRC 趨 2 ֽ */ + CRC16 = ComComputeMsgCRC16(OutBtmMsg,(UINT16)(userDataLen+FSFB_BTM_HEAD_LEN)); + ShortToCharLE(CRC16,&OutBtmMsg[(UINT16)(userDataLen+FSFB_BTM_HEAD_LEN)]); + + /* ޷ӦΪ 0 */ + pPNode->FsfbLinInfo.NoAppDataCycleNum = 0; + pPNode->IsSendFlag=0; + /*pPNode->FsfbLinInfo.RecvLinkStatus = Fsfb_WaitBtm_AbtOrSse;*/ + /*pPNode->FsfbLinInfo.SendLinkStatus = Fsfb_SendData; */ + ret = 1; + } + else + { + /* Ӵ¼ */ + ret = 0; + } + } + + return ret; +} +/*********************************************************************** +* : SetFsfbMsgHead +* : FsfbϢ֡ͷɡ +* : +* +* -------------------------------------------------------------- +* applCat UINT8 IN Ӧò +* MsgType UINT8 IN Ϣ +* SrcAddr UINT16 IN Դַ +* DestAddr UINT16 IN Ŀַ +* OutFsfbMsg UINT8* OUT FsfbϢ֡ +* ֵ : +***********************************************************************/ +static void SetFsfbMsgHead(UINT8 applCat,UINT8 MsgType, UINT16 SrcAddr, UINT16 DestAddr, UINT8 *OutFsfbMsg) +{ + OutFsfbMsg[FSFB_APP_CTGRY_POS] = applCat; /* signaling variables */ + OutFsfbMsg[FSFB_MSG_TYPE_POS] = MsgType; /* Ϣ趨 */ + ShortToCharLE(SrcAddr,&OutFsfbMsg[FSFB_SRC_ADD_POS]); /* 趨ԴַLITTLE endian */ + ShortToCharLE(DestAddr,&OutFsfbMsg[FSFB_DEST_ADD_POS]); /* 趨ԴַLITTLE endian */ +} + +/*********************************************************************** + * : FsfbCheckBtdMsg + * : ֤BTDĵȷԡ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const UINT8 * IN Bsd + * pLnkNode Fsfb_Lnk_Info_Node_Stru INOUT FSFB·Ϣ + * pFsfbStruct FSFB_INFO_STRU * INOUT Эͳһṹ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 FsfbCheckBtdMsg(const UINT8 *pBtdMsg,Fsfb_Lnk_Info_Node_Stru *pLnkNode, FSFB_INFO_STRU *pFsfbStruct) +{ + UINT8 retVal = 1; /* ʼΪ */ + UINT8 tmpret = 0; + INT32 DelayTCr = 0; /* */ + INT32 Tout = 0; /* ϴյĵʱ */ + UINT32 TCr = 0; /* ʱ */ + UINT32 SidXorTn[2] = {0}; /* SID XOR TN BSDļ */ + ComTimeStampStru *pTmStmp = &pLnkNode->FsfbLinInfo.TimeStmp; /* ʱṹ */ + const FsfbNodeParamInfoStru *pNodeParam = &pLnkNode->FsfbLinInfo.LocalNode; /* ڵϢṹ */ + UINT8 *RecordArray = pFsfbStruct->RecordArray; + UINT16 RecordArraySize = pFsfbStruct->RecordArraySize; + + /* ͨŽڵ״̬Ϊ ״̬ */ + if( Fsfb_RecvData == pLnkNode->FsfbLinInfo.RecvLinkStatus) + { + /* ʱ */ + TCr = LongFromCharLE(&pBtdMsg[FSFB_TC_POS]); + /* + * ϴαĵʱһ(ͬһͬʱܵBSDĺSSR)ñ + * 鶪Ƿʱ + */ + if( TCr != pTmStmp->NowRecvTCr) + { + DelayTCr = ComCheckTimeStamp(TCr,pTmStmp->NowRecvTCr,pNodeParam->MaxLost); + } + else + { + return retVal; + } + + if(DelayTCr >= 0) + { + /* ijʱ */ + if(pTmStmp->LastLocalRecTC != *pFsfbStruct->CycleNum) + { + Tout = ComCheckTimeStamp(*pFsfbStruct->CycleNum, + pTmStmp->LastLocalRecTC,pNodeParam->Tout); + } + else + { + /* ˵Ѿյһ֡ݣҪʱ */ + Tout = 0; + } + if(Tout >= 0) /* Ϸʱյ */ + { + /* RSDȡSID XOR TN CRCM[chan] ^ CRC[chan] ^ SYS_CHK_WD[chan] */ + tmpret = ComGetSidXorTn(pBtdMsg,SidXorTn); + /* CRCMЧ */ + retVal = ComCheckCRCM(SidXorTn,pTmStmp->NowSINIT_ADD_SID_XOR_Tn , + DelayTCr,pNodeParam->TSD_POST_RXDADA_K); + if((1 == retVal)&&(tmpret == 1)) /* ɹ ӦϢ */ + { + /* ʱṹ : pTmStmpStruǿգֵ϶Ϊ1 */ + retVal = ComUpdtTmStmpStru(SidXorTn,TCr,DelayTCr,pNodeParam->PREC_SINIT_K,pTmStmp); + retVal = 1; /* */ + } + else + { +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:CRCM Error.\n"); +#endif + /* ʧ 󷵻 */ + retVal = 0; + } + } + else /* ʱ */ + { +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Time Out.\n"); +#endif + retVal = 0; + } + } + else + { +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"DelayTCr > MaxLost\n"); +#endif + /* Ķ طSSEͬ */ + pLnkNode->FsfbLinInfo.RecvLinkStatus = Fsfb_SendBtm_Sbt; + retVal = 0; + } + } + else if( Fsfb_Halt == pLnkNode->FsfbLinInfo.RecvLinkStatus) + { + pLnkNode->FsfbLinInfo.RecvLinkStatus = Fsfb_SendBtm_Sbt; /* ״̬ΪSBT */ + retVal = 0; + } + else /* ״̬ */ + { +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:RecvStatus() not RecvData or Halt.Discard Bsd Msg."); + PrintFileHex(RecordArray,RecordArraySize,&pLnkNode->FsfbLinInfo.RecvLinkStatus,1); + PrintFiles(RecordArray,RecordArraySize,"\n"); +#endif + retVal =0; + } + + return retVal; +} +/*-------------------------------------------------------------------- + * Ĵģڲӿں END + *--------------------------------------------------------------------*/ diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbMessageInfo.h b/TSCP/src/protocol/fsfb/common_fsfb/FsfbMessageInfo.h new file mode 100644 index 0000000..71d135c --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbMessageInfo.h @@ -0,0 +1,160 @@ +/************************************************************************ +* +* ļ FsfbMessageInfo.C +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.05 +* +* FSFB/2Эи֡ʽ֡Լ·״̬ +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +************************************************************************/ +#ifndef _FSFB_MESSAGE_INFO_H_ +#define _FSFB_MESSAGE_INFO_H_ + +#include "FsfbProtclConfigMessage.h" +#include "fsfbProtclStruct.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************** +* : AccordInfoCreateFrameData +* : ӦȷSBTTSD +* : +* +* -------------------------------------------------------------------------- +* pAppData UINT8* IN Ӧ +* DataLen UINT816 IN ݳ +* OutMsg UINT8* OUT ı +* outPutDataLen UINT16* OUT ij +* pPNode Fsfb_Lnk_Info_Node_Stru** OUT ·Ϣ +* pFsfbStru FSFB_INFO_STRU * INOUT Эͳһṹ +* ֵ : UINT8* :1: 1:󷵻 +***********************************************************************/ +UINT8 AccordInfoCreateFrameData(const UINT8 *pAppData,UINT16 DataLen, + UINT8 *OutMsg,UINT16* outPutDataLen,Fsfb_Lnk_Info_Node_Stru** pPNode,FSFB_INFO_STRU *pFsfbStru); + +/*********************************************************************** +* : ArrordLnkInfoCreateFrame +* : ·зͽڵ״̬齨֡ʽ +* : +* +* ------------------------------------------------------------------------------- +* pFsfbStruct FSFB_INFO_STRU* IN ͳһṹ +* outMsg UINT8* OUT FSFBϢ֡ +* datalen UINT16* OUT Ϣ + +* ֵ : UINT8 1 0󷵻 +***********************************************************************/ +UINT8 ArrordLnkInfoCreateFrame(FSFB_INFO_STRU* pFsfbStruct,UINT8* outMsg,UINT16* datalen); + +/*********************************************************************** +* : BuildBtcBody +* :齨BTC֡Body֡ +* : +* +* ------------------------------------------------------------------------------- +* pOutDataBuff UINT8* OUT +* outDataLen UINT16* OUT ݳ +* ֵ : +***********************************************************************/ +void BuildBtcBody(UINT8* pOutDataBuff,UINT16* outDataLen); + +/*********************************************************************** +* : LnkInfoBuildFrame +* :齨Ӧݵ֡ͷ +* : +* +* ------------------------------------------------------------------------------- +* devName UINT16 IN 豸 +* msgLen UINT16 IN ݳ +* pOutDataBuff UINT8* OUT +* ֵ : +***********************************************************************/ +void LnkInfoBuildFrame(UINT16 devName,UINT16 msgLen,UINT8* pOutDataBuff); +/*********************************************************************** + * : FsfbAnalysisSseMsg + * : յSSEϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * devName UINT16* IN 豸 + * applyCat UINT8 IN application catory + * pAppData UINT8* IN Ӧ + * FSFB_INFO_STRU *pFsfbStruct FSFBͳһṹ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * ֵ : UINT8 1 0:󷵻 + ***********************************************************************/ +UINT8 FsfbAnalysisSseMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize); +/*********************************************************************** + * : FsfbAnalysisSsrMsg + * : յSSRϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * devName UINT16* IN 豸 + * applyCat UINT8 IN application catory + * pAppData UINT8* IN Ӧ + * pFsfbStruct FSFB_INFO_STRU* FSFBͳһṹ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbAnalysisSsrMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize); +/*********************************************************************** + * : FsfbAnalysisAbtMsg + * : յABTϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * devName UINT16* IN 豸 + * applyCat UINT8 IN application catory + * pAppData UINT8* IN Ӧ + * pFsfbStruct FSFB_INFO_STRU* FSFBͳһṹ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbAnalysisAbtMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize); +/*********************************************************************** + * : FsfbAnalysisEbtMsg + * : յEBTϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * devName const UINT16 IN 豸 + * applyCat UINT8 IN application Catory + * pAppData UINT8* IN յ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * pFsfbStruct FSFB_INFO_STRU * IN FSFBЭͳһṹ + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbAnalysisEbtMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize); +/*********************************************************************** + * : FsfbAnalysisBtdMsg + * : յBTDϢн֡ȡϢ, + Լݰһĸʽ + * : + * + * -------------------------------------------------------------- + * devName const UINT16 IN 豸 + * applyCat UINT8 IN application Catory + * pAppData UINT8* IN յ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * pFsfbStruct FSFB_INFO_STRU * IN FSFBЭͳһṹ + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 FsfbAnalysisBtdMsg(UINT16 devName,UINT8 applyCat,UINT8* pAppData,FSFB_INFO_STRU *pFsfbStruct,UINT8 *RecordArray, UINT16 RecordArraySize); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtcl.c b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtcl.c new file mode 100644 index 0000000..a8812cd --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtcl.c @@ -0,0 +1,1180 @@ +/** ****************************************************** +* +* ļ FsfbProtcl.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ䣺 2013.09.05 +* +* FSFBЭʵ +* ʹע⣺ +* +* ޸ļ¼ +* 2014.5.21 +* ޸ݣFsfbProtclRefreshLnkˣ tmpInput = ShortFromChar(pLnkStatusData); +* ޸ɣ֮ǰûлȡݵijȣ޷ʵָ + +* 2014.5.21 +* ޸ݣFsfbProtclRefreshLnkУ +* FsfbVarArray2LnkNodeInfo(pLnkStatusData, CurLnk); +* ΪFsfbVarArray2LnkNodeInfo((UINT8 *)&pLnkStatusData[2+FSFB_VAR_NODE_LEN * i], CurLnk); +* ֮ǰˢϢһֱΪıˢ²ȫ + ޸: ֮ǰˢϢһֱΪıˢ²ȫ + +* 2014.5.30 + ޸: FsfbStructInit(): pFsfbStruct->AppArrayijֶγʼΪ0 + ޸: Ϊ4ֽlong + ֮ǰ:ShortToChar(0, pFsfbStruct->AppArray); + Ϊ:LongToChar(0, pFsfbStruct->AppArray); + + 2014.5.30 + ޸: FsfbStructInit()pFsfbStruct->VarArrayijֶεijʼ + ޸: ʼʱӦñʼ + + 2014.5.30 + ޸:FsfbStructInit()е"·ջռ"ģ + ˶ջʼɶջʼ + ޸:ʹģ黯 + + 2014.5.30 + ޸:FsfbStructInit()е"ʱĻ"ģ + ʱڴռijʼ + ޸:¿ٵڴռӦýгʼ + 2014.8.05 + ޸:ReadQueueData()У޸BTD֧ķֵBTD֤ͨ + ֻǽ򵥵Ķ崻 + ޸:Ҫ + 2014.8.05 + ޸:ReadQueueData()Уһ֡ݳ:ݳ+2󳤶ʱ + ֡ݶִ + ޸:֮ǰδ˷֧ + 2014.8.14 + ޸ݣFsfbProtclOutPutȡÿһ֡Դ֡ݳȽ֤Ϸ֡ + ޸ɣ֮ǰֻǶԵһ֡ݳȷûж֡ݳȷҶԲϷ֡ûнӦ +* ------------ ------ --------------- +********************************************************/ +#include "string.h" +#include "stdlib.h" +#include "Convert.h" +#include "CommonRecord.h" +#include "dsuFsfbFunc.h" +#include "FsfbConfig.h" +#include "FsfbRecordDelare.h" +#include "FsfbProtclCommon.h" +#include "FsfbLnkNodeMgr.h" +#include "FsfbMessageInfo.h" +#include "RpHandleInterface.h" + +/*-------------------------------------------------------------------- + * FSFBЭڲ Start + *--------------------------------------------------------------------*/ +static UINT8 FsfbStructInit(FSFB_INFO_STRU *pFsfbStruct); +static UINT8 FsfbInitLnkMngr(FSFB_INFO_STRU *pFsfbStruct); +static UINT8 FsfbInitLnkMngrStack(ComStackElement *s); +static UINT8 ReadQueueData(QueueStruct* pQueueData, UINT16 MaxLen, UINT8* RecordArray, UINT16 RecordSize, const UINT8 netIdx, FSFB_INFO_STRU* pFsfbStruct); +static UINT8 InitFsfbRedunStruct(const FSFB_INFO_STRU *pFsfbStruct, RPHANDLE_INFO_STRU *pRedunInfoStru); +static void ClearNetsRecvPkgNum(FSFB_INFO_STRU* fsfb); +static void SetNetsRecvPkgNum(FSFB_INFO_STRU* fsfb, const UINT16 dstDevName, const UINT8 netIdx); + +/*-------------------------------------------------------------------- + * FSFBЭڲ End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * FSFBЭⲿӿں Start + *--------------------------------------------------------------------*/ +/****************************************************************************************** +* : Эʼ + 1. ڵô˺֮ǰӦҪͳһṹInputSizeOutputSize,MaxNumLink, + MaxNumPerCycle,OutnetQueueSizeȱֵ +* : UINT8 * fileName ݵļַ +* : FSFB_INFO_STRU* pFsfbStruct Эͳһṹָ +* : +* ȫֱ : +* ֵ : ʼ1򷵻0 +*******************************************************************************************/ +UINT8 FsfbProtclInit(UINT8* fileName,FSFB_INFO_STRU* pFsfbStruct) +{ + UINT8 retVal =0; + + + if(pFsfbStruct == NULL) + { + return retVal; + } + + /* DSUѯгʼ */ + retVal = dsuFsFbInit(fileName); + if( 0 == retVal ) + { + /* DSUѯʼʧ */ + return retVal; + } + else + { + /* ʲô */ + } + + /* FSFBṹʼ */ + retVal = FsfbStructInit(pFsfbStruct); + if(0 == retVal) + { + /* ¼ */ + return retVal; + } + else + { + /* ʲô */ + } + + /* ͨ·ʼ */ + if(!FsfbInitLnkMngr(pFsfbStruct)) + { + retVal =0; + return retVal; + } + + retVal = InitFsfbRedunStruct(pFsfbStruct, &pFsfbStruct->RpInfoStru); + if(0 == retVal) + { + /* ʧ ʲô */ + return retVal; + } + else + { + /*ʼɹ*/ + } + + /* ʼ */ + retVal = RpHandleInit(&pFsfbStruct->RpInfoStru); + if(0 == retVal) + { + /* ʼʧ */ + return retVal; + } + else + { + /* 㴦ɹ */ + } + + return retVal; +} + +/****************************************************************************************** +* : ЭԪ,ЭĹ,Ӧô֡, + ΪݱȽϵԪ׼ñ,ͬʱά· +* : +* : FSFB_INFO_STRU* pFsfbStruct Эͳһṹָ : +* ֵ : ȷ1󷵻0 +*******************************************************************************************/ +UINT8 FsfbProtclOutPut(FSFB_INFO_STRU* pFsfbStruct) +{ + UINT8 retVal = 1;/*ֵ*/ + UINT8 tmpRetVal = 1;/*ʱֵ*/ + UINT32 index =0; + UINT16 msgLen = 0;/* Ϣ */ + UINT16 outputDataLen =0; /* һ֡ݳ */ + UINT16 maxMagLen = 0; /* һ֡ݵ󳤶 */ + UINT8 tmpBuff[2]={0}; /* ɱĵʱ */ + UINT16 fsfbVarLen = 0;/*FSFBЭм*/ + UINT16 redunVarLen = 0;/*мݳ*/ + Fsfb_Lnk_Info_Node_Stru* pNode = NULL; /* ͨŽڵָ */ + Fsfb_Lnk_Info_Node_Stru* CurFillLnk;/*嵱ǰָ;*/ + + CurFillLnk=pFsfbStruct->LnkHead; + + /* ޷ۼ */ + while(CurFillLnk!= NULL) + { + CurFillLnk->FsfbLinInfo.NoAppDataCycleNum++; + ComAddTimeStamp(&CurFillLnk->FsfbLinInfo.TimeStmp); + /* TDM֡*/ + CurFillLnk =CurFillLnk->NextNode; + } + + maxMagLen = pFsfbStruct->OutputSize+6; + + index =4; + if(QueueStatus(&pFsfbStruct->OutputDataQueue)>2) + { + /*Ҫ͵Ӧ*/ + while (QueueStatus(&pFsfbStruct->OutputDataQueue)>2) + { + /* ɨֽڵij:һ֡Ӧݵij */ + QueueScan(2,tmpBuff,&pFsfbStruct->OutputDataQueue); + msgLen = ShortFromChar(tmpBuff); + if(msgLen <= maxMagLen) + {/* нڵݳ Сڵ */ + + /*ȡһ֡ */ + tmpRetVal = QueueRead((UINT32)(msgLen+2),pFsfbStruct->TmpDataBuff,&pFsfbStruct->OutputDataQueue); + if (tmpRetVal == 1) + { + /*ϢͬϢ */ + tmpRetVal =AccordInfoCreateFrameData(pFsfbStruct->TmpDataBuff,(msgLen+2),pFsfbStruct->AppArray+index,&outputDataLen,&pNode,pFsfbStruct); + index +=outputDataLen; + } + + if (tmpRetVal == 0) + { + LongToChar(0,pFsfbStruct->AppArray); + break; + } + } + else + { + QueueElementDiscard( msgLen, &pFsfbStruct->OutputDataQueue);/*֡*/ + } + } + } + else + { + /*Ҫ͵Ӧ*/ + QueueClear(&pFsfbStruct->OutputDataQueue); + LongToChar(0,pFsfbStruct->AppArray); + ShortToChar(0,pFsfbStruct->VarArray); + } + + /* ·ϢӦ֡ */ + tmpRetVal = ArrordLnkInfoCreateFrame(pFsfbStruct,&pFsfbStruct->AppArray[index],&outputDataLen); + index+=outputDataLen; + + if (tmpRetVal == 0) + { + LongToChar(0,pFsfbStruct->AppArray); + } + if(index >= 4) + { + LongToChar(index-4,pFsfbStruct->AppArray); + + /*дм*/ + /*ݽṹ*/ + /******************************************************* + ܳ |FSFBЭм |м + 2ֽ | N | M + *******************************************************/ + fsfbVarLen = FsfbWriteToVarArray(&pFsfbStruct->VarArray[2],pFsfbStruct); + + redunVarLen = RpHandleOutput(&pFsfbStruct->RpInfoStru); + /*ദṹемFSFBЭм*/ + ComMemCopy(pFsfbStruct->RpInfoStru.VarArray,&pFsfbStruct->VarArray[2+fsfbVarLen],redunVarLen); + + /*дмܳ*/ + if(fsfbVarLen+redunVarLen <= 65535) + { + ShortToChar((UINT16)(fsfbVarLen+redunVarLen),pFsfbStruct->VarArray); + } + else + { + /*Ҫ͵Ӧ*/ + QueueClear(&pFsfbStruct->OutputDataQueue); + LongToChar(0,pFsfbStruct->AppArray); + ShortToChar(0,pFsfbStruct->VarArray); + /*Խ,Ӧò崻*/ + retVal = 0; + } + } + return retVal; +} + +/*********************************************************************** + * : FsfbProtclReceiveData + * : ԺݽFSFBİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pFsfbStruct FSFB_INFO_STRU* INOUT FSFBЭͳһṹ + * УpFsfbStruct->OutnetQueueA + * pFsfbStruct->OutnetQueueB + * УpFsfbStruct->DataToApp + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 FsfbProtclReceiveData(FSFB_INFO_STRU* pFsfbStruct) +{ + UINT8 retVal =0; + UINT16 MaxLen = 0; /* һ֡С */ + UINT8 *RecordArray = pFsfbStruct->RecordArray; /* ¼ */ + UINT16 RecordSize = pFsfbStruct->RecordArraySize; /* ¼С */ + + /* ¼ */ + ShortToChar(0,pFsfbStruct->RecordArray); +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"FSFB Receive:\n"); +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN /* */ + /* RSR뵥Ԫʶ */ + PrintRecArrayByte(RecordArray,RecordSize,FSFB_CYCLE_TAG); /* ڿʼ0xEE */ /* M_2010_05_10 */ + PrintRecArray4ByteB(RecordArray,RecordSize,*pFsfbStruct->CycleNum); /* ں */ /*M_2010_05_10 */ + PrintRecArrayByte(RecordArray,RecordSize,FSFB_RCV_TAG); + PrintRecArrayByte(RecordArray,RecordSize,pFsfbStruct->LocalType); /* */ + PrintRecArrayByte(RecordArray,RecordSize,pFsfbStruct->LocalID); /* ID */ +#endif + + QueueClear(&pFsfbStruct->DataToApp); /* */ + + /* нڵݳ = InputSize + FSFBϢ̶ + й̶(4+ 2) */ + MaxLen = pFsfbStruct->InputSize + FSFB_FIXED_LEN + 6; + + ClearNetsRecvPkgNum(pFsfbStruct); + + /* Ժյݽд */ + retVal = ReadQueueData(&pFsfbStruct->OutnetQueueR, MaxLen, pFsfbStruct->RecordArray, pFsfbStruct->RecordArraySize, 0, pFsfbStruct); + + /* յݽд */ + retVal = ReadQueueData(&pFsfbStruct->OutnetQueueB, MaxLen, pFsfbStruct->RecordArray, pFsfbStruct->RecordArraySize, 1, pFsfbStruct); + + + + /* ı 浽ʱ */ + + /* ״̬ */ + + retVal=FsfbRecvLnkStatusMng(pFsfbStruct); + + return retVal; +} + +/*********************************************************************** + * : FsfbProtclDeleteLnk + * : 豸ͺ豸IDɾ· + * : + * + * -------------------------------------------------------------- + * devType UINT8 IN 豸 + * devId UINT8 IN 豸ID + * pFsfbStruct FSFB_INFO_STRU* INOUT FSFBЭͳһṹ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 FsfbProtclDeleteLnk(UINT8 devType,UINT8 devId,FSFB_INFO_STRU* pFsfbStruct) +{ + UINT8 retVal =0; + Fsfb_Lnk_Info_Node_Stru *LastIndex; + Fsfb_Lnk_Info_Node_Stru *CurIndex; + UINT16 destDevName;/*long豸name*/ + UINT8 ret = 0; + + if(pFsfbStruct == NULL) + { + return ret; + } + else + {} + + ComTypeId2DevName(devType,devId,&destDevName); + LastIndex = NULL; + /*ǰָͷָ뿪ʼ*/ + CurIndex = pFsfbStruct -> LnkHead; + + while(CurIndex != NULL) + { + /*ҵҪɾڵ*/ + if(destDevName == CurIndex->DestDevName) + { + /*ɾڵͷڵ*/ + if(LastIndex == NULL) + { + pFsfbStruct ->LnkHead = CurIndex->NextNode; + if( ComPushStack(&pFsfbStruct->LnkStack,(UINT32)CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + }/*if(һָLastIndex == NULL)*/ + /*ɾڵ㲻ͷڵ*/ + else + { + LastIndex->NextNode = CurIndex->NextNode; + if( ComPushStack(&pFsfbStruct->LnkStack,(UINT32)CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + } + } + else + { + /*޲*/ + } + + /*ûҵҪɾڵ㣬һָ͵ǰָ붼һڵ*/ + LastIndex = CurIndex; + CurIndex = CurIndex->NextNode; + + }/*end while(CurIndex != NULL)*/ + + /*ɾ·Ϣ*/ + retVal = RpHandleLnkDelete(destDevName,&pFsfbStruct->RpInfoStru); + + return retVal; +} + +/*********************************************************************** + * : FsfbProtclGetLnkStatus + * : 豸ͺ豸IDȡ豸״̬ + * : + * + * -------------------------------------------------------------- + * devType UINT8 IN 豸 + * devId UINT8 IN 豸ID + * pFsfbStruct FSFB_INFO_STRU* INOUT FSFBЭͳһṹ + * ֵ : 0ͨŽڵ㲻 + 0x2b:ͨж + 0x17: + ***********************************************************************/ +UINT8 FsfbProtclGetLnkStatus(UINT8 devType,UINT8 devId,FSFB_INFO_STRU* pFsfbStruct) +{ + UINT8 retVal =0; + Fsfb_Lnk_Info_Node_Stru *pNode; + UINT16 destDevName =0;/*long豸name*/ + + if(pFsfbStruct == NULL) + { + return retVal; + } + else + {} + + ComTypeId2DevName(devType,devId,&destDevName); + + pNode = FsfbSearchNodeByName(destDevName,APPLCAT_TDM,pFsfbStruct); + if(pNode == NULL) + { + retVal = 0; + } + else if( pNode->FsfbLinInfo.RecvLinkStatus == Fsfb_RecvData) + { + /* */ + retVal = 0x17; + } + else + { + /* ͨ״̬*/ + retVal = 0x2b; + } + return retVal; +} + +/*********************************************************************** + * : FsfbProtclRefreshLnk + * : мˢ·״̬ + * : + * + * -------------------------------------------------------------- + * pLnkStatusData UINT8* IN м + * pFsfbStruct FSFB_INFO_STRU* INOUT FSFBЭͳһṹ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 FsfbProtclRefreshLnk(UINT8* pLnkStatusData,FSFB_INFO_STRU* pFsfbStruct) +{ + UINT8 retVal =0; + UINT16 i; + Fsfb_Lnk_Info_Node_Stru *LastLnk = NULL; + Fsfb_Lnk_Info_Node_Stru *CurLnk = NULL; + UINT16 sLnksNums =0; + INT16 tmpInput =0; + UINT16 inputDataLnk =0; + UINT16 lnkStatusTotalLen = 0;/*·״̬ܳ*/ + UINT16 redunStatusLen = 0;/*·Ϣ*/ + UINT16 fsfbStatusLen = 0;/*FSFBЭ·Ϣ*/ + + UINT16 index = 0;/*ƫ*/ + + if((pLnkStatusData == NULL)||(pFsfbStruct == NULL)) + { + return retVal; + } + else + {} + + CurLnk = pFsfbStruct->LnkHead; + while(CurLnk != NULL) + { + if( ComPushStack(&pFsfbStruct->LnkStack,(UINT32)CurLnk) == 0) + { + retVal =0; + return retVal; + } + CurLnk = CurLnk->NextNode; + } + + /*2ֽڵ·Ϣܳ*/ + lnkStatusTotalLen = ShortFromChar(pLnkStatusData); + index += 2; + + /*ȡFSFB·Ϣ*/ + fsfbStatusLen = ShortFromChar(&pLnkStatusData[index]); + index += 2; + tmpInput = fsfbStatusLen; + if( 0 == ( tmpInput % FSFB_VAR_NODE_LEN ) ) + { + sLnksNums = ( tmpInput / FSFB_VAR_NODE_LEN ); + for( i = 0; i < sLnksNums; i++) + { + CurLnk = (Fsfb_Lnk_Info_Node_Stru *)ComPopStack(&pFsfbStruct->LnkStack); + if(CurLnk != 0) /*ӶջܹõĽڵַ*/ + { + /*ʷˢ·Ϣ*/ + FsfbVarArray2LnkNodeInfo((UINT8 *)&pLnkStatusData[index+FSFB_VAR_NODE_LEN * i], CurLnk); + + if( i == 0) + { + pFsfbStruct->LnkHead = CurLnk; + CurLnk->NextNode = NULL; + } + else + { + LastLnk->NextNode = CurLnk; + CurLnk->NextNode = NULL; + } + LastLnk = CurLnk; + inputDataLnk = inputDataLnk+FSFB_VAR_NODE_LEN; + tmpInput = tmpInput - FSFB_VAR_NODE_LEN; + if( 0 == ( tmpInput % FSFB_VAR_NODE_LEN ) ) + { + /* */ + } + else + { + retVal = 0; + return retVal; + } + + } + else + { + retVal = 0; + return retVal; + } + } + index += (sLnksNums*FSFB_VAR_NODE_LEN); + + /*ȡദ·Ϣij*/ + redunStatusLen = ShortFromChar(&pLnkStatusData[index]); + if ((redunStatusLen+2) == (lnkStatusTotalLen-2-fsfbStatusLen)) + { + /*ˢ·Ϣ*/ + retVal = RpHandleRefresh(redunStatusLen,&pLnkStatusData[index+2],&pFsfbStruct->RpInfoStru); + } + else + { + /*·Ϣ*/ + retVal = 0; + } + } + else + { + retVal = 0; + } + + return retVal; +} + +/*********************************************************************** + * : FsfbProtclFreeSpace + * : ͷſռ䡣 + * : + * + * -------------------------------------------------------------- + * pFsfbStruct FSFB_INFO_STRU* INOUT FSFBЭͳһṹ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 FsfbProtclFreeSpace(FSFB_INFO_STRU* pFsfbStruct) +{ + UINT8 retVal =0; + + if(pFsfbStruct == NULL) + { + return retVal; + } + else + { + /* */ + } + + if(pFsfbStruct->AppArray != NULL) + { + free((void *) pFsfbStruct->AppArray); + pFsfbStruct->AppArray = NULL; + } + else + { + /*޲*/ + } + + if(pFsfbStruct->VarArray != NULL) + { + free((void *) pFsfbStruct->VarArray); + pFsfbStruct->VarArray = NULL; + } + else + { + /*޲*/ + } + + if(pFsfbStruct->RecordArray != NULL) + { + free((void *) pFsfbStruct->RecordArray); + pFsfbStruct->RecordArray = NULL; + } + else + { + /*޲*/ + } + /*ͷŶеĿռ*/ + QueueElementFree(&pFsfbStruct->OutnetQueueR); + QueueElementFree(&pFsfbStruct->OutnetQueueB); + QueueElementFree(&pFsfbStruct->OutputDataQueue); + QueueElementFree(&pFsfbStruct->DataToApp); + + if(pFsfbStruct->LnkStack.stack.pStackData != NULL) + { + free((void *) pFsfbStruct->LnkStack.stack.pStackData); + pFsfbStruct->LnkStack.stack.pStackData = NULL; + } + else + { + /*޲*/ + } + + retVal = RpHandleFreeSpace(&pFsfbStruct->RpInfoStru); + + return retVal; +} + +/*-------------------------------------------------------------------- + * FSFBЭⲿӿں End + *--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * FSFBЭڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : FsfbStructInit + * : ͨúʵֶRSRijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pFsfbStruct FSFB_INFO_STRU* INOUT FSFBͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 FsfbStructInit(FSFB_INFO_STRU *pFsfbStruct) +{ + UINT8 retVal = 0; + UINT16 inputSize = 0; + UINT16 outputSize = 0; + UINT16 maxMsgNum=0; + UINT16 maxMsg = 0; + + inputSize = pFsfbStruct->InputSize; + outputSize = pFsfbStruct->OutputSize; + + /* */ + maxMsg = pFsfbStruct->InputSize > pFsfbStruct->OutputSize? + pFsfbStruct->InputSize:pFsfbStruct->OutputSize; + maxMsg += 2 + 4 + FSFB_FIXED_LEN +32; /* źŲй̶(2+4) + RSSP̶ + 32 */ + + /* ʼ */ + maxMsgNum = pFsfbStruct->MaxNumLink *(pFsfbStruct->MaxNumPerCycle + 2); /* */ + + /* FSFBģ */ + pFsfbStruct->AppArraySize = (pFsfbStruct->OutputSize+11+26)*(pFsfbStruct->MaxNumPerCycle)*(pFsfbStruct->MaxNumLink)+2; + pFsfbStruct->AppArray = (UINT8 *)malloc(pFsfbStruct->AppArraySize); + if(pFsfbStruct->AppArray == NULL) + { + retVal = 0; + return retVal; + } + else + { + LongToChar(0, pFsfbStruct->AppArray); + } + + /* FSFBģмС */ + pFsfbStruct->VarArraySize = FSFB_VAR_NODE_LEN * pFsfbStruct->MaxNumLink+32; + pFsfbStruct->VarArray = (UINT8*)malloc(pFsfbStruct->VarArraySize); + if( NULL == pFsfbStruct->VarArray) + { + /* ¼ */ + retVal =0; + return retVal; + } + else + { + ShortToChar(0, pFsfbStruct->VarArray); + } + + /* ЭӦõݶг */ + pFsfbStruct->DataToAppSize = (inputSize + 6) * maxMsgNum; /* ЭӦõݶг */ + retVal = QueueInitial(&pFsfbStruct->DataToApp,pFsfbStruct->DataToAppSize); + if(0 == retVal) + { + return retVal; + } + else + { + /* ʲô */ + } + + /* ӦøЭݶг */ + pFsfbStruct->OutputDataQueueSize= (outputSize + 8 )*maxMsgNum; + retVal = QueueInitial(&pFsfbStruct->OutputDataQueue,pFsfbStruct->OutputDataQueueSize); + if(0 == retVal) + { + return retVal; + } + else + { + /* ʲô */ + } + + /* ܶг */ + pFsfbStruct->OutnetQueueSize = (pFsfbStruct->InputSize + 2 + 11)*pFsfbStruct->MaxNumPerCycle*pFsfbStruct->MaxNumLink; + /* */ + retVal = QueueInitial(&pFsfbStruct->OutnetQueueR,pFsfbStruct->OutnetQueueSize); + if(0 == retVal) + { + return retVal; + } + else + { + /* ʲô */ + } + + /* */ + retVal = QueueInitial(&pFsfbStruct->OutnetQueueB,pFsfbStruct->OutnetQueueSize); + if(0 == retVal) + { + return retVal; + } + else + { + /* ʲô */ + } + + /* ¼ */ + pFsfbStruct->RecordArray = (UINT8*)malloc(pFsfbStruct->RecordArraySize); + if( NULL == pFsfbStruct->RecordArray) + { + /* ¼ */ + retVal =0; + return retVal; + } + else + { + ComMemSet(pFsfbStruct->RecordArray ,pFsfbStruct->RecordArraySize,0x0); + } + + /* ·ջռ */ + pFsfbStruct->LnkStack.maxNodeNum = pFsfbStruct->MaxNumLink; + retVal = StackInitial(&pFsfbStruct->LnkStack.stack,pFsfbStruct->LnkStack.maxNodeNum); + + if (0 == retVal) + { + return retVal; + } + else + { + /* */ + } + + /* ʱĻ */ + pFsfbStruct->TmpDataBuff = (UINT8 *)malloc(maxMsg); + if( NULL == pFsfbStruct->TmpDataBuff) + { + retVal =0; + return retVal; + } + else + { + ComMemSet(pFsfbStruct->TmpDataBuff ,maxMsg,0x0); + } + + pFsfbStruct->NetsRecvPkgNums = (FsfbNetsRecvPkgNum*)malloc(sizeof(FsfbNetsRecvPkgNum) * pFsfbStruct->MaxNumLink); + if (NULL == pFsfbStruct->NetsRecvPkgNums) + { + retVal = 0; + return retVal; + } + else + { + ComMemSet((UINT8*)pFsfbStruct->NetsRecvPkgNums, sizeof(FsfbNetsRecvPkgNum)* pFsfbStruct->MaxNumLink, 0u); + } + + retVal = 1; + return retVal; +} + + +/****************************************************************************************** +* : ʼͨ·(һָͷڵһά) + 1. ̬·ջռ䣬гʼ + 2. ·ͷָΪգ +* : +* : FSFB_INFO_STRU* pFsfbStruct Эʹõͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 FsfbInitLnkMngr(FSFB_INFO_STRU *pFsfbStruct) /*·ʼ*/ +{ + UINT8 retVal =0; + + /*·ڵ洢ռ*/ + if(!FsfbInitLnkMngrStack(&pFsfbStruct->LnkStack)) + { + /*¼¼*/ + retVal = 0; + return retVal; + } + pFsfbStruct->LnkHead = NULL; + + retVal = 1; + return retVal; +} + +/****************************************************************************************** +* : ʼ·ջ +* ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +* : ComStackElement* s ջָ +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 FsfbInitLnkMngrStack(ComStackElement *s)/* %RELAX */ +{ + UINT16 i;/*ѭ*/ + Fsfb_Lnk_Info_Node_Stru *pLnkMngrStack = NULL; + UINT8 retVal =0; + + StackClear(&s->stack); /* */ + pLnkMngrStack = (Fsfb_Lnk_Info_Node_Stru *)malloc(sizeof(Fsfb_Lnk_Info_Node_Stru) * s->maxNodeNum); + if(pLnkMngrStack == NULL) + { + /*ӡӡ*/ + retVal = 0; + return retVal; + } + else + { + ComMemSet((UINT8*)pLnkMngrStack, sizeof(Fsfb_Lnk_Info_Node_Stru) * s->maxNodeNum, 0x00); + } + for (i = 0;i < s->maxNodeNum;i++) + { /*ѹtotalsizeڵ*/ + if(ComPushStack(s,(STACK_DATA_TYPE)&pLnkMngrStack[i]) != 1) + { + retVal = 0; + return retVal;/*ѹڵʧ*/ + } + else + { + } + } + s->pFirstNode = (UINT32) pLnkMngrStack; + retVal = 1; + return retVal; +} + + /*********************************************************************** + * : ReadQueueData + * : Խյݽش + * : + * + * -------------------------------------------------------------- + * pQueueData QueueStruct* IN ӦýյݵĶ + * MaxLen UINT16 IN + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 + * pFsfbStruct FSFB_INFO_STRU * INOUT FSFBЭͳһṹ + * ֵ : DataNode_WL* ʱͷ + ***********************************************************************/ +static UINT8 ReadQueueData(QueueStruct *pQueueData,UINT16 MaxLen,UINT8 *RecordArray, UINT16 RecordSize, const UINT8 netIdx,FSFB_INFO_STRU *pFsfbStruct) +{ + UINT8 retVal = 0; + UINT8 flag =0; + UINT16 index = 0; /* ݱ־λ */ + UINT8 destDevType =0; + UINT8 destDevId =0; + UINT16 desDevName =0; + UINT16 MsgLen = 0; /* Ϣ */ + UINT8 applyCat = 0; + UINT8 messageType =0; /* Ϣ */ + UINT8 tmpBtd[2]={0}; + UINT32 rcvBtdSn = 0;/*յBTD֡к*/ + UINT32 rcvOtherSn = 0;/*յ֡к*/ + const UINT8 SENDER_TYPE_QUE_POS = 0; /* 淢ͷ͵λ */ + const UINT8 SENDER_ID_QUE_POS = SENDER_TYPE_QUE_POS+1; /* 淢ͷIdλ */ + const UINT8 SENDER_EMPTY_QUE_POS =SENDER_ID_QUE_POS+1; /* Ԥֽ*/ + + retVal =1; + /* г>2 */ + while(2 <= QueueStatus(pQueueData)) + { + /* нڵʽ + * ---------------------------------------------------------------------- + * | ͷType | ͷID | Ԥֽ| Ϣ֡ʽ + * 2ֽ| 1ֽ | 1 ֽ | 2bytes | + * ----------------------------------------------------------------------- + */ + index=0; + QueueRead(2,pFsfbStruct->TmpDataBuff,pQueueData); /* ɨֽڵij */ + MsgLen = ShortFromChar(pFsfbStruct->TmpDataBuff); + if((MsgLen+2) <= MaxLen) + { + /* һ֡ */ + retVal =QueueRead(MsgLen,pFsfbStruct->TmpDataBuff,pQueueData); + if (retVal == 0) + { + /* ʧʣµݴССMsgLen+2¼ */ +#ifdef FSFB_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:Write Que Err\n"); /* ʧ */ +#endif +#ifdef FSFB_RECORD_SIMPLIFY_BIN /* */ + PrintRecArray2ByteB(RecordArray,RecordSize,FSFB_WARN|FSFB_RECEIVE|FSFB_ERROR_NULL|FSFB_QUEUE_READ); /* ʧ */ +#endif + break; + } + + /* 豸Type*/ + destDevType = pFsfbStruct->TmpDataBuff[SENDER_TYPE_QUE_POS]; + /* 豸ID */ + destDevId = pFsfbStruct->TmpDataBuff[SENDER_ID_QUE_POS]; + ComTypeId2DevName(destDevType,destDevId,&desDevName); + + SetNetsRecvPkgNum(pFsfbStruct, desDevName, netIdx); + + /* Ԥֽռ*/ + index = SENDER_EMPTY_QUE_POS+2; + + while((MsgLen-index)>0) + { + /* 1ֽڵApplication Catory */ + applyCat = pFsfbStruct->TmpDataBuff[index+FSFB_APP_CTGRY_POS]; + + /* 1ֽ Ϣ */ + messageType = pFsfbStruct->TmpDataBuff[index+FSFB_MSG_TYPE_POS]; + + switch(messageType) + { + case FSFB_SSE_MSG: + /* SSE֡ */ + if(applyCat == APPLCAT_BTM) + { + rcvOtherSn = LongFromCharLE(&pFsfbStruct->TmpDataBuff[index+FSFB_TC_POS]); + retVal = ReadRpHandleQueueData(desDevName,rcvOtherSn,&pFsfbStruct->RpInfoStru); + + retVal=FsfbAnalysisSseMsg(desDevName,applyCat,&pFsfbStruct->TmpDataBuff[index],pFsfbStruct,pFsfbStruct->RecordArray,pFsfbStruct->RecordArraySize); + index +=SSE_SIZE; + } + else + { + retVal=FsfbAnalysisSseMsg(desDevName,applyCat,&pFsfbStruct->TmpDataBuff[index],pFsfbStruct,pFsfbStruct->RecordArray,pFsfbStruct->RecordArraySize); + index +=SSE_SIZE; + } + break; + case FSFB_SSR_MSG: + + rcvOtherSn = LongFromCharLE(&pFsfbStruct->TmpDataBuff[index+FSFB_TC_POS]); + retVal = ReadRpHandleQueueData(desDevName,rcvOtherSn,&pFsfbStruct->RpInfoStru); + + retVal = FsfbAnalysisSsrMsg(desDevName,applyCat,&pFsfbStruct->TmpDataBuff[index],pFsfbStruct,pFsfbStruct->RecordArray,pFsfbStruct->RecordArraySize); + index +=SSR_SIZE; + /* SSR֡ʼ */ + break; + case FSFB_TSD_MSG: + /* ܽյ */ + /* յֱӶ */ + index +=TSD_SIZE; + break; + case FSFB_ABT_MSG: + rcvOtherSn = LongFromCharLE(&pFsfbStruct->TmpDataBuff[index+FSFB_TC_POS]); + retVal = ReadRpHandleQueueData(desDevName,rcvOtherSn,&pFsfbStruct->RpInfoStru); + + retVal =FsfbAnalysisAbtMsg(desDevName,applyCat,&pFsfbStruct->TmpDataBuff[index],pFsfbStruct,pFsfbStruct->RecordArray,pFsfbStruct->RecordArraySize); + index +=ABT_SIZE; + break; + case FSFB_SBT_MSG: + /* յֱӶ */ + index +=SBT_SIZE; + break; + case FSFB_BTC_MSG: + /* յֱӶ */ + index +=BTC_SIZE; + break; + case FSFB_EBT_MSG: + /* EBT */ + retVal =FsfbAnalysisEbtMsg(desDevName,applyCat,&pFsfbStruct->TmpDataBuff[index],pFsfbStruct,pFsfbStruct->RecordArray,pFsfbStruct->RecordArraySize); + index +=EBT_SIZE; + break; + case FSFB_BTD_MSG: + /* ЧԼ*/ + rcvBtdSn = LongFromCharLE(&pFsfbStruct->TmpDataBuff[index+FSFB_TC_POS]); + + retVal = ReadRpHandleQueueData(desDevName,rcvBtdSn,&pFsfbStruct->RpInfoStru); + if(1 == retVal) + { + /* ݣ·״̬ */ + retVal =FsfbAnalysisBtdMsg(desDevName,applyCat,&pFsfbStruct->TmpDataBuff[index],pFsfbStruct,pFsfbStruct->RecordArray,pFsfbStruct->RecordArraySize); + if(1 == retVal) + { + ShortToChar(BTD_DF_SIZE+4,tmpBtd); + + QueueWrite(2,tmpBtd,&pFsfbStruct ->DataToApp); + QueueWrite(1,&destDevType,&pFsfbStruct ->DataToApp); + QueueWrite(1,&destDevId,&pFsfbStruct ->DataToApp); + ShortToChar(0,tmpBtd); + QueueWrite(2,tmpBtd,&pFsfbStruct ->DataToApp); + QueueWrite(BTD_DF_SIZE,&pFsfbStruct->TmpDataBuff[index+FSFB_BTM_HEAD_LEN],&pFsfbStruct ->DataToApp); + } + else + { + retVal=1;/*ڲϷBTDֻ֡ǽ䶪崻*/ + } + } + else + { + /* ֡ */ + retVal=1; + } + index +=BTD_SIZE; + break; + default: + flag =1; + break; + } + if ((flag == 1)||(retVal == 0)) + { + break; + } + } + } + else + {/*֡ݶ*/ + QueueElementDiscard(MsgLen,pQueueData); + } + } + return retVal; +} + +/*********************************************************************** + * : InitRedunStruct + * : ͳһṹгʼ + * : + * + * -------------------------------------------------------------- + * pFsfbStruct const FSFB_INFO_STRU* IN FSFBͳһṹ + * pRedunInfoStru RPHANDLE_INFO_STRU * IN ͳһṹ + * + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ + +static UINT8 InitFsfbRedunStruct(const FSFB_INFO_STRU *pFsfbStruct, RPHANDLE_INFO_STRU *pRedunInfoStru) +{ + UINT8 ret = 0;/*ֵ*/ + + pRedunInfoStru->LocalType = pFsfbStruct->LocalType; /* 豸ID */ + + pRedunInfoStru->MaxNumPerCycle = pFsfbStruct->MaxNumPerCycle; /* */ + pRedunInfoStru->RecordArraySize = pFsfbStruct->RecordArraySize; /* ¼ */ + + pRedunInfoStru->MaxNumLink = pFsfbStruct->MaxNumLink; + + ret = 1; + return ret; +} + +/* +*: հ +*: FSFB_INFO_STRU* fsfb fsfb +*: +*: +*ֵ: +*/ +static void ClearNetsRecvPkgNum(FSFB_INFO_STRU* fsfb) +{ + UINT16 i = 0u; + + if ((NULL != fsfb) && (NULL != fsfb->NetsRecvPkgNums)) + { + for (i = 0; i < fsfb->NetsRecvPkgNumsLen; i++) + { + ComMemSet((UINT8*)fsfb->NetsRecvPkgNums[i].NetsPkgNum, 2 * sizeof(UINT16), 0u); + } + } +} + +/* +*: øհ +*: FSFB_INFO_STRU* fsfb fsfb +* const UINT32 dstDevName Ŀ豸 +* const UINT8 netIdx ± +*: +*: +*ֵ: +*/ +static void SetNetsRecvPkgNum(FSFB_INFO_STRU* fsfb, const UINT16 dstDevName, const UINT8 netIdx) +{ + UINT16 i = 0u; + + if ((NULL != fsfb) && (NULL != fsfb->NetsRecvPkgNums) && ((0u == netIdx) || (1u == netIdx))) /**/ + { + for (i = 0; i < fsfb->NetsRecvPkgNumsLen; i++) + { + if (dstDevName == fsfb->NetsRecvPkgNums[i].DstDevName) /*ҵ*/ + { + fsfb->NetsRecvPkgNums[i].NetsPkgNum[netIdx]++; + break; + } + } + if ((i == fsfb->NetsRecvPkgNumsLen) && (fsfb->NetsRecvPkgNumsLen < fsfb->MaxNumLink)) /*δҵ,һ豸*/ + { + fsfb->NetsRecvPkgNums[fsfb->NetsRecvPkgNumsLen].DstDevName = dstDevName; + ComMemSet((UINT8*)fsfb->NetsRecvPkgNums[i].NetsPkgNum, 2 * sizeof(UINT16), 0u); + fsfb->NetsRecvPkgNums[fsfb->NetsRecvPkgNumsLen].NetsPkgNum[netIdx] = 1; + fsfb->NetsRecvPkgNumsLen++; + } + } +} + +/* +*: ȡFSFBյ +*: FSFB_INFO_STRU* fsfb fsfb +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void FsfbProtclGetNetsRecvPkgNum(FSFB_INFO_STRU* fsfb, const UINT8 dstType, const UINT8 dstId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ + UINT16 i = 0u; + UINT16 dstDevName = 0u; + + if ((NULL != fsfb) && (NULL != fsfb->NetsRecvPkgNums) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum)) /**/ + { + (*redRecvPkgNum) = 0u; + (*blueRecvPkgNum) = 0u; + ComTypeId2DevName(dstType, dstId, &dstDevName); + for (i = 0; i < fsfb->NetsRecvPkgNumsLen; i++) /**/ + { + if (dstDevName == fsfb->NetsRecvPkgNums[i].DstDevName) /*ҵ*/ + { + (*redRecvPkgNum) = fsfb->NetsRecvPkgNums[i].NetsPkgNum[0]; + (*blueRecvPkgNum) = fsfb->NetsRecvPkgNums[i].NetsPkgNum[1]; + break; + } + } + } +} + +/*-------------------------------------------------------------------- + * FSFBЭڲӿں End + *--------------------------------------------------------------------*/ diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtcl.h b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtcl.h new file mode 100644 index 0000000..6a0a0f6 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtcl.h @@ -0,0 +1,68 @@ +/******************************************************** +* +* ļ FsfbProtcl.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ䣺 2013.09.05 +* +* FsfbЭʵ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#ifndef _FSFB_PROTCL_H_ +#define _FSFB_PROTCL_H_ + +#include "fsfbProtclStruct.h" + +#ifdef __cplusplus +extern "C" { +#endif + +UINT8 FsfbProtclInit(UINT8* fileName,FSFB_INFO_STRU* pFsfbStruct); + +/*********************************************************************** +* : FsfbProtclOutPut +* : +* : +* +* ------------------------------------------------------------------------------- +* pAppData const UINT8* IN Ӧò㵽Rsspжнڵ +* DataLen UINT8 IN pAppDataݳ +* OutTsdMsg UINT8* OUT FSFDϢ֡ +* pPNode Lnk_Info_Node_Stru_WL** OUT ¶Ӧڵڷ -1 + +* ֵ : UINT8 1 0󷵻 +***********************************************************************/ +UINT8 FsfbProtclOutPut(FSFB_INFO_STRU* pFsfbStruct); + +UINT8 FsfbProtclReceiveData(FSFB_INFO_STRU* pFsfbStruct); + +UINT8 FsfbProtclDeleteLnk(UINT8 devType,UINT8 devId,FSFB_INFO_STRU* pFsfbStruct); + +UINT8 FsfbProtclGetLnkStatus(UINT8 devType,UINT8 devId,FSFB_INFO_STRU* pFsfbStruct); + +UINT8 FsfbProtclRefreshLnk(UINT8* pLnkStatusData,FSFB_INFO_STRU* pFsfbStruct); + +UINT8 FsfbProtclFreeSpace(FSFB_INFO_STRU* pFsfbStruct); + +/* +*: ȡFSFBյ +*: FSFB_INFO_STRU* fsfb fsfb +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void FsfbProtclGetNetsRecvPkgNum(FSFB_INFO_STRU* fsfb, const UINT8 dstType, const UINT8 dstId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); + +#ifdef __cplusplus +} +#endif + + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclCommon.c b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclCommon.c new file mode 100644 index 0000000..937cd65 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclCommon.c @@ -0,0 +1,965 @@ +/************************************************************************ +* +* ļ FsfbProtclCommonWl.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.05 +* +* FSFBЭʹõFLSR麯. +* ʹע ʹ֮ǰinittab gTableFast ֵ趨 +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +************************************************************************/ +#include "Convert.h" +#include "FsfbProtclCommon.h" +#include "FsfbProtclConfigMessage.h" + +/*---------------------------------------------------------------------- +* ȫֹͨMASK鶨 Start +*---------------------------------------------------------------------*/ + +#define COM_DIMTAB 256 + +const UINT32 COM_SYS_CHK_WD[2] ={COM_SYS_CHK_WD_1,COM_SYS_CHK_WD_2}; /* system check word */ +UINT32 comGTableFast[COM_CHAN_NUM][COM_DIMTAB]; /* LFSRλʹõı */ +const UINT32 comGMaskLFSR[COM_CHAN_NUM] = /* LFSRλ MASK */ +{0x0FC22F87,0xC3E887E1}; + +/*---------------------------------------------------------------------- +* ȫֹͨMASK鶨 END +*---------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------- +* LFSR Start +*---------------------------------------------------------------------*/ +static UINT8 Cominittab (UINT8 chan); +static UINT32 Compd_shift_left (UINT32 regLFSR, UINT8 chan, UINT8 nshift); +static UINT32 Compd_shift_right (UINT32 regLFSR, UINT8 chan, UINT8 nshift); +static UINT32 Compd_shl_fast (UINT32 regLFSR, UINT8 chan, UINT8 nshift); + +/*---------------------------------------------------------------------- +* End +*---------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------- +* LFSR Start +*---------------------------------------------------------------------*/ + +/*********************************************************************** +* : ComF_Add +* : LFSRļ㡣Ĵֵ ȻLFSR32λ +* : +* +* -------------------------------------------------------------- +* regLFSR UINT32 in ĴʵΪLFSR1 +* chan UINT8 in channel +* val UINT32 in 2 +* ֵ: UINT32 +***********************************************************************/ +UINT32 ComF_ADD (UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + regLFSR ^= val; + regLFSR = Compd_shl_fast (regLFSR, chan, 32); + return regLFSR; +} + +/*********************************************************************** +* : ComF_Sub +* : LFSRļ㡣ĴֵLFSR32λ +* : +* +* -------------------------------------------------------------- +* regLFSR UINT32 in ĴʵΪLFSRı +* chan UINT8 in channel +* val UINT32 in +* ֵ: UINT32 +***********************************************************************/ +UINT32 ComF_SUB (UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + regLFSR = Compd_shift_right (regLFSR, chan, 32); + regLFSR ^= val; + return regLFSR; +} + + +/*********************************************************************** +* : ComF_Post +* : LFSRļ㡣ֵLFSR32λĴ +* : +* +* -------------------------------------------------------------- +* regLFSR UINT32 in ĴʵΪLFSRı +* chan UINT8 in channel +* val UINT32 in +* ֵ: UINT32 +***********************************************************************/ +UINT32 ComF_POST (UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + UINT32 tmpVal = 0; + + tmpVal = regLFSR; + regLFSR = val; + regLFSR = Compd_shift_right (regLFSR, chan, 32); + regLFSR ^= tmpVal; + + return regLFSR; +} + +/*********************************************************************** +* : ComF_XOR +* : ԼĴ +* : +* +* -------------------------------------------------------------- +* regLFSR UINT32 in Ĵ +* val UINT32 in +* ֵ: UINT32 +***********************************************************************/ +UINT32 ComF_XOR (UINT32 regLFSR, UINT32 val) +{ + regLFSR ^= val; + return regLFSR; +} + + +/*********************************************************************** +* : ComF_LOAD +* : ֵ뵽Ĵ +* : +* +* -------------------------------------------------------------- +* regLFSR UINT32 in Ĵ +* val UINT32 in Ĵ +* ֵ: UINT32 ؼĴֵ +***********************************************************************/ +UINT32 ComF_LOAD (UINT32 regLFSR, UINT32 val) +{ + regLFSR = val; + return regLFSR; +} + +/*********************************************************************** +* : ComF_READ +* : Ĵݡ +* : +* +* -------------------------------------------------------------- +* regLFSR UINT32 in Ĵ +* ֵ: UINT32 ؼĴֵ +***********************************************************************/ +UINT32 ComF_READ (UINT32 regLFSR) +{ + return regLFSR; +} + +/*********************************************************************** +* : Cominittab +* : ȫLFSRƳgTableFast гڻ +* : +* +* -------------------------------------------------------------- +* chan UINT8 in channel ID +* +* ȫֱ : gTableFast [COM_CHAN_NUM ][COM_DIMTAB ] +* ֵ : UINT8 1: 0: +***********************************************************************/ +static UINT8 Cominittab (UINT8 chan) +{ + UINT8 ret = 0; + UINT32 index = 0; + UINT32 regLFSR = 0; + UINT32 value = 0; + + for(index = 0; index < COM_DIMTAB ; index++) + { + + value = index << 24; + value = value & 0x0FF000000; + regLFSR = ComF_LOAD (regLFSR,value); + regLFSR = Compd_shift_left (regLFSR,chan,8); + comGTableFast [chan][index] = ComF_READ (regLFSR); + } + ret = 1; + return ret; +} + +/*********************************************************************** +* : Compd_shift_left +* : Ĵָλ +* : +* +* -------------------------------------------------------------- +* regLFSR UINT32 in Ĵ +* chan UINT8 in channel ID +* nshift UINT8 in ƶλ +* +* ȫֱ : gMaskLFSR[chan] LFSR mask +* ֵ : UINT32 λֵ +***********************************************************************/ +static UINT32 Compd_shift_left (UINT32 regLFSR, UINT8 chan, UINT8 nshift) +{ + UINT8 index = 0; + UINT32 carry = 0; + + for(index=0; index>= 1; + if(0 != carry) + { + regLFSR |= 0x80000000L; + } + } + + return regLFSR; +} + + +/*********************************************************************** +* : Compd_shift_right +* : Ĵָλ +* : +* +* -------------------------------------------------------------- +* regLFSR UINT32 in Ĵ +* chan UINT8 in channel ID +* nshift UINT8 in ƶλ +* +* ȫֱ : gMaskLFSR[chan] LFSR mask +* ֵ : UINT32 λֵ +***********************************************************************/ +static UINT32 Compd_shl_fast (UINT32 regLFSR, UINT8 chan, UINT8 nshift) +{ + UINT32 tmp = 0; + UINT8 shiftCount = 0; + UINT8 index = 0; + static UINT8 tabInitFlg[COM_CHAN_NUM ] = {0}; + + /* ԿƱڻ */ + if( 1 != tabInitFlg[chan] ) + { + tabInitFlg[chan] = Cominittab (chan); + } + + shiftCount = nshift >> 3; /* 8 */ + for(index = 0; index < shiftCount; index++) + { + tmp = regLFSR >> 24; + regLFSR <<= 8; + regLFSR &= 0x0FFFFFF00; + regLFSR ^= comGTableFast [chan][tmp&(UINT32)0xFF]; + } + return regLFSR; +} + +/*---------------------------------------------------------------------- +* LFSR End +*---------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------- +* ֡֡ Start +*---------------------------------------------------------------------*/ + +/*********************************************************************** +* : ComCheckTimeStamp +* : ԽձĽм飬Ƿʱ +* : +* +* -------------------------------------------------------------- +* nowTCr UINT32 in ǰյıʱ +* lastTCr UINT32 in ϴյıʱ +* maxLost UINT32 in ֵ +* +* ֵ : UINT32 +* <0 : ʧ +* >=0 : ֵ +***********************************************************************/ +INT32 ComCheckTimeStamp (UINT32 nowTCr, UINT32 lastTCr, UINT32 maxLost) +{ + INT32 ret = 0; + + ret = nowTCr - lastTCr -1; /* */ + if( ret > (INT32)maxLost) + { + /* ֵ */ + ret = -1; + } + else + { + /* ʲô */ + ; + } + + return ret; +} +/* ЭϲʱҪ */ +/*********************************************************************** + * : ComGetSidXorTn + * : ȡBSDSID XOR TN ֵ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const UINT8* in BSD + * outSidXorTn UINT32[2] out Sid ^ T(n) + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 ComGetSidXorTn(const UINT8* pBsdMsg,UINT32 outSidXorTn[COM_CHAN_NUM]) +{ + UINT8 ret = 1; /* ֵ 1: */ + UINT8 chan = 0; /* źŵ */ + UINT16 dataLen = 0; /* ݳ */ + UINT32 CRC[COM_CHAN_NUM] = {0}; /* ݵİȫCRC */ + UINT32 CRCM[COM_CHAN_NUM] = {0}; /* ĵCRCM */ + + if( NULL == (void *)pBsdMsg) /* null check */ + { + ret = 0; /* 󷵻 */ + return ret; + } + + + dataLen = ShortFromCharLE(&pBsdMsg[FSFB_DATA_SIZE_POS])-2*FSFB_CRCM_LEN; /* ݳȻ */ + + for(chan = 0; chan < COM_CHAN_NUM; chan++) + { + /* CRC */ + if(0 == dataLen) + { + CRC[chan] = 0; + } else + { + CRC[chan] = ComCRC_Compute_Crc(pBsdMsg+FSFB_DATA_POS, dataLen, chan); /* 32λCRC */ + } + + CRCM[chan] = LongFromCharLE(pBsdMsg+FSFB_CRCM_1_POS+chan*FSFB_CRCM_LEN); /* ȡCRCM */ + + /* ĵ SID^T(n) */ + outSidXorTn[chan] = (CRCM[chan] ^ CRC[chan] ^ COM_SYS_CHK_WD[chan]); + } + return ret; +} + + +/*********************************************************************** +* : ComCheckCRCM +* : 鱨еCRCMSID^Tn()ȷԡ +* : +* +* -------------------------------------------------------------- +* sidXorTn const UINT32[2] in мSid^T(n) +* sinitAddSidXorTn const UINT32[2] in ϴεSINT Add (Sid ^ T(m)ֵ +* nDelayTCr UINT32 in +* POST_RXDAtA_K const UINT32[2][5] in ֵ߲POST_RXDATA_Kֵ +* +* ֵ : UINT8 1 0:쳣 +***********************************************************************/ +UINT8 ComCheckCRCM (const UINT32 sidXorTn[COM_CHAN_NUM ], + const UINT32 sinitAddSidXorTn[COM_CHAN_NUM ], + UINT32 nDelayTCr, + const UINT32 postRxdataK[COM_CHAN_NUM ][COM_MAX_K ]) +{ + UINT32 regLFSR = 0; + UINT8 chan =0,index = 0; + UINT8 ret = 1; /* ֵ 1 */ + + /* POST_RXDATA_K */ + for(chan = 0; chan < COM_CHAN_NUM ; chan++) + { + /* 0 Add (SINITr ADD [SIDr ^ T(n-k)] ADD 0 ....... ADD 0 ADD [SID ^ T(n)]) */ + regLFSR = ComF_LOAD (regLFSR, sinitAddSidXorTn[chan]); + for(index = 0; index < nDelayTCr; index++) + { + regLFSR = ComF_ADD (regLFSR, chan, 0); + } + regLFSR = ComF_ADD (regLFSR,chan,sidXorTn[chan]); + regLFSR = ComF_ADD (0,chan,regLFSR); + + /* CRCMȷ */ + if( ComF_READ (regLFSR) != postRxdataK[chan][nDelayTCr]) + { + ret = 0; + break; + } + else + { + /* ʲô*/ + } + } + + return ret; +} + +/*********************************************************************** +* : ComCalcCRCM +* : CRCMֵ +* : +* +* -------------------------------------------------------------- +* pData const UINT8 * in Ӧ +* DataLen UINT16 in Ӧݳ +* SID const UINT32[2] in ͷSID +* Tn const UINT32[2] in ǰʱ +* OutCRCM const UINT32[2] in CRCN +* +* pDataݳȱΪż +* +* ֵ : UINT8 1 1 +***********************************************************************/ +UINT8 ComCalcCRCM (const UINT8 *pData, UINT16 DataLen, const UINT32 SID[COM_CHAN_NUM ], const UINT32 Tn[COM_CHAN_NUM ], UINT32 OutCRCM[COM_CHAN_NUM ]) +{ + UINT8 ret = 0; + UINT8 chan = 0; + UINT32 crc32[COM_CHAN_NUM ] = {0}; + + /* */ +#if 0 + if(0 == DataLen) + { + for(chan = 0; chan < COM_CHAN_NUM ; chan++) + { + OutCRCM[chan] = 0; + } + } + else + { + /* */ + for(chan = 0; chan < COM_CHAN_NUM ; chan++) + { + crc32[chan] = ComCRC_Compute_Crc (pData,DataLen,chan); /* 32λȫCRC */ + /* CRCM= CRC32 ^ SYSCKW ^ SID ^ Tn */ + OutCRCM[chan] = crc32[chan] ^ COM_SYS_CHK_WD [chan] ^ SID[chan] ^ Tn[chan]; + } + } +#else + if(0 == DataLen) + { + for(chan = 0; chan < COM_CHAN_NUM ; chan++) + { + OutCRCM[chan] = crc32[chan] ^ COM_SYS_CHK_WD [chan] ^ SID[chan] ^ Tn[chan]; + } + } + else + { + /* */ + for(chan = 0; chan < COM_CHAN_NUM ; chan++) + { + crc32[chan] = ComCRC_Compute_Crc (pData,DataLen,chan); /* 32λȫCRC */ + /* CRCM= CRC32 ^ SYSCKW ^ SID ^ Tn */ + OutCRCM[chan] = crc32[chan] ^ COM_SYS_CHK_WD [chan] ^ SID[chan] ^ Tn[chan]; + } + } +#endif + + ret =1; + return ret; +} + + +/*********************************************************************** +* : ComUpdtTmStmpStru +* : ϴεSinitAddSidXorTm㵱ǰıĵSinitAddSidXorTn +* Ҫ : 1 Result_A = SINIT ADD (SID ^ T(n-k)) ADD 0 ADD 0 ADD ....... ADD 0 ʡ K 0 Add ... +* 2 Result_B = PREC_SINIT_K(SIDSENDER) ADD (SID ^ T(n+1)) ADD (SID ^ T(n+1)) +* 3 SINIT ADD (SID ^ T(n)) = Result_A ^ Result_B +* : +* +* -------------------------------------------------------------- +* sidXorTn UINT32[2] in мSid^T(n) +* nowTCr UINT32 in ǰյĵʱ +* nDelayTCr UINT32 in +* precSinitK UINT32[2][5] in ֵֵ߲ +* pTmStmpStru ComTimeStampStru* inout ʱṹ壬ϴյʱ估SINIT ADD (SID ^ Tn)ֵ +* +* ֵ : UINT8 1 0:쳣 +***********************************************************************/ +UINT8 ComUpdtTmStmpStru (const UINT32 sidXorTn[COM_CHAN_NUM ], + UINT32 nowRecvTCr, + UINT32 nDelayTCr, + const UINT32 precSinitK[COM_CHAN_NUM ][COM_MAX_K ], + ComTimeStampStru * pTmStmpStru) +{ + UINT8 chan =0,index = 0; + UINT8 ret = 1; /* ֵ 1 */ + UINT32 resultA = 0, resultB = 0; + UINT32 regLFSR = 0; /* */ + + /* ʱṹָ */ + if( NULL == pTmStmpStru) + { + ret = 0; /* 󷵻 */ + return ret; + } + + /* ½ܱĵʱ */ + pTmStmpStru->LastRecvTCr = pTmStmpStru->NowRecvTCr; + pTmStmpStru->NowRecvTCr = nowRecvTCr; + + + /* ݹ Sinit Add Sid ^ T(n+k) */ + for(chan = 0; chan < COM_CHAN_NUM ; chan++) + { + /* Result_A = SINIT ADD (SID ^ T(n-k)) ADD 0 ADD 0 ADD ....... ADD 0 ʡ K 0 Add ... */ + regLFSR = ComF_LOAD (regLFSR,pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan]); /* load SINIT ADD (SID ^ T(n-k)) */ + for(index = 0; index < nDelayTCr + 2; index++) + { + regLFSR = ComF_ADD (regLFSR, chan, 0); + } + resultA = ComF_READ (regLFSR); + + /* Result_B = PREC_SINIT_K(SIDSENDER) ADD (SID ^ T(n+1)) ADD (SID ^ T(n+1)) */ + regLFSR = ComF_LOAD (regLFSR, precSinitK[chan][nDelayTCr]); + regLFSR = ComF_ADD (regLFSR,chan,sidXorTn[chan]); + regLFSR = ComF_ADD (regLFSR,chan,sidXorTn[chan]); + resultB = ComF_READ (regLFSR); + + /* + * SINIT ADD (SID ^ T(n)) + * SINIT ADD (SID ^ T(n)) = Result_A ^ Result_B + */ + pTmStmpStru->LastSINIT_ADD_SID_XOR_Tn[chan] = pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan]; + pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan] = resultA ^ resultB; + } + + return ret; +} + + +/*********************************************************************** +* : ComCalcFirstSinitAndSidXorTn +* : ʼ SinitAddSidXorTmֵյSSRʱá +* : +* Ҫ : +* +* -------------------------------------------------------------- +* precFirstSinit const UINT32[2] in ָźŵӦPREC_FIRSTSINIT +* senqINI const UINT32[2] in ָźŵӦSSRSEQINIֵ +* enqTCn const UINT32[2] in ָźŵSSEʱڶӦʱ +* outSntAndSidXorTn UINT32[2] out +* +* ֵ : UINT8 1 +***********************************************************************/ +UINT8 ComCalcFirstSinitAndSidXorTn (const UINT32 precFirstSinit[COM_CHAN_NUM ], + const UINT32 senqINI[COM_CHAN_NUM ], + const UINT32 enqTCn[COM_CHAN_NUM ], + UINT32 outSntAndSidXorTn[COM_CHAN_NUM ]) +{ + UINT8 ret =0; + UINT32 regLFSR = 0; + UINT8 chan = 0; + for(chan = 0; chan < COM_CHAN_NUM ;chan++) + { + regLFSR = ComF_LOAD (regLFSR,precFirstSinit[chan]); + regLFSR = ComF_ADD (regLFSR,chan,senqINI[chan]^enqTCn[chan]); + outSntAndSidXorTn[chan] = ComF_READ (regLFSR); + } + ret =1; + return ret; +} + +/*********************************************************************** +* : ComAddTimeStamp +* : 1Ӧʱ¡ +* : +* +* -------------------------------------------------------------- +* pTmStmpStru ComTimeStampStru * inout ʱṹ һ +* +* ֵ : UINT8 1 0:쳣 +***********************************************************************/ +UINT8 ComAddTimeStamp (ComTimeStampStru *pTmStmp) +{ + UINT8 ret =1; + UINT8 chan; + UINT32 regLFSR = 0; /* 32λĴ */ + if(NULL == (void *)pTmStmp) + { + ret = 0; /* 󷵻 */ + } + else + { + pTmStmp->TC++; /* 1 */ + for(chan = 0; chan < COM_CHAN_NUM ; chan++) + { + /* ¶Ӧڵʱ */ + pTmStmp->LastTn[chan] = pTmStmp->NowTn[chan]; + /* T(n+1) = T(n) ADD 0 */ + regLFSR = ComF_LOAD (regLFSR, pTmStmp->NowTn[chan]); + regLFSR = ComF_ADD (regLFSR, chan, 0); + pTmStmp->NowTn[chan] = ComF_READ (regLFSR); + } + } + return ret; /* */ +} + + + +/*********************************************************************** +* : ComCRC_Compute_Crc +* : 32λcrc㡣 +* : +* +* ----------------------------------------------------------- +* pData const UINT8* in Ҫ +* size UINT16 in ݴС +* chan UINT8 in źŵ +* +* ֵ : UINT32 õCRC +***********************************************************************/ +UINT32 ComCRC_Compute_Crc (const UINT8* pData, UINT16 size, UINT8 chan) +{ + UINT16 index; + UINT32 Result = 0; + /*------------------------------------------------------------------------------ + * 32λCRCtable + *-----------------------------------------------------------------------------*/ + const UINT32 CrcmTab[2][256] = { + { + 0x00000000, 0x1942B361, 0x328566C2, 0x2BC7D5A3, 0x650ACD84, 0x7C487EE5, 0x578FAB46, 0x4ECD1827, + 0xCA159B08, 0xD3572869, 0xF890FDCA, 0xE1D24EAB, 0xAF1F568C, 0xB65DE5ED, 0x9D9A304E, 0x84D8832F, + 0x18CE5601, 0x018CE560, 0x2A4B30C3, 0x330983A2, 0x7DC49B85, 0x648628E4, 0x4F41FD47, 0x56034E26, + 0xD2DBCD09, 0xCB997E68, 0xE05EABCB, 0xF91C18AA, 0xB7D1008D, 0xAE93B3EC, 0x8554664F, 0x9C16D52E, + 0x319CAC02, 0x28DE1F63, 0x0319CAC0, 0x1A5B79A1, 0x54966186, 0x4DD4D2E7, 0x66130744, 0x7F51B425, + 0xFB89370A, 0xE2CB846B, 0xC90C51C8, 0xD04EE2A9, 0x9E83FA8E, 0x87C149EF, 0xAC069C4C, 0xB5442F2D, + 0x2952FA03, 0x30104962, 0x1BD79CC1, 0x02952FA0, 0x4C583787, 0x551A84E6, 0x7EDD5145, 0x679FE224, + 0xE347610B, 0xFA05D26A, 0xD1C207C9, 0xC880B4A8, 0x864DAC8F, 0x9F0F1FEE, 0xB4C8CA4D, 0xAD8A792C, + 0x63395804, 0x7A7BEB65, 0x51BC3EC6, 0x48FE8DA7, 0x06339580, 0x1F7126E1, 0x34B6F342, 0x2DF44023, + 0xA92CC30C, 0xB06E706D, 0x9BA9A5CE, 0x82EB16AF, 0xCC260E88, 0xD564BDE9, 0xFEA3684A, 0xE7E1DB2B, + 0x7BF70E05, 0x62B5BD64, 0x497268C7, 0x5030DBA6, 0x1EFDC381, 0x07BF70E0, 0x2C78A543, 0x353A1622, + 0xB1E2950D, 0xA8A0266C, 0x8367F3CF, 0x9A2540AE, 0xD4E85889, 0xCDAAEBE8, 0xE66D3E4B, 0xFF2F8D2A, + 0x52A5F406, 0x4BE74767, 0x602092C4, 0x796221A5, 0x37AF3982, 0x2EED8AE3, 0x052A5F40, 0x1C68EC21, + 0x98B06F0E, 0x81F2DC6F, 0xAA3509CC, 0xB377BAAD, 0xFDBAA28A, 0xE4F811EB, 0xCF3FC448, 0xD67D7729, + 0x4A6BA207, 0x53291166, 0x78EEC4C5, 0x61AC77A4, 0x2F616F83, 0x3623DCE2, 0x1DE40941, 0x04A6BA20, + 0x807E390F, 0x993C8A6E, 0xB2FB5FCD, 0xABB9ECAC, 0xE574F48B, 0xFC3647EA, 0xD7F19249, 0xCEB32128, + 0xC672B008, 0xDF300369, 0xF4F7D6CA, 0xEDB565AB, 0xA3787D8C, 0xBA3ACEED, 0x91FD1B4E, 0x88BFA82F, + 0x0C672B00, 0x15259861, 0x3EE24DC2, 0x27A0FEA3, 0x696DE684, 0x702F55E5, 0x5BE88046, 0x42AA3327, + 0xDEBCE609, 0xC7FE5568, 0xEC3980CB, 0xF57B33AA, 0xBBB62B8D, 0xA2F498EC, 0x89334D4F, 0x9071FE2E, + 0x14A97D01, 0x0DEBCE60, 0x262C1BC3, 0x3F6EA8A2, 0x71A3B085, 0x68E103E4, 0x4326D647, 0x5A646526, + 0xF7EE1C0A, 0xEEACAF6B, 0xC56B7AC8, 0xDC29C9A9, 0x92E4D18E, 0x8BA662EF, 0xA061B74C, 0xB923042D, + 0x3DFB8702, 0x24B93463, 0x0F7EE1C0, 0x163C52A1, 0x58F14A86, 0x41B3F9E7, 0x6A742C44, 0x73369F25, + 0xEF204A0B, 0xF662F96A, 0xDDA52CC9, 0xC4E79FA8, 0x8A2A878F, 0x936834EE, 0xB8AFE14D, 0xA1ED522C, + 0x2535D103, 0x3C776262, 0x17B0B7C1, 0x0EF204A0, 0x403F1C87, 0x597DAFE6, 0x72BA7A45, 0x6BF8C924, + 0xA54BE80C, 0xBC095B6D, 0x97CE8ECE, 0x8E8C3DAF, 0xC0412588, 0xD90396E9, 0xF2C4434A, 0xEB86F02B, + 0x6F5E7304, 0x761CC065, 0x5DDB15C6, 0x4499A6A7, 0x0A54BE80, 0x13160DE1, 0x38D1D842, 0x21936B23, + 0xBD85BE0D, 0xA4C70D6C, 0x8F00D8CF, 0x96426BAE, 0xD88F7389, 0xC1CDC0E8, 0xEA0A154B, 0xF348A62A, + 0x77902505, 0x6ED29664, 0x451543C7, 0x5C57F0A6, 0x129AE881, 0x0BD85BE0, 0x201F8E43, 0x395D3D22, + 0x94D7440E, 0x8D95F76F, 0xA65222CC, 0xBF1091AD, 0xF1DD898A, 0xE89F3AEB, 0xC358EF48, 0xDA1A5C29, + 0x5EC2DF06, 0x47806C67, 0x6C47B9C4, 0x75050AA5, 0x3BC81282, 0x228AA1E3, 0x094D7440, 0x100FC721, + 0x8C19120F, 0x955BA16E, 0xBE9C74CD, 0xA7DEC7AC, 0xE913DF8B, 0xF0516CEA, 0xDB96B949, 0xC2D40A28, + 0x460C8907, 0x5F4E3A66, 0x7489EFC5, 0x6DCB5CA4, 0x23064483, 0x3A44F7E2, 0x11832241, 0x08C19120}, + { + 0x00000000, 0x1EF09C7E, 0x3DE138FC, 0x2311A482, 0x7BC271F8, 0x6532ED86, 0x46234904, 0x58D3D57A, + 0xF784E3F0, 0xE9747F8E, 0xCA65DB0C, 0xD4954772, 0x8C469208, 0x92B60E76, 0xB1A7AAF4, 0xAF57368A, + 0xFF048983, 0xE1F415FD, 0xC2E5B17F, 0xDC152D01, 0x84C6F87B, 0x9A366405, 0xB927C087, 0xA7D75CF9, + 0x08806A73, 0x1670F60D, 0x3561528F, 0x2B91CEF1, 0x73421B8B, 0x6DB287F5, 0x4EA32377, 0x5053BF09, + 0xEE045D65, 0xF0F4C11B, 0xD3E56599, 0xCD15F9E7, 0x95C62C9D, 0x8B36B0E3, 0xA8271461, 0xB6D7881F, + 0x1980BE95, 0x077022EB, 0x24618669, 0x3A911A17, 0x6242CF6D, 0x7CB25313, 0x5FA3F791, 0x41536BEF, + 0x1100D4E6, 0x0FF04898, 0x2CE1EC1A, 0x32117064, 0x6AC2A51E, 0x74323960, 0x57239DE2, 0x49D3019C, + 0xE6843716, 0xF874AB68, 0xDB650FEA, 0xC5959394, 0x9D4646EE, 0x83B6DA90, 0xA0A77E12, 0xBE57E26C, + 0xCC05F4A9, 0xD2F568D7, 0xF1E4CC55, 0xEF14502B, 0xB7C78551, 0xA937192F, 0x8A26BDAD, 0x94D621D3, + 0x3B811759, 0x25718B27, 0x06602FA5, 0x1890B3DB, 0x404366A1, 0x5EB3FADF, 0x7DA25E5D, 0x6352C223, + 0x33017D2A, 0x2DF1E154, 0x0EE045D6, 0x1010D9A8, 0x48C30CD2, 0x563390AC, 0x7522342E, 0x6BD2A850, + 0xC4859EDA, 0xDA7502A4, 0xF964A626, 0xE7943A58, 0xBF47EF22, 0xA1B7735C, 0x82A6D7DE, 0x9C564BA0, + 0x2201A9CC, 0x3CF135B2, 0x1FE09130, 0x01100D4E, 0x59C3D834, 0x4733444A, 0x6422E0C8, 0x7AD27CB6, + 0xD5854A3C, 0xCB75D642, 0xE86472C0, 0xF694EEBE, 0xAE473BC4, 0xB0B7A7BA, 0x93A60338, 0x8D569F46, + 0xDD05204F, 0xC3F5BC31, 0xE0E418B3, 0xFE1484CD, 0xA6C751B7, 0xB837CDC9, 0x9B26694B, 0x85D6F535, + 0x2A81C3BF, 0x34715FC1, 0x1760FB43, 0x0990673D, 0x5143B247, 0x4FB32E39, 0x6CA28ABB, 0x725216C5, + 0x8806A731, 0x96F63B4F, 0xB5E79FCD, 0xAB1703B3, 0xF3C4D6C9, 0xED344AB7, 0xCE25EE35, 0xD0D5724B, + 0x7F8244C1, 0x6172D8BF, 0x42637C3D, 0x5C93E043, 0x04403539, 0x1AB0A947, 0x39A10DC5, 0x275191BB, + 0x77022EB2, 0x69F2B2CC, 0x4AE3164E, 0x54138A30, 0x0CC05F4A, 0x1230C334, 0x312167B6, 0x2FD1FBC8, + 0x8086CD42, 0x9E76513C, 0xBD67F5BE, 0xA39769C0, 0xFB44BCBA, 0xE5B420C4, 0xC6A58446, 0xD8551838, + 0x6602FA54, 0x78F2662A, 0x5BE3C2A8, 0x45135ED6, 0x1DC08BAC, 0x033017D2, 0x2021B350, 0x3ED12F2E, + 0x918619A4, 0x8F7685DA, 0xAC672158, 0xB297BD26, 0xEA44685C, 0xF4B4F422, 0xD7A550A0, 0xC955CCDE, + 0x990673D7, 0x87F6EFA9, 0xA4E74B2B, 0xBA17D755, 0xE2C4022F, 0xFC349E51, 0xDF253AD3, 0xC1D5A6AD, + 0x6E829027, 0x70720C59, 0x5363A8DB, 0x4D9334A5, 0x1540E1DF, 0x0BB07DA1, 0x28A1D923, 0x3651455D, + 0x44035398, 0x5AF3CFE6, 0x79E26B64, 0x6712F71A, 0x3FC12260, 0x2131BE1E, 0x02201A9C, 0x1CD086E2, + 0xB387B068, 0xAD772C16, 0x8E668894, 0x909614EA, 0xC845C190, 0xD6B55DEE, 0xF5A4F96C, 0xEB546512, + 0xBB07DA1B, 0xA5F74665, 0x86E6E2E7, 0x98167E99, 0xC0C5ABE3, 0xDE35379D, 0xFD24931F, 0xE3D40F61, + 0x4C8339EB, 0x5273A595, 0x71620117, 0x6F929D69, 0x37414813, 0x29B1D46D, 0x0AA070EF, 0x1450EC91, + 0xAA070EFD, 0xB4F79283, 0x97E63601, 0x8916AA7F, 0xD1C57F05, 0xCF35E37B, 0xEC2447F9, 0xF2D4DB87, + 0x5D83ED0D, 0x43737173, 0x6062D5F1, 0x7E92498F, 0x26419CF5, 0x38B1008B, 0x1BA0A409, 0x05503877, + 0x5503877E, 0x4BF31B00, 0x68E2BF82, 0x761223FC, 0x2EC1F686, 0x30316AF8, 0x1320CE7A, 0x0DD05204, + 0xA287648E, 0xBC77F8F0, 0x9F665C72, 0x8196C00C, 0xD9451576, 0xC7B58908, 0xE4A42D8A, 0xFA54B1F4} + }; + + /*------------------------------------------------------------------------------ + * ת + *-----------------------------------------------------------------------------*/ + const UINT8 Reflected_Byte[] = { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, + 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, + 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, + 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, + 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, + 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, + 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, + 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, + 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, + 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, + 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, + 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, + 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, + 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, + 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, + 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, + 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF + }; + + for(index=0; index < size; index++) + { + Result = (Result >> 8) ^ CrcmTab[chan][(Result ^ Reflected_Byte[*pData]) & 0xFF]; + pData++; + } + + return Result; +} + +/*********************************************************************** +* : ComComputeMsgCRC16 +* : 16λǰȫcrc㡣 +* : +* +* ----------------------------------------------------------- +* pData const UINT8* in Ҫ +* size UINT16 in ݴС +* +* ֵ : UINT16 õCRC +***********************************************************************/ +UINT16 ComComputeMsgCRC16 (const UINT8* pData, UINT16 size) +{ + UINT8 BitCount = 0; + UINT8 tmpByteData = 0; + UINT16 ActByte = 0, CompCRC = 0; + const UINT16 MSG_CRC_MASK = 0x8810; /* Polynomial for message CRC X25 */ + + while(size > 0) + { + tmpByteData = *pData; + ActByte = (UINT16)tmpByteData; + for(BitCount=8; BitCount>0; BitCount--) + { + if((ActByte ^ CompCRC) & 1) + { + CompCRC = (CompCRC >> 1) ^ MSG_CRC_MASK; + } + else + { + CompCRC >>= 1; + } + ActByte >>= 1; + } + pData++; + size--; + } + + return(CompCRC); +} + +/*********************************************************************** +* : ComMemSet +* : ָڴ趨ֵָ +* : +* +* -------------------------------------------------------------- +* pDestAdd UINT8 * INOUT ڴռ俪ʼַ +* Len UINT16 IN ڴռС +* Val UINT8 IN ֵָ +* +* ֵ : 1 +***********************************************************************/ +UINT8 ComMemSet (UINT8 *pDestAdd, UINT16 Len, UINT8 Val) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = Val; + } + + return (UINT8)1; +} + +/*********************************************************************** +* : ComMemCopy +* : ָڴ趨ֵָ +* : +* +* -------------------------------------------------------------- +* pSrcAdd const UINT8 * IN Դڴռַ +* pDestAdd UINT8 * INOUT Ŀڴռַ +* Len UINT16 IN ڴռС +* +* ֵ : 1 +***********************************************************************/ +UINT8 ComMemCopy (const UINT8 *pSrcAdd,UINT8 *pDestAdd, UINT16 Len) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = pSrcAdd[index]; + } + + return (UINT8)1; +} + +/*********************************************************************** +* : ComTypeId2DevName +* : TypeID ȡӦ豸ʶ +* : +* +* -------------------------------------------------------------- +* Type UINT8 IN +* ID UINT8 IN Id +* pDevName UINT16* OUT ʶ +* +* ֵ : +***********************************************************************/ +void ComTypeId2DevName (UINT8 Type, UINT8 Id, UINT16* pDevName) +{ +#ifdef TYPE_ID_2_DEVNAME_USE_COMM + UINT8 buff[2]; + buff[0] = Type; + buff[1] = Id; + + *pDevName = ShortFromChar(buff); +#else + *pDevName = Type; + *pDevName = (*pDevName)*0x100 + Id; +#endif +} +/*********************************************************************** +* : ComDevName2TypeId +* : ȡӦͺId +* : +* +* -------------------------------------------------------------- +* DevName UINT8 IN ʶ +* pType UINT8* OUT +* pID UINT8* OUT Id +* +* ֵ : +***********************************************************************/ +void ComDevName2TypeId (UINT16 DevName, UINT8* pType,UINT8* pId) +{ +#ifdef TYPE_ID_2_DEVNAME_USE_COMM + UINT8 buff[2]; + ShortToChar(DevName,buff); + *pType = buff[0]; + *pId = buff[1]; +#else + *pId = (UINT8)(DevName % 0x100); + *pType =(UINT8)(DevName /0x100); +#endif +} +/*---------------------------------------------------------------------- +* ֡֡ END +*---------------------------------------------------------------------*/ + +/* ջغ START */ + +/****************************************************************************************** +* : ջѹһڵ,ֵΪѹɹ򷵻1򷵻0 +* : StackElement* s ջָ +* UINT32 node ڵָ +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 ComPushStack(ComStackElement *s,UINT32 node)/* %RELAX */ +{ + UINT8 retVal; + + /*ѹջҪջΪ*/ + if(s->stack.Top < s->stack.TotalSize)/*ջССڶջֵʱѹڵ*/ + { + s->stack.pStackData[s->stack.Top++] = node;/*ѹջ*/ + retVal = 1; + return retVal; + } + else/*ջСڶջֵ,ѹջ.*/ + { + retVal = 0; + return retVal;/*޷ѹڵ*/ + } +} + +/****************************************************************************************** +* : Ӷջеһڵ,ֵΪһָϢʱֻҪֵǿתɶӦͼ +* : ComStackElement* s ջָ +* : +* : +* ȫֱ : +* ֵ : ɹһڵ㷵ؽڵĵַ򷵻0 +*******************************************************************************************/ +UINT32 ComPopStack(ComStackElement *s)/* %RELAX */ +{ + UINT32 retVal; + /*ջҪջԽ*/ + if(s->stack.Top > 0)/*ջС0,ʱԵڵ.*/ + { + return s->stack.pStackData[--(s->stack.Top)];/*ջһλΪոͷŵĽڵ*/ + } + else + { + retVal = 0; + return retVal;/*޷ڵ*/ + } +} + + +/* ջغ END */ diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclCommon.h b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclCommon.h new file mode 100644 index 0000000..ff4871d --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclCommon.h @@ -0,0 +1,319 @@ +/************************************************************************ +* +* ļ FsfbProtclCommon.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.05 +* +* FSFBЭʹõFLSR麯. +* ʹע ʹ֮ǰinittabgTableFastֵ趨 +* ޸ļ¼ +* ʱ ޸ ޸ +************************************************************************/ +#ifndef _FSFB_PROTCL_COMMON_H_ +#define _FSFB_PROTCL_COMMON_H_ + +#include "CommonStack.h" + +/* ڲʹò */ +#define COM_CHAN_NUM 2 /* channel */ +#define COM_MAX_K 5 /* */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/*********************************************************************** +* ṹʱṹ +* Ӣ ComTimeStampStru +* ; ڵշĵʱĻϢ +**********************************************************************/ +typedef struct +{ + UINT32 TC; /* ǰʱ */ + UINT32 LastLocalRecTC; /* ϴյıʱ */ + UINT32 NowTn[2]; /* ǰڶӦʱ */ + UINT32 LastTn[2]; /* ϸڶӦʱ */ + UINT32 LastRecvTCr; /* ϴνյͷʱ */ + UINT32 NowRecvTCr; /* ǰյͷʱ */ + UINT32 SseTC; /* SSEʱں */ + UINT32 SseTn[2]; /* SSEʱڶӦʱ */ + UINT32 RecvSseTCe; /* SSEĵĶԷʱ */ + UINT32 SeqEng[2]; /* յSSEʱSEQENQ */ + UINT8 NumSendSse; /* SSE */ + UINT32 SsrTc; /* ϴͬ */ + UINT32 NowSINIT_ADD_SID_XOR_Tn[2]; /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] */ + UINT32 LastSINIT_ADD_SID_XOR_Tn[2]; /* ϴյʱSINITr AND [SIDr ^ Tr(n)] */ +} ComTimeStampStru; + +/* ʱĶջṹ */ +typedef struct +{ + CommonStack stack; /* ջ */ + UINT32 pFirstNode; + UINT16 maxNodeNum; +} ComStackElement; + +/*---------------------------------------------------------------------- +* LFSR Start +*---------------------------------------------------------------------*/ +UINT32 ComF_ADD (UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 ComF_SUB (UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 ComF_POST (UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 ComF_XOR (UINT32 regLFSR, UINT32 val); +UINT32 ComF_LOAD (UINT32 regLFSR, UINT32 val); +UINT32 ComF_READ (UINT32 regLFSR); + +/*---------------------------------------------------------------------- +* End +*---------------------------------------------------------------------*/ + + +/*********************************************************************** +* : ComCheckTimeStamp +* : ԽձĽм,Ƿʱ +* : +* +* -------------------------------------------------------------- +* nowTCr UINT32 in ǰյıʱ +* lastTCr UINT32 in ϴյıʱ +* maxLost UINT32 in ֵ +* +* ֵ : UINT32 +* <0 : ʧ +* >=0 : ֵ +***********************************************************************/ +INT32 ComCheckTimeStamp (UINT32 nowTCr, UINT32 lastTCr, UINT32 maxLost); + +/*********************************************************************** + * : ComGetSidXorTn + * : ȡBSDSID XOR TN ֵ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const UINT8* in BSD + * outSidXorTn UINT32[2] out Sid ^ T(n) + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 ComGetSidXorTn(const UINT8* pBsdMsg,UINT32 outSidXorTn[COM_CHAN_NUM]); +/*********************************************************************** +* : ComCheckCRCM +* : 鱨еCRCMSID^Tn()ȷԡ +* : +* +* -------------------------------------------------------------- +* sidXorTn const UINT32[2] in мSid^T(n) +* sinitAddSidXorTn const UINT32[2] in ϴεSINT Add (Sid ^ T(m)ֵ +* nDelayTCr UINT32 in +* POST_RXDAtA_K const UINT32[2][5] in ֵ߲,ֵ +* +* ֵ : UINT8 1 0:쳣 +***********************************************************************/ +UINT8 ComCheckCRCM (const UINT32 sidXorTn[COM_CHAN_NUM ], + const UINT32 sinitAddSidXorTn[COM_CHAN_NUM ], + UINT32 nDelayTCr, + const UINT32 postRxdataK[COM_CHAN_NUM ][COM_MAX_K ]); + +/*********************************************************************** +* : ComIsRedunRcvMsg +* : 鱨ӦͺϢǷΪRSSPģԼԱĵĽCRC֤ +* : +* +* -------------------------------------------------------------- +* MsgLen const UINT16 in ij +* pData const UINT8 in ģ16λCRC +* +* ֵ : UINT8 1RSSP 0:RSSP +***********************************************************************/ +UINT8 ComIsRedunRcvMsg(UINT16 MsgLen, const UINT8 pData[]); + +/*********************************************************************** +* : ComCalcCRCM +* : CRCMֵ +* : +* +* -------------------------------------------------------------- +* pData const UINT8 * in Ӧ +* DataLen UINT16 in Ӧݳ +* SID const UINT32[2] in ͷSID +* Tn const UINT32[2] in ǰʱ +* outCRCM const UINT32[2] in CRCN +* +* pDataݳȱΪż +* +* ֵ : UINT8 1 0:쳣 +***********************************************************************/ +UINT8 ComCalcCRCM (const UINT8 *pData, UINT16 DataLen, const UINT32 SID[COM_CHAN_NUM ], const UINT32 Tn[COM_CHAN_NUM ], UINT32 outCRCM[COM_CHAN_NUM ]); + +/*********************************************************************** +* : ComUpdtTmStmpStru +* : ϴεSinitAddSidXorTm㵱ǰıĵSinitAddSidXorTn +* : +* +* -------------------------------------------------------------- +* sidXorTn const UINT32[2] in мSid^T(n) +* nowTCr UINT32 in ǰյĵʱ +* nDelayTCr UINT32 in +* precSinitK const UINT32[2][5] in ֵ߲,ֵ +* pTmStmpStru ComTimeStampStru * inout ʱṹ,ϴյʱ估SINIT ADD (SID ^ Tn)ֵ +* +* ֵ : UINT8 1 0:쳣 +***********************************************************************/ +UINT8 ComUpdtTmStmpStru (const UINT32 sidXorTn[COM_CHAN_NUM ], + UINT32 nowRecvTCr, + UINT32 nDelayTCr, + const UINT32 precSinitK[COM_CHAN_NUM ][COM_MAX_K ], + ComTimeStampStru * pTmStmpStru); + +/*********************************************************************** +* : ComCalcFirstSinitAndSidXorTn +* : ʼ SinitAddSidXorTmֵյSSRʱá +* : +* +* -------------------------------------------------------------- +* precFirstSinit const UINT32[2] in ָźŵӦPREC_FIRSTSINIT +* senqINI const UINT32[2] in ָźŵӦSSRSEQINIֵ +* enqTCn const UINT32[2] in ָźŵSSEʱڶӦʱ +* outSntAndSidXorTn UINT32[2] out +* +* ֵ : UINT8 1 0:쳣 +***********************************************************************/ +UINT8 ComCalcFirstSinitAndSidXorTn (const UINT32 precFirstSinit[COM_CHAN_NUM ], + const UINT32 senqINI[COM_CHAN_NUM ], + const UINT32 enqTCn[COM_CHAN_NUM ], + UINT32 outSntAndSidXorTn[COM_CHAN_NUM ]); + + +/*********************************************************************** +* : ComAddTimeStamp +* : 1,Ӧʱ¡ +* : +* +* -------------------------------------------------------------- +* pTmStmpStru ComTimeStampStru * inout ʱṹ һ +* +* ֵ : UINT8 1 0:쳣 +***********************************************************************/ +UINT8 ComAddTimeStamp (ComTimeStampStru *pTmStmp); + + +/*********************************************************************** +* : ComCRC_Compute_Crc +* : 32λcrc㡣 +* : +* +* ----------------------------------------------------------- +* pData const UINT8* in Ҫ +* size UINT16 in ݴС +* chan UINT8 in źŵ +* +* ֵ : UINT32 õCRC +***********************************************************************/ +UINT32 ComCRC_Compute_Crc (const UINT8* pData, UINT16 size, UINT8 chan); + + +/*********************************************************************** +* : ComComputeMsgCRC16 +* : 16λǰȫcrc㡣 +* : +* +* ----------------------------------------------------------- +* pData const UINT8* in Ҫ +* size UINT16 in ݴС +* +* ֵ : UINT16 õCRC +***********************************************************************/ +UINT16 ComComputeMsgCRC16 (const UINT8* pData, UINT16 size); + + +/*********************************************************************** +* : ComMemSet +* : ָڴ趨ֵָ +* : +* +* -------------------------------------------------------------- +* pDestAdd UINT8 * INOUT ڴռ俪ʼַ +* Len UINT16 IN ڴռС +* Val UINT8 IN ֵָ +* +* ֵ : +***********************************************************************/ +UINT8 ComMemSet (UINT8 *pDestAdd, UINT16 Len, UINT8 Val); + +/*********************************************************************** +* : ComMemCopy +* : ָڴ趨ֵָ +* : +* +* -------------------------------------------------------------- +* pSrcAdd const UINT8 * IN Դڴռַ +* pDestAdd UINT8 * INOUT Ŀڴռַ +* Len UINT16 IN ڴռС +* +* ֵ : 1 +***********************************************************************/ +UINT8 ComMemCopy (const UINT8 *pSrcAdd,UINT8 *pDestAdd, UINT16 Len); + +/*********************************************************************** +* : ComTypeId2DevName +* : TypeID ȡӦ豸ʶ +* : +* +* -------------------------------------------------------------- +* Type UINT8 IN +* ID UINT8 IN Id +* pDevName UINT16* OUT ʶ +* +* ֵ : +***********************************************************************/ +void ComTypeId2DevName (UINT8 Type, UINT8 Id, UINT16* pDevName); + +/*********************************************************************** +* : ComDevName2TypeId +* : ȡӦͺId +* : +* +* -------------------------------------------------------------- +* DevName UINT16 IN ʶ +* pType UINT8* OUT +* pID UINT8* OUT Id +* +* ֵ : +***********************************************************************/ +void ComDevName2TypeId (UINT16 DevName,UINT8* pType, UINT8* pId); + +/*---------------------------------------------------------------------- +* ջغ Start +*---------------------------------------------------------------------*/ +/****************************************************************************************** +* : ջѹһڵ,ֵΪѹɹ򷵻1򷵻0 +* : StackElement* s ջָ +* UINT32 node ڵָ +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ + +UINT8 ComPushStack(ComStackElement *s,UINT32 node); + +/****************************************************************************************** +* : Ӷջеһڵ,ֵΪһָϢʱֻҪֵǿתɶӦͼ +* : ComStackElement* s ջָ +* : +* : +* ȫֱ : +* ֵ : ɹһڵ㷵ؽڵĵַ򷵻0 +*******************************************************************************************/ +UINT32 ComPopStack(ComStackElement *s); +/*---------------------------------------------------------------------- +* ջغ End +*---------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclConfigMessage.h b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclConfigMessage.h new file mode 100644 index 0000000..cca0572 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbProtclConfigMessage.h @@ -0,0 +1,140 @@ +/************************************************************************ +* +* ļ FsfbProtclConfigMessage.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.05 +* +* FSFB/2ЭиϢ +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +************************************************************************/ +#ifndef _FSFB_PROTCL_CONFIG_MESSAGE_H_ +#define _FSFB_PROTCL_CONFIG_MESSAGE_H_ + +#include "CommonTypes.h" + +/* system check word */ +#define COM_SYS_CHK_WD_1 0xAE390B5AL +#define COM_SYS_CHK_WD_2 0xC103589CL + +#define FSFB_CI_DEV 60 /*豸*/ +#define FSFB_LEU_DEV 94 /*豸*/ + +/* Ϣ */ +#define FSFB_SSE_MSG ((UINT8)0x90) /* SSE Ϣ */ +#define FSFB_SSR_MSG ((UINT8)0x91) /* SSR Ϣ */ +#define FSFB_TSD_MSG ((UINT8)0x80) /* TSD Ϣ */ +#define FSFB_SBT_MSG ((UINT8)0xA0) /* SBT Ϣ */ +#define FSFB_EBT_MSG ((UINT8)0xA1) /* EBT Ϣ */ +#define FSFB_ABT_MSG ((UINT8)0xA2) /* ABT Ϣ */ +#define FSFB_BTC_MSG ((UINT8)0xA3) /* BTC Ϣ */ +#define FSFB_BTD_MSG ((UINT8)0xA4) /* BTD Ϣ */ + +/* Ϣ֡ */ +#define TSD_SIZE 58 +#define SSE_SIZE 20 +#define SSR_SIZE 25 +#define SBT_SIZE 138 +#define EBT_SIZE 22 +#define ABT_SIZE 22 +#define BTC_SIZE 30 +#define BTD_SIZE 52 + +/* data feild Size */ +#define TSD_DF_SIZE 36 +#define BTC_DF_SIZE 8 +#define SBT_DF_SIZE 116 +#define ABT_DF_SIZE 0 +#define EBT_DF_SIZE 0 +#define BTD_DF_SIZE 30 + +/* Safety Data Size */ +#define TSD_SDS 44 +#define BTC_SDS 16 +#define ABT_SDS 8 +#define BTD_SDS 38 +#define EBT_SDS 8 +#define SBT_SDS 124 + + +/* ַ */ +#define ADDR_BROADCAST 0xFFFF +#define ADDR_LEU 0x0006 +#define ADDR_BTM 0x00FF +#define ADDR_CI 0x0003 + + +#define MAX_TSD_LOST 30 /* TSDͨѶϢʧ*/ +#define MAX_BTM_LOST 10 /* BTMͨѶϢʧ*/ +#define Delta_Time_Counter_max 0x40 + +/* Ӧòݷඨ*/ +#define APPLCAT_TDM 0x01 /* TDͨѶ*/ +#define APPLCAT_BTM 0x10 /* BTMͨѶ*/ + +#define FSFB_CHANNEL_NOSIGNAL 0 /* ͨź*/ +#define FSFB_CHANNEL_SIGNAL 1 /* ͨź*/ +#define FSFB_CHANNEL_LOCKED 2 /* ͨ*/ + +/* ó */ +#define FSFB_HEAD_LEN 6 /* ֡ͷ */ +#define FSFB_TC_LEN 4 /* ij */ +#define FSFB_CRC_16_LEN 2 /* CRC 16λ ij */ + +/* ֡ͷ */ +#define FSFB_APP_CTGRY_POS 0 /* ֡ͷӦλ*/ +#define FSFB_MSG_TYPE_POS (FSFB_APP_CTGRY_POS+1) /* ֡ͷϢ */ +#define FSFB_SRC_ADD_POS (FSFB_MSG_TYPE_POS+1) /* ϢԴַ */ +#define FSFB_DEST_ADD_POS (FSFB_SRC_ADD_POS+2) /* ϢĿַ */ + +#define FSFB_BTM_HEAD_LEN 20 /* BTM֡֡ͷ */ + +#define FSFB_TC_POS FSFB_HEAD_LEN /* FSFBļλ */ + +/* TSDBTM */ +#define FSFB_CRCM_LEN 4 /* crc ֶ֤εĴС */ +#define FSFB_DATASIZE_LEN 2 /* ݳֶεĴС */ +#define FSFB_DATA_SIZE_POS (FSFB_TC_POS + FSFB_TC_LEN) /* аȫݳȱλ */ +#define FSFB_CRCM_1_POS (FSFB_DATA_SIZE_POS + FSFB_DATASIZE_LEN) /* CRCM_1λ */ +#define FSFB_CRCM_2_POS (FSFB_CRCM_1_POS + FSFB_CRCM_LEN) /* CRCM_2λ */ +#define FSFB_DATA_POS (FSFB_CRCM_2_POS + FSFB_CRCM_LEN) /* ȫݳȱλ */ + + +#define FSFB_ENQ_LEN 4 /* SEQENQ */ +/* SSE */ + +#define FSFB_SSE_ENQ_1_POS (FSFB_TC_POS+FSFB_TC_LEN) /* SSE SEQENQ_1λ */ +#define FSFB_SSE_ENQ_2_POS (FSFB_SSE_ENQ_1_POS+FSFB_ENQ_LEN) /* SSE SEQENQ_2λ */ + +/* SSR */ +#define FSFB_SSR_NUM_LEN 1 /* SSRNum DataVer */ +#define FSFB_SSR_TCENQ_POS (FSFB_TC_POS+FSFB_TC_LEN) /* SSR λ */ +#define FSFB_SSR_ENQ_1_POS (FSFB_SSR_TCENQ_POS+FSFB_TC_LEN) /* SSR SEQINI_1λ */ +#define FSFB_SSR_ENQ_2_POS (FSFB_SSR_ENQ_1_POS+FSFB_ENQ_LEN) /* SSR SEQINI_2λ */ +#define FSFB_SSR_NUM_POS (FSFB_SSR_ENQ_2_POS+FSFB_ENQ_LEN) /* SSRNum DataVer λ */ + +/*BTC data feild ʽ */ +#define FSFB_BTC_OT_POS (FSFB_DATA_POS) /* operation Type */ +#define FSFB_BTC_BT_POS (FSFB_BTC_OT_POS+2) /* LEU STATUS DATA */ +#define FSFB_BTC_SNS_POS (FSFB_BTC_BT_POS+2) /* First sub_buffer number requested */ +#define FSFB_BTC_NST_POS (FSFB_BTC_SNS_POS+2) /* NUmber Sub_buffer to Transmit*/ +/*BTC data feild ֵ */ +#define FSFB_BTC_OT_VALUE 0x0000 +#define FSFB_BTC_BT_VALUE 0x000A +#define FSFB_BTC_SNS_VALUE 0x0001 +#define FSFB_BTC_NST_VALUE 0xFFFF + +/* BTD data Feild ʽ */ +#define FSFB_BTD_BT_POS (FSFB_DATA_POS) /*buffer Type */ +#define FSFB_BTD_SBN_POS (FSFB_BTD_BT_POS+2) /* sub_buffer Number */ +#define FSFB_BTD_TNM_POS (FSFB_BTD_SBN_POS+2) /* Total Number of sub_buffer */ +#define FSFB_BTD_SBD_POS (FSFB_BTD_TNM_POS+2) /* sub-buffer data */ + +#define FSFB_FIXED_LEN 22 /* ̶ֳ֡ */ + +/* */ +#define FSFB_SEND_SBT_NUM 3 /* ȴSSRʱ෢SSE */ +#define FSFB_NONE_SEND_APP_DATA 3 /* ޷Ӧ */ +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/fsfb/common_fsfb/FsfbRecordDelare.h b/TSCP/src/protocol/fsfb/common_fsfb/FsfbRecordDelare.h new file mode 100644 index 0000000..d79a357 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/FsfbRecordDelare.h @@ -0,0 +1,77 @@ +/******************************************************** +* +* ļ FsfbRecordDelare.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ䣺 2013.09.09 +* +* FSFBЭ¼غ궨塣 +* ʹע⣺ +* +* ޸ļ¼ +* 2010.05.10 ޸ ׷FSFBڿʼʶ +* +********************************************************/ + + +#ifndef _FSFB_RECORD_DECLARE_H +#define _FSFB_RECORD_DECLARE_H + + +/******************************************************************************** +궨 +********************************************************************************/ + +/* ־λ */ +#define FSFB_CYCLE_TAG 0xDD /* FSFBڿʼʶ */ +#define FSFB_RCV_TAG 0xF4 /* FSFB뵥Ԫʶ */ +#define FSFB_OUT_TAG 0xF5 /* FSFBԪʶ */ +#define FSFB_MSG_IN_TAG 0x04 /* FSFBһ֡Ϣʼʶ(B 0000 0100) */ +#define FSFB_MSG_OUT_TAG 0x08 /* FSFBһ֡Ϣʼʶ(B 0000 1000) */ +#define FSFB_NODE_OUT_TAG 0x0C /* FSFBһ֡Ϣʼʶ(B 0000 1100) */ +#define FSFB_OUT_E_TAG 0x0F /* FSFBԪʶ(B 0000 1111) */ + +/************************************************************************ + * ԭЭһ16bit + * D15~D12 + * D11~D10ȼ + * D9~D8ģλ + * D7~D4ģеĴģ鲻ͬʱ4λĺ岻ͬ + * ڶȵײ + * D3~D0ģǷͬ4λĺͬ +************************************************************************/ +/* ȼ */ +#define FSFB_ERR 0x0800 +#define FSFB_WARN 0x0400 + +/* ģλ */ +#define FSFB_RECEIVE 0x0200 /* ģ */ +#define FSFB_OUTPUT 0x0100 /* ģ */ + +/* ģд */ +#define FSFB_ERROR_NULL 0x0000 +/* */ +#define FSFB_MSG_TYPE_ILLEGAL 0x0010 /* FSFBϢ */ +#define FSFB_MSG_OLD_ERR 0x0020 /* ± */ +#define FSFB_DEL_MSG_LNK_ERR 0x0030 /* ʱɾʧ */ +#define FSFB_MSG_NOT_NODE_ERR 0x0040 /* ϢͨŽڵϢһ */ +#define FSFB_MSG_LEN_ERR 0x0050 /* ijȲ */ +#define FSFB_MSG_FMT_ILLEGAL 0x0060 /* ĸʽ */ +#define FSFB_SSR_NOT_ILLEGAL 0x0070 /* ǶӦSSRϢ */ +#define FSFB_MSG_REPLACE_ERR 0x0080 /* ǽڵʧ */ +#define FSFB_MSG_NO_REPLACENODE 0x0090 /* ڸǽڵ */ +#define FSFB_MSG_NO_INVALID 0x00A0 /* BSDʧ */ +#define FSFB_MSG_CRC_ERR 0x00B0 +/* */ +#define FSFB_DBGET_ERR 0x0050 /* ݿѯ */ +/* ײ㴦 */ +#define FSFB_QUEUE_READ 0x0001 /* жд */ +#define FSFB_QUEUE_WRITE 0x0002 /* дд */ +#define FSFB_QUEUE_INTEGRITY 0x0003 /* ݲscanдӦø*/ +#define FSFB_LNK_PUSH 0x0004 /* ·ڵѹջ */ +#define FSFB_LNK_POP 0x0005 /* кŻڵջ */ + + + +#endif + diff --git a/TSCP/src/protocol/fsfb/common_fsfb/RpHandleInterface.c b/TSCP/src/protocol/fsfb/common_fsfb/RpHandleInterface.c new file mode 100644 index 0000000..27077b2 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/RpHandleInterface.c @@ -0,0 +1,651 @@ +/************************************************************************ +* ļRpHandleInterface.c +* ļദԴļ +* ʱ䣺2009.10.08 +* ޸ļ¼ +* 2011.12.07 RpLnkDeleteɾ· +* 2013.02.07 ReadRpHandleQueueData +* 2013.02.07 ޸RpReceive +* 2013.02.07 IsRsspMsg +************************************************************************/ +#include "stdlib.h" +#include "RpHandleInterface.h" +#include "Convert.h" +#include "CommonRecord.h" +#include "CommonStack.h" +#include "CommonMemory.h" +#include "RpHandlePlatform.h" +#include "dsuFsfbFunc.h" + +UINT8 RpHandle_init_SnStack(RPHANDLE_INFO_STRU *pRedunStruct); + +/************************************************************************* +* : +* ͨúʵദڴռ +* ˵: +* [in]RPHANDLE_INFO_STRU *pRedunStruct ദͬһṹ; +* ֵ: +* return 1 +* return 0쳣 +**************************************************************************/ +UINT8 RpHandleInit(RPHANDLE_INFO_STRU *pRedunStruct)/* %RELAX */ +{ + UINT8 ret = 0; /*ֵ*/ + + if(pRedunStruct == NULL) /* ǿռ */ + { + ret = 0; + return ret; + } + else + { + /* */ + } + + /*Ϊ¼ռ*/ + pRedunStruct->RecordArray = (UINT8 *)malloc(pRedunStruct->RecordArraySize+2); + if(pRedunStruct->RecordArray == NULL) + { + ret = 0; + return ret; + } + else + { + CommonMemSet(pRedunStruct->RecordArray,sizeof(UINT8)*(pRedunStruct->RecordArraySize+2),0,sizeof(UINT8)*(pRedunStruct->RecordArraySize+2)); + } + + /*ΪVarArrayռ*/ + pRedunStruct->VarArraySize= RP_HANDLE_LNK_LENGTH * (pRedunStruct->MaxNumLink+2); /*REDUN_LNK_LENGTHΪ·Ϣ*/ + pRedunStruct->VarArray = (UINT8 *)malloc(pRedunStruct->VarArraySize); + if(pRedunStruct->VarArray == NULL) + { + ret = 0; + return ret; + } + else + { + CommonMemSet(pRedunStruct->VarArray,sizeof(UINT8)*pRedunStruct->VarArraySize,0,sizeof(UINT8)*pRedunStruct->VarArraySize); + } + + + /*кŻջռ*/ + + ret = StackInitial(&pRedunStruct->SnLnkStack, (UINT16)pRedunStruct->MaxNumLink); + if(ret == 0) + { + return ret; + } + else + { + /* */ + } + + /*·ڵ洢ռ*/ + if(!RpHandle_init_SnStack(pRedunStruct)) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + pRedunStruct->SnLinkhead = NULL; + + ret = 1; + return ret; +} + +/***************************************************************************************** +*: +* ·еϢֵм +*˵: +* RPHANDLE_INFO_STRU *pRedunStruct ͳһṹ +*ֵ:ݳ +*****************************************************************************************/ +UINT16 RpHandleOutput(RPHANDLE_INFO_STRU *pRedunStruct)/* %RELAX */ +{ + UINT8 ret = 0; + UINT16 index = 0; + UINT16 redunDataLen = 0;/*мݳ*/ + RPHANDLESNLINK_STRU* CurNumLink; /*дVarArrayУָڵ*/ + + if(pRedunStruct == NULL) /* ǿռ */ + { + ret = 0; + return ret; + } + else + { + /* */ + } + + CurNumLink = pRedunStruct->SnLinkhead; + /* 2ֽ */ + index = index +2; + while(CurNumLink != NULL) + { + /* 2ֽ Է豸 */ + ShortToChar(CurNumLink->SnLink_Info.DestDevName, &pRedunStruct->VarArray[index]); + index += 2; + /* 4ֽ ϴη͵к*/ + LongToChar(CurNumLink->SnLink_Info.LastSn,&pRedunStruct->VarArray[index]); + index +=4; + /* 1ֽ 󶪰 */ + pRedunStruct->VarArray[index] = CurNumLink->SnLink_Info.maxLostSn; + index++; + + CurNumLink = CurNumLink->NextNode; + } + + ShortToChar((UINT16)(index-2), pRedunStruct->VarArray); + + redunDataLen = index; + return redunDataLen; +} + + + +/************************************************************************************** + * + * ͷЭںRpHandleInitзڴռ + * ڲ + * RPHANDLE_INFO_STRU * pRedunStruct ͳһṹ + * ֵ + * ɹ1ʧܷ0 + ***************************************************************************************/ +UINT8 RpHandleFreeSpace(RPHANDLE_INFO_STRU *pRedunStruct)/* %RELAX */ +{ + UINT8 ret = 1; + + if(pRedunStruct->RecordArray != NULL) + { + free((void *)pRedunStruct->RecordArray); + pRedunStruct->RecordArray = NULL; + } + else + { + /*޲*/ + } + + if(pRedunStruct->VarArray!= NULL) + { + free((void *)pRedunStruct->VarArray); + pRedunStruct->VarArray= NULL; + } + else + { + /*޲*/ + } + + StackFree(&pRedunStruct->SnLnkStack); + + if(pRedunStruct->pSnStack != NULL) + { + free((void *)pRedunStruct->pSnStack); + pRedunStruct->pSnStack = NULL; + } + else + { + /*޲*/ + } + + pRedunStruct->SnLinkhead = NULL; /*ͷÿ*/ + + return ret; +} + + +/***************************************************************************************** +*: +* ˢദм +*˵: +* RPHANDLE_INFO_STRU *pRedunStruct ͳһṹ +* UINT16 sLen_Input м +* UINT8 *Input_Data_LnkMes м +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpHandleRefresh(UINT16 sLen_Input, UINT8 *Input_Data_LnkMes,RPHANDLE_INFO_STRU *pRedunStruct)/* %RELAX */ +{ + UINT8 NumOfLink, i = 0, ret = 0; + RPHANDLESNLINK_STRU *TempIndex=NULL; + RPHANDLESNLINK_STRU *LastIndex=NULL; + STACK_DATA_TYPE pData; + UINT8 popret; + UINT16 index; + + if((pRedunStruct == NULL)||(Input_Data_LnkMes == NULL)) /* ǿռ */ + { + ret = 0; + return ret; + } + else + { + /* */ + } + + /*ýڵַѹջ*/ + TempIndex = pRedunStruct->SnLinkhead; + while(TempIndex != NULL) + { + ret=StackPush(&pRedunStruct->SnLnkStack,(STACK_DATA_TYPE)TempIndex); + if(ret ==0) + { + return ret; + } + else + { + TempIndex = TempIndex->NextNode; + } + } + pRedunStruct->SnLinkhead = NULL; + + if(sLen_Input% RP_HANDLE_LNK_LENGTH != 0) + { + /*¼*/ + ret = 0; + return ret; + } + else if(sLen_Input == 0) + { + /*¼*/ + + } + else + { + NumOfLink = (UINT8)(sLen_Input / RP_HANDLE_LNK_LENGTH); /*ڵϢREDUN_LNK_LENGTHֽ*/ + + for(i = 0; i < NumOfLink; i++) + { + /*ȡڵڴ;*/ + popret = StackPop(&pRedunStruct->SnLnkStack, &pData); + if(0 == popret) + { + ret = 0; + return ret; /*ûпõڴڵ*/ + } + else /*Ϊڵ·Ϣֵ*/ + { + index = 0; + TempIndex = (RPHANDLESNLINK_STRU *)pData; + TempIndex->SnLink_Info.DestDevName = ShortFromChar(&Input_Data_LnkMes[i * RP_HANDLE_LNK_LENGTH+ index]); + index +=2; + TempIndex->SnLink_Info.LastSn = LongFromChar(&Input_Data_LnkMes[i * RP_HANDLE_LNK_LENGTH + index]); + index +=4; + + TempIndex->SnLink_Info.maxLostSn= Input_Data_LnkMes[i * RP_HANDLE_LNK_LENGTH + index]; + index +=1; + } + + if(i == 0) /*һβΪͷڵ*/ + { + pRedunStruct->SnLinkhead = TempIndex; + } + else + { + LastIndex->NextNode = TempIndex; + } + LastIndex = TempIndex; + } + TempIndex->NextNode = NULL; + } + + ret = 1; + + return ret; +} + + +/*********************************************************************** + * : RpHandleLnkDelete + * : ͨúӦÿɾ豸Ƶ· + * : + * + * -------------------------------------------------------------- + * devName UINT16 IN 豸 + * pdelDevSn RPHANDLE_INFO_STRU * IN ͳһṹ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ + +UINT8 RpHandleLnkDelete(UINT16 devName,RPHANDLE_INFO_STRU *pdelDevSn) +{ + UINT8 ret = 0; + RPHANDLESNLINK_STRU *curIndex = NULL; + RPHANDLESNLINK_STRU *preIndex = NULL; + + curIndex = pdelDevSn->SnLinkhead; + while(curIndex != NULL) + { + if(curIndex->SnLink_Info.DestDevName == devName) + { + if(preIndex == NULL) + { + pdelDevSn -> SnLinkhead = curIndex->NextNode; + curIndex->SnLink_Info.DestDevName = 0; + curIndex->SnLink_Info.LastSn = 0; + curIndex->SnLink_Info.maxLostSn = 0; + if( StackPush(&pdelDevSn->SnLnkStack,(UINT32)curIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + }/*if(һָpreIndex == NULL)*/ + /*ɾڵ㲻ͷڵ*/ + else + { + preIndex->NextNode = curIndex->NextNode; + curIndex->SnLink_Info.DestDevName = 0; + curIndex->SnLink_Info.LastSn = 0; + curIndex->SnLink_Info.maxLostSn = 0; + if( StackPush(&pdelDevSn->SnLnkStack,(UINT32)curIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + /* wangpeipei 20120223 Del E */ + } + + } + else + { + + } + preIndex = curIndex; + curIndex = curIndex->NextNode; + } + ret = 1; + return ret; +} + +/***************************************************************************************** +*: + * ͬʱݡ + * ύԭµкűϴνյкŴ,ͬʱڹ涨ķΧڡ +*˵: +* [in]RPHANDLE_INFO_STRU *pRedunInfoStru ͳһṹ +* [in]UINT16 *destDevName 豸 +* [out]UINT32 crrSnc ǰĵк +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 ReadRpHandleQueueData(UINT16 destDevName,UINT32 crrSnc,RPHANDLE_INFO_STRU *pRedunInfoStru) +{ + UINT8 ret = 1;/*شֵ*/ + RPHANDLESNLINK_STRU* pLnkNode = NULL; + UINT8 flag = 1; + + + pLnkNode = RpHandleSearchSnLnkByAddr(destDevName,pRedunInfoStru); + if(pLnkNode == NULL) + { + + pLnkNode = RpHandleInsertNodeLnkByAddr(destDevName,pRedunInfoStru); + if (pLnkNode == NULL) + { + /* Ҫ׷Ӹ澯¼Ժ׷Ӿ */ + } + flag = 0;/* һβ˽ڵ*/ + } + else + { + /* ·Ѿ */ + flag = 1; + } + + if (flag == 0) + { + + if(pLnkNode != NULL) + { + /* ·ек*/ + pLnkNode->SnLink_Info.LastSn = crrSnc; + /*ݴݸӦ */ + } + } + else + { + if (0 == RpHandleIsTimeOut(crrSnc,pLnkNode->SnLink_Info.LastSn,pLnkNode->SnLink_Info.maxLostSn)) + { + /* ·ек*/ + + /* ֡ݴݸӦ */ + } + else + { + /*ݳʱ,ӦòӦö֡ */ + ret = 0; + } + pLnkNode->SnLink_Info.LastSn = crrSnc; + } + + return ret; +} + +/******************************************************************************************* +: + ѯ·нڵָIJкŻѯ·ɶλ·Ĺ +˵: + [in] UINT16 Dest_DevName Է豸Type+ID + RPHANDLE_INFO_STRU *pRedunStruct ͳһṹ +ֵ: + ڵĵַָ + + 1. ݶԷ豸кŻвѯӦ·ش˽ڵָ +*******************************************************************************************/ +RPHANDLESNLINK_STRU* RpHandleSearchSnLnkByAddr(UINT16 devName,RPHANDLE_INFO_STRU *pRedunStruct) +{ + RPHANDLESNLINK_STRU *CurIndex; + RPHANDLESNLINK_STRU *pret; + + /*ǰָͷָ뿪ʼ*/ + CurIndex = pRedunStruct->SnLinkhead; + + + while(1) + { + if(CurIndex != NULL) + { + /*ҵҪѯڵ*/ + if(devName == CurIndex->SnLink_Info.DestDevName) + { + return CurIndex;/*صǰָ*/ + } + else + { + CurIndex = CurIndex->NextNode; /*ûҵҪɾڵ㣬ǰָ붼һڵ*/ + } + } /* if(CurIndex != NULL)*/ + else + { + pret = NULL; + return pret; /*ûҵҪ·*/ + } + }/*while(1)*/ +} + +/******************************************************************************************* +: + ָĽڵ뵽кŻй涨λ +˵: + [in]UINT16 devName Է豸 + RPHANDLE_INFO_STRU *pRedunStruct ͳһṹ +ֵ: + ǰ·ָ + + 1·뵽кŻ + 2Ϊ·һЩϢ +*******************************************************************************************/ +RPHANDLESNLINK_STRU* RpHandleInsertNodeLnkByAddr( UINT16 devName,RPHANDLE_INFO_STRU *pRedunStruct) +{ + RPHANDLESNLINK_STRU *LastIndex; + RPHANDLESNLINK_STRU *CurIndex; + RPHANDLESNLINK_STRU *TempIndex; + STACK_DATA_TYPE pData; + DSU_FSFB_LINK_RINFO_STRU pTmpDsuRRsspLnk; + UINT8 popret; + /*REDUNSNLINK_STRU *pret;*/ + UINT8 ret = 0; + UINT8 maxLostSn = 0; + UINT8 destType = 0; + + /* ѯ豸ͨԱȡ */ + destType = (UINT8)(devName/0x100); + ret = dsuFsfbSetCommInfo(&pTmpDsuRRsspLnk,pRedunStruct->LocalType,destType); + if (ret == 1) + { + /* κδ */ + } + else + { + TempIndex = NULL; + return TempIndex; + } + maxLostSn = pTmpDsuRRsspLnk.MaxLost; + + /*ǰָͷָ뿪ʼ*/ + CurIndex = pRedunStruct->SnLinkhead; + TempIndex = NULL; + LastIndex = NULL; + + /* һڵ */ + popret = StackPop(&pRedunStruct->SnLnkStack, &pData); + if(0 == popret) + { + TempIndex = NULL; + return TempIndex; /*ûпõڴڵ*/ + } + else + { + TempIndex = (RPHANDLESNLINK_STRU *)pData; + /*ĿNameֵ*/ + TempIndex->SnLink_Info.DestDevName = devName; + TempIndex->SnLink_Info.maxLostSn = maxLostSn; + TempIndex->SnLink_Info.LastSn = 0; + } + + + while (CurIndex != NULL) + { + if (CurIndex->SnLink_Info.DestDevName < devName) + { + break; + } + else + { + LastIndex = CurIndex; + CurIndex = CurIndex->NextNode; + } + } + + if(LastIndex != NULL) + { + LastIndex->NextNode = TempIndex; + TempIndex->NextNode = CurIndex; + } + else + { + TempIndex->NextNode = CurIndex; + pRedunStruct->SnLinkhead = TempIndex; + } + + return TempIndex; +} + +/*************************************************************************************************************** +: + ʼкŻջ +˵: + RPHANDLE_INFO_STRU *pRedunStruct ͳһṹ +ֵ: + ɹ1,ʧܷ0 + + ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +***************************************************************************************************************/ +UINT8 RpHandle_init_SnStack(RPHANDLE_INFO_STRU *pRedunStruct) +{ + UINT16 i;/*ѭ*/ + RPHANDLESNLINK_STRU *SnLnk_stack = NULL; + UINT8 ret; + + if(pRedunStruct->SnLnkStack.pStackData != NULL) + { + for(i = 0;i < pRedunStruct->SnLnkStack.TotalSize;i++) + { + pRedunStruct->SnLnkStack.pStackData[i] = 0;/*ԸֵΪָ룬൱Ӧڴ*/ + } + } + else + { + ret = 0; + return ret; + } + + SnLnk_stack = (RPHANDLESNLINK_STRU *)malloc(sizeof(RPHANDLESNLINK_STRU) * pRedunStruct->SnLnkStack.TotalSize); + if(SnLnk_stack == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(SnLnk_stack,sizeof(RPHANDLESNLINK_STRU) * pRedunStruct->SnLnkStack.TotalSize,0,sizeof(RPHANDLESNLINK_STRU) * pRedunStruct->SnLnkStack.TotalSize); + } + for (i = 0;i < pRedunStruct->SnLnkStack.TotalSize;i++) + { /*ѹtotalsizeڵ*/ + if(StackPush(&pRedunStruct->SnLnkStack,(UINT32)&SnLnk_stack[i]) != 1) + { + ret = 0; + return ret;/*ѹڵʧ*/ + } + else + { + /*޲*/ + } + } + pRedunStruct->pSnStack = (UINT32 *) SnLnk_stack; + + ret = 1; + return ret; +} + +/* +* : жǷʱ,жϵǰʱ뿪ʼʱʱֵСʱ䡣 +* : UINT32 Curtime ǰʱ + UINT32 StartTime ʼʱ + UINT32 AllowTimeout ijʱʱ +* : +* : +* ȫֱ : +* ֵ : 0: ʱ 0xff:ǰʱСڿʼʱ䣬ֵʱ +*/ +UINT8 RpHandleIsTimeOut(UINT32 Curtime,UINT32 StartTime,UINT32 AllowTimeout) +{ + UINT8 ret = 0; + INT32 spdTime = 0; + spdTime = (INT32)(Curtime - StartTime); /* ʱֵ */ + if(spdTime < 0) + { + ret = (UINT8)0xFF; + } + else if((UINT32)spdTime < AllowTimeout) + { + ret = (UINT8)0; + } + else + { + ret = (UINT8)1; + } + + return ret; +} diff --git a/TSCP/src/protocol/fsfb/common_fsfb/RpHandleInterface.h b/TSCP/src/protocol/fsfb/common_fsfb/RpHandleInterface.h new file mode 100644 index 0000000..3c89952 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/RpHandleInterface.h @@ -0,0 +1,30 @@ +/************************************************************************ +* ļRpHandleInterface.h +* ļ +* ļΪЭ麯ͷļջغļ¼غ +* ʱ䣺2009.10.08 +************************************************************************/ +#ifndef _RP_HANDLE_INTERFACE_H +#define _RP_HANDLE_INTERFACE_H + +#include "RpHandlePlatform.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +UINT8 RpHandle_init_SnStack(RPHANDLE_INFO_STRU *pRedunStruct); + +RPHANDLESNLINK_STRU* RpHandleSearchSnLnkByAddr(UINT16 devName,RPHANDLE_INFO_STRU *pRedunStruct); +RPHANDLESNLINK_STRU* RpHandleInsertNodeLnkByAddr(UINT16 devName,RPHANDLE_INFO_STRU *pRedunStruct); +UINT8 RpHandleIsTimeOut(UINT32 Curtime,UINT32 StartTime,UINT32 AllowTimeout); +UINT8 RpHandleFreeSpace(RPHANDLE_INFO_STRU *pRedunStruct); +UINT8 ReadRpHandleQueueData(UINT16 destDevName,UINT32 crrSnc,RPHANDLE_INFO_STRU *pRedunInfoStru); +UINT8 RpHandleRefresh(UINT16 sLen_Input, UINT8 *Input_Data_LnkMes,RPHANDLE_INFO_STRU *pRedunStruct); +UINT8 RpHandleLnkDelete(UINT16 devName,RPHANDLE_INFO_STRU *pdelDevSn); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/fsfb/common_fsfb/RpHandlePlatform.h b/TSCP/src/protocol/fsfb/common_fsfb/RpHandlePlatform.h new file mode 100644 index 0000000..4e2a260 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/RpHandlePlatform.h @@ -0,0 +1,131 @@ +/************************************************************************ +* ļRpHandlePlatform.h +* ļദýṹͷļ +* ʱ䣺2009.11.17 +* ޸ļ¼ +* 2013.2.4 RpHandleLnkDeleteɾ· +* 2011.12.07 RpHandleLnkDeleteɾ· +* 2013.02.07 ޸RedunReceive +************************************************************************/ + +#ifndef _RP_HANDLE_PLATFORM_H +#define _RP_HANDLE_PLATFORM_H + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "CommonStack.h" + + + +#ifdef __cplusplus +extern "C" { +#endif + +#define RP_HANDLE_LNK_LENGTH 7 + +/*кŻڵϢ*/ +typedef struct +{ + UINT16 DestDevName; /* Է豸ʶ */ + UINT32 LastSn; /* ϴη͵кţ0ʾһη*/ + UINT8 maxLostSn; /* Ķ */ +} RPHANDLESNLINK_INFO_STRU; + +/*кŻ*/ +typedef struct RpHandleStSnLink_Node +{ + RPHANDLESNLINK_INFO_STRU SnLink_Info; /*ڵ·Ϣ*/ + struct RpHandleStSnLink_Node *NextNode; /*һIDͨŶԷе׵ַ*/ +} RPHANDLESNLINK_STRU ; + +/*ͳһṹ*/ +typedef struct RpHandle_Info +{ + UINT8 LocalType; /*豸type*/ + UINT8 MaxNumLink; /*ͨŵĶ*/ + UINT8 MaxNumPerCycle; /*һÿЧ*/ + UINT8* RecordArray; /*¼*/ + UINT16 RecordArraySize; /*¼С*/ + UINT8* VarArray; /*ģij2ʾм*/ + UINT16 VarArraySize; /*ģij鳤*/ + RPHANDLESNLINK_STRU *SnLinkhead; /*кŻͷָ*/ + CommonStack SnLnkStack; /*кŻջ*/ + UINT32 *pSnStack; /*ָջռ䣬ͷſռʱʹ*/ +} RPHANDLE_INFO_STRU; + +/************************************************************************* +* : +* ͨúʵڴռ +* ˵: +* [in]RPHANDLE_INFO_STRU *pRedunStruct ͬһṹ; +* [in]UINT8* fileName ݵĵַ +* ֵ: +* return 1 +* return 0쳣 +**************************************************************************/ +UINT8 RpHandleInit(RPHANDLE_INFO_STRU *pRedunStruct); + + + +/*********************************************************************** + * : RpHandleLnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * devName UINT16 IN 豸 + * pdelDevSn RPHANDLE_INFO_STRU * IN ͳһṹ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ + +UINT8 RpHandleLnkDelete(UINT16 devName,RPHANDLE_INFO_STRU *pdelDevSn); + +/************************************************************************************** + * + * ͷЭںRedunInitзڴռ + * ڲ + * RPHANDLE_INFO_STRU * pRpStruct ͳһṹ + * ֵ + * + ***************************************************************************************/ +UINT8 RpHandleFreeSpace(RPHANDLE_INFO_STRU *pRedunStruct); + +/***************************************************************************************** +*: +* ӺݣдDataToApp +*˵: +* RPHANDLE_INFO_STRU *pRedunStruct ͳһṹ +* [in]QueueStruct* OutnetQueueA +* [in]QueueStruct* OutnetQueueB +* [out]QueueStruct* RedunToRs ݵRSSP +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpHandleReceive(QueueStruct* OutnetQueueA,QueueStruct* OutnetQueueB, RPHANDLE_INFO_STRU *pRedunStruct,QueueStruct* RedunToRs); + +/***************************************************************************************** +*: +* ӦôOutputDataQueue֡дAppArrayVarArray +*˵: +* RPHANDLE_INFO_STRU *pRedunStruct ͳһṹ +*ֵ: +* ദЭм; +*****************************************************************************************/ +UINT16 RpHandleOutput(RPHANDLE_INFO_STRU *pRpStruct); +/***************************************************************************************** +*: +* ˢм +*˵: +* RPHANDLE_INFO_STRU *pRedunStruct ͳһṹ +* UINT16 sLen_Input м +* UINT8 *Input_Data_LnkMes м +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpHandleRefresh(UINT16 sLen_Input, UINT8 *Input_Data_LnkMes,RPHANDLE_INFO_STRU *pRedunStruct); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/fsfb/common_fsfb/fsfbProtclStruct.h b/TSCP/src/protocol/fsfb/common_fsfb/fsfbProtclStruct.h new file mode 100644 index 0000000..4dab339 --- /dev/null +++ b/TSCP/src/protocol/fsfb/common_fsfb/fsfbProtclStruct.h @@ -0,0 +1,198 @@ +/******************************************************** +* +* ļ FsfbProtclStruct.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ䣺 2013.09.11 +* +* FSFBʹõĽṹ嶨 +* ʹע⣺ +* +* ޸ļ¼ +*2014.5.14 +* ޸ݣ˷״̬Fsfb_SendBtm_BtdAbtBTMģʽBTDABT֡ +* ޸ԭCIյBTD֡ʱӦLEUȷ֡ABT֡ +********************************************************/ + +#ifndef _FSFB_PROTCL_STRUCT_H_ +#define _FSFB_PROTCL_STRUCT_H_ + +#include "CommonQueue.h" + +#include "FsfbProtclCommon.h" +#include "RpHandlePlatform.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*-------------------------------------------------------------------- + * Fsfbڲʹýṹ Start + *--------------------------------------------------------------------*/ + +/* ʱڵ */ +typedef struct FsfbDataNodeStru +{ + UINT16 DevName; /* 豸ʶ */ + UINT32 TCr; /* к */ + UINT8 ApplCat; /* Application cat*/ + UINT16 DataLen; /* ij */ + UINT8 *Data; /* */ + UINT16 srcAddr; /* Դַ */ + UINT16 destAddr; /* Ŀ괦 */ + struct DataNodeStru *pNextNode; /* һڵ */ + } FsfbDataNode; + +/* ·״̬ TODO */ +typedef enum +{ + Fsfb_Halt = 0x00, /* ж ·n֮sse֮״̬nʱΪ4 ߳ʼ״̬IDLE */ + Fsfb_SendSSE = 0x01, /* SSE */ + Fsfb_WaitSse =0x80, /* ȴSSE */ + Fsfb_WaitSSR = 0x02, /* ȴSSR */ + Fsfb_RecvData = 0x04, /* */ + Fsfb_SendSSR = 0x20, /* SSR */ + Fsfb_SendData = 0x40, /* */ + Fsfb_WaitBtm_AbtOrSse = 0x05, /* ȴBTMABT֡SSE֡ */ + Fsfb_WaitBtm_SbtAbt = 0x06, /* ȴBTMsbtAbt֡ */ + Fsfb_WaitBtm_Ebt =0x07, /* ȴBTMEbt֡ */ + Fsfb_WaitBtm_Sseabt =0x09, /* ȴBTMSSEABT֡ */ + Fsfb_WaitBtm_Btcabt =0x10, /* ȴBTMBTCABT֡ */ + Fsfb_SendBtm_Ebt = 0x11, /* BTMEBT֡ */ + Fsfb_SendBtm_Btc = 0x12, /* BTMBTC֡ */ + Fsfb_SendBtm_Abt = 0x13, /* BTMABT֡ */ + Fsfb_SendBtm_Sbt = 0x14, /* BTMSBT֡ */ + Fsfb_SendBtm_BtdAbt = 0x15 /* BTMBTDӦ֡ */ +} ENUM_FSFB_LINK_STATUS; + +/* ڵ״̬ö */ +typedef enum +{ + Replace_Fsfb = 0x01, /* ɸ״̬ ýڵֹͣݻdzʼ״̬ */ + DisbaledReplace_Fsfb = 0x02 /* ɸ״̬ýڵ㻹ڼ */ +} ENUM_FSFB_NODE_STATUS; + +/* 豸ڵϢṹ */ +typedef struct +{ + UINT32 SIDe[2]; /* SID */ + UINT32 SIDr[2]; /* SID */ + UINT32 SINITr[2]; /* SINIT */ + UINT32 SINITe[2]; /* SINIT */ + UINT32 DATAVER[2]; /* DATAVER */ + UINT8 NumDataVer[2]; /* Data 汾 */ + UINT8 DLost; /* */ + UINT8 SSDelay; /* 涨ʱ䣨SSDelay */ + UINT8 AntiDelayCount; /* ͬ */ + UINT8 Tout; /* BSDijʱ */ + UINT8 MaxLost; /* ʧ */ + UINT32 PREC_SINIT_K[2][5]; /* ߲PREC_SINIT? */ + UINT32 PREC_FIRSTSINIT[2]; /* ߲PREC_FIRSTSINIT */ + UINT32 TSD_POST_RXDADA_K[2][5]; /* ߲ BSD̶ֵ */ +} FsfbNodeParamInfoStru; + +/* Fsfb·Ϣṹ */ +typedef struct +{ + UINT16 rcvSrcAdd; /* սڵԴַ */ + UINT16 sendSrcAdd; /* ͽڵԴַ */ + UINT16 rcvDestAdd; /* սڵĿַ */ + UINT16 sendDestAdd; /* ͽڵĿַ */ + UINT8 RecvLinkStatus; /* ·״̬ */ + UINT8 SendLinkStatus; /* ·״̬ */ + UINT8 NoRecvDataCycleNum; /* */ + UINT8 NoAppDataCycleNum; /* ޷Ӧ */ + ComTimeStampStru TimeStmp; /* ʱϢ */ + FsfbNodeParamInfoStru LocalNode; /* ܽڵ */ +} FsfbLinkInfoStru; + + +/* ͨŽڵṹ */ +typedef struct Fsfb_Lnk_Info_Node +{ + UINT16 DestDevName; /* Է豸ʶ */ + UINT8 Applcat; /* */ + UINT8 IsSendFlag; /* Ƿ͵ı */ + FsfbLinkInfoStru FsfbLinInfo; /* Fsfb·Ϣ 0:TSDģʽ·Ϣ 1BTMģʽµ·Ϣ */ + struct Fsfb_Lnk_Info_Node *NextNode; /*һIDͨŶԷ·е׵ַ*/ +} Fsfb_Lnk_Info_Node_Stru; + +/*FSFBRGetLnkInfoʹõĽṹ*/ +typedef struct { + UINT16 DestName;/*ʾĿʶ*/ + UINT16 SseAddr; /*ʾSSE_SSR_Destination_Addresݿ*/ + UINT32 SID_NUMBER_E[2];/* ±01ֱӦݿе12ͨ,ֵΪͷSID*/ + UINT32 SID_NUMBER_R[2];/* ±01ֱӦݿе12ͨ,ֵΪܷSID*/ + UINT32 PREC_FIRSTSINIT[2]; /*ʾ׸SINIT*/ + UINT8 MaxLost;/*LOST*/ + UINT8 DLost;/*ʱ*/ + UINT8 WSsrOut;/*ȴSSRʱ*/ + UINT8 AntiDelayCount;/*ͬ*/ + UINT8 TOut; /*ijʱ*/ +} FSFB_LINK_RINFO_STRU; + +/*FSFB lnk Ϣṹ*/ +typedef struct +{ + UINT16 EmitterName; /*豸ʶ */ + UINT16 ReceptorName; /*豸ʶ */ + UINT16 ChannelNumber; /*ͨ*/ + UINT32 SID_NUMBER_E; /* ֵΪͷSID*/ + UINT32 SINIT_NUMBER; /* ݿ*/ + UINT8 DATANUM; /*ݿ*/ + UINT32 DATAVER_1_Number; /*ݿ*/ + UINT16 srcAddr; /*FSFB_Source_Address*/ + UINT16 SseAddr; /*ʾSSE_SSR_Destination_Addresݿ*/ + UINT32 SID_NUMBER_R; /* ֵΪܷSID*/ + UINT32 PREC_FIRSTSINIT ; /*ʾ׸SINIT*/ +}FSFB_LNK_INFO_STRU; + +/*յ*/ +typedef struct +{ + UINT16 DstDevName; + UINT16 NetsPkgNum[2]; +}FsfbNetsRecvPkgNum; + +/*-------------------------------------------------------------------- + * Fsfbڲʹýṹ End + *--------------------------------------------------------------------*/ +typedef struct +{ + UINT8 LocalID; /* 豸IDӦðĵڳʼʱд */ + UINT8 LocalType; /* 豸typeӦðĵڳʼʱд */ + UINT32 *CycleNum; /* ںţӦðĵÿڿʼʱд */ + UINT8 MaxNumLink; /* FsfbͬʱͨŵӦðĵڳʼʱд */ + UINT8 MaxNumPerCycle; /* FsfbһÿЧݣӦðĵڳʼʱд */ + UINT16 InputSize; /* Fsfbһ֡ӦݳȣӦðĵڳʼʱд */ + UINT16 OutputSize; /* Fsfb㷢һ֡ӦݳȣӦðĵڳʼʱд */ + UINT8 *RecordArray; /* Fsfb¼ */ + UINT16 RecordArraySize; /* Fsfb¼С */ + UINT8 *AppArray; /* ģij1ʾ */ + UINT16 AppArraySize; /* Fsfbģij鳤 */ + UINT8 *VarArray; + UINT16 VarArraySize; + QueueStruct DataToApp; /* FsfbЭӦõݶ */ + UINT32 DataToAppSize; /* ЭӦõݶг */ + QueueStruct OutputDataQueue; /* FsfbӦøЭݶ */ + UINT32 OutputDataQueueSize; /* ӦøЭݶг */ + QueueStruct OutnetQueueR; /* Fsfbն()*/ + QueueStruct OutnetQueueB; /* Fsfbն()*/ + UINT32 OutnetQueueSize; /* նгȣЭʼʱд */ + RPHANDLE_INFO_STRU RpInfoStru; /* ͳһṹ */ + + Fsfb_Lnk_Info_Node_Stru *LnkHead; /*·ͷ*/ + UINT8 *TmpDataBuff; /* ʱ */ + ComStackElement LnkStack; /* ·ջ */ + UINT16 NetsRecvPkgNumsLen; /*յ鳤*/ + FsfbNetsRecvPkgNum* NetsRecvPkgNums; /*յ*/ +} FSFB_INFO_STRU; + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/protocol_cbtc/common_dqu_protocol/dsuProtclFun.c b/TSCP/src/protocol/protocol_cbtc/common_dqu_protocol/dsuProtclFun.c new file mode 100644 index 0000000..64c1e9f --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_dqu_protocol/dsuProtclFun.c @@ -0,0 +1,605 @@ +/******************************************************************************* +* +* ļ dsuRpFunc.c +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* RpЭصdsuѯ +* ʹע⣺ +* ޸ļ¼ +* +*******************************************************************************/ + +#include "dsuProtclFun.h" +#include "CommonMemory.h" +#include "Convert.h" +#include "dfsDataRead.h" +#include "dquDataTypeDefine.h" + +#ifdef DEV_IP_TABLE_NO_HLHT +#define DSU_IP_INFO_STRU_SIZE (22) /*豸IPַռֽڳ*/ +#else +#define DSU_IP_INFO_STRU_SIZE (30) /*豸IPַռֽڳ*/ +#endif + +#define DSU_COMM_PROTCL_STRU_SIZE (3) /*豸ͨЭռֽڳ*/ + +/*FSsheetҳϢ*/ +typedef struct +{ + UINT32 Id; /**/ + UINT32 Len; /**/ + UINT32 StartIdx; /*excelʼַ*/ + UINT32 RowCount; /**/ + UINT8* Data; /*excel*/ +} SheetInfo; + +static void InitSheet(SheetInfo* sheetInfo, const UINT32 dataLen, UINT8 data[], const UINT32 excelId, const UINT32 sheetId); +static UINT8 GetCommOppDevTypes(SheetInfo* commSheet, UINT8 locType, UINT8* oppTypes, UINT8* oppTypePtls, UINT16* oppTypeNum, const UINT16 maxOppTypeNum); +static void GetCommOppDevNum(SheetInfo* devIpSheet, UINT8 oppType, UINT16* dupOppHlhtIdsLen, UINT32* dupOppHlhtIds, const UINT16 maxDupOppHlhtIdsLen, UINT8* devNum); + +/* +*: DsuCommonInfoInit +*: ѯʼ +*: UINT8 *pFsName FSļ +*: DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo ʹñ +*: +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 DsuCommonInfoInit(UINT8 *pFsName, DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT8 readRtn = 0; /*ȡFSֵ*/ + UINT8 *pData = NULL; /**/ + UINT32 dataLen = 0; /*ݳ*/ + UINT32 mallocLen = 0; /*ռС*/ + UINT32 offset = 0; /*ƫ*/ + UINT32 i = 0; /*ѭ*/ + + if ((NULL != pFsName) && (NULL != pDsuProtclBookIpInfo)) /*ηǿ*/ + { + readRtn = dquGetConfigData((CHAR*)pFsName, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_IP_ID, &pData, &dataLen); /*ȡ豸IPַ*/ + if ((1 == readRtn) && (DSU_IP_INFO_STRU_SIZE <= dataLen)) + { + pDsuProtclBookIpInfo->IpDevLen = (UINT16)(dataLen / DSU_IP_INFO_STRU_SIZE); /**/ + mallocLen = sizeof(UINT16)*(pDsuProtclBookIpInfo->IpDevLen); /*ռС*/ + pDsuProtclBookIpInfo->IpDevTypeIds = (UINT16*)malloc(mallocLen); /*ռ*/ + if (NULL != pDsuProtclBookIpInfo->IpDevTypeIds) + { + CommonMemSet(pDsuProtclBookIpInfo->IpDevTypeIds, mallocLen, 0, mallocLen); /*ʼ*/ + + mallocLen = sizeof(UINT32)*(pDsuProtclBookIpInfo->IpDevLen); /*ռС*/ +#ifndef DEV_IP_TABLE_NO_HLHT + pDsuProtclBookIpInfo->IpDevHlhtIds = (UINT32*)malloc(mallocLen); /*ռ*/ + if (NULL != pDsuProtclBookIpInfo->IpDevHlhtIds) + { + CommonMemSet(pDsuProtclBookIpInfo->IpDevHlhtIds, mallocLen, 0, mallocLen); /*ʼ*/ +#endif + + for (i = 0; i < pDsuProtclBookIpInfo->IpDevLen; i++) + { + /*2ֽ豸ID*/ + pDsuProtclBookIpInfo->IpDevTypeIds[i] = ShortFromChar(&pData[offset]); +#ifndef DEV_IP_TABLE_NO_HLHT + /*4ֽڻͨID*/ + pDsuProtclBookIpInfo->IpDevHlhtIds[i] = LongFromChar(&pData[offset + 2]); +#endif + offset += DSU_IP_INFO_STRU_SIZE; + } + if (offset == dataLen) /*豸IDֵɹ*/ + { + readRtn = dquGetConfigData((CHAR*)pFsName, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_COMM_PROTCL_ID, &pData, &dataLen); /*ȡ豸ͨЭ*/ + if ((1 == readRtn) && (DSU_COMM_PROTCL_STRU_SIZE <= dataLen)) + { + pDsuProtclBookIpInfo->CommProtclStruLen = (UINT16)(dataLen / DSU_COMM_PROTCL_STRU_SIZE); /**/ + mallocLen = sizeof(DSU_PROTCL_COMM_PROTCL_STRU)*(pDsuProtclBookIpInfo->CommProtclStruLen); /*ռС*/ + pDsuProtclBookIpInfo->pCommProtclStru = (DSU_PROTCL_COMM_PROTCL_STRU*)malloc(mallocLen); /*ռ*/ + if (NULL != pDsuProtclBookIpInfo->pCommProtclStru) + { + CommonMemSet(pDsuProtclBookIpInfo->pCommProtclStru, mallocLen, 0, mallocLen); /*ʼ*/ + + offset = 0; /*ƫƴ㿪ʼ*/ + for (i = 0; i < pDsuProtclBookIpInfo->CommProtclStruLen; i++) + { + /*1ֽڱ*/ + pDsuProtclBookIpInfo->pCommProtclStru[i].EmitterType = pData[offset]; + offset++; + /*1ֽڶԷ*/ + pDsuProtclBookIpInfo->pCommProtclStru[i].ReceptorType = pData[offset]; + offset++; + /*1ֽЭ*/ + if ((DSU_PROTCL_RSSP2 + 4) == pData[offset]) /*RSSPIIЭΪ9,õ±Ϊ5*/ + { + pDsuProtclBookIpInfo->pCommProtclStru[i].CommuType = DSU_PROTCL_RSSP2; + } + else + { + pDsuProtclBookIpInfo->pCommProtclStru[i].CommuType = pData[offset]; + } + offset++; + } + if (offset == dataLen) /*豸ͨЭֵɹ*/ + { + rtn = 1; + } + } + } + } +#ifndef DEV_IP_TABLE_NO_HLHT + } +#endif + } + } + } + + return rtn; +} + +/* +*: DsuProtclGetProtclType +*: ݱIDԷIDʹõЭ +*: UINT16 locTypeId ID +* UINT16 oppTypeId ԷID +* DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo ʹñ +*: +*: UINT8 *pProtclType Э +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 DsuProtclGetProtclType(UINT16 locTypeId, UINT16 oppTypeId, UINT8 *pProtclType, DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT8 locType = (UINT8)((locTypeId >> 8) & 0x00FF); /**/ + UINT8 oppType = (UINT8)((oppTypeId >> 8) & 0x00FF); /*Է*/ + UINT32 i = 0; /*ѭ*/ + + if ((NULL != pProtclType) && (NULL != pDsuProtclBookIpInfo)&&(NULL!= pDsuProtclBookIpInfo->pCommProtclStru)) /*ηǿ*/ + { + for (i = 0; i < pDsuProtclBookIpInfo->CommProtclStruLen; i++) /*豸ͨЭ*/ + { + /*ƥ䱾Է*/ + if ((pDsuProtclBookIpInfo->pCommProtclStru[i].EmitterType == locType) && (pDsuProtclBookIpInfo->pCommProtclStru[i].ReceptorType == oppType)) + { + *pProtclType = pDsuProtclBookIpInfo->pCommProtclStru[i].CommuType; + break; /*ҵ˳ѭ*/ + } + } + if (i != pDsuProtclBookIpInfo->CommProtclStruLen) /*ҵ*/ + { + rtn = 1; + } + } + + return rtn; +} + +/* +*: DsuGetProtclTypeInfo +*: ݱIDԷͨʱʹЭͨ豸(·) +*: UINT16 locTypeId ID +* DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo ʹñ +* UINT32 inDataLen ݳ +* UINT8 inData[] +* UINT16 globalVarOppTypePtlLen ͨŵĶԷ豸Э鳤 +*: UINT8 globalVarOppTypePtl[UINT8_MAX] ͨŵĶԷ豸Э +*: DSU_PROTCL_TYPE_STRU *dsuProtclTypeInfo Эͨ豸 +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 DsuGetProtclTypeInfo(UINT16 locTypeId, DSU_PROTCL_TYPE_STRU* dsuProtclTypeInfo, DSU_PROTCL_BOOK_IP_INFO_STRU* pDsuProtclBookIpInfo,UINT8 globalVarOppTypePtl[], UINT16 globalVarOppTypePtlLen, UINT32 inDataLen, UINT8 inData[]) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT8 locType = (UINT8)(locTypeId >> 8); /**/ + UINT32 i = 0; /*ѭ*/ + UINT8 outCanGetComm = 0; /*Ƿô*/ + UINT8 inCanGetComm = 0; /*Ƿô*/ + UINT16 oppTypeNum = 0; /*Է*/ + UINT16 dupOppHlhtIdLen = 0; /*ظԷID*/ + UINT8 devNum = 0; /*豸*/ + UINT32 oppTypeSpLen = 0; /*Է豸ռ䳤*/ + UINT32 dupOppHlhtIdSpLen = 0; /*ظԷͨIDռ䳤*/ + UINT8* oppType = NULL; /*Է豸*/ + UINT8* oppTypePtl = NULL; /*Է豸Э*/ + UINT32* dupOppHlhtId = NULL; /*ظԷͨID*/ + SheetInfo outCommSheet = { 0 }; /*ͬsheetҳ*/ + SheetInfo inCommSheet = { 0 }; /*ͬsheetҳ*/ + SheetInfo outDevIpSheet = { 0 }; /*ͬsheetҳ*/ + SheetInfo inDevIpSheet = { 0 }; /*ͬsheetҳ*/ + UINT32 outInCommRowCount = 0u; /*ͨЭsheetҳ*/ + UINT32 outInDevIpRowCount = 0u; /*豸IPַsheetҳ*/ + + if ((NULL != dsuProtclTypeInfo) && (NULL != pDsuProtclBookIpInfo)) + { + InitSheet(&outCommSheet, g_DataBufLen, g_pDataBuf, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_COMM_PROTCL_ID); + InitSheet(&inCommSheet, inDataLen, inData, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_COMM_PROTCL_ID); + InitSheet(&outDevIpSheet, g_DataBufLen, g_pDataBuf, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_IP_ID); + InitSheet(&inDevIpSheet, inDataLen, inData, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_IP_ID); + + outInCommRowCount = pDsuProtclBookIpInfo->CommProtclStruLen + inCommSheet.RowCount; + outInDevIpRowCount = pDsuProtclBookIpInfo->IpDevLen + inDevIpSheet.RowCount; + + oppTypeSpLen = sizeof(UINT8) * (outInCommRowCount); /*Էռ䳤*/ + dupOppHlhtIdSpLen = sizeof(UINT32) * (outInDevIpRowCount); /*ظԷIDռ䳤*/ + oppType = (UINT8*)malloc(oppTypeSpLen); /*Է*/ + oppTypePtl = (UINT8*)malloc(oppTypeSpLen); /*ԷʹЭ*/ + dupOppHlhtId = (UINT32*)malloc(dupOppHlhtIdSpLen); /*ظԷID*/ + + if ((NULL != oppType) && (NULL != oppTypePtl) && (NULL != dupOppHlhtId)) /*ǿ*/ + { + CommonMemSet(oppType, oppTypeSpLen, 0, oppTypeSpLen); /*ʼ*/ + CommonMemSet(oppTypePtl, oppTypeSpLen, 0, oppTypeSpLen); /*ʼ*/ + CommonMemSet(dupOppHlhtId, dupOppHlhtIdSpLen, 0, dupOppHlhtIdSpLen); /*ʼ*/ + + outCanGetComm = GetCommOppDevTypes(&outCommSheet, locType, oppType, oppTypePtl, &oppTypeNum, (UINT16)(outInCommRowCount)); + if (1u == outCanGetComm) /**/ + { + inCanGetComm = GetCommOppDevTypes(&inCommSheet, locType, oppType, oppTypePtl, &oppTypeNum, (UINT16)(outInCommRowCount)); + if ((1u == outCanGetComm) && ((0 == inCommSheet.RowCount) || (0 < inCommSheet.RowCount && 1u == inCanGetComm))) /**/ + { + for (i = 0; i < oppTypeNum; i++) /*Է*/ + { + if (oppType[i] < globalVarOppTypePtlLen) + { + globalVarOppTypePtl[oppType[i]] = oppTypePtl[i]; /*ȫͨŵĶԷ豸Э*/ + } + + devNum = 0; + if ((VOBC_TYPE == locType) && ((AOM_TYPE == oppType[i]) || (ITE_TYPE == oppType[i]))) + { + /*ATPԷAOM,ITEʱ̶ͨΪ2*/ + devNum = 2; + } + else if ((VOBC_TYPE == locType) && ((CI_TYPE == oppType[i]) || (ZC_TYPE == oppType[i]) || (ATS_TYPE == oppType[i]) || (PSC_TYPE == oppType[i]))) + { + /*ATPԷCI,ZC,ATSʱ̶ͨΪ3*/ + devNum = 3; + } + else + { + GetCommOppDevNum(&outDevIpSheet, oppType[i], &dupOppHlhtIdLen, dupOppHlhtId, (UINT16)(outInDevIpRowCount), &devNum); + GetCommOppDevNum(&inDevIpSheet, oppType[i], &dupOppHlhtIdLen, dupOppHlhtId, (UINT16)(outInDevIpRowCount), &devNum); + } + /*ӵӦЭ͵ͨ豸*/ + switch (oppTypePtl[i]) + { + case DSU_PROTCL_SFP: + (dsuProtclTypeInfo->sfpProtclNum) += devNum; + break; + case DSU_PROTCL_RSSP: + (dsuProtclTypeInfo->rsspProtclNum) += devNum; + break; + case DSU_PROTCL_RSR: + (dsuProtclTypeInfo->rsrProtclNum) += devNum; + break; + case DSU_PROTCL_RP: + (dsuProtclTypeInfo->redunProtclNum) += devNum; + break; + case DSU_PROTCL_RSSP2: + (dsuProtclTypeInfo->rssp2ProtclNum) += devNum; + break; + case DSU_PROTCL_FSFB: + (dsuProtclTypeInfo->fsfbProtclNum) += devNum; + break; + default: + break; + } + } + + rtn = 1; /*ִгɹ*/ + } + } + + /*ͷŶ̬ڴ*/ + free(oppType); + oppType = NULL; + free(oppTypePtl); + oppTypePtl = NULL; + free(dupOppHlhtId); + dupOppHlhtId = NULL; + } + } + + return rtn; +} + +/* +*: ʼsheetҳϢ +*: const UINT32 dataLen ݳ +* UINT8 data[] +* const UINT32 excelId excel +* const UINT32 sheetId sheetҳ +*: SheetInfo* sheetInfo sheetҳϢ +*: +*ֵ: +*/ +static void InitSheet(SheetInfo* sheetInfo, const UINT32 dataLen, UINT8 data[], const UINT32 excelId, const UINT32 sheetId) +{ + UINT32 idx = 0u; /*±*/ + UINT32 crcVal = 0u; /*crcֵ*/ + UINT32 crc = 0u; /*crc*/ + UINT32 curLen = 0u; /*ǰ*/ + UINT32 excelCount = 0u; /*excel*/ + UINT32 excelIdx = 0u; /*excel±*/ + UINT32 curExcelId = 0u; /*ǰexcel*/ + UINT32 curExcelPos = 0u; /*ǰexcelλ*/ + UINT32 curExcelStartPos = 0u; /*ǰexcelʼλ*/ + UINT32 sheetCount = 0u; /*sheet*/ + UINT32 sheetIdx = 0u; /*sheet±*/ + UINT32 curSheetId = 0u; /*ǰsheet*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT8 isFind = 0u; /*Ƿҵ*/ + + if ((0u < dataLen) && (NULL != data) && (NULL != sheetInfo)) /**/ + { + if ((idx + 40) <= dataLen) /*DH±*/ + { + /*4ֽCRC*/ + crcVal = LongFromChar(&data[idx]); + idx += 4; + /*4ֽڰ汾*/ + idx += 4; + /*4ֽڳ*/ + curLen = LongFromChar(&data[idx]); + idx += 4; + + if ((curLen == dataLen) && (4 < curLen)) + { + crc = Crc32(&data[4], curLen - 4); + if (crc == crcVal) + { + /*4ֽexcel*/ + excelCount = LongFromChar(&data[idx]); + idx += 4; + /*24ֽԤ*/ + idx += 24; + + for (excelIdx = 0; excelIdx < excelCount; excelIdx++) + { + if ((idx + 24) <= dataLen) /*DI±*/ + { + /*4ֽexcel*/ + curExcelId = LongFromChar(&data[idx]); + idx += 4; + if (curExcelId == excelId) + { + /*4ֽڳ*/ + idx += 4; + /*4ֽexcelλ*/ + curExcelPos = LongFromChar(&data[idx]); + curExcelStartPos = curExcelPos; + idx += 4; + /*12ֽԤ*/ + idx += 12; + + if ((curExcelPos + 40) <= dataLen) /*DH±*/ + { + /*4ֽexcel CRC*/ + crcVal = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + /*4ֽexcel汾*/ + curExcelPos += 4; + /*4ֽexcel*/ + curLen = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + + if (4 < curLen) + { + crc = Crc32(&data[curExcelStartPos + 4], curLen - 4); + if (crc == crcVal) + { + /*4ֽsheet*/ + sheetCount = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + /*24ֽԤ*/ + curExcelPos += 24; + + for (sheetIdx = 0; sheetIdx < sheetCount; sheetIdx++) + { + if ((curExcelPos + 24) <= dataLen) /*DH±*/ + { + /*4ֽsheet*/ + curSheetId = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + if (curSheetId == sheetId) + { + sheetInfo->Id = curSheetId; + /*4ֽڳ*/ + sheetInfo->Len = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + /*4ֽsheetexcelλ*/ + sheetInfo->StartIdx = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + /*2ֽ*/ + sheetInfo->RowCount = ShortFromChar(&data[curExcelPos]); + curExcelPos += 2; + /*2ֽ*/ + curExcelPos += 2; + /*8ֽԤ*/ + curExcelPos += 8; + + sheetInfo->Data = &data[curExcelStartPos]; + isFind = 1u; + } + else + { + curExcelPos += 20; /*ƫһDI*/ + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + if ((1u == isFind) || (1u == isBreak)) + { + break; + } + } + } + else /*crc*/ + { + isBreak = 1u; + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + } + else /**/ + { + idx += 20; /*ƫһDI*/ + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + if ((1u == isFind) || (1u == isBreak)) + { + break; + } + } + } + } + } + } +} + +/* +*: ȡͨŵĶԷ豸 +*: SheetInfo* commSheet 豸ͨЭ +* UINT8 locType +*: UINT8* oppTypes Է +* UINT8* oppTypePtls ԷЭ +* UINT16* oppTypeNum Է +* const UINT16 maxOppTypeNum Է +*: +*ֵ: +*/ +static UINT8 GetCommOppDevTypes(SheetInfo* commSheet, UINT8 locType, UINT8* oppTypes, UINT8* oppTypePtls, UINT16* oppTypeNum, const UINT16 maxOppTypeNum) +{ + UINT8 retVal = 0u; /*ֵ*/ + UINT32 rowLen = 0u; /*г*/ + UINT32 i = 0u; /*ѭ*/ + UINT32 j = 0u; /*ѭ*/ + UINT8 locDevType = 0u; /*豸*/ + UINT8 oppDevType = 0u; /*Է豸*/ + UINT8 ptlType = 0u; /*Э*/ + UINT8 isAddOppType = 0; /*ǷӶԷ*/ + UINT8 isConfigErr = 0u; /*Ƿô*/ + + if ((NULL != commSheet) && (NULL != oppTypes) && (NULL != oppTypePtls) && (NULL != oppTypeNum) && (0u < commSheet->Len) && (0u < commSheet->RowCount) && (0 == commSheet->Len % commSheet->RowCount)) /*sheet*/ + { + rowLen = commSheet->Len / commSheet->RowCount; + for (i = 0; i < commSheet->RowCount; i++) /*豸ͨЭ*/ + { + locDevType = commSheet->Data[commSheet->StartIdx + (i * rowLen)]; + oppDevType = commSheet->Data[commSheet->StartIdx + (i * rowLen) + 1]; + ptlType = commSheet->Data[commSheet->StartIdx + (i * rowLen) + 2]; + if (9 == ptlType) /*RSSPII9Ϊ5*/ + { + ptlType = DSU_PROTCL_RSSP2; + } + if (locDevType == locType)/* Ϊͷ */ + { + isAddOppType = 0; + for (j = 0; j < (*oppTypeNum); j++) /*鿴ǷظԷ*/ + { + if (oppTypes[j] == oppDevType) /*ظԷ*/ + { + if (oppTypePtls[j] != ptlType) /*ʹЭͲͬ,ô*/ + { + isConfigErr = 1u; + } + break; + } + } + if (j == (*oppTypeNum)) /*Ͳظ,*/ + { + isAddOppType = 1u; + } + if (0u == isConfigErr) /**/ + { + if ((1u == isAddOppType) && ((*oppTypeNum) < maxOppTypeNum)) /*ֵ*/ + { + oppTypes[*oppTypeNum] = oppDevType; /*Է*/ + oppTypePtls[*oppTypeNum] = ptlType; /*ʹЭ*/ + (*oppTypeNum)++; + } + } + else /*ô,˳*/ + { + break; + } + } + } + if (0 == isConfigErr) /**/ + { + retVal = 1u; + } + } + + return retVal; +} + +/* +*: ȡͨŵĶԷ豸 +*: SheetInfo* devIpSheet 豸IP +* UINT8 oppType Է +* UINT16* dupOppHlhtIdLen ظĶԷͨID +* UINT32* dupOppHlhtId ظĶԷͨID +*: UINT16* dupOppHlhtIdLen ظĶԷͨID +* UINT32* dupOppHlhtId ظĶԷͨID +* UINT8* devNum 豸 +*: +*ֵ: +*/ +static void GetCommOppDevNum(SheetInfo* devIpSheet, UINT8 oppType, UINT16* dupOppHlhtIdsLen, UINT32* dupOppHlhtIds, const UINT16 maxDupOppHlhtIdsLen, UINT8* devNum) +{ + UINT32 rowLen = 0u; /*г*/ + UINT32 i = 0u; /*ѭ*/ + UINT32 j = 0u; /*ѭ*/ + UINT16 devId = 0u; /*豸ID*/ + UINT32 hlhtId = 0u; /*HLHT ID*/ + + if ((NULL != devIpSheet) && (NULL != dupOppHlhtIdsLen) && (NULL != dupOppHlhtIds) && (NULL != devNum) && (0u < devIpSheet->Len) && (0u < devIpSheet->RowCount) && (0 == devIpSheet->Len % devIpSheet->RowCount)) /*sheet*/ + { + rowLen = devIpSheet->Len / devIpSheet->RowCount; + for (i = 0; i < devIpSheet->RowCount; i++) /*豸ͨЭ*/ + { + devId = ShortFromChar(&devIpSheet->Data[devIpSheet->StartIdx + (i * rowLen)]); + hlhtId = LongFromChar(&devIpSheet->Data[devIpSheet->StartIdx + (i * rowLen) + 2]); + if (((UINT8)(devId >> 8)) == oppType) /*豸ͬ*/ + { + for (j = 0; j < (*dupOppHlhtIdsLen); j++) + { +#ifdef DEV_IP_TABLE_NO_HLHT + if (dupOppHlhtIds[j] == devId) /*HLHT IDظ,˳*/ + { + break; + } +#else + if (dupOppHlhtIds[j] == hlhtId) /*HLHT IDظ,˳*/ + { + break; + } +#endif + } + if ((j == (*dupOppHlhtIdsLen)) && ((*dupOppHlhtIdsLen) < maxDupOppHlhtIdsLen)) /*HLHT IDظ*/ + { +#ifdef DEV_IP_TABLE_NO_HLHT + dupOppHlhtIds[*dupOppHlhtIdsLen] = devId; /*HLHT ID*/ +#else + dupOppHlhtIds[*dupOppHlhtIdsLen] = hlhtId; /*HLHT ID*/ +#endif + (*dupOppHlhtIdsLen)++; /*ȽϵHLHT ID1*/ + (*devNum)++; /*豸1*/ + } + } + } + } +} \ No newline at end of file diff --git a/TSCP/src/protocol/protocol_cbtc/common_dqu_protocol/dsuProtclFun.h b/TSCP/src/protocol/protocol_cbtc/common_dqu_protocol/dsuProtclFun.h new file mode 100644 index 0000000..811cbc5 --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_dqu_protocol/dsuProtclFun.h @@ -0,0 +1,120 @@ +/************************************************************************ +* +* ļ +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.29 +* з +* Эѯ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _DSU_PROTCL_FUN_H_ +#define _DSU_PROTCL_FUN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "CommonTypes.h" +#include "protocolConfig.h" +/* Эѯ汾Ŷ */ +#define DQU_PROTOCOL_VER_PRODUCT_NO 88/*Ʒ*/ +#define DQU_PROTOCOL_VER_MODULE_NO 25/*ģ*/ +#define DQU_PROTOCOL_VER_MAIN_VER 13/*ģ汾*/ +#define DQU_PROTOCOL_VER_SUB_VER 3 /*ģӰ汾*/ + +#define DSU_PROTCL_NTP ((UINT8)0) /*NTP*/ +#define DSU_PROTCL_SFP ((UINT8)1) /*SFP*/ +#define DSU_PROTCL_RP ((UINT8)2) /*RP*/ +#define DSU_PROTCL_RSR ((UINT8)3) /*RSR*/ +#define DSU_PROTCL_RSSP ((UINT8)4) /*RSSPI*/ +#define DSU_PROTCL_RSSP2 ((UINT8)5) /*RSSPII*/ +#define DSU_PROTCL_FSFB ((UINT8)6) /*FSFB*/ + +#define PROTCL_MGECFG_MAXCNT ((UINT8)0x06) /*Э*/ + +#define VOBC_TYPE ((UINT8)0x14) /*VOBC豸*/ +#define AOM_TYPE ((UINT8)0x15) /*AOM豸*/ +#define CI_TYPE ((UINT8)0x3C) /*CI豸*/ +#define ZC_TYPE ((UINT8)0x1E) /*ZC豸*/ +#define ATS_TYPE ((UINT8)0x03) /*ATS豸*/ +#define PSC_TYPE ((UINT8)0x61) /*PSC豸*/ +#define ITE_TYPE ((UINT8)0x18) /*ITE豸*/ + + /*豸ͨЭ0x4002*/ + typedef struct + { + UINT8 EmitterType; /*豸*/ + UINT8 ReceptorType; /*豸*/ + UINT8 CommuType; /*ʹõͨЭ飬1ΪSfp2ΪRp3ΪRsr4ΪRSSPI,5ΪRSSPII*/ + }DSU_PROTCL_COMM_PROTCL_STRU; + + /*ʹñ*/ + typedef struct + { + UINT16 IpDevLen; /*豸IPַ0x4001-*/ + UINT16* IpDevTypeIds; /*豸IPַ0x4001-豸ID*/ + +#ifndef DEV_IP_TABLE_NO_HLHT + UINT32* IpDevHlhtIds; /*豸IPַ0x4001-豸HLHT ID*/ +#endif + + UINT16 CommProtclStruLen; /*豸ͨЭ*/ + DSU_PROTCL_COMM_PROTCL_STRU *pCommProtclStru;/*豸ͨЭ*/ + }DSU_PROTCL_BOOK_IP_INFO_STRU; + + /*Эͨ豸*/ + typedef struct + { + UINT8 sfpProtclNum; /*SFPͨ豸*/ + UINT8 rsrProtclNum; /*RSRͨ豸*/ + UINT8 rsspProtclNum; /*RSSPIͨ豸*/ + UINT8 redunProtclNum; /*RPͨ豸*/ + UINT8 rssp2ProtclNum; /*RSSPIIͨ豸*/ + UINT8 fsfbProtclNum; /*FSFBͨ豸*/ + }DSU_PROTCL_TYPE_STRU; + + /* + *: DsuCommonInfoInit + *: ѯʼ + *: UINT8 *pFsName FSļ + *: DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo ʹñ + *: + *ֵ: 1:ɹ;0ʧ + */ + UINT8 DsuCommonInfoInit(UINT8 *pFsName, DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo); + + /* + *: DsuProtclGetProtclType + *: ݱIDԷIDʹõЭ + *: UINT16 locTypeId ID + * UINT16 oppTypeId ԷID + * DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo ʹñ + *: + *: UINT8 *pProtclType Э + *ֵ: 1:ɹ;0ʧ + */ + UINT8 DsuProtclGetProtclType(UINT16 locTypeId, UINT16 oppTypeId, UINT8 *pProtclType, DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo); + + /* + *: DsuGetProtclTypeInfo + *: ݱIDԷͨʱʹЭͨ豸(·) + *: UINT16 locTypeId ID + * DSU_PROTCL_BOOK_IP_INFO_STRU *pDsuProtclBookIpInfo ʹñ + * UINT32 inDataLen ݳ + * UINT8 inData[] + * UINT16 globalVarOppTypePtlLen ͨŵĶԷ豸Э鳤 + *: UINT8 globalVarOppTypePtl[UINT8_MAX] ͨŵĶԷ豸Э + *: DSU_PROTCL_TYPE_STRU *dsuProtclTypeInfo Эͨ豸 + *ֵ: 1:ɹ;0ʧ + */ + UINT8 DsuGetProtclTypeInfo(UINT16 locTypeId, DSU_PROTCL_TYPE_STRU* dsuProtclTypeInfo, DSU_PROTCL_BOOK_IP_INFO_STRU* pDsuProtclBookIpInfo, UINT8 globalVarOppTypePtl[], UINT16 globalVarOppTypePtlLen, UINT32 inDataLen, UINT8 inData[]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/protocol_cbtc/common_protocol/ProtclManage.c b/TSCP/src/protocol/protocol_cbtc/common_protocol/ProtclManage.c new file mode 100644 index 0000000..3346f9a --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_protocol/ProtclManage.c @@ -0,0 +1,4648 @@ +/* +* +* ļ ProtclManage.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.15 +* +* Э,ҪʵԵЭ顣 +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +* 2014.03.06 yw.lou ûзͱ,Ӧ·״̬ûиֵ,ˢ·ʱ·һ; +* ޷𿪵ĸЭ,޸,ûм״̬,ֵ0,Ա; +* 2014.03.20 yw.lou ֻΪATSͨſ1ռ,ATSܷ23֡,Խ;޸ķռ: +* ·*ЭͨŶ; +* 2014.04.13 yw.lou ΪЭݽսṹռδʼ,ոЭݺReceiveAppData,proTypeֶδʼ +* δյδʼЭյݵЭ; +* mallocռʧܺʧ,ڳʼ׶ɼ,; +* +*--------------------------------------------- +*/ +#include +#include "CommonMemory.h" +#include "dsuProtclFun.h" +#include "protclMgeCfg.h" +#include "ProtclManage.h" +#include "Convert.h" +#include "dfsDataRead.h" + +#ifdef USE_SFP +#include "sfpPrtclCommon.h" +#endif +#ifdef USE_RSR +#include "dsuRsrFunc.h" +#include "RsrCommon.h" +#endif +#ifdef USE_RSSPII +#include "Rssp2.h" +#include "PrtclParseManage.h" +#endif +#ifdef USE_RP +#include "RpInterface.h" +#endif +#ifdef USE_FSFB +#include "FsfbProtcl.h" +#endif + +/***********Эʼغ**************************************************************/ +static UINT8 InitProtclInfoStru(ProtclConfigInfoStru* pUnifyInfo, UINT16 maxLnkNum); +static UINT8 InitSfpProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo); +static UINT8 InitRpProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo); +static UINT8 InitRsspProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo); +static UINT8 InitRsrProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo); +static UINT8 InitRssp2ProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo); +static UINT8 InitFsfbProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo); +static void GetSfpNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); +static void GetRsspiNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); +static void GetRsspiiNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); +static void GetFsfbNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); +static void TypeIdToDevName(UINT8 type, UINT8 id, UINT16* pDevName); +static PROTCL_APP_TO_STRU* NewProtclAppToStru(const UINT16 outputSize, const UINT16 inputSize); +static UINT8* NewAppData(UINT16* appDataMaxLen, const UINT16 outputSize, const UINT16 inputSize); + +/* Э麯ָñ */ +static PROTCL_MGECFG_STRU protclCfgStruBuff[PROTCL_MGECFG_MAXCNT + 1] = { + {protcl_nul_Init,protcl_nul_Snd,protcl_nul_Rcv,protcl_nul_Lnk,protcl_nul_NetsRecvPkgNum,protcl_nul_DelLnk,protcl_nul_ReFreshLnk,protcl_nul_End} + +#ifdef USE_SFP + ,{InitSfpProtclStru,sfpSendData,SfpRcvData,GetSfpLnkStatus,GetSfpNetsRecvPkgNum, SfpDelLnk,SfpReFreshLnk,SfpFreeSpaceFunc} +#else + ,{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#endif + +#ifdef USE_RP + ,{InitRpProtclStru,RpSendData,RpRcvData,protcl_nul_Lnk,protcl_nul_NetsRecvPkgNum,RpDelLnk,RpReFreshLnk,RpFreeSpaceFunc} +#else + ,{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#endif + +#ifdef USE_RSR + ,{InitRsrProtclStru,RsrSendData,RsrRcvData,GetRsrLnkStatus,protcl_nul_NetsRecvPkgNum,RsrDelLnk,RsrReFreshLnk,RsrFreeSpaceFunc} +#else + ,{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#endif + +#ifdef USE_RSSPI + ,{InitRsspProtclStru,RsspSendData,RsspRcvData,GetRsspLnkStatus,GetRsspiNetsRecvPkgNum,RsspDelLnk,RsspReFreshLnk,RsspFreeSpaceFunc} +#else + ,{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#endif + +#ifdef USE_RSSPII + ,{InitRssp2ProtclStru,Rssp2SendData,Rssp2RcvData,GetRssp2LnkStatus,GetRsspiiNetsRecvPkgNum,Rssp2DelLnk,Rssp2ReFreshLnk,Rssp2FreeSpaceFunc} +#else + ,{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#endif + +#ifdef USE_FSFB + ,{InitFsfbProtclStru,FsfbSendData,FsfbRcvData,GetFsfbLnkStatus,GetFsfbNetsRecvPkgNum,FsfbDelLnk,FsfbReFreshLnk,FsfbFreeSpaceFunc} +#else + ,{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#endif +}; + +/* +* ļȡӦЭ +*/ +UINT8 Init(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + UINT8 tempProtclCnt = 0; + UINT8 tmpI = 0; + UINT8 flag = 0; + UINT8 rslt = 0; + F_INIT tmpInit; + /* 豸ʹ־ȱ*/ + UINT32 curDevRecordLenRatio[PROTCL_MGECFG_MAXCNT] = { 0 }; + /* 豸ʹ־ܳ*/ + UINT32 curDevRecordTotalLen = 0; + /* 豸һ·*/ + UINT32 devRecFitLen[PROTCL_MGECFG_MAXCNT] = { 0 }; + /* ʱ*/ + UINT32 tmpVal = 0; + PROTCL_APP_TO_STRU* pCurRcvProtclAppStru = NULL; /*յ֡Ϣ*/ + PROTCL_RCV_DATA_TYPE* ptemProtclRcvDataStru = NULL; /*ʱЭݵĽṹ*/ + PROTCL_APP_TO_STRU* pCurSndProtclAppStru = NULL; /*͵֡Ϣ*/ + PROTCL_SND_CFG_STRU* protclSndCfgStru = NULL; /*ͽṹ*/ + UINT8* pProtclNumBuff = NULL; /*Э·*/ + UINT32* curDevRecordLen = NULL; /*豸ʹ־*/ + DSU_PROTCL_TYPE_STRU* protclTypeInfoStru = NULL; /*Эͨ*/ + UINT32 i = 0u; /*ѭ*/ + UINT8 funRtn = 0u; /*úֵ*/ + + /* VOBCļ¼ݴС */ + if ((NULL == pUnifyInfo)) + { + return retVal; + } + + pUnifyInfo->GlobalVar = (GlobalVar*)malloc(sizeof(GlobalVar)); + if (NULL != pUnifyInfo->GlobalVar) + { + /*ʼЭݵĽṹ*/ + CommonMemSet(pUnifyInfo->GlobalVar, sizeof(GlobalVar), 0, sizeof(GlobalVar)); + + protclSndCfgStru = pUnifyInfo->GlobalVar->protclSndCfgStru; /*ͽṹ*/ + pProtclNumBuff = pUnifyInfo->GlobalVar->pProtclNumBuff; /*Э·*/ + curDevRecordLen = pUnifyInfo->GlobalVar->curDevRecordLen; /*豸ʹ־*/ + } + else + { + return retVal; + } + + tempProtclCnt = InitGetCfgInfo(fileName, inDataLen, inData, &pProtclNumBuff[1], pUnifyInfo); + + if (tempProtclCnt == 0) + { + retVal = 0; + return retVal; + } + protclTypeInfoStru = &pUnifyInfo->GlobalVar->protclTypeInfoStru; + + if (2 < pUnifyInfo->RecordArraySize) /*ȴ2,־ռ䴦*/ + { + /*ʷ־ռ*/ + devRecFitLen[0] = SFP_PER_LNK_RECORD_MAX_LEN; + devRecFitLen[1] = RP_PER_LNK_RECORD_MAX_LEN; + devRecFitLen[2] = RSR_PER_LNK_RECORD_MAX_LEN; + devRecFitLen[3] = RSSPI_PER_LNK_RECORD_MAX_LEN; + devRecFitLen[4] = RSSPII_PER_LNK_RECORD_MAX_LEN; + devRecFitLen[5] = FSFB_PER_LNK_RECORD_MAX_LEN; + for (tmpI = 0; tmpI < PROTCL_MGECFG_MAXCNT; tmpI++) + { + if (pProtclNumBuff[tmpI + 1] > 0) + { + curDevRecordLenRatio[tmpI] = devRecFitLen[tmpI] * pProtclNumBuff[tmpI + 1]; + curDevRecordTotalLen += curDevRecordLenRatio[tmpI]; + } + } + for (tmpI = 0; tmpI < PROTCL_MGECFG_MAXCNT; tmpI++) + { + if (pProtclNumBuff[tmpI + 1] > 0) + { + curDevRecordLen[tmpI] = (pUnifyInfo->RecordArraySize - 2) * curDevRecordLenRatio[tmpI] / curDevRecordTotalLen; + /*С־*/ + tmpVal += devRecFitLen[tmpI]; + } + } + /*־ռ.ܷ־СС־:ʷ; :ڰʷ,ʹһЭ־ȲСһ·*/ + if ((pUnifyInfo->RecordArraySize - 2) >= tmpVal) + { + /*,ij*/ + tmpVal = 0; + for (tmpI = 0; tmpI < PROTCL_MGECFG_MAXCNT; tmpI++) + { + /*ֻЭ־*/ + if (pProtclNumBuff[tmpI + 1] > 0) + { + if (curDevRecordLen[tmpI] < devRecFitLen[tmpI]) /*Сһ·,Ϊһ·,ۼij*/ + { + tmpVal += (devRecFitLen[tmpI] - curDevRecordLen[tmpI]); + curDevRecordLen[tmpI] = devRecFitLen[tmpI]; + } + else + { + /*ij*/ + if (tmpVal > 0) + { + if ((curDevRecordLen[tmpI] > tmpVal) && (curDevRecordLen[tmpI] - tmpVal >= devRecFitLen[tmpI])) /*ɼ*/ + { + curDevRecordLen[tmpI] -= tmpVal; + tmpVal = 0; + } + else /*ɼ,Ϊһ·,ۼij*/ + { + tmpVal += (devRecFitLen[tmpI] - curDevRecordLen[tmpI]); + curDevRecordLen[tmpI] = devRecFitLen[tmpI]; + } + } + } + } + } + /*ij*/ + if (tmpVal > 0) + { + for (tmpI = 0; tmpI < PROTCL_MGECFG_MAXCNT; tmpI++) + { + /*־ȿɼij*/ + if ((pProtclNumBuff[tmpI + 1] > 0) && (curDevRecordLen[tmpI] > tmpVal) && (curDevRecordLen[tmpI] - tmpVal >= devRecFitLen[tmpI])) + { + curDevRecordLen[tmpI] -= tmpVal; + tmpVal = 0; + break; + } + } + } + } + } + + /* ʼЭ*/ + for (tmpI = 0; tmpI < tempProtclCnt + 1; tmpI++) + { + if (0 < pProtclNumBuff[tmpI]) /*Эͨ,ʼ*/ + { + tmpInit = protclCfgStruBuff[tmpI].fInit; + if (NULL != tmpInit) + { + retVal = tmpInit(fileName, inDataLen, inData, pProtclNumBuff[tmpI], pUnifyInfo); + } + else /*޴Э*/ + { + retVal = 1u; + } + + if (0 == retVal) + { + /* һʼʧܣټ */ + return retVal; + } + } + else /*ʼ*/ + { + retVal = 1; + } + } + + /* ʱЭݵĽṹռ */ + pUnifyInfo->GlobalVar->RcvData = (PROTCL_RCV_DATA_TYPE*)malloc(sizeof(PROTCL_RCV_DATA_TYPE) * (PROTCL_MGECFG_MAXCNT + 1)); + ptemProtclRcvDataStru = pUnifyInfo->GlobalVar->RcvData; + + /* ݵʱ浵ݵĽṹռ */ + if (ptemProtclRcvDataStru != NULL) + { + /*ʼЭݵĽṹ*/ + CommonMemSet(ptemProtclRcvDataStru, sizeof(PROTCL_RCV_DATA_TYPE) * (PROTCL_MGECFG_MAXCNT + 1), 0, sizeof(PROTCL_RCV_DATA_TYPE) * (PROTCL_MGECFG_MAXCNT + 1)); + + /*벢ʼЭݽṹĽݻ*/ + ptemProtclRcvDataStru[DSU_PROTCL_SFP].pData = (UINT8*)malloc(sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->sfpProtclNum); + CommonMemSet(ptemProtclRcvDataStru[DSU_PROTCL_SFP].pData, sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->sfpProtclNum, + 0, pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->sfpProtclNum); + + /*涨Эݽṹ2ռSFP,һΪptemProtclRcvDataStru[0],Ĭϲʹ*/ + ptemProtclRcvDataStru[DSU_PROTCL_SFP].proType = DSU_PROTCL_SFP; + + /*벢ʼЭݽṹĽݻ*/ + ptemProtclRcvDataStru[DSU_PROTCL_RP].pData = (UINT8*)malloc(sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->redunProtclNum); + CommonMemSet(ptemProtclRcvDataStru[DSU_PROTCL_RP].pData, sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->redunProtclNum, + 0, pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->redunProtclNum); + + /*涨Эݽṹ3ռredun*/ + ptemProtclRcvDataStru[DSU_PROTCL_RP].proType = DSU_PROTCL_RP; + + /*벢ʼЭݽṹĽݻ*/ + ptemProtclRcvDataStru[DSU_PROTCL_RSR].pData = (UINT8*)malloc(sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rsrProtclNum); + CommonMemSet(ptemProtclRcvDataStru[DSU_PROTCL_RSR].pData, sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rsrProtclNum, + 0, pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rsrProtclNum); + + /*涨Эݽṹ4ռredun*/ + ptemProtclRcvDataStru[DSU_PROTCL_RSR].proType = DSU_PROTCL_RSR; + + /*벢ʼЭݽṹĽݻ*/ + ptemProtclRcvDataStru[DSU_PROTCL_RSSP].pData = (UINT8*)malloc(sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rsspProtclNum); + CommonMemSet(ptemProtclRcvDataStru[DSU_PROTCL_RSSP].pData, sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rsspProtclNum, + 0, pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rsspProtclNum); + + /*涨Эݽṹ5ռRSSP*/ + ptemProtclRcvDataStru[DSU_PROTCL_RSSP].proType = DSU_PROTCL_RSSP; + + /*벢ʼЭݽṹĽݻ*/ + ptemProtclRcvDataStru[DSU_PROTCL_RSSP2].pData = (UINT8*)malloc(sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rssp2ProtclNum); + CommonMemSet(ptemProtclRcvDataStru[DSU_PROTCL_RSSP2].pData, sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rssp2ProtclNum, + 0, pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->rssp2ProtclNum); + + /*涨Эݽṹ5ռRSSP*/ + ptemProtclRcvDataStru[DSU_PROTCL_RSSP2].proType = DSU_PROTCL_RSSP2; + + /*벢ʼЭݽṹĽݻ*/ + ptemProtclRcvDataStru[DSU_PROTCL_FSFB].pData = (UINT8*)malloc(sizeof(UINT8) * pUnifyInfo->InputSize * pUnifyInfo->MaxNumPerCycle * protclTypeInfoStru->fsfbProtclNum); + CommonMemSet(ptemProtclRcvDataStru[DSU_PROTCL_FSFB].pData, sizeof(UINT8)* pUnifyInfo->InputSize* pUnifyInfo->MaxNumPerCycle* protclTypeInfoStru->fsfbProtclNum, + 0, pUnifyInfo->InputSize* pUnifyInfo->MaxNumPerCycle* protclTypeInfoStru->fsfbProtclNum); + /*涨Эݽṹ5ռRSSP*/ + ptemProtclRcvDataStru[DSU_PROTCL_FSFB].proType = DSU_PROTCL_FSFB; + } + else + { + /* */ + retVal = 0; + return retVal; + } + + + /*ʼյ֡Ӧ*/ + pUnifyInfo->GlobalVar->pRcvProtclAppStru = NewProtclAppToStru(pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == pUnifyInfo->GlobalVar->pRcvProtclAppStru) + { + retVal = 0; + return retVal; + } + + /*ʼ͵֡Ӧ*/ + pUnifyInfo->GlobalVar->pSndProtclAppStru = NewProtclAppToStru(pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == pUnifyInfo->GlobalVar->pSndProtclAppStru) + { + retVal = 0; + return retVal; + } + + + for (tmpI = 0; tmpI < PROTCL_MGECFG_MAXCNT + 1; tmpI++) + { + /* ֹҰָ */ + protclSndCfgStru[tmpI].pProtclAppStru = (PROTCL_APP_TO_STRU*)malloc(sizeof(PROTCL_APP_TO_STRU) * 0); + protclSndCfgStru[tmpI].DevDataCnt = 0; + } + + /* ݵʱ浵ݵĽṹռ */ + if (0 < protclTypeInfoStru->sfpProtclNum) + { +#ifdef USE_SFP + tmpVal = pUnifyInfo->GlobalVar->gpsfpUnitInfo->MaxNumLink * pUnifyInfo->MaxNumPerCycle; + protclSndCfgStru[DSU_PROTCL_SFP].pProtclAppStru = (PROTCL_APP_TO_STRU*)malloc(sizeof(PROTCL_APP_TO_STRU) *tmpVal); + if ((NULL == protclSndCfgStru[DSU_PROTCL_SFP].pProtclAppStru) || (NULL == ptemProtclRcvDataStru[DSU_PROTCL_SFP].pData)) + { + flag = 1; + } + else + { + /*Ϊķʱ洢ʼ*/ + CommonMemSet(protclSndCfgStru[DSU_PROTCL_SFP].pProtclAppStru, sizeof(PROTCL_APP_TO_STRU)* tmpVal, 0u, sizeof(PROTCL_APP_TO_STRU)* tmpVal); + + /*ʼ֡Ӧ*/ + for (i = 0; i < tmpVal; i++) + { + protclSndCfgStru[DSU_PROTCL_SFP].pProtclAppStru[i].pAppData = NewAppData(&protclSndCfgStru[DSU_PROTCL_SFP].pProtclAppStru[i].appDataMaxLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == protclSndCfgStru[DSU_PROTCL_SFP].pProtclAppStru[i].pAppData) + { + break; + } + } + if (i == tmpVal) + { + pUnifyInfo->GlobalVar->gpSfpRcvDataBuff = NewAppData(&pUnifyInfo->GlobalVar->gSfpRcvDataBuffLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == pUnifyInfo->GlobalVar->gpSfpRcvDataBuff) + { + flag = 1; + } + } + else + { + flag = 1; + } + + } +#endif + } + + if (protclTypeInfoStru->redunProtclNum > 0) + { +#ifdef USE_RP + tmpVal = pUnifyInfo->GlobalVar->gpRedunUnitInfo->MaxNumLink * pUnifyInfo->MaxNumPerCycle; + protclSndCfgStru[DSU_PROTCL_RP].pProtclAppStru = (PROTCL_APP_TO_STRU*)malloc(sizeof(PROTCL_APP_TO_STRU) * tmpVal); + if ((NULL == protclSndCfgStru[DSU_PROTCL_RP].pProtclAppStru) || (NULL == ptemProtclRcvDataStru[DSU_PROTCL_RP].pData)) + { + flag = 1; + } + else + { + /*Ϊķʱ洢ʼ*/ + CommonMemSet(protclSndCfgStru[DSU_PROTCL_RP].pProtclAppStru, sizeof(PROTCL_APP_TO_STRU)* tmpVal, 0u, sizeof(PROTCL_APP_TO_STRU)* tmpVal); + + /*ʼ֡Ӧ*/ + for (i = 0; i < tmpVal; i++) + { + protclSndCfgStru[DSU_PROTCL_RP].pProtclAppStru[i].pAppData = NewAppData(&protclSndCfgStru[DSU_PROTCL_RP].pProtclAppStru[i].appDataMaxLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == protclSndCfgStru[DSU_PROTCL_RP].pProtclAppStru[i].pAppData) + { + break; + } + } + if (i == tmpVal) + { + pUnifyInfo->GlobalVar->gpRpRcvDataBuff = NewAppData(&pUnifyInfo->GlobalVar->gRpRcvDataBuffLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == pUnifyInfo->GlobalVar->gpRpRcvDataBuff) + { + flag = 1; + } + } + else + { + flag = 1; + } + + } +#endif + } + + if (protclTypeInfoStru->rsrProtclNum > 0) + { +#ifdef USE_RSR + tmpVal = pUnifyInfo->GlobalVar->gpRsrUnitInfo->MaxNumLink * pUnifyInfo->MaxNumPerCycle; + protclSndCfgStru[DSU_PROTCL_RSR].pProtclAppStru = (PROTCL_APP_TO_STRU*)malloc(sizeof(PROTCL_APP_TO_STRU) * tmpVal); + if ((NULL == protclSndCfgStru[DSU_PROTCL_RSR].pProtclAppStru) || (NULL == ptemProtclRcvDataStru[DSU_PROTCL_RSR].pData)) + { + flag = 1; + } + else + { + /*Ϊķʱ洢ʼ*/ + CommonMemSet(protclSndCfgStru[DSU_PROTCL_RSR].pProtclAppStru, sizeof(PROTCL_APP_TO_STRU) * tmpVal, 0u, sizeof(PROTCL_APP_TO_STRU) * tmpVal); + + /*ʼ֡Ӧ*/ + for (i = 0; i < tmpVal; i++) + { + protclSndCfgStru[DSU_PROTCL_RSR].pProtclAppStru[i].pAppData = NewAppData(&protclSndCfgStru[DSU_PROTCL_RSR].pProtclAppStru[i].appDataMaxLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == protclSndCfgStru[DSU_PROTCL_RSR].pProtclAppStru[i].pAppData) + { + break; + } + } + if (i == tmpVal) + { + pUnifyInfo->GlobalVar->gpRsrRcvDataBuff = NewAppData(&pUnifyInfo->GlobalVar->gRsrRcvDataBuffLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == pUnifyInfo->GlobalVar->gpRsrRcvDataBuff) + { + flag = 1; + } + } + else + { + flag = 1; + } + + } +#endif + } + + if (protclTypeInfoStru->rsspProtclNum > 0) + { +#ifdef USE_RSSPI + tmpVal = pUnifyInfo->GlobalVar->gpRsspUnitInfo->MaxNumLink * pUnifyInfo->MaxNumPerCycle; + protclSndCfgStru[DSU_PROTCL_RSSP].pProtclAppStru = (PROTCL_APP_TO_STRU*)malloc(sizeof(PROTCL_APP_TO_STRU) * tmpVal); + if ((NULL == protclSndCfgStru[DSU_PROTCL_RSSP].pProtclAppStru) || (NULL == ptemProtclRcvDataStru[DSU_PROTCL_RSSP].pData)) + { + flag = 1; + } + else + { + /*Ϊķʱ洢ʼ*/ + CommonMemSet(protclSndCfgStru[DSU_PROTCL_RSSP].pProtclAppStru, sizeof(PROTCL_APP_TO_STRU)* tmpVal, 0u, sizeof(PROTCL_APP_TO_STRU)* tmpVal); + + /*ʼ֡Ӧ*/ + for (i = 0; i < tmpVal; i++) + { + protclSndCfgStru[DSU_PROTCL_RSSP].pProtclAppStru[i].pAppData = NewAppData(&protclSndCfgStru[DSU_PROTCL_RSSP].pProtclAppStru[i].appDataMaxLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == protclSndCfgStru[DSU_PROTCL_RSSP].pProtclAppStru[i].pAppData) + { + break; + } + } + if (i == tmpVal) + { + pUnifyInfo->GlobalVar->gpRsspRcvDataBuff = NewAppData(&pUnifyInfo->GlobalVar->gRsspRcvDataBuffLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == pUnifyInfo->GlobalVar->gpRsspRcvDataBuff) + { + flag = 1; + } + } + else + { + flag = 1; + } + + } +#endif + } + + if (protclTypeInfoStru->rssp2ProtclNum > 0) + { +#ifdef USE_RSSPII + tmpVal = pUnifyInfo->GlobalVar->gpRssp2UnitInfo->MaxNumLink * pUnifyInfo->MaxNumPerCycle; + Prtcl_RSSP2_CheckInit(&pUnifyInfo->GlobalVar->Rssp2PrtclHead); + /* add 20161017 xb */ + for (tmpI = 0; tmpI < PRTCL_RQ_NUM; tmpI++) + { + rslt = (UINT8)QUEUE_RING_Init(&Prtcl_RQ[tmpI].RingQue, PRTCL_RQ_SIZE); + if (CM_TRUE != rslt) + { + flag = 1; + break; + } + Prtcl_RQ[tmpI].RingQue.m_bIsInited = CM_TRUE; + Prtcl_RQ[tmpI].RingQue.m_IfCoverQueueFull = CM_TRUE; + Prtcl_RQ[tmpI].RingQue.m_QueueState = QUEUE_RING_STATE_Empty; + } + + protclSndCfgStru[DSU_PROTCL_RSSP2].pProtclAppStru = (PROTCL_APP_TO_STRU*)malloc(sizeof(PROTCL_APP_TO_STRU) * tmpVal); + if ((NULL == protclSndCfgStru[DSU_PROTCL_RSSP2].pProtclAppStru) || (NULL == ptemProtclRcvDataStru[DSU_PROTCL_RSSP2].pData)) + { + flag = 1; + } + else + { + /*Ϊķʱ洢ʼ*/ + CommonMemSet(protclSndCfgStru[DSU_PROTCL_RSSP2].pProtclAppStru, sizeof(PROTCL_APP_TO_STRU)* tmpVal, 0u, sizeof(PROTCL_APP_TO_STRU)* tmpVal); + + /*ʼ֡Ӧ*/ + for (i = 0; i < tmpVal; i++) + { + protclSndCfgStru[DSU_PROTCL_RSSP2].pProtclAppStru[i].pAppData = NewAppData(&protclSndCfgStru[DSU_PROTCL_RSSP2].pProtclAppStru[i].appDataMaxLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == protclSndCfgStru[DSU_PROTCL_RSSP2].pProtclAppStru[i].pAppData) + { + break; + } + } + if (i == tmpVal) + { + pUnifyInfo->GlobalVar->gpRssp2RcvDataBuff = NewAppData(&pUnifyInfo->GlobalVar->gRssp2RcvDataBuffLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == pUnifyInfo->GlobalVar->gpRssp2RcvDataBuff) + { + flag = 1; + } + } + else + { + flag = 1; + } + + } +#endif + } + + if (protclTypeInfoStru->fsfbProtclNum > 0) + { +#ifdef USE_FSFB + tmpVal = pUnifyInfo->GlobalVar->gpFsfbUnitInfo->MaxNumLink * pUnifyInfo->MaxNumPerCycle; + protclSndCfgStru[DSU_PROTCL_FSFB].pProtclAppStru = (PROTCL_APP_TO_STRU*)malloc(sizeof(PROTCL_APP_TO_STRU) * tmpVal); + if ((NULL == protclSndCfgStru[DSU_PROTCL_FSFB].pProtclAppStru) || (NULL == ptemProtclRcvDataStru[DSU_PROTCL_FSFB].pData)) + { + flag = 1; + } + else + { + /*Ϊķʱ洢ʼ*/ + CommonMemSet(protclSndCfgStru[DSU_PROTCL_FSFB].pProtclAppStru, sizeof(PROTCL_APP_TO_STRU)* tmpVal, 0u, sizeof(PROTCL_APP_TO_STRU)* tmpVal); + + + /*ʼ֡Ӧ*/ + for (i = 0; i < tmpVal; i++) + { + protclSndCfgStru[DSU_PROTCL_FSFB].pProtclAppStru[i].pAppData = NewAppData(&protclSndCfgStru[DSU_PROTCL_FSFB].pProtclAppStru[i].appDataMaxLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == protclSndCfgStru[DSU_PROTCL_FSFB].pProtclAppStru[i].pAppData) + { + break; + } + } + if (i == tmpVal) + { + pUnifyInfo->GlobalVar->gpFsfbRcvDataBuff = NewAppData(&pUnifyInfo->GlobalVar->gFsfbRcvDataBuffLen, pUnifyInfo->OutputSize, pUnifyInfo->InputSize); + if (NULL == pUnifyInfo->GlobalVar->gpFsfbRcvDataBuff) + { + flag = 1; + } + } + else + { + flag = 1; + } + + } +#endif + } + + if (1 == flag) + { + retVal = 0; + } + return retVal; +} + +/* +* ܣЭ鷢 +* +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1ݳɹ +* 0ʧ +* 2:崻 +*/ +UINT8 SendAppData(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + UINT8 temLenbuf[2] = { 0 }; + PROTCL_APP_TO_STRU* tempProtclAppStru = NULL; + UINT16 locDevName = 0; + UINT16 destDevName = 0; + UINT8 protclType = 0; + UINT32 sendDataLen = 0; + UINT32 tmpDataLen = 0; + UINT16 temLnkDataLen = 0; + UINT16 tempRecordLen = 0; + UINT16 lnkDataLen = 0; + UINT16 recordDataLen = 0; + + UINT8 tmpDevDataCnt = 0; + UINT8 tmpI = 0; + F_SND tmpSndF; + UINT8 tmpSign = 0; + PROTCL_SND_CFG_STRU* protclSndCfgStru = NULL; + UINT8* pProtclNumBuff = NULL; /*Э·*/ + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->pSndProtclAppStru) && (NULL != pUnifyInfo->GlobalVar->protclSndCfgStru) && (NULL != pUnifyInfo->GlobalVar->pProtclNumBuff)) + { + tempProtclAppStru = pUnifyInfo->GlobalVar->pSndProtclAppStru; + protclSndCfgStru = pUnifyInfo->GlobalVar->protclSndCfgStru; + pProtclNumBuff = pUnifyInfo->GlobalVar->pProtclNumBuff; + + /* ӦҪ͵дЭĶ */ + TypeIdToDevName(pUnifyInfo->LocalType, pUnifyInfo->LocalID, &locDevName); + while (2 < QueueStatus(&pUnifyInfo->OutputDataQueue)) + { + QueueScan(2, temLenbuf, &pUnifyInfo->OutputDataQueue); + + ret = AppSendInputDataAnalysis(&pUnifyInfo->OutputDataQueue, tempProtclAppStru); + if (1 == ret) + { + /* 豸ͣЭʹ */ + TypeIdToDevName(tempProtclAppStru->devType, tempProtclAppStru->devId, &destDevName); + protclType = 0; + DsuProtclGetProtclType(locDevName, destDevName, &protclType, &pUnifyInfo->GlobalVar->DsuProtclBookIpInfo); + } + else + { + break; + } + /* Խ */ + if ((PROTCL_MGECFG_MAXCNT >= protclType) && (0 != protclType)) + { + if (0 < pProtclNumBuff[protclType]) /*ͨ豸*/ + { + /*֡д*/ + tmpDevDataCnt = protclSndCfgStru[protclType].DevDataCnt; + + protclSndCfgStru[protclType].pProtclAppStru[tmpDevDataCnt].appDataMaxLen = tempProtclAppStru->appDataMaxLen; + protclSndCfgStru[protclType].pProtclAppStru[tmpDevDataCnt].devType = tempProtclAppStru->devType; + protclSndCfgStru[protclType].pProtclAppStru[tmpDevDataCnt].devId = tempProtclAppStru->devId; + protclSndCfgStru[protclType].pProtclAppStru[tmpDevDataCnt].devLogId = tempProtclAppStru->devLogId; + protclSndCfgStru[protclType].pProtclAppStru[tmpDevDataCnt].appDataLen = tempProtclAppStru->appDataLen; + CommonMemCpy(protclSndCfgStru[protclType].pProtclAppStru[tmpDevDataCnt].pAppData, tempProtclAppStru->appDataLen, tempProtclAppStru->pAppData, tempProtclAppStru->appDataLen); + + protclSndCfgStru[protclType].DevDataCnt++; + } + } + else + { + /* break;*/ + } + } + + /* ִиЭķͺ */ + for (tmpI = 1; tmpI < PROTCL_MGECFG_MAXCNT + 1; tmpI++) + { + tmpDataLen = 0; + temLnkDataLen = 0; + tempRecordLen = 0; + if (0 < pProtclNumBuff[tmpI]) + { + /* ÷ͺ */ + tmpSndF = protclCfgStruBuff[tmpI].fSnd; + if (NULL != tmpSndF) + { + ret = tmpSndF(pUnifyInfo, protclSndCfgStru[tmpI].DevDataCnt, pUnifyInfo->AppArray + 4 + sendDataLen, &tmpDataLen, pUnifyInfo->VarArray + 2 + lnkDataLen, &temLnkDataLen, pUnifyInfo->RecordArray + + 2 + recordDataLen, &tempRecordLen); + } + else /*޴Э*/ + { + temLnkDataLen = 2; + ShortToChar(0, pUnifyInfo->VarArray + 2 + lnkDataLen); + ret = 1u; + } + /* Ӹ*/ + protclSndCfgStru[tmpI].DevDataCnt = 0; + + } + else + { + temLnkDataLen = 2; + ShortToChar(0, pUnifyInfo->VarArray + 2 + lnkDataLen); + ret = 1; + /* ޴ͨ */ + } + if (1 == ret) + { + sendDataLen += tmpDataLen; + lnkDataLen += temLnkDataLen; + recordDataLen += tempRecordLen; + } + else + { + tmpSign = 1; + } + } + /* ݵij */ + LongToChar(sendDataLen, pUnifyInfo->AppArray); + /* мij */ + ShortToChar(lnkDataLen, pUnifyInfo->VarArray); + /* ¼ݵij */ + ShortToChar(recordDataLen, pUnifyInfo->RecordArray); + } + else + { + ret = 0; + } + + if (1 == tmpSign) + { + ret = 0; + } + return ret; +} + + +/* +* ܣЭ +* +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1ݳɹ +* 0ʧ +* 2:崻 +*/ +UINT8 ReceiveAppData(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + UINT8 flag = 0; + UINT8 lnkState = 0; + UINT8 i = 0; /* ѭʹ */ + UINT16 locDevName = 0; + UINT8 DevType = 0; + UINT8 DevId = 0; + UINT8 LogId = 0; + PROTCL_RCV_DATA_TYPE *ptemProtclRcvDataStru = NULL; + DSU_PROTCL_TYPE_STRU *protclTypeInfoStru = NULL; + +#ifdef USE_SFP + struc_Unify_Info* gpsfpUnitInfo = NULL; /*SFPЭṹ*/ +#endif +#ifdef USE_RP + RP_INFO_STRU* gpRedunUnitInfo = NULL; /*Эṹ*/ +#endif +#ifdef USE_RSR + RSR_INFO_STRU* gpRsrUnitInfo = NULL; /*RSRЭṹ*/ +#endif +#ifdef USE_RSSPI + RSSP_INFO_STRU* gpRsspUnitInfo = NULL; /*RSSPЭṹ*/ +#endif +#ifdef USE_RSSPII + RSSP2_INFO_STRU* gpRssp2UnitInfo = NULL; /*RSSP2Эṹ*/ +#endif +#ifdef USE_FSFB + FSFB_INFO_STRU* gpFsfbUnitInfo = NULL; /*FSFBЭṹ*/ +#endif + + if ((NULL!= pUnifyInfo)&&(NULL != pUnifyInfo->GlobalVar)) + { + ptemProtclRcvDataStru = pUnifyInfo->GlobalVar->RcvData; /*ʱЭݵĽṹ*/ + protclTypeInfoStru = &pUnifyInfo->GlobalVar->protclTypeInfoStru; /*Эͨ*/ + +#ifdef USE_SFP + gpsfpUnitInfo = pUnifyInfo->GlobalVar->gpsfpUnitInfo; /*SFPЭṹ*/ +#endif +#ifdef USE_RP + gpRedunUnitInfo = pUnifyInfo->GlobalVar->gpRedunUnitInfo; /*Эṹ*/ +#endif +#ifdef USE_RSR + gpRsrUnitInfo = pUnifyInfo->GlobalVar->gpRsrUnitInfo; /*RSRЭṹ*/ +#endif +#ifdef USE_RSSPI + gpRsspUnitInfo = pUnifyInfo->GlobalVar->gpRsspUnitInfo; /*RSSPЭṹ*/ +#endif +#ifdef USE_RSSPII + gpRssp2UnitInfo = pUnifyInfo->GlobalVar->gpRssp2UnitInfo; /*RSSP2Эṹ*/ +#endif +#ifdef USE_FSFB + gpFsfbUnitInfo = pUnifyInfo->GlobalVar->gpFsfbUnitInfo; /*FSFBЭṹ*/ +#endif + + QueueClear(&pUnifyInfo->DataToApp); + if (protclTypeInfoStru->sfpProtclNum > 0) + { +#ifdef USE_SFP + QueueClear(&gpsfpUnitInfo->OutnetQueueA); + QueueClear(&gpsfpUnitInfo->OutnetQueueB); +#endif + } + + if (protclTypeInfoStru->redunProtclNum > 0) + { +#ifdef USE_RP + QueueClear(&gpRedunUnitInfo->OutnetQueueA); + QueueClear(&gpRedunUnitInfo->OutnetQueueB); +#endif + } + + if (protclTypeInfoStru->rsrProtclNum > 0) + { +#ifdef USE_RSR + QueueClear(&gpRsrUnitInfo->OutnetQueueA); + QueueClear(&gpRsrUnitInfo->OutnetQueueB); +#endif + } + + if (protclTypeInfoStru->rsspProtclNum > 0) + { +#ifdef USE_RSSPI + QueueClear(&gpRsspUnitInfo->OutnetQueueA); + QueueClear(&gpRsspUnitInfo->OutnetQueueB); +#endif + } + + if (protclTypeInfoStru->rssp2ProtclNum > 0) + { +#ifdef USE_RSSPII + QueueClear(&gpRssp2UnitInfo->OutnetQueueA); + QueueClear(&gpRssp2UnitInfo->OutnetQueueB); +#endif + } + + TypeIdToDevName(pUnifyInfo->LocalType, pUnifyInfo->LocalID, &locDevName); + + /* ȡ */ + ret = readQueueDataToApp(&pUnifyInfo->OutnetQueueA, 1, locDevName, ptemProtclRcvDataStru, pUnifyInfo); + if (0 == ret) + { + return ret; + } + + for (i = 1; i < PROTCL_MGECFG_MAXCNT + 1; i++) + { + if (ptemProtclRcvDataStru[i].rcvDataLen > 0) + { + switch (ptemProtclRcvDataStru[i].proType) + { + case DSU_PROTCL_SFP: +#ifdef USE_SFP + /* SFPЭĺݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpsfpUnitInfo->OutnetQueueA); +#endif + break; + case DSU_PROTCL_RP: +#ifdef USE_RP + /* RPЭĺݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpRedunUnitInfo->OutnetQueueA); +#endif + break; + case DSU_PROTCL_RSR: +#ifdef USE_RSR + /* RSRЭĺݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpRsrUnitInfo->OutnetQueueA); +#endif + break; + case DSU_PROTCL_RSSP: +#ifdef USE_RSSPI + /* RSSPЭĺݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpRsspUnitInfo->OutnetQueueA); +#endif + break; + case DSU_PROTCL_RSSP2: +#ifdef USE_RSSPII + /* RSSP2Эĺݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpRssp2UnitInfo->OutnetQueueA); +#endif + break; + case DSU_PROTCL_FSFB: +#ifdef USE_FSFB + /* FSFBЭĺݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpFsfbUnitInfo->OutnetQueueR); +#endif + break; + default: + break; + } + } + } + /* ȡ */ + ret = readQueueDataToApp(&pUnifyInfo->OutnetQueueB, 2, locDevName, ptemProtclRcvDataStru, pUnifyInfo); + if (0 == ret) + { + return ret; + } + /* TO BE DONE switch ŲreadQueueDataToApp */ + for (i = 1; i < PROTCL_MGECFG_MAXCNT + 1; i++) + { + if (ptemProtclRcvDataStru[i].rcvDataLen > 0) + { + switch (ptemProtclRcvDataStru[i].proType) + { + case DSU_PROTCL_SFP: +#ifdef USE_SFP + /* SFPЭݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpsfpUnitInfo->OutnetQueueB); +#endif + break; + case DSU_PROTCL_RP: +#ifdef USE_RP + /* RPЭݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpRedunUnitInfo->OutnetQueueB); +#endif + break; + case DSU_PROTCL_RSR: +#ifdef USE_RSR + /* RSRЭݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpRsrUnitInfo->OutnetQueueB); +#endif + break; + case DSU_PROTCL_RSSP: +#ifdef USE_RSSPI + /* RSSPЭݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpRsspUnitInfo->OutnetQueueB); +#endif + break; + case DSU_PROTCL_RSSP2: +#ifdef USE_RSSPII + /* RSSP2Эݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpRssp2UnitInfo->OutnetQueueB); +#endif + break; + case DSU_PROTCL_FSFB: +#ifdef USE_FSFB + /* RSSP2Эݵ֡ʽ */ + SetDataToQue(ptemProtclRcvDataStru[i].rcvDataLen, ptemProtclRcvDataStru[i].pData, &gpFsfbUnitInfo->OutnetQueueB); +#endif + break; + default: + break; + } + } + } + if (protclTypeInfoStru->sfpProtclNum > 0) + { +#ifdef USE_SFP + /* SFPЭ */ + gpsfpUnitInfo->RadamSN = *gpsfpUnitInfo->CycleNum; +#ifdef CI_TASKLOCK + taskLock(); + ret = ProtclReceive(gpsfpUnitInfo); + taskUnlock(); +#else + ret = ProtclReceive(gpsfpUnitInfo); +#endif + if (ret == 1) + { + SfpRcvData(&pUnifyInfo->DataToApp, pUnifyInfo); + } + else + { + flag = 1; + } +#endif + } + + if (protclTypeInfoStru->redunProtclNum > 0) + { +#ifdef USE_RP + /* RPЭ */ + ret = RpReceive(gpRedunUnitInfo); + if (ret == 1) + { + RpRcvData(&pUnifyInfo->DataToApp, pUnifyInfo); + } + else + { + flag = 1; + } +#endif + } + + if (protclTypeInfoStru->rsrProtclNum > 0) + { +#ifdef USE_RSR + /* RSRЭ */ + ret = RsrReceive(gpRsrUnitInfo); + if (ret == 1) + { + ret = RsrRcvData(&pUnifyInfo->DataToApp, pUnifyInfo); + } + else + { + flag = 1; + } +#endif + } + + if (protclTypeInfoStru->rsspProtclNum > 0) + { +#ifdef USE_RSSPI + /* RSSPЭ */ + ret = Rssp2Receive(gpRsspUnitInfo); + if (ret == 1) + { + RsspRcvData(&pUnifyInfo->DataToApp, pUnifyInfo); + } + else + { + flag = 1; + } +#endif + } + + if (protclTypeInfoStru->rssp2ProtclNum > 0) + { +#ifdef USE_RSSPII + /* RSSP2Э */ + ret = RsspIIReceive(gpRssp2UnitInfo); + if (ret == 1) + { + Rssp2RcvData(&pUnifyInfo->DataToApp, pUnifyInfo); + } + else + { + flag = 1; + } +#endif + } + +#ifdef USE_RSSPII + /* ζ */ + for (i = 0; i < PRTCL_RQ_NUM; i++) + { + if (Prtcl_RQ[i].bIsInit == CM_TRUE) + { + DevType = (UINT8)(Prtcl_RQ[i].SourceID / 256 / 256 / 256); + DevId = (UINT8)(Prtcl_RQ[i].SourceID / 256 / 256 % 256); + LogId = (UINT8)(Prtcl_RQ[i].SourceID % 256); + lnkState = GetLnkStatus(DevType, DevId, (UINT16)LogId, pUnifyInfo); + if (lnkState == 0) + { + Prtcl_Manage_DelRQ(Prtcl_RQ[i].SourceID); + } + } + } +#endif + + if (protclTypeInfoStru->fsfbProtclNum > 0) + { +#ifdef USE_FSFB + + if ((NULL != pUnifyInfo->CycleNum) && (0u == ((*pUnifyInfo->CycleNum) % 2)))/*FSFBЭΪ600ms*/ + { + ret = FsfbProtclReceiveData(gpFsfbUnitInfo); /*FSFBЭ*/ + if (ret == 1) + { + FsfbRcvData(&pUnifyInfo->DataToApp, pUnifyInfo); + } + else + { + flag = 1; + } + + /*ͨ*/ + QueueClear(&gpFsfbUnitInfo->OutnetQueueR); + QueueClear(&gpFsfbUnitInfo->OutnetQueueB); + } +#endif + } + + + if (flag == 1) + { + ret = 0; + } + } + + return ret; +} + +/* +* ܣѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +* 0x33·׼״̬ +* 0x4e·ڵȴ״̬ +* 0x01: ʾˢõ· +*/ +UINT8 GetLnkStatus(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + UINT16 destDevName = 0; + UINT16 locDevName = 0; + UINT8 protclType = 0; + F_LNK tmpLnkF = NULL; + if ((NULL!= pUnifyInfo)&&(NULL != pUnifyInfo->GlobalVar)) + { + TypeIdToDevName(destType, destId, &destDevName); + TypeIdToDevName(pUnifyInfo->LocalType, pUnifyInfo->LocalID, &locDevName); + ret = DsuProtclGetProtclType(locDevName, destDevName, &protclType, &pUnifyInfo->GlobalVar->DsuProtclBookIpInfo); + + if (ret != 0) + { + /* Խ */ + if ((PROTCL_MGECFG_MAXCNT >= protclType) && (0 != protclType)) + { + /* þЭĻȡ·״̬ */ + tmpLnkF = protclCfgStruBuff[protclType].fLnk; + if (NULL != tmpLnkF) + { + ret = tmpLnkF(destType, destId, logId, pUnifyInfo); + } + else /*޴Э*/ + { + ret = 0u; + } + } + else + { + ret = 0; + } + + } + } + return ret; +} + + + + +/* +* ܣɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1ɾ·ɹ +* 0ɾ·ʧ +*/ +UINT8 DelLnkFunc(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + UINT16 destDevName = 0; + UINT16 locDevName = 0; + UINT8 protclType = 0; + F_DELLNK tmpDelLnkF = NULL; + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar)) + { + TypeIdToDevName(destType, destId, &destDevName); + TypeIdToDevName(pUnifyInfo->LocalType, pUnifyInfo->LocalID, &locDevName); + retVal = DsuProtclGetProtclType(locDevName, destDevName, &protclType, &pUnifyInfo->GlobalVar->DsuProtclBookIpInfo); + + if (retVal != 0) + { + /* Խ */ + if ((PROTCL_MGECFG_MAXCNT >= protclType) && (0 != protclType)) + { + /* þЭɾ· */ + tmpDelLnkF = protclCfgStruBuff[protclType].fDelLnk; + if (NULL != tmpDelLnkF) + { + retVal = tmpDelLnkF(destType, destId, logId, pUnifyInfo); + } + else /*޴Э*/ + { + retVal = 0u; + } + } + else + { + retVal = 0; + } + + } + } + return retVal; +} + + +/* +* ܣˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 ReFresh(UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + UINT16 inLnkLen = 0; + UINT16 evrLnkLen = 0; + UINT16 index = 0;/* ƫ */ + UINT8 flag = 0; + + UINT8 i = 0;/* ѭʹ */ + F_REFRESHLNK tmpReFreshLnk; + + inLnkLen = ShortFromChar(&pLnkStatusData[0]); + for (i = 1; i < PROTCL_MGECFG_MAXCNT + 1; i++) + { + evrLnkLen = ShortFromChar(&pLnkStatusData[2 + index]); + index += 2; + if (evrLnkLen > 0) + { + if (evrLnkLen + 2 <= inLnkLen) + { + /* þЭˢ· */ + tmpReFreshLnk = protclCfgStruBuff[i].fReFreshLnk; + if (NULL != tmpReFreshLnk) + { + if (DSU_PROTCL_FSFB == i) /*FSFBˢ2ֵ*/ + { + retVal = tmpReFreshLnk(evrLnkLen, &pLnkStatusData[index], pUnifyInfo); + } + else /*FSFB*/ + { + retVal = tmpReFreshLnk(evrLnkLen, &pLnkStatusData[2 + index], pUnifyInfo); + } + } + else /*޴Э*/ + { + retVal = 1u; + } + index += evrLnkLen; + } + else + { + flag = 1; + break; + } + + } + else + { + retVal = 1; + } + inLnkLen = inLnkLen - evrLnkLen - 2; + if (retVal == 0) + { + flag = 1; + } + } + + if (flag == 1) + { + retVal = 0; + } + return retVal; +} + + + + + +/* +* ЭЭģ +* +* ProtclConfigInfoStru *pUnifyInfo Эṹ +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 FreeSpace(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + UINT8 flag = 0; + + UINT8 i = 0;/* ѭʹ */ + F_END tmpEndF = NULL; + if (NULL != pUnifyInfo) + { + for (i = 0; i < PROTCL_MGECFG_MAXCNT + 1; i++) + { + /* þЭͷſռ亯 */ + tmpEndF = protclCfgStruBuff[i].fEnd; + if (NULL != tmpEndF) + { + retVal = tmpEndF(pUnifyInfo); + } + else /*޴Э*/ + { + retVal = 1u; + } + + if (retVal == 0) + { + flag = 1; + } + } + /* ͷĽṹռ */ + FreeSpaceFunc(pUnifyInfo); + if (flag == 1) + { + retVal = 0; + } + } + + return retVal; +} + +UINT8 ReceiveTcpState(UINT16 TcpStateDataLen, UINT8* pTcpStateData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_RSSPII + if ((NULL != pTcpStateData) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRssp2UnitInfo)) + { + ret = RsspIIInputTcpState(TcpStateDataLen, pTcpStateData, pUnifyInfo->GlobalVar->gpRssp2UnitInfo); + } +#endif + + return ret; +} + +UINT8 SendTcpCtrl(UINT16* pTcpCtrlDataLen, UINT8* pTcpCtrlData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_RSSPII + if ((NULL != pTcpCtrlDataLen) && (NULL != pTcpCtrlData) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRssp2UnitInfo)) + { + ret = RsspIIOutputTcpCtrl(pTcpCtrlDataLen, pTcpCtrlData, pUnifyInfo->GlobalVar->gpRssp2UnitInfo); + } + +#endif + + return ret; +} +/***********Эʼغ**************************************************************/ +/* +* ʼļȡӦЭ +* :UINT8 *pFileName Эļ +* ProtclConfigInfoStru *pUnifyInfo +* :UINT8 *pEvenPrtclNumBuff űͨŵЭ +* ȫֱ : +* ֵ : ɹ,Э;ʧܷ0 +*/ +UINT8 InitGetCfgInfo(UINT8* pFileName, UINT32 inDataLen, UINT8 inData[], UINT8* pEvenPrtclNumBuff, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + UINT16 locDevName = 0; + UINT8 tmpIndex = 0; + UINT16 maxLnkNum = 0; + DSU_PROTCL_TYPE_STRU tempProtclTypeNum = { 0 }; + if ((NULL!= pFileName)&&(NULL!= pEvenPrtclNumBuff)&&(NULL!= pUnifyInfo)&&(NULL!= pUnifyInfo->GlobalVar)) + { + /* 豸 */ + TypeIdToDevName(pUnifyInfo->LocalType, pUnifyInfo->LocalID, &locDevName); + + ret = DsuCommonInfoInit(pFileName, &pUnifyInfo->GlobalVar->DsuProtclBookIpInfo); /* ѯʼ,ȡ豸IPñе豸IPַ豸ͨЭ */ + if (ret == 0) + { + return ret; + } + + DsuGetProtclTypeInfo(locDevName, &pUnifyInfo->GlobalVar->protclTypeInfoStru, &pUnifyInfo->GlobalVar->DsuProtclBookIpInfo, pUnifyInfo->GlobalVar->oppTypePtl, UINT8_MAX + 1, inDataLen, inData); + CommonMemCpy(&tempProtclTypeNum, sizeof(DSU_PROTCL_TYPE_STRU), &pUnifyInfo->GlobalVar->protclTypeInfoStru, sizeof(DSU_PROTCL_TYPE_STRU)); + + maxLnkNum = tempProtclTypeNum.rsspProtclNum + tempProtclTypeNum.rsrProtclNum + tempProtclTypeNum.redunProtclNum + tempProtclTypeNum.sfpProtclNum + tempProtclTypeNum.rssp2ProtclNum + tempProtclTypeNum.fsfbProtclNum; + ret = InitProtclInfoStru(pUnifyInfo, maxLnkNum); + if (ret == 0) + { + return ret; + } + +#ifdef USE_SFP + pEvenPrtclNumBuff[tmpIndex] = tempProtclTypeNum.sfpProtclNum; +#endif + tmpIndex++; + +#ifdef USE_RP + pEvenPrtclNumBuff[tmpIndex] = tempProtclTypeNum.redunProtclNum; +#endif + tmpIndex++; + +#ifdef USE_RSR + pEvenPrtclNumBuff[tmpIndex] = tempProtclTypeNum.rsrProtclNum; +#endif + tmpIndex++; + +#ifdef USE_RSSPI + pEvenPrtclNumBuff[tmpIndex] = tempProtclTypeNum.rsspProtclNum; +#endif + tmpIndex++; + +#ifdef USE_RSSPII + pEvenPrtclNumBuff[tmpIndex] = tempProtclTypeNum.rssp2ProtclNum; +#endif + tmpIndex++; + +#ifdef USE_FSFB + pEvenPrtclNumBuff[tmpIndex] = tempProtclTypeNum.fsfbProtclNum; +#endif + tmpIndex++; + + + ret = tmpIndex; + } + + return ret; +} + +/****************************************************************************************** +* : ʼͳһṹ +1. ̬ͳһṹռ䣬гʼ +* : + +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 InitProtclInfoStru(ProtclConfigInfoStru* pUnifyInfo, UINT16 maxLnkNum) +{ + UINT8 retnVal = 0; + UINT32 lTemp = 0; + + /* ЭӦõݶг */ + lTemp = (pUnifyInfo->InputSize + 7) * maxLnkNum; + pUnifyInfo->DataToAppSize = lTemp; + retnVal = QueueInitial(&pUnifyInfo->DataToApp, pUnifyInfo->DataToAppSize); + if (0 == retnVal) + { + return retnVal; + } + + + /* ӦøЭݶг */ + lTemp = (pUnifyInfo->OutputSize + 6) * maxLnkNum; + pUnifyInfo->OutputDataQueueSize = lTemp; + retnVal = QueueInitial(&pUnifyInfo->OutputDataQueue, pUnifyInfo->OutputDataQueueSize); + if (0 == retnVal) + { + return retnVal; + } + + + /*ʼն*/ + pUnifyInfo->OutnetQueueSize = (pUnifyInfo->InputSize + 38 + 6) * maxLnkNum * pUnifyInfo->MaxNumPerCycle; + retnVal = QueueInitial(&pUnifyInfo->OutnetQueueA, pUnifyInfo->OutnetQueueSize); + if (0 == retnVal) + { + return retnVal; + } + + + /* ʼն */ + retnVal = QueueInitial(&pUnifyInfo->OutnetQueueB, pUnifyInfo->OutnetQueueSize); + if (0 == retnVal) + { + return retnVal; + } + + /* ģ:ָռ */ + + pUnifyInfo->AppArraySize = (pUnifyInfo->OutputSize + 38 + 7) * maxLnkNum + 4; + pUnifyInfo->AppArray = NULL; + pUnifyInfo->AppArray = (UINT8*)malloc(pUnifyInfo->AppArraySize); + if (NULL != pUnifyInfo->AppArray) + { + /*ʼ*/ + CommonMemSet(pUnifyInfo->AppArray, pUnifyInfo->AppArraySize, 0, pUnifyInfo->AppArraySize); + } + else + { + retnVal = 0; + /* ¼ */ + return retnVal; + } + /* ģмС */ + pUnifyInfo->VarArraySize = VAR_NODE_LEN * maxLnkNum + 32; + pUnifyInfo->VarArray = NULL; + pUnifyInfo->VarArray = (UINT8*)malloc(pUnifyInfo->VarArraySize); + if (NULL == pUnifyInfo->VarArray) + { + retnVal = 0; + /* ¼ */ + return retnVal; + } + else + { + /* ʼ */ + CommonMemSet(pUnifyInfo->VarArray, pUnifyInfo->VarArraySize, 0, pUnifyInfo->VarArraySize); + } + + /* ¼ */ + pUnifyInfo->RecordArray = NULL; + pUnifyInfo->RecordArray = (UINT8*)malloc(pUnifyInfo->RecordArraySize); + if (NULL != pUnifyInfo->RecordArray) + { + /* ʼ */ + CommonMemSet(pUnifyInfo->RecordArray, pUnifyInfo->RecordArraySize, 0, pUnifyInfo->RecordArraySize); + } + else + { + retnVal = 0; + /* ¼ */ + return retnVal; + } + + retnVal = 1; + return retnVal; +} + + +/****************************************************************************************** +* : ʼSFPЭṹ +1. ̬SFPЭṹռ䣬гʼ +* :UINT8 typeNum 豸ͨʹSFPЭĸ + +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ + +static UINT8 InitSfpProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_SFP + UINT32* curDevRecordLen = pUnifyInfo->GlobalVar->curDevRecordLen; + struc_Unify_Info* gpsfpUnitInfo = NULL; /*SFPЭṹ*/ + + if (typeNum != 0) + { + if (gpsfpUnitInfo == NULL) + { + gpsfpUnitInfo = (struc_Unify_Info*)malloc(sizeof(struc_Unify_Info)); + } + if (gpsfpUnitInfo != NULL) + { + pUnifyInfo->GlobalVar->gpsfpUnitInfo = gpsfpUnitInfo; /*ȫSFPṹ*/ + CommonMemSet(gpsfpUnitInfo, sizeof(struc_Unify_Info), 0, sizeof(struc_Unify_Info)); + /* Эʼ */ + /* ʼֵ趨 */ + gpsfpUnitInfo->CpuId = pUnifyInfo->cpuId; + gpsfpUnitInfo->CycleNum = pUnifyInfo->CycleNum; + gpsfpUnitInfo->TimeCounter = pUnifyInfo->CycleNum; + gpsfpUnitInfo->LocalID = pUnifyInfo->LocalID; /* 豸ID*/ + gpsfpUnitInfo->LocalType = pUnifyInfo->LocalType; /* 豸type*/ + gpsfpUnitInfo->MaxNumLink = typeNum; /* ͨŵĶ*/ + gpsfpUnitInfo->MaxNumPerCycle = pUnifyInfo->MaxNumPerCycle; /* һÿЧ*/ + gpsfpUnitInfo->InputSize = pUnifyInfo->InputSize; /* һ֡Ӧݳ*/ + gpsfpUnitInfo->OutputSize = pUnifyInfo->OutputSize; /* һ֡Ӧݳ*/ + gpsfpUnitInfo->RecordArraySize = (UINT16)curDevRecordLen[0]; /* ¼С*/ + gpsfpUnitInfo->OutnetQueueSize = typeNum * (pUnifyInfo->InputSize + 23) * 3 * 2 + 100; + gpsfpUnitInfo->RedundTimeout = 0xffff; + gpsfpUnitInfo->OutputTimeout = 0xffff; + gpsfpUnitInfo->RadamSN = 0x1; + + ret = ProtclInit(fileName, inDataLen, inData, gpsfpUnitInfo); + + if (ret != 1) + { + return ret; + } + } + else + { + ret = 0; + return ret; + } + } + else + { + /* */ + } + ret = 1; +#endif + + return ret; +} + + +/****************************************************************************************** +* : ʼRpЭṹ +1. ̬RPЭṹռ䣬гʼ +* :UINT8 typeNum 豸ͨʹRPЭĸ + +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 InitRpProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_RP + UINT32* curDevRecordLen = pUnifyInfo->GlobalVar->curDevRecordLen; + RP_INFO_STRU* gpRedunUnitInfo = NULL; /*Эṹ*/ + + if (typeNum != 0) + { + if (gpRedunUnitInfo == NULL) + { + gpRedunUnitInfo = (RP_INFO_STRU*)malloc(sizeof(RP_INFO_STRU)); + + } + if (gpRedunUnitInfo != NULL) + { + pUnifyInfo->GlobalVar->gpRedunUnitInfo = gpRedunUnitInfo; /*Эṹ*/ + + CommonMemSet(gpRedunUnitInfo, sizeof(RP_INFO_STRU), 0, sizeof(RP_INFO_STRU)); + /* Эʼ */ + /* ʼֵ趨 */ + gpRedunUnitInfo->LocalID = pUnifyInfo->LocalID; /* 豸ID*/ + gpRedunUnitInfo->LocalType = pUnifyInfo->LocalType; /* 豸type*/ + gpRedunUnitInfo->MaxNumLink = typeNum; /* ͨŵĶ*/ + gpRedunUnitInfo->MaxNumPerCycle = pUnifyInfo->MaxNumPerCycle; /* һÿЧ*/ + gpRedunUnitInfo->InputSize = pUnifyInfo->InputSize; /* һ֡Ӧݳ*/ + gpRedunUnitInfo->OutputSize = pUnifyInfo->OutputSize; /* 㷢һ֡Ӧݳ*/ + gpRedunUnitInfo->RecordArraySize = (UINT16)curDevRecordLen[1]; /* ¼С*/ + gpRedunUnitInfo->OutnetQueueSize = typeNum * (pUnifyInfo->InputSize + 23) * 3 * 2 + 100; + + ret = RpInit(fileName, gpRedunUnitInfo); + + if (ret != 1) + { + return ret; + } + } + else + { + ret = 0; + return ret; + } + } + else + { + /* */ + } + ret = 1; +#endif + + return ret; +} + +/****************************************************************************************** +* : ʼRSSPЭṹ +1. ̬RSSPЭṹռ䣬гʼ +* :UINT8 typeNum 豸ͨʹRSSPЭĸ + +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 InitRsspProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_RSSPI + UINT32* curDevRecordLen = pUnifyInfo->GlobalVar->curDevRecordLen; + RSSP_INFO_STRU* gpRsspUnitInfo = NULL; + + if (0 != typeNum) + { + if (NULL == gpRsspUnitInfo) + { + gpRsspUnitInfo = (RSSP_INFO_STRU*)malloc(sizeof(RSSP_INFO_STRU)); + } + if (NULL != gpRsspUnitInfo) + { + pUnifyInfo->GlobalVar->gpRsspUnitInfo = gpRsspUnitInfo; + + CommonMemSet(gpRsspUnitInfo, sizeof(RSSP_INFO_STRU), 0, sizeof(RSSP_INFO_STRU)); + /* Эʼ,ʼֵ趨 */ + gpRsspUnitInfo->cpuId = pUnifyInfo->cpuId; + gpRsspUnitInfo->CycleNum = pUnifyInfo->CycleNum; + gpRsspUnitInfo->LocalID = pUnifyInfo->LocalID; /* 豸ID*/ + gpRsspUnitInfo->LocalType = pUnifyInfo->LocalType; /* 豸type*/ + gpRsspUnitInfo->LocalLogicId = pUnifyInfo->LocalLogicId; /*߼ID*/ + gpRsspUnitInfo->MaxNumLink = typeNum; /* ͨŵĶ*/ + gpRsspUnitInfo->MaxNumPerCycle = pUnifyInfo->MaxNumPerCycle; /* һÿЧ*/ + gpRsspUnitInfo->InputSize = pUnifyInfo->InputSize; /* һ֡Ӧݳ*/ + gpRsspUnitInfo->OutputSize = pUnifyInfo->OutputSize; /* һ֡Ӧݳ*/ + gpRsspUnitInfo->RecordArraySize = (UINT16)curDevRecordLen[3]; /* ¼С*/ + + gpRsspUnitInfo->OutnetQueueSize = typeNum * (pUnifyInfo->InputSize + 23) * 3 * 2 + 100; + + ret = Rssp2Init(fileName, inDataLen, inData, gpRsspUnitInfo); + + if (ret != 1) + { + return ret; + } + } + else + { + ret = 0; + return ret; + } + } + else + { + /* */ + } + ret = 1; +#endif + + return ret; +} + +/****************************************************************************************** +* : ʼRSSP2Эṹ +1. ̬RSSP2Эṹռ䣬гʼ +* :UINT8 typeNum 豸ͨʹRSSP2Эĸ + +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 InitRssp2ProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; +#ifdef USE_RSSPII + UINT32* curDevRecordLen = pUnifyInfo->GlobalVar->curDevRecordLen; + RSSP2_INFO_STRU* gpRssp2UnitInfo = NULL; + + if (0 != typeNum) + { + if (200 < typeNum) + { + typeNum = 200; + } + if (NULL == gpRssp2UnitInfo) + { + gpRssp2UnitInfo = (RSSP2_INFO_STRU*)malloc(sizeof(RSSP2_INFO_STRU)); + } + + if (NULL != gpRssp2UnitInfo) + { + pUnifyInfo->GlobalVar->gpRssp2UnitInfo = gpRssp2UnitInfo; + + CommonMemSet(gpRssp2UnitInfo, sizeof(RSSP2_INFO_STRU), 0, sizeof(RSSP2_INFO_STRU)); + /* Эʼ,ʼֵ趨 */ + gpRssp2UnitInfo->CycleNum = pUnifyInfo->CycleNum; + gpRssp2UnitInfo->RandomNum = pUnifyInfo->CycleNum; /* add 20160819 xb */ + gpRssp2UnitInfo->LocalID = pUnifyInfo->LocalID; /* 豸ID*/ + gpRssp2UnitInfo->LocalType = pUnifyInfo->LocalType; /* 豸type*/ + gpRssp2UnitInfo->MaxNumLink = typeNum; /* ͨŵĶ*/ + gpRssp2UnitInfo->MaxNumPerCycle = pUnifyInfo->MaxNumPerCycle; /* һÿЧ*/ + if ((pUnifyInfo->InputSize > RSSP2_MAX_LEN) || (pUnifyInfo->OutputSize > RSSP2_MAX_LEN)) + { + gpRssp2UnitInfo->InputSize = RSSP2_MAX_LEN; /* һ֡Ӧݳ*/ + gpRssp2UnitInfo->OutputSize = RSSP2_MAX_LEN; /* һ֡Ӧݳ*/ + } + else + { + gpRssp2UnitInfo->InputSize = pUnifyInfo->InputSize; /* һ֡Ӧݳ*/ + gpRssp2UnitInfo->OutputSize = pUnifyInfo->OutputSize; /* һ֡Ӧݳ*/ + } + gpRssp2UnitInfo->RecordArraySize = (UINT16)curDevRecordLen[4]; /* ¼С*/ + + gpRssp2UnitInfo->OutnetQueueSize = typeNum * (pUnifyInfo->InputSize + 23) * 3 * 2 + 100; + + ret = RsspIIInit(fileName, gpRssp2UnitInfo); + + if (ret != 1) + { + return ret; + } + } + else + { + ret = 0; + return ret; + } + } + else + { + /* */ + } + + ret = 1; +#endif + + return ret; +} + + +/****************************************************************************************** +* : ʼRSRЭṹ +1. ̬RSRЭṹռ䣬гʼ +* :UINT8 typeNum 豸ͨʹRSRЭĸ + +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 InitRsrProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_RSR + UINT32* curDevRecordLen = pUnifyInfo->GlobalVar->curDevRecordLen; + RSR_INFO_STRU* gpRsrUnitInfo = NULL; + + if (0 != typeNum) + { + if (NULL == gpRsrUnitInfo) + { + gpRsrUnitInfo = (RSR_INFO_STRU*)malloc(sizeof(RSR_INFO_STRU)); + } + if (NULL != gpRsrUnitInfo) + { + pUnifyInfo->GlobalVar->gpRsrUnitInfo = gpRsrUnitInfo; + + CommonMemSet(gpRsrUnitInfo, sizeof(RSR_INFO_STRU), 0, sizeof(RSR_INFO_STRU)); + /* Эʼ,ʼֵ趨 */ + gpRsrUnitInfo->CycleNum = pUnifyInfo->CycleNum; + gpRsrUnitInfo->LocalID = pUnifyInfo->LocalID; /* 豸ID*/ + gpRsrUnitInfo->LocalType = pUnifyInfo->LocalType; /* 豸type*/ + gpRsrUnitInfo->MaxNumLink = typeNum; /* ͨŵĶ*/ + gpRsrUnitInfo->MaxNumPerCycle = pUnifyInfo->MaxNumPerCycle; /* һÿЧ*/ + if ((pUnifyInfo->InputSize > RSR_RSSP_MAX_LEN) || (pUnifyInfo->OutputSize > RSR_RSSP_MAX_LEN)) + { + gpRsrUnitInfo->InputSize = RSR_RSSP_MAX_LEN; /* һ֡Ӧݳ*/ + gpRsrUnitInfo->OutputSize = RSR_RSSP_MAX_LEN; /* һ֡Ӧݳ*/ + } + else + { + gpRsrUnitInfo->InputSize = pUnifyInfo->InputSize; /* һ֡Ӧݳ*/ + gpRsrUnitInfo->OutputSize = pUnifyInfo->OutputSize; /* һ֡Ӧݳ*/ + } + gpRsrUnitInfo->RecordArraySize = (UINT16)curDevRecordLen[2]; /* ¼С*/ + + gpRsrUnitInfo->OutnetQueueSize = typeNum * (pUnifyInfo->InputSize + 23) * 3 * 2 + 100; + + ret = RsrInit(fileName, gpRsrUnitInfo); + + if (ret != 1) + { + return ret; + } + } + else + { + ret = 0; + return ret; + } + } + else + { + /* */ + } + ret = 1; + +#endif + + return ret; +} + +/****************************************************************************************** +* : ʼFSFBЭṹ +1. ̬RSRЭṹռ䣬гʼ +* :UINT8 typeNum 豸ͨʹRSRЭĸ + +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 InitFsfbProtclStru(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], UINT8 typeNum, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 rtn = 0; + +#ifdef USE_FSFB + + FSFB_INFO_STRU* fsfbUnitInfo = NULL; + + if (0 < typeNum) /*ͨ豸*/ + { + fsfbUnitInfo = (FSFB_INFO_STRU*)malloc(sizeof(FSFB_INFO_STRU)); + if (NULL != fsfbUnitInfo) /*ڴɹ*/ + { + pUnifyInfo->GlobalVar->gpFsfbUnitInfo = fsfbUnitInfo; + CommonMemSet(fsfbUnitInfo, sizeof(FSFB_INFO_STRU), 0, sizeof(FSFB_INFO_STRU)); + + fsfbUnitInfo->CycleNum = pUnifyInfo->CycleNum; + fsfbUnitInfo->LocalType = pUnifyInfo->LocalType; + fsfbUnitInfo->LocalID = pUnifyInfo->LocalID; + fsfbUnitInfo->MaxNumLink = typeNum; + fsfbUnitInfo->MaxNumPerCycle = pUnifyInfo->MaxNumPerCycle; + if ((pUnifyInfo->InputSize > FSFB_MAX_LEN) || (pUnifyInfo->OutputSize > FSFB_MAX_LEN)) /*ÿ֡Ӧ󳤶*/ + { + fsfbUnitInfo->InputSize = FSFB_MAX_LEN; + fsfbUnitInfo->OutputSize = FSFB_MAX_LEN; + } + else + { + fsfbUnitInfo->InputSize = pUnifyInfo->InputSize; + fsfbUnitInfo->OutputSize = pUnifyInfo->OutputSize; + } + fsfbUnitInfo->RecordArraySize = (UINT16)pUnifyInfo->GlobalVar->curDevRecordLen[5]; /* ¼С*/ + + rtn = FsfbProtclInit(fileName, fsfbUnitInfo); + } + else /*ڴʧ*/ + { + rtn = 0; + } + } + else /*ͨ豸*/ + { + rtn = 1; + } + +#endif + + return rtn; +} + +/***********Э鷢غ**************************************************************/ +/* +* ܣӦ÷͵ݽ +* +* +* const QueueStruct *pAppQueueData Ӧ뵽Эݶ +* PROTCL_APP_TO_STRU *protclAppStru +* ֵ +* UINT8 1 յ֡0 +*/ +UINT8 AppSendInputDataAnalysis(QueueStruct* pAppQueueData, PROTCL_APP_TO_STRU* pProtclAppStru) +{ + UINT8 retVal = 0; + UINT8 tempBuff[2] = { 0 }; + UINT16 tempDatalen = 0; + + QueueScan(2, tempBuff, pAppQueueData); /* ϶ֽ */ + tempDatalen = ShortFromChar(tempBuff); + if (((tempDatalen + 2) <= QueueStatus(pAppQueueData)) && (4 <= tempDatalen)) + { + pProtclAppStru->appDataLen = tempDatalen - 4; + QueueRead(2, tempBuff, pAppQueueData);/* */ + QueueRead(1, &pProtclAppStru->devType, pAppQueueData);/* */ + QueueRead(1, &pProtclAppStru->devId, pAppQueueData);/* ID */ + QueueRead(2, tempBuff, pAppQueueData);/* LogicID */ + pProtclAppStru->devLogId = ShortFromChar(tempBuff); + QueueRead((tempDatalen - 4), pProtclAppStru->pAppData, pAppQueueData);/* Ӧ */ + + retVal = 1; + } + else + { + retVal = 0; + } + + return retVal; +} + +/* +* ܣSFPЭ֡ +* +* +* const PROTCL_APP_TO_STRU *protclAppStru Ҫ +* QueueStruct *pAppQueueData Эݶ +* ֵ +* UINT8 1 0 +*/ +UINT8 sfpInputPackFms(const PROTCL_APP_TO_STRU protclAppStru, QueueStruct* pAppQueueData) +{ + UINT8 retVal = 0; + UINT8 tmpHeadBuf[6] = { 0 }; + + if (protclAppStru.appDataLen > 0) + { + /* */ + ShortToChar(protclAppStru.appDataLen + 4, tmpHeadBuf); + /* 2ֽڵԤ */ + tmpHeadBuf[2] = 0; + tmpHeadBuf[3] = 0; + /* 豸ID */ + tmpHeadBuf[4] = protclAppStru.devId; + /* 豸 */ + tmpHeadBuf[5] = protclAppStru.devType; + QueueWrite(6, tmpHeadBuf, pAppQueueData); + QueueWrite(protclAppStru.appDataLen, protclAppStru.pAppData, pAppQueueData); + + retVal = 1; + } + else + { + retVal = 0; + } + + return retVal; +} + + +/* +* ܣSFPЭ鷢 +* +* +* devDataCount 豸ݸ UINT8 +* +* sendDataLen ݳ UINT32* +* pSndData UINT8* +* pLnkStatusData Э״̬ UINT8* +* lnkDataLen Э״̬ݳ UINT16* +* recordArray Э¼ UINT8* +* recordDataLen Э¼ݳ UINT16* + +* ֵ +* UINT8 1 +*/ +UINT8 sfpSendData(ProtclConfigInfoStru* pUnifyInfo, UINT8 devDataCount, UINT8* pSndData, UINT32* sendDataLen, UINT8* pLnkStatusData, UINT16* lnkDataLen, UINT8* recordArray, UINT16* recordDataLen) +{ + UINT8 ret = 0; + +#ifdef USE_SFP + UINT8 i = 0;/* ѭʹ */ + UINT32 len = 0; + UINT32 dataLen = 0; + UINT16 lenInput = 0; + UINT16 tempRecordSize = 0; + PROTCL_APP_TO_STRU* pAppDataStru = pUnifyInfo->GlobalVar->protclSndCfgStru[DSU_PROTCL_SFP].pProtclAppStru; + struc_Unify_Info* gpsfpUnitInfo = pUnifyInfo->GlobalVar->gpsfpUnitInfo; /*SFPЭṹ*/ + + QueueClear(&gpsfpUnitInfo->OutputDataQueue); + + if (pAppDataStru != NULL) + { + for (i = 0; i < devDataCount; i++) + { + sfpInputPackFms(pAppDataStru[i], &gpsfpUnitInfo->OutputDataQueue); + } +#ifdef CI_TASKLOCK + taskLock(); + ret = ProtclOutput(gpsfpUnitInfo); + taskUnlock(); +#else + ret = ProtclOutput(gpsfpUnitInfo); +#endif + if (ret == 1) + { + /* óȰмͱ ó */ + /* ݳ0ͨ·ݳ 4ֽ */ + len = LongFromChar(gpsfpUnitInfo->PrtclSndBuff); + /* ĵܳ*/ + if (len > 4) + { + dataLen = LongFromChar(gpsfpUnitInfo->PrtclSndBuff + 4); + + *sendDataLen = dataLen; + CommonMemCpy(pSndData, dataLen, gpsfpUnitInfo->PrtclSndBuff + 8, dataLen); + if (len - dataLen - 4 > 0) + { + + lenInput = (UINT16)(len - dataLen - 4); + (*lnkDataLen) = lenInput + 2; + ShortToChar(lenInput, pLnkStatusData); + CommonMemCpy(&pLnkStatusData[2], lenInput, gpsfpUnitInfo->PrtclSndBuff + 8 + dataLen, lenInput); + } + else + { + /* κδ */ + *sendDataLen = 0; + ShortToChar(0, pLnkStatusData); + *lnkDataLen = 2; + } + } + else + { + /* */ + *sendDataLen = 0; + ShortToChar(0, pLnkStatusData); + *lnkDataLen = 2; + } + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + + *sendDataLen = 0; + *lnkDataLen = 0; + } + + tempRecordSize = ShortFromChar(gpsfpUnitInfo->RecordArray) + 1; + if (gpsfpUnitInfo->RecordArraySize > 3) + { + if (gpsfpUnitInfo->RecordArraySize >= (tempRecordSize + 2)) + { + ShortToChar(0, gpsfpUnitInfo->RecordArray); + ShortToChar(tempRecordSize, recordArray); + CommonMemCpy(&recordArray[2], tempRecordSize - 1, &gpsfpUnitInfo->RecordArray[2], tempRecordSize - 1); + recordArray[2 + tempRecordSize - 1] = '\0'; + *recordDataLen = tempRecordSize + 2; + } + else + { + ShortToChar(0, gpsfpUnitInfo->RecordArray); + ShortToChar(gpsfpUnitInfo->RecordArraySize - 2, recordArray); + CommonMemCpy(&recordArray[2], gpsfpUnitInfo->RecordArraySize - 3, &gpsfpUnitInfo->RecordArray[2], gpsfpUnitInfo->RecordArraySize - 3); + recordArray[gpsfpUnitInfo->RecordArraySize - 1] = '\0'; + *recordDataLen = gpsfpUnitInfo->RecordArraySize; + } + } + + } + else + { + ret = 0; + pSndData = NULL; + pLnkStatusData = NULL; + ShortToChar(0, recordArray); + *sendDataLen = 0; + *lnkDataLen = 0; + *recordDataLen = 0; + } +#endif + + return ret; +} + + +/* +* ܣRSSPЭ֡ +* +* +* const PROTCL_APP_TO_STRU *protclAppStru Ҫ +* QueueStruct *pAppQueueData Эݶ +* ֵ +* UINT8 1 0 +*/ +UINT8 RsspInputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct* pAppQueueData) +{ + UINT8 retVal = 0; + UINT8 tmpHeadBuf[6] = { 0 }; + + if (protclAppStru.appDataLen > 0) + { + /* ֽڵij */ + ShortToChar(protclAppStru.appDataLen + 4, tmpHeadBuf); + /*һֽڵ豸ID */ + tmpHeadBuf[3] = protclAppStru.devId; + /*һֽڵ豸 */ + tmpHeadBuf[2] = protclAppStru.devType; + /*2ֽ߼ID*/ + ShortToChar(protclAppStru.devLogId, &tmpHeadBuf[4]); + QueueWrite(6, tmpHeadBuf, pAppQueueData); + QueueWrite(protclAppStru.appDataLen, protclAppStru.pAppData, pAppQueueData); + + retVal = 1; + } + else + { + retVal = 0; + } + + return retVal; +} + + +/* +* ܣRSSPЭ鷢 +* +* +* devDataCount 豸ݸ UINT8 +* sendDataLen ݳ UINT32* +* pSndData UINT8* +* pLnkStatusData Э״̬ UINT8* +* lnkDataLen Э״̬ݳ UINT16* +* recordArray Э¼ UINT8* +* recordDataLen Э¼ݳ UINT16* +* ֵ +* UINT8 1 +*/ +UINT8 RsspSendData(ProtclConfigInfoStru* pUnifyInfo, UINT8 devDataCount, UINT8* pSndData, UINT32* sendDataLen, UINT8* pLnkStatusData, UINT16* lnkDataLen, UINT8* recordArray, UINT16* recordDataLen) +{ + UINT8 ret = 0; + +#ifdef USE_RSSPI + UINT8 i = 0;/* ѭʹ */ + UINT32 len = 0; + UINT16 varlen = 0; + UINT16 tempRecordSize = 0; + PROTCL_APP_TO_STRU* pAppDataStru = NULL; + RSSP_INFO_STRU* gpRsspUnitInfo = NULL; + + if ((NULL != pUnifyInfo) && (NULL != sendDataLen) && (NULL != lnkDataLen) && (NULL != recordArray) && (NULL != recordDataLen) && (NULL != pUnifyInfo->GlobalVar)) + { + pAppDataStru = pUnifyInfo->GlobalVar->protclSndCfgStru[DSU_PROTCL_RSSP].pProtclAppStru; + gpRsspUnitInfo = pUnifyInfo->GlobalVar->gpRsspUnitInfo; + + if ((pAppDataStru != NULL) && (pSndData != NULL) && (pLnkStatusData != NULL)) + { + QueueClear(&gpRsspUnitInfo->OutputDataQueue); + + for (i = 0; i < devDataCount; i++) + { + RsspInputPackFms(pAppDataStru[i], &gpRsspUnitInfo->OutputDataQueue); + } + + + ret = Rssp2Output(gpRsspUnitInfo); + if (ret == 1) + { + /* 鳤 4ֽ */ + len = LongFromChar(gpRsspUnitInfo->AppArray); + *sendDataLen = len; + + /* м鳤 2ֽ */ + varlen = ShortFromChar(gpRsspUnitInfo->VarArray); + *lnkDataLen = varlen + 2; + /* ĵܳ*/ + if (len > 2) + { + CommonMemCpy(pSndData, len, gpRsspUnitInfo->AppArray + 4, len); + } + else + { + /* */ + *sendDataLen = 0; + /**lnkDataLen = 0;*/ + } + if (varlen > 2) + { + CommonMemCpy(pLnkStatusData, varlen + 2, gpRsspUnitInfo->VarArray, varlen + 2); + + } + else + { + /* */ + ShortToChar(0, pLnkStatusData); + *lnkDataLen = 2; + } + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + *sendDataLen = 0; + *lnkDataLen = 0; + ret = 0; + } + + tempRecordSize = ShortFromChar(gpRsspUnitInfo->RecordArray) + 1; + if (gpRsspUnitInfo->RecordArraySize > 3) + { + if (gpRsspUnitInfo->RecordArraySize >= (tempRecordSize + 2)) + { + ShortToChar(0, gpRsspUnitInfo->RecordArray); + ShortToChar(tempRecordSize, recordArray); + CommonMemCpy(&recordArray[2], tempRecordSize - 1, &gpRsspUnitInfo->RecordArray[2], tempRecordSize - 1); + recordArray[2 + tempRecordSize - 1] = '\0'; + *recordDataLen = tempRecordSize + 2; + } + else + { + ShortToChar(0, gpRsspUnitInfo->RecordArray); + ShortToChar(gpRsspUnitInfo->RecordArraySize - 2, recordArray); + CommonMemCpy(&recordArray[2], gpRsspUnitInfo->RecordArraySize - 3, &gpRsspUnitInfo->RecordArray[2], gpRsspUnitInfo->RecordArraySize - 3); + recordArray[gpRsspUnitInfo->RecordArraySize - 1] = '\0'; + *recordDataLen = gpRsspUnitInfo->RecordArraySize; + } + } + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + ShortToChar(0, recordArray); + *sendDataLen = 0; + *lnkDataLen = 0; + *recordDataLen = 0; + ret = 0; + } + } + + +#endif + + return ret; +} + + +/* +* ܣRSSP2Э֡ +* +* +* const PROTCL_APP_TO_STRU *protclAppStru Ҫ +* QueueStruct *pAppQueueData Эݶ +* ֵ +* UINT8 1 0 +*/ +UINT8 Rssp2InputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct* pAppQueueData) +{ + UINT8 retVal = 0; + UINT8 tmpHeadBuf[6] = { 0 }; + + if (protclAppStru.appDataLen > 0) + { + /* ֽڵij */ + ShortToChar(protclAppStru.appDataLen + 4, tmpHeadBuf); + /*һֽڵ豸ID */ + tmpHeadBuf[3] = protclAppStru.devId; + /*һֽڵ豸 */ + tmpHeadBuf[2] = protclAppStru.devType; + /*2ֽڵ߼ID*/ + ShortToChar(protclAppStru.devLogId, &tmpHeadBuf[4]); + QueueWrite(6, tmpHeadBuf, pAppQueueData); + QueueWrite(protclAppStru.appDataLen, protclAppStru.pAppData, pAppQueueData); + + retVal = 1; + } + else + { + retVal = 0; + } + + return retVal; +} + +/* +* ܣRSSP2Э鷢 +* +* +* devDataCount 豸ݸ UINT8 +* sendDataLen ݳ UINT32* +* pSndData UINT8* +* pLnkStatusData Э״̬ UINT8* +* lnkDataLen Э״̬ݳ UINT16* +* recordArray Э¼ UINT8* +* recordDataLen Э¼ݳ UINT16* +* ֵ +* UINT8 1 +*/ +UINT8 Rssp2SendData(ProtclConfigInfoStru* pUnifyInfo, UINT8 devDataCount, UINT8* pSndData, UINT32* sendDataLen, UINT8* pLnkStatusData, UINT16* lnkDataLen, UINT8* recordArray, UINT16* recordDataLen) +{ + UINT8 ret = 0; +#ifdef USE_RSSPII + UINT8 i = 0;/* ѭʹ */ + UINT32 len = 0; + UINT16 varlen = 0; + UINT16 recordLen = 0; + PROTCL_APP_TO_STRU* pAppDataStru = pUnifyInfo->GlobalVar->protclSndCfgStru[DSU_PROTCL_RSSP2].pProtclAppStru; + RSSP2_INFO_STRU* gpRssp2UnitInfo = pUnifyInfo->GlobalVar->gpRssp2UnitInfo; + + if ((pAppDataStru != NULL) && (pSndData != NULL) && (pLnkStatusData != NULL)) + { + QueueClear(&gpRssp2UnitInfo->OutputDataQueue); + + for (i = 0; i < devDataCount; i++) + { + Rssp2InputPackFms(pAppDataStru[i], &gpRssp2UnitInfo->OutputDataQueue); + } + + + ret = RsspIIOutput(gpRssp2UnitInfo); + + if (ret == 1) + { + + /* ĵܳ*/ + len = (UINT32)(gpRssp2UnitInfo->AppArraySize); + if (len > 2) + { + CommonMemCpy(pSndData, len, gpRssp2UnitInfo->AppArray, len); + *sendDataLen = len; + } + else + { + /* */ + *sendDataLen = 0; + } + /* м鳤 2ֽ */ + varlen = ShortFromChar(gpRssp2UnitInfo->VarArray); + if (varlen > 2) + { + CommonMemCpy(pLnkStatusData, varlen + 2, gpRssp2UnitInfo->VarArray, varlen + 2); + *lnkDataLen = varlen + 2; + } + else + { + /* */ + ShortToChar(0, pLnkStatusData); + *lnkDataLen = 2; + } + + recordLen = ShortFromChar(gpRssp2UnitInfo->RecordArray); + if (recordLen > 2) + { + CommonMemCpy(recordArray, recordLen + 2, gpRssp2UnitInfo->RecordArray, recordLen + 2); + *recordDataLen = recordLen + 2; + } + else + { + ShortToChar(0, recordArray); + *recordDataLen = 2; + } + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + *sendDataLen = 0; + *lnkDataLen = 0; + *recordDataLen = 0; + ret = 0; + } + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + ShortToChar(0, recordArray); + *sendDataLen = 0; + *lnkDataLen = 0; + *recordDataLen = 0; + ret = 0; + } +#endif + + return ret; +} + + + + +#ifdef USE_RSR +/* +* ܣRSRЭ֡ +* +* +* const PROTCL_APP_TO_STRU *protclAppStru Ҫ +* QueueStruct *pAppQueueData Эݶ +* ֵ +* UINT8 1 0 +*/ +UINT8 RsrInputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct* pAppQueueData, RSR_INFO_STRU* gpRsrUnitInfo) +{ + UINT8 retVal = 0; + UINT8 tmpHeadBuf[8] = { 0 }; + UINT16 destDevName = 0; + UINT16 locDevName = 0; + UINT8 index = 0; + + UINT16 rsspSrcAdd = 0; + INT16 bsdAdd = 0; + UINT16 destRsspAdd = 0; + + if (protclAppStru.appDataLen > 0) + { + TypeIdToDevName(protclAppStru.devType, protclAppStru.devId, &destDevName); + TypeIdToDevName(gpRsrUnitInfo->LocalType, gpRsrUnitInfo->LocalID, &locDevName); + if (protclAppStru.devType == VOBC_TYPE) + { + retVal = dsuVOBCvsCIOutInfo(protclAppStru.devLogId, 0, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + else if (gpRsrUnitInfo->LocalType == VOBC_TYPE) + { + retVal = dsuVOBCvsCIOutInfo(protclAppStru.devLogId, 1, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + else + { + retVal = dsuZCvsCIOutInfo(locDevName, destDevName, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + if (retVal != 0) + { + /* ֽڵij */ + ShortToChar(protclAppStru.appDataLen + 6, tmpHeadBuf); + index += 2; + /* ֽڵԴַ */ + ShortToChar(rsspSrcAdd, tmpHeadBuf + index); + index += 2; + /* ֽڵBSDַ */ + ShortToChar(bsdAdd, tmpHeadBuf + index); + index += 2; + /* ֽڵĿַ */ + ShortToChar(destRsspAdd, tmpHeadBuf + index); + QueueWrite(8, tmpHeadBuf, pAppQueueData); + QueueWrite(protclAppStru.appDataLen, protclAppStru.pAppData, pAppQueueData); + } + else + { + retVal = 0; + } + } + else + { + retVal = 0; + } + + return retVal; +} +#endif + + +/* +* ܣRSRЭ鷢 +* +* +* devDataCount 豸ݸ UINT8 +* sendDataLen ݳ UINT32* +* pSndData UINT8* +* pLnkStatusData Э״̬ UINT8* +* lnkDataLen Э״̬ݳ UINT16* +* recordArray Э¼ UINT8* +* recordDataLen Э¼ݳ UINT16* +* ֵ +* UINT8 1 +*/ +UINT8 RsrSendData(ProtclConfigInfoStru* pUnifyInfo, UINT8 devDataCount, UINT8* pSndData, UINT32* sendDataLen, UINT8* pLnkStatusData, UINT16* lnkDataLen, UINT8* recordArray, UINT16* recordDataLen) +{ + UINT8 ret = 0; + +#ifdef USE_RSR + UINT8 i = 0; + UINT16 len = 0; + UINT16 varlen = 0; + UINT16 tempRecordSize = 0; + PROTCL_APP_TO_STRU* pAppDataStru = pUnifyInfo->GlobalVar->protclSndCfgStru[DSU_PROTCL_RSR].pProtclAppStru; + RSR_INFO_STRU* gpRsrUnitInfo = pUnifyInfo->GlobalVar->gpRsrUnitInfo; + + UINT8 protclType = GetCbtcSysType(); + + if ((pAppDataStru != NULL) && (pSndData != NULL) && (pLnkStatusData != NULL)) + { + QueueClear(&gpRsrUnitInfo->OutputDataQueue); + for (i = 0; i < devDataCount; i++) + { + RsrInputPackFms(pAppDataStru[i], &gpRsrUnitInfo->OutputDataQueue, gpRsrUnitInfo); + } + + ret = RsrOutput(gpRsrUnitInfo); + if (ret == 1) + { + /* 鳤 2ֽ */ + len = ShortFromChar(gpRsrUnitInfo->AppArray); + if (DQU_CBTC_HLT != protclType) + { + *sendDataLen = len; + } + /* м鳤 2ֽ */ + varlen = ShortFromChar(gpRsrUnitInfo->VarArray); + /* yw.lou RPһҲҪͬ*/ + /* ĵܳ*/ + if (len > 2) + { + if (DQU_CBTC_HLT == protclType) + { + RsrAndRpAppArrayPage(gpRsrUnitInfo->AppArray + 2, len, pSndData, sendDataLen); + } + else + { + CommonMemCpy(pSndData, len, gpRsrUnitInfo->AppArray + 2, len); + } + } + else + { + /* */ + *sendDataLen = 0; + } + if (varlen > 2) + { + *lnkDataLen = varlen + 2; + CommonMemCpy(pLnkStatusData, varlen + 2, gpRsrUnitInfo->VarArray, varlen + 2); + + } + else + { + /* */ + ShortToChar(0, pLnkStatusData); + + *lnkDataLen = 2; + } + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + *lnkDataLen = 0; + *sendDataLen = 0; + ret = 0; + } + + tempRecordSize = ShortFromChar(gpRsrUnitInfo->RecordArray) + 1; + if (gpRsrUnitInfo->RecordArraySize > 3) + { + if (gpRsrUnitInfo->RecordArraySize >= (tempRecordSize + 2)) + { + ShortToChar(0, gpRsrUnitInfo->RecordArray); + ShortToChar(tempRecordSize, recordArray); + CommonMemCpy(&recordArray[2], tempRecordSize - 1, &gpRsrUnitInfo->RecordArray[2], tempRecordSize - 1); + recordArray[2 + tempRecordSize - 1] = '\0'; + *recordDataLen = tempRecordSize + 2; + } + else + { + ShortToChar(0, gpRsrUnitInfo->RecordArray); + ShortToChar(gpRsrUnitInfo->RecordArraySize - 2, recordArray); + CommonMemCpy(&recordArray[2], gpRsrUnitInfo->RecordArraySize - 3, &gpRsrUnitInfo->RecordArray[2], gpRsrUnitInfo->RecordArraySize - 3); + recordArray[gpRsrUnitInfo->RecordArraySize - 1] = '\0'; + *recordDataLen = gpRsrUnitInfo->RecordArraySize; + } + } + + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + ShortToChar(0, recordArray); + *sendDataLen = 0; + *lnkDataLen = 0; + *recordDataLen = 0; + ret = 0; + } +#endif + + return ret; +} + +/* +* ܣRPЭ֡ +* +* +* const PROTCL_APP_TO_STRU *protclAppStru Ҫ +* QueueStruct *pAppQueueData Эݶ +* ֵ +* UINT8 1 0 +*/ +UINT8 RpInputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct* pAppQueueData) +{ + UINT8 retVal = 0; + UINT8 tmpHeadBuf[4] = { 0 }; + + if (protclAppStru.appDataLen > 0) + { + /* ֽڵij */ + ShortToChar(protclAppStru.appDataLen + 2, tmpHeadBuf); + /* 1ֽڵ豸 */ + tmpHeadBuf[2] = protclAppStru.devType; + /* 1ֽڵ豸ID */ + tmpHeadBuf[3] = protclAppStru.devId; + QueueWrite(4, tmpHeadBuf, pAppQueueData); + QueueWrite(protclAppStru.appDataLen, protclAppStru.pAppData, pAppQueueData); + + retVal = 1; + } + else + { + retVal = 0; + } + + return retVal; +} + + +/* +* ܣRPЭ鷢 +* +* +* devDataCount 豸ݸ UINT8 +* sendDataLen ݳ UINT32* +* pSndData UINT8* +* pLnkStatusData Э״̬ UINT8* +* lnkDataLen Э״̬ݳ UINT16* +* recordArray Э¼ UINT8* +* recordDataLen Э¼ݳ UINT16* +* ֵ +* UINT8 1 +*/ +UINT8 RpSendData(ProtclConfigInfoStru* pUnifyInfo, UINT8 devDataCount, UINT8* pSndData, UINT32* sendDataLen, UINT8* pLnkStatusData, UINT16* lnkDataLen, UINT8* recordArray, UINT16* recordDataLen) +{ + UINT8 ret = 0; + +#ifdef USE_RP + UINT8 i = 0; + UINT16 len = 0; + UINT16 varlen = 0; + UINT16 tempRecordSize = 0; + PROTCL_APP_TO_STRU* pAppDataStru = pUnifyInfo->GlobalVar->protclSndCfgStru[DSU_PROTCL_RP].pProtclAppStru; + RP_INFO_STRU* gpRedunUnitInfo = pUnifyInfo->GlobalVar->gpRedunUnitInfo; /*Эṹ*/ + + if ((pAppDataStru != NULL) && (pSndData != NULL) && (pLnkStatusData != NULL)) + { + QueueClear(&gpRedunUnitInfo->OutputDataQueue); + for (i = 0; i < devDataCount; i++) + { + RpInputPackFms(pAppDataStru[i], &gpRedunUnitInfo->OutputDataQueue); + } + + + ret = RpOutput(gpRedunUnitInfo); + if (ret == 1) + { + /* 鳤 2ֽ */ + len = ShortFromChar(gpRedunUnitInfo->AppArray); + /* м鳤 2ֽ */ + varlen = ShortFromChar(gpRedunUnitInfo->VarArray); + + /*yw.lou ޸: ڷӦݿܴΪյʱ״̬ݣʹ*/ + /* ĵܳ*/ + if ((len > 2)) + { + CommonMemCpy(pSndData, len, gpRedunUnitInfo->AppArray + 2, len); + *sendDataLen = len; + } + else + { + /* */ + *sendDataLen = 0; + } + if (varlen > 2) + { + *lnkDataLen = varlen + 2; + CommonMemCpy(pLnkStatusData, varlen + 2, gpRedunUnitInfo->VarArray, varlen + 2); + + } + else + { + /* */ + ShortToChar(0, pLnkStatusData); + *lnkDataLen = 2; + } + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + *sendDataLen = 0; + *lnkDataLen = 0; + ret = 0; + } + + tempRecordSize = ShortFromChar(gpRedunUnitInfo->RecordArray) + 1; + if (gpRedunUnitInfo->RecordArraySize > 3) + { + if (gpRedunUnitInfo->RecordArraySize >= (tempRecordSize + 2)) + { + ShortToChar(0, gpRedunUnitInfo->RecordArray); + ShortToChar(tempRecordSize, recordArray); + CommonMemCpy(&recordArray[2], tempRecordSize - 1, &gpRedunUnitInfo->RecordArray[2], tempRecordSize - 1); + recordArray[2 + tempRecordSize - 1] = '\0'; + *recordDataLen = tempRecordSize + 2; + } + else + { + ShortToChar(0, gpRedunUnitInfo->RecordArray); + ShortToChar(gpRedunUnitInfo->RecordArraySize - 2, recordArray); + CommonMemCpy(&recordArray[2], gpRedunUnitInfo->RecordArraySize - 3, &gpRedunUnitInfo->RecordArray[2], gpRedunUnitInfo->RecordArraySize - 3); + recordArray[gpRedunUnitInfo->RecordArraySize - 1] = '\0'; + *recordDataLen = gpRedunUnitInfo->RecordArraySize; + } + } + } + else + { + pSndData = NULL; + pLnkStatusData = NULL; + ShortToChar(0, recordArray); + recordArray = NULL; + *sendDataLen = 0; + *lnkDataLen = 0; + recordDataLen = 0; + ret = 0; + } +#endif + + return ret; +} + + +/* +* ܣFSFBЭ֡ +* +* +* const PROTCL_APP_TO_STRU *protclAppStru Ҫ +* QueueStruct *pAppQueueData Эݶ +* ֵ +* UINT8 1 0 +*/ +UINT8 FsfbInputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct* pAppQueueData) +{ + UINT8 retVal = 0u; /*ֵ*/ + UINT8 headBuf[5] = { 0 }; /*֡ͷ*/ + + if (protclAppStru.appDataLen > 0) + { + ShortToChar(protclAppStru.appDataLen + 3, headBuf); /*2ֽڳ*/ + headBuf[2] = protclAppStru.devType; /*1ֽ豸*/ + headBuf[3] = protclAppStru.devId; /*1ֽ豸ID*/ + headBuf[4] = 0x01; /*1ֽ֡*/ + + QueueWrite(5, headBuf, pAppQueueData); + QueueWrite(protclAppStru.appDataLen, protclAppStru.pAppData, pAppQueueData); + + retVal = 1u; + } + + return retVal; +} + +/* +* ܣFSFBЭ鷢 +* +* +* devDataCount 豸ݸ UINT8 +* sendDataLen ݳ UINT32* +* pSndData UINT8* +* pLnkStatusData Э״̬ UINT8* +* lnkDataLen Э״̬ݳ UINT16* +* recordArray Э¼ UINT8* +* recordDataLen Э¼ݳ UINT16* +* ֵ +* UINT8 1 +*/ +UINT8 FsfbSendData(ProtclConfigInfoStru* pUnifyInfo, UINT8 devDataCount, UINT8* pSndData, UINT32* sendDataLen, UINT8* pLnkStatusData, UINT16* lnkDataLen, UINT8* recordArray, UINT16* recordDataLen) +{ + UINT8 retVal = 0u; + +#ifdef USE_FSFB + + UINT32* curCycleNum = NULL; /*ǰ*/ + PROTCL_APP_TO_STRU* appToStru = NULL; /*ӦõЭݽṹ*/ + FSFB_INFO_STRU* fsfbInfo = NULL; /*FSFBЭṹ*/ + UINT8 i = 0u;/*ѭ*/ + UINT32 outQueDataLen = 0u; /*FSFBݳ*/ + UINT8 outQueData[FSFB_MAX_LEN * 16] = { 0 }; /*FSFB*/ + UINT32 outQueIdx = 0u; /*FSFBλ*/ + UINT16 outQueFramLen = 0u; /*FSFB֡*/ + UINT8 btmHead[5] = { 0 }; /*FSFB BTM֡ͷ*/ + UINT8 queWriteRtn = 0u; /*дֵ*/ + UINT32 dataLen = 0u; /*FSFBݳ*/ + UINT32 dataIdx = 0u; /*FSFBݵǰλ*/ + UINT16 frameLen = 0u; /*FSFB֡*/ + UINT16 dstTypeId = 0u; /*ĿID*/ + UINT16 recordLen = 0u; /*¼*/ + + if ((NULL != pUnifyInfo) && (NULL != pSndData) && (NULL != sendDataLen) && (NULL != pLnkStatusData) && (NULL != lnkDataLen) && (NULL != recordArray) && (NULL != recordDataLen) + && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpFsfbUnitInfo) && (NULL != pUnifyInfo->GlobalVar->protclSndCfgStru[DSU_PROTCL_FSFB].pProtclAppStru) + && (NULL != pUnifyInfo->CycleNum)) + { + curCycleNum = pUnifyInfo->CycleNum; + appToStru = pUnifyInfo->GlobalVar->protclSndCfgStru[DSU_PROTCL_FSFB].pProtclAppStru; + fsfbInfo = pUnifyInfo->GlobalVar->gpFsfbUnitInfo; + + QueueClear(&fsfbInfo->OutputDataQueue); + LongToChar(0u, fsfbInfo->AppArray); + + if (0u == ((*curCycleNum) % 2))/*FSFBЭΪ600ms*/ + { + for (i = 0; i < devDataCount; i++) /*Ŀ豸ݵ*/ + { + FsfbInputPackFms(appToStru[i], &fsfbInfo->OutputDataQueue); + } + + if (0 == ((*curCycleNum) % 50)) /*CI300msһ,50,15sһBTC*/ + { + outQueDataLen = QueueStatus(&fsfbInfo->OutputDataQueue); + if (outQueDataLen <= FSFB_MAX_LEN * 16) /*δ󳤶*/ + { + QueueScan(outQueDataLen, outQueData, &fsfbInfo->OutputDataQueue); + while ((outQueIdx + 4) < outQueDataLen) + { + outQueFramLen = ShortFromChar(&outQueData[outQueIdx]); /*2ֽڳ*/ + outQueIdx += 2; + ShortToChar((UINT16)3, &btmHead[0]); /*2ֽBTM֡ͷ*/ + memcpy(&btmHead[2], &outQueData[outQueIdx], 2); /*2ֽĿLEUID*/ + btmHead[4] = 0x10; /*BTM֡*/ + + queWriteRtn = QueueWrite(5, btmHead, &fsfbInfo->OutputDataQueue); + if (1u == queWriteRtn) + { + outQueIdx += outQueFramLen; + } + else + { + break; + } + } + } + else /*󳤶*/ + { + QueueClear(&fsfbInfo->OutputDataQueue); + } + } + + retVal = FsfbProtclOutPut(fsfbInfo); + + if (1u == retVal) + { + dataLen = 4 + LongFromChar(&fsfbInfo->AppArray[dataIdx]); + dataIdx += 4; + while ((dataIdx + 4) < dataLen) + { + /*2ֽڳ*/ + frameLen = ShortFromChar(&fsfbInfo->AppArray[dataIdx]); + dataIdx += 2; + ShortToChar(frameLen + 3, &pSndData[*sendDataLen]); + *sendDataLen += 2; + + /*1ֽЭ*/ + pSndData[*sendDataLen] = DSU_PROTCL_FSFB; + *sendDataLen += 1; + + /*2ֽĿID*/ + dstTypeId = ShortFromChar(&fsfbInfo->AppArray[dataIdx]); + dataIdx += 2; + ShortToChar(dstTypeId, &pSndData[*sendDataLen]); + *sendDataLen += 2; + + /*2ֽĿ߼ID*/ + ShortToChar(0u, &pSndData[*sendDataLen]); + *sendDataLen += 2; + + if ((2 <= frameLen) && ((dataIdx + frameLen - 2) <= dataLen)) /*֡*/ + { + frameLen -= 2; + CommonMemCpy(&pSndData[*sendDataLen], frameLen, &fsfbInfo->AppArray[dataIdx], frameLen); + + dataIdx += frameLen; + *sendDataLen += frameLen; + } + else + { + break; + } + } + + /*м*/ + *lnkDataLen = 2 + ShortFromChar(fsfbInfo->VarArray); + CommonMemCpy(pLnkStatusData, *lnkDataLen, fsfbInfo->VarArray, *lnkDataLen); + } + + if (fsfbInfo->RecordArraySize > 3) /*м¼ռ*/ + { + recordLen = ShortFromChar(fsfbInfo->RecordArray); /*־*/ + if ((2 + recordLen + 1) <= fsfbInfo->RecordArraySize) /*ɴ־,1ֽΪַ*/ + { + ShortToChar(recordLen + 1, &recordArray[0]); + CommonMemCpy(&recordArray[2], recordLen, &fsfbInfo->RecordArray[2], recordLen); + recordArray[2 + recordLen] = '\0'; + + *recordDataLen = 2 + recordLen + 1; + } + else /*ɴ־*/ + { + ShortToChar(fsfbInfo->RecordArraySize - 2, &recordArray[0]); + CommonMemCpy(&recordArray[2], fsfbInfo->RecordArraySize - 3, &fsfbInfo->RecordArray[2], fsfbInfo->RecordArraySize - 3); + recordArray[fsfbInfo->RecordArraySize - 1] = '\0'; + + *recordDataLen = fsfbInfo->RecordArraySize; + } + } + } + else + { + retVal = 1u; + } + } + +#endif + + return retVal; +} + + + +/* +* ܣRPRSRЭ鷢֡ +* +* +* UINT8* pInAppArray Ӧ +* UINT32 appDtaLen ݳ +* UINT32* outAppLen Ӧݳ +* UINT8* pOutAppArray Ӧ +* ֵ +* UINT8 1 +*/ +UINT8 RsrAndRpAppArrayPage(UINT8* pInAppArray, UINT32 appDtaLen, UINT8* pOutAppArray, UINT32* outAppLen) +{ + UINT8 retnVal = 0; + UINT32 index = 0; + UINT32 outIndex = 0; + UINT16 dataLen = 0; + + if ((pInAppArray != NULL) && (pOutAppArray != NULL) && (outAppLen != NULL)) + { + while (appDtaLen > 0) + { + /*ӽڵijȳȵԴ+2(Ŀ豸Դ豸)*/ + dataLen = ShortFromChar(&pInAppArray[index]); + if (appDtaLen >= (dataLen + 2)) + { + ShortToChar(dataLen + 2, &pOutAppArray[outIndex]); + /*1ֽڵĿ豸*/ + index += 2; + outIndex += 2; + pOutAppArray[outIndex++] = 1; + /*IPַͶ˿ں ܹ12ֽ*/ + CommonMemCpy(&pOutAppArray[outIndex], 12, &pInAppArray[index], 12); + + index += 12; + outIndex += 12; + /*1ֽڵԴ豸*/ + pOutAppArray[outIndex++] = 1; + /*IPַͶ˿ں ܹ12ֽ*/ + CommonMemCpy(&pOutAppArray[outIndex], 12, &pInAppArray[index], 12); + index += 12; + outIndex += 12; + /*Ӧ*/ + CommonMemCpy(&pOutAppArray[outIndex], dataLen - 24, &pInAppArray[index], dataLen - 24); + appDtaLen = appDtaLen - dataLen - 2; + outIndex += (dataLen - 24); + index += (dataLen - 24); + } + else + { + break; + } + } + *outAppLen = outIndex; + + retnVal = 1; + } + else + { + retnVal = 0; + } + return retnVal; +} + +/***********Эغ**************************************************************/ +/* +* ܣSFPЭ +* +* +* struc_Unify_Info *gpsfpUnitInfo SFPṹ +* QueueStruct* pOutToApp Ӧõ֡ʽ +* ֵ +* UINT8 1 +*/ +UINT8 SfpRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_SFP + UINT8 tempDatabuff[2] = { 0 }; + UINT16 tempDataLen = 0; + UINT8* sfpRcvDataBuff = NULL; + UINT16 tmpLogid = 0; + struc_Unify_Info* gpsfpUnitInfo = NULL; + + if ((NULL != pOutToApp) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpSfpRcvDataBuff) && (NULL != pUnifyInfo->GlobalVar->gpsfpUnitInfo)) + { + sfpRcvDataBuff = pUnifyInfo->GlobalVar->gpSfpRcvDataBuff; + gpsfpUnitInfo = pUnifyInfo->GlobalVar->gpsfpUnitInfo; + + CommonMemSet(sfpRcvDataBuff, sizeof(UINT8) * pUnifyInfo->GlobalVar->gSfpRcvDataBuffLen, 0u, sizeof(UINT8) * pUnifyInfo->GlobalVar->gSfpRcvDataBuffLen); + while (QueueStatus(&gpsfpUnitInfo->DataToApp) > 2) + { + QueueRead(2, tempDatabuff, &gpsfpUnitInfo->DataToApp);/* ֽڳ */ + + tempDataLen = ShortFromChar(tempDatabuff); + QueueRead(tempDataLen, sfpRcvDataBuff, &gpsfpUnitInfo->DataToApp); + tempDataLen = tempDataLen - 5 + PROTCL_OUT_FONT_LEN; + /*ShortToChar(tempDataLen,tempDatabuff);*/ + RcvDataToAppQueue(sfpRcvDataBuff[3], sfpRcvDataBuff[2], tmpLogid, sfpRcvDataBuff[4], tempDataLen, sfpRcvDataBuff + 5, pOutToApp); + } + + } +#endif + + ret = 1; + + return ret; +} + + + + +/* +* ܣRSRЭ +* +* +* +* QueueStruct* pOutToApp Ӧõ֡ʽ +* ֵ +* UINT8 1 +*/ +UINT8 RsrRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_RSR + UINT8 tempDatabuff[2] = { 0 }; + UINT16 tempDataLen = 0; + UINT8* rsrRcvDataBuff = NULL; + UINT16 tmpLogid = 0; + UINT16 srcAddr = 0; + UINT16 destAddr = 0; + UINT16 destDevName = 0; + UINT8 destDevType = 0; + UINT8 destDevId = 0; + RSR_INFO_STRU* gpRsrUnitInfo = NULL; + + if ((NULL != pOutToApp) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsrRcvDataBuff) && (NULL != pUnifyInfo->GlobalVar->gpRsrUnitInfo)) + { + rsrRcvDataBuff = pUnifyInfo->GlobalVar->gpRsrRcvDataBuff; + gpRsrUnitInfo = pUnifyInfo->GlobalVar->gpRsrUnitInfo; + + CommonMemSet(rsrRcvDataBuff, sizeof(UINT8) * pUnifyInfo->GlobalVar->gRsrRcvDataBuffLen, 0u, sizeof(UINT8) * pUnifyInfo->GlobalVar->gRsrRcvDataBuffLen); + while (QueueStatus(&gpRsrUnitInfo->DataToApp) > 2) + { + QueueRead(2, tempDatabuff, &gpRsrUnitInfo->DataToApp);/* ֽڳ */ + + tempDataLen = ShortFromChar(tempDatabuff); + QueueRead(tempDataLen, rsrRcvDataBuff, &gpRsrUnitInfo->DataToApp); + tempDataLen = tempDataLen - 4 + PROTCL_OUT_FONT_LEN; + srcAddr = ShortFromChar(rsrRcvDataBuff); + destAddr = ShortFromChar(rsrRcvDataBuff + 2); + + if (gpRsrUnitInfo->LocalType == VOBC_TYPE) + { + + dsuVOBCvsCIInInfo(srcAddr, destAddr, &tmpLogid); + destDevType = CI_TYPE; + } + else if (gpRsrUnitInfo->LocalType == ZC_TYPE) + { + dsuZCvsCIInInfo(srcAddr, destAddr, &destDevName); + DevName2TypeId(destDevName, &destDevType, &destDevId); + tmpLogid = 0; + } + else if (gpRsrUnitInfo->LocalType == CI_TYPE) + { + if (dsuVOBCvsCIInInfo(srcAddr, destAddr, &tmpLogid) == 0) + { + dsuZCvsCIInInfo(srcAddr, destAddr, &destDevName); + DevName2TypeId(destDevName, &destDevType, &destDevId); + tmpLogid = 0; + } + else + { + /*dsuVOBCvsCIInInfo(srcAddr,destAddr,&tmpLogid);*/ + destDevType = VOBC_TYPE; + } + } + else + { + ret = 0; + return ret; + } + RcvDataToAppQueue(destDevType, destDevId, tmpLogid, 0, tempDataLen, rsrRcvDataBuff + 4, pOutToApp); + + } + + } +#endif + + ret = 1; + + return ret; +} + +/*յд뵽 */ +UINT8 RcvDataToAppQueue(UINT8 devType, UINT8 devId, UINT16 logId, UINT8 lifeTime, UINT16 appDatalen, UINT8* pAppData, QueueStruct* pDataToApp) +{ + UINT8 ret = 0; + UINT8 tempDataBuff[2] = { 0 }; + ShortToChar(appDatalen, tempDataBuff); + QueueWrite(2, tempDataBuff, pDataToApp); + QueueWrite(1, &devType, pDataToApp); + QueueWrite(1, &devId, pDataToApp); + ShortToChar(logId, tempDataBuff); + QueueWrite(2, tempDataBuff, pDataToApp); + QueueWrite(1, &lifeTime, pDataToApp); + QueueWrite(appDatalen - PROTCL_OUT_FONT_LEN, pAppData, pDataToApp); + ret = 1; + return ret; +} + + +/* +* ܣRSSPЭ +* +* +* +* QueueStruct* pOutToApp Ӧõ֡ʽ +* ֵ +* UINT8 1 +*/ +UINT8 RsspRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_RSSPI + UINT8 tempDatabuff[2] = { 0 }; + UINT16 tempDataLen = 0; + UINT8* rsspRcvDataBuff = NULL; + UINT16 tmpLogid = 0; + UINT16 logid = 0U; + RSSP_INFO_STRU* gpRsspUnitInfo = NULL; + + if ((NULL != pOutToApp) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsspRcvDataBuff) && (NULL != pUnifyInfo->GlobalVar->gpRsspUnitInfo)) + { + rsspRcvDataBuff = pUnifyInfo->GlobalVar->gpRsspRcvDataBuff; + gpRsspUnitInfo = pUnifyInfo->GlobalVar->gpRsspUnitInfo; + + CommonMemSet(rsspRcvDataBuff, sizeof(UINT8) * pUnifyInfo->GlobalVar->gRsspRcvDataBuffLen, 0u, sizeof(UINT8) * pUnifyInfo->GlobalVar->gRsspRcvDataBuffLen); + while (QueueStatus(&gpRsspUnitInfo->DataToApp) > 2) + { + QueueRead(2, tempDatabuff, &gpRsspUnitInfo->DataToApp); + tempDataLen = ShortFromChar(tempDatabuff); + QueueRead(tempDataLen, rsspRcvDataBuff, &gpRsspUnitInfo->DataToApp); + if (4 <= tempDataLen) + { + logid = rsspRcvDataBuff[2]; + tmpLogid = (UINT16)(((logid << 8) & 0xFF00) | (rsspRcvDataBuff[3] & 0x00FF)); + tempDataLen = tempDataLen - 4 + PROTCL_OUT_FONT_LEN; + RcvDataToAppQueue(rsspRcvDataBuff[0], rsspRcvDataBuff[1], tmpLogid, 0, tempDataLen, rsspRcvDataBuff + 4, pOutToApp); + } + } + + } +#endif + + ret = 1; + + return ret; +} + +/* +* ܣRSSP2Э +* +* +* +* QueueStruct* pOutToApp Ӧõ֡ʽ +* ֵ +* UINT8 1 +*/ +UINT8 Rssp2RcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; +#ifdef USE_RSSPII + UINT8 tempDatabuff[2] = { 0 }; + UINT16 tempDataLen = 0; + UINT8* rssp2RcvDataBuff = NULL; + UINT16 logId = 0; + UINT8 devType = 0; + UINT8 devId = 0; + RSSP2_INFO_STRU* gpRssp2UnitInfo = NULL; + + if ((NULL != pOutToApp) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRssp2RcvDataBuff) && (NULL != pUnifyInfo->GlobalVar->gpRssp2UnitInfo)) + { + rssp2RcvDataBuff = pUnifyInfo->GlobalVar->gpRssp2RcvDataBuff; + gpRssp2UnitInfo = pUnifyInfo->GlobalVar->gpRssp2UnitInfo; + + CommonMemSet(rssp2RcvDataBuff, sizeof(UINT8) * pUnifyInfo->GlobalVar->gRssp2RcvDataBuffLen, 0u, sizeof(UINT8) * pUnifyInfo->GlobalVar->gRssp2RcvDataBuffLen); + while (QueueStatus(&gpRssp2UnitInfo->DataToApp) > 2) + { + QueueRead(2, tempDatabuff, &gpRssp2UnitInfo->DataToApp); + tempDataLen = ShortFromChar(tempDatabuff);/* ȡ */ + tempDataLen -= 4; + QueueRead(1, &devType, &gpRssp2UnitInfo->DataToApp); + QueueRead(1, &devId, &gpRssp2UnitInfo->DataToApp); + QueueRead(2, tempDatabuff, &gpRssp2UnitInfo->DataToApp); + logId = ShortFromChar(tempDatabuff); + QueueRead(tempDataLen, rssp2RcvDataBuff, &gpRssp2UnitInfo->DataToApp);/* ȡ */ + + tempDataLen = tempDataLen + PROTCL_OUT_FONT_LEN;/* Ӧݵij,5 */ + + RcvDataToAppQueue(devType, devId, logId, 0, tempDataLen, rssp2RcvDataBuff, pOutToApp); + } + + } +#endif + + ret = 1; + + return ret; +} + + +/* +* ܣRPЭ +* +* +* +* QueueStruct* pOutToApp Ӧõ֡ʽ +* ֵ +* UINT8 1 +*/ +UINT8 RpRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_RP + UINT8 tempDatabuff[2] = { 0 }; + UINT16 tempDataLen = 0; + UINT8* rpRcvDataBuff = NULL; + UINT8 tempType = 0; + UINT8 tempId = 0; + UINT16 tmpLogid = 0; + RP_INFO_STRU* gpRedunUnitInfo = NULL; /*Эṹ*/ + + if ((NULL != pOutToApp) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRpRcvDataBuff) && (NULL != pUnifyInfo->GlobalVar->gpRedunUnitInfo)) + { + rpRcvDataBuff = pUnifyInfo->GlobalVar->gpRpRcvDataBuff; + gpRedunUnitInfo = pUnifyInfo->GlobalVar->gpRedunUnitInfo; + + CommonMemSet(rpRcvDataBuff, sizeof(UINT8) * pUnifyInfo->GlobalVar->gRpRcvDataBuffLen, 0u, sizeof(UINT8) * pUnifyInfo->GlobalVar->gRpRcvDataBuffLen); + while (QueueStatus(&gpRedunUnitInfo->DataToApp) > 2) + { + QueueRead(2, tempDatabuff, &gpRedunUnitInfo->DataToApp); + QueueRead(1, &tempType, &gpRedunUnitInfo->DataToApp); + QueueRead(1, &tempId, &gpRedunUnitInfo->DataToApp); + + tempDataLen = ShortFromChar(tempDatabuff); + QueueRead(tempDataLen - 2, rpRcvDataBuff, &gpRedunUnitInfo->DataToApp); + tempDataLen = tempDataLen - 2 + PROTCL_OUT_FONT_LEN; + RcvDataToAppQueue(tempType, tempId, tmpLogid, 0, tempDataLen, rpRcvDataBuff, pOutToApp); + } + + } +#endif + + ret = 1; + + return ret; +} + +/* +* ܣFSFBЭ +* +* +* +* QueueStruct* pOutToApp Ӧõ֡ʽ +* ֵ +* UINT8 1 +*/ +UINT8 FsfbRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + +#ifdef USE_FSFB + UINT8 dataLenBuf[2] = { 0 }; + UINT16 dataLen = 0u; + UINT8* rcvBuf = NULL; + FSFB_INFO_STRU* gpFsfbUnitInfo = NULL; + + if ((NULL != pOutToApp) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpFsfbRcvDataBuff) && (NULL != pUnifyInfo->GlobalVar->gpFsfbUnitInfo)) + { + rcvBuf = pUnifyInfo->GlobalVar->gpFsfbRcvDataBuff; + gpFsfbUnitInfo = pUnifyInfo->GlobalVar->gpFsfbUnitInfo; + + CommonMemSet(rcvBuf, sizeof(UINT8) * pUnifyInfo->GlobalVar->gFsfbRcvDataBuffLen, 0u, sizeof(UINT8) * pUnifyInfo->GlobalVar->gFsfbRcvDataBuffLen); + while (QueueStatus(&gpFsfbUnitInfo->DataToApp) > 2) + { + QueueRead(2, dataLenBuf, &gpFsfbUnitInfo->DataToApp); + dataLen = ShortFromChar(dataLenBuf); + QueueRead(dataLen, rcvBuf, &gpFsfbUnitInfo->DataToApp); + + dataLen = dataLen - 4 + PROTCL_OUT_FONT_LEN; + RcvDataToAppQueue(rcvBuf[0], rcvBuf[1], 0, 0, dataLen, &rcvBuf[4], pOutToApp); + } + + } +#endif + + ret = 1; + + return ret; +} + + +/* ȡе */ +UINT8 readQueueDataToApp(QueueStruct* rcvQueueData, UINT8 OutNetFlag, UINT16 locDevName, PROTCL_RCV_DATA_TYPE* pDataToApp, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + UINT8 retFun = 0; + UINT8 i = 0; /* ѭʹ */ + UINT16 destDevName = 0; + UINT8 protclType = 0; + PROTCL_APP_TO_STRU* tempProtclAppStru = NULL; + +#ifdef USE_RSSPII + QueueRingID pRingQue = NULL; + CM_BOOL mbRet = CM_FALSE; + UINT32 len = 0; +#endif + + if ((NULL != rcvQueueData) && (NULL != pDataToApp) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->pRcvProtclAppStru)) + { + tempProtclAppStru = pUnifyInfo->GlobalVar->pRcvProtclAppStru; + + for (i = 0; i < PROTCL_MGECFG_MAXCNT + 1; i++) + { + /*Ϣ,;*/ + pDataToApp[i].rcvDataLen = 0; + } + + while (2 < QueueStatus(rcvQueueData)) + { + retFun = 0; + ret = AppReceiveDataAnalysis(rcvQueueData, tempProtclAppStru); + if (ret == 1) + { + TypeIdToDevName(tempProtclAppStru->devType, tempProtclAppStru->devId, &destDevName); + retFun = DsuProtclGetProtclType(locDevName, destDevName, &protclType, &pUnifyInfo->GlobalVar->DsuProtclBookIpInfo); + } + else + { + break; + } + + if (1 == retFun) + { + if (DSU_PROTCL_RSSP2 == protclType)/* RSSP-IIЭûĿ豸ID */ + { +#ifdef USE_RSSPII + pRingQue = NULL; + Prtcl_Manage_GetRQ(tempProtclAppStru->devType * 256 * 256 * 256 + tempProtclAppStru->devId * 256 * 256 + OutNetFlag * 256 + tempProtclAppStru->devLogId, &pRingQue); + QUEUE_RING_Write(pRingQue, tempProtclAppStru->pAppData, tempProtclAppStru->appDataLen); + mbRet = CM_TRUE; + while (CM_TRUE == mbRet) + { + mbRet = Prtcl_Base_Check(pRingQue, &pUnifyInfo->GlobalVar->Rssp2PrtclHead, tempProtclAppStru->pAppData, pUnifyInfo->GlobalVar->gRssp2RcvDataBuffLen, &len); + if (CM_TRUE == mbRet) + { + tempProtclAppStru->appDataLen = (UINT16)len;/* ͨݳ */ + /*һ֡βд*/ + ShortToChar(tempProtclAppStru->appDataLen + 4, pDataToApp[protclType].pData + pDataToApp[protclType].rcvDataLen);/*֡=ͨݳ+4ֽ֡ͷ*/ + /*޸Ļܳ*/ + pDataToApp[protclType].rcvDataLen += 2; + + /* ӷͷ豸 */ + *(pDataToApp[protclType].pData + pDataToApp[protclType].rcvDataLen) = tempProtclAppStru->devType; + pDataToApp[protclType].rcvDataLen++; + + /* ӷͷ豸ID */ + *(pDataToApp[protclType].pData + pDataToApp[protclType].rcvDataLen) = tempProtclAppStru->devId; + pDataToApp[protclType].rcvDataLen++; + + /* ߼ID */ + ShortToChar(tempProtclAppStru->devLogId, pDataToApp[protclType].pData + pDataToApp[protclType].rcvDataLen); + pDataToApp[protclType].rcvDataLen += 2; + + /*β*/ + CommonMemCpy(pDataToApp[protclType].pData + pDataToApp[protclType].rcvDataLen, tempProtclAppStru->appDataLen, tempProtclAppStru->pAppData, tempProtclAppStru->appDataLen); + /*»ܳ*/ + pDataToApp[protclType].rcvDataLen += tempProtclAppStru->appDataLen; + } + } +#endif + } + else + { + if ((DSU_PROTCL_RSSP == protclType) || (DSU_PROTCL_FSFB == protclType)) /*RSSPIFSFBЭ*/ + { + /*2ֽܳ*/ + ShortToChar(tempProtclAppStru->appDataLen + 4, &pDataToApp[protclType].pData[pDataToApp[protclType].rcvDataLen]); + pDataToApp[protclType].rcvDataLen += 2; + + /*1ֽ*/ + pDataToApp[protclType].pData[pDataToApp[protclType].rcvDataLen] = tempProtclAppStru->devType; + pDataToApp[protclType].rcvDataLen++; + + /*1ֽID*/ + pDataToApp[protclType].pData[pDataToApp[protclType].rcvDataLen] = tempProtclAppStru->devId; + pDataToApp[protclType].rcvDataLen++; + + /*2ֽ߼ID*/ + ShortToChar(tempProtclAppStru->devLogId, &pDataToApp[protclType].pData[pDataToApp[protclType].rcvDataLen]); + pDataToApp[protclType].rcvDataLen += 2; + } + else /*Э*/ + { + /*ЭͲд,ʹȫֹ涨ĸЭ*/ + /*pDataToApp[protclType].proType = protclType;*/ + /*һ֡βд*/ + ShortToChar(tempProtclAppStru->appDataLen, pDataToApp[protclType].pData + pDataToApp[protclType].rcvDataLen); + /*޸Ļܳ*/ + pDataToApp[protclType].rcvDataLen += 2; + } + /*β*/ + CommonMemCpy(pDataToApp[protclType].pData + pDataToApp[protclType].rcvDataLen, tempProtclAppStru->appDataLen, tempProtclAppStru->pAppData, tempProtclAppStru->appDataLen); + /*»ܳ*/ + pDataToApp[protclType].rcvDataLen += tempProtclAppStru->appDataLen; + } + } + else + { + break; + } + } + + ret = 1; + } + + return ret; +} + + +/* +* ܣӦòݽ +* +* +* const QueueStruct *pAppQueueData Ӧ뵽Эݶ +* PROTCL_APP_TO_STRU *protclAppStru +* ֵ +* UINT8 1 յ֡0 +*/ +UINT8 AppReceiveDataAnalysis(QueueStruct* pAppQueueData, PROTCL_APP_TO_STRU* pProtclAppStru) +{ + UINT8 retVal = 0; + UINT8 tempBuff[2] = { 0 }; + UINT16 tempDatalen = 0; + + UINT8 protclType = GetCbtcSysType(); + + QueueScan(2, tempBuff, pAppQueueData); /* ϶ֽ */ + tempDatalen = ShortFromChar(tempBuff); + + if ((tempDatalen + 2) <= QueueStatus(pAppQueueData)) + { + + QueueRead(2, tempBuff, pAppQueueData);/* */ + QueueRead(1, &pProtclAppStru->devType, pAppQueueData);/* */ + QueueRead(1, &pProtclAppStru->devId, pAppQueueData);/* ID */ + + if ((DQU_CBTC_CPK == protclType) || (DQU_CBTC_FAO == protclType)) /*ϿFAO*/ + { + pProtclAppStru->appDataLen = tempDatalen - 2; + QueueRead((tempDatalen - 2), pProtclAppStru->pAppData, pAppQueueData);/* Ӧ */ + retVal = 1; + } + else /**/ + { + if (4 <= tempDatalen) + { + pProtclAppStru->appDataLen = tempDatalen - 4; + QueueRead(2, tempBuff, pAppQueueData); + pProtclAppStru->devLogId = ShortFromChar(tempBuff); + QueueRead((tempDatalen - 4), pProtclAppStru->pAppData, pAppQueueData);/* Ӧ */ + + retVal = 1; + } + else + { + retVal = 0; + } + } + } + else + { + retVal = 0; + } + + return retVal; +} + + +/* +* Buffĸʽѹ +*/ +UINT8 SetDataToQue(UINT32 dataLen, UINT8* buff, QueueStruct* q) +{ + UINT8 ret = 0; + QueueClear(q); + ret = QueueWrite(dataLen, buff, q); + return ret; +} + + + +/************************************·״̬ѯ******************************************/ +/* +* ܣSFPЭѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* struc_Unify_Info *pSfpUnitInfo SFPͳһṹ +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +* 0x33·׼״̬ +* 0x4e·ڵȴ״̬ +*/ +UINT8 GetSfpLnkStatus(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_SFP + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpsfpUnitInfo)) + { + retVal = ProtclCheckLnkStatus(destType, destId, pUnifyInfo->GlobalVar->gpsfpUnitInfo); + } + +#endif + + return retVal; +} + +/* +* ܣRSRЭѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +*/ +UINT8 GetRsrLnkStatus(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSR + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsrUnitInfo)) + { + + UINT16 locDevName = 0; + UINT16 DestDevName = 0; + UINT16 rsspSrcAdd = 0; + INT16 bsdAdd = 0; + UINT16 destRsspAdd = 0; + RSR_INFO_STRU* gpRsrUnitInfo = pUnifyInfo->GlobalVar->gpRsrUnitInfo; + + TypeIdToDevName(gpRsrUnitInfo->LocalType, gpRsrUnitInfo->LocalID, &locDevName); + TypeIdToDevName(destType, destId, &DestDevName); + + if (destType == VOBC_TYPE) + { + retVal = dsuVOBCvsCIOutInfo(logId, 0, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + else if (gpRsrUnitInfo->LocalType == VOBC_TYPE) + { + retVal = dsuVOBCvsCIOutInfo(logId, 1, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + else + { + retVal = dsuZCvsCIOutInfo(locDevName, DestDevName, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + if (1 == retVal) + { + retVal = RsrLnkStatus(rsspSrcAdd, bsdAdd, destRsspAdd, gpRsrUnitInfo); + } + } +#endif + + return retVal; +} + +/* +* ܣRSSPЭѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +*/ +UINT8 GetRsspLnkStatus(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSSPI + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsspUnitInfo)) + { + retVal = Rssp2LnkStatus(destType, destId, logId, pUnifyInfo->GlobalVar->gpRsspUnitInfo); + } + +#endif + + return retVal; +} + +/* +* ܣRSSP2Эѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +*/ +UINT8 GetRssp2LnkStatus(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSSPII + retVal = RsspIILnkStatus(destType, destId, logId, pUnifyInfo->GlobalVar->gpRssp2UnitInfo); +#endif + + return retVal; +} + +/* +* ܣFSFBЭѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +*/ +UINT8 GetFsfbLnkStatus(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_FSFB + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpFsfbUnitInfo)) + { + retVal = FsfbProtclGetLnkStatus(destType, destId, pUnifyInfo->GlobalVar->gpFsfbUnitInfo); + } + +#endif + + return retVal; +} + +/*******************************************ɾ·Ӻʼ **********************************************/ + +/* +* ܣSFPЭɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* struc_Unify_Info *pSfpUnitInfo SFPͳһṹ +* ֵ +* 1ɾ·ɹ +* 0ɾ·ʧ +*/ +UINT8 SfpDelLnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_SFP + retVal = ProtclDeleteLnk(destType, destId, pUnifyInfo->GlobalVar->gpsfpUnitInfo); +#endif + + return retVal; +} + +/* +* ܣRpЭɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 1ɾ·ɹ +* 0ɾ·ʧ +*/ +UINT8 RpDelLnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RP + UINT16 destDevName = 0; + TypeIdToDevName(destType, destId, &destDevName); + retVal = RpLnkDelete(destDevName, pUnifyInfo->GlobalVar->gpRedunUnitInfo); +#endif + + return retVal; +} + +/* +* ܣRSRЭɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 1ɾ·ɹ +* 0ɾ·ʧ +*/ +UINT8 RsrDelLnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSR + UINT16 locDevName = 0; + UINT16 DestDevName = 0; + UINT16 rsspSrcAdd = 0; + INT16 bsdAdd = 0; + UINT16 destRsspAdd = 0; + RSR_INFO_STRU* gpRsrUnitInfo = pUnifyInfo->GlobalVar->gpRsrUnitInfo; + + TypeIdToDevName(gpRsrUnitInfo->LocalType, gpRsrUnitInfo->LocalID, &locDevName); + TypeIdToDevName(destType, destId, &DestDevName); + + if (destType == VOBC_TYPE) + { + retVal = dsuVOBCvsCIOutInfo(logId, 0, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + else if (gpRsrUnitInfo->LocalType == VOBC_TYPE) + { + retVal = dsuVOBCvsCIOutInfo(logId, 1, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + else + { + retVal = dsuZCvsCIOutInfo(locDevName, DestDevName, &rsspSrcAdd, &bsdAdd, &destRsspAdd); + } + if (1 == retVal) + { + retVal = RsrLnkDelete(rsspSrcAdd, bsdAdd, destRsspAdd, gpRsrUnitInfo); + } +#endif + + return retVal; +} + +/* +* ܣRSSPЭɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 1ɾ·ɹ +* 0ɾ·ʧ +*/ +UINT8 RsspDelLnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSSPI + retVal = Rssp2LnkDelete(destType, destId, logId, pUnifyInfo->GlobalVar->gpRsspUnitInfo); +#endif + + return retVal; +} + +/* +* ܣRSSP2Эɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 1ɾ·ɹ +* 0ɾ·ʧ +*/ +UINT8 Rssp2DelLnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSSPII + retVal = RsspIILnkDelete(destType, destId, logId, pUnifyInfo->GlobalVar->gpRssp2UnitInfo); +#endif + + return retVal; +} + +/* +* ܣFSFBЭɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ֵ +* 1ɾ·ɹ +* 0ɾ·ʧ +*/ +UINT8 FsfbDelLnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_FSFB + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpFsfbUnitInfo)) + { + retVal = FsfbProtclDeleteLnk(destType, destId, pUnifyInfo->GlobalVar->gpFsfbUnitInfo); + } + +#endif + + return retVal; +} + +/********************************************ˢ·غ*********************************************/ +/* +* ܣSFPˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* struc_Unify_Info *pSfpUnitInfo SFPͳһṹ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 SfpReFreshLnk(UINT16 slen_input, UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_SFP + if (NULL != pUnifyInfo->GlobalVar->gpsfpUnitInfo) + { + retVal = ProtclFreshLnkMngr(slen_input, pLnkStatusData, pUnifyInfo->GlobalVar->gpsfpUnitInfo); + } + else + { + retVal = 1; + } +#endif + + return retVal; +} + +/* +* ܣRPˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 RpReFreshLnk(UINT16 slen_input, UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RP + if (NULL != pUnifyInfo->GlobalVar->gpRedunUnitInfo) + { + retVal = RpRefresh(slen_input, pLnkStatusData, pUnifyInfo->GlobalVar->gpRedunUnitInfo); + } + else + { + retVal = 1; + + } +#endif + + return retVal; +} + +/* +* ܣRSRˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 RsrReFreshLnk(UINT16 slen_input, UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSR + if (NULL != pUnifyInfo->GlobalVar->gpRsrUnitInfo) + { + retVal = RsrRefresh(slen_input, pLnkStatusData, pUnifyInfo->GlobalVar->gpRsrUnitInfo); + } + else + { + retVal = 1; + + } +#endif + + return retVal; +} + +/* +* ܣRSSPˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 RsspReFreshLnk(UINT16 slen_input, UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSSPI + if (NULL != pUnifyInfo->GlobalVar->gpRsspUnitInfo) + { + retVal = Rssp2Refresh(slen_input, pLnkStatusData, pUnifyInfo->GlobalVar->gpRsspUnitInfo); + } + else + { + retVal = 1; + } +#endif + + return retVal; +} + +/* +* ܣRSSP2ˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 Rssp2ReFreshLnk(UINT16 slen_input, UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSSPII + if (NULL != pUnifyInfo->GlobalVar->gpRssp2UnitInfo) + { + retVal = RsspIIRefresh(slen_input, pLnkStatusData, pUnifyInfo->GlobalVar->gpRssp2UnitInfo); + } + else + { + retVal = 1; + } +#endif + + return retVal; +} + + +/* +* ܣFSFBˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 FsfbReFreshLnk(UINT16 slen_input, UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_FSFB + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpFsfbUnitInfo)) + { + retVal = FsfbProtclRefreshLnk(pLnkStatusData, pUnifyInfo->GlobalVar->gpFsfbUnitInfo); + } + +#endif + + return retVal; +} + +/********************************************ٿռغ*********************************************/ +/* +* SFPЭЭģ +* struc_Unify_Info *pSfpUnitInfo SFPͳһṹ +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 SfpFreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_SFP + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpsfpUnitInfo)) + { + retVal = ProtclFreeSpace(pUnifyInfo->GlobalVar->gpsfpUnitInfo); + } + else + { + retVal = 1; + } +#endif + + return retVal; +} + +/* +* RPЭЭģ +* +* +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 RpFreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RP + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRedunUnitInfo)) + { + retVal = RpFreeSpace(pUnifyInfo->GlobalVar->gpRedunUnitInfo); + } + else + { + retVal = 1; + } +#endif + + return retVal; +} + +/* +* RSRЭЭģ +* +* +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 RsrFreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSR + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsrUnitInfo)) + { + retVal = RsrFreeSpace(pUnifyInfo->GlobalVar->gpRsrUnitInfo); + } + else + { + retVal = 1; + } +#endif + + return retVal; +} + + +/* +* RSSPЭЭģ +* +* +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 RsspFreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSSPI + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsspUnitInfo)) + { + retVal = Rssp2FreeSpace(pUnifyInfo->GlobalVar->gpRsspUnitInfo); + } + else + { + retVal = 1; + } +#endif + + return retVal; +} +/* +* RSSP2ЭЭģ +* +* +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 Rssp2FreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_RSSPII + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRssp2UnitInfo)) + { + retVal = RsspIIFreeSpace(pUnifyInfo->GlobalVar->gpRssp2UnitInfo); + } + else + { + retVal = 1; + } +#endif + + return retVal; +} + +/* +* FSFBЭЭģ +* +* +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 FsfbFreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 0; + +#ifdef USE_FSFB + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpFsfbUnitInfo)) + { + retVal = FsfbProtclFreeSpace(pUnifyInfo->GlobalVar->gpFsfbUnitInfo); + } + +#endif + + return retVal; +} + + +/* +* ȫֱĿռ +* +* ProtclConfigInfoStru* pUnifyInfo ṹ +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 FreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retVal = 1; + UINT8 i = 0;/* ѭʹ */ + + if ((NULL!= pUnifyInfo)&&(NULL != pUnifyInfo->GlobalVar)&&(NULL != pUnifyInfo->GlobalVar->RcvData)) + { + for (i = 1; i < (PROTCL_MGECFG_MAXCNT + 1); i++) + { + if ((NULL != pUnifyInfo->GlobalVar->RcvData[i].pData)) + { + free((void*)pUnifyInfo->GlobalVar->RcvData[i].pData); + pUnifyInfo->GlobalVar->RcvData[i].pData = NULL; + } + } + free((void*)pUnifyInfo->GlobalVar->RcvData); + pUnifyInfo->GlobalVar->RcvData = NULL; + + + for (i = 0; i < (PROTCL_MGECFG_MAXCNT + 1); i++) + { + if (NULL != pUnifyInfo->GlobalVar->protclSndCfgStru[i].pProtclAppStru) + { + free((void*)pUnifyInfo->GlobalVar->protclSndCfgStru[i].pProtclAppStru); + pUnifyInfo->GlobalVar->protclSndCfgStru[i].pProtclAppStru = NULL; + } + } + free(pUnifyInfo->GlobalVar->RcvData); + pUnifyInfo->GlobalVar->RcvData = NULL; + free(pUnifyInfo->GlobalVar); + } + + + return retVal; +} + + + +/***********Getting**&**Setting****װ******************************************************/ + +/***********쳣**************************************************************/ +/** 㺯 +* Ҫںָ㡣 +* ֹ쳣ʹÿյĺָµIJ +**************************************************/ +UINT8 protcl_nul_Init(UINT8* nul_FileName, UINT32 inDataLen, UINT8 inData[], UINT8 nul_Num, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retval = 1; + + return retval; +} + +UINT8 protcl_nul_Snd(ProtclConfigInfoStru* pUnifyInfo, UINT8 devDataCount, UINT8* pSndData, UINT32* sendDataLen, UINT8* pLnkStatusData, UINT16* lnkDataLen, UINT8* recordArray, UINT16* recordDataLen) +{ + UINT8 retval = 1; + + return retval; +} + +UINT8 protcl_nul_Rcv(QueueStruct* PQueueStru, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retval = 1; + + return retval; +} + + +UINT8 protcl_nul_Lnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retval = 1; + + return retval; +} + +void protcl_nul_NetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ + if ((NULL != pUnifyInfo) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum)) + { + (*redRecvPkgNum) = 0u; + (*blueRecvPkgNum) = 0u; + } +} + +UINT8 protcl_nul_DelLnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retval = 1; + + return retval; +} + + +UINT8 protcl_nul_ReFreshLnk(UINT16 slen_input, UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retval = 1; + + return retval; +} + + +UINT8 protcl_nul_End(ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 retval = 1; + + return retval; +} + +/******************************************************************************************************* +* : Э鼰Э㶪崻Ϣ +* : ӦûȡvProtclErrorInfo +* : vProtclErrorInfo +* : vProtclErrorInfoϢ +* ȫֱ: +* ֵ: +*******************************************************************************************************/ + +UINT8 GetProtclErrorInfo(UINT32 vProtclErrorInfo[]) +{ + UINT8 index = 0, retval = 0; + +#ifdef USE_RP + vProtclErrorInfo[index++] = GetRpErrorInfo(); +#endif +#ifdef USE_RSR + vProtclErrorInfo[index++] = GetRsrErrorInfo(); +#endif + + retval = 1; + return retval; +} + + +/******************************************************************************************************* +* : Э鼰Э㶪ͷ崻븴λ +* : ӦûȡvProtclErrorInfo +* : vProtclErrorInfo +* : vProtclErrorInfo +* ȫֱ: +* ֵ: +*******************************************************************************************************/ + +UINT8 ReSetProtclErrorInfo(UINT32 vProtclErrorInfo[]) +{ + UINT8 ret = 1; +#ifdef USE_RP + ReSetRpErrorInfo(); +#endif +#ifdef USE_RSR + ReSetRsrErrorInfo(); +#endif + CommonMemSet(vProtclErrorInfo, sizeof(UINT32) * PRTCL_ERR_INFO_LEN, 0, sizeof(UINT32) * PRTCL_ERR_INFO_LEN); + return ret; +} +/******************************************************************************************************* +* : RSSPЭ޷Ӧӿں +* : +* : +* : gRsspErrorInfo +* ȫֱ: gRsspErrorInfo +* ֵ: 1:ɹ +*******************************************************************************************************/ + +UINT8 SetRsspConfigData(UINT8 vNoSendDataNum, ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 1; + +#ifdef USE_RSSPI + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsspUnitInfo)) + { + SetRsspNoSendAppData(vNoSendDataNum, pUnifyInfo->GlobalVar->gpRsspUnitInfo); + } + +#endif + + return ret; +} + +/* +*: TypeIdToDevName +*: IDת豸 +*: UINT8 type +* UINT8 id ID +*: +*: UINT16 *pDevName 豸 +*ֵ: +*/ +static void TypeIdToDevName(UINT8 type, UINT8 id, UINT16* pDevName) +{ + UINT16 devName = 0U; + devName = type; + *pDevName = ((UINT16)(devName << 8) & 0xFF00) | (id & 0x00FF); +} + +/* +*: ȡյ +*: ProtclConfigInfoStru* pUnifyInfo +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void GetNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ + UINT16 locTypeId = 0u; /*ID*/ + UINT16 oppTypeId = 0u; /*ԷID*/ + UINT8 protclType = 0u; /*Э*/ + UINT8 isGetProtclType = 0u; /*ǷȡЭ*/ + F_NETPKGNUM fNetsPkgNum = NULL; /*հ*/ + + if ((NULL != pUnifyInfo) && (NULL != pUnifyInfo->GlobalVar) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum)) /**/ + { + (*redRecvPkgNum) = 0u; + (*blueRecvPkgNum) = 0u; + TypeIdToDevName(pUnifyInfo->LocalType, pUnifyInfo->LocalID, &locTypeId); + TypeIdToDevName(dstType, dstId, &oppTypeId); + isGetProtclType = DsuProtclGetProtclType(locTypeId, oppTypeId, &protclType, &pUnifyInfo->GlobalVar->DsuProtclBookIpInfo); + + if ((1u == isGetProtclType) && (PROTCL_MGECFG_MAXCNT >= protclType) && (0u != protclType)) /*ȡЭ*/ + { + fNetsPkgNum = protclCfgStruBuff[protclType].fNetsRecvPkgNum; + if (NULL != fNetsPkgNum) + { + fNetsPkgNum(pUnifyInfo, dstType, dstId, dstLogicId, redRecvPkgNum, blueRecvPkgNum); + } + } + } +} + +/* +*: ȡSFPյ +*: ProtclConfigInfoStru* pUnifyInfo +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +static void GetSfpNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ +#ifdef USE_SFP + if ((NULL != pUnifyInfo) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpsfpUnitInfo)) /**/ + { + ProtclGetNetsRecvPkgNum(pUnifyInfo->GlobalVar->gpsfpUnitInfo, dstType, dstId, redRecvPkgNum, blueRecvPkgNum); + } +#endif +} + +/* +*: ȡRSSPIյ +*: ProtclConfigInfoStru* pUnifyInfo +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +static void GetRsspiNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ +#ifdef USE_RSSPI + if ((NULL != pUnifyInfo) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsspUnitInfo)) /**/ + { + RsspiGetNetsRecvPkgNum(pUnifyInfo->GlobalVar->gpRsspUnitInfo, dstType, dstId, dstLogicId, redRecvPkgNum, blueRecvPkgNum); + } +#endif +} + +/* +*: ȡRSSPIIյ +*: ProtclConfigInfoStru* pUnifyInfo +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +static void GetRsspiiNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ +#ifdef USE_RSSPII + if ((NULL != pUnifyInfo) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRssp2UnitInfo)) /**/ + { + RsspiiGetNetsRecvPkgNum(pUnifyInfo->GlobalVar->gpRssp2UnitInfo, dstType, dstId, dstLogicId, redRecvPkgNum, blueRecvPkgNum); + } +#endif +} + +/* +*: ȡFSFBյ +*: ProtclConfigInfoStru* pUnifyInfo +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +static void GetFsfbNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ +#ifdef USE_FSFB + if ((NULL != pUnifyInfo) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum) && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpFsfbUnitInfo)) /**/ + { + FsfbProtclGetNetsRecvPkgNum(pUnifyInfo->GlobalVar->gpFsfbUnitInfo, dstType, dstId, redRecvPkgNum, blueRecvPkgNum); + } +#endif +} + +/* +*: ʼ֡ӦõЭݽṹ--ֻܳʼʱʹ +*: const UINT16 outputSize Ӧ +* const UINT16 inputSize Ӧ +*: +*: +*ֵ: PROTCL_APP_TO_STRU* protclAppToStru ӦõЭݽṹ +*/ +static PROTCL_APP_TO_STRU* NewProtclAppToStru(const UINT16 outputSize, const UINT16 inputSize) +{ + PROTCL_APP_TO_STRU* protclAppToStru = NULL; /*ֵ*/ + + protclAppToStru = (PROTCL_APP_TO_STRU*)malloc(sizeof(PROTCL_APP_TO_STRU)); + if (NULL != protclAppToStru) + { + CommonMemSet(protclAppToStru, sizeof(PROTCL_APP_TO_STRU), 0u, sizeof(PROTCL_APP_TO_STRU)); + + protclAppToStru->pAppData = NewAppData(&protclAppToStru->appDataMaxLen, outputSize, inputSize); + if (NULL == protclAppToStru->pAppData) + { + protclAppToStru = NULL; + } + } + + return protclAppToStru; +} + + +/* +*: ɵ֡ӦõЭ--ֻܳʼʱʹ +*: const UINT16 outputSize Ӧ +* constUINT16 inputSize Ӧ +*: UINT16* appDataMaxLen ӦõЭ󳤶 +*: +*ֵ: UINT8* appData ӦõЭ +*/ +static UINT8* NewAppData(UINT16* appDataMaxLen, const UINT16 outputSize, const UINT16 inputSize) +{ + UINT8* appData = NULL; /*ֵ*/ + UINT32 mallocLen = 0u; /*ռ䳤*/ + + if (NULL != appDataMaxLen) + { + *appDataMaxLen = (outputSize > inputSize) ? outputSize : inputSize; + *appDataMaxLen += 44u; /*ʱټӸЭͷ*/ + mallocLen = sizeof(UINT8) * (*appDataMaxLen); + appData = (UINT8*)malloc(mallocLen); + if (NULL != appData) + { + CommonMemSet(appData, mallocLen, 0u, mallocLen); + } + else + { + appData = NULL; + } + } + + return appData; +} \ No newline at end of file diff --git a/TSCP/src/protocol/protocol_cbtc/common_protocol/ProtclManage.h b/TSCP/src/protocol/protocol_cbtc/common_protocol/ProtclManage.h new file mode 100644 index 0000000..fcb6d46 --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_protocol/ProtclManage.h @@ -0,0 +1,247 @@ +/* +* +* ļ ProtclManage.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.15 +* +* Э,ҪʵԵЭ顣 +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +*/ +#ifndef _PROTCL_MANAGE_H_ +#define _PROTCL_MANAGE_H_ + +#include "dquCbtcType.h" +#include "protclStruct.h" + +#ifdef USE_SFP +#include "sfpplatform.h" +#endif +#ifdef USE_RP +#include "RpPlatform.h" +#endif +#ifdef USE_RSSPI +#include "RsspWl.h" +#endif +#ifdef USE_RSR +#include "Rsr.h" +#endif + +#define LEN_IP_ADDR 4 /*IPַ*/ + +#define PROTCL_OUT_FONT_LEN 5 /* ֡ͷ */ +#define VAR_NODE_LEN 400 /* м */ +#define RSR_RSSP_MAX_LEN (2900) /*ZC-101450Ϊ2900*/ +#define RSSP2_MAX_LEN 1200 +#define FSFB_MAX_LEN (200) /*FSFBÿ֡Ӧ󳤶*/ + +#define SFP_PER_LNK_RECORD_MAX_LEN 96 /*SFPÿ·¼󳤶*/ +#define RP_PER_LNK_RECORD_MAX_LEN 68 /*RPÿ·¼󳤶*/ +#define RSR_PER_LNK_RECORD_MAX_LEN 194 /*RSRÿ·¼󳤶*/ +#define RSSPI_PER_LNK_RECORD_MAX_LEN 130 /*RSSPIÿ·¼󳤶*/ +#define RSSPII_PER_LNK_RECORD_MAX_LEN 158 /*RSSPIIÿ·¼󳤶*/ +#define FSFB_PER_LNK_RECORD_MAX_LEN 68 /*FSFBÿ·¼󳤶*/ + + +#define PRTCL_ERR_INFO_LEN 10 /* ЭС */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define ERR_PRTCL_MANAGE_TYPE_ERR 0x00000001 +#define ERR_PRTCL_MANAGE_DATA_ANALYSIS_ERR 0x00000002 + +/* + * Эʼ + * + */ +UINT8 Init(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], ProtclConfigInfoStru* pUnifyInfo); + +/* +* ܣЭ鷢 +* +* +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* UINT8 1 +*/ +UINT8 SendAppData(ProtclConfigInfoStru *pUnifyInfo); + +/* +* ܣЭ +* +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1ݳɹ +0ʧ +*/ + +UINT8 ReceiveAppData(ProtclConfigInfoStru* pUnifyInfo); + +/* +* ܣѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +* 0x33·׼״̬ +* 0x4e·ڵȴ״̬ +*/ +UINT8 GetLnkStatus (UINT8 destType,UINT8 destId,UINT16 logId,ProtclConfigInfoStru * pUnifyInfo); + +/* +* ܣɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1ɾ·ɹ +* 0ɾ·ʧ +*/ +UINT8 DelLnkFunc(UINT8 destType,UINT8 destId,UINT16 logId,ProtclConfigInfoStru *pUnifyInfo); + +/* +* ܣˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 ReFresh(UINT8 *pLnkStatusData, ProtclConfigInfoStru *pUnifyInfo); + +/* +* ЭЭģ +* +* ProtclConfigInfoStru *pUnifyInfo Эṹ +* ֵ +* 1 ٳɹ +* 0 ʧ +*/ +UINT8 FreeSpace(ProtclConfigInfoStru *pUnifyInfo); + +UINT8 ReceiveTcpState(UINT16 TcpStateDataLen,UINT8* pTcpStateData, ProtclConfigInfoStru *pUnifyInfo); +UINT8 SendTcpCtrl(UINT16 *pTcpCtrlDataLen,UINT8 *pTcpCtrlData, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 InitGetCfgInfo(UINT8* pFileName, UINT32 inDataLen, UINT8 inData[], UINT8* pEvenPrtclNumBuff, ProtclConfigInfoStru* pUnifyInfo); +/***********Э鷢غ**************************************************************/ +UINT8 AppSendInputDataAnalysis(QueueStruct *pAppQueueData,PROTCL_APP_TO_STRU *pProtclAppStru); +UINT8 sfpInputPackFms(const PROTCL_APP_TO_STRU protclAppStru, QueueStruct *pAppQueueData); +UINT8 sfpSendData(ProtclConfigInfoStru *pUnifyInfo, UINT8 devDataCount,UINT8* pSndData,UINT32* sendDataLen,UINT8 * pLnkStatusData,UINT16* lnkDataLen,UINT8* recordArray,UINT16* recordDataLen); +UINT8 RsspInputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct *pAppQueueData); +UINT8 RsspSendData(ProtclConfigInfoStru *pUnifyInfo, UINT8 devDataCount,UINT8* pSndData,UINT32* sendDataLen,UINT8* pLnkStatusData,UINT16* lnkDataLen,UINT8* recordArray,UINT16* recordDataLen); + +#ifdef USE_RSR +UINT8 RsrInputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct *pAppQueueData, RSR_INFO_STRU *gpRsrUnitInfo); +#endif + +UINT8 RsrSendData(ProtclConfigInfoStru *pUnifyInfo, UINT8 devDataCount,UINT8* pSndData,UINT32* sendDataLen,UINT8* pLnkStatusData,UINT16* lnkDataLen,UINT8* recordArray,UINT16* recordDataLen); +UINT8 RpInputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct *pAppQueueData); +UINT8 RpSendData(ProtclConfigInfoStru *pUnifyInfo, UINT8 devDataCount,UINT8* pSndData,UINT32* sendDataLen,UINT8* pLnkStatusData,UINT16* lnkDataLen,UINT8* recordArray,UINT16* recordDataLen); +UINT8 RsrAndRpAppArrayPage(UINT8* pInAppArray,UINT32 appDtaLen,UINT8* pOutAppArray,UINT32* outAppLen); +UINT8 Rssp2InputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct *pAppQueueData); +UINT8 Rssp2SendData(ProtclConfigInfoStru *pUnifyInfo, UINT8 devDataCount,UINT8* pSndData,UINT32* sendDataLen,UINT8* pLnkStatusData,UINT16* lnkDataLen,UINT8* recordArray,UINT16* recordDataLen); +UINT8 FsfbInputPackFms(PROTCL_APP_TO_STRU protclAppStru, QueueStruct* pAppQueueData); +UINT8 FsfbSendData(ProtclConfigInfoStru* pUnifyInfo, UINT8 devDataCount, UINT8* pSndData, UINT32* sendDataLen, UINT8* pLnkStatusData, UINT16* lnkDataLen, UINT8* recordArray, UINT16* recordDataLen); +/***********Эغ**************************************************************/ +UINT8 SfpRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru *pUnifyInfo); +UINT8 RpRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru *pUnifyInfo); +UINT8 RsrRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru *pUnifyInfo); +UINT8 RsspRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru *pUnifyInfo); +UINT8 SetDataToQue(UINT32 dataLen,UINT8 *buff,QueueStruct* q); +UINT8 AppReceiveDataAnalysis(QueueStruct *pAppQueueData,PROTCL_APP_TO_STRU *pProtclAppStru); +UINT8 readQueueDataToApp(QueueStruct *rcvQueueData, UINT8 OutNetFlag, UINT16 locDevName, PROTCL_RCV_DATA_TYPE* pDataToApp, ProtclConfigInfoStru *pUnifyInfo); +UINT8 RcvDataToAppQueue(UINT8 devType,UINT8 devId,UINT16 logId,UINT8 lifeTime,UINT16 appDatalen,UINT8* pAppData,QueueStruct* pDataToApp); +UINT8 Rssp2RcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru *pUnifyInfo); +UINT8 FsfbRcvData(QueueStruct* pOutToApp, ProtclConfigInfoStru* pUnifyInfo); +/***********Э·غ***********************************************************/ +UINT8 GetSfpLnkStatus (UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 GetRsrLnkStatus (UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 GetRsspLnkStatus (UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 GetRssp2LnkStatus (UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 GetFsfbLnkStatus(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo); + +/*******************************************ɾ·غ **********************************************/ + +UINT8 SfpDelLnk(UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 RpDelLnk(UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 RsrDelLnk(UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 RsspDelLnk(UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 Rssp2DelLnk(UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); + +UINT8 FsfbDelLnk(UINT8 destType, UINT8 destId, UINT16 logId, ProtclConfigInfoStru* pUnifyInfo); + +/*********************ˢ·غ***********************************************/ +UINT8 SfpReFreshLnk(UINT16 slen_input,UINT8 *pLnkStatusData, ProtclConfigInfoStru *pUnifyInfo); +UINT8 RpReFreshLnk(UINT16 slen_input,UINT8 *pLnkStatusData, ProtclConfigInfoStru *pUnifyInfo); +UINT8 RsrReFreshLnk( UINT16 slen_input,UINT8 *pLnkStatusData, ProtclConfigInfoStru *pUnifyInfo); +UINT8 RsspReFreshLnk(UINT16 slen_input,UINT8 *pLnkStatusData, ProtclConfigInfoStru *pUnifyInfo); +UINT8 Rssp2ReFreshLnk(UINT16 slen_input,UINT8 *pLnkStatusData, ProtclConfigInfoStru *pUnifyInfo); +UINT8 FsfbReFreshLnk(UINT16 slen_input, UINT8* pLnkStatusData, ProtclConfigInfoStru* pUnifyInfo); + +/********************************************ٿռغ*********************************************/ +UINT8 SfpFreeSpaceFunc(ProtclConfigInfoStru *pUnifyInfo); +UINT8 RpFreeSpaceFunc(ProtclConfigInfoStru *pUnifyInfo); +UINT8 RsrFreeSpaceFunc(ProtclConfigInfoStru *pUnifyInfo); +UINT8 RsspFreeSpaceFunc(ProtclConfigInfoStru *pUnifyInfo); +UINT8 Rssp2FreeSpaceFunc(ProtclConfigInfoStru *pUnifyInfo); +UINT8 FreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo); +UINT8 FsfbFreeSpaceFunc(ProtclConfigInfoStru* pUnifyInfo); + +/***********Getting**&**Setting****װ***********************************************/ + +/***********쳣**************************************************************/ +UINT8 protcl_nul_Init(UINT8* nul_FileName, UINT32 inDataLen, UINT8 inData[], UINT8 nul_Num, ProtclConfigInfoStru* pUnifyInfo); +UINT8 protcl_nul_Snd(ProtclConfigInfoStru *pUnifyInfo, UINT8 devDataCount,UINT8* pSndData,UINT32* sendDataLen,UINT8 * pLnkStatusData,UINT16* lnkDataLen,UINT8* recordArray,UINT16* recordDataLen); +UINT8 protcl_nul_Rcv(QueueStruct* PQueueStru, ProtclConfigInfoStru *pUnifyInfo); +UINT8 protcl_nul_Lnk(UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); +void protcl_nul_NetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); +UINT8 protcl_nul_DelLnk(UINT8 destType,UINT8 destId,UINT16 logId, ProtclConfigInfoStru *pUnifyInfo); +UINT8 protcl_nul_ReFreshLnk(UINT16 slen_input,UINT8 *pLnkStatusData, ProtclConfigInfoStru *pUnifyInfo); +UINT8 protcl_nul_End(ProtclConfigInfoStru *pUnifyInfo); + +UINT8 GetProtclErrorInfo(UINT32 vProtclErrorInfo[]); +UINT8 ReSetProtclErrorInfo(UINT32 vProtclErrorInfo[]); + +UINT8 SetRsspConfigData(UINT8 vNoSendDataNum, ProtclConfigInfoStru *pUnifyInfo); + +/* +*: ȡյ +*: ProtclConfigInfoStru* pUnifyInfo +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void GetNetsRecvPkgNum(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/protocol_cbtc/common_protocol/protclInterFun.c b/TSCP/src/protocol/protocol_cbtc/common_protocol/protclInterFun.c new file mode 100644 index 0000000..80c7f0e --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_protocol/protclInterFun.c @@ -0,0 +1,1549 @@ +#include "protclInterFun.h" +#include "ProtclManage.h" +#include "Convert.h" +#include "protclMgeCfg.h" +#include "dsuRsspFunc.h" +#include "CommonMemory.h" +#include "CommonRecord.h" + +#define RSSPI_OPP_IDS_NUM (255) /*RSSPIĶԷΨһID*/ + +#define DEV_LEN_ILLEGAL (2u) /*DevDataFormatCheck豸ݳȷǷ*/ +#define DEV_IDX_ILLEGAL (3u) /*DevDataFormatCheck豸±Ƿ*/ +#define DATA_IDX_ILLEGAL (4u) /*RepeatDataFormatCheck±Ƿ*/ +#define DEV_SFP_LEN_ILLEGAL (5u) /*RepeatValCheck豸SFPݳȷǷ*/ +#define DEV_RSSPI_FSFB_LEN_ILLEGAL (6u) /*RepeatValCheck豸RSSPI-FSFBݳȷǷ*/ +#define DEV_RSSPII_LEN_ILLEGAL (7u) /*RepeatValCheck豸RSSPIIݳȷǷ*/ +#define DATA1_NET_LEN_ILLEGAL (8u) /*RepeatCheckSetһݳȷǷ*/ +#define DATA2_STAGING_NO_SPACE (9u) /*RepeatCheckSetݴ޿ռ*/ +#define DATA2_IDX_ILLEGAL (10u) /*TwoDevRepeat±Ƿ*/ +#define DATA2_DEV_LEN_ILLEGAL (11u) /*TwoDevRepeat豸ݳȷǷ*/ +#define DATA1_IDX_ILLEGAL (12u) /*TwoDevRepeatһλ÷Ƿ*/ +#define DATA2STAGING_NET_ILLEGAL (13u) /*TwoNetRepeatݴȷǷ*/ +#define DATA2_NET_IDX_ILLEGAL (14u) /*TwoRepeat±Ƿ*/ +#define DATA2STAGING_COPY_ILLEGAL (15u) /*TwoRepeatݴ渳ֵݳȷǷ*/ +#define NET_LEN_ILLEGAL (16u) /*DevDataFormatCheckݳȷǷ*/ +#define NET2_LEN_ILLEGAL (17u) /*TwoNetRepeat2ݳȷǷ*/ +#define NET1_LEN_ILLEGAL (18u) /*TwoDevRepeat1ݳȷǷ*/ +#define DATA2_STAGING_NO (19u) /*TwoDevRepeatݴ޿ռ*/ +#define NO_DATA_NET1_LEN_ILLEGAL (20u) /*TwoDevRepeat1ʱݳȷǷ*/ + +static UINT16 DelRsspiNotOppId(UINT16 linkDataLen, UINT8 linkData[], UINT16 singleLinkLen, UINT16 oppIdIdx, UINT8 oppIdsNum, const UINT32 oppIds[]); + +static UINT8 ProtclTwoRepeatParam(ProtclConfigInfoStru* protcl, UINT8* data1, UINT8* data2, UINT32* data2Len, UINT8* data2Staging); +static UINT8 RepeatDataFormatCheck(UINT8* data, const UINT32 dataLen); +static UINT8 DevDataFormatCheck(UINT8* data, const UINT32 dataLen, UINT32* dataIdx, UINT32* netLen); +static UINT8 TwoRepeat(ProtclConfigInfoStru* protcl, UINT8* data1, const UINT32 data1Len, UINT8* data2, UINT32* data2Len, UINT8* data2Staging, const UINT32 data2StagingMaxLen); +static UINT8 RepeatDataNetFormatCheck(UINT8* data, const UINT32 dataLen, const UINT32 netDataIdx, UINT32* netLen); +static UINT8 TwoNetRepeat(ProtclConfigInfoStru* protcl, UINT8* data1, UINT32* data1Idx, const UINT32 data1Len, UINT8* data2, UINT32* data2Idx, const UINT32 data2Len, UINT8* data2Staging, UINT32* data2StagingIdx, const UINT32 data2StagingMaxLen); +static UINT8 TwoNetRepeatParam(ProtclConfigInfoStru* protcl, UINT8* data1, UINT32* data1Idx, UINT8* data2, UINT32* data2Idx, UINT8* data2Staging, UINT32* data2StagingIdx); +static UINT8 TwoDevRepeat(ProtclConfigInfoStru* protcl, UINT8* data1, const UINT32 data1IdxNet, UINT32* data1Idx, const UINT32 data1Len, UINT8* data2, UINT32* data2Idx, const UINT32 data2Len, UINT32* net2Idx, const UINT32 net2Len, UINT8* data2Staging, UINT32* data2StagingIdx, const UINT32 data2StagingMaxLen); +static UINT8 TwoDevRepeatParam(ProtclConfigInfoStru* protcl, UINT8* data1, UINT32* data1Idx, UINT8* data2, UINT32* data2Idx, UINT32* net2Idx, UINT8* data2Staging, UINT32* data2StagingIdx); +static UINT8 RepeatCheck(const UINT8 dev2OppTypePtl, const UINT32 dev2UniqueId, UINT8* dev2Data, const UINT16 dev2Len, UINT8* data1, UINT32* data1Idx, const UINT32 data1Len, const UINT32 data1IdxNet, UINT32* net1Idx, const UINT32 net1Len, UINT8* data2Staging, UINT32* data2StagingIdx, const UINT32 data2StagingMaxLen); +static UINT8 RepeatCheckParam(UINT8* dev2Data, UINT8* data1, UINT32* data1Idx, UINT32* net1Idx, UINT8* data2Staging, UINT32* data2StagingIdx); +static UINT8 RepeatCheckSet(UINT8 isRepeat, UINT8 isFirst, UINT8* dev2Data, UINT16 dev2Len, UINT32* data1Idx, UINT32 net1Idx, UINT32 net1Len, UINT8* data2Staging, UINT32* data2StagingIdx, const UINT32 data2StagingMaxLen); +static UINT8 RepeatDataCheck(UINT8* isRepeat, UINT8 dev2OppTypePtl, UINT32 dev2UniqueId, UINT8* dev2Data, UINT16 dev2Len, UINT8* data1, UINT32 data1IdxNet, const UINT32 data1Len, UINT32* net1Idx, UINT32 net1Len); +static UINT8 RepeatDataCheckParam(UINT8* isRepeat, UINT8* dev2Data, UINT8* data1, UINT32* net1Idx); +static UINT8 RepeatValCheck(UINT8* isRepeat, UINT8 dev2OppTypePtl, UINT8* dev2Data, UINT16 devLen, UINT8* data1, UINT32 data1Idx, const UINT32 data1MaxLen); +static UINT8 RepeatValCheckParam(UINT8* isRepeat, UINT8* devData, UINT16 devLen, UINT8* data1, UINT32 data1Idx, const UINT32 data1MaxLen); + +/* +* Эʼģ +* +* char* fileName ݵĵַ +* UINT32 inDataLen ڲ +* UINT8 inData[] ڲ +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1 ʼɹ +* 0: ʼʧ +*/ +UINT8 ProtclInitFunc(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], ProtclConfigInfoStru* pUnifyInfo) +{ + UINT8 ret = 0; + + if ((NULL != pUnifyInfo) && (NULL != fileName)) + { + ret = Init(fileName, inDataLen, inData, pUnifyInfo); + } + + return ret; +} + +/* +*: ProtclEndFunc +*: Э +*: ProtclConfigInfoStru *pUnifyInfo Эͳһṹ +*: +*: +*ֵ: 1;ٳɹ,0:ʧ +*/ +UINT8 ProtclEndFunc(ProtclConfigInfoStru *pUnifyInfo) +{ + UINT8 ret = 0; + if (NULL != pUnifyInfo) + { + ret = FreeSpace(pUnifyInfo); + } + + + return ret; +} + +/* +* ܣЭ鷢 +* +* +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* UINT8 1 +*/ + +UINT8 ProtclSendDataFunc(ProtclConfigInfoStru * pUnifyInfo) +{ + UINT8 ret =0; + if (NULL != pUnifyInfo) + { + if ((pUnifyInfo->AppArray != NULL) && (pUnifyInfo->VarArray != NULL)) + { + ret = SendAppData(pUnifyInfo); + } + else + { + ret = 0; + } + } + else + { + ret = 0; + } + return ret; +} + +/* +* ܣЭ +* +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1ݳɹ +0ʧ +*/ + +UINT8 ProtclReceiveDataFunc (ProtclConfigInfoStru * pUnifyInfo) +{ + UINT8 ret =0; + + if (pUnifyInfo != NULL) + { + ret = ReceiveAppData(pUnifyInfo); + } + else + { + ret=0; + } + + return ret; +} + +/* +* ܣѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +* 0x33·׼״̬ +* 0x4e·ڵȴ״̬ +* 0x01: ʾˢõ· +*/ +UINT8 ProtclGetLnkStatus (UINT8 destType,UINT8 destId,UINT16 logId,ProtclConfigInfoStru * pUnifyInfo) +{ + UINT8 ret =0; + if (NULL!=pUnifyInfo) + { + ret = GetLnkStatus(destType,destId,logId,pUnifyInfo); + } + + return ret; +} + + +/* +* ܣɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ̬ID +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* UINT8 1 ɾɹ +* 0 ɾʧ +*/ + +UINT8 ProtclDeleteLnkFunc(UINT8 DestType,UINT8 DestID,UINT16 logId,ProtclConfigInfoStru * pUnifyInfo) +{ + UINT8 retnVal =0; + + if (NULL!= pUnifyInfo) + { + retnVal = DelLnkFunc(DestType, DestID, logId, pUnifyInfo); + } + + return retnVal; +} + + +/* +* ܣˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 ProtclReFreshFunc(UINT8* pLnkStatusData, ProtclConfigInfoStru *pUnifyInfo) +{ + UINT8 retVal =0; + if ((NULL != pLnkStatusData) && (NULL != pUnifyInfo)) + { + retVal = ReFresh(pLnkStatusData, pUnifyInfo); + } + + return retVal; +} + +/************************************************************************ +ܣЭTCP·״̬Ϣ +: ûҪÿڵҽһα,ΪЭTCP·״̬Ϣ + ע⣬ȵЭպProtclReceiveDataFunc()ñ + ܵ±ڵЭպ޷ȷ»ΪδȷAU1 + Ϣ½ʱӳ + + UINT16 TcpStateDataLen, TCP״̬Ϣֽ + UINT8* pTcpStateData TCP״̬Ϣ +ֵ0ʧ 1ɹ +************************************************************************/ +UINT8 ProtclReceiveTcpStateFunc(UINT16 TcpStateDataLen,UINT8* pTcpStateData, ProtclConfigInfoStru *pUnifyInfo) +{ + UINT8 ret =0; + if ((NULL!= pTcpStateData)&&(NULL!= pUnifyInfo)) + { + ret = ReceiveTcpState(TcpStateDataLen, pTcpStateData, pUnifyInfo); + } + + return ret; +} + +/************************************************************************ +ܣЭTCP·Ϣ +ʹTCPͨţRSSP2Э飩ʱûҪÿڵҽһα, + ȡЭTCP·ϢϢ͸ת2ͨſ + ע⣬ͨſTCP·Ϣͨűġ +: + UINT16 *pTcpCtrlDataLen, TCPϢֽ + UINT8 *pTcpCtrlData TCPϢ +ֵ +************************************************************************/ +UINT8 ProtclSendTcpCtrlFunc(UINT16 *pTcpCtrlDataLen,UINT8 *pTcpCtrlData, ProtclConfigInfoStru *pUnifyInfo) +{ + UINT8 ret = 0; + if ((NULL != pTcpCtrlDataLen)&&(NULL!= pTcpCtrlData)&&(NULL!= pUnifyInfo)) + { + ret = SendTcpCtrl(pTcpCtrlDataLen, pTcpCtrlData, pUnifyInfo); + } + + return ret; +} + +/* +*: DelRsspiNotOppId +*: ɾRSSPI·зָĶԷַ· +*: UINT16 linkDataLen ·ݳ +* UINT8 linkData[] · +* UINT16 singleLinkLen · +* UINT16 oppIdIdx ԷΨһID·λ +* UINT8 oppIdsNum ԷΨһID +* const UINT32 oppIds[] ԷΨһID +*: +*: +*ֵ: UINT16 aftLinkDataLen ·ݳ +*/ +static UINT16 DelRsspiNotOppId(UINT16 linkDataLen, UINT8 linkData[], UINT16 singleLinkLen, UINT16 oppIdIdx, UINT8 oppIdsNum, const UINT32 oppIds[]) +{ + UINT16 aftLinkDataLen = linkDataLen; /*·ݳ*/ + UINT16 i = 0; /*ѭ*/ + UINT16 j = 0; /*ѭ*/ + UINT16 linkNum = linkDataLen / singleLinkLen; /*ĵ·*/ + UINT32 oppIdLink = 0; /*·ϢжԷΨһID*/ + UINT16 curIdx = 0; /*ǰ·±λ*/ + + if (( NULL != linkData)&&( NULL != oppIds)) + { + for (i = 0; i < linkNum; i++) /*·Ϣ*/ + { + oppIdLink = LongFromChar(&linkData[curIdx + oppIdIdx]); /*·жԷΨһID*/ + for (j = 0; j < oppIdsNum; j++) + { + if (oppIds[j] == oppIdLink) /*ҵ˳ѭ*/ + { + break; + } + } + if (j == oppIdsNum) /*δҵ,ɾ˶ԷΨһID·*/ + { + if (i < (linkNum - 1)) /*һ,ƶ·Ϣ*/ + { + CommonMemCpy(&linkData[curIdx], linkDataLen - (singleLinkLen * (i + 1)), &linkData[curIdx + singleLinkLen], linkDataLen - (singleLinkLen * (i + 1))); + } + aftLinkDataLen -= singleLinkLen; /*󳤶*/ + } + else + { + curIdx += singleLinkLen; /*±ƫһ·*/ + } + } + + } + + return aftLinkDataLen; +} + +/* +*: AdjustRsspiVarArray +*: RSSPI·,ָֻĶԷַ· +*: UINT8 oppIdsNum ԷID߼ID +* const UINT16 oppTypeIds[] ԷID +* const UINT16 oppLogicIds[] Է߼ID +* ProtclConfigInfoStru *pUnifyInfo ṹ +*: +*: +*ֵ: +*/ +void AdjustRsspiVarArray(UINT8 oppIdsNum, const UINT16 oppTypeIds[], const UINT16 oppLogicIds[], ProtclConfigInfoStru *pUnifyInfo) +{ + const UINT16 oppIdSafeIdx = 7; /*ԷΨһIDڰȫλ*/ + const UINT16 oppIdRedundIdx = 0; /*ԷΨһIDλ*/ + + UINT32 oppIds[RSSPI_OPP_IDS_NUM] = { 0 }; /*ԷΨһID*/ + UINT32 i = 0; /*ѭ*/ + UINT8 *linkData = NULL; /*·Ϣ*/ + UINT16 totalLen = 0; /*·ܳ*/ + UINT16 curIdx = 0; /*ǰ·±λ*/ + UINT32 curProtcl = 1; /*ǰЭʶ*/ + UINT16 curLen = 0; /*ǰЭ·*/ + UINT16 curLenIdx = 0; /*ǰЭ·λ*/ + UINT16 safeLen = 0; /*RSSPIȫ·*/ + UINT16 safeLenIdx = 0; /*RSSPIȫ·λ*/ + UINT16 aftSafeLen = 0; /*RSSPIȫ·*/ + UINT16 redundLen = 0; /*RSSPI·*/ + UINT16 redundLenIdx = 0; /*RSSPI·λ*/ + UINT16 aftRedundLen = 0; /*RSSPI·*/ + UINT8 isAdjustRear = 0; /*Ƿβ*/ + +#ifdef USE_RSSPI + if ((0 < oppIdsNum) && (RSSPI_OPP_IDS_NUM > oppIdsNum) && (NULL != oppTypeIds) && (NULL != oppLogicIds) && (NULL != pUnifyInfo) && (NULL != pUnifyInfo->VarArray) + && (NULL != pUnifyInfo->GlobalVar) && (NULL != pUnifyInfo->GlobalVar->gpRsspUnitInfo) && (NULL != pUnifyInfo->GlobalVar->gpRsspUnitInfo->pDsuRsspInfoStruWL)) /**/ + { + for (i = 0; i < oppIdsNum; i++) /*ȡRSSPIԷΨһID*/ + { +#ifdef RSSP_NO_HLHT + oppIds[i] = oppTypeIds[i]; +#else + oppIds[i] = DquTypeIdToHlhtId(oppTypeIds[i], oppLogicIds[i], pUnifyInfo->GlobalVar->gpRsspUnitInfo->pDsuRsspInfoStruWL); /*ԷΨһID*/ +#endif + } + + linkData = pUnifyInfo->VarArray; /*·Ϣ*/ + /*·ܳ*/ + totalLen = 2 + ShortFromChar(linkData); + curIdx += 2; + + for (curProtcl = 1; curProtcl <= PROTCL_MGECFG_MAXCNT; curProtcl++) /*Э*/ + { + /*ǰ·±λ*/ + curLen = ShortFromChar(&linkData[curIdx]); + curLenIdx = curIdx; + curIdx += 2; + + if ((curIdx + curLen) <= totalLen) /*Э·Ч*/ + { + if ((DSU_PROTCL_RSSP == curProtcl) && (2 < curLen)) /*ǰRSSPIЭ,·Ϣ*/ + { + safeLen = ShortFromChar(&linkData[curIdx]); /*ȫ·*/ + if (((2 + safeLen) <= curLen) && (0 == (safeLen%RSSP_VAR_NODE_LEN_WL))) /*ȫ·Ч*/ + { + safeLenIdx = curIdx; /*ȫ·λ*/ + curIdx += 2; + + if (0 < safeLen) /*аȫ·Ϣ*/ + { + aftSafeLen = DelRsspiNotOppId(safeLen, &linkData[curIdx], RSSP_VAR_NODE_LEN_WL, oppIdSafeIdx, oppIdsNum, oppIds); + } + + redundLenIdx = curIdx + safeLen; + redundLen = curLen - 2 - safeLen; + if ((0 < redundLen) && (0 == (redundLen % RP_LINK_LEN))) + { + aftRedundLen = DelRsspiNotOppId(redundLen, &linkData[redundLenIdx], RP_LINK_LEN, oppIdRedundIdx, oppIdsNum, oppIds); + } + + if ((aftSafeLen <= safeLen) && (aftRedundLen <= redundLen)) /*󳤶Ч*/ + { + curIdx += aftSafeLen; /*㿪ʼλ*/ + if (aftSafeLen < safeLen) /*ȫ*/ + { + CommonMemCpy(&linkData[curIdx], aftRedundLen, &linkData[redundLenIdx], aftRedundLen); /**/ + ShortToChar(aftSafeLen, &linkData[safeLenIdx]); /*ôİȫ㳤*/ + isAdjustRear = 1; + } + else + { + if (aftRedundLen < redundLen) /**/ + { + isAdjustRear = 1; + } + } + curIdx += aftRedundLen; /*βݿʼλ*/ + if (1 == isAdjustRear) /*β*/ + { + CommonMemCpy(&linkData[curIdx], totalLen - curLenIdx - 2 - curLen, &linkData[curLenIdx + 2 + curLen], totalLen - curLenIdx - 2 - curLen); /*β*/ + ShortToChar(2 + aftSafeLen + aftRedundLen, &linkData[curLenIdx]); /*ôRSSPI·*/ + ShortToChar(totalLen - 2 - (safeLen - aftSafeLen) - (redundLen - aftRedundLen), linkData); /*·ܳ*/ + } + } + } + + break; /*ҵRSSPI·˳ѭ*/ + } + else /*RSSPIЭѭ*/ + { + curIdx += curLen; + } + } + else /*Э·Ч,˳ѭ*/ + { + break; + } + } + } +#endif +} + +/* +*: ȡյ +*: ProtclConfigInfoStru* pUnifyInfo +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void ProtclGetNetsRecvPkgNumFunc(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ + if ((NULL != pUnifyInfo) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum)) /**/ + { + GetNetsRecvPkgNum(pUnifyInfo, dstType, dstId, dstLogicId, redRecvPkgNum, blueRecvPkgNum); + } +} + +/* +*: ProtclGetSwapData +*: ȡ˫CPU +*: UINT8 swapData[] 2ֽܳ+SFP(2ֽڳ+N[4ֽCRC])+RSSPI(2ֽڳ+N[4ֽSVC]) ռ2046 +* const UINT16 swapDataMaxLen 󳤶 2046 +* ProtclConfigInfoStru* protcl Эṹ +*: +*: +*ֵ: +*/ +void ProtclGetSwapData(UINT8 swapData[], const UINT16 swapDataMaxLen, ProtclConfigInfoStru* protcl) +{ + UINT16 swapDataLen = 0u; /*ݳ*/ + UINT8* record = NULL; /*־*/ + UINT16 recordSize = 0u; /*־鳤*/ + + if ((NULL != swapData) && (NULL != protcl) && (NULL != protcl->GlobalVar) && (2u < swapDataMaxLen)) /*ǿռ*/ + { + record = protcl->RecordArray; + recordSize = protcl->RecordArraySize; + PrintRecArrayByte(record, recordSize, 0xD1u); + + ShortToChar(0u, &swapData[0]); /*ܳ*/ + +#ifdef USE_SFP + SfpGetSwapData(&swapData[2], swapDataMaxLen, protcl->GlobalVar->gpsfpUnitInfo); +#else + ShortToChar(0u, &swapData[2]); /*Ϊ0*/ +#endif + swapDataLen = 2u + 2u + ShortFromChar(&swapData[2]); /*ۼSFP,rsspiʼλ*/ + if (swapDataLen < swapDataMaxLen) /*пռ*/ + { +#ifdef USE_RSSPI + RsspiGetSwapData(&swapData[swapDataLen], swapDataMaxLen - swapDataLen, protcl->GlobalVar->gpRsspUnitInfo); +#else + ShortToChar(0u, &swapData[swapDataLen]); /*Ϊ0*/ +#endif + swapDataLen += (2u + ShortFromChar(&swapData[swapDataLen])); /*ۼRSSPI*/ + + ShortToChar(swapDataLen - 2u, &swapData[0]); /*ܳ*/ + } + else /*޿ռ*/ + { + PrintRecArrayByte(record, recordSize, 1u); + PrintRecArray2ByteB(record, recordSize, swapDataLen); + PrintRecArray2ByteB(record, recordSize, swapDataMaxLen); + } + } +} + +/* +*: ProtclSetSwapData +*: ˫CPU +*: UINT8 swapData[] 2ֽܳ+SFP(2ֽڳ+N[4ֽCRC])+RSSPI(2ֽڳ+N[4ֽSVC]) +* ProtclConfigInfoStru* protcl Эṹ +*: +*: +*ֵ: +*/ +void ProtclSetSwapData(UINT8 swapData[], ProtclConfigInfoStru* protcl) +{ + UINT16 swapDataLen = 0u; /*ݳ*/ + UINT32 allLen = 0u; /*ܳ*/ + UINT32 outAppIdx = 0u; /*Ӧλ*/ + UINT8* outAppData = NULL; /*Ӧ*/ + UINT16 pkgLen = 0u; /**/ + UINT8 protclType = 0u; /*Э*/ + UINT16 sfpLen = 0u; /*SFP*/ + UINT16 rsspiLen = 0u; /*RSSPI*/ + UINT16 sfpStartIdx = 0u; /*SFPʼλ*/ + UINT16 rsspiStartIdx = 0u; /*RSSPIʼλ*/ + UINT8 isProSfp = 0u; /*ǷSFP*/ + UINT8 isProRsspi = 0u; /*ǷRSSPI*/ + UINT8* record = NULL; /*־*/ + UINT16 recordSize = 0u; /*־鳤*/ + + if ((NULL != swapData) && (NULL != protcl) && (NULL != protcl->GlobalVar)) + { + record = protcl->RecordArray; + recordSize = protcl->RecordArraySize; + PrintRecArrayByte(record, recordSize, 0xD2u); + + swapDataLen = ShortFromChar(&swapData[0]); /*ܳ*/ + + sfpStartIdx = 2u; /*RSSPIʼλ*/ + sfpLen = ShortFromChar(&swapData[2]); + rsspiStartIdx = 2u + sfpStartIdx + sfpLen; /*RSSPIʼλ*/ + rsspiLen = ShortFromChar(&swapData[rsspiStartIdx]); + if (((2u + sfpLen + 2u + rsspiLen) == swapDataLen) && (0u == (sfpLen % 4u)) && (0u == (rsspiLen % 4u))) /*ȼ*/ + { + /*AppArray:4ֽܳ+|&2ֽڳ+1ֽЭ+1ֽĿ+1ֽĿID+2ֽԤ+Ϸ(Э)*/ + allLen = LongFromChar(&protcl->AppArray[0]); + if (0u < allLen) /**/ + { + outAppData = &protcl->AppArray[4]; + while (outAppIdx < allLen) /*Ӧ*/ + { + pkgLen = 2u + ShortFromChar(&outAppData[outAppIdx]); + if ((outAppIdx + pkgLen) <= allLen) /*ǰӦλüӳСڵӦó,Ϸ*/ + { + protclType = outAppData[outAppIdx + 2u]; /*Э*/ + if ((DSU_PROTCL_SFP == protclType) || (DSU_PROTCL_RSSP == protclType)) /*SFPRSSPI*/ + { + if (DSU_PROTCL_SFP == protclType) /*SFP*/ + { + if (0u == isProSfp) /*ֻһ,,SFPһ*/ + { +#ifdef USE_SFP + SfpSetSwapDataForOut(&swapData[sfpStartIdx], &outAppData[outAppIdx], protcl->GlobalVar->gpsfpUnitInfo); +#endif + isProSfp = 1u; + } + } + else /*RSSPI*/ + { + if (0u == isProRsspi) /*ֻһ,,RSSPIһ*/ + { +#ifdef USE_RSSPI + RsspiSetSwapDataForOut(&swapData[rsspiStartIdx], &outAppData[outAppIdx], protcl->GlobalVar->gpRsspUnitInfo); +#endif + isProRsspi = 1u; + } + } + } + + outAppIdx += pkgLen; + } + else /*ȷǷ*/ + { + PrintRecArrayByte(record, recordSize, 3u); + PrintRecArray2ByteB(record, recordSize, pkgLen); + PrintRecArray4ByteB(record, recordSize, outAppIdx); + PrintRecArray4ByteB(record, recordSize, allLen); + + break; + } + } + } + else /**/ + { + PrintRecArrayByte(record, recordSize, 2u); + PrintRecArrayByte(record, recordSize, 0u); + } + } + else /*ȼ*/ + { + PrintRecArrayByte(record, recordSize, 1u); + PrintRecArray2ByteB(record, recordSize, swapDataLen); + PrintRecArray2ByteB(record, recordSize, sfpLen); + PrintRecArray2ByteB(record, recordSize, rsspiLen); + } + } +} + +/* +*: ProtclDelAllLink +*: ɾ· +*: ProtclConfigInfoStru* protcl Эṹ +*: +*: +*ֵ: +*/ +void ProtclDelAllLink(ProtclConfigInfoStru* protcl) +{ + if ((NULL != protcl) && (NULL != protcl->GlobalVar)) /**/ + { +#ifdef USE_SFP + SfpDelAllLink(protcl->GlobalVar->gpsfpUnitInfo); +#endif +#ifdef USE_RSSPI + RsspiDelAllLink(protcl->GlobalVar->gpRsspUnitInfo); +#endif + } +} + +/* +*: ProtclTwoRepeat +*: ݱȽȥظ(жȥе,Ա) +*: +* ProtclConfigInfoStru* protcl Эṹ +* UINT8* data1 һ(ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* const UINT32 data1Len һݳ +* UINT8* data2Staging ݴ +* const UINT32 data2StagingMaxLen ݴ󳤶 +*: +* UINT8* data2 (ʽ:ͬ) +* UINT32* data2Len ݳ +*: +*ֵ: ɹ:1 ʧ:0 +*/ +UINT8 ProtclTwoRepeat(ProtclConfigInfoStru* protcl, UINT8* data1, const UINT32 data1Len, UINT8* data2, UINT32* data2Len, UINT8* data2Staging, const UINT32 data2StagingMaxLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT8 funRtn = 0u; /*úֵ*/ + + funRtn = ProtclTwoRepeatParam(protcl, data1, data2, data2Len, data2Staging); + if (1u == funRtn) /*ú*/ + { + if ((0u == data1Len) && (0u == *data2Len)) /**/ + { + rtnVal = 1u; + } + else if ((0u < data1Len) && (0u == *data2Len)) /*һ,*/ + { + rtnVal = RepeatDataFormatCheck(data1, data1Len); + } + else if ((0u == data1Len) && (0u < *data2Len)) /*һ,*/ + { + rtnVal = RepeatDataFormatCheck(data2, *data2Len); + } + else /*һ,*/ + { + rtnVal = TwoRepeat(protcl, data1, data1Len, data2, data2Len, data2Staging, data2StagingMaxLen); + } + } + + return rtnVal; +} + +/* +*: ProtclTwoRepeatParam +*: ݱȽȥظݺ +*: +* ProtclConfigInfoStru* protcl Эṹ +* UINT8* data1 һ(ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* UINT8* data2Staging ݴ +*: +* UINT8* data2 (ʽ:ͬ) +* UINT32* data2Len ݳ +*: +*ֵ: ɹ:1 ʧ:0 +*/ +static UINT8 ProtclTwoRepeatParam(ProtclConfigInfoStru* protcl, UINT8* data1, UINT8* data2, UINT32* data2Len, UINT8* data2Staging) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + + if ((NULL != protcl) && (NULL != data1) && (NULL != data2) && (NULL != data2Len) && (NULL != data2Staging)) /**/ + { + rtnVal = 1u; + } + + return rtnVal; +} + +/* +*: RepeatDataFormatCheck +*: ҪȽȥصݸʽ +*: +* UINT8* data (ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* const UINT32 dataLen ݳ +*: +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 RepeatDataFormatCheck(UINT8* data, const UINT32 dataLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT32 dataIdx = 0u; /*ݵǰλ*/ + UINT32 netLen = 0u; /*ݳ*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT8 funRtn = 0u; /*úֵ*/ + + if (NULL != data) /**/ + { + while (dataIdx < dataLen) /**/ + { + if (dataIdx + 4u <= dataLen) /*±Ϸ.4Ϊ4ֽݳ*/ + { + funRtn = DevDataFormatCheck(data, dataLen, &dataIdx, &netLen); + if (1u != funRtn) /*úֵ쳣*/ + { + rtnVal = funRtn; + isBreak = 1u; + } + } + else /*±Ƿ*/ + { + rtnVal = DATA_IDX_ILLEGAL; + isBreak = 1u; + } + if (1u == isBreak) /*˳*/ + { + break; + } + } + if ((0u == isBreak) && (dataIdx == dataLen)) /*˳ݳȺϷ*/ + { + rtnVal = 1u; + } + } + + return rtnVal; +} + +/* +*: DevDataFormatCheck +*: 豸ݸʽ +*: +* UINT8* data (ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* const UINT32 dataLen ݳ +*: +* UINT32* dataIdx ݵǰλ +* UINT32* netLen ݳ +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 DevDataFormatCheck(UINT8* data, const UINT32 dataLen, UINT32* dataIdx, UINT32* netLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT32 netIdx = 0u; /*ݵǰλ*/ + UINT16 devLen = 0u; /*豸ݳ*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + + if ((NULL != data) && (NULL != dataIdx) && (NULL != netLen)) /**/ + { + netIdx = 0u; /*ݵǰλ*/ + *netLen = 4u + LongFromChar(&data[*dataIdx]); /*ݳ*/ + if (*netLen <= dataLen) /*ݳȺϷ*/ + { + netIdx += 4u; + *dataIdx += 4u; + while (netIdx < *netLen) /*豸*/ + { + if (*dataIdx + 6u < dataLen) /*±Ϸ.6Ϊ2ֽ豸ݳ+4ֽ豸ΨһID*/ + { + devLen = 2u + ShortFromChar(&data[*dataIdx]); /*豸ݳ*/ + if ((6u < (UINT32)devLen) && (4u + (UINT32)devLen <= *netLen)) /*豸ݳȺϷ*/ + { + netIdx += devLen; + *dataIdx += devLen; + } + else /*豸ݳȷǷ*/ + { + rtnVal = DEV_LEN_ILLEGAL; + isBreak = 1u; + } + } + else /*±Ƿ*/ + { + rtnVal = DEV_IDX_ILLEGAL; + isBreak = 1u; + } + if (1u == isBreak) /*д,˳*/ + { + break; + } + } + if (netIdx == *netLen) /*ݳȼ*/ + { + rtnVal = 1u; + } + } + else /*ݳȷǷ*/ + { + rtnVal = NET_LEN_ILLEGAL; + } + } + + return rtnVal; +} + +/* +*: TwoRepeat +*: ݶݱȽȥظ(жȥе,Ա) +*: +* ProtclConfigInfoStru* protcl Эṹ +* UINT8* data1 һ(ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* UINT32 data1Len һݳ +* UINT8* data2Staging ݴ +* UINT32 data2StagingMaxLen ݴ󳤶 +*: +* UINT8* data2 (ʽ:ͬ) +* UINT32* data2Len ݳ +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 TwoRepeat(ProtclConfigInfoStru* protcl, UINT8* data1, const UINT32 data1Len, UINT8* data2, UINT32* data2Len, UINT8* data2Staging, const UINT32 data2StagingMaxLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT32 data2Idx = 0u; /*ݵǰλ*/ + UINT32 data1Idx = 0u; /*1ǰλ*/ + UINT8 funRtn = 0u; /*úֵ*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT32 data2StagingIdx = 0u; /*ݴ鵱ǰλ*/ + + funRtn = ProtclTwoRepeatParam(protcl, data1, data2, data2Len, data2Staging); + if (1u == funRtn) /*ú*/ + { + while (data2Idx < *data2Len) /**/ + { + if (data2Idx + 4u <= *data2Len) /*±Ϸ.4Ϊ4ֽݳ*/ + { + funRtn = TwoNetRepeat(protcl, data1, &data1Idx, data1Len, data2, &data2Idx, *data2Len, data2Staging, &data2StagingIdx, data2StagingMaxLen); + if (1u != funRtn) + { + rtnVal = funRtn; + isBreak = 1u; + } + } + else /*±Ƿ*/ + { + rtnVal = DATA2_NET_IDX_ILLEGAL; + isBreak = 1u; + } + if (1u == isBreak) /*˳*/ + { + break; + } + } + if ((0u == isBreak) && (data1Idx == data1Len) && (data2Idx == *data2Len)) /*˳һݳȺϷ*/ + { + if (data2StagingIdx <= *data2Len) /*ݴݳȺϷ*/ + { + (void)CommonMemCpy(&data2[0], *data2Len, &data2Staging[0], data2StagingIdx); + *data2Len = data2StagingIdx; + rtnVal = 1u; + } + else /*ݴݳȷǷ*/ + { + rtnVal = DATA2STAGING_COPY_ILLEGAL; + } + } + } + + return rtnVal; +} + + +/* +*: RepeatDataNetFormatCheck +*: ҪȽȥݵijݸʽ +*: +* UINT8* data (ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* const UINT32 dataLen ݳ +* const UINT32 netDataIdx λ +*: +* UINT32* netLen ݳ +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 RepeatDataNetFormatCheck(UINT8* data, const UINT32 dataLen, const UINT32 netDataIdx, UINT32* netLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT32 dataIdx = 0u; /*ݵǰλ*/ + UINT8 funRtn = 0u; /*úֵ*/ + + if ((NULL != data) && (NULL != netLen)) /**/ + { + dataIdx = netDataIdx; + if (dataIdx + 4u <= dataLen) /*±Ϸ.4Ϊ4ֽݳ*/ + { + funRtn = DevDataFormatCheck(data, dataLen, &dataIdx, netLen); + if (1u == funRtn) /*úֵ*/ + { + if (dataIdx <= dataLen) /*ݳȺϷ*/ + { + rtnVal = 1u; + } + } + else /*úֵ*/ + { + rtnVal = funRtn; + } + } + } + + return rtnVal; +} + +/* +*: TwoNetRepeat +*: ݱȽȥظ +*: +* ProtclConfigInfoStru* protcl Эṹ +* UINT8* data1 һ(ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* const UINT32 data1Len һݳ +* UINT8* data2 (ʽ:ͬ) +* const UINT32 data2Len ݳ +* UINT32 data2StagingMaxLen ݴ󳤶 +*: +* UINT32* data1Idx 1± +* UINT32* data2Idx 2± +* UINT8* data2Staging ݴ +* UINT32* data2StagingIdx ݴ± +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 TwoNetRepeat(ProtclConfigInfoStru* protcl, UINT8* data1, UINT32* data1Idx, const UINT32 data1Len, UINT8* data2, UINT32* data2Idx, const UINT32 data2Len, UINT8* data2Staging, UINT32* data2StagingIdx, const UINT32 data2StagingMaxLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT32 data1IdxNet = 0u; /*1ǰλ*/ + UINT32 net2Len = 0u; /*2ݳ*/ + UINT32 net2Idx = 0u; /*2ݵǰλ*/ + UINT32 net1Len = 0u; /*1ݳ*/ + UINT8 funRtn = 0u; /*úֵ*/ + UINT8 isErr = 0u; /*Ƿ*/ + UINT32 data2StagingStartIdx = 0u; /*ݴݿʼλ*/ + + funRtn = TwoNetRepeatParam(protcl, data1, data1Idx, data2, data2Idx, data2Staging, data2StagingIdx); + if (1u == funRtn) /*ú*/ + { + if (*data2StagingIdx + 4u <= data2StagingMaxLen) /*ݴпռ*/ + { + data1IdxNet = *data1Idx; /*һݵǰλ*/ + + data2StagingStartIdx = *data2StagingIdx; /*öݴݿʼλ*/ + (void)CommonMemCpy(&data2Staging[data2StagingStartIdx], data2StagingMaxLen - data2StagingStartIdx, &data2[*data2Idx], 4u); + *data2StagingIdx += 4u; + + net2Len = 4u + LongFromChar(&data2[*data2Idx]); /*ݳ*/ + if (net2Len <= data2Len) /*ݳȺϷ*/ + { + net2Idx += 4u; + *data2Idx += 4u; + + if (4u < net2Len) /*豸*/ + { + while (net2Idx < net2Len) /**/ + { + funRtn = TwoDevRepeat(protcl, data1, data1IdxNet, data1Idx, data1Len, data2, data2Idx, data2Len, &net2Idx, net2Len, data2Staging, data2StagingIdx, data2StagingMaxLen); + if (1u != funRtn) /*˳*/ + { + rtnVal = funRtn; + isErr = 1u; + break; + } + } + } + else /*豸*/ + { + funRtn = RepeatDataNetFormatCheck(data1, data1Len, data1IdxNet, &net1Len); + if (1u == funRtn) /**/ + { + *data1Idx += net1Len; + } + else /*쳣*/ + { + rtnVal = funRtn; + isErr = 1u; + } + } + + if ((0u == isErr) && (net2Idx == net2Len)) /*˳ݳȷǷ*/ + { + if (data2StagingStartIdx + 4u <= *data2StagingIdx) /*ݴ泤ȺϷ*/ + { + LongToChar(*data2StagingIdx - data2StagingStartIdx - 4u, &data2Staging[data2StagingStartIdx]); + rtnVal = 1u; + } + else /*ݴ泤ȷǷ*/ + { + rtnVal = DATA2STAGING_NET_ILLEGAL; + } + } + } + else /*ݳȷǷ*/ + { + rtnVal = NET2_LEN_ILLEGAL; + } + } + } + + return rtnVal; +} + +/* +*: TwoNetRepeatParam +*: ݱȽȥظݲ +*: +* ProtclConfigInfoStru* protcl Эṹ +* UINT8* data1 һ(ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* UINT8* data2 (ʽ:ͬ) +* UINT32* data1Idx 1± +* UINT32* data2Idx 2± +* UINT8* data2Staging ݴ +* UINT32* data2StagingIdx ݴ± +*: +*: +*ֵ: ɹ:1 ʧ:0 +*/ +static UINT8 TwoNetRepeatParam(ProtclConfigInfoStru* protcl, UINT8* data1, UINT32* data1Idx, UINT8* data2, UINT32* data2Idx, UINT8* data2Staging, UINT32* data2StagingIdx) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + + if ((NULL != protcl) && (NULL != data1) && (NULL != data1Idx) && (NULL != data2) && (NULL != data2Idx) && (NULL != data2Staging) && (NULL != data2StagingIdx)) /**/ + { + rtnVal = 1u; + } + + return rtnVal; +} + +/* +*: TwoDevRepeat +*: 豸ݱȽȥظ +*: +* ProtclConfigInfoStru* protcl Эṹ +* UINT8* data1 һ(ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* const UINT32 data1IdxNet 1ǰ± +* const UINT32 data1Len һݳ +* UINT8* data2 (ʽ:ͬ) +* const UINT32 data2Len ݳ +* const UINT32 net2Len 2 +* const UINT32 data2StagingMaxLen ݴ󳤶 +*: +* UINT32* data1Idx 1± +* UINT32* data2Idx 2± +* UINT32* net2Idx 2± +* UINT8* data2Staging ݴ +* UINT32* data2StagingIdx ݴ± +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 TwoDevRepeat(ProtclConfigInfoStru* protcl, UINT8* data1, const UINT32 data1IdxNet, UINT32* data1Idx, const UINT32 data1Len, UINT8* data2, UINT32* data2Idx, const UINT32 data2Len, UINT32* net2Idx, const UINT32 net2Len, UINT8* data2Staging, UINT32* data2StagingIdx, const UINT32 data2StagingMaxLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT16 dev2Len = 0u; /*豸ݳ*/ + UINT32 dev2UniqueId = 0u; /*豸ΨһID(ID+߼ID)*/ + UINT8 dev2oppTypePtl = 0u; /*Է豸Э*/ + UINT32 net1Len = 0u; /*1*/ + UINT32 net1Idx = 0u; /*1±*/ + UINT8 funRtn = 0u; /*úֵ*/ + UINT8 isErr = 0u; /*Ƿ*/ + + funRtn = TwoDevRepeatParam(protcl, data1, data1Idx, data2, data2Idx, net2Idx, data2Staging, data2StagingIdx); + if (1u == funRtn) /*ú*/ + { + if (*data2Idx + 6u < data2Len) /*±Ϸ.6Ϊ2ֽ豸ݳ+4ֽ豸ΨһID*/ + { + dev2Len = 2u + ShortFromChar(&data2[*data2Idx]); /*豸ݳ*/ + if ((6u < (UINT32)dev2Len) && (4u + (UINT32)dev2Len <= net2Len)) /*豸ݳȺϷ*/ + { + dev2oppTypePtl = protcl->GlobalVar->oppTypePtl[data2[*data2Idx + 2u]]; + dev2UniqueId = LongFromChar(&data2[*data2Idx + 2u]); /*豸ΨһID*/ + if ((data1IdxNet + 4u) <= data1Len) /*λúϷ*/ + { + net1Len = 4u + LongFromChar(&data1[data1IdxNet]); /**/ + if (net1Len <= data1Len) /*ȺϷ*/ + { + net1Idx += 4u; + if (4u < net1Len) /*豸*/ + { + funRtn = RepeatCheck(dev2oppTypePtl, dev2UniqueId, &data2[*data2Idx], dev2Len, data1, data1Idx, data1Len, data1IdxNet, &net1Idx, net1Len, data2Staging, data2StagingIdx, data2StagingMaxLen); + if (1u == funRtn) /*úֵ*/ + { + *net2Idx += dev2Len; + *data2Idx += dev2Len; + rtnVal = 1u; + } + else /*úֵ*/ + { + rtnVal = funRtn; + } + } + else /*豸*/ + { + if (data1IdxNet == *data1Idx) /*һ*/ + { + if (net1Idx == net1Len) /*-< ǷϷ*/ + { + *data1Idx += net1Len; /*-< һ±*/ + } + else /*ȷǷ*/ + { + isErr = 1u; /*-< ô־Ϊ1*/ + } + } + if (0u == isErr) /*-< Ƿ޴*/ + { + if (*data2StagingIdx + dev2Len <= data2StagingMaxLen) /*-< ݴǷпռ*/ + { + (void)CommonMemCpy(&data2Staging[*data2StagingIdx], data2StagingMaxLen - (*data2StagingIdx), &data2[*data2Idx], dev2Len); /*-< 豸ݸƵݴ*/ + *data2StagingIdx += dev2Len; /*-< öݴ泤豸*/ + + *net2Idx += dev2Len; /*-< ö±豸*/ + *data2Idx += dev2Len; /*-< ö±豸*/ + + rtnVal = 1u; /*-< úֵΪ1*/ + } + else /*ݴ޿ռ*/ + { + rtnVal = DATA2_STAGING_NO; /*-< úֵΪ19*/ + } + } + else /*д*/ + { + rtnVal = NO_DATA_NET1_LEN_ILLEGAL; /*-< úֵΪ20*/ + } + } + } + else /*ȷǷ*/ + { + rtnVal = NET1_LEN_ILLEGAL; + } + } + else /*λ÷Ƿ*/ + { + rtnVal = DATA1_IDX_ILLEGAL; + } + } + else /*豸ݳȷǷ*/ + { + rtnVal = DATA2_DEV_LEN_ILLEGAL; + } + } + else /*±Ƿ*/ + { + rtnVal = DATA2_IDX_ILLEGAL; + } + } + + return rtnVal; +} + +/* +*: TwoDevRepeatParam +*: 豸ݱȽȥظݺ +*: +* ProtclConfigInfoStru* protcl Эṹ +* UINT8* data1 һ(ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* UINT8* data2 (ʽ:ͬ) +* UINT32* data1Idx 1± +* UINT32* data2Idx 2± +* UINT32* net2Idx 2± +* UINT8* data2Staging ݴ +* UINT32* data2StagingIdx ݴ± +*: +*: +*ֵ: ɹ:1 ʧ:0 +*/ +static UINT8 TwoDevRepeatParam(ProtclConfigInfoStru* protcl, UINT8* data1, UINT32* data1Idx, UINT8* data2, UINT32* data2Idx, UINT32* net2Idx, UINT8* data2Staging, UINT32* data2StagingIdx) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + + if ((NULL != protcl) && (NULL != data1) && (NULL != data1Idx) && (NULL != data2) && (NULL != data2Idx) && (NULL != net2Idx) && (NULL != data2Staging) && (NULL != data2StagingIdx)) /**/ + { + rtnVal = 1u; + } + + return rtnVal; +} + +/* +*: RepeatCheck +*: ظ +*: ProtclConfigInfoStru* protcl Эṹ +* const UINT8 dev2OppTypePtl Э +* const UINT32 dev2UniqueId 豸ΨһID(ID+߼ID) +* UINT8* dev2Data 豸(ʽ:Эݰ) +* UINT16 dev2Len 豸ݳ +* UINT8* data1 һ +* UINT32* data1Idx һݵǰλ +* const UINT32 data1Len һݳ +* const UINT32 data1IdxNet һݵǰλ +* const UINT32 net1Len 1 +* UINT8* data2Staging ݴ +* UINT32* data2StagingIdx ݴ± +* const UINT32 data2StagingMaxLen ݴ󳤶 +*: +* UINT32* net1Idx 1ǰλ +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 RepeatCheck(const UINT8 dev2OppTypePtl, const UINT32 dev2UniqueId, UINT8* dev2Data, const UINT16 dev2Len, UINT8* data1, UINT32* data1Idx, const UINT32 data1Len, const UINT32 data1IdxNet, UINT32* net1Idx, const UINT32 net1Len, UINT8* data2Staging, UINT32* data2StagingIdx, const UINT32 data2StagingMaxLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT8 funRtn = 0u; /*úֵ*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT8 isFirst = 0u; /*Ƿһ*/ + UINT8 isRepeat = 0u; /*Ƿظ*/ + + funRtn = RepeatCheckParam(dev2Data, data1, data1Idx, net1Idx, data2Staging, data2StagingIdx); + if (1u == funRtn) /*ú*/ + { + if (data1IdxNet == *data1Idx) /*һδ1*/ + { + isFirst = 1u; + } + while (*net1Idx < net1Len) /*д豸*/ + { + funRtn = RepeatDataCheck(&isRepeat, dev2OppTypePtl, dev2UniqueId, &dev2Data[6], dev2Len - 6u, data1, data1IdxNet, data1Len, net1Idx, net1Len); + if (1u == funRtn) /*ú*/ + { + if (1u == isRepeat) /*ظ*/ + { + if (0u == isFirst) /*ǵһ,ٱ*/ + { + isBreak = 1u; + } + } + } + else /*ú쳣*/ + { + rtnVal = funRtn; + } + + if ((1u != funRtn) || (1u == isBreak)) /*ô˳*/ + { + break; + } + } + + if (1u == funRtn) /*޴*/ + { + rtnVal = RepeatCheckSet(isRepeat, isFirst, dev2Data, dev2Len, data1Idx, *net1Idx, net1Len, data2Staging, data2StagingIdx, data2StagingMaxLen); + } + } + + return rtnVal; +} + +/* +*: RepeatCheckParam +*: ظ麯 +*: ProtclConfigInfoStru* protcl Эṹ +* UINT8* dev2Data 豸 +* UINT8* data1 һ +* UINT32* data1Idx һݵǰλ +* UINT8* data2Staging ݴ +* UINT32* data2StagingIdx ݴ± +* UINT32* net1Idx 1ǰλ +*: +*: +*ֵ: ɹ:1 ʧ:0 +*/ +static UINT8 RepeatCheckParam(UINT8* dev2Data, UINT8* data1, UINT32* data1Idx, UINT32* net1Idx, UINT8* data2Staging, UINT32* data2StagingIdx) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + + if ((NULL != dev2Data) && (NULL != data1) && (NULL != data1Idx) && (NULL != net1Idx) && (NULL != data2Staging) && (NULL != data2StagingIdx)) /**/ + { + rtnVal = 1u; + } + + return rtnVal; +} + +/* +*: RepeatCheckSet +*: ظ +*: UINT8 isRepeat Ƿظ +* UINT8 isFirst Ƿһ +* UINT8* dev2Data 豸(ʽ:Эݰ) +* UINT16 dev2Len 豸ݳ +* UINT8* data1 һ +* UINT32* data1Idx һݵǰλ +* const UINT32 data1Len һݳ +* const UINT32 data1IdxNet һݵǰλ +* const UINT32 net1Len 1 +* UINT8* data2Staging ݴ +* UINT32* data2StagingIdx ݴ± +* const UINT32 data2StagingMaxLen ݴ󳤶 +*: +* UINT32* net1Idx 1ǰλ +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 RepeatCheckSet(UINT8 isRepeat, UINT8 isFirst, UINT8* dev2Data, UINT16 dev2Len, UINT32* data1Idx, UINT32 net1Idx, UINT32 net1Len, UINT8* data2Staging, UINT32* data2StagingIdx, const UINT32 data2StagingMaxLen) +{ + UINT8 isErr = 0u; /*Ƿ*/ + UINT8 rtnVal = 0u; /*ֵ*/ + + if ((NULL != dev2Data) && (NULL != data1Idx) && (NULL != data2Staging) && (NULL != data2StagingIdx)) /**/ + { + if (0u == isRepeat) /*ظ*/ + { + if (*data2StagingIdx + dev2Len <= data2StagingMaxLen) /*ݴпռ*/ + { + (void)CommonMemCpy(&data2Staging[*data2StagingIdx], data2StagingMaxLen - (*data2StagingIdx), &dev2Data[0], dev2Len); + *data2StagingIdx += dev2Len; + } + else /*ݴ޿ռ*/ + { + isErr = 1u; + } + } + + if (0u == isErr) /*޴*/ + { + if (1u == isFirst) /*һ*/ + { + if (net1Idx == net1Len) /*ȺϷ*/ + { + *data1Idx += net1Len; + rtnVal = 1u; + } + else /*ȺϷ*/ + { + rtnVal = DATA1_NET_LEN_ILLEGAL; + } + } + else /*ǵһ*/ + { + rtnVal = 1u; + } + } + else /*д*/ + { + rtnVal = DATA2_STAGING_NO_SPACE; + } + } + + return rtnVal; +} + +/* +*: RepeatDataCheck +*: ظݼ +*: UINT8* isRepeat Ƿظ +* UINT8 dev2OppTypePtl Э +* UINT32 devUniqueId 豸ΨһID(ID+߼ID) +* UINT8* dev2Data 豸(ʽ:Эݰ) +* UINT16 dev2Len 豸ݳ +* UINT8* data1 һ +* UINT32* data1Idx һݵǰλ +* const UINT32 data1Len һݳ +* const UINT32 data1IdxNet һݵǰλ +* const UINT32 net1Len 1 +*: +* UINT32* net1Idx 1ǰλ +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 RepeatDataCheck(UINT8* isRepeat, UINT8 dev2OppTypePtl, UINT32 dev2UniqueId, UINT8* dev2Data, UINT16 dev2Len, UINT8* data1, UINT32 data1IdxNet, const UINT32 data1Len, UINT32* net1Idx, UINT32 net1Len) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT16 curDevLen = 0u; /*ǰ豸ݳ*/ + UINT32 curDevUniqueId = 0u; /*ǰ豸ΨһID(ID+߼ID)*/ + UINT8 funRtn = 0u; /*úֵ*/ + + funRtn = RepeatDataCheckParam(isRepeat, dev2Data, data1, net1Idx); + if (1u == funRtn) /*ú*/ + { + if ((data1IdxNet + 4u) <= data1Len) /*λ,ȼ*/ + { + if ((data1IdxNet + *net1Idx + 6u) < data1Len) /*±Ч*/ + { + curDevLen = ShortFromChar(&data1[data1IdxNet + *net1Idx]); /*豸ݳ*/ + *net1Idx += 2u; + if ((4u < (UINT32)curDevLen) && (6u + (UINT32)curDevLen <= net1Len)) /*豸ݳЧ*/ + { + curDevUniqueId = LongFromChar(&data1[data1IdxNet + *net1Idx]); /*ǰ豸ΨһID*/ + if ((curDevLen == 4u + dev2Len) && (curDevUniqueId == dev2UniqueId)) + { + funRtn = RepeatValCheck(isRepeat, dev2OppTypePtl, dev2Data, dev2Len, data1, data1IdxNet + *net1Idx + 4u, data1Len); + if (1u == funRtn) /*ú*/ + { + *net1Idx += curDevLen; + rtnVal = 1u; + } + else /*ú쳣*/ + { + rtnVal = funRtn; + } + } + else + { + *net1Idx += curDevLen; + rtnVal = 1u; + } + + } + } + } + } + + return rtnVal; +} + +/* +*: RepeatDataCheckParam +*: ظݼú +*: UINT8* isRepeat Ƿظ +* UINT8* dev2Data 豸(ʽ:Эݰ) +* UINT8* data1 һ +* UINT32* net1Idx 1ǰλ +*: +*: +*ֵ: ɹ:1 ʧ:0 +*/ +static UINT8 RepeatDataCheckParam(UINT8* isRepeat, UINT8* dev2Data, UINT8* data1, UINT32* net1Idx) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + + if ((NULL != isRepeat) && (NULL != dev2Data) && (NULL != data1) && (NULL != net1Idx)) /**/ + { + rtnVal = 1u; + } + + return rtnVal; +} + +/* +*: RepeatValCheck +*: ظֵ +*: UINT8 dev2OppTypePtl Э +* UINT8* dev2Data 豸(ʽ:Эݰ) +* UINT16 devLen 豸ݳ +* UINT8* data1 һ +* UINT32* data1Idx һ± +* const UINT32 data1MaxLen һ󳤶 +*: +* UINT8* isRepeat Ƿظ +*: +*ֵ: ɹ:1 ʧ:1 +*/ +static UINT8 RepeatValCheck(UINT8* isRepeat, UINT8 dev2OppTypePtl, UINT8* dev2Data, UINT16 devLen, UINT8* data1, UINT32 data1Idx, const UINT32 data1MaxLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + UINT8 funRtn = 0u; /*úֵ*/ + INT32 cmpRtn = 0; /*ȽϷֵ*/ + + funRtn = RepeatValCheckParam(isRepeat, dev2Data, devLen, data1, data1Idx, data1MaxLen); + if (1u == funRtn) /*ú*/ + { + if (DSU_PROTCL_SFP == dev2OppTypePtl) /*SFPЭ*/ + { + if (23u <= devLen) /*ȺϷ*/ + { + cmpRtn = memcmp(&dev2Data[devLen - 4u], &data1[data1Idx + devLen - 4u], 4u); + rtnVal = 1u; + } + else /*ȷǷ*/ + { + rtnVal = DEV_SFP_LEN_ILLEGAL; + } + } + else if (DSU_PROTCL_RSSP == dev2OppTypePtl || DSU_PROTCL_FSFB == dev2OppTypePtl) /*RSSP FSFBЭ*/ + { + if (20u <= devLen) /*ȺϷ*/ + { + cmpRtn = memcmp(&dev2Data[devLen - 2u], &data1[data1Idx + devLen - 2u], 2u); + rtnVal = 1u; + } + else /*ȷǷ*/ + { + rtnVal = DEV_RSSPI_FSFB_LEN_ILLEGAL; + } + } + else if (DSU_PROTCL_RSSP2 == dev2OppTypePtl) /*RSSPIIЭ*/ + { + if (19u <= devLen) /*ȺϷ*/ + { + cmpRtn = memcmp(&dev2Data[8], &data1[data1Idx + 8u], 2u); + rtnVal = 1u; + } + else /*ȷǷ*/ + { + rtnVal = DEV_RSSPII_LEN_ILLEGAL; + } + } + else /**/ + { + cmpRtn = memcmp(&dev2Data[0], &data1[data1Idx], devLen); + rtnVal = 1u; + } + if (0 == cmpRtn) /*ͬ*/ + { + *isRepeat = 1u; + } + } + + return rtnVal; +} + +/* +*: RepeatValCheckParam +*: ظֵ麯 +*: UINT8* devData 豸(ʽ:Эݰ) +* UINT16 devLen 豸ݳ +* UINT8* data1 һ +* UINT32* data1Idx һ± +* const UINT32 data1MaxLen һ󳤶 +* UINT8* isRepeat Ƿظ +*: +*: +*ֵ: ɹ:1 ʧ:0 +*/ +static UINT8 RepeatValCheckParam(UINT8* isRepeat, UINT8* devData, UINT16 devLen, UINT8* data1, UINT32 data1Idx, const UINT32 data1MaxLen) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + + if ((NULL != isRepeat) && (NULL != devData) && (NULL != data1)) /**/ + { + if (data1Idx + devLen <= data1MaxLen) /*ȺϷ*/ + { + rtnVal = 1u; + } + } + + return rtnVal; +} \ No newline at end of file diff --git a/TSCP/src/protocol/protocol_cbtc/common_protocol/protclInterFun.h b/TSCP/src/protocol/protocol_cbtc/common_protocol/protclInterFun.h new file mode 100644 index 0000000..123e986 --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_protocol/protclInterFun.h @@ -0,0 +1,230 @@ +/* +* +* ļ ProtclInterFun.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.15 +* +* Э࣬ҪʵԵЭ顣 +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +* 1 2011/06/07 ¥ΰ Э +*/ +#ifndef _PROTCL_Inter_Fun_H_ +#define _PROTCL_Inter_Fun_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "protclStruct.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* +* Эʼģ +* +* char* fileName ݵĵַ +* UINT32 inDataLen ڲ +* UINT8 inData[] ڲ +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1 ʼɹ +* 0: ʼʧ +*/ +UINT8 ProtclInitFunc(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], ProtclConfigInfoStru* pUnifyInfo); + +/* +*: ProtclEndFunc +*: Э +*: ProtclConfigInfoStru *pUnifyInfo Эͳһṹ +*: +*: +*ֵ: 1;ٳɹ,0:ʧ +*/ +UINT8 ProtclEndFunc(ProtclConfigInfoStru *pUnifyInfo); + +/* +* ܣЭ +* +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 1ݳɹ +0ʧ +*/ +UINT8 ProtclReceiveDataFunc (ProtclConfigInfoStru * pUnifyInfo); + +/* +* ܣЭ鷢 +* +* +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* UINT8 1 +*/ + +UINT8 ProtclSendDataFunc(ProtclConfigInfoStru * pUnifyInfo); + + +/* +* ܣɾ· +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ̬ID +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* UINT8 1 ɾɹ +* 0 ɾʧ +*/ + +UINT8 ProtclDeleteLnkFunc(UINT8 DestType,UINT8 DestID,UINT16 logId,ProtclConfigInfoStru * pUnifyInfo); + +/* +* ܣѯ·״̬ +* +* +* UINT8 DestType Է豸 +* UINT8 DestID Է豸ID +* UINT16 logId ˹µCIVOBCͨţҪдVOBCվ̨šϵͳ0 +* ProtclConfigInfoStru * pUnifyInfo ͳһṹ +* ֵ +* 0ڸ·ش +* 0x17·ݴ״̬ +* 0x2b·ͨж״̬ +* 0x33·׼״̬ +* 0x4e·ڵȴ״̬ +* 0x01: ʾˢõ· +*/ +UINT8 ProtclGetLnkStatus (UINT8 destType,UINT8 destId,UINT16 logId,ProtclConfigInfoStru * pUnifyInfo); + +/* +* ܣˢ·״̬ +* +* +* UINT8* pLnkStatusData Э״̬ +* ֵ +* 0ˢ·ʧ +* 1ˢ·ɹ +*/ +UINT8 ProtclReFreshFunc(UINT8* pLnkStatusData, ProtclConfigInfoStru * pUnifyInfo); + +/************************************************************************ +ܣЭTCP·״̬Ϣ +: ʹTCPͨţRSSP2Э飩ʱûҪÿڵҽһα, + ΪЭTCP·״̬Ϣע⣬ȵñЭպ + ProtclReceiveDataFunc()ܵ±ڵЭպ޷ȷ + »ΪδȷAU1Ϣ½ʱӳ + + UINT16 TcpStateDataLen, TCP״ֽ̬ + UINT8* pTcpStateData TCP״̬ +ֵ0ʧ 1ɹ + TCP·״̬ݽṹ + ȣ | ڵ1 | ڵ2 | ... + 2ֽ | Զ豸ͨETCSID(4ֽ) ״̬(1ֽ) | ... | ... + ״̬ݽṹ + RRRRBBBB 4λΪ״̬Ϣ4λΪ״̬Ϣ״̬Ϣ0 1 2 3Ͽ 4ѶϿ +************************************************************************/ +UINT8 ProtclReceiveTcpStateFunc(UINT16 TcpStateDataLen,UINT8* pTcpStateData, ProtclConfigInfoStru *pUnifyInfo); + +/************************************************************************ +ܣЭTCP·Ϣ +ʹTCPͨţRSSP2Э飩ʱûҪÿڵҽһα, + ȡЭTCP·ϢϢ͸ת2ͨſ + ע⣬ͨſTCP·Ϣͨűġ +: + UINT16 *pTcpCtrlDataLen, TCPϢֽ + UINT8 *pTcpCtrlData TCPϢ +ֵ0ʧ 1ɹ + TCP·Ʊݽṹ + ȣ | ڵ1 | ڵ2 | ... + 2ֽ | Զ豸ͨETCSID(4ֽ) (1ֽ) | ... | ... + ݽṹ + RRRRBBBB 4λΪָ4λΪָָ0 1 2 3Ͽ +************************************************************************/ +UINT8 ProtclSendTcpCtrlFunc(UINT16 *pTcpCtrlDataLen,UINT8 *pTcpCtrlData, ProtclConfigInfoStru *pUnifyInfo); + +/* +*: AdjustRsspiVarArray +*: RSSPI·,ָֻĶԷַ· +*: UINT8 oppIdsNum ԷID߼ID +* const UINT16 oppTypeIds[] ԷID +* const UINT16 oppLogicIds[] Է߼ID +* ProtclConfigInfoStru *pUnifyInfo ṹ +*: +*: +*ֵ: +*/ +void AdjustRsspiVarArray(UINT8 oppIdsNum, const UINT16 oppTypeIds[], const UINT16 oppLogicIds[], ProtclConfigInfoStru *pUnifyInfo); + +/* +*: ȡյ +*: ProtclConfigInfoStru* pUnifyInfo +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void ProtclGetNetsRecvPkgNumFunc(ProtclConfigInfoStru* pUnifyInfo, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); + +/* +*: ProtclGetSwapData +*: ȡ˫CPU +*: UINT8 swapData[] 2ֽܳ+SFP(2ֽڳ+N[4ֽCRC])+RSSPI(2ֽڳ+N[4ֽSVC]) ռ2046 +* const UINT16 swapDataMaxLen 󳤶 2046 +* ProtclConfigInfoStru* protcl Эṹ +*: +*: +*ֵ: +*/ +void ProtclGetSwapData(UINT8 swapData[], const UINT16 swapDataMaxLen, ProtclConfigInfoStru* protcl); + +/* +*: ProtclSetSwapData +*: ˫CPU +*: UINT8 swapData[] 2ֽܳ+SFP(2ֽڳ+N[4ֽCRC])+RSSPI(2ֽڳ+N[4ֽSVC]) +* ProtclConfigInfoStru* protcl Эṹ +*: +*: +*ֵ: +*/ +void ProtclSetSwapData(UINT8 swapData[], ProtclConfigInfoStru* protcl); + +/* +*: ProtclDelAllLink +*: ɾ· +*: ProtclConfigInfoStru* protcl Эṹ +*: +*: +*ֵ: +*/ +void ProtclDelAllLink(ProtclConfigInfoStru* protcl); + +/* +*: ProtclTwoRepeat +*: ݱȽȥظ(жȥе,Ա) +*: +* ProtclConfigInfoStru* protcl Эṹ +* UINT8* data1 һ(ʽ:{4ֽڳ+{2ֽڳ+2ֽ豸ID+2ֽ߼ID+ݰ}+{N}}+{N}) +* const UINT32 data1Len һݳ +* UINT8* data2Staging ݴ +* const UINT32 data2StagingMaxLen ݴ󳤶 +*: +* UINT8* data2 (ʽ:ͬ) +* UINT32* data2Len ݳ +*: +*ֵ: ɹ:1 ʧ:0 +*/ +UINT8 ProtclTwoRepeat(ProtclConfigInfoStru* protcl, UINT8* data1, const UINT32 data1Len, UINT8* data2, UINT32* data2Len, UINT8* data2Staging, const UINT32 data2StagingMaxLen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/protocol_cbtc/common_protocol/protclMgeCfg.h b/TSCP/src/protocol/protocol_cbtc/common_protocol/protclMgeCfg.h new file mode 100644 index 0000000..d30f899 --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_protocol/protclMgeCfg.h @@ -0,0 +1,58 @@ +/************************************************************************ +* ļ protclMgeCfg.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2013.09.22 +* +* Э + Э鼯йṩͳһӿڡ +* ʹע + +* ޸ļ¼ 2013.09.22 1 ½ + +************************************************************************/ + +#ifndef _PROTCLMGECFG_H_ +#define _PROTCLMGECFG_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "protclStruct.h" + +/****#궨#*************************************************************/ +/* Э */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/****#Ͷ#*************************************************************/ +/* ָ */ +typedef UINT8 (*F_INIT)(UINT8*, UINT32, UINT8*, UINT8, ProtclConfigInfoStru*); /* װ֮INIT */ +typedef UINT8 (*F_SND)(ProtclConfigInfoStru*, UINT8, UINT8*, UINT32*, UINT8*, UINT16*, UINT8*, UINT16*); /* װ֮SND */ +typedef UINT8 (* F_RCV)(QueueStruct*, ProtclConfigInfoStru*); /* װ֮RCV */ +typedef UINT8 (* F_LNK)(UINT8,UINT8,UINT16, ProtclConfigInfoStru*); /* װ֮GETLNK */ +typedef void (*F_NETPKGNUM)(ProtclConfigInfoStru*, const UINT8, const UINT8, const UINT16, UINT16*, UINT16*); /* װ֮NetsRecvPkgNum */ +typedef UINT8 (* F_DELLNK)(UINT8,UINT8,UINT16, ProtclConfigInfoStru*);/* װ֮DELLNK */ +typedef UINT8 (* F_REFRESHLNK)(UINT16,UINT8*, ProtclConfigInfoStru*); /* װ֮REFRESHLNK */ +typedef UINT8 (* F_END)(ProtclConfigInfoStru*); /* װ֮END */ + +/****#ṹ嶨#********************************************************/ +typedef struct { + F_INIT fInit; + F_SND fSnd; + F_RCV fRcv; + F_LNK fLnk; + F_NETPKGNUM fNetsRecvPkgNum; + F_DELLNK fDelLnk; + F_REFRESHLNK fReFreshLnk; + F_END fEnd; +}PROTCL_MGECFG_STRU; + + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/protocol_cbtc/common_protocol/protclStruct.h b/TSCP/src/protocol/protocol_cbtc/common_protocol/protclStruct.h new file mode 100644 index 0000000..76a46d7 --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_protocol/protclStruct.h @@ -0,0 +1,156 @@ +/* +* +* ļ ProtclStruct.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2013.09.15 +* +* Э࣬ҪʵԵЭ顣 +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +*/ +#ifndef _PROTCL_STRUCT_H_ +#define _PROTCL_STRUCT_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "protocolConfig.h" +#include "dsuProtclFun.h" + +#ifdef USE_RSSPII +#include "PrtclBaseParse.h" +#include "Rssp2Struct.h" +#endif +#ifdef USE_SFP +#include "sfpplatform.h" +#endif +#ifdef USE_RSR +#include "RsspStruct.h" +#endif +#ifdef USE_RSSPI +#include "RsspStructWl.h" +#endif +#ifdef USE_RP +#include "RpPlatform.h" +#endif +#ifdef USE_FSFB +#include "fsfbProtclStruct.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Э汾Ŷ */ +#define PROTOCOLCODE_VER_PRODUCT_NO 88/*Ʒ*/ +#define PROTOCOLCODE_VER_MODULE_NO 24/*ģ*/ +#define PROTOCOLCODE_VER_MAIN_VER 13/*ģ汾*/ +#define PROTOCOLCODE_VER_SUB_VER 3 /*ģӰ汾*/ + /**/ + typedef struct + { + UINT8 proType; /*Э*/ + UINT8* pData; /*յ*/ + UINT32 rcvDataLen; /*ݳ*/ + }PROTCL_RCV_DATA_TYPE; + + /*ӦõЭݽṹ*/ + typedef struct + { + UINT8* pAppData; /* Ӧ */ + UINT16 appDataMaxLen; /* Ӧ󳤶 */ + UINT8 devType; /* 豸 */ + UINT8 devId; /* 豸ID */ + UINT16 devLogId; /* 豸̬ID */ + UINT16 appDataLen; /* Ӧݳ */ + }PROTCL_APP_TO_STRU; + + /* Э鷢Ϳýṹ */ + typedef struct + { + PROTCL_APP_TO_STRU* pProtclAppStru; + UINT8 DevDataCnt; + }PROTCL_SND_CFG_STRU; + + + /*ȫֱ*/ + typedef struct + { + DSU_PROTCL_BOOK_IP_INFO_STRU DsuProtclBookIpInfo; /*ʹñ*/ + +#ifdef USE_SFP + struc_Unify_Info *gpsfpUnitInfo; /*SFPЭṹ*/ + UINT8* gpSfpRcvDataBuff; /*յⲿ*/ + UINT16 gSfpRcvDataBuffLen; /*յⲿݳ*/ +#endif +#ifdef USE_RP + RP_INFO_STRU *gpRedunUnitInfo; /*Эṹ*/ + UINT8* gpRpRcvDataBuff; /*յⲿ*/ + UINT16 gRpRcvDataBuffLen; /*յⲿݳ*/ +#endif +#ifdef USE_RSR + RSR_INFO_STRU *gpRsrUnitInfo; /*RSRЭṹ*/ + UINT8* gpRsrRcvDataBuff; /*յⲿ*/ + UINT16 gRsrRcvDataBuffLen; /*յⲿݳ*/ +#endif +#ifdef USE_RSSPI + RSSP_INFO_STRU *gpRsspUnitInfo; /*RSSPЭṹ*/ + UINT8* gpRsspRcvDataBuff; /*յⲿ*/ + UINT16 gRsspRcvDataBuffLen; /*յⲿݳ*/ +#endif +#ifdef USE_RSSPII + RSSP2_INFO_STRU *gpRssp2UnitInfo; /*RSSP2Эṹ*/ + PRTCL_BASE_CONF Rssp2PrtclHead; /*RSSP2Э֡ʹõЭͷ*/ + UINT8* gpRssp2RcvDataBuff; /*յⲿ*/ + UINT16 gRssp2RcvDataBuffLen; /*յⲿݳ*/ +#endif +#ifdef USE_FSFB + FSFB_INFO_STRU* gpFsfbUnitInfo; /*FSFBЭṹ*/ + UINT8* gpFsfbRcvDataBuff; /*յⲿ*/ + UINT16 gFsfbRcvDataBuffLen; /*յⲿݳ*/ +#endif + + PROTCL_APP_TO_STRU* pRcvProtclAppStru; /*յ֡Ϣ*/ + PROTCL_RCV_DATA_TYPE *RcvData; /*ʱЭݵĽṹ*/ + PROTCL_APP_TO_STRU* pSndProtclAppStru; /*͵֡Ϣ*/ + PROTCL_SND_CFG_STRU protclSndCfgStru[PROTCL_MGECFG_MAXCNT + 1]; /*Ϣṹ*/ + UINT8 pProtclNumBuff[PROTCL_MGECFG_MAXCNT + 1]; /*Э·*/ + UINT32 curDevRecordLen[PROTCL_MGECFG_MAXCNT]; /*豸ʹ־*/ + DSU_PROTCL_TYPE_STRU protclTypeInfoStru; /*ѯϢṹ*/ + UINT8 oppTypePtl[UINT8_MAX + 1]; /*ͨŵĶԷ豸Э*/ + }GlobalVar; + +/* Эͳһṹ */ +typedef struct +{ + UINT8 cpuId; /* cpuID,Сͻ˫CPUSVC*/ + UINT8 LocalID; /* 豸ID*/ + UINT8 LocalType; /* 豸type*/ + UINT16 LocalLogicId; /*߼ID*/ + UINT32* CycleNum; /* ں */ + UINT16 InputSize; /* һ֡Ӧݳ*/ + UINT16 OutputSize; /* һ֡Ӧݳ*/ + QueueStruct OutnetQueueA; /* նA */ + QueueStruct OutnetQueueB; /* նB */ + UINT32 OutnetQueueSize; /* նгȣЭʼʱд */ + QueueStruct DataToApp; /* ЭӦõݶ */ + UINT32 DataToAppSize; /* ЭӦõݶг */ + QueueStruct OutputDataQueue; /* ӦøЭݶ */ + UINT32 OutputDataQueueSize; /* ӦøЭݶг */ + UINT32 VarArraySize; /* м鳤 */ + UINT8 *VarArray; /* м */ + UINT8 *AppArray; /* Ӧõ */ + UINT32 AppArraySize; /* Ӧõ鳤 */ + UINT8 *RecordArray; /* Э¼ */ + UINT16 RecordArraySize; /* Э¼С */ + GlobalVar *GlobalVar; /*õȫֱ*/ + UINT8 MaxNumPerCycle; /*һÿЧݣӦðĵڳʼʱд*/ +}ProtclConfigInfoStru; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/protocol_cbtc/common_protocol_config/protocolConfig.h b/TSCP/src/protocol/protocol_cbtc/common_protocol_config/protocolConfig.h new file mode 100644 index 0000000..7a391a9 --- /dev/null +++ b/TSCP/src/protocol/protocol_cbtc/common_protocol_config/protocolConfig.h @@ -0,0 +1,28 @@ + +/******************************************************************************* +* ļ sfpConfig.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2019.03.07 +* +* ļΪЭļ +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + +#ifndef _ProtocolConfig_H +#define _ProtocolConfig_H + +/**************************Э¼궨忪**********************************/ +/*#define CI_TASKLOCK*/ /*CItaskLock()ֶ֧߳*/ + +#define USE_SFP /*ʹSFP*/ +#define USE_RP /*ʹRP*/ +#define USE_RSR /*ʹRSR*/ +#define USE_RSSPI /*ʹRSSPI*/ +#define USE_RSSPII /*ʹRSSPII*/ +#define USE_FSFB /*ʹFSFB*/ + +#endif diff --git a/TSCP/src/protocol/redun_record_cbtc/common_dqu_rp/dsuRpFunc.c b/TSCP/src/protocol/redun_record_cbtc/common_dqu_rp/dsuRpFunc.c new file mode 100644 index 0000000..b111921 --- /dev/null +++ b/TSCP/src/protocol/redun_record_cbtc/common_dqu_rp/dsuRpFunc.c @@ -0,0 +1,151 @@ +/******************************************************************************* +* +* ļ dsuRpFunc.c +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* RpЭصdsuѯ +* ʹע⣺ +* ޸ļ¼ +* +*******************************************************************************/ + +#include "dsuRpFunc.h" +#include "CommonMemory.h" +#include "dfsDataRead.h" +#include "dquDataTypeDefine.h" + +#define DSU_COMM_PROTCL_STRU_SIZE 3 + +DSU_BOOK_IP_INFO_STRU DsuBookIpInfoStru; /*ʼ֮ڱʼ֮ݵı*/ + +/* +*: dsuIpInit +*: RPѯʼ +*: UINT8 *pFsName FSļ +*: +*: +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 dsuIpInit(UINT8 *pFsName) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT8 readRtn = 0; /*ȡFSֵ*/ + UINT8 *pData = NULL; /**/ + UINT32 dataLen = 0; /*ݳ*/ + UINT32 mallocLen = 0; /*ռС*/ + UINT32 offset = 0; /*ƫ*/ + UINT32 i = 0; /*ѭ*/ + + if (NULL != pFsName) /*ηǿ*/ + { + readRtn = dquGetConfigData((CHAR*)pFsName, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_COMM_PROTCL_ID, &pData, &dataLen); /*ȡ豸ͨЭ*/ + if ((1 == readRtn) && (DSU_COMM_PROTCL_STRU_SIZE <= dataLen)) + { + DsuBookIpInfoStru.CommProtclStruLen = (UINT16)(dataLen / DSU_COMM_PROTCL_STRU_SIZE); /**/ + mallocLen = sizeof(DSU_COMM_PROTCL_STRU)*(DsuBookIpInfoStru.CommProtclStruLen); /*ռС*/ + DsuBookIpInfoStru.pCommProtclStru = (DSU_COMM_PROTCL_STRU*)malloc(mallocLen); /*Ϊṹռ*/ + if (NULL != DsuBookIpInfoStru.pCommProtclStru) + { + CommonMemSet(DsuBookIpInfoStru.pCommProtclStru, mallocLen, 0, mallocLen); + + for (i = 0; i < DsuBookIpInfoStru.CommProtclStruLen; i++) + { + /*1ֽڱ*/ + DsuBookIpInfoStru.pCommProtclStru[i].EmitterType = pData[offset]; + offset++; + /*1ֽڶԷ*/ + DsuBookIpInfoStru.pCommProtclStru[i].ReceptorType = pData[offset]; + offset++; + /*1ֽЭ*/ + DsuBookIpInfoStru.pCommProtclStru[i].CommuType = pData[offset]; + offset++; + } + if (offset == dataLen) /*豸ͨЭֵɹ*/ + { + rtn = 1; + } + } + } + } + + return rtn; +} + +/* +*: dsuRpGetDevType +*: 豸ƻȡ豸 +*: UINT16 DevName 豸 +*: +*: +*ֵ: 豸 +*/ +UINT8 dsuRpGetDevType(UINT16 DevName) +{ + UINT8 devType; + devType=(UINT8)(DevName>>8); + + return devType; +} + +/* +*: dsuRpTypeId2DevName +*: IDȡ豸 +*: UINT8 Type 豸 +* UINT8 Id 豸ID +*: +*: UINT16 DevName 豸 +*ֵ: +*/ +void dsuRpTypeId2DevName(UINT8 Type, UINT8 Id, UINT16* pDevName) +{ + *pDevName = Type; + *pDevName = (*pDevName)*0x100 + Id; +} + +/* +*: dsurRpGetProtclType +*: ݱƶԷƻȡЭ +*: UINT16 LocalName +* UINT16 DestName Է +*: +*: UINT8* protclTye Э +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 dsurRpGetProtclType(UINT16 LocalName, UINT16 DestName,UINT8* protclTye) +{ + UINT8 chReturnValue;/*ֵ*/ + UINT16 i;/*ѭ*/ + + UINT8 TempEmitterType;/*豸*/ + UINT8 TempReceptorType;/*豸*/ + + DSU_COMM_PROTCL_STRU *pTempCommProtclStru;/*ͨЭʱ*/ + + /*ȡ豸*/ + TempEmitterType=dsuRpGetDevType(LocalName); + TempReceptorType=dsuRpGetDevType(DestName); + + pTempCommProtclStru=DsuBookIpInfoStru.pCommProtclStru; + for (i=0;iEmitterType==TempEmitterType)&&(pTempCommProtclStru->ReceptorType == TempReceptorType)) + { + + *protclTye=pTempCommProtclStru->CommuType; + break; + } + pTempCommProtclStru++; + } + + if (i==DsuBookIpInfoStru.CommProtclStruLen) + { + /*ûвҵҪͨ*/ + chReturnValue=0; + return chReturnValue; + } + + chReturnValue =1; + return chReturnValue; +} diff --git a/TSCP/src/protocol/redun_record_cbtc/common_dqu_rp/dsuRpFunc.h b/TSCP/src/protocol/redun_record_cbtc/common_dqu_rp/dsuRpFunc.h new file mode 100644 index 0000000..802dd78 --- /dev/null +++ b/TSCP/src/protocol/redun_record_cbtc/common_dqu_rp/dsuRpFunc.h @@ -0,0 +1,84 @@ +/************************************************************************ +* +* ļ +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.29 +* з +* ѯ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _DSU_RP_FUNC_H_ +#define _DSU_RP_FUNC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "CommonTypes.h" + + /*豸ͨЭ0x4002*/ + typedef struct + { + UINT8 EmitterType; /*豸*/ + UINT8 ReceptorType; /*豸*/ + UINT8 CommuType; /*ʹõͨЭ飬1ΪSfp2ΪRp3ΪRsr4ΪRSSPI,5ΪRSSPII*/ + }DSU_COMM_PROTCL_STRU; + + /*豸ͨЭϢ*/ + typedef struct + { + UINT16 CommProtclStruLen; /*豸ͨЭ*/ + DSU_COMM_PROTCL_STRU *pCommProtclStru; /*豸ͨЭ*/ + }DSU_BOOK_IP_INFO_STRU; + + /* + *: dsuIpInit + *: RPѯʼ + *: UINT8 *pFsName FSļ + *: + *: + *ֵ: 1:ɹ;0ʧ + */ + UINT8 dsuIpInit(UINT8 *pFsName); + + /* + *: dsuRpGetDevType + *: 豸ƻȡ豸 + *: UINT16 DevName 豸 + *: + *: + *ֵ: 豸 + */ + UINT8 dsuRpGetDevType(UINT16 DevName); + + /* + *: dsuRpTypeId2DevName + *: IDȡ豸 + *: UINT8 Type 豸 + * UINT8 Id 豸ID + *: + *: UINT16 DevName 豸 + *ֵ: + */ + void dsuRpTypeId2DevName(UINT8 Type, UINT8 Id, UINT16* pDevName); + + /* + *: dsurRpGetProtclType + *: ݱƶԷƻȡЭ + *: UINT16 LocalName + * UINT16 DestName Է + *: + *: UINT8* protclTye Э + *ֵ: 1:ɹ;0ʧ + */ + UINT8 dsurRpGetProtclType(UINT16 LocalName, UINT16 DestName, UINT8* protclTye); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/redun_record_cbtc/common_redun/RpDeclare.h b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpDeclare.h new file mode 100644 index 0000000..46b0050 --- /dev/null +++ b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpDeclare.h @@ -0,0 +1,76 @@ + +/************************************************************************ +* ļRpDeclare.h +* ļļΪЭ鹫ͷļֵĺ궨嶼ڴļ +* ʱ䣺2009.11.16 +************************************************************************/ + +#ifndef _RPDECLARE_H +#define _RPDECLARE_H + + +/******************************************************************************** +궨 +********************************************************************************/ + + +/************************************************************************ + * ԭЭһ16bit + * D15~D12 + * D11~D10ȼ + * D9~D8ģλ + * D7~D4ģеĴģ鲻ͬʱ4λĺ岻ͬ + * ڶȵײ + * D3~D0ģǷͬ4λĺͬ +************************************************************************/ +/*ȼ*/ +#define RP_ERR 0x0800 +#define RP_WARN 0x0400 + +/*ģλ*/ +#define RP_RECEIVE 0x0200 /*ģ*/ +#define RP_OUTPUT 0x0100 /*ģ*/ + +/*ģд*/ +#define RP_ERROR_NULL 0x0000 +/**/ +#define RP_EDITION_ILLEGAL 0x0010 /*汾ŷǷ*/ +#define RP_SN_ILLEGAL 0x0020 /*кŲϷ*/ +#define RP_DESTNAME_ERR 0x0030 /*ĿName*/ +#define RP_QUEUE_OVLOAD 0x0040 /*ڶпռ䲻*/ +/**/ +#define RP_DBGET_ERR 0x0050 /*ݿѯ*/ +/*ײ㴦*/ +#define RP_QUEUE_READ 0x0001 /*жд*/ +#define RP_QUEUE_WRITE 0x0002 /*дд*/ +#define RP_QUEUE_INTEGRITY 0x0003 /*ݲscanдӦø*/ +#define RP_LNK_PUSH 0x0004 /*кŻڵѹջ*/ +#define RP_LNK_POP 0x0005 /*кŻڵջ*/ +#define RP_QUEUE_INTEGRITY_R 0x0006 /*г*/ +#define RP_QUEUE_INTEGRITY_B 0x0007 /*г*/ +#define RP_QUEUE_OVERLONG 0x0008 /*֡ݳ*/ + + +/******궨**************/ +#define RP_ERR_RECEIVE_RP_LNK_POP 0x00000001 /*ģкŻڵջ*/ +#define RP_WARN_RECEIVE_RP_QUEUE_INTEGRITY_R 0x00000002 /*ģг*/ +#define RP_WARN_RECEIVE_RP_QUEUE_INTEGRITY_B 0x00000004 /*ģг*/ +#define RP_WARN_RECEIVE_RP_QUEUE_READ 0x00000008 /*ģжд*/ +#define RP_WARN_RECEIVE_RP_EDITION_ILLEGAL 0x00000010 /*ģ汾ŷǷ*/ +#define RP_WARN_RECEIVE_RP_DESTNAME_ERR 0x00000020 /*ģĿƴ*/ +#define RP_WARN_RECEIVE_RP_SN_ILLEGAL 0x00000040 /*ģкŲϷ*/ +#define RP_WARN_RECEIVE_RP_QUEUE_OVLOAD 0x00000080 /*ģڶпռ䲻*/ + +#define RP_ERR_OUTPUT_RP_LNK_POP 0x00000100 /*ģкŻڵջ*/ +#define RP_WARN_OUTPUT_RP_QUEUE_OVERLONG 0x00000200 /*ģ֡ݳ*/ +#define RP_WARN_OUTPUT_RP_QUEUE_INTEGRITY 0x00000400 /*ģݲ*/ +#define RP_WARN_OUTPUT_RP_QUEUE_READ 0x00000800 /*ģжд*/ + + + + + + + +#endif + diff --git a/TSCP/src/protocol/redun_record_cbtc/common_redun/RpInterface.c b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpInterface.c new file mode 100644 index 0000000..4682be2 --- /dev/null +++ b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpInterface.c @@ -0,0 +1,1801 @@ +/************************************************************************ +* ļRpInterface.c +* ļЭԴļ +* ʱ䣺2009.10.08 +* ޸ļ¼ +* 2011.12.07 ӶRsrCommon.h +* 2011.12.07 RpLnkDeleteɾ· +************************************************************************/ +#include "stdlib.h" +#include "CommonMemory.h" +#include "RpStruct.h" +#include "RpInterface.h" +#include "Convert.h" +#include "CommonRecord.h" +#include "CommonStack.h" +#include "RpPlatform.h" +#include "RpDeclare.h" +#include "dsuRpFunc.h" + +/*崻¼Ϣ*/ +UINT32 gRpErrorInfo; + +UINT8 RpMemSet(UINT8 *pDestAdd, UINT16 Len, UINT8 Val); + +/************************************************************************* +* : +* ͨúʵڴռ +* ˵: +* [in]RP_INFO_STRU *pRpStruct ͬһṹ; +* ֵ: +* return 1 +* return 0쳣 +**************************************************************************/ +UINT8 RpInit(UINT8* fileName,RP_INFO_STRU *pRpStruct)/* %RELAX */ +{ + UINT32 temp; /*¼ҪĿռС*/ + UINT8 ret = 0; /*ֵ*/ + + if(pRpStruct == NULL) /* ǿռ */ + { + ret = 0; + return ret; + } + else + { + /* */ + } + + ret = dsuIpInit(fileName); + if (ret == 0) + { + return ret; + } + /*ʼڲݴ*/ + temp = pRpStruct->OutputSize>pRpStruct->InputSize?pRpStruct->OutputSize:pRpStruct->InputSize; + temp += 20; + pRpStruct->Buff_Rp = (UINT8 *)malloc(temp); + if(pRpStruct->Buff_Rp == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pRpStruct->Buff_Rp,sizeof(UINT8)*temp,0,sizeof(UINT8)*temp); + } + + /*Ϊ¼ռ*/ + pRpStruct->RecordArray = (UINT8 *)malloc(pRpStruct->RecordArraySize+2); + if(pRpStruct->RecordArray == NULL) + { + ret = 0; + return ret; + } + else + { + CommonMemSet(pRpStruct->RecordArray,sizeof(UINT8)*(pRpStruct->RecordArraySize+2),0,sizeof(UINT8)*(pRpStruct->RecordArraySize+2)); + } + + /*ΪAppArrayռ*/ + pRpStruct->AppArraySize= (pRpStruct->OutputSize+11+26)*(pRpStruct->MaxNumPerCycle)*(pRpStruct->MaxNumLink)+2; + pRpStruct->AppArray = (UINT8 *)malloc(pRpStruct->AppArraySize); + if(pRpStruct->AppArray == NULL) + { + ret = 0; + return ret; + } + else + { + CommonMemSet(pRpStruct->AppArray,sizeof(UINT8)*pRpStruct->AppArraySize,0,sizeof(UINT8)*pRpStruct->AppArraySize); + } + + /*ΪVarArrayռ*/ + pRpStruct->VarArraySize= 68 * (pRpStruct->MaxNumLink+2); /*68Ϊ·Ϣ*/ + pRpStruct->VarArray = (UINT8 *)malloc(pRpStruct->VarArraySize); + if(pRpStruct->VarArray == NULL) + { + ret = 0; + return ret; + } + else + { + CommonMemSet(pRpStruct->VarArray,sizeof(UINT8)*pRpStruct->VarArraySize,0,sizeof(UINT8)*pRpStruct->VarArraySize); + } + + /*ΪӦõĶDataToAppռ*/ + pRpStruct->DataToAppSize = (pRpStruct->InputSize + 4)*pRpStruct->MaxNumPerCycle*pRpStruct->MaxNumLink; + ret = QueueInitial(&pRpStruct->DataToApp, pRpStruct->DataToAppSize); + if(ret == 0) + { + return ret; + } + else + { + /*޲*/ + } + + /*ΪӦøĶOutputDataQueueռ*/ + pRpStruct->OutputDataQueueSize = (pRpStruct->OutputSize + 4)*pRpStruct->MaxNumPerCycle*pRpStruct->MaxNumLink; + ret = QueueInitial(&pRpStruct->OutputDataQueue, pRpStruct->OutputDataQueueSize); + if(ret == 0) + { + return ret; + } + else + { + /*޲*/ + } + + /*ΪӦøĶOutnetQueueAռ*/ + pRpStruct->OutnetQueueSize = (pRpStruct->InputSize + 2 + 11)*pRpStruct->MaxNumPerCycle*pRpStruct->MaxNumLink; + ret = QueueInitial(&pRpStruct->OutnetQueueA, pRpStruct->OutnetQueueSize); + if(ret == 0) + { + return ret; + } + else + { + /*޲*/ + } + + /*ΪӦøĶOutnetQueueBռ*/ + pRpStruct->OutnetQueueSize = (pRpStruct->InputSize + 2 +11)*pRpStruct->MaxNumPerCycle*pRpStruct->MaxNumLink; + ret = QueueInitial(&pRpStruct->OutnetQueueB, pRpStruct->OutnetQueueSize); + if(ret == 0) + { + return ret; + } + else + { + /*޲*/ + } + + /*кŻջռ*/ + StackInitial(&pRpStruct->SnLnkStack, (UINT16)pRpStruct->MaxNumLink); + + /*·ڵ洢ռ*/ + if(!Rp_init_SnStack(pRpStruct)) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + pRpStruct->SnLinkhead = NULL; + + ret = 1; + return ret; +} + +/*********************************************************************** + * : RpLnkDelete + * : ͨúӦÿɾ豸Ƶ· + * : + * + * -------------------------------------------------------------- + * devName UINT16 IN 豸 + * pdelDevSn RP_INFO_STRU * IN ͳһṹ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ + +UINT8 RpLnkDelete(UINT16 devName,RP_INFO_STRU *pdelDevSn) +{ + UINT8 ret = 0; + RpSNLINK_STRU *curIndex = NULL; + RpSNLINK_STRU *preIndex = NULL; + + curIndex = pdelDevSn->SnLinkhead; + while(curIndex != NULL) + { + if(curIndex->DestDevName == devName) + { + if(preIndex == NULL) + { + pdelDevSn -> SnLinkhead = curIndex->NextNode; + curIndex->DestDevName = 0; + curIndex->SnLink_Info.DestDevName = 0; + RpMemSet((UINT8 *)curIndex->SnLink_Info.SnArray,sizeof(curIndex->SnLink_Info.SnArray),0); + if( StackPush(&pdelDevSn->SnLnkStack,(UINT32)curIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + }/*if(һָpreIndex == NULL)*/ + /*ɾڵ㲻ͷڵ*/ + else + { + preIndex->NextNode = curIndex->NextNode; + curIndex->DestDevName = 0; + curIndex->SnLink_Info.DestDevName = 0; + RpMemSet((UINT8 *)curIndex->SnLink_Info.SnArray,sizeof(curIndex->SnLink_Info.SnArray),0); + if( StackPush(&pdelDevSn->SnLnkStack,(UINT32)curIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + } + + } + else + { + + } + preIndex = curIndex; + curIndex = curIndex->NextNode; + } + ret = 1; + return ret; +} + + +/************************************************************************************** + * + * ͷЭںRpInitзڴռ + * ڲ + * RP_INFO_STRU * pRpStruct ͳһṹ + * ֵ + * ɹ1ʧܷ0 + ***************************************************************************************/ +UINT8 RpFreeSpace(RP_INFO_STRU *pRpStruct)/* %RELAX */ +{ + UINT8 ret = 1; + + if(pRpStruct->Buff_Rp != NULL) + { + free((void *)pRpStruct->Buff_Rp); + pRpStruct->Buff_Rp = NULL; + } + else + { + /*޲*/ + } + + if(pRpStruct->RecordArray != NULL) + { + free((void *)pRpStruct->RecordArray); + pRpStruct->RecordArray = NULL; + } + else + { + /*޲*/ + } + + if(pRpStruct->AppArray != NULL) + { + free((void *)pRpStruct->AppArray); + pRpStruct->AppArray = NULL; + } + else + { + /*޲*/ + } + + if(pRpStruct->VarArray!= NULL) + { + free((void *)pRpStruct->VarArray); + pRpStruct->VarArray= NULL; + } + else + { + /*޲*/ + } + + QueueElementFree(&pRpStruct->DataToApp); + QueueElementFree(&pRpStruct->OutputDataQueue); + QueueElementFree(&pRpStruct->OutnetQueueA); + QueueElementFree(&pRpStruct->OutnetQueueB); + + StackFree(&pRpStruct->SnLnkStack); + + if(pRpStruct->pSnStack != NULL) + { + free((void *)pRpStruct->pSnStack); + pRpStruct->pSnStack = NULL; + } + else + { + /*޲*/ + } + + pRpStruct->SnLinkhead = NULL; /*ͷÿ*/ + + return ret; +} + +/***************************************************************************************** +*: +* ӺݣдDataToApp +*˵: +* RP_INFO_STRU *pRpStruct ͳһṹ +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpReceive(RP_INFO_STRU *pRpStruct)/* %RELAX */ +{ + UINT16 Length; /*¼ݳ*/ + UINT16 LocalDevNameInFrame; + UINT16 DestDevNameInFrame; + UINT32 SnInFrame; /*¼к*/ + UINT8 len[10]; + UINT8 temp[10]; + UINT16 lenthofData; /*ݳ*/ + UINT16 lenthofRcvA = 0; + UINT16 lenthofRcvB = 0;/*յÿ֡ݵij(len[2]ַתõ)*/ + UINT8 ToBeContinue = 0; /*1 Դ֡ݣֱӴ֡ݣ0*/ + UINT8 QueueReadFlag; /*¼ϴζȡǺ/еĸ*/ + UINT8 QueueAvailable; /*ȡʶ*/ + UINT8 RVQueueRead; /*жȡֵ*/ + UINT8 RcvQueueReadLenth; + UINT8 i = 0; + RpSNLINK_STRU* CurrentSnNode; + UINT8 ret; + UINT32 QueueCnt; + + QueueReadFlag = 0x55; + RVQueueRead = 0xFF; + QueueAvailable = 0; /*пñ־*/ + CurrentSnNode = NULL; + + if(pRpStruct == NULL) /* ǿռ */ + { + ret = 0; + return ret; + } + else + { + /* */ + } + + ShortToChar(0, pRpStruct->RecordArray); + +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Cycle:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"LName:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->LocalType,1); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->LocalID,1); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Rcv:\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*ڿʼ־*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0xf0); + /*뵥Ԫʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0xf2); + /*TypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->LocalType); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->LocalID); +#endif + + + for(i = 0; i < 10; i++) + { + len[i] = 0; + } + + while(1) + { + QueueAvailable = 0; + +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"IN:\n"); +#endif + /*жϺǷ*/ + if(QueueScan(5,len,&pRpStruct->OutnetQueueA) != 0) /*ɨȣ4ֽ*/ + { + lenthofRcvA = ShortFromChar(len);/*֡ij*/ + lenthofData = ShortFromChar(&len[3]);/*ݵij*/ + + if((lenthofRcvA > (pRpStruct->InputSize + 11))||(lenthofRcvA != (lenthofData + 11))) + { + /*յݳ,ǴӶж֡ݣһ֡Ķȡ*/ +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_INTEGRITY_R); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_INTEGRITY_R); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_INTEGRITY_R; + + + /*lenthofRcvA+2ֽݴӶж´ζȡ*/ + QueueElementDiscard( (UINT16)(lenthofRcvA + 2), &pRpStruct->OutnetQueueA); + + ToBeContinue = 1; /*ֱӽһεĶȡѭ*/ + } + else + { + QueueAvailable |= 0x0F; /*пñ־*/ + } + } + else + { + /*޲*/ + } + + /*жǷ*/ + if(QueueScan(5,len,&pRpStruct->OutnetQueueB) != 0) /*ɨȣ4ֽ*/ + { + lenthofRcvB = ShortFromChar(len);/*֡ij*/ + lenthofData = ShortFromChar(&len[3]);/*ݵij*/ + + if((lenthofRcvB> (pRpStruct->InputSize + 11))||(lenthofRcvB != (lenthofData + 11))) + { + /*¼¼յݳ*/ +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_INTEGRITY_B); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_INTEGRITY_B); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_INTEGRITY_B; + + + /*lenthofRcvB+2ֽݴӶж´ζȡ*/ + QueueElementDiscard( (UINT16)(lenthofRcvB + 2), &pRpStruct->OutnetQueueB); + + ToBeContinue = 1; /*ֱӽһεĶȡѭ*/ + } + else + { + QueueAvailable |= 0xF0; /*пñ־*/ + } + + } + else + { + /*޲*/ + } + + if(ToBeContinue == 0) + { + if(QueueAvailable == 0xFF)/*жɶ*/ + { + if(QueueReadFlag == 0x55)/*ϴζĶǺ*/ + { + /*Ϊ֡ͷֽڣΪԴ򲻱䣬ȶֽڣ*/ + RcvQueueReadLenth = QueueRead(2,pRpStruct->Buff_Rp,&pRpStruct->OutnetQueueB); + if(RcvQueueReadLenth != 1) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," \n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_READ; + + break; + } + + RVQueueRead = QueueRead( (UINT16)(lenthofRcvB),pRpStruct->Buff_Rp,&pRpStruct->OutnetQueueB); + QueueReadFlag = 0xAA;/*ζ*/ + +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"BNet:"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*һ֡ϢʼʶϢԴ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x40|0x0A); +#endif + } + else + { + /*Ϊ֡ͷֽڣΪԴ򲻱䣬ȶֽڣ*/ + RcvQueueReadLenth = QueueRead(2,pRpStruct->Buff_Rp,&pRpStruct->OutnetQueueA); + if(RcvQueueReadLenth != 1) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," \n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_READ; + + break; + } + + RVQueueRead = QueueRead( (UINT16)(lenthofRcvA),pRpStruct->Buff_Rp,&pRpStruct->OutnetQueueA); + QueueReadFlag = 0x55;/*ζ*/ +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"RNet:"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*һ֡ϢʼʶϢԴ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x40|0x05); +#endif + } + } + else if(QueueAvailable == 0x0F)/*пɶ*/ + { + /*Ϊ֡ͷֽڣΪԴ򲻱䣬ȶֽڣ*/ + RcvQueueReadLenth = QueueRead(2,pRpStruct->Buff_Rp,&pRpStruct->OutnetQueueA); + if(RcvQueueReadLenth != 1) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," \n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_READ; + + break;/*˳ѭ*/ + } + + RVQueueRead = QueueRead( (UINT16)(lenthofRcvA),pRpStruct->Buff_Rp,&pRpStruct->OutnetQueueA); + QueueReadFlag = 0x55;/*ζǺ*/ +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"RNet:"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*һ֡ϢʼʶϢԴ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x40|0x05); +#endif + } + else if(QueueAvailable == 0xF0)/*пɶ*/ + { + /*Ϊ֡ͷֽڣΪԴ򲻱䣬ȶֽڣ*/ + RcvQueueReadLenth = QueueRead(2,pRpStruct->Buff_Rp,&pRpStruct->OutnetQueueB); + if(RcvQueueReadLenth != 1) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," \n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_READ; + + break;/*˳ѭ*/ + } + + RVQueueRead = QueueRead( (UINT16)(lenthofRcvB),pRpStruct->Buff_Rp,&pRpStruct->OutnetQueueB); + QueueReadFlag = 0xAA;/*ζ*/ +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"BNet:"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*һ֡ϢʼʶϢԴ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x40|0x0A); +#endif + + } + else + { + break; /*˳whileѭ*/ + } + + if(RVQueueRead == 1) /*жǷԶ֡*/ + { + if(pRpStruct->Buff_Rp[0] != 0xFF) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_EDITION_ILLEGAL|RP_ERROR_NULL); + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," \n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_EDITION_ILLEGAL|RP_ERROR_NULL); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_EDITION_ILLEGAL; + + } + else + { + Length = ShortFromChar(&pRpStruct->Buff_Rp[1]); + + DestDevNameInFrame = ShortFromChar(&pRpStruct->Buff_Rp[3]); + LocalDevNameInFrame = ShortFromChar(&pRpStruct->Buff_Rp[5]); + if(LocalDevNameInFrame != pRpStruct->LocalType*0x100 + pRpStruct->LocalID) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_DESTNAME_ERR|RP_ERROR_NULL); + PrintFiles(pRpStruct->RecordArray, pRpStruct->RecordArraySize," \n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_DESTNAME_ERR|RP_ERROR_NULL); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_DESTNAME_ERR; + + } + else + { + SnInFrame = LongFromChar(&pRpStruct->Buff_Rp[7]); +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Len:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,Length); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"DN:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,DestDevNameInFrame); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"LN:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,LocalDevNameInFrame); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Sn:"); + PrintFileU32Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,SnInFrame); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Data:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->Buff_Rp[11],2); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼շ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->Buff_Rp[5]); + /*¼շID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->Buff_Rp[6]); + /*¼ͷ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->Buff_Rp[3]); + /*¼ͷID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->Buff_Rp[4]); + /*¼ͷSn*/ + PrintRecArray4ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,SnInFrame); + /*¼Ӧݳ*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,Length); +#endif + CurrentSnNode = Rp_SearchSnLnk(DestDevNameInFrame,pRpStruct); + if(CurrentSnNode == NULL) + { + CurrentSnNode = Rp_InsertLnk(DestDevNameInFrame,pRpStruct); + if(CurrentSnNode != NULL) + { + if(SnInFrame != 0x00) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_SN_ILLEGAL|RP_ERROR_NULL); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_SN_ILLEGAL|RP_ERROR_NULL); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_SN_ILLEGAL; + + + CurrentSnNode->SnLink_Info.SnArray[CurrentSnNode->SnLink_Info.SnArrayIndex++] = SnInFrame; + QueueCnt = QueueStatus(&pRpStruct->DataToApp); + QueueCnt = pRpStruct->DataToApp.qsize - QueueCnt; + if(QueueCnt >= (UINT32)(2 + 2 + Length)) + { + ShortToChar((UINT16)(Length + 2), temp); + ret =QueueWrite(2, temp, &pRpStruct->DataToApp); + + ret =QueueWrite(1, &pRpStruct->Buff_Rp[3], &pRpStruct->DataToApp); + + ret =QueueWrite(1, &pRpStruct->Buff_Rp[4], &pRpStruct->DataToApp); + + ret =QueueWrite(Length, &pRpStruct->Buff_Rp[11], &pRpStruct->DataToApp); +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"OUT:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Len:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,Length); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"SrcNm:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->Buff_Rp[3],2); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Data:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->Buff_Rp[11],2); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼дݵϢʼ־*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x80|0x00); + /*¼ͷ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->Buff_Rp[3]); + /*¼ͷID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->Buff_Rp[4]); + /*¼Ӧݳ*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,Length); +#endif + } + else + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_QUEUE_OVLOAD|RP_ERROR_NULL); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_QUEUE_OVLOAD|RP_ERROR_NULL); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_OVLOAD; + + } + } + else + { + /*֡*/ + } + } + else + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"E:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_ERR|RP_RECEIVE|RP_ERROR_NULL|RP_LNK_POP); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_ERR|RP_RECEIVE|RP_ERROR_NULL|RP_LNK_POP); +#endif + gRpErrorInfo |= RP_ERR_RECEIVE_RP_LNK_POP; + + } + } + else + { + if(SnInFrame == 0) + { + /*ýڵк飬0*/ + for(i = 0; i < 15; i++) + { + CurrentSnNode->SnLink_Info.SnArray[i] = 0; + } + CurrentSnNode->SnLink_Info.SnArrayIndex = 0; + + } + else + { + ret = Rp_IsSnExit(SnInFrame, CurrentSnNode); + if(ret == 1) + { + /*֡*/ + } + else + { + if(CurrentSnNode->SnLink_Info.SnArrayIndex > 14) + { + CurrentSnNode->SnLink_Info.SnArrayIndex = 0; + } + CurrentSnNode->SnLink_Info.SnArray[CurrentSnNode->SnLink_Info.SnArrayIndex++] = SnInFrame; + QueueCnt = QueueStatus(&pRpStruct->DataToApp); + QueueCnt = pRpStruct->DataToApp.qsize - QueueCnt; + if(QueueCnt >= (UINT32)(2 + 2 + Length)) + { + ShortToChar((UINT16)(Length + 2), temp); + ret =QueueWrite(2, temp, &pRpStruct->DataToApp); + + ret =QueueWrite(1, &pRpStruct->Buff_Rp[3], &pRpStruct->DataToApp); + + ret =QueueWrite(1, &pRpStruct->Buff_Rp[4], &pRpStruct->DataToApp); + + ret =QueueWrite(Length, &pRpStruct->Buff_Rp[11], &pRpStruct->DataToApp); +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"OUT:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Len:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,Length); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"SrcNm:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->Buff_Rp[3],2); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Data:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->Buff_Rp[11],2); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼дݵϢʼ־*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x80|0x00); + /*¼ͷ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->Buff_Rp[3]); + /*¼ͷID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->Buff_Rp[4]); + /*¼Ӧݳ*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,Length); +#endif + } + else + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_QUEUE_OVLOAD|RP_ERROR_NULL); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_QUEUE_OVLOAD|RP_ERROR_NULL); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_OVLOAD; + + } + } + } + } + } + } + } + else + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_RECEIVE|RP_ERROR_NULL|RP_QUEUE_READ); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_READ; + + break; + } + } + else + { + ToBeContinue = 0; + } + } + + ret = 1; + return ret; +} + +/***************************************************************************************** +*: +* ӦôOutputDataQueue֡дAppArrayVarArray +*˵: +* RP_INFO_STRU *pRpStruct ͳһṹ +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpOutput(RP_INFO_STRU *pRpStruct)/* %RELAX */ +{ + UINT32 QueueLength; + UINT16 Length; + UINT16 DestDevNameInFrame; + UINT16 LocalDevName; + RpSNLINK_STRU *CurrentSnLink; /*дAppArrayУָڵ*/ + RpSNLINK_STRU *CurNumLink; /*дVarArrayУָڵ*/ + UINT16 i = 0; + UINT16 j = 0; + UINT16 NumOfLink = 0; + UINT16 AppArray_Len = 0; /*AppAarryѴݳ*/ + UINT16 AppArray_Temp = 0; + UINT8 ret; + UINT8 RpGetLnkInfoRet; + UINT16 locDevName = 0; + UINT16 destDevName = 0; + UINT8 protclType =0; + + if(pRpStruct == NULL) /* ǿռ */ + { + ret = 0; + return ret; + } + else + { + /* */ + } + +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Output:\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*Ԫʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0xf3); + /*TypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->LocalType); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,pRpStruct->LocalID); +#endif + /*ӦõĽӿ*/ + ShortToChar(0, pRpStruct->AppArray); + + QueueLength = QueueStatus(&pRpStruct->OutputDataQueue); +#ifdef RP_RECORD_SIMPLIFY_BIN + /*Ӧ÷ݶܳ*/ + PrintRecArray4ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,QueueLength); +#endif + while(QueueLength > 2) + { + if(QueueRead(2, pRpStruct->Buff_Rp, &pRpStruct->OutputDataQueue)) + { + Length = ShortFromChar(pRpStruct->Buff_Rp); + + if(Length > pRpStruct->OutputSize + 2) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_OUTPUT|RP_ERROR_NULL|RP_QUEUE_OVERLONG); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_OUTPUT|RP_ERROR_NULL|RP_QUEUE_OVERLONG); +#endif + gRpErrorInfo |= RP_WARN_RECEIVE_RP_QUEUE_OVLOAD; + + + /*LengthֽݴӶж´ζȡ*/ + QueueElementDiscard( Length, &pRpStruct->OutputDataQueue); + + } + else if((UINT32)(Length + 2) > QueueLength) + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_OUTPUT|RP_ERROR_NULL|RP_QUEUE_INTEGRITY); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_OUTPUT|RP_ERROR_NULL|RP_QUEUE_INTEGRITY); +#endif + gRpErrorInfo |= RP_WARN_OUTPUT_RP_QUEUE_INTEGRITY; + + break; + } + else + { + if(QueueRead(Length, pRpStruct->Buff_Rp, &pRpStruct->OutputDataQueue)) + { + DestDevNameInFrame = ShortFromChar(pRpStruct->Buff_Rp); + LocalDevName = pRpStruct->LocalType * 0x100 + pRpStruct->LocalID; +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"IN:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Len:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,(UINT16)(Length -2)); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"DstNm:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,DestDevNameInFrame); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Data:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->Buff_Rp[2], 2); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*Ӷжݵʼʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x40|0x00); + /*ĿTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[0]); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[1]); + /*֡дӦݵij*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,(UINT16)(Length - 2)); +#endif + /*ȡͷͽշ豸ʶ*/ + dsuRpTypeId2DevName(pRpStruct->LocalType, pRpStruct->LocalID, &locDevName); + dsuRpTypeId2DevName(pRpStruct->Buff_Rp[0], pRpStruct->Buff_Rp[1], &destDevName); + /*ݷͷͽշ豸ʶȡЭ*/ + dsurRpGetProtclType(locDevName, destDevName, &protclType); + + /*ȡɹ*/ + CurrentSnLink = Rp_SearchSnLnk(DestDevNameInFrame,pRpStruct); + if(CurrentSnLink != NULL) + { + /*жǷ񷢳к0.LastSnΪ0ûзк0*/ + if(CurrentSnLink->SnLink_Info.LastSn == 0) + { + for(i = 0; i < 3; i ++) + { + /*ȡѴݳ*/ + AppArray_Len = ShortFromChar(pRpStruct->AppArray); + /*дкΪ0*/ + LongToChar(0, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_SN]); + /*д֡*/ + AppArray_Temp = 5 + 11; /*5 Э͡Ŀ豸ͺIDԤкΪ0дӦ*/ + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_FRAME_LEN]); + /*дЭ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_PTOTCL_TYPE] = protclType; + + /*дĿͺĿID*/ + ShortToChar(DestDevNameInFrame, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_DEVTYPE]); + /*Ԥֽ*/ + ShortToChar(0, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_RESERVED]); + /*д汾*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_EDITION] = 0xFF; + /*дϢij*/ + AppArray_Temp = 0; + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_TEXT_LEN]); + /*д뷢ͷʶ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_LOC_TYPEID] = pRpStruct->LocalType; + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_LOC_TYPEID + 1] = pRpStruct->LocalID; + /*дշʶ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_TYPEID] = pRpStruct->Buff_Rp[0]; + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_TYPEID + 1] = pRpStruct->Buff_Rp[1]; + + + AppArray_Temp = 7 + 11 + AppArray_Len; + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[0]); + + CurrentSnLink->SnLink_Info.LastSn = 0; +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"OUT:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Len:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Sn:"); + PrintFileU32Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurrentSnLink->SnLink_Info.LastSn); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"DstNm:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,ShortFromChar(pRpStruct->Buff_Rp)); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*緢͵ʼʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x80|0x00); + /*շTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[0]); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[1]); + /*ͷTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->LocalType); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->LocalID); + /*к*/ + PrintRecArray4ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurrentSnLink->SnLink_Info.LastSn); + /*֡дӦݵij*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0); +#endif + } + } + /*ȡѴݳ*/ + AppArray_Len = ShortFromChar(pRpStruct->AppArray); + /*дк*/ + if(CurrentSnLink->SnLink_Info.LastSn == 0xFFFFFFFF) + { + CurrentSnLink->SnLink_Info.LastSn = 0; + } + LongToChar((CurrentSnLink->SnLink_Info.LastSn + 1), &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_SN]); + /*д֡*/ + AppArray_Temp = 5 + Length - 2 + 11; /*5 Э͡Ŀ豸ͺIDԤlength -2Ǵݳ*/ + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_FRAME_LEN]); + /*дЭ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_PTOTCL_TYPE] = protclType; + /*дĿͺĿID*/ + ShortToChar(DestDevNameInFrame, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_DEVTYPE]); + /*Ԥֽ*/ + ShortToChar(0, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_RESERVED]); + /*д汾*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_EDITION] = 0xFF; + /*дϢij*/ + AppArray_Temp = Length - 2; + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_TEXT_LEN]); + /*д뷢ͷʶ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_LOC_TYPEID] = pRpStruct->LocalType; + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_LOC_TYPEID + 1] = pRpStruct->LocalID; + /*дշʶ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_TYPEID] = pRpStruct->Buff_Rp[0]; + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_TYPEID + 1] = pRpStruct->Buff_Rp[1]; + /*дϢ*/ + for(i = 0; i < Length - 2; i++) + { + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_TEXT + i] = pRpStruct->Buff_Rp[2 + i]; + } + + AppArray_Temp = 7 + 11 + Length - 2 + AppArray_Len; + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[0]); + + CurrentSnLink->SnLink_Info.LastSn++; +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"OUT:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Len:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,(UINT16)(Length -2)); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Sn:"); + PrintFileU32Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurrentSnLink->SnLink_Info.LastSn); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"DstNm:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,ShortFromChar(pRpStruct->Buff_Rp)); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Data:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->Buff_Rp[2], 2); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*緢͵ʼʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x80|0x00); + /*շTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[0]); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[1]); + /*ͷTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->LocalType); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->LocalID); + /*к*/ + PrintRecArray4ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurrentSnLink->SnLink_Info.LastSn); + /*֡дӦݵij*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,(UINT16)(Length - 2)); +#endif + } + else + { + CurrentSnLink = Rp_InsertLnk(DestDevNameInFrame,pRpStruct); + if(CurrentSnLink != NULL) + { + for(i = 0; i < 3; i ++) + { + /*ȡѴݳ*/ + AppArray_Len = ShortFromChar(pRpStruct->AppArray); + /*дкΪ0*/ + LongToChar(0, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_SN]); + /*д֡*/ + AppArray_Temp = 5 + 11; /*5 Э͡Ŀ豸ͺIDԤкΪ0дӦ*/ + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_FRAME_LEN]); + /*дЭ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_PTOTCL_TYPE] = protclType; + + /*дĿͺĿID*/ + ShortToChar(DestDevNameInFrame, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_DEVTYPE]); + /*Ԥֽ*/ + ShortToChar(0, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_RESERVED]); + /*д汾*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_EDITION] = 0xFF; + /*дϢij*/ + AppArray_Temp = 0; + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_TEXT_LEN]); + /*д뷢ͷʶ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_LOC_TYPEID] = pRpStruct->LocalType; + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_LOC_TYPEID + 1] = pRpStruct->LocalID; + /*дշʶ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_TYPEID] = pRpStruct->Buff_Rp[0]; + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_TYPEID + 1] = pRpStruct->Buff_Rp[1]; + + + AppArray_Temp = 7 + 11 + AppArray_Len; + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[0]); + + CurrentSnLink->SnLink_Info.LastSn = 0; +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"OUT:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Len:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Sn:"); + PrintFileU32Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurrentSnLink->SnLink_Info.LastSn); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"DstNm:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,ShortFromChar(pRpStruct->Buff_Rp)); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*緢͵ʼʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x80|0x00); + /*շTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[0]); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[1]); + /*ͷTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->LocalType); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->LocalID); + /*к*/ + PrintRecArray4ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurrentSnLink->SnLink_Info.LastSn); + /*֡дӦݵij*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0); +#endif + } + /*ȡѴݳ*/ + AppArray_Len = ShortFromChar(pRpStruct->AppArray); + /*дкΪ1*/ + LongToChar(1, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_SN]); + /*д֡*/ + AppArray_Temp = 5 + Length - 2 + 11; /*5 Э͡Ŀ豸ͺIDԤlength -2Ǵݳ*/ + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_FRAME_LEN]); + /*дЭ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_PTOTCL_TYPE] = protclType; + + /*дĿͺĿID*/ + ShortToChar(DestDevNameInFrame, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_DEVTYPE]); + /*Ԥֽ*/ + ShortToChar(0, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_RESERVED]); + /*д汾*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_EDITION] = 0xFF; + /*дϢij*/ + AppArray_Temp = Length - 2; + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_TEXT_LEN]); + /*д뷢ͷʶ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_LOC_TYPEID] = pRpStruct->LocalType; + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_LOC_TYPEID + 1] = pRpStruct->LocalID; + /*дշʶ*/ + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_TYPEID] = pRpStruct->Buff_Rp[0]; + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_DEST_TYPEID + 1] = pRpStruct->Buff_Rp[1]; + /*дϢ*/ + for(i = 0; i < Length - 2; i++) + { + pRpStruct->AppArray[AppArray_Len + 2 + OUTPUT_TEXT + i] = pRpStruct->Buff_Rp[2 + i]; + } + + AppArray_Temp = 7 + 11 + Length - 2 + AppArray_Len; + ShortToChar(AppArray_Temp, &pRpStruct->AppArray[0]); + + CurrentSnLink->SnLink_Info.LastSn = 1; +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"OUT:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Len:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,(UINT16)(Length -2)); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Sn:"); + PrintFileU32Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurrentSnLink->SnLink_Info.LastSn); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"DstNm:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,ShortFromChar(pRpStruct->Buff_Rp)); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Data:"); + PrintFileHex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,&pRpStruct->Buff_Rp[2], 2); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*緢͵ʼʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize,0x80|0x00); + /*շTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[0]); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[1]); + /*ͷTypeID*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->LocalType); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->LocalID); + /*к*/ + PrintRecArray4ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurrentSnLink->SnLink_Info.LastSn); + /*֡дӦݵij*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,(UINT16)(Length-2)); +#endif + } + else + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"E:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_ERR|RP_OUTPUT|RP_ERROR_NULL|RP_LNK_POP); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_ERR|RP_OUTPUT|RP_ERROR_NULL|RP_LNK_POP); +#endif + gRpErrorInfo |= RP_ERR_OUTPUT_RP_LNK_POP; + + } + } + } + else + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_OUTPUT|RP_ERROR_NULL|RP_QUEUE_READ); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_OUTPUT|RP_ERROR_NULL|RP_QUEUE_READ); +#endif + gRpErrorInfo |= RP_WARN_OUTPUT_RP_QUEUE_READ; + + break; + } + } + } + else + { +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"W:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_OUTPUT|RP_ERROR_NULL|RP_QUEUE_READ); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*¼*/ + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize,RP_WARN|RP_OUTPUT|RP_ERROR_NULL|RP_QUEUE_READ); +#endif + gRpErrorInfo |= RP_WARN_OUTPUT_RP_QUEUE_READ; + + break; + } + + QueueLength = QueueStatus(&pRpStruct->OutputDataQueue); + } + + CurNumLink = pRpStruct->SnLinkhead; + NumOfLink = 0; + + while(CurNumLink != NULL) + { + ShortToChar(CurNumLink->DestDevName, &pRpStruct->VarArray[2 + 68 * NumOfLink]); + ShortToChar(CurNumLink->SnLink_Info.SnArrayIndex, &pRpStruct->VarArray[4 + 68 * NumOfLink]); + LongToChar(CurNumLink->SnLink_Info.LastSn, &pRpStruct->VarArray[6 + 68 * NumOfLink]); +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Lnk:\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"DstNm:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurNumLink->DestDevName); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"Sn:"); + PrintFileU32Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurNumLink->SnLink_Info.LastSn); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + /*һ·ʼʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, 0xC0|0x00); + ShortToChar(CurNumLink->DestDevName, pRpStruct->Buff_Rp); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[0]); + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, pRpStruct->Buff_Rp[1]); + PrintRecArray4ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize, CurNumLink->SnLink_Info.LastSn); +#endif + +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"SnArray:"); +#endif + for(i = 0; i < 15; i++) + { + LongToChar(CurNumLink->SnLink_Info.SnArray[i], &pRpStruct->VarArray[10 + i *4 + 68 * NumOfLink]); +#ifdef RP_RECORD_ERR_ASC + PrintFileU32Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,CurNumLink->SnLink_Info.SnArray[i]); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize," "); +#endif +#ifdef RP_RECORD_SIMPLIFY_BIN + PrintRecArray4ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize, CurNumLink->SnLink_Info.SnArray[i]); +#endif + } +#ifdef RP_RECORD_ERR_ASC + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif + NumOfLink++; + CurNumLink = CurNumLink->NextNode; + } + + ShortToChar((UINT16)(68 * NumOfLink), pRpStruct->VarArray); + +#ifdef RP_RECORD_SIMPLIFY_BIN + /*Ԫʶ*/ + PrintRecArrayByte(pRpStruct->RecordArray,pRpStruct->RecordArraySize, 0xE0|0x00); + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize, AppArray_Temp); + PrintRecArray2ByteB(pRpStruct->RecordArray,pRpStruct->RecordArraySize, (UINT16)(68 * NumOfLink)); +#endif +#ifdef RP_RECORD_ERR_ASC + Length = ShortFromChar(pRpStruct->RecordArray); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"RcdLen:"); + PrintFileU16Hex(pRpStruct->RecordArray,pRpStruct->RecordArraySize,Length); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); + PrintFiles(pRpStruct->RecordArray,pRpStruct->RecordArraySize,"\n"); +#endif + + ret = 1; + return ret; +} + +/***************************************************************************************** +*: +* ˢм +*˵: +* RP_INFO_STRU *pRpStruct ͳһṹ +* UINT16 sLen_Input м +* UINT8 *Input_Data_LnkMes м +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpRefresh(UINT16 sLen_Input, UINT8 *Input_Data_LnkMes,RP_INFO_STRU *pRpStruct)/* %RELAX */ +{ + UINT8 NumOfLink, i = 0, j = 0, ret = 0; + RpSNLINK_STRU *TempIndex=NULL; + RpSNLINK_STRU *LastIndex=NULL; + STACK_DATA_TYPE pData; + UINT8 popret; + + if((pRpStruct == NULL)||(Input_Data_LnkMes == NULL)) /* ǿռ */ + { + ret = 0; + return ret; + } + else + { + /* */ + } + + /*ýڵַѹջ*/ + TempIndex = pRpStruct->SnLinkhead; + while(TempIndex != NULL) + { + StackPush(&pRpStruct->SnLnkStack,(STACK_DATA_TYPE)TempIndex); + TempIndex = TempIndex->NextNode; + } + pRpStruct->SnLinkhead = NULL; + + if(sLen_Input%68 != 0) + { + /*¼*/ + ret = 0; + return ret; + } + else if(sLen_Input == 0) + { + /*¼*/ + ret = 1; + return ret; + } + else + { + NumOfLink = (UINT8)(sLen_Input / 68); /*ڵϢ68ֽ*/ + + for(i = 0; i < NumOfLink; i++) + { + /*ȡڵڴ;*/ + popret = StackPop(&pRpStruct->SnLnkStack, &pData); + if(0 == popret) + { + ret = 0; + return ret; /*ûпõڴڵ*/ + } + else /*Ϊڵ·Ϣֵ*/ + { + TempIndex = (RpSNLINK_STRU *)pData; + TempIndex->DestDevName = ShortFromChar(&Input_Data_LnkMes[i * 68+ 0]); + TempIndex->SnLink_Info.DestDevName = ShortFromChar(&Input_Data_LnkMes[i * 68+ 0]); + TempIndex->SnLink_Info.SnArrayIndex= ShortFromChar(&Input_Data_LnkMes[i * 68+ 2]); + TempIndex->SnLink_Info.LastSn= LongFromChar(&Input_Data_LnkMes[i * 68+ 4]); + for(j = 0; j < 15; j++) + { + TempIndex->SnLink_Info.SnArray[j] = LongFromChar(&Input_Data_LnkMes[i * 68+ 8 + 4 * j]); + } + } + + if(i == 0) /*һβΪͷڵ*/ + { + pRpStruct->SnLinkhead = TempIndex; + } + else + { + LastIndex->NextNode = TempIndex; + } + LastIndex = TempIndex; + } + TempIndex->NextNode = NULL; + + ret = 1; + return ret; + } +} + +/*************************************************************************************************************** +: + ʼкŻջ +˵: + RP_INFO_STRU *pRpStruct ͳһṹ +ֵ: + ɹ1,ʧܷ0 + + ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +***************************************************************************************************************/ +UINT8 Rp_init_SnStack(RP_INFO_STRU *pRpStruct) +{ + UINT16 i;/*ѭ*/ + RpSNLINK_STRU *SnLnk_stack = NULL; + UINT8 ret; + + if(pRpStruct->SnLnkStack.pStackData != NULL) + { + for(i = 0;i < pRpStruct->SnLnkStack.TotalSize;i++) + { + pRpStruct->SnLnkStack.pStackData[i] = 0;/*ԸֵΪָ룬൱Ӧڴ*/ + } + } + else + { + ret = 0; + return ret; + } + + SnLnk_stack = (RpSNLINK_STRU *)malloc(sizeof(RpSNLINK_STRU) * pRpStruct->SnLnkStack.TotalSize); + if(SnLnk_stack == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(SnLnk_stack,sizeof(RpSNLINK_STRU) * pRpStruct->SnLnkStack.TotalSize,0,sizeof(RpSNLINK_STRU) * pRpStruct->SnLnkStack.TotalSize); + } + for (i = 0;i < pRpStruct->SnLnkStack.TotalSize;i++) + { /*ѹtotalsizeڵ*/ + if(StackPush(&pRpStruct->SnLnkStack,(UINT32)&SnLnk_stack[i]) != 1) + { + ret = 0; + return ret;/*ѹڵʧ*/ + } + else + { + /*޲*/ + } + } + pRpStruct->pSnStack = (UINT32 *) SnLnk_stack; + + ret = 1; + return ret; +} + +/******************************************************************************************* +: + ѯ·нڵָIJкŻѯ·ɶλ·Ĺ +˵: + [in] UINT16 Dest_DevName Է豸Type+ID + RP_INFO_STRU *pRpStruct ͳһṹ +ֵ: + ڵĵַָ + + 1. ݶԷ豸кŻвѯӦ·ش˽ڵָ +*******************************************************************************************/ +RpSNLINK_STRU* Rp_SearchSnLnk(UINT16 Dest_DevName,RP_INFO_STRU *pRpStruct) +{ + RpSNLINK_STRU *CurIndex; + RpSNLINK_STRU *pret; + + /*ǰָͷָ뿪ʼ*/ + CurIndex = pRpStruct->SnLinkhead; + + while(1) + { + if(CurIndex != NULL) + { + /*ҵҪѯڵ*/ + if(Dest_DevName == CurIndex->DestDevName) + { + return CurIndex;/*صǰָ*/ + } + else + { + CurIndex = CurIndex->NextNode; /*ûҵҪɾڵ㣬ǰָ붼һڵ*/ + } + } /* if(CurIndex != NULL)*/ + else + { + pret = NULL; + return pret; /*ûҵҪ·*/ + } + }/*while(1)*/ +} + +/******************************************************************************************* +: + ָĽڵ뵽кŻй涨λ +˵: + [in]UINT16 Dest_DevName Է豸 + RP_INFO_STRU *pRpStruct ͳһṹ +ֵ: + ǰ·ָ + + 1·뵽кŻ + 2Ϊ·һЩϢ +*******************************************************************************************/ +RpSNLINK_STRU* Rp_InsertLnk( UINT16 Dest_DevName,RP_INFO_STRU *pRpStruct) +{ + RpSNLINK_STRU *LastIndex; + RpSNLINK_STRU *CurIndex; + RpSNLINK_STRU *TempIndex; + STACK_DATA_TYPE pData; + UINT8 i; + + UINT8 popret; + RpSNLINK_STRU *pret; + + /*ǰָͷָ뿪ʼ*/ + CurIndex = pRpStruct->SnLinkhead; + TempIndex = NULL; + LastIndex = NULL; + + /*·*/ + while(1) + { + /*·Ѿнڵ*/ + if(CurIndex != NULL) + { + /*ڵڵǰڵ,ڵǰڵ֮ǰ*/ + if( Dest_DevName >CurIndex ->DestDevName) + { + /*ȡڵڴ;*/ + popret = StackPop(&pRpStruct->SnLnkStack, &pData); + if(0 == popret) + { + pret = NULL; + return pret; /*ûпõڴڵ*/ + } + else + { + TempIndex = (RpSNLINK_STRU *)pData; + /*ĿNameֵ*/ + TempIndex->DestDevName = Dest_DevName; + TempIndex->SnLink_Info.DestDevName = Dest_DevName; + TempIndex->SnLink_Info.SnArrayIndex= 0; + TempIndex->SnLink_Info.LastSn = 0; + for(i = 0;i < 15;i++) + { + TempIndex->SnLink_Info.SnArray[i] = 0; + } + } + /*ָһڵָǰָ*/ + TempIndex->NextNode = CurIndex; + + /*ڵΪһڵ,ͷڵó²ڵ*/ + if(LastIndex == NULL) + { + pRpStruct->SnLinkhead = TempIndex; + } + /*ڵ㲻Ϊһڵ㣬һڵָڵ*/ + else + { + LastIndex->NextNode = TempIndex; + } + + /*ز뵱ǰַָѭ*/ + return TempIndex; + } + /*ڵѾڣעǷҪ¸*/ + else if( Dest_DevName == CurIndex ->DestDevName) + { + /*ĿNameֵ*/ + CurIndex->DestDevName = Dest_DevName; + CurIndex->SnLink_Info.DestDevName = Dest_DevName; + CurIndex->SnLink_Info.SnArrayIndex= 0; + CurIndex->SnLink_Info.LastSn = 0; + for(i = 0;i < 15;i++) + { + CurIndex->SnLink_Info.SnArray[i] = 0; + } + + /*ѭ*/ + return CurIndex; + } + /*ڵСڵǰڵ㣬ǰһڵһڵ*/ + else + { + LastIndex = CurIndex; + CurIndex = CurIndex->NextNode; + } + } + /*ڵΪһڵ||ڵΪһڵ*/ + else + { + /*ȡڵڴ*/ + popret = StackPop(&pRpStruct->SnLnkStack, &pData); + if(0 == popret) + { + pret = NULL; + return pret; /*ûпõڴڵ*/ + } + else + { + TempIndex = (RpSNLINK_STRU *)pData; + /*ĿNameֵ*/ + TempIndex->DestDevName = Dest_DevName; + TempIndex->SnLink_Info.DestDevName = Dest_DevName; + TempIndex->SnLink_Info.SnArrayIndex= 0; + TempIndex->SnLink_Info.LastSn = 0; + for(i = 0;i < 15;i++) + { + TempIndex->SnLink_Info.SnArray[i] = 0; + } + } + + + /*ڵΪһڵ㣬Ϊͷڵһڵ*/ + if(LastIndex == NULL) + { + /*ͷָ븳ֵ*/ + pRpStruct->SnLinkhead= TempIndex; + } + /*ڵΪһڵ㣬ýڵ뵽һڵλ*/ + else + { + LastIndex->NextNode = TempIndex; + } + /*ָһڵָΪ*/ + TempIndex->NextNode = NULL; + + /*ز뵱ǰַָ*/ + return TempIndex; + } + } +} + +/******************************************************************************************* +*: +* жкڻǷѾ洢 +*˵: +* UINT32 Sn Ҫѯк +* RpSNLINK_STRU* SnNode кŻбڵ +*ֵ +* return 1 +* return 0 +********************************************************************************************/ +UINT8 Rp_IsSnExit(UINT32 Sn, RpSNLINK_STRU* SnNode) +{ + UINT8 i, ret = 0; + + if(SnNode == NULL) + { + return ret; + } + + for(i = 0; i < 15; i++) /*洢15к*/ + { + if(SnNode->SnLink_Info.SnArray[i] == Sn) + { + ret = 1; + return ret; + } + } + + return ret; +} + + +/*-------------------------------------------------------------------- + * RSRڹú Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : MemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pDestAdd UINT8 * INOUT ڴռ俪ʼַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : 1 + ***********************************************************************/ +UINT8 RpMemSet(UINT8 *pDestAdd, UINT16 Len, UINT8 Val) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = Val; + } + + return (UINT8)1; +} +/******************************************************************************************************* +* : RPЭ鶪ͷ崻 +* : +* : +* : gRpErrorInfo +* ȫֱ: gRpErrorInfo +* ֵ: gRpErrorInfo +*******************************************************************************************************/ + +UINT32 GetRpErrorInfo(void) +{ + UINT32 ret = 0; + ret = gRpErrorInfo; + return ret; +} +/******************************************************************************************************* +* : RPЭ鶪ͷ崻븴λ +* : +* : +* : gRpErrorInfo +* ȫֱ: gRpErrorInfo +* ֵ: 1:ɹ +*******************************************************************************************************/ + +UINT32 ReSetRpErrorInfo(void) +{ + UINT32 ret = 1; + gRpErrorInfo = 0; + return ret; +} + diff --git a/TSCP/src/protocol/redun_record_cbtc/common_redun/RpInterface.h b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpInterface.h new file mode 100644 index 0000000..cb45263 --- /dev/null +++ b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpInterface.h @@ -0,0 +1,42 @@ +/************************************************************************ +* ļRpInterface.h +* ļ +* ļΪЭ麯ͷļջغļ¼غ +* ʱ䣺2009.10.08 +************************************************************************/ +#ifndef _RPINTERFACE_H +#define _RPINTERFACE_H + +#include "RpStruct.h" +#include "RpPlatform.h" + +#define OUTPUT_FRAME_LEN 0 /**/ +#define OUTPUT_PTOTCL_TYPE (OUTPUT_FRAME_LEN+2) +#define OUTPUT_DEST_DEVTYPE (OUTPUT_PTOTCL_TYPE+1) /**/ +#define OUTPUT_DEST_DEVID (OUTPUT_DEST_DEVTYPE+1) /**/ +#define OUTPUT_RESERVED (OUTPUT_DEST_DEVID+1) +#define OUTPUT_EDITION (OUTPUT_RESERVED+2) /**/ +#define OUTPUT_TEXT_LEN (OUTPUT_EDITION+1) /**/ +#define OUTPUT_LOC_TYPEID (OUTPUT_TEXT_LEN+2) /**/ +#define OUTPUT_DEST_TYPEID (OUTPUT_LOC_TYPEID+2) /**/ +#define OUTPUT_SN (OUTPUT_DEST_TYPEID+2) /**/ +#define OUTPUT_TEXT (OUTPUT_SN+4) /**/ + +#ifdef __cplusplus +extern "C" { +#endif + +UINT8 Rp_init_SnStack(RP_INFO_STRU *pRpStruct); +RpSNLINK_STRU* Rp_SearchSnLnk(UINT16 Dest_DevName,RP_INFO_STRU *pRpStruct); +RpSNLINK_STRU* Rp_InsertLnk( UINT16 Dest_DevName,RP_INFO_STRU *pRpStruct); +UINT8 Rp_IsSnExit(UINT32 Sn, RpSNLINK_STRU* SnNode); +UINT32 GetRpErrorInfo(void); +UINT32 ReSetRpErrorInfo(void); + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/redun_record_cbtc/common_redun/RpPlatform.h b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpPlatform.h new file mode 100644 index 0000000..e99ab51 --- /dev/null +++ b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpPlatform.h @@ -0,0 +1,130 @@ +/************************************************************************ +* ļRpPlatform.h +* ļЭ鹫ýṹͷļ +* ʱ䣺2009.11.17 +* ޸ļ¼ +* 2012-8-15 15:54:00 ޸ļ¼ +* 1.RPЭ汾ź궨 +************************************************************************/ + +#ifndef _RPPLATFORM_H +#define _RPPLATFORM_H + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "CommonStack.h" +#include "RpStruct.h" +#include "RpConfig.h" + +/* RPЭ汾Ŷ */ +#define RPCODE_VER_PRODUCT_NO 66 +#define RPCODE_VER_MODULE_NO 2 +#define RPCODE_VER_MAIN_VER 2 +#define RPCODE_VER_SUB_VER 0 + +#ifdef __cplusplus +extern "C" { +#endif + + +/*ͳһṹ*/ +typedef struct Rp_Info +{ + UINT8 LocalID; /*豸ID*/ + UINT8 LocalType; /*豸type*/ + UINT8 MaxNumLink; /*ͨŵĶ*/ + UINT8 MaxNumPerCycle; /*һÿЧ*/ + UINT16 InputSize; /*һ֡Ӧݳ*/ + UINT16 OutputSize; /*㷢һ֡Ӧݳ*/ + UINT8* RecordArray; /*¼*/ + UINT16 RecordArraySize; /*¼С*/ + UINT8* AppArray; /*ģij1ʾ*/ + UINT16 AppArraySize; /*ģij鳤*/ + UINT8* VarArray; /*ģij2ʾм*/ + UINT16 VarArraySize; /*ģij鳤*/ + QueueStruct DataToApp; /*ЭӦõݶ*/ + UINT32 DataToAppSize; /*ЭӦõݶг*/ + QueueStruct OutputDataQueue; /*ӦøЭݶ*/ + UINT32 OutputDataQueueSize; /*ӦøЭݶг*/ + QueueStruct OutnetQueueA; /*նA(->)*/ + QueueStruct OutnetQueueB; /*նB(->)*/ + UINT32 OutnetQueueSize; /*նгȣЭʼʱд*/ + RpSNLINK_STRU *SnLinkhead; /*кŻͷָ*/ + CommonStack SnLnkStack; /*кŻջ*/ + UINT32 *pSnStack; /*ָջռ䣬ͷſռʱʹ*/ + UINT8 *Buff_Rp; /*ʱݻ*/ +} RP_INFO_STRU ; + +/************************************************************************* +* : +* ͨúʵڴռ +* ˵: +* [in]RP_INFO_STRU *pRpStruct ͬһṹ; +* ֵ: +* return 1 +* return 0쳣 +**************************************************************************/ +UINT8 RpInit(UINT8* fileName,RP_INFO_STRU *pRpStruct); + +/*********************************************************************** + * : RpLnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * devName UINT16 IN 豸 + * pdelDevSn RP_INFO_STRU * IN ͳһṹ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ + +UINT8 RpLnkDelete(UINT16 devName,RP_INFO_STRU *pdelDevSn); + +/************************************************************************************** + * + * ͷЭںRpInitзڴռ + * ڲ + * RP_INFO_STRU * pRpStruct ͳһṹ + * ֵ + * + ***************************************************************************************/ +UINT8 RpFreeSpace(RP_INFO_STRU *pRpStruct); + +/***************************************************************************************** +*: +* ӺݣдDataToApp +*˵: +* RP_INFO_STRU *pRpStruct ͳһṹ +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpReceive(RP_INFO_STRU *pRpStruct); + +/***************************************************************************************** +*: +* ӦôOutputDataQueue֡дAppArrayVarArray +*˵: +* RP_INFO_STRU *pRpStruct ͳһṹ +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpOutput(RP_INFO_STRU *pRpStruct); + +/***************************************************************************************** +*: +* ˢм +*˵: +* RP_INFO_STRU *pRpStruct ͳһṹ +* UINT16 sLen_Input м +* UINT8 *Input_Data_LnkMes м +*ֵ: +* ȷ1󷵻0; +*****************************************************************************************/ +UINT8 RpRefresh(UINT16 sLen_Input, UINT8 *Input_Data_LnkMes,RP_INFO_STRU *pRpStruct); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/protocol/redun_record_cbtc/common_redun/RpStruct.h b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpStruct.h new file mode 100644 index 0000000..7f5b9fc --- /dev/null +++ b/TSCP/src/protocol/redun_record_cbtc/common_redun/RpStruct.h @@ -0,0 +1,43 @@ +/************************************************************************ +* ļRpStruct.h +* ļЭ鹫ýṹͷļ +* ʱ䣺2009.10.07 +* ޸ļ¼ +************************************************************************/ + +#ifndef _RPSTRUCT_H +#define _RPSTRUCT_H + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "CommonStack.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*кŻڵϢ*/ +typedef struct +{ + UINT16 DestDevName; /*Է豸ʶ*/ + UINT16 SnArrayIndex; /*ֵ*/ + UINT32 LastSn; /*ϴη͵кţ0ʾһη*/ + UINT32 SnArray[15]; /*кŻ*/ +} RpSNLINK_INFO_STRU; + +/*кŻ*/ +typedef struct RLPStSnLink_Node +{ + UINT16 DestDevName; /*Է豸ʶ*/ + RpSNLINK_INFO_STRU SnLink_Info; /*ڵ·Ϣ*/ + struct RLPStSnLink_Node *NextNode; /*һIDͨŶԷе׵ַ*/ +} RpSNLINK_STRU ; + +#ifdef __cplusplus +} +#endif + +#else +#endif + + diff --git a/TSCP/src/protocol/redun_record_cbtc/common_redun_record_config/RpConfig.h b/TSCP/src/protocol/redun_record_cbtc/common_redun_record_config/RpConfig.h new file mode 100644 index 0000000..b00df89 --- /dev/null +++ b/TSCP/src/protocol/redun_record_cbtc/common_redun_record_config/RpConfig.h @@ -0,0 +1,26 @@ + +/******************************************************************************* +* ļ RpConfig.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2010.05.04 +* +* ļΪRPЭļ ¼ܴ +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + +#ifndef _RPCONFIG_H +#define _RPCONFIG_H + +/**************************Э¼궨忪**********************************/ + +/*#define RP_RECORD_ERR_ASC*/ /* ַʽ¼ */ + +#define RP_RECORD_SIMPLIFY_BIN /* ԶƷʽ¼ */ + +#else +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrDataStru.h b/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrDataStru.h new file mode 100644 index 0000000..36a6835 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrDataStru.h @@ -0,0 +1,114 @@ +/******************************************************************************* +* +* ļ dsuRsrDataStru.h +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* RSRЭصdsuѯṹ嶨壬ڲʹ +* ʹע⣺ +* ޸ļ¼ +* +*******************************************************************************/ +#ifndef _DSU_RSR_DATA_STRU_H +#define _DSU_RSR_DATA_STRU_H + +#include "CommonTypes.h" + + +/*󳤶ڴ洢ݿ*/ +#define DSURSR_MAX_RSSP_INFO_NUM 250 /*ݿ ֵ*/ +#define DSURSR_MAX_K_NUM 31 /*ݿɢֵ*/ +#define MAX_PLATFORM_PER_CI 7 /*CIplatform*/ + +#define DSU_RSSP_LNK_INFO_STRU_SIZE (DSURSR_MAX_K_NUM*8+35) /*rssp lnk Ϣṹ峤*/ +#define DSU_CI_PLATFORM_INFO_STRU_SIZE (MAX_PLATFORM_PER_CI+2) /*ƽ̨ݽṹ峤*/ +#define DSU_DEVICE_COMM_INFO_STRU_SIZE 11 + + +#ifdef __cplusplus +extern "C" { +#endif +/*½ṹ嶨dsuݿеݴ洢ⷢ*/ + +/*rssp lnk Ϣṹ*/ +typedef struct +{ + UINT16 Id; + UINT16 EmitterNameOrLogicId; /*豸ʶڹ̶˵һϢʶƶ˵һ洢Logic Id*/ + UINT16 ReceptorNameOrLogicId; /*豸ʶڹ̶˵һϢʶƶ˵һ洢Logic Id*/ + UINT16 ChannelNumber; /*ͨ*/ + UINT32 SID_NUMBER_E; /* ݿ⣬ֵΪͷSID*/ + UINT32 SINIT_NUMBER; /* ݿ*/ + UINT8 DATANUM; /*ݿ*/ + UINT32 DATAVER_1_Number; /*ݿ*/ + UINT16 RsspAddr; /*RSSP_Source_Address*/ + INT16 BsdAddr; /*BSD_Destination_Address*/ + UINT16 SseAddr; /*ʾSSE_SSR_Destination_Addresݿ*/ + UINT32 SID_NUMBER_R; /* ݿ⣬ֵΪܷSID*/ + UINT32 PREC_FIRSTSINIT ; /*ʾ׸SINIT*/ + UINT32 PREC_SINIT_K[DSURSR_MAX_K_NUM]; /*ʾSINITֵ*/ + UINT32 POST_RXDADA_K[DSURSR_MAX_K_NUM];/*ʾBSD̶ֵ*/ + +}DSU_RSSP_LNK_INFO_STRU; + +/*ƽ̨ݽṹ*/ +typedef struct +{ + UINT8 CIId; /*platformӦCIid*/ + UINT8 CIPlatformNum;/*CIplatform*/ + UINT8 CIPlatformId[MAX_PLATFORM_PER_CI];/*CIplatform Id*/ +}DSU_CI_PLATFORM_INFO_STRU; + +/*豸ͨԱ*/ +typedef struct +{ + UINT16 EmitterType; /*豸*/ + UINT16 ReceptorType; /*豸*/ + UINT8 MaxLost; /*LOST*/ + UINT8 DLost; /*ʱ*/ + UINT8 WSsrOut; /*ȴSSRʱ*/ + UINT8 AntiDelayCount; /*ͬ*/ + UINT8 TOut; /*ijʱ*/ + UINT8 MsgId; /*ʾϢID뱨ķء*/ + UINT8 IftVer; /*ʾӿڰ汾ţ뱨ķ*/ +}DSU_DEVICE_COMM_INFO_STRU; + +typedef struct +{ + /*źŲݳȺ*/ + + /*RsspLnkϢݳȺݣƶԹ̶*/ + UINT16 RsspInfoStruLenVobc2CiLen; + DSU_RSSP_LNK_INFO_STRU RsspLnkInfoVobc2CiStruBuf[DSURSR_MAX_RSSP_INFO_NUM]; + + /*RsspLnkϢݳȺݣ̶Թ̶*/ + UINT16 RsspInfoStruLenZcvsCiLen; + DSU_RSSP_LNK_INFO_STRU RsspLnkInfoZcvsCiStruBuf[DSURSR_MAX_RSSP_INFO_NUM]; + + /*RsspLnkϢݳȺ,̶ƶ*/ + UINT16 RsspInfoStruLenCi2VobcLen; + DSU_RSSP_LNK_INFO_STRU RsspLnkInfoCi2VobcStruBuf[DSURSR_MAX_RSSP_INFO_NUM]; + + + /*RsspLnkϢݳȺ,̶ƶ*/ + UINT16 RsspInfoStruLen; + DSU_RSSP_LNK_INFO_STRU *pRsspLnkInfoStru; + + /*ƽ̨CIϢݳȺ*/ + UINT16 CIPlatFormInfoStruLen; + DSU_CI_PLATFORM_INFO_STRU *pCIPlatFormInfoStru; + + /*ͨŹϵṹ*/ + UINT16 DeviceCommStruLen; + DSU_DEVICE_COMM_INFO_STRU* pDevCommInfoStru; + +}DSU_RSR_INFO_STRU; + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrFunc.c b/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrFunc.c new file mode 100644 index 0000000..e9484f0 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrFunc.c @@ -0,0 +1,1377 @@ +/******************************************************************************* +* +* ļ dsuRsrFunc.c +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* RSRЭصdsuѯ +* ʹע⣺ +* ޸ļ¼ +* +*******************************************************************************/ + + +#include "dsuRsrFunc.h" +#include "CommonMemory.h" +#include "Convert.h" +#include "dsuRsrDataStru.h" +#include "dfsDataRead.h" +#include "dquDataTypeDefine.h" + + +#define DSU_SSTY_INDEX 0 +#define DSU_SSID_INDEX 1 + +DSU_RSR_INFO_STRU dsuRsrInfoStru; /*ڱRSRϢĽṹ*/ +DSU_RSR_INFO_STRU* pDsuRsrInfoStru; /*ǰڲݿ.*/ + +/* +* úڲѯźŲ㱨ǷϷ +* ѯݿǷиͨŹϵ +* UINT16 localName, ʾԴʶTYPEǰIDں +* UINT8 localLogId,ʾԴ̬ID +* UINT16 DestName, ʾĿıʶTYPEǰIDں +* UINT8 DestLogId, ʾĵĶ̬ID +* UINT8 ItfVer, ʾӿڰ汾ţ뱨ķ +* UINT8 MsgId,ʾϢID뱨ķء +* UINT8* pIsLegalRole,ʾͨŹϵǷݿ +* 1ʾϷݿڸͨŹϵ +* 0ʾϷݿвڸͨŹϵ +* ֵ1ɹݲһϷ +* 0ʧܣ +*/ +UINT8 dsuSigIsLegal(UINT16 LocalName, UINT8 LocalLogId,UINT16 DestName, UINT8 DestLogId, UINT8 ItfVer, UINT8 MsgId,UINT8* pIsLegalRole) +{ + UINT8 ByLocalName[2]; /*Դʶ*/ + UINT8 ByDestName[2]; /*Ŀʶ*/ + UINT16 i; /*ѭ*/ + DSU_DEVICE_COMM_INFO_STRU* pTempDevCommInfoStru; + UINT8 chReturnValue; + + /*жͨŹϵǷϷ*/ + chReturnValue=dsuRsrCheckSigRelationLegal(LocalName,LocalLogId,DestName,DestLogId); + if (chReturnValue==0) + { + /*ͨŹϵϷ*/ + * pIsLegalRole=DSURSR_FALSE; + chReturnValue=1; + return chReturnValue; + } + + /*ıʶֳsstyssid*/ + ShortToChar(LocalName,ByLocalName); + ShortToChar(DestName,ByDestName); + + pTempDevCommInfoStru=pDsuRsrInfoStru->pDevCommInfoStru; + for (i=0;iDeviceCommStruLen;i++) + { + if ((ByLocalName[DSU_SSTY_INDEX]==pTempDevCommInfoStru->EmitterType) + &&(ByDestName[DSU_SSTY_INDEX]==pTempDevCommInfoStru->ReceptorType)) + { + /*SSTyҵڵ*/ + if ((pTempDevCommInfoStru->IftVer==ItfVer)&&(pTempDevCommInfoStru->MsgId==MsgId)) + { + * pIsLegalRole=DSURSR_TRUE; + chReturnValue=1; + return chReturnValue; + } + else + { + /*ҵУݲԣ˵Ϸ*/ + * pIsLegalRole=DSURSR_FALSE; + chReturnValue=1; + return chReturnValue; + } + + + } + else + { + /*вҪҵݣ*/ + } + pTempDevCommInfoStru++; + } + + /*δҵӦͨŹϵݣϵϷ*/ + * pIsLegalRole=DSURSR_FALSE; + chReturnValue=1; + return chReturnValue; +} + +/* +* úڻȡźŲİ汾ԼϢID +* UINT16 localName, ʾԴʶTYPEǰIDں +* UINT8 localLogId,ʾԴ̬ID +* UINT16 DestName, ʾĿıʶTYPEǰIDں +* UINT8 DestLogId, ʾĵĶ̬ID +* UINT8* pItfVer, ʾӿڰ汾ţ뱨ķ +* UINT8* pMsgId,ʾϢID뱨ķء +* ֵ1ɹ +* 0ʧ,δҵͨŹϵ +*/ +UINT8 dsuSigGetInfo(UINT16 LocalName, UINT8 LocalLogId,UINT16 DestName, UINT8 DestLogId, UINT8* pItfVer, UINT8* pMsgId) +{ + UINT8 ByLocalName[2]; /*Դʶ*/ + UINT8 ByDestName[2]; /*Ŀʶ*/ + UINT16 i; /*ѭ*/ + DSU_DEVICE_COMM_INFO_STRU* pTempDevCommInfoStru; + UINT8 chReturnValue; + + + /*жͨŹϵǷϷ*/ + chReturnValue=dsuRsrCheckSigRelationLegal(LocalName,LocalLogId,DestName,DestLogId); + if (chReturnValue==0) + { + /*ͨŹϵϷ*/ + chReturnValue=0; + return chReturnValue; + } + + /*ıʶֳsstyssid*/ + ShortToChar(LocalName,ByLocalName); + ShortToChar(DestName,ByDestName); + + pTempDevCommInfoStru=pDsuRsrInfoStru->pDevCommInfoStru; + for (i=0;iDeviceCommStruLen;i++) + { + if ((ByLocalName[DSU_SSTY_INDEX]==pTempDevCommInfoStru->EmitterType) + &&(ByDestName[DSU_SSTY_INDEX]==pTempDevCommInfoStru->ReceptorType)) + { + /*SSTyҵڵ*/ + * pItfVer=pTempDevCommInfoStru->IftVer; + * pMsgId=pTempDevCommInfoStru->MsgId; + chReturnValue=1; + return chReturnValue; + } + else + { + /*вҪҵݣ*/ + } + pTempDevCommInfoStru++; + } + + /*δҵӦͨŹϵݣϵϷ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +* 豸ͲѯͨϢ +* UINT8 localType, 豸 +* UINT8 DestType, Ŀ豸 +* DSU_RSSP_LINK_RINFO_STRU* pRsspLnkRInfo,UINT8 localType, UINT8 DestType +* ֵ1ɹ0ʧ +*/ +UINT8 dsuSetCommInfo(DSU_RSSP_LINK_RINFO_STRU* pRsspLnkRInfo,UINT8 localType, UINT8 DestType) +{ + UINT16 i;/*ѭ*/ + DSU_DEVICE_COMM_INFO_STRU* pTempDevCommInfoStru; + UINT8 chReturnValue; + + pTempDevCommInfoStru=pDsuRsrInfoStru->pDevCommInfoStru; + for (i=0;iDeviceCommStruLen;i++) + { + if ((localType==pTempDevCommInfoStru->EmitterType) + &&(DestType==pTempDevCommInfoStru->ReceptorType)) + { + /*SSTyҵڵ*/ + pRsspLnkRInfo->MaxLost=pTempDevCommInfoStru->MaxLost; + pRsspLnkRInfo->DLost=pTempDevCommInfoStru->DLost; + pRsspLnkRInfo->WSsrOut=pTempDevCommInfoStru->WSsrOut; + pRsspLnkRInfo->AntiDelayCount=pTempDevCommInfoStru->AntiDelayCount; + pRsspLnkRInfo->TOut=pTempDevCommInfoStru->TOut; + + chReturnValue=1; + return chReturnValue; + } + else + { + /*вҪҵݣ*/ + } + pTempDevCommInfoStru++; + } + + /*δҵӦͨŹϵݣϵϷ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +* ȡ豸 +* UINT16 DevName 豸 +* +* ֵ豸 +*/ +UINT8 dsuRsrGetDevType(UINT16 DevName) +{ + UINT8 devType; + devType=(UINT8)(DevName>>8); + + return devType; +} + +/* +* ȡ豸ID +* UINT16 DevName 豸 +* +* ֵ豸Id +*/ +UINT8 dsuRsrGetDevId(UINT16 DevName) +{ + UINT8 devId; + devId=(UINT8)(DevName&0xff); + + return devId; +} + +/* +* úڲѯRSSP·ϢսڵϢԼźŲӳݡ +* UINT16 RsspAddr, rsspַ +* INT16 BSDAddr, bsdַ +* DSU_RSSP_LINK_RINFO_STRU* pRsspLnkInfoϢ +* ṹ帳ֵ£ +* UINT8 ROLE;ʾĿǷΪƶ豸 +* UINT8 LocalLogId; ʾԴ̬ID +* UINT16 DestNameʾĿʶ +* UINT8 DestLogId; ʾĵĿ궯̬ID +* ROLE Ϊ0x00ʱԴĿΪ̶豸 +* LocalLogId 0xFF +* DestName = ݿ +* DestLogId 0xFF +* +* ROLRΪ0x55ʱԴΪ̶豸ĿΪƶ豸 +* LocalLogId 0xFF +* DestName = 0xFFFF +* DestLogId ݿ +* +* ROLRΪ0xFFʱԴΪƶ豸ĿΪ̶豸 +* LocalLogId ݿ +* DestName =ݿ +* DestLogId 0xFF +* +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuRsspRGetLnkInfo(UINT16 RsspAddr, INT16 BsdAddr, DSU_RSSP_LINK_RINFO_STRU* pRsspLnkRInfo) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU* pTempRsspLnkInfoStru; + UINT16 pTempRsspLnkInfoStruLen; + UINT8 ChannelCount; + UINT16 CurrentChannel; + UINT8 LocalDevType; + UINT8 DestDevType; + + /*Ϊƶ,Vobc2Ciв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoVobc2CiStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenVobc2CiLen; + + /*ҵChannelΪ0*/ + ChannelCount=0; + + /*ѭ*/ + for (i=0;iRsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ѾҵĿ*/ + CurrentChannel=pTempRsspLnkInfoStru->ChannelNumber-1; + ChannelCount++; + + pRsspLnkRInfo->ROLE=ROLE_VOBC2CI; + pRsspLnkRInfo->LocalLogId=(UINT8)(pTempRsspLnkInfoStru->EmitterNameOrLogicId); + pRsspLnkRInfo->DestName=pTempRsspLnkInfoStru->ReceptorNameOrLogicId; + pRsspLnkRInfo->DestLogId=0xff; + pRsspLnkRInfo->SseAddr=pTempRsspLnkInfoStru->SseAddr; + pRsspLnkRInfo->SID_NUMBER_E[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_E; + pRsspLnkRInfo->SID_NUMBER_R[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_R; + pRsspLnkRInfo->PREC_FIRSTSINIT[CurrentChannel]=pTempRsspLnkInfoStru->PREC_FIRSTSINIT; + CommonMemCpy(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel], sizeof(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel]),pTempRsspLnkInfoStru->POST_RXDADA_K,sizeof(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel])); + CommonMemCpy(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel], sizeof(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel]),pTempRsspLnkInfoStru->PREC_SINIT_K,sizeof(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel])); + + chReturnValue=dsuSetCommInfo(pRsspLnkRInfo,DSURSR_DEVTYPE_VOBC,DSURSR_DEVTYPE_CI); + if (chReturnValue==0) + { + /*ͨŹϵʧܣʧ*/ + chReturnValue=0; + return chReturnValue; + } + + if (ChannelCount>=2) + { + /*ͨϢҵ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*δҵͨ*/ + } + + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + /*Ϊƶ,Ci2Vobcв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoCi2VobcStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenCi2VobcLen; + + /*ҵChannelΪ0*/ + ChannelCount=0; + + /*ѭ*/ + for (i=0;iRsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ѾҵĿ*/ + CurrentChannel=pTempRsspLnkInfoStru->ChannelNumber-1; + ChannelCount++; + + pRsspLnkRInfo->ROLE=ROLE_CI2VOBC; + pRsspLnkRInfo->LocalLogId=0xff; + pRsspLnkRInfo->DestName=0xffff; + pRsspLnkRInfo->DestLogId=(UINT8)(pTempRsspLnkInfoStru->ReceptorNameOrLogicId); + pRsspLnkRInfo->SseAddr=pTempRsspLnkInfoStru->SseAddr; + pRsspLnkRInfo->SID_NUMBER_E[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_E; + pRsspLnkRInfo->SID_NUMBER_R[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_R; + pRsspLnkRInfo->PREC_FIRSTSINIT[CurrentChannel]=pTempRsspLnkInfoStru->PREC_FIRSTSINIT; + CommonMemCpy(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel], sizeof(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel]), pTempRsspLnkInfoStru->POST_RXDADA_K, sizeof(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel])); + CommonMemCpy(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel], sizeof(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel]), pTempRsspLnkInfoStru->PREC_SINIT_K, sizeof(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel])); + + chReturnValue=dsuSetCommInfo(pRsspLnkRInfo,DSURSR_DEVTYPE_CI,DSURSR_DEVTYPE_VOBC); + if (chReturnValue==0) + { + /*ͨŹϵʧܣʧ*/ + chReturnValue=0; + return chReturnValue; + } + + if (ChannelCount>=2) + { + /*ͨϢҵ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*δҵͨ*/ + } + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + /*Ϊƶ,ZcvsCiв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoZcvsCiStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenZcvsCiLen; + + /*ҵChannelΪ0*/ + ChannelCount=0; + + /*ѭ*/ + for (i=0;iRsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ѾҵĿ*/ + CurrentChannel=pTempRsspLnkInfoStru->ChannelNumber-1; + ChannelCount++; + + pRsspLnkRInfo->ROLE=ROLE_ZC_CI; + pRsspLnkRInfo->LocalLogId=0xff; + pRsspLnkRInfo->DestName=pTempRsspLnkInfoStru->ReceptorNameOrLogicId; + pRsspLnkRInfo->DestLogId=0xff; + pRsspLnkRInfo->SseAddr=pTempRsspLnkInfoStru->SseAddr; + pRsspLnkRInfo->SID_NUMBER_E[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_E; + pRsspLnkRInfo->SID_NUMBER_R[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_R; + pRsspLnkRInfo->PREC_FIRSTSINIT[CurrentChannel]=pTempRsspLnkInfoStru->PREC_FIRSTSINIT; + CommonMemCpy(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel], sizeof(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel]), pTempRsspLnkInfoStru->POST_RXDADA_K, sizeof(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel])); + CommonMemCpy(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel], sizeof(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel]), pTempRsspLnkInfoStru->PREC_SINIT_K, sizeof(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel])); + + LocalDevType=dsuRsrGetDevType(pTempRsspLnkInfoStru->EmitterNameOrLogicId); + DestDevType=dsuRsrGetDevType(pTempRsspLnkInfoStru->ReceptorNameOrLogicId); + chReturnValue=dsuSetCommInfo(pRsspLnkRInfo,LocalDevType,DestDevType); + if (chReturnValue==0) + { + /*ͨŹϵʧܣʧ*/ + chReturnValue=0; + return chReturnValue; + } + + if (ChannelCount>=2) + { + /*ͨϢҵ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*δҵͨ*/ + } + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + + /*δҵ豸ʧ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +* úڲѯRSSP·ϢͽڵϢԼźŲӳݡ +* UINT16 RsspAddr, rsspַ +* INT16 BSDAddr, bsdַ +* DSU_RSSP_LINK_SINFO_STRU* pRsspLnkInfoϢ +* ṹ帳ֵ£ +* UINT8 ROLE;ʾĿǷΪƶ豸 +* UINT8 LocalLogId; ʾԴ̬ID +* UINT16 DestNameʾĿʶ +* UINT8 DestLogId; ʾĵĿ궯̬ID +* ROLE Ϊ0x00ʱԴĿΪ̶豸 +* LocalLogId 0xFF +* DestName = ݿ +* DestLogId 0xFF +* +* ROLRΪ0x55ʱԴΪ̶豸ĿΪƶ豸 +* LocalLogId 0xFF +* DestName = 0xFFFF +* DestLogId ݿ +* +* ROLRΪ0xFFʱԴΪƶ豸ĿΪ̶豸 +* LocalLogId ݿ +* DestName =ݿ +* DestLogId 0xFF +* +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuRsspSGetLnkInfo(UINT16 RsspAddr, INT16 BsdAddr, DSU_RSSP_LINK_SINFO_STRU* pRsspLnkSInfo) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU* pTempRsspLnkInfoStru; + UINT16 pTempRsspLnkInfoStruLen; + UINT8 ChannelCount; + UINT16 CurrentChannel; + + /*Ϊƶ,Vobc2Ciв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoVobc2CiStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenVobc2CiLen; + + /*ҵChannelΪ0*/ + ChannelCount=0; + + /*ѭ*/ + for (i=0;iRsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ѾҵĿ*/ + CurrentChannel=pTempRsspLnkInfoStru->ChannelNumber-1; + ChannelCount++; + + pRsspLnkSInfo->ROLE=ROLE_VOBC2CI; + pRsspLnkSInfo->LocalLogId=(UINT8)(pTempRsspLnkInfoStru->EmitterNameOrLogicId); + pRsspLnkSInfo->DestName=pTempRsspLnkInfoStru->ReceptorNameOrLogicId; + pRsspLnkSInfo->DestLogId=0xff; + pRsspLnkSInfo->SseAddr=pTempRsspLnkInfoStru->SseAddr; + pRsspLnkSInfo->SID_NUMBER_E[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_E; + pRsspLnkSInfo->SID_NUMBER_R[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_R; + pRsspLnkSInfo->SINIT_NUMBER[CurrentChannel]=pTempRsspLnkInfoStru->SINIT_NUMBER; + pRsspLnkSInfo->DATANUM[CurrentChannel]=pTempRsspLnkInfoStru->DATANUM; + pRsspLnkSInfo->DATAVER_1_Number[CurrentChannel]=pTempRsspLnkInfoStru->DATAVER_1_Number; + pRsspLnkSInfo->DATANUM[CurrentChannel]=pTempRsspLnkInfoStru->DATANUM; + + if (ChannelCount>=2) + { + chReturnValue=1; + return chReturnValue; + } + else + { + /*δҵͨ*/ + } + + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + /*Ϊƶ,Ci2Vobcв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoCi2VobcStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenCi2VobcLen; + + /*ҵChannelΪ0*/ + ChannelCount=0; + + /*ѭ*/ + for (i=0;iRsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ѾҵĿ*/ + CurrentChannel=pTempRsspLnkInfoStru->ChannelNumber-1; + ChannelCount++; + + pRsspLnkSInfo->ROLE=ROLE_CI2VOBC; + pRsspLnkSInfo->LocalLogId=0xff; + pRsspLnkSInfo->DestName=0xffff; + pRsspLnkSInfo->DestLogId=(UINT8)(pTempRsspLnkInfoStru->ReceptorNameOrLogicId); + pRsspLnkSInfo->SseAddr=pTempRsspLnkInfoStru->SseAddr; + pRsspLnkSInfo->SID_NUMBER_E[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_E; + pRsspLnkSInfo->SID_NUMBER_R[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_R; + pRsspLnkSInfo->SINIT_NUMBER[CurrentChannel]=pTempRsspLnkInfoStru->SINIT_NUMBER; + pRsspLnkSInfo->DATANUM[CurrentChannel]=pTempRsspLnkInfoStru->DATANUM; + pRsspLnkSInfo->DATAVER_1_Number[CurrentChannel]=pTempRsspLnkInfoStru->DATAVER_1_Number; + pRsspLnkSInfo->DATANUM[CurrentChannel]=pTempRsspLnkInfoStru->DATANUM; + + if (ChannelCount>=2) + { + chReturnValue=1; + return chReturnValue; + } + else + { + /*δҵͨ*/ + } + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + /*Ϊƶ,ZcvsCiв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoZcvsCiStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenZcvsCiLen; + + /*ҵChannelΪ0*/ + ChannelCount=0; + + /*ѭ*/ + for (i=0;iRsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ѾҵĿ*/ + CurrentChannel=pTempRsspLnkInfoStru->ChannelNumber-1; + ChannelCount++; + + pRsspLnkSInfo->ROLE=ROLE_ZC_CI; + pRsspLnkSInfo->LocalLogId=0xff; + pRsspLnkSInfo->DestName=pTempRsspLnkInfoStru->ReceptorNameOrLogicId; + pRsspLnkSInfo->DestLogId=0xff; + pRsspLnkSInfo->SseAddr=pTempRsspLnkInfoStru->SseAddr; + pRsspLnkSInfo->SID_NUMBER_E[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_E; + pRsspLnkSInfo->SID_NUMBER_R[CurrentChannel]=pTempRsspLnkInfoStru->SID_NUMBER_R; + pRsspLnkSInfo->SINIT_NUMBER[CurrentChannel]=pTempRsspLnkInfoStru->SINIT_NUMBER; + pRsspLnkSInfo->DATANUM[CurrentChannel]=pTempRsspLnkInfoStru->DATANUM; + pRsspLnkSInfo->DATAVER_1_Number[CurrentChannel]=pTempRsspLnkInfoStru->DATAVER_1_Number; + pRsspLnkSInfo->DATANUM[CurrentChannel]=pTempRsspLnkInfoStru->DATANUM; + + if (ChannelCount>=2) + { + chReturnValue=1; + return chReturnValue; + } + else + { + /*δҵͨ*/ + } + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + + /*δҵ豸ʧ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +* úڻȡCI߼վ̨Ϣվ̨ +* UINT16 CIDevName, CI豸ʶ +* UINT8* pLogicIDNum, վ̨Ŀ +* UINT8 LogicID[], վ̨ID,ׯÿCIϽվ̨Ϊ6վ̨ +* ֵ1ɹ +* 0ʧܣδҵCIID +*/ +UINT8 dsuRsspGetLogicId(UINT16 CIDevName, UINT8* pLogicIDNum,UINT8 LogicID[]) +{ + UINT16 i; /*ѭ*/ + UINT16 j; /*ѭ*/ + DSU_CI_PLATFORM_INFO_STRU *pTempCIPlatFormInfoStru; + UINT8 ByCIName[2]; /*ֽڱʶ*/ + UINT8 chReturnValue; + + /*ıʶֳsstyssid*/ + ShortToChar(CIDevName,ByCIName); + + pTempCIPlatFormInfoStru=pDsuRsrInfoStru->pCIPlatFormInfoStru; + for (i=0;iCIPlatFormInfoStruLen;i++) + { + /*жϵǰCI IdCIIDǷͬ*/ + if (ByCIName[DSU_SSID_INDEX]==pTempCIPlatFormInfoStru->CIId) + { + /*ǰCIIDCIIDֵͬ*/ + *pLogicIDNum=pTempCIPlatFormInfoStru->CIPlatformNum; + for (j=0;jCIPlatformNum;j++) + { + LogicID[j]=pTempCIPlatFormInfoStru->CIPlatformId[j]; + } + + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰCIIDCIIDͬ*/ + } + + pTempCIPlatFormInfoStru++; + } + + /*ûҵCIIDڵݣʧ*/ + chReturnValue=0; + return chReturnValue; + +} + +/* +* úڲѯZCCIͨϢӦã>RSRЭʱʹá +* UINT16 LocalName,ʾԴʶTYPEǰIDں +* UINT16 DestName,ʾĿıʶTYPEǰIDں +* UINT16* pRsspAddr, rsspַ +* INT16* pBsdAddr, bsdַ +* UINT16* pSseAddr sseַ +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuZCvsCIOutInfo(UINT16 LocalName,UINT16 DestName,UINT16* pRsspAddr,INT16* pBsdAddr,UINT16* pSseAddr) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU* pTempRsspLnkInfoStru; + + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoZcvsCiStruBuf; + + for (i=0;iRsspInfoStruLenZcvsCiLen;i++) + { + if ((pTempRsspLnkInfoStru->EmitterNameOrLogicId==LocalName) + &&(pTempRsspLnkInfoStru->ReceptorNameOrLogicId==DestName)) + { + /*ǰԴĿ豸ϣֵ*/ + *pRsspAddr=pTempRsspLnkInfoStru->RsspAddr; + *pBsdAddr=pTempRsspLnkInfoStru->BsdAddr; + *pSseAddr=pTempRsspLnkInfoStru->SseAddr; + + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰԴĿ豸벻ϣ*/ + } + pTempRsspLnkInfoStru++; + } + + chReturnValue=0; + return chReturnValue; +} + + +/* +* úڲѯZCCIͨϢRSRЭ->Ӧʱʹá +* UINT16 RsspAddr, rsspַ +* INT16 BsdAddr, bsdַ +* UINT16* pLocalNameʾԴʾTYPEǰIDں +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuZCvsCIInInfo(UINT16 RsspAddr,INT16 BsdAddr, UINT16* pLocalName) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU* pTempRsspLnkInfoStru; + + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoZcvsCiStruBuf; + + for (i=0;iRsspInfoStruLenZcvsCiLen;i++) + { + if ((pTempRsspLnkInfoStru->RsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ǰRsspAddr BsdAddrϣֵ*/ + *pLocalName=pTempRsspLnkInfoStru->EmitterNameOrLogicId; + + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰԴĿ豸벻ϣ*/ + } + pTempRsspLnkInfoStru++; + } + + chReturnValue=0; + return chReturnValue; +} + + +/* +* úڲѯVOBCCIͨϢӦã>RSRЭʱʹá +* UINT8 PlatId, ʾվ̨ID +* UINT8 LocalRole,ʾǷΪƶ塣 +* 1Ϊƶ,ʱվ̨IDݿΪԴ +* 0Ϊ̶壬ʱվ̨IDݿΪĿꡣ +* UINT16* pRsspAddr, rsspַ +* INT16* pBsdAddr, bsdַ +* UINT16* pSseAddr sseַ +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuVOBCvsCIOutInfo(UINT16 PlatId, UINT8 LocalRole,UINT16* pRsspAddr, INT16* pBsdAddr,UINT16* pSseAddr) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU* pTempRsspLnkInfoStru; + UINT16 pTempRsspLnkInfoStruLen; + UINT8 ByPlatId; + + /*˴ӦûõPlatIdΪ2byteЭPlatIdΪ1byte˴һǿת*/ + if(PlatId>255) + { + /*PlatIdϷ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*PlatIdϷִ*/ + + } + ByPlatId=(UINT8)(PlatId); + + + if (LocalRole==1) + { + /*Ϊƶ,Vobc2Ciв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoVobc2CiStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenVobc2CiLen; + + /*ѭPlatId*/ + for (i=0;iEmitterNameOrLogicId==PlatId) + { + /*ǰPlatIdϣֵ*/ + *pRsspAddr=pTempRsspLnkInfoStru->RsspAddr; + *pBsdAddr=pTempRsspLnkInfoStru->BsdAddr; + *pSseAddr=pTempRsspLnkInfoStru->SseAddr; + + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰPlatId벻ϣ*/ + } + pTempRsspLnkInfoStru++; + } + } + else + { + /*Ϊƶ,Vobc2Ciв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoCi2VobcStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenCi2VobcLen; + + /*ѭPlatId*/ + for (i=0;iReceptorNameOrLogicId==PlatId) + { + /*ǰPlatIdϣֵ*/ + *pRsspAddr=pTempRsspLnkInfoStru->RsspAddr; + *pBsdAddr=pTempRsspLnkInfoStru->BsdAddr; + *pSseAddr=pTempRsspLnkInfoStru->SseAddr; + + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰPlatId벻ϣ*/ + } + pTempRsspLnkInfoStru++; + } + + } + + /*δҵ豸ʧ*/ + chReturnValue=0; + return chReturnValue; +} + + + +/* +* úڲѯVOBCCIͨϢRSRЭ->Ӧʱʹá +* UINT16 RsspAddr, rsspַ +* INT16 BsdAddr, bsdַ +* UINT8* pPlatId ʾվ̨ID +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuVOBCvsCIInInfo(UINT16 RsspAddr,INT16 BsdAddr, UINT16* pPlatId) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU* pTempRsspLnkInfoStru; + UINT16 pTempRsspLnkInfoStruLen; + + /*Ϊƶ,Vobc2Ciв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoVobc2CiStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenVobc2CiLen; + + /*ѭPlatId*/ + for (i=0;iRsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ѾҵĿ*/ + + /*˴ӦûõPlatIdΪ2byteЭPlatIdΪ1byte˴һǿת*/ + *pPlatId=(UINT16)(pTempRsspLnkInfoStru->EmitterNameOrLogicId); + + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + /*Ϊ̶,Ci2Vobcв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoCi2VobcStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenCi2VobcLen; + + /*ѭPlatId*/ + for (i=0;iRsspAddr==RsspAddr) + &&(pTempRsspLnkInfoStru->BsdAddr==BsdAddr)) + { + /*ѾҵĿ*/ + + /*˴ӦûõPlatIdΪ2byteЭPlatIdΪ1byte˴һǿת*/ + *pPlatId=(UINT16)(pTempRsspLnkInfoStru->ReceptorNameOrLogicId); + + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + + /*δҵ豸ʧ*/ + chReturnValue=0; + return chReturnValue; +} + + +/* +* ݼ麯ڲdsuǷ +* +* +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuRsrCheckData(void) +{ + UINT8 chReturnValue=1; /*ֵ*/ + return chReturnValue; +} + +/* +* 豸ǷϷźŲͨ˫NameǷϷ +* +* +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuRsrCheckSigRelationLegal(UINT16 LocalName, UINT8 LocalLogId,UINT16 DestName, UINT8 DestLogId) +{ + UINT8 chReturnValue; /**/ + UINT16 i; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU* pTempRsspLnkInfoStru; + UINT16 pTempRsspLnkInfoStruLen; + UINT8 LocalDevType; + UINT8 DestDevType; + UINT8 LocalDevId; + UINT8 DestDevId; + + /*ȡ豸ͺId*/ + LocalDevType=dsuRsrGetDevType(LocalName); + DestDevType=dsuRsrGetDevType(DestName); + + LocalDevId=dsuRsrGetDevId(LocalName); + DestDevId=dsuRsrGetDevId(DestName); + + /*ݲͬ豸ͷദ*/ + if (LocalDevType==DSURSR_DEVTYPE_VOBC) + { + /*̶豸ssidlogic idǷͬ*/ + if (DestDevId!=DestLogId) + { + /*̶豸IdLogicId*/ + chReturnValue=0; + return chReturnValue; + } + + /*Ϊƶ,Vobc2Ciв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoVobc2CiStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenVobc2CiLen; + + /*ѭ*/ + for (i=0;iEmitterNameOrLogicId==LocalLogId) + &&(pTempRsspLnkInfoStru->ReceptorNameOrLogicId==DestName)) + { + /*ѾҵĿ,ͨŹϵϷ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + } + else if (DestDevType==DSURSR_DEVTYPE_VOBC) + { + + /*̶豸ssidlogic idǷͬ*/ + if (LocalDevId!=LocalLogId) + { + /*̶豸IdLogicId*/ + chReturnValue=0; + return chReturnValue; + } + + /*ԷΪƶ,Ci2Vobcв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoCi2VobcStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenCi2VobcLen; + + + /*ѭ*/ + for (i=0;iEmitterNameOrLogicId==LocalName) + &&(pTempRsspLnkInfoStru->ReceptorNameOrLogicId==DestLogId)) + { + /*ѾҵĿ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + } + else + { + /*̶豸ssidlogic idǷͬ*/ + if ((LocalDevId!=LocalLogId)||(DestDevId!=DestLogId)) + { + /*̶豸IdLogicId*/ + chReturnValue=0; + return chReturnValue; + } + + + /*˫Ϊ̶,ZcvsCiв*/ + pTempRsspLnkInfoStru=pDsuRsrInfoStru->RsspLnkInfoZcvsCiStruBuf; + pTempRsspLnkInfoStruLen=pDsuRsrInfoStru->RsspInfoStruLenZcvsCiLen; + + /*ѭ*/ + for (i=0;iEmitterNameOrLogicId==LocalName) + &&(pTempRsspLnkInfoStru->ReceptorNameOrLogicId==DestName)) + { + /*ѾҵĿ*/ + chReturnValue=1; + return chReturnValue; + } + else + { + /*ǰĿ*/ + } + pTempRsspLnkInfoStru++; + } + + } + + /*δҵͨŹϵͨŹϵϷ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +* ȫͨЭrsrʼڼȷԣݽṹ +* +FSName ļݵַ +pDsuRsrInfoStru ֽͷָ +* pDsuRsrInfoStru ʼ +* ֵ1ɹ +* 0ʧܣд +*/ +UINT8 dsuRsrInit(UINT8* FSName) +{ + UINT8 chReturnValue =0 ; /*ֵ*/ + UINT8 TempRet; + UINT8* pData=NULL; /*ڶȡݵָ*/ + UINT32 dataLen=0; /*ݳ*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 i; + UINT32 j; + + pDsuRsrInfoStru=&dsuRsrInfoStru; + + /*ʼrssp lnk Ϣ*/ + /*ȡ*/ + TempRet=dquGetConfigData((char*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_RSSP_LNK_ID, &pData , &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + if(dataLen>0) + { + pDsuRsrInfoStru->RsspInfoStruLen=(UINT16)(dataLen/DSU_RSSP_LNK_INFO_STRU_SIZE); /*ݵĸ*/ + pDsuRsrInfoStru->pRsspLnkInfoStru=(DSU_RSSP_LNK_INFO_STRU*)malloc(sizeof(DSU_RSSP_LNK_INFO_STRU)*(pDsuRsrInfoStru->RsspInfoStruLen)); /*Ϊṹռ*/ + if (pDsuRsrInfoStru->pRsspLnkInfoStru==NULL) + { + /*ռʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + CommonMemSet(pDsuRsrInfoStru->pRsspLnkInfoStru,sizeof(DSU_RSSP_LNK_INFO_STRU)*(pDsuRsrInfoStru->RsspInfoStruLen),0,sizeof(DSU_RSSP_LNK_INFO_STRU)*(pDsuRsrInfoStru->RsspInfoStruLen)); + } + + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i=0;iRsspInfoStruLen;i++) + { + pDsuRsrInfoStru->pRsspLnkInfoStru[i].Id=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].EmitterNameOrLogicId=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].ReceptorNameOrLogicId=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].ChannelNumber=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].SID_NUMBER_E=LongFromChar(pData+dataOff); + dataOff+=4; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].SINIT_NUMBER=LongFromChar(pData+dataOff); + dataOff+=4; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].DATANUM=pData[dataOff]; + dataOff++; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].DATAVER_1_Number=LongFromChar(pData+dataOff); + dataOff+=4; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].RsspAddr=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].BsdAddr=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].SseAddr=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].SID_NUMBER_R=LongFromChar(pData+dataOff); + dataOff+=4; + + pDsuRsrInfoStru->pRsspLnkInfoStru[i].PREC_FIRSTSINIT=LongFromChar(pData+dataOff); + dataOff+=4; + + for (j=0;jpRsspLnkInfoStru[i].PREC_SINIT_K[j]=LongFromChar(pData+dataOff); + dataOff+=4; + + } + + for (j=0;jpRsspLnkInfoStru[i].POST_RXDADA_K[j]=LongFromChar(pData+dataOff); + dataOff+=4; + + } + + + } + + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + } + else + { + /* */ + } + + /*ʼƽ̨ݽṹ*/ + /*ȡ*/ + TempRet=dquGetConfigData((char*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_CI_PLATFORM_ID, &pData , &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + if(dataLen>0) + { + pDsuRsrInfoStru->CIPlatFormInfoStruLen=(UINT16)(dataLen/DSU_CI_PLATFORM_INFO_STRU_SIZE); /*ݵĸ*/ + pDsuRsrInfoStru->pCIPlatFormInfoStru =(DSU_CI_PLATFORM_INFO_STRU*)malloc(sizeof(DSU_CI_PLATFORM_INFO_STRU)*(pDsuRsrInfoStru->CIPlatFormInfoStruLen)); /*Ϊṹռ*/ + if (pDsuRsrInfoStru->pCIPlatFormInfoStru==NULL) + { + /*ռʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + CommonMemSet(pDsuRsrInfoStru->pCIPlatFormInfoStru,sizeof(DSU_CI_PLATFORM_INFO_STRU)*(pDsuRsrInfoStru->CIPlatFormInfoStruLen),0,sizeof(DSU_CI_PLATFORM_INFO_STRU)*(pDsuRsrInfoStru->CIPlatFormInfoStruLen)); + } + + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i=0;iCIPlatFormInfoStruLen;i++) + { + pDsuRsrInfoStru->pCIPlatFormInfoStru[i].CIId=pData[dataOff]; + dataOff++; + + pDsuRsrInfoStru->pCIPlatFormInfoStru[i].CIPlatformNum=pData[dataOff]; + dataOff++; + + for (j=0;jpCIPlatFormInfoStru[i].CIPlatformId[j]=pData[dataOff]; + dataOff++; + } + } + + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + } + else + { + /* */ + } + + /*ʼ豸ͨԱ*/ + /*ȡ*/ + TempRet=dquGetConfigData((char*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_COMM_INFO_ID, &pData , &dataLen); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + if(dataLen>0) + { + pDsuRsrInfoStru->DeviceCommStruLen=(UINT16)(dataLen/DSU_DEVICE_COMM_INFO_STRU_SIZE); /*ݵĸ*/ + pDsuRsrInfoStru->pDevCommInfoStru =(DSU_DEVICE_COMM_INFO_STRU*)malloc(sizeof(DSU_DEVICE_COMM_INFO_STRU)*(pDsuRsrInfoStru->DeviceCommStruLen)); /*Ϊṹռ*/ + if (pDsuRsrInfoStru->pDevCommInfoStru==NULL) + { + /*ռʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + CommonMemSet(pDsuRsrInfoStru->pDevCommInfoStru,sizeof(DSU_DEVICE_COMM_INFO_STRU)*(pDsuRsrInfoStru->DeviceCommStruLen),0,sizeof(DSU_DEVICE_COMM_INFO_STRU)*(pDsuRsrInfoStru->DeviceCommStruLen)); + } + + dataOff=0; + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i=0;iDeviceCommStruLen;i++) + { + + pDsuRsrInfoStru->pDevCommInfoStru[i].EmitterType=ShortFromChar(pData+dataOff); + dataOff+=2; + + pDsuRsrInfoStru->pDevCommInfoStru[i].ReceptorType=ShortFromChar(pData+dataOff); + dataOff+=2; + + + pDsuRsrInfoStru->pDevCommInfoStru[i].MaxLost=pData[dataOff]; + dataOff++; + + pDsuRsrInfoStru->pDevCommInfoStru[i].DLost=pData[dataOff]; + dataOff++; + + pDsuRsrInfoStru->pDevCommInfoStru[i].WSsrOut=pData[dataOff]; + dataOff++; + + pDsuRsrInfoStru->pDevCommInfoStru[i].AntiDelayCount=pData[dataOff]; + dataOff++; + + pDsuRsrInfoStru->pDevCommInfoStru[i].TOut=pData[dataOff]; + dataOff++; + + pDsuRsrInfoStru->pDevCommInfoStru[i].MsgId=pData[dataOff]; + dataOff++; + + pDsuRsrInfoStru->pDevCommInfoStru[i].IftVer=pData[dataOff]; + dataOff++; + + } + + if (dataOff!=dataLen) + { + /*ݳȲǽݵ˵쳣*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + } + else + { + /* */ + } + + /*RsspLnkݷֳZcVsCi,Vobc2Ci,Ci2Vobc*/ + ManageRsspData(); + + chReturnValue=1; + return chReturnValue; +} + +/* RsspLnkݷֳZcVsCi,Vobc2Ci,Ci2Vobc*/ +void ManageRsspData(void) +{ + UINT16 i; /*ѭñ*/ + UINT16 EmitterType; + UINT16 ReceptorType; + pDsuRsrInfoStru->RsspInfoStruLenZcvsCiLen=0; + pDsuRsrInfoStru->RsspInfoStruLenVobc2CiLen=0; + pDsuRsrInfoStru->RsspInfoStruLenCi2VobcLen=0; + + /*ѭRsspLnkеݷ,ݷֳ࣬CIvsZC,VOBC2CICI2VOBCCICIͨŵѶ*/ + for (i=0;iRsspInfoStruLen;i++) + { + EmitterType=dsuRsrGetDevType(pDsuRsrInfoStru->pRsspLnkInfoStru[i].EmitterNameOrLogicId); + ReceptorType=dsuRsrGetDevType(pDsuRsrInfoStru->pRsspLnkInfoStru[i].ReceptorNameOrLogicId); + if (((EmitterType==DSURSR_DEVTYPE_CI)&&(ReceptorType==DSURSR_DEVTYPE_ZC)) + ||((EmitterType ==DSURSR_DEVTYPE_ZC )&&(ReceptorType==DSURSR_DEVTYPE_CI))) + { + CommonMemCpy(pDsuRsrInfoStru->RsspLnkInfoZcvsCiStruBuf + pDsuRsrInfoStru->RsspInfoStruLenZcvsCiLen, sizeof(DSU_RSSP_LNK_INFO_STRU), pDsuRsrInfoStru->pRsspLnkInfoStru + i, sizeof(DSU_RSSP_LNK_INFO_STRU)); + pDsuRsrInfoStru->RsspInfoStruLenZcvsCiLen++; + } + else if ((EmitterType==DSURSR_DEVTYPE_PLATFORM)&&(ReceptorType==DSURSR_DEVTYPE_CI)) + { + CommonMemCpy(pDsuRsrInfoStru->RsspLnkInfoVobc2CiStruBuf + pDsuRsrInfoStru->RsspInfoStruLenVobc2CiLen, sizeof(DSU_RSSP_LNK_INFO_STRU), pDsuRsrInfoStru->pRsspLnkInfoStru + i, sizeof(DSU_RSSP_LNK_INFO_STRU)); + pDsuRsrInfoStru->RsspInfoStruLenVobc2CiLen++; + } + else if ((EmitterType==DSURSR_DEVTYPE_CI )&&(ReceptorType==DSURSR_DEVTYPE_PLATFORM)) + { + CommonMemCpy(pDsuRsrInfoStru->RsspLnkInfoCi2VobcStruBuf + pDsuRsrInfoStru->RsspInfoStruLenCi2VobcLen, sizeof(DSU_RSSP_LNK_INFO_STRU), pDsuRsrInfoStru->pRsspLnkInfoStru + i, sizeof(DSU_RSSP_LNK_INFO_STRU)); + + pDsuRsrInfoStru->RsspInfoStruLenCi2VobcLen++; + } + else + { + /*ͨͣ¼*/ + } + } + + return; +} + + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrFunc.h b/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrFunc.h new file mode 100644 index 0000000..47c37db --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_dqu_rsr/dsuRsrFunc.h @@ -0,0 +1,193 @@ + +/************************************************************************ +* +* ļ +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.30 +* з +* ȫͨЭrsrѯ +* ʹע +* ޸ļ¼ +* +************************************************************************/ + +#ifndef _DSU_RSR_FUNC_H_ +#define _DSU_RSR_FUNC_H_ + +#include "CommonTypes.h" +#include "dsuRsrDataStru.h" + +/*߲еKNum*/ +#define DSURSR_K_NUM 5 + +/*ֵźŲǷϷ*/ +#define DSURSR_FALSE 0 +#define DSURSR_TRUE 1 + +#define RSRDSU_IP_ADDR_LEN 4 + +/*֮ͨŽɫĺ*/ +#define ROLE_ZC_CI ((UINT8)(0x00)) /*ZCCIͨ*/ +#define ROLE_VOBC2CI ((UINT8)(0xff)) /*VOBC2CIͨ*/ +#define ROLE_CI2VOBC ((UINT8)(0x55)) /*CI2VOBC*/ + +#define DSURSR_DEVTYPE_ZC 0x1E /*豸ZC*/ +#define DSURSR_DEVTYPE_CI 0x3C/*豸CI*/ +#define DSURSR_DEVTYPE_ATS 0x03/*豸ATS*/ +#define DSURSR_DEVTYPE_PLATFORM 0x00/*豸ƽ̨ڴ˴עSSTY豸RsspLnkInfoֻLogicIdǼSSTyΪ0*/ +#define DSURSR_DEVTYPE_VOBC 0x14/*豸VOBC*/ + +#ifdef __cplusplus +extern "C" { +#endif + + /*RsspSGetLnkInfoʹõĽṹ*/ + typedef struct { + UINT8 ROLE;/*ʾͨŹϵ*/ + UINT8 LocalLogId; /* ʾԴ̬ID */ + UINT16 DestName;/*ʾĿʶ*/ + UINT8 DestLogId; /* ʾĵĿ궯̬ID */ + UINT16 SseAddr; /*ʾSSE_SSR_Destination_Addresݿ*/ + UINT32 SID_NUMBER_E[2];/* ݿ⣬±01ֱӦݿе12ͨ,ֵΪͷSID*/ + UINT32 SID_NUMBER_R[2];/* ݿ⣬±01ֱӦݿе12ͨ,ֵΪܷSID*/ + UINT32 SINIT_NUMBER[2];/* ݿ⣬±01ֱӦݿе12ͨ*/ + UINT8 DATANUM[2];/*ݿ⣬±01ֱӦݿе12ͨ*/ + UINT32 DATAVER_1_Number[2]; /*ݿ⣬±01ֱӦݿе12ͨ*/ + } DSU_RSSP_LINK_SINFO_STRU; + + /*RsspRGetLnkInfoʹõĽṹ*/ + typedef struct { + UINT8 ROLE;/*ʾͨŹϵ*/ + UINT8 LocalLogId; /* ʾԴ̬ID */ + UINT16 DestName;/*ʾĿʶ*/ + UINT8 DestLogId; /* ʾĵĿ궯̬ID */ + UINT16 SseAddr; /*ʾSSE_SSR_Destination_Addresݿ*/ + UINT32 SID_NUMBER_E[2];/* ݿ⣬±01ֱӦݿе12ͨ,ֵΪͷSID*/ + UINT32 SID_NUMBER_R[2];/* ݿ⣬±01ֱӦݿе12ͨ,ֵΪܷSID*/ + UINT32 PREC_FIRSTSINIT [2]; /*ʾ׸SINIT*/ + UINT32 POST_RXDADA_K[2][DSURSR_K_NUM]; /*ʾBSD̶ֵ*/ + UINT32 PREC_SINIT_K[2][DSURSR_K_NUM]; /*ʾSINITֵ*/ + UINT8 MaxLost;/*LOST*/ + UINT8 DLost;/*ʱ*/ + UINT8 WSsrOut;/*ȴSSRʱ*/ + UINT8 AntiDelayCount;/*ͬ*/ + UINT8 TOut; /*ijʱ*/ + } DSU_RSSP_LINK_RINFO_STRU; + +UINT8 dsuRsrGetDevType(UINT16 DevName); +UINT8 dsuRsrGetDevId(UINT16 DevName); +UINT8 dsuSetCommInfo(DSU_RSSP_LINK_RINFO_STRU* pRsspLnkRInfo,UINT8 localType, UINT8 DestType); +UINT8 dsuRsrCheckData(void); +UINT8 dsuRsrCheckSigRelationLegal(UINT16 LocalName, UINT8 LocalLogId,UINT16 DestName, UINT8 DestLogId); + +/*ṩӦʹõIJѯ*/ +UINT8 dsuZCvsCIOutInfo(UINT16 LocalName,UINT16 DestName,UINT16* RsspAddr,INT16* BsdAddr,UINT16* SseAddr); + +UINT8 dsuZCvsCIInInfo(UINT16 RsspAddr,INT16 BsdAddr, UINT16* LocalName); + +UINT8 dsuVOBCvsCIOutInfo(UINT16 PlatId, UINT8 LocalRole,UINT16* RsspAddr, INT16* BsdAddr,UINT16* SseAddr); + +UINT8 dsuVOBCvsCIInInfo(UINT16 RsspAddr,INT16 BsdAddr, UINT16* PlatId); + +/*ṩrsrЭʹõIJѯ*/ + +/* +* úڲѯźŲ㱨ǷϷ +* ѯݿǷиͨŹϵ +* UINT16 localName, ʾԴʶTYPEǰIDں +* UINT8 localLogId,ʾԴ̬ID +* UINT16 DestName, ʾĿıʶTYPEǰIDں +* UINT8 DestLogId, ʾĵĶ̬ID +* UINT8 ItfVer, ʾӿڰ汾ţ뱨ķ +* UINT8 MsgId,ʾϢID뱨ķء +* UINT8* pIsLegalRole,ʾͨŹϵǷݿ +* 1ʾϷݿڸͨŹϵ +* 0ʾϷݿвڸͨŹϵ +* ֵ1ɹݲһϷ +* 0ʧܣĿǰûз0 +*/ +UINT8 dsuSigIsLegal(UINT16 LocalName, UINT8 LocalLogId,UINT16 DestName, UINT8 DestLogId, UINT8 ItfVer, UINT8 MsgId,UINT8* pIsLegalRole); + +/* +* úڻȡźŲİ汾ԼϢID +* UINT16 localName, ʾԴʶTYPEǰIDں +* UINT8 localLogId,ʾԴ̬ID +* UINT16 DestName, ʾĿıʶTYPEǰIDں +* UINT8 DestLogId, ʾĵĶ̬ID +* UINT8* pItfVer, ʾӿڰ汾ţ뱨ķ +* UINT8* pMsgId,ʾϢID뱨ķء +* ֵ1ɹ +* 0ʧ,δҵͨŹϵ +*/ +UINT8 dsuSigGetInfo(UINT16 localName, UINT8 localLogId,UINT16 DestName, UINT8 DestLogId, UINT8* pItfVer, UINT8* pMsgId); + +UINT8 dsuRsspRGetLnkInfo(UINT16 RsspAddr, INT16 BsdAddr, DSU_RSSP_LINK_RINFO_STRU* pRsspLnkRInfo); + +/* +* úڲѯRSSP·ϢͽڵϢԼźŲӳݡ +* UINT16 RsspAddr, rsspַ +* INT16 BSDAddr, bsdַ +* DSU_RSSP_LINK_SINFO_STRU* pRsspLnkInfoϢ +* ṹ帳ֵ£ +* UINT8 ROLE;ʾĿǷΪƶ豸 +* UINT8 LocalLogId; ʾԴ̬ID +* UINT16 DestNameʾĿʶ +* UINT8 DestLogId; ʾĵĿ궯̬ID +* ROLE Ϊ0x00ʱԴĿΪ̶豸 +* LocalLogId 0xFF +* DestName = ݿ +* DestLogId 0xFF +* +* ROLRΪ0x55ʱԴΪ̶豸ĿΪƶ豸 +* LocalLogId 0xFF +* DestName = 0xFFFF +* DestLogId ݿ +* +* ROLRΪ0xFFʱԴΪƶ豸ĿΪ̶豸 +* LocalLogId ݿ +* DestName =ݿ +* DestLogId 0xFF +* +* ֵ1ɹ +* 0ʧ +*/ +UINT8 dsuRsspSGetLnkInfo(UINT16 RsspAddr, INT16 BsdAddr, DSU_RSSP_LINK_SINFO_STRU* pRsspLnkSInfo); + +/* +* úڻȡCI߼վ̨Ϣվ̨ +* UINT16 CIDevName, CI豸ʶ +* UINT8* pLogicIDNum, վ̨Ŀ +* UINT8 LogicID[], վ̨ID,ׯÿCIϽվ̨Ϊ6վ̨ +* ֵ1ɹ +* 0ʧܣδҵCIID +*/ +UINT8 dsuRsspGetLogicId(UINT16 CIDevName, UINT8* pLogicIDNum,UINT8 LogicID[]); + + +/* +* ȫͨЭrsrʼڼȷԣݽṹ +* +FSName ļݵַ +pDsuRsrInfoStru ֽͷָ +* pDsuRsrInfoStru ʼ +* ֵ1ɹ +* 0ʧܣд +*/ +UINT8 dsuRsrInit(UINT8* FSName); + + +/* RsspLnkݷֳZcVsCi,Vobc2Ci,Ci2Vobc*/ +void ManageRsspData(void); + + +extern DSU_RSR_INFO_STRU dsuRsrInfoStru; /*ڱRSRϢĽṹ*/ +extern DSU_RSR_INFO_STRU* pDsuRsrInfoStru; /*ǰڲݿ.*/ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/Rsr.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/Rsr.c new file mode 100644 index 0000000..90dcbdf --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/Rsr.c @@ -0,0 +1,758 @@ +/** ****************************************************** +* +* ļ Rsr.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.10.25 +* ؼЭ鲿 +* RsrЭʵ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2009.12.16 ¥ΰ ¼׷ +* 2011.12.06 ޸InitRpStructͨŵ +* 2011.12.06 ޸CheckRsrStructͼʱƽ̨ +* 2011.12.07 RsrLnkDeleteɾ·ܣ޸RsspLnkDelete +* 2011.12.13 ޸RsrOutputӵ·Ͽʱɾ· +********************************************************/ +#include +#include "CommonMemory.h" +#include "RsspIF.h" +#include "RpPlatform.h" +#include "RsspStruct.h" +#include "RsrCommon.h" +#include "RsspCommon.h" +#include "Convert.h" +#include "sigInterface.h" +#include "RsrRecordDelare.h" +#include "CommonRecord.h" +#include "RsspLnkNodeMgr.h" +#include "dsuRsrFunc.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*-------------------------------------------------------------------- + * RSRڲʹú Start + *--------------------------------------------------------------------*/ +static UINT8 InitRpStruct(const RSR_INFO_STRU *pRsrInfoStru, RP_INFO_STRU *pRpInfoStru); +static UINT8 CheckRsrStruct(const RSR_INFO_STRU *pRsrInfoStru); +static void QueueCopy(QueueStruct *queFrom,QueueStruct *QueTo); + + +/*-------------------------------------------------------------------- + * RSRڲʹú End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * RSRӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : RsrReceive + * : ԺݽRSRİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ + * УpRsrStruct->OutnetQueueA + * pRsrStruct->OutnetQueueB + * УpRsrStruct->DataToApp + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrReceive(RSR_INFO_STRU *pRsrStruct) +{ + UINT16 LocalName; + UINT8 ret = 0; + + if(pRsrStruct == NULL) /* ǿռ */ + { + /* ¼ */ + return ret; + } + else + { + /* */ + } + + + TypeId2DevName(pRsrStruct->LocalType,pRsrStruct->LocalID,&LocalName); /* ʶ = Type + ID */ + + /* ݿ ͳһṹ */ + QueueCopy(&pRsrStruct->OutnetQueueA,&pRsrStruct->RpInfoStru.OutnetQueueA); + QueueCopy(&pRsrStruct->OutnetQueueB,&pRsrStruct->RpInfoStru.OutnetQueueB); + + /* ¼ */ + ShortToChar(0,pRsrStruct->RecordArray); + + /* 봦 */ + ret = RpReceive(&pRsrStruct->RpInfoStru); + if(0 == ret) + { + /* ¼ */ + return 0; + } + else + { + /* */ + } + + /* źŲ봦 */ + ret = SigReceive(LocalName,&pRsrStruct->RpInfoStru.DataToApp,&pRsrStruct->QueSig2Rs); + if(0 == ret) + { + /* ¼ */ + return 0; + } + else + { + /* */ + } + + /* RSSP봦 */ + ret = RsspReceive(&pRsrStruct->QueSig2Rs, &pRsrStruct->DataToApp,pRsrStruct); + if(0 == ret) + { + /* ¼ */ + return 0; + } + else + { + /* */ + } + + return ret; +} + +/*********************************************************************** + * : RsrOutput + * : ӦݽRSRİȫ + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ + * УpRsrStruct->OutputDataQueue + * УpRsrStruct->AppArray + * pRsrStruct->VarArray + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrOutput(RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0; + UINT16 LocalName = 0; /* ʶ */ + UINT16 DataLen = 0; /* ݵij */ + UINT16 RsspVarLen = 0; /* 鳤 */ + UINT8 index = 0; + UINT16 devName = 0; + Lnk_Info_Node_Stru* lnkNodeArr = NULL; + + UINT8 lnkNodeNum = 0; /* ڵ */ + + if(pRsrStruct == NULL) + { + return ret; + } + else + { + /* ʲô */ + } + TypeId2DevName(pRsrStruct->LocalType, pRsrStruct->LocalID, &LocalName); + + /* RSSP */ + ret = RsspOutput(&pRsrStruct->OutputDataQueue,&pRsrStruct->QueSig2Rs,pRsrStruct->VarArray+2,pRsrStruct); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + + /* źŲ */ + ret = SigOutput(LocalName,&pRsrStruct->QueSig2Rs, &pRsrStruct->RpInfoStru.OutputDataQueue); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + + /* */ + ret = RpOutput(&pRsrStruct->RpInfoStru); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* wangpeipei 20111213 Mod S */ + /* ·Ͽʱɾ· */ + GetLnkNodeArr(&lnkNodeArr,&lnkNodeNum,pRsrStruct); + for(index = 0;index < lnkNodeNum;index++) + { + /* ýڵΪɸǽڵ㣬ʼͳһṹ */ + if((lnkNodeArr[index].NodeStatus == Replace) && (lnkNodeArr[index].DestDevName == 0)) + { + devName = lnkNodeArr[index].DestDevName; + RpLnkDelete(devName,&pRsrStruct->RpInfoStru); + } + else + { + /* Nothing */ + } + } + /* wangpeipei 20111213 Mod E */ + /* RSRͳһṹ.AppArray = ͳһṹ.AppArray */ + pRsrStruct->AppArray = pRsrStruct->RpInfoStru.AppArray; + + /* + * м鿽 + * ------------------------------------------------------ + * ܳ | RSSP㳤 | RSSPм | м | + * 2 ֽ| 2ֽ | + * ------------------------------------------------------- + * Rssp㳤ԼRSSPмRSSP趨 + * + */ + RsspVarLen = ShortFromChar(pRsrStruct->VarArray+2); /* Rsspм */ + DataLen = ShortFromChar(pRsrStruct->RpInfoStru.VarArray); /* 㳤 */ + /* + * ṹVarArray[2]ʼм + * RsrͳһṹVarArray+4+RsspмȺλ + */ + RsrMemCopy(pRsrStruct->RpInfoStru.VarArray+2, + pRsrStruct->VarArray+4+RsspVarLen,DataLen); + + /* ܳ */ + ShortToChar((UINT16)(RsspVarLen+DataLen+2),pRsrStruct->VarArray); + + } + + ret = 1; + return ret; +} + +/*********************************************************************** + * : RsrInit + * : ͨúʵֶRSRijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ壬гʼֵá + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrInit(UINT8 *fileName,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0; + UINT32 tmp = 0; + UINT16 MaxMsgNum = 0; + UINT16 InputSize = 0, OutputSize = 0; + + /* */ + ret = CheckRsrStruct(pRsrStruct); + if(0 == ret) + { + return ret; + } + + InputSize = pRsrStruct->InputSize; + OutputSize = pRsrStruct->OutputSize; + + /* DSUѯгʼ */ + ret = dsuRsrInit(fileName); + if( 0 == ret ) + { + /* DSUѯʼʧ */ + return ret; + } + else + { + /* ʲô */ + } + + /* ͳһṹʼ */ + ret = InitRpStruct(pRsrStruct,&pRsrStruct->RpInfoStru); + if(0 == ret) + { + /* ʧ ʲô */ + return ret; + } + else + { + /* */ + } + + /* ʼ */ + ret = RpInit(fileName,&pRsrStruct->RpInfoStru); + if(0 == ret) + { + /* ʼʧ */ + return ret; + } + else + { + /* 㴦ɹ */ + } + + /* RSSPʼ */ + ret = RsspInit(pRsrStruct); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + + /* ʼ */ + MaxMsgNum = pRsrStruct->MaxNumLink *(pRsrStruct->MaxNumPerCycle + 2); /* */ + + /* RSRģ:ָռ */ + pRsrStruct->AppArraySize = pRsrStruct->RpInfoStru.AppArraySize; + pRsrStruct->AppArray = pRsrStruct->RpInfoStru.AppArray; + + /* RSRģмС */ + pRsrStruct->VarArraySize = pRsrStruct->RsspVarArraySize + pRsrStruct->RpInfoStru.VarArraySize + 32; + pRsrStruct->VarArray = (UINT8*)malloc(pRsrStruct->VarArraySize); + if( NULL == pRsrStruct->VarArray) + { + /* ¼ */ + return 0; + } + else + { + /* ʲô */ + CommonMemSet(pRsrStruct->VarArray,sizeof(UINT8)*pRsrStruct->VarArraySize,0,sizeof(UINT8)*pRsrStruct->VarArraySize); + } + + /* ЭӦõݶг */ + pRsrStruct->DataToAppSize = (InputSize + 6) * MaxMsgNum; /* ЭӦõݶг */ + ret = QueueInitial(&pRsrStruct->DataToApp,pRsrStruct->DataToAppSize); + if(0 == ret) + { + return ret; + } + else + { + /* ʲô */ + } + + /* ӦøЭݶг */ + pRsrStruct->OutputDataQueueSize= (OutputSize + 8 )*MaxMsgNum; + ret = QueueInitial(&pRsrStruct->OutputDataQueue,pRsrStruct->OutputDataQueueSize); + if(0 == ret) + { + return ret; + } + else + { + /* ʲô */ + } + + /* ܶг */ + pRsrStruct->OutnetQueueSize = pRsrStruct->RpInfoStru.OutnetQueueSize; /* Ľܶгһ */ + /* */ + ret = QueueInitial(&pRsrStruct->OutnetQueueA,pRsrStruct->OutnetQueueSize); + if(0 == ret) + { + return ret; + } + else + { + /* ʲô */ + } + + /* */ + ret = QueueInitial(&pRsrStruct->OutnetQueueB,pRsrStruct->OutnetQueueSize); + if(0 == ret) + { + return ret; + } + else + { + /* ʲô */ + } + + /* ʱг */ + tmp = pRsrStruct->OutnetQueueSize > pRsrStruct->AppArraySize ? pRsrStruct->OutnetQueueSize:pRsrStruct->AppArraySize; + ret = QueueInitial(&pRsrStruct->QueSig2Rs,tmp); + if(0 == ret) + { + return ret; + } + else + { + /* ʲô */ + } + /* ¼ */ + pRsrStruct->RecordArray = pRsrStruct->RpInfoStru.RecordArray; + + ret = 1; + return ret; +} + +/*********************************************************************** + * : RsrFreeSpace + * : ͨúͷRSR㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ壬гʼֵá + * ֵ : UINT8 0 󷵻 1 + ***********************************************************************/ +UINT8 RsrFreeSpace(RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0; + + if(pRsrStruct == NULL) + { + return ret; + } + + /* ռͷ */ + ret = RpFreeSpace(&pRsrStruct->RpInfoStru); + if(0 == ret) + { + /* ʧ */ + return ret; + } + else + { + /* 㴦ɹ */ + } + + /* RSSPռͷ */ + ret = RsspFreeSpace(pRsrStruct); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + + /* ռͷ */ + + /* RSRģ:ָռ ͷ */ + pRsrStruct->AppArray = NULL; + + /* RSRģмռͷ */ + if( NULL != pRsrStruct->VarArray) + { + free(pRsrStruct->VarArray); + pRsrStruct->VarArray = NULL; + } + else + { + /* ʲô */ + } + + /* ЭӦõݶг */ + ret = QueueElementFree(&pRsrStruct->DataToApp); + + /* ӦøЭݶг */ + ret = QueueElementFree(&pRsrStruct->OutputDataQueue); + + /* ܶг */ + /* */ + ret = QueueElementFree(&pRsrStruct->OutnetQueueA); + + /* */ + ret = QueueElementFree(&pRsrStruct->OutnetQueueB); + + /* ʱг */ + ret = QueueElementFree(&pRsrStruct->QueSig2Rs); + + /* ¼ ͷţ㹲ڴָ */ + pRsrStruct->RecordArray = NULL; + + ret = 1; + return ret; +} + + +/*********************************************************************** + * : RsrLnkStatus + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * RsSAdd UINT16 IN RSSPԴַ + * BsDAdd INT16 IN BSDַ + * SeDAdd UINT16 IN RSSPĿַSSESSRַ + * ֵ : UINT8 0ڸ·ش; + * 0x17·ݴ״̬DATA + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 RsrLnkStatus(UINT16 RsSAdd,INT16 BsDAdd,UINT16 SeDAdd,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0; + ret = RsspLnkStatus(RsSAdd,BsDAdd,SeDAdd,pRsrStruct); + return ret; +} + +/*********************************************************************** + * : RsrLnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * RsSAdd UINT16 IN RSSPԴַ + * BsDAdd INT16 IN BSDַ + * SeDAdd UINT16 IN RSSPĿַSSESSRַ + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ +UINT8 RsrLnkDelete(UINT16 RsSAdd,INT16 BsDAdd,UINT16 SeDAdd,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 1; + UINT16 devName = 0; + /* wangpeipei 20111207 ADD S */ + + ret = RsspLnkDelete(RsSAdd,BsDAdd,SeDAdd,&devName,pRsrStruct); + + if(ret == 0) + { + return ret; + } + else + { + /* ޲ */ + } + + /* ɾ· */ + ret = RpLnkDelete(devName,&pRsrStruct->RpInfoStru); + /* wangpeipei 20111207 ADD S */ + return ret; +} + +/*********************************************************************** + * : RsrRefresh + * : Ӧʹøú¶ԱRSRм¸ֵ + * : + * + * -------------------------------------------------------------- + * sLen_Input UINT16 IN мĴС + * Input_Data_LnkMes UINT8 IN м + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ +UINT8 RsrRefresh(UINT16 sLen_Input, UINT8* Input_Data_LnkMes,RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 0; + UINT16 RsspVarLen = 0; /* Rsspм */ + UINT16 RpVarLen = 0; /* м */ + + /* ǿռ */ + if(NULL == Input_Data_LnkMes) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + RsspVarLen = ShortFromChar(Input_Data_LnkMes); + + /* ȼ */ + if((RsspVarLen+2) > sLen_Input) + { + /* ȲϷ */ + return ret; + } + else + { + /* ʲô */ + } + + /* + * Input_Data_LnkMesʽ + * --------------------------------------------------- + * | RSSP㳤 | RSSPм | м | + * | 2ֽ | N | M | + * --------------------------------------------------- + * + */ + + /* Rsspмˢ */ + ret = RsspRefresh(RsspVarLen,Input_Data_LnkMes+2, pRsrStru); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + + /* ˢ */ + RpVarLen = sLen_Input - RsspVarLen-2; /* м */ + ret = RpRefresh(RpVarLen, + Input_Data_LnkMes+2+RsspVarLen,&pRsrStru->RpInfoStru); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + ret = 1; + return ret; +} + +/*-------------------------------------------------------------------- + * RSRӿں End + *--------------------------------------------------------------------*/ + + +/*-------------------------------------------------------------------- + * RSRڲʹú Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : InitRpStruct + * : ͳһṹгʼ + * : + * + * -------------------------------------------------------------- + * pRsrInfoStru const RSR_INFO_STRU* IN RSRͳһṹ + * pRpInfoStru RP_INFO_STRU * IN ͳһṹ + * + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ + +static UINT8 InitRpStruct(const RSR_INFO_STRU *pRsrInfoStru, RP_INFO_STRU *pRpInfoStru) +{ + UINT8 DestType = 0,DestDevNum = 0; /* Է豸࣬Է豸 */ + UINT8 ret = 0; + pRpInfoStru->LocalID = pRsrInfoStru->LocalID; /* 豸ID */ + pRpInfoStru->LocalType = pRsrInfoStru->LocalType; /* 豸Type */ + + pRpInfoStru->MaxNumPerCycle = pRsrInfoStru->MaxNumPerCycle; /* */ + pRpInfoStru->RecordArraySize = pRsrInfoStru->RecordArraySize; /* ¼ */ + + /* wangpeipei 20111205 MOD S */ + /* ôСʾ뱾ͨŵָͨŶ + * ɳվͳ׷ӡڴ˷ѱȽءVOBCʱNվͨ󣬵һʱֻһͨţ + * ˷ѡ˸ijͬʱͨŵ˷ѡͬʱչ + * ޸ĺҪҲṩɾ·(кűʹ) + */ + pRpInfoStru->MaxNumLink = pRsrInfoStru->MaxNumLink; + /* wangpeipei 20111205 MOD E */ + + /* */ + pRpInfoStru->InputSize = pRsrInfoStru->InputSize + (SIGHEADER_APP_TYPE+1) + RSSP_FIXED_LEN; + /* */ + pRpInfoStru->OutputSize = pRsrInfoStru->OutputSize + (SIGHEADER_APP_TYPE+1) + RSSP_FIXED_LEN; + + ret = 1; + return ret; +} + /* + * ͳһṹĸĿм顣 + */ +static UINT8 CheckRsrStruct(const RSR_INFO_STRU *pRsrInfoStru) +{ + UINT8 ret = 0; + const UINT16 MaxDataLen = MAX_RSSP_MSG -RSSP_FIXED_LEN; /* ӦݴС1400-22 */ + + /* ͳһṹָ벻Ϊ */ + if(pRsrInfoStru == NULL) + { + return ret; + } + + /* ͼ */ + + /* wangpeipei 20111205 Del S */ + /* + * ɾͼ顣 + */ + /* wangpeipei 20111205 Del E */ + + /* Ŀ */ + if( (pRsrInfoStru->MaxNumLink == 0) || (pRsrInfoStru->MaxNumPerCycle == 0)) + { + return ret; + } + + /* Ӧ */ + if( (0 == pRsrInfoStru->InputSize) || (pRsrInfoStru->InputSize > MaxDataLen)) + { + return ret; + } + + /* Ӧ */ + if( (0 == pRsrInfoStru->OutputSize ) || (pRsrInfoStru->OutputSize > MaxDataLen)) + { + return ret; + } + + /* ں */ + if( pRsrInfoStru->CycleNum == NULL) + { + return ret; + } + + ret = 1; + return ret; +} + + /* + * Զнп + */ +static void QueueCopy(QueueStruct *QueFrom,QueueStruct *QueTo) +{ + UINT8 data[1400] = {0}; + UINT32 Len = 0; + Len =QueueStatus(QueFrom); + while(Len > 0) + { + if( Len > 1400 ) + { + QueueRead(1400,data,QueFrom); + QueueWrite(1400,data,QueTo); + Len = Len-1400; + } + else + { + QueueRead(Len,data,QueFrom); + QueueWrite(Len,data,QueTo); + Len = 0; + } + } +} + + +/*-------------------------------------------------------------------- + * RSRڲʹú End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/Rsr.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/Rsr.h new file mode 100644 index 0000000..164d3ba --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/Rsr.h @@ -0,0 +1,143 @@ +/******************************************************** +* +* ļ Rsr.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.10.25 +* ؼЭ鲿 +* RsrЭʵ +* ʹע⣺ +* +* ޸ļ¼ +* +********************************************************/ + +#ifndef _RSR_H_ +#define _RSR_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "RpPlatform.h" +#include "RsspStruct.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + +/*-------------------------------------------------------------------- + * RSRӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : RsrReceive + * : ԺݽRSRİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ + * УpRsrStruct->OutnetQueueA + * pRsrStruct->OutnetQueueB + * УpRsrStruct->DataToApp + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrReceive(RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : RsrOutput + * : ӦݽRSRİȫ + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ + * УpRsrStruct->OutputDataQueue + * УpRsrStruct->AppArray + * pRsrStruct->VarArray + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrOutput(RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : RsrInit + * : ͨúʵֶRSRijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ壬гʼֵá + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrInit(UINT8* fileName,RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : RsrFreeSpace + * : ͨúͷRSR㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrFreeSpace(RSR_INFO_STRU *pRsrStruct); + + +/*********************************************************************** + * : RsrLnkStatus + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * RsSAdd UINT16 IN RSSPԴַ + * BsDAdd INT16 IN BSDַ + * SeDAdd UINT16 IN RSSPĿַSSESSRַ + * ֵ : UINT8 0ڸ·ش + * 0x17·ݴ״̬DATA + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 RsrLnkStatus(UINT16 RsSAdd,INT16 BsDAdd,UINT16 SeDAdd,RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : RsrLnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * RsSAdd UINT16 IN RSSPԴַ + * BsDAdd INT16 IN BSDַ + * SeDAdd UINT16 IN RSSPĿַSSESSRַ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrLnkDelete(UINT16 RsSAdd,INT16 BsDAdd,UINT16 SeDAdd,RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : RsrRefresh + * : Ӧʹøú¶ԱRSRм¸ֵ + * : + * + * -------------------------------------------------------------- + * sLen_Input UINT16 IN мĴС + * Input_Data_LnkMes UINT8* IN м + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsrRefresh(UINT16 sLen_Input, UINT8* Input_Data_LnkMes,RSR_INFO_STRU *pRsrStruct); + +/*-------------------------------------------------------------------- + * RSRӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrCommon.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrCommon.c new file mode 100644 index 0000000..151f4a3 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrCommon.c @@ -0,0 +1,164 @@ +/******************************************************** +* +* ļ RsrCommon.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.10.25 +* ؼЭ鲿 +* Rsr㹲ͨ +* ʹע⣺ +* +* ޸ļ¼ +* +********************************************************/ +#include "RsrCommon.h" +#include "Convert.h" + + +/*崻¼Ϣ*/ +UINT32 gRsrErrorInfo; + +/* ڲȫֱ */ +/* RSR_INFO_STRU *gpRsrInfoStru; */ + +/*-------------------------------------------------------------------- + * RSRڹú Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : MemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pDestAdd UINT8 * INOUT ڴռ俪ʼַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : 1 + ***********************************************************************/ +UINT8 RsrMemSet(UINT8 *pDestAdd, UINT16 Len, UINT8 Val) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = Val; + } + + return (UINT8)1; +} + +/*********************************************************************** + * : MemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pSrcAdd const UINT8 * IN Դڴռַ + * pDestAdd UINT8 * INOUT Ŀڴռַ + * Len UINT16 IN ڴռС + * + * ֵ : 1 + ***********************************************************************/ +UINT8 RsrMemCopy(const UINT8 *pSrcAdd,UINT8 *pDestAdd, UINT16 Len) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = pSrcAdd[index]; + } + + return (UINT8)1; +} + +/*********************************************************************** + * : TypeId2DevName + * : TypeID ȡӦ豸ʶ + * : + * + * -------------------------------------------------------------- + * Type UINT8 IN + * ID UINT8 IN Id + * pDevName UINT16* OUT ʶ + * + * ֵ : + ***********************************************************************/ +void TypeId2DevName(UINT8 Type, UINT8 Id, UINT16* pDevName) +{ +#ifdef TYPE_ID_2_DEVNAME_USE_COMM + UINT8 buff[2]; + buff[0] = Type; + buff[1] = Id; + + *pDevName = ShortFromChar(buff); +#else + *pDevName = Type; + *pDevName = (*pDevName)*0x100 + Id; +#endif + return; +} + +/*********************************************************************** + * : DevName2TypeId + * : ȡӦͺId + * : + * + * -------------------------------------------------------------- + * DevName UINT8 IN ʶ + * pType UINT8* OUT + * pID UINT8* OUT Id + * + * ֵ : + ***********************************************************************/ +void DevName2TypeId(UINT16 DevName, UINT8* pType,UINT8* pId) +{ +#ifdef TYPE_ID_2_DEVNAME_USE_COMM + UINT8 buff[2]; + ShortToChar(DevName,buff); + *pType = buff[0]; + *pId = buff[1]; +#else + *pId = (UINT8)(DevName % 0x100); + *pType =(UINT8)(DevName /0x100); +#endif + return; +} +/******************************************************************************************************* +* : RSRЭ鶪ͷ崻 +* : +* : +* : gRsrErrorInfo +* ȫֱ: gRsrErrorInfo +* ֵ: gRsrErrorInfo +*******************************************************************************************************/ + +UINT32 GetRsrErrorInfo(void) +{ + UINT32 ret = 0; + ret = gRsrErrorInfo; + return ret; +} +/******************************************************************************************************* +* : RSRЭ鶪ͷ崻븴λ +* : +* : +* : gRsrErrorInfo +* ȫֱ: gRsrErrorInfo +* ֵ: 1:ɹ +*******************************************************************************************************/ + +UINT32 ReSetRsrErrorInfo(void) +{ + UINT32 ret = 1; + gRsrErrorInfo = 0; + return ret; +} + +/*-------------------------------------------------------------------- + * RSRڲú End + *--------------------------------------------------------------------*/ + + + + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrCommon.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrCommon.h new file mode 100644 index 0000000..8e64bf7 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrCommon.h @@ -0,0 +1,124 @@ +/******************************************************** +* +* ļ RsrCommon.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.10.25 +* ؼЭ鲿 +* Rsr㹲ͨ +* ʹע⣺ +* +* ޸ļ¼ +* 2010.05.10 ¥ΰ RsrConfig.h Ϊ RsrPlatform.h +* +********************************************************/ + +#ifndef _RSR_COMMON_H_ +#define _RSR_COMMON_H_ + +#include "Rsr.h" +#include "CommonTypes.h" +#include "RsrPlatform.h" +#include "sigInterface.h" + + +#ifndef NULL +#define NULL 0 +#endif + +/* */ +#define RSR_TYPE_ZC 0x1E /* ZC */ +#define RSR_TYPE_CI 0x3C /* CI */ +#define RSR_TYPE_CC 0x14 /* CC */ + + +#define MAX_RSSP_MSG 1400 /* RSSPϢ֡󳤶ȣźŲϢС */ + +#define TYPE_ID_2_DEVNAME_USE_COMM /* TRUE Type Id תΪʶ ʹùͨת */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*崻¼Ϣ*/ +extern UINT32 gRsrErrorInfo; + +/* ڲȫֱ */ +/*extern RSR_INFO_STRU *gpRsrInfoStru;*/ + +/*-------------------------------------------------------------------- + * RSRڹú Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : RsrMemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pDestAdd UINT8 * INOUT ڴռ俪ʼַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : + ***********************************************************************/ +UINT8 RsrMemSet(UINT8 *pDestAdd, UINT16 Len, UINT8 Val); + +/*********************************************************************** + * : RsrMemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pSrcAdd const UINT8 * IN Դڴռַ + * pDestAdd UINT8 * INOUT Ŀڴռַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : + ***********************************************************************/ +UINT8 RsrMemCopy(const UINT8 *pSrcAdd,UINT8 *pDestAdd, UINT16 Len); + +/*********************************************************************** + * : TypeId2DevName + * : TypeID ȡӦ豸ʶ + * : + * + * -------------------------------------------------------------- + * Type UINT8 IN + * ID UINT8 IN Id + * pDevName UINT16* OUT ʶ + * + * ֵ : + ***********************************************************************/ +void TypeId2DevName(UINT8 Type, UINT8 Id, UINT16* pDevName); + +/*********************************************************************** + * : DevName2TypeId + * : ȡӦͺId + * : + * + * -------------------------------------------------------------- + * DevName UINT16 IN ʶ + * pType UINT8* OUT + * pID UINT8* OUT Id + * + * ֵ : + ***********************************************************************/ +void DevName2TypeId(UINT16 DevName,UINT8* pType, UINT8* pId); + + +UINT32 GetRsrErrorInfo(void); +UINT32 ReSetRsrErrorInfo(void); + + +/*-------------------------------------------------------------------- + * RSRڲú End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrPlatform.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrPlatform.h new file mode 100644 index 0000000..d283098 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrPlatform.h @@ -0,0 +1,47 @@ +/******************************************************** +* +* ļ RsrPlatform.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.10.25 +* ؼЭ鲿 +* Rsrļ +* ʹע⣺ +* +* ޸ļ¼ +* 2010.05.10 ¥ΰ ΪRsrPlatform.hͳһ +* 2010.05.10 ¥ΰ Ѽ¼ض嵽RsrConfig.hļ +* +*2012-8-15 15:54:00 ޸ļ¼ +* 1.RSRЭ汾ź궨 +********************************************************/ +#ifndef _RSR_PLATFORM_H_ +#define _RSR_PLATFORM_H_ + +#include "CommonTypes.h" +#include "RsrConfig.h" + +#define RSR_VER_NORMAL 0x01 /* Release */ +#define RSR_VER_RP_ONLY 0x02 /* ֻ */ + +/* RSRЭ汾 */ +#define RSRCODE_VER_PRODUCT_NO 66 +#define RSRCODE_VER_MODULE_NO 3 +#define RSRCODE_VER_MAIN_VER 2 +#define RSRCODE_VER_SUB_VER 0 + +#define RSR_VERSION RSR_VER_NORMAL /* ǰʹð汾 */ + +/* ƽ̨ */ +/* Ҫʵʵƽ̨ */ +#define ENM_ZC (CBTC_VXWORKS) /* ZC */ +#define ENM_CC (CBTC_MOTOROLA) /* VOBC */ +#define ENM_CI (CBTC_WINDOWS) /* CI */ + +/* ֻ */ +/* #define RSR_RP_ONLY */ +/* */ +#define RSR_NORMAL + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrRecordDelare.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrRecordDelare.h new file mode 100644 index 0000000..5a44fd0 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/RsrRecordDelare.h @@ -0,0 +1,113 @@ +/******************************************************** +* +* ļ RsrRecordDelare.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.12.16 +* ؼЭ鲿 +* RSR¼غ궨塣 +* ʹע⣺ +* +* ޸ļ¼ +* 2010.05.10 ޸ ׷Rsspڿʼʶ +* +********************************************************/ + + +#ifndef _RSR_RECORD_DECLARE_H +#define _RSR_RECORD_DECLARE_H + + +/******************************************************************************** +궨 +********************************************************************************/ + +/* ־λ */ +#define RSSP_CYCLE_TAG 0xEE /* RSSPڿʼʶ A_2010_05_10 */ +#define RSSP_RCV_TAG 0xF4 /* RSSP뵥Ԫʶ */ +#define RSSP_OUT_TAG 0xF5 /* RSRԪʶ */ +#define RSSP_MSG_IN_TAG 0x04 /* RSSPһ֡Ϣʼʶ(B 0000 0100) */ +#define RSSP_MSG_OUT_TAG 0x08 /* RSSPһ֡Ϣʼʶ(B 0000 1000) */ +#define RSSP_NODE_OUT_TAG 0x0C /* RSSPһ֡Ϣʼʶ(B 0000 1100) */ +#define RSSP_OUT_E_TAG 0x0F /* RSSPԪʶ(B 0000 1111) */ + +/************************************************************************ + * ԭЭһ16bit + * D15~D12 + * D11~D10ȼ + * D9~D8ģλ + * D7~D4ģеĴģ鲻ͬʱ4λĺ岻ͬ + * ڶȵײ + * D3~D0ģǷͬ4λĺͬ +************************************************************************/ +/* ȼ */ +#define RSR_ERR 0x0800 +#define RSR_WARN 0x0400 + +/* ģλ */ +#define RSR_RECEIVE 0x0200 /* ģ */ +#define RSR_OUTPUT 0x0100 /* ģ */ + +/* ģд */ +#define RSR_ERROR_NULL 0x0000 +/* */ +#define RSR_MSG_TYPE_ILLEGAL 0x0010 /* RSSPϢ */ +#define RSR_MSG_OLD_ERR 0x0020 /* ± */ +#define RSR_DEL_MSG_LNK_ERR 0x0030 /* ʱɾʧ */ +#define RSR_MSG_NOT_NODE_ERR 0x0040 /* ϢͨŽڵϢһ */ +#define RSR_MSG_LEN_ERR 0x0050 /* ijȲ */ +#define RSR_MSG_FMT_ILLEGAL 0x0060 /* ĸʽ */ +#define RSR_SSR_NOT_ILLEGAL 0x0070 /* ǶӦSSRϢ */ +#define RSR_MSG_REPLACE_ERR 0x0080 /* ǽڵʧ */ +#define RSR_MSG_NO_REPLACENODE 0x0090 /* ڸǽڵ */ +#define RSR_MSG_NO_INVALID 0x00A0 /* BSDʧ */ + +/* */ +#define RSR_DBGET_ERR 0x0050 /* ݿѯ */ +/* ײ㴦 */ +#define RSR_QUEUE_READ 0x0001 /* жд */ +#define RSR_QUEUE_WRITE 0x0002 /* дд */ +#define RSR_QUEUE_INTEGRITY 0x0003 /* ݲscanдӦø*/ +#define RSR_LNK_PUSH 0x0004 /* ·ڵѹջ */ +#define RSR_LNK_POP 0x0005 /* кŻڵջ */ + + +/******궨**************/ +#define RSR_WARN_RECEIVE_RSR_MSG_NOT_NODE_ERR 0x00000001 /*ģ鱨ϢͨŽڵϢһ*/ +#define RSR_WARN_RECEIVE_RSR_MSG_LEN_ERR 0x00000002 /*ģ鱨ijȲȷ*/ +#define RSR_WARN_RECEIVE_RSR_SSR_NOT_ILLEGAL 0x00000004 /*ģ鲻ǶӦSSRϢ*/ +#define RSR_WARN_RECEIVE_RSR_MSG_NO_INVALID 0x00000008 /*ģBSDʧ*/ +#define RSR_WARN_RECEIVE_RSR_MSG_REPLACE_ERR 0x00000010 /*ģ鸲ǽڵʧ*/ +#define RSR_WARN_RECEIVE_RSR_MSG_NO_REPLACENODE 0x00000020 /*ģ鲻ڸǽڵ*/ +#define RSR_WARN_RECEIVE_RSR_MSG_OLD_ERR 0x00000040 /*ģ±*/ +#define RSR_WARN_RECEIVE_RSR_QUEUE_WRITE 0x00000080 /*ģдд*/ +#define RSR_WARN_RECEIVE_RSR_DEL_MSG_LNK_ERR 0x00000100 /*ģʱɾʧ*/ +#define RSR_WARN_RECEIVE_RSR_QUEUE_READ 0x00000200 /*ģжд*/ +#define RSR_WARN_RECEIVE_RSR_LNK_POP 0x00000400 /*ģкŻڵջ*/ +#define RSR_WARN_RECEIVE_RSR_MSG_TYPE_ILLEGAL 0x00000800 /*ģ鲻RSSPϢ*/ +#define RSR_WARN_RECEIVE_RSR_QUEUE_INTEGRITY 0x00001000 /*ģݲ*/ + +#define RSR_WARN_OUTPUT_RSR_QUEUE_READ 0x00002000 /*ģжд*/ +#define RSR_WARN_OUTPUT_RSR_MSG_FMT_ILLEGAL 0x00004000 /*ģ鱨ĸʽ*/ +#define RSR_WARN_OUTPUT_RSR_MSG_REPLACE_ERR 0x00008000 /*ģ鸲ǽڵʧ*/ +#define RSR_WARN_OUTPUT_RSR_QUEUE_WRITE 0x00010000 /*ģдʧ*/ + + + + + + + + + + + + + + + + + + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspCommon.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspCommon.c new file mode 100644 index 0000000..712b15a --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspCommon.c @@ -0,0 +1,855 @@ +/************************************************************************ +* +* ļ RsspCommon.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.10.02 +* ؼЭ鲿 +* RSSPЭʹõFLSR麯. +* ʹע ʹ֮ǰinittabgTableFastֵ趨 +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +* 2009/11/01 ¥ΰ +* 2009/12/02 ¥ΰ MisraCӦ +* +************************************************************************/ + +#include "RsspCommon.h" +#include "Convert.h" + +/*---------------------------------------------------------------------- + * ȫֹͨMASK鶨 Start + *---------------------------------------------------------------------*/ + +#define DIMTAB 256 + +const UINT32 SYS_CHK_WD[2] ={0xAE390B5AL,0xC103589CL}; /* system check word */ +UINT32 gTableFast[CHAN_NUM][DIMTAB]; /* LFSRλʹõı */ +const UINT32 gMaskLFSR[CHAN_NUM] = /* LFSRλ MASK */ + {0x0FC22F87,0xC3E887E1}; + +/*---------------------------------------------------------------------- + * ȫֹͨMASK鶨 END + *---------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------- + * LFSR Start + *---------------------------------------------------------------------*/ +UINT8 inittab(UINT8 chan); +UINT32 pd_shift_left(UINT32 regLFSR, UINT8 chan, UINT8 nshift); +UINT32 pd_shift_right(UINT32 regLFSR, UINT8 chan, UINT8 nshift); +UINT32 pd_shl_fast(UINT32 regLFSR, UINT8 chan, UINT8 nshift); + +/*---------------------------------------------------------------------- + * End + *---------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------- + * LFSR Start + *---------------------------------------------------------------------*/ + +/*********************************************************************** + * : F_Add + * : LFSRļ㡣Ĵֵ ȻLFSR32λ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in ĴʵΪLFSR1 + * chan UINT8 in channel + * val UINT32 in 2 + * ֵ: UINT32 + ***********************************************************************/ +UINT32 F_ADD(UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + regLFSR ^= val; + regLFSR = pd_shl_fast(regLFSR, chan, 32); + return regLFSR; +} + +/*********************************************************************** + * : F_Sub + * : LFSRļ㡣ĴֵLFSR32λ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in ĴʵΪLFSRı + * chan UINT8 in channel + * val UINT32 in + * ֵ: UINT32 + ***********************************************************************/ + UINT32 F_SUB(UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + regLFSR = pd_shift_right(regLFSR, chan, 32); + regLFSR ^= val; + return regLFSR; +} + + +/*********************************************************************** + * : F_Post + * : LFSRļ㡣ֵLFSR32λĴ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in ĴʵΪLFSRı + * chan UINT8 in channel + * val UINT32 in + * ֵ: UINT32 + ***********************************************************************/ +UINT32 F_POST(UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + UINT32 tmpVal = 0; + + tmpVal = regLFSR; + regLFSR = val; + regLFSR = pd_shift_right(regLFSR, chan, 32); + regLFSR ^= tmpVal; + + return regLFSR; +} + +/*********************************************************************** + * : F_XOR + * : ԼĴ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * val UINT32 in + * ֵ: UINT32 + ***********************************************************************/ +UINT32 F_XOR(UINT32 regLFSR, UINT32 val) +{ + regLFSR ^= val; + return regLFSR; +} + + +/*********************************************************************** + * : F_LOAD + * : ֵ뵽Ĵ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * val UINT32 in Ĵ + * ֵ: UINT32 ؼĴֵ + ***********************************************************************/ +UINT32 F_LOAD(UINT32 regLFSR, UINT32 val) +{ + regLFSR = val; + return regLFSR; +} + +/*********************************************************************** + * : F_READ + * : Ĵݡ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * ֵ: UINT32 ؼĴֵ + ***********************************************************************/ +UINT32 F_READ(UINT32 regLFSR) +{ + return regLFSR; +} + +/*********************************************************************** + * : inittab + * : ȫLFSRƳgTableFastгڻ + * : + * + * -------------------------------------------------------------- + * chan UINT8 in channel ID + * + * ȫֱ : gTableFast[CHAN_NUM][DIMTAB] + * ֵ : UINT8 1: 0: + ***********************************************************************/ +UINT8 inittab(UINT8 chan) +{ + UINT8 ret = 0; + UINT32 index = 0; + UINT32 regLFSR = 0; + UINT32 value = 0; + + for(index = 0; index < DIMTAB; index++) + { + + value = index << 24; + value = value & 0x0FF000000; + regLFSR = F_LOAD(regLFSR,value); + regLFSR = pd_shift_left(regLFSR,chan,8); + gTableFast[chan][index] = F_READ(regLFSR); + } + ret = 1; + return ret; +} + +/*********************************************************************** + * : pd_shift_left + * : Ĵָλ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * chan UINT8 in channel ID + * nshift UINT8 in ƶλ + * + * ȫֱ : gMaskLFSR[chan] LFSR mask + * ֵ : UINT32 λֵ + ***********************************************************************/ +UINT32 pd_shift_left(UINT32 regLFSR, UINT8 chan, UINT8 nshift) +{ + UINT8 index = 0; + UINT32 carry = 0; + + for(index=0; index>= 1; + if(0 != carry) + { + regLFSR |= 0x80000000L; + } + } + + return regLFSR; +} + + +/*********************************************************************** + * : pd_shift_right + * : Ĵָλ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * chan UINT8 in channel ID + * nshift UINT8 in ƶλ + * + * ȫֱ : gMaskLFSR[chan] LFSR mask + * ֵ : UINT32 λֵ + ***********************************************************************/ +UINT32 pd_shl_fast(UINT32 regLFSR, UINT8 chan, UINT8 nshift) +{ + UINT32 tmp = 0; + UINT8 shiftCount = 0; + UINT8 index = 0; + static UINT8 tabInitFlg[CHAN_NUM] = {0}; + + /* ԿƱڻ */ + if( 1 != tabInitFlg[chan] ) + { + tabInitFlg[chan] = inittab(chan); + } + + shiftCount = nshift >> 3; /* 8 */ + for(index = 0; index < shiftCount; index++) + { + tmp = regLFSR >> 24; + regLFSR <<= 8; + regLFSR &= 0x0FFFFFF00; + regLFSR ^= gTableFast[chan][tmp&(UINT32)0xFF]; + } + return regLFSR; +} + +/*---------------------------------------------------------------------- + * LFSR End + *---------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------- + * RSSP֡֡ Start + *---------------------------------------------------------------------*/ + +/*********************************************************************** + * : CheckTimeStamp + * : ԽձĽм飬Ƿʱ + * : + * + * -------------------------------------------------------------- + * nowTCr UINT32 in ǰյıʱ + * lastTCr UINT32 in ϴյıʱ + * maxLost UINT32 in ֵ + * + * ֵ : UINT32 + * -1 : ʧ + * >=0 : ֵ + ***********************************************************************/ +INT32 CheckTimeStamp(UINT32 nowTCr, UINT32 lastTCr, UINT32 maxLost) +{ + INT32 ret = 0; + + ret = nowTCr - lastTCr -1; /* */ + if( ret > (INT32)maxLost) + { + /* ֵ */ + ret = -1; + } + else + { + /* ʲô */ + ; + } + + return ret; +} + +/*********************************************************************** + * : GetSidXorTn + * : ȡBSDSID XOR TN ֵ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const UINT8* in BSD + * outSidXorTn UINT32[2] out Sid ^ T(n) + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 GetSidXorTn(const UINT8* pBsdMsg,UINT32 outSidXorTn[CHAN_NUM]) +{ + UINT8 ret = 1; /* ֵ 1: */ + UINT8 chan = 0; /* źŵ */ + UINT16 dataLen = 0; /* ݳ */ + UINT32 CRC[CHAN_NUM] = {0}; /* ݵİȫCRC */ + UINT32 CRCM[CHAN_NUM] = {0}; /* ĵCRCM */ + + if( NULL == (void *)pBsdMsg) /* null check */ + { + ret = 0; /* 󷵻 */ + return ret; + } + + dataLen = ShortFromCharLE(&pBsdMsg[RSSP_DATA_SIZE_POS])-2*CRCM_LEN; /* ݳȻ */ + + for(chan = 0; chan < CHAN_NUM; chan++) + { + /* CRC */ + if(0 == dataLen) + { + CRC[chan] = 0; + } else + { + CRC[chan] = CRC_Compute_Crc(pBsdMsg+RSSP_DATA_POS, dataLen, chan); /* 32λCRC */ + } + + CRCM[chan] = LongFromCharLE(pBsdMsg+RSSP_CRCM_1_POS+chan*CRCM_LEN); /* ȡCRCM */ + + /* ĵ SID^T(n) */ + outSidXorTn[chan] = CRCM[chan] ^ CRC[chan] ^ SYS_CHK_WD[chan]; + } + return ret; +} + +/*********************************************************************** + * : CheckCRCM + * : 鱨еCRCMSID^Tn()ȷԡ + * : + * + * -------------------------------------------------------------- + * sidXorTn const UINT32[2] in мSid^T(n) + * sinitAddSidXorTn const UINT32[2] in ϴεSINT Add (Sid ^ T(m)ֵ + * nDelayTCr UINT32 in + * POST_RXDAtA_K const UINT32[2][5] in ֵ߲POST_RXDATA_Kֵ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 CheckCRCM(const UINT32 sidXorTn[CHAN_NUM], + const UINT32 sinitAddSidXorTn[CHAN_NUM], + UINT32 nDelayTCr, + const UINT32 postRxdataK[CHAN_NUM][MAX_K]) +{ + UINT32 regLFSR = 0; + UINT8 chan =0,index = 0; + UINT8 ret = 1; /* ֵ 1 */ + + /* POST_RXDATA_K */ + for(chan = 0; chan < CHAN_NUM; chan++) + { + /* 0 Add (SINITr ADD [SIDr ^ T(n-k)] ADD 0 ....... ADD 0 ADD [SID ^ T(n)]) */ + regLFSR = F_LOAD(regLFSR, sinitAddSidXorTn[chan]); + for(index = 0; index < nDelayTCr; index++) + { + regLFSR = F_ADD(regLFSR, chan, 0); + } + regLFSR = F_ADD(regLFSR,chan,sidXorTn[chan]); + regLFSR = F_ADD(0,chan,regLFSR); + + /* CRCMȷ */ + if( F_READ(regLFSR) != postRxdataK[chan][nDelayTCr]) + { + ret = 0; + break; + } + else + { + /* ʲô*/ + } + } + + return ret; +} + +/*********************************************************************** + * : CalcCRCM + * : CRCMֵ + * : + * + * -------------------------------------------------------------- + * pData const UINT8 * in Ӧ + * DataLen UINT16 in Ӧݳ + * SID const UINT32[2] in ͷSID + * Tn const UINT32[2] in ǰʱ + * OutCRCM const UINT32[2] in CRCN + * + * pDataݳȱΪż + * + * ֵ : UINT8 1 1 + ***********************************************************************/ +UINT8 CalcCRCM(const UINT8 *pData, UINT16 DataLen, const UINT32 SID[CHAN_NUM], const UINT32 Tn[CHAN_NUM], UINT32 OutCRCM[CHAN_NUM]) +{ + UINT8 ret = 0; + UINT8 chan = 0; + UINT32 crc32[CHAN_NUM] = {0}; + + /* */ + if(0 == DataLen) + { + for(chan = 0; chan < CHAN_NUM; chan++) + { + OutCRCM[chan] = 0; + } + } + else + { + /* */ + for(chan = 0; chan < CHAN_NUM; chan++) + { + crc32[chan] = CRC_Compute_Crc(pData,DataLen,chan); /* 32λȫCRC */ + /* CRCM= CRC32 ^ SYSCKW ^ SID ^ Tn */ + OutCRCM[chan] = crc32[chan] ^ SYS_CHK_WD[chan] ^ SID[chan] ^ Tn[chan]; + } + } + ret =1; + return ret; +} + + +/*********************************************************************** + * : UpdtTmStmpStru + * : ϴεSinitAddSidXorTm㵱ǰıĵSinitAddSidXorTn + * Ҫ : 1 Result_A = SINIT ADD (SID ^ T(n-k)) ADD 0 ADD 0 ADD ....... ADD 0 ʡ K 0 Add ... + * 2 Result_B = PREC_SINIT_K(SIDSENDER) ADD (SID ^ T(n+1)) ADD (SID ^ T(n+1)) + * 3 SINIT ADD (SID ^ T(n)) = Result_A ^ Result_B + * : + * + * -------------------------------------------------------------- + * sidXorTn UINT32[2] in мSid^T(n) + * nowTCr UINT32 in ǰյĵʱ + * nDelayTCr UINT32 in + * precSinitK UINT32[2][5] in ֵֵ߲ + * pTmStmpStru TimeStampStru* inout ʱṹ壬ϴյʱ估SINIT ADD (SID ^ Tn)ֵ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 UpdtTmStmpStru(const UINT32 sidXorTn[CHAN_NUM], + UINT32 nowRecvTCr, + UINT32 nDelayTCr, + const UINT32 precSinitK[CHAN_NUM][MAX_K], + TimeStampStru* pTmStmpStru) +{ + UINT8 chan =0,index = 0; + UINT8 ret = 1; /* ֵ 1 */ + UINT32 resultA = 0, resultB = 0; + UINT32 regLFSR = 0; /* */ + + /* ʱṹָ */ + if( NULL == pTmStmpStru) + { + ret = 0; /* 󷵻 */ + return ret; + } + + /* ½ܱĵʱ */ + pTmStmpStru->LastRecvTCr = pTmStmpStru->NowRecvTCr; + pTmStmpStru->NowRecvTCr = nowRecvTCr; + + + /* ݹ Sinit Add Sid ^ T(n+k) */ + for(chan = 0; chan < CHAN_NUM; chan++) + { + /* Result_A = SINIT ADD (SID ^ T(n-k)) ADD 0 ADD 0 ADD ....... ADD 0 ʡ K 0 Add ... */ + regLFSR = F_LOAD(regLFSR,pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan]); /* load SINIT ADD (SID ^ T(n-k)) */ + for(index = 0; index < nDelayTCr + 2; index++) + { + regLFSR = F_ADD(regLFSR, chan, 0); + } + resultA = F_READ(regLFSR); + + /* Result_B = PREC_SINIT_K(SIDSENDER) ADD (SID ^ T(n+1)) ADD (SID ^ T(n+1)) */ + regLFSR = F_LOAD(regLFSR, precSinitK[chan][nDelayTCr]); + regLFSR = F_ADD(regLFSR,chan,sidXorTn[chan]); + regLFSR = F_ADD(regLFSR,chan,sidXorTn[chan]); + resultB = F_READ(regLFSR); + + /* + * SINIT ADD (SID ^ T(n)) + * SINIT ADD (SID ^ T(n)) = Result_A ^ Result_B + */ + pTmStmpStru->LastSINIT_ADD_SID_XOR_Tn[chan] = pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan]; + pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan] = resultA ^ resultB; + } + + return ret; +} + + +/*********************************************************************** + * : CalcFirstSinitAndSidXorTn + * : ʼ SinitAddSidXorTmֵյSSRʱá + * : + * Ҫ : + * + * -------------------------------------------------------------- + * precFirstSinit const UINT32[2] in ָźŵӦPREC_FIRSTSINIT + * senqINI const UINT32[2] in ָźŵӦSSRSEQINIֵ + * enqTCn const UINT32[2] in ָźŵSSEʱڶӦʱ + * outSntAndSidXorTn UINT32[2] out + * + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 CalcFirstSinitAndSidXorTn(const UINT32 precFirstSinit[CHAN_NUM], + const UINT32 senqINI[CHAN_NUM], + const UINT32 enqTCn[CHAN_NUM], + UINT32 outSntAndSidXorTn[CHAN_NUM]) +{ + UINT8 ret =0; + UINT32 regLFSR = 0; + UINT8 chan = 0; + for(chan = 0; chan < CHAN_NUM;chan++) + { + regLFSR = F_LOAD(regLFSR,precFirstSinit[chan]); + regLFSR = F_ADD(regLFSR,chan,senqINI[chan]^enqTCn[chan]); + outSntAndSidXorTn[chan] = F_READ(regLFSR); + } + ret =1; + return ret; +} + +/*********************************************************************** + * : AddTimeStamp + * : 1Ӧʱ¡ + * : + * + * -------------------------------------------------------------- + * pTmStmpStru TimeStampStru* inout ʱṹ һ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 AddTimeStamp(TimeStampStru *pTmStmp) +{ + UINT8 ret =1; + UINT8 chan; + UINT32 regLFSR = 0; /* 32λĴ */ + if(NULL == (void *)pTmStmp) + { + ret = 0; /* 󷵻 */ + } + else + { + pTmStmp->TC++; /* 1 */ + for(chan = 0; chan < CHAN_NUM; chan++) + { + /* ¶Ӧڵʱ */ + pTmStmp->LastTn[chan] = pTmStmp->NowTn[chan]; + /* T(n+1) = T(n) ADD 0 */ + regLFSR = F_LOAD(regLFSR, pTmStmp->NowTn[chan]); + regLFSR = F_ADD(regLFSR, chan, 0); + pTmStmp->NowTn[chan] = F_READ(regLFSR); + } + } + return ret; /* */ +} + + + +/*********************************************************************** + * : CRC_Compute_Crc + * : 32λcrc㡣 + * : + * + * ----------------------------------------------------------- + * pData const UINT8* in Ҫ + * size UINT16 in ݴС + * chan UINT8 in źŵ + * + * ֵ : UINT32 õCRC + ***********************************************************************/ +UINT32 CRC_Compute_Crc(const UINT8* pData, UINT16 size, UINT8 chan) +{ + UINT16 index; + UINT32 Result = 0; + /*------------------------------------------------------------------------------ + * 32λCRCtable + *-----------------------------------------------------------------------------*/ + const UINT32 CrcmTab[2][256] = { + { + 0x00000000, 0x1942B361, 0x328566C2, 0x2BC7D5A3, 0x650ACD84, 0x7C487EE5, 0x578FAB46, 0x4ECD1827, + 0xCA159B08, 0xD3572869, 0xF890FDCA, 0xE1D24EAB, 0xAF1F568C, 0xB65DE5ED, 0x9D9A304E, 0x84D8832F, + 0x18CE5601, 0x018CE560, 0x2A4B30C3, 0x330983A2, 0x7DC49B85, 0x648628E4, 0x4F41FD47, 0x56034E26, + 0xD2DBCD09, 0xCB997E68, 0xE05EABCB, 0xF91C18AA, 0xB7D1008D, 0xAE93B3EC, 0x8554664F, 0x9C16D52E, + 0x319CAC02, 0x28DE1F63, 0x0319CAC0, 0x1A5B79A1, 0x54966186, 0x4DD4D2E7, 0x66130744, 0x7F51B425, + 0xFB89370A, 0xE2CB846B, 0xC90C51C8, 0xD04EE2A9, 0x9E83FA8E, 0x87C149EF, 0xAC069C4C, 0xB5442F2D, + 0x2952FA03, 0x30104962, 0x1BD79CC1, 0x02952FA0, 0x4C583787, 0x551A84E6, 0x7EDD5145, 0x679FE224, + 0xE347610B, 0xFA05D26A, 0xD1C207C9, 0xC880B4A8, 0x864DAC8F, 0x9F0F1FEE, 0xB4C8CA4D, 0xAD8A792C, + 0x63395804, 0x7A7BEB65, 0x51BC3EC6, 0x48FE8DA7, 0x06339580, 0x1F7126E1, 0x34B6F342, 0x2DF44023, + 0xA92CC30C, 0xB06E706D, 0x9BA9A5CE, 0x82EB16AF, 0xCC260E88, 0xD564BDE9, 0xFEA3684A, 0xE7E1DB2B, + 0x7BF70E05, 0x62B5BD64, 0x497268C7, 0x5030DBA6, 0x1EFDC381, 0x07BF70E0, 0x2C78A543, 0x353A1622, + 0xB1E2950D, 0xA8A0266C, 0x8367F3CF, 0x9A2540AE, 0xD4E85889, 0xCDAAEBE8, 0xE66D3E4B, 0xFF2F8D2A, + 0x52A5F406, 0x4BE74767, 0x602092C4, 0x796221A5, 0x37AF3982, 0x2EED8AE3, 0x052A5F40, 0x1C68EC21, + 0x98B06F0E, 0x81F2DC6F, 0xAA3509CC, 0xB377BAAD, 0xFDBAA28A, 0xE4F811EB, 0xCF3FC448, 0xD67D7729, + 0x4A6BA207, 0x53291166, 0x78EEC4C5, 0x61AC77A4, 0x2F616F83, 0x3623DCE2, 0x1DE40941, 0x04A6BA20, + 0x807E390F, 0x993C8A6E, 0xB2FB5FCD, 0xABB9ECAC, 0xE574F48B, 0xFC3647EA, 0xD7F19249, 0xCEB32128, + 0xC672B008, 0xDF300369, 0xF4F7D6CA, 0xEDB565AB, 0xA3787D8C, 0xBA3ACEED, 0x91FD1B4E, 0x88BFA82F, + 0x0C672B00, 0x15259861, 0x3EE24DC2, 0x27A0FEA3, 0x696DE684, 0x702F55E5, 0x5BE88046, 0x42AA3327, + 0xDEBCE609, 0xC7FE5568, 0xEC3980CB, 0xF57B33AA, 0xBBB62B8D, 0xA2F498EC, 0x89334D4F, 0x9071FE2E, + 0x14A97D01, 0x0DEBCE60, 0x262C1BC3, 0x3F6EA8A2, 0x71A3B085, 0x68E103E4, 0x4326D647, 0x5A646526, + 0xF7EE1C0A, 0xEEACAF6B, 0xC56B7AC8, 0xDC29C9A9, 0x92E4D18E, 0x8BA662EF, 0xA061B74C, 0xB923042D, + 0x3DFB8702, 0x24B93463, 0x0F7EE1C0, 0x163C52A1, 0x58F14A86, 0x41B3F9E7, 0x6A742C44, 0x73369F25, + 0xEF204A0B, 0xF662F96A, 0xDDA52CC9, 0xC4E79FA8, 0x8A2A878F, 0x936834EE, 0xB8AFE14D, 0xA1ED522C, + 0x2535D103, 0x3C776262, 0x17B0B7C1, 0x0EF204A0, 0x403F1C87, 0x597DAFE6, 0x72BA7A45, 0x6BF8C924, + 0xA54BE80C, 0xBC095B6D, 0x97CE8ECE, 0x8E8C3DAF, 0xC0412588, 0xD90396E9, 0xF2C4434A, 0xEB86F02B, + 0x6F5E7304, 0x761CC065, 0x5DDB15C6, 0x4499A6A7, 0x0A54BE80, 0x13160DE1, 0x38D1D842, 0x21936B23, + 0xBD85BE0D, 0xA4C70D6C, 0x8F00D8CF, 0x96426BAE, 0xD88F7389, 0xC1CDC0E8, 0xEA0A154B, 0xF348A62A, + 0x77902505, 0x6ED29664, 0x451543C7, 0x5C57F0A6, 0x129AE881, 0x0BD85BE0, 0x201F8E43, 0x395D3D22, + 0x94D7440E, 0x8D95F76F, 0xA65222CC, 0xBF1091AD, 0xF1DD898A, 0xE89F3AEB, 0xC358EF48, 0xDA1A5C29, + 0x5EC2DF06, 0x47806C67, 0x6C47B9C4, 0x75050AA5, 0x3BC81282, 0x228AA1E3, 0x094D7440, 0x100FC721, + 0x8C19120F, 0x955BA16E, 0xBE9C74CD, 0xA7DEC7AC, 0xE913DF8B, 0xF0516CEA, 0xDB96B949, 0xC2D40A28, + 0x460C8907, 0x5F4E3A66, 0x7489EFC5, 0x6DCB5CA4, 0x23064483, 0x3A44F7E2, 0x11832241, 0x08C19120}, + { + 0x00000000, 0x1EF09C7E, 0x3DE138FC, 0x2311A482, 0x7BC271F8, 0x6532ED86, 0x46234904, 0x58D3D57A, + 0xF784E3F0, 0xE9747F8E, 0xCA65DB0C, 0xD4954772, 0x8C469208, 0x92B60E76, 0xB1A7AAF4, 0xAF57368A, + 0xFF048983, 0xE1F415FD, 0xC2E5B17F, 0xDC152D01, 0x84C6F87B, 0x9A366405, 0xB927C087, 0xA7D75CF9, + 0x08806A73, 0x1670F60D, 0x3561528F, 0x2B91CEF1, 0x73421B8B, 0x6DB287F5, 0x4EA32377, 0x5053BF09, + 0xEE045D65, 0xF0F4C11B, 0xD3E56599, 0xCD15F9E7, 0x95C62C9D, 0x8B36B0E3, 0xA8271461, 0xB6D7881F, + 0x1980BE95, 0x077022EB, 0x24618669, 0x3A911A17, 0x6242CF6D, 0x7CB25313, 0x5FA3F791, 0x41536BEF, + 0x1100D4E6, 0x0FF04898, 0x2CE1EC1A, 0x32117064, 0x6AC2A51E, 0x74323960, 0x57239DE2, 0x49D3019C, + 0xE6843716, 0xF874AB68, 0xDB650FEA, 0xC5959394, 0x9D4646EE, 0x83B6DA90, 0xA0A77E12, 0xBE57E26C, + 0xCC05F4A9, 0xD2F568D7, 0xF1E4CC55, 0xEF14502B, 0xB7C78551, 0xA937192F, 0x8A26BDAD, 0x94D621D3, + 0x3B811759, 0x25718B27, 0x06602FA5, 0x1890B3DB, 0x404366A1, 0x5EB3FADF, 0x7DA25E5D, 0x6352C223, + 0x33017D2A, 0x2DF1E154, 0x0EE045D6, 0x1010D9A8, 0x48C30CD2, 0x563390AC, 0x7522342E, 0x6BD2A850, + 0xC4859EDA, 0xDA7502A4, 0xF964A626, 0xE7943A58, 0xBF47EF22, 0xA1B7735C, 0x82A6D7DE, 0x9C564BA0, + 0x2201A9CC, 0x3CF135B2, 0x1FE09130, 0x01100D4E, 0x59C3D834, 0x4733444A, 0x6422E0C8, 0x7AD27CB6, + 0xD5854A3C, 0xCB75D642, 0xE86472C0, 0xF694EEBE, 0xAE473BC4, 0xB0B7A7BA, 0x93A60338, 0x8D569F46, + 0xDD05204F, 0xC3F5BC31, 0xE0E418B3, 0xFE1484CD, 0xA6C751B7, 0xB837CDC9, 0x9B26694B, 0x85D6F535, + 0x2A81C3BF, 0x34715FC1, 0x1760FB43, 0x0990673D, 0x5143B247, 0x4FB32E39, 0x6CA28ABB, 0x725216C5, + 0x8806A731, 0x96F63B4F, 0xB5E79FCD, 0xAB1703B3, 0xF3C4D6C9, 0xED344AB7, 0xCE25EE35, 0xD0D5724B, + 0x7F8244C1, 0x6172D8BF, 0x42637C3D, 0x5C93E043, 0x04403539, 0x1AB0A947, 0x39A10DC5, 0x275191BB, + 0x77022EB2, 0x69F2B2CC, 0x4AE3164E, 0x54138A30, 0x0CC05F4A, 0x1230C334, 0x312167B6, 0x2FD1FBC8, + 0x8086CD42, 0x9E76513C, 0xBD67F5BE, 0xA39769C0, 0xFB44BCBA, 0xE5B420C4, 0xC6A58446, 0xD8551838, + 0x6602FA54, 0x78F2662A, 0x5BE3C2A8, 0x45135ED6, 0x1DC08BAC, 0x033017D2, 0x2021B350, 0x3ED12F2E, + 0x918619A4, 0x8F7685DA, 0xAC672158, 0xB297BD26, 0xEA44685C, 0xF4B4F422, 0xD7A550A0, 0xC955CCDE, + 0x990673D7, 0x87F6EFA9, 0xA4E74B2B, 0xBA17D755, 0xE2C4022F, 0xFC349E51, 0xDF253AD3, 0xC1D5A6AD, + 0x6E829027, 0x70720C59, 0x5363A8DB, 0x4D9334A5, 0x1540E1DF, 0x0BB07DA1, 0x28A1D923, 0x3651455D, + 0x44035398, 0x5AF3CFE6, 0x79E26B64, 0x6712F71A, 0x3FC12260, 0x2131BE1E, 0x02201A9C, 0x1CD086E2, + 0xB387B068, 0xAD772C16, 0x8E668894, 0x909614EA, 0xC845C190, 0xD6B55DEE, 0xF5A4F96C, 0xEB546512, + 0xBB07DA1B, 0xA5F74665, 0x86E6E2E7, 0x98167E99, 0xC0C5ABE3, 0xDE35379D, 0xFD24931F, 0xE3D40F61, + 0x4C8339EB, 0x5273A595, 0x71620117, 0x6F929D69, 0x37414813, 0x29B1D46D, 0x0AA070EF, 0x1450EC91, + 0xAA070EFD, 0xB4F79283, 0x97E63601, 0x8916AA7F, 0xD1C57F05, 0xCF35E37B, 0xEC2447F9, 0xF2D4DB87, + 0x5D83ED0D, 0x43737173, 0x6062D5F1, 0x7E92498F, 0x26419CF5, 0x38B1008B, 0x1BA0A409, 0x05503877, + 0x5503877E, 0x4BF31B00, 0x68E2BF82, 0x761223FC, 0x2EC1F686, 0x30316AF8, 0x1320CE7A, 0x0DD05204, + 0xA287648E, 0xBC77F8F0, 0x9F665C72, 0x8196C00C, 0xD9451576, 0xC7B58908, 0xE4A42D8A, 0xFA54B1F4} + }; + + /*------------------------------------------------------------------------------ + * ת + *-----------------------------------------------------------------------------*/ + const UINT8 Reflected_Byte[] = { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, + 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, + 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, + 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, + 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, + 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, + 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, + 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, + 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, + 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, + 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, + 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, + 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, + 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, + 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, + 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, + 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF + }; + + for(index=0; index < size; index++) + { + Result = (Result >> 8) ^ CrcmTab[chan][(Result ^ Reflected_Byte[*pData]) & 0xFF]; + pData++; + } + + return Result; +} + +/*********************************************************************** + * : ComputeMsgCRC16 + * : 16λǰȫcrc㡣 + * : + * + * ----------------------------------------------------------- + * pData const UINT8* in Ҫ + * size UINT16 in ݴС + * + * ֵ : UINT16 õCRC + ***********************************************************************/ +UINT16 ComputeMsgCRC16(const UINT8* pData, UINT16 size) +{ + UINT8 BitCount = 0; + UINT8 tmpByteData = 0; + UINT16 ActByte = 0, CompCRC = 0; + const UINT16 MSG_CRC_MASK = 0x8810; /* Polynomial for message CRC X25 */ + + while(size > 0) + { + tmpByteData = *pData; + ActByte = (UINT16)tmpByteData; + for(BitCount=8; BitCount>0; BitCount--) + { + if((ActByte ^ CompCRC) & 1) + { + CompCRC = (CompCRC >> 1) ^ MSG_CRC_MASK; + } + else + { + CompCRC >>= 1; + } + ActByte >>= 1; + } + pData++; + size--; + } + + return(CompCRC); +} + +/*********************************************************************** + * : IsRsspMsg + * : 鱨ӦͺϢǷΪRSSPģԼԱĵĽCRC֤ + * : + * + * -------------------------------------------------------------- + * MsgLen const UINT16 in ij + * pData const UINT8 in ģ16λCRC + * + * ֵ : UINT8 1RSSP 0:RSSP + ***********************************************************************/ +UINT8 IsRsspMsg(UINT16 MsgLen, const UINT8 pData[]) +{ + UINT8 ret = 1; + UINT16 calcCrc = 0,msgCrc = 0; + + /* ij ССRSSPijȣSSEijȣ */ + if(MsgLen < RSSP_SSE_LEN ) + { + ret =0; + } + else + { + /* RSSPϢʽ + * -------------------------------------------------------- + * Head | Body | 16λ CRC | + * --------------------------------------------------------- + * Ӧ|Ϣ|Դַ|Ŀַ | | | + * --------------------------------------------------------- + * 1ֽ| 1ֽ | 2ֽ| 2ֽ | n | 2 ֽ | + * --------------------------------------------------------- + */ + calcCrc = ComputeMsgCRC16(pData,(UINT16)(MsgLen-(UINT16)CRC_16_LEN)); + msgCrc = ShortFromCharLE(pData+MsgLen-CRC_16_LEN); + + /* CRC */ + if(calcCrc != msgCrc) + { + ret = 0; + } + else + { + /* Application Category = 01 */ + /* Message Type = 80 or 90 or 91 */ + if((RSSP_APP_CATEGORY != pData[RSSP_APP_CTGRY_POS]) + ||((RSSP_SSE_MSG != pData[RSSP_MSG_TYPE_POS]) + && (RSSP_SSR_MSG != pData[RSSP_MSG_TYPE_POS]) + && (RSSP_BSD_MSG != pData[RSSP_MSG_TYPE_POS]))) + { + ret = 0; + } + else + { + ret = 1; + } + } + } + return ret; +} + +/*---------------------------------------------------------------------- + * RSSP֡֡ END + *---------------------------------------------------------------------*/ + + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspCommon.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspCommon.h new file mode 100644 index 0000000..19d6b80 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspCommon.h @@ -0,0 +1,289 @@ +/************************************************************************ +* +* ļ RsspCommon.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.10.02 +* ؼЭ鲿 +* RSSPЭʹõFLSR麯. +* ʹע ʹ֮ǰinittabgTableFastֵ趨 +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +* 2009/11/01 ¥ΰ +* 2009/12/02 ¥ΰ MisraCӦ +* +************************************************************************/ + +#ifndef _RSSP_COMMON_H_ +#define _RSSP_COMMON_H_ + +#include "CommonTypes.h" + +#ifndef NULL +#define NULL 0 +#endif +/* ڲʹò */ +#define CHAN_NUM 2 /* channel */ +#define MAX_K 5 /* */ + +/* Ϣ */ +#define RSSP_SSE_MSG ((UINT8)0x90) /* SSE Ϣ */ +#define RSSP_SSR_MSG ((UINT8)0x91) /* SSR Ϣ */ +#define RSSP_BSD_MSG ((UINT8)0x80) /* BSD Ϣ */ + +/* ó */ +#define RSSP_HEAD_LEN 6 /* ֡ͷ */ +#define TC_LEN 4 /* ij */ +#define CRC_16_LEN 2 /* CRC 16λ ij */ + +/* Application Category */ +#define RSSP_APP_CATEGORY 0x01 /* Signaling Variables */ + +/* ֡ͷ */ +#define RSSP_APP_CTGRY_POS 0 /* ֡ͷӦλ*/ +#define RSSP_MSG_TYPE_POS (RSSP_APP_CTGRY_POS+1) /* ֡ͷϢ */ +#define RSSP_SRC_ADD_POS (RSSP_MSG_TYPE_POS+1) /* RSSPϢԴַ */ +#define RSSP_DEST_ADD_POS (RSSP_SRC_ADD_POS+2) /* RSSPϢĿַ */ + +#define RSSP_TC_POS RSSP_HEAD_LEN /* RSSPļλ */ + +/* SSE */ +#define RSSP_SSE_ENQ_LEN 4 /* SSE SEQENQ */ +#define RSSP_SSE_ENQ_1_POS (RSSP_TC_POS+TC_LEN) /* SSE SEQENQ_1λ */ +#define RSSP_SSE_ENQ_2_POS (RSSP_SSE_ENQ_1_POS+RSSP_SSE_ENQ_LEN) /* SSE SEQENQ_2λ */ + + +/* SSR */ +#define RSSP_SSR_INI_LEN 4 /* SSR SEQINI */ +#define RSSP_SSR_NUM_LEN 1 /* SSRNum DataVer */ +#define RSSP_SSR_TCENQ_POS (RSSP_TC_POS+TC_LEN) /* SSR λ */ +#define RSSP_SSR_INI_1_POS (RSSP_SSR_TCENQ_POS+TC_LEN) /* SSR SEQINI_1λ */ +#define RSSP_SSR_INI_2_POS (RSSP_SSR_INI_1_POS+RSSP_SSR_INI_LEN) /* SSR SEQINI_2λ */ +#define RSSP_SSR_NUM_POS (RSSP_SSR_INI_2_POS+RSSP_SSR_INI_LEN) /* SSRNum DataVer λ */ + +/* BSD */ +#define CRCM_LEN 4 /* crc ֶ֤εĴС */ +#define DATASIZE_LEN 2 /* ݳֶεĴС */ +#define RSSP_DATA_SIZE_POS (RSSP_TC_POS + TC_LEN) /* аȫݳȱλ */ +#define RSSP_CRCM_1_POS (RSSP_DATA_SIZE_POS + DATASIZE_LEN) /* CRCM_1λ */ +#define RSSP_CRCM_2_POS (RSSP_CRCM_1_POS + CRCM_LEN) /* CRCM_2λ */ +#define RSSP_DATA_POS (RSSP_CRCM_2_POS + CRCM_LEN) /* ȫݳȱλ */ + +/* RSSPϢ̶ */ +#define RSSP_SSE_LEN (RSSP_SSE_ENQ_2_POS+RSSP_SSE_ENQ_LEN+CRC_16_LEN) /* SSE */ +#define RSSP_SSR_LEN (RSSP_SSR_NUM_POS+RSSP_SSR_NUM_LEN+CRC_16_LEN) /* SSR */ +#define RSSP_FIXED_LEN (RSSP_DATA_POS+CRC_16_LEN) /* RSSPϢ̶ֳ */ + +/* */ +#define SEND_SSE_NUM 3 /* ȴSSRʱ෢SSE */ +#define NONE_SEND_APP_DATA 3 /* ޷Ӧ */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/*********************************************************************** + * ṹʱṹ + * Ӣ TimeStampStru + * ; RSSPڵշĵʱĻϢ + **********************************************************************/ +typedef struct +{ + UINT32 TC; /* ǰʱ */ + UINT32 LastLocalRecTC; /* ϴյıʱ */ + UINT32 NowTn[2]; /* ǰڶӦʱ */ + UINT32 LastTn[2]; /* ϸڶӦʱ */ + UINT32 LastRecvTCr; /* ϴνյͷʱ */ + UINT32 NowRecvTCr; /* ǰյͷʱ */ + UINT32 SseTC; /* SSEʱں */ + UINT32 SseTn[2]; /* SSEʱڶӦʱ */ + UINT32 RecvSseTCe; /* SSEĵĶԷʱ */ + UINT32 SeqEng[2]; /* յSSEʱSEQENQ */ + UINT8 NumSendSse; /* SSE */ + UINT32 SsrTc; /* ϴͬ */ + UINT32 NowSINIT_ADD_SID_XOR_Tn[2]; /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] */ + UINT32 LastSINIT_ADD_SID_XOR_Tn[2]; /* ϴյʱSINITr AND [SIDr ^ Tr(n)] */ +} TimeStampStru; + +/*---------------------------------------------------------------------- + * LFSR Start + *---------------------------------------------------------------------*/ +UINT32 F_ADD(UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 F_SUB(UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 F_POST(UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 F_XOR(UINT32 regLFSR, UINT32 val); +UINT32 F_LOAD(UINT32 regLFSR, UINT32 val); +UINT32 F_READ(UINT32 regLFSR); + +/*---------------------------------------------------------------------- + * End + *---------------------------------------------------------------------*/ + + +/*********************************************************************** + * : CheckTimeStamp + * : ԽձĽм,Ƿʱ + * : + * + * -------------------------------------------------------------- + * nowTCr UINT32 in ǰյıʱ + * lastTCr UINT32 in ϴյıʱ + * maxLost UINT32 in ֵ + * + * ֵ : UINT32 + * <0 : ʧ + * >=0 : ֵ + ***********************************************************************/ +INT32 CheckTimeStamp(UINT32 nowTCr, UINT32 lastTCr, UINT32 maxLost); + + +/*********************************************************************** + * : GetSidXorTn + * : ȡBSDSID XOR TN ֵ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const UINT8* in BSD + * outSidXorTn UINT32[2] out Sid ^ T(n) + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 GetSidXorTn(const UINT8* pBsdMsg,UINT32 outSidXorTn[CHAN_NUM]); + + +/*********************************************************************** + * : CheckCRCM + * : 鱨еCRCMSID^Tn()ȷԡ + * : + * + * -------------------------------------------------------------- + * sidXorTn const UINT32[2] in мSid^T(n) + * sinitAddSidXorTn const UINT32[2] in ϴεSINT Add (Sid ^ T(m)ֵ + * nDelayTCr UINT32 in + * POST_RXDAtA_K const UINT32[2][5] in ֵ߲,ֵ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 CheckCRCM(const UINT32 sidXorTn[CHAN_NUM], + const UINT32 sinitAddSidXorTn[CHAN_NUM], + UINT32 nDelayTCr, + const UINT32 postRxdataK[CHAN_NUM][MAX_K]); + +/*********************************************************************** + * : IsRsspMsg + * : 鱨ӦͺϢǷΪRSSPģԼԱĵĽCRC֤ + * : + * + * -------------------------------------------------------------- + * MsgLen const UINT16 in ij + * pData const UINT8 in ģ16λCRC + * + * ֵ : UINT8 1RSSP 0:RSSP + ***********************************************************************/ +UINT8 IsRsspMsg(UINT16 MsgLen, const UINT8 pData[]); + +/*********************************************************************** + * : CalcCRCM + * : CRCMֵ + * : + * + * -------------------------------------------------------------- + * pData const UINT8 * in Ӧ + * DataLen UINT16 in Ӧݳ + * SID const UINT32[2] in ͷSID + * Tn const UINT32[2] in ǰʱ + * outCRCM const UINT32[2] in CRCN + * + * pDataݳȱΪż + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 CalcCRCM(const UINT8 *pData, UINT16 DataLen, const UINT32 SID[CHAN_NUM], const UINT32 Tn[CHAN_NUM], UINT32 outCRCM[CHAN_NUM]); + +/*********************************************************************** + * : UpdtTmStmpStru + * : ϴεSinitAddSidXorTm㵱ǰıĵSinitAddSidXorTn + * : + * + * -------------------------------------------------------------- + * sidXorTn const UINT32[2] in мSid^T(n) + * nowTCr UINT32 in ǰյĵʱ + * nDelayTCr UINT32 in + * precSinitK const UINT32[2][5] in ֵ߲,ֵ + * pTmStmpStru TimeStampStru* inout ʱṹ,ϴյʱ估SINIT ADD (SID ^ Tn)ֵ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 UpdtTmStmpStru(const UINT32 sidXorTn[CHAN_NUM], + UINT32 nowRecvTCr, + UINT32 nDelayTCr, + const UINT32 precSinitK[CHAN_NUM][MAX_K], + TimeStampStru* pTmStmpStru); + +/*********************************************************************** + * : CalcFirstSinitAndSidXorTn + * : ʼ SinitAddSidXorTmֵյSSRʱá + * : + * + * -------------------------------------------------------------- + * precFirstSinit const UINT32[2] in ָźŵӦPREC_FIRSTSINIT + * senqINI const UINT32[2] in ָźŵӦSSRSEQINIֵ + * enqTCn const UINT32[2] in ָźŵSSEʱڶӦʱ + * outSntAndSidXorTn UINT32[2] out + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 CalcFirstSinitAndSidXorTn(const UINT32 precFirstSinit[CHAN_NUM], + const UINT32 senqINI[CHAN_NUM], + const UINT32 enqTCn[CHAN_NUM], + UINT32 outSntAndSidXorTn[CHAN_NUM]); + + +/*********************************************************************** + * : AddTimeStamp + * : 1,Ӧʱ¡ + * : + * + * -------------------------------------------------------------- + * pTmStmpStru TimeStampStru* inout ʱṹ һ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 AddTimeStamp(TimeStampStru *pTmStmp); + + +/*********************************************************************** + * : CRC_Compute_Crc + * : 32λcrc㡣 + * : + * + * ----------------------------------------------------------- + * pData const UINT8* in Ҫ + * size UINT16 in ݴС + * chan UINT8 in źŵ + * + * ֵ : UINT32 õCRC + ***********************************************************************/ +UINT32 CRC_Compute_Crc(const UINT8* pData, UINT16 size, UINT8 chan); + + +/*********************************************************************** + * : ComputeMsgCRC16 + * : 16λǰȫcrc㡣 + * : + * + * ----------------------------------------------------------- + * pData const UINT8* in Ҫ + * size UINT16 in ݴС + * + * ֵ : UINT16 õCRC + ***********************************************************************/ +UINT16 ComputeMsgCRC16(const UINT8* pData, UINT16 size); + +#ifdef __cplusplus +} +#endif + +#endif /* endif */ diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspIF.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspIF.h new file mode 100644 index 0000000..b99fa03 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspIF.h @@ -0,0 +1,138 @@ +/******************************************************** +* +* ļ RsspIF.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* Rsspӿڶ +* ʹע⣺ +* +* ޸ļ¼ +* +********************************************************/ + +#ifndef _RSSP_IF_H_ +#define _RSSP_IF_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "Rsr.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*-------------------------------------------------------------------- + * RSSPӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : RsspReceive + * : ԺݽRSRİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * SigToRs QueueStruct* IN źŲ㵽Rssp + * RsToSig QueueStruct* OUT Rssp㵽Ӧò + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspReceive(QueueStruct *SigToRs,QueueStruct *RsToApp, RSR_INFO_STRU *pRsrStru); + +/*********************************************************************** + * : RsspOutput + * : ӦݽRSRİȫ + * : + * + * -------------------------------------------------------------- + * SigToRs QueueStruct* IN źŲ㵽Rssp + * RsToSig QueueStruct* OUT Rssp㵽Ӧò + * varArray + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspOutput(QueueStruct *AppToRs,QueueStruct *RsToSig,UINT8 *varArray,RSR_INFO_STRU *pRsrStru); + +/*********************************************************************** + * : RsspInit + * : ͨúʵֶRSRijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ壬гʼֵá + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspInit(RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : RsspFreeSpace + * : ͨúͷRSR㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspFreeSpace(RSR_INFO_STRU *pRsrStruct); + + +/*********************************************************************** + * : RsspLnkStatus + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * RsSAdd UINT16 IN RSSPԴַ + * BsDAdd INT16 IN BSDַ + * SeDAdd UINT16 IN RSSPĿַSSESSRַ + * ֵ : UINT8 0ڸ·ش + * 0x17·ݴ״̬DATA + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 RsspLnkStatus(UINT16 SrcAddr,INT16 BsdAddr,UINT16 DestAddr,RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : RsspLnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * SrcAddr UINT16 IN RSSPԴַ + * BsdAddr UINT16 IN BSDַ + * DestAddr UINT16 IN RSSPĿַSSESSRַ + * devName UINT16* OUT 豸 + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspLnkDelete(UINT16 SrcAddr,INT16 BsdAddr,UINT16 DestAddr,UINT16* devName,RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : RsspRefresh + * : Ӧʹøú¶ԱRSRм¸ֵ + * : + * + * -------------------------------------------------------------- + * VarLen UINT16 IN мĴС + * VarArray UINT8* IN м + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspRefresh(UINT16 VarLen, const UINT8 *VarArray, RSR_INFO_STRU *pRsrStruct); + +/*-------------------------------------------------------------------- + * RSSPӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspInit.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspInit.c new file mode 100644 index 0000000..3a8c1eb --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspInit.c @@ -0,0 +1,156 @@ +/******************************************************** +* ļ RsspInit.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.12.07 +* ؼЭ鲿 +* RSSPʼԼڴͷš +* ʹע⣺RsspInit󣬱ӦĵRsspFreeSpace +* +* ޸ļ¼ +* ʱ ޸ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2011.12.06 ޸RsspInitInitLnkNodeArrIJ +********************************************************/ + +#include "stdlib.h" +#include "CommonMemory.h" +#include "RsspIF.h" +#include "RsspStruct.h" +#include "RsrCommon.h" +#include "RsspLnkNodeMgr.h" +#include "RsspTmpMsgLnkCommon.h" + +/* ȫֱ */ +/*UINT8 *TmpDataBuff;*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************** + * : RsspInit + * : ͨúʵֶRSRijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ壬гʼֵá + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspInit(RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0; + UINT16 DevName = 0; /* ʶ */ + UINT16 MaxMsgNum=0,MaxMsg = 0; + + /* ȡöӦʶ */ + TypeId2DevName(pRsrStruct->LocalType, pRsrStruct->LocalID, &DevName); + + /* RSSPмij */ + pRsrStruct->RsspVarArraySize = RSR_VAR_NODE_LEN * pRsrStruct->MaxNumLink+32; + /* RSSPʱ ռ ֱʹRsrVarArray */ + pRsrStruct->RsspVarArray = NULL; + + /* wangpeipei 20111205 MOD S */ + /* + * ȫͨŽڵʼ : ʼԭ豸ƸΪֻҪʼ· + */ + ret = InitLnkNodeArr(pRsrStruct->MaxNumLink,pRsrStruct); + /* wangpeipei 20111205 MOD E */ + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* */ + } + +#ifdef RSR_NORMAL + /* */ + MaxMsg = pRsrStruct->InputSize > pRsrStruct->OutputSize? + pRsrStruct->InputSize:pRsrStruct->OutputSize; + MaxMsg += 2 + 4 + RSSP_FIXED_LEN +32; /* źŲй̶(2+4) + RSSP̶ + 32 */ + + /* */ + MaxMsgNum = pRsrStruct->MaxNumLink*(pRsrStruct->MaxNumPerCycle +2); + + /* ʱĶջռʼ */ + ret = InitMsgNodeStack(MaxMsgNum,MaxMsg,pRsrStruct); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + + /* ʱĻ */ + pRsrStruct->TmpDataBuff = (UINT8 *)malloc(MaxMsg); + if( NULL == pRsrStruct->TmpDataBuff) + { + return 0; + } + else + { + /* ʲô */ + CommonMemSet(pRsrStruct->TmpDataBuff,sizeof(UINT8)*MaxMsg,0,sizeof(UINT8)*MaxMsg); + } + +#endif + + ret = 1; + return ret; +} + +/*********************************************************************** + * : RsrFreeSpace + * : ͨúͷRSR㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRsrStruct RSR_INFO_STRU* INOUT RSRͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspFreeSpace(RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 1; + + /* ȫͨŽڵռͷ */ + DestoryLnkNodeArr(pRsrStruct); + +#ifdef RSR_NORMAL + /* ʱռ ͷ */ + if(pRsrStruct->RsspVarArray != NULL) + { + free(pRsrStruct->RsspVarArray ); + pRsrStruct->RsspVarArray = NULL; + } + + /* ʱĶջռͷ:ʧ */ + ret = DestoryMsgNodeStack(pRsrStruct); + + /* ʱ */ + if(NULL != pRsrStruct->TmpDataBuff) + { + free(pRsrStruct->TmpDataBuff); + pRsrStruct->TmpDataBuff = NULL; + } + else + { + /* ʲô */ + } + +#endif + return ret; +} + +#ifdef __cplusplus +} +#endif diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspLnkNodeMgr.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspLnkNodeMgr.c new file mode 100644 index 0000000..700255c --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspLnkNodeMgr.c @@ -0,0 +1,1236 @@ +/******************************************************** +* ļ RsspLnkNodeMgr.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.12.07 +* ؼЭ鲿 +* ͨŽڵزʼѯǵȲ +* ʹע⣺ñļеĺȵóʼĺ +* +* ޸ļ¼ +* ʱ ޸ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2011.12.06 ޸InitLnkNodeArr·ʼͨŽڵ +* 2011.12.06 ޸SearchLnkBsdNodeBsdַRsspԴַѯӦͨŽڵ +* 2011.12.06 ޸SearchLnkSse_SsrNodeRsspԴַRsspĿĵַѯӦͨŽڵ +* 2011.12.06 ޸GetReplaceNodeʱĸƽ̨ +* 2011.12.06 ޸recvReplaceLnkNodeBsdַRsspԴַ(RsspĿĵַ費Ҫ޸ģ) +* 2011.12.06 ޸outputReplaceLnkNodeBsdַRsspԴַRsspĿĵַ +* 2011.12.06 ޸LnkNodeInfo2VarArrayмBsdַRsspԴַRsspĿĵַ +* 2011.12.06 ޸VarArray2LnkNodeInfoмӵBsdַRsspԴַRsspĿĵַдӦͨŽڵϢ +* 2011.12.06 ޸CheckRecvDsuLnkInfoʱĸƽ̨ +* 2011.12.06 ޸CheckOutputDsuLnkInfoʱĸƽ̨ +* 2011.12.07 ޸WriteToVarArrayɸǽڵϢмС +* 2011.12.13 ޸RsspLnkDeleteӲ +********************************************************/ +#include +#include "RsspIF.h" +#include "RsrCommon.h" +#include "RsspCommon.h" +#include "dsuRsrFunc.h" +#include "RsspLnkNodeMgr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* ȫֱ */ +/*static Lnk_Info_Node_Stru* LnkNodeArr;*/ /* ͨŽڵ */ +/*static UINT8 LnkNodeNum;*/ /* ͨŽڵ鳤 */ + +/*-------------------------------------------------------------------- + * ·ģڲ Start + *--------------------------------------------------------------------*/ +static UINT8 InitRsspLnkInfo(INT16 BsdAddr,const DSU_RSSP_LINK_RINFO_STRU* pRecvDsuLnkInf, const DSU_RSSP_LINK_SINFO_STRU* pOutputDsuLnkInf, RsspLinkInfoStru* pRsspLnkInfo); +static UINT8 SetNodeParam(const DSU_RSSP_LINK_RINFO_STRU* pRecvDsuLnkInf, const DSU_RSSP_LINK_SINFO_STRU* pOutputDsuLnkInf, NodeParamInfoStru *pNodeParam); +static void LnkNodeInfo2VarArray(const Lnk_Info_Node_Stru* pNode, UINT8* VarArray); +static void VarArray2LnkNodeInfo(const UINT8* VarArray, Lnk_Info_Node_Stru* pNode); +static UINT8 CheckRecvDsuLnkInfo(UINT16 LocalDevName,const DataNode *pNode,const DSU_RSSP_LINK_RINFO_STRU *pRecvLnkInfo); +static UINT8 CheckOutputDsuLnkInfo(UINT16 LocalDevName,const DataNode *pNode,const DSU_RSSP_LINK_SINFO_STRU *pOutputLnkInfo); +static UINT8 CheckInputAddr(UINT16 LocalDevName,UINT16 SrcAddr,const DSU_RSSP_LINK_RINFO_STRU *pRecvLnkInfo); +/*-------------------------------------------------------------------- + * ·ģڲ End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * RSSPṩĽӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : RsspLnkStatus + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * SrcAddr UINT16 IN RSSPԴַ + * BsdAddr INT16 IN BSDַ + * DestAddr UINT16 IN RSSPĿַSSESSRַ + * ֵ : UINT8 0ڸ·ش + * 0x17·ݴ״̬DATA + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 RsspLnkStatus(UINT16 SrcAddr,INT16 BsdAddr,UINT16 DestAddr,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0; + + Lnk_Info_Node_Stru* pNode = NULL; + pNode = SearchNodeByAddr(SrcAddr, DestAddr, BsdAddr,pRsrStruct); + if(pNode == NULL) + { + ret = 0; + } + else if( pNode->RsspLinInfo.RecvLinkStatus == RecvData) + { + /* */ + ret = 0x17; + } + else + { + /* ͨ״̬*/ + ret = 0x2b; + } + + return ret; +} +/* wangpeipei 20111213 Mod S */ +/*********************************************************************** + * : RsspLnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * RsSAdd UINT16 IN RSSPԴַ + * BsDAdd UINT16 IN BSDַ + * SeDAdd UINT16 IN RSSPĿַSSESSRַ + * devName UINT16* OUT 豸 + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspLnkDelete(UINT16 SrcAddr,INT16 BsdAddr,UINT16 DestAddr,UINT16* devName,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0; + + Lnk_Info_Node_Stru* pNode = NULL; + pNode = SearchNodeByAddr(SrcAddr, DestAddr, BsdAddr,pRsrStruct); + if(pNode == NULL) + { + ret = 0; + } + else + { + *devName = pNode->DestDevName; + /* ͨŽڵ״̬Ϊ ɸ״̬ */ + pNode->NodeStatus = Replace; + ret = 1; + } + + return ret; +} +/* wangpeipei 20111213 Mod E */ +/*********************************************************************** + * : RsspRefresh + * : Ӧʹøú¶ԱRSRм¸ֵ + * : + * + * -------------------------------------------------------------- + * VarLen UINT16 IN мĴС + * VarArray UINT8* IN м + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspRefresh(UINT16 VarLen, const UINT8 *VarArray, RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 1; + + UINT8 NodeLen = 0; + UINT8 NodeNum = 0; + UINT8 index =0; + DSU_RSSP_LINK_RINFO_STRU recvLnkInfo; /* ΪշʱĽڵϢ */ + DSU_RSSP_LINK_SINFO_STRU outputLnkInfo; /* ΪͷʱĽڵϢ */ + + NodeLen = RSR_VAR_NODE_LEN; + if( VarLen % NodeLen == 0) + { + /* ڵ :(ڵ8)ת */ + NodeNum =(UINT8) (VarLen / NodeLen); + } + else + { + return 0; + } + + /* ڵ 󷵻 */ + if( NodeNum <= pRsrStruct->LnkNodeNum) + { + for(index = 0; index < NodeNum; index++) + { + /* ͨŽڵϢ趨 */ + VarArray2LnkNodeInfo(VarArray,&pRsrStruct->LnkNodeArr[index]); + + if(0 != pRsrStruct->LnkNodeArr[index].DestDevName) + { + /* ΪͷϢȡ */ + ret = dsuRsspSGetLnkInfo(pRsrStruct->LnkNodeArr[index].RsspLinInfo.RsspSrcAddr, + pRsrStruct->LnkNodeArr[index].RsspLinInfo.DestBsdAdd, + &outputLnkInfo); + if(ret == 0) + { + /* 󣬴󷵻 */ + return ret; + } + else + { + /* ʲô */ + } + + /* ΪշϢȡ */ + ret = dsuRsspRGetLnkInfo(pRsrStruct->LnkNodeArr[index].RsspLinInfo.RsspDestAddr, + pRsrStruct->LnkNodeArr[index].RsspLinInfo.DestBsdAdd, + &recvLnkInfo); + if(ret == 0) + { + /* 󣬴󷵻 */ + return ret; + } + else + { + /* ʲô */ + } + /* 豸Ϣ趨 */ + ret = SetNodeParam(&recvLnkInfo,&outputLnkInfo, + &pRsrStruct->LnkNodeArr[index].RsspLinInfo.LocalNode); + } + else + { + /* ʲô */ + } + + VarArray += NodeLen; + } + } + else + { + /* ڵ 򷵻0 */ + return 0; + } + + ret = 1; + + return ret; +} + +/*-------------------------------------------------------------------- + * RSSPṩĽӿں End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * RSSPڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : GetLnkNodeArr + * : ȡȫֵͨŽڵָԼͨŽڵ + * : + * + * ----------------------------------------------------------------------------- + * pLnkInfoNodeArr Lnk_Info_Node_Stru** OUT ָָͨ + * OutLen UINT8* OUT + * + * ֵ : + ***********************************************************************/ + void GetLnkNodeArr(Lnk_Info_Node_Stru** pLnkInfoNodeArr,UINT8 *OutLen,RSR_INFO_STRU *pRsrStruct) +{ + *pLnkInfoNodeArr = pRsrStruct->LnkNodeArr; + *OutLen = pRsrStruct->LnkNodeNum; +} + +/* wangpeipei 20111206 ADD S */ +/*********************************************************************** + * : InitLnkNodeArr + * : ȫͨŽڵгʼ + * + * : + * + * -------------------------------------------------------------- + * Num UINT8 IN ӦָͨŶ + * + * ȫֱ : LnkNodeArr ͨŽڵ + * ֵ : UINT8 1: 0 + ***********************************************************************/ +UINT8 InitLnkNodeArr(UINT8 num,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 1; + UINT8 index = 0; + UINT16 lnkNodeArrSize = 0; + pRsrStruct->LnkNodeNum = num; + lnkNodeArrSize = sizeof(Lnk_Info_Node_Stru)*pRsrStruct->LnkNodeNum; + pRsrStruct->LnkNodeArr = (Lnk_Info_Node_Stru*) malloc(lnkNodeArrSize); + if(NULL == pRsrStruct->LnkNodeArr) + { + ret = 0; + } + else + { + RsrMemSet((UINT8*)pRsrStruct->LnkNodeArr,lnkNodeArrSize,0); /* */ + } + for(index = 0;index < pRsrStruct->LnkNodeNum;index++) + { + pRsrStruct->LnkNodeArr[index].NodeStatus = Replace; /* ͨŽڵΪɸǽڵ */ + } + /* wangpeipei 20111206 ADD S */ + return ret; +} + +/* wangpeipei 20111201 ADD*/ +/*********************************************************************** + * : SearchLnkBsdNode + * : BsdַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * RsspSrcAddr UINT16 IN RsspԴַ + * DestBsdAdd INT16 IN Bsdַ + * + * ȫֱ : LnkNodeArr ȫֱ + * ֵ : Lnk_Info_Node_Stru* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +Lnk_Info_Node_Stru* SearchLnkBsdNode(UINT16 RsspSrcAddr,INT16 DestBsdAdd,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 index = 0; + Lnk_Info_Node_Stru* retNodePtr = NULL; + + for(index = 0; index < pRsrStruct->LnkNodeNum; index++) + { + /* BSDַԴַѯ */ + if((pRsrStruct->LnkNodeArr[index].DestBsdAdd == DestBsdAdd) + && (pRsrStruct->LnkNodeArr[index].RsspDestAddr== RsspSrcAddr) && (pRsrStruct->LnkNodeArr[index].NodeStatus != Replace)) + { + retNodePtr = & pRsrStruct->LnkNodeArr[index]; + } + else + { + /* nothing */ + } + } + return retNodePtr; +} + +/*********************************************************************** + * : SearchLnkSse_SsrNode + * : PSSPĿĵַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * RsspSrcAddr UINT16 IN RsspԴַ + * RsspDestAddr UINT16 IN PsspĿĵַ + * + * ȫֱ : LnkNodeArr ȫֱ + * ֵ : Lnk_Info_Node_Stru* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +Lnk_Info_Node_Stru* SearchLnkSse_SsrNode(UINT16 RsspSrcAddr,UINT16 RsspDestAddr,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 index = 0; + Lnk_Info_Node_Stru* retNodePtr = NULL; + + for(index = 0; index < pRsrStruct->LnkNodeNum; index++) + { + + /* ָ̬Id Լ ʶȡöӦڵϢ */ + if((pRsrStruct->LnkNodeArr[index].RsspDestAddr == RsspDestAddr) + && (pRsrStruct->LnkNodeArr[index].RsspSrcAddr == RsspSrcAddr)) + { + retNodePtr = & pRsrStruct->LnkNodeArr[index]; + } + else + { + /* nothing */ + } + + } + return retNodePtr; +} +/* wangpeipei 20111201 ADD */ + +/*********************************************************************** + * : GetReplaceNode + * : ͨɸǵĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * srcAddr UINT16 IN Դַ + * desAddr INT16 IN Ŀַ + * + * ȫֱ : LnkNodeArr* ȫֱͨŽڵ + * ֵ : Lnk_Info_Node_Stru* NULL쳣 NULLͨŽڵ + ***********************************************************************/ +/* wangpeipei 20111202 Mod S */ +/*Lnk_Info_Node_Stru* GetReplaceNode(UINT16 srcAddr, INT16 desAddr)*/ +Lnk_Info_Node_Stru* GetReplaceNode(RSR_INFO_STRU *pRsrStruct) +/* wangpeipei 20111202 Add S */ +{ + UINT8 index = 0; + Lnk_Info_Node_Stru* retNodePtr = NULL; + /* wangpeipei 20111202 MOD S */ + for(index = 0; index < pRsrStruct->LnkNodeNum; index++) + { + /* ýڵɸ ظýڵָ */ + /*if((srcAddr == LnkNodeArr[index].RsspSrcAddr) && (desAddr == LnkNodeArr[index].RsspDestAddr) + && (LnkNodeArr[index].NodeStatus == Replace))*/ + if(pRsrStruct->LnkNodeArr[index].NodeStatus == Replace) + { + retNodePtr = &pRsrStruct->LnkNodeArr[index]; + break; + } + else + { + /* ʲô */ + } + } + /* wangpeipei 20111202 Mod E */ + return retNodePtr; +} + + +/*********************************************************************** + * : DestoryLnkNodeArr + * : ͷͨŽڵĿռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : ޡ + ***********************************************************************/ +void DestoryLnkNodeArr(RSR_INFO_STRU *pRsrStruct) +{ + /* ͨŽڵĿռ䲻Ϊգͷڴռ */ + if(NULL != pRsrStruct->LnkNodeArr) + { + free(pRsrStruct->LnkNodeArr); + pRsrStruct->LnkNodeArr = NULL; + pRsrStruct->LnkNodeNum = 0; + } + else + { + /* ʲô */ + } +} + +/*********************************************************************** + * : recvReplaceLnkNode + * : ݱϢͨŽڵϢʼ + * : + * + * ------------------------------------------------------------- + * LocalDevName UINT16 IN ʶ + * pDataNode const DataNode* IN Ľڵ + * pLnkNodeInfo ͨŽڵ INOUT ͨŽڵ + * + * ֵ : UINT8 1 0󷵻 + * ʹ ΪģյBSDʱӦͨŽڵ㲻ʱ + * + ***********************************************************************/ +UINT8 recvReplaceLnkNode(UINT16 LocalDevName,const DataNode* pDataNode,Lnk_Info_Node_Stru *pLnkNodeInfo, RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 0,checkRet = 0; + INT16 BsdAddr = 0; + UINT16 DestSrcAddr = 0; + DSU_RSSP_LINK_RINFO_STRU recvLnkInfo; /* ΪշʱĽڵϢ */ + DSU_RSSP_LINK_SINFO_STRU outputLnkInfo; /* ΪͷʱĽڵϢ */ + + /* BSDĿַ Ϊ BSDַ */ + BsdAddr = (INT16)ShortFromCharLE(&pDataNode->Data[RSSP_DEST_ADD_POS]); + /* BSDĵıԴַ ԷSSEַ */ + DestSrcAddr = ShortFromCharLE(&pDataNode->Data[RSSP_SRC_ADD_POS]); + + /* ݽձĵԴַԼĿַ(BSDַ)ȡñΪܽڵϢ */ + ret = dsuRsspRGetLnkInfo(DestSrcAddr, + BsdAddr, &recvLnkInfo); + /* ȡóɹ ϢʱĽڵϢһ */ + checkRet = CheckRecvDsuLnkInfo(LocalDevName,pDataNode,&recvLnkInfo); + if((0 == ret) || (0 == checkRet)) + { + ret = 0; + return ret; + } + /* ȡõSseַԼĿַ(BSDַ)ȡñΪͽڵϢ */ + ret = dsuRsspSGetLnkInfo(recvLnkInfo.SseAddr, BsdAddr, &outputLnkInfo); + /* ȡóɹ ϢʱĽڵϢһ */ + checkRet = CheckOutputDsuLnkInfo(LocalDevName,pDataNode,&outputLnkInfo); + if((0 == ret) || (0 == checkRet)) + { + ret = 0; + return ret; + } + + /* Էʶ趨 */ + pLnkNodeInfo->DestDevName = pDataNode->DevName; + + /* wangpeipei 20111202 ADD */ + /* BSDַԴַ趨*/ + pLnkNodeInfo->RsspSrcAddr = recvLnkInfo.SseAddr; + pLnkNodeInfo->DestBsdAdd = BsdAddr; + pLnkNodeInfo->RsspDestAddr = DestSrcAddr; + /* wangpeipei 20111202 ADDD*/ + + /* RSSP·Ϣṹʼ */ + InitRsspLnkInfo(BsdAddr, &recvLnkInfo, &outputLnkInfo, &pLnkNodeInfo->RsspLinInfo); + + /* ͨŽڵĽ״̬ΪSSE */ + pLnkNodeInfo->RsspLinInfo.RecvLinkStatus = SendSSE; + + /* ͨŽڵ״̬趨Ϊɸ */ + pLnkNodeInfo->NodeStatus = DisbaledReplace; + + ret = 1; + return ret; + +} +/*********************************************************************** + * : outputReplaceLnkNode + * : ԴַĿַBSDַȡöӦڵϢ + * ͨŽڵϢʼ + * : + * + * ------------------------------------------------------------- + * SrcAddr UINT16 IN Դַ + * BsdAddr INT16 IN BSDַ + * DestAddr UINT16 IN SSEַ + * LocalDevName UINT16 IN ʶ + * pPLnkNodeInfo Lnk_Info_Node_Stru** OUT ͨŽڵ + * + * ֵ : UINT8 1 0󷵻 + * ʹ Ϊģ飬ַָͨŽڵ㲻ʱ + * + ***********************************************************************/ +UINT8 outputReplaceLnkNode(UINT16 SrcAddr,INT16 BsdAddr,UINT16 DestAddr, + UINT16 LocalDevName,Lnk_Info_Node_Stru **pPLnkNodeInfo, RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0,chcRet = 0; + UINT8 DestType = 0,DestId = 0; /* ԷType,ԷId*/ + DSU_RSSP_LINK_RINFO_STRU recvLnkInfo; /* ΪշʱĽڵϢ */ + DSU_RSSP_LINK_SINFO_STRU outputLnkInfo; /* ΪͷʱĽڵϢ */ + Lnk_Info_Node_Stru *pLnkNodeInfo = NULL; + + /* ݲĿַԼBSDַȡñΪܽڵϢ */ + ret = dsuRsspRGetLnkInfo(DestAddr, BsdAddr, &recvLnkInfo); + /* + * ȡóɹ Ϣ뱾Ϣһ + */ + chcRet = CheckInputAddr(LocalDevName,SrcAddr,&recvLnkInfo); + if((1 == ret) && ( 1 == chcRet)) + { + /* ȡõSseַԼĿַ(BSDַ)ȡñΪͽڵϢ */ + ret = dsuRsspSGetLnkInfo(recvLnkInfo.SseAddr, BsdAddr, &outputLnkInfo); + if(0 == ret) + { + /* ȡʧܣ󷵻 */ + return ret; + } + + /* Էʶ趨: + * ͨŶԷΪCCԷͷϢжԷʶ϶ȡõ + * ԷΪZCCI ̬Id Ϊ豸ID ѯɸǽڵ㡣 + */ + DevName2TypeId(outputLnkInfo.DestName,&DestType, &DestId); + pLnkNodeInfo = GetReplaceNode(pRsrStruct); + if(NULL == pLnkNodeInfo) + { + /* ɸǽڵȡʧ 󷵻 */ + ret = 0; + return ret; + } + else + { + /* ȡõĸǽڵָ 淵pPLnKNodeInfo */ + *pPLnkNodeInfo = pLnkNodeInfo; + } + /* Էʶ趨 */ + pLnkNodeInfo->DestDevName = outputLnkInfo.DestName; + + /* RSSP·Ϣṹʼ */ + InitRsspLnkInfo(BsdAddr, &recvLnkInfo, &outputLnkInfo, &pLnkNodeInfo->RsspLinInfo); + + /* wangpeipei 20111205 Del S */ + /* ɾ̬ID */ + /* wangpeipei 20111205 Del E */ + + /* wangpeipei 20111205 ADD S */ + /* Bsdַ*/ + pLnkNodeInfo->DestBsdAdd = BsdAddr; + + /* RsspԴַ */ + pLnkNodeInfo->RsspSrcAddr = pLnkNodeInfo->RsspLinInfo.RsspSrcAddr; + + /* RsspĿĵַ */ + pLnkNodeInfo->RsspDestAddr = pLnkNodeInfo->RsspLinInfo.RsspDestAddr; + /* wangpeipei 20111205 ADD E */ + + /* ͨŽڵ״̬趨Ϊɸ */ + pLnkNodeInfo->NodeStatus = DisbaledReplace; + } + else + { + /* Ϣȡʧ ͨŹϵʽ CICC ַϵ */ + ret = 0; + return ret; + } + + ret = 1; + return ret; +} + +/*********************************************************************** + * : SearchNodeByAddr + * : ָRSSPԴַRSSPĿַ(SSE SSR)BSDַѯӦͨŽڵǷڡ + * 򷵻ضӦͨŽڵָ룬򷵻NULL + * : + * + * -------------------------------------------------------------------------- + * SrcAddr UINT16 IN RSSPԴַ + * DestAddr UINT16 IN RSSPĿַSSE SSR + * BsdAddr INT16 IN BSDַ + * + * ֵ : Lnk_Info_Node_Stru* ͨŽڵָ룬 NULL: + ***********************************************************************/ +Lnk_Info_Node_Stru* SearchNodeByAddr(UINT16 SrcAddr, UINT16 DestAddr, INT16 BsdAddr,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 index = 0; + Lnk_Info_Node_Stru* retLnkNodePtr = NULL; /* ָ */ + + for( index = 0; index < pRsrStruct->LnkNodeNum; index++) + { + /* + * ָĵַӦͨŽڵ + */ + if( (pRsrStruct->LnkNodeArr[index].RsspLinInfo.RsspSrcAddr == SrcAddr) + && (pRsrStruct->LnkNodeArr[index].RsspLinInfo.RsspDestAddr == DestAddr) + && (pRsrStruct->LnkNodeArr[index].RsspLinInfo.DestBsdAdd == BsdAddr)) + { + retLnkNodePtr = & pRsrStruct->LnkNodeArr[index]; + } + else + { + /* жһ */ + } + } + + return retLnkNodePtr; +} + +/*-------------------------------------------------------------------- + * RSSPڲӿں End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * ·ģڲ Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : InitRsspLnkInfo + * : ݷϢԼϢ·Ϣгʼ + * : + * + * -------------------------------------------------------------------------- + * BsdAddr INT16 IN BSDַ + * pRecvDsuLnkInf const DSU_RSSP_LINK_RINFO_STRU* IN Ϣ + * pOutputDsuLnkInf const DSU_RSSP_LINK_SINFO_STRU* IN Ϣ + * pRsspLnkInfo RsspLinkInfoStru* INOUT ·Ϣṹ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 InitRsspLnkInfo(INT16 BsdAddr, + const DSU_RSSP_LINK_RINFO_STRU* pRecvDsuLnkInf, + const DSU_RSSP_LINK_SINFO_STRU* pOutputDsuLnkInf, + RsspLinkInfoStru* pRsspLnkInfo) +{ + UINT8 TmpType = 0, TmpId = 0; + + /* */ + RsrMemSet((UINT8 *)pRsspLnkInfo,sizeof(RsspLinkInfoStru),0); + + /* ԷĶ̬ID ͱ̬ID 趨 */ + if(ROLE_ZC_CI == pOutputDsuLnkInf->ROLE) + { + /* ̶ ̶ͨʱȡõıʶ豸Id ΪӦĶ̬Id */ + DevName2TypeId(pOutputDsuLnkInf->DestName, &TmpType,&TmpId); + pRsspLnkInfo->DestLogId = TmpId; /* Է̬Id Է豸Id*/ + + DevName2TypeId(pRecvDsuLnkInf->DestName, &TmpType,&TmpId); + pRsspLnkInfo->LocalLogId = TmpId; /* ܻϢĶԷʶΪʶ豸IdΪ̬Id */ + + } + else if(ROLE_VOBC2CI == pOutputDsuLnkInf->ROLE ) + { /* + * ΪCC ԷΪCI,ƶ̶ͨŹϵУԷĶ̬ID޷ȡá + * ͽڵĻϢеı̬Id ΪĶ̬Id + * ͽڵϢеĶԷ豸ʶȡöԷ豸IDΪԷ̬Id + */ + pRsspLnkInfo->LocalLogId = pOutputDsuLnkInf->LocalLogId; + + /* ԷĶ̬Id Ϊ Է豸ID */ + DevName2TypeId(pOutputDsuLnkInf->DestName, &TmpType,&TmpId); + pRsspLnkInfo->DestLogId = TmpId; + } + else + { + /* + * ΪCI ԷΪCC,̶ƶͨŹϵУĶ̬ID޷ȡá + * ܽڵϢеĶԷ豸ʶȡñ豸IDΪ̬Id + * ͽڵĻϢеĶԷ̬Id ΪԷĶ̬Id + */ + DevName2TypeId(pRecvDsuLnkInf->DestName, &TmpType,&TmpId); + pRsspLnkInfo->LocalLogId = TmpId; /* 豸Ķ̬Id*/ + + pRsspLnkInfo->DestLogId = pOutputDsuLnkInf->DestLogId ; /* Է̬Id */ + } + + + pRsspLnkInfo->RsspSrcAddr = pRecvDsuLnkInf->SseAddr; /* RSSPԴַ = շϢSSeַ */ + pRsspLnkInfo->RsspDestAddr = pOutputDsuLnkInf->SseAddr; /* RSSPĿַ(SSEַ) = ͷϢSSEַ */ + + /* BSDַ趨 */ + pRsspLnkInfo->DestBsdAdd = BsdAddr; + + /* 趨ͨŽڵĻϢ */ + SetNodeParam(pRecvDsuLnkInf, pOutputDsuLnkInf, &pRsspLnkInfo->LocalNode); + + pRsspLnkInfo->RecvLinkStatus = Halt; /* ·״̬趨Ϊж״̬ */ + pRsspLnkInfo->SendLinkStatus = Halt; /* ·״̬趨Ϊж״̬ */ + pRsspLnkInfo->NoRecvDataCycleNum = 0; /* ʼΪ0 */ + pRsspLnkInfo->NoAppDataCycleNum = 0; /* ޷ӦʼΪ0 */ + + pRsspLnkInfo->TimeStmp.TC = 0; /* ǰʱΪ0 */ + + /* ǰڶӦʱͨŵķͷSIDʼ */ + pRsspLnkInfo->TimeStmp.NowTn[0] = pRsspLnkInfo->LocalNode.SIDr[0]; + pRsspLnkInfo->TimeStmp.NowTn[1] = pRsspLnkInfo->LocalNode.SIDr[1]; + + return (UINT8)1; /* ̶1 */ +} + + +/*********************************************************************** + * : WriteToVarArray + * : ͨŽڵдм + * : + * + * -------------------------------------------------------------- + * VarArray UINT8* OUT SSR + * ȫֱ UINT8 LnkNodeArr[] + * ֵ : 1 + ***********************************************************************/ +UINT8 WriteToVarArray(UINT8 *VarArray,RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret =0,index=0; + UINT8 *pTmp = NULL; + UINT8 NodeLen = 0; + UINT8 count = 0; + + NodeLen = (UINT8)RSR_VAR_NODE_LEN; + pTmp = VarArray + 2; + for(index =0;index < pRsrStruct->LnkNodeNum; index++) + { + /* wangpeipei 20111207 ADD S */ + /* ֻɸǽڵ */ + if(pRsrStruct->LnkNodeArr[index].NodeStatus == DisbaledReplace) + { + /* wangpeipei 20111207 ADD E */ + /* ǰڵϢдм */ + LnkNodeInfo2VarArray(&pRsrStruct->LnkNodeArr[index],pTmp); + /* һڵ */ + pTmp += NodeLen; + count++; + } + } + + /* д볤 LnkNodeNum * NodeLen 2ֽ */ + ShortToChar((UINT16)(count*NodeLen),VarArray); + + ret = 1; + return ret; +} + + +/*********************************************************************** + * : LnkNodeInfo2VarArray + * : ͨŽڵϢд뵽м档 + * : + * + * ----------------------------------------------------------------------------- + * pLnkInfoNodeArr const Lnk_Info_Node_Stru* IN ָָͨ + * VarArray UINT8* OUT м + * + * ֵ : + ***********************************************************************/ + static void LnkNodeInfo2VarArray(const Lnk_Info_Node_Stru* pNode, UINT8* VarArray) + { + UINT16 index = 0; + const RsspLinkInfoStru *pRsspLnkInfo = &pNode->RsspLinInfo; + const TimeStampStru *pTmStmp = &pNode->RsspLinInfo.TimeStmp; + + /* -------- Lnk_Info_Node_Stru ------ */ + /* Էʶ 2ֽ */ + ShortToChar(pNode->DestDevName, &VarArray[index]); + index +=2; + + /* wangpeipei 20111205 ADD */ + /* Bsdַ 2ֽ */ + ShortToChar((UINT16)pNode->DestBsdAdd, &VarArray[index]); + index += 2; + + /* RsspԴַ 2ֽ */ + ShortToChar(pNode->RsspSrcAddr, &VarArray[index]); + index +=2; + + /* RsspĿĵַ 2ֽ */ + ShortToChar(pNode->RsspDestAddr, &VarArray[index]); + index += 2; + /* wangpeipei 20111205 ADD*/ + + /* ڵɸ״̬ 1ֽ */ + VarArray[index++] = pNode->NodeStatus; + + /* -------- RsspLinkInfoStru ---------- */ + /* ̬ID 1ֽ */ + VarArray[index++] = pRsspLnkInfo->LocalLogId; + /* Է̬ID 1ֽ */ + VarArray[index++] = pRsspLnkInfo->DestLogId; + /* ·״̬ 1ֽ */ + VarArray[index++] = pRsspLnkInfo->RecvLinkStatus; + /* ·״̬ 1ֽ */ + VarArray[index++] = pRsspLnkInfo->SendLinkStatus; + /* 1ֽ */ + VarArray[index++] = pRsspLnkInfo->NoRecvDataCycleNum; + /* ޷Ӧ 1ֽ */ + VarArray[index++] = pRsspLnkInfo->NoAppDataCycleNum; + /* BSDַ 2ֽ */ + ShortToChar((UINT16)pRsspLnkInfo->DestBsdAdd,&VarArray[index]); + index += 2; + /* RSSPԴַ 2ֽ */ + ShortToChar(pRsspLnkInfo->RsspSrcAddr,&VarArray[index]); + index += 2; + /* RSSPĿĵַ 2ֽ */ + ShortToChar(pRsspLnkInfo->RsspDestAddr , &VarArray[index]); + index += 2; + + /* -------------- ʱϢ ----------- */ + /* ǰʱ 4ֽ*/ + LongToChar(pTmStmp->TC, &VarArray[index]); + index += 4; + + /* ϴյıʱ 4ֽ */ + LongToChar(pTmStmp->LastLocalRecTC, &VarArray[index]); + index += 4; + + /* ǰڶӦʱ[0] 4ֽ */ + LongToChar(pTmStmp->NowTn[0], &VarArray[index]); + index += 4; + + /* ǰڶӦʱ[1] 4ֽ */ + LongToChar(pTmStmp->NowTn[1], &VarArray[index]); + index += 4; + + /* ϸڶӦʱ[0] 4ֽ */ + LongToChar(pTmStmp->LastTn[0], &VarArray[index]); + index += 4; + + /* ϸڶӦʱ[1] 4ֽ */ + LongToChar(pTmStmp->LastTn[1], &VarArray[index]); + index += 4; + + /* ϴνյͷʱ 4ֽ */ + LongToChar(pTmStmp->LastRecvTCr, &VarArray[index]); + index += 4; + + /* ǰյͷʱ 4ֽ */ + LongToChar(pTmStmp->NowRecvTCr, &VarArray[index]); + index += 4; + + /* SSEʱں 4ֽ */ + LongToChar(pTmStmp->SseTC, &VarArray[index]); + index += 4; + + /* SSEʱڶӦʱ[0] 4ֽ */ + LongToChar(pTmStmp->SseTn[0], &VarArray[index]); + index += 4; + + /* SSEʱڶӦʱ[1] 4ֽ */ + LongToChar(pTmStmp->SseTn[1], &VarArray[index]); + index += 4; + + /* SSEĵĶԷʱ 4ֽ */ + LongToChar(pTmStmp->RecvSseTCe, &VarArray[index]); + index += 4; + + /* յSSEʱSEQENQ[0] 4ֽ */ + LongToChar(pTmStmp->SeqEng[0], &VarArray[index]); + index += 4; + + /* յSSEʱSEQENQ[1] 4ֽ */ + LongToChar(pTmStmp->SeqEng[1], &VarArray[index]); + index += 4; + + /* SSE 1ֽ */ + VarArray[index++] = pTmStmp->NumSendSse; + + /* ϴͬ 4ֽ */ + LongToChar(pTmStmp->SsrTc, &VarArray[index]); + index += 4; + + /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] [0] 4ֽ */ + LongToChar(pTmStmp->NowSINIT_ADD_SID_XOR_Tn[0], &VarArray[index]); + index += 4; + + /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] [1] 4ֽ */ + LongToChar(pTmStmp->NowSINIT_ADD_SID_XOR_Tn[1], &VarArray[index]); + index += 4; + + /* ϴյʱSINITr AND [SIDr ^ Tr(n)] [0] 4ֽ */ + LongToChar(pTmStmp->LastSINIT_ADD_SID_XOR_Tn[0], &VarArray[index]); + index += 4; + + /* ϴյʱSINITr AND [SIDr ^ Tr(n)] [1] 4ֽ */ + LongToChar(pTmStmp->LastSINIT_ADD_SID_XOR_Tn[1], &VarArray[index]); + index += 4; + } + + /*********************************************************************** + * : VarArray2LnkNodeInfo + * : мһĽڵϢдָͨŽڵϢ + * : + * + * ----------------------------------------------------------------------------- + * VarArray const UINT8* IN м + * pLnkInfoNodeArr Lnk_Info_Node_Stru* OUT ָָͨ + * + * ʹƣӦָĿռɵ÷֤ + * ֵ : + ***********************************************************************/ + static void VarArray2LnkNodeInfo(const UINT8* VarArray, Lnk_Info_Node_Stru* pNode) + { + UINT16 index = 0; + RsspLinkInfoStru *pRsspLnkInfo = &pNode->RsspLinInfo; + TimeStampStru *pTmStmp = &pNode->RsspLinInfo.TimeStmp; + + /* -------- Lnk_Info_Node_Stru ------ */ + /* Էʶ 2ֽ */ + pNode->DestDevName = ShortFromChar(&VarArray[index]); + index +=2; + + /* wangpeipei 20111205 ADD */ + /* BSDַ 2ֽ */ + pNode->DestBsdAdd = (INT16)ShortFromChar(&VarArray[index]); + index += 2; + /* RSSPԴַ 2ֽ */ + pNode->RsspSrcAddr = ShortFromChar(&VarArray[index]); + index += 2; + /* RSSPĿĵַ 2ֽ */ + pNode->RsspDestAddr = ShortFromChar(&VarArray[index]); + index += 2; + /* wangpeipei 20111205 ADD*/ + + /* ڵɸ״̬ 1ֽ */ + pNode->NodeStatus = VarArray[index++]; + + /* -------- RsspLinkInfoStru ---------- */ + /* ̬ID 1ֽ */ + pRsspLnkInfo->LocalLogId = VarArray[index++]; + /* Է̬ID 1ֽ */ + pRsspLnkInfo->DestLogId = VarArray[index++]; + /* ·״̬ 1ֽ */ + pRsspLnkInfo->RecvLinkStatus = VarArray[index++]; + /* ·״̬ 1ֽ */ + pRsspLnkInfo->SendLinkStatus = VarArray[index++]; + /* 1ֽ */ + pRsspLnkInfo->NoRecvDataCycleNum = VarArray[index++]; + /* ޷Ӧ 1ֽ */ + pRsspLnkInfo->NoAppDataCycleNum = VarArray[index++]; + /* BSDַ 2ֽ */ + pRsspLnkInfo->DestBsdAdd = (INT16)ShortFromChar(&VarArray[index]); + index += 2; + /* RSSPԴַ 2ֽ */ + pRsspLnkInfo->RsspSrcAddr = ShortFromChar(&VarArray[index]); + index += 2; + /* RSSPĿĵַ 2ֽ */ + pRsspLnkInfo->RsspDestAddr = ShortFromChar(&VarArray[index]); + index += 2; + + /* -------------- ʱϢ ----------- */ + /* ǰʱ 4ֽ*/ + pTmStmp->TC = LongFromChar(&VarArray[index]); + index += 4; + + /* ϴյıʱ 4ֽ */ + pTmStmp->LastLocalRecTC = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰڶӦʱ[0] 4ֽ */ + pTmStmp->NowTn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰڶӦʱ[1] 4ֽ */ + pTmStmp->NowTn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϸڶӦʱ[0] 4ֽ */ + pTmStmp->LastTn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϸڶӦʱ[1] 4ֽ */ + pTmStmp->LastTn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϴνյͷʱ 4ֽ */ + pTmStmp->LastRecvTCr = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰյͷʱ 4ֽ */ + pTmStmp->NowRecvTCr = LongFromChar(&VarArray[index]); + index += 4; + + /* SSEʱں 4ֽ */ + pTmStmp->SseTC = LongFromChar(&VarArray[index]); + index += 4; + + /* SSEʱڶӦʱ[0] 4ֽ */ + pTmStmp->SseTn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* SSEʱڶӦʱ[1] 4ֽ */ + pTmStmp->SseTn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* SSEĵĶԷʱ 4ֽ */ + pTmStmp->RecvSseTCe = LongFromChar(&VarArray[index]); + index += 4; + + /* յSSEʱSEQENQ[0] 4ֽ */ + pTmStmp->SeqEng[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* յSSEʱSEQENQ[1] 4ֽ */ + pTmStmp->SeqEng[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* SSE 1ֽ */ + pTmStmp->NumSendSse = VarArray[index++]; + + /* ϴͬ 4ֽ */ + pTmStmp->SsrTc = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] [0] 4ֽ */ + pTmStmp->NowSINIT_ADD_SID_XOR_Tn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] [1] 4ֽ */ + pTmStmp->NowSINIT_ADD_SID_XOR_Tn[1] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϴյʱSINITr AND [SIDr ^ Tr(n)] [0] 4ֽ */ + pTmStmp->LastSINIT_ADD_SID_XOR_Tn[0] = LongFromChar(&VarArray[index]); + index += 4; + + /* ϴյʱSINITr AND [SIDr ^ Tr(n)] [1] 4ֽ */ + pTmStmp->LastSINIT_ADD_SID_XOR_Tn[1] = LongFromChar(&VarArray[index]); + index += 4; + } + +/*********************************************************************** + * : CheckRecvDsuLnkInfo + * : DSUȡýշϢϢǷһ¡ + * : + * + * -------------------------------------------------------------------------- + * LocalDevName UINT16 IN ʶ + * pDataNode const DataNode* IN Ľڵ + * pRecvLnkInfo const DSU_RSSP_LINK_RINFO_STRU IN Ϣ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 CheckRecvDsuLnkInfo(UINT16 LocalDevName, + const DataNode *pNode, + const DSU_RSSP_LINK_RINFO_STRU *pRecvLnkInfo) +{ + UINT8 ret = 0; + UINT8 LocalType =0,LocalId = 0; /* ̬ͣId */ + + DevName2TypeId(LocalDevName,&LocalType,&LocalId); + + /* wangpeipei 20111205 ADD S */ + if((pRecvLnkInfo->ROLE == ROLE_ZC_CI) + && (pRecvLnkInfo->DestName == LocalDevName) && (pNode->LocalLogId == LocalId)) + { + ret = 1; + } + else if((pRecvLnkInfo->ROLE == ROLE_CI2VOBC) + && (pRecvLnkInfo->DestLogId == pNode->LocalLogId )) + { + ret = 1; + } + else if((pRecvLnkInfo->ROLE == ROLE_VOBC2CI) + && (pRecvLnkInfo->LocalLogId == pNode->DestLogId) + && (pRecvLnkInfo->DestName == LocalDevName) && (pNode->LocalLogId == LocalId)) + { + ret = 1; + } + else + { + /* ش */ + ret = 0; + } + /* wangpeipei 20111205 ADD E */ + return ret; +} +/*********************************************************************** + * : CheckOutputDsuLnkInfo + * : DSUȡ÷ͷϢϢǷһ¡ + * : + * + * -------------------------------------------------------------------------- + * LocalDevName UINT16 IN ʶ + * pDataNode const DataNode* IN Ľڵ + * pRecvLnkInfo const DSU_RSSP_LINK_SINFO_STRU IN Ϣ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 CheckOutputDsuLnkInfo(UINT16 LocalDevName, + const DataNode *pNode, + const DSU_RSSP_LINK_SINFO_STRU *pOutputLnkInfo) +{ + UINT8 ret = 0; + UINT8 LocalType =0,LocalId = 0; /* ̬ͣId */ + UINT8 DestType =0,DestId = 0; /* ԷͣԷ̬Id */ + + DevName2TypeId(LocalDevName,&LocalType,&LocalId); + DevName2TypeId(pOutputLnkInfo->DestName,&DestType,&DestId); + + /* wangpeipei 20111205 ADD S */ + if((pOutputLnkInfo->ROLE == ROLE_ZC_CI) + && (pOutputLnkInfo->DestName == pNode->DevName) + && (pNode->LocalLogId == LocalId) && (pNode->DestLogId == DestId)) + { + ret = 1; + } + else if ((pOutputLnkInfo->ROLE == ROLE_VOBC2CI)&& (pNode->DestLogId == DestId)) + { + ret = 1; + } + else if ((pOutputLnkInfo->ROLE == ROLE_CI2VOBC)&&(pNode->LocalLogId == LocalId)) + { + ret = 1; + } + else + { + /* ش */ + ret = 0; + } + /* wangpeipei 20111205 ADD E */ + return ret; +} + +/*********************************************************************** + * : CheckInputAddr + * : BSDַԼSSEַ ȡõıΪϢǷȷ + * : + * + * ------------------------------------------------------------------------ + * LocalDevName UINT16 IN ʶ + * SrcAddr UINT16 IN Դַ + * pRecvLnkInfo constDSU_RSSP_LINK_RINFO_STRU* IN Ϣ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 CheckInputAddr(UINT16 LocalDevName,UINT16 SrcAddr, + const DSU_RSSP_LINK_RINFO_STRU *pRecvLnkInfo) +{ + UINT8 ret = 0; + UINT8 Type = 0, Id =0; + + DevName2TypeId(LocalDevName,&Type,&Id); /* ȡ豸 豸Id */ + + /* շSSEַǷڱԴַ˵Ӧøĵַ */ + if(SrcAddr != pRecvLnkInfo->SseAddr) + { + return ret; + } + + /* ϢͨŹϵΪ0xFF˵ΪCIԷCC + * ʵCIյCCϢܸԷϢʱݲϷ + */ + if(pRecvLnkInfo->ROLE == ROLE_VOBC2CI) + { + return ret; + } + + /* + * CCҽϢ.Էʶͱıʶ Ӧøַ + */ + if((RSR_TYPE_CC != Type) && (LocalDevName != pRecvLnkInfo->DestName)) + { + return ret; + } + + ret = 1; /* */ + return ret; +} + +/*********************************************************************** + * : SetNodeParam + * : ÿȡͨŽڵϢõָ豸ڵϢṹ档 + * : + * + * -------------------------------------------------------------------------- + * pRecvDsuLnkInf const DSU_RSSP_LINK_RINFO_STRU* IN Ϣ + * pOutputDsuLnkInf const DSU_RSSP_LINK_SINFO_STRU* IN Ϣ + * pRsspLnkInfo RsspLinkInfoStru* INOUT ·Ϣṹ + * + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 SetNodeParam(const DSU_RSSP_LINK_RINFO_STRU* pRecvDsuLnkInf, + const DSU_RSSP_LINK_SINFO_STRU* pOutputDsuLnkInf, + NodeParamInfoStru *pNodeParam) +{ + UINT8 chan = 0; /* źŵ */ + UINT8 index = 0; + for(chan = 0; chan < 2; chan++) + { + /* ͽڵϢ */ + pNodeParam->SIDe[chan] = pOutputDsuLnkInf->SID_NUMBER_R[chan]; /* շSID */ + pNodeParam->SIDr[chan] = pOutputDsuLnkInf->SID_NUMBER_E[chan]; /* ͷSID */ + pNodeParam->SINIT[chan] = pOutputDsuLnkInf->SINIT_NUMBER[chan]; /* ʾ׸SINIT */ + pNodeParam->DATAVER[chan] = pOutputDsuLnkInf->DATAVER_1_Number[chan]; /* DATAVER */ + pNodeParam->NumDataVer[chan] = pOutputDsuLnkInf->DATANUM[chan]; /* Data 汾 */ + + /* ֵ߲ */ + pNodeParam->PREC_FIRSTSINIT[chan] = pRecvDsuLnkInf->PREC_FIRSTSINIT[chan]; /* ߲PREC_FIRSTSINIT */ + for( index = 0; index <5; index++) + { + pNodeParam->PREC_SINIT_K[chan][index] = pRecvDsuLnkInf->PREC_SINIT_K[chan][index]; /* ߲PREC_SINIT */ + pNodeParam->TSD_POST_RXDADA_K[chan][index] = pRecvDsuLnkInf->POST_RXDADA_K[chan][index]; /* ߲ BSD̶ֵ */ + } + } + + /* շϢ */ + pNodeParam->DLost = pRecvDsuLnkInf->DLost; /* */ + pNodeParam->SSDelay = pRecvDsuLnkInf->WSsrOut; /* 涨ʱ䣨SSDelay */ + pNodeParam->AntiDelayCount = pRecvDsuLnkInf->AntiDelayCount; /* ͬ */ + pNodeParam->Tout = pRecvDsuLnkInf->TOut ; /* BSDijʱ */ + pNodeParam->MaxLost = pRecvDsuLnkInf->MaxLost; /* ʧ */ + + return (UINT8)1; +} + +/*-------------------------------------------------------------------- + * ·ģڲ End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspLnkNodeMgr.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspLnkNodeMgr.h new file mode 100644 index 0000000..72ba9f2 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspLnkNodeMgr.h @@ -0,0 +1,187 @@ +/******************************************************** +* +* ļ RsspLnkNodeMgr.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* RsspͨŽڵصĺ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* +********************************************************/ + +#ifndef _RSSP_LNK_NODE_MGR_H_ +#define _RSSP_LNK_NODE_MGR_H_ + +#include "RsspStruct.h" + +#define RSR_VAR_NODE_LEN 98 /* мһڵij */ + +#ifdef __cplusplus +extern "C" { +#endif +/*-------------------------------------------------------------------- + * RSSPڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : InitLnkNodeArr + * : ȫͨŽڵгʼ + * + * : + * + * -------------------------------------------------------------- + * Num UINT8 IN ӦָͨŶ + * + * ȫֱ : LnkNodeArr ͨŽڵ + * ֵ : UINT8 1: 0 + ***********************************************************************/ +UINT8 InitLnkNodeArr(UINT8 Num,RSR_INFO_STRU *pRsrStruct); + +/* wangpeipei 20111201 ADD*/ +/*********************************************************************** + * : SearchLnkBsdNode + * : BsdַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * RsspSrcAddr UINT16 IN RsspԴַ + * DestBsdAdd INT16 IN Bsdַ + * + * ȫֱ : LnkNodeArr ȫֱ + * ֵ : Lnk_Info_Node_Stru* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +Lnk_Info_Node_Stru* SearchLnkBsdNode(UINT16 RsspSrcAddr,INT16 DestBsdAdd,RSR_INFO_STRU *pRsrStruct); + + +/*********************************************************************** + * : SearchLnkSse_SsrNode + * : PSSPĿĵַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * RsspSrcAddr UINT16 IN RsspԴַ + * RsspDestAddr UINT16 IN PsspĿĵַ + * + * ȫֱ : LnkNodeArr ȫֱ + * ֵ : Lnk_Info_Node_Stru* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +Lnk_Info_Node_Stru* SearchLnkSse_SsrNode(UINT16 RsspSrcAddr,UINT16 RsspDestAddr,RSR_INFO_STRU *pRsrStruct); + + +/*********************************************************************** + * : GetReplaceNode + * : ͨɸǵĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * srcAddr UINT16 IN Դַ + * desAddr INT16 IN Ŀַ + * + * ȫֱ : LnkNodeArr* ȫֱͨŽڵ + * ֵ : Lnk_Info_Node_Stru* NULL쳣 NULLͨŽڵ + ***********************************************************************/ +Lnk_Info_Node_Stru* GetReplaceNode(RSR_INFO_STRU *pRsrStruct); +/* wangpeipei 20111201 ADD*/ + +/*********************************************************************** + * : DestoryLnkNodeArr + * : ͷͨŽڵĿռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +void DestoryLnkNodeArr(RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : recvReplaceLnkNode + * : ݱϢͨŽڵϢʼ + * : + * + * ------------------------------------------------------------- + * LocalDevName UINT16 IN ʶ + * pDataNode const DataNode* IN Ľڵ + * pLnkNodeInfo Lnk_Info_Node_Stru* INOUT ͨŽڵ + * + * ֵ : UINT8 1 0󷵻 + * ʹ ΪģյBSDʱӦͨŽڵ㲻ʱ + ***********************************************************************/ +UINT8 recvReplaceLnkNode(UINT16 LocalDevName,const DataNode* pDataNode,Lnk_Info_Node_Stru *pLnkNodeInfo, RSR_INFO_STRU *pRsrStru); + +/*********************************************************************** + * : outputReplaceLnkNode + * : ԴַĿַBSDַȡöӦڵϢ + * ͨŽڵϢʼ + * : + * + * ------------------------------------------------------------- + * SrcAddr UINT16 IN Դַ + * BsdAddr INT16 IN BSDַ + * DestAddr UINT16 IN SSEַ + * LocalDevName UINT16 IN ʶ + * pLnkNodeInfo Lnk_Info_Node_Stru** INOUT ͨŽڵ + * + * ֵ : UINT8 1 0󷵻 + * ʹ Ϊģ飬ַָͨŽڵ㲻ʱ + ***********************************************************************/ +UINT8 outputReplaceLnkNode(UINT16 SrcAddr,INT16 BsdAddr, UINT16 DestAddr,UINT16 LocalDevName,Lnk_Info_Node_Stru **pLnkNodeInfo,RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : SetNodeParam + * : ָRSSPԴַRSSPĿַ(SSE SSR)BSDַѯӦͨŽڵǷڡ + * 򷵻ضӦͨŽڵָ룬򷵻NULL + * : + * + * -------------------------------------------------------------------------- + * SrcAddr UINT16 IN RSSPԴַ + * DestAddr UINT16 IN RSSPĿַSSE SSR + * BsdAddr INT16 IN BSDַ + * + * ֵ : Lnk_Info_Node_Stru* ͨŽڵָ룬 NULL: + ***********************************************************************/ +Lnk_Info_Node_Stru* SearchNodeByAddr(UINT16 SrcAddr, UINT16 DestAddr, INT16 BsdAddr,RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : WriteToVarArray + * : ͨŽڵдм + * : + * + * -------------------------------------------------------------- + * VarArray UINT8* OUT SSR + * ȫֱ UINT8 LnkNodeArr[] + * ֵ : 1 + ***********************************************************************/ +UINT8 WriteToVarArray(UINT8 *VarArray,RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : GetLnkNodeArr + * : ȡȫֵͨŽڵָԼͨŽڵ + * : + * + * ----------------------------------------------------------------------------- + * pLnkInfoNodeArr Lnk_Info_Node_Stru** OUT ָָͨ + * LogId UINT8* OUT + * + * ֵ : + ***********************************************************************/ +void GetLnkNodeArr(Lnk_Info_Node_Stru** pLnkInfoNodeArr,UINT8 *OutLen,RSR_INFO_STRU *pRsrStruct); +/*-------------------------------------------------------------------- + * RSSPڲӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspOutput.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspOutput.c new file mode 100644 index 0000000..e7ab825 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspOutput.c @@ -0,0 +1,929 @@ +/******************************************************** +* +* ļ RsspOutput.C +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* Rsspģ顣 +* ʹע⣺ +* RsspInitòܣñļڵĺ +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2009.12.16 ¥ΰ ¼׷ +* 2010.02.01 ¥ΰ TimeCounter ۼӣ˹ĵ +* 2011.11.17 ¥ΰ Ӧûݷ͵ʱڶⷢκݡ +********************************************************/ + +#include "RsspIF.h" +#include "RsspStruct.h" +#include "RsrCommon.h" +#include "CommonQueue.h" +#include "Convert.h" +#include "dsuRsrFunc.h" +#include "RsspLnkNodeMgr.h" +#include "RsrRecordDelare.h" +#include "CommonRecord.h" +#include "dsuRsrFunc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------- + * RSSPģڲʹú Start + *--------------------------------------------------------------------*/ +static UINT8 CreateBsdMsg(const UINT8 *pAppData,UINT16 DataLen,UINT8 *OutMsg,Lnk_Info_Node_Stru** pPNodeIndex,RSR_INFO_STRU *pRsrStru); +static UINT8 CreateSseMsg(Lnk_Info_Node_Stru *pLnkNodeInfo,UINT8 *OutMsg); +static UINT8 CreateSsrMsg(Lnk_Info_Node_Stru *pLnkNodeInfo,UINT8 *OutMsg); +static UINT8 WriteToRsToSigQue(const UINT8 *pMsg,UINT16 MsgLen,Lnk_Info_Node_Stru *pLnkNodeInfo,QueueStruct *RsToSig, RSR_INFO_STRU *pRsrStru); + +static void SetRsspMsgHead(UINT8 MsgType, UINT16 SrcAddr, UINT16 DestAddr, UINT8 *OutRsspMsg); + +#ifdef RSR_RP_ONLY +static UINT8 WirtToSig(QueueStruct *AppToRs, QueueStruct *RsToSig); +#endif + +/*-------------------------------------------------------------------- + * RSSPģڲʹú End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * RSSPӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : RsrOutput + * : ӦòܵݣаȫݴύźŲ㡣 + * ͬʱͨŽڵ·״̬SSESSRġ + * : + * + * -------------------------------------------------------------- + * SigToRs QueueStruct* IN źŲ㵽Rssp + * RsToSig QueueStruct* OUT Rssp㵽Ӧò + * varArray UINT8* OUT м + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspOutput(QueueStruct *AppToRs,QueueStruct *RsToSig,UINT8 *VarArray,RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 0,index =0; + UINT8 QueErrFlag = 0; /* вFlag,0㹻1 */ + UINT8 LnkNodeNum = 0; /* ͨŽڵ */ + UINT16 MaxMsgLen = 0; /* һнڵݳ */ + UINT16 MsgLen = 0; /* Ϣ */ + UINT8 TmpOutMsg[MAX_RSSP_MSG+32] = {0}; /* ɱݻ */ + Lnk_Info_Node_Stru* LnkNodeArr = NULL; /* ͨŽڵ */ + Lnk_Info_Node_Stru* pNode = NULL; /* ͨŽڵָ */ + UINT8 *RecordArray = pRsrStru->RecordArray; /* ¼ */ + UINT16 RecordSize = pRsrStru->RecordArraySize; /* ¼С */ + /* ywlou20101118 Add S */ + UINT8 appDataFlg = 0; /* 0Ӧ 1 Ӧ */ + /* ywlou20101118 Add E */ + +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"RSSP Output:\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + /* RSRԪʶ */ + PrintRecArrayByte(RecordArray,RecordSize,RSSP_OUT_TAG); + PrintRecArrayByte(RecordArray,RecordSize,pRsrStru->LocalType); /* */ + PrintRecArrayByte(RecordArray,RecordSize,pRsrStru->LocalID); /* ID */ + PrintRecArray2ByteB(RecordArray,RecordSize,(UINT16)QueueStatus(AppToRs)); /* ܳ */ +#endif + +#ifdef RSR_RP_ONLY + ret = WirtToSig(AppToRs, RsToSig); +#else + ret = QueueClear(RsToSig); /* */ + + /* ȡȫֵͨŽڵ */ + GetLnkNodeArr(&LnkNodeArr,&LnkNodeNum,pRsrStru); + + /* ޷ۼ */ + for(index =0; index OutputSize + 6; + + /* ywlou20101118 Add S */ + appDataFlg = 0; + /* wangpeipei 20120611 Mod S */ + if(pRsrStru->LocalType == 0x3c) + { + appDataFlg = 1; + } +/*#if ENM_CI*/ + /* Ƿʱֱӷݡ*/ + /*appDataFlg = 1; +#endif*/ + /* ywlou20101118 Add E */ + + /* ȡӦ */ + while(QueueStatus(AppToRs) > 2) + { + QueueScan(2,pRsrStru->TmpDataBuff,AppToRs); /* ϶ֽ */ + MsgLen = ShortFromChar(pRsrStru->TmpDataBuff); /* ȡó */ + + /* нڵݳ С */ + if(MsgLen <= MaxMsgLen) + { + /* һڵӦ */ + ret = QueueRead((UINT32)(MsgLen+2),pRsrStru->TmpDataBuff,AppToRs); + if(1 == ret) + { + /* BSD */ + ret = CreateBsdMsg(pRsrStru->TmpDataBuff,(UINT16)(MsgLen+2),TmpOutMsg,&pNode,pRsrStru); + + /* BSDɳɹ */ + if(1 == ret) + { + /* д :ȫݳ+ ֡ͷ + ֵ+ ֽ */ + MsgLen = ShortFromCharLE(&TmpOutMsg[RSSP_DATA_SIZE_POS])+RSSP_CRCM_1_POS+CRC_16_LEN; + ret = WriteToRsToSigQue(TmpOutMsg,MsgLen,pNode,RsToSig,pRsrStru); + if(0 == ret) + { + /* дʧܣ¼һӦݴ */ + } + else + { + /* ʲô һڵ */ + /* ywlou20101118 Add S */ + /* һ֡BSD */ + appDataFlg = 1; + /* ywlou20101118 Add E */ + } + } + else /* ʧ */ + { + /* ¼һнڵ */ + } + } + else + { + /* ָȵĶжȡʧܣ˵ʣԪز㣬ֱѭ¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:QueueRead Err\n"); /* ʧ */ +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + PrintRecArray2ByteB(RecordArray,RecordSize,RSR_WARN|RSR_OUTPUT|RSR_ERROR_NULL|RSR_QUEUE_READ); /* ʧ */ + +#endif + gRsrErrorInfo |= RSR_WARN_OUTPUT_RSR_QUEUE_READ; + + break; + } + } + else /* MsgLen >= MaxMsgLen */ + { + /* ¼,һ */ + QueueElementDiscard(MsgLen,AppToRs); + /* ָȵĶжȡʧܣ˵ʣԪز㣬ֱѭ¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:QueueRead Err\n"); /* ʧ */ +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + PrintRecArray2ByteB(RecordArray,RecordSize,RSR_WARN|RSR_OUTPUT|RSR_MSG_FMT_ILLEGAL|RSR_ERROR_NULL); /* Ȳȷ */ + +#endif + gRsrErrorInfo |= RSR_WARN_OUTPUT_RSR_MSG_FMT_ILLEGAL; + + } + } + QueErrFlag = 0; /* вFlag Ϊ 0 */ + /* ͨŽڵ·״̬仯 */ + for(index =0; index RecordArray; /* ¼ */ + UINT16 RecordSize = pRsrStru->RecordArraySize; /* ¼С */ + + const UINT8 SRC_ADDR_APP_QUE_POS = 2; /* ӦòбԴַλ */ + const UINT8 BSD_ADDR_APP_QUE_POS = SRC_ADDR_APP_QUE_POS+2; /* ӦòбBSDַλ */ + const UINT8 DES_ADDR_APP_QUE_POS = BSD_ADDR_APP_QUE_POS+2; /* ӦòбSSE SSRַλ */ + const UINT8 DATA_APP_QUE_POS = DES_ADDR_APP_QUE_POS+2; /* ӦòбӦݵλ */ + + TypeId2DevName(pRsrStru->LocalType, pRsrStru->LocalID, &LocalDevName); + /* + * ---------------------------------------------------- + * ݳ | SrcAddr | BsdAddr | SrcAddr | Ӧ | + * 2ֽ | 2ֽ | 2ֽ | 2ֽ | n | + * ----------------------------------------------------- + */ + SrcAddr = ShortFromChar(&pAppData[SRC_ADDR_APP_QUE_POS]); /* RSSPԴַ */ + DestAddr = ShortFromChar(&pAppData[DES_ADDR_APP_QUE_POS]); /* RSSPĿַ(SSE SSR) */ + BsdAddr = (INT16)ShortFromChar(&pAppData[BSD_ADDR_APP_QUE_POS]); /* BSDַ */ + MsgLen = DataLen - DATA_APP_QUE_POS; /* Ӧݳ */ + +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"IN:\n"); + PrintFiles(RecordArray,RecordSize,"SrcAddr:"); + PrintFileU16Hex(RecordArray,RecordSize,SrcAddr); /* Դַ */ + PrintFiles(RecordArray,RecordSize,"\tBsdAddr:"); + PrintFileU16Hex(RecordArray,RecordSize,BsdAddr); /* BSDַ */ + PrintFiles(RecordArray,RecordSize,"\tSrcAddr:"); + PrintFileU16Hex(RecordArray,RecordSize,DestAddr); /* Ŀַ */ + PrintFiles(RecordArray,RecordSize,"\tDataLen:"); + PrintFileU16Hex(RecordArray,RecordSize,MsgLen); /* Ӧݳ */ + PrintFiles(RecordArray,RecordSize,"\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray,RecordSize,RSSP_MSG_IN_TAG); /* һϢ֡ʼʶ */ + PrintRecArray2ByteB(RecordArray,RecordSize,SrcAddr); /* Դַ */ + PrintRecArray2ByteB(RecordArray,RecordSize,BsdAddr); /* BSDַ */ + PrintRecArray2ByteB(RecordArray,RecordSize,DestAddr); /* Ŀַ */ + PrintRecArray2ByteB(RecordArray,RecordSize,MsgLen); /* Ӧݳ */ +#endif + + /* ѯӦͨŽڵǷ */ + pTmpNode = SearchNodeByAddr(SrcAddr,DestAddr,BsdAddr,pRsrStru); + if(NULL == pTmpNode) /* ͨŽڵ㲻 */ + { + /* ݵַĸǽڵ㣬ڵ㸲 */ + ret = outputReplaceLnkNode(SrcAddr,BsdAddr,DestAddr,LocalDevName,&pTmpNode, pRsrStru); + if( 0 == ret ) + { + /* ڵ㸲 ʧܣ¼ 󷵻 */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:Replace Node Err.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordSize,RSR_WARN|RSR_OUTPUT|RSR_MSG_REPLACE_ERR|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_OUTPUT_RSR_MSG_REPLACE_ERR; + + return ret; + } + else /* Ǵɹ */ + { + /* */ + } + } + else /* ͨŽڵ */ + { + /* */ + } + + /* Ӧݷ͵ͨŽڵΪɸ״̬ */ + pTmpNode->NodeStatus = DisbaledReplace; + (*pPNode) = pTmpNode; /* ͨŽڵָ뱣浽ָ */ + + /* ֡ͷ趨 */ + SetRsspMsgHead(RSSP_BSD_MSG, SrcAddr,BsdAddr, OutBsdMsg); + + /* Body 趨 + * ---------------------------------------------------- + * | ȫݳ | CRCM_1 | CRCM_2 | Ӧ | + * 4ֽ | 2ֽ | 4ֽ | 4ֽ | n | + * ----------------------------------------------------- + */ + /* Ӧ */ + /* pAppData+8 ʼ MsgLenӦݵ */ + RsrMemCopy(pAppData+DATA_APP_QUE_POS, &OutBsdMsg[RSSP_DATA_POS],MsgLen); + if((MsgLen%2) != 0) /* ȫݳȷż */ + { + OutBsdMsg[RSSP_DATA_POS+MsgLen] = 0; /* ȫݲ */ + MsgLen += 1; + } + else + { + /* ʲô */ + } + + /* CRCMֵ,(϶1 ) */ + ret = CalcCRCM(&OutBsdMsg[RSSP_DATA_POS],MsgLen, + pTmpNode->RsspLinInfo.LocalNode.SIDr, + pTmpNode->RsspLinInfo.TimeStmp.NowTn, + CRCM); + + /* 趨 4ֽ */ + LongToCharLE(pTmpNode->RsspLinInfo.TimeStmp.TC, &OutBsdMsg[RSSP_TC_POS]); + + /* ȫݳ Ӧ+ 2CRCM 2ֽ */ + ShortToCharLE((UINT16)(MsgLen+2*CRCM_LEN), &OutBsdMsg[RSSP_DATA_SIZE_POS]); + + /* CRCM[0] CRCM[1] 趨 4 ֽ */ + LongToCharLE(CRCM[0],&OutBsdMsg[RSSP_CRCM_1_POS]); + LongToCharLE(CRCM[1],&OutBsdMsg[RSSP_CRCM_2_POS]); + + /* 16λ CRC 趨 2 ֽ */ + CRC16 = ComputeMsgCRC16(OutBsdMsg,(UINT16)(MsgLen+RSSP_FIXED_LEN-CRC_16_LEN)); + ShortToCharLE(CRC16,&OutBsdMsg[(UINT16)(MsgLen+RSSP_FIXED_LEN-CRC_16_LEN)]); + + + /* ޷ӦΪ 0 */ + pTmpNode->RsspLinInfo.NoAppDataCycleNum = 0; + + ret = 1; + return ret; +} + +/*********************************************************************** + * : CreateSseMsg + * : SSEϢ֡ + * : + * + * -------------------------------------------------------------- + * pLnkNodeInfo Lnk_Info_Node_Stru* INOUT ͨŽڵָ룬SSEں + * OutSseMsg UINT8* OUT SSEϢ֡ + * pLnkNodeInfo ԼOutSseMsg ָǿգɵô֤ + * ֵ : UINT8 1 0󷵻RSSP_SSE_LEN + ***********************************************************************/ +static UINT8 CreateSseMsg(Lnk_Info_Node_Stru *pLnkNodeInfo,UINT8 *OutSseMsg) +{ + UINT8 ret = 0; /* ֵ */ + UINT16 Crc16 = 0; /* CRC 16 */ + UINT32 TmpSeqEnq = 0; /* ʱSEQENQ */ + + /* ͨŽڵ״̬ Լ SSEϢ */ + /* 趨״̬ΪȴSSR */ + pLnkNodeInfo->RsspLinInfo.RecvLinkStatus = WaitSSR; + /* ͨŽڵδΪ0 */ + pLnkNodeInfo->RsspLinInfo.NoRecvDataCycleNum = 0; + + /* SSEʱںͶӦʱ趨 */ + pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTC = pLnkNodeInfo->RsspLinInfo.TimeStmp.TC; /* Ӧֵ֤SSRļֵ */ + pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[0] = pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[0]; /* ӦʱյSSRʱʼSINITֵ */ + pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[1] = pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[1]; + + /* ֡ͷ趨 */ + SetRsspMsgHead(RSSP_SSE_MSG,pLnkNodeInfo->RsspLinInfo.RsspSrcAddr, + pLnkNodeInfo->RsspLinInfo.RsspDestAddr,OutSseMsg); + + /* Body 趨 + * ------------------------------- + * | SEQENQ_1 | SEQENQ_2 | + * 4ֽ | 4ֽ | 4ֽ | + * ------------------------------- + */ + /* */ + LongToCharLE(pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTC, + &OutSseMsg[RSSP_TC_POS]); + + /* SEQENQ_1 SIDe ^ Tn 趨 */ + TmpSeqEnq = pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[0]^pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[0]; + LongToCharLE(TmpSeqEnq,&OutSseMsg[RSSP_SSE_ENQ_1_POS]); + + /* SEQENQ_2 趨 */ + TmpSeqEnq = pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[1]^pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[1]; + LongToCharLE(TmpSeqEnq,&OutSseMsg[RSSP_SSE_ENQ_2_POS]); + + /* CRC 趨*/ + Crc16 = ComputeMsgCRC16(OutSseMsg,RSSP_SSE_LEN-CRC_16_LEN); + ShortToCharLE(Crc16,&OutSseMsg[RSSP_SSE_LEN-CRC_16_LEN]); + + ret =1; + return ret; +} + +/*********************************************************************** + * : CreateSsrMsg + * : SSRϢ֡ + * : + * + * -------------------------------------------------------------- + * pLnkNodeInfo Lnk_Info_Node_Stru* INOUT ͨŽڵָ + * OutSsrMsg UINT8* OUT SSR + * pLnkNodeInfo ԼOutSseMsg ָǿգɵô֤ + * ֵ : 1 + ***********************************************************************/ +static UINT8 CreateSsrMsg(Lnk_Info_Node_Stru *pLnkNodeInfo,UINT8 *OutSsrMsg) +{ + UINT8 ret = 0; /* ֵ */ + UINT16 Crc16 = 0; /* CRC 16 */ + UINT32 TmpSeqIni = 0; /* ʱSEQIni */ + + /* 趨״̬Ϊ */ + pLnkNodeInfo->RsspLinInfo.SendLinkStatus = SendData; + + + /* ֡ͷ趨 */ + SetRsspMsgHead(RSSP_SSR_MSG,pLnkNodeInfo->RsspLinInfo.RsspSrcAddr, + pLnkNodeInfo->RsspLinInfo.RsspDestAddr,OutSsrMsg); + + /* Body 趨 */ + LongToCharLE(pLnkNodeInfo->RsspLinInfo.TimeStmp.TC, &OutSsrMsg[RSSP_TC_POS]); /* */ + LongToCharLE(pLnkNodeInfo->RsspLinInfo.TimeStmp.RecvSseTCe,&OutSsrMsg[RSSP_SSR_TCENQ_POS]); /* ܵSSEļ */ + + /* SEQINI = SEQENQ ^ SIDr ^ DataVer ^ Tr(n) */ + /* SEQINI_1 趨 */ + TmpSeqIni = pLnkNodeInfo->RsspLinInfo.TimeStmp.SeqEng[0] ^ pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[0] + ^ pLnkNodeInfo->RsspLinInfo.LocalNode.DATAVER[0] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[0]; + LongToCharLE(TmpSeqIni,&OutSsrMsg[RSSP_SSR_INI_1_POS]); + + /* SEQINI_2 趨 */ + TmpSeqIni = pLnkNodeInfo->RsspLinInfo.TimeStmp.SeqEng[1] ^ pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[1] + ^ pLnkNodeInfo->RsspLinInfo.LocalNode.DATAVER[1] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[1]; + LongToCharLE(TmpSeqIni,&OutSsrMsg[RSSP_SSR_INI_2_POS]); + + /* NUM_DATAVER 趨 źŵ1 źŵ2 汾һ ĬΪźŵ1 */ + OutSsrMsg[RSSP_SSR_NUM_POS] = pLnkNodeInfo->RsspLinInfo.LocalNode.NumDataVer[0]; + + /* CRC 趨*/ + Crc16 = ComputeMsgCRC16(OutSsrMsg,RSSP_SSR_LEN-CRC_16_LEN); + ShortToCharLE(Crc16,&OutSsrMsg[RSSP_SSR_LEN-CRC_16_LEN]); + + ret =1; + return ret; +} + +/*********************************************************************** + * : SetRsspMsgHead + * : RsspϢ֡ͷɡ + * : + * + * -------------------------------------------------------------- + * MsgLen UINT8 IN Ϣ + * SrcAddr UINT16 IN Դַ + * DestAddr UINT16 IN Ŀַ + * OutRsspMsg UINT8* OUT RSSPϢ֡ + * OutRsspMsg ָǿԼȷԣɵô֤ + * ֵ : + ***********************************************************************/ +static void SetRsspMsgHead(UINT8 MsgType, UINT16 SrcAddr, UINT16 DestAddr, UINT8 *OutRsspMsg) +{ + OutRsspMsg[RSSP_APP_CTGRY_POS] = RSSP_APP_CATEGORY; /* signaling variables */ + OutRsspMsg[RSSP_MSG_TYPE_POS] = MsgType; /* Ϣ趨 */ + ShortToCharLE(SrcAddr,&OutRsspMsg[RSSP_SRC_ADD_POS]); /* 趨ԴַLITTLE endian */ + ShortToCharLE(DestAddr,&OutRsspMsg[RSSP_DEST_ADD_POS]); /* 趨ԴַLITTLE endian */ + +} + +/*********************************************************************** + * : WriteToRsToSigQue + * : ĵднڵ㡣 + * : + * + * -------------------------------------------------------------- + * pMsg const UINT8* IN RSSP + * MsgLen UINT16 IN ij + * pLnkNodeInfo Lnk_Info_Node_Stru IN ͨŽڵָ + * RsToSig QueueStruct* OUT RSSP㵽źŲ + * RsToSig pLnkNodeInfo ԼpMsg ָǿգɵô֤ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 WriteToRsToSigQue(const UINT8 *pMsg, + UINT16 MsgLen, + Lnk_Info_Node_Stru *pLnkNodeInfo, + QueueStruct *RsToSig, RSR_INFO_STRU *pRsrStru) +{ + + UINT8 ret = 1; + UINT16 Len = 0; /* ڵ㳤 ȵֽ */ + UINT8 TmpQueueBuff[MAX_RSSP_MSG+4+2+32] = {0}; /* */ + UINT8 *RecordArray = pRsrStru->RecordArray; /* ¼ */ + UINT16 RecordSize = pRsrStru->RecordArraySize; /* ¼С */ + const UINT8 LEN_POS = 0; /* ڵ㳤ȱλ */ + const UINT8 LOCAL_LOG_ID_POS = LEN_POS+2; /* ̬IDλ */ + const UINT8 DEST_DEVNAME_POS = LOCAL_LOG_ID_POS+1; /* Էʶλ */ + const UINT8 DEST_LOG_ID_POS = DEST_DEVNAME_POS+2; /* Է̬IDλ */ + const UINT8 RSSP_MSG_POS = DEST_LOG_ID_POS+1; /* RsspϢ֡ʼλ */ + + Len = MsgLen + 4; /* ij + 4 */ + + /* иʽ + * --------------------------------------------------------------------- + * ݳ | ̬Id | Է | ԷId | Է̬Id| RSSPϢ | + * 2ֽ | 1ֽ | 1 ֽ | 1ֽ | 1 | n | + * -------------------------------------------------------------------- + */ + /* д볤*/ + ShortToChar(Len,TmpQueueBuff); + + /* ̬ID */ + TmpQueueBuff[LOCAL_LOG_ID_POS] = pLnkNodeInfo->RsspLinInfo.LocalLogId; + + /* ԷͣԷId */ + ShortToChar(pLnkNodeInfo->DestDevName,&TmpQueueBuff[DEST_DEVNAME_POS]); + + /* Է̬ID趨 */ + TmpQueueBuff[DEST_LOG_ID_POS] = pLnkNodeInfo->RsspLinInfo.DestLogId; + + /* RSSPϢ */ + RsrMemCopy(pMsg,&TmpQueueBuff[RSSP_MSG_POS],MsgLen); + + /* д */ + ret = QueueWrite(Len+2,TmpQueueBuff,RsToSig); + if( 0 == ret) + { + /* ¼ 󷵻 */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:QueueWrite Err.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordSize,RSR_WARN|RSR_OUTPUT|RSR_ERROR_NULL|RSR_QUEUE_WRITE); + +#endif + gRsrErrorInfo |= RSR_WARN_OUTPUT_RSR_QUEUE_WRITE; + + return ret; + } + else + { + /* ʲô */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"Out:\n"); + PrintFiles(RecordArray,RecordSize,"LocLogId:"); + PrintFileHex(RecordArray,RecordSize,&TmpQueueBuff[LOCAL_LOG_ID_POS],1); /* ̬Id */ + PrintFiles(RecordArray,RecordSize,"\tDestType:"); + PrintFileHex(RecordArray,RecordSize,&TmpQueueBuff[DEST_DEVNAME_POS],1); /* Է */ + PrintFiles(RecordArray,RecordSize,"\tDestId:"); + PrintFileHex(RecordArray,RecordSize,&TmpQueueBuff[DEST_DEVNAME_POS+1],1);/* ԷId */ + PrintFiles(RecordArray,RecordSize,"\tDestLogId:"); + PrintFileHex(RecordArray,RecordSize,&TmpQueueBuff[DEST_LOG_ID_POS],1); /* Է̬Id */ + PrintFiles(RecordArray,RecordSize,"\tMsgType:"); + PrintFileHex(RecordArray,RecordSize,(UINT8 *)(&pMsg[RSSP_MSG_TYPE_POS]),1); /* Ϣ */ + PrintFiles(RecordArray,RecordSize,"\tSrcAddr:"); + PrintFileU16Hex(RecordArray,RecordSize,ShortFromCharLE(&pMsg[RSSP_SRC_ADD_POS])); /* ϢԴַ */ + PrintFiles(RecordArray,RecordSize,"\tBsdAddr:"); + PrintFileU16Hex(RecordArray,RecordSize,ShortFromCharLE(&pMsg[RSSP_DEST_ADD_POS])); /* ϢĿַ */ + PrintFiles(RecordArray,RecordSize,"\tTC:"); + PrintFileU32Hex(RecordArray,RecordSize,LongFromCharLE(&pMsg[RSSP_TC_POS])); /* */ + PrintFiles(RecordArray,RecordSize,"\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray,RecordSize,RSSP_MSG_OUT_TAG); /* һϢ֡ʼʶ */ + PrintRecArrayByte(RecordArray,RecordSize,TmpQueueBuff[LOCAL_LOG_ID_POS]); /* ̬Id */ + PrintRecArrayByte(RecordArray,RecordSize,TmpQueueBuff[DEST_DEVNAME_POS]); /* Է */ + PrintRecArrayByte(RecordArray,RecordSize,TmpQueueBuff[DEST_DEVNAME_POS+1]); /* ԷId */ + PrintRecArrayByte(RecordArray,RecordSize,TmpQueueBuff[DEST_LOG_ID_POS]); /* Է̬Id */ + PrintRecArrayByte(RecordArray,RecordSize,pMsg[RSSP_MSG_TYPE_POS]); /* Ϣ */ + PrintRecArray2ByteB(RecordArray,RecordSize,ShortFromCharLE(&pMsg[RSSP_SRC_ADD_POS])); /* ϢԴַ */ + PrintRecArray2ByteB(RecordArray,RecordSize,ShortFromCharLE(&pMsg[RSSP_DEST_ADD_POS])); /* ϢĿַ */ + PrintRecArray4ByteB(RecordArray,RecordSize,LongFromCharLE(&pMsg[RSSP_TC_POS])); /* */ +#endif + } + return ret; +} + /*-------------------------------------------------------------------- + * RSSPģڲʹúʵ End + *--------------------------------------------------------------------*/ + +#ifdef RSR_RP_ONLY +/* ʱRSR */ +static UINT8 WirtToSig(QueueStruct *AppToRs, QueueStruct *RsToSig) +{ UINT8 ret = 0; + UINT8 ContinueFlag = 0; /* ѭʶ 1һѭ0*/ + UINT16 MsgLen = 0; /* ڵݳ */ + UINT16 SrcAddr = 0, DestAddr = 0; /* ԴַĿַ */ + INT16 BsdAddr = 0; /* BSDַ */ + UINT8 LocalLogId = 0, DestLogId = 0; /* ̬IdԷ̬Id */ + UINT8 DestType = 0, DestId = 0; /* ԷͣԷId */ + Lnk_Info_Node_Stru* pLnkNode = NULL; /* ͨŽڵָ */ + DSU_RSSP_LINK_SINFO_STRU OutputDsuLnkInfo; /* ͻϢ */ + UINT8 TmpDataBuffArr[MAX_RSSP_MSG+128] = {0}; /* Ӧݻ */ + UINT8 OutDataBuff[MAX_RSSP_MSG+128] = {0}; /* Ӧݻ */ + const UINT8 SRC_ADDR_APP_QUE_POS = 2; /* ӦòбԴַλ */ + const UINT8 BSD_ADDR_APP_QUE_POS = SRC_ADDR_APP_QUE_POS+2; /* ӦòбBSDַλ */ + const UINT8 DES_ADDR_APP_QUE_POS = BSD_ADDR_APP_QUE_POS+2; /* ӦòбSSE SSRַλ */ + const UINT8 DATA_APP_QUE_POS = DES_ADDR_APP_QUE_POS+2; /* Ӧòб汾̬Idλ */ + const UINT8 LEN_OUT_QUE_POS = 0; /* ݳȱλ */ + const UINT8 SRC_LOGID_OUT_QUE_POS = LEN_OUT_QUE_POS+2; /* Դ̬Idλ */ + const UINT8 DEST_TYPE_OUT_QUE_POS = SRC_LOGID_OUT_QUE_POS+1;/* жԷͱλ */ + const UINT8 DEST_ID_OUT_QUE_POS = DEST_TYPE_OUT_QUE_POS+1; /* жԷIdλ */ + const UINT8 DEST_LOGID_OUT_QUE_POS = DEST_ID_OUT_QUE_POS+1; /* жԷ̬Idλ */ + const UINT8 DATA_OUT_QUE_POS = DEST_LOGID_OUT_QUE_POS+1; /* ݱλ */ + const UINT16 MAX_FRAME_LEN = MAX_RSSP_MSG + 6 -22; + while( QueueStatus(AppToRs) > 2) + { + ContinueFlag = 0; + QueueScan(2,TmpDataBuffArr,AppToRs); /* ɨ */ + MsgLen = ShortFromChar(TmpDataBuffArr); + if( MsgLen <= MAX_FRAME_LEN ) /* ȺϷ */ + { + ret = QueueRead(MsgLen+2,TmpDataBuffArr,AppToRs); /* нڵ */ + if( 0 == ret) + { + /* ¼ */ + break; + } + else + { + /* ʲô */ + } + SrcAddr = ShortFromChar(&TmpDataBuffArr[SRC_ADDR_APP_QUE_POS]); /* Դַ */ + BsdAddr = ShortFromChar(&TmpDataBuffArr[BSD_ADDR_APP_QUE_POS]); /* BSDַ */ + DestAddr = ShortFromChar(&TmpDataBuffArr[DES_ADDR_APP_QUE_POS]); /* SSE SSRַ */ + + /* ͻϢȡ */ + ret = dsuRsspSGetLnkInfo(SrcAddr,BsdAddr,&OutputDsuLnkInfo); + if((1 == ret) && (DestAddr == OutputDsuLnkInfo.SseAddr)) + { + if(ROLE_ZC_CI == OutputDsuLnkInfo.ROLE ) + { + /* ̶͹̶ͨţȡ Էı־Է豸ID Ϊ Է̬ID */ + DevName2TypeId(OutputDsuLnkInfo.DestName, &DestType,&DestId); + DestLogId = DestId; /* ̶豸Id Ϊ̬Id */ + LocalLogId = gpRsrInfoStru->LocalID; + } + else if( ROLE_VOBC2CI == OutputDsuLnkInfo.ROLE ) + { + /* VOBCCIͨţΪVOBCȡöԷıʶ Լ̬Id */ + DevName2TypeId(OutputDsuLnkInfo.DestName, &DestType,&DestId); + DestLogId = DestId; + LocalLogId = OutputDsuLnkInfo.LocalLogId; + } + else if(ROLE_CI2VOBC == OutputDsuLnkInfo.ROLE ) + { + /* CI VOBC ͨ ΪCIֻȡöԷĶ̬Id */ + DestLogId = OutputDsuLnkInfo.DestLogId; + LocalLogId = gpRsrInfoStru->LocalID; + + /* + * ݶԷ̬Id ȡ ӦڵϢ + * ȡò յӦCCϢ֮ǰCICCϢ + */ + pLnkNode = SearchLnkNode(0,DestLogId); + if( (NULL == pLnkNode) || (pLnkNode->DestDevName == 0)) + { + /* + * ûҵӦͨŽڵ ҵͨŽڵ㻹ûյӦCC Ϣ + * Ӧݣһ֡Ӧ + */ + ContinueFlag = 1; + } + else + { + /* ȡöԷͺ豸Id */ + DevName2TypeId(pLnkNode->DestDevName, &DestType, &DestId); + } + } + else + { /* ȡͨŹϵϷ Ӧ */ + ContinueFlag = 1; + } + + if(0 == ContinueFlag) + { + /* RSSPźŲнڵʽ + * ---------------------------------------------------------------- + * | ̬Id | Է | ԷId | Է̬Id | Ӧ | + * 2ֽ| 1ֽ | 1 ֽ | 1 ֽ | 1ֽ | n | + *----------------------------------------------------------------- + */ + ShortToChar(MsgLen-6+4,&OutDataBuff[LEN_OUT_QUE_POS]); /* ݳ */ + OutDataBuff[SRC_LOGID_OUT_QUE_POS] = LocalLogId; /* Դ̬Id */ + OutDataBuff[DEST_TYPE_OUT_QUE_POS] = DestType; /* Է */ + OutDataBuff[DEST_ID_OUT_QUE_POS] = DestId; /* ԷId */ + OutDataBuff[DEST_LOGID_OUT_QUE_POS] = DestLogId; /* Է̬Id */ + RsrMemCopy( &TmpDataBuffArr[DATA_APP_QUE_POS], /* MsgLen-6 Ӧ */ + &OutDataBuff[DATA_OUT_QUE_POS], MsgLen-6); + /* д MsgLen-6+4 + 2 ij */ + ret = QueueWrite(MsgLen, OutDataBuff,RsToSig); + if(0 == ret) + { + /* дʧܣ˵пнڵݲ,һ֡ݴ */ + break; + } + else + { + /* ʲô */ + } + } /* 0 == ContinueFlag */ + else + { + /* ʲôһ֡ݴ */ + } + } + else /* if(1 == ret && DestAddr == OutputDsuLnkInfo.SseAddr ) */ + { + /* һ֡ݴ */ + } + } + else + { + /* ֡ȲϷ ¼ */ + } + + } /* while(QueueStatus(AppToRs) >2) */ + + ret = 1; + return ret; +} +#endif + +#ifdef __cplusplus +} +#endif diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspRecive.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspRecive.c new file mode 100644 index 0000000..76bf0f6 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspRecive.c @@ -0,0 +1,1217 @@ +/******************************************************** +* ļ RsspRecive.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* Rsspʵ +* ʹע⣺ +* RsspInitòܣñļڵĺ +* ޸ļ¼ +* ޸ļ¼ +* ʱ ޸ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2009.12.16 ¥ΰ ¼׷ +* 2010.01.14 ¥ΰ 뿨˹µԺ󣬱ȥͬ +* 2010.01.23 ¥ΰ ɲȱݶӦΪHalt̬ʱͬʱSSE +* 2010.05.10 ¥ΰ ģļ¼׷RSSPڿʼʶԼں +* 2011.12.06 ޸AnalysisSSEnqMsg +* 2011.12.06 ޸AnalysisBsdMsg +* 2011.12.06 ޸AnalysisSSRepMsg +* 2011.12.06 CheckAddr鱨ϢͨŽڵϢǷһ¡ +********************************************************/ + +#include "RsspIF.h" +#include "RsspStruct.h" +#include "RsrCommon.h" +#include "RsspLnkNodeMgr.h" +#include "RsspTmpMsgLnkCommon.h" +#include "RsrRecordDelare.h" +#include "CommonRecord.h" +#include "dsuRsrFunc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------- + * RSSPģڲʹú Start + *--------------------------------------------------------------------*/ + static UINT8 WriteRsToAppQue(DataNode *pHead,QueueStruct* RsToApp,UINT8 *RecordArray, UINT16 RecordArraySize, RSR_INFO_STRU *pRsrStru); + static UINT8 AnalysisSSEnqMsg(const DataNode* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSR_INFO_STRU *pRsrStru); + static UINT8 AnalysisSSRepMsg(const DataNode* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSR_INFO_STRU *pRsrStru); + static UINT8 AnalysisBsdMsg(const DataNode* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSR_INFO_STRU *pRsrStru); + static UINT8 CheckSseSsrAddr(const DataNode *pDataNode, const Lnk_Info_Node_Stru *pLnkNode, RSR_INFO_STRU *pRsrStru); + static UINT8 UptLnkNodeInfoBySSE(const DataNode *pDataNode, Lnk_Info_Node_Stru *pLnkNode, RSR_INFO_STRU *pRsrStru); + static UINT8 UptLnkNodeInfoBySSR(const DataNode *pDataNode, Lnk_Info_Node_Stru *pLnkNode, RSR_INFO_STRU *pRsrStru); + /* wangpeiepi 20111201 ADD*/ + static UINT8 CheckAddr(const DataNode *pDataNode, const Lnk_Info_Node_Stru *pLnkNode); + /* wangpeiepi 20111201 ADD*/ + + static UINT8 CheckBsdMsg(const UINT8 *pBsdMsg,Lnk_Info_Node_Stru *pLnkNode, RSR_INFO_STRU *pRsrStru); + + static UINT8 RecvLnkStatusMng(RSR_INFO_STRU *pRsrStru); +#ifdef RSR_RP_ONLY + /* ʱRSR ר */ + static UINT8 WriteDataToAppQ(QueueStruct *SigQue,QueueStruct* AppQue); +#endif + /*-------------------------------------------------------------------- + * RSSPģڲʹú End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * RSSPӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : RsspReceive + * : źŲܵݶУȫύӦò + * : + * + * -------------------------------------------------------------- + * SigToRs QueueStruct* IN źŲ㵽Rssp + * RsToSig QueueStruct* OUT Rssp㵽Ӧò + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspReceive(QueueStruct *SigToRs,QueueStruct *RsToApp, RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 0; + UINT8 DelNodeFlg = 0; /* ɾڵʶ 0ɾ 1ɾ */ + UINT8 MsgType = 0; /* Ϣ */ + UINT16 MaxLen = 0; /* һ֡С */ + DataNode *pMsgHead = NULL; /* ʱıͷ */ + DataNode *pCur = NULL, *pLast = NULL; /* ǰڵָ룬һڵָ */ + DataNode *pNext = NULL; + UINT8 *RecordArray = pRsrStru->RecordArray; /* ¼ */ + UINT16 RecordSize = pRsrStru->RecordArraySize; /* ¼С */ + +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"RSSP Receive:\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + /* RSR뵥Ԫʶ */ + PrintRecArrayByte(RecordArray,RecordSize,RSSP_CYCLE_TAG); /* ڿʼ0xEE */ /* M_2010_05_10 */ + PrintRecArray4ByteB(RecordArray,RecordSize,*pRsrStru->CycleNum); /* ں */ /*M_2010_05_10 */ + PrintRecArrayByte(RecordArray,RecordSize,RSSP_RCV_TAG); + PrintRecArrayByte(RecordArray,RecordSize,pRsrStru->LocalType); /* */ + PrintRecArrayByte(RecordArray,RecordSize,pRsrStru->LocalID); /* ID */ + PrintRecArray2ByteB(RecordArray,RecordSize,(UINT16)QueueStatus(SigToRs)); /* ܳ */ +#endif + + ret = QueueClear(RsToApp); /* */ + + /* нڵݳ = InputSize + RSSPϢ̶ + й̶(4+ 2) */ + MaxLen = pRsrStru->InputSize + RSSP_FIXED_LEN + 6; + /* ı 浽ʱ */ + pMsgHead = GetSortedMsgFromQue(SigToRs,MaxLen,RecordArray,RecordSize, pRsrStru); + pCur = pMsgHead; + pLast = NULL; + + /* ʱﱨĽд */ + while(pCur != NULL) + { + DelNodeFlg = 0; /* ɾ */ + MsgType = pCur->Data[RSSP_MSG_TYPE_POS]; + pNext = pCur->pNextNode; + + /* ǰϢ͵ж */ + if( RSSP_SSE_MSG == MsgType) + { + /* ǰڵ㱨ĵϢΪ SSE */ + ret = AnalysisSSEnqMsg(pCur,RecordArray,RecordSize,pRsrStru); + + /* ʱ ɾڵ */ + DelNodeFlg = 1; + } + else if ( RSSP_SSR_MSG == MsgType ) + { + /* SSR */ + ret = AnalysisSSRepMsg(pCur,RecordArray,RecordSize,pRsrStru); + + /* ʱ ɾڵ */ + DelNodeFlg = 1; + } + else + { + /* Ѿ֤ϢͺϷ + * SSE SSR϶ BSD + */ + ret = AnalysisBsdMsg(pCur,RecordArray,RecordSize,pRsrStru); + if( 0 == ret) /* ʧ */ + { + /* ɾýڵ */ + DelNodeFlg = 1; + } + else + { + /* ʲô һڵ */ + } + } + + /* SSEĻSSRĻBSDķʱɾǰĽڵ */ + if( 1 == DelNodeFlg) + { + ret = DelTmpMsgLnkNode(pCur, pLast, &pMsgHead, pRsrStru); + } + else + { + /* һĽڵ */ + pLast = pCur; + } + + /* һڵ㴦 */ + pCur = pNext; + } /* While */ + + /* ʱBSDд */ + ret = WriteRsToAppQue(pMsgHead,RsToApp,RecordArray,RecordSize,pRsrStru); + + /* ״̬ */ + ret = RecvLnkStatusMng(pRsrStru); +#ifdef RSR_RP_ONLY + ret = WriteDataToAppQ(SigToRs,RsToApp); +#endif + + return ret; +} + + +/*-------------------------------------------------------------------- + * RSSPӿں End + *--------------------------------------------------------------------*/ + + /*-------------------------------------------------------------------- + * RSSPģڲʹúʵ Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : AnalysisSSEnqMsg + * : յSSEϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * pNode const DataNode* IN źŲ㵽Rssp + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 AnalysisSSEnqMsg(const DataNode* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 0; + Lnk_Info_Node_Stru *retLnkNodePtr = NULL; + /* wangpeipei 20111201 ADD*/ + UINT16 SrcAddr = 0; + UINT16 DesAddr = 0; + /* wangpeipei 20111201 ADD*/ + /* ij == 18CRC*/ + if((RSSP_SSE_LEN -CRC_16_LEN) == pNode->DataLen) + { + /* wangpeipei 20111201 ADD S */ + DesAddr = ShortFromCharLE(&pNode->Data[RSSP_SRC_ADD_POS]); + SrcAddr = ShortFromCharLE(&pNode->Data[RSSP_DEST_ADD_POS]); + retLnkNodePtr = SearchLnkSse_SsrNode(SrcAddr,DesAddr, pRsrStru); + /* wangpeipei 20111201 ADD E */ + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + /* wangpeipei 20111201 ADD S */ + ret = CheckAddr(pNode,retLnkNodePtr); + /* wangpeipei 20111201 ADD E */ + if(0 == ret) + { + /* һ ¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_NOT_NODE_ERR|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_NOT_NODE_ERR; + + } + else /* ͨ */ + { + /* ·Ϣṹ */ + ret = UptLnkNodeInfoBySSE(pNode,retLnkNodePtr,pRsrStru); + } + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Node Not Exist.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_NOT_NODE_ERR|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_NOT_NODE_ERR; + + } + } + else /* Ȳ */ + { + /* ¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_LEN_ERR|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_LEN_ERR; + + } + + ret = 1; + return ret; +} + +/*********************************************************************** + * : AnalysisSSRepMsg + * : յSSRϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * pNode const DataNode* IN źŲ㵽Rssp + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 AnalysisSSRepMsg(const DataNode* pNode,UINT8 *RecordArray,UINT16 RecordArraySize, RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 0; + Lnk_Info_Node_Stru *retLnkNodePtr = NULL; + /* wangpeipei 20111201 ADD*/ + UINT16 SrcAddr = 0; + UINT16 DesAddr = 0; + /* wangpeipei 20111201 ADD*/ + /* ij == 23CRC*/ + if((RSSP_SSR_LEN-CRC_16_LEN) == pNode->DataLen) + { + /* wangpeipei 20111201 ADD */ + DesAddr = ShortFromCharLE(&pNode->Data[RSSP_SRC_ADD_POS]); + SrcAddr = ShortFromCharLE(&pNode->Data[RSSP_DEST_ADD_POS]); + retLnkNodePtr = SearchLnkSse_SsrNode(SrcAddr,DesAddr,pRsrStru); + /* wangpeipei 20111201 ADD */ + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + /* wangpeipei 20111201 ADD S */ + ret = CheckAddr(pNode,retLnkNodePtr); + /* wangpeipei 20111201 ADD E */ + if(0 == ret) + { + /* һ ¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_NOT_NODE_ERR|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_NOT_NODE_ERR; + + } + else /* ͨ */ + { + /* ·Ϣṹ */ + ret = UptLnkNodeInfoBySSR(pNode,retLnkNodePtr,pRsrStru); + if( 0 == ret) + { + /* ³˵ǶӦSSR ô¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:SSR Msg Err.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_SSR_NOT_ILLEGAL|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_SSR_NOT_ILLEGAL; + + } + else + { + /* ʲô */ + } + } + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_NOT_NODE_ERR|RSR_ERROR_NULL); +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_NOT_NODE_ERR; + + } + } + else /* Ȳ */ + { + /* ¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_LEN_ERR|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_LEN_ERR; + + } + + ret = 1; + return ret; +} + +/*********************************************************************** + * : AnalysisBsdMsg + * : յBSDϢн֡ + * : + * + * -------------------------------------------------------------- + * pNode const DataNode* IN źŲ㵽Rssp + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 AnalysisBsdMsg(const DataNode* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 1; /* */ + UINT8 DestType = 0, DestId = 0; /* ԷͣԷId */ + UINT16 LocalDevName = 0; /* ʶ */ + UINT16 RsspMsgLen = 0; /* RSSPϢ峤 */ + Lnk_Info_Node_Stru *retLnkNodePtr = NULL; + /* wangpeipei 20111201 ADD*/ + UINT16 srcAddr = 0; + INT16 bsdAddr = 0; + /* wangpeipei 20111201 ADD*/ + + /* ʶ*/ + TypeId2DevName(pRsrStru->LocalType, pRsrStru->LocalID,&LocalDevName); + /* ԷͣIdȡ */ + DevName2TypeId(pNode->DevName, &DestType, &DestId); + /* Ϣ峤 */ + RsspMsgLen = ShortFromCharLE(&pNode->Data[RSSP_DATA_SIZE_POS]); + + /* RSSPij >= BSD̶(20,CRC) + * && Ϣ峤 == RSSPij-BSD̶ + 2 CRCM + */ + if((RSSP_DATA_POS <= pNode->DataLen) + &&((pNode->DataLen - RSSP_CRCM_1_POS)== RsspMsgLen)) + { + /* wangpeipei 20111201 ADD */ + srcAddr= ShortFromCharLE(&pNode->Data[RSSP_SRC_ADD_POS]); + bsdAddr = (INT16)ShortFromCharLE(&pNode->Data[RSSP_DEST_ADD_POS]); + retLnkNodePtr = SearchLnkBsdNode(srcAddr,bsdAddr, pRsrStru); + /* wangpeipei 20111201 ADD */ + + /* ͨŽڵͨŹϵж */ + if( NULL != retLnkNodePtr) /* ͨŽڵ */ + { + /* BSDϢǷͨŽڵһ */ + /* wangpeipei 20111206 ADD S */ + ret = CheckAddr(pNode,retLnkNodePtr); + /* wangpeipei 20111206 ADD E */ + if(1 == ret) /* ֤ͨ */ + { + /* ֤BSDϢǷϷ */ + ret = CheckBsdMsg(pNode->Data,retLnkNodePtr, pRsrStru); + if(1 == ret) + { + /* ֤ͨ */ + /* ϴյıʱ趨Ϊǰں */ + retLnkNodePtr->RsspLinInfo.TimeStmp.LastLocalRecTC = *pRsrStru->CycleNum; + /* 趨Ϊ0 */ + retLnkNodePtr->RsspLinInfo.NoRecvDataCycleNum = 0; + + /* ɹ */ + ret = 1; + } + else + { +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:BSD Invalid.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_NO_INVALID|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_NO_INVALID; + + /* ֤ʧ */ + ret = 0; + } + } + else + { + /* ¼ ,󷵻 */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_NOT_NODE_ERR|RSR_ERROR_NULL); +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_NOT_NODE_ERR; + + ret = 0; + } + } + else /* ͨŽڵ㲻 if( NULL != retLnkNodePtr) */ + { + /* ڣȡɸǽڵи */ + /* wangpeipei 20111206 ADD S */ + retLnkNodePtr = GetReplaceNode(pRsrStru); + + /* wangpeipei 20111206 ADD E */ + if( NULL != retLnkNodePtr) /* ǽڵ */ + { + ret = recvReplaceLnkNode(LocalDevName,pNode,retLnkNodePtr, pRsrStru); + if( 0 == ret) + { + /* ¼Warning */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Rplace Node Err.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_REPLACE_ERR|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_REPLACE_ERR; + + } + else + { + /* ʲô */ + } + /* 󷵻أԲ洦ɾýڵ */ + ret = 0; + } + else /* ǽڵ㲻 */ + { + ret = 0; /* 󷵻أ */ + /* ¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:No Rplace Node.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_NO_REPLACENODE|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_NO_REPLACENODE; + + } + + } /* else */ + } + else /* ȲϷ ¼ */ + { + /* ¼󷵻 */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_LEN_ERR|RSR_ERROR_NULL); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_LEN_ERR; + + ret = 0; + } + + return ret; +} +/*********************************************************************** + * : WriteRsToAppQue + * : ԽɹBSDĵӦдС + * жֻ֡ȡµıݡ + * : + * + * -------------------------------------------------------------- + * pHead DataNode* IN źŲ㵽Rssp + * RsToApp QueueStruct* INOUT RSSPӦõ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 WriteRsToAppQue(DataNode *pHead,QueueStruct* RsToApp,UINT8 *RecordArray, UINT16 RecordArraySize, RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 0; + DataNode *pCur = NULL,*pNext = NULL; + UINT16 SrcAddr = 0, DestAddr = 0; /* Դַ Ŀַ */ + UINT16 AppDataLen = 0; /* Ӧݳ */ + const UINT8 LEN_OUT_QUE_POS = 0; /* ݳȱλ */ + const UINT8 SRC_ADDR_OUT_QUE_POS = LEN_OUT_QUE_POS+2; /* жԷԴַλ */ + const UINT8 DEST_ADDR_OUT_QUE_POS = SRC_ADDR_OUT_QUE_POS+2; /* жԷBSDַλ */ + const UINT8 DATA_OUT_QUE_POS = DEST_ADDR_OUT_QUE_POS+2; /* ݱλ */ + + pCur = pHead; + /* ǰڵ㲻Ϊ */ + while(pCur != NULL) + { + /* ǰڵһڵıʶȣѸñĵݶ */ + pNext = pCur->pNextNode; + if( (NULL != pNext) && (pNext->DevName == pCur->DevName) ) + { + /* ˵ñʶӦķͷ±ģڵΪݣ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:OLD MSG.\n"); /* ±Ķ */ +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_MSG_OLD_ERR|RSR_ERROR_NULL); /* ±Ķ */ + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_OLD_ERR; + + } + else + { + /* ȫݳ 2CRCM */ + AppDataLen = ShortFromCharLE(&pCur->Data[RSSP_DATA_SIZE_POS]) -2*CRCM_LEN; + SrcAddr = ShortFromCharLE(&pCur->Data[RSSP_SRC_ADD_POS]); /* RSSPԴַ */ + DestAddr = ShortFromCharLE(&pCur->Data[RSSP_DEST_ADD_POS]); /* RSSPĿַ */ + /* д + * ------------------------------------------------- + * ݳ | Դַ | Ŀַ| Ӧ | + * 2ֽ | 2ֽ | 2 ֽ | n | + * ------------------------------------------------- + */ + ShortToChar((UINT16)(AppDataLen+4),&pRsrStru->TmpDataBuff[LEN_OUT_QUE_POS]); /* ݳ ȫݳ + 4(ԴַĿַ) */ + ShortToChar(SrcAddr,&pRsrStru->TmpDataBuff[SRC_ADDR_OUT_QUE_POS]); /* RsspԴַ */ + ShortToChar(DestAddr,&pRsrStru->TmpDataBuff[DEST_ADDR_OUT_QUE_POS]); /* RsspĿַ */ + /* Ӧ */ + RsrMemCopy(&pCur->Data[RSSP_DATA_POS],&pRsrStru->TmpDataBuff[DATA_OUT_QUE_POS], AppDataLen); + + /* д */ + ret = QueueWrite(AppDataLen+4+2,pRsrStru->TmpDataBuff,RsToApp); + if(1 == ret) + { /* дɹ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"Out:\n"); + PrintFiles(RecordArray,RecordArraySize,"MsgLen"); + PrintFileU16Hex(RecordArray,RecordArraySize,AppDataLen); /* Ӧݳ */ + PrintFiles(RecordArray,RecordArraySize,"\tSrcAddr"); + PrintFileU16Hex(RecordArray,RecordArraySize,SrcAddr); /* Դַ */ + PrintFiles(RecordArray,RecordArraySize,"\tDestAddr"); + PrintFileU16Hex(RecordArray,RecordArraySize,DestAddr); /* Ŀַ */ + PrintFiles(RecordArray,RecordArraySize,"\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray,RecordArraySize,RSSP_MSG_OUT_TAG); /* һϢ֡ʼʶ */ + PrintRecArray2ByteB(RecordArray,RecordArraySize,AppDataLen); /* Ӧݳ */ + PrintRecArray2ByteB(RecordArray,RecordArraySize,SrcAddr); /* Դַ */ + PrintRecArray2ByteB(RecordArray,RecordArraySize,DestAddr); /* Ŀַ */ +#endif + } + else + { + /* дʧ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Queue Write Err.\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_ERROR_NULL|RSR_QUEUE_WRITE); + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_QUEUE_WRITE; + + } + } + + /* ɾǰĽڵ:pCurʵΪͷɾpCur󣬱ͷΪpNext */ + ret = DelTmpMsgLnkNode(pCur,NULL,&pCur, pRsrStru); + if(0 == ret ) + { + /* ¼ WarningʵʲӦûᷢĴ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Delete Msg Lnk Error."); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(RecordArray,RecordArraySize,RSR_WARN|RSR_RECEIVE|RSR_DEL_MSG_LNK_ERR|RSR_ERROR_NULL); /* ʱɾʧ */ + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_DEL_MSG_LNK_ERR; + + } + else + { + /* һڵ */ + } + } + + ret = 1; + return ret; +} + +/*********************************************************************** + * : RecvLnkStatusMng + * : ͨŽڵϢ״̬仯 + * : + * + * -------------------------------------------------------------- + * pBsdMsg const DataNode* IN Bsd + * pLnkNode Lnk_Info_Node_Stru INOUT RSSPӦõ + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 RecvLnkStatusMng(RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 1; + UINT8 index = 0; + UINT8 LnkNodeNum = 0; /* ڵ */ + UINT8 RecvStatus = 0; /* ״̬ */ + UINT32 NowCycleNum = 0, LastLocalRecTC; /* ϴյıں */ + UINT32 NoRecDataTc = 0; + INT32 AntiDelayTC = 0; + Lnk_Info_Node_Stru * LnkNodeArr = NULL; + + NowCycleNum = *pRsrStru->CycleNum; + + /* ȡȫͨŽڵ */ + GetLnkNodeArr(&LnkNodeArr,&LnkNodeNum,pRsrStru); + for(index = 0; index < LnkNodeNum; index++ ) + { + /* ״̬Ϊ ȴSSR */ + RecvStatus = LnkNodeArr[index].RsspLinInfo.RecvLinkStatus; + if((WaitSSR == RecvStatus) || (RecvData == RecvStatus)) + { + LastLocalRecTC = LnkNodeArr[index].RsspLinInfo.TimeStmp.LastLocalRecTC; + /* ûյж */ + if(NowCycleNum != LastLocalRecTC) + { + /* ûյ+1 */ + LnkNodeArr[index].RsspLinInfo.NoRecvDataCycleNum += 1; + NoRecDataTc = LnkNodeArr[index].RsspLinInfo.NoRecvDataCycleNum; + /* ȴSSR */ + if(WaitSSR == RecvStatus) + { + /* ȴSSRʱ */ + if(LnkNodeArr[index].RsspLinInfo.LocalNode.SSDelay < NoRecDataTc) + { + /* SSEʱ */ + if(LnkNodeArr[index].RsspLinInfo.TimeStmp.NumSendSse >= SEND_SSE_NUM) + { + /* ״̬ΪHALT SSE */ + LnkNodeArr[index].RsspLinInfo.RecvLinkStatus = Halt; + LnkNodeArr[index].RsspLinInfo.TimeStmp.NumSendSse = 0; + } + else /* SSEʱ SSE */ + { + LnkNodeArr[index].RsspLinInfo.RecvLinkStatus = SendSSE; + LnkNodeArr[index].RsspLinInfo.TimeStmp.NumSendSse++; + } + } + else + { + /* ʲô */ + } + } + else /* ״̬ */ + { + /* ͬ ʱ */ +#if 0 /* ζͬ 2010.1.14 */ + AntiDelayTC = CheckTimeStamp(NowCycleNum,LnkNodeArr[index].RsspLinInfo.TimeStmp.SsrTc,LnkNodeArr[index].RsspLinInfo.LocalNode.AntiDelayCount); +#endif + if((NoRecDataTc >LnkNodeArr[index].RsspLinInfo.LocalNode.DLost) + || (AntiDelayTC <0)) + { + /* ״̬趨ΪSSE */ + LnkNodeArr[index].RsspLinInfo.RecvLinkStatus = SendSSE; + } + else + { + /* ʲô */ + } + } + } + else /* жӦ */ + { + /* ʲô */ + } + } + else /* ȴSSR ״̬ */ + { + /* ʲô */ + } + } + + return ret; +} + +/*********************************************************************** + * : CheckAddr + * : 鱨ϢͨŽڵϢǷһ¡ + * : + * + * -------------------------------------------------------------- + * pDataNode DataNode* IN Ľڵ + * pLnkNode const Lnk_Info_Node_Stru INOUT RSSPӦõ + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 CheckAddr(const DataNode *pDataNode, const Lnk_Info_Node_Stru *pLnkNode) +{ + UINT8 ret = 0; /* ʼֵɹ */ + + /* wangpeipei 20111201 ADD */ + UINT16 DevName = 0; + DevName = pDataNode ->DevName; + /* 豸 == ͨŽڵϢ.·鱨.Դַ */ + if( (DevName == pLnkNode->DestDevName) && (pDataNode->LocalLogId == pLnkNode->RsspLinInfo.LocalLogId) + && (pDataNode->DestLogId == pLnkNode->RsspLinInfo.DestLogId)) + /* wangpeipei 20111201 ADD*/ + { + /* ͨ */ + ret = 1; + } + else + { + /* ʧܣֵ ret = 0 */ + } + return ret; +} + +/*********************************************************************** + * : UptLnkNodeInfoBySSE + * : SSEϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pDataNode const DataNode* IN Ľڵ + * pLnkNode Lnk_Info_Node_Stru INOUT RSSPӦõ + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 UptLnkNodeInfoBySSE(const DataNode *pDataNode, Lnk_Info_Node_Stru *pLnkNode, RSR_INFO_STRU *pRsrStru) +{ + const UINT8 *Msg = NULL; /* RSSPָ */ + RsspLinkInfoStru *pRsspLnkInfo = NULL; + + Msg = pDataNode->Data; + pRsspLnkInfo = &pLnkNode->RsspLinInfo; + + /* ·ͽڵ״̬Ϊ SSR */ + pRsspLnkInfo->SendLinkStatus = SendSSR; + + /* 趨յSSEʱ */ + pRsspLnkInfo->TimeStmp.RecvSseTCe = + LongFromCharLE(&Msg[RSSP_TC_POS]); + + /* SEQENQ_1ȡ 趨 */ + pRsspLnkInfo->TimeStmp.SeqEng[0] = LongFromCharLE(&Msg[RSSP_SSE_ENQ_1_POS]); + + /* SEQENQ_2ȡ 趨 */ + pRsspLnkInfo->TimeStmp.SeqEng[1] = LongFromCharLE(&Msg[RSSP_SSE_ENQ_2_POS]); + + return (UINT8)1; +} + +/*********************************************************************** + * : UptLnkNodeInfoBySSR + * : SSRϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pDataNode const DataNode* IN Ľڵ + * pLnkNode Lnk_Info_Node_Stru INOUT RSSPӦõ + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 UptLnkNodeInfoBySSR(const DataNode *pDataNode, Lnk_Info_Node_Stru *pLnkNode, RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 1; /* ʼֵ */ + UINT32 SseTCe = 0; /* SSR SSETC */ + UINT32 SeqIni[2] = {0}; /* SSRĵSEQ_INI ֵ */ + const UINT8 *Msg = NULL; /* RSSPָ */ + RsspLinkInfoStru *pRsspLnkInfo = NULL; /* ·鱨 */ + TimeStampStru *pTmStmp = NULL; /* ʱṹָ */ + + Msg = pDataNode->Data; + pRsspLnkInfo = &pLnkNode->RsspLinInfo; + pTmStmp = &pRsspLnkInfo->TimeStmp; + + /* ͨ·Ľ״̬Ϊ ȴSSR */ + if(WaitSSR == pRsspLnkInfo->RecvLinkStatus ) + { + SseTCe = LongFromCharLE(&Msg[RSSP_SSR_TCENQ_POS]); /* SSRĵ SSE */ + + /* жǷΪӦ SSR */ + if( pTmStmp->SseTC == SseTCe) + { + /* ǶӦSSRģ·鱨Ϣ */ + + pTmStmp->SsrTc = *pRsrStru->CycleNum; /* ϴͬںŸ ǰں */ + + SeqIni[0] = LongFromCharLE(&Msg[RSSP_SSR_INI_1_POS]); /* źŵ SEQINI_1 ֵ */ + SeqIni[1] = LongFromCharLE(&Msg[RSSP_SSR_INI_2_POS]); /* źŵ SEQINI_2 ֵ */ + + /* ʼSINITr AND [SIDr ^ Tr(n)]浽pTmStmp->NowSINIT_ADD_SID_XOR_Tn */ + ret = CalcFirstSinitAndSidXorTn(pRsspLnkInfo->LocalNode.PREC_FIRSTSINIT,SeqIni, + pTmStmp->SseTn,pTmStmp->NowSINIT_ADD_SID_XOR_Tn); + + pTmStmp->NumSendSse = 0; /* SSE 趨Ϊ 0 */ + pTmStmp->LastLocalRecTC = *pRsrStru->CycleNum; /* ϴյĵıʱ */ + pTmStmp->LastRecvTCr = pTmStmp->NowRecvTCr; /* ϴνܱʱΪ ǰյʱ Ԥ */ + pTmStmp->NowRecvTCr = LongFromCharLE(&Msg[RSSP_TC_POS]); /* ǰյʱ = ļ */ + + pRsspLnkInfo->RecvLinkStatus = RecvData; /* ·״̬ = */ + pRsspLnkInfo->NoRecvDataCycleNum = 0; /* */ + } + else /* ǶӦSSR */ + { + /* 󷵻 */ + ret = 0; + } + } + else + { + /* 󷵻 0 */ + ret = 0; + } + + + return ret; +} +/* wangpeiepi 20111201 del*/ +/*********************************************************************** + * : CheckBsdAddr + * : BSDĵĵַϢǷһ¡ + * : + * + * -------------------------------------------------------------- + * pDataNode const DataNode* IN Ľڵ + * pLnkNode Lnk_Info_Node_Stru INOUT RSSPӦõ + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 CheckBsdAddr(const DataNode *pDataNode, Lnk_Info_Node_Stru *pLnkNode) +{ + UINT8 ret = 1; /* ʼ */ + UINT16 SrcAddr = 0; /* Դַ */ + INT16 DestBsdAddr = 0; /* Ŀַ(Bsdַ) */ + + SrcAddr = ShortFromCharLE(&pDataNode->Data[RSSP_SRC_ADD_POS]); + DestBsdAddr = (INT16)ShortFromCharLE(&pDataNode->Data[RSSP_DEST_ADD_POS]); + + /* + * Ŀַ == ͨŽڵϢ.·鱨.BSDַ(BSDĿַΪBSDַ) + * && Դַ == ͨŽڵϢ.·鱨.Ŀַ(SSE) + * && ͨŽڵϢ.Է̬Id == ͷ̬Id + * && ͨŽڵϢ.̬Id == շ̬Id + */ + if( (SrcAddr == pLnkNode->RsspLinInfo.RsspDestAddr) + && (DestBsdAddr == pLnkNode->RsspLinInfo.DestBsdAdd) + && (pDataNode->DestLogId == pLnkNode->RsspLinInfo.DestLogId) + && (pDataNode->LocalLogId == pLnkNode->RsspLinInfo.LocalLogId) ) + { + /* ͨ */ + } + else + { + /* ʧܣֵ ret = 0 */ + ret = 0; + } + + return ret; +} +/* wangpeiepi 20111201 del */ +/*********************************************************************** + * : CheckBsdMsg + * : ֤BSDĵȷԡ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const DataNode* IN Bsd + * pLnkNode Lnk_Info_Node_Stru INOUT RSSPӦõ + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 CheckBsdMsg(const UINT8 *pBsdMsg,Lnk_Info_Node_Stru *pLnkNode, RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 1; /* ʼΪ */ + INT32 DelayTCr = 0; /* */ + INT32 Tout = 0; /* ϴյĵʱ */ + UINT32 TCr = 0; /* ʱ */ + UINT32 SidXorTn[2] = {0}; /* SID XOR TN BSDļ */ + TimeStampStru *pTmStmp = &pLnkNode->RsspLinInfo.TimeStmp; /* ʱṹ */ + const NodeParamInfoStru *pNodeParam = &pLnkNode->RsspLinInfo.LocalNode; /* ڵϢṹ */ + UINT8 *RecordArray = pRsrStru->RecordArray; + UINT16 RecordArraySize = pRsrStru->RecordArraySize; + + /* ͨŽڵ״̬Ϊ ״̬ */ + if( RecvData == pLnkNode->RsspLinInfo.RecvLinkStatus) + { + /* ʱ */ + TCr = LongFromCharLE(&pBsdMsg[RSSP_TC_POS]); + /* + * ϴαĵʱһ(ͬһͬʱܵBSDĺSSR)ñ + * 鶪Ƿʱ + */ + if( TCr != pTmStmp->NowRecvTCr) + { + DelayTCr = CheckTimeStamp(TCr,pTmStmp->NowRecvTCr,pNodeParam->MaxLost); + } + else + { + return 0; + } + if(DelayTCr >= 0) + { + /* ijʱ */ + if(pTmStmp->LastLocalRecTC != *pRsrStru->CycleNum) + { + Tout = CheckTimeStamp(*pRsrStru->CycleNum, + pTmStmp->LastLocalRecTC,pNodeParam->Tout); + } + else + { + /* ˵Ѿյһ֡ݣҪʱ */ + Tout = 0; + } + if(Tout >= 0) /* Ϸʱյ */ + { + /* BSDȡSID XOR TN CRCM[chan] ^ CRC[chan] ^ SYS_CHK_WD[chan] */ + ret = GetSidXorTn(pBsdMsg,SidXorTn); + /* CRCMЧ */ + ret = CheckCRCM(SidXorTn,pTmStmp->NowSINIT_ADD_SID_XOR_Tn , + DelayTCr,pNodeParam->TSD_POST_RXDADA_K); + if(1 == ret) /* ɹ ӦϢ */ + { + /* ʱṹ : pTmStmpStruǿգֵ϶Ϊ1 */ + ret = UpdtTmStmpStru(SidXorTn,TCr,DelayTCr,pNodeParam->PREC_SINIT_K,pTmStmp); + ret = 1; /* */ + } + else + { +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:CRCM Error.\n"); +#endif + /* ʧ 󷵻 */ + ret = 0; + } + } + else /* ʱ */ + { +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Time Out.\n"); +#endif + ret = 0; + } + } + else + { +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"DelayTCr > MaxLost\n"); +#endif + /* Ķ طSSEͬ */ + pLnkNode->RsspLinInfo.RecvLinkStatus = SendSSE; + ret = 0; + } + } + else if( Halt == pLnkNode->RsspLinInfo.RecvLinkStatus) + { + pLnkNode->RsspLinInfo.RecvLinkStatus = SendSSE; /* ״̬ΪSSE */ + ret = 0; + } + else /* ״̬ */ + { +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:RecvStatus() not RecvData or Halt.Discard Bsd Msg."); + PrintFileHex(RecordArray,RecordArraySize,&pLnkNode->RsspLinInfo.RecvLinkStatus,1); + PrintFiles(RecordArray,RecordArraySize,"\n"); +#endif + ret =0; + } + + return ret; +} + +/* רú */ +#ifdef RSR_RP_ONLY +static UINT8 WriteDataToAppQ(QueueStruct *SigQue,QueueStruct* AppQue) +{ + UINT8 ret = 0; + UINT8 ContinueFlg = 0; /* ѭʶλ0 1һѭ */ + UINT16 MsgLen = 0; /* ݳ */ + UINT8 SenderType = 0,SenderId =0,SenderLogId = 0; /* ͷͣId ̬Id */ + UINT16 SrcAddr = 0,SseAddr =0; /* Դַ,SSEַ*/ + INT16 BsdAddr =0; + UINT16 DestDevName = 0; /* Էʶ */ + UINT16 LocalName = 0; /* ʶ */ + UINT8 LocalLogId =0; /* ̬Id */ + const UINT16 MaxLen = MAX_RSSP_MSG + 4; /* 󳤶 */ + const UINT8 SENDER_TYPE_QUE_POS = 2; /* źŲб淢ͷ͵λ */ + const UINT8 SENDER_ID_QUE_POS = SENDER_TYPE_QUE_POS+1; /* źŲб淢ͷIdλ */ + const UINT8 SENDER_LOG_ID_QUE_POS = SENDER_ID_QUE_POS+1; /* źŲб淢ͷ̬Idλ */ + const UINT8 RECV_LOG_ID_QUE_POS = SENDER_LOG_ID_QUE_POS+1; /* źŲб汾̬Idλ */ + const UINT8 RSSP_DATA_QUE_POS = RECV_LOG_ID_QUE_POS+1; /* źŲбӦλ */ + const UINT8 LEN_OUT_QUE_POS = 0; /* ݳȱλ */ + const UINT8 SRC_ADDR_OUT_QUE_POS = LEN_OUT_QUE_POS+2; /* жԷԴַλ */ + const UINT8 DEST_ADDR_OUT_QUE_POS = SRC_ADDR_OUT_QUE_POS+2; /* жԷBSDַλ */ + const UINT8 DATA_OUT_QUE_POS = DEST_ADDR_OUT_QUE_POS+2; /* ݱλ */ + UINT8 TmpDataBuffArr[MAX_RSSP_MSG+128] = {0}; /* Ӧݻ */ + UINT8 OutDataBuff[MAX_RSSP_MSG+128] = {0}; /* Ӧݻ */ + Lnk_Info_Node_Stru *pLnkNode = NULL; /* ͨŽڵָ */ + + TypeId2DevName(gpRsrInfoStru->LocalType,gpRsrInfoStru->LocalID,&LocalName); + /* ȡк д뵽 */ + while(QueueStatus(SigQue) >= 2) + { + ContinueFlg =0; + QueueScan(2,(QueueElement *)TmpDataBuffArr,SigQue); /* ɨǰڵij */ + MsgLen = ShortFromChar(TmpDataBuffArr); + + /* нڵݳ Ԥȵı ñ */ + if( MsgLen <= MaxLen) + { + /* ȡǰ нڵ */ + ret = QueueRead(MsgLen+2,(QueueElement *)TmpDataBuffArr,SigQue); + if(0 == ret) + { + /* ʧܣôǰʣµݴС С MsgLen ݣѭ */ + break; + } + else + { + /* ʲô */ + } + + SenderType = TmpDataBuffArr[SENDER_TYPE_QUE_POS]; /* ȡ͵豸 */ + SenderId = TmpDataBuffArr[SENDER_ID_QUE_POS]; /* ȡ͵豸ID */ + SenderLogId = TmpDataBuffArr[SENDER_LOG_ID_QUE_POS]; /* ȡ͵Ķ̬ID */ + LocalLogId = TmpDataBuffArr[SENDER_LOG_ID_QUE_POS]; /* ̬Id */ + + TypeId2DevName(SenderType,SenderId,&DestDevName); /* Էʶȡ */ + /* յϢȡ RsspԴַ BSDַԼ SSE SSRַ */ + if(RSR_TYPE_CC == gpRsrInfoStru->LocalType) + { + /* + * Ϊƶ ԷΪCI + * ̬Id ɫ = 0ͷ̶壩 + */ + ret = dsuVOBCvsCIOutInfo(LocalLogId,0,&SrcAddr,&BsdAddr,&SseAddr); + if(0 == ret) + { + /* ¼ */ + ContinueFlg = 1; /* һѭ */ + } + else + { + /* ʲô */ + } + } + else + { + /* Ϊ̶ */ + /* ж϶ԷDz CC ȷͨŹϵ */ + if(RSR_TYPE_CC == SenderType ) + { + /* + * ԷΪCC ƶ壬 ΪCI ݶԷ̬IDȡӦRSSPַ + * Է̬ID ɫ = 1 ͷΪƶ壩 + */ + ret = dsuVOBCvsCIOutInfo(SenderLogId,1,&SrcAddr,&BsdAddr,&SseAddr); + if(0 == ret) + { + /* ݣ¼ */ + ContinueFlg = 1; /* һѭ */ + } + else + { + /* ȡöӦͨŽڵ ȻõǰԷʶ Ǹýڵ */ + pLnkNode = SearchLnkNode(0,SenderLogId); + if( pLnkNode == NULL) + { + /* + *ѯͨŽڵ㣬˵źŲöԷ̬Id ȷ + *ݣһ֡ + */ + ContinueFlg = 1; /* һѭ */ + } + else + { + /* ǽڵıʶ */ + TypeId2DevName(SenderType,SenderId,&pLnkNode->DestDevName); + } + } + } + else + { + /* + * ԷΪ̶ Ϊ̶ ˫ʶȡöӦĵַ + * Էʶ ʶ + */ + ret = dsuZCvsCIOutInfo(DestDevName,LocalName,&SrcAddr,&BsdAddr,&SseAddr); + if(0 == ret) + { + /* ݣ ¼ */ + ContinueFlg = 1; /* һѭ */ + } + else + { + /* ʲô */ + } + } + } + + if(ContinueFlg == 0) /* */ + { + ShortToChar( MsgLen, &OutDataBuff[LEN_OUT_QUE_POS]); /* ݳ:Ӧݳ MsgLen - 4 + 4 */ + ShortToChar( SrcAddr, &OutDataBuff[SRC_ADDR_OUT_QUE_POS]); /* RSSPԴַ */ + ShortToChar( BsdAddr,&OutDataBuff[DEST_ADDR_OUT_QUE_POS]); /* BSDַ */ + /* TmpDataBuffArr+ RSSP_DATA_QUE_POS ʼ MsgLen-4Ӧ OutDataBuff[DATA_OUT_QUE_POS]ʼڴ */ + RsrMemCopy(&TmpDataBuffArr[RSSP_DATA_QUE_POS],&OutDataBuff[DATA_OUT_QUE_POS],(UINT16)(MsgLen-4)); + + /* ɵĶнڵд Ķ */ + ret = QueueWrite(MsgLen+2,(QueueElement *)OutDataBuff,AppQue); + if(0 == ret) + { + /* ¼ гȲ */ + } + else + { + /* ʲô */ + } + } + } + else /* if MaxLen <= OutSize */ + { + QueueElementDiscard(MsgLen,SigQue); /* */ + ret = 0; /* һڵ */ + } + } + + ret = 1; + return ret; +} +#endif + /*-------------------------------------------------------------------- + * RSSPģڲʹúʵ End + *--------------------------------------------------------------------*/ + + +#ifdef __cplusplus +} +#endif + + + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspStruct.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspStruct.h new file mode 100644 index 0000000..fe7f373 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspStruct.h @@ -0,0 +1,166 @@ +/******************************************************** +* +* ļ RsspStruct.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* RsspʹõĽṹ嶨 +* ʹע⣺ +* +* ޸ļ¼ +* 2011.12.06 ޸ͨŽڵϢṹ塣ɾ̬IDRsspԴַRsspĿĵַBsdַ +* +********************************************************/ + +#ifndef _RSSP_STRUCT_H_ +#define _RSSP_STRUCT_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "CommonStack.h" +#include "RsspCommon.h" +#include "RpPlatform.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*-------------------------------------------------------------------- + * RSSPڲʹýṹ Start + *--------------------------------------------------------------------*/ + +/* ʱڵ */ +typedef struct DataNodeStru +{ + UINT16 DevName; /* 豸ʶ */ + UINT32 TCr; /* к */ + UINT8 DestLogId; /* Է̬ID */ + UINT8 LocalLogId; /* ̬ID */ + UINT16 DataLen; /* ij */ + UINT8 *Data; /* */ + struct DataNodeStru *pNextNode; /* һڵ */ + } DataNode; + +/* ʱĶջṹ */ +typedef struct +{ + CommonStack stack; /* ջ */ + DataNode *pFirstNode; /* ջռ */ +} RsspStackElement; + + +/* ·״̬ */ +typedef enum +{ + Halt = 0x00, /* ж ·n֮sse֮״̬nʱΪ4 ߳ʼ״̬IDLE */ + SendSSE = 0x01, /* SSE ܽڵ */ + WaitSSR = 0x02, /* ȴSSR ܽڵ */ + RecvData = 0x04, /* ܽڵ */ + SendSSR = 0x20, /* SSR ͽڵ */ + SendData = 0x40 /* ͽڵ */ +} ENUM_RSSP_LINK_STATUS; + +/* ڵ״̬ö */ +typedef enum +{ + Replace = 0x01, /* ɸ״̬ ýڵֹͣݻdzʼ״̬ */ + DisbaledReplace = 0x02 /* ɸ״̬ýڵ㻹ڼ */ +} ENUM_RSSP_NODE_STATUS; + +/* 豸ڵϢṹ */ +typedef struct +{ + UINT32 SIDe[2]; /* SID */ + UINT32 SIDr[2]; /* SID */ + UINT32 SINIT[2]; /* SINIT */ + UINT32 DATAVER[2]; /* DATAVER */ + UINT8 NumDataVer[2]; /* Data 汾 */ + UINT8 DLost; /* */ + UINT8 SSDelay; /* 涨ʱ䣨SSDelay */ + UINT8 AntiDelayCount; /* ͬ */ + UINT8 Tout; /* BSDijʱ */ + UINT8 MaxLost; /* ʧ */ + UINT32 PREC_SINIT_K[2][5]; /* ߲PREC_SINIT? */ + UINT32 PREC_FIRSTSINIT[2]; /* ߲PREC_FIRSTSINIT */ + UINT32 TSD_POST_RXDADA_K[2][5]; /* ߲ BSD̶ֵ */ +} NodeParamInfoStru; + +/* RSSP·Ϣṹ */ +typedef struct +{ + UINT8 LocalLogId; /* ̬ID */ + UINT8 DestLogId; /* Է̬ID */ + UINT8 RecvLinkStatus; /* ·״̬ */ + UINT8 SendLinkStatus; /* ·״̬ */ + UINT8 NoRecvDataCycleNum; /* */ + UINT8 NoAppDataCycleNum; /* ޷Ӧ */ + INT16 DestBsdAdd; /* BSDַ */ + UINT16 RsspSrcAddr; /* RSSPԴַ */ + UINT16 RsspDestAddr; /* RSSPĿĵַ */ + TimeStampStru TimeStmp; /* ʱϢ */ + NodeParamInfoStru LocalNode; /* ܽڵ */ +} RsspLinkInfoStru; + +/* ͨŽڵṹ */ +typedef struct +{ + UINT16 DestDevName; /* Է豸ʶ */ + + /* wangpeipei 20111201 Add start*/ + INT16 DestBsdAdd; /* BSDַ */ + UINT16 RsspSrcAddr; /* RSSPԴַ */ + UINT16 RsspDestAddr; /* RSSPĿĵַ */ + /* wangpeipei 20111201 Add end*/ + + UINT8 NodeStatus; /* ڵ㸲״̬ */ + RsspLinkInfoStru RsspLinInfo; /* RSSP·Ϣ */ +} Lnk_Info_Node_Stru; + + + +/*-------------------------------------------------------------------- + * RSSPڲʹýṹ End + *--------------------------------------------------------------------*/ +typedef struct +{ + UINT8 LocalID; /* 豸IDӦðĵڳʼʱд */ + UINT8 LocalType; /* 豸typeӦðĵڳʼʱд */ + UINT32 *CycleNum; /* ںţӦðĵÿڿʼʱд */ + UINT8 MaxNumLink; /* RSRͬʱͨŵӦðĵڳʼʱд */ + UINT8 MaxNumPerCycle; /* RSRһÿЧݣӦðĵڳʼʱд */ + UINT16 InputSize; /* RSRһ֡ӦݳȣӦðĵڳʼʱд */ + UINT16 OutputSize; /* RSR㷢һ֡ӦݳȣӦðĵڳʼʱд */ + UINT8 *RecordArray; /* RSR¼ */ + UINT16 RecordArraySize; /* RSR¼С */ + UINT8 *AppArray; /* ģij1ʾ */ + UINT16 AppArraySize; /* RSRģij鳤 */ + UINT8 *VarArray; /* RSRģij2ʾм */ + UINT16 VarArraySize; /* ģij鳤 */ + QueueStruct DataToApp; /* RSRЭӦõݶ */ + UINT32 DataToAppSize; /* ЭӦõݶг */ + QueueStruct OutputDataQueue; /* RSRӦøЭݶ */ + UINT32 OutputDataQueueSize; /* ӦøЭݶг */ + QueueStruct OutnetQueueA; /* RSRնA(->) */ + QueueStruct OutnetQueueB; /* RSRնB(->) */ + UINT32 OutnetQueueSize; /* նгȣЭʼʱд */ + RP_INFO_STRU RpInfoStru; /* ͳһṹ */ + UINT16 RsspVarArraySize; /* Rsspм鳤 */ + UINT8 *RsspVarArray; /* Rsspм鳤 δʹ */ + QueueStruct QueSig2Rs; /* źŲ㵽ʱ */ + + /* ڵʱӵı */ + UINT8 *TmpDataBuff; + RsspStackElement* StackOfDataLink; + Lnk_Info_Node_Stru* LnkNodeArr; /* ͨŽڵ */ + UINT8 LnkNodeNum; /* ͨŽڵ鳤 */ +} RSR_INFO_STRU; + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspTmpMsgLnkCommon.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspTmpMsgLnkCommon.c new file mode 100644 index 0000000..9b02d55 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspTmpMsgLnkCommon.c @@ -0,0 +1,463 @@ +/******************************************************** +* +* ļ RsspTmpMsgLnkCommon.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* ʱ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2009.12.15 ¥ΰ ԪBugӦ +* +********************************************************/ +#include +#include "CommonMemory.h" +#include "RsrCommon.h" +#include "RsspTmpMsgLnkCommon.h" +#include "RsrRecordDelare.h" +#include "CommonRecord.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* ʱջռ */ +/*static RsspStackElement* StackOfDataLink = NULL;*/ + +/*-------------------------------------------------------------------- + * RSSPڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : GetSortedMsgFromQue + * : ԺݽRSRİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pMsgQue QueueStruct* IN źŲ㵽Rssp + * MaxLen UINT16 IN + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : DataNode* ʱͷ + ***********************************************************************/ +DataNode* GetSortedMsgFromQue(QueueStruct *SigToRs,UINT16 MaxLen,UINT8 *RecordArray, UINT16 RecordSize,RSR_INFO_STRU *pRsrStru) +{ + UINT8 ret = 0; + UINT16 MsgLen = 0; /* Ϣ */ + DataNode *pHead = NULL; /* ͷ */ + DataNode *pCur = NULL; /* ǰɵĽڵ */ + const UINT8 QUE_FIXED_LEN = 4; /* нڵ̶ֳ */ + const UINT8 SENDER_TYPE_QUE_POS = 2; /* źŲб淢ͷ͵λ */ + const UINT8 SENDER_ID_QUE_POS = SENDER_TYPE_QUE_POS+1; /* źŲб淢ͷIdλ */ + const UINT8 SENDER_LOG_ID_QUE_POS = SENDER_ID_QUE_POS+1; /* źŲб淢ͷ̬Idλ */ + const UINT8 RECV_LOG_ID_QUE_POS = SENDER_LOG_ID_QUE_POS+1; /* źŲб汾̬Idλ */ + const UINT8 RSSP_DATA_QUE_POS = RECV_LOG_ID_QUE_POS+1; /* źŲбӦλ */ + + /* г>2 */ + while(2 <= QueueStatus(SigToRs)) + { + /* źŲRSSPнڵʽ + * ---------------------------------------------------------------------- + * | ͷType | ͷID | ͷ̬Id | ̬Id | RSSPϢ | + * 2ֽ| 1ֽ | 1 ֽ | 1 ֽ | 1ֽ | n | + * ----------------------------------------------------------------------- + */ + QueueScan(2,pRsrStru->TmpDataBuff,SigToRs); /* ɨֽڵij */ + MsgLen = ShortFromChar(pRsrStru->TmpDataBuff); + if((MsgLen+2) <= MaxLen) + { + ret = QueueRead(MsgLen+2,(QueueElement *)pRsrStru->TmpDataBuff,SigToRs); + if( ret == 0) + { + /* ʧʣµݴССMsgLen+2¼ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:Write Que Err\n"); /* ʧ */ +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + PrintRecArray2ByteB(RecordArray,RecordSize,RSR_WARN|RSR_RECEIVE|RSR_ERROR_NULL|RSR_QUEUE_READ); /* ʧ */ + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_QUEUE_READ; + + break; + } + + /* RSSP ʱĽڵ */ + ret = IsRsspMsg((UINT16)(MsgLen - QUE_FIXED_LEN), &pRsrStru->TmpDataBuff[QUE_FIXED_LEN+2]); + /* ǷΪRSSPģȻжϷǷϷ */ + if( (1== ret) && + ((RSR_TYPE_ZC == pRsrStru->TmpDataBuff[SENDER_TYPE_QUE_POS]) + || (RSR_TYPE_CC == pRsrStru->TmpDataBuff[SENDER_TYPE_QUE_POS]) + || (RSR_TYPE_CI == pRsrStru->TmpDataBuff[SENDER_TYPE_QUE_POS]))) + { + /* ӶջﵯһʱĽڵ㣬ַ浽pCur */ + ret = StackPop(&pRsrStru->StackOfDataLink->stack,(STACK_DATA_TYPE *)&pCur); + if(1 == ret) + { + /* ȡɹ */ + + /* Էʶ趨 TmpDataBuff[2..3] */ + TypeId2DevName(pRsrStru->TmpDataBuff[SENDER_TYPE_QUE_POS], + pRsrStru->TmpDataBuff[SENDER_ID_QUE_POS],&pCur->DevName); + + /* ͷ̬ID 趨 TmpDataBuff[4] */ + pCur->DestLogId = pRsrStru->TmpDataBuff[SENDER_LOG_ID_QUE_POS]; + + /* շ̬ID TmpDataBuff[5]*/ + pCur->LocalLogId = pRsrStru->TmpDataBuff[RECV_LOG_ID_QUE_POS]; + + /* RSSPϢ趨 ȥ2λCRC*/ + pCur->DataLen = MsgLen-QUE_FIXED_LEN-2; + RsrMemCopy(&pRsrStru->TmpDataBuff[RSSP_DATA_QUE_POS],pCur->Data,pCur->DataLen); + + /* ļ趨 */ + /* Bug 874 Ӧ */ + pCur->TCr = LongFromCharLE(&pCur->Data[RSSP_TC_POS]); + + /* ʱ */ + pHead = InsTmpMsgLnk(pHead,pCur); +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"IN:\n"); + PrintFiles(RecordArray,RecordSize,"DestType:"); /* ֡ͷ */ + PrintFileHex(RecordArray,RecordSize,&pRsrStru->TmpDataBuff[SENDER_TYPE_QUE_POS],1); + PrintFiles(RecordArray,RecordSize,"\tDestId:"); /* ֡ͷID */ + PrintFileHex(RecordArray,RecordSize,&pRsrStru->TmpDataBuff[SENDER_ID_QUE_POS],1); + PrintFiles(RecordArray,RecordSize,"\tDestLogId:"); /* ֡ͷ̬ID */ + PrintFileHex(RecordArray,RecordSize,&pRsrStru->TmpDataBuff[SENDER_LOG_ID_QUE_POS],1); + PrintFiles(RecordArray,RecordSize,"\tLocLogId:"); /* ܷ̬֡ID */ + PrintFileHex(RecordArray,RecordSize,&pRsrStru->TmpDataBuff[RECV_LOG_ID_QUE_POS],1); + PrintFiles(RecordArray,RecordSize,"\tMsgType:"); /* ֡Ϣ */ + PrintFileHex(RecordArray,RecordSize,&pCur->Data[RSSP_MSG_TYPE_POS],1); + PrintFiles(RecordArray,RecordSize,"\tSrcAddr:"); /* ֡ϢԴַ */ + PrintFileU16Hex(RecordArray,RecordSize,ShortFromCharLE(&pCur->Data[RSSP_SRC_ADD_POS])); + PrintFiles(RecordArray,RecordSize,"\tDestAddr:"); /* ֡ϢĿĵַ */ + PrintFileU16Hex(RecordArray,RecordSize,ShortFromCharLE(&pCur->Data[RSSP_DEST_ADD_POS])); + PrintFiles(RecordArray,RecordSize,"\tTC:"); /* ֡Ϣ */ + PrintFileU32Hex(RecordArray,RecordSize,pCur->TCr); + PrintFiles(RecordArray,RecordSize,"\n"); +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray,RecordSize,RSSP_MSG_IN_TAG); /* һϢ֡ʼʶ */ + PrintRecArrayByte(RecordArray,RecordSize,pRsrStru->TmpDataBuff[SENDER_TYPE_QUE_POS]); /* ֡ͷ */ + PrintRecArrayByte(RecordArray,RecordSize,pRsrStru->TmpDataBuff[SENDER_ID_QUE_POS]); /* ֡ͷID */ + PrintRecArrayByte(RecordArray,RecordSize,pRsrStru->TmpDataBuff[SENDER_LOG_ID_QUE_POS]); /* ֡ͷ̬ID */ + PrintRecArrayByte(RecordArray,RecordSize,pRsrStru->TmpDataBuff[RECV_LOG_ID_QUE_POS]); /* ܷ̬֡ID */ + PrintRecArrayByte(RecordArray,RecordSize,pCur->Data[RSSP_MSG_TYPE_POS]); /* ֡Ϣ */ + PrintRecArray2ByteB(RecordArray,RecordSize,ShortFromCharLE(&pCur->Data[RSSP_SRC_ADD_POS])); /* ֡ϢԴַ */ + PrintRecArray2ByteB(RecordArray,RecordSize,ShortFromCharLE(&pCur->Data[RSSP_DEST_ADD_POS])); /* ֡ϢĿĵַ */ + PrintRecArray4ByteB(RecordArray,RecordSize,pCur->TCr); /* ֡Ϣ */ +#endif + } + else + { + /* ȡʧܣջнڵ㲻 */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:Link POP Err."); /* ջ */ +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + PrintRecArray2ByteB(RecordArray,RecordSize,RSR_WARN|RSR_RECEIVE|RSR_ERROR_NULL|RSR_LNK_POP); /* ջ */ + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_LNK_POP; + + break; + } + } + else /* RSSPϢ */ + { + /* ¼ϢͲ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:Not Rssp MSg.\n"); /* RSSPϢ */ +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + PrintRecArray2ByteB(RecordArray,RecordSize,RSR_WARN|RSR_RECEIVE|RSR_MSG_TYPE_ILLEGAL|RSR_ERROR_NULL); /* RSSPϢ */ + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_MSG_TYPE_ILLEGAL; + + } + } + else + { + /* 󳤶ȳ */ + QueueElementDiscard(MsgLen,SigToRs); + /* һ֡ */ +#ifdef RSR_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordSize,"W:Queue Err.\n"); /* вϷ */ +#endif +#ifdef RSR_RECORD_SIMPLIFY_BIN /* */ + PrintRecArray2ByteB(RecordArray,RecordSize,RSR_WARN|RSR_RECEIVE|RSR_ERROR_NULL|RSR_QUEUE_INTEGRITY); /* вϷ */ + +#endif + gRsrErrorInfo |= RSR_WARN_RECEIVE_RSR_QUEUE_INTEGRITY; + + } + } + + return pHead; +} + +/*********************************************************************** + * : InsTmpMsgLnk + * : һڵ㡣ʶк˳ + * : + * + * -------------------------------------------------------------- + * pHead DataNode* IN ͷ + * pDataNode DataNode* IN Ľڵ + * + * ֵ : DataNode* ʱͷ + ***********************************************************************/ +DataNode* InsTmpMsgLnk(DataNode *pHead,DataNode *pNode) +{ + DataNode *pLast = NULL,*pCur = NULL; + + pCur = pHead; + + /* ڵָΪգֱӷ ͷ */ /* Bug 847 Ӧ */ + if(NULL == pNode) + { + return pHead; + } + + while(pCur != NULL) + { + /* ǰڵıʶڲڵ ߱ʶ ڲ ôѭ */ + if((pCur->DevName > pNode->DevName) || + ((pCur->DevName == pNode->DevName) && (pCur->TCr >=pNode->TCr))) + { + break; + } + else + { + /* һڵ */ + pLast = pCur; + pCur = pCur->pNextNode; + + } + } + + /* ڵ */ + if( NULL == pLast) + { + /* ͷ */ + pNode->pNextNode = pCur; + pHead = pNode; + } + else + { + /* 뵽pLast */ + pLast->pNextNode = pNode; + pNode->pNextNode = pCur; + } + + return pHead; /* رͷ */ +} + +/*********************************************************************** + * : DelTmpMsgLnkNode + * : ɾӦĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * pCur DataNode* IN ɾڵ + * pLast DataNode* IN ɾǰڵ + * pHead DataNode** INOUT ͷָָ룬Ϊصıͷָ + * + * ֵ : UINT8 1: 0: + ***********************************************************************/ +UINT8 DelTmpMsgLnkNode(DataNode *pCur,DataNode *pLast,DataNode **pHead, RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 1; + /* ǰڵ㲻Ϊͷ */ + if( pCur != *pHead) + { + pLast->pNextNode = pCur->pNextNode; + } + else + { + /* ǰڵΪͷ */ + *pHead = pCur->pNextNode; + } + + /* pCurָڵ */ + pCur->DataLen = 0; + pCur->DestLogId = 0; + pCur->DevName = 0; + pCur->LocalLogId = 0; + pCur->TCr = 0; + pCur->pNextNode =0; + + /* ѹжջ */ + if(0 == StackPush(&pRsrStruct->StackOfDataLink->stack,(STACK_DATA_TYPE)pCur)) + { + /* ѹջʧ */ + ret = 0; + } + else + { + ret = 1; + } + + return ret; +} + +/*********************************************************************** + * : InitMsgNodeStack + * : ʼʱĶջռ䡣 + * : + * + * -------------------------------------------------------------- + * NodeNum UINT16 IN + * MaxData UINT16 IN С + * + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ +UINT8 InitMsgNodeStack(UINT16 NodeNum,UINT16 MaxData, RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 0; + UINT16 index=0; + UINT16 NodeLen = 0; + DataNode* pTmp = NULL; + + NodeLen = sizeof(DataNode); + + /* ʱĶջṹռ */ + pRsrStruct->StackOfDataLink = (RsspStackElement*)malloc(sizeof(RsspStackElement)); + if(NULL == pRsrStruct->StackOfDataLink) + { + return ret; + } + else + { + CommonMemSet(pRsrStruct->StackOfDataLink,sizeof(RsspStackElement),0,sizeof(RsspStackElement)); + } + + /* ջʼ */ + ret = StackInitial(&pRsrStruct->StackOfDataLink->stack,NodeNum); + if( 0 == ret) + { + /* ʧ ͷѷռ */ + DestoryMsgNodeStack(pRsrStruct); + + /* ջʼʧ */ + return ret; + } + + /* Ŀռ */ + pRsrStruct->StackOfDataLink->pFirstNode = (DataNode *)malloc(NodeNum * NodeLen); + if(NULL == pRsrStruct->StackOfDataLink->pFirstNode) + { + /* ʧ ͷѷռ */ + DestoryMsgNodeStack(pRsrStruct); + + /* ڴʧ */ + ret = 0; + return ret; + } + else + { + CommonMemSet(pRsrStruct->StackOfDataLink->pFirstNode,NodeNum * NodeLen,0,NodeNum * NodeLen); + } + + /* ʱĽڵѹջ */ + for(index = 0; indexStackOfDataLink->pFirstNode[index]; + pTmp->Data = (UINT8 *)malloc(MaxData); /* ʵʱı */ + if(NULL == pTmp->Data) + { + /* ʧ ͷѷռ */ + DestoryMsgNodeStack(pRsrStruct); + ret = 0; + return ret; + } + else + { + /* ʲô */ + CommonMemSet(pTmp->Data,sizeof(UINT8)*MaxData,0,sizeof(UINT8)*MaxData); + } + + /* ѹջ */ + ret = StackPush(&pRsrStruct->StackOfDataLink->stack,(STACK_DATA_TYPE)pTmp); + if(0 == ret) + { + /* ʧ ͷѷռ */ + DestoryMsgNodeStack(pRsrStruct); + return ret; + } + else + { + /* ʲô */ + } + } + + return ret; +} + + +/*********************************************************************** + * : DestoryMsgNodeStack + * : ͷʱĶջռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 DestoryMsgNodeStack(RSR_INFO_STRU *pRsrStruct) +{ + UINT8 ret = 1; + DataNode *pNode = NULL; + + /* ȫʱĶջΪգ */ + if(NULL == pRsrStruct->StackOfDataLink) + { + return ret; + } + + while(StackStatus(&pRsrStruct->StackOfDataLink->stack)>0) + { + /* Ѿ֤˶ջ϶пнڵ㣬 */ + ret = StackPop(&pRsrStruct->StackOfDataLink->stack ,(STACK_DATA_TYPE *)&pNode); + if(pNode->Data != NULL) + { + free(pNode->Data); + pNode->Data = NULL; + } + } + + /* ͷŶջ */ + ret = StackFree(&pRsrStruct->StackOfDataLink->stack); + + /* ͷʱĶнڵ㻺 */ + if(pRsrStruct->StackOfDataLink->pFirstNode != NULL) + { + free(pRsrStruct->StackOfDataLink->pFirstNode); + pRsrStruct->StackOfDataLink->pFirstNode = NULL; + } + + /* ͷȫֵָpRsrStru->StackOfDataLinkָĿռ */ + free(pRsrStruct->StackOfDataLink); + pRsrStruct->StackOfDataLink = NULL; + + return ret; +} + + +/*-------------------------------------------------------------------- + * RSSPڲӿں End + *--------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + + + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspTmpMsgLnkCommon.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspTmpMsgLnkCommon.h new file mode 100644 index 0000000..42790fc --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/rssp/RsspTmpMsgLnkCommon.h @@ -0,0 +1,110 @@ +/******************************************************** +* +* ļ RsspTmpMsgLnkCommon.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* Rsspʱ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +********************************************************/ + +#ifndef _RSSP_TMP_MSG_LNK_COMMON_H_ +#define _RSSP_TMP_MSG_LNK_COMMON_H_ + +#include "RsspStruct.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*-------------------------------------------------------------------- + * RSSPڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : GetSortedMsgFromQue + * : ԺݽRSRİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pMsgQue QueueStruct* IN źŲ㵽Rssp + * MaxLen UINT16 IN + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 + * + * ȫֱ : gpRsrStruct RSRڲȫֱ + * ֵ : DataNode* ʱͷ + ***********************************************************************/ +DataNode* GetSortedMsgFromQue(QueueStruct *SigToRs,UINT16 MaxLen,UINT8 *RecordArray, UINT16 RecordSize, RSR_INFO_STRU *pRsrStru); + +/*********************************************************************** + * : InsTmpMsgLnk + * : һڵ㡣ʶк˳ + * : + * + * -------------------------------------------------------------- + * pHead DataNode* IN ͷ + * pNode DataNode* IN Ľڵ + * + * ֵ : DataNode* NULL쳣 NULLʱͷ + ***********************************************************************/ +DataNode* InsTmpMsgLnk(DataNode *pHead,DataNode *pNode); + +/*********************************************************************** + * : DelTmpMsgLnkNode + * : ɾӦĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * pCur DataNode* IN ɾڵ + * pLast DataNode* IN ɾǰڵ + * pHead DataNode** INOUT ͷ + * + * ֵ : DataNode* NULL쳣 NULLʱͷ + ***********************************************************************/ +UINT8 DelTmpMsgLnkNode(DataNode *pCur,DataNode *pLast,DataNode **pHead, RSR_INFO_STRU *pRsrStruct); + +/*********************************************************************** + * : InitMsgNodeStack + * : ʼʱĶջռ䡣 + * : + * + * -------------------------------------------------------------- + * NodeNum UINT16 IN + * MaxData UINT16 IN С + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 InitMsgNodeStack(UINT16 NodeNum,UINT16 MaxData, RSR_INFO_STRU *pRsrStruct); + + +/*********************************************************************** + * : DestoryMsgNodeStack + * : ͷʱĶջռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 DestoryMsgNodeStack(RSR_INFO_STRU *pRsrStruct); + + +/*-------------------------------------------------------------------- + * RSSPڲӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigDeclare.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigDeclare.h new file mode 100644 index 0000000..885f0a2 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigDeclare.h @@ -0,0 +1,64 @@ + +/******************************************************************************* +* ļ sigDeclare.c +* Ȩ˵ +* 汾 1.0 +* ʱ 2009.11.23 +* +* RSRźŲЭ궨 +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + +#ifndef _SIG_DECLARE_H +#define _SIG_DECLARE_H + +#ifndef NULL +#define NULL 0 +#endif + +/*************************ڵ֡λƺ궨****************************/ +#define RCV_FRAME_LEN 0 +#define RCV_SENDER_TYPE RCV_FRAME_LEN + 2 +#define RCV_SENDER_ID RCV_SENDER_TYPE + 1 +#define RCV_VERSION_NUM RCV_SENDER_ID + 1 +#define RCV_MSG_LEN RCV_VERSION_NUM + 1 +#define RCV_SRC_TYPE RCV_MSG_LEN + 2 +#define RCV_SRC_LOGIC_ID RCV_SRC_TYPE + 1 +#define RCV_SRC_ID RCV_SRC_LOGIC_ID + 1 +#define RCV_AIM_TYPE RCV_SRC_ID + 1 +#define RCV_AIM_LOGIC_ID RCV_AIM_TYPE + 1 +#define RCV_AIM_ID RCV_AIM_LOGIC_ID + 1 +#define RCV_TIME RCV_AIM_ID + 1 +#define RCV_MSG_ID RCV_TIME + 8 +#define RCV_APP_TYPE RCV_MSG_ID + 1 +#define RCV_MSG_INFO RCV_APP_TYPE + 1 + + +/*************************ڵ֡λƺ궨****************************/ +#define SND_FRAME_LEN 0 +#define SND_SRC_LOGIC_ID SND_FRAME_LEN + 2 +#define SND_AIM_TYPE SND_SRC_LOGIC_ID + 1 +#define SND_AIM_ID SND_AIM_TYPE + 1 +#define SND_AIM_LOGIC_ID SND_AIM_ID + 1 +#define SND_MSG_INFO SND_AIM_LOGIC_ID + 1 + + +/**************************źŲ֡ͷλƺ궨****************************/ +#define SIGHEADER_VERSION_NUM 0 +#define SIGHEADER_MSG_LEN SIGHEADER_VERSION_NUM + 1 +#define SIGHEADER_SRC_TYPE SIGHEADER_MSG_LEN + 2 +#define SIGHEADER_SRC_LOGIC_ID SIGHEADER_SRC_TYPE + 1 +#define SIGHEADER_SRC_ID SIGHEADER_SRC_LOGIC_ID + 1 +#define SIGHEADER_AIM_TYPE SIGHEADER_SRC_ID + 1 +#define SIGHEADER_AIM_LOGIC_ID SIGHEADER_AIM_TYPE + 1 +#define SIGHEADER_AIM_ID SIGHEADER_AIM_LOGIC_ID + 1 +#define SIGHEADER_TIME SIGHEADER_AIM_ID + 1 +#define SIGHEADER_MSG_ID SIGHEADER_TIME + 8 +#define SIGHEADER_APP_TYPE SIGHEADER_MSG_ID + 1 + + + +#endif diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigInterface.c b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigInterface.c new file mode 100644 index 0000000..f2874b1 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigInterface.c @@ -0,0 +1,458 @@ + +/******************************************************************************* +* ļ sigInterface.c +* Ȩ˵ +* 汾 1.0 +* ʱ 2009.11.23 +* +* RSRźŲЭ麯Դļ +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + +#include "sigInterface.h" +#include "dsuRsrFunc.h" + + +/****************************************************************************************** +* : źŲ봦 +* : QueueStruct *RpToSig źŲЭĶ + UINT16 LocalName 豸 +* : +* : QueueStruct *SigToRs źŲRSSPЭĶ +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 SigReceive(UINT16 LocalName, QueueStruct *RpToSig, QueueStruct *SigToRs) +{ + UINT8 TmpRcvBuf[1500]={0}; /*RpToSigе֡ݴ*/ + UINT32 QueueLenth; /*RpToSigпݳ*/ + UINT8 Tmpchar[2]; /*ݴ*/ + UINT16 FrameLen; /*RpToSigе֡ݳ*/ + UINT16 MsgLen; /*֡еϢ峤*/ + UINT8 RetQueueRead; /*зֵ*/ + UINT8 RetQueueWrite; /*дкֵ*/ + UINT8 IsHeaderLegal; /*źŲ֡ͷǷϷֵ*/ + UINT8 ret; /*ֵ*/ + + if((RpToSig != NULL)&&(SigToRs != NULL)) + { + /*ճڶSigToRs*/ + QueueClear(SigToRs); + + /*ڶRpToSigĿݳ*/ + QueueLenth = QueueStatus (RpToSig); + while(QueueLenth > 2) + { + /*ɨڶRpToSigĵ֡ݳȣֽ*/ + QueueScan(2, Tmpchar, RpToSig); + FrameLen = ShortFromChar(Tmpchar); + + /*ж֡Ƿ񳬳*/ + if(FrameLen <= 1400+19+2) + { + /*ڶRpToSigһ֡ݶTmpRcvBuf*/ + RetQueueRead = QueueRead((FrameLen + 2), TmpRcvBuf, RpToSig); + + /*гɹӦĴ*/ + if(RetQueueRead == 1) + { + MsgLen = ShortFromChar(&TmpRcvBuf[RCV_MSG_LEN]); + /*ж֡Ƿ*/ + if(MsgLen == FrameLen-19-2) + { + /*źŲ֡ͷǷ*/ + IsHeaderLegal = CheckSigHeader(TmpRcvBuf[RCV_SENDER_TYPE], TmpRcvBuf[RCV_SENDER_ID], &TmpRcvBuf[RCV_VERSION_NUM], LocalName); + if(IsHeaderLegal == 1) + { + /*ϢдڶSigToRs*/ + RetQueueWrite = WriteSigToRs(&TmpRcvBuf[RCV_VERSION_NUM], SigToRs); + if(RetQueueWrite == 0) + { + /*¼дд*/ + break; + } + } + else + { + /*¼źŲ֡ͷϷ*/ + } + } + else + { + /*¼ݳȴ*/ + } + } + /*ʧܣѭ1*/ + else + { + /*¼д*/ + break; + } + } + else + { + /*¼ݳ,ͬʱ֡֡Ĵ*/ + QueueElementDiscard( (UINT16)(FrameLen + 2), RpToSig); + } + + + /*֡ݵĴ*/ + QueueLenth = QueueStatus (RpToSig); + } + } + else + { + ret = 0; + return ret; + } + + ret = 1; + return ret; +} + + +/****************************************************************************************** +* : жźŲ֡ͷǷϷ +* : UINT8 SenderType ͷType + UINT8 SenderID ͷID + UINT8 *SigHeader źŲ֡ͷָ + UINT16 LocalName ʶ(Type+ID) +* : +* : +* ȫֱ : +* ֵ : źŲ֡ͷϷ1,Ϸ0 +*******************************************************************************************/ +UINT8 CheckSigHeader(UINT8 SenderType, UINT8 SenderID, UINT8 *SigHeader, UINT16 LocalName) +{ + UINT16 SrcName; + UINT16 AimName; + UINT8 IsLegal; + UINT16 MsgLen; + UINT8 retIsSigLegal; + UINT8 ret; + + SrcName = SigHeader[SIGHEADER_SRC_TYPE]*0x100 + SigHeader[SIGHEADER_SRC_ID]; + AimName = SigHeader[SIGHEADER_AIM_TYPE]*0x100 + SigHeader[SIGHEADER_AIM_ID]; + MsgLen = ShortFromChar(&SigHeader[SIGHEADER_MSG_LEN]); + + /*жźŲ֡ͷĿĵַǷ뱾ʶ*/ + if(AimName == LocalName) + { + /*жϷͷTypeIDǷźŲ֡ͷͬ*/ + if((SenderType == SigHeader[SIGHEADER_SRC_TYPE])&&(SenderID == SigHeader[SIGHEADER_SRC_ID])) + { + /*ѯݿж֡ͷǷϷ*/ + retIsSigLegal = dsuSigIsLegal(SrcName, SigHeader[SIGHEADER_SRC_LOGIC_ID], AimName, SigHeader[SIGHEADER_AIM_LOGIC_ID], SigHeader[SIGHEADER_VERSION_NUM], SigHeader[SIGHEADER_MSG_ID],&IsLegal); + + /*жϲѯݿ⺯Ƿȷ*/ + if(retIsSigLegal == 1) + { + /*ź֡ͷǷϷ*/ + if(IsLegal == 1) + { + /*ӦǷΪ2*/ + if(SigHeader[SIGHEADER_APP_TYPE]== 2) + { + /*ϢijǷҪ*/ + if(MsgLen < 1400) + { + ret = 1; + return ret; + } + else + { + /*¼Ϣȳ*/ + } + } + else + { + /*¼ӦͲ*/ + } + } + else + { + /*¼źŲ֡ͷѯݿⲻϷ*/ + } + } + else + { + /*¼ѯݿ*/ + } + } + else + { + /*¼֡ԴʶźŲ֡ͷԴʶ*/ + } + } + else + { + /*¼Ŀĵַ*/ + } + + ret = 0; + return ret; +} + +/****************************************************************************************** +* : дźŲRSSPЭĶ +* : UINT8 *SigMsg źŲϢ +* : +* : QueueStruct *SigToRs źŲRSSPЭĶ +* ȫֱ : +* ֵ : ɹ1,ʣ೤Ȳ0 +*******************************************************************************************/ +UINT8 WriteSigToRs(UINT8 *SigMsg, QueueStruct *SigToRs) +{ + UINT16 MsgLen; + UINT16 DataLen; + UINT32 QueueLen; + UINT8 len[2]; + UINT8 ret; + + /*㵥֡ܳ*/ + MsgLen = ShortFromChar(&SigMsg[SIGHEADER_MSG_LEN]); + DataLen = MsgLen + 4; + ShortToChar(DataLen, len); + + /*ж϶ʣ೤Ƿ㹻*/ + QueueLen = QueueStatus (SigToRs); + if((SigToRs->qsize - QueueLen) > (UINT32)(DataLen + 2)) + { + /*ֽڵDataLenдӦö*/ + QueueWrite(2, len, SigToRs); + /*һֽڵԴTypeдӦö*/ + QueueWrite(1, &SigMsg[SIGHEADER_SRC_TYPE], SigToRs); + /*һֽڵԴIDдӦö*/ + QueueWrite(1, &SigMsg[SIGHEADER_SRC_ID], SigToRs); + /*һֽڵԴ̬IDдӦö*/ + QueueWrite(1, &SigMsg[SIGHEADER_SRC_LOGIC_ID], SigToRs); + /*һֽڵĿĶ̬IDдӦö*/ + QueueWrite(1, &SigMsg[SIGHEADER_AIM_LOGIC_ID], SigToRs); + /*ϢдӦö*/ + QueueWrite(MsgLen, &SigMsg[SIGHEADER_APP_TYPE + 1], SigToRs); + + ret = 1; + return ret; + } + else + { + /*¼пóȲ*/ + ret = 0; + return ret; + } +} + +/****************************************************************************************** +* : źŲ +* : QueueStruct *RsToSig RSSPźŲЭĶ + UINT16 LocalName 豸 +* : +* : QueueStruct *SigToRp źŲЭĶ +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 SigOutput(UINT16 LocalName, QueueStruct *RsToSig, QueueStruct *SigToRp) +{ + UINT8 TmpSndBuf[1500]={0}; /*RsToSigе֡ݴ*/ + UINT8 SigHeader[19]={0}; /*źŲ֡ͷ*/ + UINT32 QueueLenth; /*RpToSigпݳ*/ + UINT8 Tmpchar[2]; /*ݴ*/ + UINT16 FrameLen; /*RpToSigе֡ݳ*/ + UINT8 RetQueueRead; /*зֵ*/ + UINT8 RetQueueWrite; /*дкֵ*/ + UINT8 IsSetSucces; /*źŲ֡ͷֵ*/ + UINT8 ret; /*ֵ*/ + + if((RsToSig != NULL)&&(SigToRp != NULL)) + { + /*ճڶSigToRp*/ + QueueClear(SigToRp); + + /*ڶRsToSigĿݳ*/ + QueueLenth = QueueStatus (RsToSig); + while(QueueLenth > 2) + { + /*ɨڶRsToSigĵ֡ݳȣֽ*/ + QueueScan(2, Tmpchar, RsToSig); + FrameLen = ShortFromChar(Tmpchar); + + /*ж֡Ƿ*/ + if(FrameLen <= 1400+4) + { + /*ڶRsToSigһ֡ݶTmpSndBuf*/ + RetQueueRead = QueueRead((FrameLen + 2), TmpSndBuf, RsToSig); + + /*гɹӦĴ*/ + if(RetQueueRead == 1) + { + /*źŲ֡ͷ*/ + IsSetSucces = SetSigHeader(TmpSndBuf, SigHeader, LocalName); + if(IsSetSucces == 1) + { + /*ϢдڶSigToRp*/ + RetQueueWrite = WriteSigToRp(&TmpSndBuf[SND_MSG_INFO], SigHeader, SigToRp); + if(RetQueueWrite == 0) + { + /*¼дд*/ + break; + } + } + else + { + /*¼źŲ֡ͷ*/ + } + + } + /*ʧܣѭ1*/ + else + { + /*¼д*/ + break; + } + } + else + { + /*¼ݳ,ͬʱ֡֡Ĵ*/ + QueueElementDiscard( (UINT16)(FrameLen + 2), RsToSig); + } + + /*֡ݵĴ*/ + QueueLenth = QueueStatus (RsToSig); + } + } + else + { + ret = 0; + return ret; + } + + ret = 1; + return ret; +} + +/****************************************************************************************** +* : źŲ֡ͷ +* : UINT8 *FrameBuf RSSPźŲЭ鵥֡ݵͷָ + UINT16 LocalName ʶ(Type+ID) +* : +* : UINT8 *SigHeaderBuf źŲ֡ͷ +* ȫֱ : +* ֵ : źŲ֡ͷȷ1,ѯݿ󷵻0 +*******************************************************************************************/ +UINT8 SetSigHeader(UINT8 *FrameBuf, UINT8 *SigHeaderBuf, UINT16 LocalName) +{ + UINT16 FrameLen; /*֡*/ + UINT16 MsgLen; /*Ϣ*/ + UINT16 AimName; /*Ŀ豸ʶTypeǰIDں*/ + UINT8 Name[2]; /*ʶʱ飬0ΪType1ΪID*/ + UINT8 ItfVer; /*ӿڰ汾*/ + UINT8 MsgID; /*ϢID*/ + UINT8 i; /*ѭ*/ + UINT8 retGetInfo; /*źŲѯݿ⺯ֵ*/ + UINT8 ret; + + FrameLen = ShortFromChar(&FrameBuf[SND_FRAME_LEN]); + MsgLen = FrameLen - 4; + + /*źŲϢ峤*/ + ShortToChar(MsgLen, &SigHeaderBuf[SIGHEADER_MSG_LEN]); + + /*ԴTypeԴID*/ + ShortToChar(LocalName, Name); + SigHeaderBuf[SIGHEADER_SRC_TYPE] = Name[0]; + SigHeaderBuf[SIGHEADER_SRC_ID] = Name[1]; + + /*Դ̬ID*/ + SigHeaderBuf[SIGHEADER_SRC_LOGIC_ID] = FrameBuf[SND_SRC_LOGIC_ID]; + + /*ĿType*/ + SigHeaderBuf[SIGHEADER_AIM_TYPE] = FrameBuf[SND_AIM_TYPE]; + + /*ĿID*/ + SigHeaderBuf[SIGHEADER_AIM_ID] = FrameBuf[SND_AIM_ID]; + + /*ĿĶ̬ID*/ + SigHeaderBuf[SIGHEADER_AIM_LOGIC_ID] = FrameBuf[SND_AIM_LOGIC_ID]; + + + /*ѯݿ⣬ѻýӿڰ汾ϢID*/ + AimName = FrameBuf[SND_AIM_TYPE]*0x100 + FrameBuf[SND_AIM_ID]; + retGetInfo = dsuSigGetInfo(LocalName, SigHeaderBuf[SIGHEADER_SRC_LOGIC_ID], AimName, SigHeaderBuf[SIGHEADER_AIM_LOGIC_ID], &ItfVer, &MsgID); + if(retGetInfo == 1) + { + /*ýӿڰ汾ϢID*/ + SigHeaderBuf[SIGHEADER_VERSION_NUM] = ItfVer; + SigHeaderBuf[SIGHEADER_MSG_ID] = MsgID; + } + else + { + /*¼ѯݿ*/ + ret = 0; + return ret; + } + + /*ںʱ䣬˫Լںʱ䣬0*/ + for(i = 0; i < 8; i++) + { + SigHeaderBuf[SIGHEADER_TIME + i] = 0; + } + + /*Ӧ*/ + SigHeaderBuf[SIGHEADER_APP_TYPE] = 2; + + ret = 1; + return ret; +} + +/****************************************************************************************** +* : дźŲЭĶ +* : UINT8 *SigMsgBody źŲϢ + UINT8 *SigHeaderBuf źŲ֡ͷ +* : +* : QueueStruct *SigToRp źŲЭĶ +* ȫֱ : +* ֵ : ɹ1,ʣ೤Ȳ0 +*******************************************************************************************/ +UINT8 WriteSigToRp(UINT8 *SigMsgBody, UINT8 *SigHeaderBuf, QueueStruct *SigToRp) +{ + UINT16 MsgLen; + UINT16 DataLen; + UINT32 QueueLen; + UINT8 len[2]; + UINT8 ret; + + /*㵥֡ܳ*/ + MsgLen = ShortFromChar(&SigHeaderBuf[SIGHEADER_MSG_LEN]); + DataLen = MsgLen + 2 + 19; + ShortToChar(DataLen, len); + + /*ж϶ʣ೤Ƿ㹻*/ + QueueLen = QueueStatus (SigToRp); + if((SigToRp->qsize - QueueLen) > (UINT32)(DataLen + 2)) + { + /*ֽڵDataLenдӦö*/ + QueueWrite(2, len, SigToRp); + /*һֽڵĿTypeдӦö*/ + QueueWrite(1, &SigHeaderBuf[SIGHEADER_AIM_TYPE], SigToRp); + /*һֽڵĿIDдӦö*/ + QueueWrite(1, &SigHeaderBuf[SIGHEADER_AIM_ID], SigToRp); + /*19ֽڵźŲ֡ͷдӦö*/ + QueueWrite(19, SigHeaderBuf, SigToRp); + /*ϢдӦö*/ + QueueWrite(MsgLen, SigMsgBody, SigToRp); + + ret = 1; + return ret; + } + else + { + /*¼пóȲ*/ + ret = 0; + return ret; + } +} + + diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigInterface.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigInterface.h new file mode 100644 index 0000000..a5eff61 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr/sig/sigInterface.h @@ -0,0 +1,103 @@ + +/******************************************************************************* +* ļ sigInterface.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2009.11.23 +* +* RSRźŲЭ麯ͷļ +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + +#ifndef _SIG_INTERFACE_H +#define _SIG_INTERFACE_H + +#include "CommonTypes.h" +#include "Convert.h" +#include "CommonQueue.h" +#include "sigDeclare.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************** +* : źŲ봦 +* : QueueStruct *RpToSig źŲЭĶ + UINT16 LocalName 豸 +* : +* : QueueStruct *SigToRs źŲRSSPЭĶ +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 SigReceive(UINT16 LocalName, QueueStruct *RpToSig, QueueStruct *SigToRs); + + +/****************************************************************************************** +* : жźŲ֡ͷǷϷ +* : UINT8 SenderType ͷType + UINT8 SenderID ͷID + UINT8 *SigHeader źŲ֡ͷָ + UINT16 LocalName ʶ(Type+ID) +* : +* : +* ȫֱ : +* ֵ : źŲ֡ͷϷ1,Ϸ0 +*******************************************************************************************/ +UINT8 CheckSigHeader(UINT8 SenderType, UINT8 SenderID, UINT8 *SigHeader, UINT16 LocalName); + + +/****************************************************************************************** +* : дźŲRSSPЭĶ +* : UINT8 *SigMsg źŲϢ +* : +* : QueueStruct *SigToRs źŲRSSPЭĶ +* ȫֱ : +* ֵ : ɹ1,ʣ೤Ȳ0 +*******************************************************************************************/ +UINT8 WriteSigToRs(UINT8 *SigMsg, QueueStruct *SigToRs); + + +/****************************************************************************************** +* : źŲ +* : QueueStruct *RsToSig RSSPźŲЭĶ + UINT16 LocalName 豸 +* : +* : QueueStruct *SigToRp źŲЭĶ +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 SigOutput(UINT16 LocalName, QueueStruct *RsToSig, QueueStruct *SigToRp); + + +/****************************************************************************************** +* : źŲ֡ͷ +* : UINT8 *FrameBuf RSSPźŲЭ鵥֡ݵͷָ + UINT16 LocalName ʶ(Type+ID) +* : +* : UINT8 *SigHeaderBuf źŲ֡ͷ +* ȫֱ : +* ֵ : źŲ֡ͷȷ1,ѯݿ󷵻0 +*******************************************************************************************/ +UINT8 SetSigHeader(UINT8 *FrameBuf, UINT8 *SigHeaderBuf, UINT16 LocalName); + + +/****************************************************************************************** +* : дźŲЭĶ +* : UINT8 *SigMsgBody źŲϢ + UINT8 *SigHeaderBuf źŲ֡ͷ +* : +* : QueueStruct *SigToRp źŲЭĶ +* ȫֱ : +* ֵ : ɹ1,ʣ೤Ȳ0 +*******************************************************************************************/ +UINT8 WriteSigToRp(UINT8 *SigMsgBody, UINT8 *SigHeaderBuf, QueueStruct *SigToRp); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/rsr_record_cbtc/common_rsr_record_config/RsrConfig.h b/TSCP/src/protocol/rsr_record_cbtc/common_rsr_record_config/RsrConfig.h new file mode 100644 index 0000000..9ec2fd2 --- /dev/null +++ b/TSCP/src/protocol/rsr_record_cbtc/common_rsr_record_config/RsrConfig.h @@ -0,0 +1,23 @@ +/******************************************************** +* +* ļ RsrConfig.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2010.05.10 +* ؼЭ鲿 +* Rsrļ : RSSP¼ +* ʹע⣺ +* +* ޸ļ¼ +* +********************************************************/ +#ifndef _RSR_CONFIG_H_ +#define _RSR_CONFIG_H_ + +/* ¼뿪 */ +/* #define RSR_RECORD_ERR_ASCII */ /* ַʽ¼ */ + +#define RSR_RECORD_SIMPLIFY_BIN /* ԶƷʽ¼ */ + +#endif + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2DataStru.h b/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2DataStru.h new file mode 100644 index 0000000..1ee5803 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2DataStru.h @@ -0,0 +1,123 @@ +/******************************************************************************* +* +* ļ dsuRsspDataStru.h +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* RSRЭصdsuѯṹ嶨壬ڲʹ +* ʹע⣺ +* ޸ļ¼ +** 2013.02.15 ɾDSU_RSSP_LNK_INFO_STRUDSU_RSSP_LNK_INFO_STRU_WL +** 2013.02.15 ɾDSU_RSSP_INFO_STRUDSU_RSSP_INFO_STRU_WL +*******************************************************************************/ +#ifndef _DSU_RSSP2_DATA_STRU_H +#define _DSU_RSSP2_DATA_STRU_H + +#include "CommonTypes.h" + + +/*󳤶ڴ洢ݿ*/ +#define DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE (40) +#define DSU_DATA_PRTCL_RSSP2_LOC_TYPE_LINE_SIZE (7) +#define DSU_DATA_PRTCL_RSSP2_DEV_LINE_SIZE (40) +#define DSU_DATA_PRTCL_RSSP2_COMM_RELATION_SIZE (2) + +#define DSU_DATA_PRTCL_RSSP2_RMT_TYPE_CFG (7) +#define DSU_DATA_PRTCL_RSSP2_LOC_TYPE_CFG (8) +#define DSU_DATA_PRTCL_RSSP2_DEV_CFG (9) +#define DSU_DATA_PRTCL_RSSP2_COMM_RELATION_CFG (10) + +/* VOBCʹö˱ */ +#define VOBC_ENDID_TC1 1 /* TC1 */ +#define VOBC_ENDID_TC2 2 /* TC2*/ +#define VOBC_ENDID_REDUN 0 /* 2IPβ೵ */ + +#undef RSSP2_2IP_MODE /**/ + +typedef enum +{ + DEVICE_TYPE_ZC = 0x01, /* ZC */ + DEVICE_TYPE_ATP = 0x02, /* ATP */ + DEVICE_TYPE_AOM = 0x03, /* AOM */ + DEVICE_TYPE_ATS = 0x04, /* ATS */ + DEVICE_TYPE_DSU = 0x05, /* DSU */ + DEVICE_TYPE_CI = 0x06, /* CI */ + DEVICE_TYPE_MSS = 0x07, /* MSS */ + DEVICE_TYPE_UNKNOWN = 0xFF /* δ֪ */ + }RSSP2_DEVICE_TYPE; + +#ifdef __cplusplus +extern "C" { +#endif + +/*½ṹ嶨dsuݿеݴ洢ⷢ*/ +/*rssp2 7 Эջ㹲Ϣṹ*/ +typedef struct +{ + UINT8 RemoteEtcsType; /*ԷETCS*/ + UINT32 SAITsyn; /* SAITsynʱʱֵ*/ + UINT32 SAIECRtnPeriod; /* SAI㳤ڻص */ + UINT16 SAISNDiffMax; /* SAIֵ */ + UINT32 SAIECAlarm; /* SAIEC״ֵ̬*/ + UINT32 SAIECRtnValue; /* SAIECصֵ TO BE DONE */ + UINT32 SAIMaxErrValue; /*SAIֵ */ + UINT32 SAIUpdFailCountMax; /* SAI¹ֵ */ + UINT32 MASLTsynTimeOut; /* MASLTestabʱʱֵ */ + UINT32 ALETsynTimeOut; /* ALETsynʱʱֵ */ + UINT32 ALETconTimeOut; /*ALETconʱʱֵ(ͨʹ,Э㲻ʹ) */ + UINT8 ALETSNCheckMode; /* ALETSNģʽ */ +}DSU_RSSP2_WS_TYPE_CFG_STRU; /*%RELAX*/ + +/*rssp2 8 RSSP2豸Ͳṹ*/ +typedef struct +{ + UINT8 LocalEtcsType; /* ETCS*/ + UINT32 SAI_Tupd; /* Tupdʱʱֵ*/ + UINT16 SAI_EcPeriod; /* SAIECֵ */ +}DSU_RSSP2_LOC_TYPE_CFG_STRU;/*%RELAX*/ + +typedef struct +{ + UINT8 Ip[4]; + UINT16 Port; +}DSU_IP_PORT; /*%RELAX*/ + +/*rssp2 9 RSSP2豸ͨŲṹ*/ +typedef struct +{ + UINT32 EtcsId; /*豸ETCS*/ + UINT8 Key[24]; /*Կ*/ + DSU_IP_PORT BlueIpPort; + DSU_IP_PORT RedIpPort; +}DSU_RSSP2_DEV_CFG_STRU;/*%RELAX*/ + +/*RSSPIIͨŹϵ*/ +typedef struct +{ + UINT8 InitiatorType; /**/ + UINT8 FollowerType; /*淽*/ +}DSU_RSSP2_COMM_RELATION_STRU; + +typedef struct +{ + UINT32 dsuRssp2WsTypeCfgLen; + DSU_RSSP2_WS_TYPE_CFG_STRU *pDsuRssp2WsTypeCfgStru;/* 7 */ + + UINT32 dsuRssp2LocTypeCfgLen; + DSU_RSSP2_LOC_TYPE_CFG_STRU *pDsuRssp2LocTypeCfgStru;/* 8 */ + + UINT32 dsuRssp2DevCfgLen; + DSU_RSSP2_DEV_CFG_STRU *pDsuRssp2DevCfgStru;/* 9 */ + + UINT32 dsuRssp2CommRelationLen; + DSU_RSSP2_COMM_RELATION_STRU* pDsuRssp2CommRelationStru; /*10 RSSPIIͨŹϵ*/ + +}DSU_RSSP2_INFO_STRU,*LPDSU_RSSP2_INFO_STRU;/*%RELAX*/ + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2Func.c b/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2Func.c new file mode 100644 index 0000000..83109cc --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2Func.c @@ -0,0 +1,918 @@ +#include "dsuRssp2Func.h" +#include "CommonMemory.h" +#include "Convert.h" +#include "dfsDataRead.h" +#include "dquDataTypeDefine.h" +#include "dquIdmapInit.h" + +DSU_RSSP2_INFO_STRU dsuRssp2InfoStru; /*ڱRSSP2ϢĽṹ*/ +DSU_RSSP2_INFO_STRU *g_dsuRssp2Stru; /* ǰڲݿ */ +DSU_IDMAP_STRU pDsuIdmapStru = { 0 }; /*Ŷձ*/ + +/*VOBCڲת4ֽڻͨ*/ +UINT8 dquVobcName2OutDevId(IN UINT16 VobcName, IN UINT8 EndId, OUT UINT32 *pOutDevId); +/*4ֽETCSIDתVOBCڲ*/ +UINT8 dquEtcsId2VobcName(IN UINT32 EtcsId, OUT UINT16 *pDevName, OUT UINT16 *pEndId); + +UINT8 dquSetInitRssp2Ref(DSU_RSSP2_INFO_STRU * pDsuRssp2Stru) +{ + UINT8 ret = 0; + if (NULL != pDsuRssp2Stru) + { + g_dsuRssp2Stru = pDsuRssp2Stru; + ret = 1; + } + else + { + g_dsuRssp2Stru = NULL; + ret = 0; + } + return ret; +} +/************************************************************************ +* ȫͨЭRSSP2Эѯʼڼȷԣݽṹ +ʹЭѯ֮ǰһ +* +FSName ļݵַ +* ֵ1ɹ +* 0ʧܣд +************************************************************************/ +UINT8 dsuRssp2Init(UINT8* FSName) +{ + UINT8 chReturnValue = 1; /*ֵ*/ + UINT8 TempRet; + UINT8* pData = NULL; /*ڶȡݵָ*/ + UINT32 dataLen = 0; /*ݳ*/ + UINT32 i = 0; + UINT32 j = 0; + UINT32 IbookLen = 0; + + /*ʼŶձ*/ + if (NULL == g_dsuIdmapStru) + { + dquSetInitIdmapRef(&pDsuIdmapStru); + } + dfsIdmapInit((CHAR*)FSName); + + if (NULL != g_dsuRssp2Stru) + { + chReturnValue = 1; + } + else + { +#if 1 /* TO BE DONE ϵʼģʽʱ汾׮Эʼľ巽ʽ */ + g_dsuRssp2Stru = &dsuRssp2InfoStru; + chReturnValue = 1; +#else + chReturnValue = 0; +#endif + } + + /******************************************7*****************************************/ + /*ʼrssp2 Эջ乲 */ + /*ȡ*/ + TempRet = dquGetConfigData((INT8*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PRTCL_RSSP2_RMT_TYPE_CFG, &pData, &dataLen); + if ((1 == chReturnValue) && (1 == TempRet) && (0 == (dataLen % DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE))) + { + IbookLen = (UINT32)(dataLen / DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); /*ݵĸ*/ + if (0 < IbookLen) + { + g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru = (DSU_RSSP2_WS_TYPE_CFG_STRU*)MyNew(sizeof(DSU_RSSP2_WS_TYPE_CFG_STRU) * IbookLen); /*Ϊṹռ*/ + if (NULL == g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru) + { + chReturnValue = 0; + } + } + if (1 == chReturnValue) + { + CommonMemSet(g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru, sizeof(DSU_RSSP2_WS_TYPE_CFG_STRU) * IbookLen, 0, sizeof(DSU_RSSP2_WS_TYPE_CFG_STRU) * IbookLen); + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0; i < IbookLen; i++) + { + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->RemoteEtcsType = *(pData + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->SAITsyn = LongFromChar(pData + 1 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->SAIECRtnPeriod = LongFromChar(pData + 5 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->SAISNDiffMax = ShortFromChar(pData + 9 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->SAIECAlarm = LongFromChar(pData + 11 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->SAIECRtnValue = LongFromChar(pData + 15 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->SAIMaxErrValue = LongFromChar(pData + 19 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->SAIUpdFailCountMax = LongFromChar(pData + 23 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->MASLTsynTimeOut = LongFromChar(pData + 27 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->ALETsynTimeOut = LongFromChar(pData + 31 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->ALETconTimeOut = LongFromChar(pData + 35 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + (g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru + i)->ALETSNCheckMode = *(pData + 39 + i * DSU_DATA_PRTCL_RSSP2_RMT_TYPE_LINE_SIZE); + }/* end for i */ + g_dsuRssp2Stru->dsuRssp2WsTypeCfgLen = IbookLen; + } + } + else + { + /* ȡļʧ */ + chReturnValue = 0; + } + + /******************************************8*****************************************/ + /*ʼrssp2 Ե㰲ȫñ */ + /*ȡ*/ + TempRet = dquGetConfigData((INT8*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PRTCL_RSSP2_LOC_TYPE_CFG, &pData, &dataLen); + if ((1 == chReturnValue) && (1 == TempRet) && (0 == (dataLen % DSU_DATA_PRTCL_RSSP2_LOC_TYPE_LINE_SIZE))) + { + IbookLen = (UINT32)(dataLen / DSU_DATA_PRTCL_RSSP2_LOC_TYPE_LINE_SIZE); /*ݵĸ*/ + + if (0 < IbookLen) + { + g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru = (DSU_RSSP2_LOC_TYPE_CFG_STRU*)MyNew(sizeof(DSU_RSSP2_LOC_TYPE_CFG_STRU) * IbookLen); /*Ϊṹռ*/ + if (NULL == g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru) + { + chReturnValue = 0; + } + } + if (1 == chReturnValue) + { + CommonMemSet(g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru, sizeof(DSU_RSSP2_LOC_TYPE_CFG_STRU) * IbookLen, 0, sizeof(DSU_RSSP2_LOC_TYPE_CFG_STRU) * IbookLen); + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0; i < IbookLen; i++) + { + (g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru + i)->LocalEtcsType = *(pData + DSU_DATA_PRTCL_RSSP2_LOC_TYPE_LINE_SIZE * i); + (g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru + i)->SAI_Tupd = LongFromChar(pData + 1 + DSU_DATA_PRTCL_RSSP2_LOC_TYPE_LINE_SIZE * i); + (g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru + i)->SAI_EcPeriod = ShortFromChar(pData + 5 + DSU_DATA_PRTCL_RSSP2_LOC_TYPE_LINE_SIZE * i); + } + g_dsuRssp2Stru->dsuRssp2LocTypeCfgLen = IbookLen; + } + } + else + { + /* ȡļʧ */ + chReturnValue = 0; + } + + /******************************************9*****************************************/ + /* ʼrssp2 ǰTCPͨñ */ + /* ȡ */ + TempRet = dquGetConfigData((INT8*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PRTCL_RSSP2_DEV_CFG, &pData, &dataLen); + if ((1 == chReturnValue) && (1 == TempRet) && (dataLen > 0)) + { + IbookLen = (UINT32)(dataLen / DSU_DATA_PRTCL_RSSP2_DEV_LINE_SIZE); /*ݵĸ*/ + if (0 < IbookLen) + { + g_dsuRssp2Stru->pDsuRssp2DevCfgStru = (DSU_RSSP2_DEV_CFG_STRU*)MyNew(sizeof(DSU_RSSP2_DEV_CFG_STRU) * IbookLen); /*Ϊṹռ*/ + if (NULL == g_dsuRssp2Stru->pDsuRssp2DevCfgStru) + { + chReturnValue = 0; + } + } + + if (1 == chReturnValue) + { + CommonMemSet(g_dsuRssp2Stru->pDsuRssp2DevCfgStru, sizeof(DSU_RSSP2_DEV_CFG_STRU) * IbookLen, 0, sizeof(DSU_RSSP2_DEV_CFG_STRU) * IbookLen); + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0; i < IbookLen; i++) + { + (g_dsuRssp2Stru->pDsuRssp2DevCfgStru + i)->EtcsId = LongFromChar(pData + DSU_DATA_PRTCL_RSSP2_DEV_LINE_SIZE * i); + CommonMemCpy((g_dsuRssp2Stru->pDsuRssp2DevCfgStru + i)->Key, 24, (pData + 4 + DSU_DATA_PRTCL_RSSP2_DEV_LINE_SIZE * i), 24); + CommonMemCpy((g_dsuRssp2Stru->pDsuRssp2DevCfgStru + i)->BlueIpPort.Ip, 4, (pData + 28 + DSU_DATA_PRTCL_RSSP2_DEV_LINE_SIZE * i), 4); + CommonMemCpy((g_dsuRssp2Stru->pDsuRssp2DevCfgStru + i)->RedIpPort.Ip, 4, (pData + 32 + DSU_DATA_PRTCL_RSSP2_DEV_LINE_SIZE * i), 4); + (g_dsuRssp2Stru->pDsuRssp2DevCfgStru + i)->BlueIpPort.Port = ShortFromChar(pData + 36 + DSU_DATA_PRTCL_RSSP2_DEV_LINE_SIZE * i); + (g_dsuRssp2Stru->pDsuRssp2DevCfgStru + i)->RedIpPort.Port = ShortFromChar(pData + 38 + DSU_DATA_PRTCL_RSSP2_DEV_LINE_SIZE * i); + } + g_dsuRssp2Stru->dsuRssp2DevCfgLen = IbookLen; + } + } + else + { + /* ȡļʧ */ + chReturnValue = 0; + } + + TempRet = dquGetConfigData((INT8*)FSName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PRTCL_RSSP2_COMM_RELATION_CFG, &pData, &dataLen); + if ((1u == chReturnValue) && (1u == TempRet)) + { + if (0u < dataLen) /**/ + { + IbookLen = (UINT32)(dataLen / DSU_DATA_PRTCL_RSSP2_COMM_RELATION_SIZE); /*ݵĸ*/ + if (0 < IbookLen) + { + g_dsuRssp2Stru->pDsuRssp2CommRelationStru = (DSU_RSSP2_COMM_RELATION_STRU*)MyNew(sizeof(DSU_RSSP2_COMM_RELATION_STRU) * IbookLen); /*Ϊṹռ*/ + if (NULL == g_dsuRssp2Stru->pDsuRssp2CommRelationStru) + { + chReturnValue = 0; + } + } + + if (1 == chReturnValue) + { + CommonMemSet(g_dsuRssp2Stru->pDsuRssp2CommRelationStru, sizeof(DSU_RSSP2_COMM_RELATION_STRU) * IbookLen, 0, sizeof(DSU_RSSP2_COMM_RELATION_STRU) * IbookLen); + /*ͨѭݽṹУ˳ṹ嶨Ӧ*/ + for (i = 0u; i < IbookLen; i++) + { + g_dsuRssp2Stru->pDsuRssp2CommRelationStru[i].InitiatorType = pData[DSU_DATA_PRTCL_RSSP2_COMM_RELATION_SIZE * i]; + g_dsuRssp2Stru->pDsuRssp2CommRelationStru[i].FollowerType = pData[DSU_DATA_PRTCL_RSSP2_COMM_RELATION_SIZE * i + 1]; + } + g_dsuRssp2Stru->dsuRssp2CommRelationLen = IbookLen; + + for (i = 0; i < g_dsuRssp2Stru->dsuRssp2CommRelationLen; i++) /**/ + { + if (g_dsuRssp2Stru->pDsuRssp2CommRelationStru[i].InitiatorType != g_dsuRssp2Stru->pDsuRssp2CommRelationStru[i].FollowerType) /*淽ͬ*/ + { + for (j = i + 1; j < g_dsuRssp2Stru->dsuRssp2CommRelationLen; j++) /*¸*/ + { + if ((g_dsuRssp2Stru->pDsuRssp2CommRelationStru[j].InitiatorType == g_dsuRssp2Stru->pDsuRssp2CommRelationStru[i].FollowerType) + && (g_dsuRssp2Stru->pDsuRssp2CommRelationStru[j].FollowerType == g_dsuRssp2Stru->pDsuRssp2CommRelationStru[i].InitiatorType)) /*˫ô,ɼָ淽*/ + { + chReturnValue = 0; + break; + } + } + } + } + } + } + } + else + { + /* ȡļʧ */ + chReturnValue = 0; + } + + return chReturnValue; +} + +/************************************************************************ +ܣڴͷź +룺 + +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dsuRsspIIFreeSpace(void) +{ + UINT8 rt = 0; + + if (NULL != g_dsuRssp2Stru) + { + if (NULL != g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru) + { + free((void*)g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru); + g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru = NULL; + } + + if (NULL != g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru) + { + free((void*)g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru); + g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru = NULL; + } + + if (NULL != g_dsuRssp2Stru->pDsuRssp2DevCfgStru) + { + free((void*)g_dsuRssp2Stru->pDsuRssp2DevCfgStru); + g_dsuRssp2Stru->pDsuRssp2DevCfgStru = NULL; + } + rt = 1; + } + return rt; +} + +/************************************************************************ +ܣ2ֽڲź2ֽ߼ת4ֽETCSID +룺 +IN UINT16 DevName 2ֽڲţλ豸 λ豸) +IN UINT16 LogId vobcʱʹö˱ 1-TC1 2-TC2 0-2IPβ೵ + 豸ʱ + +OUT UINT32 *pEtcsId 4ֽETCSID +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquDevName2EtcsId(IN UINT16 DevName, IN UINT16 LogId, OUT UINT32 *pEtcsId) +{ + UINT8 ret = 0; + UINT32 hlhtId = 0; + UINT32 etcsId = 0; + UINT8 devType = 0; + UINT8 devId = 0; + UINT32 i = 0; + DSU_RSSP2_DEV_CFG_STRU *pDevCfg = NULL; + + devType = (UINT8)(DevName / 256); + devId = (UINT8)(DevName & 0x00FF); + + /*ڼ*/ + if (NULL == pEtcsId) + { + ret = 0; + } + else + { + *pEtcsId = 0; + ret = 1; + } + if (NULL == g_dsuRssp2Stru) + { + ret = 0; + } + + /* һͨ */ + if (1 == ret) + { + switch (devType) + { + case DEVTYPE_ZC: + ret = dquQueryOutDevId(QFUN_IDMAP_ZC_ID, devId, &hlhtId); + break; + case DEVTYPE_ATS: + ret = dquQueryOutDevId(QFUN_IDMAP_ATS_ID, devId, &hlhtId); + break; + case DEVTYPE_CI: + ret = dquQueryOutDevId(QFUN_IDMAP_CI_ID, devId, &hlhtId); + if((((hlhtId)>>29)&0x00000007) == 0x01) /* CQ HOTFIX TH */ + { + if(LogId==1||LogId==2) + { + hlhtId += LogId-1; + } + } + break; + case DEVTYPE_VOBC: + ret = dquVobcName2OutDevId(DevName, (UINT8)LogId, &hlhtId); + break; + case DEVTYPE_DSU: + ret = dquQueryOutDevId(QFUN_IDMAP_DSU_ID, devId, &hlhtId); + break; + case DEVTYPE_AOM: + ret = dquVobcName2OutDevId(DevName, (UINT8)LogId, &hlhtId); + break; + default: + ret = 0; + break; + } + } + + /*ҶӦETCSID*/ + if (1 == ret) + { + ret = 0; + pDevCfg = g_dsuRssp2Stru->pDsuRssp2DevCfgStru; + for (i = 0; i < g_dsuRssp2Stru->dsuRssp2DevCfgLen; i++) + { + if ((hlhtId&ETCSID_MASK) == (pDevCfg->EtcsId&ETCSID_MASK)) + { + etcsId = pDevCfg->EtcsId; + ret = 1; + break; + } + pDevCfg++; + } + } + + if (1 == ret) + { + *pEtcsId = etcsId; + } + + return ret; +} + +/************************************************************************ +ܣ4ֽETCSIDת2ֽڲź2ֽ߼ +룺 +IN UINT32 EtcsId ETCSID + +OUT UINT16 *pDevId 2ֽڲţλ豸 λ豸) +OUT UINT16 *pLogicId vobcʱʹö˱ 1-TC1 2-TC2 0-2IPβ೵ + 豸ʱ +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquEtcsId2DevName(IN UINT32 EtcsId, OUT UINT16 *pDevName, OUT UINT16 *pLogId) +{ + UINT8 ret = 0; + UINT16 devName = 0; + UINT16 logId = 0; + RSSP2_DEVICE_TYPE type = DEVICE_TYPE_UNKNOWN; + + if ((NULL != pDevName) && (NULL != pLogId)) + { + GetEtcsTypeFromEtcsId(EtcsId, &type); + switch (type) + { + case DEVICE_TYPE_ZC:/* ZCű */ + ret = dquQueryDevBits2Index(QFUN_IDMAP_ZC_ID, EtcsId, ETCSID_MASK, &devName); + devName += DEVTYPE_ZC * 256; + break; + case DEVICE_TYPE_ATP:/* VOBCű */ + ret = dquEtcsId2VobcName(EtcsId, &devName, &logId); + break; + case DEVICE_TYPE_ATS:/* ATSű */ + ret = dquQueryDevBits2Index(QFUN_IDMAP_ATS_ID, EtcsId, ETCSID_MASK, &devName); + devName += DEVTYPE_ATS * 256; + break; + case DEVICE_TYPE_DSU:/* DSUű */ + ret = dquQueryDevBits2Index(QFUN_IDMAP_DSU_ID, EtcsId, ETCSID_MASK, &devName); + devName += DEVTYPE_DSU * 256; + break; + case DEVICE_TYPE_CI:/* CIű */ + ret = dquQueryDevBits2Index(QFUN_IDMAP_CI_ID, EtcsId, ETCSID_MASK, &devName); + if(1 != ret) /* CQ HOTFIX TH */ + { + ret = dquQueryDevBits2Index(QFUN_IDMAP_CI_ID, EtcsId-1, ETCSID_MASK, &devName); + if(1 == ret) + { + logId = 2; + } + } + devName += DEVTYPE_CI * 256; + break; + case DEVICE_TYPE_AOM:/* AOMű */ + ret = dquEtcsId2VobcName(EtcsId, &devName, &logId); + break; + default: + ret = 0; + break; + } + } + else + { + ret = 0; + } + if (1 == ret) + { + *pDevName = devName; + *pLogId = logId; + } + return ret; +} + + +/************************************************************************ +ܣvobcڲת4ֽڻͨ +룺 +IN UINT16 VobcName 2ֽڲţλ豸 λ豸) +IN UINT8 EndId vobcʹö˱ű 1-TC1ˣ2-TC2 0-2IPβ೵ + +OUT UINT32 *pOutDevId 4ֽڻͨ +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquVobcName2OutDevId(IN UINT16 VobcName, IN UINT8 EndId, OUT UINT32 *pOutDevId) +{ + UINT8 ret = 0; + UINT32 hlhtId = 0;/*ͨ*/ + UINT32 vobcId[2] = { 0,0 }; + UINT8 devType = 0; + UINT8 devId = 0; + + /* */ + if (NULL != pOutDevId) + { + *pOutDevId = 0; + ret = 1; + } + else + { + ret = 0; + } + if (NULL == g_dsuRssp2Stru) + { + ret = 0; + } + if ((VOBC_ENDID_TC1 != EndId) && (VOBC_ENDID_TC2 != EndId) && (VOBC_ENDID_REDUN != EndId)) + { + ret = 0; + } + devType = (UINT8)(VobcName / 256); + if ((DEVTYPE_VOBC != devType)&&(DEVTYPE_AOM != devType)) + { + ret = 0; + } + + /* ѯVOBCͨ */ + if (1 == ret) + { + devId = (UINT8)(VobcName & 0x00FF); + if (DEVTYPE_VOBC == devType) + { + ret = dquQueryOutVobcDevId(devId, vobcId); + } + else + { + ret = dquQueryOutAOMDevId(devId, vobcId); + } + switch (EndId) + { + case VOBC_ENDID_TC1: + hlhtId = vobcId[0]; + break; + case VOBC_ENDID_TC2: + hlhtId = vobcId[1]; + break; + case VOBC_ENDID_REDUN:/*2IPβ೵ʹ"VOBC1"*/ + hlhtId = vobcId[0]; + break; + default: + /* ɴ֧ */ + ret = 0; + break; + } + } + + if (1 == ret) + { + *pOutDevId = hlhtId; + } + + return ret; +} + +/************************************************************************ +ܣETCSIDתvobcڲ +룺 +IN UINT32 EtcsId ETCSID + +OUT UINT16 *pDevName 2ֽڲţλ豸 λ豸) +OUT UINT16 *pEndId vobcʹö˱ 1-TC1 2-TC2 0-2IPβ೵ +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquEtcsId2VobcName(IN UINT32 EtcsId, OUT UINT16 *pDevName, OUT UINT16 *pEndId) +{ + UINT8 ret = 0; + UINT8 endId = 0; + UINT16 index = 0; + RSSP2_DEVICE_TYPE type = DEVICE_TYPE_UNKNOWN; + + if ((NULL != pDevName) && (NULL != pEndId)) + { + *pDevName = 0; + *pEndId = 0; + ret = 1; + } + else + { + ret = 0; + } + + if (1 == ret) + { + endId = GET_VOBC_END_ID(EtcsId); + switch (endId) + { + case 1: + *pEndId = VOBC_ENDID_TC1; + break; + case 2: + *pEndId = VOBC_ENDID_TC2; + break; + case 3: + *pEndId = VOBC_ENDID_REDUN; + break; + default: + ret = 0; + break; + } + } + + GetEtcsTypeFromEtcsId(EtcsId, &type); + if ((DEVICE_TYPE_ATP != type)&&(DEVICE_TYPE_AOM != type)) + { + ret = 0; + } + + if (1 == ret) + { + if (DEVICE_TYPE_ATP == type) + { + ret = dquQueryVobcDevBits2Index(EtcsId, ETCSID_MASK, &index); + } + else + { + ret = dquQueryAOMDevBits2Index(EtcsId, ETCSID_MASK, &index); + } + } + + if(1 == ret) + { + if (DEVICE_TYPE_ATP == type) + { + *pDevName = DEVTYPE_VOBC * 256 + index; + } + else + { + *pDevName = DEVTYPE_AOM * 256 + index; + } + } + return ret; +} + +/************************************************************************ +ܣETCSIDȡRSSP2ЭʹõIP˿ +룺 +IN UINT32 EtcsId ETCSID + +OUT UINT8 *pNum, TCPͨ(һԺIP˿Ϊһ飬4IPϵͳΪ2) +OUT DSU_IP_PORT *pRedIpPort, IP˿(˿ں65535ʾ˿) +OUT DSU_IP_PORT *pBlueIpPort IP˿(IP˿ͬDZԪһͨ) +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquGetIpPortByEtcsId(IN UINT32 EtcsId, OUT UINT8 *pNum, OUT DSU_IP_PORT *pRedIpPort, OUT DSU_IP_PORT *pBlueIpPort) +{ + UINT8 ret = 0; + UINT32 i = 0; + UINT8 j = 0; + DSU_RSSP2_DEV_CFG_STRU *pDevCfg = NULL; + if ((NULL != pNum) && (NULL != pRedIpPort) && (NULL != pBlueIpPort) && (NULL!= g_dsuRssp2Stru)) + { + pDevCfg = g_dsuRssp2Stru->pDsuRssp2DevCfgStru; + for (i = 0; i < g_dsuRssp2Stru->dsuRssp2DevCfgLen; i++) + { + if ((EtcsId&ETCSID_MASK) == (pDevCfg->EtcsId&ETCSID_MASK)) + { + CommonMemCpy(pRedIpPort[j].Ip, 4, pDevCfg->RedIpPort.Ip, 4); + pRedIpPort[j].Port = pDevCfg->RedIpPort.Port; + CommonMemCpy(pBlueIpPort[j].Ip, 4, pDevCfg->BlueIpPort.Ip, 4); + pBlueIpPort[j].Port = pDevCfg->BlueIpPort.Port; + j++; + ret = 1; + } + pDevCfg++; + } + *pNum = j; + } + return ret; +} + +/************************************************************************ +ܣRSSP-2ЭʹõIP˿ڻȡETCSID +ö˿ںΪ65535ʾ˿ڣУ鴫Ķ˿ںţ + ֻҪIPƥӦETCSID +룺 +IN DSU_IP_PORT IpPort, IP˿ + +OUT UINT32 *pEtcsId, ETCSID +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquGetEtcsIdByIpPort(IN DSU_IP_PORT IpPort, OUT UINT32 *pEtcsId) +{ + UINT8 ret = 0; + UINT32 i = 0; + DSU_RSSP2_DEV_CFG_STRU *pDevCfg = NULL; + INT32 rslt1 = 0; + INT32 rslt2 = 0; + if ((NULL != pEtcsId) && (NULL != g_dsuRssp2Stru)) + { + *pEtcsId = 0; + pDevCfg = g_dsuRssp2Stru->pDsuRssp2DevCfgStru; + for (i = 0; i < g_dsuRssp2Stru->dsuRssp2DevCfgLen; i++) + { + rslt1 = CommonMemCmp(IpPort.Ip, pDevCfg->RedIpPort.Ip, 4); + rslt2 = CommonMemCmp(IpPort.Ip, pDevCfg->BlueIpPort.Ip, 4); + if (((0 == rslt1) && ((IpPort.Port == pDevCfg->RedIpPort.Port)||(0xFFFF == pDevCfg->RedIpPort.Port))) + || ((0 == rslt2) && ((IpPort.Port == pDevCfg->BlueIpPort.Port)||(0xFFFF == pDevCfg->BlueIpPort.Port)))) + { + *pEtcsId = pDevCfg->EtcsId; + ret = 1; + break; + } + pDevCfg++; + } + } + return ret; +} + +/************************************************************************ +ܣݹ豸(ETCS)ȡЭջ乲 +룺 +IN UINT8 WsEtcsType 豸(ETCS) + +OUT DSU_RSSP2_WS_TYPE_CFG_STRU *pRssp2RmtTypeCfg Эջ +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquRssp2GetWaysideTypeCfg(IN UINT8 WsEtcsType, OUT DSU_RSSP2_WS_TYPE_CFG_STRU *pRssp2RmtTypeCfg) +{ + UINT8 ret = 0; + UINT8 tmpRet = 0; + UINT32 i = 0; + + if ((NULL != pRssp2RmtTypeCfg) && (NULL != g_dsuRssp2Stru)) + { + tmpRet = 1; + } + else + { + tmpRet = 0; + } + + if (1 == tmpRet) + { + for (i = 0; i < g_dsuRssp2Stru->dsuRssp2WsTypeCfgLen; i++) + { + if (WsEtcsType == g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru[i].RemoteEtcsType) + { + CommonMemCpy((UINT8*)pRssp2RmtTypeCfg, sizeof(DSU_RSSP2_WS_TYPE_CFG_STRU), (UINT8*)&g_dsuRssp2Stru->pDsuRssp2WsTypeCfgStru[i], sizeof(DSU_RSSP2_WS_TYPE_CFG_STRU)); + ret = 1; + break; + } + } + } + return ret; +} + +/************************************************************************ +ܣETCS豸ͻȡ豸 +룺 +IN UINT8 LocalEtcsType ͨ豸(4ֽⲿ) + +OUT DSU_RSSP2_LOC_TYPE_CFG_STRU *pRssp2LocTypeCfg RSSP2豸Ͳ +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquRssp2GetLocalTypeCfg(IN UINT8 LocalEtcsType, OUT DSU_RSSP2_LOC_TYPE_CFG_STRU *pRssp2LocTypeCfg) +{ + UINT8 ret = 0; + UINT8 tmpRet = 0; + UINT32 i = 0; + DSU_RSSP2_LOC_TYPE_CFG_STRU *pLocTypeCfg = NULL; + if ((NULL != pRssp2LocTypeCfg) && (NULL != g_dsuRssp2Stru)) + { + tmpRet = 1; + } + else + { + tmpRet = 0; + } + if (1 == tmpRet) + { + pLocTypeCfg = g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru; + for (i = 0; i < g_dsuRssp2Stru->dsuRssp2LocTypeCfgLen; i++) + { + if (LocalEtcsType == g_dsuRssp2Stru->pDsuRssp2LocTypeCfgStru[i].LocalEtcsType) + { + CommonMemCpy((UINT8*)pRssp2LocTypeCfg, sizeof(DSU_RSSP2_LOC_TYPE_CFG_STRU), (UINT8*)pLocTypeCfg, sizeof(DSU_RSSP2_LOC_TYPE_CFG_STRU)); + ret = 1; + break; + } + pLocTypeCfg++; + } + } + return ret; +} + + +/************************************************************************ +ܣETCSIDȡ豸 +룺 +IN UINT32 EtcsId ETCSID + +OUT DSU_RSSP2_DEV_CFG_STRU *pRssp2DevCfg Ե㰲ȫ +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquRssp2GetDevCfg(IN UINT32 EtcsId, OUT DSU_RSSP2_DEV_CFG_STRU *pRssp2DevCfg) +{ + UINT8 ret = 0; + UINT8 tmpRet = 0; + UINT32 i = 0; + DSU_RSSP2_DEV_CFG_STRU *pDevCfg=NULL; + + if ((NULL != pRssp2DevCfg) && (NULL != g_dsuRssp2Stru)) + { + tmpRet = 1; + } + else + { + tmpRet = 0; + } + if (1 == tmpRet) + { + pDevCfg = g_dsuRssp2Stru->pDsuRssp2DevCfgStru; + for (i = 0; i < g_dsuRssp2Stru->dsuRssp2DevCfgLen; i++) + { + if ((EtcsId&ETCSID_MASK) == (pDevCfg->EtcsId&ETCSID_MASK)) + { + CommonMemCpy((UINT8*)pRssp2DevCfg, sizeof(DSU_RSSP2_DEV_CFG_STRU), (UINT8*)pDevCfg, sizeof(DSU_RSSP2_DEV_CFG_STRU)); + ret = 1; + break; + } + pDevCfg++; + } + } + return ret; +} + +/************************************************************************ +ܣETCSIDȡETCS +룺 +IN UINT32 EtcsId, ETCSID + +OUT RSSP2_DEVICE_TYPE *pDevType ETCS +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 GetEtcsTypeFromEtcsId(UINT32 EtcsId, RSSP2_DEVICE_TYPE *pDevType) +{ + UINT8 ret = 0; + UINT8 devType = 0; + + devType = (EtcsId / 256 / 256 / 256) & 0x1F; + + if (NULL != pDevType) + { + *pDevType = 0; + if ((8 > devType) && (0 < devType)) + { + *pDevType = devType; + ret = 1; + } + } + return ret; +} + +/************************************************************************ +ܣݱETCSID,ԷETCSIDȡͨŽɫ +룺 +IN UINT32 locEtcsId, 豸ETCSID +IN UINT32 dstEtcsId, Է豸ETCSID + +OUT UINT8 *pRole ͨŽɫ 0(ͻ) 1շ() +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 dquRssp2GetRole(IN UINT32 locEtcsId, IN UINT32 dstEtcsId, OUT UINT8* role) +{ + UINT8 retVal = 0u; /*ֵ*/ + UINT8 locIsGet = 0u; /*ǷȡRSSPII*/ + UINT8 dstIsGet = 0u; /*ǷȡRSSPII*/ + RSSP2_DEVICE_TYPE locType = DEVICE_TYPE_UNKNOWN; /*RSSPII*/ + RSSP2_DEVICE_TYPE dstType = DEVICE_TYPE_UNKNOWN; /*ԷRSSPII*/ + RSSP2_DEVICE_TYPE initiatorType = DEVICE_TYPE_UNKNOWN; /*ǰRSSPII*/ + RSSP2_DEVICE_TYPE followerType = DEVICE_TYPE_UNKNOWN; /*ǰ淽RSSPII*/ + UINT32 i = 0u; /*ѭ*/ + + if ((NULL != role) && (NULL != g_dsuRssp2Stru)) + { + (*role) = 0xFFu; + locIsGet = GetEtcsTypeFromEtcsId(locEtcsId, &locType); + dstIsGet = GetEtcsTypeFromEtcsId(dstEtcsId, &dstType); + if ((1u == locIsGet) && (1u == dstIsGet)) /*ȡ*/ + { + if (g_dsuRssp2Stru->dsuRssp2CommRelationLen > 0) /*ͨŹϵ*/ + { + for (i = 0; i < g_dsuRssp2Stru->dsuRssp2CommRelationLen; i++) + { + initiatorType = g_dsuRssp2Stru->pDsuRssp2CommRelationStru[i].InitiatorType; + followerType = g_dsuRssp2Stru->pDsuRssp2CommRelationStru[i].FollowerType; + if (((initiatorType == locType) && (followerType == dstType)) + || ((initiatorType == dstType) && (followerType == locType))) + { + if ((initiatorType == locType) && (followerType == dstType)) + { + (*role) = 0u; + } + else + { + (*role) = 1u; + } + retVal = 1u; + break; + } + } + } + else /*δͨŹϵ,֮ǰ汾Ĺ̶ϵ*/ + { + if ((DEVICE_TYPE_ATP == locType) || (DEVICE_TYPE_AOM == locType)) /**/ + { + (*role) = 0u; + retVal = 1u; + } + else if ((DEVICE_TYPE_ZC == locType) || (DEVICE_TYPE_CI == locType) || (DEVICE_TYPE_ATS == locType) || (DEVICE_TYPE_DSU == locType) || (DEVICE_TYPE_MSS == locType)) /*淽*/ + { + (*role) = 1u; + retVal = 1u; + } + else + { + retVal = 0u; + } + } + } + } + + return retVal; +} + +/* +*: CommonMemCmp +*: ڴȽϺ +*: const void *str1 Ƚ1 +* const void *str2 Ƚ2 +* UINT32 count ݳ +*: +*: +*ֵ: INT32 < 0:С;>0:;=0 +*/ +INT32 CommonMemCmp(const void *str1, const void *str2, UINT32 count) +{ + INT32 rtn = 0; /*ֵ*/ + UINT32 i = 0; /*ѭ*/ + + for (i = 0; i < count; i++) /**/ + { + if (((UINT8 *)str1)[i] != ((UINT8 *)str2)[i]) /*,˳ѭ,زֵ*/ + { + rtn = ((UINT8 *)str1)[i] - ((UINT8 *)str2)[i]; + break; + } + } + + return rtn; +} \ No newline at end of file diff --git a/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2Func.h b/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2Func.h new file mode 100644 index 0000000..f0862a3 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/dqu_rsspii_cbtc/dsuRssp2Func.h @@ -0,0 +1,90 @@ +/* +RSSP2Эѯ +ԣ +ѯ汾V3.0 +ݽṹ汾V3.0 + +ʹ÷빫ѯV3.0 + +ϵʼ +1.һDSU_RSSP2_INFO_STRUṹ壬 +2.dquSetInitRssp2Ref()DSU_RSSP2_INFO_STRUṹַRSSP2Эѯ +3.dsuRssp2Init()FSļַݸRSSP2ЭѯЭѯɳʼ + +ע⣺RSSP2ѯҪʹñŶձӦҪֱʼRSSP2ѯͱŶձȺҪ󣩣ֶʼɺſʹRSSP2Эѯ +ȼʱRSSP2ѯͱŶձµԴȺҪ󣩲ſʹRSSP2Эѯ + +*/ +#ifndef _DSU_RSSP2_FUNC_H_ +#define _DSU_RSSP2_FUNC_H_ + +#include "CommonTypes.h" +#include "dsuRssp2DataStru.h" +#include "dsuIdmapVar.h" +#include "dsuEmapDefine.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define GET_VOBC_END_ID(EtcsId) (UINT8)((EtcsId)&0x03) +#define ETCSID_MASK (0x7FFFFFF) + +extern DSU_RSSP2_INFO_STRU dsuRssp2InfoStru; /* ڱRSSP2ϢĽṹ*/ +extern DSU_RSSP2_INFO_STRU *g_dsuRssp2Stru; /* ǰڲݿ */ + +/* RSSP2ݾ̬ṹ */ +UINT8 dquSetInitRssp2Ref(DSU_RSSP2_INFO_STRU * pDsuRssp2Stru); + +/*RSSP2Эѯʼ*/ +UINT8 dsuRssp2Init(UINT8* FSName); + +/*2ֽڲת4ֽETCSID*/ +UINT8 dquDevName2EtcsId(IN UINT16 DevName, IN UINT16 LogId, OUT UINT32 *pEtcsId); + +/*4ֽETCSIDת2ֽڲ*/ +UINT8 dquEtcsId2DevName(IN UINT32 EtcsId, OUT UINT16 *pDevName, OUT UINT16 *pLogId); + +/*ETCSIDȡRSSP-2ЭʹõIP˿*/ +UINT8 dquGetIpPortByEtcsId(IN UINT32 EtcsId, OUT UINT8 *pNum, OUT DSU_IP_PORT *pRedIpPort, OUT DSU_IP_PORT *pBlueIpPort); + +/*RSSP-2ЭʹõIP˿ڻȡETCSID*/ +UINT8 dquGetEtcsIdByIpPort(IN DSU_IP_PORT IpPort, OUT UINT32 *pEtcsId); + +/*ȡ豸*/ +UINT8 dquRssp2GetWaysideTypeCfg(IN UINT8 WsEtcsType, OUT DSU_RSSP2_WS_TYPE_CFG_STRU *pRssp2RmtTypeCfg); + +/*ȡ豸*/ +UINT8 dquRssp2GetLocalTypeCfg(IN UINT8 LocalEtcsType, OUT DSU_RSSP2_LOC_TYPE_CFG_STRU *pRssp2LocTypeCfg); + +/*ȡ豸*/ +UINT8 dquRssp2GetDevCfg(IN UINT32 EtcsId, OUT DSU_RSSP2_DEV_CFG_STRU *pRssp2DevCfg); + +/* ݻͨ豸Żȡͨ豸 */ +UINT8 GetEtcsTypeFromEtcsId(UINT32 EtcsId, RSSP2_DEVICE_TYPE *pDevType); + +/*ݱETCSID,ԷETCSIDȡͨŽɫ*/ +UINT8 dquRssp2GetRole(IN UINT32 locEtcsId, IN UINT32 dstEtcsId, OUT UINT8* role); + +/*ڴͷź*/ +UINT8 dsuRsspIIFreeSpace(void); + +/* +*: CommonMemCmp +*: ڴȽϺ +*: const void *str1 Ƚ1 +* const void *str2 Ƚ2 +* UINT32 count ݳ +*: +*: +*ֵ: INT32 < 0:С;>0:;=0 +*/ +INT32 CommonMemCmp(const void *str1, const void *str2, UINT32 count); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Base.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Base.c new file mode 100644 index 0000000..595147e --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Base.c @@ -0,0 +1,53 @@ +/** ****************************************************** +* +* ļ CM_Base.c +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* ·װϵͳ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#include "CM_Base.h" + +/************************************************************************ +ܣ־¼ +û¼־Ϣ +룺 + INT32 level + const CHAR* fmt ־Ϣ + INT32 arg1 1 + INT32 arg2 2 + INT32 arg3 3 + INT32 arg4 4 + INT32 arg5 5 + INT32 arg6 6 + +ֵ +************************************************************************/ +#if(LOG_LEVEL >= 0) +CM_VOID CM_LogMsg(INT32 level, const CHAR* fmt, INT32 arg1, INT32 arg2, INT32 arg3, INT32 arg4, INT32 arg5, INT32 arg6) +{ + if (level <= LOG_LEVEL) + { +#ifdef VXWORKS + logMsg(fmt,arg1,arg2,arg3,arg4,arg5,arg6); +#endif +#ifdef WIN32 +#ifndef NO_PRINTF + printf(fmt,arg1,arg2,arg3,arg4,arg5,arg6); +#endif +#endif +#ifdef QNX +#ifndef NO_PRINTF + printf(fmt,arg1,arg2,arg3,arg4,arg5,arg6); +#endif +#endif + } + return; +} +#endif diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Base.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Base.h new file mode 100644 index 0000000..11f7eb9 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Base.h @@ -0,0 +1,51 @@ +/** ****************************************************** +* +* ļ CM_Base.h +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* ·װϵͳ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#ifndef _CM_BASE_H_ +#define _CM_BASE_H_ + +#include "CM_Type.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /*< __cplusplus */ + + +/************************************************************************ +ܣ־¼ +û¼־Ϣ +룺 + INT32 level + const CHAR* fmt ־Ϣ + INT32 arg1 1 + INT32 arg2 2 + INT32 arg3 3 + INT32 arg4 4 + INT32 arg5 5 + INT32 arg6 6 + +ֵ +************************************************************************/ +#if(LOG_LEVEL >= 0) +CM_VOID CM_LogMsg(INT32 level, const CHAR* fmt, INT32 arg1, INT32 arg2, INT32 arg3, INT32 arg4, INT32 arg5, INT32 arg6); +#else +#define CM_LogMsg((X),(Y),(Z1),(Z2),(Z3),(Z4),(Z5),(Z6)) (NULL) /*%RELAX*/ +#endif + +#ifdef __cplusplus +} +#endif /*< __cplusplus */ + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Define.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Define.h new file mode 100644 index 0000000..2f68116 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Define.h @@ -0,0 +1,33 @@ +/** ****************************************************** +* +* ļ CM_Define.h +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* ־¼غ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#ifndef _CM_DEFINE_H_ +#define _CM_DEFINE_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /*< __cplusplus */ + +#define LOG_LEVEL (10) /*%RELAX*/ + +#define LOG_ERROR (2) /*%RELAX*/ +#define LOG_WARN (4) /*%RELAX*/ +#define LOG_INFO (6) /*%RELAX*/ + +#ifdef __cplusplus +} +#endif /*< __cplusplus */ + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_RingQueue.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_RingQueue.c new file mode 100644 index 0000000..a965338 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_RingQueue.c @@ -0,0 +1,1058 @@ +/** ****************************************************** +* +* ļ CM_RingQueue.c +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* ζд +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ + +#include "CM_RingQueue.h" +#include "CommonMemory.h" + +/************************************************************************ +ܣ軷νṹ +Ļνṹָʱ Իνṹ +룺 + QueueRingID pQueue ζнṹָ + UINT32 dwWaitTime ʱ + +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +CM_BOOL QUEUE_RING_Lock_Time(IN QueueRingID pQueue, IN UINT32 dwWaitTime); + +/************************************************************************ +ܣ軷νṹ +軷νṹ +룺 + QueueRingID pQueue ζнṹָ + +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +CM_BOOL QUEUE_RING_UnLock(IN QueueRingID pQueue); + +/************************************************************************ +ܣõͷָƫƶٵCM_UINT8ָ +õͷָƫƶٵCM_UINT8ָ +룺 + QueueRingID pQueue ζнṹָ + const UINT32 mHeadoffset ƫ + +ֵͷָƫƶٵCM_UINT8ָ +************************************************************************/ +const UINT8 * QUEUE_RING_GetIndexBytePtr(IN QueueRingID pQueue, IN const UINT32 mHeadoffset); + +/************************************************************************ +ܣظͷַָ Ϊձʾû +ظͷַָ Ϊձʾû +룺 + QueueRingID pQueue ζнṹָ + +ֵͷַָ +************************************************************************/ +const UINT8 * QUEUE_RING_GetHeadBytePtr(IN QueueRingID pQueue); + +/************************************************************************ +ܣõͷָƫƶٵCM_UINT8ָ +õͷָƫƶٵCM_UINT8ָ +룺 + QueueRingID pQueue ζнṹָ + const UINT32 dwHeadoffset ƫ + +ֵͷָƫƶٵCM_UINT8ָ +************************************************************************/ +const static UINT8 * QUEUE_RING_GetIndexBytePtrInside(IN QueueRingID pQueue, IN const UINT32 dwHeadoffset); + +/************************************************************************ +ܣʼݲ +ʼݲ +룺 + QueueRingID pQueue ζнṹָ + +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +CM_BOOL QUEUE_RING_Mutex_Init(IN QueueRingID pQueue); + +/************************************************************************ +ܣַָڻνṹеλ +ַָڻνṹеλ +룺 + QueueRingID pQueue ζнṹָ + INT32 iTempIndex ʱ + const UINT8 * pSubBytes ַָ + const UINT32 dwSubLenth ַ + const UINT32 dwSearchOffset ƫ + UINT32 mainLenth ܳ + const UINT8 * _pTableDir ָ + const CM_BOOL bSearchDir Ƿ + +ֵλ +************************************************************************/ +static INT32 QUEUE_RING_SearchByte_Sub(IN QueueRingID pQueue, + IN INT32 iTempIndex, + IN const UINT8 * pSubBytes, + IN const UINT32 dwSubLenth, + IN const UINT32 dwSearchOffset, + IN UINT32 mainLenth, + IN const UINT8 * _pTableDir, + IN const CM_BOOL bSearchDir); + +/************************************************************************ +ܣζгʼ ṹָ ָдС +ζгʼ ṹָ ָдС +룺 + QueueRingID pQueue ζнṹָ + const UINT32 mMaxBufferLenth ʼζеĴС + +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +CM_BOOL QUEUE_RING_Init(IN QueueRingID pQueue, IN const UINT32 mMaxBufferLenth) +{ + /* жӻʼ󳤶*/ + CM_BOOL bRet = CM_TRUE; + if (NULL == pQueue) + { + bRet = CM_FALSE; + } + else /*(CM_TRUE == bRet)*/ + { + /*CM_Memset(pQueue, 0, sizeof(QUEUE_RING_DATA_STRUCT));*/ + if (mMaxBufferLenth > MAX_QUEUE_BUFFER_LENTH) + { + pQueue->m_dwMaxBufferLenth = MAX_QUEUE_BUFFER_LENTH; + } + else + { + pQueue->m_dwMaxBufferLenth = mMaxBufferLenth; + } +#ifdef MUTEX_QUEUE_OPEN + pQueue->m_bUseMutex = CM_TRUE; +#endif + /* CM_LogMsg(LOG_ERROR, "QUEUE_RING CM_Mutex_Init Ret:%d\r\n", bRet, 0, 0, 0, 0, 0);*/ + } + if (CM_TRUE == bRet) + { + bRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + /*CM_LogMsg(LOG_ERROR, "QUEUE_RING QUEUE_RING_Lock_Time Ret:%d\r\n", bRet, 0, 0, 0, 0, 0);*/ + } + if (CM_TRUE == bRet) + { + pQueue->m_pDataCache = (UINT8 *)malloc(pQueue->m_dwMaxBufferLenth + 1); /* ˴һ Ϊжж ֤ʵʵĻС */ + if (NULL == pQueue->m_pDataCache) + { + bRet = CM_FALSE; + CM_LogMsg(LOG_ERROR, "QUEUE_RING CM_malloc ERROR Len:%d\r\n", pQueue->m_dwMaxBufferLenth + 1, 0, 0, 0, 0, 0); + } + else + { + CommonMemSet(pQueue->m_pDataCache, pQueue->m_dwMaxBufferLenth + 1, 0, pQueue->m_dwMaxBufferLenth + 1); + QUEUE_RING_SetEmpty(pQueue); + pQueue->m_IfCoverQueueFull = CM_TRUE; /*/Ĭжʱԭ*/ + pQueue->m_QueueState = QUEUE_RING_STATE_Empty; + pQueue->m_bIsInited = CM_TRUE; + pQueue->m_pHeadOffset = 0; + pQueue->m_pTailOffset = 0; +#ifdef RQ_TASK_SAFE + pQueue->m_hMutexHanle = (CM_THREAD)NULL; +#endif + QUEUE_RING_UnLock(pQueue); + } + } + return bRet; +} + +/************************************************************************ +ܣͷָṹĻζռڴ +ͷָṹĻζռڴ +룺 + QueueRingID pQueue ζнṹָ + +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +CM_BOOL QUEUE_RING_Release(IN QueueRingID pQueue) +{ + CM_BOOL bRet = CM_TRUE; + if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited) + ) + { + bRet = CM_FALSE; + } + if (CM_TRUE == bRet) + { + bRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == bRet) + { + if (pQueue->m_pDataCache != NULL) + { + free(pQueue->m_pDataCache); + pQueue->m_pDataCache = NULL; + } + + pQueue->m_dwDataLenth = 0U; /* Чݳ */ + pQueue->m_pHeadOffset = 0U; /* /ͷλָ */ + pQueue->m_pTailOffset = 0U; /* βλָ */ + QUEUE_RING_UnLock(pQueue); + } + return bRet; +} + +/************************************************************************ +ܣͷָṹĻζռڴ +ͷָṹĻζռڴ +룺 + QueueRingID pQueue ζнṹָ + +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +UINT8 QUEUE_RING_SetEmpty(IN QueueRingID pQueue) +{ + CM_BOOL bRet = CM_TRUE; + if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited) + ) + { + bRet = CM_FALSE; + } + if (CM_TRUE == bRet) + { + bRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == bRet) + { + pQueue->m_dwDataLenth = 0U; + pQueue->m_pHeadOffset = 0U; + pQueue->m_pTailOffset = 0U; + pQueue->m_QueueState = QUEUE_RING_STATE_Empty; + QUEUE_RING_UnLock(pQueue); + } + return bRet; +} + +/************************************************************************ +ܣжͷȡһ Dzже +жͷȡһ Dzже +룺 + IN QueueRingID pQueue, ζнṹָ + IN const UINT32 mOutBufMaxLenth, ΪmOutBufferڴ泤ȵֵ + IN const UINT32 mReadLenth, Ϊȡݵij + IN const UINT32 mReadStartoff ȡʱָƫ Ĭ0 + + OUT UINT8 * mOutBuffer, Ϊⲿbuffer ݸƽȥ + OUT UINT32 * mOutReadLen, ȡbuff +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +UINT8 QUEUE_RING_ReadOnly(IN QueueRingID pQueue, + OUT UINT8 * pOutBuffer, + OUT UINT32 * dwOutReadLen, + IN const UINT32 dwOutBufMaxLenth, + IN const UINT32 dwReadLenth, IN const UINT32 dwReadStartoff /*ȡָƫ*/) +{ + UINT8 mbRet = CM_TRUE; + UINT32 dwReadLen = 0; + UINT32 dwReadPos = 0; + INT32 iCounter = 0; + if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited) + || (NULL == pQueue->m_pDataCache) + || (NULL == pOutBuffer) + || (pQueue->m_dwDataLenth <= 0) /*û ȡ*/ + ) + { + mbRet = CM_FALSE; + } + if (CM_TRUE == mbRet) + { + mbRet = (UINT8)QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == mbRet) /*ɹ ܼκ*/ + { + + if (dwOutBufMaxLenth < dwReadLenth) + { + mbRet = QUEUE_RING_STATE_MSG_BUF_OUTOFLENTH; /* /Խ */ + dwReadLen = dwOutBufMaxLenth; /* /СĶȡ */ + /*ASSERT(0);*/ + } + else + { + dwReadLen = dwReadLenth; + } + /* /ȡЧݳȵ ಻Чݳ */ + /* ȡ+ȡʼƫ ܳ */ + if (dwReadLen + dwReadStartoff > pQueue->m_dwDataLenth) + { + if (dwReadStartoff <= pQueue->m_dwDataLenth) + { + dwReadLen = pQueue->m_dwDataLenth - dwReadStartoff; + mbRet = QUEUE_RING_STATE_READ_OK; /* OK */ + } + else /* mReadStartoff Ѿ Խ */ + { + dwReadLen = 0U; /* /ȡ */ + mbRet = QUEUE_RING_STATE_MSG_BUF_OUTOFLENTH; /* /Խ */ + } + } + else + { + mbRet = QUEUE_RING_STATE_READ_OK; /* OK */ + } + + for (iCounter = 0; iCounter < (INT32)dwReadLen; iCounter++) + { + dwReadPos = (pQueue->m_pHeadOffset + dwReadStartoff + iCounter) % (pQueue->m_dwMaxBufferLenth + 1); + pOutBuffer[iCounter] = pQueue->m_pDataCache[dwReadPos]; + } + /*CM_LogMsg(0, "RING BUF READ %d\r\n", dwReadLen, 0, 0, 0, 0, 0);*/ + QUEUE_RING_UnLock(pQueue); + } + if (dwOutReadLen != NULL) + { + *dwOutReadLen = dwReadLen; /* ⲿ */ + } + return mbRet; +} + +/************************************************************************ +ܣджӵβ 򸲸 +джӵβ 򸲸 +룺 + IN QueueRingID pQueue, ζнṹָ + IN const UINT8 * mbuffer, Ҫде + IN const UINT32 mLenth ݳ + +ֵΪ״̬Ϣenum _RING_QUEUE_STATE_ 1Ϊɹ ֵ쳣 +************************************************************************/ +UINT8 QUEUE_RING_Write(IN QueueRingID pQueue, IN const UINT8 * pbuffer, IN const UINT32 dwLenth) +{ + UINT8 mbRet = CM_TRUE; + /*CM_LogMsg(0, "RING BUF WRITE In 1 %d\r\n", 0, 0, 0, 0, 0, 0);*/ + if((NULL == pQueue) || (NULL == pbuffer)) + { + mbRet = CM_FALSE; + } + else + { + mbRet = CM_TRUE; + } + if (CM_TRUE == mbRet) + { + if((CM_TRUE != pQueue->m_bIsInited) + || (NULL == pQueue->m_pDataCache)) + { + mbRet = CM_FALSE; + CM_LogMsg(0, "RING WRITE ERROR pQueue=%X,m_bIsInited=%d,m_pDataCache=%X \r\n", (INT32)pQueue, pQueue->m_bIsInited, (INT32)pQueue->m_pDataCache, 0, 0, 0); + } + } + if (CM_TRUE == mbRet) + { + mbRet = (UINT8)QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + /*CM_LogMsg(0, "RING BUF WRITE Lock %d\r\n", 0, 0, 0, 0, 0, 0);*/ + } + if (CM_TRUE == mbRet) + { + + UINT32 dwWriteLen = dwLenth; + UINT32 dwStartWrite = 0U; + /*CM_UINT32 dwWritePos = 0;*/ + INT32 iCounter = 0U; + /*CM_LogMsg(0, "RING BUF WRITE Lock OK %d\r\n", 0, 0, 0, 0, 0, 0);*/ + + /* Ҫ жܳ ǰ ֻжӳȵ ж֮ǰ */ + if (dwWriteLen >= pQueue->m_dwMaxBufferLenth) + { + dwStartWrite = dwWriteLen - pQueue->m_dwMaxBufferLenth; + dwWriteLen = pQueue->m_dwMaxBufferLenth; + pQueue->m_pHeadOffset = 0U; /* /ͷλָ */ + pQueue->m_pTailOffset = 0U; /* /ͷλָ */ + pQueue->m_dwDataLenth = 0U; + mbRet = QUEUE_RING_STATE_MSG_BUF_OUTOFLENTH; + } + else /* /ҪдݳСڶܳ */ + { + if (pQueue->m_dwDataLenth + dwWriteLen > pQueue->m_dwMaxBufferLenth) /* Ҫд+Ѿ 󳤶 ˵Ҫ */ + { + if (CM_FALSE == pQueue->m_IfCoverQueueFull) /* / Ҫ޸дݳ ±֤дݵʣгȼ */ + { + /* mWriteLen= mWriteLen-(m_DataLenth + mWriteLen -m_MaxBufferLenth); */ + dwWriteLen = pQueue->m_dwMaxBufferLenth - pQueue->m_dwDataLenth; /* ʽ ͬ */ + mbRet = QUEUE_RING_STATE_FULL_WRITE; + } + } + } + if ((pQueue->m_pDataCache != NULL) + /* && (dwWriteLen <= (pQueue->m_MaxBufferLenth - pQueue->mStartData + 1))*/ /* /дݳ ҪС 󳤶-д */ + && (dwWriteLen > 0) /*жҪд*/ + && (dwWriteLen <= (dwLenth - dwStartWrite)) /* /д볤 ҪС ⲿݵ󳤶-ȡ */ + ) + { + for (iCounter = 0; iCounter < (INT32)dwWriteLen; iCounter++) + { + /*˴ж϶ дҪ ƶͷָ*/ + if (QUEUE_RING_IsFull(pQueue)) + { + pQueue->m_pHeadOffset = (pQueue->m_pHeadOffset + 1) % (pQueue->m_dwMaxBufferLenth + 1); + pQueue->m_dwDataLenth -= 1; + } + + pQueue->m_pDataCache[pQueue->m_pTailOffset] = pbuffer[dwStartWrite + iCounter]; + pQueue->m_pTailOffset = (pQueue->m_pTailOffset + 1) % (pQueue->m_dwMaxBufferLenth + 1); + pQueue->m_dwDataLenth += 1; + } + /* pQueue->m_dwDataLenth += dwWriteLen; */ /*ЧݳҪϴ˴cpy */ + mbRet = QUEUE_RING_STATE_WRITE_OK; + } + else + { + mbRet = QUEUE_RING_STATE_WRITE_ERROR; + } + /*CM_LogMsg(0, "RING BUF WRITE %d\r\n", dwWriteLen, 0, 0, 0, 0, 0);*/ + QUEUE_RING_UnLock(pQueue); + }/*lock*/ + return mbRet; +} /*QUEUE_RING_Write*/ + +/************************************************************************ +ܣж϶ǷΪ +ж϶ǷΪ +룺 + IN QueueRingID pQueue ζнṹָ + +ֵCM_BOOL true- false- +************************************************************************/ +CM_BOOL QUEUE_RING_IsFull(IN QueueRingID pQueue) +{ + CM_BOOL mIsFull = CM_FALSE; + CM_BOOL bRet = CM_TRUE; + if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited) + ) + { + bRet = CM_FALSE; + } + else /*(CM_TRUE == bRet)*/ + { + bRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == bRet) + { + if (pQueue->m_dwDataLenth >= pQueue->m_dwMaxBufferLenth) + { + mIsFull = CM_TRUE; + } + + QUEUE_RING_UnLock(pQueue); + } + return mIsFull; +} + +/************************************************************************ +ܣȡжеݲӦ ʵƶָƫ +ȡжеݲӦ ʵƶָƫ +룺 + IN QueueRingID pQueue, ζнṹָ + IN const UINT32 mOutBufMaxLenth, ΪmOutBufferڴ泤ȵֵ + IN const UINT32 mReadLenth, Ϊȡݵij + IN const UINT32 mReadStartoffȡʱָƫ Ĭ0 + + OUT UINT8 * mOutBuffer, Ϊⲿbuffer ݸƽȥ + OUT UINT32 * mOutReadLen, ȡbuff +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +UINT8 QUEUE_RING_Read(IN QueueRingID pQueue, + OUT UINT8 * pOutBuffer, OUT UINT32 * dwOutReadLen, /* ȡbuff */ + IN const UINT32 dwOutBufMaxLenth, IN const UINT32 dwReadLenth, + IN const UINT32 dwReadStartoff /*ȡָƫ*/) +{ + UINT8 mbRet = QUEUE_RING_STATE_READ_ERROR; + UINT8 mdeleteRet = QUEUE_RING_STATE_EXCUTE_FAIL; + UINT32 dwDeletedLen = 0; + + mbRet = QUEUE_RING_ReadOnly(pQueue, pOutBuffer, dwOutReadLen, dwOutBufMaxLenth, dwReadLenth, dwReadStartoff); + if (CM_FALSE != mbRet) + { + mdeleteRet = QUEUE_RING_Delete(pQueue, *dwOutReadLen + dwReadStartoff, &dwDeletedLen);/*Ҫȡݺƫܺ*/ + if ((QUEUE_RING_STATE_EXCUTE_OK != mdeleteRet) + || (dwDeletedLen != *dwOutReadLen + dwReadStartoff) + ) + { + mbRet = QUEUE_RING_STATE_READ_ERROR; + } + } + return mbRet; +} + +/************************************************************************ +ܣƶָ ɾ +ƶָ ɾ* ʵֻƶָλ ͷκ +룺 + IN QueueRingID pQueue, ζнṹָ + IN const UINT32 mDeletedLenth, Ҫݳ + + OUT UINT32 * mDeletedLenʵɾݳ ȷ NULLʾ +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +UINT8 QUEUE_RING_Delete(IN QueueRingID pQueue, IN const UINT32 dwDeletedLenth, OUT UINT32 * dwDeletedLen /* = NULL*/) +{ + UINT8 mbRet = CM_TRUE; + if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited) + ) + { + mbRet = CM_FALSE; + } + else /*(CM_TRUE == bRet)*/ + { + mbRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == mbRet) + { + UINT32 dwMoveDis = dwDeletedLenth; + /* ƶ಻Чݳ */ + if (dwDeletedLenth > pQueue->m_dwDataLenth) + { + dwMoveDis = pQueue->m_dwDataLenth; + mbRet = QUEUE_RING_STATE_MSG_BUF_OUTOFLENTH; + } + else + { + mbRet = QUEUE_RING_STATE_EXCUTE_OK; + } + + /* ƶ ͷָƫ С󳤶 */ + pQueue->m_pHeadOffset = ((pQueue->m_pHeadOffset + dwMoveDis) % (pQueue->m_dwMaxBufferLenth + 1)); + /* if (pQueue->m_pHeadOffset + dwMoveDis <= pQueue->m_dwMaxBufferLenth) + { + pQueue->m_pHeadOffset += dwMoveDis; + } + else + { + pQueue->m_pHeadOffset = (dwMoveDis + pQueue->m_pHeadOffset) - pQueue->m_dwMaxBufferLenth - 1; / * /0λҲҪһλ * / + }*/ + + pQueue->m_dwDataLenth -= dwMoveDis; + if (dwDeletedLen != NULL) + { + *dwDeletedLen = dwMoveDis; + } + QUEUE_RING_UnLock(pQueue); + } + else + { + mbRet = QUEUE_RING_STATE_LOCK_ERR; + /* /Ӧʧ */ + } + return mbRet; +} + +/************************************************************************ +ܣõζеݳ +õζеݳ +룺 + IN QueueRingID pQueue, ζнṹָ + +ֵUINT32 +************************************************************************/ +UINT32 QUEUE_RING_GetLenth(IN QueueRingID pQueue) +{ + CM_BOOL bRet = CM_TRUE; + UINT32 dwDataLenth = 0; + if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited) + ) + { + bRet = CM_FALSE; + } + else /*(CM_TRUE == bRet)*/ + { + bRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == bRet) + { + + if (pQueue->m_pTailOffset >= pQueue->m_pHeadOffset) + { + dwDataLenth = (pQueue->m_pTailOffset - pQueue->m_pHeadOffset); + } + else + { + dwDataLenth = pQueue->m_dwMaxBufferLenth+1 - (pQueue->m_pHeadOffset - pQueue->m_pTailOffset);/*0λҲҪվһλ m_MaxBufferLenth λҲ*/ + } + + if (dwDataLenth != pQueue->m_dwDataLenth) + { + /* 㷨 */ + CM_LogMsg(9, "ERROR:QUEUE_RING_Lenth,DataLen=%d,DatalenCal=%d,Head=%d,Tail=%d\r\n", + pQueue->m_dwDataLenth, dwDataLenth, + pQueue->m_pHeadOffset, pQueue->m_pTailOffset, 0, 0 + ); + + } + + QUEUE_RING_UnLock(pQueue); + } + return dwDataLenth; +} + +/************************************************************************ +ܣж϶ǷΪ +ж϶ǷΪ +룺 + IN QueueRingID pQueue, ζнṹָ + +ֵCM_BOOL true- false- +************************************************************************/ +CM_BOOL QUEUE_RING_IsEmpty(IN QueueRingID pQueue) +{ + CM_BOOL bRet = CM_TRUE; + CM_BOOL mIsEmpty = CM_FALSE; + UINT32 dwDataLenth = 0; + if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited) + ) + { + bRet = CM_FALSE; + } + else /*(CM_TRUE == bRet)*/ + { + bRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == bRet) + { + if (pQueue->m_pTailOffset == pQueue->m_pHeadOffset) + { + mIsEmpty = CM_TRUE; + } + else + { + mIsEmpty = CM_FALSE; + } + + QUEUE_RING_UnLock(pQueue); + } + else + { + + } + return mIsEmpty; +} + +/************************************************************************ +ܣõͷָƫƶٵCM_UINT8ָ +õͷָƫƶٵCM_UINT8ָ +룺 + QueueRingID pQueue ζнṹָ + const UINT32 dwHeadoffset ƫ + +ֵͷָƫƶٵCM_UINT8ָ +************************************************************************/ +const static UINT8 * QUEUE_RING_GetIndexBytePtrInside(IN QueueRingID pQueue, IN const UINT32 dwHeadoffset) +{ + /* úڲ κβЧԼ ֱӷؽ Ч*/ + /*const CM_UINT8 * pDataPrtRet = NULL; + pDataPrtRet = ;*/ + return (pQueue->m_pDataCache + ((pQueue->m_pHeadOffset + dwHeadoffset) % (pQueue->m_dwMaxBufferLenth + 1))); +} + +/************************************************************************ +ܣõͷָƫƶٵCM_UINT8ָ +õͷָƫƶٵCM_UINT8ָ +룺 + QueueRingID pQueue ζнṹָ + const UINT32 mHeadoffset ƫ + +ֵͷָƫƶٵCM_UINT8ָ +************************************************************************/ +const UINT8 * QUEUE_RING_GetIndexBytePtr(IN QueueRingID pQueue, IN const UINT32 dwHeadoffset) +{ + CM_BOOL bRet = CM_TRUE; + const UINT8 * pDataPrtRet = NULL; + UINT32 dwDataLenth = 0; + if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited) + ) + { + bRet = CM_FALSE; + } + else /*(CM_TRUE == bRet)*/ + { + bRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == bRet) + { + if (dwHeadoffset < pQueue->m_dwDataLenth) /* ݵ² ƫСЧݳȲ */ + { + pDataPrtRet = QUEUE_RING_GetIndexBytePtrInside(pQueue, dwHeadoffset); + /*if (pQueue->m_pHeadOffset + dwHeadoffset <= pQueue->m_dwMaxBufferLenth) + { + pDataPrtRet = pQueue->m_pDataCache + pQueue->m_pHeadOffset + dwHeadoffset; + } + else/ *лβ* / + { + pDataPrtRet = pQueue->m_pDataCache + pQueue->m_pHeadOffset + dwHeadoffset - pQueue->m_dwMaxBufferLenth - 1;/ *0Ҳռһλ* / + }*/ + } + QUEUE_RING_UnLock(pQueue); + } + return pDataPrtRet; +} + +/************************************************************************ +ܣظͷַָ Ϊձʾû +ظͷַָ Ϊձʾû +룺 + QueueRingID pQueue ζнṹָ + +ֵͷַָ +************************************************************************/ +const UINT8 * QUEUE_RING_GetHeadBytePtr(IN QueueRingID pQueue) +{ + return QUEUE_RING_GetIndexBytePtr(pQueue, 0);/*ͷָ뼴0*/ +} + +/************************************************************************ +ܣ軷νṹ +Ļνṹָʱ Իνṹ +룺 + QueueRingID pQueue ζнṹָ + UINT32 dwWaitTime ʱ + +ֵCM_TRUE ɹCM_FALSE ʧ +************************************************************************/ +CM_BOOL QUEUE_RING_Lock_Time(IN QueueRingID pQueue, IN UINT32 dwWaitTime) +{ + CM_BOOL bRet = CM_TRUE; +#ifdef RQ_TASK_SAFE + CM_THREAD hThread = (CM_THREAD)NULL; + if (!pQueue->m_bUseMutex) + { + return CM_TRUE; + } + + + if ((NULL == pQueue) + || (NULL == pQueue->m_DataMutex) + ) + { + bRet = CM_FALSE; + } + else /*(CM_TRUE == bRet)*/ + { +#ifdef VXWORKS + hThread = taskIdSelf(); + if (pQueue->m_hMutexHanle == hThread) + { + bRet = CM_TRUE; + } + else + { + bRet = CM_Mutex_Lock_Time(pQueue->m_DataMutex, dwWaitTime); + } + if (CM_TRUE == bRet) + { + pQueue->m_hMutexHanle = hThread; + } + /* CM_LogMsg(0, "Lock %X bRet%d,m_hMutexHanle:%X,hThread:%X\r\n", pQueue, bRet, pQueue->m_hMutexHanle, hThread, 0, 0);*/ +#endif /* VXWORKS */ + } + +#endif + return bRet; +} + +/************************************************************************ +ܣ軷νṹ +軷νṹ +룺 + QueueRingID pQueue ζнṹָ + +ֵCM_TRUE ɹCM_FALSE ʧ +************************************************************************/ +CM_BOOL QUEUE_RING_UnLock(IN QueueRingID pQueue) +{ + CM_BOOL bRet = CM_TRUE; +#ifdef RQ_TASK_SAFE + if (!pQueue->m_bUseMutex) + { + return CM_TRUE; + } + + if ((NULL == pQueue) + || (NULL == pQueue->m_DataMutex) + ) + { + bRet = CM_FALSE; + } + else /*(CM_TRUE == bRet)*/ + { + bRet = CM_Mutex_Unlock(pQueue->m_DataMutex); + +#ifdef VXWORKS + + /* CM_LogMsg(0, "UnLock %X bRet:%d,m_hMutexHanle%X\r\n", pQueue,bRet, pQueue->m_hMutexHanle, 0, 0, 0);*/ + if (CM_TRUE == bRet) + { + pQueue->m_hMutexHanle = NULL; + } +#endif + } +#endif + return bRet; +} + +/************************************************************************ +ܣʼݲ +ʼݲ +룺 + QueueRingID pQueue ζнṹָ + +ֵCM_TRUE ɹCM_FALSE ʧ +************************************************************************/ +CM_BOOL QUEUE_RING_Mutex_Init(IN QueueRingID pQueue) +{ + CM_BOOL bRet = CM_TRUE; +#ifdef RQ_TASK_SAFE + if (pQueue->m_bUseMutex) + { + bRet = CM_Mutex_Init(&pQueue->m_DataMutex); + } +#endif + return bRet; +} + +/************************************************************************ +ܣַָڻνṹеλ +ַָڻνṹеλ +룺 + QueueRingID pQueue ζнṹָ + INT32 iTempIndex ʱ + const UINT8 * pSubBytes ַָ + const UINT32 dwSubLenth ַ + const UINT32 dwSearchOffset ƫ + UINT32 mainLenth ܳ + const UINT8 * _pTableDir ָ + const CM_BOOL bSearchDir Ƿ + +ֵλ +************************************************************************/ +static INT32 QUEUE_RING_SearchByte_Sub(IN QueueRingID pQueue, + IN INT32 iTempIndex, + IN const UINT8 * pSubBytes, + IN const UINT32 dwSubLenth, + IN const UINT32 dwSearchOffset, + IN UINT32 mainLenth, + IN const UINT8 * _pTableDir, + IN const CM_BOOL bSearchDir) +{ + const UINT8 *mTempMainPtr = NULL; + INT32 i = 0; + INT32 moveIndex = 0; + INT32 iRet = -1; + CM_BOOL bFlag = CM_FALSE; + + if (CM_TRUE == bSearchDir) + { + while (iTempIndex + dwSubLenth <= mainLenth) + { + for (i = 0; i < (INT32)dwSubLenth; i++) + { + mTempMainPtr = QUEUE_RING_GetIndexBytePtrInside(pQueue, (UINT32)(iTempIndex + i)); + if (pSubBytes[i] != *mTempMainPtr) + { + break; + } + else + { + + } + } + bFlag = CM_FALSE; + if (i == dwSubLenth) /* /жϵCM_UINT8һλͬ */ + { + iRet = (INT32)iTempIndex; + bFlag = CM_TRUE; + } + else + { + /*ƶִԱȵַ*/ + mTempMainPtr = QUEUE_RING_GetIndexBytePtrInside(pQueue, (UINT32)iTempIndex + (UINT32)dwSubLenth); + moveIndex = _pTableDir[*mTempMainPtr]; + if (moveIndex == 0) + { + bFlag = CM_TRUE; + } + } + if(CM_TRUE == bFlag) + { + break; + } + iTempIndex = iTempIndex + moveIndex; + }/*while*/ + } + else + { + while (((INT32)(iTempIndex - dwSubLenth + 1) >= 0)) + { + for (i = 0; i < (INT32)dwSubLenth; i++) + { + mTempMainPtr = QUEUE_RING_GetIndexBytePtrInside(pQueue, (UINT32)(iTempIndex - i)); + if (pSubBytes[dwSubLenth - i - 1] != *mTempMainPtr) + { + break; + } + else + { + + } + } + bFlag = CM_FALSE; + if (i == dwSubLenth) /* /жϵCM_UINT8һλͬ */ + { + iRet = (INT32)iTempIndex - (INT32)dwSubLenth + 1; /*˴ΪĩβַѾռһλ*/ + bFlag = CM_TRUE; + } + else + { + /*ƶִԱȵַ*/ + mTempMainPtr = QUEUE_RING_GetIndexBytePtrInside(pQueue, (UINT32)(iTempIndex - dwSubLenth)); + moveIndex = _pTableDir[*mTempMainPtr]; + if (moveIndex == 0) + { + bFlag = CM_TRUE; + } + } + if(CM_TRUE == bFlag) + { + break; + } + iTempIndex = iTempIndex - moveIndex; + }/*while*/ + } + return iRet; +} + +/************************************************************************ +ܣ + +룺 + IN QUEUE_RING_DATA_STRUCT * pQueue,ζнṹָ + IN const CM_UINT8 *msubBytes,ַ + IN const CM_UINT32 msubLenth,ִ + IN const CM_UINT32 mSearchOffset ƫ + IN const CM_BOOL bSearchDir ָ + +ֵΪִӦƫ ڷ-1 +************************************************************************/ +INT32 QUEUE_RING_SearchByte(IN QueueRingID pQueue, + IN const UINT8 * pSubBytes, + IN const UINT32 dwSubLenth, + IN const UINT8 * _pTableDir, /*_TableDir ҹؼֵ ҪpreCompute ʼ СΪ256*/ + IN const UINT32 dwSearchOffset, + IN const CM_BOOL bSearchDir /*ָ CM_TRUE */) +{ + INT32 iRet = -1; + UINT32 subLenth = 0; + UINT32 mainLenth = 0; + INT32 iTempIndex = 0; + /*CM_INT32 iTempByteOff = 0; + CM_UINT32 dwSubIndex = 0;*/ + const UINT8 *mmainBytes = NULL; + /*const CM_UINT8 *mTempMainPtr = NULL; */ + /*const CM_UINT8 *mTempMainBytes = mmainBytes;*/ + /* + CM_INT32 i = 0; + CM_INT32 moveIndex = 0; */ + mainLenth = QUEUE_RING_GetLenth(pQueue); + subLenth = dwSubLenth; + + if (CM_TRUE == bSearchDir) + { + iTempIndex = dwSearchOffset; + } + else + { + iTempIndex = mainLenth - dwSearchOffset - 1; /*βʼ ֱӶȡһλ*/ + } + if (0 == dwSubLenth) + { + iRet = iTempIndex; + } + else + { + mmainBytes = QUEUE_RING_GetIndexBytePtr(pQueue, iTempIndex); + if ((subLenth <= 0) || (mainLenth <= 0) + || (mmainBytes == NULL) || (pSubBytes == NULL) + || (_pTableDir == NULL) + || (iTempIndex >= (INT32)mainLenth) /* ƫƲܴ Чݳ */ + || (dwSearchOffset > mainLenth) /*ʼƫƲܴ*/ + ) + { + iRet = -1; + } + else if ((NULL == pQueue) + || (CM_TRUE != pQueue->m_bIsInited)/* TO BE DONE ĺÿ */ + ) + { + iRet = -1; + } + else /*(CM_TRUE == bRet)*/ + { + iRet = QUEUE_RING_Lock_Time(pQueue, TIMEOUT_SINGLE_LOCK_RING_BUFF); + } + if (CM_TRUE == iRet) + { + iRet = QUEUE_RING_SearchByte_Sub(pQueue, iTempIndex, pSubBytes, + dwSubLenth, dwSearchOffset, + mainLenth, _pTableDir, + bSearchDir + ); + QUEUE_RING_UnLock(pQueue); + } + } + return iRet; +} + +/************************************************************************ +ܣʼ +ʼ +룺 + IN const UINT8* msubBytes, ַ + IN const UINT32 subLenth,ִ + IN const CM_BOOL bSearchDir ָ CM_TRUE + + OUT UINT8 *_TableDir, +ֵ +************************************************************************/ +void QUEUE_RING_preCompute(IN const UINT8* msubBytes, + IN const UINT32 subLenth, + OUT UINT8 *_TableDir, + IN const CM_BOOL bSearchDir /*ָ*/) +{ + UINT32 dwCounter = 0; + for (dwCounter = 0; dwCounter < MAX_UNSIGNED_CHAR_SIZE; dwCounter++) + { + _TableDir[dwCounter] = (UINT8)(subLenth + 1); + } + if (CM_TRUE == bSearchDir) + { + for (dwCounter = 0; dwCounter < subLenth; dwCounter++) + { + _TableDir[msubBytes[dwCounter]] = (UINT8)(subLenth - dwCounter); + } + } + else + { + /**/ + for (dwCounter = 0; dwCounter < subLenth; dwCounter++) + { + _TableDir[msubBytes[subLenth - dwCounter - 1]] = (UINT8)(subLenth - dwCounter); + } + } +} diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_RingQueue.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_RingQueue.h new file mode 100644 index 0000000..e091f32 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_RingQueue.h @@ -0,0 +1,223 @@ +/** ****************************************************** +* +* ļ CM_RingQueue.c +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* ζд +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#ifndef __CM_RING_QUEUE__H +#define __CM_RING_QUEUE__H + +#include "CM_Base.h" + + + +/*#define MUTEX_QUEUE_OPEN*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /*< __cplusplus */ + + +#define TIMEOUT_SINGLE_LOCK_RING_BUFF (50) /* ʱ */ /*%RELAX*/ + +#define MAX_QUEUE_BUFFER_LENTH (1024 * 64U) /* ж󳤶 64KB ֹʼ ϵͳ */ /*%RELAX*/ +#define _DEFAULT_QEUEUE_RING_BUFFER_LENTH (32 * 1024U) /*Ĭϻ󳤶 CM_UINT8Ϊλ*/ /*%RELAX*/ + +#ifndef MAX_UNSIGNED_CHAR_SIZE +#define MAX_UNSIGNED_CHAR_SIZE 256 /* һCM_UINT8 ܹ 256 */ /*%RELAX*/ +#endif + + typedef enum QUEUE_RING_STATE_ENUM_ + { + QUEUE_RING_STATE_EXCUTE_FAIL = 0x00, /* ʾִʧ */ + QUEUE_RING_STATE_EXCUTE_OK = 0x01, /* ʾһִгɹ */ + QUEUE_RING_STATE_Empty = 0x10, /*п*/ + QUEUE_RING_STATE_READ_OK = QUEUE_RING_STATE_EXCUTE_OK, /*ȡɹ*/ + QUEUE_RING_STATE_Data = 0x11, /**/ + QUEUE_RING_STATE_WRITE_OK = QUEUE_RING_STATE_EXCUTE_OK, /*дɹ*/ + QUEUE_RING_STATE_MSG_BUF_ERR = 0x10, /*쳣*/ + QUEUE_RING_STATE_MSG_BUF_OUTOFLENTH = 0x20, /*ݳȳж󻺳 ǰ ֻжӴСͬ*/ + QUEUE_RING_STATE_MSG_NOFIND = 0x30, /*Ϣδ*/ + QUEUE_RING_STATE_FULL = 0x40, /**/ + QUEUE_RING_STATE_FULL_WRITE = 0x50, /* жҸд */ + QUEUE_RING_STATE_LOCK_ERR = 0x60, /*쳣*/ + QUEUE_RING_STATE_READ_ERROR = 0x70, /*жȡ쳣*/ + QUEUE_RING_STATE_WRITE_ERROR = 0x80, /*д쳣*/ + QUEUE_RING_STATE_JAM = 0x90, /* жʱ */ + QUEUE_RING_STATE_NORMAL = 0xA1 /*״̬*/ + }QUEUE_RING_STATE; + + typedef struct QUEUE_RING_DATA_STRUCT_ + { + CM_BOOL m_bIsInited; /*ʼ*/ + UINT8 * m_pDataCache; /* ݴָ */ + UINT32 m_dwMaxBufferLenth; /* ѭжӵĻ󳤶 ҲжܴϢ */ + UINT32 m_dwDataLenth; /* Чݳ */ + UINT32 m_pHeadOffset; /* ͷλָ */ + UINT32 m_pTailOffset; /* βλָ */ + CM_BOOL m_bUseMutex; /* ǷʹݻⱣ*/ + UINT8 m_IfCoverQueueFull; /*ǵжʱǷ񸲸ԭȵ ߶*/ + UINT8 m_QueueState; /* ж״̬ */ +#ifdef RQ_TASK_SAFE + CM_THREAD m_hMutexHanle; /**/ + MUTEX_CM m_DataMutex; /* ݲⱣ */ +#endif + }QUEUE_RING_DATA_STRUCT; + + typedef QUEUE_RING_DATA_STRUCT * QueueRingID; + + /*ζгʼ ṹָ ָдС + 룺QueueRingID pQueue ζнṹָ + const UINT32 mMaxBufferLenth ʼζеĴС + + ֵ1Ϊɹ ֵ쳣*/ + CM_BOOL QUEUE_RING_Init(/*ζнṹָ*/IN QueueRingID pQueue, + /*ʼζеĴС*/IN const UINT32 mMaxBufferLenth); + + + /*ͷָṹĻζռڴ + 룺QueueRingID pQueue ζнṹָ + + ֵ1Ϊɹ ֵ쳣*/ + CM_BOOL QUEUE_RING_Release(/*ζнṹָ*/IN QueueRingID pQueue); + + /* õʱ ݸ 1Ϊɹ ֵ쳣*/ + /* CM_UINT8 QUEUE_RING_SetCover(IN QueueRingID pQueue, IN const CM_BOOL ifCover);*/ + + /* ն + 룺QueueRingID pQueue ζнṹָ + + ֵ1Ϊɹ ֵ쳣*/ + UINT8 QUEUE_RING_SetEmpty(/*ζнṹָ*/IN QueueRingID pQueue); + + /* джӵβ 򸲸 + 룺IN QueueRingID pQueue, ζнṹָ + IN const UINT8 * mbuffer, Ҫде + IN const UINT32 mLenth ݳ + + ֵΪ״̬Ϣenum _RING_QUEUE_STATE_ 1Ϊɹ ֵ쳣*/ + UINT8 QUEUE_RING_Write(/*ζнṹָ*/IN QueueRingID pQueue, + /*Ҫде*/IN const UINT8 * mbuffer, + /*ݳ*/IN const UINT32 mLenth); + + /* + *жͷȡһ Dzже + 룺 + IN QueueRingID pQueue, ζнṹָ + IN const UINT32 mOutBufMaxLenth, ΪmOutBufferڴ泤ȵֵ + IN const UINT32 mReadLenth, Ϊȡݵij + IN const UINT32 mReadStartoff ȡʱָƫ Ĭ0 + + OUT UINT8 * mOutBuffer, Ϊⲿbuffer ݸƽȥ + OUT UINT32 * mOutReadLen, ȡbuff + ֵ1Ϊɹ ֵ쳣 */ + UINT8 QUEUE_RING_ReadOnly( /*ζнṹָ*/IN QueueRingID pQueue, + /*Ϊⲿbuffer ݸƽȥ*/OUT UINT8 * mOutBuffer, + /*ȡbuff */OUT UINT32 * mOutReadLen, + /*ΪmOutBufferڴ泤ȵֵ*/IN const UINT32 mOutBufMaxLenth, + /*Ϊȡݵij*/IN const UINT32 mReadLenth, + /*ȡʱָƫ Ĭ0*/IN const UINT32 mReadStartoff + ); + + /* ȡжеݲӦ ʵƶָƫ + 룺 + IN QueueRingID pQueue, ζнṹָ + IN const UINT32 mOutBufMaxLenth, ΪmOutBufferڴ泤ȵֵ + IN const UINT32 mReadLenth, Ϊȡݵij + IN const UINT32 mReadStartoffȡʱָƫ Ĭ0 + + OUT UINT8 * mOutBuffer, Ϊⲿbuffer ݸƽȥ + OUT UINT32 * mOutReadLen, ȡbuff + ֵ1Ϊɹ ֵ쳣*/ + UINT8 QUEUE_RING_Read( /*ζнṹָ*/IN QueueRingID pQueue, + /*Ϊⲿbuffer ݸƽȥ*/OUT UINT8 * mOutBuffer, + /*ȡbuff */OUT UINT32 * mOutReadLen, + /*ΪmOutBufferڴ泤ȵֵ*/IN const UINT32 mOutBufMaxLenth, + /*Ϊȡݵij*/IN const UINT32 mReadLenth, + /*ȡʱָƫ Ĭ0*/IN const UINT32 mReadStartoff + ); + + /* ƶָ ɾ + * ʵֻƶָλ ͷκ + : + IN QueueRingID pQueue, ζнṹָ + IN const UINT32 mDeletedLenth, Ҫݳ + + OUT UINT32 * mDeletedLenʵɾݳ ȷ NULLʾ + ֵ1Ϊɹ ֵ쳣*/ + UINT8 QUEUE_RING_Delete(/*ζнṹָ*/IN QueueRingID pQueue, + /*Ҫݳ*/ IN const UINT32 mDeletedLenth, + /*ʵɾݳ ȷ NULLʾ*/ OUT UINT32 * mDeletedLen); + + /* õζеݳ + 룺IN QueueRingID pQueue ζнṹָ + + ֵUINT32 + */ + UINT32 QUEUE_RING_GetLenth(/*ζнṹָ*/IN QueueRingID pQueue); + /* ж϶ǷΪ + 룺IN QueueRingID pQueue ζнṹָ + + ֵCM_BOOL true- false- + */ + CM_BOOL QUEUE_RING_IsEmpty(/*ζнṹָ*/IN QueueRingID pQueue); + + /* ж϶Ƿ״̬Ϊ + 룺IN QueueRingID pQueue ζнṹָ + + ֵCM_BOOL true- false-*/ + CM_BOOL QUEUE_RING_IsFull(/*ζнṹָ*/IN QueueRingID pQueue); + + /* const CM_UINT8 * QUEUE_RING_GetPrePrt(IN QueueRingID pQueue, IN const CM_UINT8 * pNowPrt);*/ + /* const CM_UINT8 * GetNextBytePtrByOff(IN const CM_UINT8 * pNowPrt,IN const CM_UINT32 moffset);ظָݵ moffset ַ ΪNULL ʾѾݶβ ûЧ + */ + + /* + 룺 + IN QUEUE_RING_DATA_STRUCT * pQueue,ζнṹָ + IN const CM_UINT8 *msubBytes,ַ + IN const CM_UINT32 msubLenth,ִ + IN const CM_UINT32 mSearchOffset ƫ + IN const CM_BOOL bSearchDir ָ + + ֵΪִӦƫ ڷ-1 + );*/ + INT32 QUEUE_RING_SearchByte(/*ζнṹָ*/IN QueueRingID pQueue, + /*ַ*/IN const UINT8 * msubBytes, + /*ִ*/IN const UINT32 msubLenth, + /* _TableDir ҹؼֵ ҪpreCompute ʼ СΪ256*/ + IN const UINT8 * _TableDir, + /*ƫ*/IN const UINT32 mSearchOffset, + /*ָ CM_TRUE */IN const CM_BOOL bSearchDir + ); + + /*ʼ + 룺 + IN const UINT8* msubBytes, ַ + IN const UINT32 subLenth,ִ + IN const CM_BOOL bSearchDir ָ CM_TRUE + + OUT UINT8 *_TableDir, + ֵ + */ + void QUEUE_RING_preCompute(/*ַ*/IN const UINT8* msubBytes, + /*ִ*/ IN const UINT32 subLenth, + /**/OUT UINT8 *_TableDir, + /*ָ CM_TRUE */ IN const CM_BOOL bSearchDir + ); + + +#ifdef __cplusplus +} +#endif /*< __cplusplus */ + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Type.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Type.h new file mode 100644 index 0000000..fcbc855 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/CM_Type.h @@ -0,0 +1,68 @@ +/** ****************************************************** +* +* ļ CM_Type.h +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* Ͷ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#ifndef _CM_TYPE_H_ +#define _CM_TYPE_H_ + +#include "CM_Define.h" + +#include +#include +#include +#include "CommonTypes.h" +#ifdef WIN32 +#include "windows.h" +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif /*< __cplusplus */ + +typedef int CM_BOOL; +typedef void CM_VOID; +typedef size_t CM_SIZE_T; + +#define CM_TRUE ((CM_BOOL)1) +#define CM_FALSE ((CM_BOOL)0) +#define CM_ERROR ((INT32)(-1)) +#define CM_OK (0) + +#define IN +#define OUT + +#ifdef WIN32 +typedef unsigned int CM_THREAD; +typedef unsigned int CM_THREAD_FUNC_RETURN; +typedef CM_THREAD_FUNC_RETURN(__stdcall* CM_THREAD_FUNC)(void* args); +#define CM_THREAD_CALL __stdcall +#endif +#ifdef QNX +typedef pthread_t CM_THREAD; +typedef void* CM_THREAD_FUNC_RETURN; +typedef CM_THREAD_FUNC_RETURN(*CM_THREAD_FUNC)(void* args); +#define CM_THREAD_CALL +#endif +#ifdef VXWORKS +typedef int CM_THREAD; +typedef int CM_THREAD_FUNC_RETURN; +typedef FUNCPTR CM_THREAD_FUNC; +#define CM_THREAD_CALL +#endif + +#ifdef __cplusplus +} +#endif /*< __cplusplus */ + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclBaseParse.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclBaseParse.c new file mode 100644 index 0000000..85c19dc --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclBaseParse.c @@ -0,0 +1,308 @@ +/** ****************************************************** +* +* ļ PrtclBaseParse.c +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* Эʼ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#include "PrtclBaseParse.h" +#include "crc.h" +#define LOG_PB 9 + +static UINT32 Prtcl_Base_ReadDataLen(IN const PRTCL_BASE_CONFID pHeadID, OUT UINT8 *mTempBuf, IN const UINT32 dwBufMax); + +/************************************************************************ +ܣЭʼ +Эʼ +룺IN OUT PRTCL_BASE_CONFID pHeadID ͨЭṹָ +ֵ1Ϊɹ ֵ쳣 +************************************************************************/ +CM_BOOL Prtcl_Base_Init(/*ͨЭϢָ*/IN OUT PRTCL_BASE_CONFID pHeadID) +{ + CM_BOOL bIfOk = CM_FALSE; + if (NULL != pHeadID) + { + /* */ + QUEUE_RING_preCompute(pHeadID->m_Head, pHeadID->m_HeadLen, pHeadID->m_HeadTable, pHeadID->m_SearchDir); + bIfOk = CM_TRUE; + } + else + { + } + return bIfOk; +} + +#if 0 +static CM_UINT32 Prtcl_Base_ReadDataLen(IN const PRTCL_BASE_CONFID pHeadID, OUT CM_UINT8 *mTempBuf, IN const CM_UINT32 dwBufMax) +{ + CM_UINT32 dwDataLen = 0; + if ((NULL != pHeadID) + &&(NULL != mTempBuf) + &&(dwBufMax > pHeadID->uReadLen) + ) + { + if ((pHeadID->uLenByte == 1) && (pHeadID->uReadLen > 1)) + { + dwDataLen = mTempBuf[pHeadID->uReadLen - 1]; + } + else if ((pHeadID->uLenByte == 2) && (pHeadID->uReadLen > 2)) + { + dwDataLen = mTempBuf[pHeadID->uReadLen - 1] + 256 * mTempBuf[pHeadID->uReadLen - 2]; /*ֽǰ,Ŀǰݳֽ*/ + } + else + { + /* CM_LogMsg(LOG_ERROR, "E:Prtcl_Base_ReadDataLen uReadLen:%d, uLenByte:%d\r\n", pHeadID->uReadLen, pHeadID->uLenByte, 0, 0, 0, 0);*/ + dwDataLen = 0; + } + dwDataLen += pHeadID->uAddLen; + } + else + { + + } + return dwDataLen; +} +#else + +/************************************************************************ +ܣȡݳ +ȡݳ +룺 + IN const PRTCL_BASE_CONFID pHeadID ʼЭ + IN const UINT32 dwBufMax ָĴС + + OUT UINT8 *mTempBuf ʱݻָ +ֵݳ +************************************************************************/ +static UINT32 Prtcl_Base_ReadDataLen(IN const PRTCL_BASE_CONFID pHeadID, OUT UINT8 *mTempBuf, IN const UINT32 dwBufMax) +{ + UINT32 dwDataLen = 0; + if ((NULL != pHeadID) + &&(NULL != mTempBuf) + &&(dwBufMax > pHeadID->uReadLen) + ) + { + if ((pHeadID->uLenByte == 1) && (pHeadID->uReadLen > 1)) + { + dwDataLen = mTempBuf[pHeadID->m_HeadLen]; + } + else if ((pHeadID->uLenByte == 2) && (pHeadID->uReadLen > 2)) + { + dwDataLen = mTempBuf[pHeadID->m_HeadLen] * 256 + mTempBuf[pHeadID->m_HeadLen+1]; /*ֽǰ,Ŀǰݳֽ*/ + } + else + { + /* CM_LogMsg(LOG_ERROR, "E:Prtcl_Base_ReadDataLen uReadLen:%d, uLenByte:%d\r\n", pHeadID->uReadLen, pHeadID->uLenByte, 0, 0, 0, 0);*/ + dwDataLen = 0; + } + dwDataLen += pHeadID->uAddLen; + } + else + { + + } + return dwDataLen; +} +#endif + +/************************************************************************ +ܣЭӻλһϢ +ͨЭģ ʹѾʼЭϢ Զݽн +룺 + IN QueueRingID pQueue,滺ݵĻζ + IN const PRTCL_BASE_CONFID pHeadID,ʼЭͷ + IN const UINT32 dwBufMax,ָĴС + + OUT UINT8 *pBuf,һ + OUT UINT32 *pBufLen ָһĴС +ֵǷɹ ɹTURE FALSE +************************************************************************/ +CM_BOOL Prtcl_Base_Check(/*ݻλ*/IN QueueRingID pQueue, + /*ͨЭϢָ*/IN const PRTCL_BASE_CONFID pHeadID, + /*洢ȡϢĻ*/OUT UINT8 *pBuf, + /**/IN const UINT32 dwBufMax, + /*Ϣ*/OUT UINT32 *pBufLen) +{ + CM_BOOL bRet = CM_FALSE; + UINT8 mTempBuf[32] = { 0 };/* ʱ ȡ*/ + UINT32 dwOutLenth = 0; + UINT32 dwDataLen = 0; + INT32 iIndexHead = -1; + INT32 iOffset = 0; + INT32 iAllLen = 0; + CM_BOOL bIfCheckAgain = CM_TRUE; + CM_BOOL bCheckState = CM_TRUE; + UINT16 calcCrc = 0; + UINT16 msgCrc = 0; + + if ((NULL == pQueue) + || (NULL == pBuf) + || (NULL == pHeadID) + ) + { + bIfCheckAgain = CM_FALSE; + } + if (NULL != pBufLen) + { + *pBufLen = 0; + } + + while (bIfCheckAgain) + { + iIndexHead = QUEUE_RING_SearchByte(pQueue, + pHeadID->m_Head, pHeadID->m_HeadLen, + pHeadID->m_HeadTable, + iOffset, /*ƫ0ʼ*/ + pHeadID->m_SearchDir /**/ + ); + if (iIndexHead < 0) + { + bIfCheckAgain = CM_FALSE; + bCheckState = CM_FALSE; + } + else + { + bCheckState = CM_TRUE; + } + if (CM_TRUE == bCheckState) + { + QUEUE_RING_ReadOnly(pQueue, mTempBuf, + &dwOutLenth, sizeof(mTempBuf), + pHeadID->uReadLen,/* ֻ4λ*/ + iIndexHead); + if (pHeadID->uReadLen == dwOutLenth) /*ȡɹ,Ⱥ*/ + { + dwDataLen = Prtcl_Base_ReadDataLen(pHeadID, mTempBuf, sizeof(mTempBuf)); + } + else + { + bCheckState = CM_FALSE; + bIfCheckAgain = CM_FALSE; + } + } + else + { + + } + if (CM_TRUE == bCheckState) + { + iAllLen = QUEUE_RING_GetLenth(pQueue) - iIndexHead; + if (iAllLen < (INT32)dwDataLen) + { + bIfCheckAgain = CM_TRUE; + bCheckState = CM_FALSE; + } + else + { + + } + } + else + { + + } + if (CM_FALSE == bCheckState) + { + /*not enough datalen*/ + } + else + { + QUEUE_RING_ReadOnly(pQueue, pBuf, &dwOutLenth, dwBufMax, dwDataLen, iIndexHead); + if (dwDataLen == dwOutLenth) + { + if (CM_TRUE == pHeadID->m_bCheckCRC) + { + calcCrc = GetCCITTCrcH(CCITT_CRC_INIT, pBuf, pHeadID->uReadLen - 2); + msgCrc = pBuf[pHeadID->uReadLen - 1] + 256 * pBuf[pHeadID->uReadLen - 2]; + if (calcCrc == msgCrc) + { + bCheckState = CM_TRUE; + } + else + { + /* CM_LogMsg(LOG_PB, "calcCrc=%04x,msgCrc=%04x\n", calcCrc, msgCrc, 0, 0, 0, 0);*/ + bCheckState = CM_FALSE; + } + + /* ȷCRCȷҲû׼ܴճ + if (CM_FALSE == bCheckState) + { + QUEUE_RING_Delete(pQueue, iIndexHead + 1, NULL); + iIndexHead = -1; + } + else + { + + }*/ + } + else + { + bCheckState = CM_TRUE; + } + } + else + { + bCheckState = CM_FALSE; + /* CM_LogMsg(LOG_PB, "Prtcl_Check Read Buf %d:%d \r\n", dwDataLen, dwOutLenth, 0, 0, 0, 0);*/ + } + if (CM_TRUE == bCheckState) /* crcУ*/ + { + if (NULL != pBufLen) + { + *pBufLen = dwOutLenth; + } + QUEUE_RING_Delete(pQueue, iIndexHead + dwDataLen, NULL); + bRet = CM_TRUE; + bIfCheckAgain = CM_FALSE; + } + else + { + + bIfCheckAgain = CM_TRUE; + } + } + if (CM_TRUE == bIfCheckAgain) + { + iOffset = iIndexHead + 1; /* ͷʼ*/ + } + else + { + + } + } /* while*/ + return bRet; +} + +/************************************************************************ +ܣRSSP2Эʼ +RSSP2Эʼ +룺 +OUT PRTCL_BASE_CONF *pHeadID ʼЭͷ +ֵǷʼɹ ɹTURE FALSE +************************************************************************/ +CM_BOOL Prtcl_RSSP2_CheckInit(OUT PRTCL_BASE_CONF *pHeadID) +{ + CM_BOOL bRet = CM_FALSE; + if (NULL != pHeadID) + { + pHeadID->m_HeadLen = 0; /* ûй̶ͷ */ + pHeadID->m_SearchDir = CM_TRUE;/* */ + pHeadID->uReadLen = 10;/* ҪʶALEͷΪ10ֽ */ + pHeadID->uLenByte = 2; /* Ϊ2ֽ */ + pHeadID->uAddLen = 2; /* + 2 = ALEܳ */ + pHeadID->m_bCheckCRC = CM_TRUE; + bRet = CM_TRUE; + } + else + { + bRet = CM_FALSE; + } + return bRet; +} diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclBaseParse.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclBaseParse.h new file mode 100644 index 0000000..533f446 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclBaseParse.h @@ -0,0 +1,88 @@ +/** ****************************************************** +* +* ļ PrtclBaseParse.h +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* Эʼ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#ifndef _PROTOCOL_BASE_PARSE_H_ +#define _PROTOCOL_BASE_PARSE_H_ + +#include "CM_RingQueue.h" + +#ifdef __cplusplus +extern "C" { +#endif + /* ʼͷϢ Ҫúðͷ + 1 ӦóʼýӿPrtcl_Init + 2 ģεøЭijʼͬʱ¼Ƿʼɹһʧܾͽʧܣ + 3 سɹ̡ + */ +#define MAX_PACKAGE_HEADorTAIL_Lenth 10 /* /ͷ߰β󳤶 */ + typedef struct _PRTCL_BASE_CONF + { + UINT8 m_Head[MAX_PACKAGE_HEADorTAIL_Lenth]; + UINT8 m_HeadTable[MAX_UNSIGNED_CHAR_SIZE]; /* ʱʹõ*/ + UINT16 m_HeadLen; /* ͷ*/ + CM_BOOL m_SearchDir; /* bSearchDir Ϊ TRUE Ϊ FALSEΪ*/ + + CM_BOOL m_bCheckCRC; /* ǷCRCУ Ĭ crcݵ2λ*/ + + UINT8 uReadLen; /*ͷ+ݳȵֽ */ + UINT8 uLenByte; /*ݳɼֽڱʾ */ /*Ŀǰദֽ*/ + UINT8 uAddLen; /*ݳ=ݳ+AddLen */ + + /* /*ʱβϢ + CM_UINT8 m_Tail[MAX_PACKAGE_HEADorTAIL_Lenth]; + CM_UINT8 m_TailTable[MAX_UNSIGNED_CHAR_SIZE]; */ + } PRTCL_BASE_CONF, *PRTCL_BASE_CONFID; + + CM_BOOL Prtcl_Base_Init(/*ͨЭṹָ*/IN OUT PRTCL_BASE_CONFID pHeadID); + + /* ͨЭģ ʹѾʼЭϢ Զݽн + 룺 + IN QueueRingID pQueue,滺ݵĻζ + IN const PRTCL_BASE_CONFID pHeadID,ʼЭͷ + IN const UINT32 dwBufMax,ָĴС + + OUT UINT8 *pBuf,һ + OUT UINT32 *pBufLen ָһĴС + ֵǷɹ ɹTURE FALSE*/ + CM_BOOL Prtcl_Base_Check(/* 滺ݵĻζ*/IN QueueRingID pQueue, + /* ʼЭͷ*/IN const PRTCL_BASE_CONFID pHeadID, + /* һ*/ OUT UINT8 *pBuf, + /* ָĴС*/IN const UINT32 dwBufMax, + /* ָһĴС*/OUT UINT32 *pBufLen + ); + + /* RSSP2Эʼ + 룺 + OUT PRTCL_BASE_CONF *pHeadID ʼЭͷ + ֵǷʼɹ ɹTURE FALSE*/ + CM_BOOL Prtcl_RSSP2_CheckInit(/* ʼЭͷ */ OUT PRTCL_BASE_CONF *pHeadID); +#if 0 + /* RSSP2ЭԶݽн + 룺 + IN QueueRingID pQueue,滺ݵĻζ + IN const UINT32 dwBufMax,ָĴС + + OUT UINT8 *pBuf,һ + OUT UINT32 *pBufLenָһĴС + ֵ:Ƿɹ ɹTURE FALSE*/ + CM_BOOL Ptrtcl_RSSP2_Check(/* 滺ݵĻζ*/IN QueueRingID pQueue, + /* һ*/ OUT UINT8 *pBuf, + /* ָĴС*/IN const UINT32 dwBufMax, + /* ָһĴС*/OUT UINT32 *pBufLen); +#endif +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclParseManage.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclParseManage.c new file mode 100644 index 0000000..7ffb748 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclParseManage.c @@ -0,0 +1,93 @@ +/** ****************************************************** +* +* ļ PrtclParseManage.c +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* ʼͷŻζ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#include "PrtclParseManage.h" + +/************************************************************************ +ܣȡζ ʱ»ζ +ȡζ ʱ»ζ +룺IN UINT32 SourceID,ԴID +OUT QueueRingID *pQID ζ +ֵTRUEɹ FALSEʧ +************************************************************************/ +CM_BOOL Prtcl_Manage_GetRQ(/*ԴID*/IN UINT32 SourceID,/*ζ*/ OUT QueueRingID *pQID) +{ + CM_BOOL rt = CM_FALSE; + UINT32 i = 0; + CM_BOOL bFlag = CM_FALSE; + STRUCT_Prtcl_RQ *pNode = NULL; + for (i = 0;i < PRTCL_RQ_NUM;i++) + { + if (CM_TRUE == Prtcl_RQ[i].bIsInit) + { + if (SourceID == Prtcl_RQ[i].SourceID) + {/* ѴRQ */ + *pQID = &Prtcl_RQ[i].RingQue; + rt = CM_TRUE; + break; + } + else + { + + } + } + else if(NULL == pNode) + { + pNode = &Prtcl_RQ[i]; + } + else + { + + } + } + if ((CM_FALSE == rt)&&(NULL != pNode)) + {/* δRQпнڵ */ + bFlag = QUEUE_RING_SetEmpty(&pNode->RingQue); + if (CM_TRUE == bFlag) + { + pNode->bIsInit = CM_TRUE; + pNode->SourceID = SourceID; + *pQID = &pNode->RingQue; + rt = CM_TRUE; + } + } + else + { + /* CM_LogMsg(LOG_WARN, "Prtcl_RQ array full\n",0,0,0,0,0,0);*/ + } + return rt; +} + +/************************************************************************ +ܣɾζ +ɾζ +룺UINT32 SourceID ԴID + +ֵTRUEɹ FALSEʧ +************************************************************************/ +CM_BOOL Prtcl_Manage_DelRQ(/*ԴID*/UINT32 SourceID) +{ + CM_BOOL rt = CM_FALSE; + UINT32 i = 0; + for (i = 0;i < PRTCL_RQ_NUM;i++) + { + if ((CM_TRUE == Prtcl_RQ[i].bIsInit) && (SourceID == Prtcl_RQ[i].SourceID)) + { + Prtcl_RQ[i].bIsInit = CM_FALSE; + Prtcl_RQ[i].SourceID = 0u; + rt = QUEUE_RING_SetEmpty(&Prtcl_RQ[i].RingQue); + } + } + return rt; +} \ No newline at end of file diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclParseManage.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclParseManage.h new file mode 100644 index 0000000..7cca5f3 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/PrtclParseManage.h @@ -0,0 +1,57 @@ +/** ****************************************************** +* +* ļ PrtclParseManage.h +* Ȩ˵ ؿƼɷ޹˾ +* 汾 1.0 +* ʱ䣺 2017.01.01 +* з +* ʼͷŻζ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#ifndef _PROTOCOL_PARSE_MANAGE_H_ +#define _PROTOCOL_PARSE_MANAGE_H_ + +#include "PrtclBaseParse.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define PRTCL_RQ_NUM (100u) +#define PRTCL_RQ_SIZE (2000u) + +typedef struct _STRUCT_Prtcl_RQ +{ + CM_BOOL bIsInit; /* ʼ־ */ + UINT32 SourceID; /* ԴID */ + QUEUE_RING_DATA_STRUCT RingQue; /* */ +/* + CM_UINT32 HeadNum; + CM_UINT32 HeadIndex[100];*/ +}STRUCT_Prtcl_RQ; + +typedef STRUCT_Prtcl_RQ* STRUCT_Prtcl_RQID; + +STRUCT_Prtcl_RQ Prtcl_RQ[PRTCL_RQ_NUM]; + +/* ȡζ ʱ»ζ +룺IN UINT32 SourceID,ԴID + OUT QueueRingID *pQID ζ +ֵTRUEɹ FALSEʧ*/ +CM_BOOL Prtcl_Manage_GetRQ(/*ԴID*/IN UINT32 SourceID,/*ζ*/ OUT QueueRingID *pQID); + +/* ɾζ +룺UINT32 SourceID ԴID + +ֵTRUEɹ FALSEʧ*/ +CM_BOOL Prtcl_Manage_DelRQ(/*ԴID*/UINT32 SourceID); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2.c new file mode 100644 index 0000000..ac54233 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2.c @@ -0,0 +1,4850 @@ +/******************************************************** +* +* ļ Rssp2.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ䣺 2016.2.22 +* з +* Rssp2Эʵ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ +#include +#include +#include "Rssp2.h" +#include "CommonMemory.h" +#include "Rssp2Struct.h" +#include "Rssp2Common.h" +#include "Convert.h" +#include "Rssp2LnkNodeMgr.h" +#include "crc.h" +#include "des.h" +#include "typeDefine.h" +#include "dsuRssp2Func.h" +#include "CommonRecord.h" +#ifdef RSSP2_DEMO +#include "log.h" +#endif + +#define MAX_EC (0xFFFFFFFFUL) /* ECֵ */ +#define MAX_SN (0xFFFFUL) /* SNֵ */ +#define MAX_TIME (0xFFFFFFFFUL) /* ʱֵ */ + +UINT8 g_ucKMACKey1[8] = KMAC1; /* g_ucKMACKey1 */ +UINT8 g_ucKMACKey2[8] = KMAC2; /* g_ucKMACKey2 */ +UINT8 g_ucKMACKey3[8] = KMAC3; /* g_ucKMACKey3 */ +UINT8 g_btRb[8] = RB; /*%RELAX*/ /* 64Rb */ +UINT8 g_btRa[8] = RA; /*%RELAX*/ /* 64λRa */ +UINT8 g_IsInited = 0; /* ǷѾʼ־ add 20160819 xb CR9590:ֹظʼ */ + +/* ϲTCP״̬״̬ʱʹõHash */ +static TCP_STATE Hash_MergeTcpState[5][5] = { + {TCP_STATE_DISCONNECTED, TCP_STATE_CONNECTING,TCP_STATE_CONNECTED,TCP_STATE_DISCONNECTING,TCP_STATE_DISCONNECTED}, + {TCP_STATE_CONNECTING, TCP_STATE_CONNECTING,TCP_STATE_CONNECTED,TCP_STATE_CONNECTING, TCP_STATE_CONNECTING}, + {TCP_STATE_CONNECTED, TCP_STATE_CONNECTED, TCP_STATE_CONNECTED,TCP_STATE_CONNECTED, TCP_STATE_CONNECTED}, + {TCP_STATE_DISCONNECTING,TCP_STATE_CONNECTING,TCP_STATE_CONNECTED,TCP_STATE_DISCONNECTING,TCP_STATE_DISCONNECTED}, + {TCP_STATE_DISCONNECTED, TCP_STATE_CONNECTING,TCP_STATE_CONNECTED,TCP_STATE_DISCONNECTED, TCP_STATE_DISCONNECTED} };/*%RELAX*/ + +/*ʱӦݰб*/ +typedef struct +{ + UINT32 DataLen; /**/ + UINT32 DstEtcsId; /*ĿEtcsId*/ + UINT8 *Packet; /*ݰ*/ +} AppOutPackets; +/*ʱӦݰбָ*/ +static AppOutPackets *gpAppOutPackets = NULL; + +/* ֲ */ + +/* ALE */ +/* ALEӿڣbuild ALEPKT */ +LOCAL UINT16 BuildAleData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, ALE_PACK_TYPE packetType, UINT8* pData, UINT16 len, UINT8 *pOutData); + +/* ALE */ +/* ALEӿڣPrase ALEPKT(ALEPKT>>>SaPdu) */ +LOCAL UINT16 ParseAleData(LPBYTE data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 btPacketType, UINT8* pucOutBuf); + +/* MASL */ +/* build Au1 SaPdu */ +LOCAL UINT16 BuildAu1SaPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT32 RandNum, UINT8* pOutData); +/* build Au2 SaPdu */ +LOCAL UINT16 BuildAu2SaPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT32 RandNum, UINT8* pOutData); +/* build Au3 SaPdu */ +LOCAL UINT16 BuildAu3SaPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData); +/* build Ar SaPdu */ +LOCAL UINT16 BuildArSaPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData); +/* build DT SaPdu */ +LOCAL UINT16 BuildDtSaPduData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 *data, UINT16 len, UINT8 *pOutData); +/* build DI SaPdu */ +LOCAL UINT16 BuildDISaPduData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 btReason, UINT8 btSubReason, UINT8 *pData); +/* build AU1 ALEPKT */ +LOCAL UINT16 BuildAu1SaiPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT32 RandNum, UINT8* pOutData); +/* build AU2 ALEPKT */ +LOCAL UINT16 BuildAu2SaiPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT32 RandNum, UINT8* pOutData); +/* build AU3 ALEPKT */ +LOCAL UINT16 BuildAu3SaiPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData); +/* build AR ALEPKT */ +LOCAL UINT16 BuildArSaiPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData); +/* build DI ALEPKT */ +LOCAL UINT16 BuildDiSaiPduData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 *pOutData); + +/* MASL */ +/* MASLӿ:աSaPdu(SaPdu>>>SAI msg) */ +LOCAL UINT16 ProcessSaPDU(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData); +/* աAU1 SaPdu */ +LOCAL UINT8 ProcessAu1SaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2); +/* աAU2 SaPdu */ +LOCAL UINT8 ProcessAu2SaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2); +/* աAU3 SaPdu */ +LOCAL UINT8 ProcessAu3SaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2); +/* աAR SaPdu */ +LOCAL UINT8 ProcessArSaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2); +/* աDT SaPdu(DT SaPdu>>>SAI msg) */ +LOCAL UINT16 ProcessDtSaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData); +/* աDI SaPdu */ +LOCAL UINT8 ProcessDiSaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2); + +/* SAI */ +/* build EC Start SAI msg */ +LOCAL UINT16 BuildEcStartData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 *pOutData); +/* build APP SAI msg */ +LOCAL UINT16 BuildSaiMsg(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT8* pOutData); +/* build EC Start ALEPKT */ +LOCAL UINT16 SendEcStart(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT8 *pOutData); + +/* Ӧò */ +/* Ӧòӿڣbuild APP ALEPKT(APP msg>>>ALEPKT) */ +UINT16 BuildRSSP2Data(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT8 *pOutData); + +/* SAI */ +/* SAIӿڣա SAI msg(SAI msg>>>APP msg) */ +LOCAL UINT16 ProcessSaiPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT32 Now, UINT8* pOutData); +/* ա EC Start SAI msg */ +LOCAL UINT8 ProcessEcStart(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now); +/* ա APP SAI msg (SAI APP msg>>>APP msg)*/ +LOCAL UINT16 ProcessAppMsg(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData); + +/* ͨųʱ */ +void Rssp2TimeOutCheck(LPRSSP2_INFO_STRU pRssp2); +/* EC */ +LOCAL VOID ECProc(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now); +/* ECʵ */ +LOCAL VOID ECCheck(LPRSSP2_LNK_INFO_NODE_STRU pRssp2); + +/* RSSP2߼ */ +/* RSSP2Эսӿ */ +UINT8 Rssp2ReceiveDataProc(QueueStruct* OutnetQueueA, QueueStruct* OutnetQueueB, RSSP2_INFO_STRU *pRssp2Stru); +/* RSSP2Ϣнա */ +UINT8 ProcRssp2Data(QueueStruct* OutnetQueue, RSSP2_INFO_STRU* pRssp2Stru, const UINT8 netIdx); +/* RSSP2֡ */ +UINT8 ProcRssp2Node(UINT32 dstEtcsId, UINT8* pData, UINT16 dataLen, RSSP2_INFO_STRU *pRssp2Stru); + +/* RSSP2߼ */ +/* RSSP2Э鷢ͽӿ */ +UINT8 ProcessRssp2OutData(QueueStruct *AppToRs, RSSP2_INFO_STRU *pRssp2Stru); +/* RSSP2ĩ⴦ */ +UINT8 Rssp2CycSend(RSSP2_INFO_STRU *pRssp2Struct); +/* RSSP2ͨŽڵ㷢߼ */ +UINT8 Rssp2NodeSend(RSSP2_INFO_STRU *pRssp2Stru, RSSP2_LNK_INFO_NODE_STRU *pNode, UINT16 AppDataLen, UINT8 *AppData); + +/* һڵ·״̬(·ˢ) */ +UINT8 Rssp2NodeSave(IN const RSSP2_LNK_INFO_NODE_STRU *pRssp2Node, OUT RSSP2_LNK_STATUS_INFO_STRU*pStatusNode); +/* һ·״̬ݻָһRSSP2ڵ(·ˢ) */ +UINT8 Rssp2NodeRefresh(IN UINT32 LocalEtcsId, IN const RSSP2_LNK_STATUS_INFO_STRU *pStatusNode, OUT RSSP2_LNK_INFO_NODE_STRU *pRssp2LnkInfoNode); + +/* ͳһṹĿм */ +static UINT8 CheckRssp2Struct(const RSSP2_INFO_STRU *pRssp2Struct); + +/* ״̬лȡ״̬ */ +TCP_STATE GetRedTcpState(UINT8 StateCode); +/* ״̬лȡ״̬ */ +TCP_STATE GetBlueTcpState(UINT8 StateCode); +/* ȡϲTCP״̬ */ +TCP_STATE GetMergeTcpState(UINT8 StateCode); +/* ȡ */ +TCP_CTRL GetOneTcpCtrl(TCP_CTRL TcpCtrl, TCP_STATE TcpState); +/* ȡ˫(ϲ) */ +UINT8 GetMergeTcpCtrl(TCP_CTRL TcpCtrl, TCP_STATE RedState, TCP_STATE BlueState); + +static void ClearNetsRecvPkgNum(RSSP2_INFO_STRU* rsspii); +static void SetNetsRecvPkgNum(RSSP2_INFO_STRU* rsspii, const UINT32 dstEtcsId, const UINT8 netIdx); + +/****************************************************************************** +** TriDES8Bytes +** ִεı׼8ֽDES㷨 +** pcKey1,pcKey2,pcKey3:ֱָ8ֽڵԿ +** pcData: ָ򱣴ԭʼ8ֽݻ +** bType: (ENCRYPT)(DECRYPT) +** pcData: ָ򱣴8ֽݻ +** ֵ +*******************************************************************************/ +LOCAL VOID TriDES8Bytes(LPBYTE pcKey1, LPBYTE pcKey2, LPBYTE pcKey3, + LPBYTE pcData, INT bType); +/****************************************************************************** +** BuildSessionKeys +** ɻỰԿ +** pMaslMASLָ +** +** ֵ +******************************************************************************/ +LOCAL VOID BuildSessionKeys(MASL_PARAM *pMasl); + +/****************************************************************************** +** GetFrameMAC +** ֡MACֵοSubset-037 V2.3.0 7.2.2.2--Safety procedures +** pcKey1,pcKey2,pcKey3: ֱָ8ֽڵijʼԿ +** pcFrame: ָԭʼ֡ +** ulDA:շctcsIDֽڷʽҶ +** iFrameLen: ԭʼ֡ +** pcMac: ָ8ֽڵMACֵ洢 +** ֵ +******************************************************************************/ +LOCAL VOID GetFrameMAC(LPBYTE pucKey1, LPBYTE pucKey2, LPBYTE pucKey3, + UINT32 dwDA, LPBYTE pucMac, LPBYTE pucFrame, INT iFrameLen); + +/****************************************************************************** +** GetTimeDiff +** ȡʱIJֵ +** NewTimeµʱ +** OldTime ϴεʱ +** +** ֵʱֵ +******************************************************************************/ +LOCAL UINT32 GetTimeDiff(UINT32 NewTime, UINT32 OldTime); + +/****************************************************************************** +** GetTsDiff +** ȡŵIJֵ +** NewTsµĴ +** OldTsһεĴ +** +** ֵŵIJֵ +******************************************************************************/ +LOCAL INT GetTsDiff(UINT16 NewTs, UINT16 OldTs); + +/****************************************************************************** +** GetSNDiff +** Get SN Diff +** wNewSN new sn +** wOldSN last sn +** none +** ֵreturn diff +******************************************************************************/ +LOCAL INT GetSNDiff(UINT16 wNewSN, UINT32 wOldSN); + +/* RSSP2־¼ */ +#if (RSSP2_LOG_LEVEL>=0) +LOCAL UINT8 *vRecArray; +LOCAL UINT16 vRecArraySize; +#endif +#if (RSSP2_LOG_LEVEL>=0) +void commonLogMsg(UINT8* RecArray, UINT16 RecSize, INT32 LogLevel, UINT8 LogCode, const CHAR *fmt, + UINT8 argNum, UINT32 arg1, UINT32 arg2, UINT32 arg3, UINT32 arg4, UINT32 arg5, UINT32 arg6); + +void RSSP2LogBinNodeInfo(UINT8* RecArray, UINT16 RecSize, RSSP2_LNK_INFO_NODE_STRU *pRssp2Node); +#else +#define commonLogMsg((A),(B),(C),(D),(E),(F),(X1),(X2),(X3),(X4),(X5),(X6)) NULL +#define RSSP2LogBinNodeInfo((A),(B),(X)) NULL +#endif + +/* ֲ */ + +/****************************************************************************** +** BuildAleData +** (ALE) +** pRssp2: RSSP2ڵָ +** packetType: +** pData: ָûݵָ +** len: ûֽڳ +** pOutData: ָĻָ룬Ӧ>=iDataLen+10ֽ +** ֵ ALEݵij +******************************************************************************/ +LOCAL UINT16 BuildAleData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, ALE_PACK_TYPE packetType, UINT8* pData, UINT16 len, UINT8 *pOutData) +{ + UINT16 nFcs16 = 0; + UINT16 index = 0; + + if ((NULL == pRssp2) || (NULL == pData) || (NULL == pOutData)) + { + index = 0; + } + else + { + pOutData[index++] = (UINT8)((len + 8) >> 8); + pOutData[index++] = (UINT8)(len + 8); + pOutData[index++] = pRssp2->NodeInfo.aleParam.version; /* 豸汾 */ + pOutData[index++] = pRssp2->NodeInfo.aleParam.appType; /* Ӧó */ + pOutData[index++] = (UINT8)(pRssp2->NodeInfo.aleParam.sendTS >> 8); /* */ + pOutData[index++] = (UINT8)pRssp2->NodeInfo.aleParam.sendTS++; + pOutData[index++] = pRssp2->NodeInfo.aleParam.nrFlag; /* N/R־ */ + + pOutData[index++] = packetType; /* */ + + nFcs16 = GetCCITTCrcH(CCITT_CRC_INIT, pOutData, index); /* У */ + + pOutData[index++] = nFcs16 / 256; + pOutData[index++] = (UINT8)(nFcs16 & 0x00FF); + + Rssp2MemCopy(pData, pOutData + index, len);/* û */ + index += len; + } + return index; +} + +/****************************************************************************** +ܣParse Ale Data + +: + data,len ALEPKT + pRssp2 RSSP2 Object + btPacketType ALE + + pucOutBuf SaPdu(MASL) +ֵUINT16 SaPdu(MASL) +******************************************************************************/ +LOCAL UINT16 ParseAleData(LPBYTE data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 btPacketType, UINT8* pucOutBuf) +{ + UINT16 wFrameLen = 0; + UINT16 wFcs16 = 0; + UINT16 wRecvTS = 0; + UINT16 wIndex = 0; + UINT8 btVersion = 0; + UINT8 btAppType = 0; + UINT8 btPktType = 0; + UINT8 bCheck = 1; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 1, "P5001:ALE start:(%d,%d) dataType %d len %d\n", 4, pRssp2->LocalDevName, pRssp2->DestDevName, btPacketType, len, 0, 0); + if ((len < 10) || (NULL == pucOutBuf)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 2, "P5002:ALE:DataLen error:%d\n", 1, len, 0, 0, 0, 0, 0); + bCheck = 0; /* ݳ*/ + } + + + if (1 == bCheck) + { + /* ݳ */ + wFrameLen = (data[wIndex] << 8) + data[wIndex + 1]; + wIndex += 2; + + if (wFrameLen != (UINT16)(len - 2)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 3, "P5003:ALE:PacketLen error:%d,%d\n", 2, len, wFrameLen, 0, 0, 0, 0); + bCheck = 0; /* ֶδ󣬰봫볤Ȳ */ + } + } + + if (1 == bCheck) + { + /* 汾 */ + btVersion = data[wIndex++]; + + if (pRssp2->NodeInfo.aleParam.version != btVersion) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 4, "P5004:ALE:dev ver :%d,%d\n", 2, + pRssp2->NodeInfo.aleParam.version, btVersion, 0, 0, 0, 0); + /*bCheck = 0;*/ /* 豸汾һ */ + } + } + + if (1 == bCheck) + { + /* Ӧ */ + btAppType = data[wIndex++]; + + if (pRssp2->NodeInfo.aleParam.appType != btAppType) /* Ӧó */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 5, "P5005:ALE:app ver :%d,%d\n", 2, + pRssp2->NodeInfo.aleParam.appType, btAppType, 0, 0, 0, 0); + /*bCheck = 0;*/ + } + } + + /* */ + wRecvTS = (data[wIndex] << 8) + data[wIndex + 1]; + wIndex += 2; + + /* ־̶Ϊ0 */ + wIndex++; + + if (1 == bCheck) + { + /* */ + btPktType = data[wIndex++]; + if (btPktType != btPacketType) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 6, "P5006:ALE:pack type error:%d,%d\n", 2, + btPacketType, btPktType, 0, 0, 0, 0); + bCheck = 0; /* ʹ */ + } + } + + if (1 == bCheck) + { + /* CRC */ + wFcs16 = (data[wIndex] << 8) + data[wIndex + 1]; + wIndex += 2; + + if (wFcs16 != GetCCITTCrcH(CCITT_CRC_INIT, data, 8)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 7, "P5007:ALE:crc error:%d\n", 1, + wFcs16, 0, 0, 0, 0, 0); + bCheck = 0; /* Уʹ */ + } + } + + if (1 == bCheck) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 8, "P5008:ALE:wRecvTS = %d pRssp2->aleObject.recvTS = %d\n", 2, + wRecvTS, pRssp2->NodeInfo.aleParam.recvTS, 0, 0, 0, 0); + if ((0 == wRecvTS) && (0 == pRssp2->NodeInfo.aleParam.recvTS)) + { + if (TRUE == pRssp2->NodeInfo.aleParam.bIsZero)/* յΪ0֡ */ + { + pRssp2->NodeInfo.aleParam.bIsZero = FALSE; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 9, "P5009:ALE:Repeat Sequence equal 0\n", 0, + 0, 0, 0, 0, 0, 0); + bCheck = 0; + } + else + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 10, "P5010:ALE:Sequence 0\n", 0, + 0, 0, 0, 0, 0, 0); + pRssp2->NodeInfo.aleParam.bIsZero = TRUE; + } + } + else + { + if (GetTsDiff(wRecvTS, pRssp2->NodeInfo.aleParam.recvTS) <= 0) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 11, "P5011:ALE:TS error:%d,%d\n", 2, + wRecvTS, pRssp2->NodeInfo.aleParam.recvTS, 0, 0, 0, 0); + bCheck = 0; + } + } + + if (1 == bCheck) + { + pRssp2->NodeInfo.aleParam.recvTS = wRecvTS; + CommonMemCpy(pucOutBuf, len - 10, data + 10, len - 10); /* û */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 12, "P5012:ALE end:MaslLen=%d\n", 1, + len - 10, 0, 0, 0, 0, 0); + len -= 10; + } + } + + if (1 != bCheck) + { + len = 0; + } + return len; +} + +/****************************************************************************** +** BuildAU1SaPDU +** Build AU1 SaPDU subset037 7.2.4.2.2 +** pMasl: Masl object +** +** ֵUINT16 SaPdu +******************************************************************************/ +LOCAL UINT16 BuildAu1SaPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT32 RandNum, UINT8* pOutData) +{ + UINT16 index = 0; + LPMASL_PARAM pMasl = NULL; + /* */ + if ((NULL == pRssp2) || (NULL == pOutData)) + { + index = 0; + } + else + { + pMasl = &pRssp2->NodeInfo.maslParam; + + /* add 20160819 xb CR9590: */ + LongToChar(RandNum, &pMasl->Rb[0]); + LongToChar(~RandNum, &pMasl->Rb[4]); + + + pOutData[index++] = ((UINT8)(pMasl->localDevType) * 32) | ((MSG_AU1 & 0x0F) << 1) | pMasl->btDf; + pOutData[index++] = (UINT8)((pMasl->localCtcsID / 256 / 256) & 0xff); + pOutData[index++] = (UINT8)((pMasl->localCtcsID / 256) & 0xff); + pOutData[index++] = (UINT8)((pMasl->localCtcsID) & 0xff); + pOutData[index++] = SAF; + Rssp2MemCopy(pMasl->Rb, pOutData + index, 8); + index += 8; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 107, "P5107:MASL:Build AU1:0x%02x %02x %02x %02x %02x\n", 5, + pOutData[0], pOutData[1], pOutData[2], pOutData[3], pOutData[4], 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 108, "P5108:MASL:AU1 Rb1:0x%02x %02x %02x %02x\n", 4, + pMasl->Rb[0], pMasl->Rb[1], pMasl->Rb[2], pMasl->Rb[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 108, "P5108:MASL:AU1 Rb2:0x%02x %02x %02x %02x\n", 4, + pMasl->Rb[4], pMasl->Rb[5], pMasl->Rb[6], pMasl->Rb[7], 0, 0); + } + return index; +} + +/****************************************************************************** +** BuildAU2SaPDU +** Build AU2 SaPDU subset037 7.2.4.2.3 +** pMasl: Masl object +** +** ֵ UINT16 SaPdu +******************************************************************************/ +LOCAL UINT16 BuildAu2SaPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT32 RandNum, UINT8* pOutData) +{ + UINT8 btMac[8] = { 0 }; + UINT8 ucFrameTocalculateMac[24] = { 0 }; + UINT16 index = 0; + LPMASL_PARAM pMasl = NULL; + /* */ + if ((NULL == pRssp2) || (NULL == pOutData)) + { + index = 0; + } + else + { + pMasl = &pRssp2->NodeInfo.maslParam; + + /* add 20160819 xb CR9590: */ + LongToChar(RandNum, &pMasl->Ra[0]); + LongToChar(~RandNum, &pMasl->Ra[4]); + + /**generate Ra*/ + /* Get Session Key */ +#ifdef RSSP2_PREDEF_SESSIONKEY + CommonMemCpy(pMasl->ks1, 8, g_ucKMACKey1, 8); + CommonMemCpy(pMasl->ks2, 8, g_ucKMACKey2, 8); + CommonMemCpy(pMasl->ks3, 8, g_ucKMACKey3, 8); +#else + BuildSessionKeys(pMasl); +#endif + pOutData[index++] = (((UINT8)pMasl->localDevType) << 5) | ((MSG_AU2 & 0x0F) << 1) | pMasl->btDf; + /*ӦCTCS_ID */ + pOutData[index++] = (UINT8)(pMasl->localCtcsID >> 16); + pOutData[index++] = (UINT8)(pMasl->localCtcsID >> 8); + pOutData[index++] = (UINT8)(pMasl->localCtcsID); + pOutData[index++] = SAF; + CommonMemCpy(pOutData + index, 8, pMasl->Ra, 8); + index += 8; + + /*ӼCBC_MACԴAU2Rb|INITIATORID */ + CommonMemCpy(ucFrameTocalculateMac, 24, pOutData, index); + CommonMemCpy(ucFrameTocalculateMac + index, 24 - index, pMasl->Rb, 8); + + ucFrameTocalculateMac[21] = (UINT8)(pMasl->remoteCtcsID >> 16); + ucFrameTocalculateMac[22] = (UINT8)(pMasl->remoteCtcsID >> 8); + ucFrameTocalculateMac[23] = (UINT8)(pMasl->remoteCtcsID); + + /* CBC_MAC */ + GetFrameMAC(pMasl->ks1, pMasl->ks2, pMasl->ks3, pMasl->remoteCtcsID, btMac, ucFrameTocalculateMac, 24); + + CommonMemCpy(pOutData + index, 8, btMac, 8); + index += 8; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 110, "P5110:MASL:build AU2 Head:0x%02x %02x %02x %02x %02x\n", 5, + pOutData[0], pOutData[1], pOutData[2], pOutData[3], pOutData[4], 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 111, "P5111:MASL:build AU2 Ra1:0x%02x %02x %02x %02x\n", 4, + pMasl->Ra[0], pMasl->Ra[1], pMasl->Ra[2], pMasl->Ra[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 111, "P5111:MASL:build AU2 Ra2:0x%02x %02x %02x %02x\n", 4, + pMasl->Ra[4], pMasl->Ra[5], pMasl->Ra[6], pMasl->Ra[7], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 112, "P5112:MASL:build AU2 MAC1:0x%02x %02x %02x %02x\n", 4, + btMac[0], btMac[1], btMac[2], btMac[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 112, "P5112:MASL:build AU2 MAC2:0x%02x %02x %02x %02x\n", 4, + btMac[4], btMac[5], btMac[6], btMac[7], 0, 0); + } + return index; +} + +/****************************************************************************** +** BuildAU3SaPDU +** Build AU3 SaPDU subset037 7.2.4.2.4 +** pMasl: Masl object +** +** ֵ UINT16 SaPdu +******************************************************************************/ +LOCAL UINT16 BuildAu3SaPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData) +{ + UINT8 btMac[8] = { 0 }; + UINT8 ucFrameTocalculateMac[17] = { 0 }; + UINT16 index = 0; + LPMASL_PARAM pMasl = NULL; + /* */ + if ((NULL == pRssp2) || (NULL == pOutData)) + { + index = 0; + } + else + { + pMasl = &pRssp2->NodeInfo.maslParam; + pOutData[index++] = ((MSG_AU3 & 0x0F) << 1) | pMasl->btDf; + + /* MAC,MACݺAU3|Rb|Ra */ + ucFrameTocalculateMac[0] = pOutData[0]; + Rssp2MemCopy(pMasl->Rb, ucFrameTocalculateMac + 1, 8); + Rssp2MemCopy(pMasl->Ra, ucFrameTocalculateMac + 9, 8); + + GetFrameMAC(pMasl->ks1, pMasl->ks2, pMasl->ks3, pMasl->remoteCtcsID, btMac, ucFrameTocalculateMac, 17); + Rssp2MemCopy(btMac, pOutData + index, 0x08); + index += 8; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 113, "P5113:MASL:build AU3 MAC1:0x%02x %02x %02x %02x\n", 4, + btMac[0], btMac[1], btMac[2], btMac[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 113, "P5113:MASL:build AU3 MAC2:0x%02x %02x %02x %02x\n", 4, + btMac[4], btMac[5], btMac[6], btMac[7], 0, 0); + } + return index; +} + +/****************************************************************************** +** BuildARSaPDU +** Build AR SaPDU subset037 7.2.4.2.5 +** pMasl: Masl object +** +** ֵ UINT16 SaPdu +******************************************************************************/ +LOCAL UINT16 BuildArSaPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData) +{ + UINT8 btMac[8] = { 0 }; + UINT8 ucFrameTocalculateMac = 0; + UINT16 index = 0; + LPMASL_PARAM pMasl = NULL; + + /* */ + if ((NULL == pRssp2) || (NULL == pOutData)) + { + index = 0; + } + else + { + pMasl = &pRssp2->NodeInfo.maslParam; + pOutData[index++] = ((MSG_AR & 0x0F) << 1) | pMasl->btDf; + ucFrameTocalculateMac = pOutData[0]; + GetFrameMAC(pMasl->ks1, pMasl->ks2, pMasl->ks3, pMasl->remoteCtcsID, btMac, &ucFrameTocalculateMac, 1); + Rssp2MemCopy(btMac, pOutData + index, 0x08); + index += 8; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 114, "P5114:MASL:build AR MAC1:0x%02x %02x %02x %02x\n", 4, + btMac[0], btMac[1], btMac[2], btMac[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 114, "P5114:MASL:build AR MAC2:0x%02x %02x %02x %02x\n", 4, + btMac[4], btMac[5], btMac[6], btMac[7], 0, 0); + } + return index; +} + +/****************************************************************************** +** BuildDTSaPDU +** Build DT SaPDU subset037 7.2.4.3.1 +** pMasl: Masl object +** pbtInData: input buffer +** wLen: length of input +** pOutData DT SaPDU +** ֵUINT16 SaPdu +******************************************************************************/ +LOCAL UINT16 BuildDtSaPduData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 *data, UINT16 len, UINT8 *pOutData) +{ + UINT16 index = 0; + LPMASL_PARAM pMasl = NULL; + + /* */ + if ((NULL == pRssp2) || (NULL == data)|| (NULL == pOutData)) + { + index = 0; + } + else + { + pMasl = &pRssp2->NodeInfo.maslParam; + pOutData[index++] = ((MSG_DT & 0x0F) << 1) | pMasl->btDf; + Rssp2MemCopy(data, pOutData + index, len); + index += len; + /* 㲢дMAC */ + GetFrameMAC(pMasl->ks1, pMasl->ks2, pMasl->ks3, pMasl->remoteCtcsID, pOutData + index, pOutData, index); + index += 8; + } + return index; +} + +/****************************************************************************** +** BuildDISaPDU +** Build DI SaPDU subset037 7.2.4.4.1 +** pMasl: Masl object +** btReason: reason of disconnection +** btSubReason: subreason of disconnection +** +** ֵUINT16 SaPdu +******************************************************************************/ +LOCAL UINT16 BuildDISaPduData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 btReason, UINT8 btSubReason, UINT8 *pData) +{ + LPMASL_PARAM pMasl = NULL; + UINT16 index = 0; + + if ((NULL == pRssp2) || (NULL == pData)) + { + index = 0; + } + else + { + pMasl = &pRssp2->NodeInfo.maslParam; + + pData[index++] = ((MSG_DI & 0x0F) << 1) | pMasl->btDf; + pData[index++] = btReason; + pData[index++] = btSubReason; + } + return index; +} + +/************************************************************************ +:build AU1 ALEPKT +AU1 SaPduװALEPKT,ѷAU1ӦMASL״̬ +:pRssp2 RSSP2 object + Now AU1ʱ + pRssp2->NodeInfo.maslPara MASL +:pOutData ALEPKT + pRssp2->NodeInfo.maslPara MASL״̬ +ֵUINT16 ALEPKT +************************************************************************/ +LOCAL UINT16 BuildAu1SaiPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT32 RandNum, UINT8* pOutData) +{ + UINT8 ucTmpData[22] = { 0 }; + UINT16 ret = 0; + UINT16 index = 0; + UINT8 maslData[AU1_MASL_LEN] = { 0 }; + + if ((NULL == pRssp2) || (NULL == pOutData)) + { + index = 0; + } + else + { + if (MASL_STATE_DISCONNECTED == pRssp2->NodeInfo.maslParam.status) + { + /**make AU1*/ + Rssp2MemSet(maslData, sizeof(maslData), 0); + ret = BuildAu1SaPdu(pRssp2, RandNum, maslData); + /** AU1 to CFM*/ + ucTmpData[index++] = HIBYTE(HIWORD(pRssp2->NodeInfo.aleParam.localCtcsID)); + ucTmpData[index++] = LOBYTE(HIWORD(pRssp2->NodeInfo.aleParam.localCtcsID)); + ucTmpData[index++] = HIBYTE(LOWORD(pRssp2->NodeInfo.aleParam.localCtcsID)); + ucTmpData[index++] = LOBYTE(LOWORD(pRssp2->NodeInfo.aleParam.localCtcsID)); + ucTmpData[index++] = HIBYTE(HIWORD(pRssp2->NodeInfo.aleParam.remoteCtcsID)); + ucTmpData[index++] = LOBYTE(HIWORD(pRssp2->NodeInfo.aleParam.remoteCtcsID)); + ucTmpData[index++] = HIBYTE(LOWORD(pRssp2->NodeInfo.aleParam.remoteCtcsID)); + ucTmpData[index++] = LOBYTE(LOWORD(pRssp2->NodeInfo.aleParam.remoteCtcsID)); + ucTmpData[index++] = ALE_SERVICE_CLASS_D; + + Rssp2MemCopy(maslData, ucTmpData + index, ret); + + index += ret; + + ret = BuildAleData(pRssp2, ALE_PACK_TYPE_CR, ucTmpData, index, pOutData); + /*send data */ + pRssp2->NodeInfo.maslParam.Tconnect = Now;/* use to judge timeout */ + pRssp2->NodeInfo.maslParam.Tau1 = Now; + pRssp2->NodeInfo.maslParam.status = MASL_STATE_CONNECTING; + pRssp2->NodeInfo.maslParam.connStatus = MASL_CONNECTION_WAITING_FOR_AU2; + pRssp2->NodeInfo.aleParam.bIsZero = FALSE; /*add 20170727 xb AU10к*/ + pRssp2->NodeInfo.aleParam.recvTS = 0; + } + } + return ret; +} + +/************************************************************************ +:build AU2 ALEPKT +AU2 SaPduװALEPKT,ѷAU2ӦMASL״̬ +:pRssp2 RSSP2 object + Now AU2ʱ + pRssp2->NodeInfo.maslPara MASL +:pOutData ALEPKT + pRssp2->NodeInfo.maslPara MASL״̬ +ֵUINT16 ALEPKT +************************************************************************/ +LOCAL UINT16 BuildAu2SaiPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT32 RandNum, UINT8* pOutData) +{ + UINT16 ret = 0; + UINT8 tmpData[AU2_ALE_LEN] = { 0 }; + + if ((NULL == pRssp2) || (NULL == pOutData)) + { + ret = 0; + } + else + { + /**make AU2*/ + Rssp2MemSet(tmpData, sizeof(tmpData), 0); + + ret = BuildAu2SaPdu(pRssp2, RandNum, tmpData + 4); + /** AU2 to CFM*/ + tmpData[0] = HIBYTE(HIWORD(pRssp2->NodeInfo.maslParam.localCtcsID));/* صCTCSID */ + tmpData[1] = LOBYTE(HIWORD(pRssp2->NodeInfo.maslParam.localCtcsID)); + tmpData[2] = HIBYTE(LOWORD(pRssp2->NodeInfo.maslParam.localCtcsID)); + tmpData[3] = LOBYTE(LOWORD(pRssp2->NodeInfo.maslParam.localCtcsID)); + + ret += 4; + + ret = BuildAleData(pRssp2, ALE_PACK_TYPE_CC, tmpData, ret, pOutData); + + pRssp2->NodeInfo.maslParam.Tconnect = Now; + pRssp2->NodeInfo.maslParam.status = MASL_STATE_CONNECTING; + pRssp2->NodeInfo.maslParam.connStatus = MASL_CONNECTION_WAITING_FOR_AU3; + } + return ret; +} + +/************************************************************************ +:build AU3 ALEPKT +AU3 SaPduװALEPKT,ѷAU3ӦMASL״̬ +:pRssp2 RSSP2 object + pRssp2->NodeInfo.maslPara MASL +:pOutData ALEPKT + pRssp2->NodeInfo.maslPara MASL״̬ +ֵUINT16 ALEPKT +************************************************************************/ +LOCAL UINT16 BuildAu3SaiPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData) +{ + UINT16 ret = 0; + UINT8 tmpData[AU3_MASL_LEN] = { 0 }; + + if ((NULL == pRssp2) || (NULL == pOutData)) + { + ret = 0; + } + else + { + /**make AU3*/ + Rssp2MemSet(tmpData, sizeof(tmpData), 0); + ret = BuildAu3SaPdu(pRssp2, tmpData); + /** AU3 to CFM*/ + ret = BuildAleData(pRssp2, ALE_PACK_TYPE_DT, tmpData, ret, pOutData); + + pRssp2->NodeInfo.maslParam.connStatus = MASL_CONNECTION_WAITING_FOR_AR; + } + return ret; +} + +/************************************************************************ +:build AR ALEPKT +AR SaPduװALEPKT,ѷARӦMASL״̬ +:pRssp2 RSSP2 object +:pOutData ALEPKT + pRssp2->NodeInfo.maslPara MASL״̬ +ֵUINT16 ALEPKT +************************************************************************/ +LOCAL UINT16 BuildArSaiPdu(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData) +{ + UINT16 ret = 0; + UINT8 tmpData[AR_MASL_LEN] = { 0 }; + + if ((NULL == pRssp2) || (NULL == pOutData)) + { + ret = 0; + } + else + { + /**make AR*/ + Rssp2MemSet(tmpData, sizeof(tmpData), 0); + ret = BuildArSaPdu(pRssp2, tmpData); + + /** AR to CFM*/ + ret = BuildAleData(pRssp2, ALE_PACK_TYPE_DT, tmpData, ret, pOutData); + /** update Connection State*/ + pRssp2->NodeInfo.maslParam.status = MASL_STATE_CONNECTED; + } + return ret; +} + +/************************************************************************ +:build DI ALEPKT +DI SaPduװALEPKT,ѷDIӦMASL״̬,λSFM +:pRssp2 RSSP2 object +:pOutData ALEPKT + pRssp2->NodeInfo λSFM +ֵUINT16 ALEPKT +************************************************************************/ +LOCAL UINT16 BuildDiSaiPduData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 *pOutData) +{ + UINT16 ret = 0; + UINT8 btReason = 0; + UINT8 btSubReason = 0; + UINT8 tmpData[MAX_RSSP2_DATA_LEN] = { 0 }; + + if ((NULL == pRssp2) || (NULL == pOutData)) + { + ret = 0; + } + else + { + Rssp2MemSet(tmpData, sizeof(tmpData), 0x00); + + btReason = pRssp2->NodeInfo.maslParam.discIndication.reason; + btSubReason = pRssp2->NodeInfo.maslParam.discIndication.subReason; + + ret = BuildDISaPduData(pRssp2, btReason, btSubReason, tmpData); + if (0 < ret) + { + ret = BuildAleData(pRssp2, ALE_PACK_TYPE_DI, tmpData, ret, pOutData); + } + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 116, "P5116:ALE:build DI data:destDev=0x%04x,Reason=0x%04x,SubReason=%d\n", + 3, pRssp2->DestDevName, btReason, btSubReason, 0, 0, 0); + } + return ret; +} + +/****************************************************************************** +ܣա SaPdu +MASLݽա + άMASL״̬ + ЧSAIģ֮ +룺pRssp2: Rssp2 object + UINT8 *data, UINT16 len SaPdu + pRssp2->NodeInfo.maslParam MASL״̬ + + OutData SAI + pRssp2->NodeInfo ڵ״̬ + pRssp2->LinkStatus ·״̬ +ֵ UINT16 SAIij +******************************************************************************/ +LOCAL UINT16 ProcessSaPDU(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData) +{ + UINT16 saiLen = 0; + UINT8 tmpRet = 0; + LPMASL_PARAM pMasl = NULL; + LPSAI_PARAM pSai = NULL; + UINT16 index = 0; + UINT8 dir = 0; + UINT8 maslType = 0; + + if ((NULL == data) || (NULL == pRssp2) || (NULL == pOutData)) + { + saiLen = 0; + } + else + { + pMasl = &pRssp2->NodeInfo.maslParam; + pSai = &pRssp2->NodeInfo.saiParam; + + /**Check Direction*/ + if (pMasl->btDf == (data[index] & 0x01)) + {/**direction error*/ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 13, "P5013:MASL:dir error msg=%d,self=%d\n", 2, + data[index] & 0x01, pMasl->btDf, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + if (pMasl->btDf == 0) + { + /*Value of direction flag '0' instead of '1'*/ + pRssp2->NodeInfo.maslParam.discIndication.reason = 6; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 1;/*#DI#0x0601*/ + } + else + { + /*Value of direction flag '1' instead of '0'*/ + pRssp2->NodeInfo.maslParam.discIndication.reason = 6; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 2;/*#DI#0x0602*/ + } + } + else + { + /** Deal SaPDU*/ + maslType = (data[index] >> 1) & 0x0F; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 14, "P5014:MASL:type=%d,len=%d\n", 2, + maslType, len, 0, 0, 0, 0); + switch (maslType) + { + case MSG_AU1: /**AU1 SaPDU*/ + tmpRet = ProcessAu1SaPdu(data, len, pRssp2); + break; + case MSG_AU2: /*AU2 SaPDU */ + tmpRet = ProcessAu2SaPdu(data, len, pRssp2); + break; + case MSG_AU3: /*AU3 SaPDU */ + tmpRet = ProcessAu3SaPdu(data, len, pRssp2); + break; + case MSG_AR: /*AR SaPDU */ + tmpRet = ProcessArSaPdu(data, len, pRssp2); + break; + case MSG_DT: /*DT SaPDU */ + saiLen = ProcessDtSaPdu(data, len, pRssp2, pOutData); + break; + case MSG_DI: /*DI SaPDU */ + tmpRet = ProcessDiSaPdu(data, len, pRssp2); + break; + default: + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 51, "P5051:MASL:msg type error:%d\n", 1, + maslType, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 1;/*#DI#0x0801*/ + break; + } + } + } + return saiLen; +} + +/****************************************************************************** +ܣա AU1 SaPdu +: ȡRb +룺pRssp2: Rssp2 object + UINT8 *data, UINT16 len AU1 SaPdu + pRssp2->NodeInfo.maslParam MASL״̬ + + pRssp2->NodeInfo.maslParam MASL״̬ + pRssp2->LinkStatus ·״̬ +ֵ UINT16 1ɹ 0ʧ +******************************************************************************/ +LOCAL UINT8 ProcessAu1SaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2) +{ + UINT8 ret = 0; + UINT8 rmtDevType = 0; + UINT16 index = 0; + UINT32 rmtCtcsId = 0; + UINT8 saf = 0; + + ret = 1; + if ((NULL == pRssp2) || (NULL == data)) + { + ret = 0; + } + + if (1 == ret) + { + /**Check device type*/ + rmtDevType = (data[index++] >> 5); + if (rmtDevType != (UINT8)pRssp2->NodeInfo.maslParam.remoteDevType) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 15, "P5015:MASL:rmtDevType error:msg=%d,exp=%d\n", 2, + rmtDevType, pRssp2->NodeInfo.maslParam.remoteDevType, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 5;/*#DI#0x0805*/ + ret = 0; + } + } + + if (1 == ret) + { + /**Check ctcsID*/ + rmtCtcsId += (data[index++] << 16); + rmtCtcsId += (data[index++] << 8); + rmtCtcsId += data[index++]; + if (rmtCtcsId != (pRssp2->NodeInfo.maslParam.remoteCtcsID & 0x00FFFFFF)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 16, "P5016:MASL:rmtCTCSId error:0x%02x%02x%02x\n", + 3, data[1], data[2], data[3], 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 6;/* DI:0x0805*/ + ret = 0; + } + } + + if (1 == ret) + { + /**Check SaF*/ + saf = data[index++]; + if (SAF != saf) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 17, "P5017:MASL:SAF error:%d\n", + 1, saf, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 3; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 29;/*#DI#0x031d*/ + ret = 0; + } + } + + if (1 == ret) + { + /**Check if it Should AU1*/ + if (MASL_STATE_CONNECTING == pRssp2->NodeInfo.maslParam.status) + { + if (MASL_CONNECTION_WAITING_FOR_AU2 == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 18, + "P5018:MASL:get AU1 instead AU2 error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 1; + ret = 0; + } + else if (MASL_CONNECTION_WAITING_FOR_AU3 == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 19, + "P5019:MASL:get AU1 instead AU3 error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 2; + ret = 0; + } + else if (MASL_CONNECTION_WAITING_FOR_AR == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 20, + "P5020:MASL:get AU1 instead AR error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 3; + ret = 0; + } + else + { + } + } + else if (MASL_STATE_CONNECTED == pRssp2->NodeInfo.maslParam.status) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 21, + "P5021:MASL:get AU1 while connected error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 5; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 1; + ret = 0; + } + else + { + } + } + + if (1 == ret) + { + Rssp2MemCopy(data + index, pRssp2->NodeInfo.maslParam.Rb, 8); + index += 8; + + pRssp2->LinkStatus = RSSP2_SEND_AU2; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 22, + "P5022:MASL:recv AU1 success:0x%02x %02x %02x %02x\n", 4, + pRssp2->NodeInfo.maslParam.Rb[0], + pRssp2->NodeInfo.maslParam.Rb[1], + pRssp2->NodeInfo.maslParam.Rb[2], + pRssp2->NodeInfo.maslParam.Rb[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 22, + "P5022:MASL:recv AU1 success:0x%02x %02x %02x %02x\n", 4, + pRssp2->NodeInfo.maslParam.Rb[4], + pRssp2->NodeInfo.maslParam.Rb[5], + pRssp2->NodeInfo.maslParam.Rb[6], + pRssp2->NodeInfo.maslParam.Rb[7], 0, 0); + } + return ret; +} + +/****************************************************************************** +ܣա AU2 SaPdu +ȡRa,ỰԿ +룺pRssp2: Rssp2 object + UINT8 *data, UINT16 len AU2 SaPdu + pRssp2->NodeInfo.maslParam MASL״̬ + + pRssp2->NodeInfo.maslParam MASL״̬ + pRssp2->LinkStatus ·״̬ +ֵ UINT8 1ɹ 0ʧ +******************************************************************************/ +LOCAL UINT8 ProcessAu2SaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2) +{ + UINT8 btMac[8] = { 0 }; + UINT8 ucFrameTocalculateMac[24] = { 0 }; + UINT8 rmtDevType = 0; + UINT16 index = 0; + UINT32 rmtCtcsId = 0; + UINT8 saf = 0; + LPMASL_PARAM pMasl = NULL; + UINT8 bCheck = 1; + + if ((NULL == pRssp2) || (NULL == data)) + { + bCheck = 0; + } + + if (1 == bCheck) + { + pMasl = &pRssp2->NodeInfo.maslParam; + + /**Check device type*/ + rmtDevType = (data[index++] >> 5); + if (rmtDevType != (UINT8)pRssp2->NodeInfo.maslParam.remoteDevType) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 23, "P5023:MASL:rmtDevType error:msg=%d,exp=%d\n", 2, + rmtDevType, pRssp2->NodeInfo.maslParam.remoteDevType, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 2; + bCheck = 0; + } + } + + if (1 == bCheck) + { + /**Check ctcsID*/ + rmtCtcsId += (data[index++] << 16); + rmtCtcsId += (data[index++] << 8); + rmtCtcsId += data[index++]; + if (rmtCtcsId != (pRssp2->NodeInfo.maslParam.remoteCtcsID & 0x00FFFFFF)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 24, "P5024:MASL:rmtCTCSId error:0x%02x%02x%02x\n", + 3, data[1], data[2], data[3], 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 4; + bCheck = 0; + } + /**Check SaF*/ + saf = data[index++]; + if (SAF != saf) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 25, "P5025:MASL:SAF error:%d\n", + 1, saf, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 3; + bCheck = 0; + } + } + + if (1 == bCheck) + { + /**Get Ra*/ + Rssp2MemCopy(data + index, pRssp2->NodeInfo.maslParam.Ra, 8); + index += 8; + + /* Get Session Key */ +#ifdef RSSP2_PREDEF_SESSIONKEY + CommonMemCpy(pMasl->ks1, 8, g_ucKMACKey1, 8); + CommonMemCpy(pMasl->ks2, 8, g_ucKMACKey2, 8); + CommonMemCpy(pMasl->ks3, 8, g_ucKMACKey3, 8); +#else + BuildSessionKeys(pMasl); +#endif + /*ӼCBC_MACԴAU2Rb|INITIATORID */ + CommonMemCpy(ucFrameTocalculateMac, 24, data, index); + CommonMemCpy(ucFrameTocalculateMac + index, 24 - index, pRssp2->NodeInfo.maslParam.Rb, 8); + + ucFrameTocalculateMac[index + 8] = (UINT8)(pRssp2->NodeInfo.maslParam.localCtcsID >> 16); + ucFrameTocalculateMac[index + 8 + 1] = (UINT8)(pRssp2->NodeInfo.maslParam.localCtcsID >> 8); + ucFrameTocalculateMac[index + 8 + 2] = (UINT8)(pRssp2->NodeInfo.maslParam.localCtcsID); + + /* CBC_MAC */ + GetFrameMAC(pRssp2->NodeInfo.maslParam.ks1, pRssp2->NodeInfo.maslParam.ks2, pRssp2->NodeInfo.maslParam.ks3, pRssp2->NodeInfo.maslParam.localCtcsID, btMac, ucFrameTocalculateMac, index + 11); + if (0 != CommonMemCmp(data + index, btMac, 8)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 26, "P5026:MASL:AU2 MAC error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 4; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 2; + bCheck = 0; + } + } + + if (1 == bCheck) + { + /**Check if it Should AU2*/ + if (MASL_STATE_CONNECTING == pRssp2->NodeInfo.maslParam.status) + { + if (MASL_CONNECTION_WAITING_FOR_AU3 == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 27, "P5027:MASL:get AU2 instead AU3 error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x12; + bCheck = 0; + } + else if (MASL_CONNECTION_WAITING_FOR_AR == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 28, "P5028:MASL:get AU2 instead AR error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x13; + bCheck = 0; + } + else + { + /**/ + } + } + else if (MASL_STATE_CONNECTED == pRssp2->NodeInfo.maslParam.status) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 29, "P5029:MASL:get AU2 while connected error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 5; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x02; + bCheck = 0; + } + else if (MASL_STATE_DISCONNECTED == pRssp2->NodeInfo.maslParam.status) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 30, "P5030:MASL:get AU2 while disconnected error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 5; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x12; + bCheck = 0; + } + else + { + /*ɴ֧*/ + } + } + if (1 == bCheck) + { + pRssp2->LinkStatus = RSSP2_SEND_AU3; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 46, "P5046:MASL:recv AU2 success\n", + 0, 0, 0, 0, 0, 0, 0); + } + return bCheck; +} + +/****************************************************************************** +ܣա AU3 SaPdu +УỰԿ +룺pRssp2: Rssp2 object + UINT8 *data, UINT16 len AU3 SaPdu + pRssp2->NodeInfo.maslParam MASL״̬ + + pRssp2->NodeInfo.maslParam MASL״̬ + pRssp2->LinkStatus ·״̬ +ֵ UINT16 1ɹ 0ʧ +******************************************************************************/ +LOCAL UINT8 ProcessAu3SaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2) +{ + UINT8 btMac[8] = { 0 }; + UINT8 ucFrameTocalculateMac[17] = { 0 }; + UINT8 msgType = 0; + UINT8 msgDf = 0; + UINT16 index = 0; + UINT32 rmtCtcsId = 0; + UINT8 saf = 0; + LPMASL_PARAM pMasl = NULL; + UINT8 bCheck = 1; + + if ((NULL == pRssp2) || (NULL == data)) + { + bCheck = 0; + } + + if (1 == bCheck) + { + pMasl = &pRssp2->NodeInfo.maslParam; + + /**Check device type*/ + msgType = (data[index] >> 1) & 0x0F; + msgDf = data[index] & 0x01; + index++; + + if ((MSG_AU3 != msgType) || (INITIATOR_TO_RESPONDER != msgDf)) + { + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 7; + bCheck = 0; + } + } + if (1 == bCheck) + { + /**Check MAC*/ + /* MAC,MACݺAU3|Rb|Ra */ + ucFrameTocalculateMac[0] = data[0]; + Rssp2MemCopy(pMasl->Rb, ucFrameTocalculateMac + 1, 8); + Rssp2MemCopy(pMasl->Ra, ucFrameTocalculateMac + 9, 8); + + GetFrameMAC(pRssp2->NodeInfo.maslParam.ks1, pRssp2->NodeInfo.maslParam.ks2, pRssp2->NodeInfo.maslParam.ks3, pRssp2->NodeInfo.maslParam.localCtcsID, btMac, ucFrameTocalculateMac, 17); + + if (0 != CommonMemCmp(data + index, btMac, 8)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 31, "P5031:MASL:AU3 MAC error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 4; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 3; + bCheck = 0; + } + } + + if (1 == bCheck) + { + /**Check if it Should AU3*/ + if (MASL_STATE_CONNECTING == pRssp2->NodeInfo.maslParam.status) + { + if (MASL_CONNECTION_WAITING_FOR_AU2 == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 32, "P5032:MASL:get AU3 instead AU2 error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x11; + bCheck = 0; + } + if (MASL_CONNECTION_WAITING_FOR_AR == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 33, "P5033:MASL:get AU3 instead AR error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x23; + bCheck = 0; + } + } + if (MASL_STATE_CONNECTED == pRssp2->NodeInfo.maslParam.status) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 34, "P5034:MASL:get AU3 while connected error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 5; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x03; + bCheck = 0; + } + if (MASL_STATE_DISCONNECTED == pRssp2->NodeInfo.maslParam.status) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 35, "P5035:MASL:get AU3 while disconnected error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 5; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x13; + bCheck = 0; + } + } + + if (1 == bCheck) + { + pRssp2->LinkStatus = RSSP2_SEND_AR; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 47, "P5047:MASL:recv AU3 success\n", + 0, 0, 0, 0, 0, 0, 0); + } + return bCheck; +} + +/****************************************************************************** +ܣա AR SaPdu +УỰԿ +룺pRssp2: Rssp2 object + UINT8 *data, UINT16 len Ar SaPdu + pRssp2->NodeInfo.maslParam MASL״̬ + + pRssp2->NodeInfo.maslParam MASL״̬ + pRssp2->LinkStatus ·״̬ +ֵ UINT16 1ɹ 0ʧ +******************************************************************************/ +LOCAL UINT8 ProcessArSaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2) +{ + UINT8 bCheck = 1; + UINT8 btMac[8] = { 0 }; + UINT8 ucFrameTocalculateMac = 0; + UINT8 mti = 0; + UINT16 index = 0; + UINT32 rmtCtcsId = 0; + UINT8 saf = 0; + LPMASL_PARAM pMasl = NULL; + INT32 rslt = 0; + + if ((NULL == pRssp2) || (NULL == data)) + { + bCheck = 0; + } + if (1 == bCheck) + { + pMasl = &pRssp2->NodeInfo.maslParam; + + /**Check device type*/ + mti = (data[index] >> 1) & 0x0F; + saf = data[index] & 0x01; + index++; + + if ((MSG_AR != mti) || (RESPONDER_TO_INITIATOR != saf)) + { + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 8; + bCheck = 0; + } + + /**Check MAC*/ + ucFrameTocalculateMac = data[0]; + GetFrameMAC(pRssp2->NodeInfo.maslParam.ks1, pRssp2->NodeInfo.maslParam.ks2, pRssp2->NodeInfo.maslParam.ks3, pRssp2->NodeInfo.maslParam.localCtcsID, btMac, &ucFrameTocalculateMac, 1); + rslt = CommonMemCmp(data + index, btMac, 8); + if ((1 == bCheck) && (0 != rslt)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 36, "P5036:MASL:AR MAC error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 4; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 4; + bCheck = 0; + } + /**Check if it Should AR*/ + if ((1 == bCheck) && (MASL_STATE_CONNECTING == pRssp2->NodeInfo.maslParam.status)) + { + if (MASL_CONNECTION_WAITING_FOR_AU2 == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 37, "P5037:MASL:get AR instead AU2 error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x21; + bCheck = 0; + } + else if (MASL_CONNECTION_WAITING_FOR_AU3 == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 38, "P5038:MASL:get AR instead AU3 error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x22; + bCheck = 0; + } + else + { + /* Уͨ */ + } + } + else if ((1 == bCheck) && (MASL_STATE_CONNECTED == pRssp2->NodeInfo.maslParam.status)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 39, "P5039:MASL:get AR while connect error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 5; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x04; + bCheck = 0; + } + else if ((1 == bCheck) && (MASL_STATE_DISCONNECTED == pRssp2->NodeInfo.maslParam.status)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 40, "P5040:MASL:get AR while disconnect error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 5; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x14; + bCheck = 0; + } + else + { + /* Уͨ */ + } + } + + if (1 == bCheck) + { + /** update Connection State*/ + pRssp2->NodeInfo.maslParam.status = MASL_STATE_CONNECTED; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 48, "P5048:MASL:recv AR success MASL CONNECTED\n", + 0, 0, 0, 0, 0, 0, 0); + + /* init send ECStart */ + if (MASL_ROLE_INITIATOR == pRssp2->NodeInfo.maslParam.role)/*ECStart */ + { + pRssp2->LinkStatus = RSSP2_SEND_ECSTART; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 49, "P5049:MASL:Link state change to ECSTART\n", + 0, 0, 0, 0, 0, 0, 0); + } + } + return bCheck; +} + +/****************************************************************************** +ܣա DT SaPdu +MASLУͨаSAIģSAI +룺pRssp2: Rssp2 object + UINT8 *data, UINT16 len DT SaPdu + pRssp2->NodeInfo.maslParam MASL״̬ + + pOutData SAI + pRssp2->NodeInfo.maslParam MASL״̬ + pRssp2->LinkStatus ·״̬ +ֵ UINT16 SAIij +******************************************************************************/ +LOCAL UINT16 ProcessDtSaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData) +{ + UINT16 ret = 0; + UINT8 btMac[8] = { 0 }; + UINT8 ucFrameTocalculateMac = 0; + UINT8 rmtDevType = 0; + UINT16 index = 0; + UINT32 rmtCtcsId = 0; + UINT8 saf = 0; + LPMASL_PARAM pMasl = NULL; + UINT8 bCheck = 1; + + if ((NULL == pRssp2) || (NULL == data) || (NULL == pOutData)) + { + bCheck = 0; + } + if (1 == bCheck) + { + pMasl = &pRssp2->NodeInfo.maslParam; + + /**Check etcsIDType*/ + if ((data[0] >> 5) != 0x00) + { + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 9; + bCheck = 0; + } + + /**Check if it Should DT*/ + if (MASL_STATE_CONNECTING == pRssp2->NodeInfo.maslParam.status) + { + if (MASL_CONNECTION_WAITING_FOR_AU2 == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 43, "P5043:MASL:get DT instead AU2 error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x31; + bCheck = 0; + } + if (MASL_CONNECTION_WAITING_FOR_AU3 == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 44, "P5044:MASL:get DT instead AU3 error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x32; + bCheck = 0; + } + if (MASL_CONNECTION_WAITING_FOR_AR == pRssp2->NodeInfo.maslParam.connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 45, "P5045:MASL:get DT instead AR error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 9; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x33; + bCheck = 0; + } + } + /* connection should be established */ + else if (MASL_STATE_CONNECTED != pRssp2->NodeInfo.maslParam.status) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 41, "P5041:MASL:get DT while not connect error\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 255; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 5; + bCheck = 0; + } + else + { + /* Уͨ */ + } + } + if (1 == bCheck) + { + /**Check MAC*/ + GetFrameMAC(pRssp2->NodeInfo.maslParam.ks1, pRssp2->NodeInfo.maslParam.ks2, pRssp2->NodeInfo.maslParam.ks3, pRssp2->NodeInfo.maslParam.localCtcsID, btMac, data, len - 8); + if (0 != CommonMemCmp(data + (len - 8), btMac, 8)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 42, "P5042:MASL:DT MAC error\n", + 0, 0, 0, 0, 0, 0, 0); + bCheck = 0; + } + } + + if (1 == bCheck) + { + /**put data to SAI*/ + ret = len - 9; + CommonMemCpy(pOutData, ret, data + 1, ret); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 50, "P5050:MASL:recv success, saiLen=%d\n", + 1, ret, 0, 0, 0, 0, 0); + } + else + { + ret = 0; + } + return ret; +} + +/****************************************************************************** +ܣա DI SaPdu +յЧDI SaPduʱͷűȫӣλز + DI SaPduУʧʱ±뷢DI״̬Ͽȫӵ +룺pRssp2: Rssp2 object + UINT8 *data, UINT16 len DI SaPdu + pRssp2->NodeInfo.maslParam MASL״̬ + + pRssp2->NodeInfo ڵ״̬ + pRssp2->LinkStatus ·״̬ +ֵ UINT16 1ɹ 0ʧ +******************************************************************************/ +LOCAL UINT8 ProcessDiSaPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2) +{ + UINT8 bCheck = 1; + UINT16 index = 0; + + /**Check etcsIDType*/ + if ((data[index++] >> 5) != 0x00) + { + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 8; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 0x0a; + bCheck = 0; + } + if (1 == bCheck) + { + pRssp2->NodeInfo.maslParam.discIndication.reason = data[index++]; + pRssp2->NodeInfo.maslParam.discIndication.subReason = data[index++]; + + pRssp2->NodeInfo.maslParam.status = MASL_STATE_DISCONNECTED; + pRssp2->NodeInfo.saiParam.status = SAI_STATE_DISCONNECTED; + pRssp2->NodeInfo.maslParam.connStatus = MASL_CONNECTION_NONE; + pRssp2->NodeInfo.tcpParam.TCPCtrl = TCP_CTRL_DISCONNECT; + + /* λصRSSP2 */ + /* EC */ + pRssp2->NodeInfo.saiParam.NextEx = 0; + /* յEC */ + pRssp2->NodeInfo.saiParam.recvSN = 0; + /* յĴ */ + pRssp2->NodeInfo.aleParam.recvTS = 0; + /* ͵EC */ + pRssp2->NodeInfo.aleParam.sendTS = 0; + /* ͵Ĵ */ + pRssp2->NodeInfo.saiParam.sendSN = 0; + pRssp2->NodeInfo.saiParam.Tstart = 0; + pRssp2->NodeInfo.saiParam.UpdCount = 0; + pRssp2->NodeInfo.maslParam.Tconnect = 0; + pRssp2->NodeInfo.maslParam.Tau1 = 0; + pRssp2->NodeStatus = NODE_REPLACE; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 124, "P5124:MASL:recv DI msg0x%02x%02x\n", 2, + pRssp2->NodeInfo.maslParam.discIndication.reason, + pRssp2->NodeInfo.maslParam.discIndication.subReason, 0, 0, 0, 0); + } + return bCheck; +} + +/****************************************************************************** +ܣbuild EC Start SAI msg +룺pRssp2 RSSP2 Object +pOutData SAI +ֵUINT16 SAIij +******************************************************************************/ +LOCAL UINT16 BuildEcStartData(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8 *pOutData) +{ + UINT16 index = 0; + LPSAI_PARAM pSai = NULL; + RSSP2_DEVICE_TYPE localEtcsType = DEVICE_TYPE_UNKNOWN; + RSSP2_DEVICE_TYPE remoteEtcsType = DEVICE_TYPE_UNKNOWN; + + if ((NULL == pRssp2) || (NULL == pOutData)) + { + index = 0; + } + else + { + GetEtcsTypeFromEtcsId(pRssp2->LocalEtcsId, &localEtcsType); + GetEtcsTypeFromEtcsId(pRssp2->DestEtcsId, &remoteEtcsType); + + pSai = &pRssp2->NodeInfo.saiParam; + + pSai->sendSN = 0; + pSai->sendEC = 0; + + pOutData[index++] = 0x81; + /**SN*/ + pOutData[index++] = HIBYTE(pSai->sendSN); + pOutData[index++] = LOBYTE(pSai->sendSN); + CommonMemSet(&pOutData[index], 12, 0, 12); + index += 12; + /**EC*/ /* TO BE DONE ECϢдλô */ + pOutData[index++] = HIBYTE(HIWORD(pSai->sendEC)); + pOutData[index++] = LOBYTE(HIWORD(pSai->sendEC)); + pOutData[index++] = HIBYTE(LOWORD(pSai->sendEC)); + pOutData[index++] = LOBYTE(LOWORD(pSai->sendEC)); + /**Version*/ + pOutData[index++] = HIBYTE(HIWORD(SAI_VERSION)); + pOutData[index++] = LOBYTE(HIWORD(SAI_VERSION)); + pOutData[index++] = HIBYTE(LOWORD(SAI_VERSION)); + pOutData[index++] = LOBYTE(LOWORD(SAI_VERSION)); + /**EC Period*/ + /* edit 20170324 xb ATSЭ */ + if (((DEVICE_TYPE_ATP == localEtcsType)||(DEVICE_TYPE_AOM == localEtcsType))&& (DEVICE_TYPE_ATS == remoteEtcsType)) + { + /* VOBCԷATSʱд崦 */ + pOutData[index++] = HIBYTE(2000); + pOutData[index++] = LOBYTE(2000); + } + else + { + pOutData[index++] = HIBYTE(pSai->comECPeriod); + pOutData[index++] = LOBYTE(pSai->comECPeriod); + } + /**message len*/ + pSai->sendSN++; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 115, "P5115:SAI:Build EC Start1:0x%02x %02x %02x %02x \n", 4, + pOutData[0], pOutData[1], pOutData[2], pOutData[3], pOutData[4], pOutData[5]); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 115, "P5115:SAI:Build EC Start2:0x%02x %02x %02x %02x \n", 4, + pOutData[6], pOutData[7], pOutData[8], pOutData[9], pOutData[10], pOutData[11]); + } + return index; +} + +/****************************************************************************** +ܣbuild APP SAI msg +Ҫ͵ӦñķװSAI + ҪӦACK,޸ӦSAIϢ + ҪACK,޸ӦSAIϢͲ¼ʱ +룺pRssp2 RSSP2 Object + data, len Ӧñ + Now ķʱ +pOutData װӦñĵSAIӦñ +ֵUINT16 SAIij +******************************************************************************/ +LOCAL UINT16 BuildSaiMsg(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT8* pOutData) +{ + LPSAI_PARAM pSai = NULL; + UINT16 index = 0; + RSSP2_DEVICE_TYPE localEtcsType = DEVICE_TYPE_UNKNOWN; + RSSP2_DEVICE_TYPE remoteEtcsType = DEVICE_TYPE_UNKNOWN; + + if ((NULL == data) || (NULL == pRssp2) || (NULL == pOutData)) + { + index = 0; + } + else + { + GetEtcsTypeFromEtcsId(pRssp2->LocalEtcsId, &localEtcsType); + GetEtcsTypeFromEtcsId(pRssp2->DestEtcsId, &remoteEtcsType); + pSai = &pRssp2->NodeInfo.saiParam; + /**message type*/ + if (TRUE == pSai->bAck) + { + pOutData[index++] = 0x88; + pSai->bAck = FALSE; + } + else if (SAI_REQACK_START == pSai->statesReqACK) + { + pOutData[index++] = 0x87; + pSai->statesReqACK = SAI_REQACK_WAITING_ACK; + pSai->requestofAckTime = Now;/* use to judge Ack timeout */ + } + else + { + pOutData[index++] = 0x86; + } + + /**SN*/ + pOutData[index++] = HIBYTE(pSai->sendSN); + pOutData[index++] = LOBYTE(pSai->sendSN); + + /* TTS0 */ + CommonMemSet(pOutData + index, 12, 0, 12); + index += 12; + + /**EC*/ + if (((DEVICE_TYPE_ATP == localEtcsType)||(DEVICE_TYPE_AOM == localEtcsType)) && (DEVICE_TYPE_ATS == remoteEtcsType)) + { + /* VOBCԷATSʱд崦 */ + pOutData[index++] = HIBYTE(HIWORD(pSai->sendEC/7)); + pOutData[index++] = LOBYTE(HIWORD(pSai->sendEC/7)); + pOutData[index++] = HIBYTE(LOWORD(pSai->sendEC/7)); + pOutData[index++] = LOBYTE(LOWORD(pSai->sendEC/7)); + } + else + { + pOutData[index++] = HIBYTE(HIWORD(pSai->sendEC)); + pOutData[index++] = LOBYTE(HIWORD(pSai->sendEC)); + pOutData[index++] = HIBYTE(LOWORD(pSai->sendEC)); + pOutData[index++] = LOBYTE(LOWORD(pSai->sendEC)); + } + + /**Data*/ + CommonMemCpy(pOutData + index, len, data, len); + /**message len*/ + index += len; + + pSai->sendSN++; + } + return index; +} + +/****************************************************************************** +ܣbuild EC Start ALEPKT + EC Start msg װALEPKT + ѷEC StartSAI״̬,¼EC Startʱ +룺pRssp2 RSSP2 Object + Now ķʱ +pOutData ALEPKT + pRssp2->NodeInfo.saiParam SAI״̬ +ֵUINT16 ALEPKT +******************************************************************************/ +LOCAL UINT16 SendEcStart(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT8 *pOutData) +{ + MASL_PARAM *pMasl = &(pRssp2->NodeInfo.maslParam); + SAI_PARAM *pSai = &(pRssp2->NodeInfo.saiParam); + UINT8 tmpData[MAX_RSSP2_DATA_LEN] = { 0 }; + UINT8 maslData[MAX_RSSP2_DATA_LEN] = { 0 }; + UINT16 ret = 0; + + ret = BuildEcStartData(pRssp2, tmpData); + ret = BuildDtSaPduData(pRssp2, tmpData, ret, maslData); + /**DT to CFM*/ + ret = BuildAleData(pRssp2, ALE_PACK_TYPE_DT, maslData, ret, pOutData); + /*send data */ + pSai->status = SAI_STATE_CONNECTING; + pSai->Tstart = Now;/* use to check SAI connect timeout */ + + return ret; +} + +/****************************************************************************** +ܣbuild APP ALEPKT +ӦϢװALEPKT + ̣ӦϢ>>SAIӦϢ>>MASL DT SaPdu>>ALEKPKT +룺 + data, len ӦϢ + pRssp2 RSSP2 Object + Now Ϣʱ + + pOutData ALEPKT +ֵUINT16 ALEPKT +******************************************************************************/ +UINT16 BuildRSSP2Data(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now, UINT8 *pOutData) +{ + UINT16 ret = 0; + UINT8 saiData[MAX_SAI_DATA_LEN] = { 0 }; + UINT8 maslData[MAX_MASL_DATA_LEN] = { 0 }; + + if ((MASL_STATE_CONNECTED != pRssp2->NodeInfo.maslParam.status) || (SAI_STATE_CONNECTED != pRssp2->NodeInfo.saiParam.status)) + { + ret = 0; + } + else + { + ret = BuildSaiMsg(data, len, pRssp2, Now, saiData); + ret = BuildDtSaPduData(pRssp2, saiData, ret, maslData); + ret = BuildAleData(pRssp2, ALE_PACK_TYPE_DT, maslData, ret, pOutData); + } + return ret; +} + +/****************************************************************************** +ܣա SAI msg +룺pRssp2 RSSP2 Object + data,len SAI msg SAI + Now յSAI msgʱ + + pOutData APP msg ȥSAI֮Ӧñ + pRssp2->NodeInfo.saiParam SAI״̬ +ֵUINT16 APP msg +******************************************************************************/ +LOCAL UINT16 ProcessSaiPdu(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT32 Now, UINT8* pOutData) +{ + UINT16 appLen = 0; + UINT8 msgType = 0; + + SAI_PARAM *pSai = &(pRssp2->NodeInfo.saiParam); + + msgType = data[0]; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 52, "P5052:SAI:Parse Start:type=%d,len=%d\n", 2, + msgType, len, 0, 0, 0, 0); + if (0x81 == msgType)/**ExecutionCycleStart*/ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 53, "P5053:SAI:Passe EC Start\n", 0, 0, 0, 0, 0, 0, 0); + ProcessEcStart(data, len, pRssp2, Now); + } + else if ((0x86 == msgType) || (0x87 == msgType) || (0x88 == msgType)) + {/**SAI appmsg protected by EC*/ + appLen = ProcessAppMsg(data, len, pRssp2, pOutData); + } + else + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 63, "P5063:SAI:msgType error:%d\n", 1, msgType, 0, 0, 0, 0, 0); + } + + return appLen; +} + +/****************************************************************************** +ܣա EC Start SAI msg +ͨŷֻSAI connectingʱEC StartϢ + ͨŽշֻSAI connectedʱEC StartϢ + յEC StartϢʱøEC +룺pRssp2 RSSP2 Object + data,len EC Start SAI msg + Now EC Startʱ +pRssp2->NodeInfo.saiParam SAI״̬ +ֵUINT8 1ɹ 0ʧ +******************************************************************************/ +LOCAL UINT8 ProcessEcStart(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now) +{ + UINT8 ret = 0; + UINT8 zeros[12] = { 0 }; + MASL_PARAM *pMasl = &(pRssp2->NodeInfo.maslParam); + SAI_PARAM *pSai = &(pRssp2->NodeInfo.saiParam); + UINT32 recVersion = MAKELONG(MAKEWORD(data[22], data[21]), MAKEWORD(data[20], data[19])); + ret = 1; + if (recVersion != SAI_VERSION) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 54, "P5054:SAI:ECStart version check fail:%d,%d\n", 2, + recVersion, SAI_VERSION, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 255; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 1; + ret = 0; + } + if (1 == ret) + { + CommonMemSet(zeros, 12, 0, 12); + if (0 != CommonMemCmp(data + 3, zeros, 12)) + { + ret = 0; + } + + } + if (1 == ret) + { + ret = 0; + if (MASL_ROLE_INITIATOR == pMasl->role) + {/**is initiator*/ + if (SAI_STATE_CONNECTING == pSai->status) + {/**only when connecting*/ + pSai->status = SAI_STATE_CONNECTED; + ret = 1; + } + } + else + {/**is not initiator then send ECStart*/ + if (SAI_STATE_DISCONNECTED == pSai->status) + {/**only when disconnected*/ + pRssp2->LinkStatus = RSSP2_SEND_ECSTART; + pSai->status = SAI_STATE_CONNECTING; + ret = 1; + } + } + + if (ret == 1) + { + /** Save SN EC ECPeriod*/ + pSai->recvSN = MAKEWORD(data[2], data[1]); + pSai->SuccError = 0; + pSai->recvEC = MAKELONG(MAKEWORD(data[18], data[17]), MAKEWORD(data[16], data[15])); +#ifndef RSSP2_PREDEF_R + pSai->remoteECPeriod = MAKEWORD(data[24], data[23]); + pSai->R = (double)((double)pSai->localECPeriod / (double)pSai->remoteECPeriod); +#endif + pSai->NextEx = (double)pSai->recvEC; + pSai->Tstart = Now; + pSai->EcState = 0; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 55, + "P5055:SAI:recv ECStart:recvSN=%d,recvEC=%d,remoteECPer=%d,time=%d\n", 4, + pSai->recvSN, pSai->recvEC, pSai->remoteECPeriod, pSai->Tstart, 0, 0); + } + } + return ret; +} + +/****************************************************************************** +ܣա SAI App msg +SAIECļ飨SAI㽨ӺÿڽEC飬ԷRSSP2ڴͳһ + "ӦӦϢ"¼ACK־ + "ӦӦϢ"ӦĵȴӦ־ +룺pRssp2 RSSP2 Object + data,len SAI APP msg SAIӦñ + + pOutData APP msg ȥSAI֮Ӧñ + pRssp2->NodeInfo.saiParam SAI״̬ +ֵUINT16 ALEPKT +******************************************************************************/ +LOCAL UINT16 ProcessAppMsg(UINT8 *data, UINT16 len, LPRSSP2_LNK_INFO_NODE_STRU pRssp2, UINT8* pOutData) +{ + UINT16 ret = 0; + SAI_PARAM* pSai = NULL; + UINT16 recvSN = 0; + INT recvSNDiff = 0; + UINT8 msgType = 0; + UINT8 bCheck = 1; + UINT8 zeros[12] = { 0 }; + + if ((NULL == data) || (NULL == pRssp2)) + { + bCheck = 0; + } + if (1 == bCheck) + { + msgType = data[0]; + pSai = &pRssp2->NodeInfo.saiParam; + /** deal SN*/ + recvSN = MAKEWORD(data[2], data[1]); + recvSNDiff = GetSNDiff(recvSN, pSai->recvSN); + + if (1 == recvSNDiff) + { + pSai->SuccError = 0; + } + else + { + pSai->SuccError++; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 130, "P5130:SAI:successive error detect:msg=%d,exp=%d,succ=%d\n", + 3, recvSN, pSai->recvSN + 1, pSai->SuccError, 0, 0, 0); + } + if (pSai->SuccError > pSai->MaxSuccErrorCount) + { /* successive error */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 129, "P5129:SAI:max successive error reached\n", 0, 0, 0, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 255; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 8;/* TO BE DONE */ + bCheck = 0; + } + + if (recvSNDiff <= 0) + {/**Old Message */ + /*printf("old Message!\n");*/ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 57, "P5057:SAI:old SN detect:recv=%d,last=%d\n", + 2, recvSN, pSai->recvSN, 0, 0, 0, 0); + bCheck = 0; + } + else if ((recvSNDiff > 0) && (recvSNDiff < pSai->Parameter_N)) + {/** normal Message */ + pSai->recvSN = recvSN; + } + else + {/** ab normal Message */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 58, "P5058:SAI:SN check fail:recv=%d,last=%d\n", + 2, recvSN, pSai->recvSN, 0, 0, 0, 0); + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 255; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 2; + bCheck = 0; + } + } + /* TO BE DONE TTS */ + if (1 == bCheck) + { + CommonMemSet(zeros, 12, 0, 12); + if (0 != CommonMemCmp(&data[3], zeros, 12)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 56, "P5056:SAI:TTS region check fail\n", + 0, 0, 0, 0, 0, 0, 0); + bCheck = 0; + } + } + + if (1 == bCheck) + { + /** deal responder connection*/ + if ((SAI_STATE_CONNECTING == pSai->status) && (MASL_ROLE_RESPONDER == pRssp2->NodeInfo.maslParam.role)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 59, "P5059:SAI:state change to CONNECTED\n", + 0, 0, 0, 0, 0, 0, 0); + pSai->status = SAI_STATE_CONNECTED; + } + + /**Recv EC*/ + pSai->recvEC = MAKELONG(MAKEWORD(data[18], data[17]), MAKEWORD(data[16], data[15])); + + /**Deal detection of delay*/ + switch (msgType) + { + case 0x86: /*appmsg protected by EC */ + break; + case 0x87: /*appmsg protected by EC, with Request of Ack */ + pSai->bAck = TRUE; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 60, "P5060:SAI:recv Ack Request\n", + 0, 0, 0, 0, 0, 0, 0); + break; + case 0x88: /*appmsg protected by EC, with Ack */ + pSai->statesReqACK = SAI_REQACK_NULL; + pSai->UpdCount = 0; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 61, "P5061:SAI:recv Ack\n", + 0, 0, 0, 0, 0, 0, 0); + break; + default: + break; + } + /* data to app */ + /** Data to User*/ + Rssp2MemCopy(data + 19, pOutData, len - 19); + + ret = len - 19; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 62, "P5062:SAI:recv app success:EC=%d,appLen=%d\n", + 2, pSai->recvEC, ret, 0, 0, 0, 0); + } + else + { + ret = 0; + } + return ret; +} + + +/****************************************************************************** +ܣEC +ʵECECУ׼ +룺pRssp2 RSSP2 Object + Now ǰʱ + + pRssp2->NodeInfo.saiParam еEC״̬ +ֵvoid +******************************************************************************/ +LOCAL VOID ECProc(LPRSSP2_LNK_INFO_NODE_STRU pRssp2, RSSP2TIME Now) +{ + if (NULL != pRssp2) + { + /*EC check */ + ECCheck(pRssp2); + + /* ʱ */ + /** RequestofAck cyclelly*/ + if (0 == (++pRssp2->NodeInfo.saiParam.sendEC%pRssp2->NodeInfo.saiParam.Ack_Request_Cycle_Rate)) + { + pRssp2->NodeInfo.saiParam.statesReqACK = SAI_REQACK_START; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 93, "P5093:EC:request ack\n", + 0, 0, 0, 0, 0, 0, 0); + } + /** RequestofAck timeout*/ + if (SAI_REQACK_WAITING_ACK == pRssp2->NodeInfo.saiParam.statesReqACK) + { + if (GetTimeDiff(Now, pRssp2->NodeInfo.saiParam.requestofAckTime) * pRssp2->NodeInfo.saiParam.localECPeriod > (DOUBLE)(pRssp2->NodeInfo.saiParam.Timer_Syn)) + { + pRssp2->NodeInfo.saiParam.statesReqACK = SAI_REQACK_START; + pRssp2->NodeInfo.saiParam.UpdCount++; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 94, "P5094:EC:request ack timeout\n", + 0, 0, 0, 0, 0, 0, 0); + } + } + /* RequestofAck fail */ + if (pRssp2->NodeInfo.saiParam.UpdCount >= pRssp2->NodeInfo.saiParam.UpdFailCountMax) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 128, "P5128:EC:request ack fail\n", + 0, 0, 0, 0, 0, 0, 0); + pRssp2->NodeInfo.saiParam.statesReqACK = SAI_REQACK_NULL; + pRssp2->NodeInfo.saiParam.UpdCount = 0; + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 255; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 7; + } + } +} + +/****************************************************************************** +ܣʵEC +EC̷ֵΧʱ·״̬ת"DI"ȫӶϿ + + pRssp2->NodeInfo.saiParam еEC״̬ +ֵvoid +******************************************************************************/ +LOCAL VOID ECCheck(LPRSSP2_LNK_INFO_NODE_STRU pRssp2) +{ + /* */ +#ifndef FLOAT_OPT_SIM + DOUBLE dCurrEx = pRssp2->NodeInfo.saiParam.NextEx; /* ǰEx (ֵ)=ԷEC(dzֵ)=ϴEx */ + pRssp2->NodeInfo.saiParam.NextEx = dCurrEx + pRssp2->NodeInfo.saiParam.R; /* Ex=ǰEx+R */ + pRssp2->NodeInfo.saiParam.EcDelta = (INT32)(dCurrEx - pRssp2->NodeInfo.saiParam.recvEC); /* Delta=ǰEx-ԷEC */ +#else + UINT32 dwCurrEx = pRssp2->NodeInfo.saiParam.NextExM; /* ǰEx (ֵ)=ԷEC(dzֵ)=ϴEx */ + pRssp2->NodeInfo.saiParam.NextExM = dwCurrEx + pRssp2->NodeInfo.saiParam.RM; /* Ex=ǰEx+R */ + pRssp2->NodeInfo.saiParam.EcDelta = (LONG)(dwCurrEx - pRssp2->NodeInfo.saiParam.recvEC * 10) / 10; /* Delta=ǰEx-ԷEC */ +#endif + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 89, "P5089:EC:(0x%04x)Check Start Ex=%d,RecEc=%d,Delta=%d,NextEx=%d\n", + 5,(UINT16)(pRssp2->DestDevName), + (UINT16)dCurrEx, + (UINT16)(pRssp2->NodeInfo.saiParam.recvEC), + (UINT16)(pRssp2->NodeInfo.saiParam.EcDelta), + (UINT16)(pRssp2->NodeInfo.saiParam.NextEx), 0); + if (pRssp2->NodeInfo.saiParam.EcDelta == 0)/* EC */ + { + pRssp2->NodeInfo.saiParam.EcState = 0; + } + else if (pRssp2->NodeInfo.saiParam.EcDelta < 0)/* Է͵ÿ */ + { + pRssp2->NodeInfo.saiParam.EcState = 0; +#ifndef FLOAT_OPT_SIM + pRssp2->NodeInfo.saiParam.NextEx = pRssp2->NodeInfo.saiParam.recvEC + pRssp2->NodeInfo.saiParam.R; +#else + pRssp2->NodeInfo.saiParam.NextExM = pRssp2->NodeInfo.saiParam.recvEC * 10 + pRssp2->NodeInfo.saiParam.RM; +#endif + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 90, "P5090:EC:(0x%04x)-Delta detect Delta=%d,NextEx=%d\n", + 3, (UINT16)(pRssp2->DestDevName), (UINT16)pRssp2->NodeInfo.saiParam.EcDelta, (UINT16)(pRssp2->NodeInfo.saiParam.NextEx), 0, 0, 0); + } + else if (pRssp2->NodeInfo.saiParam.EcDelta < pRssp2->NodeInfo.saiParam.Parameter_ALARM)/* Է͵̷Χ */ + { + if (pRssp2->NodeInfo.saiParam.EcDelta != (LONG)pRssp2->NodeInfo.saiParam.EcState) + { + pRssp2->NodeInfo.saiParam.Delta_equal_count = 0;/* ǰDeltaֵϴεDeltaֵһʼ */ + } + else + { + pRssp2->NodeInfo.saiParam.Delta_equal_count++; /* DeltaֵǰһDeltaֵȣֵ1 */ + } + + pRssp2->NodeInfo.saiParam.EcState = pRssp2->NodeInfo.saiParam.EcDelta;/*EC״̬ */ + + if (pRssp2->NodeInfo.saiParam.Delta_equal_count >= pRssp2->NodeInfo.saiParam.Max_Cycles_In_Same_Delta_Value)/* Deltaʱͣͬһ״̬СExҽECĴʱ */ + { +#ifndef FLOAT_OPT_SIM + pRssp2->NodeInfo.saiParam.NextEx -= 1; +#else + pRssp2->NodeInfo.saiParam.NextExM -= 1; +#endif + pRssp2->NodeInfo.saiParam.statesReqACK = SAI_REQACK_START; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 91, "P5091:EC:(0x%04x)ExEC fixed,NextEx=%d\n", + 2, (UINT16)(pRssp2->DestDevName), (UINT16)(pRssp2->NodeInfo.saiParam.NextEx), 0, 0, 0, 0); + } + } + else/* ̷Χ */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 92, "P5092:EC:(0x%04x)check fail delta=%d\n", + 2, (UINT16)(pRssp2->DestDevName), (UINT16)(pRssp2->NodeInfo.saiParam.EcDelta), 0, 0, 0, 0); + pRssp2->NodeInfo.saiParam.EcState = 0; + pRssp2->LinkStatus = RSSP2_SEND_DI; + pRssp2->NodeInfo.maslParam.discIndication.reason = 255; + pRssp2->NodeInfo.maslParam.discIndication.subReason = 3; + pRssp2->NodeInfo.saiParam.status = SAI_STATE_DISCONNECTED; + pRssp2->NodeInfo.maslParam.status = MASL_STATE_DISCONNECTED; + pRssp2->NodeInfo.maslParam.connStatus = 0; + } +} + +/*********************************************************************** + * : CheckRssp2Struct + * : ͳһṹĸĿм + * : + * + * -------------------------------------------------------------- + * pRssp2Struct const RSSP2_INFO_STRU* IN RSSP2ͳһṹ + * + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ +static UINT8 CheckRssp2Struct(const RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; + const UINT16 MaxDataLen = MAX_RSSP2_MSG; /* ӦݴС1400-22 */ + + /* ͳһṹָ벻Ϊ */ + if (pRssp2Struct != NULL) + { + ret = 1; + /* Ŀ */ + if ((pRssp2Struct->MaxNumLink == 0) || (pRssp2Struct->MaxNumPerCycle == 0)) + { + ret = 0; + } + + /* Ӧ */ + if ((0 == pRssp2Struct->InputSize) || (pRssp2Struct->InputSize > MaxDataLen)) + { + ret = 0; + } + + /* Ӧ */ + if ((0 == pRssp2Struct->OutputSize) || (pRssp2Struct->OutputSize > MaxDataLen)) + { + ret = 0; + } + + /* ں */ + if (pRssp2Struct->CycleNum == NULL) + { + ret = 0; + } + + /* */ + if (pRssp2Struct->RandomNum == NULL) + { + ret = 0; + } + } + else + { + ret = 0; + } + return ret; +} + +/****************************************************************************** +ܣSFMʱEC +룺LPRSSP2_INFO_STRU RSSP2ڲʹýṹ + +ֵvoid +******************************************************************************/ +void Rssp2TimeOutCheck(LPRSSP2_INFO_STRU pRssp2) +{ + ALE_PARAM *pAle = NULL; + MASL_PARAM *pMasl = NULL; + SAI_PARAM *pSai = NULL; + RSSP2_LNK_INFO_NODE_STRU *pRssp2LnkNode = NULL; + UINT32 cycle = *pRssp2->CycleNum; + UINT8 lnkNum = pRssp2->MaxNumLink; + UINT8 i = 0; + + for (i = 0; i < lnkNum; i++) + { + pRssp2LnkNode = &pRssp2->LnkNodeArr[i]; + + if (NODE_DISBALED_REPLACE == pRssp2LnkNode->NodeStatus) + { + pAle = &pRssp2LnkNode->NodeInfo.aleParam; + pMasl = &pRssp2LnkNode->NodeInfo.maslParam; + pSai = &pRssp2LnkNode->NodeInfo.saiParam; + + + if (MASL_STATE_CONNECTED == pMasl->status) + { + if (SAI_STATE_CONNECTED == pSai->status)/* SAIʱִEC */ + { + ECProc(pRssp2LnkNode, cycle); + } + else if (SAI_STATE_CONNECTING == pSai->status) /* SAI㽨ʱ */ + { + + if (GetTimeDiff(cycle, pSai->Tstart) * pSai->localECPeriod >= (DOUBLE)(pSai->Timer_Syn)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 87, "P5087:TIMEOUT:SAI connect timeout:Tstart=%d,Now=%d\n", 2, + pSai->Tstart, cycle, 0, 0, 0, 0); + pRssp2LnkNode->LinkStatus = RSSP2_SEND_DI; + pRssp2LnkNode->NodeInfo.maslParam.discIndication.reason = 255; + pRssp2LnkNode->NodeInfo.maslParam.discIndication.subReason = 4; + } + } + else + { + if (GetTimeDiff(cycle, pMasl->Tconnect) * pSai->localECPeriod >= (DOUBLE)(pMasl->Testab))/* ʼSAI㽨ʱ */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 133, "P5133:TIMEOUT:MASL connect timeout:Tcon=%d,Now=%d\n", 2, + pMasl->Tconnect, cycle, 0, 0, 0, 0); + pRssp2LnkNode->LinkStatus = RSSP2_SEND_DI; + pRssp2LnkNode->NodeInfo.maslParam.discIndication.reason = 7; + pRssp2LnkNode->NodeInfo.maslParam.discIndication.subReason = 0x13; + } + } + } + else if (MASL_STATE_CONNECTING == pMasl->status) + { + if (GetTimeDiff(cycle, pMasl->Tconnect) * pSai->localECPeriod >= (DOUBLE)(pMasl->Testab))/* MASL㽨ʱ */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 88, "P5088:TIMEOUT:MASL connect timeout:Tcon=%d,Now=%d\n", 2, + pMasl->Tconnect, cycle, 0, 0, 0, 0); + pRssp2LnkNode->LinkStatus = RSSP2_SEND_DI; + pRssp2LnkNode->NodeInfo.maslParam.discIndication.reason = 7; + pRssp2LnkNode->NodeInfo.maslParam.discIndication.subReason = 3; + } + + if (MASL_CONNECTION_WAITING_FOR_AU2 == pMasl->connStatus)/* ALEʱ */ + { + /* MASLAU1AU2ʵϾALECR()CC(ȷ)ALEʱǵȴAU2ʱ */ + if (GetTimeDiff(cycle, pMasl->Tau1) * pSai->localECPeriod >= (DOUBLE)(pMasl->Tsyn)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 127, "P5127:TIMEOUT:(0x%04x)ALE connect timeout:Tau1=%d,Now=%d\n", 3, + pRssp2LnkNode->DestDevName, pMasl->Tau1, cycle, 0, 0, 0); + /* edit 20161210 xb AU1ʧʱٷͶ֡ */ +#if 0 + pRssp2LnkNode->LinkStatus = RSSP2_SEND_DI; + pRssp2LnkNode->NodeInfo.maslParam.discIndication.reason = 255; + pRssp2LnkNode->NodeInfo.maslParam.discIndication.subReason = 6; +#else + pRssp2LnkNode->LinkStatus = RSSP2_SEND_AU1; + pMasl->connStatus = MASL_CONNECTION_NONE; + pMasl->status = MASL_STATE_DISCONNECTED; + pRssp2LnkNode->NodeInfo.aleParam.sendTS = 0; +#endif + } + } + } + else + { + /**/ + } + + if ((RSSP2_SEND_DI == pRssp2LnkNode->LinkStatus) && (TCP_STATE_DISCONNECTED == pRssp2LnkNode->NodeInfo.tcpParam.TCPState)) + {/* ڵ״̬ΪDI(RSSP2ȷ϶),ӦTCP״̬Ϊ"ѶϿ"ԷͷTCPӣʱ,TCPƸΪ"Ͽ"ӶͷűTCP */ + pRssp2LnkNode->LinkStatus = RSSP2_SEND_NONE; + pRssp2LnkNode->NodeInfo.tcpParam.TCPCtrl = TCP_CTRL_DISCONNECT; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 122, "P5122:TIMEOUT:TCP Disconnected at DI\n", 0, 0, 0, 0, 0, 0, 0); + } + + if ((TCP_CTRL_DISCONNECT == pRssp2LnkNode->NodeInfo.tcpParam.TCPCtrl) && (TCP_STATE_DISCONNECTED == pRssp2LnkNode->NodeInfo.tcpParam.TCPState)) + {/* ǰTCPָΪ"Ͽ",ӦTCP״̬Ϊ"ѶϿ"ʱ,ɾӦڵ */ + pRssp2LnkNode->NodeStatus = NODE_REPLACE; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 120, "P5120:TIMEOUT:Connect Shutdown from=%d,state=%d\n", 2, + pRssp2LnkNode->DestDevName, pRssp2LnkNode->NodeInfo.tcpParam.TCPState, 0, 0, 0, 0); + } + }/* endif ɸǽڵ */ + } +} + +/************************************************************************ +ܣRSSP2ݽ +ֱϢУִڽռ +룺OutnetQueueA RSSP2Ϣ + OutnetQueueB RSSP2Ϣ +************************************************************************/ +UINT8 Rssp2ReceiveDataProc(QueueStruct* OutnetQueueA, QueueStruct* OutnetQueueB, RSSP2_INFO_STRU *pRssp2Stru) +{ + UINT8 ret = 0; + UINT8 procRslt = 0; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_CYC, RSSP2_LOG_CYC_START, "P5255:------------------------------CycStart:%d------------------------------\n", 1, *pRssp2Stru->CycleNum, 0, 0, 0, 0, 0); + + ClearNetsRecvPkgNum(pRssp2Stru); + + /* ȡݣRpToRsУֱӹ */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_CYC, RSSP2_LOG_RED_RECV_START, "P5241:RedNetRecvStart\n", 0, 0, 0, 0, 0, 0, 0); + procRslt = ProcRssp2Data(OutnetQueueA, pRssp2Stru, 0u); + if (procRslt == 1) + { + /* дгɹ */ + ret = 1; + } + else + { + /* return ret;*/ /* ˳ߵijʱ߼ */ + } + /* ȡ RpToRsУֱӹ */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_CYC, RSSP2_LOG_BLUE_RECV_START, "P5242:BlueNetRecvStart\n", 0, 0, 0, 0, 0, 0, 0); + procRslt = ProcRssp2Data(OutnetQueueB, pRssp2Stru, 1u); + if (procRslt == 1) + { + /* дгɹ */ + ret = 1; + } + else + { + /* return ret;*/ + } + + Rssp2TimeOutCheck(pRssp2Stru); + + return ret; +} + +/************************************************************************ +ܣRSSP2Ϣд +RSSP2ϢнЭͨ֡Эͨý֡ͷ+RSSP2Эͨݣ +룺RSSP2Ϣ +************************************************************************/ +UINT8 ProcRssp2Data(QueueStruct* OutnetQueue, RSSP2_INFO_STRU *pRssp2Stru, const UINT8 netIdx) +{ + UINT8 ret = 0; + UINT8 tmpRet = 0; + UINT16 len = 0; + UINT32 tmpLen = 0; + UINT8 index = 0; + UINT8 data[MAX_RSSP2_DATA_LEN] = { 0 }; + UINT8 tmpBuff[2]; + UINT16 devId = 0; + UINT16 logId = 0; + UINT32 dstEtcsId = 0; + UINT8 bCheck = 1; + + tmpLen = QueueStatus(OutnetQueue); + + /* ЭͨýϢͷ + * ϢͷӦдģʵҲͨصȣRSSP2ģ飩ָʾʱʹõŵ͡ԴݵϢ + * ӦݲֲͨʵⲿŵյIJRSSP2Эͨ + * --------------------------------------------- + * ݳ | DestType | DestID | LogId | Ӧ | + * 2ֽ | 1ֽ | 1ֽ | 2ֽ | n | + * --------------------------------------------- + * ʵRSSP2ģڲԻЭ鱣ıݼԴݣͨϵͳԴȽϡ飬ʵ + * ˰ȫԡΪݰȫԭӦֱͨϵͳԴϢͨϢͷʵֻΪ˼ + * 빤ֱڰȫ + */ + ret = 1; + bCheck = 1; + while (tmpLen > 2) + { + /* ֡ʽ 2ֽڳȣ+ */ + tmpRet = QueueScan(2, tmpBuff, OutnetQueue); + if (tmpRet == 1) + { + len = ShortFromChar(tmpBuff); + + /* ж϶Ƿô */ + if (((UINT32)(len + 2) <= tmpLen) && (4 <= len)) + { + Rssp2MemSet(data, sizeof(data), 0x00); + tmpRet = QueueRead(len + 2, data, OutnetQueue);/* ݶ */ + if (tmpRet == 1) + { + /* 2ֽڳ */ + index = 2; + + /* 2ֽtype Id */ + devId = ShortFromChar(&data[index]); + index += 2; + + /* 2ֽ߼Id */ + logId = (ShortFromChar(&data[index])) % 256; + index += 2; + + len = len - 4;/* 豸ID ߼ID */ + + bCheck = dquDevName2EtcsId(devId, logId, &dstEtcsId); + if (1 == bCheck) + { + SetNetsRecvPkgNum(pRssp2Stru, dstEtcsId, netIdx); + + ret &= ProcRssp2Node(dstEtcsId, data + index, len, pRssp2Stru); /* ֻҪнڵ㴦ʧܾͰʧܴ */ + } + else + { + ret = 0;/* ޷ı֡֡ӰĽ */ + } + } + else + { + ret = 0; + bCheck = 0; + } + } + else + { + /*ն*/ + QueueElementDiscard((UINT16)(tmpLen), OutnetQueue); + ret = 0; + bCheck = 0; + } + } + else + { + /* ֣ܳǰѾ֤ */ + ret = 0; + bCheck = 0; + } + if (1 != bCheck) + { + break; + } + tmpLen = QueueStatus(OutnetQueue); + } + + return ret; +} + +/************************************************************************ +ܣRSSP2֡ +ͨŽڵĵRSSP2֡Ľս +룺 + UINT8 devType,Դ豸ͣ UINT8 devId Դ豸ID ͨϵͳָʾԴݣ + UINT8* pData, UINT16 dataLen RSSP2֡ + RSSP2_INFO_STRU* pRssp2Stru RSSP2Эͳһṹ +ֵ UINT8 1ɹ 0ʧ + TCPδʱյݶΪʧ + TCPӣMASLδʱ(ȫӵĹ)յݶΪճɹ + TCPӣMASLʱEcStartʧ(ȫӽʧ)Ϊʧ + TCPӣSAIʱյSAI APPΪճɹ +************************************************************************/ +UINT8 ProcRssp2Node(UINT32 dstEtcsId, UINT8* pData, UINT16 dataLen, RSSP2_INFO_STRU *pRssp2Stru) +{ + UINT8 ret = 0; /* ֵ */ + ALE_PARAM *pAle = NULL; /* ALEָ */ + MASL_PARAM *pMasl = NULL; /* MASLָ */ + SAI_PARAM *pSai = NULL; /* SAIָ */ + RSSP2_LNK_INFO_NODE_STRU *pRssp2LnkNode = NULL; + UINT16 localDevName = 0; /* 豸 */ + UINT16 destDevName = 0; /* Ŀ豸 */ + UINT8 maslData[MAX_RSSP2_DATA_LEN] = { 0 }; /* MASLϢ */ + UINT8 saiData[MAX_RSSP2_DATA_LEN] = { 0 }; /* SAIϢ */ + UINT8 appData[MAX_RSSP2_DATA_LEN] = { 0 }; /* ӦòϢ */ + UINT16 maslLen = 0; /* MASLϢ */ + UINT16 saiLen = 0; /* SAIϢ */ + UINT16 appLen = 0; /* ӦòϢ */ + INT i = 0; /* ѭ */ + UINT8 tmpHeadBuf[6] = { 0 }; /* ڴ洢ӦͨýϢͷĻ */ + UINT8 bCheck = 1; + + /* */ + if ((NULL == pData) || (NULL == pRssp2Stru)) + { + bCheck = 0; + } + + if (1 == bCheck) + { + pRssp2LnkNode = SearchRssp2LnkNode(pRssp2Stru->LocalEtcsId, dstEtcsId, pRssp2Stru); + if (NULL == pRssp2LnkNode)/* TCPӽʱᴴRSSP2ڵ㣬߽֧˵TCPδֱ˳ */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 123, "P5123:RSSP2:Unkown Node msg detect,from:0x%x\n", 1, dstEtcsId, 0, 0, 0, 0, 0); + bCheck = 0; + } + } + if (1 == bCheck) + { + pAle = &pRssp2LnkNode->NodeInfo.aleParam; + pMasl = &pRssp2LnkNode->NodeInfo.maslParam; + pSai = &pRssp2LnkNode->NodeInfo.saiParam; + /* + Rssp2MemSet(maslData, sizeof(maslData), 0); + Rssp2MemSet(saiData, sizeof(saiData), 0); + Rssp2MemSet(appData, sizeof(appData), 0); + */ +#ifdef RSSP2_RECORD_SIMPLIFY_BIN + commonLogMsg(pRssp2Stru->RecordArray, pRssp2Stru->RecordArraySize, RSSP2_LOG_INFO, RSSP2_LOG_NODE_RECV_START, + "P5254:NodeRecvStart:Local=0x%04x,Remote=0x%04x,SAI_STATE=%d,MASL_STATE=%d,COM_STATE=%d\n", 5, + pRssp2LnkNode->LocalDevName, + pRssp2LnkNode->DestDevName, + pRssp2LnkNode->NodeInfo.saiParam.status, + pRssp2LnkNode->NodeInfo.maslParam.status, + pRssp2LnkNode->NodeInfo.maslParam.connStatus, 0); +#endif +#ifdef RSSP2_RECORD_ERR_ASCII + PrintRecArrayByte(vRecArray, vRecArraySize, RSSP2_LOG_NODE_RECV_START);/* տʼ־ */ + /*RSSP2LogBinNodeInfo(pRssp2Stru->RecordArray, pRssp2Stru->RecordArraySize, pRssp2LnkNode);*/ +#endif + } + + if (1 == bCheck) + { + if (TCP_STATE_CONNECTED == pRssp2LnkNode->NodeInfo.tcpParam.TCPState) + { + ret = 1; + if (MASL_STATE_CONNECTED == pMasl->status)/* MASL */ + { + if (SAI_STATE_CONNECTED == pSai->status)/*SAI*/ + { + if (DI_ALE_LEN == dataLen)/* Ϣ */ /* DIûMAC(8ֽ)̵SaPdu(ֻ3ֽ)Կ */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 67, "P5067:RSSP2:detect ALE DI msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DI, maslData); + } + else + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 68, "P5068:RSSP2:detect ALE DT msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DT, maslData); + } + + if (0 < maslLen)/* MASL㴦 */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 69, "P5069:RSSP2:detect MASL msg\n", + 0, 0, 0, 0, 0, 0, 0); + saiLen = ProcessSaPDU(maslData, maslLen, pRssp2LnkNode, saiData); + } + else + { + ret = 0; + } + + if (0 < saiLen) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 70, "P5070:RSSP2:detect SAI msg\n", + 0, 0, 0, 0, 0, 0, 0); + appLen = ProcessSaiPdu(saiData, saiLen, pRssp2LnkNode, *pRssp2Stru->CycleNum, appData); + + if (0 < appLen) + { + /* ЭͨýϢͷ + * ӦָʾյԺη(Դ) + * ӦݲֲRSSP2Э鱣ͨӦ + * ----------------------------------------------------------------- + * ݳ | DestType | DestID | LogId | Ӧ | + * 2ֽ | 1ֽ | 1ֽ | 2ֽ | n | + * ----------------------------------------------------------------- + */ + /* ֽڵij */ + ShortToChar(appLen + 4, tmpHeadBuf); + /*һֽڵ豸 */ + tmpHeadBuf[2] = (UINT8)((pRssp2LnkNode->DestDevName >> 8) & 0xFF); + /*һֽڵ豸ID */ + tmpHeadBuf[3] = (UINT8)(pRssp2LnkNode->DestDevName & 0xFF); + /*2ֽڵ߼ID*/ + ShortToChar(pRssp2LnkNode->DestLogId, &tmpHeadBuf[4]); + QueueWrite(6, tmpHeadBuf, &pRssp2Stru->DataToApp); + QueueWrite(appLen, appData, &pRssp2Stru->DataToApp); + pRssp2Stru->DataToAppSize += (appLen + 6); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 64, + "P5064:RSSP2:AppMsgRecv:len=%d,from=0x%04x\n", + 2, appLen, pRssp2LnkNode->DestDevName, 0, 0, 0, 0); + } + } + } + else if (SAI_STATE_DISCONNECTED == pSai->status)/* rsp recv ECStart and DI SaPDU */ + { + if (DI_ALE_LEN == dataLen)/* Ϣ */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 71, "P5071:RSSP2:detect ALE DI msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DI, maslData); + } + else + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 72, "P5072:RSSP2:detect ALE nonDI msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DT, maslData); + } + + if (0 < maslLen) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 73, "P5073:RSSP2:detect MASL msg\n", + 0, 0, 0, 0, 0, 0, 0); + saiLen = ProcessSaPDU(maslData, maslLen, pRssp2LnkNode, saiData); + + if (0 < saiLen) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 74, "P5074:RSSP2:detect SAI msg\n", + 0, 0, 0, 0, 0, 0, 0); + ret = ProcessEcStart(saiData, saiLen, pRssp2LnkNode, *pRssp2Stru->CycleNum); + } + + } + } + else if (SAI_STATE_CONNECTING == pSai->status) + { + if (DI_ALE_LEN == dataLen)/* Ϣ */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 75, "P5075:RSSP2:detect ALE DI msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DI, maslData); + } + else + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 76, "P5076:RSSP2:detect ALE nonDI msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DT, maslData); + } + + if (0 < maslLen)/* MASL㴦 */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 77, "P5077:RSSP2:detect MASL msg\n", + 0, 0, 0, 0, 0, 0, 0); + saiLen = ProcessSaPDU(maslData, maslLen, pRssp2LnkNode, saiData); + + if (0 < saiLen) + { + if (MASL_ROLE_INITIATOR == pRssp2LnkNode->NodeInfo.maslParam.role) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 78, "P5078:RSSP2:detect ECStart msg\n", + 0, 0, 0, 0, 0, 0, 0); + ret = ProcessEcStart(saiData, saiLen, pRssp2LnkNode, *pRssp2Stru->CycleNum); + } + else + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 79, "P5079:RSSP2:detect SAI msg\n", + 0, 0, 0, 0, 0, 0, 0); + appLen = ProcessSaiPdu(saiData, saiLen, pRssp2LnkNode, *pRssp2Stru->CycleNum, appData); + + if (0 < appLen) + { + /* ֽڵij */ + ShortToChar(appLen + 4, tmpHeadBuf); + /*һֽڵ豸 */ + tmpHeadBuf[2] = (UINT8)((pRssp2LnkNode->DestDevName >> 8) & 0xFF); + /*һֽڵ豸ID */ + tmpHeadBuf[3] = (UINT8)(pRssp2LnkNode->DestDevName & 0xFF); + /*2ֽڵ߼ID*/ + ShortToChar(pRssp2LnkNode->DestLogId, &tmpHeadBuf[4]); + QueueWrite(6, tmpHeadBuf, &pRssp2Stru->DataToApp); + QueueWrite(appLen, appData, &pRssp2Stru->DataToApp); + pRssp2Stru->DataToAppSize += (appLen + 6); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 65, + "P5065:RSSP2:First AppMsgRecv:len=%d,from=0x%04x\n", + 2, appLen, pRssp2LnkNode->DestDevName, 0, 0, 0, 0); + ret = 1; + } + } + } + } + } + else + { + /* ɴ֧ */ + } + } + else if (MASL_STATE_CONNECTING == pMasl->status) + { + if (DI_ALE_LEN == dataLen)/*recv DIPDU*/ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 80, "P5080:RSSP2:detect ALE DI msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DI, maslData); + } + else/*recv other PDU*/ + { + if (MASL_CONNECTION_WAITING_FOR_AU2 == pMasl->connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 81, "P5081:RSSP2:detect AU2 msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_CC, maslData); + for (i = 4; i < maslLen; i++) + { + maslData[i - 4] = maslData[i]; + } + maslLen = (maslLen > 4) ? maslLen - 4 : 0; + + } + else if (MASL_CONNECTION_WAITING_FOR_AU3 == pMasl->connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 82, "P5082:RSSP2:detect AU3 msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DT, maslData); + } + else if (MASL_CONNECTION_WAITING_FOR_AR == pMasl->connStatus) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 83, "P5083:RSSP2:detect AR msg\n", + 0, 0, 0, 0, 0, 0, 0); + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_DT, maslData); + } + else + { + /* MASLڲ״̬ȷ */ + } + } + + if (maslLen > 1) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 84, "P5084:RSSP2:detect MASL msg\n", + 0, 0, 0, 0, 0, 0, 0); + saiLen = ProcessSaPDU(maslData, maslLen, pRssp2LnkNode, saiData); + + } + } + else if (MASL_STATE_DISCONNECTED == pMasl->status) + { + pAle->recvTS = 0; + pAle->bIsZero = FALSE; + + maslLen = ParseAleData(pData, dataLen, pRssp2LnkNode, ALE_PACK_TYPE_CR, maslData); + for (i = 9; i < maslLen; i++) + { + maslData[i - 9] = maslData[i]; + } + maslLen = (maslLen > 9) ? (maslLen - 9) : 0; + + if (0 < maslLen) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 85, "P5085:RSSP2:detect MASL msg\n", + 0, 0, 0, 0, 0, 0, 0); + saiLen = ProcessSaPDU(maslData, maslLen, pRssp2LnkNode, saiData); + } + + /* ͨŷMASLѶϿյͨűĽһAU1? */ + /* + if(MASL_ROLE_INITIATOR == pMasl->role) + { + commonLogMsg(vRecArray,vRecArraySize,RSSP2_LOG_INFO,86,"P5086:RSSP2:send AU1 msg\n", + 0,0,0,0,0,0,0); + appLen = BuildAu1SaiPdu(pRssp2LnkNode,*pRssp2Stru->CycleNum,appData); + } + */ + } + else + { + /* MASL״̬ȷ */ + } + } + else + { + /* TCPδ */ + } + } + else + { + /* ڼʧ */ + } + return ret; +} + +/************************************************************************ +ܣRSSP2Э鷢ͽӿ +Ӧ÷ͶУûҪ͵ӦñķװRSSP2 + SAI㲻״̬ЭҪı +************************************************************************/ +UINT8 ProcessRssp2OutData(QueueStruct *AppToRs, RSSP2_INFO_STRU *pRssp2Stru) +{ + UINT8 ret = 0; + UINT8 rslt = 0; + UINT8 index = 0; + UINT8 LnkNodeNum = 0; /* ͨŽڵ */ + UINT16 MaxMsgLen = 0; /* һнڵݳ */ + UINT32 MsgLen = 0; /* Ϣ */ + UINT8 tmpData[MAX_RSSP2_DATA_LEN + 4] = { 0 }; /* ɱݻ */ + LPRSSP2_LNK_INFO_NODE_STRU LnkNodeArr = NULL; /* ͨŽڵ */ + LPRSSP2_LNK_INFO_NODE_STRU pNode = NULL; /* ͨŽڵָ */ + UINT16 destDevName = 0; + UINT16 destLogId = 0; + UINT32 destEtcsId = 0; + UINT8 role = 0; + + UINT8 activeNodeNum = 0; /*Ծڵ,ڱм*/ + UINT16 varOffSet = 0; /*мʱʹõƫ*/ + UINT32 gpAppOutPacketsLen = 0; /*ʱӦݰбָ볤*/ + UINT32 i = 0; /*ѭʹ*/ + + if ((NULL == AppToRs) || (NULL == pRssp2Stru) || (NULL == gpAppOutPackets)) + { + ret = 0; + } + else + { + /* Э鷢Ͷ */ + pRssp2Stru->AppArraySize = 0; + + /* ȡȫֵͨŽڵ */ + LnkNodeArr = pRssp2Stru->LnkNodeArr; + LnkNodeNum = pRssp2Stru->LnkNodeNum; + + /* ޷ۼ */ + for (index = 0; index < LnkNodeNum; index++) + { + /* ɸǽڵ */ + if (NODE_DISBALED_REPLACE == LnkNodeArr[index].NodeStatus) + { + /* ޷ۼ */ + LnkNodeArr[index].NoAppDataCycleNum++; + if (LnkNodeArr[index].NoAppDataCycleNum > LnkNodeArr[index].NodeInfo.saiParam.Parameter_ALARM) + { + LnkNodeArr[index].NodeStatus = NODE_REPLACE; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 132, "P5132:RSSP2:Release Node(no app send):locName=0x%04x,DesName=0x%04x\n", + 2, LnkNodeArr[index].LocalDevName, LnkNodeArr[index].DestDevName, 0, 0, 0, 0); + } + } + else + { + /* ʲô */ + } + } + + /* нڵݳ */ + MaxMsgLen = pRssp2Stru->OutputSize + 6; + +#ifdef RSSP2_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(vRecArray, vRecArraySize, RSSP2_LOG_SEND_START);/* Ϳʼ־ */ +#endif + ret = 1;/* ݷΪͳɹ */ + /* ȡӦ */ + while (QueueStatus(AppToRs) > 2) + { + QueueScan(2, tmpData, AppToRs); /* ϶ֽ */ + MsgLen = ShortFromChar(tmpData); /* ȡó */ + + /* нڵݳ С */ + if ((MsgLen <= MaxMsgLen) && (4 <= MsgLen)) + { + /* һڵӦ */ + ret = QueueRead((UINT32)(MsgLen + 2), tmpData, AppToRs); + if (1 == ret) + { + /*2ֽڳ*/ + index = 2; + /*2ֽ豸ID*/ + destDevName = ShortFromChar(&tmpData[index]); + index += 2; + /*2ֽ߼ID*/ + destLogId = ShortFromChar(&tmpData[index]); + index += 2; + + rslt = dquDevName2EtcsId(destDevName, destLogId, &destEtcsId); + if (1 == rslt) /*ѯ*/ + { + /*Ӧб*/ + for (i = 0; i < gpAppOutPacketsLen; i++) + { + /*ظĿĵַİ,õǰ°滻*/ + if (gpAppOutPackets[i].DstEtcsId == destEtcsId) + { + CommonMemSet(&gpAppOutPackets[i].Packet[0], gpAppOutPackets[i].DataLen, 0, gpAppOutPackets[i].DataLen); + CommonMemCpy(&gpAppOutPackets[i].Packet[0], MsgLen + 2, tmpData, MsgLen + 2); + gpAppOutPackets[i].DataLen = MsgLen + 2; + + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 252, "P5252:destEtcsId=0x%04x,dataLen=0x%04x\n", + 2, destEtcsId, MsgLen + 2, 0, 0, 0, 0); + + break; + } + } + /*ظ,ӵǰ*/ + if (i == gpAppOutPacketsLen) + { + /*о*/ + if (gpAppOutPackets[gpAppOutPacketsLen].DataLen > 0) + { + CommonMemSet(&gpAppOutPackets[gpAppOutPacketsLen].Packet[0], gpAppOutPackets[gpAppOutPacketsLen].DataLen, 0, gpAppOutPackets[gpAppOutPacketsLen].DataLen); + } + gpAppOutPackets[gpAppOutPacketsLen].DataLen = MsgLen + 2; + gpAppOutPackets[gpAppOutPacketsLen].DstEtcsId = destEtcsId; + CommonMemCpy(&gpAppOutPackets[gpAppOutPacketsLen].Packet[0], MsgLen + 2, tmpData, MsgLen + 2); + gpAppOutPacketsLen++; + } + } + } + else + { + /* ָȵĶжȡʧܣ˵ʣԪز㣬ֱѭ¼ */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 105, "P5105:RSSP2:read send queue fail:msgLen=%d\n", + 1, MsgLen, 0, 0, 0, 0, 0); + ret = 0; + break; + } + } + else /* MsgLen >= MaxMsgLen */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 106, "P5106:RSSP2:read send msg len error:msgLen=%d\n", + 1, MsgLen, 0, 0, 0, 0, 0); + ret = 0; + /* ¼,һ */ + QueueElementDiscard(MsgLen + 2, AppToRs); + /* ָȵĶжȡʧܣ˵ʣԪز㣬ֱѭ¼ */ + } + } + + /*Ӧݴ*/ + if ((1 == ret) && (gpAppOutPacketsLen > 0)) + { + /*Ӧб*/ + for (i = 0; i < gpAppOutPacketsLen; i++) + { + CommonMemSet(&tmpData[0], MAX_RSSP2_DATA_LEN + 4, 0, MAX_RSSP2_DATA_LEN + 4); + CommonMemCpy(&tmpData[0], gpAppOutPackets[i].DataLen, &gpAppOutPackets[i].Packet[0], gpAppOutPackets[i].DataLen); + destEtcsId = gpAppOutPackets[i].DstEtcsId; + MsgLen = gpAppOutPackets[i].DataLen - 2; + + pNode = SearchRssp2LnkNode(pRssp2Stru->LocalEtcsId, destEtcsId, pRssp2Stru); + if (NULL == pNode) + {/* ûҵжϱǷΪ𷽣Ϊ𷽣ݣΪ𷽣AU1 */ + + /* ѯĽɫǷ𷽣Ϣ */ + rslt = dquRssp2GetRole(pRssp2Stru->LocalEtcsId, destEtcsId, &role); + + /* Ϊ𷽣ʼ */ + + if ((1 == rslt) && (MASL_ROLE_INITIATOR == role)) + { + pNode = GetRssp2ReplaceNode(pRssp2Stru); + ret = InitRssp2LnkInfoNode(pRssp2Stru->LocalEtcsId, destEtcsId, role, pNode); + if (1 == ret) + { + pNode->LinkStatus = RSSP2_SEND_AU1; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 95, "P5095:RSSP2:Init LnkNode:locName=0x%04x,DesName=0x%04x\n", + 2, pNode->LocalDevName, pNode->DestDevName, 0, 0, 0, 0); + } + else + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_ERROR, 126, "P5126:RSSP2:Init LnkNode:locName=0x%04x,DesName=0x%04x fail!!!\n", + 2, pNode->LocalDevName, destEtcsId, 0, 0, 0, 0); + } + } + else + { + ret = 0; + } + } + + /* ֻҪнڵ㷢ʧ,Ϊʧ */ + if (NULL != pNode) + { + if ((DEVTYPE_ATS == (pNode->DestDevName / 256)) && (DEVTYPE_VOBC == (pNode->LocalDevName / 256) || DEVTYPE_AOM == (pNode->LocalDevName / 256)))/* VOBCATSϢʱ */ + { + if (*(pRssp2Stru->CycleNum) % 7 == 0) + { + ret &= Rssp2NodeSend(pRssp2Stru, pNode, MsgLen - 4, tmpData + 6); + } + } + else + { + ret &= Rssp2NodeSend(pRssp2Stru, pNode, MsgLen - 4, tmpData + 6); + } + } + else + { + ret = 0; + } + + } + } + + ret &= Rssp2CycSend(pRssp2Stru); + + /* м add 20160328 xb */ + /* + мݽṹ + ܳ(2byte)(ӻԾͨŽڵֶοʼ) | ԾͨŽڵ(1byte) | ͨŽڵݽṹ1(sizeof(RSSP2_LNK_INFO_NODE_STRU)) | ͨŽڵݽṹ2 | ... + */ + varOffSet = 3;/* ƫƵ2ֽڳȺ1ֽڽڵ */ + activeNodeNum = 0; + for (index = 0; index < LnkNodeNum; index++) + { + /* ɸǽڵ */ + if (NODE_DISBALED_REPLACE == LnkNodeArr[index].NodeStatus) + { +#ifdef RSSP2_SIMP_REFRESH + if (SAI_STATE_CONNECTED == LnkNodeArr[index].NodeInfo.saiParam.status) + { + Rssp2NodeSave(&LnkNodeArr[index], (RSSP2_LNK_STATUS_INFO_STRU*)(pRssp2Stru->VarArray + varOffSet)); + varOffSet += sizeof(RSSP2_LNK_STATUS_INFO_STRU); + activeNodeNum++; + } +#else + CommonMemCpy(pRssp2Stru->VarArray + varOffSet, sizeof(RSSP2_LNK_INFO_NODE_STRU), &LnkNodeArr[index], sizeof(RSSP2_LNK_INFO_NODE_STRU)); + varOffSet += sizeof(RSSP2_LNK_INFO_NODE_STRU); + activeNodeNum++; +#endif + } + else + { + /* ʲô */ + } + } + /* мֽ */ +#ifdef RSSP2_SIMP_REFRESH + ShortToChar((UINT16)(1 + activeNodeNum * sizeof(RSSP2_LNK_STATUS_INFO_STRU)), pRssp2Stru->VarArray); +#else + ShortToChar((UINT16)(1 + activeNodeNum * sizeof(RSSP2_LNK_INFO_NODE_STRU)), pRssp2Stru->VarArray); +#endif + /* мڵ */ + pRssp2Stru->VarArray[2] = activeNodeNum; + } + + return ret; + } + +/************************************************************************ +ܣRSSP2ĩ⴦ +SAIδӵЭ齫·״̬ЭҪıģ + Ͽọ̈̄ +************************************************************************/ +UINT8 Rssp2CycSend(RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 i = 0; + UINT8 rt = 1; + for (i = 0; i < pRssp2Struct->LnkNodeNum; i++) + { + if ((pRssp2Struct->LnkNodeArr[i].NodeStatus != NODE_REPLACE) + && (pRssp2Struct->LnkNodeArr[i].LinkStatus != RSSP2_SEND_NONE) + && (pRssp2Struct->LnkNodeArr[i].LinkStatus != RSSP2_SEND_DT)) + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_NOTICE, 125, "P5125:RSSP2:Cyc End Send to:0x%04x(%d)\n", 1, pRssp2Struct->LnkNodeArr[i].DestDevName, pRssp2Struct->LnkNodeArr[i].LinkStatus, 0, 0, 0, 0); + if ((DEVTYPE_ATS == (pRssp2Struct->LnkNodeArr[i].DestDevName / 256)) && (DEVTYPE_VOBC == (pRssp2Struct->LnkNodeArr[i].LocalDevName / 256) || DEVTYPE_AOM == (pRssp2Struct->LnkNodeArr[i].LocalDevName / 256)))/* VOBCATSϢʱ */ + { + if (*(pRssp2Struct->CycleNum) % 7 == 0) + { + rt &= Rssp2NodeSend(pRssp2Struct, &pRssp2Struct->LnkNodeArr[i], 0, NULL); + } + } + else + { + rt &= Rssp2NodeSend(pRssp2Struct, &pRssp2Struct->LnkNodeArr[i], 0, NULL);/* ֻҪнڵ㷢ʧܾΪʧ */ + } + } + } + return rt; +} + +/************************************************************************ +: RSSP2ͨŽڵ㷢 + +: + UINT16 AppDataLen, UINT8 *AppData ͵Ӧ + RSSP2_LNK_INFO_NODE_STRU *pNode RSSP2ͨŽڵ + RSSP2_INFO_STRU *pRssp2Stru RSSP2ͳһݽṹ + + pRssp2Stru->AppArray Эͨ÷Ϣ֡(Эͨ÷Ϣͷ+RSSP2Э) +ֵUINT8 1ɹ 0ʧ +************************************************************************/ +UINT8 Rssp2NodeSend(RSSP2_INFO_STRU *pRssp2Stru, RSSP2_LNK_INFO_NODE_STRU *pNode, UINT16 AppDataLen, UINT8 *AppData) +{ + UINT8 ret = 0; + UINT8 aleData[MAX_RSSP2_DATA_LEN] = { 0 }; + UINT16 aleDataLen = 0; + UINT8 tempDataBuff[2]; + UINT8 destType; + UINT8 destId; + UINT8 role; + UINT8 rslt; + + if ((NULL != pRssp2Stru) && (NULL != pNode)) + { +#ifdef RSSP2_RECORD_SIMPLIFY_BIN + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_CYC, RSSP2_LOG_NODE_SEND_START, + "P5253:NodeSendStart:Remote=0x%04x,SAI_STATE=%d,MASL_STATE=%d,COM_STATE=%d,TCP_STATE=%d,LnkStat=%d\n", 6, + pNode->DestDevName, pNode->NodeInfo.saiParam.status, + pNode->NodeInfo.maslParam.status, + pNode->NodeInfo.maslParam.connStatus, + pNode->NodeInfo.tcpParam.TCPState, + pNode->LinkStatus); +#endif +#ifdef RSSP2_RECORD_ERR_ASCII + PrintRecArrayByte(vRecArray, vRecArraySize, RSSP2_LOG_NODE_SEND_START);/* Ϳʼ־ */ + RSSP2LogBinNodeInfo(pRssp2Stru->RecordArray, pRssp2Stru->RecordArraySize, pNode); +#endif + destType = (pNode->DestDevName >> 8) & 0xff; + destId = pNode->DestDevName & 0xff; + pNode->NoAppDataCycleNum = 0; + + pNode->NodeInfo.tcpParam.TCPCtrl = TCP_CTRL_CONNECT; + if (TCP_STATE_CONNECTED == pNode->NodeInfo.tcpParam.TCPState) + { + + Rssp2MemSet(aleData, sizeof(aleData), 0); + if ((RSSP2_SEND_NONE != pNode->LinkStatus) && (RSSP2_SEND_DT != pNode->LinkStatus)) + { + if (RSSP2_SEND_AU1 == pNode->LinkStatus)/* AU1 */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 96, "P5096:RSSP2:send AU1 msg\n", + 0, 0, 0, 0, 0, 0, 0); + aleDataLen = BuildAu1SaiPdu(pNode, (*pRssp2Stru->CycleNum), *pRssp2Stru->RandomNum, aleData); + pNode->LinkStatus = RSSP2_SEND_NONE; + } + else if (RSSP2_SEND_AU2 == pNode->LinkStatus)/* AU2 */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 97, "P5097:RSSP2:send AU2 msg\n", + 0, 0, 0, 0, 0, 0, 0); + aleDataLen = BuildAu2SaiPdu(pNode, (*pRssp2Stru->CycleNum), (*pRssp2Stru->RandomNum), aleData); + pNode->LinkStatus = RSSP2_SEND_NONE; + } + else if (RSSP2_SEND_AU3 == pNode->LinkStatus)/* AU3 */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 98, "P5098:RSSP2:send AU3 msg\n", + 0, 0, 0, 0, 0, 0, 0); + aleDataLen = BuildAu3SaiPdu(pNode, aleData); + pNode->LinkStatus = RSSP2_SEND_NONE; + } + else if (RSSP2_SEND_AR == pNode->LinkStatus)/* AR */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 99, "P5099:RSSP2:send AR msg\n", + 0, 0, 0, 0, 0, 0, 0); + aleDataLen = BuildArSaiPdu(pNode, aleData); + pNode->LinkStatus = RSSP2_SEND_NONE; + } + else if (RSSP2_SEND_ECSTART == pNode->LinkStatus)/* ECSTART */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 100, "P5100:RSSP2:send EC Start msg\n", + 0, 0, 0, 0, 0, 0, 0); + aleDataLen = SendEcStart(pNode, (*pRssp2Stru->CycleNum), aleData); + pNode->LinkStatus = RSSP2_SEND_NONE; + + } + else if (RSSP2_SEND_DI == pNode->LinkStatus)/* DI */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 101, "P5101:RSSP2:send ALE DI msg, Release Node\n", + 0, 0, 0, 0, 0, 0, 0); + aleDataLen = BuildDiSaiPduData(pNode, aleData); + pNode->LinkStatus = RSSP2_SEND_NONE; + pNode->NodeStatus = NODE_REPLACE; + } + else + { + /* ɴ֧ */ + } + } + else + { + if (SAI_STATE_CONNECTED == pNode->NodeInfo.saiParam.status)/* ʱӦ */ + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 102, "P5102:RSSP2:send app msg\n", + 0, 0, 0, 0, 0, 0, 0); + aleDataLen = BuildRSSP2Data(AppData, AppDataLen, pNode, (*pRssp2Stru->CycleNum), aleData); + } + else + { + /*SAI·δ,*/ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_CYC, 103, "P5103:RSSP2:app send abort(SAI not ready)\n", + 0, 0, 0, 0, 0, 0, 0); + } + } + + if (0 < aleDataLen) + { + /* Эͨ÷Ϣͷ + * Ӧָʾⷢʱʹõŵ͡ĿĵصϢ + * ӦݲֲͨʵⲿŵϴRSSP2Эͨ + * ----------------------------------------------------------------- + * ݳ | ProType | DestType | DestID | ߼ID | Ӧ | + * 2ֽ | 1ֽ | 1ֽ | 1ֽ | 2ֽ | n | + * ----------------------------------------------------------------- + */ + ShortToChar(aleDataLen + 5, tempDataBuff); + Rssp2MemCopy(tempDataBuff, pRssp2Stru->AppArray + pRssp2Stru->AppArraySize, 2); + pRssp2Stru->AppArraySize += 2; + /*Э*/ + *(pRssp2Stru->AppArray + pRssp2Stru->AppArraySize) = 9; + pRssp2Stru->AppArraySize += 1; + /*Ŀ豸ID*/ + ShortToChar(pNode->DestDevName, tempDataBuff); + Rssp2MemCopy(tempDataBuff, pRssp2Stru->AppArray + pRssp2Stru->AppArraySize, 2); + pRssp2Stru->AppArraySize += 2; + /*Ŀ߼ID*/ + ShortToChar(pNode->DestLogId, tempDataBuff); + Rssp2MemCopy(tempDataBuff, pRssp2Stru->AppArray + pRssp2Stru->AppArraySize, 2); + pRssp2Stru->AppArraySize += 2; + Rssp2MemCopy(aleData, pRssp2Stru->AppArray + pRssp2Stru->AppArraySize, aleDataLen); + pRssp2Stru->AppArraySize += aleDataLen; + ret = 1; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 104, "P5104:RSSP2:send app msg success:(%d,%d) to (%d,%d):len=%d\n", 5, + pRssp2Stru->LocalType, pRssp2Stru->LocalID, destType, destId, pRssp2Stru->AppArraySize, 0); + } + } + else + { + /* TCP·δ */ + if(RSSP2_SEND_AU1 != pNode->LinkStatus) + { + pNode->LinkStatus = RSSP2_SEND_NONE; + } + rslt = dquRssp2GetRole(pNode->LocalEtcsId, pNode->DestEtcsId, &role); + /* edit 20170724 xb Ϊ𷽼⵽TCPϿ׼طAU1 */ + if(1 == rslt) + { + if ((MASL_ROLE_INITIATOR == role) && (MASL_STATE_CONNECTED != pNode->NodeInfo.maslParam.status)) + { + InitRssp2LnkInfoNode(pNode->LocalEtcsId, pNode->DestEtcsId, role, pNode); + pNode->NodeInfo.tcpParam.TCPCtrl = TCP_CTRL_CONNECT; + pNode->LinkStatus = RSSP2_SEND_AU1; + } + } + + ret = 1; + } + } + else /* ʧ */ + { + ret = 0; + } + return ret; +} + +/*-------------------------------------------------------------------- + * RSSPӿں Start + *--------------------------------------------------------------------*/ + /*********************************************************************** + * : Rssp2Receive + * : ԺݽRSSP2İȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ + * УpRssp2Struct->OutnetQueueA + * pRssp2Struct->OutnetQueueB + * УpRssp2Struct->DataToApp + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIReceive(RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; + + if ((NULL != pRssp2Struct) && (1 == g_IsInited))/* ڲ */ + { + pRssp2Struct->DataToAppSize = 0; + QueueClear(&pRssp2Struct->DataToApp); + + /* ¼ */ +#if (RSSP2_LOG_LEVEL>=0) + ShortToChar(0, pRssp2Struct->RecordArray); + vRecArray = pRssp2Struct->RecordArray; + vRecArraySize = pRssp2Struct->RecordArraySize; +#endif + /* RSSP봦 */ + Rssp2ReceiveDataProc(&pRssp2Struct->OutnetQueueA, &pRssp2Struct->OutnetQueueB, pRssp2Struct); + ret = 1; /* 20160518ҪЭʧֻDzӦݣպءʧܡ */ + } + else + { + ret = 0; + } + return ret; +} + +/*********************************************************************** + * : RsspIIOutput + * : ӦݽRSSPİȫ + * : + * + * -------------------------------------------------------------- + * pRssp2Struct RSSP_INFO_STRU* INOUT RSSP2ͳһṹ + * УpRssp2Struct->OutputDataQueue + * УpRssp2Struct->AppArray + * pRssp2Struct->VarArray + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIOutput(RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; + + if ((NULL != pRssp2Struct) && (1 == g_IsInited)) + { + /* RSSP2 */ + ProcessRssp2OutData(&pRssp2Struct->OutputDataQueue, pRssp2Struct); + ret = 1;/* 20160518Ҫ,RSSP2͹̶سɹ */ + } + else + { + /* ʲô */ + ret = 0; + } + + return ret; +} + +/*********************************************************************** + * : RsspIIInit + * : ͨúʵֶRSSP2ijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIInit(UINT8* fileName, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; + UINT32 tmp = 0; + UINT32 MaxMsgNum = 0; + UINT16 InputSize = 0, OutputSize = 0; + UINT32 i = 0; +#ifdef RSSP2_PREDEF_SESSIONKEY + DSU_RSSP2_WS_TYPE_CFG_STRU protclStack = { 0 }; + MASL_PARAM maslPara = { 0 }; +#endif + /* ǷѾʼ */ + if (1 == g_IsInited) + { + ret = 0; + } + else + { + ret = 1; + } + + /* */ + if (1 == ret) + { + ret = CheckRssp2Struct(pRssp2Struct); + } + + if (1 == ret) + { + InputSize = pRssp2Struct->InputSize; + OutputSize = pRssp2Struct->OutputSize; + if (200 < pRssp2Struct->MaxNumLink) + { + pRssp2Struct->MaxNumLink = 200; + } + /* DSUѯгʼ */ + ret = dsuRssp2Init(fileName); + } + + if (1 == ret) + { + /* RSSP2ʼ */ + /* + * ȫͨŽڵʼ : ʼԭ豸ƸΪֻҪʼ· + */ + ret = InitRssp2LnkNodeArr(pRssp2Struct->MaxNumLink, pRssp2Struct); + +#ifdef RSSP2_PREDEF_SESSIONKEY + Rssp2MemCopy(&dsuRssp2InfoStru.pDsuRssp2LocTypeCfgStru->Key[0], maslPara.km1, 8); + Rssp2MemCopy(&dsuRssp2InfoStru.pDsuRssp2LocTypeCfgStru->Key[8], maslPara.km2, 8); + Rssp2MemCopy(&dsuRssp2InfoStru.pDsuRssp2LocTypeCfgStru->Key[16], maslPara.km3, 8); + Rssp2MemCopy(g_btRa, maslPara.Ra, 8); + Rssp2MemCopy(g_btRb, maslPara.Rb, 8); + BuildSessionKeys(&maslPara); + Rssp2MemCopy(maslPara.ks1, g_ucKMACKey1, 8); + Rssp2MemCopy(maslPara.ks2, g_ucKMACKey2, 8); + Rssp2MemCopy(maslPara.ks3, g_ucKMACKey3, 8); +#endif + } + + if (1 == ret) + { + /* ʼ */ + MaxMsgNum = pRssp2Struct->MaxNumLink *(pRssp2Struct->MaxNumPerCycle + 2); /* */ + + /* ЭӦõݶг */ + pRssp2Struct->DataToAppSize = (InputSize + 6) * MaxMsgNum; /* ЭӦõݶг */ + ret = QueueInitial(&pRssp2Struct->DataToApp, pRssp2Struct->DataToAppSize); + } + + if (1 == ret) + { + /* ӦøЭݶг */ + pRssp2Struct->OutputDataQueueSize = (OutputSize + 8)*MaxMsgNum; + ret = QueueInitial(&pRssp2Struct->OutputDataQueue, pRssp2Struct->OutputDataQueueSize); + + /*ΪʱӦݰбָռ*/ + gpAppOutPackets = (AppOutPackets *)malloc(sizeof(AppOutPackets)*MaxMsgNum); + if (NULL== gpAppOutPackets) + { + ret = 0; + } + else + { + CommonMemSet(gpAppOutPackets, sizeof(AppOutPackets)*MaxMsgNum, 0, sizeof(AppOutPackets)*MaxMsgNum); + } + /*Ϊÿռ*/ + for (i = 0; i < MaxMsgNum; i++) + { + gpAppOutPackets[i].DataLen = 0; + gpAppOutPackets[i].DstEtcsId = 0; + + gpAppOutPackets[i].Packet = (UINT8 *)malloc(sizeof(UINT8)*(OutputSize + 8)); + if (NULL == gpAppOutPackets[i].Packet) + { + ret = 0; + } + else + { + CommonMemSet(gpAppOutPackets[i].Packet, sizeof(UINT8)*(OutputSize + 8), 0, sizeof(UINT8)*(OutputSize + 8)); + } + /*ռʧ˳ѭ*/ + if (0 == ret) + { + break; + } + } + } + + if (1 == ret) + { + /* ܶг */ + pRssp2Struct->OutnetQueueSize = (InputSize + 8)*MaxMsgNum; + /* */ + ret = QueueInitial(&pRssp2Struct->OutnetQueueA, pRssp2Struct->OutnetQueueSize); + } + + if (1 == ret) + { + /* */ + ret = QueueInitial(&pRssp2Struct->OutnetQueueB, pRssp2Struct->OutnetQueueSize); + } + + if (1 == ret) + { + /*ΪAppArrayռ*/ + pRssp2Struct->AppArraySize = (UINT32)OutputSize*(pRssp2Struct->MaxNumPerCycle)*(pRssp2Struct->MaxNumLink) + 2; + pRssp2Struct->AppArray = (UINT8 *)malloc(pRssp2Struct->AppArraySize); + if (pRssp2Struct->AppArray == NULL) + { + ret = 0; + } + else + { + CommonMemSet(pRssp2Struct->AppArray, sizeof(UINT8)*pRssp2Struct->AppArraySize, 0, sizeof(UINT8)*pRssp2Struct->AppArraySize); + } + } + + if (1 == ret) + { + /* ΪмVarArrayռ */ +#ifdef RSSP2_SIMP_REFRESH + pRssp2Struct->VarArraySize = 3 + pRssp2Struct->MaxNumLink * sizeof(RSSP2_NODE_PARAMINFO_STRU); +#else + pRssp2Struct->VarArraySize = 3 + pRssp2Struct->MaxNumLink * sizeof(RSSP2_LNK_INFO_NODE_STRU); +#endif + pRssp2Struct->VarArray = (UINT8 *)malloc(pRssp2Struct->VarArraySize); + if (pRssp2Struct->VarArray == NULL) + { + ret = 0; + } + else + { + CommonMemSet(pRssp2Struct->VarArray, sizeof(UINT8)*(pRssp2Struct->VarArraySize), 0, sizeof(UINT8)*(pRssp2Struct->VarArraySize)); + } + } + + /* Ϊ־¼RecordArrayռ */ +#if (RSSP2_LOG_LEVEL>=0) + if (1 == ret) + { + pRssp2Struct->RecordArray = (UINT8 *)malloc(pRssp2Struct->RecordArraySize); + if (pRssp2Struct->RecordArray == NULL) + { + ret = 0; + } + else + { + CommonMemSet(pRssp2Struct->RecordArray, sizeof(UINT8)*(pRssp2Struct->RecordArraySize), 0, sizeof(UINT8)*(pRssp2Struct->RecordArraySize)); + } + } +#endif + + if (1u == ret) + { + pRssp2Struct->NetsRecvPkgNums = (RsppiiNetsRecvPkgNum*)malloc(sizeof(RsppiiNetsRecvPkgNum) * pRssp2Struct->MaxNumLink); + if (NULL != pRssp2Struct->NetsRecvPkgNums) + { + CommonMemSet(pRssp2Struct->NetsRecvPkgNums, sizeof(RsppiiNetsRecvPkgNum) * pRssp2Struct->MaxNumLink, 0u, sizeof(RsppiiNetsRecvPkgNum) * pRssp2Struct->MaxNumLink); + } + else + { + ret = 0u; + } + } + + /* 㱾ػͨ */ + /* add 20160819 xb CR9590:ӶԿе֧ */ + if (1 == ret) + { + ret = dquDevName2EtcsId(pRssp2Struct->LocalType * 256 + pRssp2Struct->LocalID, 0, &pRssp2Struct->LocalEtcsId);/* ڱ˾Ʒֻ2IPĬϳʼ߼IDΪ0 */ + } + + /* ȫֳʼ־ */ + if (1 == ret) + { + g_IsInited = 1; + } + return ret; +} + +/*********************************************************************** + * : RsspIIFreeSpace + * : ͨúͷRSSP2㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIFreeSpace(RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; /*ֵ*/ + UINT32 maxMsgNum = 0; /*Ϣ*/ + UINT32 i = 0; /*ѭ*/ + + ret = dsuRsspIIFreeSpace(); + + if (pRssp2Struct == NULL) + { + ret = 0; + } + else + { + /* RSSP2ռͷ */ + DestoryRssp2LnkNodeArr(pRssp2Struct); + + /* ռͷ */ + + /* ЭӦõݶг */ + ret &= QueueElementFree(&pRssp2Struct->DataToApp); + + /* ӦøЭݶг */ + ret &= QueueElementFree(&pRssp2Struct->OutputDataQueue); + + /*ͷʱӦݰбָռ*/ + if (NULL != gpAppOutPackets) + { + /**/ + maxMsgNum = pRssp2Struct->MaxNumLink *(pRssp2Struct->MaxNumPerCycle + 2); + for (i = 0; i < maxMsgNum; i++) + { + free(gpAppOutPackets[i].Packet); + gpAppOutPackets[i].Packet = NULL; + } + free(gpAppOutPackets); + gpAppOutPackets = NULL; + } + + /* ܶг */ + /* */ + ret &= QueueElementFree(&pRssp2Struct->OutnetQueueA); + + /* */ + ret &= QueueElementFree(&pRssp2Struct->OutnetQueueB); + + free(pRssp2Struct->AppArray); + pRssp2Struct->AppArray = NULL; + free(pRssp2Struct->VarArray); + pRssp2Struct->VarArray = NULL; +#if (RSSP2_LOG_LEVEL >= 0) + free(pRssp2Struct->RecordArray); + pRssp2Struct->RecordArray = NULL; +#endif + } + return ret; +} +/*********************************************************************** + * : RsspIILnkStatus + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * destType UINT8 IN Ŀ + * destId UINT8 IN ĿID + * logicId UINT16 IN VOBC豸ʱʹö˱ţ豸ʱЧ + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ壬гʼֵá + * ֵ : UINT8 0ڸ·ش + * 0x17·ݴ״̬DATA + * 0x33, Ϊڽ + * 0x4e, Ϊܷڵȴ + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 RsspIILnkStatus(UINT8 destType, UINT8 destId, UINT16 logicId, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; + + if (pRssp2Struct == NULL) + { + ret = 0; + } + else + { + /* RSSP2· */ + ret = GetRsspIILnkStatus(destType, destId, logicId, pRssp2Struct); + } + return ret; +} + +/*********************************************************************** + * : RsspIILnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * destType UINT8 IN Ŀ + * destId UINT8 IN ĿID + * logicId UINT16 IN VOBC豸ʱʹö˱ţ豸ʱЧ + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIILnkDelete(UINT8 destType, UINT8 destId, UINT16 logicId, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 1; + UINT16 destDevName = 0; + UINT32 destEtcsId = 0; + RSSP2_LNK_INFO_NODE_STRU *pNode = NULL; + + if ((pRssp2Struct == NULL) || (1 != g_IsInited)) + { + ret = 0; + } + else + { + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_NOTICE, 66, "P5066:RSSP2:Release Link:0x%02x%02x(%d)\n", 3, destType, destId, logicId, 0, 0, 0); + + Rssp2TypeId2DevName(destType, destId, &destDevName); + + ret = dquDevName2EtcsId(destDevName, logicId, &destEtcsId); + + if (1 == ret) + { + pNode = SearchRssp2LnkNode(pRssp2Struct->LocalEtcsId, destEtcsId, pRssp2Struct); + } + else + { + pNode = NULL; + } + + if (pNode != NULL) + { + pNode->LinkStatus = RSSP2_SEND_DI; + } + ret = 1; + } + return ret; +} + +/************************************************************************ +ܣRSSP2ڵϢ +RSSP2ڵϢ浽·״̬Ϣ +룺 +IN RSSP2_LNK_INFO_NODE_STRU *pRssp2Node RSSP2ڵ + +OUT const RSSP2_LNK_STATUS_INFO_STRU *pStatusNode ·״̬Ϣ +ֵUINT8 1 0󷵻 +************************************************************************/ +UINT8 Rssp2NodeSave(IN const RSSP2_LNK_INFO_NODE_STRU *pRssp2Node, OUT RSSP2_LNK_STATUS_INFO_STRU*pStatusNode) +{ + UINT8 ret = 0; + if ((NULL != pRssp2Node) && (NULL != pStatusNode)) + { + ret = 1; + } + else + { + ret = 0; + } + + if (1 == ret) + { + pStatusNode->DestEtcsId = pRssp2Node->DestEtcsId; + pStatusNode->SAI_recvSN = pRssp2Node->NodeInfo.saiParam.recvSN; + pStatusNode->SAI_sendSN = pRssp2Node->NodeInfo.saiParam.sendSN; + pStatusNode->SAI_recvEC = pRssp2Node->NodeInfo.saiParam.recvEC; + pStatusNode->SAI_sendEC = pRssp2Node->NodeInfo.saiParam.sendEC; + pStatusNode->ALE_recvTS = pRssp2Node->NodeInfo.aleParam.recvTS; + pStatusNode->ALE_sendTS = pRssp2Node->NodeInfo.aleParam.sendTS; +#ifndef RSSP2_PREDEF_R + /* ʹûļRʱҪͬ */ + pStatusNode->SAI_rmtECPeriod = pRssp2Node->NodeInfo.saiParam.remoteECPeriod; +#endif +#ifndef RSSP2_PREDEF_SESSIONKEY + CommonMemCpy(pStatusNode->btKMACKey1, 8, pRssp2Node->NodeInfo.maslParam.ks1, 8); + CommonMemCpy(pStatusNode->btKMACKey2, 8, pRssp2Node->NodeInfo.maslParam.ks2, 8); + CommonMemCpy(pStatusNode->btKMACKey3, 8, pRssp2Node->NodeInfo.maslParam.ks3, 8); +#endif + } + return ret; +} + +/************************************************************************ +ܣRSSP2ڵˢ +·״̬ݽṹˢRSSP2ڵ +룺 +IN UINT32 LocalEtcsId +IN const RSSP2_LNK_STATUS_INFO_STRU *pStatusNode + +OUT RSSP2_LNK_INFO_NODE_STRU *pRssp2Node +ֵUINT8 1 0󷵻 +************************************************************************/ +UINT8 Rssp2NodeRefresh(IN UINT32 LocalEtcsId, IN const RSSP2_LNK_STATUS_INFO_STRU *pStatusNode, OUT RSSP2_LNK_INFO_NODE_STRU *pRssp2LnkInfoNode) +{ + UINT8 ret = 0; + MASL_ROLE role = MASL_ROLE_INITIATOR; + if ((NULL != pStatusNode) && (NULL != pRssp2LnkInfoNode)) + { + ret = 1; + } + else + { + ret = 0; + } + + if (1 == ret) + { + /* ȡͨŽɫ */ + ret = dquRssp2GetRole(LocalEtcsId, pStatusNode->DestEtcsId, (UINT8*)&role); + } + + if (1 == ret) + { + /* ļȡϢ */ + ret = InitRssp2LnkInfoNode(LocalEtcsId, pStatusNode->DestEtcsId, role, pRssp2LnkInfoNode); + } + + if (1 == ret) + { + /* ˢ½ڵ״̬Ϣ */ + pRssp2LnkInfoNode->LinkStatus = RSSP2_SEND_DT; + pRssp2LnkInfoNode->NoAppDataCycleNum = 0; + pRssp2LnkInfoNode->NoRecvDataCycleNum = 0; + + /* TCP */ + pRssp2LnkInfoNode->NodeInfo.tcpParam.TCPCtrl = TCP_CTRL_CONNECT; + pRssp2LnkInfoNode->NodeInfo.tcpParam.TCPState = TCP_STATE_CONNECTED; + + /* ALE */ + pRssp2LnkInfoNode->NodeInfo.aleParam.bIsZero = 0; + pRssp2LnkInfoNode->NodeInfo.aleParam.recvTS = pStatusNode->ALE_recvTS; + pRssp2LnkInfoNode->NodeInfo.aleParam.sendTS = pStatusNode->ALE_sendTS; + pRssp2LnkInfoNode->NodeInfo.aleParam.state = ALE_STATE_CONNECTED; + + /* MASL */ +#ifdef RSSP2_PREDEF_SESSIONKEY + CommonMemCpy(pRssp2LnkInfoNode->NodeInfo.maslParam.ks1, 8, g_ucKMACKey1, 8); + CommonMemCpy(pRssp2LnkInfoNode->NodeInfo.maslParam.ks2, 8, g_ucKMACKey2, 8); + CommonMemCpy(pRssp2LnkInfoNode->NodeInfo.maslParam.ks3, 8, g_ucKMACKey3, 8); +#else + CommonMemCpy(pRssp2LnkInfoNode->NodeInfo.maslParam.ks1, 8, pStatusNode->btKMACKey1, 8); + CommonMemCpy(pRssp2LnkInfoNode->NodeInfo.maslParam.ks2, 8, pStatusNode->btKMACKey2, 8); + CommonMemCpy(pRssp2LnkInfoNode->NodeInfo.maslParam.ks3, 8, pStatusNode->btKMACKey3, 8); +#endif + pRssp2LnkInfoNode->NodeInfo.maslParam.status = MASL_STATE_CONNECTED; + + /* SAI */ + pRssp2LnkInfoNode->NodeInfo.saiParam.recvSN = pStatusNode->SAI_recvSN; + pRssp2LnkInfoNode->NodeInfo.saiParam.sendSN = pStatusNode->SAI_sendSN; + pRssp2LnkInfoNode->NodeInfo.saiParam.recvEC = pStatusNode->SAI_recvEC; + pRssp2LnkInfoNode->NodeInfo.saiParam.sendEC = pStatusNode->SAI_sendEC; + pRssp2LnkInfoNode->NodeInfo.saiParam.NextEx = pRssp2LnkInfoNode->NodeInfo.saiParam.recvEC; + pRssp2LnkInfoNode->NodeInfo.saiParam.EcState = 0; + pRssp2LnkInfoNode->NodeInfo.saiParam.statesReqACK = SAI_REQACK_NULL; + pRssp2LnkInfoNode->NodeInfo.saiParam.bAck = 0; + pRssp2LnkInfoNode->NodeInfo.saiParam.status = SAI_STATE_CONNECTED; +#ifndef RSSP2_PREDEF_R + pRssp2LnkInfoNode->NodeInfo.saiParam.remoteECPeriod = pStatusNode->SAI_rmtECPeriod; + pRssp2LnkInfoNode->NodeInfo.saiParam.R = (double)((double)pRssp2LnkInfoNode->NodeInfo.saiParam.localECPeriod / (double)pRssp2LnkInfoNode->NodeInfo.saiParam.remoteECPeriod); +#endif + } + return ret; +} + +/*********************************************************************** + * : RsspIIRefresh + * : Ӧʹøú¶ԱRSSP2м¸ֵ + * : + * + * -------------------------------------------------------------- + * sLen_Input UINT16 IN мĴС + * Input_Data_LnkMes UINT8* IN м + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIRefresh(UINT16 VarLen, const UINT8 *VarArray, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; + UINT16 Rssp2VarLen = 0; /* Rsspм */ + UINT8 ActiveNodeNum = 0; + UINT8 index = 0; + UINT16 i = 0; + UINT8 rslt = 0; + RSSP2_LNK_STATUS_INFO_STRU lnkStatusInfo = { 0 }; + + if ((NULL == VarArray) || (NULL == pRssp2Struct) || (1 != g_IsInited)) + { + ret = 0; + } + else + { + for (index = 0; index < pRssp2Struct->LnkNodeNum; index++) + { + CommonMemSet(&pRssp2Struct->LnkNodeArr[index], sizeof(RSSP2_LNK_INFO_NODE_STRU), 0, sizeof(RSSP2_LNK_INFO_NODE_STRU)); + pRssp2Struct->LnkNodeArr[index].NodeStatus = NODE_REPLACE; /* ͨŽڵΪɸǽڵ */ + } + + ActiveNodeNum = VarArray[0]; +#ifdef RSSP2_SIMP_REFRESH + /* ·ˢģʽ */ + if (VarLen == 1 + ActiveNodeNum * sizeof(RSSP2_LNK_STATUS_INFO_STRU)) + { + i = 1; + for (index = 0; index < ActiveNodeNum; index++) + { + /* ˢ·״̬Ϣ */ + /* ȡһڵ·״̬Ϣ */ + CommonMemCpy(&lnkStatusInfo, sizeof(RSSP2_LNK_STATUS_INFO_STRU), VarArray + i, sizeof(RSSP2_LNK_STATUS_INFO_STRU)); + /* ˢһڵ */ + rslt = Rssp2NodeRefresh(pRssp2Struct->LocalEtcsId, &lnkStatusInfo, &pRssp2Struct->LnkNodeArr[index]); + i += sizeof(RSSP2_LNK_STATUS_INFO_STRU); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 131, "P5131:Node Refresh=%d(0x%04x,0x%04x)\n", + 3, rslt, pRssp2Struct->LocalID + 256 * pRssp2Struct->LocalType, lnkStatusInfo.DestEtcsId, 0, 0, 0); + } + } +#else + /* ȫ·ˢģʽ */ + if (VarLen == 1 + ActiveNodeNum * sizeof(RSSP2_LNK_INFO_NODE_STRU)) + { + CommonMemCpy(pRssp2Struct->LnkNodeArr, ActiveNodeNum * sizeof(RSSP2_LNK_INFO_NODE_STRU), VarArray + 1, ActiveNodeNum * sizeof(RSSP2_LNK_INFO_NODE_STRU));; + } +#endif + ret = 1; + } + return ret; +} + +/************************************************************************ +:ȡTCP״̬ +TCP״̬еTCP״̬ȡTCP״̬ +:StateCode TCP״̬ +: +ֵ:TCP_STATE TCP״̬ +************************************************************************/ +TCP_STATE GetRedTcpState(UINT8 StateCode) +{ + TCP_STATE state = TCP_STATE_IDLE; + StateCode = (StateCode >> 4) & 0x0f; + if ((0 <= StateCode) && (4 >= StateCode)) + { + state = StateCode; + } + return state; +} + +/************************************************************************ +:ȡTCP״̬ +TCP״̬еTCP״̬ȡTCP״̬ +:StateCode TCP״̬ +: +ֵ:TCP_STATE TCP״̬ +************************************************************************/ +TCP_STATE GetBlueTcpState(UINT8 StateCode) +{ + TCP_STATE state = TCP_STATE_IDLE; + StateCode = StateCode & 0x0f; + if ((0 <= StateCode) && (4 >= StateCode)) + { + state = StateCode; + } + return state; +} + +/************************************************************************ +:ȡϲTCP״̬ +:ݺTCP״̬ۺϼ·TCP״̬(ֻҪһͨͨ) +:StateCode TCP״̬ +: +ֵ:TCP_STATE TCP״̬ +************************************************************************/ +TCP_STATE GetMergeTcpState(UINT8 StateCode) +{ + TCP_STATE MergeState = TCP_STATE_DISCONNECTED; + UINT8 RedState = 0; + UINT8 BlueState = 0; + RedState = (StateCode >> 4) & 0x0f; + BlueState = StateCode & 0x0f; + if ((0 <= RedState) && (4 >= RedState) && (0 <= BlueState) && (4 >= BlueState)) + { + MergeState = Hash_MergeTcpState[RedState][BlueState]; + } + return MergeState; +} + +/************************************************************************ +ܣЭTCP·״̬ + + UINT16 bufLen, TCP·״̬ij + const UINT8 *buf TCP·״̬ + + RSSP2_INFO_STRU *pRssp2Stru еTCPڵϢRSSP2ڵеTCPϢ +˵ + TCP״̬ʱȽTCPڵRSSP2ڵTCP״̬ΪѶϿ, + ҲδյTCP״̬ʱĬTCP״̬ΪѶϿ + TCPڵзֱ𱣴TCP״̬ںϺTCP״̬,RSSP2ڵֻںϺ״̬ + յ·TCP״̬ʱµTCPڵ,ЭΪշʱRSSP2ڵ +************************************************************************/ +UINT8 RsspIIInputTcpState(UINT16 bufLen, const UINT8 *buf, RSSP2_INFO_STRU *pRssp2Stru) +{ + UINT8 rt = 1; + UINT8 rslt = 0; + UINT16 msgLen = 0; + UINT16 i = 0; + UINT8 devType = 0; + UINT8 devId = 0; + UINT32 localEtcsId = 0; + UINT32 destEtcsId = 0; + TCP_LNK_NODE_STRU *pTcpNode = NULL; + RSSP2_LNK_INFO_NODE_STRU *pRssp2LnkNode = NULL; + UINT8 role = 0; + + /* */ + if (NULL != buf) + { + rt = 1; + } + else + { + rt = 0; + } + if (1 == rt) + { + msgLen = ShortFromChar(buf); + if ((msgLen + 2 != bufLen) || (0 != msgLen % 5) || (0 == msgLen)) + { + rt = 0; + } + } + + if ((1 == rt) && (NULL != pRssp2Stru) && (1 == g_IsInited)) + { + /* TCP״̬ */ + for (i = 0; i < pRssp2Stru->LnkNodeNum; i++) + { + pRssp2Stru->TcpNodeArr[i].TcpState = TCP_STATE_DISCONNECTED; + pRssp2Stru->LnkNodeArr[i].NodeInfo.tcpParam.TCPState = TCP_STATE_DISCONNECTED; + } + + /* TCP·״̬ */ + localEtcsId = pRssp2Stru->LocalEtcsId; + for (i = 2; i < bufLen; i += 5) + { + destEtcsId = LongFromChar(&buf[i]); + + /* TCPڵ·״̬ */ + pTcpNode = SearchTcpNode(localEtcsId, destEtcsId, pRssp2Stru); + if (pTcpNode == NULL) + { + pTcpNode = GetTcpReplaceNode(pRssp2Stru); + if (pTcpNode != NULL) + { + InitTcpNode(localEtcsId, destEtcsId, pTcpNode); + } + else + { + rt = 0; + } + } + if (NULL != pTcpNode) + { + pTcpNode->RedState = GetRedTcpState(buf[i + 4]); + pTcpNode->BlueState = GetBlueTcpState(buf[i + 4]); + pTcpNode->TcpState = GetMergeTcpState(buf[i + 4]); + } + /* ɾʧЧTcpڵ */ + RemoveInactiveTcpNode(pRssp2Stru); + + /* RSSP2ڵ·״̬ */ + if (NULL != pTcpNode) + { + /* ѯĽɫǽշϢ */ + rslt = dquRssp2GetRole(localEtcsId, destEtcsId, &role); + if (1 == rslt) + { + pRssp2LnkNode = SearchRssp2LnkNode(localEtcsId, destEtcsId, pRssp2Stru); + } + else + { + pRssp2LnkNode = NULL; + } + if (NULL == pRssp2LnkNode) + { + if ((MASL_ROLE_RESPONDER == role) + && ((TCP_STATE_CONNECTING == pTcpNode->TcpState) || (TCP_STATE_CONNECTED == pTcpNode->TcpState))) + { + /* "շ"յ""""״̬ʱͨŽڵ */ + pRssp2LnkNode = GetRssp2ReplaceNode(pRssp2Stru); + rslt = InitRssp2LnkInfoNode(localEtcsId, destEtcsId, MASL_ROLE_RESPONDER, pRssp2LnkNode); + if (1 == rslt) + { + pRssp2LnkNode->NodeInfo.saiParam.status = SAI_STATE_DISCONNECTED; + pRssp2LnkNode->NodeInfo.maslParam.status = MASL_STATE_DISCONNECTED; + pRssp2LnkNode->NodeInfo.maslParam.connStatus = MASL_CONNECTION_NONE; + pRssp2LnkNode->NodeInfo.tcpParam.TCPState = pTcpNode->TcpState; + pRssp2LnkNode->NodeInfo.tcpParam.TCPCtrl = TCP_CTRL_CONNECT; + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 117, "P5117:TCP:Connect Accept from=0x%04x,state=0x%02x\n", 2, + destEtcsId, buf[i + 2], 0, 0, 0, 0); + } + else + { + /* ζŷTCPһ Ͽ */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 121, "P5121:TCP:Connect Refused from=0x%04x,state=0x%02x\n", 2, + destEtcsId, buf[i + 4], 0, 0, 0, 0); + } + } + else + { + /* յЧTCP״̬Ϣ, */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_WARN, 118, "P5118:TCP:State Ignored from=0x%04x,state=0x%02x\n", 2, + destEtcsId, buf[i + 4], 0, 0, 0, 0); + } + } + else /* NULL != pRssp2LnkNode */ + { + /* ҵӦͨŽڵ */ + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_CYC, 119, "P5119:TCP:State Report from=0x%04x,state=0x%02x\n", 2, + destEtcsId, buf[i + 4], 0, 0, 0, 0); + pRssp2LnkNode->NodeInfo.tcpParam.TCPState = pTcpNode->TcpState; + } + } + }/* endfor */ + } + return rt; +} + +/************************************************************************ +ܣȡ +ݵTCP״̬RSSP2TCPּڵĿ֣ + RSSP2ģֻTCP_CTRL_CONNECTTCP_CTRL_DISCONNECTֿ +룺 + TCP_CTRL TcpCtrl, RSSP2TCP + TCP_STATE TcpState TCP״̬ + +ֵTCP_CTRL TCP +*************************************************************************/ +TCP_CTRL GetOneTcpCtrl(TCP_CTRL TcpCtrl, TCP_STATE TcpState) +{ + TCP_CTRL CtrlCode = TCP_CTRL_IDLE; + switch (TcpCtrl) + { + case TCP_CTRL_CONNECT:/* Ϊ */ + if (TCP_STATE_CONNECTED == TcpState) + {/* ʱͱ */ + CtrlCode = TCP_CTRL_KEEPALIVE; + } + else + {/* ʱ */ + CtrlCode = TCP_CTRL_CONNECT; + } + break; + case TCP_CTRL_DISCONNECT:/* ΪϿ */ + if ((TCP_STATE_IDLE == TcpState) || (TCP_STATE_DISCONNECTED == TcpState)) + {/* ѶϿʱͿ */ + CtrlCode = TCP_CTRL_IDLE; + } + else + { + /* ѶϿʱͶϿ */ + CtrlCode = TCP_CTRL_DISCONNECT; + } + break; + default: + CtrlCode = TCP_CTRL_IDLE; + break; + } + return CtrlCode; +} + +/************************************************************************ +:˫ϲTCP +룺 + TCP_CTRL TcpCtrl, RSSP2TCP(ֻTCP_CTRL_CONNECTTCP_CTRL_DISCONNECT) + TCP_STATE RedState, ״̬ + TCP_STATE BlueState ״̬ + +ֵUINT8 ˫ϲTCP +************************************************************************/ +UINT8 GetMergeTcpCtrl(TCP_CTRL TcpCtrl, TCP_STATE RedState, TCP_STATE BlueState) +{ + UINT8 MergeCtrl = 0; + UINT8 RedCtrl = 0; + UINT8 BlueCtrl = 0; + + RedCtrl = GetOneTcpCtrl(TcpCtrl, RedState); + BlueCtrl = GetOneTcpCtrl(TcpCtrl, BlueState); + MergeCtrl = (RedCtrl & 0x0f) * 16 + (BlueCtrl & 0x0f); + + return MergeCtrl; +} + +/************************************************************************ +ܣЭTCP·Ʊ + + RSSP2_INFO_STRU *pRssp2Stru еTCPڵϢRSSP2ڵеTCPϢ + + UINT16 bufLen, TCP·Ʊij + const UINT8 *buf TCP·Ʊ +ֵ: 0ʧ 1ɹ +˵: + TCPƱʱȽTCPڵĿΪϿ,ҲRSSP2ѾɾʱĬϷTCP + RSSP2·ϷͽʱµTCPڵ㣬TCP״̬ΪѶϿ +************************************************************************/ +UINT8 RsspIIOutputTcpCtrl(UINT16 *pbufLen, UINT8 *buf, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 i = 0; + UINT8 nCount = 0; + UINT8 rt = 0; + TCP_LNK_NODE_STRU *pTcpNode = NULL; + + if ((NULL == pbufLen) || (NULL == buf)) + { + rt = 0; + } + else + { + rt = 1; + } + + if (1 == rt) + { + *pbufLen = 2; + ShortToChar(0, buf); + } + + if ((1 == rt) && (NULL != pRssp2Struct) && (1 == g_IsInited)) + { + /* TCPڵĿ */ + for (i = 0; i < pRssp2Struct->LnkNodeNum; i++) + { + pRssp2Struct->TcpNodeArr[i].TcpCtrl = TCP_CTRL_DISCONNECT; + } + + /* TCPڵĿ */ + for (i = 0; i < pRssp2Struct->LnkNodeNum; i++) + { + if (pRssp2Struct->LnkNodeArr[i].NodeStatus != NODE_REPLACE) + { + pTcpNode = SearchTcpNode(pRssp2Struct->LnkNodeArr[i].LocalEtcsId, pRssp2Struct->LnkNodeArr[i].DestEtcsId, pRssp2Struct); + if (NULL == pTcpNode) + { + /* RSSP2дµͨŽڵ,ҪӦTCPڵ */ + pTcpNode = GetTcpReplaceNode(pRssp2Struct); + if (NULL != pTcpNode) + { + InitTcpNode(pRssp2Struct->LnkNodeArr[i].LocalEtcsId, pRssp2Struct->LnkNodeArr[i].DestEtcsId, pTcpNode); + } + else + { + /* TCPڵûҵýڵ,TCPڵѾ,򱣳ָΪNULLRSSP2ڵ,TCP */ + /* Ӧòᷢ */ + } + } + if (NULL != pTcpNode) + { + pTcpNode->TcpCtrl = pRssp2Struct->LnkNodeArr[i].NodeInfo.tcpParam.TCPCtrl; + } + } + } + + /* ɾЧTCPڵ */ + RemoveInactiveTcpNode(pRssp2Struct); + + /* TCP·Ʊ */ + /* + | ڵ1 | ڵ2 | ... + 2ֽ | ͨ豸(4byte) (1byte) | ... | ... + */ + nCount = 0; + for (i = 0; i < pRssp2Struct->LnkNodeNum; i++) + { + if (NODE_REPLACE != pRssp2Struct->TcpNodeArr[i].NodeStatus) + { + LongToChar(pRssp2Struct->TcpNodeArr[i].DestEtcsId, &buf[2 + 5 * nCount]); + buf[2 + 5 * nCount + 4] = GetMergeTcpCtrl(pRssp2Struct->TcpNodeArr[i].TcpCtrl, pRssp2Struct->TcpNodeArr[i].RedState, pRssp2Struct->TcpNodeArr[i].BlueState); + nCount++; + } + } + ShortToChar(nCount * 5, buf); + *pbufLen = 2 + nCount * 5; + } + return rt; +} + + +/* +*: հ +*: RSSP2_INFO_STRU* rsspii +*: +*: +*ֵ: +*/ +static void ClearNetsRecvPkgNum(RSSP2_INFO_STRU* rsspii) +{ + UINT16 i = 0u; /*ѭ*/ + + if ((NULL != rsspii) && (NULL != rsspii->NetsRecvPkgNums)) /**/ + { + for (i = 0; i < rsspii->NetsRecvPkgNumsLen; i++) + { + Rssp2MemSet((UINT8*)rsspii->NetsRecvPkgNums[i].NetsPkgNum, 2 * sizeof(UINT16), 0u); + } + } +} + +/* +*: øհ +*: RSSP2_INFO_STRU* rsspii +* const UINT32 dstEtcsId ĿETCSID +* const UINT8 netIdx ± +*: +*: +*ֵ: +*/ +static void SetNetsRecvPkgNum(RSSP2_INFO_STRU* rsspii, const UINT32 dstEtcsId, const UINT8 netIdx) +{ + UINT16 i = 0u; /*ѭ*/ + + if ((NULL != rsspii) && (NULL != rsspii->NetsRecvPkgNums) && ((0u == netIdx) || (1u == netIdx))) /**/ + { + for (i = 0; i < rsspii->NetsRecvPkgNumsLen; i++) + { + if (dstEtcsId == rsspii->NetsRecvPkgNums[i].DstEtcsId) /*ҵ*/ + { + rsspii->NetsRecvPkgNums[i].NetsPkgNum[netIdx]++; + break; + } + } + if ((i == rsspii->NetsRecvPkgNumsLen) && (rsspii->NetsRecvPkgNumsLen < rsspii->MaxNumLink)) /*δҵ,һ豸*/ + { + rsspii->NetsRecvPkgNums[rsspii->NetsRecvPkgNumsLen].DstEtcsId = dstEtcsId; + Rssp2MemSet((UINT8*)rsspii->NetsRecvPkgNums[i].NetsPkgNum, 2 * sizeof(UINT16), 0u); + rsspii->NetsRecvPkgNums[rsspii->NetsRecvPkgNumsLen].NetsPkgNum[netIdx] = 1; + rsspii->NetsRecvPkgNumsLen++; + } + } +} + +/* +*: ȡRSSPIIյ +*: RSSP2_INFO_STRU* rsspii +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void RsspiiGetNetsRecvPkgNum(RSSP2_INFO_STRU* rsspii, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ + UINT16 dstTypeId = 0u; /*ĿID*/ + UINT8 isGetDstEtcsId = 0u; /*ǷȡĿETCSID*/ + UINT32 dstEtcsId = 0u; /*ĿETCSID*/ + UINT16 i = 0u; /*ѭ*/ + + if ((NULL != rsspii) && (NULL != rsspii->NetsRecvPkgNums) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum)) /**/ + { + (*redRecvPkgNum) = 0u; + (*blueRecvPkgNum) = 0u; + + dstTypeId = (UINT16)(((dstType << 8) & 0xFF00) | (dstId & 0x00FF)); + isGetDstEtcsId = dquDevName2EtcsId(dstTypeId, dstLogicId, &dstEtcsId); + if (1u == isGetDstEtcsId) + { + for (i = 0u; i < rsspii->NetsRecvPkgNumsLen; i++) /**/ + { + if (rsspii->NetsRecvPkgNums[i].DstEtcsId == dstEtcsId) /*ҵ*/ + { + (*redRecvPkgNum) = rsspii->NetsRecvPkgNums[i].NetsPkgNum[0]; + (*blueRecvPkgNum) = rsspii->NetsRecvPkgNums[i].NetsPkgNum[1]; + break; + } + } + } + } +} + + +/****************************************************************************** +** TriDES8Bytes +** ִεı׼8ֽDES㷨 +** pcKey1,pcKey2,pcKey3:ֱָ8ֽڵԿ +** pcData: ָ򱣴ԭʼ8ֽݻ +** bType: (ENCRYPT)(DECRYPT) +** pcData: ָ򱣴8ֽݻ +** ֵ +*******************************************************************************/ +LOCAL VOID TriDES8Bytes(LPBYTE pcKey1, LPBYTE pcKey2, LPBYTE pcKey3, LPBYTE pcData, INT bType) +{ + UINT32 savedkey1[32] = { 0 }; + UINT32 savedkey2[32] = { 0 }; + UINT32 savedkey3[32] = { 0 }; + + if (bType == ENCRYPT) /* ݼܹ */ + { + buildsubkey(pcKey2, DECRYPT); + savesubkey(savedkey2); + buildsubkey(pcKey3, ENCRYPT); + savesubkey(savedkey3); + buildsubkey(pcKey1, ENCRYPT); + savesubkey(savedkey1); + fastdes(pcData, pcData); + setsubkey(savedkey2); + fastdes(pcData, pcData); + setsubkey(savedkey3); + fastdes(pcData, pcData); + } + else + { + buildsubkey(pcKey2, ENCRYPT); + savesubkey(savedkey2); + buildsubkey(pcKey1, DECRYPT); + savesubkey(savedkey1); + buildsubkey(pcKey3, DECRYPT); + savesubkey(savedkey3); + fastdes(pcData, pcData); + setsubkey(savedkey2); + fastdes(pcData, pcData); + setsubkey(savedkey1); + fastdes(pcData, pcData); + } +} + +/****************************************************************************** +** BuildSessionKeys +** ɻỰԿ +** pMaslMASLָ +** +** ֵ +******************************************************************************/ +LOCAL VOID BuildSessionKeys(MASL_PARAM *pMasl) +{ + UINT8 ucKey[8] = { 0 }; + UINT8 ucRALRBL[8] = { 0 }; + UINT8 ucRARRBR[8] = { 0 }; + + ucRALRBL[0] = pMasl->Ra[0]; + ucRALRBL[1] = pMasl->Ra[1]; + ucRALRBL[2] = pMasl->Ra[2]; + ucRALRBL[3] = pMasl->Ra[3]; + ucRALRBL[4] = pMasl->Rb[0]; + ucRALRBL[5] = pMasl->Rb[1]; + ucRALRBL[6] = pMasl->Rb[2]; + ucRALRBL[7] = pMasl->Rb[3]; + + ucRARRBR[0] = pMasl->Ra[4]; + ucRARRBR[1] = pMasl->Ra[5]; + ucRARRBR[2] = pMasl->Ra[6]; + ucRARRBR[3] = pMasl->Ra[7]; + ucRARRBR[4] = pMasl->Rb[4]; + ucRARRBR[5] = pMasl->Rb[5]; + ucRARRBR[6] = pMasl->Rb[6]; + ucRARRBR[7] = pMasl->Rb[7]; + + CommonMemCpy(ucKey, 8, ucRALRBL, 8); + /* 3DES㷨ɻỰԿ*/ + TriDES8Bytes(pMasl->km1, pMasl->km2, pMasl->km3, ucRALRBL, ENCRYPT); + CommonMemCpy(pMasl->ks1, 8, ucRALRBL, 8); + TriDES8Bytes(pMasl->km1, pMasl->km2, pMasl->km3, ucRARRBR, ENCRYPT); + CommonMemCpy(pMasl->ks2, 8, ucRARRBR, 8); + TriDES8Bytes(pMasl->km3, pMasl->km2, pMasl->km1, ucKey, ENCRYPT); + CommonMemCpy(pMasl->ks3, 8, ucKey, 8); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 109, "P5109:MASL:build session key11:0x%02x %02x %02x %02x\n", 4, + pMasl->ks1[0], pMasl->ks1[1], pMasl->ks1[2], pMasl->ks1[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 109, "P5109:MASL:build session key12:0x%02x %02x %02x %02x\n", 4, + pMasl->ks1[4], pMasl->ks1[5], pMasl->ks1[6], pMasl->ks1[7], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 109, "P5109:MASL:build session key21:0x%02x %02x %02x %02x\n", 4, + pMasl->ks2[0], pMasl->ks2[1], pMasl->ks2[2], pMasl->ks2[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 109, "P5109:MASL:build session key22:0x%02x %02x %02x %02x\n", 4, + pMasl->ks2[4], pMasl->ks2[5], pMasl->ks2[6], pMasl->ks2[7], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 109, "P5109:MASL:build session key31:0x%02x %02x %02x %02x\n", 4, + pMasl->ks3[0], pMasl->ks3[1], pMasl->ks3[2], pMasl->ks3[3], 0, 0); + commonLogMsg(vRecArray, vRecArraySize, RSSP2_LOG_INFO, 109, "P5109:MASL:build session key32:0x%02x %02x %02x %02x\n", 4, + pMasl->ks1[4], pMasl->ks3[5], pMasl->ks3[6], pMasl->ks3[7], 0, 0); +} + +/****************************************************************************** +** GetFrameMAC +** ֡MACֵοSubset-037 V2.3.0 7.2.2.2--Safety procedures +** pcKey1,pcKey2,pcKey3: ֱָ8ֽڵijʼԿ +** pcFrame: ָԭʼ֡ +** ulDA:շctcsIDֽڷʽҶ +** iFrameLen: ԭʼ֡ +** pcMac: ָ8ֽڵMACֵ洢 +** ֵ +******************************************************************************/ +LOCAL VOID GetFrameMAC(LPBYTE pucKey1, LPBYTE pucKey2, LPBYTE pucKey3, + UINT32 dwDA, LPBYTE pucMac, LPBYTE pucFrame, INT iFrameLen) +{ + INT32 i; + INT32 j = 0; + INT32 iByteItem = 0; + UINT8 cData[8] = { 0 }; /* 64λݿ */ + UINT8 ucDataToCal[1500] = { 0 }; /* ڼMac */ + INT iLoopTimes; /* ѭ */ + UINT32 savedkey1[32] = { 0 }; + UINT32 savedkey2[32] = { 0 }; + UINT32 savedkey3[32] = { 0 }; + + CommonMemSet(ucDataToCal, 1500, 0x00, 1500); + + /* ֽڵĴǰ׺ l*/ + ucDataToCal[0] = (UINT8)((iFrameLen + 3) / 256); + ucDataToCal[1] = (UINT8)(iFrameLen + 3); + + /* ǰ׺24λDA*/ + ucDataToCal[2] = (UINT8)(dwDA >> 16); + ucDataToCal[3] = (UINT8)(dwDA >> 8); + ucDataToCal[4] = (UINT8)dwDA; + + for (i = 0; i < iFrameLen; i++) + { + ucDataToCal[i + 5] = pucFrame[i]; + } + + iFrameLen = iFrameLen + 5; + /* ѭ*/ + iLoopTimes = (iFrameLen + 7) / 8; /* ǰ׺ֽڳ(=5)ȡ8ֽڵ */ + + buildsubkey(pucKey1, ENCRYPT); + savesubkey(savedkey1); + setsubkey(savedkey1); + + for (i = 0; i < iLoopTimes; i++) + { + /* 64λĵλݿ鲢ǰһεĽݲʱ0 */ + for (iByteItem = 0; iByteItem < 8; iByteItem++) + { + if (iFrameLen > 0) + { + cData[iByteItem] ^= ucDataToCal[j++]; + iFrameLen--; + } + } + /* DES */ + fastdes(cData, cData); + } + + /* һݿ3-DES㷨 */ + buildsubkey(pucKey2, DECRYPT); + savesubkey(savedkey2); + setsubkey(savedkey2); + fastdes(cData, cData); + buildsubkey(pucKey3, ENCRYPT); + savesubkey(savedkey3); + setsubkey(savedkey3); + fastdes(cData, cData); + /* յΪMAC */ + CommonMemCpy(pucMac, 8, cData, 8); +} + +/****************************************************************************** +** GetTimeDiff +** ȡʱIJֵ +** NewTimeµʱ +** OldTime ϴεʱ +** +** ֵʱֵ +******************************************************************************/ +LOCAL UINT32 GetTimeDiff(UINT32 NewTime, UINT32 OldTime) +{ + UINT32 retVal = 0; + + if (NewTime >= OldTime) + { + retVal = (NewTime - OldTime); + } + else + { + retVal = (NewTime + (MAX_TIME - OldTime) + 1); + } + + return retVal; +} + +/****************************************************************************** +** GetTsDiff +** ȡŵIJֵ +** NewTsµĴ +** OldTsһεĴ +** +** ֵŵIJֵ +******************************************************************************/ +LOCAL INT GetTsDiff(UINT16 NewTs, UINT16 OldTs) +{ + INT retVal = 0; + + if (NewTs >= OldTs) + { + retVal = (NewTs - OldTs); + /*7յݻ,յTS·TS25(7000/285С)ľͶ,TSֵ25*/ + if (retVal > 25) + { + retVal = -1; + } + } + else + { + retVal = OldTs - NewTs; + if (retVal > (INT)(MAX_SN / 2)) + { + retVal = (NewTs + (MAX_SN - OldTs) + 1); + } + else + { + retVal = -retVal; + } + } + + return retVal; +} + +/****************************************************************************** +** GetSNDiff +** Get SN Diff +** wNewSN new sn +** wOldSN last sn +** none +** ֵreturn diff +******************************************************************************/ +LOCAL INT GetSNDiff(UINT16 wNewSN, UINT32 wOldSN) +{ + INT iRetVal = 0; + if (wNewSN >= wOldSN) + { + iRetVal = (wNewSN - wOldSN); + if (iRetVal > (INT)((MAX_SN) / 2)) + { + iRetVal = -(INT)(MAX_SN - iRetVal + 1); + } + } + else + { + iRetVal = (wOldSN - wNewSN); + if (iRetVal > (INT)(MAX_SN / 2)) + { + iRetVal = (wNewSN + (MAX_SN - wOldSN + 1)); + } + else + { + iRetVal = -iRetVal; + } + } + return iRetVal; +} + +/*-------------------------------------------------------------------- + * RSSPⲿʹú End + *--------------------------------------------------------------------*/ + +#if (RSSP2_LOG_LEVEL >= 0) +void commonLogMsg(UINT8* RecArray, UINT16 RecSize, INT32 LogLevel, UINT8 LogCode, const CHAR *fmt, + UINT8 argNum, UINT32 arg0, UINT32 arg1, UINT32 arg2, UINT32 arg3, UINT32 arg4, UINT32 arg5) +{ + INT8 s[256] = { 0 }; + INT8 str[10] = {0}; + UINT8 i = 0; + UINT16 j = 0; + UINT16 arg[6] = { 0 }; + +#ifdef ZC_APP /*ZC APP,ZC־¼ӿڼ¼ȫ־Ϣ*/ + sprintf(s, fmt, arg0, arg1, arg2, arg3, arg4, arg5); + debug_infor_printf("%s", s); +#else + if (LogLevel <= RSSP2_LOG_LEVEL) + { +#ifdef RSSP2_RECORD_ERR_ASCII + arg[0] = arg0; + arg[1] = arg1; + arg[2] = arg2; + arg[3] = arg3; + arg[4] = arg4; + arg[5] = arg5; + CommonMemCpy(s, 6,fmt,6); + i=6; + for(j=0;j=0) +void RSSP2LogBinNodeInfo(UINT8* RecArray, UINT16 RecSize, RSSP2_LNK_INFO_NODE_STRU *pRssp2Node) +{ + /*edit 20170725 xb ־ӡ*/ + /* ͨŽڵϢ */ + PrintRecArray2ByteB(RecArray, RecSize, pRssp2Node->LocalDevName); + PrintRecArray2ByteB(RecArray, RecSize, pRssp2Node->DestDevName); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->LinkStatus); + /*PrintRecArray4ByteB(RecArray, RecSize, pRssp2Node->LocalEtcsId);*/ + /*PrintRecArray4ByteB(RecArray, RecSize, pRssp2Node->DestEtcsId);*/ + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NoRecvDataCycleNum); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NoAppDataCycleNum); + /* SAIϢ */ + PrintRecArray2ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.recvSN); + /*PrintRecArray2ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.remoteECPeriod);*/ + PrintRecArray2ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.recvEC); + PrintRecArray2ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.sendSN); + /*PrintRecArray2ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.localECPeriod);*/ + PrintRecArray2ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.sendEC); + PrintRecArray4ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.Tstart); + PrintRecArray2ByteB(RecArray, RecSize, (UINT16)(pRssp2Node->NodeInfo.saiParam.NextEx)); + PrintRecArray2ByteB(RecArray, RecSize, (INT16)pRssp2Node->NodeInfo.saiParam.EcDelta); + PrintRecArray4ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.Delta_equal_count); + PrintRecArray4ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.EcState); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.statesReqACK); + PrintRecArray4ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.requestofAckTime); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.bAck); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.saiParam.status); + /* MASLϢ */ + PrintRecArray4ByteB(RecArray, RecSize, pRssp2Node->NodeInfo.maslParam.Tconnect); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.maslParam.status); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.maslParam.connStatus); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.maslParam.discIndication.reason); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.maslParam.discIndication.subReason); + /* ALEϢ */ + PrintRecArray2ByteB(RecArray, RecSize, (INT16)pRssp2Node->NodeInfo.aleParam.recvTS); + PrintRecArray2ByteB(RecArray, RecSize, (INT16)pRssp2Node->NodeInfo.aleParam.curRecvTS); + PrintRecArray2ByteB(RecArray, RecSize, (INT16)pRssp2Node->NodeInfo.aleParam.sendTS); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.aleParam.state); + PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.aleParam.bIsZero); + /*PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.aleParam.appType);*/ + /*PrintRecArrayByte(RecArray, RecSize, pRssp2Node->NodeInfo.aleParam.nrFlag);*/ + /* TCPϢ */ + +} +#endif diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2.h new file mode 100644 index 0000000..72d9b5d --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2.h @@ -0,0 +1,176 @@ +/** ****************************************************** +* +* ļ Rssp2.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ䣺 2016.2.22 +* з +* Rssp2Эʵ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +********************************************************/ + +#ifndef _RSSP2_H_ +#define _RSSP2_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "Rssp2Struct.h" +#include "typedefine.h" +#include "Rssp2Configl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern UINT8 g_ucKMACKey1[8]; /* g_ucKMACKey1 */ +extern UINT8 g_ucKMACKey2[8]; /* g_ucKMACKey2 */ +extern UINT8 g_ucKMACKey3[8]; /* g_ucKMACKey3 */ +extern UINT8 g_btRb[8]; /* 64Rb */ +extern UINT8 g_btRa[8]; /* 64λRa */ + +/*-------------------------------------------------------------------- + * RSSP2ӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : Rssp2Receive + * : ԺݽRSSP2İȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ + * УpRssp2Struct->OutnetQueueA + * pRssp2Struct->OutnetQueueB + * УpRssp2Struct->DataToApp + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIReceive(RSSP2_INFO_STRU *pRssp2Struct); + +/*********************************************************************** + * : RsspIIOutput + * : ӦݽRSSPİȫ + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSP2ͳһṹ + * УpRssp2Struct->OutputDataQueue + * УpRssp2Struct->AppArray + * pRssp2Struct->VarArray + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIOutput(RSSP2_INFO_STRU *pRssp2Struct); + +/*********************************************************************** + * : RsspIIInit + * : ͨúʵֶRSSP2ijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIInit(UINT8* fileName,RSSP2_INFO_STRU *pRssp2Struct); + +/*********************************************************************** + * : RsspIIFreeSpace + * : ͨúͷRSSP2㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIFreeSpace(RSSP2_INFO_STRU *pRssp2Struct); + + +/*********************************************************************** + * : RsspIILnkStatus + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * destType UINT8 IN Ŀ + * destId UINT8 IN ĿID + * logicId UINT16 IN VOBC豸ʱʹö˱ţ豸ʱЧ + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ壬гʼֵá + * ֵ : UINT8 0ڸ·ش + * 0x17·ݴ״̬DATA + * 0x33, Ϊڽ + * 0x4e, Ϊܷڵȴ + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 RsspIILnkStatus(UINT8 destType,UINT8 destId, UINT16 logicId, RSSP2_INFO_STRU *pRssp2Struct); + +/*********************************************************************** + * : RsspIILnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * destType UINT8 IN Ŀ + * destId UINT8 IN ĿID + * logicId UINT16 IN VOBC豸ʱʹö˱ţ豸ʱЧ + * pRssp2Struct RSSP2_INFO_STRU* INOUT RSSP2ͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIILnkDelete(UINT8 destType,UINT8 destId, UINT16 logicId, RSSP2_INFO_STRU *pRssp2Struct); + +/*********************************************************************** + * : RsspIIRefresh + * : Ӧʹøú¶ԱRSSP2м¸ֵ + * : + * + * -------------------------------------------------------------- + * sLen_Input UINT16 IN мĴС + * Input_Data_LnkMes UINT8* IN м + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspIIRefresh(UINT16 VarLen, const UINT8 *VarArray, RSSP2_INFO_STRU *pRssp2Struct); + +/************************************************************************ +:ӦʹøúRSSP2Э뱾ڵTCP·״̬Ϣ +UINT16 bufLen,TCP·״̬Ϣֽ + const UINT8 *buf TCP·״̬Ϣ + +ֵUINT8 1 0󷵻 +************************************************************************/ +UINT8 RsspIIInputTcpState(UINT16 bufLen,const UINT8 *buf,RSSP2_INFO_STRU *pRssp2Struct); + +/************************************************************************ +:ӦʹøúȡRSSP2ЭıڵTCP·Ϣ +UINT16 bufLen,TCP·״̬Ϣֽ + const UINT8 *buf TCP·״̬Ϣ + +ֵUINT8 1 0󷵻 +************************************************************************/ +UINT8 RsspIIOutputTcpCtrl(UINT16 *pbufLen,UINT8 *buf,RSSP2_INFO_STRU *pRssp2Struct); + +/* +*: ȡRSSPIIյ +*: RSSP2_INFO_STRU* rsspii fsfb +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void RsspiiGetNetsRecvPkgNum(RSSP2_INFO_STRU* rsspii, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); + +/*-------------------------------------------------------------------- + * RSSP2ӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Common.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Common.c new file mode 100644 index 0000000..b3566a3 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Common.c @@ -0,0 +1,107 @@ +/************************************************************************ +* +* ļ Rssp2Common.c +* Ȩ˵ +* 汾 1.0 +* ʱ +* ؼЭ鲿 +* RSSP2ЭʹõĻ麯. +* ʹע +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +************************************************************************/ + +#include "Rssp2Common.h" +#include "Convert.h" + +/*********************************************************************** + * : Rssp2MemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pDestAdd UINT8 * INOUT ڴռ俪ʼַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : 1 + ***********************************************************************/ +UINT8 Rssp2MemSet(UINT8 *pDestAdd, UINT16 Len, UINT8 Val) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = Val; + } + + return (UINT8)1; +} + +/*********************************************************************** + * : Rssp2MemCopy + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pSrcAdd const UINT8 * IN Դڴռַ + * pDestAdd UINT8 * INOUT Ŀڴռַ + * Len UINT16 IN ڴռС + * + * ֵ : 1 + ***********************************************************************/ +UINT8 Rssp2MemCopy(const UINT8 *pSrcAdd,UINT8 *pDestAdd, UINT16 Len) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = pSrcAdd[index]; + } + + return (UINT8)1; +} + +/*********************************************************************** + * : Rssp2TypeId2DevName + * : TypeID ȡӦ豸ʶ + * : + * + * -------------------------------------------------------------- + * Type UINT8 IN + * ID UINT8 IN Id + * pDevName UINT16* OUT ʶ + * + * ֵ : + ***********************************************************************/ +void Rssp2TypeId2DevName(UINT8 Type, UINT8 Id, UINT16* pDevName) +{ + UINT8 buff[2]; + buff[0] = Type; + buff[1] = Id; + *pDevName = ShortFromChar(buff); + return; +} +/*********************************************************************** + * : DevName2TypeId_WL + * : ȡӦͺId + * : + * + * -------------------------------------------------------------- + * DevName UINT8 IN ʶ + * pType UINT8* OUT + * pID UINT8* OUT Id + * + * ֵ : + ***********************************************************************/ +void Rssp2DevName2TypeId(UINT16 DevName, UINT8* pType,UINT8* pId) +{ + UINT8 buff[2] = { 0 }; + ShortToChar(DevName,buff); + *pType = buff[0]; + *pId = buff[1]; + return; +} + + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Common.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Common.h new file mode 100644 index 0000000..a9a3ca3 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Common.h @@ -0,0 +1,96 @@ +/************************************************************************ +* +* ļ RsspCommonWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.10.02 +* ؼЭ鲿 +* RSSPЭʹõFLSR麯. +* ʹע ʹ֮ǰinittab_WLgTableFast_WLֵ趨 +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +* 2009/11/01 ¥ΰ +* 2009/12/02 ¥ΰ MisraCӦ +* 2013/03/01 ޸CIVOBCĶ壬ɾZCĶ +************************************************************************/ + +#ifndef _RSSP2_COMMON_H_ +#define _RSSP2_COMMON_H_ + +#include "CommonTypes.h" + +#ifndef NULL +#define NULL 0 +#endif + +#define MAX_RSSP2_MSG 1400 /* RSSPϢ֡󳤶 */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************** + * : RsrMemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pDestAdd UINT8 * INOUT ڴռ俪ʼַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : + ***********************************************************************/ +UINT8 Rssp2MemSet(UINT8 *pDestAdd, UINT16 Len, UINT8 Val); + +/*********************************************************************** + * : RsrMemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pSrcAdd const UINT8 * IN Դڴռַ + * pDestAdd UINT8 * INOUT Ŀڴռַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : + ***********************************************************************/ +UINT8 Rssp2MemCopy(const UINT8 *pSrcAdd,UINT8 *pDestAdd, UINT16 Len); + +/*********************************************************************** + * : TypeId2DevName_WL + * : TypeID ȡӦ豸ʶ + * : + * + * -------------------------------------------------------------- + * Type UINT8 IN + * ID UINT8 IN Id + * pDevName UINT16* OUT ʶ + * + * ֵ : + ***********************************************************************/ +void Rssp2TypeId2DevName(UINT8 Type, UINT8 Id, UINT16* pDevName); + +/*********************************************************************** + * : DevName2TypeId_WL + * : ȡӦͺId + * : + * + * -------------------------------------------------------------- + * DevName UINT16 IN ʶ + * pType UINT8* OUT + * pID UINT8* OUT Id + * + * ֵ : + ***********************************************************************/ +void Rssp2DevName2TypeId(UINT16 DevName,UINT8* pType, UINT8* pId); + + +#ifdef __cplusplus +} +#endif + +#endif /* endif */ diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2LnkNodeMgr.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2LnkNodeMgr.c new file mode 100644 index 0000000..353eaf6 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2LnkNodeMgr.c @@ -0,0 +1,500 @@ +/******************************************************** +* ļ RsspLnkNodeMgrWl.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.12.07 +* ؼЭ鲿 +* ͨŽڵزʼѯǵȲ +* ʹע⣺ñļеĺȵóʼĺ +* +* ޸ļ¼ +* ʱ ޸ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +********************************************************/ + +#include "Rssp2LnkNodeMgr.h" +#include "Rssp2Common.h" +#include "dsuRssp2Func.h" +#include "Convert.h" +#include "typedefine.h" +#include "Rssp2.h" +#include "stdlib.h" + +/*-------------------------------------------------------------------- + * ·ģڲ Start + *--------------------------------------------------------------------*/ + + /*-------------------------------------------------------------------- + * ·ģڲ End + *--------------------------------------------------------------------*/ + + /*-------------------------------------------------------------------- + * RSSPṩĽӿں Start + *--------------------------------------------------------------------*/ + /*********************************************************************** + * : RsspLnkStatus_WL + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * destType UINT8 IN + * destId UINT8 IN BSDַ + * logicId UINT16 IN VOBC豸ʱʹö˱ţ豸ʱЧ + * ֵ : UINT8 0ڸ·ش + * 0x17·ݴ״̬DATA + * 0x33, Ϊڽ + * 0x4e, Ϊܷڵȴ + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 GetRsspIILnkStatus(UINT8 destType, UINT8 destId, UINT16 logicId, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; + UINT16 destDevName = 0; + UINT32 destEtcsId = 0; + UINT32 localEtcsId = 0; + RSSP2_LNK_INFO_NODE_STRU* pNode = NULL; + + Rssp2TypeId2DevName(destType, destId, &destDevName); + + if (NULL != pRssp2Struct) + { + ret = dquDevName2EtcsId(destDevName, logicId, &destEtcsId); + } + else + { + ret = 0; + } + + if (1 == ret) + { + pNode = SearchRssp2LnkNode(pRssp2Struct->LocalEtcsId, destEtcsId, pRssp2Struct); + } + else + { + pNode = NULL; + } + + if (pNode == NULL) + { + /* · */ + ret = 0; + } + else if (pNode->NodeInfo.saiParam.status == SAI_STATE_CONNECTED) + { + /* */ + ret = 0x17; + } + else + { + switch (pNode->NodeInfo.maslParam.role) + { + case MASL_ROLE_INITIATOR: + if (pNode->NodeInfo.tcpParam.TCPCtrl == TCP_CTRL_CONNECT) + { + ret = 0x33;/* Ϊڽ */ + } + else + { + ret = 0x2b;/* ͨж */ + } + break; + case MASL_ROLE_RESPONDER: + if (pNode->NodeInfo.tcpParam.TCPState == TCP_STATE_CONNECTED) + { + ret = 0x4e;/* Ϊܷڵȴ */ + } + else + { + ret = 0x2b;/* ͨж */ + } + break; + default: + /* ͨ״̬*/ + ret = 0x2b; + break; + } + } + + return ret; +} + +/*********************************************************************** + * : InitLnkNodeArr_WL + * : ȫͨŽڵгʼ + * + * : + * + * -------------------------------------------------------------- + * Num UINT8 IN ӦָͨŶ + * + * ȫֱ : LnkNodeArr ͨŽڵ + * ֵ : UINT8 1: 0 + ***********************************************************************/ +UINT8 InitRssp2LnkNodeArr(UINT8 num, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 ret = 0; + UINT8 index = 0; + UINT16 lnkNodeArrSize = 0; + pRssp2Struct->LnkNodeNum = num; + lnkNodeArrSize = sizeof(RSSP2_LNK_INFO_NODE_STRU)*pRssp2Struct->LnkNodeNum; + pRssp2Struct->LnkNodeArr = (RSSP2_LNK_INFO_NODE_STRU*)malloc(lnkNodeArrSize); + pRssp2Struct->TcpNodeArr = (TCP_LNK_NODE_STRU *)malloc(pRssp2Struct->LnkNodeNum * sizeof(TCP_LNK_NODE_STRU)); + + if ((NULL == pRssp2Struct->LnkNodeArr) || (NULL == pRssp2Struct->TcpNodeArr)) + { + ret = 0; + } + else + { + Rssp2MemSet((UINT8*)pRssp2Struct->LnkNodeArr, lnkNodeArrSize, 0); /* */ + Rssp2MemSet((UINT8*)pRssp2Struct->TcpNodeArr, pRssp2Struct->LnkNodeNum * sizeof(TCP_LNK_NODE_STRU), 0); + for (index = 0;index < pRssp2Struct->LnkNodeNum;index++) + { + pRssp2Struct->LnkNodeArr[index].NodeStatus = NODE_REPLACE; /* ͨŽڵΪɸǽڵ */ + pRssp2Struct->TcpNodeArr[index].NodeStatus = NODE_REPLACE; + } + ret = 1; + } + return ret; +} + +TCP_LNK_NODE_STRU * SearchTcpNode(UINT32 LocalEtcsId, UINT32 DestEtcsId, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 i = 0; + TCP_LNK_NODE_STRU *pTcpNode = NULL; + for (i = 0;i < pRssp2Struct->LnkNodeNum;i++) + { + if ((pRssp2Struct->TcpNodeArr[i].NodeStatus != NODE_REPLACE) + && (pRssp2Struct->TcpNodeArr[i].LocalEtcsId == LocalEtcsId) + && (pRssp2Struct->TcpNodeArr[i].DestEtcsId == DestEtcsId)) + { + pTcpNode = &pRssp2Struct->TcpNodeArr[i]; + break; + } + } + return pTcpNode; +} + +TCP_LNK_NODE_STRU *GetTcpReplaceNode(RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 i = 0; + TCP_LNK_NODE_STRU *pTcpNode = NULL; + for (i = 0;i < pRssp2Struct->LnkNodeNum;i++) + { + if (pRssp2Struct->TcpNodeArr[i].NodeStatus == NODE_REPLACE) + { + pTcpNode = &pRssp2Struct->TcpNodeArr[i]; + break; + } + } + return pTcpNode; +} + +UINT8 InitTcpNode(UINT32 LocalEtcsId, UINT32 DestEtcsId, TCP_LNK_NODE_STRU *pTcpNode) +{ + UINT8 rt = 0; + if (NULL != pTcpNode) + { + pTcpNode->NodeStatus = NODE_DISBALED_REPLACE; + pTcpNode->LocalEtcsId = LocalEtcsId; + pTcpNode->DestEtcsId = DestEtcsId; + pTcpNode->TcpState = TCP_STATE_DISCONNECTED; + pTcpNode->RedState = TCP_STATE_DISCONNECTED; + pTcpNode->BlueState = TCP_STATE_DISCONNECTED; + pTcpNode->TcpCtrl = TCP_CTRL_DISCONNECT; + rt = 1; + } + return rt; +} +/************************************************************************ +:ɾTCPڵ + TCPڵĿΪϿ״̬ΪѶϿɾ֮ +************************************************************************/ +UINT8 RemoveInactiveTcpNode(RSSP2_INFO_STRU *pRssp2Stru) +{ + UINT8 rt = 0; + UINT8 i = 0; + if (NULL != pRssp2Stru) + { + + for (i = 0;i < pRssp2Stru->LnkNodeNum;i++) + { + if ((NODE_REPLACE != pRssp2Stru->TcpNodeArr[i].NodeStatus) + && (TCP_STATE_DISCONNECTED == pRssp2Stru->TcpNodeArr[i].TcpState) + && (TCP_CTRL_DISCONNECT == pRssp2Stru->TcpNodeArr[i].TcpCtrl)) + { + pRssp2Stru->TcpNodeArr[i].NodeStatus = NODE_REPLACE; + } + } + rt = 1; + } + return rt; +} + +/*********************************************************************** + * : SearchRssp2LnkNode + * : PSSPĿĵַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * localCtcsId UINT32 IN Rssp2Դַ + * destCtcsId UINT32 IN Pssp2Ŀĵַ + * pRssp2Struct RSSP2_INFO_STRU* IN RSSP2Э״̬ + * ֵ : RSSP2_LNK_INFO_NODE_STRU* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +RSSP2_LNK_INFO_NODE_STRU* SearchRssp2LnkNode(UINT32 localCtcsId, UINT32 destCtcsId, RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 index = 0; + RSSP2_LNK_INFO_NODE_STRU* retNodePtr = NULL; + + for (index = 0; index < pRssp2Struct->LnkNodeNum; index++) + { + if ((pRssp2Struct->LnkNodeArr[index].DestEtcsId == destCtcsId) + && (pRssp2Struct->LnkNodeArr[index].LocalEtcsId == localCtcsId) && (pRssp2Struct->LnkNodeArr[index].NodeStatus != NODE_REPLACE)) + { + retNodePtr = &pRssp2Struct->LnkNodeArr[index]; + break; + } + else + { + /* nothing */ + } + } + return retNodePtr; +} + + + +UINT8 InitRssp2LnkInfoNode(UINT32 LocaEtcsId, UINT32 DestEtcsId, MASL_ROLE role, LPRSSP2_LNK_INFO_NODE_STRU pRssp2LnkInfoNode) +{ + UINT8 ret = 0; + RSSP2_DEVICE_TYPE localEtcsType = 0; + RSSP2_DEVICE_TYPE WsEtcsType = 0; + UINT32 ObEtcsId = 0; + DSU_RSSP2_WS_TYPE_CFG_STRU rssp2WsTypeCfg; + DSU_RSSP2_LOC_TYPE_CFG_STRU rssp2LocTypeCfg; + DSU_RSSP2_DEV_CFG_STRU rssp2ObDevCfg; + + CommonMemSet(&rssp2WsTypeCfg, sizeof(DSU_RSSP2_WS_TYPE_CFG_STRU), 0, sizeof(DSU_RSSP2_WS_TYPE_CFG_STRU)); + CommonMemSet(&rssp2LocTypeCfg, sizeof(DSU_RSSP2_LOC_TYPE_CFG_STRU), 0, sizeof(DSU_RSSP2_LOC_TYPE_CFG_STRU)); + CommonMemSet(&rssp2ObDevCfg, sizeof(DSU_RSSP2_DEV_CFG_STRU), 0, sizeof(DSU_RSSP2_DEV_CFG_STRU)); + +#ifdef RSSP2_PREDEF_R + DSU_RSSP2_WS_TYPE_CFG_STRU rmtProclStkInfo; +#endif + + + if (NULL != pRssp2LnkInfoNode) + { + CommonMemSet(pRssp2LnkInfoNode, sizeof(RSSP2_LNK_INFO_NODE_STRU), 0, sizeof(RSSP2_LNK_INFO_NODE_STRU)); + ret = 1; + } + else + { + ret = 0; + } + + if (1 == ret) + { + ret = GetEtcsTypeFromEtcsId(LocaEtcsId, &localEtcsType); + } + + if (1 == ret) + { + if ((DEVICE_TYPE_ATP == localEtcsType)|| (DEVICE_TYPE_AOM == localEtcsType)) + { + /* Լdz豸ʱԶǹ豸 */ + ret = GetEtcsTypeFromEtcsId(DestEtcsId, &WsEtcsType); + ObEtcsId = LocaEtcsId; + } + else + { + /* Լǹ豸ʱԼ豸;ǹ豸 */ + WsEtcsType = localEtcsType; + ObEtcsId = DestEtcsId; + } + } + + if (1 == ret) + { + ret = dquRssp2GetWaysideTypeCfg((UINT8)WsEtcsType, &rssp2WsTypeCfg); + } + + if (1 == ret) + { + ret = dquRssp2GetLocalTypeCfg((UINT8)localEtcsType, &rssp2LocTypeCfg); + } + + if (1 == ret) + { + ret = dquRssp2GetDevCfg(ObEtcsId,&rssp2ObDevCfg); + } + +#ifdef RSSP2_PREDEF_R + if (1 == ret) + { + ret = dquRssp2GetWaysideTypeCfg(DestDevName, &rmtProclStkInfo); + } +#endif + + if (1 == ret) + { + pRssp2LnkInfoNode->NodeStatus = NODE_DISBALED_REPLACE; + pRssp2LnkInfoNode->LinkStatus = RSSP2_SEND_NONE; + + pRssp2LnkInfoNode->LocalEtcsId = LocaEtcsId; + pRssp2LnkInfoNode->DestEtcsId = DestEtcsId; + dquEtcsId2DevName(LocaEtcsId, &pRssp2LnkInfoNode->LocalDevName, &pRssp2LnkInfoNode->LocalLogId); + dquEtcsId2DevName(DestEtcsId, &pRssp2LnkInfoNode->DestDevName, &pRssp2LnkInfoNode->DestLogId); + + /* ò */ + + /* SAIʼ */ + Rssp2MemSet((UINT8*)&pRssp2LnkInfoNode->NodeInfo.saiParam, sizeof(SAI_PARAM), 0); + pRssp2LnkInfoNode->NodeInfo.saiParam.NextEx = 0.0; + pRssp2LnkInfoNode->NodeInfo.saiParam.status = SAI_STATE_DISCONNECTED; + pRssp2LnkInfoNode->NodeInfo.saiParam.UpdCount = 0; + pRssp2LnkInfoNode->NodeInfo.saiParam.UpdFailCountMax = rssp2WsTypeCfg.SAIUpdFailCountMax; /* EC¹ֵ */ + /* صEC */ + switch (localEtcsType) + { + case DEVICE_TYPE_ATP: + pRssp2LnkInfoNode->NodeInfo.saiParam.localECPeriod = 285.714; + break; + default: + pRssp2LnkInfoNode->NodeInfo.saiParam.localECPeriod = rssp2LocTypeCfg.SAI_EcPeriod; + break; + } + pRssp2LnkInfoNode->NodeInfo.saiParam.comECPeriod = rssp2LocTypeCfg.SAI_EcPeriod; /* Զ˴EC */ +#ifdef RSSP2_PREDEF_R + pRssp2LnkInfoNode->NodeInfo.saiParam.remoteECPeriod = rmtProclStkInfo.SAILocalECPeriod; + pRssp2LnkInfoNode->NodeInfo.saiParam.R = (double)(pRssp2LnkInfoNode->NodeInfo.saiParam.localECPeriod) / (double)(pRssp2LnkInfoNode->NodeInfo.saiParam.remoteECPeriod); +#else + pRssp2LnkInfoNode->NodeInfo.saiParam.R = 0.0; +#endif + pRssp2LnkInfoNode->NodeInfo.saiParam.Parameter_N = rssp2WsTypeCfg.SAISNDiffMax; /* SAIN */ + pRssp2LnkInfoNode->NodeInfo.saiParam.MaxSuccErrorCount = rssp2WsTypeCfg.SAIMaxErrValue; /* SAIֵ */ + pRssp2LnkInfoNode->NodeInfo.saiParam.Parameter_ALARM = rssp2WsTypeCfg.SAIECAlarm / rssp2LocTypeCfg.SAI_EcPeriod; /* DeltaAlarm */ + pRssp2LnkInfoNode->NodeInfo.saiParam.Timer_Syn = rssp2WsTypeCfg.SAITsyn; /* SAIʱʱ */ + pRssp2LnkInfoNode->NodeInfo.saiParam.Max_Cycles_In_Same_Delta_Value = rssp2WsTypeCfg.SAIECRtnPeriod / rssp2LocTypeCfg.SAI_EcPeriod;/* ʱͣڷ0ڵ */ + pRssp2LnkInfoNode->NodeInfo.saiParam.Ack_Request_Cycle_Rate = (UINT16)(rssp2LocTypeCfg.SAI_Tupd / pRssp2LnkInfoNode->NodeInfo.saiParam.localECPeriod); /* ʱ */ + + /* MASLʼ */ + Rssp2MemSet((UINT8*)&pRssp2LnkInfoNode->NodeInfo.maslParam, sizeof(MASL_PARAM), 0); + Rssp2MemCopy(g_btRa, pRssp2LnkInfoNode->NodeInfo.maslParam.Ra, 8); + Rssp2MemCopy(g_btRb, pRssp2LnkInfoNode->NodeInfo.maslParam.Rb, 8); + Rssp2MemCopy(&rssp2ObDevCfg.Key[0], pRssp2LnkInfoNode->NodeInfo.maslParam.km1, 8); + Rssp2MemCopy(&rssp2ObDevCfg.Key[8], pRssp2LnkInfoNode->NodeInfo.maslParam.km2, 8); + Rssp2MemCopy(&rssp2ObDevCfg.Key[16], pRssp2LnkInfoNode->NodeInfo.maslParam.km3, 8); + Rssp2MemSet(pRssp2LnkInfoNode->NodeInfo.maslParam.ks1, 8, 0); + Rssp2MemSet(pRssp2LnkInfoNode->NodeInfo.maslParam.ks2, 8, 0); + Rssp2MemSet(pRssp2LnkInfoNode->NodeInfo.maslParam.ks3, 8, 0); + pRssp2LnkInfoNode->NodeInfo.maslParam.Testab = rssp2WsTypeCfg.MASLTsynTimeOut;/* MASLʱʱ */ + pRssp2LnkInfoNode->NodeInfo.maslParam.Tsyn = rssp2WsTypeCfg.ALETsynTimeOut;/* ALEʱʱ */ + pRssp2LnkInfoNode->NodeInfo.maslParam.Tconnect = 0; + pRssp2LnkInfoNode->NodeInfo.maslParam.Tau1 = 0; + GetEtcsTypeFromEtcsId(pRssp2LnkInfoNode->LocalEtcsId, &pRssp2LnkInfoNode->NodeInfo.maslParam.localDevType); + GetEtcsTypeFromEtcsId(pRssp2LnkInfoNode->DestEtcsId, &pRssp2LnkInfoNode->NodeInfo.maslParam.remoteDevType); + pRssp2LnkInfoNode->NodeInfo.maslParam.btDf = (MASL_ROLE_INITIATOR == role) ? INITIATOR_TO_RESPONDER : RESPONDER_TO_INITIATOR; + pRssp2LnkInfoNode->NodeInfo.maslParam.role = role; + pRssp2LnkInfoNode->NodeInfo.maslParam.localCtcsID = pRssp2LnkInfoNode->LocalEtcsId; + pRssp2LnkInfoNode->NodeInfo.maslParam.remoteCtcsID = pRssp2LnkInfoNode->DestEtcsId; + pRssp2LnkInfoNode->NodeInfo.maslParam.status = MASL_STATE_DISCONNECTED; + pRssp2LnkInfoNode->NodeInfo.maslParam.connStatus = MASL_CONNECTION_NONE; + pRssp2LnkInfoNode->NodeInfo.maslParam.discIndication.reason = 0; + pRssp2LnkInfoNode->NodeInfo.maslParam.discIndication.subReason = 0; + + /* ALE */ + Rssp2MemSet((UINT8*)&pRssp2LnkInfoNode->NodeInfo.aleParam, sizeof(ALE_PARAM), 0); + pRssp2LnkInfoNode->NodeInfo.aleParam.state = ALE_STATE_DISCONNECT; + pRssp2LnkInfoNode->NodeInfo.aleParam.localCtcsID = pRssp2LnkInfoNode->LocalEtcsId; + pRssp2LnkInfoNode->NodeInfo.aleParam.remoteCtcsID = pRssp2LnkInfoNode->DestEtcsId; + pRssp2LnkInfoNode->NodeInfo.aleParam.version = RSSP2_ALE_VERSION; + pRssp2LnkInfoNode->NodeInfo.aleParam.bIsZero = FALSE; + pRssp2LnkInfoNode->NodeInfo.aleParam.appType = ALE_APP_TYPE_RBC_INTERLOCK; + pRssp2LnkInfoNode->NodeInfo.aleParam.nrFlag = ALE_NR_FLAG_N; + pRssp2LnkInfoNode->NodeInfo.aleParam.recvTS = 0; + pRssp2LnkInfoNode->NodeInfo.aleParam.sendTS = 0; + + /* TCP */ + pRssp2LnkInfoNode->NodeInfo.tcpParam.TCPCtrl = TCP_CTRL_DISCONNECT; + pRssp2LnkInfoNode->NodeInfo.tcpParam.TCPState = TCP_STATE_DISCONNECTED; + + ret = 1; + } + return ret; +} + +/*********************************************************************** + * : GetRssp2ReplaceNode + * : ͨɸǵĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * + * ȫֱ : LnkNodeArr* ȫֱͨŽڵ + * ֵ : RSSP2_LNK_INFO_NODE_STRU* NULL쳣 NULLͨŽڵ + ***********************************************************************/ + +RSSP2_LNK_INFO_NODE_STRU* GetRssp2ReplaceNode(RSSP2_INFO_STRU *pRssp2Struct) +{ + UINT8 index = 0; + RSSP2_LNK_INFO_NODE_STRU* retNodePtr = NULL; + + for (index = 0; index < pRssp2Struct->LnkNodeNum; index++) + { + /* ýڵɸ ظýڵָ */ + /*if((srcAddr == LnkNodeArr[index].Rssp2SrcAddr) && (desAddr == LnkNodeArr[index].Rssp2DestAddr) + && (LnkNodeArr[index].NodeStatus == Replace))*/ + if (pRssp2Struct->LnkNodeArr[index].NodeStatus == NODE_REPLACE) + { + retNodePtr = &pRssp2Struct->LnkNodeArr[index]; + break; + } + else + { + /* ʲô */ + } + } + return retNodePtr; +} + + +/*********************************************************************** + * : DestoryRssp2LnkNodeArr + * : ͷͨŽڵĿռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : ޡ + ***********************************************************************/ +void DestoryRssp2LnkNodeArr(RSSP2_INFO_STRU *pRssp2Struct) +{ + /* ͨŽڵĿռ䲻Ϊգͷڴռ */ + if (NULL != pRssp2Struct->LnkNodeArr) + { + free(pRssp2Struct->LnkNodeArr); + pRssp2Struct->LnkNodeArr = NULL; + pRssp2Struct->LnkNodeNum = 0; + } + + if (NULL != pRssp2Struct->TcpNodeArr) + { + free(pRssp2Struct->TcpNodeArr); + pRssp2Struct->TcpNodeArr = NULL; + pRssp2Struct->LnkNodeNum = 0; + } +} +/*-------------------------------------------------------------------- + * ·ģڲ End + *--------------------------------------------------------------------*/ + + + + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2LnkNodeMgr.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2LnkNodeMgr.h new file mode 100644 index 0000000..77bdcad --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2LnkNodeMgr.h @@ -0,0 +1,103 @@ +/******************************************************** +* +* ļ Rssp2LnkNodeMgr.h +* Ȩ˵ +* 汾 1.0 +* ʱ䣺 +* ؼЭ鲿 +* Rssp2ͨŽڵصĺ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* +* +********************************************************/ + +#ifndef _RSSP2_LNK_NODE_MGR_H_ +#define _RSSP2_LNK_NODE_MGR_H_ + +#include "Rssp2Struct.h" + +#ifdef __cplusplus +extern "C" { +#endif +/*-------------------------------------------------------------------- + * RSSP2ڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : InitRssp2LnkNodeArr + * : ȫͨŽڵгʼ + * + * : + * + * -------------------------------------------------------------- + * Num UINT8 IN ӦָͨŶ + * + * ȫֱ : LnkNodeArr ͨŽڵ + * ֵ : UINT8 1: 0 + ***********************************************************************/ +UINT8 InitRssp2LnkNodeArr(UINT8 Num,RSSP2_INFO_STRU *pRssp2Struct); + +/* TCPڵ */ +TCP_LNK_NODE_STRU * SearchTcpNode(UINT32 LocalEtcsId, UINT32 DestEtcsId, RSSP2_INFO_STRU *pRssp2Struct); + +/* ȡɸǵTCPڵ */ +TCP_LNK_NODE_STRU *GetTcpReplaceNode(RSSP2_INFO_STRU *pRssp2Struct); + +/* ʼTCPڵ */ +UINT8 InitTcpNode(UINT32 LocalEtcsId,UINT32 DestEtcsId,TCP_LNK_NODE_STRU *pTcpNode); + +/* ɾTCPڵ */ +UINT8 RemoveInactiveTcpNode(RSSP2_INFO_STRU *pRssp2Stru); + +UINT8 InitRssp2LnkInfoNode(UINT32 LocaEtcsId, UINT32 DestEtcsId, MASL_ROLE role, LPRSSP2_LNK_INFO_NODE_STRU pRssp2LnkInfoNode); + +/*********************************************************************** +* : SearchRssp2LnkNode +* : PSSPĿĵַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ +* ַ򷵻NULL +* : +* +* -------------------------------------------------------------- +* localCtcsId UINT32 IN Rssp2Դַ +* destCtcsId UINT32 IN Pssp2Ŀĵַ +* pRssp2Struct RSSP2_INFO_STRU* IN RSSP2Э״̬ +* ֵ : RSSP2_LNK_INFO_NODE_STRU* NULL:ָڵ㲻 !=NULL ָڵַ +***********************************************************************/ +RSSP2_LNK_INFO_NODE_STRU* SearchRssp2LnkNode(UINT32 localCtcsId,UINT32 destCtcsId,RSSP2_INFO_STRU *pRssp2Struct); + +/*********************************************************************** + * : GetRssp2ReplaceNode + * : ͨɸǵĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * + * ȫֱ : LnkNodeArr* ȫֱͨŽڵ + * ֵ : RSSP2_LNK_INFO_NODE_STRU* NULL쳣 NULLͨŽڵ + ***********************************************************************/ +RSSP2_LNK_INFO_NODE_STRU* GetRssp2ReplaceNode(RSSP2_INFO_STRU *pRssp2Struct); + +/*********************************************************************** + * : DestoryRssp2LnkNodeArr + * : ͷͨŽڵĿռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : ޡ + ***********************************************************************/ +void DestoryRssp2LnkNodeArr(RSSP2_INFO_STRU *pRssp2Struct); + +UINT8 GetRsspIILnkStatus(UINT8 destType,UINT8 destId, UINT16 logicId, RSSP2_INFO_STRU *pRssp2Struct); + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Struct.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Struct.h new file mode 100644 index 0000000..c744eb9 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/Rssp2Struct.h @@ -0,0 +1,510 @@ +/******************************************************** +* +* ļ Rssp2Struct.h +* Ȩ˵ +* 汾 1.0 +* ʱ䣺 2016.02.17 +* lcj_516 +* Rssp2ЭʹõĽṹ嶨 +* ʹע⣺ +* +* ޸ļ¼ +* +* +********************************************************/ + +#ifndef _RSSP2_STRUCT_H_ +#define _RSSP2_STRUCT_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "CommonStack.h" +#include "CommonMemory.h" +#include "typedefine.h" +#include "Rssp2Configl.h" +#include "dsuRssp2DataStru.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_RECV_PACK_CNT 18 +#define MAX_SEND_PACK_CNT 6 +#define RSSP2_CNT 4 +#define MAX_APP_LEN 1472 + +#define TIMER_SYN 4000 /* 4s */ +#define CNS0_VALUE 100 /* Cns0,ͬһ״̬ */ +#define CDOTD_VALUE 1000 /* ʱ */ +#define SAI_N 0x0A /* Param_N */ +#define EC_ALARM 0x0A /* Param_EC */ +#define EC_PERIOD 500 /* EC */ +#define RSSP2_ALE_VERSION 0x01 /* 豸汾Ϣ */ + +#define SAF 0x01 /*using 3DES */ +#define SAI_VERSION 0x00000001 /*EC startϢʹ */ + +#define KMAC1 { 0xA3, 0x45, 0x34, 0x68, 0x98, 0x01, 0x2A, 0xBF } /* g_ucKMACKey1 */ +#define KMAC2 { 0xCD, 0xBE, 0x34, 0x56, 0x78, 0xBF, 0xEA, 0x32 } /* g_ucKMACKey2 */ +#define KMAC3 { 0x12, 0xAE, 0x34, 0x21, 0x45, 0x78, 0x98, 0x50 } /* g_ucKMACKey3 */ +#define RB { 0x0F, 0x95, 0xEF, 0x4A, 0x66, 0x25, 0xA9, 0x0D } /* 64Rb */ +#define RA { 0x1F, 0xD3, 0xA1, 0xCE, 0x7B, 0x87, 0xE9, 0xB0 } /* 64Ra */ + +#define SAI_HEAD_LEN 19 +#define MASL_HEAD_LEN 9 +#define ALE_HEAD_LEN 10 + +#define MAX_GAL_DATA_LEN 1500 +#define MAX_SAI_DATA_LEN (MAX_GAL_DATA_LEN + SAI_HEAD_LEN) +#define MAX_MASL_DATA_LEN (MAX_SAI_DATA_LEN + MASL_HEAD_LEN) +#define MAX_ALE_DATA_LEN (MAX_MASL_DATA_LEN + ALE_HEAD_LEN) +#define MAX_RSSP2_DATA_LEN MAX_ALE_DATA_LEN + +#define AU1_MASL_LEN 13 +#define AU1_ALE_LEN (AU1_MASL_LEN + 19) + +#define AU2_MASL_LEN 21 +#define AU2_ALE_LEN (AU2_MASL_LEN + 14) + +#define AU3_MASL_LEN 9 +#define AU3_ALE_LEN (AU3_MASL_LEN + 10) + +#define AR_MASL_LEN 9 +#define AR_ALE_LEN (AR_MASL_LEN + 10) + +#define DI_MASL_LEN 3 +#define DI_ALE_LEN (DI_MASL_LEN + 10) + + typedef enum + { + TSRS_RIGHT=1, + TSRS_LEFT + + }TSRS_SEQ; + + typedef enum + { + CF_READ = 1, + CF_WRITE + }CF_INFO_TYPE; + + + + typedef enum + { + SAI_REQACK_NULL = 0, + SAI_REQACK_START = 1, + SAI_REQACK_WAITING_ACK = 2 + }SAI_REQACK_STATE; + + typedef enum + { + SAI_STATE_CONNECTING = 1 , /**< Connection is being connected. */ + SAI_STATE_CONNECTED = 2 , /**< Connection is connected. */ + SAI_STATE_DISCONNECTED = 3 /**< Connection is disconnected. */ + }SAI_STATE; + + typedef enum + { + TCP_STATE_IDLE =0, + TCP_STATE_CONNECTING =1, + TCP_STATE_CONNECTED =2, + TCP_STATE_DISCONNECTING =3, + TCP_STATE_DISCONNECTED =4 + }TCP_STATE; + + typedef enum + { + TCP_CTRL_IDLE =0, + TCP_CTRL_CONNECT =1, + TCP_CTRL_KEEPALIVE =2, + TCP_CTRL_DISCONNECT =3 + }TCP_CTRL; /* Эֻʹ13,02רͨ */ + + typedef enum + { + MASL_STATE_CONNECTING = 1 , /**< Connection is being connected. */ + MASL_STATE_CONNECTED = 2 , /**< Connection is connected. */ + MASL_STATE_DISCONNECTED = 3 /**< Connection is disconnected. */ + }MASL_STATE; + + /* Ϣ subset0377.2.4.1.6 */ + typedef enum + { + MSG_AU1 = 0x01, + MSG_AU2 = 0x02, + MSG_AU3 = 0x03, + MSG_AR = 0x09, + MSG_DT = 0x05, + MSG_DI = 0x08 + }MASL_MSG_TYPE_FLAG; + + /*ʶ */ + typedef enum + { + INITIATOR_TO_RESPONDER = 0, + RESPONDER_TO_INITIATOR = 1 + }MASL_DIRECTION_FLAG; + + /* MASL ״̬ */ + typedef enum + { + MASL_CONNECTION_NONE = 0, + MASL_CONNECTION_WAITING_FOR_AU2 = 1, + MASL_CONNECTION_WAITING_FOR_AU3 = 2, + MASL_CONNECTION_WAITING_FOR_AR = 3 + } MASL_CONNECTING_STATE; + + typedef enum + { + MASL_ROLE_INITIATOR = 0x00, + MASL_ROLE_RESPONDER =0x01 + }MASL_ROLE; + + typedef enum + { + ALE_STATE_DISCONNECT = 0, + ALE_STATE_RECVFIRSTPKT = 1, /**rec AU1 or AU2*/ + ALE_STATE_CONNECTED = 2 /**send recv DT PKT*/ + }ALE_STATE; + + typedef enum + { + CTCS_ID_TYPE_RADIO_IN_FILL = 0x00, /**) */ + QueueStruct OutnetQueueB; /* RSSP2նB(->) */ + UINT32 OutnetQueueSize; /* նгȣЭʼʱд */ + + TCP_LNK_NODE_STRU *TcpNodeArr; /* TCPڵ */ + RSSP2_LNK_INFO_NODE_STRU* LnkNodeArr; /* ͨŽڵ */ + UINT8 LnkNodeNum; /* ͨŽڵ鳤 */ + +#if (RSSP2_LOG_LEVEL>=0) + UINT8 *RecordArray; /* RSSP2¼ */ + UINT16 RecordArraySize; /* RSSP2¼С */ +#endif + + UINT32 LocalEtcsId; /* 豸ͨţRSSP2Эʼʱ add 20160819 xb CR9590:ӶԿߵ֧ */ + + UINT16 NetsRecvPkgNumsLen; /*յ鳤*/ + RsppiiNetsRecvPkgNum* NetsRecvPkgNums; /*յ*/ +} RSSP2_INFO_STRU,*LPRSSP2_INFO_STRU; + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/crc.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/crc.c new file mode 100644 index 0000000..e702c0c --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/crc.c @@ -0,0 +1,70 @@ +/****************************************************************************** +** Ŀƣרпϵͳʱٷ +** ȨϢCopyright (c) 2010-2015Beijing Jiaoda Microunion Tech Co.,LTD. +** ļƣcrc.c 汾ţV0.0.0 +** ˣ ڣ2010.11.23 +** ժҪ +** οף +******************************************************************************* +** ޸ڣ +** ޸ݣ +******************************************************************************/ +#include "crc.h" + +/* CCITT-CRC16: x16+x12+x5+1 */ +/* λǰ */ +WORD crc16_ccitt_tableH[256]={ /*%RELAX*/ /*%RELAX*/ + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, + 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, + 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, + 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, + 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, + 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, + 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, + 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, + 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, + 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, + 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, + 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, + 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, + 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, + 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, + 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, + 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, + 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, + 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, + 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, + 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, + 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, + 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 +}; + + +/* λǰ */ +/* crc[0] = HIBYTE(crc) */ +/* crc[1] = LOBYTE(crc) */ +/******************************************************************************* +** GetCCITTCrcH +** ñ׼CRC-CCITT㷨FCS-16οSubset-098 V1.0.0 6.4.5.1.5 +** pData: ָУ iLen: ԭʼֽڳ +** +** ֵ16λCRC +*******************************************************************************/ +WORD GetCCITTCrcH(WORD crcInit, BYTE *pBuf, DWORD dwLen) /*%RELAX*/ +{ + WORD dwCrc = crcInit; + while(dwLen--) + { + dwCrc = (dwCrc << 8) ^ crc16_ccitt_tableH[((dwCrc >> 8) ^ *pBuf++) & 0xFF]; /*%RELAX*/ /*%RELAX*/ /*%RELAX*/ + } + return( dwCrc & 0xFFFF ); /*%RELAX*/ +} diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/crc.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/crc.h new file mode 100644 index 0000000..b9b1aef --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/crc.h @@ -0,0 +1,25 @@ +/****************************************************************************** +** Ŀƣרпϵͳʱٷ +** ȨϢCopyright (c) 2010-2015Beijing Jiaoda Microunion Tech Co.,LTD. +** ļƣcrc.h 汾ţV0.0.0 +** ˣ ڣ2010.11.23 +** ժҪ +** οף +******************************************************************************* +** ޸ڣ +** ޸ݣ +******************************************************************************/ +#ifndef _CRC_H_ +#define _CRC_H_ + +#include "typeDefine.h" + +#define CCITT_CRC_INIT 0xFFFF +#define CCITT_CRC_MASK 0x1021 /* x^16+x^12+x^5+1 */ +#define ALSTOM_CRC_MASK 0x8810 /* x^16+x^11+x^4+1 */ + +WORD GetCCITTCrcH(WORD crcInit, BYTE *message, DWORD len); + +#endif + + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/des.c b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/des.c new file mode 100644 index 0000000..4735e18 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/des.c @@ -0,0 +1,428 @@ +/****************************************************************************** +** Ŀƣרпϵͳʱٷ +** ȨϢCopyright (c) 2010-2015Beijing Jiaoda Microunion Tech Co.,LTD. +** ļƣdes.c 汾ţV0.0.0 +** ˣ lcj_109 ڣ2010.11.23 +** ժҪ +** οף +******************************************************************************* +** ޸ڣ +** ޸ݣ +******************************************************************************/ +#include "des.h" + +static VOID retaxiskey(DWORD *pkey); +static VOID uch2ul(BYTE * from, DWORD * to); +static VOID ul2uch(DWORD * from, BYTE * to); +static VOID desfunc(DWORD * block, DWORD * subkey); + +/*ԿڲĴÿΪһ鹲16 */ +DWORD ulsubkey[32] = { 0L }; + +/* ֽλʽ */ +const BYTE bytebit[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; + +/* λʽ */ +const DWORD longbit[24] = { + 0x00800000L, 0x00400000L, 0x00200000L, 0x00100000L, 0x00080000L, 0x00040000L, 0x00020000L, 0x00010000L, + 0x00008000L, 0x00004000L, 0x00002000L, 0x00001000L, 0x00000800L, 0x00000400L, 0x00000200L, 0x00000100L, + 0x00000080L, 0x00000040L, 0x00000020L, 0x00000010L, 0x00000008L, 0x00000004L, 0x00000002L, 0x00000001L }; + +/* Կɵı׼PC1PC2ûλ */ +const BYTE PC1_TABLE[56] = { + 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 9, 1, + 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 62, 54, 46, 38, + 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 60, 52, 44, 36, + 28, 20, 12, 4, 27, 19, 11, 3 }; + +const BYTE PC2_TABLE[48] = { + 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, + 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, + 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 }; + +const BYTE LSHIFT_TABLE[16] = { 1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28 }; + +/* SP */ +const DWORD SP1[64] = { + 0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L, 0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L, + 0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L, 0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L, + 0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L, 0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L, + 0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L, 0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L, + 0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L, 0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L, + 0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L, 0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L, + 0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L, 0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L, + 0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L, 0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L }; +const DWORD SP2[64] = { + 0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L, 0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L, + 0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L, 0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L, + 0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L, 0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L, + 0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L, 0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L, + 0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L, 0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L, + 0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L, 0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L, + 0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L, 0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L, + 0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L, 0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L }; +const DWORD SP3[64] = { + 0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L, 0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L, + 0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L, 0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L, + 0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L, 0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L, + 0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L, 0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L, + 0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L, 0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L, + 0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L, 0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L, + 0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L, 0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L, + 0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L, 0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L }; +const DWORD SP4[64] = { + 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, 0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L, + 0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L, 0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L, + 0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L, 0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L, + 0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L, 0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L, + 0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L, 0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L, + 0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L, 0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L, + 0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L, 0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L, + 0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L, 0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L }; +const DWORD SP5[64] = { + 0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L, 0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L, + 0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L, 0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L, + 0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L, 0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L, + 0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L, 0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L, + 0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L, 0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L, + 0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L, 0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L, + 0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L, 0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L, + 0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L, 0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L }; +const DWORD SP6[64] = { + 0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L, 0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L, + 0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L, 0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L, + 0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L, 0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L, + 0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L, 0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L, + 0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L, 0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L, + 0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L, 0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L, + 0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L, 0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L, + 0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L, 0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L }; +const DWORD SP7[64] = { + 0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L, 0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L, + 0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L, 0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L, + 0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L, 0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L, + 0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L, 0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L, + 0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L, 0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L, + 0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L, 0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L, + 0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L, 0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L, + 0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L, 0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L }; +const DWORD SP8[64] = { + 0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L, 0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L, + 0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L, 0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L, + 0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L, 0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L, + 0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L, 0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L, + 0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L, 0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L, + 0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L, 0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L, + 0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L, 0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L, + 0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L, 0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L }; + +/******************************************************************************** +** setsubkey +** ڲԿĴ +** from: 16Կ +** +** ֵ +********************************************************************************/ +VOID setsubkey( DWORD *from ) +{ + DWORD *to = NULL; + DWORD *tail = NULL; + + to = ulsubkey; + tail = &ulsubkey[31]; + + while( to <= tail ) + { + *to++ = *from++; + } +} + +/******************************************************************************** +** savesubkey +** ڲԿĴ +** to: ָ洢16ԿĻ +** +** ֵ +********************************************************************************/ +VOID savesubkey(DWORD *to) +{ + DWORD *from = NULL; + DWORD *tail = NULL; + + from = ulsubkey; + tail = &ulsubkey[31]; + + while( from <= tail ) + { + *to++ = *from++; + } +} + +/******************************************************************************** +** retaxiskey +** 16Կ +** pkey1: 16Կָ +** +** ֵ +********************************************************************************/ +static VOID retaxiskey(DWORD *pkey1) +{ + INT i = 0; /*%RELAX*/ + DWORD *pkey2 = NULL; + DWORD finalkey[32]; + DWORD *pfinalkey = NULL; + + pfinalkey = finalkey; + pkey2 = pkey1 + 1; + for( i = 0; i < 16; i++ ) + { + *pfinalkey = (*pkey1 & 0x00fc0000L) << 6; + *pfinalkey |= (*pkey1 & 0x00000fc0L) << 10; + *pfinalkey |= (*pkey2 & 0x00fc0000L) >> 10; + *pfinalkey |= (*pkey2 & 0x00000fc0L) >> 6; + + pfinalkey ++; + *pfinalkey = (*pkey1 & 0x0003f000L) << 12; + *pfinalkey |= (*pkey1 & 0x0000003fL) << 16; + *pfinalkey |= (*pkey2 & 0x0003f000L) >> 4; + *pfinalkey |= (*pkey2 & 0x0000003fL); + + pkey1 += 2; + pkey2 += 2; + pfinalkey ++; + } + setsubkey(finalkey); +} + +/******************************************************************************** +** buildsubkey +** Կ浽ڲĴ +** key: ָ8ֽڵԭʼԿ +** mode: (ENCRYPT=1)(DECRYPT=0)ģʽ +** +** ֵ +********************************************************************************/ +VOID buildsubkey(BYTE *key, short mode) +{ + INT i, j, m, n; /*%RELAX*/ + DWORD tableitem; + BYTE bitspc1[56], bitsshift[56]; + DWORD keypc2[32] = { 0L }; + + for( i = 0; i < 56; i++ ) + { + tableitem = PC1_TABLE[i]; + bitspc1[i] = (key[tableitem >> 3] & bytebit[tableitem & 0x07]) ? 1 : 0; + } + + if( mode == DECRYPT ) + { + m = 30; + } + else + { + m = 0; + } + for( i = 0; i < 16; i++ ) + { + tableitem = LSHIFT_TABLE[i]; + + for( j = 0; j < 28; j++) + { + if( tableitem < 28 ) + { + bitsshift[j] = bitspc1[tableitem]; + } + else + { + bitsshift[j] = bitspc1[tableitem - 28]; + } + tableitem++; + } + + for( ; j < 56; j++ ) + { + if( tableitem < 56 ) + { + bitsshift[j] = bitspc1[tableitem]; + } + else + { + bitsshift[j] = bitspc1[tableitem - 28]; + } + tableitem++; + } + + n = m + 1; + for( j = 0; j < 24; j++ ) + { + if( bitsshift[PC2_TABLE[j]] ) + { + keypc2[m] |= longbit[j]; + } + if( bitsshift[PC2_TABLE[j+24]] ) + { + keypc2[n] |= longbit[j]; + } + } + + if( mode == DECRYPT ) + { + m -= 2; + } + else + { + m += 2; + } + } + + retaxiskey(keypc2); +} + +/******************************************************************************** +** uch2ul +** 8ַֽתΪ +** from: ת8ֽ +** to: 洢תݵ2 +** ֵ +********************************************************************************/ + +static VOID uch2ul(BYTE * from, DWORD * to) +{ + *to = (DWORD)(*from++) << 24; + *to |= (DWORD)(*from++) << 16; + *to |= (DWORD)(*from++) << 8; + *to |= (DWORD)(*from++); + to ++; + *to = (DWORD)(*from++) << 24; + *to |= (DWORD)(*from++) << 16; + *to |= (DWORD)(*from++) << 8; + *to |= (DWORD)(*from++); +} + +/******************************************************************************** +** ul2uch +** תΪ8ַֽ +** from: ת2 +** to: 洢תݵ8ֽ +** ֵ +********************************************************************************/ +static VOID ul2uch(DWORD * from, BYTE * to) +{ + *to++ = (BYTE)(*from >> 24); + *to++ = (BYTE)(*from >> 16); + *to++ = (BYTE)(*from >> 8); + *to++ = (BYTE)(*from); + from ++; + *to++ = (BYTE)(*from >> 24); + *to++ = (BYTE)(*from >> 16); + *to++ = (BYTE)(*from >> 8); + *to = (BYTE)(*from); +} + +/******************************************************************************** +** block: شݿ +** ֵ +********************************************************************************/ +static VOID desfunc(DWORD * block, DWORD * subkey) +{ + DWORD round; + DWORD left, right; + DWORD midvalue; + DWORD workdata; + + left = block[0]; + right = block[1]; + + workdata = ((left >> 4) ^ right) & 0x0f0f0f0fL; + right ^= workdata; + left ^= (workdata << 4); + workdata = ((left >> 16) ^ right) & 0x0000ffffL; + right ^= workdata; + left ^= (workdata << 16); + workdata = ((right >> 2) ^ left) & 0x33333333L; + left ^= workdata; + right ^= (workdata << 2); + workdata = ((right >> 8) ^ left) & 0x00ff00ffL; + left ^= workdata; + right ^= (workdata << 8); + right = (right << 1) | ((right >> 31) & 1L); + workdata = (left ^ right) & 0xaaaaaaaaL; + left ^= workdata; + right ^= workdata; + left = (left << 1) | ((left >> 31) & 1L); + + for( round = 0; round < 8; round++ ) + { + workdata = (right << 28) | (right >> 4); + + workdata ^= subkey[0]; + subkey ++; + midvalue = SP7[workdata & 0x3fL]; + midvalue |= SP5[(workdata >> 8) & 0x3fL]; + midvalue |= SP3[(workdata >> 16) & 0x3fL]; + midvalue |= SP1[(workdata >> 24) & 0x3fL]; + workdata = right ^ subkey[0]; + subkey ++; + midvalue |= SP8[workdata & 0x3fL]; + midvalue |= SP6[(workdata >> 8) & 0x3fL]; + midvalue |= SP4[(workdata >> 16) & 0x3fL]; + midvalue |= SP2[(workdata >> 24) & 0x3fL]; + left ^= midvalue; + + workdata = (left << 28) | (left >> 4); + workdata ^= subkey[0]; + subkey ++; + midvalue = SP7[workdata & 0x3fL]; + midvalue |= SP5[(workdata >> 8) & 0x3fL]; + midvalue |= SP3[(workdata >> 16) & 0x3fL]; + midvalue |= SP1[(workdata >> 24) & 0x3fL]; + workdata = left ^ subkey[0]; + subkey ++; + midvalue |= SP8[workdata & 0x3fL]; + midvalue |= SP6[(workdata >> 8) & 0x3fL]; + midvalue |= SP4[(workdata >> 16) & 0x3fL]; + midvalue |= SP2[(workdata >> 24) & 0x3fL]; + right ^= midvalue; + } + + right = (right << 31) | (right >> 1); + workdata = (left ^ right) & 0xaaaaaaaaL; + left ^= workdata; + right ^= workdata; + left = (left << 31) | (left >> 1); + workdata = ((left >> 8) ^ right) & 0x00ff00ffL; + right ^= workdata; + left ^= (workdata << 8); + workdata = ((left >> 2) ^ right) & 0x33333333L; + right ^= workdata; + left ^= (workdata << 2); + workdata = ((right >> 16) ^ left) & 0x0000ffffL; + left ^= workdata; + right ^= (workdata << 16); + workdata = ((right >> 4) ^ left) & 0x0f0f0f0fL; + left ^= workdata; + right ^= (workdata << 4); + + block[0] = right; + block[1] = left; +} + +/******************************************************************************** +** fastdes +** ٵDES㷨 +** blockin: 64λ8ֽڣݿ +** blockout: 洢ݵ8ֽݿ +** ֵ +********************************************************************************/ +VOID fastdes(BYTE *blockin, BYTE *blockout) +{ + DWORD workdata[2]; + + uch2ul(blockin, workdata); + desfunc(workdata, ulsubkey); + ul2uch(workdata, blockout); +} + + + diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/des.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/des.h new file mode 100644 index 0000000..2509e3b --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/des.h @@ -0,0 +1,64 @@ +/****************************************************************************** +** Ŀƣרпϵͳʱٷ +** ȨϢCopyright (c) 2010-2015Beijing Jiaoda Microunion Tech Co.,LTD. +** ļƣdes.h 汾ţV0.0.0 +** ˣ lcj_109 ڣ2010.11.23 +** ժҪ +** οף +******************************************************************************* +** ޸ڣ +** ޸ݣ +******************************************************************************/ +#ifndef __DES_H__ +#define __DES_H__ + +#include "typeDefine.h" + +#ifdef __cplusplus +extern "C" { +#endif +/* ӽ */ +enum { DECRYPT = 0, ENCRYPT = 1 }; + +/******************************************************************************** +** buildsubkey +** Կ浽ڲĴ +** key: ָ8ֽڵԭʼԿ +** mode: (ENCRYPT=1)(DECRYPT=0)ģʽ +** +** ֵ +********************************************************************************/ +VOID buildsubkey(BYTE *key, short mode); + +/******************************************************************************** +** setsubkey +** ڲԿĴ +** from: 16Կ +** +** ֵ +********************************************************************************/ +VOID setsubkey(DWORD *from); + +/******************************************************************************** +** savesubkey +** ڲԿĴ +** to: ָ洢16ԿĻ +** +** ֵ +********************************************************************************/ +VOID savesubkey(DWORD *to); + +/******************************************************************************** +** fastdes +** ٵDES㷨 +** blockin: 64λ8ֽڣݿ +** blockout: 洢ݵ8ֽݿ +** ֵ +********************************************************************************/ +VOID fastdes(BYTE *blockin, BYTE *blockout); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/typedefine.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/typedefine.h new file mode 100644 index 0000000..1f5e4f7 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_cbtc/typedefine.h @@ -0,0 +1,131 @@ +/****************************************************************** +** Ŀƣ +** ȨϢ +** ļƣtypeDefine.h 汾ţV0.0.0 +** ˣ ڣ2010.11.23 +** ժҪ +** οף +******************************************************************* +** ޸ڣ +** ޸ݣ +******************************************************************/ + +#ifndef _TYPE_DEFINE_H_ +#define _TYPE_DEFINE_H_ +#include +#define TICKTIME 250 /* Ӧóʱ(ms) */ + + +typedef unsigned char BYTE; /*޷8λ*/ +typedef unsigned char *LPBYTE; /*޷8λָ*/ +typedef unsigned short WORD; +typedef unsigned short *LPWORD; +typedef unsigned long DWORD; +typedef unsigned long *LPDWORD; +typedef int INT; +typedef int *PINT; +typedef unsigned int UINT; +typedef unsigned int *PUINT; +typedef int BOOL; +typedef void *PVOID; +/*typedef char CHAR;*/ +typedef short SHORT; +typedef long LONG; +typedef unsigned short USHORT; +typedef double DOUBLE; + +/* ASSERT */ +#ifndef ASSERT +#ifdef WIN32 +#define ASSERT(a) assert(a) +#else +#define ASSERT(a) +#endif +#endif + +/* VOID */ +#ifndef VOID +#define VOID void +#endif + +/* FALSE */ +#ifndef FALSE +#define FALSE 0 +#endif + +/* TRUE */ +#ifndef TRUE +#define TRUE 1 +#endif + +/* STATUS */ +#ifndef STATUS +#define STATUS int +#endif + +/* OK */ +#ifndef OK +#define OK 0 +#endif + +/* NULL */ +#ifndef NULL +#define NULL 0 +#endif + +/* LOCAL */ +#ifndef LOCAL +#define LOCAL static +#endif + +/* CONST */ +#ifndef CONST +#define CONST const +#endif + +/* MAX */ +#ifndef MAX +#define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +/* MIN */ +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +/* MAKEWORD */ +#ifndef MAKEWORD +#define MAKEWORD(a, b) ((WORD)(((BYTE)(((DWORD)(a)) & 0xff)) | ((WORD)((BYTE)(((DWORD)(b)) & 0xff))) << 8)) +#endif + +/* MAKELONG */ +#ifndef MAKELONG +#define MAKELONG(a, b) ((LONG)(((WORD)(((DWORD)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD)(b)) & 0xffff))) << 16)) +#endif + +/* LOWORD */ +#ifndef LOWORD +#define LOWORD(l) ((WORD)(((DWORD)(l)) & 0xffff)) +#endif + +/* HIWORD */ +#ifndef HIWORD +#define HIWORD(l) ((WORD)((((DWORD)(l)) >> 16) & 0xffff)) +#endif + +/* LOBYTE */ +#ifndef LOBYTE +#define LOBYTE(w) ((BYTE)(((DWORD)(w)) & 0xff)) +#endif + +/* HIBYTE */ +#ifndef HIBYTE +#define HIBYTE(w) ((BYTE)((((DWORD)(w)) >> 8) & 0xff)) +#endif + +/* ABS */ +#ifndef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) +#endif + +#endif /*_TYPE_DEFINE_H_*/ diff --git a/TSCP/src/protocol/rssp2_record_cbtc/rsspii_record_config_cbtc/Rssp2Configl.h b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_record_config_cbtc/Rssp2Configl.h new file mode 100644 index 0000000..7f3d705 --- /dev/null +++ b/TSCP/src/protocol/rssp2_record_cbtc/rsspii_record_config_cbtc/Rssp2Configl.h @@ -0,0 +1,54 @@ +/******************************************************** +* +* ļ Rssp2Config.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 +* +* RSSP2¼ +* ʹע⣺ +* +* ޸ļ¼ +* +********************************************************/ +#ifndef _RSSP2_CONFIG_H_ +#define _RSSP2_CONFIG_H_ + +/* WIN32 demo ģʽ */ +/*#define RSSP2_DEMO */ + +/* ¼뿪 */ +#define RSSP2_RECORD_ERR_ASCII /* ַʽ¼ */ + +#define RSSP2_RECORD_SIMPLIFY_BIN /* ԶƷʽ¼ */ + +#ifdef RSSP2_RECORD_SIMPLIFY_BIN +#undef RSSP2_RECORD_ERR_ASCII /* ֹظ */ +#endif + +#if CBTC_MOTOROLA +#define RSSP2_SIMP_REFRESH /*·ˢ*/ +#endif + +/* ߵԿ */ +/* #define _BUILD_IN_TEST_ */ /* ߵԹ */ + +/* ¼ȼ */ +#define RSSP2_LOG_ERROR (1) +#define RSSP2_LOG_WARN (2) +#define RSSP2_LOG_NOTICE (3) +#define RSSP2_LOG_INFO (5) +#define RSSP2_LOG_CYC (10) + +#define RSSP2_LOG_LEVEL (10) /* ־¼ȼ */ + +/* רм¼붨 */ +#define RSSP2_LOG_CYC_START (0xFF) /* ڿʼ*/ +#define RSSP2_LOG_NODE_RECV_START (0xFE) /* ڵտʼ */ +#define RSSP2_LOG_NODE_SEND_START (0xFD) /* ڵ㷢Ϳʼ */ +#define RSSP2_LOG_RED_RECV_START (0xF1) /* տʼ */ +#define RSSP2_LOG_BLUE_RECV_START (0xF2) /* տʼ */ +#define RSSP2_LOG_SEND_START (0xF3) /* Ϳʼ */ + +#endif + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspDataStru.h b/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspDataStru.h new file mode 100644 index 0000000..acdbf9c --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspDataStru.h @@ -0,0 +1,112 @@ +/******************************************************************************* +* +* ļ dsuRsspDataStru.h +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* RSRЭصdsuѯṹ嶨壬ڲʹ +* ʹע⣺ +* ޸ļ¼ +** 2013.02.15 ɾDSU_RSSP_LNK_INFO_STRUDSU_RSSP_LNK_INFO_STRU_WL +** 2013.02.15 ɾDSU_RSSP_INFO_STRUDSU_RSSP_INFO_STRU_WL +*******************************************************************************/ + +#ifndef _DSU_RSSP_DATA_STRU_H +#define _DSU_RSSP_DATA_STRU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "CommonTypes.h" + +#define DSURSR_MAX_K_NUM_WL 10 /*ɢSINIT RXDADA*/ + + /*RSSPϢ*/ + typedef struct + { + UINT16 Id; /**/ + UINT32 EmitterName; /*ID*/ + UINT32 ReceptorName; /*ԷID*/ + UINT16 ChannelNumber; /*ͨ*/ + UINT32 SID_NUMBER_E; /*SID*/ + UINT32 SINIT_NUMBER; /*SINIT*/ + UINT8 DATANUM; /*汾*/ + UINT32 DATAVER_1_Number; /*DATAVER*/ + UINT16 RsspAddr; /*Դַ*/ + UINT16 BsdAddr; /*ĿĵַBSD*/ + UINT16 SseAddr; /*Ŀĵַ*/ + UINT32 SID_NUMBER_R; /*ԷSID*/ + UINT32 PREC_FIRSTSINIT; /*׸SINIT*/ + UINT32 PREC_SINIT_K[DSURSR_MAX_K_NUM_WL]; /*SINIT*/ + UINT32 POST_RXDADA_K[DSURSR_MAX_K_NUM_WL]; /*RXDADA*/ + }DSU_RSSP_LNK_INFO_STRU_WL; + + /*豸ͨԱ*/ + typedef struct + { + UINT16 EmitterType; /*ͷ*/ + UINT16 ReceptorType; /*շ*/ + UINT8 MaxLost; /*󶪰*/ + UINT8 DLost; /*ղ*/ + UINT8 WSsrOut; /*ȴظSSR*/ + UINT8 AntiDelayCount; /*ͬ-δ*/ + UINT8 TOut; /*ijʱ*/ + UINT8 MsgId; /*ϢID-δ*/ + UINT8 IftVer; /*ӿڰ汾,δ*/ + }DSU_DEVICE_COMM_INFO_STRU_WL; + + /*豸ӦHLHTIDб*/ + typedef struct + { + UINT16 DevId; /*豸ID*/ + UINT32 *HlhtIds; /*hlhtidб*/ + } DSU_DEV_HLHTID; + + /*RSSPIϢ*/ + typedef struct + { + UINT32 LocEmitterName; /*õı豸ΨһID*/ + UINT16 LocRsspiAddr; /*õĶӦ豸ΨһIDRSSPIַ*/ + + UINT16 RsspInfoStruLen; /*RSSPϢ*/ + DSU_RSSP_LNK_INFO_STRU_WL *pRsspLnkInfoStru; /*RSSPϢ*/ + + UINT16 DeviceCommStruLen; /*豸ͨԱ*/ + DSU_DEVICE_COMM_INFO_STRU_WL *pDevCommInfoStru; /*豸ͨԱ*/ + + UINT16 ZcRowNum; /*ZCŶձ*/ + DSU_DEV_HLHTID *ZcHlhtids; /*ZCŶձ*/ + + UINT16 CiRowNum; /*CIŶձ*/ + DSU_DEV_HLHTID *CiHlhtids; /*CIŶձ*/ + + UINT16 AtsRowNum; /*ATSŶձ*/ + DSU_DEV_HLHTID *AtsHlhtids; /*ATSŶձ*/ + + UINT16 VobcRowNum; /*VOBCŶձ*/ + DSU_DEV_HLHTID *VobcHlhtids; /*VOBCŶձ*/ + + UINT16 DsuRowNum; /*DSUŶձ*/ + DSU_DEV_HLHTID *DsuHlhtids; /*DSUŶձ*/ + + UINT16 AomRowNum; /*AOMŶձ*/ + DSU_DEV_HLHTID *AomHlhtids; /*AOMŶձ*/ + + UINT16 TdtRowNum; /*TDTŶձ*/ + DSU_DEV_HLHTID *TdtHlhtids; /*TDTŶձ*/ + + UINT16 AxleRowNum; /*ϵͳŶձ*/ + DSU_DEV_HLHTID* AxleHlhtids; /*ϵͳŶձ*/ + + UINT16 IteRowNum; /*ITEŶձ*/ + DSU_DEV_HLHTID* IteHlhtids; /*ITEŶձ*/ + }DSU_RSSP_INFO_STRU_WL; + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspFunc.c b/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspFunc.c new file mode 100644 index 0000000..7028268 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspFunc.c @@ -0,0 +1,1917 @@ +/******************************************************************************* +* +* ļ dsuRsspFunc.c +* Ȩ˵ʱƼι˾ +* 汾 1.0 +* ʱ䣺2009.11.20 +* ؼЭ鲿 +* RSRЭصdsuѯ +* ʹע⣺ +* ޸ļ¼ +*** 2013.02.15 ɾdsuRsspRGetLnkInfodsuRsspRGetLnkInfoWl +** 2013.02.15 ɾdsuRsspSGetLnkInfodsuRsspSGetLnkInfoWl +** 2013.02.15 dsuInputdevvsOutputDevOutInfoWl +** 2013.02.15 dsuInputdevvsOutputdevInInfoWl +** 2013.02.15 ɾManageRsspData +** 2013.02.15 ɾdsuRsrInitdsuRsspInitWl +** 2013.02.15 dsuRsspRGetAddrWl +** 2013.02.15 dsuRsspRGetName_WL +*******************************************************************************/ + +#include "dsuRsspFunc.h" +#include "CommonMemory.h" +#include "Convert.h" +#include "dfsDataRead.h" +#include "dquDataTypeDefine.h" +#include "RsspConfigWl.h" +#include "RsspCommonWl.h" + +#ifdef RSSP_NO_HLHT +#define DSU_RSSP_LNK_INFO_STRU_SIZE_WL (DSURSR_MAX_K_NUM_WL*8+35) /*RSSPϢռֽ*/ +#else +#define DSU_RSSP_LNK_INFO_STRU_SIZE_WL (DSURSR_MAX_K_NUM_WL*8+39) /*RSSPϢռֽ*/ +#endif + +#define DSU_DEVICE_COMM_INFO_STRU_SIZE_WL 11 /*豸ͨռֽڳ*/ + + +#define IDMAP_TDT_ID (20) /*TDTŶձID*/ +#define IDMAP_AXLE_ID (21) /*ϵͳŶձID*/ +#define IDMAP_ITE_ID (22) /*ITEŶձID*/ + +#define ID_MAP_SIZE 6 /*豸Ŷձռֽڳ*/ +#define VOBC_ID_MAP_SIZE 10 /*豸Ŷձռֽڳ*/ + +#define DEV_HLHTID_NUM_ONE 1 /*豸Ӧhlhtid-1*/ +#define DEV_HLHTID_NUM_TWO 2 /*豸Ӧhlhtid-2*/ + +#define ZC_TYPE 0x1E /*ZC豸*/ +#define CI_TYPE 0x3C /*CI豸*/ +#define ATS_TYPE 0x03 /*ATS豸*/ +#define VOBC_TYPE 0x14 /*VOBC豸*/ +#define DSU_TYPE 0x2B /*DSU豸*/ +#define AOM_TYPE 0x15 /*AOM豸*/ +#define TDT_TYPE 0x2C /*TDT豸*/ +#define AXLE_TYPE 0xA0 /*ϵͳ豸*/ +#define ITE_DEVTYPE (0x2F) /*ITE豸*/ +#define CHANNEL_NUM (2) /*Уͨ*/ +#define COMM_DEV_TYPE_MAX_NUM (15) /*뱾豸ͨŵ豸*/ +#define COMM_DEV_MAX_NUM (256*COMM_DEV_TYPE_MAX_NUM) /*뱾豸ͨŵ豸*/ + +/*FSsheetҳϢ*/ +typedef struct +{ + UINT32 Id; /**/ + UINT32 Len; /**/ + UINT32 StartIdx; /*excelʼַ*/ + UINT32 RowCount; /**/ + UINT8* Data; /*excel*/ +} SheetInfo; + +/*ȫУ*/ +typedef struct +{ + UINT32 DevId; /*豸ID*/ + UINT16 Addr; /*ַ*/ + UINT32 Sid[CHANNEL_NUM]; /*ͨԴID*/ + UINT32 Sinit[CHANNEL_NUM]; /*ͨԴʼ*/ + UINT32 Dataver[CHANNEL_NUM]; /*ͨ汾*/ +} SafeParam; + +static void InitSheet(SheetInfo* sheetInfo, const UINT32 dataLen, UINT8 data[], const UINT32 excelId, const UINT32 sheetId); +static UINT32 PrecSinit(UINT32 sinit, UINT32 sid, UINT8 channel, UINT8 addTimes); +static UINT32 PrecRxdata(UINT32 sinit, UINT32 sid, UINT8 channel, UINT8 addTimes); +static UINT8 CheckInOutParamSheet(const UINT32 inDataLen, UINT8 inData[], const UINT32 outDataLen, UINT8 outData[], SheetInfo* inParamSheet, SheetInfo* outParamSheet); +static void GenerateParamsRow(SafeParam* locSafeParam, SafeParam* oppSafeParam, UINT16* rsspLnkInfosLen, DSU_RSSP_LNK_INFO_STRU_WL rsspLnkInfos[], const UINT16 maxRsspLnkInfosLen); +static UINT8 GetDevSafeParamFromSheet(const UINT32 locHlhtId, SheetInfo* paramSheet, SafeParam* safeParam); +static UINT8 GetDevSafeParam(const UINT32 locHlhtId, SheetInfo* outParamSheet, SheetInfo* inParamSheet, SafeParam* safeParam); +static void GetCommTypes(const UINT16 locTypeId, SheetInfo* commSheet, UINT16* commTypesLen, UINT8 commTypes[], const UINT16 maxCommTypesLen); +static UINT8 GetOppSafeParams(const UINT16 locAddr, const UINT8 oppDevType, SheetInfo* paramSheet, UINT32* oppSafeParamsNum, SafeParam sfeParamsNum[], const UINT32 maxOppSafeParamsNum, SheetInfo* otherParamSheet, DSU_RSSP_INFO_STRU_WL* dsuRsspInfo); +static UINT8 CheckSafeParamOnly(SafeParam* safeParam, SheetInfo* sheetInfo); + +#ifndef RSSP_NO_HLHT +static UINT8 DquInitHlhtId(UINT8 *pFsName, UINT8 sheetId, UINT8 colUseLen, UINT8 hlhtIdNum, UINT16 *pRowNum, DSU_DEV_HLHTID **pDsuDevHlhtids); + +static UINT32 DquGetHlhtId(UINT8 type, UINT8 id, UINT16 logicId, UINT16 rowNum, const DSU_DEV_HLHTID *pDevHlhtids); + +static UINT32 DquGetDevHlhtId(UINT8 devType, UINT8 devId, UINT16 logicId, DSU_RSSP_INFO_STRU_WL *pDsuRssp); + +static UINT8 DquGetDevId(UINT32 hlhtId, UINT16 rowNum, const DSU_DEV_HLHTID *pDevHlhtids, UINT8 hlhtIdNum); +#endif + +/* +*: ʼsheetҳϢ +*: const UINT32 dataLen ݳ +* UINT8 data[] +* const UINT32 excelId excel +* const UINT32 sheetId sheetҳ +*: SheetInfo* sheetInfo sheetҳϢ +*: +*ֵ: +*/ +static void InitSheet(SheetInfo* sheetInfo, const UINT32 dataLen, UINT8 data[], const UINT32 excelId, const UINT32 sheetId) +{ + UINT32 idx = 0u; /*±*/ + UINT32 crcVal = 0u; /*crcֵ*/ + UINT32 crc = 0u; /*crc*/ + UINT32 curLen = 0u; /*ǰ*/ + UINT32 excelCount = 0u; /*excel*/ + UINT32 excelIdx = 0u; /*excel±*/ + UINT32 curExcelId = 0u; /*ǰexcel*/ + UINT32 curExcelPos = 0u; /*ǰexcelλ*/ + UINT32 curExcelStartPos = 0u; /*ǰexcelʼλ*/ + UINT32 sheetCount = 0u; /*sheet*/ + UINT32 sheetIdx = 0u; /*sheet±*/ + UINT32 curSheetId = 0u; /*ǰsheet*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT8 isFind = 0u; /*Ƿҵ*/ + + if ((0u < dataLen) && (NULL != data) && (NULL != sheetInfo)) /**/ + { + if ((idx + 40) <= dataLen) /*DH±*/ + { + /*4ֽCRC*/ + crcVal = LongFromChar(&data[idx]); + idx += 4; + /*4ֽڰ汾*/ + idx += 4; + /*4ֽڳ*/ + curLen = LongFromChar(&data[idx]); + idx += 4; + + if ((curLen == dataLen) && (4 < curLen)) + { + crc = Crc32(&data[4], curLen - 4); + if (crc == crcVal) + { + /*4ֽexcel*/ + excelCount = LongFromChar(&data[idx]); + idx += 4; + /*24ֽԤ*/ + idx += 24; + + for (excelIdx = 0; excelIdx < excelCount; excelIdx++) + { + if ((idx + 24) <= dataLen) /*DI±*/ + { + /*4ֽexcel*/ + curExcelId = LongFromChar(&data[idx]); + idx += 4; + if (curExcelId == excelId) + { + /*4ֽڳ*/ + idx += 4; + /*4ֽexcelλ*/ + curExcelPos = LongFromChar(&data[idx]); + curExcelStartPos = curExcelPos; + idx += 4; + /*12ֽԤ*/ + idx += 12; + + if ((curExcelPos + 40) <= dataLen) /*DH±*/ + { + /*4ֽexcel CRC*/ + crcVal = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + /*4ֽexcel汾*/ + curExcelPos += 4; + /*4ֽexcel*/ + curLen = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + + if (4 < curLen) + { + crc = Crc32(&data[curExcelStartPos + 4], curLen - 4); + if (crc == crcVal) + { + /*4ֽsheet*/ + sheetCount = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + /*24ֽԤ*/ + curExcelPos += 24; + + for (sheetIdx = 0; sheetIdx < sheetCount; sheetIdx++) + { + if ((curExcelPos + 24) <= dataLen) /*DH±*/ + { + /*4ֽsheet*/ + curSheetId = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + if (curSheetId == sheetId) + { + sheetInfo->Id = curSheetId; + /*4ֽڳ*/ + sheetInfo->Len = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + /*4ֽsheetexcelλ*/ + sheetInfo->StartIdx = LongFromChar(&data[curExcelPos]); + curExcelPos += 4; + /*2ֽ*/ + sheetInfo->RowCount = ShortFromChar(&data[curExcelPos]); + curExcelPos += 2; + /*2ֽ*/ + curExcelPos += 2; + /*8ֽԤ*/ + curExcelPos += 8; + + sheetInfo->Data = &data[curExcelStartPos]; + isFind = 1u; + } + else + { + curExcelPos += 20; /*ƫһDI*/ + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + if ((1u == isFind) || (1u == isBreak)) + { + break; + } + } + } + else /*crc*/ + { + isBreak = 1u; + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + } + else /**/ + { + idx += 20; /*ƫһDI*/ + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + if ((1u == isFind) || (1u == isBreak)) + { + break; + } + } + } + } + } + } +} + +/* +*: PrecSinit +*: UINT32 sinit +* UINT32 sid +* UINT8 channel +* UINT8 addTimes +*: +*: +*ֵ: UINT32 PrecSinit +*/ +static UINT32 PrecSinit(UINT32 sinit, UINT32 sid, UINT8 channel, UINT8 addTimes) +{ + if (0 == addTimes) + { + return F_ADD_WL(F_ADD_WL(F_ADD_WL(sinit, channel, sid), channel, 0), channel, 0); + } + else + { + addTimes--; + return F_ADD_WL(PrecSinit(sinit, sid, channel, addTimes), channel, 0); + } +} + +/* +*: PrecRxdata +*: UINT32 sinit ʼ +* UINT32 sid +* UINT8 channel +* UINT8 addTimes +*: +*: +*ֵ: UINT32 PrecRxdata +*/ +static UINT32 PrecRxdata(UINT32 sinit, UINT32 sid, UINT8 channel, UINT8 addTimes) +{ + if (0 == addTimes) + { + return F_ADD_WL(sinit, channel, sid); + } + else + { + addTimes--; + return F_ADD_WL(PrecRxdata(sinit, sid, channel, addTimes), channel, 0); + } +} + +/* +*: +*: const UINT32 inDataLen ݳ +* UINT8 inData[] +* const UINT32 outDataLen ݳ +* UINT8 outData[] +*: SheetInfo* inParamSheet sheetϢ +* SheetInfo* outParamSheet sheetϢ +*: +*ֵ: UINT8 Ƿɹ.0:ɹ,1:ɹ +*/ +static UINT8 CheckInOutParamSheet(const UINT32 inDataLen, UINT8 inData[], const UINT32 outDataLen, UINT8 outData[], SheetInfo* inParamSheet, SheetInfo* outParamSheet) +{ + UINT8 retVal = 0u; /*ֵ*/ + UINT32 inParamRowLen = 0u; /*г*/ + UINT32 inParamRowIdx = 0u; /*±*/ + UINT32 inParamDevId = 0u; /*豸ID*/ + UINT32 inParamSid = 0u; /*SID*/ + UINT32 inParamSinit = 0u; /*SINIT*/ + UINT32 inParamDataver = 0u; /*DATAVER*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT32 outParamRowLen = 0u; /*г*/ + UINT32 outParamRowIdx = 0u; /*±*/ + UINT32 outParamDevId = 0u; /*豸ID*/ + UINT32 outParamSid = 0u; /*SID*/ + UINT32 outParamSinit = 0u; /*SINIT*/ + UINT32 outParamDataver = 0u; /*DATAVER*/ + UINT8 funRtn = 0u; /*-< úֵ*/ + + if ((NULL != outData) && (NULL != outParamSheet)) + { + InitSheet(outParamSheet, outDataLen, outData, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_RSSP_LNK_ID); + + if (0u < inDataLen) /**/ + { + if ((NULL != inData) && (NULL != inParamSheet)) /**/ + { + InitSheet(inParamSheet, inDataLen, inData, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_RSSP_LNK_ID); + if ((0u < inParamSheet->Len) && (0u < inParamSheet->RowCount)) /*-RSSPϢ-*/ + { + if (0u == (inParamSheet->Len % inParamSheet->RowCount)) /**/ + { + inParamRowLen = inParamSheet->Len / inParamSheet->RowCount; + for (inParamRowIdx = 0u; inParamRowIdx < inParamSheet->RowCount; inParamRowIdx++) /*-RSSPϢ*/ + { + inParamDevId = LongFromChar(&inParamSheet->Data[inParamSheet->StartIdx + (inParamRowIdx * inParamRowLen) + 2u]); + inParamSid = LongFromChar(&inParamSheet->Data[inParamSheet->StartIdx + (inParamRowIdx * inParamRowLen) + 12u]); + inParamSinit = LongFromChar(&inParamSheet->Data[inParamSheet->StartIdx + (inParamRowIdx * inParamRowLen) + 16u]); + inParamDataver = LongFromChar(&inParamSheet->Data[inParamSheet->StartIdx + (inParamRowIdx * inParamRowLen) + 21u]); + if ((0u < outParamSheet->Len) && (0u < outParamSheet->RowCount) && (0u == (outParamSheet->Len % outParamSheet->RowCount)))/*-RSSPϢ-*/ + { + outParamRowLen = outParamSheet->Len / outParamSheet->RowCount; + if (outParamRowLen == inParamRowLen) + { + for (outParamRowIdx = 0u; outParamRowIdx < outParamSheet->RowCount; outParamRowIdx++) /*-RSSPϢ*/ + { + outParamDevId = LongFromChar(&outParamSheet->Data[outParamSheet->StartIdx + (outParamRowIdx * outParamRowLen) + 2u]); + outParamSid = LongFromChar(&outParamSheet->Data[outParamSheet->StartIdx + (outParamRowIdx * outParamRowLen) + 12u]); + outParamSinit = LongFromChar(&outParamSheet->Data[outParamSheet->StartIdx + (outParamRowIdx * outParamRowLen) + 16u]); + outParamDataver = LongFromChar(&outParamSheet->Data[outParamSheet->StartIdx + (outParamRowIdx * outParamRowLen) + 21u]); + if ((outParamDevId == inParamDevId) && (outParamSid == inParamSid) && (outParamSinit == inParamSinit) && (outParamDataver == inParamDataver)) /*ͬ*/ + { + isBreak = 1u; /*˳*/ + break; + } + } + } + else /*гȲͬ*/ + { + isBreak = 1u; + } + } + if (1u == isBreak) /*˳*/ + { + break; + } + } + if (0u == isBreak) /*ͬ*/ + { + retVal = 1u; + } + } + } + else /*RSSPϢ */ + { + retVal = 1u; + } + } + } + else /**/ + { + retVal = 1u; + } + } + + return retVal; +} + +/* +*: +*: SafeParam* locSafeParam ȫ +* SafeParam* oppSafeParam Էȫ +* const UINT16 maxRsspLnkInfosLen 鳤 +*: UINT16* rsspLnkInfosLen ǰIJ鳤 +* DSU_RSSP_LNK_INFO_STRU_WL rsspLnkInfos[] +*: +*ֵ: +*/ +static void GenerateParamsRow(SafeParam* locSafeParam, SafeParam* oppSafeParam, UINT16* rsspLnkInfosLen, DSU_RSSP_LNK_INFO_STRU_WL rsspLnkInfos[], const UINT16 maxRsspLnkInfosLen) +{ + UINT32 i = 0u; /*ѭ*/ + UINT8 channelIdx = 0u; /*ͨ±*/ + UINT8 maxLostIdx = 0u; /*󶪰±*/ + + if ((NULL != locSafeParam) && (NULL != oppSafeParam) && (NULL != rsspLnkInfosLen) && (NULL != rsspLnkInfos)) /**/ + { + for (i = 0; i < (*rsspLnkInfosLen); i++) /**/ + { + if ((rsspLnkInfos[i].EmitterName == locSafeParam->DevId) && (rsspLnkInfos[i].ReceptorName == oppSafeParam->DevId)) /*в*/ + { + break; + } + } + if ((i == (*rsspLnkInfosLen)) && ((*rsspLnkInfosLen) < maxRsspLnkInfosLen)) /*δв,*/ + { + for (channelIdx = 0u; channelIdx < CHANNEL_NUM; channelIdx++) /*ͨ*/ + { + rsspLnkInfos[*rsspLnkInfosLen].Id = (UINT16)(*rsspLnkInfosLen + 1); +#ifdef RSSP_NO_HLHT + rsspLnkInfos[*rsspLnkInfosLen].EmitterName = (UINT16)locSafeParam->DevId; + rsspLnkInfos[*rsspLnkInfosLen].ReceptorName = (UINT16)oppSafeParam->DevId; +#else + rsspLnkInfos[*rsspLnkInfosLen].EmitterName = locSafeParam->DevId; + rsspLnkInfos[*rsspLnkInfosLen].ReceptorName = oppSafeParam->DevId; +#endif + + rsspLnkInfos[*rsspLnkInfosLen].ChannelNumber = channelIdx + 1; + rsspLnkInfos[*rsspLnkInfosLen].SID_NUMBER_E = locSafeParam->Sid[channelIdx]; + rsspLnkInfos[*rsspLnkInfosLen].SINIT_NUMBER = locSafeParam->Sinit[channelIdx]; + rsspLnkInfos[*rsspLnkInfosLen].DATANUM = 1; + rsspLnkInfos[*rsspLnkInfosLen].DATAVER_1_Number = locSafeParam->Dataver[channelIdx]; + rsspLnkInfos[*rsspLnkInfosLen].RsspAddr = locSafeParam->Addr; + rsspLnkInfos[*rsspLnkInfosLen].BsdAddr = oppSafeParam->Addr; + rsspLnkInfos[*rsspLnkInfosLen].SseAddr = oppSafeParam->Addr; + rsspLnkInfos[*rsspLnkInfosLen].SID_NUMBER_R = oppSafeParam->Sid[channelIdx]; + rsspLnkInfos[*rsspLnkInfosLen].PREC_FIRSTSINIT = locSafeParam->Sinit[channelIdx] ^ oppSafeParam->Sid[channelIdx] ^ locSafeParam->Dataver[channelIdx]; + + for (maxLostIdx = 0u; maxLostIdx < DSURSR_MAX_K_NUM_WL; maxLostIdx++) + { + /*((SINITr ADD SIDr)^(SINITr ADD SIDr ADD 0 ADD 0 ADD ... 0)) SUB SIDr SUB SIDr*/ + rsspLnkInfos[*rsspLnkInfosLen].PREC_SINIT_K[maxLostIdx] = F_SUB_WL(F_SUB_WL(F_ADD_WL(locSafeParam->Sinit[channelIdx], channelIdx, locSafeParam->Sid[channelIdx]) + ^ PrecSinit(locSafeParam->Sinit[channelIdx], locSafeParam->Sid[channelIdx], channelIdx, maxLostIdx) + , channelIdx + , locSafeParam->Sid[channelIdx]) + , channelIdx + , locSafeParam->Sid[channelIdx]); + } + + for (maxLostIdx = 0; maxLostIdx < DSURSR_MAX_K_NUM_WL; maxLostIdx++) + { + /*expectVal ADD 0*/ + /*SINITr ADD SIDr ADD ... 0 ADD SIDr ADD 0*/ + rsspLnkInfos[*rsspLnkInfosLen].POST_RXDADA_K[maxLostIdx] = F_ADD_WL(F_ADD_WL( + PrecRxdata(locSafeParam->Sinit[channelIdx], locSafeParam->Sid[channelIdx], channelIdx, maxLostIdx), + channelIdx, locSafeParam->Sid[channelIdx]), channelIdx, 0u); + } + + (*rsspLnkInfosLen)++; /**/ + } + } + } +} + +/** + * @brief GetDevSafeParamFromSheet RSSPϢлȡ豸ȫ + * @param locHlhtId ͨID ȡֵΧ:0x00000000-0xFFFFFFFF + * @param paramSheet RSSPϢ ȡֵΧ:οṹSheetInfo + * @param safeParam ȫ ȡֵΧ:οṹSafeParam + * @return 0:ʧ;1:ɹ + */ +static UINT8 GetDevSafeParamFromSheet(const UINT32 locHlhtId, SheetInfo* paramSheet, SafeParam* safeParam) +{ + UINT8 rtnVal = 0u; /*-< úֵΪʧ*/ + UINT32 colLen = 0u; /*ֽڳ*/ + UINT32 curIdx = 0u; /*±*/ + UINT32 devId = 0u; /*豸ID*/ + UINT32 channelIdx = 0u; /*ֵͨλ*/ + UINT32 i = 0u; /*ͨ±*/ + UINT32 paramVal[2][6] = { 0 }; /*ڱȽֵ*/ + + if ((NULL != paramSheet) && (NULL != safeParam) && (0u < paramSheet->Len) && (0u < paramSheet->RowCount) && (0u == paramSheet->Len % paramSheet->RowCount) && (0u == (paramSheet->RowCount % 2u))) /*-< ǷǿұݳǷ00Ϊ2ݳ*/ + { + colLen = paramSheet->Len / paramSheet->RowCount; /*-< г*/ + for (curIdx = 0u; curIdx < paramSheet->RowCount; curIdx += 2) /*-< ǰȽ±ǷС*/ + { +#ifdef RSSP_NO_HLHT + devId = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + (curIdx * colLen) + 2]); /*-< õǰΨһID*/ +#else + devId = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + (curIdx * colLen) + 2]); /*-< õǰΨһID*/ +#endif + if (devId == locHlhtId) /*-< ǰΨһIDǷΪ豸ΨһID*/ + { + for (i = 0u; i < 2u; i++) /*-< ǰͨǷС2*/ + { +#ifdef RSSP_NO_HLHT + paramVal[i][1] = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + 2u]); /*-< õǰΨһID*/ + channelIdx = 6u; /*-< ͨ±*/ +#else + paramVal[i][1] = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + 2u]); /*-< õǰΨһID*/ + channelIdx = 10u; /*-< ͨ±*/ +#endif + + paramVal[i][0] = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx]); /*-< õǰͨ*/ + paramVal[i][2] = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx + 2u]); /*-< õǰSID*/ + paramVal[i][3] = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx + 6u]); /*-< õǰSINIT*/ + paramVal[i][4] = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx + 11u]); /*-< õǰDATAVER*/ + paramVal[i][5] = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx + 15u]); /*-< õǰADDR*/ + } + + if ((1u == paramVal[0][0]) && (2u == paramVal[1][0]) && (paramVal[0][1] == paramVal[1][1]) && (paramVal[0][5] == paramVal[1][5])) /*-< ͨ,ΨһID,ADDRǷȷ*/ + { + safeParam->DevId = paramVal[0][1]; /*-< ΨһID*/ + safeParam->Addr = paramVal[0][5]; /*-< ADDR*/ + for (i = 0u; i < 2u; i++) /*-< ǰͨǷС2*/ + { + safeParam->Sid[i] = paramVal[i][2]; /*-< SID*/ + safeParam->Sinit[i] = paramVal[i][3]; /*-< SINIT*/ + safeParam->Dataver[i] = paramVal[i][4]; /*-< DATAVER*/ + } + rtnVal = 1u; /*-< úֵΪɹ*/ + } + else + { + break; /*-< ˳*/ + } + } + } + } + + return rtnVal; /*-< غֵ*/ +} + +/** + * @brief GetDevSafeParam RSSPϢлȡ豸ȫ + * @param locHlhtId ͨID ȡֵΧ:ȡֵΧ:0x00000000-0xFFFFFFFF + * @param outParamSheet RSSPϢ ȡֵΧ:οṹSheetInfo + * @param inParamSheet RSSPϢ ȡֵΧ:οṹSheetInfo + * @param safeParam ȫ ȡֵΧ:οṹSafeParam + * @return 0:ʧ;1:ɹ + */ +static UINT8 GetDevSafeParam(const UINT32 locHlhtId, SheetInfo* outParamSheet, SheetInfo* inParamSheet, SafeParam* safeParam) +{ + UINT8 rtnVal = 0u; /*-< úֵΪʧ*/ + UINT8 funRtn = 0u; /*-< õúֵΪʧ*/ + + if ((NULL != outParamSheet) && (NULL != inParamSheet) && (NULL != safeParam)) /*-< Ƿǿ*/ + { + funRtn = GetDevSafeParamFromSheet(locHlhtId, outParamSheet, safeParam); /*-< ûȡȫ,ֵúֵ*/ + if (1u != funRtn) /*-< úǷdzɹ*/ + { + funRtn = GetDevSafeParamFromSheet(locHlhtId, inParamSheet, safeParam); /*-< ûȡȫ,ֵúֵ*/ + } + if (1u == funRtn) /*-< úǷɹ*/ + { + funRtn = CheckSafeParamOnly(safeParam, outParamSheet); /*-< ûȡ鰲ȫΨһ,ֵúֵ*/ + if (1u == funRtn) /*-< úǷɹ*/ + { + funRtn = CheckSafeParamOnly(safeParam, inParamSheet); /*-< ûȡ鰲ȫΨһ,ֵúֵ*/ + if (1u == funRtn) /*-< úǷɹ*/ + { + rtnVal = 1u; /*-< úֵΪɹ*/ + } + } + } + } + + return rtnVal; /*-< غֵ*/ +} + +/* +*: ȡͨŵ豸б +*: const UINT16 locTypeId ID +* SheetInfo* commSheet 豸ͨЭ +* UINT16 maxCommTypesLen ͨ豸鳤 +*: UINT16* commTypesLen 豸鳤 +* UINT8 commTypes[] 豸 +*: +*ֵ: +*/ +static void GetCommTypes(const UINT16 locTypeId, SheetInfo* commSheet, UINT16* commTypesLen, UINT8 commTypes[], const UINT16 maxCommTypesLen) +{ + UINT8 locType = 0u; /**/ + UINT32 rowLen = 0u; /*г*/ + UINT32 rowIdx = 0u; /*±*/ + UINT8 locDevType = 0u; /*豸*/ + UINT8 oppDevType = 0u; /*Է豸*/ + UINT8 ptclType = 0u; /*Э*/ + UINT32 i = 0u; /*ѭ*/ + + if ((NULL != commSheet) && (NULL != commTypesLen) && (NULL != commTypes) && (0u < commSheet->Len) && (0u < commSheet->RowCount) && (0u == commSheet->Len % commSheet->RowCount)) /*ⲿ-豸IPַ-*/ + { + locType = (UINT8)((locTypeId >> 8) & 0xFF); + rowLen = commSheet->Len / commSheet->RowCount; + for (rowIdx = 0u; rowIdx < commSheet->RowCount; rowIdx++) /*豸IPַ*/ + { + locDevType = commSheet->Data[commSheet->StartIdx + (rowIdx * rowLen)]; + oppDevType = commSheet->Data[commSheet->StartIdx + (rowIdx * rowLen) + 1]; + ptclType = commSheet->Data[commSheet->StartIdx + (rowIdx * rowLen) + 2]; + if ((locDevType == locType) && (4u == ptclType)) /*DZ豸RSSPI*/ + { + for (i = 0; i < (*commTypesLen); i++) + { + if (commTypes[i] == oppDevType) + { + break; + } + } + if ((i == (*commTypesLen)) && ((*commTypesLen) < maxCommTypesLen)) /*ظ,*/ + { + commTypes[*commTypesLen] = oppDevType; + (*commTypesLen)++; + } + } + } + } +} + +/** + * @brief GetOppSafeParams ȡͨŵĶԷ豸ȫб + * @param locAddr Эַ ȡֵΧ:0x0000-0xFFFF + * @param oppDevType Է豸 ȡֵΧ:0x00-0xFF + * @param paramSheet ڲҵRSSPϢ ȡֵΧ:οṹSheetInfo + * @param oppSafeParamsNum Է豸ȫб ȡֵΧ:0x00000000-0xFFFFFFFF + * @param sfeParamsNum Է豸ȫб ȡֵΧ:SafeParam + * @param maxOppSafeParamsNum Է豸ȫб ȡֵΧ:0x00000000-0xFFFFFFFF + * @param otherParamSheet ڲҵRSSPϢ ȡֵΧ:οṹSheetInfo + * @param dsuRsspInfo Эõݱ ȡֵΧ:οṹDSU_RSSP_INFO_STRU_WL + * @return 0:ʧ;1:ɹ + */ +static UINT8 GetOppSafeParams(const UINT16 locAddr, const UINT8 oppDevType, SheetInfo* paramSheet, UINT32* oppSafeParamsNum, SafeParam sfeParamsNum[], const UINT32 maxOppSafeParamsNum, SheetInfo* otherParamSheet, DSU_RSSP_INFO_STRU_WL* dsuRsspInfo) +{ + UINT8 rtnVal = 0u; /*-< úֵΪʧ*/ + UINT32 colLen = 0u; /*ֽڳ*/ + UINT32 curIdx = 0u; /*ǰ±*/ + UINT32 hlhtId = 0u; /*ΨһͨID*/ + UINT16 devTypeId = 0u; /*豸ID*/ + UINT32 i = 0u; /*ѭ*/ + UINT32 channelIdx = 0u; /*ֵͨλ*/ + UINT16 curAddr = 0u; /*ǰADDR*/ + UINT32 curCmpVal[2][6] = { 0 }; /*ǰڱȽֵ*/ + UINT8 funRtn = 0u; /*õúֵΪʧ*/ + UINT8 isErr = 0u; /*Ƿд*/ + + if ((NULL != paramSheet) && (NULL != oppSafeParamsNum) && (NULL != sfeParamsNum) && (NULL != otherParamSheet) && (NULL != dsuRsspInfo)) /*-< Ƿǿ*/ + { + if ((0u < paramSheet->Len) && (0u < paramSheet->RowCount)) /*-< Ƿ*/ + { + if (0u == paramSheet->Len % paramSheet->RowCount) /*-< ݳǷ*/ + { + colLen = paramSheet->Len / paramSheet->RowCount; /*-< г*/ + for (curIdx = 0u; curIdx < paramSheet->RowCount; curIdx += 2) /*-< ǰ±ǷС*/ + { +#ifdef RSSP_NO_HLHT + hlhtId = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + (curIdx * colLen) + 2]); /*-< õǰΨһID*/ + devTypeId = (UINT16)hlhtId; + channelIdx = 6u; /*-< ͨ±*/ +#else + hlhtId = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + (curIdx * colLen) + 2]); /*-< õǰΨһID*/ + devTypeId = DquToDevTypeId(hlhtId, dsuRsspInfo); /*-< ȡ豸ID*/ + channelIdx = 10u; /*-< ͨ±*/ +#endif + curAddr = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + (curIdx * colLen) + channelIdx + 19u]); /*-< õǰADDR*/ + if (((UINT8)((devTypeId >> 8) & 0xFF) == oppDevType) && ((curAddr == locAddr) || (0u == curAddr))) /*-< ǷĿ豸 ҵǰADDRΪADDRΪ0*/ + { + for (i = 0u; i < 2u; i++) /*-< ǰͨǷС2*/ + { + curCmpVal[i][0] = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx]); /*-< õǰͨ*/ + +#ifdef RSSP_NO_HLHT + curCmpVal[i][1] = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + 2]); /*-< õǰΨһID*/ +#else + curCmpVal[i][1] = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + 2]); /*-< õǰΨһID*/ +#endif + + curCmpVal[i][2] = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx + 2u]); /*-< õǰSID*/ + curCmpVal[i][3] = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx + 6u]); /*-< õǰSINIT*/ + curCmpVal[i][4] = LongFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx + 11u]); /*-< õǰDATAVER*/ + curCmpVal[i][5] = ShortFromChar(¶mSheet->Data[paramSheet->StartIdx + ((curIdx + i) * colLen) + channelIdx + 15u]); /*-< õǰADDR*/ + } + + if ((1u == curCmpVal[0][0]) && (2u == curCmpVal[1][0]) && (curCmpVal[0][1] == curCmpVal[1][1]) && (curCmpVal[0][5] == curCmpVal[1][5])) /*-< ǰͨǷȷ*/ + { + for (i = 0; i < (*oppSafeParamsNum); i++) /*-< ǰԷȫ±ǷСڲ*/ + { + if (sfeParamsNum[i].DevId == hlhtId) /*-< ȫбǷд˲*/ + { + break; /*-< ˳*/ + } + } + if (i == (*oppSafeParamsNum)) /*-< Ƿ޴˲*/ + { + if ((*oppSafeParamsNum) < maxOppSafeParamsNum) /*-< ǷӰȫ*/ + { + sfeParamsNum[*oppSafeParamsNum].DevId = hlhtId; /*-< ΨһID*/ + sfeParamsNum[*oppSafeParamsNum].Addr = curCmpVal[0][5]; /*-< ADDR*/ + for (i = 0u; i < 2u; i++) /*-< ǰͨǷС2*/ + { + sfeParamsNum[*oppSafeParamsNum].Sid[i] = curCmpVal[i][2]; /*-< SID*/ + sfeParamsNum[*oppSafeParamsNum].Sinit[i] = curCmpVal[i][3]; /*-< SINIT*/ + sfeParamsNum[*oppSafeParamsNum].Dataver[i] = curCmpVal[i][4]; /*-< DATAVER*/ + } + + funRtn = CheckSafeParamOnly(&sfeParamsNum[*oppSafeParamsNum], paramSheet); /*-< ûȡ鰲ȫΨһ,ֵúֵ*/ + if (1u == funRtn) /*-< úǷɹ*/ + { + funRtn = CheckSafeParamOnly(&sfeParamsNum[*oppSafeParamsNum], otherParamSheet); /*-< ûȡ鰲ȫΨһ,ֵúֵ*/ + if (1u != funRtn) /*-< úǷdzɹ*/ + { + isErr = 1u; /*-< д*/ + } + } + else + { + isErr = 1u; /*-< д*/ + } + + (*oppSafeParamsNum)++; /*-< ԷȫԼ1*/ + } + else + { + isErr = 1u; /*-< д*/ + } + } + } + else + { + isErr = 1u; /*-< д*/ + } + } + + if (1u == isErr) /*-< Ƿд*/ + { + break; /*-< ˳*/ + } + } + if (0u == isErr) /*-< Ƿ޴*/ + { + rtnVal = 1u; /*-< úֵΪɹ*/ + } + } + } + else + { + rtnVal = 1u; /*-< úֵΪɹ*/ + } + } + + return rtnVal; /*-< غֵ*/ +} + +/** + * @brief DsuRsspInitWl RSSPIЭѯʼ,ֻڳʼʱʹ + * @param pFsName FSļ ȡֵΧ:ļַ + * @param inDataLen FSݳ ȡֵΧ:0x00000000-0xFFFFFFFF + * @param inData FS ȡֵΧ:ֽ + * @param localTypeId ID ȡֵΧ:0x0000-0xFFFF + * @param localLogicId ߼ID ȡֵΧ:0x0000-0xFFFF + * @param pDsuRsspInfo Эõݱ ȡֵΧ:οṹDSU_RSSP_INFO_STRU_WL + * @return 0:ʧ;1:ɹ + */ +UINT8 DsuRsspInitWl(UINT8* pFsName, UINT32 inDataLen, UINT8 inData[], UINT16 localTypeId, UINT16 localLogicId, DSU_RSSP_INFO_STRU_WL* pDsuRsspInfo) +{ + UINT8 rtn = 0; /*-< úֵΪʧ*/ + UINT8 readRtn = 0; /*ȡFSֵ*/ + UINT8* pData = NULL; /**/ + UINT32 dataLen = 0; /*ݳ*/ + UINT16 rsspILinkLen = 0; /*- 뱾豸ͨŵЭͨŹϵ*/ + UINT32 mallocLen = 0; /*ռС*/ + UINT32 offset = 0; /*ƫ*/ + UINT32 i = 0; /*ѭ*/ + UINT32 j = 0; /*ѭ*/ + UINT32 localId = 0; /*ΨһID*/ + UINT32 locId = 0; /*õıΨһID*/ + UINT32 oppId = 0; /*õĶԷΨһID*/ + + SheetInfo inParamSheet = { 0 }; + SheetInfo outParamSheet = { 0 }; + UINT8 paramCheckRtn = 0u; + SafeParam locSafeParam = { 0 }; + + + UINT32 oppSafeParamsNum = 0u; /*ͨŵİȫ*/ + SafeParam* oppSafeParams = NULL; /*ͨŵİȫ*/ + SheetInfo outCommSheet = { 0 }; /*豸ͨЭ*/ + SheetInfo inCommSheet = { 0 }; /*豸ͨЭ*/ + UINT16 commTypesLen = 0u; /*ͨŵ豸鳤*/ + UINT8 commTypes[COMM_DEV_TYPE_MAX_NUM] = { 0 }; /*ͨŵ豸*/ + UINT16 curLnkInfosLen = 0u; /*ǰ·*/ + UINT8 funRtn = 0u; /*úֵ*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + + SheetInfo configSheet = { 0 }; /*豸ͨsheetҳ*/ + UINT32 rowLen = 0u; /*г*/ + UINT8 hasSame = 0u; /*ͬ*/ + UINT16 inLocDevType = 0u; /*ڲ豸*/ + UINT16 inOppDevType = 0u; /*ڲԷ豸*/ + UINT16 rowCount = 0u; /**/ + + if (NULL != pDsuRsspInfo) /*-< Ƿǿ*/ + { +#ifdef RSSP_NO_HLHT + localId = localTypeId; /*-< ñΨһID*/ +#else + /*ȡZCŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_ZC_ID, ID_MAP_SIZE, DEV_HLHTID_NUM_ONE, &pDsuRsspInfo->ZcRowNum, &pDsuRsspInfo->ZcHlhtids); /*-< óʼŶձZC*/ + if (1 == readRtn) /*-< úǷɹ*/ + { + /*ȡCIŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_CI_ID, ID_MAP_SIZE, DEV_HLHTID_NUM_ONE, &pDsuRsspInfo->CiRowNum, &pDsuRsspInfo->CiHlhtids); /*-< óʼŶձCI*/ + if (1 == readRtn) /*-< úǷɹ*/ + { + /*ȡATSŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_ATS_ID, ID_MAP_SIZE, DEV_HLHTID_NUM_ONE, &pDsuRsspInfo->AtsRowNum, &pDsuRsspInfo->AtsHlhtids); /*-< óʼŶձATS*/ + if (1 == readRtn) /*-< úǷɹ*/ + { + /*ȡVOBCŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_VOBC_ID, VOBC_ID_MAP_SIZE, DEV_HLHTID_NUM_TWO, &pDsuRsspInfo->VobcRowNum, &pDsuRsspInfo->VobcHlhtids); /*-< óʼŶձVOBC*/ + if (1 == readRtn) /*-< úǷɹ*/ + { + /*ȡDSUŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_DSU_ID, ID_MAP_SIZE, DEV_HLHTID_NUM_ONE, &pDsuRsspInfo->DsuRowNum, &pDsuRsspInfo->DsuHlhtids); /*-< óʼŶձDSU*/ + if (1 == readRtn) /*-< úǷɹ*/ + { + /*ȡAOMŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_AOMSEC_ID, VOBC_ID_MAP_SIZE, DEV_HLHTID_NUM_TWO, &pDsuRsspInfo->AomRowNum, &pDsuRsspInfo->AomHlhtids); /*-< óʼŶձAOM*/ + if (1 == readRtn) /*-< úǷɹ*/ + { + /*ȡTDTŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_TDT_ID, ID_MAP_SIZE, DEV_HLHTID_NUM_ONE, &pDsuRsspInfo->TdtRowNum, &pDsuRsspInfo->TdtHlhtids); /*-< óʼŶձTDT*/ + if (1 == readRtn) /*-< úǷɹ*/ + { + /*ȡϵͳŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_AXLE_ID, VOBC_ID_MAP_SIZE, DEV_HLHTID_NUM_TWO, &pDsuRsspInfo->AxleRowNum, &pDsuRsspInfo->AxleHlhtids); /*-< óʼŶձļϵͳ*/ + if (1 == readRtn) /*-< úǷɹ*/ + { + /*ȡITEŶձ*/ + readRtn = DquInitHlhtId(pFsName, IDMAP_ITE_ID, VOBC_ID_MAP_SIZE, DEV_HLHTID_NUM_TWO, &pDsuRsspInfo->IteRowNum, &pDsuRsspInfo->IteHlhtids); /*-< óʼŶձITE*/ + } + } + } + } + } + } + } + } + localId = DquTypeIdToHlhtId(localTypeId, localLogicId, pDsuRsspInfo); /*-< ñΨһID*/ +#endif + paramCheckRtn = CheckInOutParamSheet(inDataLen, inData, g_DataBufLen, g_pDataBuf, &inParamSheet, &outParamSheet); /*-< ü*/ + if (1u == paramCheckRtn) /*-< úֵΪɹ*/ + { + mallocLen = sizeof(SafeParam) * COMM_DEV_MAX_NUM; /*-< ͨŵİȫС*/ + oppSafeParams = (SafeParam*)malloc(mallocLen); /*-< ͨŵİȫ*/ + if (NULL != oppSafeParams) /*-< ͨŵİȫǷɹ*/ + { + CommonMemSet(oppSafeParams, mallocLen, 0, mallocLen); /*-< ͨŵİȫ*/ + + funRtn = GetDevSafeParam(localId, &outParamSheet, &inParamSheet, &locSafeParam); /*-< ûȡȫ,ֵúֵ*/ + if (1u == funRtn) /*-< úǷɹ*/ + { + InitSheet(&outCommSheet, g_DataBufLen, g_pDataBuf, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_COMM_PROTCL_ID); /*-< ʼ豸ͨЭ*/ + InitSheet(&inCommSheet, inDataLen, inData, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_COMM_PROTCL_ID); /*-< ʼ豸ͨЭ*/ + GetCommTypes(localTypeId, &outCommSheet, &commTypesLen, commTypes, COMM_DEV_TYPE_MAX_NUM); /*-< 豸ͨЭлȡͨ豸*/ + GetCommTypes(localTypeId, &inCommSheet, &commTypesLen, commTypes, COMM_DEV_TYPE_MAX_NUM); /*-< 豸ͨЭлȡͨ豸*/ + if (0u < commTypesLen) /*-< Ƿͨ豸*/ + { + for (i = 0u; i < commTypesLen; i++) /*-< ͨ豸±ǷСͨ豸*/ + { + funRtn = GetOppSafeParams(locSafeParam.Addr, commTypes[i], &outParamSheet, &oppSafeParamsNum, oppSafeParams, COMM_DEV_MAX_NUM, &inParamSheet, pDsuRsspInfo); /*-< ûȡԷȫ,ֵúֵ*/ + if (1 == funRtn) /*-< úǷɹ*/ + { + funRtn = GetOppSafeParams(locSafeParam.Addr, commTypes[i], &inParamSheet, &oppSafeParamsNum, oppSafeParams, COMM_DEV_MAX_NUM, &outParamSheet, pDsuRsspInfo); /*-< ûȡԷȫ,ֵúֵ*/ + if (0 == funRtn) /*-< úǷʧ*/ + { + isBreak = 1u; /*-< ˳־Ϊ˳*/ + } + } + else + { + isBreak = 1u; /*-< ˳־Ϊ˳*/ + } + if (1u == isBreak) /*-< ˳־ǷΪ˳*/ + { + break; /*-< ˳*/ + } + } + + if ((1u == funRtn) && (0 < oppSafeParamsNum)) /*-< úǷɹ ͨŰȫ*/ + { + pDsuRsspInfo->RsspInfoStruLen = 4u * oppSafeParamsNum; /*-< RSSPϢ,һԷ豸Ҫ4*/ + mallocLen = sizeof(DSU_RSSP_LNK_INFO_STRU_WL) * pDsuRsspInfo->RsspInfoStruLen; /*-< SSPϢС*/ + pDsuRsspInfo->pRsspLnkInfoStru = (DSU_RSSP_LNK_INFO_STRU_WL*)malloc(mallocLen); /*-< RSSPϢ*/ + if (NULL != pDsuRsspInfo->pRsspLnkInfoStru) /*-< RSSPϢǷɹ*/ + { + CommonMemSet(pDsuRsspInfo->pRsspLnkInfoStru, mallocLen, 0, mallocLen); /*-< RSSPϢ*/ + + for (i = 0u; i < oppSafeParamsNum; i++) /*-< ǰͨŰȫ±ǷСͨŰȫ*/ + { + GenerateParamsRow(&locSafeParam, &oppSafeParams[i], &curLnkInfosLen, pDsuRsspInfo->pRsspLnkInfoStru, pDsuRsspInfo->RsspInfoStruLen); /*-< òк,ԷͨŲ*/ + GenerateParamsRow(&oppSafeParams[i], &locSafeParam, &curLnkInfosLen, pDsuRsspInfo->pRsspLnkInfoStru, pDsuRsspInfo->RsspInfoStruLen); /*-< òк,ԷͨŲ*/ + } + free(oppSafeParams); /*-< ͷŶ̬ͨŰȫб*/ + oppSafeParams = NULL; /*-< ͨŰȫбΪ*/ + oppSafeParamsNum = 0u; /*-< ͨŰȫбΪ0*/ + + InitSheet(&configSheet, inDataLen, inData, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_COMM_INFO_ID); /*-< ʼFS豸ͨԱ*/ + /*ȡ豸ͨԱ*/ + readRtn = dquGetConfigData((CHAR*)pFsName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_COMM_INFO_ID, &pData, &dataLen); /*-< úȡFS豸ͨԱ*/ + if ((1 == readRtn) && (DSU_DEVICE_COMM_INFO_STRU_SIZE_WL <= dataLen)) /*-< úǷɹ*/ + { + pDsuRsspInfo->DeviceCommStruLen = (UINT16)(dataLen / DSU_DEVICE_COMM_INFO_STRU_SIZE_WL); /*-< ñݵĸ*/ + mallocLen = sizeof(DSU_DEVICE_COMM_INFO_STRU_WL) * (pDsuRsspInfo->DeviceCommStruLen + configSheet.RowCount); /*-< ÷ռС*/ + pDsuRsspInfo->pDevCommInfoStru = (DSU_DEVICE_COMM_INFO_STRU_WL*)malloc(mallocLen); /*-< 豸ͨԱռ*/ + if (NULL != pDsuRsspInfo->pDevCommInfoStru) /*-< 豸ͨԱǷɹ*/ + { + CommonMemSet(pDsuRsspInfo->pDevCommInfoStru, mallocLen, 0, mallocLen); /*-< 豸ͨԱ*/ + + offset = 0; /*-< ±Ϊ0*/ + for (i = 0; i < pDsuRsspInfo->DeviceCommStruLen; i++) + { + /*2ֽڱ*/ + pDsuRsspInfo->pDevCommInfoStru[i].EmitterType = ShortFromChar(&pData[offset]); /*-< ñ*/ + offset += 2; /*-< ±2*/ + /*2ֽڶԷ*/ + pDsuRsspInfo->pDevCommInfoStru[i].ReceptorType = ShortFromChar(&pData[offset]); /*-< öԷ*/ + offset += 2; /*-< ±2*/ + /*1ֽ󶪰*/ + pDsuRsspInfo->pDevCommInfoStru[i].MaxLost = pData[offset]; /*-< 󶪰*/ + offset++; /*-< ±1*/ + /*1ֽղ*/ + pDsuRsspInfo->pDevCommInfoStru[i].DLost = pData[offset]; /*-< ղ*/ + offset++; /*-< ±1*/ + /*1ֽڵȴظSSR*/ + pDsuRsspInfo->pDevCommInfoStru[i].WSsrOut = pData[offset]; /*-< õȴظSSR*/ + offset++; /*-< ±1*/ + /*1ֽڶͬ*/ + pDsuRsspInfo->pDevCommInfoStru[i].AntiDelayCount = pData[offset]; /*-< öͬ*/ + offset++; /*-< ±1*/ + /*1ֽڱijʱ*/ + pDsuRsspInfo->pDevCommInfoStru[i].TOut = pData[offset]; /*-< ñijʱ*/ + offset++; /*-< ±1*/ + + if ((UINT8_MAX != pDsuRsspInfo->pDevCommInfoStru[i].MaxLost) + && (UINT8_MAX != pDsuRsspInfo->pDevCommInfoStru[i].DLost) + && (UINT8_MAX != pDsuRsspInfo->pDevCommInfoStru[i].WSsrOut) + && (UINT8_MAX != pDsuRsspInfo->pDevCommInfoStru[i].AntiDelayCount) + && (UINT8_MAX != pDsuRsspInfo->pDevCommInfoStru[i].TOut)) /*-< 󶪰,Ч,SSR,ʱʱУ,ʱǷ񶼷0xFF(ֹUINT8ֵȽϴС)*/ + { + /*1ֽϢID*/ + pDsuRsspInfo->pDevCommInfoStru[i].MsgId = pData[offset]; /*-< ϢID*/ + offset++; /*-< ±1*/ + /*1ֽڽӿڰ汾*/ + pDsuRsspInfo->pDevCommInfoStru[i].IftVer = pData[offset]; /*-< ýӿڰ汾*/ + offset++; /*-< ±1*/ + } + else + { + break; /*-< ˳*/ + } + } + if (offset == dataLen) /*-< 豸ͨԱֵǷɹ*/ + { + if ((0u < configSheet.Len) && (0 == configSheet.Len % configSheet.RowCount)) /*-< FS豸ͨԱֵǷɹ*/ + { + rowLen = configSheet.Len / configSheet.RowCount; /*-< FS豸ͨԱг*/ + if (DSU_DEVICE_COMM_INFO_STRU_SIZE_WL == rowLen) /*-< FS豸ͨԱгǷȷ*/ + { + rowCount = pDsuRsspInfo->DeviceCommStruLen; /*-< õǰ*/ + for (i = 0; i < configSheet.RowCount; i++) /*-< ǰ±ǷС*/ + { + hasSame = 0u; /*-< ظ־Ϊ0*/ + inLocDevType = ShortFromChar(&configSheet.Data[configSheet.StartIdx + (i * rowLen)]); /*-< */ + inOppDevType = ShortFromChar(&configSheet.Data[configSheet.StartIdx + (i * rowLen) + 2]); /*-< Է*/ + for (j = 0; j < pDsuRsspInfo->DeviceCommStruLen; j++) /*-< ǰǷСڱ*/ + { + if ((inLocDevType == pDsuRsspInfo->pDevCommInfoStru[j].EmitterType) && (inOppDevType == pDsuRsspInfo->pDevCommInfoStru[j].ReceptorType)) /*-< ԷǷͬ*/ + { + hasSame = 1u; /*-< ظ־Ϊ1*/ + } + } + if (0u == hasSame) /*-< ظ־ǷΪ0*/ + { + pDsuRsspInfo->pDevCommInfoStru[rowCount].EmitterType = inLocDevType; /*-< ñ*/ + pDsuRsspInfo->pDevCommInfoStru[rowCount].ReceptorType = inOppDevType; /*-< öԷ*/ + pDsuRsspInfo->pDevCommInfoStru[rowCount].MaxLost = configSheet.Data[configSheet.StartIdx + (i * rowLen) + 4]; /*-< 󶪰*/ + pDsuRsspInfo->pDevCommInfoStru[rowCount].DLost = configSheet.Data[configSheet.StartIdx + (i * rowLen) + 5]; /*-< ղ*/ + pDsuRsspInfo->pDevCommInfoStru[rowCount].WSsrOut = configSheet.Data[configSheet.StartIdx + (i * rowLen) + 6]; /*-< õȴظSSR*/ + pDsuRsspInfo->pDevCommInfoStru[rowCount].AntiDelayCount = configSheet.Data[configSheet.StartIdx + (i * rowLen) + 7]; /*-< öͬ*/ + pDsuRsspInfo->pDevCommInfoStru[rowCount].TOut = configSheet.Data[configSheet.StartIdx + (i * rowLen) + 8]; /*-< ñijʱ*/ + pDsuRsspInfo->pDevCommInfoStru[rowCount].MsgId = configSheet.Data[configSheet.StartIdx + (i * rowLen) + 9]; /*-< ϢID*/ + pDsuRsspInfo->pDevCommInfoStru[rowCount].IftVer = configSheet.Data[configSheet.StartIdx + (i * rowLen) + 10]; /*-< ýӿڰ汾*/ + + rowCount++; /*-< 1*/ + } + } + pDsuRsspInfo->DeviceCommStruLen = rowCount; /*-< */ + } + } + + for (i = 0; i < pDsuRsspInfo->RsspInfoStruLen; i++) /*-< ǰ±ǷС*/ + { + if (pDsuRsspInfo->pRsspLnkInfoStru[i].EmitterName == localId) /*-< ΨһIDǷΪΨһID*/ + { + pDsuRsspInfo->LocEmitterName = pDsuRsspInfo->pRsspLnkInfoStru[i].EmitterName; /*-< ñΨһID*/ + pDsuRsspInfo->LocRsspiAddr = pDsuRsspInfo->pRsspLnkInfoStru[i].RsspAddr; /*-< ñЭַ*/ + break; /*-< ˳*/ + } + } + + rtn = 1; /*-< úֵΪɹ*/ + } + } + } + } + } + + } + } + } + } + } + + return rtn; /*-< غֵ*/ +} + +/* +*: dsuSetCommInfo_WL +*: ݱԷ豸Ϊշʱò +*: UINT8 localType +* UINT8 DestType Է +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: DSU_RSSP_LINK_RINFO_STRU_WL *pRsspLnkRInfo շʱò +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 dsuSetCommInfo_WL(DSU_RSSP_LINK_RINFO_STRU_WL *pRsspLnkRInfo,UINT8 localType, UINT8 DestType, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL) +{ + UINT16 i;/*ѭ*/ + DSU_DEVICE_COMM_INFO_STRU_WL* pTempDevCommInfoStru; + UINT8 chReturnValue; + UINT16 offset = 0U; + pTempDevCommInfoStru=pDsuRsrInfoStru_WL->pDevCommInfoStru; + for (i=0;iDeviceCommStruLen;i++) + { + if ((localType==pTempDevCommInfoStru[offset].EmitterType) + &&(DestType== pTempDevCommInfoStru[offset].ReceptorType)) + { + /*SSTyҵڵ*/ + pRsspLnkRInfo->MaxLost= pTempDevCommInfoStru[offset].MaxLost; + pRsspLnkRInfo->DLost= pTempDevCommInfoStru[offset].DLost; + pRsspLnkRInfo->WSsrOut= pTempDevCommInfoStru[offset].WSsrOut; + pRsspLnkRInfo->AntiDelayCount= pTempDevCommInfoStru[offset].AntiDelayCount; + pRsspLnkRInfo->TOut= pTempDevCommInfoStru[offset].TOut; + + chReturnValue=1; + return chReturnValue; + } + else + { + /*вҪҵݣ*/ + } + offset++; + } + + /*δҵӦͨŹϵݣϵϷ*/ + chReturnValue=0; + return chReturnValue; +} + +/* +*: dsuRsspGetDevTypeWl +*: ȡ豸 +*: UINT16 DevName 豸 +*: +*: +*ֵ: 豸 +*/ +UINT8 dsuRsspGetDevTypeWl(UINT16 DevName) +{ + UINT8 devType; + devType = (UINT8)(DevName >> 8); + + return devType; +} + +/* +*: dsuRsspRGetLnkInfoWl +*: ڲѯRSSP·ϢսڵϢӳ +*: UINT16 RsspAddr Rsspַ +* UINT16 SrcAddr Srcַ +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: DSU_RSSP_LINK_RINFO_STRU_WL *pRsspLnkRInfo շʱò +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 dsuRsspRGetLnkInfoWl(UINT16 RsspAddr, UINT16 SrcAddr, DSU_RSSP_LINK_RINFO_STRU_WL* pRsspLnkRInfo, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL) +{ + UINT8 chReturnValue = 0; /**/ + UINT16 i = 0; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU_WL* pTempRsspLnkInfoStru = NULL; + UINT16 pTempRsspLnkInfoStruLen = 0; + UINT8 ChannelCount = 0; + UINT16 CurrentChannel = 0; + UINT8 LocalDevType = 0; + UINT8 DestDevType = 0; + UINT16 offset = 0U; + /*ҵChannelΪ0*/ + ChannelCount = 0; + + if ((NULL != pRsspLnkRInfo)&&(NULL!= pDsuRsrInfoStru_WL)) + { + pTempRsspLnkInfoStru = pDsuRsrInfoStru_WL->pRsspLnkInfoStru; + pTempRsspLnkInfoStruLen = pDsuRsrInfoStru_WL->RsspInfoStruLen; + + /*ѭ*/ + for (i = 0; i < pTempRsspLnkInfoStruLen; i++) + { + if ((pTempRsspLnkInfoStru[offset].RsspAddr == RsspAddr) + && (pTempRsspLnkInfoStru[offset].SseAddr == SrcAddr)) + { + /*ѾҵĿ*/ + CurrentChannel = pTempRsspLnkInfoStru[offset].ChannelNumber - 1; + ChannelCount++; + + pRsspLnkRInfo->LocalLogId = 0xff; + pRsspLnkRInfo->DestName = pTempRsspLnkInfoStru[offset].ReceptorName; + pRsspLnkRInfo->DestLogId = 0xff; + pRsspLnkRInfo->SseAddr = pTempRsspLnkInfoStru[offset].SseAddr; + pRsspLnkRInfo->SID_NUMBER_E[CurrentChannel] = pTempRsspLnkInfoStru[offset].SID_NUMBER_E; + pRsspLnkRInfo->SID_NUMBER_R[CurrentChannel] = pTempRsspLnkInfoStru[offset].SID_NUMBER_R; + pRsspLnkRInfo->PREC_FIRSTSINIT[CurrentChannel] = pTempRsspLnkInfoStru[offset].PREC_FIRSTSINIT; + CommonMemCpy(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel], sizeof(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel]), pTempRsspLnkInfoStru[offset].POST_RXDADA_K, sizeof(pRsspLnkRInfo->POST_RXDADA_K[CurrentChannel])); + CommonMemCpy(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel], sizeof(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel]), pTempRsspLnkInfoStru[offset].PREC_SINIT_K, sizeof(pRsspLnkRInfo->PREC_SINIT_K[CurrentChannel])); +#ifdef RSSP_NO_HLHT + LocalDevType = (pTempRsspLnkInfoStru->EmitterName >> 8) & 0xff; + DestDevType = (pTempRsspLnkInfoStru->ReceptorName >> 8) & 0xff; +#else + LocalDevType = DquToDevType(pTempRsspLnkInfoStru[offset].EmitterName, pDsuRsrInfoStru_WL); + DestDevType = DquToDevType(pTempRsspLnkInfoStru[offset].ReceptorName, pDsuRsrInfoStru_WL); +#endif + chReturnValue = dsuSetCommInfo_WL(pRsspLnkRInfo, LocalDevType, DestDevType, pDsuRsrInfoStru_WL); + if (chReturnValue == 0) + { + break; + } + + if (ChannelCount >= 2) + { + /*ͨϢҵ*/ + chReturnValue = 1; + break; + } + else + { + /*δҵͨ*/ + } + } + else + { + /*ǰĿ*/ + } + offset++; + } + + } + + return chReturnValue; +} + +/* +*: dsuRsspSGetLnkInfoWl +*: ڲѯRSSP·ϢͽڵϢӳ +*: UINT16 RsspAddr Դַ +* UINT16 BsdAddr Ŀĵַ +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: DSU_RSSP_LINK_SINFO_STRU_WL* pRsspLnkSInfo, ͷʱò +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 dsuRsspSGetLnkInfoWl(UINT16 RsspAddr, UINT16 BsdAddr, DSU_RSSP_LINK_SINFO_STRU_WL* pRsspLnkSInfo, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL) +{ + UINT8 chReturnValue = 0; /**/ + UINT16 i = 0; /*ѭ*/ + DSU_RSSP_LNK_INFO_STRU_WL* pTempRsspLnkInfoStru = NULL; + UINT16 pTempRsspLnkInfoStruLen = 0; + UINT8 ChannelCount = 0; + UINT16 CurrentChannel = 0; + UINT16 offset = 0U; + if ((NULL != pRsspLnkSInfo) && (NULL != pDsuRsrInfoStru_WL)) + { + pTempRsspLnkInfoStru = pDsuRsrInfoStru_WL->pRsspLnkInfoStru; + pTempRsspLnkInfoStruLen = pDsuRsrInfoStru_WL->RsspInfoStruLen; + + /*ҵChannelΪ0*/ + ChannelCount = 0; + + /*ѭ*/ + for (i = 0; i < pTempRsspLnkInfoStruLen; i++) + { + if ((pTempRsspLnkInfoStru[offset].RsspAddr == RsspAddr) + && (pTempRsspLnkInfoStru[offset].BsdAddr == BsdAddr)) + { + /*ѾҵĿ*/ + CurrentChannel = pTempRsspLnkInfoStru[offset].ChannelNumber - 1; + ChannelCount++; + + pRsspLnkSInfo->LocalLogId = 0xff; + pRsspLnkSInfo->DestName = pTempRsspLnkInfoStru[offset].ReceptorName; + pRsspLnkSInfo->DestLogId = 0xff; + pRsspLnkSInfo->SseAddr = pTempRsspLnkInfoStru[offset].SseAddr; + pRsspLnkSInfo->SID_NUMBER_E[CurrentChannel] = pTempRsspLnkInfoStru[offset].SID_NUMBER_E; + pRsspLnkSInfo->SID_NUMBER_R[CurrentChannel] = pTempRsspLnkInfoStru[offset].SID_NUMBER_R; + pRsspLnkSInfo->SINIT_NUMBER[CurrentChannel] = pTempRsspLnkInfoStru[offset].SINIT_NUMBER; + pRsspLnkSInfo->DATANUM[CurrentChannel] = pTempRsspLnkInfoStru[offset].DATANUM; + pRsspLnkSInfo->DATAVER_1_Number[CurrentChannel] = pTempRsspLnkInfoStru[offset].DATAVER_1_Number; + pRsspLnkSInfo->DATANUM[CurrentChannel] = pTempRsspLnkInfoStru[offset].DATANUM; + + if (ChannelCount >= 2) + { + chReturnValue = 1; + break; + } + else + { + /*δҵͨ*/ + } + } + else + { + /*ǰĿ*/ + } + offset++; + } + } + + return chReturnValue; +} + +/* +*: dsuRsspRGetAddrWl +*: ݱ豸ƺͶԷ豸ƣѯRSSP·ȡԴַĿַ +*: UINT32 destDevName Ŀ豸 +* UINT32 locDevName 豸 +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: UINT16* rsspSrcAddr Դַ +* UINT16* rsspDestAddr Ŀĵַ +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 dsuRsspRGetAddrWl(UINT32 destDevName,UINT32 locDevName ,UINT16* rsspSrcAddr,UINT16* rsspDestAddr, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL) +{ + UINT8 ret = 0; + UINT16 i; /*ѭ*/ + + for (i = 0;i < pDsuRsrInfoStru_WL->RsspInfoStruLen;i++) + { + if ((pDsuRsrInfoStru_WL->pRsspLnkInfoStru[i].EmitterName == locDevName) && (pDsuRsrInfoStru_WL->pRsspLnkInfoStru[i].ReceptorName == destDevName)) + { + *rsspSrcAddr = pDsuRsrInfoStru_WL->pRsspLnkInfoStru[i].RsspAddr; + *rsspDestAddr = pDsuRsrInfoStru_WL->pRsspLnkInfoStru[i].SseAddr; + break; + } + else + { + } + } + + if (i == pDsuRsrInfoStru_WL->RsspInfoStruLen) + { + return ret; + } + ret = 1; + return ret; +} + +/* +*: dsuRsspRGetName_WL +*: ԴַĿַѯRSSP·ȡ豸ƺͶԷ豸 +*: UINT16 rsspSrcAddr Դַ +* UINT16 rsspDestAddr Ŀĵַ +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: UINT32* destDevName Ŀ豸 +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 dsuRsspRGetName_WL(UINT16 rsspSrcAddr,UINT16 rsspDestAddr,UINT32* destDevName, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL) +{ + UINT8 ret = 0; + + UINT16 i; /*ѭ*/ + + if ((NULL != destDevName) && (NULL != pDsuRsrInfoStru_WL) && (NULL != pDsuRsrInfoStru_WL->pRsspLnkInfoStru)) + { + for (i = 0; i < pDsuRsrInfoStru_WL->RsspInfoStruLen; i++) + { + if ((pDsuRsrInfoStru_WL->pRsspLnkInfoStru[i].RsspAddr == rsspSrcAddr) && (pDsuRsrInfoStru_WL->pRsspLnkInfoStru[i].SseAddr == rsspDestAddr)) + { + *destDevName = pDsuRsrInfoStru_WL->pRsspLnkInfoStru[i].EmitterName; + break; + } + else + { + } + } + + if (i == pDsuRsrInfoStru_WL->RsspInfoStruLen) + { + return ret; + } + } + + ret = 1; + return ret; +} + +/** + * @brief CheckSafeParamOnly RSSPϢǷΨһ + * @param safeParam ȫ ȡֵΧ:οṹSafeParam + * @param sheetInfo sheetҳϢ ȡֵΧ:οṹSheetInfo + * @return 0:ʧ;1:ɹ + */ +static UINT8 CheckSafeParamOnly(SafeParam* safeParam, SheetInfo* sheetInfo) +{ + UINT8 rtnVal = 0u; /*-< úֵΪʧ*/ + UINT32 colLen = 0u; /*ֽڳ*/ + UINT32 cmpVal[2][6] = { 0 }; /*ڱȽֵ*/ + UINT32 curIdx = 0u; /*-< ǰȽ±*/ + UINT32 curCmpVal[2][6] = { 0 }; /*-< ǰڱȽֵ*/ + UINT32 channelIdx = 0u; /*ֵͨλ*/ + UINT32 i = 0u; /*ͨ±*/ + UINT32 j = 0u; /*Ƚֵ±*/ + UINT8 hasSame = 0u; /*Ƿͬ־Ϊͬ*/ + UINT8 hasNoSame = 0u; /*Ƿͬ־Ϊ޲ͬ*/ + + if ((NULL != safeParam) && (NULL != sheetInfo)) /*-< Ƿǿ*/ + { + if ((0u < sheetInfo->Len) && (0u < sheetInfo->RowCount)) /*-< Ƿ*/ + { + if ((0u == (sheetInfo->Len % sheetInfo->RowCount)) && (0u == (sheetInfo->RowCount % 2u))) /*-< ݳǷϷǷͨ*/ + { + for (i = 0u; i < 2u; i++) /*-< ǰͨǷС2*/ + { + cmpVal[i][1] = safeParam->DevId; /*-< ڱȽΨһID*/ + cmpVal[i][2] = safeParam->Sid[i]; /*-< ڱȽSID*/ + cmpVal[i][3] = safeParam->Sinit[i]; /*-< ڱȽSINIT*/ + cmpVal[i][4] = safeParam->Dataver[i]; /*-< ڱȽDATAVER*/ + cmpVal[i][5] = safeParam->Addr; /*-< ڱȽADDR*/ + } + + colLen = sheetInfo->Len / sheetInfo->RowCount; /*-< г*/ + for (curIdx = 0u; curIdx < sheetInfo->RowCount; curIdx += 2) /*-< ǰȽ±ǷС*/ + { + for (i = 0u; i < 2u; i++) /*-< ǰͨǷС2*/ + { +#ifdef RSSP_NO_HLHT + curCmpVal[i][1] = ShortFromChar(&sheetInfo->Data[sheetInfo->StartIdx + ((curIdx + i) * colLen) + 2u]); /*-< õǰΨһID*/ + channelIdx = 6u; /*-< ͨ±*/ +#else + curCmpVal[i][1] = LongFromChar(&sheetInfo->Data[sheetInfo->StartIdx + ((curIdx + i) * colLen) + 2u]); /*-< õǰΨһID*/ + channelIdx = 10u; /*-< ͨ±*/ +#endif + + curCmpVal[i][0] = ShortFromChar(&sheetInfo->Data[sheetInfo->StartIdx + ((curIdx + i) * colLen) + channelIdx]); /*-< õǰͨ*/ + curCmpVal[i][2] = LongFromChar(&sheetInfo->Data[sheetInfo->StartIdx + ((curIdx + i) * colLen) + channelIdx + 2u]); /*-< õǰSID*/ + curCmpVal[i][3] = LongFromChar(&sheetInfo->Data[sheetInfo->StartIdx + ((curIdx + i) * colLen) + channelIdx + 6u]); /*-< õǰSINIT*/ + curCmpVal[i][4] = LongFromChar(&sheetInfo->Data[sheetInfo->StartIdx + ((curIdx + i) * colLen) + channelIdx + 11u]); /*-< õǰDATAVER*/ + curCmpVal[i][5] = ShortFromChar(&sheetInfo->Data[sheetInfo->StartIdx + ((curIdx + i) * colLen) + channelIdx + 15u]); /*-< õǰADDR*/ + } + if ((1u == curCmpVal[0][0]) && (2u == curCmpVal[1][0]) && (curCmpVal[0][1] == curCmpVal[1][1]) && (curCmpVal[0][5] == curCmpVal[1][5])) /*-< ͨ,ΨһID,ADDRǷȷ*/ + { + for (i = 0u; i < 2u; i++) /*-< ǰͨǷС2*/ + { + hasSame = 0u; /*-< Ƿͬ־Ϊͬ*/ + hasNoSame = 0u; /*-< Ƿͬ־Ϊ޲ͬ*/ + for (j = 1u; j < 6u; j++) /*-< ǰȽֵ±ǷСֵ*/ + { + if (curCmpVal[i][j] == cmpVal[i][j]) /*-< ֵͬͨǷͬ*/ + { + hasSame = 1u; /*-< Ƿͬ־Ϊͬ*/ + } + else + { + hasNoSame = 1u; /*-< Ƿͬ־Ϊвͬ*/ + } + } + if ((1u == hasSame) && (1u == hasNoSame))/*-< Ƿͬвͬ*/ + { + break; /*-< ˳*/ + } + } + if (2u != i) /*-< ͨȽǷȽ*/ + { + break; /*-< ˳*/ + } + } + } + if (curIdx == sheetInfo->RowCount) /*-< ǰȽǷȽ*/ + { + rtnVal = 1u; /*-< úֵΪɹ*/ + } + } + } + else + { + rtnVal = 1u; /*-< úֵΪɹ*/ + } + } + + return rtnVal; /*-< غֵ*/ +} + +#ifndef RSSP_NO_HLHT +/* +*: DquInitHlhtId +*: ʼŶձ +*: UINT8 *pFsName ļ +* UINT8 sheetId sheetҳID +* UINT8 colUseLen sheetռֽڳ +* UINT8 hlhtIdNum һ豸Ӧhlhtid +*: +*: UINT16 *pRowNum +* DSU_DEV_HLHTID **pDsuDevHlhtids hlhtidֵб +*ֵ: 1:ɹ;0ʧ +*/ +static UINT8 DquInitHlhtId(UINT8* pFsName, UINT8 sheetId, UINT8 colUseLen, UINT8 hlhtIdNum, UINT16* pRowNum, DSU_DEV_HLHTID** pDsuDevHlhtids) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT8* pData = NULL; /**/ + UINT32 dataLen = 0; /*ݳ*/ + UINT32 mallocLen = 0; /*ռС*/ + UINT32 offset = 0; /*ƫ*/ + UINT32 i = 0; /*ѭ*/ + UINT32 j = 0; /*ѭ*/ + + if ((NULL != pFsName) && (0 < sheetId) && (5 < colUseLen) && (0 < hlhtIdNum) && (NULL != pRowNum) && (NULL != pDsuDevHlhtids)) /*ηǿ*/ + { + dquGetConfigData((CHAR*)pFsName, IDMAP_DATA_TYPE, sheetId, &pData, &dataLen); + if (0 < dataLen) /**/ + { + *pRowNum = (UINT16)(dataLen / colUseLen); /*ݵĸ*/ + mallocLen = sizeof(DSU_DEV_HLHTID) * (*pRowNum); /*ռС*/ + *pDsuDevHlhtids = (DSU_DEV_HLHTID*)malloc(mallocLen); /*Ϊ豸ͨԱռ*/ + if (NULL != (*pDsuDevHlhtids)) + { + CommonMemSet(*pDsuDevHlhtids, mallocLen, 0, mallocLen); + + for (i = 0; i < *pRowNum; i++) /**/ + { + /*2ֽ豸ID*/ + (*pDsuDevHlhtids)[i].DevId = ShortFromChar(&pData[offset]); + offset += 2; + /*n4ֽHLHTID*/ + (*pDsuDevHlhtids)[i].HlhtIds = (UINT32*)malloc(sizeof(UINT32) * hlhtIdNum); /*HLHTIDsռ*/ + for (j = 0; j < hlhtIdNum; j++) /*HlhtIds*/ + { + (*pDsuDevHlhtids)[i].HlhtIds[j] = LongFromChar(&pData[offset]); + offset += 4; + } + } + if (offset == dataLen) /*Ŷձֵɹ*/ + { + rtn = 1; + } + } + } + else /*ݳΪ0*/ + { + rtn = 1; + } + } + + return rtn; +} + +/* +*: DquGetHlhtId +*: 豸ID,logid,Ӧȡhlhtid +*: UINT8 type +* UINT8 id 豸ID +* UINT16 logicId dz ߼ID1:1 22 +* ߼ID0 +* UINT16 rowNum +* const DSU_DEV_HLHTID *pDevHlhtids ӦŶձϢ +*: +*: +*ֵ: ӦHLHTID +*/ +static UINT32 DquGetHlhtId(UINT8 type, UINT8 id, UINT16 logicId, UINT16 rowNum, const DSU_DEV_HLHTID* pDevHlhtids) +{ + UINT32 hlhtId = 0; /*ֵ*/ + UINT32 i = 0; /*ѭ*/ + + if ((NULL != pDevHlhtids) && (NULL != pDevHlhtids->HlhtIds) + && (((0u == type) && ((0u == logicId)|| (1u == logicId))) + || ((1u == type) && ((0u == logicId)|| (1u == logicId)|| (2u == logicId))))) + { + if (0u < logicId) /*0:೵,1:һ,2:*/ + { + logicId -= 1; + } + for (i = 0u; i < rowNum; i++) + { + if (pDevHlhtids[i].DevId == id) /*ҵID˳*/ + { + hlhtId = pDevHlhtids[i].HlhtIds[logicId]; + break; + } + } + } + return hlhtId; +} + +/* +*: DquGetDevId +*: ȡ豸ID +*: UINT32 hlhtId HLHTID +* UINT16 rowNum +* const DSU_DEV_HLHTID *pDevHlhtids ӦŶձϢ +* UINT8 hlhtIdNum һ豸Ӧhlhtid +*: +*: +*ֵ: ӦID +*/ +static UINT8 DquGetDevId(UINT32 hlhtId, UINT16 rowNum, const DSU_DEV_HLHTID *pDevHlhtids, UINT8 hlhtIdNum) +{ + UINT8 id = 0; /*豸ID*/ + UINT32 i = 0; /*ѭ*/ + UINT32 j = 0; /*ѭ*/ + UINT8 isBreak = 0; /*Ƿ˳ѭ*/ + + for (i = 0; i < rowNum; i++) + { + for (j = 0; j < hlhtIdNum; j++) + { + if (pDevHlhtids[i].HlhtIds[j] == hlhtId) /*ҵHLHTID˳*/ + { + id = (UINT8)pDevHlhtids[i].DevId; /*豸IDһֽڵ*/ + isBreak = 1; + break; + } + } + if (1 == isBreak) /*ҵ˳ѭ*/ + { + break; + } + } + + return id; +} + +/** +* @brief DquGetDevHlhtId 豸,豸ID,߼IDӱŶձлȡHLHT ID +* @param devType 豸 ȡֵΧ:0x00-0xFF +* @param devId 豸ID ȡֵΧ:0x00-0xFF +* @param logicId ߼ID ȡֵΧ:0x0000-0xFFFF +* @param pDsuRssp RSSPIϢ ȡֵΧ:οṹDSU_RSSP_INFO_STRU_WL + * @return ͨID ȡֵΧ:0x00000000-0xFFFFFFFF +*/ +static UINT32 DquGetDevHlhtId(UINT8 devType, UINT8 devId, UINT16 logicId, DSU_RSSP_INFO_STRU_WL* pDsuRssp) +{ + UINT32 hlhtId = 0; /*-< úֵΪ0*/ + if (NULL != pDsuRssp) /*-< Ƿǿ*/ + { + switch (devType) /*-< ж*/ + { + case ZC_TYPE: /*-< ǷΪZC*/ + /*ZC*/ + hlhtId = DquGetHlhtId(0, devId, logicId, pDsuRssp->ZcRowNum, pDsuRssp->ZcHlhtids); /*-< ûȡZCͨID,ֵֵ*/ + break; /*-< ˳*/ + case CI_TYPE: /*-< ǷΪCI*/ + /*CI*/ + hlhtId = DquGetHlhtId(0, devId, logicId, pDsuRssp->CiRowNum, pDsuRssp->CiHlhtids); /*-< ûȡCIͨID,ֵֵ*/ + break; /*-< ˳*/ + case ATS_TYPE: /*-< ǷΪATS*/ + /*ATS*/ + hlhtId = DquGetHlhtId(0, devId, logicId, pDsuRssp->AtsRowNum, pDsuRssp->AtsHlhtids); /*-< ûȡATSͨID,ֵֵ*/ + break; /*-< ˳*/ + case VOBC_TYPE: /*-< ǷΪVOBC*/ + /*VOBC*/ + hlhtId = DquGetHlhtId(1, devId, logicId, pDsuRssp->VobcRowNum, pDsuRssp->VobcHlhtids); /*-< ûȡVOBCͨID,ֵֵ*/ + break; /*-< ˳*/ + case DSU_TYPE: /*-< ǷΪDSU*/ + /*DSU*/ + hlhtId = DquGetHlhtId(0, devId, logicId, pDsuRssp->DsuRowNum, pDsuRssp->DsuHlhtids); /*-< ûȡDSUͨID,ֵֵ*/ + break; /*-< ˳*/ + case AOM_TYPE: /*-< ǷΪAOM*/ + /*AOM*/ + hlhtId = DquGetHlhtId(1, devId, logicId, pDsuRssp->AomRowNum, pDsuRssp->AomHlhtids); /*-< ûȡAOMͨID,ֵֵ*/ + break; /*-< ˳*/ + case TDT_TYPE: /*-< ǷΪTDT*/ + /*TDT*/ + hlhtId = DquGetHlhtId(0, devId, logicId, pDsuRssp->TdtRowNum, pDsuRssp->TdtHlhtids); /*-< ûȡTDTͨID,ֵֵ*/ + break; /*-< ˳*/ + case AXLE_TYPE: /*-< ǷΪϵͳ*/ + /*ϵͳ*/ + hlhtId = DquGetHlhtId(1, devId, logicId, pDsuRssp->AxleRowNum, pDsuRssp->AxleHlhtids); /*-< ûȡϵͳͨID,ֵֵ*/ + break; /*-< ˳*/ + case ITE_DEVTYPE: /*-< ǷΪITE*/ + /*ITE*/ + hlhtId = DquGetHlhtId(1, devId, logicId, pDsuRssp->IteRowNum, pDsuRssp->IteHlhtids); /*-< ûȡITEͨID,ֵֵ*/ + break; /*-< ˳*/ + default: /*-< */ + /*޲*/ + break; /*-< ˳*/ + } + } + + return hlhtId; /*-< غֵ*/ +} + +/* +*: DquToHlhtId +*: 豸ID,߼IDתHLHTID +*: UINT8 devType 豸 +* UINT8 devId 豸ID +* UINT16 logicId ߼ID +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: +*ֵ: HLHTID +*/ +UINT32 DquToHlhtId(UINT8 devType, UINT8 devId, UINT16 logicId, DSU_RSSP_INFO_STRU_WL *pDsuRssp) +{ + UINT32 hlhtId = 0; /*ֵHLHTID*/ + UINT16 devName = 0U; + if (NULL != pDsuRssp) + { + hlhtId = DquGetDevHlhtId(devType, devId, logicId, pDsuRssp); + } + + if (0 == hlhtId) /*Ŷձδҵ*/ + { + devName = devType; + hlhtId = ((UINT16)(devName << 8) & 0xFF00) | (devId & 0x00FF); /*ʹ豸IDΪRSSPIΨһID*/ + } + + return hlhtId; +} + +/* +*: DquTypeIdToHlhtId +*: 豸ID,߼IDתHLHTID +*: UINT16 devTypeId 豸ID +* UINT16 logicId ߼ID +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: +*ֵ: HLHTID +*/ +UINT32 DquTypeIdToHlhtId(UINT16 devTypeId, UINT16 logicId, DSU_RSSP_INFO_STRU_WL *pDsuRssp) +{ + UINT32 hlhtId = 0; /*ֵHLHTID*/ + UINT8 devType = (UINT8)((devTypeId >> 8) & 0x00FF); /*豸*/ + UINT8 devId = (UINT8)(devTypeId & 0x00FF); /*豸ID*/ + + hlhtId = DquGetDevHlhtId(devType, devId, logicId, pDsuRssp); + if (0 == hlhtId) /*Ŷձδҵ*/ + { + hlhtId = devTypeId; /*ʹ豸IDΪRSSPIΨһID*/ + } + + return hlhtId; +} + +/** +* @brief DquToDevTypeId HLHTIDת豸ID +* @param hlhtid ͨID ȡֵΧ:0x00000000-0xFFFFFFFF +* @param pDsuRssp RSSPIϢ ȡֵΧ:οṹDSU_RSSP_INFO_STRU_WL + * @return 豸ID ȡֵΧ:0x0000-0xFFFF +*/ +UINT16 DquToDevTypeId(UINT32 hlhtid, DSU_RSSP_INFO_STRU_WL* pDsuRssp) +{ + UINT16 typeId = 0; /*-< úֵΪ0*/ + UINT8 id = 0; /*豸ID*/ + UINT16 devName = 0U; /*-< 豸Ϊ0*/ + id = DquGetDevId(hlhtid, pDsuRssp->ZcRowNum, pDsuRssp->ZcHlhtids, DEV_HLHTID_NUM_ONE); /*-< ûȡZC豸ID,ֵ豸ID*/ + if (0 == id) /*-< ZCŶձǷδҵ*/ + { + id = DquGetDevId(hlhtid, pDsuRssp->CiRowNum, pDsuRssp->CiHlhtids, DEV_HLHTID_NUM_ONE); /*-< ûȡCI豸ID,ֵ豸ID*/ + if (0 == id) /*-< CIŶձǷδҵ*/ + { + id = DquGetDevId(hlhtid, pDsuRssp->AtsRowNum, pDsuRssp->AtsHlhtids, DEV_HLHTID_NUM_ONE); /*-< ûȡATS豸ID,ֵ豸ID*/ + if (0 == id) /*-< ATSŶձǷδҵ*/ + { + id = DquGetDevId(hlhtid, pDsuRssp->VobcRowNum, pDsuRssp->VobcHlhtids, DEV_HLHTID_NUM_TWO); /*-< ûȡVOBC豸ID,ֵ豸ID*/ + if (0 == id) /*-< VOBCŶձǷδҵ*/ + { + id = DquGetDevId(hlhtid, pDsuRssp->DsuRowNum, pDsuRssp->DsuHlhtids, DEV_HLHTID_NUM_ONE); /*-< ûȡDSU豸ID,ֵ豸ID*/ + if (0 == id) /*-< DSUŶձǷδҵ*/ + { + id = DquGetDevId(hlhtid, pDsuRssp->AomRowNum, pDsuRssp->AomHlhtids, DEV_HLHTID_NUM_TWO); /*-< ûȡAOM豸ID,ֵ豸ID*/ + if (0 == id) /*-< AOMŶձǷδҵ*/ + { + id = DquGetDevId(hlhtid, pDsuRssp->TdtRowNum, pDsuRssp->TdtHlhtids, DEV_HLHTID_NUM_ONE); /*-< ûȡTDT豸ID,ֵ豸ID*/ + if (0 == id) /*-< TDTŶձǷδҵ*/ + { + id = DquGetDevId(hlhtid, pDsuRssp->AxleRowNum, pDsuRssp->AxleHlhtids, DEV_HLHTID_NUM_TWO); /*-< ûȡϵͳ豸ID,ֵ豸ID*/ + if (0 == id) /*-< AXLEŶձǷδҵ*/ + { + id = DquGetDevId(hlhtid, pDsuRssp->IteRowNum, pDsuRssp->IteHlhtids, DEV_HLHTID_NUM_TWO); /*-< ûȡITE豸ID,ֵ豸ID*/ + if (0 == id) /*-< ITEŶձǷδҵ*/ + { + typeId = 0; /*-< IDΪ0*/ + } + else + { + devName = (UINT8)ITE_DEVTYPE; /*-< 豸ΪITE豸*/ + } + } + else + { + devName = (UINT8)AXLE_TYPE; /*-< 豸Ϊϵͳ*/ + } + }/*ҵ,TDTID*/ + else + { + devName = (UINT8)TDT_TYPE; /*-< 豸ΪTDT*/ + } + } + else /*ҵ,AOMID*/ + { + devName = (UINT8)AOM_TYPE; /*-< 豸ΪAOM*/ + } + } + else /*ҵ,DSUID*/ + { + devName = (UINT8)DSU_TYPE; /*-< 豸ΪDSU*/ + } + } + else /*ҵ,VOBCID*/ + { + devName = (UINT8)VOBC_TYPE; /*-< 豸ΪVOBC*/ + } + } + else /*ҵ,ATSID*/ + { + devName = (UINT8)ATS_TYPE; /*-< 豸ΪATS*/ + } + } + else /*ҵ,CIID*/ + { + devName = (UINT8)CI_TYPE; /*-< 豸ΪCI*/ + } + } + else /*ҵ,ZCID*/ + { + devName = (UINT8)ZC_TYPE; /*-< 豸ΪZC*/ + } + typeId = (UINT16)(((devName << 8) & 0xFF00) | id); /*-< ͨ豸ID*/ + + if (0 == typeId) /*-< IDǷΪ0*/ + { + typeId = (UINT16)(hlhtid & 0x0000FFFF); /*-< ʹôRSSPIΨһIDΪ豸ID*/ + } + return typeId; /*-< غֵ*/ +} + +/* +*: DquToDevType +*: HLHTIDת豸 +*: UINT32 hlhtid HLHTID +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: +*ֵ: 豸 +*/ +UINT8 DquToDevType(UINT32 hlhtid, DSU_RSSP_INFO_STRU_WL *pDsuRssp) +{ + UINT8 devType = 0; /*豸*/ + UINT16 typeId = 0; /*豸ID*/ + + typeId = DquToDevTypeId(hlhtid, pDsuRssp); + devType = (UINT8)((typeId >> 8) & 0x00FF); + + return devType; +} + +/* +*: DquToDevId +*: HLHTIDת豸ID +*: UINT32 hlhtid HLHTID +* DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ +*: +*: +*ֵ: 豸ID +*/ +UINT8 DquToDevId(UINT32 hlhtid, DSU_RSSP_INFO_STRU_WL *pDsuRssp) +{ + UINT8 devId = 0; /*豸ID*/ + UINT16 typeId = 0; /*豸ID*/ + + typeId = DquToDevTypeId(hlhtid, pDsuRssp); + devId = (UINT8)(typeId & 0x00FF); + + return devId; +} + +/* +*: FreeDsuRsspi +*: ͷRSSPIѯʹõĿռ +*: DSU_RSSP_INFO_STRU_WL **pDsuRsrInfoStru_WL RSSPIϢ +*: +*: +*ֵ: +*/ +void FreeDsuRsspi(DSU_RSSP_INFO_STRU_WL **pDsuRsspInfo) +{ + UINT32 i = 0; /*ѭ*/ + + free((*pDsuRsspInfo)->pRsspLnkInfoStru); + (*pDsuRsspInfo)->pRsspLnkInfoStru = NULL; + + free((*pDsuRsspInfo)->pDevCommInfoStru); + (*pDsuRsspInfo)->pDevCommInfoStru = NULL; + + /*ZCŶձ*/ + if (0 < (*pDsuRsspInfo)->ZcRowNum) + { + for (i = 0; i < (*pDsuRsspInfo)->ZcRowNum; i++) + { + free((*pDsuRsspInfo)->ZcHlhtids[i].HlhtIds); + (*pDsuRsspInfo)->ZcHlhtids[i].HlhtIds = NULL; + } + free((*pDsuRsspInfo)->ZcHlhtids); + (*pDsuRsspInfo)->ZcHlhtids = NULL; + } + + /*CIŶձ*/ + if (0 < (*pDsuRsspInfo)->CiRowNum) + { + for (i = 0; i < (*pDsuRsspInfo)->CiRowNum; i++) + { + free((*pDsuRsspInfo)->CiHlhtids[i].HlhtIds); + (*pDsuRsspInfo)->CiHlhtids[i].HlhtIds = NULL; + } + free((*pDsuRsspInfo)->CiHlhtids); + (*pDsuRsspInfo)->CiHlhtids = NULL; + } + + /*ATSŶձ*/ + if (0 < (*pDsuRsspInfo)->AtsRowNum) + { + for (i = 0; i < (*pDsuRsspInfo)->AtsRowNum; i++) + { + free((*pDsuRsspInfo)->AtsHlhtids[i].HlhtIds); + (*pDsuRsspInfo)->AtsHlhtids[i].HlhtIds = NULL; + } + free((*pDsuRsspInfo)->AtsHlhtids); + (*pDsuRsspInfo)->AtsHlhtids = NULL; + } + + /*VOBCŶձ*/ + if (0 < (*pDsuRsspInfo)->VobcRowNum) + { + for (i = 0; i < (*pDsuRsspInfo)->VobcRowNum; i++) + { + free((*pDsuRsspInfo)->VobcHlhtids[i].HlhtIds); + (*pDsuRsspInfo)->VobcHlhtids[i].HlhtIds = NULL; + } + free((*pDsuRsspInfo)->VobcHlhtids); + (*pDsuRsspInfo)->VobcHlhtids = NULL; + } + + /*DSUŶձ*/ + if (0 < (*pDsuRsspInfo)->DsuRowNum) + { + for (i = 0; i < (*pDsuRsspInfo)->DsuRowNum; i++) + { + free((*pDsuRsspInfo)->DsuHlhtids[i].HlhtIds); + (*pDsuRsspInfo)->DsuHlhtids[i].HlhtIds = NULL; + } + free((*pDsuRsspInfo)->DsuHlhtids); + (*pDsuRsspInfo)->DsuHlhtids = NULL; + } + + /*AOMŶձ*/ + if (0 < (*pDsuRsspInfo)->AomRowNum) + { + for (i = 0; i < (*pDsuRsspInfo)->AomRowNum; i++) + { + free((*pDsuRsspInfo)->AomHlhtids[i].HlhtIds); + (*pDsuRsspInfo)->AomHlhtids[i].HlhtIds = NULL; + } + free((*pDsuRsspInfo)->AomHlhtids); + (*pDsuRsspInfo)->AomHlhtids = NULL; + } + + /*ͷſռ*/ + free(*pDsuRsspInfo); + (*pDsuRsspInfo) = NULL; +} + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspFunc.h b/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspFunc.h new file mode 100644 index 0000000..8fc6785 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_dqu_rssp/dsuRsspFunc.h @@ -0,0 +1,213 @@ +/************************************************************************ +* +* ļ dsuRsspFunc.h +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ 2011.12.30 +* з +* ȫͨЭrsrѯ +* ʹע +* ޸ļ¼ +* 20130222 ɾͨŽɫĺ +************************************************************************/ + +#ifndef _DSU_RSSP_FUNC_H_ +#define _DSU_RSSP_FUNC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "dsuRsspDataStru.h" +#include "RsspConfigWl.h" +/* RSSPѯ汾Ŷ */ +#define DQU_RSSP_VER_PRODUCT_NO 88/*Ʒ*/ +#define DQU_RSSP_VER_MODULE_NO 19/*ģ*/ +#define DQU_RSSP_VER_MAIN_VER 20/*ģ汾*/ +#define DQU_RSSP_VER_SUB_VER 3 /*ģӰ汾*/ + /*RsspSGetLnkInfoʹõĽṹ*/ + typedef struct { + UINT8 LocalLogId; /* ʾԴ̬ID */ + UINT32 DestName;/*ʾĿʶ*/ + UINT8 DestLogId; /* ʾĵĿ궯̬ID */ + UINT16 SseAddr; /*ʾSSE_SSR_Destination_Addresݿ*/ + UINT32 SID_NUMBER_E[2];/* ݿ⣬±01ֱӦݿе12ͨ,ֵΪͷSID*/ + UINT32 SID_NUMBER_R[2];/* ݿ⣬±01ֱӦݿе12ͨ,ֵΪܷSID*/ + UINT32 SINIT_NUMBER[2];/* ݿ⣬±01ֱӦݿе12ͨ*/ + UINT8 DATANUM[2];/*ݿ⣬±01ֱӦݿе12ͨ*/ + UINT32 DATAVER_1_Number[2]; /*ݿ⣬±01ֱӦݿе12ͨ*/ + } DSU_RSSP_LINK_SINFO_STRU_WL; + + /*RsspRGetLnkInfoʹõĽṹ*/ + typedef struct { + UINT8 LocalLogId; /* ʾԴ̬ID */ + UINT32 DestName;/*ʾĿʶ*/ + UINT8 DestLogId; /* ʾĵĿ궯̬ID */ + UINT16 SseAddr; /*ʾSSE_SSR_Destination_Addresݿ*/ + UINT32 SID_NUMBER_E[2];/* ݿ⣬±01ֱӦݿе12ͨ,ֵΪͷSID*/ + UINT32 SID_NUMBER_R[2];/* ݿ⣬±01ֱӦݿе12ͨ,ֵΪܷSID*/ + UINT32 PREC_FIRSTSINIT[2]; /*ʾ׸SINIT*/ + UINT32 POST_RXDADA_K[2][DSURSR_MAX_K_NUM_WL]; /*ʾBSD̶ֵ*/ + UINT32 PREC_SINIT_K[2][DSURSR_MAX_K_NUM_WL]; /*ʾSINITֵ*/ + UINT8 MaxLost;/*LOST*/ + UINT8 DLost;/*ʱ*/ + UINT8 WSsrOut;/*ȴSSRʱ*/ + UINT8 AntiDelayCount;/*ͬ*/ + UINT8 TOut; /*ijʱ*/ + } DSU_RSSP_LINK_RINFO_STRU_WL; + + /* + *: DsuRsspInitWl + *: RSSPIЭѯʼ + *: UINT8 *pFsName FSļ + * UINT16 localTypeId ID + * UINT16 localLogicId ߼ID + *: DSU_RSSP_INFO_STRU_WL *pDsuRsspInfo RSSPIϢ + *: + *ֵ: 1:ɹ;0ʧ + */ + UINT8 DsuRsspInitWl(UINT8* pFsName, UINT32 inDataLen, UINT8 inData[], UINT16 localTypeId, UINT16 localLogicId, DSU_RSSP_INFO_STRU_WL* pDsuRsspInfo); + /* + *: dsuSetCommInfo_WL + *: ݱԷ豸Ϊշʱò + *: UINT8 localType + * UINT8 DestType Է + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: DSU_RSSP_LINK_RINFO_STRU_WL *pRsspLnkRInfo շʱò + *ֵ: 1:ɹ;0ʧ + */ + UINT8 dsuSetCommInfo_WL(DSU_RSSP_LINK_RINFO_STRU_WL* pRsspLnkRInfo, UINT8 localType, UINT8 DestType, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL); + + /* + *: dsuRsspGetDevTypeWl + *: ȡ豸 + *: UINT16 DevName 豸 + *: + *: + *ֵ: 豸 + */ + UINT8 dsuRsspGetDevTypeWl(UINT16 DevName); + + /* + *: dsuRsspRGetLnkInfoWl + *: ڲѯRSSP·ϢսڵϢӳ + *: UINT16 RsspAddr Rsspַ + * UINT16 SrcAddr Srcַ + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: DSU_RSSP_LINK_RINFO_STRU_WL *pRsspLnkRInfo շʱò + *ֵ: 1:ɹ;0ʧ + */ + UINT8 dsuRsspRGetLnkInfoWl(UINT16 RsspAddr, UINT16 SrcAddr, DSU_RSSP_LINK_RINFO_STRU_WL* pRsspLnkRInfo, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL); + + /* + *: dsuRsspSGetLnkInfoWl + *: ڲѯRSSP·ϢͽڵϢӳ + *: UINT16 RsspAddr Դַ + * UINT16 BsdAddr Ŀĵַ + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: DSU_RSSP_LINK_SINFO_STRU_WL* pRsspLnkSInfo, ͷʱò + *ֵ: 1:ɹ;0ʧ + */ + UINT8 dsuRsspSGetLnkInfoWl(UINT16 RsspAddr, UINT16 BsdAddr, DSU_RSSP_LINK_SINFO_STRU_WL* pRsspLnkSInfo, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL); + + /* + *: dsuRsspRGetAddrWl + *: ݱ豸ƺͶԷ豸ƣѯRSSP·ȡԴַĿַ + *: UINT16 destDevName Ŀ豸 + * UINT16 locDevName 豸 + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: UINT16* rsspSrcAddr Դַ + * UINT16* rsspDestAddr Ŀĵַ + *ֵ: 1:ɹ;0ʧ + */ + UINT8 dsuRsspRGetAddrWl(UINT32 destDevName, UINT32 locDevName, UINT16* rsspSrcAddr, UINT16* rsspDestAddr, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL); + + /* + *: dsuRsspRGetName_WL + *: ԴַĿַѯRSSP·ȡ豸ƺͶԷ豸 + *: UINT16 rsspSrcAddr Դַ + * UINT16 rsspDestAddr Ŀĵַ + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: UINT16* destDevName Ŀ豸 + *ֵ: 1:ɹ;0ʧ + */ + UINT8 dsuRsspRGetName_WL(UINT16 rsspSrcAddr, UINT16 rsspDestAddr, UINT32* destDevName, DSU_RSSP_INFO_STRU_WL* pDsuRsrInfoStru_WL); +#ifndef RSSP_NO_HLHT + /* + *: DquToHlhtId + *: 豸ID,߼IDתHLHTID + *: UINT8 devType 豸 + * UINT8 devId 豸ID + * UINT16 logicId ߼ID + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: + *ֵ: HLHTID + */ + UINT32 DquToHlhtId(UINT8 devType, UINT8 devId, UINT16 logicId, DSU_RSSP_INFO_STRU_WL *pDsuRssp); + + /* + *: DquTypeIdToHlhtId + *: 豸ID,߼IDתHLHTID + *: UINT16 devTypeId 豸ID + * UINT16 logicId ߼ID + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: + *ֵ: HLHTID + */ + UINT32 DquTypeIdToHlhtId(UINT16 devTypeId, UINT16 logicId, DSU_RSSP_INFO_STRU_WL *pDsuRssp); + + + /** + * @brief DquToDevTypeId HLHTIDת豸ID + * @param hlhtid ͨID ȡֵΧ:0x00000000-0xFFFFFFFF + * @param pDsuRssp RSSPIϢ ȡֵΧ:οṹDSU_RSSP_INFO_STRU_WL + * @return 豸ID ȡֵΧ:0x0000-0xFFFF + */ + UINT16 DquToDevTypeId(UINT32 hlhtid, DSU_RSSP_INFO_STRU_WL *pDsuRssp); + + /* + *: DquToDevType + *: HLHTIDת豸 + *: UINT32 hlhtid HLHTID + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: + *ֵ: 豸 + */ + UINT8 DquToDevType(UINT32 hlhtid, DSU_RSSP_INFO_STRU_WL *pDsuRssp); + + /* + *: DquToDevId + *: HLHTIDת豸ID + *: UINT32 hlhtid HLHTID + * DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: + *ֵ: 豸ID + */ + UINT8 DquToDevId(UINT32 hlhtid, DSU_RSSP_INFO_STRU_WL *pDsuRssp); + + /* + *: FreeDsuRsspi + *: ͷRSSPIѯʹõĿռ + *: DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL RSSPIϢ + *: + *: + *ֵ: + */ + void FreeDsuRsspi(DSU_RSSP_INFO_STRU_WL **pDsuRsspInfo); +#endif +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspCommonWl.c b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspCommonWl.c new file mode 100644 index 0000000..49dceaa --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspCommonWl.c @@ -0,0 +1,1045 @@ +/************************************************************************ +* +* ļ RsspCommonWl.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.10.02 +* ؼЭ鲿 +* RSSPЭʹõFLSR麯. +* ʹע ʹ֮ǰinittab_WLgTableFast_WLֵ趨 +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +* 2009/11/01 ¥ΰ +* 2009/12/02 ¥ΰ MisraCӦ +* 2013/02/16 RSRЭRSRcommomRSSPCommomϲ +************************************************************************/ + +#include +#include "RsspCommonWl.h" +#include "Convert.h" + +/*---------------------------------------------------------------------- + * ȫֹͨMASK鶨 Start + *---------------------------------------------------------------------*/ + +#define DIMTAB_WL 256 + +static const UINT32 SYS_CHK_WD_WL[2] ={0xAE390B5AL,0xC103589CL}; /* system check word */ +static UINT32 gTableFast_WL[CHAN_NUM_WL][DIMTAB_WL]; /* LFSRλʹõı */ +static const UINT32 gMaskLFSR_WL[CHAN_NUM_WL] = /* LFSRλ MASK */ + {0x0FC22F87,0xC3E887E1}; + +/*---------------------------------------------------------------------- + * ȫֹͨMASK鶨 END + *---------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------- + * LFSR Start + *---------------------------------------------------------------------*/ +static UINT8 inittab_WL(UINT8 chan); +static UINT32 pd_shift_left_WL(UINT32 regLFSR, UINT8 chan, UINT8 nshift); +static UINT32 pd_shift_right_WL(UINT32 regLFSR, UINT8 chan, UINT8 nshift); +static UINT32 pd_shl_fast_WL(UINT32 regLFSR, UINT8 chan, UINT8 nshift); + +/*---------------------------------------------------------------------- + * End + *---------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------- + * LFSR Start + *---------------------------------------------------------------------*/ + +/*********************************************************************** + * : F_Add_WL + * : LFSRļ㡣Ĵֵ ȻLFSR32λ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in ĴʵΪLFSR1 + * chan UINT8 in channel + * val UINT32 in 2 + * ֵ: UINT32 + ***********************************************************************/ +UINT32 F_ADD_WL(UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + regLFSR ^= val; + regLFSR = pd_shl_fast_WL(regLFSR, chan, 32); + return regLFSR; +} + +/*********************************************************************** + * : F_Sub_WL + * : LFSRļ㡣ĴֵLFSR32λ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in ĴʵΪLFSRı + * chan UINT8 in channel + * val UINT32 in + * ֵ: UINT32 + ***********************************************************************/ + UINT32 F_SUB_WL(UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + regLFSR = pd_shift_right_WL(regLFSR, chan, 32); + regLFSR ^= val; + return regLFSR; +} + + +/*********************************************************************** + * : F_Post_WL + * : LFSRļ㡣ֵLFSR32λĴ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in ĴʵΪLFSRı + * chan UINT8 in channel + * val UINT32 in + * ֵ: UINT32 + ***********************************************************************/ +UINT32 F_POST_WL(UINT32 regLFSR, UINT8 chan, UINT32 val) +{ + UINT32 tmpVal = 0; + + tmpVal = regLFSR; + regLFSR = val; + regLFSR = pd_shift_right_WL(regLFSR, chan, 32); + regLFSR ^= tmpVal; + + return regLFSR; +} + +/*********************************************************************** + * : F_XOR_WL + * : ԼĴ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * val UINT32 in + * ֵ: UINT32 + ***********************************************************************/ +UINT32 F_XOR_WL(UINT32 regLFSR, UINT32 val) +{ + regLFSR ^= val; + return regLFSR; +} + + +/*********************************************************************** + * : F_LOAD_WL + * : ֵ뵽Ĵ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * val UINT32 in Ĵ + * ֵ: UINT32 ؼĴֵ + ***********************************************************************/ +UINT32 F_LOAD_WL(UINT32 regLFSR, UINT32 val) +{ + regLFSR = val; + return regLFSR; +} + +/*********************************************************************** + * : F_READ_WL + * : Ĵݡ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * ֵ: UINT32 ؼĴֵ + ***********************************************************************/ +UINT32 F_READ_WL(UINT32 regLFSR) +{ + return regLFSR; +} + +/*********************************************************************** + * : inittab_WL + * : ȫLFSRƳgTableFast_WLгڻ + * : + * + * -------------------------------------------------------------- + * chan UINT8 in channel ID + * + * ȫֱ : gTableFast_WL[CHAN_NUM_WL][DIMTAB_WL] + * ֵ : UINT8 1: 0: + ***********************************************************************/ +static UINT8 inittab_WL(UINT8 chan) +{ + UINT8 ret = 0; + UINT32 index = 0; + UINT32 regLFSR = 0; + UINT32 value = 0; + + for(index = 0; index < DIMTAB_WL; index++) + { + + value = index << 24; + value = value & 0x0FF000000; + regLFSR = F_LOAD_WL(regLFSR,value); + regLFSR = pd_shift_left_WL(regLFSR,chan,8); + gTableFast_WL[chan][index] = F_READ_WL(regLFSR); + } + ret = 1; + return ret; +} + +/*********************************************************************** + * : pd_shift_left_WL + * : Ĵָλ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * chan UINT8 in channel ID + * nshift UINT8 in ƶλ + * + * ȫֱ : gMaskLFSR[chan] LFSR mask + * ֵ : UINT32 λֵ + ***********************************************************************/ +static UINT32 pd_shift_left_WL(UINT32 regLFSR, UINT8 chan, UINT8 nshift) +{ + UINT8 index = 0; + UINT32 carry = 0; + + for(index=0; index>= 1; + if(0 != carry) + { + regLFSR |= 0x80000000L; + } + } + + return regLFSR; +} + + +/*********************************************************************** + * : pd_shift_right_WL + * : Ĵָλ + * : + * + * -------------------------------------------------------------- + * regLFSR UINT32 in Ĵ + * chan UINT8 in channel ID + * nshift UINT8 in ƶλ + * + * ȫֱ : gMaskLFSR[chan] LFSR mask + * ֵ : UINT32 λֵ + ***********************************************************************/ +static UINT32 pd_shl_fast_WL(UINT32 regLFSR, UINT8 chan, UINT8 nshift) +{ + UINT32 tmp = 0; + UINT8 shiftCount = 0; + UINT8 index = 0; + static UINT8 tabInitFlg[CHAN_NUM_WL] = {0}; + + /* ԿƱڻ */ + if( 1 != tabInitFlg[chan] ) + { + tabInitFlg[chan] = inittab_WL(chan); + } + + shiftCount = nshift >> 3; /* 8 */ + for(index = 0; index < shiftCount; index++) + { + tmp = regLFSR >> 24; + regLFSR <<= 8; + regLFSR &= 0x0FFFFFF00; + regLFSR ^= gTableFast_WL[chan][tmp&(UINT32)0xFF]; + } + return regLFSR; +} + +/*---------------------------------------------------------------------- + * LFSR End + *---------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------- + * RSSP֡֡ Start + *---------------------------------------------------------------------*/ + +/*********************************************************************** + * : CheckTimeStamp_WL + * : ԽձĽм飬Ƿʱ + * : + * + * -------------------------------------------------------------- + * nowTCr UINT32 in ǰյıʱ + * lastTCr UINT32 in ϴյıʱ + * maxLost UINT32 in ֵ + * + * ֵ : UINT32 + * <0 : ʧ + * >=0 : ֵ + ***********************************************************************/ +INT32 CheckTimeStamp_WL(UINT32 nowTCr, UINT32 lastTCr, UINT32 maxLost) +{ + INT32 ret = 0; + + ret = nowTCr - lastTCr - 1; /* */ + if (ret > (INT32)maxLost) + { + /* ֵ */ + ret = -1; + } + else if (ret < 0) + { + /* ɰ */ + ret = -2; + } + else + { + + } + + return ret; + +} +/*********************************************************************** + * : GetSidXorTn_WL + * : ȡBSDSID XOR TN ֵ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const UINT8* in BSD + * outSidXorTn UINT32[2] out Sid ^ T(n) + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 GetSidXorTn_WL(const UINT8* pBsdMsg,UINT32 outSidXorTn[CHAN_NUM_WL]) +{ + UINT8 ret = 1; /* ֵ 1: */ + UINT8 chan = 0; /* źŵ */ + UINT16 dataLen = 0; /* ݳ */ + UINT32 CRC[CHAN_NUM_WL] = {0}; /* ݵİȫCRC */ + UINT32 CRCM[CHAN_NUM_WL] = {0}; /* ĵCRCM */ + + if( NULL == (void *)pBsdMsg) /* null check */ + { + ret = 0; /* 󷵻 */ + return ret; + } + + + dataLen = ShortFromCharLE(&pBsdMsg[RSSP_DATA_SIZE_POS_WL])-2*CRCM_LEN_WL; /* ݳȻ */ + + for(chan = 0; chan < CHAN_NUM_WL; chan++) + { + /* CRC */ + if(0 == dataLen) + { + CRC[chan] = 0; + } else + { + CRC[chan] = CRC_Compute_Crc_WL(&pBsdMsg[RSSP_DATA_POS_WL], dataLen, chan); /* 32λCRC */ + } + + CRCM[chan] = LongFromCharLE(&pBsdMsg[RSSP_CRCM_1_POS_WL + chan * CRCM_LEN_WL]); /* ȡCRCM */ + + /* ĵ SID^T(n) */ + outSidXorTn[chan] = (CRCM[chan] ^ CRC[chan] ^ SYS_CHK_WD_WL[chan]); + } + return ret; +} + +/*********************************************************************** + * : CheckCRCM_WL + * : 鱨еCRCMSID^Tn()ȷԡ + * : + * + * -------------------------------------------------------------- + * sidXorTn const UINT32[2] in мSid^T(n) + * sinitAddSidXorTn const UINT32[2] in ϴεSINT Add (Sid ^ T(m)ֵ + * nDelayTCr UINT32 in + * POST_RXDAtA_K const UINT32[2][5] in ֵ߲POST_RXDATA_Kֵ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 CheckCRCM_WL(const UINT32 sidXorTn[CHAN_NUM_WL], + const UINT32 sinitAddSidXorTn[CHAN_NUM_WL], + UINT32 nDelayTCr, + const UINT32 postRxdataK[CHAN_NUM_WL][DSURSR_MAX_K_NUM_WL]) +{ + UINT32 regLFSR = 0; + UINT8 chan =0,index = 0; + UINT8 ret = 1; /* ֵ 1 */ + + /* POST_RXDATA_K */ + for(chan = 0; chan < CHAN_NUM_WL; chan++) + { + /* 0 Add (SINITr ADD [SIDr ^ T(n-k)] ADD 0 ....... ADD 0 ADD [SID ^ T(n)]) */ + regLFSR = F_LOAD_WL(regLFSR, sinitAddSidXorTn[chan]); + for(index = 0; index < nDelayTCr; index++) + { + regLFSR = F_ADD_WL(regLFSR, chan, 0); + } + regLFSR = F_ADD_WL(regLFSR,chan,sidXorTn[chan]); + regLFSR = F_ADD_WL(0,chan,regLFSR); + + /* CRCMȷ */ + if( F_READ_WL(regLFSR) != postRxdataK[chan][nDelayTCr]) + { + ret = 0; + break; + } + else + { + /* ʲô*/ + } + } + + return ret; +} + +/*********************************************************************** + * : CalcCRCM_WL + * : CRCMֵ + * : + * + * -------------------------------------------------------------- + * pData const UINT8 * in Ӧ + * DataLen UINT16 in Ӧݳ + * SID const UINT32[2] in ͷSID + * Tn const UINT32[2] in ǰʱ + * OutCRCM const UINT32[2] in CRCN + * + * pDataݳȱΪż + * + * ֵ : UINT8 1 1 + ***********************************************************************/ +UINT8 CalcCRCM_WL(const UINT8 *pData, UINT16 DataLen, const UINT32 SID[CHAN_NUM_WL], const UINT32 Tn[CHAN_NUM_WL], UINT32 OutCRCM[CHAN_NUM_WL]) +{ + UINT8 ret = 0; + UINT8 chan = 0; + UINT32 crc32[CHAN_NUM_WL] = {0}; + + /* */ + if(0 == DataLen) + { + for(chan = 0; chan < CHAN_NUM_WL; chan++) + { + OutCRCM[chan] = 0; + } + } + else + { + /* */ + for(chan = 0; chan < CHAN_NUM_WL; chan++) + { + crc32[chan] = CRC_Compute_Crc_WL(pData,DataLen,chan); /* 32λȫCRC */ + /* CRCM= CRC32 ^ SYSCKW ^ SID ^ Tn */ + OutCRCM[chan] = crc32[chan] ^ SYS_CHK_WD_WL[chan] ^ SID[chan] ^ Tn[chan]; + } + } + ret =1; + return ret; +} + + +/*********************************************************************** + * : UpdtTmStmpStru_WL + * : ϴεSinitAddSidXorTm㵱ǰıĵSinitAddSidXorTn + * Ҫ : 1 Result_A = SINIT ADD (SID ^ T(n-k)) ADD 0 ADD 0 ADD ....... ADD 0 ʡ K 0 Add ... + * 2 Result_B = PREC_SINIT_K(SIDSENDER) ADD (SID ^ T(n+1)) ADD (SID ^ T(n+1)) + * 3 SINIT ADD (SID ^ T(n)) = Result_A ^ Result_B + * : + * + * -------------------------------------------------------------- + * sidXorTn UINT32[2] in мSid^T(n) + * nowTCr UINT32 in ǰյĵʱ + * nDelayTCr UINT32 in + * precSinitK UINT32[2][5] in ֵֵ߲ + * pTmStmpStru_WL TimeStampStru* inout ʱṹ壬ϴյʱ估SINIT ADD (SID ^ Tn)ֵ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 UpdtTmStmpStru_WL(const UINT32 sidXorTn[CHAN_NUM_WL], + UINT32 nowRecvTCr, + UINT32 nDelayTCr, + const UINT32 precSinitK[CHAN_NUM_WL][DSURSR_MAX_K_NUM_WL], + TimeStampStru_WL* pTmStmpStru) +{ + UINT8 chan =0,index = 0; + UINT8 ret = 1; /* ֵ 1 */ + UINT32 resultA = 0, resultB = 0; + UINT32 regLFSR = 0; /* */ + + /* ʱṹָ */ + if( NULL == pTmStmpStru) + { + ret = 0; /* 󷵻 */ + return ret; + } + + /* ½ܱĵʱ */ + pTmStmpStru->LastRecvTCr = pTmStmpStru->NowRecvTCr; + pTmStmpStru->NowRecvTCr = nowRecvTCr; + + + /* ݹ Sinit Add Sid ^ T(n+k) */ + for(chan = 0; chan < CHAN_NUM_WL; chan++) + { + /* Result_A = SINIT ADD (SID ^ T(n-k)) ADD 0 ADD 0 ADD ....... ADD 0 ʡ K 0 Add ... */ + regLFSR = F_LOAD_WL(regLFSR,pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan]); /* load SINIT ADD (SID ^ T(n-k)) */ + for(index = 0; index < nDelayTCr + 2; index++) + { + regLFSR = F_ADD_WL(regLFSR, chan, 0); + } + resultA = F_READ_WL(regLFSR); + + /* Result_B = PREC_SINIT_K(SIDSENDER) ADD (SID ^ T(n+1)) ADD (SID ^ T(n+1)) */ + regLFSR = F_LOAD_WL(regLFSR, precSinitK[chan][nDelayTCr]); + regLFSR = F_ADD_WL(regLFSR,chan,sidXorTn[chan]); + regLFSR = F_ADD_WL(regLFSR,chan,sidXorTn[chan]); + resultB = F_READ_WL(regLFSR); + + /* + * SINIT ADD (SID ^ T(n)) + * SINIT ADD (SID ^ T(n)) = Result_A ^ Result_B + */ + pTmStmpStru->LastSINIT_ADD_SID_XOR_Tn[chan] = pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan]; + pTmStmpStru->NowSINIT_ADD_SID_XOR_Tn[chan] = resultA ^ resultB; + } + + return ret; +} + + +/*********************************************************************** + * : CalcFirstSinitAndSidXorTn_WL + * : ʼ SinitAddSidXorTmֵյSSRʱá + * : + * Ҫ : + * + * -------------------------------------------------------------- + * precFirstSinit const UINT32[2] in ָźŵӦPREC_FIRSTSINIT + * senqINI const UINT32[2] in ָźŵӦSSRSEQINIֵ + * enqTCn const UINT32[2] in ָźŵSSEʱڶӦʱ + * outSntAndSidXorTn UINT32[2] out + * + * ֵ : UINT8 1 + ***********************************************************************/ +UINT8 CalcFirstSinitAndSidXorTn_WL(const UINT32 precFirstSinit[CHAN_NUM_WL], + const UINT32 senqINI[CHAN_NUM_WL], + const UINT32 enqTCn[CHAN_NUM_WL], + UINT32 outSntAndSidXorTn[CHAN_NUM_WL]) +{ + UINT8 ret =0; + UINT32 regLFSR = 0; + UINT8 chan = 0; + for(chan = 0; chan < CHAN_NUM_WL;chan++) + { + regLFSR = F_LOAD_WL(regLFSR,precFirstSinit[chan]); + regLFSR = F_ADD_WL(regLFSR,chan,senqINI[chan]^enqTCn[chan]); + outSntAndSidXorTn[chan] = F_READ_WL(regLFSR); + } + ret =1; + return ret; +} + +/*********************************************************************** + * : AddTimeStamp_WL + * : 1Ӧʱ¡ + * : + * + * -------------------------------------------------------------- + * pTmStmpStru TimeStampStru_WL* inout ʱṹ һ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 AddTimeStamp_WL(TimeStampStru_WL *pTmStmp) +{ + UINT8 ret =1; + UINT8 chan; + UINT32 regLFSR = 0; /* 32λĴ */ + if(NULL == (void *)pTmStmp) + { + ret = 0; /* 󷵻 */ + } + else + { + pTmStmp->TC++; /* 1 */ + for(chan = 0; chan < CHAN_NUM_WL; chan++) + { + /* ¶Ӧڵʱ */ + pTmStmp->LastTn[chan] = pTmStmp->NowTn[chan]; + /* T(n+1) = T(n) ADD 0 */ + regLFSR = F_LOAD_WL(regLFSR, pTmStmp->NowTn[chan]); + regLFSR = F_ADD_WL(regLFSR, chan, 0); + pTmStmp->NowTn[chan] = F_READ_WL(regLFSR); + } + } + return ret; /* */ +} + + + +/*********************************************************************** + * : CRC_Compute_Crc_WL + * : 32λcrc㡣 + * : + * + * ----------------------------------------------------------- + * pData const UINT8* in Ҫ + * size UINT16 in ݴС + * chan UINT8 in źŵ + * + * ֵ : UINT32 õCRC + ***********************************************************************/ +UINT32 CRC_Compute_Crc_WL(const UINT8* pData, UINT16 size, UINT8 chan) +{ + UINT16 index; + UINT32 Result = 0; + UINT16 offset = 0U; + /*------------------------------------------------------------------------------ + * 32λCRCtable + *-----------------------------------------------------------------------------*/ + const UINT32 CrcmTab[2][256] = { + { + 0x00000000, 0x1942B361, 0x328566C2, 0x2BC7D5A3, 0x650ACD84, 0x7C487EE5, 0x578FAB46, 0x4ECD1827, + 0xCA159B08, 0xD3572869, 0xF890FDCA, 0xE1D24EAB, 0xAF1F568C, 0xB65DE5ED, 0x9D9A304E, 0x84D8832F, + 0x18CE5601, 0x018CE560, 0x2A4B30C3, 0x330983A2, 0x7DC49B85, 0x648628E4, 0x4F41FD47, 0x56034E26, + 0xD2DBCD09, 0xCB997E68, 0xE05EABCB, 0xF91C18AA, 0xB7D1008D, 0xAE93B3EC, 0x8554664F, 0x9C16D52E, + 0x319CAC02, 0x28DE1F63, 0x0319CAC0, 0x1A5B79A1, 0x54966186, 0x4DD4D2E7, 0x66130744, 0x7F51B425, + 0xFB89370A, 0xE2CB846B, 0xC90C51C8, 0xD04EE2A9, 0x9E83FA8E, 0x87C149EF, 0xAC069C4C, 0xB5442F2D, + 0x2952FA03, 0x30104962, 0x1BD79CC1, 0x02952FA0, 0x4C583787, 0x551A84E6, 0x7EDD5145, 0x679FE224, + 0xE347610B, 0xFA05D26A, 0xD1C207C9, 0xC880B4A8, 0x864DAC8F, 0x9F0F1FEE, 0xB4C8CA4D, 0xAD8A792C, + 0x63395804, 0x7A7BEB65, 0x51BC3EC6, 0x48FE8DA7, 0x06339580, 0x1F7126E1, 0x34B6F342, 0x2DF44023, + 0xA92CC30C, 0xB06E706D, 0x9BA9A5CE, 0x82EB16AF, 0xCC260E88, 0xD564BDE9, 0xFEA3684A, 0xE7E1DB2B, + 0x7BF70E05, 0x62B5BD64, 0x497268C7, 0x5030DBA6, 0x1EFDC381, 0x07BF70E0, 0x2C78A543, 0x353A1622, + 0xB1E2950D, 0xA8A0266C, 0x8367F3CF, 0x9A2540AE, 0xD4E85889, 0xCDAAEBE8, 0xE66D3E4B, 0xFF2F8D2A, + 0x52A5F406, 0x4BE74767, 0x602092C4, 0x796221A5, 0x37AF3982, 0x2EED8AE3, 0x052A5F40, 0x1C68EC21, + 0x98B06F0E, 0x81F2DC6F, 0xAA3509CC, 0xB377BAAD, 0xFDBAA28A, 0xE4F811EB, 0xCF3FC448, 0xD67D7729, + 0x4A6BA207, 0x53291166, 0x78EEC4C5, 0x61AC77A4, 0x2F616F83, 0x3623DCE2, 0x1DE40941, 0x04A6BA20, + 0x807E390F, 0x993C8A6E, 0xB2FB5FCD, 0xABB9ECAC, 0xE574F48B, 0xFC3647EA, 0xD7F19249, 0xCEB32128, + 0xC672B008, 0xDF300369, 0xF4F7D6CA, 0xEDB565AB, 0xA3787D8C, 0xBA3ACEED, 0x91FD1B4E, 0x88BFA82F, + 0x0C672B00, 0x15259861, 0x3EE24DC2, 0x27A0FEA3, 0x696DE684, 0x702F55E5, 0x5BE88046, 0x42AA3327, + 0xDEBCE609, 0xC7FE5568, 0xEC3980CB, 0xF57B33AA, 0xBBB62B8D, 0xA2F498EC, 0x89334D4F, 0x9071FE2E, + 0x14A97D01, 0x0DEBCE60, 0x262C1BC3, 0x3F6EA8A2, 0x71A3B085, 0x68E103E4, 0x4326D647, 0x5A646526, + 0xF7EE1C0A, 0xEEACAF6B, 0xC56B7AC8, 0xDC29C9A9, 0x92E4D18E, 0x8BA662EF, 0xA061B74C, 0xB923042D, + 0x3DFB8702, 0x24B93463, 0x0F7EE1C0, 0x163C52A1, 0x58F14A86, 0x41B3F9E7, 0x6A742C44, 0x73369F25, + 0xEF204A0B, 0xF662F96A, 0xDDA52CC9, 0xC4E79FA8, 0x8A2A878F, 0x936834EE, 0xB8AFE14D, 0xA1ED522C, + 0x2535D103, 0x3C776262, 0x17B0B7C1, 0x0EF204A0, 0x403F1C87, 0x597DAFE6, 0x72BA7A45, 0x6BF8C924, + 0xA54BE80C, 0xBC095B6D, 0x97CE8ECE, 0x8E8C3DAF, 0xC0412588, 0xD90396E9, 0xF2C4434A, 0xEB86F02B, + 0x6F5E7304, 0x761CC065, 0x5DDB15C6, 0x4499A6A7, 0x0A54BE80, 0x13160DE1, 0x38D1D842, 0x21936B23, + 0xBD85BE0D, 0xA4C70D6C, 0x8F00D8CF, 0x96426BAE, 0xD88F7389, 0xC1CDC0E8, 0xEA0A154B, 0xF348A62A, + 0x77902505, 0x6ED29664, 0x451543C7, 0x5C57F0A6, 0x129AE881, 0x0BD85BE0, 0x201F8E43, 0x395D3D22, + 0x94D7440E, 0x8D95F76F, 0xA65222CC, 0xBF1091AD, 0xF1DD898A, 0xE89F3AEB, 0xC358EF48, 0xDA1A5C29, + 0x5EC2DF06, 0x47806C67, 0x6C47B9C4, 0x75050AA5, 0x3BC81282, 0x228AA1E3, 0x094D7440, 0x100FC721, + 0x8C19120F, 0x955BA16E, 0xBE9C74CD, 0xA7DEC7AC, 0xE913DF8B, 0xF0516CEA, 0xDB96B949, 0xC2D40A28, + 0x460C8907, 0x5F4E3A66, 0x7489EFC5, 0x6DCB5CA4, 0x23064483, 0x3A44F7E2, 0x11832241, 0x08C19120}, + { + 0x00000000, 0x1EF09C7E, 0x3DE138FC, 0x2311A482, 0x7BC271F8, 0x6532ED86, 0x46234904, 0x58D3D57A, + 0xF784E3F0, 0xE9747F8E, 0xCA65DB0C, 0xD4954772, 0x8C469208, 0x92B60E76, 0xB1A7AAF4, 0xAF57368A, + 0xFF048983, 0xE1F415FD, 0xC2E5B17F, 0xDC152D01, 0x84C6F87B, 0x9A366405, 0xB927C087, 0xA7D75CF9, + 0x08806A73, 0x1670F60D, 0x3561528F, 0x2B91CEF1, 0x73421B8B, 0x6DB287F5, 0x4EA32377, 0x5053BF09, + 0xEE045D65, 0xF0F4C11B, 0xD3E56599, 0xCD15F9E7, 0x95C62C9D, 0x8B36B0E3, 0xA8271461, 0xB6D7881F, + 0x1980BE95, 0x077022EB, 0x24618669, 0x3A911A17, 0x6242CF6D, 0x7CB25313, 0x5FA3F791, 0x41536BEF, + 0x1100D4E6, 0x0FF04898, 0x2CE1EC1A, 0x32117064, 0x6AC2A51E, 0x74323960, 0x57239DE2, 0x49D3019C, + 0xE6843716, 0xF874AB68, 0xDB650FEA, 0xC5959394, 0x9D4646EE, 0x83B6DA90, 0xA0A77E12, 0xBE57E26C, + 0xCC05F4A9, 0xD2F568D7, 0xF1E4CC55, 0xEF14502B, 0xB7C78551, 0xA937192F, 0x8A26BDAD, 0x94D621D3, + 0x3B811759, 0x25718B27, 0x06602FA5, 0x1890B3DB, 0x404366A1, 0x5EB3FADF, 0x7DA25E5D, 0x6352C223, + 0x33017D2A, 0x2DF1E154, 0x0EE045D6, 0x1010D9A8, 0x48C30CD2, 0x563390AC, 0x7522342E, 0x6BD2A850, + 0xC4859EDA, 0xDA7502A4, 0xF964A626, 0xE7943A58, 0xBF47EF22, 0xA1B7735C, 0x82A6D7DE, 0x9C564BA0, + 0x2201A9CC, 0x3CF135B2, 0x1FE09130, 0x01100D4E, 0x59C3D834, 0x4733444A, 0x6422E0C8, 0x7AD27CB6, + 0xD5854A3C, 0xCB75D642, 0xE86472C0, 0xF694EEBE, 0xAE473BC4, 0xB0B7A7BA, 0x93A60338, 0x8D569F46, + 0xDD05204F, 0xC3F5BC31, 0xE0E418B3, 0xFE1484CD, 0xA6C751B7, 0xB837CDC9, 0x9B26694B, 0x85D6F535, + 0x2A81C3BF, 0x34715FC1, 0x1760FB43, 0x0990673D, 0x5143B247, 0x4FB32E39, 0x6CA28ABB, 0x725216C5, + 0x8806A731, 0x96F63B4F, 0xB5E79FCD, 0xAB1703B3, 0xF3C4D6C9, 0xED344AB7, 0xCE25EE35, 0xD0D5724B, + 0x7F8244C1, 0x6172D8BF, 0x42637C3D, 0x5C93E043, 0x04403539, 0x1AB0A947, 0x39A10DC5, 0x275191BB, + 0x77022EB2, 0x69F2B2CC, 0x4AE3164E, 0x54138A30, 0x0CC05F4A, 0x1230C334, 0x312167B6, 0x2FD1FBC8, + 0x8086CD42, 0x9E76513C, 0xBD67F5BE, 0xA39769C0, 0xFB44BCBA, 0xE5B420C4, 0xC6A58446, 0xD8551838, + 0x6602FA54, 0x78F2662A, 0x5BE3C2A8, 0x45135ED6, 0x1DC08BAC, 0x033017D2, 0x2021B350, 0x3ED12F2E, + 0x918619A4, 0x8F7685DA, 0xAC672158, 0xB297BD26, 0xEA44685C, 0xF4B4F422, 0xD7A550A0, 0xC955CCDE, + 0x990673D7, 0x87F6EFA9, 0xA4E74B2B, 0xBA17D755, 0xE2C4022F, 0xFC349E51, 0xDF253AD3, 0xC1D5A6AD, + 0x6E829027, 0x70720C59, 0x5363A8DB, 0x4D9334A5, 0x1540E1DF, 0x0BB07DA1, 0x28A1D923, 0x3651455D, + 0x44035398, 0x5AF3CFE6, 0x79E26B64, 0x6712F71A, 0x3FC12260, 0x2131BE1E, 0x02201A9C, 0x1CD086E2, + 0xB387B068, 0xAD772C16, 0x8E668894, 0x909614EA, 0xC845C190, 0xD6B55DEE, 0xF5A4F96C, 0xEB546512, + 0xBB07DA1B, 0xA5F74665, 0x86E6E2E7, 0x98167E99, 0xC0C5ABE3, 0xDE35379D, 0xFD24931F, 0xE3D40F61, + 0x4C8339EB, 0x5273A595, 0x71620117, 0x6F929D69, 0x37414813, 0x29B1D46D, 0x0AA070EF, 0x1450EC91, + 0xAA070EFD, 0xB4F79283, 0x97E63601, 0x8916AA7F, 0xD1C57F05, 0xCF35E37B, 0xEC2447F9, 0xF2D4DB87, + 0x5D83ED0D, 0x43737173, 0x6062D5F1, 0x7E92498F, 0x26419CF5, 0x38B1008B, 0x1BA0A409, 0x05503877, + 0x5503877E, 0x4BF31B00, 0x68E2BF82, 0x761223FC, 0x2EC1F686, 0x30316AF8, 0x1320CE7A, 0x0DD05204, + 0xA287648E, 0xBC77F8F0, 0x9F665C72, 0x8196C00C, 0xD9451576, 0xC7B58908, 0xE4A42D8A, 0xFA54B1F4} + }; + + /*------------------------------------------------------------------------------ + * ת + *-----------------------------------------------------------------------------*/ + const UINT8 Reflected_Byte[] = { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, + 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, + 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, + 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, + 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, + 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, + 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, + 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, + 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, + 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, + 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, + 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, + 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, + 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, + 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, + 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, + 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF + }; + + for(index=0; index < size; index++) + { + Result = (Result >> 8) ^ CrcmTab[chan][(Result ^ Reflected_Byte[pData[offset]]) & 0xFF]; + offset++; + } + + return Result; +} + +/*********************************************************************** + * : ComputeMsgCRC16_WL + * : 16λǰȫcrc㡣 + * : + * + * ----------------------------------------------------------- + * pData const UINT8* in Ҫ + * size UINT16 in ݴС + * + * ֵ : UINT16 õCRC + ***********************************************************************/ +UINT16 ComputeMsgCRC16_WL(const UINT8* pData, UINT16 size) +{ + UINT8 BitCount = 0; + UINT8 tmpByteData = 0; + UINT16 ActByte = 0, CompCRC = 0; + UINT16 offset = 0U; + const UINT16 MSG_CRC_MASK = 0x8810; /* Polynomial for message CRC X25 */ + + while(size > 0) + { + tmpByteData = pData[offset]; + ActByte = (UINT16)tmpByteData; + for(BitCount=8; BitCount>0; BitCount--) + { + if((ActByte ^ CompCRC) & 1) + { + CompCRC = (CompCRC >> 1) ^ MSG_CRC_MASK; + } + else + { + CompCRC >>= 1; + } + ActByte >>= 1; + } + offset++; + size--; + } + + return(CompCRC); +} + +/*********************************************************************** + * : RsspMemSet_WL + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pDestAdd UINT8 * INOUT ڴռ俪ʼַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : 1 + ***********************************************************************/ +UINT8 RsspMemSet_WL(UINT8 *pDestAdd, UINT16 Len, UINT8 Val) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = Val; + } + + return (UINT8)1; +} + +/*********************************************************************** + * : RsspMemCopy_WL + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pSrcAdd const UINT8 * IN Դڴռַ + * pDestAdd UINT8 * INOUT Ŀڴռַ + * Len UINT16 IN ڴռС + * + * ֵ : 1 + ***********************************************************************/ +UINT8 RsspMemCopy_WL(const UINT8 *pSrcAdd,UINT8 *pDestAdd, UINT16 Len) +{ + UINT16 index = 0; + + for(index = 0; index < Len; index++) + { + pDestAdd[index] = pSrcAdd[index]; + } + + return (UINT8)1; +} + +/*********************************************************************** + * : TypeId2DevName_WL + * : TypeID ȡӦ豸ʶ + * : + * + * -------------------------------------------------------------- + * Type UINT8 IN + * ID UINT8 IN Id + * pDevName UINT16* OUT ʶ + * + * ֵ : + ***********************************************************************/ +void TypeId2DevName_WL(UINT8 Type, UINT8 Id, UINT16* pDevName) +{ +#ifdef TYPE_ID_2_DEVNAME_USE_COMM_WL + UINT8 buff[2]; + buff[0] = Type; + buff[1] = Id; + + *pDevName = ShortFromChar(buff); +#else + *pDevName = Type; + *pDevName = (*pDevName)*0x100 + Id; +#endif + return; +} +/*********************************************************************** + * : DevName2TypeId_WL + * : ȡӦͺId + * : + * + * -------------------------------------------------------------- + * DevName UINT8 IN ʶ + * pType UINT8* OUT + * pID UINT8* OUT Id + * + * ֵ : + ***********************************************************************/ +void DevName2TypeId_WL(UINT16 DevName, UINT8* pType,UINT8* pId) +{ +#ifdef TYPE_ID_2_DEVNAME_USE_COMM_WL + UINT8 buff[2]; + ShortToChar(DevName,buff); + *pType = buff[0]; + *pId = buff[1]; +#else + *pId = (UINT8)(DevName % 0x100); + *pType =(UINT8)(DevName /0x100); +#endif + return; +} + +/*---------------------------------------------------------------------- + * RSSP֡֡ END + *---------------------------------------------------------------------*/ + + /* + * ջʼڳʼһջStackFreeʹ + * ҪΪջռ䣬жջڲʼ + * ˵ CommonStackWl *pStack, ʼĵĶջ + * UINT32 TotalSize, ջС + * ֵ 1ɹ + * 0ʧ + */ +UINT8 StackInitialWl(CommonStackWl* pStack, UINT16 TotalSize) +{ + UINT8 bRet = 0;/*ں*/ + + /*ֵж*/ + if ((NULL != pStack) && (0 != TotalSize)) + { + /*ֵϷ*/ + + /*ջݳʼ */ + pStack->TotalSize = TotalSize; + pStack->Top = 0; + + /*ջռ*/ + pStack->pStackData = (STACK_DATA_TYPE_WL*)malloc(sizeof(STACK_DATA_TYPE_WL) * (pStack->TotalSize)); + if (pStack->pStackData != NULL) + { + /*ɹʼ*/ + bRet = 1; + } + else + { + /*ջʼռʧܣʧ*/ + bRet = 0; + } + } + else + { + /*ֵϷʧ*/ + + bRet = 0; + } + + return bRet; + +} + +/****************************************************************************************** +* : ӶջеջԪأ +* : +* : CommonStackWl *pStack ջָ +* : STACK_DATA_TYPE_WL* pData ջԪ +* ȫֱ : +* ֵ : ɹ1򷵻0 +*******************************************************************************************/ +UINT8 StackPopWl(CommonStackWl* pStack, STACK_DATA_TYPE_WL* pData)/* %RELAX */ +{ + UINT8 ret;/*ں*/ + + if (pStack->Top > 0) + { + /*ջ*/ + + /*ջԪ*/ + pStack->Top--; + *pData = pStack->pStackData[pStack->Top]; + + /*ִгɹ*/ + ret = 1; + return ret; + } + else + { + /*ջݣʧ*/ + ret = 0; + return ret; + } +} + +/****************************************************************************************** +* : ջѹһ +* : STACK_DATA_TYPE_WL Data ջ +* : CommonStackWl *pStack ջָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 StackPushWl(CommonStackWl* pStack, STACK_DATA_TYPE_WL Data)/* %RELAX */ +{ + UINT8 ret;/*ں*/ + + if (pStack->Top < pStack->TotalSize) + { + /*ջССڶջֵʱѹջ*/ + + /*ѹջ*/ + pStack->pStackData[pStack->Top] = Data; + pStack->Top++; + + ret = 1; + return ret; + } + else + { + /*ջСڶջֵ,ѹջ.*/ + + ret = 0; + return ret;/*޷ѹջԪ*/ + } +} + +/* +* ջ洢ռͷź +* ڲҪijջʱ򣬰Ѷջݴ洢ռͷŵ,StackInitialʹ +* ˵ CommonStackWl *pStack, ջָ +* ֵ 1ɹ +*/ +UINT8 StackFreeWl(CommonStackWl* pStack) +{ + + UINT8 ret = 1;/*ں*/ + + /*ջָλ*/ + pStack->Top = 0; + pStack->TotalSize = 0; + + /*ͷŶջռ*/ + if (pStack->pStackData != NULL) + { + free(pStack->pStackData); + pStack->pStackData = NULL; + } + + return ret; +} + +/* +* ջ洢ռԪظ +* ˵ CommonStackWl *pStack, ջָ +* ֵ ջԪظ +*/ +UINT16 StackStatusWl(CommonStackWl* pStack) +{ + return pStack->Top; +} \ No newline at end of file diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspCommonWl.h b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspCommonWl.h new file mode 100644 index 0000000..8a2b771 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspCommonWl.h @@ -0,0 +1,429 @@ +/************************************************************************ +* +* ļ RsspCommonWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ 2009.10.02 +* ؼЭ鲿 +* RSSPЭʹõFLSR麯. +* ʹע ʹ֮ǰinittab_WLgTableFast_WLֵ趨 +* ޸ļ¼ +* ʱ ޸ ޸ +*--------------------------------------------- +* 2009/11/01 ¥ΰ +* 2009/12/02 ¥ΰ MisraCӦ +* 2013/03/01 ޸CIVOBCĶ壬ɾZCĶ +************************************************************************/ + +#ifndef _RSSP_COMMONWL_H_ +#define _RSSP_COMMONWL_H_ + +#include "CommonTypes.h" +#include "dsuRsspDataStru.h" +#include "RsspConfigWl.h" + +#ifndef NULL +#define NULL 0 +#endif + + +/* */ +#define RSSP_TYPE_VOBC_BACK_WL (0x13) /*VOBC-ͨ*/ +#define RSSP_TYPE_VOBC_WL 0x14 /*VOBC*/ +#define RSSP_TYPE_AOM_WL 0x15 /*AOM*/ +#define RSSP_TYPE_ATS_WL 0x03 /*ATS*/ +#define RSSP_TYPE_TTIL_WL 0x17 /*β*/ + +#define TYPE_ID_2_DEVNAME_USE_COMM_WL /* TRUE Type Id תΪʶ ʹùͨת */ + +/* ڲʹò */ +#define CHAN_NUM_WL 2 /* channel */ + +/* Ϣ */ +#define RSSP_SSE_MSG_WL ((UINT8)0x90) /* SSE Ϣ */ +#define RSSP_SSR_MSG_WL ((UINT8)0x91) /* SSR Ϣ */ +#define RSSP_RSD_MSG_WL ((UINT8)0x80) /* RSD Ϣ */ +#define RSSP_RSD_MSG_WL_B ((UINT8)0x81) /* B͵ RSD Ϣ */ + +#define RSSPI_TYPE_IN_ADAPTER (0x04) /*RSSPI*/ +#define SVC_ARRAY_MAX_LEN ((UINT16)(4*255)) /*255·*/ + +/* ó */ +#define RSSP_HEAD_LEN_WL 6 /* ֡ͷ */ +#define TC_LEN_WL 4 /* ij */ +#define CRC_16_LEN_WL 2 /* CRC 16λ ij */ + +/* Application Category */ +#define RSSP_APP_CATEGORY_WL 0x01 /* Signaling Variables */ + +/* ֡ͷ */ +#define RSSP_APP_CTGRY_POS_WL 0 /* ֡ͷӦλ*/ +#define RSSP_MSG_TYPE_POS_WL (RSSP_APP_CTGRY_POS_WL+1) /* ֡ͷϢ */ +#define RSSP_SRC_ADD_POS_WL (RSSP_MSG_TYPE_POS_WL+1) /* RSSPϢԴַ */ +#define RSSP_DEST_ADD_POS_WL (RSSP_SRC_ADD_POS_WL+2) /* RSSPϢĿַ */ + +#define RSSP_TC_POS_WL RSSP_HEAD_LEN_WL /* RSSPļλ */ + +/* SSE */ +#define RSSP_SSE_ENQ_LEN_WL 4 /* SSE SEQENQ */ +#define RSSP_SSE_ENQ_1_POS_WL (RSSP_TC_POS_WL+TC_LEN_WL) /* SSE SEQENQ_1λ */ +#define RSSP_SSE_ENQ_2_POS_WL (RSSP_SSE_ENQ_1_POS_WL+RSSP_SSE_ENQ_LEN_WL) /* SSE SEQENQ_2λ */ + + +/* SSR */ +#define RSSP_SSR_INI_LEN_WL 4 /* SSR SEQINI */ +#define RSSP_SSR_NUM_LEN_WL 1 /* SSRNum DataVer */ +#define RSSP_SSR_TCENQ_POS_WL (RSSP_TC_POS_WL+TC_LEN_WL) /* SSR λ */ +#define RSSP_SSR_INI_1_POS_WL (RSSP_SSR_TCENQ_POS_WL+TC_LEN_WL) /* SSR SEQINI_1λ */ +#define RSSP_SSR_INI_2_POS_WL (RSSP_SSR_INI_1_POS_WL+RSSP_SSR_INI_LEN_WL) /* SSR SEQINI_2λ */ +#define RSSP_SSR_NUM_POS_WL (RSSP_SSR_INI_2_POS_WL+RSSP_SSR_INI_LEN_WL) /* SSRNum DataVer λ */ + +/* RSD */ +#define CRCM_LEN_WL 4 /* crc ֶ֤εĴС */ +#define DATASIZE_LEN_WL 2 /* ݳֶεĴС */ +#define RSSP_DATA_SIZE_POS_WL (RSSP_TC_POS_WL + TC_LEN_WL) /* аȫݳȱλ */ +#define RSSP_CRCM_1_POS_WL (RSSP_DATA_SIZE_POS_WL + DATASIZE_LEN_WL) /* CRCM_1λ */ +#define RSSP_CRCM_2_POS_WL (RSSP_CRCM_1_POS_WL + CRCM_LEN_WL) /* CRCM_2λ */ +#define RSSP_DATA_POS_WL (RSSP_CRCM_2_POS_WL + CRCM_LEN_WL) /* ȫݳȱλ */ + +/* RSSPϢ̶ */ +#define RSSP_SSE_LEN_WL (RSSP_SSE_ENQ_2_POS_WL+RSSP_SSE_ENQ_LEN_WL+CRC_16_LEN_WL) /* SSE */ +#define RSSP_SSR_LEN_WL (RSSP_SSR_NUM_POS_WL+RSSP_SSR_NUM_LEN_WL+CRC_16_LEN_WL) /* SSR */ +#define RSSP_FIXED_LEN_WL (RSSP_DATA_POS_WL+CRC_16_LEN_WL) /* RSSPϢ̶ֳ */ + +/* */ +#define SEND_SSE_NUM_WL 3 /* ȴSSRʱ෢SSE */ +#define NONE_SEND_APP_DATA_WL 3 /* ޷Ӧ */ + +#define RP_LINK_LEN (14) /*·*/ + +#ifdef RSSPI_SIMPLE_LINK_REFRESH +#define RSSP_VAR_NODE_LEN_WL (58) /*·ˢ,мһڵij*/ +#else +#define RSSP_VAR_NODE_LEN_WL (87) /*мһڵij*/ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/*********************************************************************** + * ṹʱṹ + * Ӣ TimeStampStru_WL + * ; RSSPڵշĵʱĻϢ + **********************************************************************/ +typedef struct +{ + UINT32 TC; /* ǰʱ */ + UINT32 LastLocalRecTC; /* ϴյıʱ */ + UINT32 NowTn[2]; /* ǰڶӦʱ */ + UINT32 LastTn[2]; /* ϸڶӦʱ */ + UINT32 LastRecvTCr; /* ϴνյͷʱ */ + UINT32 NowRecvTCr; /* ǰյͷʱ */ + UINT32 SseTC; /* SSEʱں */ + UINT32 SseTn[2]; /* SSEʱڶӦʱ */ + UINT32 RecvSseTCe; /* SSEĵĶԷʱ */ + UINT32 SeqEng[2]; /* յSSEʱSEQENQ */ + UINT8 NumSendSse; /* SSE */ + UINT32 SsrTc; /* ϴͬ */ + UINT32 NowSINIT_ADD_SID_XOR_Tn[2]; /* ǰյʱ SINITr AND [SIDr ^ Tr(n)] */ + UINT32 LastSINIT_ADD_SID_XOR_Tn[2]; /* ϴյʱSINITr AND [SIDr ^ Tr(n)] */ +} TimeStampStru_WL; + + +typedef void* STACK_DATA_TYPE_WL; + +/*ջṹ嶨*/ +typedef struct +{ + void** pStackData; /*нڵֵʾǴ洢ݵĿռ*/ + UINT16 Top; /*ĿǰջĴС.ͬʱֵҲǰջ,дԪҪŵ±. + ڱջһ˳ջ,˳ջдֵӦdzʼΪ, + ֮,0STACK_MAXSIZE-1.*/ + UINT16 TotalSize; /*˶ջܹŽڵ*/ +} CommonStackWl; + +/*---------------------------------------------------------------------- + * LFSR Start + *---------------------------------------------------------------------*/ +UINT32 F_ADD_WL(UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 F_SUB_WL(UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 F_POST_WL(UINT32 regLFSR, UINT8 chan, UINT32 val); +UINT32 F_XOR_WL(UINT32 regLFSR, UINT32 val); +UINT32 F_LOAD_WL(UINT32 regLFSR, UINT32 val); +UINT32 F_READ_WL(UINT32 regLFSR); + +/*---------------------------------------------------------------------- + * End + *---------------------------------------------------------------------*/ + + +/*********************************************************************** + * : CheckTimeStamp_WL + * : ԽձĽм,Ƿʱ + * : + * + * -------------------------------------------------------------- + * nowTCr UINT32 in ǰյıʱ + * lastTCr UINT32 in ϴյıʱ + * maxLost UINT32 in ֵ + * + * ֵ : UINT32 + * <0 : ʧ + * >=0 : ֵ + ***********************************************************************/ +INT32 CheckTimeStamp_WL(UINT32 nowTCr, UINT32 lastTCr, UINT32 maxLost); + + +/*********************************************************************** + * : GetSidXorTn_WL + * : ȡBSDSID XOR TN ֵ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const UINT8* in BSD + * outSidXorTn UINT32[2] out Sid ^ T(n) + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 GetSidXorTn_WL(const UINT8* pBsdMsg,UINT32 outSidXorTn[CHAN_NUM_WL]); + + +/*********************************************************************** + * : CheckCRCM_WL + * : 鱨еCRCMSID^Tn()ȷԡ + * : + * + * -------------------------------------------------------------- + * sidXorTn const UINT32[2] in мSid^T(n) + * sinitAddSidXorTn const UINT32[2] in ϴεSINT Add (Sid ^ T(m)ֵ + * nDelayTCr UINT32 in + * POST_RXDAtA_K const UINT32[2][5] in ֵ߲,ֵ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 CheckCRCM_WL(const UINT32 sidXorTn[CHAN_NUM_WL], + const UINT32 sinitAddSidXorTn[CHAN_NUM_WL], + UINT32 nDelayTCr, + const UINT32 postRxdataK[CHAN_NUM_WL][DSURSR_MAX_K_NUM_WL]); + +/*********************************************************************** + * : IsRedunRcvMsg + * : 鱨ӦͺϢǷΪRSSPģԼԱĵĽCRC֤ + * : + * + * -------------------------------------------------------------- + * MsgLen const UINT16 in ij + * pData const UINT8 in ģ16λCRC + * + * ֵ : UINT8 1RSSP 0:RSSP + ***********************************************************************/ +UINT8 IsRedunRcvMsg(UINT16 MsgLen, const UINT8 pData[], UINT8* recordArray, UINT16 recordArraySize); + +/*********************************************************************** + * : CalcCRCM_WL + * : CRCMֵ + * : + * + * -------------------------------------------------------------- + * pData const UINT8 * in Ӧ + * DataLen UINT16 in Ӧݳ + * SID const UINT32[2] in ͷSID + * Tn const UINT32[2] in ǰʱ + * OutCRCM const UINT32[2] in CRCN + * + * pDataݳȱΪż + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 CalcCRCM_WL(const UINT8 *pData, UINT16 DataLen, const UINT32 SID[CHAN_NUM_WL], const UINT32 Tn[CHAN_NUM_WL], UINT32 OutCRCM[CHAN_NUM_WL]); + +/*********************************************************************** + * : UpdtTmStmpStru_WL + * : ϴεSinitAddSidXorTm㵱ǰıĵSinitAddSidXorTn + * : + * + * -------------------------------------------------------------- + * sidXorTn const UINT32[2] in мSid^T(n) + * nowTCr UINT32 in ǰյĵʱ + * nDelayTCr UINT32 in + * precSinitK const UINT32[2][5] in ֵ߲,ֵ + * pTmStmpStru TimeStampStru_WL* inout ʱṹ,ϴյʱ估SINIT ADD (SID ^ Tn)ֵ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 UpdtTmStmpStru_WL(const UINT32 sidXorTn[CHAN_NUM_WL], + UINT32 nowRecvTCr, + UINT32 nDelayTCr, + const UINT32 precSinitK[CHAN_NUM_WL][DSURSR_MAX_K_NUM_WL], + TimeStampStru_WL* pTmStmpStru); + +/*********************************************************************** + * : CalcFirstSinitAndSidXorTn_WL + * : ʼ SinitAddSidXorTmֵյSSRʱá + * : + * + * -------------------------------------------------------------- + * precFirstSinit const UINT32[2] in ָźŵӦPREC_FIRSTSINIT + * senqINI const UINT32[2] in ָźŵӦSSRSEQINIֵ + * enqTCn const UINT32[2] in ָźŵSSEʱڶӦʱ + * outSntAndSidXorTn UINT32[2] out + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 CalcFirstSinitAndSidXorTn_WL(const UINT32 precFirstSinit[CHAN_NUM_WL], + const UINT32 senqINI[CHAN_NUM_WL], + const UINT32 enqTCn[CHAN_NUM_WL], + UINT32 outSntAndSidXorTn[CHAN_NUM_WL]); + + +/*********************************************************************** + * : AddTimeStamp_WL + * : 1,Ӧʱ¡ + * : + * + * -------------------------------------------------------------- + * pTmStmpStru TimeStampStru_WL* inout ʱṹ һ + * + * ֵ : UINT8 1 0:쳣 + ***********************************************************************/ +UINT8 AddTimeStamp_WL(TimeStampStru_WL *pTmStmp); + + +/*********************************************************************** + * : CRC_Compute_Crc_WL + * : 32λcrc㡣 + * : + * + * ----------------------------------------------------------- + * pData const UINT8* in Ҫ + * size UINT16 in ݴС + * chan UINT8 in źŵ + * + * ֵ : UINT32 õCRC + ***********************************************************************/ +UINT32 CRC_Compute_Crc_WL(const UINT8* pData, UINT16 size, UINT8 chan); + + +/*********************************************************************** + * : ComputeMsgCRC16_WL + * : 16λǰȫcrc㡣 + * : + * + * ----------------------------------------------------------- + * pData const UINT8* in Ҫ + * size UINT16 in ݴС + * + * ֵ : UINT16 õCRC + ***********************************************************************/ +UINT16 ComputeMsgCRC16_WL(const UINT8* pData, UINT16 size); + + +/*********************************************************************** + * : RsrMemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pDestAdd UINT8 * INOUT ڴռ俪ʼַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : + ***********************************************************************/ +UINT8 RsspMemSet_WL(UINT8 *pDestAdd, UINT16 Len, UINT8 Val); + +/*********************************************************************** + * : RsrMemSet + * : ָڴ趨ֵָ + * : + * + * -------------------------------------------------------------- + * pSrcAdd const UINT8 * IN Դڴռַ + * pDestAdd UINT8 * INOUT Ŀڴռַ + * Len UINT16 IN ڴռС + * Val UINT8 IN ֵָ + * + * ֵ : + ***********************************************************************/ +UINT8 RsspMemCopy_WL(const UINT8 *pSrcAdd,UINT8 *pDestAdd, UINT16 Len); + +/*********************************************************************** + * : TypeId2DevName_WL + * : TypeID ȡӦ豸ʶ + * : + * + * -------------------------------------------------------------- + * Type UINT8 IN + * ID UINT8 IN Id + * pDevName UINT16* OUT ʶ + * + * ֵ : + ***********************************************************************/ +void TypeId2DevName_WL(UINT8 Type, UINT8 Id, UINT16* pDevName); + +/*********************************************************************** + * : DevName2TypeId_WL + * : ȡӦͺId + * : + * + * -------------------------------------------------------------- + * DevName UINT16 IN ʶ + * pType UINT8* OUT + * pID UINT8* OUT Id + * + * ֵ : + ***********************************************************************/ +void DevName2TypeId_WL(UINT16 DevName,UINT8* pType, UINT8* pId); + +/* +* ջʼڳʼһջStackFreeʹ +* ҪΪջռ䣬жջڲʼ +* ˵ CommonStackWl *pStack, ʼĵĶջ +* UINT32 TotalSize, ջС +* ֵ 1ɹ +* 0ʧ +*/ +UINT8 StackInitialWl(CommonStackWl* pStack, UINT16 TotalSize); + +/****************************************************************************************** +* : ӶջеջԪأ +* : +* : CommonStackWl *pStack ջָ +* : STACK_DATA_TYPE_WL* pData ջԪ +* ȫֱ : +* ֵ : ɹ1򷵻0 +*******************************************************************************************/ +UINT8 StackPopWl(CommonStackWl* pStack, STACK_DATA_TYPE_WL* pData); + +/****************************************************************************************** +* : ջѹһ +* : STACK_DATA_TYPE_WL Data ջ +* : CommonStackWl *pStack ջָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 StackPushWl(CommonStackWl* pStack, STACK_DATA_TYPE_WL Data); + +/* +* ջ洢ռͷź +* ڲҪijջʱ򣬰Ѷջݴ洢ռͷŵ,StackInitialʹ +* ˵ CommonStackWl *pStack, ջָ +* ֵ 1ɹ +*/ +UINT8 StackFreeWl(CommonStackWl* pStack); + +/* +* ջ洢ռԪظ +* ˵ CommonStackWl *pStack, ջָ +* ֵ ջԪظ +*/ +UINT16 StackStatusWl(CommonStackWl* pStack); + +#ifdef __cplusplus +} +#endif + +#endif /* endif */ diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspIFWl.h b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspIFWl.h new file mode 100644 index 0000000..1d7c3f2 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspIFWl.h @@ -0,0 +1,127 @@ +/******************************************************** +* +* ļ RsspIFWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* Rsspӿڶ +* ʹע⣺ +* +* ޸ļ¼ +* +********************************************************/ + +#ifndef _RSSP_IFWL_H_ +#define _RSSP_IFWL_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "RsspWl.h" +#include "RsspStructWl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +*: RsspReceive_WL +*: RSSPI봦 +*: RSSP_INFO_STRU* rssp RSSPIṹ +*: +*: +*ֵ: Ƿɹ,0:ɹ,1:ɹ +*/ +UINT8 RsspReceive_WL(RSSP_INFO_STRU* rssp); + +/** + * @brief RsspOutput_WL RSSPI + * @param AppToRs ӦøЭݶ ȡֵΧ:οṹQueueStruct + * @param VarArray · ȡֵΧ:ֽ + * @param pRsspStru RSSPIʵ ȡֵΧ:οṹRSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ +UINT8 RsspOutput_WL(QueueStruct *AppToRs,UINT8 *VarArray,RSSP_INFO_STRU *pRsspStru); + +/*********************************************************************** + * : RsspInit_WL + * : ͨúʵֶRSSPijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspInit_WL(RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : RsspFreeSpace_WL + * : ͨúͷRSSP㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspFreeSpace_WL(RSSP_INFO_STRU *pRsspStruct); + +/* +*: RsspLnkStatus_WL +*: õijȫܽڵڱڵͨ״̬ +* ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ +* ijȫսڵ㣬򷵻ش +*: UINT8 dstType Ŀ +* UINT8 dstId ĿID +* UINT16 dstLogicId Ŀ߼ID +* RSSP_INFO_STRU *pRsspi RSSPIϢ +*: +*: ·״̬ 0x17:,0x2b:ͨŲ +*ֵ: +*/ +UINT8 RsspLnkStatus_WL(UINT8 dstType, UINT8 dstId, UINT16 dstLogicId, RSSP_INFO_STRU *pRsspi); + +/*********************************************************************** + * : RsspLnkDelete_WL + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * devName UINT32* OUT 豸 + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspLnkDelete_WL(UINT32 destDevName,RSSP_INFO_STRU *pRsspStruct); + +/** + * @brief RsspRefresh_WL ˢ· + * @param VarLen ·ݳ ȡֵΧ:0x0000-0xFFFF + * @param VarArray · ȡֵΧ:ֽ + * @param pRsspStruct RSSPIʵ ȡֵΧ:οṹ:RSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ +UINT8 RsspRefresh_WL(UINT16 VarLen, const UINT8 *VarArray, RSSP_INFO_STRU *pRsspStruct); + +/* +*: ȡRSSPIյ +*: RSSP_INFO_STRU* rsspi rsspi +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void GetNetsRecvPkgNum_WL(RSSP_INFO_STRU* rsspi, const UINT16 dstAddr, UINT16* redPkgNum, UINT16* bluePkgNum); + +/*-------------------------------------------------------------------- + * RSSPӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspInitWl.c b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspInitWl.c new file mode 100644 index 0000000..a9e89fb --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspInitWl.c @@ -0,0 +1,174 @@ +/******************************************************** +* ļ RsspInitWl.h +* Ȩ˵ +* 汾 1.0 +* ʱ䣺 2013.3.1 +* ؼЭ鲿 +* RSSPʼԼڴͷš +* ʹע⣺RsspInit󣬱ӦĵRsspFreeSpace +* +* ޸ļ¼ +* ʱ ޸ +* ------------ ------ --------------- +* 2013.3.1 ¥ΰ +********************************************************/ + +#include "stdlib.h" +#include "CommonMemory.h" +#include "RsspIFWl.h" +#include "RsspStructWl.h" +#include "RsspCommonWl.h" +#include "RsspLnkNodeMgrWl.h" +#include "RsspTmpMsgLnkCommonWl.h" +#include "dsuRsspFunc.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/*********************************************************************** + * : RsspInit_WL + * : ͨúʵֶRSRSPijʼӦ趨ĻֵеĴС + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ + UINT8 RsspInit_WL(RSSP_INFO_STRU* pRsspStruct) + { + UINT8 rtn = 0; /*ֵ*/ + UINT32 mallocLen = 0u; /*ռ䳤*/ + + if (NULL != pRsspStruct) /*ǿж*/ + { + /*¼ռ*/ + pRsspStruct->RecordArray = (UINT8*)malloc(pRsspStruct->RecordArraySize + 2); + if (NULL != pRsspStruct->RecordArray) + { + CommonMemSet(pRsspStruct->RecordArray, sizeof(UINT8) * (pRsspStruct->RecordArraySize + 2), 0, sizeof(UINT8) * (pRsspStruct->RecordArraySize + 2)); + + /*ЭӦAppArrayռ*/ + pRsspStruct->AppArraySize = (pRsspStruct->OutputSize + RSSP_FIXED_LEN_WL + 14 + 26) * (pRsspStruct->MaxNumLink) + 2; + pRsspStruct->AppArray = (UINT8*)malloc(pRsspStruct->AppArraySize); + if (NULL != pRsspStruct->AppArray) + { + CommonMemSet(pRsspStruct->AppArray, sizeof(UINT8) * pRsspStruct->AppArraySize, 0, sizeof(UINT8) * pRsspStruct->AppArraySize); + + /*·ռ*/ + pRsspStruct->VarArraySize = RSSP_VAR_NODE_LEN_WL * pRsspStruct->MaxNumLink + 32 + 14 * (pRsspStruct->MaxNumLink + 2) + 32; + pRsspStruct->VarArray = (UINT8*)malloc(pRsspStruct->VarArraySize); + if (NULL != pRsspStruct->VarArray) + { + CommonMemSet(pRsspStruct->VarArray, sizeof(UINT8) * pRsspStruct->VarArraySize, 0, sizeof(UINT8) * pRsspStruct->VarArraySize); + + /*֡ռ*/ + pRsspStruct->FrameDataMaxLen = 2 + 8 + RSSP_FIXED_LEN_WL + 32 + (pRsspStruct->InputSize > pRsspStruct->OutputSize ? pRsspStruct->InputSize : pRsspStruct->OutputSize); + pRsspStruct->FrameData = (UINT8*)malloc(pRsspStruct->FrameDataMaxLen); + if (NULL != pRsspStruct->FrameData) + { + CommonMemSet(pRsspStruct->FrameData, sizeof(UINT8) * pRsspStruct->FrameDataMaxLen, 0, sizeof(UINT8) * pRsspStruct->FrameDataMaxLen); + + /*ݶջռ*/ + rtn = InitMsgNodeStack_WL(pRsspStruct->MaxNumLink * (pRsspStruct->MaxNumPerCycle + 2) * 2, pRsspStruct->FrameDataMaxLen, &pRsspStruct->StackOfDataLink); + if (1 == rtn) /*·ڵռ*/ + { + rtn = InitLnkNodeArr_WL(pRsspStruct->MaxNumLink, pRsspStruct); + } + if (1 == rtn) /*ӦøЭݶзռ*/ + { + rtn = 0; /*ĬϷ0*/ + pRsspStruct->OutnetQueueSize = (pRsspStruct->OutputSize + 8) * pRsspStruct->MaxNumLink * (pRsspStruct->MaxNumPerCycle + 2); + rtn = QueueInitial(&pRsspStruct->OutnetQueueA, pRsspStruct->OutnetQueueSize); + if (1 == rtn) + { + rtn = QueueInitial(&pRsspStruct->OutnetQueueB, pRsspStruct->OutnetQueueSize); + } + } + if (1 == rtn) /*ЭӦݶзռ*/ + { + pRsspStruct->DataToAppSize = (pRsspStruct->InputSize + 6) * pRsspStruct->MaxNumLink * (pRsspStruct->MaxNumPerCycle + 2); + rtn = QueueInitial(&pRsspStruct->DataToApp, pRsspStruct->DataToAppSize); + } + if (1 == rtn) /*ӦøЭݶзռ*/ + { + pRsspStruct->OutputDataQueueSize = (pRsspStruct->OutputSize + 8) * pRsspStruct->MaxNumLink * (pRsspStruct->MaxNumPerCycle + 2); + rtn = QueueInitial(&pRsspStruct->OutputDataQueue, pRsspStruct->OutputDataQueueSize); + } + if (1 == rtn) /*ӦøЭݶзռ*/ + { + rtn = 0; /*ĬϷ0*/ + /*Ӧ÷ݸĬֵΪ3*/ + pRsspStruct->NoSendAppData = NONE_SEND_APP_DATA_WL; + + pRsspStruct->NetsRecvPkgNums = (RsppiNetsRecvPkgNum*)malloc(sizeof(RsppiNetsRecvPkgNum) * pRsspStruct->MaxNumLink); + if (NULL != pRsspStruct->NetsRecvPkgNums) + { + CommonMemSet(pRsspStruct->NetsRecvPkgNums, sizeof(RsppiNetsRecvPkgNum) * pRsspStruct->MaxNumLink, 0, sizeof(RsppiNetsRecvPkgNum) * pRsspStruct->MaxNumLink); + + mallocLen = sizeof(UINT8) * ((pRsspStruct->OutputSize > pRsspStruct->InputSize) ? pRsspStruct->OutputSize : pRsspStruct->InputSize); + mallocLen += 32u; + pRsspStruct->gpSendSingleOutMsg = (UINT8*)malloc(mallocLen); + if (NULL != pRsspStruct->gpSendSingleOutMsg) + { + CommonMemSet(pRsspStruct->gpSendSingleOutMsg, mallocLen, 0u, mallocLen); + + rtn = 1; /*ʼ*/ + } + + } + + } + } + } + } + } + } + + return rtn; + } + +/*********************************************************************** + * : RsspFreeSpace_WL + * : ͨúͷRSSP㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspFreeSpace_WL(RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 ret = 1; + + /* ȫͨŽڵռͷ */ + DestoryLnkNodeArr_WL(pRsspStruct); + + /* ʱĶջռͷ:ʧ */ + ret = DestoryMsgNodeStack_WL(&pRsspStruct->StackOfDataLink); + + /* ʱ */ + if (NULL != pRsspStruct->FrameData) + { + free(pRsspStruct->FrameData); + pRsspStruct->FrameData = NULL; + } + else + { + /* ʲô */ + } +#ifndef RSSP_NO_HLHT + /*ͷRSSPϢ*/ + if (NULL != pRsspStruct->pDsuRsspInfoStruWL) + { + FreeDsuRsspi(&pRsspStruct->pDsuRsspInfoStruWL); + } +#endif + return ret; +} + +#ifdef __cplusplus +} +#endif diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspLnkNodeMgrWl.c b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspLnkNodeMgrWl.c new file mode 100644 index 0000000..5c7dedb --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspLnkNodeMgrWl.c @@ -0,0 +1,1139 @@ +/******************************************************** +* ļ RsspLnkNodeMgrWl.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.12.07 +* ؼЭ鲿 +* ͨŽڵزʼѯǵȲ +* ʹע⣺ñļеĺȵóʼĺ +* +* ޸ļ¼ +* ʱ ޸ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2013.02.19 ɾInitRsspLnkInfoInitRsspLnkInfoWl +* 2013.02.19 ɾSetNodeParamSetNodeParamWl +* 2013.02.19 ɾCheckRecvDsuLnkInfoCheckRecvDsuLnkInfoWl +* 2013.02.19 ɾCheckOutputDsuLnkInfoCheckOutputDsuLnkInfoWl +* 2013.02.19 ɾCheckInputAddrCheckInputAddrWl +* 2013.02.19 ɾInitRsspLnkInfoInitRsspLnkInfoWl +* 2013.02.19 ɾInitRsspLnkInfoInitRsspLnkInfoWl +* 2014.01.15 ޸SearchNodeByAddr_WLĴ +********************************************************/ +#include +#include "RsspIFWL.h" +#include "RsspCommonWl.h" +#include "dsuRsspFunc.h" +#include "RsspLnkNodeMgrWl.h" +#include "Convert.h" +#include "RsspConfigWl.h" +#include "CommonRecord.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------- + * ·ģڲ Start + *--------------------------------------------------------------------*/ +static UINT8 InitRsspLnkInfoWl(const DSU_RSSP_LINK_RINFO_STRU_WL* pRecvDsuLnkInf, const DSU_RSSP_LINK_SINFO_STRU_WL* pOutputDsuLnkInf, RsspLinkInfoStru_WL* pRsspLnkInfo, DSU_RSSP_INFO_STRU_WL *pDsuRsspi); +static UINT8 SetNodeParamWl(const DSU_RSSP_LINK_RINFO_STRU_WL* pRecvDsuLnkInf, const DSU_RSSP_LINK_SINFO_STRU_WL* pOutputDsuLnkInf, NodeParamInfoStru_WL *pNodeParam); +static void LnkNodeInfo2VarArray_WL(const Lnk_Info_Node_Stru_WL* pNode, const UINT8 lnkNodeIdx, UINT8* VarArray); +static void VarArray2LnkNodeInfo_WL(const UINT8* VarArray, Lnk_Info_Node_Stru_WL* pNode); +static UINT8 CheckRecvDsuLnkInfoWl(UINT16 LocalDevName, const DataNode_WL *pNode, const DSU_RSSP_LINK_RINFO_STRU_WL *pRecvLnkInfo, DSU_RSSP_INFO_STRU_WL *pDsuRsspi); +static UINT8 CheckOutputDsuLnkInfoWl(UINT16 LocalDevName, const DataNode_WL *pNode, const DSU_RSSP_LINK_SINFO_STRU_WL *pOutputLnkInfo, DSU_RSSP_INFO_STRU_WL *pDsuRsspi); +static UINT8 CheckInputAddrWl(UINT32 LocalDevName,UINT16 SrcAddr,const DSU_RSSP_LINK_RINFO_STRU_WL *pRecvLnkInfo); +/*-------------------------------------------------------------------- + * ·ģڲ End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * RSSPṩĽӿں Start + *--------------------------------------------------------------------*/ + + /* + *: RsspLnkStatus_WL + *: õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + *: UINT8 dstType Ŀ + * UINT8 dstId ĿID + * UINT16 dstLogicId Ŀ߼ID + * RSSP_INFO_STRU *pRsspi RSSPIϢ + *: + *: ·״̬ 0x17:,0x2b:ͨŲ + *ֵ: + */ +UINT8 RsspLnkStatus_WL(UINT8 dstType, UINT8 dstId, UINT16 dstLogicId, RSSP_INFO_STRU *pRsspi) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT32 oppId = 0; /*ԷΨһID*/ + Lnk_Info_Node_Stru_WL *pNode = NULL; /*·ڵ*/ + UINT16 dstName = 0U; + if (NULL != pRsspi) + { + +#ifdef RSSP_NO_HLHT + TypeId2DevName_WL(dstType, dstId, &dstName); /*ȡĿRSSPIΨһID*/ + oppId = dstName; + +#else + oppId = DquToHlhtId(dstType, dstId, dstLogicId, pRsspi->pDsuRsspInfoStruWL); /*ȡĿRSSPIΨһID*/ +#endif + + pNode = SearchNodeByAddr_WL(oppId, pRsspi); + } + + if (NULL != pNode) + { + if (RecvData_WL == pNode->RsspLinInfo.RecvLinkStatus) + { + rtn = 0x17; /*״̬*/ + } + else + { + rtn = 0x2b; /*ͨŲ״̬*/ + } + } + + return rtn; +} + +/*********************************************************************** + * : RsspLnkDelete_WL + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * devName UINT16* OUT 豸 + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 RsspLnkDelete_WL(UINT32 destDevName,RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 ret = 0; + + Lnk_Info_Node_Stru_WL* pNode = NULL; + pNode = SearchNodeByAddr_WL(destDevName,pRsspStruct); + if(pNode == NULL) + { + ret = 0; + } + else + { + /*·Ϣ*/ + RsspMemSet_WL((UINT8*)pNode, sizeof(Lnk_Info_Node_Stru_WL), 0); + /* ͨŽڵ״̬Ϊ ɸ״̬ */ + pNode->NodeStatus = Replace_WL; + ret = 1; + } + + return ret; +} + + /** + * @brief RsspRefresh_WL ˢ· + * @param VarLen ·ݳ ȡֵΧ:0x0000-0xFFFF + * @param VarArray · ȡֵΧ:ֽ + * @param pRsspStruct RSSPIʵ ȡֵΧ:οṹ:RSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ +UINT8 RsspRefresh_WL(UINT16 VarLen, const UINT8* VarArray, RSSP_INFO_STRU* pRsspStruct) +{ + UINT8 ret = 1u; /*-< úֵΪɹ*/ + + UINT8 NodeLen = 0u; /*ýڵ㳤Ϊ0*/ + UINT8 NodeNum = 0u; /*ýڵΪ0*/ + UINT8 index = 0u; /*±Ϊ0*/ + UINT16 offset = 0u; /*±Ϊ0*/ + DSU_RSSP_LINK_RINFO_STRU_WL recvLnkInfo; /*ΪշʱĽڵϢ*/ + DSU_RSSP_LINK_SINFO_STRU_WL outputLnkInfo; /*ΪͷʱĽڵϢ*/ + UINT8 lnkNodeIdx = 0u; /*·ڵ±Ϊ0*/ + + NodeLen = RSSP_VAR_NODE_LEN_WL; /*-< úֵΪɹ*/ + if ((0u == (VarLen % NodeLen)) && (UINT8_MAX >= (VarLen / NodeLen))) /*-< ·ݳǷ񵥽ڵ· СUINT8_MAXֵ*/ + { + NodeNum = (UINT8)(VarLen / NodeLen); /*-< Ҫˢ·ڵ*/ + } + else + { + return 0u; /*-< غʧ*/ + } + + if ((NULL != VarArray) && (NULL != pRsspStruct) && (NULL != pRsspStruct->LnkNodeArr)) /*-< Ƿǿ*/ + { + RsspMemSet_WL((UINT8*)pRsspStruct->LnkNodeArr, sizeof(Lnk_Info_Node_Stru_WL) * pRsspStruct->LnkNodeNum, 0); /*-< ·ڵ*/ + + for (index = 0u; index < pRsspStruct->LnkNodeNum; index++) /*-< ǰ·±ǷС·*/ + { + pRsspStruct->LnkNodeArr[index].NodeStatus = Replace_WL; /*-< õǰ·ڵ״̬Ϊ*/ + } + } + else + { + return 0; /*-< غʧ*/ + } + + if (NodeNum <= pRsspStruct->LnkNodeNum) /*-< Ҫˢ·ڵǷС·*/ + { + for (index = 0; index < NodeNum; index++) /*-< ǰ·±ǷС·*/ + { + lnkNodeIdx = VarArray[offset]; /*-< ·ڵ±ΪҪˢ·ڵ±*/ + if (lnkNodeIdx < pRsspStruct->LnkNodeNum) /*-< Ҫˢǰ·ڵ±ǷС·*/ + { + VarArray2LnkNodeInfo_WL(&VarArray[offset], &pRsspStruct->LnkNodeArr[lnkNodeIdx]); /*-< ·ڵݺ*/ + + if (0u != pRsspStruct->LnkNodeArr[lnkNodeIdx].DestDevName) /*-< ǰ·ڵԷΨһIDǷ0*/ + { + /* ΪͷϢȡ */ + ret = dsuRsspSGetLnkInfoWl(pRsspStruct->LnkNodeArr[lnkNodeIdx].RsspLinInfo.RsspSrcAddr, + pRsspStruct->LnkNodeArr[lnkNodeIdx].RsspLinInfo.DestBsdAdd, + &outputLnkInfo, pRsspStruct->pDsuRsspInfoStruWL); /*-< òѯͷ·Ϣ,ֵֵ*/ + if (ret == 0u) /*-< ֵǷʧ*/ + { + return ret; /*-< غֵ*/ + } + else + { + /*-< ʲô*/ + } + + /* ΪշϢȡ */ + ret = dsuRsspRGetLnkInfoWl(pRsspStruct->LnkNodeArr[lnkNodeIdx].RsspLinInfo.RsspDestAddr, + pRsspStruct->LnkNodeArr[lnkNodeIdx].RsspLinInfo.RsspSrcAddr, + &recvLnkInfo, pRsspStruct->pDsuRsspInfoStruWL); /*-< òѯշ·Ϣ,ֵֵ*/ + if (ret == 0) /*-< ֵǷʧ*/ + { + return ret; /*-< غֵ*/ + } + else + { + /*-< ʲô*/ + } + /* 豸Ϣ趨 */ + ret = SetNodeParamWl(&recvLnkInfo, &outputLnkInfo, + &pRsspStruct->LnkNodeArr[lnkNodeIdx].RsspLinInfo.LocalNode); /*-< ·,ֵֵ*/ + } + else + { + /*-< ʲô*/ + } + } + else + { + PrintRecArray2ByteB(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, 0x8801u); /*-< ¼ˢ·±־*/ + PrintRecArrayByte(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, lnkNodeIdx); /*-< ¼ˢ·־־*/ + PrintRecArrayByte(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, pRsspStruct->LnkNodeNum); /*-< ¼ˢ·־־*/ + + return 0u; /*-< غʧ*/ + } + + offset += NodeLen; /*-< ±·*/ + } + } + else + { + return 0; /*-< غʧ*/ + } + + PrintRecArray2ByteB(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, 0x8800u); /*-< ¼ˢ·־־*/ + ret = 1; /*-< úֵΪɹ*/ + return ret; /*-< غֵ*/ +} + +/*********************************************************************** + * : GetLnkNodeArr_WL + * : ȡȫֵͨŽڵָԼͨŽڵ + * : + * + * ----------------------------------------------------------------------------- + * pLnkInfoNodeArr Lnk_Info_Node_Stru_WL** OUT ָָͨ + * OutLen UINT8* OUT + * + * ֵ : + ***********************************************************************/ + void GetLnkNodeArr_WL(Lnk_Info_Node_Stru_WL** pLnkInfoNodeArr,UINT8 *OutLen,RSSP_INFO_STRU *pRsspStruct) +{ + *pLnkInfoNodeArr = pRsspStruct->LnkNodeArr; + *OutLen = pRsspStruct->LnkNodeNum; +} + +/** + * @brief InitLnkNodeArr_WL ʼ·ڵ + * @param num · ȡֵΧ:0x00-0xFF + * @param pRsspStruct RSSPIʵ ȡֵΧ:οṹ:RSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ + UINT8 InitLnkNodeArr_WL(UINT8 num, RSSP_INFO_STRU* pRsspStruct) + { + UINT8 ret = 1u; /*-< úֵΪɹ*/ + UINT8 index = 0u; /*·±*/ + UINT32 lnkNodeArrSize = 0u; /*·鳤*/ + pRsspStruct->LnkNodeNum = num; /*-< ·RSSPIʵ·*/ + lnkNodeArrSize = sizeof(Lnk_Info_Node_Stru_WL) * pRsspStruct->LnkNodeNum; /*-< ·鳤*/ + pRsspStruct->LnkNodeArr = (Lnk_Info_Node_Stru_WL*)malloc(lnkNodeArrSize); /*-< ·ռ*/ + if (NULL == pRsspStruct->LnkNodeArr) /*-< Ƿʧ*/ + { + ret = 0u; /*-< úֵΪɹ*/ + } + else + { + RsspMemSet_WL((UINT8*)pRsspStruct->LnkNodeArr, lnkNodeArrSize, 0); /*-< ·*/ + } + for (index = 0u; index < pRsspStruct->LnkNodeNum; index++) /*-< ǰ·±ǷС·*/ + { + pRsspStruct->LnkNodeArr[index].NodeStatus = Replace_WL; /*-< õǰ·ڵΪ*/ + + pRsspStruct->LnkNodeArr[index].RecvKeepHaltCycleNum = 0u; /*-< ձHalt_WL״̬*/ + pRsspStruct->LnkNodeArr[index].RecvKeepSendSseCycleNum = 0u; /*-< ձSendSSE_WL״̬*/ + } + + return ret; /*-< غֵ*/ + } + +/*********************************************************************** + * : SearchLnkBsdNode_WL + * : BsdַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * RsspSrcAddr UINT16 IN RsspԴַ + * DestBsdAdd UINT16 IN Bsdַ + * + * ȫֱ : LnkNodeArr ȫֱ + * ֵ : Lnk_Info_Node_Stru_WL* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +Lnk_Info_Node_Stru_WL* SearchLnkBsdNode_WL(UINT16 RsspSrcAddr,UINT16 DestBsdAdd,RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 index = 0; + Lnk_Info_Node_Stru_WL* retNodePtr = NULL; + + for(index = 0; index < pRsspStruct->LnkNodeNum; index++) + { + /* wangpeipei 20120319 Mod */ + /* BSDַԴַѯ */ + if((DisbaledReplace_WL == pRsspStruct->LnkNodeArr[index].NodeStatus) + && (pRsspStruct->LnkNodeArr[index].RsspLinInfo.RsspSrcAddr == DestBsdAdd) + && (pRsspStruct->LnkNodeArr[index].RsspLinInfo.RsspDestAddr== RsspSrcAddr)) + { + retNodePtr = & pRsspStruct->LnkNodeArr[index]; + break; + } + else + { + /* nothing */ + } + } + return retNodePtr; +} + +/*********************************************************************** + * : SearchLnkSse_SsrNode_WL + * : PSSPĿĵַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * RsspSrcAddr UINT16 IN RsspԴַ + * RsspDestAddr UINT16 IN PsspĿĵַ + * + * ȫֱ : LnkNodeArr ȫֱ + * ֵ : Lnk_Info_Node_Stru_WL* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +Lnk_Info_Node_Stru_WL* SearchLnkSse_SsrNode_WL(UINT16 RsspSrcAddr,UINT16 RsspDestAddr,RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 index = 0; + Lnk_Info_Node_Stru_WL* retNodePtr = NULL; + + for(index = 0; index < pRsspStruct->LnkNodeNum; index++) + { + + /* ָ̬Id Լ ʶȡöӦڵϢ */ + if((DisbaledReplace_WL == pRsspStruct->LnkNodeArr[index].NodeStatus) + && (pRsspStruct->LnkNodeArr[index].RsspLinInfo.RsspDestAddr == RsspDestAddr) + && (pRsspStruct->LnkNodeArr[index].RsspLinInfo.RsspSrcAddr == RsspSrcAddr)) + { + retNodePtr = & pRsspStruct->LnkNodeArr[index]; + break; + } + else + { + /* nothing */ + } + + } + return retNodePtr; +} +/* wangpeipei 20111201 ADD */ + +/*********************************************************************** + * : GetReplaceNode_WL + * : ͨɸǵĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * + * ȫֱ : LnkNodeArr* ȫֱͨŽڵ + * ֵ : Lnk_Info_Node_Stru_WL* NULL쳣 NULLͨŽڵ + ***********************************************************************/ + +Lnk_Info_Node_Stru_WL* GetReplaceNode_WL(RSSP_INFO_STRU *pRsspStruct) +/* wangpeipei 20111202 Add S */ +{ + UINT8 index = 0; + Lnk_Info_Node_Stru_WL* retNodePtr = NULL; + + for(index = 0; index < pRsspStruct->LnkNodeNum; index++) + { + /* ýڵɸ ظýڵָ */ + /*if((srcAddr == LnkNodeArr[index].RsspSrcAddr) && (desAddr == LnkNodeArr[index].RsspDestAddr) + && (LnkNodeArr[index].NodeStatus == Replace))*/ + if(pRsspStruct->LnkNodeArr[index].NodeStatus == Replace_WL) + { + retNodePtr = &pRsspStruct->LnkNodeArr[index]; + break; + } + else + { + /* ʲô */ + } + } + /* wangpeipei 20111202 Mod E */ + return retNodePtr; +} + + +/*********************************************************************** + * : DestoryLnkNodeArr_WL + * : ͷͨŽڵĿռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : ޡ + ***********************************************************************/ +void DestoryLnkNodeArr_WL(RSSP_INFO_STRU *pRsspStruct) +{ + /* ͨŽڵĿռ䲻Ϊգͷڴռ */ + if(NULL != pRsspStruct->LnkNodeArr) + { + free(pRsspStruct->LnkNodeArr); + pRsspStruct->LnkNodeArr = NULL; + pRsspStruct->LnkNodeNum = 0; + } + else + { + /* ʲô */ + } +} + +/*********************************************************************** + * : recvReplaceLnkNode_WL + * : ݱϢͨŽڵϢʼ + * : + * + * ------------------------------------------------------------- + * LocalDevName UINT16 IN ʶ + * pDataNode const DataNode_WL* IN Ľڵ + * pLnkNodeInfo ͨŽڵ INOUT ͨŽڵ + * + * ֵ : UINT8 1 0󷵻 + * ʹ ΪģյBSDʱӦͨŽڵ㲻ʱ + * + ***********************************************************************/ +UINT8 recvReplaceLnkNode_WL(UINT16 LocalDevName,const DataNode_WL* pDataNode,Lnk_Info_Node_Stru_WL *pLnkNodeInfo, DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL) +{ + UINT8 ret = 0,checkRet = 0; + UINT16 BsdAddr = 0; + UINT16 DestSrcAddr = 0; + DSU_RSSP_LINK_RINFO_STRU_WL recvLnkInfo; /* ΪշʱĽڵϢ */ + DSU_RSSP_LINK_SINFO_STRU_WL outputLnkInfo; /* ΪͷʱĽڵϢ */ + + /* BSDĿַ Ϊ BSDַ */ + BsdAddr = (INT16)ShortFromCharLE(&pDataNode->Data[RSSP_DEST_ADD_POS_WL]); + /* BSDĵıԴַ ԷSSEַ */ + DestSrcAddr = ShortFromCharLE(&pDataNode->Data[RSSP_SRC_ADD_POS_WL]); + + /* ݽձĵԴַԼĿַ(BSDַ)ȡñΪܽڵϢ */ + ret = dsuRsspRGetLnkInfoWl(DestSrcAddr, + BsdAddr, &recvLnkInfo, pDsuRsrInfoStru_WL); + /* ȡóɹ ϢʱĽڵϢһ */ + checkRet = CheckRecvDsuLnkInfoWl(LocalDevName, pDataNode, &recvLnkInfo, pDsuRsrInfoStru_WL); + if((0 == ret) || (0 == checkRet)) + { + ret = 0; + return ret; + } + /* ȡõSseַԼĿַ(BSDַ)ȡñΪͽڵϢ */ + + ret = dsuRsspSGetLnkInfoWl(recvLnkInfo.SseAddr, (INT16)DestSrcAddr, &outputLnkInfo, pDsuRsrInfoStru_WL); + /* ȡóɹ ϢʱĽڵϢһ */ + checkRet = CheckOutputDsuLnkInfoWl(LocalDevName, pDataNode, &outputLnkInfo, pDsuRsrInfoStru_WL); + if((0 == ret) || (0 == checkRet)) + { + ret = 0; + return ret; + } + + /* Էʶ趨 */ + pLnkNodeInfo->DestDevName = pDataNode->DevName; + + /* RSSP·Ϣṹʼ */ + InitRsspLnkInfoWl(&recvLnkInfo, &outputLnkInfo, &pLnkNodeInfo->RsspLinInfo, pDsuRsrInfoStru_WL); + + /* ͨŽڵĽ״̬ΪSSE */ + pLnkNodeInfo->RsspLinInfo.RecvLinkStatus = SendSSE_WL; + + /* ͨŽڵ״̬趨Ϊɸ */ + pLnkNodeInfo->NodeStatus = DisbaledReplace_WL; + + ret = 1; + return ret; + +} +/*********************************************************************** + * : outputReplaceLnkNode_WL + * : ԴַĿַBSDַȡöӦڵϢ + * ͨŽڵϢʼ + * : + * + * ------------------------------------------------------------- + * SrcAddr UINT16 IN Դַ + * BsdAddr UINT16 IN BSDַ + * DestAddr UINT16 IN SSEַ + * LocalDevName UINT32 IN ʶ + * pPLnkNodeInfo Lnk_Info_Node_Stru_WL** OUT ͨŽڵ + * + * ֵ : UINT8 1 0󷵻 + * ʹ Ϊģ飬ַָͨŽڵ㲻ʱ + * + ***********************************************************************/ +UINT8 outputReplaceLnkNode_WL(UINT16 SrcAddr,UINT16 BsdAddr,UINT16 DestAddr, + UINT32 LocalDevName,Lnk_Info_Node_Stru_WL **pPLnkNodeInfo, + RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 ret = 0,chcRet = 0; + DSU_RSSP_LINK_RINFO_STRU_WL recvLnkInfo; /* ΪշʱĽڵϢ */ + DSU_RSSP_LINK_SINFO_STRU_WL outputLnkInfo; /* ΪͷʱĽڵϢ */ + Lnk_Info_Node_Stru_WL *pLnkNodeInfo = NULL; + + /* ݲĿַԼBSDַȡñΪܽڵϢ */ + ret = dsuRsspRGetLnkInfoWl(DestAddr, SrcAddr, &recvLnkInfo, pRsspStruct->pDsuRsspInfoStruWL); + /* + * ȡóɹ Ϣ뱾Ϣһ + */ + chcRet = CheckInputAddrWl(LocalDevName,SrcAddr,&recvLnkInfo); + if((1 == ret) && ( 1 == chcRet)) + { + /* ȡõSseַԼĿַ(BSDַ)ȡñΪͽڵϢ */ + ret = dsuRsspSGetLnkInfoWl(recvLnkInfo.SseAddr, BsdAddr, &outputLnkInfo, pRsspStruct->pDsuRsspInfoStruWL); + if(0 == ret) + { + /* ȡʧܣ󷵻 */ + return ret; + } + + pLnkNodeInfo = GetReplaceNode_WL(pRsspStruct); + if(NULL == pLnkNodeInfo) + { + /* ɸǽڵȡʧ 󷵻 */ + ret = 0; + return ret; + } + else + { + /* ȡõĸǽڵָ 淵pPLnKNodeInfo */ + *pPLnkNodeInfo = pLnkNodeInfo; + } + /* Էʶ趨 */ + pLnkNodeInfo->DestDevName = outputLnkInfo.DestName; + + /* RSSP·Ϣṹʼ */ + InitRsspLnkInfoWl(&recvLnkInfo, &outputLnkInfo, &pLnkNodeInfo->RsspLinInfo, pRsspStruct->pDsuRsspInfoStruWL); + + /* ͨŽڵ״̬趨Ϊɸ */ + pLnkNodeInfo->NodeStatus = DisbaledReplace_WL; + } + else + { + /* Ϣȡʧ ͨŹϵʽ CICC ַϵ */ + ret = 0; + return ret; + } + + ret = 1; + return ret; +} + +/*********************************************************************** + * : SearchNodeByAddr_WL + * : ָĶԷ豸ʶѯӦͨŽڵǷڡ + * 򷵻ضӦͨŽڵָ룬򷵻NULL + * : + * + * -------------------------------------------------------------------------- + * destName UINT32 IN Է豸ʶ + * + * ֵ : Lnk_Info_Node_Stru_WL* ͨŽڵָ룬 NULL: + ***********************************************************************/ +Lnk_Info_Node_Stru_WL* SearchNodeByAddr_WL(UINT32 destName,RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 index = 0; + Lnk_Info_Node_Stru_WL* retLnkNodePtr = NULL; /* ָ */ + for( index = 0; index < pRsspStruct->LnkNodeNum; index++) + { + /* + * ָĵַӦͨŽڵ + */ + if((DisbaledReplace_WL == pRsspStruct->LnkNodeArr[index].NodeStatus) + && (destName == pRsspStruct->LnkNodeArr[index].DestDevName)) + { + retLnkNodePtr = & pRsspStruct->LnkNodeArr[index]; + break; + } + else + { + /* жһ */ + } + } + + return retLnkNodePtr; +} + +/*-------------------------------------------------------------------- + * RSSPڲӿں End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * ·ģڲ Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : InitRsspLnkInfo + * : ݷϢԼϢ·Ϣгʼ + * : + * + * -------------------------------------------------------------------------- + * pRecvDsuLnkInf const DSU_RSSP_LINK_RINFO_STRU_WL* IN Ϣ + * pOutputDsuLnkInf const DSU_RSSP_LINK_SINFO_STRU_WL* IN Ϣ + * pRsspLnkInfo RsspLinkInfoStru_WL* INOUT ·Ϣṹ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +/* MOD 20130802 ɾ BsdAddr */ +static UINT8 InitRsspLnkInfoWl(const DSU_RSSP_LINK_RINFO_STRU_WL* pRecvDsuLnkInf, + const DSU_RSSP_LINK_SINFO_STRU_WL* pOutputDsuLnkInf, + RsspLinkInfoStru_WL* pRsspLnkInfo, + DSU_RSSP_INFO_STRU_WL *pDsuRsspi) +{ + UINT8 ret = 0; + + /* ADD 20130802 */ + if(pOutputDsuLnkInf == NULL) + { + ret = 0; + } + else + { + /* */ + RsspMemSet_WL((UINT8 *)pRsspLnkInfo,sizeof(RsspLinkInfoStru_WL),0); +#ifdef RSSP_NO_HLHT + pRsspLnkInfo->DestLogId = pOutputDsuLnkInf->DestName & 0xff; + pRsspLnkInfo->LocalLogId = pRecvDsuLnkInf->DestName & 0xff; +#else + pRsspLnkInfo->DestLogId = DquToDevId(pOutputDsuLnkInf->DestName, pDsuRsspi); /* Է̬Id Է豸Id*/ + pRsspLnkInfo->LocalLogId = DquToDevId(pRecvDsuLnkInf->DestName, pDsuRsspi); /* ܻϢĶԷʶΪʶ豸IdΪ̬Id */ +#endif + + pRsspLnkInfo->RsspSrcAddr = pRecvDsuLnkInf->SseAddr; /* RSSPԴַ = շϢSSeַ */ + pRsspLnkInfo->RsspDestAddr = pOutputDsuLnkInf->SseAddr; /* RSSPĿַ(SSEַ) = ͷϢSSEַ */ + + /* BSDַ趨 */ + pRsspLnkInfo->DestBsdAdd = pOutputDsuLnkInf->SseAddr; + + /* 趨ͨŽڵĻϢ */ + SetNodeParamWl(pRecvDsuLnkInf, pOutputDsuLnkInf, &pRsspLnkInfo->LocalNode); + + pRsspLnkInfo->RecvLinkStatus = Halt_WL; /* ·״̬趨Ϊж״̬ */ + pRsspLnkInfo->SendLinkStatus = Halt_WL; /* ·״̬趨Ϊж״̬ */ + pRsspLnkInfo->NoRecvDataCycleNum = 0; /* ʼΪ0 */ + pRsspLnkInfo->NoAppDataCycleNum = 0; /* ޷ӦʼΪ0 */ + + /*pRsspLnkInfo->TimeStmp.TC = 0;*/ /* ǰʱΪ0 */ + + /* ǰڶӦʱͨŵķͷSIDʼ */ + pRsspLnkInfo->TimeStmp.NowTn[0] = pRsspLnkInfo->LocalNode.SIDr[0]; + pRsspLnkInfo->TimeStmp.NowTn[1] = pRsspLnkInfo->LocalNode.SIDr[1]; + ret = 1; + } + return ret; /* ̶1 */ +} + + /** + * @brief WriteToVarArray_WL д· + * @param VarArray · ȡֵΧֽ + * @param pRsspStruct RSSPIʵ ȡֵΧ:οṹ:RSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ +UINT8 WriteToVarArray_WL(UINT8* VarArray, RSSP_INFO_STRU* pRsspStruct) +{ + UINT8 ret = 0u, index = 0u; /*-< úֵΪʧ*/ + UINT8* pTmp = NULL; /*·*/ + UINT8 NodeLen = 0u; /*ڵ㳤*/ + UINT8 count = 0u; /*ýڵ*/ + UINT16 offset = 0u; /*·±*/ + if ((NULL != VarArray) && (NULL != pRsspStruct)) /*-< Ƿǿ*/ + { + NodeLen = (UINT8)RSSP_VAR_NODE_LEN_WL; /*-< ýڵ㳤*/ + pTmp = &VarArray[2]; /*-< ·*/ + for (index = 0u; index < pRsspStruct->LnkNodeNum; index++) /*-< ·±ǷС·*/ + { + if (pRsspStruct->LnkNodeArr[index].NodeStatus == DisbaledReplace_WL) /*-< ǰ·ǷΪ*/ + { + LnkNodeInfo2VarArray_WL(&pRsspStruct->LnkNodeArr[index], index, &pTmp[offset]); /*-< ·ڵд·ݺ*/ + + offset += NodeLen; /*-< ·±·ڵ㳤*/ + count++; /*-< ýڵ1*/ + } + } + + ShortToChar((count * NodeLen), VarArray); /*-< д·ݳȵ·*/ + ret = 1u; /*-< úֵΪɹ*/ + } + + return ret; /*-< غֵ*/ +} + +/** + * @brief LnkNodeInfo2VarArray_WL ·ڵд· + * @param pNode ·ڵ ȡֵΧ:οṹ:Lnk_Info_Node_Stru_WL + * @param lnkNodeIdx ·ڵ± ȡֵΧ:0x00-0xFF + * @param VarArray · ȡֵΧ:ֽ + */ +static void LnkNodeInfo2VarArray_WL(const Lnk_Info_Node_Stru_WL* pNode, const UINT8 lnkNodeIdx, UINT8* VarArray) +{ + UINT16 index = 0; /*·±*/ + const RsspLinkInfoStru_WL* pRsspLnkInfo = &pNode->RsspLinInfo; /*ǰ·Ϣ*/ + const TimeStampStru_WL* pTmStmp = &pNode->RsspLinInfo.TimeStmp; /*ǰ·ʱ*/ + + VarArray[index++] = lnkNodeIdx; /*-< ·ڵ±·,±1*/ + + LongToChar(pNode->CycleNum, &VarArray[index]); /*-< ںŸ·*/ + index += 4; /*-< ·±4*/ + + VarArray[index++] = pNode->ExeCycle; /*-< ǷΪִڸ·,±1*/ + + VarArray[index++] = pNode->HasRsdBeforeSseOrSsr; /*-< SSESSR֮ǰǷRSD·,±1*/ + + VarArray[index++] = pNode->RecvKeepHaltCycleNum; /*-< ýձHalt_WL״̬·,±1*/ + + VarArray[index++] = pNode->RecvKeepSendSseCycleNum; /*-< ýձSendSSE_WL״̬·,±1*/ + + LongToChar(pNode->DestDevName, &VarArray[index]); /*-< öԷΨһID·*/ + index += 4; /*-< ·±4*/ + + ShortToChar(pNode->DestTypeId, &VarArray[index]); /*-< öԷID·*/ + index += 2; /*-< ·±2*/ + + ShortToChar(pNode->DestLogicId, &VarArray[index]); /*-< öԷ߼ID·*/ + index += 2; /*-< ·±2*/ + + VarArray[index++] = pNode->NodeStatus; /*-< ·Ƿñʶ·,±1*/ + + VarArray[index++] = pRsspLnkInfo->LocalLogId; /*-< ñ̬ID·,±1*/ + + VarArray[index++] = pRsspLnkInfo->DestLogId; /*-< öԷ̬ID·,±1*/ + + VarArray[index++] = pRsspLnkInfo->RecvLinkStatus; /*-< ·״̬·,±1*/ + + VarArray[index++] = pRsspLnkInfo->SendLinkStatus; /*-< ·״̬·,±1*/ + + VarArray[index++] = pRsspLnkInfo->NoRecvDataCycleNum; /*-< ·,±1*/ + + VarArray[index++] = pRsspLnkInfo->NoAppDataCycleNum; /*-< ޷Ӧ·,±1*/ + + ShortToChar((UINT16)pRsspLnkInfo->DestBsdAdd, &VarArray[index]); /*-< BSDַ·*/ + index += 2; /*-< ·±2*/ + + ShortToChar(pRsspLnkInfo->RsspSrcAddr, &VarArray[index]); /*-< RSSPԴַ·*/ + index += 2; /*-< ·±2*/ + + ShortToChar(pRsspLnkInfo->RsspDestAddr, &VarArray[index]); /*-< RSSPĿĵַ·*/ + index += 2; /*-< ·±2*/ + + LongToChar(pTmStmp->TC, &VarArray[index]); /*-< õǰʱ·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->LastLocalRecTC, &VarArray[index]); /*-< ϴյıʱӸ·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->NowTn[0], &VarArray[index]); /*-< õǰڶӦʱ[0]·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->NowTn[1], &VarArray[index]); /*-< õǰڶӦʱ[1]·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->NowRecvTCr, &VarArray[index]); /*-< õǰյͷʱӸ·*/ + index += 4; /*-< ·±4*/ + +#ifndef RSSPI_SIMPLE_LINK_REFRESH /*Ƿ·꿪*/ + + LongToChar(pTmStmp->SseTC, &VarArray[index]); /*-< SSEʱںŸ·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->SseTn[0], &VarArray[index]); /*-< SSEʱڶӦʱ[0]·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->SseTn[1], &VarArray[index]); /*-< SSEʱڶӦʱ[1]·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->RecvSseTCe, &VarArray[index]); /*-< SSEĵĶԷʱӸ·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->SeqEng[0], &VarArray[index]); /*-< յSSEʱSEQENQ[0]·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->SeqEng[1], &VarArray[index]); /*-< յSSEʱSEQENQ[1]·*/ + index += 4; /*-< ·±4*/ + + VarArray[index++] = pTmStmp->NumSendSse; /*-< ÷SSE·,±1*/ + + LongToChar(pTmStmp->SsrTc, &VarArray[index]); /*-< ϴͬ·*/ + index += 4; /*-< ·±4*/ + +#endif + + LongToChar(pTmStmp->NowSINIT_ADD_SID_XOR_Tn[0], &VarArray[index]); /*-< õǰյʱSINITr AND [SIDr ^ Tr(n)] [0]·*/ + index += 4; /*-< ·±4*/ + + LongToChar(pTmStmp->NowSINIT_ADD_SID_XOR_Tn[1], &VarArray[index]); /*-< õǰյʱSINITr AND [SIDr ^ Tr(n)] [1]·*/ +} + +/** + * @brief VarArray2LnkNodeInfo_WL ·ݸֵ·ڵ + * @param VarArray · ȡֵΧ:ֽ + * @param pNode ·ڵ ȡֵΧ:οṹ:Lnk_Info_Node_Stru_WL + */ +static void VarArray2LnkNodeInfo_WL(const UINT8* VarArray, Lnk_Info_Node_Stru_WL* pNode) +{ + UINT16 index = 0; /*·±*/ + RsspLinkInfoStru_WL* pRsspLnkInfo = &pNode->RsspLinInfo; /*ǰ·Ϣ*/ + TimeStampStru_WL* pTmStmp = &pNode->RsspLinInfo.TimeStmp; /*ǰ·ʱ*/ + + index += 1; /*-< ·±*/ + + pNode->CycleNum = LongFromChar(&VarArray[index]); /*-< ·ݸֵں*/ + index += 4; /*-< ·±4*/ + + pNode->ExeCycle = VarArray[index++]; /*-< ·ݸֵǷΪִ,±1*/ + + pNode->HasRsdBeforeSseOrSsr = VarArray[index++]; /*-< ·ݸֵSSESSR֮ǰǷRSD,±1*/ + + pNode->RecvKeepHaltCycleNum = VarArray[index++]; /*-< ·ݸձHalt_WL״̬,±1*/ + + pNode->RecvKeepSendSseCycleNum = VarArray[index++]; /*-< ·ݸձSendSSE_WL״̬,±1*/ + + pNode->DestDevName = LongFromChar(&VarArray[index]); /*-< ·ݸֵԷΨһID*/ + index += 4; /*-< ·±4*/ + + pNode->DestTypeId = ShortFromChar(&VarArray[index]); /*-< ·ݸֵԷID*/ + index += 2; /*-< ·±2*/ + + pNode->DestLogicId = ShortFromChar(&VarArray[index]); /*-< ·ݸֵԷ߼ID*/ + index += 2; /*-< ·±2*/ + + pNode->NodeStatus = VarArray[index++]; /*-< ·ݸֵڵɸ״̬,±1*/ + + pRsspLnkInfo->LocalLogId = VarArray[index++]; /*-< ·ݸֵ̬ID,±1*/ + + pRsspLnkInfo->DestLogId = VarArray[index++]; /*-< ·ݸֵԷ̬ID,±1*/ + + pRsspLnkInfo->RecvLinkStatus = VarArray[index++]; /*-< ·ݸֵ·״̬,±1*/ + + pRsspLnkInfo->SendLinkStatus = VarArray[index++]; /*-< ·ݸֵ·״̬,±1*/ + + pRsspLnkInfo->NoRecvDataCycleNum = VarArray[index++]; /*-< ·ݸֵ,±1*/ + + pRsspLnkInfo->NoAppDataCycleNum = VarArray[index++]; /*-< ·ݸֵ޷Ӧ,±1*/ + + pRsspLnkInfo->DestBsdAdd = (INT16)ShortFromChar(&VarArray[index]); /*-< ·ݸֵBSDַ*/ + index += 2; /*-< ·±2*/ + + pRsspLnkInfo->RsspSrcAddr = ShortFromChar(&VarArray[index]); /*-< ·ݸֵRSSPԴַ*/ + index += 2; /*-< ·±2*/ + + pRsspLnkInfo->RsspDestAddr = ShortFromChar(&VarArray[index]); /*-< ·ݸֵRSSPĿĵַ*/ + index += 2; /*-< ·±2*/ + + pTmStmp->TC = LongFromChar(&VarArray[index]); /*-< ·ݸֵǰʱ*/ + index += 4; /*-< ·±4*/ + + pTmStmp->LastLocalRecTC = LongFromChar(&VarArray[index]); /*-< ·ݸֵϴյıʱ*/ + index += 4; /*-< ·±4*/ + + pTmStmp->NowTn[0] = LongFromChar(&VarArray[index]); /*-< ·ݸֵǰڶӦʱ[0]*/ + index += 4; /*-< ·±4*/ + + pTmStmp->NowTn[1] = LongFromChar(&VarArray[index]); /*-< ·ݸֵǰڶӦʱ[1]*/ + index += 4; /*-< ·±4*/ + + pTmStmp->NowRecvTCr = LongFromChar(&VarArray[index]); /*-< ·ݸֵǰյͷʱ*/ + index += 4; /*-< ·±4*/ + +#ifndef RSSPI_SIMPLE_LINK_REFRESH /*Ƿ·꿪*/ + + pTmStmp->SseTC = LongFromChar(&VarArray[index]); /*-< ·ݸֵSSEʱں*/ + index += 4; /*-< ·±4*/ + + pTmStmp->SseTn[0] = LongFromChar(&VarArray[index]); /*-< ·ݸֵSSEʱڶӦʱ[0]*/ + index += 4; /*-< ·±4*/ + + pTmStmp->SseTn[1] = LongFromChar(&VarArray[index]); /*-< ·ݸֵSSEʱڶӦʱ[1]*/ + index += 4; /*-< ·±4*/ + + pTmStmp->RecvSseTCe = LongFromChar(&VarArray[index]); /*-< ·ݸֵSSEĵĶԷʱ*/ + index += 4; /*-< ·±4*/ + + pTmStmp->SeqEng[0] = LongFromChar(&VarArray[index]); /*-< ·ݸֵյSSEʱSEQENQ[0]*/ + index += 4; /*-< ·±4*/ + + pTmStmp->SeqEng[1] = LongFromChar(&VarArray[index]); /*-< ·ݸֵյSSEʱSEQENQ[1]*/ + index += 4; /*-< ·±4*/ + + pTmStmp->NumSendSse = VarArray[index++]; /*-< ·ݸֵSSE,±1*/ + + pTmStmp->SsrTc = LongFromChar(&VarArray[index]); /*-< ·ݸֵϴͬ*/ + index += 4; /*-< ·±4*/ + +#endif + + pTmStmp->NowSINIT_ADD_SID_XOR_Tn[0] = LongFromChar(&VarArray[index]); /*-< ·ݸֵǰյʱ SINITr AND [SIDr ^ Tr(n)] [0]*/ + index += 4; /*-< ·±4*/ + + pTmStmp->NowSINIT_ADD_SID_XOR_Tn[1] = LongFromChar(&VarArray[index]); /*-< ·ݸֵǰյʱ SINITr AND [SIDr ^ Tr(n)] [1]*/ + index += 4; /*-< ·±4*/ +} + + /* +*: CheckRecvDsuLnkInfoWl +*: DSUȡýշϢϢǷһ +*: UINT16 LocalDevName ID +* const DataNode_WL *pNode յݽڵ +* const DSU_RSSP_LINK_RINFO_STRU_WL *pRecvLnkInfo շϢ +* DSU_RSSP_INFO_STRU_WL *pDsuRsspi RSSPIϢ +*: +*: +*ֵ: 1:ɹ,0:ʧ +*/ + static UINT8 CheckRecvDsuLnkInfoWl(UINT16 LocalDevName, const DataNode_WL *pNode, const DSU_RSSP_LINK_RINFO_STRU_WL *pRecvLnkInfo, DSU_RSSP_INFO_STRU_WL *pDsuRsspi) + { + UINT8 rtn = 0; /*ֵ*/ + UINT8 locType = 0; /**/ + UINT8 locId = 0; /*ID*/ + + if (NULL != pRecvLnkInfo) /*ηǿ*/ + { + DevName2TypeId_WL(LocalDevName, &locType, &locId); + if ((pRecvLnkInfo->DestName == pDsuRsspi->LocEmitterName) && (pRecvLnkInfo->SseAddr == pDsuRsspi->LocRsspiAddr) && (pNode->LocalLogId == locId)) + { + /*յݶӦıΨһIDȷ*/ + rtn = 1; + } + } + + return rtn; + } + + /* +*: CheckOutputDsuLnkInfoWl +*: DSUȡ÷ͷϢϢǷһ +*: UINT16 LocalDevName ID +* const DataNode_WL *pNode յݽڵ +* const DSU_RSSP_LINK_SINFO_STRU_WL *pOutputLnkInfo ͷϢ +* DSU_RSSP_INFO_STRU_WL *pDsuRsspi RSSPIϢ +*: +*: +*ֵ: 1:ɹ,0:ʧ +*/ + static UINT8 CheckOutputDsuLnkInfoWl(UINT16 LocalDevName, const DataNode_WL *pNode, const DSU_RSSP_LINK_SINFO_STRU_WL *pOutputLnkInfo, DSU_RSSP_INFO_STRU_WL *pDsuRsspi) + { + UINT8 rtn = 0; /*ֵ*/ + UINT8 locType = 0; /**/ + UINT8 locId = 0; /*ID*/ + UINT8 dstId = 0; /*ԷID*/ + + if (NULL != pOutputLnkInfo) /*ηǿ*/ + { + DevName2TypeId_WL(LocalDevName, &locType, &locId); /*豸ID*/ +#ifdef RSSP_NO_HLHT + dstId = pOutputLnkInfo->DestName & 0xff; +#else + dstId = DquToDevId(pOutputLnkInfo->DestName, pDsuRsspi); /*Է豸ID*/ +#endif + + if ((pOutputLnkInfo->DestName == pNode->DevName) && (pNode->LocalLogId == locId) && (pNode->DestLogId == dstId)) + { + /*յݶӦĶԷ豸IDȷ*/ + rtn = 1; + } + } + + return rtn; + } + +/*********************************************************************** + * : CheckInputAddrWl + * : ݱ豸ԼSSEַ ȡõıΪϢǷȷ + * : + * + * ------------------------------------------------------------------------ + * LocalDevName UINT16 IN ʶ + * SrcAddr UINT16 IN Դַ + * pRecvLnkInfo const DSU_RSSP_LINK_RINFO_STRU_WL* IN Ϣ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +static UINT8 CheckInputAddrWl(UINT32 LocalDevName,UINT16 SrcAddr, + const DSU_RSSP_LINK_RINFO_STRU_WL *pRecvLnkInfo) +{ + UINT8 ret = 0; + /* Del 20130802 S */ + /*UINT8 Type = 0, Id =0; + + DevName2TypeId_WL(LocalDevName,&Type,&Id);*/ /* ȡ豸 豸Id */ + /* ɾĴ wangpeipei Del E */ + + /*ADD 20130802 */ + if(pRecvLnkInfo == NULL) + { + return ret; + } + /* շSSEַǷڱԴַ˵Ӧøĵַ */ + if(SrcAddr != pRecvLnkInfo->SseAddr) + { + return ret; + } + + /* + * Էʶͱıʶ Ӧøַ + */ + if(LocalDevName != pRecvLnkInfo->DestName) + { + return ret; + } + + ret = 1; /* */ + return ret; +} + +/*********************************************************************** + * : SetNodeParamWl + * : ÿȡͨŽڵϢõָ豸ڵϢṹ档 + * : + * + * -------------------------------------------------------------------------- + * pRecvDsuLnkInf const DSU_RSSP_LINK_RINFO_STRU_WL* IN Ϣ + * pOutputDsuLnkInf const DSU_RSSP_LINK_SINFO_STRU_WL* IN Ϣ + * pRsspLnkInfo RsspLinkInfoStru_WL* INOUT ·Ϣṹ + * + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 SetNodeParamWl(const DSU_RSSP_LINK_RINFO_STRU_WL* pRecvDsuLnkInf, + const DSU_RSSP_LINK_SINFO_STRU_WL* pOutputDsuLnkInf, + NodeParamInfoStru_WL *pNodeParam) +{ + UINT8 chan = 0; /* źŵ */ + UINT8 index = 0; + UINT8 ret = 0; + + if((pRecvDsuLnkInf == NULL)||(pOutputDsuLnkInf== NULL)) + { + ret = 0; + } + else + { + for(chan = 0; chan < 2; chan++) + { + /* ͽڵϢ */ + pNodeParam->SIDe[chan] = pOutputDsuLnkInf->SID_NUMBER_R[chan]; /* շSID */ + pNodeParam->SIDr[chan] = pOutputDsuLnkInf->SID_NUMBER_E[chan]; /* ͷSID */ + pNodeParam->SINIT[chan] = pOutputDsuLnkInf->SINIT_NUMBER[chan]; /* ʾ׸SINIT */ + pNodeParam->DATAVER[chan] = pOutputDsuLnkInf->DATAVER_1_Number[chan]; /* DATAVER */ + pNodeParam->NumDataVer[chan] = pOutputDsuLnkInf->DATANUM[chan]; /* Data 汾 */ + + /* ֵ߲ */ + pNodeParam->PREC_FIRSTSINIT[chan] = pRecvDsuLnkInf->PREC_FIRSTSINIT[chan]; /* ߲PREC_FIRSTSINIT */ + for( index = 0; index < DSURSR_MAX_K_NUM_WL; index++) + { + pNodeParam->PREC_SINIT_K[chan][index] = pRecvDsuLnkInf->PREC_SINIT_K[chan][index]; /* ߲PREC_SINIT */ + pNodeParam->TSD_POST_RXDADA_K[chan][index] = pRecvDsuLnkInf->POST_RXDADA_K[chan][index]; /* ߲ BSD̶ֵ */ + } + } + + /* շϢ */ + pNodeParam->DLost = pRecvDsuLnkInf->DLost; /* */ + pNodeParam->SSDelay = pRecvDsuLnkInf->WSsrOut; /* 涨ʱ䣨SSDelay */ + pNodeParam->AntiDelayCount = pRecvDsuLnkInf->AntiDelayCount; /* ͬ */ + pNodeParam->Tout = pRecvDsuLnkInf->TOut ; /* BSDijʱ */ + pNodeParam->MaxLost = pRecvDsuLnkInf->MaxLost; /* ʧ */ + + } + ret = 1; + return (UINT8)1; +} + +/*********************************************************************** + * : AdjustLnkCycle + * : ָ͡ںšǰ·ǰ·ںŲǷΪִڡ + * : + * + * ----------------------------------------------------------- + * localType UINT8 IN + * cycleNum UINT32 IN ں + * lnkNode Lnk_Info_Node_Stru_WL* IN ·ڵ + * + * ֵ : + ***********************************************************************/ +void AdjustLnkCycle(UINT8 localType, UINT32 cycleNum, Lnk_Info_Node_Stru_WL* lnkNode) +{ + if (lnkNode != NULL) + { + if (((RSSP_TYPE_VOBC_WL == localType) || (RSSP_TYPE_VOBC_BACK_WL == localType)) && (RSSP_TYPE_ATS_WL == (lnkNode->DestTypeId / 256))) /*VOBCATS*/ + { + if (0 == (cycleNum % VOBC_ATS_CYCLENUM_MULTIPLE)) /*ںű,·ںŲִ*/ + { + lnkNode->ExeCycle = 1; + } + else /*ںű,ִ*/ + { + lnkNode->ExeCycle = 0; + } + } + else if ((RSSP_TYPE_AOM_WL == localType) && (RSSP_TYPE_ATS_WL == (lnkNode->DestTypeId / 256))) /*AOMATS*/ + { + if (0 == (cycleNum % AOM_ATS_CYCLENUM_MULTIPLE)) /*ںű,·ںŲִ*/ + { + lnkNode->ExeCycle = 1; + } + else /*ںű,ִ*/ + { + lnkNode->ExeCycle = 0; + } + } + else /*,õ·ڿִ*/ + { + lnkNode->ExeCycle = 1; + } + } +} + +/*-------------------------------------------------------------------- + * ·ģڲ End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspLnkNodeMgrWl.h b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspLnkNodeMgrWl.h new file mode 100644 index 0000000..8f7ebb8 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspLnkNodeMgrWl.h @@ -0,0 +1,189 @@ +/******************************************************** +* +* ļ RsspLnkNodeMgrWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* RsspͨŽڵصĺ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* +********************************************************/ + +#ifndef _RSSP_LNK_NODE_MGR_WL_H_ +#define _RSSP_LNK_NODE_MGR_WL_H_ + +#include "RsspStructWl.h" + +#ifdef __cplusplus +extern "C" { +#endif +/*-------------------------------------------------------------------- + * RSSPڲӿں Start + *--------------------------------------------------------------------*/ + + /** + * @brief InitLnkNodeArr_WL ʼ·ڵ + * @param num · ȡֵΧ:0x00-0xFF + * @param pRsspStruct RSSPIʵ ȡֵΧ:οṹ:RSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ +UINT8 InitLnkNodeArr_WL(UINT8 num,RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : SearchLnkBsdNode_WL + * : BsdַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * RsspSrcAddr UINT16 IN RsspԴַ + * DestBsdAdd UINT16 IN Bsdַ + * + * ȫֱ : LnkNodeArr ȫֱ + * ֵ : Lnk_Info_Node_Stru_WL* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +Lnk_Info_Node_Stru_WL* SearchLnkBsdNode_WL(UINT16 RsspSrcAddr,UINT16 DestBsdAdd,RSSP_INFO_STRU *pRsspStruct); + + +/*********************************************************************** + * : SearchLnkSse_SsrNode_WL + * : PSSPĿĵַԴַѯӦͨŽڵ㣬ͨŽڵھͷӦ + * ַ򷵻NULL + * : + * + * -------------------------------------------------------------- + * RsspSrcAddr UINT16 IN RsspԴַ + * RsspDestAddr UINT16 IN PsspĿĵַ + * + * ȫֱ : LnkNodeArr ȫֱ + * ֵ : Lnk_Info_Node_Stru_WL* NULL:ָڵ㲻 !=NULL ָڵַ + ***********************************************************************/ +Lnk_Info_Node_Stru_WL* SearchLnkSse_SsrNode_WL(UINT16 RsspSrcAddr,UINT16 RsspDestAddr,RSSP_INFO_STRU *pRsspStruct); + + +/*********************************************************************** + * : GetReplaceNode_WL + * : ͨɸǵĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * srcAddr UINT16 IN Դַ + * desAddr INT16 IN Ŀַ + * + * ȫֱ : LnkNodeArr* ȫֱͨŽڵ + * ֵ : Lnk_Info_Node_Stru_WL* NULL쳣 NULLͨŽڵ + ***********************************************************************/ +Lnk_Info_Node_Stru_WL* GetReplaceNode_WL(RSSP_INFO_STRU *pRsspStruct); + + +/*********************************************************************** + * : DestoryLnkNodeArr_WL + * : ͷͨŽڵĿռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +void DestoryLnkNodeArr_WL(RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : recvReplaceLnkNode_WL + * : ݱϢͨŽڵϢʼ + * : + * + * ------------------------------------------------------------- + * LocalDevName UINT16 IN ʶ + * pDataNode const DataNode_WL* IN Ľڵ + * pLnkNodeInfo Lnk_Info_Node_Stru_WL* INOUT ͨŽڵ + * + * ֵ : UINT8 1 0󷵻 + * ʹ ΪģյBSDʱӦͨŽڵ㲻ʱ + ***********************************************************************/ +UINT8 recvReplaceLnkNode_WL(UINT16 LocalDevName,const DataNode_WL* pDataNode,Lnk_Info_Node_Stru_WL *pLnkNodeInfo, DSU_RSSP_INFO_STRU_WL *pDsuRsrInfoStru_WL); + +/*********************************************************************** + * : outputReplaceLnkNode_WL + * : ԴַĿַBSDַȡöӦڵϢ + * ͨŽڵϢʼ + * : + * + * ------------------------------------------------------------- + * SrcAddr UINT16 IN Դַ + * BsdAddr UINT16 IN BSDַ + * DestAddr UINT16 IN SSEַ + * LocalDevName UINT32 IN ʶ + * pPLnkNodeInfo Lnk_Info_Node_Stru_WL** OUT ͨŽڵ + * + * ֵ : UINT8 1 0󷵻 + * ʹ Ϊģ飬ַָͨŽڵ㲻ʱ + * + ***********************************************************************/ +UINT8 outputReplaceLnkNode_WL(UINT16 SrcAddr,UINT16 BsdAddr,UINT16 DestAddr,UINT32 LocalDevName,Lnk_Info_Node_Stru_WL **pPLnkNodeInfo,RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : SetNodeParamWl + * : ָRSSPԴַRSSPĿַ(SSE SSR)BSDַѯӦͨŽڵǷڡ + * 򷵻ضӦͨŽڵָ룬򷵻NULL + * : + * + * ----------------------------------------------------------- + * destName UINT32 IN Ŀ豸ʶ + * + * ֵ : Lnk_Info_Node_Stru_WL* ͨŽڵָ룬 NULL: + ***********************************************************************/ +Lnk_Info_Node_Stru_WL* SearchNodeByAddr_WL(UINT32 destName,RSSP_INFO_STRU *pRsspStruct); + +/** + * @brief WriteToVarArray_WL д· + * @param VarArray · ȡֵΧֽ + * @param pRsspStruct RSSPIʵ ȡֵΧ:οṹ:RSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ +UINT8 WriteToVarArray_WL(UINT8 *VarArray,RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : GetLnkNodeArr_WL + * : ȡȫֵͨŽڵָԼͨŽڵ + * : + * + * ----------------------------------------------------------------------------- + * pLnkInfoNodeArr Lnk_Info_Node_Stru_WL** OUT ָָͨ + * LogId UINT8* OUT + * + * ֵ : + ***********************************************************************/ +void GetLnkNodeArr_WL(Lnk_Info_Node_Stru_WL** pLnkInfoNodeArr,UINT8 *OutLen,RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : AdjustLnkCycle + * : ָ͡ںšǰ·ǰ·ںŲǷΪִڡ + * : + * + * ----------------------------------------------------------- + * localType UINT8 IN + * cycleNum UINT32 IN ں + * lnkNode Lnk_Info_Node_Stru_WL* IN ·ڵ + * + * ֵ : + ***********************************************************************/ +void AdjustLnkCycle(UINT8 localType, UINT32 cycleNum, Lnk_Info_Node_Stru_WL *lnkNode); + +/*-------------------------------------------------------------------- + * RSSPڲӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspOutputWl.c b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspOutputWl.c new file mode 100644 index 0000000..d3dbeb3 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspOutputWl.c @@ -0,0 +1,982 @@ +/******************************************************** +* +* ļ RsspOutputWl.C +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* Rsspģ顣 +* ʹע⣺ +* RsspInitòܣñļڵĺ +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2009.12.16 ¥ΰ ¼׷ +* 2010.02.01 ¥ΰ TimeCounter ۼӣ˹ĵ +* 2011.11.17 ¥ΰ Ӧûݷ͵ʱڶⷢκݡ +* 2013.03.01 CreateBsdMsgΪCreateRsdMsg +********************************************************/ + +#include "RsspIFWl.h" +#include "RsspStructWl.h" +#include "RsspCommonWl.h" +#include "CommonQueue.h" +#include "Convert.h" +#include "dsuRsspFunc.h" +#include "RsspLnkNodeMgrWl.h" +#include "RsspRecordDelareWl.h" +#include "CommonRecord.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------- + * RSSPģڲʹú Start + *--------------------------------------------------------------------*/ +static UINT8 CreateRsdMsg_WL(const UINT8 *pAppData,UINT16 DataLen,UINT8 *OutBsdMsg, Lnk_Info_Node_Stru_WL** pPNode,RSSP_INFO_STRU *pRsspStru); +static UINT8 CreateSseMsg_WL(Lnk_Info_Node_Stru_WL *pLnkNodeInfo,UINT8 *OutSseMsg,RSSP_INFO_STRU *pRsspStru); +static UINT8 CreateSsrMsg_WL(Lnk_Info_Node_Stru_WL *pLnkNodeInfo,UINT8 *OutSsrMsg,RSSP_INFO_STRU *pRsspStru); + +static UINT8 WriteToAppArray(const UINT8* appData, const UINT16 appDataLen, Lnk_Info_Node_Stru_WL* lnkNode, UINT32* curAppArrayIdx, RSSP_INFO_STRU* rssp); + +static void SetRsspMsgHead_WL(UINT8 MsgType, UINT16 SrcAddr, UINT16 DestAddr, UINT8 *OutRsspMsg); + +static void RecvLnkStatusMng_WL(RSSP_INFO_STRU* pRsspStru); + +/*-------------------------------------------------------------------- + * RSSPģڲʹú End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * RSSPӿں Start + *--------------------------------------------------------------------*/ + + /** + * @brief RsspOutput_WL RSSPI + * @param AppToRs ӦøЭݶ ȡֵΧ:οṹQueueStruct + * @param VarArray · ȡֵΧ:ֽ + * @param pRsspStru RSSPIʵ ȡֵΧ:οṹRSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ +UINT8 RsspOutput_WL(QueueStruct* AppToRs, UINT8* VarArray, RSSP_INFO_STRU* pRsspStru) +{ + /** ֲ*/ + UINT8 ret = 0, index = 0; /*-< ÷ֵΪʧ*/ + UINT8 QueErrFlag = 0; /*-< öдʶΪ*/ + UINT8 LnkNodeNum = 0; /* ͨŽڵ */ + UINT16 MaxMsgLen = 0; /* һнڵݳ */ + UINT16 MsgLen = 0; /* Ϣ */ + UINT8* TmpOutMsg = NULL; /* ɱݻ */ + Lnk_Info_Node_Stru_WL* LnkNodeArr = NULL; /* ͨŽڵ */ + Lnk_Info_Node_Stru_WL* pNode = NULL; /* ͨŽڵָ */ + /* ywlou20101118 Add S */ + UINT8 appDataFlg = 0; /*-< ǷӦøݱʶΪ*/ + /* ywlou20101118 Add E */ + UINT32 destDevName = 0; /* Է豸ʶ */ + UINT8 dstType = 0; /*Ŀ*/ + UINT8* RecordArray = NULL; + UINT16 RecordSize = 0; + const UINT8 twoLen = 2; /*ֵ2*/ + UINT32 curAppArrayIdx = 4; /*Ӧ±,ǰ4ֽܳ*/ + + if ((NULL != AppToRs) && (NULL != VarArray) && (NULL != pRsspStru) && (NULL != pRsspStru->RecordArray) && (NULL != pRsspStru->gpSendSingleOutMsg)) /*-< Ƿǿ*/ + { + RecvLnkStatusMng_WL(pRsspStru); /*-< ø·״̬*/ + + TmpOutMsg = pRsspStru->gpSendSingleOutMsg; /*-< ø·״̬*/ + + RecordArray = pRsspStru->RecordArray; /*-< õ¼*/ + RecordSize = pRsspStru->RecordArraySize; /*-< õ¼鳤*/ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "RSSP Output:\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /*Ƿƺ꿪*/ + /* RSRԪʶ */ + PrintRecArrayByte(RecordArray, RecordSize, RSSP_OUTPUT); /*-< ¼ʶ־*/ + PrintRecArray2ByteB(RecordArray, RecordSize, (UINT16)QueueStatus(AppToRs)); /*-< ¼ܳ־*/ +#endif + RsspMemSet_WL(&pRsspStru->AppArray[0], pRsspStru->AppArraySize, 0); /*-< ոӦݴŵ麯*/ + /* ȡȫֵͨŽڵ */ + GetLnkNodeArr_WL(&LnkNodeArr, &LnkNodeNum, pRsspStru); /*-< ȡͨŽڵ麯*/ + + /* ޷ۼ */ + for (index = 0; index < LnkNodeNum; index++) /*-< ǰ·±ǷС·*/ + { + LnkNodeArr[index].CycleNum++; /*-< Эۼ1*/ + AdjustLnkCycle(pRsspStru->LocalType, LnkNodeArr[index].CycleNum, &LnkNodeArr[index]); /*-< øָ͡ںšǰ·ǰ·ںŲǷΪִں*/ + if (1 == LnkNodeArr[index].ExeCycle) /*-< ·Ƿִ*/ + { + LnkNodeArr[index].HasRsdBeforeSseOrSsr = 0; /*-< δɹRSDʶΪ*/ + /* ɸǽڵ */ + if ((DisbaledReplace_WL == LnkNodeArr[index].NodeStatus) + && (Halt_WL != LnkNodeArr[index].RsspLinInfo.SendLinkStatus)) /*-< ǰ·Ϊҷ״̬ж*/ + { + /* ͨʱ޷ۼ */ + LnkNodeArr[index].RsspLinInfo.NoAppDataCycleNum++; /*-< ޷Ӧ1*/ + } + else + { + /*-< ʲô*/ + } + + /* ۼ */ + AddTimeStamp_WL(&LnkNodeArr[index].RsspLinInfo.TimeStmp); /*-< ǰ·ں1*/ + } + else + { + /*-< ʲô*/ + } + } + + /* нڵݳ */ + MaxMsgLen = pRsspStru->OutputSize + 6; /*-< öнڵݳ*/ + + /* ȡӦ */ + while (QueueStatus(AppToRs) > 2) /*-< ӦøݶǷ*/ + { + QueueScan(2, pRsspStru->FrameData, AppToRs); /*-< õݳֽ*/ + MsgLen = ShortFromChar(pRsspStru->FrameData); /*-< õݳ*/ + + /* нڵݳ С */ + if ((MsgLen <= MaxMsgLen) && (MsgLen > twoLen)) /*-< ݳǷϷ*/ + { + /* һڵӦ */ + ret = QueueRead((MsgLen + 2), pRsspStru->FrameData, AppToRs); /*-< öкһڵӦ*/ + if (1 == ret) /*-< úǷɹ*/ + { + /* RSD */ + ret = CreateRsdMsg_WL(pRsspStru->FrameData, (UINT16)(MsgLen + 2), TmpOutMsg, &pNode, pRsspStru); /*-< RSD֡*/ + RsspMemSet_WL(pRsspStru->FrameData, (UINT16)(MsgLen + 2), 0); /*-< Ӧø֡*/ + /* RSDɳɹ */ + if (1 == ret) /*-< úǷɹ*/ + { + /* д :ȫݳ+ ֡ͷ + ֵ+ ֽ */ + MsgLen = ShortFromCharLE(&TmpOutMsg[RSSP_DATA_SIZE_POS_WL]) + RSSP_CRCM_1_POS_WL + CRC_16_LEN_WL; /*-< õ֡*/ + ret = WriteToAppArray(TmpOutMsg, MsgLen, pNode, &curAppArrayIdx, pRsspStru); /*-< RSD֡дк*/ + if (0 == ret) /*-< úǷʧ*/ + { + /*-< ʲô*/ + } + else + { + /* ʲô һڵ */ + /* ywlou20101118 Add S */ + /* һ֡BSD */ + pNode->HasRsdBeforeSseOrSsr = 1; /*-< δɹRSDʶΪ*/ + /* ywlou20101118 Add E */ + } + } + else /* ʧ */ + { + /*-< ʲô*/ + } + } + else + { + /* ָȵĶжȡʧܣ˵ʣԪز㣬ֱѭ¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "W:QueueRead Err\n"); /* ʧ */ +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /*Ƿƺ꿪*/ + PrintRecArrayByte(RecordArray, RecordSize, OUTPUT_READ_QUE_ERR); /*-< ¼ʧ־*/ +#endif + break; /*-< ˳*/ + } + } + else /* MsgLen >= MaxMsgLen */ + { + /* ¼,һ */ + QueueElementDiscard(MsgLen + 2, AppToRs); /*-< ɾԪغ*/ + /* ָȵĶжȡʧܣ˵ʣԪز㣬ֱѭ¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "W:QueueRead Err\n"); /* ʧ */ +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /*Ƿƺ꿪*/ + PrintRecArrayByte(RecordArray, RecordSize, OUTPUT_LEN_ERR); /*-< ¼Ȳȷ־*/ +#endif + } + } + QueErrFlag = 0; /*-< öвʶΪ*/ + /* ͨŽڵ·״̬仯 */ + for (index = 0; index < LnkNodeNum; index++) /*-< ǰ·±ǷС·*/ + { + if (1 == LnkNodeArr[index].ExeCycle) /*-< ·Ƿִ*/ + { + if (pRsspStru->NoSendAppData < LnkNodeArr[index].RsspLinInfo.NoAppDataCycleNum) /*-< ·޷ӦǷֵ*/ + { + /*״̬ж*/ + LnkNodeArr[index].RsspLinInfo.SendLinkStatus = Halt_WL; /*-< ô·״̬Ϊж*/ + /*޷Ӧ */ + LnkNodeArr[index].RsspLinInfo.NoAppDataCycleNum = 0; /*-< ·޷Ӧ*/ + /*״̬Ϊж*/ + if (Halt_WL == LnkNodeArr[index].RsspLinInfo.RecvLinkStatus) /*-< ·״̬Ƿж*/ + { + /*Է豸ʶ*/ + destDevName = LnkNodeArr[index].DestDevName; /*-< õ·ԷΨһID*/ + /*ɾȫ·*/ + ret = RsspLnkDelete_WL(destDevName, pRsspStru); /*-< ɾ·*/ + } + } + else + { + /*-< ʲô*/ + } + + if ((RSSP_TYPE_VOBC_WL == pRsspStru->LocalType) || (RSSP_TYPE_VOBC_BACK_WL == pRsspStru->LocalType) || (RSSP_TYPE_AOM_WL == pRsspStru->LocalType)) /*-< Ƿ񳵻򳵺󱸻AOM*/ + { + if (DisbaledReplace_WL == LnkNodeArr[index].NodeStatus) /*-< ǰ·Ƿ*/ + { +#ifdef RSSP_NO_HLHT /*Ƿ޻ͨID꿪*/ + dstType = (LnkNodeArr[index].DestDevName >> 8) & 0xff; /*-< ĿID*/ + +#else + dstType = DquToDevType(LnkNodeArr[index].DestDevName, pRsspStru->pDsuRsspInfoStruWL); /*-< øHLHTIDת豸ͺĿID*/ +#endif + } + if ((RSSP_TYPE_VOBC_WL == dstType) || (RSSP_TYPE_VOBC_BACK_WL == dstType) || (RSSP_TYPE_TTIL_WL == dstType)) /*-< ԷǷ񳵻򳵺󱸻βͨ*/ + { + appDataFlg = 1; /*-< ǷӦøݱʶΪ*/ + } + else /*ͨ*/ + { + if (1 == LnkNodeArr[index].HasRsdBeforeSseOrSsr) /*-< SSESSR֮ǰǷRSDʶǷΪ*/ + { + appDataFlg = 1; /*-< ǷӦøݱʶΪ*/ + } + else /*򲻷SSESSR*/ + { + appDataFlg = 0; /*-< ǷӦøݱʶΪ*/ + } + } + } + else + { + appDataFlg = 1; /*-< ǷӦøݱʶΪ*/ + } + LnkNodeArr[index].HasRsdBeforeSseOrSsr = 0; /*-< SSESSR֮ǰǷRSDʶΪ*/ + + /* ״̬Ϊ SSE */ + /* ywlou20101118 MOd S */ + /* ޸ΪûBSDݲ SSE ԼSSR */ + if ((0 == QueErrFlag) && (DisbaledReplace_WL == LnkNodeArr[index].NodeStatus) && (SendSSE_WL == LnkNodeArr[index].RsspLinInfo.RecvLinkStatus) && (1 == appDataFlg)) /*-< дʶǷ Ҵ·Ƿ ״̬ǷSSE ҷӦøݱʶǷ*/ + { + /* ywlou20101118 MOd S */ + ret = CreateSseMsg_WL(&LnkNodeArr[index], TmpOutMsg, pRsspStru); /*-< SSE֡*/ + if (ret == 1) /*-< úǷɹ*/ + { + ret = WriteToAppArray(TmpOutMsg, RSSP_SSE_LEN_WL, &LnkNodeArr[index], &curAppArrayIdx, pRsspStru); /*-< SSE֡дк*/ + if (0 == ret) /*-< úǷʧ*/ + { + /* Ϊдʧܣ˵жпռ䲻дSSE + * Ѿд뱨ġ + * Ѷвı־Ϊ 1 + */ + QueErrFlag = 1; /*-< öдʶΪ*/ + } + else + { + /*-< ʲô*/ + } + } + else /* ʧ */ + { + /*-< ʲô*/ + } + } + + /* ڵ״̬Ϊɸ ״̬ΪSendSSR ôSSR */ + /* ywlou20101118 MOd S */ + /* ޸ΪûBSDݲ SSE ԼSSR */ + if ((0 == QueErrFlag) && (DisbaledReplace_WL == LnkNodeArr[index].NodeStatus) + && (SendSSR_WL == LnkNodeArr[index].RsspLinInfo.SendLinkStatus) + && (1 == appDataFlg)) /*-< дʶǷ Ҵ·Ƿ ״̬ǷSSR ҷӦøݱʶǷ*/ + { + /* ywlou20101118 MOd E */ + ret = CreateSsrMsg_WL(&LnkNodeArr[index], TmpOutMsg, pRsspStru); /*-< SSR֡*/ + if (ret == 1) /*-< úǷɹ*/ + { + ret = WriteToAppArray(TmpOutMsg, RSSP_SSR_LEN_WL, &LnkNodeArr[index], &curAppArrayIdx, pRsspStru); /*-< SSR֡дк*/ + if (0 == ret) /*-< úǷʧ*/ + { + /*-< ʲô*/ + } + else + { + /*-< ʲô*/ + } + } + else + { + /*-< ʲô*/ + } + + } + else + { + /* ʲô */ + } + } + else + { + /* ʲô */ + } + } + /* м */ + ret = WriteToVarArray_WL(VarArray, pRsspStru); /*-< д·ݺ*/ + + PrintRecArrayByte(RecordArray, RecordSize, LINK_INFO); /*-< ¼RSSPI·ݱʶ*/ + PrintRecArray2ByteB(RecordArray, RecordSize, ShortFromChar(VarArray)); /*-< ¼·ݳ */ + + /* ͨŽڵϢ */ + for (index = 0; index < LnkNodeNum; index++) /*-< ǰ·±ǷС·*/ + { + if (DisbaledReplace_WL == LnkNodeArr[index].NodeStatus) /*-< ǰ·ڵǷ*/ + { +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "Node Info:"); + PrintFiles(RecordArray, RecordSize, "\nDestType:"); + PrintFileU16Hex(RecordArray, RecordSize, LnkNodeArr[index].DestDevName); /* ԷʶDestType */ + + PrintFiles(RecordArray, RecordSize, "\tSrcAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspSrcAddr); /* RSSPԴַ(SrcAddr) */ + PrintFiles(RecordArray, RecordSize, "\tBsdAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, LnkNodeArr[index].DestBsdAdd); /* RSSPBSDַ(BsdAddr) */ + PrintFiles(RecordArray, RecordSize, "\tDestAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspDestAddr); /* RSSPĿַ(DestAddr) */ + /* wangpeipei 20111205 ADD E */ + + PrintFiles(RecordArray, RecordSize, "\tNoAppDataCr:"); + PrintFileHex(RecordArray, RecordSize, &LnkNodeArr[index].RsspLinInfo.NoAppDataCycleNum, 1); /* Ӧ */ + PrintFiles(RecordArray, RecordSize, "\tRecvDataCr:"); + PrintFileHex(RecordArray, RecordSize, &LnkNodeArr[index].RsspLinInfo.NoRecvDataCycleNum, 1); /* ޽ */ + PrintFiles(RecordArray, RecordSize, "\tRcvStatus:"); + PrintFileHex(RecordArray, RecordSize, &LnkNodeArr[index].RsspLinInfo.RecvLinkStatus, 1); /* ״̬(RcvStatus) */ + PrintFiles(RecordArray, RecordSize, "\tSndStatus:"); + PrintFileHex(RecordArray, RecordSize, &LnkNodeArr[index].RsspLinInfo.SendLinkStatus, 1); /* ״̬(RcvStatus) */ + PrintFiles(RecordArray, RecordSize, "\tNodeStatus:"); + PrintFileHex(RecordArray, RecordSize, &LnkNodeArr[index].NodeStatus, 1); /* ɸ״̬(NodeStatus) */ + PrintFiles(RecordArray, RecordSize, "\tTC:"); + PrintFileU32Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.TC); /* (TC) */ + PrintFiles(RecordArray, RecordSize, "\tSrcAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.RsspSrcAddr); /* RSSPԴַ(SrcAddr) */ + PrintFiles(RecordArray, RecordSize, "\tBsdAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.DestBsdAdd); /* RSSPBSDַ(BsdAddr) */ + PrintFiles(RecordArray, RecordSize, "\tDestAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.RsspDestAddr); /* RSSPĿַ(DestAddr) */ + PrintFiles(RecordArray, RecordSize, "\tLastRcvTCr:"); + PrintFileU32Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.LastLocalRecTC); /* յıʱ(LastRcvTCr) */ + PrintFiles(RecordArray, RecordSize, "\tLastSsrTC:"); + PrintFileU32Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.SsrTc); /* ϴͬں(LastSsrTC) */ + PrintFiles(RecordArray, RecordSize, "\tRcvTCe:"); + PrintFileU32Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.NowRecvTCr); /* ǰյͷʱ(RcvTCe) */ + PrintFiles(RecordArray, RecordSize, "\tSSETCr:"); + PrintFileU32Hex(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.SseTC); /* SSEʱں(SSETCr) */ + PrintFiles(RecordArray, RecordSize, "\tSndSsrNum:"); + PrintFileHex(RecordArray, RecordSize, &LnkNodeArr[index].RsspLinInfo.TimeStmp.NumSendSse, 1); /* SSE(SndSsrNum) */ + PrintFiles(RecordArray, RecordSize, "\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /*Ƿƺ꿪*/ + PrintRecArrayByte(RecordArray, RecordSize, index); /*-< ¼ǰ·±־*/ + PrintRecArray2ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.RsspDestAddr); /*-< ¼RSSPIĿĵַ־*/ + PrintRecArray2ByteB(RecordArray, RecordSize, LnkNodeArr[index].DestTypeId); /*-< ¼ĿID־*/ + PrintRecArray2ByteB(RecordArray, RecordSize, LnkNodeArr[index].DestLogicId); /*-< ¼Ŀ߼ID־*/ + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].ExeCycle); /*-< ¼ǷִЭ־*/ + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].CycleNum); /*-< ¼ں־*/ + + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].NodeStatus); /*-< ¼ɸ״̬־*/ + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.RecvLinkStatus); /*-< ¼״̬־*/ + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.NoRecvDataCycleNum); /*-< ¼޽־*/ + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.SendLinkStatus); /*-< ¼״̬־*/ + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.NoAppDataCycleNum); /*-< ¼Ӧ־*/ + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].RecvKeepHaltCycleNum); /*-< ձHalt_WL״̬־*/ + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].RecvKeepSendSseCycleNum); /*-< ձSendSSE_WL״̬־*/ + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].HasRsdBeforeSseOrSsr); /*-< ¼SSESSR֮ǰǷRSD־*/ + + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.TC); /*-< ¼־*/ + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.NowTn[0]); /*-< ¼ǰڶӦʱ-1ͨ־*/ + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.NowTn[1]); /*-< ¼ǰڶӦʱ-2ͨ־*/ + + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.NowRecvTCr); /*-< ¼ǰյͷʱ(RcvTCe)־*/ + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.LastLocalRecTC); /*-< ¼յıʱ(LastRcvTCr)־*/ + + PrintRecArrayByte(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.NumSendSse); /*-< ¼SSE־*/ + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.SseTC); /*-< ¼SSEʱTC־*/ + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.SsrTc); /*-< ¼յSSRʱTC־*/ + + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.RecvSseTCe); /*-< ¼յSSEʱ֡TC־*/ + + /*յSSR RSDʱ*/ + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.NowSINIT_ADD_SID_XOR_Tn[0]); /*-< ¼ǰյʱ SINITr AND [SIDr ^ Tr(n)]1ͨ־*/ + PrintRecArray4ByteB(RecordArray, RecordSize, LnkNodeArr[index].RsspLinInfo.TimeStmp.NowSINIT_ADD_SID_XOR_Tn[1]); /*-< ¼ǰյʱ SINITr AND [SIDr ^ Tr(n)]-2ͨ־*/ +#endif + } + } + + } + + return ret; /*-< غֵ*/ +} + + +/*-------------------------------------------------------------------- + * RSSPӿں End + *--------------------------------------------------------------------*/ + + /*-------------------------------------------------------------------- + * RSSPģڲʹúʵ Start + *--------------------------------------------------------------------*/ + + /** +* @brief CreateRsdMsg_WL Ӧ RSD +* @param pAppData Ӧò㵽Rsspжнڵ ȡֵΧ:ֽ +* @param DataLen pAppDataݳ ȡֵΧ:0x0000-0xFFFF +* @param OutBsdMsg RSSPϢ֡ ȡֵΧ:ֽ +* @param pPNode Ӧڵ ȡֵΧ:οṹLnk_Info_Node_Stru_WL +* @param pRsspStru RSSPI ȡֵΧ:οṹRSSP_INFO_STRU + * @return 0:ʧ;1:ɹ +*/ +static UINT8 CreateRsdMsg_WL(const UINT8 *pAppData,UINT16 DataLen, + UINT8 *OutBsdMsg, Lnk_Info_Node_Stru_WL** pPNode,RSSP_INFO_STRU *pRsspStru) +{ + UINT8 ret = 0; /*-< úֵΪʧ*/ + UINT32 LocalDevName = 0; /*ΨһID*/ + UINT16 oppTypeId = 0; /*ԷID*/ + UINT16 oppLogicId = 0; /*Է߼ID*/ + UINT16 MsgLen = 0; /* Ӧݳ */ + UINT16 SrcAddr = 0, DestAddr = 0; /* ԴַԼ ĿַSSE_SSR*/ + UINT16 BsdAddr = 0; /* BSDַ */ + UINT16 CRC16 = 0; /* RSSPϢCRC */ + UINT32 CRCM[2] ={0}; /* CRCM */ + Lnk_Info_Node_Stru_WL *pTmpNode = NULL; /* ͨŽڵָ */ + UINT8 *RecordArray = NULL; /* ¼ */ + UINT16 RecordSize = 0; /* ¼С */ + UINT32 DestDevName = 0; + const UINT8 DEST_TYPE_APP_QUE_POS = 2; /* ӦòбԷ͵λ */ + const UINT8 DEST_ID_APP_QUE_POS = DEST_TYPE_APP_QUE_POS+1; /* ӦòбԷIDλ */ + const UINT8 DEST_LOGIC_ID_QUE_POS = DEST_ID_APP_QUE_POS+1; /* ӦòбԷ߼IDλ */ + const UINT8 DATA_APP_QUE_POS = DEST_LOGIC_ID_QUE_POS + 2; /* ӦòбӦݵλ */ + + if ((NULL != pAppData)&&(NULL != OutBsdMsg)&&(NULL != pPNode) && (NULL != pRsspStru) &&(NULL != pRsspStru->pDsuRsspInfoStruWL)&&(DataLen >= DATA_APP_QUE_POS)&&(NULL != pRsspStru->RecordArray)) /*-< Ƿǿ*/ + { + RecordArray = pRsspStru->RecordArray; /*-< ü¼*/ + RecordSize = pRsspStru->RecordArraySize; /*-< ü¼鳤*/ + + LocalDevName = pRsspStru->pDsuRsspInfoStruWL->LocEmitterName; /*-< ñΨһID*/ + /* + * ---------------------------------------------------- + * ݳ | DestType | DestID | Ӧ | + * 2ֽ | 1ֽ | 1ֽ | n | + * ----------------------------------------------------- + */ + + TypeId2DevName_WL(pAppData[DEST_TYPE_APP_QUE_POS], pAppData[DEST_ID_APP_QUE_POS], &oppTypeId); /*-< õõԷID*/ + oppLogicId = ShortFromChar(&pAppData[DEST_LOGIC_ID_QUE_POS]); /*-< õõԷ߼ID*/ +#ifdef RSSP_NO_HLHT + DestDevName = oppTypeId; /*-< öԷΨһID*/ +#else + DestDevName = DquTypeIdToHlhtId(oppTypeId, oppLogicId, pRsspStru->pDsuRsspInfoStruWL); /*-< öԷΨһID*/ +#endif + ret = dsuRsspRGetAddrWl(DestDevName, LocalDevName, &SrcAddr, &DestAddr, pRsspStru->pDsuRsspInfoStruWL); /*-< ûȡЭַ,ֵֵ*/ + if (ret == 1) /*-< ֵǷɹ*/ + { + } + else + { + ret = 0; /*-< úֵΪʧ*/ + return ret; /*-< غֵ*/ + } + BsdAddr = DestAddr; /*-< BSDַ*/ + MsgLen = DataLen - DATA_APP_QUE_POS; /*-< Ӧݳ*/ + +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "IN:\n"); + PrintFiles(RecordArray, RecordSize, "SrcAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, SrcAddr); /* Դַ */ + PrintFiles(RecordArray, RecordSize, "\tBsdAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, BsdAddr); /* BSDַ */ + PrintFiles(RecordArray, RecordSize, "\tSrcAddr:"); + PrintFileU16Hex(RecordArray, RecordSize, DestAddr); /* Ŀַ */ + PrintFiles(RecordArray, RecordSize, "\tDataLen:"); + PrintFileU16Hex(RecordArray, RecordSize, MsgLen); /* Ӧݳ */ + PrintFiles(RecordArray, RecordSize, "\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordSize, 0x80); /*-< ¼֡־*/ + PrintRecArray2ByteB(RecordArray, RecordSize, BsdAddr); /*-< ¼Ŀַ־*/ + PrintRecArray2ByteB(RecordArray, RecordSize, MsgLen); /*-< ¼Ӧݳ־*/ +#endif + + /* ѯӦͨŽڵǷ */ + pTmpNode = SearchNodeByAddr_WL(DestDevName, pRsspStru); /*-< òѯڵ㺯*/ + if (NULL == pTmpNode) /*-< ͨŽڵǷΪտ*/ + { + /* ݵַĸǽڵ㣬ڵ㸲 */ + ret = outputReplaceLnkNode_WL(SrcAddr, BsdAddr, DestAddr, LocalDevName, &pTmpNode, pRsspStru); /*-< ɽڵ㺯*/ + if (0 == ret) /*-< úǷɹ*/ + { + /* ڵ㸲 ʧܣ¼ 󷵻 */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "W:Replace Node Err.\n"); /*-< ¼ɽڵ־*/ +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordSize, OUTPUT_NEW_NODE_ERR); /*-< ¼ɽڵ־*/ +#endif + return ret; /*-< غֵ*/ + } + else + { + pTmpNode->CycleNum = *pRsspStru->CycleNum; /*-< ӦڸЭ*/ + pTmpNode->DestTypeId = oppTypeId; /*-< öԷID*/ + pTmpNode->DestLogicId = oppLogicId; /*-< öԷ߼ID*/ + pTmpNode->RsspLinInfo.TimeStmp.TC = pTmpNode->CycleNum; /*-< ·üʼ*/ + PrintRecArrayByte(RecordArray, RecordSize, OUTPUT_NEW_NODE); /*-< ¼½ڵ־*/ + } + } + else /* ͨŽڵ */ + { + /* */ + } + + if (1 == pTmpNode->ExeCycle) /*-< ·Ƿִ*/ + { + /* Ӧݷ͵ͨŽڵΪɸ״̬ */ + pTmpNode->NodeStatus = DisbaledReplace_WL; /*-< ·ڵ*/ + (*pPNode) = pTmpNode; /*-< ͨŽڵָ뱣浽ָ*/ + + /* ֡ͷ趨 */ + SetRsspMsgHead_WL(RSSP_RSD_MSG_WL, SrcAddr, BsdAddr, OutBsdMsg); /*-< ֡ͷ*/ + + /* Body 趨 + * ---------------------------------------------------- + * | ȫݳ | CRCM_1 | CRCM_2 | Ӧ | + * 4ֽ | 2ֽ | 4ֽ | 4ֽ | n | + * ----------------------------------------------------- + */ + /* Ӧ */ + /* pAppData+8 ʼ MsgLenӦݵ */ + RsspMemCopy_WL(&pAppData[DATA_APP_QUE_POS], &OutBsdMsg[RSSP_DATA_POS_WL], MsgLen); /*-< Ӧݵ*/ + /* wangpeipei 20120328 yuweiliantiaoshi Mod */ + /*if((MsgLen%2) != 0)*/ /* ȫݳȷż */ + /*{ + OutBsdMsg[RSSP_DATA_POS+MsgLen] = 0;*/ /* ȫݲ */ + /*MsgLen += 1; + } + else + {*/ + /* ʲô */ + /*}*/ + + /* CRCMֵ,(϶1 ) */ + ret = CalcCRCM_WL(&OutBsdMsg[RSSP_DATA_POS_WL], MsgLen, + pTmpNode->RsspLinInfo.LocalNode.SIDr, + pTmpNode->RsspLinInfo.TimeStmp.NowTn, + CRCM); /*-< üSVC,ֵֵ*/ + + /* 趨 4ֽ */ + LongToCharLE(pTmpNode->RsspLinInfo.TimeStmp.TC, &OutBsdMsg[RSSP_TC_POS_WL]); /*-< ü*/ + + /* ȫݳ Ӧ+ 2CRCM 2ֽ */ + ShortToCharLE((UINT16)(MsgLen + 2 * CRCM_LEN_WL), &OutBsdMsg[RSSP_DATA_SIZE_POS_WL]); /*-< ݳȵ*/ +#ifdef DOUBLE_CPU_INTERACTIVE_SVC + if(0u == pRsspStru->cpuId) /*-< CPUIDǷΪ0*/ + { + /* CRCM[0] CRCM[1] 趨 4 ֽ */ + LongToCharLE(CRCM[0], &OutBsdMsg[RSSP_CRCM_1_POS_WL]); /*-< 1ͨSVC*/ + LongToCharLE((UINT32)0u, &OutBsdMsg[RSSP_CRCM_2_POS_WL]); /*-< 2ͨ0*/ + } + else + { + /* CRCM[0] CRCM[1] 趨 4 ֽ */ + LongToCharLE((UINT32)0u, &OutBsdMsg[RSSP_CRCM_1_POS_WL]); /*-< 1ͨ0*/ + LongToCharLE(CRCM[1], &OutBsdMsg[RSSP_CRCM_2_POS_WL]); /*-< 2ͨSVC*/ + } +#else + /* CRCM[0] CRCM[1] 趨 4 ֽ */ + LongToCharLE(CRCM[0], &OutBsdMsg[RSSP_CRCM_1_POS_WL]); /*-< 1ͨSVC*/ + LongToCharLE(CRCM[1], &OutBsdMsg[RSSP_CRCM_2_POS_WL]); /*-< 2ͨSVC*/ +#endif + /* 16λ CRC 趨 2 ֽ */ + CRC16 = ComputeMsgCRC16_WL(OutBsdMsg, (UINT16)(MsgLen + RSSP_FIXED_LEN_WL - CRC_16_LEN_WL)); /*-< CRCֵ*/ + ShortToCharLE(CRC16, &OutBsdMsg[(UINT16)(MsgLen + RSSP_FIXED_LEN_WL - CRC_16_LEN_WL)]); /*-< CRCֵ*/ + + + /* ޷ӦΪ 0 */ + pTmpNode->RsspLinInfo.NoAppDataCycleNum = 0; /*-< ӦΪ0*/ + + ret = 1; /*-< úֵΪɹ*/ + } + else /*·ִRSD*/ + { + ret = 0; /*-< úֵΪʧ*/ + } + } + + return ret; /*-< غֵ*/ +} + + /** + * @brief CreateSseMsg_WL SSE֡ + * @param pLnkNodeInfo ·ڵ ȡֵΧ:οṹ:Lnk_Info_Node_Stru_WL + * @param OutSseMsg SSE֡ ȡֵΧ:οṹ:ֽ + * @param pRsspStru RSSPIʵ ȡֵΧ:οṹ:RSSP_INFO_STRU + * @return 0:ʧ 1:ɹ + */ +static UINT8 CreateSseMsg_WL(Lnk_Info_Node_Stru_WL* pLnkNodeInfo, UINT8* OutSseMsg, RSSP_INFO_STRU* pRsspStru) +{ + UINT8 ret = 0u; /*-< úֵΪʧ*/ + UINT16 Crc16 = 0u; /*CRCֵ*/ + UINT32 TmpSeqEnq = 0u; /*ʱSEQENQ*/ + + pLnkNodeInfo->RsspLinInfo.RecvLinkStatus = WaitSSR_WL; /*-< õǰ·ڵ״̬ΪSSR*/ + + pLnkNodeInfo->RsspLinInfo.NoRecvDataCycleNum = 0u; /*-< 㵱ǰ·ڵ*/ + + pLnkNodeInfo->RsspLinInfo.NoAppDataCycleNum = 0u; /*-< 㵱ǰ·ڵ޷Ӧ*/ + + pLnkNodeInfo->RecvKeepSendSseCycleNum = 0u; /*-< ձSendSSE_WL״̬*/ + + /* SSEʱںͶӦʱ趨 */ + pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTC = pLnkNodeInfo->RsspLinInfo.TimeStmp.TC; /*-< õǰ·ڵSSEʱںΪǰں*/ + pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[0] = pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[0]; /*-< õǰ·ڵSSEʱ1ͨʱΪ1ͨSINIT*/ + pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[1] = pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[1]; /*-< õǰ·ڵSSEʱ2ͨʱΪ2ͨSINIT*/ + + SetRsspMsgHead_WL(RSSP_SSE_MSG_WL, pLnkNodeInfo->RsspLinInfo.RsspSrcAddr, pLnkNodeInfo->RsspLinInfo.RsspDestAddr, OutSseMsg); /*-< ֡ͷ*/ + + LongToCharLE(pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTC, &OutSseMsg[RSSP_TC_POS_WL]); /*-< SSEں*/ + +#ifdef DOUBLE_CPU_INTERACTIVE_SVC /*Ƿ˫SVC꿪*/ + if (0u == pRsspStru->cpuId) /*-< ǰCPUǷ0*/ + { + TmpSeqEnq = pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[0] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[0]; /*-< õ1ͨSSEʱ*/ + LongToCharLE(TmpSeqEnq, &OutSseMsg[RSSP_SSE_ENQ_1_POS_WL]); /*-< 1ͨSSEʱSSE֡SeqEnq1λ*/ + + LongToCharLE((UINT32)0u, &OutSseMsg[RSSP_SSE_ENQ_2_POS_WL]); /*-< 2ͨ0SSE֡SeqEnq2λ*/ + } + else + { + LongToCharLE((UINT32)0u, &OutSseMsg[RSSP_SSE_ENQ_1_POS_WL]); /*-< 1ͨ0SSE֡SeqEnq1λ*/ + + TmpSeqEnq = pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[1] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[1]; /*-< õ2ͨSSEʱ*/ + LongToCharLE(TmpSeqEnq, &OutSseMsg[RSSP_SSE_ENQ_2_POS_WL]); /*-< 2ͨSSEʱSSE֡SeqEnq2λ*/ + } +#else/* SEQENQ_1 SIDe ^ Tn 趨 */ + TmpSeqEnq = pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[0] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[0]; /*-< õ1ͨSSEʱ*/ + LongToCharLE(TmpSeqEnq, &OutSseMsg[RSSP_SSE_ENQ_1_POS_WL]); /*-< 1ͨSSEʱSSE֡SeqEnq1λ*/ + + /* SEQENQ_2 趨 */ + TmpSeqEnq = pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[1] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.SseTn[1]; /*-< õ2ͨSSEʱ*/ + LongToCharLE(TmpSeqEnq, &OutSseMsg[RSSP_SSE_ENQ_2_POS_WL]); /*-< 2ͨSSEʱSSE֡SeqEnq2λ*/ +#endif + + Crc16 = ComputeMsgCRC16_WL(OutSseMsg, RSSP_SSE_LEN_WL - CRC_16_LEN_WL); /*-< õ֡CRCֵ*/ + ShortToCharLE(Crc16, &OutSseMsg[RSSP_SSE_LEN_WL - CRC_16_LEN_WL]); /*-< CRCֵ֡*/ + + ret = 1u; /*-< úֵΪɹ*/ + return ret; /*-< غֵ*/ +} + +/*********************************************************************** + * : CreateSsrMsg_WL + * : SSRϢ֡ + * : + * + * -------------------------------------------------------------- + * pLnkNodeInfo Lnk_Info_Node_Stru_WL* INOUT ͨŽڵָ + * OutSsrMsg UINT8* OUT SSR + * pLnkNodeInfo ԼOutSseMsg ָǿգɵô֤ + * ֵ : 1 + ***********************************************************************/ +static UINT8 CreateSsrMsg_WL(Lnk_Info_Node_Stru_WL *pLnkNodeInfo,UINT8 *OutSsrMsg,RSSP_INFO_STRU *pRsspStru) +{ + UINT8 ret = 0; /* ֵ */ + UINT16 Crc16 = 0; /* CRC 16 */ + UINT32 TmpSeqIni = 0; /* ʱSEQIni */ + + /* 趨״̬Ϊ */ + pLnkNodeInfo->RsspLinInfo.SendLinkStatus = SendData_WL; + pLnkNodeInfo->RsspLinInfo.NoAppDataCycleNum = 0; + + + /* ֡ͷ趨 */ + SetRsspMsgHead_WL(RSSP_SSR_MSG_WL,pLnkNodeInfo->RsspLinInfo.RsspSrcAddr, + pLnkNodeInfo->RsspLinInfo.RsspDestAddr,OutSsrMsg); + + /* Body 趨 */ + LongToCharLE(pLnkNodeInfo->RsspLinInfo.TimeStmp.TC, &OutSsrMsg[RSSP_TC_POS_WL]); /* */ + LongToCharLE(pLnkNodeInfo->RsspLinInfo.TimeStmp.RecvSseTCe,&OutSsrMsg[RSSP_SSR_TCENQ_POS_WL]); /* ܵSSEļ */ + +#ifdef DOUBLE_CPU_INTERACTIVE_SVC + if(0u == pRsspStru->cpuId) + { + TmpSeqIni = pLnkNodeInfo->RsspLinInfo.TimeStmp.SeqEng[0] ^ pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[0] + ^ pLnkNodeInfo->RsspLinInfo.LocalNode.DATAVER[0] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[0]; + LongToCharLE(TmpSeqIni,&OutSsrMsg[RSSP_SSR_INI_1_POS_WL]); + + /* SEQINI_2 趨 */ + LongToCharLE((UINT32)0u,&OutSsrMsg[RSSP_SSR_INI_2_POS_WL]); + } + else + { + /* SEQINI = SEQENQ ^ SIDr ^ DataVer ^ Tr(n) */ + /* SEQINI_1 趨 */ + LongToCharLE((UINT32)0u,&OutSsrMsg[RSSP_SSR_INI_1_POS_WL]); + + /* SEQINI_2 趨 */ + TmpSeqIni = pLnkNodeInfo->RsspLinInfo.TimeStmp.SeqEng[1] ^ pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[1] + ^ pLnkNodeInfo->RsspLinInfo.LocalNode.DATAVER[1] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[1]; + LongToCharLE(TmpSeqIni,&OutSsrMsg[RSSP_SSR_INI_2_POS_WL]); + } +#else + /* SEQINI = SEQENQ ^ SIDr ^ DataVer ^ Tr(n) */ + /* SEQINI_1 趨 */ + TmpSeqIni = pLnkNodeInfo->RsspLinInfo.TimeStmp.SeqEng[0] ^ pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[0] + ^ pLnkNodeInfo->RsspLinInfo.LocalNode.DATAVER[0] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[0]; + LongToCharLE(TmpSeqIni,&OutSsrMsg[RSSP_SSR_INI_1_POS_WL]); + + /* SEQINI_2 趨 */ + TmpSeqIni = pLnkNodeInfo->RsspLinInfo.TimeStmp.SeqEng[1] ^ pLnkNodeInfo->RsspLinInfo.LocalNode.SIDr[1] + ^ pLnkNodeInfo->RsspLinInfo.LocalNode.DATAVER[1] ^ pLnkNodeInfo->RsspLinInfo.TimeStmp.NowTn[1]; + LongToCharLE(TmpSeqIni,&OutSsrMsg[RSSP_SSR_INI_2_POS_WL]); +#endif + /* NUM_DATAVER 趨 źŵ1 źŵ2 汾һ ĬΪźŵ1 */ + OutSsrMsg[RSSP_SSR_NUM_POS_WL] = pLnkNodeInfo->RsspLinInfo.LocalNode.NumDataVer[0]; + + /* CRC 趨*/ + Crc16 = ComputeMsgCRC16_WL(OutSsrMsg,RSSP_SSR_LEN_WL-CRC_16_LEN_WL); + ShortToCharLE(Crc16,&OutSsrMsg[RSSP_SSR_LEN_WL-CRC_16_LEN_WL]); + + ret =1; + return ret; +} + +/*********************************************************************** + * : SetRsspMsgHead_WL + * : RsspϢ֡ͷɡ + * : + * + * -------------------------------------------------------------- + * MsgLen UINT8 IN Ϣ + * SrcAddr UINT16 IN Դַ + * DestAddr UINT16 IN Ŀַ + * OutRsspMsg UINT8* OUT RSSPϢ֡ + * OutRsspMsg ָǿԼȷԣɵô֤ + * ֵ : + ***********************************************************************/ +static void SetRsspMsgHead_WL(UINT8 MsgType, UINT16 SrcAddr, UINT16 DestAddr, UINT8 *OutRsspMsg) +{ + OutRsspMsg[RSSP_APP_CTGRY_POS_WL] = RSSP_APP_CATEGORY_WL; /* signaling variables */ + OutRsspMsg[RSSP_MSG_TYPE_POS_WL] = MsgType; /* Ϣ趨 */ + ShortToCharLE(SrcAddr,&OutRsspMsg[RSSP_SRC_ADD_POS_WL]); /* 趨ԴַLITTLE endian */ + ShortToCharLE(DestAddr,&OutRsspMsg[RSSP_DEST_ADD_POS_WL]); /* 趨ԴַLITTLE endian */ + +} + +/* +*: WriteToAppArray +*: дݵЭӦ +*: const UINT8* appData Ӧ +* const UINT16 appDataLen Ӧ鳤 +* Lnk_Info_Node_Stru_WL* lnkNode ·ڵ +* RSSP_INFO_STRU* rssp RSSPIṹ +*: UINT32* curAppArrayIdx ЭӦ鵱ǰ± +*: +*ֵ: Ƿдɹ.0:ʧ;1:ɹ +*/ +static UINT8 WriteToAppArray(const UINT8* appData, const UINT16 appDataLen, Lnk_Info_Node_Stru_WL* lnkNode, UINT32* curAppArrayIdx, RSSP_INFO_STRU* rssp) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT8 pkgType = 0; /**/ + UINT16 dstAddr = 0; /*Ŀĵַ*/ + UINT32 sn = 0; /**/ + + if ((NULL != appData) && (NULL != lnkNode) && (NULL != curAppArrayIdx) && (NULL != rssp)) /**/ + { + PrintRecArray2ByteB(rssp->RecordArray, rssp->RecordArraySize, appDataLen); /*Ӧó*/ + + if ((*curAppArrayIdx) + 7 + appDataLen <= rssp->AppArraySize) /*д,7ֽAppArrayÿͷ*/ + { + if (appDataLen > 10) /*֡ʽ,10ֽڵRSSPI*/ + { + ShortToChar(5 + appDataLen, &rssp->AppArray[*curAppArrayIdx]); /*ô˰*/ + (*curAppArrayIdx) += 2; /*2ֽڳ*/ + + rssp->AppArray[*curAppArrayIdx] = RSSPI_TYPE_IN_ADAPTER; /*1ֽЭ */ + (*curAppArrayIdx) += 1; + + ShortToChar(lnkNode->DestTypeId, &rssp->AppArray[*curAppArrayIdx]); /*2ֽڶԷID*/ + (*curAppArrayIdx) += 2; + + ShortToChar(lnkNode->DestLogicId, &rssp->AppArray[*curAppArrayIdx]); /*2ֽڶԷ߼ID*/ + (*curAppArrayIdx) += 2; + + RsspMemCopy_WL(appData, &rssp->AppArray[*curAppArrayIdx], appDataLen); /*RSSPI֡*/ + (*curAppArrayIdx) += appDataLen; + + LongToChar((*curAppArrayIdx) - 4, rssp->AppArray); /*ܳ*/ + + pkgType = appData[RSSP_MSG_TYPE_POS_WL]; /*֡*/ + dstAddr = ShortFromCharLE(&appData[RSSP_DEST_ADD_POS_WL]); /*Էַ*/ + sn = LongFromCharLE(&appData[RSSP_TC_POS_WL]); /**/ + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, pkgType); /*֡*/ + PrintRecArray2ByteB(rssp->RecordArray, rssp->RecordArraySize, dstAddr); /*RSSPIĿĵַ*/ + PrintRecArray4ByteB(rssp->RecordArray, rssp->RecordArraySize, sn); /**/ + + rtn = 1; /**/ + } + else /*֡ʽ*/ + { + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, OUTPUT_FRAME_ERR); + } + } + else /*޿ռ*/ + { + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, OUTPUT_WRITE_NO_SPACE_ERR); + } + } + + return rtn; +} + +/*********************************************************************** + * : RecvLnkStatusMng_WL + * : ͨŽڵϢ״̬仯 + * : + * + * -------------------------------------------------------------- + * pBsdMsg const DataNod_WLe* IN Bsd + * pLnkNode Lnk_Info_Node_Stru_WL INOUT RSSPӦõ + * + + * ֵ : UINT8 1 + ***********************************************************************/ +static void RecvLnkStatusMng_WL(RSSP_INFO_STRU* pRsspStru) +{ + UINT8 index = 0u; /*±*/ + UINT8 LnkNodeNum = 0u; /*·ڵ*/ + UINT8 RecvStatus = 0u; /*״̬*/ + UINT32 LastLocalRecTC = 0u; /*ϴյıں*/ + UINT32 NoRecDataTc = 0u; /**/ + UINT8 delLnkRtn = 0u; /*ɾ·*/ + +#ifdef TIMED_SSE /*Ƿ嶨ʱSSEʱУ꿪*/ + INT32 AntiDelayTC = 0; /*ǰSSRڲǷ,-1:*/ +#endif + Lnk_Info_Node_Stru_WL* LnkNodeArr = NULL; /*ӽڵб*/ + UINT32 destDevName = 0u; /*Է豸ΨһID*/ + + GetLnkNodeArr_WL(&LnkNodeArr, &LnkNodeNum, pRsspStru); /*-< úȡӽڵбб*/ + for (index = 0u; index < LnkNodeNum; index++) /*-< ǰڵ±ǷСڽڵ*/ + { + if (1u == LnkNodeArr[index].ExeCycle) /*-< ·Ƿִ*/ + { + RecvStatus = LnkNodeArr[index].RsspLinInfo.RecvLinkStatus; /*-< õǰڵ״̬״̬*/ + if ((WaitSSR_WL == RecvStatus) || (RecvData_WL == RecvStatus)) /*-< ״̬ǷSSR״̬*/ + { + LastLocalRecTC = LnkNodeArr[index].RsspLinInfo.TimeStmp.LastLocalRecTC; /*-< õǰڵϴյЧʱںŸϴյЧʱں*/ + if (LnkNodeArr[index].RsspLinInfo.TimeStmp.TC != LastLocalRecTC) /*-< ǰںǷ񲻵ϴյЧʱں*/ + { + LnkNodeArr[index].RsspLinInfo.NoRecvDataCycleNum += 1u; /*-< õǰڵ1*/ + NoRecDataTc = LnkNodeArr[index].RsspLinInfo.NoRecvDataCycleNum; /*-< õǰڵ*/ + if (WaitSSR_WL == RecvStatus) /*-< ״̬ǷSSR״̬*/ + { + if (LnkNodeArr[index].RsspLinInfo.LocalNode.SSDelay < NoRecDataTc) /*-< Ƿڵǰڵ̵ĵSSR*/ + { + if (LnkNodeArr[index].RsspLinInfo.TimeStmp.NumSendSse >= SEND_SSE_NUM_WL) /*-< ǰڵ㷢SSEǷڵSSE*/ + { + LnkNodeArr[index].RsspLinInfo.RecvLinkStatus = Halt_WL; /*-< õǰڵ״̬Ϊж*/ + LnkNodeArr[index].RsspLinInfo.NoRecvDataCycleNum = 0; /*-< 㵱ǰڵ*/ + LnkNodeArr[index].RsspLinInfo.TimeStmp.NumSendSse = 0; /*-< 㵱ǰڵ㷢SSE*/ + } + else + { + LnkNodeArr[index].RsspLinInfo.RecvLinkStatus = SendSSE_WL; /*-< õǰڵ״̬ΪSSE״̬*/ + LnkNodeArr[index].RsspLinInfo.TimeStmp.NumSendSse++; /*-< õǰڵ㷢SSE1*/ + } + } + else + { + /*-< ʲô */ + } + } + else + { +#ifdef TIMED_SSE /*Ƿ嶨ʱSSEʱУ꿪*/ + AntiDelayTC = CheckTimeStamp_WL(LnkNodeArr[index].RsspLinInfo.TimeStmp.TC, LnkNodeArr[index].RsspLinInfo.TimeStmp.SsrTc, LnkNodeArr[index].RsspLinInfo.LocalNode.AntiDelayCount); /*-< úõǰSSRڲǷ*/ + if (AntiDelayTC < 0) /*-< ǰSSRڲǷ*/ + { + LnkNodeArr[index].RsspLinInfo.RecvLinkStatus = SendSSE_WL; /*-< õǰڵ״̬ΪSSE״̬*/ + } + else + { + /*-< ʲô*/ + } +#endif + if (NoRecDataTc > LnkNodeArr[index].RsspLinInfo.LocalNode.DLost) /*-< Ƿڵǰڵ̵*/ + { + LnkNodeArr[index].RsspLinInfo.RecvLinkStatus = Halt_WL; /*-< õǰڵ״̬Ϊж*/ + LnkNodeArr[index].RsspLinInfo.NoRecvDataCycleNum = 0u; /*-< 㵱ǰڵ*/ + } + else + { + /*-< ʲô*/ + } + } + } + else + { + /*-< ʲô*/ + } + } + else + { + /*-< ʲô*/ + } + + if (DisbaledReplace_WL == LnkNodeArr[index].NodeStatus) /*-< ǰڵ·Ƿ*/ + { + if ((Halt_WL == LnkNodeArr[index].RsspLinInfo.SendLinkStatus) + && ((Halt_WL == LnkNodeArr[index].RsspLinInfo.RecvLinkStatus) || (SendSSE_WL == LnkNodeArr[index].RsspLinInfo.RecvLinkStatus))) /*-< ǰڵ㷢״̬Ƿж ״̬ǷжϻSSE*/ + { + if (Halt_WL == LnkNodeArr[index].RsspLinInfo.RecvLinkStatus) /*-< ǰڵ״̬Ƿж*/ + { + LnkNodeArr[index].RecvKeepHaltCycleNum++; /*-< ձHalt_WL״̬1*/ + } + else + { + LnkNodeArr[index].RecvKeepSendSseCycleNum++; /*-< ձSendSSE_WL״̬1*/ + } + + /*״̬ﵽ ʱ ·*/ + if ((LnkNodeArr[index].RecvKeepHaltCycleNum > LnkNodeArr[index].RsspLinInfo.LocalNode.DLost) || (LnkNodeArr[index].RecvKeepSendSseCycleNum > LnkNodeArr[index].RsspLinInfo.LocalNode.DLost)) /*-< ǰڵձHalt_WL״̬Ƿڵǰڵ̵ ǰڵձSendSSE_WL״̬Ƿڵǰڵ̵*/ + { + destDevName = LnkNodeArr[index].DestDevName; /*-< õǰڵԷΨһIDԷΨһID*/ + delLnkRtn = RsspLnkDelete_WL(destDevName, pRsspStru); /*-< ɾ·*/ + if (0u == delLnkRtn) /*-< úʧ*/ + { + PrintRecArrayByte(pRsspStru->RecordArray, pRsspStru->RecordArraySize, INPUT_LNK_STATUS_ERR); /*-< ¼ɾ·ʧ־*/ + PrintRecArray4ByteB(pRsspStru->RecordArray, pRsspStru->RecordArraySize, destDevName); /*-< ¼ɾ·ʧܵĶԷΨһID־*/ + } + + LnkNodeArr[index].RecvKeepHaltCycleNum = 0u; /*-< ձHalt_WL״̬*/ + LnkNodeArr[index].RecvKeepSendSseCycleNum = 0u; /*-< ձSendSSE_WL״̬*/ + } + } + else + { + LnkNodeArr[index].RecvKeepHaltCycleNum = 0u; /*-< ձHalt_WL״̬*/ + LnkNodeArr[index].RecvKeepSendSseCycleNum = 0u; /*-< ձSendSSE_WL״̬*/ + } + } + } + else + { + /*-< ʲô*/ + } + } +} + +#ifdef __cplusplus +} +#endif diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspReciveWl.c b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspReciveWl.c new file mode 100644 index 0000000..0b5334f --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspReciveWl.c @@ -0,0 +1,1203 @@ +/******************************************************** +* ļ RsspReciveWl.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* Rsspʵ +* ʹע⣺ +* RsspInitòܣñļڵĺ +* ޸ļ¼ +* ޸ļ¼ +* ʱ ޸ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2009.12.16 ¥ΰ ¼׷ +* 2010.01.14 ¥ΰ 뿨˹µԺ󣬱ȥͬ +* 2010.01.23 ¥ΰ ɲȱݶӦΪHalt̬ʱͬʱSSE +* 2010.05.10 ¥ΰ ģļ¼׷RSSPڿʼʶԼں +* 2011.12.06 ޸AnalysisSSEnqMsg +* 2011.12.06 ޸AnalysisBsdMsg +* 2011.12.06 ޸AnalysisSSRepMsg +* 2011.12.06 CheckAddr鱨ϢͨŽڵϢǷһ¡ +* 2013.02.16 ޸WriteRsToAppQue +* 2013.03.01 AnalysisBsdMsg޸ΪAnalysisRsdMsg,BSD޸ijRSd +* 2013.03.01 AnalysisBsdMsg޸ΪAnalysisRsdMsg +********************************************************/ + +#include "RsspIFWl.h" +#include "RsspStructWl.h" +#include "RsspCommonWl.h" +#include "RsspLnkNodeMgrWl.h" +#include "RsspTmpMsgLnkCommonWl.h" +#include "RsspRecordDelareWl.h" +#include "CommonRecord.h" +#include "dsuRsspFunc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------- + * RSSPģڲʹú Start + *--------------------------------------------------------------------*/ + static UINT8 WriteRsToAppQue_WL(DataNode_WL *pHead,QueueStruct* RsToApp,UINT8 *RecordArray, UINT16 RecordArraySize, RSSP_INFO_STRU *pRsspStru); + static UINT8 AnalysisSSEnqMsg_WL(const DataNode_WL* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSSP_INFO_STRU *pRsspStru); + static UINT8 AnalysisSSRepMsg_WL(const DataNode_WL* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSSP_INFO_STRU *pRsspStru); + static UINT8 AnalysisRsdMsg_WL(DataNode_WL* pNode, UINT8 *RecordArray, UINT16 RecordArraySize, RSSP_INFO_STRU *pRsspStru); + static UINT8 UptLnkNodeInfoBySSE_WL(const DataNode_WL *pDataNode, Lnk_Info_Node_Stru_WL *pLnkNode); + static UINT8 UptLnkNodeInfoBySSR_WL(const DataNode_WL *pDataNode, Lnk_Info_Node_Stru_WL *pLnkNode, UINT8 *RecordArray, UINT16 RecordArraySize); + static UINT8 CheckAddr_WL(const DataNode_WL *pDataNode, const Lnk_Info_Node_Stru_WL *pLnkNode); + + static UINT8 CheckRsdMsg_WL(const UINT8 *pBsdMsg,Lnk_Info_Node_Stru_WL *pLnkNode, RSSP_INFO_STRU *pRsspStru); + + static void ReadNetData(QueueStruct* pInputQue, DataNode_WL** pHeadNode, RSSP_INFO_STRU* rssp, const UINT8 netIdx); + static void ClearNetsRecvPkgNum(RSSP_INFO_STRU* rsspi); + static void SetNetsRecvPkgNum(RSSP_INFO_STRU* rsspi, const UINT16 dstAddr, const UINT8 netIdx); + + /* +*: RsspReceive_WL +*: RSSPI봦 +*: RSSP_INFO_STRU* rssp RSSPIṹ +*: +*: +*ֵ: Ƿɹ,0:ɹ,1:ɹ +*/ + UINT8 RsspReceive_WL(RSSP_INFO_STRU* rssp) + { + UINT8 rtn = 0; /*ֵ*/ + DataNode_WL* headNode = NULL; /*ͷڵ*/ + DataNode_WL* curNode = NULL; /*ǰڵ*/ + DataNode_WL* lastNode = NULL; /*Ͻڵ*/ + DataNode_WL* nexNode = NULL; /*½ڵ*/ + UINT8 isDelNode = 0; /*Ƿɾڵ*/ + UINT8 frameType = 0; /*֡*/ + UINT8 proFun = 0; /**/ + + if ((NULL != rssp) && (NULL != rssp->RecordArray) && (NULL != rssp->StackOfDataLink)) /*ǿռ*/ + { + QueueClear(&rssp->DataToApp); /*ЭӦݶ*/ + + ClearNetsRecvPkgNum(rssp); + + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, RED_NET_DATA); /*¼־*/ + ReadNetData(&rssp->OutnetQueueA, &headNode, rssp, 0); /*ȡ,ݶջ*/ + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, BLUE_NET_DATA); /*¼־*/ + ReadNetData(&rssp->OutnetQueueB, &headNode, rssp, 1); /*ȡ,ݶջ*/ + + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, RSSP_INPUT); /*¼־*/ + + if (NULL != headNode) /**/ + { + curNode = headNode; /*ͷڵ㿪ʼ*/ + while (NULL != curNode) /**/ + { + isDelNode = 0; /*Ĭϲɾ*/ + frameType = curNode->Data[RSSP_MSG_TYPE_POS_WL]; /*֡*/ + if (RSSP_SSE_MSG_WL == frameType) /*SSE֡*/ + { + AnalysisSSEnqMsg_WL(curNode, rssp->RecordArray, rssp->RecordArraySize, rssp); + isDelNode = 1; /*ɾڵ*/ + } + else if (RSSP_SSR_MSG_WL == frameType) /*SSR֡*/ + { + AnalysisSSRepMsg_WL(curNode, rssp->RecordArray, rssp->RecordArraySize, rssp); + isDelNode = 1; /*ɾڵ*/ + } + else /*RSD֡*/ + { + proFun = AnalysisRsdMsg_WL(curNode, rssp->RecordArray, rssp->RecordArraySize, rssp); + if (0 == proFun) /*ʧ*/ + { + isDelNode = 1; /*ɾڵ*/ + } + } + + nexNode = curNode->pNextNode; /*½ڵ,ɾǰڵ嵱ǰڵ½ڵָ*/ + if (1 == isDelNode) /*ɾڵ*/ + { + proFun = DelTmpMsgLnkNode_WL(curNode, lastNode, &headNode, rssp->StackOfDataLink); + if (0 == proFun) + { + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, INPUT_DEL_NODE_ERR); /*¼־*/ + } + } + else /*ɾڵ*/ + { + lastNode = curNode; /*Ͻڵ*/ + } + curNode = nexNode; /*׼½ڵ*/ + } + + proFun = WriteRsToAppQue_WL(headNode, &rssp->DataToApp, rssp->RecordArray, rssp->RecordArraySize, rssp); + if (0 == proFun) + { + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, INPUT_WRITE_ERR); /*¼־*/ + } + } + + rtn = 1; + } + + return rtn; + } + + /*-------------------------------------------------------------------- + * RSSPģڲʹúʵ Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : AnalysisSSEnqMsg_WL + * : յSSEϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * pNode const DataNode_WL* IN źŲ㵽Rssp + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * + + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 AnalysisSSEnqMsg_WL(const DataNode_WL* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSSP_INFO_STRU *pRsspStru) +{ + UINT8 ret = 0; + Lnk_Info_Node_Stru_WL *retLnkNodePtr = NULL; + /* wangpeipei 20111201 ADD*/ + UINT16 SrcAddr = 0; + UINT16 DesAddr = 0; + /* wangpeipei 20111201 ADD*/ + /* ij == 18CRC*/ + if((RSSP_SSE_LEN_WL -CRC_16_LEN_WL) == pNode->DataLen) + { + /* wangpeipei 20111201 ADD S */ + DesAddr = ShortFromCharLE(&pNode->Data[RSSP_SRC_ADD_POS_WL]); + SrcAddr = ShortFromCharLE(&pNode->Data[RSSP_DEST_ADD_POS_WL]); + retLnkNodePtr = SearchLnkSse_SsrNode_WL(SrcAddr,DesAddr, pRsspStru); + /* wangpeipei 20111201 ADD E */ + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + /* wangpeipei 20111201 ADD S */ + ret = CheckAddr_WL(pNode,retLnkNodePtr); + /* wangpeipei 20111201 ADD E */ + if(0 == ret) + { + /* һ ¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, CHK_SSE_ADDR_ERR); + PrintRecArray2ByteB(RecordArray, RecordArraySize, DesAddr); + +#endif + } + else /* ͨ */ + { + /* ·Ϣṹ */ + ret = UptLnkNodeInfoBySSE_WL(pNode,retLnkNodePtr); + + PrintRecArray2ByteB(RecordArray, RecordArraySize, DesAddr); + PrintRecArrayByte(RecordArray, RecordArraySize, pNode->Data[RSSP_MSG_TYPE_POS_WL]); + PrintRecArray4ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&pNode->Data[RSSP_TC_POS_WL])); + } + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Node Not Exist.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, INPUT_SSE_NO_USE_NODE); + PrintRecArray2ByteB(RecordArray, RecordArraySize, DesAddr); +#endif + } + } + else /* Ȳ */ + { + /* ¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, SSE_LEN_ERR); + +#endif + } + + ret = 1; + return ret; +} + +/*********************************************************************** + * : AnalysisSSRepMsg_WL + * : յSSRϢн֡ȡϢ + * : + * + * -------------------------------------------------------------- + * pNode const DataNode_WL* IN źŲ㵽Rssp + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + * + + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 AnalysisSSRepMsg_WL(const DataNode_WL* pNode,UINT8 *RecordArray,UINT16 RecordArraySize, RSSP_INFO_STRU *pRsspStru) +{ + UINT8 ret = 0; + Lnk_Info_Node_Stru_WL *retLnkNodePtr = NULL; + /* wangpeipei 20111201 ADD*/ + UINT16 SrcAddr = 0; + UINT16 DesAddr = 0; + /* wangpeipei 20111201 ADD*/ + /* ij == 23CRC*/ + if((RSSP_SSR_LEN_WL-CRC_16_LEN_WL) == pNode->DataLen) + { + /* wangpeipei 20111201 ADD */ + DesAddr = ShortFromCharLE(&pNode->Data[RSSP_SRC_ADD_POS_WL]); + SrcAddr = ShortFromCharLE(&pNode->Data[RSSP_DEST_ADD_POS_WL]); + retLnkNodePtr = SearchLnkSse_SsrNode_WL(SrcAddr,DesAddr,pRsspStru); + /* wangpeipei 20111201 ADD */ + /* жͨŽڵǷ */ + if( NULL != retLnkNodePtr) + { + /* ͨŽڵڣô鱨ĵϢǷ͸ͨŽڵһ */ + /* wangpeipei 20111201 ADD S */ + ret = CheckAddr_WL(pNode,retLnkNodePtr); + /* wangpeipei 20111201 ADD E */ + if(0 == ret) + { + /* һ ¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, CHK_SSR_ADDR_ERR); + PrintRecArray2ByteB(RecordArray, RecordArraySize, DesAddr); +#endif + } + else /* ͨ */ + { + /* ·Ϣṹ */ + ret = UptLnkNodeInfoBySSR_WL(pNode, retLnkNodePtr, RecordArray, RecordArraySize); + if( 0 == ret) + { + /* ³˵ǶӦSSR ô¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:SSR Msg Err.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, UPD_SSR_ERR); +#endif + } + } + } + else + { + /* ¼ ͨŽڵ㲻 */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray,RecordArraySize, INPUT_SSR_NO_USE_NODE); + PrintRecArray2ByteB(RecordArray, RecordArraySize, DesAddr); +#endif + } + } + else /* Ȳ */ + { + /* ¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, SSR_LEN_ERR); + +#endif + } + + ret = 1; + return ret; +} + + /** +* @brief AnalysisRsdMsg_WL յRSDϢн֡ +* @param pNode źŲ㵽Rsspڵ ȡֵΧ:οṹDataNode_WL +* @param RecordArray ¼ ȡֵΧ:ֽ +* @param RecordArraySize ¼鳤 ȡֵΧ:0x0000-0xFFFF +* @param pRsspStru RSSPIϢ ȡֵΧ:οṹRSSP_INFO_STRU + * @return 0:ʧ;1:ɹ +*/ +static UINT8 AnalysisRsdMsg_WL(DataNode_WL* pNode,UINT8 *RecordArray, UINT16 RecordArraySize, RSSP_INFO_STRU *pRsspStru) +{ + UINT8 ret = 0; /*-< úֵΪʧ*/ + UINT16 LocalDevName = 0; /* ʶ */ + UINT16 RsspMsgLen = 0; /* RSSPϢ峤 */ + Lnk_Info_Node_Stru_WL *retLnkNodePtr = NULL; + /* wangpeipei 20111201 ADD*/ + UINT16 srcAddr = 0; + UINT16 bsdAddr = 0; + /* wangpeipei 20111201 ADD*/ + + /* ʶ*/ + TypeId2DevName_WL(pRsspStru->LocalType, pRsspStru->LocalID,&LocalDevName); /*-< ûȡID*/ + /* Ϣ峤 */ + RsspMsgLen = ShortFromCharLE(&pNode->Data[RSSP_DATA_SIZE_POS_WL]); /*-< Ϣ*/ + + /* RSSPij >= RSD̶(20,CRC) + * && Ϣ峤 == RSSPij-RSD̶ + 2 CRCM + */ + if((RSSP_DATA_POS_WL <= pNode->DataLen) + &&((pNode->DataLen - RSSP_CRCM_1_POS_WL)== RsspMsgLen)) /*-< ϢǷȷ*/ + { + /* wangpeipei 20111201 ADD */ + srcAddr= ShortFromCharLE(&pNode->Data[RSSP_SRC_ADD_POS_WL]); /*-< Դַ*/ + bsdAddr = ShortFromCharLE(&pNode->Data[RSSP_DEST_ADD_POS_WL]); /*-< ԴBSDַ*/ + retLnkNodePtr = SearchLnkBsdNode_WL(srcAddr,bsdAddr, pRsspStru); /*-< òѯ·*/ + /* wangpeipei 20111201 ADD */ + + /* ͨŽڵͨŹϵж */ + if( NULL != retLnkNodePtr) /*-< úǷɹ*/ + { + /* RSDϢǷͨŽڵһ */ + /* wangpeipei 20111206 ADD S */ + ret = CheckAddr_WL(pNode,retLnkNodePtr); /*-< üַ*/ + /* wangpeipei 20111206 ADD E */ + if(1 == ret) /*-< úǷɹ*/ + { + /* ֤RSDϢǷϷ */ + ret = CheckRsdMsg_WL(pNode->Data,retLnkNodePtr, pRsspStru); /*-< УRSD*/ + if(1 == ret) /*-< úǷɹ*/ + { + /* ֤ͨ */ + pNode->DestTypeId = retLnkNodePtr->DestTypeId; /*-< ݽڵĶԷID*/ + /* ϴյıʱ趨Ϊǰں */ + retLnkNodePtr->RsspLinInfo.TimeStmp.LastLocalRecTC = retLnkNodePtr->RsspLinInfo.TimeStmp.TC; /*-< ϴյıʱ趨Ϊǰں*/ + /* 趨Ϊ0 */ + retLnkNodePtr->RsspLinInfo.NoRecvDataCycleNum = 0; /*-< 趨Ϊ0*/ + + /* ɹ */ + ret = 1; /*-< úֵΪɹ*/ + } + else + { +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:BSD Invalid.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, CHK_RSD_ERR); /*-< ¼RSD־*/ + PrintRecArray2ByteB(RecordArray, RecordArraySize, srcAddr); /*-< ¼Դַ־*/ +#endif + /* ֤ʧ */ + ret = 0; /*-< úֵΪʧ*/ + } + } + else + { + /* ¼ ,󷵻 */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:NOT Node Msg.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, CHK_RSD_ADDR_ERR); /*-< ¼ַ־*/ + PrintRecArray2ByteB(RecordArray, RecordArraySize, srcAddr); /*-< ¼Դַ־*/ +#endif + ret = 0; /*-< úֵΪʧ*/ + } + } + else /* ͨŽڵ㲻 if( NULL != retLnkNodePtr) */ + { + /* ڣȡɸǽڵи */ + /* wangpeipei 20111206 ADD S */ + retLnkNodePtr = GetReplaceNode_WL(pRsspStru); /*-< ûȡ·ڵ㺯*/ + + /* wangpeipei 20111206 ADD E */ + if( NULL != retLnkNodePtr) /*-< úǷɹ*/ + { + ret = recvReplaceLnkNode_WL(LocalDevName, pNode, retLnkNodePtr, pRsspStru->pDsuRsspInfoStruWL); /*-< ·ڵ㺯*/ + if( 0 == ret) /*-< úǷɹ*/ + { + /* ¼Warning */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Rplace Node Err.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, INPUT_NEW_NODE_ERR); /*-< ¼·ڵ־*/ + PrintRecArray2ByteB(RecordArray, RecordArraySize, srcAddr); /*-< ¼Դַ־*/ +#endif + } + else + { + retLnkNodePtr->CycleNum = *pRsspStru->CycleNum; /*-< Ӧ*/ +#ifdef RSSP_NO_HLHT + pNode->DestTypeId = (UINT16)retLnkNodePtr->DestDevName; /*-< ĿID*/ +#else + pNode->DestTypeId = DquToDevTypeId(retLnkNodePtr->DestDevName, pRsspStru->pDsuRsspInfoStruWL); /*-< ĿID*/ +#endif + retLnkNodePtr->DestTypeId = pNode->DestTypeId; /*-< öԷID*/ + retLnkNodePtr->DestLogicId = pNode->DestLogicId; /*-< öԷ߼ID*/ + retLnkNodePtr->RsspLinInfo.TimeStmp.TC = retLnkNodePtr->CycleNum; /*-< ·üʼ*/ + + PrintRecArrayByte(RecordArray, RecordArraySize, INPUT_NEW_NODE); /*-< ¼½ڵ־*/ + PrintRecArray2ByteB(RecordArray, RecordArraySize, srcAddr); /*-< ¼Դַ־*/ + } + /* 󷵻أԲ洦ɾýڵ */ + ret = 0; /*-< úֵΪʧ*/ + } + else /* ǽڵ㲻 */ + { + ret = 0; /*-< úֵΪʧ*/ + /* ¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:No Rplace Node.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, NO_NODE); /*-< ¼޽ڵ־*/ + PrintRecArray2ByteB(RecordArray, RecordArraySize, srcAddr); /*-< ¼Դַ־*/ + +#endif + } + + } /* else */ + } + else /* ȲϷ ¼ */ + { + /* ¼󷵻 */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Msg Len Err.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray,RecordArraySize, INPUT_RSD_LEN_ERR); /*-< ¼RSDȴ־*/ + +#endif + ret = 0; /*-< úֵΪʧ*/ + } + + return ret; /*-< غֵ*/ +} +/*********************************************************************** + * : WriteRsToAppQue_WL + * : ԽɹRSDĵӦдС + * жֻ֡ȡµıݡ + * : + * + * -------------------------------------------------------------- + * pHead DataNode_WL* IN ദRssp + * RsToApp QueueStruct* INOUT RSSPӦõ + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 IN ¼С + + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 WriteRsToAppQue_WL(DataNode_WL *pHead,QueueStruct* RsToApp,UINT8 *RecordArray, UINT16 RecordArraySize, RSSP_INFO_STRU *pRsspStru) +{ + UINT8 ret = 0; + DataNode_WL *pCur = NULL,*pNext = NULL; + UINT16 SrcAddr = 0, DestAddr = 0; /* Դַ Ŀַ */ + UINT16 AppDataLen = 0; + UINT32 destName = 0; + /* Ӧݳ */ + const UINT8 LEN_OUT_QUE_POS = 0; /* ݳȱλ */ + /* wangpeipei Del 2013.02.16 S */ + /*const UINT8 SRC_ADDR_OUT_QUE_POS = LEN_OUT_QUE_POS+2; */ /* жԷԴַλ */ + /*const UINT8 DEST_ADDR_OUT_QUE_POS = SRC_ADDR_OUT_QUE_POS+2;*/ /* жԷBSDַλ */ + /*const UINT8 DATA_OUT_QUE_POS = DEST_ADDR_OUT_QUE_POS+2;*/ /* ݱλ */ + /* wangpeipei Del 2013.02.16 E */ + + /* wangpeipei ADD 2013.02.16 S */ + const UINT8 SRC_TYPE_OUT_QUE_POS = LEN_OUT_QUE_POS+2; /*ԷIDλ */ + const UINT8 DST_LOGIC_ID_QUE_POS = SRC_TYPE_OUT_QUE_POS +2; /* Է߼IDλ */ + const UINT8 DATA_OUT_QUE_POS = DST_LOGIC_ID_QUE_POS + 2; /* ݱλ */ + /* wangpeipei ADD 2013.02.16 E */ + pCur = pHead; + /* ǰڵ㲻Ϊ */ + while(pCur != NULL) + { + /* ǰڵһڵıʶȣѸñĵݶ */ + pNext = pCur->pNextNode; + if( (NULL != pNext) && (pNext->DevName == pCur->DevName) ) + { + /* ˵ñʶӦķͷ±ģڵΪݣ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:OLD MSG.\n"); /* ±Ķ */ +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, RSD_DUP); /* ±Ķ */ + PrintRecArray4ByteB(RecordArray, RecordArraySize, pCur->DevName); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pCur->TCr); +#endif + } + else + { + /* ȫݳ 2CRCM */ + AppDataLen = ShortFromCharLE(&pCur->Data[RSSP_DATA_SIZE_POS_WL]) -2*CRCM_LEN_WL; + SrcAddr = ShortFromCharLE(&pCur->Data[RSSP_SRC_ADD_POS_WL]); /* RSSPԴַ */ + DestAddr = ShortFromCharLE(&pCur->Data[RSSP_DEST_ADD_POS_WL]); /* RSSPĿַ */ + /* д + * ------------------------------------------------- + * ݳ | ԷType | ԷID| Ӧ | + * 2ֽ | 1ֽ | 1 ֽ| n | + * ------------------------------------------------- + */ + ret = dsuRsspRGetName_WL(SrcAddr, DestAddr, &destName, pRsspStru->pDsuRsspInfoStruWL); + + ShortToChar((UINT16)(AppDataLen+4),&pRsspStru->FrameData[LEN_OUT_QUE_POS]); /* ݳ ȫݳ + 4(ԴַĿַ) */ + ShortToChar(pCur->DestTypeId, &pRsspStru->FrameData[SRC_TYPE_OUT_QUE_POS]); /*ԴID*/ + ShortToChar(pCur->DestLogicId, &pRsspStru->FrameData[DST_LOGIC_ID_QUE_POS]); /*Դ߼ID*/ + + /* Ӧ */ + RsspMemCopy_WL(&pCur->Data[RSSP_DATA_POS_WL],&pRsspStru->FrameData[DATA_OUT_QUE_POS], AppDataLen); + + /* д */ + ret = QueueWrite(2+AppDataLen+4,pRsspStru->FrameData,RsToApp); + if(1 == ret) + { /* дɹ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"Out:\n"); + PrintFiles(RecordArray,RecordArraySize,"MsgLen"); + PrintFileU16Hex(RecordArray,RecordArraySize,AppDataLen); /* Ӧݳ */ + PrintFiles(RecordArray,RecordArraySize,"\tSrcAddr"); + PrintFileU16Hex(RecordArray,RecordArraySize,SrcAddr); /* Դַ */ + PrintFiles(RecordArray,RecordArraySize,"\tDestAddr"); + PrintFileU16Hex(RecordArray,RecordArraySize,DestAddr); /* Ŀַ */ + PrintFiles(RecordArray,RecordArraySize,"\n"); +#endif + } + else + { + /* дʧ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Queue Write Err.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, RSD_APP_WRITE_ERR); +#endif + } + + PrintRecArray2ByteB(RecordArray, RecordArraySize, SrcAddr); + PrintRecArrayByte(RecordArray, RecordArraySize, pCur->Data[RSSP_MSG_TYPE_POS_WL]); + PrintRecArray4ByteB(RecordArray, RecordArraySize, LongFromCharLE(&pCur->Data[RSSP_TC_POS_WL])); + PrintRecArray2ByteB(RecordArray, RecordArraySize, AppDataLen); + } + + /* ɾǰĽڵ:pCurʵΪͷɾpCur󣬱ͷΪpNext */ + ret = DelTmpMsgLnkNode_WL(pCur, NULL, &pCur, pRsspStru->StackOfDataLink); + if(0 == ret ) + { + /* ¼ WarningʵʲӦûᷢĴ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:Delete Msg Lnk Error."); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(RecordArray, RecordArraySize, RSD_DEL_DATA_NODE_ERR); /* ʱɾʧ */ + +#endif + } + else + { + /* һڵ */ + } + } + + ret = 1; + return ret; +} + +/*********************************************************************** + * : CheckAddr_WL + * : 鱨ϢͨŽڵϢǷһ¡ + * : + * + * -------------------------------------------------------------- + * pDataNode DataNode_WL* IN Ľڵ + * pLnkNode const Lnk_Info_Node_Stru_WL INOUT RSSPӦõ + * + + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 CheckAddr_WL(const DataNode_WL *pDataNode, const Lnk_Info_Node_Stru_WL *pLnkNode) +{ + UINT8 ret = 0; /* ʼֵɹ */ + + /* 豸 == ͨŽڵϢ.·鱨.Դַ */ + if( (pDataNode->DevName == pLnkNode->DestDevName) && (pDataNode->LocalLogId == pLnkNode->RsspLinInfo.LocalLogId) + && (pDataNode->DestLogId == pLnkNode->RsspLinInfo.DestLogId)) + /* wangpeipei 20111201 ADD*/ + { + /* ͨ */ + ret = 1; + } + else + { + /* ʧܣֵ ret = 0 */ + } + return ret; +} + +/*********************************************************************** + * : UptLnkNodeInfoBySSE_WL + * : SSEϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pDataNode const DataNode_WL* IN Ľڵ + * pLnkNode Lnk_Info_Node_Stru_WL INOUT RSSPӦõ + * + + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 UptLnkNodeInfoBySSE_WL(const DataNode_WL *pDataNode, Lnk_Info_Node_Stru_WL *pLnkNode) +{ + const UINT8 *Msg = NULL; /* RSSPָ */ + RsspLinkInfoStru_WL *pRsspLnkInfo = NULL; + + Msg = pDataNode->Data; + pRsspLnkInfo = &pLnkNode->RsspLinInfo; + + /* ·ͽڵ״̬Ϊ SSR */ + pRsspLnkInfo->SendLinkStatus = SendSSR_WL; + + /* 趨յSSEʱ */ + pRsspLnkInfo->TimeStmp.RecvSseTCe = + LongFromCharLE(&Msg[RSSP_TC_POS_WL]); + + /* SEQENQ_1ȡ 趨 */ + pRsspLnkInfo->TimeStmp.SeqEng[0] = LongFromCharLE(&Msg[RSSP_SSE_ENQ_1_POS_WL]); + + /* SEQENQ_2ȡ 趨 */ + pRsspLnkInfo->TimeStmp.SeqEng[1] = LongFromCharLE(&Msg[RSSP_SSE_ENQ_2_POS_WL]); + + return (UINT8)1; +} + +/*********************************************************************** + * : UptLnkNodeInfoBySSR_WL + * : SSRϢͨŽڵϢ + * : + * + * -------------------------------------------------------------- + * pDataNode const DataNode_WL* IN Ľڵ + * pLnkNode Lnk_Info_Node_Stru_WL INOUT RSSPӦõ + * + + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 UptLnkNodeInfoBySSR_WL(const DataNode_WL *pDataNode, Lnk_Info_Node_Stru_WL *pLnkNode, UINT8 *RecordArray, UINT16 RecordArraySize) +{ + UINT8 ret = 1; /* ʼֵ */ + UINT32 SseTCe = 0; /* SSR SSETC */ + UINT32 SeqIni[2] = {0}; /* SSRĵSEQ_INI ֵ */ + const UINT8 *Msg = NULL; /* RSSPָ */ + RsspLinkInfoStru_WL *pRsspLnkInfo = NULL; /* ·鱨 */ + TimeStampStru_WL *pTmStmp = NULL; /* ʱṹָ */ + + Msg = pDataNode->Data; + pRsspLnkInfo = &pLnkNode->RsspLinInfo; + pTmStmp = &pRsspLnkInfo->TimeStmp; + + /* ͨ·Ľ״̬Ϊ ȴSSR */ + if(WaitSSR_WL == pRsspLnkInfo->RecvLinkStatus ) + { + SseTCe = LongFromCharLE(&Msg[RSSP_SSR_TCENQ_POS_WL]); /* SSRĵ SSE */ + + /* жǷΪӦ SSR */ + if( pTmStmp->SseTC == SseTCe) + { + /* ǶӦSSRģ·鱨Ϣ */ + + pTmStmp->SsrTc = pLnkNode->RsspLinInfo.TimeStmp.TC; /* ϴͬںŸ ǰں */ + + SeqIni[0] = LongFromCharLE(&Msg[RSSP_SSR_INI_1_POS_WL]); /* źŵ SEQINI_1 ֵ */ + SeqIni[1] = LongFromCharLE(&Msg[RSSP_SSR_INI_2_POS_WL]); /* źŵ SEQINI_2 ֵ */ + + /* ʼSINITr AND [SIDr ^ Tr(n)]浽pTmStmp->NowSINIT_ADD_SID_XOR_Tn */ + ret = CalcFirstSinitAndSidXorTn_WL(pRsspLnkInfo->LocalNode.PREC_FIRSTSINIT,SeqIni, + pTmStmp->SseTn,pTmStmp->NowSINIT_ADD_SID_XOR_Tn); + + pTmStmp->NumSendSse = 0; /* SSE 趨Ϊ 0 */ + pTmStmp->LastLocalRecTC = pLnkNode->RsspLinInfo.TimeStmp.TC; /* ϴյĵıʱ */ + pTmStmp->LastRecvTCr = pTmStmp->NowRecvTCr; /* ϴνܱʱΪ ǰյʱ Ԥ */ + pTmStmp->NowRecvTCr = LongFromCharLE(&Msg[RSSP_TC_POS_WL]); /* ǰյʱ = ļ */ + + pRsspLnkInfo->RecvLinkStatus = RecvData_WL; /* ·״̬ = */ + pRsspLnkInfo->NoRecvDataCycleNum = 0; /* */ + } + else /* ǶӦSSR */ + { + /* 󷵻 */ + ret = 0; + PrintRecArrayByte(RecordArray, RecordArraySize, SSR_SSE_SN_ERR); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pTmStmp->SseTC); + } + + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&Msg[RSSP_SRC_ADD_POS_WL])); + PrintRecArrayByte(RecordArray, RecordArraySize, Msg[RSSP_MSG_TYPE_POS_WL]); + PrintRecArray4ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&Msg[RSSP_TC_POS_WL])); + PrintRecArray4ByteB(RecordArray, RecordArraySize, SseTCe); + } + else + { + /* 󷵻 0 */ + ret = 0; + + PrintRecArrayByte(RecordArray, RecordArraySize, SSR_RCV_STATUS_ERR); + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&Msg[RSSP_SRC_ADD_POS_WL])); + } + + + return ret; +} + +/*********************************************************************** + * : CheckRsdMsg_WL + * : ֤RSDĵȷԡ + * : + * + * -------------------------------------------------------------- + * pBsdMsg const UINT8 * IN Bsd + * pLnkNode Lnk_Info_Node_Stru_WL INOUT RSSPӦõ + * + + * ֵ : UINT8 1 + ***********************************************************************/ +static UINT8 CheckRsdMsg_WL(const UINT8 *pBsdMsg,Lnk_Info_Node_Stru_WL *pLnkNode, RSSP_INFO_STRU *pRsspStru) +{ + UINT8 ret = 1; /* ʼΪ */ + UINT8 tmpret = 0; + INT32 DelayTCr = 0; /* */ + INT32 Tout = 0; /* ϴյĵʱ */ + UINT32 TCr = 0; /* ʱ */ + UINT32 SidXorTn[2] = {0}; /* SID XOR TN BSDļ */ + TimeStampStru_WL *pTmStmp = &pLnkNode->RsspLinInfo.TimeStmp; /* ʱṹ */ + const NodeParamInfoStru_WL *pNodeParam = &pLnkNode->RsspLinInfo.LocalNode; /* ڵϢṹ */ + UINT8 *RecordArray = pRsspStru->RecordArray; + UINT16 RecordArraySize = pRsspStru->RecordArraySize; + + /* ͨŽڵ״̬Ϊ ״̬ */ + if( RecvData_WL == pLnkNode->RsspLinInfo.RecvLinkStatus) + { + /* ʱ */ + TCr = LongFromCharLE(&pBsdMsg[RSSP_TC_POS_WL]); + /* + * ϴαĵʱһ(ͬһͬʱܵBSDĺSSR)ñ + * 鶪Ƿʱ + */ + if( TCr != pTmStmp->NowRecvTCr) + { + DelayTCr = CheckTimeStamp_WL(TCr,pTmStmp->NowRecvTCr,pNodeParam->MaxLost); + } + else + { + PrintRecArrayByte(RecordArray, RecordArraySize, INPUT_TC_EQ); + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&pBsdMsg[RSSP_SRC_ADD_POS_WL])); + PrintRecArray4ByteB(RecordArray, RecordArraySize, TCr); + return 0; + } + + if(-1 == DelayTCr) + {/*кųޣSSE*/ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"DelayTCr > MaxLost\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordArraySize, OVER_MAX_LOST); + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&pBsdMsg[RSSP_SRC_ADD_POS_WL])); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pTmStmp->NowRecvTCr); + PrintRecArray4ByteB(RecordArray, RecordArraySize, TCr); +#endif + /* Ķ طSSEͬ */ + pLnkNode->RsspLinInfo.RecvLinkStatus = SendSSE_WL; + ret = 0; + } + else if(-2 == DelayTCr) + {/*ݣ*/ +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordArraySize, OLD_DATA); + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&pBsdMsg[RSSP_SRC_ADD_POS_WL])); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pTmStmp->NowRecvTCr); + PrintRecArray4ByteB(RecordArray, RecordArraySize, TCr); +#endif + ret = 0; + } + else + { + /* ijʱ */ + if (pTmStmp->LastLocalRecTC != pTmStmp->TC) + { + Tout = CheckTimeStamp_WL(pTmStmp->TC, + pTmStmp->LastLocalRecTC, pNodeParam->Tout); + } + else + { + /* ˵Ѿյһ֡ݣҪʱ */ + Tout = 0; + } + if (Tout >= 0) /* Ϸʱյ */ + { + /* RSDȡSID XOR TN CRCM[chan] ^ CRC[chan] ^ SYS_CHK_WD[chan] */ + tmpret = GetSidXorTn_WL(pBsdMsg, SidXorTn); + /* CRCMЧ */ + ret = CheckCRCM_WL(SidXorTn, pTmStmp->NowSINIT_ADD_SID_XOR_Tn, + (UINT32)DelayTCr, pNodeParam->TSD_POST_RXDADA_K); + + if ((1U == ret) && (1U == tmpret)) /* ɹ ӦϢ */ + { + /* ʱṹ : pTmStmpStruǿգֵ϶Ϊ1 */ + ret = UpdtTmStmpStru_WL(SidXorTn, TCr, DelayTCr, pNodeParam->PREC_SINIT_K, pTmStmp); + ret = 1; /* */ + } + else + { +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordArraySize, "W:CRCM Error.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordArraySize, SVC_ERR); + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&pBsdMsg[RSSP_SRC_ADD_POS_WL])); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pTmStmp->NowRecvTCr); + PrintRecArray4ByteB(RecordArray, RecordArraySize, TCr); + PrintRecArray4ByteB(RecordArray, RecordArraySize, SidXorTn[0]); + PrintRecArray4ByteB(RecordArray, RecordArraySize, SidXorTn[1]); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pTmStmp->NowSINIT_ADD_SID_XOR_Tn[0]); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pTmStmp->NowSINIT_ADD_SID_XOR_Tn[1]); +#endif + /* ʧ 󷵻 */ + ret = 0; + } + } + else /* ʱ */ + { +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordArraySize, "W:Time Out.\n"); +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordArraySize, OVER_MAX_TIME); + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&pBsdMsg[RSSP_SRC_ADD_POS_WL])); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pTmStmp->LastLocalRecTC); + PrintRecArray4ByteB(RecordArray, RecordArraySize, pTmStmp->TC); +#endif + ret = 0; + } + } + } + else if( Halt_WL == pLnkNode->RsspLinInfo.RecvLinkStatus) + { + pLnkNode->RsspLinInfo.RecvLinkStatus = SendSSE_WL; /* ״̬ΪSSE */ + ret = 0; + + PrintRecArrayByte(RecordArray, RecordArraySize, RSD_HALT_SSE); + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&pBsdMsg[RSSP_SRC_ADD_POS_WL])); + } + else /* ״̬ */ + { +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray,RecordArraySize,"W:RecvStatus() not RecvData or Halt.Discard Bsd Msg."); + PrintFileHex(RecordArray,RecordArraySize,&pLnkNode->RsspLinInfo.RecvLinkStatus,1); + PrintFiles(RecordArray,RecordArraySize,"\n"); +#endif + ret =0; + + PrintRecArrayByte(RecordArray, RecordArraySize, RSD_RCV_HALT_ERR); + PrintRecArray2ByteB(RecordArray, RecordArraySize, ShortFromCharLE(&pBsdMsg[RSSP_SRC_ADD_POS_WL])); + } + + return ret; +} + +/** +* @brief ReadNetData ȡ,С򲢹˵ظ,ݶջ +* @param pInputQue ݶ ȡֵΧ:οṹQueueStruct +* @param pHeadNode ͷڵ ȡֵΧ:οṹDataNode_WL +* @param rssp RSSPI ȡֵΧ:οṹRSSP_INFO_STRU +* @param netIdx ʶ ȡֵΧ:0:һ;1: +*/ +static void ReadNetData(QueueStruct* pInputQue, DataNode_WL** pHeadNode, RSSP_INFO_STRU* rssp, const UINT8 netIdx) +{ + /*- ֲ*/ + const UINT8 oneLen = 1u; /*ֵ1*/ + const UINT8 twoLen = 2u; /*ֵ2*/ + UINT32 queLen = 0u; /*г*/ + UINT16 pkgDataLen = 0u; /*ݳ*/ + UINT8 idx = 0u; /*±*/ + UINT8 crcValid = 0u; /*CRC16ǷЧ*/ + UINT16 dstLogicId = 0u; /*Է߼ID*/ + UINT8 frameType = 0u; /*֡*/ + UINT16 srcAddr = 0u; /*Դַ*/ + UINT16 dstAddr = 0u; /*Ŀĵַ*/ + UINT32 sn = 0u; /**/ + DataNode_WL* pLastNode = NULL; /*һڵ*/ + DataNode_WL* pCurNode = NULL; /*ǰڵ*/ + DataNode_WL* pNewNode = NULL; /*½ڵ*/ + UINT8 isCover = 0u; /*Ƿ񸲸ǽڵ*/ + UINT8 isPop = 0u; /*Ƿܵڵ*/ + UINT8 isAddFull = 0u; /*ջʱǷ*/ + UINT8 isInBreak = 0u; /*Ƿ˳ڲѭ*/ + UINT16 dstTypeId = 0u; /*ĿID*/ + UINT32 dstId = 0u; /*ĶԷΨһID*/ + UINT32 recvDstId = 0u; /*յЭΨһIDӦΨһID*/ + + if ((NULL != pInputQue) && (NULL != pHeadNode) && (NULL != rssp) && (NULL != rssp->StackOfDataLink) && (NULL != rssp->pDsuRsspInfoStruWL) && (NULL != rssp->FrameData) && (NULL != rssp->RecordArray)) /*-< Ƿǿ*/ + { + queLen = QueueStatus(pInputQue); /*-< öݳ*/ + PrintRecArray4ByteB(rssp->RecordArray, rssp->RecordArraySize, queLen); /*-< ¼ݳ*/ + /*,д*/ + while (queLen > twoLen) /*-< Ƿ*/ + { + QueueScan(twoLen, rssp->FrameData, pInputQue); /*-< ɨֽڵ*/ + pkgDataLen = ShortFromChar(rssp->FrameData); /*-< ʾĴ˵ݳ*/ + if ((twoLen + pkgDataLen) <= queLen) /*-< ʾĴ˵ݳǷ*/ + { + if ((twoLen + twoLen + RSSP_HEAD_LEN_WL + TC_LEN_WL + CRC_16_LEN_WL) < pkgDataLen) /*-< 2ֽID+2ֽ߼ID+RSSPI֡,Сڰ,ʾ֡Ƿ*/ + { + if ((twoLen + pkgDataLen) <= rssp->FrameDataMaxLen) /*-< ݳǷдջݻ*/ + { + QueueRead(twoLen + pkgDataLen, rssp->FrameData, pInputQue); /*-< ,2ֽڳ+RSSPI֡ʽ*/ + + idx = twoLen; /*-< 2ֽڳ*/ + dstTypeId = ShortFromChar(&rssp->FrameData[idx]); /*-< ĿID*/ + idx += twoLen; /*-< ±2*/ + dstLogicId = ShortFromChar(&rssp->FrameData[idx]); /*-< Ŀ߼ID*/ + idx += twoLen; /*-< ±2*/ + idx += oneLen; /*-< ±1*/ + frameType = rssp->FrameData[idx]; /*-< ֡*/ + idx += oneLen; /*-< ±1*/ + srcAddr = ShortFromCharLE(&rssp->FrameData[idx]); /*-< Դַ*/ + idx += twoLen; /*-< ±2*/ + dstAddr = ShortFromCharLE(&rssp->FrameData[idx]); /*-< Ŀĵַ*/ + idx += twoLen; /*-< ±2*/ + sn = LongFromCharLE(&rssp->FrameData[idx]); /*-< */ + + SetNetsRecvPkgNum(rssp, srcAddr, netIdx); /*-< øհ*/ + + PrintRecArray2ByteB(rssp->RecordArray, rssp->RecordArraySize, srcAddr); /*-< ¼Դַ־*/ + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, frameType); /*-< ¼֡־*/ + PrintRecArray4ByteB(rssp->RecordArray, rssp->RecordArraySize, sn); /*-< ¼־*/ + + if (dstAddr == rssp->pDsuRsspInfoStruWL->LocRsspiAddr) /*-< ǷǷ*/ + { +#ifdef RSSP_NO_HLHT + dstId = dstTypeId; /*-< öԷΨһID*/ +#else + dstId = DquTypeIdToHlhtId(dstTypeId, dstLogicId, rssp->pDsuRsspInfoStruWL); /*-< öԷΨһID*/ +#endif + dsuRsspRGetName_WL(srcAddr, dstAddr, &recvDstId, rssp->pDsuRsspInfoStruWL); /*-< յԷΨһID*/ + if (recvDstId == dstId) /*-< ΨһIDΨһIDǷһ*/ + { + crcValid = IsRedunRcvMsg(pkgDataLen - twoLen - twoLen, &rssp->FrameData[twoLen + twoLen + twoLen], rssp->RecordArray, rssp->RecordArraySize); /*-< ü鵥ݱĺ*/ + if (1u == crcValid) /*-< úǷɹ*/ + { + pLastNode = NULL; /*-< һڵ*/ + pCurNode = (*pHeadNode); /*-< ǰڵͷڵ㿪ʼ*/ + isCover = 0u; /*-< ǽڵ*/ + isPop = 0u; /*-< δڵ*/ + isAddFull = 0u; /*-< Ƿӱ־Ϊ*/ + + isInBreak = 0u; /*-< ˳־Ϊ˳*/ + while (NULL != pCurNode) /*-< ǰڵǷǿ*/ + { + if ((srcAddr == pCurNode->SrcAddr) && (sn == pCurNode->TCr) && (frameType == pCurNode->FrameType)) /*-< Ƿֵͬڵ*/ + { + isCover = 1u; /*-< øDZ־Ϊ*/ + isInBreak = 1u; /*-< ˳־Ϊ˳*/ + } + else /*Դַ,,֡ С*/ + { + if ((srcAddr < pCurNode->SrcAddr) /*-< Դַ,,֡*/ + || ((srcAddr == pCurNode->SrcAddr) && (sn < pCurNode->TCr)) /*ٱȽ*/ + || ((srcAddr == pCurNode->SrcAddr) && (sn == pCurNode->TCr) && (frameType < pCurNode->FrameType)) /*ٱȽ֡*/ + ) + { + isInBreak = 1u; /*-< ˳־Ϊ˳*/ + } + } + + if (0 == isInBreak) /*-< ˳־ΪǷΪ˳*/ + { + pLastNode = pCurNode; /*-< һڵΪڵ*/ + pCurNode = pCurNode->pNextNode;/*-< õǰڵΪһڵ*/ + + } + else /*˳*/ + { + break;/*-< ˳*/ + } + } + + if (1u == isCover) /*-< ǽڵ־ǷΪ*/ + { + pNewNode = pCurNode; /*-< ½ڵΪǰڵ*/ + } + else /*ڵ*/ + { + isPop = StackPopWl(&rssp->StackOfDataLink->stack, (STACK_DATA_TYPE_WL*)&pNewNode); /*-< õ½ڵ㺯*/ + if (1u == isPop) /*-< úǷɹ*/ + { + if (NULL != pCurNode) /*-< ǰڵǷǿ*/ + { + pNewNode->pNextNode = pCurNode; /*-< һڵΪǰڵ*/ + } + if (NULL == pLastNode) /*-< һڵǷΪ*/ + { + *pHeadNode = pNewNode; /*-< ͷڵΪ½ڵ*/ + } + else /*һڵָ½ڵ*/ + { + pLastNode->pNextNode = pNewNode; /*-< һڵΪ½ڵ*/ + } + } + else /*ջ*/ + { + if ((NULL != (*pHeadNode)) && (NULL != pLastNode)) /*-< ͷڵǿһڵǿ*/ + { + pNewNode = (*pHeadNode); /*-< ½ڵΪͷڵ*/ + (*pHeadNode) = (*pHeadNode)->pNextNode; /*-< ͷڵΪһڵ*/ + pLastNode->pNextNode = pNewNode; /*-< һڵΪ½ڵ*/ + pNewNode->pNextNode = pCurNode; /*-< һڵΪǰڵ*/ + isAddFull = 1u; /*-< Ƿӱ־Ϊ*/ + } + + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, RP_INPUT_STACK_NO); /*-< ¼־-ջ޿ռ־*/ + PrintRecArray4ByteB(rssp->RecordArray, rssp->RecordArraySize, queLen); /*-< ¼ݳ־*/ + } + } + if ((1u == isCover) || (1u == isPop) || (1u == isAddFull)) /*-< DZ־Ϊ ҵɹ ǷΪ*/ + { + pNewNode->FrameType = frameType; /*-< ֡*/ + pNewNode->SrcAddr = srcAddr; /*-< RSSPIԴַ*/ + dsuRsspRGetName_WL(srcAddr, dstAddr, &pNewNode->DevName, rssp->pDsuRsspInfoStruWL); /*-< öԷΨһID*/ +#ifdef RSSP_NO_HLHT + pNewNode->DestLogId = pNewNode->DevName & 0xff; /*-< Ŀ߼ID*/ +#else + pNewNode->DestLogId = DquToDevId(pNewNode->DevName, rssp->pDsuRsspInfoStruWL); /*-< Ŀ߼ID*/ +#endif + pNewNode->LocalLogId = rssp->LocalID; /*-< ñ߼ID*/ + pNewNode->DestLogicId = dstLogicId; /*-< öԷ߼ID*/ + pNewNode->DataLen = pkgDataLen - twoLen - twoLen - twoLen; /*-< ȥ2ֽCRC,pkgDataLen2ֽID,2ֽ߼ID*/ + pNewNode->TCr = sn; /*-< */ + RsspMemCopy_WL(&rssp->FrameData[twoLen + twoLen + twoLen], pNewNode->Data, pkgDataLen - twoLen); /*-< ֡*/ + } + } + } + else /*Ƿ*/ + { + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, RP_INPUT_FRAME_ID_ERR); /*-< ¼ΨһID־*/ + } + } + else /*Ƿ*/ + { + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, RP_INPUT_PKG_ADDR_ERR); /*-< ¼ַ־*/ + } + } + else /*ݳȲдջݻ*/ + { + QueueElementDiscard(twoLen + pkgDataLen, pInputQue); /*-< Ӷ˵*/ + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, RP_OVER_MAX_INPUT_PKG_LEN); /*-< ¼־*/ + } + } + else /*ʾ֡ȴ*/ + { + QueueElementDiscard(queLen, pInputQue); /*-< ն*/ + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, RP_INPUT_PKG_LEN_ERR); /*-< ¼ȴ־*/ + } + } + else /*ʾĴ˵ݳȴ*/ + { + QueueElementDiscard(queLen, pInputQue); /*-< ն*/ + PrintRecArrayByte(rssp->RecordArray, rssp->RecordArraySize, RP_INPUT_LEN_ERR); /*-< ¼볤ȴ־*/ + } + queLen = QueueStatus(pInputQue); /*-< ȡʣݳ*/ + + } + } +} + +/* +*: հ +*: struc_Unify_Info* sfp sfp +*: +*: +*ֵ: +*/ +static void ClearNetsRecvPkgNum(RSSP_INFO_STRU* rsspi) +{ + UINT16 i = 0u; /*ѭ*/ + + if ((NULL != rsspi) && (NULL != rsspi->NetsRecvPkgNums)) /**/ + { + for (i = 0; i < rsspi->NetsRecvPkgNumsLen; i++) + { + RsspMemSet_WL((UINT8*)rsspi->NetsRecvPkgNums[i].NetsPkgNum, 2 * sizeof(UINT16), 0u); + } + } +} + +/* +*: øհ +*: RSSP_INFO_STRU* rsspi rsspi +* const UINT16 dstAddr Ŀĵַ +* const UINT8 netIdx ± +*: +*: +*ֵ: +*/ +static void SetNetsRecvPkgNum(RSSP_INFO_STRU* rsspi, const UINT16 dstAddr, const UINT8 netIdx) +{ + UINT16 i = 0u; /*ѭ*/ + + if ((NULL != rsspi) && (NULL != rsspi->NetsRecvPkgNums) && ((0u == netIdx) || (1u == netIdx))) /**/ + { + for (i = 0; i < rsspi->NetsRecvPkgNumsLen; i++) + { + if (dstAddr == rsspi->NetsRecvPkgNums[i].DstAddr) /*ҵ*/ + { + rsspi->NetsRecvPkgNums[i].NetsPkgNum[netIdx]++; + break; + } + } + if ((i == rsspi->NetsRecvPkgNumsLen) && (rsspi->NetsRecvPkgNumsLen < rsspi->MaxNumLink)) /*δҵ,һ豸*/ + { + rsspi->NetsRecvPkgNums[rsspi->NetsRecvPkgNumsLen].DstAddr = dstAddr; + RsspMemSet_WL((UINT8*)rsspi->NetsRecvPkgNums[i].NetsPkgNum, 2 * sizeof(UINT16), 0u); + rsspi->NetsRecvPkgNums[rsspi->NetsRecvPkgNumsLen].NetsPkgNum[netIdx] = 1; + rsspi->NetsRecvPkgNumsLen++; + } + } +} + +/* +*: ȡRSSPIյ +*: RSSP_INFO_STRU* rsspi rsspi +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void GetNetsRecvPkgNum_WL(RSSP_INFO_STRU* rsspi, const UINT16 dstAddr, UINT16* redPkgNum, UINT16* bluePkgNum) +{ + UINT16 i = 0u; /*ѭ*/ + + if ((NULL != rsspi) && (NULL != rsspi->NetsRecvPkgNums) && (NULL != redPkgNum) && (NULL != bluePkgNum)) /**/ + { + for (i = 0; i < rsspi->NetsRecvPkgNumsLen; i++) + { + if (dstAddr == rsspi->NetsRecvPkgNums[i].DstAddr) + { + (*redPkgNum) = rsspi->NetsRecvPkgNums[i].NetsPkgNum[0]; + (*bluePkgNum) = rsspi->NetsRecvPkgNums[i].NetsPkgNum[1]; + break; + } + } + } +} + +#ifdef __cplusplus +} +#endif + + + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspRecordDelareWl.h b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspRecordDelareWl.h new file mode 100644 index 0000000..3426745 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspRecordDelareWl.h @@ -0,0 +1,90 @@ +/******************************************************** +* +* ļ RsspRecordDelareWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.12.16 +* ؼЭ鲿 +* RSR¼غ궨塣 +* ʹע⣺ +* +* ޸ļ¼ +* 2010.05.10 ޸ ׷Rsspڿʼʶ +* +********************************************************/ + +#ifndef _RSSP_RECORD_DECLARE_WL_H +#define _RSSP_RECORD_DECLARE_WL_H + +#include "RsspConfigWl.h" + +/******************************************************************************** +궨 +********************************************************************************/ + +#define RSSP_CYCLE_START 0xEE /*RSSPڿʼʶ*/ +#define RED_NET_DATA 0xF1 /**/ +#define BLUE_NET_DATA 0xF2 /**/ +#define RP_INPUT_LEN_ERR 0x01 /*ݳȴ*/ +#define RP_INPUT_PKG_LEN_ERR 0x02 /**/ +#define RP_OVER_MAX_INPUT_PKG_LEN 0x03 /**/ +#define RP_INPUT_PKG_ADDR_ERR 0x04 /*ַ*/ +#define RP_INPUT_PKG_INVALID 0x05 /*Уʧ*/ +#define RP_INPUT_STACK_NO 0x06 /*ջ޿ռ*/ +#define RP_INPUT_FRAME_LEN_ERR 0x07 /*뵥֡ȴ*/ +#define RP_INPUT_FRAME_TYPE_ERR 0x08 /*֡ͳȴ*/ +#define RP_INPUT_FRAME_ID_ERR 0x09 /*֡ΨһIDΨһID*/ + +#define RSSP_INPUT 0xF3 /*RSSP뵥Ԫʶ*/ +#define INPUT_LEN_ERR 0x20 /*ݳȴ*/ +#define INPUT_READ_ERR 0x21 /*ݶд*/ +#define INPUT_PKG_INVALID 0x22 /*Уʧ*/ +#define INPUT_STACK_NO 0x23 /*ջ޿ռ*/ +#define INPUT_RSD_LEN_ERR 0x24 /*RSD֡ȴ*/ +#define NO_NODE 0x25 /*޿ýڵ*/ +#define INPUT_NEW_NODE_ERR 0x26 /*ʱ½ڵ*/ +#define INPUT_NEW_NODE 0x27 /*ʱ½ڵ*/ +#define CHK_RSD_ADDR_ERR 0x28 /*RSDַ*/ +#define CHK_RSD_ERR 0x29 /*RSD*/ +#define INPUT_TC_EQ 0x2A /*RSDTC*/ +#define OVER_MAX_LOST 0x2B /*RSD󶪰*/ +#define OVER_MAX_TIME 0x2C /*RSDʱ*/ +#define SVC_ERR 0x2D /*RSDSVCУ*/ +#define RSD_HALT_SSE 0x2E /*յRSD,HALT״̬SSE*/ +#define RSD_RCV_HALT_ERR 0x2F /*յRSD,״̬*/ +#define SSE_LEN_ERR 0x30 /*յSSEȴ*/ +#define INPUT_SSE_NO_USE_NODE 0x31 /*յSSEʱ,õĽڵ*/ +#define CHK_SSE_ADDR_ERR 0x32 /*SSEַ*/ +#define SSR_LEN_ERR 0x33 /*յSSRȴ*/ +#define INPUT_SSR_NO_USE_NODE 0x34 /*յSSRʱ,õĽڵ*/ +#define CHK_SSR_ADDR_ERR 0x35 /*SSRַ*/ +#define UPD_SSR_ERR 0x36 /*SSR*/ +#define SSR_RCV_STATUS_ERR 0x37 /*յSSR·״̬*/ +#define SSR_SSE_SN_ERR 0x38 /*յSSRӦSSEŴ*/ +#define RSD_DUP 0x39 /*RSDظ*/ +#define RSD_DEL_DATA_NODE_ERR 0x3A /*RSDɾݽڵ*/ +#define RSD_APP_WRITE_ERR 0x3B /*RSDɾݽڵ*/ +#define OLD_DATA 0x3C /*RSDݰ*/ +#define INPUT_DEL_NODE_ERR 0x3D /*ɾڵ*/ +#define INPUT_WRITE_ERR 0x3E /*Э鵽Ӧô*/ +#define INPUT_LNK_STATUS_ERR 0x3F /*·״̬*/ + +#define RSSP_OUTPUT 0xF4 /*RSSPIԪʶ*/ +#define OUTPUT_LEN_ERR 0x60 /*ݳȴ*/ +#define OUTPUT_READ_QUE_ERR 0x61 /*ȡд*/ +#define OUTPUT_NEW_NODE_ERR 0x62 /*½ڵ*/ +#define OUTPUT_NEW_NODE 0x63 /*½ڵ*/ +#define OUTPUT_WRITE_NO_SPACE_ERR 0x64 /*д޿ռ*/ +#define OUTPUT_FRAME_ERR 0x65 /*֡*/ + +#define LINK_INFO 0xF5 /*RSSPI·Ϣ*/ + +#define GET_SVC 0xF6 /*ȡRSSPI SVC*/ +#define SET_SVC 0xF7 /*RSSPI SVC*/ +#define SET_SVC_DATA_ERR 0xA0 /*SVCݴ*/ +#define NO_OUT_APP 0xA1 /*ûӦ*/ +#define PKG_LEN_ERR 0xA2 /*ȴ*/ +#define FRAME_TYPE_ERR 0xA3 /*֡*/ + +#endif + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspStructWl.h b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspStructWl.h new file mode 100644 index 0000000..7841261 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspStructWl.h @@ -0,0 +1,161 @@ +/******************************************************** +* +* ļ RsspStructWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* RsspʹõĽṹ嶨 +* ʹע⣺ +* +* ޸ļ¼ +* 2011.12.06 ޸ͨŽڵϢṹ塣ɾ̬IDRsspԴַRsspĿĵַBsdַ +* +********************************************************/ + +#ifndef _RSSP_STRUCT_WL_H_ +#define _RSSP_STRUCT_WL_H_ + +#include "CommonTypes.h" +#include "RsspCommonWl.h" +#include "RsspTmpMsgLnkCommonWl.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* RSSPЭ汾Ŷ */ +#define RSSPCODE_VER_PRODUCT_NO 88/*Ʒ*/ +#define RSSPCODE_VER_MODULE_NO 20/*ģ*/ +#define RSSPCODE_VER_MAIN_VER 20/*ģ汾*/ +#define RSSPCODE_VER_SUB_VER 3 /*ģӰ汾*/ + +/*-------------------------------------------------------------------- + * RSSPڲʹýṹ Start + *--------------------------------------------------------------------*/ + +/* ·״̬ */ +typedef enum +{ + Halt_WL = 0x00, /* ж ·n֮sse֮״̬nʱΪ4 ߳ʼ״̬IDLE */ + SendSSE_WL = 0x01, /* SSE ܽڵ */ + WaitSSR_WL = 0x02, /* ȴSSR ܽڵ */ + RecvData_WL = 0x04, /* ܽڵ */ + SendSSR_WL = 0x20, /* SSR ͽڵ */ + SendData_WL = 0x40 /* ͽڵ */ +} ENUM_RSSP_LINK_STATUS_WL; + +/* ڵ״̬ö */ +typedef enum +{ + Replace_WL = 0x01, /* ɸ״̬ ýڵֹͣݻdzʼ״̬ */ + DisbaledReplace_WL = 0x02 /* ɸ״̬ýڵ㻹ڼ */ +} ENUM_RSSP_NODE_STATUS_WL; + +/* 豸ڵϢṹ */ +typedef struct +{ + UINT32 SIDe[2]; /* SID */ + UINT32 SIDr[2]; /* SID */ + UINT32 SINIT[2]; /* SINIT */ + UINT32 DATAVER[2]; /* DATAVER */ + UINT8 NumDataVer[2]; /* Data 汾 */ + UINT8 DLost; /* */ + UINT8 SSDelay; /* 涨ʱ䣨SSDelay */ + UINT8 AntiDelayCount; /* ͬ */ + UINT8 Tout; /* BSDijʱ */ + UINT8 MaxLost; /* ʧ */ + UINT32 PREC_SINIT_K[2][DSURSR_MAX_K_NUM_WL]; /* ߲PREC_SINIT? */ + UINT32 PREC_FIRSTSINIT[2]; /* ߲PREC_FIRSTSINIT */ + UINT32 TSD_POST_RXDADA_K[2][DSURSR_MAX_K_NUM_WL]; /* ߲ BSD̶ֵ */ +} NodeParamInfoStru_WL; + +/* RSSP·Ϣṹ */ +typedef struct +{ + UINT8 LocalLogId; /* ̬ID */ + UINT8 DestLogId; /* Է̬ID */ + UINT8 RecvLinkStatus; /* ·״̬ */ + UINT8 SendLinkStatus; /* ·״̬ */ + UINT8 NoRecvDataCycleNum; /* */ + UINT8 NoAppDataCycleNum; /* ޷Ӧ */ + UINT16 DestBsdAdd; /* BSDַ */ + UINT16 RsspSrcAddr; /* RSSPԴַ */ + UINT16 RsspDestAddr; /* RSSPĿĵַ */ + TimeStampStru_WL TimeStmp; /* ʱϢ */ + NodeParamInfoStru_WL LocalNode; /* ܽڵ */ +} RsspLinkInfoStru_WL; + +/* ͨŽڵṹ */ +typedef struct +{ + UINT32 CycleNum; /*ǰ·ں*/ + UINT8 ExeCycle; /*ǷΪִ*/ + UINT8 HasRsdBeforeSseOrSsr; /*SSESSR֮ǰǷRSD*/ + UINT8 RecvKeepHaltCycleNum; /*ձHalt_WL״̬*/ + UINT8 RecvKeepSendSseCycleNum; /*ձSendSSE_WL״̬*/ + + UINT32 DestDevName; /*ԷΨһID*/ + UINT16 DestTypeId; /*ԷID*/ + UINT16 DestLogicId; /*Է߼ID*/ + + UINT8 NodeStatus; /* ڵ㸲״̬ */ + RsspLinkInfoStru_WL RsspLinInfo; /* RSSP·Ϣ */ +} Lnk_Info_Node_Stru_WL; + +/*յ*/ +typedef struct +{ + UINT16 DstAddr; + UINT16 NetsPkgNum[2]; +}RsppiNetsRecvPkgNum; + +/*-------------------------------------------------------------------- + * RSSPڲʹýṹ End + *--------------------------------------------------------------------*/ +typedef struct +{ + UINT8 cpuId; /* cpuID,Сͻ˫CPUSVC*/ + UINT8 LocalID; /* 豸IDӦðĵڳʼʱд */ + UINT8 LocalType; /* 豸typeӦðĵڳʼʱд */ + UINT16 LocalLogicId; /*߼ID*/ + UINT32 *CycleNum; /* ںţӦðĵÿڿʼʱд */ + UINT8 MaxNumLink; /* RSSPͬʱͨŵӦðĵڳʼʱд */ + UINT8 MaxNumPerCycle; /* RSSPһÿЧݣӦðĵڳʼʱд */ + UINT16 InputSize; /* RSSPһ֡ӦݳȣӦðĵڳʼʱд */ + UINT16 OutputSize; /* RSSP㷢һ֡ӦݳȣӦðĵڳʼʱд */ + UINT8 *RecordArray; /* RSSP¼ */ + UINT16 RecordArraySize; /* RSSP¼С */ + UINT8 *AppArray; /* ģij1ʾ */ + UINT32 AppArraySize; /* RSSPģij鳤 */ + UINT8 *VarArray; /* RSSPģij2ʾм */ + UINT16 VarArraySize; /* ģij鳤 */ + QueueStruct DataToApp; /* RSSPЭӦõݶ */ + UINT32 DataToAppSize; /* ЭӦõݶг */ + QueueStruct OutputDataQueue; /* RSSPӦøЭݶ */ + UINT32 OutputDataQueueSize; /* ӦøЭݶг */ + QueueStruct OutnetQueueA; /* RSSPնA(->) */ + QueueStruct OutnetQueueB; /* RSSPնB(->) */ + UINT32 OutnetQueueSize; /* նгȣЭʼʱд */ + + /* ڵʱӵı */ + UINT16 FrameDataMaxLen; /*֡󳤶*/ + UINT8* FrameData; /*֡*/ + RsspStackElement_WL* StackOfDataLink; + Lnk_Info_Node_Stru_WL* LnkNodeArr; /* ͨŽڵ */ + UINT8 LnkNodeNum; /* ͨŽڵ鳤 */ + DSU_RSSP_INFO_STRU_WL *pDsuRsspInfoStruWL; /*RSSPϢ*/ + UINT8 NoSendAppData; /*ʱӦøЭӦ*/ + UINT16 NetsRecvPkgNumsLen; /*յ鳤*/ + RsppiNetsRecvPkgNum* NetsRecvPkgNums; /*յ*/ + UINT8* gpSendSingleOutMsg; /*͵֡*/ +} RSSP_INFO_STRU; + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspTmpMsgLnkCommonWl.c b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspTmpMsgLnkCommonWl.c new file mode 100644 index 0000000..0b2517c --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspTmpMsgLnkCommonWl.c @@ -0,0 +1,524 @@ +/******************************************************** +* +* ļ RsspTmpMsgLnkCommonWl.c +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* ʱ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2009.12.15 ¥ΰ ԪBugӦ +* 2013.02.22 ޸GetSortedMsgFromQueɾɫ +********************************************************/ +#include +#include "CommonMemory.h" +#include "RsspCommonWl.h" +#include "RsspTmpMsgLnkCommonWl.h" +#include "RsspRecordDelareWl.h" +#include "CommonRecord.h" + +#ifdef __cplusplus +extern "C" { +#endif + + + /*-------------------------------------------------------------------- + * RSSPڲӿں Start + *--------------------------------------------------------------------*/ + /*********************************************************************** + * : GetSortedMsgFromQue_WL + * : ԺݽRSRİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pMsgQue QueueStruct* IN źŲ㵽Rssp + * MaxLen UINT16 IN + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 + * + * ֵ : DataNode_WL* ʱͷ + ***********************************************************************/ + DataNode_WL* GetSortedMsgFromQue_WL(QueueStruct *RpToRs, UINT16 MaxLen, UINT8 *RecordArray, UINT16 RecordSize, UINT8 *pTmpDataBuff, RsspStackElement_WL *pStackOfDataLink) + { + UINT8 ret = 0; + UINT16 MsgLen = 0; /* Ϣ */ + DataNode_WL *pHead = NULL; /* ͷ */ + DataNode_WL *pCur = NULL; /* ǰɵĽڵ */ + const UINT8 QUE_FIXED_LEN = 8; /* нڵ̶ֳ */ + const UINT8 SENDER_TYPE_QUE_POS = 2; /* źŲбԷΨһIDλ */ + const UINT8 SENDER_LOG_ID_QUE_POS = SENDER_TYPE_QUE_POS + 4; /* źŲб淢ͷ̬Idλ */ + const UINT8 RECV_LOG_ID_QUE_POS = SENDER_LOG_ID_QUE_POS + 1; /* źŲб汾̬Idλ */ + const UINT8 LOGIC_ID_QUE_POS = RECV_LOG_ID_QUE_POS + 1; /* źŲб汾̬Idλ */ + const UINT8 RSSP_DATA_QUE_POS = LOGIC_ID_QUE_POS + 2; /* źŲбӦλ */ + + if ((NULL != RpToRs)&& (NULL != RecordArray) && (NULL != pTmpDataBuff) && (NULL != pStackOfDataLink)) + { + /* г>2 */ + while (2 <= QueueStatus(RpToRs)) + { + /* źŲRSSPнڵʽ + * ---------------------------------------------------------------------- + * | ͷType | ͷID | ͷ̬Id | ̬Id | RSSPϢ | + * 2ֽ| 1ֽ | 1 ֽ | 1 ֽ | 1ֽ | n | + * ----------------------------------------------------------------------- + */ + QueueScan(2, pTmpDataBuff, RpToRs); /* ɨֽڵij */ + MsgLen = ShortFromChar(pTmpDataBuff); + if ((MsgLen + 2) <= MaxLen) + { + ret = QueueRead(MsgLen + 2, (QueueElement*)pTmpDataBuff, RpToRs); + if (ret == 0) + { + /* ʧʣµݴССMsgLen+2¼ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "W:Write Que Err\n"); /* ʧ */ +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordSize, INPUT_READ_ERR); /* ʧ */ +#endif + break; + } + + /* RSSP ʱĽڵ */ + ret = IsRedunRcvMsg((UINT16)(MsgLen - QUE_FIXED_LEN), &pTmpDataBuff[QUE_FIXED_LEN + 2], RecordArray, RecordSize); + /* ǷΪRSSPģȻжϷǷϷ */ + if (1 == ret) + { + /* ӶջﵯһʱĽڵ㣬ַ浽pCur */ + ret = StackPopWl(&pStackOfDataLink->stack, (STACK_DATA_TYPE_WL*)&pCur); + if (1 == ret) + { + /* ȡɹ */ + /*ԷΨһID*/ + pCur->DevName = LongFromChar(&pTmpDataBuff[SENDER_TYPE_QUE_POS]); + + /* ͷ̬ID 趨 TmpDataBuff[4] */ + pCur->DestLogId = pTmpDataBuff[SENDER_LOG_ID_QUE_POS]; + + /* շ̬ID TmpDataBuff[5]*/ + pCur->LocalLogId = pTmpDataBuff[RECV_LOG_ID_QUE_POS]; + + /*Է߼ID*/ + pCur->DestLogicId = ShortFromChar(&pTmpDataBuff[LOGIC_ID_QUE_POS]); + + /* RSSPϢ趨 ȥ2λCRC*/ + pCur->DataLen = MsgLen - QUE_FIXED_LEN - 2; + RsspMemCopy_WL(&pTmpDataBuff[RSSP_DATA_QUE_POS], pCur->Data, pCur->DataLen); + + /* ļ趨 */ /* Bug 874 Ӧ */ + pCur->TCr = LongFromCharLE(&pCur->Data[RSSP_TC_POS_WL]); + + /* ʱ */ + pHead = InsTmpMsgLnk_WL(pHead, pCur); +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "IN:\n"); + PrintFiles(RecordArray, RecordSize, "DestType:"); /* ֡ͷ */ + PrintFileHex(RecordArray, RecordSize, &pTmpDataBuff[SENDER_TYPE_QUE_POS], 1); + PrintFiles(RecordArray, RecordSize, "\tDestId:"); /* ֡ͷID */ + PrintFileHex(RecordArray, RecordSize, &pTmpDataBuff[SENDER_ID_QUE_POS], 1); + PrintFiles(RecordArray, RecordSize, "\tDestLogId:"); /* ֡ͷ̬ID */ + PrintFileHex(RecordArray, RecordSize, &pTmpDataBuff[SENDER_LOG_ID_QUE_POS], 1); + PrintFiles(RecordArray, RecordSize, "\tLocLogId:"); /* ܷ̬֡ID */ + PrintFileHex(RecordArray, RecordSize, &pTmpDataBuff[RECV_LOG_ID_QUE_POS], 1); + PrintFiles(RecordArray, RecordSize, "\tMsgType:"); /* ֡Ϣ */ + PrintFileHex(RecordArray, RecordSize, &pCur->Data[RSSP_MSG_TYPE_POS_WL], 1); + PrintFiles(RecordArray, RecordSize, "\tSrcAddr:"); /* ֡ϢԴַ */ + PrintFileU16Hex(RecordArray, RecordSize, ShortFromCharLE(&pCur->Data[RSSP_SRC_ADD_POS_WL])); + PrintFiles(RecordArray, RecordSize, "\tDestAddr:"); /* ֡ϢĿĵַ */ + PrintFileU16Hex(RecordArray, RecordSize, ShortFromCharLE(&pCur->Data[RSSP_DEST_ADD_POS_WL])); + PrintFiles(RecordArray, RecordSize, "\tTC:"); /* ֡Ϣ */ + PrintFileU32Hex(RecordArray, RecordSize, pCur->TCr); + PrintFiles(RecordArray, RecordSize, "\n"); +#endif + } + else + { + /* ȡʧܣջнڵ㲻 */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "W:Link POP Err."); /* ջ */ +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordSize, INPUT_STACK_NO); /* ջ */ +#endif + break; + } + } + else /* RSSPϢ */ + { + /* ¼ϢͲ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "W:Not Rssp MSg.\n"); /* RSSPϢ */ +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordSize, INPUT_PKG_INVALID); /* RSSPϢ */ +#endif + } + } + else + { + /* 󳤶ȳ */ + QueueElementDiscard(MsgLen, RpToRs); + /* һ֡ */ +#ifdef RSSP_RECORD_ERR_ASCII /* ַʽ */ + PrintFiles(RecordArray, RecordSize, "W:Queue Err.\n"); /* вϷ */ +#endif +#ifdef RSSP_RECORD_SIMPLIFY_BIN /* */ + PrintRecArrayByte(RecordArray, RecordSize, INPUT_LEN_ERR); /* вϷ */ +#endif + } + } + } + return pHead; + } + + /*********************************************************************** + * : InsTmpMsgLnk_WL + * : һڵ㡣ʶк˳ + * : + * + * -------------------------------------------------------------- + * pHead DataNode_WL* IN ͷ + * pDataNode DataNode_WL* IN Ľڵ + * + * ֵ : DataNode* ʱͷ + ***********************************************************************/ + DataNode_WL* InsTmpMsgLnk_WL(DataNode_WL *pHead, DataNode_WL *pNode) + { + DataNode_WL *pLast = NULL, *pCur = NULL; + + pCur = pHead; + + /* ڵָΪգֱӷ ͷ */ /* Bug 847 Ӧ */ + if (NULL == pNode) + { + return pHead; + } + + while (pCur != NULL) + { + /* ǰڵıʶڲڵ ߱ʶ ڲ ôѭ */ + if ((pCur->DevName > pNode->DevName) || + ((pCur->DevName == pNode->DevName) && (pCur->TCr >= pNode->TCr))) + { + break; + } + else + { + /* һڵ */ + pLast = pCur; + pCur = pCur->pNextNode; + + } + } + + /* ڵ */ + if (NULL == pLast) + { + /* ͷ */ + pNode->pNextNode = pCur; + pHead = pNode; + } + else + { + /* 뵽pLast */ + pLast->pNextNode = pNode; + pNode->pNextNode = pCur; + } + + return pHead; /* رͷ */ + } + + /*********************************************************************** + * : DelTmpMsgLnkNode_WL + * : ɾӦĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * pCur DataNode_WL* IN ɾڵ + * pLast DataNodev* IN ɾǰڵ + * pHead DataNode_WL** INOUT ͷָָ룬Ϊصıͷָ + * + * ֵ : UINT8 1: 0: + ***********************************************************************/ + UINT8 DelTmpMsgLnkNode_WL(DataNode_WL *pCur, DataNode_WL *pLast, DataNode_WL **pHead, RsspStackElement_WL *pStackOfDataLink) + { + UINT8 ret = 1; + /* ǰڵ㲻Ϊͷ */ + if (pCur != *pHead) + { + pLast->pNextNode = pCur->pNextNode; + } + else + { + /* ǰڵΪͷ */ + *pHead = pCur->pNextNode; + } + + /* pCurָڵ */ + pCur->DataLen = 0; + pCur->DestLogId = 0; + pCur->DevName = 0; + pCur->DestTypeId = 0; + pCur->LocalLogId = 0; + pCur->DestLogicId = 0; + pCur->TCr = 0; + pCur->pNextNode = 0; + + /* ѹжջ */ + if (0 == StackPushWl(&pStackOfDataLink->stack, (STACK_DATA_TYPE_WL)pCur)) + { + /* ѹջʧ */ + ret = 0; + } + else + { + ret = 1; + } + + return ret; + } + + /*********************************************************************** + * : InitMsgNodeStack_WL + * : ʼʱĶջռ䡣 + * : + * + * -------------------------------------------------------------- + * NodeNum UINT16 IN + * MaxData UINT16 IN С + * pStackOfDataLink RsspStackElement_WL** INOUT ջԪ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ + UINT8 InitMsgNodeStack_WL(UINT16 NodeNum, UINT16 MaxData, RsspStackElement_WL **pStackOfDataLink) + { + UINT8 ret = 0; + UINT16 index = 0; + UINT16 NodeLen = 0; + DataNode_WL* pTmp = NULL; + + NodeLen = sizeof(DataNode_WL); + + /* ADD 20130802 */ + if ((0 == NodeNum) || (0 == MaxData) || (NULL == pStackOfDataLink)) + { + return ret; + } + /* ʱĶջṹռ */ + *pStackOfDataLink = (RsspStackElement_WL*)malloc(sizeof(RsspStackElement_WL)); + if (NULL == *pStackOfDataLink) + { + return ret; + } + else + { + CommonMemSet(*pStackOfDataLink, sizeof(RsspStackElement_WL), 0, sizeof(RsspStackElement_WL)); + } + + /* ջʼ */ + ret = StackInitialWl(&(*pStackOfDataLink)->stack, NodeNum); + if (0 == ret) + { + /* ʧ ͷѷռ */ + DestoryMsgNodeStack_WL(pStackOfDataLink); + + /* ջʼʧ */ + return ret; + } + + /* Ŀռ */ + (*pStackOfDataLink)->pFirstNode = (DataNode_WL *)malloc(NodeNum * NodeLen); + if (NULL == (*pStackOfDataLink)->pFirstNode) + { + /* ʧ ͷѷռ */ + DestoryMsgNodeStack_WL(pStackOfDataLink); + + /* ڴʧ */ + ret = 0; + return ret; + } + else + { + CommonMemSet((*pStackOfDataLink)->pFirstNode, NodeNum * NodeLen, 0, NodeNum * NodeLen); + } + + /* ʱĽڵѹջ */ + for (index = 0; index < NodeNum; index++) + { + pTmp = &(*pStackOfDataLink)->pFirstNode[index]; + pTmp->Data = (UINT8 *)malloc(MaxData); /* ʵʱı */ + if (NULL == pTmp->Data) + { + /* ʧ ͷѷռ */ + DestoryMsgNodeStack_WL(pStackOfDataLink); + ret = 0; + return ret; + } + else + { + /* ʲô */ + CommonMemSet(pTmp->Data, MaxData, 0, MaxData); + } + + /* ѹջ */ + ret = StackPushWl(&(*pStackOfDataLink)->stack, (STACK_DATA_TYPE_WL)pTmp); + if (0 == ret) + { + /* ʧ ͷѷռ */ + DestoryMsgNodeStack_WL(pStackOfDataLink); + return ret; + } + else + { + /* ʲô */ + } + } + + return ret; + } + + + /*********************************************************************** + * : DestoryMsgNodeStack_WL + * : ͷʱĶջռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : UINT8 1 + ***********************************************************************/ + UINT8 DestoryMsgNodeStack_WL(RsspStackElement_WL **pStackOfDataLink) + { + UINT8 ret = 1; + DataNode_WL *pNode = NULL; + + /* ȫʱĶջΪգ */ + if (NULL == *pStackOfDataLink) + { + return ret; + } + + while (StackStatusWl(&(*pStackOfDataLink)->stack) > 0) + { + /* Ѿ֤˶ջ϶пнڵ㣬 */ + ret = StackPopWl(&(*pStackOfDataLink)->stack, (STACK_DATA_TYPE_WL*)&pNode); + if (pNode->Data != NULL) + { + free(pNode->Data); + pNode->Data = NULL; + } + } + + /* ͷŶջ */ + ret = StackFreeWl(&(*pStackOfDataLink)->stack); + + /* ͷʱĶнڵ㻺 */ + if ((*pStackOfDataLink)->pFirstNode != NULL) + { + free((*pStackOfDataLink)->pFirstNode); + (*pStackOfDataLink)->pFirstNode = NULL; + } + + /* ͷȫֵָpRsspStru->StackOfDataLinkָĿռ */ + free((*pStackOfDataLink)); + (*pStackOfDataLink) = NULL; + + return ret; + } + + /*********************************************************************** + * : IsRedunRcvMsg + * : 鱨ӦͺϢǷΪRSSPģԼԱĵĽCRC֤ + * : + * + * -------------------------------------------------------------- + * MsgLen const UINT16 in ij + * pData const UINT8 in ģ16λCRC + * + * ֵ : UINT8 1RSSP 0:RSSP + ***********************************************************************/ + + /** + * @brief IsRedunRcvMsg 鱨ӦͺϢǷΪRSSPģԼԱĵĽCRC֤ + * @param MsgLen ij ȡֵΧ:0x0000-0xFFFF + * @param pData ȡֵΧ:ֽ + * @param recordArray ־ ȡֵΧ:ֽ + * @param recordArraySize ־鳤 ȡֵΧ:0x0000-0xFFFF + * @return 1:ɹ;0:ʧ + */ + UINT8 IsRedunRcvMsg(UINT16 MsgLen, const UINT8 pData[], UINT8* recordArray, UINT16 recordArraySize) + { + UINT8 ret = 1; /*-< úֵΪɹ*/ + UINT16 calcCrc = 0, msgCrc = 0; + + /* ij ССRSSPijȣSSEijȣ */ + if (MsgLen < RSSP_SSE_LEN_WL) /*-< ֡ǷСС֡*/ + { + ret = 0; /*-< úֵΪʧ*/ + + PrintRecArrayByte(recordArray, recordArraySize, RP_INPUT_FRAME_LEN_ERR); /*-< ¼֡ȴ־*/ + PrintRecArray2ByteB(recordArray, recordArraySize, MsgLen); /*-< ¼֡־*/ + } + else + { + /* RSSPϢʽ + * -------------------------------------------------------- + * Head | Body | 16λ CRC | + * --------------------------------------------------------- + * Ӧ|Ϣ|Դַ|Ŀַ | | | + * --------------------------------------------------------- + * 1ֽ| 1ֽ | 2ֽ| 2ֽ | n | 2 ֽ | + * --------------------------------------------------------- + */ + calcCrc = ComputeMsgCRC16_WL(pData, (UINT16)(MsgLen - (UINT16)(CRC_16_LEN_WL))); /*-< CRCֵ*/ + msgCrc = ShortFromCharLE(pData + MsgLen - CRC_16_LEN_WL); /*-< õ֡CRCֵ*/ + + /* CRC */ + if (calcCrc != msgCrc) /*-< CRCǷ񲻵*/ + { + ret = 0; /*-< úֵΪʧ*/ + + PrintRecArrayByte(recordArray, recordArraySize, RP_INPUT_PKG_INVALID); /*-< ¼CRCУ־*/ + PrintRecArray2ByteB(recordArray, recordArraySize, calcCrc); /*-< ¼CRCֵ־*/ + PrintRecArray2ByteB(recordArray, recordArraySize, msgCrc); /*-< ¼õ֡CRCֵ־*/ + } + else + { + /* Application Category = 01 */ + /* Message Type = 80 or 90 or 91 */ + if ((RSSP_APP_CATEGORY_WL != pData[RSSP_APP_CTGRY_POS_WL]) + || ((RSSP_SSE_MSG_WL != pData[RSSP_MSG_TYPE_POS_WL]) + && (RSSP_SSR_MSG_WL != pData[RSSP_MSG_TYPE_POS_WL]) + && (RSSP_RSD_MSG_WL != pData[RSSP_MSG_TYPE_POS_WL]) + && (RSSP_RSD_MSG_WL_B != pData[RSSP_MSG_TYPE_POS_WL]))) /*-< Ƿ1 ֡Ƿ0x90,ҷ0x91,ҷ0x80,ҷ0x81*/ + { + ret = 0; /*-< úֵΪʧ*/ + + PrintRecArrayByte(recordArray, recordArraySize, RP_INPUT_FRAME_TYPE_ERR); /*-< ¼֡ʹ־*/ + PrintRecArrayByte(recordArray, recordArraySize, pData[RSSP_APP_CTGRY_POS_WL]); /*-< ¼־*/ + PrintRecArrayByte(recordArray, recordArraySize, pData[RSSP_MSG_TYPE_POS_WL]); /*-< ¼֡־*/ + } + else + { + ret = 1; /*-< úֵΪɹ*/ + } + } + } + return ret; /*-< غֵ*/ + } + + /*-------------------------------------------------------------------- + * RSSPڲӿں End + *--------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + + + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspTmpMsgLnkCommonWl.h b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspTmpMsgLnkCommonWl.h new file mode 100644 index 0000000..e35dd46 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspTmpMsgLnkCommonWl.h @@ -0,0 +1,135 @@ +/******************************************************** +* +* ļ RsspTmpMsgLnkCommonWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.11.25 +* ؼЭ鲿 +* Rsspʱ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +********************************************************/ + +#ifndef _RSSP_TMP_MSG_LNK_COMMONWL_WL_H_ +#define _RSSP_TMP_MSG_LNK_COMMONWL_WL_H_ + +#include "CommonQueue.h" +#include "RsspCommonWl.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ʱڵ */ +typedef struct DataNodeStru_WL +{ + UINT32 DevName; /* 豸ʶ */ + UINT16 DestTypeId; /*ԷID*/ + UINT32 TCr; /* к */ + UINT8 DestLogId; /* Է̬ID */ + UINT8 LocalLogId; /* ̬ID */ + UINT16 DestLogicId;/*Է߼ID*/ + UINT8 FrameType; /*֡*/ + UINT16 SrcAddr; /*RSSPIԴַ*/ + UINT16 DataLen; /* ij */ + UINT8 *Data; /* */ + struct DataNodeStru_WL *pNextNode; /* һڵ */ + } DataNode_WL; + +/* ʱĶջṹ */ +typedef struct +{ + CommonStackWl stack; /* ջ */ + DataNode_WL *pFirstNode; /* ջռ */ +} RsspStackElement_WL; + +/*-------------------------------------------------------------------- + * RSSPڲӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : GetSortedMsgFromQue_WL + * : ԺݽRSSPİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pMsgQue QueueStruct* IN źŲ㵽Rssp + * MaxLen UINT16 IN + * RecordArray UINT8* INOUT ¼ + * RecordArraySize UINT16 + * + + * ֵ : DataNode_WL* ʱͷ + ***********************************************************************/ +DataNode_WL* GetSortedMsgFromQue_WL(QueueStruct *RpToRs,UINT16 MaxLen,UINT8 *RecordArray, UINT16 RecordSize, UINT8 *pTmpDataBuff, RsspStackElement_WL *pStackOfDataLink); + +/*********************************************************************** + * : InsTmpMsgLnk_WL + * : һڵ㡣ʶк˳ + * : + * + * -------------------------------------------------------------- + * pHead DataNode_WL* IN ͷ + * pNode DataNode_WL* IN Ľڵ + * + * ֵ : DataNode_WL* NULL쳣 NULLʱͷ + ***********************************************************************/ +DataNode_WL* InsTmpMsgLnk_WL(DataNode_WL *pHead,DataNode_WL *pNode); + +/*********************************************************************** + * : DelTmpMsgLnkNode_WL + * : ɾ + ӦĽڵ㡣 + * : + * + * -------------------------------------------------------------- + * pCur DataNode_WL* IN ɾڵ + * pLast DataNode_WL* IN ɾǰڵ + * pHead DataNode_WL** INOUT ͷ + * + * ֵ : DataNode_WL* NULL쳣 NULLʱͷ + ***********************************************************************/ +UINT8 DelTmpMsgLnkNode_WL(DataNode_WL *pCur,DataNode_WL *pLast,DataNode_WL **pHead, RsspStackElement_WL *pStackOfDataLink); + +/*********************************************************************** + * : InitMsgNodeStack_WL + * : ʼʱĶջռ䡣 + * : + * + * -------------------------------------------------------------- + * NodeNum UINT16 IN + * MaxData UINT16 IN С + * pStackOfDataLink RsspStackElement_WL** INOUT ջԪ + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 InitMsgNodeStack_WL(UINT16 NodeNum,UINT16 MaxData, RsspStackElement_WL **pStackOfDataLink); + + +/*********************************************************************** + * : DestoryMsgNodeStack_WL + * : ͷʱĶջռ + * : + * + * ------------------------------------------------------------- + * + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 DestoryMsgNodeStack_WL(RsspStackElement_WL **pStackOfDataLink); + +/*-------------------------------------------------------------------- + * RSSPڲӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspWl.c b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspWl.c new file mode 100644 index 0000000..5e5b73d --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspWl.c @@ -0,0 +1,694 @@ +/** ****************************************************** +* +* ļ RsspWl.c +* Ȩ˵ ؿƼ޹˾ +* 汾 1.0 +* ʱ䣺 2013.2.5 +* ؼЭ鲿 +* RsspЭʵ +* ʹע⣺ +* +* ޸ļ¼ +* ʱ +* ------------ ------ --------------- +* 2009.12.07 ¥ΰ +* 2013.02.07 ӺԼӦRSSPṹ +********************************************************/ +#include +#include "CommonMemory.h" +#include "RsspIFWl.h" +#include "RsspStructWl.h" +#include "RsspCommonWl.h" +#include "Convert.h" +#include "RsspRecordDelareWl.h" +#include "CommonRecord.h" +#include "RsspLnkNodeMgrWl.h" +#include "dsuRsspFunc.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/*-------------------------------------------------------------------- + * RSSPڲʹú Start + *--------------------------------------------------------------------*/ + +static UINT8 CheckRsspStruct_WL(const RSSP_INFO_STRU *pRsspStruct); + +/*-------------------------------------------------------------------- + * RSSPڲʹú End + *--------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------- + * RSSPӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : Rssp2Receive + * : ԺݽRSSPİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ + * УpRsspStruct->OutnetQueueA + * pRsspStruct->OutnetQueueB + * УpRsspStruct->DataToApp + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ + + /* + *: Rssp2Receive + *: RSSPI봦 + *: + *: RSSP_INFO_STRU *pRsspStruct RSSPIϢ + *: + *ֵ: 1:ɹ;0:ʧ + */ +UINT8 Rssp2Receive(RSSP_INFO_STRU* pRsspStruct) +{ + UINT8 rtn = 0; /*ֵ*/ + + if ((NULL != pRsspStruct) && (NULL != pRsspStruct->pDsuRsspInfoStruWL) && (NULL != pRsspStruct->RecordArray)) /*ָǿռ*/ + { + ShortToChar(0, pRsspStruct->RecordArray); /*¼*/ + PrintRecArrayByte(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, RSSP_CYCLE_START); /*RSSPI־ʼʶ*/ + PrintRecArray4ByteB(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, *pRsspStruct->CycleNum); /*ں*/ + PrintRecArrayByte(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, pRsspStruct->LocalType); /**/ + PrintRecArrayByte(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, pRsspStruct->LocalID); /*ID*/ + PrintRecArray2ByteB(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, pRsspStruct->LocalLogicId); /*߼ID*/ + PrintRecArray2ByteB(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, pRsspStruct->pDsuRsspInfoStruWL->LocRsspiAddr); /*RSSPIַ*/ + + rtn = RsspReceive_WL(pRsspStruct); + } + + return rtn; +} + +/*********************************************************************** + * : Rssp2Output + * : ӦݽRSSPİȫ + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ + * УpRsspStruct->OutputDataQueue + * УpRsspStruct->AppArray + * pRsspStruct->VarArray + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 Rssp2Output(RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 ret = 0; + UINT16 LocalName = 0; /* ʶ */ + + if(pRsspStruct == NULL) + { + return ret; + } + else + { + /* ʲô */ + } + TypeId2DevName_WL(pRsspStruct->LocalType, pRsspStruct->LocalID, &LocalName); + + /* RSSP */ + ret = RsspOutput_WL(&pRsspStruct->OutputDataQueue, pRsspStruct->VarArray, pRsspStruct); + if(0 == ret) + { + /* ¼ */ + return ret; + } + else + { + /* ʲô */ + } + /*wangpeipei 20120223 Mod S */ + + ret = 1; + return ret; +} + +/* +*: Rssp2Init +*: RSSPIЭʼ +*: UINT8 *pFsName FSļ +*: RSSP_INFO_STRU *pRsspStruct RSSPIϢ +*: +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 Rssp2Init(UINT8* pFsName, UINT32 inParamLen, UINT8 inParam[], RSSP_INFO_STRU* pRsspStruct) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT16 locTypeId = 0; /*ID*/ + UINT16 localType = 0U; + if ((NULL != pFsName) && (NULL != pRsspStruct)) /*ǿ*/ + { + rtn = CheckRsspStruct_WL(pRsspStruct); /**/ + if (1 == rtn) + { + pRsspStruct->pDsuRsspInfoStruWL = (DSU_RSSP_INFO_STRU_WL*)malloc(sizeof(DSU_RSSP_INFO_STRU_WL)); /*ΪRSSPIϢռ*/ + if (NULL != pRsspStruct->pDsuRsspInfoStruWL) + { + CommonMemSet(pRsspStruct->pDsuRsspInfoStruWL, sizeof(DSU_RSSP_INFO_STRU_WL), 0, sizeof(DSU_RSSP_INFO_STRU_WL)); + localType = pRsspStruct->LocalType; + locTypeId = ((UINT16)(localType << 8) & 0xFF00) | (pRsspStruct->LocalID & 0x00FF); + rtn = DsuRsspInitWl(pFsName, inParamLen, inParam, locTypeId, pRsspStruct->LocalLogicId, pRsspStruct->pDsuRsspInfoStruWL); + if (1 == rtn) + { + rtn = RsspInit_WL(pRsspStruct); + } + } + } + } + + return rtn; +} + +/*********************************************************************** + * : RsrFreeSpace + * : ͨúͷRSR㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * ֵ : UINT8 0 󷵻 1 + ***********************************************************************/ +UINT8 Rssp2FreeSpace(RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 ret = 0; + + if(pRsspStruct == NULL) + { + ret=0; + } + else + { + /* RSSPռͷ */ + ret = RsspFreeSpace_WL(pRsspStruct); + + /* ռͷ */ + + /* RSSPģͷ */ + if (NULL != pRsspStruct->AppArray) + { + free(pRsspStruct->AppArray); + pRsspStruct->AppArray = NULL; + } + + /* RSRģмռͷ */ + if( NULL != pRsspStruct->VarArray) + { + free(pRsspStruct->VarArray); + pRsspStruct->VarArray = NULL; + } + else + { + /* ʲô */ + } + + /* ЭӦõݶг */ + QueueElementFree(&pRsspStruct->DataToApp); + + /* ӦøЭݶг */ + QueueElementFree(&pRsspStruct->OutputDataQueue); + + /* ܶг */ + /* */ + QueueElementFree(&pRsspStruct->OutnetQueueA); + + /* */ + QueueElementFree(&pRsspStruct->OutnetQueueB); + + /* ¼ ͷ */ + if (NULL != pRsspStruct->RecordArray) + { + free(pRsspStruct->RecordArray); + pRsspStruct->RecordArray = NULL; + } + + } + return ret; +} +/*********************************************************************** + * : Rssp2LnkStatus + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * destType UINT8 IN Ŀ + * destId UINT8 IN ĿID + * logicId UINT16 IN Ŀ߼ID + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * ֵ : UINT8 0ڸ·ش; + * 0x17·ݴ״̬DATA + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 Rssp2LnkStatus(UINT8 destType,UINT8 destId, UINT16 logicId, RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 ret = 0; + + /* ADD 20130802 */ + if(pRsspStruct == NULL) + { + ret = 0; + return ret; + } + /* RSPP · */ + ret = RsspLnkStatus_WL(destType, destId, logicId, pRsspStruct); + return ret; +} + +/*********************************************************************** + * : RsrLnkDelete + * : ͨúӦÿɾijͽڵ㡣ӦòҪijʱøúɾӦķͽڵ㡣 + * : + * + * -------------------------------------------------------------- + * destType UINT8 IN Ŀ + * destId UINT8 IN ĿID + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ + + /* + *: Rssp2LnkDelete + *: ͨԷID+Է߼IDɾ· + *: UINT8 dstType Է + * UINT8 dstId ԷID + * UINT16 dstLogicId Է߼ID + * RSSP_INFO_STRU *pRsspStruct RSSPIϢ + *: + *: + *ֵ: 1:ɹ;0;ʧ + */ +UINT8 Rssp2LnkDelete(UINT8 dstType, UINT8 dstId, UINT16 dstLogicId, RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 rtn = 0; /*ֵ*/ + UINT32 oppId = 0; /*ԷΨһID*/ + UINT16 dstName = 0U; + + if (NULL != pRsspStruct) /*ǿ*/ + { +#ifdef RSSP_NO_HLHT + TypeId2DevName_WL(dstType, dstId, &dstName); /*ȡĿRSSPIΨһID*/ + oppId = dstName; + +#else + oppId = DquToHlhtId(dstType, dstId, dstLogicId, pRsspStruct->pDsuRsspInfoStruWL); /*ȡĿRSSPIΨһID*/ +#endif + + PrintRecArrayByte(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, 0x77); + PrintRecArray4ByteB(pRsspStruct->RecordArray, pRsspStruct->RecordArraySize, oppId); + + /*ɾRSSP·*/ + rtn = RsspLnkDelete_WL(oppId, pRsspStruct); + } + + return rtn; +} + +/*********************************************************************** + * : Rssp2Refresh + * : Ӧʹøú¶ԱRSSPм¸ֵ + * : + * + * -------------------------------------------------------------- + * sLen_Input UINT16 IN мĴС + * Input_Data_LnkMes UINT8 IN м + * + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ +UINT8 Rssp2Refresh(UINT16 sLen_Input, UINT8* Input_Data_LnkMes, RSSP_INFO_STRU* pRsspStruct) +{ + UINT8 ret = 0; + + ret = RsspRefresh_WL(sLen_Input, Input_Data_LnkMes, pRsspStruct); /*sLen_Input Input_Data_LnkMes ·*/ + + return ret; +} + +/*********************************************************************** + * : CheckRsspStruct_WL + * : ͳһṹĸĿм + * : + * + * -------------------------------------------------------------- + * pRsspStruct const RSSP_INFO_STRU* IN RSSPͳһṹ + * + * ֵ : UINT8 0󷵻 1 + ***********************************************************************/ +static UINT8 CheckRsspStruct_WL(const RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 ret = 0; + + /* ͳһṹָ벻Ϊ */ + if(pRsspStruct == NULL) + { + return ret; + } + + /* Ŀ */ + if( (pRsspStruct->MaxNumLink == 0) || (pRsspStruct->MaxNumPerCycle == 0)) + { + return ret; + } + + /* Ӧ */ + if (0 == pRsspStruct->InputSize) + { + return ret; + } + + /* Ӧ */ + if (0 == pRsspStruct->OutputSize) + { + return ret; + } + + /* ں */ + if( pRsspStruct->CycleNum == NULL) + { + return ret; + } + + ret = 1; + return ret; +} + +/******************************************************************************************************* +* : RSSPЭ޷Ӧ +* : pNoSendAppData ޷ʹ +* pRsspStruct RSSPIṹ +* : +* : +* ֵ: 1:ɹ +*******************************************************************************************************/ +UINT8 SetRsspNoSendAppData(UINT8 pNoSendAppData, RSSP_INFO_STRU *pRsspStruct) +{ + UINT8 ret = 1; + pRsspStruct->NoSendAppData = pNoSendAppData; + return ret; +} + +/* +*: ȡRSSPIյ +*: RSSP_INFO_STRU* rsspi rsspi +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void RsspiGetNetsRecvPkgNum(RSSP_INFO_STRU* rsspi, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ + /*- ֲ*/ + UINT32 oppHlhtId = 0u; /*ԷͨID*/ + UINT8 isGet = 0u; /*Ƿȡ*/ + UINT16 locAddr = 0u; /*ַ*/ + UINT16 oppAddr = 0u; /*Էַ*/ + UINT16 dstName = 0u; /*ԷΨһID*/ + + if ((NULL != rsspi) && (NULL != rsspi->NetsRecvPkgNums) && (NULL != rsspi->pDsuRsspInfoStruWL) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum)) /*-< Ƿǿ*/ + { +#ifdef RSSP_NO_HLHT + TypeId2DevName_WL(dstType, dstId, &dstName); /*-< ȡĿRSSPIΨһID*/ + oppHlhtId = dstName;/*-< ĿRSSPIΨһID*/ +#else + oppHlhtId = DquToHlhtId(dstType, dstId, dstLogicId, rsspi->pDsuRsspInfoStruWL); /*-< ĿRSSPIΨһID*/ +#endif + isGet = dsuRsspRGetAddrWl(oppHlhtId, rsspi->pDsuRsspInfoStruWL->LocEmitterName, &locAddr, &oppAddr, rsspi->pDsuRsspInfoStruWL); /*-< ûȡַ*/ + if (1u == isGet) /*-< úǷɹ*/ + { + GetNetsRecvPkgNum_WL(rsspi, oppAddr, redRecvPkgNum, blueRecvPkgNum); /*-< ûȡRSSPIյ*/ + } + } +} + +/* +*: RsspiGetSwapData +*: ȡ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽSVC]) +* const UINT16 swapDataMaxLen 󳤶 +* RSSP_INFO_STRU* rsspi SFPṹ +*: +*: +*ֵ: +*/ +void RsspiGetSwapData(UINT8 swapData[], const UINT16 swapDataMaxLen, RSSP_INFO_STRU* rsspi) +{ + UINT16 swapDataLen = 0u; /*λ*/ + UINT32 allLen = 0u; /*ܳ*/ + UINT8* outAppData = NULL; /*Ӧ*/ + UINT32 outAppIdx = 0u; /*Ӧλ*/ + UINT16 pkgLen = 0u; /**/ + UINT16 svcPos = 0u; /*SVCappArrayλ*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT8* record = NULL; /*־*/ + UINT16 recordSize = 0u; /*־鳤*/ + + if ((NULL != swapData) && (NULL != rsspi) && (2u < swapDataMaxLen)) /*ǿռ*/ + { + record = rsspi->RecordArray; + recordSize = rsspi->RecordArraySize; + PrintRecArrayByte(record, recordSize, GET_SVC); + + ShortToChar(0u, &swapData[0]); /**/ + swapDataLen += 2u; + +#ifdef DOUBLE_CPU_INTERACTIVE_SVC + /*AppArrayʽ:4ֽܳ+N[2ֽڳ+1ֽЭ+2ֽĿĵַ+2ֽԤ+]*/ + allLen = LongFromChar(&rsspi->AppArray[0]); + if (0u < allLen) /**/ + { + outAppData = &rsspi->AppArray[4]; /*Ӧݿʼַ*/ + while (outAppIdx < allLen) /*Ӧ*/ + { + pkgLen = 2u + ShortFromChar(&outAppData[outAppIdx]); + if ((outAppIdx + pkgLen) <= allLen) /*ǰӦλüӳСڵӦó,Ϸ*/ + { + if ((swapDataLen + 4u) <= swapDataMaxLen) /*пռ*/ + { + if ((RSSP_RSD_MSG_WL == outAppData[outAppIdx + 8u]) && (pkgLen >= 7u + RSSP_FIXED_LEN_WL))/*RSD֡*/ + { + svcPos = (0u == rsspi->cpuId) ? 19u : 23u; /*ǰCPU0,SVC±19,23*/ + } + else if ((RSSP_SSE_MSG_WL == outAppData[outAppIdx + 8u]) && ((7u + RSSP_SSE_LEN_WL) == pkgLen)) /*SSE֡*/ + { + svcPos = (0u == rsspi->cpuId) ? 17u : 21u; /*ǰCPU0,SVC±17,21*/ + } + else if ((RSSP_SSR_MSG_WL == outAppData[outAppIdx + 8u]) && ((7u + RSSP_SSR_LEN_WL) == pkgLen)) /*SSR֡*/ + { + svcPos = (0u == rsspi->cpuId) ? 21u : 25u; /*ǰCPU0,SVC±21,25*/ + } + else /*֡*/ + { + PrintRecArrayByte(record, recordSize, FRAME_TYPE_ERR); + PrintRecArrayByte(record, recordSize, outAppData[outAppIdx + 8u]); + isBreak = 1u; + } + if (0u == isBreak) /*֡*/ + { + CommonMemCpy(&swapData[swapDataLen], (UINT32)4u, &outAppData[outAppIdx + svcPos], 4u); /*SVC*/ + swapDataLen += 4u; /*ۼӽݳ*/ + outAppIdx += pkgLen; /*ƫ±*/ + } + } + else /*޿ռ*/ + { + PrintRecArrayByte(record, recordSize, 4u); + PrintRecArray2ByteB(record, recordSize, swapDataLen); + PrintRecArray2ByteB(record, recordSize, swapDataMaxLen); + + isBreak = 1u; + } + } + else /*ȷǷ*/ + { + PrintRecArrayByte(record, recordSize, PKG_LEN_ERR); + PrintRecArray2ByteB(record, recordSize, pkgLen); + PrintRecArray4ByteB(record, recordSize, outAppIdx); + PrintRecArray4ByteB(record, recordSize, allLen); + + isBreak = 1u; + } + if (1u == isBreak) /*˳*/ + { + break; + } + } + if (0u == isBreak) /**/ + { + ShortToChar(swapDataLen - 2u, &swapData[0]); /*ó*/ + } + } + else + { + PrintRecArrayByte(record, recordSize, NO_OUT_APP); + PrintRecArrayByte(record, recordSize, 0u); + } +#endif + } +} + +/* +*: RsspiSetSwapData +*: ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽSVC]) +* RSSP_INFO_STRU* rsspi SFPṹ +*: +*: +*ֵ: +*/ +void RsspiSetSwapData(UINT8 swapData[], RSSP_INFO_STRU* rsspi) +{ + /*PrtclSndBuffʽ:4ֽܳ+N[2ֽڳ+1ֽЭ+2ֽĿĵַ+2ֽԤ+]*/ + RsspiSetSwapDataForOut(swapData, &rsspi->AppArray[4], rsspi); +} + +/* +*: RsspiSetSwapDataForOut +*: ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽSVC]) +* UINT8 outData[] ָ +* RSSP_INFO_STRU* rsspi SFPṹ +*: +*: +*ֵ: +*/ +void RsspiSetSwapDataForOut(UINT8 swapData[], UINT8 outData[], RSSP_INFO_STRU* rsspi) +{ + UINT16 swapDataLen = 0u; /*CRC*/ + UINT32 allLen = 0u; /*ܳ*/ + UINT8 dstNum = 0u; /*ĿĵַCRC*/ + UINT8 i = 0u; /*ѭ*/ + UINT32 outAppIdx = 0u; /*Ӧλ*/ + UINT8* outAppData = NULL; /*Ӧ*/ + UINT16 pkgLen = 0u; /**/ + UINT16 svcPos = 0u; /*SVCappArrayλ*/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT16 crc16 = 0u; /*CRC16ֵ*/ + UINT8* record = NULL; /*־*/ + UINT16 recordSize = 0u; /*־鳤*/ + + if ((NULL != swapData) && (NULL != outData) && (NULL != rsspi)) /**/ + { + record = rsspi->RecordArray; + recordSize = rsspi->RecordArraySize; + PrintRecArrayByte(record, recordSize, SET_SVC); + +#ifdef DOUBLE_CPU_INTERACTIVE_SVC + swapDataLen = ShortFromChar(&swapData[0]); + if ((0u < swapDataLen) && (0u == (swapDataLen % 4u))) /*ȺϷ*/ + { + /*PrtclSndBuffʽ:4ֽܳ+N[2ֽڳ+1ֽЭ+2ֽĿĵַ+2ֽԤ+]*/ + allLen = LongFromChar(&rsspi->AppArray[0]); + if (0u < allLen) /**/ + { + outAppData = &outData[0]; + dstNum = swapDataLen / 4u; + for (i = 0u; i < dstNum; i++) + { + pkgLen = 2u + ShortFromChar(&outAppData[outAppIdx]); + if ((outAppIdx + pkgLen) <= allLen) /*ȴڵ(7ֽͷ+23ֽ֡ʽ),ҵǰӦλüӳСڵӦó,Ϸ*/ + { + if ((RSSP_RSD_MSG_WL == outAppData[outAppIdx + 8u]) && (pkgLen >= 7u + RSSP_FIXED_LEN_WL))/*RSD֡*/ + { + svcPos = (0u == rsspi->cpuId) ? 23u : 19u; /*ǰCPU0,SVC±23,19*/ + } + else if ((RSSP_SSE_MSG_WL == outAppData[outAppIdx + 8u]) && ((7u + RSSP_SSE_LEN_WL) == pkgLen)) /*SSE֡*/ + { + svcPos = (0u == rsspi->cpuId) ? 21u : 17u; /*ǰCPU0,SVC±21,17*/ + } + else if ((RSSP_SSR_MSG_WL == outAppData[outAppIdx + 8u]) && ((7u + RSSP_SSR_LEN_WL) == pkgLen)) /*SSR֡*/ + { + svcPos = (0u == rsspi->cpuId) ? 25u : 21u; /*ǰCPU0,SVC±25,21*/ + } + else /*֡*/ + { + PrintRecArrayByte(record, recordSize, FRAME_TYPE_ERR); + PrintRecArrayByte(record, recordSize, outAppData[outAppIdx + 8u]); + + isBreak = 1u; + } + + if (0u == isBreak) /*֡*/ + { + CommonMemCpy(&outAppData[outAppIdx + svcPos], (UINT32)4u, &swapData[2u + 4u * i], (UINT32)4u); /*SVC*/ + + /*¼CRC16outAppData*/ + crc16 = ComputeMsgCRC16_WL(&outAppData[outAppIdx + 7u], pkgLen - 9u); + ShortToCharLE(crc16, &outAppData[outAppIdx + pkgLen - 2u]); + } + + outAppIdx += pkgLen; + } + else /*ȷǷ*/ + { + PrintRecArrayByte(record, recordSize, PKG_LEN_ERR); + PrintRecArray2ByteB(record, recordSize, pkgLen); + PrintRecArray4ByteB(record, recordSize, outAppIdx); + PrintRecArray4ByteB(record, recordSize, allLen); + + isBreak = 1u; + } + if (1u == isBreak) /*˳*/ + { + break; + } + } + } + else + { + PrintRecArrayByte(record, recordSize, NO_OUT_APP); + PrintRecArrayByte(record, recordSize, 0u); + } + } + else + { + PrintRecArrayByte(record, recordSize, SET_SVC_DATA_ERR); + PrintRecArray2ByteB(record, recordSize, swapDataLen); + } +#endif + } +} + +/* +*: RsspiDelAllLink +*: RSSPIɾ· +*: RSSP_INFO_STRU* rsspi RSSPIṹ +*: +*: +*ֵ: +*/ +void RsspiDelAllLink(RSSP_INFO_STRU* rsspi) +{ + UINT8 i = 0u; /*ѭ*/ + + if ((NULL != rsspi) && (NULL != rsspi->LnkNodeArr)) /**/ + { + for (i = 0; i < rsspi->LnkNodeNum; i++) /*·*/ + { + RsspMemSet_WL((UINT8*)&rsspi->LnkNodeArr[i], sizeof(Lnk_Info_Node_Stru_WL), 0u); /*·Ϣ*/ + rsspi->LnkNodeArr[i].NodeStatus = Replace_WL; /*ڵ״̬ÿɸ*/ + } + + if (NULL != rsspi->RecordArray) /*¼־*/ + { + PrintRecArray2ByteB(rsspi->RecordArray, rsspi->RecordArraySize, (UINT16)0xF0F0u); + } + } +} + +/*-------------------------------------------------------------------- + * RSSPⲿʹú End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspWl.h b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspWl.h new file mode 100644 index 0000000..9cd5077 --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp/RsspWl.h @@ -0,0 +1,202 @@ +/******************************************************** +* +* ļ RsspWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2009.10.25 +* ؼЭ鲿 +* RsrЭʵ +* ʹע⣺ +* +* ޸ļ¼ +* +********************************************************/ + +#ifndef _RSSPWL_H_ +#define _RSSPWL_H_ + +#include "CommonTypes.h" +#include "CommonQueue.h" +#include "RsspStructWl.h" +#include "RsspCommonWl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*-------------------------------------------------------------------- + * RSSPӿں Start + *--------------------------------------------------------------------*/ +/*********************************************************************** + * : Rssp2Receive + * : ԺݽRSSPİȫȫݽӦá + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ + * УpRsspStruct->OutnetQueueA + * pRsspStruct->OutnetQueueB + * УpRsspStruct->DataToApp + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 Rssp2Receive(RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : Rssp2Output + * : ӦݽRSSPİȫ + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ + * УpRsspStruct->OutputDataQueue + * УpRsspStruct->AppArray + * pRsspStruct->VarArray + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 Rssp2Output(RSSP_INFO_STRU *pRsspStruct); + +/* +*: Rssp2Init +*: RSSPIЭʼ +*: UINT8 *pFsName FSļ +*: RSSP_INFO_STRU *pRsspStruct RSSPIϢ +*: +*ֵ: 1:ɹ;0ʧ +*/ +UINT8 Rssp2Init(UINT8 *pFsName, UINT32 inParamLen, UINT8 inParam[], RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : Rssp2FreeSpace + * : ͨúͷRSSP㿪ٵĿռ䡣 + * : + * + * -------------------------------------------------------------- + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 Rssp2FreeSpace(RSSP_INFO_STRU *pRsspStruct); + + +/*********************************************************************** + * : Rssp2LnkStatus + * : õijȫܽڵڱڵͨ״̬ + * ijȫܽڵ㣬򷵻ظðȫڵͨ״̬ + * ijȫսڵ㣬򷵻ش + * : + * + * ------------------------------------------------------------- + * destType UINT8 IN Ŀ + * destId UINT8 IN ĿID + * logicId UINT16 IN Ŀ߼ID + * pRsspStruct RSSP_INFO_STRU* INOUT RSSPͳһṹ壬гʼֵá + * ֵ : UINT8 0ڸ·ش + * 0x17·ݴ״̬DATA + * 0x2b·޷״̬HALT + ***********************************************************************/ +UINT8 Rssp2LnkStatus(UINT8 destType, UINT8 destId, UINT16 logicId, RSSP_INFO_STRU *pRsspStruct); + +/* + *: Rssp2LnkDelete + *: ͨԷID+Է߼IDɾ· + *: UINT8 dstType Է + * UINT8 dstId ԷID + * UINT16 dstLogicId Է߼ID + * RSSP_INFO_STRU *pRsspStruct RSSPIϢ + *: + *: + *ֵ: 1:ɹ;0;ʧ + */ +UINT8 Rssp2LnkDelete(UINT8 dstType, UINT8 dstId, UINT16 dstLogicId, RSSP_INFO_STRU *pRsspStruct); + +/*********************************************************************** + * : Rssp2Refresh + * : Ӧʹøú¶ԱRSSPм¸ֵ + * : + * + * -------------------------------------------------------------- + * sLen_Input UINT16 IN мĴС + * Input_Data_LnkMes UINT8* IN м + * + * ֵ : UINT8 1 0󷵻 + ***********************************************************************/ +UINT8 Rssp2Refresh(UINT16 sLen_Input, UINT8* Input_Data_LnkMes,RSSP_INFO_STRU *pRsspStruct); + +/******************************************************************************************************* +* : RSSPЭ޷Ӧ +* : pNoSendAppData ޷ʹ +* pRsspStruct RSSPIṹ +* : +* : +* ֵ: 1:ɹ +*******************************************************************************************************/ +UINT8 SetRsspNoSendAppData(UINT8 pNoSendAppData, RSSP_INFO_STRU *pRsspStruct); + +/* +*: ȡRSSPIյ +*: RSSP_INFO_STRU* rsspi rsspi +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +* const UINT16 dstLogicId Ŀ߼ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void RsspiGetNetsRecvPkgNum(RSSP_INFO_STRU* rsspi, const UINT8 dstType, const UINT8 dstId, const UINT16 dstLogicId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); + +/* +*: RsspiGetSwapData +*: ȡ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽSVC]) +* const UINT16 swapDataMaxLen 󳤶 +* RSSP_INFO_STRU* rsspi SFPṹ +*: +*: +*ֵ: +*/ +void RsspiGetSwapData(UINT8 swapData[], const UINT16 swapDataMaxLen, RSSP_INFO_STRU* rsspi); + +/* +*: RsspiSetSwapData +*: ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽSVC]) +* RSSP_INFO_STRU* rsspi SFPṹ +*: +*: +*ֵ: +*/ +void RsspiSetSwapData(UINT8 swapData[], RSSP_INFO_STRU* rsspi); + +/* +*: RsspiSetSwapDataForOut +*: ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽSVC]) +* UINT8 outData[] ָ +* RSSP_INFO_STRU* rsspi SFPṹ +*: +*: +*ֵ: +*/ +void RsspiSetSwapDataForOut(UINT8 swapData[], UINT8 outData[], RSSP_INFO_STRU* rsspi); + +/* +*: RsspiDelAllLink +*: RSSPIɾ· +*: RSSP_INFO_STRU* rsspi RSSPIṹ +*: +*: +*ֵ: +*/ +void RsspiDelAllLink(RSSP_INFO_STRU* rsspi); + +/*-------------------------------------------------------------------- + * RSSPӿں End + *--------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/TSCP/src/protocol/rssp_record_cbtc1/common_rssp_record_config/RsspConfigWl.h b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp_record_config/RsspConfigWl.h new file mode 100644 index 0000000..ac6feab --- /dev/null +++ b/TSCP/src/protocol/rssp_record_cbtc1/common_rssp_record_config/RsspConfigWl.h @@ -0,0 +1,26 @@ +/******************************************************** +* +* ļ RsspConfigWl.h +* Ȩ˵ ʱƼι˾ +* 汾 1.0 +* ʱ䣺 2010.05.10 +* ؼЭ鲿 +* Rsrļ : RSSP¼ +* ʹע⣺ +* +* ޸ļ¼ +* +********************************************************/ +#ifndef _RSSP_CONFIG_WL_H_ +#define _RSSP_CONFIG_WL_H_ + +#define VOBC_ATS_CYCLENUM_MULTIPLE 5 /*VOBCATSںű*/ +#define AOM_ATS_CYCLENUM_MULTIPLE 5 /*AOMATSںű*/ + +/* ¼뿪 */ +/* #define RSSP_RECORD_ERR_ASCII */ /* ַʽ¼ */ + + #define RSSP_RECORD_SIMPLIFY_BIN /* ԶƷʽ¼ */ + +#endif + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_dqu_sfp/dsuRelatedDeal.c b/TSCP/src/protocol/sfp_record_cbtc1/common_dqu_sfp/dsuRelatedDeal.c new file mode 100644 index 0000000..d31a848 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_dqu_sfp/dsuRelatedDeal.c @@ -0,0 +1,1158 @@ + +/************************************************************************ +* ļDSURelatedDeal.c +* ļCBTCϵͳDSUЭشĺ +Ҫڴ洢жܹԼ彨ϸϢĺ +* ʱ䣺2009.01.17 +* ļ +1.ӦṩݿеϢ +2.жϸ豸·ϵǷϷҲܷ +3.ݸıͶԷĶõľϢ +4.ZCѯҪһ豸Һͬ͵ͨŹϵ豸Ϊ𷽵· +5.ṩType+ID豸ıȽϺ +* +************************************************************************/ +#include "CommonMemory.h" +#include "dfsDataRead.h" +#include "dsuRelatedDeal.h" /*ļ.hļ*/ +#include "dquDataTypeDefine.h" + +#define DSU_OBJ_INFO_LENGTH 14 /*DSUͨŶϢȣλֽڣ*/ +#define DSU_DIFF_RELATION_LENGTH 15 /*DSUͬ豸ͨŹϵ¼ȣλֽڣ*/ +#define DSU_SAME_RELATION_LENGTH 17 /*DSUͬ豸ͨŹϵ¼ȣλֽڣ*/ + +/*ṹڲܺ*/ +#define DSU_IP_INFO_STRU_SIZE 22 + +#define DSU_OBJ_TYPE_SUBINDEX 0 /*DSUͨŶ*/ +#define DSU_OBJ_ID_SUBINDEX 1 /*DSUͨŶID*/ +#define DSU_OBJ_BLUEIP_SUBINDEX 2 /*DSUͨŶIP*/ +#define DSU_OBJ_BLUEPORT_SUBINDEX 6 /*DSUͨŶ˿*/ +#define DSU_OBJ_REDIP_SUBINDEX 8 /*DSUͨŶIP*/ +#define DSU_OBJ_REDPORT_SUBINDEX 12 /*DSUͨŶ˿*/ + + +#define DSU_DIFF_SPON_TYPE_SUBINDEX 0 /*DSUͬ豸ͨŹϵ*/ +#define DSU_DIFF_SPON_COMTYPE_SUBINDEX 1 /*DSUͬ豸ͨŹϵͨ*/ +#define DSU_DIFF_SPON_CYCLE_SUBINDEX 2 /*DSUͬ豸ͨŹϵ*/ +#define DSU_DIFF_SPON_MSG_MAXDELAY_SUBINDEX 4 /*DSUͬ豸ͨŹϵʱ*/ +#define DSU_DIFF_SPON_ACK_MAXDELAY_SUBINDEX 6 /*DSUͬ豸ͨŹϵ𷽽ACKʱ*/ +#define DSU_DIFF_FOLL_TYPE_SUBINDEX 8 /*DSUͬ豸ͨŹϵ淽*/ +#define DSU_DIFF_FOLL_COMTYPE_SUBINDEX 9 /*DSUͬ豸ͨŹϵ淽ͨ*/ +#define DSU_DIFF_FOLL_CYCLE_SUBINDEX 10 /*DSUͬ豸ͨŹϵ淽*/ +#define DSU_DIFF_FOLL_MSG_MAXDELAY_SUBINDEX 12 /*DSUͬ豸ͨŹϵ淽ʱ*/ +#define DSU_DIFF_SENDMSG_MINDELAY_SUBINDEX 14 /*DSUͨŹϵгɹһС*/ + +#define DSU_SAME_SPON_TYPE_SUBINDEX 0 /*DSUͬ豸ͨŹϵ*/ +#define DSU_SAME_SPON_ID_SUBINDEX 1 /*DSUͬ豸ͨŹϵID*/ +#define DSU_SAME_SPON_COMTYPE_SUBINDEX 2 /*DSUͬ豸ͨŹϵͨ*/ +#define DSU_SAME_SPON_CYCLE_SUBINDEX 3 /*DSUͬ豸ͨŹϵ*/ +#define DSU_SAME_SPON_MSG_MAXDELAY_SUBINDEX 5 /*DSUͬ豸ͨŹϵʱ*/ +#define DSU_SAME_SPON_ACK_MAXDELAY_SUBINDEX 7 /*DSUͬ豸ͨŹϵ𷽽ACKʱ*/ +#define DSU_SAME_FOLL_TYPE_SUBINDEX 9 /*DSUͬ豸ͨŹϵ淽*/ +#define DSU_SAME_FOLL_ID_SUBINDEX 10 /*DSUͬ豸ͨŹϵ淽ID*/ +#define DSU_SAME_FOLL_COMTYPE_SUBINDEX 11 /*DSUͬ豸ͨŹϵ淽ͨ*/ +#define DSU_SAME_FOLL_CYCLE_SUBINDEX 12 /*DSUͬ豸ͨŹϵ淽*/ +#define DSU_SAME_FOLL_MSG_MAXDELAY_SUBINDEX 14 /*DSUͬ豸ͨŹϵ淽ʱ*/ +#define DSU_SAME_SENDMSG_MINDELAY_SUBINDEX 16 /*DSUͨŹϵгɹһС*/ + + +#define DSU_DATA_PROTCL_DIFF_RELATION 0x04 /*DSUͬ豸ͨŹϵtableId*/ +#define DSU_DATA_PROTCL_SAME_RELATION 0x05 /*DSUͬ豸ͨŹϵtableId*/ + + +/*FSsheetҳϢ*/ +typedef struct +{ + UINT32 Id; /**/ + UINT32 Len; /**/ + UINT16 RowCount; /**/ + UINT32 ColLen; /*ֽڳ*/ + UINT8* Data; /**/ +} SheetInfo; + +static void InitSheet(SheetInfo* sheetInfo, UINT8 data[], const UINT32 dataLen, const UINT32 excelId, const UINT32 sheetId); +static void MergeParam(SheetInfo* sheetInfo, UINT8 outData[], UINT32* outDataIdx, UINT16 outDataLen, UINT8 mergeData[], UINT32* mergeDataIdx); + +/*************************************************************************************************************** +豸TYPE豸IDתlong͵豸 +˵ +[in]UINT8 devType 豸 +[in]UINT8 devID 豸ID +ֵunsigned INT32 ͵豸 +豸TYPE豸IDתlong͵豸 +***************************************************************************************************************/ +static UINT32 dsuTypeIdToName(UINT8 devType,UINT8 devID) +{ + UINT32 Templong; + Templong = 0; + Templong = devType; + Templong = (Templong*0x100) + devID; + Templong = Templong*0x10000 ; + return Templong; +} + +/* +:ж豸ܷԷ豸DSUͨŶУҪȥҶԷ豸ͬ豸ϵͬ豸ϵ add by lcj) +˵: +[in]struc_Unify_Info * LocalInfo󱾵Ϣͳһṹ +[in]UINT32 DestDevNameԷ豸Name +[out]UINT8* role ɫ +ֵ:ܹ1,򷵻0 +*/ +UINT8 dsuIsLnkLegal(struc_Unify_Info * LocalInfo, UINT32 DestDevName,UINT8* role) +{ + register UINT32 lTemp; /*ʱlongͱ*/ + register UINT8 * data; /*ݿַʱ*/ + + UINT32 i; + UINT8 ret = 0; + + /*UINT16 nObjNumber;*/ /*ͨŶ*/ + UINT16 nDiffRelation; /*ͬͨͨŹϵ*/ + UINT16 nSameRelation; /*ͬͨͨŹϵ*/ + UINT32 lSameRelationIndex; /*ͬͨͨŹϵʼ*/ + UINT32 lDiffRelationIndex; /*ͬͨͨŹϵʼ*/ + UINT32 lDevName; /*ͨŶʱ*/ + UINT32 lDevName2; /*ͨŶʱ*/ + UINT32 lLocalDevName; /*ʱ*/ + UINT32 lDestDevType; /*Է豸ʱ*/ + + if(dsuDataCheck((UINT8 *) LocalInfo->DataBase) == 1) + { + data = (UINT8 *) LocalInfo->DataBase; + + lTemp=0; +#ifdef SFP_CKECK_DSU_IP + /*õDSUͨŶ*/ + nObjNumber = ShortFromChar(&data[lTemp]); + lTemp+=2; + + /*õDSUвͬͨŹϵ*/ + lTemp +=nObjNumber* DSU_OBJ_INFO_LENGTH; +#endif + /*õDSUвͬͨŹϵ*/ + nDiffRelation = ShortFromChar(&data[lTemp]); + lTemp+=2; + lDiffRelationIndex = lTemp; + + /*õDSUͬͨŹϵ*/ + lTemp = lTemp+nDiffRelation * DSU_DIFF_RELATION_LENGTH; + + /*õDSUͬͨŹϵ*/ + nSameRelation = ShortFromChar(&data[lTemp]); + lTemp+=2; + lSameRelationIndex = lTemp; +#ifdef SFP_CKECK_DSU_IP + /*жϱ豸Ϸ*/ + lLocalDevName = dsuTypeIdToName(LocalInfo->LocalType,LocalInfo->LocalID); + lTemp=dsuIsDevExist(LocalInfo,lLocalDevName); + if (lTemp == 0) + { + /*豸Ϸ*/ + ret = 0; + return ret; + } + + + lTemp=dsuIsDevExist(LocalInfo,DestDevName);/* ͨŶʼַ */ + + if(lTemp!=0) + + { + #endif + /*Ŀ豸Ϸ*/ + + /*ͬͨŶϵ*/ + if(LocalInfo->LocalType == ((DestDevName>>24) & 0xFF)) + { + lTemp = lSameRelationIndex; + lLocalDevName = ((UINT32) LocalInfo->LocalType << 24) + ((UINT32) LocalInfo->LocalID<<16); + for(i = 0; i < nSameRelation; i++) + { + /*÷豸*/ + lDevName = ((UINT32) data[lTemp]<<24) + ((UINT32) data[lTemp + 1] << 16); + /*ø淽豸*/ + lDevName2 = ((UINT32) data[lTemp + DSU_SAME_FOLL_TYPE_SUBINDEX] << 24) + + ((UINT32) data[lTemp + DSU_SAME_FOLL_ID_SUBINDEX] << 16); + /*Ϊ𷽣ԷΪ淽*/ + if((lLocalDevName == lDevName )&& (DestDevName == lDevName2)) + { + (*role) = DSU_ROLE_SPON; + ret = 1; + return ret; + } + /*Ϊ淽ԷΪ*/ + else if((lLocalDevName == lDevName2) && (DestDevName == lDevName)) + { + (*role) = DSU_ROLE_FLW; + ret = 1; + return ret; + } + else + { + lTemp = lTemp + DSU_SAME_RELATION_LENGTH; + } + + } + } + else /*鲻ͬͨŶϵ*/ + { + lTemp = lDiffRelationIndex; + lLocalDevName = LocalInfo->LocalType; + lDestDevType = (DestDevName>>24) & 0xff; + for(i = 0; i < nDiffRelation; i++) + { + /*÷豸豸*/ + lDevName = data[lTemp]; + /*ø淽豸豸*/ + lDevName2 = data[lTemp + DSU_DIFF_FOLL_TYPE_SUBINDEX]; + + if((lLocalDevName == lDevName) && (lDestDevType == lDevName2)) + { + (*role) = DSU_ROLE_SPON; + ret = 1; + return ret; + } + else if((lLocalDevName == lDevName2) && (lDestDevType == lDevName)) + { + (*role) = DSU_ROLE_FLW; + ret = 1; + return ret; + } + else + { + lTemp = lTemp + DSU_DIFF_RELATION_LENGTH; + } + } + } + ret = 0; + return ret; +#ifdef SFP_CKECK_DSU_IP + } + else + { + ret = 0; + return ret; + } +#endif + } + else + { + ret = 0; + return ret; + } +} + + +/* +* :ȡlnkϢ +* ˵: +* [in]UINT32 DestDevName 豸+id +* [in]struc_Unify_Info * LocalInfo 󱾵Ϣͳһṹ +* ʹõȫֱ +* ֵ:ַ1򷵻0 +*/ +UINT8 dsuGetLnkInfo(struc_Unify_Info* LocalInfo, UINT32 DestDevName, struc_LnkBasicInfo* lnk_basic_info ) +{ + register UINT32 lTemp; /*ʱlongͱ*/ + register UINT8 * data; /*ݿַʱ*/ + + UINT16 i; + /*UINT16 nObjNumber;*/ /*ͨŶ*/ + UINT16 nDiffRelation; /*ͬͨͨŹϵ*/ + UINT16 nSameRelation; /*ͬͨͨŹϵ*/ + UINT32 lSameRelationIndex; /*ͬͨͨŹϵʼ*/ + UINT32 lDiffRelationIndex; /*ͬͨͨŹϵʼ*/ + UINT32 lDestDevType; /*Է豸ʱ*/ + UINT32 lLocalDevName; /*ʱ*/ + UINT32 lDevName; + UINT32 lDevName2; + UINT8 ret; +#ifdef SFP_CKECK_DSU_IP + /*жϱ豸Ϸ*/ + lLocalDevName = dsuTypeIdToName(LocalInfo->LocalType,LocalInfo->LocalID); + + lTemp=dsuIsDevExist(LocalInfo,lLocalDevName); + if (lTemp == 0) + { + /*豸Ϸ*/ + ret = 0; + return ret; + } +#endif + lLocalDevName = dsuTypeIdToName(LocalInfo->LocalType,LocalInfo->LocalID); +#ifdef SFP_CKECK_DSU_IP + /*ж豸ǷDSUݱдڣڣ򷵻豸ϢĵһֽDSUеλ*/ + if(dsuIsDevExist(LocalInfo , DestDevName) != 0) + { +#endif + data = (UINT8 *) LocalInfo->DataBase; + lTemp=0; +#ifdef SFP_CKECK_DSU_IP + /*õDSUͨŶ*/ + nObjNumber = ShortFromChar(&data[lTemp]); + lTemp+=2; + + /*õDSUвͬͨŹϵ*/ + lTemp = lTemp + nObjNumber* DSU_OBJ_INFO_LENGTH; +#endif + /*õDSUвͬͨŹϵ*/ + nDiffRelation = ShortFromChar(&data[lTemp]); + lTemp+=2; + lDiffRelationIndex = lTemp; + + /*õDSUͬͨŹϵ*/ + lTemp = lTemp + nDiffRelation * DSU_DIFF_RELATION_LENGTH; + + /*õDSUͬͨŹϵ*/ + nSameRelation = ShortFromChar(&data[lTemp]); + lTemp+=2; + lSameRelationIndex = lTemp; + + if(LocalInfo->LocalType == ((DestDevName>>24) & 0xFF))/* ͬ豸 */ + { + lTemp = lSameRelationIndex; + lLocalDevName = ((UINT32) LocalInfo->LocalType << 24) + ((UINT32) LocalInfo->LocalID<<16); + for(i = 0; i < nSameRelation; i++) + { + /*÷豸*/ + lDevName = ((UINT32) data[lTemp]<<24) + ((UINT32) data[lTemp + 1] << 16); + /*ø淽豸*/ + lDevName2 = ((UINT32) data[lTemp + DSU_SAME_FOLL_TYPE_SUBINDEX]<<24) + + ((UINT32) data[lTemp + DSU_SAME_FOLL_ID_SUBINDEX] << 16); + + if((lLocalDevName == lDevName )&& (DestDevName == lDevName2)) + { + lnk_basic_info->Role = DSU_ROLE_SPON; /*ɫ*/ + /*ͨŹϵϷ*/ + lnk_basic_info->NCyclesPerPack = data[lTemp + DSU_SAME_SENDMSG_MINDELAY_SUBINDEX]; + /* 𷽷ͨͣҲǸ淽ݵͨͣ*/ + lnk_basic_info->LocalCommType = data[lTemp + DSU_SAME_SPON_COMTYPE_SUBINDEX]; + /*ķ*/ + lnk_basic_info->LocalCycle = ShortFromChar(&data[lTemp + DSU_SAME_SPON_CYCLE_SUBINDEX]); + /*ʱ*/ + lnk_basic_info->LocalMaxDelay = ShortFromChar(&data[lTemp + DSU_SAME_SPON_MSG_MAXDELAY_SUBINDEX]); + /*Ҫ֪Ackʱ*/ + lnk_basic_info->AckMaxDelay = ShortFromChar(&data[lTemp + DSU_SAME_SPON_ACK_MAXDELAY_SUBINDEX]); + /*Էķ*/ + lnk_basic_info->DestCycle = ShortFromChar(&data[lTemp + DSU_SAME_FOLL_CYCLE_SUBINDEX]); + /*Էʱ*/ + lnk_basic_info->DestMaxDelay = ShortFromChar(&data[lTemp + DSU_SAME_FOLL_MSG_MAXDELAY_SUBINDEX]); + /* 淽ͨͣҲǷ𷽽ݵͨͣ*/ + lnk_basic_info->DestCommType = data[lTemp + DSU_SAME_FOLL_COMTYPE_SUBINDEX]; +#ifdef SFP_CKECK_DSU_IP + /*дϢ*/ + dsuFillLnkCommConfig(LocalInfo, DestDevName,lnk_basic_info); +#endif + ret = 1; + return ret; + + } + else if((lLocalDevName == lDevName2) && (DestDevName == lDevName)) + { + lnk_basic_info->Role = DSU_ROLE_FLW; /*ɫ*/ + /*ͨŹϵϷ*/ + lnk_basic_info->NCyclesPerPack = data[lTemp + DSU_SAME_SENDMSG_MINDELAY_SUBINDEX]; + /* 𷽷ͨͣҲǸ淽ݵͨͣ*/ + lnk_basic_info->LocalCommType = data[lTemp + DSU_SAME_FOLL_COMTYPE_SUBINDEX]; + /*ķ*/ + lnk_basic_info->LocalCycle = ShortFromChar(&data[lTemp + DSU_SAME_FOLL_CYCLE_SUBINDEX]); + /*ʱ*/ + lnk_basic_info->LocalMaxDelay = ShortFromChar(&data[lTemp + DSU_SAME_FOLL_MSG_MAXDELAY_SUBINDEX]); + /*Էķ*/ + lnk_basic_info->DestCycle = ShortFromChar(&data[lTemp + DSU_SAME_SPON_CYCLE_SUBINDEX]); + /*Էʱ*/ + lnk_basic_info->DestMaxDelay = ShortFromChar(&data[lTemp + DSU_SAME_SPON_MSG_MAXDELAY_SUBINDEX]); + /* 淽ͨͣҲǷ𷽽ݵͨͣ*/ + lnk_basic_info->DestCommType = data[lTemp + DSU_SAME_SPON_COMTYPE_SUBINDEX]; + + #ifdef SFP_CKECK_DSU_IP + /*дϢ*/ + dsuFillLnkCommConfig(LocalInfo, DestDevName,lnk_basic_info); + #endif + ret = 1; + return ret; + } + else + { + lTemp = lTemp + DSU_SAME_RELATION_LENGTH; + } + } + } + else + { + lTemp = lDiffRelationIndex; + lLocalDevName = LocalInfo->LocalType; + lDestDevType = ((DestDevName>>24) & 0xff); + for(i = 0; i < nDiffRelation; i++) + { + /*÷豸*/ + lDevName = data[lTemp]; + /*ø淽豸*/ + lDevName2 = data[lTemp + DSU_DIFF_FOLL_TYPE_SUBINDEX]; + if((lLocalDevName == lDevName) && (lDestDevType == lDevName2)) + { + lnk_basic_info->Role = DSU_ROLE_SPON; /*ɫ*/ + lnk_basic_info->NCyclesPerPack = data[lTemp + DSU_DIFF_SENDMSG_MINDELAY_SUBINDEX];/*ͨŹϵϷ*/ + lnk_basic_info->LocalCommType = data[lTemp + DSU_DIFF_SPON_COMTYPE_SUBINDEX];/* 𷽷ͨͣҲǸ淽ݵͨͣ*/ + lnk_basic_info->LocalCycle = ShortFromChar(&data[lTemp + DSU_DIFF_SPON_CYCLE_SUBINDEX]); /*ķ*/ + lnk_basic_info->LocalMaxDelay = ShortFromChar(&data[lTemp + DSU_DIFF_SPON_MSG_MAXDELAY_SUBINDEX]);/*ʱ*/ + lnk_basic_info->AckMaxDelay = ShortFromChar(&data[lTemp + DSU_DIFF_SPON_ACK_MAXDELAY_SUBINDEX]);/*Ҫ֪Ackʱ*/ + lnk_basic_info->DestCycle = ShortFromChar(&data[lTemp + DSU_DIFF_FOLL_CYCLE_SUBINDEX]); /*Էķ*/ + lnk_basic_info->DestMaxDelay = ShortFromChar(&data[lTemp + DSU_DIFF_FOLL_MSG_MAXDELAY_SUBINDEX]); /*Էʱ*/ + lnk_basic_info->DestCommType = data[lTemp + DSU_DIFF_FOLL_COMTYPE_SUBINDEX];/* 淽ͨͣҲǷ𷽽ݵͨͣ*/ + #ifdef SFP_CKECK_DSU_IP + /*дϢ*/ + dsuFillLnkCommConfig(LocalInfo, DestDevName,lnk_basic_info) ; + #endif + ret = 1; + return ret; + } + else if((lLocalDevName == lDevName2) && (lDestDevType == lDevName)) + { + lnk_basic_info->Role = DSU_ROLE_FLW; /*ɫ*/ + lnk_basic_info->NCyclesPerPack = data[lTemp + DSU_DIFF_SENDMSG_MINDELAY_SUBINDEX];/*ͨŹϵϷ*/ + lnk_basic_info->LocalCommType = data[lTemp + DSU_DIFF_FOLL_COMTYPE_SUBINDEX];/* 𷽷ͨͣҲǸ淽ݵͨͣ*/ + lnk_basic_info->LocalCycle = ShortFromChar(&data[lTemp + DSU_DIFF_FOLL_CYCLE_SUBINDEX]); /*ķ*/ + lnk_basic_info->LocalMaxDelay = ShortFromChar(&data[lTemp + DSU_DIFF_FOLL_MSG_MAXDELAY_SUBINDEX]);/*ʱ*/ + lnk_basic_info->DestCycle = ShortFromChar(&data[lTemp + DSU_DIFF_SPON_CYCLE_SUBINDEX]); /*Էķ*/ + lnk_basic_info->DestMaxDelay = ShortFromChar(&data[lTemp + DSU_DIFF_SPON_MSG_MAXDELAY_SUBINDEX]); /*Էʱ*/ + lnk_basic_info->DestCommType = data[lTemp + DSU_DIFF_SPON_COMTYPE_SUBINDEX];/* 淽ͨͣҲǷ𷽽ݵͨͣ*/ + #ifdef SFP_CKECK_DSU_IP + /*дϢ*/ + dsuFillLnkCommConfig(LocalInfo, DestDevName,lnk_basic_info); + #endif + ret = 1; + return ret; + } + else + { + lTemp = lTemp + DSU_DIFF_RELATION_LENGTH; + } + } + } + ret = 0; + return ret; /*죬еıû鵽ʱ*/ + #ifdef SFP_CKECK_DSU_IP + } + else + { + ret = 0; + return ret; /*ݿд*/ + } + #endif +} +#ifdef SFP_CKECK_DSU_IP +/* +* :DSUijһ¼Ϣ䵽·ϢṹԪ +* ˵: +* [in]UINT32 DevName 豸name +* [out]struc_LnkBasicInfo* lnk_Comm_info ·ҪĻϢ +* [in]struc_Unify_Info * LocalInfo 󱾵Ϣͳһṹ +* ֵ:ɹ1򷵻0 +*/ +UINT8 dsuFillLnkCommConfig(struc_Unify_Info * LocalInfo, UINT32 DevName,struc_LnkBasicInfo* lnk_Comm_info) +{ + /*****************2012.4.1΢Ŀ޸***********************************/ + register UINT32 lTemp; /*ʱlongͱ*/ + register UINT8 * data; /*ݿַʱ*/ + + UINT8 ret; + UINT32 i; + UINT16 nObjNumber; /*ͨŶ*/ + UINT32 lDevName; /*ͨŶʱ*/ + + /*ĬҵipϢΪ0*/ + lnk_Comm_info->dstNum=0; + + if(dsuDataCheck((UINT8 *) LocalInfo->DataBase) == 1) + { + data = (UINT8 *) LocalInfo->DataBase; + lTemp=0; + + /*õDSUͨŶ*/ + nObjNumber = ShortFromChar(&data[lTemp]); + lTemp+=2; + + for(i = 0; i < nObjNumber; i++) + { + lDevName = ((UINT32) data[lTemp]<<24) + ((UINT32) data[lTemp + 1] << 16); + if(lDevName == DevName) + { + /*豸nameڴ豸name*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].RedIp[0] = data[lTemp + DSU_OBJ_REDIP_SUBINDEX];/*IPַ*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].RedIp[1] = data[lTemp + DSU_OBJ_REDIP_SUBINDEX + 1];/*IPַ*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].RedIp[2] = data[lTemp + DSU_OBJ_REDIP_SUBINDEX + 2];/*IPַ*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].RedIp[3] = data[lTemp + DSU_OBJ_REDIP_SUBINDEX + 3];/*IPַ*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].PortRed = ShortFromChar(&data[lTemp + DSU_OBJ_REDPORT_SUBINDEX]);/*˿*/ + + + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].BlueIp[0] = data[lTemp + DSU_OBJ_BLUEIP_SUBINDEX];/*IPַ*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].BlueIp[1] = data[lTemp + DSU_OBJ_BLUEIP_SUBINDEX + 1];/*IPַ*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].BlueIp[2] = data[lTemp + DSU_OBJ_BLUEIP_SUBINDEX + 2];/*IPַ*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].BlueIp[3] = data[lTemp + DSU_OBJ_BLUEIP_SUBINDEX + 3];/*IPַ*/ + lnk_Comm_info->DstIpInfo[lnk_Comm_info->dstNum].PortBlue = ShortFromChar(&data[lTemp + DSU_OBJ_BLUEPORT_SUBINDEX]);/*˿*/ + + lnk_Comm_info->dstNum++; + + } + else + { + /*豸nameڴ豸name*/ + + + } + + lTemp = lTemp + DSU_OBJ_INFO_LENGTH; + } + + + } + else + { + /*ݲϷֱӷʧ*/ + + } + + /*жǷҵipַ*/ + if (lnk_Comm_info->dstNum==0) + { + ret = 0; + + } + else + { + ret = 1; + } + + return ret; + +} +#endif +/* +*DSUУ飺DSUݵȷ +* ڣ洢DSU +* ڣȷ1󷵻0 +*/ +UINT8 dsuDataCheck(const UINT8* data) +{ + UINT8 ret=1; + UINT8 tempData; + + /*һݣԹرվ档*/ + tempData=data[0]; + return ret; +} +#ifdef SFP_CKECK_DSU_IP +/* +* :ж豸ǷݿеĶж豸ǷDSUͨŶУ +* ˵: +* [in]UINT32 DevName 豸+id +* [in]struc_Unify_Info * LocalInfo 󱾵Ϣͳһṹ +* ʹõȫֱ +* ֵ:ַDSUݿеڴλƫ򷵻0 +*/ +UINT32 dsuIsDevExist(struc_Unify_Info * LocalInfo , UINT32 DevName) +{ + register UINT32 lTemp; /*ʱlongͱ*/ + register UINT8 * data; /*ݿַʱ*/ + + UINT32 ret; + UINT32 i; + UINT16 nObjNumber; /*ͨŶ*/ + UINT32 lDevName; /*ͨŶʱ*/ + + if(dsuDataCheck((UINT8 *) LocalInfo->DataBase) == 1) + { + data = (UINT8 *) LocalInfo->DataBase; + lTemp=0; + + /*õDSUͨŶ*/ + nObjNumber = ShortFromChar(&data[lTemp]); + lTemp+=2; + + for(i = 0; i < nObjNumber; i++) + { + lDevName = ((UINT32) data[lTemp]<<24) + ((UINT32) data[lTemp + 1] << 16); + if(lDevName != DevName) + { + lTemp = lTemp + DSU_OBJ_INFO_LENGTH; + } + else + { + return lTemp; + } + } + ret = 0; + return ret; + + } + else + { + ret = 0; + return ret; + } +} +#endif +/* +* :ȡDSUͨŶ +* ˵: +* [in] struc_Unify_Info * LocalInfo ǰеĶͳһṹ +* ֵ: >0DSUͨŶ, + 0 +*/ +UINT16 dsuGetObjNum(struc_Unify_Info * LocalInfo) +{ +#ifdef SFP_CKECK_DSU_IP + UINT8 *data; /*ݿַʱ*/ + UINT16 nObjNumber; /*DSUͨŶ*/ + + data = (UINT8 *) LocalInfo->DataBase; + /*õDSUͨŶ*/ + + if(dsuDataCheck(data) == 1) + { + nObjNumber = ShortFromChar(&data[0]); + } + else + { + nObjNumber=0; + } +#else + UINT16 nObjNumber; /*DSUͨŶ*/ + nObjNumber = LocalInfo->MaxNumLink;/* Ҫһֵ */ +#endif + return nObjNumber; + +} + +#ifdef USE_DSU_SFP + +/* +* :ݴݵļԻݵĵַȡЭݵڴСٵڴַͨpDataBaseء +* ˵: +UINT8* fileName ļַ +UINT8** pDataBase ݿַ +ֵ:ȷ1򷵻0 +*/ +UINT8 dsuSfpInit(UINT8* fileName,UINT8** pDataBase) +{ + UINT8 chReturnValue =0 ; /*ֵ*/ + UINT8 TempRet; + UINT8* pData=NULL; /*ص*/ + UINT32 dataOff=0; /*ƫ*/ + UINT32 dataOffIp=0; /*ipƫ*/ + UINT32 dataLineNum=0; /*ipݸ*/ + +#ifdef SFP_CKECK_DSU_IP + UINT8* pData1=NULL; /*DSUͨŶ*/ + UINT32 data1Len=0; /*DSUͨŶݳ*/ +#endif + UINT8* pData2=NULL; /*DSUͬ豸ͨŹϵ*/ + UINT32 data2Len=0; /*DSUͬ豸ͨŹϵݳ */ + UINT8* pData3=NULL; /*DSUͬ豸ͨŹϵ*/ + UINT32 data3Len=0; /*DSUͬ豸ͨŹϵݳ*/ + + /*UINT32 i;*/ +#ifdef SFP_CKECK_DSU_IP + /*ȡ*/ + TempRet=dquGetConfigData((CHAR *)fileName, DSU_DEVICE_IP_CONFIG_TYPE, DSU_DATA_IP_IP_ID, &pData1 , &data1Len); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } +#endif + /*ȡ*/ + TempRet=dquGetConfigData((CHAR *)fileName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_DIFF_RELATION, &pData2 , &data2Len); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + /*ȡ*/ + TempRet=dquGetConfigData((CHAR *)fileName, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_SAME_RELATION, &pData3 , &data3Len); + if (TempRet!=1) + { + /*ݶȡʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { + /*ִ*/ + } + + + /*̬ݿռ䣬100ǿ㹻*/ +#ifdef SFP_CKECK_DSU_IP + pData=(UINT8*)malloc(data1Len+data2Len+data3Len+100); +#else + pData=(UINT8*)malloc(data2Len+data3Len+100); +#endif + if (pData==NULL) + { + /*ռʧ*/ + chReturnValue=0; + return chReturnValue; + } + else + { +#ifdef SFP_CKECK_DSU_IP + /*ִ*/ + CommonMemSet(pData,(data1Len+data2Len+data3Len+100),0,(data1Len+data2Len+data3Len+100)); +#else + CommonMemSet(pData,(data2Len+data3Len+100),0,(data2Len+data3Len+100)); +#endif + } + + /**/ + dataOff=0; +#ifdef SFP_CKECK_DSU_IP + /*ipݿ*/ + + /*ipݵ*/ + dataLineNum=data1Len/DSU_IP_INFO_STRU_SIZE; + + if (dataLineNum>65535) + { + /*жԽ*/ + chReturnValue=0; + return chReturnValue; + } + + ShortToChar((UINT16)dataLineNum,pData+dataOff); + dataOff+=2; + + /*ʼipƫ*/ + dataOffIp=0; + /*ѭ*/ + for (i=0;iId = 0u; + sheetInfo->Len = 0u; + sheetInfo->RowCount = 0u; + sheetInfo->ColLen = 0u; + sheetInfo->Data = NULL; + + if ((idx + 40u) <= dataLen) /*DH±*/ + { + /*4ֽCRC*/ + crcVal = LongFromChar(&data[idx]); + idx += 4u; + /*4ֽڰ汾*/ + idx += 4u; + /*4ֽڳ*/ + curLen = LongFromChar(&data[idx]); + idx += 4u; + + if ((curLen == dataLen) && (4u < curLen)) + { + crc = Crc32(&data[4], curLen - 4u); + if (crc == crcVal) + { + /*4ֽexcel*/ + excelCount = LongFromChar(&data[idx]); + idx += 4u; + /*24ֽԤ*/ + idx += 24u; + + for (excelIdx = 0u; excelIdx < excelCount; excelIdx++) + { + if ((idx + 24u) <= dataLen) /*DI±*/ + { + /*4ֽexcel*/ + curExcelId = LongFromChar(&data[idx]); + idx += 4u; + if (curExcelId == excelId) + { + /*4ֽڳ*/ + idx += 4u; + /*4ֽexcelλ*/ + curExcelPos = LongFromChar(&data[idx]); + curExcelStartPos = curExcelPos; + idx += 4u; + /*12ֽԤ*/ + idx += 12u; + + if ((curExcelPos + 40u) <= dataLen) /*DH±*/ + { + /*4ֽexcel CRC*/ + crcVal = LongFromChar(&data[curExcelPos]); + curExcelPos += 4u; + /*4ֽexcel汾*/ + curExcelPos += 4u; + /*4ֽexcel*/ + curLen = LongFromChar(&data[curExcelPos]); + curExcelPos += 4u; + + if (4u < curLen) + { + crc = Crc32(&data[curExcelStartPos + 4u], curLen - 4u); + if (crc == crcVal) + { + /*4ֽsheet*/ + sheetCount = LongFromChar(&data[curExcelPos]); + curExcelPos += 4u; + /*24ֽԤ*/ + curExcelPos += 24u; + + for (sheetIdx = 0u; sheetIdx < sheetCount; sheetIdx++) + { + if ((curExcelPos + 24u) <= dataLen) /*DH±*/ + { + /*4ֽsheet*/ + curSheetId = LongFromChar(&data[curExcelPos]); + curExcelPos += 4u; + if (curSheetId == sheetId) + { + sheetInfo->Id = curSheetId; + /*4ֽڳ*/ + sheetInfo->Len = LongFromChar(&data[curExcelPos]); + curExcelPos += 4u; + /*4ֽsheetexcelλ*/ + curSheetStartPos = LongFromChar(&data[curExcelPos]); + curExcelPos += 4u; + /*2ֽ*/ + sheetInfo->RowCount = ShortFromChar(&data[curExcelPos]); + curExcelPos += 2u; + /*2ֽ-*/ + curExcelPos += 2u; + /*8ֽԤ*/ + curExcelPos += 8u; + /*Lenֽ*/ + sheetInfo->Data = &data[curExcelStartPos + curSheetStartPos]; + + if (0u < sheetInfo->RowCount) /**/ + { + if ((0u < sheetInfo->Len) && (0u == (sheetInfo->Len % sheetInfo->RowCount))) /*ݳ*/ + { + sheetInfo->ColLen = sheetInfo->Len / sheetInfo->RowCount; + } + else /*ݴ*/ + { + sheetInfo->Len = 0u; + sheetInfo->RowCount = 0u; + sheetInfo->Data = NULL; + } + } + else /**/ + { + sheetInfo->Len = 0u; + sheetInfo->Data = NULL; + } + + isBreak = 1u; + } + else + { + curExcelPos += 20u; /*ƫһDI*/ + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + if (1u == isBreak) + { + break; + } + } + } + else /*crc*/ + { + isBreak = 1u; + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + } + else /**/ + { + idx += 20u; /*ƫһDI*/ + } + } + else /*ȴ*/ + { + isBreak = 1u; + } + if (1u == isBreak) + { + break; + } + } + } + } + } + } +} + +/* +*: ϲ +*: SheetInfo* sheetInfo sheetҳϢ +* UINT8 outData[] ⲿ +* UINT32* outDataIdx ⲿλ +*: UINT8 mergeData[] ϲ +* UINT32* mergeDataIdx ϲλ +*: +*ֵ: +*/ +static void MergeParam(SheetInfo* sheetInfo, UINT8 outData[], UINT32* outDataIdx, UINT16 outDataLen, UINT8 mergeData[], UINT32* mergeDataIdx) +{ + UINT8* proOutData = NULL; /*ⲿ*/ + UINT16 outRowCount = 0u; /*ⲿ*/ + UINT16 mergeRowCount = 0u; /*ϲ*/ + UINT32 rowCountIdx = 0u; /*λ*/ + UINT32 rowShouldLen = 0u; /*Ӧó*/ + UINT32 oppDevIdx = 0u; /*Է豸λ*/ + UINT32 colLen = 0u; /*ܳ*/ + UINT32 i = 0u; /*ѭ*/ + UINT32 j = 0u; /*ѭ*/ + UINT8 hasSame = 0u; /*ͬ*/ + UINT16 inLocDev = 0u; /*ڲ豸*/ + UINT16 outLocDev = 0u; /*ⲿ豸*/ + UINT16 inOppDev = 0u; /*ڲԷ豸*/ + UINT16 outOppDev = 0u; /*ⲿԷ豸*/ + + if ((NULL != sheetInfo) && (NULL != mergeData) && (NULL != mergeDataIdx)) /**/ + { + proOutData = &outData[*outDataIdx]; + CommonMemCpy(&mergeData[*mergeDataIdx], outDataLen, &proOutData[0], outDataLen); /*Ʋͬ豸*/ + outRowCount = ShortFromChar(&proOutData[0]); /*ǰ*/ + mergeRowCount = outRowCount; + (*outDataIdx) += outDataLen; /*λ*/ + + rowCountIdx = (*mergeDataIdx); /*³λ*/ + (*mergeDataIdx) += outDataLen; + if (NULL != sheetInfo->Data) /*,ϲ*/ + { + if ((DSU_DATA_PROTCL_DIFF_RELATION == sheetInfo->Id) || (DSU_DATA_PROTCL_SAME_RELATION == sheetInfo->Id)) /*sheetҳ*/ + { + if (DSU_DATA_PROTCL_DIFF_RELATION == sheetInfo->Id) /*ͬͱ*/ + { + rowShouldLen = DSU_DIFF_RELATION_LENGTH; + oppDevIdx = 8u; + } + else + { + rowShouldLen = DSU_SAME_RELATION_LENGTH; + oppDevIdx = 9u; + } + colLen = sheetInfo->ColLen; + if ((colLen == rowShouldLen)) /*г*/ + { + for (i = 0; i < sheetInfo->RowCount; i++) /**/ + { + hasSame = 0u; + if (DSU_DATA_PROTCL_DIFF_RELATION == sheetInfo->Id) /*ͬͱ*/ + { + inLocDev = sheetInfo->Data[i * colLen]; + inOppDev = sheetInfo->Data[(i * colLen) + oppDevIdx]; + } + else + { + inLocDev = ShortFromChar(&sheetInfo->Data[i * colLen]); + inOppDev = ShortFromChar(&sheetInfo->Data[(i * colLen) + oppDevIdx]); + } + for (j = 0; j < outRowCount; j++) + { + if (DSU_DATA_PROTCL_DIFF_RELATION == sheetInfo->Id) /*ͬͱ*/ + { + outLocDev = proOutData[2u + (j * colLen)]; + outOppDev = proOutData[2u + (j * colLen) + oppDevIdx]; + } + else + { + outLocDev = ShortFromChar(&proOutData[2u + (j * colLen)]); + outOppDev = ShortFromChar(&proOutData[(2u + (j * colLen)) + oppDevIdx]); + } + if ((inLocDev == outLocDev) && (inOppDev == outOppDev)) /*ݱԷͬ*/ + { + hasSame = 1u; + break; + } + } + if (0u == hasSame) /*޲ͬ,*/ + { + CommonMemCpy(&mergeData[*mergeDataIdx], colLen, &sheetInfo->Data[i * colLen], colLen); + (*mergeDataIdx) += colLen; + mergeRowCount++; + } + } + + ShortToChar(mergeRowCount, &mergeData[rowCountIdx]); + } + } + } + } +} + +/* +*: ϲ +*: const UINT32 inDataLen ڲ +* UINT8 inData[] ڲ +* struc_Unify_Info* sfp sfpṹ +*: +*: +*ֵ: Ƿɹ.1:ɹ;0:ʧ +*/ +UINT8 MergeDataBaseInParam(const UINT32 inDataLen, UINT8 inData[], struc_Unify_Info* sfp) +{ + UINT8 rtnVal = 0u; /*ֵ*/ + SheetInfo diffSheet = { 0u }; /*ͬ豸sheetҳ*/ + SheetInfo sameSheet = { 0u }; /*ͬ豸sheetҳ*/ + UINT8* dataBase = NULL; /*ݲ*/ + UINT32 curDataBaseIdx = 0u; /*ǰݲλ*/ + UINT32 mergeDataLen = 0u; /*ϲݳ*/ + UINT8* mergeData = NULL; /*ϲ*/ + UINT32 curMergeDataIdx = 0u; /*ǰϲλ*/ + UINT16 diffDataLen = 0u; /*ͬ豸ݳ*/ + UINT16 sameDataLen = 0u; /*ͬ豸ݳ*/ + UINT16 diffRowNum = 0u; /*ͬ豸*/ + UINT16 sameRowNum = 0u; /*ͬ豸*/ + + if ((NULL != sfp) && (NULL != sfp->DataBase)) /**/ + { + if ((0u < inDataLen) && (NULL != inData)) /**/ + { + InitSheet(&diffSheet, inData, inDataLen, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_DIFF_RELATION); + InitSheet(&sameSheet, inData, inDataLen, DSU_DATA_PROTCL_TYPE, DSU_DATA_PROTCL_SAME_RELATION); + dataBase = sfp->DataBase; + +#ifdef SFP_CKECK_DSU_IP + relationNum = ShortFromChar(&dataBase[curDataBaseIdx]); /*IP*/ + curDataBaseIdx += 2u; + curDataBaseIdx = curDataBaseIdx + relationNum * DSU_OBJ_INFO_LENGTH; /*IP*/ +#endif + diffRowNum = ShortFromChar(&dataBase[curDataBaseIdx]); /*ͬ豸ͨŹϵ*/ + diffDataLen = 2u + diffRowNum * DSU_DIFF_RELATION_LENGTH; /*ͬ豸ݳ*/ + sameRowNum = ShortFromChar(&dataBase[curDataBaseIdx + +diffDataLen]); /*ͬ豸ݳ*/ + sameDataLen = 2u + sameRowNum * DSU_SAME_RELATION_LENGTH; /*ͬ豸ͨŹϵ*/ + + mergeDataLen = curDataBaseIdx + diffDataLen + diffSheet.Len + sameDataLen + sameSheet.Len; /*ܳ*/ + mergeData = (UINT8*)malloc(sizeof(UINT8) * mergeDataLen); + if (NULL != mergeData) + { + CommonMemSet(&mergeData[0], mergeDataLen, 0u, mergeDataLen); /**/ + +#ifdef SFP_CKECK_DSU_IP + CommonMemCpy(&mergeData[0], curDataBaseIdx, &dataBase[0], curDataBaseIdx); + curMergeDataIdx += curDataBaseIdx; +#endif + + MergeParam(&diffSheet, &dataBase[0], &curDataBaseIdx, diffDataLen, &mergeData[0], &curMergeDataIdx); + MergeParam(&sameSheet, &dataBase[0], &curDataBaseIdx, sameDataLen, &mergeData[0], &curMergeDataIdx); + + sfp->DataBase = mergeData; + + rtnVal = 1u; + } + } + else /**/ + { + rtnVal = 1u; + } + } + + return rtnVal; +} + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_dqu_sfp/dsuRelatedDeal.h b/TSCP/src/protocol/sfp_record_cbtc1/common_dqu_sfp/dsuRelatedDeal.h new file mode 100644 index 0000000..f625711 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_dqu_sfp/dsuRelatedDeal.h @@ -0,0 +1,156 @@ + +/************************************************************************ +* ļDSURelatedDeal.h +* ļCBTCϵͳDSUЭشĺͷļ + Ҫڴ洢жܹԼ彨ϸϢĺ +* ʱ䣺2008.07.29 +* ļ + 1.ӦṩݿеϢ뵽̬ñṹУ + 2.жϸ豸·ϵǷϷҲܷ + 3.ݸıͶԷĶõľϢ + 4. + 5.ṩType+ID豸ıȽϺ +* +************************************************************************/ +#ifndef _DSURELATEDDEAL_H +#define _DSURELATEDDEAL_H + +#include "sfpplatform.h" + +#include "Convert.h" +#include "CommonTypes.h" + + +#define DSU_ROLE_SPON 0x00 /**/ +#define DSU_ROLE_FLW 0x01 /*淽*/ + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct + { + UINT8 RedIp[4]; /*IPַ*/ + UINT16 PortRed; /*˿ں*/ + UINT8 BlueIp[4]; /*IPַ*/ + UINT16 PortBlue; /*˿ں*/ + } IP_PORT_STRU; + + typedef struct { + UINT8 Role; /*ɫ*/ + UINT8 NCyclesPerPack; /*ͨŹϵϷ*/ + UINT16 LocalCycle; /*ڳ(ķڳ)*/ + UINT16 LocalMaxDelay; /*ʱ*/ + UINT8 LocalCommType; /*ͨͣҲǶԷݵͨͣ*/ + UINT16 DestCycle; /* Էķ*/ + UINT16 DestMaxDelay; /*ʱ*/ + UINT16 AckMaxDelay; /*շACKӳ*/ + UINT8 DestCommType; /*ԷͨͣҲDZݵͨͣ*/ + + #ifdef SFP_CKECK_DSU_IP + /*IP*/ + UINT8 dstNum; + IP_PORT_STRU DstIpInfo[2]; + #endif + } struc_LnkBasicInfo; + + +/* +:ж豸ܷ +˵: + [in]struc_Unify_Info * LocalInfo󱾵Ϣͳһṹ + [in]UINT32 DestDevNameԷ豸Name + [out]UINT8* role ɫ +ֵ:ܹ1,򷵻0 +*/ +UINT8 dsuIsLnkLegal(struc_Unify_Info * LocalInfo, UINT32 DestDevName,UINT8* role); + +/* + * :ж豸ǷݿеĶ + * ˵: + * [in]UINT32 DestDevName 豸+id + * [in]struc_Unify_Info * LocalInfo 󱾵Ϣͳһṹ + * ʹõȫֱ + * ֵ:ַ1򷵻0 + */ +UINT8 dsuGetLnkInfo(struc_Unify_Info* LocalInfo, UINT32 DestDevName, struc_LnkBasicInfo* lnk_basic_info ); + +#ifdef SFP_CKECK_DSU_IP +/* + * :DSUijһ¼Ϣ䵽·ϢṹԪ + * ˵: + * [in]UINT32 DevName 豸name + * [out]struc_LnkBasicInfo* lnk_Comm_info ·ҪĻϢ + * [in]struc_Unify_Info * LocalInfo 󱾵Ϣͳһṹ + * ֵ:ɹ1򷵻0 + */ +UINT8 dsuFillLnkCommConfig(struc_Unify_Info * LocalInfo, UINT32 DevName,struc_LnkBasicInfo* lnk_Comm_info); +#endif +/* + * DSUУ飺DSUݵȷ + * ڣ洢DSU + * ڣȷ1󷵻0 + */ +UINT8 dsuDataCheck(const UINT8* data); +#ifdef SFP_CKECK_DSU_IP +/* + * :ж豸ǷݿеĶ + * ˵: + * [in]UINT32 DevName 豸+id + * [in]struc_Unify_Info * LocalInfo 󱾵Ϣͳһṹ + * ʹõȫֱ + * ֵ:ַDSUݿеڴλƫ򷵻0 + */ +UINT32 dsuIsDevExist(struc_Unify_Info * LocalInfo , UINT32 DevName); +#endif +/* +* :ȡDSUͨŶ +* ˵: +* [in] struc_Unify_Info * LocalInfo ǰеĶͳһṹ +* ֵ: >0DSUͨŶ, +0 +*/ +UINT16 dsuGetObjNum(struc_Unify_Info * LocalInfo); + +/* +* :ͬʱõ淽Ϣ +* ˵: +* [out]INT8 *FollowDevInfo:¼淽Ϣͷָ (Ӧöһ1*9) +* ڲʽΪ +* Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6...... +* 淽 淽1Type 淽1ID 0 0 淽2Type 淽2ID ... +* [in] struc_Unify_Info * LocalInfo ǰеĶͳһṹ +* ֵ:ȷ1򷵻0 +*/ +UINT8 dsuSameTypeLnk(struc_Unify_Info * LocalInfo, UINT8 *FollowDevInfo); + + +#ifdef USE_DSU_SFP +/* +* :ݴݵļԻݵĵַȡЭݵڴСٵڴַͨpDataBaseء +* ˵: +UINT8* fileName ļַ +UINT8** pDataBase ݿַ +ֵ:ȷ1򷵻0 +*/ +UINT8 dsuSfpInit(UINT8* fileName,UINT8** pDataBase); +#endif + +/* +*: ϲ +*: const UINT32 inDataLen ڲ +* UINT8 inData[] ڲ +* struc_Unify_Info* sfp sfpṹ +*: +*: +*ֵ: Ƿɹ.1:ɹ;0:ʧ +*/ +UINT8 MergeDataBaseInParam(const UINT32 inDataLen, UINT8 inData[], struc_Unify_Info* sfp); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpDeclare.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpDeclare.h new file mode 100644 index 0000000..aeb58b6 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpDeclare.h @@ -0,0 +1,148 @@ + +/******************************************************************************* +* ļ Declare.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* ļΪЭ鹫ͷļֵĺ궨嶼ڴļ + ļӦļ +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + + +#ifndef _SFPDECLARE_H +#define _SFPDECLARE_H + + +/******************************************************************************** +궨 +********************************************************************************/ + + + +/******·궨**************/ +#define ROLE_SPON 0x00 /**/ +#define ROLE_FLW 0x01 /*淽*/ + +#define STATUS_DATA 0x17 /*·״̬״̬*/ +#define STATUS_HALT 0x2b /*·״̬ͨж״̬*/ +#define STATUS_PRECON 0x33 /*·״̬׼״̬*/ +#define STATUS_WCONACK 0x4e /*·״̬ȴ״̬*/ + +#define COMMTYPE_MULTICOMM 0x33 /*ͨͣ鲥*/ +#define COMMTYPE_P2P 0x55 /*ͨ״̬Ե*/ + +/*֡*/ +#define FRAME_RFC 0x17 /*֡*/ +#define FRAME_ACK 0x2b /*ȷ֡*/ +#define FRAME_DATA 0x35 /*֡*/ +#define FRAME_IDLE 0x59 /*άӱ*/ + +/************************************************************************ + * ԭЭһ16bit + * D15~D12 + * D11~D10ȼ + * D9~D8ģλ + * D7~D4ģеĴģ鲻ͬʱ4λĺ岻ͬ + * ڶȵײ + * D3~D0ģǷͬ4λĺͬ +************************************************************************/ +/*ȼ*/ +#define ERR 0x0800 +#define WARN 0x0C00 + +/*ģλ*/ +#define NET_STATUS 0x0000 /**/ +#define REDUN 0x0100 /*ģ*/ +#define RECEIVE 0x0200 /*ģ*/ +#define OUTPUT 0x0300 /*ģ*/ + +/*ģд*/ +#define ERROR_NULL 0x0000 +/**/ +#define FRAMETYPE_ROLE_CONFLICT 0x0010 /*֡󲻷*/ +#define SN_ILLEGAL 0x0020 /*кŲϷ*/ +#define FRAMETYPE_STATUS_CONFLICT 0x0030 /*֡ͺ·״̬Ϸ*/ +#define RE_RECV_RFC 0x0040 /*ظյRFC*/ +#define CRC_ERR 0x0050 /*CRC*/ +#define OBJ_ILLEAGL 0x0060 /*ͨŶ󲻺Ϸ*/ +#define DESTNAME_ERR 0x0070 /*ĿName*/ +#define OUTNETDATA_TOO_LONG 0x0080 /*ݳȹ*/ +#define SN_LOC_OVER 0x0090 /*յıŷǷ*/ +#define SN_OPP_OVER 0x00A0 /*յĶԷŷǷ*/ + +/**/ +#define NODE_LOST 0x0010 /*ݵû*/ +/**/ +#define ROLE_STATUS_CONFLICT 0x0010 /*ɫ·״̬*/ +#define APPDATA_LENGTH_ERR 0x0020 /*Ӧøݹ*/ + +/*ײ㴦*/ +#define TIMEOUT 0x0001 /*ģ鳬ʱ*/ +#define QUEUE_READ 0x0002 /*жд*/ +#define QUEUE_WRITE 0x0003 /*дд*/ +#define QUEUE_INTEGRITY 0x0004 /*ݲscanдӦø*/ +#define LNKMANAGE_PUSH 0x0005 /*·ڵѹջ*/ +#define LNKMANAGE_POP 0x0006 /*·ڵջ*/ +#define INPUT_LNK_PUSH 0x0007 /*һάݱڵѹջ*/ +#define INPUT_LNK_POP 0x0008 /*һάݱڵջ*/ +#define OUTPUT_LNK_PUSH 0x0009 /*ѹջ*/ +#define OUTPUT_LNK_POP 0x000a /*ջ*/ +#define ARRAY_FULL 0x000b /**/ + + +/****************************Эദʹõĺ궨*********************/ +/*յ*/ +#define RCV_DATA_LEN 0 /*0,ݵij*/ +#define RCV_SRC_SN (RCV_DATA_LEN+2) /*2,ݵķͷк*/ +#define RCV_AIM_SN (RCV_SRC_SN+4) /*6,ݵĽշк*/ +#define RCV_FRAME_TYPE (RCV_AIM_SN+4) /*10,ݵı*/ +#define RCV_AIM_DN (RCV_FRAME_TYPE+1) /*11,ݵĿ豸NAME*/ +#define RCV_SRC_DN (RCV_AIM_DN+4) /*15,ݵԴ豸NAME*/ +#define RCV_APP_DATA (RCV_SRC_DN+4) /*19,*/ + +/*ദһάе*/ +#define LINK_DATA_LEN 0 /*0,һάڵеݵij*/ +#define LINK_SRC_SN (LINK_DATA_LEN+2) /*2,һάڵеݵķͷк*/ +#define LINK_AIM_SN (LINK_SRC_SN+4) /*6,һάڵеݵĽշк*/ +#define LINK_FRAME_TYPE (LINK_AIM_SN+4) /*10,һάڵеݵı*/ +#define LINK_SRC_DN (LINK_FRAME_TYPE+1) /*11,һάڵеݵԴ豸ID*/ +#define LINK_APP_DATA (LINK_SRC_DN+4) /*15,һάڵеݵԴ豸*/ +/***********************************/ + + +/**************Э궨*****************************************/ +/************ЭӿһάиԪ±*******/ +#define NODATA 0 /*ûӦ*/ +#define LEN_IDX 0 /*б֡ݳ±*/ +#define SENDSN_IDX 2 /*зк±*/ +#define REVSN_IDX 6 /*зк±*/ +#define FRAMETYPE_IDX 10 /*б±*/ +#define DESTID_IDX 11 /*Դ߼ID±*/ +#define DESTTYPE_IDX 14 /*Դ߼ID±*/ +#define DESTData_IDX DESTID_IDX+4 /*Ӧ±*/ +/*#define MAX_TIMEOUTREV 0x04 */ /*淽ʱݶ10*/ + +/**/ +#define COM_ERROR 0 /*ƽ̨*/ +#define DONE 0x01 /*Э봦*/ +/******************************/ + + + +/*******************Эú궨*******************/ +#define ITEMSRC_BOTH 0x17 /*Դݶк·*/ +#define ITEMSRC_DATABUFF 0x33 /*Դݶ*/ +#define ITEMSRC_LNKMNGR 0x55 /*Դ·*/ + +#define NEED2SEND 0x33 /*Ҫ*/ +#define SENT 0x55 /*Ѿ͹*/ +/**********************************/ + + +#define LNKFRAMELEN 0x24 /* мһ֡ݳ */ +#endif diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpLinkManage.c b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpLinkManage.c new file mode 100644 index 0000000..30a9cd7 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpLinkManage.c @@ -0,0 +1,811 @@ + +/******************************************************************************* +* ļ sfpLinkManage.c +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* CBTCȫͨЭSFPͨ·غ + 1.·ʼ + 2.ڵ + 3.ѯ + 4.дڵϢ + 5.ɾڵĹ +* ʹע + +* ޸ļ¼ + 2009-8-27 17:55:29 + 1.޸ͣʹCommonTypes.hеĶ + 2.Fill_In_Lnk_Mngrע͵ͨšͨ͡鲥ַ + 3.ProtclFreshLnkMngr58Ϊ48 + 4.FillLnkMngr_from_HISTORYע͵ͨšͨ͡鲥ַ +*******************************************************************************/ + +#include "sfpLinkManage.h" +#include "sfpDeclare.h" +#include "dsuRelatedDeal.h" +#include "CommonMemory.h" + +/****************************************************************************************** +* : ʼͨ·(һָͷڵһά) + 1. ̬·ջռ䣬гʼ + 2. ·ͷָΪգ +* : +* : struc_Unify_Info* LnkUnifyInfo Эʹõͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 InitLnkMngr(struc_Unify_Info *LnkUnifyInfo) /*·ʼ*/ +{ + UINT8 ret; + + /*·ڵ洢ռ*/ + if(!init_Lnk_Mngr_stack(&LnkUnifyInfo->LnkStack)) + { + /*¼¼*/ + ret = 0; + return ret; + } + LnkUnifyInfo->LnkHead = NULL; + + ret = 1; + return ret; +} + +/****************************************************************************************** +* : Ϊ·ָڵӽڵϢ + 1. 豸·Ϣṹеݸֵ·ڵ +* : UINT32 Dest_DevName Է豸Name + struc_LnkBasicInfo* lnk_basic_info ̬ñҪ·ϢŵĽṹ +* : struct struc_Lnk_Mngr *chCurIndex Ҫ·Ľڵָ +* : +* ȫֱ : +* ֵ : +*******************************************************************************************/ +void Fill_In_Lnk_Mngr(UINT32 Dest_DevName, struc_Lnk_Mngr *chCurIndex,struc_LnkBasicInfo *lnk_basic_info)/* %RELAX */ +{ + + UINT16 localwidth = 0; + UINT16 destwidth = 0; + UINT16 datatimeoutnum = 0; + UINT16 acktimeoutnum = 0; + UINT8 i = 0; + + + GetLnkMngValue(lnk_basic_info,&localwidth,&destwidth,&datatimeoutnum,&acktimeoutnum); + + /*õ·ɫ*/ + chCurIndex->Lnk_Info.chRole = lnk_basic_info->Role; + + /*дͨŶԷ豸Name*/ + chCurIndex->Lnk_Info.nDestDevName = Dest_DevName; + + #ifdef SFP_CKECK_DSU_IP + /* дԷĿϵ */ + chCurIndex->Lnk_Info.destNum = lnk_basic_info->dstNum; + + for(i = 0;i< lnk_basic_info->dstNum;i++) + { + /*дԷIP*/ + chCurIndex->Lnk_Info.chDestIP[0+i*2][0] = lnk_basic_info->DstIpInfo[i].RedIp[0]; + chCurIndex->Lnk_Info.chDestIP[0+i*2][1] = lnk_basic_info->DstIpInfo[i].RedIp[1]; + chCurIndex->Lnk_Info.chDestIP[0+i*2][2] = lnk_basic_info->DstIpInfo[i].RedIp[2]; + chCurIndex->Lnk_Info.chDestIP[0+i*2][3] = lnk_basic_info->DstIpInfo[i].RedIp[3]; + /*дԷPort*/ + chCurIndex->Lnk_Info.nPort[0+i*2] = lnk_basic_info->DstIpInfo[i].PortRed; + + /*дԷIP*/ + chCurIndex->Lnk_Info.chDestIP[1+i*2][0] = lnk_basic_info->DstIpInfo[i].BlueIp[0]; + chCurIndex->Lnk_Info.chDestIP[1+i*2][1] = lnk_basic_info->DstIpInfo[i].BlueIp[1]; + chCurIndex->Lnk_Info.chDestIP[1+i*2][2] = lnk_basic_info->DstIpInfo[i].BlueIp[2]; + chCurIndex->Lnk_Info.chDestIP[1+i*2][3] = lnk_basic_info->DstIpInfo[i].BlueIp[3]; + /*дԷPort*/ + chCurIndex->Lnk_Info.nPort[1+i*2] = lnk_basic_info->DstIpInfo[i].PortBlue; + } + + if(i ==1) + { + + /*дԷIP*/ + chCurIndex->Lnk_Info.chDestIP[0+i*2][0] = 0; + chCurIndex->Lnk_Info.chDestIP[0+i*2][1] = 0; + chCurIndex->Lnk_Info.chDestIP[0+i*2][2] = 0; + chCurIndex->Lnk_Info.chDestIP[0+i*2][3] = 0; + /*дԷPort*/ + chCurIndex->Lnk_Info.nPort[0+i*2] = 0; + + /*дԷIP*/ + chCurIndex->Lnk_Info.chDestIP[1+i*2][0] = 0; + chCurIndex->Lnk_Info.chDestIP[1+i*2][1] = 0; + chCurIndex->Lnk_Info.chDestIP[1+i*2][2] = 0; + chCurIndex->Lnk_Info.chDestIP[1+i*2][3] = 0; + /*дԷPort*/ + chCurIndex->Lnk_Info.nPort[1+i*2] = 0; + } + else + { + /* */ + } +#endif + /*дյ֡ͣʼΪ0*/ + chCurIndex->Lnk_Info.lastframe = 0; + + /*յ֡кţʼΪ0*/ + chCurIndex->Lnk_Info.lastCycle = 0; + + /*дδյݵ,ʼΪ0*/ + chCurIndex->Lnk_Info.chNoDataRcvCycle = 0; + + /*д·״̬ʼΪ0*/ + chCurIndex->Lnk_Info.chStatus = 0; + + /*ͶԷкųʼֵ*/ + chCurIndex->Lnk_Info.RfcSN = 0; + chCurIndex->Lnk_Info.AckSN = 0; + + /*д·ĶԷк,ʼΪ0*/ + chCurIndex->Lnk_Info.lDestSN = 0; + chCurIndex->Lnk_Info.lLocalSN = 0; + + /*дĵĶԷ*/ + chCurIndex->Lnk_Info.nCycle[0] = lnk_basic_info->DestCycle; + chCurIndex->Lnk_Info.nCycle[1] = lnk_basic_info->LocalCycle; + + /*д·ıкЧ*/ + chCurIndex->Lnk_Info.nSnWidth[0] = destwidth; + chCurIndex->Lnk_Info.nSnWidth[1] = localwidth; + + /*ݺACKĽܳʱ*/ + chCurIndex->Lnk_Info.nTimeOut = datatimeoutnum;/*ݱijʱʱ*/ + chCurIndex->Lnk_Info.nACKTOut = acktimeoutnum;/*ACKijʱʱ*/ + + /*дĵʱ*/ + chCurIndex->Lnk_Info.DestMaxDelay = lnk_basic_info->DestMaxDelay; + +} + + +/****************************************************************************************** +* : ָĽڵ뵽·й涨λ + 1. ·뵽· + 2. Ϊ·һЩϢ +* : UINT32 Dest_DevName Է豸Name +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹָ +* : +* ȫֱ : +* ֵ : ǰڵָ룬ʧܷNULL +*******************************************************************************************/ +struc_Lnk_Mngr* InsertLnk( UINT32 Dest_DevName, struc_Unify_Info *LnkUnifyInfo) /* %RELAX */ +{ + + struc_LnkBasicInfo LnkBasicInfo; /*DSU·Ϣṹ*/ + struc_Lnk_Mngr *LastIndex; + struc_Lnk_Mngr *CurIndex; + struc_Lnk_Mngr *TempIndex; + struc_Lnk_Mngr *pret; + + LastIndex = NULL; + /*ǰָͷָ뿪ʼ*/ + CurIndex = LnkUnifyInfo ->LnkHead; + TempIndex = NULL; + + /*DSUж·Ϣ*/ + if( dsuGetLnkInfo( LnkUnifyInfo, Dest_DevName, &LnkBasicInfo ) != 1) /*ʹDSUṩȡ·Ϣ*/ + { + pret = NULL; + return pret;/*ؿָ*/ + } + else + { + /*޲*/ + } + + /*·*/ + while(1) + { + /*·Ѿнڵ*/ + if(CurIndex != NULL) + { + /*ڵڵǰڵ,ڵǰڵ֮ǰ*/ + if( Dest_DevName >CurIndex ->DevName) + { + /*ȡڵڴ;*/ + TempIndex = (struc_Lnk_Mngr*)PopStack(&LnkUnifyInfo->LnkStack); + if(NULL == TempIndex) + { + pret = NULL; + return pret; /*ûпõڴڵ㣬ؿָ*/ + } + else + { + /*޲*/ + } + + /*ĿNameֵ*/ + TempIndex->DevName = Dest_DevName; + + /*Ϣڵ*/ + Fill_In_Lnk_Mngr(Dest_DevName,TempIndex,&LnkBasicInfo); + + /*ָһڵָǰָ*/ + TempIndex->NextNode = CurIndex; + + /*ڵΪһڵ,ͷڵó²ڵ*/ + if(LastIndex == NULL) + { + LnkUnifyInfo ->LnkHead = TempIndex; + } + /*ڵ㲻Ϊһڵ㣬һڵָڵ*/ + else + { + LastIndex->NextNode = TempIndex; + } + + /*ز뵱ǰַָѭ*/ + return TempIndex; + } + /*ڵѾڣ¸*/ + else if( Dest_DevName == CurIndex ->DevName) + { + /*ĿNameֵ*/ + CurIndex->DevName = Dest_DevName; + + /*Ϣڵ*/ + Fill_In_Lnk_Mngr(Dest_DevName,CurIndex,&LnkBasicInfo); + + /*صǰַָѭ*/ + return CurIndex; + } + /*ڵСڵǰڵ㣬ǰһڵһڵ*/ + else + { + LastIndex = CurIndex; + CurIndex = CurIndex->NextNode; + } + } + /*ڵΪһڵ||ڵΪһڵ*/ + else + { + /*ȡڵڴ*/ + TempIndex = (struc_Lnk_Mngr *)PopStack(&LnkUnifyInfo->LnkStack); + if(NULL == TempIndex) + { + pret = NULL; + return pret; /*ûпõڴڵ㣬ؿָ*/ + } + else + { + /*޲*/ + } + + /*ĿNameֵ*/ + TempIndex->DevName = Dest_DevName; + + /*Ϣڵ*/ + Fill_In_Lnk_Mngr(Dest_DevName,TempIndex,&LnkBasicInfo); + + /*ڵΪһڵ㣬Ϊͷڵһڵ*/ + if(LastIndex == NULL) + { + /*ͷָ븳ֵ*/ + LnkUnifyInfo ->LnkHead = TempIndex; + } + /*ڵΪһڵ㣬ýڵ뵽һڵλ*/ + else + { + LastIndex-> NextNode = TempIndex; + } + + /*ָһڵָΪ*/ + TempIndex->NextNode = NULL; + + /*ز뵱ǰַָ*/ + return TempIndex; + } + } + +} + +/****************************************************************************************** +* : ΪӦṩ·ɾڵIJɾ·ָڵ + 1. Ӧõô˺ɾӦTypeID· +* : UINT8 DestType Է豸 + UINT8 DestID Է豸ID +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1󷵻0 +*******************************************************************************************/ +UINT8 ProtclDeleteLnk(UINT8 DestType,UINT8 DestID, struc_Unify_Info *LnkUnifyInfo)/* %RELAX */ +{ + + struc_Lnk_Mngr *LastIndex; + struc_Lnk_Mngr *CurIndex; + UINT32 Dest_DevName;/*long豸name*/ + UINT8 ret = 0; + + if(LnkUnifyInfo == NULL) + { + return ret; + } + else + {} + + Dest_DevName = TypeIdToName(DestType,DestID); + LastIndex = NULL; + /*ǰָͷָ뿪ʼ*/ + CurIndex = LnkUnifyInfo -> LnkHead; + + while(CurIndex != NULL) + { + /*ҵҪɾڵ*/ + if(Dest_DevName == CurIndex->DevName) + { + /*ɾڵͷڵ*/ + if(LastIndex == NULL) + { + LnkUnifyInfo -> LnkHead = CurIndex->NextNode; + if( PushStack(&LnkUnifyInfo->LnkStack,CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + }/*if(һָLastIndex == NULL)*/ + /*ɾڵ㲻ͷڵ*/ + else + { + LastIndex->NextNode = CurIndex->NextNode; + if( PushStack(&LnkUnifyInfo->LnkStack,CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + } + } + else + { + /*޲*/ + } + + /*ûҵҪɾڵ㣬һָ͵ǰָ붼һڵ*/ + LastIndex = CurIndex; + CurIndex = CurIndex->NextNode; + + }/*end while(CurIndex != NULL)*/ + + ret = 1; + return ret; +} + +/****************************************************************************************** +* : ΪЭṩ·ɾڵIJɾ·ָڵ + 1. Эô˺ɾָָ· +* : struc_Lnk_Mngr *chIndex Ҫɾڵָ +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1󷵻0 +*******************************************************************************************/ +UINT8 DelLnk(struc_Lnk_Mngr *chIndex, struc_Unify_Info *LnkUnifyInfo)/* %RELAX */ +{ + struc_Lnk_Mngr *CurIndex; + struc_Lnk_Mngr *LastIndex; + UINT8 ret; + + /*ͷڵ㸳ǰָ*/ + CurIndex = LnkUnifyInfo -> LnkHead; + LastIndex = NULL; + + while(CurIndex != NULL) + { + /*ҵҪɾڵ*/ + if(chIndex == CurIndex) + { + /*ɾڵͷڵ*/ + if(LastIndex == NULL) + { + LnkUnifyInfo -> LnkHead = CurIndex->NextNode; + if( PushStack(&LnkUnifyInfo->LnkStack,CurIndex) == 0) + { + ret =0; + return ret; + } + else + { + /*޲*/ + } + }/*if(һָLastIndex == NULL)*/ + /*ɾڵ㲻ͷڵ*/ + else + { + LastIndex->NextNode = CurIndex->NextNode; + if( PushStack(&LnkUnifyInfo->LnkStack,CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + } + } + else + { + /*޲*/ + } + + /*ûҵҪɾڵ㣬һָ͵ǰָ붼һڵ*/ + LastIndex = CurIndex; + CurIndex = CurIndex->NextNode; + + }/*end while(CurIndex != NULL)*/ + + ret = 1; + return ret; +} + +/****************************************************************************************** +* : ѯ·нڵָIJ·ѯ·ɶλ·Ĺ + 1. ݶԷ豸·вѯӦ·ش˽ڵָ +* : UINT32 Dest_DevName Է豸Type+ID +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹָ +* : +* ȫֱ : +* ֵ : Ҫҽڵĵַָ +*******************************************************************************************/ +struc_Lnk_Mngr* SearchLnk(UINT32 Dest_DevName, struc_Unify_Info *LnkUnifyInfo )/* %RELAX */ +{ + struc_Lnk_Mngr *CurIndex; + struc_Lnk_Mngr *pret; + + /*ǰָͷָ뿪ʼ*/ + CurIndex = LnkUnifyInfo -> LnkHead; + + while(1) + { + if(CurIndex != NULL) + { + /*ҵҪѯڵ*/ + if(Dest_DevName == CurIndex->DevName) + { + return CurIndex;/*صǰָ*/ + }/*if(Dest_DevName == CurIndex->DevName)*/ + else + { + CurIndex = CurIndex->NextNode; /*ûҵҪɾڵ㣬ǰָ붼һڵ*/ + } + }/* if(CurIndex != NULL)*/ + else + { + pret = NULL; + return pret; /*ûҵҪ·*/ + } + }/*while(1)*/ + +} + +/****************************************************************************************** +* : ָ·ľ̬ñϢΪ·Ϣ + 1. ·ľ̬ñϢ㱨ĵı/Էıijʱ + 2. ·ľ̬ñϢݱĵijʱACKĵijʱ +* : struc_LnkBasicInfo* lnk_basic_info ̬ñб·Ϣ洢ṹ +* : +* : UINT16* localwidth ijʱ + UINT16* destwidth Էijʱ + UINT16* datatimeoutnum ݱʱ + UINT16* acktimeoutnum ACKʱ +* ȫֱ : +* ֵ : +*******************************************************************************************/ +void GetLnkMngValue(struc_LnkBasicInfo *lnk_basic_info,UINT16 *localwidth,UINT16 *destwidth,UINT16 *datatimeoutnum,UINT16 *acktimeoutnum)/* %RELAX */ +{ + UINT16 Local_Timeout_Rcv; /*ݽճʱʱ*/ + UINT16 Dest_Timeout_Rcv; /*Էݽճʱʱ*/ + UINT16 Timeout_Temp; /*мֵ*/ + + /*ȼ㱾ݽճʱʱͶԷݽճʱʱ䣬ΪݶΪõ*/ + + /*ݽճʱʱ㣬ݹʽɵ*/ + Local_Timeout_Rcv = (lnk_basic_info->DestCycle * lnk_basic_info->NCyclesPerPack) + + lnk_basic_info->DestMaxDelay +lnk_basic_info->LocalCycle; + + /*Էݽճʱʱ㣬ݹʽɵ*/ + Dest_Timeout_Rcv = (lnk_basic_info->LocalCycle * lnk_basic_info->NCyclesPerPack ) + + lnk_basic_info->LocalMaxDelay + lnk_basic_info->DestCycle; + + /*ɴ˿ԽʱԼкſ*/ + + /*ݱʱɱʱʱ/*/ + *datatimeoutnum = Local_Timeout_Rcv / (lnk_basic_info->LocalCycle); + + /*кſɶԷʱʱ/*/ + *localwidth = Dest_Timeout_Rcv / (lnk_basic_info->LocalCycle); + /*Էкſɱʱʱ/Է*/ + *destwidth = Local_Timeout_Rcv / (lnk_basic_info->DestCycle); + + /*㱾ACKʱֻеʱŻ*/ + if(lnk_basic_info->Role == ROLE_SPON) + { + Timeout_Temp = (((lnk_basic_info->DestCycle) * 2) + lnk_basic_info->AckMaxDelay )/(lnk_basic_info->LocalCycle); + *acktimeoutnum = Timeout_Temp + 2; + } + else + { + *acktimeoutnum = 0; + } +} + +/****************************************************************************************** +* : ѯ·ij·ڱڵ·״̬ + 1. Ӧø豸ͺIDѯ·д·ڵ·״̬ +* : UINT8 DestType Է豸 + UINT8 DestID Է豸ID +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹ +* : +* ȫֱ : +* ֵ : ָڵ·״̬󷵻0 +*******************************************************************************************/ +UINT8 ProtclCheckLnkStatus(UINT8 DestType,UINT8 DestID, struc_Unify_Info *LnkUnifyInfo )/* %RELAX */ +{ + struc_Lnk_Mngr *CurIndex; + UINT32 Dest_DevName;/*long豸name*/ + UINT8 ret = 0; + + if(LnkUnifyInfo == NULL) + { + return ret; + } + else + {} + + Dest_DevName = TypeIdToName(DestType,DestID); + + /*ǰָͷָ뿪ʼ*/ + CurIndex = LnkUnifyInfo->LnkHead; + while(1) + { + if(CurIndex != NULL) + { + /*ҵҪѯڵ*/ + if(Dest_DevName == CurIndex->DevName) + { + return CurIndex->Lnk_Info.chStatus;/*صǰָָ·״̬*/ + }/*if(Dest_DevName == CurIndex->DevName)*/ + else + { + /*ûҵҪɾڵ㣬ǰָ붼һڵ*/ + CurIndex = CurIndex->NextNode; + } + }/*if(CurIndex != NULL)*/ + else + { + /*ûҵҪɾڵ*/ + ret = 0; + return ret; + } + }/*while(1)*/ + +} + +/****************************************************************************************** +* : ˢ±ͨ·ƽ̨ӦҪ·ʾ +* : INT16 sLen_Input 鳤 + UINT8 *Input_Data_LnkMes ͷָ +* : struc_Unify_Info *LnkUnifyInfo ƽ̨ṩͳһṹ +* : +* ȫֱ : +* ֵ : 1쳣0 +*******************************************************************************************/ +UINT8 ProtclFreshLnkMngr(INT16 sLen_Input,UINT8 *Input_Data_LnkMes, struc_Unify_Info *LnkUnifyInfo )/* %RELAX */ +{ + UINT16 i = 0; + struc_Lnk_Mngr *LastLnk = NULL; + struc_Lnk_Mngr *CurLnk = NULL; + UINT16 sLnksNums = 0; + INT16 tmpSlen_input = sLen_Input; + UINT8 ret = 0; + + if((LnkUnifyInfo == NULL)||(Input_Data_LnkMes == NULL)) + { + return ret; + } + else + {} + + while(LnkUnifyInfo->LnkHead != NULL) + { + CurLnk = LnkUnifyInfo->LnkHead; + LnkUnifyInfo->LnkHead = CurLnk ->NextNode; + if( PushStack(&LnkUnifyInfo->LnkStack,CurLnk) == 0) + { + ret =0; + return ret; + } + } + + if( 0 == ( sLen_Input % LNKFRAMELEN ) ) + { + sLnksNums = ( sLen_Input / LNKFRAMELEN ); + for( i = 0; i < sLnksNums; i++) + { + CurLnk = (struc_Lnk_Mngr *)PopStack(&LnkUnifyInfo->LnkStack); + if(NULL != CurLnk) /*ӶջܹõĽڵַ*/ + { + /*Ŀnameֵ*/ + CurLnk->DevName = LongFromCharLE(Input_Data_LnkMes + 1 ); + + /*ʷˢ·Ϣ*/ + FillLnkMngr_from_HISTORY( Input_Data_LnkMes, CurLnk); + + if( i == 0) + { + LnkUnifyInfo->LnkHead = CurLnk; + CurLnk->NextNode = NULL; + } + else + { + LastLnk->NextNode = CurLnk; + CurLnk->NextNode = NULL; + } + LastLnk = CurLnk; + Input_Data_LnkMes = Input_Data_LnkMes+LNKFRAMELEN; + tmpSlen_input = tmpSlen_input - LNKFRAMELEN; + if( 0 == ( tmpSlen_input % LNKFRAMELEN ) ) + { + /* */ + } + else + { + ret = 0; + return ret; + } + + }/*end if((CurLnk = (struct struc_Lnk_Mngr *)PopStack(&new_stack))!= 0)*/ + else + { + ret = 0; + return ret; + } + }/*end for( i = 0; i < sLnksNums; i++)*/ + + ret = 1; + return ret; + } + else + { + ret = 0; + return ret; + } + +} + +/****************************************************************************************** +* : ʷϢ±ͨͨ·ڲ,ƽ̨Ӧòɼ +* : UINT8 *Input_Data_LnkMes ͷָ +* : struc_Lnk_Mngr *CurLnk ·ͷָ +* : +* ȫֱ : +* ֵ : 1쳣0 +*******************************************************************************************/ +static UINT8 FillLnkMngr_from_HISTORY(UINT8 *Input_Data_LnkMes,struc_Lnk_Mngr *CurLnk) +{ + UINT32 temp_long; + UINT16 temp_short; + UINT16 i; + UINT8 ret; + i = 0; + + /*Role ·бɫ Unsigned char,1ֽ*/ + CurLnk->Lnk_Info.chRole = *(Input_Data_LnkMes+i++); + + /*nDestDevName Է豸name(ID+type) 4ֽ*/ + CurLnk->Lnk_Info.nDestDevName = LongFromCharLE(Input_Data_LnkMes+i); + + i=i+4; + + /*Status ·״̬ Unsigned char,1ֽ*/ + CurLnk->Lnk_Info.chStatus = *(Input_Data_LnkMes+i++); + + /*LocalSN ͷк Unsigned long,4ֽ*/ + temp_long = LongFromChar(Input_Data_LnkMes+i); + CurLnk->Lnk_Info.lLocalSN = temp_long; + + i = i + 4; + + /*DestSN շк Unsigned long,4ֽ*/ + temp_long = LongFromChar(Input_Data_LnkMes+i); + CurLnk->Lnk_Info.lDestSN = temp_long; + + i = i + 4; + + /*LocalSnWidth кЧȣжSNǷϷʱʹã Unsigned short2ֽ*/ + temp_short = ShortFromChar(Input_Data_LnkMes+i); + CurLnk->Lnk_Info.nSnWidth[1] = temp_short ; + + i = i + 2; + + /*DestSnWidth ԷкЧȣжSNǷϷʱʹã Unsigned short2ֽ*/ + temp_short = ShortFromChar(Input_Data_LnkMes+i); + CurLnk->Lnk_Info.nSnWidth[0] = temp_short ; + + i = i + 2; + + /*LocalTimeOutRcv ݱĽճʱʱ() Unsigned short2ֽ*/ + temp_short = ShortFromChar(Input_Data_LnkMes+i); + CurLnk->Lnk_Info.nTimeOut = temp_short ; + + i = i + 2; + + /*LocalTimeOutAck AckĽճʱʱ() Short2ֽ*/ + temp_short = ShortFromChar(Input_Data_LnkMes+i); + CurLnk->Lnk_Info.nACKTOut = temp_short ; + + i = i + 2; + + /*RecDataProNum յݵں Unsigned long,4ֽ */ + temp_long = LongFromChar(Input_Data_LnkMes+i); + CurLnk->Lnk_Info.lastCycle = temp_long; + + i = i + 4; + + /*Frametype յݵı Unsigned char,1ֽ*/ + CurLnk->Lnk_Info.lastframe = *(Input_Data_LnkMes+i++); + + /*NoDataRcvCycle ûյݵ Unsigned char,1ֽ*/ + CurLnk->Lnk_Info.chNoDataRcvCycle = *(Input_Data_LnkMes+i++); + + /*·еRFCʼк*/ + CurLnk->Lnk_Info.RfcSN = LongFromChar(Input_Data_LnkMes+i); + + i = i + 4; + + /*·еACKʼк*/ + CurLnk->Lnk_Info.AckSN = LongFromChar(Input_Data_LnkMes+i); + + ret = 1; + return ret; +} + +/* +*: SfpDelAllLink +*: SFPɾ· +*: struc_Unify_Info* spf SFPṹ +*: +*: +*ֵ: +*/ +void SfpDelAllLink(struc_Unify_Info* spf) +{ + struc_Lnk_Mngr* curLink = NULL; /*ǰ·*/ + + if (NULL != spf) /**/ + { + curLink = spf->LnkHead; /*õǰ·*/ + while (NULL != curLink) /*·*/ + { + spf->LnkHead = curLink->NextNode; /*ͷָ*/ + + CommonMemSet(curLink, sizeof(struc_Lnk_Mngr), 0u, sizeof(struc_Lnk_Mngr)); /*·Ϣ*/ + (void)PushStack(&spf->LnkStack, curLink); /*·ڵѹջ*/ + + curLink = spf->LnkHead; /*µǰ·Ϊһ·*/ + } + + if (NULL != spf->RecordArray) /*¼־*/ + { + PrintRecArray2ByteB(spf->RecordArray, spf->RecordArraySize, (UINT16)0xF0F0u); + } + } +} + + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpLinkManage.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpLinkManage.h new file mode 100644 index 0000000..bac4741 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpLinkManage.h @@ -0,0 +1,135 @@ + +/******************************************************************************* +* ļ sfpLinkManage.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* CBTCȫͨЭSFPͨ·غͷļ +* ʹע + +* ޸ļ¼ + 2009-11-10 17:37:48 + 1. ProtclDeleteLnkProtclCheckLnkStatusProtclFreshLnkMngrƵplatform.h + +*******************************************************************************/ + +#ifndef _SFPLINKMANAGE_H +#define _SFPLINKMANAGE_H + +#include "sfpplatform.h" +#include "sfpDeclare.h" +#include "dsuRelatedDeal.h" +#include "Convert.h" +#include "sfpPrtclCommon.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*****************************************************************************************/ +/* ͨ· */ +/*****************************************************************************************/ + + +/****************************************************************************************** +* : ʼͨ·(һָͷڵһά) + 1. ̬·ջռ䣬гʼ + 2. ·ͷָΪգ +* : +* : struc_Unify_Info* LnkUnifyInfo Эʹõͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 InitLnkMngr(struc_Unify_Info *LnkUnifyInfo); + + +/****************************************************************************************** +* : ָĽڵ뵽·й涨λ + 1. ·뵽· + 2. Ϊ·һЩϢ +* : UINT32 Dest_DevName Է豸Name +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹָ +* : +* ȫֱ : +* ֵ : ǰڵָ룬ʧܷNULL +*******************************************************************************************/ +struc_Lnk_Mngr* InsertLnk( UINT32 Dest_DevName, struc_Unify_Info *LnkUnifyInfo); + + +/****************************************************************************************** +* : Ϊ·ָڵӽڵϢ + 1. 豸·Ϣṹеݸֵ·ڵ +* : UINT32 Dest_DevName Է豸Name + struc_LnkBasicInfo* lnk_basic_info ̬ñҪ·ϢŵĽṹ +* : struct struc_Lnk_Mngr *chCurIndex Ҫ·Ľڵָ +* : +* ȫֱ : +* ֵ : +*******************************************************************************************/ +void Fill_In_Lnk_Mngr(UINT32 Dest_DevName, struc_Lnk_Mngr *chCurIndex, struc_LnkBasicInfo *lnk_basic_info); + + + +/****************************************************************************************** +* : ѯ·нڵָIJ·ѯ·ɶλ·Ĺ + 1. ݶԷ豸·вѯӦ·ش˽ڵָ +* : UINT32 Dest_DevName Է豸Type+ID +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹָ +* : +* ȫֱ : +* ֵ : Ҫҽڵĵַָ +*******************************************************************************************/ +struc_Lnk_Mngr* SearchLnk(UINT32 Dest_DevName, struc_Unify_Info *LnkUnifyInfo); + + +/****************************************************************************************** +* : ΪЭṩ·ɾڵIJɾ·ָڵ + 1. Эô˺ɾָָ· +* : struc_Lnk_Mngr *chIndex Ҫɾڵָ +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1󷵻0 +*******************************************************************************************/ +UINT8 DelLnk(struc_Lnk_Mngr *chIndex, struc_Unify_Info *LnkUnifyInfo); + + +/****************************************************************************************** +* : ָ·ľ̬ñϢΪ·Ϣ + 1. ·ľ̬ñϢ㱨ĵı/Էıijʱ + 2. ·ľ̬ñϢݱĵijʱACKĵijʱ +* : struc_LnkBasicInfo* lnk_basic_info ̬ñб·Ϣ洢ṹ +* : +* : UINT16* localwidth ijʱ + UINT16* destwidth Էijʱ + UINT16* datatimeoutnum ݱʱ + UINT16* acktimeoutnum ACKʱ +* ȫֱ : +* ֵ : +*******************************************************************************************/ +void GetLnkMngValue(struc_LnkBasicInfo *lnk_basic_info,UINT16 *localwidth,UINT16 *destwidth,UINT16 *datatimeoutnum,UINT16 *acktimeoutnum); + + + +/****************************************************************************************** +* : ʷϢ±ͨͨ·ڲ,ƽ̨Ӧòɼ +* : UINT8 *Input_Data_LnkMes ͷָ +* : struc_Lnk_Mngr *CurLnk ·ͷָ +* : +* ȫֱ : +* ֵ : 1쳣0 +*******************************************************************************************/ +static UINT8 FillLnkMngr_from_HISTORY(UINT8 *Input_Data_LnkMes,struc_Lnk_Mngr *CurLnk); + +#ifdef __cplusplus +} +#endif + +#else + +#endif + + + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclCommon.c b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclCommon.c new file mode 100644 index 0000000..851e30d --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclCommon.c @@ -0,0 +1,433 @@ + +/******************************************************************************* +* ļ sfpPrtclCommon.c +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* ļΪЭ鹫ļջغType + ID豸ת + صǰʱTick +* ʹע + +* ޸ļ¼ + 2009-8-27 15:01:23޸ļ¼ + 1.޸ͣʹCommonTypes.hеĶ + ޸ıǩpeipei.wang20111011 + ޸ݣIsTimeOut.C +*******************************************************************************/ + +#include "stdlib.h" +#include "CommonMemory.h" +#include "sfpPrtclCommon.h" + +/****************************************************************************************** +* : 豸TYPE豸IDתlong͵豸 +* : UINT8 devType 豸 +* UINT8 devID 豸ID +* : +* : +* ȫֱ : +* ֵ : unsigned INT32 ͵豸 +*******************************************************************************************/ +UINT32 TypeIdToName(UINT8 devType,UINT8 devID)/* %RELAX */ +{ + UINT32 Templong; + Templong = 0; + Templong = devType; + Templong = (Templong*0x100) + devID; + Templong = Templong*0x10000 ; + return Templong; +} + + +/****************************************************************************************** +* : صǰʱ̵ĺ +* Բͬƽ̨вͬĴ +* Windowsƽ̨ͨúGetCurTime()ȡǰʱ +* VxWorksƽ̨ƽ̨ṩǰʱֵָ +* : struct Unify_Info *pUnifyInfo ƽ̨ͳһṹ +* : +* : +* ȫֱ : +* ֵ : ǰʱ +*******************************************************************************************/ +UINT32 GetTick(struc_Unify_Info *pUnifyInfo)/* %RELAX */ +{ +#if CBTC_WINDOWS + return GetCurTime(Time_StartPoint); +#else + return *(pUnifyInfo->TimeCounter); +#endif +} + + + +/************************************************************************/ +/* ջĹò */ +/************************************************************************/ + +/****************************************************************************************** +* : Ӷջеһڵ,ֵΪһָϢʱֻҪֵǿתɶӦͼ +* : StackElement* s ջָ +* : +* : +* ȫֱ : +* ֵ : ɹһڵ㷵ؽڵĵַ򷵻0 +*******************************************************************************************/ +void* PopStack(StackElement *s)/* %RELAX */ +{ + void* ret; + /*ջҪջԽ*/ + if(s->size > 0)/*ջС0,ʱԵڵ.*/ + { + return s->pNode[--(s->size)];/*ջһλΪոͷŵĽڵ*/ + } + else + { + ret = NULL; + return ret;/*޷ڵ*/ + } +} + + +/****************************************************************************************** +* : ջѹһڵ,ֵΪѹɹ򷵻1򷵻0 +* : StackElement* s ջָ +* UINT32 node ڵָ +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 PushStack(StackElement *s,void* node)/* %RELAX */ +{ + UINT8 ret; + + /*ѹջҪջΪ*/ + if(s->size < s->totalsize)/*ջССڶջֵʱѹڵ*/ + { + s->pNode[s->size++] = node;/*ѹջ*/ + ret = 1; + return ret; + } + else/*ջСڶջֵ,ѹջ.*/ + { + ret = 0; + return ret;/*޷ѹڵ*/ + } +} + +/****************************************************************************************** +* : ʼһάڵջ +* ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +* : StackElement* s ջָ +* UINT16 DataSize ڵݴ洢ռĴС +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 Init_InputBuffer_Stack(StackElement *s, UINT16 DataSize)/* %RELAX */ +{ + UINT16 i;/*ѭ*/ + struc_InputBuffer *InputBufferNodeTemp; + UINT8 ret; + + InputBufferNodeTemp = NULL; + s->size = 0;/*ʼջΪ*/ + for(i = 0;i < s->totalsize;i++) + { + s->pNode[i] = 0;/*ԸֵΪָ룬൱Ӧڴ*/ + } + InputBufferNodeTemp = (struc_InputBuffer *)malloc(sizeof(struc_InputBuffer)*(s->totalsize)); + if(InputBufferNodeTemp == NULL) + { + /*ӡӡ*/ + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(InputBufferNodeTemp,sizeof(struc_InputBuffer)*(s->totalsize),0,sizeof(struc_InputBuffer)*(s->totalsize)); + } + for (i = 0;i < s->totalsize;i++) + { + InputBufferNodeTemp[i].data = NULL; + InputBufferNodeTemp[i].data = (UINT8*) malloc(DataSize); + if(InputBufferNodeTemp[i].data == NULL) + { + /*ӡӡ*/ + ret = 0; + return ret; + } + else + { + CommonMemSet(InputBufferNodeTemp[i].data,DataSize,0,DataSize); + } + /*ѹtotalsizeڵ*/ + if(PushStack(s,&InputBufferNodeTemp[i]) != 1) + { + ret = 0; + return ret; + } + else + {} + } + s->pFirstNode = InputBufferNodeTemp; + ret = 1; + return ret; +} + + +/****************************************************************************************** +* : ʼ·ջ +* ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +* : StackElement* s ջָ +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 init_Lnk_Mngr_stack(StackElement *s)/* %RELAX */ +{ + UINT16 i;/*ѭ*/ + struc_Lnk_Mngr *Lnk_Mngr_stack = NULL; + UINT8 ret; + + s->size = 0;/*ʼջΪ*/ + for(i = 0;i < s->totalsize;i++) + { + s->pNode[i] = 0;/*ԸֵΪָ룬൱Ӧڴ*/ + } + + Lnk_Mngr_stack = (struc_Lnk_Mngr *)malloc(sizeof(struc_Lnk_Mngr) * s->totalsize); + if(Lnk_Mngr_stack == NULL) + { + /*ӡӡ*/ + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(Lnk_Mngr_stack,sizeof(struc_Lnk_Mngr) * s->totalsize,0,sizeof(struc_Lnk_Mngr) * s->totalsize); + } + for (i = 0;i < s->totalsize;i++) + { /*ѹtotalsizeڵ*/ + if(PushStack(s,&Lnk_Mngr_stack[i]) != 1) + { + /*printf("Push Stack Error!\n");*/ + ret = 0; + return ret;/*ѹڵʧ*/ + } + else + { + /*printf("Success Pushed One Node!\n");*/ + } + } + s->pFirstNode = Lnk_Mngr_stack; + ret = 1; + return ret; +} + + +/****************************************************************************************** +* : ʼЭջ +* ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +* : StackElement* s ջָ +* UINT16 DataSize ڵݴ洢ռĴС +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 InitOutputStack(StackElement *s,UINT16 DataSize)/* %RELAX */ +{ + UINT16 i;/*ѭ*/ + struc_OutputDataBuff *OutputDataBuff = NULL; + UINT8 ret; + + s->size = 0;/*ʼջΪ*/ + for(i = 0;i < s->totalsize;i++) + { + s->pNode[i] = 0;/*ԸֵΪָ룬൱Ӧڴ*/ + } + OutputDataBuff = (struc_OutputDataBuff *)malloc(sizeof(struc_OutputDataBuff)*s->totalsize); + + if(OutputDataBuff == NULL) + { + /*ӡӡ*/ + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(OutputDataBuff,sizeof(struc_OutputDataBuff)*s->totalsize,0,sizeof(struc_OutputDataBuff)*s->totalsize); + } + + for (i = 0;i < s->totalsize;i++) + { /*ѹtotalsizeڵ*/ + OutputDataBuff[i].chData = NULL; + OutputDataBuff[i].chData = (UINT8*) malloc(DataSize); + if(OutputDataBuff[i].chData == NULL) + { + /*ӡӡ*/ + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(OutputDataBuff[i].chData,DataSize,0,DataSize); + } + if(PushStack(s,&OutputDataBuff[i]) != 1) + { + /*printf("Push Stack Error!\n");*/ + ret = 0; + return ret;/*ѹڵʧ*/ + } + else + { + /*printf("Success Pushed One Node!\n");*/ + } + } + + s->pFirstNode = OutputDataBuff; + + ret = 1; + return ret; +} + + + +/****************************************************************************************** +* : ͷջ̬Ŀռ [·ӦĶջӦĶջԪӦĶջ] +* : struc_Unify_Info *pUnifyInfo ҪͷſռӦͳһṹ +* : +* : +* ȫֱ : +* ֵ : ɹ1 +*******************************************************************************************/ +UINT8 FreeLnkSpace(struc_Unify_Info *pUnifyInfo)/* %RELAX */ +{ + INT32 i; + struc_InputBuffer *pInputBuffer; + struc_OutputDataBuff *pOutputDataBuff; + UINT8 ret; + + /*ͷĿռ*/ + for(i = 0; i < pUnifyInfo->InputStack.totalsize; i++) + { + /*ջΪջջĽڵΪֱ˳*/ + if (NULL == (void *)pUnifyInfo->InputStack.pFirstNode) /*ﱾӦòpNode[i]ǷѾռˣpNodeڳͿܲδ洢ռ׵ַ*/ + { + break; + } + else + { + /*޲*/ + } + pInputBuffer = (struc_InputBuffer*) pUnifyInfo->InputStack.pNode[i]; + if(pInputBuffer->data != NULL) + { + free((void *) pInputBuffer->data); + pInputBuffer->data = NULL; + } + else + { + /*޲*/ + } + } + + if (NULL != (void *)pUnifyInfo->InputStack.pFirstNode) /*FirstNodeǶջڴ洢ڵַٵĿռ׵ַ*/ + { + free((void*)pUnifyInfo->InputStack.pFirstNode); + pUnifyInfo->InputStack.pFirstNode = (UINT32)NULL; + } + else + { + /*޲*/ + } + + /*ͷ·ռ*/ + if (NULL != (void *)pUnifyInfo->LnkStack.pFirstNode) /*FirstNodeǶջڴ洢ڵַٵĿռ׵ַ*/ + { + free((void *)pUnifyInfo->LnkStack.pFirstNode); + pUnifyInfo->LnkStack.pFirstNode = (UINT32)NULL; + } + else + { + /*޲*/ + } + + /*ͷĿռ*/ + for(i = 0; i < pUnifyInfo->OutputStack.totalsize; i++) + { + /*ջΪջջĽڵΪֱ˳*/ + if (NULL == (void *)pUnifyInfo->OutputStack.pFirstNode) + { + break; + } + else + { + /*޲*/ + } + pOutputDataBuff = (struc_OutputDataBuff*) pUnifyInfo->OutputStack.pNode[i]; + if(pOutputDataBuff->chData != NULL) + { + free((void *)pOutputDataBuff->chData); + pOutputDataBuff->chData = NULL; + } + else + { + /*޲*/ + } + } + if (NULL != (void *)pUnifyInfo->OutputStack.pFirstNode) /*FirstNodeǶջڴ洢ڵַٵĿռ׵ַ*/ + { + free((void*)pUnifyInfo->OutputStack.pFirstNode); + pUnifyInfo->OutputStack.pFirstNode = (UINT32)NULL; + } + else + { + /*޲*/ + } + + ret = 1; + return ret; +} + +/* +* : жǷʱ,жϵǰʱ뿪ʼʱʱֵСʱ䡣 +* : UINT32 Curtime ǰʱ + UINT32 StartTime ʼʱ + UINT32 AllowTimeout ijʱʱ +* : +* : +* ȫֱ : +* ֵ : 0: ʱ 0xff:ǰʱСڿʼʱ䣬ֵʱ +*/ +UINT8 IsTimeOut(UINT32 Curtime,UINT32 StartTime,UINT32 AllowTimeout) +{ + UINT8 ret = 0; + INT32 spdTime = 0; + spdTime = (INT32)(Curtime - StartTime); /* ʱֵ */ + if(spdTime < 0) + { + ret = (UINT8)0xFF; + } + else if((UINT32)spdTime < AllowTimeout) + { + ret = (UINT8)0; + } + else + { + ret = (UINT8)1; + } + + return ret; +} + + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclCommon.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclCommon.h new file mode 100644 index 0000000..1f93466 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclCommon.h @@ -0,0 +1,152 @@ + +/******************************************************************************* +* ļ sfpPrtclCommon.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* ļΪЭ鹫ļͷļջغType + ID豸ת + صǰʱTick +* ʹע + +* ޸ļ¼ + 2009-8-27 15:01:23޸ļ¼ + 1.޸ͣʹCommonTypes.hеĶ + ޸ıǩpeipei.wang20111011 + ޸ݣIsTimeOut.h +*******************************************************************************/ + + +#ifndef _SFPPRTCLCOMMON_H_ +#define _SFPPRTCLCOMMON_H_ + +#include "sfpplatform.h" +#include "Convert.h" +#include "CommonTypes.h" +#include "CommonRecord.h" +#if CBTC_WINDOWS + #include "sfpWindowsTimeCounter.h" +#endif +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************** +* : ʼ·ջ +* ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +* : StackElement* s ջָ +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 init_Lnk_Mngr_stack(StackElement *s); + + +/****************************************************************************************** +* : ʼһάڵջ +* ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +* : StackElement* s ջָ +* UINT16 DataSize ڵݴ洢ռĴС +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 Init_InputBuffer_Stack(StackElement *s, UINT16 DataSize); + + +/****************************************************************************************** +* : ʼЭջ +* ʼضСضṹĶջ,ͬĽṹֻҪѹ벻ָͬʹ÷ʽɲͬĹջ +* : StackElement* s ջָ +* UINT16 DataSize ڵݴ洢ռĴС +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 InitOutputStack(StackElement *s,UINT16 DataSize); + + +/****************************************************************************************** +* : ͷջ̬Ŀռ [·ӦĶջӦĶջԪӦĶջ] +* : struc_Unify_Info *pUnifyInfo ҪͷſռӦͳһṹ +* : +* : +* ȫֱ : +* ֵ : ɹ1 +*******************************************************************************************/ +UINT8 FreeLnkSpace(struc_Unify_Info *pUnifyInfo); + + +/************************************************************************/ +/* ջĹò */ +/************************************************************************/ + +/****************************************************************************************** +* : ջѹһڵ,ֵΪѹɹ򷵻1򷵻0 +* : StackElement* s ջָ +* UINT32 node ڵָ +* : +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 PushStack(StackElement *s,void* node); + + +/****************************************************************************************** +* : Ӷջеһڵ,ֵΪһָϢʱֻҪֵǿתɶӦͼ +* : StackElement* s ջָ +* : +* : +* ȫֱ : +* ֵ : ɹһڵ㷵ؽڵĵַ򷵻0 +*******************************************************************************************/ +void* PopStack(StackElement *s); + +/****************************************************************************************** +* : صǰʱ̵ĺ +* Բͬƽ̨вͬĴ +* Windowsƽ̨ͨúGetCurTime()ȡǰʱ +* VxWorksƽ̨ƽ̨ṩǰʱֵָ +* : struct Unify_Info *pUnifyInfo ƽ̨ͳһṹ +* : +* : +* ȫֱ : +* ֵ : ǰʱ +*******************************************************************************************/ +UINT32 GetTick(struc_Unify_Info *pUnifyInfo); + + +/****************************************************************************************** +* : 豸TYPE豸IDתlong͵豸 +* : UINT8 devType 豸 +* UINT8 devID 豸ID +* : +* : +* ȫֱ : +* ֵ : unsigned INT32 ͵豸 +*******************************************************************************************/ +UINT32 TypeIdToName(UINT8 devType,UINT8 devID); + + +/* +* : жǷʱ,жϵǰʱ뿪ʼʱʱֵСʱ䡣 +* : UINT32 Curtime ǰʱ + UINT32 StartTime ʼʱ + UINT32 AllowTimeout ijʱʱ +* : +* : +* ȫֱ : +* ֵ : 0: ʱ 0xff:ǰʱСڿʼʱ䣬ֵʱ +*/ +UINT8 IsTimeOut(UINT32 Curtime,UINT32 StartTime,UINT32 AllowTimeout); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclInit.c b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclInit.c new file mode 100644 index 0000000..522ee67 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclInit.c @@ -0,0 +1,460 @@ + +/******************************************************************************* +* ļ PrtclInit.c +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* ļΪЭʼԴļplatform.h +* ʹע + +* ޸ļ¼ + 2008.09.01 + PrtclFreeSpaceڰѳʼж̬ڴռ䶼ͷŵ + + 2009.1.20 + 1.PrtclInitӶCommBufferڴ䣬BlueNetNoDataCycleRedNetNoDataCycleΪ0 + 2.PrtclInitжԴСɾӦҪٿռͿٿռ + 3.PrtclFreeSpaceͷCommBufferĿռ + + 2009-8-27 14:46:00 + 1.ɾPrtclInitPrtclRcvڴ䣬ɾBlueNetNoDataCycleRedNetNoDataCycle0 + 2.޸lTemp = (OutputSize + 49 + 48)* MaxNumLink + 4;4948ֱֵΪЭռֽΪ49 + ·ڵռֽ(οֵΪ48)]ԭΪ58 + 3.ɾProtclFreeSpaceжPrtclRcvڴͷ + 4.޸ͣʹCommonTypes.hеĶ + 2010-2-11 15:13:18 + 1.ʼMaxNumLink = pUnifyInfo->MaxNumLink;ΪMaxNumLink = pUnifyInfo->MaxNumLink + 1; + 2.ʼм¼ռpUnifyInfo->RecordArray = (UINT8*)malloc(pUnifyInfo->RecordArraySize)Ϊ + pUnifyInfo->RecordArray = (UINT8*)malloc(pUnifyInfo->RecordArraySize+2) + + ޸ıǩpeipei.wang20120103 + ޸ݣʼӲfileNameз롣 +*******************************************************************************/ + +/*#include "StdAfx.h"*/ +#include "stdlib.h" +#include "CommonMemory.h" +#include "sfpplatform.h" +#include "sfpPrtclReceive.h" +#include "sfpLinkManage.h" +#include "sfpDeclare.h" +#include "sfpPrtcl_Output.h" +#include "dsuRelatedDeal.h" + + +/****************************************************************************************** +* : Эʼ + 1. ڵô˺֮ǰӦҪͳһṹInputSizeOutputSize,MaxNumLink, + MaxNumPerCycle,OutnetQueueSizeȱֵ +* : UINT8 * fileName ݵļַ +* : UINT32 inDataLen ڲ +* : UINT8 inData[] ڲ +* : struc_Unify_Info* pUnifyInfo Эͳһṹָ +* : +* ȫֱ : +* ֵ : ʼ1򷵻0 +*******************************************************************************************/ +UINT8 ProtclInit(UINT8 *fileName, UINT32 inDataLen, UINT8 inData[], struc_Unify_Info *pUnifyInfo)/* %RELAX */ +{ + UINT16 InputSize; /*ΪԽṹеһЩʵʱ*/ + UINT16 OutputSize; + UINT16 MaxNumLink; + UINT16 MaxNumPerCycle; + UINT32 lTemp; + UINT8 ret = 0; + + if(pUnifyInfo == NULL) + { + ret = 0; + return ret; + } + else + {} + + /* wangpeipei 20120103 Mod S */ + if((fileName != NULL) && (pUnifyInfo->DataBase == NULL)) + { +#ifdef USE_DSU_SFP + ret = dsuSfpInit(fileName, &pUnifyInfo->DataBase); + if (ret == 0) + { + return ret; + } + else + { + /* */ + } +#else + ret = 1; +#endif + } + else if((fileName == NULL) && (pUnifyInfo->DataBase != NULL)) + { + /* */ + } + else + { + return ret; + } + + ret = MergeDataBaseInParam(inDataLen, inData, pUnifyInfo); + if (0u == ret) + { + return ret; + } + + /* wangpeipei 20120103 Mod End */ + /*ͳһṹе4ʱ*/ + InputSize = pUnifyInfo->InputSize; + OutputSize = pUnifyInfo->OutputSize; + MaxNumLink = pUnifyInfo->MaxNumLink + 1; + MaxNumPerCycle = pUnifyInfo->MaxNumPerCycle; + + /*ȸӦøĸ㲢ͳһṹеĶСֵ*/ + /* DataToAppӿڶдС + * ¹ʽЭ㣬ʼ + * [InputSize ÿ֡ݵֽ+ЭռֵֽΪ7]* + * MaxNumLink·*/ + /*Ӧöпռ*/ + lTemp = (InputSize + 7) * MaxNumLink; + pUnifyInfo->DataToAppSize = lTemp; + + + /* OutputDataQueueĴС + * ¹ʽԸֵгʼ + * [OutputSize (ÿ֡ݵֽ)+ЭֵֽΪ6]* + * MaxNumLink· + */ + lTemp = (OutputSize + 6) * MaxNumLink; + pUnifyInfo->OutputDataQueueSize = lTemp; + + /* Э뵥ԪЭ൥ԪijС + * ܿռ = [InputSize ÿ֡ݵֽ+ЭռֵֽΪ15]* + * MaxNumLink·*ÿÿյֵοֵΪ5+ + * ֵֽΪ2 + */ + lTemp = (InputSize + 15) * MaxNumLink* MaxNumPerCycle + 2; + pUnifyInfo->PrtclRcvSize = lTemp; + + /* PrtclSndBuffָĴС + *ܿռ = [OutputSize ÿ֡ݵֽ+ЭռֽΪ49+ + * ·ڵռֽ(οֵΪ48)]* MaxNumLink·+ + * ͷռֽ4.7ֱеģ鳤+鳤0 = 8 + */ + lTemp = (OutputSize + 49 + 4 + LNKFRAMELEN) * MaxNumLink + 8; + pUnifyInfo->PrtclSndBuffSize = lTemp; + + + /**/ + pUnifyInfo->DataAfterReduntancy = NULL; + pUnifyInfo->DataAfterReduntancy =(UINT8*) malloc(pUnifyInfo->PrtclRcvSize); + if(pUnifyInfo->DataAfterReduntancy == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pUnifyInfo->DataAfterReduntancy,pUnifyInfo->PrtclRcvSize,0,pUnifyInfo->PrtclRcvSize); + } + + /*Эڲʹʱռ*/ + lTemp = InputSize + 20; + pUnifyInfo->CommBuffer = (UINT8*)malloc(lTemp); + if (pUnifyInfo->CommBuffer ==NULL) + { + ret =0; + return ret; + } + else + { + CommonMemSet(pUnifyInfo->CommBuffer,lTemp,0,lTemp); + } + + /**/ + pUnifyInfo->PrtclSndBuff = NULL; + pUnifyInfo->PrtclSndBuff = (UINT8*)malloc(pUnifyInfo->PrtclSndBuffSize); + if(pUnifyInfo->PrtclSndBuff == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pUnifyInfo->PrtclSndBuff,sizeof(UINT8)*pUnifyInfo->PrtclSndBuffSize,0,sizeof(UINT8)*pUnifyInfo->PrtclSndBuffSize); + } + +#ifdef SWAP_CRC + lTemp = 2u + 4u * (pUnifyInfo->MaxNumLink + 2u); /*2ֽڳ+·(4ֽĿID+4ֽCRC)*/ + pUnifyInfo->SwapCrcs = (UINT8*)malloc(lTemp); + if (pUnifyInfo->SwapCrcs == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pUnifyInfo->SwapCrcs, sizeof(UINT8) * lTemp, 0, sizeof(UINT8) * lTemp); + } +#endif + + /*¼Ŀռ*/ + pUnifyInfo->RecordArray = NULL; + pUnifyInfo->RecordArray = (UINT8*)malloc(pUnifyInfo->RecordArraySize+2); + if(pUnifyInfo->RecordArray == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pUnifyInfo->RecordArray,sizeof(UINT8)*(pUnifyInfo->RecordArraySize+2),0,sizeof(UINT8)*(pUnifyInfo->RecordArraySize+2)); + } + + + /*·ջռ*/ + pUnifyInfo->LnkStack.pNode = NULL; + pUnifyInfo->LnkStack.pNode = (void**)malloc(MaxNumLink * sizeof(void*)); + pUnifyInfo->LnkStack.totalsize = (UINT16) MaxNumLink; + if(pUnifyInfo->LnkStack.pNode == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pUnifyInfo->LnkStack.pNode,MaxNumLink * sizeof(void*),0,MaxNumLink * sizeof(void*)); + } + + /*ջռ*/ + pUnifyInfo->OutputStack.pNode = NULL; + pUnifyInfo->OutputStack.pNode = (void**)malloc(MaxNumLink * sizeof(void*)); + pUnifyInfo->OutputStack.totalsize = (UINT16) MaxNumLink; + if(pUnifyInfo->OutputStack.pNode == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pUnifyInfo->OutputStack.pNode,MaxNumLink * sizeof(void*),0,MaxNumLink * sizeof(void*)); + } + + /*ջռ*/ + pUnifyInfo->InputStack.pNode = NULL; + pUnifyInfo->InputStack.pNode = (void**)malloc((UINT16)MaxNumLink * MaxNumPerCycle * sizeof(void*)); + pUnifyInfo->InputStack.totalsize = (UINT16) MaxNumLink * MaxNumPerCycle; + if(pUnifyInfo->InputStack.pNode == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pUnifyInfo->InputStack.pNode,MaxNumLink * MaxNumPerCycle* sizeof(void*),0,MaxNumLink * MaxNumPerCycle* sizeof(void*)); + } + + pUnifyInfo->NetsRecvPkgNums = (SfpNetsRecvPkgNum*)malloc(sizeof(SfpNetsRecvPkgNum) * pUnifyInfo->MaxNumLink); + if (NULL == pUnifyInfo->NetsRecvPkgNums) + { + ret = 0; + return ret; + } + else + { + CommonMemSet(pUnifyInfo->NetsRecvPkgNums, sizeof(SfpNetsRecvPkgNum) * pUnifyInfo->MaxNumLink, 0, sizeof(SfpNetsRecvPkgNum) * pUnifyInfo->MaxNumLink); + } + + /*Ϣṹռ*/ + lTemp = dsuGetObjNum(pUnifyInfo); /*ݿнڵ*/ + pUnifyInfo->NumBuildLink = NULL; + pUnifyInfo->NumBuildLink = (DuanLianInfo*) malloc(lTemp * sizeof(DuanLianInfo)); + if(pUnifyInfo->NumBuildLink == NULL) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + CommonMemSet(pUnifyInfo->NumBuildLink,lTemp * sizeof(DuanLianInfo),0,lTemp * sizeof(DuanLianInfo)); + } + + if(!InitLnkMngr(pUnifyInfo)) /*ͨ·ʼ*/ + { +#ifdef _DEBUG_ + printf("InitLnkMngr error\n"); +#endif + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + if(!RedundancyInitial(pUnifyInfo)) /*ͨദʼ*/ + { +#ifdef _DEBUG_ + printf("RedundancyInitial error\n"); +#endif + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + if(!Prtcl_RecInitial(pUnifyInfo)) /*ͨЭʼ*/ + { +#ifdef _DEBUG_ + printf("Prtcl_RecInitial error\n"); +#endif + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + if(!Prtcl_OutputInitial(pUnifyInfo)) /*ͨЭʼ*/ + { +#ifdef _DEBUG_ + printf("Prtcl_OutputInitial error\n"); +#endif + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + ret = 1; + return ret; +} + + +/****************************************************************************************** +* : ͷЭPrtclInitзڴռ +* : +* : struc_Unify_Info* pUnifyInfo Эͳһṹָ +* : +* ȫֱ : +* ֵ : ȷ1 +*******************************************************************************************/ +UINT8 ProtclFreeSpace(struc_Unify_Info *pUnifyInfo)/* %RELAX */ +{ + UINT8 ret = 0; + + if(pUnifyInfo == NULL) + { + return ret; + } + else + {} + + /*ͷŵռ䣺飬ݴ飬飬¼*/ + if(pUnifyInfo->DataAfterReduntancy != NULL) + { + free((void *) pUnifyInfo->DataAfterReduntancy); + pUnifyInfo->DataAfterReduntancy = NULL; + } + else + { + /*޲*/ + } + + if(pUnifyInfo->CommBuffer != NULL) + { + free((void *) pUnifyInfo->CommBuffer); + pUnifyInfo->CommBuffer = NULL; + } + else + { + /*޲*/ + } + + if(pUnifyInfo->PrtclSndBuff != NULL) + { + free((void *) pUnifyInfo->PrtclSndBuff); + pUnifyInfo->PrtclSndBuff = NULL; + } + else + { + /*޲*/ + } + + if(pUnifyInfo->RecordArray != NULL) + { + free((void *) pUnifyInfo->RecordArray); + pUnifyInfo->RecordArray = NULL; + } + else + { + /*޲*/ + } + + /*ͷŶջ鼰ӦĽڵݿռ䣺·ջռ䣬ջռ䣬ջռ*/ + FreeLnkSpace(pUnifyInfo); + + if(pUnifyInfo->LnkStack.pNode != NULL) + { + free((void *) pUnifyInfo->LnkStack.pNode); + pUnifyInfo->LnkStack.pNode = NULL; + } + else + { + /*޲*/ + } + + if(pUnifyInfo->OutputStack.pNode != NULL) + { + free((void *) pUnifyInfo->OutputStack.pNode); + pUnifyInfo->OutputStack.pNode = NULL; + } + else + { + /*޲*/ + } + + if(pUnifyInfo->InputStack.pNode != NULL) + { + free((void *) pUnifyInfo->InputStack.pNode); + pUnifyInfo->InputStack.pNode = NULL; + } + else + { + /*޲*/ + } + + /*ͷŶеĿռ*/ + QueueElementFree(&pUnifyInfo->OutnetQueueA); + QueueElementFree(&pUnifyInfo->OutnetQueueB); + QueueElementFree(&pUnifyInfo->OutputDataQueue); + QueueElementFree(&pUnifyInfo->DataToApp); + + /*ͷ͵Ĵ洢ռ*/ + if(pUnifyInfo->NumBuildLink != NULL) + { + free((void *) pUnifyInfo->NumBuildLink); + pUnifyInfo->NumBuildLink = NULL; + } + else + { + /*޲*/ + } + + ret = 1; + return ret; +} diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclReceive.c b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclReceive.c new file mode 100644 index 0000000..0b6b2f9 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclReceive.c @@ -0,0 +1,2383 @@ + +/******************************************************************************* +* ļ sfpPrtclReceive.c +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* Э뵥ԪԴļ +* ʹע + +* ޸ļ¼ + ԭģ޸ļ¼: + 2008.7.8 + 1.ɾextern SEM_ID semC_Innet_to_OutnetԼwindowsµInnernet_RevQueue_Counterź + 2.ɾͳһṹڵȫֱ + 3.ɾwindows¼¼ļرԼ + + 2008.7.12 ޸ļ¼ + 1. Rcv޸ģЭ鹲ûPrtclCommBuffer + + 2008.08.21 ޸ļ¼ + 1ڶеһ֡ݳ֮ǰӦȷ󳤶ȣЭ齫ݶٴһֱ֡ݶ + 2кͶջijʼ˱仯˳ȵIJ + + 2009.1.20޸ļ¼ + 1.ֱд + 2.ڵֽڳȸΪĸֽ + 3.ڵֽܳȸΪĸֽ + 4.޸InsertNodeӲ + + 2009-9-21 10:08:30 + 1.֡ʽֽڣʾдݵܳȣӦ޸RedundancyReceiveɨȽбȽϣ + ж϶еǷɶĺôDzƻеĽṹΪұֻһж裩; Ȼ + ʱȶȶٶһ֡ݣΪԭг򲻱䣬ĶС + + ԭģ޸ļ¼ + 2008.7.11 ޸ļ¼ + 1. ɾNum_NoData; + 2. CommBufferָЭ鹫õĻPrtclCommBuffer + 3. FindNewestFrameӺеʱNewArrayָЭ鹫õĻPrtclCommBuffer + + 2008.7.25 ޸ļ¼ + 1. ʱCRC鷢뵥ԪRfc֡һ֧УûаRFCʼкŴ·С + RFCʼкŵĸֵ䣻 + + 2008.7.28 ޸ļ¼ + 1.еĺBuildNode_Rec()ֲģУ + + 2009.1.20޸ļ¼ + 1.FindNewtestFrameӲÿ֡ + 2.ɾ·Уȡ֡ + 3.ʱͳһṹ + 4.ijȸΪ4ֽ + 5.дӦöгȸΪ4ֽ + + 2010-2-11 11:21:36 + 1.޸Ķļ¼ʽɾʱļ¼TypeIDλãTypeǰIDں + 2.ݳȴ򳤶ȳĴQueueElementDiscardʵ + + ޸ıǩpeipei.wang20111011 + ޸ݣ1ȫֱAbsTimeoutPointForRedunɾ¶startTimePointForRedunദʼʱ䣩ͨGetTick(pUnifyInfoForRedun)ã + 2ԭʱжϴʱ䷴תΪǰʱ- ģ鿪ʼʱ < ģִʱޣ + + ޸ıǩpeipei.wang20120522 + ޸ݣ1 Prtcl_ReceiveеUINT16 b޸ΪUINT33 b; +*******************************************************************************/ + +#include "sfpPrtclReceive.h" +#include "CommonMemory.h" + +static void ClearNetsRecvPkgNum(struc_Unify_Info* sfp); +static void SetNetsRecvPkgNum(struc_Unify_Info* sfp, const UINT32 dstDevName, const UINT8 netIdx); + +/* peipei.wang20111011 mod S */ +/* ɾԳʱʱ㣬׷Ӷ봦ʼʱ */ +/* static UINT32 AbsTimeoutPointForRedunn; */ /*Գʱʱ*/ +/* peipei.wang20111011 mod E */ +/****************************************************************************************** +* : Э뺯 +* : +* : struc_Unify_Info* pUnifyInfo Эͳһṹָ +* : +* ȫֱ : +* ֵ : ȷ1󷵻0 +*******************************************************************************************/ +UINT8 ProtclReceive(struc_Unify_Info *pUnifyInfo)/* %RELAX */ +{ + UINT8 ret = 0; + + if(pUnifyInfo == NULL) + { + return ret; + } + else + {} + + if(Redundancy(pUnifyInfo)!=1) + { + ret = 0; + return ret; + } + if(Prtcl_Receive(pUnifyInfo)!=1) + { + ret = 0; + return ret; + } + ret = 1; + return ret; +} + +/******************************************************************************** +Эദ +********************************************************************************/ + +/****************************************************************************************** +* : Redundancy()ЭģһݵĴ + úְһӺȡݲദĺRedundancyReceive() +* : +* : struc_Unify_Info *pUnifyInfo ͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 Redundancy(struc_Unify_Info *pUnifyInfo) +{ + UINT8 ret; + + /* peipei.wang20111011 mod S */ + /*ɾԳʱʱ㣬׷ӻȡദʼʱ*/ + /*AbsTimeoutPointForRedun = GetTick(pUnifyInfoForRedun) + pUnifyInfoForRedun->RedundTimeout;*/ + /* peipei.wang20111011 mod E */ + + /*ڿʼѼ¼鳤*/ + pUnifyInfo->RecordArray[0] = 0; + pUnifyInfo->RecordArray[1] = 0; +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"Cycle:"); + PrintFileU32Int(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,*pUnifyInfo->CycleNum); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"ChkNet:"); + PrintFileU32Int(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,(UINT32)0); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"LName:"); + PrintFileHex(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,&pUnifyInfo->LocalType,1); + PrintFileU32Int(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,(UINT32)pUnifyInfo->LocalID); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"\n"); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"RNet:"); + PrintFileU32Int(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,(UINT32)QueueStatus(&pUnifyInfo->OutnetQueueA)); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize," "); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"\n"); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"BNet:"); + PrintFileU32Int(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,(UINT32)QueueStatus(&pUnifyInfo->OutnetQueueB)); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize," "); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"\n"); +#endif + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + /*࿪ʼ*/ + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"Redun: "); +#endif +#ifdef PRTCL_RECORD_DATA_ASC + /*ǰTickĿǰ¼Ϊ㣬Ϊƽ̨޷뼶ͬ*/ + PrintFileU32Int(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,(UINT32)0); +#endif +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize," "); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"LName:"); + PrintFileHex(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,&pUnifyInfoForRedun->LocalType,1); + PrintFileU32Int(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,(UINT32)pUnifyInfoForRedun->LocalID); + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"\n"); +#endif + +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + /*ڿʼ־*/ + PrintRecArrayByte(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,0xff); + /*ǰں*/ + PrintRecArray2ByteB(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,((UINT16)*(pUnifyInfo->CycleNum))); +#endif + +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + /*ֱӡ뵥Ԫʼ־ǰʱ䣬IDType*/ + PrintRecArrayByte(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,0x02); + PrintRecArrayByte(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,pUnifyInfo->LocalType); + PrintRecArrayByte(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,pUnifyInfo->LocalID); +#endif + + /********************** + ݣദ + ***********************/ + RedundancyReceive(pUnifyInfo); + + +#ifdef PRTCL_RECORD_DATA_ASC + /*ӡദʱ*/ + PrintFiles(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,"Redan Over:"); + PrintFileU32Int(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,(UINT32)0); + PrintFilec(pUnifyInfo->RecordArray,pUnifyInfo->RecordArraySize,'\n'); +#endif + + ret = 1; + return ret; +} + + +/****************************************************************************************** +* : Эദijʼ +* : +* : struc_Unify_Info *pUnifyInfo ͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 RedundancyInitial(struc_Unify_Info *pUnifyInfo) +{ + UINT32 i; + UINT8 ret; + + /*ͨ·ͷڵ*/ + pUnifyInfo->InputBufferHead = NULL; + + /*ʼģij*/ + for(i = 0;i < 2;i++) + { + pUnifyInfo->DataAfterReduntancy[i] = 0; + } + + /*·ڵ洢ռ*/ + if(!Init_InputBuffer_Stack(&pUnifyInfo->InputStack, (UINT16)(pUnifyInfo->InputSize+15))) + { + /*¼¼*/ + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + /*ദгʼ*/ + if(!QueueInitial(&pUnifyInfo->OutnetQueueA,(UINT32) pUnifyInfo->OutnetQueueSize)) + { + /*¼¼*/ + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + if(!QueueInitial(&pUnifyInfo->OutnetQueueB,(UINT32) pUnifyInfo->OutnetQueueSize)) + { + /*¼¼*/ + ret = 0; + return ret; + } + else + { + /*޲*/ + } + + ret = 1; + return ret; +} + +/****************************************************************************************** +* : ݣദ Redundancy()е + 1Ӷжÿһ֡ + 2жϱԷ߼ַǷϷ + 3жCRCǷȷ + 4жϱ͡ + 5յRFC֡·ڣ·жϸRFCǷϷڣһά + 6յACK֡ͨ·жϸACKǷϷϷͨһάжǷ֡ + 7յDATA֡ͨ·жϸDATAǷϷϷͨһάжǷ֡ +* : +* : +* : +* ȫֱ : static struc_Lnk_Mngr *CurIndex_Lnk_Mngr = NULL; ǰ·еָ +* static StackElement *PointStack = NULL; ָһάڵջָ +* static UINT8 *Rcv = NULL; յÿ֡ݳ +* static struc_Unify_Info *pUnifyInfoForRedun; ģƽ̨ṹָ룬ģõƽ̨ṹָĶôָ +* static UINT32 AbsTimeoutPointForRedun; Գʱʱ +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ + +/* +*: RedundancyReceive +*: ݣദ +* 1Ӷжÿһ֡ +* 2жϱԷ߼ַǷϷ +* 3жCRCǷȷ +* 4жϱ͡ +* 5յRFC֡·ڣ·жϸRFCǷϷڣһά +* 6յACK֡ͨ·жϸACKǷϷϷͨһάжǷ֡ +* 7յDATA֡ͨ·жϸDATAǷϷϷͨһάжǷ֡ +*: struc_Unify_Info *pUnifyInfoForRedun SFPṹ +*: +*: +*ֵ: 1:ɹ;0ʧ +*/ +static UINT16 RedundancyReceive(struc_Unify_Info *pUnifyInfoForRedun) +{ + UINT32 DestSN; + UINT32 LocalSN;/*ԷSNSN*/ + UINT8 Dest_SN[4]; + UINT8 Local_SN[4];/*ԷSN顢SN*/ + UINT32 DestDevNameInFrame; + UINT32 LocalDevNameInFrame;/*ԷIDID*/ + UINT8 len[4];/*QueueScanӶõÿһ֡ij飬ڸ*/ + UINT16 lenthofRcvA; + UINT16 lenthofRcvB;/*յÿ֡ݵij(len[2]ַתõ)*/ + UINT16 FrameLenthOfRcvA; + UINT16 FrameLenthOfRcvB;/*ͨſдĴյĵ֡ܳ*/ + UINT8 Link_Role;/*·ɫ*/ + UINT16 i; + UINT16 ret; + + struc_InputBuffer *p_temp; /*ָһάʱָ*/ + + /*0x0F---(A)пɶ0xF0(B)пɶ + *0xFF---˫ɶ0x00ɶֵ0x00*/ + UINT8 QueueAvailable; + + /*0x55---ǰһζȡǺ(A)У0xAAǰһζ + *ȡ(B)гʼĬϵǺмֵ0x55*/ + UINT8 QueueReadFlag; + /*öжȡķֵ洢*/ + UINT8 RVQueueRead; + UINT8 RcvQueueReadLenth; + + UINT32 LocalDevName; + + UINT8 ToBeContinue = 0; + + StackElement *PointStack = &pUnifyInfoForRedun->InputStack; /*һάָջ*/ + UINT32 startTimePointForRedun = GetTick(pUnifyInfoForRedun); /*ȡദʼʱ*/ + struc_Lnk_Mngr *CurIndex_Lnk_Mngr = NULL; /*ǰ·еָ*/ + UINT8 *Rcv = pUnifyInfoForRedun->DataAfterReduntancy; /*RcvָЭ鹲û*/ + + /*ֲʼ*/ + DestSN = 0; + LocalSN = 0; + lenthofRcvA = 0; + lenthofRcvB = 0; + QueueAvailable = 0; + QueueReadFlag = 0x55; + RVQueueRead = 0xFF; + LocalDevName = TypeIdToName(pUnifyInfoForRedun->LocalType,pUnifyInfoForRedun->LocalID); + + ClearNetsRecvPkgNum(pUnifyInfoForRedun); + + while(1) + { + /* peipei.wang20111011 mod S */ + /*ɾԭʱжϣ׷ӵǰʱ - ദʼʱģִʱ޵ж*/ + /*if(GetTick(pUnifyInfoForRedun) < AbsTimeoutPointForRedun)*/ + if(IsTimeOut(GetTick(pUnifyInfoForRedun),startTimePointForRedun,pUnifyInfoForRedun->RedundTimeout) == 0 ) + /* peipei.wang20111011 mod E*/ + { + /*QueueScanɨ֡ij*/ + if(PointStack->size != 0)/*нڵ*/ + { + QueueAvailable = 0; /*пñ־*/ + + /*Ϊ֡ʽı䣬ԭ֡ʽǰ֡ȣҪȶֽ*/ + /*жϺǷ*/ + /*if(QueueStatus(&pUnifyInfoForRedun->OutnetQueueA) > 2)*/ /*õݳʣ2ֽ*/ + if(QueueScan(4,len,&pUnifyInfoForRedun->OutnetQueueA) != 0) /*ɨȣ4ֽ*/ + { + FrameLenthOfRcvA = ShortFromChar(len); /*֡ܳ*/ + + lenthofRcvA = ShortFromChar(&len[2]);/*֡ij*/ + + if(((FrameLenthOfRcvA - 2) != lenthofRcvA)||(lenthofRcvA < 21))/*Զһڵ*/ + { +#ifdef PRTCL_RECORD_ERR_ASC + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_INTEGRITY); + /*¼¼*/ +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_INTEGRITY); +#endif + + /*FrameLenthOfRcvA+2ֽݴӶж´ζȡ*/ + QueueElementDiscard( (UINT16)(FrameLenthOfRcvA+2), &pUnifyInfoForRedun->OutnetQueueA); + + ToBeContinue = 1; /*ֱӽһεĶȡѭ*/ + } + else if(lenthofRcvA > (pUnifyInfoForRedun->InputSize + 21)) + { + /*յݳ,ǴӶж֡ݣһ֡Ķȡ*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|OUTNETDATA_TOO_LONG|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize," RedNet "); + PrintFileU32Int(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + lenthofRcvA); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|OUTNETDATA_TOO_LONG|ERROR_NULL); +#endif + + /*FrameLenthOfRcvA+2ֽݴӶж´ζȡ*/ + QueueElementDiscard( (UINT16)(FrameLenthOfRcvA+2), &pUnifyInfoForRedun->OutnetQueueA); + + ToBeContinue = 1; /*ֱӽһεĶȡѭ*/ + } + else + { + QueueAvailable |= 0x0F; /*пñ־*/ + } + } + else + { + /*޲*/ + } + + /*жǷ*/ + /*if(QueueStatus(&pUnifyInfoForRedun->OutnetQueueB) > 2)*/ /*õݳʣ2ֽ*/ + if(QueueScan(4,len,&pUnifyInfoForRedun->OutnetQueueB) != 0) /*ɨȣ4ֽ*/ + { + FrameLenthOfRcvB = ShortFromChar(len); /*֡ܳ*/ + + lenthofRcvB = ShortFromChar(&len[2]);/*֡ij*/ + + if(((FrameLenthOfRcvB - 2) != lenthofRcvB)||(lenthofRcvB < 21))/*Զһڵ,ĺôDzƻеĽṹ*/ + /*if(QueueStatus(&pUnifyInfoForRedun->OutnetQueueB) < (lenthofRcvB + 2))*/ + { +#ifdef PRTCL_RECORD_ERR_ASC + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_INTEGRITY); + /*¼¼*/ +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_INTEGRITY); +#endif + + /*FrameLenthOfRcvB+2ֽݴӶж´ζȡ*/ + QueueElementDiscard( (UINT16)(FrameLenthOfRcvB+2), &pUnifyInfoForRedun->OutnetQueueB); + + ToBeContinue = 1; /*ֱӽһεĶȡѭ*/ + } + else if(lenthofRcvB > (pUnifyInfoForRedun->InputSize + 21)) + { + /*¼¼յݳ*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|OUTNETDATA_TOO_LONG|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize," BlueNet "); + PrintFileU32Int(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + lenthofRcvB); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|OUTNETDATA_TOO_LONG|ERROR_NULL); +#endif + + + /*FrameLenthOfRcvB+2ֽݴӶж´ζȡ*/ + QueueElementDiscard((UINT16)(FrameLenthOfRcvB+2), &pUnifyInfoForRedun->OutnetQueueB); + + ToBeContinue = 1; /*ֱӽһεĶȡѭ*/ + } + else + { + QueueAvailable |= 0xF0; /*пñ־*/ + } + + } + else + { + /*޲*/ + } + + if(ToBeContinue == 0) + { + if(QueueAvailable == 0xFF)/*жɶ*/ + { + if(QueueReadFlag == 0x55)/*ϴζĶǺ*/ + { + /*Ϊ֡ͷֽڣΪԴ򲻱䣬ȶֽڣ*/ + RcvQueueReadLenth = QueueRead(2,Rcv,&pUnifyInfoForRedun->OutnetQueueB); + if(RcvQueueReadLenth != 1) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + #endif + break;/*Ƴѭ*/ + } + + RVQueueRead = QueueRead( (UINT16)(lenthofRcvB + 2),Rcv,&pUnifyInfoForRedun->OutnetQueueB); + DestDevNameInFrame = LongFromCharLE(&Rcv[RCV_SRC_DN]); + SetNetsRecvPkgNum(pUnifyInfoForRedun, DestDevNameInFrame, 1); + QueueReadFlag = 0xAA;/*ζ*/ + /*¼¼*/ + #ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"BNet:"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + /*һ֡ϢʼʶϢԴ*/ + PrintRecArrayByte(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + 0x40|0x0A); + #endif + } + else + { + /*Ϊ֡ͷֽڣΪԴ򲻱䣬ȶֽڣ*/ + RcvQueueReadLenth = QueueRead(2,Rcv,&pUnifyInfoForRedun->OutnetQueueA); + if(RcvQueueReadLenth != 1) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + #endif + break;/*Ƴѭ*/ + } + + RVQueueRead = QueueRead( (UINT16)(lenthofRcvA + 2),Rcv,&pUnifyInfoForRedun->OutnetQueueA); + DestDevNameInFrame = LongFromCharLE(&Rcv[RCV_SRC_DN]); + SetNetsRecvPkgNum(pUnifyInfoForRedun, DestDevNameInFrame, 0); + QueueReadFlag = 0x55; + /*¼¼*/ + #ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"RNet:"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + /*һ֡ϢʼʶϢԴ*/ + PrintRecArrayByte(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + 0x40|0x05); + #endif + } + } + else if(QueueAvailable == 0x0F)/*пɶ*/ + { + /*Ϊ֡ͷֽڣΪԴ򲻱䣬ȶֽڣ*/ + RcvQueueReadLenth = QueueRead(2,Rcv,&pUnifyInfoForRedun->OutnetQueueA); + if(RcvQueueReadLenth != 1) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + #endif + break;/*˳ѭ*/ + } + + RVQueueRead = QueueRead( (UINT16)(lenthofRcvA + 2),Rcv,&pUnifyInfoForRedun->OutnetQueueA); + DestDevNameInFrame = LongFromCharLE(&Rcv[RCV_SRC_DN]); + SetNetsRecvPkgNum(pUnifyInfoForRedun, DestDevNameInFrame, 0); + QueueReadFlag = 0x55;/*ζǺ*/ + /*¼¼*/ + #ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"RNet:"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + /*һ֡ϢʼʶϢԴ*/ + PrintRecArrayByte(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + 0x40|0x05); + #endif + } + else if(QueueAvailable == 0xF0)/*пɶ*/ + { + /*Ϊ֡ͷֽڣΪԴ򲻱䣬ȶֽڣ*/ + RcvQueueReadLenth = QueueRead(2,Rcv,&pUnifyInfoForRedun->OutnetQueueB); + if(RcvQueueReadLenth != 1) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + #endif + break;/*˳ѭ*/ + } + + RVQueueRead = QueueRead( (UINT16)(lenthofRcvB + 2),Rcv,&pUnifyInfoForRedun->OutnetQueueB); + DestDevNameInFrame = LongFromCharLE(&Rcv[RCV_SRC_DN]); + SetNetsRecvPkgNum(pUnifyInfoForRedun, DestDevNameInFrame, 1); + QueueReadFlag = 0xAA;/*ζ*/ + /*¼¼*/ + #ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"BNet:"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + /*һ֡ϢʼʶϢԴ*/ + PrintRecArrayByte(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + 0x40|0x0A); + #endif + } + else + { + break; /*˳whileѭ*/ + } + + if(RVQueueRead == 1) /*жǷԶ֡*/ + {/*Զ֡*/ + + /*Է豸ͱ豸ID*/ + LocalDevNameInFrame = LongFromCharLE(&Rcv[RCV_AIM_DN]); + DestDevNameInFrame = LongFromCharLE(&Rcv[RCV_SRC_DN]); + /*ԼԷSN*/ + for(i = 0; i < 4;i++) + { + Dest_SN[i] = Rcv[RCV_SRC_SN + i]; + Local_SN[i] = Rcv[RCV_AIM_SN + i]; + } + DestSN = LongFromChar(Dest_SN); + LocalSN = LongFromChar(Local_SN); + /*¼¼*/ + #ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"AName:"); + PrintFileU32Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + LocalDevNameInFrame); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"SName:"); + PrintFileU32Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + DestDevNameInFrame); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"MType:"); + PrintFileHex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + &Rcv[RCV_FRAME_TYPE],1); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"LSN:"); + PrintFileU32Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + LocalSN); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"DSN:"); + PrintFileU32Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + DestSN); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"Len:"); + if(QueueReadFlag == 0x55) /*пɶ*/ + { + PrintFileU32Int(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + (UINT32) lenthofRcvA - 21); + } + else if(QueueReadFlag == 0xAA) + { + PrintFileU32Int(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + (UINT32) lenthofRcvB - 21); + } + else + { + /*޲*/ + } + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + /*֡ĿͺID*/ + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + (UINT16)((LocalDevNameInFrame >> 16) & 0xffff)); + /*֡ԴͺID*/ + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + (UINT16)((DestDevNameInFrame >> 16) & 0xffff)); + /*֡*/ + PrintRecArrayByte(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + Rcv[RCV_FRAME_TYPE]); + /*к*/ + PrintRecArray4ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + LocalSN); + /*Էк*/ + PrintRecArray4ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + DestSN); + /*֡*/ + if(QueueReadFlag == 0x55) /*пɶ*/ + { + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + (UINT16) lenthofRcvA - 21); + } + else if(QueueReadFlag == 0xAA) + { + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + (UINT16) lenthofRcvB - 21); + } + else + { + /*޲*/ + } + #endif + + + if(LocalDevNameInFrame == LocalDevName) /*Ŀ豸typeId뱾һ*/ + { + /*òѯ̬ñZCϵATSϵĺж϶ԷͨŶǷϷ;õɫLink_Role;*/ + if(dsuIsLnkLegal(pUnifyInfoForRedun,DestDevNameInFrame,&Link_Role))/*typeϷ && IDϷ*/ + { + if(JudgeCrc(Rcv,pUnifyInfoForRedun))/*CRCжϣȷֱӶ֡*/ + { + if(Link_Role == ROLE_SPON)/*ɫΪ*/ + { + if(Rcv[RCV_FRAME_TYPE] == FRAME_RFC)/*յRFC֡,*/ + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|FRAMETYPE_ROLE_CONFLICT|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|FRAMETYPE_ROLE_CONFLICT|ERROR_NULL); + #endif + }/*if(Rcv[RCV_FRAME_TYPE] == FRAME_RFC)*/ + else if(Rcv[RCV_FRAME_TYPE] == FRAME_ACK)/*յACK֡,һ*/ + { + /*òѯͨŹSearchLnkظڱеָ룻*/ + CurIndex_Lnk_Mngr = SearchLnk(DestDevNameInFrame,pUnifyInfoForRedun);/*·вѯ޸·*/ + if(CurIndex_Lnk_Mngr != NULL)/*ڸ·*/ + { + /*·֡ΪACKкͬ*/ + /*·WaitConյı͹ȥSN·ϲܶӦ!!!!!!!*/ + if(CurIndex_Lnk_Mngr->Lnk_Info.AckSN != DestSN ) + { + /*òҽڵ㺯ڵǷڸ豸typeID*/ + p_temp = SearchGroupNode(DestDevNameInFrame, pUnifyInfoForRedun); + if(p_temp != NULL)/*ڸtypeIDڵ*/ + { + /*ɾнڵ㺯TYPEIDµSNڵȫɾ*/ + DelGroupNode(p_temp,pUnifyInfoForRedun); + /*òڵ㺯ACK֡²뵽ڵ㻺*/ + InsertNode(DestDevNameInFrame,&Rcv[RCV_SRC_SN],Rcv,pUnifyInfoForRedun); + if(pUnifyInfoForRedun->InputBufferHead == NULL) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + + #endif + + + } + else + { + /*޲*/ + } + } + else/*ڸtypeIDڵ*/ + { + /*òڵ㺯ACK֡²뵽ڵ㻺*/ + InsertNode(DestDevNameInFrame,&Rcv[RCV_SRC_SN],Rcv,pUnifyInfoForRedun); + if(pUnifyInfoForRedun->InputBufferHead == NULL) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + + #endif + + } + else + { + /*޲*/ + } + } + }/*·״̬ΪWCONACKҸ֡ıк·еһ*/ + else + { + /*޲*/ + } + }/*if(CurIndex_Lnk_Mngr != NULL)*/ + else + { + /*޲*/ + } + + }/*if(Rcv[RCV_FRAME_TYPE] == FRAME_ACK)*/ + else if((Rcv[RCV_FRAME_TYPE] == FRAME_DATA) || (Rcv[RCV_FRAME_TYPE] == FRAME_IDLE))/*֡ΪIdle̬data̬*/ + { + /*SearchLnkѯͨŹظڱе±ꣻ*/ + CurIndex_Lnk_Mngr = SearchLnk(DestDevNameInFrame,pUnifyInfoForRedun);/*·вѯ޸·*/ + if(CurIndex_Lnk_Mngr != NULL)/*ڸ·*/ + { + if(CurIndex_Lnk_Mngr->Lnk_Info.chStatus == STATUS_DATA) + { + if(JudgeSN(CurIndex_Lnk_Mngr,LocalSN,DestSN, pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize))/*жкźϷԺJudgeSNظ֡кǷϷ*/ + { + /*òڵ㺯ýڵ*/ + InsertNode(DestDevNameInFrame,&Rcv[RCV_SRC_SN],Rcv,pUnifyInfoForRedun); + if(pUnifyInfoForRedun->InputBufferHead == NULL) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + + #endif + + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + + #endif + + } + else + { + /*޲*/ + } + }/*if(JudgeSN(CurIndex_Lnk_Mngr,LocalSN,DestSN))*/ + else/*кŲϷ*/ + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|SN_ILLEGAL|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|SN_ILLEGAL|ERROR_NULL); + + #endif + + } + }/*if(CurIndex_Lnk_Mngr->Lnk_Info.chStatus == STATUS_DATA)*/ + else/*·Ϊ״̬*/ + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|FRAMETYPE_STATUS_CONFLICT|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|FRAMETYPE_STATUS_CONFLICT|ERROR_NULL); + + #endif + + } + }/*if(CurIndex_Lnk_Mngr != NULL)*/ + else + { + /*޲*/ + } + }/*if((Rcv[RCV_FRAME_TYPE] == FRAME_DATA) || (Rcv[RCV_FRAME_TYPE] == FRAME_IDLE))*/ + else + { + /*޲*/ + } + }/*if(Link_Role == ROLE_SPON)*/ + else if(Link_Role == ROLE_FLW) + { + if(Rcv[RCV_FRAME_TYPE] == FRAME_ACK)/*淽յACK֡,*/ + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|FRAMETYPE_ROLE_CONFLICT|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|FRAMETYPE_ROLE_CONFLICT|ERROR_NULL); + #endif + } + else if(Rcv[RCV_FRAME_TYPE] == FRAME_RFC)/*淽յRFC֡,һ*/ + { + /*òѯͨŹSearchLnkظڱе±ꣻ*/ + CurIndex_Lnk_Mngr = SearchLnk(DestDevNameInFrame,pUnifyInfoForRedun);/*·вѯ޸·*/ + if(CurIndex_Lnk_Mngr != NULL)/*ͨŹдڸ·*/ + { + if(CurIndex_Lnk_Mngr->Lnk_Info.RfcSN == DestSN) + /*·֡ΪRFCкͬ*/ + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|RE_RECV_RFC|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|RE_RECV_RFC|ERROR_NULL); + #endif + }/*if((CurIndex_Lnk_Mngr->Lnk_Info.lastframe == FRAME_RFC)&&(CurIndex_Lnk_Mngr->Lnk_Info.lDestSN == DestSN))*/ + else/*·֡ͲΪRFCкŲͬ*/ + { + /*òҽڵ㺯ڵǷڸ豸typeID*/ + p_temp = SearchGroupNode(DestDevNameInFrame, pUnifyInfoForRedun); + if(p_temp != NULL)/*ڸtypeIDڵ*/ + { + /*ɾнڵ㺯TYPEIDµSNڵȫɾ*/ + DelGroupNode(p_temp,pUnifyInfoForRedun); + /*òڵ㺯ACK֡²뵽ڵ㻺*/ + InsertNode(DestDevNameInFrame,&Rcv[RCV_SRC_SN],Rcv,pUnifyInfoForRedun); + if(pUnifyInfoForRedun->InputBufferHead == NULL) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + + #endif + + } + else + { + /*޲*/ + } + }/*end if(p_temp ! = NULL)*/ + else/*ڸtypeIDڵ*/ + { + /*òڵ㺯RFC֡²뵽ڵ㻺*/ + InsertNode(DestDevNameInFrame,&Rcv[RCV_SRC_SN],Rcv,pUnifyInfoForRedun); + if(pUnifyInfoForRedun->InputBufferHead == NULL) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + #endif + + } + else + { + /*޲*/ + } + } + }/*·֡ͲΪRFCкŲͬ*/ + }/*if(CurIndex_Lnk_Mngr != NULL)*/ + else/*ͨŹдڸ·*/ + { + /*òҽڵ㺯ڵǷڸ豸typeID*/ + p_temp = SearchGroupNode(DestDevNameInFrame, pUnifyInfoForRedun); + if(p_temp != NULL)/*ڸtypeIDڵ*/ + { + /*ɾнڵ㺯TYPEIDµSNڵȫɾ*/ + DelGroupNode(p_temp,pUnifyInfoForRedun); + /*òڵ㺯ACK֡²뵽ڵ㻺*/ + InsertNode(DestDevNameInFrame,&Rcv[RCV_SRC_SN],Rcv,pUnifyInfoForRedun); + if(pUnifyInfoForRedun->InputBufferHead == NULL) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + + #endif + } + else + { + /*޲*/ + } + }/*end if(p_temp != NULL)*/ + else/*ڸtypeIDڵ*/ + { + /*òڵ㺯RFC֡²뵽ڵ㻺*/ + InsertNode(DestDevNameInFrame,&Rcv[RCV_SRC_SN],Rcv,pUnifyInfoForRedun); + if(pUnifyInfoForRedun->InputBufferHead == NULL) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + + + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + #endif + } + else + { + /*޲*/ + } + } + }/*ͨŹвڸ·*/ + }/*else if(Rcv[RCV_FRAME_TYPE] == FRAME_RFC)*/ + else if((Rcv[RCV_FRAME_TYPE] == FRAME_DATA) || (Rcv[RCV_FRAME_TYPE] == FRAME_IDLE))/*֡ΪIdle̬data̬*/ + { + /*òѯͨŹSearchLnkظڱе±ꣻ*/ + CurIndex_Lnk_Mngr = SearchLnk(DestDevNameInFrame,pUnifyInfoForRedun);/*·вѯ޸·*/ + if(CurIndex_Lnk_Mngr != NULL)/*ͨŹдڸ·*/ + { + if((CurIndex_Lnk_Mngr->Lnk_Info.chStatus == STATUS_DATA) || (CurIndex_Lnk_Mngr->Lnk_Info.chStatus == STATUS_HALT)) + { + if(JudgeSN(CurIndex_Lnk_Mngr,LocalSN,DestSN, pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize))/*жкźϷԺJudgeSNظ֡кǷϷ*/ + { + /*òڵ㺯ýڵ*/ + InsertNode(DestDevNameInFrame,&Rcv[RCV_SRC_SN],Rcv,pUnifyInfoForRedun); + if(pUnifyInfoForRedun->InputBufferHead == NULL) + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + #endif + + } + else + { + /*޲*/ + } + }/*if(JudgeSN(CurIndex_Lnk_Mngr,LocalSN,DestSN))*/ + else/*кŲϷ*/ + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|SN_ILLEGAL|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|SN_ILLEGAL|ERROR_NULL); + #endif + } + }/*if((CurIndex_Lnk_Mngr->Lnk_Info.chStatus == STATUS_DATA) || (CurIndex_Lnk_Mngr->Lnk_Info.chStatus == STATUS_HALT))*/ + else/*·״̬Ϊ*/ + { + + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|FRAMETYPE_STATUS_CONFLICT|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|FRAMETYPE_STATUS_CONFLICT|ERROR_NULL); + #endif + + } + }/*if(CurIndex_Lnk_Mngr != NULL)*/ + else + { + /*޲*/ + } + }/*if((Rcv[RCV_FRAME_TYPE] == FRAME_DATA) || (Rcv[RCV_FRAME_TYPE] == FRAME_IDLE))*/ + else + { + /*޲*/ + } + }/*else if(Link_Role == ROLE_FLW)*/ + else + { + /*޲*/ + } + }/*if(JudgeCrc())*/ + else /*CRCжϲȷ,*/ + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|CRC_ERR|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|CRC_ERR|ERROR_NULL); + #endif + } + }/*if(IsLnkLegal(Rcv[RCV_AIM_TYPE],Local_id,Rcv[RCV_SRC_TYPE],Dest_id,&Link_Role))*/ + else/*ԷͨŶ󲻺Ϸ*/ + { + + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|OBJ_ILLEAGL|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|OBJ_ILLEAGL|ERROR_NULL); + #endif + } + }/*if(LocalDevNameInFrame == LocalDevName)*/ + else /*Ŀ豸typeId뱾زһ£*/ + { + + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|DESTNAME_ERR|ERROR_NULL); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|DESTNAME_ERR|ERROR_NULL); + #endif + } + }/*if( QueueRead((lenthofRcv + 2),Rcv,&innet_to_outnet_Queue) != 0)*/ + else/*֡*/ + { + /*¼¼*/ + #ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + #endif + #ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + WARN|REDUN|ERROR_NULL|QUEUE_READ); + #endif + break;/*˳ѭ*/ + }/*if(QueueScan(2,len,&innet_to_outnet_Queue) != 0)*/ + } + else + { + ToBeContinue = 0; + } + + }/*нڵ*/ + else + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|INPUT_LNK_POP); + +#endif + + break; + } + } + else + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|TIMEOUT); + PrintFiles(pUnifyInfoForRedun->RecordArray, pUnifyInfoForRedun->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRedun->RecordArray,pUnifyInfoForRedun->RecordArraySize, + ERR|REDUN|ERROR_NULL|TIMEOUT); + +#endif + + break; + } + } + + ret = 1; + return ret; + +} + + +/************************************************************************/ +/* ѯڵ洢нڵָIJ */ +/************************************************************************/ + +/* +*: SearchGroupNode +*: ڽڵ洢ѯij豸µĽڵ㣬ɶλ·Ĺ +*: UINT32 DeviceName Է豸 +* struc_Unify_Info *pUnifyInfoForRedun SFPṹ +*: +*: +*ֵ: 1:ɹ;0ʧ +*/ +static struc_InputBuffer* SearchGroupNode(UINT32 DeviceName, struc_Unify_Info *pUnifyInfoForRedun) +{ + struc_InputBuffer *CurIndex; + struc_InputBuffer *pret; + + /*ǰָӽڵ洢ͷָ뿪ʼ*/ + CurIndex = pUnifyInfoForRedun->InputBufferHead; + + while(1) + { + if(CurIndex != NULL) + { + /*ҵҪѯڵ*/ + if(DeviceName == CurIndex->DevName) + { + return CurIndex;/*صǰַָָ*/ + }/*if(DeviceName == CurIndex->DevName)*/ + else + { + /*޲*/ + } + + CurIndex = CurIndex->NextNode; /*ûҵҪɾڵ㣬ǰָ붼һڵ*/ + }/* if(CurIndex != NULL)*/ + else + { + pret = NULL; + return pret; /*ûҵҪɾڵ*/ + } + }/*while(1)*/ + +} + + +/****************************************************************************************** +* : 뵱ǰڵ +* : UINT8 *a Ϣ +* : struc_InputBuffer *p ҪĽڵ +* : +* ȫֱ : +* ֵ : +*******************************************************************************************/ +static void BuildNode(struc_InputBuffer *p,UINT8 *a) +{ + UINT8 len[2],Len[2]; + UINT16 lenth; + UINT16 i; + + for(i = 0; i < 2; i++) + { + len[i] = a[RCV_DATA_LEN + i]; + } + + lenth = ShortFromChar(len); + ShortToChar((UINT16)(lenth - 8),Len); + + /*֡ȸһάĽڵ*/ + for(i = 0; i < 2; i++) + { + p->data[LINK_DATA_LEN + i] = Len[i]; + } + + for(i = 0; i < 4;i++) + { + p->data[LINK_SRC_SN + i] = a[RCV_SRC_SN + i]; /*ԷкŸһάĽڵ*/ + p->data[LINK_AIM_SN + i] = a[RCV_AIM_SN + i]; /*кŸһάĽڵ*/ + } + p->data[LINK_FRAME_TYPE] = a[RCV_FRAME_TYPE]; /*֡͸һάĽڵ*/ + for(i = 0; i < 4;i++) + { + /*Դ豸nameһάĽڵ*/ + p->data[LINK_SRC_DN + i] = a[RCV_SRC_DN + i]; + } + for(i = 0; i < (ShortFromChar(&a[RCV_DATA_LEN]) - 21);i++) /*ӦݸһάĽڵ*/ + { + p->data[LINK_APP_DATA + i] = a[RCV_APP_DATA + i]; + } + +} + +/************************************************************************/ +/* Ϊڵ洢½ڵIJ */ +/************************************************************************/ + +/****************************************************************************************** +* : ָĽڵ뵽ڵ洢й涨λ +* : UINT32 DestDevName Է豸 +* UINT8 *DestSN Է豸SN +* UINT8 *Inputarray +* : struc_Unify_Info *pUnifyInfo Ӧͳһṹ +* : +* ȫֱ : +* ֵ : ²ڵָ +*******************************************************************************************/ +static struc_InputBuffer* InsertNode(UINT32 DestDevName,UINT8 *DestSN,UINT8 *Inputarray,struc_Unify_Info *pUnifyInfo) +{ + struc_InputBuffer *LastIndex; + struc_InputBuffer *CurIndex; + struc_InputBuffer *TempIndex; + UINT16 i; + struc_InputBuffer *pret; + + LastIndex = NULL; + /*ǰָͷָ뿪ʼ*/ + CurIndex = pUnifyInfo->InputBufferHead; + TempIndex = NULL; + + /*һά*/ + while(1) + { + /*һάнڵ*/ + if(CurIndex != NULL) + { + /*ڵڵǰڵ,ڵǰڵ֮ǰ*/ + if(DevNameSNcmp(DestDevName,DestSN,CurIndex->DevName,CurIndex->DevSn) == 1) + { + /*ȡڵڴ;*/ + TempIndex = (struc_InputBuffer*)PopStack(&pUnifyInfo->InputStack); + if(NULL == TempIndex) + { + pret = 0; + return pret; /*ûпõڴڵ*/ + } + else + { + /*޲*/ + } + + /*ĿIDֵ*/ + TempIndex->DevName = DestDevName; + + /*ĿSNֵ*/ + for(i = 0; i < 4; i++) + { + TempIndex->DevSn[i] = *(DestSN + i); + } + + /*Ϣڵ*/ + BuildNode(TempIndex,Inputarray); + + /*ڵΪһڵ,ͷڵó²ڵ*/ + if(LastIndex == NULL) + { + pUnifyInfo->InputBufferHead = TempIndex; + } + /*ڵ㲻Ϊһڵ㣬һڵָڵ*/ + else + { + LastIndex->NextNode = TempIndex; + } + + /*ָһڵָǰָ*/ + TempIndex->NextNode = CurIndex; + + /*ز뵱ǰַָѭ*/ + return TempIndex; + } + /*ڵѾڣעǷҪ¸*/ + else if(DevNameSNcmp(DestDevName,DestSN,CurIndex->DevName,CurIndex->DevSn) == 0) + { + /*ĿID,TYPEֵ*/ + CurIndex->DevName = DestDevName; + /*ĿSNֵ*/ + for(i = 0; i < 4; i++) + { + CurIndex->DevSn[i] = *(DestSN + i); + } + + /*Ϣڵ*/ + BuildNode(CurIndex,Inputarray); + + /*ѭ*/ + return CurIndex;/*и·ش*/ + } + /*ڵСڵǰڵ㣬ǰһڵһڵ*/ + else + { + LastIndex = CurIndex; + CurIndex = CurIndex->NextNode; + } + } + /*ڵΪһڵ||ڵΪһڵ*/ + else + { + /*ȡڵڴ*/ + TempIndex = (struc_InputBuffer*)PopStack(&pUnifyInfo->InputStack); + if(NULL == TempIndex) + { + pret = 0; + return pret; /*ûпõڴڵ*/ + } + else + { + /*޲*/ + } + + /*ĿNameֵ*/ + TempIndex->DevName = DestDevName; + /*ĿSNֵ*/ + for(i = 0; i < 4; i++) + { + TempIndex->DevSn[i] = *(DestSN + i); + } + + /*Ϣڵ*/ + BuildNode(TempIndex,Inputarray); + + /*ڵΪһڵ㣬Ϊͷڵһڵ*/ + if(LastIndex == NULL) + { + /*ͷָ븳ֵ*/ + pUnifyInfo->InputBufferHead = TempIndex; + } + /*ڵΪһڵ㣬ýڵ뵽һڵλ*/ + else + { + LastIndex-> NextNode = TempIndex; + } + /*ָһڵָΪ*/ + TempIndex->NextNode = NULL; + + /*ز뵱ǰַָ*/ + return TempIndex; + } + } + +} + + + +/****************************************************************************************** +* : ɾദڵ洢ûʱЧԵĽڵ, +* ýڵûʱЧԣôúɾýڵ㼰ԺûʱЧԵSNڵ +* : struc_InputBuffer *NodeIndex ǰҪɾָ +* : struc_Unify_Info *pUnifyInfo ҪɾĽڵͨŶӦͳһṹ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 DelGroupNode(struc_InputBuffer *NodeIndex,struc_Unify_Info *pUnifyInfo) +{ + struc_InputBuffer *CurIndex; + struc_InputBuffer *LastIndex; + UINT8 ret; + + /*ͷڵ㸳ǰָ*/ + CurIndex = pUnifyInfo->InputBufferHead; + LastIndex = NULL; + while(CurIndex != NULL) + { + /*ҵҪɾڵ*/ + if(CurIndex == NodeIndex) + { + /*ɾڵͷڵ*/ + if(LastIndex == NULL) + { + while(CurIndex->NextNode != NULL) + { /*жǷΪͬһTYPEIDǣɾڵ*/ + if(CurIndex->DevName == CurIndex->NextNode->DevName) + { + /*ͷָ¸ֵ*/ + pUnifyInfo->InputBufferHead = CurIndex->NextNode; + if( PushStack(&pUnifyInfo->InputStack,CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + CurIndex = CurIndex->NextNode; + } + else + { + break;/*ΪͬһtypeID,ѭ*/ + } + } + + /*ͷָ¸ֵ*/ + pUnifyInfo->InputBufferHead = CurIndex->NextNode; + + /*ɾһڵ*/ + if( PushStack(&pUnifyInfo->InputStack,CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + }/*if(һָLastIndex == NULL)*/ + + /*ɾڵ㲻ͷڵ*/ + else + { + /*жǷΪͬһTYPEIDǣɾڵ*/ + while(CurIndex->NextNode != NULL) + { + if(CurIndex->DevName == CurIndex->NextNode->DevName) + { + LastIndex->NextNode = CurIndex->NextNode; + if( PushStack(&pUnifyInfo->InputStack,CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + CurIndex = CurIndex->NextNode; + } /*if(DevIDcmp(CurIndex->DevType,CurIndex->DevID,CurIndex->NextNode->DevType,CurIndex->NextNode->DevID) == 0)*/ + else + { + break;/*ΪͬһtypeID,ѭ*/ + } + }/* while(CurIndex->NextNode != NULL)*/ + /*ɾһڵ*/ + LastIndex->NextNode = CurIndex->NextNode; + if( PushStack(&pUnifyInfo->InputStack,CurIndex) == 0) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + } + } /*if(CurIndex == NodeIndex) */ + else + { + /*޲*/ + } + + /*ûҵҪɾڵ㣬һָ͵ǰָ붼һڵ*/ + LastIndex = CurIndex; + CurIndex = CurIndex->NextNode; + } + ret = 1; + return ret; +} + + +/****************************************************************************************** +* : жCRC,ԽCRCж,֡IDLE֡֡ҪRFCACKSN +* : +* : +* : +* ȫֱ : UINT8 *Rcv ദ飬ŵÿ֡ϢЭ鴦ʱõĿռ +* struc_Unify_Info *pUnifyInfoForRedun õͳһṹָȫֱõе·ͷڵָ +* ֵ : CRCȷ򷵻1򷵻0 +*******************************************************************************************/ + +/* +*: JudgeCrc +*: жCRC,ԽCRCж,֡IDLE֡֡ҪRFCACKSN +*: UINT8 Rcv[] յ +* struc_Unify_Info *pUnifyInfoForRedun SFPṹ +*: +*: +*ֵ: 1:ɹ;0ʧ +*/ +static UINT16 JudgeCrc(UINT8 Rcv[], struc_Unify_Info *pUnifyInfoForRedun) +{ +#ifdef DUAL_CRC + UINT32 crcOneInData = 0u; /*յݵCRC1*/ + UINT32 calcCrcVal = 0u; /*CRCֵ*/ +#endif + UINT32 CrcInData;/*յݵCRC*/ + UINT16 nLen;/*Ӧôݵij*/ + UINT16 LengthForCrc; + struc_Lnk_Mngr *CurLnk = NULL; + UINT16 ret; + + /*ȡݵij*/ + nLen = ShortFromChar(&Rcv[RCV_DATA_LEN]); + + if (nLen != 0) + { +#ifdef DUAL_CRC + crcOneInData = LongFromChar(&Rcv[nLen - 8 + 2]); /*ȡԭеCRC1*/ +#endif + /*ȡԭеCRC*/ + CrcInData = LongFromChar(&Rcv[nLen - 4 + 2]); + +#ifdef DUAL_CRC + LengthForCrc = nLen - 8; /*CRCݳ*/ +#else + LengthForCrc = nLen - 4; /*CRCݳ*/ +#endif + + /*ݵ֡ΪDATAIDELʱҪRFCACKʼк*/ + if((Rcv[RCV_FRAME_TYPE] == FRAME_DATA) || (Rcv[RCV_FRAME_TYPE] == FRAME_IDLE)) + { + /*豸ѯ·*/ + CurLnk = SearchLnk(LongFromCharLE(&Rcv[RCV_SRC_DN]),pUnifyInfoForRedun); + if(CurLnk != NULL) + { +#ifdef DUAL_CRC + /*RFCʼк*/ + LongToChar(CurLnk->Lnk_Info.RfcSN, &Rcv[nLen + 2 - 8]); + /*ACKʼк*/ + LongToChar(CurLnk->Lnk_Info.AckSN, &Rcv[nLen + 2 - 4]); + /*޸ڼCRCݳ*/ + LengthForCrc = nLen + 8 - 8; +#else + /*RFCʼк*/ + LongToChar(CurLnk->Lnk_Info.RfcSN, &Rcv[nLen + 2 - 4]); + /*ACKʼк*/ + LongToChar(CurLnk->Lnk_Info.AckSN, &Rcv[nLen + 2]); + /*޸ڼCRCݳ*/ + LengthForCrc = nLen + 8 - 4; +#endif + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } + +#ifdef DUAL_CRC + calcCrcVal = Crc32(&Rcv[RCV_SRC_SN], LengthForCrc); /*CRC*/ + if ((calcCrcVal == crcOneInData)&&(calcCrcVal == CrcInData)) /*˫CRCУ*/ + { + LongToChar(CrcInData, &Rcv[nLen - 8 + 2]); +#else + /*CRCеԭCRCȽϣɹ棬Ϊ*/ + if (Crc32(&Rcv[RCV_SRC_SN], LengthForCrc) == CrcInData) + { +#endif + LongToChar(CrcInData,&Rcv[nLen - 4 + 2]); + ret = 1; + return ret; + } + else + { + ret = 0; + return ret; + } + } + else + { + ret = 0; + return ret; + } +} + + +/****************************************************************************************** +* : ദж֡ʵЧ.жкǷϷ㣬ϣ +* 1.յıкҪСڵǰкţӦڳʱǰ͵һݵıк +* 2.ܵĶԷкҪڵǰĶԷкŻҪСڳʱڷ͵к +* 3.Ĵ; +* : struc_Lnk_Mngr *lnk_index ·е· +* UINT32 local_sn к +* UINT32 dest_sn Էк +* UINT8 *pRecord ־ +* UINT16 recordMaxLen ־󳤶 +* : +* : +* ȫֱ : +* ֵ : кźϷ1򷵻0 +*******************************************************************************************/ +static UINT32 JudgeSN(struc_Lnk_Mngr *lnk_index,UINT32 local_sn,UINT32 dest_sn, UINT8 *pRecord, UINT16 recordMaxLen) +{ + UINT32 Local_Width;/*кŴĿ*/ + UINT32 Dest_Width;/*ԷкŵĿ*/ + UINT32 temp_SN; + UINT8 blIn_Local_Width; + UINT8 blIn_Dest_Width;/*Ƿкſ*/ + + /*ȵڶԷijʱʱӳԱķ,ȡλ*/ + Local_Width = lnk_index->Lnk_Info.nSnWidth[1]; + + /*ԷȵڱijʱʱӳԶԷķ,ȡλ*/ + Dest_Width = lnk_index->Lnk_Info.nSnWidth[0]; + + /* (к - ) > к,ô˵кˣֶδ*/ + temp_SN = lnk_index->Lnk_Info.lLocalSN - Local_Width; + + /*жǷ*/ + /**/ + if (temp_SN > (lnk_index->Lnk_Info.lLocalSN)) + { + blIn_Local_Width = ((local_sn <= (lnk_index->Lnk_Info.lLocalSN)) || (local_sn >= temp_SN) ) ? 1 :0; + } + /*û,ûбҪǸ10ɵģ*/ + else + { + blIn_Local_Width = ((local_sn <= (lnk_index->Lnk_Info.lLocalSN)) && (local_sn >= temp_SN)) ? 1 :0; + } + + /* Էк+ < ,ô˵Էк,ֶδ*/ + temp_SN = lnk_index->Lnk_Info.lDestSN + Dest_Width; + + /**/ + if (temp_SN < Dest_Width) + { + blIn_Dest_Width = ((dest_sn > (lnk_index->Lnk_Info.lDestSN)) || (dest_sn <= temp_SN + 1)) ? 1 :0; + } + /*û,ûбҪǸ10ɵģ*/ + else + { + blIn_Dest_Width = ((dest_sn > (lnk_index->Lnk_Info.lDestSN)) && (dest_sn <= temp_SN))? 1 :0; + } + + if (0 == blIn_Local_Width) /*żǷ*/ + { + PrintRecArray2ByteB(pRecord, recordMaxLen, WARN | REDUN | SN_LOC_OVER | ERROR_NULL); + PrintRecArray2ByteB(pRecord, recordMaxLen, lnk_index->Lnk_Info.nSnWidth[1]); /**/ + PrintRecArray4ByteB(pRecord, recordMaxLen, lnk_index->Lnk_Info.lLocalSN); /*ǰ*/ + PrintRecArray4ByteB(pRecord, recordMaxLen, local_sn); /*յı*/ + } + if (0 == blIn_Dest_Width) /*ԷżǷ*/ + { + PrintRecArray2ByteB(pRecord, recordMaxLen, WARN | REDUN | SN_OPP_OVER | ERROR_NULL); + PrintRecArray2ByteB(pRecord, recordMaxLen, lnk_index->Lnk_Info.nSnWidth[0]); /*Է*/ + PrintRecArray4ByteB(pRecord, recordMaxLen, lnk_index->Lnk_Info.lDestSN); /*ϴյĶԷ*/ + PrintRecArray4ByteB(pRecord, recordMaxLen, dest_sn); /*յĶԷ*/ + } + + return (blIn_Local_Width && blIn_Dest_Width) ? 1 :0;/*Ϊ淵棬*/ +} + + + +/****************************************************************************************** +* : ȽDeviceName+SNĴСȽDeviceName+SNϺݵĴС豸DeviceNameǰSnں +* : UINT32 DeviceNameA 豸AName +* UINT8 SnA[] 豸ASN +* UINT32 DeviceNameB 豸BName +* UINT8 SnB[] 豸BSN +* : +* : +* ȫֱ : +* ֵ : a > b1;a == b 0;a < b-1 +*******************************************************************************************/ +static INT8 DevNameSNcmp(UINT32 DeviceNameA,UINT8 SnA[],UINT32 DeviceNameB,UINT8 SnB[]) +{ + UINT32 lSnA; + UINT32 lSnB; + INT8 ret; + + lSnA = 0; + lSnB = 0; + lSnA = LongFromChar(SnA); + lSnB = LongFromChar(SnB); + + /*a= 0xFFF0) && (lSnB <= 0x000F)) + { + ret = -1; + return ret; + } + else if((lSnB >= 0xFFF0) && (lSnA <= 0x000F)) + { + ret = 1; + return ret; + } + else if(lSnA < lSnB) + { + ret = -1; + return ret; + } + /*豸ȣsn*/ + else if(lSnA == lSnB) + { + ret = 0; + return ret; + } + else + { + /*޲*/ + } + /*豸ȣsna>b*/ + ret = 1; + return ret; + } + else + { + ret = 1; + return ret; + } +} + + + +/****************************************************************************************** +* : Эģ봦 + 1. Ȱ൥Ԫ뵥ԪĽӿȡ£Ѿɵȥ + 2. ÿһ֡޸ɾýڵ估ͬtypeIDºĽڵ㣻 + 3. ޸һά󣬿ʼ޸·Ϣ֡ΪDATAдӦõĶУ + 4. ݴ󣬿ʼ·ʱΪ淽ҳʱɾ· +* : +* : struc_Unify_Info *pUnifyInfo Эʹõͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 Prtcl_Receive(struc_Unify_Info *pUnifyInfo) +{ + /*********ֲ壬ģר***********/ + + struc_Unify_Info *pUnifyInfoForRcv; /*ģƽ̨ṹָ룬ģõƽ̨ṹָĶôָ*/ + /*·*/ + struc_Lnk_Mngr *Lnk; /*ҵ·󱣴·ָ*/ + struc_Lnk_Mngr *NewLnk; /*·󱣴·ָ*/ + struc_Lnk_Mngr *check; /*·ʱ·ָ*/ + struc_Lnk_Mngr *s; /*ɾ·ʱݴ·ָ*/ + + /*պͷк*/ + UINT32 RcvSN; + UINT32 SendSN; + /*ѭ*/ + UINT16 i; + /*ɾ־*/ + UINT16 to_delete; + + UINT16 Framelen;/*֡ݳ*/ + UINT16 Framelen_App;/*֡Ӧݳ*/ + UINT8 FrameType; /*֡ݴ*/ + /*һά*/ + struc_InputBuffer *CurIndex; /*ǰָ*/ + struc_InputBuffer *LastIndex; /*һָ*/ + UINT32 CurDevName; /*ǰڵĶԷ豸*/ + UINT32 LastDevName; /*һڵĶԷ豸*/ + UINT32 LocalSN; + UINT8 LifeTime; + /* wangpeipei 20120522 Mod */ + UINT32 b; + + UINT8 DelNodeRet; + UINT8 ret; + + /*********һЩijʼ***********/ + + pUnifyInfoForRcv = pUnifyInfo;/*ʼõƽ̨ṹָ*/ + + to_delete = 0; /*ɾ־*/ + s = NULL; + +#ifdef PRTCL_RECORD_ERR_ASC + /*ǰTick࿪ʼ*/ + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"Rcv: "); +#endif +#ifdef PRTCL_RECORD_DATA_ASC + PrintFileU32Int(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,(UINT32)0); +#endif +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize," "); + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"LName:"); + PrintFileHex(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,&pUnifyInfoForRcv->LocalType,1); + PrintFileU32Int(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,(UINT32)pUnifyInfoForRcv->LocalID); + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"\n"); +#endif + CurIndex = pUnifyInfoForRcv->InputBufferHead; + LastIndex = NULL; + + LastDevName = 0; + + while(CurIndex != NULL) + { + + CurDevName = CurIndex->DevName; + + Framelen = ShortFromChar(&CurIndex->data[LINK_DATA_LEN]); /*ǰ֡ij*/ + FrameType = CurIndex->data[LINK_FRAME_TYPE]; /*ǰ֡*/ + + if(LastDevName != CurIndex->DevName)/*ͬ豸Ľڵ*/ + { + /*********Ƚ޸·**********/ + Lnk = SearchLnk(CurDevName,pUnifyInfoForRcv); + + /*·иýڵ㲻ΪգӴ*/ + if(Lnk != NULL) + { + /*֡ΪRFC֡*/ + if(FrameType == FRAME_RFC) + { + /*·״̬ΪPRECON̬*/ + Lnk->Lnk_Info.chStatus = STATUS_PRECON; + /*мյĶԷк*/ + SendSN = LongFromChar(&CurIndex->data[LINK_SRC_SN]); + Lnk->Lnk_Info.lDestSN = SendSN; + /*Էкųʼֵ*/ + Lnk->Lnk_Info.RfcSN = SendSN; + /*յ֡ΪRFC֡*/ + Lnk->Lnk_Info.lastframe = FRAME_RFC; + /*ûյݵ*/ + Lnk->Lnk_Info.chNoDataRcvCycle = 0; + /*뵱ǰ */ + Lnk->Lnk_Info.lastCycle = *pUnifyInfoForRcv->CycleNum; + } + /*֡ΪACK֡*/ + else if(FrameType == FRAME_ACK) + { + if(Lnk->Lnk_Info.chStatus == STATUS_WCONACK)/*ǰ·״̬WconAck״̬*/ + { + /*ACKкȷеĽкϴαķкһ£*/ + RcvSN = LongFromChar(&CurIndex->data[LINK_AIM_SN]); + if(RcvSN == Lnk->Lnk_Info.lLocalSN) + { + /*·ӦIJ*/ + /*·״̬ΪDATA̬*/ + Lnk->Lnk_Info.chStatus = STATUS_DATA; + /*յ֡ΪACK֡*/ + Lnk->Lnk_Info.lastframe = FRAME_ACK; + /*мյĶԷк*/ + SendSN = LongFromChar(&CurIndex->data[LINK_SRC_SN]); + /*Էкųʼֵ*/ + Lnk->Lnk_Info.AckSN = SendSN; + Lnk->Lnk_Info.lDestSN = SendSN; + /*ûյݵ*/ + Lnk->Lnk_Info.chNoDataRcvCycle = 0; + /*뵱ǰ */ + Lnk->Lnk_Info.lastCycle = *pUnifyInfoForRcv->CycleNum; + } + else + { + /*޲*/ + } + } + else if(Lnk->Lnk_Info.chStatus == STATUS_DATA) /*DATA̬յACK֡״̬ΪSTATUS_HALT*/ + { + Lnk->Lnk_Info.chStatus = STATUS_HALT; + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize, + WARN|RECEIVE|FRAMETYPE_STATUS_CONFLICT|ERROR_NULL); + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize, + WARN|RECEIVE|FRAMETYPE_STATUS_CONFLICT|ERROR_NULL); +#endif + } + else + { + /*¼*/ + } + } + /*֡ΪDATAIDLE֡*/ + else if((FrameType == FRAME_DATA)||(FrameType == FRAME_IDLE)) + { + /*ûյݵ*/ + Lnk->Lnk_Info.chNoDataRcvCycle = 0; + /*ȷ·DATA̬*/ + Lnk->Lnk_Info.chStatus = STATUS_DATA; + /*յ֡*/ + Lnk->Lnk_Info.lastframe = FrameType; + /*мյĶԷк*/ + SendSN = LongFromChar(&CurIndex->data[LINK_SRC_SN]); + Lnk->Lnk_Info.lDestSN = SendSN; + /*뵱ǰ */ + Lnk->Lnk_Info.lastCycle = *pUnifyInfoForRcv->CycleNum; + } + else + { + /*¼*/ + } + } + /*ڵΪգӲڣ֡ΪRFC֡*/ + else if(FrameType == FRAME_RFC) + { + /*ӵ·*/ + NewLnk = InsertLnk(CurDevName,pUnifyInfoForRcv); + /*·ڵ㣬أһ֡*/ + if(NewLnk == NULL) + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize, + ERR|RECEIVE|ERROR_NULL|LNKMANAGE_POP); + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRcv->RecordArray, pUnifyInfoForRcv->RecordArraySize, + ERR|RECEIVE|ERROR_NULL|LNKMANAGE_POP); + +#endif + + } + /*·صIJ*/ + else + { + /*·PRECON̬*/ + NewLnk->Lnk_Info.chStatus = STATUS_PRECON; + /*ɫΪ淽*/ + NewLnk->Lnk_Info.chRole = ROLE_FLW; + /*мյĶԷк*/ + SendSN = LongFromChar(&CurIndex->data[LINK_SRC_SN]); + NewLnk->Lnk_Info.lDestSN = SendSN; + /*Էкųʼֵ*/ + NewLnk->Lnk_Info.RfcSN = SendSN; + /*յ֡ΪRFC֡*/ + NewLnk->Lnk_Info.lastframe = FRAME_RFC; + /*뵱ǰ */ + NewLnk->Lnk_Info.lastCycle = *pUnifyInfoForRcv->CycleNum; + } + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } + + /*֡дӦö*/ + if(FrameType == FRAME_DATA) + { + Framelen_App = Framelen - 9 + 1; /*ȵЭյij-кų-֡ͳ + */ + ShortToChar(Framelen_App,pUnifyInfoForRcv->CommBuffer);/**/ + for(i = 0;i < 4;i++) + { + pUnifyInfoForRcv->CommBuffer[i+2] = CurIndex->data[LINK_SRC_DN+i]; /*TypeIDComBuffer*/ + } + LocalSN = LongFromChar(&CurIndex->data[LINK_AIM_SN]); + + Lnk = SearchLnk(CurDevName,pUnifyInfoForRcv); + if(Lnk != NULL) + { + LifeTime = (UINT8)(Lnk->Lnk_Info.lLocalSN - LocalSN); + pUnifyInfoForRcv->CommBuffer[6] = LifeTime + 1; + + for(i = 0;(UINT16) i < Framelen - 13;i++) + { + pUnifyInfoForRcv->CommBuffer[i+7] = CurIndex->data[LINK_APP_DATA+i]; + } + + b = (UINT32)(pUnifyInfoForRcv->DataToApp.qsize - QueueStatus(&pUnifyInfoForRcv->DataToApp) ); + if((UINT32)(Framelen_App+2)<= b) + { + QueueWrite( Framelen_App+2,pUnifyInfoForRcv->CommBuffer,&pUnifyInfoForRcv->DataToApp); + +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"Name:"); + PrintFileU32Hex(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize, + LongFromCharLE(&pUnifyInfoForRcv->CommBuffer[2])); + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"Len:"); + PrintFileU32Int(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize, + (UINT32) Framelen_App - 5); + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"LifeTime:"); + PrintFileHex(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize, + &pUnifyInfoForRcv->CommBuffer[6],1); + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"\n"); +#endif + +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(pUnifyInfoForRcv->RecordArray, pUnifyInfoForRcv->RecordArraySize, + 0x80|(pUnifyInfoForRcv->CommBuffer[6] & 0x3f)); /*ӡ*/ + PrintRecArrayByte(pUnifyInfoForRcv->RecordArray, pUnifyInfoForRcv->RecordArraySize, + pUnifyInfoForRcv->CommBuffer[5]); /*ӡԴType*/ + PrintRecArrayByte(pUnifyInfoForRcv->RecordArray, pUnifyInfoForRcv->RecordArraySize, + pUnifyInfoForRcv->CommBuffer[4]); /*ӡԴID*/ + PrintRecArray2ByteB(pUnifyInfoForRcv->RecordArray, pUnifyInfoForRcv->RecordArraySize, + Framelen_App - 5); /*ӡӦݳ*/ +#endif + } + else + { + /*¼¼,ʣ೤Ȳ*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize, + WARN|RECEIVE|WARN|QUEUE_WRITE); + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForRcv->RecordArray, pUnifyInfoForRcv->RecordArraySize, + WARN|RECEIVE|WARN|QUEUE_WRITE); +#endif + + } + + if(CurIndex->NextNode!= NULL) + { + if(CurIndex->DevName == CurIndex->NextNode->DevName) + { + DelNodeRet = DelGroupNode(CurIndex->NextNode,pUnifyInfoForRcv); + if(DelNodeRet == 0) + { + break; + } + }/*ǰڵ㲻Ϊͬnameڵ㣬ɾͬnameĽڵ*/ + } + + }/*if((Lnk = SearchLnk(CurDevName,pUnifyInfoForRcv)) != NULL)*/ + else + { + /*¼*/ + } + }/*if(FrameType==FRAME_DATA)*/ + else + { + /*޲*/ + } + + LastIndex = CurIndex; + LastDevName = LastIndex->DevName; + CurIndex = CurIndex->NextNode; + + }/*while(CurIndex!=NULL)*/ + + /*****************һά***************************/ + CurIndex = pUnifyInfo->InputBufferHead; + while(CurIndex != NULL) + { + pUnifyInfo->InputBufferHead = CurIndex->NextNode; + if(PushStack(&pUnifyInfo->InputStack,CurIndex) == 0) + { + /*¼*/ + ret = 1; + return ret; + } + else + { + /*޲*/ + } + CurIndex = pUnifyInfo->InputBufferHead; + } + + /***************·ʱ***************/ + + /*ͷָ뿪ʼ*/ + check = pUnifyInfoForRcv->LnkHead; + + /*ǿ*/ + while(check != NULL) + { + /*ûյ*/ + if(check->Lnk_Info.lastCycle != *pUnifyInfoForRcv->CycleNum) + { + /*ûյ+1*/ + check->Lnk_Info.chNoDataRcvCycle++; + + /*ʱ*/ + if((check->Lnk_Info.chNoDataRcvCycle) > (check->Lnk_Info.nTimeOut)) + { + /*DATA״̬ΪHALT*/ + if(check->Lnk_Info.chStatus == STATUS_DATA) + { + check->Lnk_Info.chStatus = STATUS_HALT; + } + else + { + /*޲*/ + } + + /*Ϊ淽ҳʱʱ ʱʱ䣬ɾӣɾ־*/ + if((check->Lnk_Info.chRole == ROLE_FLW)&&(check->Lnk_Info.chNoDataRcvCycle > (check->Lnk_Info.nTimeOut+1))) + { + s = check; + to_delete = 1; + } + else + { + /*޲*/ + } + } + else + { + /*޲*/ + } + + } + else + { + /*޲*/ + } + + /*ָƵһ*/ + check = check->NextNode; + /*Ҫɾɾ*/ + if(to_delete == 1) + { + to_delete = 0; + DelLnk(s,pUnifyInfoForRcv); + } + else + { + /*޲*/ + } + + } + +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,"Rcv Over:"); + PrintFileU32Int(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,(UINT32)0); + PrintFilec(pUnifyInfoForRcv->RecordArray,pUnifyInfoForRcv->RecordArraySize,'\n'); +#endif + + ret = 1; + return ret; +} + + +/****************************************************************************************** +* : Э봦ijʼ + 1. ͳһṹе뵥ԪӦõĽӿڶнгʼ +* : +* : struc_Unify_Info *pUnifyInfoForRcv Эʹõͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 Prtcl_RecInitial(struc_Unify_Info *pUnifyInfoForRcv) +{ + UINT8 ret; + /*гʼ add by ly*/ + if(!QueueInitial(&pUnifyInfoForRcv->DataToApp,pUnifyInfoForRcv->DataToAppSize)) + { + /*¼*/ + ret = 0; + return ret; + } + ret = 1; + return ret; +} + +/* +*: հ +*: struc_Unify_Info* sfp sfp +*: +*: +*ֵ: +*/ +static void ClearNetsRecvPkgNum(struc_Unify_Info* sfp) +{ + UINT16 i = 0u; /*ѭ*/ + + if ((NULL != sfp) && (NULL != sfp->NetsRecvPkgNums)) /**/ + { + for (i = 0; i < sfp->NetsRecvPkgNumsLen; i++) + { + CommonMemSet(&sfp->NetsRecvPkgNums[i].NetsPkgNum, 2 * sizeof(UINT16), 0u, 2 * sizeof(UINT16)); + } + } +} + +/* +*: øհ +*: struc_Unify_Info* sfp sfp +* const UINT32 dstDevName Ŀ豸 +* const UINT8 netIdx ± +*: +*: +*ֵ: +*/ +static void SetNetsRecvPkgNum(struc_Unify_Info* sfp, const UINT32 dstDevName, const UINT8 netIdx) +{ + UINT16 i = 0u; /*ѭ*/ + + if ((NULL != sfp) && (NULL != sfp->NetsRecvPkgNums) && ((0u == netIdx) || (1u == netIdx))) /**/ + { + for (i = 0; i < sfp->NetsRecvPkgNumsLen; i++) /**/ + { + if (dstDevName == sfp->NetsRecvPkgNums[i].DstDevName) /*ҵ*/ + { + sfp->NetsRecvPkgNums[i].NetsPkgNum[netIdx]++; + break; + } + } + if ((i == sfp->NetsRecvPkgNumsLen) && (sfp->NetsRecvPkgNumsLen < sfp->MaxNumLink)) /*δҵ,һ豸*/ + { + sfp->NetsRecvPkgNums[sfp->NetsRecvPkgNumsLen].DstDevName = dstDevName; + CommonMemSet(&sfp->NetsRecvPkgNums[sfp->NetsRecvPkgNumsLen].NetsPkgNum, 2, 0, 2); + sfp->NetsRecvPkgNums[sfp->NetsRecvPkgNumsLen].NetsPkgNum[netIdx] = 1; + sfp->NetsRecvPkgNumsLen++; + } + } +} + +/* +*: ȡSFPյ +*: struc_Unify_Info* sfp sfp +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void ProtclGetNetsRecvPkgNum(struc_Unify_Info* sfp, const UINT8 dstType, const UINT8 dstId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum) +{ + UINT16 i = 0u; /*ѭ*/ + UINT32 dstDevName = 0u; /*Ŀ豸*/ + + if ((NULL != sfp) && (NULL != sfp->NetsRecvPkgNums) && (NULL != redRecvPkgNum) && (NULL != blueRecvPkgNum)) /**/ + { + (*redRecvPkgNum) = 0u; + (*blueRecvPkgNum) = 0u; + dstDevName = TypeIdToName(dstType, dstId); + for (i = 0; i < sfp->NetsRecvPkgNumsLen; i++) /**/ + { + if (dstDevName == sfp->NetsRecvPkgNums[i].DstDevName) /*ҵĿ豸*/ + { + (*redRecvPkgNum) = sfp->NetsRecvPkgNums[i].NetsPkgNum[0]; + (*blueRecvPkgNum) = sfp->NetsRecvPkgNums[i].NetsPkgNum[1]; + break; /*˳*/ + } + } + } +} diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclReceive.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclReceive.h new file mode 100644 index 0000000..5cb1ca7 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclReceive.h @@ -0,0 +1,207 @@ + +/******************************************************************************* +* ļ sfpPrtclReceive.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* Э뵥Ԫͷļ +* ʹע + +* ޸ļ¼ + 2008.7.8 + 1.typeԼIDĸΪnameʽ + 2.DevNameSNcmp +*******************************************************************************/ + +#ifndef _SFPPRTCLRECEIVE_H +#define _SFPPRTCLRECEIVE_H + +#include "sfpplatform.h" +#include "sfpLinkManage.h" +#include "dsuRelatedDeal.h" +#include "sfpDeclare.h" +#include "CommonQueue.h" +#include "Convert.h" +#include "CRC32.h" +#include "sfpPrtclCommon.h" + + +#ifdef __cplusplus +extern "C" { +#endif +/******************************************************************************** + +********************************************************************************/ +/****************************************************************************************** +* : Redundancy()ЭģһݵĴ + úְһӺȡݲദĺRedundancyReceive() +* : +* : struc_Unify_Info *pUnifyInfo ͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 Redundancy(struc_Unify_Info *pUnifyInfo); + + + +/****************************************************************************************** +* : Эദijʼ +* : +* : struc_Unify_Info *pUnifyInfo ͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 RedundancyInitial(struc_Unify_Info *pUnifyInfo); + +/* +*: RedundancyReceive +*: ݣദ +* 1Ӷжÿһ֡ +* 2жϱԷ߼ַǷϷ +* 3жCRCǷȷ +* 4жϱ͡ +* 5յRFC֡·ڣ·жϸRFCǷϷڣһά +* 6յACK֡ͨ·жϸACKǷϷϷͨһάжǷ֡ +* 7յDATA֡ͨ·жϸDATAǷϷϷͨһάжǷ֡ +*: struc_Unify_Info *pUnifyInfoForRedun SFPṹ +*: +*: +*ֵ: 1:ɹ;0ʧ +*/ +static UINT16 RedundancyReceive(struc_Unify_Info *pUnifyInfoForRedun); + +/* +*: SearchGroupNode +*: ڽڵ洢ѯij豸µĽڵ㣬ɶλ·Ĺ +*: UINT32 DeviceName Է豸 +* struc_Unify_Info *pUnifyInfoForRedun SFPṹ +*: +*: +*ֵ: 1:ɹ;0ʧ +*/ +static struc_InputBuffer* SearchGroupNode(UINT32 DeviceName, struc_Unify_Info *pUnifyInfoForRedun); + + + +/****************************************************************************************** +* : ָĽڵ뵽ڵ洢й涨λ +* : UINT32 DestDevName Է豸 +* UINT8 *DestSN Է豸SN +* UINT8 *Inputarray +* : struc_Unify_Info *pUnifyInfo Ӧͳһṹ +* : +* ȫֱ : +* ֵ : ²ڵָ +*******************************************************************************************/ +static struc_InputBuffer* InsertNode(UINT32 DestDevName,UINT8 *DestSN,UINT8 *Inputarray,struc_Unify_Info *pUnifyInfo); + + +/****************************************************************************************** +* : 뵱ǰڵ +* : UINT8 *a Ϣ +* : struc_InputBuffer *p ҪĽڵ +* : +* ȫֱ : +* ֵ : +*******************************************************************************************/ +static void BuildNode( struc_InputBuffer *p,UINT8 *a); + +/****************************************************************************************** +* : ɾദڵ洢ûʱЧԵĽڵ, +* ýڵûʱЧԣôúɾýڵ㼰ԺûʱЧԵSNڵ +* : struc_InputBuffer *NodeIndex ǰҪɾָ +* : struc_Unify_Info *pUnifyInfo ҪɾĽڵͨŶӦͳһṹ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 DelGroupNode(struc_InputBuffer *NodeIndex,struc_Unify_Info *pUnifyInfo); + + + +/***********************************************************************/ + +/* +*: JudgeCrc +*: жCRC,ԽCRCж,֡IDLE֡֡ҪRFCACKSN +*: UINT8 Rcv[] յ +* struc_Unify_Info *pUnifyInfoForRedun SFPṹ +*: +*: +*ֵ: 1:ɹ;0ʧ +*/ +static UINT16 JudgeCrc(UINT8 Rcv[], struc_Unify_Info *pUnifyInfoForRedun); + +/****************************************************************************************** +* : ദж֡ʵЧ.жкǷϷ㣬ϣ +* 1.յıкҪСڵǰкţӦڳʱǰ͵һݵıк +* 2.ܵĶԷкҪڵǰĶԷкŻҪСڳʱڷ͵к +* 3.Ĵ; +* : struc_Lnk_Mngr *lnk_index ·е· +* UINT32 local_sn к +* UINT32 dest_sn Էк +* UINT8 *pRecord ־ +* UINT16 recordMaxLen ־󳤶 +* : +* : +* ȫֱ : +* ֵ : кźϷ1򷵻0 +*******************************************************************************************/ +static UINT32 JudgeSN(struc_Lnk_Mngr *lnk_index, UINT32 local_sn, UINT32 dest_sn, UINT8 *pRecord, UINT16 recordMaxLen); + + + +/****************************************************************************************** +* : ȽDeviceName+SNĴСȽDeviceName+SNϺݵĴС豸DeviceNameǰSnں +* : UINT32 DeviceNameA 豸AName +* UINT8 SnA[] 豸ASN +* UINT32 DeviceNameB 豸BName +* UINT8 SnB[] 豸BSN +* : +* : +* ȫֱ : +* ֵ : a > b1;a == b 0;a < b-1 +*******************************************************************************************/ +static INT8 DevNameSNcmp(UINT32 DeviceNameA,UINT8 SnA[],UINT32 DeviceNameB,UINT8 SnB[]); + + + + +/****************************************************************************************** +* : Эģ봦 + 1. Ȱ൥Ԫ뵥ԪĽӿȡ£Ѿɵȥ + 2. ÿһ֡޸ɾýڵ估ͬtypeIDºĽڵ㣻 + 3. ޸һά󣬿ʼ޸·Ϣ֡ΪDATAдӦõĶУ + 4. ݴ󣬿ʼ·ʱΪ淽ҳʱɾ· +* : +* : struc_Unify_Info *pUnifyInfo Эʹõͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +static UINT8 Prtcl_Receive(struc_Unify_Info *pUnifyInfo); + + + +/****************************************************************************************** +* : Э봦ijʼ + 1. ͳһṹе뵥ԪӦõĽӿڶнгʼ +* : +* : struc_Unify_Info *pUnifyInfoForRcv Эʹõͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1,ʧܷ0 +*******************************************************************************************/ +UINT8 Prtcl_RecInitial(struc_Unify_Info *pUnifyInfo); + +#ifdef __cplusplus +} +#endif + +#else + +#endif + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclStruct.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclStruct.h new file mode 100644 index 0000000..08d4ac5 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtclStruct.h @@ -0,0 +1,181 @@ + +/******************************************************************************* +* ļ PrtclStruct.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* Э鹫ýṹͷļ +* ʹע + +* ޸ļ¼ + 2008.7.8޸ļ¼ + 1.struc_Unify_Infoͳһṹ嶨塣 + 2.Ӻ UINT32 GetTimeCounter(); + + 2008.7.29 ޸ļ¼ + 1. DSUؽṹ嶨ֲPrtclStruct.hУ + + 2009.1.20޸ļ¼ + 1.ɾdeclare.h + + 2009-8-27 15:19:06޸ļ¼ + 1.޸ͣʹCommonTypes.hеĶ + 2.struc_LnkBasicInfoɾunsigned char DestMultiCommIpRed[4]; + unsigned char DestMultiCommIpBlue[4]; + unsigned char DestGroup; + 3.struc_Lnk_Infoɾunsigned char CommType; + unsigned char DestGroup; + unsigned char DestMultiCommIpRed[4]; + unsigned char DestMultiCommIpBlue[4]; + 4.struc_CommConfigɾunsigned char MultiCommIpBlue[4]; + unsigned char MultiCommIpRed[4]; + unsigned char Group; +*******************************************************************************/ + + +#ifndef _SFPPRTCLSTRUCT_H +#define _SFPPRTCLSTRUCT_H + +#include "CommonTypes.h" + +/*ͳƶϢĽṹ*/ +typedef struct S_DuanLianInfo { + UINT32 DevName; /*豸+ID*/ + INT32 nTotalNums_DuanLian; /*ۻ*/ + INT32 nTotalNums_ReSnd[2]; /*ۻط*/ +} DuanLianInfo; + + +/***ڵṹ**/ +typedef struct InputBufferNode +{ + UINT32 DevName; /*豸ID*/ + UINT8 DevSn[4]; /*ԷSN*/ + UINT8 *data; /**/ + UINT8 cycle; /*άдڵ*/ + struct InputBufferNode *NextNode;/*һIDͨŶԷ·е׵ַ*/ +} struc_InputBuffer ; /*·*/ + + +/************************************************************************/ +/* Ԥͨ·ݽṹ */ +/************************************************************************/ + +typedef struct +{ + UINT8 chRole; /*곣01ʶ𷽺͸淽*/ + UINT32 nDestDevName; /*豸NAME(ID+TYPE)*/ + UINT8 chStatus; /*·״̬*/ + UINT8 destNum; /* Ŀϵ */ + UINT8 lastframe; /*յݵı*/ + UINT8 chDestIP[4][4]; /* IPַchIP[0]ΪԷIP, chIP[1]ΪԷIp*/ + UINT16 nPort[4]; /*˿ںţ0ΪԷ1ΪԷ*/ + UINT32 lastCycle; /*յݵ,ʱûõ*/ + UINT32 RfcSN; /*RFCʼк*/ + UINT32 AckSN; /*ACKʼк*/ + UINT32 lDestSN; /*Էк*/ + UINT32 lLocalSN; /*к*/ + UINT16 nCycle[2]; /*ķڣ0ΪԷ1Ϊ*/ + UINT16 nSnWidth[2]; /*Է̬кЧȣ̬кЧ*/ + UINT16 nTimeOut; /*ݱijʱʱ*/ + UINT16 nACKTOut; /*ACKijʱʱ*/ + UINT8 chNoDataRcvCycle; /*ûյݵֵΪ㣬Ҳ˵յ*/ + UINT16 DestMaxDelay; /*Էʱ(λΪms)ʱûõ*/ +} struc_Lnk_Info; /*·Ϣ*/ + +/***·ڵṹ***/ +typedef struct Lnk_Mngr_Node +{ + UINT32 DevName; /*豸NAME(ID+TYPE)*/ + struc_Lnk_Info Lnk_Info; /*·Ϣ˴Ϊһڵ*/ + struct Lnk_Mngr_Node *NextNode; /*һIDͨŶԷ·е׵ַ*/ +} struc_Lnk_Mngr ; /*·*/ + + + +/******м仺*********/ +typedef struct lOutputDataNode +{ + UINT32 DevName; /*豸NAME(ID+TYPE)*/ + UINT8 DataStatus; /*ݵ״̬SENT (0x33),Ѿͳȥ,˵Ϊ;NEED2SEND (0x55) Ҫ,˵*/ + UINT32 DataCycleNum; /*ݵں*/ + UINT16 DataLen; /*Ӧݳ*/ + UINT8 *chData; /**/ + struct lOutputDataNode *pNext; +} struc_OutputDataBuff; /*ݴ洢ռ,*/ + + + +/********ջͨ*********/ +typedef struct +{ + void** pNode; /*нڵֵʾǴ洢ݵĿռ*/ + UINT16 size; /*ĿǰջĴС.ͬʱֵҲǰջ,дԪҪŵ±.ڱջһ˳ջ,˳ջдֵӦdzʼΪ, + ֮,0STACK_MAXSIZE-1.*/ + UINT16 totalsize; /*˶ջܹŽڵ*/ + void* pFirstNode; /*ѹջĵַһĸԪأڿռͷʱֱӽӦĵַռͷţ˱ڼ¼ַ*/ +} StackElement; + + + +/*****ڱ*******/ +typedef struct AppOutput +{ + UINT16 AppDataLen; /*Ӧݳ,ݵij*/ + UINT32 DestDevName; /*Ŀ豸IDTYPE*/ + UINT8 *chAppData; /**/ +} struc_AppOutput; /*ݶеһṹڵ*/ + + +typedef struct { + UINT8 ID; /*¼,൱ڼ¼ 1 byte*/ + UINT32 DevName; /*豸 4 byte*/ + UINT8 IPBlue[4]; /*IPַ 4 bytes*/ + UINT16 PortBlue; /*˿ 2 bytes*/ + UINT8 IPRed[4]; /*IPַ 4 bytes*/ + UINT16 PortRed; /*˿ 2 bytes*/ +} struc_CommConfig; /*ͨñ 17 bytes*/ + +/************************************************************************/ +/* DSUؽṹ嶨 */ +/************************************************************************/ +typedef struct{ + UINT8 ID; /*¼,൱ڼ¼ 1 byte*/ + UINT32 SponDevType; /*豸 1 byte*/ + UINT8 SponCommType; /* 𷽷ͨͣҲǸ淽ݵͨͣ 1 byte*/ + UINT16 SponCycle; /*𷽱ķڳ(ķڳ) 2 bytes*/ + UINT16 SponMaxDelay; /*𷽱ʱBΪĵԷӳʱСֵΪĵԷӳʱֵ˱ֵΪ£2 bytes*/ + UINT16 AckMaxDelay; /*7.11ӣյAckʱBΪRfcĵԷӳʱСֵΪյAckӳʱֵ˱ֵΪ£2 bytes*/ + UINT32 FlwDevType; /*淽豸 1 byte*/ + UINT8 FlwCommType; /*淽ͨͣҲǷͷݵͨͣ 1 byte*/ + UINT16 FlwCycle; /*淽ڳ(ķڳ) 2 bytes*/ + UINT16 FlwMaxDelay; /*淽ʱBΪĵԷӳʱСֵΪĵԷӳʱֵ˱ֵΪ£2 bytes*/ + UINT8 NCyclesPerPack; /*ͨŹϵгɹһС 1 byte*/ +} struc_DiffDevRelations; /*ͬ豸ͨԼϵ 14 bytes*/ + +typedef struct{ + UINT8 ID; /*¼,൱ڼ¼ 1 byte*/ + UINT32 SponDevName; /*豸name 4 byte*/ + UINT8 SponCommType; /* 𷽷ͨͣҲǸ淽ݵͨͣ1 byte*/ + UINT16 SponCycle; /*𷽱ķڳ(ķڳ) 2 bytes*/ + UINT16 SponMaxDelay; /*𷽱ʱBΪĵԷӳʱСֵΪĵԷӳʱֵ˱ֵΪ£2 bytes*/ + UINT16 AckMaxDelay; /*7.11ӣյAckʱBΪRfcĵԷӳʱСֵΪյAckӳʱֵ˱ֵΪ£2 bytes*/ + UINT32 FlwDevName; /*淽豸name 4 byte*/ + UINT8 FlwCommType; /*淽ͨͣҲǷͷݵͨͣ 1 byte*/ + UINT16 FlwCycle; /*淽ڳ(ķڳ) 2 bytes*/ + UINT16 FlwMaxDelay; /*淽ʱBΪĵԷӳʱСֵΪĵԷӳʱֵ˱ֵΪ£2 bytes*/ + UINT8 NCyclesPerPack; /*ͨŹϵгɹһС 1 byte*/ +} struc_SameDevRelations; /*ͬ豸ͨԼϵ 20 bytes*/ + +/*յ*/ +typedef struct +{ + UINT32 DstDevName; + UINT16 NetsPkgNum[2]; +}SfpNetsRecvPkgNum; + +#else + +#endif + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtcl_Output.c b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtcl_Output.c new file mode 100644 index 0000000..6108d3d --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtcl_Output.c @@ -0,0 +1,1886 @@ + +/******************************************************************************* +* ļ Prtcl_Output.c +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* ͨЭԪģԴļ +* ʹע + +* ޸ļ¼ + 1ЭBuildOutputDataڵӺʱӺ-1BuildOutputData1Ӧñ + ΪӦøĴݣߺӦøIJϵĻֻЭڲѴ¼ + 2IP˿ڵ֡õϢһɴݿжȡڶԭҪÿڶݿжȡһ + 3ڰӦݵ뵽ṹеʱҪжӦݵijȣݳȳӦȷֵ + Эڴ˴¼˳ڼ֡ + 4鲻Ӧ֡ʱֻе֡кʵʲᷢ + 2009.1.21޸ļ¼ + 1ֽڳ2ֽڸΪ4ֽڣnNumsPrtclSndԼCurFrameStartIndexunsigned shortΪunsigned long + 2ݳ0 ProtclOutputDivide_long_to_char( (UINT32)(nNumsPrtclSnd - 4),temp_char);ΪDivide_long_to_char( (UINT32)(nNumsPrtclSnd - 8),temp_char); + ܳLongToChar( (UINT32)(nNumsPrtclSnd - 2),temp_char);ΪDivide_long_to_char( (UINT32)(nNumsPrtclSnd - 4),temp_char); + ޸ıǩpeipei.wang20111011 + ޸ݣ1ֲAbsTimeoutForOutputɾ¶startTimeoutForOutputʼʱ䣩ͨGetTick(pUnifyInfoForOutput)ã + 2ԭʱжϴʱ䷭תΪǰʱ- ģ鿪ʼʱ < ģִʱޣ + + ޸ıǩpeipei.wang20120522 + ޸ݣ1BuildFrameеUINT32 iǿתΪUINT16 ޸ģԭе +*******************************************************************************/ + +#include "sfpPrtcl_Output.h" +#include "sfpDeclare.h" +#include "dsuRelatedDeal.h" +#include "CommonMemory.h" + +/* +*: Insert_OutputDataBuff +*: ڵ֮һڵ,ӶջƳһԪ洢 +*: struc_OutputDataBuff* pLastNode ǰڵ +* struc_OutputDataBuff* pCurNode ǰڵ +* UINT32 DevName 豸type+IDָԷģ +* UINT8 data_status ״̬(ѷ δ) +* UINT16 data_len ݳ(ָǴݵij) +* UINT8 data[] +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: +*: +*ֵ: ɹصǰָ,򷵻ش(ؿռΪ) +*/ +static struc_OutputDataBuff* Insert_OutputDataBuff(struc_OutputDataBuff *pLastNode, struc_OutputDataBuff *pCurNode, UINT32 DevName, UINT8 data_status, UINT16 data_len, UINT8 data[], struc_Unify_Info *pUnifyInfoForOutput) +{ + + struc_OutputDataBuff *pSrcNode;/*ʹöջеĽڵΪӵĵַ*/ + UINT16 i; + + pSrcNode = (struc_OutputDataBuff *)PopStack(&pUnifyInfoForOutput->OutputStack); + if (pSrcNode == NULL)/*ջΪ,Žв,򱨴,ؿ*/ + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + +#endif + + return NULL; + } + else + { + /*ջǿգִIJ*/ + } + + if (pLastNode == NULL)/*ǰڵΪ*/ + { + pUnifyInfoForOutput->OutputDataBuffHead = pSrcNode;/*޸ͷڵ*/ + } + else + { + pLastNode->pNext = pSrcNode;/*ǰڵָԴڵ*/ + } + + pSrcNode->DevName = DevName;/*豸name*/ + pSrcNode->DataStatus = data_status;/*ݷ״̬*/ + pSrcNode->DataCycleNum = *pUnifyInfoForOutput->CycleNum;/*¼ǰں*/ + pSrcNode->DataLen = data_len;/*ݳ*/ + for(i = 0;i < data_len;i++) + { + pSrcNode->chData[i] = data[i];/**/ + } + + pSrcNode->pNext = pCurNode;/*޸nextָ*/ + + return pSrcNode;/*زڵָ,ָǰָ*/ +} + +/* +*: Delete_OutputDataBuff +*: ǰڵͱڵ,ɾڵ +*: struc_OutputDataBuff *pLastNode ǰڵ +* struc_OutputDataBuff *pCurNode ǰڵ +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: +*: +*ֵ: ɾɹеǰڵһڵ(NULLҲȷ),󷵻ΪNULL_ITEM +*/ +static struc_OutputDataBuff* Delete_OutputDataBuff(struc_OutputDataBuff *pLastNode,struc_OutputDataBuff *pCurNode, struc_Unify_Info *pUnifyInfoForOutput) +{ + + struc_OutputDataBuff *pNode; + + /*ȵָѹջ*/ + if (pLastNode == NULL)/*ǰڵΪ*/ + { + pUnifyInfoForOutput->OutputDataBuffHead = pCurNode->pNext;/*޸ͷڵ*/ + } + else + { + pLastNode->pNext = pCurNode->pNext;/*ǰڵָһڵ*/ + } + pNode = pLastNode;/*صǰڵһڵ*/ + + if (PushStack(&pUnifyInfoForOutput->OutputStack,pCurNode) != 1) + { + /*¼¼ջѹջ*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_PUSH); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_PUSH); + +#endif + + return NULL_ITEM; + } + else + { + /*ѹջɹ޲*/ + } + + return pNode; +} + + +/****************************************************************************************** +* : Эijʼ +* : +* : struc_Unify_Info *pUnifyInfo óʼӦͳһṹ +* : +* ȫֱ : UINT32 nNumsPrtclSnd Эݵĸ(ֽΪλ) + struc_Lnk_Mngr* pCurProc_Lnk ·еǰĵ·ָ,ָ룬ʵ + UINT8 chCurProcItemSrc ǰҪԪصԴ + struc_OutputDataBuff *pLastDataBuffItem ʾǰݴ洢Ԫָ + struc_OutputDataBuff *pCurDataBuffItem ʾһδݴ洢Ԫָ +* ֵ : ʼɹ1 ʧܷ0 +*******************************************************************************************/ +UINT8 Prtcl_OutputInitial(struc_Unify_Info *pUnifyInfo) +{ + UINT16 i; + UINT8 ret; + UINT16 DSUNumNodes; /*ݿнڵ*/ + + if(QueueInitial(&pUnifyInfo ->OutputDataQueue,pUnifyInfo->OutputDataQueueSize)!=1) + { + ret = 0; + return ret; + } + else + { + /*гʼɹ޲*/ + } + + /*ʼ*/ + if( InitOutputStack(&pUnifyInfo->OutputStack,pUnifyInfo->OutputSize) != 1) + { + ret = 0; + return ret;/*ջʼ*/ + } + else + { + /*ʼɹ޲*/ + } + + pUnifyInfo->OutputDataBuffHead = NULL; /*ñʼΪ*/ + + DSUNumNodes = dsuGetObjNum(pUnifyInfo);/*DSUе豸*/ + /*ؽͳƽṹijʼ*/ + for(i = 0; i < DSUNumNodes; i++) + { + pUnifyInfo->NumBuildLink[i].DevName = 0; + pUnifyInfo->NumBuildLink[i].nTotalNums_DuanLian = 0; + pUnifyInfo->NumBuildLink[i].nTotalNums_ReSnd[0] = 0; + pUnifyInfo->NumBuildLink[i].nTotalNums_ReSnd[1] = 0; + } + + ret = 1; + return ret; +} + +/* +*: DeQueue_OutputData +*: ӶȡݷڽṹԪ +*: struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: +*: struc_AppOutput* pOut Ӧõ1,ָ +*ֵ: 1:ɹ;0ʧ +*/ +static INT8 DeQueue_OutputData(struc_AppOutput *pOut, struc_Unify_Info *pUnifyInfoForOutput) +{ + UINT8 temp[4];/*ֽڵλ,ֽڸλ*/ + UINT16 len;/**/ + INT8 ret; + + + /*жǷΪ*/ + if (QueueStatus(&pUnifyInfoForOutput->OutputDataQueue) == 0) + { + ret = 0; + return ret; + } + else + { + /*зǿգִIJ*/ + } + + /*Ϊ߰ȫӦжܷһڵ*/ + if(QueueScan(2,temp,&pUnifyInfoForOutput->OutputDataQueue) == 0)/*ȡɹ,*/ + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_INTEGRITY); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif + +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_INTEGRITY); + +#endif + + ret = -1; + return ret;/**/ + } + else + { + /*Զڵ㣬ִIJ*/ + } + + /*һݽڵij = ڵ㳤 + 2*/ + len = ShortFromChar(temp)+ 2; + /*жӦøǷ񳬹󳤶*/ + if((len - 6) > pUnifyInfoForOutput->OutputSize) + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|APPDATA_LENGTH_ERR|ERROR_NULL); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|APPDATA_LENGTH_ERR|ERROR_NULL); + +#endif + + ret = -1; + return ret; + } + else + { + /*ȺϷ*/ + } + + if(QueueStatus(&pUnifyInfoForOutput->OutputDataQueue) < len)/*Զһڵ,ĺôDzƻеĽṹ*/ + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_INTEGRITY); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_INTEGRITY); + +#endif + + ret = -1; + return ret;/**/ + } + else + { + /*Զڵ*/ + } + + /*ȵõнڵ㳤,ڵ㳤Ȳݳֽ,ڵɨ*/ + if(QueueRead(2,temp,&pUnifyInfoForOutput->OutputDataQueue) != 1)/*ȡɹ,*/ + { + /*д*/ + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_READ); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_READ); + +#endif + + ret = -1; + return ret;/**/ + } + else + { + /*гɹ*/ + } + + /*ݵij = ڵ㳤 - 4*/ + pOut->AppDataLen = ShortFromChar(temp)-4; + + /*ȡĿname 4ֽ*/ + if(QueueRead(4,temp,&pUnifyInfoForOutput->OutputDataQueue) != 1)/*ȡɹ,*/ + { + /*д*/ + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_READ); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_READ); + +#endif + + ret = -1; + return ret;/**/ + } + else + { + /*гɹ*/ + } + + + /*ȡĿname4ֽ,ͷԤֽó0*/ + temp[0] = 0; + temp[1] = 0; + pOut->DestDevName = LongFromCharLE(temp); + /**/ + if(QueueRead(pOut->AppDataLen,pOut->chAppData,&pUnifyInfoForOutput->OutputDataQueue) != 1)/*ȡɹ,*/ + { + /*д*/ + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_READ); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|QUEUE_READ); + +#endif + + ret = -1; + return ret;/**/ + } + else + { + /*гɹ*/ + } + +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"DName:"); + PrintFileU32Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pOut->DestDevName); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"AppDataLen:"); + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)pOut->AppDataLen); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + 0x40); + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT16)((pOut->DestDevName >> 16) & 0xffff)); + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pOut->AppDataLen); +#endif + + ret = 1; + return ret;/*ڵȡ*/ +} + +/* +*: Queue2Buff +*: ݶе䵽صݻڵȥ +*: struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: +*: +*ֵ: 1:ɹ;-1ʧ +*/ +static INT8 Queue2Buff(struc_Unify_Info *pUnifyInfoForOutput) +{ + struc_AppOutput pCurProc_QueueItem; /*ݶеǰĵĽڵֵʵ壬ָ*/ + struc_OutputDataBuff *pLastNode;/*ʾǰݴ洢Ԫָ*/ + struc_OutputDataBuff *pCurNode;/*ʾһδݴ洢Ԫָ*/ + INT8 IsQueueEmpty;/*ʾǷΪգҪʹþ̬*/ + UINT16 i;/*ѭ*/ + INT8 ret; + + /*ע⣺ЭʱchAppDataӦʹ*/ + pCurProc_QueueItem.chAppData = pUnifyInfoForOutput->PrtclSndBuff; + + /*¼¼*/ +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"AppQueLen:"); + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)QueueStatus(&pUnifyInfoForOutput->OutputDataQueue)); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); +#endif + +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray4ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + QueueStatus(&pUnifyInfoForOutput->OutputDataQueue)); +#endif + + /*ȷݶȡһڵ,ֱӷش*/ + IsQueueEmpty = DeQueue_OutputData(&pCurProc_QueueItem, pUnifyInfoForOutput); + if( IsQueueEmpty == -1 ) /*ȡݻеһԪ*/ + { + ret = -1; + return ret; /*һݱ*/ + } + else + { + /*ȷݶжȡһڵ*/ + } + while(IsQueueEmpty != 0)/*ݶвΪ*/ + { + /*Ϊ·ҵʵĵԪ*/ + pLastNode = NULL;/*һδָΪ*/ + pCurNode = pUnifyInfoForOutput->OutputDataBuffHead; /*ǰҪݻλݻͷڵ*/ + while(1) + { + if(pCurNode != NULL) + { + if(pCurProc_QueueItem.DestDevName > pCurNode->DevName) + {/*ݶнڵ豸ݻڵ豸*/ + /*ӦݻӴ豸Ľڵ*/ + pCurNode = Insert_OutputDataBuff(pLastNode, pCurNode, pCurProc_QueueItem.DestDevName, + NEED2SEND, pCurProc_QueueItem.AppDataLen, pCurProc_QueueItem.chAppData, pUnifyInfoForOutput); + if( pCurNode == NULL) + { + /*ʧ*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + +#endif + + } + else + { + /*ڵɹ*/ + } + break;/*while(1)ı·洢Ԫ*/ + } + else if(pCurProc_QueueItem.DestDevName == pCurNode->DevName) + {/*ҵݻд豸Ľڵ*/ + /**/ + pCurNode->DataLen = pCurProc_QueueItem.AppDataLen;/*ݵij*/ + pCurNode->DataCycleNum = *pUnifyInfoForOutput->CycleNum;/*¼ǰں*/ + for(i = 0;i < pCurProc_QueueItem.AppDataLen;i++) + { + pCurNode->chData[i] = pCurProc_QueueItem.chAppData[i];/**/ + } + pCurNode->DataStatus = NEED2SEND;/*״̬Ϊδ*/ + pLastNode = pCurNode;/*ݵԪ*/ + pCurNode = pCurNode->pNext;/*ݵԪ*/ + break;/*while(1)ı·洢Ԫ*/ + } + else /*˵ûҵ豸Ľڵ㣬ѭ*/ + { + pLastNode = pCurNode;/*ݵԪ*/ + pCurNode = pCurNode->pNext;/*ݵԪ*/ + } + } + else/*ǰҪݻָΪ*/ + {/*ڵ*/ + pCurNode = Insert_OutputDataBuff(pLastNode, pCurNode, pCurProc_QueueItem.DestDevName, + NEED2SEND, pCurProc_QueueItem.AppDataLen, pCurProc_QueueItem.chAppData, pUnifyInfoForOutput); + if(pCurNode == NULL) + { + /*ʧ*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + +#endif + + } + break; + } + } + IsQueueEmpty = DeQueue_OutputData(&pCurProc_QueueItem, pUnifyInfoForOutput); + if( IsQueueEmpty == -1 ) /*ȡݻеһԪ*/ + { + ret = -1; + return ret; /*һݱ*/ + } + else + { + /*ȷݶжȡһڵ*/ + } + } + ret = 1; + return ret; +} + +/* +*: GetNextItem2Proc +*: õҪһͨŶ:˼·Ǵݻʹ·зֱȡ +* δDeviceNameֵĽڵ㣬ȻȽȡDeviceNameֵѡֵĽڵΪϲ +* ѭд˴ҪĶ󡣴ԭΪͨŶֻ·еĶǣ +* ·ӶӦڵ㣨ֻЭ뵥ԪյRFCˣ˶ֻݻдʱ +* Ȳڴ˻ڶ·κ޸ģӦõһҪijݻӦɾл֣˶ +* ·кݻжʱҲٴ˻ڶ·ݻཻһֽ +* д˻ڵĴȫֱʽӳһڡ +* зֵҪʾܷȡЧ󣬶ʵҪĶͨ +*: UINT8 NeedToInit ǷҪʼ,ҪΪΪ +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: UINT8 *chCurProcItemSrc ǰҪԪصԴ +* struc_Lnk_Mngr **pCurProc_Lnk ǰ· +* struc_OutputDataBuff **pLastDataBuffItem; ʾǰݴ洢Ԫָ +* struc_OutputDataBuff **pCurDataBuffItem; ʾһδݴ洢Ԫָ +*: +*ֵ: ɹطǸֵнڵҪʱ1޽ڵҪʱ0,ʧܷ-1 +*/ +static INT8 GetNextItem2Proc(UINT8 NeedToInit, UINT8 *chCurProcItemSrc, struc_Lnk_Mngr **pCurProc_Lnk, struc_OutputDataBuff **pLastDataBuffItem, struc_OutputDataBuff **pCurDataBuffItem, struc_Unify_Info *pUnifyInfoForOutput) +{ + UINT8 temp; + INT8 ret; + + if(NeedToInit) + { + *pLastDataBuffItem = NULL; /*ǰ·Ľڵ㶨λ·ͷָ*/ + *pCurDataBuffItem = pUnifyInfoForOutput->OutputDataBuffHead; /*ǰҪݻָ붨λݻͷڵ*/ + *pCurProc_Lnk = pUnifyInfoForOutput-> LnkHead; /*·ͷڵָ*/ + } + else + { + switch(*chCurProcItemSrc)/*һθıڴһڵʱ,һεIJ*/ + { + case ITEMSRC_DATABUFF:/*пܳҪָ뻹ҪָԪصҪз*/ + *pLastDataBuffItem = *pCurDataBuffItem;/*һδݻĽڵΪǰݻڵ,ʵҲǺһڵ*/ + if(*pCurDataBuffItem != NULL)/*ǰݻĽڵһڵ*/ + { + *pCurDataBuffItem = (*pCurDataBuffItem)->pNext; + } + else + { + *pCurDataBuffItem = pUnifyInfoForOutput->OutputDataBuffHead; /*???ӦΪNULLΪOutputDataBuffHead???*/ + } + break; + case ITEMSRC_LNKMNGR:/*ڵֻ·ڵʱӦһݻڵ㣬IJͬBOTHһ*/ + case ITEMSRC_BOTH:/*пܳҪָ뻹ҪָԪصҪз*/ + /*ǰ·Ľڵһڵ*/ + *pCurProc_Lnk = (*pCurProc_Lnk)->NextNode; + + *pLastDataBuffItem = *pCurDataBuffItem;/*һδݻĽڵΪǰݻڵ,ʵҲǺһڵ*/ + if(*pCurDataBuffItem != NULL)/*ǰݻĽڵһڵ*/ + { + *pCurDataBuffItem = (*pCurDataBuffItem)->pNext; + } + else + { + *pCurDataBuffItem = pUnifyInfoForOutput->OutputDataBuffHead;/*???ӦΪNULLΪOutputDataBuffHead???*/ + } + break; + default: + break; + } + } + if((NULL==(*pCurDataBuffItem)) && (NULL==(*pCurProc_Lnk)))/*ǰ·Ľڵ㲢ҵǰҪݻָҲΪ*/ + { + ret = 0; + return ret;/*ѾûЧĴ,0*/ + } + else if(NULL==(*pCurProc_Lnk))/*·ָΪ*/ + {/*˵Ҫݻ˵·Ѿɾ·Ҫ·Ӧ*/ + *chCurProcItemSrc = ITEMSRC_DATABUFF;/*ǰݶԴΪݻ֮IJӦɾڵ*/ + } + else if(*pCurDataBuffItem == NULL)/*ǰҪݻָΪ*/ + {/*Ҫ·,˵Ҫһڵ洢˽ڵ*/ + temp = 0x00;/*ûʱҪһݻڵʱĬϲ0x00*/ + /*ݻϴδָ֮ڵ㣬ȥһݣ״̬ΪҪ,ԭ뵥Ԫ + δ֪ԭijݻڵ㶪ʧ*/ + *pCurDataBuffItem = Insert_OutputDataBuff(*pLastDataBuffItem, *pCurDataBuffItem, + (*pCurProc_Lnk)->Lnk_Info.nDestDevName, SENT, 1, &temp, pUnifyInfoForOutput); + if(*pCurDataBuffItem == NULL) + { +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif + +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + +#endif + + /*ʧ*/ + ret = -1; + return ret;/**/ + } + *chCurProcItemSrc = ITEMSRC_LNKMNGR;/*ǰ·*/ + } + else/*߶,ʱҪжnameĴС*/ + { + /*ݻname>·name*/ + if(((*pCurDataBuffItem)->DevName) > ((*pCurProc_Lnk)->Lnk_Info.nDestDevName)) + { + *chCurProcItemSrc = ITEMSRC_DATABUFF; + } + /*ݻname=·name*/ + else if(((*pCurDataBuffItem)->DevName) == ((*pCurProc_Lnk)->Lnk_Info.nDestDevName)) + { + *chCurProcItemSrc = ITEMSRC_BOTH; + } + /*ݻname<·name*/ + else + { + temp = 0x00; + /*ݻ²һ*/ + *pCurDataBuffItem = Insert_OutputDataBuff(*pLastDataBuffItem, *pCurDataBuffItem, + (*pCurProc_Lnk)->Lnk_Info.nDestDevName, SENT, 1, &temp, pUnifyInfoForOutput); + if(*pCurDataBuffItem == NULL) + { + /*ʧ*/ + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_POP); +#endif + + ret =-1; + return ret;/**/ + } + *chCurProcItemSrc = ITEMSRC_LNKMNGR; + } + } + + ret = 1; + return ret;/*ЧĴ󣬷1*/ +} + +/* +*: BuildFrame +*: ֡ͣ·ԼӦݣ֡ʽӦ֡ +*: UINT8 frametype ֡ +* struc_OutputDataBuff* pSrcData ӦݴŻ +* struc_Lnk_Mngr* pSrcLnk ·е· +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: UINT32 *nNumsPrtclSnd ± +*: +*ֵ: 1:ɹ;0ʧ +*/ +static INT8 BuildFrame(UINT8 frametype, struc_OutputDataBuff *pSrcData, struc_Lnk_Mngr *pSrcLnk, UINT32 *nNumsPrtclSnd, struc_Unify_Info *pUnifyInfoForOutput) +{ + UINT16 temp_short; + UINT16 temp_SendLen; + UINT32 temp_long; + UINT8 temp_char[4]; + UINT32 i; + UINT32 CurFrameStartIndex; + UINT32 LocalDevName; + INT8 ret; + UINT16 tmplen = 0; + UINT8 *msgBuff; + + UINT8 longDevName[4]; + + LocalDevName = TypeIdToName(pUnifyInfoForOutput->LocalType,pUnifyInfoForOutput->LocalID); + CurFrameStartIndex = *nNumsPrtclSnd; + if(frametype == FRAME_DATA)/*֡,ô֡дݳΪʵҪ͵ݳ,Ϊ0*/ + { + temp_SendLen = pSrcData->DataLen; + } + else + { + temp_SendLen = 0; + } + +#ifdef DUAL_CRC + temp_short = 27 + 1 + 1 + 1 + 2 + temp_SendLen; +#else + temp_short = 23 + 1 + 1 + 1 + 2 + temp_SendLen; +#endif + + /*жǷ*/ + i = pUnifyInfoForOutput->PrtclSndBuffSize - (*nNumsPrtclSnd) - 2; + if( i < (UINT32)(temp_short + 2 + 8)) + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|ARRAY_FULL); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|ARRAY_FULL); + +#endif + + ret = 1; + return ret; + } + else + { + /**/ + } + ShortToChar(temp_short,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + + /* 2 ЭSFP=1 */ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 1; + + LongToChar(pSrcLnk->Lnk_Info.nDestDevName,longDevName); + + /* 3 Ŀ豸TYPE */ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = longDevName[0]; + + /* 4 Ŀ豸ID */ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = longDevName[1]; + + /* 5-6 ֽ */ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0; + + /*7-8 ݳ Int37-58+n-1*/ + msgBuff = pUnifyInfoForOutput->PrtclSndBuff+(*nNumsPrtclSnd); + +#ifdef DUAL_CRC + temp_short = 25 + temp_SendLen; +#else + temp_short = 21 + temp_SendLen; +#endif + + ShortToChar(temp_short,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + + /*6-9 ͷк Long,4ֽڵк*/ + LongToChar(pSrcLnk->Lnk_Info.lLocalSN,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + + /*10-13 շк Long,4ֽڵк*/ + LongToChar(pSrcLnk->Lnk_Info.lDestSN,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + + /* UINT8,ת*/ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = frametype; + + /* Ŀ߼ID+type INT8,ĿIDţ4ֽ*/ + LongToCharLE(pSrcLnk->Lnk_Info.nDestDevName,&pUnifyInfoForOutput->PrtclSndBuff[*nNumsPrtclSnd]); + *nNumsPrtclSnd = (*nNumsPrtclSnd) + 4; + + /* Դ߼ID+type INT8,ԴIDţ4ֽ*/ + LongToCharLE(LocalDevName,&pUnifyInfoForOutput->PrtclSndBuff[*nNumsPrtclSnd]); + *nNumsPrtclSnd = (*nNumsPrtclSnd) + 4; + + tmplen = 21 + 5; + /* Ӧ ϢͲ*/ + for(i = tmplen;(UINT16) i < temp_SendLen + tmplen;i++) + { + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = pSrcData->chData[i- tmplen]; + } + + /*(54+n)-(57+n) ЭCRC 37-53+nCRC*/ + /*֡Ϊ֡IDLE֡ʱCRCҪϳʼк*/ + if((frametype == FRAME_DATA) || (frametype == FRAME_IDLE)) + { + /*ȡRFCijʼк*/ + LongToChar(pSrcLnk->Lnk_Info.RfcSN, temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + /*ȡACKijʼк*/ + LongToChar(pSrcLnk->Lnk_Info.AckSN, temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + /*Ƶcrcʼλ*/ + *nNumsPrtclSnd = (*nNumsPrtclSnd) - 8; + /*CRC*/ + /* temp_long = Crc32(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 6+pSrcLnk->Lnk_Info.destNum *12 + LocalNum * 12], (UINT16)(temp_SendLen + 25)); */ + temp_long = Crc32(msgBuff+2,(UINT32)(temp_SendLen + 25)); + LongToChar(temp_long, temp_char); + +#ifdef DUAL_CRC + if (0u == pUnifyInfoForOutput->CpuId) /*CPU0 һCRCλøֵ*/ + { + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + } + else /*CPU1 ڶCRCλøֵ*/ + { + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + } +#else +#ifdef SWAP_CRC + tmplen = ShortFromChar(&pUnifyInfoForOutput->SwapCrcs[0]); /*ȡ2ֽܳ*/ + LongToChar(temp_long, &pUnifyInfoForOutput->SwapCrcs[2u + tmplen]); /*׷CRC*/ + ShortToChar(tmplen + 4u, &pUnifyInfoForOutput->SwapCrcs[0]); /*2ֽܳ*/ + + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; +#else + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; +#endif +#endif + + + } + /*֡ΪRFCACK*/ + else + { + /* temp_long = Crc32(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 6+pSrcLnk->Lnk_Info.destNum *12 + LocalNum * 12], (UINT16)(temp_SendLen + 17));*/ /*CRC*/ + temp_long = Crc32(msgBuff+2,(UINT16)(temp_SendLen + 17)); + LongToChar(temp_long, temp_char); + +#ifdef DUAL_CRC + if (0u == pUnifyInfoForOutput->CpuId) /*CPU0 һCRCλøֵ*/ + { + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + } + else /*CPU1 ڶCRCλøֵ*/ + { + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + } +#else +#ifdef SWAP_CRC + tmplen = ShortFromChar(&pUnifyInfoForOutput->SwapCrcs[0]); /*ȡ2ֽܳ*/ + LongToChar(temp_long, &pUnifyInfoForOutput->SwapCrcs[2u + tmplen]); /*׷CRC*/ + ShortToChar(tmplen + 4u, &pUnifyInfoForOutput->SwapCrcs[0]); /*2ֽܳ*/ + + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = 0u; +#else + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; +#endif +#endif + } + + /*¼¼*/ +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + /*ͷк*/ + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"LSN:"); + PrintFileU32Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 9])); + /*շк*/ + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"DSN:"); + PrintFileU32Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 13])); + /**/ + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"MType:"); + PrintFileHex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + &pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 17],1); + /*ĿID*/ + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"AName:"); + PrintFileU32Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)LongFromCharLE(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 18])); + /*ԴID*/ + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"SName:"); + PrintFileU32Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)LongFromCharLE(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 22])); + /*ݳ*/ + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"Len:"); + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)(ShortFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 7]) -21)); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + /*Э鷢͵֡*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + 0x80); + /*ӡLocalSN*/ + PrintRecArray4ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 9])); + /*ӡDestSN*/ + PrintRecArray4ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 13])); + /*ӡϢ*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 17]); + /*ӡĿType*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 21]); + /*ӡĿID*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 20]); + /*ӡԴType*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 25]); + /*ӡԴID*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 24]); + /*֡Ӧݳ*/ + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ShortFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 7]) -21); + +#endif + + ret = 1; + return ret; +} + +/* +*: FillLnkMngr_into_PrtclSnd +*: ·ijһ·Ϣ䵽һάȥ +*: struc_Lnk_Mngr* CurLnk ǰ· +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: UINT32 *nNumsPrtclSnd ± +*: +*ֵ: 1:ɹ;0ʧ +*/ +static INT8 FillLnkMngr_into_PrtclSnd(struc_Lnk_Mngr *CurLnk, UINT32 *nNumsPrtclSnd, struc_Unify_Info *pUnifyInfoForOutput) +{ + UINT8 temp_char[4]; + UINT32 CurFrameStartIndex; + INT8 ret; + + CurFrameStartIndex = *nNumsPrtclSnd; + + /*Role ·бɫ UINT8,1ֽ 0*/ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = CurLnk->Lnk_Info.chRole; + + /*DestID Է豸ID+TYPENAME INT8[4],4ֽ 1-4*/ + LongToCharLE(CurLnk->Lnk_Info.nDestDevName,&pUnifyInfoForOutput->PrtclSndBuff[*nNumsPrtclSnd]); + + *nNumsPrtclSnd = (*nNumsPrtclSnd) + 4; + + /*Status ·״̬ UINT8,1ֽ 5*/ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = CurLnk->Lnk_Info.chStatus; + + /*LocalSN ͷк UINT32,4ֽ 27-30*/ + LongToChar(CurLnk->Lnk_Info.lLocalSN,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + + /*DestSN շк UINT32,4ֽ 31-34*/ + LongToChar(CurLnk->Lnk_Info.lDestSN,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + + /*LocalSnWidth кЧȣжSNǷϷʱʹã Unsigned short2ֽ 35-36*/ + ShortToChar(CurLnk->Lnk_Info.nSnWidth[1],temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + + /*DestSnWidth ԷкЧȣжSNǷϷʱʹã Unsigned short2ֽ 37-38*/ + ShortToChar(CurLnk->Lnk_Info.nSnWidth[0],temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + + /*LocalTimeOutRcv ݱĽճʱʱ() Unsigned short2ֽ 39-40*/ + ShortToChar(CurLnk->Lnk_Info.nTimeOut,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + + /*LocalTimeOutAck AckĽճʱʱ() Short2ֽ 41-42*/ + ShortToChar(CurLnk->Lnk_Info.nACKTOut,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + + /*RecDataProNum յݵں UINT32,4ֽ 43-46*/ + LongToChar(CurLnk->Lnk_Info.lastCycle,temp_char); + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = temp_char[3]; + + /*Frametype յݵı UINT8,1ֽ 47*/ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = CurLnk->Lnk_Info.lastframe; + + /*NoDataRcvCycle ûյݵ UINT8,1ֽ 48*/ + pUnifyInfoForOutput->PrtclSndBuff[(*nNumsPrtclSnd)++] = CurLnk->Lnk_Info.chNoDataRcvCycle; + + /*RFCʼк 50-53*/ + LongToChar(CurLnk->Lnk_Info.RfcSN,&pUnifyInfoForOutput->PrtclSndBuff[*nNumsPrtclSnd]); + + *nNumsPrtclSnd = (*nNumsPrtclSnd) + 4; + + /*ACKʼк 54-57*/ + LongToChar(CurLnk->Lnk_Info.AckSN,&pUnifyInfoForOutput->PrtclSndBuff[*nNumsPrtclSnd]); + + *nNumsPrtclSnd = (*nNumsPrtclSnd) + 4; + + /*¼¼*/ +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"Name:"); + PrintFileU32Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + LongFromCharLE(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 1])); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"Role:"); + PrintFileHex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + &pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex],1); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"Status:"); + PrintFileHex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + &pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 5],1); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"LSN:"); + PrintFileU32Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 6])); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"DSN:"); + PrintFileU32Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 10])); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"NoData:"); + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)(pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 27])); + PrintFilec(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,'\n'); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + 0xC0 | pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex]); + /*Ŀtype*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 4]); + /*ĿID*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 3]); + /*ӡ·״̬*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 5]); + /*ӡûյ*/ + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 27]); + /*ӡк*/ + PrintRecArray4ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 6])); + /*ӡԷк*/ + PrintRecArray4ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[CurFrameStartIndex + 10])); +#endif + + ret = 1; + return ret; +} + + +/****************************************************************************************** +* : ЭԪ,ЭĹ,Ӧô֡, + ΪݱȽϵԪ׼ñ,ͬʱά· +* : +* : struc_Unify_Info* pUnifyInfo Эͳһṹָ +* : +* ȫֱ : UINT32 nNumsPrtclSnd Эݵĸ(ֽΪλ) + struc_Lnk_Mngr *pCurProc_Lnk ·еǰĵ·ָ,ָ룬ʵ* + UINT8 chCurProcItemSrc ǰҪԪصԴ ITEMSRC_BOTH (ݶк·) 0x17;ITEMSRC_DATAQUEUE (ݶ) 0x33;ITEMSRC_LNKMNGR(·) 0x55 + struc_OutputDataBuff *pLastDataBuffItem ʾǰݴ洢Ԫָ + struc_OutputDataBuff *pCurDataBuffItem ʾһδݴ洢Ԫָ + struc_Unify_Info *pUnifyInfoForOutput ƽ̨ṹָ +* ֵ : ȷ1󷵻0 +*******************************************************************************************/ +UINT8 ProtclOutput(struc_Unify_Info *pUnifyInfo)/* %RELAX */ +{ + UINT8 blNeedToInit; + UINT8 temp_char[4]; + struc_Lnk_Mngr *CurFillLnk;/*嵱ǰָ;*/ + UINT8 Role; + /*UINT8 index;*/ + INT8 ResultofGet;/*GetNextItem2ProcĴ*/ + INT32 i; + UINT16 DSUNumNodes; /*ݿнڵ*/ + + /*struc_LnkBasicInfo BasicInfoForLocal;*/ + /* peipei.wang20111011 mod S */ + /*ɾʱֵ׷ʼʱ*/ + /*UINT32 AbsTimeoutForOutput;*/ /*ʱֵ*/ + UINT32 startTimeoutForOutput;/*ʼʱ*/ + /* peipei.wang20111011 mod E */ + + UINT32 LocalDevName; + UINT8 ret = 0; + UINT8 chCurProcItemSrc = 0; /*ǰҪԪصԴ ITEMSRC_BOTH (ݶк·) 0x17;ITEMSRC_DATAQUEUE (ݶ) 0x33;ITEMSRC_LNKMNGR(·) 0x55*/ + struc_Lnk_Mngr *pCurProc_Lnk = NULL; /*·еǰĵ·ָ,ָ룬ʵ*/ + struc_OutputDataBuff *pLastDataBuffItem = NULL; /*ʾһδݴ洢Ԫָ*/ + struc_OutputDataBuff *pCurDataBuffItem = NULL; /*ʾǰݴ洢Ԫָ*/ + UINT32 nNumsPrtclSnd = 0; /*Эݵĸ(ֽΪλ)*/ + struc_Unify_Info *pUnifyInfoForOutput = pUnifyInfo; /*SFPṹ*/ + + if(pUnifyInfo == NULL) + { + return ret; + } + else + {} + +#ifdef SWAP_CRC + ShortToChar(0u, &pUnifyInfoForOutput->SwapCrcs[0]); /**/ +#endif + + blNeedToInit = 1;/*Ҫʼ*/ + /*豸ֵ*/ + LocalDevName = TypeIdToName(pUnifyInfoForOutput->LocalType,pUnifyInfoForOutput->LocalID); + nNumsPrtclSnd = 8;/*Э֡ȳʼ,ӵλʼд*/ + + /* peipei.wang20111011 mod S */ + /*ɾģԳʱʱ䣬׷ӻȡʼʱ*/ + /*AbsTimeoutForOutput = GetTick(pUnifyInfoForOutput) + pUnifyInfoForOutput->OutputTimeout;*/ + /*ȡʼʱ*/ + startTimeoutForOutput = GetTick(pUnifyInfoForOutput); + /* peipei.wang20111011 mod E */ + + DSUNumNodes = dsuGetObjNum(pUnifyInfoForOutput); /*ݿнڵ*/ +#ifdef PRTCL_RECORD_ERR_ASC + /*ǰTick࿪ʼ*/ + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"Output: "); +#endif +#ifdef PRTCL_RECORD_DATA_ASC + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,(UINT32)0); +#endif +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize," "); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"LName:"); + PrintFileHex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + &pUnifyInfoForOutput->LocalType,1); + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)pUnifyInfoForOutput->LocalID); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,0x03); + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->LocalType); + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + pUnifyInfoForOutput->LocalID); + +#endif + + + /*鳤Ⱥ鳤0*/ + for(i = 0;i < 8; i++) + { + pUnifyInfoForOutput->PrtclSndBuff[i] = 0; + } + + /*ݴݶжȡ䵽ݻȥ*/ + if( Queue2Buff(pUnifyInfoForOutput) == -1)/*ʧܣش*/ + { + ret = 1; + return ret; + } + else + { + /*ɹ*/ + } + ResultofGet = GetNextItem2Proc(blNeedToInit, &chCurProcItemSrc, &pCurProc_Lnk, &pLastDataBuffItem, &pCurDataBuffItem, pUnifyInfoForOutput); + if(ResultofGet < 0)/**/ + { + ret = 1; + return ret; + } + else + { + /*õһȷ*/ + } + + while(1)/*ǰĴԪزΪ,˵Ҫ,˵*/ + { + /* peipei.wang20111011 mod S */ + /*ɾʱжϣ׷Ϊǰʱ - ʼʱģִʱ޵ж*/ + /*if(GetTick(pUnifyInfoForOutput) < AbsTimeoutForOutput)*/ + if(IsTimeOut(GetTick(pUnifyInfoForOutput),startTimeoutForOutput,pUnifyInfoForOutput->OutputTimeout) == 0) + /* peipei.wang20111011 mod E */ + { + /*ݱnametypeidݿлϢ*/ + + if(ResultofGet != 0) + { + blNeedToInit = 0;/*Ҫʼü*/ + /* wangpeipei 20120306 Add S */ + + /* wangpeipei 20120306 Add E */ + switch(chCurProcItemSrc)/*ݵǰҪͨŶԴз*/ + { + + case ITEMSRC_DATABUFF:/*ֻݻ֣·޴˶*/ + if(pCurDataBuffItem->DataCycleNum == *pUnifyInfoForOutput->CycleNum)/*µ,˵Ҫ뽨*/ + { + + if(dsuIsLnkLegal(pUnifyInfoForOutput,pCurDataBuffItem->DevName,&Role)) + {/*Ϸ*/ + if(Role == ROLE_SPON)/*Ϊ*/ + { + /*·Ӵ·൱ԭ·֮ǰһ·pCurProc_LnkǵǰҪͨŶӦ·Ľڵ*/ + /*·ڵ㣬أһ֡*/ + pCurProc_Lnk = InsertLnk(pCurDataBuffItem->DevName,pUnifyInfoForOutput); + if(pCurProc_Lnk == NULL) + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|LNKMANAGE_POP); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|LNKMANAGE_POP); + +#endif + + } + else + { + /*·״̬ΪwConAck¼кţ*/ + pCurProc_Lnk->Lnk_Info.lLocalSN = pUnifyInfoForOutput->RadamSN; + pCurProc_Lnk->Lnk_Info.chStatus = STATUS_WCONACK; + /*¼RFCʼк*/ + pCurProc_Lnk->Lnk_Info.RfcSN = pUnifyInfoForOutput->RadamSN; + BuildFrame(FRAME_RFC, pCurDataBuffItem, pCurProc_Lnk, &nNumsPrtclSnd, pUnifyInfoForOutput);/*֯RFC֡*/ + /*ԭǰҪ·ʹĽͬɾһ,ԱGetNextItem2Procͳһ*/ + pCurProc_Lnk = pCurProc_Lnk->NextNode; + } + } + else + {} + }/*Ϸκβ*/ + else + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"W:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + WARN|OUTPUT|OBJ_ILLEAGL|ERROR_NULL); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray,pUnifyInfoForOutput->RecordArraySize, + WARN|OUTPUT|OBJ_ILLEAGL|ERROR_NULL); +#endif + + } + } + else/*,ɾڵ*/ + { + /*ɾڵݻԶ˽ڵǰڵ*/ + pCurDataBuffItem = Delete_OutputDataBuff(pLastDataBuffItem, pCurDataBuffItem, pUnifyInfoForOutput); + if(pCurDataBuffItem == NULL_ITEM) + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_PUSH); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|OUTPUT_LNK_PUSH); + +#endif + + + ret = 1; + return ret; + } + else + {} + } + break; + case ITEMSRC_LNKMNGR: /*ֻ·дڣݻв:ΪݻвڵIJѾGetNextItem2Proc, + Ӧ·״̬в,˿Բ߶вһµĴ*/ + case ITEMSRC_BOTH: /*߶ʱ,Ҫ·״״̬ۺϿ*/ + switch(pCurProc_Lnk->Lnk_Info.chStatus)/*·״̬*/ + { + case STATUS_DATA:/*״̬*/ + /*кҪй0*/ + if( (pCurProc_Lnk->Lnk_Info.lLocalSN + 1) == 0 ) + { + pCurProc_Lnk->Lnk_Info.lLocalSN = 1; + } + else + { + pCurProc_Lnk->Lnk_Info.lLocalSN = (pCurProc_Lnk->Lnk_Info.lLocalSN + 1); + } + switch(pCurDataBuffItem->DataStatus)/*ݴ洢ռ״̬*/ + { + case SENT:/*Ѿ*/ + /*֯IDLE֡*/ + BuildFrame(FRAME_IDLE, pCurDataBuffItem, pCurProc_Lnk, &nNumsPrtclSnd, pUnifyInfoForOutput); + break; + case NEED2SEND: + /*ݵǰݴ洢ռ齨DATA֡*/ + BuildFrame(FRAME_DATA, pCurDataBuffItem, pCurProc_Lnk, &nNumsPrtclSnd, pUnifyInfoForOutput); + pCurDataBuffItem->DataStatus = SENT; + break; + default: + break; + } + break; + case STATUS_HALT:/*ͨж״̬*/ + if(pCurProc_Lnk->Lnk_Info.chRole == ROLE_SPON)/*Ϊ*/ + { + /*˵¶һǼⷢ𷽶״*/ + for( i = 0;i < DSUNumNodes;i++)/*ҶӦͼϢ*/ + {/*ǵԭȴӿյλÿʼд,Ѿй·䵥Ԫ,·䵥Ԫ*/ + if (pUnifyInfoForOutput->NumBuildLink[i].DevName == 0x00)/*˵ǿհ׵Ԫ*/ + { + pUnifyInfoForOutput->NumBuildLink[i].DevName = pCurDataBuffItem->DevName; + pUnifyInfoForOutput->NumBuildLink[i].nTotalNums_DuanLian++;/*ۻ+1*/ + break;/**/ + } + else + { + /**/ + } + if (pUnifyInfoForOutput->NumBuildLink[i].DevName == pCurDataBuffItem->DevName)/*ҵȵļ*/ + { + pUnifyInfoForOutput->NumBuildLink[i].nTotalNums_DuanLian++;/*ۻ+1*/ + break; + } + else + { + /*ûҵ*/ + } + } + /*·״̬ΪwConAck¼к,½ճʱ*/ + pCurProc_Lnk->Lnk_Info.lLocalSN = pUnifyInfoForOutput->RadamSN; + pCurProc_Lnk->Lnk_Info.chStatus = STATUS_WCONACK; + pCurProc_Lnk->Lnk_Info.chNoDataRcvCycle = 0; + /*¼RFCʼк*/ + pCurProc_Lnk->Lnk_Info.RfcSN = pUnifyInfoForOutput->RadamSN; + /*֯RFC֡*/ + BuildFrame(FRAME_RFC, pCurDataBuffItem, pCurProc_Lnk, &nNumsPrtclSnd, pUnifyInfoForOutput); + } + else + {} + break; + case STATUS_PRECON:/*յRFC׼ACK״̬*/ + if(pCurProc_Lnk->Lnk_Info.chRole == ROLE_FLW)/*Ϊ淽*/ + { + /*Ǽ淽״*/ + /*˵¶һλǵһν,ڵһη䵥ԪʱûбҪ++*/ + for(i = 0;i < DSUNumNodes;i++)/*ҶӦͼϢ*/ + {/*ǵԭȴӿյλÿʼд,Ѿй·䵥Ԫ,·䵥Ԫ*/ + if (pUnifyInfoForOutput->NumBuildLink[i].DevName == 0x00)/*˵ǿհ׵Ԫ*/ + { + pUnifyInfoForOutput->NumBuildLink[i].DevName = pCurDataBuffItem->DevName; + pUnifyInfoForOutput->NumBuildLink[i].nTotalNums_DuanLian++;/*ۻ+1*/ + break;/**/ + } + else + { + /**/ + } + if (pUnifyInfoForOutput->NumBuildLink[i].DevName == pCurDataBuffItem->DevName)/*ҵȵļ*/ + { + pUnifyInfoForOutput->NumBuildLink[i].nTotalNums_DuanLian++;/*ۻ+1*/ + break; + } + else + { + /*ûҵ*/ + } + } + /*·״̬ΪDATA¼кţ*/ + pCurProc_Lnk->Lnk_Info.lLocalSN = pUnifyInfoForOutput->RadamSN; + pCurProc_Lnk->Lnk_Info.chStatus = STATUS_DATA; + /*¼ACK֡ʼк*/ + pCurProc_Lnk->Lnk_Info.AckSN = pUnifyInfoForOutput->RadamSN; + /*RFC齨ACK֡*/ + BuildFrame(FRAME_ACK, pCurDataBuffItem, pCurProc_Lnk, &nNumsPrtclSnd, pUnifyInfoForOutput); + } + else + { + /*Ϊ𷽣*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ROLE_STATUS_CONFLICT|ERROR_NULL); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ROLE_STATUS_CONFLICT|ERROR_NULL); + +#endif + + } + break; + case STATUS_WCONACK: /*ȴACK״̬*/ + /*ҪACKǷʱжǷҪؽ*/ + if( pCurProc_Lnk->Lnk_Info.chNoDataRcvCycle >= pCurProc_Lnk->Lnk_Info.nACKTOut ) + {/*½*/ + if(pCurProc_Lnk->Lnk_Info.chRole != ROLE_SPON)/*Ƿδ֪*/ + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ROLE_STATUS_CONFLICT|ERROR_NULL); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ROLE_STATUS_CONFLICT|ERROR_NULL); + +#endif + + ret = 1; + return ret;/**/ + } + else + { + /*Ƿ𷽣ִIJ*/ + } + /*·״̬ΪwConAck¼к,½ճʱ*/ + pCurProc_Lnk->Lnk_Info.lLocalSN = pUnifyInfoForOutput->RadamSN; + pCurProc_Lnk->Lnk_Info.chStatus = STATUS_WCONACK; + pCurProc_Lnk->Lnk_Info.chNoDataRcvCycle = 0; + /*¼RFCʼк*/ + pCurProc_Lnk->Lnk_Info.RfcSN = pUnifyInfoForOutput->RadamSN; + /*֯RFC֡*/ + BuildFrame(FRAME_RFC, pCurDataBuffItem, pCurProc_Lnk, &nNumsPrtclSnd, pUnifyInfoForOutput); + } + else + { + /*ûгʱ*/ + } + break; + default: + break; + } + break; + default: + break; + } + + ResultofGet = GetNextItem2Proc(blNeedToInit, &chCurProcItemSrc, &pCurProc_Lnk, &pLastDataBuffItem, &pCurDataBuffItem, pUnifyInfoForOutput); + if(ResultofGet < 0) /*Ϊһεѭ׼*/ + { + ret = 1; + return ret; + } + else + { + /*õһȷ*/ + } + } + else + { + break;/*ȡϣѭ*/ + } + } + else + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|TIMEOUT); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|TIMEOUT); + +#endif + + break; + } + } + /*ݳ,λȽ*/ + LongToChar( (UINT32)(nNumsPrtclSnd - 8),temp_char); + /*ݳ0*/ + pUnifyInfoForOutput->PrtclSndBuff[4] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[5] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[6] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[7] = temp_char[3]; + + /*·Ϣ*/ + CurFillLnk = pUnifyInfoForOutput->LnkHead;/*λ·ͷָ*/ + /*¼¼*/ +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"Links:\n"); +#endif + while (CurFillLnk != NULL) + { + if((pUnifyInfoForOutput->PrtclSndBuffSize - nNumsPrtclSnd) < LNKFRAMELEN) + { + /*¼¼*/ +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"E:"); + PrintFileU16Hex(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|ARRAY_FULL); + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"\n"); + +#endif +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArray2ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + ERR|OUTPUT|ERROR_NULL|ARRAY_FULL); + +#endif + + /*֡*/ + LongToChar( (UINT32)(nNumsPrtclSnd - 4),temp_char);/*ݳȵĸֽ*/ + /*鳤Ȳ¼ij*/ + pUnifyInfoForOutput->PrtclSndBuff[0] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[1] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[2] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[3] = temp_char[3]; + ret = 1; + return ret; + } + else + { + /*ֽȷ*/ + } + /*ض·*/ + FillLnkMngr_into_PrtclSnd(CurFillLnk, &nNumsPrtclSnd, pUnifyInfoForOutput); + /*¼¼,·״̬Ϣ*/ + /*ǰ·Ľڵһڵ*/ + CurFillLnk = CurFillLnk->NextNode; + } + /*֡*/ + LongToChar( (UINT32)(nNumsPrtclSnd - 4),temp_char);/*ݳȵֽ*/ + pUnifyInfoForOutput->PrtclSndBuff[0] = temp_char[0]; + pUnifyInfoForOutput->PrtclSndBuff[1] = temp_char[1]; + pUnifyInfoForOutput->PrtclSndBuff[2] = temp_char[2]; + pUnifyInfoForOutput->PrtclSndBuff[3] = temp_char[3]; + /*¼¼*/ +#ifdef PRTCL_RECORD_DATA_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"wh_len:"); + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)(nNumsPrtclSnd - 4)); + PrintFilec(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,' '); + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,(UINT32)0); + PrintFilec(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,'\n'); +#endif + +#ifdef PRTCL_RECORD_SIMPLIFY_BIN + PrintRecArrayByte(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + 0xE0); + /*鳤*/ + PrintRecArray4ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + nNumsPrtclSnd - 4); + /*ݲ鳤*/ + PrintRecArray4ByteB(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + LongFromChar(&pUnifyInfoForOutput->PrtclSndBuff[4])); +#endif + +#ifdef PRTCL_RECORD_ERR_ASC + PrintFiles(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,"UByte:"); + PrintFileU32Int(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize, + (UINT32)ShortFromChar(pUnifyInfoForOutput->RecordArray)); + PrintFilec(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,'\n'); + PrintFilec(pUnifyInfoForOutput->RecordArray, pUnifyInfoForOutput->RecordArraySize,'\n'); +#endif + + ret = 1; + return ret; +} + +/* +*: SfpGetSwapData +*: ȡ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽCRC]) +* const UINT16 swapDataMaxLen 󳤶 +* struc_Unify_Info* sfpInfo SFPṹ +*: +*: +*ֵ: +*/ +void SfpGetSwapData(UINT8 swapData[], const UINT16 swapDataMaxLen, struc_Unify_Info* sfpInfo) +{ + UINT16 swapDataLen = 0u; /*λ*/ + UINT32 allLen = 0u; /*ܳ*/ + UINT8* outAppData = NULL; /*Ӧ*/ + UINT32 outAppIdx = 0u; /*Ӧλ*/ + UINT16 pkgLen = 0u; /**/ + UINT8 isBreak = 0u; /*Ƿ˳*/ + UINT8* record = NULL; /*־*/ + UINT16 recordSize = 0u; /*־鳤*/ + + if ((NULL != swapData) && (NULL != sfpInfo) && (2u < swapDataMaxLen)) /**/ + { + record = sfpInfo->RecordArray; + recordSize = sfpInfo->RecordArraySize; + PrintRecArrayByte(record, recordSize, 0xE1u); + + ShortToChar(0u, &swapData[0]); /**/ + swapDataLen += 2u; + +#ifdef DUAL_CRC + /*PrtclSndBuffʽ:4ֽܳ(Ӧú·)+4ֽӦó+N[2ֽڳ+1ֽЭ+2ֽĿĵַ+2ֽԤ+]+·*/ + allLen = LongFromChar(&sfpInfo->PrtclSndBuff[4]); + if (0u < allLen) /**/ + { + outAppData = &sfpInfo->PrtclSndBuff[8]; /*Ӧݿʼַ*/ + while (outAppIdx < allLen) /*Ӧ*/ + { + pkgLen = 2u + ShortFromChar(&outAppData[outAppIdx]); + if ((34u <= pkgLen) && ((outAppIdx + pkgLen) <= allLen)) /*ȴڵ(7ֽͷ+27ֽ֡ʽ),ҵǰӦλüӳСڵӦó,Ϸ*/ + { + if ((swapDataLen + 4u) <= swapDataMaxLen) /*пռ*/ + { + if (0u == sfpInfo->CpuId) /*CPU0 CRC*/ + { + CommonMemCpy(&swapData[swapDataLen], 4u, &outAppData[outAppIdx + pkgLen - 8u], 4u); + } + else /*CPU1 CRC*/ + { + CommonMemCpy(&swapData[swapDataLen], 4u, &outAppData[outAppIdx + pkgLen - 4u], 4u); + } + swapDataLen += 4u; /*ۼӽݳ*/ + outAppIdx += pkgLen; /*ƫ±*/ + } + else /*޿ռ*/ + { + PrintRecArrayByte(record, recordSize, 4u); + PrintRecArray2ByteB(record, recordSize, swapDataLen); + PrintRecArray2ByteB(record, recordSize, swapDataMaxLen); + + isBreak = 1u; + } + } + else /*ȷǷ*/ + { + PrintRecArrayByte(record, recordSize, 3u); + PrintRecArray2ByteB(record, recordSize, pkgLen); + PrintRecArray4ByteB(record, recordSize, outAppIdx); + PrintRecArray4ByteB(record, recordSize, allLen); + + isBreak = 1u; + } + if (1u == isBreak) /*˳*/ + { + break; + } + } + if (0u == isBreak) /**/ + { + ShortToChar(swapDataLen - 2u, &swapData[0]); /*ó*/ + } + } + else + { + PrintRecArrayByte(record, recordSize, 2u); + PrintRecArrayByte(record, recordSize, 0u); + } +#else +#ifdef SWAP_CRC + swapDataLen = 2u + ShortFromChar(&sfpInfo->SwapCrcs[0]); + if (swapDataLen <= swapDataMaxLen) /*пռ,CRC*/ + { + CommonMemCpy(&swapData[0], swapDataLen, &sfpInfo->SwapCrcs[0], swapDataLen); + } + else + { + PrintRecArrayByte(record, recordSize, 1u); + PrintRecArray2ByteB(record, recordSize, swapDataLen); + PrintRecArray2ByteB(record, recordSize, swapDataMaxLen); + } +#endif +#endif + } +} + +/* +*: SfpSetSwapData +*: ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽCRC]) +* struc_Unify_Info* sfpInfo SFPṹ +*: +*: +*ֵ: +*/ +void SfpSetSwapData(UINT8 swapData[], struc_Unify_Info* sfpInfo) +{ + /*PrtclSndBuffʽ:4ֽܳ(Ӧú·)+4ֽӦó+N[2ֽڳ+1ֽЭ+2ֽĿĵַ+2ֽԤ+]+·*/ + SfpSetSwapDataForOut(swapData, &sfpInfo->PrtclSndBuff[8], sfpInfo); +} + +/* +*: SfpSetSwapDataForOut +*: ָ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽCRC]) +* UINT8 outData[] ָ +* struc_Unify_Info* sfpInfo SFPṹ +*: +*: +*ֵ: +*/ +void SfpSetSwapDataForOut(UINT8 swapData[], UINT8 outData[], struc_Unify_Info* sfpInfo) +{ + UINT16 swapDataLen = 0u; /*CRC*/ + UINT32 allLen = 0u; /*ܳ*/ + UINT8 dstNum = 0u; /*ĿĵַCRC*/ + UINT8 i = 0u; /*ѭ*/ + UINT32 outAppIdx = 0u; /*Ӧλ*/ + UINT8* outAppData = NULL; /*Ӧ*/ + UINT16 pkgLen = 0u; /**/ + UINT8* record = NULL; /*־*/ + UINT16 recordSize = 0u; /*־鳤*/ + + if ((NULL != swapData) && (NULL != outData) && (NULL != sfpInfo)) /**/ + { + record = sfpInfo->RecordArray; + recordSize = sfpInfo->RecordArraySize; + PrintRecArrayByte(record, recordSize, 0xE2u); + + swapDataLen = ShortFromChar(&swapData[0]); + if ((0u < swapDataLen) && (0u == (swapDataLen % 4u))) /*ȺϷ*/ + { + /*PrtclSndBuffʽ:4ֽܳ(Ӧú·)+4ֽӦó+N[2ֽڳ+1ֽЭ+2ֽĿĵַ+2ֽԤ+]+·*/ + allLen = LongFromChar(&sfpInfo->PrtclSndBuff[4]); + if (0u < allLen) /**/ + { + outAppData = &outData[0]; + dstNum = swapDataLen / 4u; + for (i = 0u; i < dstNum; i++) + { + pkgLen = 2u + ShortFromChar(&outAppData[outAppIdx]); +#ifdef DUAL_CRC + if ((34u <= pkgLen) && ((outAppIdx + pkgLen) <= allLen)) /*ȴڵ(7ֽͷ+27ֽ֡ʽ),ҵǰӦλüӳСڵӦó,Ϸ*/ +#else + if ((30u <= pkgLen) && ((outAppIdx + pkgLen) <= allLen)) /*ȴڵ(7ֽͷ+23ֽ֡ʽ),ҵǰӦλüӳСڵӦó,Ϸ*/ +#endif + { +#ifdef DUAL_CRC + if (0u == sfpInfo->CpuId) /*CPU0,CPU1 CRC*/ + { + CommonMemCpy(&outAppData[outAppIdx + pkgLen - 4u], 4u, &swapData[2u + 4u * i], 4u); + } + else /*CPU1,CPU0 CRC*/ + { + CommonMemCpy(&outAppData[outAppIdx + pkgLen - 8u], 4u, &swapData[2u + 4u * i], 4u); + } +#else +#ifdef SWAP_CRC + CommonMemCpy(&outAppData[outAppIdx + pkgLen - 4u], 4u, &swapData[2u + 4u * i], 4u); +#endif +#endif + + outAppIdx += pkgLen; + } + else /*ȷǷ*/ + { + PrintRecArrayByte(record, recordSize, 3u); + PrintRecArray2ByteB(record, recordSize, pkgLen); + PrintRecArray4ByteB(record, recordSize, outAppIdx); + PrintRecArray4ByteB(record, recordSize, allLen); + + break; + } + } + } + else + { + PrintRecArrayByte(record, recordSize, 2u); + PrintRecArrayByte(record, recordSize, 0u); + } + } + else + { + PrintRecArrayByte(record, recordSize, 1u); + PrintRecArray2ByteB(record, recordSize, swapDataLen); + } + } +} \ No newline at end of file diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtcl_Output.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtcl_Output.h new file mode 100644 index 0000000..d3ee482 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpPrtcl_Output.h @@ -0,0 +1,159 @@ + +/******************************************************************************* +* ļ Prtcl_Output.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* ͨЭԪģͷļ +* ʹע + +* ޸ļ¼ + 2008.7.10 + 1.޸BuildOutputDataԼPrtcl_OutputInitialβ +*******************************************************************************/ + +#ifndef _SFPPRTCL_OUTPUT_H +#define _SFPPRTCL_OUTPUT_H + +#include "sfpplatform.h" +#include "sfpLinkManage.h" +#include "sfpDeclare.h" +#include "CommonQueue.h" +#include "Convert.h" +#include "CRC32.h" +#include "dsuRelatedDeal.h" +#include "sfpPrtclCommon.h" + +#define NULL_ITEM ((struc_OutputDataBuff*)0x00000001) /*òڵķӦͬڿսڵ*/ + + + +#ifdef __cplusplus +extern "C" { +#endif +/************************************************************************/ +/* ݴ洢ԪIJ */ +/************************************************************************/ + +/* +*: Insert_OutputDataBuff +*: ڵ֮һڵ,ӶջƳһԪ洢 +*: struc_OutputDataBuff* pLastNode ǰڵ +* struc_OutputDataBuff* pCurNode ǰڵ +* UINT32 DevName 豸type+IDָԷģ +* UINT8 data_status ״̬(ѷ δ) +* UINT16 data_len ݳ(ָǴݵij) +* UINT8 data[] +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: +*: +*ֵ: ɹصǰָ,򷵻ش(ؿռΪ) +*/ +static struc_OutputDataBuff* Insert_OutputDataBuff(struc_OutputDataBuff *pLastNode, struc_OutputDataBuff *pCurNode, UINT32 DevName, UINT8 data_status, UINT16 data_len, UINT8 data[], struc_Unify_Info *pUnifyInfoForOutput); + +/* +*: Delete_OutputDataBuff +*: ǰڵͱڵ,ɾڵ +*: struc_OutputDataBuff *pLastNode ǰڵ +* struc_OutputDataBuff *pCurNode ǰڵ +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: +*: +*ֵ: ɾɹеǰڵһڵ(NULLҲȷ),󷵻ΪNULL_ITEM +*/ +static struc_OutputDataBuff* Delete_OutputDataBuff(struc_OutputDataBuff *pLastNode, struc_OutputDataBuff *pCurNode, struc_Unify_Info *pUnifyInfoForOutput); + +/************************************************************************/ +/* Э */ +/************************************************************************/ + + +/****************************************************************************************** +* : Эijʼ +* : +* : struc_Unify_Info *pUnifyInfo óʼӦͳһṹ +* : +* ȫֱ : UINT32 nNumsPrtclSnd Эݵĸ(ֽΪλ) + struc_Lnk_Mngr* pCurProc_Lnk ·еǰĵ·ָ,ָ룬ʵ + UINT8 chCurProcItemSrc ǰҪԪصԴ + struc_OutputDataBuff *pLastDataBuffItem ʾǰݴ洢Ԫָ + struc_OutputDataBuff *pCurDataBuffItem ʾһδݴ洢Ԫָ +* ֵ : ʼɹ1 ʧܷ0 +*******************************************************************************************/ +UINT8 Prtcl_OutputInitial(struc_Unify_Info *pUnifyInfo); + +/* +*: DeQueue_OutputData +*: ӶȡݷڽṹԪ +*: struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: +*: struc_AppOutput* pOut Ӧõ1,ָ +*ֵ: 1:ɹ;0ʧ +*/ +static INT8 DeQueue_OutputData(struc_AppOutput *pOut, struc_Unify_Info *pUnifyInfoForOutput); + +/* +*: Queue2Buff +*: ݶе䵽صݻڵȥ +*: struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: +*: +*ֵ: 1:ɹ;-1ʧ +*/ +static INT8 Queue2Buff(struc_Unify_Info *pUnifyInfoForOutput); + +/* +*: GetNextItem2Proc +*: õҪһͨŶ:˼·Ǵݻʹ·зֱȡ +* δDeviceNameֵĽڵ㣬ȻȽȡDeviceNameֵѡֵĽڵΪϲ +* ѭд˴ҪĶ󡣴ԭΪͨŶֻ·еĶǣ +* ·ӶӦڵ㣨ֻЭ뵥ԪյRFCˣ˶ֻݻдʱ +* Ȳڴ˻ڶ·κ޸ģӦõһҪijݻӦɾл֣˶ +* ·кݻжʱҲٴ˻ڶ·ݻཻһֽ +* д˻ڵĴȫֱʽӳһڡ +* зֵҪʾܷȡЧ󣬶ʵҪĶͨ +*: UINT8 NeedToInit ǷҪʼ,ҪΪΪ +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: UINT8 *chCurProcItemSrc ǰҪԪصԴ +* struc_Lnk_Mngr **pCurProc_Lnk ǰ· +* struc_OutputDataBuff **pLastDataBuffItem; ʾǰݴ洢Ԫָ +* struc_OutputDataBuff **pCurDataBuffItem; ʾһδݴ洢Ԫָ +*: +*ֵ: ɹطǸֵнڵҪʱ1޽ڵҪʱ0,ʧܷ-1 +*/ +static INT8 GetNextItem2Proc(UINT8 NeedToInit, UINT8 *chCurProcItemSrc, struc_Lnk_Mngr **pCurProc_Lnk, struc_OutputDataBuff **pLastDataBuffItem, struc_OutputDataBuff **pCurDataBuffItem, struc_Unify_Info *pUnifyInfoForOutput); + +/* +*: BuildFrame +*: ֡ͣ·ԼӦݣ֡ʽӦ֡ +*: UINT8 frametype ֡ +* struc_OutputDataBuff* pSrcData ӦݴŻ +* struc_Lnk_Mngr* pSrcLnk ·е· +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: UINT32 *nNumsPrtclSnd ± +*: +*ֵ: 1:ɹ;0ʧ +*/ +static INT8 BuildFrame(UINT8 frametype, struc_OutputDataBuff *pSrcData, struc_Lnk_Mngr *pSrcLnk, UINT32 *nNumsPrtclSnd, struc_Unify_Info *pUnifyInfoForOutput); + +/* +*: FillLnkMngr_into_PrtclSnd +*: ·ijһ·Ϣ䵽һάȥ +*: struc_Lnk_Mngr* CurLnk ǰ· +* struc_Unify_Info *pUnifyInfoForOutput SFPṹ +*: UINT32 *nNumsPrtclSnd ± +*: +*ֵ: 1:ɹ;0ʧ +*/ +static INT8 FillLnkMngr_into_PrtclSnd(struc_Lnk_Mngr *CurLnk, UINT32 *nNumsPrtclSnd, struc_Unify_Info *pUnifyInfoForOutput); + +#ifdef __cplusplus +} +#endif + + +#else + +#endif + diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpWindowsTimeCounter.c b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpWindowsTimeCounter.c new file mode 100644 index 0000000..d3a219d --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpWindowsTimeCounter.c @@ -0,0 +1,35 @@ +/************************************************************************ +* ļWindowsTimeCounter.c +* ļļΪWindowsƽ̨»ȡǰʱ䣨msΪλԴļ + ЭڲʱʹãʽWindowsƽ̨Ӧṩ + ȡǰʱĺ +* ʱ䣺2008.07.29 +************************************************************************/ + +#include "sfpWindowsTimeCounter.h" + +#if CBTC_WINDOWS + +/* +õǰʱ䣬ܵ +ڣ + LARGE_INTEGER CounterStartValue ʱʼ +: + ǰʱ㣬λms +ֵ + ǰʱ㣬λms +*/ +UINT32 GetCurTime(LARGE_INTEGER CounterStartValue) +{ + /*嶨ʱ*/ + LARGE_INTEGER CounterFreq; /*Ƶ*/ + LARGE_INTEGER CounterEndValue; /*ֵյ*/ + UINT32 TimeInterval;/*ʱ*/ + /*ʼʱ*/ + QueryPerformanceFrequency(&CounterFreq);/*Ƶ*/ + QueryPerformanceCounter(&CounterEndValue);/*ȡڶʱ*/ + TimeInterval = (UINT32) ((FLOAT64)(CounterEndValue.QuadPart - CounterStartValue.QuadPart) / (FLOAT64)(CounterFreq.QuadPart) * 1000); + return TimeInterval; /*ﵽʱ䷵棬Ϊ*/ +} + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpWindowsTimeCounter.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpWindowsTimeCounter.h new file mode 100644 index 0000000..97bc5ed --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpWindowsTimeCounter.h @@ -0,0 +1,42 @@ + +/************************************************************************ +* ļWindowsTimeCounter.h +* ļļΪWindowsƽ̨»ȡǰʱ䣨msΪλͷļ + ЭڲʱʹãʽWindowsƽ̨Ӧṩ + ȡǰʱĺ +* ʱ䣺2008.07.29 +************************************************************************/ + +#ifndef _SFPWINDOWSTIMECOUNTER_H_ +#define _SFPWINDOWSTIMECOUNTER_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "CommonTypes.h" + +#if CBTC_WINDOWS +#include + + LARGE_INTEGER Time_StartPoint; /*ʱ,¼Э鿪ʱ*/ + +/* +õǰʱ䣬ܵ +ڣ + LARGE_INTEGER CounterStartValue ʱʼ +: + ǰʱ㣬λms +ֵ + ǰʱ㣬λms +*/ +UINT32 GetCurTime(LARGE_INTEGER CounterStartValue); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpplatform.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpplatform.h new file mode 100644 index 0000000..f9f1319 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/sfpplatform.h @@ -0,0 +1,261 @@ + +/******************************************************************************* +* ļ platform.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2008.07.29 +* +* ļΪЭΪӦṩͷļ + 1. ЭΪӦṩĺڴͷļ + 2. ļͳһṹĶ + 3. Windowsƽ̨ҪӦṩȡǰʱֵĺЭҪ + ˺޸PrtclCommon.hļеGetTick() +* ʹע + +* ޸ļ¼ + 1.08.9.15 + ṹеݿָԼʱָͶconst UINT8*const UINT32 * + 2009.1.20޸ļ¼ + 1.ɾͬƽ̨ͷļ + 2.ɾ궨; + 3.ProtclReceive + 4.ͳһṹ CommBufferBlueNetNoDataCycleRedNetNoDataCycle + 5.ͳһṹ潫CycleNumԭunsigned longΪunsigned long* + + 2009.1.21޸ļ¼ + 1.ɾԭȵԼຯ char Prtcl_Receive(struc_Unify_Info *pUnifyInfo);Լunsigned char Redundancy(struc_Unify_Info *pUnifyInfo); + ŵļ + 2.ͳһṹеOutnetQueueSizePrtclSndBuffSizePrtclRcvSizeDataToAppSizeOutputDataQueueSizeshortΪlong + + 2009-8-27 14:53:00޸ļ¼ + 1.ɾͳһṹNetStatusANetStatusBPtrclRcvBlueNetNoDataCycleRedNetNoDataCycle + 2.޸ͣʹCommonTypes.hеĶ + 2012-8-15 15:54:00޸ļ¼ + 1.SFPЭ汾ź궨 +*******************************************************************************/ + +#ifndef _SFPPLATFORM_H +#define _SFPPLATFORM_H + +#include "sfpPrtclStruct.h" +#include "CommonQueue.h" +#include "sfpConfig.h" + + +/* SFPЭ汾Ŷ */ +#define SFPCODE_VER_PRODUCT_NO 66 +#define SFPCODE_VER_MODULE_NO 1 +#define SFPCODE_VER_MAIN_VER 2 +#define SFPCODE_VER_SUB_VER 1 + +/**************************ϵͳõIJ**********************************/ + +/******************ͳһṹ*********************/ +typedef struct Unify_Info +{ + UINT8 CpuId; /*CPU ID,˫CPUCRC*/ + UINT8 LocalID; /*豸IDӦðĵڳʼʱд*/ + UINT8 LocalType; /*豸typeӦðĵڳʼʱд*/ + UINT32 *CycleNum; /*ںţӦðĵÿڿʼʱд*/ + UINT32 RadamSN; /*Ӧðĵÿڿʼʱд*/ + UINT16 RedundTimeout; /*ģִʱޣλmsΪִеʱ䣩Ӧðĵڳʼʱд*/ + UINT16 OutputTimeout; /*ģִʱޣλmsΪִеʱ䣩Ӧðĵڳʼʱд*/ + struct S_DuanLianInfo *NumBuildLink; /*ṹ壬οṹ嶨ĵ˵*/ + struc_InputBuffer *InputBufferHead; /*ͷ*/ + struc_Lnk_Mngr *LnkHead; /*·ͷ*/ + struc_OutputDataBuff *OutputDataBuffHead; /*ͷ*/ + UINT8 MaxNumLink; /*ͬʱͨŵ·Ӧðĵڳʼʱд*/ + UINT8 MaxNumPerCycle; /*һÿЧݣӦðĵڳʼʱд*/ + UINT16 InputSize; /*һ֡ӦݳȣӦðĵڳʼʱд*/ + UINT16 OutputSize; /*һ֡ӦݳȣӦðĵڳʼʱд*/ + UINT8 *DataAfterReduntancy; /*ģ鴦ģ*/ + UINT32 PrtclRcvSize; /*DataAfterReduntancyռ*/ + UINT8 *RecordArray; /*¼*/ + UINT16 RecordArraySize; /*¼С*/ + UINT8 *PrtclSndBuff; /*ģij*/ + UINT32 PrtclSndBuffSize; /*ģij鳤*/ + QueueStruct DataToApp; /*ЭӦõݶ*/ + UINT32 DataToAppSize; /*ЭӦõݶг*/ + QueueStruct OutputDataQueue; /*ӦøЭݶ*/ + UINT32 OutputDataQueueSize; /*ӦøЭݶг*/ + QueueStruct OutnetQueueA; /*նA(->)*/ + QueueStruct OutnetQueueB; /*նB(->)*/ + UINT32 OutnetQueueSize; /*նгȣӦðĵʼʱд*/ + StackElement LnkStack; /*·ջ*/ + StackElement InputStack; /*һάջ*/ + StackElement OutputStack; /*һάջ*/ + UINT8* DataBase; /*ݿָ*/ + const UINT32 *TimeCounter; /*ʱڴģļʱ*/ + UINT8 *CommBuffer; /*Эڲʹãʱ09*/ + UINT16 NetsRecvPkgNumsLen; /*յ鳤*/ + SfpNetsRecvPkgNum* NetsRecvPkgNums; /*յ*/ +#ifdef SWAP_CRC + UINT8* SwapCrcs; /*Ϣ˫CPUĸԷCRCϢ*/ +#endif + +}struc_Unify_Info; + +#ifdef __cplusplus +extern "C" { +#endif + +/********************************************************/ +/************************************************/ +/********************************************************/ + +/****************************************************************************************** +* : Эʼ + 1. ڵô˺֮ǰӦҪͳһṹInputSizeOutputSize,MaxNumLink, + MaxNumPerCycle,OutnetQueueSizeȱֵ +* : UINT8 * fileName ݵļַ +* : UINT32 inDataLen ڲ +* : UINT8 inData[] ڲ +* : struc_Unify_Info* pUnifyInfo Эͳһṹָ +* : +* ȫֱ : +* ֵ : ʼ1򷵻0 +*******************************************************************************************/ + UINT8 ProtclInit(UINT8* fileName, UINT32 inDataLen, UINT8 inData[], struc_Unify_Info* pUnifyInfo); + + + +/****************************************************************************************** +* : Э뺯 +* : +* : struc_Unify_Info* pUnifyInfo Эͳһṹָ +* : +* ȫֱ : +* ֵ : ȷ1󷵻0 +*******************************************************************************************/ +UINT8 ProtclReceive(struc_Unify_Info *pUnifyInfo); + + +/****************************************************************************************** +* : ЭԪ,ЭĹ,Ӧô֡, + ΪݱȽϵԪ׼ñ,ͬʱά· +* : +* : struc_Unify_Info* pUnifyInfo Эͳһṹָ +* : +* ȫֱ : UINT32 nNumsPrtclSnd Эݵĸ(ֽΪλ) + struc_Lnk_Mngr *pCurProc_Lnk ·еǰĵ·ָ,ָ룬ʵ* + UINT8 chCurProcItemSrc ǰҪԪصԴ ITEMSRC_BOTH (ݶк·) 0x17;ITEMSRC_DATAQUEUE (ݶ) 0x33;ITEMSRC_LNKMNGR(·) 0x55 + struc_OutputDataBuff *pLastDataBuffItem ʾǰݴ洢Ԫָ + struc_OutputDataBuff *pCurDataBuffItem ʾһδݴ洢Ԫָ + struc_Unify_Info *pUnifyInfoForOutput ƽ̨ṹָ +* ֵ : ȷ1󷵻0 +*******************************************************************************************/ +UINT8 ProtclOutput(struc_Unify_Info *pUnifyInfo); + + +/****************************************************************************************** +* : ΪӦṩ·ɾڵIJɾ·ָڵ + 1. Ӧõô˺ɾӦTypeID· +* : UINT8 DestType Է豸 + UINT8 DestID Է豸ID +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹָ +* : +* ȫֱ : +* ֵ : ɹ1󷵻0 +*******************************************************************************************/ +UINT8 ProtclDeleteLnk(UINT8 DestType,UINT8 DestID,struc_Unify_Info *LnkUnifyInfo); + +/****************************************************************************************** +* : ѯ·ij·ڱڵ·״̬ + 1. Ӧø豸ͺIDѯ·д·ڵ·״̬ +* : UINT8 DestType Է豸 + UINT8 DestID Է豸ID +* : struc_Unify_Info* LnkUnifyInfo ƽ̨ṩͳһṹ +* : +* ȫֱ : +* ֵ : ָڵ·״̬󷵻0 +*******************************************************************************************/ +UINT8 ProtclCheckLnkStatus(UINT8 DestType,UINT8 DestID,struc_Unify_Info *LnkUnifyInfo ); + + + +/****************************************************************************************** +* : ˢ±ͨ·ƽ̨ӦҪ·ʾ +* : INT16 sLen_Input 鳤 + UINT8 *Input_Data_LnkMes ͷָ +* : struc_Unify_Info *LnkUnifyInfo ƽ̨ṩͳһṹ +* : +* ȫֱ : +* ֵ : 1쳣0 +*******************************************************************************************/ +UINT8 ProtclFreshLnkMngr(INT16 sLen_Input,UINT8 *Input_Data_LnkMes, struc_Unify_Info *LnkUnifyInfo ); + + + +/****************************************************************************************** +* : ͷЭPrtclInitзڴռ +* : +* : struc_Unify_Info* pUnifyInfo Эͳһṹָ +* : +* ȫֱ : +* ֵ : ȷ1 +*******************************************************************************************/ +UINT8 ProtclFreeSpace(struc_Unify_Info *pUnifyInfo); + +/* +*: ȡSFPյ +*: struc_Unify_Info* sfp sfp +* const UINT8 dstType Ŀ豸 +* const UINT8 dstId Ŀ豸ID +*: UINT16* redRecvPkgNum յ +* UINT16* blueRecvPkgNum յ +*: +*ֵ: +*/ +void ProtclGetNetsRecvPkgNum(struc_Unify_Info* sfp, const UINT8 dstType, const UINT8 dstId, UINT16* redRecvPkgNum, UINT16* blueRecvPkgNum); + +/* +*: SfpGetSwapData +*: ȡ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽCRC]) +* const UINT16 swapDataMaxLen 󳤶 +* struc_Unify_Info* sfpInfo SFPṹ +*: +*: +*ֵ: +*/ +void SfpGetSwapData(UINT8 swapData[], const UINT16 swapDataMaxLen, struc_Unify_Info* sfpInfo); + +/* +*: SfpSetSwapData +*: ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽCRC]) +* struc_Unify_Info* sfpInfo SFPṹ +*: +*: +*ֵ: +*/ +void SfpSetSwapData(UINT8 swapData[], struc_Unify_Info* sfpInfo); + +/* +*: SfpSetSwapDataForOut +*: ָ˫CPU +*: UINT8 swapData[] (2ֽڳ+N[4ֽCRC]) +* UINT8 outData[] ָ +* struc_Unify_Info* sfpInfo SFPṹ +*: +*: +*ֵ: +*/ +void SfpSetSwapDataForOut(UINT8 swapData[], UINT8 outData[], struc_Unify_Info* sfpInfo); + +/* +*: SfpDelAllLink +*: SFPɾ· +*: struc_Unify_Info* spf SFPṹ +*: +*: +*ֵ: +*/ +void SfpDelAllLink(struc_Unify_Info* spf); + +#ifdef __cplusplus +} +#endif + +#else +#endif diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/协议c和cpp转换.bat b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/协议c和cpp转换.bat new file mode 100644 index 0000000..14ee250 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp/协议c和cpp转换.bat @@ -0,0 +1,18 @@ +@echo on +if exist *.cpp goto cpptoc +if exist *.c goto ctocpp +goto end + +:cpptoc +md ..\csource +copy *.cpp ..\csource\*.c +copy *.h ..\csource\*.h +goto end + +:ctocpp +md ..\cppsource +copy *.c ..\cppsource\*.cpp +copy *.h ..\cppsource\*.h +goto end + +:end \ No newline at end of file diff --git a/TSCP/src/protocol/sfp_record_cbtc1/common_sfp_nr_config/sfpConfig.h b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp_nr_config/sfpConfig.h new file mode 100644 index 0000000..0756986 --- /dev/null +++ b/TSCP/src/protocol/sfp_record_cbtc1/common_sfp_nr_config/sfpConfig.h @@ -0,0 +1,28 @@ + +/******************************************************************************* +* ļ sfpConfig.h +* Ȩ˵ +* 汾 1.0 +* ʱ 2010.05.04 +* +* ļΪSFPЭļ +* ʹע + +* ޸ļ¼ + +*******************************************************************************/ + +#ifndef _SFPCONFIG_H +#define _SFPCONFIG_H + +/**************************Э¼궨忪**********************************/ +/*#define PRTCL_RECORD_DATA_ASC*/ /*ݲַͼ¼*/ +/*#define PRTCL_RECORD_ERR_ASC*/ /*󲿷ַͼ¼*/ + +#define PRTCL_RECORD_SIMPLIFY_BIN /*Ƽ¼*/ +#define USE_DSU_SFP /*ʹSFPѯ*/ +/*#define SWAP_CRC */ /*CRC*/ + +#else +#endif +